Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUnderground78 <underground78@users.sourceforge.net>2013-06-23 22:46:36 +0400
committerUnderground78 <underground78@users.sourceforge.net>2013-06-29 23:56:22 +0400
commitf46c1fd78e595b889bb27148a986cdbd0e4913c0 (patch)
treefbd90a5b738081dc615b1083382907cb228e6b3a
parent51e719b03f2e1ace5bf49b1512b340f278cb586e (diff)
Remove now deprecated filters.
-rw-r--r--include/IMPCVideoDecFilter.h (renamed from src/filters/transform/MPCVideoDec/IMPCVideoDecFilter.h)180
-rw-r--r--include/moreuuids.h5
-rw-r--r--mpc-hc.sln321
-rw-r--r--mpc-hc_vs2012.sln321
-rw-r--r--src/filters/Filters.h14
-rw-r--r--src/filters/parser/AviSplitter/AviFile.cpp652
-rw-r--r--src/filters/parser/AviSplitter/AviFile.h89
-rw-r--r--src/filters/parser/AviSplitter/AviSplitter.cpp988
-rw-r--r--src/filters/parser/AviSplitter/AviSplitter.def5
-rw-r--r--src/filters/parser/AviSplitter/AviSplitter.h115
-rw-r--r--src/filters/parser/AviSplitter/AviSplitter.rc108
-rw-r--r--src/filters/parser/AviSplitter/AviSplitter.vcxproj258
-rw-r--r--src/filters/parser/AviSplitter/AviSplitter.vcxproj.filters70
-rw-r--r--src/filters/parser/AviSplitter/AviSplitterSettingsWnd.cpp95
-rw-r--r--src/filters/parser/AviSplitter/AviSplitterSettingsWnd.h53
-rw-r--r--src/filters/parser/AviSplitter/IAviSplitterFilter.h30
-rw-r--r--src/filters/parser/AviSplitter/resource.h17
-rw-r--r--src/filters/parser/AviSplitter/stdafx.cpp22
-rw-r--r--src/filters/parser/AviSplitter/stdafx.h27
-rw-r--r--src/filters/parser/FLVSplitter/FLVSplitter.cpp924
-rw-r--r--src/filters/parser/FLVSplitter/FLVSplitter.def5
-rw-r--r--src/filters/parser/FLVSplitter/FLVSplitter.h96
-rw-r--r--src/filters/parser/FLVSplitter/FLVSplitter.rc102
-rw-r--r--src/filters/parser/FLVSplitter/FLVSplitter.vcxproj256
-rw-r--r--src/filters/parser/FLVSplitter/FLVSplitter.vcxproj.filters55
-rw-r--r--src/filters/parser/FLVSplitter/resource.h14
-rw-r--r--src/filters/parser/FLVSplitter/stdafx.cpp22
-rw-r--r--src/filters/parser/FLVSplitter/stdafx.h27
-rw-r--r--src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp101
-rw-r--r--src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.h47
-rw-r--r--src/filters/parser/MP4Splitter/MP4Splitter.cpp2114
-rw-r--r--src/filters/parser/MP4Splitter/MP4Splitter.def5
-rw-r--r--src/filters/parser/MP4Splitter/MP4Splitter.h107
-rw-r--r--src/filters/parser/MP4Splitter/MP4Splitter.rc104
-rw-r--r--src/filters/parser/MP4Splitter/MP4Splitter.vcxproj263
-rw-r--r--src/filters/parser/MP4Splitter/MP4Splitter.vcxproj.filters67
-rw-r--r--src/filters/parser/MP4Splitter/MP4SplitterFile.cpp63
-rw-r--r--src/filters/parser/MP4Splitter/MP4SplitterFile.h38
-rw-r--r--src/filters/parser/MP4Splitter/resource.h14
-rw-r--r--src/filters/parser/MP4Splitter/stdafx.cpp22
-rw-r--r--src/filters/parser/MP4Splitter/stdafx.h29
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaFile.cpp1595
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaFile.h593
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp1687
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaSplitter.def5
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaSplitter.h131
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaSplitter.rc102
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaSplitter.vcxproj258
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaSplitter.vcxproj.filters61
-rw-r--r--src/filters/parser/MatroskaSplitter/resource.h14
-rw-r--r--src/filters/parser/MatroskaSplitter/stdafx.cpp22
-rw-r--r--src/filters/parser/MatroskaSplitter/stdafx.h28
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitter.cpp235
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitter.def5
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitter.h62
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitter.rc102
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitter.vcxproj255
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitter.vcxproj.filters61
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitterFile.cpp431
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitterFile.h58
-rw-r--r--src/filters/parser/MpaSplitter/resource.h15
-rw-r--r--src/filters/parser/MpaSplitter/stdafx.cpp22
-rw-r--r--src/filters/parser/MpaSplitter/stdafx.h31
-rw-r--r--src/filters/parser/MpegSplitter/IMpegSplitterFilter.h50
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitter.cpp2087
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitter.def5
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitter.h148
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitter.rc115
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitter.vcxproj258
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitter.vcxproj.filters70
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitterFile.cpp1134
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitterFile.h180
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.cpp152
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.h74
-rw-r--r--src/filters/parser/MpegSplitter/resource.h24
-rw-r--r--src/filters/parser/MpegSplitter/stdafx.cpp22
-rw-r--r--src/filters/parser/MpegSplitter/stdafx.h27
-rw-r--r--src/filters/parser/OggSplitter/OggFile.cpp104
-rw-r--r--src/filters/parser/OggSplitter/OggFile.h97
-rw-r--r--src/filters/parser/OggSplitter/OggSplitter.cpp1318
-rw-r--r--src/filters/parser/OggSplitter/OggSplitter.def5
-rw-r--r--src/filters/parser/OggSplitter/OggSplitter.h206
-rw-r--r--src/filters/parser/OggSplitter/OggSplitter.rc102
-rw-r--r--src/filters/parser/OggSplitter/OggSplitter.vcxproj255
-rw-r--r--src/filters/parser/OggSplitter/OggSplitter.vcxproj.filters61
-rw-r--r--src/filters/parser/OggSplitter/resource.h14
-rw-r--r--src/filters/parser/OggSplitter/stdafx.cpp22
-rw-r--r--src/filters/parser/OggSplitter/stdafx.h27
-rw-r--r--src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp2672
-rw-r--r--src/filters/parser/RealMediaSplitter/RealMediaSplitter.def5
-rw-r--r--src/filters/parser/RealMediaSplitter/RealMediaSplitter.h366
-rw-r--r--src/filters/parser/RealMediaSplitter/RealMediaSplitter.rc102
-rw-r--r--src/filters/parser/RealMediaSplitter/RealMediaSplitter.vcxproj256
-rw-r--r--src/filters/parser/RealMediaSplitter/RealMediaSplitter.vcxproj.filters55
-rw-r--r--src/filters/parser/RealMediaSplitter/resource.h14
-rw-r--r--src/filters/parser/RealMediaSplitter/stdafx.cpp22
-rw-r--r--src/filters/parser/RealMediaSplitter/stdafx.h27
-rw-r--r--src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp2
-rw-r--r--src/filters/source/DTSAC3Source/DTSAC3Source.cpp614
-rw-r--r--src/filters/source/DTSAC3Source/DTSAC3Source.def5
-rw-r--r--src/filters/source/DTSAC3Source/DTSAC3Source.h67
-rw-r--r--src/filters/source/DTSAC3Source/DTSAC3Source.rc102
-rw-r--r--src/filters/source/DTSAC3Source/DTSAC3Source.vcxproj253
-rw-r--r--src/filters/source/DTSAC3Source/DTSAC3Source.vcxproj.filters55
-rw-r--r--src/filters/source/DTSAC3Source/resource.h14
-rw-r--r--src/filters/source/DTSAC3Source/stdafx.cpp22
-rw-r--r--src/filters/source/DTSAC3Source/stdafx.h27
-rw-r--r--src/filters/source/FLACSource/FLACSource.cpp494
-rw-r--r--src/filters/source/FLACSource/FLACSource.def5
-rw-r--r--src/filters/source/FLACSource/FLACSource.h109
-rw-r--r--src/filters/source/FLACSource/FLACSource.rc103
-rw-r--r--src/filters/source/FLACSource/FLACSource.vcxproj260
-rw-r--r--src/filters/source/FLACSource/FLACSource.vcxproj.filters55
-rw-r--r--src/filters/source/FLACSource/resource.h14
-rw-r--r--src/filters/source/FLACSource/stdafx.cpp21
-rw-r--r--src/filters/source/FLACSource/stdafx.h26
-rw-r--r--src/filters/source/FLICSource/FLICSource.cpp790
-rw-r--r--src/filters/source/FLICSource/FLICSource.def5
-rw-r--r--src/filters/source/FLICSource/FLICSource.h180
-rw-r--r--src/filters/source/FLICSource/FLICSource.rc102
-rw-r--r--src/filters/source/FLICSource/FLICSource.vcxproj250
-rw-r--r--src/filters/source/FLICSource/FLICSource.vcxproj.filters55
-rw-r--r--src/filters/source/FLICSource/resource.h14
-rw-r--r--src/filters/source/FLICSource/stdafx.cpp22
-rw-r--r--src/filters/source/FLICSource/stdafx.h27
-rw-r--r--src/filters/transform/MPCVideoDec/CpuId.cpp128
-rw-r--r--src/filters/transform/MPCVideoDec/CpuId.h56
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoder.cpp773
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoder.h161
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp390
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderH264.h67
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.cpp282
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.h62
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp330
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderVC1.h103
-rw-r--r--src/filters/transform/MPCVideoDec/FfmpegContext.cpp939
-rw-r--r--src/filters/transform/MPCVideoDec/FfmpegContext.h78
-rw-r--r--src/filters/transform/MPCVideoDec/H264RandomAccess.cpp96
-rw-r--r--src/filters/transform/MPCVideoDec/H264RandomAccess.h40
-rw-r--r--src/filters/transform/MPCVideoDec/MPCFfmpegDec.cpp59
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDec.def5
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDec.vcxproj313
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDec.vcxproj.filters137
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp2672
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h329
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDecFilter.rc166
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.cpp447
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.h102
-rw-r--r--src/filters/transform/MPCVideoDec/PODtypes.h32
-rw-r--r--src/filters/transform/MPCVideoDec/TlibavcodecExt.cpp56
-rw-r--r--src/filters/transform/MPCVideoDec/TlibavcodecExt.h47
-rw-r--r--src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.cpp208
-rw-r--r--src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.h87
-rw-r--r--src/filters/transform/MPCVideoDec/VideoDecOutputPin.cpp131
-rw-r--r--src/filters/transform/MPCVideoDec/VideoDecOutputPin.h55
-rw-r--r--src/filters/transform/MPCVideoDec/array_allocator.h49
-rw-r--r--src/filters/transform/MPCVideoDec/char_t.h291
-rw-r--r--src/filters/transform/MPCVideoDec/ffImgfmt.cpp1562
-rw-r--r--src/filters/transform/MPCVideoDec/ffImgfmt.h489
-rw-r--r--src/filters/transform/MPCVideoDec/resource.h40
-rw-r--r--src/filters/transform/MPCVideoDec/stdafx.cpp46
-rw-r--r--src/filters/transform/MPCVideoDec/stdafx.h40
-rw-r--r--src/filters/transform/MpaDecFilter/AudioHelper.cpp453
-rw-r--r--src/filters/transform/MpaDecFilter/AudioHelper.h64
-rw-r--r--src/filters/transform/MpaDecFilter/FFAudioDecoder.cpp579
-rw-r--r--src/filters/transform/MpaDecFilter/FFAudioDecoder.h70
-rw-r--r--src/filters/transform/MpaDecFilter/IMpaDecFilter.h57
-rw-r--r--src/filters/transform/MpaDecFilter/Mixer.cpp256
-rw-r--r--src/filters/transform/MpaDecFilter/Mixer.h49
-rw-r--r--src/filters/transform/MpaDecFilter/MpaDecFilter.cpp2325
-rw-r--r--src/filters/transform/MpaDecFilter/MpaDecFilter.def5
-rw-r--r--src/filters/transform/MpaDecFilter/MpaDecFilter.h197
-rw-r--r--src/filters/transform/MpaDecFilter/MpaDecFilter.rc120
-rw-r--r--src/filters/transform/MpaDecFilter/MpaDecFilter.vcxproj274
-rw-r--r--src/filters/transform/MpaDecFilter/MpaDecFilter.vcxproj.filters80
-rw-r--r--src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.cpp233
-rw-r--r--src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.h101
-rw-r--r--src/filters/transform/MpaDecFilter/PaddedArray.h47
-rw-r--r--src/filters/transform/MpaDecFilter/resource.h23
-rw-r--r--src/filters/transform/MpaDecFilter/stdafx.cpp22
-rw-r--r--src/filters/transform/MpaDecFilter/stdafx.h27
-rw-r--r--src/filters/transform/Mpeg2DecFilter/IMpeg2DecFilter.h65
-rw-r--r--src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp2439
-rw-r--r--src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.def5
-rw-r--r--src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.h329
-rw-r--r--src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.rc124
-rw-r--r--src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.vcxproj277
-rw-r--r--src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.vcxproj.filters83
-rw-r--r--src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.cpp239
-rw-r--r--src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.h88
-rw-r--r--src/filters/transform/Mpeg2DecFilter/attributes.h44
-rw-r--r--src/filters/transform/Mpeg2DecFilter/idct_mmx.objbin10091 -> 0 bytes
-rw-r--r--src/filters/transform/Mpeg2DecFilter/idct_sse2.cpp322
-rw-r--r--src/filters/transform/Mpeg2DecFilter/libmpeg2.cpp3743
-rw-r--r--src/filters/transform/Mpeg2DecFilter/libmpeg2.h402
-rw-r--r--src/filters/transform/Mpeg2DecFilter/mc_sse2.cpp483
-rw-r--r--src/filters/transform/Mpeg2DecFilter/motion_comp_mmx.objbin8998 -> 0 bytes
-rw-r--r--src/filters/transform/Mpeg2DecFilter/resource.h27
-rw-r--r--src/filters/transform/Mpeg2DecFilter/stdafx.cpp22
-rw-r--r--src/filters/transform/Mpeg2DecFilter/stdafx.h27
-rw-r--r--src/mpc-hc/FGManagerBDA.cpp3
-rw-r--r--src/mpc-hc/MainFrm.cpp8
-rw-r--r--src/thirdparty/Bento4/Bento4.vcxproj257
-rw-r--r--src/thirdparty/Bento4/Bento4.vcxproj.filters451
-rw-r--r--src/thirdparty/Bento4/Core/Ap4.h42
-rw-r--r--src/thirdparty/Bento4/Core/Ap4Array.h152
-rw-r--r--src/thirdparty/Bento4/Core/Ap4Atom.cpp433
-rw-r--r--src/thirdparty/Bento4/Core/Ap4Atom.h407
-rw-r--r--src/thirdparty/Bento4/Core/Ap4AtomFactory.cpp542
-rw-r--r--src/thirdparty/Bento4/Core/Ap4AtomFactory.h84
-rw-r--r--src/thirdparty/Bento4/Core/Ap4AtomSampleTable.cpp272
-rw-r--r--src/thirdparty/Bento4/Core/Ap4AtomSampleTable.h91
-rw-r--r--src/thirdparty/Bento4/Core/Ap4AvcCAtom.cpp47
-rw-r--r--src/thirdparty/Bento4/Core/Ap4AvcCAtom.h57
-rw-r--r--src/thirdparty/Bento4/Core/Ap4ByteStream.cpp596
-rw-r--r--src/thirdparty/Bento4/Core/Ap4ByteStream.h155
-rw-r--r--src/thirdparty/Bento4/Core/Ap4ChplAtom.cpp72
-rw-r--r--src/thirdparty/Bento4/Core/Ap4ChplAtom.h62
-rw-r--r--src/thirdparty/Bento4/Core/Ap4CmvdAtom.cpp67
-rw-r--r--src/thirdparty/Bento4/Core/Ap4CmvdAtom.h64
-rw-r--r--src/thirdparty/Bento4/Core/Ap4Co64Atom.cpp153
-rw-r--r--src/thirdparty/Bento4/Core/Ap4Co64Atom.h62
-rw-r--r--src/thirdparty/Bento4/Core/Ap4Config.h71
-rw-r--r--src/thirdparty/Bento4/Core/Ap4Constants.h39
-rw-r--r--src/thirdparty/Bento4/Core/Ap4ContainerAtom.cpp164
-rw-r--r--src/thirdparty/Bento4/Core/Ap4ContainerAtom.h81
-rw-r--r--src/thirdparty/Bento4/Core/Ap4CttsAtom.cpp115
-rw-r--r--src/thirdparty/Bento4/Core/Ap4CttsAtom.h73
-rw-r--r--src/thirdparty/Bento4/Core/Ap4DataAtom.cpp53
-rw-r--r--src/thirdparty/Bento4/Core/Ap4DataAtom.h59
-rw-r--r--src/thirdparty/Bento4/Core/Ap4DataBuffer.cpp178
-rw-r--r--src/thirdparty/Bento4/Core/Ap4DataBuffer.h73
-rw-r--r--src/thirdparty/Bento4/Core/Ap4DcomAtom.cpp47
-rw-r--r--src/thirdparty/Bento4/Core/Ap4DcomAtom.h55
-rw-r--r--src/thirdparty/Bento4/Core/Ap4Debug.cpp67
-rw-r--r--src/thirdparty/Bento4/Core/Ap4Debug.h51
-rw-r--r--src/thirdparty/Bento4/Core/Ap4DecoderConfigDescriptor.cpp166
-rw-r--r--src/thirdparty/Bento4/Core/Ap4DecoderConfigDescriptor.h88
-rw-r--r--src/thirdparty/Bento4/Core/Ap4DecoderSpecificInfoDescriptor.cpp98
-rw-r--r--src/thirdparty/Bento4/Core/Ap4DecoderSpecificInfoDescriptor.h67
-rw-r--r--src/thirdparty/Bento4/Core/Ap4Descriptor.cpp116
-rw-r--r--src/thirdparty/Bento4/Core/Ap4Descriptor.h116
-rw-r--r--src/thirdparty/Bento4/Core/Ap4DescriptorFactory.cpp108
-rw-r--r--src/thirdparty/Bento4/Core/Ap4DescriptorFactory.h50
-rw-r--r--src/thirdparty/Bento4/Core/Ap4DrefAtom.cpp89
-rw-r--r--src/thirdparty/Bento4/Core/Ap4DrefAtom.h56
-rw-r--r--src/thirdparty/Bento4/Core/Ap4EndaAtom.cpp25
-rw-r--r--src/thirdparty/Bento4/Core/Ap4EndaAtom.h33
-rw-r--r--src/thirdparty/Bento4/Core/Ap4EsDescriptor.cpp205
-rw-r--r--src/thirdparty/Bento4/Core/Ap4EsDescriptor.h78
-rw-r--r--src/thirdparty/Bento4/Core/Ap4EsdsAtom.cpp95
-rw-r--r--src/thirdparty/Bento4/Core/Ap4EsdsAtom.h61
-rw-r--r--src/thirdparty/Bento4/Core/Ap4File.cpp92
-rw-r--r--src/thirdparty/Bento4/Core/Ap4File.h68
-rw-r--r--src/thirdparty/Bento4/Core/Ap4FileByteStream.h90
-rw-r--r--src/thirdparty/Bento4/Core/Ap4FileWriter.cpp91
-rw-r--r--src/thirdparty/Bento4/Core/Ap4FileWriter.h58
-rw-r--r--src/thirdparty/Bento4/Core/Ap4FrmaAtom.cpp76
-rw-r--r--src/thirdparty/Bento4/Core/Ap4FrmaAtom.h60
-rw-r--r--src/thirdparty/Bento4/Core/Ap4FtabAtom.cpp65
-rw-r--r--src/thirdparty/Bento4/Core/Ap4FtabAtom.h78
-rw-r--r--src/thirdparty/Bento4/Core/Ap4FtypAtom.cpp99
-rw-r--r--src/thirdparty/Bento4/Core/Ap4FtypAtom.h59
-rw-r--r--src/thirdparty/Bento4/Core/Ap4HdlrAtom.cpp110
-rw-r--r--src/thirdparty/Bento4/Core/Ap4HdlrAtom.h72
-rw-r--r--src/thirdparty/Bento4/Core/Ap4HintTrackReader.cpp324
-rw-r--r--src/thirdparty/Bento4/Core/Ap4HintTrackReader.h95
-rw-r--r--src/thirdparty/Bento4/Core/Ap4HmhdAtom.cpp93
-rw-r--r--src/thirdparty/Bento4/Core/Ap4HmhdAtom.h59
-rw-r--r--src/thirdparty/Bento4/Core/Ap4IkmsAtom.cpp97
-rw-r--r--src/thirdparty/Bento4/Core/Ap4IkmsAtom.h60
-rw-r--r--src/thirdparty/Bento4/Core/Ap4Interfaces.h68
-rw-r--r--src/thirdparty/Bento4/Core/Ap4IsfmAtom.cpp107
-rw-r--r--src/thirdparty/Bento4/Core/Ap4IsfmAtom.h66
-rw-r--r--src/thirdparty/Bento4/Core/Ap4IsmaCryp.cpp717
-rw-r--r--src/thirdparty/Bento4/Core/Ap4IsmaCryp.h245
-rw-r--r--src/thirdparty/Bento4/Core/Ap4List.h474
-rw-r--r--src/thirdparty/Bento4/Core/Ap4MdhdAtom.cpp172
-rw-r--r--src/thirdparty/Bento4/Core/Ap4MdhdAtom.h76
-rw-r--r--src/thirdparty/Bento4/Core/Ap4MoovAtom.cpp196
-rw-r--r--src/thirdparty/Bento4/Core/Ap4MoovAtom.h71
-rw-r--r--src/thirdparty/Bento4/Core/Ap4Movie.cpp235
-rw-r--r--src/thirdparty/Bento4/Core/Ap4Movie.h70
-rw-r--r--src/thirdparty/Bento4/Core/Ap4MvhdAtom.cpp182
-rw-r--r--src/thirdparty/Bento4/Core/Ap4MvhdAtom.h80
-rw-r--r--src/thirdparty/Bento4/Core/Ap4NmhdAtom.cpp61
-rw-r--r--src/thirdparty/Bento4/Core/Ap4NmhdAtom.h51
-rw-r--r--src/thirdparty/Bento4/Core/Ap4PaspAtom.cpp27
-rw-r--r--src/thirdparty/Bento4/Core/Ap4PaspAtom.h41
-rw-r--r--src/thirdparty/Bento4/Core/Ap4Processor.cpp297
-rw-r--r--src/thirdparty/Bento4/Core/Ap4Processor.h72
-rw-r--r--src/thirdparty/Bento4/Core/Ap4Results.h63
-rw-r--r--src/thirdparty/Bento4/Core/Ap4RtpAtom.cpp93
-rw-r--r--src/thirdparty/Bento4/Core/Ap4RtpAtom.h59
-rw-r--r--src/thirdparty/Bento4/Core/Ap4RtpHint.cpp639
-rw-r--r--src/thirdparty/Bento4/Core/Ap4RtpHint.h297
-rw-r--r--src/thirdparty/Bento4/Core/Ap4SLConfigDescriptor.cpp54
-rw-r--r--src/thirdparty/Bento4/Core/Ap4SLConfigDescriptor.h62
-rw-r--r--src/thirdparty/Bento4/Core/Ap4Sample.cpp161
-rw-r--r--src/thirdparty/Bento4/Core/Ap4Sample.h91
-rw-r--r--src/thirdparty/Bento4/Core/Ap4SampleDescription.cpp271
-rw-r--r--src/thirdparty/Bento4/Core/Ap4SampleDescription.h256
-rw-r--r--src/thirdparty/Bento4/Core/Ap4SampleEntry.cpp1307
-rw-r--r--src/thirdparty/Bento4/Core/Ap4SampleEntry.h453
-rw-r--r--src/thirdparty/Bento4/Core/Ap4SampleTable.cpp114
-rw-r--r--src/thirdparty/Bento4/Core/Ap4SampleTable.h58
-rw-r--r--src/thirdparty/Bento4/Core/Ap4SchmAtom.cpp120
-rw-r--r--src/thirdparty/Bento4/Core/Ap4SchmAtom.h68
-rw-r--r--src/thirdparty/Bento4/Core/Ap4SdpAtom.cpp100
-rw-r--r--src/thirdparty/Bento4/Core/Ap4SdpAtom.h61
-rw-r--r--src/thirdparty/Bento4/Core/Ap4SmhdAtom.cpp85
-rw-r--r--src/thirdparty/Bento4/Core/Ap4SmhdAtom.h57
-rw-r--r--src/thirdparty/Bento4/Core/Ap4StcoAtom.cpp151
-rw-r--r--src/thirdparty/Bento4/Core/Ap4StcoAtom.h62
-rw-r--r--src/thirdparty/Bento4/Core/Ap4StscAtom.cpp224
-rw-r--r--src/thirdparty/Bento4/Core/Ap4StscAtom.h105
-rw-r--r--src/thirdparty/Bento4/Core/Ap4StsdAtom.cpp196
-rw-r--r--src/thirdparty/Bento4/Core/Ap4StsdAtom.h80
-rw-r--r--src/thirdparty/Bento4/Core/Ap4StssAtom.cpp104
-rw-r--r--src/thirdparty/Bento4/Core/Ap4StssAtom.h56
-rw-r--r--src/thirdparty/Bento4/Core/Ap4StszAtom.cpp194
-rw-r--r--src/thirdparty/Bento4/Core/Ap4StszAtom.h70
-rw-r--r--src/thirdparty/Bento4/Core/Ap4SttsAtom.cpp174
-rw-r--r--src/thirdparty/Bento4/Core/Ap4SttsAtom.h80
-rw-r--r--src/thirdparty/Bento4/Core/Ap4SyntheticSampleTable.cpp130
-rw-r--r--src/thirdparty/Bento4/Core/Ap4SyntheticSampleTable.h79
-rw-r--r--src/thirdparty/Bento4/Core/Ap4TimsAtom.cpp76
-rw-r--r--src/thirdparty/Bento4/Core/Ap4TimsAtom.h60
-rw-r--r--src/thirdparty/Bento4/Core/Ap4TkhdAtom.cpp187
-rw-r--r--src/thirdparty/Bento4/Core/Ap4TkhdAtom.h105
-rw-r--r--src/thirdparty/Bento4/Core/Ap4Track.cpp369
-rw-r--r--src/thirdparty/Bento4/Core/Ap4Track.h118
-rw-r--r--src/thirdparty/Bento4/Core/Ap4TrakAtom.cpp204
-rw-r--r--src/thirdparty/Bento4/Core/Ap4TrakAtom.h85
-rw-r--r--src/thirdparty/Bento4/Core/Ap4TrefTypeAtom.cpp82
-rw-r--r--src/thirdparty/Bento4/Core/Ap4TrefTypeAtom.h58
-rw-r--r--src/thirdparty/Bento4/Core/Ap4Types.h68
-rw-r--r--src/thirdparty/Bento4/Core/Ap4UnknownDescriptor.cpp58
-rw-r--r--src/thirdparty/Bento4/Core/Ap4UnknownDescriptor.h60
-rw-r--r--src/thirdparty/Bento4/Core/Ap4UrlAtom.cpp99
-rw-r--r--src/thirdparty/Bento4/Core/Ap4UrlAtom.h57
-rw-r--r--src/thirdparty/Bento4/Core/Ap4Utils.cpp348
-rw-r--r--src/thirdparty/Bento4/Core/Ap4Utils.h104
-rw-r--r--src/thirdparty/Bento4/Core/Ap4VmhdAtom.cpp92
-rw-r--r--src/thirdparty/Bento4/Core/Ap4VmhdAtom.h58
-rw-r--r--src/thirdparty/Bento4/Crypto/Ap4AesBlockCipher.cpp1841
-rw-r--r--src/thirdparty/Bento4/Crypto/Ap4AesBlockCipher.h82
-rw-r--r--src/thirdparty/Bento4/Crypto/Ap4StreamCipher.cpp159
-rw-r--r--src/thirdparty/Bento4/Crypto/Ap4StreamCipher.h47
-rw-r--r--src/thirdparty/Bento4/precomp.cpp23
-rw-r--r--src/thirdparty/ffmpeg/Makefile427
-rw-r--r--src/thirdparty/ffmpeg/config.asm226
-rw-r--r--src/thirdparty/ffmpeg/config.h513
-rw-r--r--src/thirdparty/ffmpeg/custom_code.txt30
-rw-r--r--src/thirdparty/ffmpeg/ffmpeg.vcxproj724
-rw-r--r--src/thirdparty/ffmpeg/ffmpeg.vcxproj.filters1796
-rw-r--r--src/thirdparty/ffmpeg/gccbuild.bat242
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/aac.h336
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/aac_ac3_parser.c104
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/aac_ac3_parser.h66
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/aac_parser.c69
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/aac_tablegen.h42
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/aac_tablegen_decl.h36
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/aacadtsdec.c70
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/aacadtsdec.h54
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/aacdec.c3058
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/aacdectab.h104
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/aacps.c968
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/aacps.h84
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/aacps_tablegen.h215
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/aacpsdata.c163
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/aacpsdsp.c214
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/aacpsdsp.h53
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/aacsbr.c1722
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/aacsbr.h49
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/aacsbrdata.h616
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/aactab.c1207
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/aactab.h77
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/ac3.c231
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/ac3.h181
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/ac3_parser.c194
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/ac3_parser.h41
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/ac3dec.c1492
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/ac3dec.h241
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/ac3dec_data.c60
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/ac3dec_data.h32
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/ac3dsp.c263
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/ac3dsp.h144
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/ac3tab.c314
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/ac3tab.h72
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/acelp_filters.c155
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/acelp_filters.h153
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/acelp_pitch_delay.c189
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/acelp_pitch_delay.h252
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/acelp_vectors.c272
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/acelp_vectors.h288
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/adpcm.c1434
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/adpcm.h48
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/adpcm_data.c91
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/adpcm_data.h41
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/alac.c631
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/alac_data.c56
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/alac_data.h46
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/allcodecs.c144
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/alsdec.c1787
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/amr.h70
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/amrnbdata.h1671
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/amrnbdec.c1096
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/amrwbdata.h1890
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/amrwbdec.c1281
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/atrac.c120
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/atrac.h36
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/atrac3.c1014
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/atrac3data.h141
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/audio_frame_queue.h83
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/audioconvert.h70
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/avcodec.h5114
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/avfft.c144
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/avfft.h116
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/avpacket.c321
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/avpicture.c78
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/bgmc.c558
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/bgmc.h56
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/bit_depth_template.c92
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/bitstream.c339
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/bytestream.h345
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/cabac.c318
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/cabac.h56
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/cabac_functions.h162
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/cbrt_tablegen.h51
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/celp_filters.c219
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/celp_filters.h169
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/celp_math.c126
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/celp_math.h97
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/codec_desc.c2553
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/cook.c1289
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/cookdata.h580
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/copy_block.h94
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/dca.c33
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/dca.h42
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/dca_parser.c208
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/dca_parser.h36
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/dcadata.h7664
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/dcadec.c2526
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/dcadsp.c51
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/dcadsp.h30
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/dcahuff.h1076
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/dct.c222
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/dct.h70
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/dct32.c276
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/dct32.h25
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/dct32_float.c20
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/diracdsp.h67
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/dsputil.c2959
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/dsputil.h407
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/dsputil_template.c436
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/dxva.h1966
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/eac3_data.c1134
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/eac3_data.h36
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/eac3dec.c607
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/error_resilience.c1322
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/faandct.c229
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/faandct.h37
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/faanidct.c169
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/faanidct.h31
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/fft-internal.h75
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/fft.c353
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/fft.h153
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/flac.c246
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/flac.h143
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/flacdata.c33
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/flacdata.h31
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/flacdec.c586
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/flacdsp.c131
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/flacdsp.h37
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/flacdsp_lpc_template.c141
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/flacdsp_template.c103
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/flv.h33
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/flvdec.c134
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/fmtconvert.c121
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/fmtconvert.h101
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/frame_thread_encoder.c270
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/frame_thread_encoder.h26
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/get_bits.h631
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/golomb.c173
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/golomb.h557
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h261.c53
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h261.h51
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h261data.h42
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h263.c385
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h263.h210
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h263_parser.c95
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h263_parser.h29
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h263data.h299
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h263dec.c796
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264.c4532
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264.h941
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264_cabac.c2430
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264_cavlc.c1170
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264_direct.c634
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264_dxva.c1288
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264_loopfilter.c829
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264_mb_template.c377
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264_mc_template.c160
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264_mvpred.h834
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264_parser.c398
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264_ps.c695
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264_recov.c170
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264_refs.c784
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264_sei.c256
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264addpx_template.c68
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264chroma.c54
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264chroma.h38
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264chroma_template.c142
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264data.h272
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264dsp.c153
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264dsp.h119
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264dsp_template.c328
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264idct.c48
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264idct.h44
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264idct_template.c315
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264pred.c595
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264pred.h119
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264pred_template.c1272
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264qpel.c104
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264qpel.h38
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/h264qpel_template.c560
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/hpel_template.c100
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/huffman.c176
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/huffman.h47
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/imgconvert.c680
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/imgconvert.h29
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/indeo3.c1151
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/indeo3data.h362
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/indeo4.c660
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/indeo4data.h350
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/indeo5.c678
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/indeo5data.h162
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/intelh263dec.c138
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/internal.h212
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/intrax8.c788
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/intrax8.h59
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/intrax8dsp.c433
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/intrax8dsp.h35
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/intrax8huf.h918
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/ituh263dec.c1158
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/ivi_common.c1384
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/ivi_common.h322
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/ivi_dsp.c624
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/ivi_dsp.h205
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/jpegls.c87
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/jpegls.h114
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/jpeglsdec.c385
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/jpeglsdec.h41
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/jrevdct.c1155
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/kbdwin.c47
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/kbdwin.h35
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/latm_parser.c112
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/log2_tab.c1
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/lpc.h198
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/lsp.c235
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/lsp.h130
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mathops.h218
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mathtables.c89
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mdct.c203
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mips/amrwbdec_mips.h62
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mips/lsp_mips.h108
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mjpeg.c145
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mjpeg.h156
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mjpegbdec.c171
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mjpegdec.c1935
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mjpegdec.h133
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mjpegenc.h61
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mlp.c115
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mlp.h127
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mlp_parser.c398
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mlp_parser.h65
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mlpdec.c1267
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mlpdsp.c64
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mlpdsp.h37
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpeg12.c2748
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpeg12.h85
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpeg12data.c432
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpeg12data.h57
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpeg12decdata.h93
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpeg4audio.c190
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpeg4audio.h109
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpeg4data.h376
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpeg4video.c170
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpeg4video.h200
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpeg4video_parser.c154
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpeg4video_parser.h34
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpeg4videodec.c2385
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpegaudio.c50
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpegaudio.h77
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpegaudio_parser.c110
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpegaudio_tablegen.h72
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpegaudiodata.c146
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpegaudiodata.h44
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpegaudiodec.c2081
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpegaudiodec_float.c104
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpegaudiodecheader.c146
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpegaudiodecheader.h76
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpegaudiodectab.h615
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpegaudiodsp.c48
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpegaudiodsp.h89
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpegaudiodsp_data.c56
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpegaudiodsp_fixed.c20
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpegaudiodsp_float.c20
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpegaudiodsp_template.c400
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpegvideo.c3171
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpegvideo.h943
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpegvideo_motion.c894
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/mpegvideo_parser.c208
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/msmpeg4.c1269
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/msmpeg4.h68
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/msmpeg4data.c2005
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/msmpeg4data.h90
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/msrle.c168
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/msrledec.c265
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/msrledec.h39
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/nellymoser.c225
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/nellymoser.h57
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/nellymoserdec.c212
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/old_codec_ids.h398
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/options.c296
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/options_table.h420
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/parser.c300
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/parser.h59
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/png.h69
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/pthread.c1158
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/put_bits.h237
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/ra144.c1728
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/ra144.h85
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/ra144dec.c139
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/ra288.c241
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/ra288.h149
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/rangecoder.h147
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/ratecontrol.h104
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/rdft.c133
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/rdft.h74
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/rectangle.h125
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/rl.h86
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/rnd_avg.h50
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/rv10.c782
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/rv30.c289
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/rv30data.h181
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/rv30dsp.c307
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/rv34.c1796
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/rv34.h141
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/rv34data.h126
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/rv34dsp.c143
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/rv34dsp.h87
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/rv34vlc.h4055
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/rv40.c580
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/rv40data.h101
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/rv40dsp.c614
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/rv40vlc2.h706
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/sbr.h189
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/sbrdsp.c248
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/sbrdsp.h51
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/simple_idct.c233
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/simple_idct.h57
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/simple_idct_template.c324
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/sinewin.c20
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/sinewin.h60
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/sinewin_tablegen.h67
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/sipr.c576
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/sipr.h110
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/sipr16k.c282
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/sipr16kdata.h533
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/siprdata.h263
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/sp5x.h238
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/sp5xdec.c121
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/svq1.c43
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/svq1.h59
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/svq13.c69
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/svq1_cb.h1525
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/svq1_vlc.h268
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/svq1dec.c834
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/svq3.c1206
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/svq3.h27
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/synth_filter.c64
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/synth_filter.h37
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/thread.h126
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/tscc.c192
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/unary.h56
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/utils.c2750
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vc1.c1667
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vc1.h462
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vc1_dxva.c186
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vc1acdata.h367
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vc1data.c1135
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vc1data.h208
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vc1dec.c5890
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vc1dsp.c868
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vc1dsp.h82
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vdpau_internal.h59
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/version.h110
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/videodsp.c52
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/videodsp.h79
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/videodsp_template.c98
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vmnc.c533
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vorbis.c236
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vorbis.h50
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vorbis_data.c2194
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vorbisdec.c1771
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vorbisdsp.c33
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vorbisdsp.h37
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vp3.c2452
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vp3data.h3181
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vp3dsp.c320
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vp3dsp.h56
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vp5.c290
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vp56.c767
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vp56.h377
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vp56data.c68
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vp56data.h254
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vp56dsp.c94
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vp56dsp.h42
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vp56rac.c47
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vp5data.h177
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vp6.c696
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vp6data.h310
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vp6dsp.c61
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vp8.c2089
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vp8.h276
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vp8data.h691
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vp8dsp.c530
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/vp8dsp.h96
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/w32pthreads.h272
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/wmv2.c176
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/wmv2.h60
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/wmv2dec.c479
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/wmv2dsp.c146
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/wmv2dsp.h33
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/ac3dsp.asm457
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/ac3dsp_init.c232
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/cabac.h229
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/dct32.asm490
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/deinterlace.asm82
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/diracdsp_mmx.h47
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/dsputil.asm815
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/dsputil_avg_template.c77
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/dsputil_mmx.c1927
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/dsputil_mmx.h119
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/dsputil_qns_template.c101
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/dsputil_rnd_template.c594
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/fdct.c586
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/fft.asm1093
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/fft.h41
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/fft_init.c69
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/fmtconvert.asm429
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/fmtconvert_init.c149
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/h264_chromamc.asm678
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/h264_chromamc_10bit.asm271
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/h264_deblock.asm1075
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/h264_deblock_10bit.asm923
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/h264_i386.h204
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/h264_idct.asm1015
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/h264_idct_10bit.asm546
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/h264_intrapred.asm2702
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/h264_intrapred_10bit.asm1199
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/h264_intrapred_init.c402
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/h264_qpel.c626
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/h264_qpel_10bit.asm884
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/h264_qpel_8bit.asm1031
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/h264_weight.asm317
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/h264_weight_10bit.asm282
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/h264chroma_init.c118
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/h264dsp_init.c375
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/hpeldsp.asm502
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/idct_mmx.c632
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/idct_mmx_xvid.c558
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/idct_sse2_xvid.c408
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/idct_xvid.h43
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/imdct36.asm724
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/mathops.h130
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/mlpdsp.c182
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/motion_est.c474
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/mpeg4qpel.asm560
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/mpegaudiodec.c273
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/mpegvideo.c601
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/rv34dsp.asm196
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/rv34dsp_init.c46
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/rv40dsp.asm505
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/rv40dsp_init.c243
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/sbrdsp.asm222
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/sbrdsp_init.c48
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/simple_idct.c1168
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/vc1dsp.asm317
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/vc1dsp.h29
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/vc1dsp_init.c123
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/vc1dsp_mmx.c751
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/videodsp.asm612
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/videodsp_init.c128
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/vorbisdsp.asm83
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/vorbisdsp_init.c43
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/vp3dsp.asm667
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/vp3dsp_init.c130
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/vp56_arith.h54
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/vp56dsp.asm170
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/vp56dsp_init.c49
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/vp8dsp.asm2781
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/x86/vp8dsp_init.c442
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/xiph.c63
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/xiph.h43
-rw-r--r--src/thirdparty/ffmpeg/libavcodec/xvmc_internal.h33
-rw-r--r--src/thirdparty/ffmpeg/libavresample/audio_convert.c414
-rw-r--r--src/thirdparty/ffmpeg/libavresample/audio_convert.h102
-rw-r--r--src/thirdparty/ffmpeg/libavresample/audio_data.c372
-rw-r--r--src/thirdparty/ffmpeg/libavresample/audio_data.h175
-rw-r--r--src/thirdparty/ffmpeg/libavresample/audio_mix.c739
-rw-r--r--src/thirdparty/ffmpeg/libavresample/audio_mix.h94
-rw-r--r--src/thirdparty/ffmpeg/libavresample/audio_mix_matrix.c289
-rw-r--r--src/thirdparty/ffmpeg/libavresample/avresample.h409
-rw-r--r--src/thirdparty/ffmpeg/libavresample/dither.c439
-rw-r--r--src/thirdparty/ffmpeg/libavresample/dither.h93
-rw-r--r--src/thirdparty/ffmpeg/libavresample/internal.h110
-rw-r--r--src/thirdparty/ffmpeg/libavresample/options.c99
-rw-r--r--src/thirdparty/ffmpeg/libavresample/resample.c469
-rw-r--r--src/thirdparty/ffmpeg/libavresample/resample.h67
-rw-r--r--src/thirdparty/ffmpeg/libavresample/resample_template.c102
-rw-r--r--src/thirdparty/ffmpeg/libavresample/utils.c635
-rw-r--r--src/thirdparty/ffmpeg/libavresample/version.h46
-rw-r--r--src/thirdparty/ffmpeg/libavresample/x86/audio_convert.asm1261
-rw-r--r--src/thirdparty/ffmpeg/libavresample/x86/audio_convert_init.c263
-rw-r--r--src/thirdparty/ffmpeg/libavresample/x86/audio_mix.asm511
-rw-r--r--src/thirdparty/ffmpeg/libavresample/x86/audio_mix_init.c215
-rw-r--r--src/thirdparty/ffmpeg/libavresample/x86/dither.asm117
-rw-r--r--src/thirdparty/ffmpeg/libavresample/x86/dither_init.c61
-rw-r--r--src/thirdparty/ffmpeg/libavresample/x86/util.asm41
-rw-r--r--src/thirdparty/ffmpeg/libavutil/attributes.h154
-rw-r--r--src/thirdparty/ffmpeg/libavutil/audio_fifo.c194
-rw-r--r--src/thirdparty/ffmpeg/libavutil/audio_fifo.h146
-rw-r--r--src/thirdparty/ffmpeg/libavutil/audioconvert.h6
-rw-r--r--src/thirdparty/ffmpeg/libavutil/avassert.h66
-rw-r--r--src/thirdparty/ffmpeg/libavutil/avconfig.h7
-rw-r--r--src/thirdparty/ffmpeg/libavutil/avstring.c319
-rw-r--r--src/thirdparty/ffmpeg/libavutil/avstring.h240
-rw-r--r--src/thirdparty/ffmpeg/libavutil/avutil.h260
-rw-r--r--src/thirdparty/ffmpeg/libavutil/bprint.c294
-rw-r--r--src/thirdparty/ffmpeg/libavutil/bprint.h183
-rw-r--r--src/thirdparty/ffmpeg/libavutil/bswap.h109
-rw-r--r--src/thirdparty/ffmpeg/libavutil/channel_layout.c258
-rw-r--r--src/thirdparty/ffmpeg/libavutil/channel_layout.h216
-rw-r--r--src/thirdparty/ffmpeg/libavutil/colorspace.h111
-rw-r--r--src/thirdparty/ffmpeg/libavutil/common.h437
-rw-r--r--src/thirdparty/ffmpeg/libavutil/cpu.c230
-rw-r--r--src/thirdparty/ffmpeg/libavutil/cpu.h108
-rw-r--r--src/thirdparty/ffmpeg/libavutil/crc.c321
-rw-r--r--src/thirdparty/ffmpeg/libavutil/crc.h74
-rw-r--r--src/thirdparty/ffmpeg/libavutil/dict.c183
-rw-r--r--src/thirdparty/ffmpeg/libavutil/dict.h152
-rw-r--r--src/thirdparty/ffmpeg/libavutil/error.c99
-rw-r--r--src/thirdparty/ffmpeg/libavutil/error.h117
-rw-r--r--src/thirdparty/ffmpeg/libavutil/eval.c834
-rw-r--r--src/thirdparty/ffmpeg/libavutil/eval.h113
-rw-r--r--src/thirdparty/ffmpeg/libavutil/fifo.c182
-rw-r--r--src/thirdparty/ffmpeg/libavutil/fifo.h144
-rw-r--r--src/thirdparty/ffmpeg/libavutil/float_dsp.c139
-rw-r--r--src/thirdparty/ffmpeg/libavutil/float_dsp.h189
-rw-r--r--src/thirdparty/ffmpeg/libavutil/imgutils.c368
-rw-r--r--src/thirdparty/ffmpeg/libavutil/imgutils.h200
-rw-r--r--src/thirdparty/ffmpeg/libavutil/internal.h165
-rw-r--r--src/thirdparty/ffmpeg/libavutil/intfloat.h77
-rw-r--r--src/thirdparty/ffmpeg/libavutil/intfloat_readwrite.c97
-rw-r--r--src/thirdparty/ffmpeg/libavutil/intfloat_readwrite.h40
-rw-r--r--src/thirdparty/ffmpeg/libavutil/intmath.h150
-rw-r--r--src/thirdparty/ffmpeg/libavutil/intreadwrite.h621
-rw-r--r--src/thirdparty/ffmpeg/libavutil/lfg.c102
-rw-r--r--src/thirdparty/ffmpeg/libavutil/lfg.h62
-rw-r--r--src/thirdparty/ffmpeg/libavutil/libm.h189
-rw-r--r--src/thirdparty/ffmpeg/libavutil/lls.c155
-rw-r--r--src/thirdparty/ffmpeg/libavutil/lls.h45
-rw-r--r--src/thirdparty/ffmpeg/libavutil/log.c280
-rw-r--r--src/thirdparty/ffmpeg/libavutil/log.h222
-rw-r--r--src/thirdparty/ffmpeg/libavutil/log2_tab.c32
-rw-r--r--src/thirdparty/ffmpeg/libavutil/lzo.c242
-rw-r--r--src/thirdparty/ffmpeg/libavutil/lzo.h66
-rw-r--r--src/thirdparty/ffmpeg/libavutil/mathematics.c173
-rw-r--r--src/thirdparty/ffmpeg/libavutil/mathematics.h147
-rw-r--r--src/thirdparty/ffmpeg/libavutil/md5.c210
-rw-r--r--src/thirdparty/ffmpeg/libavutil/md5.h49
-rw-r--r--src/thirdparty/ffmpeg/libavutil/mem.c367
-rw-r--r--src/thirdparty/ffmpeg/libavutil/mem.h235
-rw-r--r--src/thirdparty/ffmpeg/libavutil/old_pix_fmts.h171
-rw-r--r--src/thirdparty/ffmpeg/libavutil/opt.c1435
-rw-r--r--src/thirdparty/ffmpeg/libavutil/opt.h733
-rw-r--r--src/thirdparty/ffmpeg/libavutil/parseutils.c865
-rw-r--r--src/thirdparty/ffmpeg/libavutil/parseutils.h174
-rw-r--r--src/thirdparty/ffmpeg/libavutil/pixdesc.c1793
-rw-r--r--src/thirdparty/ffmpeg/libavutil/pixdesc.h237
-rw-r--r--src/thirdparty/ffmpeg/libavutil/pixfmt.h357
-rw-r--r--src/thirdparty/ffmpeg/libavutil/random_seed.c151
-rw-r--r--src/thirdparty/ffmpeg/libavutil/random_seed.h43
-rw-r--r--src/thirdparty/ffmpeg/libavutil/rational.c174
-rw-r--r--src/thirdparty/ffmpeg/libavutil/rational.h155
-rw-r--r--src/thirdparty/ffmpeg/libavutil/samplefmt.c251
-rw-r--r--src/thirdparty/ffmpeg/libavutil/samplefmt.h243
-rw-r--r--src/thirdparty/ffmpeg/libavutil/sha.c383
-rw-r--r--src/thirdparty/ffmpeg/libavutil/sha.h74
-rw-r--r--src/thirdparty/ffmpeg/libavutil/time.c70
-rw-r--r--src/thirdparty/ffmpeg/libavutil/time.h41
-rw-r--r--src/thirdparty/ffmpeg/libavutil/timecode.c218
-rw-r--r--src/thirdparty/ffmpeg/libavutil/timecode.h140
-rw-r--r--src/thirdparty/ffmpeg/libavutil/timer.h78
-rw-r--r--src/thirdparty/ffmpeg/libavutil/utils.c81
-rw-r--r--src/thirdparty/ffmpeg/libavutil/version.h138
-rw-r--r--src/thirdparty/ffmpeg/libavutil/x86/asm.h110
-rw-r--r--src/thirdparty/ffmpeg/libavutil/x86/bswap.h61
-rw-r--r--src/thirdparty/ffmpeg/libavutil/x86/cpu.c201
-rw-r--r--src/thirdparty/ffmpeg/libavutil/x86/cpu.h61
-rw-r--r--src/thirdparty/ffmpeg/libavutil/x86/cpuid.asm91
-rw-r--r--src/thirdparty/ffmpeg/libavutil/x86/emms.asm30
-rw-r--r--src/thirdparty/ffmpeg/libavutil/x86/emms.h46
-rw-r--r--src/thirdparty/ffmpeg/libavutil/x86/float_dsp.asm265
-rw-r--r--src/thirdparty/ffmpeg/libavutil/x86/float_dsp_init.c152
-rw-r--r--src/thirdparty/ffmpeg/libavutil/x86/intreadwrite.h97
-rw-r--r--src/thirdparty/ffmpeg/libavutil/x86/timer.h43
-rw-r--r--src/thirdparty/ffmpeg/libavutil/x86/x86inc.asm1310
-rw-r--r--src/thirdparty/ffmpeg/libavutil/x86/x86util.asm667
-rw-r--r--src/thirdparty/ffmpeg/libavutil/x86_cpu.h1
-rw-r--r--src/thirdparty/ffmpeg/libswscale/input.c1354
-rw-r--r--src/thirdparty/ffmpeg/libswscale/options.c81
-rw-r--r--src/thirdparty/ffmpeg/libswscale/output.c1722
-rw-r--r--src/thirdparty/ffmpeg/libswscale/rgb2rgb.c390
-rw-r--r--src/thirdparty/ffmpeg/libswscale/rgb2rgb.h166
-rw-r--r--src/thirdparty/ffmpeg/libswscale/rgb2rgb_template.c927
-rw-r--r--src/thirdparty/ffmpeg/libswscale/swscale.c974
-rw-r--r--src/thirdparty/ffmpeg/libswscale/swscale.h355
-rw-r--r--src/thirdparty/ffmpeg/libswscale/swscale_internal.h840
-rw-r--r--src/thirdparty/ffmpeg/libswscale/swscale_unscaled.c1068
-rw-r--r--src/thirdparty/ffmpeg/libswscale/utils.c1882
-rw-r--r--src/thirdparty/ffmpeg/libswscale/version.h59
-rw-r--r--src/thirdparty/ffmpeg/libswscale/x86/input.asm670
-rw-r--r--src/thirdparty/ffmpeg/libswscale/x86/output.asm413
-rw-r--r--src/thirdparty/ffmpeg/libswscale/x86/rgb2rgb.c149
-rw-r--r--src/thirdparty/ffmpeg/libswscale/x86/rgb2rgb_template.c2498
-rw-r--r--src/thirdparty/ffmpeg/libswscale/x86/scale.asm431
-rw-r--r--src/thirdparty/ffmpeg/libswscale/x86/swscale.c585
-rw-r--r--src/thirdparty/ffmpeg/libswscale/x86/swscale_template.c1717
-rw-r--r--src/thirdparty/ffmpeg/libswscale/x86/yuv2rgb.c113
-rw-r--r--src/thirdparty/ffmpeg/libswscale/x86/yuv2rgb_template.c451
-rw-r--r--src/thirdparty/ffmpeg/libswscale/yuv2rgb.c927
-rw-r--r--src/thirdparty/ffmpeg/mpc_helper.c65
-rw-r--r--src/thirdparty/libflac/include/FLAC/all.h370
-rw-r--r--src/thirdparty/libflac/include/FLAC/assert.h45
-rw-r--r--src/thirdparty/libflac/include/FLAC/callback.h184
-rw-r--r--src/thirdparty/libflac/include/FLAC/export.h91
-rw-r--r--src/thirdparty/libflac/include/FLAC/format.h1022
-rw-r--r--src/thirdparty/libflac/include/FLAC/metadata.h2181
-rw-r--r--src/thirdparty/libflac/include/FLAC/ordinals.h80
-rw-r--r--src/thirdparty/libflac/include/FLAC/stream_decoder.h1559
-rw-r--r--src/thirdparty/libflac/include/FLAC/stream_encoder.h1768
-rw-r--r--src/thirdparty/libflac/include/ogg/ogg.h210
-rw-r--r--src/thirdparty/libflac/include/ogg/os_types.h147
-rw-r--r--src/thirdparty/libflac/include/share/alloc.h208
-rw-r--r--src/thirdparty/libflac/include/share/getopt.h184
-rw-r--r--src/thirdparty/libflac/include/share/grabbag.h29
-rw-r--r--src/thirdparty/libflac/include/share/grabbag/cuesheet.h42
-rw-r--r--src/thirdparty/libflac/include/share/grabbag/file.h63
-rw-r--r--src/thirdparty/libflac/include/share/grabbag/picture.h46
-rw-r--r--src/thirdparty/libflac/include/share/grabbag/replaygain.h72
-rw-r--r--src/thirdparty/libflac/include/share/grabbag/seektable.h38
-rw-r--r--src/thirdparty/libflac/include/share/replaygain_analysis.h59
-rw-r--r--src/thirdparty/libflac/include/share/replaygain_synthesis.h51
-rw-r--r--src/thirdparty/libflac/include/share/utf8.h25
-rw-r--r--src/thirdparty/libflac/src/libFLAC/Ogg/bitwise.c857
-rw-r--r--src/thirdparty/libflac/src/libFLAC/Ogg/framing.c2093
-rw-r--r--src/thirdparty/libflac/src/libFLAC/bitmath.c149
-rw-r--r--src/thirdparty/libflac/src/libFLAC/bitreader.c1383
-rw-r--r--src/thirdparty/libflac/src/libFLAC/bitwriter.c892
-rw-r--r--src/thirdparty/libflac/src/libFLAC/cpu.c418
-rw-r--r--src/thirdparty/libflac/src/libFLAC/crc.c142
-rw-r--r--src/thirdparty/libflac/src/libFLAC/fixed.c435
-rw-r--r--src/thirdparty/libflac/src/libFLAC/float.c308
-rw-r--r--src/thirdparty/libflac/src/libFLAC/format.c599
-rw-r--r--src/thirdparty/libflac/src/libFLAC/ia32/bitreader_asm.nasm569
-rw-r--r--src/thirdparty/libflac/src/libFLAC/ia32/cpu_asm.nasm121
-rw-r--r--src/thirdparty/libflac/src/libFLAC/ia32/fixed_asm.nasm312
-rw-r--r--src/thirdparty/libflac/src/libFLAC/ia32/lpc_asm.nasm1511
-rw-r--r--src/thirdparty/libflac/src/libFLAC/ia32/nasm.h75
-rw-r--r--src/thirdparty/libflac/src/libFLAC/ia32/stream_encoder_asm.nasm159
-rw-r--r--src/thirdparty/libflac/src/libFLAC/include/private/all.h49
-rw-r--r--src/thirdparty/libflac/src/libFLAC/include/private/bitmath.h42
-rw-r--r--src/thirdparty/libflac/src/libFLAC/include/private/bitreader.h99
-rw-r--r--src/thirdparty/libflac/src/libFLAC/include/private/bitwriter.h103
-rw-r--r--src/thirdparty/libflac/src/libFLAC/include/private/cpu.h88
-rw-r--r--src/thirdparty/libflac/src/libFLAC/include/private/crc.h61
-rw-r--r--src/thirdparty/libflac/src/libFLAC/include/private/fixed.h97
-rw-r--r--src/thirdparty/libflac/src/libFLAC/include/private/float.h97
-rw-r--r--src/thirdparty/libflac/src/libFLAC/include/private/format.h44
-rw-r--r--src/thirdparty/libflac/src/libFLAC/include/private/lpc.h214
-rw-r--r--src/thirdparty/libflac/src/libFLAC/include/private/md5.h44
-rw-r--r--src/thirdparty/libflac/src/libFLAC/include/private/memory.h56
-rw-r--r--src/thirdparty/libflac/src/libFLAC/include/private/metadata.h45
-rw-r--r--src/thirdparty/libflac/src/libFLAC/include/private/ogg_decoder_aspect.h79
-rw-r--r--src/thirdparty/libflac/src/libFLAC/include/private/ogg_encoder_aspect.h62
-rw-r--r--src/thirdparty/libflac/src/libFLAC/include/private/ogg_helper.h43
-rw-r--r--src/thirdparty/libflac/src/libFLAC/include/private/ogg_mapping.h63
-rw-r--r--src/thirdparty/libflac/src/libFLAC/include/private/stream_encoder_framing.h45
-rw-r--r--src/thirdparty/libflac/src/libFLAC/include/private/window.h71
-rw-r--r--src/thirdparty/libflac/src/libFLAC/include/protected/all.h38
-rw-r--r--src/thirdparty/libflac/src/libFLAC/include/protected/stream_decoder.h58
-rw-r--r--src/thirdparty/libflac/src/libFLAC/include/protected/stream_encoder.h110
-rw-r--r--src/thirdparty/libflac/src/libFLAC/libflac.vcxproj195
-rw-r--r--src/thirdparty/libflac/src/libFLAC/libflac.vcxproj.filters195
-rw-r--r--src/thirdparty/libflac/src/libFLAC/lpc.c1377
-rw-r--r--src/thirdparty/libflac/src/libFLAC/md5.c420
-rw-r--r--src/thirdparty/libflac/src/libFLAC/memory.c221
-rw-r--r--src/thirdparty/libflac/src/libFLAC/metadata_iterators.c3364
-rw-r--r--src/thirdparty/libflac/src/libFLAC/metadata_object.c1824
-rw-r--r--src/thirdparty/libflac/src/libFLAC/ogg_decoder_aspect.c253
-rw-r--r--src/thirdparty/libflac/src/libFLAC/ogg_encoder_aspect.c227
-rw-r--r--src/thirdparty/libflac/src/libFLAC/ogg_helper.c209
-rw-r--r--src/thirdparty/libflac/src/libFLAC/ogg_mapping.c47
-rw-r--r--src/thirdparty/libflac/src/libFLAC/stream_decoder.c3387
-rw-r--r--src/thirdparty/libflac/src/libFLAC/stream_encoder.c4348
-rw-r--r--src/thirdparty/libflac/src/libFLAC/stream_encoder_framing.c553
-rw-r--r--src/thirdparty/libflac/src/libFLAC/window.c225
1021 files changed, 101 insertions, 377631 deletions
diff --git a/src/filters/transform/MPCVideoDec/IMPCVideoDecFilter.h b/include/IMPCVideoDecFilter.h
index dbfe1316b..1e9268ac7 100644
--- a/src/filters/transform/MPCVideoDec/IMPCVideoDecFilter.h
+++ b/include/IMPCVideoDecFilter.h
@@ -1,90 +1,90 @@
-/*
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-// Internal codec list (used to enable/disable codec in standalone mode)
-typedef enum {
- MPCVD_H264 = 1 << 0,
- MPCVD_VC1 = 1 << 1,
- MPCVD_XVID = 1 << 2,
- MPCVD_DIVX = 1 << 3,
- MPCVD_WMV = 1 << 4,
- MPCVD_MSMPEG4 = 1 << 5,
- MPCVD_H263 = 1 << 6,
- MPCVD_SVQ3 = 1 << 7,
- MPCVD_THEORA = 1 << 8,
- MPCVD_AMVV = 1 << 9,
- MPCVD_FLASH = 1 << 10,
- MPCVD_H264_DXVA = 1 << 11,
- MPCVD_VC1_DXVA = 1 << 12,
- MPCVD_VP356 = 1 << 13,
- MPCVD_VP8 = 1 << 14,
- MPCVD_MJPEG = 1 << 15,
- MPCVD_INDEO = 1 << 16,
- MPCVD_RV = 1 << 17,
- MPCVD_WMV3_DXVA = 1 << 19,
- MPCVD_MPEG2_DXVA = 1 << 20
-} MPC_VIDEO_CODEC;
-
-// Interlaced flag handling
-enum MPCVD_INTERLACED_FLAG {
- MPCVC_INTERLACED_AUTO,
- MPCVC_INTERLACED_PROGRESSIVE,
- MPCVC_INTERLACED_TOP_FIELD_FIRST,
- MPCVC_INTERLACED_BOTTOM_FIELD_FIRST
-};
-
-interface __declspec(uuid("CDC3B5B3-A8B0-4c70-A805-9FC80CDEF262"))
-IMPCVideoDecFilter :
-public IUnknown {
- STDMETHOD(Apply()) PURE;
-
- STDMETHOD(SetThreadNumber(int nValue)) PURE;
- STDMETHOD_(int, GetThreadNumber()) PURE;
-
- STDMETHOD(SetDiscardMode(int nValue)) PURE;
- STDMETHOD_(int, GetDiscardMode()) PURE;
-
- STDMETHOD_(GUID*, GetDXVADecoderGuid()) PURE;
-
- STDMETHOD(SetActiveCodecs(MPC_VIDEO_CODEC nValue)) PURE;
- STDMETHOD_(MPC_VIDEO_CODEC, GetActiveCodecs()) PURE;
-
- STDMETHOD_(LPCTSTR, GetVideoCardDescription()) PURE;
-
- STDMETHOD(SetARMode(int nValue)) PURE;
- STDMETHOD_(int, GetARMode()) PURE;
-
- STDMETHOD(SetDXVACheckCompatibility(int nValue)) PURE;
- STDMETHOD_(int, GetDXVACheckCompatibility()) PURE;
-
- STDMETHOD(SetDXVA_SD(int nValue)) PURE;
- STDMETHOD_(int, GetDXVA_SD()) PURE;
-};
-
-interface __declspec(uuid("F0ABC515-19ED-4D65-9D5F-59E36AE7F2AF"))
-IMPCVideoDecFilter2 :
-public IMPCVideoDecFilter {
- STDMETHOD_(int, GetFrameType()) PURE;
-
- STDMETHOD(SetInterlacedFlag(MPCVD_INTERLACED_FLAG interlacedFlag)) PURE;
- STDMETHOD_(MPCVD_INTERLACED_FLAG, GetInterlacedFlag()) PURE;
-};
+/*
+ * (C) 2006-2013 see Authors.txt
+ *
+ * This file is part of MPC-HC.
+ *
+ * MPC-HC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * MPC-HC 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#pragma once
+
+// Internal codec list (used to enable/disable codec in standalone mode)
+typedef enum {
+ MPCVD_H264 = 1 << 0,
+ MPCVD_VC1 = 1 << 1,
+ MPCVD_XVID = 1 << 2,
+ MPCVD_DIVX = 1 << 3,
+ MPCVD_WMV = 1 << 4,
+ MPCVD_MSMPEG4 = 1 << 5,
+ MPCVD_H263 = 1 << 6,
+ MPCVD_SVQ3 = 1 << 7,
+ MPCVD_THEORA = 1 << 8,
+ MPCVD_AMVV = 1 << 9,
+ MPCVD_FLASH = 1 << 10,
+ MPCVD_H264_DXVA = 1 << 11,
+ MPCVD_VC1_DXVA = 1 << 12,
+ MPCVD_VP356 = 1 << 13,
+ MPCVD_VP8 = 1 << 14,
+ MPCVD_MJPEG = 1 << 15,
+ MPCVD_INDEO = 1 << 16,
+ MPCVD_RV = 1 << 17,
+ MPCVD_WMV3_DXVA = 1 << 19,
+ MPCVD_MPEG2_DXVA = 1 << 20
+} MPC_VIDEO_CODEC;
+
+// Interlaced flag handling
+enum MPCVD_INTERLACED_FLAG {
+ MPCVC_INTERLACED_AUTO,
+ MPCVC_INTERLACED_PROGRESSIVE,
+ MPCVC_INTERLACED_TOP_FIELD_FIRST,
+ MPCVC_INTERLACED_BOTTOM_FIELD_FIRST
+};
+
+interface __declspec(uuid("CDC3B5B3-A8B0-4c70-A805-9FC80CDEF262"))
+IMPCVideoDecFilter :
+public IUnknown {
+ STDMETHOD(Apply()) PURE;
+
+ STDMETHOD(SetThreadNumber(int nValue)) PURE;
+ STDMETHOD_(int, GetThreadNumber()) PURE;
+
+ STDMETHOD(SetDiscardMode(int nValue)) PURE;
+ STDMETHOD_(int, GetDiscardMode()) PURE;
+
+ STDMETHOD_(GUID*, GetDXVADecoderGuid()) PURE;
+
+ STDMETHOD(SetActiveCodecs(MPC_VIDEO_CODEC nValue)) PURE;
+ STDMETHOD_(MPC_VIDEO_CODEC, GetActiveCodecs()) PURE;
+
+ STDMETHOD_(LPCTSTR, GetVideoCardDescription()) PURE;
+
+ STDMETHOD(SetARMode(int nValue)) PURE;
+ STDMETHOD_(int, GetARMode()) PURE;
+
+ STDMETHOD(SetDXVACheckCompatibility(int nValue)) PURE;
+ STDMETHOD_(int, GetDXVACheckCompatibility()) PURE;
+
+ STDMETHOD(SetDXVA_SD(int nValue)) PURE;
+ STDMETHOD_(int, GetDXVA_SD()) PURE;
+};
+
+interface __declspec(uuid("F0ABC515-19ED-4D65-9D5F-59E36AE7F2AF"))
+IMPCVideoDecFilter2 :
+public IMPCVideoDecFilter {
+ STDMETHOD_(int, GetFrameType()) PURE;
+
+ STDMETHOD(SetInterlacedFlag(MPCVD_INTERLACED_FLAG interlacedFlag)) PURE;
+ STDMETHOD_(MPCVD_INTERLACED_FLAG, GetInterlacedFlag()) PURE;
+};
diff --git a/include/moreuuids.h b/include/moreuuids.h
index 4bf62c678..c6ad090e3 100644
--- a/include/moreuuids.h
+++ b/include/moreuuids.h
@@ -1263,3 +1263,8 @@ DEFINE_GUID(CLSID_FFDShowDXVADecoder, 0x0B0EFF97, 0xC750, 0x462C, 0x94, 0x88, 0x
// Microsoft DTV-DVD Audio Decoder - {E1F1A0B8-BEEE-490D-BA7C-066C40B5E2B9}
DEFINE_GUID(CLSID_MSDVTDVDAudioDecoder, 0xE1F1A0B8, 0xBEEE, 0x490D, 0xBA, 0x7C, 0x06, 0x6C, 0x40, 0xB5, 0xE2, 0xB9);
+
+// Old MPC-HC filters
+DEFINE_GUID(CLSID_MPCMpegSplitter, 0xDC257063, 0x045F, 0x4BE2, 0xBD, 0x5B, 0xE1, 0x22, 0x79, 0xC4, 0x64, 0xF0);
+DEFINE_GUID(CLSID_MPCMpegSplitterSource, 0x1365BE7A, 0xC86A, 0x473C, 0x9A, 0x41, 0xC0, 0xA6, 0xE8, 0x2C, 0x9F, 0xA3);
+DEFINE_GUID(CLSID_MPCVideoDecoder, 0x008BAC12, 0xFBAF, 0x497b, 0x96, 0x70, 0xBC, 0x6F, 0x6F, 0xBA, 0xE2, 0xC4);
diff --git a/mpc-hc.sln b/mpc-hc.sln
index b0a4b7ea7..7f321aaeb 100644
--- a/mpc-hc.sln
+++ b/mpc-hc.sln
@@ -51,10 +51,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BaseClasses", "src\thirdpar
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Filters", "src\filters\Filters.vcxproj", "{273B3149-3192-4B75-A791-470320B90812}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ffmpeg", "src\thirdparty\ffmpeg\ffmpeg.vcxproj", "{438286B7-A9F4-411D-BCC5-948C40E37D8F}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libflac", "src\thirdparty\libflac\src\libFLAC\libflac.vcxproj", "{4CEFBC84-C215-11DB-8314-0800200C9A66}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "src\thirdparty\zlib\zlib.vcxproj", "{2FCD4B66-9CF9-4C8F-BC70-37CD20002D49}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BaseMuxer", "src\filters\muxer\BaseMuxer\BaseMuxer.vcxproj", "{DB5F93B2-54D0-4474-A588-D259BE36C832}"
@@ -65,26 +61,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MatroskaMuxer", "src\filter
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WavDest", "src\filters\muxer\WavDest\WavDest.vcxproj", "{EB202B68-8029-4985-B914-E94B44D2E230}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AviSplitter", "src\filters\parser\AviSplitter\AviSplitter.vcxproj", "{9738B023-FC46-48A2-953A-0035FD897678}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BaseSplitter", "src\filters\parser\BaseSplitter\BaseSplitter.vcxproj", "{37768B3F-89BC-4C16-B2A8-767C5DA84C3F}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DSMSplitter", "src\filters\parser\DSMSplitter\DSMSplitter.vcxproj", "{1E91F58C-0BAE-4021-8087-D1864D8EC066}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FLVSplitter", "src\filters\parser\FLVSplitter\FLVSplitter.vcxproj", "{E62223EF-8263-41EB-8174-CD78BBEEF368}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MatroskaSplitter", "src\filters\parser\MatroskaSplitter\MatroskaSplitter.vcxproj", "{3F5EA225-F4B7-4413-AEB3-4E4E5751E438}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MP4Splitter", "src\filters\parser\MP4Splitter\MP4Splitter.vcxproj", "{9ED4B036-7399-4128-868D-6E71188E0277}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MpaSplitter", "src\filters\parser\MpaSplitter\MpaSplitter.vcxproj", "{C0F7A036-FC2D-40DF-9852-C37518DB6B3E}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MpegSplitter", "src\filters\parser\MpegSplitter\MpegSplitter.vcxproj", "{4628C665-EDE4-40D2-B525-32BE8B8551C8}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OggSplitter", "src\filters\parser\OggSplitter\OggSplitter.vcxproj", "{7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RealMediaSplitter", "src\filters\parser\RealMediaSplitter\RealMediaSplitter.vcxproj", "{53CF9195-19DB-457D-8F55-8DB1706DFA84}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StreamDriveThru", "src\filters\parser\StreamDriveThru\StreamDriveThru.vcxproj", "{AE399B7E-2B2C-4A96-9016-C5C74B0A2FA0}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AsyncReader", "src\thirdparty\AsyncReader\AsyncReader.vcxproj", "{9F31D122-E84D-485A-A58D-09DAD01A56CE}"
@@ -107,12 +87,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BaseSource", "src\filters\s
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "D2VSource", "src\filters\source\D2VSource\D2VSource.vcxproj", "{83CC6B88-A112-4192-BD5A-F2A249AF2277}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DTSAC3Source", "src\filters\source\DTSAC3Source\DTSAC3Source.vcxproj", "{30D48874-899F-41C6-9B26-A40C96C91102}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FLACSource", "src\filters\source\FLACSource\FLACSource.vcxproj", "{916D0FC1-1D86-487A-82DE-37FBEE43FB34}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FLICSource", "src\filters\source\FLICSource\FLICSource.vcxproj", "{431DD5B6-3F2F-47EE-A23F-514BC044B704}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ShoutcastSource", "src\filters\source\ShoutcastSource\ShoutcastSource.vcxproj", "{42B599D7-BB84-481F-A42A-2DBE0E2E2D7E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SubtitleSource", "src\filters\source\SubtitleSource\SubtitleSource.vcxproj", "{8F998497-9C51-4FAA-83E4-1D85B22CBA13}"
@@ -127,12 +101,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BufferFilter", "src\filters
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DeCSSFilter", "src\filters\transform\DeCSSFilter\DeCSSFilter.vcxproj", "{F6B06383-3FFD-403B-9867-4AA82A20AA83}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MpaDecFilter", "src\filters\transform\MpaDecFilter\MpaDecFilter.vcxproj", "{4421516D-10A6-41C1-ADF3-099573BBB0C6}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MPCVideoDec", "src\filters\transform\MPCVideoDec\MPCVideoDec.vcxproj", "{58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Mpeg2DecFilter", "src\filters\transform\Mpeg2DecFilter\Mpeg2DecFilter.vcxproj", "{305BAB2D-0D75-4FBC-8BCD-A2917392B48C}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lcms2", "src\thirdparty\lcms2\lcms2.vcxproj", "{ACF5C64B-78AA-4730-91A2-24F4910FBAD9}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MediaInfoLib", "src\thirdparty\MediaInfo\MediaInfoLib.vcxproj", "{20E0F8D6-213C-460B-B361-9C725CB375C7}"
@@ -143,8 +111,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SoundTouch", "src\thirdpart
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VSFilter", "src\filters\transform\VSFilter\VSFilter.vcxproj", "{F671100C-469F-4723-AAC4-B7FE4F5B8DC4}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Bento4", "src\thirdparty\Bento4\Bento4.vcxproj", "{40177920-A66C-4647-B119-332A10224C83}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unrar", "src\thirdparty\unrar\unrar.vcxproj", "{DA8461C4-7683-4360-9372-2A9E0F1795C2}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RARFileSource", "src\thirdparty\RARFileSource\RARFileSource.vcxproj", "{2B7F22D7-1750-47C5-8709-1A3688B62499}"
@@ -479,38 +445,6 @@ Global
{273B3149-3192-4B75-A791-470320B90812}.Release|Win32.Build.0 = Release|Win32
{273B3149-3192-4B75-A791-470320B90812}.Release|x64.ActiveCfg = Release|x64
{273B3149-3192-4B75-A791-470320B90812}.Release|x64.Build.0 = Release|x64
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Debug Filter|Win32.ActiveCfg = Debug|Win32
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Debug Filter|Win32.Build.0 = Debug|Win32
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Debug Filter|x64.ActiveCfg = Debug|x64
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Debug Filter|x64.Build.0 = Debug|x64
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Debug Lite|x64.ActiveCfg = Debug|x64
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Debug|Win32.ActiveCfg = Debug|Win32
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Debug|x64.ActiveCfg = Debug|x64
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Release Filter|Win32.ActiveCfg = Release|Win32
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Release Filter|Win32.Build.0 = Release|Win32
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Release Filter|x64.ActiveCfg = Release|x64
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Release Filter|x64.Build.0 = Release|x64
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Release Lite|Win32.ActiveCfg = Release|Win32
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Release Lite|x64.ActiveCfg = Release|x64
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Release|Win32.ActiveCfg = Release|Win32
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Release|x64.ActiveCfg = Release|x64
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Debug Filter|Win32.ActiveCfg = Debug|Win32
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Debug Filter|Win32.Build.0 = Debug|Win32
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Debug Filter|x64.ActiveCfg = Debug|x64
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Debug Filter|x64.Build.0 = Debug|x64
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Debug Lite|x64.ActiveCfg = Debug|x64
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Debug|Win32.ActiveCfg = Debug|Win32
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Debug|x64.ActiveCfg = Debug|x64
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Release Filter|Win32.ActiveCfg = Release|Win32
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Release Filter|Win32.Build.0 = Release|Win32
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Release Filter|x64.ActiveCfg = Release|x64
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Release Filter|x64.Build.0 = Release|x64
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Release Lite|Win32.ActiveCfg = Release|Win32
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Release Lite|x64.ActiveCfg = Release|x64
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Release|Win32.ActiveCfg = Release|Win32
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Release|x64.ActiveCfg = Release|x64
{2FCD4B66-9CF9-4C8F-BC70-37CD20002D49}.Debug Filter|Win32.ActiveCfg = Debug|Win32
{2FCD4B66-9CF9-4C8F-BC70-37CD20002D49}.Debug Filter|Win32.Build.0 = Debug|Win32
{2FCD4B66-9CF9-4C8F-BC70-37CD20002D49}.Debug Filter|x64.ActiveCfg = Debug|x64
@@ -631,22 +565,6 @@ Global
{EB202B68-8029-4985-B914-E94B44D2E230}.Release|Win32.Build.0 = Release|Win32
{EB202B68-8029-4985-B914-E94B44D2E230}.Release|x64.ActiveCfg = Release|x64
{EB202B68-8029-4985-B914-E94B44D2E230}.Release|x64.Build.0 = Release|x64
- {9738B023-FC46-48A2-953A-0035FD897678}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {9738B023-FC46-48A2-953A-0035FD897678}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {9738B023-FC46-48A2-953A-0035FD897678}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {9738B023-FC46-48A2-953A-0035FD897678}.Debug Filter|x64.Build.0 = Debug Filter|x64
- {9738B023-FC46-48A2-953A-0035FD897678}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {9738B023-FC46-48A2-953A-0035FD897678}.Debug Lite|x64.ActiveCfg = Debug|x64
- {9738B023-FC46-48A2-953A-0035FD897678}.Debug|Win32.ActiveCfg = Debug|Win32
- {9738B023-FC46-48A2-953A-0035FD897678}.Debug|x64.ActiveCfg = Debug|x64
- {9738B023-FC46-48A2-953A-0035FD897678}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {9738B023-FC46-48A2-953A-0035FD897678}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {9738B023-FC46-48A2-953A-0035FD897678}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {9738B023-FC46-48A2-953A-0035FD897678}.Release Filter|x64.Build.0 = Release Filter|x64
- {9738B023-FC46-48A2-953A-0035FD897678}.Release Lite|Win32.ActiveCfg = Release|Win32
- {9738B023-FC46-48A2-953A-0035FD897678}.Release Lite|x64.ActiveCfg = Release|x64
- {9738B023-FC46-48A2-953A-0035FD897678}.Release|Win32.ActiveCfg = Release|Win32
- {9738B023-FC46-48A2-953A-0035FD897678}.Release|x64.ActiveCfg = Release|x64
{37768B3F-89BC-4C16-B2A8-767C5DA84C3F}.Debug Filter|Win32.ActiveCfg = Debug|Win32
{37768B3F-89BC-4C16-B2A8-767C5DA84C3F}.Debug Filter|Win32.Build.0 = Debug|Win32
{37768B3F-89BC-4C16-B2A8-767C5DA84C3F}.Debug Filter|x64.ActiveCfg = Debug|x64
@@ -687,118 +605,6 @@ Global
{1E91F58C-0BAE-4021-8087-D1864D8EC066}.Release|Win32.Build.0 = Release|Win32
{1E91F58C-0BAE-4021-8087-D1864D8EC066}.Release|x64.ActiveCfg = Release|x64
{1E91F58C-0BAE-4021-8087-D1864D8EC066}.Release|x64.Build.0 = Release|x64
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Debug Filter|x64.Build.0 = Debug Filter|x64
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Debug Lite|x64.ActiveCfg = Debug|x64
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Debug|Win32.ActiveCfg = Debug|Win32
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Debug|x64.ActiveCfg = Debug|x64
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Release Filter|x64.Build.0 = Release Filter|x64
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Release Lite|Win32.ActiveCfg = Release|Win32
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Release Lite|x64.ActiveCfg = Release|x64
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Release|Win32.ActiveCfg = Release|Win32
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Release|x64.ActiveCfg = Release|x64
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Debug Filter|x64.Build.0 = Debug Filter|x64
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Debug Lite|x64.ActiveCfg = Debug|x64
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Debug|Win32.ActiveCfg = Debug|Win32
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Debug|x64.ActiveCfg = Debug|x64
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Release Filter|x64.Build.0 = Release Filter|x64
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Release Lite|Win32.ActiveCfg = Release|Win32
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Release Lite|x64.ActiveCfg = Release|x64
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Release|Win32.ActiveCfg = Release|Win32
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Release|x64.ActiveCfg = Release|x64
- {9ED4B036-7399-4128-868D-6E71188E0277}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {9ED4B036-7399-4128-868D-6E71188E0277}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {9ED4B036-7399-4128-868D-6E71188E0277}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {9ED4B036-7399-4128-868D-6E71188E0277}.Debug Filter|x64.Build.0 = Debug Filter|x64
- {9ED4B036-7399-4128-868D-6E71188E0277}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {9ED4B036-7399-4128-868D-6E71188E0277}.Debug Lite|x64.ActiveCfg = Debug|x64
- {9ED4B036-7399-4128-868D-6E71188E0277}.Debug|Win32.ActiveCfg = Debug|Win32
- {9ED4B036-7399-4128-868D-6E71188E0277}.Debug|x64.ActiveCfg = Debug|x64
- {9ED4B036-7399-4128-868D-6E71188E0277}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {9ED4B036-7399-4128-868D-6E71188E0277}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {9ED4B036-7399-4128-868D-6E71188E0277}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {9ED4B036-7399-4128-868D-6E71188E0277}.Release Filter|x64.Build.0 = Release Filter|x64
- {9ED4B036-7399-4128-868D-6E71188E0277}.Release Lite|Win32.ActiveCfg = Release|Win32
- {9ED4B036-7399-4128-868D-6E71188E0277}.Release Lite|x64.ActiveCfg = Release|x64
- {9ED4B036-7399-4128-868D-6E71188E0277}.Release|Win32.ActiveCfg = Release|Win32
- {9ED4B036-7399-4128-868D-6E71188E0277}.Release|x64.ActiveCfg = Release|x64
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Debug Filter|x64.Build.0 = Debug Filter|x64
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Debug Lite|x64.ActiveCfg = Debug|x64
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Debug|Win32.ActiveCfg = Debug|Win32
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Debug|x64.ActiveCfg = Debug|x64
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Release Filter|x64.Build.0 = Release Filter|x64
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Release Lite|Win32.ActiveCfg = Release|Win32
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Release Lite|x64.ActiveCfg = Release|x64
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Release|Win32.ActiveCfg = Release|Win32
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Release|x64.ActiveCfg = Release|x64
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Debug Filter|x64.Build.0 = Debug Filter|x64
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Debug Lite|x64.ActiveCfg = Debug|x64
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Debug|Win32.ActiveCfg = Debug|Win32
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Debug|x64.ActiveCfg = Debug|x64
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Release Filter|x64.Build.0 = Release Filter|x64
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Release Lite|Win32.ActiveCfg = Release|Win32
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Release Lite|x64.ActiveCfg = Release|x64
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Release|Win32.ActiveCfg = Release|Win32
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Release|x64.ActiveCfg = Release|x64
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Debug Filter|x64.Build.0 = Debug Filter|x64
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Debug Lite|x64.ActiveCfg = Debug|x64
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Debug|Win32.ActiveCfg = Debug|Win32
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Debug|x64.ActiveCfg = Debug|x64
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Release Filter|x64.Build.0 = Release Filter|x64
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Release Lite|Win32.ActiveCfg = Release|Win32
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Release Lite|x64.ActiveCfg = Release|x64
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Release|Win32.ActiveCfg = Release|Win32
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Release|x64.ActiveCfg = Release|x64
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Debug Filter|x64.Build.0 = Debug Filter|x64
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Debug Lite|x64.ActiveCfg = Debug|x64
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Debug|Win32.ActiveCfg = Debug|Win32
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Debug|x64.ActiveCfg = Debug|x64
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Release Filter|x64.Build.0 = Release Filter|x64
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Release Lite|Win32.ActiveCfg = Release|Win32
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Release Lite|x64.ActiveCfg = Release|x64
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Release|Win32.ActiveCfg = Release|Win32
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Release|x64.ActiveCfg = Release|x64
{AE399B7E-2B2C-4A96-9016-C5C74B0A2FA0}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
{AE399B7E-2B2C-4A96-9016-C5C74B0A2FA0}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
{AE399B7E-2B2C-4A96-9016-C5C74B0A2FA0}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
@@ -1025,54 +831,6 @@ Global
{83CC6B88-A112-4192-BD5A-F2A249AF2277}.Release|Win32.Build.0 = Release|Win32
{83CC6B88-A112-4192-BD5A-F2A249AF2277}.Release|x64.ActiveCfg = Release|x64
{83CC6B88-A112-4192-BD5A-F2A249AF2277}.Release|x64.Build.0 = Release|x64
- {30D48874-899F-41C6-9B26-A40C96C91102}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {30D48874-899F-41C6-9B26-A40C96C91102}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {30D48874-899F-41C6-9B26-A40C96C91102}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {30D48874-899F-41C6-9B26-A40C96C91102}.Debug Filter|x64.Build.0 = Debug Filter|x64
- {30D48874-899F-41C6-9B26-A40C96C91102}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {30D48874-899F-41C6-9B26-A40C96C91102}.Debug Lite|x64.ActiveCfg = Debug|x64
- {30D48874-899F-41C6-9B26-A40C96C91102}.Debug|Win32.ActiveCfg = Debug|Win32
- {30D48874-899F-41C6-9B26-A40C96C91102}.Debug|x64.ActiveCfg = Debug|x64
- {30D48874-899F-41C6-9B26-A40C96C91102}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {30D48874-899F-41C6-9B26-A40C96C91102}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {30D48874-899F-41C6-9B26-A40C96C91102}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {30D48874-899F-41C6-9B26-A40C96C91102}.Release Filter|x64.Build.0 = Release Filter|x64
- {30D48874-899F-41C6-9B26-A40C96C91102}.Release Lite|Win32.ActiveCfg = Release|Win32
- {30D48874-899F-41C6-9B26-A40C96C91102}.Release Lite|x64.ActiveCfg = Release|x64
- {30D48874-899F-41C6-9B26-A40C96C91102}.Release|Win32.ActiveCfg = Release|Win32
- {30D48874-899F-41C6-9B26-A40C96C91102}.Release|x64.ActiveCfg = Release|x64
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Debug Filter|x64.Build.0 = Debug Filter|x64
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Debug Lite|x64.ActiveCfg = Debug|x64
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Debug|Win32.ActiveCfg = Debug|Win32
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Debug|x64.ActiveCfg = Debug|x64
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Release Filter|x64.Build.0 = Release Filter|x64
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Release Lite|Win32.ActiveCfg = Release|Win32
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Release Lite|x64.ActiveCfg = Release|x64
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Release|Win32.ActiveCfg = Release|Win32
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Release|x64.ActiveCfg = Release|x64
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Debug Filter|x64.Build.0 = Debug Filter|x64
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Debug Lite|x64.ActiveCfg = Debug|x64
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Debug|Win32.ActiveCfg = Debug|Win32
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Debug|x64.ActiveCfg = Debug|x64
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Release Filter|x64.Build.0 = Release Filter|x64
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Release Lite|Win32.ActiveCfg = Release|Win32
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Release Lite|x64.ActiveCfg = Release|x64
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Release|Win32.ActiveCfg = Release|Win32
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Release|x64.ActiveCfg = Release|x64
{42B599D7-BB84-481F-A42A-2DBE0E2E2D7E}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
{42B599D7-BB84-481F-A42A-2DBE0E2E2D7E}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
{42B599D7-BB84-481F-A42A-2DBE0E2E2D7E}.Debug Filter|x64.ActiveCfg = Debug|x64
@@ -1221,52 +979,6 @@ Global
{F6B06383-3FFD-403B-9867-4AA82A20AA83}.Release|Win32.Build.0 = Release|Win32
{F6B06383-3FFD-403B-9867-4AA82A20AA83}.Release|x64.ActiveCfg = Release|x64
{F6B06383-3FFD-403B-9867-4AA82A20AA83}.Release|x64.Build.0 = Release|x64
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Debug Filter|x64.Build.0 = Debug Filter|x64
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Debug Lite|x64.ActiveCfg = Debug|x64
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Debug|Win32.ActiveCfg = Debug|Win32
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Debug|x64.ActiveCfg = Debug|x64
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Release Filter|x64.Build.0 = Release Filter|x64
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Release Lite|Win32.ActiveCfg = Release|Win32
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Release Lite|x64.ActiveCfg = Release|x64
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Release|Win32.ActiveCfg = Release|Win32
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Release|x64.ActiveCfg = Release|x64
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Debug Filter|x64.Build.0 = Debug Filter|x64
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Debug Lite|x64.ActiveCfg = Debug|x64
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Debug|Win32.ActiveCfg = Debug|Win32
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Debug|x64.ActiveCfg = Debug|x64
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Release Filter|x64.Build.0 = Release Filter|x64
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Release Lite|Win32.ActiveCfg = Release|Win32
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Release Lite|x64.ActiveCfg = Release|x64
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Release|Win32.ActiveCfg = Release|Win32
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Release|x64.ActiveCfg = Release|x64
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Debug Lite|x64.ActiveCfg = Debug|x64
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Debug|Win32.ActiveCfg = Debug|Win32
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Debug|x64.ActiveCfg = Debug|x64
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Release Lite|Win32.ActiveCfg = Release|Win32
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Release Lite|x64.ActiveCfg = Release|x64
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Release|Win32.ActiveCfg = Release|Win32
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Release|x64.ActiveCfg = Release|x64
{ACF5C64B-78AA-4730-91A2-24F4910FBAD9}.Debug Filter|Win32.ActiveCfg = Debug|Win32
{ACF5C64B-78AA-4730-91A2-24F4910FBAD9}.Debug Filter|x64.ActiveCfg = Debug|x64
{ACF5C64B-78AA-4730-91A2-24F4910FBAD9}.Debug Lite|Win32.ActiveCfg = Debug|Win32
@@ -1359,22 +1071,6 @@ Global
{F671100C-469F-4723-AAC4-B7FE4F5B8DC4}.Release Lite|x64.ActiveCfg = Release Filter|x64
{F671100C-469F-4723-AAC4-B7FE4F5B8DC4}.Release|Win32.ActiveCfg = Release Filter|Win32
{F671100C-469F-4723-AAC4-B7FE4F5B8DC4}.Release|x64.ActiveCfg = Release Filter|x64
- {40177920-A66C-4647-B119-332A10224C83}.Debug Filter|Win32.ActiveCfg = Debug|Win32
- {40177920-A66C-4647-B119-332A10224C83}.Debug Filter|Win32.Build.0 = Debug|Win32
- {40177920-A66C-4647-B119-332A10224C83}.Debug Filter|x64.ActiveCfg = Debug|x64
- {40177920-A66C-4647-B119-332A10224C83}.Debug Filter|x64.Build.0 = Debug|x64
- {40177920-A66C-4647-B119-332A10224C83}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {40177920-A66C-4647-B119-332A10224C83}.Debug Lite|x64.ActiveCfg = Debug|x64
- {40177920-A66C-4647-B119-332A10224C83}.Debug|Win32.ActiveCfg = Debug|Win32
- {40177920-A66C-4647-B119-332A10224C83}.Debug|x64.ActiveCfg = Debug|x64
- {40177920-A66C-4647-B119-332A10224C83}.Release Filter|Win32.ActiveCfg = Release|Win32
- {40177920-A66C-4647-B119-332A10224C83}.Release Filter|Win32.Build.0 = Release|Win32
- {40177920-A66C-4647-B119-332A10224C83}.Release Filter|x64.ActiveCfg = Release|x64
- {40177920-A66C-4647-B119-332A10224C83}.Release Filter|x64.Build.0 = Release|x64
- {40177920-A66C-4647-B119-332A10224C83}.Release Lite|Win32.ActiveCfg = Release|Win32
- {40177920-A66C-4647-B119-332A10224C83}.Release Lite|x64.ActiveCfg = Release|x64
- {40177920-A66C-4647-B119-332A10224C83}.Release|Win32.ActiveCfg = Release|Win32
- {40177920-A66C-4647-B119-332A10224C83}.Release|x64.ActiveCfg = Release|x64
{DA8461C4-7683-4360-9372-2A9E0F1795C2}.Debug Filter|Win32.ActiveCfg = Debug|Win32
{DA8461C4-7683-4360-9372-2A9E0F1795C2}.Debug Filter|Win32.Build.0 = Debug|Win32
{DA8461C4-7683-4360-9372-2A9E0F1795C2}.Debug Filter|x64.ActiveCfg = Debug|x64
@@ -1448,15 +1144,12 @@ Global
{C2082189-3ECB-4079-91FA-89D3C8A305C0} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
{E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
{273B3149-3192-4B75-A791-470320B90812} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
- {438286B7-A9F4-411D-BCC5-948C40E37D8F} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
- {4CEFBC84-C215-11DB-8314-0800200C9A66} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
{2FCD4B66-9CF9-4C8F-BC70-37CD20002D49} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
{9F31D122-E84D-485A-A58D-09DAD01A56CE} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
{ACF5C64B-78AA-4730-91A2-24F4910FBAD9} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
{20E0F8D6-213C-460B-B361-9C725CB375C7} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
{0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
{68A5DD20-7057-448B-8FE0-B6AC8D205509} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
- {40177920-A66C-4647-B119-332A10224C83} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
{DA8461C4-7683-4360-9372-2A9E0F1795C2} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
{2B7F22D7-1750-47C5-8709-1A3688B62499} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
{ED257874-E12E-4143-AF0A-0676DA3BB18C} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
@@ -1476,16 +1169,8 @@ Global
{65361C7C-83D6-42E4-870C-4DC85AE641FE} = {49B5BAE3-749C-414C-80CC-A756DD548CE3}
{67827491-8162-4039-9132-F934ABC836A0} = {49B5BAE3-749C-414C-80CC-A756DD548CE3}
{EB202B68-8029-4985-B914-E94B44D2E230} = {49B5BAE3-749C-414C-80CC-A756DD548CE3}
- {9738B023-FC46-48A2-953A-0035FD897678} = {D626CC4F-BFB1-4030-8DD8-1A3A1D41248E}
{37768B3F-89BC-4C16-B2A8-767C5DA84C3F} = {D626CC4F-BFB1-4030-8DD8-1A3A1D41248E}
{1E91F58C-0BAE-4021-8087-D1864D8EC066} = {D626CC4F-BFB1-4030-8DD8-1A3A1D41248E}
- {E62223EF-8263-41EB-8174-CD78BBEEF368} = {D626CC4F-BFB1-4030-8DD8-1A3A1D41248E}
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438} = {D626CC4F-BFB1-4030-8DD8-1A3A1D41248E}
- {9ED4B036-7399-4128-868D-6E71188E0277} = {D626CC4F-BFB1-4030-8DD8-1A3A1D41248E}
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E} = {D626CC4F-BFB1-4030-8DD8-1A3A1D41248E}
- {4628C665-EDE4-40D2-B525-32BE8B8551C8} = {D626CC4F-BFB1-4030-8DD8-1A3A1D41248E}
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475} = {D626CC4F-BFB1-4030-8DD8-1A3A1D41248E}
- {53CF9195-19DB-457D-8F55-8DB1706DFA84} = {D626CC4F-BFB1-4030-8DD8-1A3A1D41248E}
{AE399B7E-2B2C-4A96-9016-C5C74B0A2FA0} = {D626CC4F-BFB1-4030-8DD8-1A3A1D41248E}
{543D40E9-8CA6-4E4B-9936-90CBA562B268} = {4909B0ED-CC22-4509-ACD0-FB60C4FC73ED}
{4D3B4FF4-535A-4201-AB7D-9AEC1E737A95} = {4909B0ED-CC22-4509-ACD0-FB60C4FC73ED}
@@ -1496,9 +1181,6 @@ Global
{FB565A7A-50DC-4A0D-852D-5E7F74DAB82C} = {C0038E92-68BF-4491-B5AA-BEE9857A49F8}
{F50E74C2-5BE7-4C9B-B1E7-6CA19CFAD34E} = {02DAA1A6-31C8-4002-89FE-50BF53752244}
{83CC6B88-A112-4192-BD5A-F2A249AF2277} = {02DAA1A6-31C8-4002-89FE-50BF53752244}
- {30D48874-899F-41C6-9B26-A40C96C91102} = {02DAA1A6-31C8-4002-89FE-50BF53752244}
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34} = {02DAA1A6-31C8-4002-89FE-50BF53752244}
- {431DD5B6-3F2F-47EE-A23F-514BC044B704} = {02DAA1A6-31C8-4002-89FE-50BF53752244}
{42B599D7-BB84-481F-A42A-2DBE0E2E2D7E} = {02DAA1A6-31C8-4002-89FE-50BF53752244}
{8F998497-9C51-4FAA-83E4-1D85B22CBA13} = {02DAA1A6-31C8-4002-89FE-50BF53752244}
{D8DB3E7E-D50E-4EC3-A9B9-DAD18F5FE466} = {683639C3-F209-4EF8-B6CC-8741C61EDECF}
@@ -1506,9 +1188,6 @@ Global
{54DDA60F-E528-4D07-A152-960A1E818680} = {F9F42BF2-3F13-4654-82C5-E27B8879EC4E}
{9DCFD02A-16A0-4766-BC18-66163E21929D} = {F9F42BF2-3F13-4654-82C5-E27B8879EC4E}
{F6B06383-3FFD-403B-9867-4AA82A20AA83} = {F9F42BF2-3F13-4654-82C5-E27B8879EC4E}
- {4421516D-10A6-41C1-ADF3-099573BBB0C6} = {F9F42BF2-3F13-4654-82C5-E27B8879EC4E}
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF} = {F9F42BF2-3F13-4654-82C5-E27B8879EC4E}
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C} = {F9F42BF2-3F13-4654-82C5-E27B8879EC4E}
{F671100C-469F-4723-AAC4-B7FE4F5B8DC4} = {F9F42BF2-3F13-4654-82C5-E27B8879EC4E}
EndGlobalSection
EndGlobal
diff --git a/mpc-hc_vs2012.sln b/mpc-hc_vs2012.sln
index bd464ad0b..e27918aa3 100644
--- a/mpc-hc_vs2012.sln
+++ b/mpc-hc_vs2012.sln
@@ -50,10 +50,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BaseClasses", "src\thirdpar
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Filters", "src\filters\Filters.vcxproj", "{273B3149-3192-4B75-A791-470320B90812}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ffmpeg", "src\thirdparty\ffmpeg\ffmpeg.vcxproj", "{438286B7-A9F4-411D-BCC5-948C40E37D8F}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libflac", "src\thirdparty\libflac\src\libFLAC\libflac.vcxproj", "{4CEFBC84-C215-11DB-8314-0800200C9A66}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "src\thirdparty\zlib\zlib.vcxproj", "{2FCD4B66-9CF9-4C8F-BC70-37CD20002D49}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BaseMuxer", "src\filters\muxer\BaseMuxer\BaseMuxer.vcxproj", "{DB5F93B2-54D0-4474-A588-D259BE36C832}"
@@ -64,26 +60,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MatroskaMuxer", "src\filter
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WavDest", "src\filters\muxer\WavDest\WavDest.vcxproj", "{EB202B68-8029-4985-B914-E94B44D2E230}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AviSplitter", "src\filters\parser\AviSplitter\AviSplitter.vcxproj", "{9738B023-FC46-48A2-953A-0035FD897678}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BaseSplitter", "src\filters\parser\BaseSplitter\BaseSplitter.vcxproj", "{37768B3F-89BC-4C16-B2A8-767C5DA84C3F}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DSMSplitter", "src\filters\parser\DSMSplitter\DSMSplitter.vcxproj", "{1E91F58C-0BAE-4021-8087-D1864D8EC066}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FLVSplitter", "src\filters\parser\FLVSplitter\FLVSplitter.vcxproj", "{E62223EF-8263-41EB-8174-CD78BBEEF368}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MatroskaSplitter", "src\filters\parser\MatroskaSplitter\MatroskaSplitter.vcxproj", "{3F5EA225-F4B7-4413-AEB3-4E4E5751E438}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MP4Splitter", "src\filters\parser\MP4Splitter\MP4Splitter.vcxproj", "{9ED4B036-7399-4128-868D-6E71188E0277}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MpaSplitter", "src\filters\parser\MpaSplitter\MpaSplitter.vcxproj", "{C0F7A036-FC2D-40DF-9852-C37518DB6B3E}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MpegSplitter", "src\filters\parser\MpegSplitter\MpegSplitter.vcxproj", "{4628C665-EDE4-40D2-B525-32BE8B8551C8}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OggSplitter", "src\filters\parser\OggSplitter\OggSplitter.vcxproj", "{7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RealMediaSplitter", "src\filters\parser\RealMediaSplitter\RealMediaSplitter.vcxproj", "{53CF9195-19DB-457D-8F55-8DB1706DFA84}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StreamDriveThru", "src\filters\parser\StreamDriveThru\StreamDriveThru.vcxproj", "{AE399B7E-2B2C-4A96-9016-C5C74B0A2FA0}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AsyncReader", "src\thirdparty\AsyncReader\AsyncReader.vcxproj", "{9F31D122-E84D-485A-A58D-09DAD01A56CE}"
@@ -106,12 +86,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BaseSource", "src\filters\s
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "D2VSource", "src\filters\source\D2VSource\D2VSource.vcxproj", "{83CC6B88-A112-4192-BD5A-F2A249AF2277}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DTSAC3Source", "src\filters\source\DTSAC3Source\DTSAC3Source.vcxproj", "{30D48874-899F-41C6-9B26-A40C96C91102}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FLACSource", "src\filters\source\FLACSource\FLACSource.vcxproj", "{916D0FC1-1D86-487A-82DE-37FBEE43FB34}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FLICSource", "src\filters\source\FLICSource\FLICSource.vcxproj", "{431DD5B6-3F2F-47EE-A23F-514BC044B704}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ShoutcastSource", "src\filters\source\ShoutcastSource\ShoutcastSource.vcxproj", "{42B599D7-BB84-481F-A42A-2DBE0E2E2D7E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SubtitleSource", "src\filters\source\SubtitleSource\SubtitleSource.vcxproj", "{8F998497-9C51-4FAA-83E4-1D85B22CBA13}"
@@ -126,12 +100,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BufferFilter", "src\filters
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DeCSSFilter", "src\filters\transform\DeCSSFilter\DeCSSFilter.vcxproj", "{F6B06383-3FFD-403B-9867-4AA82A20AA83}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MpaDecFilter", "src\filters\transform\MpaDecFilter\MpaDecFilter.vcxproj", "{4421516D-10A6-41C1-ADF3-099573BBB0C6}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MPCVideoDec", "src\filters\transform\MPCVideoDec\MPCVideoDec.vcxproj", "{58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Mpeg2DecFilter", "src\filters\transform\Mpeg2DecFilter\Mpeg2DecFilter.vcxproj", "{305BAB2D-0D75-4FBC-8BCD-A2917392B48C}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lcms2", "src\thirdparty\lcms2\lcms2.vcxproj", "{ACF5C64B-78AA-4730-91A2-24F4910FBAD9}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MediaInfoLib", "src\thirdparty\MediaInfo\MediaInfoLib.vcxproj", "{20E0F8D6-213C-460B-B361-9C725CB375C7}"
@@ -142,8 +110,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SoundTouch", "src\thirdpart
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VSFilter", "src\filters\transform\VSFilter\VSFilter.vcxproj", "{F671100C-469F-4723-AAC4-B7FE4F5B8DC4}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Bento4", "src\thirdparty\Bento4\Bento4.vcxproj", "{40177920-A66C-4647-B119-332A10224C83}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unrar", "src\thirdparty\unrar\unrar.vcxproj", "{DA8461C4-7683-4360-9372-2A9E0F1795C2}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RARFileSource", "src\thirdparty\RARFileSource\RARFileSource.vcxproj", "{2B7F22D7-1750-47C5-8709-1A3688B62499}"
@@ -478,38 +444,6 @@ Global
{273B3149-3192-4B75-A791-470320B90812}.Release|Win32.Build.0 = Release|Win32
{273B3149-3192-4B75-A791-470320B90812}.Release|x64.ActiveCfg = Release|x64
{273B3149-3192-4B75-A791-470320B90812}.Release|x64.Build.0 = Release|x64
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Debug Filter|Win32.ActiveCfg = Debug|Win32
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Debug Filter|Win32.Build.0 = Debug|Win32
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Debug Filter|x64.ActiveCfg = Debug|x64
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Debug Filter|x64.Build.0 = Debug|x64
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Debug Lite|x64.ActiveCfg = Debug|x64
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Debug|Win32.ActiveCfg = Debug|Win32
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Debug|x64.ActiveCfg = Debug|x64
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Release Filter|Win32.ActiveCfg = Release|Win32
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Release Filter|Win32.Build.0 = Release|Win32
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Release Filter|x64.ActiveCfg = Release|x64
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Release Filter|x64.Build.0 = Release|x64
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Release Lite|Win32.ActiveCfg = Release|Win32
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Release Lite|x64.ActiveCfg = Release|x64
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Release|Win32.ActiveCfg = Release|Win32
- {438286B7-A9F4-411D-BCC5-948C40E37D8F}.Release|x64.ActiveCfg = Release|x64
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Debug Filter|Win32.ActiveCfg = Debug|Win32
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Debug Filter|Win32.Build.0 = Debug|Win32
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Debug Filter|x64.ActiveCfg = Debug|x64
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Debug Filter|x64.Build.0 = Debug|x64
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Debug Lite|x64.ActiveCfg = Debug|x64
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Debug|Win32.ActiveCfg = Debug|Win32
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Debug|x64.ActiveCfg = Debug|x64
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Release Filter|Win32.ActiveCfg = Release|Win32
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Release Filter|Win32.Build.0 = Release|Win32
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Release Filter|x64.ActiveCfg = Release|x64
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Release Filter|x64.Build.0 = Release|x64
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Release Lite|Win32.ActiveCfg = Release|Win32
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Release Lite|x64.ActiveCfg = Release|x64
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Release|Win32.ActiveCfg = Release|Win32
- {4CEFBC84-C215-11DB-8314-0800200C9A66}.Release|x64.ActiveCfg = Release|x64
{2FCD4B66-9CF9-4C8F-BC70-37CD20002D49}.Debug Filter|Win32.ActiveCfg = Debug|Win32
{2FCD4B66-9CF9-4C8F-BC70-37CD20002D49}.Debug Filter|Win32.Build.0 = Debug|Win32
{2FCD4B66-9CF9-4C8F-BC70-37CD20002D49}.Debug Filter|x64.ActiveCfg = Debug|x64
@@ -630,22 +564,6 @@ Global
{EB202B68-8029-4985-B914-E94B44D2E230}.Release|Win32.Build.0 = Release|Win32
{EB202B68-8029-4985-B914-E94B44D2E230}.Release|x64.ActiveCfg = Release|x64
{EB202B68-8029-4985-B914-E94B44D2E230}.Release|x64.Build.0 = Release|x64
- {9738B023-FC46-48A2-953A-0035FD897678}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {9738B023-FC46-48A2-953A-0035FD897678}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {9738B023-FC46-48A2-953A-0035FD897678}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {9738B023-FC46-48A2-953A-0035FD897678}.Debug Filter|x64.Build.0 = Debug Filter|x64
- {9738B023-FC46-48A2-953A-0035FD897678}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {9738B023-FC46-48A2-953A-0035FD897678}.Debug Lite|x64.ActiveCfg = Debug|x64
- {9738B023-FC46-48A2-953A-0035FD897678}.Debug|Win32.ActiveCfg = Debug|Win32
- {9738B023-FC46-48A2-953A-0035FD897678}.Debug|x64.ActiveCfg = Debug|x64
- {9738B023-FC46-48A2-953A-0035FD897678}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {9738B023-FC46-48A2-953A-0035FD897678}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {9738B023-FC46-48A2-953A-0035FD897678}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {9738B023-FC46-48A2-953A-0035FD897678}.Release Filter|x64.Build.0 = Release Filter|x64
- {9738B023-FC46-48A2-953A-0035FD897678}.Release Lite|Win32.ActiveCfg = Release|Win32
- {9738B023-FC46-48A2-953A-0035FD897678}.Release Lite|x64.ActiveCfg = Release|x64
- {9738B023-FC46-48A2-953A-0035FD897678}.Release|Win32.ActiveCfg = Release|Win32
- {9738B023-FC46-48A2-953A-0035FD897678}.Release|x64.ActiveCfg = Release|x64
{37768B3F-89BC-4C16-B2A8-767C5DA84C3F}.Debug Filter|Win32.ActiveCfg = Debug|Win32
{37768B3F-89BC-4C16-B2A8-767C5DA84C3F}.Debug Filter|Win32.Build.0 = Debug|Win32
{37768B3F-89BC-4C16-B2A8-767C5DA84C3F}.Debug Filter|x64.ActiveCfg = Debug|x64
@@ -686,118 +604,6 @@ Global
{1E91F58C-0BAE-4021-8087-D1864D8EC066}.Release|Win32.Build.0 = Release|Win32
{1E91F58C-0BAE-4021-8087-D1864D8EC066}.Release|x64.ActiveCfg = Release|x64
{1E91F58C-0BAE-4021-8087-D1864D8EC066}.Release|x64.Build.0 = Release|x64
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Debug Filter|x64.Build.0 = Debug Filter|x64
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Debug Lite|x64.ActiveCfg = Debug|x64
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Debug|Win32.ActiveCfg = Debug|Win32
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Debug|x64.ActiveCfg = Debug|x64
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Release Filter|x64.Build.0 = Release Filter|x64
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Release Lite|Win32.ActiveCfg = Release|Win32
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Release Lite|x64.ActiveCfg = Release|x64
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Release|Win32.ActiveCfg = Release|Win32
- {E62223EF-8263-41EB-8174-CD78BBEEF368}.Release|x64.ActiveCfg = Release|x64
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Debug Filter|x64.Build.0 = Debug Filter|x64
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Debug Lite|x64.ActiveCfg = Debug|x64
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Debug|Win32.ActiveCfg = Debug|Win32
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Debug|x64.ActiveCfg = Debug|x64
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Release Filter|x64.Build.0 = Release Filter|x64
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Release Lite|Win32.ActiveCfg = Release|Win32
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Release Lite|x64.ActiveCfg = Release|x64
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Release|Win32.ActiveCfg = Release|Win32
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438}.Release|x64.ActiveCfg = Release|x64
- {9ED4B036-7399-4128-868D-6E71188E0277}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {9ED4B036-7399-4128-868D-6E71188E0277}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {9ED4B036-7399-4128-868D-6E71188E0277}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {9ED4B036-7399-4128-868D-6E71188E0277}.Debug Filter|x64.Build.0 = Debug Filter|x64
- {9ED4B036-7399-4128-868D-6E71188E0277}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {9ED4B036-7399-4128-868D-6E71188E0277}.Debug Lite|x64.ActiveCfg = Debug|x64
- {9ED4B036-7399-4128-868D-6E71188E0277}.Debug|Win32.ActiveCfg = Debug|Win32
- {9ED4B036-7399-4128-868D-6E71188E0277}.Debug|x64.ActiveCfg = Debug|x64
- {9ED4B036-7399-4128-868D-6E71188E0277}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {9ED4B036-7399-4128-868D-6E71188E0277}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {9ED4B036-7399-4128-868D-6E71188E0277}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {9ED4B036-7399-4128-868D-6E71188E0277}.Release Filter|x64.Build.0 = Release Filter|x64
- {9ED4B036-7399-4128-868D-6E71188E0277}.Release Lite|Win32.ActiveCfg = Release|Win32
- {9ED4B036-7399-4128-868D-6E71188E0277}.Release Lite|x64.ActiveCfg = Release|x64
- {9ED4B036-7399-4128-868D-6E71188E0277}.Release|Win32.ActiveCfg = Release|Win32
- {9ED4B036-7399-4128-868D-6E71188E0277}.Release|x64.ActiveCfg = Release|x64
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Debug Filter|x64.Build.0 = Debug Filter|x64
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Debug Lite|x64.ActiveCfg = Debug|x64
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Debug|Win32.ActiveCfg = Debug|Win32
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Debug|x64.ActiveCfg = Debug|x64
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Release Filter|x64.Build.0 = Release Filter|x64
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Release Lite|Win32.ActiveCfg = Release|Win32
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Release Lite|x64.ActiveCfg = Release|x64
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Release|Win32.ActiveCfg = Release|Win32
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E}.Release|x64.ActiveCfg = Release|x64
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Debug Filter|x64.Build.0 = Debug Filter|x64
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Debug Lite|x64.ActiveCfg = Debug|x64
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Debug|Win32.ActiveCfg = Debug|Win32
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Debug|x64.ActiveCfg = Debug|x64
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Release Filter|x64.Build.0 = Release Filter|x64
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Release Lite|Win32.ActiveCfg = Release|Win32
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Release Lite|x64.ActiveCfg = Release|x64
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Release|Win32.ActiveCfg = Release|Win32
- {4628C665-EDE4-40D2-B525-32BE8B8551C8}.Release|x64.ActiveCfg = Release|x64
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Debug Filter|x64.Build.0 = Debug Filter|x64
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Debug Lite|x64.ActiveCfg = Debug|x64
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Debug|Win32.ActiveCfg = Debug|Win32
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Debug|x64.ActiveCfg = Debug|x64
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Release Filter|x64.Build.0 = Release Filter|x64
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Release Lite|Win32.ActiveCfg = Release|Win32
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Release Lite|x64.ActiveCfg = Release|x64
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Release|Win32.ActiveCfg = Release|Win32
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}.Release|x64.ActiveCfg = Release|x64
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Debug Filter|x64.Build.0 = Debug Filter|x64
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Debug Lite|x64.ActiveCfg = Debug|x64
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Debug|Win32.ActiveCfg = Debug|Win32
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Debug|x64.ActiveCfg = Debug|x64
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Release Filter|x64.Build.0 = Release Filter|x64
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Release Lite|Win32.ActiveCfg = Release|Win32
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Release Lite|x64.ActiveCfg = Release|x64
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Release|Win32.ActiveCfg = Release|Win32
- {53CF9195-19DB-457D-8F55-8DB1706DFA84}.Release|x64.ActiveCfg = Release|x64
{AE399B7E-2B2C-4A96-9016-C5C74B0A2FA0}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
{AE399B7E-2B2C-4A96-9016-C5C74B0A2FA0}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
{AE399B7E-2B2C-4A96-9016-C5C74B0A2FA0}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
@@ -1024,54 +830,6 @@ Global
{83CC6B88-A112-4192-BD5A-F2A249AF2277}.Release|Win32.Build.0 = Release|Win32
{83CC6B88-A112-4192-BD5A-F2A249AF2277}.Release|x64.ActiveCfg = Release|x64
{83CC6B88-A112-4192-BD5A-F2A249AF2277}.Release|x64.Build.0 = Release|x64
- {30D48874-899F-41C6-9B26-A40C96C91102}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {30D48874-899F-41C6-9B26-A40C96C91102}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {30D48874-899F-41C6-9B26-A40C96C91102}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {30D48874-899F-41C6-9B26-A40C96C91102}.Debug Filter|x64.Build.0 = Debug Filter|x64
- {30D48874-899F-41C6-9B26-A40C96C91102}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {30D48874-899F-41C6-9B26-A40C96C91102}.Debug Lite|x64.ActiveCfg = Debug|x64
- {30D48874-899F-41C6-9B26-A40C96C91102}.Debug|Win32.ActiveCfg = Debug|Win32
- {30D48874-899F-41C6-9B26-A40C96C91102}.Debug|x64.ActiveCfg = Debug|x64
- {30D48874-899F-41C6-9B26-A40C96C91102}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {30D48874-899F-41C6-9B26-A40C96C91102}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {30D48874-899F-41C6-9B26-A40C96C91102}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {30D48874-899F-41C6-9B26-A40C96C91102}.Release Filter|x64.Build.0 = Release Filter|x64
- {30D48874-899F-41C6-9B26-A40C96C91102}.Release Lite|Win32.ActiveCfg = Release|Win32
- {30D48874-899F-41C6-9B26-A40C96C91102}.Release Lite|x64.ActiveCfg = Release|x64
- {30D48874-899F-41C6-9B26-A40C96C91102}.Release|Win32.ActiveCfg = Release|Win32
- {30D48874-899F-41C6-9B26-A40C96C91102}.Release|x64.ActiveCfg = Release|x64
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Debug Filter|x64.Build.0 = Debug Filter|x64
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Debug Lite|x64.ActiveCfg = Debug|x64
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Debug|Win32.ActiveCfg = Debug|Win32
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Debug|x64.ActiveCfg = Debug|x64
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Release Filter|x64.Build.0 = Release Filter|x64
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Release Lite|Win32.ActiveCfg = Release|Win32
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Release Lite|x64.ActiveCfg = Release|x64
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Release|Win32.ActiveCfg = Release|Win32
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34}.Release|x64.ActiveCfg = Release|x64
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Debug Filter|x64.Build.0 = Debug Filter|x64
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Debug Lite|x64.ActiveCfg = Debug|x64
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Debug|Win32.ActiveCfg = Debug|Win32
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Debug|x64.ActiveCfg = Debug|x64
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Release Filter|x64.Build.0 = Release Filter|x64
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Release Lite|Win32.ActiveCfg = Release|Win32
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Release Lite|x64.ActiveCfg = Release|x64
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Release|Win32.ActiveCfg = Release|Win32
- {431DD5B6-3F2F-47EE-A23F-514BC044B704}.Release|x64.ActiveCfg = Release|x64
{42B599D7-BB84-481F-A42A-2DBE0E2E2D7E}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
{42B599D7-BB84-481F-A42A-2DBE0E2E2D7E}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
{42B599D7-BB84-481F-A42A-2DBE0E2E2D7E}.Debug Filter|x64.ActiveCfg = Debug|x64
@@ -1220,52 +978,6 @@ Global
{F6B06383-3FFD-403B-9867-4AA82A20AA83}.Release|Win32.Build.0 = Release|Win32
{F6B06383-3FFD-403B-9867-4AA82A20AA83}.Release|x64.ActiveCfg = Release|x64
{F6B06383-3FFD-403B-9867-4AA82A20AA83}.Release|x64.Build.0 = Release|x64
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Debug Filter|x64.Build.0 = Debug Filter|x64
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Debug Lite|x64.ActiveCfg = Debug|x64
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Debug|Win32.ActiveCfg = Debug|Win32
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Debug|x64.ActiveCfg = Debug|x64
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Release Filter|x64.Build.0 = Release Filter|x64
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Release Lite|Win32.ActiveCfg = Release|Win32
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Release Lite|x64.ActiveCfg = Release|x64
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Release|Win32.ActiveCfg = Release|Win32
- {4421516D-10A6-41C1-ADF3-099573BBB0C6}.Release|x64.ActiveCfg = Release|x64
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Debug Filter|x64.Build.0 = Debug Filter|x64
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Debug Lite|x64.ActiveCfg = Debug|x64
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Debug|Win32.ActiveCfg = Debug|Win32
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Debug|x64.ActiveCfg = Debug|x64
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Release Filter|x64.Build.0 = Release Filter|x64
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Release Lite|Win32.ActiveCfg = Release|Win32
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Release Lite|x64.ActiveCfg = Release|x64
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Release|Win32.ActiveCfg = Release|Win32
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}.Release|x64.ActiveCfg = Release|x64
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Debug Filter|Win32.ActiveCfg = Debug Filter|Win32
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Debug Filter|Win32.Build.0 = Debug Filter|Win32
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Debug Filter|x64.ActiveCfg = Debug Filter|x64
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Debug Lite|x64.ActiveCfg = Debug|x64
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Debug|Win32.ActiveCfg = Debug|Win32
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Debug|x64.ActiveCfg = Debug|x64
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Release Filter|Win32.ActiveCfg = Release Filter|Win32
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Release Filter|Win32.Build.0 = Release Filter|Win32
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Release Filter|x64.ActiveCfg = Release Filter|x64
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Release Lite|Win32.ActiveCfg = Release|Win32
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Release Lite|x64.ActiveCfg = Release|x64
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Release|Win32.ActiveCfg = Release|Win32
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C}.Release|x64.ActiveCfg = Release|x64
{ACF5C64B-78AA-4730-91A2-24F4910FBAD9}.Debug Filter|Win32.ActiveCfg = Debug|Win32
{ACF5C64B-78AA-4730-91A2-24F4910FBAD9}.Debug Filter|x64.ActiveCfg = Debug|x64
{ACF5C64B-78AA-4730-91A2-24F4910FBAD9}.Debug Lite|Win32.ActiveCfg = Debug|Win32
@@ -1358,22 +1070,6 @@ Global
{F671100C-469F-4723-AAC4-B7FE4F5B8DC4}.Release Lite|x64.ActiveCfg = Release Filter|x64
{F671100C-469F-4723-AAC4-B7FE4F5B8DC4}.Release|Win32.ActiveCfg = Release Filter|Win32
{F671100C-469F-4723-AAC4-B7FE4F5B8DC4}.Release|x64.ActiveCfg = Release Filter|x64
- {40177920-A66C-4647-B119-332A10224C83}.Debug Filter|Win32.ActiveCfg = Debug|Win32
- {40177920-A66C-4647-B119-332A10224C83}.Debug Filter|Win32.Build.0 = Debug|Win32
- {40177920-A66C-4647-B119-332A10224C83}.Debug Filter|x64.ActiveCfg = Debug|x64
- {40177920-A66C-4647-B119-332A10224C83}.Debug Filter|x64.Build.0 = Debug|x64
- {40177920-A66C-4647-B119-332A10224C83}.Debug Lite|Win32.ActiveCfg = Debug|Win32
- {40177920-A66C-4647-B119-332A10224C83}.Debug Lite|x64.ActiveCfg = Debug|x64
- {40177920-A66C-4647-B119-332A10224C83}.Debug|Win32.ActiveCfg = Debug|Win32
- {40177920-A66C-4647-B119-332A10224C83}.Debug|x64.ActiveCfg = Debug|x64
- {40177920-A66C-4647-B119-332A10224C83}.Release Filter|Win32.ActiveCfg = Release|Win32
- {40177920-A66C-4647-B119-332A10224C83}.Release Filter|Win32.Build.0 = Release|Win32
- {40177920-A66C-4647-B119-332A10224C83}.Release Filter|x64.ActiveCfg = Release|x64
- {40177920-A66C-4647-B119-332A10224C83}.Release Filter|x64.Build.0 = Release|x64
- {40177920-A66C-4647-B119-332A10224C83}.Release Lite|Win32.ActiveCfg = Release|Win32
- {40177920-A66C-4647-B119-332A10224C83}.Release Lite|x64.ActiveCfg = Release|x64
- {40177920-A66C-4647-B119-332A10224C83}.Release|Win32.ActiveCfg = Release|Win32
- {40177920-A66C-4647-B119-332A10224C83}.Release|x64.ActiveCfg = Release|x64
{DA8461C4-7683-4360-9372-2A9E0F1795C2}.Debug Filter|Win32.ActiveCfg = Debug|Win32
{DA8461C4-7683-4360-9372-2A9E0F1795C2}.Debug Filter|Win32.Build.0 = Debug|Win32
{DA8461C4-7683-4360-9372-2A9E0F1795C2}.Debug Filter|x64.ActiveCfg = Debug|x64
@@ -1447,15 +1143,12 @@ Global
{C2082189-3ECB-4079-91FA-89D3C8A305C0} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
{E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
{273B3149-3192-4B75-A791-470320B90812} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
- {438286B7-A9F4-411D-BCC5-948C40E37D8F} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
- {4CEFBC84-C215-11DB-8314-0800200C9A66} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
{2FCD4B66-9CF9-4C8F-BC70-37CD20002D49} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
{9F31D122-E84D-485A-A58D-09DAD01A56CE} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
{ACF5C64B-78AA-4730-91A2-24F4910FBAD9} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
{20E0F8D6-213C-460B-B361-9C725CB375C7} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
{0DA1DA7D-F393-4E7C-A7CE-CB5C6A67BC94} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
{68A5DD20-7057-448B-8FE0-B6AC8D205509} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
- {40177920-A66C-4647-B119-332A10224C83} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
{DA8461C4-7683-4360-9372-2A9E0F1795C2} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
{2B7F22D7-1750-47C5-8709-1A3688B62499} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
{ED257874-E12E-4143-AF0A-0676DA3BB18C} = {D9A0529B-9EC4-4D30-9E05-A5D533739D95}
@@ -1475,16 +1168,8 @@ Global
{65361C7C-83D6-42E4-870C-4DC85AE641FE} = {49B5BAE3-749C-414C-80CC-A756DD548CE3}
{67827491-8162-4039-9132-F934ABC836A0} = {49B5BAE3-749C-414C-80CC-A756DD548CE3}
{EB202B68-8029-4985-B914-E94B44D2E230} = {49B5BAE3-749C-414C-80CC-A756DD548CE3}
- {9738B023-FC46-48A2-953A-0035FD897678} = {D626CC4F-BFB1-4030-8DD8-1A3A1D41248E}
{37768B3F-89BC-4C16-B2A8-767C5DA84C3F} = {D626CC4F-BFB1-4030-8DD8-1A3A1D41248E}
{1E91F58C-0BAE-4021-8087-D1864D8EC066} = {D626CC4F-BFB1-4030-8DD8-1A3A1D41248E}
- {E62223EF-8263-41EB-8174-CD78BBEEF368} = {D626CC4F-BFB1-4030-8DD8-1A3A1D41248E}
- {3F5EA225-F4B7-4413-AEB3-4E4E5751E438} = {D626CC4F-BFB1-4030-8DD8-1A3A1D41248E}
- {9ED4B036-7399-4128-868D-6E71188E0277} = {D626CC4F-BFB1-4030-8DD8-1A3A1D41248E}
- {C0F7A036-FC2D-40DF-9852-C37518DB6B3E} = {D626CC4F-BFB1-4030-8DD8-1A3A1D41248E}
- {4628C665-EDE4-40D2-B525-32BE8B8551C8} = {D626CC4F-BFB1-4030-8DD8-1A3A1D41248E}
- {7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475} = {D626CC4F-BFB1-4030-8DD8-1A3A1D41248E}
- {53CF9195-19DB-457D-8F55-8DB1706DFA84} = {D626CC4F-BFB1-4030-8DD8-1A3A1D41248E}
{AE399B7E-2B2C-4A96-9016-C5C74B0A2FA0} = {D626CC4F-BFB1-4030-8DD8-1A3A1D41248E}
{543D40E9-8CA6-4E4B-9936-90CBA562B268} = {4909B0ED-CC22-4509-ACD0-FB60C4FC73ED}
{4D3B4FF4-535A-4201-AB7D-9AEC1E737A95} = {4909B0ED-CC22-4509-ACD0-FB60C4FC73ED}
@@ -1495,9 +1180,6 @@ Global
{FB565A7A-50DC-4A0D-852D-5E7F74DAB82C} = {C0038E92-68BF-4491-B5AA-BEE9857A49F8}
{F50E74C2-5BE7-4C9B-B1E7-6CA19CFAD34E} = {02DAA1A6-31C8-4002-89FE-50BF53752244}
{83CC6B88-A112-4192-BD5A-F2A249AF2277} = {02DAA1A6-31C8-4002-89FE-50BF53752244}
- {30D48874-899F-41C6-9B26-A40C96C91102} = {02DAA1A6-31C8-4002-89FE-50BF53752244}
- {916D0FC1-1D86-487A-82DE-37FBEE43FB34} = {02DAA1A6-31C8-4002-89FE-50BF53752244}
- {431DD5B6-3F2F-47EE-A23F-514BC044B704} = {02DAA1A6-31C8-4002-89FE-50BF53752244}
{42B599D7-BB84-481F-A42A-2DBE0E2E2D7E} = {02DAA1A6-31C8-4002-89FE-50BF53752244}
{8F998497-9C51-4FAA-83E4-1D85B22CBA13} = {02DAA1A6-31C8-4002-89FE-50BF53752244}
{D8DB3E7E-D50E-4EC3-A9B9-DAD18F5FE466} = {683639C3-F209-4EF8-B6CC-8741C61EDECF}
@@ -1505,9 +1187,6 @@ Global
{54DDA60F-E528-4D07-A152-960A1E818680} = {F9F42BF2-3F13-4654-82C5-E27B8879EC4E}
{9DCFD02A-16A0-4766-BC18-66163E21929D} = {F9F42BF2-3F13-4654-82C5-E27B8879EC4E}
{F6B06383-3FFD-403B-9867-4AA82A20AA83} = {F9F42BF2-3F13-4654-82C5-E27B8879EC4E}
- {4421516D-10A6-41C1-ADF3-099573BBB0C6} = {F9F42BF2-3F13-4654-82C5-E27B8879EC4E}
- {58E36BF5-4A06-47E4-BD40-4CCEF8C634DF} = {F9F42BF2-3F13-4654-82C5-E27B8879EC4E}
- {305BAB2D-0D75-4FBC-8BCD-A2917392B48C} = {F9F42BF2-3F13-4654-82C5-E27B8879EC4E}
{F671100C-469F-4723-AAC4-B7FE4F5B8DC4} = {F9F42BF2-3F13-4654-82C5-E27B8879EC4E}
EndGlobalSection
EndGlobal
diff --git a/src/filters/Filters.h b/src/filters/Filters.h
index e7ee7e302..6d4aeab23 100644
--- a/src/filters/Filters.h
+++ b/src/filters/Filters.h
@@ -24,15 +24,7 @@
#include "muxer/DSMMuxer/DSMMuxer.h"
#include "muxer/MatroskaMuxer/MatroskaMuxer.h"
#include "muxer/WavDest/WavDest.h"
-#include "parser/AviSplitter/AviSplitter.h"
#include "parser/DSMSplitter/DSMSplitter.h"
-#include "parser/FLVSplitter/FLVSplitter.h"
-#include "parser/MatroskaSplitter/MatroskaSplitter.h"
-#include "parser/MP4Splitter/MP4Splitter.h"
-#include "parser/MpaSplitter/MpaSplitter.h"
-#include "parser/MpegSplitter/MpegSplitter.h"
-#include "parser/OggSplitter/OggSplitter.h"
-#include "parser/RealMediaSplitter/RealMediaSplitter.h"
#include "parser/StreamDriveThru/StreamDriveThru.h"
#include "reader/CDDAReader/CDDAReader.h"
#include "reader/CDXAReader/CDXAReader.h"
@@ -41,16 +33,10 @@
#include "renderer/MpcAudioRenderer/MpcAudioRenderer.h"
#include "renderer/SyncClock/SyncClock.h"
#include "source/D2VSource/D2VSource.h"
-#include "source/DTSAC3Source/DTSAC3Source.h"
-#include "source/FLACSource/FLACSource.h"
-#include "source/FLICSource/FLICSource.h"
#include "source/ShoutcastSource/ShoutcastSource.h"
#include "source/SubtitleSource/SubtitleSource.h"
#include "switcher/AudioSwitcher/AudioSwitcher.h"
#include "transform/AVI2AC3Filter/AVI2AC3Filter.h"
#include "transform/BufferFilter/BufferFilter.h"
#include "transform/DeCSSFilter/DeCSSFilter.h"
-#include "transform/MpaDecFilter/MpaDecFilter.h"
-#include "transform/MPCVideoDec/MPCVideoDecFilter.h"
-#include "transform/Mpeg2DecFilter/Mpeg2DecFilter.h"
#include "RARFileSource/library/RFS.h"
diff --git a/src/filters/parser/AviSplitter/AviFile.cpp b/src/filters/parser/AviSplitter/AviFile.cpp
deleted file mode 100644
index 896b36d1b..000000000
--- a/src/filters/parser/AviSplitter/AviFile.cpp
+++ /dev/null
@@ -1,652 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "AviFile.h"
-#include <math.h>
-
-//
-// CAviFile
-//
-
-CAviFile::CAviFile(IAsyncReader* pAsyncReader, HRESULT& hr)
- : CBaseSplitterFile(pAsyncReader, hr)
-{
- if (FAILED(hr)) {
- return;
- }
- m_isamv = false;
- hr = Init();
-}
-
-HRESULT CAviFile::Init()
-{
- Seek(0);
- DWORD dw[3];
- if (S_OK != Read(dw) || dw[0] != FCC('RIFF') || (dw[2] != FCC('AVI ') && dw[2] != FCC('AVIX') && dw[2] != FCC('AMV '))) {
- return E_FAIL;
- }
-
- m_isamv = (dw[2] == FCC('AMV '));
- Seek(0);
- HRESULT hr = Parse(0, GetLength());
- UNREFERENCED_PARAMETER(hr);
- if (m_movis.IsEmpty()) { // FAILED(hr) is allowed as long as there was a movi chunk found
- return E_FAIL;
- }
-
- if (m_avih.dwStreams == 0 && !m_strms.IsEmpty()) {
- m_avih.dwStreams = (DWORD)m_strms.GetCount();
- }
-
- if (m_avih.dwStreams != m_strms.GetCount()) {
- return E_FAIL;
- }
-
- for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
- strm_t* s = m_strms[i];
- if (s->strh.fccType != FCC('auds')) {
- continue;
- }
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)s->strf.GetData();
- if (wfe->wFormatTag == 0x55 && wfe->nBlockAlign == 1152
- && s->strh.dwScale == 1 && s->strh.dwRate != wfe->nSamplesPerSec) {
- // correcting encoder bugs...
- s->strh.dwScale = 1152;
- s->strh.dwRate = wfe->nSamplesPerSec;
- }
- }
-
- if (!m_isamv && (FAILED(BuildIndex()))) {
- EmptyIndex();
- }
-
- return S_OK;
-}
-
-HRESULT CAviFile::BuildAMVIndex()
-{
- strm_t::chunk NewChunk;
- DWORD ulType;
- DWORD ulSize;
-
- ZeroMemory(&NewChunk, sizeof(strm_t::chunk));
- while ((Read(ulType) == S_OK) && (Read(ulSize) == S_OK)) {
- switch (ulType) {
- case FCC('00dc'): // 01bw: JPeg
- NewChunk.size = ulSize;
- NewChunk.filepos = GetPos();
- NewChunk.orgsize = ulSize;
- NewChunk.fKeyFrame = true;
- m_strms[0]->cs.Add(NewChunk);
- break;
- case FCC('01wb'): // 00dc: Audio
- NewChunk.size = ulSize;
- NewChunk.orgsize = ulSize;
- NewChunk.fKeyFrame = true;
- NewChunk.filepos = GetPos();
- m_strms[1]->cs.Add(NewChunk);
- break;
- }
- Seek(GetPos() + ulSize);
- }
-
- TRACE(_T("Video packet : %d Audio packet :%d\n"), m_strms[0]->cs.GetCount(), m_strms[1]->cs.GetCount());
- return S_OK;
-}
-
-HRESULT CAviFile::Parse(DWORD parentid, __int64 end)
-{
- HRESULT hr = S_OK;
-
- CAutoPtr<strm_t> strm;
-
- while (S_OK == hr && GetPos() < end) {
- UINT64 pos = GetPos();
-
- DWORD id = 0, size;
- if (S_OK != Read(id) || id == 0) {
- return E_FAIL;
- }
-
- if (id == FCC('RIFF') || id == FCC('LIST')) {
- if (S_OK != Read(size) || S_OK != Read(id)) {
- return E_FAIL;
- }
-
- if (m_isamv) {
- size = (DWORD)(min(end, DWORD_MAX) - GetPos() - 8); // No size set in AVM : guess end of file...
- }
- size += (size & 1) + 8;
-
- TRACE(_T("CAviFile::Parse(..): LIST '%c%c%c%c'\n"),
- TCHAR((id >> 0) & 0xff),
- TCHAR((id >> 8) & 0xff),
- TCHAR((id >> 16) & 0xff),
- TCHAR((id >> 24) & 0xff));
-
- if (id == FCC('movi')) {
- m_movis.AddTail(pos);
- if (m_isamv) {
- BuildAMVIndex();
- }
- } else {
- hr = Parse(id, pos + size);
- }
- } else {
- if (S_OK != Read(size)) {
- return E_FAIL;
- }
- if (GetPos() + size > end) {
- return E_FAIL; // broken chunk
- }
-
- TRACE(_T("CAviFile::Parse(..): '%c%c%c%c'\n"),
- TCHAR((id >> 0) & 0xff),
- TCHAR((id >> 8) & 0xff),
- TCHAR((id >> 16) & 0xff),
- TCHAR((id >> 24) & 0xff));
-
- if (parentid == FCC('INFO') && size > 0) {
- switch (id) {
- case FCC('IARL'): // Archival Location. Indicates where the subject of the file is archived.
- case FCC('IART'): // Artist. Lists the artist of the original subject of the file; for example, "Michaelangelo."
- case FCC('ICMS'): // Commissioned. Lists the name of the person or organization that commissioned the subject of the file; for example, "Pope Julian II."
- case FCC('ICMT'): // Comments. Provides general comments about the file or the subject of the file. If the comment is several sentences long, end each sentence with a period. Do not include new-line characters.
- case FCC('ICOP'): // Copyright. Records the copyright information for the file; for example, "Copyright Encyclopedia International 1991." If there are multiple copyrights, separate them by a semicolon followed by a space.
- case FCC('ICRD'): // Creation date. Specifies the date the subject of the file was created. List dates in year-month-day format, padding one-digit months and days with a zero on the left; for example, "1553-05-03" for May 3, 1553.
- case FCC('ICRP'): // Cropped. Describes whether an image has been cropped and, if so, how it was cropped; for example, "lower-right corner."
- case FCC('IDIM'): // Dimensions. Specifies the size of the original subject of the file; for example, "8.5 in h, 11 in w."
- case FCC('IDPI'): // Dots Per Inch. Stores dots per inch setting of the digitizer used to produce the file, such as "300."
- case FCC('IENG'): // Engineer. Stores the name of the engineer who worked on the file. If there are multiple engineers, separate the names by a semicolon and a blank; for example, "Smith, John; Adams, Joe."
- case FCC('IGNR'): // Genre. Describes the original work, such as "landscape," "portrait," "still life," etc.
- case FCC('IKEY'): // Keywords. Provides a list of keywords that refer to the file or subject of the file. Separate multiple keywords with a semicolon and a blank; for example, "Seattle; aerial view; scenery."
- case FCC('ILGT'): // Lightness. Describes the changes in lightness settings on the digitizer required to produce the file. Note that the format of this information depends on hardware used.
- case FCC('IMED'): // Medium. Describes the original subject of the file, such as "computer image," "drawing," "lithograph," and so on.
- case FCC('INAM'): // Name. Stores the title of the subject of the file, such as "Seattle From Above."
- case FCC('IPLT'): // Palette Setting. Specifies the number of colors requested when digitizing an image, such as "256."
- case FCC('IPRD'): // Product. Specifies the name of the title the file was originally intended for, such as "Encyclopedia of Pacific Northwest Geography."
- case FCC('ISBJ'): // Subject. Describes the contents of the file, such as "Aerial view of Seattle."
- case FCC('ISFT'): // Software. Identifies the name of the software package used to create the file, such as "Microsoft WaveEdit."
- case FCC('ISHP'): // Sharpness. Identifies the changes in sharpness for the digitizer required to produce the file (the format depends on the hardware used).
- case FCC('ISRC'): // Source. Identifies the name of the person or organization who supplied the original subject of the file; for example, "Trey Research."
- case FCC('ISRF'): // Source Form. Identifies the original form of the material that was digitized, such as "slide," "paper," "map," and so on. This is not necessarily the same as IMED.
- case FCC('ITCH'): { // Technician. Identifies the technician who digitized the subject file; for example, "Smith, John."
- CStringA str;
- if (S_OK != ByteRead((BYTE*)str.GetBufferSetLength(size), size)) {
- return E_FAIL;
- }
- m_info[id] = str;
- break;
- }
- }
- }
-
- switch (id) {
- case FCC('amvh'):
- case FCC('avih'):
- m_avih.fcc = id;
- m_avih.cb = size;
- if (S_OK != Read(m_avih, 8)) {
- return E_FAIL;
- }
- break;
- case FCC('strh'):
- if (!strm) {
- strm.Attach(DEBUG_NEW strm_t());
- }
- strm->strh.fcc = FCC('strh');
- strm->strh.cb = size;
- if (S_OK != Read(strm->strh, 8)) {
- return E_FAIL;
- }
- if (m_isamv) {
- // First alway video, second always audio
- strm->strh.fccType = m_strms.IsEmpty() ? FCC('vids') : FCC('amva');
- strm->strh.dwRate = m_avih.dwReserved[0] * 1000; // dwReserved[0] = fps!
- strm->strh.dwScale = 1000;
- }
- break;
- case FCC('strn'):
- if (S_OK != ByteRead((BYTE*)strm->strn.GetBufferSetLength(size), size)) {
- return E_FAIL;
- }
- break;
- case FCC('strf'):
- if (!strm) {
- strm.Attach(DEBUG_NEW strm_t());
- }
- strm->strf.SetCount(size);
- if (S_OK != ByteRead(strm->strf.GetData(), size)) {
- return E_FAIL;
- }
- if (m_isamv) {
- if (strm->strh.fccType == FCC('vids')) {
- strm->strf.SetCount(sizeof(BITMAPINFOHEADER));
- BITMAPINFOHEADER* pbmi = &((BITMAPINFO*)strm->strf.GetData())->bmiHeader;
- pbmi->biSize = sizeof(BITMAPINFOHEADER);
- pbmi->biHeight = m_avih.dwHeight;
- pbmi->biWidth = m_avih.dwWidth;
- pbmi->biCompression = FCC('AMVV');
- pbmi->biPlanes = 1;
- pbmi->biBitCount = 24;
- pbmi->biSizeImage = pbmi->biHeight * pbmi->biWidth * (pbmi->biBitCount / 8);
- }
- m_strms.Add(strm);
- }
-
- break;
- case FCC('indx'):
- if (!strm) {
- strm.Attach(DEBUG_NEW strm_t());
- }
- ASSERT(strm->indx == nullptr);
- AVISUPERINDEX* pSuperIndex;
- if (size < MAXDWORD - 8) {
- // Fix buffer overrun vulnerability
- try {
- pSuperIndex = (AVISUPERINDEX*)DEBUG_NEW unsigned char [(size_t)(size + 8)];
- } catch (CMemoryException* e) {
- pSuperIndex = nullptr;
- e->Delete();
- }
- if (pSuperIndex) {
- strm->indx.Attach(pSuperIndex);
- strm->indx->fcc = FCC('indx');
- strm->indx->cb = size;
- if (S_OK != ByteRead((BYTE*)(AVISUPERINDEX*)strm->indx + 8, size)) {
- return E_FAIL;
- }
- ASSERT(strm->indx->wLongsPerEntry == 4 && strm->indx->bIndexType == AVI_INDEX_OF_INDEXES);
- }
- }
- break;
- case FCC('dmlh'):
- if (S_OK != Read(m_dmlh)) {
- return E_FAIL;
- }
- break;
- case FCC('vprp'):
- //if (S_OK != Read(m_vprp)) return E_FAIL;
- break;
- case FCC('idx1'):
- ASSERT(m_idx1 == nullptr);
- m_idx1.Attach((AVIOLDINDEX*)DEBUG_NEW BYTE[size + 8]);
- m_idx1->fcc = FCC('idx1');
- m_idx1->cb = size;
- if (S_OK != ByteRead((BYTE*)(AVIOLDINDEX*)m_idx1 + 8, size)) {
- return E_FAIL;
- }
- break;
- default:
- TRACE(_T("CAviFile::Parse(..): unknown tag '%c%c%c%c'\n"),
- TCHAR((id >> 0) & 0xff),
- TCHAR((id >> 8) & 0xff),
- TCHAR((id >> 16) & 0xff),
- TCHAR((id >> 24) & 0xff));
- break;
- }
-
- size += (size & 1) + 8;
- }
-
- Seek(pos + size);
- }
-
- if (strm) {
- m_strms.Add(strm);
- }
-
- return hr;
-}
-
-REFERENCE_TIME CAviFile::GetTotalTime()
-{
- REFERENCE_TIME t = 0/*10i64*m_avih.dwMicroSecPerFrame*m_avih.dwTotalFrames*/;
-
- for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
- strm_t* s = m_strms[i];
-
- if (s->IsRawSubtitleStream()) {
- continue;
- }
-
- REFERENCE_TIME t2 = s->GetRefTime((DWORD)s->cs.GetCount(), s->totalsize);
- t = max(t, t2);
- }
-
- if (t == 0) {
- t = 10i64 * m_avih.dwMicroSecPerFrame * m_avih.dwTotalFrames;
- }
-
- return t;
-}
-
-HRESULT CAviFile::BuildIndex()
-{
- EmptyIndex();
-
- DWORD nSuperIndexes = 0;
-
- for (DWORD track = 0; track < m_avih.dwStreams; track++) {
- strm_t* s = m_strms[track];
- if (s->indx && s->indx->nEntriesInUse > 0) {
- nSuperIndexes++;
- }
- }
-
- if (nSuperIndexes == m_avih.dwStreams) {
- for (DWORD track = 0; track < m_avih.dwStreams; track++) {
- strm_t* s = m_strms[track];
-
- AVISUPERINDEX* idx = (AVISUPERINDEX*)s->indx;
-
- DWORD nEntriesInUse = 0;
-
- for (DWORD j = 0; j < idx->nEntriesInUse; ++j) {
- Seek(idx->aIndex[j].qwOffset);
-
- AVISTDINDEX stdidx;
- if (S_OK != ByteRead((BYTE*)&stdidx, FIELD_OFFSET(AVISTDINDEX, aIndex))) {
- EmptyIndex();
- return E_FAIL;
- }
-
- nEntriesInUse += stdidx.nEntriesInUse;
- }
-
- s->cs.SetCount(nEntriesInUse);
-
- DWORD frame = 0;
- UINT64 size = 0;
-
- for (DWORD j = 0; j < idx->nEntriesInUse; ++j) {
- Seek(idx->aIndex[j].qwOffset);
-
- CAutoPtr<AVISTDINDEX> p((AVISTDINDEX*)DEBUG_NEW BYTE[idx->aIndex[j].dwSize]);
- if (!p || S_OK != ByteRead((BYTE*)(AVISTDINDEX*)p, idx->aIndex[j].dwSize) || p->qwBaseOffset >= (DWORDLONG)GetLength()) {
- EmptyIndex();
- return E_FAIL;
- }
-
- for (DWORD k = 0; k < p->nEntriesInUse; ++k) {
- s->cs[frame].size = size;
- s->cs[frame].filepos = p->qwBaseOffset + p->aIndex[k].dwOffset;
- s->cs[frame].fKeyFrame = !(p->aIndex[k].dwSize & AVISTDINDEX_DELTAFRAME)
- || s->strh.fccType == FCC('auds');
- s->cs[frame].fChunkHdr = false;
- s->cs[frame].orgsize = p->aIndex[k].dwSize & AVISTDINDEX_SIZEMASK;
-
- if (m_idx1) {
- s->cs[frame].filepos -= 8;
- s->cs[frame].fChunkHdr = true;
- }
-
- ++frame;
- size += s->GetChunkSize(p->aIndex[k].dwSize & AVISTDINDEX_SIZEMASK);
- }
- }
-
- s->totalsize = size;
- }
- } else if (AVIOLDINDEX* idx = m_idx1) {
- size_t len = idx->cb / sizeof(idx->aIndex[0]);
-
- UINT64 offset = m_movis.GetHead() + 8;
-
- //detect absolute chunk addressing (TODO: read AVI specification and make it better)
- if (idx->aIndex[0].dwOffset > offset) {
- DWORD id;
- Seek(offset + idx->aIndex[0].dwOffset);
- Read(id);
- if (id != idx->aIndex[0].dwChunkId) {
- TRACE(_T("WARNING: CAviFile::Init() detected absolute chunk addressing in \'idx1\'\n"));
- offset = 0;
- }
- }
-
- for (DWORD track = 0; track < m_avih.dwStreams; track++) {
- strm_t* s = m_strms[track];
-
- // calculate the number of frames and set index size before using it
- size_t nFrames = 0;
- for (size_t i = 0; i < len; i++) {
- if (TRACKNUM(idx->aIndex[i].dwChunkId) == track) {
- nFrames++;
- }
- }
- s->cs.SetCount(nFrames);
-
- // read index
- size_t frame = 0;
- UINT64 size = 0;
- for (size_t i = 0; i < len; i++) {
- if (TRACKNUM(idx->aIndex[i].dwChunkId) == track) {
- s->cs[frame].size = size;
- s->cs[frame].filepos = offset + idx->aIndex[i].dwOffset;
- s->cs[frame].fKeyFrame = (idx->aIndex[i].dwFlags & AVIIF_KEYFRAME)
- || s->strh.fccType == FCC('auds') // FIXME: some audio index is without any kf flag
- || frame == 0; // grrr
- s->cs[frame].fChunkHdr = i + 1 == len || idx->aIndex[i].dwOffset != idx->aIndex[i + 1].dwOffset;
- s->cs[frame].orgsize = idx->aIndex[i].dwSize;
-
- frame++;
- size += s->GetChunkSize(idx->aIndex[i].dwSize);
- }
- }
-
- s->totalsize = size;
- }
- }
-
- m_idx1.Free();
- for (DWORD track = 0; track < m_avih.dwStreams; track++) {
- m_strms[track]->indx.Free();
- }
-
- return S_OK;
-}
-
-void CAviFile::EmptyIndex()
-{
- for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
- strm_t* s = m_strms[i];
- s->cs.RemoveAll();
- s->totalsize = 0;
- }
-}
-
-bool CAviFile::IsInterleaved(bool fKeepInfo)
-{
- if (m_strms.GetCount() < 2) {
- return true;
- }
- /*
- if (m_avih.dwFlags&AVIF_ISINTERLEAVED) // not reliable, nandub can write f*cked up files and still sets it
- return true;
- */
- for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
- m_strms[i]->cs2.SetCount(m_strms[i]->cs.GetCount());
- }
-
- DWORD* curchunks = DEBUG_NEW DWORD[m_avih.dwStreams];
- UINT64* cursizes = DEBUG_NEW UINT64[m_avih.dwStreams];
-
- ZeroMemory(curchunks, sizeof(DWORD)*m_avih.dwStreams);
- ZeroMemory(cursizes, sizeof(UINT64)*m_avih.dwStreams);
-
- int end = 0;
-
- for (;;) {
- UINT64 fpmin = _I64_MAX;
-
- DWORD n = (DWORD) - 1;
- for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
- DWORD curchunk = curchunks[i];
- CAtlArray<strm_t::chunk>& cs = m_strms[i]->cs;
- if (curchunk >= cs.GetCount()) {
- continue;
- }
- UINT64 fp = cs[curchunk].filepos;
- if (fp < fpmin) {
- fpmin = fp;
- n = i;
- }
- }
- if (n == -1) {
- break;
- }
-
- strm_t* s = m_strms[n];
- DWORD& curchunk = curchunks[n];
- UINT64& cursize = cursizes[n];
-
- if (!s->IsRawSubtitleStream()) {
- strm_t::chunk2& cs2 = s->cs2[curchunk];
- cs2.t = (DWORD)(s->GetRefTime(curchunk, cursize) >> 13); // for comparing later it is just as good as /10000 to get a near [ms] accuracy
- //cs2.t = (DWORD)(s->GetRefTime(curchunk, cursize)/10000);
- cs2.n = end++;
- }
-
- cursize = s->cs[curchunk].size;
- ++curchunk;
- }
-
- ZeroMemory(curchunks, sizeof(DWORD)*m_avih.dwStreams);
-
- strm_t::chunk2 cs2last = {(DWORD) - 1, 0};
-
- bool fInterleaved = true;
-
- while (fInterleaved) {
- strm_t::chunk2 cs2min = {LONG_MAX, LONG_MAX};
-
- DWORD n = (DWORD) - 1;
- for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
- DWORD curchunk = curchunks[i];
- if (curchunk >= m_strms[i]->cs2.GetCount()) {
- continue;
- }
- strm_t::chunk2& cs2 = m_strms[i]->cs2[curchunk];
- if (cs2.t < cs2min.t) {
- cs2min = cs2;
- n = i;
- }
- }
- if (n == -1) {
- break;
- }
-
- ++curchunks[n];
-
- if (cs2last.t != (DWORD) - 1 && abs((int)cs2min.n - (int)cs2last.n) >= 1000) {
- fInterleaved = false;
- }
-
- cs2last = cs2min;
- }
-
- delete [] curchunks;
- delete [] cursizes;
-
- if (fInterleaved && !fKeepInfo) {
- // this is not needed anymore, let's save a little memory then
- for (DWORD i = 0; i < m_avih.dwStreams; ++i) {
- m_strms[i]->cs2.RemoveAll();
- }
- }
-
- return fInterleaved;
-}
-
-REFERENCE_TIME CAviFile::strm_t::GetRefTime(DWORD frame, UINT64 size)
-{
- if (strh.dwRate == 0) {
- return 0;
- }
- if (strh.fccType == FCC('auds')) {
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)strf.GetData();
- if (wfe->nBlockAlign == 0) {
- return 0;
- }
- return (REFERENCE_TIME)ceil(10000000.0 * size * strh.dwScale / (unsigned __int64(strh.dwRate) * wfe->nBlockAlign));
- // need calculate in double, because the (10000000ui64 * size * strh.dwScale) can give overflow
- // "ceil" is necessary to compensate for framenumber->reftime->framenumber conversion
- }
- return (REFERENCE_TIME)ceil(10000000.0 * frame * strh.dwScale / strh.dwRate);
- // need calculate in double, because the (10000000ui64 * frame * strh.dwScale) can give overflow (verified in practice)
- // "ceil" is necessary to compensate for framenumber->reftime->framenumber conversion
-}
-
-DWORD CAviFile::strm_t::GetFrame(REFERENCE_TIME rt)
-{
- DWORD frame;
-
- if (strh.dwScale == 0 || rt <= 0 || cs.IsEmpty()) {
- frame = 0;
- } else if (strh.fccType == FCC('auds')) {
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)strf.GetData();
-
- UINT64 size = (UINT64)(double(rt) * wfe->nBlockAlign * strh.dwRate / (strh.dwScale * 10000000.0));
- // need calculate in double, because the (rt * wfe->nBlockAlign * strh.dwRate) can give overflow
- frame = 1;
- for (; frame < cs.GetCount(); ++frame) {
- if (cs[frame].size > size) {
- break;
- }
- }
- --frame;
- } else {
- frame = (DWORD)(double(rt) * strh.dwRate / (strh.dwScale * 10000000.0));
- // need calculate in double, because the (rt * strh.dwRate) can give overflow (verified in practice)
- if (frame >= cs.GetCount()) {
- frame = (DWORD)cs.GetCount() - 1;
- }
- }
-
- return frame;
-}
-
-DWORD CAviFile::strm_t::GetKeyFrame(REFERENCE_TIME rt)
-{
- DWORD i = GetFrame(rt);
- for (; i > 0; i--) {
- if (cs[i].fKeyFrame) {
- break;
- }
- }
- return i;
-}
-
-DWORD CAviFile::strm_t::GetChunkSize(DWORD size)
-{
- if (strh.fccType == FCC('auds')) {
- WORD nBlockAlign = ((WAVEFORMATEX*)strf.GetData())->nBlockAlign;
- size = nBlockAlign ? (size + (nBlockAlign - 1)) / nBlockAlign * nBlockAlign : 0; // round up for nando's vbr hack
- }
-
- return size;
-}
-
-bool CAviFile::strm_t::IsRawSubtitleStream()
-{
- return strn.Find("Subtitle") == 0 || strh.fccType == FCC('txts') && cs.GetCount() == 1;
-}
diff --git a/src/filters/parser/AviSplitter/AviFile.h b/src/filters/parser/AviSplitter/AviFile.h
deleted file mode 100644
index 14fba760e..000000000
--- a/src/filters/parser/AviSplitter/AviFile.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <aviriff.h> // conflicts with vfw.h...
-#include "../BaseSplitter/BaseSplitter.h"
-
-class CAviFile : public CBaseSplitterFile
-{
- HRESULT Init();
- HRESULT Parse(DWORD parentid, __int64 end);
- HRESULT BuildAMVIndex();
-
-public:
- CAviFile(IAsyncReader* pAsyncReader, HRESULT& hr);
-
- //using CBaseSplitterFile::Read;
- template<typename T>
- HRESULT Read(T& var, int offset = 0) {
- ZeroMemory(&var, sizeof(var));
- HRESULT hr = ByteRead((BYTE*)&var + offset, sizeof(var) - offset);
- return hr;
- }
-
- AVIMAINHEADER m_avih;
- struct ODMLExtendedAVIHeader {
- DWORD dwTotalFrames;
- } m_dmlh;
- //VideoPropHeader m_vprp;
- struct strm_t {
- AVISTREAMHEADER strh;
- CAtlArray<BYTE> strf;
- CStringA strn;
- CAutoPtr<AVISUPERINDEX> indx;
- struct chunk {
- UINT64 fKeyFrame: 1, fChunkHdr: 1, size: 62;
- UINT64 filepos;
- DWORD orgsize;
- };
- CAtlArray<chunk> cs;
- UINT64 totalsize;
- REFERENCE_TIME GetRefTime(DWORD frame, UINT64 size);
- int GetTime(DWORD frame, UINT64 size);
- DWORD GetFrame(REFERENCE_TIME rt);
- DWORD GetKeyFrame(REFERENCE_TIME rt);
- DWORD GetChunkSize(DWORD size);
- bool IsRawSubtitleStream();
-
- // tmp
- struct chunk2 {
- DWORD t;
- DWORD n;
- };
- CAtlArray<chunk2> cs2;
- };
- CAutoPtrArray<strm_t> m_strms;
- CAtlMap<DWORD, CStringA> m_info;
- CAutoPtr<AVIOLDINDEX> m_idx1;
-
- CAtlList<UINT64> m_movis;
- bool m_isamv;
-
- REFERENCE_TIME GetTotalTime();
- HRESULT BuildIndex();
- void EmptyIndex();
- bool IsInterleaved(bool fKeepInfo = false);
-};
-
-#define TRACKNUM(fcc) (10 * ((fcc & 0xff) - 0x30) + (((fcc >> 8) & 0xff) - 0x30))
-#define TRACKTYPE(fcc) ((WORD)((((DWORD)fcc >> 24) & 0xff) | ((fcc >> 8) & 0xff00)))
diff --git a/src/filters/parser/AviSplitter/AviSplitter.cpp b/src/filters/parser/AviSplitter/AviSplitter.cpp
deleted file mode 100644
index 37737ed68..000000000
--- a/src/filters/parser/AviSplitter/AviSplitter.cpp
+++ /dev/null
@@ -1,988 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <MMReg.h>
-#include "AviFile.h"
-#include "AviSplitter.h"
-
-#define MAXPACKETS_AVI 1000
-
-#ifdef STANDALONE_FILTER
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_Avi},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
-};
-
-const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, 0, nullptr}
-};
-
-const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CAviSplitterFilter), AviSplitterName, MERIT_NORMAL + 1, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CAviSourceFilter), AviSourceName, MERIT_NORMAL + 1, 0, nullptr, CLSID_LegacyAmFilterCategory},
-};
-
-CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CAviSplitterFilter>, nullptr, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CAviSourceFilter>, nullptr, &sudFilter[1]},
- {L"CAviSplitterPropertyPage", &__uuidof(CAviSplitterSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CAviSplitterSettingsWnd>>},
-};
-
-int g_cTemplates = _countof(g_Templates);
-
-STDAPI DllRegisterServer()
-{
- CAtlList<CString> chkbytes;
- chkbytes.AddTail(_T("0,4,,52494646,8,4,,41564920")); // 'RIFF' ... 'AVI '
- chkbytes.AddTail(_T("0,4,,52494646,8,4,,41564958")); // 'RIFF' ... 'AVIX'
- chkbytes.AddTail(_T("0,4,,52494646,8,4,,414D5620")); // 'RIFF' ... 'AMV '
-
- RegisterSourceFilter(
- CLSID_AsyncReader,
- MEDIASUBTYPE_Avi,
- chkbytes,
- _T(".avi"), _T(".divx"), _T(".vp6"), _T(".amv"), nullptr);
-
- return AMovieDllRegisterServer2(TRUE);
-}
-
-STDAPI DllUnregisterServer()
-{
- //UnRegisterSourceFilter(MEDIASUBTYPE_Avi);
-
- return AMovieDllRegisterServer2(FALSE);
-}
-
-extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);
-
-class CAviSplitterApp : public CWinApp
-{
-public:
- CAviSplitterApp() {}
-
- BOOL InitInstance() {
- if (!__super::InitInstance()) {
- return FALSE;
- }
- DllEntryPoint(m_hInstance, DLL_PROCESS_ATTACH, 0);
- return TRUE;
- }
-
- BOOL ExitInstance() {
- DllEntryPoint(m_hInstance, DLL_PROCESS_DETACH, 0);
- return __super::ExitInstance();
- }
-
- void SetDefaultRegistryKey() {
- SetRegistryKey(_T("Gabest"));
- }
-
- DECLARE_MESSAGE_MAP()
-};
-
-BEGIN_MESSAGE_MAP(CAviSplitterApp, CWinApp)
-END_MESSAGE_MAP()
-
-CAviSplitterApp theApp;
-
-#endif
-
-//
-// CAviSplitterFilter
-//
-
-CAviSplitterFilter::CAviSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("CAviSplitterFilter"), pUnk, phr, __uuidof(this), MAXPACKETS_AVI)
- , m_timeformat(TIME_FORMAT_MEDIA_TIME)
- , m_maxTimeStamp(Packet::INVALID_TIME)
- , m_bNonInterleavedFilesSupport(true)
-{
-#ifdef STANDALONE_FILTER
- /*CRegKey key;
-
- if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\AVI Splitter"), KEY_READ)) {
- DWORD dw;
-
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("NonInterleavedFilesSupport"), dw)) {
- m_bNonInterleavedFilesSupport = !!dw;
- }
- }*/
-#else
- //m_bNonInterleavedFilesSupport = !!AfxGetApp()->GetProfileInt(_T("Filters\\AVI Splitter"), _T("NonInterleavedFilesSupport"), m_bNonInterleavedFilesSupport);
-#endif
-}
-
-STDMETHODIMP CAviSplitterFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
-{
- CheckPointer(ppv, E_POINTER);
-
- *ppv = nullptr;
-
- return
- QI(IAviSplitterFilter)
- QI(ISpecifyPropertyPages)
- QI(ISpecifyPropertyPages2)
- __super::NonDelegatingQueryInterface(riid, ppv);
-}
-
-STDMETHODIMP CAviSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo)
-{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
-
- if (m_pName && m_pName[0] == L'M' && m_pName[1] == L'P' && m_pName[2] == L'C') {
- (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
- wcscpy_s(pInfo->achName, AviSourceName);
- }
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
-}
-
-HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
-{
- CheckPointer(pAsyncReader, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- m_pFile.Free();
- m_tFrame.Free();
-
- m_pFile.Attach(DEBUG_NEW CAviFile(pAsyncReader, hr));
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
-
- if (SUCCEEDED(hr) && !m_bNonInterleavedFilesSupport && !m_pFile->IsInterleaved()) {
- hr = E_FAIL;
- }
-
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration = m_pFile->GetTotalTime();
-
- bool fHasIndex = false;
-
- for (unsigned int i = 0; !fHasIndex && i < m_pFile->m_strms.GetCount(); ++i) {
- if (!m_pFile->m_strms[i]->cs.IsEmpty()) {
- fHasIndex = true;
- }
- }
-
- for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
- CAviFile::strm_t* s = m_pFile->m_strms[i];
-
- if (fHasIndex && s->cs.IsEmpty()) {
- continue;
- }
-
- CMediaType mt;
- CAtlArray<CMediaType> mts;
-
- CStringW name, label;
-
- if (s->strh.fccType == FCC('vids')) {
- label = L"Video";
-
- ASSERT(s->strf.GetCount() >= sizeof(BITMAPINFOHEADER));
-
- BITMAPINFOHEADER* pbmi = &((BITMAPINFO*)s->strf.GetData())->bmiHeader;
-
- mt.majortype = MEDIATYPE_Video;
- switch (pbmi->biCompression) {
- case BI_RGB:
- case BI_BITFIELDS:
- mt.subtype =
- pbmi->biBitCount == 1 ? MEDIASUBTYPE_RGB1 :
- pbmi->biBitCount == 4 ? MEDIASUBTYPE_RGB4 :
- pbmi->biBitCount == 8 ? MEDIASUBTYPE_RGB8 :
- pbmi->biBitCount == 16 ? MEDIASUBTYPE_RGB565 :
- pbmi->biBitCount == 24 ? MEDIASUBTYPE_RGB24 :
- pbmi->biBitCount == 32 ? MEDIASUBTYPE_ARGB32 :
- MEDIASUBTYPE_NULL;
- break;
- //case BI_RLE8: mt.subtype = MEDIASUBTYPE_RGB8; break;
- //case BI_RLE4: mt.subtype = MEDIASUBTYPE_RGB4; break;
- case FCC('AVRn')://uncommon fourcc
- case FCC('JPGL')://uncommon fourcc
- mt.subtype = MEDIASUBTYPE_MJPG;
- break;
- case FCC('MPG2'):
- mt.subtype = MEDIASUBTYPE_MPEG2_VIDEO;
- break;
- default:
- mt.subtype = FOURCCMap(pbmi->biCompression);
- }
- mt.formattype = FORMAT_VideoInfo;
- VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + (ULONG)s->strf.GetCount() - sizeof(BITMAPINFOHEADER));
- ZeroMemory(mt.Format(), mt.FormatLength());
- memcpy(&pvih->bmiHeader, s->strf.GetData(), s->strf.GetCount());
- if (s->strh.dwRate > 0) {
- pvih->AvgTimePerFrame = 10000000ui64 * s->strh.dwScale / s->strh.dwRate;
- }
-
- if (s->cs.GetCount() && pvih->AvgTimePerFrame > 0) {
- UINT64 size = 0;
- for (unsigned int j = 0; j < s->cs.GetCount(); ++j) {
- size += s->cs[j].orgsize;
- }
- pvih->dwBitRate = (DWORD)(10000000.0 * size * 8 / (s->cs.GetCount() * pvih->AvgTimePerFrame) + 0.5);
- // need calculate in double, because the (10000000ui64 * size * 8) can give overflow
- }
-
- mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
- ? s->strh.dwSuggestedBufferSize * 3 / 2
- : (pvih->bmiHeader.biWidth * pvih->bmiHeader.biHeight * 4));
- mts.Add(mt);
- } else if (s->strh.fccType == FCC('auds') || s->strh.fccType == FCC('amva')) {
- label = L"Audio";
-
- ASSERT(s->strf.GetCount() >= sizeof(WAVEFORMATEX)
- || s->strf.GetCount() == sizeof(PCMWAVEFORMAT));
-
- WAVEFORMATEX* pwfe = (WAVEFORMATEX*)s->strf.GetData();
-
- if (pwfe->nBlockAlign == 0) {
- continue;
- }
-
- mt.majortype = MEDIATYPE_Audio;
- if (m_pFile->m_isamv) {
- mt.subtype = FOURCCMap(MAKEFOURCC('A', 'M', 'V', 'A'));
- } else {
- mt.subtype = FOURCCMap(pwfe->wFormatTag);
- }
- mt.formattype = FORMAT_WaveFormatEx;
- if (nullptr == mt.AllocFormatBuffer(max((ULONG)s->strf.GetCount(), sizeof(WAVEFORMATEX)))) {
- continue;
- }
- memcpy(mt.Format(), s->strf.GetData(), s->strf.GetCount());
- pwfe = (WAVEFORMATEX*)mt.Format();
- if (s->strf.GetCount() == sizeof(PCMWAVEFORMAT)) {
- pwfe->cbSize = 0;
- }
- if (pwfe->wFormatTag == WAVE_FORMAT_PCM) {
- pwfe->nBlockAlign = pwfe->nChannels * pwfe->wBitsPerSample >> 3;
- }
- if (pwfe->wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
- mt.subtype = ((WAVEFORMATEXTENSIBLE*)pwfe)->SubFormat;
- }
- mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
- ? s->strh.dwSuggestedBufferSize * 3 / 2
- : (pwfe->nChannels * pwfe->nSamplesPerSec * 32 >> 3));
- mts.Add(mt);
- } else if (s->strh.fccType == FCC('mids')) {
- label = L"Midi";
-
- mt.majortype = MEDIATYPE_Midi;
- mt.subtype = MEDIASUBTYPE_NULL;
- mt.formattype = FORMAT_None;
- mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
- ? s->strh.dwSuggestedBufferSize * 3 / 2
- : (1024 * 1024));
- mts.Add(mt);
- } else if (s->strh.fccType == FCC('txts')) {
- label = L"Text";
-
- mt.majortype = MEDIATYPE_Text;
- mt.subtype = MEDIASUBTYPE_NULL;
- mt.formattype = FORMAT_None;
- mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
- ? s->strh.dwSuggestedBufferSize * 3 / 2
- : (1024 * 1024));
- mts.Add(mt);
- } else if (s->strh.fccType == FCC('iavs')) {
- label = L"Interleaved";
-
- ASSERT(s->strh.fccHandler == FCC('dvsd'));
-
- mt.majortype = MEDIATYPE_Interleaved;
- mt.subtype = FOURCCMap(s->strh.fccHandler);
- mt.formattype = FORMAT_DvInfo;
- mt.SetFormat(s->strf.GetData(), max((ULONG)s->strf.GetCount(), sizeof(DVINFO)));
- mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
- ? s->strh.dwSuggestedBufferSize * 3 / 2
- : (1024 * 1024));
- mts.Add(mt);
- }
-
- if (mts.IsEmpty()) {
- TRACE(_T("CAviSourceFilter: Unsupported stream (%d)\n"), i);
- continue;
- }
-
- //Put filename at front sometime(eg. ~temp.avi) will cause filter graph
- //stop check this pin. Not sure the reason exactly. but it happens.
- //If you know why, please emailto: tomasen@gmail.com
- if (s->strn.IsEmpty()) {
- name.Format(L"%s %u", label, i);
- } else {
- name.Format(L"%s (%s %u)", CStringW(s->strn), label, i);
- }
-
- HRESULT hr2;
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DEBUG_NEW CAviSplitterOutputPin(mts, name, this, this, &hr2));
- AddOutputPin(i, pPinOut);
- }
-
- POSITION pos = m_pFile->m_info.GetStartPosition();
- while (pos) {
- DWORD fcc;
- CStringA value;
- m_pFile->m_info.GetNextAssoc(pos, fcc, value);
-
- switch (fcc) {
- case FCC('INAM'):
- SetProperty(L"TITL", CStringW(value));
- break;
- case FCC('IART'):
- SetProperty(L"AUTH", CStringW(value));
- break;
- case FCC('ICOP'):
- SetProperty(L"CPYR", CStringW(value));
- break;
- case FCC('ISBJ'):
- SetProperty(L"DESC", CStringW(value));
- break;
- }
- }
-
- m_tFrame.Attach(DEBUG_NEW DWORD[m_pFile->m_avih.dwStreams]);
-
- return !m_pOutputs.IsEmpty() ? S_OK : E_FAIL;
-}
-
-bool CAviSplitterFilter::DemuxInit()
-{
- SetThreadName((DWORD) - 1, "CAviSplitterFilter");
-
- if (!m_pFile) {
- return false;
- }
-
- // reindex if needed
-
- bool fReIndex = false;
-
- for (DWORD i = 0; i < m_pFile->m_avih.dwStreams && !fReIndex; ++i) {
- if (m_pFile->m_strms[i]->cs.IsEmpty() && GetOutputPin(i)) {
- fReIndex = true;
- }
- }
-
- if (fReIndex) {
- m_pFile->EmptyIndex();
-
- m_fAbort = false;
- m_nOpenProgress = 0;
-
- m_rtDuration = 0;
-
- CAutoVectorPtr<UINT64> pSize;
- pSize.Allocate(m_pFile->m_avih.dwStreams);
- ZeroMemory((UINT64*)pSize, sizeof(UINT64)*m_pFile->m_avih.dwStreams);
- m_pFile->Seek(0);
- ReIndex(m_pFile->GetLength(), pSize);
-
- if (m_fAbort) {
- m_pFile->EmptyIndex();
- }
-
- m_fAbort = false;
- m_nOpenProgress = 100;
- }
-
- return true;
-}
-
-HRESULT CAviSplitterFilter::ReIndex(__int64 end, UINT64* pSize)
-{
- HRESULT hr = S_OK;
-
- while (S_OK == hr && m_pFile->GetPos() < end && SUCCEEDED(hr) && !m_fAbort) {
- __int64 pos = m_pFile->GetPos();
-
- DWORD id = 0, size;
- if (S_OK != m_pFile->Read(id) || id == 0) {
- return E_FAIL;
- }
-
- if (id == FCC('RIFF') || id == FCC('LIST')) {
- if (S_OK != m_pFile->Read(size) || S_OK != m_pFile->Read(id)) {
- return E_FAIL;
- }
-
- size += (size & 1) + 8;
-
- if (id == FCC('AVI ') || id == FCC('AVIX') || id == FCC('movi') || id == FCC('rec ')) {
- hr = ReIndex(pos + size, pSize);
- }
- } else {
- if (S_OK != m_pFile->Read(size)) {
- return E_FAIL;
- }
-
- DWORD TrackNumber = TRACKNUM(id);
-
- if (TrackNumber < m_pFile->m_strms.GetCount()) {
- CAviFile::strm_t* s = m_pFile->m_strms[TrackNumber];
-
- WORD type = TRACKTYPE(id);
-
- if (type == 'db' || type == 'dc' || /*type == 'pc' ||*/ type == 'wb'
- || type == 'iv' || type == '__' || type == 'xx') {
- CAviFile::strm_t::chunk c;
- c.filepos = pos;
- c.size = pSize[TrackNumber];
- c.orgsize = size;
- c.fKeyFrame = size > 0; // TODO: find a better way...
- c.fChunkHdr = true;
- s->cs.Add(c);
-
- pSize[TrackNumber] += s->GetChunkSize(size);
-
- REFERENCE_TIME rt = s->GetRefTime((DWORD)s->cs.GetCount() - 1, pSize[TrackNumber]);
- m_rtDuration = max(rt, m_rtDuration);
- }
- }
-
- size += (size & 1) + 8;
- }
-
- m_pFile->Seek(pos + size);
-
- m_nOpenProgress = m_pFile->GetPos() * 100 / m_pFile->GetLength();
-
- DWORD cmd;
- if (CheckRequest(&cmd)) {
- if (cmd == CMD_EXIT) {
- m_fAbort = true;
- } else {
- Reply(S_OK);
- }
- }
- }
-
- return hr;
-}
-
-void CAviSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
-{
- ZeroMemory((DWORD*)m_tFrame, m_pFile->m_avih.dwStreams * sizeof(DWORD));
- m_pFile->Seek(0);
-
- DbgLog((LOG_TRACE, 0, _T("Seek: %I64d"), rt / 10000));
-
- if (rt > 0) {
- for (DWORD track = 0; track < m_pFile->m_avih.dwStreams; track++) {
- CAviFile::strm_t* s = m_pFile->m_strms[track];
-
- if (s->IsRawSubtitleStream() || s->cs.IsEmpty()) {
- continue;
- }
-
- //ASSERT(s->GetFrame(rt) == s->GetKeyFrame(rt)); // fast seek test
- m_tFrame[track] = s->GetKeyFrame(rt);
- }
- }
-}
-
-bool CAviSplitterFilter::DemuxLoop()
-{
- HRESULT hr = S_OK;
-
- CAtlArray<BOOL> fDiscontinuity;
- fDiscontinuity.SetCount(m_pFile->m_avih.dwStreams);
- ZeroMemory(fDiscontinuity.GetData(), m_pFile->m_avih.dwStreams * sizeof(BOOL));
-
- while (SUCCEEDED(hr) && !CheckRequest(nullptr)) {
- DWORD curTrack = DWORD_MAX;
-
- REFERENCE_TIME minTime = INT64_MAX;
- UINT64 minpos = INT64_MAX;
- for (DWORD track = 0; track < m_pFile->m_avih.dwStreams; track++) {
- CAviFile::strm_t* s = m_pFile->m_strms[track];
- DWORD f = m_tFrame[track];
-
- if (f >= (DWORD)s->cs.GetCount()) {
- continue;
- }
-
- if (s->IsRawSubtitleStream()) {
- // TODO: get subtitle time from index
- minTime = 0;
- curTrack = track;
- break; // read all subtitles at once
- }
-
- REFERENCE_TIME start = s->GetRefTime(f, s->cs[f].size);
- if (start < minTime || (start == minTime && s->cs[f].filepos < minpos)) {
- minTime = start;
- curTrack = track;
- minpos = s->cs[f].filepos;
- }
- }
-
- if (minTime == INT64_MAX) {
- return true;
- }
-
- do {
- CAviFile::strm_t* s = m_pFile->m_strms[curTrack];
- DWORD f = m_tFrame[curTrack];
- //TRACE(_T("CAviFile::DemuxLoop(): track %d, time %I64d, pos %I64d\n"), curTrack, minTime, s->cs[f].filepos);
-
- m_pFile->Seek(s->cs[f].filepos);
- DWORD size = 0;
-
- if (s->cs[f].fChunkHdr) {
- DWORD id = 0;
- if (S_OK != m_pFile->Read(id) || id == 0 || curTrack != TRACKNUM(id) || S_OK != m_pFile->Read(size)) {
- fDiscontinuity[curTrack] = true;
- break;
- }
-
- if (size != s->cs[f].orgsize) {
- TRACE(_T("WARNING: CAviFile::DemuxLoop() incorrect chunk size. By index: %d, by header: %d\n"), s->cs[f].orgsize, size);
- fDiscontinuity[curTrack] = true;
- //ASSERT(0);
- break;
- }
- } else {
- size = s->cs[f].orgsize;
- }
-
- CAutoPtr<Packet> p(DEBUG_NEW Packet());
-
- p->TrackNumber = (DWORD)curTrack;
- p->bSyncPoint = (BOOL)s->cs[f].fKeyFrame;
- p->bDiscontinuity = fDiscontinuity[curTrack];
- p->rtStart = s->GetRefTime(f, s->cs[f].size);
- p->rtStop = s->GetRefTime(f + 1, f + 1 < (DWORD)s->cs.GetCount() ? s->cs[f + 1].size : s->totalsize);
- p->SetCount(size);
- if (S_OK != (hr = m_pFile->ByteRead(p->GetData(), p->GetCount()))) {
- return true; // break;
- }
-#if defined(_DEBUG) && 0
- DbgLog((LOG_TRACE, 0,
- _T("%d (%d): %I64d - %I64d, %I64d - %I64d (size = %d)"),
- minTrack, (int)p->bSyncPoint,
- (p->rtStart) / 10000, (p->rtStop) / 10000,
- (p->rtStart - m_rtStart) / 10000, (p->rtStop - m_rtStart) / 10000,
- size));
-#endif
- m_maxTimeStamp = max(m_maxTimeStamp, p->rtStart);
-
- hr = DeliverPacket(p);
-
- fDiscontinuity[curTrack] = false;
- } while (0);
-
- m_tFrame[curTrack]++;
- }
-
- if (m_maxTimeStamp != Packet::INVALID_TIME) {
- m_rtCurrent = m_maxTimeStamp;
- }
- return true;
-}
-
-// IMediaSeeking
-
-STDMETHODIMP CAviSplitterFilter::GetDuration(LONGLONG* pDuration)
-{
- CheckPointer(pDuration, E_POINTER);
- CheckPointer(m_pFile, VFW_E_NOT_CONNECTED);
-
- if (m_timeformat == TIME_FORMAT_FRAME) {
- for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
- CAviFile::strm_t* s = m_pFile->m_strms[i];
- if (s->strh.fccType == FCC('vids')) {
- *pDuration = s->cs.GetCount();
- return S_OK;
- }
- }
-
- return E_UNEXPECTED;
- }
-
- return __super::GetDuration(pDuration);
-}
-
-//
-
-STDMETHODIMP CAviSplitterFilter::IsFormatSupported(const GUID* pFormat)
-{
- CheckPointer(pFormat, E_POINTER);
- HRESULT hr = __super::IsFormatSupported(pFormat);
- if (S_OK == hr) {
- return hr;
- }
- return *pFormat == TIME_FORMAT_FRAME ? S_OK : S_FALSE;
-}
-
-STDMETHODIMP CAviSplitterFilter::GetTimeFormat(GUID* pFormat)
-{
- CheckPointer(pFormat, E_POINTER);
- *pFormat = m_timeformat;
- return S_OK;
-}
-
-STDMETHODIMP CAviSplitterFilter::IsUsingTimeFormat(const GUID* pFormat)
-{
- CheckPointer(pFormat, E_POINTER);
- return *pFormat == m_timeformat ? S_OK : S_FALSE;
-}
-
-STDMETHODIMP CAviSplitterFilter::SetTimeFormat(const GUID* pFormat)
-{
- CheckPointer(pFormat, E_POINTER);
- if (S_OK != IsFormatSupported(pFormat)) {
- return E_FAIL;
- }
- m_timeformat = *pFormat;
- return S_OK;
-}
-
-STDMETHODIMP CAviSplitterFilter::GetStopPosition(LONGLONG* pStop)
-{
- CheckPointer(pStop, E_POINTER);
- if (FAILED(__super::GetStopPosition(pStop))) {
- return E_FAIL;
- }
- if (m_timeformat == TIME_FORMAT_MEDIA_TIME) {
- return S_OK;
- }
- LONGLONG rt = *pStop;
- if (FAILED(ConvertTimeFormat(pStop, &TIME_FORMAT_FRAME, rt, &TIME_FORMAT_MEDIA_TIME))) {
- return E_FAIL;
- }
- return S_OK;
-}
-
-STDMETHODIMP CAviSplitterFilter::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat)
-{
- CheckPointer(pTarget, E_POINTER);
-
- const GUID& SourceFormat = pSourceFormat ? *pSourceFormat : m_timeformat;
- const GUID& TargetFormat = pTargetFormat ? *pTargetFormat : m_timeformat;
-
- if (TargetFormat == SourceFormat) {
- *pTarget = Source;
- return S_OK;
- } else if (TargetFormat == TIME_FORMAT_FRAME && SourceFormat == TIME_FORMAT_MEDIA_TIME) {
- for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
- CAviFile::strm_t* s = m_pFile->m_strms[i];
- if (s->strh.fccType == FCC('vids')) {
- *pTarget = s->GetFrame(Source);
- return S_OK;
- }
- }
- } else if (TargetFormat == TIME_FORMAT_MEDIA_TIME && SourceFormat == TIME_FORMAT_FRAME) {
- for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
- CAviFile::strm_t* s = m_pFile->m_strms[i];
- if (s->strh.fccType == FCC('vids')) {
- if (Source < 0 || Source >= (LONGLONG)s->cs.GetCount()) {
- return E_FAIL;
- }
- CAviFile::strm_t::chunk& c = s->cs[(size_t)Source];
- *pTarget = s->GetRefTime((DWORD)Source, c.size);
- return S_OK;
- }
- }
- }
-
- return E_FAIL;
-}
-
-STDMETHODIMP CAviSplitterFilter::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop)
-{
- HRESULT hr;
- if (FAILED(hr = __super::GetPositions(pCurrent, pStop)) || m_timeformat != TIME_FORMAT_FRAME) {
- return hr;
- }
-
- if (pCurrent)
- if (FAILED(ConvertTimeFormat(pCurrent, &TIME_FORMAT_FRAME, *pCurrent, &TIME_FORMAT_MEDIA_TIME))) {
- return E_FAIL;
- }
- if (pStop)
- if (FAILED(ConvertTimeFormat(pStop, &TIME_FORMAT_FRAME, *pStop, &TIME_FORMAT_MEDIA_TIME))) {
- return E_FAIL;
- }
-
- return S_OK;
-}
-
-HRESULT CAviSplitterFilter::SetPositionsInternal(void* id, LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
-{
- if (m_timeformat != TIME_FORMAT_FRAME) {
- return __super::SetPositionsInternal(id, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
- }
-
- if (!pCurrent && !pStop
- || (dwCurrentFlags & AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning
- && (dwStopFlags & AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning) {
- return S_OK;
- }
-
- REFERENCE_TIME
- rtCurrent = m_rtCurrent,
- rtStop = m_rtStop;
-
- if ((dwCurrentFlags & AM_SEEKING_PositioningBitsMask)
- && FAILED(ConvertTimeFormat(&rtCurrent, &TIME_FORMAT_FRAME, rtCurrent, &TIME_FORMAT_MEDIA_TIME))) {
- return E_FAIL;
- }
- if ((dwStopFlags & AM_SEEKING_PositioningBitsMask)
- && FAILED(ConvertTimeFormat(&rtStop, &TIME_FORMAT_FRAME, rtStop, &TIME_FORMAT_MEDIA_TIME))) {
- return E_FAIL;
- }
-
- if (pCurrent)
- switch (dwCurrentFlags & AM_SEEKING_PositioningBitsMask) {
- case AM_SEEKING_NoPositioning:
- break;
- case AM_SEEKING_AbsolutePositioning:
- rtCurrent = *pCurrent;
- break;
- case AM_SEEKING_RelativePositioning:
- rtCurrent = rtCurrent + *pCurrent;
- break;
- case AM_SEEKING_IncrementalPositioning:
- rtCurrent = rtCurrent + *pCurrent;
- break;
- }
-
- if (pStop)
- switch (dwStopFlags & AM_SEEKING_PositioningBitsMask) {
- case AM_SEEKING_NoPositioning:
- break;
- case AM_SEEKING_AbsolutePositioning:
- rtStop = *pStop;
- break;
- case AM_SEEKING_RelativePositioning:
- rtStop += *pStop;
- break;
- case AM_SEEKING_IncrementalPositioning:
- rtStop = rtCurrent + *pStop;
- break;
- }
-
- if ((dwCurrentFlags & AM_SEEKING_PositioningBitsMask)
- && pCurrent)
- if (FAILED(ConvertTimeFormat(pCurrent, &TIME_FORMAT_MEDIA_TIME, rtCurrent, &TIME_FORMAT_FRAME))) {
- return E_FAIL;
- }
- if ((dwStopFlags & AM_SEEKING_PositioningBitsMask)
- && pStop)
- if (FAILED(ConvertTimeFormat(pStop, &TIME_FORMAT_MEDIA_TIME, rtStop, &TIME_FORMAT_FRAME))) {
- return E_FAIL;
- }
-
- return __super::SetPositionsInternal(id, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
-}
-
-// IKeyFrameInfo
-
-STDMETHODIMP CAviSplitterFilter::GetKeyFrameCount(UINT& nKFs)
-{
- if (!m_pFile) {
- return E_UNEXPECTED;
- }
-
- HRESULT hr = S_OK;
-
- nKFs = 0;
-
- for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
- CAviFile::strm_t* s = m_pFile->m_strms[i];
- if (s->strh.fccType != FCC('vids')) {
- continue;
- }
-
- for (unsigned int j = 0; j < s->cs.GetCount(); ++j) {
- CAviFile::strm_t::chunk& c = s->cs[j];
- if (c.fKeyFrame) {
- ++nKFs;
- }
- }
-
- if (nKFs == s->cs.GetCount()) {
- hr = S_FALSE;
- }
-
- break;
- }
-
- return hr;
-}
-
-STDMETHODIMP CAviSplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs)
-{
- CheckPointer(pFormat, E_POINTER);
- CheckPointer(pKFs, E_POINTER);
-
- if (!m_pFile) {
- return E_UNEXPECTED;
- }
- if (*pFormat != TIME_FORMAT_MEDIA_TIME && *pFormat != TIME_FORMAT_FRAME) {
- return E_INVALIDARG;
- }
-
- for (unsigned int i = 0; i < m_pFile->m_strms.GetCount(); ++i) {
- CAviFile::strm_t* s = m_pFile->m_strms[i];
- if (s->strh.fccType != FCC('vids')) {
- continue;
- }
- bool fConvertToRefTime = !!(*pFormat == TIME_FORMAT_MEDIA_TIME);
-
- UINT nKFsTmp = 0;
-
- for (unsigned int j = 0; j < s->cs.GetCount() && nKFsTmp < nKFs; ++j) {
- if (s->cs[j].fKeyFrame) {
- pKFs[nKFsTmp++] = fConvertToRefTime ? s->GetRefTime(j, s->cs[j].size) : j;
- }
- }
- nKFs = nKFsTmp;
-
- return S_OK;
- }
-
- return E_FAIL;
-}
-
-// ISpecifyPropertyPages2
-
-STDMETHODIMP CAviSplitterFilter::GetPages(CAUUID* pPages)
-{
- CheckPointer(pPages, E_POINTER);
-
- HRESULT hr = S_OK;
-
- pPages->cElems = 1;
- pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID) * pPages->cElems);
- if (pPages->pElems != nullptr) {
- pPages->pElems[0] = __uuidof(CAviSplitterSettingsWnd);
- } else {
- hr = E_OUTOFMEMORY;
- }
-
- return hr;
-}
-
-STDMETHODIMP CAviSplitterFilter::CreatePage(const GUID& guid, IPropertyPage** ppPage)
-{
- CheckPointer(ppPage, E_POINTER);
-
- if (*ppPage != nullptr) {
- return E_INVALIDARG;
- }
-
- HRESULT hr;
-
- if (guid == __uuidof(CAviSplitterSettingsWnd)) {
- (*ppPage = DEBUG_NEW CInternalPropertyPageTempl<CAviSplitterSettingsWnd>(nullptr, &hr))->AddRef();
- }
-
- return *ppPage ? S_OK : E_FAIL;
-}
-
-// IAviSplitterFilter
-STDMETHODIMP CAviSplitterFilter::Apply()
-{
-#ifdef STANDALONE_FILTER
- /*CRegKey key;
- if (ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\AVI Splitter"))) {
- key.SetDWORDValue(_T("NonInterleavedFilesSupport"), m_bNonInterleavedFilesSupport);
- }*/
-#else
- //AfxGetApp()->WriteProfileInt(_T("Filters\\AVI Splitter"), _T("NonInterleavedFilesSupport"), m_bNonInterleavedFilesSupport);
-#endif
-
- return S_OK;
-}
-
-STDMETHODIMP CAviSplitterFilter::SetNonInterleavedFilesSupport(BOOL nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_bNonInterleavedFilesSupport = !!nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(BOOL) CAviSplitterFilter::GetNonInterleavedFilesSupport()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_bNonInterleavedFilesSupport;
-}
-
-//
-// CAviSourceFilter
-//
-
-CAviSourceFilter::CAviSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CAviSplitterFilter(pUnk, phr)
-{
- m_clsid = __uuidof(this);
- m_pInput.Free();
-}
-
-//
-// CAviSplitterOutputPin
-//
-
-CAviSplitterOutputPin::CAviSplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseSplitterOutputPin(mts, pName, pFilter, pLock, phr, 0, MAXPACKETS_AVI)
-{
-}
-
-HRESULT CAviSplitterOutputPin::CheckConnect(IPin* pPin)
-{
- int iPosition = 0;
- CMediaType mt;
- while (S_OK == GetMediaType(iPosition++, &mt)) {
- if (mt.majortype == MEDIATYPE_Video
- && (mt.subtype == FOURCCMap(FCC('IV32'))
- || mt.subtype == FOURCCMap(FCC('IV31'))
- || mt.subtype == FOURCCMap(FCC('IF09')))) {
- CLSID clsid = GetCLSID(GetFilterFromPin(pPin));
- if (clsid == CLSID_VideoMixingRenderer || clsid == CLSID_OverlayMixer) {
- return E_FAIL;
- }
- }
-
- mt.InitMediaType();
- }
-
- return __super::CheckConnect(pPin);
-}
diff --git a/src/filters/parser/AviSplitter/AviSplitter.def b/src/filters/parser/AviSplitter/AviSplitter.def
deleted file mode 100644
index 6492e5cd6..000000000
--- a/src/filters/parser/AviSplitter/AviSplitter.def
+++ /dev/null
@@ -1,5 +0,0 @@
-EXPORTS
- DllCanUnloadNow PRIVATE
- DllGetClassObject PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
diff --git a/src/filters/parser/AviSplitter/AviSplitter.h b/src/filters/parser/AviSplitter/AviSplitter.h
deleted file mode 100644
index 8f2005fd2..000000000
--- a/src/filters/parser/AviSplitter/AviSplitter.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <atlbase.h>
-#include <atlcoll.h>
-#include "../BaseSplitter/BaseSplitter.h"
-#include "AviSplitterSettingsWnd.h"
-
-#define AviSplitterName L"MPC AVI Splitter"
-#define AviSourceName L"MPC AVI Source"
-
-class CAviFile;
-
-class CAviSplitterOutputPin : public CBaseSplitterOutputPin
-{
-public:
- CAviSplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
-
- HRESULT CheckConnect(IPin* pPin);
-};
-
-class __declspec(uuid("9736D831-9D6C-4E72-B6E7-560EF9181001"))
- CAviSplitterFilter
- : public CBaseSplitterFilter
- , public ISpecifyPropertyPages2
- , public IAviSplitterFilter
-{
- CCritSec m_csProps;
-
- CAutoVectorPtr<DWORD> m_tFrame;
-
- bool m_bNonInterleavedFilesSupport;
-
-protected:
- CAutoPtr<CAviFile> m_pFile;
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
-
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
-
- HRESULT ReIndex(__int64 end, UINT64* pSize);
-
- REFERENCE_TIME m_maxTimeStamp;
-public:
- CAviSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // CBaseFilter
-
- STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
-
- // IMediaSeeking
-
- STDMETHODIMP GetDuration(LONGLONG* pDuration);
-
- // TODO: this is too ugly, integrate this with the baseclass somehow
- GUID m_timeformat;
- STDMETHODIMP IsFormatSupported(const GUID* pFormat);
- STDMETHODIMP GetTimeFormat(GUID* pFormat);
- STDMETHODIMP IsUsingTimeFormat(const GUID* pFormat);
- STDMETHODIMP SetTimeFormat(const GUID* pFormat);
- STDMETHODIMP GetStopPosition(LONGLONG* pStop);
- STDMETHODIMP ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat,
- LONGLONG Source, const GUID* pSourceFormat);
- STDMETHODIMP GetPositions(LONGLONG* pCurrent, LONGLONG* pStop);
-
- HRESULT SetPositionsInternal(void* id, LONGLONG* pCurrent, DWORD dwCurrentFlags,
- LONGLONG* pStop, DWORD dwStopFlags);
-
- // IKeyFrameInfo
-
- STDMETHODIMP GetKeyFrameCount(UINT& nKFs);
- STDMETHODIMP GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs);
-
- // ISpecifyPropertyPages2
-
- STDMETHODIMP GetPages(CAUUID* pPages);
- STDMETHODIMP CreatePage(const GUID& guid, IPropertyPage** ppPage);
-
- // IAviSplitterFilter
- STDMETHODIMP Apply();
-
- STDMETHODIMP SetNonInterleavedFilesSupport(BOOL nValue);
- STDMETHODIMP_(BOOL) GetNonInterleavedFilesSupport();
-};
-
-class __declspec(uuid("CEA8DEFF-0AF7-4DB9-9A38-FB3C3AEFC0DE"))
- CAviSourceFilter : public CAviSplitterFilter
-{
-public:
- CAviSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
-};
diff --git a/src/filters/parser/AviSplitter/AviSplitter.rc b/src/filters/parser/AviSplitter/AviSplitter.rc
deleted file mode 100644
index da78c7cbd..000000000
--- a/src/filters/parser/AviSplitter/AviSplitter.rc
+++ /dev/null
@@ -1,108 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-#include "version.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (United States) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION MPC_VERSION_NUM
- PRODUCTVERSION MPC_VERSION_NUM
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS VOS_NT_WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE VFT2_UNKNOWN
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", MPC_VERSION_COMMENTS
- VALUE "CompanyName", MPC_COMP_NAME_STR
- VALUE "FileDescription", "AVI Splitter"
- VALUE "FileVersion", MPC_VERSION_STR_FULL
- VALUE "InternalName", "AVI Splitter"
- VALUE "LegalCopyright", MPC_COPYRIGHT_STR
- VALUE "OriginalFilename", "AviSplitter.ax"
- VALUE "ProductName", "AVI Splitter"
- VALUE "ProductVersion", MPC_VERSION_STR_FULL
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-STRINGTABLE
-BEGIN
- IDS_FILTER_SETTINGS_CAPTION "Settings"
- IDS_AVISPLITTER_NON_INTERLEAVED "Non interleaved files support"
-END
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // English (United States) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/src/filters/parser/AviSplitter/AviSplitter.vcxproj b/src/filters/parser/AviSplitter/AviSplitter.vcxproj
deleted file mode 100644
index b07296a91..000000000
--- a/src/filters/parser/AviSplitter/AviSplitter.vcxproj
+++ /dev/null
@@ -1,258 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug Filter|Win32">
- <Configuration>Debug Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug Filter|x64">
- <Configuration>Debug Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|Win32">
- <Configuration>Release Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|x64">
- <Configuration>Release Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{9738B023-FC46-48A2-953A-0035FD897678}</ProjectGuid>
- <RootNamespace>AviSplitter</RootNamespace>
- <Keyword>MFCProj</Keyword>
- <ProjectName>AviSplitter</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <Import Project="..\..\..\platform.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">.ax</TargetExt>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>AviSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>AviSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>AviSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>AviSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="AviFile.cpp" />
- <ClCompile Include="AviSplitter.cpp" />
- <ClCompile Include="AviSplitterSettingsWnd.cpp" />
- <ClCompile Include="stdafx.cpp">
- <PrecompiledHeader>Create</PrecompiledHeader>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="AviSplitter.def" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="AviFile.h" />
- <ClInclude Include="AviSplitter.h" />
- <ClInclude Include="AviSplitterSettingsWnd.h" />
- <ClInclude Include="IAviSplitterFilter.h" />
- <ClInclude Include="resource.h">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ClInclude>
- <ClInclude Include="stdafx.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="AviSplitter.rc">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ResourceCompile>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\DSUtil\DSUtil.vcxproj">
- <Project>{fc70988b-1ae5-4381-866d-4f405e28ac42}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\Kasumi\Kasumi.vcxproj">
- <Project>{0d252872-7542-4232-8d02-53f9182aee15}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\system\system.vcxproj">
- <Project>{c2082189-3ecb-4079-91fa-89d3c8a305c0}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\BaseClasses\BaseClasses.vcxproj">
- <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\Filters.vcxproj">
- <Project>{273b3149-3192-4b75-a791-470320b90812}</Project>
- </ProjectReference>
- <ProjectReference Include="..\BaseSplitter\BaseSplitter.vcxproj">
- <Project>{37768b3f-89bc-4c16-b2a8-767c5da84c3f}</Project>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/AviSplitter/AviSplitter.vcxproj.filters b/src/filters/parser/AviSplitter/AviSplitter.vcxproj.filters
deleted file mode 100644
index 080f0fa1b..000000000
--- a/src/filters/parser/AviSplitter/AviSplitter.vcxproj.filters
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{ec5fabec-814c-4ffb-8d23-25aec8708380}</UniqueIdentifier>
- <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{cc7db61d-a383-4ede-bcbb-8c23eff3cea6}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{0b124017-fe32-448f-a338-451dbd38ed75}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="AviFile.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="AviSplitter.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="AviSplitterSettingsWnd.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="stdafx.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="AviSplitter.def">
- <Filter>Source Files</Filter>
- </None>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="AviFile.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="AviSplitter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="AviSplitterSettingsWnd.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="IAviSplitterFilter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="resource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="stdafx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="AviSplitter.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/AviSplitter/AviSplitterSettingsWnd.cpp b/src/filters/parser/AviSplitter/AviSplitterSettingsWnd.cpp
deleted file mode 100644
index 975823d58..000000000
--- a/src/filters/parser/AviSplitter/AviSplitterSettingsWnd.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * (C) 2012-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "AviSplitterSettingsWnd.h"
-#include "../../../DSUtil/DSUtil.h"
-#include "resource.h"
-#include "../../../mpc-hc/InternalFiltersConfig.h"
-
-
-CAviSplitterSettingsWnd::CAviSplitterSettingsWnd()
-{
-}
-
-bool CAviSplitterSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
-{
- ASSERT(!m_pASF);
-
- m_pASF.Release();
-
- POSITION pos = pUnks.GetHeadPosition();
- while (pos && !(m_pASF = pUnks.GetNext(pos))) {
- ;
- }
-
- if (!m_pASF) {
- return false;
- }
-
- return true;
-}
-
-void CAviSplitterSettingsWnd::OnDisconnect()
-{
- m_pASF.Release();
-}
-
-bool CAviSplitterSettingsWnd::OnActivate()
-{
- ASSERT(IPP_FONTSIZE == 13);
- const int h20 = IPP_SCALE(20);
- DWORD dwStyle = WS_VISIBLE | WS_CHILD | WS_TABSTOP;
- CPoint p(10, 10);
-
- m_cbNonInterleavedFilesSupport.Create(ResStr(IDS_AVISPLITTER_NON_INTERLEAVED), dwStyle | BS_AUTOCHECKBOX | BS_LEFTTEXT, CRect(p, CSize(IPP_SCALE(260), m_fontheight)), this, IDC_PP_NON_INTERLEAVED_FILES_SUPPORT);
- p.y += h20;
-
- if (m_pASF) {
- m_cbNonInterleavedFilesSupport.SetCheck(m_pASF->GetNonInterleavedFilesSupport());
- }
- m_cbNonInterleavedFilesSupport.EnableWindow(FALSE);
-
- for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
- pWnd->SetFont(&m_font, FALSE);
- }
-
- return true;
-}
-
-void CAviSplitterSettingsWnd::OnDeactivate()
-{
-}
-
-bool CAviSplitterSettingsWnd::OnApply()
-{
- OnDeactivate();
-
- if (m_pASF) {
- m_pASF->SetNonInterleavedFilesSupport(m_cbNonInterleavedFilesSupport.GetCheck());
-
- m_pASF->Apply();
- }
-
- return true;
-}
-
-BEGIN_MESSAGE_MAP(CAviSplitterSettingsWnd, CInternalPropertyPageWnd)
-END_MESSAGE_MAP()
diff --git a/src/filters/parser/AviSplitter/AviSplitterSettingsWnd.h b/src/filters/parser/AviSplitter/AviSplitterSettingsWnd.h
deleted file mode 100644
index b56e93c15..000000000
--- a/src/filters/parser/AviSplitter/AviSplitterSettingsWnd.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * (C) 2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../InternalPropertyPage.h"
-#include "IAviSplitterFilter.h"
-#include "resource.h"
-#include <afxcmn.h>
-
-class __declspec(uuid("A008C72A-0D51-461D-9043-C823B3A7D4CC"))
- CAviSplitterSettingsWnd : public CInternalPropertyPageWnd
-{
-private:
- CComQIPtr<IAviSplitterFilter> m_pASF;
-
- CButton m_cbNonInterleavedFilesSupport;
-
- enum {
- IDC_PP_NON_INTERLEAVED_FILES_SUPPORT = 10000,
- };
-
-public:
- CAviSplitterSettingsWnd();
-
- bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
- void OnDisconnect();
- bool OnActivate();
- void OnDeactivate();
- bool OnApply();
-
- static LPCTSTR GetWindowTitle() { return MAKEINTRESOURCE(IDS_FILTER_SETTINGS_CAPTION); }
- static CSize GetWindowSize() { return CSize(280, 33); }
-
- DECLARE_MESSAGE_MAP()
-};
diff --git a/src/filters/parser/AviSplitter/IAviSplitterFilter.h b/src/filters/parser/AviSplitter/IAviSplitterFilter.h
deleted file mode 100644
index a648d3b42..000000000
--- a/src/filters/parser/AviSplitter/IAviSplitterFilter.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * (C) 2012-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-interface __declspec(uuid("1E41BBCB-F6E0-4A49-91F7-A2AD5B5C7113"))
-IAviSplitterFilter :
-public IUnknown {
- STDMETHOD(Apply()) PURE;
-
- STDMETHOD(SetNonInterleavedFilesSupport(BOOL nValue)) PURE;
- STDMETHOD_(BOOL, GetNonInterleavedFilesSupport()) PURE;
-};
diff --git a/src/filters/parser/AviSplitter/resource.h b/src/filters/parser/AviSplitter/resource.h
deleted file mode 100644
index 6a2c6fabd..000000000
--- a/src/filters/parser/AviSplitter/resource.h
+++ /dev/null
@@ -1,17 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by AviSplitter.rc
-//
-#define IDS_FILTER_SETTINGS_CAPTION 7000
-#define IDS_AVISPLITTER_NON_INTERLEAVED 7100
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 101
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/filters/parser/AviSplitter/stdafx.cpp b/src/filters/parser/AviSplitter/stdafx.cpp
deleted file mode 100644
index 784f2cebc..000000000
--- a/src/filters/parser/AviSplitter/stdafx.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
diff --git a/src/filters/parser/AviSplitter/stdafx.h b/src/filters/parser/AviSplitter/stdafx.h
deleted file mode 100644
index 5b6b09e05..000000000
--- a/src/filters/parser/AviSplitter/stdafx.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../../DSUtil/SharedInclude.h"
-#include "../../../../include/stdafx_common.h"
-#include "../../../../include/stdafx_common_afx.h"
-#include "../../../../include/stdafx_common_dshow.h"
diff --git a/src/filters/parser/FLVSplitter/FLVSplitter.cpp b/src/filters/parser/FLVSplitter/FLVSplitter.cpp
deleted file mode 100644
index 1b16e6c0c..000000000
--- a/src/filters/parser/FLVSplitter/FLVSplitter.cpp
+++ /dev/null
@@ -1,924 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "FLVSplitter.h"
-#include "../../../DSUtil/DSUtil.h"
-
-#ifdef STANDALONE_FILTER
-#include <InitGuid.h>
-#endif
-#include <MMReg.h>
-#include "moreuuids.h"
-
-#define FLV_AUDIODATA 8
-#define FLV_VIDEODATA 9
-#define FLV_SCRIPTDATA 18
-
-#define FLV_AUDIO_PCM 0 // Linear PCM, platform endian
-#define FLV_AUDIO_ADPCM 1 // ADPCM
-#define FLV_AUDIO_MP3 2 // MP3
-#define FLV_AUDIO_PCMLE 3 // Linear PCM, little endian
-#define FLV_AUDIO_NELLY16 4 // Nellymoser 16 kHz mono
-#define FLV_AUDIO_NELLY8 5 // Nellymoser 8 kHz mono
-#define FLV_AUDIO_NELLY 6 // Nellymoser
-// 7 = G.711 A-law logarithmic PCM (reserved)
-// 8 = G.711 mu-law logarithmic PCM (reserved)
-// 9 = reserved
-#define FLV_AUDIO_AAC 10 // AAC
-#define FLV_AUDIO_SPEEX 11 // Speex
-// 14 = MP3 8 kHz (reserved)
-// 15 = Device-specific sound (reserved)
-
-//#define FLV_VIDEO_JPEG 1 // non-standard? need samples
-#define FLV_VIDEO_H263 2 // Sorenson H.263
-#define FLV_VIDEO_SCREEN 3 // Screen video
-#define FLV_VIDEO_VP6 4 // On2 VP6
-#define FLV_VIDEO_VP6A 5 // On2 VP6 with alpha channel
-#define FLV_VIDEO_SCREEN2 6 // Screen video version 2
-#define FLV_VIDEO_AVC 7 // AVC
-
-#ifdef STANDALONE_FILTER
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_FLV},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
-};
-
-const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, 0, nullptr}
-};
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut2[] = {
- {&MEDIATYPE_Video, &MEDIASUBTYPE_NULL},
-};
-
-const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CFLVSplitterFilter), FlvSplitterName, MERIT_NORMAL, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CFLVSourceFilter), FlvSourceName, MERIT_NORMAL, 0, nullptr, CLSID_LegacyAmFilterCategory},
-};
-
-CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CFLVSplitterFilter>, nullptr, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CFLVSourceFilter>, nullptr, &sudFilter[1]},
-};
-
-int g_cTemplates = _countof(g_Templates);
-
-STDAPI DllRegisterServer()
-{
- DeleteRegKey(_T("Media Type\\Extensions\\"), _T(".flv"));
-
- RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_FLV, _T("0,4,,464C5601"), nullptr);
-
- return AMovieDllRegisterServer2(TRUE);
-}
-
-STDAPI DllUnregisterServer()
-{
- UnRegisterSourceFilter(MEDIASUBTYPE_FLV);
-
- return AMovieDllRegisterServer2(FALSE);
-}
-
-#include "../../FilterApp.h"
-
-CFilterApp theApp;
-
-#endif
-
-//
-// CFLVSplitterFilter
-//
-
-CFLVSplitterFilter::CFLVSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("CFLVSplitterFilter"), pUnk, phr, __uuidof(this))
-{
-}
-
-STDMETHODIMP CFLVSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo)
-{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
-
- if (m_pName && m_pName[0] == L'M' && m_pName[1] == L'P' && m_pName[2] == L'C') {
- (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
- wcscpy_s(pInfo->achName, FlvSourceName);
- }
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
-}
-
-bool CFLVSplitterFilter::ReadTag(Tag& t)
-{
- if (m_pFile->GetRemaining() < 15) {
- return false;
- }
-
- t.PreviousTagSize = (UINT32)m_pFile->BitRead(32);
- t.TagType = (BYTE)m_pFile->BitRead(8);
- t.DataSize = (UINT32)m_pFile->BitRead(24);
- t.TimeStamp = (UINT32)m_pFile->BitRead(24);
- t.TimeStamp |= (UINT32)m_pFile->BitRead(8) << 24;
- t.StreamID = (UINT32)m_pFile->BitRead(24);
-
- return m_pFile->GetRemaining() >= t.DataSize;
-}
-
-bool CFLVSplitterFilter::ReadTag(AudioTag& at)
-{
- if (!m_pFile->GetRemaining()) {
- return false;
- }
-
- at.SoundFormat = (BYTE)m_pFile->BitRead(4);
- at.SoundRate = (BYTE)m_pFile->BitRead(2);
- at.SoundSize = (BYTE)m_pFile->BitRead(1);
- at.SoundType = (BYTE)m_pFile->BitRead(1);
-
- return true;
-}
-
-bool CFLVSplitterFilter::ReadTag(VideoTag& vt)
-{
- if (!m_pFile->GetRemaining()) {
- return false;
- }
-
- vt.FrameType = (BYTE)m_pFile->BitRead(4);
- vt.CodecID = (BYTE)m_pFile->BitRead(4);
-
- return true;
-}
-
-#ifndef NOVIDEOTWEAK
-bool CFLVSplitterFilter::ReadTag(VideoTweak& vt)
-{
- if (!m_pFile->GetRemaining()) {
- return false;
- }
-
- vt.x = (BYTE)m_pFile->BitRead(4);
- vt.y = (BYTE)m_pFile->BitRead(4);
-
- return true;
-}
-#endif
-
-bool CFLVSplitterFilter::Sync(__int64& pos)
-{
- m_pFile->Seek(pos);
-
- while (m_pFile->GetRemaining() >= 15) {
- __int64 limit = m_pFile->GetRemaining();
- while (true) {
- BYTE b = (BYTE)m_pFile->BitRead(8);
- if (b == FLV_AUDIODATA || b == FLV_VIDEODATA) {
- break;
- }
- if (--limit < 15) {
- return false;
- }
- }
-
- pos = m_pFile->GetPos() - 5;
- m_pFile->Seek(pos);
-
- Tag ct;
- if (ReadTag(ct)) {
- __int64 next = m_pFile->GetPos() + ct.DataSize;
- if (next == m_pFile->GetLength() - 4) {
- m_pFile->Seek(pos);
- return true;
- } else if (next <= m_pFile->GetLength() - 19) {
- m_pFile->Seek(next);
- Tag nt;
- if (ReadTag(nt) && (nt.TagType == FLV_AUDIODATA || nt.TagType == FLV_VIDEODATA || nt.TagType == FLV_SCRIPTDATA)) {
- if ((nt.PreviousTagSize == ct.DataSize + 11) ||
- (m_IgnorePrevSizes &&
- nt.TimeStamp >= ct.TimeStamp &&
- nt.TimeStamp - ct.TimeStamp <= 1000)) {
- m_pFile->Seek(pos);
- return true;
- }
- }
- }
- }
-
- m_pFile->Seek(pos + 5);
- }
-
- return false;
-}
-
-HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
-{
- CheckPointer(pAsyncReader, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- m_pFile.Free();
- m_pFile.Attach(DEBUG_NEW CBaseSplitterFileEx(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false));
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration = 0;
-
- if (m_pFile->BitRead(24) != 'FLV' || m_pFile->BitRead(8) != 1) {
- return E_FAIL;
- }
-
- EXECUTE_ASSERT(m_pFile->BitRead(5) == 0); // TypeFlagsReserved
- bool fTypeFlagsAudio = !!m_pFile->BitRead(1);
- EXECUTE_ASSERT(m_pFile->BitRead(1) == 0); // TypeFlagsReserved
- bool fTypeFlagsVideo = !!m_pFile->BitRead(1);
- m_DataOffset = (UINT32)m_pFile->BitRead(32);
-
- // doh, these flags aren't always telling the truth
- fTypeFlagsAudio = fTypeFlagsVideo = true;
-
- Tag t;
- AudioTag at;
- VideoTag vt;
-
- UINT32 prevTagSize = 0;
- m_IgnorePrevSizes = false;
-
- m_pFile->Seek(m_DataOffset);
-
- for (int i = 0; ReadTag(t) && (fTypeFlagsVideo || fTypeFlagsAudio); i++) {
- if (!t.DataSize) {
- continue; // skip empty Tag
- }
-
- UINT64 next = m_pFile->GetPos() + t.DataSize;
-
- CStringW name;
-
- CMediaType mt;
- CMediaType ff_mtype;
- mt.SetSampleSize(1);
- mt.subtype = GUID_NULL;
-
- if (i != 0 && t.PreviousTagSize != prevTagSize) {
- m_IgnorePrevSizes = true;
- }
- prevTagSize = t.DataSize + 11;
-
- if (t.TagType == FLV_AUDIODATA && t.DataSize != 0 && fTypeFlagsAudio) {
- UNREFERENCED_PARAMETER(at);
- AudioTag at;
- name = L"Audio";
-
- if (ReadTag(at)) {
- int dataSize = t.DataSize - 1;
-
- fTypeFlagsAudio = false;
-
- mt.majortype = MEDIATYPE_Audio;
- mt.formattype = FORMAT_WaveFormatEx;
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX));
- ZeroMemory(wfe, sizeof(WAVEFORMATEX));
- wfe->nSamplesPerSec = 44100 * (1 << at.SoundRate) / 8;
- wfe->wBitsPerSample = 8 * (at.SoundSize + 1);
- wfe->nChannels = at.SoundType + 1;
-
- switch (at.SoundFormat) {
- case FLV_AUDIO_PCM:
- case FLV_AUDIO_PCMLE:
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_PCM);
- name += L" PCM";
- wfe->nBlockAlign = wfe->wBitsPerSample * wfe->nChannels / 8;
- wfe->nAvgBytesPerSec = wfe->nBlockAlign * wfe->nSamplesPerSec;
- break;
- case FLV_AUDIO_ADPCM:
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_ADPCM_SWF);
- name += L" ADPCM";
- break;
- case FLV_AUDIO_MP3:
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_MPEGLAYER3);
- name += L" MP3";
-
- {
- CBaseSplitterFileEx::mpahdr h;
- CMediaType mt2;
- if (m_pFile->Read(h, 4, false, &mt2)) {
- mt = mt2;
- }
- }
- break;
- case FLV_AUDIO_NELLY16:
- mt.subtype = FOURCCMap(MAKEFOURCC('N', 'E', 'L', 'L'));
- wfe->nSamplesPerSec = 16000;
- name += L" Nellimoser";
- break;
- case FLV_AUDIO_NELLY8:
- mt.subtype = FOURCCMap(MAKEFOURCC('N', 'E', 'L', 'L'));
- wfe->nSamplesPerSec = 8000;
- name += L" Nellimoser";
- break;
- case FLV_AUDIO_NELLY:
- mt.subtype = FOURCCMap(MAKEFOURCC('N', 'E', 'L', 'L'));
- name += L" Nellimoser";
- break;
- case FLV_AUDIO_AAC: {
- if (dataSize < 1 || m_pFile->BitRead(8) != 0) { // packet type 0 == aac header
- fTypeFlagsAudio = true;
- break;
- }
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_AAC);
- name += L" AAC";
-
- __int64 configOffset = m_pFile->GetPos();
- UINT32 configSize = dataSize - 1;
- if (configSize < 2) {
- break;
- }
-
- // Might break depending on the AAC profile, see ff_mpeg4audio_get_config in ffmpeg's mpeg4audio.c
- m_pFile->BitRead(5);
- int iSampleRate = (int)m_pFile->BitRead(4);
- int iChannels = (int)m_pFile->BitRead(4);
- if (iSampleRate > 12 || iChannels > 7) {
- break;
- }
-
- const int sampleRates[] = {
- 96000, 88200, 64000, 48000, 44100, 32000, 24000,
- 22050, 16000, 12000, 11025, 8000, 7350
- };
- const int channels[] = {
- 0, 1, 2, 3, 4, 5, 6, 8
- };
-
- wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX) + configSize);
- ZeroMemory(wfe, mt.FormatLength());
- wfe->nSamplesPerSec = sampleRates[iSampleRate];
- wfe->wBitsPerSample = 16;
- wfe->nChannels = channels[iChannels];
- wfe->cbSize = configSize;
-
- m_pFile->Seek(configOffset);
- m_pFile->ByteRead((BYTE*)(wfe + 1), configSize);
- }
-
- }
- }
- } else if (t.TagType == FLV_VIDEODATA && t.DataSize != 0 && fTypeFlagsVideo) {
- UNREFERENCED_PARAMETER(vt);
- VideoTag vt;
- if (ReadTag(vt) && vt.FrameType == 1) {
- int dataSize = t.DataSize - 1;
-
- fTypeFlagsVideo = false;
- name = L"Video";
-
- mt.majortype = MEDIATYPE_Video;
- mt.formattype = FORMAT_VideoInfo;
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
- ZeroMemory(vih, sizeof(VIDEOINFOHEADER));
-
- BITMAPINFOHEADER* bih = &vih->bmiHeader;
-
- int w, h, arx, ary;
-
- switch (vt.CodecID) {
- case FLV_VIDEO_H263: // H.263
- if (m_pFile->BitRead(17) != 1) {
- break;
- }
-
- m_pFile->BitRead(13); // Version (5), TemporalReference (8)
-
- switch (BYTE PictureSize = (BYTE)m_pFile->BitRead(3)) { // w00t
- case 0:
- case 1:
- vih->bmiHeader.biWidth = (WORD)m_pFile->BitRead(8 * (PictureSize + 1));
- vih->bmiHeader.biHeight = (WORD)m_pFile->BitRead(8 * (PictureSize + 1));
- break;
- case 2:
- case 3:
- case 4:
- vih->bmiHeader.biWidth = 704 / PictureSize;
- vih->bmiHeader.biHeight = 576 / PictureSize;
- break;
- case 5:
- case 6:
- PictureSize -= 3;
- vih->bmiHeader.biWidth = 640 / PictureSize;
- vih->bmiHeader.biHeight = 480 / PictureSize;
- break;
- }
-
- if (!vih->bmiHeader.biWidth || !vih->bmiHeader.biHeight) {
- break;
- }
-
- mt.subtype = FOURCCMap(vih->bmiHeader.biCompression = '1VLF');
- name += L" H.263";
-
- break;
- case FLV_VIDEO_SCREEN: {
- m_pFile->BitRead(4);
- vih->bmiHeader.biWidth = (LONG)m_pFile->BitRead(12);
- m_pFile->BitRead(4);
- vih->bmiHeader.biHeight = (LONG)m_pFile->BitRead(12);
-
- if (!vih->bmiHeader.biWidth || !vih->bmiHeader.biHeight) {
- break;
- }
-
- vih->bmiHeader.biSize = sizeof(vih->bmiHeader);
- vih->bmiHeader.biPlanes = 1;
- vih->bmiHeader.biBitCount = 24;
- vih->bmiHeader.biSizeImage = vih->bmiHeader.biWidth * vih->bmiHeader.biHeight * 3;
-
- mt.subtype = FOURCCMap(vih->bmiHeader.biCompression = '1VSF');
- name += L" Screen";
-
- break;
- }
- case FLV_VIDEO_VP6A: // VP6 with alpha
- m_pFile->BitRead(24);
- case FLV_VIDEO_VP6: { // VP6
-#ifdef NOVIDEOTWEAK
- m_pFile->BitRead(8);
-#else
- VideoTweak fudge;
- ReadTag(fudge);
-#endif
-
- if (m_pFile->BitRead(1)) {
- // Delta (inter) frame
- fTypeFlagsVideo = true;
- break;
- }
- m_pFile->BitRead(6);
- bool fSeparatedCoeff = !!m_pFile->BitRead(1);
- m_pFile->BitRead(5);
- int filterHeader = (int)m_pFile->BitRead(2);
- m_pFile->BitRead(1);
- if (fSeparatedCoeff || !filterHeader) {
- m_pFile->BitRead(16);
- }
-
- h = (int)m_pFile->BitRead(8) * 16;
- w = (int)m_pFile->BitRead(8) * 16;
-
- ary = (int)m_pFile->BitRead(8) * 16;
- arx = (int)m_pFile->BitRead(8) * 16;
-
- if (arx && arx != w || ary && ary != h) {
- VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER2));
- ZeroMemory(vih2, sizeof(VIDEOINFOHEADER2));
- vih2->dwPictAspectRatioX = arx;
- vih2->dwPictAspectRatioY = ary;
- bih = &vih2->bmiHeader;
- mt.formattype = FORMAT_VideoInfo2;
- vih = (VIDEOINFOHEADER*)vih2;
- }
-
- bih->biWidth = w;
- bih->biHeight = h;
-#ifndef NOVIDEOTWEAK
- SetRect(&vih->rcSource, 0, 0, w - fudge.x, h - fudge.y);
- SetRect(&vih->rcTarget, 0, 0, w - fudge.x, h - fudge.y);
-#endif
-
- mt.subtype = FOURCCMap(bih->biCompression = '4VLF');
- name += L" VP6";
-
- break;
- }
- case FLV_VIDEO_AVC: { // H.264
- if (dataSize < 4 || m_pFile->BitRead(8) != 0) { // packet type 0 == avc header
- fTypeFlagsVideo = true;
- break;
- }
- m_pFile->BitRead(24); // composition time
-
- __int64 headerOffset = m_pFile->GetPos();
- UINT32 headerSize = dataSize - 4;
- BYTE* headerData = DEBUG_NEW BYTE[headerSize];
-
- m_pFile->ByteRead(headerData, headerSize);
-
- m_pFile->Seek(headerOffset + 9);
-
- mt.formattype = FORMAT_MPEG2Video;
- MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + headerSize);
- ZeroMemory(vih, mt.FormatLength());
- vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
- vih->hdr.bmiHeader.biPlanes = 1;
- vih->hdr.bmiHeader.biBitCount = 24;
- vih->dwFlags = (headerData[4] & 0x03) + 1; // nal length size
-
- vih->dwProfile = (BYTE)m_pFile->BitRead(8);
- m_pFile->BitRead(8);
- vih->dwLevel = (BYTE)m_pFile->BitRead(8);
- m_pFile->UExpGolombRead(); // seq_parameter_set_id
- UINT64 chroma_format_idc = 0;
- if (vih->dwProfile >= 100) { // high profile
- chroma_format_idc = m_pFile->UExpGolombRead();
- if (chroma_format_idc == 3) { // chroma_format_idc
- m_pFile->BitRead(1); // residue_transform_flag
- }
- m_pFile->UExpGolombRead(); // bit_depth_luma_minus8
- m_pFile->UExpGolombRead(); // bit_depth_chroma_minus8
- m_pFile->BitRead(1); // qpprime_y_zero_transform_bypass_flag
- if (m_pFile->BitRead(1)) { // seq_scaling_matrix_present_flag
- for (int k = 0; k < 8; k++) {
- if (m_pFile->BitRead(1)) { // seq_scaling_list_present_flag
- for (int j = 0, size = (k < 6) ? 16 : 64, next = 8; j < size && next != 0; ++j) {
- next = (next + m_pFile->SExpGolombRead() + 256) & 255;
- }
- }
- }
- }
- }
- m_pFile->UExpGolombRead(); // log2_max_frame_num_minus4
- UINT64 pic_order_cnt_type = m_pFile->UExpGolombRead();
- if (pic_order_cnt_type == 0) {
- m_pFile->UExpGolombRead(); // log2_max_pic_order_cnt_lsb_minus4
- } else if (pic_order_cnt_type == 1) {
- m_pFile->BitRead(1); // delta_pic_order_always_zero_flag
- m_pFile->SExpGolombRead(); // offset_for_non_ref_pic
- m_pFile->SExpGolombRead(); // offset_for_top_to_bottom_field
- UINT64 num_ref_frames_in_pic_order_cnt_cycle = m_pFile->UExpGolombRead();
- for (int k = 0; k < num_ref_frames_in_pic_order_cnt_cycle; k++) {
- m_pFile->SExpGolombRead(); // offset_for_ref_frame[k]
- }
- }
- m_pFile->UExpGolombRead(); // num_ref_frames
- m_pFile->BitRead(1); // gaps_in_frame_num_value_allowed_flag
- UINT64 pic_width_in_mbs_minus1 = m_pFile->UExpGolombRead();
- UINT64 pic_height_in_map_units_minus1 = m_pFile->UExpGolombRead();
- BYTE frame_mbs_only_flag = (BYTE)m_pFile->BitRead(1);
- if (!frame_mbs_only_flag) {
- m_pFile->BitRead(1); // mb_adaptive_frame_field_flag
- }
- m_pFile->BitRead(1); // direct_8x8_inference_flag
- BYTE crop = (BYTE)m_pFile->BitRead(1); // frame_cropping_flag
- unsigned int crop_left = 0;
- unsigned int crop_right = 0;
- unsigned int crop_top = 0;
- unsigned int crop_bottom = 0;
-
- if (crop) {
- crop_left = (unsigned int)m_pFile->UExpGolombRead(); // frame_cropping_rect_left_offset
- crop_right = (unsigned int)m_pFile->UExpGolombRead(); // frame_cropping_rect_right_offset
- crop_top = (unsigned int)m_pFile->UExpGolombRead(); // frame_cropping_rect_top_offset
- crop_bottom = (unsigned int)m_pFile->UExpGolombRead(); // frame_cropping_rect_bottom_offset
- }
- struct sar {
- WORD num;
- WORD den;
- } sar;
-
- if (m_pFile->BitRead(1)) { // vui_parameters_present_flag
- if (m_pFile->BitRead(1)) { // aspect_ratio_info_present_flag
- BYTE aspect_ratio_idc = (BYTE)m_pFile->BitRead(8); // aspect_ratio_idc
- if (255 == aspect_ratio_idc) {
- sar.num = (WORD)m_pFile->BitRead(16); // sar_width
- sar.den = (WORD)m_pFile->BitRead(16); // sar_height
- } else if (aspect_ratio_idc < 17) {
- sar.num = pixel_aspect[aspect_ratio_idc][0];
- sar.den = pixel_aspect[aspect_ratio_idc][1];
- } else {
- return E_FAIL;
- }
- } else {
- sar.num = 1;
- sar.den = 1;
- }
- }
- unsigned int mb_Width = (unsigned int)pic_width_in_mbs_minus1 + 1;
- unsigned int mb_Height = ((unsigned int)pic_height_in_map_units_minus1 + 1) * (2 - frame_mbs_only_flag);
- BYTE CHROMA444 = (chroma_format_idc == 3);
-
- unsigned int Width, Height;
- Width = 16 * mb_Width - (2u >> CHROMA444) * min(crop_right, (8u << CHROMA444) - 1);
- if (frame_mbs_only_flag) {
- Height = 16 * mb_Height - (2u >> CHROMA444) * min(crop_bottom, (8u << CHROMA444) - 1);
- } else {
- Height = 16 * mb_Height - (4u >> CHROMA444) * min(crop_bottom, (8u << CHROMA444) - 1);
- }
- if (!sar.num) {
- sar.num = 1;
- }
- if (!sar.den) {
- sar.den = 1;
- }
- CSize aspect(Width * sar.num, Height * sar.den);
- int gcd = GCD(aspect.cx, aspect.cy);
- if (gcd > 1) {
- aspect.cx /= gcd;
- aspect.cy /= gcd;
- }
-
- vih->hdr.dwPictAspectRatioX = aspect.cx;
- vih->hdr.dwPictAspectRatioY = aspect.cy;
- vih->hdr.bmiHeader.biWidth = Width;
- vih->hdr.bmiHeader.biHeight = Height;
-
- BYTE* src = (BYTE*)headerData + 5;
- BYTE* dst = (BYTE*)vih->dwSequenceHeader;
- BYTE* src_end = (BYTE*)headerData + headerSize;
- BYTE* dst_end = (BYTE*)vih->dwSequenceHeader + headerSize;
- int spsCount = *(src++) & 0x1F;
- int ppsCount = -1;
-
- vih->cbSequenceHeader = 0;
-
- while (src < src_end - 1) {
- if (spsCount == 0 && ppsCount == -1) {
- ppsCount = *(src++);
- continue;
- }
-
- if (spsCount > 0) {
- spsCount--;
- } else if (ppsCount > 0) {
- ppsCount--;
- } else {
- break;
- }
-
- int len = ((src[0] << 8) | src[1]) + 2;
- if (src + len > src_end || dst + len > dst_end) {
- ASSERT(0);
- break;
- }
- memcpy(dst, src, len);
- src += len;
- dst += len;
- vih->cbSequenceHeader += len;
- }
-
- delete [] headerData;
-
- mt.subtype = FOURCCMap(vih->hdr.bmiHeader.biCompression = '1CVA');
- name += L" H.264";
-
- break;
- }
- default:
- fTypeFlagsVideo = true;
- }
- }
- }
-
- if (mt.subtype != GUID_NULL) {
- CAtlArray<CMediaType> mts;
- if (mt.subtype == FOURCCMap(MAKEFOURCC('A', 'S', 'W', 'F'))) {
- mts.InsertAt(0, ff_mtype);
- }
- mts.Add(mt);
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DEBUG_NEW CBaseSplitterOutputPin(mts, name, this, this, &hr));
- EXECUTE_ASSERT(SUCCEEDED(AddOutputPin(t.TagType, pPinOut)));
- }
-
- m_pFile->Seek(next);
- }
-
- if (m_pFile->IsRandomAccess()) {
- __int64 pos = max(m_DataOffset, m_pFile->GetLength() - 256 * 1024);
-
- if (Sync(pos)) {
- Tag t;
- AudioTag at;
- VideoTag vt;
-
- while (ReadTag(t)) {
- UINT64 next = m_pFile->GetPos() + t.DataSize;
-
- if (t.TagType == FLV_AUDIODATA && ReadTag(at) || t.TagType == FLV_VIDEODATA && ReadTag(vt)) {
- m_rtDuration = max(m_rtDuration, 10000i64 * t.TimeStamp);
- }
-
- m_pFile->Seek(next);
- }
- }
- }
-
- m_rtNewStop = m_rtStop = m_rtDuration;
-
- return !m_pOutputs.IsEmpty() ? S_OK : E_FAIL;
-}
-
-bool CFLVSplitterFilter::DemuxInit()
-{
- SetThreadName((DWORD) - 1, "CFLVSplitterFilter");
- return true;
-}
-
-void CFLVSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
-{
- if (!m_rtDuration || rt <= 0) {
- m_pFile->Seek(m_DataOffset);
- } else if (!m_IgnorePrevSizes) {
- NormalSeek(rt);
- } else {
- AlternateSeek(rt);
- }
-}
-
-void CFLVSplitterFilter::NormalSeek(REFERENCE_TIME rt)
-{
- bool fAudio = !!GetOutputPin(FLV_AUDIODATA);
- bool fVideo = !!GetOutputPin(FLV_VIDEODATA);
-
- __int64 pos = m_DataOffset + (__int64)(double(m_pFile->GetLength() - m_DataOffset) * rt / m_rtDuration);
-
- if (!Sync(pos)) {
- ASSERT(0);
- m_pFile->Seek(m_DataOffset);
- return;
- }
-
- Tag t;
- AudioTag at;
- VideoTag vt;
-
- while (ReadTag(t)) {
- if (10000i64 * t.TimeStamp >= rt) {
- m_pFile->Seek(m_pFile->GetPos() - 15);
- break;
- }
-
- m_pFile->Seek(m_pFile->GetPos() + t.DataSize);
- }
-
- while (m_pFile->GetPos() >= m_DataOffset && (fAudio || fVideo) && ReadTag(t)) {
- UINT64 prev = m_pFile->GetPos() - 15 - t.PreviousTagSize - 4;
-
- if (10000i64 * t.TimeStamp <= rt) {
- if (t.TagType == FLV_AUDIODATA && ReadTag(at)) {
- fAudio = false;
- } else if (t.TagType == FLV_VIDEODATA && ReadTag(vt) && vt.FrameType == 1) {
- fVideo = false;
- }
- }
-
- m_pFile->Seek(prev);
- }
-
- if (fAudio || fVideo) {
- ASSERT(0);
- m_pFile->Seek(m_DataOffset);
- }
-}
-
-void CFLVSplitterFilter::AlternateSeek(REFERENCE_TIME rt)
-{
- bool hasAudio = !!GetOutputPin(FLV_AUDIODATA);
- bool hasVideo = !!GetOutputPin(FLV_VIDEODATA);
-
- __int64 estimPos = m_DataOffset + (__int64)(double(m_pFile->GetLength() - m_DataOffset) * rt / m_rtDuration);
-
- while (true) {
- estimPos -= 256 * 1024;
- if (estimPos < m_DataOffset) {
- estimPos = m_DataOffset;
- }
-
- bool foundAudio = !hasAudio;
- bool foundVideo = !hasVideo;
- __int64 bestPos = estimPos;
-
- if (Sync(bestPos)) {
- Tag t;
- AudioTag at;
- VideoTag vt;
-
- while (ReadTag(t) && t.TimeStamp * 10000i64 < rt) {
- __int64 cur = m_pFile->GetPos() - 15;
- __int64 next = cur + 15 + t.DataSize;
-
- if (hasAudio && t.TagType == FLV_AUDIODATA && ReadTag(at)) {
- foundAudio = true;
- if (!hasVideo) {
- bestPos = cur;
- }
- } else if (hasVideo && t.TagType == FLV_VIDEODATA && ReadTag(vt) && vt.FrameType == 1) {
- foundVideo = true;
- bestPos = cur;
- }
-
- m_pFile->Seek(next);
- }
- }
-
- if (foundAudio && foundVideo) {
- m_pFile->Seek(bestPos);
- return;
- } else if (estimPos == m_DataOffset) {
- m_pFile->Seek(m_DataOffset);
- return;
- }
-
- }
-}
-
-bool CFLVSplitterFilter::DemuxLoop()
-{
- HRESULT hr = S_OK;
-
- CAutoPtr<Packet> p;
-
- Tag t;
- AudioTag at = {};
- VideoTag vt = {};
-
- while (SUCCEEDED(hr) && !CheckRequest(nullptr) && m_pFile->GetRemaining()) {
- if (!ReadTag(t)) {
- break;
- }
-
- __int64 next = m_pFile->GetPos() + t.DataSize;
-
- if ((t.DataSize > 0) && (t.TagType == FLV_AUDIODATA && ReadTag(at) || t.TagType == FLV_VIDEODATA && ReadTag(vt))) {
- UINT32 tsOffset = 0;
- if (t.TagType == FLV_VIDEODATA) {
- if (vt.FrameType == 5) {
- goto NextTag; // video info/command frame
- }
- if (vt.CodecID == FLV_VIDEO_VP6) {
- m_pFile->BitRead(8);
- } else if (vt.CodecID == FLV_VIDEO_VP6A) {
- m_pFile->BitRead(32);
- } else if (vt.CodecID == FLV_VIDEO_AVC) {
- if (m_pFile->BitRead(8) != 1) {
- goto NextTag;
- }
- // Tag timestamps specify decode time, this is the display time offset
- tsOffset = (UINT32)m_pFile->BitRead(24);
- tsOffset = (tsOffset + 0xff800000) ^ 0xff800000; // sign extension
- }
- }
- if (t.TagType == FLV_AUDIODATA && at.SoundFormat == FLV_AUDIO_AAC) {
- if (m_pFile->BitRead(8) != 1) {
- goto NextTag;
- }
- }
- __int64 dataSize = next - m_pFile->GetPos();
- if (dataSize <= 0) {
- goto NextTag;
- }
- p.Attach(DEBUG_NEW Packet());
- p->TrackNumber = t.TagType;
- p->rtStart = 10000i64 * (t.TimeStamp + tsOffset);
- p->rtStop = p->rtStart + 1;
- p->bSyncPoint = t.TagType == FLV_VIDEODATA ? vt.FrameType == 1 : true;
- p->SetCount((size_t)dataSize);
- m_pFile->ByteRead(p->GetData(), p->GetCount());
- hr = DeliverPacket(p);
- }
-
-NextTag:
- m_pFile->Seek(next);
- }
-
- return true;
-}
-
-//
-// CFLVSourceFilter
-//
-
-CFLVSourceFilter::CFLVSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CFLVSplitterFilter(pUnk, phr)
-{
- m_clsid = __uuidof(this);
- m_pInput.Free();
-}
diff --git a/src/filters/parser/FLVSplitter/FLVSplitter.def b/src/filters/parser/FLVSplitter/FLVSplitter.def
deleted file mode 100644
index 6492e5cd6..000000000
--- a/src/filters/parser/FLVSplitter/FLVSplitter.def
+++ /dev/null
@@ -1,5 +0,0 @@
-EXPORTS
- DllCanUnloadNow PRIVATE
- DllGetClassObject PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
diff --git a/src/filters/parser/FLVSplitter/FLVSplitter.h b/src/filters/parser/FLVSplitter/FLVSplitter.h
deleted file mode 100644
index 7401c297b..000000000
--- a/src/filters/parser/FLVSplitter/FLVSplitter.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <atlcoll.h>
-#include "../BaseSplitter/BaseSplitter.h"
-#include "../../transform/BaseVideoFilter/BaseVideoFilter.h"
-
-#define FlvSplitterName L"MPC FLV Splitter"
-#define FlvSourceName L"MPC FLV Source"
-
-class __declspec(uuid("47E792CF-0BBE-4F7A-859C-194B0768650A"))
- CFLVSplitterFilter : public CBaseSplitterFilter
-{
- UINT32 m_DataOffset;
- bool m_IgnorePrevSizes;
-
- bool Sync(__int64& pos);
-
- struct VideoTweak {
- BYTE x;
- BYTE y;
- };
-
- bool ReadTag(VideoTweak& t);
-
- struct Tag {
- UINT32 PreviousTagSize;
- BYTE TagType;
- UINT32 DataSize;
- UINT32 TimeStamp;
- UINT32 StreamID;
- };
-
- bool ReadTag(Tag& t);
-
- struct AudioTag {
- BYTE SoundFormat;
- BYTE SoundRate;
- BYTE SoundSize;
- BYTE SoundType;
- };
-
- bool ReadTag(AudioTag& at);
-
- struct VideoTag {
- BYTE FrameType;
- BYTE CodecID;
- };
-
- bool ReadTag(VideoTag& vt);
-
- void NormalSeek(REFERENCE_TIME rt);
- void AlternateSeek(REFERENCE_TIME rt);
-
-protected:
- CAutoPtr<CBaseSplitterFileEx> m_pFile;
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
-
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
-
-public:
- CFLVSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
-
- // CBaseFilter
- STDMETHODIMP_(HRESULT) QueryFilterInfo(FILTER_INFO* pInfo);
-
-};
-
-class __declspec(uuid("C9ECE7B3-1D8E-41F5-9F24-B255DF16C087"))
- CFLVSourceFilter : public CFLVSplitterFilter
-{
-public:
- CFLVSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
-};
diff --git a/src/filters/parser/FLVSplitter/FLVSplitter.rc b/src/filters/parser/FLVSplitter/FLVSplitter.rc
deleted file mode 100644
index d0ebc17cb..000000000
--- a/src/filters/parser/FLVSplitter/FLVSplitter.rc
+++ /dev/null
@@ -1,102 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-#include "version.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (United States) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION MPC_VERSION_NUM
- PRODUCTVERSION MPC_VERSION_NUM
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS VOS_NT_WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE VFT2_UNKNOWN
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", MPC_VERSION_COMMENTS
- VALUE "CompanyName", MPC_COMP_NAME_STR
- VALUE "FileDescription", "FLV Splitter"
- VALUE "FileVersion", MPC_VERSION_STR_FULL
- VALUE "InternalName", "FLV Splitter"
- VALUE "LegalCopyright", MPC_COPYRIGHT_STR
- VALUE "OriginalFilename", "FLVSplitter.ax"
- VALUE "ProductName", "FLV Splitter"
- VALUE "ProductVersion", MPC_VERSION_STR_FULL
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // English (United States) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/src/filters/parser/FLVSplitter/FLVSplitter.vcxproj b/src/filters/parser/FLVSplitter/FLVSplitter.vcxproj
deleted file mode 100644
index 9987fd621..000000000
--- a/src/filters/parser/FLVSplitter/FLVSplitter.vcxproj
+++ /dev/null
@@ -1,256 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug Filter|Win32">
- <Configuration>Debug Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug Filter|x64">
- <Configuration>Debug Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|Win32">
- <Configuration>Release Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|x64">
- <Configuration>Release Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{E62223EF-8263-41EB-8174-CD78BBEEF368}</ProjectGuid>
- <RootNamespace>FLVSplitter</RootNamespace>
- <Keyword>MFCProj</Keyword>
- <ProjectName>FLVSplitter</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <Import Project="..\..\..\platform.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">.ax</TargetExt>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>FLVSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>FLVSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>FLVSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>FLVSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="FLVSplitter.cpp" />
- <ClCompile Include="stdafx.cpp">
- <PrecompiledHeader>Create</PrecompiledHeader>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="FLVSplitter.def" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="FLVSplitter.h" />
- <ClInclude Include="resource.h">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ClInclude>
- <ClInclude Include="stdafx.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="FLVSplitter.rc">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ResourceCompile>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\DSUtil\DSUtil.vcxproj">
- <Project>{fc70988b-1ae5-4381-866d-4f405e28ac42}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\Kasumi\Kasumi.vcxproj">
- <Project>{0d252872-7542-4232-8d02-53f9182aee15}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\system\system.vcxproj">
- <Project>{c2082189-3ecb-4079-91fa-89d3c8a305c0}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\BaseClasses\BaseClasses.vcxproj">
- <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\Filters.vcxproj">
- <Project>{273b3149-3192-4b75-a791-470320b90812}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\transform\BaseVideoFilter\BaseVideoFilter.vcxproj">
- <Project>{54dda60f-e528-4d07-a152-960a1e818680}</Project>
- </ProjectReference>
- <ProjectReference Include="..\BaseSplitter\BaseSplitter.vcxproj">
- <Project>{37768b3f-89bc-4c16-b2a8-767c5da84c3f}</Project>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/FLVSplitter/FLVSplitter.vcxproj.filters b/src/filters/parser/FLVSplitter/FLVSplitter.vcxproj.filters
deleted file mode 100644
index 6d767d024..000000000
--- a/src/filters/parser/FLVSplitter/FLVSplitter.vcxproj.filters
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{97226fda-bc54-4e0c-aa74-af0bce156234}</UniqueIdentifier>
- <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{5c741c80-ab9b-4610-9718-d8f53ffa5718}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{a046237a-5cf9-45be-a5d4-c55690bd66c6}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="FLVSplitter.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="stdafx.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="FLVSplitter.def">
- <Filter>Source Files</Filter>
- </None>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="FLVSplitter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="resource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="stdafx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="FLVSplitter.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/FLVSplitter/resource.h b/src/filters/parser/FLVSplitter/resource.h
deleted file mode 100644
index cf17d77a9..000000000
--- a/src/filters/parser/FLVSplitter/resource.h
+++ /dev/null
@@ -1,14 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by FLVSplitter.rc
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 101
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/filters/parser/FLVSplitter/stdafx.cpp b/src/filters/parser/FLVSplitter/stdafx.cpp
deleted file mode 100644
index 784f2cebc..000000000
--- a/src/filters/parser/FLVSplitter/stdafx.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
diff --git a/src/filters/parser/FLVSplitter/stdafx.h b/src/filters/parser/FLVSplitter/stdafx.h
deleted file mode 100644
index 5b6b09e05..000000000
--- a/src/filters/parser/FLVSplitter/stdafx.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../../DSUtil/SharedInclude.h"
-#include "../../../../include/stdafx_common.h"
-#include "../../../../include/stdafx_common_afx.h"
-#include "../../../../include/stdafx_common_dshow.h"
diff --git a/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp b/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp
deleted file mode 100644
index afbb51d29..000000000
--- a/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "Ap4AsyncReaderStream.h"
-
-AP4_AsyncReaderStream::AP4_AsyncReaderStream(CBaseSplitterFile* pFile)
- : m_refs(1)
- , m_pFile(pFile)
-{
- ASSERT(pFile);
-}
-
-AP4_AsyncReaderStream::~AP4_AsyncReaderStream()
-{
- ASSERT(m_refs == 0);
-}
-
-void AP4_AsyncReaderStream::AddReference()
-{
- ASSERT(m_refs > 0);
- ++m_refs;
-}
-
-void AP4_AsyncReaderStream::Release()
-{
- ASSERT(m_refs > 0);
- if (--m_refs == 0) {
- delete this;
- }
-}
-
-AP4_Result AP4_AsyncReaderStream::Read(void* buffer, AP4_Size bytesToRead, AP4_Size* bytesRead)
-{
- __int64 bytesAvail = m_pFile->GetRemaining();
-
- if (bytesAvail < (__int64)bytesToRead) {
- if (bytesRead) {
- *bytesRead = bytesAvail;
- }
- bytesToRead = bytesAvail;
- }
-
- if (bytesAvail == 0) {
- return AP4_ERROR_EOS;
- }
-
- if (FAILED(m_pFile->ByteRead((BYTE*)buffer, bytesToRead))) {
- if (bytesRead) {
- *bytesRead = 0;
- }
- return AP4_ERROR_READ_FAILED;
- }
-
- if (bytesRead) {
- *bytesRead = bytesToRead;
- }
-
- return AP4_SUCCESS;
-}
-
-AP4_Result AP4_AsyncReaderStream::Write(const void* buffer, AP4_Size bytesToWrite, AP4_Size* bytesWritten)
-{
- return AP4_ERROR_WRITE_FAILED;
-}
-
-AP4_Result AP4_AsyncReaderStream::Seek(AP4_Offset offset)
-{
- m_pFile->Seek(offset);
- return m_pFile->GetPos() == offset ? AP4_SUCCESS : AP4_FAILURE;
-}
-
-AP4_Result AP4_AsyncReaderStream::Tell(AP4_Offset& offset)
-{
- offset = (AP4_Offset)m_pFile->GetPos();
- return AP4_SUCCESS;
-}
-
-AP4_Result AP4_AsyncReaderStream::GetSize(AP4_Size& size)
-{
- size = (AP4_Size)m_pFile->GetLength();
- return AP4_SUCCESS;
-}
diff --git a/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.h b/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.h
deleted file mode 100644
index 66c1835f7..000000000
--- a/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../BaseSplitter/BaseSplitter.h"
-
-#include "Ap4.h"
-#include "Ap4File.h"
-#include "Ap4ByteStream.h"
-
-class AP4_AsyncReaderStream : public AP4_ByteStream
-{
- int m_refs;
- CBaseSplitterFile* m_pFile;
-
-public:
- AP4_AsyncReaderStream(CBaseSplitterFile* pFile);
- virtual ~AP4_AsyncReaderStream();
-
- void AddReference();
- void Release();
-
- AP4_Result Read(void* buffer, AP4_Size bytesToRead, AP4_Size* bytesRead);
- AP4_Result Write(const void* buffer, AP4_Size bytesToWrite, AP4_Size* bytesWritten);
- AP4_Result Seek(AP4_Offset offset);
- AP4_Result Tell(AP4_Offset& offset);
- AP4_Result GetSize(AP4_Size& size);
-};
diff --git a/src/filters/parser/MP4Splitter/MP4Splitter.cpp b/src/filters/parser/MP4Splitter/MP4Splitter.cpp
deleted file mode 100644
index dd1d7bb8f..000000000
--- a/src/filters/parser/MP4Splitter/MP4Splitter.cpp
+++ /dev/null
@@ -1,2114 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <MMreg.h>
-#include "MP4Splitter.h"
-#include "../../../DSUtil/GolombBuffer.h"
-#include "../../../DSUtil/AudioParser.h"
-
-#ifdef STANDALONE_FILTER
-#include <InitGuid.h>
-#endif
-#include "moreuuids.h"
-
-#include "Ap4.h"
-#include "Ap4File.h"
-#include "Ap4StssAtom.h"
-#include "Ap4StsdAtom.h"
-#include "Ap4IsmaCryp.h"
-#include "Ap4AvcCAtom.h"
-#include "Ap4ChplAtom.h"
-#include "Ap4FtabAtom.h"
-#include "Ap4DataAtom.h"
-#include "Ap4PaspAtom.h"
-
-#ifdef STANDALONE_FILTER
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_MP4},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
-};
-
-const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, 0, nullptr}
-};
-
-const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CMP4SplitterFilter), MP4SplitterName, MERIT_NORMAL, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CMP4SourceFilter), MP4SourceName, MERIT_NORMAL, 0, nullptr, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CMPEG4VideoSplitterFilter), L"MPC MPEG4 Video Splitter", MERIT_NORMAL, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CMPEG4VideoSourceFilter), L"MPC MPEG4 Video Source", MERIT_NORMAL, 0, nullptr, CLSID_LegacyAmFilterCategory},
-};
-
-CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMP4SplitterFilter>, nullptr, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CMP4SourceFilter>, nullptr, &sudFilter[1]},
- {sudFilter[2].strName, sudFilter[2].clsID, CreateInstance<CMPEG4VideoSplitterFilter>, nullptr, &sudFilter[2]},
- {sudFilter[3].strName, sudFilter[3].clsID, CreateInstance<CMPEG4VideoSourceFilter>, nullptr, &sudFilter[3]},
-};
-
-int g_cTemplates = _countof(g_Templates);
-
-STDAPI DllRegisterServer()
-{
- DeleteRegKey(_T("Media Type\\Extensions\\"), _T(".mp4"));
- DeleteRegKey(_T("Media Type\\Extensions\\"), _T(".mov"));
-
- CAtlList<CString> chkbytes;
-
- // mp4
- chkbytes.AddTail(_T("4,4,,66747970")); // ftyp
- chkbytes.AddTail(_T("4,4,,6d6f6f76")); // moov
- chkbytes.AddTail(_T("4,4,,6d646174")); // mdat
- chkbytes.AddTail(_T("4,4,,736b6970")); // skip
- chkbytes.AddTail(_T("4,12,ffffffff00000000ffffffff,77696465027fe3706d646174")); // wide ? mdat
-
- // mpeg4 video
- chkbytes.AddTail(_T("3,3,,000001"));
-
- RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_MP4, chkbytes, nullptr);
-
- return AMovieDllRegisterServer2(TRUE);
-}
-
-STDAPI DllUnregisterServer()
-{
- UnRegisterSourceFilter(MEDIASUBTYPE_MP4);
-
- return AMovieDllRegisterServer2(FALSE);
-}
-
-#include "../../FilterApp.h"
-
-CFilterApp theApp;
-
-#endif
-
-struct SSACharacter {
- CString pre, post;
- WCHAR c;
-};
-
-static CStringW ConvertTX3GToSSA(
- CStringW str,
- const AP4_Tx3gSampleEntry::AP4_Tx3gDescription& desc,
- CStringW font,
- const AP4_Byte* mods,
- int size,
- CSize framesize,
- CPoint translation,
- int durationms,
- CRect& rbox)
-{
- int str_len = str.GetLength();
-
- SSACharacter* chars = DEBUG_NEW SSACharacter[str_len];
- for (int i = 0; i < str_len; ++i) {
- chars[i].c = str[i];
- }
- str.Empty();
-
- //
-
- rbox.SetRect(desc.TextBox.Left, desc.TextBox.Top, desc.TextBox.Right, desc.TextBox.Bottom);
-
- int align = 2;
- signed char h = (signed char)desc.HorizontalJustification;
- signed char v = (signed char)desc.VerticalJustification;
- if (h == 0 && v < 0) {
- align = 1;
- } else if (h > 0 && v < 0) {
- align = 2;
- } else if (h < 0 && v < 0) {
- align = 3;
- } else if (h == 0 && v > 0) {
- align = 4;
- } else if (h > 0 && v > 0) {
- align = 5;
- } else if (h < 0 && v > 0) {
- align = 6;
- } else if (h == 0 && v == 0) {
- align = 7;
- } else if (h > 0 && v == 0) {
- align = 8;
- } else if (h < 0 && v == 0) {
- align = 9;
- }
- str.Format(L"{\\an%d}%s", align, CStringW(str));
-
- if (!font.CompareNoCase(L"serif")) {
- font = L"Times New Roman";
- } else if (!font.CompareNoCase(L"sans-serif")) {
- font = L"Arial";
- } else if (!font.CompareNoCase(L"monospace")) {
- font = L"Courier New";
- }
- str.Format(L"{\\fn%s}%s", font, CStringW(str));
-
- const AP4_Byte* fclr = (const AP4_Byte*)&desc.Style.Font.Color;
-
- CStringW font_color;
- font_color.Format(L"{\\1c%02x%02x%02x\\1a%02x}", fclr[2], fclr[1], fclr[0], 255 - fclr[3]);
- str = font_color + str;
-
- str.Format(L"%s{\\2c%02x%02x%02x\\2a%02x}", CString(str), fclr[2], fclr[1], fclr[0], 255 - fclr[3]);
-
- CStringW font_size;
- font_size.Format(L"{\\fs%u}", desc.Style.Font.Size);
- str = font_size + str;
-
- CStringW font_flags;
- font_flags.Format(L"{\\b%d\\i%d\\u%d}",
- (desc.Style.Font.Face & 1) ? 1 : 0,
- (desc.Style.Font.Face & 2) ? 1 : 0,
- (desc.Style.Font.Face & 4) ? 1 : 0);
- str = font_flags + str;
-
- //
-
- const AP4_Byte* hclr = (const AP4_Byte*)&desc.BackgroundColor;
-
- while (size > 8) {
- DWORD tag_size = (mods[0] << 24) | (mods[1] << 16) | (mods[2] << 8) | (mods[3]);
- mods += 4;
- DWORD tag = (mods[0] << 24) | (mods[1] << 16) | (mods[2] << 8) | (mods[3]);
- mods += 4;
-
- size -= tag_size;
- tag_size -= 8;
- const AP4_Byte* next = mods + tag_size;
-
- if (tag == 'styl') {
- WORD styl_count = (mods[0] << 8) | (mods[1]);
- mods += 2;
-
- while (styl_count-- > 0) {
- WORD start = (mods[0] << 8) | (mods[1]);
- mods += 2;
- WORD end = (mods[0] << 8) | (mods[1]);
- mods += 2;
- WORD font_id = (mods[0] << 8) | (mods[1]);
- mods += 2;
- WORD flags = mods[0];
- mods += 1;
- WORD size = mods[0];
- mods += 1;
- const AP4_Byte* color = mods;
- mods += 4;
-
- if (end > str_len) {
- end = str_len;
- }
-
- if (start < end) {
- CStringW s;
-
- s.Format(L"{\\1c%02x%02x%02x\\1a%02x}", color[2], color[1], color[0], 255 - color[3]);
- chars[start].pre += s;
- chars[end - 1].post += font_color;
-
- s.Format(L"{\\fs%u}", size);
- chars[start].pre += s;
- chars[end - 1].post += font_size;
-
- s.Format(L"{\\b%d\\i%d\\u%d}", (flags & 1) ? 1 : 0, (flags & 2) ? 1 : 0, (flags & 4) ? 1 : 0);
- chars[start].pre += s;
- chars[end - 1].post += font_flags;
- }
- }
- } else if (tag == 'hclr') {
- hclr = mods;
- } else if (tag == 'hlit') {
- WORD start = (mods[0] << 8) | (mods[1]);
- mods += 2;
- WORD end = (mods[0] << 8) | (mods[1]);
- mods += 2;
-
- if (end > str_len) {
- end = str_len;
- }
-
- if (start < end) {
- CStringW s;
-
- s.Format(L"{\\3c%02x%02x%02x\\3a%02x}", hclr[2], hclr[1], hclr[0], 255 - hclr[3]);
- chars[start].pre += s;
- chars[end - 1].post += font_color;
-
- chars[start].pre += L"{\\bord0.1}";
- chars[end - 1].post += L"{\\bord}";
- }
- } else if (tag == 'blnk') {
- WORD start = (mods[0] << 8) | (mods[1]);
- mods += 2;
- WORD end = (mods[0] << 8) | (mods[1]);
- mods += 2;
-
- if (end > str_len) {
- end = str_len;
- }
-
- if (start < end) {
- // cheap...
-
- for (int i = 0, alpha = 255; i < durationms; i += 750, alpha = 255 - alpha) {
- CStringW s;
- s.Format(L"{\\t(%d, %d, \\alpha&H%02x&)}", i, i + 750, alpha);
- chars[start].pre += s;
- }
-
- chars[end - 1].post += L"{\\alpha}";
- }
- } else if (tag == 'tbox') {
- rbox.top = (mods[0] << 8) | (mods[1]);
- mods += 2;
- rbox.left = (mods[0] << 8) | (mods[1]);
- mods += 2;
- rbox.bottom = (mods[0] << 8) | (mods[1]);
- mods += 2;
- rbox.right = (mods[0] << 8) | (mods[1]);
- mods += 2;
- } else if (tag == 'krok' && !(desc.DisplayFlags & 0x800)) {
- DWORD start_time = (mods[0] << 24) | (mods[1] << 16) | (mods[2] << 8) | (mods[3]);
- mods += 4;
- WORD krok_count = (mods[0] << 8) | (mods[1]);
- mods += 2;
-
- while (krok_count-- > 0) {
- DWORD end_time = (mods[0] << 24) | (mods[1] << 16) | (mods[2] << 8) | (mods[3]);
- mods += 4;
- WORD start = (mods[0] << 8) | (mods[1]);
- mods += 2;
- WORD end = (mods[0] << 8) | (mods[1]);
- mods += 2;
-
- if (end > str_len) {
- end = str_len;
- }
-
- if (start < end) {
- CStringW s;
-
- s.Format(L"{\\kt%u\\kf%u}", start_time / 10, (end_time - start_time) / 10);
- chars[start].pre += s;
- s.Format(L"{\\1c%02x%02x%02x\\1a%02x}", hclr[2], hclr[1], hclr[0], 255 - hclr[3]);
- chars[start].pre += s;
- chars[end - 1].post += L"{\\kt}" + font_color;
- }
-
- start_time = end_time;
- }
- }
-
- mods = next;
- }
-
- // continous karaoke
-
- if (desc.DisplayFlags & 0x800) {
- CStringW s;
-
- s.Format(L"{\\1c%02x%02x%02x\\1a%02x}", hclr[2], hclr[1], hclr[0], 255 - hclr[3]);
- str += s;
-
- int breaks = 0;
-
- for (int i = 0, j = 0; i <= str_len; ++i) {
- if (chars[i].c == '\n' /*|| chars[i].c == ' '*/) {
- ++breaks;
- }
- }
-
- if (str_len > breaks) {
- float dur = (float)max(durationms - 500, 0) / 10;
-
- for (int i = 0, j = 0; i <= str_len; ++i) {
- if (i == str_len || chars[i].c == '\n' /*|| chars[i].c == ' '*/) {
- s.Format(L"{\\kf%d}", (int)(dur * (i - j) / (str_len - breaks)));
- chars[j].pre += s;
- j = i + 1;
- }
- }
- }
- }
-
- //
-
- for (int i = 0; i < str_len; ++i) {
- str += chars[i].pre;
- str += chars[i].c;
- if (desc.DisplayFlags & 0x20000) {
- str += L"\\N";
- }
- str += chars[i].post;
- }
-
- delete [] chars;
-
- //
-
- if (rbox.IsRectEmpty()) {
- rbox.SetRect(0, 0, framesize.cx, framesize.cy);
- }
- rbox.OffsetRect(translation);
-
- CRect rbox2 = rbox;
- rbox2.DeflateRect(2, 2);
-
- CRect r(0, 0, 0, 0);
- if (rbox2.Height() > 0) {
- r.top = rbox2.top;
- r.bottom = framesize.cy - rbox2.bottom;
- }
- if (rbox2.Width() > 0) {
- r.left = rbox2.left;
- r.right = framesize.cx - rbox2.right;
- }
-
- CStringW hdr;
- hdr.Format(L"0,0,Text,,%d,%d,%d,%d,,{\\clip(%d,%d,%d,%d)}",
- r.left, r.right, r.top, r.bottom,
- rbox.left, rbox.top, rbox.right, rbox.bottom);
-
- //
-
- return hdr + str;
-}
-
-//
-// CMP4SplitterFilter
-//
-
-CMP4SplitterFilter::CMP4SplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("CMP4SplitterFilter"), pUnk, phr, __uuidof(this))
-{
-}
-
-CMP4SplitterFilter::~CMP4SplitterFilter()
-{
-}
-
-STDMETHODIMP CMP4SplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo)
-{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
-
- if (m_pName && m_pName[0] == L'M' && m_pName[1] == L'P' && m_pName[2] == L'C') {
- (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
- wcscpy_s(pInfo->achName, MP4SourceName);
- }
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
-}
-
-void SetTrackName(CString* TrackName, CString Suffix)
-{
- if (TrackName->IsEmpty()) {
- *TrackName = Suffix;
- } else {
- *TrackName += _T(" - ");
- *TrackName += Suffix;
- }
-}
-
-HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
-{
- CheckPointer(pAsyncReader, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- //bool b_HasVideo = false;
-
- m_trackpos.RemoveAll();
-
- m_pFile.Free();
- m_pFile.Attach(DEBUG_NEW CMP4SplitterFile(pAsyncReader, hr));
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration = 0;
- REFERENCE_TIME rtVideoDuration = 0;
-
- m_framesize.SetSize(640, 480);
-
- if (AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie()) {
- // looking for main video track (skip tracks with motionless frames)
- AP4_UI32 mainvideoID = 0;
- for (AP4_List<AP4_Track>::Item* item = movie->GetTracks().FirstItem();
- item;
- item = item->GetNext()) {
- AP4_Track* track = item->GetData();
-
- if (track->GetType() != AP4_Track::TYPE_VIDEO) {
- continue;
- }
- if (!mainvideoID) {
- mainvideoID = track->GetId();
- }
- if (AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
- if (stss->m_Entries.ItemCount() > 0) {
- mainvideoID = track->GetId();
- break;
- }
- }
- }
- // process the tracks
- for (AP4_List<AP4_Track>::Item* item = movie->GetTracks().FirstItem();
- item;
- item = item->GetNext()) {
- AP4_Track* track = item->GetData();
-
- if (track->GetType() != AP4_Track::TYPE_VIDEO
- && track->GetType() != AP4_Track::TYPE_AUDIO
- && track->GetType() != AP4_Track::TYPE_TEXT
- && track->GetType() != AP4_Track::TYPE_SUBP) {
- continue;
- }
-
- //if (b_HasVideo && track->GetType() == AP4_Track::TYPE_VIDEO) {
- if (track->GetType() == AP4_Track::TYPE_VIDEO && track->GetId() != mainvideoID) {
- continue;
- }
-
- AP4_Sample sample;
-
- if (!AP4_SUCCEEDED(track->GetSample(0, sample)) || sample.GetDescriptionIndex() == 0xFFFFFFFF) {
- continue;
- }
-
- CStringW TrackName = UTF8ToStringW(track->GetTrackName().c_str());
- if (TrackName.IsEmpty()) {
- TrackName = LocalToStringW(track->GetTrackName().c_str()); //Trying Local...
- }
- if (TrackName.GetLength() && TrackName[0] < 0x20) {
- TrackName.Delete(0);
- }
- TrackName.Trim();
-
- CStringA TrackLanguage = track->GetTrackLanguage().c_str();
-
- CAtlArray<CMediaType> mts;
-
- CMediaType mt;
- mt.SetSampleSize(1);
-
- VIDEOINFOHEADER* vih = nullptr;
- WAVEFORMATEX* wfe = nullptr;
-
- AP4_DataBuffer empty;
-
- if (AP4_SampleDescription* desc = track->GetSampleDescription(sample.GetDescriptionIndex())) {
- AP4_MpegSampleDescription* mpeg_desc = nullptr;
-
- if (desc->GetType() == AP4_SampleDescription::TYPE_MPEG) {
- mpeg_desc = dynamic_cast<AP4_MpegSampleDescription*>(desc);
- } else if (desc->GetType() == AP4_SampleDescription::TYPE_ISMACRYP) {
- AP4_IsmaCrypSampleDescription* isma_desc = dynamic_cast<AP4_IsmaCrypSampleDescription*>(desc);
- mpeg_desc = isma_desc->GetOriginalSampleDescription();
- }
-
- if (mpeg_desc) {
- CStringW TypeString = CStringW(mpeg_desc->GetObjectTypeString(mpeg_desc->GetObjectTypeId()));
- if ((TypeString.Find(_T("UNKNOWN")) == -1) && (TypeString.Find(_T("INVALID")) == -1)) {
- SetTrackName(&TrackName, TypeString);
- }
- }
-
- if (AP4_MpegVideoSampleDescription* video_desc =
- dynamic_cast<AP4_MpegVideoSampleDescription*>(mpeg_desc)) {
- const AP4_DataBuffer* di = video_desc->GetDecoderInfo();
- if (!di) {
- di = &empty;
- }
-
- LONG biWidth = (LONG)video_desc->GetWidth();
- LONG biHeight = (LONG)video_desc->GetHeight();
-
- if (!biWidth || !biHeight) {
- if (AP4_TkhdAtom* tkhd = dynamic_cast<AP4_TkhdAtom*>(track->GetTrakAtom()->GetChild(AP4_ATOM_TYPE_TKHD))) {
- biWidth = tkhd->GetWidth() >> 16;
- biHeight = tkhd->GetHeight() >> 16;
- }
- }
-
- if (!biWidth || !biHeight) {
- continue;
- }
-
- mt.majortype = MEDIATYPE_Video;
- mt.formattype = FORMAT_VideoInfo;
- vih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + di->GetDataSize());
- ZeroMemory(vih, mt.FormatLength());
- vih->dwBitRate = video_desc->GetAvgBitrate() / 8;
- vih->bmiHeader.biSize = sizeof(vih->bmiHeader);
- vih->bmiHeader.biWidth = biWidth;
- vih->bmiHeader.biHeight = biHeight;
- memcpy(vih + 1, di->GetData(), di->GetDataSize());
-
- switch (video_desc->GetObjectTypeId()) {
- case AP4_MPEG4_VISUAL_OTI:
- mt.subtype = FOURCCMap('v4pm');
- mt.formattype = FORMAT_MPEG2Video;
- {
- MPEG2VIDEOINFO* mvih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + di->GetDataSize());
- ZeroMemory(mvih, mt.FormatLength());
- mvih->hdr.bmiHeader.biSize = sizeof(mvih->hdr.bmiHeader);
- mvih->hdr.bmiHeader.biWidth = biWidth;
- mvih->hdr.bmiHeader.biHeight = biHeight;
- mvih->hdr.bmiHeader.biCompression = 'v4pm';
- mvih->hdr.bmiHeader.biPlanes = 1;
- mvih->hdr.bmiHeader.biBitCount = 24;
- mvih->hdr.dwPictAspectRatioX = mvih->hdr.bmiHeader.biWidth;
- mvih->hdr.dwPictAspectRatioY = mvih->hdr.bmiHeader.biHeight;
- mvih->cbSequenceHeader = di->GetDataSize();
- memcpy(mvih->dwSequenceHeader, di->GetData(), di->GetDataSize());
- mts.Add(mt);
- mt.subtype = FOURCCMap(mvih->hdr.bmiHeader.biCompression = 'V4PM');
- mts.Add(mt);
- //b_HasVideo = true;
- }
- break;
- case AP4_JPEG_OTI:
- mt.subtype = FOURCCMap('gepj');
- mt.formattype = FORMAT_MPEG2Video;
- {
- MPEG2VIDEOINFO* mvih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + di->GetDataSize());
- ZeroMemory(mvih, mt.FormatLength());
- mvih->hdr.bmiHeader.biSize = sizeof(mvih->hdr.bmiHeader);
- mvih->hdr.bmiHeader.biWidth = biWidth;
- mvih->hdr.bmiHeader.biHeight = biHeight;
- mvih->hdr.bmiHeader.biCompression = 'gepj';
- mvih->hdr.bmiHeader.biPlanes = 1;
- mvih->hdr.bmiHeader.biBitCount = 24;
- mvih->hdr.dwPictAspectRatioX = mvih->hdr.bmiHeader.biWidth;
- mvih->hdr.dwPictAspectRatioY = mvih->hdr.bmiHeader.biHeight;
- mvih->cbSequenceHeader = di->GetDataSize();
- memcpy(mvih->dwSequenceHeader, di->GetData(), di->GetDataSize());
- mts.Add(mt);
- //b_HasVideo = true;
- }
- break;
- case AP4_MPEG2_VISUAL_SIMPLE_OTI:
- case AP4_MPEG2_VISUAL_MAIN_OTI:
- case AP4_MPEG2_VISUAL_SNR_OTI:
- case AP4_MPEG2_VISUAL_SPATIAL_OTI:
- case AP4_MPEG2_VISUAL_HIGH_OTI:
- case AP4_MPEG2_VISUAL_422_OTI:
- mt.subtype = MEDIASUBTYPE_MPEG2_VIDEO;
- {
- m_pFile->Seek(sample.GetOffset());
- CBaseSplitterFileEx::seqhdr h;
- CMediaType mt2;
- if (m_pFile->Read(h, sample.GetSize(), &mt2)) {
- mt = mt2;
- }
- }
- mts.Add(mt);
- break;
- case AP4_MPEG1_VISUAL_OTI: // ???
- mt.subtype = MEDIASUBTYPE_MPEG1Payload;
- {
- m_pFile->Seek(sample.GetOffset());
- CBaseSplitterFileEx::seqhdr h;
- CMediaType mt2;
- if (m_pFile->Read(h, sample.GetSize(), &mt2)) {
- mt = mt2;
- }
- }
- mts.Add(mt);
- break;
- }
-
- if (mt.subtype == GUID_NULL) {
- TRACE(_T("Unknown video OBI: %02x\n"), video_desc->GetObjectTypeId());
- }
- } else if (AP4_MpegAudioSampleDescription* audio_desc =
- dynamic_cast<AP4_MpegAudioSampleDescription*>(mpeg_desc)) {
- const AP4_DataBuffer* di = audio_desc->GetDecoderInfo();
- if (!di) {
- di = &empty;
- }
- const BYTE* extdata = di->GetData();
- size_t extsize = di->GetDataSize();
- ASSERT(extsize <= WORD_MAX);
-
- mt.majortype = MEDIATYPE_Audio;
- mt.formattype = FORMAT_WaveFormatEx;
-
- wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX) + di->GetDataSize());
- ZeroMemory(wfe, mt.FormatLength());
- wfe->nSamplesPerSec = audio_desc->GetSampleRate();
- wfe->nAvgBytesPerSec = audio_desc->GetAvgBitrate() / 8;
- wfe->nChannels = audio_desc->GetChannelCount();
- wfe->wBitsPerSample = audio_desc->GetSampleSize();
- wfe->cbSize = (WORD)extsize;
- wfe->nBlockAlign = wfe->nChannels * wfe->wBitsPerSample / 8;
-
- memcpy(wfe + 1, extdata, extsize);
-
- switch (audio_desc->GetObjectTypeId()) {
- case AP4_MPEG4_AUDIO_OTI:
- case AP4_MPEG2_AAC_AUDIO_MAIN_OTI: // ???
- case AP4_MPEG2_AAC_AUDIO_LC_OTI: // ???
- case AP4_MPEG2_AAC_AUDIO_SSRP_OTI: // ???
- if (extsize > 10) {
- if (*(DWORD*)(extdata + 6) == 0x00534c41) { // 'ALS\0' sync word
- wfe->wFormatTag = WAVE_FORMAT_UNKNOWN;
- mt.subtype = FOURCCMap(MAKEFOURCC('A', 'L', 'S', ' ')); // create our own GUID - {20534C41-0000-0010-8000-00AA00389B71}
- mts.Add(mt);
- break;
- }
- }
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_AAC);
- if (extsize >= 2 && wfe->nChannels < 8) {
- WORD channels = (extdata[1] >> 3) & 0xf;
- if (channels) { // not the best solution
- wfe->nChannels = channels;
- wfe->nBlockAlign = channels * wfe->wBitsPerSample / 8;
- }
- }
- mts.Add(mt);
- break;
- case AP4_MPEG2_PART3_AUDIO_OTI: // ???
- case AP4_MPEG1_AUDIO_OTI:
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_MPEGLAYER3);
- {
- m_pFile->Seek(sample.GetOffset());
- CBaseSplitterFileEx::mpahdr h;
- CMediaType mt2;
- if (m_pFile->Read(h, sample.GetSize(), false, &mt2)) {
- mt = mt2;
- }
- }
- mts.Add(mt);
- break;
- case AP4_DTSC_AUDIO_OTI:
- case AP4_DTSH_AUDIO_OTI:
- case AP4_DTSL_AUDIO_OTI:
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_DVD_DTS);
- {
- m_pFile->Seek(sample.GetOffset());
- CBaseSplitterFileEx::dtshdr h;
- CMediaType mt2;
- if (m_pFile->Read(h, sample.GetSize(), &mt2)) {
- mt = mt2;
- }
- }
- mts.Add(mt);
- break;
- }
-
- if (mt.subtype == GUID_NULL) {
- TRACE(_T("Unknown audio OBI: %02x\n"), audio_desc->GetObjectTypeId());
- }
- } else if (AP4_MpegSystemSampleDescription* system_desc =
- dynamic_cast<AP4_MpegSystemSampleDescription*>(desc)) {
- const AP4_DataBuffer* di = system_desc->GetDecoderInfo();
- if (!di) {
- di = &empty;
- }
-
- switch (system_desc->GetObjectTypeId()) {
- case AP4_NERO_VOBSUB:
- if (di->GetDataSize() >= 16 * 4) {
- CSize size(720, 576);
- if (AP4_TkhdAtom* tkhd = dynamic_cast<AP4_TkhdAtom*>(track->GetTrakAtom()->GetChild(AP4_ATOM_TYPE_TKHD))) {
- size.cx = tkhd->GetWidth() >> 16;
- size.cy = tkhd->GetHeight() >> 16;
- }
-
- const AP4_Byte* pal = di->GetData();
- CAtlList<CStringA> sl;
- for (int i = 0; i < 16 * 4; i += 4) {
- BYTE y = (pal[i + 1] - 16) * 255 / 219;
- BYTE u = pal[i + 2];
- BYTE v = pal[i + 3];
- BYTE r = (BYTE)min(max(1.0 * y + 1.4022 * (v - 128), 0), 255);
- BYTE g = (BYTE)min(max(1.0 * y - 0.3456 * (u - 128) - 0.7145 * (v - 128), 0), 255);
- BYTE b = (BYTE)min(max(1.0 * y + 1.7710 * (u - 128), 0) , 255);
- CStringA str;
- str.Format("%02x%02x%02x", r, g, b);
- sl.AddTail(str);
- }
-
- CStringA hdr;
- hdr.Format(
- "# VobSub index file, v7 (do not modify this line!)\n"
- "size: %dx%d\n"
- "palette: %s\n",
- size.cx, size.cy,
- Implode(sl, ','));
-
- mt.majortype = MEDIATYPE_Subtitle;
- mt.subtype = MEDIASUBTYPE_VOBSUB;
- mt.formattype = FORMAT_SubtitleInfo;
- SUBTITLEINFO* si = (SUBTITLEINFO*)mt.AllocFormatBuffer(sizeof(SUBTITLEINFO) + hdr.GetLength());
- ZeroMemory(si, mt.FormatLength());
- si->dwOffset = sizeof(SUBTITLEINFO);
- strcpy_s(si->IsoLang, _countof(si->IsoLang), CStringA(TrackLanguage));
- wcscpy_s(si->TrackName, _countof(si->TrackName), TrackName);
- memcpy(si + 1, (LPCSTR)hdr, hdr.GetLength());
- mts.Add(mt);
- }
- break;
- }
-
- if (mt.subtype == GUID_NULL) {
- TRACE(_T("Unknown audio OBI: %02x\n"), system_desc->GetObjectTypeId());
- }
- } else if (AP4_UnknownSampleDescription* unknown_desc =
- dynamic_cast<AP4_UnknownSampleDescription*>(desc)) { // TEMP
- AP4_SampleEntry* sample_entry = unknown_desc->GetSampleEntry();
-
- if (dynamic_cast<AP4_TextSampleEntry*>(sample_entry)
- || dynamic_cast<AP4_Tx3gSampleEntry*>(sample_entry)) {
- mt.majortype = MEDIATYPE_Subtitle;
- mt.subtype = MEDIASUBTYPE_ASS2;
- mt.formattype = FORMAT_SubtitleInfo;
- CStringA hdr;
- hdr.Format(
- "[Script Info]\n"
- "ScriptType: v4.00++\n"
- "ScaledBorderAndShadow: yes\n"
- "PlayResX: %d\n"
- "PlayResY: %d\n"
- "[V4++ Styles]\n"
- "Style: Text,Arial,12,&H00ffffff,&H0000ffff,&H00000000,&H80000000,0,0,0,0,100,100,0,0.00,3,0,0,2,0,0,0,0,1,1\n",
- // "Style: Text,Arial,12,&H00ffffff,&H0000ffff,&H00000000,&H80000000,0,0,0,0,100,100,0,0.00,1,0,0,2,0,0,0,0,1,1\n",
- m_framesize.cx,
- m_framesize.cy);
- SUBTITLEINFO* si = (SUBTITLEINFO*)mt.AllocFormatBuffer(sizeof(SUBTITLEINFO) + hdr.GetLength());
- ZeroMemory(si, mt.FormatLength());
- si->dwOffset = sizeof(SUBTITLEINFO);
- strcpy_s(si->IsoLang, _countof(si->IsoLang), CStringA(TrackLanguage));
- wcscpy_s(si->TrackName, _countof(si->TrackName), TrackName);
- memcpy(si + 1, (LPCSTR)hdr, hdr.GetLength());
- mts.Add(mt);
- }
- }
- } else if (AP4_Avc1SampleEntry* avc1 = dynamic_cast<AP4_Avc1SampleEntry*>(
- track->GetTrakAtom()->FindChild("mdia/minf/stbl/stsd/avc1"))) {
- if (AP4_AvcCAtom* avcC = dynamic_cast<AP4_AvcCAtom*>(avc1->GetChild(AP4_ATOM_TYPE_AVCC))) {
- SetTrackName(&TrackName, _T("MPEG4 Video (H264)"));
-
- const AP4_DataBuffer* di = avcC->GetDecoderInfo();
- if (!di) {
- di = &empty;
- }
- int num = 1;
- int den = 1;
- if (AP4_PaspAtom* pasp = dynamic_cast<AP4_PaspAtom*>(avc1->GetChild(AP4_ATOM_TYPE_PASP))) {
- num = pasp->GetNum();
- den = pasp->GetDen();
- }
- if (num <= 0 || den <= 0) { // if bad AR
- num = den = 1; // then reset AR
- }
-
- const AP4_Byte* data = di->GetData();
- AP4_Size size = di->GetDataSize();
-
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = FOURCCMap('1cva');
- mt.formattype = FORMAT_MPEG2Video;
-
- MPEG2VIDEOINFO* mvih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + size - 7);
- ZeroMemory(mvih, mt.FormatLength());
- mvih->hdr.bmiHeader.biSize = sizeof(mvih->hdr.bmiHeader);
- mvih->hdr.bmiHeader.biWidth = (LONG)avc1->GetWidth();
- mvih->hdr.bmiHeader.biHeight = (LONG)avc1->GetHeight();
- mvih->hdr.bmiHeader.biCompression = '1cva';
- mvih->hdr.bmiHeader.biPlanes = 1;
- mvih->hdr.bmiHeader.biBitCount = 24;
-
- CSize aspect(mvih->hdr.bmiHeader.biWidth * num, mvih->hdr.bmiHeader.biHeight * den);
- int gcd = GCD(aspect.cx, aspect.cy);
- if (gcd > 1) {
- aspect.cx /= gcd;
- aspect.cy /= gcd;
- }
- mvih->hdr.dwPictAspectRatioX = aspect.cx;
- mvih->hdr.dwPictAspectRatioY = aspect.cy;
- if (item->GetData()->GetSampleCount()) {
- mvih->hdr.AvgTimePerFrame = item->GetData()->GetDurationMs() * 10000 / (item->GetData()->GetSampleCount());
- }
- mvih->dwProfile = data[1];
- mvih->dwLevel = data[3];
- mvih->dwFlags = (data[4] & 3) + 1;
-
- mvih->cbSequenceHeader = 0;
-
- BYTE* src = (BYTE*)data + 5;
- BYTE* dst = (BYTE*)mvih->dwSequenceHeader;
-
- BYTE* src_end = (BYTE*)data + size;
- BYTE* dst_end = (BYTE*)mvih->dwSequenceHeader + size;
-
- for (int i = 0; i < 2; ++i) {
- for (int n = *src++ & 0x1f; n > 0; --n) {
- int len = ((src[0] << 8) | src[1]) + 2;
- if (src + len > src_end || dst + len > dst_end) {
- ASSERT(0);
- break;
- }
- memcpy(dst, src, len);
- src += len;
- dst += len;
- mvih->cbSequenceHeader += len;
- }
- }
-
- mts.Add(mt);
-
- mt.subtype = FOURCCMap(mvih->hdr.bmiHeader.biCompression = '1CVA');
- mts.Add(mt);
- //b_HasVideo = true;
- }
- } else if (AP4_StsdAtom* stsd = dynamic_cast<AP4_StsdAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stsd"))) {
- const AP4_DataBuffer& db = stsd->GetDataBuffer();
-
- int k = 0;
- for (AP4_List<AP4_Atom>::Item* item = stsd->GetChildren().FirstItem();
- item;
- item = item->GetNext(), ++k) {
-
- AP4_Atom* atom = item->GetData();
- AP4_Atom::Type type = atom->GetType();
-
- if (k == 0 && stsd->GetChildren().ItemCount() > 1 && type == AP4_ATOM_TYPE_JPEG) {
- continue; // Multiple fourcc, we skip first JPEG.
- }
-
- DWORD fourcc =
- ((type >> 24) & 0x000000ff) |
- ((type >> 8) & 0x0000ff00) |
- ((type << 8) & 0x00ff0000) |
- ((type << 24) & 0xff000000);
-
- if (AP4_VisualSampleEntry* vse = dynamic_cast<AP4_VisualSampleEntry*>(atom)) {
-
- if (type == AP4_ATOM_TYPE_MJPA || type == AP4_ATOM_TYPE_MJPB || type == AP4_ATOM_TYPE_MJPG) {
- SetTrackName(&TrackName, _T("M-Jpeg"));
- } else if (type == AP4_ATOM_TYPE_RAW) {
- fourcc = BI_RGB;
- }
-
- mt.majortype = MEDIATYPE_Video;
- mt.formattype = FORMAT_VideoInfo;
- vih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + db.GetDataSize());
- ZeroMemory(vih, mt.FormatLength());
- vih->bmiHeader.biSize = sizeof(vih->bmiHeader);
- vih->bmiHeader.biWidth = (LONG)vse->GetWidth();
- vih->bmiHeader.biHeight = (LONG)vse->GetHeight();
- vih->bmiHeader.biCompression = fourcc;
- vih->bmiHeader.biBitCount = (LONG)vse->GetDepth();
- memcpy(vih + 1, db.GetData(), db.GetDataSize());
-
- if (fourcc == BI_RGB) {
- WORD& bitcount = vih->bmiHeader.biBitCount;
- if (bitcount == 16) {
- mt.subtype = MEDIASUBTYPE_RGB555;
- } else if (bitcount == 24) {
- mt.subtype = MEDIASUBTYPE_RGB24;
- } else if (bitcount == 32) {
- mt.subtype = MEDIASUBTYPE_ARGB32;
- } else {
- break;
- }
- mts.Add(mt);
- break;
- }
- mt.subtype = FOURCCMap(fourcc);
- mts.Add(mt);
-
- char buff[5];
- memcpy(buff, &fourcc, 4);
- buff[4] = 0;
-
- _strlwr_s(buff);
- AP4_Atom::Type typelwr = *(AP4_Atom::Type*)buff;
-
- if (typelwr != fourcc) {
- mt.subtype = FOURCCMap(vih->bmiHeader.biCompression = typelwr);
- mts.Add(mt);
- //b_HasVideo = true;
- }
-
- _strupr_s(buff);
- AP4_Atom::Type typeupr = *(AP4_Atom::Type*)buff;
-
- if (typeupr != fourcc) {
- mt.subtype = FOURCCMap(vih->bmiHeader.biCompression = typeupr);
- mts.Add(mt);
- //b_HasVideo = true;
- }
-
- break;
- } else if (AP4_AudioSampleEntry* ase = dynamic_cast<AP4_AudioSampleEntry*>(atom)) {
- DWORD samplerate = ase->GetSampleRate();
- WORD channels = ase->GetChannelCount();
- WORD bitspersample = ase->GetSampleSize();
-
- // overwrite audio fourc
- if ((type & 0xffff0000) == AP4_ATOM_TYPE('m', 's', 0, 0)) {
- fourcc = type & 0xffff;
- } else if (type == AP4_ATOM_TYPE_ALAW) {
- fourcc = WAVE_FORMAT_ALAW;
- SetTrackName(&TrackName, _T("PCM A-law"));
- } else if (type == AP4_ATOM_TYPE_ULAW) {
- fourcc = WAVE_FORMAT_MULAW;
- SetTrackName(&TrackName, _T("PCM mu-law"));
- } else if (type == AP4_ATOM_TYPE__MP3) {
- SetTrackName(&TrackName, _T("MPEG Audio (MP3)"));
- fourcc = WAVE_FORMAT_MPEGLAYER3;
- } else if ((type == AP4_ATOM_TYPE__AC3) || (type == AP4_ATOM_TYPE_SAC3) || (type == AP4_ATOM_TYPE_EAC3)) {
- fourcc = 0x2000;
- if (type != AP4_ATOM_TYPE_EAC3) {
- SetTrackName(&TrackName, _T("AC-3 Audio"));
- } else {
- SetTrackName(&TrackName, _T("Enhanced AC-3 audio"));
- }
- } else if (type == AP4_ATOM_TYPE_MP4A) {
- fourcc = WAVE_FORMAT_AAC;
- SetTrackName(&TrackName, _T("MPEG-2 Audio AAC"));
- } else if (type == AP4_ATOM_TYPE_NMOS) {
- fourcc = MAKEFOURCC('N', 'E', 'L', 'L');
- SetTrackName(&TrackName, _T("NellyMoser Audio"));
- } else if (type == AP4_ATOM_TYPE_ALAC) {
- fourcc = MAKEFOURCC('a', 'l', 'a', 'c');
- SetTrackName(&TrackName, _T("ALAC Audio"));
- } else if ((type == AP4_ATOM_TYPE_NONE || type == AP4_ATOM_TYPE_RAW) && bitspersample == 8 ||
- type == AP4_ATOM_TYPE_SOWT && bitspersample == 16 ||
- (type == AP4_ATOM_TYPE_IN24 || type == AP4_ATOM_TYPE_IN32) && ase->GetEndian() == ENDIAN_LITTLE) {
- fourcc = type = WAVE_FORMAT_PCM;
- } else if ((type == AP4_ATOM_TYPE_FL32 || type == AP4_ATOM_TYPE_FL64) && ase->GetEndian() == ENDIAN_LITTLE) {
- fourcc = type = WAVE_FORMAT_IEEE_FLOAT;
- } else if (type == AP4_ATOM_TYPE_LPCM) {
- DWORD flags = ase->GetFormatSpecificFlags();
- if (flags & 2) { // big endian
- if (flags & 1) { // floating point
- if (bitspersample == 32) {
- type = AP4_ATOM_TYPE_FL32;
- } else if (bitspersample == 64) {
- type = AP4_ATOM_TYPE_FL64;
- }
- } else {
- if (bitspersample == 16) {
- type = AP4_ATOM_TYPE_TWOS;
- } else if (bitspersample == 24) {
- type = AP4_ATOM_TYPE_IN24;
- } else if (bitspersample == 32) {
- type = AP4_ATOM_TYPE_IN32;
- }
- }
- fourcc = ((type >> 24) & 0x000000ff) |
- ((type >> 8) & 0x0000ff00) |
- ((type << 8) & 0x00ff0000) |
- ((type << 24) & 0xff000000);
- } else { // little endian
- if (flags & 1) { // floating point
- fourcc = type = WAVE_FORMAT_IEEE_FLOAT;
- } else {
- fourcc = type = WAVE_FORMAT_PCM;
- }
- }
- }
-
- DWORD nAvgBytesPerSec = 0;
- if (type == AP4_ATOM_TYPE_EAC3) {
-
- AP4_Sample sample;
- AP4_DataBuffer sample_data;
-
- AP4_Cardinal SampleCount = track->GetSampleCount();
- if (SampleCount) {
- track->ReadSample(1, sample, sample_data);
- const AP4_Byte* data = sample_data.GetData();
- AP4_Size size = sample_data.GetDataSize();
-
- CGolombBuffer gb((BYTE*)data, size);
- for (; size >= 7 && gb.BitRead(16, true) != 0x0b77; --size) {
- gb.BitRead(8);
- }
- WORD sync = (WORD)gb.BitRead(16);
- if ((size >= 7) && (sync == 0x0b77)) {
- static DWORD freq[] = {48000, 44100, 32000, 0};
- gb.BitRead(2);
- gb.BitRead(3);
- WORD frame_size = ((WORD)gb.BitRead(11) + 1) << 1;
- BYTE sr_code = (BYTE)gb.BitRead(2);
- if (sr_code == 3) {
- BYTE sr_code2 = (BYTE)gb.BitRead(2);
- samplerate = freq[sr_code2] / 2;
- } else {
- static BYTE eac3_blocks[4] = {1, 2, 3, 6};
- BYTE num_blocks = eac3_blocks[gb.BitRead(2)];
- samplerate = freq[sr_code];
- nAvgBytesPerSec = frame_size * samplerate / (num_blocks * 256);
- }
- BYTE acmod = (BYTE)gb.BitRead(3);
- BYTE lfeon = (BYTE)gb.BitRead(1);
- static WORD channels_tbl[] = {2, 1, 2, 3, 3, 4, 4, 5};
- channels = channels_tbl[acmod] + lfeon;
- }
- }
- }
-
- mt.majortype = MEDIATYPE_Audio;
- mt.formattype = FORMAT_WaveFormatEx;
- wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX));
- ZeroMemory(wfe, mt.FormatLength());
- if (!(fourcc & 0xffff0000)) {
- wfe->wFormatTag = (WORD)fourcc;
- }
- wfe->nSamplesPerSec = samplerate;
- wfe->nChannels = channels;
- wfe->wBitsPerSample = bitspersample;
- wfe->nBlockAlign = ase->GetBytesPerFrame();
- if (nAvgBytesPerSec == 0 && ase->GetSamplesPerPacket() > 0) {
- wfe->nAvgBytesPerSec = wfe->nSamplesPerSec * wfe->nBlockAlign / ase->GetSamplesPerPacket();
- }
-
- mt.subtype = FOURCCMap(fourcc);
-
-
- if (type == AP4_ATOM_TYPE('m', 's', 0x00, 0x02)) {
- const WORD numcoef = 7;
- static ADPCMCOEFSET coef[] = { {256, 0}, {512, -256}, {0, 0}, {192, 64}, {240, 0}, {460, -208}, {392, -232} };
- const ULONG size = sizeof(ADPCMWAVEFORMAT) + (numcoef * sizeof(ADPCMCOEFSET));
- ADPCMWAVEFORMAT* format = (ADPCMWAVEFORMAT*)mt.ReallocFormatBuffer(size);
- if (format != nullptr) {
- format->wfx.wFormatTag = WAVE_FORMAT_ADPCM;
- format->wfx.wBitsPerSample = 4;
- format->wfx.cbSize = (WORD)(size - sizeof(WAVEFORMATEX));
- format->wSamplesPerBlock = format->wfx.nBlockAlign * 2 / format->wfx.nChannels - 12;
- format->wNumCoef = numcoef;
- memcpy(format->aCoef, coef, sizeof(coef));
- }
- } else if (type == AP4_ATOM_TYPE('m', 's', 0x00, 0x11)) {
- IMAADPCMWAVEFORMAT* format = (IMAADPCMWAVEFORMAT*)mt.ReallocFormatBuffer(sizeof(IMAADPCMWAVEFORMAT));
- if (format != nullptr) {
- format->wfx.wFormatTag = WAVE_FORMAT_IMA_ADPCM;
- format->wfx.wBitsPerSample = 4;
- format->wfx.cbSize = (WORD)(sizeof(IMAADPCMWAVEFORMAT) - sizeof(WAVEFORMATEX));
- int X = (format->wfx.nBlockAlign - (4 * format->wfx.nChannels)) * 8;
- int Y = format->wfx.wBitsPerSample * format->wfx.nChannels;
- format->wSamplesPerBlock = (X / Y) + 1;
- }
- } else if (type == AP4_ATOM_TYPE_ALAC) {
- const AP4_Byte* data = db.GetData();
- AP4_Size size = db.GetDataSize();
-
- while (size >= 36) {
- if ((*(DWORD*)(data) == 0x24000000) && (*(DWORD*)(data + 4) == 0x63616c61)) {
- break;
- }
- size--;
- data++;
- }
-
- if (size >= 36) {
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + 36);
- wfe->cbSize = 36;
- memcpy(wfe + 1, data, 36);
- }
- } else if (type == WAVE_FORMAT_PCM) {
- mt.SetSampleSize(wfe->nBlockAlign);
- if (channels > 2 || bitspersample > 16) {
- WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEXTENSIBLE));
- if (wfex != nullptr) {
- wfex->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
- wfex->Format.cbSize = 22;
- wfex->Samples.wValidBitsPerSample = bitspersample;
- wfex->dwChannelMask = GetDefChannelMask(channels); // TODO: get correct channel mask from mov file
- wfex->SubFormat = MEDIASUBTYPE_PCM;
- }
- }
- } else if (type == WAVE_FORMAT_IEEE_FLOAT) {
- mt.SetSampleSize(wfe->nBlockAlign);
- if (channels > 2) {
- WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEXTENSIBLE));
- if (wfex != nullptr) {
- wfex->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
- wfex->Format.cbSize = 22;
- wfex->Samples.wValidBitsPerSample = bitspersample;
- wfex->dwChannelMask = GetDefChannelMask(channels); // TODO: get correct channel mask from mov file
- wfex->SubFormat = MEDIASUBTYPE_IEEE_FLOAT;
- }
- }
- } else if (type == AP4_ATOM_TYPE_MP4A ||
- type == AP4_ATOM_TYPE_ALAW ||
- type == AP4_ATOM_TYPE_ULAW) {
- // not need any extra data for ALAW, ULAW
- // also extra data is not required for IMA4, MAC3, MAC6
- } else if (db.GetDataSize() > 0) {
- //always needed extra data for QDM2
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + db.GetDataSize());
- wfe->cbSize = db.GetDataSize();
- memcpy(wfe + 1, db.GetData(), db.GetDataSize());
- }
-
- mts.Add(mt);
- break;
- } else {
- TRACE(_T("Unknow MP4 Stream %x\n") , fourcc);
- }
- }
- }
-
- if (mts.IsEmpty()) {
- continue;
- }
-
- REFERENCE_TIME rtDuration = 10000i64 * track->GetDurationMs();
- if (m_rtDuration < rtDuration) {
- m_rtDuration = rtDuration;
- }
- if (rtVideoDuration < rtDuration && AP4_Track::TYPE_VIDEO == track->GetType()) {
- rtVideoDuration = rtDuration; // get the max video duration
- }
-
- DWORD id = track->GetId();
-
- CStringW name, lang;
- name.Format(L"Output %u", id);
-
- if (!TrackName.IsEmpty()) {
- name = TrackName;
- }
-
- if (!TrackLanguage.IsEmpty()) {
- if (TrackLanguage != L"und") {
- name += " (" + TrackLanguage + ")";
- }
- }
-
- for (size_t i = 0, j = mts.GetCount(); i < j; ++i) {
- BITMAPINFOHEADER bih;
- if (ExtractBIH(&mts[i], &bih)) {
- m_framesize.cx = bih.biWidth;
- m_framesize.cy = abs(bih.biHeight);
- }
- }
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DEBUG_NEW CMP4SplitterOutputPin(mts, name, this, this, &hr));
-
- if (!TrackName.IsEmpty()) {
- pPinOut->SetProperty(L"NAME", TrackName);
- }
- if (!TrackLanguage.IsEmpty()) {
- pPinOut->SetProperty(L"LANG", CStringW(TrackLanguage));
- }
-
- EXECUTE_ASSERT(SUCCEEDED(AddOutputPin(id, pPinOut)));
-
- m_trackpos[id] = trackpos();
-
- if (mts.GetCount() == 1 && mts[0].subtype == MEDIASUBTYPE_ASS2) {
- LPCWSTR postfix = L" (plain text)";
-
- mts[0].subtype = MEDIASUBTYPE_UTF8;
-
- SUBTITLEINFO* si = (SUBTITLEINFO*)mts[0].ReallocFormatBuffer(sizeof(SUBTITLEINFO));
- wcscat_s(si->TrackName, postfix);
-
- id ^= 0x80402010; // FIXME: until fixing, let's hope there won't be another track like this...
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DEBUG_NEW CMP4SplitterOutputPin(mts, name + postfix, this, this, &hr));
-
- if (!TrackName.IsEmpty()) {
- pPinOut->SetProperty(L"NAME", TrackName + postfix);
- }
- if (!TrackLanguage.IsEmpty()) {
- pPinOut->SetProperty(L"LANG", CStringW(TrackLanguage));
- }
-
- EXECUTE_ASSERT(SUCCEEDED(AddOutputPin(id, pPinOut)));
- }
- }
-
- if (AP4_ChplAtom* chpl = dynamic_cast<AP4_ChplAtom*>(movie->GetMoovAtom()->FindChild("udta/chpl"))) {
- AP4_Array<AP4_ChplAtom::AP4_Chapter>& chapters = chpl->GetChapters();
-
- for (AP4_Cardinal i = 0; i < chapters.ItemCount(); ++i) {
- AP4_ChplAtom::AP4_Chapter& chapter = chapters[i];
- ChapAppend(chapter.Time, UTF8To16(ConvertMBCS(chapter.Name.c_str(), ANSI_CHARSET, CP_UTF8))); // this is b0rked, thx to nero :P
- }
-
- ChapSort();
- }
-
- if (AP4_ContainerAtom* ilst = dynamic_cast<AP4_ContainerAtom*>(movie->GetMoovAtom()->FindChild("udta/meta/ilst"))) {
- CStringW title, artist, writer, album, year, appl, desc, gen, track;
-
- for (AP4_List<AP4_Atom>::Item* item = ilst->GetChildren().FirstItem();
- item;
- item = item->GetNext()) {
- if (AP4_ContainerAtom* atom = dynamic_cast<AP4_ContainerAtom*>(item->GetData())) {
- if (AP4_DataAtom* data = dynamic_cast<AP4_DataAtom*>(atom->GetChild(AP4_ATOM_TYPE_DATA))) {
- const AP4_DataBuffer* db = data->GetData();
-
- if (atom->GetType() == AP4_ATOM_TYPE_TRKN) {
- if (db->GetDataSize() >= 4) {
- unsigned short n = (db->GetData()[2] << 8) | db->GetData()[3];
- if (n > 0 && n < 100) {
- track.Format(L"%02u", n);
- } else if (n >= 100) {
- track.Format(L"%u", n);
- }
- }
- } else {
- CStringW str = UTF8To16(CStringA((LPCSTR)db->GetData(), db->GetDataSize()));
-
- switch (atom->GetType()) {
- case AP4_ATOM_TYPE_NAM:
- title = str;
- break;
- case AP4_ATOM_TYPE_ART:
- artist = str;
- break;
- case AP4_ATOM_TYPE_WRT:
- writer = str;
- break;
- case AP4_ATOM_TYPE_ALB:
- album = str;
- break;
- case AP4_ATOM_TYPE_DAY:
- year = str;
- break;
- case AP4_ATOM_TYPE_TOO:
- appl = str;
- break;
- case AP4_ATOM_TYPE_CMT:
- desc = str;
- break;
- case AP4_ATOM_TYPE_GEN:
- gen = str;
- break;
- }
- }
- }
- }
- }
-
- if (!title.IsEmpty()) {
- if (!track.IsEmpty()) {
- title = track + L" - " + title;
- }
- if (!album.IsEmpty()) {
- title = album + L" - " + title;
- }
- if (!year.IsEmpty()) {
- title += L" - " + year;
- }
- if (!gen.IsEmpty()) {
- title += L" - " + gen;
- }
- SetProperty(L"TITL", title);
- }
-
- if (!artist.IsEmpty()) {
- SetProperty(L"AUTH", artist);
- } else if (!writer.IsEmpty()) {
- SetProperty(L"AUTH", writer);
- }
-
- if (!appl.IsEmpty()) {
- SetProperty(L"APPL", appl);
- }
-
- if (!desc.IsEmpty()) {
- SetProperty(L"DESC", desc);
- }
- }
- }
-
- if (rtVideoDuration > 0 && rtVideoDuration < m_rtDuration / 2) {
- m_rtDuration = rtVideoDuration; // fix incorrect duration
- }
-
- m_rtNewStop = m_rtStop = m_rtDuration;
-
- TRACE(_T("CMP4SplitterFilter m_pOutputs.GetCount() = %d\n") , m_pOutputs.GetCount());
-
- return !m_pOutputs.IsEmpty() ? S_OK : E_FAIL;
-}
-
-bool CMP4SplitterFilter::DemuxInit()
-{
- AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
-
- POSITION pos = m_trackpos.GetStartPosition();
- while (pos) {
- CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
-
- pPair->m_value.index = 0;
- pPair->m_value.ts = 0;
-
- AP4_Track* track = movie->GetTrack(pPair->m_key);
-
- AP4_Sample sample;
- if (AP4_SUCCEEDED(track->GetSample(0, sample))) {
- pPair->m_value.ts = sample.GetCts();
- }
- }
-
- return true;
-}
-
-void CMP4SplitterFilter::DemuxSeek(REFERENCE_TIME rt)
-{
- AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
-
- POSITION pos = m_trackpos.GetStartPosition();
- while (pos) {
- CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
-
- AP4_Track* track = movie->GetTrack(pPair->m_key);
-
- if (AP4_FAILED(track->GetSampleIndexForRefTime(rt, pPair->m_value.index))) {
- continue;
- }
-
- AP4_Sample sample;
- if (AP4_SUCCEEDED(track->GetSample(pPair->m_value.index, sample))) {
- pPair->m_value.ts = sample.GetCts();
- }
-
- // FIXME: slow search & stss->m_Entries is private
- if (AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
- if (stss->m_Entries.ItemCount() > 0) {
- AP4_Cardinal i = 1;
- while (i < stss->m_Entries.ItemCount()) {
- if (stss->m_Entries[i] - 1 > pPair->m_value.index) {
- break;
- }
- ++i;
- }
- //ASSERT(pPair->m_value.index == stss->m_Entries[i-1] - 1); // fast seek test
- pPair->m_value.index = stss->m_Entries[i - 1] - 1;
- }
- }
- }
-}
-
-bool CMP4SplitterFilter::DemuxLoop()
-{
- HRESULT hr = S_OK;
-
- AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
-
- while (SUCCEEDED(hr) && !CheckRequest(nullptr)) {
- CAtlMap<DWORD, trackpos>::CPair* pPairNext = nullptr;
- REFERENCE_TIME rtNext = 0;
-
- POSITION pos = m_trackpos.GetStartPosition();
- while (pos) {
- CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
-
- AP4_Track* track = movie->GetTrack(pPair->m_key);
-
- CBaseSplitterOutputPin* pPin = GetOutputPin((DWORD)track->GetId());
- if (!pPin->IsConnected()) {
- continue;
- }
-
- REFERENCE_TIME rt = (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * pPair->m_value.ts);
-
- if (pPair->m_value.index < track->GetSampleCount() && (!pPairNext || rt < rtNext)) {
- pPairNext = pPair;
- rtNext = rt;
- }
- }
-
- if (!pPairNext) {
- break;
- }
-
- AP4_Track* track = movie->GetTrack(pPairNext->m_key);
-
- CBaseSplitterOutputPin* pPin = GetOutputPin((DWORD)track->GetId());
-
- AP4_Sample sample;
- AP4_DataBuffer data;
-
- if (pPin && pPin->IsConnected() && AP4_SUCCEEDED(track->ReadSample(pPairNext->m_value.index, sample, data))) {
- const CMediaType& mt = pPin->CurrentMediaType();
-
- CAutoPtr<Packet> p(DEBUG_NEW Packet());
- p->TrackNumber = (DWORD)track->GetId();
- p->rtStart = (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * sample.GetCts());
- p->rtStop = p->rtStart + (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * sample.GetDuration());
- p->bSyncPoint = TRUE;
-
- // FIXME: slow search & stss->m_Entries is private
- if (AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
- if (stss->m_Entries.ItemCount() > 0) {
- p->bSyncPoint = FALSE;
- for (AP4_Cardinal i = 0; i < stss->m_Entries.ItemCount(); ++i) {
- if (stss->m_Entries[i] - 1 < pPairNext->m_value.index) {
- continue;
- }
- if (stss->m_Entries[i] - 1 == pPairNext->m_value.index) {
- p->bSyncPoint = TRUE;
- }
- break;
- }
- }
- }
-
- //
- if (track->GetType() == AP4_Track::TYPE_AUDIO && data.GetDataSize() >= 1 && data.GetDataSize() <= 16) {
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
-
- int nBlockAlign;
- if (wfe->nBlockAlign == 0) {
- nBlockAlign = 1200;
- } else if (wfe->nBlockAlign <= 16) { // for PCM (from 8bit mono to 64bit stereo), A-Law, u-Law
- nBlockAlign = wfe->nBlockAlign * (wfe->nSamplesPerSec >> 4); // 1/16s=62.5ms
- } else {
- nBlockAlign = wfe->nBlockAlign;
- pPairNext->m_value.index -= pPairNext->m_value.index % wfe->nBlockAlign;
- }
-
- p->rtStop = p->rtStart;
- TRACE(_T("track->GetSampleCount() %d %d\n"), track->GetSampleCount(), pPairNext->m_value.index);
- int fFirst = true;
-
- while (AP4_SUCCEEDED(track->ReadSample(pPairNext->m_value.index, sample, data))) {
- AP4_Size size = data.GetDataSize();
- const AP4_Byte* ptr = data.GetData();
-
- if (fFirst) {
- p->SetData(ptr, size);
- p->rtStart = p->rtStop = (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * sample.GetCts());
- fFirst = false;
- } else {
- for (int i = 0; i < size; ++i) {
- p->Add(ptr[i]);
- }
- }
-
- p->rtStop += (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * sample.GetDuration());
-
- if (pPairNext->m_value.index + 1 >= track->GetSampleCount() || (int)p->GetCount() >= nBlockAlign) {
- break;
- }
-
- pPairNext->m_value.index++;
- }
- } else if (track->GetType() == AP4_Track::TYPE_TEXT) {
- CStringA dlgln_bkg, dlgln_plaintext;
-
- const AP4_Byte* ptr = data.GetData();
- AP4_Size avail = data.GetDataSize();
-
- if (avail > 2) {
- AP4_UI16 size = (ptr[0] << 8) | ptr[1];
-
- if (size <= avail - 2) {
- CStringA str;
-
- if (size >= 2 && ptr[2] == 0xfe && ptr[3] == 0xff) {
- CStringW wstr = CStringW((LPCWSTR)&ptr[2], size / 2);
- for (int i = 0; i < wstr.GetLength(); ++i) {
- wstr.SetAt(i, ((WORD)wstr[i] >> 8) | ((WORD)wstr[i] << 8));
- }
- str = UTF16To8(wstr);
- } else {
- str = CStringA((LPCSTR)&ptr[2], size);
- }
-
- CStringA dlgln = str;
-
- if (mt.subtype == MEDIASUBTYPE_ASS2) {
- AP4_SampleDescription* desc = track->GetSampleDescription(sample.GetDescriptionIndex());
-
- dlgln = "0,0,Text,,0000,0000,0000,0000,," + str;
- dlgln_plaintext = str;
-
- CPoint translation(0, 0);
- if (AP4_TkhdAtom* tkhd = dynamic_cast<AP4_TkhdAtom*>(track->GetTrakAtom()->GetChild(AP4_ATOM_TYPE_TKHD))) {
- AP4_Float x, y;
- tkhd->GetTranslation(x, y);
- translation.SetPoint((int)x, (int)y);
- }
-
- if (AP4_UnknownSampleDescription* unknown_desc = dynamic_cast<AP4_UnknownSampleDescription*>(desc)) { // TEMP
- AP4_SampleEntry* sample_entry = unknown_desc->GetSampleEntry();
-
- if (AP4_TextSampleEntry* text = dynamic_cast<AP4_TextSampleEntry*>(sample_entry)) {
- const AP4_TextSampleEntry::AP4_TextDescription& d = text->GetDescription();
-
- // TODO
- } else if (AP4_Tx3gSampleEntry* tx3g = dynamic_cast<AP4_Tx3gSampleEntry*>(sample_entry)) {
- const AP4_Tx3gSampleEntry::AP4_Tx3gDescription& desc = tx3g->GetDescription();
-
- CStringW font = L"Arial";
-
- if (AP4_FtabAtom* ftab = dynamic_cast<AP4_FtabAtom*>(tx3g->GetChild(AP4_ATOM_TYPE_FTAB))) {
- AP4_String Name;
- if (AP4_SUCCEEDED(ftab->LookupFont(desc.Style.Font.Id, Name))) {
- font = Name.c_str();
- }
- }
-
- CRect rbox;
- CStringW ssa = ConvertTX3GToSSA(
- UTF8To16(str), desc, font,
- ptr + (2 + size), avail - (2 + size),
- m_framesize, translation,
- (p->rtStop - p->rtStart) / 10000,
- rbox);
- dlgln = UTF16To8(ssa);
-
- const AP4_Byte* bclr = (const AP4_Byte*)&desc.BackgroundColor;
-
- if (bclr[3]) {
- CPoint tl = rbox.TopLeft();
- rbox.OffsetRect(-tl.x, -tl.y);
-
- dlgln_bkg.Format(
- "0,-1,Text,,0,0,0,0,,{\\an7\\pos(%d,%d)\\1c%02x%02x%02x\\1a%02x\\bord0\\shad0}{\\p1}m %d %d l %d %d l %d %d l %d %d {\\p0}",
- tl.x, tl.y,
- bclr[2], bclr[1], bclr[0],
- 255 - bclr[3],
- rbox.left, rbox.top,
- rbox.right, rbox.top,
- rbox.right, rbox.bottom,
- rbox.left, rbox.bottom);
- }
- }
- }
- }
-
- dlgln.Replace("\r", "");
- dlgln.Replace("\n", "\\N");
-
- p->SetData((LPCSTR)dlgln, dlgln.GetLength());
- }
- }
-
- if (!dlgln_bkg.IsEmpty()) {
- CAutoPtr<Packet> p2(DEBUG_NEW Packet());
- p2->TrackNumber = p->TrackNumber;
- p2->rtStart = p->rtStart;
- p2->rtStop = p->rtStop;
- p2->bSyncPoint = p->bSyncPoint;
- p2->SetData((LPCSTR)dlgln_bkg, dlgln_bkg.GetLength());
- hr = DeliverPacket(p2);
- }
-
- if (!dlgln_plaintext.IsEmpty()) {
- CAutoPtr<Packet> p2(DEBUG_NEW Packet());
- p2->TrackNumber = p->TrackNumber ^ 0x80402010;
- p2->rtStart = p->rtStart;
- p2->rtStop = p->rtStop;
- p2->bSyncPoint = p->bSyncPoint;
- p2->SetData((LPCSTR)dlgln_plaintext, dlgln_plaintext.GetLength());
- hr = DeliverPacket(p2);
- }
- } else {
- p->SetData(data.GetData(), data.GetDataSize());
- }
- hr = DeliverPacket(p);
- }
-
- {
- AP4_Sample sample;
- if (AP4_SUCCEEDED(track->GetSample(++pPairNext->m_value.index, sample))) {
- pPairNext->m_value.ts = sample.GetCts();
- }
- }
-
- }
-
- return true;
-}
-
-// IKeyFrameInfo
-
-STDMETHODIMP CMP4SplitterFilter::GetKeyFrameCount(UINT& nKFs)
-{
- CheckPointer(m_pFile, E_UNEXPECTED);
-
- if (!m_pFile) {
- return E_UNEXPECTED;
- }
-
- AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
-
- POSITION pos = m_trackpos.GetStartPosition();
- while (pos) {
- CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
-
- AP4_Track* track = movie->GetTrack(pPair->m_key);
-
- if (track->GetType() != AP4_Track::TYPE_VIDEO) {
- continue;
- }
-
- if (AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
- nKFs = stss->m_Entries.ItemCount();
- return S_OK;
- }
- }
-
- return E_FAIL;
-}
-
-STDMETHODIMP CMP4SplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs)
-{
- CheckPointer(pFormat, E_POINTER);
- CheckPointer(pKFs, E_POINTER);
- CheckPointer(m_pFile, E_UNEXPECTED);
-
- if (*pFormat != TIME_FORMAT_MEDIA_TIME) {
- return E_INVALIDARG;
- }
-
- if (!m_pFile) {
- return E_UNEXPECTED;
- }
-
- AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
-
- POSITION pos = m_trackpos.GetStartPosition();
- while (pos) {
- CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
-
- AP4_Track* track = movie->GetTrack(pPair->m_key);
-
- if (track->GetType() != AP4_Track::TYPE_VIDEO) {
- continue;
- }
-
- if (AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
- UINT nKFsTmp = 0;
- AP4_UI32 mts = track->GetMediaTimeScale();
-
- for (AP4_Cardinal i = 0; i < stss->m_Entries.ItemCount() && nKFsTmp < nKFs; ++i) {
- AP4_Sample sample;
- if (AP4_SUCCEEDED(track->GetSample(stss->m_Entries[i] - 1, sample))) {
- pKFs[nKFsTmp++] = REFERENCE_TIME((10000000ui64 * sample.GetCts() + mts / 2) / mts);
- //pKFs[nKFsTmp++] = REFERENCE_TIME(10000000.0 * sample.GetCts() / track->GetMediaTimeScale() + 0.5);
- }
- }
- nKFs = nKFsTmp;
-
- return S_OK;
- }
- }
-
- return E_FAIL;
-}
-
-//
-// CMP4SourceFilter
-//
-
-CMP4SourceFilter::CMP4SourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CMP4SplitterFilter(pUnk, phr)
-{
- m_clsid = __uuidof(this);
- m_pInput.Free();
-}
-
-//
-// CMPEG4VideoSplitterFilter
-//
-
-CMPEG4VideoSplitterFilter::CMPEG4VideoSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("CMPEG4VideoSplitterFilter"), pUnk, phr, __uuidof(this))
-{
-}
-
-void CMPEG4VideoSplitterFilter::SkipUserData()
-{
- m_pFile->BitByteAlign();
- while (m_pFile->BitRead(32, true) == 0x000001b2)
- while (m_pFile->BitRead(24, true) != 0x000001) {
- m_pFile->BitRead(8);
- }
-}
-
-HRESULT CMPEG4VideoSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
-{
- CheckPointer(pAsyncReader, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- m_pFile.Free();
- m_pFile.Attach(DEBUG_NEW CBaseSplitterFileEx(pAsyncReader, hr));
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration = 0;
-
- // TODO
-
- DWORD width = 0;
- DWORD height = 0;
- BYTE parx = 1;
- BYTE pary = 1;
- REFERENCE_TIME atpf = 400000;
-
- if (m_pFile->BitRead(24, true) != 0x000001) {
- return E_FAIL;
- }
-
- BYTE id;
- while (m_pFile->NextMpegStartCode(id, 1024 - m_pFile->GetPos())) {
- if (id == 0xb5) {
- BYTE is_visual_object_identifier = (BYTE)m_pFile->BitRead(1);
-
- if (is_visual_object_identifier) {
- BYTE visual_object_verid = (BYTE)m_pFile->BitRead(4);
- BYTE visual_object_priority = (BYTE)m_pFile->BitRead(3);
- }
-
- BYTE visual_object_type = (BYTE)m_pFile->BitRead(4);
-
- if (visual_object_type == 1 || visual_object_type == 2) {
- BYTE video_signal_type = (BYTE)m_pFile->BitRead(1);
-
- if (video_signal_type) {
- BYTE video_format = (BYTE)m_pFile->BitRead(3);
- BYTE video_range = (BYTE)m_pFile->BitRead(1);
- BYTE colour_description = (BYTE)m_pFile->BitRead(1);
-
- if (colour_description) {
- BYTE colour_primaries = (BYTE)m_pFile->BitRead(8);
- BYTE transfer_characteristics = (BYTE)m_pFile->BitRead(8);
- BYTE matrix_coefficients = (BYTE)m_pFile->BitRead(8);
- }
- }
- }
-
- SkipUserData();
-
- if (visual_object_type == 1) {
- if (m_pFile->BitRead(24) != 0x000001) {
- break;
- }
-
- BYTE video_object_start_code = (BYTE)m_pFile->BitRead(8);
- if (video_object_start_code < 0x00 || video_object_start_code > 0x1f) {
- break;
- }
-
- if (m_pFile->BitRead(24) != 0x000001) {
- break;
- }
-
- BYTE video_object_layer_start_code = (DWORD)m_pFile->BitRead(8);
- if (video_object_layer_start_code < 0x20 || video_object_layer_start_code > 0x2f) {
- break;
- }
-
- BYTE random_accessible_vol = (BYTE)m_pFile->BitRead(1);
- BYTE video_object_type_indication = (BYTE)m_pFile->BitRead(8);
-
- if (video_object_type_indication == 0x12) { // Fine Granularity Scalable
- break; // huh
- }
-
- BYTE is_object_layer_identifier = (BYTE)m_pFile->BitRead(1);
-
- BYTE video_object_layer_verid = 0;
-
- if (is_object_layer_identifier) {
- video_object_layer_verid = (BYTE)m_pFile->BitRead(4);
- BYTE video_object_layer_priority = (BYTE)m_pFile->BitRead(3);
- }
-
- BYTE aspect_ratio_info = (BYTE)m_pFile->BitRead(4);
-
- switch (aspect_ratio_info) {
- default:
- ASSERT(0);
- break;
- case 1:
- parx = 1;
- pary = 1;
- break;
- case 2:
- parx = 12;
- pary = 11;
- break;
- case 3:
- parx = 10;
- pary = 11;
- break;
- case 4:
- parx = 16;
- pary = 11;
- break;
- case 5:
- parx = 40;
- pary = 33;
- break;
- case 15:
- parx = (BYTE)m_pFile->BitRead(8);
- pary = (BYTE)m_pFile->BitRead(8);
- break;
- }
-
- BYTE vol_control_parameters = (BYTE)m_pFile->BitRead(1);
-
- if (vol_control_parameters) {
- BYTE chroma_format = (BYTE)m_pFile->BitRead(2);
- BYTE low_delay = (BYTE)m_pFile->BitRead(1);
- BYTE vbv_parameters = (BYTE)m_pFile->BitRead(1);
-
- if (vbv_parameters) {
- WORD first_half_bit_rate = (WORD)m_pFile->BitRead(15);
- if (!m_pFile->BitRead(1)) {
- break;
- }
- WORD latter_half_bit_rate = (WORD)m_pFile->BitRead(15);
- if (!m_pFile->BitRead(1)) {
- break;
- }
- WORD first_half_vbv_buffer_size = (WORD)m_pFile->BitRead(15);
- if (!m_pFile->BitRead(1)) {
- break;
- }
-
- BYTE latter_half_vbv_buffer_size = (BYTE)m_pFile->BitRead(3);
- WORD first_half_vbv_occupancy = (WORD)m_pFile->BitRead(11);
- if (!m_pFile->BitRead(1)) {
- break;
- }
- WORD latter_half_vbv_occupancy = (WORD)m_pFile->BitRead(15);
- if (!m_pFile->BitRead(1)) {
- break;
- }
- }
- }
-
- BYTE video_object_layer_shape = (BYTE)m_pFile->BitRead(2);
-
- if (video_object_layer_shape == 3 && video_object_layer_verid != 1) {
- BYTE video_object_layer_shape_extension = (BYTE)m_pFile->BitRead(4);
- }
-
- if (!m_pFile->BitRead(1)) {
- break;
- }
- WORD vop_time_increment_resolution = (WORD)m_pFile->BitRead(16);
- if (!m_pFile->BitRead(1)) {
- break;
- }
- BYTE fixed_vop_rate = (BYTE)m_pFile->BitRead(1);
-
- if (fixed_vop_rate) {
- int bits = 0;
- for (WORD i = vop_time_increment_resolution; i; i /= 2) {
- ++bits;
- }
-
- WORD fixed_vop_time_increment = m_pFile->BitRead(bits);
-
- if (fixed_vop_time_increment) {
- atpf = 10000000i64 * fixed_vop_time_increment / vop_time_increment_resolution;
- }
- }
-
- if (video_object_layer_shape != 2) {
- if (video_object_layer_shape == 0) {
- if (!m_pFile->BitRead(1)) {
- break;
- }
- width = (WORD)m_pFile->BitRead(13);
- if (!m_pFile->BitRead(1)) {
- break;
- }
- height = (WORD)m_pFile->BitRead(13);
- if (!m_pFile->BitRead(1)) {
- break;
- }
- }
-
- BYTE interlaced = (BYTE)m_pFile->BitRead(1);
- BYTE obmc_disable = (BYTE)m_pFile->BitRead(1);
-
- // ...
- }
- }
- } else if (id == 0xb6) {
- m_seqhdrsize = m_pFile->GetPos() - 4;
- }
- }
-
- if (!width || !height) {
- return E_FAIL;
- }
-
- CAtlArray<CMediaType> mts;
-
- CMediaType mt;
- mt.SetSampleSize(1);
-
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = FOURCCMap('v4pm');
- mt.formattype = FORMAT_MPEG2Video;
- MPEG2VIDEOINFO* mvih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + m_seqhdrsize);
- ZeroMemory(mvih, mt.FormatLength());
- mvih->hdr.bmiHeader.biSize = sizeof(mvih->hdr.bmiHeader);
- mvih->hdr.bmiHeader.biWidth = width;
- mvih->hdr.bmiHeader.biHeight = height;
- mvih->hdr.bmiHeader.biCompression = 'v4pm';
- mvih->hdr.bmiHeader.biPlanes = 1;
- mvih->hdr.bmiHeader.biBitCount = 24;
- mvih->hdr.AvgTimePerFrame = atpf;
- mvih->hdr.dwPictAspectRatioX = width * parx;
- mvih->hdr.dwPictAspectRatioY = height * pary;
- mvih->cbSequenceHeader = m_seqhdrsize;
- m_pFile->Seek(0);
- m_pFile->ByteRead((BYTE*)mvih->dwSequenceHeader, m_seqhdrsize);
- mts.Add(mt);
- mt.subtype = FOURCCMap(mvih->hdr.bmiHeader.biCompression = 'V4PM');
- mts.Add(mt);
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DEBUG_NEW CBaseSplitterOutputPin(mts, L"Video", this, this, &hr));
- EXECUTE_ASSERT(SUCCEEDED(AddOutputPin(0, pPinOut)));
-
- m_rtNewStop = m_rtStop = m_rtDuration;
-
- return !m_pOutputs.IsEmpty() ? S_OK : E_FAIL;
-}
-
-bool CMPEG4VideoSplitterFilter::DemuxInit()
-{
- return true;
-}
-
-void CMPEG4VideoSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
-{
- ASSERT(rt == 0);
-
- m_pFile->Seek(m_seqhdrsize);
-}
-
-bool CMPEG4VideoSplitterFilter::DemuxLoop()
-{
- HRESULT hr = S_OK;
-
- CAutoPtr<Packet> p;
-
- REFERENCE_TIME rt = 0;
- REFERENCE_TIME atpf = ((MPEG2VIDEOINFO*)GetOutputPin(0)->CurrentMediaType().Format())->hdr.AvgTimePerFrame;
-
- DWORD sync = ~0;
-
- while (SUCCEEDED(hr) && !CheckRequest(nullptr) && m_pFile->GetRemaining()) {
- for (int i = 0; i < 65536; ++i) { // don't call CheckRequest so often
- bool eof = !m_pFile->GetRemaining();
-
- if (p && !p->IsEmpty() && (m_pFile->BitRead(32, true) == 0x000001b6 || eof)) {
- hr = DeliverPacket(p);
- }
-
- if (eof) {
- break;
- }
-
- if (!p) {
- p.Attach(DEBUG_NEW Packet());
- p->SetCount(0, 1024);
- p->TrackNumber = 0;
- p->rtStart = rt;
- p->rtStop = rt + atpf;
- p->bSyncPoint = FALSE;
- rt += atpf;
- // rt = Packet::INVALID_TIME;
- }
-
- BYTE b;
- m_pFile->ByteRead(&b, 1);
- p->Add(b);
- }
- }
-
- return true;
-}
-
-//
-// CMPEG4VideoSourceFilter
-//
-
-CMPEG4VideoSourceFilter::CMPEG4VideoSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CMPEG4VideoSplitterFilter(pUnk, phr)
-{
- m_clsid = __uuidof(this);
- m_pInput.Free();
-}
-
-//
-// CMP4SplitterOutputPin
-//
-
-CMP4SplitterOutputPin::CMP4SplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseSplitterOutputPin(mts, pName, pFilter, pLock, phr)
-{
-}
-
-CMP4SplitterOutputPin::~CMP4SplitterOutputPin()
-{
-}
-
-HRESULT CMP4SplitterOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
-{
- CAutoLock cAutoLock(this);
- return __super::DeliverNewSegment(tStart, tStop, dRate);
-}
-
-HRESULT CMP4SplitterOutputPin::DeliverEndFlush()
-{
- CAutoLock cAutoLock(this);
- return __super::DeliverEndFlush();
-}
-
-HRESULT CMP4SplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
-{
- CAutoLock cAutoLock(this);
- return __super::DeliverPacket(p);
-}
diff --git a/src/filters/parser/MP4Splitter/MP4Splitter.def b/src/filters/parser/MP4Splitter/MP4Splitter.def
deleted file mode 100644
index 6492e5cd6..000000000
--- a/src/filters/parser/MP4Splitter/MP4Splitter.def
+++ /dev/null
@@ -1,5 +0,0 @@
-EXPORTS
- DllCanUnloadNow PRIVATE
- DllGetClassObject PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
diff --git a/src/filters/parser/MP4Splitter/MP4Splitter.h b/src/filters/parser/MP4Splitter/MP4Splitter.h
deleted file mode 100644
index 10b58e3a2..000000000
--- a/src/filters/parser/MP4Splitter/MP4Splitter.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <atlbase.h>
-#include <atlcoll.h>
-#include "MP4SplitterFile.h"
-#include "../BaseSplitter/BaseSplitter.h"
-
-#define MP4SplitterName L"MPC MP4/MOV Splitter"
-#define MP4SourceName L"MPC MP4/MOV Source"
-
-class __declspec(uuid("61F47056-E400-43d3-AF1E-AB7DFFD4C4AD"))
- CMP4SplitterFilter : public CBaseSplitterFilter
-{
- struct trackpos {
- DWORD /*AP4_Ordinal*/ index;
- unsigned __int64 /*AP4_TimeStamp*/ ts;
- };
- CAtlMap<DWORD, trackpos> m_trackpos;
- CSize m_framesize;
-
-protected:
- CAutoPtr<CMP4SplitterFile> m_pFile;
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
-
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
-
-public:
- CMP4SplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
- virtual ~CMP4SplitterFilter();
-
- // CBaseFilter
- STDMETHODIMP_(HRESULT) QueryFilterInfo(FILTER_INFO* pInfo);
-
- // IKeyFrameInfo
-
- STDMETHODIMP_(HRESULT) GetKeyFrameCount(UINT& nKFs);
- STDMETHODIMP_(HRESULT) GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs);
-};
-
-class __declspec(uuid("3CCC052E-BDEE-408a-BEA7-90914EF2964B"))
- CMP4SourceFilter : public CMP4SplitterFilter
-{
-public:
- CMP4SourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
-};
-
-// for raw mpeg4 elementary streams:
-
-class __declspec(uuid("D3D9D58B-45B5-48AB-B199-B8C40560AEC7"))
- CMPEG4VideoSplitterFilter : public CBaseSplitterFilter
-{
- __int64 m_seqhdrsize;
- int NextStartCode();
- void SkipUserData();
-
-protected:
- CAutoPtr<CBaseSplitterFileEx> m_pFile;
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
-
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
-
-public:
- CMPEG4VideoSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
-};
-
-class __declspec(uuid("E2B98EEA-EE55-4E9B-A8C1-6E5288DF785A"))
- CMPEG4VideoSourceFilter : public CMPEG4VideoSplitterFilter
-{
-public:
- CMPEG4VideoSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
-};
-
-class CMP4SplitterOutputPin : public CBaseSplitterOutputPin, protected CCritSec
-{
-public:
- CMP4SplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
- virtual ~CMP4SplitterOutputPin();
-
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
- HRESULT DeliverPacket(CAutoPtr<Packet> p);
- HRESULT DeliverEndFlush();
-};
diff --git a/src/filters/parser/MP4Splitter/MP4Splitter.rc b/src/filters/parser/MP4Splitter/MP4Splitter.rc
deleted file mode 100644
index b45dd9a87..000000000
--- a/src/filters/parser/MP4Splitter/MP4Splitter.rc
+++ /dev/null
@@ -1,104 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-#include "version.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (U.S.) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-#ifdef _WIN32
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-#endif //_WIN32
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION MPC_VERSION_NUM
- PRODUCTVERSION MPC_VERSION_NUM
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS VOS_NT_WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE VFT2_UNKNOWN
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", MPC_VERSION_COMMENTS
- VALUE "CompanyName", MPC_COMP_NAME_STR
- VALUE "FileDescription", "MP4 Splitter"
- VALUE "FileVersion", MPC_VERSION_STR_FULL
- VALUE "InternalName", "MP4 Splitter"
- VALUE "LegalCopyright", MPC_COPYRIGHT_STR
- VALUE "OriginalFilename", "MP4Splitter.ax"
- VALUE "ProductName", "MP4 Splitter"
- VALUE "ProductVersion", MPC_VERSION_STR_FULL
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // English (U.S.) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/src/filters/parser/MP4Splitter/MP4Splitter.vcxproj b/src/filters/parser/MP4Splitter/MP4Splitter.vcxproj
deleted file mode 100644
index 907d49cec..000000000
--- a/src/filters/parser/MP4Splitter/MP4Splitter.vcxproj
+++ /dev/null
@@ -1,263 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug Filter|Win32">
- <Configuration>Debug Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug Filter|x64">
- <Configuration>Debug Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|Win32">
- <Configuration>Release Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|x64">
- <Configuration>Release Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{9ED4B036-7399-4128-868D-6E71188E0277}</ProjectGuid>
- <RootNamespace>MP4Splitter</RootNamespace>
- <Keyword>MFCProj</Keyword>
- <ProjectName>MP4Splitter</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <Import Project="..\..\..\platform.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">.ax</TargetExt>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\thirdparty\Bento4\Core;..\..\..\thirdparty\Bento4\Crypto;..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\thirdparty\Bento4\Core;..\..\..\thirdparty\Bento4\Crypto;..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\thirdparty\Bento4\Core;..\..\..\thirdparty\Bento4\Crypto;..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\thirdparty\Bento4\Core;..\..\..\thirdparty\Bento4\Crypto;..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\thirdparty\Bento4\Core;..\..\..\thirdparty\Bento4\Crypto;..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MP4Splitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\thirdparty\Bento4\Core;..\..\..\thirdparty\Bento4\Crypto;..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MP4Splitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\thirdparty\Bento4\Core;..\..\..\thirdparty\Bento4\Crypto;..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MP4Splitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\thirdparty\Bento4\Core;..\..\..\thirdparty\Bento4\Crypto;..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MP4Splitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="Ap4AsyncReaderStream.cpp" />
- <ClCompile Include="MP4Splitter.cpp" />
- <ClCompile Include="MP4SplitterFile.cpp" />
- <ClCompile Include="stdafx.cpp">
- <PrecompiledHeader>Create</PrecompiledHeader>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="Ap4AsyncReaderStream.h" />
- <ClInclude Include="MP4Splitter.h" />
- <ClInclude Include="MP4SplitterFile.h" />
- <ClInclude Include="resource.h">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ClInclude>
- <ClInclude Include="stdafx.h" />
- </ItemGroup>
- <ItemGroup>
- <None Include="MP4Splitter.def" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="MP4Splitter.rc">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ResourceCompile>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\DSUtil\DSUtil.vcxproj">
- <Project>{fc70988b-1ae5-4381-866d-4f405e28ac42}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\Kasumi\Kasumi.vcxproj">
- <Project>{0d252872-7542-4232-8d02-53f9182aee15}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\system\system.vcxproj">
- <Project>{c2082189-3ecb-4079-91fa-89d3c8a305c0}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\zlib\zlib.vcxproj">
- <Project>{2fcd4b66-9cf9-4c8f-bc70-37cd20002d49}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\BaseClasses\BaseClasses.vcxproj">
- <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\Filters.vcxproj">
- <Project>{273b3149-3192-4b75-a791-470320b90812}</Project>
- </ProjectReference>
- <ProjectReference Include="..\BaseSplitter\BaseSplitter.vcxproj">
- <Project>{37768b3f-89bc-4c16-b2a8-767c5da84c3f}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\Bento4\Bento4.vcxproj">
- <Project>{40177920-a66c-4647-b119-332a10224c83}</Project>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/MP4Splitter/MP4Splitter.vcxproj.filters b/src/filters/parser/MP4Splitter/MP4Splitter.vcxproj.filters
deleted file mode 100644
index bd8470503..000000000
--- a/src/filters/parser/MP4Splitter/MP4Splitter.vcxproj.filters
+++ /dev/null
@@ -1,67 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{811a4da3-b120-496c-98a0-7016078458cd}</UniqueIdentifier>
- <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{4ae0033a-41e4-43a5-ac05-966c1d9184fe}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{2471c705-e3fc-48d6-9877-e6ece4604e13}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="Ap4AsyncReaderStream.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="MP4Splitter.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="MP4SplitterFile.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="stdafx.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="Ap4AsyncReaderStream.h">
- <Filter>Source Files</Filter>
- </ClInclude>
- <ClInclude Include="MP4Splitter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="MP4SplitterFile.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="resource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="stdafx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <None Include="MP4Splitter.def">
- <Filter>Source Files</Filter>
- </None>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="MP4Splitter.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/MP4Splitter/MP4SplitterFile.cpp b/src/filters/parser/MP4Splitter/MP4SplitterFile.cpp
deleted file mode 100644
index e4881f63b..000000000
--- a/src/filters/parser/MP4Splitter/MP4SplitterFile.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "MP4SplitterFile.h"
-#include "Ap4AsyncReaderStream.h"
-
-CMP4SplitterFile::CMP4SplitterFile(IAsyncReader* pReader, HRESULT& hr)
- : CBaseSplitterFileEx(pReader, hr, DEFAULT_CACHE_LENGTH, false)
- , m_pAp4File(nullptr)
-{
- if (FAILED(hr)) {
- return;
- }
-
- hr = Init();
-}
-
-CMP4SplitterFile::~CMP4SplitterFile()
-{
- delete(AP4_File*)m_pAp4File;
-}
-
-void* /* AP4_Movie* */ CMP4SplitterFile::GetMovie()
-{
- ASSERT(m_pAp4File);
- return m_pAp4File ? ((AP4_File*)m_pAp4File)->GetMovie() : nullptr;
-}
-
-HRESULT CMP4SplitterFile::Init()
-{
- Seek(0);
-
- delete(AP4_File*)m_pAp4File;
-
- AP4_ByteStream* stream = DEBUG_NEW AP4_AsyncReaderStream(this);
-
- m_pAp4File = DEBUG_NEW AP4_File(*stream);
-
- AP4_Movie* movie = ((AP4_File*)m_pAp4File)->GetMovie();
-
- stream->Release();
-
- return movie ? S_OK : E_FAIL;
-}
diff --git a/src/filters/parser/MP4Splitter/MP4SplitterFile.h b/src/filters/parser/MP4Splitter/MP4SplitterFile.h
deleted file mode 100644
index df41f8803..000000000
--- a/src/filters/parser/MP4Splitter/MP4SplitterFile.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../BaseSplitter/BaseSplitter.h"
-// #include "Ap4AsyncReaderStream.h" // FIXME
-
-class CMP4SplitterFile : public CBaseSplitterFileEx
-{
- void* /* AP4_File* */ m_pAp4File;
-
- HRESULT Init();
-
-public:
- CMP4SplitterFile(IAsyncReader* pReader, HRESULT& hr);
- virtual ~CMP4SplitterFile();
-
- void* /* AP4_Movie* */ GetMovie();
-};
diff --git a/src/filters/parser/MP4Splitter/resource.h b/src/filters/parser/MP4Splitter/resource.h
deleted file mode 100644
index f9afd652d..000000000
--- a/src/filters/parser/MP4Splitter/resource.h
+++ /dev/null
@@ -1,14 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by MP4Splitter.rc
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 101
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/filters/parser/MP4Splitter/stdafx.cpp b/src/filters/parser/MP4Splitter/stdafx.cpp
deleted file mode 100644
index 784f2cebc..000000000
--- a/src/filters/parser/MP4Splitter/stdafx.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
diff --git a/src/filters/parser/MP4Splitter/stdafx.h b/src/filters/parser/MP4Splitter/stdafx.h
deleted file mode 100644
index b0e6277c8..000000000
--- a/src/filters/parser/MP4Splitter/stdafx.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../../DSUtil/SharedInclude.h"
-#include "../../../../include/stdafx_common.h"
-#include "../../../../include/stdafx_common_afx.h"
-#include "../../../../include/stdafx_common_dshow.h"
-
-#include <crtdefs.h>
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaFile.cpp b/src/filters/parser/MatroskaSplitter/MatroskaFile.cpp
deleted file mode 100644
index 396d6a449..000000000
--- a/src/filters/parser/MatroskaSplitter/MatroskaFile.cpp
+++ /dev/null
@@ -1,1595 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "MatroskaFile.h"
-#include "../../../DSUtil/DSUtil.h"
-#include "zlib/zlib.h"
-
-#define DOCTYPE _T("matroska")
-#define DOCTYPE_WEBM _T("webm")
-#define DOCTYPEVERSION 2
-
-using namespace MatroskaReader;
-
-
-#define BeginChunk \
- CheckPointer(pMN0, E_POINTER); \
- CAutoPtr<CMatroskaNode> pMN = pMN0->Child(); \
- \
- if (!pMN) \
- return S_FALSE; \
- do { \
- switch (pMN->m_id) {
-
-
-#define EndChunk \
- } \
- } while (pMN->Next()); \
- \
- return S_OK;
-
-
-static void bswap(BYTE* s, int len)
-{
- for (BYTE* d = s + len - 1; s < d; s++, d--) {
- *s ^= *d, *d ^= *s, *s ^= *d;
- }
-}
-
-//
-// CMatroskaFile
-//
-
-CMatroskaFile::CMatroskaFile(IAsyncReader* pAsyncReader, HRESULT& hr)
- : CBaseSplitterFile(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false)
- , m_rtOffset(0)
-{
- if (FAILED(hr)) {
- return;
- }
- hr = Init();
-}
-
-HRESULT CMatroskaFile::Init()
-{
- DWORD dw;
- if (FAILED(Read(dw)) || dw != 0x1A45DFA3) {
- return E_FAIL;
- }
-
- CMatroskaNode Root(this);
- if (FAILED(Parse(&Root))) {
- return E_FAIL;
- }
-
- CAutoPtr<CMatroskaNode> pSegment, pCluster;
- if ((pSegment = Root.Child(0x18538067))
- && (pCluster = pSegment->Child(0x1F43B675))) {
- Cluster c0;
- c0.ParseTimeCode(pCluster);
- m_rtOffset = m_segment.GetRefTime(c0.TimeCode);
- }
-
- return S_OK;
-}
-
-template <class T>
-HRESULT CMatroskaFile::Read(T& var)
-{
- HRESULT hr = ByteRead((BYTE*)&var, sizeof(var));
- if (S_OK == hr) {
- bswap((BYTE*)&var, sizeof(var));
- }
- return hr;
-}
-
-HRESULT CMatroskaFile::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x1A45DFA3:
- m_ebml.Parse(pMN);
- if ((m_ebml.DocType != DOCTYPE || m_ebml.DocTypeReadVersion > DOCTYPEVERSION) && m_ebml.DocType != DOCTYPE_WEBM) {
- return E_FAIL;
- }
- break;
-case 0x18538067:
- if (m_segment.SegmentInfo.SegmentUID.IsEmpty()) {
- m_segment.ParseMinimal(pMN);
- }
- break;
- EndChunk;
-}
-
-//
-
-HRESULT EBML::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x4286:
- EBMLVersion.Parse(pMN);
- break;
-case 0x42F7:
- EBMLReadVersion.Parse(pMN);
- break;
-case 0x42F2:
- EBMLMaxIDLength.Parse(pMN);
- break;
-case 0x42F3:
- EBMLMaxSizeLength.Parse(pMN);
- break;
-case 0x4282:
- DocType.Parse(pMN);
- break;
-case 0x4287:
- DocTypeVersion.Parse(pMN);
- break;
-case 0x4285:
- DocTypeReadVersion.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT Segment::Parse(CMatroskaNode* pMN0)
-{
- pos = pMN0->GetPos();
-
- BeginChunk;
-case 0x1549A966:
- SegmentInfo.Parse(pMN);
- break;
-case 0x114D9B74:
- MetaSeekInfo.Parse(pMN);
- break;
-case 0x1654AE6B:
- Tracks.Parse(pMN);
- break;
-case 0x1F43B675:
- Clusters.Parse(pMN);
- break;
-case 0x1C53BB6B:
- Cues.Parse(pMN);
- break;
-case 0x1941A469:
- Attachments.Parse(pMN);
- break;
-case 0x1043A770:
- Chapters.Parse(pMN);
- break;
- // case 0x1254C367: Tags.Parse(pMN); break;
- EndChunk;
-}
-
-HRESULT Segment::ParseMinimal(CMatroskaNode* pMN0)
-{
- CheckPointer(pMN0, E_POINTER);
-
- pos = pMN0->GetPos();
- len = pMN0->m_len;
-
- CAutoPtr<CMatroskaNode> pMN = pMN0->Child();
- if (!pMN) {
- return S_FALSE;
- }
-
- unsigned int k = 0;
-
- do {
- switch (pMN->m_id) {
- case 0x1549A966:
- SegmentInfo.Parse(pMN);
- k |= (1 << 0);
- break;
- case 0x114D9B74:
- MetaSeekInfo.Parse(pMN);
- k |= (1 << 1);
- break;
- case 0x1654AE6B:
- Tracks.Parse(pMN);
- k |= (1 << 2);
- break;
- case 0x1C53BB6B:
- k |= (1 << 3);
- Cues.Parse(pMN);
- break;
- }
- } while (k != 15 && pMN->m_id != 0x1F43B675 && pMN->Next());
-
- if (!pMN->IsRandomAccess()) {
- return S_OK;
- }
-
- while (QWORD pos = pMN->FindPos(0x114D9B74, pMN->GetPos())) {
- pMN->SeekTo(pos);
- if (FAILED(pMN->Parse())) {
- break; // a broken file
- }
- MetaSeekInfo.Parse(pMN);
- }
-
- if (k != 15) {
- if (Cues.IsEmpty() && (pMN = pMN0->Child(0x1C53BB6B, false))) {
- do {
- Cues.Parse(pMN);
- } while (pMN->Next(true));
- }
-
- if (Chapters.IsEmpty() && (pMN = pMN0->Child(0x1043A770, false))) {
- do {
- Chapters.Parse(pMN); /*BIG UGLY HACK:*/
- break;
- } while (pMN->Next(true));
- }
-
- if (Attachments.IsEmpty() && (pMN = pMN0->Child(0x1941A469, false))) {
- do {
- Attachments.Parse(pMN); /*BIG UGLY HACK:*/
- break;
- } while (pMN->Next(true));
- }
- }
-
- return S_OK;
-}
-
-UINT64 Segment::GetMasterTrack()
-{
- UINT64 TrackNumber = 0, AltTrackNumber = 0;
-
- POSITION pos1 = Tracks.GetHeadPosition();
- while (pos1 && TrackNumber == 0) {
- Track* pT = Tracks.GetNext(pos1);
-
- POSITION pos2 = pT->TrackEntries.GetHeadPosition();
- while (pos2 && TrackNumber == 0) {
- TrackEntry* pTE = pT->TrackEntries.GetNext(pos2);
-
- if (pTE->TrackType == TrackEntry::TypeVideo) {
- TrackNumber = pTE->TrackNumber;
- break;
- } else if (pTE->TrackType == TrackEntry::TypeAudio && AltTrackNumber == 0) {
- AltTrackNumber = pTE->TrackNumber;
- }
- }
- }
-
- if (TrackNumber == 0) {
- TrackNumber = AltTrackNumber;
- }
- if (TrackNumber == 0) {
- TrackNumber = 1;
- }
-
- return TrackNumber;
-}
-
-ChapterAtom* ChapterAtom::FindChapterAtom(UINT64 id)
-{
- if (ChapterUID == id) {
- return this;
- }
-
- POSITION pos = ChapterAtoms.GetHeadPosition();
- while (pos) {
- ChapterAtom* ca = ChapterAtoms.GetNext(pos)->FindChapterAtom(id);
- if (ca) {
- return ca;
- }
- }
-
- return nullptr;
-}
-
-ChapterAtom* Segment::FindChapterAtom(UINT64 id, int nEditionEntry)
-{
- POSITION pos1 = Chapters.GetHeadPosition();
- while (pos1) {
- Chapter* c = Chapters.GetNext(pos1);
-
- POSITION pos2 = c->EditionEntries.GetHeadPosition();
- while (pos2) {
- EditionEntry* ee = c->EditionEntries.GetNext(pos2);
-
- if (nEditionEntry-- == 0) {
- return id == 0 ? ee : ee->FindChapterAtom(id);
- }
- }
- }
-
- return nullptr;
-}
-
-HRESULT Info::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x73A4:
- SegmentUID.Parse(pMN);
- break;
-case 0x7384:
- SegmentFilename.Parse(pMN);
- break;
-case 0x3CB923:
- PrevUID.Parse(pMN);
- break;
-case 0x3C83AB:
- PrevFilename.Parse(pMN);
- break;
-case 0x3EB923:
- NextUID.Parse(pMN);
- break;
-case 0x3E83BB:
- NextFilename.Parse(pMN);
- break;
-case 0x2AD7B1:
- TimeCodeScale.Parse(pMN);
- break;
-case 0x4489:
- Duration.Parse(pMN);
- break;
-case 0x4461:
- DateUTC.Parse(pMN);
- break;
-case 0x7BA9:
- Title.Parse(pMN);
- break;
-case 0x4D80:
- MuxingApp.Parse(pMN);
- break;
-case 0x5741:
- WritingApp.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT Seek::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x4DBB:
- SeekHeads.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT SeekHead::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x53AB:
- SeekID.Parse(pMN);
- break;
-case 0x53AC:
- SeekPosition.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT Track::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0xAE:
- TrackEntries.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT TrackEntry::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0xD7:
- TrackNumber.Parse(pMN);
- break;
-case 0x73C5:
- TrackUID.Parse(pMN);
- break;
-case 0x83:
- TrackType.Parse(pMN);
- break;
-case 0xB9:
- FlagEnabled.Parse(pMN);
- break;
-case 0x88:
- FlagDefault.Parse(pMN);
- break;
-case 0x9C:
- FlagLacing.Parse(pMN);
- break;
-case 0x55AA:
- FlagForced.Parse(pMN);
- break;
-case 0x6DE7:
- MinCache.Parse(pMN);
- break;
-case 0x6DF8:
- MaxCache.Parse(pMN);
- break;
-case 0x536E:
- Name.Parse(pMN);
- break;
-case 0x22B59C:
- Language.Parse(pMN);
- break;
-case 0x86:
- CodecID.Parse(pMN);
- break;
-case 0x63A2:
- CodecPrivate.Parse(pMN);
- break;
-case 0x258688:
- CodecName.Parse(pMN);
- break;
-case 0x3A9697:
- CodecSettings.Parse(pMN);
- break;
-case 0x3B4040:
- CodecInfoURL.Parse(pMN);
- break;
-case 0x26B240:
- CodecDownloadURL.Parse(pMN);
- break;
-case 0xAA:
- CodecDecodeAll.Parse(pMN);
- break;
-case 0x6FAB:
- TrackOverlay.Parse(pMN);
- break;
-case 0x23E383:
-case 0x2383E3:
- DefaultDuration.Parse(pMN);
- break;
-case 0x23314F:
- TrackTimecodeScale.Parse(pMN);
- break;
-case 0xE0:
- if (S_OK == v.Parse(pMN)) {
- DescType |= DescVideo;
- }
- break;
-case 0xE1:
- if (S_OK == a.Parse(pMN)) {
- DescType |= DescAudio;
- }
- break;
-case 0x6D80:
- ces.Parse(pMN);
- break;
- EndChunk;
-}
-
-static int cesort(const void* a, const void* b)
-{
- UINT64 ce1 = (static_cast<ContentEncoding*>(const_cast<void*>(a)))->ContentEncodingOrder;
- UINT64 ce2 = (static_cast<ContentEncoding*>(const_cast<void*>(b)))->ContentEncodingOrder;
-
- return (int)ce1 - (int)ce2;
-}
-
-bool TrackEntry::Expand(CBinary& data, UINT64 Scope)
-{
- if (ces.ce.IsEmpty()) {
- return true;
- }
-
- CAtlArray<ContentEncoding*> cearray;
- POSITION pos = ces.ce.GetHeadPosition();
- while (pos) {
- cearray.Add(ces.ce.GetNext(pos));
- }
- qsort(cearray.GetData(), cearray.GetCount(), sizeof(ContentEncoding*), cesort);
-
- for (int i = (int)cearray.GetCount() - 1; i >= 0; i--) {
- ContentEncoding* ce = cearray[i];
-
- if (!(ce->ContentEncodingScope & Scope)) {
- continue;
- }
-
- if (ce->ContentEncodingType == ContentEncoding::Compression) {
- if (!data.Decompress(ce->cc)) {
- return false;
- }
- } else if (ce->ContentEncodingType == ContentEncoding::Encryption) {
- // TODO
- return false;
- }
- }
-
- return true;
-}
-
-HRESULT Video::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x9A:
- FlagInterlaced.Parse(pMN);
- break;
-case 0x53B8:
- StereoMode.Parse(pMN);
- break;
-case 0xB0:
- PixelWidth.Parse(pMN);
- if (!DisplayWidth) {
- DisplayWidth.Set(PixelWidth);
- }
- break;
-case 0xBA:
- PixelHeight.Parse(pMN);
- if (!DisplayHeight) {
- DisplayHeight.Set(PixelHeight);
- }
- break;
-case 0x54B0:
- DisplayWidth.Parse(pMN);
- break;
-case 0x54BA:
- DisplayHeight.Parse(pMN);
- break;
-case 0x54B2:
- DisplayUnit.Parse(pMN);
- break;
-case 0x54B3:
- AspectRatioType.Parse(pMN);
- break;
-case 0x54AA:
- VideoPixelCropBottom.Parse(pMN);
- if ((INT64)VideoPixelCropBottom < 0) {
- VideoPixelCropBottom.Set(0); // fix bad value
- }
- break;
-case 0x54BB:
- VideoPixelCropTop.Parse(pMN);
- if ((INT64)VideoPixelCropTop < 0) {
- VideoPixelCropTop.Set(0); // fix bad value
- }
- break;
-case 0x54CC:
- VideoPixelCropLeft.Parse(pMN);
- if ((INT64)VideoPixelCropLeft < 0) {
- VideoPixelCropLeft.Set(0); // fix bad value
- }
- break;
-case 0x54DD:
- VideoPixelCropRight.Parse(pMN);
- if ((INT64)VideoPixelCropRight < 0) {
- VideoPixelCropRight.Set(0); // fix bad value
- }
- break;
-case 0x2EB524:
- ColourSpace.Parse(pMN);
- break;
-case 0x2FB523:
- GammaValue.Parse(pMN);
- break;
-case 0x2383E3:
- FramePerSec.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT Audio::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0xB5:
- SamplingFrequency.Parse(pMN);
- if (!OutputSamplingFrequency) {
- OutputSamplingFrequency.Set(SamplingFrequency);
- }
- break;
-case 0x78B5:
- OutputSamplingFrequency.Parse(pMN);
- break;
-case 0x9F:
- Channels.Parse(pMN);
- break;
-case 0x7D7B:
- ChannelPositions.Parse(pMN);
- break;
-case 0x6264:
- BitDepth.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT ContentEncodings::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x6240:
- ce.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT ContentEncoding::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x5031:
- ContentEncodingOrder.Parse(pMN);
- break;
-case 0x5032:
- ContentEncodingScope.Parse(pMN);
- break;
-case 0x5033:
- ContentEncodingType.Parse(pMN);
- break;
-case 0x5034:
- cc.Parse(pMN);
- break;
-case 0x5035:
- ce.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT ContentCompression::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x4254:
- ContentCompAlgo.Parse(pMN);
- break;
-case 0x4255:
- ContentCompSettings.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT ContentEncryption::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x47e1:
- ContentEncAlgo.Parse(pMN);
- break;
-case 0x47e2:
- ContentEncKeyID.Parse(pMN);
- break;
-case 0x47e3:
- ContentSignature.Parse(pMN);
- break;
-case 0x47e4:
- ContentSigKeyID.Parse(pMN);
- break;
-case 0x47e5:
- ContentSigAlgo.Parse(pMN);
- break;
-case 0x47e6:
- ContentSigHashAlgo.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT Cluster::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0xE7:
- TimeCode.Parse(pMN);
- break;
-case 0xA7:
- Position.Parse(pMN);
- break;
-case 0xAB:
- PrevSize.Parse(pMN);
- break;
-case 0xA0:
- BlockGroups.Parse(pMN, true);
- break;
-case 0xA3:
- SimpleBlocks.Parse(pMN, true);
- break;
- EndChunk;
-}
-
-HRESULT Cluster::ParseTimeCode(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0xE7:
- TimeCode.Parse(pMN);
- return S_OK;
- EndChunk;
-}
-
-HRESULT BlockGroup::Parse(CMatroskaNode* pMN0, bool fFull)
-{
- BeginChunk;
-case 0xA1:
- Block.Parse(pMN, fFull);
- break;
-case 0xA2: /* TODO: multiple virt blocks? */
- ;
- break;
-case 0x9B:
- BlockDuration.Parse(pMN);
- break;
-case 0xFA:
- ReferencePriority.Parse(pMN);
- break;
-case 0xFB:
- ReferenceBlock.Parse(pMN);
- break;
-case 0xFD:
- ReferenceVirtual.Parse(pMN);
- break;
-case 0xA4:
- CodecState.Parse(pMN);
- break;
-case 0xE8:
- TimeSlices.Parse(pMN);
- break;
-case 0x75A1:
- if (fFull) {
- ba.Parse(pMN);
- }
- break;
- EndChunk;
-}
-
-HRESULT SimpleBlock::Parse(CMatroskaNode* pMN, bool fFull)
-{
- pMN->SeekTo(pMN->m_start);
-
- TrackNumber.Parse(pMN);
- CShort s;
- s.Parse(pMN);
- TimeCode.Set(s);
- Lacing.Parse(pMN);
-
- if (!fFull) {
- return S_OK;
- }
-
- CAtlList<QWORD> lens;
- QWORD tlen = 0;
- QWORD FrameSize;
- BYTE FramesInLaceLessOne;
-
- switch ((Lacing & 0x06) >> 1) {
- case 0:
- // No lacing
- lens.AddTail((pMN->m_start + pMN->m_len) - (pMN->GetPos() + tlen));
- break;
- case 1:
- // Xiph lacing
- BYTE n;
- pMN->Read(n);
- while (n-- > 0) {
- BYTE b;
- QWORD len = 0;
- do {
- pMN->Read(b);
- len += b;
- } while (b == 0xff);
- lens.AddTail(len);
- tlen += len;
- }
- lens.AddTail((pMN->m_start + pMN->m_len) - (pMN->GetPos() + tlen));
- break;
- case 2:
- // Fixed-size lacing
- pMN->Read(FramesInLaceLessOne);
- FramesInLaceLessOne++;
- FrameSize = ((pMN->m_start + pMN->m_len) - (pMN->GetPos() + tlen)) / FramesInLaceLessOne;
- while (FramesInLaceLessOne-- > 0) {
- lens.AddTail(FrameSize);
- }
- break;
- case 3:
- // EBML lacing
- pMN->Read(FramesInLaceLessOne);
-
- CLength FirstFrameSize;
- FirstFrameSize.Parse(pMN);
- lens.AddTail(FirstFrameSize);
- FramesInLaceLessOne--;
- tlen = FirstFrameSize;
-
- CSignedLength DiffSize;
- FrameSize = FirstFrameSize;
- while (FramesInLaceLessOne--) {
- DiffSize.Parse(pMN);
- FrameSize += DiffSize;
- lens.AddTail(FrameSize);
- tlen += FrameSize;
- }
- lens.AddTail((pMN->m_start + pMN->m_len) - (pMN->GetPos() + tlen));
- break;
- }
-
- POSITION pos = lens.GetHeadPosition();
- while (pos) {
- QWORD len = lens.GetNext(pos);
- CAutoPtr<CBinary> p(DEBUG_NEW CBinary());
- p->SetCount((INT_PTR)len);
- pMN->Read(p->GetData(), len);
- BlockData.AddTail(p);
- }
-
- return S_OK;
-}
-
-HRESULT BlockAdditions::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0xA6:
- bm.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT BlockMore::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0xEE:
- BlockAddID.Parse(pMN);
- break;
-case 0xA5:
- BlockAdditional.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT TimeSlice::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0xCC:
- LaceNumber.Parse(pMN);
- break;
-case 0xCD:
- FrameNumber.Parse(pMN);
- break;
-case 0xCE:
- Delay.Parse(pMN);
- break;
-case 0xCF:
- Duration.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT Cue::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0xBB:
- CuePoints.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT CuePoint::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0xB3:
- CueTime.Parse(pMN);
- break;
-case 0xB7:
- CueTrackPositions.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT CueTrackPosition::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0xF7:
- CueTrack.Parse(pMN);
- break;
-case 0xF1:
- CueClusterPosition.Parse(pMN);
- break;
-case 0x5387:
- CueBlockNumber.Parse(pMN);
- break;
-case 0xEA:
- CueCodecState.Parse(pMN);
- break;
-case 0xDB:
- CueReferences.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT CueReference::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x96:
- CueRefTime.Parse(pMN);
- break;
-case 0x97:
- CueRefCluster.Parse(pMN);
- break;
-case 0x535F:
- CueRefNumber.Parse(pMN);
- break;
-case 0xEB:
- CueRefCodecState.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT Attachment::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x61A7:
- AttachedFiles.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT AttachedFile::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x467E:
- FileDescription.Parse(pMN);
- break;
-case 0x466E:
- FileName.Parse(pMN);
- break;
-case 0x4660:
- FileMimeType.Parse(pMN);
- break;
-case 0x465C: // binary
- FileDataLen = (INT_PTR)pMN->m_len;
- FileDataPos = pMN->m_start;
- break;
-case 0x46AE:
- FileUID.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT Chapter::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x45B9:
- EditionEntries.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT EditionEntry::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0xB6:
- ChapterAtoms.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT ChapterAtom::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x73C4:
- ChapterUID.Parse(pMN);
- break;
-case 0x91:
- ChapterTimeStart.Parse(pMN);
- break;
-case 0x92:
- ChapterTimeEnd.Parse(pMN);
- break;
- // case 0x8F: // TODO
-case 0x80:
- ChapterDisplays.Parse(pMN);
- break;
-case 0xB6:
- ChapterAtoms.Parse(pMN);
- break;
-case 0x98:
- ChapterFlagHidden.Parse(pMN);
- break;
-case 0x4598:
- ChapterFlagEnabled.Parse(pMN);
- break;
- EndChunk;
-}
-
-HRESULT ChapterDisplay::Parse(CMatroskaNode* pMN0)
-{
- BeginChunk;
-case 0x85:
- ChapString.Parse(pMN);
- break;
-case 0x437C:
- ChapLanguage.Parse(pMN);
- break;
-case 0x437E:
- ChapCountry.Parse(pMN);
- break;
- EndChunk;
-}
-
-//
-
-HRESULT CBinary::Parse(CMatroskaNode* pMN)
-{
- ASSERT(pMN->m_len <= INT_MAX);
- SetCount((INT_PTR)pMN->m_len);
- return pMN->Read(GetData(), pMN->m_len);
-}
-
-bool CBinary::Compress(ContentCompression& cc)
-{
- if (cc.ContentCompAlgo == ContentCompression::ZLIB) {
- int res;
- z_stream c_stream;
-
- c_stream.zalloc = (alloc_func)0;
- c_stream.zfree = (free_func)0;
- c_stream.opaque = (voidpf)0;
-
- if (Z_OK != (res = deflateInit(&c_stream, 9))) {
- return false;
- }
-
- c_stream.next_in = GetData();
- c_stream.avail_in = (uInt)GetCount();
-
- BYTE* dst = nullptr;
- BYTE* newDst = nullptr;
- int n = 0;
- do {
- newDst = (BYTE*)realloc(dst, ++n * 10);
- if (newDst) {
- dst = newDst;
- c_stream.next_out = &dst[(n - 1) * 10];
- c_stream.avail_out = 10;
- }
- if (!newDst || (Z_OK != (res = deflate(&c_stream, Z_FINISH)) && Z_STREAM_END != res)) {
- free(dst);
- return false;
- }
- } while (0 == c_stream.avail_out && Z_STREAM_END != res);
-
- deflateEnd(&c_stream);
-
- SetCount(c_stream.total_out);
- memcpy(GetData(), dst, GetCount());
-
- free(dst);
-
- return true;
- }
-
- return false;
-}
-
-bool CBinary::Decompress(ContentCompression& cc)
-{
- if (cc.ContentCompAlgo == ContentCompression::ZLIB) {
- int res;
- z_stream d_stream;
-
- d_stream.zalloc = (alloc_func)0;
- d_stream.zfree = (free_func)0;
- d_stream.opaque = (voidpf)0;
-
- if (Z_OK != (res = inflateInit(&d_stream))) {
- return false;
- }
-
- d_stream.next_in = GetData();
- d_stream.avail_in = (uInt)GetCount();
-
- BYTE* dst = nullptr;
- BYTE* newDst = nullptr;
- int n = 0;
- do {
- newDst = (BYTE*)realloc(dst, ++n * 1000);
- if (newDst) {
- dst = newDst;
- d_stream.next_out = &dst[(n - 1) * 1000];
- d_stream.avail_out = 1000;
- }
- if (!newDst || (Z_OK != (res = inflate(&d_stream, Z_NO_FLUSH)) && Z_STREAM_END != res)) {
- free(dst);
- return false;
- }
- } while (0 == d_stream.avail_out && 0 != d_stream.avail_in && Z_STREAM_END != res);
-
- inflateEnd(&d_stream);
-
- SetCount(d_stream.total_out);
- memcpy(GetData(), dst, GetCount());
-
- free(dst);
-
- return true;
- } else if (cc.ContentCompAlgo == ContentCompression::HDRSTRIP) {
- InsertArrayAt(0, &cc.ContentCompSettings);
- }
-
- return false;
-}
-
-HRESULT CANSI::Parse(CMatroskaNode* pMN)
-{
- Empty();
-
- QWORD len = pMN->m_len;
- CHAR c;
- while (len-- > 0 && SUCCEEDED(pMN->Read(c))) {
- *this += c;
- }
-
- return (len == -1 ? S_OK : E_FAIL);
-}
-
-HRESULT CUTF8::Parse(CMatroskaNode* pMN)
-{
- Empty();
- CAutoVectorPtr<BYTE> buff;
- if (!buff.Allocate((UINT)pMN->m_len + 1) || S_OK != pMN->Read(buff, pMN->m_len)) {
- return E_FAIL;
- }
- buff[pMN->m_len] = 0;
- CStringW::operator = (UTF8To16((LPCSTR)(BYTE*)buff));
- return S_OK;
-}
-
-HRESULT CUInt::Parse(CMatroskaNode* pMN)
-{
- m_val = 0;
- for (int i = 0; i < (int)pMN->m_len; i++) {
- m_val <<= 8;
- HRESULT hr = pMN->Read(*(BYTE*)&m_val);
- if (FAILED(hr)) {
- return hr;
- }
- }
- m_fValid = true;
- return S_OK;
-}
-
-HRESULT CInt::Parse(CMatroskaNode* pMN)
-{
- m_val = 0;
- for (int i = 0; i < (int)pMN->m_len; i++) {
- HRESULT hr = pMN->Read(*((BYTE*)&m_val + 7 - i));
- if (FAILED(hr)) {
- return hr;
- }
- }
- m_val >>= (8 - pMN->m_len) * 8;
- m_fValid = true;
- return S_OK;
-}
-
-HRESULT CFloat::Parse(CMatroskaNode* pMN)
-{
- HRESULT hr = E_FAIL;
- m_val = 0;
-
- if (pMN->m_len == 4) {
- float val = 0;
- hr = pMN->Read(val);
- m_val = val;
- } else if (pMN->m_len == 8) {
- hr = pMN->Read(m_val);
- }
- if (SUCCEEDED(hr)) {
- m_fValid = true;
- }
- return hr;
-}
-
-
-template<class T, class BASE>
-HRESULT CSimpleVar<T, BASE>::Parse(CMatroskaNode* pMN)
-{
- m_val = 0;
- m_fValid = true;
- return pMN->Read(m_val);
-}
-
-HRESULT CID::Parse(CMatroskaNode* pMN)
-{
- m_val = 0;
-
- BYTE b = 0;
- HRESULT hr = pMN->Read(b);
- if (FAILED(hr)) {
- return hr;
- }
-
- int nMoreBytes = 0;
-
- if ((b & 0x80) == 0x80) {
- m_val = b & 0xff;
- nMoreBytes = 0;
- } else if ((b & 0xc0) == 0x40) {
- m_val = b & 0x7f;
- nMoreBytes = 1;
- } else if ((b & 0xe0) == 0x20) {
- m_val = b & 0x3f;
- nMoreBytes = 2;
- } else if ((b & 0xf0) == 0x10) {
- m_val = b & 0x1f;
- nMoreBytes = 3;
- } else {
- return E_FAIL;
- }
-
- while (nMoreBytes-- > 0) {
- m_val <<= 8;
- hr = pMN->Read(*(BYTE*)&m_val);
- if (FAILED(hr)) {
- return hr;
- }
- }
-
- m_fValid = true;
-
- return S_OK;
-}
-
-HRESULT CLength::Parse(CMatroskaNode* pMN)
-{
- m_val = 0;
-
- BYTE b = 0;
- HRESULT hr = pMN->Read(b);
- if (FAILED(hr)) {
- return hr;
- }
-
- int nMoreBytes = 0;
-
- if ((b & 0x80) == 0x80) {
- m_val = b & 0x7f;
- nMoreBytes = 0;
- } else if ((b & 0xc0) == 0x40) {
- m_val = b & 0x3f;
- nMoreBytes = 1;
- } else if ((b & 0xe0) == 0x20) {
- m_val = b & 0x1f;
- nMoreBytes = 2;
- } else if ((b & 0xf0) == 0x10) {
- m_val = b & 0x0f;
- nMoreBytes = 3;
- } else if ((b & 0xf8) == 0x08) {
- m_val = b & 0x07;
- nMoreBytes = 4;
- } else if ((b & 0xfc) == 0x04) {
- m_val = b & 0x03;
- nMoreBytes = 5;
- } else if ((b & 0xfe) == 0x02) {
- m_val = b & 0x01;
- nMoreBytes = 6;
- } else if ((b & 0xff) == 0x01) {
- m_val = b & 0x00;
- nMoreBytes = 7;
- } else {
- return E_FAIL;
- }
-
- //int nMoreBytesTmp = nMoreBytes;
-
- QWORD UnknownSize = (1i64 << (7 * (nMoreBytes + 1))) - 1;
-
- while (nMoreBytes-- > 0) {
- m_val <<= 8;
- hr = pMN->Read(*(BYTE*)&m_val);
- if (FAILED(hr)) {
- return hr;
- }
- }
-
- if (m_val == UnknownSize) {
- m_val = pMN->GetLength() - pMN->GetPos();
- TRACE(_T("CLength: Unspecified chunk size at %I64d (corrected to %I64d)\n"), pMN->GetPos(), m_val);
- }
-
- if (m_fSigned) {
- m_val -= (UnknownSize >> 1);
- }
-
- m_fValid = true;
-
- return S_OK;
-}
-/*
-HRESULT CSignedLength::Parse(CMatroskaNode* pMN)
-{
-// HRESULT hr = __super::Parse(pMN);
-// if (FAILED(hr)) return hr;
-
- m_val = 0;
-
- BYTE b = 0;
- HRESULT hr = pMN->Read(b);
- if (FAILED(hr)) return hr;
-
- int nMoreBytes = 0;
-
- if ((b&0x80) == 0x80) {m_val = b&0x7f; nMoreBytes = 0;}
- else if ((b&0xc0) == 0x40) {m_val = b&0x3f; nMoreBytes = 1;}
- else if ((b&0xe0) == 0x20) {m_val = b&0x1f; nMoreBytes = 2;}
- else if ((b&0xf0) == 0x10) {m_val = b&0x0f; nMoreBytes = 3;}
- else if ((b&0xf8) == 0x08) {m_val = b&0x07; nMoreBytes = 4;}
- else if ((b&0xfc) == 0x04) {m_val = b&0x03; nMoreBytes = 5;}
- else if ((b&0xfe) == 0x02) {m_val = b&0x01; nMoreBytes = 6;}
- else if ((b&0xff) == 0x01) {m_val = b&0x00; nMoreBytes = 7;}
- else return E_FAIL;
-
- //int nMoreBytesTmp = nMoreBytes;
-
- QWORD UnknownSize = (1i64<<(7*(nMoreBytes+1)))-1;
-
- while (nMoreBytes-- > 0)
- {
- m_val <<= 8;
- hr = pMN->Read(*(BYTE*)&m_val);
- if (FAILED(hr)) return hr;
- }
-
- if (m_val == UnknownSize)
- {
- m_val = pMN->GetLength() - pMN->GetPos();
- TRACE(_T("CLength: Unspecified chunk size at %I64d (corrected to %I64d)\n"), pMN->GetPos(), m_val);
- }
-
- m_val -= (UnknownSize >> 1);
-
- m_fValid = true;
-
- return S_OK;
-}
-*/
-template<class T>
-HRESULT CNode<T>::Parse(CMatroskaNode* pMN)
-{
- CAutoPtr<T> p(DEBUG_NEW T());
- HRESULT hr = E_OUTOFMEMORY;
- if (!p || FAILED(hr = p->Parse(pMN))) {
- return hr;
- }
- AddTail(p);
- return S_OK;
-}
-
-HRESULT CBlockGroupNode::Parse(CMatroskaNode* pMN, bool fFull)
-{
- CAutoPtr<BlockGroup> p(DEBUG_NEW BlockGroup());
- HRESULT hr = E_OUTOFMEMORY;
- if (!p || FAILED(hr = p->Parse(pMN, fFull))) {
- return hr;
- }
- AddTail(p);
- return S_OK;
-}
-
-HRESULT CSimpleBlockNode::Parse(CMatroskaNode* pMN, bool fFull)
-{
- CAutoPtr<SimpleBlock> p(DEBUG_NEW SimpleBlock());
- HRESULT hr = E_OUTOFMEMORY;
- if (!p || FAILED(hr = p->Parse(pMN, fFull))) {
- return hr;
- }
- AddTail(p);
- return S_OK;
-}
-
-///////////////////////////////
-
-CMatroskaNode::CMatroskaNode(CMatroskaFile* pMF)
- : m_pMF(pMF)
- , m_pParent(nullptr)
-{
- ASSERT(m_pMF);
- m_start = m_filepos = 0;
- m_len.Set(m_pMF ? m_pMF->GetLength() : 0);
-}
-
-CMatroskaNode::CMatroskaNode(CMatroskaNode* pParent)
- : m_pMF(pParent->m_pMF)
- , m_pParent(pParent)
-{
- Parse();
-}
-
-HRESULT CMatroskaNode::Parse()
-{
- m_filepos = GetPos();
- if (FAILED(m_id.Parse(this)) || FAILED(m_len.Parse(this))) {
- return E_FAIL;
- }
- m_start = GetPos();
- return S_OK;
-}
-
-CAutoPtr<CMatroskaNode> CMatroskaNode::Child(DWORD id, bool fSearch)
-{
- if (m_len == 0) {
- return CAutoPtr<CMatroskaNode>();
- }
- SeekTo(m_start);
- CAutoPtr<CMatroskaNode> pMN(DEBUG_NEW CMatroskaNode(this));
- if (id && !pMN->Find(id, fSearch)) {
- pMN.Free();
- }
- return pMN;
-}
-
-bool CMatroskaNode::Next(bool fSame)
-{
- if (!m_pParent) {
- return false;
- }
-
- CID id = m_id;
-
- while (m_start + m_len < m_pParent->m_start + m_pParent->m_len) {
- SeekTo(m_start + m_len);
-
- if (FAILED(Parse())) {
- if (!Resync()) {
- return false;
- }
- }
-
- if (!fSame || m_id == id) {
- return true;
- }
- }
-
- return false;
-}
-
-bool CMatroskaNode::Find(DWORD id, bool fSearch)
-{
- QWORD pos = m_pParent && m_pParent->m_id == 0x18538067 /*segment?*/
- ? FindPos(id)
- : 0;
-
- if (pos) {
- SeekTo(pos);
- Parse();
- } else if (fSearch) {
- while (m_id != id && Next()) {
- ;
- }
- }
-
- return (m_id == id);
-}
-
-void CMatroskaNode::SeekTo(QWORD pos)
-{
- m_pMF->Seek(pos);
-}
-
-QWORD CMatroskaNode::GetPos()
-{
- return m_pMF->GetPos();
-}
-
-QWORD CMatroskaNode::GetLength()
-{
- return m_pMF->GetLength();
-}
-
-template <class T>
-HRESULT CMatroskaNode::Read(T& var)
-{
- return m_pMF->Read(var);
-}
-
-HRESULT CMatroskaNode::Read(BYTE* pData, QWORD len)
-{
- return m_pMF->ByteRead(pData, len);
-}
-
-QWORD CMatroskaNode::FindPos(DWORD id, QWORD start)
-{
- Segment& sm = m_pMF->m_segment;
-
- POSITION pos = sm.MetaSeekInfo.GetHeadPosition();
- while (pos) {
- Seek* s = sm.MetaSeekInfo.GetNext(pos);
-
- POSITION pos2 = s->SeekHeads.GetHeadPosition();
- while (pos2) {
- SeekHead* sh = s->SeekHeads.GetNext(pos2);
- if (sh->SeekID == id && sh->SeekPosition + sm.pos >= start) {
- return sh->SeekPosition + sm.pos;
- }
- }
- }
-
- return 0;
-}
-
-CAutoPtr<CMatroskaNode> CMatroskaNode::Copy()
-{
- CAutoPtr<CMatroskaNode> pNewNode(DEBUG_NEW CMatroskaNode(m_pMF));
- pNewNode->m_pParent = m_pParent;
- pNewNode->m_id.Set(m_id);
- pNewNode->m_len.Set(m_len);
- pNewNode->m_filepos = m_filepos;
- pNewNode->m_start = m_start;
- return pNewNode;
-}
-
-CAutoPtr<CMatroskaNode> CMatroskaNode::GetFirstBlock()
-{
- CAutoPtr<CMatroskaNode> pNode = Child();
- do {
- if (pNode->m_id == 0xA0 || pNode->m_id == 0xA3) {
- return pNode;
- }
- } while (pNode->Next());
- return CAutoPtr<CMatroskaNode>();
-}
-
-bool CMatroskaNode::NextBlock()
-{
- if (!m_pParent) {
- return false;
- }
-
- CID id = m_id;
-
- while (m_start + m_len < m_pParent->m_start + m_pParent->m_len) {
- SeekTo(m_start + m_len);
-
- if (FAILED(Parse())) {
- if (!Resync()) {
- return false;
- }
- }
-
- if (m_id == 0xA0 || m_id == 0xA3) {
- return true;
- }
- }
-
- return false;
-}
-
-bool CMatroskaNode::Resync()
-{
- if (m_pParent->m_id == 0x18538067) { /*segment?*/
- SeekTo(m_filepos);
-
- for (BYTE b = 0; S_OK == Read(b); b = 0) {
- if ((b & 0xf0) != 0x10) {
- continue;
- }
-
- DWORD dw = b;
- Read((BYTE*)&dw + 1, 3);
- bswap((BYTE*)&dw, 4);
-
- switch (dw) {
- case 0x1549A966: // SegmentInfo
- case 0x114D9B74: // MetaSeekInfo
- case 0x1654AE6B: // Tracks
- case 0x1F43B675: // Clusters
- case 0x1C53BB6B: // Cues
- case 0x1941A469: // Attachments
- case 0x1043A770: // Chapters
- case 0x1254C367: // Tags
- SeekTo(GetPos() - 4);
- return SUCCEEDED(Parse());
- default:
- SeekTo(GetPos() - 3);
- break;
- }
- }
- }
-
- return false;
-}
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaFile.h b/src/filters/parser/MatroskaSplitter/MatroskaFile.h
deleted file mode 100644
index 9ef8995ca..000000000
--- a/src/filters/parser/MatroskaSplitter/MatroskaFile.h
+++ /dev/null
@@ -1,593 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <atlbase.h>
-#include <atlcoll.h>
-#include "../BaseSplitter/BaseSplitter.h"
-
-namespace MatroskaReader
-{
- class CMatroskaNode;
-
- class CANSI : public CStringA
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN);
- };
- class CUTF8 : public CStringW
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- template<class T, class BASE>
- class CSimpleVar
- {
- protected:
- T m_val;
- bool m_fValid;
- public:
- CSimpleVar(T val = 0) : m_val(val), m_fValid(false) {}
- BASE& operator = (const BASE& v) {
- m_val = v.m_val;
- m_fValid = true;
- return *this;
- }
- BASE& operator = (T val) {
- m_val = val;
- m_fValid = true;
- return *this;
- }
- operator T() const {
- return m_val;
- }
- BASE& Set(T val) {
- m_val = val;
- m_fValid = true;
- return (*(BASE*)this);
- }
- bool IsValid() const {
- return m_fValid;
- }
- virtual HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class CUInt : public CSimpleVar<UINT64, CUInt>
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN);
- };
- class CInt : public CSimpleVar<INT64, CInt>
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN);
- };
- class CByte : public CSimpleVar<BYTE, CByte> {};
- class CShort : public CSimpleVar<short, CShort> {};
- class CFloat : public CSimpleVar<double, CFloat>
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN);
- };
- class CID : public CSimpleVar<DWORD, CID>
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN);
- };
- class CLength : public CSimpleVar<UINT64, CLength>
- {
- bool m_fSigned;
- public:
- CLength(bool fSigned = false) : m_fSigned(fSigned) {} HRESULT Parse(CMatroskaNode* pMN);
- };
- class CSignedLength : public CLength
- {
- public:
- CSignedLength() : CLength(true) {}
- };
-
- class ContentCompression;
-
- class CBinary : public CAtlArray<BYTE>
- {
- public:
- CBinary& operator = (const CBinary& b) {
- Copy(b);
- return *this;
- }
- CStringA ToString() {
- return CStringA((LPCSTR)GetData(), (int)GetCount());
- }
- bool Compress(ContentCompression& cc), Decompress(ContentCompression& cc);
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- template<class T>
- class CNode : public CAutoPtrList<T>
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class EBML
- {
- public:
- CUInt EBMLVersion, EBMLReadVersion;
- CUInt EBMLMaxIDLength, EBMLMaxSizeLength;
- CANSI DocType;
- CUInt DocTypeVersion, DocTypeReadVersion;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class Info
- {
- public:
- CBinary SegmentUID, PrevUID, NextUID;
- CUTF8 SegmentFilename, PrevFilename, NextFilename;
- CUInt TimeCodeScale; // [ns], default: 1.000.000
- CFloat Duration;
- CInt DateUTC;
- CUTF8 Title, MuxingApp, WritingApp;
-
- Info() { TimeCodeScale.Set(1000000ui64); }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class SeekHead
- {
- public:
- CID SeekID;
- CUInt SeekPosition;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class Seek
- {
- public:
- CNode<SeekHead> SeekHeads;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class TimeSlice
- {
- public:
- CUInt LaceNumber, FrameNumber;
- CUInt Delay, Duration;
-
- TimeSlice() {
- LaceNumber.Set(0);
- FrameNumber.Set(0);
- Delay.Set(0);
- Duration.Set(0);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class SimpleBlock
- {
- public:
- CLength TrackNumber;
- CInt TimeCode;
- CByte Lacing;
- CAutoPtrList<CBinary> BlockData;
-
- HRESULT Parse(CMatroskaNode* pMN, bool fFull);
- };
-
- class BlockMore
- {
- public:
- CInt BlockAddID;
- CBinary BlockAdditional;
-
- BlockMore() { BlockAddID.Set(1); }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class BlockAdditions
- {
- public:
- CNode<BlockMore> bm;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class BlockGroup
- {
- public:
- SimpleBlock Block;
- //BlockVirtual
- CUInt BlockDuration;
- CUInt ReferencePriority;
- CInt ReferenceBlock;
- CInt ReferenceVirtual;
- CBinary CodecState;
- CNode<TimeSlice> TimeSlices;
- BlockAdditions ba;
-
- HRESULT Parse(CMatroskaNode* pMN, bool fFull);
- };
-
- class CBlockGroupNode : public CNode<BlockGroup>
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN, bool fFull);
- };
-
- class CSimpleBlockNode : public CNode<SimpleBlock>
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN, bool fFull);
- };
-
- class Cluster
- {
- public:
- CUInt TimeCode, Position, PrevSize;
- CBlockGroupNode BlockGroups;
- CSimpleBlockNode SimpleBlocks;
-
- HRESULT Parse(CMatroskaNode* pMN);
- HRESULT ParseTimeCode(CMatroskaNode* pMN);
- };
-
- class Video
- {
- public:
- CUInt FlagInterlaced, StereoMode;
- CUInt PixelWidth, PixelHeight, DisplayWidth, DisplayHeight, DisplayUnit;
- CUInt VideoPixelCropBottom, VideoPixelCropTop, VideoPixelCropLeft, VideoPixelCropRight;
- CUInt AspectRatioType;
- CUInt ColourSpace;
- CFloat GammaValue;
- CFloat FramePerSec;
-
- Video() {
- FlagInterlaced.Set(0);
- StereoMode.Set(0);
- DisplayUnit.Set(0);
- AspectRatioType.Set(0);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class Audio
- {
- public:
- CFloat SamplingFrequency;
- CFloat OutputSamplingFrequency;
- CUInt Channels;
- CBinary ChannelPositions;
- CUInt BitDepth;
-
- Audio() {
- SamplingFrequency.Set(8000.0);
- Channels.Set(1);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class ContentCompression
- {
- public:
- CUInt ContentCompAlgo;
- enum { ZLIB, BZLIB, LZO1X, HDRSTRIP };
- CBinary ContentCompSettings;
-
- ContentCompression() { ContentCompAlgo.Set(ZLIB); }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class ContentEncryption
- {
- public:
- CUInt ContentEncAlgo;
- enum { UNKE, DES, THREEDES, TWOFISH, BLOWFISH, AES };
- CBinary ContentEncKeyID, ContentSignature, ContentSigKeyID;
- CUInt ContentSigAlgo;
- enum { UNKS, RSA };
- CUInt ContentSigHashAlgo;
- enum { UNKSH, SHA1_160, MD5 };
-
- ContentEncryption() {
- ContentEncAlgo.Set(0);
- ContentSigAlgo.Set(0);
- ContentSigHashAlgo.Set(0);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class ContentEncoding
- {
- public:
- CUInt ContentEncodingOrder;
- CUInt ContentEncodingScope;
- enum { AllFrameContents = 1, TracksPrivateData = 2 };
- CUInt ContentEncodingType;
- enum { Compression, Encryption };
- ContentCompression cc;
- ContentEncryption ce;
-
- ContentEncoding() {
- ContentEncodingOrder.Set(0);
- ContentEncodingScope.Set(AllFrameContents);
- ContentEncodingType.Set(Compression);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class ContentEncodings
- {
- public:
- CNode<ContentEncoding> ce;
-
- ContentEncodings() {}
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class TrackEntry
- {
- public:
- enum { TypeVideo = 1,
- TypeAudio = 2,
- TypeComplex = 3,
- TypeLogo = 0x10,
- TypeSubtitle = 0x11,
- TypeControl = 0x20
- };
- CUInt TrackNumber, TrackUID, TrackType;
- CUInt FlagEnabled, FlagDefault, FlagLacing, FlagForced;
- CUInt MinCache, MaxCache;
- CUTF8 Name;
- CANSI Language;
- CBinary CodecID;
- CBinary CodecPrivate;
- CUTF8 CodecName;
- CUTF8 CodecSettings;
- CANSI CodecInfoURL;
- CANSI CodecDownloadURL;
- CUInt CodecDecodeAll;
- CUInt TrackOverlay;
- CUInt DefaultDuration;
- CUInt MaxBlockAdditionID;
- CFloat TrackTimecodeScale;
- enum { NoDesc = 0, DescVideo = 1, DescAudio = 2 };
- unsigned int DescType;
- Video v;
- Audio a;
- ContentEncodings ces;
- TrackEntry() {
- DescType = NoDesc;
- FlagEnabled.Set(1);
- FlagDefault.Set(1);
- FlagLacing.Set(1);
- FlagForced.Set(0);
- MinCache.Set(0);
- TrackTimecodeScale.Set(1.0f);
- Language.CStringA::operator = ("eng");
- MaxBlockAdditionID.Set(0);
- CodecDecodeAll.Set(1);
- }
- HRESULT Parse(CMatroskaNode* pMN);
-
- bool Expand(CBinary& data, UINT64 Scope);
- };
-
- class Track
- {
- public:
- CNode<TrackEntry> TrackEntries;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class CueReference
- {
- public:
- CUInt CueRefTime, CueRefCluster, CueRefNumber, CueRefCodecState;
-
- CueReference() {
- CueRefNumber.Set(1);
- CueRefCodecState.Set(0);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class CueTrackPosition
- {
- public:
- CUInt CueTrack, CueClusterPosition, CueBlockNumber, CueCodecState;
- CNode<CueReference> CueReferences;
-
- CueTrackPosition() {
- CueBlockNumber.Set(1);
- CueCodecState.Set(0);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class CuePoint
- {
- public:
- CUInt CueTime;
- CNode<CueTrackPosition> CueTrackPositions;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class Cue
- {
- public:
- CNode<CuePoint> CuePoints;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class AttachedFile
- {
- public:
- CUTF8 FileDescription;
- CUTF8 FileName;
- CANSI FileMimeType;
- QWORD FileDataPos, FileDataLen; // BYTE* FileData
- CUInt FileUID;
-
- AttachedFile() { FileDataPos = FileDataLen = 0; }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class Attachment
- {
- public:
- CNode<AttachedFile> AttachedFiles;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class ChapterDisplay
- {
- public:
- CUTF8 ChapString;
- CANSI ChapLanguage;
- CANSI ChapCountry;
-
- ChapterDisplay() { ChapLanguage.CStringA::operator = ("eng"); }
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class ChapterAtom
- {
- public:
- CUInt ChapterUID;
- CUInt ChapterTimeStart, ChapterTimeEnd, ChapterFlagHidden, ChapterFlagEnabled;
- //CNode<CUInt> ChapterTracks; // TODO
- CNode<ChapterDisplay> ChapterDisplays;
- CNode<ChapterAtom> ChapterAtoms;
-
- ChapterAtom() {
- ChapterUID.Set(0);// 0 = not set (ChapUID zero not allow by Matroska specs)
- ChapterFlagHidden.Set(0);
- ChapterFlagEnabled.Set(1);
- }
- HRESULT Parse(CMatroskaNode* pMN);
- ChapterAtom* FindChapterAtom(UINT64 id);
- };
-
- class EditionEntry : public ChapterAtom
- {
- public:
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class Chapter
- {
- public:
- CNode<EditionEntry> EditionEntries;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class Segment
- {
- public:
- QWORD pos, len;
- Info SegmentInfo;
- CNode<Seek> MetaSeekInfo;
- CNode<Cluster> Clusters;
- CNode<Track> Tracks;
- CNode<Cue> Cues;
- CNode<Attachment> Attachments;
- CNode<Chapter> Chapters;
- // TODO: Chapters
- // TODO: Tags
-
- HRESULT Parse(CMatroskaNode* pMN);
- HRESULT ParseMinimal(CMatroskaNode* pMN);
-
- UINT64 GetMasterTrack();
-
- REFERENCE_TIME GetRefTime(INT64 t) const {
- return t * (REFERENCE_TIME)(SegmentInfo.TimeCodeScale) / 100;
- }
- ChapterAtom* FindChapterAtom(UINT64 id, int nEditionEntry = 0);
- };
-
- class CMatroskaFile : public CBaseSplitterFile
- {
- public:
- CMatroskaFile(IAsyncReader* pAsyncReader, HRESULT& hr);
- virtual ~CMatroskaFile() {}
-
- HRESULT Init();
-
- //using CBaseSplitterFile::Read;
- template <class T> HRESULT Read(T& var);
-
- EBML m_ebml;
- Segment m_segment;
- REFERENCE_TIME m_rtOffset;
-
- HRESULT Parse(CMatroskaNode* pMN);
- };
-
- class CMatroskaNode
- {
- CMatroskaNode* m_pParent;
- CMatroskaFile* m_pMF;
-
- bool Resync();
-
- public:
- CID m_id;
- CLength m_len;
- QWORD m_filepos, m_start;
-
- HRESULT Parse();
-
- public:
- CMatroskaNode(CMatroskaFile* pMF); // creates the root
- CMatroskaNode(CMatroskaNode* pParent);
-
- CMatroskaNode* Parent() { return m_pParent; }
- CAutoPtr<CMatroskaNode> Child(DWORD id = 0, bool fSearch = true);
- bool Next(bool fSame = false);
- bool Find(DWORD id, bool fSearch = true);
-
- QWORD FindPos(DWORD id, QWORD start = 0);
-
- void SeekTo(QWORD pos);
- QWORD GetPos(), GetLength();
- template <class T> HRESULT Read(T& var);
- HRESULT Read(BYTE* pData, QWORD len);
-
- CAutoPtr<CMatroskaNode> Copy();
-
- CAutoPtr<CMatroskaNode> GetFirstBlock();
- bool NextBlock();
-
- bool IsRandomAccess() { return m_pMF->IsRandomAccess(); }
- };
-}
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp
deleted file mode 100644
index 9909ac57f..000000000
--- a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp
+++ /dev/null
@@ -1,1687 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <MMReg.h>
-#include "MatroskaSplitter.h"
-#include "../../../DSUtil/AudioParser.h"
-
-#ifdef STANDALONE_FILTER
-#include <InitGuid.h>
-#endif
-#include "moreuuids.h"
-#include <vector>
-
-using namespace MatroskaReader;
-
-#ifdef STANDALONE_FILTER
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_Matroska},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL}
-};
-
-const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, 0, nullptr}
-};
-
-const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CMatroskaSplitterFilter), MatroskaSplitterName, MERIT_NORMAL, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CMatroskaSourceFilter), MatroskaSourceName, MERIT_NORMAL, 0, nullptr, CLSID_LegacyAmFilterCategory},
-};
-
-CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMatroskaSplitterFilter>, nullptr, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CMatroskaSourceFilter>, nullptr, &sudFilter[1]},
-};
-
-int g_cTemplates = _countof(g_Templates);
-
-STDAPI DllRegisterServer()
-{
- RegisterSourceFilter(
- __uuidof(CMatroskaSourceFilter),
- MEDIASUBTYPE_Matroska,
- _T("0,4,,1A45DFA3"),
- _T(".mkv"), _T(".mka"), _T(".mks"), nullptr);
-
- return AMovieDllRegisterServer2(TRUE);
-}
-
-STDAPI DllUnregisterServer()
-{
- UnRegisterSourceFilter(MEDIASUBTYPE_Matroska);
-
- return AMovieDllRegisterServer2(FALSE);
-}
-
-#include "../../FilterApp.h"
-
-CFilterApp theApp;
-
-#endif
-
-//
-// CMatroskaSplitterFilter
-//
-
-CMatroskaSplitterFilter::CMatroskaSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("CMatroskaSplitterFilter"), pUnk, phr, __uuidof(this))
-{
-}
-
-CMatroskaSplitterFilter::~CMatroskaSplitterFilter()
-{
-}
-
-STDMETHODIMP CMatroskaSplitterFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
-{
- CheckPointer(ppv, E_POINTER);
-
- return
- QI(ITrackInfo)
- __super::NonDelegatingQueryInterface(riid, ppv);
-}
-
-STDMETHODIMP CMatroskaSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo)
-{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
-
- if (m_pName && m_pName[0] == L'M' && m_pName[1] == L'P' && m_pName[2] == L'C') {
- (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
- wcscpy_s(pInfo->achName, MatroskaSourceName);
- }
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
-}
-
-HRESULT CMatroskaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
-{
- CheckPointer(pAsyncReader, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- m_pFile.Free();
- m_pTrackEntryMap.RemoveAll();
- m_pOrderedTrackArray.RemoveAll();
-
- CAtlArray<CMatroskaSplitterOutputPin*> pinOut;
- CAtlArray<TrackEntry*> pinOutTE;
-
- m_pFile.Attach(DEBUG_NEW CMatroskaFile(pAsyncReader, hr));
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration = 0;
-
- int iVideo = 1, iAudio = 1, iSubtitle = 1;
- bool bHasVideo = 0;
-
- POSITION pos = m_pFile->m_segment.Tracks.GetHeadPosition();
- while (pos) {
- Track* pT = m_pFile->m_segment.Tracks.GetNext(pos);
-
- POSITION pos2 = pT->TrackEntries.GetHeadPosition();
- while (pos2) {
- TrackEntry* pTE = pT->TrackEntries.GetNext(pos2);
-
- bool isSub = false;
-
- if (!pTE->Expand(pTE->CodecPrivate, ContentEncoding::TracksPrivateData)) {
- continue;
- }
-
- CStringA CodecID = pTE->CodecID.ToString();
-
- CStringW Name;
- Name.Format(L"Output %I64u", (UINT64)pTE->TrackNumber);
-
- CMediaType mt;
- CAtlArray<CMediaType> mts;
-
- mt.SetSampleSize(1);
-
- if (pTE->TrackType == TrackEntry::TypeVideo) {
- Name.Format(L"Video %d", iVideo++);
-
- mt.majortype = MEDIATYPE_Video;
-
- if (CodecID == "V_MS/VFW/FOURCC") {
- mt.formattype = FORMAT_VideoInfo;
- VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + pTE->CodecPrivate.GetCount() - sizeof(BITMAPINFOHEADER));
- ZeroMemory(mt.Format(), mt.FormatLength());
- memcpy(&pvih->bmiHeader, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- mt.subtype = FOURCCMap(pvih->bmiHeader.biCompression);
- switch (pvih->bmiHeader.biCompression) {
- case BI_RGB:
- case BI_BITFIELDS:
- mt.subtype =
- pvih->bmiHeader.biBitCount == 1 ? MEDIASUBTYPE_RGB1 :
- pvih->bmiHeader.biBitCount == 4 ? MEDIASUBTYPE_RGB4 :
- pvih->bmiHeader.biBitCount == 8 ? MEDIASUBTYPE_RGB8 :
- pvih->bmiHeader.biBitCount == 16 ? MEDIASUBTYPE_RGB565 :
- pvih->bmiHeader.biBitCount == 24 ? MEDIASUBTYPE_RGB24 :
- pvih->bmiHeader.biBitCount == 32 ? MEDIASUBTYPE_ARGB32 :
- MEDIASUBTYPE_NULL;
- break;
- // case BI_RLE8: mt.subtype = MEDIASUBTYPE_RGB8; break;
- // case BI_RLE4: mt.subtype = MEDIASUBTYPE_RGB4; break;
- }
- if (!bHasVideo) {
- mts.Add(mt);
- if (mt.subtype == MEDIASUBTYPE_WVC1) {
- mt.subtype = MEDIASUBTYPE_WVC1_CYBERLINK;
- mts.Add(mt);
- }
- }
- bHasVideo = true;
- } else if (CodecID == "V_UNCOMPRESSED") {
- } else if (CodecID.Find("V_MPEG4/ISO/AVC") == 0 && pTE->CodecPrivate.GetCount() >= 6) {
- BYTE sps = pTE->CodecPrivate[5] & 0x1f;
-
- std::vector<BYTE> avcC;
- for (size_t i = 0, j = pTE->CodecPrivate.GetCount(); i < j; i++) {
- avcC.push_back(pTE->CodecPrivate[i]);
- }
-
- std::vector<BYTE> sh;
-
- unsigned jj = 6;
-
- while (sps--) {
- if (jj + 2 > avcC.size()) {
- goto avcfail;
- }
- unsigned spslen = ((unsigned)avcC[jj] << 8) | avcC[jj + 1];
- if (jj + 2 + spslen > avcC.size()) {
- goto avcfail;
- }
- unsigned cur = sh.size();
- sh.resize(cur + spslen + 2, 0);
- std::copy(avcC.begin() + jj, avcC.begin() + jj + 2 + spslen, sh.begin() + cur);
- jj += 2 + spslen;
- }
-
- if (jj + 1 > avcC.size()) {
- continue;
- }
-
- unsigned pps = avcC[jj++];
-
- while (pps--) {
- if (jj + 2 > avcC.size()) {
- goto avcfail;
- }
- unsigned ppslen = ((unsigned)avcC[jj] << 8) | avcC[jj + 1];
- if (jj + 2 + ppslen > avcC.size()) {
- goto avcfail;
- }
- unsigned cur = sh.size();
- sh.resize(cur + ppslen + 2, 0);
- std::copy(avcC.begin() + jj, avcC.begin() + jj + 2 + ppslen, sh.begin() + cur);
- jj += 2 + ppslen;
- }
-
- goto avcsuccess;
-avcfail:
- continue;
-avcsuccess:
-
- CAtlArray<BYTE> data;
- data.SetCount(sh.size());
- std::copy(sh.begin(), sh.end(), data.GetData());
-
- mt.subtype = FOURCCMap('1CVA');
- mt.formattype = FORMAT_MPEG2Video;
- MPEG2VIDEOINFO* pm2vi = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + data.GetCount());
- ZeroMemory(mt.Format(), mt.FormatLength());
- pm2vi->hdr.bmiHeader.biSize = sizeof(pm2vi->hdr.bmiHeader);
- pm2vi->hdr.bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
- pm2vi->hdr.bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
- pm2vi->hdr.bmiHeader.biCompression = '1CVA';
- pm2vi->hdr.bmiHeader.biPlanes = 1;
- pm2vi->hdr.bmiHeader.biBitCount = 24;
- pm2vi->dwProfile = pTE->CodecPrivate[1];
- pm2vi->dwLevel = pTE->CodecPrivate[3];
- pm2vi->dwFlags = (pTE->CodecPrivate[4] & 3) + 1;
- BYTE* pSequenceHeader = (BYTE*)pm2vi->dwSequenceHeader;
- memcpy(pSequenceHeader, data.GetData(), data.GetCount());
- pm2vi->cbSequenceHeader = (DWORD)data.GetCount();
- if (!bHasVideo) {
- mts.Add(mt);
- }
- bHasVideo = true;
- } else if (CodecID.Find("V_MPEG4/") == 0) {
- mt.subtype = FOURCCMap('V4PM');
- mt.formattype = FORMAT_MPEG2Video;
- MPEG2VIDEOINFO* pm2vi = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + pTE->CodecPrivate.GetCount());
- ZeroMemory(mt.Format(), mt.FormatLength());
- pm2vi->hdr.bmiHeader.biSize = sizeof(pm2vi->hdr.bmiHeader);
- pm2vi->hdr.bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
- pm2vi->hdr.bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
- pm2vi->hdr.bmiHeader.biCompression = 'V4PM';
- pm2vi->hdr.bmiHeader.biPlanes = 1;
- pm2vi->hdr.bmiHeader.biBitCount = 24;
- BYTE* pSequenceHeader = (BYTE*)pm2vi->dwSequenceHeader;
- memcpy(pSequenceHeader, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- pm2vi->cbSequenceHeader = (DWORD)pTE->CodecPrivate.GetCount();
- if (!bHasVideo) {
- mts.Add(mt);
- }
- bHasVideo = true;
- } else if (CodecID.Find("V_REAL/RV") == 0) {
- mt.subtype = FOURCCMap('00VR' + ((CodecID[9] - 0x30) << 16));
- mt.formattype = FORMAT_VideoInfo;
- VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + pTE->CodecPrivate.GetCount());
- ZeroMemory(mt.Format(), mt.FormatLength());
- memcpy(mt.Format() + sizeof(VIDEOINFOHEADER), pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- pvih->bmiHeader.biSize = sizeof(pvih->bmiHeader);
- pvih->bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
- pvih->bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
- pvih->bmiHeader.biCompression = mt.subtype.Data1;
- if (!bHasVideo) {
- mts.Add(mt);
- }
- bHasVideo = true;
- } else if (CodecID == "V_DIRAC") {
- mt.subtype = MEDIASUBTYPE_DiracVideo;
- mt.formattype = FORMAT_DiracVideoInfo;
- DIRACINFOHEADER* dvih = (DIRACINFOHEADER*)mt.AllocFormatBuffer(FIELD_OFFSET(DIRACINFOHEADER, dwSequenceHeader) + pTE->CodecPrivate.GetCount());
- ZeroMemory(mt.Format(), mt.FormatLength());
- dvih->hdr.bmiHeader.biSize = sizeof(dvih->hdr.bmiHeader);
- dvih->hdr.bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
- dvih->hdr.bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
- dvih->hdr.dwPictAspectRatioX = dvih->hdr.bmiHeader.biWidth;
- dvih->hdr.dwPictAspectRatioY = dvih->hdr.bmiHeader.biHeight;
-
- BYTE* pSequenceHeader = (BYTE*)dvih->dwSequenceHeader;
- memcpy(pSequenceHeader, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- dvih->cbSequenceHeader = (DWORD)pTE->CodecPrivate.GetCount();
-
- if (!bHasVideo) {
- mts.Add(mt);
- }
- bHasVideo = true;
- } else if (CodecID == "V_MPEG2") {
- BYTE* seqhdr = pTE->CodecPrivate.GetData();
- DWORD len = (DWORD)pTE->CodecPrivate.GetCount();
- int w = (int)pTE->v.PixelWidth;
- int h = (int)pTE->v.PixelHeight;
-
- if (MakeMPEG2MediaType(mt, seqhdr, len, w, h)) {
- if (!bHasVideo) {
- mts.Add(mt);
- }
- bHasVideo = true;
- }
- } else if (CodecID == "V_THEORA") {
- BYTE* thdr = pTE->CodecPrivate.GetData() + 3;
-
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = FOURCCMap('OEHT');
- mt.formattype = FORMAT_MPEG2_VIDEO;
- MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(sizeof(MPEG2VIDEOINFO) + pTE->CodecPrivate.GetCount());
- ZeroMemory(mt.Format(), mt.FormatLength());
- vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
- vih->hdr.bmiHeader.biWidth = *(WORD*)&thdr[10] >> 4;
- vih->hdr.bmiHeader.biHeight = *(WORD*)&thdr[12] >> 4;
- vih->hdr.bmiHeader.biCompression = 'OEHT';
- vih->hdr.bmiHeader.biPlanes = 1;
- vih->hdr.bmiHeader.biBitCount = 24;
- int nFpsNum = (thdr[22] << 24) | (thdr[23] << 16) | (thdr[24] << 8) | thdr[25];
- int nFpsDenum = (thdr[26] << 24) | (thdr[27] << 16) | (thdr[28] << 8) | thdr[29];
- if (nFpsNum) {
- vih->hdr.AvgTimePerFrame = (REFERENCE_TIME)(10000000.0 * nFpsDenum / nFpsNum);
- }
- vih->hdr.dwPictAspectRatioX = (thdr[14] << 16) | (thdr[15] << 8) | thdr[16];
- vih->hdr.dwPictAspectRatioY = (thdr[17] << 16) | (thdr[18] << 8) | thdr[19];
- mt.bFixedSizeSamples = 0;
-
- vih->cbSequenceHeader = (DWORD)pTE->CodecPrivate.GetCount();
- memcpy(&vih->dwSequenceHeader, pTE->CodecPrivate.GetData(), vih->cbSequenceHeader);
-
- if (!bHasVideo) {
- mts.Add(mt);
- }
- bHasVideo = true;
- } else if (CodecID.Find("V_VP8") == 0) {
- mt.subtype = FOURCCMap('08PV');
- mt.formattype = FORMAT_VideoInfo;
- VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + pTE->CodecPrivate.GetCount());
- ZeroMemory(mt.Format(), mt.FormatLength());
- memcpy(mt.Format() + sizeof(VIDEOINFOHEADER), pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- pvih->bmiHeader.biSize = sizeof(pvih->bmiHeader);
- pvih->bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
- pvih->bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
- pvih->bmiHeader.biCompression = mt.subtype.Data1;
- if (!bHasVideo) {
- mts.Add(mt);
- }
- bHasVideo = true;
- } else if (CodecID == "V_QUICKTIME" && pTE->CodecPrivate.GetCount() >= 8) {
- DWORD* type;
- if (m_pFile->m_ebml.DocTypeReadVersion == 1) {
- type = (DWORD*)(pTE->CodecPrivate.GetData());
- } else {
- type = (DWORD*)(pTE->CodecPrivate.GetData() + 4);
- }
- if (*type == MAKEFOURCC('S', 'V', 'Q', '3') || *type == MAKEFOURCC('S', 'V', 'Q', '1') || *type == MAKEFOURCC('c', 'v', 'i', 'd')) {
- mt.subtype = FOURCCMap(*type);
- mt.formattype = FORMAT_VideoInfo;
- VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + pTE->CodecPrivate.GetCount());
- ZeroMemory(mt.Format(), mt.FormatLength());
- memcpy(mt.Format() + sizeof(VIDEOINFOHEADER), pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- pvih->bmiHeader.biSize = sizeof(pvih->bmiHeader);
- pvih->bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
- pvih->bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
- pvih->bmiHeader.biCompression = mt.subtype.Data1;
- if (!bHasVideo) {
- mts.Add(mt);
- }
- bHasVideo = true;
- }
- } else if (CodecID == "V_DSHOW/MPEG1VIDEO" || CodecID == "V_MPEG1") {
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = MEDIASUBTYPE_MPEG1Payload;
- mt.formattype = FORMAT_MPEGVideo;
-
- MPEG1VIDEOINFO* pm1vi = (MPEG1VIDEOINFO*)mt.AllocFormatBuffer(sizeof(MPEG1VIDEOINFO) + pTE->CodecPrivate.GetCount());
- ZeroMemory(mt.Format(), mt.FormatLength());
- memcpy(mt.Format() + sizeof(MPEG1VIDEOINFO), pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
-
- pm1vi->hdr.bmiHeader.biSize = sizeof(pm1vi->hdr.bmiHeader);
- pm1vi->hdr.bmiHeader.biWidth = (LONG)pTE->v.PixelWidth;
- pm1vi->hdr.bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
- pm1vi->hdr.bmiHeader.biBitCount = 12;
- pm1vi->hdr.bmiHeader.biSizeImage = DIBSIZE(pm1vi->hdr.bmiHeader);
-
- mt.SetSampleSize(pm1vi->hdr.bmiHeader.biWidth * pm1vi->hdr.bmiHeader.biHeight * 4);
- if (!bHasVideo) {
- mts.Add(mt);
- }
- bHasVideo = true;
- }
- REFERENCE_TIME AvgTimePerFrame = 0;
-
- if (pTE->v.FramePerSec > 0) {
- AvgTimePerFrame = (REFERENCE_TIME)(10000000i64 / pTE->v.FramePerSec);
- } else if (pTE->DefaultDuration > 0 && pTE->DefaultDuration != 1000000) {
- AvgTimePerFrame = (REFERENCE_TIME)pTE->DefaultDuration / 100;
- } else { // pTE->DefaultDuration == 1000000 or < 0
- CMatroskaNode Root(m_pFile);
- m_pSegment = Root.Child(0x18538067);
- m_pCluster = m_pSegment->Child(0x1F43B675);
-
- QWORD lastCueClusterPosition = (QWORD) - 1;
- UINT64 timecode1 = 0;
- UINT64 timecode2 = 0;
- unsigned int framecount = 0;
- bool readmore = true;
-
- POSITION pos1 = m_pFile->m_segment.Cues.GetHeadPosition();
- while (readmore && pos1) {
- Cue* pCue = m_pFile->m_segment.Cues.GetNext(pos1);
- POSITION pos2 = pCue->CuePoints.GetHeadPosition();
- while (readmore && pos2) {
- CuePoint* pCuePoint = pCue->CuePoints.GetNext(pos2);
- POSITION pos3 = pCuePoint->CueTrackPositions.GetHeadPosition();
- while (readmore && pos3) {
- CueTrackPosition* pCueTrackPositions = pCuePoint->CueTrackPositions.GetNext(pos3);
- if (pCueTrackPositions->CueTrack != pTE->TrackNumber) {
- continue;
- }
-
- if (lastCueClusterPosition == pCueTrackPositions->CueClusterPosition) {
- continue;
- }
- lastCueClusterPosition = pCueTrackPositions->CueClusterPosition;
-
- m_pCluster->SeekTo(m_pSegment->m_start + pCueTrackPositions->CueClusterPosition);
- m_pCluster->Parse();
-
- Cluster c;
- c.ParseTimeCode(m_pCluster);
-
- if (CAutoPtr<CMatroskaNode> pBlock = m_pCluster->GetFirstBlock()) {
- do {
- CBlockGroupNode bgn;
-
- if (pBlock->m_id == 0xA0) {
- bgn.Parse(pBlock, true);
- } else if (pBlock->m_id == 0xA3) {
- CAutoPtr<BlockGroup> bg(DEBUG_NEW BlockGroup());
- bg->Block.Parse(pBlock, true);
- if (!(bg->Block.Lacing & 0x80)) {
- bg->ReferenceBlock.Set(0); // not a kf
- }
- bgn.AddTail(bg);
- }
-
- POSITION pos4 = bgn.GetHeadPosition();
- while (pos4) {
- BlockGroup* bg = bgn.GetNext(pos4);
- if (bg->Block.TrackNumber != pTE->TrackNumber) {
- continue;
- }
- UINT64 tc = c.TimeCode + bg->Block.TimeCode;
- TRACE(_T("Frame: %d, TimeCode %I64d\n"), framecount, tc);
-
- if (framecount == 0) {
- timecode1 = tc;
- timecode2 = tc;
- } else if (tc == timecode2) { // hmm
- continue;
- } else if (tc > timecode2) { // I and P frames
- if (framecount > 24) {
- // good for 23.976, 24, 25, 30, 50, 60 fps.
- // for 29.97 and 59,94 can give a small inaccuracy
- readmore = false;
- break;
- }
- timecode2 = tc;
- } //else if (tc < timecode2) {} // B-Frames
-
- framecount++;
- }
- } while (readmore && pBlock->NextBlock());
- }
- }
- }
- }
- if (framecount > 1) {
- AvgTimePerFrame = m_pFile->m_segment.SegmentInfo.TimeCodeScale * (timecode2 - timecode1) / (100 * (framecount - 1));
- }
-
- m_pCluster.Free();
- }
- //if (AvgTimePerFrame < 0) AvgTimePerFrame = 0;
-
- for (size_t i = 0; i < mts.GetCount(); i++) {
- if (mts[i].formattype == FORMAT_VideoInfo
- || mts[i].formattype == FORMAT_VideoInfo2
- || mts[i].formattype == FORMAT_MPEG2Video
- || mts[i].formattype == FORMAT_MPEGVideo) {
- if (pTE->v.PixelWidth && pTE->v.PixelHeight) {
- RECT rect = {(LONG)pTE->v.VideoPixelCropLeft,
- (LONG)pTE->v.VideoPixelCropTop,
- (LONG)(pTE->v.PixelWidth - pTE->v.VideoPixelCropRight),
- (LONG)(pTE->v.PixelHeight - pTE->v.VideoPixelCropBottom)
- };
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mts[i].Format();
- vih->rcSource = vih->rcTarget = rect;
- }
-
- if (AvgTimePerFrame) {
- if (mts[i].subtype == MEDIASUBTYPE_MPEG1Payload) {
- AvgTimePerFrame *= 2; // Need more testing, but work on all sample that i have :)
- }
- ((VIDEOINFOHEADER*)mts[i].Format())->AvgTimePerFrame = AvgTimePerFrame;
- }
- }
- }
-
- if (pTE->v.DisplayWidth && pTE->v.DisplayHeight) {
- for (size_t i = 0; i < mts.GetCount(); i++) {
- if (mts[i].formattype == FORMAT_VideoInfo) {
- mt = mts[i];
- DWORD vih1 = FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader);
- DWORD vih2 = FIELD_OFFSET(VIDEOINFOHEADER2, bmiHeader);
- DWORD bmi = mts[i].FormatLength() - FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader);
- mt.formattype = FORMAT_VideoInfo2;
- mt.AllocFormatBuffer(vih2 + bmi);
- memcpy(mt.Format(), mts[i].Format(), vih1);
- ZeroMemory(mt.Format() + vih1, vih2 - vih1);
- memcpy(mt.Format() + vih2, mts[i].Format() + vih1, bmi);
-
- CSize aspect((int)pTE->v.DisplayWidth, (int)pTE->v.DisplayHeight);
- int gcd = GCD(aspect.cx, aspect.cy);
- if (gcd > 1) {
- aspect.cx /= gcd;
- aspect.cy /= gcd;
- }
- ((VIDEOINFOHEADER2*)mt.Format())->dwPictAspectRatioX = aspect.cx;
- ((VIDEOINFOHEADER2*)mt.Format())->dwPictAspectRatioY = aspect.cy;
- mts.InsertAt(i++, mt);
- } else if (mts[i].formattype == FORMAT_MPEG2Video) {
- CSize aspect((int)pTE->v.DisplayWidth, (int)pTE->v.DisplayHeight);
- int gcd = GCD(aspect.cx, aspect.cy);
- if (gcd > 1) {
- aspect.cx /= gcd;
- aspect.cy /= gcd;
- }
- ((MPEG2VIDEOINFO*)mts[i].Format())->hdr.dwPictAspectRatioX = aspect.cx;
- ((MPEG2VIDEOINFO*)mts[i].Format())->hdr.dwPictAspectRatioY = aspect.cy;
- }
- }
- }
- } else if (pTE->TrackType == TrackEntry::TypeAudio) {
- Name.Format(L"Audio %d", iAudio++);
-
- mt.majortype = MEDIATYPE_Audio;
- mt.formattype = FORMAT_WaveFormatEx;
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX));
- ZeroMemory(wfe, mt.FormatLength());
- wfe->nChannels = (WORD)pTE->a.Channels;
- wfe->nSamplesPerSec = (DWORD)pTE->a.SamplingFrequency;
- wfe->wBitsPerSample = (WORD)pTE->a.BitDepth;
- wfe->nBlockAlign = (WORD)((wfe->nChannels * wfe->wBitsPerSample) / 8);
- wfe->nAvgBytesPerSec = wfe->nSamplesPerSec * wfe->nBlockAlign;
- mt.SetSampleSize(256000);
-
- if (CodecID == "A_MPEG/L3") {
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_MPEGLAYER3);
- mts.Add(mt);
- } else if (CodecID == "A_MPEG/L2" ||
- CodecID == "A_MPEG/L1") {
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_MPEG);
- mts.Add(mt);
- } else if (CodecID == "A_AC3" ||
- CodecID == "A_EAC3") {
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_DOLBY_AC3);
- mts.Add(mt);
- } else if (CodecID == "A_TRUEHD" ||
- CodecID == "A_MLP") {
- wfe->wFormatTag = WAVE_FORMAT_DOLBY_AC3;
- mt.subtype = MEDIASUBTYPE_DOLBY_TRUEHD;
- mts.Add(mt);
- } else if (CodecID == "A_DTS") {
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_DVD_DTS);
- mts.Add(mt);
- } else if (CodecID == "A_TTA1") {
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_TTA1);
- wfe->cbSize = 30;
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + 30);
- BYTE* p = (BYTE*)(wfe + 1);
- memcpy(p, (const unsigned char*)"TTA1\x01\x00", 6);
- memcpy(p + 6, &wfe->nChannels, 2);
- memcpy(p + 8, &wfe->wBitsPerSample, 2);
- memcpy(p + 10, &wfe->nSamplesPerSec, 4);
- ZeroMemory(p + 14, 30 - 14);
- mts.Add(mt);
- } else if (CodecID == "A_AAC") {
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_AAC);
- wfe->cbSize = (WORD)pTE->CodecPrivate.GetCount();
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + pTE->CodecPrivate.GetCount());
- memcpy(wfe + 1, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- mts.Add(mt);
- } else if (CodecID == "A_WAVPACK4") {
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_WAVPACK4);
- wfe->cbSize = (WORD)pTE->CodecPrivate.GetCount();
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + pTE->CodecPrivate.GetCount());
- memcpy(wfe + 1, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- mts.Add(mt);
- } else if (CodecID == "A_FLAC") {
- wfe->wFormatTag = WAVE_FORMAT_FLAC;
- wfe->cbSize = (WORD)pTE->CodecPrivate.GetCount();
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + pTE->CodecPrivate.GetCount());
- memcpy(wfe + 1, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
-
- mt.subtype = MEDIASUBTYPE_FLAC_FRAMED;
- mts.Add(mt);
- mt.subtype = MEDIASUBTYPE_FLAC;
- mts.Add(mt);
- } else if (CodecID == "A_PCM/INT/LIT") {
- mt.subtype = MEDIASUBTYPE_PCM;
- mt.SetSampleSize(wfe->nBlockAlign);
- if (pTE->a.Channels <= 2 && pTE->a.BitDepth <= 16) {
- wfe->wFormatTag = WAVE_FORMAT_PCM;
- } else {
- WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEXTENSIBLE));
- if (pTE->a.BitDepth & 7) {
- wfex->Format.wBitsPerSample = (WORD)(pTE->a.BitDepth + 7) & 0xFFF8;
- wfex->Format.nBlockAlign = wfex->Format.nChannels * wfex->Format.wBitsPerSample / 8;
- wfex->Format.nAvgBytesPerSec = wfex->Format.nSamplesPerSec * wfex->Format.nBlockAlign;
- mt.SetSampleSize(wfex->Format.nBlockAlign);
- }
- wfex->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
- wfex->Format.cbSize = 22;
- wfex->Samples.wValidBitsPerSample = (WORD)pTE->a.BitDepth;
- wfex->dwChannelMask = GetDefChannelMask(wfex->Format.nChannels);
- wfex->SubFormat = MEDIASUBTYPE_PCM;
- }
- mts.Add(mt);
- } else if (CodecID == "A_PCM/FLOAT/IEEE") {
- mt.subtype = MEDIASUBTYPE_IEEE_FLOAT;
- mt.SetSampleSize(wfe->nBlockAlign);
- if (pTE->a.Channels <= 2) {
- wfe->wFormatTag = WAVE_FORMAT_IEEE_FLOAT;
- } else {
- WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEXTENSIBLE));
- wfex->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
- wfex->Format.cbSize = 22;
- wfex->Samples.wValidBitsPerSample = (WORD)pTE->a.BitDepth;
- wfex->dwChannelMask = GetDefChannelMask(wfex->Format.nChannels);
- wfex->SubFormat = MEDIASUBTYPE_IEEE_FLOAT;
- }
- mts.Add(mt);
- } else if (CodecID == "A_MS/ACM") {
- wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(pTE->CodecPrivate.GetCount());
- memcpy(wfe, (WAVEFORMATEX*)pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- if (wfe->wFormatTag == WAVE_FORMAT_EXTENSIBLE && wfe->cbSize == 22) {
- mt.subtype = ((WAVEFORMATEXTENSIBLE*)wfe)->SubFormat;
- } else {
- mt.subtype = FOURCCMap(wfe->wFormatTag);
- }
- mts.Add(mt);
- } else if (CodecID == "A_VORBIS") {
- BYTE* p = pTE->CodecPrivate.GetData();
- CAtlArray<int> sizes;
- int totalsize = 0;
- for (BYTE n = *p++; n > 0; n--) {
- int size = 0;
- do {
- size += *p;
- } while (*p++ == 0xff);
- sizes.Add(size);
- totalsize += size;
- }
- sizes.Add((int)(pTE->CodecPrivate.GetData() + pTE->CodecPrivate.GetCount() - p) - totalsize);
- totalsize += sizes[sizes.GetCount() - 1];
-
- if (sizes.GetCount() == 3) {
- mt.subtype = MEDIASUBTYPE_Vorbis2;
- mt.formattype = FORMAT_VorbisFormat2;
- VORBISFORMAT2* pvf2 = (VORBISFORMAT2*)mt.AllocFormatBuffer(sizeof(VORBISFORMAT2) + (ULONG)totalsize);
- ZeroMemory(pvf2, mt.FormatLength());
- pvf2->Channels = (WORD)pTE->a.Channels;
- pvf2->SamplesPerSec = (DWORD)pTE->a.SamplingFrequency;
- pvf2->BitsPerSample = (DWORD)pTE->a.BitDepth;
- BYTE* p2 = mt.Format() + sizeof(VORBISFORMAT2);
- for (size_t i = 0; i < sizes.GetCount(); p += sizes[i], p2 += sizes[i], i++) {
- memcpy(p2, p, pvf2->HeaderSize[i] = sizes[i]);
- }
-
- mts.Add(mt);
- }
-
- mt.subtype = MEDIASUBTYPE_Vorbis;
- mt.formattype = FORMAT_VorbisFormat;
- VORBISFORMAT* vf = (VORBISFORMAT*)mt.AllocFormatBuffer(sizeof(VORBISFORMAT));
- ZeroMemory(vf, mt.FormatLength());
- vf->nChannels = (WORD)pTE->a.Channels;
- vf->nSamplesPerSec = (DWORD)pTE->a.SamplingFrequency;
- vf->nMinBitsPerSec = vf->nMaxBitsPerSec = vf->nAvgBitsPerSec = (DWORD) - 1;
- mts.Add(mt);
- } else if (CodecID.Find("A_AAC/") == 0) {
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_AAC);
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + 5);
- wfe->cbSize = 2;
-
- int profile;
-
- if (CodecID.Find("/MAIN") > 0) {
- profile = 0;
- } else if (CodecID.Find("/SBR") > 0) {
- profile = -1;
- } else if (CodecID.Find("/LC") > 0) {
- profile = 1;
- } else if (CodecID.Find("/SSR") > 0) {
- profile = 2;
- } else if (CodecID.Find("/LTP") > 0) {
- profile = 3;
- } else {
- continue;
- }
-
- WORD cbSize = MakeAACInitData((BYTE*)(wfe + 1), profile, wfe->nSamplesPerSec, (int)pTE->a.Channels);
-
- mts.Add(mt);
-
- if (profile < 0) {
- wfe->cbSize = cbSize;
- wfe->nSamplesPerSec *= 2;
- wfe->nAvgBytesPerSec *= 2;
-
- mts.InsertAt(0, mt);
- }
- } else if (CodecID.Find("A_REAL/") == 0 && CodecID.GetLength() >= 11) {
- mt.subtype = FOURCCMap((DWORD)CodecID[7] | ((DWORD)CodecID[8] << 8) | ((DWORD)CodecID[9] << 16) | ((DWORD)CodecID[10] << 24));
- mt.bTemporalCompression = TRUE;
- wfe->cbSize = (WORD)pTE->CodecPrivate.GetCount();
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + pTE->CodecPrivate.GetCount());
- memcpy(wfe + 1, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- wfe->cbSize = 0; // IMPORTANT: this is screwed, but cbSize has to be 0 and the extra data from codec priv must be after WAVEFORMATEX
- mts.Add(mt);
- } else if (CodecID == "A_QUICKTIME" && pTE->CodecPrivate.GetCount() >= 8) {
- DWORD* type = (DWORD*)(pTE->CodecPrivate.GetData() + 4);
- if (*type == MAKEFOURCC('Q', 'D', 'M', '2') || *type == MAKEFOURCC('Q', 'D', 'M', 'C')) {
- mt.subtype = FOURCCMap(*type);
- wfe->cbSize = (WORD)pTE->CodecPrivate.GetCount();
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + pTE->CodecPrivate.GetCount());
- memcpy(wfe + 1, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- mts.Add(mt);
- }
- } else if (CodecID == "A_ALAC") {
- mt.subtype = MEDIASUBTYPE_ALAC;
- WORD cbSize = (WORD)pTE->CodecPrivate.GetCount() + 12;
- wfe->cbSize = cbSize;
- wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + cbSize);
- BYTE* p = (BYTE*)(wfe + 1);
-
- ZeroMemory(p, cbSize);
- memcpy(p + 3, &cbSize, 1);
- memcpy(p + 4, (const unsigned char*)"alac", 4);
- memcpy(p + 12, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- mts.Add(mt);
- }
- } else if (pTE->TrackType == TrackEntry::TypeSubtitle) {
- if (iSubtitle == 1) {
- InstallFonts();
- }
-
- Name.Format(L"Subtitle %d", iSubtitle++);
-
- mt.SetSampleSize(1);
-
- if (CodecID == "S_TEXT/ASCII") {
- mt.majortype = MEDIATYPE_Text;
- mt.subtype = MEDIASUBTYPE_NULL;
- mt.formattype = FORMAT_None;
- mts.Add(mt);
- isSub = true;
- } else {
- mt.majortype = MEDIATYPE_Subtitle;
- mt.formattype = FORMAT_SubtitleInfo;
- SUBTITLEINFO* psi = (SUBTITLEINFO*)mt.AllocFormatBuffer(sizeof(SUBTITLEINFO) + pTE->CodecPrivate.GetCount());
- ZeroMemory(psi, mt.FormatLength());
- strncpy_s(psi->IsoLang, pTE->Language, _countof(psi->IsoLang) - 1);
- CString subtitle_Name = pTE->Name;
- if (pTE->FlagForced) { // "Forced" overrides "Default"
- subtitle_Name += L" [Forced]";
- } else if (pTE->FlagDefault) {
- subtitle_Name += L" [Default]";
- }
- subtitle_Name = subtitle_Name.Trim();
-
- wcsncpy_s(psi->TrackName, subtitle_Name, _countof(psi->TrackName) - 1);
- memcpy(mt.pbFormat + (psi->dwOffset = sizeof(SUBTITLEINFO)), pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
-
- mt.subtype =
- CodecID == "S_TEXT/UTF8" ? MEDIASUBTYPE_UTF8 :
- CodecID == "S_TEXT/SSA" || CodecID == "S_SSA" ? MEDIASUBTYPE_SSA :
- CodecID == "S_TEXT/ASS" || CodecID == "S_ASS" ? MEDIASUBTYPE_ASS :
- CodecID == "S_TEXT/USF" || CodecID == "S_USF" ? MEDIASUBTYPE_USF :
- CodecID == "S_HDMV/PGS" ? MEDIASUBTYPE_HDMVSUB :
- //CodecID == "S_DVBSUB" ? MEDIASUBTYPE_DVB_SUBTITLES : // does not work
- CodecID == "S_VOBSUB" ? MEDIASUBTYPE_VOBSUB :
- MEDIASUBTYPE_NULL;
-
- if (mt.subtype != MEDIASUBTYPE_NULL) {
- mts.Add(mt);
- isSub = true;
- }
- }
- }
-
- if (mts.IsEmpty()) {
- TRACE(_T("CMatroskaSourceFilter: Unsupported TrackType %s (%I64d)\n"), CString(CodecID), (UINT64)pTE->TrackType);
- continue;
- }
-
- Name = CStringW(pTE->Language.IsEmpty() ? L"English" : CStringW(ISO6392ToLanguage(pTE->Language)))
- + (pTE->Name.IsEmpty() ? L"" : L", " + pTE->Name)
- + (L" (" + Name + L")");
-
- if (pTE->FlagForced) { // "Forced" overrides "Default"
- Name = Name + L" [Forced]";
- } else if (pTE->FlagDefault) {
- Name = Name + L" [Default]";
- }
-
- HRESULT hr2;
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DEBUG_NEW CMatroskaSplitterOutputPin(pTE->MinCache, pTE->DefaultDuration / 100, mts, Name, this, this, &hr2));
- if (!pTE->Name.IsEmpty()) {
- pPinOut->SetProperty(L"NAME", pTE->Name);
- }
- if (pTE->Language.GetLength() == 3) {
- pPinOut->SetProperty(L"LANG", CStringW(CString(pTE->Language)));
- }
-
- if (!isSub) {
- pinOut.InsertAt((iVideo + iAudio - 3), DEBUG_NEW CMatroskaSplitterOutputPin(pTE->MinCache, pTE->DefaultDuration / 100, mts, Name, this, this, &hr2), 1);
- pinOutTE.InsertAt((iVideo + iAudio - 3), pTE, 1);
- } else {
- pinOut.Add(DEBUG_NEW CMatroskaSplitterOutputPin(pTE->MinCache, pTE->DefaultDuration / 100, mts, Name, this, this, &hr2));
- pinOutTE.Add(pTE);
- }
-
- }
- }
-
- for (size_t i = 0; i < pinOut.GetCount(); i++) {
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut;
- pPinOut.Attach(pinOut[i]);
- TrackEntry* pTE = pinOutTE[i];
-
- if (pTE != nullptr) {
- AddOutputPin((DWORD)pTE->TrackNumber, pPinOut);
- m_pTrackEntryMap[(DWORD)pTE->TrackNumber] = pTE;
- m_pOrderedTrackArray.Add(pTE);
- }
- }
-
-
- Info& info = m_pFile->m_segment.SegmentInfo;
-
- if (m_pFile->IsRandomAccess()) {
- m_rtDuration = (REFERENCE_TIME)(info.Duration * info.TimeCodeScale / 100);
- }
-
- m_rtNewStop = m_rtStop = m_rtDuration;
-
- /*#ifdef _DEBUG
- for (int i = 1, j = GetChapterCount(CHAPTER_ROOT_ID); i <= j; i++)
- {
- UINT id = GetChapterId(CHAPTER_ROOT_ID, i);
- struct ChapterElement ce;
- BOOL b = GetChapterInfo(id, &ce);
- BSTR bstr = GetChapterStringInfo(id, "eng", "");
- if (bstr) ::SysFreeString(bstr);
- }
- #endif*/
-
- SetProperty(L"TITL", info.Title);
- // TODO
-
- // resources
-
- {
- POSITION pos = m_pFile->m_segment.Attachments.GetHeadPosition();
- while (pos) {
- Attachment* pA = m_pFile->m_segment.Attachments.GetNext(pos);
-
- POSITION pos = pA->AttachedFiles.GetHeadPosition();
- while (pos) {
- AttachedFile* pF = pA->AttachedFiles.GetNext(pos);
-
- CAtlArray<BYTE> pData;
- pData.SetCount((size_t)pF->FileDataLen);
- m_pFile->Seek(pF->FileDataPos);
- if (SUCCEEDED(m_pFile->ByteRead(pData.GetData(), pData.GetCount()))) {
- ResAppend(pF->FileName, pF->FileDescription, CStringW(pF->FileMimeType), pData.GetData(), (DWORD)pData.GetCount());
- }
- }
- }
- }
-
- // chapters
-
- if (ChapterAtom* caroot = m_pFile->m_segment.FindChapterAtom(0)) {
- CStringA str;
- str.ReleaseBufferSetLength(GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, str.GetBuffer(3), 3));
- CStringA ChapLanguage = CStringA(ISO6391To6392(str));
- if (ChapLanguage.GetLength() < 3) {
- ChapLanguage = "eng";
- }
-
- SetupChapters(ChapLanguage, caroot);
- }
-
- return !m_pOutputs.IsEmpty() ? S_OK : E_FAIL;
-}
-
-void CMatroskaSplitterFilter::SetupChapters(LPCSTR lng, ChapterAtom* parent, int level)
-{
- CStringW tabs('+', level);
-
- if (!tabs.IsEmpty()) {
- tabs += ' ';
- }
-
- POSITION pos = parent->ChapterAtoms.GetHeadPosition();
- while (pos) {
- // ChapUID zero not allow by Matroska specs
- UINT64 ChapUID = parent->ChapterAtoms.GetNext(pos)->ChapterUID;
- ChapterAtom* ca = (ChapUID == 0) ? nullptr : m_pFile->m_segment.FindChapterAtom(ChapUID);
-
- if (ca) {
- CStringW name, first;
-
- POSITION pos = ca->ChapterDisplays.GetHeadPosition();
- while (pos) {
- ChapterDisplay* cd = ca->ChapterDisplays.GetNext(pos);
- if (first.IsEmpty()) {
- first = cd->ChapString;
- }
- if (cd->ChapLanguage == lng) {
- name = cd->ChapString;
- }
- }
-
- name = tabs + (!name.IsEmpty() ? name : first);
-
- ChapAppend(ca->ChapterTimeStart / 100 - m_pFile->m_rtOffset, name);
-
- if (!ca->ChapterAtoms.IsEmpty() && level < 5) {
- // level < 5 - hard limit for the number of levels
- SetupChapters(lng, ca, level + 1);
- }
- }
- }
-
-}
-
-void CMatroskaSplitterFilter::InstallFonts()
-{
- POSITION pos = m_pFile->m_segment.Attachments.GetHeadPosition();
- while (pos) {
- Attachment* pA = m_pFile->m_segment.Attachments.GetNext(pos);
-
- POSITION p2 = pA->AttachedFiles.GetHeadPosition();
- while (p2) {
- AttachedFile* pF = pA->AttachedFiles.GetNext(p2);
-
- if (pF->FileMimeType == "application/x-truetype-font" ||
- pF->FileMimeType == "application/x-font-ttf" ||
- pF->FileMimeType == "application/vnd.ms-opentype") {
- // assume this is a font resource
-
- if (BYTE* pData = DEBUG_NEW BYTE[(UINT)pF->FileDataLen]) {
- m_pFile->Seek(pF->FileDataPos);
-
- if (SUCCEEDED(m_pFile->ByteRead(pData, pF->FileDataLen))) {
- //m_fontinst.InstallFont(pData, (UINT)pF->FileDataLen);
- m_fontinst.InstallFontMemory(pData, (UINT)pF->FileDataLen);
- }
-
- delete [] pData;
- }
- }
- }
- }
-}
-
-void CMatroskaSplitterFilter::SendVorbisHeaderSample()
-{
- HRESULT hr;
-
- POSITION pos = m_pTrackEntryMap.GetStartPosition();
- while (pos) {
- DWORD TrackNumber = 0;
- TrackEntry* pTE = nullptr;
- m_pTrackEntryMap.GetNextAssoc(pos, TrackNumber, pTE);
-
- CBaseSplitterOutputPin* pPin = GetOutputPin(TrackNumber);
-
- if (!(pTE && pPin && pPin->IsConnected())) {
- continue;
- }
-
- if (pTE->CodecID.ToString() == "A_VORBIS" && pPin->CurrentMediaType().subtype == MEDIASUBTYPE_Vorbis
- && !pTE->CodecPrivate.IsEmpty()) {
- BYTE* ptr = pTE->CodecPrivate.GetData();
-
- CAtlList<int> sizes;
- int last = 0;
- for (BYTE n = *ptr++; n > 0; n--) {
- int size = 0;
- do {
- size += *ptr;
- } while (*ptr++ == 0xff);
- sizes.AddTail(size);
- last += size;
- }
- sizes.AddTail((int)(pTE->CodecPrivate.GetData() + pTE->CodecPrivate.GetCount() - ptr) - last);
-
- hr = S_OK;
-
- POSITION pos = sizes.GetHeadPosition();
- while (pos && SUCCEEDED(hr)) {
- long len = sizes.GetNext(pos);
-
- CAutoPtr<Packet> p(DEBUG_NEW Packet());
- p->TrackNumber = (DWORD)pTE->TrackNumber;
- p->rtStart = 0;
- p->rtStop = 1;
- p->bSyncPoint = FALSE;
-
- p->SetData(ptr, len);
- ptr += len;
-
- hr = DeliverPacket(p);
- }
-
- if (FAILED(hr)) {
- TRACE(_T("ERROR: Vorbis initialization failed for stream %I64d\n"), TrackNumber);
- }
- }
- }
-}
-
-bool CMatroskaSplitterFilter::DemuxInit()
-{
- SetThreadName((DWORD) - 1, "CMatroskaSplitterFilter");
-
- CMatroskaNode Root(m_pFile);
- if (!m_pFile
- || !(m_pSegment = Root.Child(0x18538067))
- || !(m_pCluster = m_pSegment->Child(0x1F43B675))) {
- return false;
- }
-
- // reindex if needed
-
- if (m_pFile->IsRandomAccess() && m_pFile->m_segment.Cues.IsEmpty()) {
- m_nOpenProgress = 0;
- m_pFile->m_segment.SegmentInfo.Duration.Set(0);
-
- UINT64 TrackNumber = m_pFile->m_segment.GetMasterTrack();
-
- CAutoPtr<Cue> pCue(DEBUG_NEW Cue());
-
- do {
- Cluster c;
- c.ParseTimeCode(m_pCluster);
-
- m_pFile->m_segment.SegmentInfo.Duration.Set((float)c.TimeCode - m_pFile->m_rtOffset / 10000);
-
- CAutoPtr<CuePoint> pCuePoint(DEBUG_NEW CuePoint());
- CAutoPtr<CueTrackPosition> pCueTrackPosition(DEBUG_NEW CueTrackPosition());
- pCuePoint->CueTime.Set(c.TimeCode);
- pCueTrackPosition->CueTrack.Set(TrackNumber);
- pCueTrackPosition->CueClusterPosition.Set(m_pCluster->m_filepos - m_pSegment->m_start);
- pCuePoint->CueTrackPositions.AddTail(pCueTrackPosition);
- pCue->CuePoints.AddTail(pCuePoint);
-
- m_nOpenProgress = m_pFile->GetPos() * 100 / m_pFile->GetLength();
-
- DWORD cmd;
- if (CheckRequest(&cmd)) {
- if (cmd == CMD_EXIT) {
- m_fAbort = true;
- } else {
- Reply(S_OK);
- }
- }
- } while (!m_fAbort && m_pCluster->Next(true));
-
- m_nOpenProgress = 100;
-
- if (!m_fAbort) {
- m_pFile->m_segment.Cues.AddTail(pCue);
- }
-
- m_fAbort = false;
-
- if (m_pFile->m_segment.Cues.GetCount()) {
- Info& info = m_pFile->m_segment.SegmentInfo;
- m_rtDuration = (REFERENCE_TIME)(info.Duration * info.TimeCodeScale / 100);
- m_rtNewStop = m_rtStop = m_rtDuration;
- }
- }
-
- m_pCluster.Free();
- m_pBlock.Free();
-
- return true;
-}
-
-void CMatroskaSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
-{
- m_pCluster = m_pSegment->Child(0x1F43B675);
- m_pBlock.Free();
-
- if (rt > 0) {
- rt += m_pFile->m_rtOffset;
-
- QWORD lastCueClusterPosition = (QWORD) - 1;
-
- Segment& s = m_pFile->m_segment;
-
- UINT64 TrackNumber = s.GetMasterTrack();
-
- POSITION pos1 = s.Cues.GetHeadPosition();
- while (pos1) {
- Cue* pCue = s.Cues.GetNext(pos1);
-
- POSITION pos2 = pCue->CuePoints.GetTailPosition();
- while (pos2) {
- CuePoint* pCuePoint = pCue->CuePoints.GetPrev(pos2);
-
- if (rt < s.GetRefTime(pCuePoint->CueTime)) {
- continue;
- }
-
- POSITION pos3 = pCuePoint->CueTrackPositions.GetHeadPosition();
- while (pos3) {
- CueTrackPosition* pCueTrackPositions = pCuePoint->CueTrackPositions.GetNext(pos3);
-
- if (TrackNumber != pCueTrackPositions->CueTrack) {
- continue;
- }
-
- if (lastCueClusterPosition == pCueTrackPositions->CueClusterPosition) {
- continue;
- }
-
- lastCueClusterPosition = pCueTrackPositions->CueClusterPosition;
-
- m_pCluster->SeekTo(m_pSegment->m_start + pCueTrackPositions->CueClusterPosition);
- m_pCluster->Parse();
-
- bool fFoundKeyFrame = false;
- /*
- if (pCueTrackPositions->CueBlockNumber > 0)
- {
- // TODO: CueBlockNumber only tells the block num of the track and not for all mixed in the cluster
- m_nLastBlock = (int)pCueTrackPositions->CueBlockNumber;
- fFoundKeyFrame = true;
- }
- else
- */
- {
- Cluster c;
- c.ParseTimeCode(m_pCluster);
-
- if (CAutoPtr<CMatroskaNode> pBlock = m_pCluster->GetFirstBlock()) {
- bool fPassedCueTime = false;
-
- do {
- CBlockGroupNode bgn;
-
- if (pBlock->m_id == 0xA0) {
- bgn.Parse(pBlock, true);
- } else if (pBlock->m_id == 0xA3) {
- CAutoPtr<BlockGroup> bg(DEBUG_NEW BlockGroup());
- bg->Block.Parse(pBlock, true);
- if (!(bg->Block.Lacing & 0x80)) {
- bg->ReferenceBlock.Set(0); // not a kf
- }
- bgn.AddTail(bg);
- }
-
- POSITION pos4 = bgn.GetHeadPosition();
- while (!fPassedCueTime && pos4) {
- BlockGroup* bg = bgn.GetNext(pos4);
-
- if (bg->Block.TrackNumber == pCueTrackPositions->CueTrack && rt < s.GetRefTime(c.TimeCode + bg->Block.TimeCode)
- || rt + 5000000i64 < s.GetRefTime(c.TimeCode + bg->Block.TimeCode)) { // allow 500ms difference between tracks, just in case intreleaving wasn't that much precise
- fPassedCueTime = true;
- } else if (bg->Block.TrackNumber == pCueTrackPositions->CueTrack && !bg->ReferenceBlock.IsValid()) {
- fFoundKeyFrame = true;
- m_pBlock = pBlock->Copy();
- }
- }
- } while (!fPassedCueTime && pBlock->NextBlock());
- }
- }
-
- if (fFoundKeyFrame) {
- pos1 = pos2 = pos3 = nullptr;
- }
- }
- }
- }
-
- if (!m_pBlock) {
- m_pCluster = m_pSegment->Child(0x1F43B675);
- }
- }
-}
-
-bool CMatroskaSplitterFilter::DemuxLoop()
-{
- HRESULT hr = S_OK;
-
- SendVorbisHeaderSample(); // HACK: init vorbis decoder with the headers
-
- do {
- Cluster c;
- c.ParseTimeCode(m_pCluster);
-
- if (!m_pBlock) {
- m_pBlock = m_pCluster->GetFirstBlock();
- }
- if (!m_pBlock) {
- continue;
- }
-
- do {
- CBlockGroupNode bgn;
-
- if (m_pBlock->m_id == 0xA0) {
- bgn.Parse(m_pBlock, true);
- } else if (m_pBlock->m_id == 0xA3) {
- CAutoPtr<BlockGroup> bg(DEBUG_NEW BlockGroup());
- bg->Block.Parse(m_pBlock, true);
- if (!(bg->Block.Lacing & 0x80)) {
- bg->ReferenceBlock.Set(0); // not a kf
- }
- bgn.AddTail(bg);
- }
-
- while (bgn.GetCount() && SUCCEEDED(hr)) {
- CAutoPtr<MatroskaPacket> p(DEBUG_NEW MatroskaPacket());
- p->bg = bgn.RemoveHead();
-
- p->bSyncPoint = !p->bg->ReferenceBlock.IsValid();
- p->TrackNumber = (DWORD)p->bg->Block.TrackNumber;
-
- TrackEntry* pTE = nullptr;
-
- if (!m_pTrackEntryMap.Lookup(p->TrackNumber, pTE) || !pTE) {
- continue;
- }
-
- p->rtStart = m_pFile->m_segment.GetRefTime((REFERENCE_TIME)c.TimeCode + p->bg->Block.TimeCode);
- p->rtStop = p->rtStart + (p->bg->BlockDuration.IsValid() ? m_pFile->m_segment.GetRefTime(p->bg->BlockDuration) : 1);
-
- // Fix subtitle with duration = 0
- if (pTE->TrackType == TrackEntry::TypeSubtitle && !p->bg->BlockDuration.IsValid()) {
- p->bg->BlockDuration.Set(1); // just setting it to be valid
- p->rtStop = p->rtStart;
- }
-
- POSITION pos = p->bg->Block.BlockData.GetHeadPosition();
- while (pos) {
- CBinary* pb = p->bg->Block.BlockData.GetNext(pos);
- pTE->Expand(*pb, ContentEncoding::AllFrameContents);
- }
-
- // HACK
- p->rtStart -= m_pFile->m_rtOffset;
- p->rtStop -= m_pFile->m_rtOffset;
-
- hr = DeliverPacket(p);
- }
- } while (m_pBlock->NextBlock() && SUCCEEDED(hr) && !CheckRequest(nullptr));
-
- m_pBlock.Free();
- } while (m_pFile->GetPos() < (__int64)(m_pFile->m_segment.pos + m_pFile->m_segment.len)
- && m_pCluster->Next(true) && SUCCEEDED(hr) && !CheckRequest(nullptr));
-
- m_pCluster.Free();
-
- return true;
-}
-
-// IKeyFrameInfo
-
-STDMETHODIMP CMatroskaSplitterFilter::GetKeyFrameCount(UINT& nKFs)
-{
- if (!m_pFile) {
- return E_UNEXPECTED;
- }
-
- HRESULT hr = S_OK;
-
- nKFs = 0;
-
- POSITION pos = m_pFile->m_segment.Cues.GetHeadPosition();
- while (pos) {
- nKFs += (UINT)m_pFile->m_segment.Cues.GetNext(pos)->CuePoints.GetCount();
- }
-
- return hr;
-}
-
-STDMETHODIMP CMatroskaSplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs)
-{
- CheckPointer(pFormat, E_POINTER);
- CheckPointer(pKFs, E_POINTER);
-
- if (!m_pFile) {
- return E_UNEXPECTED;
- }
- if (*pFormat != TIME_FORMAT_MEDIA_TIME) {
- return E_INVALIDARG;
- }
-
- UINT nKFsTmp = 0;
-
- POSITION pos1 = m_pFile->m_segment.Cues.GetHeadPosition();
- while (pos1 && nKFsTmp < nKFs) {
- Cue* pCue = m_pFile->m_segment.Cues.GetNext(pos1);
-
- POSITION pos2 = pCue->CuePoints.GetHeadPosition();
- while (pos2 && nKFsTmp < nKFs) {
- pKFs[nKFsTmp++] = m_pFile->m_segment.GetRefTime(pCue->CuePoints.GetNext(pos2)->CueTime);
- }
- }
-
- nKFs = nKFsTmp;
-
- return S_OK;
-}
-
-//
-// CMatroskaSourceFilter
-//
-
-CMatroskaSourceFilter::CMatroskaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CMatroskaSplitterFilter(pUnk, phr)
-{
- m_clsid = __uuidof(this);
- m_pInput.Free();
-}
-
-//
-// CMatroskaSplitterOutputPin
-//
-
-CMatroskaSplitterOutputPin::CMatroskaSplitterOutputPin(
- unsigned int nMinCache, REFERENCE_TIME rtDefaultDuration,
- CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseSplitterOutputPin(mts, pName, pFilter, pLock, phr)
- , m_nMinCache(nMinCache), m_rtDefaultDuration(rtDefaultDuration)
-{
- m_nMinCache = 1;//max(m_nMinCache, 1);
-}
-
-CMatroskaSplitterOutputPin::~CMatroskaSplitterOutputPin()
-{
-}
-
-HRESULT CMatroskaSplitterOutputPin::DeliverEndFlush()
-{
- {
- CAutoLock cAutoLock(&m_csQueue);
- m_packets.RemoveAll();
- m_rob.RemoveAll();
- m_tos.RemoveAll();
- }
-
- return __super::DeliverEndFlush();
-}
-
-HRESULT CMatroskaSplitterOutputPin::DeliverEndOfStream()
-{
- CAutoLock cAutoLock(&m_csQueue);
-
- // send out the last remaining packets from the queue
-
- while (m_rob.GetCount()) {
- MatroskaPacket* mp = m_rob.RemoveHead();
- if (m_rob.GetCount() && !mp->bg->BlockDuration.IsValid()) {
- mp->rtStop = m_rob.GetHead()->rtStart;
- } else if (m_rob.IsEmpty() && m_rtDefaultDuration > 0) {
- mp->rtStop = mp->rtStart + m_rtDefaultDuration;
- }
-
- timeoverride to = {mp->rtStart, mp->rtStop};
- m_tos.AddTail(to);
- }
-
- while (m_packets.GetCount()) {
- HRESULT hr = DeliverBlock(m_packets.RemoveHead());
- if (hr != S_OK) {
- return hr;
- }
- }
-
- return __super::DeliverEndOfStream();
-}
-
-HRESULT CMatroskaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
-{
- MatroskaPacket* mp = dynamic_cast<MatroskaPacket*>(p.m_p);
- if (!mp) {
- return __super::DeliverPacket(p);
- }
-
- // don't try to understand what's happening here, it's magic
-
- CAutoLock cAutoLock(&m_csQueue);
-
- CAutoPtr<MatroskaPacket> p2;
- p.Detach();
- p2.Attach(mp);
- m_packets.AddTail(p2);
-
- POSITION pos = m_rob.GetTailPosition();
- ASSERT(m_nMinCache > 0);
- for (int i = m_nMinCache - 1; i > 0 && pos && mp->bg->ReferencePriority < m_rob.GetAt(pos)->bg->ReferencePriority; --i) {
- m_rob.GetPrev(pos);
- }
-
- if (!pos) {
- m_rob.AddHead(mp);
- } else {
- m_rob.InsertAfter(pos, mp);
- }
-
- mp = nullptr;
-
- if (m_rob.GetCount() == m_nMinCache + 1) {
- ASSERT(m_nMinCache > 0);
- pos = m_rob.GetHeadPosition();
- MatroskaPacket* mp1 = m_rob.GetNext(pos);
- MatroskaPacket* mp2 = m_rob.GetNext(pos);
- if (!mp1->bg->BlockDuration.IsValid()) {
- mp1->bg->BlockDuration.Set(1); // just to set it valid
-
- if (mp1->rtStart >= mp2->rtStart) {
- /* CString str;
- str.Format(_T("mp1->rtStart (%I64d) >= mp2->rtStart (%I64d)!!!\n"), mp1->rtStart, mp2->rtStart);
- AfxMessageBox(str);
- */
- // TRACE(_T("mp1->rtStart (%I64d) >= mp2->rtStart (%I64d)!!!\n"), mp1->rtStart, mp2->rtStart);
- } else {
- mp1->rtStop = mp2->rtStart;
- }
- }
- }
-
- while (m_packets.GetCount()) {
- mp = m_packets.GetHead();
- if (!mp->bg->BlockDuration.IsValid()) {
- break;
- }
-
- mp = m_rob.RemoveHead();
- timeoverride to = {mp->rtStart, mp->rtStop};
- m_tos.AddTail(to);
-
- HRESULT hr = DeliverBlock(m_packets.RemoveHead());
- if (hr != S_OK) {
- return hr;
- }
- }
-
- return S_OK;
-}
-
-HRESULT CMatroskaSplitterOutputPin::DeliverBlock(MatroskaPacket* p)
-{
- HRESULT hr = S_FALSE;
-
- if (m_tos.GetCount()) {
- timeoverride to = m_tos.RemoveHead();
-
-#if defined(_DEBUG) && 0
- TRACE(_T("(track=%d) %I64d, %I64d -> %I64d, %I64d (buffcnt=%d)\n"),
- p->TrackNumber, p->rtStart, p->rtStop, to.rtStart, to.rtStop,
- QueueCount());
-#endif
-
- p->rtStart = to.rtStart;
- p->rtStop = to.rtStop;
- }
-
- REFERENCE_TIME
- rtStart = p->rtStart,
- rtDelta = (p->rtStop - p->rtStart) / p->bg->Block.BlockData.GetCount(),
- rtStop = p->rtStart + rtDelta;
-
- POSITION pos = p->bg->Block.BlockData.GetHeadPosition();
- while (pos) {
- CAutoPtr<Packet> tmp(DEBUG_NEW Packet());
- tmp->TrackNumber = p->TrackNumber;
- tmp->bDiscontinuity = p->bDiscontinuity;
- tmp->bSyncPoint = p->bSyncPoint;
- tmp->rtStart = rtStart;
- tmp->rtStop = rtStop;
- tmp->Copy(*p->bg->Block.BlockData.GetNext(pos));
- if (S_OK != (hr = DeliverPacket(tmp))) {
- break;
- }
-
- rtStart += rtDelta;
- rtStop += rtDelta;
-
- p->bSyncPoint = false;
- p->bDiscontinuity = false;
- }
-
- if (m_mt.subtype == FOURCCMap(WAVE_FORMAT_WAVPACK4)) {
- POSITION pos = p->bg->ba.bm.GetHeadPosition();
- while (pos) {
- const BlockMore* bm = p->bg->ba.bm.GetNext(pos);
- CAutoPtr<Packet> tmp(DEBUG_NEW Packet());
- tmp->TrackNumber = p->TrackNumber;
- tmp->bDiscontinuity = false;
- tmp->bSyncPoint = false;
- tmp->rtStart = p->rtStart;
- tmp->rtStop = p->rtStop;
- tmp->Copy(bm->BlockAdditional);
- if (S_OK != (hr = DeliverPacket(tmp))) {
- break;
- }
- }
- }
-
- return hr;
-}
-
-// ITrackInfo
-
-TrackEntry* CMatroskaSplitterFilter::GetTrackEntryAt(UINT aTrackIdx)
-{
- if (aTrackIdx >= m_pOrderedTrackArray.GetCount()) {
- return nullptr;
- }
- return m_pOrderedTrackArray[aTrackIdx];
-}
-
-STDMETHODIMP_(UINT) CMatroskaSplitterFilter::GetTrackCount()
-{
- return (UINT)m_pTrackEntryMap.GetCount();
-}
-
-STDMETHODIMP_(BOOL) CMatroskaSplitterFilter::GetTrackInfo(UINT aTrackIdx, struct TrackElement* pStructureToFill)
-{
- TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if (pTE == nullptr) {
- return FALSE;
- }
-
- pStructureToFill->FlagDefault = !!pTE->FlagDefault;
- pStructureToFill->FlagForced = !!pTE->FlagForced;
- pStructureToFill->FlagLacing = !!pTE->FlagLacing;
- strncpy_s(pStructureToFill->Language, pTE->Language, 3);
- if (pStructureToFill->Language[0] == '\0') {
- strncpy_s(pStructureToFill->Language, "eng", 3);
- }
- pStructureToFill->Language[3] = '\0';
- pStructureToFill->MaxCache = (UINT)pTE->MaxCache;
- pStructureToFill->MinCache = (UINT)pTE->MinCache;
- pStructureToFill->Type = (BYTE)pTE->TrackType;
- return TRUE;
-}
-
-STDMETHODIMP_(BOOL) CMatroskaSplitterFilter::GetTrackExtendedInfo(UINT aTrackIdx, void* pStructureToFill)
-{
- TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if (pTE == nullptr) {
- return FALSE;
- }
-
- if (pTE->TrackType == TrackEntry::TypeVideo) {
- TrackExtendedInfoVideo* pTEIV = (TrackExtendedInfoVideo*)pStructureToFill;
- pTEIV->AspectRatioType = (BYTE)pTE->v.AspectRatioType;
- pTEIV->DisplayUnit = (BYTE)pTE->v.DisplayUnit;
- pTEIV->DisplayWidth = (UINT)pTE->v.DisplayWidth;
- pTEIV->DisplayHeight = (UINT)pTE->v.DisplayHeight;
- pTEIV->Interlaced = !!pTE->v.FlagInterlaced;
- pTEIV->PixelWidth = (UINT)pTE->v.PixelWidth;
- pTEIV->PixelHeight = (UINT)pTE->v.PixelHeight;
- } else if (pTE->TrackType == TrackEntry::TypeAudio) {
- TrackExtendedInfoAudio* pTEIA = (TrackExtendedInfoAudio*)pStructureToFill;
- pTEIA->BitDepth = (UINT)pTE->a.BitDepth;
- pTEIA->Channels = (UINT)pTE->a.Channels;
- pTEIA->OutputSamplingFrequency = (float)pTE->a.OutputSamplingFrequency;
- pTEIA->SamplingFreq = (float)pTE->a.SamplingFrequency;
- } else {
- return FALSE;
- }
-
- return TRUE;
-}
-
-STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackName(UINT aTrackIdx)
-{
- TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if (pTE == nullptr) {
- return nullptr;
- }
- return pTE->Name.AllocSysString();
-}
-
-STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecID(UINT aTrackIdx)
-{
- TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if (pTE == nullptr) {
- return nullptr;
- }
- return pTE->CodecID.ToString().AllocSysString();
-}
-
-STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecName(UINT aTrackIdx)
-{
- TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if (pTE == nullptr) {
- return nullptr;
- }
- return pTE->CodecName.AllocSysString();
-}
-
-STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecInfoURL(UINT aTrackIdx)
-{
- TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if (pTE == nullptr) {
- return nullptr;
- }
- return pTE->CodecInfoURL.AllocSysString();
-}
-
-STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecDownloadURL(UINT aTrackIdx)
-{
- TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if (pTE == nullptr) {
- return nullptr;
- }
- return pTE->CodecDownloadURL.AllocSysString();
-}
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.def b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.def
deleted file mode 100644
index 6492e5cd6..000000000
--- a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.def
+++ /dev/null
@@ -1,5 +0,0 @@
-EXPORTS
- DllCanUnloadNow PRIVATE
- DllGetClassObject PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.h b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.h
deleted file mode 100644
index 774443f12..000000000
--- a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <atlbase.h>
-#include <atlcoll.h>
-#include "MatroskaFile.h"
-#include "../BaseSplitter/BaseSplitter.h"
-#include "ITrackInfo.h"
-
-#define MatroskaSplitterName L"MPC Matroska Splitter"
-#define MatroskaSourceName L"MPC Matroska Source"
-
-class MatroskaPacket : public Packet
-{
-protected:
- int GetDataSize() {
- size_t size = 0;
- POSITION pos = bg->Block.BlockData.GetHeadPosition();
- while (pos) {
- size += bg->Block.BlockData.GetNext(pos)->GetCount();
- }
- return (int)size;
- }
-public:
- CAutoPtr<MatroskaReader::BlockGroup> bg;
-};
-
-class CMatroskaSplitterOutputPin : public CBaseSplitterOutputPin
-{
- HRESULT DeliverBlock(MatroskaPacket* p);
-
- unsigned int m_nMinCache;
- REFERENCE_TIME m_rtDefaultDuration;
-
- CCritSec m_csQueue;
- CAutoPtrList<MatroskaPacket> m_packets;
- CAtlList<MatroskaPacket*> m_rob;
-
- typedef struct {
- REFERENCE_TIME rtStart, rtStop;
- } timeoverride;
- CAtlList<timeoverride> m_tos;
-
-protected:
- HRESULT DeliverPacket(CAutoPtr<Packet> p);
-
-public:
- CMatroskaSplitterOutputPin(
- unsigned int nMinCache, REFERENCE_TIME rtDefaultDuration,
- CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
- virtual ~CMatroskaSplitterOutputPin();
-
- HRESULT DeliverEndFlush();
- HRESULT DeliverEndOfStream();
-};
-
-class __declspec(uuid("149D2E01-C32E-4939-80F6-C07B81015A7A"))
- CMatroskaSplitterFilter : public CBaseSplitterFilter, public ITrackInfo
-{
- void SetupChapters(LPCSTR lng, MatroskaReader::ChapterAtom* parent, int level = 0);
- void InstallFonts();
- void SendVorbisHeaderSample();
-
- CAutoPtr<MatroskaReader::CMatroskaNode> m_pSegment, m_pCluster, m_pBlock;
-
-protected:
- CAutoPtr<MatroskaReader::CMatroskaFile> m_pFile;
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
-
- CAtlMap<DWORD, MatroskaReader::TrackEntry*> m_pTrackEntryMap;
- CAtlArray<MatroskaReader::TrackEntry*> m_pOrderedTrackArray;
- MatroskaReader::TrackEntry* GetTrackEntryAt(UINT aTrackIdx);
-
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
-
-public:
- CMatroskaSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
- virtual ~CMatroskaSplitterFilter();
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // CBaseFilter
-
- STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
-
- // IKeyFrameInfo
-
- STDMETHODIMP GetKeyFrameCount(UINT& nKFs);
- STDMETHODIMP GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs);
-
- // ITrackInfo
-
- STDMETHODIMP_(UINT) GetTrackCount();
- STDMETHODIMP_(BOOL) GetTrackInfo(UINT aTrackIdx, struct TrackElement* pStructureToFill);
- STDMETHODIMP_(BOOL) GetTrackExtendedInfo(UINT aTrackIdx, void* pStructureToFill);
- STDMETHODIMP_(BSTR) GetTrackName(UINT aTrackIdx);
- STDMETHODIMP_(BSTR) GetTrackCodecID(UINT aTrackIdx);
- STDMETHODIMP_(BSTR) GetTrackCodecName(UINT aTrackIdx);
- STDMETHODIMP_(BSTR) GetTrackCodecInfoURL(UINT aTrackIdx);
- STDMETHODIMP_(BSTR) GetTrackCodecDownloadURL(UINT aTrackIdx);
-};
-
-class __declspec(uuid("0A68C3B5-9164-4a54-AFAF-995B2FF0E0D4"))
- CMatroskaSourceFilter : public CMatroskaSplitterFilter
-{
-public:
- CMatroskaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
-};
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.rc b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.rc
deleted file mode 100644
index 3e5208af5..000000000
--- a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.rc
+++ /dev/null
@@ -1,102 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-#include "version.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (United States) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION MPC_VERSION_NUM
- PRODUCTVERSION MPC_VERSION_NUM
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS VOS_NT_WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE VFT2_UNKNOWN
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", MPC_VERSION_COMMENTS
- VALUE "CompanyName", MPC_COMP_NAME_STR
- VALUE "FileDescription", "Matroska Splitter"
- VALUE "FileVersion", MPC_VERSION_STR_FULL
- VALUE "InternalName", "Matroska Splitter"
- VALUE "LegalCopyright", MPC_COPYRIGHT_STR
- VALUE "OriginalFilename", "MatroskaSplitter.ax"
- VALUE "ProductName", "Matroska Splitter"
- VALUE "ProductVersion", MPC_VERSION_STR_FULL
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // English (United States) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.vcxproj b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.vcxproj
deleted file mode 100644
index 19c06c397..000000000
--- a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.vcxproj
+++ /dev/null
@@ -1,258 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug Filter|Win32">
- <Configuration>Debug Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug Filter|x64">
- <Configuration>Debug Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|Win32">
- <Configuration>Release Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|x64">
- <Configuration>Release Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{3F5EA225-F4B7-4413-AEB3-4E4E5751E438}</ProjectGuid>
- <RootNamespace>MatroskaSplitter</RootNamespace>
- <Keyword>MFCProj</Keyword>
- <ProjectName>MatroskaSplitter</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <Import Project="..\..\..\platform.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">.ax</TargetExt>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MatroskaSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MatroskaSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MatroskaSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MatroskaSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="MatroskaFile.cpp" />
- <ClCompile Include="MatroskaSplitter.cpp" />
- <ClCompile Include="stdafx.cpp">
- <PrecompiledHeader>Create</PrecompiledHeader>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="MatroskaSplitter.def" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="MatroskaFile.h" />
- <ClInclude Include="MatroskaSplitter.h" />
- <ClInclude Include="resource.h">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ClInclude>
- <ClInclude Include="stdafx.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="MatroskaSplitter.rc">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ResourceCompile>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\DSUtil\DSUtil.vcxproj">
- <Project>{fc70988b-1ae5-4381-866d-4f405e28ac42}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\Kasumi\Kasumi.vcxproj">
- <Project>{0d252872-7542-4232-8d02-53f9182aee15}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\system\system.vcxproj">
- <Project>{c2082189-3ecb-4079-91fa-89d3c8a305c0}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\zlib\zlib.vcxproj">
- <Project>{2fcd4b66-9cf9-4c8f-bc70-37cd20002d49}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\BaseClasses\BaseClasses.vcxproj">
- <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\Filters.vcxproj">
- <Project>{273b3149-3192-4b75-a791-470320b90812}</Project>
- </ProjectReference>
- <ProjectReference Include="..\BaseSplitter\BaseSplitter.vcxproj">
- <Project>{37768b3f-89bc-4c16-b2a8-767c5da84c3f}</Project>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.vcxproj.filters b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.vcxproj.filters
deleted file mode 100644
index f06730c57..000000000
--- a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.vcxproj.filters
+++ /dev/null
@@ -1,61 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{9ef31dfd-95ec-4218-a840-f6c00ca6a2f4}</UniqueIdentifier>
- <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{387f16df-2821-49ac-b2e0-3e0c454021dc}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{482333a1-25da-4a3f-a09b-495e204e4b32}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="MatroskaFile.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="MatroskaSplitter.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="stdafx.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="MatroskaSplitter.def">
- <Filter>Source Files</Filter>
- </None>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="MatroskaFile.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="MatroskaSplitter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="resource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="stdafx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="MatroskaSplitter.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/MatroskaSplitter/resource.h b/src/filters/parser/MatroskaSplitter/resource.h
deleted file mode 100644
index 1cd7111d9..000000000
--- a/src/filters/parser/MatroskaSplitter/resource.h
+++ /dev/null
@@ -1,14 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by MatroskaSplitter.rc
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 101
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/filters/parser/MatroskaSplitter/stdafx.cpp b/src/filters/parser/MatroskaSplitter/stdafx.cpp
deleted file mode 100644
index 784f2cebc..000000000
--- a/src/filters/parser/MatroskaSplitter/stdafx.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
diff --git a/src/filters/parser/MatroskaSplitter/stdafx.h b/src/filters/parser/MatroskaSplitter/stdafx.h
deleted file mode 100644
index 4b7a0b4bc..000000000
--- a/src/filters/parser/MatroskaSplitter/stdafx.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../../DSUtil/SharedInclude.h"
-#include "../../../../include/stdafx_common.h"
-#include "../../../../include/stdafx_common_afx.h"
-#include "../../../../include/stdafx_common_dshow.h"
-#include "../../../DSUtil/DSUtil.h"
diff --git a/src/filters/parser/MpaSplitter/MpaSplitter.cpp b/src/filters/parser/MpaSplitter/MpaSplitter.cpp
deleted file mode 100644
index 3cdc5f1d7..000000000
--- a/src/filters/parser/MpaSplitter/MpaSplitter.cpp
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <MMReg.h>
-#ifdef STANDALONE_FILTER
-#include <InitGuid.h>
-#endif
-#include "MpaSplitter.h"
-#include "moreuuids.h"
-
-#ifdef STANDALONE_FILTER
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG1Audio},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL}
-};
-
-const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, 0, nullptr}
-};
-
-const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CMpaSplitterFilter), MpaSplitterName, MERIT_NORMAL + 1, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CMpaSourceFilter), MpaSourceName, MERIT_NORMAL + 1, 0, nullptr, CLSID_LegacyAmFilterCategory},
-};
-
-CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMpaSplitterFilter>, nullptr, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CMpaSourceFilter>, nullptr, &sudFilter[1]},
-};
-
-int g_cTemplates = _countof(g_Templates);
-
-STDAPI DllRegisterServer()
-{
- CAtlList<CString> chkbytes;
- chkbytes.AddTail(_T("0,2,FFE0,FFE0"));
- chkbytes.AddTail(_T("0,10,FFFFFF00000080808080,49443300000000000000"));
- RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_MPEG1Audio, chkbytes, nullptr);
-
- return AMovieDllRegisterServer2(TRUE);
-}
-
-STDAPI DllUnregisterServer()
-{
- return AMovieDllRegisterServer2(FALSE);
-}
-
-#include "../../FilterApp.h"
-
-CFilterApp theApp;
-
-#endif
-
-//
-// CMpaSplitterFilter
-//
-
-CMpaSplitterFilter::CMpaSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("CMpaSplitterFilter"), pUnk, phr, __uuidof(this))
-{
-}
-
-STDMETHODIMP CMpaSplitterFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
-{
- CheckPointer(ppv, E_POINTER);
-
- return
- __super::NonDelegatingQueryInterface(riid, ppv);
-}
-
-STDMETHODIMP CMpaSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo)
-{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
-
- if (m_pName && m_pName[0] == L'M' && m_pName[1] == L'P' && m_pName[2] == L'C') {
- (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
- wcscpy_s(pInfo->achName, MpaSourceName);
- }
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
-}
-
-HRESULT CMpaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
-{
- CheckPointer(pAsyncReader, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- m_pFile.Free();
-
- m_pFile.Attach(DEBUG_NEW CMpaSplitterFile(pAsyncReader, hr));
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- CAtlArray<CMediaType> mts;
- mts.Add(m_pFile->GetMediaType());
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DEBUG_NEW CBaseSplitterOutputPin(mts, L"Audio", this, this, &hr));
- AddOutputPin(0, pPinOut);
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration = m_pFile->GetDuration();
-
- CStringW str, title;
- if (m_pFile->m_tags.Lookup('TIT2', str)) {
- title = str;
- }
- if (m_pFile->m_tags.Lookup('TYER', str) && !title.IsEmpty() && !str.IsEmpty()) {
- title += L" (" + str + L")";
- }
- if (!title.IsEmpty()) {
- SetProperty(L"TITL", title);
- }
- if (m_pFile->m_tags.Lookup('TPE1', str)) {
- SetProperty(L"AUTH", str);
- }
- if (m_pFile->m_tags.Lookup('TCOP', str)) {
- SetProperty(L"CPYR", str);
- }
- if (m_pFile->m_tags.Lookup('COMM', str)) {
- SetProperty(L"DESC", str);
- }
-
- return !m_pOutputs.IsEmpty() ? S_OK : E_FAIL;
-}
-
-STDMETHODIMP CMpaSplitterFilter::GetDuration(LONGLONG* pDuration)
-{
- CheckPointer(pDuration, E_POINTER);
- CheckPointer(m_pFile, VFW_E_NOT_CONNECTED);
-
- *pDuration = m_pFile->GetDuration();
-
- return S_OK;
-}
-
-bool CMpaSplitterFilter::DemuxInit()
-{
- SetThreadName((DWORD) - 1, "CMpaSplitterFilter");
- if (!m_pFile) {
- return false;
- }
-
- // TODO
-
- return true;
-}
-
-void CMpaSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
-{
- __int64 startpos = m_pFile->GetStartPos();
- __int64 endpos = m_pFile->GetEndPos();
-
- if (rt <= 0 || m_pFile->GetDuration() <= 0) {
- m_pFile->Seek(startpos);
- m_rtStart = 0;
- } else {
- m_pFile->Seek(startpos + (__int64)((1.0 * rt / m_pFile->GetDuration()) * (endpos - startpos)));
- m_rtStart = rt;
- }
-
-}
-
-bool CMpaSplitterFilter::DemuxLoop()
-{
- HRESULT hr = S_OK;
-
- int FrameSize;
- REFERENCE_TIME rtDuration;
-
- while (SUCCEEDED(hr) && !CheckRequest(nullptr) && m_pFile->GetPos() < m_pFile->GetEndPos() - 9) {
- if (!m_pFile->Sync(FrameSize, rtDuration)) {
- Sleep(1);
- continue;
- }
-
- CAutoPtr<Packet> p(DEBUG_NEW Packet());
- p->SetCount(FrameSize);
- m_pFile->ByteRead(p->GetData(), FrameSize);
-
- p->TrackNumber = 0;
- p->rtStart = m_rtStart;
- p->rtStop = m_rtStart + rtDuration;
- p->bSyncPoint = TRUE;
-
- hr = DeliverPacket(p);
-
- m_rtStart += rtDuration;
- }
-
- return true;
-}
-
-//
-// CMpaSourceFilter
-//
-
-CMpaSourceFilter::CMpaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CMpaSplitterFilter(pUnk, phr)
-{
- m_clsid = __uuidof(this);
- m_pInput.Free();
-}
diff --git a/src/filters/parser/MpaSplitter/MpaSplitter.def b/src/filters/parser/MpaSplitter/MpaSplitter.def
deleted file mode 100644
index 6492e5cd6..000000000
--- a/src/filters/parser/MpaSplitter/MpaSplitter.def
+++ /dev/null
@@ -1,5 +0,0 @@
-EXPORTS
- DllCanUnloadNow PRIVATE
- DllGetClassObject PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
diff --git a/src/filters/parser/MpaSplitter/MpaSplitter.h b/src/filters/parser/MpaSplitter/MpaSplitter.h
deleted file mode 100644
index 676d9d8d0..000000000
--- a/src/filters/parser/MpaSplitter/MpaSplitter.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../BaseSplitter/BaseSplitter.h"
-#include "MpaSplitterFile.h"
-
-#define MpaSplitterName L"MPC Mpa Splitter"
-#define MpaSourceName L"MPC Mpa Source"
-
-class __declspec(uuid("0E9D4BF7-CBCB-46C7-BD80-4EF223A3DC2B"))
- CMpaSplitterFilter : public CBaseSplitterFilter
-{
- REFERENCE_TIME m_rtStart;
-
-protected:
- CAutoPtr<CMpaSplitterFile> m_pFile;
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
-
- STDMETHODIMP GetDuration(LONGLONG* pDuration);
-
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
-
-public:
- CMpaSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // CBaseFilter
-
- STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
-
-};
-
-class __declspec(uuid("59A0DB73-0287-4C9A-9D3C-8CFF39F8E5DB"))
- CMpaSourceFilter : public CMpaSplitterFilter
-{
-public:
- CMpaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
-};
diff --git a/src/filters/parser/MpaSplitter/MpaSplitter.rc b/src/filters/parser/MpaSplitter/MpaSplitter.rc
deleted file mode 100644
index 6fd827bc0..000000000
--- a/src/filters/parser/MpaSplitter/MpaSplitter.rc
+++ /dev/null
@@ -1,102 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-#include "version.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (United States) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION MPC_VERSION_NUM
- PRODUCTVERSION MPC_VERSION_NUM
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS VOS_NT_WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE VFT2_UNKNOWN
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", MPC_VERSION_COMMENTS
- VALUE "CompanyName", MPC_COMP_NAME_STR
- VALUE "FileDescription", "Mpa Splitter"
- VALUE "FileVersion", MPC_VERSION_STR_FULL
- VALUE "InternalName", "Mpa Splitter"
- VALUE "LegalCopyright", MPC_COPYRIGHT_STR
- VALUE "OriginalFilename", "MpaSplitter.ax"
- VALUE "ProductName", "Mpa Splitter"
- VALUE "ProductVersion", MPC_VERSION_STR_FULL
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // English (United States) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/src/filters/parser/MpaSplitter/MpaSplitter.vcxproj b/src/filters/parser/MpaSplitter/MpaSplitter.vcxproj
deleted file mode 100644
index d88344341..000000000
--- a/src/filters/parser/MpaSplitter/MpaSplitter.vcxproj
+++ /dev/null
@@ -1,255 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug Filter|Win32">
- <Configuration>Debug Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug Filter|x64">
- <Configuration>Debug Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|Win32">
- <Configuration>Release Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|x64">
- <Configuration>Release Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{C0F7A036-FC2D-40DF-9852-C37518DB6B3E}</ProjectGuid>
- <RootNamespace>MpaSplitter</RootNamespace>
- <Keyword>MFCProj</Keyword>
- <ProjectName>MpaSplitter</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <Import Project="..\..\..\platform.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">.ax</TargetExt>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MpaSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MpaSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MpaSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MpaSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="MpaSplitter.cpp" />
- <ClCompile Include="MpaSplitterFile.cpp" />
- <ClCompile Include="stdafx.cpp">
- <PrecompiledHeader>Create</PrecompiledHeader>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="MpaSplitter.def" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="MpaSplitter.h" />
- <ClInclude Include="MpaSplitterFile.h" />
- <ClInclude Include="resource.h">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ClInclude>
- <ClInclude Include="stdafx.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="MpaSplitter.rc">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ResourceCompile>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\DSUtil\DSUtil.vcxproj">
- <Project>{fc70988b-1ae5-4381-866d-4f405e28ac42}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\Kasumi\Kasumi.vcxproj">
- <Project>{0d252872-7542-4232-8d02-53f9182aee15}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\system\system.vcxproj">
- <Project>{c2082189-3ecb-4079-91fa-89d3c8a305c0}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\BaseClasses\BaseClasses.vcxproj">
- <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\Filters.vcxproj">
- <Project>{273b3149-3192-4b75-a791-470320b90812}</Project>
- </ProjectReference>
- <ProjectReference Include="..\BaseSplitter\BaseSplitter.vcxproj">
- <Project>{37768b3f-89bc-4c16-b2a8-767c5da84c3f}</Project>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/MpaSplitter/MpaSplitter.vcxproj.filters b/src/filters/parser/MpaSplitter/MpaSplitter.vcxproj.filters
deleted file mode 100644
index 370f5a9d5..000000000
--- a/src/filters/parser/MpaSplitter/MpaSplitter.vcxproj.filters
+++ /dev/null
@@ -1,61 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{83fa794a-e93b-4f78-92a0-3af952b1b16c}</UniqueIdentifier>
- <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{ff3aa9c3-cd89-4cdd-a526-fb6c03d372b7}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{ce0a230d-519f-43e0-bb7d-cd56d97cc3de}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="MpaSplitter.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="MpaSplitterFile.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="stdafx.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="MpaSplitter.def">
- <Filter>Source Files</Filter>
- </None>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="MpaSplitter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="MpaSplitterFile.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="resource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="stdafx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="MpaSplitter.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/MpaSplitter/MpaSplitterFile.cpp b/src/filters/parser/MpaSplitter/MpaSplitterFile.cpp
deleted file mode 100644
index 27317e18e..000000000
--- a/src/filters/parser/MpaSplitter/MpaSplitterFile.cpp
+++ /dev/null
@@ -1,431 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <MMReg.h>
-#include "MpaSplitterFile.h"
-
-#ifdef STANDALONE_FILTER
-#include <InitGuid.h>
-#endif
-#include "moreuuids.h"
-
-#define FRAMES_FLAG 0x0001
-#define MPA_HEADER_SIZE 4 // MPEG-Audio Header Size
-
-//
-
-static const LPCTSTR s_genre[] = {
- _T("Blues"), _T("Classic Rock"), _T("Country"), _T("Dance"),
- _T("Disco"), _T("Funk"), _T("Grunge"), _T("Hip-Hop"),
- _T("Jazz"), _T("Metal"), _T("New Age"), _T("Oldies"),
- _T("Other"), _T("Pop"), _T("R&B"), _T("Rap"),
- _T("Reggae"), _T("Rock"), _T("Techno"), _T("Industrial"),
- _T("Alternative"), _T("Ska"), _T("Death Metal"), _T("Pranks"),
- _T("Soundtrack"), _T("Euro-Techno"), _T("Ambient"), _T("Trip-Hop"),
- _T("Vocal"), _T("Jazz+Funk"), _T("Fusion"), _T("Trance"),
- _T("Classical"), _T("Instrumental"), _T("Acid"), _T("House"),
- _T("Game"), _T("Sound Clip"), _T("Gospel"), _T("Noise"),
- _T("Alternative Rock"), _T("Bass"), _T("Soul"), _T("Punk"),
- _T("Space"), _T("Meditative"), _T("Instrumental Pop"), _T("Instrumental Rock"),
- _T("Ethnic"), _T("Gothic"), _T("Darkwave"), _T("Techno-Industrial"),
- _T("Electronic"), _T("Pop-Folk"), _T("Eurodance"), _T("Dream"),
- _T("Southern Rock"), _T("Comedy"), _T("Cult"), _T("Gangsta"),
- _T("Top 40"), _T("Christian Rap"), _T("Pop/Funk"), _T("Jungle"),
- _T("Native US"), _T("Cabaret"), _T("New Wave"), _T("Psychadelic"),
- _T("Rave"), _T("Showtunes"), _T("Trailer"), _T("Lo-Fi"),
- _T("Tribal"), _T("Acid Punk"), _T("Acid Jazz"), _T("Polka"),
- _T("Retro"), _T("Musical"), _T("Rock & Roll"), _T("Hard Rock"),
- _T("Folk"), _T("Folk-Rock"), _T("National Folk"), _T("Swing"),
- _T("Fast Fusion"), _T("Bebob"), _T("Latin"), _T("Revival"),
- _T("Celtic"), _T("Bluegrass"), _T("Avantgarde"), _T("Gothic Rock"),
- _T("Progressive Rock"), _T("Psychedelic Rock"), _T("Symphonic Rock"), _T("Slow Rock"),
- _T("Big Band"), _T("Chorus"), _T("Easy Listening"), _T("Acoustic"),
- _T("Humour"), _T("Speech"), _T("Chanson"), _T("Opera"),
- _T("Chamber Music"), _T("Sonata"), _T("Symphony"), _T("Booty Bass"),
- _T("Primus"), _T("Porn Groove"), _T("Satire"), _T("Slow Jam"),
- _T("Club"), _T("Tango"), _T("Samba"), _T("Folklore"),
- _T("Ballad"), _T("Power Ballad"), _T("Rhytmic Soul"), _T("Freestyle"),
- _T("Duet"), _T("Punk Rock"), _T("Drum Solo"), _T("Acapella"),
- _T("Euro-House"), _T("Dance Hall"), _T("Goa"), _T("Drum & Bass"),
- _T("Club-House"), _T("Hardcore"), _T("Terror"), _T("Indie"),
- _T("BritPop"), _T("Negerpunk"), _T("Polsk Punk"), _T("Beat"),
- _T("Christian Gangsta"), _T("Heavy Metal"), _T("Black Metal"),
- _T("Crossover"), _T("Contemporary C"), _T("Christian Rock"), _T("Merengue"), _T("Salsa"),
- _T("Thrash Metal"), _T("Anime"), _T("JPop"), _T("SynthPop"),
-};
-
-//
-
-CMpaSplitterFile::CMpaSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr)
- : CBaseSplitterFileEx(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false)
- , m_mode(none)
- , m_rtDuration(0)
- , m_startpos(0)
- , m_endpos(0)
- , m_totalbps(0)
- , m_bIsVBR(false)
-{
- if (SUCCEEDED(hr)) {
- hr = Init();
- }
-}
-
-HRESULT CMpaSplitterFile::Init()
-{
- m_startpos = 0;
- m_endpos = GetLength();
-
- Seek(0);
-
- // some files can be determined as Mpeg Audio
- if ((BitRead(24, true) == 0x000001) || // ?
- (BitRead(32, true) == 'RIFF') || // skip AVI and WAV files
- (BitRead(24, true) == 'AMV')) { // skip MTV files (.amv .mtv)
- return E_FAIL;
- }
-
- if (m_endpos > 128 && IsRandomAccess()) {
- Seek(m_endpos - 128);
-
- if (BitRead(24) == 'TAG') {
- m_endpos -= 128;
-
- CStringA str;
-
- // title
- ByteRead((BYTE*)str.GetBufferSetLength(30), 30);
- m_tags['TIT2'] = CStringW(str).Trim();
-
- // artist
- ByteRead((BYTE*)str.GetBufferSetLength(30), 30);
- m_tags['TPE1'] = CStringW(str).Trim();
-
- // album
- ByteRead((BYTE*)str.GetBufferSetLength(30), 30);
- m_tags['TALB'] = CStringW(str).Trim();
-
- // year
- ByteRead((BYTE*)str.GetBufferSetLength(4), 4);
- m_tags['TYER'] = CStringW(str).Trim();
-
- // comment
- ByteRead((BYTE*)str.GetBufferSetLength(30), 30);
- m_tags['COMM'] = CStringW(str).Trim();
-
- // track
- LPCSTR s = str;
- if (s[28] == 0 && s[29] != 0) {
- m_tags['TRCK'].Format(L"%d", s[29]);
- }
-
- // genre
- BYTE genre = (BYTE)BitRead(8);
- if (genre < _countof(s_genre)) {
- m_tags['TCON'] = CStringW(s_genre[genre]);
- }
- }
- }
-
- Seek(0);
-
- bool MP3_find = false;
-
- while (BitRead(24, true) == 'ID3') {
- MP3_find = true;
-
- BitRead(24);
-
- BYTE major = (BYTE)BitRead(8);
- BYTE revision = (BYTE)BitRead(8);
- UNREFERENCED_PARAMETER(revision);
-
- BYTE flags = (BYTE)BitRead(8);
- UNREFERENCED_PARAMETER(flags);
- DWORD size = 0;
- if (BitRead(1) != 0) {
- return E_FAIL;
- }
- size |= BitRead(7) << 21;
- if (BitRead(1) != 0) {
- return E_FAIL;
- }
- size |= BitRead(7) << 14;
- if (BitRead(1) != 0) {
- return E_FAIL;
- }
- size |= BitRead(7) << 7;
- if (BitRead(1) != 0) {
- return E_FAIL;
- }
- size |= BitRead(7);
-
- m_startpos = GetPos() + size;
-
- // TODO: read extended header
-
- if (major <= 4) {
- __int64 pos = GetPos();
-
- while (pos < m_startpos) {
- Seek(pos);
-
- DWORD tag = (DWORD)BitRead(32);
- DWORD size = 0;
- size |= BitRead(8) << 24;
- size |= BitRead(8) << 16;
- size |= BitRead(8) << 8;
- size |= BitRead(8);
- WORD flags = (WORD)BitRead(16);
- UNREFERENCED_PARAMETER(flags);
-
- pos += 4 + 4 + 2 + size;
-
- if (!size || pos >= m_startpos) {
- break;
- }
-
- if (tag == 'TIT2'
- || tag == 'TPE1'
- || tag == 'TALB'
- || tag == 'TYER'
- || tag == 'COMM'
- || tag == 'TRCK') {
- BYTE encoding = (BYTE)BitRead(8);
- size--;
-
- WORD bom = (WORD)BitRead(16, true);
-
- CStringA str;
- CStringW wstr;
-
- if (encoding > 0 && size >= 2 && bom == 0xfffe) {
- BitRead(16);
- size = (size - 2) / 2;
- ByteRead((BYTE*)wstr.GetBufferSetLength(size), size * 2);
- m_tags[tag] = wstr.Trim();
- } else if (encoding > 0 && size >= 2 && bom == 0xfeff) {
- BitRead(16);
- size = (size - 2) / 2;
- ByteRead((BYTE*)wstr.GetBufferSetLength(size), size * 2);
- for (int i = 0, j = wstr.GetLength(); i < j; i++) {
- wstr.SetAt(i, (wstr[i] << 8) | (wstr[i] >> 8));
- }
- m_tags[tag] = wstr.Trim();
- } else {
- ByteRead((BYTE*)str.GetBufferSetLength(size), size);
- m_tags[tag] = (encoding > 0 ? UTF8To16(str) : CStringW(str)).Trim();
- }
- }
- }
- }
-
- Seek(m_startpos);
-
- for (int i = 0; i < (1 << 20) && m_startpos < m_endpos && BitRead(8, true) == 0; i++) {
- BitRead(8), m_startpos++;
- }
- }
-
- int searchlen = 0;
- __int64 startpos = 0;
- __int64 syncpos = 0;
-
- __int64 startpos_mp3 = m_startpos;
- while (m_mode == none) {
- if (!MP3_find && GetPos() >= 2048) {
- break;
- }
- searchlen = (int)min(m_endpos - startpos_mp3, 512);
- Seek(startpos_mp3);
-
- // If we fail to see sync bytes, we reposition here and search again
- syncpos = startpos_mp3 + searchlen;
-
- // Check for a valid MPA header
- if (Read(m_mpahdr, searchlen, true, &m_mt)) {
- m_mode = mpa;
-
- syncpos = GetPos();
- startpos = syncpos - 4;
-
- // make sure the first frame is followed by another of the same kind (validates m_mpahdr basically)
- Seek(startpos + m_mpahdr.FrameSize);
- if (!Sync(4)) {
- m_mode = none;
- } else {
- break;
- }
- }
-
- // If we have enough room to search for a valid header, then skip ahead and try again
- if (m_endpos - syncpos >= 8) {
- startpos_mp3 = syncpos;
- } else {
- break;
- }
- }
-
- searchlen = (int)min(m_endpos - m_startpos, m_startpos > 0 ? 512 : 7);
- Seek(m_startpos);
-
- if (m_mode == none && Read(m_aachdr, searchlen, &m_mt)) {
- m_mode = mp4a;
-
- startpos = GetPos() - (m_aachdr.fcrc ? 7 : 9);
-
- // make sure the first frame is followed by another of the same kind (validates m_aachdr basically)
- Seek(startpos + m_aachdr.aac_frame_length);
- if (!Sync(9)) {
- m_mode = none;
- }
- }
-
- if (m_mode == none) {
- return E_FAIL;
- }
-
- m_startpos = startpos;
-
- if (m_mode == mpa) {
- DWORD m_dwFrames = 0; // total number of frames
- Seek(m_startpos + MPA_HEADER_SIZE + 32);
- if (BitRead(32, true) == 'Xing' || BitRead(32, true) == 'Info') {
- BitRead(32); // Skip ID tag
- DWORD dwFlags = (DWORD)BitRead(32);
- // extract total number of frames in file
- if (dwFlags & FRAMES_FLAG) {
- m_dwFrames = (DWORD)BitRead(32);
- }
-
- } else if (BitRead(32, true) == 'VBRI') {
- BitRead(32); // Skip ID tag
- // extract all fields from header (all mandatory)
- BitRead(16); // version
- BitRead(16); // delay
- BitRead(16); // quality
- BitRead(32); // bytes
- m_dwFrames = (DWORD)BitRead(32); // extract total number of frames in file
- }
-
- if (m_dwFrames) {
-
- bool l3ext = m_mpahdr.layer == 3 && !(m_mpahdr.version & 1);
- DWORD m_dwSamplesPerFrame = m_mpahdr.layer == 1 ? 384 : l3ext ? 576 : 1152;
-
- m_bIsVBR = true;
- m_rtDuration = 10000000i64 * (m_dwFrames * m_dwSamplesPerFrame / m_mpahdr.nSamplesPerSec);
- }
- }
-
- Seek(m_startpos);
-
- int FrameSize;
- REFERENCE_TIME rtFrameDur, rtPrevDur = -1;
- clock_t start = clock();
- int i = 0;
- while (Sync(FrameSize, rtFrameDur) && (clock() - start) < CLOCKS_PER_SEC) {
- TRACE(_T("%I64d\n"), m_rtDuration);
- Seek(GetPos() + FrameSize);
- i = rtPrevDur == m_rtDuration ? i + 1 : 0;
- if (i == 10) {
- break;
- }
- rtPrevDur = m_rtDuration;
- }
-
- return S_OK;
-}
-
-bool CMpaSplitterFile::Sync(int limit)
-{
- int FrameSize;
- REFERENCE_TIME rtDuration;
- return Sync(FrameSize, rtDuration, limit);
-}
-
-bool CMpaSplitterFile::Sync(int& FrameSize, REFERENCE_TIME& rtDuration, int limit)
-{
- __int64 endpos = min(m_endpos, GetPos() + limit);
-
- if (m_mode == mpa) {
- while (GetPos() <= endpos - 4) {
- mpahdr h;
-
- if (Read(h, (int)(endpos - GetPos()), true)) {
- if (m_mpahdr.version == h.version
- && m_mpahdr.layer == h.layer
- && m_mpahdr.channels == h.channels) {
- Seek(GetPos() - 4);
- AdjustDuration(h.nBytesPerSec);
-
- FrameSize = h.FrameSize;
- rtDuration = h.rtDuration;
-
- return true;
- }
- } else {
- break;
- }
- }
- } else if (m_mode == mp4a) {
- while (GetPos() <= endpos - 9) {
- aachdr h;
-
- if (Read(h, (int)(endpos - GetPos()))) {
- if (m_aachdr.version == h.version
- && m_aachdr.layer == h.layer
- && m_aachdr.channels == h.channels) {
- Seek(GetPos() - (h.fcrc ? 7 : 9));
- AdjustDuration(h.nBytesPerSec);
- Seek(GetPos() + (h.fcrc ? 7 : 9));
-
- FrameSize = h.FrameSize;
- rtDuration = h.rtDuration;
-
- return true;
- }
- } else {
- break;
- }
- }
- }
-
- return false;
-}
-
-void CMpaSplitterFile::AdjustDuration(int nBytesPerSec)
-{
- ASSERT(nBytesPerSec);
-
- if (!m_bIsVBR) {
- int rValue;
- if (!m_pos2bps.Lookup(GetPos(), rValue)) {
- m_totalbps += nBytesPerSec;
- if (!m_totalbps) {
- return;
- }
- m_pos2bps.SetAt(GetPos(), nBytesPerSec);
- __int64 avgbps = m_totalbps / m_pos2bps.GetCount();
- m_rtDuration = 10000000i64 * (m_endpos - m_startpos) / avgbps;
- }
- }
-}
diff --git a/src/filters/parser/MpaSplitter/MpaSplitterFile.h b/src/filters/parser/MpaSplitter/MpaSplitterFile.h
deleted file mode 100644
index 41c5a09c8..000000000
--- a/src/filters/parser/MpaSplitter/MpaSplitterFile.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../BaseSplitter/BaseSplitter.h"
-
-class CMpaSplitterFile : public CBaseSplitterFileEx
-{
- CMediaType m_mt;
- REFERENCE_TIME m_rtDuration;
-
- enum { none, mpa, mp4a } m_mode;
-
- mpahdr m_mpahdr;
- aachdr m_aachdr;
- __int64 m_startpos, m_endpos;
-
- __int64 m_totalbps;
- CRBMap<__int64, int> m_pos2bps;
-
- HRESULT Init();
- void AdjustDuration(int nBytesPerSec);
-
- bool m_bIsVBR;
-
-public:
- CMpaSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr);
-
- CAtlMap<DWORD, CStringW> m_tags;
-
- const CMediaType& GetMediaType() { return m_mt; }
- REFERENCE_TIME GetDuration() { return IsRandomAccess() ? m_rtDuration : 0; }
-
- __int64 GetStartPos() { return m_startpos; }
- __int64 GetEndPos() { return m_endpos; }
-
- bool Sync(int limit = 0x2000);
- bool Sync(int& FrameSize, REFERENCE_TIME& rtDuration, int limit = 0x2000);
-};
diff --git a/src/filters/parser/MpaSplitter/resource.h b/src/filters/parser/MpaSplitter/resource.h
deleted file mode 100644
index c2fcfb22b..000000000
--- a/src/filters/parser/MpaSplitter/resource.h
+++ /dev/null
@@ -1,15 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by MpaSplitter.rc
-//
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 101
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/filters/parser/MpaSplitter/stdafx.cpp b/src/filters/parser/MpaSplitter/stdafx.cpp
deleted file mode 100644
index 784f2cebc..000000000
--- a/src/filters/parser/MpaSplitter/stdafx.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
diff --git a/src/filters/parser/MpaSplitter/stdafx.h b/src/filters/parser/MpaSplitter/stdafx.h
deleted file mode 100644
index a29dc1481..000000000
--- a/src/filters/parser/MpaSplitter/stdafx.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../../DSUtil/SharedInclude.h"
-#include "../../../../include/stdafx_common.h"
-#include "../../../../include/stdafx_common_afx.h"
-#include "../../../../include/stdafx_common_dshow.h"
-
-#include <atlcoll.h>
-#include "../../../DSUtil/DSUtil.h"
-#include "../../../DSUtil/MediaTypes.h"
diff --git a/src/filters/parser/MpegSplitter/IMpegSplitterFilter.h b/src/filters/parser/MpegSplitter/IMpegSplitterFilter.h
deleted file mode 100644
index e0ad52cb0..000000000
--- a/src/filters/parser/MpegSplitter/IMpegSplitterFilter.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * (C) 2011-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-interface __declspec(uuid("1DC9C085-04AC-4BB8-B2BD-C49A4D30B104"))
-IMpegSplitterFilter :
-public IUnknown {
- STDMETHOD(Apply()) PURE;
-
- STDMETHOD(SetFastStreamChange(BOOL nValue)) PURE;
- STDMETHOD_(BOOL, GetFastStreamChange()) PURE;
-
- STDMETHOD(SetForcedSub(BOOL nValue)) PURE;
- STDMETHOD_(BOOL, GetForcedSub()) PURE;
-
- STDMETHOD(SetAudioLanguageOrder(WCHAR * nValue)) PURE;
- STDMETHOD_(WCHAR*, GetAudioLanguageOrder()) PURE;
-
- STDMETHOD(SetSubtitlesLanguageOrder(WCHAR * nValue)) PURE;
- STDMETHOD_(WCHAR*, GetSubtitlesLanguageOrder()) PURE;
-
- STDMETHOD(SetVC1_GuidFlag(int nValue)) PURE;
- STDMETHOD_(int, GetVC1_GuidFlag()) PURE;
-
- STDMETHOD(SetTrueHD(int nValue)) PURE;
- STDMETHOD_(int, GetTrueHD()) PURE;
-
- STDMETHOD(SetAlternativeDuration(BOOL nValue)) PURE;
- STDMETHOD_(BOOL, GetAlternativeDuration()) PURE;
-
- STDMETHOD_(int, GetMPEGType()) PURE;
-};
diff --git a/src/filters/parser/MpegSplitter/MpegSplitter.cpp b/src/filters/parser/MpegSplitter/MpegSplitter.cpp
deleted file mode 100644
index 136c663e0..000000000
--- a/src/filters/parser/MpegSplitter/MpegSplitter.cpp
+++ /dev/null
@@ -1,2087 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <MMReg.h>
-#ifdef STANDALONE_FILTER
-#include <InitGuid.h>
-#endif
-#include <dmodshow.h>
-#include "MpegSplitter.h"
-#include "moreuuids.h"
-#include "../../../DSUtil/AudioParser.h"
-#include "../../../DSUtil/DSUtil.h"
-#include "../../../mpc-hc/SettingsDefines.h"
-
-TCHAR* MPEG2_Profile[] = {
- L"0",
- L"High Profile",
- L"Spatially Scalable Profile",
- L"SNR Scalable Profile",
- L"Main Profile",
- L"Simple Profile",
- L"6",
- L"7",
-};
-
-TCHAR* MPEG2_Level[] = {
- L"0",
- L"1",
- L"2",
- L"3",
- L"High Level",
- L"4",
- L"High1440 Level",
- L"5",
- L"Main Level",
- L"6",
- L"Low Level",
- L"7",
- L"8",
- L"9",
- L"10",
- L"11",
-};
-
-#ifdef STANDALONE_FILTER
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG1System},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG2_PROGRAM},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG2_TRANSPORT},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG2_PVA},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
-};
-
-const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, 0, nullptr},
-};
-
-const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CMpegSplitterFilter), MpegSplitterName, MERIT_NORMAL + 1, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CMpegSourceFilter), MpegSourceName, MERIT_UNLIKELY, 0, nullptr, CLSID_LegacyAmFilterCategory},
-};
-
-CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMpegSplitterFilter>, nullptr, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CMpegSourceFilter>, nullptr, &sudFilter[1]},
- {L"CMpegSplitterPropertyPage", &__uuidof(CMpegSplitterSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CMpegSplitterSettingsWnd>>},
-};
-
-int g_cTemplates = _countof(g_Templates);
-
-STDAPI DllRegisterServer()
-{
- DeleteRegKey(_T("Media Type\\Extensions\\"), _T(".ts"));
-
- RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_MPEG1System, _T("0,16,FFFFFFFFF100010001800001FFFFFFFF,000001BA2100010001800001000001BB"), nullptr);
- RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_MPEG2_PROGRAM, _T("0,5,FFFFFFFFC0,000001BA40"), nullptr);
- RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_MPEG2_PVA, _T("0,8,fffffc00ffe00000,4156000055000000"), nullptr);
-
- CAtlList<CString> chkbytes;
- chkbytes.AddTail(_T("0,1,,47,188,1,,47,376,1,,47"));
- chkbytes.AddTail(_T("4,1,,47,196,1,,47,388,1,,47"));
- chkbytes.AddTail(_T("0,4,,54467263,1660,1,,47")); // TFrc
- RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_MPEG2_TRANSPORT, chkbytes, nullptr);
-
- return AMovieDllRegisterServer2(TRUE);
-}
-
-STDAPI DllUnregisterServer()
-{
- return AMovieDllRegisterServer2(FALSE);
-}
-
-#include "../../FilterApp.h"
-
-CFilterApp theApp;
-
-#endif
-
-template <typename t_CType>
-t_CType GetFormatHelper(t_CType& _pInfo, const CMediaType* _pFormat)
-{
- ASSERT(_pFormat->cbFormat >= sizeof(*_pInfo));
- _pInfo = (t_CType)_pFormat->pbFormat;
- return _pInfo;
-}
-
-static int GetHighestBitSet32(unsigned long _Value)
-{
- unsigned long Ret;
- unsigned char bNonZero = _BitScanReverse(&Ret, _Value);
- if (bNonZero) {
- return Ret;
- } else {
- return -1;
- }
-}
-
-CString FormatBitrate(double _Bitrate)
-{
- CString Temp;
- if (_Bitrate > 20000000) { // More than 2 mbit
- Temp.Format(L"%.2f mbit/s", double(_Bitrate) / 1000000.0);
- } else {
- Temp.Format(L"%.1f kbit/s", double(_Bitrate) / 1000.0);
- }
-
- return Temp;
-}
-
-CString FormatString(const wchar_t* pszFormat, ...)
-{
- CString Temp;
- ATLASSERT(AtlIsValidString(pszFormat));
-
- va_list argList;
- va_start(argList, pszFormat);
- Temp.FormatV(pszFormat, argList);
- va_end(argList);
-
- return Temp;
-}
-
-CString GetMediaTypeDesc(const CMediaType* _pMediaType, const CHdmvClipInfo::Stream* pClipInfo, int _PresentationType, CString lang)
-{
- const WCHAR* pPresentationDesc = nullptr;
-
- if (pClipInfo) {
- pPresentationDesc = StreamTypeToName(pClipInfo->m_Type);
- } else {
- pPresentationDesc = StreamTypeToName((PES_STREAM_TYPE)_PresentationType);
- }
-
- CString MajorType;
- CAtlList<CString> Infos;
-
- if (_pMediaType->majortype == MEDIATYPE_Video) {
- MajorType = "Video";
-
- if (pClipInfo) {
- CString name = ISO6392ToLanguage(pClipInfo->m_LanguageCode);
-
- if (!name.IsEmpty()) {
- Infos.AddTail(name);
- }
- } else {
- if (!lang.IsEmpty()) {
- Infos.AddTail(lang);
- }
- }
-
- const VIDEOINFOHEADER* pVideoInfo = nullptr;
- const VIDEOINFOHEADER2* pVideoInfo2 = nullptr;
-
- if (_pMediaType->formattype == FORMAT_MPEGVideo) {
- Infos.AddTail(L"MPEG");
-
- const MPEG1VIDEOINFO* pInfo = GetFormatHelper(pInfo, _pMediaType);
-
- pVideoInfo = &pInfo->hdr;
-
- } else if (_pMediaType->formattype == FORMAT_MPEG2_VIDEO) {
- const MPEG2VIDEOINFO* pInfo = GetFormatHelper(pInfo, _pMediaType);
-
- pVideoInfo2 = &pInfo->hdr;
-
- bool bIsAVC = false;
- bool bIsMPEG2 = false;
-
- if (pInfo->hdr.bmiHeader.biCompression == '1CVA') {
- bIsAVC = true;
- Infos.AddTail(L"AVC (H.264)");
- } else if (pInfo->hdr.bmiHeader.biCompression == 'CVMA') {
- bIsAVC = true;
- Infos.AddTail(L"MVC (Full)");
- } else if (pInfo->hdr.bmiHeader.biCompression == 'CVME') {
- bIsAVC = true;
- Infos.AddTail(L"MVC (Subset)");
- } else if (pInfo->hdr.bmiHeader.biCompression == 0) {
- Infos.AddTail(L"MPEG2");
- bIsMPEG2 = true;
- } else {
- WCHAR Temp[5];
- ZeroMemory(Temp, sizeof(Temp));
- Temp[0] = (pInfo->hdr.bmiHeader.biCompression >> 0) & 0xFF;
- Temp[1] = (pInfo->hdr.bmiHeader.biCompression >> 8) & 0xFF;
- Temp[2] = (pInfo->hdr.bmiHeader.biCompression >> 16) & 0xFF;
- Temp[3] = (pInfo->hdr.bmiHeader.biCompression >> 24) & 0xFF;
- Infos.AddTail(Temp);
- }
-
- if (bIsMPEG2) {
- Infos.AddTail(MPEG2_Profile[pInfo->dwProfile]);
- } else if (pInfo->dwProfile) {
- if (bIsAVC) {
- switch (pInfo->dwProfile) {
- case 44:
- Infos.AddTail(L"CAVLC Profile");
- break;
- case 66:
- Infos.AddTail(L"Baseline Profile");
- break;
- case 77:
- Infos.AddTail(L"Main Profile");
- break;
- case 88:
- Infos.AddTail(L"Extended Profile");
- break;
- case 100:
- Infos.AddTail(L"High Profile");
- break;
- case 110:
- Infos.AddTail(L"High 10 Profile");
- break;
- case 118:
- Infos.AddTail(L"Multiview High Profile");
- break;
- case 122:
- Infos.AddTail(L"High 4:2:2 Profile");
- break;
- case 244:
- Infos.AddTail(L"High 4:4:4 Profile");
- break;
- case 128:
- Infos.AddTail(L"Stereo High Profile");
- break;
- default:
- Infos.AddTail(FormatString(L"Profile %d", pInfo->dwProfile));
- break;
- }
- } else {
- Infos.AddTail(FormatString(L"Profile %d", pInfo->dwProfile));
- }
- }
-
- if (bIsMPEG2) {
- Infos.AddTail(MPEG2_Level[pInfo->dwLevel]);
- } else if (pInfo->dwLevel) {
- if (bIsAVC) {
- Infos.AddTail(FormatString(L"Level %1.1f", double(pInfo->dwLevel) / 10.0));
- } else {
- Infos.AddTail(FormatString(L"Level %d", pInfo->dwLevel));
- }
- }
- } else if (_pMediaType->formattype == FORMAT_VIDEOINFO2) {
- const VIDEOINFOHEADER2* pInfo = GetFormatHelper(pInfo, _pMediaType);
-
- pVideoInfo2 = pInfo;
- bool bIsVC1 = false;
-
- DWORD CodecType = pInfo->bmiHeader.biCompression;
- if (CodecType == '1CVW') {
- bIsVC1 = true;
- Infos.AddTail(L"VC-1");
- } else if (CodecType) {
- WCHAR Temp[5];
- ZeroMemory(Temp, sizeof(Temp));
- Temp[0] = (CodecType >> 0) & 0xFF;
- Temp[1] = (CodecType >> 8) & 0xFF;
- Temp[2] = (CodecType >> 16) & 0xFF;
- Temp[3] = (CodecType >> 24) & 0xFF;
- Infos.AddTail(Temp);
- }
- } else if (_pMediaType->subtype == MEDIASUBTYPE_DVD_SUBPICTURE) {
- Infos.AddTail(L"DVD Sub Picture");
- } else if (_pMediaType->subtype == MEDIASUBTYPE_SVCD_SUBPICTURE) {
- Infos.AddTail(L"SVCD Sub Picture");
- } else if (_pMediaType->subtype == MEDIASUBTYPE_CVD_SUBPICTURE) {
- Infos.AddTail(L"CVD Sub Picture");
- }
-
- if (pVideoInfo2) {
- if (pVideoInfo2->bmiHeader.biWidth && pVideoInfo2->bmiHeader.biHeight) {
- Infos.AddTail(FormatString(L"%dx%d", pVideoInfo2->bmiHeader.biWidth, pVideoInfo2->bmiHeader.biHeight));
- }
- if (pVideoInfo2->AvgTimePerFrame) {
- Infos.AddTail(FormatString(L"%.3f fps", 10000000.0 / double(pVideoInfo2->AvgTimePerFrame)));
- }
- if (pVideoInfo2->dwBitRate) {
- Infos.AddTail(FormatBitrate(pVideoInfo2->dwBitRate));
- }
- } else if (pVideoInfo) {
- if (pVideoInfo->bmiHeader.biWidth && pVideoInfo->bmiHeader.biHeight) {
- Infos.AddTail(FormatString(L"%dx%d", pVideoInfo->bmiHeader.biWidth, pVideoInfo->bmiHeader.biHeight));
- }
- if (pVideoInfo->AvgTimePerFrame) {
- Infos.AddTail(FormatString(L"%.3f fps", 10000000.0 / double(pVideoInfo->AvgTimePerFrame)));
- }
- if (pVideoInfo->dwBitRate) {
- Infos.AddTail(FormatBitrate(pVideoInfo->dwBitRate));
- }
- }
-
- } else if (_pMediaType->majortype == MEDIATYPE_Audio) {
- MajorType = "Audio";
- if (pClipInfo) {
- CString name = ISO6392ToLanguage(pClipInfo->m_LanguageCode);
- if (!name.IsEmpty()) {
- Infos.AddTail(name);
- }
- } else {
- if (!lang.IsEmpty()) {
- Infos.AddTail(lang);
- }
- }
- if (_pMediaType->formattype == FORMAT_WaveFormatEx) {
- const WAVEFORMATEX* pInfo = GetFormatHelper(pInfo, _pMediaType);
-
- if (_pMediaType->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
- Infos.AddTail(L"DVD LPCM");
- } else if (_pMediaType->subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
- const WAVEFORMATEX_HDMV_LPCM* pInfoHDMV = GetFormatHelper(pInfoHDMV, _pMediaType);
- UNREFERENCED_PARAMETER(pInfoHDMV);
- Infos.AddTail(L"HDMV LPCM");
- }
- if (_pMediaType->subtype == MEDIASUBTYPE_DOLBY_DDPLUS) {
- Infos.AddTail(L"Dolby Digital Plus");
- } else if (_pMediaType->subtype == MEDIASUBTYPE_DOLBY_TRUEHD) {
- Infos.AddTail(L"TrueHD");
- } else {
- switch (pInfo->wFormatTag) {
- case WAVE_FORMAT_PS2_PCM: {
- Infos.AddTail(L"PS2 PCM");
- }
- break;
- case WAVE_FORMAT_PS2_ADPCM: {
- Infos.AddTail(L"PS2 ADPCM");
- }
- break;
- case WAVE_FORMAT_DVD_DTS: {
- if (pPresentationDesc) {
- Infos.AddTail(pPresentationDesc);
- } else {
- Infos.AddTail(L"DTS");
- }
- }
- break;
- case WAVE_FORMAT_DOLBY_AC3: {
- if (pPresentationDesc) {
- Infos.AddTail(pPresentationDesc);
- } else {
- Infos.AddTail(L"Dolby Digital");
- }
- }
- break;
- case WAVE_FORMAT_AAC: {
- Infos.AddTail(L"AAC");
- }
- break;
- case WAVE_FORMAT_MPEGLAYER3: {
- Infos.AddTail(L"MP3");
- }
- break;
- case WAVE_FORMAT_MPEG: {
- const MPEG1WAVEFORMAT* pInfoMPEG1 = GetFormatHelper(pInfoMPEG1, _pMediaType);
-
- int layer = GetHighestBitSet32(pInfoMPEG1->fwHeadLayer) + 1;
- Infos.AddTail(FormatString(L"MPEG1 - Layer %d", layer));
- }
- break;
- }
- }
-
- if (pClipInfo && (pClipInfo->m_SampleRate == BDVM_SampleRate_48_192 || pClipInfo->m_SampleRate == BDVM_SampleRate_48_96)) {
- switch (pClipInfo->m_SampleRate) {
- case BDVM_SampleRate_48_192:
- Infos.AddTail(FormatString(L"192(48) kHz"));
- break;
- case BDVM_SampleRate_48_96:
- Infos.AddTail(FormatString(L"96(48) kHz"));
- break;
- }
- } else if (pInfo->nSamplesPerSec) {
- Infos.AddTail(FormatString(L"%.1f kHz", double(pInfo->nSamplesPerSec) / 1000.0));
- }
- if (pInfo->nChannels) {
- Infos.AddTail(FormatString(L"%d chn", pInfo->nChannels));
- }
- if (pInfo->wBitsPerSample) {
- Infos.AddTail(FormatString(L"%d bit", pInfo->wBitsPerSample));
- }
- if (pInfo->nAvgBytesPerSec) {
- Infos.AddTail(FormatBitrate(pInfo->nAvgBytesPerSec * 8));
- }
-
- }
- } else if (_pMediaType->majortype == MEDIATYPE_Subtitle) {
- MajorType = "Subtitle";
-
- if (pPresentationDesc) {
- Infos.AddTail(pPresentationDesc);
- }
-
- if (pClipInfo) {
- CString name = ISO6392ToLanguage(pClipInfo->m_LanguageCode);
- if (!name.IsEmpty()) {
- Infos.AddHead(name);
- } else if (!lang.IsEmpty()) {
- Infos.AddHead(lang);
- }
- } else if (_pMediaType->cbFormat == sizeof(SUBTITLEINFO)) {
- const SUBTITLEINFO* pInfo = GetFormatHelper(pInfo, _pMediaType);
- CString name = ISO6392ToLanguage(pInfo->IsoLang);
-
- if (!lang.IsEmpty()) {
- Infos.AddHead(lang);
- } else if (!name.IsEmpty()) {
- Infos.AddHead(name);
- }
- if (pInfo->TrackName[0]) {
- Infos.AddTail(pInfo->TrackName);
- }
- } else if (!lang.IsEmpty()) {
- Infos.AddHead(lang);
- }
- }
-
- if (!Infos.IsEmpty()) {
- CString Ret;
-
- Ret += MajorType;
- Ret += " - ";
-
- bool bFirst = true;
-
- for (POSITION pos = Infos.GetHeadPosition(); pos; Infos.GetNext(pos)) {
- CString& String = Infos.GetAt(pos);
-
- if (bFirst) {
- Ret += String;
- } else {
- Ret += L", " + String;
- }
-
- bFirst = false;
- }
-
- return Ret;
- }
- return CString();
-}
-
-//
-// CMpegSplitterFilter
-//
-
-CMpegSplitterFilter::CMpegSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid)
- : CBaseSplitterFilter(NAME("CMpegSplitterFilter"), pUnk, phr, clsid)
- , m_pPipoBimbo(false)
- , m_rtPlaylistDuration(0)
- , m_csAudioLanguageOrder(_T(""))
- , m_csSubtitlesLanguageOrder(_T(""))
- , m_useFastStreamChange(true)
- , m_ForcedSub(false)
- , m_AC3CoreOnly(0)
- , m_nVC1_GuidFlag(1)
- , m_AlternativeDuration(false)
-{
-#ifdef STANDALONE_FILTER
- CRegKey key;
- TCHAR buff[256];
- ULONG len;
-
- if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Splitter"), KEY_READ)) {
- DWORD dw;
-
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("UseFastStreamChange"), dw)) {
- m_useFastStreamChange = !!dw;
- }
-
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("ForcedSub"), dw)) {
- m_ForcedSub = !!dw;
- }
-
- len = _countof(buff);
- ZeroMemory(buff, sizeof(buff));
- if (ERROR_SUCCESS == key.QueryStringValue(_T("AudioLanguageOrder"), buff, &len)) {
- m_csAudioLanguageOrder = CString(buff);
- }
-
- len = _countof(buff);
- ZeroMemory(buff, sizeof(buff));
- if (ERROR_SUCCESS == key.QueryStringValue(_T("SubtitlesLanguageOrder"), buff, &len)) {
- m_csSubtitlesLanguageOrder = CString(buff);
- }
-
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("VC1_Decoder_Output"), dw)) {
- m_nVC1_GuidFlag = dw;
- }
-
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("AC3CoreOnly"), dw)) {
- m_AC3CoreOnly = dw;
- }
-
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("AlternativeDuration"), dw)) {
- m_AlternativeDuration = !!dw;
- }
- }
-#else
- m_useFastStreamChange = !!AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("UseFastStreamChange"), m_useFastStreamChange);
- m_ForcedSub = !!AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("ForcedSub"), m_ForcedSub);
- m_csSubtitlesLanguageOrder = AfxGetApp()->GetProfileString(IDS_R_SETTINGS, IDS_RS_SUBTITLESLANGORDER, _T(""));
- m_csAudioLanguageOrder = AfxGetApp()->GetProfileString(IDS_R_SETTINGS, IDS_RS_AUDIOSLANGORDER, _T(""));
- m_nVC1_GuidFlag = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("VC1_Decoder_Output"), m_nVC1_GuidFlag);
- if (m_nVC1_GuidFlag < 1 || m_nVC1_GuidFlag > 3) {
- m_nVC1_GuidFlag = 1;
- }
- m_AC3CoreOnly = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("AC3CoreOnly"), m_AC3CoreOnly);
- m_AlternativeDuration = !!AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Splitter"), _T("AlternativeDuration"), m_AlternativeDuration);
-#endif
-}
-
-bool CMpegSplitterFilter::StreamIsTrueHD(const WORD pid)
-{
- int iProgram = -1;
- const CHdmvClipInfo::Stream* pClipInfo;
- const CMpegSplitterFile::program* pProgram = m_pFile->FindProgram(pid, iProgram, pClipInfo);
- int StreamType = pClipInfo ? pClipInfo->m_Type : pProgram ? pProgram->streams[iProgram].type : 0;
- return (StreamType == AUDIO_STREAM_AC3_TRUE_HD);
-}
-
-STDMETHODIMP CMpegSplitterFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
-{
- CheckPointer(ppv, E_POINTER);
-
- return
- QI(IMpegSplitterFilter)
- QI(ISpecifyPropertyPages)
- QI(ISpecifyPropertyPages2)
- QI(IAMStreamSelect)
- __super::NonDelegatingQueryInterface(riid, ppv);
-}
-
-STDMETHODIMP CMpegSplitterFilter::GetClassID(CLSID* pClsID)
-{
- CheckPointer(pClsID, E_POINTER);
-
- if (m_pPipoBimbo) {
- memcpy(pClsID, &CLSID_WMAsfReader, sizeof(GUID));
- return S_OK;
- } else {
- return __super::GetClassID(pClsID);
- }
-}
-
-STDMETHODIMP CMpegSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo)
-{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
-
- if (m_pName && m_pName[0] == L'M' && m_pName[1] == L'P' && m_pName[2] == L'C') {
- (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
- wcscpy_s(pInfo->achName, MpegSourceName);
- }
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
-}
-
-void CMpegSplitterFilter::ReadClipInfo(LPCOLESTR pszFileName)
-{
- if (wcslen(pszFileName) > 0) {
- WCHAR Drive[_MAX_DRIVE];
- WCHAR Dir[MAX_PATH];
- WCHAR Filename[MAX_PATH];
- WCHAR Ext[_MAX_EXT];
-
- if (_wsplitpath_s(pszFileName, Drive, _countof(Drive), Dir, _countof(Dir), Filename, _countof(Filename), Ext, _countof(Ext)) == 0) {
- CString strClipInfo;
-
- _wcslwr_s(Ext, _countof(Ext));
-
- if (wcscmp(Ext, L".ssif") == 0) {
- if (Drive[0]) {
- strClipInfo.Format(_T("%s\\%s\\..\\..\\CLIPINF\\%s.clpi"), Drive, Dir, Filename);
- } else {
- strClipInfo.Format(_T("%s\\..\\..\\CLIPINF\\%s.clpi"), Dir, Filename);
- }
- } else {
- if (Drive[0]) {
- strClipInfo.Format(_T("%s\\%s\\..\\CLIPINF\\%s.clpi"), Drive, Dir, Filename);
- } else {
- strClipInfo.Format(_T("%s\\..\\CLIPINF\\%s.clpi"), Dir, Filename);
- }
- }
-
- m_ClipInfo.ReadInfo(strClipInfo);
- }
- }
-}
-
-STDMETHODIMP CMpegSplitterFilter::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
-{
- return __super::Load(pszFileName, pmt);
-}
-
-HRESULT CMpegSplitterFilter::DemuxNextPacket(REFERENCE_TIME rtStartOffset)
-{
- HRESULT hr;
- BYTE b;
-
- if (m_pFile->m_type == mpeg_ps || m_pFile->m_type == mpeg_es) {
- if (!m_pFile->NextMpegStartCode(b)) {
- return S_FALSE;
- }
-
- if (b == 0xba) { // program stream header
- CMpegSplitterFile::pshdr h;
- if (!m_pFile->Read(h)) {
- return S_FALSE;
- }
- } else if (b == 0xbb) { // program stream system header
- CMpegSplitterFile::pssyshdr h;
- if (!m_pFile->Read(h)) {
- return S_FALSE;
- }
- } else if ((b >= 0xbd && b < 0xf0) || (b == 0xfd)) { // pes packet
- CMpegSplitterFile::peshdr h;
-
- if (!m_pFile->Read(h, b) || !h.len) {
- return S_FALSE;
- }
-
- if (h.type == CMpegSplitterFile::mpeg2 && h.scrambling) {
- ASSERT(0);
- return E_FAIL;
- }
-
- __int64 pos = m_pFile->GetPos();
-
- DWORD TrackNumber = m_pFile->AddStream(0, b, h.id_ext, h.len);
-
- if (GetOutputPin(TrackNumber)) {
- CAutoPtr<Packet> p(DEBUG_NEW Packet());
-
- p->TrackNumber = TrackNumber;
- p->bSyncPoint = !!h.fpts;
- p->bAppendable = !h.fpts;
- p->rtStart = h.fpts ? (h.pts - rtStartOffset) : Packet::INVALID_TIME;
- p->rtStop = p->rtStart + 1;
- p->SetCount(h.len - (size_t)(m_pFile->GetPos() - pos));
-
- m_pFile->ByteRead(p->GetData(), h.len - (m_pFile->GetPos() - pos));
-
- hr = DeliverPacket(p);
- }
- m_pFile->Seek(pos + h.len);
- }
- } else if (m_pFile->m_type == mpeg_ts) {
- CMpegSplitterFile::tshdr h;
-
- if (!m_pFile->Read(h)) {
- return S_FALSE;
- }
-
-
- __int64 pos = m_pFile->GetPos();
-
- m_pFile->UpdatePrograms(h, false);
-
- if (h.payload && ISVALIDPID(h.pid)) {
- DWORD TrackNumber = h.pid;
-
- CMpegSplitterFile::peshdr h2;
-
- if (h.payloadstart && m_pFile->NextMpegStartCode(b, 4) && m_pFile->Read(h2, b)) { // pes packet
- if (h2.type == CMpegSplitterFile::mpeg2 && h2.scrambling) {
- ASSERT(0);
- return E_FAIL;
- }
- TrackNumber = m_pFile->AddStream(h.pid, b, 0, h.bytes - (DWORD)(m_pFile->GetPos() - pos));
- }
-
- if (GetOutputPin(TrackNumber)) {
- CAutoPtr<Packet> p(DEBUG_NEW Packet());
-
- p->TrackNumber = TrackNumber;
- p->bSyncPoint = !!h2.fpts;
- p->bAppendable = !h2.fpts;
-
- if (h.fPCR) {
- CRefTime rtNow;
- StreamTime(rtNow);
- //TRACE(_T("Now=%s PCR=%s\n"), ReftimeToString(rtNow.m_time), ReftimeToString(h.PCR));
- }
-
- p->rtStart = h2.fpts ? (h2.pts - rtStartOffset) : Packet::INVALID_TIME;
- p->rtStop = p->rtStart + 1;
- p->SetCount(h.bytes - (size_t)(m_pFile->GetPos() - pos));
-
- int nBytes = int(h.bytes - (m_pFile->GetPos() - pos));
- m_pFile->ByteRead(p->GetData(), nBytes);
-
- hr = DeliverPacket(p);
- }
- }
-
- m_pFile->Seek(h.next);
- } else if (m_pFile->m_type == mpeg_pva) {
- CMpegSplitterFile::pvahdr h;
- if (!m_pFile->Read(h)) {
- return S_FALSE;
- }
-
- DWORD TrackNumber = h.streamid;
-
- __int64 pos = m_pFile->GetPos();
-
- if (GetOutputPin(TrackNumber)) {
- CAutoPtr<Packet> p(DEBUG_NEW Packet());
-
- p->TrackNumber = TrackNumber;
- p->bSyncPoint = !!h.fpts;
- p->bAppendable = !h.fpts;
- p->rtStart = h.fpts ? (h.pts - rtStartOffset) : Packet::INVALID_TIME;
- p->rtStop = p->rtStart + 1;
- p->SetCount(h.length);
-
- m_pFile->ByteRead(p->GetData(), h.length);
- hr = DeliverPacket(p);
- }
-
- m_pFile->Seek(pos + h.length);
- }
-
- return S_OK;
-}
-
-//
-
-HRESULT CMpegSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
-{
- CheckPointer(pAsyncReader, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- m_pFile.Free();
-
- ReadClipInfo(GetPartFilename(pAsyncReader));
- m_pFile.Attach(DEBUG_NEW CMpegSplitterFile(pAsyncReader, hr, m_ClipInfo.IsHdmv(), m_ClipInfo, m_nVC1_GuidFlag, m_ForcedSub, m_AC3CoreOnly, m_AlternativeDuration));
-
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
-
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- if (m_pFile->m_type == mpeg_ps) {
- if (m_pInput && m_pInput->IsConnected() && (GetCLSID(m_pInput->GetConnected()) == GUIDFromCString(_T("{773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73}")))) { // MPC VTS Reader
- pTI = GetFilterFromPin(m_pInput->GetConnected());
- }
- }
-
- CString cs_audioProgram = _T("");
- CString cs_subpicProgram = _T("");
-
- // Create
- if (m_ClipInfo.IsHdmv()) {
- for (size_t i = 0; i < m_ClipInfo.GetStreamNumber(); i++) {
- const CHdmvClipInfo::Stream* stream = m_ClipInfo.GetStreamByIndex(i);
- if (stream->m_Type == PRESENTATION_GRAPHICS_STREAM) {
- m_pFile->AddHdmvPGStream(stream->m_PID, stream->m_LanguageCode);
- }
- }
- }
-
- CString lang = _T("");
- CAtlArray<CString> lang_list_audio;
- CAtlArray<CString> lang_list_subpic;
- int Idx_audio = 0;
- int Idx_subpic = 0;
-
- if (!m_csAudioLanguageOrder.IsEmpty()) {
- int tPos = 0;
- lang = m_csAudioLanguageOrder.Tokenize(_T(",; "), tPos);
- while (tPos != -1) {
- if (!lang.IsEmpty()) {
- lang_list_audio.Add(lang);
- }
- lang = m_csAudioLanguageOrder.Tokenize(_T(",; "), tPos);
- }
- }
-
- if (!m_csSubtitlesLanguageOrder.IsEmpty()) {
- int tPos = 0;
- lang = m_csSubtitlesLanguageOrder.Tokenize(_T(",; "), tPos);
- while (tPos != -1) {
- if (!lang.IsEmpty()) {
- lang_list_subpic.Add(lang);
- }
- lang = m_csSubtitlesLanguageOrder.Tokenize(_T(",; "), tPos);
- }
- }
-
- for (int i = 0; i < _countof(m_pFile->m_streams); i++) {
- POSITION pos = m_pFile->m_streams[i].GetHeadPosition();
- while (pos) {
- CMpegSplitterFile::stream& s = m_pFile->m_streams[i].GetNext(pos);
- CAtlArray<CMediaType> mts;
- mts.Add(s.mt);
-
- CStringW name = CMpegSplitterFile::CStreamList::ToString(i);
- CStringW str;
-
- if (i == CMpegSplitterFile::subpic && s.pid == NO_SUBTITLE_PID) {
- str = NO_SUBTITLE_NAME;
- continue;
- } else {
- int iProgram = -1;
- const CHdmvClipInfo::Stream* pClipInfo;
- const CMpegSplitterFile::program* pProgram = m_pFile->FindProgram(s.pid, iProgram, pClipInfo);
- const wchar_t* pStreamName = nullptr;
- int StreamType = pClipInfo ? pClipInfo->m_Type : pProgram ? pProgram->streams[iProgram].type : 0;
- pStreamName = StreamTypeToName((PES_STREAM_TYPE)StreamType);
-
- CString lang_name = _T("");
- m_pFile->m_pPMT_Lang.Lookup(s.pid, lang_name);
-
- lang_name = pTI ? pTI->GetTrackName(s.ps1id) : lang_name;
-
- CString FormatDesc = GetMediaTypeDesc(&s.mt, pClipInfo, StreamType, lang_name);
-
- if (!FormatDesc.IsEmpty()) {
- str.Format(L"%s (%04x,%02x,%02x)", FormatDesc.GetString(), s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- } else if (pStreamName) {
- str.Format(L"%s - %s (%04x,%02x,%02x)", name, pStreamName, s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- } else {
- str.Format(L"%s (%04x,%02x,%02x)", name, s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- }
- }
- if (i == CMpegSplitterFile::audio) {
- CString str_tmp = str.Mid(8).MakeLower();
- if (Idx_audio == 0) {
- Idx_audio = 1;
- } else {
- Idx_audio++;
- }
- for (size_t j = 0; j < lang_list_audio.GetCount(); j++) {
- int num = _tstoi(lang_list_audio[j]);
- if (num > 0) { // this is track number
- if (Idx_audio != num) {
- continue; // not matched
- }
- } else { // this is lang string
- int len = lang_list_audio[j].GetLength();
- if (str_tmp.Left(len) != lang_list_audio[j]) {
- continue; // not matched
- }
- }
- cs_audioProgram = str;
- break;
- }
- }
- if (i == CMpegSplitterFile::subpic) {
- CString str_tmp = str.Mid(11).MakeLower();
- if (Idx_subpic == 0) {
- Idx_subpic = 1;
- } else {
- Idx_subpic++;
- }
- for (size_t j = 0; j < lang_list_subpic.GetCount(); j++) {
- int num = _tstoi(lang_list_subpic[j]);
- if (num > 0) { // this is track number
- if (Idx_subpic != num) {
- continue; // not matched
- }
- } else { // this is lang string
- int len = lang_list_subpic[j].GetLength();
- if (str_tmp.Left(len) != lang_list_subpic[j]) {
- continue; // not matched
- }
- }
- cs_subpicProgram = str;
- break;
- }
- }
- }
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration = 0;
-
- for (int i = 0; i < _countof(m_pFile->m_streams); i++) {
- POSITION pos = m_pFile->m_streams[i].GetHeadPosition();
- while (pos) {
- CMpegSplitterFile::stream& s = m_pFile->m_streams[i].GetNext(pos);
- CAtlArray<CMediaType> mts;
- mts.Add(s.mt);
-
- CStringW name = CMpegSplitterFile::CStreamList::ToString(i);
- CStringW str;
-
- if (i == CMpegSplitterFile::subpic && s.pid == NO_SUBTITLE_PID) {
- str = NO_SUBTITLE_NAME;
- } else {
- int iProgram = -1;
- const CHdmvClipInfo::Stream* pClipInfo;
- const CMpegSplitterFile::program* pProgram = m_pFile->FindProgram(s.pid, iProgram, pClipInfo);
- const wchar_t* pStreamName = nullptr;
- int StreamType = pClipInfo ? pClipInfo->m_Type : pProgram ? pProgram->streams[iProgram].type : 0;
- pStreamName = StreamTypeToName((PES_STREAM_TYPE)StreamType);
-
- CString lang_name = _T("");
- m_pFile->m_pPMT_Lang.Lookup(s.pid, lang_name);
-
- lang_name = pTI ? pTI->GetTrackName(s.ps1id) : lang_name;
-
- CString FormatDesc = GetMediaTypeDesc(&s.mt, pClipInfo, StreamType, lang_name);
-
- if (!FormatDesc.IsEmpty()) {
- str.Format(L"%s (%04x,%02x,%02x)", FormatDesc.GetString(), s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- } else if (pStreamName) {
- str.Format(L"%s - %s (%04x,%02x,%02x)", name, pStreamName, s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- } else {
- str.Format(L"%s (%04x,%02x,%02x)", name, s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- }
- }
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DEBUG_NEW CMpegSplitterOutputPin(mts, str, this, this, &hr, m_pFile->m_type));
- if (i == CMpegSplitterFile::subpic) {
- (static_cast<CMpegSplitterOutputPin*>(pPinOut.m_p))->SetMaxShift(_I64_MAX);
- }
-
- if (i == CMpegSplitterFile::audio) {
- if (!cs_audioProgram.IsEmpty()) {
- if (!cs_audioProgram.Compare(str) && (S_OK == AddOutputPin(s, pPinOut))) {
- break;
- }
- } else {
- if (S_OK == AddOutputPin(s, pPinOut)) {
- break;
- }
- }
- } else if (i == CMpegSplitterFile::subpic) {
- if (!cs_subpicProgram.IsEmpty()) {
- if (!cs_subpicProgram.Compare(str) && (S_OK == AddOutputPin(s, pPinOut))) {
- break;
- }
- } else {
- if ((m_pFile->m_streams[CMpegSplitterFile::subpic].GetCount() == 1) && (S_OK == AddOutputPin(s, pPinOut))) {
- break;
- } else if ((s.pid != NO_SUBTITLE_PID) && (S_OK == AddOutputPin(s, pPinOut))) {
- break;
- }
- }
- } else {
- if (S_OK == AddOutputPin(s, pPinOut)) {
- break;
- }
- }
- }
- }
-
- if (m_rtPlaylistDuration) {
- m_rtNewStop = m_rtStop = m_rtDuration = m_rtPlaylistDuration;
- } else if (m_pFile->IsRandomAccess() && m_pFile->m_rate) {
- m_rtNewStop = m_rtStop = m_rtDuration = 10000000i64 * m_pFile->GetLength() / m_pFile->m_rate;
- }
-
- return !m_pOutputs.IsEmpty() ? S_OK : E_FAIL;
-}
-
-bool CMpegSplitterFilter::DemuxInit()
-{
- SetThreadName((DWORD) - 1, "CMpegSplitterFilter");
- if (!m_pFile) {
- return false;
- }
-
- m_rtStartOffset = 0;
-
- return true;
-}
-
-void CMpegSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
-{
- CAtlList<CMpegSplitterFile::stream>* pMasterStream = m_pFile->GetMasterStream();
-
- if (!pMasterStream) {
- ASSERT(0);
- return;
- }
-
- if (m_pFile->IsStreaming()) {
- m_pFile->Seek(max(0, m_pFile->GetLength() - 100 * 1024));
- m_rtStartOffset = m_pFile->m_rtMin + m_pFile->NextPTS(pMasterStream->GetHead());
- return;
- }
-
- REFERENCE_TIME rtPreroll = 10000000;
-
- if (rt <= rtPreroll || m_rtDuration <= 0) {
- m_pFile->Seek(0);
- } else {
- __int64 len = m_pFile->GetLength();
- __int64 seekpos = (__int64)(1.0 * rt / m_rtDuration * len);
- __int64 minseekpos = _I64_MAX;
-
- REFERENCE_TIME rtmax = rt - rtPreroll;
- REFERENCE_TIME rtmin = rtmax - 5000000;
-
- if (m_rtStartOffset == 0) {
- for (int i = 0; i < _countof(m_pFile->m_streams) - 1; i++) {
- POSITION pos = m_pFile->m_streams[i].GetHeadPosition();
- while (pos) {
- DWORD TrackNum = m_pFile->m_streams[i].GetNext(pos);
-
- CBaseSplitterOutputPin* pPin = GetOutputPin(TrackNum);
- if (pPin && pPin->IsConnected()) {
- m_pFile->Seek(seekpos);
-
- __int64 curpos = seekpos;
- REFERENCE_TIME pdt = _I64_MIN;
-
- for (int j = 0; j < 10; j++) {
- REFERENCE_TIME rt2 = m_pFile->NextPTS(TrackNum);
-
- if (rt2 < 0) {
- break;
- }
-
- REFERENCE_TIME dt = rt2 - rtmax;
- if (dt > 0 && dt == pdt) {
- dt = 10000000i64;
- }
-
-
- if (rtmin <= rt2 && rt2 <= rtmax || pdt > 0 && dt < 0) {
- minseekpos = min(minseekpos, curpos);
- break;
- }
-
- curpos -= (__int64)(1.0 * dt / m_rtDuration * len);
- m_pFile->Seek(curpos);
-
- //pdt = dt;
- }
- }
- }
- }
- }
-
- if (minseekpos != _I64_MAX) {
- seekpos = minseekpos;
- } else {
- // this file is probably screwed up, try plan B, seek simply by bitrate
-
- rt -= rtPreroll;
- seekpos = (__int64)(1.0 * rt / m_rtDuration * len);
- m_pFile->Seek(seekpos);
- m_rtStartOffset = m_pFile->m_rtMin + m_pFile->NextPTS(pMasterStream->GetHead()) - rt;
- }
-
- m_pFile->Seek(seekpos);
- }
-}
-
-bool CMpegSplitterFilter::DemuxLoop()
-{
- REFERENCE_TIME rtStartOffset = m_rtStartOffset ? m_rtStartOffset : m_pFile->m_rtMin;
-
- HRESULT hr = S_OK;
- while (SUCCEEDED(hr) && !CheckRequest(nullptr)) {
- if ((hr = m_pFile->HasMoreData(1024 * 500)) == S_OK)
- if ((hr = DemuxNextPacket(rtStartOffset)) == S_FALSE) {
- Sleep(1);
- }
- }
-
- return true;
-}
-
-bool CMpegSplitterFilter::BuildPlaylist(LPCTSTR pszFileName, CAtlList<CHdmvClipInfo::PlaylistItem>& Items)
-{
- m_rtPlaylistDuration = 0;
- return SUCCEEDED(m_ClipInfo.ReadPlaylist(pszFileName, m_rtPlaylistDuration, Items)) ? true : false;
-}
-
-bool CMpegSplitterFilter::BuildChapters(LPCTSTR pszFileName, CAtlList<CHdmvClipInfo::PlaylistItem>& PlaylistItems, CAtlList<CHdmvClipInfo::PlaylistChapter>& Items)
-{
- return SUCCEEDED(m_ClipInfo.ReadChapters(pszFileName, PlaylistItems, Items)) ? true : false;
-}
-
-// IAMStreamSelect
-
-STDMETHODIMP CMpegSplitterFilter::Count(DWORD* pcStreams)
-{
- CheckPointer(pcStreams, E_POINTER);
-
- *pcStreams = 0;
-
- for (int i = 0; i < _countof(m_pFile->m_streams); i++) {
- (*pcStreams) += m_pFile->m_streams[i].GetCount();
- }
-
- return S_OK;
-}
-
-STDMETHODIMP CMpegSplitterFilter::Enable(long lIndex, DWORD dwFlags)
-{
- if (!(dwFlags & AMSTREAMSELECTENABLE_ENABLE)) {
- return E_NOTIMPL;
- }
-
- for (int i = 0, j = 0; i < _countof(m_pFile->m_streams); i++) {
- int cnt = (int)m_pFile->m_streams[i].GetCount();
-
- if (lIndex >= j && lIndex < j + cnt) {
- lIndex -= j;
-
- POSITION pos = m_pFile->m_streams[i].FindIndex(lIndex);
- if (!pos) {
- return E_UNEXPECTED;
- }
-
- CMpegSplitterFile::stream& to = m_pFile->m_streams[i].GetAt(pos);
-
- pos = m_pFile->m_streams[i].GetHeadPosition();
- while (pos) {
- CMpegSplitterFile::stream& from = m_pFile->m_streams[i].GetNext(pos);
- if (!GetOutputPin(from)) {
- continue;
- }
-
- if (m_useFastStreamChange) {
- PauseGraph;
- ResumeGraph;
- }
-
- HRESULT hr;
- if (FAILED(hr = RenameOutputPin(from, to, &to.mt))) {
- return hr;
- }
-
-#if 0
- // Don't rename other pin for Hdmv!
- int iProgram;
- const CHdmvClipInfo::Stream* pClipInfo;
- const CMpegSplitterFile::program* p = m_pFile->FindProgram(to.pid, iProgram, pClipInfo);
-
- if (p != nullptr && !m_ClipInfo.IsHdmv() && !m_pFile->IsHdmv()) {
- for (int k = 0; k < _countof(m_pFile->m_streams); k++) {
- if (k == i) {
- continue;
- }
-
- pos = m_pFile->m_streams[k].GetHeadPosition();
- while (pos) {
- CMpegSplitterFile::stream& from = m_pFile->m_streams[k].GetNext(pos);
- if (!GetOutputPin(from)) {
- continue;
- }
-
- for (int l = 0; l < _countof(p->streams); l++) {
- if (const CMpegSplitterFile::stream* s = m_pFile->m_streams[k].FindStream(p->streams[l].pid)) {
- if (from != *s) {
- hr = RenameOutputPin(from, *s, &s->mt);
- }
- break;
- }
- }
- }
- }
- }
-#endif
-
- return S_OK;
- }
- }
-
- j += cnt;
- }
-
- return S_FALSE;
-}
-
-LONGLONG GetMediaTypeQuality(const CMediaType* _pMediaType, int _PresentationFormat)
-{
- if (_pMediaType->formattype == FORMAT_WaveFormatEx) {
- __int64 Ret = 0;
-
- const WAVEFORMATEX* pInfo = GetFormatHelper(pInfo, _pMediaType);
- int TypePriority = 0;
-
- if (_pMediaType->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
- TypePriority = 12;
- } else if (_pMediaType->subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
- TypePriority = 12;
- } else {
- if (_PresentationFormat == AUDIO_STREAM_DTS_HD_MASTER_AUDIO) {
- TypePriority = 12;
- } else if (_PresentationFormat == AUDIO_STREAM_DTS_HD) {
- TypePriority = 11;
- } else if (_PresentationFormat == AUDIO_STREAM_AC3_TRUE_HD) {
- TypePriority = 12;
- } else if (_PresentationFormat == AUDIO_STREAM_AC3_PLUS) {
- TypePriority = 10;
- } else {
- switch (pInfo->wFormatTag) {
- case WAVE_FORMAT_PS2_PCM: {
- TypePriority = 12;
- }
- break;
- case WAVE_FORMAT_PS2_ADPCM: {
- TypePriority = 4;
- }
- break;
- case WAVE_FORMAT_DVD_DTS: {
- TypePriority = 9;
- }
- break;
- case WAVE_FORMAT_DOLBY_AC3: {
- TypePriority = 8;
- }
- break;
- case WAVE_FORMAT_AAC: {
- TypePriority = 7;
- }
- break;
- case WAVE_FORMAT_MPEGLAYER3: {
- TypePriority = 6;
- }
- break;
- case WAVE_FORMAT_MPEG: {
- TypePriority = 5;
- }
- break;
- }
- }
- }
-
- Ret += __int64(TypePriority) * 100000000i64 * 1000000000i64;
-
- Ret += __int64(pInfo->nChannels) * 1000000i64 * 1000000000i64;
- Ret += __int64(pInfo->nSamplesPerSec) * 10i64 * 1000000000i64;
- Ret += __int64(pInfo->wBitsPerSample) * 10000000i64;
- Ret += __int64(pInfo->nAvgBytesPerSec);
-
- return Ret;
- }
-
- return 0;
-}
-
-STDMETHODIMP CMpegSplitterFilter::Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* pdwFlags, LCID* plcid, DWORD* pdwGroup, WCHAR** ppszName, IUnknown** ppObject, IUnknown** ppUnk)
-{
- for (int i = 0, j = 0; i < _countof(m_pFile->m_streams); i++) {
- int cnt = (int)m_pFile->m_streams[i].GetCount();
-
- if (lIndex >= j && lIndex < j + cnt) {
- lIndex -= j;
-
- POSITION pos = m_pFile->m_streams[i].FindIndex(lIndex);
- if (!pos) {
- return E_UNEXPECTED;
- }
-
- CMpegSplitterFile::stream& s = m_pFile->m_streams[i].GetAt(pos);
- const CHdmvClipInfo::Stream* pStream = m_ClipInfo.FindStream(s.pid);
-
- if (ppmt) {
- *ppmt = CreateMediaType(&s.mt);
- }
- if (pdwFlags) {
- *pdwFlags = GetOutputPin(s) ? (AMSTREAMSELECTINFO_ENABLED | AMSTREAMSELECTINFO_EXCLUSIVE) : 0;
- }
- if (plcid) {
- *plcid = pStream ? pStream->m_LCID : 0;
- }
- if (pdwGroup) {
- *pdwGroup = i;
- }
- if (ppObject) {
- *ppObject = nullptr;
- }
- if (ppUnk) {
- *ppUnk = nullptr;
- }
-
- if (ppszName) {
- CStringW name = CMpegSplitterFile::CStreamList::ToString(i);
-
- CStringW str;
-
- if (i == CMpegSplitterFile::subpic && s.pid == NO_SUBTITLE_PID) {
- str = NO_SUBTITLE_NAME;
- if (plcid) {
- *plcid = (LCID)LCID_NOSUBTITLES;
- }
- } else {
- int iProgram;
- const CHdmvClipInfo::Stream* pClipInfo;
- const CMpegSplitterFile::program* pProgram = m_pFile->FindProgram(s.pid, iProgram, pClipInfo);
- const wchar_t* pStreamName = nullptr;
- int StreamType = pClipInfo ? pClipInfo->m_Type : pProgram ? pProgram->streams[iProgram].type : 0;
- pStreamName = StreamTypeToName((PES_STREAM_TYPE)StreamType);
-
- CString lang_name = _T("");
- m_pFile->m_pPMT_Lang.Lookup(s.pid, lang_name);
-
- lang_name = pTI ? pTI->GetTrackName(s.ps1id) : lang_name;
-
- CString FormatDesc = GetMediaTypeDesc(&s.mt, pClipInfo, StreamType, lang_name);
-
- if (!FormatDesc.IsEmpty()) {
- str.Format(L"%s (%04x,%02x,%02x)", FormatDesc.GetString(), s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- } else if (pStreamName) {
- str.Format(L"%s - %s (%04x,%02x,%02x)", name, pStreamName, s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- } else {
- str.Format(L"%s (%04x,%02x,%02x)", name, s.pid, s.pesid, s.ps1id); // TODO: make this nicer
- }
- }
-
- *ppszName = (WCHAR*)CoTaskMemAlloc((str.GetLength() + 1) * sizeof(WCHAR));
- if (*ppszName == nullptr) {
- return E_OUTOFMEMORY;
- }
-
- wcscpy_s(*ppszName, str.GetLength() + 1, str);
- }
- }
-
- j += cnt;
- }
-
- return S_OK;
-}
-
-// ISpecifyPropertyPages2
-
-STDMETHODIMP CMpegSplitterFilter::GetPages(CAUUID* pPages)
-{
- CheckPointer(pPages, E_POINTER);
-
- HRESULT hr = S_OK;
-
- pPages->cElems = 1;
- pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID) * pPages->cElems);
- if (pPages->pElems != nullptr) {
- pPages->pElems[0] = __uuidof(CMpegSplitterSettingsWnd);
- } else {
- hr = E_OUTOFMEMORY;
- }
-
- return hr;
-}
-
-STDMETHODIMP CMpegSplitterFilter::CreatePage(const GUID& guid, IPropertyPage** ppPage)
-{
- CheckPointer(ppPage, E_POINTER);
-
- if (*ppPage != nullptr) {
- return E_INVALIDARG;
- }
-
- HRESULT hr;
-
- if (guid == __uuidof(CMpegSplitterSettingsWnd)) {
- (*ppPage = DEBUG_NEW CInternalPropertyPageTempl<CMpegSplitterSettingsWnd>(nullptr, &hr))->AddRef();
- }
-
- return *ppPage ? S_OK : E_FAIL;
-}
-
-// IMpegSplitterFilter
-STDMETHODIMP CMpegSplitterFilter::Apply()
-{
-#ifdef STANDALONE_FILTER
- CRegKey key;
- if (ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Splitter"))) {
- key.SetDWORDValue(_T("UseFastStreamChange"), m_useFastStreamChange);
- key.SetDWORDValue(_T("ForcedSub"), m_ForcedSub);
- key.SetStringValue(_T("AudioLanguageOrder"), m_csAudioLanguageOrder);
- key.SetStringValue(_T("SubtitlesLanguageOrder"), m_csSubtitlesLanguageOrder);
- key.SetDWORDValue(_T("VC1_Decoder_Output"), m_nVC1_GuidFlag);
- key.SetDWORDValue(_T("AC3CoreOnly"), m_AC3CoreOnly);
- key.SetDWORDValue(_T("AlternativeDuration"), m_AlternativeDuration);
- }
-#else
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Splitter"), _T("UseFastStreamChange"), m_useFastStreamChange);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Splitter"), _T("ForcedSub"), m_ForcedSub);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Splitter"), _T("VC1_Decoder_Output"), m_nVC1_GuidFlag);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Splitter"), _T("AC3CoreOnly"), m_AC3CoreOnly);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Splitter"), _T("AlternativeDuration"), m_AlternativeDuration);
-#endif
-
- return S_OK;
-}
-
-STDMETHODIMP CMpegSplitterFilter::SetFastStreamChange(BOOL nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_useFastStreamChange = !!nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(BOOL) CMpegSplitterFilter::GetFastStreamChange()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_useFastStreamChange;
-}
-
-STDMETHODIMP CMpegSplitterFilter::SetForcedSub(BOOL nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_ForcedSub = !!nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(BOOL) CMpegSplitterFilter::GetForcedSub()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_ForcedSub;
-}
-
-STDMETHODIMP CMpegSplitterFilter::SetAudioLanguageOrder(WCHAR* nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_csAudioLanguageOrder = nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(WCHAR*) CMpegSplitterFilter::GetAudioLanguageOrder()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_csAudioLanguageOrder.GetBuffer();
-}
-
-STDMETHODIMP CMpegSplitterFilter::SetSubtitlesLanguageOrder(WCHAR* nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_csSubtitlesLanguageOrder = nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(WCHAR*) CMpegSplitterFilter::GetSubtitlesLanguageOrder()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_csSubtitlesLanguageOrder.GetBuffer();
-}
-
-STDMETHODIMP CMpegSplitterFilter::SetVC1_GuidFlag(int nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_nVC1_GuidFlag = nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(int) CMpegSplitterFilter::GetVC1_GuidFlag()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_nVC1_GuidFlag;
-}
-
-STDMETHODIMP CMpegSplitterFilter::SetTrueHD(int nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_AC3CoreOnly = nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(int) CMpegSplitterFilter::GetTrueHD()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_AC3CoreOnly;
-}
-
-STDMETHODIMP CMpegSplitterFilter::SetAlternativeDuration(BOOL nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_AlternativeDuration = !!nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(BOOL) CMpegSplitterFilter::GetAlternativeDuration()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_AlternativeDuration;
-}
-
-STDMETHODIMP_(int) CMpegSplitterFilter::GetMPEGType()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_pFile->m_type;
-}
-//
-// CMpegSourceFilter
-//
-
-CMpegSourceFilter::CMpegSourceFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid)
- : CMpegSplitterFilter(pUnk, phr, clsid)
-{
- m_pInput.Free();
-}
-
-//
-// CMpegSplitterOutputPin
-//
-
-CMpegSplitterOutputPin::CMpegSplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr, int type)
- : CBaseSplitterOutputPin(mts, pName, pFilter, pLock, phr)
- , m_fHasAccessUnitDelimiters(false)
- , m_rtMaxShift(50000000)
- , m_bFilterDTSMA(false)
- , m_type(type)
- , DD_reset(false)
- , m_bFlushed(false)
-{
-}
-
-CMpegSplitterOutputPin::~CMpegSplitterOutputPin()
-{
-}
-
-HRESULT CMpegSplitterOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
-{
- {
- CAutoLock cAutoLock(this);
-
- m_rtPrev = Packet::INVALID_TIME;
- m_rtOffset = 0;
- }
-
- return __super::DeliverNewSegment(tStart, tStop, dRate);
-}
-
-HRESULT CMpegSplitterOutputPin::DeliverEndFlush()
-{
- {
- CAutoLock cAutoLock(this);
-
- m_p.Free();
- m_pl.RemoveAll();
- DD_reset = true;
- m_bFlushed = true;
- }
-
- return __super::DeliverEndFlush();
-}
-
-#define MOVE_TO_H264_START_CODE(b, e) \
- while (b <= e-4 && !((*(DWORD *)b == 0x01000000) || ((*(DWORD *)b & 0x00FFFFFF) == 0x00010000))) { \
- b++; \
- } \
- if ((b <= e-4) && *(DWORD *)b == 0x01000000) \
- b++;
-
-HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
-{
- CAutoLock cAutoLock(this);
-
- if (p->rtStart != Packet::INVALID_TIME) {
- REFERENCE_TIME rt = p->rtStart + m_rtOffset;
-
- // Filter invalid PTS (if too different from previous packet)
- if (m_rtPrev != Packet::INVALID_TIME)
- if (_abs64(rt - m_rtPrev) > m_rtMaxShift) {
- m_rtOffset += m_rtPrev - rt;
- }
-
- p->rtStart += m_rtOffset;
- p->rtStop += m_rtOffset;
-
- m_rtPrev = p->rtStart;
- }
-
- if (p->pmt) {
- if (*((CMediaType*)p->pmt) != m_mt) {
- SetMediaType((CMediaType*)p->pmt);
- }
- }
-
- if (m_mt.subtype == MEDIASUBTYPE_AAC) { // special code for aac, the currently available decoders only like whole frame samples
- if (m_p && m_p->GetCount() == 1 && m_p->GetAt(0) == 0xff && !(!p->IsEmpty() && (p->GetAt(0) & 0xf6) == 0xf0)) {
- m_p.Free();
- }
-
- if (!m_p) {
- BYTE* base = p->GetData();
- BYTE* s = base;
- BYTE* e = s + p->GetCount();
-
- for (; s < e; s++) {
- if (*s != 0xff) {
- continue;
- }
-
- if (s == e - 1 || (s[1] & 0xf6) == 0xf0) {
- memmove(base, s, e - s);
- p->SetCount(e - s);
- m_p = p;
- break;
- }
- }
- } else {
- m_p->Append(*p);
- }
-
- while (m_p && m_p->GetCount() > 9) {
- BYTE* base = m_p->GetData();
- BYTE* s = base;
- BYTE* e = s + m_p->GetCount();
- int len = ((s[3] & 3) << 11) | (s[4] << 3) | (s[5] >> 5);
- bool crc = !(s[1] & 1);
- s += 7;
- len -= 7;
- if (crc) {
- s += 2, len -= 2;
- }
-
- if (e - s < len) {
- break;
- }
-
- if (len <= 0 || e - s >= len + 2 && (s[len] != 0xff || (s[len + 1] & 0xf6) != 0xf0)) {
- m_p.Free();
- break;
- }
-
- CAutoPtr<Packet> p2(DEBUG_NEW Packet());
-
- p2->TrackNumber = m_p->TrackNumber;
- p2->bDiscontinuity |= m_p->bDiscontinuity;
- m_p->bDiscontinuity = false;
-
- p2->bSyncPoint = m_p->rtStart != Packet::INVALID_TIME;
- p2->rtStart = m_p->rtStart;
- m_p->rtStart = Packet::INVALID_TIME;
-
- p2->rtStop = m_p->rtStop;
- m_p->rtStop = Packet::INVALID_TIME;
- p2->pmt = m_p->pmt;
- m_p->pmt = nullptr;
- p2->SetData(s, len);
-
- s += len;
- memmove(base, s, e - s);
- m_p->SetCount(e - s);
-
- HRESULT hr = __super::DeliverPacket(p2);
- if (hr != S_OK) {
- return hr;
- }
- }
-
- if (m_p && p) {
- if (!m_p->bDiscontinuity) {
- m_p->bDiscontinuity = p->bDiscontinuity;
- }
- if (!m_p->bSyncPoint) {
- m_p->bSyncPoint = p->bSyncPoint;
- }
- if (m_p->rtStart == Packet::INVALID_TIME) {
- m_p->rtStart = p->rtStart, m_p->rtStop = p->rtStop;
- }
- if (m_p->pmt) {
- DeleteMediaType(m_p->pmt);
- }
-
- m_p->pmt = p->pmt;
- p->pmt = nullptr;
- }
-
- return S_OK;
- } else if (m_mt.subtype == FOURCCMap('1CVA') || m_mt.subtype == FOURCCMap('1cva') || m_mt.subtype == FOURCCMap('CVMA') || m_mt.subtype == FOURCCMap('CVME')) {
- if (!m_p) {
- m_p.Attach(DEBUG_NEW Packet());
- m_p->TrackNumber = p->TrackNumber;
- m_p->bDiscontinuity = p->bDiscontinuity;
- p->bDiscontinuity = FALSE;
-
- m_p->bSyncPoint = p->bSyncPoint;
- p->bSyncPoint = FALSE;
-
- m_p->rtStart = p->rtStart;
- p->rtStart = Packet::INVALID_TIME;
-
- m_p->rtStop = p->rtStop;
- p->rtStop = Packet::INVALID_TIME;
- }
-
- m_p->Append(*p);
-
- BYTE* start = m_p->GetData();
- BYTE* end = start + m_p->GetCount();
-
- MOVE_TO_H264_START_CODE(start, end);
-
- while (start <= end - 4) {
- BYTE* next = start + 1;
-
- MOVE_TO_H264_START_CODE(next, end);
-
- if (next >= end - 4) {
- break;
- }
-
- int size = next - start;
-
- CH264Nalu Nalu;
- Nalu.SetBuffer(start, size, 0);
-
- CAutoPtr<Packet> p2;
-
- while (Nalu.ReadNext()) {
- DWORD dwNalLength =
- ((Nalu.GetDataLength() >> 24) & 0x000000ff) |
- ((Nalu.GetDataLength() >> 8) & 0x0000ff00) |
- ((Nalu.GetDataLength() << 8) & 0x00ff0000) |
- ((Nalu.GetDataLength() << 24) & 0xff000000);
-
- CAutoPtr<Packet> p3(DEBUG_NEW Packet());
-
- p3->SetCount(Nalu.GetDataLength() + sizeof(dwNalLength));
- memcpy(p3->GetData(), &dwNalLength, sizeof(dwNalLength));
- memcpy(p3->GetData() + sizeof(dwNalLength), Nalu.GetDataBuffer(), Nalu.GetDataLength());
-
- if (p2 == nullptr) {
- p2 = p3;
- } else {
- p2->Append(*p3);
- }
- }
- start = next;
-
- if (!p2) {
- continue;
- }
-
- p2->TrackNumber = m_p->TrackNumber;
- p2->bDiscontinuity = m_p->bDiscontinuity;
- m_p->bDiscontinuity = FALSE;
-
- p2->bSyncPoint = m_p->bSyncPoint;
- m_p->bSyncPoint = FALSE;
-
- p2->rtStart = m_p->rtStart;
- m_p->rtStart = Packet::INVALID_TIME;
- p2->rtStop = m_p->rtStop;
- m_p->rtStop = Packet::INVALID_TIME;
-
- p2->pmt = m_p->pmt;
- m_p->pmt = nullptr;
-
- m_pl.AddTail(p2);
-
- if (p->rtStart != Packet::INVALID_TIME) {
- m_p->rtStart = p->rtStart;
- m_p->rtStop = p->rtStop;
- p->rtStart = Packet::INVALID_TIME;
- }
- if (p->bDiscontinuity) {
- m_p->bDiscontinuity = p->bDiscontinuity;
- p->bDiscontinuity = FALSE;
- }
- if (p->bSyncPoint) {
- m_p->bSyncPoint = p->bSyncPoint;
- p->bSyncPoint = FALSE;
- }
- if (m_p->pmt) {
- DeleteMediaType(m_p->pmt);
- }
-
- m_p->pmt = p->pmt;
- p->pmt = nullptr;
- }
- if (start > m_p->GetData()) {
- m_p->RemoveAt(0, start - m_p->GetData());
- }
-
- REFERENCE_TIME rtStart = Packet::INVALID_TIME, rtStop = Packet::INVALID_TIME;
-
- for (POSITION pos = m_pl.GetHeadPosition(); pos; m_pl.GetNext(pos)) {
- if (pos == m_pl.GetHeadPosition()) {
- continue;
- }
-
- Packet* pPacket = m_pl.GetAt(pos);
- BYTE* pData = pPacket->GetData();
-
- if ((pData[4] & 0x1f) == 0x09) {
- m_fHasAccessUnitDelimiters = true;
- }
-
- if ((pData[4] & 0x1f) == 0x09 || (!m_fHasAccessUnitDelimiters && pPacket->rtStart != Packet::INVALID_TIME)) {
- if (pPacket->rtStart == Packet::INVALID_TIME && rtStart != Packet::INVALID_TIME) {
- pPacket->rtStart = rtStart;
- pPacket->rtStop = rtStop;
- }
-
- p = m_pl.RemoveHead();
-
- while (pos != m_pl.GetHeadPosition()) {
- CAutoPtr<Packet> p2 = m_pl.RemoveHead();
- p->Append(*p2);
- }
-
- HRESULT hr = __super::DeliverPacket(p);
- if (hr != S_OK) {
- return hr;
- }
- } else if (rtStart == Packet::INVALID_TIME) {
- rtStart = pPacket->rtStart;
- rtStop = pPacket->rtStop;
- }
- }
-
- return S_OK;
- } else if (m_mt.subtype == FOURCCMap('1CVW') || m_mt.subtype == FOURCCMap('1cvw') ||
- m_mt.subtype == MEDIASUBTYPE_WVC1_CYBERLINK || m_mt.subtype == MEDIASUBTYPE_WVC1_ARCSOFT) { // just like aac, this has to be starting nalus, more can be packed together
- if (!m_p) {
- m_p.Attach(DEBUG_NEW Packet());
- m_p->TrackNumber = p->TrackNumber;
- m_p->bDiscontinuity = p->bDiscontinuity;
- p->bDiscontinuity = FALSE;
-
- m_p->bSyncPoint = p->bSyncPoint;
- p->bSyncPoint = FALSE;
-
- m_p->rtStart = p->rtStart;
- p->rtStart = Packet::INVALID_TIME;
-
- m_p->rtStop = p->rtStop;
- p->rtStop = Packet::INVALID_TIME;
- }
-
- m_p->Append(*p);
-
- BYTE* start = m_p->GetData();
- BYTE* end = start + m_p->GetCount();
-
- bool bSeqFound = false;
- while (start <= end - 4) {
- if (*(DWORD*)start == 0x0D010000) {
- bSeqFound = true;
- break;
- } else if (*(DWORD*)start == 0x0F010000) {
- break;
- }
- start++;
- }
-
- while (start <= end - 4) {
- BYTE* next = start + 1;
-
- while (next <= end - 4) {
- if (*(DWORD*)next == 0x0D010000) {
- if (bSeqFound) {
- break;
- }
- bSeqFound = true;
- } else if (*(DWORD*)next == 0x0F010000) {
- break;
- }
- next++;
- }
-
- if (next >= end - 4) {
- break;
- }
-
- int size = next - start - 4;
- UNREFERENCED_PARAMETER(size);
-
- CAutoPtr<Packet> p2(DEBUG_NEW Packet());
- p2->TrackNumber = m_p->TrackNumber;
- p2->bDiscontinuity = m_p->bDiscontinuity;
- m_p->bDiscontinuity = FALSE;
-
- p2->bSyncPoint = m_p->bSyncPoint;
- m_p->bSyncPoint = FALSE;
-
- p2->rtStart = m_p->rtStart;
- m_p->rtStart = Packet::INVALID_TIME;
-
- p2->rtStop = m_p->rtStop;
- m_p->rtStop = Packet::INVALID_TIME;
-
- p2->pmt = m_p->pmt;
- m_p->pmt = nullptr;
-
- p2->SetData(start, next - start);
-
- HRESULT hr = __super::DeliverPacket(p2);
- if (hr != S_OK) {
- return hr;
- }
-
- if (p->rtStart != Packet::INVALID_TIME) {
- m_p->rtStart = p->rtStop; //p->rtStart; //Sebastiii for enable VC1 decoding in FFDshow (no more shutter)
- m_p->rtStop = p->rtStop;
- p->rtStart = Packet::INVALID_TIME;
- }
- if (p->bDiscontinuity) {
- m_p->bDiscontinuity = p->bDiscontinuity;
- p->bDiscontinuity = FALSE;
- }
- if (p->bSyncPoint) {
- m_p->bSyncPoint = p->bSyncPoint;
- p->bSyncPoint = FALSE;
- }
- if (m_p->pmt) {
- DeleteMediaType(m_p->pmt);
- }
-
- m_p->pmt = p->pmt;
- p->pmt = nullptr;
-
- start = next;
- bSeqFound = (*(DWORD*)start == 0x0D010000);
- }
-
- if (start > m_p->GetData()) {
- m_p->RemoveAt(0, start - m_p->GetData());
- }
-
- return S_OK;
- }
- // DTS HD MA data is causing trouble with some filters, lets just remove it
- else if (m_bFilterDTSMA && ((m_mt.subtype == MEDIASUBTYPE_DTS || m_mt.subtype == MEDIASUBTYPE_WAVE_DTS))) {
- if (p->GetCount() < 4 && !p->pmt) {
- return S_OK; // Should be invalid packet
- }
- BYTE* hdr = p->GetData();
-
- int Type;
- // 16 bits big endian bitstream
- if (hdr[0] == 0x7f && hdr[1] == 0xfe &&
- hdr[2] == 0x80 && hdr[3] == 0x01) {
- Type = 16 + 32;
- }
-
- // 16 bits low endian bitstream
- else if (hdr[0] == 0xfe && hdr[1] == 0x7f &&
- hdr[2] == 0x01 && hdr[3] == 0x80) {
- Type = 16;
- }
-
- // 14 bits big endian bitstream
- else if (hdr[0] == 0x1f && hdr[1] == 0xff &&
- hdr[2] == 0xe8 && hdr[3] == 0x00 &&
- hdr[4] == 0x07 && (hdr[5] & 0xf0) == 0xf0) {
- Type = 14 + 32;
- }
-
- // 14 bits low endian bitstream
- else if (hdr[0] == 0xff && hdr[1] == 0x1f &&
- hdr[2] == 0x00 && hdr[3] == 0xe8 &&
- (hdr[4] & 0xf0) == 0xf0 && hdr[5] == 0x07) {
- Type = 14;
- }
-
- // no sync
- else if (!p->pmt) {
- return S_OK;
- }
- // HDMV LPCM
- } else if (m_mt.subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
- if (!m_p) {
- m_p.Attach(DEBUG_NEW Packet());
- }
- m_p->Append(*p);
-
- if (m_p->GetCount() < 4) {
- m_p.Free();
- return S_OK; // Should be invalid packet
- }
-
- BYTE* start = m_p->GetData();
- int samplerate, channels;
- size_t header_size = ParseHdmvLPCMHeader(start, &samplerate, &channels);
- if (!header_size || header_size > m_p->GetCount()) {
- if (!header_size) {
- m_p.Free();
- }
- return S_OK;
- }
-
- if (!p->pmt && m_bFlushed) {
- p->pmt = CreateMediaType(&m_mt);
- m_bFlushed = false;
- }
- p->SetData(start + 4, m_p->GetCount() - 4);
- m_p.Free();
- // Dolby_AC3
- } else if ((m_type == mpeg_ts) &&
- (m_mt.subtype == MEDIASUBTYPE_DOLBY_AC3) &&
- (static_cast<CMpegSplitterFilter*>(m_pFilter))->StreamIsTrueHD(p->TrackNumber) &&
- (static_cast<CMpegSplitterFilter*>(m_pFilter))->GetTrueHD() != 2) {
- if (p->GetCount() < 8) {
- return S_OK; // Should be invalid packet
- }
- BYTE* start = p->GetData();
- if (*(WORD*)start != 0x770b) { // skip none AC3
- return S_OK;
- }
- // TrueHD
- } else if (m_mt.subtype == MEDIASUBTYPE_DOLBY_TRUEHD && (static_cast<CMpegSplitterFilter*>(m_pFilter))->GetTrueHD() != 2) {
- if (p->GetCount() < 8) {
- return S_OK; // Should be invalid packet
- }
- BYTE* start = p->GetData();
- if (*(WORD*)start == 0x770b) { // skip AC3
- return S_OK;
- }
- if (DD_reset || p->rtStart == 0) {
- p->bDiscontinuity = true;
- DD_reset = false;
- }
- } else {
- m_p.Free();
- m_pl.RemoveAll();
- }
-
- return __super::DeliverPacket(p);
-}
-
-STDMETHODIMP CMpegSplitterOutputPin::Connect(IPin* pReceivePin, const AM_MEDIA_TYPE* pmt)
-{
- HRESULT hr;
- PIN_INFO PinInfo;
- GUID FilterClsid;
-
- if (SUCCEEDED(pReceivePin->QueryPinInfo(&PinInfo))) {
- if (SUCCEEDED(PinInfo.pFilter->GetClassID(&FilterClsid))) {
- if (FilterClsid == CLSID_DMOWrapperFilter) {
- (static_cast<CMpegSplitterFilter*>(m_pFilter))->SetPipo(true);
- }
- // AC3 Filter did not support DTS-MA
- else if (FilterClsid == CLSID_AC3Filter) {
- m_bFilterDTSMA = true;
- }
- }
- PinInfo.pFilter->Release();
- }
-
- hr = __super::Connect(pReceivePin, pmt);
- (static_cast<CMpegSplitterFilter*>(m_pFilter))->SetPipo(false);
- return hr;
-}
diff --git a/src/filters/parser/MpegSplitter/MpegSplitter.def b/src/filters/parser/MpegSplitter/MpegSplitter.def
deleted file mode 100644
index 6492e5cd6..000000000
--- a/src/filters/parser/MpegSplitter/MpegSplitter.def
+++ /dev/null
@@ -1,5 +0,0 @@
-EXPORTS
- DllCanUnloadNow PRIVATE
- DllGetClassObject PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
diff --git a/src/filters/parser/MpegSplitter/MpegSplitter.h b/src/filters/parser/MpegSplitter/MpegSplitter.h
deleted file mode 100644
index 2a6eb97cc..000000000
--- a/src/filters/parser/MpegSplitter/MpegSplitter.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../BaseSplitter/BaseSplitter.h"
-#include "MpegSplitterFile.h"
-#include "MpegSplitterSettingsWnd.h"
-#include "ITrackInfo.h"
-
-#define MpegSplitterName L"MPC MPEG Splitter"
-#define MpegSourceName L"MPC MPEG Source"
-
-class __declspec(uuid("DC257063-045F-4BE2-BD5B-E12279C464F0"))
- CMpegSplitterFilter
- : public CBaseSplitterFilter
- , public IAMStreamSelect
- , public ISpecifyPropertyPages2
- , public IMpegSplitterFilter
-{
- REFERENCE_TIME m_rtStartOffset;
- bool m_pPipoBimbo;
- CHdmvClipInfo m_ClipInfo;
-
-protected:
- CAutoPtr<CMpegSplitterFile> m_pFile;
- CComQIPtr<ITrackInfo> pTI;
-
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
- void ReadClipInfo(LPCOLESTR pszFileName);
-
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
- bool BuildPlaylist(LPCTSTR pszFileName, CAtlList<CHdmvClipInfo::PlaylistItem>& files);
- bool BuildChapters(LPCTSTR pszFileName, CAtlList<CHdmvClipInfo::PlaylistItem>& PlaylistItems, CAtlList<CHdmvClipInfo::PlaylistChapter>& Items);
-
- HRESULT DemuxNextPacket(REFERENCE_TIME rtStartOffset);
-
- REFERENCE_TIME m_rtPlaylistDuration;
-
-private:
- CString m_csAudioLanguageOrder, m_csSubtitlesLanguageOrder;
- bool m_useFastStreamChange, m_ForcedSub, m_AlternativeDuration;
- int m_nVC1_GuidFlag, m_AC3CoreOnly;
- CCritSec m_csProps;
-
-public:
- CMpegSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid = __uuidof(CMpegSplitterFilter));
- void SetPipo(bool bPipo) { m_pPipoBimbo = bPipo; };
-
- bool StreamIsTrueHD(const WORD pid);
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- STDMETHODIMP GetClassID(CLSID* pClsID);
- STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
-
- // CBaseFilter
-
- STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
-
- // IAMStreamSelect
-
- STDMETHODIMP Count(DWORD* pcStreams);
- STDMETHODIMP Enable(long lIndex, DWORD dwFlags);
- STDMETHODIMP Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* pdwFlags, LCID* plcid,
- DWORD* pdwGroup, WCHAR** ppszName, IUnknown** ppObject, IUnknown** ppUnk);
-
- // ISpecifyPropertyPages2
-
- STDMETHODIMP GetPages(CAUUID* pPages);
- STDMETHODIMP CreatePage(const GUID& guid, IPropertyPage** ppPage);
-
- // IMpegSplitterFilter
- STDMETHODIMP Apply();
-
- STDMETHODIMP SetFastStreamChange(BOOL nValue);
- STDMETHODIMP_(BOOL) GetFastStreamChange();
-
- STDMETHODIMP SetForcedSub(BOOL nValue);
- STDMETHODIMP_(BOOL) GetForcedSub();
-
- STDMETHODIMP SetAudioLanguageOrder(WCHAR* nValue);
- STDMETHODIMP_(WCHAR*) GetAudioLanguageOrder();
-
- STDMETHODIMP SetSubtitlesLanguageOrder(WCHAR* nValue);
- STDMETHODIMP_(WCHAR*) GetSubtitlesLanguageOrder();
-
- STDMETHODIMP SetVC1_GuidFlag(int nValue);
- STDMETHODIMP_(int) GetVC1_GuidFlag();
-
- STDMETHODIMP SetTrueHD(int nValue);
- STDMETHODIMP_(int) GetTrueHD();
-
- STDMETHODIMP SetAlternativeDuration(BOOL nValue);
- STDMETHODIMP_(BOOL) GetAlternativeDuration();
-
- STDMETHODIMP_(int) GetMPEGType();
-};
-
-class __declspec(uuid("1365BE7A-C86A-473C-9A41-C0A6E82C9FA3"))
- CMpegSourceFilter : public CMpegSplitterFilter
-{
-public:
- CMpegSourceFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid = __uuidof(CMpegSourceFilter));
-};
-
-class CMpegSplitterOutputPin : public CBaseSplitterOutputPin, protected CCritSec
-{
- CAutoPtr<Packet> m_p;
- CAutoPtrList<Packet> m_pl;
- REFERENCE_TIME m_rtPrev, m_rtOffset, m_rtMaxShift;
- bool m_fHasAccessUnitDelimiters;
- bool m_bFilterDTSMA;
- bool DD_reset;
- bool m_bFlushed;
- int m_type;
-
-protected:
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
- HRESULT DeliverPacket(CAutoPtr<Packet> p);
- HRESULT DeliverEndFlush();
-
-public:
- CMpegSplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr, int type);
- virtual ~CMpegSplitterOutputPin();
- STDMETHODIMP Connect(IPin* pReceivePin, const AM_MEDIA_TYPE* pmt);
- void SetMaxShift(REFERENCE_TIME rtMaxShift) { m_rtMaxShift = rtMaxShift; };
-};
diff --git a/src/filters/parser/MpegSplitter/MpegSplitter.rc b/src/filters/parser/MpegSplitter/MpegSplitter.rc
deleted file mode 100644
index 50eefbf5a..000000000
--- a/src/filters/parser/MpegSplitter/MpegSplitter.rc
+++ /dev/null
@@ -1,115 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-#include "version.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (United States) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION MPC_VERSION_NUM
- PRODUCTVERSION MPC_VERSION_NUM
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS VOS_NT_WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE VFT2_UNKNOWN
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", MPC_VERSION_COMMENTS
- VALUE "CompanyName", MPC_COMP_NAME_STR
- VALUE "FileDescription", "MPEG Splitter"
- VALUE "FileVersion", MPC_VERSION_STR_FULL
- VALUE "InternalName", "MPEG Splitter"
- VALUE "LegalCopyright", MPC_COPYRIGHT_STR
- VALUE "OriginalFilename", "MpegSplitter.ax"
- VALUE "ProductName", "MPEG Splitter"
- VALUE "ProductVersion", MPC_VERSION_STR_FULL
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-STRINGTABLE
-BEGIN
- IDS_FILTER_SETTINGS_CAPTION "Settings"
- IDS_MPEGSPLITTER_FSTREAM_CHANGE "Fast stream change"
- IDS_MPEGSPLITTER_LANG_ORDER "Audio language order:"
- IDS_MPEGSPLITTER_SUB_ORDER "Subtitles language order:"
- IDS_MPEGSPLITTER_VC1_GUIDFLAG "VC-1 Output compatibility:"
- IDS_MPEGSPLITTER_SUB_FORCING "Force load all subtitles"
- IDS_MPEGSPLITTER_TRUEHD_OUTPUT "TrueHD+AC3 streams output"
- IDS_MPEGSPLITTER_THD_NOSPLIT "As is"
- IDS_MPEGSPLITTER_ALT_DUR_CALC "Alternative method calculation of duration"
-END
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // English (United States) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/src/filters/parser/MpegSplitter/MpegSplitter.vcxproj b/src/filters/parser/MpegSplitter/MpegSplitter.vcxproj
deleted file mode 100644
index e7f6c485e..000000000
--- a/src/filters/parser/MpegSplitter/MpegSplitter.vcxproj
+++ /dev/null
@@ -1,258 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug Filter|Win32">
- <Configuration>Debug Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug Filter|x64">
- <Configuration>Debug Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|Win32">
- <Configuration>Release Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|x64">
- <Configuration>Release Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{4628C665-EDE4-40D2-B525-32BE8B8551C8}</ProjectGuid>
- <RootNamespace>MpegSplitter</RootNamespace>
- <Keyword>MFCProj</Keyword>
- <ProjectName>MpegSplitter</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <Import Project="..\..\..\platform.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">.ax</TargetExt>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MpegSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MpegSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MpegSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>MpegSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="MpegSplitter.cpp" />
- <ClCompile Include="MpegSplitterFile.cpp" />
- <ClCompile Include="MpegSplitterSettingsWnd.cpp" />
- <ClCompile Include="stdafx.cpp">
- <PrecompiledHeader>Create</PrecompiledHeader>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="MpegSplitter.def" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="IMpegSplitterFilter.h" />
- <ClInclude Include="MpegSplitter.h" />
- <ClInclude Include="MpegSplitterFile.h" />
- <ClInclude Include="resource.h">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ClInclude>
- <ClInclude Include="MpegSplitterSettingsWnd.h" />
- <ClInclude Include="stdafx.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="MpegSplitter.rc">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ResourceCompile>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\DSUtil\DSUtil.vcxproj">
- <Project>{fc70988b-1ae5-4381-866d-4f405e28ac42}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\Kasumi\Kasumi.vcxproj">
- <Project>{0d252872-7542-4232-8d02-53f9182aee15}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\system\system.vcxproj">
- <Project>{c2082189-3ecb-4079-91fa-89d3c8a305c0}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\BaseClasses\BaseClasses.vcxproj">
- <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\Filters.vcxproj">
- <Project>{273b3149-3192-4b75-a791-470320b90812}</Project>
- </ProjectReference>
- <ProjectReference Include="..\BaseSplitter\BaseSplitter.vcxproj">
- <Project>{37768b3f-89bc-4c16-b2a8-767c5da84c3f}</Project>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/MpegSplitter/MpegSplitter.vcxproj.filters b/src/filters/parser/MpegSplitter/MpegSplitter.vcxproj.filters
deleted file mode 100644
index 1866e3db9..000000000
--- a/src/filters/parser/MpegSplitter/MpegSplitter.vcxproj.filters
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{70db579e-c2ed-4846-a0d6-b454d5fb8edb}</UniqueIdentifier>
- <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{433ed245-8fc9-40ee-963b-755c136edc4f}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{967ace11-b9ea-4595-b490-e262f148595f}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="MpegSplitter.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="MpegSplitterFile.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="stdafx.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="MpegSplitterSettingsWnd.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="MpegSplitter.def">
- <Filter>Source Files</Filter>
- </None>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="IMpegSplitterFilter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="MpegSplitter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="MpegSplitterFile.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="MpegSplitterSettingsWnd.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="resource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="stdafx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="MpegSplitter.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp b/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp
deleted file mode 100644
index 777fc0169..000000000
--- a/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp
+++ /dev/null
@@ -1,1134 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <MMReg.h>
-#include "MpegSplitterFile.h"
-
-#ifdef STANDALONE_FILTER
-#include <InitGuid.h>
-#endif
-#include "moreuuids.h"
-
-#define MEGABYTE 1024*1024
-#define PTS_MAX_BEFORE_WRAP (((1i64 << 33) - 1) * 10000 / 90)
-
-
-CMpegSplitterFile::CMpegSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr, bool bIsHdmv, CHdmvClipInfo& ClipInfo, int guid_flag, bool ForcedSub, int AC3CoreOnly, bool AlternativeDuration)
- : CBaseSplitterFileEx(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false, true)
- , m_type(mpeg_us)
- , m_rate(0)
- , m_rtMin(0), m_rtMax(0)
- , m_posMin(0), m_posMax(0)
- , m_rtPrec(_I64_MIN)
- , m_bPTSWrap(false)
- , m_bIsHdmv(bIsHdmv)
- , m_ClipInfo(ClipInfo)
- , m_nVC1_GuidFlag(guid_flag)
- , m_ForcedSub(ForcedSub)
- , m_AC3CoreOnly(AC3CoreOnly)
- , m_AlternativeDuration(AlternativeDuration)
- , m_init(false)
-{
- if (SUCCEEDED(hr)) {
- hr = Init(pAsyncReader);
- }
-}
-
-HRESULT CMpegSplitterFile::Init(IAsyncReader* pAsyncReader)
-{
- HRESULT hr;
-
- // get the type first
-
- m_type = mpeg_us;
-
- Seek(0);
-
- if (m_type == mpeg_us) {
- if (BitRead(32, true) == 'TFrc') {
- Seek(0x67c);
- }
- int cnt = 0, limit = 4;
- for (tshdr h; cnt < limit && Read(h); cnt++) {
- Seek(h.next);
- }
- if (cnt >= limit) {
- m_type = mpeg_ts;
- }
- }
-
- Seek(0);
-
- if (m_type == mpeg_us) {
- if (BitRead(32, true) == 'TFrc') {
- Seek(0xE80);
- }
- int cnt = 0, limit = 4;
- for (tshdr h; cnt < limit && Read(h); cnt++) {
- Seek(h.next);
- }
- if (cnt >= limit) {
- m_type = mpeg_ts;
- }
- }
-
- Seek(0);
-
- if (m_type == mpeg_us) {
- int cnt = 0, limit = 4;
- for (pvahdr h; cnt < limit && Read(h); cnt++) {
- Seek(GetPos() + h.length);
- }
- if (cnt >= limit) {
- m_type = mpeg_pva;
- }
- }
-
- Seek(0);
-
- if (m_type == mpeg_us) {
- BYTE b;
- for (int i = 0; (i < 4 || GetPos() < MAX_PROBE_SIZE) && m_type == mpeg_us && NextMpegStartCode(b); i++) {
- if (b == 0xba) {
- pshdr h;
- if (Read(h)) {
- m_type = mpeg_ps;
- m_rate = int(h.bitrate / 8);
- break;
- }
- } else if ((b & 0xe0) == 0xc0 // audio, 110xxxxx, mpeg1/2/3
- || (b & 0xf0) == 0xe0 // video, 1110xxxx, mpeg1/2
- // || (b&0xbd) == 0xbd) // private stream 1, 0xbd, ac3/dts/lpcm/subpic
- || b == 0xbd) { // private stream 1, 0xbd, ac3/dts/lpcm/subpic
- peshdr h;
- if (Read(h, b) && BitRead(24, true) == 0x000001) {
- m_type = mpeg_es;
- }
- }
- }
- }
-
- Seek(0);
-
- if (m_type == mpeg_us) {
- return E_FAIL;
- }
-
- // min/max pts & bitrate
- m_rtMin = m_posMin = _I64_MAX;
- m_rtMax = m_posMax = 0;
- m_rtPrec = _I64_MIN;
- m_bPTSWrap = false;
-
- m_init = true;
-
- if (IsRandomAccess() || IsStreaming()) {
- if (IsStreaming()) {
- for (int i = 0; i < 20 || i < 50 && S_OK != HasMoreData(MEGABYTE, 100); i++) {
- ;
- }
- }
-
- SearchPrograms(0, min(GetLength(), MEGABYTE * 5)); // max 5Mb for search a valid Program Map Table
-
- __int64 pfp = 0;
- const int k = 5;
- for (int i = 0; i <= k; i++) {
- __int64 fp = i * GetLength() / k;
- fp = min(GetLength() - MEGABYTE / 8, fp);
- fp = max(pfp, fp);
- __int64 nfp = fp + (pfp == 0 ? 10 * MEGABYTE : MEGABYTE / 8);
- if (FAILED(hr = SearchStreams(fp, nfp, pAsyncReader))) {
- return hr;
- }
- pfp = nfp;
- }
- } else {
- if (FAILED(hr = SearchStreams(0, MEGABYTE / 8, pAsyncReader))) {
- return hr;
- }
- }
-
- if (m_type == mpeg_ts) {
- if (IsRandomAccess() || IsStreaming()) {
- if (IsStreaming()) {
- for (int i = 0; i < 20 || i < 50 && S_OK != HasMoreData(1024 * 100, 100); i++) {
- ;
- }
- }
-
- __int64 pfp = 0;
- const int k = 5;
- for (int i = 0; i <= k; i++) {
- __int64 fp = i * GetLength() / k;
- fp = min(GetLength() - MEGABYTE / 8, fp);
- fp = max(pfp, fp);
- __int64 nfp = fp + (pfp == 0 ? 10 * MEGABYTE : MEGABYTE / 8);
- if (FAILED(hr = SearchStreams(fp, nfp, pAsyncReader, TRUE))) {
- return hr;
- }
- pfp = nfp;
- }
- } else {
- if (FAILED(hr = SearchStreams(0, MEGABYTE / 8, pAsyncReader, TRUE))) {
- return hr;
- }
- }
- }
-
- if (m_posMax - m_posMin <= 0 || (m_rtMax - m_rtMin <= 0 && !m_bPTSWrap)) {
- return E_FAIL;
- }
-
- m_init = false;
-
- int indicated_rate = m_rate;
- REFERENCE_TIME dur = !m_bPTSWrap ? (m_rtMax - m_rtMin) : (PTS_MAX_BEFORE_WRAP - m_rtMin + m_rtMax);
- int detected_rate = int(10000000i64 * (m_posMax - m_posMin) / dur);
-
- m_rate = detected_rate ? detected_rate : m_rate;
-#if (0)
- // normally "detected" should always be less than "indicated", but sometimes it can be a few percent higher (+10% is allowed here)
- // (update: also allowing +/-50k/s)
- if (indicated_rate == 0 || ((float)detected_rate / indicated_rate) < 1.1 || abs(detected_rate - indicated_rate) < 50 * 1024) {
- m_rate = detected_rate;
- } else {
- ; // TODO: in this case disable seeking, or try doing something less drastical...
- }
-#endif
-
- // Add fake subtitle stream...
- if (m_streams[video].GetCount() && m_streams[subpic].GetCount()) {
- if (m_type == mpeg_ts && m_bIsHdmv) {
- AddHdmvPGStream(NO_SUBTITLE_PID, "---");
- } else {
- stream s;
- s.pid = NO_SUBTITLE_PID;
- s.mt.majortype = m_streams[subpic].GetHead().mt.majortype;
- s.mt.subtype = m_streams[subpic].GetHead().mt.subtype;
- s.mt.formattype = m_streams[subpic].GetHead().mt.formattype;
- m_streams[subpic].Insert(s, this);
- }
- }
-
- Seek(0);
-
- return S_OK;
-}
-
-void CMpegSplitterFile::OnComplete(IAsyncReader* pAsyncReader)
-{
- __int64 pos = GetPos();
-
- if (SUCCEEDED(SearchStreams(GetLength() - 500 * 1024, GetLength(), pAsyncReader, TRUE))) {
- int indicated_rate = m_rate;
- REFERENCE_TIME dur = !m_bPTSWrap ? (m_rtMax - m_rtMin) : (PTS_MAX_BEFORE_WRAP - m_rtMin + m_rtMax);
- int detected_rate = int(10000000i64 * (m_posMax - m_posMin) / dur);
-
- m_rate = detected_rate ? detected_rate : m_rate;
-#if (0)
- // normally "detected" should always be less than "indicated", but sometimes it can be a few percent higher (+10% is allowed here)
- // (update: also allowing +/-50k/s)
- if (indicated_rate == 0 || ((float)detected_rate / indicated_rate) < 1.1 || abs(detected_rate - indicated_rate) < 50 * 1024) {
- m_rate = detected_rate;
- } else {
- ; // TODO: in this case disable seeking, or try doing something less drastical...
- }
-#endif
- }
-
- Seek(pos);
-}
-
-REFERENCE_TIME CMpegSplitterFile::NextPTS(DWORD TrackNum)
-{
- REFERENCE_TIME rt = -1;
- __int64 rtpos = -1;
-
- BYTE b;
-
- while (GetRemaining()) {
- if (m_type == mpeg_ps || m_type == mpeg_es) {
- if (!NextMpegStartCode(b)) { // continue;
- ASSERT(0);
- break;
- }
-
- rtpos = GetPos() - 4;
-
- if ((b >= 0xbd && b < 0xf0) || (b == 0xfd)) {
- peshdr h;
- if (!Read(h, b) || !h.len) {
- continue;
- }
-
- __int64 pos = GetPos();
-
- if (h.fpts && AddStream(0, b, h.id_ext, h.len) == TrackNum) {
- //ASSERT(h.pts >= m_rtMin && h.pts <= m_rtMax);
- rt = h.pts;
- break;
- }
-
- Seek(pos + h.len);
- }
- } else if (m_type == mpeg_ts) {
- tshdr h;
- if (!Read(h)) {
- continue;
- }
-
- rtpos = GetPos() - 4;
-
- if (h.payload && h.payloadstart && ISVALIDPID(h.pid)) {
- peshdr h2;
- if (NextMpegStartCode(b, 4) && Read(h2, b)) { // pes packet
- if (h2.fpts && AddStream(h.pid, b, 0, DWORD(h.bytes - (GetPos() - rtpos)) == TrackNum)) {
- //ASSERT(h2.pts >= m_rtMin && h2.pts <= m_rtMax);
- rt = h2.pts;
- break;
- }
- }
- }
-
- Seek(h.next);
- } else if (m_type == mpeg_pva) {
- pvahdr h;
- if (!Read(h)) {
- continue;
- }
-
- if (h.fpts) {
- rt = h.pts;
- break;
- }
- }
- }
-
- if (rtpos >= 0) {
- Seek(rtpos);
- }
- if (rt >= 0) {
- rt -= m_rtMin;
- }
-
- return rt;
-}
-
-void CMpegSplitterFile::SearchPrograms(__int64 start, __int64 stop)
-{
- if (m_type != mpeg_ts) {
- return;
- }
-
- Seek(start);
- stop = min(stop, GetLength());
-
- while (GetPos() < stop) {
- tshdr h;
- if (!Read(h)) {
- continue;
- }
-
- UpdatePrograms(h);
- Seek(h.next);
- }
-}
-
-HRESULT CMpegSplitterFile::SearchStreams(__int64 start, __int64 stop, IAsyncReader* pAsyncReader, BOOL CalcDuration)
-{
- Seek(start);
- stop = min(stop, GetLength());
-
- while (GetPos() < stop) {
- BYTE b;
-
- if (m_type == mpeg_ps || m_type == mpeg_es) {
- if (!NextMpegStartCode(b)) {
- continue;
- }
-
- if (b == 0xba) { // program stream header
- pshdr h;
- if (!Read(h)) {
- continue;
- }
- m_rate = int(h.bitrate / 8);
- } else if (b == 0xbb) { // program stream system header
- pssyshdr h;
- if (!Read(h)) {
- continue;
- }
- } else if ((b >= 0xbd && b < 0xf0) || (b == 0xfd)) { // pes packet
- peshdr h;
- if (!Read(h, b) || !h.len) {
- continue;
- }
-
- if (h.type == mpeg2 && h.scrambling) {
- ASSERT(0);
- return E_FAIL;
- }
-
- if (h.fpts) {
- if (m_rtMin == _I64_MAX) {
- m_rtMin = h.pts;
- m_posMin = GetPos();
- TRACE(_T("m_rtMin(SearchStreams)=%s\n"), ReftimeToString(m_rtMin));
- }
- if (m_rtMin < h.pts && m_rtMax < h.pts) {
- m_rtMax = h.pts;
- m_posMax = GetPos();
- TRACE(_T("m_rtMax(SearchStreams)=%s\n"), ReftimeToString(m_rtMax));
- }
- }
-
- __int64 pos = GetPos();
- AddStream(0, b, h.id_ext, h.len);
- if (h.len) {
- Seek(pos + h.len);
- }
- }
- } else if (m_type == mpeg_ts) {
- tshdr h;
- if (!Read(h)) {
- continue;
- }
-
- __int64 pos = GetPos();
-
- //UpdatePrograms(h);
-
- if (h.payload && ISVALIDPID(h.pid)) {
- peshdr h2;
- if (h.payloadstart && NextMpegStartCode(b, 4) && Read(h2, b)) { // pes packet
- if (h2.type == mpeg2 && h2.scrambling) {
- ASSERT(0);
- return E_FAIL;
- }
-
- if (h2.fpts && CalcDuration && (m_AlternativeDuration || (GetMasterStream() && GetMasterStream()->GetHead() == h.pid))) {
- if (m_rtPrec != _I64_MIN && abs(h2.pts - m_rtPrec) >= PTS_MAX_BEFORE_WRAP / 2) {
- m_bPTSWrap = true;
- m_rtMax = h2.pts;
- m_posMax = GetPos();
- TRACE(_T("PTS Wrap detected --> m_rtMax(SearchStreams)=%s\n"), ReftimeToString(m_rtMax));
- }
- m_rtPrec = h2.pts;
-
- if ((m_rtMin == _I64_MAX) || (m_rtMin > h2.pts && m_rtMax > h2.pts && !m_bPTSWrap)) {
- m_rtMin = h2.pts;
- m_posMin = GetPos();
- TRACE(_T("m_rtMin(SearchStreams)=%s, PID=%d\n"), ReftimeToString(m_rtMin), h.pid);
- }
-
- if (m_rtMax < h2.pts && (m_rtMin < h2.pts || m_bPTSWrap)) {
- m_rtMax = h2.pts;
- m_posMax = GetPos();
- TRACE(_T("m_rtMax(SearchStreams)=%s, PID=%d\n"), ReftimeToString(m_rtMax), h.pid);
- // Ugly code : to support BRD H264 seamless playback, CMultiFiles need to update m_rtPTSOffset variable
- // each time a new part is open...
- // use this code only if Blu-ray is detected
- if (m_ClipInfo.IsHdmv()) {
- for (size_t i = 0; i < m_ClipInfo.GetStreamNumber(); i++) {
- const CHdmvClipInfo::Stream* stream = m_ClipInfo.GetStreamByIndex(i);
- if (stream->m_Type == VIDEO_STREAM_H264 && m_rtMin == 116506666) {
- CComQIPtr<ISyncReader> pReader = pAsyncReader;
- if (pReader) {
- pReader->SetPTSOffset(&m_rtPTSOffset);
- }
- //TRACE(_T("UPDATE m_rtPTSOffset(SearchStreams)=%s\n"), ReftimeToString(m_rtPTSOffset));
- //TRACE(_T("m_rtMin(Boucle)=%s\n"), ReftimeToString(m_rtMin));
- //TRACE(_T("stream=%d\n"), stream->m_Type);
- //TRACE(_T("m_rtMax(Boucle)=%s\n"), ReftimeToString(m_rtMax));
- //TRACE(_T("m_rtMax - m_rtMin(Boucle)=%s\n"), ReftimeToString(m_rtMax - m_rtMin));
- }
- }
- }
- }
- }
- } else {
- b = 0;
- }
-
- if (!CalcDuration) {
- AddStream(h.pid, b, 0, DWORD(h.bytes - (GetPos() - pos)));
- }
- }
-
- Seek(h.next);
- } else if (m_type == mpeg_pva) {
- pvahdr h;
- if (!Read(h)) {
- continue;
- }
-
- if (h.fpts) {
- if (m_rtMin == _I64_MAX) {
- m_rtMin = h.pts;
- m_posMin = GetPos();
- }
-
- if (m_rtMin < h.pts && m_rtMax < h.pts) {
- m_rtMax = h.pts;
- m_posMax = GetPos();
- }
- }
-
- __int64 pos = GetPos();
-
- if (h.streamid == 1) {
- AddStream(h.streamid, 0xe0, 0, h.length);
- } else if (h.streamid == 2) {
- AddStream(h.streamid, 0xc0, 0, h.length);
- }
-
- if (h.length) {
- Seek(pos + h.length);
- }
- }
- }
-
- return S_OK;
-}
-
-#define IsMpegAudio(stream_type) (stream_type == AUDIO_STREAM_MPEG1 || stream_type == AUDIO_STREAM_MPEG2)
-#define IsAACAudio(stream_type) (stream_type == AUDIO_STREAM_AAC)
-#define IsAACLATMAudio(stream_type) (stream_type == AUDIO_STREAM_AAC_LATM)
-#define IsAC3Audio(stream_type) ( \
- stream_type == AUDIO_STREAM_AC3 || stream_type == AUDIO_STREAM_AC3_PLUS || \
- stream_type == AUDIO_STREAM_AC3_TRUE_HD || stream_type == SECONDARY_AUDIO_AC3_PLUS || \
- stream_type == PES_PRIVATE)
-#define IsMPEG2Video(stream_type) (stream_type == VIDEO_STREAM_MPEG2)
-#define IsH264Video(stream_type) (stream_type == VIDEO_STREAM_H264)
-#define IsVC1Video(stream_type) (stream_type == VIDEO_STREAM_VC1)
-
-DWORD CMpegSplitterFile::AddStream(WORD pid, BYTE pesid, BYTE ps1id, DWORD len)
-{
- if (pid) {
- if (pesid) {
- m_pid2pes[pid] = pesid;
- } else {
- m_pid2pes.Lookup(pid, pesid);
- }
- }
-
- stream s;
- s.pid = pid;
- s.pesid = pesid;
- s.ps1id = ps1id;
-
- const __int64 start = GetPos();
- int type = unknown;
-
- if (pesid >= 0xe0 && pesid < 0xf0) { // mpeg video
-
- // MPEG2
- if (type == unknown) {
- CMpegSplitterFile::seqhdr h;
- if (!m_streams[video].Find(s) && Read(h, len, &s.mt)) {
- PES_STREAM_TYPE stream_type = INVALID;
- if (GetStreamType(s.pid, stream_type)) {
- if (IsMPEG2Video(stream_type)) {
- type = video;
- }
- } else {
- type = video;
- }
- }
- }
-
- // H.264
- if (type == unknown) {
- Seek(start);
- // PPS and SPS can be present on differents packets
- // and can also be split into multiple packets
- if (!avch.Lookup(pid)) {
- ZeroMemory(&avch[pid], sizeof(CMpegSplitterFile::avchdr));
- }
-#if defined(MVC_SUPPORT)
- if (!m_streams[video].Find(s) && !m_streams[stereo].Find(s) && Read(avch[pid], len, &s.mt)) {
- if (avch[pid].spspps[index_subsetsps].complete) {
- type = stereo;
- } else {
- type = video;
- }
- }
-#else
- if (!m_streams[video].Find(s) && Read(avch[pid], len, &s.mt)) {
- PES_STREAM_TYPE stream_type = INVALID;
- if (GetStreamType(s.pid, stream_type)) {
- if (IsH264Video(stream_type)) {
- type = video;
- }
- } else {
- type = video;
- }
- }
-#endif
- }
- } else if (pesid >= 0xc0 && pesid < 0xe0) { // mpeg audio
-
- // AAC
- if (type == unknown) {
- CMpegSplitterFile::aachdr h;
- if (!m_streams[audio].Find(s) && Read(h, len, &s.mt, m_type)) {
- PES_STREAM_TYPE stream_type = INVALID;
- if (GetStreamType(s.pid, stream_type)) {
- if (IsAACAudio(stream_type)) {
- type = audio;
- }
- } else {
- type = audio;
- }
- }
- }
-
- // AAC LATM
- if (type == unknown) {
- Seek(start);
- CMpegSplitterFile::latm_aachdr h;
- if (!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
- PES_STREAM_TYPE stream_type = INVALID;
- if (GetStreamType(s.pid, stream_type)) {
- if (IsAACLATMAudio(stream_type)) {
- type = audio;
- }
- } else {
- type = audio;
- }
- }
- }
-
- // MPEG Audio
- if (type == unknown) {
- Seek(start);
- CMpegSplitterFile::mpahdr h;
- if (!m_streams[audio].Find(s) && Read(h, len, false, &s.mt)) {
- PES_STREAM_TYPE stream_type = INVALID;
- if (GetStreamType(s.pid, stream_type)) {
- if (IsMpegAudio(stream_type)) {
- type = audio;
- }
- } else {
- type = audio;
- }
- }
- }
- } else if (pesid == 0xbd || pesid == 0xfd) { // private stream 1
- if (s.pid) {
- if (!m_streams[audio].Find(s) && !m_streams[video].Find(s)) {
-
- // AC3, E-AC3, TrueHD
- if (type == unknown) {
- CMpegSplitterFile::ac3hdr h;
- if (Read(h, len, &s.mt, true, (m_AC3CoreOnly == 1))) {
- PES_STREAM_TYPE stream_type = INVALID;
- if (GetStreamType(s.pid, stream_type)) {
- if (IsAC3Audio(stream_type)) {
- type = audio;
- }
- } else {
- type = audio;
- }
- }
- }
-
- // DTS, DTS HD, DTS HD MA
- if (type == unknown) {
- Seek(start);
- CMpegSplitterFile::dtshdr h;
- if (Read(h, len, &s.mt, false)) {
- type = audio;
- }
- }
-
- // VC1
- if (type == unknown) {
- Seek(start);
- CMpegSplitterFile::vc1hdr h;
- if (!m_streams[video].Find(s) && Read(h, len, &s.mt, m_nVC1_GuidFlag)) {
- PES_STREAM_TYPE stream_type = INVALID;
- if (GetStreamType(s.pid, stream_type)) {
- if (IsVC1Video(stream_type)) {
- type = video;
- }
- } else {
- type = video;
- }
- }
- }
-
- // DVB subtitles
- if (type == unknown) {
- Seek(start);
- CMpegSplitterFile::dvbsub h;
- if (!m_streams[video].Find(s) && Read(h, len, &s.mt)) {
- type = subpic;
- }
- }
-
- int iProgram;
- const CHdmvClipInfo::Stream* pClipInfo;
- const program* pProgram = FindProgram(s.pid, iProgram, pClipInfo);
- if ((type == unknown) && (pProgram != nullptr)) {
- PES_STREAM_TYPE StreamType = INVALID;
-
- Seek(start);
- StreamType = pProgram->streams[iProgram].type;
-
- switch (StreamType) {
- case AUDIO_STREAM_LPCM: {
- CMpegSplitterFile::hdmvlpcmhdr h;
- if (!m_streams[audio].Find(s) && Read(h, &s.mt)) {
- type = audio;
- }
- }
- break;
- case PRESENTATION_GRAPHICS_STREAM: {
- CMpegSplitterFile::hdmvsubhdr h;
- if (!m_streams[subpic].Find(s) && Read(h, &s.mt, pClipInfo ? pClipInfo->m_LanguageCode : nullptr)) {
- m_bIsHdmv = true;
- type = subpic;
- }
- }
- break;
- }
- }
- } else if ((m_AC3CoreOnly != 1) && m_init) {
- int iProgram;
- const CHdmvClipInfo::Stream* pClipInfo;
- const program* pProgram = FindProgram(s.pid, iProgram, pClipInfo);
- if ((type == unknown) && (pProgram != nullptr) && AUDIO_STREAM_AC3_TRUE_HD == pProgram->streams[iProgram].type) {
- const stream* source = m_streams[audio].FindStream(s.pid);
- if (source && source->mt.subtype == MEDIASUBTYPE_DOLBY_AC3) {
- CMpegSplitterFile::ac3hdr h;
- if (Read(h, len, &s.mt, false, (m_AC3CoreOnly == 1)) && s.mt.subtype == MEDIASUBTYPE_DOLBY_TRUEHD) {
- m_streams[audio].Replace((stream&)*source, s, this);
- }
- }
- }
- }
- } else if (pesid == 0xfd) {
- CMpegSplitterFile::vc1hdr h;
- if (!m_streams[video].Find(s) && Read(h, len, &s.mt, m_nVC1_GuidFlag)) {
- type = video;
- }
- } else {
- BYTE b = (BYTE)BitRead(8, true);
- WORD w = (WORD)BitRead(16, true);
- DWORD dw = (DWORD)BitRead(32, true);
-
- if (b >= 0x80 && b < 0x88 || w == 0x0b77) { // ac3
- s.ps1id = (b >= 0x80 && b < 0x88) ? (BYTE)(BitRead(32) >> 24) : 0x80;
-
- CMpegSplitterFile::ac3hdr h;
- if (!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
- type = audio;
- }
- } else if (b >= 0x88 && b < 0x90 || dw == 0x7ffe8001) { // dts
- s.ps1id = (b >= 0x88 && b < 0x90) ? (BYTE)(BitRead(32) >> 24) : 0x88;
-
- CMpegSplitterFile::dtshdr h;
- if (!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
- type = audio;
- }
- } else if (b >= 0xa0 && b < 0xa8) { // lpcm
- s.ps1id = (BYTE)BitRead(8);
-
- do {
- // DVD-Audio LPCM
- if (b == 0xa0) {
- BitRead(8); // Continuity Counter - counts from 0x00 to 0x1f and then wraps to 0x00.
- DWORD headersize = (DWORD)BitRead(16); // LPCM_header_length
- if (headersize >= 8 && headersize + 4 < len) {
- CMpegSplitterFile::dvdalpcmhdr h;
- if (Read(h, len - 4, &s.mt)) {
- Seek(start + 4 + headersize);
- type = audio;
- break;
- }
- }
- }
- // DVD-Audio MLP
- else if (b == 0xa1 && len > 10) {
- BYTE counter = (BYTE)BitRead(8); // Continuity Counter: 0x00..0x1f or 0x20..0x3f or 0x40..0x5f
- BitRead(8); // some unknown data
- DWORD headersize = (DWORD)BitRead(8); // MLP_header_length (always equal 6?)
- BitRead(32); // some unknown data
- WORD unknown1 = (WORD)BitRead(16); // 0x0000 or 0x0400
- if (counter <= 0x5f && headersize == 6 && (unknown1 == 0x0000 || unknown1 == 0x0400)) { // Maybe it's MLP?
- // MLP header may be missing in the first package
- CMpegSplitterFile::mlphdr h;
- if (!m_streams[audio].Find(s) && Read(h, len - 10, &s.mt, true)) {
- // This is exactly the MLP.
- Seek(start + 10);
- type = audio;
- }
- Seek(start + 10);
- break;
- }
- }
-
- // DVD LPCM
- if (m_streams[audio].Find(s)) {
- Seek(start + 7);
- } else {
- Seek(start + 4);
- CMpegSplitterFile::lpcmhdr h;
- if (Read(h, &s.mt)) {
- type = audio;
- }
- }
- } while (false);
- } else if (b >= 0x20 && b < 0x40) { // DVD subpic
- s.ps1id = (BYTE)BitRead(8);
-
- CMpegSplitterFile::dvdspuhdr h;
- if (!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
- type = subpic;
- }
- } else if (b >= 0x70 && b < 0x80) { // SVCD subpic
- s.ps1id = (BYTE)BitRead(8);
-
- CMpegSplitterFile::svcdspuhdr h;
- if (!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
- type = subpic;
- }
- } else if (b >= 0x00 && b < 0x10) { // CVD subpic
- s.ps1id = (BYTE)BitRead(8);
-
- CMpegSplitterFile::cvdspuhdr h;
- if (!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
- type = subpic;
- }
- } else if (w == 0xffa0 || w == 0xffa1) { // ps2-mpg audio
- s.ps1id = (BYTE)BitRead(8);
- s.pid = (WORD)((BitRead(8) << 8) | BitRead(16)); // pid = 0xa000 | track id
-
- CMpegSplitterFile::ps2audhdr h;
- if (!m_streams[audio].Find(s) && Read(h, &s.mt)) {
- type = audio;
- }
- } else if (w == 0xff90) { // ps2-mpg ac3 or subtitles
- s.ps1id = (BYTE)BitRead(8);
- s.pid = (WORD)((BitRead(8) << 8) | BitRead(16)); // pid = 0x9000 | track id
-
- w = (WORD)BitRead(16, true);
-
- if (w == 0x0b77) {
- CMpegSplitterFile::ac3hdr h;
- if (!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
- type = audio;
- }
- } else if (w == 0x0000) { // usually zero...
- CMpegSplitterFile::ps2subhdr h;
- if (!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
- type = subpic;
- }
- }
- } else if (b >= 0xc0 && b < 0xcf) { // dolby digital/dolby digital +
- s.ps1id = (BYTE)BitRead(8);
- // skip audio header - 3-byte
- BitRead(8);
- BitRead(8);
- BitRead(8);
- CMpegSplitterFile::ac3hdr h;
- if (!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
- type = audio;
- }
- } else if (b >= 0xb0 && b < 0xbf) { // truehd
- s.ps1id = (BYTE)BitRead(8);
- // skip audio header - 3-byte
- BitRead(8);
- BitRead(8);
- BitRead(8);
- // TrueHD audio has a 4-byte header
- BitRead(8);
- CMpegSplitterFile::ac3hdr h;
- if (!m_streams[audio].Find(s) && Read(h, len, &s.mt, false, false)) {
- type = audio;
- }
- }
- }
- } else if (pesid == 0xbe) { // padding
- } else if (pesid == 0xbf) { // private stream 2
- }
-
- if (type != unknown && !m_streams[type].Find(s)) {
- if (s.pid) {
- for (int i = 0; i < unknown; i++) {
- if (m_streams[i].Find(s)) {
- return s;
- }
- }
- }
-
- m_streams[type].Insert(s, this);
- }
-
- return s;
-}
-
-void CMpegSplitterFile::AddHdmvPGStream(WORD pid, const char* language_code)
-{
- stream s;
-
- s.pid = pid;
- s.pesid = 0xbd;
-
- CMpegSplitterFile::hdmvsubhdr h;
- if (!m_streams[subpic].Find(s) && Read(h, &s.mt, language_code)) {
- m_streams[subpic].Insert(s, this);
- }
-}
-
-CAtlList<CMpegSplitterFile::stream>* CMpegSplitterFile::GetMasterStream()
-{
- return
- !m_streams[video].IsEmpty() ? &m_streams[video] :
- !m_streams[audio].IsEmpty() ? &m_streams[audio] :
- !m_streams[subpic].IsEmpty() ? &m_streams[subpic] :
-#if defined(MVC_SUPPORT)
- !m_streams[stereo].IsEmpty() ? &m_streams[stereo] :
-#endif
- nullptr;
-}
-
-void CMpegSplitterFile::UpdatePrograms(const tshdr& h, bool UpdateLang)
-{
- CAutoLock cAutoLock(&m_csProps);
-
- if (h.payload && h.payloadstart && h.pid == 0) {
- trsechdr h2;
- if (Read(h2) && h2.table_id == 0) {
- CAtlMap<WORD, bool> newprograms;
-
- int len = h2.section_length;
- len -= 5 + 4;
-
- for (int i = len / 4; i > 0; i--) {
- WORD program_number = (WORD)BitRead(16);
- BYTE reserved = (BYTE)BitRead(3);
- WORD pid = (WORD)BitRead(13);
- UNREFERENCED_PARAMETER(reserved);
- if (program_number != 0) {
- m_programs[pid].program_number = program_number;
- newprograms[program_number] = true;
- }
- }
-
- POSITION pos = m_programs.GetStartPosition();
- while (pos) {
- const CAtlMap<WORD, program>::CPair* pPair = m_programs.GetNext(pos);
-
- if (!newprograms.Lookup(pPair->m_value.program_number)) {
- m_programs.RemoveKey(pPair->m_key);
- }
- }
- }
- } else if (CAtlMap<WORD, program>::CPair* pPair = m_programs.Lookup(h.pid)) {
- if (h.payload && h.payloadstart) {
- trsechdr h2;
- if (Read(h2) && h2.table_id == 2) {
- int len = h2.section_length;
- len -= 5 + 4;
-
- BYTE buffer[1024];
- ByteRead(buffer, len);
-
- int max_len = h.bytes - 9;
-
- if (len > max_len) {
- ZeroMemory(pPair->m_value.ts_buffer, sizeof(pPair->m_value.ts_buffer));
- pPair->m_value.ts_len_cur = max_len;
- pPair->m_value.ts_len_packet = len;
- memcpy(pPair->m_value.ts_buffer, buffer, max_len);
- } else {
- CGolombBuffer gb(buffer, len);
- UpdatePrograms(gb, h.pid, UpdateLang);
- }
- }
- } else {
- if (pPair->m_value.ts_len_cur > 0) {
- int len = pPair->m_value.ts_len_packet - pPair->m_value.ts_len_cur;
- if (len > h.bytes) {
- ByteRead(pPair->m_value.ts_buffer + pPair->m_value.ts_len_cur, h.bytes);
- pPair->m_value.ts_len_cur += h.bytes;
- } else {
- ByteRead(pPair->m_value.ts_buffer + pPair->m_value.ts_len_cur, pPair->m_value.ts_len_packet - pPair->m_value.ts_len_cur);
- CGolombBuffer gb(pPair->m_value.ts_buffer, pPair->m_value.ts_len_packet);
- UpdatePrograms(gb, h.pid, UpdateLang);
- }
- }
- }
- }
-}
-
-void CMpegSplitterFile::UpdatePrograms(CGolombBuffer gb, WORD pid, bool UpdateLang)
-{
- if (CAtlMap<WORD, program>::CPair* pPair = m_programs.Lookup(pid)) {
- ZeroMemory(pPair->m_value.streams, sizeof(pPair->m_value.streams));
-
- int len = gb.GetSize();
-
- BYTE reserved1 = (BYTE)gb.BitRead(3);
- WORD PCR_PID = (WORD)gb.BitRead(13);
- BYTE reserved2 = (BYTE)gb.BitRead(4);
- WORD program_info_length = (WORD)gb.BitRead(12);
- UNREFERENCED_PARAMETER(reserved1);
- UNREFERENCED_PARAMETER(PCR_PID);
- UNREFERENCED_PARAMETER(reserved2);
-
- len -= (4 + program_info_length);
- if (len <= 0) {
- return;
- }
-
- while (program_info_length-- > 0) {
- gb.BitRead(8);
- }
-
- for (int i = 0; i < _countof(pPair->m_value.streams) && len >= 5; i++) {
- BYTE stream_type = (BYTE)gb.BitRead(8);
- BYTE nreserved1 = (BYTE)gb.BitRead(3);
- WORD pid = (WORD)gb.BitRead(13);
- BYTE nreserved2 = (BYTE)gb.BitRead(4);
- WORD ES_info_length = (WORD)gb.BitRead(12);
- UNREFERENCED_PARAMETER(nreserved1);
- UNREFERENCED_PARAMETER(nreserved2);
-
- pPair->m_value.streams[i].pid = pid;
- pPair->m_value.streams[i].type = (PES_STREAM_TYPE)stream_type;
-
- if (m_ForcedSub) {
- if (stream_type == PRESENTATION_GRAPHICS_STREAM) {
- stream s;
- s.pid = pid;
- CMpegSplitterFile::hdmvsubhdr hdr;
- if (Read(hdr, &s.mt, nullptr)) {
- if (!m_streams[subpic].Find(s)) {
- m_streams[subpic].Insert(s, this);
- }
- }
- }
- }
-
- len -= (5 + ES_info_length);
- if (len < 0) {
- break;
- }
- if (ES_info_length <= 2) {
- continue;
- }
-
- if (UpdateLang) {
- int info_length = ES_info_length;
- for (;;) {
- BYTE descriptor_tag = (BYTE)gb.BitRead(8);
- BYTE descriptor_length = (BYTE)gb.BitRead(8);
- info_length -= (2 + descriptor_length);
- if (info_length < 0) {
- break;
- }
- char ch[4];
- switch (descriptor_tag) {
- case 0x0a: // ISO 639 language descriptor
- case 0x56: // Teletext descriptor
- case 0x59: // Subtitling descriptor
- gb.ReadBuffer((BYTE*)ch, 3);
- ch[3] = 0;
- for (int j = 3; j < descriptor_length; j++) {
- gb.BitRead(8);
- }
- if (!(ch[0] == 'u' && ch[1] == 'n' && ch[2] == 'd')) {
- m_pPMT_Lang[pid] = ISO6392ToLanguage(ch);
- }
- break;
- default:
- for (int j = 0; j < descriptor_length; j++) {
- gb.BitRead(8);
- }
- break;
- }
- if (info_length <= 2) {
- break;
- }
- }
- } else {
- while (ES_info_length-- > 0) {
- gb.BitRead(8);
- }
- }
- }
- pPair->m_value.ts_len_cur = 0;
- pPair->m_value.ts_len_packet = 0;
- }
-}
-
-UINT32 SwapLE(const UINT32& _Value)
-{
- return (_Value & 0xFF) << 24 | ((_Value >> 8) & 0xFF) << 16 | ((_Value >> 16) & 0xFF) << 8 | ((_Value >> 24) & 0xFF) << 0;
-}
-
-UINT16 SwapLE(const UINT16& _Value)
-{
- return (_Value & 0xFF) << 8 | ((_Value >> 8) & 0xFF) << 0;
-}
-
-const CMpegSplitterFile::program* CMpegSplitterFile::FindProgram(WORD pid, int& iStream, const CHdmvClipInfo::Stream*& _pClipInfo)
-{
- _pClipInfo = m_ClipInfo.FindStream(pid);
-
- iStream = -1;
-
- POSITION pos = m_programs.GetStartPosition();
-
- while (pos) {
- program* p = &m_programs.GetNextValue(pos);
-
- for (int i = 0; i < _countof(p->streams); i++) {
- if (p->streams[i].pid == pid) {
- iStream = i;
- return p;
- }
- }
- }
-
- return nullptr;
-}
-
-bool CMpegSplitterFile::GetStreamType(WORD pid, PES_STREAM_TYPE& stream_type)
-{
- int iProgram;
- const CHdmvClipInfo::Stream* pClipInfo;
- const program* pProgram = FindProgram(pid, iProgram, pClipInfo);
- if (pProgram) {
- stream_type = pProgram->streams[iProgram].type;
-
- if (stream_type != INVALID) {
- return true;
- }
- }
-
- return false;
-}
diff --git a/src/filters/parser/MpegSplitter/MpegSplitterFile.h b/src/filters/parser/MpegSplitter/MpegSplitterFile.h
deleted file mode 100644
index 38a7c813e..000000000
--- a/src/filters/parser/MpegSplitter/MpegSplitterFile.h
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <atlbase.h>
-#include <atlcoll.h>
-#include "../BaseSplitter/BaseSplitter.h"
-#include "../../../DSUtil/GolombBuffer.h"
-
-#define NO_SUBTITLE_PID 1 // Fake PID use for the "No subtitle" entry
-#define NO_SUBTITLE_NAME _T("No subtitle")
-
-#define ISVALIDPID(pid) (pid >= 0x10 && pid < 0x1fff)
-
-//#define MVC_SUPPORT
-
-class CMpegSplitterFile : public CBaseSplitterFileEx
-{
- CAtlMap<WORD, BYTE> m_pid2pes;
- CAtlMap<WORD, CMpegSplitterFile::avchdr> avch;
- bool m_bIsHdmv;
- bool m_init;
-
- HRESULT Init(IAsyncReader* pAsyncReader);
-
- void OnComplete(IAsyncReader* pAsyncReader);
-
-public:
- CHdmvClipInfo& m_ClipInfo;
- CMpegSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr, bool bIsHdmv,
- CHdmvClipInfo& ClipInfo, int guid_flag, bool ForcedSub,
- int AC3CoreOnly, bool m_AlternativeDuration);
-
- REFERENCE_TIME NextPTS(DWORD TrackNum);
-
- CCritSec m_csProps;
-
- MPEG_TYPES m_type;
-
- REFERENCE_TIME m_rtMin, m_rtMax;
- __int64 m_posMin, m_posMax;
- REFERENCE_TIME m_rtPrec;
- bool m_bPTSWrap;
- int m_rate; // byte/sec
-
- int m_nVC1_GuidFlag, m_AC3CoreOnly;
- bool m_ForcedSub, m_AlternativeDuration;
-
- struct stream {
- CMpegSplitterFile* m_pFile;
- CMediaType mt;
- WORD pid;
- BYTE pesid, ps1id;
- struct stream()
- : m_pFile(0) {
- pid = pesid = ps1id = 0;
- }
- operator DWORD() const {
- return pid ? pid : ((pesid << 8) | ps1id);
- }
- bool operator == (const struct stream& s) const {
- return (DWORD) * this == (DWORD)s;
- }
- };
-
- enum {
- video,
- audio,
- subpic,
-#if defined(MVC_SUPPORT)
- stereo,
-#endif
- unknown
- };
-
- class CStreamList : public CAtlList<stream>
- {
- public:
- void Insert(stream& s, CMpegSplitterFile* _pFile) {
- s.m_pFile = _pFile;
- AddTail(s);
- if (GetCount() > 1) {
- for (size_t j = 0; j < GetCount(); j++) {
- for (size_t i = 0; i < GetCount() - 1; i++) {
- if (GetAt(FindIndex(i)) > GetAt(FindIndex(i + 1))) {
- SwapElements(FindIndex(i), FindIndex(i + 1));
- }
- }
- }
- }
- }
-
- void Replace(stream& source, stream& dest, CMpegSplitterFile* _pFile) {
- source.m_pFile = _pFile;
- dest.m_pFile = _pFile;
- for (POSITION pos = GetHeadPosition(); pos; GetNext(pos)) {
- stream& s = GetAt(pos);
- if (source == s) {
- SetAt(pos, dest);
- return;
- }
- }
- }
-
- static CStringW ToString(int type) {
- return
- type == video ? L"Video" :
- type == audio ? L"Audio" :
- type == subpic ? L"Subtitle" :
-#if defined(MVC_SUPPORT)
- type == stereo ? L"Stereo" :
-#endif
- L"Unknown";
- }
-
- const stream* FindStream(int pid) {
- for (POSITION pos = GetHeadPosition(); pos; GetNext(pos)) {
- const stream& s = GetAt(pos);
- if (s.pid == pid) {
- return &s;
- }
- }
-
- return nullptr;
- }
-
- } m_streams[unknown];
-
- HRESULT SearchStreams(__int64 start, __int64 stop, IAsyncReader* pAsyncReader, BOOL CalcDuration = FALSE);
- DWORD AddStream(WORD pid, BYTE pesid, BYTE ps1id, DWORD len);
- void AddHdmvPGStream(WORD pid, const char* language_code);
- CAtlList<stream>* GetMasterStream();
- bool IsHdmv() { return m_bIsHdmv; };
-
- struct program {
- WORD program_number;
- struct stream {
- WORD pid;
- PES_STREAM_TYPE type;
-
- };
- stream streams[64];
- struct program() {
- ZeroMemory(this, sizeof(*this));
- }
-
- BYTE ts_buffer[1024];
- WORD ts_len_cur, ts_len_packet;
- };
-
- CAtlMap<WORD, program> m_programs;
-
- void SearchPrograms(__int64 start, __int64 stop);
- void UpdatePrograms(const tshdr& h, bool UpdateLang = true);
- void UpdatePrograms(CGolombBuffer gb, WORD pid, bool UpdateLang = true);
- const program* FindProgram(WORD pid, int& iStream, const CHdmvClipInfo::Stream*& _pClipInfo);
-
- CAtlMap<DWORD, CString> m_pPMT_Lang;
-
- bool GetStreamType(WORD pid, PES_STREAM_TYPE& stream_type);
-};
diff --git a/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.cpp b/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.cpp
deleted file mode 100644
index dbdd7c0b9..000000000
--- a/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.cpp
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "MpegSplitterSettingsWnd.h"
-#include "../../../DSUtil/DSUtil.h"
-#include "resource.h"
-#include "../../../mpc-hc/InternalFiltersConfig.h"
-
-
-CMpegSplitterSettingsWnd::CMpegSplitterSettingsWnd()
-{
-}
-
-bool CMpegSplitterSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
-{
- ASSERT(!m_pMSF);
-
- m_pMSF.Release();
-
- POSITION pos = pUnks.GetHeadPosition();
- while (pos && !(m_pMSF = pUnks.GetNext(pos))) {
- ;
- }
-
- if (!m_pMSF) {
- return false;
- }
-
- return true;
-}
-
-void CMpegSplitterSettingsWnd::OnDisconnect()
-{
- m_pMSF.Release();
-}
-
-bool CMpegSplitterSettingsWnd::OnActivate()
-{
- ASSERT(IPP_FONTSIZE == 13);
- const int h20 = IPP_SCALE(20);
- const int h25 = IPP_SCALE(25);
- const int h30 = IPP_SCALE(30);
- DWORD dwStyle = WS_VISIBLE | WS_CHILD | WS_TABSTOP;
- CPoint p(10, 10);
-
- m_cbFastStreamChange.Create(ResStr(IDS_MPEGSPLITTER_FSTREAM_CHANGE), dwStyle | BS_AUTOCHECKBOX | BS_LEFTTEXT, CRect(p, CSize(IPP_SCALE(305), m_fontheight)), this, IDC_PP_FAST_STREAM_SELECT);
- p.y += h20;
-
- m_cbForcedSub.Create(ResStr(IDS_MPEGSPLITTER_SUB_FORCING), dwStyle | BS_AUTOCHECKBOX | BS_LEFTTEXT, CRect(p, CSize(IPP_SCALE(305), m_fontheight)), this, IDC_PP_SUBTITLE_FORCED);
- p.y += h20;
-
- m_cbAlternativeDuration.Create(ResStr(IDS_MPEGSPLITTER_ALT_DUR_CALC), dwStyle | BS_AUTOCHECKBOX | BS_LEFTTEXT, CRect(p, CSize(IPP_SCALE(305), m_fontheight)), this, IDC_PP_ALTERNATIVE_DURATION);
- p.y += h20;
-
- m_txtAudioLanguageOrder.Create(ResStr(IDS_MPEGSPLITTER_LANG_ORDER), WS_VISIBLE | WS_CHILD, CRect(p, CSize(IPP_SCALE(200), m_fontheight)), this, (UINT)IDC_STATIC);
- p.y += h20;
- m_edtAudioLanguageOrder.CreateEx(WS_EX_CLIENTEDGE, _T("EDIT"), _T(""), WS_CHILD | WS_VISIBLE | WS_TABSTOP, CRect(p, CSize(IPP_SCALE(305), m_fontheight + 6)), this, IDC_PP_AUDIO_LANGUAGE_ORDER);
- p.y += h25;
-
- m_txtSubtitlesLanguageOrder.Create(ResStr(IDS_MPEGSPLITTER_SUB_ORDER), WS_VISIBLE | WS_CHILD, CRect(p, CSize(IPP_SCALE(200), m_fontheight)), this, (UINT)IDC_STATIC);
- p.y += h20;
- m_edtSubtitlesLanguageOrder.CreateEx(WS_EX_CLIENTEDGE, _T("EDIT"), _T(""), WS_CHILD | WS_VISIBLE | WS_TABSTOP, CRect(p, CSize(IPP_SCALE(305), m_fontheight + 6)), this, IDC_PP_SUBTITLES_LANGUAGE_ORDER);
- p.y += h25;
-
- m_txtVC1_GuidFlag.Create(ResStr(IDS_MPEGSPLITTER_VC1_GUIDFLAG), WS_VISIBLE | WS_CHILD, CRect(p, CSize(IPP_SCALE(200), m_fontheight)), this, (UINT)IDC_STATIC);
- p.y += h20;
- m_cbVC1_GuidFlag.Create(dwStyle | CBS_DROPDOWNLIST | WS_VSCROLL, CRect(p, CSize(IPP_SCALE(305), 200)), this, IDC_PP_VC1_GUIDFLAG);
- m_cbVC1_GuidFlag.AddString(_T("Default"));
- m_cbVC1_GuidFlag.AddString(_T("Cyberlink VC-1 Decoder"));
- m_cbVC1_GuidFlag.AddString(_T("ArcSoft VC-1 Decoder"));
- SetClassLongPtr(GetDlgItem(IDC_PP_VC1_GUIDFLAG)->m_hWnd, GCLP_HCURSOR, (LONG_PTR)AfxGetApp()->LoadStandardCursor(IDC_HAND));
- p.y += h30;
-
- m_grpTrueHD.Create(ResStr(IDS_MPEGSPLITTER_TRUEHD_OUTPUT), WS_VISIBLE | WS_CHILD | BS_GROUPBOX, CRect(p + CPoint(-5, 0), CSize(IPP_SCALE(305), h20 + h20)), this, (UINT)IDC_STATIC);
- p.y += h20;
- m_cbTrueHD.Create(_T("TrueHD"), dwStyle | BS_AUTORADIOBUTTON | BS_TOP | BS_MULTILINE | WS_GROUP, CRect(p, CSize(IPP_SCALE(60), m_fontheight + 2)), this, IDC_PP_TRUEHD);
- m_cbAC3Core.Create(_T("AC-3"), dwStyle | BS_AUTORADIOBUTTON | BS_TOP | BS_MULTILINE, CRect(p + CPoint(IPP_SCALE(100), 0), CSize(IPP_SCALE(60), m_fontheight + 2)), this, IDC_PP_AC3CORE);
- m_cbAsIs.Create(ResStr(IDS_MPEGSPLITTER_THD_NOSPLIT), dwStyle | BS_AUTORADIOBUTTON | BS_TOP | BS_MULTILINE, CRect(p + CPoint(IPP_SCALE(200), 0), CSize(IPP_SCALE(95), m_fontheight + 2)), this, IDC_PP_ASIS);
-
- if (m_pMSF) {
- m_cbFastStreamChange.SetCheck(m_pMSF->GetFastStreamChange());
- m_cbForcedSub.SetCheck(m_pMSF->GetForcedSub());
- m_edtAudioLanguageOrder.SetWindowText(m_pMSF->GetAudioLanguageOrder());
- m_edtSubtitlesLanguageOrder.SetWindowText(m_pMSF->GetSubtitlesLanguageOrder());
- m_cbVC1_GuidFlag.SetCurSel(m_pMSF->GetVC1_GuidFlag() - 1);
- m_cbTrueHD.SetCheck(m_pMSF->GetTrueHD() == 0);
- m_cbAC3Core.SetCheck(m_pMSF->GetTrueHD() == 1);
- m_cbAsIs.SetCheck(!m_cbTrueHD.GetCheck() && !m_cbAC3Core.GetCheck());
- m_cbAlternativeDuration.SetCheck(m_pMSF->GetAlternativeDuration());
- }
-
-#ifndef STANDALONE_FILTER
- m_edtAudioLanguageOrder.EnableWindow(FALSE);
- m_edtSubtitlesLanguageOrder.EnableWindow(FALSE);
-#endif
-
-
- for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
- pWnd->SetFont(&m_font, FALSE);
- }
-
- return true;
-}
-
-void CMpegSplitterSettingsWnd::OnDeactivate()
-{
-}
-
-bool CMpegSplitterSettingsWnd::OnApply()
-{
- OnDeactivate();
-
- if (m_pMSF) {
- m_pMSF->SetFastStreamChange(m_cbFastStreamChange.GetCheck());
- m_pMSF->SetForcedSub(m_cbForcedSub.GetCheck());
- m_pMSF->SetVC1_GuidFlag(m_cbVC1_GuidFlag.GetCurSel() + 1);
- m_pMSF->SetTrueHD(m_cbTrueHD.GetCheck() ? 0 : m_cbAC3Core.GetCheck() ? 1 : 2);
- m_pMSF->SetAlternativeDuration(m_cbAlternativeDuration.GetCheck());
-
-#ifdef STANDALONE_FILTER
- CString str = _T("");
- m_edtAudioLanguageOrder.GetWindowText(str);
- m_pMSF->SetAudioLanguageOrder(str.GetBuffer());
- m_edtSubtitlesLanguageOrder.GetWindowText(str);
- m_pMSF->SetSubtitlesLanguageOrder(str.GetBuffer());
-#endif
- m_pMSF->Apply();
- }
-
- return true;
-}
-
-BEGIN_MESSAGE_MAP(CMpegSplitterSettingsWnd, CInternalPropertyPageWnd)
-END_MESSAGE_MAP()
diff --git a/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.h b/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.h
deleted file mode 100644
index cff9f9479..000000000
--- a/src/filters/parser/MpegSplitter/MpegSplitterSettingsWnd.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../InternalPropertyPage.h"
-#include "IMpegSplitterFilter.h"
-#include "resource.h"
-#include <afxcmn.h>
-
-class __declspec(uuid("44FCB62D-3AEB-401C-A7E1-8A984C017923"))
- CMpegSplitterSettingsWnd : public CInternalPropertyPageWnd
-{
-private:
- CComQIPtr<IMpegSplitterFilter> m_pMSF;
-
- CButton m_cbFastStreamChange;
- CButton m_cbForcedSub;
- CButton m_cbAlternativeDuration;
- CStatic m_txtAudioLanguageOrder;
- CEdit m_edtAudioLanguageOrder;
- CStatic m_txtSubtitlesLanguageOrder;
- CEdit m_edtSubtitlesLanguageOrder;
- CStatic m_txtVC1_GuidFlag;
- CComboBox m_cbVC1_GuidFlag;
-
- CButton m_grpTrueHD;
- CButton m_cbTrueHD;
- CButton m_cbAC3Core;
- CButton m_cbAsIs;
-
- enum {
- IDC_PP_FAST_STREAM_SELECT = 10000,
- IDC_PP_SUBTITLE_FORCED,
- IDC_PP_AUDIO_LANGUAGE_ORDER,
- IDC_PP_SUBTITLES_LANGUAGE_ORDER,
- IDC_PP_VC1_GUIDFLAG,
- IDC_PP_TRUEHD,
- IDC_PP_AC3CORE,
- IDC_PP_ASIS,
- IDC_PP_ALTERNATIVE_DURATION
- };
-
-public:
- CMpegSplitterSettingsWnd();
-
- bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
- void OnDisconnect();
- bool OnActivate();
- void OnDeactivate();
- bool OnApply();
-
- static LPCTSTR GetWindowTitle() { return MAKEINTRESOURCE(IDS_FILTER_SETTINGS_CAPTION); }
- static CSize GetWindowSize() { return CSize(320, 260); }
-
- DECLARE_MESSAGE_MAP()
-};
diff --git a/src/filters/parser/MpegSplitter/resource.h b/src/filters/parser/MpegSplitter/resource.h
deleted file mode 100644
index cbb3855c0..000000000
--- a/src/filters/parser/MpegSplitter/resource.h
+++ /dev/null
@@ -1,24 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by MpegSplitter.rc
-//
-#define IDS_FILTER_SETTINGS_CAPTION 7000
-#define IDS_MPEGSPLITTER_FSTREAM_CHANGE 7200
-#define IDS_MPEGSPLITTER_SUB_FORCING 7201
-#define IDS_MPEGSPLITTER_ALT_DUR_CALC 7202
-#define IDS_MPEGSPLITTER_LANG_ORDER 7203
-#define IDS_MPEGSPLITTER_SUB_ORDER 7205
-#define IDS_MPEGSPLITTER_VC1_GUIDFLAG 7206
-#define IDS_MPEGSPLITTER_TRUEHD_OUTPUT 7207
-#define IDS_MPEGSPLITTER_THD_NOSPLIT 7208
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 101
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/filters/parser/MpegSplitter/stdafx.cpp b/src/filters/parser/MpegSplitter/stdafx.cpp
deleted file mode 100644
index 784f2cebc..000000000
--- a/src/filters/parser/MpegSplitter/stdafx.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
diff --git a/src/filters/parser/MpegSplitter/stdafx.h b/src/filters/parser/MpegSplitter/stdafx.h
deleted file mode 100644
index 5b6b09e05..000000000
--- a/src/filters/parser/MpegSplitter/stdafx.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../../DSUtil/SharedInclude.h"
-#include "../../../../include/stdafx_common.h"
-#include "../../../../include/stdafx_common_afx.h"
-#include "../../../../include/stdafx_common_dshow.h"
diff --git a/src/filters/parser/OggSplitter/OggFile.cpp b/src/filters/parser/OggSplitter/OggFile.cpp
deleted file mode 100644
index eebab48a1..000000000
--- a/src/filters/parser/OggSplitter/OggFile.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "OggFile.h"
-
-COggFile::COggFile(IAsyncReader* pAsyncReader, HRESULT& hr)
- : CBaseSplitterFile(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false)
-{
- if (FAILED(hr)) {
- return;
- }
- hr = Init();
-}
-
-HRESULT COggFile::Init()
-{
- Seek(0);
- if (!Sync()) {
- return E_FAIL;
- }
-
- return S_OK;
-}
-
-bool COggFile::Sync(HANDLE hBreak)
-{
- __int64 start = GetPos();
-
- DWORD dw;
- for (__int64 i = 0, j = hBreak ? GetLength() - start : MAX_PROBE_SIZE;
- i < j && S_OK == ByteRead((BYTE*)&dw, sizeof(dw))
- && ((i & 0xffff) || !hBreak || WaitForSingleObject(hBreak, 0) != WAIT_OBJECT_0);
- i++, Seek(start + i)) {
- if (dw == 'SggO') {
- Seek(start + i);
- return true;
- }
- }
-
- Seek(start);
-
- return false;
-}
-
-bool COggFile::Read(OggPageHeader& hdr, HANDLE hBreak)
-{
- return Sync(hBreak) && S_OK == ByteRead((BYTE*)&hdr, sizeof(hdr)) && hdr.capture_pattern == 'SggO';
-}
-
-bool COggFile::Read(OggPage& page, bool fFull, HANDLE hBreak)
-{
- ZeroMemory(&page.m_hdr, sizeof(page.m_hdr));
- page.m_lens.RemoveAll();
- page.SetCount(0);
-
- if (!Read(page.m_hdr, hBreak)) {
- return false;
- }
-
- int pagelen = 0, packetlen = 0;
- for (BYTE i = 0; i < page.m_hdr.number_page_segments; i++) {
- BYTE b;
- if (S_OK != ByteRead(&b, 1)) {
- return false;
- }
- packetlen += b;
- if (1/*b < 0xff*/) {
- page.m_lens.AddTail(packetlen);
- pagelen += packetlen;
- packetlen = 0;
- }
- }
-
- if (fFull) {
- page.SetCount(pagelen);
- if (S_OK != ByteRead(page.GetData(), page.GetCount())) {
- return false;
- }
- } else {
- Seek(GetPos() + pagelen);
- page.m_lens.RemoveAll();
- }
-
- return true;
-}
diff --git a/src/filters/parser/OggSplitter/OggFile.h b/src/filters/parser/OggSplitter/OggFile.h
deleted file mode 100644
index 4c7cff2c4..000000000
--- a/src/filters/parser/OggSplitter/OggFile.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../BaseSplitter/BaseSplitter.h"
-
-#pragma pack(push, 1)
-
-struct OggPageHeader {
- DWORD capture_pattern;
- BYTE stream_structure_version;
- BYTE header_type_flag;
- enum { continued = 1, first = 2, last = 4 };
- __int64 granule_position;
- DWORD bitstream_serial_number;
- DWORD page_sequence_number;
- DWORD CRC_checksum;
- BYTE number_page_segments;
-};
-
-struct OggVorbisIdHeader {
- DWORD vorbis_version;
- BYTE audio_channels;
- DWORD audio_sample_rate;
- DWORD bitrate_maximum;
- DWORD bitrate_nominal;
- DWORD bitrate_minimum;
- BYTE blocksize_0: 4;
- BYTE blocksize_1: 4;
- BYTE framing_flag;
-};
-
-struct OggVideoHeader {
- DWORD w, h;
-};
-
-struct OggAudioHeader {
- WORD nChannels, nBlockAlign;
- DWORD nAvgBytesPerSec;
-};
-
-struct OggStreamHeader {
- char streamtype[8], subtype[4];
- DWORD size;
- __int64 time_unit, samples_per_unit;
- DWORD default_len;
- DWORD buffersize;
- WORD bps;
- WORD alignmentfix1;
- union {
- OggVideoHeader v;
- OggAudioHeader a;
- };
- DWORD alignmentfix2;
-};
-#pragma pack(pop)
-
-class OggPage : public CAtlArray<BYTE>
-{
-public:
- OggPageHeader m_hdr;
- CAtlList<int> m_lens;
- OggPage() {
- ZeroMemory(&m_hdr, sizeof(m_hdr));
- }
-};
-
-class COggFile : public CBaseSplitterFile
-{
- HRESULT Init();
-
-public:
- COggFile(IAsyncReader* pAsyncReader, HRESULT& hr);
-
- bool Sync(HANDLE hBreak = nullptr);
- bool Read(OggPageHeader& hdr, HANDLE hBreak = nullptr);
- bool Read(OggPage& page, bool fFull = true, HANDLE hBreak = nullptr);
-};
diff --git a/src/filters/parser/OggSplitter/OggSplitter.cpp b/src/filters/parser/OggSplitter/OggSplitter.cpp
deleted file mode 100644
index 39ed7ee1b..000000000
--- a/src/filters/parser/OggSplitter/OggSplitter.cpp
+++ /dev/null
@@ -1,1318 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "OggSplitter.h"
-#include "../../../DSUtil/DSUtil.h"
-#include "../../../DSUtil/GolombBuffer.h"
-
-#ifdef STANDALONE_FILTER
-#include <InitGuid.h>
-#endif
-#include "moreuuids.h"
-
-# define TH_VERSION_CHECK(version_major,version_minor,version_subminor,_maj,_min,_sub) \
- (version_major>(_maj)||version_major==(_maj)&& \
- (version_minor>(_min)||version_minor==(_min)&& \
- version_subminor>=(_sub)))
-
-#ifdef STANDALONE_FILTER
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
-};
-
-const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, 0, nullptr}
-};
-
-const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(COggSplitterFilter), OggSplitterName, MERIT_NORMAL + 1, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(COggSourceFilter), OggSourceName, MERIT_NORMAL + 1, 0, nullptr, CLSID_LegacyAmFilterCategory},
-};
-
-CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<COggSplitterFilter>, nullptr, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<COggSourceFilter>, nullptr, &sudFilter[1]},
-};
-
-int g_cTemplates = _countof(g_Templates);
-
-STDAPI DllRegisterServer()
-{
- RegisterSourceFilter(
- CLSID_AsyncReader,
- MEDIASUBTYPE_Ogg,
- _T("0,4,,4F676753"), // OggS
- _T(".ogg"), _T(".ogm"), nullptr);
-
- return AMovieDllRegisterServer2(TRUE);
-}
-
-STDAPI DllUnregisterServer()
-{
- UnRegisterSourceFilter(MEDIASUBTYPE_Ogg);
-
- return AMovieDllRegisterServer2(FALSE);
-}
-
-#include "../../FilterApp.h"
-
-CFilterApp theApp;
-
-#endif
-
-//
-// bitstream
-//
-
-class bitstream
-{
- BYTE* m_p;
- int m_len, m_pos;
-public:
- bitstream(BYTE* p, int len, bool rev = false) : m_p(p), m_len(len * 8) {
- m_pos = !rev ? 0 : len * 8;
- }
- bool hasbits(int cnt) {
- int pos = m_pos + cnt;
- return (pos >= 0 && pos < m_len);
- }
- unsigned int showbits(int cnt) { // a bit unclean, but works and can read backwards too! :P
- if (!hasbits(cnt)) {
- ASSERT(0);
- return 0;
- }
- unsigned int ret = 0, off = 0;
- BYTE* p = m_p;
- if (cnt < 0) {
- p += (m_pos + cnt) >> 3;
- off = (m_pos + cnt) & 7;
- cnt = abs(cnt);
- ret = (*p++ & (~0 << off)) >> off;
- off = 8 - off;
- cnt -= off;
- } else {
- p += m_pos >> 3;
- off = m_pos & 7;
- ret = (*p++ >> off) & ((1 << min(cnt, 8)) - 1);
- off = 0;
- cnt -= 8 - off;
- }
- while (cnt > 0) {
- ret |= (*p++ & ((1 << min(cnt, 8)) - 1)) << off;
- off += 8;
- cnt -= 8;
- }
- return ret;
- }
- unsigned int getbits(int cnt) {
- unsigned int ret = showbits(cnt);
- m_pos += cnt;
- return ret;
- }
-};
-
-//
-// COggSplitterFilter
-//
-
-COggSplitterFilter::COggSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("COggSplitterFilter"), pUnk, phr, __uuidof(this))
-{
-}
-
-COggSplitterFilter::~COggSplitterFilter()
-{
-}
-
-STDMETHODIMP COggSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo)
-{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
-
- if (m_pName && m_pName[0] == L'M' && m_pName[1] == L'P' && m_pName[2] == L'C') {
- (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
- wcscpy_s(pInfo->achName, OggSourceName);
- }
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
-}
-
-HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
-{
- CheckPointer(pAsyncReader, E_POINTER);
-
- HRESULT hr = E_FAIL;
-
- m_pFile.Free();
-
- m_pFile.Attach(DEBUG_NEW COggFile(pAsyncReader, hr));
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = 0;
-
- m_rtDuration = 0;
-
- m_pFile->Seek(0);
- OggPage page;
- for (int i = 0, nWaitForMore = 0; m_pFile->Read(page), i < 100; i++) {
- BYTE* p = page.GetData();
- if (!p) {
- break;
- }
-
- if (!(page.m_hdr.header_type_flag & OggPageHeader::continued)) {
- if (!memcmp(p, "fishead", 7) || !memcmp(p, "fisbone", 7)) {
- continue;
- }
-
- BYTE type = *p++;
-
- CStringW name;
- name.Format(L"Stream %d", i);
-
- HRESULT hr2;
-
- if (type >= 0x80 && type <= 0x82 && !memcmp(p, "theora", 6)) {
- if (type == 0x80) {
- name.Format(L"Theora %d", i);
- CAutoPtr<CBaseSplitterOutputPin> pPinOut;
- pPinOut.Attach(DEBUG_NEW COggTheoraOutputPin(page.GetData(), name, this, this, &hr2));
- AddOutputPin(page.m_hdr.bitstream_serial_number, pPinOut);
- nWaitForMore++;
- }
- } else if (type == 1 && (page.m_hdr.header_type_flag & OggPageHeader::first)) {
- CAutoPtr<CBaseSplitterOutputPin> pPinOut;
-
- if (!memcmp(p, "vorbis", 6)) {
- if ((*(OggVorbisIdHeader*)(p + 6)).audio_sample_rate == 0) {
- return E_FAIL; // fix crash on broken files
- }
- name.Format(L"Vorbis %d", i);
- pPinOut.Attach(DEBUG_NEW COggVorbisOutputPin((OggVorbisIdHeader*)(p + 6), name, this, this, &hr2));
- nWaitForMore++;
- } else if (!memcmp(p, "video", 5)) {
- name.Format(L"Video %d", i);
- pPinOut.Attach(DEBUG_NEW COggVideoOutputPin((OggStreamHeader*)p, name, this, this, &hr2));
- } else if (!memcmp(p, "audio", 5)) {
- name.Format(L"Audio %d", i);
- pPinOut.Attach(DEBUG_NEW COggAudioOutputPin((OggStreamHeader*)p, name, this, this, &hr2));
- } else if (!memcmp(p, "text", 4)) {
- name.Format(L"Text %d", i);
- pPinOut.Attach(DEBUG_NEW COggTextOutputPin((OggStreamHeader*)p, name, this, this, &hr2));
- } else if (!memcmp(p, "Direct Show Samples embedded in Ogg", 35)) {
- name.Format(L"DirectShow %d", i);
- pPinOut.Attach(DEBUG_NEW COggDirectShowOutputPin((AM_MEDIA_TYPE*)(p + 35 + sizeof(GUID)), name, this, this, &hr2));
- }
-
- AddOutputPin(page.m_hdr.bitstream_serial_number, pPinOut);
- } else if (type == 3 && !memcmp(p, "vorbis", 6)) {
- if (COggSplitterOutputPin* pOggPin =
- dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
- pOggPin->AddComment(p + 6, (int)page.GetCount() - 6 - 1);
- }
- } else if (type == 0x7F && page.GetCount() > 12 && *(long*)(p + 8) == 0x43614C66) { // Flac
- // Ogg Flac : method 1
- CAutoPtr<CBaseSplitterOutputPin> pPinOut;
- name.Format(L"FLAC %d", i);
- pPinOut.Attach(DEBUG_NEW COggFlacOutputPin(p + 12, (int)page.GetCount() - 14, name, this, this, &hr2));
- AddOutputPin(page.m_hdr.bitstream_serial_number, pPinOut);
- } else if (*(long*)(p - 1) == 0x43614C66) {
- //bFlac = true;
- //nWaitForMore++;
- if (m_pFile->Read(page)) {
- CAutoPtr<CBaseSplitterOutputPin> pPinOut;
- name.Format(L"FLAC %d", i);
- p = page.GetData();
- pPinOut.Attach(DEBUG_NEW COggFlacOutputPin(p, (int)page.GetCount(), name, this, this, &hr2));
- AddOutputPin(page.m_hdr.bitstream_serial_number, pPinOut);
- }
- } else if (!(type & 1) && nWaitForMore == 0) {
- break;
- }
- }
-
- if (COggTheoraOutputPin* ptr = dynamic_cast<COggTheoraOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
- ptr->UnpackInitPage(page);
- if (ptr->IsInitialized()) {
- nWaitForMore--;
- }
- }
-
- if (COggVorbisOutputPin* ptr = dynamic_cast<COggVorbisOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
- ptr->UnpackInitPage(page);
- if (ptr->IsInitialized()) {
- nWaitForMore--;
- }
- }
- }
-
- if (m_pOutputs.IsEmpty()) {
- return E_FAIL;
- }
-
- if (m_pFile->IsRandomAccess()) {
- m_pFile->Seek(max(m_pFile->GetLength() - MAX_PROBE_SIZE, 0));
-
- OggPage ppage;
- while (m_pFile->Read(ppage)) {
- COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(ppage.m_hdr.bitstream_serial_number));
- if (!pOggPin || ppage.m_hdr.granule_position == -1) {
- continue;
- }
- REFERENCE_TIME rt = pOggPin->GetRefTime(ppage.m_hdr.granule_position);
- m_rtDuration = max(rt, m_rtDuration);
- }
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration;
-
- // comments
-
- {
- CAtlMap<CStringW, CStringW, CStringElementTraits<CStringW>> tagmap;
- tagmap[L"TITLE"] = L"TITL";
- tagmap[L"ARTIST"] = L"AUTH"; // not quite
- tagmap[L"COPYRIGHT"] = L"CPYR";
- tagmap[L"DESCRIPTION"] = L"DESC";
-
- POSITION pos2 = tagmap.GetStartPosition();
- while (pos2) {
- CStringW oggtag, dsmtag;
- tagmap.GetNextAssoc(pos2, oggtag, dsmtag);
-
- POSITION pos = m_pOutputs.GetHeadPosition();
- while (pos) {
- COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>((CBaseOutputPin*)m_pOutputs.GetNext(pos));
- if (!pOggPin) {
- continue;
- }
-
- CStringW value = pOggPin->GetComment(oggtag);
- if (!value.IsEmpty()) {
- SetProperty(dsmtag, value);
- break;
- }
- }
- }
-
- POSITION pos = m_pOutputs.GetHeadPosition();
- while (pos && !ChapGetCount()) {
- COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>((CBaseOutputPin*)m_pOutputs.GetNext(pos));
- if (!pOggPin) {
- continue;
- }
-
- for (int i = 1; pOggPin; i++) {
- CStringW key;
- key.Format(L"CHAPTER%02d", i);
- CStringW time = pOggPin->GetComment(key);
- if (time.IsEmpty()) {
- break;
- }
- key.Format(L"CHAPTER%02dNAME", i);
- CStringW name = pOggPin->GetComment(key);
- if (name.IsEmpty()) {
- name.Format(L"Chapter %d", i);
- }
- int h, m, s, ms;
- WCHAR c;
- if (7 != swscanf_s(time, L"%d%c%d%c%d%c%d", &h, &c, 1, &m, &c, 1, &s, &c, 1, &ms)) {
- break;
- }
- REFERENCE_TIME rt = ((((REFERENCE_TIME)h * 60 + m) * 60 + s) * 1000 + ms) * 10000;
- ChapAppend(rt, name);
- }
- }
- }
-
- return !m_pOutputs.IsEmpty() ? S_OK : E_FAIL;
-}
-
-bool COggSplitterFilter::DemuxInit()
-{
- SetThreadName((DWORD) - 1, "COggSplitterFilter");
- if (!m_pFile) {
- return false;
- }
-
- return true;
-}
-
-void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
-{
- if (rt <= 0) {
- m_pFile->Seek(0);
- } else if (m_rtDuration > 0) {
- // oh, the horror...
-
- __int64 len = m_pFile->GetLength();
- __int64 startpos = len * rt / m_rtDuration;
- //__int64 diff = 0;
-
- REFERENCE_TIME rtMinDiff = _I64_MAX;
-
- for (;;) {
- __int64 endpos = startpos;
- REFERENCE_TIME rtPos = -1;
-
- OggPage page;
- m_pFile->Seek(startpos);
- while (m_pFile->Read(page, false)) {
- if (page.m_hdr.granule_position == -1) {
- continue;
- }
-
- COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number));
- if (!pOggPin) {
- ASSERT(0);
- continue;
- }
-
- rtPos = pOggPin->GetRefTime(page.m_hdr.granule_position);
- endpos = m_pFile->GetPos();
-
- break;
- }
-
- __int64 rtDiff = rtPos - rt;
-
- if (rtDiff < 0) {
- rtDiff = -rtDiff;
-
- if (rtDiff < 1000000 || rtDiff >= rtMinDiff) {
- m_pFile->Seek(startpos);
- break;
- }
-
- rtMinDiff = rtDiff;
- }
-
- __int64 newpos = startpos;
-
- if (rtPos < rt && rtPos < m_rtDuration) {
- newpos = startpos + (__int64)((1.0 * (rt - rtPos) / (m_rtDuration - rtPos)) * (len - startpos)) + 1024;
- if (newpos < endpos) {
- newpos = endpos + 1024;
- }
- } else if (rtPos > rt && rtPos > 0) {
- newpos = startpos - (__int64)((1.0 * (rtPos - rt) / (rtPos - 0)) * (startpos - 0)) - 1024;
- if (newpos >= startpos) {
- newpos = startpos - 1024;
- }
- } else if (rtPos == rt) {
- m_pFile->Seek(startpos);
- break;
- } else {
- ASSERT(0);
- m_pFile->Seek(0);
- break;
- }
-
- //diff = newpos - startpos;
-
- startpos = max(min(newpos, len), 0);
- }
-
- m_pFile->Seek(startpos);
-
- POSITION pos = m_pOutputs.GetHeadPosition();
- while (pos) {
- COggSplitterOutputPin* pPin = dynamic_cast<COggSplitterOutputPin*>(static_cast<CBaseSplitterOutputPin*>(m_pOutputs.GetNext(pos)));
-
- if (!dynamic_cast<COggVideoOutputPin*>(pPin) && !dynamic_cast<COggTheoraOutputPin*>(pPin)) {
- continue;
- }
-
- bool fKeyFrameFound = false, fSkipKeyFrame = true;
- __int64 endpos = _I64_MAX;
-
- while (!(fKeyFrameFound && !fSkipKeyFrame) && startpos > 0) {
- OggPage page;
- while (!(fKeyFrameFound && !fSkipKeyFrame) && m_pFile->GetPos() < endpos && m_pFile->Read(page)) {
- if (page.m_hdr.granule_position == -1) {
- continue;
- }
-
- if (pPin != dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
- continue;
- }
-
- if (pPin->GetRefTime(page.m_hdr.granule_position) > rt) {
- break;
- }
-
- if (!fKeyFrameFound) {
- pPin->UnpackPage(page);
-
- CAutoPtr<OggPacket> p;
- while (p = pPin->GetPacket()) {
- if (p->bSyncPoint) {
- fKeyFrameFound = true;
- fSkipKeyFrame = p->fSkip;
- }
- }
-
- if (fKeyFrameFound) {
- break;
- }
- } else {
- pPin->UnpackPage(page);
-
- CAutoPtr<OggPacket> p;
- while (p = pPin->GetPacket()) {
- if (!p->fSkip) {
- fSkipKeyFrame = false;
- break;
- }
- }
- }
- }
-
- if (!(fKeyFrameFound && !fSkipKeyFrame)) {
- endpos = startpos;
- startpos = max(startpos - 10 * MAX_PROBE_SIZE, 0);
- }
-
- m_pFile->Seek(startpos);
- }
-
-#ifdef _DEBUG
- // verify kf
-
- {
- fKeyFrameFound = false;
-
- OggPage page;
- while (!fKeyFrameFound && m_pFile->Read(page)) {
- if (page.m_hdr.granule_position == -1) {
- continue;
- }
-
- if (pPin != dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
- continue;
- }
-
- REFERENCE_TIME rtPos = pPin->GetRefTime(page.m_hdr.granule_position);
- if (rtPos > rt) {
- break;
- }
-
- pPin->UnpackPage(page);
-
- CAutoPtr<OggPacket> p;
- while (p = pPin->GetPacket()) {
- if (p->bSyncPoint) {
- fKeyFrameFound = true;
- break;
- }
- }
- }
-
- ASSERT(fKeyFrameFound);
-
- m_pFile->Seek(startpos);
- }
-#endif
- break;
- }
- }
-}
-
-bool COggSplitterFilter::DemuxLoop()
-{
- HRESULT hr = S_OK;
-
- OggPage page;
- while (SUCCEEDED(hr) && !CheckRequest(nullptr) && m_pFile->Read(page, true, GetRequestHandle())) {
- COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number));
- if (!pOggPin) {
- ASSERT(0);
- continue;
- }
- if (!pOggPin->IsConnected()) {
- continue;
- }
- if (FAILED(hr = pOggPin->UnpackPage(page))) {
- ASSERT(0);
- break;
- }
- CAutoPtr<OggPacket> p;
- while (!CheckRequest(nullptr) && SUCCEEDED(hr) && (p = pOggPin->GetPacket())) {
- if (!p->fSkip) {
- hr = DeliverPacket(p);
- }
- }
- }
-
- return true;
-}
-
-//
-// COggSourceFilter
-//
-
-COggSourceFilter::COggSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : COggSplitterFilter(pUnk, phr)
-{
- m_clsid = __uuidof(this);
- m_pInput.Free();
-}
-
-//
-// COggSplitterOutputPin
-//
-
-COggSplitterOutputPin::COggSplitterOutputPin(LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseSplitterOutputPin(pName, pFilter, pLock, phr)
-{
- ResetState((DWORD) - 1);
-}
-
-void COggSplitterOutputPin::AddComment(BYTE* p, int len)
-{
- bitstream bs(p, len);
- bs.getbits(bs.getbits(32) * 8);
- for (int n = bs.getbits(32); n-- > 0;) {
- CStringA str;
- for (int len2 = bs.getbits(32); len2-- > 0;) {
- str += (CHAR)bs.getbits(8);
- }
-
- CAtlList<CStringA> sl;
- Explode(str, sl, '=', 2);
- if (sl.GetCount() == 2) {
- CAutoPtr<CComment> ptr(DEBUG_NEW CComment(UTF8To16(sl.GetHead()), UTF8To16(sl.GetTail())));
-
- if (ptr->m_key == L"LANGUAGE") {
- CString lang = ISO6392ToLanguage(sl.GetTail()), iso6392 = LanguageToISO6392(CString(ptr->m_value));
-
- if (ptr->m_value.GetLength() == 3 && !lang.IsEmpty()) {
- SetName(CStringW(lang));
- SetProperty(L"LANG", ptr->m_value);
- } else if (!iso6392.IsEmpty()) {
- SetName(ptr->m_value);
- SetProperty(L"LANG", CStringW(iso6392));
- } else {
- SetName(ptr->m_value);
- SetProperty(L"NAME", ptr->m_value);
- }
- }
-
- m_pComments.AddTail(ptr);
- }
- }
- ASSERT(bs.getbits(1) == 1);
-}
-
-CStringW COggSplitterOutputPin::GetComment(CStringW key)
-{
- key.MakeUpper();
- CAtlList<CStringW> sl;
- POSITION pos = m_pComments.GetHeadPosition();
- while (pos) {
- CComment* p = m_pComments.GetNext(pos);
- if (key == p->m_key) {
- sl.AddTail(p->m_value);
- }
- }
- return Implode(sl, ';');
-}
-
-void COggSplitterOutputPin::ResetState(DWORD seqnum)
-{
- CAutoLock csAutoLock(&m_csPackets);
- m_packets.RemoveAll();
- m_lastpacket.Free();
- m_lastseqnum = seqnum;
- m_rtLast = 0;
- m_fSkip = true;
-}
-
-HRESULT COggSplitterOutputPin::UnpackPage(OggPage& page)
-{
- if (m_lastseqnum != page.m_hdr.page_sequence_number - 1) {
- ResetState(page.m_hdr.page_sequence_number);
- return S_FALSE; // FIXME
- } else {
- m_lastseqnum = page.m_hdr.page_sequence_number;
- }
-
- POSITION first = page.m_lens.GetHeadPosition();
- while (first && page.m_lens.GetAt(first) == 255) {
- page.m_lens.GetNext(first);
- }
- if (!first) {
- first = page.m_lens.GetTailPosition();
- }
-
- POSITION last = page.m_lens.GetTailPosition();
- while (last && page.m_lens.GetAt(last) == 255) {
- page.m_lens.GetPrev(last);
- }
- if (!last) {
- last = page.m_lens.GetTailPosition();
- }
-
- BYTE* pData = page.GetData();
-
- int i = 0, j = 0, len = 0;
-
- for (POSITION pos = page.m_lens.GetHeadPosition(); pos; page.m_lens.GetNext(pos)) {
- len = page.m_lens.GetAt(pos);
- j += len;
-
- if (len < 255 || pos == page.m_lens.GetTailPosition()) {
- if (first == pos && (page.m_hdr.header_type_flag & OggPageHeader::continued)) {
- // ASSERT(m_lastpacket);
-
- if (m_lastpacket) {
- size_t size = m_lastpacket->GetCount();
- m_lastpacket->SetCount(size + j - i);
- memcpy(m_lastpacket->GetData() + size, pData + i, j - i);
-
- CAutoLock csAutoLock(&m_csPackets);
-
- if (len < 255) {
- m_packets.AddTail(m_lastpacket);
- }
- }
- } else {
- CAutoPtr<OggPacket> p(DEBUG_NEW OggPacket());
-
- if (last == pos && page.m_hdr.granule_position != -1) {
- p->bDiscontinuity = m_fSkip;
- REFERENCE_TIME rtLast = m_rtLast;
- m_rtLast = GetRefTime(page.m_hdr.granule_position);
- // some bad encodings have a +/-1 frame difference from the normal timeline,
- // but these seem to cancel eachother out nicely so we can just ignore them
- // to make it play a bit more smooth.
- if (abs(rtLast - m_rtLast) == GetRefTime(1)) {
- m_rtLast = rtLast; // FIXME
- }
- m_fSkip = false;
- }
-
- p->TrackNumber = page.m_hdr.bitstream_serial_number;
-
- if (S_OK == UnpackPacket(p, pData + i, j - i)) {
- //if (p->TrackNumber == 1)
- //TRACE(_T("[%d]: %d, %I64d -> %I64d (skip=%d, disc=%d, sync=%d)\n"),
- // (int)p->TrackNumber, p->GetCount(), p->rtStart, p->rtStop,
- // (int)m_fSkip, (int)p->bDiscontinuity, (int)p->bSyncPoint);
-
- if (p->rtStart <= p->rtStop && p->rtStop <= p->rtStart + 10000000i64 * 60) {
- CAutoLock csAutoLock(&m_csPackets);
-
- m_rtLast = p->rtStop;
- p->fSkip = m_fSkip;
-
- if (len < 255) {
- m_packets.AddTail(p);
- } else {
- m_lastpacket = p;
- }
- } else {
- ASSERT(0);
- }
- }
- }
-
- i = j;
- }
- }
-
- return S_OK;
-}
-
-CAutoPtr<OggPacket> COggSplitterOutputPin::GetPacket()
-{
- CAutoPtr<OggPacket> p;
- CAutoLock csAutoLock(&m_csPackets);
- if (m_packets.GetCount()) {
- p = m_packets.RemoveHead();
- }
- return p;
-}
-
-HRESULT COggSplitterOutputPin::DeliverEndFlush()
-{
- ResetState();
- return __super::DeliverEndFlush();
-}
-
-HRESULT COggSplitterOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
-{
- ResetState();
- return __super::DeliverNewSegment(tStart, tStop, dRate);
-}
-
-//
-// COggVorbisOutputPin
-//
-
-COggVorbisOutputPin::COggVorbisOutputPin(OggVorbisIdHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : COggSplitterOutputPin(pName, pFilter, pLock, phr)
-{
- m_audio_sample_rate = h->audio_sample_rate;
- m_blocksize[0] = 1 << h->blocksize_0;
- m_blocksize[1] = 1 << h->blocksize_1;
- m_lastblocksize = 0;
-
- CMediaType mt;
-
- mt.InitMediaType();
- mt.majortype = MEDIATYPE_Audio;
- mt.subtype = MEDIASUBTYPE_Vorbis;
- mt.formattype = FORMAT_VorbisFormat;
- VORBISFORMAT* vf = (VORBISFORMAT*)mt.AllocFormatBuffer(sizeof(VORBISFORMAT));
- ZeroMemory(mt.Format(), mt.FormatLength());
- vf->nChannels = h->audio_channels;
- vf->nSamplesPerSec = h->audio_sample_rate;
- vf->nAvgBitsPerSec = h->bitrate_nominal;
- vf->nMinBitsPerSec = h->bitrate_minimum;
- vf->nMaxBitsPerSec = h->bitrate_maximum;
- vf->fQuality = -1;
- mt.SetSampleSize(8192);
- m_mts.Add(mt);
-
- mt.InitMediaType();
- mt.majortype = MEDIATYPE_Audio;
- mt.subtype = MEDIASUBTYPE_Vorbis2;
- mt.formattype = FORMAT_VorbisFormat2;
- VORBISFORMAT2* vf2 = (VORBISFORMAT2*)mt.AllocFormatBuffer(sizeof(VORBISFORMAT2));
- ZeroMemory(mt.Format(), mt.FormatLength());
- vf2->Channels = h->audio_channels;
- vf2->SamplesPerSec = h->audio_sample_rate;
- mt.SetSampleSize(8192);
- m_mts.InsertAt(0, mt);
-}
-
-HRESULT COggVorbisOutputPin::UnpackInitPage(OggPage& page)
-{
- HRESULT hr = __super::UnpackPage(page);
-
- while (m_packets.GetCount()) {
- Packet* p = m_packets.GetHead();
-
- if (p->GetCount() >= 6 && p->GetAt(0) == 0x05) {
- // yeah, right, we are going to be parsing this backwards! :P
- bitstream bs(p->GetData(), (int)p->GetCount(), true);
- while (bs.hasbits(-1) && bs.getbits(-1) != 1) {
- ;
- }
- for (int cnt = 0; bs.hasbits(-8 - 16 - 16 - 1 - 6); cnt++) {
- unsigned int modes = bs.showbits(-6) + 1;
-
- unsigned int mapping = bs.getbits(-8);
- unsigned int transformtype = bs.getbits(-16);
- unsigned int windowtype = bs.getbits(-16);
- unsigned int blockflag = bs.getbits(-1);
- UNREFERENCED_PARAMETER(mapping);
-
- if (transformtype != 0 || windowtype != 0) {
- ASSERT(modes == cnt);
- UNREFERENCED_PARAMETER(modes);
- break;
- }
-
- m_blockflags.InsertAt(0, !!blockflag);
- }
- }
-
- int cnt = (int)m_initpackets.GetCount();
- if (cnt < 3 && (p->GetCount() >= 6 && p->GetAt(0) == 1 + cnt * 2)) {
- VORBISFORMAT2* vf2 = (VORBISFORMAT2*)m_mts[0].Format();
- vf2->HeaderSize[cnt] = p->GetCount();
- int len = m_mts[0].FormatLength();
- memcpy(m_mts[0].ReallocFormatBuffer(len + p->GetCount()) + len, p->GetData(), p->GetCount());
- }
-
- m_initpackets.AddTail(m_packets.RemoveHead());
- }
-
- return hr;
-}
-
-REFERENCE_TIME COggVorbisOutputPin::GetRefTime(__int64 granule_position)
-{
- REFERENCE_TIME rt = granule_position * 10000000 / m_audio_sample_rate;
- return rt;
-}
-
-HRESULT COggVorbisOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len)
-{
- if (len > 0 && m_blockflags.GetCount()) {
- bitstream bs(pData, len);
- if (bs.getbits(1) == 0) {
- unsigned int x = (unsigned int)m_blockflags.GetCount() - 1;
- int n = 0;
- while (x) {
- n++;
- x >>= 1;
- }
- DWORD blocksize = m_blocksize[m_blockflags[bs.getbits(n)] ? 1 : 0];
- if (m_lastblocksize) {
- m_rtLast += GetRefTime((m_lastblocksize + blocksize) >> 2);
- }
- m_lastblocksize = blocksize;
- }
- }
-
- p->bSyncPoint = TRUE;
- p->rtStart = m_rtLast;
- p->rtStop = m_rtLast + 1;
- p->SetData(pData, len);
-
- return S_OK;
-}
-
-HRESULT COggVorbisOutputPin::DeliverPacket(CAutoPtr<OggPacket> p)
-{
- if (p->GetCount() > 0 && (p->GetAt(0) & 1)) {
- return S_OK;
- }
-
- return __super::DeliverPacket(p);
-}
-
-HRESULT COggVorbisOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
-{
- HRESULT hr = __super::DeliverNewSegment(tStart, tStop, dRate);
-
- m_lastblocksize = 0;
-
- if (m_mt.subtype == MEDIASUBTYPE_Vorbis) {
- POSITION pos = m_initpackets.GetHeadPosition();
- while (pos) {
- Packet* pi = m_initpackets.GetNext(pos);
- CAutoPtr<OggPacket> p(DEBUG_NEW OggPacket());
- p->TrackNumber = pi->TrackNumber;
- p->bDiscontinuity = p->bSyncPoint = FALSE;//TRUE;
- p->rtStart = p->rtStop = 0;
- p->Copy(*pi);
- __super::DeliverPacket(p);
- }
- }
-
- return hr;
-}
-
-//
-// COggFlacOutputPin
-//
-
-COggFlacOutputPin::COggFlacOutputPin(BYTE* h, int nCount, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : COggSplitterOutputPin(pName, pFilter, pLock, phr)
-{
- CGolombBuffer Buffer(h, nCount);
-
- Buffer.BitRead(1); // Last-metadata-block flag
-
- if (Buffer.BitRead(7) != 0) { // Should be a STREAMINFO block
- if (phr) {
- *phr = VFW_E_INVALID_FILE_FORMAT;
- }
- return;
- }
-
- Buffer.BitRead(24); // Length (in bytes) of metadata to follow
- Buffer.ReadShort(); // m_nMinBlocksize
- Buffer.ReadShort(); // m_nMaxBlocksize
- Buffer.BitRead(24); // m_nMinFrameSize
- Buffer.BitRead(24); // m_nMaxFrameSize
- m_nSamplesPerSec = (int)Buffer.BitRead(20);
- m_nChannels = (int)Buffer.BitRead(3) + 1;
- m_wBitsPerSample = (WORD)Buffer.BitRead(5) + 1;
- Buffer.BitRead(36); // m_i64TotalNumSamples
- m_nAvgBytesPerSec = (m_nChannels * (m_wBitsPerSample >> 3)) * m_nSamplesPerSec;
-
- CMediaType mt;
-
- mt.majortype = MEDIATYPE_Audio;
- mt.subtype = MEDIASUBTYPE_FLAC_FRAMED;
- mt.formattype = FORMAT_WaveFormatEx;
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX));
- ZeroMemory(wfe, sizeof(WAVEFORMATEX));
- wfe->cbSize = sizeof(WAVEFORMATEX);
- wfe->wFormatTag = WAVE_FORMAT_FLAC;
- wfe->nSamplesPerSec = m_nSamplesPerSec;
- wfe->nAvgBytesPerSec = m_nAvgBytesPerSec;
- wfe->nChannels = m_nChannels;
- wfe->nBlockAlign = 1;
- wfe->wBitsPerSample = m_wBitsPerSample;
-
- m_mts.InsertAt(0, mt);
- *phr = S_OK;
-}
-
-REFERENCE_TIME COggFlacOutputPin::GetRefTime(__int64 granule_position)
-{
- REFERENCE_TIME rt = (granule_position * UNITS) / m_nSamplesPerSec;
- return rt;
-}
-
-HRESULT COggFlacOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len)
-{
- if (pData[0] != 0xFF || (pData[1] & 0xFE) != 0xF8) {
- return S_FALSE;
- }
-
- p->bSyncPoint = TRUE;
- p->rtStart = m_rtLast;
- p->rtStop = m_rtLast + 1; // TODO : find packet duration !
- p->SetData(pData, len);
-
- return S_OK;
-}
-
-HRESULT COggFlacOutputPin::DeliverPacket(CAutoPtr<OggPacket> p)
-{
- if (p->GetCount() > 0 && (p->GetAt(0) & 1)) {
- return S_OK;
- }
-
- return __super::DeliverPacket(p);
-}
-
-HRESULT COggFlacOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
-{
- HRESULT hr = __super::DeliverNewSegment(tStart, tStop, dRate);
-
- m_lastblocksize = 0;
-
- if (m_mt.subtype == MEDIASUBTYPE_FLAC_FRAMED) {
- POSITION pos = m_initpackets.GetHeadPosition();
- while (pos) {
- Packet* pi = m_initpackets.GetNext(pos);
- CAutoPtr<OggPacket> p(DEBUG_NEW OggPacket());
- p->TrackNumber = pi->TrackNumber;
- p->bDiscontinuity = p->bSyncPoint = FALSE;//TRUE;
- p->rtStart = p->rtStop = 0;
- p->Copy(*pi);
- __super::DeliverPacket(p);
- }
- }
-
- return hr;
-}
-//
-// COggDirectShowOutputPin
-//
-
-COggDirectShowOutputPin::COggDirectShowOutputPin(AM_MEDIA_TYPE* pmt, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : COggSplitterOutputPin(pName, pFilter, pLock, phr)
-{
- CMediaType mt;
- memcpy((AM_MEDIA_TYPE*)&mt, pmt, FIELD_OFFSET(AM_MEDIA_TYPE, pUnk));
- mt.SetFormat((BYTE*)(pmt + 1), pmt->cbFormat);
- mt.SetSampleSize(1);
- if (mt.majortype == MEDIATYPE_Video) { // TODO: find samples for audio and find out what to return in GetRefTime...
- m_mts.Add(mt);
- }
-}
-
-REFERENCE_TIME COggDirectShowOutputPin::GetRefTime(__int64 granule_position)
-{
- REFERENCE_TIME rt = 0;
-
- if (m_mt.majortype == MEDIATYPE_Video) {
- rt = granule_position * ((VIDEOINFOHEADER*)m_mt.Format())->AvgTimePerFrame;
- } else if (m_mt.majortype == MEDIATYPE_Audio) {
- rt = granule_position; // ((WAVEFORMATEX*)m_mt.Format())-> // TODO
- }
-
- return rt;
-}
-
-HRESULT COggDirectShowOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len)
-{
- int i = 0;
-
- BYTE hdr = pData[i++];
-
- if (!(hdr & 1)) {
- // TODO: verify if this was still present in the old format (haven't found one sample yet)
- BYTE nLenBytes = (hdr >> 6) | ((hdr & 2) << 1);
- __int64 Length = 0;
- for (int j = 0; j < nLenBytes; j++) {
- Length |= (__int64)pData[i++] << (j << 3);
- }
-
- if (len < i) {
- ASSERT(0);
- return E_FAIL;
- }
-
- p->bSyncPoint = !!(hdr & 8);
- p->rtStart = m_rtLast;
- p->rtStop = m_rtLast + (nLenBytes ? GetRefTime(Length) : GetRefTime(1));
- p->SetData(&pData[i], len - i);
-
- return S_OK;
- }
-
- return S_FALSE;
-}
-
-//
-// COggStreamOutputPin
-//
-
-COggStreamOutputPin::COggStreamOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : COggSplitterOutputPin(pName, pFilter, pLock, phr)
-{
- m_time_unit = h->time_unit;
- m_samples_per_unit = h->samples_per_unit;
- m_default_len = h->default_len;
-}
-
-REFERENCE_TIME COggStreamOutputPin::GetRefTime(__int64 granule_position)
-{
- return granule_position * m_time_unit / m_samples_per_unit;
-}
-
-HRESULT COggStreamOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len)
-{
- int i = 0;
-
- BYTE hdr = pData[i++];
-
- if (!(hdr & 1)) {
- BYTE nLenBytes = (hdr >> 6) | ((hdr & 2) << 1);
- __int64 Length = 0;
- for (int j = 0; j < nLenBytes; j++) {
- Length |= (__int64)pData[i++] << (j << 3);
- }
-
- if (len < i) {
- ASSERT(0);
- return E_FAIL;
- }
-
- p->bSyncPoint = !!(hdr & 8);
- p->rtStart = m_rtLast;
- p->rtStop = m_rtLast + (nLenBytes ? GetRefTime(Length) : GetRefTime(m_default_len));
- p->SetData(&pData[i], len - i);
-
- return S_OK;
- }
-
- return S_FALSE;
-}
-
-//
-// COggVideoOutputPin
-//
-
-COggVideoOutputPin::COggVideoOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : COggStreamOutputPin(h, pName, pFilter, pLock, phr)
-{
- int extra = (int)h->size - sizeof(OggStreamHeader);
- extra = max(extra, 0);
-
- CMediaType mt;
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = FOURCCMap(MAKEFOURCC(h->subtype[0], h->subtype[1], h->subtype[2], h->subtype[3]));
- mt.formattype = FORMAT_VideoInfo;
- VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + extra);
- ZeroMemory(mt.Format(), mt.FormatLength());
- memcpy(mt.Format() + sizeof(VIDEOINFOHEADER), h + 1, extra);
- pvih->AvgTimePerFrame = h->time_unit / h->samples_per_unit;
- pvih->bmiHeader.biWidth = h->v.w;
- pvih->bmiHeader.biHeight = h->v.h;
- pvih->bmiHeader.biBitCount = (WORD)h->bps;
- pvih->bmiHeader.biCompression = mt.subtype.Data1;
- switch (pvih->bmiHeader.biCompression) {
- case BI_RGB:
- case BI_BITFIELDS:
- mt.subtype =
- pvih->bmiHeader.biBitCount == 1 ? MEDIASUBTYPE_RGB1 :
- pvih->bmiHeader.biBitCount == 4 ? MEDIASUBTYPE_RGB4 :
- pvih->bmiHeader.biBitCount == 8 ? MEDIASUBTYPE_RGB8 :
- pvih->bmiHeader.biBitCount == 16 ? MEDIASUBTYPE_RGB565 :
- pvih->bmiHeader.biBitCount == 24 ? MEDIASUBTYPE_RGB24 :
- pvih->bmiHeader.biBitCount == 32 ? MEDIASUBTYPE_RGB32 :
- MEDIASUBTYPE_NULL;
- break;
- case BI_RLE8:
- mt.subtype = MEDIASUBTYPE_RGB8;
- break;
- case BI_RLE4:
- mt.subtype = MEDIASUBTYPE_RGB4;
- break;
- }
- mt.SetSampleSize(max(h->buffersize, 1));
- m_mts.Add(mt);
-}
-
-//
-// COggAudioOutputPin
-//
-
-COggAudioOutputPin::COggAudioOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : COggStreamOutputPin(h, pName, pFilter, pLock, phr)
-{
- int extra = (int)h->size - sizeof(OggStreamHeader);
- extra = max(extra, 0);
-
- CMediaType mt;
- mt.majortype = MEDIATYPE_Audio;
- mt.subtype = FOURCCMap(strtol(CStringA(h->subtype, 4), nullptr, 16));
- mt.formattype = FORMAT_WaveFormatEx;
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX) + extra);
- ZeroMemory(mt.Format(), mt.FormatLength());
- memcpy(mt.Format() + sizeof(WAVEFORMATEX), h + 1, extra);
- wfe->cbSize = extra;
- wfe->wFormatTag = (WORD)mt.subtype.Data1;
- wfe->nChannels = h->a.nChannels;
- wfe->nSamplesPerSec = (DWORD)(10000000i64 * h->samples_per_unit / h->time_unit);
- wfe->wBitsPerSample = (WORD)h->bps;
- wfe->nAvgBytesPerSec = h->a.nAvgBytesPerSec; // TODO: verify for PCM
- wfe->nBlockAlign = h->a.nBlockAlign; // TODO: verify for PCM
- mt.SetSampleSize(max(h->buffersize, 1));
- m_mts.Add(mt);
-}
-
-//
-// COggTextOutputPin
-//
-
-COggTextOutputPin::COggTextOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : COggStreamOutputPin(h, pName, pFilter, pLock, phr)
-{
- CMediaType mt;
- mt.majortype = MEDIATYPE_Text;
- mt.subtype = MEDIASUBTYPE_NULL;
- mt.formattype = FORMAT_None;
- mt.SetSampleSize(1);
- m_mts.Add(mt);
-}
-
-// COggTheoraOutputPin
-
-COggTheoraOutputPin::COggTheoraOutputPin(BYTE* p, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : COggSplitterOutputPin(pName, pFilter, pLock, phr)
-{
- CMediaType mt;
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = FOURCCMap('OEHT');
- mt.formattype = FORMAT_MPEG2_VIDEO;
- MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(sizeof(MPEG2VIDEOINFO));
- ZeroMemory(mt.Format(), mt.FormatLength());
- vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
- vih->hdr.bmiHeader.biWidth = *(WORD*)&p[10] >> 4;
- vih->hdr.bmiHeader.biHeight = *(WORD*)&p[12] >> 4;
- vih->hdr.bmiHeader.biCompression = 'OEHT';
- vih->hdr.bmiHeader.biPlanes = 1;
- vih->hdr.bmiHeader.biBitCount = 24;
- m_nFpsNum = (p[22] << 24) | (p[23] << 16) | (p[24] << 8) | p[25];
- m_nFpsDenum = (p[26] << 24) | (p[27] << 16) | (p[28] << 8) | p[29];
- if (m_nFpsNum) {
- m_rtAvgTimePerFrame = (REFERENCE_TIME)(10000000.0 * m_nFpsDenum / m_nFpsNum);
- vih->hdr.AvgTimePerFrame = m_rtAvgTimePerFrame;
- }
- vih->hdr.dwPictAspectRatioX = (p[14] << 16) | (p[15] << 8) | p[16];
- vih->hdr.dwPictAspectRatioY = (p[17] << 16) | (p[18] << 8) | p[19];
-
- m_KfgShift = (((p[40] << 8) + p[41]) & 0x3E0) >> 5;
- m_nIndexOffset = TH_VERSION_CHECK(p[7], p[8], p[9], 3, 2, 1);
-
- if (m_KfgShift == 0) {
- m_KfgShift = 6; // Is it really default value ?
- }
-
- mt.bFixedSizeSamples = 0;
- m_mts.Add(mt);
-}
-
-HRESULT COggTheoraOutputPin::UnpackInitPage(OggPage& page)
-{
- HRESULT hr = __super::UnpackPage(page);
-
- while (m_packets.GetCount()) {
- Packet* p = m_packets.GetHead();
-
- CMediaType& mt = m_mts[0];
- int size = (int)p->GetCount();
- ASSERT(size <= 0xffff);
- MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.ReallocFormatBuffer(
- FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) +
- ((MPEG2VIDEOINFO*)mt.Format())->cbSequenceHeader +
- 2 + size);
- *(WORD*)((BYTE*)vih->dwSequenceHeader + vih->cbSequenceHeader) = (size >> 8) | (size << 8);
- memcpy((BYTE*)vih->dwSequenceHeader + vih->cbSequenceHeader + 2, p->GetData(), size);
- vih->cbSequenceHeader += 2 + size;
-
- m_initpackets.AddTail(m_packets.RemoveHead());
- }
-
- return hr;
-}
-
-REFERENCE_TIME COggTheoraOutputPin::GetRefTime(__int64 granule_position)
-{
- LONGLONG iframe;
- LONGLONG pframe;
-
- iframe = granule_position >> m_KfgShift;
- pframe = granule_position - (iframe << m_KfgShift);
- /*3.2.0 streams store the frame index in the granule position.
- 3.2.1 and later store the frame count.
- We return the index, so adjust the value if we have a 3.2.1 or later
- stream.*/
-
- REFERENCE_TIME rt = (iframe + pframe - m_nIndexOffset) * m_rtAvgTimePerFrame;
- return rt;
-}
-
-HRESULT COggTheoraOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len)
-{
- if (!pData) {
- return E_FAIL;
- }
-
- p->bSyncPoint = len > 0 ? !(*pData & 0x40) : TRUE;
- p->rtStart = m_rtLast;
- p->rtStop = m_rtLast + 1;
- p->SetData(pData, len);
-
- if (!(*pData & 0x80) && m_mt.majortype == MEDIATYPE_Video) {
- p->rtStop = p->rtStart + ((MPEG2VIDEOINFO*)m_mt.Format())->hdr.AvgTimePerFrame;
- }
-
- return S_OK;
-}
diff --git a/src/filters/parser/OggSplitter/OggSplitter.def b/src/filters/parser/OggSplitter/OggSplitter.def
deleted file mode 100644
index 6492e5cd6..000000000
--- a/src/filters/parser/OggSplitter/OggSplitter.def
+++ /dev/null
@@ -1,5 +0,0 @@
-EXPORTS
- DllCanUnloadNow PRIVATE
- DllGetClassObject PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
diff --git a/src/filters/parser/OggSplitter/OggSplitter.h b/src/filters/parser/OggSplitter/OggSplitter.h
deleted file mode 100644
index 1570e0116..000000000
--- a/src/filters/parser/OggSplitter/OggSplitter.h
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <atlbase.h>
-#include <atlcoll.h>
-#include "OggFile.h"
-#include "../BaseSplitter/BaseSplitter.h"
-
-#define OggSplitterName L"MPC Ogg Splitter"
-#define OggSourceName L"MPC Ogg Source"
-
-class OggPacket : public Packet
-{
-public:
- OggPacket() { fSkip = false; }
- bool fSkip;
-};
-
-class COggSplitterOutputPin : public CBaseSplitterOutputPin
-{
- class CComment
- {
- public:
- CStringW m_key, m_value;
- CComment(CStringW key, CStringW value) : m_key(key), m_value(value) {
- m_key.MakeUpper();
- }
- };
-
- CAutoPtrList<CComment> m_pComments;
-
-protected:
- CCritSec m_csPackets;
- CAutoPtrList<OggPacket> m_packets;
- CAutoPtr<OggPacket> m_lastpacket;
- DWORD m_lastseqnum;
- REFERENCE_TIME m_rtLast;
- bool m_fSkip;
-
- void ResetState(DWORD seqnum = -1);
-
-public:
- COggSplitterOutputPin(LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
-
- void AddComment(BYTE* p, int len);
- CStringW GetComment(CStringW key);
-
- HRESULT UnpackPage(OggPage& page);
- virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len) = 0;
- virtual REFERENCE_TIME GetRefTime(__int64 granule_position) = 0;
- CAutoPtr<OggPacket> GetPacket();
-
- HRESULT DeliverEndFlush();
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
-};
-
-class COggVorbisOutputPin : public COggSplitterOutputPin
-{
- CAutoPtrList<OggPacket> m_initpackets;
-
- DWORD m_audio_sample_rate;
- DWORD m_blocksize[2], m_lastblocksize;
- CAtlArray<bool> m_blockflags;
-
- virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len);
- virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
-
- HRESULT DeliverPacket(CAutoPtr<OggPacket> p);
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
-
-public:
- COggVorbisOutputPin(OggVorbisIdHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
-
- HRESULT UnpackInitPage(OggPage& page);
- bool IsInitialized() { return m_initpackets.GetCount() >= 3; }
-};
-
-class COggFlacOutputPin : public COggSplitterOutputPin
-{
- CAutoPtrList<OggPacket> m_initpackets;
-
- int m_nSamplesPerSec;
- int m_nChannels;
- WORD m_wBitsPerSample;
- int m_nAvgBytesPerSec;
-
- DWORD m_blocksize[2], m_lastblocksize;
- CAtlArray<bool> m_blockflags;
-
- virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len);
- virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
-
- HRESULT DeliverPacket(CAutoPtr<OggPacket> p);
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
-
-public:
- COggFlacOutputPin(BYTE* h, int nCount, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
-
- bool IsInitialized() { return m_initpackets.GetCount() >= 3; }
-};
-
-class COggDirectShowOutputPin : public COggSplitterOutputPin
-{
- virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len);
- virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
-
-public:
- COggDirectShowOutputPin(AM_MEDIA_TYPE* pmt, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
-};
-
-class COggStreamOutputPin : public COggSplitterOutputPin
-{
- __int64 m_time_unit, m_samples_per_unit;
- DWORD m_default_len;
-
- virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len);
- virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
-
-public:
- COggStreamOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
-};
-
-class COggVideoOutputPin : public COggStreamOutputPin
-{
-public:
- COggVideoOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
-};
-
-class COggAudioOutputPin : public COggStreamOutputPin
-{
-public:
- COggAudioOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
-};
-
-class COggTextOutputPin : public COggStreamOutputPin
-{
-public:
- COggTextOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
-};
-
-class COggTheoraOutputPin : public COggSplitterOutputPin
-{
- CAutoPtrList<OggPacket> m_initpackets;
- LONGLONG m_KfgShift;
- int m_nIndexOffset;
- int m_nFpsNum;
- int m_nFpsDenum;
- REFERENCE_TIME m_rtAvgTimePerFrame;
-
- virtual HRESULT UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len);
- virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
-
-public:
- COggTheoraOutputPin(BYTE* p, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
-
- HRESULT UnpackInitPage(OggPage& page);
- bool IsInitialized() { return m_initpackets.GetCount() >= 3; }
-};
-
-class __declspec(uuid("9FF48807-E133-40AA-826F-9B2959E5232D"))
- COggSplitterFilter : public CBaseSplitterFilter
-{
-protected:
- CAutoPtr<COggFile> m_pFile;
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
-
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
-
-public:
- COggSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
- virtual ~COggSplitterFilter();
-
- // CBaseFilter
-
- STDMETHODIMP_(HRESULT) QueryFilterInfo(FILTER_INFO* pInfo);
-
-};
-
-class __declspec(uuid("6D3688CE-3E9D-42F4-92CA-8A11119D25CD"))
- COggSourceFilter : public COggSplitterFilter
-{
-public:
- COggSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
-};
diff --git a/src/filters/parser/OggSplitter/OggSplitter.rc b/src/filters/parser/OggSplitter/OggSplitter.rc
deleted file mode 100644
index 46fdb77ec..000000000
--- a/src/filters/parser/OggSplitter/OggSplitter.rc
+++ /dev/null
@@ -1,102 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-#include "version.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (United States) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION MPC_VERSION_NUM
- PRODUCTVERSION MPC_VERSION_NUM
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS VOS_NT_WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE VFT2_UNKNOWN
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", MPC_VERSION_COMMENTS
- VALUE "CompanyName", MPC_COMP_NAME_STR
- VALUE "FileDescription", "Ogg Splitter"
- VALUE "FileVersion", MPC_VERSION_STR_FULL
- VALUE "InternalName", "Ogg Splitter"
- VALUE "LegalCopyright", MPC_COPYRIGHT_STR
- VALUE "OriginalFilename", "OggSplitter.ax"
- VALUE "ProductName", "Ogg Splitter"
- VALUE "ProductVersion", MPC_VERSION_STR_FULL
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // English (United States) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/src/filters/parser/OggSplitter/OggSplitter.vcxproj b/src/filters/parser/OggSplitter/OggSplitter.vcxproj
deleted file mode 100644
index 7cb508da5..000000000
--- a/src/filters/parser/OggSplitter/OggSplitter.vcxproj
+++ /dev/null
@@ -1,255 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug Filter|Win32">
- <Configuration>Debug Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug Filter|x64">
- <Configuration>Debug Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|Win32">
- <Configuration>Release Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|x64">
- <Configuration>Release Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{7FE0A205-3F39-4AC3-BC3C-C2D9E4D02475}</ProjectGuid>
- <RootNamespace>OggSplitter</RootNamespace>
- <Keyword>MFCProj</Keyword>
- <ProjectName>OggSplitter</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <Import Project="..\..\..\platform.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">.ax</TargetExt>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>OggSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>OggSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>OggSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>OggSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="OggFile.cpp" />
- <ClCompile Include="OggSplitter.cpp" />
- <ClCompile Include="stdafx.cpp">
- <PrecompiledHeader>Create</PrecompiledHeader>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="OggSplitter.def" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="OggFile.h" />
- <ClInclude Include="OggSplitter.h" />
- <ClInclude Include="resource.h">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ClInclude>
- <ClInclude Include="stdafx.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="OggSplitter.rc">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ResourceCompile>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\DSUtil\DSUtil.vcxproj">
- <Project>{fc70988b-1ae5-4381-866d-4f405e28ac42}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\Kasumi\Kasumi.vcxproj">
- <Project>{0d252872-7542-4232-8d02-53f9182aee15}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\system\system.vcxproj">
- <Project>{c2082189-3ecb-4079-91fa-89d3c8a305c0}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\BaseClasses\BaseClasses.vcxproj">
- <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\Filters.vcxproj">
- <Project>{273b3149-3192-4b75-a791-470320b90812}</Project>
- </ProjectReference>
- <ProjectReference Include="..\BaseSplitter\BaseSplitter.vcxproj">
- <Project>{37768b3f-89bc-4c16-b2a8-767c5da84c3f}</Project>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/OggSplitter/OggSplitter.vcxproj.filters b/src/filters/parser/OggSplitter/OggSplitter.vcxproj.filters
deleted file mode 100644
index d4687b02d..000000000
--- a/src/filters/parser/OggSplitter/OggSplitter.vcxproj.filters
+++ /dev/null
@@ -1,61 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{30dbc4b9-307c-4a34-99cd-6ae8cdc29c72}</UniqueIdentifier>
- <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{6f7219e1-61de-4305-b4fe-b9af26cb95f3}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{ad968fc1-5150-4f92-882e-065c3247c093}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="OggFile.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="OggSplitter.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="stdafx.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="OggSplitter.def">
- <Filter>Source Files</Filter>
- </None>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="OggFile.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="OggSplitter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="resource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="stdafx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="OggSplitter.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/OggSplitter/resource.h b/src/filters/parser/OggSplitter/resource.h
deleted file mode 100644
index 3bf040c0b..000000000
--- a/src/filters/parser/OggSplitter/resource.h
+++ /dev/null
@@ -1,14 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by OggSplitter.rc
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 101
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/filters/parser/OggSplitter/stdafx.cpp b/src/filters/parser/OggSplitter/stdafx.cpp
deleted file mode 100644
index 784f2cebc..000000000
--- a/src/filters/parser/OggSplitter/stdafx.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
diff --git a/src/filters/parser/OggSplitter/stdafx.h b/src/filters/parser/OggSplitter/stdafx.h
deleted file mode 100644
index 5b6b09e05..000000000
--- a/src/filters/parser/OggSplitter/stdafx.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../../DSUtil/SharedInclude.h"
-#include "../../../../include/stdafx_common.h"
-#include "../../../../include/stdafx_common_afx.h"
-#include "../../../../include/stdafx_common_dshow.h"
diff --git a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp
deleted file mode 100644
index 75adca484..000000000
--- a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp
+++ /dev/null
@@ -1,2672 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <Shlwapi.h>
-#include <atlpath.h>
-#include <MMReg.h>
-#include <ks.h>
-#include <ksmedia.h>
-#include "../../../DSUtil/DSUtil.h"
-#include "../../../DSUtil/MediaTypes.h"
-#include "RealMediaSplitter.h"
-#include "../../../Subtitles/SubtitleInputPin.h"
-
-#ifdef STANDALONE_FILTER
-#include <InitGuid.h>
-#endif
-#include "moreuuids.h"
-
-#define MAXPACKETS_RV 10000
-
-template<typename T>
-static void bswap(T& var)
-{
- BYTE* s = (BYTE*)&var;
- for (BYTE* d = s + sizeof(var) - 1; s < d; s++, d--) {
- *s ^= *d, *d ^= *s, *s ^= *d;
- }
-}
-
-void rvinfo::bswap()
-{
- ::bswap(dwSize);
- ::bswap(w);
- ::bswap(h);
- ::bswap(bpp);
- ::bswap(unk1);
- ::bswap(fps);
- ::bswap(type1);
- ::bswap(type2);
-}
-
-void rainfo3::bswap()
-{
- ::bswap(fourcc);
- ::bswap(version);
- ::bswap(header_size);
- ::bswap(data_size);
-}
-
-void rainfo::bswap()
-{
- ::bswap(version1);
- ::bswap(version2);
- ::bswap(header_size);
- ::bswap(flavor);
- ::bswap(coded_frame_size);
- ::bswap(sub_packet_h);
- ::bswap(frame_size);
- ::bswap(sub_packet_size);
-}
-
-void rainfo4::bswap()
-{
- __super::bswap();
- ::bswap(sample_rate);
- ::bswap(sample_size);
- ::bswap(channels);
-}
-
-void rainfo5::bswap()
-{
- __super::bswap();
- ::bswap(sample_rate);
- ::bswap(sample_size);
- ::bswap(channels);
-}
-
-using namespace RMFF;
-
-#ifdef STANDALONE_FILTER
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
-};
-
-const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, 0, nullptr}
-};
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn2[] = {
- {&MEDIATYPE_Video, &MEDIASUBTYPE_RV20},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_RV30},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_RV40},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_RV41},
-};
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut2[] = {
- {&MEDIATYPE_Video, &MEDIASUBTYPE_NULL},
-};
-
-const AMOVIESETUP_PIN sudpPins2[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesIn2), sudPinTypesIn2},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesOut2), sudPinTypesOut2}
-};
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn3[] = {
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_14_4},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_28_8},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_ATRC},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_COOK},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_DNET},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_SIPR},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_AAC},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_RAAC},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_RACP},
-};
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut3[] = {
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM},
-};
-
-const AMOVIESETUP_PIN sudpPins3[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesIn3), sudPinTypesIn3},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesOut3), sudPinTypesOut3}
-};
-
-const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CRealMediaSplitterFilter), RMSplitterName, MERIT_NORMAL, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CRealMediaSourceFilter), RMSourceName, MERIT_NORMAL, 0, nullptr, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CRealVideoDecoder), L"MPC RealVideo Decoder", MERIT_NORMAL, _countof(sudpPins2), sudpPins2, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CRealAudioDecoder), L"MPC RealAudio Decoder", MERIT_NORMAL, _countof(sudpPins3), sudpPins3, CLSID_LegacyAmFilterCategory},
-};
-
-CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CRealMediaSplitterFilter>, nullptr, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CRealMediaSourceFilter>, nullptr, &sudFilter[1]},
- {sudFilter[2].strName, sudFilter[2].clsID, CreateInstance<CRealVideoDecoder>, nullptr, &sudFilter[2]},
- {sudFilter[3].strName, sudFilter[3].clsID, CreateInstance<CRealAudioDecoder>, nullptr, &sudFilter[3]},
-};
-
-int g_cTemplates = _countof(g_Templates);
-
-STDAPI DllRegisterServer()
-{
- RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_RealMedia, _T("0,4,,2E524D46"), _T(".rm"), _T(".rmvb"), _T(".ram"), nullptr);
-
- return AMovieDllRegisterServer2(TRUE);
-}
-
-STDAPI DllUnregisterServer()
-{
- UnRegisterSourceFilter(MEDIASUBTYPE_RealMedia);
-
- return AMovieDllRegisterServer2(FALSE);
-}
-
-#include "../../FilterApp.h"
-
-CFilterApp theApp;
-
-#endif
-
-//
-// CRealMediaSplitterFilter
-//
-
-CRealMediaSplitterFilter::CRealMediaSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("CRealMediaSplitterFilter"), pUnk, phr, __uuidof(this), MAXPACKETS_RV)
-{
-}
-
-CRealMediaSplitterFilter::~CRealMediaSplitterFilter()
-{
-}
-
-STDMETHODIMP CRealMediaSplitterFilter::QueryFilterInfo(FILTER_INFO* pInfo)
-{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
-
- if (m_pName && m_pName[0] == L'M' && m_pName[1] == L'P' && m_pName[2] == L'C') {
- (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);
- } else {
- wcscpy_s(pInfo->achName, RMSourceName);
- }
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
-}
-
-HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
-{
- CheckPointer(pAsyncReader, E_POINTER);
-
- {
- DWORD dw;
- if (FAILED(pAsyncReader->SyncRead(0, 4, (BYTE*)&dw)) || dw != 'FMR.') {
- return E_FAIL;
- }
- }
-
- HRESULT hr = E_FAIL;
-
- m_pFile.Free();
-
- m_pFile.Attach(DEBUG_NEW CRMFile(pAsyncReader, hr));
- if (!m_pFile) {
- return E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- m_pFile.Free();
- return hr;
- }
-
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = 0;
-
- m_rtStop = 10000i64 * m_pFile->m_p.tDuration;
-
- POSITION pos = m_pFile->m_mps.GetHeadPosition();
- while (pos) {
- MediaProperies* pmp = m_pFile->m_mps.GetNext(pos);
-
- CStringW name;
- name.Format(L"Output %02u", pmp->stream);
- if (!pmp->name.IsEmpty()) {
- name += L" (" + CStringW(pmp->name) + L")";
- }
-
- CAtlArray<CMediaType> mts;
-
- CMediaType mt;
- mt.SetSampleSize(max(pmp->maxPacketSize * 16/**/, 1));
-
- if (pmp->mime == "video/x-pn-realvideo") {
- mt.majortype = MEDIATYPE_Video;
- mt.formattype = FORMAT_VideoInfo;
-
- VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + (ULONG)pmp->typeSpecData.GetCount());
- ZeroMemory(mt.Format(), mt.FormatLength());
- memcpy(pvih + 1, pmp->typeSpecData.GetData(), pmp->typeSpecData.GetCount());
-
- rvinfo rvi = *(rvinfo*)pmp->typeSpecData.GetData();
- rvi.bswap();
-
- ASSERT(rvi.dwSize >= FIELD_OFFSET(rvinfo, morewh));
- ASSERT(rvi.fcc1 == 'ODIV');
-
- mt.subtype = FOURCCMap(rvi.fcc2);
- if (rvi.fps > 0x10000) {
- pvih->AvgTimePerFrame = REFERENCE_TIME(10000000i64 / ((float)rvi.fps / 0x10000));
- }
- pvih->dwBitRate = pmp->avgBitRate;
- pvih->bmiHeader.biSize = sizeof(pvih->bmiHeader);
- pvih->bmiHeader.biWidth = rvi.w;
- pvih->bmiHeader.biHeight = rvi.h;
- pvih->bmiHeader.biPlanes = 3;
- pvih->bmiHeader.biBitCount = rvi.bpp;
- pvih->bmiHeader.biCompression = rvi.fcc2;
- pvih->bmiHeader.biSizeImage = rvi.w * rvi.h * 3 / 2;
- mts.Add(mt);
-
- BYTE* extra = pmp->typeSpecData.GetData();
- DWORD extralen = (DWORD)pmp->typeSpecData.GetCount();
-
- if (extralen > 26) {
- extra += 26;
- extralen -= 26;
- VIDEOINFOHEADER* pvih2 = (VIDEOINFOHEADER*)mt.ReallocFormatBuffer(sizeof(VIDEOINFOHEADER) + extralen);
- memcpy(pvih2 + 1, extra, extralen);
- mts.InsertAt(0, mt);
- }
-
- if (pmp->width > 0 && pmp->height > 0) {
- BITMAPINFOHEADER bmi = pvih->bmiHeader;
- mt.formattype = FORMAT_VideoInfo2;
- VIDEOINFOHEADER2* pvih2 = (VIDEOINFOHEADER2*)mt.ReallocFormatBuffer(sizeof(VIDEOINFOHEADER2) + (ULONG)pmp->typeSpecData.GetCount());
- ZeroMemory(mt.Format() + FIELD_OFFSET(VIDEOINFOHEADER2, dwInterlaceFlags), mt.FormatLength() - FIELD_OFFSET(VIDEOINFOHEADER2, dwInterlaceFlags));
- memcpy(pvih2 + 1, pmp->typeSpecData.GetData(), pmp->typeSpecData.GetCount());
- pvih2->bmiHeader = bmi;
- pvih2->bmiHeader.biWidth = (DWORD)pmp->width;
- pvih2->bmiHeader.biHeight = (DWORD)pmp->height;
- pvih2->dwPictAspectRatioX = rvi.w;
- pvih2->dwPictAspectRatioY = rvi.h;
-
- mts.InsertAt(0, mt);
- }
- } else if (pmp->mime == "audio/x-pn-realaudio") {
- mt.majortype = MEDIATYPE_Audio;
- mt.formattype = FORMAT_WaveFormatEx;
- mt.bTemporalCompression = 1;
-
- WAVEFORMATEX* pwfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX) + (ULONG)pmp->typeSpecData.GetCount());
- ZeroMemory(mt.Format(), mt.FormatLength());
- memcpy(pwfe + 1, pmp->typeSpecData.GetData(), pmp->typeSpecData.GetCount());
-
- union {
- DWORD fcc;
- char fccstr[5];
- };
-
- fcc = 0;
- fccstr[4] = 0;
-
- BYTE* fmt = pmp->typeSpecData.GetData();
- for (size_t i = 0; i < pmp->typeSpecData.GetCount() - 4; i++, fmt++) {
- if (*(DWORD*)fmt == MAKEFOURCC('.' , 'r' , 'a' , 0xfd)) {
- break;
- }
- }
-
- BYTE* extra = nullptr;
-
- WORD ver = fmt[4] << 8 | fmt[5];
- if (ver == 3) {
- rainfo3 rai3 = *(rainfo3*)fmt;
- rai3.bswap();
- fcc = '4_41';
- pwfe->nChannels = 1;
- pwfe->nSamplesPerSec = 8000;
- pwfe->nAvgBytesPerSec = 1000;
- pwfe->nBlockAlign = 2;
- pwfe->wBitsPerSample = 16;
- } else {
- rainfo rai = *(rainfo*)fmt;
- rai.bswap();
-
- if (rai.version2 == 4) {
- rainfo4 rai4 = *(rainfo4*)fmt;
- rai4.bswap();
- pwfe->nChannels = rai4.channels;
- pwfe->wBitsPerSample = rai4.sample_size;
- pwfe->nSamplesPerSec = rai4.sample_rate;
- pwfe->nBlockAlign = rai4.frame_size;
- BYTE* p = (BYTE*)((rainfo4*)fmt + 1);
- int len = *p++;
- p += len;
- len = *p++;
- ASSERT(len == 4);
- if (len == 4) {
- fcc = MAKEFOURCC(p[0], p[1], p[2], p[3]);
- }
- extra = p + len + 3;
- } else if (rai.version2 == 5) {
- rainfo5 rai5 = *(rainfo5*)fmt;
- rai5.bswap();
- pwfe->nChannels = rai5.channels;
- pwfe->wBitsPerSample = rai5.sample_size;
- pwfe->nSamplesPerSec = rai5.sample_rate;
- pwfe->nBlockAlign = rai5.frame_size;
- fcc = rai5.fourcc3;
- extra = fmt + sizeof(rainfo5) + 4;
- } else {
- continue;
- }
- }
-
- _strupr_s(fccstr);
-
- mt.subtype = FOURCCMap(fcc);
-
- bswap(fcc);
-
- switch (fcc) {
- case '14_4':
- pwfe->wFormatTag = WAVE_FORMAT_14_4;
- break;
- case '28_8':
- pwfe->wFormatTag = WAVE_FORMAT_28_8;
- break;
- case 'ATRC':
- pwfe->wFormatTag = WAVE_FORMAT_ATRC;
- break;
- case 'COOK':
- pwfe->wFormatTag = WAVE_FORMAT_COOK;
- break;
- case 'DNET':
- pwfe->wFormatTag = WAVE_FORMAT_DNET;
- break;
- case 'SIPR':
- pwfe->wFormatTag = WAVE_FORMAT_SIPR;
- break;
- case 'RAAC':
- pwfe->wFormatTag = WAVE_FORMAT_RAAC;
- break;
- case 'RACP':
- pwfe->wFormatTag = WAVE_FORMAT_RACP;
- break;
- }
-
- if (pwfe->wFormatTag) {
- mts.Add(mt);
-
- if (fcc == 'DNET') {
- mt.subtype = FOURCCMap(pwfe->wFormatTag = WAVE_FORMAT_DOLBY_AC3);
- mts.InsertAt(0, mt);
- } else if (fcc == 'RAAC' || fcc == 'RACP') {
- mt.subtype = FOURCCMap(pwfe->wFormatTag = WAVE_FORMAT_AAC);
- DWORD extralen = *(DWORD*)extra;
- extra += 4;
- ::bswap(extralen);
- ASSERT(*extra == 2); // always 2? why? what does it mean?
- if (*extra == 2) {
- extra++;
- extralen--;
- WAVEFORMATEX* pwfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + extralen);
- pwfe->cbSize = extralen;
- memcpy(pwfe + 1, extra, extralen);
- } else {
- WAVEFORMATEX* pwfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + 5);
- pwfe->cbSize = MakeAACInitData((BYTE*)(pwfe + 1), 0, pwfe->nSamplesPerSec, pwfe->nChannels);
- }
- mts.InsertAt(0, mt);
- }
- }
- } else if (pmp->mime == "logical-fileinfo") {
- CAtlMap<CStringA, CStringA, CStringElementTraits<CStringA>> lfi;
- CStringA key, value;
-
- BYTE* p = pmp->typeSpecData.GetData();
- BYTE* end = p + pmp->typeSpecData.GetCount();
- p += 8;
-
- DWORD cnt = p <= end - 4 ? *(DWORD*)p : 0;
- bswap(cnt);
- p += 4;
-
- if (cnt > 0xffff) { // different format?
- p += 2;
- cnt = p <= end - 4 ? *(DWORD*)p : 0;
- bswap(cnt);
- p += 4;
- }
-
- while (p < end - 4 && cnt-- > 0) {
- BYTE* base = p;
- DWORD len = *(DWORD*)p;
- bswap(len);
- p += 4;
- if (base + len > end) {
- break;
- }
-
- p++;
- WORD keylen = *(WORD*)p;
- bswap(keylen);
- p += 2;
- memcpy(key.GetBufferSetLength(keylen), p, keylen);
- p += keylen;
-
- p += 4;
- WORD valuelen = *(WORD*)p;
- bswap(valuelen);
- p += 2;
- memcpy(value.GetBufferSetLength(valuelen), p, valuelen);
- p += valuelen;
-
- ASSERT(p == base + len);
- p = base + len;
-
- lfi[key] = value;
- }
-
- POSITION pos = lfi.GetStartPosition();
- while (pos) {
- lfi.GetNextAssoc(pos, key, value);
-
- int n = 0;
- if (key.Find("CHAPTER") == 0 && key.Find("TIME") == key.GetLength() - 4
- && (n = strtol(key.Mid(7), nullptr, 10)) > 0) {
- int h, m, s, ms;
- char c;
- if (7 != sscanf_s(value, "%d%c%d%c%d%c%d", &h, &c, 1, &m, &c, 1, &s, &c, 1, &ms)) {
- continue;
- }
-
- key.Format("CHAPTER%02dNAME", n);
- if (!lfi.Lookup(key, value) || value.IsEmpty()) {
- value.Format("Chapter %d", n);
- }
-
- ChapAppend(
- ((((REFERENCE_TIME)h * 60 + m) * 60 + s) * 1000 + ms) * 10000,
- CStringW(CString(value)));
- }
- }
- }
-
- if (mts.IsEmpty()) {
- TRACE(_T("Unsupported RealMedia stream (%d): %s\n"), pmp->stream, CString(pmp->mime));
- continue;
- }
-
- HRESULT hr2;
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DEBUG_NEW CRealMediaSplitterOutputPin(mts, name, this, this, &hr2));
- if (SUCCEEDED(AddOutputPin((DWORD)pmp->stream, pPinOut))) {
- if (!m_rtStop) {
- m_pFile->m_p.tDuration = max(m_pFile->m_p.tDuration, pmp->tDuration);
- }
- }
- }
-
- pos = m_pFile->m_subs.GetHeadPosition();
- for (DWORD stream = 0; pos; stream++) {
- CRMFile::subtitle& s = m_pFile->m_subs.GetNext(pos);
-
- CStringW name;
- name.Format(L"Subtitle %02u", stream);
- if (!s.name.IsEmpty()) {
- name += L" (" + CStringW(CString(s.name)) + L")";
- }
-
- CMediaType mt;
- mt.SetSampleSize(1);
- mt.majortype = MEDIATYPE_Text;
-
- CAtlArray<CMediaType> mts;
- mts.Add(mt);
-
- HRESULT hr2;
-
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DEBUG_NEW CRealMediaSplitterOutputPin(mts, name, this, this, &hr2));
- AddOutputPin((DWORD)~stream, pPinOut);
- }
-
- m_rtDuration = m_rtNewStop = m_rtStop = 10000i64 * m_pFile->m_p.tDuration;
-
- SetProperty(L"TITL", CStringW(m_pFile->m_cd.title));
- SetProperty(L"AUTH", CStringW(m_pFile->m_cd.author));
- SetProperty(L"CPYR", CStringW(m_pFile->m_cd.copyright));
- SetProperty(L"DESC", CStringW(m_pFile->m_cd.comment));
-
- return !m_pOutputs.IsEmpty() ? S_OK : E_FAIL;
-}
-
-bool CRealMediaSplitterFilter::DemuxInit()
-{
- SetThreadName((DWORD) - 1, "CRealMediaSplitterFilter");
-
- if (!m_pFile) {
- return false;
- }
-
- // reindex if needed
-
- if (m_pFile->m_irs.IsEmpty()) {
- m_nOpenProgress = 0;
- m_rtDuration = 0;
-
- int stream = m_pFile->GetMasterStream();
-
- UINT32 tLastStart = (UINT32) - 1;
- UINT32 nPacket = 0;
-
- POSITION pos = m_pFile->m_dcs.GetHeadPosition();
- while (pos && !m_fAbort) {
- DataChunk* pdc = m_pFile->m_dcs.GetNext(pos);
-
- m_pFile->Seek(pdc->pos);
-
- for (UINT32 i = 0; i < pdc->nPackets && !m_fAbort; i++, nPacket++) {
- UINT64 filepos = m_pFile->GetPos();
-
- HRESULT hr;
-
- MediaPacketHeader mph;
- if (S_OK != (hr = m_pFile->Read(mph, false))) {
- break;
- }
-
- m_rtDuration = max((__int64)(10000i64 * mph.tStart), m_rtDuration);
-
- if (mph.stream == stream && (mph.flags & MediaPacketHeader::PN_KEYFRAME_FLAG) && tLastStart != mph.tStart) {
- CAutoPtr<IndexRecord> pir(DEBUG_NEW IndexRecord);
- pir->tStart = mph.tStart;
- pir->ptrFilePos = (UINT32)filepos;
- pir->packet = nPacket;
- m_pFile->m_irs.AddTail(pir);
-
- tLastStart = mph.tStart;
- }
-
- m_nOpenProgress = m_pFile->GetPos() * 100 / m_pFile->GetLength();
-
- DWORD cmd;
- if (CheckRequest(&cmd)) {
- if (cmd == CMD_EXIT) {
- m_fAbort = true;
- } else {
- Reply(S_OK);
- }
- }
- }
- }
-
- m_nOpenProgress = 100;
-
- if (m_fAbort) {
- m_pFile->m_irs.RemoveAll();
- }
-
- m_fAbort = false;
- }
-
- m_seekpos = nullptr;
- m_seekpacket = 0;
- m_seekfilepos = 0;
-
- return true;
-}
-
-void CRealMediaSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
-{
- if (rt <= 0) {
- m_seekpos = m_pFile->m_dcs.GetHeadPosition();
- m_seekpacket = 0;
- m_seekfilepos = m_pFile->m_dcs.GetHead()->pos;
- } else {
- m_seekpos = nullptr;
-
- POSITION pos = m_pFile->m_irs.GetTailPosition();
- while (pos && !m_seekpos) {
- IndexRecord* pir = m_pFile->m_irs.GetPrev(pos);
- if (pir->tStart <= rt / 10000) {
- m_seekpacket = pir->packet;
-
- pos = m_pFile->m_dcs.GetTailPosition();
- while (pos && !m_seekpos) {
- POSITION tmp = pos;
-
- DataChunk* pdc = m_pFile->m_dcs.GetPrev(pos);
-
- if (pdc->pos <= pir->ptrFilePos) {
- m_seekpos = tmp;
- m_seekfilepos = pir->ptrFilePos;
-
- POSITION pos = m_pFile->m_dcs.GetHeadPosition();
- while (pos != m_seekpos) {
- m_seekpacket -= m_pFile->m_dcs.GetNext(pos)->nPackets;
- }
- }
- }
-
- // search the closest keyframe to the seek time (commented out 'cause rm seems to index all of its keyframes...)
- /*
- if (m_seekpos)
- {
- DataChunk* pdc = m_pFile->m_dcs.GetAt(m_seekpos);
-
- m_pFile->Seek(m_seekfilepos);
-
- REFERENCE_TIME seektime = -1;
- UINT32 seekstream = -1;
-
- for (UINT32 i = m_seekpacket; i < pdc->nPackets; i++)
- {
- UINT64 filepos = m_pFile->GetPos();
-
- MediaPacketHeader mph;
- if (S_OK != m_pFile->Read(mph, false))
- break;
-
- if (seekstream == -1) seekstream = mph.stream;
- if (seekstream != mph.stream) continue;
-
- if (seektime == 10000i64*mph.tStart) continue;
- if (rt < 10000i64*mph.tStart) break;
-
- if ((mph.flags&MediaPacketHeader::PN_KEYFRAME_FLAG))
- {
- m_seekpacket = i;
- m_seekfilepos = filepos;
- seektime = 10000i64*mph.tStart;
- }
- }
- }
- */
- }
- }
-
- if (!m_seekpos) {
- m_seekpos = m_pFile->m_dcs.GetHeadPosition();
- m_seekpacket = 0;
- m_seekfilepos = m_pFile->m_dcs.GetAt(m_seekpos)->pos;
- }
- }
-}
-
-bool CRealMediaSplitterFilter::DemuxLoop()
-{
- HRESULT hr = S_OK;
- POSITION pos;
-
- pos = m_pFile->m_subs.GetHeadPosition();
- for (DWORD stream = 0; pos && SUCCEEDED(hr) && !CheckRequest(nullptr); stream++) {
- CRMFile::subtitle& s = m_pFile->m_subs.GetNext(pos);
-
- CAutoPtr<Packet> p(DEBUG_NEW Packet);
-
- p->TrackNumber = ~stream;
- p->bSyncPoint = TRUE;
- p->rtStart = 0;
- p->rtStop = 1;
-
- size_t count = (4 + 1) + (2 + 4 + (s.name.GetLength() + 1) * 2) + (2 + 4 + s.data.GetLength());
- p->SetCount(count);
- BYTE* ptr = p->GetData();
-
- strcpy_s((char*)ptr, count, "GAB2");
- ptr += 4 + 1;
- count -= 4 + 1;
-
- *(WORD*)ptr = 2;
- ptr += 2;
- count -= 2;
- *(DWORD*)ptr = (s.name.GetLength() + 1) * 2;
- ptr += 4;
- count -= 4;
- wcscpy_s((WCHAR*)ptr, count / 2, CStringW(s.name));
- ptr += (s.name.GetLength() + 1) * 2;
-
- *(WORD*)ptr = 4;
- ptr += 2;
- *(DWORD*)ptr = s.data.GetLength();
- ptr += 4;
- memcpy((char*)ptr, s.data, s.data.GetLength());
- ptr += s.name.GetLength();
-
- hr = DeliverPacket(p);
- }
-
- pos = m_seekpos;
- while (pos && SUCCEEDED(hr) && !CheckRequest(nullptr)) {
- DataChunk* pdc = m_pFile->m_dcs.GetNext(pos);
-
- m_pFile->Seek(m_seekfilepos > 0 ? m_seekfilepos : pdc->pos);
-
- for (UINT32 i = m_seekpacket; i < pdc->nPackets && SUCCEEDED(hr) && !CheckRequest(nullptr); i++) {
- MediaPacketHeader mph;
- if (S_OK != (hr = m_pFile->Read(mph))) {
- break;
- }
-
- CAutoPtr<Packet> p(DEBUG_NEW Packet);
- p->TrackNumber = mph.stream;
- p->bSyncPoint = !!(mph.flags & MediaPacketHeader::PN_KEYFRAME_FLAG);
- p->rtStart = 10000i64 * (mph.tStart);
- p->rtStop = p->rtStart + 1;
- p->Copy(mph.pData);
- hr = DeliverPacket(p);
- }
-
- m_seekpacket = 0;
- m_seekfilepos = 0;
- }
-
- return true;
-}
-
-// IKeyFrameInfo
-
-STDMETHODIMP CRealMediaSplitterFilter::GetKeyFrameCount(UINT& nKFs)
-{
- if (!m_pFile) {
- return E_UNEXPECTED;
- }
- nKFs = m_pFile->m_irs.GetCount();
- return S_OK;
-}
-
-STDMETHODIMP CRealMediaSplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs)
-{
- CheckPointer(pFormat, E_POINTER);
- CheckPointer(pKFs, E_POINTER);
-
- if (!m_pFile) {
- return E_UNEXPECTED;
- }
- if (*pFormat != TIME_FORMAT_MEDIA_TIME) {
- return E_INVALIDARG;
- }
-
- UINT nKFsTmp = 0;
- POSITION pos = m_pFile->m_irs.GetHeadPosition();
- for (int i = 0; pos && nKFsTmp < nKFs; i++) {
- pKFs[nKFsTmp++] = 10000i64 * m_pFile->m_irs.GetNext(pos)->tStart;
- }
- nKFs = nKFsTmp;
-
- return S_OK;
-}
-
-//
-// CRealMediaSplitterOutputPin
-//
-
-CRealMediaSplitterOutputPin::CRealMediaSplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseSplitterOutputPin(mts, pName, pFilter, pLock, phr, 0, MAXPACKETS_RV)
-{
-}
-
-CRealMediaSplitterOutputPin::~CRealMediaSplitterOutputPin()
-{
-}
-
-HRESULT CRealMediaSplitterOutputPin::DeliverEndFlush()
-{
- {
- CAutoLock cAutoLock(&m_csQueue);
- m_segments.Clear();
- }
-
- return __super::DeliverEndFlush();
-}
-
-HRESULT CRealMediaSplitterOutputPin::DeliverSegments()
-{
- HRESULT hr;
-
- if (m_segments.IsEmpty()) {
- m_segments.Clear();
- return S_OK;
- }
-
- CAutoPtr<Packet> p(DEBUG_NEW Packet());
-
- p->TrackNumber = (DWORD) - 1;
- p->bDiscontinuity = m_segments.fDiscontinuity;
- p->bSyncPoint = m_segments.fSyncPoint;
- p->rtStart = m_segments.rtStart;
- p->rtStop = m_segments.rtStart + 1;
-
- DWORD len = 0, total = 0;
- POSITION pos = m_segments.GetHeadPosition();
- while (pos) {
- segment* s = m_segments.GetNext(pos);
- len = max(len, s->offset + s->data.GetCount());
- total += s->data.GetCount();
- }
- ASSERT(len == total);
- len += 1 + 2 * 4 * (!m_segments.fMerged ? m_segments.GetCount() : 1);
-
- p->SetCount(len);
-
- BYTE* pData = p->GetData();
-
- *pData++ = m_segments.fMerged ? 0 : m_segments.GetCount() - 1;
-
- if (m_segments.fMerged) {
- *((DWORD*)pData) = 1;
- pData += 4;
- *((DWORD*)pData) = 0;
- pData += 4;
- } else {
- pos = m_segments.GetHeadPosition();
- while (pos) {
- *((DWORD*)pData) = 1;
- pData += 4;
- *((DWORD*)pData) = m_segments.GetNext(pos)->offset;
- pData += 4;
- }
- }
-
- pos = m_segments.GetHeadPosition();
- while (pos) {
- segment* s = m_segments.GetNext(pos);
- memcpy(pData + s->offset, s->data.GetData(), s->data.GetCount());
- }
-
- hr = __super::DeliverPacket(p);
-
- m_segments.Clear();
-
- return hr;
-}
-
-HRESULT CRealMediaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
-{
- HRESULT hr = S_OK;
-
- ASSERT(p->rtStart < p->rtStop);
-
- if (m_mt.subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3) {
- WORD* s = (WORD*)p->GetData();
- WORD* e = s + p->GetCount() / 2;
- while (s < e) {
- bswap(*s++);
- }
- }
-
- if (m_mt.subtype == MEDIASUBTYPE_RV10 || m_mt.subtype == MEDIASUBTYPE_RV20
- || m_mt.subtype == MEDIASUBTYPE_RV30 || m_mt.subtype == MEDIASUBTYPE_RV40
- || m_mt.subtype == MEDIASUBTYPE_RV41) {
- CAutoLock cAutoLock(&m_csQueue);
-
- int len = (int)p->GetCount();
- BYTE* pIn = p->GetData();
- BYTE* pInOrg = pIn;
-
- if (m_segments.rtStart != p->rtStart) {
- if (S_OK != (hr = DeliverSegments())) {
- return hr;
- }
- }
-
- if (!m_segments.fDiscontinuity && p->bDiscontinuity) {
- m_segments.fDiscontinuity = true;
- }
- m_segments.fSyncPoint = !!p->bSyncPoint;
- m_segments.rtStart = p->rtStart;
-
- while (pIn - pInOrg < len) {
- BYTE hdr = *pIn++;
- DWORD packetlen = 0, packetoffset = 0;
-
- if ((hdr & 0xc0) == 0x40) {
- pIn++;
- packetlen = len - (pIn - pInOrg);
- } else {
- if ((hdr & 0x40) == 0) {
- pIn++; //BYTE subseq = (*pIn++)&0x7f;
- }
-
-#define GetWORD(var) \
- var = (var << 8) | (*pIn++); \
- var = (var << 8) | (*pIn++);
-
- GetWORD(packetlen);
- if (packetlen & 0x8000) {
- m_segments.fMerged = true;
- }
- if ((packetlen & 0x4000) == 0) {
- GetWORD(packetlen);
- packetlen &= 0x3fffffff;
- } else {
- packetlen &= 0x3fff;
- }
-
- GetWORD(packetoffset);
- if ((packetoffset & 0x4000) == 0) {
- GetWORD(packetoffset);
- packetoffset &= 0x3fffffff;
- } else {
- packetoffset &= 0x3fff;
- }
-
-#undef GetWORD
-
- if ((hdr & 0xc0) == 0xc0) {
- m_segments.rtStart = 10000i64 * packetoffset - m_rtStart, packetoffset = 0;
- } else if ((hdr & 0xc0) == 0x80) {
- packetoffset = packetlen - packetoffset;
- }
-
- pIn++; //BYTE seqnum = *pIn++;
- }
-
- int len2 = min(len - (pIn - pInOrg), int(packetlen - packetoffset));
-
- CAutoPtr<segment> s(DEBUG_NEW segment);
- s->offset = packetoffset;
- s->data.SetCount(len2);
- memcpy(s->data.GetData(), pIn, len2);
- m_segments.AddTail(s);
-
- pIn += len2;
-
- if ((hdr & 0x80) || packetoffset + len2 >= packetlen) {
- if (S_OK != (hr = DeliverSegments())) {
- return hr;
- }
- }
- }
- } else if (m_mt.subtype == MEDIASUBTYPE_RAAC || m_mt.subtype == MEDIASUBTYPE_RACP
- || m_mt.subtype == MEDIASUBTYPE_AAC) {
- BYTE* ptr = p->GetData() + 2;
-
- CAtlList<WORD> sizes;
- int total = 0;
- int remaining = (int)p->GetCount() - 2;
- int expected = *(ptr - 1) >> 4;
-
- while (total < remaining) {
- int size = (ptr[0] << 8) | (ptr[1]);
- sizes.AddTail(size);
- total += size;
- ptr += 2;
- remaining -= 2;
- expected--;
- }
-
- ASSERT(total == remaining);
- ASSERT(expected == 0);
-
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
- REFERENCE_TIME rtDur = 10240000000i64 / wfe->nSamplesPerSec * (wfe->cbSize > 2 ? 2 : 1);
- REFERENCE_TIME rtStart = p->rtStart;
- BOOL bDiscontinuity = p->bDiscontinuity;
-
- POSITION pos = sizes.GetHeadPosition();
- while (pos) {
- WORD size = sizes.GetNext(pos);
-
- CAutoPtr<Packet> p(DEBUG_NEW Packet);
- p->bDiscontinuity = bDiscontinuity;
- p->bSyncPoint = true;
- p->rtStart = rtStart;
- p->rtStop = rtStart += rtDur;
- p->SetData(ptr, size);
- ptr += size;
- bDiscontinuity = false;
- if (S_OK != (hr = __super::DeliverPacket(p))) {
- break;
- }
- }
- } else {
- hr = __super::DeliverPacket(p);
- }
-
- return hr;
-}
-
-//
-// CRealMediaSourceFilter
-//
-
-CRealMediaSourceFilter::CRealMediaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CRealMediaSplitterFilter(pUnk, phr)
-{
- m_clsid = __uuidof(this);
- m_pInput.Free();
-}
-
-//
-// CRMFile
-//
-
-CRMFile::CRMFile(IAsyncReader* pAsyncReader, HRESULT& hr)
- : CBaseSplitterFile(pAsyncReader, hr)
-{
- if (FAILED(hr)) {
- return;
- }
- hr = Init();
-}
-
-template<typename T>
-HRESULT CRMFile::Read(T& var)
-{
- HRESULT hr = ByteRead((BYTE*)&var, sizeof(var));
- bswap(var);
- return hr;
-}
-
-HRESULT CRMFile::Read(ChunkHdr& hdr)
-{
- ZeroMemory(&hdr, sizeof(hdr));
- HRESULT hr;
- if (S_OK != (hr = Read(hdr.object_id))
- || S_OK != (hr = Read(hdr.size))
- || S_OK != (hr = Read(hdr.object_version))) {
- return hr;
- }
- return S_OK;
-}
-
-HRESULT CRMFile::Read(MediaPacketHeader& mph, bool fFull)
-{
- ZeroMemory(&mph, FIELD_OFFSET(MediaPacketHeader, pData));
- mph.stream = (UINT16) - 1;
-
- HRESULT hr;
-
- UINT16 object_version;
- if (S_OK != (hr = Read(object_version))) {
- return hr;
- }
- if (object_version != 0 && object_version != 1) {
- return S_OK;
- }
-
- UINT8 flags;
- if (S_OK != (hr = Read(mph.len))
- || S_OK != (hr = Read(mph.stream))
- || S_OK != (hr = Read(mph.tStart))
- || S_OK != (hr = Read(mph.reserved))
- || S_OK != (hr = Read(flags))) {
- return hr;
- }
- mph.flags = (MediaPacketHeader::flag_t)flags;
-
- LONG len = mph.len;
- len -= sizeof(object_version);
- len -= FIELD_OFFSET(MediaPacketHeader, flags);
- len -= sizeof(flags);
- ASSERT(len >= 0);
- len = max(len, 0);
-
- if (fFull) {
- mph.pData.SetCount(len);
- if (mph.len > 0 && S_OK != (hr = ByteRead(mph.pData.GetData(), len))) {
- return hr;
- }
- } else {
- Seek(GetPos() + len);
- }
-
- return S_OK;
-}
-
-HRESULT CRMFile::Init()
-{
- Seek(0);
-
- bool fFirstChunk = true;
-
- HRESULT hr;
-
- ChunkHdr hdr;
- while (GetRemaining() && S_OK == (hr = Read(hdr))) {
- __int64 pos = GetPos() - sizeof(hdr);
-
- if (fFirstChunk && hdr.object_id != '.RMF') {
- return E_FAIL;
- }
-
- fFirstChunk = false;
-
- if (pos + hdr.size > GetLength() && hdr.object_id != 'DATA') { // truncated?
- break;
- }
-
- if (hdr.object_id == 0x2E7261FD) { // '.ra+0xFD'
- return E_FAIL;
- }
-
- if (hdr.object_version == 0) {
- switch (hdr.object_id) {
- case '.RMF':
- if (S_OK != (hr = Read(m_fh.version))) {
- return hr;
- }
- if (hdr.size == 0x10) {
- WORD w = 0;
- if (S_OK != (hr = Read(w))) {
- return hr;
- }
- m_fh.nHeaders = w;
- } else if (S_OK != (hr = Read(m_fh.nHeaders))) {
- return hr;
- }
- break;
- case 'CONT':
- UINT16 slen;
- if (S_OK != (hr = Read(slen))) {
- return hr;
- }
- if (slen > 0 && S_OK != (hr = ByteRead((BYTE*)m_cd.title.GetBufferSetLength(slen), slen))) {
- return hr;
- }
- if (S_OK != (hr = Read(slen))) {
- return hr;
- }
- if (slen > 0 && S_OK != (hr = ByteRead((BYTE*)m_cd.author.GetBufferSetLength(slen), slen))) {
- return hr;
- }
- if (S_OK != (hr = Read(slen))) {
- return hr;
- }
- if (slen > 0 && S_OK != (hr = ByteRead((BYTE*)m_cd.copyright.GetBufferSetLength(slen), slen))) {
- return hr;
- }
- if (S_OK != (hr = Read(slen))) {
- return hr;
- }
- if (slen > 0 && S_OK != (hr = ByteRead((BYTE*)m_cd.comment.GetBufferSetLength(slen), slen))) {
- return hr;
- }
- break;
- case 'PROP':
- if (S_OK != (hr = Read(m_p.maxBitRate))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.avgBitRate))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.maxPacketSize))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.avgPacketSize))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.nPackets))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.tDuration))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.tPreroll))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.ptrIndex))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.ptrData))) {
- return hr;
- }
- if (S_OK != (hr = Read(m_p.nStreams))) {
- return hr;
- }
- UINT16 flags;
- if (S_OK != (hr = Read(flags))) {
- return hr;
- }
- m_p.flags = (Properies::flags_t)flags;
- break;
- case 'MDPR': {
- CAutoPtr<MediaProperies> mp(DEBUG_NEW MediaProperies);
- if (S_OK != (hr = Read(mp->stream))) {
- return hr;
- }
- if (S_OK != (hr = Read(mp->maxBitRate))) {
- return hr;
- }
- if (S_OK != (hr = Read(mp->avgBitRate))) {
- return hr;
- }
- if (S_OK != (hr = Read(mp->maxPacketSize))) {
- return hr;
- }
- if (S_OK != (hr = Read(mp->avgPacketSize))) {
- return hr;
- }
- if (S_OK != (hr = Read(mp->tStart))) {
- return hr;
- }
- if (S_OK != (hr = Read(mp->tPreroll))) {
- return hr;
- }
- if (S_OK != (hr = Read(mp->tDuration))) {
- return hr;
- }
- UINT8 len;
- if (S_OK != (hr = Read(len))) {
- return hr;
- }
- if (len > 0 && S_OK != (hr = ByteRead((BYTE*)mp->name.GetBufferSetLength(len), len))) {
- return hr;
- }
- if (S_OK != (hr = Read(len))) {
- return hr;
- }
- if (len > 0 && S_OK != (hr = ByteRead((BYTE*)mp->mime.GetBufferSetLength(len), len))) {
- return hr;
- }
- UINT32 tsdlen;
- if (S_OK != (hr = Read(tsdlen))) {
- return hr;
- }
- mp->typeSpecData.SetCount(tsdlen);
- if (tsdlen > 0 && S_OK != (hr = ByteRead(mp->typeSpecData.GetData(), tsdlen))) {
- return hr;
- }
- mp->width = mp->height = 0;
- mp->interlaced = mp->top_field_first = false;
- m_mps.AddTail(mp);
- break;
- }
- case 'DATA': {
- CAutoPtr<DataChunk> dc(DEBUG_NEW DataChunk);
- if (S_OK != (hr = Read(dc->nPackets))) {
- return hr;
- }
- if (S_OK != (hr = Read(dc->ptrNext))) {
- return hr;
- }
- dc->pos = GetPos();
- m_dcs.AddTail(dc);
- GetDimensions();
- break;
- }
- case 'INDX': {
- IndexChunkHeader ich;
- if (S_OK != (hr = Read(ich.nIndices))) {
- return hr;
- }
- if (S_OK != (hr = Read(ich.stream))) {
- return hr;
- }
- if (S_OK != (hr = Read(ich.ptrNext))) {
- return hr;
- }
- int stream = GetMasterStream();
- while (ich.nIndices-- > 0) {
- UINT16 object_version;
- if (S_OK != (hr = Read(object_version))) {
- return hr;
- }
- if (object_version == 0) {
- CAutoPtr<IndexRecord> ir(DEBUG_NEW IndexRecord);
- if (S_OK != (hr = Read(ir->tStart))) {
- return hr;
- }
- if (S_OK != (hr = Read(ir->ptrFilePos))) {
- return hr;
- }
- if (S_OK != (hr = Read(ir->packet))) {
- return hr;
- }
- if (ich.stream == stream) {
- m_irs.AddTail(ir);
- }
- }
- }
- break;
- }
- case '.SUB':
- if (hdr.size > sizeof(hdr)) {
- int size = hdr.size - sizeof(hdr);
- CAutoVectorPtr<char> buff;
- if (!buff.Allocate(size)) {
- return E_OUTOFMEMORY;
- }
- char* p = buff;
- if (S_OK != (hr = ByteRead((BYTE*)p, size))) {
- return hr;
- }
- for (char* end = p + size; p < end;) {
- subtitle s;
- s.name = p;
- p += s.name.GetLength() + 1;
- CStringA len(p);
- p += len.GetLength() + 1;
- s.data = CStringA(p, strtol(len, nullptr, 10));
- p += s.data.GetLength();
- m_subs.AddTail(s);
- }
- }
- break;
- }
- }
-
- if (hdr.object_id == 'CONT' && BitRead(32, true) == 'DATA') {
- hdr.size = GetPos() - pos;
- }
-
- ASSERT(hdr.object_id == 'DATA'
- || GetPos() == pos + hdr.size
- || GetPos() == pos + sizeof(hdr));
-
- pos += hdr.size;
- if (pos > GetPos()) {
- Seek(pos);
- }
- }
-
- return S_OK;
-}
-
-#define GetBits(n) GetBits2(n, p, bit_offset, bit_buffer)
-
-unsigned int GetBits2(int n, unsigned char*& p, unsigned int& bit_offset, unsigned int& bit_buffer)
-{
- unsigned int ret = ((unsigned int)bit_buffer >> (32 - (n)));
-
- bit_offset += n;
- bit_buffer <<= n;
- if (bit_offset > (32 - 16)) {
- p += bit_offset >> 3;
- bit_offset &= 7;
- bit_buffer = (unsigned int)p[0] << 24;
- bit_buffer |= (unsigned int)p[1] << 16;
- bit_buffer |= (unsigned int)p[2] << 8;
- bit_buffer |= (unsigned int)p[3];
- bit_buffer <<= bit_offset;
- }
-
- return ret;
-}
-
-void GetDimensions(unsigned char* p, unsigned int* wi, unsigned int* hi)
-{
- unsigned int w, h, c;
-
- const unsigned int cw[8] = {160, 176, 240, 320, 352, 640, 704, 0};
- const unsigned int ch1[8] = {120, 132, 144, 240, 288, 480, 0, 0};
- const unsigned int ch2[4] = {180, 360, 576, 0};
-
- unsigned int bit_offset = 0;
- unsigned int bit_buffer = *(unsigned int*)p;
- bswap(bit_buffer);
-
- GetBits(13);
-
- GetBits(13);
-
- w = cw[GetBits(3)];
- if (w == 0) {
- do {
- c = GetBits(8);
- w += (c << 2);
- } while (c == 255);
- }
-
- c = GetBits(3);
-
- h = ch1[c];
- if (h == 0) {
- c = ((c << 1) | GetBits(1)) & 3;
-
- h = ch2[c];
- if (h == 0) {
- do {
- c = GetBits(8);
- h += (c << 2);
- } while (c == 255);
- }
- }
-
- *wi = w;
- *hi = h;
-}
-
-void GetDimensions_X10(unsigned char* p, unsigned int* wi, unsigned int* hi,
- bool* interlaced, bool* top_field_first, bool* repeat_field)
-{
- unsigned int w, h, c;
-
- const unsigned int cw[8] = {160, 176, 240, 320, 352, 640, 704, 0};
- const unsigned int ch1[8] = {120, 132, 144, 240, 288, 480, 0, 0};
- const unsigned int ch2[4] = {180, 360, 576, 0};
-
- unsigned int bit_offset = 0;
- unsigned int bit_buffer = *(unsigned int*)p;
- bswap(bit_buffer);
-
- GetBits(9);
-
- *interlaced = false;
- *top_field_first = false;
- *repeat_field = false;
- c = GetBits(1);
- if (c) {
- c = GetBits(1);
- if (c) {
- *interlaced = true;
- }
- c = GetBits(1);
- if (c) {
- *top_field_first = true;
- }
- c = GetBits(1);
- if (c) {
- *repeat_field = true;
- }
-
- c = GetBits(1);
- c = GetBits(1);
- if (c) {
- GetBits(2);
- }
- }
-
- GetBits(16);
-
- w = cw[GetBits(3)];
- if (w == 0) {
- do {
- c = GetBits(8);
- w += (c << 2);
- } while (c == 255);
- }
-
- c = GetBits(3);
-
- h = ch1[c];
- if (h == 0) {
- c = ((c << 1) | GetBits(1)) & 3;
-
- h = ch2[c];
- if (h == 0) {
- do {
- c = GetBits(8);
- h += (c << 2);
- } while (c == 255);
- }
- }
-
- *wi = w;
- *hi = h;
-}
-
-void CRMFile::GetDimensions()
-{
- POSITION pos = m_mps.GetHeadPosition();
- while (pos) {
- UINT64 filepos = GetPos();
-
- MediaProperies* pmp = m_mps.GetNext(pos);
- if (pmp->mime == "video/x-pn-realvideo") {
- pmp->width = pmp->height = 0;
-
- rvinfo rvi = *(rvinfo*)pmp->typeSpecData.GetData();
- rvi.bswap();
-
- if (rvi.fcc2 != '04VR' && rvi.fcc2 != '14VR') {
- continue;
- }
-
- MediaPacketHeader mph;
- while (S_OK == Read(mph)) {
- if (mph.stream != pmp->stream || mph.len == 0
- || !(mph.flags & MediaPacketHeader::PN_KEYFRAME_FLAG)) {
- continue;
- }
-
- BYTE* p = mph.pData.GetData();
- BYTE* p0 = p;
- int len = (int)mph.pData.GetCount();
-
- BYTE hdr = *p++;
- DWORD packetlen = 0, packetoffset = 0;
-
- if ((hdr & 0xc0) == 0x40) {
- packetlen = len - (++p - p0);
- } else {
- if ((hdr & 0x40) == 0) {
- p++;
- }
-
-#define GetWORD(var) \
- var = (var << 8) | (*p++); \
- var = (var << 8) | (*p++);
-
- GetWORD(packetlen);
- if ((packetlen & 0x4000) == 0) {
- GetWORD(packetlen);
- packetlen &= 0x3fffffff;
- } else {
- packetlen &= 0x3fff;
- }
-
- GetWORD(packetoffset);
- if ((packetoffset & 0x4000) == 0) {
- GetWORD(packetoffset);
- packetoffset &= 0x3fffffff;
- } else {
- packetoffset &= 0x3fff;
- }
-
-#undef GetWORD
-
- if ((hdr & 0xc0) == 0xc0) {
- packetoffset = 0;
- } else if ((hdr & 0xc0) == 0x80) {
- packetoffset = packetlen - packetoffset;
- }
-
- p++;
- }
-
- len = min(len - (p - p0), int(packetlen - packetoffset));
-
- if (len > 0) {
- bool repeat_field;
- if (rvi.fcc2 == '14VR') {
- ::GetDimensions_X10(p, &pmp->width, &pmp->height, &pmp->interlaced, &pmp->top_field_first, &repeat_field);
- } else {
- ::GetDimensions(p, &pmp->width, &pmp->height);
- }
-
- if (rvi.w == pmp->width && rvi.h == pmp->height) {
- pmp->width = pmp->height = 0;
- }
-
- break;
- }
- }
- }
-
- Seek(filepos);
- }
-}
-
-int CRMFile::GetMasterStream()
-{
- int s1 = -1, s2 = -1;
-
- POSITION pos = m_mps.GetHeadPosition();
- while (pos) {
- MediaProperies* pmp = m_mps.GetNext(pos);
- if (pmp->mime == "video/x-pn-realvideo") {
- s1 = pmp->stream;
- break;
- } else if (pmp->mime == "audio/x-pn-realaudio" && s2 == -1) {
- s2 = pmp->stream;
- }
- }
-
- if (s1 == -1) {
- s1 = s2;
- }
-
- return s1;
-}
-
-
-////////////////////////////
-
-//
-// CRealVideoDecoder
-//
-
-CRealVideoDecoder::CRealVideoDecoder(LPUNKNOWN lpunk, HRESULT* phr)
- : CBaseVideoFilter(NAME("CRealVideoDecoder"), lpunk, phr, __uuidof(this))
- , m_hDrvDll(nullptr)
- , m_dwCookie(0)
- , m_lastBuffSizeDim(0)
-{
-}
-
-CRealVideoDecoder::~CRealVideoDecoder()
-{
- if (m_hDrvDll) {
- FreeLibrary(m_hDrvDll);
- }
-}
-
-HRESULT CRealVideoDecoder::InitRV(const CMediaType* pmt)
-{
- FreeRV();
-
- HRESULT hr = VFW_E_TYPE_NOT_ACCEPTED;
-
- rvinfo rvi = *(rvinfo*)(pmt->Format() + (pmt->formattype == FORMAT_VideoInfo ? sizeof(VIDEOINFOHEADER) : sizeof(VIDEOINFOHEADER2)));
- rvi.bswap();
-
-#pragma pack(push, 1)
- struct {
- WORD unk1, w, h, unk3;
- DWORD unk2, subformat, unk5, format;
- } i =
- {11, rvi.w, rvi.h, 0, 0, rvi.type1, 1, rvi.type2};
-#pragma pack(pop)
-
- if (FAILED(hr = RVInit(&i, &m_dwCookie))) {
- return hr;
- }
-
- if (rvi.fcc2 <= '03VR' && rvi.type2 >= 0x20200002) {
- int nWidthHeight = (1 + ((rvi.type1 >> 16) & 7));
- UINT32* pWH = DEBUG_NEW UINT32[nWidthHeight * 2];
- pWH[0] = rvi.w;
- pWH[1] = rvi.h;
- for (int j = 2; j < nWidthHeight * 2; j++) {
- pWH[j] = rvi.morewh[j - 2] * 4;
- }
-#pragma pack(push, 1)
- struct {
- UINT32 data1;
- UINT32 data2;
- UINT32* dimensions;
- } cmsg_data =
- {0x24, nWidthHeight, pWH};
-#pragma pack(pop)
- hr = RVCustomMessage(&cmsg_data, m_dwCookie);
- delete [] pWH;
- }
-
- return hr;
-}
-
-void CRealVideoDecoder::FreeRV()
-{
- if (m_dwCookie) {
- RVFree(m_dwCookie);
- m_dwCookie = 0;
- }
-}
-
-HRESULT CRealVideoDecoder::Transform(IMediaSample* pIn)
-{
- CAutoLock cAutoLock(&m_csReceive);
-
- HRESULT hr;
-
- BYTE* pDataIn = nullptr;
- if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
- return hr;
- }
-
- long len = pIn->GetActualDataLength();
- if (len <= 0) {
- return S_OK; // nothing to do
- }
-
- REFERENCE_TIME rtStart, rtStop;
- pIn->GetTime(&rtStart, &rtStop);
-
- rtStart += m_tStart;
-
- int offset = 1 + ((*pDataIn) + 1) * 8;
-
-#pragma pack(push, 1)
- struct {
- DWORD len, unk1, chunks;
- DWORD* extra;
- DWORD unk2, timestamp;
- } transform_in =
- {len - offset, 0, *pDataIn, (DWORD*)(pDataIn + 1), 0, (DWORD)(rtStart / 10000)};
- struct {
- DWORD unk1, unk2, timestamp, w, h;
- } transform_out =
- {0, 0, 0, 0, 0};
-#pragma pack(pop)
-
- pDataIn += offset;
-
- if (m_fDropFrames && m_timestamp + 1 == transform_in.timestamp) {
- m_timestamp = transform_in.timestamp;
- return S_OK;
- }
-
-
- unsigned int tmp1, tmp2;
- bool interlaced = false, tmp3, tmp4;
- ::GetDimensions_X10(pDataIn, &tmp1, &tmp2, &interlaced, &tmp3, &tmp4);
-
- int size = tmp1 * tmp2;
- if (m_lastBuffSizeDim < size) {
- _aligned_free(m_pI420);
- _aligned_free(m_pI420Tmp);
-
- m_lastBuffSizeDim = size;
- TRACE(_T("resize out put buff %d") , size);
- m_pI420 = static_cast<BYTE*>(_aligned_malloc(size * 3 / 2, 16));
- if (m_pI420) {
- TRACE(_T(" m_pI420.Allocated 1"));
- ZeroMemory(m_pI420, size);
- TRACE(_T(" m_pI420.Allocated 2"));
- memset(m_pI420 + size, 0x80, size / 2);
- TRACE(_T(" m_pI420.Allocated 3"));
- } else {
- TRACE(_T(" m_pI420.Allocate fail %d") , size * 3 / 2);
- return S_OK;
- }
- m_pI420Tmp = static_cast<BYTE*>(_aligned_malloc(size * 3 / 2, 16));
- if (m_pI420Tmp) {
- TRACE(_T(" m_pI420Tmp.Allocated 1"));
- ZeroMemory(m_pI420Tmp, size);
- TRACE(_T(" m_pI420Tmp.Allocated 2"));
- memset(m_pI420Tmp + size, 0x80, size / 2);
- TRACE(_T(" m_pI420Tmp.Allocated 3"));
- } else {
- TRACE(_T(" m_pI420Tmp.Allocate fail %d") , size * 3 / 2);
- return S_OK;
- }
- }
-
- hr = RVTransform(pDataIn, (BYTE*)m_pI420, &transform_in, &transform_out, m_dwCookie);
-
- m_timestamp = transform_in.timestamp;
-
- if (FAILED(hr)) {
- TRACE(_T("RV returned an error code!!!\n"));
- ASSERT(!(transform_out.unk1 & 1)); // error allowed when the "render" flag is not set
- // return hr;
- }
-
- if (pIn->IsPreroll() == S_OK || rtStart < 0 || !(transform_out.unk1 & 1)) {
- return S_OK;
- }
-
- CComPtr<IMediaSample> pOut;
- BYTE* pDataOut = nullptr;
- if (/*FAILED(hr = GetDeliveryBuffer(transform_out.w, transform_out.h, &pOut)) // TODO
- && */ FAILED(hr = GetDeliveryBuffer(m_w, m_h, &pOut))
- || FAILED(hr = pOut->GetPointer(&pDataOut))) {
- return hr;
- }
-
- BYTE* pI420[3] = {m_pI420, m_pI420Tmp, nullptr};
-
- if (interlaced) {
- int iSize = m_w * m_h;
- DeinterlaceBlend(pI420[1], pI420[0], m_w, m_h, m_w, m_w);
- DeinterlaceBlend(pI420[1] + iSize, pI420[0] + iSize, m_w / 2, m_h / 2, m_w / 2, m_w / 2);
- DeinterlaceBlend(pI420[1] + iSize * 5 / 4, pI420[0] + iSize * 5 / 4, m_w / 2, m_h / 2, m_w / 2, m_w / 2);
- pI420[2] = pI420[1], pI420[1] = pI420[0], pI420[0] = pI420[2];
- }
-
- if (transform_out.w != m_w || transform_out.h != m_h) {
- Resize(pI420[0], transform_out.w, transform_out.h, pI420[1], m_w, m_h);
- // only one of these can be true, and when it happens the result image must be in the tmp buffer
- if (transform_out.w == m_w || transform_out.h == m_h) {
- pI420[2] = pI420[1], pI420[1] = pI420[0], pI420[0] = pI420[2];
- }
- }
-
- rtStart = 10000i64 * transform_out.timestamp - m_tStart;
- rtStop = rtStart + 1;
- pOut->SetTime(&rtStart, /*nullptr*/&rtStop);
-
- pOut->SetDiscontinuity(pIn->IsDiscontinuity() == S_OK);
-
- CopyBuffer(pDataOut, pI420[0], m_w, m_h, m_w, MEDIASUBTYPE_I420);
-
- DbgLog((LOG_TRACE, 0, _T("V: rtStart=%I64d, rtStop=%I64d, disc=%d, sync=%d"),
- rtStart, rtStop, pOut->IsDiscontinuity() == S_OK, pOut->IsSyncPoint() == S_OK));
-
- return m_pOutput->Deliver(pOut);
-}
-
-void CRealVideoDecoder::Resize(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD wo, DWORD ho)
-{
- int si = wi * hi, so = wo * ho;
- ASSERT(((si * so) & 3) == 0);
-
- if (wi < wo) {
- ResizeWidth(pIn, wi, hi, pOut, wo, ho);
- ResizeWidth(pIn + si, wi / 2, hi / 2, pOut + so, wo / 2, ho / 2);
- ResizeWidth(pIn + si + si / 4, wi / 2, hi / 2, pOut + so + so / 4, wo / 2, ho / 2);
- if (hi == ho) {
- return;
- }
- ResizeHeight(pOut, wo, hi, pIn, wo, ho);
- ResizeHeight(pOut + so, wo / 2, hi / 2, pIn + so, wo / 2, ho / 2);
- ResizeHeight(pOut + so + so / 4, wo / 2, hi / 2, pIn + so + so / 4, wo / 2, ho / 2);
- } else if (hi < ho) {
- ResizeHeight(pIn, wi, hi, pOut, wo, ho);
- ResizeHeight(pIn + si, wi / 2, hi / 2, pOut + so, wo / 2, ho / 2);
- ResizeHeight(pIn + si + si / 4, wi / 2, hi / 2, pOut + so + so / 4, wo / 2, ho / 2);
- if (wi == wo) {
- return;
- }
- ASSERT(0); // this is uncreachable code, but anyway... looks nice being so symmetric
- ResizeWidth(pOut, wi, ho, pIn, wo, ho);
- ResizeWidth(pOut + so, wi / 2, ho / 2, pIn + so, wo / 2, ho / 2);
- ResizeWidth(pOut + so + so / 4, wi / 2, ho / 2, pIn + so + so / 4, wo / 2, ho / 2);
- }
-}
-
-void CRealVideoDecoder::ResizeWidth(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD wo, DWORD ho)
-{
- for (DWORD y = 0; y < hi; y++, pIn += wi, pOut += wo) {
- if (wi == wo) {
- memcpy(pOut, pIn, wo);
- } else {
- ResizeRow(pIn, wi, 1, pOut, wo, 1);
- }
- }
-}
-
-void CRealVideoDecoder::ResizeHeight(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD wo, DWORD ho)
-{
- if (hi == ho) {
- memcpy(pOut, pIn, wo * ho);
- } else {
- for (DWORD x = 0; x < wo; x++, pIn++, pOut++) {
- ResizeRow(pIn, hi, wo, pOut, ho, wo);
- }
- }
-}
-
-void CRealVideoDecoder::ResizeRow(BYTE* pIn, DWORD wi, DWORD dpi, BYTE* pOut, DWORD wo, DWORD dpo)
-{
- ASSERT(wi < wo);
-
- if (dpo == 1) {
- for (DWORD i = 0, j = 0, dj = (wi << 16) / wo; i < wo - 1; i++, pOut++, j += dj)
- // pOut[i] = pIn[j>>16];
- {
- BYTE* p = &pIn[j >> 16];
- DWORD jf = j & 0xffff;
- *pOut = ((p[0] * (0xffff - jf) + p[1] * jf) + 0x7fff) >> 16;
- }
-
- *pOut = pIn[wi - 1];
- } else {
- for (DWORD i = 0, j = 0, dj = (wi << 16) / wo; i < wo - 1; i++, pOut += dpo, j += dj)
- // *pOut = pIn[dpi*(j>>16)];
- {
- BYTE* p = &pIn[dpi * (j >> 16)];
- DWORD jf = j & 0xffff;
- *pOut = ((p[0] * (0xffff - jf) + p[dpi] * jf) + 0x7fff) >> 16;
- }
-
- *pOut = pIn[dpi * (wi - 1)];
- }
-}
-
-HRESULT CRealVideoDecoder::CheckInputType(const CMediaType* mtIn)
-{
- if (mtIn->majortype != MEDIATYPE_Video
- || mtIn->subtype != MEDIASUBTYPE_RV20
- && mtIn->subtype != MEDIASUBTYPE_RV30
- && mtIn->subtype != MEDIASUBTYPE_RV40
- && mtIn->subtype != MEDIASUBTYPE_RV41) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- if (mtIn->formattype == FORMAT_VideoInfo2) {
- VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mtIn->Format();
- if (vih2->dwPictAspectRatioX < (DWORD)vih2->bmiHeader.biWidth
- || vih2->dwPictAspectRatioY < (DWORD)vih2->bmiHeader.biHeight) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- }
-
- if (!m_pInput->IsConnected()) {
- if (m_hDrvDll) {
- FreeLibrary(m_hDrvDll);
- m_hDrvDll = nullptr;
- }
-
- CAtlList<CString> paths;
- CString olddll, newdll, oldpath, newpath;
-
- olddll.Format(_T("drv%c3260.dll"), (TCHAR)((mtIn->subtype.Data1 >> 16) & 0xff));
- newdll =
- mtIn->subtype == FOURCCMap('14VR') ? _T("drvi.dll") :
- mtIn->subtype == FOURCCMap('02VR') ? _T("drv2.dll") :
- _T("drvc.dll");
-
- CRegKey key;
- TCHAR buff[MAX_PATH];
- ULONG len = sizeof(buff);
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Software\\RealNetworks\\Preferences\\DT_Codecs"), KEY_READ)
- && ERROR_SUCCESS == key.QueryStringValue(nullptr, buff, &len) && _tcslen(buff) > 0) {
- oldpath = buff;
- TCHAR c = oldpath[oldpath.GetLength() - 1];
- if (c != '\\' && c != '/') {
- oldpath += '\\';
- }
- key.Close();
- }
- len = sizeof(buff);
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Helix\\HelixSDK\\10.0\\Preferences\\DT_Codecs"), KEY_READ)
- && ERROR_SUCCESS == key.QueryStringValue(nullptr, buff, &len) && _tcslen(buff) > 0) {
- newpath = buff;
- TCHAR c = newpath[newpath.GetLength() - 1];
- if (c != '\\' && c != '/') {
- newpath += '\\';
- }
- key.Close();
- }
-
- if (!newpath.IsEmpty()) {
- paths.AddTail(newpath + newdll);
- }
- if (!oldpath.IsEmpty()) {
- paths.AddTail(oldpath + newdll);
- }
- paths.AddTail(newdll); // default dll paths
- if (!newpath.IsEmpty()) {
- paths.AddTail(newpath + olddll);
- }
- if (!oldpath.IsEmpty()) {
- paths.AddTail(oldpath + olddll);
- }
- paths.AddTail(olddll); // default dll paths
-
- POSITION pos = paths.GetHeadPosition();
- do {
- if (pos) {
- m_hDrvDll = LoadLibrary(paths.GetNext(pos));
- }
- } while (pos && !m_hDrvDll);
-
- if (m_hDrvDll) {
- RVCustomMessage = (PRVCustomMessage)GetProcAddress(m_hDrvDll, "RV20toYUV420CustomMessage");
- RVFree = (PRVFree)GetProcAddress(m_hDrvDll, "RV20toYUV420Free");
- RVHiveMessage = (PRVHiveMessage)GetProcAddress(m_hDrvDll, "RV20toYUV420HiveMessage");
- RVInit = (PRVInit)GetProcAddress(m_hDrvDll, "RV20toYUV420Init");
- RVTransform = (PRVTransform)GetProcAddress(m_hDrvDll, "RV20toYUV420Transform");
-
- if (!RVCustomMessage) {
- RVCustomMessage = (PRVCustomMessage)GetProcAddress(m_hDrvDll, "RV40toYUV420CustomMessage");
- }
- if (!RVFree) {
- RVFree = (PRVFree)GetProcAddress(m_hDrvDll, "RV40toYUV420Free");
- }
- if (!RVHiveMessage) {
- RVHiveMessage = (PRVHiveMessage)GetProcAddress(m_hDrvDll, "RV40toYUV420HiveMessage");
- }
- if (!RVInit) {
- RVInit = (PRVInit)GetProcAddress(m_hDrvDll, "RV40toYUV420Init");
- }
- if (!RVTransform) {
- RVTransform = (PRVTransform)GetProcAddress(m_hDrvDll, "RV40toYUV420Transform");
- }
- }
-
- if (!m_hDrvDll || !RVCustomMessage
- || !RVFree || !RVHiveMessage
- || !RVInit || !RVTransform) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- if (FAILED(InitRV(mtIn))) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- }
-
- return S_OK;
-}
-
-HRESULT CRealVideoDecoder::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
-{
- if (m_pOutput && m_pOutput->IsConnected()) {
- BITMAPINFOHEADER bih1, bih2;
- if (ExtractBIH(mtOut, &bih1) && ExtractBIH(&m_pOutput->CurrentMediaType(), &bih2)
- && abs(bih1.biHeight) != abs(bih2.biHeight)) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- }
-
- return __super::CheckTransform(mtIn, mtOut);
-}
-
-HRESULT CRealVideoDecoder::StartStreaming()
-{
- const CMediaType& mt = m_pInput->CurrentMediaType();
- if (FAILED(InitRV(&mt))) {
- return E_FAIL;
- }
-
- int size = m_w * m_h;
- m_lastBuffSizeDim = size;
- m_pI420 = static_cast<BYTE*>(_aligned_malloc(size * 3 / 2, 16));
- ZeroMemory(m_pI420, size);
- memset(m_pI420 + size, 0x80, size / 2);
- m_pI420Tmp = static_cast<BYTE*>(_aligned_malloc(size * 3 / 2, 16));
- ZeroMemory(m_pI420Tmp, size);
- memset(m_pI420Tmp + size, 0x80, size / 2);
-
- return __super::StartStreaming();
-}
-
-HRESULT CRealVideoDecoder::StopStreaming()
-{
- _aligned_free(m_pI420);
- _aligned_free(m_pI420Tmp);
-
- FreeRV();
-
- return __super::StopStreaming();
-}
-
-HRESULT CRealVideoDecoder::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
-{
- CAutoLock cAutoLock(&m_csReceive);
-
- m_timestamp = (DWORD)~0;
- m_fDropFrames = false;
-
- DWORD tmp[2] = {20, 0};
- RVHiveMessage(tmp, m_dwCookie);
-
- m_tStart = tStart;
- return __super::NewSegment(tStart, tStop, dRate);
-}
-
-HRESULT CRealVideoDecoder::AlterQuality(Quality q)
-{
- if (q.Late > 500 * 10000i64) {
- m_fDropFrames = true;
- }
- if (q.Late <= 0) {
- m_fDropFrames = false;
- }
- // TRACE(_T("CRealVideoDecoder::AlterQuality: Type=%d, Proportion=%d, Late=%I64d, TimeStamp=%I64d\n"), q.Type, q.Proportion, q.Late, q.TimeStamp);
- return E_NOTIMPL;
-}
-
-/////////////////////////
-
-//
-// CRealAudioDecoder
-//
-
-CRealAudioDecoder::CRealAudioDecoder(LPUNKNOWN lpunk, HRESULT* phr)
- : CTransformFilter(NAME("CRealAudioDecoder"), lpunk, __uuidof(this))
- , m_hDrvDll(nullptr)
- , m_dwCookie(0)
-{
- if (phr) {
- *phr = S_OK;
- }
-}
-
-CRealAudioDecoder::~CRealAudioDecoder()
-{
- // FreeRA();
- if (m_hDrvDll) {
- FreeLibrary(m_hDrvDll);
- }
-}
-
-HRESULT CRealAudioDecoder::InitRA(const CMediaType* pmt)
-{
- FreeRA();
-
- HRESULT hr;
-
- if (RAOpenCodec2 && FAILED(hr = RAOpenCodec2(&m_dwCookie, m_dllpath))
- || RAOpenCodec && FAILED(hr = RAOpenCodec(&m_dwCookie))) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- WAVEFORMATEX* pwfe = (WAVEFORMATEX*)pmt->Format();
-
- // someone might be doing cbSize = sizeof(WAVEFORMATEX), chances of
- // cbSize being really sizeof(WAVEFORMATEX) is less than this,
- // especially with our rm splitter ;)
- DWORD cbSize = pwfe->cbSize;
- if (cbSize == sizeof(WAVEFORMATEX)) {
- ASSERT(0);
- cbSize = 0;
- }
-
- WORD wBitsPerSample = pwfe->wBitsPerSample;
- if (!wBitsPerSample) {
- wBitsPerSample = 16;
- }
-
-#pragma pack(push, 1)
- struct {
- DWORD freq;
- WORD bpsample, channels, quality;
- DWORD bpframe, packetsize, extralen;
- void* extra;
- } initdata = {
- pwfe->nSamplesPerSec, wBitsPerSample, pwfe->nChannels, 100,
- 0, 0, 0, nullptr
- };
-#pragma pack(pop)
-
- CAutoVectorPtr<BYTE> pBuff;
-
- if (pmt->subtype == MEDIASUBTYPE_AAC) {
- pBuff.Allocate(cbSize + 1);
- pBuff[0] = 0x02;
- memcpy(pBuff + 1, pwfe + 1, cbSize);
- initdata.extralen = cbSize + 1;
- initdata.extra = pBuff;
- } else {
- if (pmt->FormatLength() <= sizeof(WAVEFORMATEX) + cbSize) { // must have type_specific_data appended
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- BYTE* fmt = pmt->Format() + sizeof(WAVEFORMATEX) + cbSize;
-
- for (int i = 0, len = pmt->FormatLength() - (sizeof(WAVEFORMATEX) + cbSize); i < len - 4; i++, fmt++) {
- if (fmt[0] == '.' || fmt[1] == 'r' || fmt[2] == 'a') {
- break;
- }
- }
-
- m_rai = *(rainfo*)fmt;
- m_rai.bswap();
-
- BYTE* p;
-
- if (m_rai.version2 == 4) {
- p = (BYTE*)((rainfo4*)fmt + 1);
- int len = *p++;
- p += len;
- len = *p++;
- p += len;
- ASSERT(len == 4);
- } else if (m_rai.version2 == 5) {
- p = (BYTE*)((rainfo5*)fmt + 1);
- } else {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- p += 3;
- if (m_rai.version2 == 5) {
- p++;
- }
-
- initdata.bpframe = m_rai.sub_packet_size;
- initdata.packetsize = m_rai.coded_frame_size;
- initdata.extralen = min((pmt->Format() + pmt->FormatLength()) - (p + 4), (LONG) * (DWORD*)p);
- initdata.extra = p + 4;
- }
-
- if (FAILED(hr = RAInitDecoder(m_dwCookie, &initdata))) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- if (RASetPwd) {
- RASetPwd(m_dwCookie, "Ardubancel Quazanga");
- }
-
- if (RASetFlavor && FAILED(hr = RASetFlavor(m_dwCookie, m_rai.flavor))) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- return S_OK;
-}
-
-void CRealAudioDecoder::FreeRA()
-{
- if (m_dwCookie) {
- RAFreeDecoder(m_dwCookie);
- RACloseCodec(m_dwCookie);
- m_dwCookie = 0;
- }
-}
-
-HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn)
-{
- CAutoLock cAutoLock(&m_csReceive);
-
- HRESULT hr;
-
- AM_SAMPLE2_PROPERTIES* const pProps = m_pInput->SampleProps();
- if (pProps->dwStreamId != AM_STREAM_MEDIA) {
- return m_pOutput->Deliver(pIn);
- }
-
- BYTE* pDataIn = nullptr;
- if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
- return hr;
- }
- BYTE* pDataInOrg = pDataIn;
- UNREFERENCED_PARAMETER(pDataInOrg);
-
- long len = pIn->GetActualDataLength();
- if (len <= 0) {
- return S_OK;
- }
-
- REFERENCE_TIME rtStart, rtStop;
- pIn->GetTime(&rtStart, &rtStop);
- /*
- if (pIn->IsPreroll() == S_OK || rtStart < 0)
- return S_OK;
- */
-
- if (S_OK == pIn->IsSyncPoint()) {
- m_bufflen = 0;
- m_rtBuffStart = rtStart;
- m_fBuffDiscontinuity = pIn->IsDiscontinuity() == S_OK;
- }
-
- BYTE* src = nullptr;
- BYTE* dst = nullptr;
-
- int w = m_rai.coded_frame_size;
- int h = m_rai.sub_packet_h;
- int sps = m_rai.sub_packet_size;
-
- if (m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_RAAC
- || m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_RACP
- || m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_AAC) {
- src = pDataIn;
- dst = pDataIn + len;
- w = len;
- } else {
- memcpy(&m_buff[m_bufflen], pDataIn, len);
- m_bufflen += len;
-
- len = w * h;
-
- if (m_bufflen >= len) {
- ASSERT(m_bufflen == len);
-
- src = m_buff;
- dst = m_buff + len;
-
- if (sps > 0
- && (m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_COOK
- || m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_ATRC)) {
- for (int y = 0; y < h; y++) {
- for (int x = 0, w2 = w / sps; x < w2; x++) {
- // TRACE(_T("--- %d, %d\n"), (h*x+((h+1)/2)*(y&1)+(y>>1)), sps*(h*x+((h+1)/2)*(y&1)+(y>>1)));
- memcpy(dst + sps * (h * x + ((h + 1) / 2) * (y & 1) + (y >> 1)), src, sps);
- src += sps;
- }
- }
-
- src = m_buff + len;
- dst = m_buff + len * 2;
- } else if (m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_SIPR) {
- // http://mplayerhq.hu/pipermail/mplayer-dev-eng/2002-August/010569.html
-
- static BYTE sipr_swaps[38][2] = {
- {0, 63}, {1, 22}, {2, 44}, {3, 90}, {5, 81}, {7, 31}, {8, 86}, {9, 58}, {10, 36}, {12, 68},
- {13, 39}, {14, 73}, {15, 53}, {16, 69}, {17, 57}, {19, 88}, {20, 34}, {21, 71}, {24, 46},
- {25, 94}, {26, 54}, {28, 75}, {29, 50}, {32, 70}, {33, 92}, {35, 74}, {38, 85}, {40, 56},
- {42, 87}, {43, 65}, {45, 59}, {48, 79}, {49, 93}, {51, 89}, {55, 95}, {61, 76}, {67, 83},
- {77, 80}
- };
-
- int bs = h * w * 2 / 96; // nibbles per subpacket
- for (int n = 0; n < 38; n++) {
- int i = bs * sipr_swaps[n][0];
- int o = bs * sipr_swaps[n][1];
- // swap nibbles of block 'i' with 'o' TODO: optimize
- for (int j = 0; j < bs; j++) {
- int x = (i & 1) ? (src[(i >> 1)] >> 4) : (src[(i >> 1)] & 15);
- int y = (o & 1) ? (src[(o >> 1)] >> 4) : (src[(o >> 1)] & 15);
- if (o & 1) {
- src[(o >> 1)] = (src[(o >> 1)] & 0x0F) | (x << 4);
- } else {
- src[(o >> 1)] = (src[(o >> 1)] & 0xF0) | x;
- }
- if (i & 1) {
- src[(i >> 1)] = (src[(i >> 1)] & 0x0F) | (y << 4);
- } else {
- src[(i >> 1)] = (src[(i >> 1)] & 0xF0) | y;
- }
- ++i;
- ++o;
- }
- }
- }
-
- m_bufflen = 0;
- }
- }
-
- rtStart = m_rtBuffStart;
-
- for (; src < dst; src += w) {
- CComPtr<IMediaSample> pOut;
- BYTE* pDataOut = nullptr;
- if (FAILED(hr = m_pOutput->GetDeliveryBuffer(&pOut, nullptr, nullptr, 0))
- || FAILED(hr = pOut->GetPointer(&pDataOut))) {
- return hr;
- }
-
- AM_MEDIA_TYPE* pmt;
- if (SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt) {
- CMediaType mt(*pmt);
- m_pOutput->SetMediaType(&mt);
- DeleteMediaType(pmt);
- }
-
- hr = RADecode(m_dwCookie, src, w, pDataOut, &len, -1);
-
- if (FAILED(hr)) {
- TRACE(_T("RA returned an error code!!!\n"));
- continue;
- // return hr;
- }
-
- WAVEFORMATEX* pwfe = (WAVEFORMATEX*)m_pOutput->CurrentMediaType().Format();
-
- rtStop = rtStart + 1000i64 * len / pwfe->nAvgBytesPerSec * 10000;
- pOut->SetTime(&rtStart, &rtStop);
- pOut->SetMediaTime(nullptr, nullptr);
-
- pOut->SetDiscontinuity(m_fBuffDiscontinuity);
- m_fBuffDiscontinuity = false;
- pOut->SetSyncPoint(TRUE);
-
- pOut->SetActualDataLength(len);
-
- DbgLog((LOG_TRACE, 0, _T("A: rtStart=%I64d, rtStop=%I64d, disc=%d, sync=%d"),
- rtStart, rtStop, pOut->IsDiscontinuity() == S_OK, pOut->IsSyncPoint() == S_OK));
-
- if (rtStart >= 0 && S_OK != (hr = m_pOutput->Deliver(pOut))) {
- return hr;
- }
-
- rtStart = rtStop;
- }
-
- m_rtBuffStart = rtStart;
-
- return S_OK;
-}
-
-HRESULT CRealAudioDecoder::CheckInputType(const CMediaType* mtIn)
-{
- if (mtIn->majortype != MEDIATYPE_Audio
- || mtIn->subtype != MEDIASUBTYPE_14_4
- && mtIn->subtype != MEDIASUBTYPE_28_8
- && mtIn->subtype != MEDIASUBTYPE_ATRC
- && mtIn->subtype != MEDIASUBTYPE_COOK
- && mtIn->subtype != MEDIASUBTYPE_DNET
- && mtIn->subtype != MEDIASUBTYPE_SIPR
- && mtIn->subtype != MEDIASUBTYPE_RAAC
- && mtIn->subtype != MEDIASUBTYPE_RACP
- && mtIn->subtype != MEDIASUBTYPE_AAC) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- if (!m_pInput->IsConnected()) {
- if (m_hDrvDll) {
- FreeLibrary(m_hDrvDll);
- m_hDrvDll = nullptr;
- }
-
- CAtlList<CString> paths;
- CString olddll, newdll, oldpath, newpath;
-
- TCHAR fourcc[5] = {
- (TCHAR)((mtIn->subtype.Data1 >> 0) & 0xff),
- (TCHAR)((mtIn->subtype.Data1 >> 8) & 0xff),
- (TCHAR)((mtIn->subtype.Data1 >> 16) & 0xff),
- (TCHAR)((mtIn->subtype.Data1 >> 24) & 0xff),
- 0
- };
-
- if (!_tcscmp(_T("RACP"), fourcc) || !_tcscmp(_T("\xff"), fourcc)) {
- _tcscpy_s(fourcc, _T("RAAC"));
- }
-
- olddll.Format(_T("%s3260.dll"), fourcc);
- newdll.Format(_T("%s.dll"), fourcc);
-
- CRegKey key;
- TCHAR buff[MAX_PATH];
- ULONG len = _countof(buff);
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Software\\RealNetworks\\Preferences\\DT_Codecs"), KEY_READ)
- && ERROR_SUCCESS == key.QueryStringValue(nullptr, buff, &len) && _tcslen(buff) > 0) {
- oldpath = buff;
- TCHAR c = oldpath[oldpath.GetLength() - 1];
- if (c != '\\' && c != '/') {
- oldpath += '\\';
- }
- key.Close();
- }
- len = _countof(buff);
- if (ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Helix\\HelixSDK\\10.0\\Preferences\\DT_Codecs"), KEY_READ)
- && ERROR_SUCCESS == key.QueryStringValue(nullptr, buff, &len) && _tcslen(buff) > 0) {
- newpath = buff;
- TCHAR c = newpath[newpath.GetLength() - 1];
- if (c != '\\' && c != '/') {
- newpath += '\\';
- }
- key.Close();
- }
-
- if (!newpath.IsEmpty()) {
- paths.AddTail(newpath + newdll);
- }
- if (!oldpath.IsEmpty()) {
- paths.AddTail(oldpath + newdll);
- }
- paths.AddTail(newdll); // default dll paths
- if (!newpath.IsEmpty()) {
- paths.AddTail(newpath + olddll);
- }
- if (!oldpath.IsEmpty()) {
- paths.AddTail(oldpath + olddll);
- }
- paths.AddTail(olddll); // default dll paths
-
- POSITION pos = paths.GetHeadPosition();
- do {
- if (pos) {
- m_hDrvDll = LoadLibrary(paths.GetNext(pos));
- }
- } while (pos && !m_hDrvDll);
-
- if (m_hDrvDll) {
- RACloseCodec = (PCloseCodec)GetProcAddress(m_hDrvDll, "RACloseCodec");
- RADecode = (PDecode)GetProcAddress(m_hDrvDll, "RADecode");
- RAFlush = (PFlush)GetProcAddress(m_hDrvDll, "RAFlush");
- RAFreeDecoder = (PFreeDecoder)GetProcAddress(m_hDrvDll, "RAFreeDecoder");
- RAGetFlavorProperty = (PGetFlavorProperty)GetProcAddress(m_hDrvDll, "RAGetFlavorProperty");
- RAInitDecoder = (PInitDecoder)GetProcAddress(m_hDrvDll, "RAInitDecoder");
- RAOpenCodec = (POpenCodec)GetProcAddress(m_hDrvDll, "RAOpenCodec");
- RAOpenCodec2 = (POpenCodec2)GetProcAddress(m_hDrvDll, "RAOpenCodec2");
- RASetFlavor = (PSetFlavor)GetProcAddress(m_hDrvDll, "RASetFlavor");
- RASetDLLAccessPath = (PSetDLLAccessPath)GetProcAddress(m_hDrvDll, "RASetDLLAccessPath");
- RASetPwd = (PSetPwd)GetProcAddress(m_hDrvDll, "RASetPwd");
- }
-
- if (!m_hDrvDll || !RACloseCodec || !RADecode /*|| !RAFlush*/
- || !RAFreeDecoder || !RAGetFlavorProperty || !RAInitDecoder
- || !(RAOpenCodec || RAOpenCodec2) /*|| !RASetFlavor*/) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- if (m_hDrvDll) {
- char chbuff[MAX_PATH];
- GetModuleFileNameA(m_hDrvDll, chbuff, MAX_PATH);
- CPathA p(chbuff);
- p.RemoveFileSpec();
- p.AddBackslash();
- m_dllpath = p.m_strPath;
- if (RASetDLLAccessPath) {
- RASetDLLAccessPath("DT_Codecs=" + m_dllpath);
- }
- }
-
- if (FAILED(InitRA(mtIn))) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- }
-
- return S_OK;
-}
-
-HRESULT CRealAudioDecoder::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
-{
- return mtIn->majortype == MEDIATYPE_Audio && (mtIn->subtype == MEDIASUBTYPE_14_4
- || mtIn->subtype == MEDIASUBTYPE_28_8
- || mtIn->subtype == MEDIASUBTYPE_ATRC
- || mtIn->subtype == MEDIASUBTYPE_COOK
- || mtIn->subtype == MEDIASUBTYPE_DNET
- || mtIn->subtype == MEDIASUBTYPE_SIPR
- || mtIn->subtype == MEDIASUBTYPE_RAAC
- || mtIn->subtype == MEDIASUBTYPE_RACP
- || mtIn->subtype == MEDIASUBTYPE_AAC)
- && mtOut->majortype == MEDIATYPE_Audio && mtOut->subtype == MEDIASUBTYPE_PCM
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
-}
-
-HRESULT CRealAudioDecoder::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
-{
- if (m_pInput->IsConnected() == FALSE) {
- return E_UNEXPECTED;
- }
-
- CComPtr<IMemAllocator> pAllocatorIn;
- m_pInput->GetAllocator(&pAllocatorIn);
- if (!pAllocatorIn) {
- return E_UNEXPECTED;
- }
-
- WAVEFORMATEX* pwfe = (WAVEFORMATEX*)m_pOutput->CurrentMediaType().Format();
-
- WORD wBitsPerSample = pwfe->wBitsPerSample;
- if (!wBitsPerSample) {
- wBitsPerSample = 16;
- }
-
- // ok, maybe this is too much...
- pProperties->cBuffers = 8;
- pProperties->cbBuffer = pwfe->nChannels * pwfe->nSamplesPerSec * wBitsPerSample >> 3; // nAvgBytesPerSec;
- pProperties->cbAlign = 1;
- pProperties->cbPrefix = 0;
-
- HRESULT hr;
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
- return hr;
- }
-
- return (pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR);
-}
-
-HRESULT CRealAudioDecoder::GetMediaType(int iPosition, CMediaType* pmt)
-{
- if (m_pInput->IsConnected() == FALSE) {
- return E_UNEXPECTED;
- }
-
- *pmt = m_pInput->CurrentMediaType();
- pmt->subtype = MEDIASUBTYPE_PCM;
- WAVEFORMATEX* pwfe = (WAVEFORMATEX*)pmt->ReallocFormatBuffer(sizeof(WAVEFORMATEX));
-
- if (iPosition < 0) {
- return E_INVALIDARG;
- }
- if (iPosition > (pwfe->nChannels > 2 && pwfe->nChannels <= 6 ? 1 : 0)) {
- return VFW_S_NO_MORE_ITEMS;
- }
-
- if (!pwfe->wBitsPerSample) {
- pwfe->wBitsPerSample = 16;
- }
-
- pwfe->cbSize = 0;
- pwfe->wFormatTag = WAVE_FORMAT_PCM;
- pwfe->nBlockAlign = pwfe->nChannels * pwfe->wBitsPerSample >> 3;
- pwfe->nAvgBytesPerSec = pwfe->nSamplesPerSec * pwfe->nBlockAlign;
-
- if (iPosition == 0 && pwfe->nChannels > 2 && pwfe->nChannels <= 6) {
- static DWORD chmask[] = {
- KSAUDIO_SPEAKER_DIRECTOUT,
- KSAUDIO_SPEAKER_MONO,
- KSAUDIO_SPEAKER_STEREO,
- KSAUDIO_SPEAKER_STEREO | SPEAKER_FRONT_CENTER,
- KSAUDIO_SPEAKER_QUAD,
- KSAUDIO_SPEAKER_QUAD | SPEAKER_FRONT_CENTER,
- KSAUDIO_SPEAKER_5POINT1
- };
-
- WAVEFORMATEXTENSIBLE* pwfex = (WAVEFORMATEXTENSIBLE*)pmt->ReallocFormatBuffer(sizeof(WAVEFORMATEXTENSIBLE));
- pwfex->Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
- pwfex->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
- pwfex->dwChannelMask = chmask[pwfex->Format.nChannels];
- pwfex->Samples.wValidBitsPerSample = pwfex->Format.wBitsPerSample;
- pwfex->SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
- }
-
- return S_OK;
-}
-
-HRESULT CRealAudioDecoder::StartStreaming()
-{
- int w = m_rai.coded_frame_size;
- int h = m_rai.sub_packet_h;
- int sps = m_rai.sub_packet_size;
- UNREFERENCED_PARAMETER(sps);
-
- int len = w * h;
-
- m_buff.Allocate(len * 2);
- m_bufflen = 0;
- m_rtBuffStart = 0;
-
- return __super::StartStreaming();
-}
-
-HRESULT CRealAudioDecoder::StopStreaming()
-{
- m_buff.Free();
- m_bufflen = 0;
-
- return __super::StopStreaming();
-}
-
-HRESULT CRealAudioDecoder::EndOfStream()
-{
- return __super::EndOfStream();
-}
-
-HRESULT CRealAudioDecoder::BeginFlush()
-{
- return __super::BeginFlush();
-}
-
-HRESULT CRealAudioDecoder::EndFlush()
-{
- return __super::EndFlush();
-}
-
-HRESULT CRealAudioDecoder::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
-{
- CAutoLock cAutoLock(&m_csReceive);
- m_tStart = tStart;
- m_bufflen = 0;
- m_rtBuffStart = 0;
- return __super::NewSegment(tStart, tStop, dRate);
-}
diff --git a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.def b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.def
deleted file mode 100644
index 6492e5cd6..000000000
--- a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.def
+++ /dev/null
@@ -1,5 +0,0 @@
-EXPORTS
- DllCanUnloadNow PRIVATE
- DllGetClassObject PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
diff --git a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.h b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.h
deleted file mode 100644
index b7a15722c..000000000
--- a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.h
+++ /dev/null
@@ -1,366 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <atlbase.h>
-#include <atlcoll.h>
-#include "../BaseSplitter/BaseSplitter.h"
-#include "../../transform/BaseVideoFilter/BaseVideoFilter.h"
-
-#define RMSplitterName L"MPC RealMedia Splitter"
-#define RMSourceName L"MPC RealMedia Source"
-#define RMVideoDecoderName L"MPC RealVideo Decoder"
-#define RMAudioDecoderName L"MPC RealAudio Decoder"
-
-#pragma pack(push, 1)
-
-namespace RMFF
-{
- typedef struct {
- union {
- char id[4];
- UINT32 object_id;
- };
- UINT32 size;
- UINT16 object_version;
- } ChunkHdr;
- typedef struct {
- UINT32 version, nHeaders;
- } FileHdr;
- typedef struct {
- UINT32 maxBitRate, avgBitRate;
- UINT32 maxPacketSize, avgPacketSize, nPackets;
- UINT32 tDuration, tPreroll;
- UINT32 ptrIndex, ptrData;
- UINT16 nStreams;
- enum flags_t {
- PN_SAVE_ENABLED = 1,
- PN_PERFECT_PLAY_ENABLED = 2,
- PN_LIVE_BROADCAST = 4
- } flags;
- } Properies;
- typedef struct {
- UINT16 stream;
- UINT32 maxBitRate, avgBitRate;
- UINT32 maxPacketSize, avgPacketSize;
- UINT32 tStart, tPreroll, tDuration;
- CStringA name, mime;
- CAtlArray<BYTE> typeSpecData;
- UINT32 width, height;
- bool interlaced, top_field_first;
- } MediaProperies;
- typedef struct {
- CStringA title, author, copyright, comment;
- } ContentDesc;
- typedef struct {
- UINT64 pos;
- UINT32 nPackets, ptrNext;
- } DataChunk;
- typedef struct {
- UINT16 len, stream;
- UINT32 tStart;
- UINT8 reserved;
- enum flag_t {
- PN_RELIABLE_FLAG = 1,
- PN_KEYFRAME_FLAG = 2
- } flags; // UINT8
- CAtlArray<BYTE> pData;
- } MediaPacketHeader;
- typedef struct {
- UINT32 nIndices;
- UINT16 stream;
- UINT32 ptrNext;
- } IndexChunkHeader;
- typedef struct {
- UINT32 tStart, ptrFilePos, packet;
- } IndexRecord;
-}
-
-struct rvinfo {
- DWORD dwSize, fcc1, fcc2;
- WORD w, h, bpp;
- DWORD unk1, fps, type1, type2;
- BYTE morewh[14];
- void bswap();
-};
-
-struct rainfo3 {
- DWORD fourcc; // Header signature ('.', 'r', 'a', 0xfd)
- WORD version; // Version (always 3)
- WORD header_size; // Header size, not including first 8 bytes
- BYTE unknown[10]; // Unknown
- DWORD data_size; // Data size
- void bswap();
-};
-
-struct rainfo {
- DWORD fourcc1; // '.', 'r', 'a', 0xfd
- WORD version1; // 4 or 5
- WORD unknown1; // 00 000
- DWORD fourcc2; // .ra4 or .ra5
- DWORD unknown2; // ???
- WORD version2; // 4 or 5
- DWORD header_size; // == 0x4e
- WORD flavor; // codec flavor id
- DWORD coded_frame_size; // coded frame size
- DWORD unknown3; // big number
- DWORD unknown4; // bigger number
- DWORD unknown5; // yet another number
- WORD sub_packet_h;
- WORD frame_size;
- WORD sub_packet_size;
- WORD unknown6; // 00 00
- void bswap();
-};
-
-struct rainfo4 : rainfo {
- WORD sample_rate;
- WORD unknown8; // 0
- WORD sample_size;
- WORD channels;
- void bswap();
-};
-
-struct rainfo5 : rainfo {
- BYTE unknown7[6]; // 0, srate, 0
- WORD sample_rate;
- WORD unknown8; // 0
- WORD sample_size;
- WORD channels;
- DWORD genr; // "genr"
- DWORD fourcc3; // fourcc
- void bswap();
-};
-
-#pragma pack(pop)
-
-class CRMFile : public CBaseSplitterFile
-{
- // using CBaseSplitterFile::Read;
-
- HRESULT Init();
- void GetDimensions();
-
-public:
- CRMFile(IAsyncReader* pAsyncReader, HRESULT& hr);
-
- template<typename T> HRESULT Read(T& var);
- HRESULT Read(RMFF::ChunkHdr& hdr);
- HRESULT Read(RMFF::MediaPacketHeader& mph, bool fFull = true);
-
- RMFF::FileHdr m_fh;
- RMFF::ContentDesc m_cd;
- RMFF::Properies m_p;
- CAutoPtrList<RMFF::MediaProperies> m_mps;
- CAutoPtrList<RMFF::DataChunk> m_dcs;
- CAutoPtrList<RMFF::IndexRecord> m_irs;
-
- typedef struct {
- CStringA name, data;
- } subtitle;
- CAtlList<subtitle> m_subs;
-
- int GetMasterStream();
-};
-
-class CRealMediaSplitterOutputPin : public CBaseSplitterOutputPin
-{
-private:
- typedef struct {
- CAtlArray<BYTE> data;
- DWORD offset;
- } segment;
-
- class CSegments : public CAutoPtrList<segment>, public CCritSec
- {
- public:
- REFERENCE_TIME rtStart;
- bool fDiscontinuity, fSyncPoint, fMerged;
- void Clear() {
- CAutoLock cAutoLock(this);
- rtStart = 0;
- fDiscontinuity = fSyncPoint = fMerged = false;
- RemoveAll();
- }
- } m_segments;
-
- CCritSec m_csQueue;
-
- HRESULT DeliverSegments();
-
-protected:
- HRESULT DeliverPacket(CAutoPtr<Packet> p);
-
-public:
- CRealMediaSplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
- virtual ~CRealMediaSplitterOutputPin();
-
- HRESULT DeliverEndFlush();
-};
-
-class __declspec(uuid("E21BE468-5C18-43EB-B0CC-DB93A847D769"))
- CRealMediaSplitterFilter : public CBaseSplitterFilter
-{
-protected:
- CAutoPtr<CRMFile> m_pFile;
- HRESULT CreateOutputs(IAsyncReader* pAsyncReader);
-
- bool DemuxInit();
- void DemuxSeek(REFERENCE_TIME rt);
- bool DemuxLoop();
-
- POSITION m_seekpos;
- UINT32 m_seekpacket;
- UINT64 m_seekfilepos;
-
-public:
- CRealMediaSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
- virtual ~CRealMediaSplitterFilter();
-
- // CBaseFilter
-
- STDMETHODIMP_(HRESULT) QueryFilterInfo(FILTER_INFO* pInfo);
-
- // IKeyFrameInfo
-
- STDMETHODIMP_(HRESULT) GetKeyFrameCount(UINT& nKFs);
- STDMETHODIMP_(HRESULT) GetKeyFrames(const GUID* pFormat, REFERENCE_TIME* pKFs, UINT& nKFs);
-};
-
-class __declspec(uuid("765035B3-5944-4A94-806B-20EE3415F26F"))
- CRealMediaSourceFilter : public CRealMediaSplitterFilter
-{
-public:
- CRealMediaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
-};
-
-////////////
-
-class __declspec(uuid("238D0F23-5DC9-45A6-9BE2-666160C324DD"))
- CRealVideoDecoder : public CBaseVideoFilter
-{
- typedef HRESULT(WINAPI* PRVCustomMessage)(void*, DWORD);
- typedef HRESULT(WINAPI* PRVFree)(DWORD);
- typedef HRESULT(WINAPI* PRVHiveMessage)(void*, DWORD);
- typedef HRESULT(WINAPI* PRVInit)(void*, DWORD* dwCookie);
- typedef HRESULT(WINAPI* PRVTransform)(BYTE*, BYTE*, void*, void*, DWORD);
-
- PRVCustomMessage RVCustomMessage;
- PRVFree RVFree;
- PRVHiveMessage RVHiveMessage;
- PRVInit RVInit;
- PRVTransform RVTransform;
-
- HMODULE m_hDrvDll;
- DWORD m_dwCookie;
- int m_lastBuffSizeDim;
-
- HRESULT InitRV(const CMediaType* pmt);
- void FreeRV();
-
- REFERENCE_TIME m_tStart;
-
- void Resize(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD wo, DWORD ho);
- void ResizeWidth(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD wo, DWORD ho);
- void ResizeHeight(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD wo, DWORD ho);
- void ResizeRow(BYTE* pIn, DWORD wi, DWORD dpi, BYTE* pOut, DWORD wo, DWORD dpo);
-
- BYTE* m_pI420, *m_pI420Tmp;
-
-public:
- CRealVideoDecoder(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CRealVideoDecoder();
-
- HRESULT Transform(IMediaSample* pIn);
- HRESULT CheckInputType(const CMediaType* mtIn);
- HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
-
- HRESULT StartStreaming();
- HRESULT StopStreaming();
-
- HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
-
- DWORD m_timestamp;
- bool m_fDropFrames;
- HRESULT AlterQuality(Quality q);
-};
-
-class __declspec(uuid("941A4793-A705-4312-8DFC-C11CA05F397E"))
- CRealAudioDecoder : public CTransformFilter
-{
- typedef HRESULT(WINAPI* PCloseCodec)(DWORD);
- typedef HRESULT(WINAPI* PDecode)(DWORD, BYTE*, long, BYTE*, long*, long);
- typedef HRESULT(WINAPI* PFlush)(DWORD, DWORD, DWORD);
- typedef HRESULT(WINAPI* PFreeDecoder)(DWORD);
- typedef void* (WINAPI* PGetFlavorProperty)(void*, DWORD, DWORD, int*);
- typedef HRESULT(WINAPI* PInitDecoder)(DWORD, void*);
- typedef HRESULT(WINAPI* POpenCodec)(void*);
- typedef HRESULT(WINAPI* POpenCodec2)(void*, const char*);
- typedef HRESULT(WINAPI* PSetFlavor)(DWORD, WORD);
- typedef void (WINAPI* PSetDLLAccessPath)(const char*);
- typedef void (WINAPI* PSetPwd)(DWORD, const char*);
-
- PCloseCodec RACloseCodec;
- PDecode RADecode;
- PFlush RAFlush;
- PFreeDecoder RAFreeDecoder;
- PGetFlavorProperty RAGetFlavorProperty;
- PInitDecoder RAInitDecoder;
- POpenCodec RAOpenCodec;
- POpenCodec2 RAOpenCodec2;
- PSetFlavor RASetFlavor;
- PSetDLLAccessPath RASetDLLAccessPath;
- PSetPwd RASetPwd;
-
- CStringA m_dllpath;
- HMODULE m_hDrvDll;
- DWORD m_dwCookie;
-
- HRESULT InitRA(const CMediaType* pmt);
- void FreeRA();
-
- REFERENCE_TIME m_tStart;
-
- rainfo m_rai;
- CAutoVectorPtr<BYTE> m_buff;
- int m_bufflen;
- REFERENCE_TIME m_rtBuffStart;
- bool m_fBuffDiscontinuity;
-
-public:
- CRealAudioDecoder(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CRealAudioDecoder();
-
- HRESULT Receive(IMediaSample* pIn);
- HRESULT CheckInputType(const CMediaType* mtIn);
- HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
- HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT GetMediaType(int iPosition, CMediaType* pMediaType);
-
- HRESULT StartStreaming();
- HRESULT StopStreaming();
-
- HRESULT EndOfStream();
- HRESULT BeginFlush();
- HRESULT EndFlush();
- HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
-};
diff --git a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.rc b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.rc
deleted file mode 100644
index 2a64ab6b2..000000000
--- a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.rc
+++ /dev/null
@@ -1,102 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-#include "version.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (United States) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION MPC_VERSION_NUM
- PRODUCTVERSION MPC_VERSION_NUM
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS VOS_NT_WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE VFT2_UNKNOWN
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", MPC_VERSION_COMMENTS
- VALUE "CompanyName", MPC_COMP_NAME_STR
- VALUE "FileDescription", "RealMedia Splitter"
- VALUE "FileVersion", MPC_VERSION_STR_FULL
- VALUE "InternalName", "RealMedia Splitter"
- VALUE "LegalCopyright", MPC_COPYRIGHT_STR
- VALUE "OriginalFilename", "RealMediaSplitter.ax"
- VALUE "ProductName", "RealMedia Splitter"
- VALUE "ProductVersion", MPC_VERSION_STR_FULL
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // English (United States) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.vcxproj b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.vcxproj
deleted file mode 100644
index 9ffcc1d09..000000000
--- a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.vcxproj
+++ /dev/null
@@ -1,256 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug Filter|Win32">
- <Configuration>Debug Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug Filter|x64">
- <Configuration>Debug Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|Win32">
- <Configuration>Release Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|x64">
- <Configuration>Release Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{53CF9195-19DB-457D-8F55-8DB1706DFA84}</ProjectGuid>
- <RootNamespace>RealMediaSplitter</RootNamespace>
- <Keyword>MFCProj</Keyword>
- <ProjectName>RealMediaSplitter</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <Import Project="..\..\..\platform.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">.ax</TargetExt>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>RealMediaSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>RealMediaSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>RealMediaSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>RealMediaSplitter.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="RealMediaSplitter.cpp" />
- <ClCompile Include="stdafx.cpp">
- <PrecompiledHeader>Create</PrecompiledHeader>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="RealMediaSplitter.def" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="RealMediaSplitter.h" />
- <ClInclude Include="resource.h">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ClInclude>
- <ClInclude Include="stdafx.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="RealMediaSplitter.rc">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ResourceCompile>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\DSUtil\DSUtil.vcxproj">
- <Project>{fc70988b-1ae5-4381-866d-4f405e28ac42}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\Kasumi\Kasumi.vcxproj">
- <Project>{0d252872-7542-4232-8d02-53f9182aee15}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\system\system.vcxproj">
- <Project>{c2082189-3ecb-4079-91fa-89d3c8a305c0}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\BaseClasses\BaseClasses.vcxproj">
- <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\Filters.vcxproj">
- <Project>{273b3149-3192-4b75-a791-470320b90812}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\transform\BaseVideoFilter\BaseVideoFilter.vcxproj">
- <Project>{54dda60f-e528-4d07-a152-960a1e818680}</Project>
- </ProjectReference>
- <ProjectReference Include="..\BaseSplitter\BaseSplitter.vcxproj">
- <Project>{37768b3f-89bc-4c16-b2a8-767c5da84c3f}</Project>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.vcxproj.filters b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.vcxproj.filters
deleted file mode 100644
index 263090f65..000000000
--- a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.vcxproj.filters
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{87fab731-8112-4bbb-8e3a-65188e022232}</UniqueIdentifier>
- <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{1636a0aa-ab63-48eb-81e1-c644318584f1}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{c30231bb-4c89-4fc3-934f-c0ce5e8f1872}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="RealMediaSplitter.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="stdafx.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="RealMediaSplitter.def">
- <Filter>Source Files</Filter>
- </None>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="RealMediaSplitter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="resource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="stdafx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="RealMediaSplitter.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/parser/RealMediaSplitter/resource.h b/src/filters/parser/RealMediaSplitter/resource.h
deleted file mode 100644
index 713badf0e..000000000
--- a/src/filters/parser/RealMediaSplitter/resource.h
+++ /dev/null
@@ -1,14 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by RealMediaSplitter.rc
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 101
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/filters/parser/RealMediaSplitter/stdafx.cpp b/src/filters/parser/RealMediaSplitter/stdafx.cpp
deleted file mode 100644
index 784f2cebc..000000000
--- a/src/filters/parser/RealMediaSplitter/stdafx.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
diff --git a/src/filters/parser/RealMediaSplitter/stdafx.h b/src/filters/parser/RealMediaSplitter/stdafx.h
deleted file mode 100644
index 5b6b09e05..000000000
--- a/src/filters/parser/RealMediaSplitter/stdafx.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../../DSUtil/SharedInclude.h"
-#include "../../../../include/stdafx_common.h"
-#include "../../../../include/stdafx_common_afx.h"
-#include "../../../../include/stdafx_common_dshow.h"
diff --git a/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp
index 0eecb345d..3ef5fe969 100644
--- a/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp
@@ -24,7 +24,7 @@
#include <Mferror.h>
#include "IPinHook.h"
#include "MacrovisionKicker.h"
-#include "../../transform/MPCVideoDec/MPCVideoDecFilter.h"
+#include "IMPCVideoDecFilter.h"
#if (0) // Set to 1 to activate EVR traces
#define TRACE_EVR TRACE
diff --git a/src/filters/source/DTSAC3Source/DTSAC3Source.cpp b/src/filters/source/DTSAC3Source/DTSAC3Source.cpp
deleted file mode 100644
index 7f3d0a650..000000000
--- a/src/filters/source/DTSAC3Source/DTSAC3Source.cpp
+++ /dev/null
@@ -1,614 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <MMReg.h>
-#include <ks.h>
-#ifdef STANDALONE_FILTER
-#include <InitGuid.h>
-#endif
-#include <uuids.h>
-#include "moreuuids.h"
-#include "DTSAC3Source.h"
-#include "../../../DSUtil/AudioParser.h"
-#include <atlpath.h>
-// TODO: remove this when it's fixed in MSVC
-// Work around warning C4005: 'XXXX' : macro redefinition
-#pragma warning(push)
-#pragma warning(disable: 4005)
-#include <stdint.h>
-#pragma warning(pop)
-
-enum {
- unknown,
- AC3,
- EAC3,
- //TrueHD,
- //TrueHDAC3,
- MLP,
- DTS,
- DTSHD,
- DTSPaded,
- SPDIF_AC3
-};
-
-bool isDTSSync(const DWORD sync)
-{
- if (sync == 0x0180fe7f || // '7FFE8001' 16 bits and big endian bitstream
- sync == 0x80017ffe || // 'FE7F0180' 16 bits and little endian bitstream
- sync == 0x00e8ff1f || // '1FFFE800' 14 bits and big endian bitstream
- sync == 0xe8001fff) { // 'FF1F00E8' 14 bits and little endian bitstream
- return true;
- } else {
- return false;
- }
-}
-
-DWORD ParseWAVECDHeader(const BYTE wh[44])
-{
- if (*(DWORD*)wh != 0x46464952 //"RIFF"
- || *(DWORDLONG*)(wh + 8) != 0x20746d6645564157 //"WAVEfmt "
- || *(DWORD*)(wh + 36) != 0x61746164) { //"data"
- return 0;
- }
- PCMWAVEFORMAT pcmwf = *(PCMWAVEFORMAT*)(wh + 20);
- if (pcmwf.wf.wFormatTag != 1
- || pcmwf.wf.nChannels != 2
- || pcmwf.wf.nSamplesPerSec != 44100 && pcmwf.wf.nSamplesPerSec != 48000
- || pcmwf.wf.nBlockAlign != 4
- || pcmwf.wf.nAvgBytesPerSec != pcmwf.wf.nSamplesPerSec * pcmwf.wf.nBlockAlign
- || pcmwf.wBitsPerSample != 16) {
- return 0;
- }
- return *(DWORD*)(wh + 40); //return size of "data"
-}
-
-int ParseAC3IEC61937Header(const BYTE* buf)
-{
- WORD* wbuf = (WORD*)buf;
- if (*(DWORD*)buf == IEC61937_SYNC_WORD
- && wbuf[2] == 0x0001
- && wbuf[3] > 0 && wbuf[3] < (6144 - 8) * 8
- && wbuf[4] == 0x0B77) {
- return 6144;
- }
- return 0;
-}
-
-#ifdef STANDALONE_FILTER
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_DTS},
- {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DTS},
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_DOLBY_AC3},
- {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DOLBY_AC3},
-};
-
-const AMOVIESETUP_PIN sudOpPin[] = {
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesOut), sudPinTypesOut}
-};
-
-const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CDTSAC3Source), DTSAC3SourceName, MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
-};
-
-CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDTSAC3Source>, nullptr, &sudFilter[0]}
-};
-
-int g_cTemplates = _countof(g_Templates);
-
-STDAPI DllRegisterServer()
-{
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
- _T("0"), _T("0,4,,7FFE8001")); // DTS
-
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
- _T("0"), _T("0,4,,fE7f0180")); // DTS LE
-
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
- _T("1"), _T("0,2,,0B77")); // AC3, E-AC3
-
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
- _T("2"), _T("0,16,,52494646xxxx57415645666D7420")); // RIFFxxxxWAVEfmt_ for DTSWAV
-
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
- _T("0"), _T("4,4,,F8726FBB")); // MLP
-
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
- _T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
-
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".dts"),
- _T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
-
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".ac3"),
- _T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
-
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".eac3"),
- _T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
-
- return AMovieDllRegisterServer2(TRUE);
-}
-
-STDAPI DllUnregisterServer()
-{
- DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".dts"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".ac3"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".eac3"));
-
- return AMovieDllRegisterServer2(FALSE);
-}
-
-#include "../../FilterApp.h"
-
-CFilterApp theApp;
-
-#endif
-
-//
-// CDTSAC3Source
-//
-
-CDTSAC3Source::CDTSAC3Source(LPUNKNOWN lpunk, HRESULT* phr)
- : CBaseSource<CDTSAC3Stream>(NAME("CDTSAC3Source"), lpunk, phr, __uuidof(this))
-{
-}
-
-CDTSAC3Source::~CDTSAC3Source()
-{
-}
-
-STDMETHODIMP CDTSAC3Source::QueryFilterInfo(FILTER_INFO* pInfo)
-{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
- wcscpy_s(pInfo->achName, DTSAC3SourceName);
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
-}
-
-// CDTSAC3Stream
-
-CDTSAC3Stream::CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr)
- : CBaseStream(NAME("CDTSAC3Stream"), pParent, phr)
- , m_dataOffset(0)
- , m_subtype(GUID_NULL)
- , m_wFormatTag(WAVE_FORMAT_UNKNOWN)
- , m_channels(0)
- , m_samplerate(0)
- , m_bitrate(0)
- , m_framesize(0)
- , m_fixedframesize(true)
- , m_framelength(0)
- , m_bitdepth(0)
- , m_streamtype(unknown)
-{
- CAutoLock cAutoLock(&m_cSharedState);
- CString fn(wfn);
- CFileException ex;
- HRESULT hr = E_FAIL;
- m_AvgTimePerFrame = 0;
-
- bool waveheader = false;
-
- do {
- if (!m_file.Open(fn, CFile::modeRead | CFile::shareDenyNone, &ex)) {
- hr = AmHresultFromWin32(ex.m_lOsError);
- break;
- }
- const CString path = m_file.GetFilePath();
- const CString ext = CPath(m_file.GetFileName()).GetExtension().MakeLower();
-
- DWORD id = 0;
- DWORD id2 = 0;
- if (m_file.Read(&id, sizeof(id)) != sizeof(id) ||
- m_file.Read(&id2, sizeof(id2)) != sizeof(id2)) {
- break;
- }
-
- // WAVE-CD header
- if (id == RIFF_DWORD) {
- if (ext != _T(".dtswav") && ext != _T(".dts") && ext != _T(".wav")) { //check only specific extensions
- break;
- }
- BYTE buf[44];
- m_file.SeekToBegin();
- if (m_file.Read(&buf, 44) != 44
- || ParseWAVECDHeader(buf) == 0
- || m_file.Read(&id, sizeof(id)) != sizeof(id)) {
- break;
- }
- waveheader = true;
- }
-
- m_dataOffset = m_file.GetPosition() - sizeof(id) - (!waveheader ? sizeof(id2) : 0);
-
- bool isFound = isDTSSync(id) || (WORD)id == AC3_SYNC_WORD || id == IEC61937_SYNC_WORD || id2 == MLP_SYNC_WORD /*|| id2!=TRUEHD_SYNC_WORD*/;
-
- // search DTS and AC3 headers (skip garbage in the beginning)
- if (!isFound) {
- UINT buflen = 0;
- if (waveheader && ext == _T(".wav") && PathFileExists(path.Left(path.GetLength() - ext.GetLength()) + _T(".cue"))) {
- buflen = 64 * 1024; // for .wav+.cue sometimes need to use a more deep search
- } else if (ext == _T(".dtswav") || ext == _T(".dts") || ext == _T(".wav") || ext == _T(".ac3") || ext == _T(".eac3")) { //check only specific extensions
- buflen = 6 * 1024;
- } else {
- break;
- }
-
- if (m_dataOffset < buflen) {
- buflen -= (UINT)m_dataOffset; // tiny optimization
- }
- m_file.Seek(m_dataOffset, CFile::begin);
-
- BYTE* buf = DEBUG_NEW BYTE[buflen];
- UINT len = m_file.Read(buf, buflen);
- if (len < 100) {
- break; // file is very small
- }
-
- for (UINT i = 1; i + 8 < len; i++) { // looking for DTS or AC3 sync
- id = *(DWORD*)(buf + i);
- if (isDTSSync(id) || (WORD)id == AC3_SYNC_WORD && (GetAC3FrameSize(buf + i) > 0 || GetEAC3FrameSize(buf + i) > 0)) {
- isFound = true;
- m_dataOffset += i;
- break;
- }
- }
- delete [] buf;
- }
- if (!isFound) {
- break;
- }
-
- m_file.Seek(m_dataOffset, CFile::begin);
-
- // DTS & DTS-HD
- if (isDTSSync(id)) {
- BYTE buf[16];
- if (m_file.Read(&buf, 16) != 16) {
- break;
- }
-
- // DTS header
- int targeted_bitrate;
- int fsize = ParseDTSHeader(buf, &m_samplerate, &m_channels, &m_framelength, &targeted_bitrate);
- if (fsize == 0) {
- break;
- }
- m_streamtype = DTS;
-
- // DTS-HD header and zero padded
- unsigned long sync = -1;
- unsigned int HD_size = 0;
- int zero_bytes = 0;
-
- m_file.Seek(m_dataOffset + fsize, CFile::begin);
- m_file.Read(&sync, sizeof(sync));
- if (id == DTS_SYNC_WORD && sync == DTSHD_SYNC_WORD && m_file.Read(&buf, 8) == 8) {
- unsigned char isBlownUpHeader = (buf[1] >> 5) & 1;
- if (isBlownUpHeader) {
- HD_size = ((buf[2] & 1) << 19 | buf[3] << 11 | buf[4] << 3 | buf[5] >> 5) + 1;
- } else {
- HD_size = ((buf[2] & 31) << 11 | buf[3] << 3 | buf[4] >> 5) + 1;
- }
- //TODO: get more information about DTS-HD
- m_streamtype = DTSHD;
- m_fixedframesize = false;
- } else if (sync == 0 && fsize < 2048) { // zero padded?
- m_file.Seek(m_dataOffset + 2048, CFile::begin);
- m_file.Read(&sync, sizeof(sync));
- if (sync == id) {
- zero_bytes = 2048 - fsize;
- m_streamtype = DTSPaded;
- }
- }
-
- // calculate actual bitrate
- m_framesize = fsize + HD_size + zero_bytes;
- m_bitrate = int ((m_framesize) * 8i64 * m_samplerate / m_framelength); // inaccurate, because HD_size is not constant
-
- // calculate framesize to support a sonic audio decoder 4.3 (TODO: make otherwise)
- // sonicDTSminsize = fsize + HD_size + 4096
- int k = (m_framesize + 4096 + m_framesize - 1) / m_framesize;
- m_framesize *= k;
- m_framelength *= k;
-
- m_wFormatTag = WAVE_FORMAT_DTS;
- m_subtype = MEDIASUBTYPE_DTS;
- }
- // AC3 & E-AC3
- else if ((WORD)id == AC3_SYNC_WORD) {
- BYTE buf[20];
- if (m_file.Read(&buf, 8) != 8) {
- break;
- }
-
- BYTE bsid = (buf[5] >> 3);
- int fsize = 0;
- //int HD_size = 0;
-
- // AC3 header
- if (bsid <= 10) {
- fsize = ParseAC3Header(buf, &m_samplerate, &m_channels, &m_framelength, &m_bitrate);
- if (fsize == 0) {
- break;
- }
- m_streamtype = AC3;
- m_subtype = MEDIASUBTYPE_DOLBY_AC3;
- /*
- // TrueHD+AC3
- m_file.Seek(m_dataOffset+fsize, CFile::begin);
- if (m_file.Read(&buf, 20) == 20) {
- int samplerate2, channels2, framelength2;
- HD_size = ParseTrueHDHeader(buf, &samplerate2, &channels2, &framelength2);
- if (HD_size > 0) {
- m_streamtype = TrueHDAC3;
- m_fixedframesize = false;
- }
- }
- */
- }
- // E-AC3 header
- else if (bsid <= 16) {
- int frametype;
- fsize = ParseEAC3Header(buf, &m_samplerate, &m_channels, &m_framelength, &frametype);
- if (fsize == 0) {
- break;
- }
-
- m_file.Seek(m_dataOffset + fsize, CFile::begin);
- if (m_file.Read(&buf, 8) == 8) {
- int samplerate2, channels2, samples2, frametype2;
- int fsize2 = ParseEAC3Header(buf, &samplerate2, &channels2, &samples2, &frametype2);
- if (fsize2 > 0 && frametype2 == EAC3_FRAME_TYPE_DEPENDENT) {
- fsize += fsize2;
- }
- }
- m_bitrate = int (fsize * 8i64 * m_samplerate / m_framelength);
- m_streamtype = EAC3;
- m_subtype = MEDIASUBTYPE_DOLBY_DDPLUS;
- } else { //unknown bsid
- break;
- }
-
- // calculate framesize to support a sonic audio decoder 4.3 (TODO: make otherwise)
- // sonicAC3minsize = framesize + 64
- m_framesize = fsize * 2;
- m_framelength *= 2;
-
- m_wFormatTag = WAVE_FORMAT_UNKNOWN;
- }
- // SPDIF AC3
- else if (waveheader && id == IEC61937_SYNC_WORD) {
- BYTE buf[16];
- if (m_file.Read(&buf, 16) != 16) {
- break;
- }
- m_framesize = ParseAC3IEC61937Header(buf);
- if (m_framesize == 0) {
- break;
- }
-
- m_wFormatTag = WAVE_FORMAT_DOLBY_AC3_SPDIF;
- m_channels = 2;
- m_samplerate = 44100;
- m_bitrate = 1411200;
- m_bitdepth = 16;
- m_framelength = 1536;
-
- m_subtype = MEDIASUBTYPE_DOLBY_AC3_SPDIF;
- m_streamtype = SPDIF_AC3;
- }
- // MLP
- else if (id2 == MLP_SYNC_WORD) {
- BYTE buf[20];
- if (m_file.Read(&buf, 20) != 20) {
- break;
- }
-
- bool istruehd;
- m_framesize = ParseMLPHeader(buf, &m_samplerate, &m_channels, &m_framelength, &m_bitdepth, &istruehd);
- if (m_framesize == 0) {
- break;
- }
-
- m_streamtype = MLP;
- m_fixedframesize = false;
-
- m_bitrate = (int)(m_framesize * 8i64 * m_samplerate / m_framelength); // inaccurate, because framesize is not constant
-
- m_wFormatTag = WAVE_FORMAT_UNKNOWN;
- m_subtype = MEDIASUBTYPE_MLP;
- }
- /*
- // TrueHD
- else if (id2 == TRUEHD_SYNC_WORD) {
- BYTE buf[20];
- if (m_file.Read(&buf, 20) != 20)
- break;
- int fsize = 0;
- int fsize2 = 0;
- fsize = ParseTrueHDHeader(buf, &m_samplerate, &m_channels, &m_framelength);
- if (fsize == 0)
- break;
- m_streamtype = TrueHD;
- m_fixedframesize = false;
-
- // TrueHD+AC3
- if (m_file.Read(&buf, 8) == 8) {
- int samplerate2, channels2, framelength2, bitrate2;
- fsize2 = ParseAC3Header(buf, &samplerate2, &channels2, &framelength2, &bitrate2);
- if (fsize2 > 0) {
- m_streamtype = TrueHDAC3;
-
- if (samplerate2 > 0) {
- m_samplerate = samplerate2;
- m_framelength = framelength2;
- }
- }
- }
-
- m_framesize = fsize + fsize2;
- m_bitrate = int ((m_framesize) * 8i64 * m_samplerate / m_framelength);
- //m_bitdepth = 24;
-
- m_wFormatTag = WAVE_FORMAT_UNKNOWN;
- m_subtype = MEDIASUBTYPE_DOLBY_TRUEHD;
- */
- else {
- break;
- }
-
- if (m_samplerate > 0) {
- m_AvgTimePerFrame = 10000000i64 * m_framelength / m_samplerate;
- }
- m_rtDuration = m_AvgTimePerFrame * (m_file.GetLength() - m_dataOffset) / m_framesize;
- m_rtStop = m_rtDuration;
-
- hr = S_OK;
- } while (false);
-
- if (phr) {
- *phr = hr;
- }
-}
-
-CDTSAC3Stream::~CDTSAC3Stream()
-{
-}
-
-HRESULT CDTSAC3Stream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties)
-{
- ASSERT(pAlloc);
- ASSERT(pProperties);
-
- HRESULT hr = NOERROR;
-
- pProperties->cBuffers = 1;
- pProperties->cbBuffer = m_framesize;
-
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
- return hr;
- }
-
- if (Actual.cbBuffer < pProperties->cbBuffer) {
- return E_FAIL;
- }
- ASSERT(Actual.cBuffers == pProperties->cBuffers);
-
- return NOERROR;
-}
-
-HRESULT CDTSAC3Stream::FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, long& len)
-{
- BYTE* pOutOrg = pOut;
-
- const GUID* majortype = &m_mt.majortype;
- const GUID* subtype = &m_mt.subtype;
- UNREFERENCED_PARAMETER(subtype);
-
- if (*majortype == MEDIATYPE_Audio) {
- m_file.Seek(m_dataOffset + nFrame * m_framesize, CFile::begin);
- if ((int)m_file.Read(pOut, m_framesize) < m_framesize) {
- return S_FALSE;
- }
- pOut += m_framesize;
- }
-
- len = (long)(pOut - pOutOrg);
-
- return S_OK;
-}
-
-HRESULT CDTSAC3Stream::GetMediaType(int iPosition, CMediaType* pmt)
-{
- CAutoLock cAutoLock(m_pFilter->pStateLock());
-
- if (iPosition == 0) {
- pmt->majortype = MEDIATYPE_Audio;
- pmt->subtype = m_subtype;
- pmt->formattype = FORMAT_WaveFormatEx;
-
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
- wfe->wFormatTag = m_wFormatTag;
- wfe->nChannels = m_channels;
- wfe->nSamplesPerSec = m_samplerate;
- wfe->nAvgBytesPerSec = (m_bitrate + 4) / 8;
- wfe->nBlockAlign = m_framesize < WORD_MAX ? m_framesize : WORD_MAX;
- wfe->wBitsPerSample = m_bitdepth;
- wfe->cbSize = 0;
-
- if (m_streamtype == SPDIF_AC3) {
- wfe->nBlockAlign = 4;
- pmt->SetSampleSize(m_framesize);
- } else if (m_streamtype == MLP /*|| m_streamtype == TrueHD*/) {
- pmt->SetSampleSize(0);
- }
-
- } else {
- return VFW_S_NO_MORE_ITEMS;
- }
-
- pmt->SetTemporalCompression(FALSE);
-
- return S_OK;
-}
-
-HRESULT CDTSAC3Stream::CheckMediaType(const CMediaType* pmt)
-{
- if (pmt->majortype == MEDIATYPE_Audio && pmt->formattype == FORMAT_WaveFormatEx) {
- WORD& wFmtTag = ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag;
-
- if (pmt->subtype == MEDIASUBTYPE_DTS && wFmtTag == WAVE_FORMAT_DTS) {
- return S_OK;
- } else if (pmt->subtype == MEDIASUBTYPE_WAVE_DTS && wFmtTag == WAVE_FORMAT_DVD_DTS) {
- return S_OK;
- } else if (pmt->subtype == MEDIASUBTYPE_DOLBY_AC3 && (wFmtTag == WAVE_FORMAT_UNKNOWN || wFmtTag == WAVE_FORMAT_DOLBY_AC3)) {
- return S_OK;
- } else if (pmt->subtype == MEDIASUBTYPE_DOLBY_DDPLUS && wFmtTag == WAVE_FORMAT_UNKNOWN) {
- return S_OK;
- } else if (pmt->subtype == MEDIASUBTYPE_DOLBY_AC3_SPDIF && wFmtTag == WAVE_FORMAT_DOLBY_AC3_SPDIF) {
- return S_OK;
- } else if (pmt->subtype == MEDIASUBTYPE_MLP && wFmtTag == WAVE_FORMAT_UNKNOWN) {
- return S_OK;
- }
- //else if (pmt->subtype == MEDIASUBTYPE_DOLBY_TRUEHD && wFmtTag == WAVE_FORMAT_UNKNOWN) {
- // return S_OK;
- //}
- }
- return E_INVALIDARG;
-}
diff --git a/src/filters/source/DTSAC3Source/DTSAC3Source.def b/src/filters/source/DTSAC3Source/DTSAC3Source.def
deleted file mode 100644
index 6492e5cd6..000000000
--- a/src/filters/source/DTSAC3Source/DTSAC3Source.def
+++ /dev/null
@@ -1,5 +0,0 @@
-EXPORTS
- DllCanUnloadNow PRIVATE
- DllGetClassObject PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
diff --git a/src/filters/source/DTSAC3Source/DTSAC3Source.h b/src/filters/source/DTSAC3Source/DTSAC3Source.h
deleted file mode 100644
index c1d2ab8e1..000000000
--- a/src/filters/source/DTSAC3Source/DTSAC3Source.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <atlbase.h>
-#include "../BaseSource/BaseSource.h"
-
-#define DTSAC3SourceName L"MPC DTS/AC3/DD+ Source"
-
-class CDTSAC3Stream;
-
-class __declspec(uuid("B4A7BE85-551D-4594-BDC7-832B09185041"))
- CDTSAC3Source : public CBaseSource<CDTSAC3Stream>
-{
-public:
- CDTSAC3Source(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CDTSAC3Source();
-
- // CBaseFilter
- STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
-};
-
-class CDTSAC3Stream : public CBaseStream
-{
- CFile m_file;
- LONGLONG m_dataOffset;
-
- GUID m_subtype;
- WORD m_wFormatTag;
- int m_channels; // number of channels
- int m_samplerate; // samples per second
- int m_bitrate; // bits per second
- int m_framesize; // bytes per frame
- bool m_fixedframesize; // constant frame size
- int m_framelength; // samples per frame
- WORD m_bitdepth; // bits per sample
- BYTE m_streamtype;
-
-public:
- CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr);
- virtual ~CDTSAC3Stream();
-
- HRESULT FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, long& len);
-
- HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT CheckMediaType(const CMediaType* pMediaType);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
-};
diff --git a/src/filters/source/DTSAC3Source/DTSAC3Source.rc b/src/filters/source/DTSAC3Source/DTSAC3Source.rc
deleted file mode 100644
index 006ff960f..000000000
--- a/src/filters/source/DTSAC3Source/DTSAC3Source.rc
+++ /dev/null
@@ -1,102 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-#include "version.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (United States) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION MPC_VERSION_NUM
- PRODUCTVERSION MPC_VERSION_NUM
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS VOS_NT_WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE VFT2_UNKNOWN
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", MPC_VERSION_COMMENTS
- VALUE "CompanyName", MPC_COMP_NAME_STR
- VALUE "FileDescription", "DTS/AC3 Source Filter"
- VALUE "FileVersion", MPC_VERSION_STR_FULL
- VALUE "InternalName", "DTS/AC3 Source Filter"
- VALUE "LegalCopyright", MPC_COPYRIGHT_STR
- VALUE "OriginalFilename", "DTSAC3Source.ax"
- VALUE "ProductName", "DTS/AC3 Source Filter"
- VALUE "ProductVersion", MPC_VERSION_STR_FULL
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // English (United States) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/src/filters/source/DTSAC3Source/DTSAC3Source.vcxproj b/src/filters/source/DTSAC3Source/DTSAC3Source.vcxproj
deleted file mode 100644
index 4c91a3b4e..000000000
--- a/src/filters/source/DTSAC3Source/DTSAC3Source.vcxproj
+++ /dev/null
@@ -1,253 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug Filter|Win32">
- <Configuration>Debug Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug Filter|x64">
- <Configuration>Debug Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|Win32">
- <Configuration>Release Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|x64">
- <Configuration>Release Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{30D48874-899F-41C6-9B26-A40C96C91102}</ProjectGuid>
- <RootNamespace>DTSAC3Source</RootNamespace>
- <Keyword>MFCProj</Keyword>
- <ProjectName>DTSAC3Source</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <Import Project="..\..\..\platform.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">.ax</TargetExt>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>DTSAC3Source.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>DTSAC3Source.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>DTSAC3Source.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>DTSAC3Source.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="DTSAC3Source.cpp" />
- <ClCompile Include="stdafx.cpp">
- <PrecompiledHeader>Create</PrecompiledHeader>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="DTSAC3Source.def" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="DTSAC3Source.h" />
- <ClInclude Include="resource.h">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ClInclude>
- <ClInclude Include="stdafx.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="DTSAC3Source.rc">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ResourceCompile>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\DSUtil\DSUtil.vcxproj">
- <Project>{fc70988b-1ae5-4381-866d-4f405e28ac42}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\Kasumi\Kasumi.vcxproj">
- <Project>{0d252872-7542-4232-8d02-53f9182aee15}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\system\system.vcxproj">
- <Project>{c2082189-3ecb-4079-91fa-89d3c8a305c0}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\BaseClasses\BaseClasses.vcxproj">
- <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\Filters.vcxproj">
- <Project>{273b3149-3192-4b75-a791-470320b90812}</Project>
- </ProjectReference>
- <ProjectReference Include="..\BaseSource\BaseSource.vcxproj">
- <Project>{f50e74c2-5be7-4c9b-b1e7-6ca19cfad34e}</Project>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/source/DTSAC3Source/DTSAC3Source.vcxproj.filters b/src/filters/source/DTSAC3Source/DTSAC3Source.vcxproj.filters
deleted file mode 100644
index 553d420d0..000000000
--- a/src/filters/source/DTSAC3Source/DTSAC3Source.vcxproj.filters
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{a3970398-8a5f-4b11-a1c1-9dabcdfb8d02}</UniqueIdentifier>
- <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{803d81e6-1204-446a-b372-77e7af507a41}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{dbdf0199-c1aa-485e-ad11-4308b4b1f168}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="DTSAC3Source.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="stdafx.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="DTSAC3Source.def">
- <Filter>Source Files</Filter>
- </None>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="DTSAC3Source.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="resource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="stdafx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="DTSAC3Source.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/source/DTSAC3Source/resource.h b/src/filters/source/DTSAC3Source/resource.h
deleted file mode 100644
index de6a5d12c..000000000
--- a/src/filters/source/DTSAC3Source/resource.h
+++ /dev/null
@@ -1,14 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by DTSAC3Source.rc
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 101
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/filters/source/DTSAC3Source/stdafx.cpp b/src/filters/source/DTSAC3Source/stdafx.cpp
deleted file mode 100644
index 784f2cebc..000000000
--- a/src/filters/source/DTSAC3Source/stdafx.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
diff --git a/src/filters/source/DTSAC3Source/stdafx.h b/src/filters/source/DTSAC3Source/stdafx.h
deleted file mode 100644
index 5b6b09e05..000000000
--- a/src/filters/source/DTSAC3Source/stdafx.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../../DSUtil/SharedInclude.h"
-#include "../../../../include/stdafx_common.h"
-#include "../../../../include/stdafx_common_afx.h"
-#include "../../../../include/stdafx_common_dshow.h"
diff --git a/src/filters/source/FLACSource/FLACSource.cpp b/src/filters/source/FLACSource/FLACSource.cpp
deleted file mode 100644
index c6db94211..000000000
--- a/src/filters/source/FLACSource/FLACSource.cpp
+++ /dev/null
@@ -1,494 +0,0 @@
-/*
- * (C) 2009-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <MMReg.h>
-#include <ks.h>
-#ifdef STANDALONE_FILTER
-#include <InitGuid.h>
-#endif
-#include <uuids.h>
-#include "moreuuids.h"
-#include "FLACSource.h"
-#include "../../../DSUtil/DSUtil.h"
-#include "libflac/src/libflac/include/protected/stream_decoder.h"
-
-#define _DECODER_ (FLAC__StreamDecoder*)m_pDecoder
-
-#ifdef STANDALONE_FILTER
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_FLAC_FRAMED}
-};
-
-const AMOVIESETUP_PIN sudOpPin[] = {
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesOut), sudPinTypesOut}
-};
-
-const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CFLACSource), FlacSourceName, MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
-};
-
-CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CFLACSource>, nullptr, &sudFilter[0]}
-};
-
-int g_cTemplates = _countof(g_Templates);
-
-STDAPI DllRegisterServer()
-{
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"),
- _T("0"), _T("0,4,,664C6143"));
-
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"),
- _T("Source Filter"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"));
-
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".flac"),
- _T("Source Filter"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"));
-
- return AMovieDllRegisterServer2(TRUE);
-}
-
-STDAPI DllUnregisterServer()
-{
- DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".flac"));
-
- return AMovieDllRegisterServer2(FALSE);
-}
-
-#include "../../FilterApp.h"
-
-CFilterApp theApp;
-
-#endif
-
-
-// Declaration for FLAC callbacks
-static FLAC__StreamDecoderReadStatus StreamDecoderRead(const FLAC__StreamDecoder* decoder, FLAC__byte buffer[], size_t* bytes, void* client_data);
-static FLAC__StreamDecoderSeekStatus StreamDecoderSeek(const FLAC__StreamDecoder* decoder, FLAC__uint64 absolute_byte_offset, void* client_data);
-static FLAC__StreamDecoderTellStatus StreamDecoderTell(const FLAC__StreamDecoder* decoder, FLAC__uint64* absolute_byte_offset, void* client_data);
-static FLAC__StreamDecoderLengthStatus StreamDecoderLength(const FLAC__StreamDecoder* decoder, FLAC__uint64* stream_length, void* client_data);
-static FLAC__bool StreamDecoderEof(const FLAC__StreamDecoder* decoder, void* client_data);
-static FLAC__StreamDecoderWriteStatus StreamDecoderWrite(const FLAC__StreamDecoder* decoder, const FLAC__Frame* frame, const FLAC__int32* const buffer[], void* client_data);
-static void StreamDecoderError(const FLAC__StreamDecoder* decoder, FLAC__StreamDecoderErrorStatus status, void* client_data);
-static void StreamDecoderMetadata(const FLAC__StreamDecoder* decoder, const FLAC__StreamMetadata* metadata, void* client_data);
-
-
-//
-// CFLACSource
-//
-
-CFLACSource::CFLACSource(LPUNKNOWN lpunk, HRESULT* phr)
- : CBaseSource<CFLACStream>(NAME("CFLACSource"), lpunk, phr, __uuidof(this))
-{
-}
-
-CFLACSource::~CFLACSource()
-{
-}
-
-STDMETHODIMP CFLACSource::NonDelegatingQueryInterface(REFIID riid, void** ppv)
-{
- CheckPointer(ppv, E_POINTER);
-
- return
- QI(IDSMChapterBag)
- QI2(IAMMediaContent)
- __super::NonDelegatingQueryInterface(riid, ppv);
-}
-
-STDMETHODIMP CFLACSource::QueryFilterInfo(FILTER_INFO* pInfo)
-{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
- wcscpy_s(pInfo->achName, FlacSourceName);
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
-}
-
-STDMETHODIMP CFLACSource::get_AuthorName(BSTR* pbstrAuthorName)
-{
- CheckPointer(pbstrAuthorName, E_POINTER);
- HRESULT hr = VFW_E_NOT_FOUND;
-
- CString author;
- if (GetFLACStream()->GetComment(_T("artist"), author)) {
- *pbstrAuthorName = author.AllocSysString();
- hr = S_OK;
- }
-
- return hr;
-}
-
-STDMETHODIMP CFLACSource::get_Title(BSTR* pbstrTitle)
-{
- CheckPointer(pbstrTitle, E_POINTER);
- HRESULT hr = VFW_E_NOT_FOUND;
-
- CString title;
- if (GetFLACStream()->GetComment(_T("title"), title)) {
- *pbstrTitle = title.AllocSysString();
- hr = S_OK;
- }
-
- return hr;
-}
-
-STDMETHODIMP CFLACSource::get_Description(BSTR* pbstrDescription)
-{
- CheckPointer(pbstrDescription, E_POINTER);
- HRESULT hr = VFW_E_NOT_FOUND;
-
- CString desc;
- if (GetFLACStream()->GetComment(_T("description"), desc)) {
- *pbstrDescription = desc.AllocSysString();
- hr = S_OK;
- }
-
- return hr;
-}
-
-STDMETHODIMP CFLACSource::get_Copyright(BSTR* pbstrCopyright)
-{
- CheckPointer(pbstrCopyright, E_POINTER);
- HRESULT hr = VFW_E_NOT_FOUND;
-
- CString copyright;
- if (GetFLACStream()->GetComment(_T("copyright"), copyright)
- || GetFLACStream()->GetComment(_T("date"), copyright)) {
- *pbstrCopyright = copyright.AllocSysString();
- hr = S_OK;
- }
-
- return hr;
-}
-
-// CFLACStream
-
-CFLACStream::CFLACStream(const WCHAR* wfn, CSource* pParent, HRESULT* phr)
- : CBaseStream(NAME("CFLACStream"), pParent, phr)
- , m_bIsEOF(false)
- , m_pDecoder(nullptr)
-{
- CAutoLock cAutoLock(&m_cSharedState);
- CString fn(wfn);
- CFileException ex;
- HRESULT hr = E_FAIL;
-
- do {
- if (!m_file.Open(fn, CFile::modeRead | CFile::shareDenyNone, &ex)) {
- hr = AmHresultFromWin32(ex.m_lOsError);
- break;
- }
-
- m_pDecoder = FLAC__stream_decoder_new();
- if (!m_pDecoder) {
- break;
- }
-
- // We want to get the embedded CUE sheet and the Vorbis tags if available
- FLAC__stream_decoder_set_metadata_respond(_DECODER_, FLAC__METADATA_TYPE_CUESHEET);
- FLAC__stream_decoder_set_metadata_respond(_DECODER_, FLAC__METADATA_TYPE_VORBIS_COMMENT);
-
- if (FLAC__STREAM_DECODER_INIT_STATUS_OK != FLAC__stream_decoder_init_stream(_DECODER_,
- StreamDecoderRead,
- StreamDecoderSeek,
- StreamDecoderTell,
- StreamDecoderLength,
- StreamDecoderEof,
- StreamDecoderWrite,
- StreamDecoderMetadata,
- StreamDecoderError,
- this)) {
- break;
- }
-
-
- if (!FLAC__stream_decoder_process_until_end_of_metadata(_DECODER_) ||
- !FLAC__stream_decoder_seek_absolute(_DECODER_, 0)) {
- break;
- }
-
- FLAC__stream_decoder_get_decode_position(_DECODER_, &m_llOffset);
-
- hr = S_OK;
- } while (false);
-
- if (phr) {
- *phr = hr;
- }
-}
-
-CFLACStream::~CFLACStream()
-{
- if (m_pDecoder) {
- FLAC__stream_decoder_delete(_DECODER_);
- m_pDecoder = nullptr;
- }
-}
-
-HRESULT CFLACStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties)
-{
- ASSERT(pAlloc);
- ASSERT(pProperties);
-
- HRESULT hr = NOERROR;
-
- pProperties->cBuffers = 1;
- pProperties->cbBuffer = m_nMaxFrameSize;
-
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
- return hr;
- }
-
- if (Actual.cbBuffer < pProperties->cbBuffer) {
- return E_FAIL;
- }
- ASSERT(Actual.cBuffers == pProperties->cBuffers);
-
- return NOERROR;
-}
-
-HRESULT CFLACStream::FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, long& len)
-{
- FLAC__uint64 llCurPos;
- FLAC__uint64 llNextPos;
-
- if (m_bDiscontinuity) {
- FLAC__stream_decoder_seek_absolute(_DECODER_, (m_rtPosition * m_i64TotalNumSamples) / m_rtDuration);
- }
-
- FLAC__stream_decoder_get_decode_position(_DECODER_, &llCurPos);
-
- FLAC__stream_decoder_skip_single_frame(_DECODER_);
- if (m_bIsEOF) {
- return S_FALSE;
- }
- FLAC__stream_decoder_get_decode_position(_DECODER_, &llNextPos);
-
- FLAC__uint64 llCurFile = m_file.GetPosition();
- len = (long)(llNextPos - llCurPos);
- ASSERT(len > 0);
- if (len <= 0) {
- return S_FALSE;
- } else if (len > m_nMaxFrameSize) { // Probably a corrupted file but try to play it anyway
- len = m_nMaxFrameSize;
- }
-
- m_file.Seek(llCurPos, CFile::begin);
- m_file.Read(pOut, len);
- m_file.Seek(llCurFile, CFile::begin);
-
- if ((_DECODER_)->protected_->blocksize > 0 && (_DECODER_)->protected_->sample_rate > 0) {
- m_AvgTimePerFrame = (_DECODER_)->protected_->blocksize * UNITS / (_DECODER_)->protected_->sample_rate;
- } else {
- m_AvgTimePerFrame = m_rtDuration * len / (m_llFileSize - m_llOffset);
- }
-
- return S_OK;
-}
-
-HRESULT CFLACStream::GetMediaType(int iPosition, CMediaType* pmt)
-{
- CAutoLock cAutoLock(m_pFilter->pStateLock());
-
- if (iPosition == 0) {
- pmt->majortype = MEDIATYPE_Audio;
- pmt->subtype = MEDIASUBTYPE_FLAC_FRAMED;
- pmt->formattype = FORMAT_WaveFormatEx;
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
- ZeroMemory(wfe, sizeof(WAVEFORMATEX));
- wfe->wFormatTag = WAVE_FORMAT_FLAC;
- wfe->nChannels = m_nChannels;
- wfe->nSamplesPerSec = m_nSamplesPerSec;
- wfe->nAvgBytesPerSec = m_nAvgBytesPerSec;
- wfe->nBlockAlign = 1;
- wfe->wBitsPerSample = m_wBitsPerSample;
- wfe->cbSize = 0;
- } else {
- return VFW_S_NO_MORE_ITEMS;
- }
-
- pmt->SetTemporalCompression(FALSE);
-
- return S_OK;
-}
-
-HRESULT CFLACStream::CheckMediaType(const CMediaType* pmt)
-{
- if (pmt->majortype == MEDIATYPE_Audio
- && pmt->subtype == MEDIASUBTYPE_FLAC_FRAMED
- && pmt->formattype == FORMAT_WaveFormatEx
- && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_FLAC) {
- return S_OK;
- } else {
- return E_INVALIDARG;
- }
-}
-
-void CFLACStream::UpdateFromMetadata(void* pBuffer)
-{
- const FLAC__StreamMetadata* pMetadata = (const FLAC__StreamMetadata*) pBuffer;
-
- if (pMetadata->type == FLAC__METADATA_TYPE_STREAMINFO) {
- m_nMaxFrameSize = pMetadata->data.stream_info.max_framesize;
- m_nSamplesPerSec = pMetadata->data.stream_info.sample_rate;
- m_nChannels = pMetadata->data.stream_info.channels;
- m_wBitsPerSample = pMetadata->data.stream_info.bits_per_sample;
- m_i64TotalNumSamples = pMetadata->data.stream_info.total_samples;
- m_nAvgBytesPerSec = (m_nChannels * (m_wBitsPerSample >> 3)) * m_nSamplesPerSec;
-
- if (!m_nMaxFrameSize) { // Estimate a maximum frame size
- m_nMaxFrameSize = (2 * m_wBitsPerSample * m_nChannels * pMetadata->data.stream_info.max_blocksize + 7) / 8;
- }
-
- // === Init members from base classes
- GetFileSizeEx(m_file.m_hFile, (LARGE_INTEGER*)&m_llFileSize);
- m_rtDuration = (m_i64TotalNumSamples * UNITS) / m_nSamplesPerSec;
- m_rtStop = m_rtDuration;
- m_AvgTimePerFrame = (m_nMaxFrameSize + pMetadata->data.stream_info.min_framesize) * m_rtDuration / 2 / m_llFileSize;
- } else if (pMetadata->type == FLAC__METADATA_TYPE_CUESHEET) {
- CString s;
- REFERENCE_TIME rt;
- for (unsigned int i = 0; i < pMetadata->data.cue_sheet.num_tracks; ++i) {
- FLAC__StreamMetadata_CueSheet_Track& track = pMetadata->data.cue_sheet.tracks[i];
- // Ignore non-audio tracks and lead-out track
- if (track.type != 0
- || (pMetadata->data.cue_sheet.is_cd && track.number == 170)
- || (!pMetadata->data.cue_sheet.is_cd && track.number == 255)) {
- continue;
- }
-
- rt = MILLISECONDS_TO_100NS_UNITS(1000 * track.offset / m_nSamplesPerSec);
- s.Format(_T("Track %02u"), i + 1);
- ((CFLACSource*)m_pFilter)->ChapAppend(rt, s);
-
- if (track.num_indices > 1) {
- for (int j = 0; j < track.num_indices; ++j) {
- FLAC__StreamMetadata_CueSheet_Index& index = track.indices[j];
- s.Format(_T("+ INDEX %02u"), index.number);
- REFERENCE_TIME r = rt + MILLISECONDS_TO_100NS_UNITS(1000 * index.offset / m_nSamplesPerSec);
- ((CFLACSource*)m_pFilter)->ChapAppend(r, s);
- }
- }
- }
- } else if (pMetadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) {
- for (unsigned int i = 0; i < pMetadata->data.vorbis_comment.num_comments; i++) {
- FLAC__StreamMetadata_VorbisComment_Entry& entry = pMetadata->data.vorbis_comment.comments[i];
- CStringA comment((char*)entry.entry, (int)entry.length);
- int nSepPos = comment.Find("=");
-
- if (nSepPos > 0) {
- CString tag = UTF8To16(comment.Left(nSepPos)).MakeLower();
- CString content = UTF8To16(comment.Mid(nSepPos + 1));
-
- CString oldContent;
- if (m_vorbisComments.Lookup(tag, oldContent)) {
- m_vorbisComments[tag].Append(_T(", "));
- m_vorbisComments[tag].Append(content);
- } else {
- m_vorbisComments[tag] = content;
- }
- }
- }
- }
-}
-
-bool CFLACStream::GetComment(const CString& tag, CString& content) const
-{
- return !!m_vorbisComments.Lookup(tag, content);
-}
-
-FLAC__StreamDecoderReadStatus StreamDecoderRead(const FLAC__StreamDecoder* decoder, FLAC__byte buffer[], size_t* bytes, void* client_data)
-{
- CFLACStream* pThis = static_cast<CFLACStream*>(client_data);
- UINT nRead = pThis->GetFile()->Read(buffer, (UINT) * bytes);
-
- pThis->m_bIsEOF = (nRead != *bytes);
- *bytes = nRead;
-
- return (*bytes == 0) ? FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM : FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
-}
-
-FLAC__StreamDecoderSeekStatus StreamDecoderSeek(const FLAC__StreamDecoder* decoder, FLAC__uint64 absolute_byte_offset, void* client_data)
-{
- CFLACStream* pThis = static_cast<CFLACStream*>(client_data);
-
- pThis->m_bIsEOF = false;
- pThis->GetFile()->Seek(absolute_byte_offset, CFile::begin);
- return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
-}
-
-FLAC__StreamDecoderTellStatus StreamDecoderTell(const FLAC__StreamDecoder* decoder, FLAC__uint64* absolute_byte_offset, void* client_data)
-{
- CFLACStream* pThis = static_cast<CFLACStream*>(client_data);
- *absolute_byte_offset = pThis->GetFile()->GetPosition();
- return FLAC__STREAM_DECODER_TELL_STATUS_OK;
-}
-
-FLAC__StreamDecoderLengthStatus StreamDecoderLength(const FLAC__StreamDecoder* decoder, FLAC__uint64* stream_length, void* client_data)
-{
- CFLACStream* pThis = static_cast<CFLACStream*>(client_data);
- CFile* pFile = pThis->GetFile();
-
- if (pFile == nullptr) {
- return FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED;
- } else {
- *stream_length = pFile->GetLength();
- return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
- }
-}
-
-FLAC__bool StreamDecoderEof(const FLAC__StreamDecoder* decoder, void* client_data)
-{
- CFLACStream* pThis = static_cast<CFLACStream*>(client_data);
-
- return pThis->m_bIsEOF;
-}
-
-FLAC__StreamDecoderWriteStatus StreamDecoderWrite(const FLAC__StreamDecoder* decoder, const FLAC__Frame* frame, const FLAC__int32* const buffer[], void* client_data)
-{
- CFLACStream* pThis = static_cast<CFLACStream*>(client_data);
- UNREFERENCED_PARAMETER(pThis);
-
- return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
-}
-
-void StreamDecoderError(const FLAC__StreamDecoder* decoder, FLAC__StreamDecoderErrorStatus status, void* client_data)
-{
-}
-
-void StreamDecoderMetadata(const FLAC__StreamDecoder* decoder, const FLAC__StreamMetadata* metadata, void* client_data)
-{
- CFLACStream* pThis = static_cast<CFLACStream*>(client_data);
-
- if (pThis) {
- pThis->UpdateFromMetadata((void*)metadata);
- }
-}
diff --git a/src/filters/source/FLACSource/FLACSource.def b/src/filters/source/FLACSource/FLACSource.def
deleted file mode 100644
index 6492e5cd6..000000000
--- a/src/filters/source/FLACSource/FLACSource.def
+++ /dev/null
@@ -1,5 +0,0 @@
-EXPORTS
- DllCanUnloadNow PRIVATE
- DllGetClassObject PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
diff --git a/src/filters/source/FLACSource/FLACSource.h b/src/filters/source/FLACSource/FLACSource.h
deleted file mode 100644
index 111577956..000000000
--- a/src/filters/source/FLACSource/FLACSource.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * (C) 2009-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <atlbase.h>
-#include <qnetwork.h>
-#include "../BaseSource/BaseSource.h"
-#include "../../../DSUtil/DSMPropertyBag.h"
-
-#define FlacSourceName L"MPC FLAC Source"
-
-class CFLACStream;
-
-class __declspec(uuid("1930D8FF-4739-4e42-9199-3B2EDEAA3BF2"))
- CFLACSource
- : public CBaseSource<CFLACStream>
- , public IAMMediaContent
- , public IDSMChapterBagImpl
-{
- CFLACStream* GetFLACStream() { return (CFLACStream*)m_paStreams[0]; }
-
-public:
- CFLACSource(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CFLACSource();
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // CBaseFilter
- STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
-
- // IDispatch
-
- STDMETHODIMP GetTypeInfoCount(UINT* pctinfo) { return E_NOTIMPL; }
- STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo) { return E_NOTIMPL; }
- STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** rgszNames, UINT cNames, LCID lcid, DISPID* rgdispid) { return E_NOTIMPL; }
- STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult, EXCEPINFO* pexcepinfo, UINT* puArgErr) { return E_NOTIMPL; }
-
- // IAMMediaContent
-
- STDMETHODIMP get_AuthorName(BSTR* pbstrAuthorName);
- STDMETHODIMP get_Title(BSTR* pbstrTitle);
- STDMETHODIMP get_Description(BSTR* pbstrDescription);
- STDMETHODIMP get_Copyright(BSTR* pbstrCopyright);
- STDMETHODIMP get_Rating(BSTR* pbstrRating) { return E_NOTIMPL; }
- STDMETHODIMP get_BaseURL(BSTR* pbstrBaseURL) { return E_NOTIMPL; }
- STDMETHODIMP get_LogoURL(BSTR* pbstrLogoURL) { return E_NOTIMPL; }
- STDMETHODIMP get_LogoIconURL(BSTR* pbstrLogoURL) { return E_NOTIMPL; }
- STDMETHODIMP get_WatermarkURL(BSTR* pbstrWatermarkURL) { return E_NOTIMPL; }
- STDMETHODIMP get_MoreInfoURL(BSTR* pbstrMoreInfoURL) { return E_NOTIMPL; }
- STDMETHODIMP get_MoreInfoBannerImage(BSTR* pbstrMoreInfoBannerImage) { return E_NOTIMPL; }
- STDMETHODIMP get_MoreInfoBannerURL(BSTR* pbstrMoreInfoBannerURL) { return E_NOTIMPL; }
- STDMETHODIMP get_MoreInfoText(BSTR* pbstrMoreInfoText) { return E_NOTIMPL; }
-};
-
-class CGolombBuffer;
-
-class CFLACStream : public CBaseStream
-{
- CFile m_file;
- void* m_pDecoder;
-
- int m_nMaxFrameSize;
- int m_nSamplesPerSec;
- int m_nChannels;
- WORD m_wBitsPerSample;
- __int64 m_i64TotalNumSamples;
- int m_nAvgBytesPerSec;
-
- ULONGLONG m_llOffset; // Position of first frame in file
- ULONGLONG m_llFileSize; // Size of the file
-
- CMapStringToString m_vorbisComments;
-
-public:
- CFLACStream(const WCHAR* wfn, CSource* pParent, HRESULT* phr);
- virtual ~CFLACStream();
-
- HRESULT FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, long& len);
-
- HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT CheckMediaType(const CMediaType* pMediaType);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
-
- void UpdateFromMetadata(void* pBuffer);
- inline CFile* GetFile() { return &m_file; };
-
- bool GetComment(const CString& tag, CString& content) const;
-
- bool m_bIsEOF;
-};
diff --git a/src/filters/source/FLACSource/FLACSource.rc b/src/filters/source/FLACSource/FLACSource.rc
deleted file mode 100644
index 8ea43c31c..000000000
--- a/src/filters/source/FLACSource/FLACSource.rc
+++ /dev/null
@@ -1,103 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-#include "version.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (United States) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION MPC_VERSION_NUM
- PRODUCTVERSION MPC_VERSION_NUM
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS VOS_NT_WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE VFT2_UNKNOWN
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", MPC_VERSION_COMMENTS
- VALUE "CompanyName", MPC_COMP_NAME_STR
- VALUE "FileDescription", "FLAC Source Filter"
- VALUE "FileVersion", MPC_VERSION_STR_FULL
- VALUE "InternalName", "FLAC Source Filter"
- VALUE "LegalCopyright", MPC_COPYRIGHT_STR
- VALUE "OriginalFilename", "FLACSource.ax"
- VALUE "ProductName", "FLAC Source Filter"
- VALUE "ProductVersion", MPC_VERSION_STR_FULL
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // English (United States) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
-
diff --git a/src/filters/source/FLACSource/FLACSource.vcxproj b/src/filters/source/FLACSource/FLACSource.vcxproj
deleted file mode 100644
index ec83fda74..000000000
--- a/src/filters/source/FLACSource/FLACSource.vcxproj
+++ /dev/null
@@ -1,260 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug Filter|Win32">
- <Configuration>Debug Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug Filter|x64">
- <Configuration>Debug Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|Win32">
- <Configuration>Release Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|x64">
- <Configuration>Release Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{916D0FC1-1D86-487A-82DE-37FBEE43FB34}</ProjectGuid>
- <RootNamespace>FLACSource</RootNamespace>
- <Keyword>MFCProj</Keyword>
- <ProjectName>FLACSource</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <Import Project="..\..\..\platform.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">.ax</TargetExt>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\libflac\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;FLAC__NO_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\libflac\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;FLAC__NO_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\libflac\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;FLAC__NO_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\libflac\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;FLAC__NO_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\libflac\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>FLAC__NO_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>FLACSource.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\libflac\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>FLAC__NO_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>FLACSource.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\libflac\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>FLAC__NO_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>FLACSource.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\libflac\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>FLAC__NO_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>FLACSource.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="FLACSource.cpp" />
- <ClCompile Include="stdafx.cpp">
- <PrecompiledHeader>Create</PrecompiledHeader>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="FLACSource.def" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="FLACSource.h" />
- <ClInclude Include="resource.h">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ClInclude>
- <ClInclude Include="stdafx.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="FLACSource.rc">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ResourceCompile>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\DSUtil\DSUtil.vcxproj">
- <Project>{fc70988b-1ae5-4381-866d-4f405e28ac42}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\Kasumi\Kasumi.vcxproj">
- <Project>{0d252872-7542-4232-8d02-53f9182aee15}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\system\system.vcxproj">
- <Project>{c2082189-3ecb-4079-91fa-89d3c8a305c0}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\BaseClasses\BaseClasses.vcxproj">
- <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\Filters.vcxproj">
- <Project>{273b3149-3192-4b75-a791-470320b90812}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\libflac\src\libFLAC\libflac.vcxproj">
- <Project>{4cefbc84-c215-11db-8314-0800200c9a66}</Project>
- </ProjectReference>
- <ProjectReference Include="..\BaseSource\BaseSource.vcxproj">
- <Project>{f50e74c2-5be7-4c9b-b1e7-6ca19cfad34e}</Project>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/source/FLACSource/FLACSource.vcxproj.filters b/src/filters/source/FLACSource/FLACSource.vcxproj.filters
deleted file mode 100644
index c7a1a5529..000000000
--- a/src/filters/source/FLACSource/FLACSource.vcxproj.filters
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{3610c5ea-606a-4724-8a24-58d52dcdd27b}</UniqueIdentifier>
- <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{31b893ca-d95e-4d9c-b371-890afc4058ea}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{a86368d4-f9b1-4a43-8536-48dc6f51dec7}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="FLACSource.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="stdafx.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="FLACSource.def">
- <Filter>Source Files</Filter>
- </None>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="FLACSource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="resource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="stdafx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="FLACSource.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project>
diff --git a/src/filters/source/FLACSource/resource.h b/src/filters/source/FLACSource/resource.h
deleted file mode 100644
index fefe67e12..000000000
--- a/src/filters/source/FLACSource/resource.h
+++ /dev/null
@@ -1,14 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by FLACSource.rc
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 101
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/filters/source/FLACSource/stdafx.cpp b/src/filters/source/FLACSource/stdafx.cpp
deleted file mode 100644
index 42728ce2e..000000000
--- a/src/filters/source/FLACSource/stdafx.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * (C) 2009-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
diff --git a/src/filters/source/FLACSource/stdafx.h b/src/filters/source/FLACSource/stdafx.h
deleted file mode 100644
index c61418ce9..000000000
--- a/src/filters/source/FLACSource/stdafx.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * (C) 2009-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../../DSUtil/SharedInclude.h"
-#include "../../../../include/stdafx_common.h"
-#include "../../../../include/stdafx_common_afx.h"
-#include "../../../../include/stdafx_common_dshow.h"
diff --git a/src/filters/source/FLICSource/FLICSource.cpp b/src/filters/source/FLICSource/FLICSource.cpp
deleted file mode 100644
index 1e2ef22cd..000000000
--- a/src/filters/source/FLICSource/FLICSource.cpp
+++ /dev/null
@@ -1,790 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "FLICSource.h"
-#include "../../../DSUtil/DSUtil.h"
-
-#ifdef STANDALONE_FILTER
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
- {&MEDIATYPE_Video, &MEDIASUBTYPE_RGB32},
-};
-
-const AMOVIESETUP_PIN sudOpPin[] = {
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesOut), sudPinTypesOut}
-};
-
-const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CFLICSource), FlicSourceName, MERIT_NORMAL, _countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
-};
-
-CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CFLICSource>, nullptr, &sudFilter[0]}
-};
-
-int g_cTemplates = _countof(g_Templates);
-
-STDAPI DllRegisterServer()
-{
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"),
- _T("0"), _T("4,2,,11AF"));
-
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"),
- _T("1"), _T("4,2,,12AF"));
-
- SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"),
- _T("Source Filter"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"));
-
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".fli"),
- _T("Source Filter"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"));
-
- SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".flc"),
- _T("Source Filter"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"));
-
- return AMovieDllRegisterServer2(TRUE);
-}
-
-STDAPI DllUnregisterServer()
-{
- DeleteRegKey(_T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".fli"));
- DeleteRegKey(_T("Media Type\\Extensions"), _T(".flc"));
-
- return AMovieDllRegisterServer2(FALSE);
-}
-
-#include "../../FilterApp.h"
-
-CFilterApp theApp;
-
-#endif
-
-//
-// CFLICSource
-//
-
-CFLICSource::CFLICSource(LPUNKNOWN lpunk, HRESULT* phr)
- : CSource(NAME("CFLICSource"), lpunk, __uuidof(this))
-{
-}
-
-CFLICSource::~CFLICSource()
-{
-}
-
-STDMETHODIMP CFLICSource::NonDelegatingQueryInterface(REFIID riid, void** ppv)
-{
- CheckPointer(ppv, E_POINTER);
-
- return
- QI(IFileSourceFilter)
- QI(IAMFilterMiscFlags)
- __super::NonDelegatingQueryInterface(riid, ppv);
-}
-
-// IFileSourceFilter
-
-STDMETHODIMP CFLICSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
-{
- if (GetPinCount() > 0) {
- return VFW_E_ALREADY_CONNECTED;
- }
-
- HRESULT hr = S_OK;
- if (!(DEBUG_NEW CFLICStream(pszFileName, this, &hr))) {
- return E_OUTOFMEMORY;
- }
-
- if (FAILED(hr)) {
- return hr;
- }
-
- m_fn = pszFileName;
-
- return S_OK;
-}
-
-STDMETHODIMP CFLICSource::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
-{
- if (!ppszFileName) {
- return E_POINTER;
- }
-
- *ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength() + 1) * sizeof(WCHAR));
- if (!(*ppszFileName)) {
- return E_OUTOFMEMORY;
- }
-
- wcscpy_s(*ppszFileName, m_fn.GetLength() + 1, m_fn);
-
- return S_OK;
-}
-
-// IAMFilterMiscFlags
-
-ULONG CFLICSource::GetMiscFlags()
-{
- return AM_FILTER_MISC_FLAGS_IS_SOURCE;
-}
-
-STDMETHODIMP CFLICSource::QueryFilterInfo(FILTER_INFO* pInfo)
-{
- CheckPointer(pInfo, E_POINTER);
- ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
- wcscpy_s(pInfo->achName, FlicSourceName);
- pInfo->pGraph = m_pGraph;
- if (m_pGraph) {
- m_pGraph->AddRef();
- }
-
- return S_OK;
-}
-
-// CFLICStream
-
-CFLICStream::CFLICStream(const WCHAR* wfn, CFLICSource* pParent, HRESULT* phr)
- : CSourceStream(NAME("FLICStream"), phr, pParent, L"Output")
- , CSourceSeeking(NAME("FLICStream"), (IPin*)this, phr, &m_cSharedState)
- , m_bDiscontinuity(FALSE), m_bFlushing(FALSE)
-{
- CAutoLock cAutoLock(&m_cSharedState);
-
- CString fn(wfn);
-
- if (!m_flic.Open(fn, CFile::modeRead | CFile::shareDenyNone)) {
- if (phr) {
- *phr = E_FAIL;
- }
- return;
- }
-
- if (m_flic.Read(&m_hdr, sizeof(m_hdr)) != sizeof(m_hdr)
- || (m_hdr.type != 0xAF11 && m_hdr.type != 0xAF12)
- || m_hdr.depth != 8) {
- if (phr) {
- *phr = E_FAIL;
- }
- return;
- }
-
- if (m_hdr.speed == 0) {
- m_hdr.speed = (m_hdr.type == 0xAF11) ? 5 : 67;
- }
- m_AvgTimePerFrame = (m_hdr.type == 0xAF11)
- ? 10000000i64 * m_hdr.speed / 70
- : 10000000i64 * m_hdr.speed / 1000;
-
- // not tested (lack of test files)
- {
- __int64 pos = m_flic.GetPosition();
- FLIC_PREFIX fp;
- if (m_flic.Read(&fp, sizeof(fp)) != sizeof(fp) || fp.type != 0xF100) {
- m_flic.Seek(pos, CFile::begin);
- } else {
- m_flic.Seek(pos + fp.size, CFile::begin);
- }
- }
-
- FLIC_FRAME_ENTRY ffe;
- unsigned int nFrames = 0;
- m_frames.SetCount(m_hdr.frames);
- while (nFrames < m_hdr.frames && m_flic.Read(&ffe.hdr, sizeof(ffe.hdr)) == sizeof(ffe.hdr) && ffe.hdr.type == 0xF1FA) {
-
- ffe.pos = m_flic.GetPosition();
- ffe.fKeyframe = false;
-
- int chunk = 0;
- while (chunk < ffe.hdr.chunks) {
- FLIC_CHUNK fc;
- if (m_flic.Read(&fc, sizeof(fc)) != sizeof(fc)) {
- break;
- }
- ffe.fKeyframe = ffe.fKeyframe
- || fc.type == FLIC_BRUN
- || fc.type == FLIC_BLACK
- || fc.type == FLIC_COPY
- || fc.type == DTA_BRUN
- || fc.type == DTA_COPY
- || fc.type == KEY_IMAGE;
-
- ULONGLONG pos = m_flic.GetPosition() + fc.size - sizeof(fc);
- if (pos < m_flic.GetLength()) {
- m_flic.Seek(pos, CFile::begin);
- } else {
- break;
- }
-
- chunk++;
- }
- if (chunk < ffe.hdr.chunks) {
- break;
- }
-
- ULONGLONG pos = ffe.pos + ffe.hdr.size - sizeof(ffe.hdr);
- if (pos < m_flic.GetLength()) {
- m_flic.Seek(pos, CFile::begin);
- } else {
- break;
- }
-
- m_frames[nFrames] = ffe;
- nFrames++;
- }
- if (nFrames > 0) {
- m_frames.SetCount(nFrames); // if the file is incomplete, then truncate the index
- m_frames[0].fKeyframe = true;
- } else {
- if (phr) {
- *phr = E_FAIL;
- }
- return;
- }
-
- m_nLastFrameNum = -1;
- ZeroMemory(m_pPalette, sizeof(m_pPalette));
- m_nBufferSize = m_hdr.width * m_hdr.height * 32 >> 3;
- if (!m_pFrameBuffer.Allocate(m_nBufferSize)) {
- if (phr) {
- *phr = E_OUTOFMEMORY;
- }
- return;
- }
-
- m_rtDuration = m_rtStop = m_AvgTimePerFrame * nFrames;
-
- if (phr) {
- *phr = m_rtDuration > 0 ? S_OK : E_FAIL;
- }
-}
-
-CFLICStream::~CFLICStream()
-{
- CAutoLock cAutoLock(&m_cSharedState);
-}
-
-STDMETHODIMP CFLICStream::NonDelegatingQueryInterface(REFIID riid, void** ppv)
-{
- CheckPointer(ppv, E_POINTER);
-
- return (riid == IID_IMediaSeeking) ? CSourceSeeking::NonDelegatingQueryInterface(riid, ppv) //GetInterface((IMediaSeeking*)this, ppv)
- : CSourceStream::NonDelegatingQueryInterface(riid, ppv);
-}
-
-void CFLICStream::UpdateFromSeek()
-{
- if (ThreadExists()) {
- // next time around the loop, the worker thread will
- // pick up the position change.
- // We need to flush all the existing data - we must do that here
- // as our thread will probably be blocked in GetBuffer otherwise
-
- m_bFlushing = TRUE;
-
- DeliverBeginFlush();
- // make sure we have stopped pushing
- Stop();
- // complete the flush
- DeliverEndFlush();
-
- m_bFlushing = FALSE;
-
- // restart
- Run();
- }
-}
-
-HRESULT CFLICStream::SetRate(double dRate)
-{
- if (dRate <= 0) {
- return E_INVALIDARG;
- }
-
- {
- CAutoLock lock(CSourceSeeking::m_pLock);
- m_dRateSeeking = dRate;
- }
-
- UpdateFromSeek();
-
- return S_OK;
-}
-
-HRESULT CFLICStream::OnThreadStartPlay()
-{
- m_bDiscontinuity = TRUE;
- return DeliverNewSegment(m_rtStart, m_rtStop, m_dRateSeeking);
-}
-
-HRESULT CFLICStream::ChangeStart()
-{
- {
- CAutoLock lock(CSourceSeeking::m_pLock);
- m_rtSampleTime = 0;
- m_rtPosition = m_rtStart;
- }
-
- UpdateFromSeek();
-
- return S_OK;
-}
-
-HRESULT CFLICStream::ChangeStop()
-{
- {
- CAutoLock lock(CSourceSeeking::m_pLock);
- if (m_rtPosition < m_rtStop) {
- return S_OK;
- }
- }
-
- // We're already past the new stop time -- better flush the graph.
- UpdateFromSeek();
-
- return S_OK;
-}
-
-HRESULT CFLICStream::OnThreadCreate()
-{
- CAutoLock cAutoLockShared(&m_cSharedState);
- m_rtSampleTime = 0;
- m_rtPosition = m_rtStart;
-
- return CSourceStream::OnThreadCreate();
-}
-
-HRESULT CFLICStream::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties)
-{
- // CAutoLock cAutoLock(m_pFilter->pStateLock());
-
- ASSERT(pAlloc);
- ASSERT(pProperties);
-
- HRESULT hr = NOERROR;
-
- pProperties->cBuffers = 1;
- pProperties->cbBuffer = m_nBufferSize;
-
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
- return hr;
- }
-
- if (Actual.cbBuffer < pProperties->cbBuffer) {
- return E_FAIL;
- }
- ASSERT(Actual.cBuffers == pProperties->cBuffers);
-
- return NOERROR;
-}
-
-HRESULT CFLICStream::FillBuffer(IMediaSample* pSample)
-{
- {
- CAutoLock cAutoLockShared(&m_cSharedState);
-
- if (m_rtPosition >= m_rtStop) {
- return S_FALSE;
- }
-
- BYTE* pDataIn = m_pFrameBuffer;
- BYTE* pDataOut = nullptr;
- if (!pDataIn || FAILED(pSample->GetPointer(&pDataOut)) || !pDataOut) {
- return S_FALSE;
- }
-
- AM_MEDIA_TYPE* pmt;
- if (SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
- CMediaType mt(*pmt);
- SetMediaType(&mt);
-
- DeleteMediaType(pmt);
- }
-
- int w, h, bpp;
- if (m_mt.formattype == FORMAT_VideoInfo) {
- w = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biWidth;
- h = abs(((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biHeight);
- bpp = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biBitCount;
- } else if (m_mt.formattype == FORMAT_VideoInfo2) {
- w = ((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biWidth;
- h = abs(((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biHeight);
- bpp = ((VIDEOINFOHEADER2*)m_mt.pbFormat)->bmiHeader.biBitCount;
- } else {
- return S_FALSE;
- }
-
- int pitchIn = m_hdr.width;
- int pitchOut = w * bpp >> 3;
-
- int nFrame = (int)(m_rtPosition / m_AvgTimePerFrame);
-
- {
- SeekToNearestKeyFrame(nFrame);
-
- while (m_nLastFrameNum < nFrame && !m_bFlushing) {
- ExtractFrame(++m_nLastFrameNum);
- }
-
- for (int y = 0, p = min(pitchIn, pitchOut);
- y < h;
- y++, pDataIn += pitchIn, pDataOut += pitchOut) {
- BYTE* src = pDataIn;
- BYTE* end = src + p;
- DWORD* dst = (DWORD*)pDataOut;
- while (src < end) {
- *dst++ = m_pPalette[*src++];
- }
- }
- }
-
- pSample->SetActualDataLength(pitchOut * h);
-
- REFERENCE_TIME rtStart, rtStop;
- // The sample times are modified by the current rate.
- rtStart = static_cast<REFERENCE_TIME>(m_rtSampleTime / m_dRateSeeking);
- rtStop = rtStart + static_cast<int>(m_AvgTimePerFrame / m_dRateSeeking);
- pSample->SetTime(&rtStart, &rtStop);
-
- m_rtSampleTime += m_AvgTimePerFrame;
- m_rtPosition += m_AvgTimePerFrame;
- }
-
- pSample->SetSyncPoint(TRUE);
-
- if (m_bDiscontinuity) {
- pSample->SetDiscontinuity(TRUE);
- m_bDiscontinuity = FALSE;
- }
-
- return S_OK;
-}
-
-HRESULT CFLICStream::GetMediaType(int iPosition, CMediaType* pmt)
-{
- CAutoLock cAutoLock(m_pFilter->pStateLock());
-
- if (iPosition < 0) {
- return E_INVALIDARG;
- }
- if (iPosition > 0) {
- return VFW_S_NO_MORE_ITEMS;
- }
-
- pmt->SetType(&MEDIATYPE_Video);
- pmt->SetSubtype(&MEDIASUBTYPE_RGB32);
- pmt->SetFormatType(&FORMAT_VideoInfo);
- pmt->SetTemporalCompression(TRUE);
-
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
- ZeroMemory(vih, sizeof(VIDEOINFOHEADER));
- vih->AvgTimePerFrame = m_AvgTimePerFrame;
- vih->bmiHeader.biSize = sizeof(vih->bmiHeader);
- vih->bmiHeader.biWidth = m_hdr.width;
- vih->bmiHeader.biHeight = -m_hdr.height;
- vih->bmiHeader.biPlanes = 1;
- vih->bmiHeader.biBitCount = 32;
- vih->bmiHeader.biCompression = BI_RGB;
- vih->bmiHeader.biSizeImage = m_nBufferSize;
-
- pmt->SetSampleSize(vih->bmiHeader.biSizeImage);
-
- return NOERROR;
-}
-
-HRESULT CFLICStream::CheckConnect(IPin* pPin)
-{
- return CSourceStream::CheckConnect(pPin);
-}
-
-HRESULT CFLICStream::CheckMediaType(const CMediaType* pmt)
-{
- if (pmt->majortype == MEDIATYPE_Video
- && pmt->subtype == MEDIASUBTYPE_RGB32
- && pmt->formattype == FORMAT_VideoInfo) {
- return S_OK;
- }
-
- return E_INVALIDARG;
-}
-
-STDMETHODIMP CFLICStream::Notify(IBaseFilter* pSender, Quality q)
-{
- return E_NOTIMPL;
-}
-
-////////
-
-void CFLICStream::SeekToNearestKeyFrame(int nFrame)
-{
- if (m_nLastFrameNum == nFrame) {
- return;
- }
-
- if (m_nLastFrameNum > nFrame) {
- m_nLastFrameNum = -1;
- }
-
- for (int i = m_nLastFrameNum + 1, j = min((int)m_frames.GetCount(), nFrame); i < j; i++) {
- FLIC_FRAME_ENTRY& ffe = m_frames[i];
- if (ffe.fKeyframe) {
- m_nLastFrameNum = i - 1;
- }
- }
-}
-
-void CFLICStream::ExtractFrame(int nFrame)
-{
- FLIC_FRAME_ENTRY& ffe = m_frames[nFrame];
-
- bool fNewPalette = false;
- bool fNewFrame = false;
-
- m_flic.Seek(ffe.pos, CFile::begin);
-
- int chunk = 0;
- while (chunk < ffe.hdr.chunks) {
- FLIC_CHUNK fc;
- if (m_flic.Read(&fc, sizeof(fc)) != sizeof(fc)) {
- break;
- }
-
- ULONGLONG next = m_flic.GetPosition() + fc.size - sizeof(fc);
- if (next >= m_flic.GetLength()) {
- break;
- }
-
- switch (fc.type) {
- case FLIC_64_COLOR:
- fNewPalette = _colorchunk(true);
- break;
- case FLIC_256_COLOR:
- fNewPalette = _colorchunk(false);
- break;
- case FLIC_BRUN:
- _brunchunk();
- fNewFrame = true;
- break;
- case FLIC_LC:
- _lcchunk();
- break;
- case FLIC_DELTA:
- _deltachunk();
- break;
- case FLIC_BLACK:
- _blackchunk();
- fNewFrame = true;
- break;
- case FLIC_COPY:
- _copychunk();
- fNewFrame = true;
- break;
- case FLIC_MINI:
- break;
- default:
- break;
- }
-
- m_flic.Seek(next, CFile::begin);
-
- chunk++;
- }
-
- if (chunk < ffe.hdr.chunks) {
- ASSERT(0);
- }
-
- ffe.fKeyframe = (fNewPalette && fNewFrame);
-}
-
-void CFLICStream::_blackchunk()
-{
- ZeroMemory(m_pFrameBuffer, sizeof(m_nBufferSize));
-}
-
-void CFLICStream::_copychunk()
-{
- m_flic.Read(m_pFrameBuffer, m_nBufferSize);
-}
-
-bool CFLICStream::_colorchunk(bool f64)
-{
- int nColorsUpdated = 0;
-
- BYTE skip = 0;
-
- WORD packets;
- m_flic.Read(&packets, sizeof(packets));
-
- while (packets--) {
- BYTE skip2;
- m_flic.Read(&skip2, sizeof(skip2));
- skip += skip2;
-
- BYTE count;
- m_flic.Read(&count, sizeof(count));
-
- int len = (count == 0 ? (256 - skip) : count);
- while (len-- > 0) {
- BYTE r, g, b;
- m_flic.Read(&r, sizeof(r));
- m_flic.Read(&g, sizeof(g));
- m_flic.Read(&b, sizeof(b));
- m_pPalette[skip++] = f64
- ? ((r << 18) & 0xff0000) | ((g << 10) & 0xff00) | ((b << 2) & 0xff)
- : ((r << 16) & 0xff0000) | ((g << 8) & 0xff00) | ((b << 0) & 0xff);
- nColorsUpdated++;
- }
- }
-
- return (nColorsUpdated == 256);
-}
-
-void CFLICStream::_brunchunk()
-{
- BYTE* tmp = m_pFrameBuffer;
-
- int lines = m_hdr.height;
- while (lines--) {
- BYTE packets;
- m_flic.Read(&packets, sizeof(packets));
-
- BYTE* ptr = tmp;
-
- while (ptr < tmp + m_hdr.width) {
- signed char count;
- m_flic.Read(&count, sizeof(count));
-
- if (count >= 0) {
- BYTE c;
- m_flic.Read(&c, sizeof(c));
- memset(ptr, c, count);
- ptr += count;
- } else {
- m_flic.Read(ptr, -count);
- ptr += -count;
- }
- }
-
- tmp += m_hdr.width;
- }
-}
-
-void CFLICStream::_lcchunk()
-{
- WORD y;
- m_flic.Read(&y, sizeof(y));
-
- BYTE* tmp = &m_pFrameBuffer[y * m_hdr.width];
-
- WORD lines;
- m_flic.Read(&lines, sizeof(lines));
-
- while (lines--) {
- BYTE* ptr = tmp;
-
- BYTE packets;
- m_flic.Read(&packets, sizeof(packets));
-
- while (packets--) {
- BYTE skip;
- m_flic.Read(&skip, sizeof(skip));
-
- ptr += skip;
-
- signed char count;
- m_flic.Read(&count, sizeof(count));
-
- if (count >= 0) {
- m_flic.Read(ptr, count);
- ptr += count;
- } else {
- BYTE c;
- m_flic.Read(&c, sizeof(c));
- memset(ptr, c, -count);
- ptr += -count;
- }
- }
-
- tmp += m_hdr.width;
- }
-}
-
-void CFLICStream::_deltachunk()
-{
- BYTE* tmp = m_pFrameBuffer;
-
- WORD lines;
- m_flic.Read(&lines, sizeof(lines));
-
- while (lines--) {
- signed short packets;
- m_flic.Read(&packets, sizeof(packets));
-
- if (packets < 0) {
- if (packets & 0x4000) {
- tmp += -packets * m_hdr.width;
- lines++;
- } else {
- signed char count;
- m_flic.Read(&count, sizeof(count));
- tmp[m_hdr.width - 1] = (BYTE)packets;
- }
- } else {
- BYTE* ptr = tmp;
-
- while (packets--) {
- BYTE skip;
- m_flic.Read(&skip, sizeof(skip));
-
- ptr += skip;
-
- signed char count;
- m_flic.Read(&count, sizeof(count));
-
- if (count >= 0) {
- // Fix vulnerability : http://www.team509.com/modules.php?name=News&file=article&sid=38
- if ((count << 1) + (long)(ptr - m_pFrameBuffer) < m_nBufferSize) {
- m_flic.Read(ptr, count << 1);
- } else {
- ASSERT(FALSE);
- }
- ptr += count << 1;
- } else {
- WORD c;
- m_flic.Read(&c, sizeof(c));
- count = -count;
- while (count-- > 0) {
- *ptr++ = c >> 8;
- *ptr++ = c & 0xff;
- }
- }
- }
-
- tmp += m_hdr.width;
- }
- }
-}
diff --git a/src/filters/source/FLICSource/FLICSource.def b/src/filters/source/FLICSource/FLICSource.def
deleted file mode 100644
index 6492e5cd6..000000000
--- a/src/filters/source/FLICSource/FLICSource.def
+++ /dev/null
@@ -1,5 +0,0 @@
-EXPORTS
- DllCanUnloadNow PRIVATE
- DllGetClassObject PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
diff --git a/src/filters/source/FLICSource/FLICSource.h b/src/filters/source/FLICSource/FLICSource.h
deleted file mode 100644
index 6b7ef6cd7..000000000
--- a/src/filters/source/FLICSource/FLICSource.h
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <atlcoll.h>
-
-#define FlicSourceName L"MPC FLIC Source"
-
-#pragma pack(push, 1)
-enum {
- FLIC_256_COLOR = 4,
- FLIC_DELTA = 7,
- FLIC_64_COLOR = 11,
- FLIC_LC = 12,
- FLIC_BLACK = 13,
- FLIC_BRUN = 15,
- FLIC_COPY = 16,
- FLIC_MINI = 18,
- DTA_BRUN = 25,
- DTA_COPY = 26,
- KEY_IMAGE = 35
-};
-
-// http://www.compuphase.com/flic.htm
-struct FLIC {
- DWORD size; // Size of FLIC including this header
- WORD type; // File type 0xAF11, 0xAF12, 0xAF30, 0xAF44, ...
- WORD frames; // Number of frames in first segment
- WORD width; // FLIC width in pixels
- WORD height; // FLIC height in pixels
- WORD depth; // Bits per pixel (usually 8)
- WORD flags; // Set to zero or to three
- DWORD speed; // Delay between frames
- WORD reserved1; // Set to zero
- DWORD created; // Date of FLIC creation (FLC only)
- DWORD creator; // Serial number or compiler id (FLC only)
- DWORD updated; // Date of FLIC update (FLC only)
- DWORD updater; // Serial number (FLC only), see creator
- WORD aspect_dx; // Width of square rectangle (FLC only)
- WORD aspect_dy; // Height of square rectangle (FLC only)
- WORD ext_flags; // EGI: flags for specific EGI extensions
- WORD keyframes; // EGI: key-image frequency
- WORD totalframes; // EGI: total number of frames (segments)
- DWORD req_memory; // EGI: maximum chunk size (uncompressed)
- WORD max_regions; // EGI: max. number of regions in a CHK_REGION chunk
- WORD transp_num; // EGI: number of transparent levels
- BYTE reserved2[24]; // Set to zero
- DWORD oframe1; // Offset to frame 1 (FLC only)
- DWORD oframe2; // Offset to frame 2 (FLC only)
- BYTE reserved3[40]; // Set to zero
-};
-
-struct FLIC_PREFIX {
- DWORD size; // Size of the chunk, including subchunks
- WORD type; // Chunk type: 0xF100
- WORD chunks; // Number of subchunks
- BYTE reserved[8]; // Reserved, set to 0
-};
-
-struct FLIC_FRAME {
- DWORD size; // Size of the chunk, including subchunks
- WORD type; // Chunk type: 0xF1FA
- WORD chunks; // Number of subchunks
- WORD delay; // Delay in milliseconds
- short reserved; // Always zero
- unsigned short width; // Frame width override (if non-zero)
- unsigned short height; // Frame height override (if non-zero)
-};
-
-struct FLIC_CHUNK {
- DWORD size; // Bytes in this chunk.
- WORD type; // Type of chunk
-};
-#pragma pack(pop)
-
-struct FLIC_FRAME_ENTRY {
- __int64 pos;
- bool fKeyframe;
- FLIC_FRAME hdr;
-};
-
-class __declspec(uuid("17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4"))
- CFLICSource
- : public CSource
- , public IFileSourceFilter
- , public IAMFilterMiscFlags
-{
- CStringW m_fn;
-
-public:
- CFLICSource(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CFLICSource();
-
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // IFileSourceFilter
- STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
- STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt);
-
- // IAMFilterMiscFlags
- STDMETHODIMP_(ULONG) GetMiscFlags();
-
- // CBaseFilter
- STDMETHODIMP QueryFilterInfo(FILTER_INFO* pInfo);
-};
-
-class CFLICStream
- : public CSourceStream
- , public CSourceSeeking
-{
- CFile m_flic;
- FLIC m_hdr;
- CAtlArray<FLIC_FRAME_ENTRY> m_frames;
-
- CCritSec m_cSharedState;
-
- REFERENCE_TIME m_AvgTimePerFrame;
- REFERENCE_TIME m_rtSampleTime, m_rtPosition;
-
- BOOL m_bDiscontinuity, m_bFlushing;
-
- HRESULT OnThreadStartPlay();
- HRESULT OnThreadCreate();
-
- void UpdateFromSeek();
- STDMETHODIMP SetRate(double dRate);
-
- HRESULT ChangeStart();
- HRESULT ChangeStop();
- HRESULT ChangeRate() { return S_OK; }
-
-private:
- int m_nLastFrameNum;
- DWORD m_pPalette[256];
- CAutoVectorPtr<BYTE> m_pFrameBuffer;
- int m_nBufferSize;
-
- void SeekToNearestKeyFrame(int nFrame);
- void ExtractFrame(int nFrame);
- void _blackchunk();
- void _copychunk();
- bool _colorchunk(bool f64);
- void _brunchunk();
- void _lcchunk();
- void _deltachunk();
-
-public:
- CFLICStream(const WCHAR* wfn, CFLICSource* pParent, HRESULT* phr);
- virtual ~CFLICStream();
-
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- HRESULT DecideBufferSize(IMemAllocator* pIMemAlloc, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT FillBuffer(IMediaSample* pSample);
- HRESULT CheckConnect(IPin* pPin);
- HRESULT CheckMediaType(const CMediaType* pMediaType);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
-
- STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
-};
diff --git a/src/filters/source/FLICSource/FLICSource.rc b/src/filters/source/FLICSource/FLICSource.rc
deleted file mode 100644
index b0be99b0d..000000000
--- a/src/filters/source/FLICSource/FLICSource.rc
+++ /dev/null
@@ -1,102 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-#include "version.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (United States) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION MPC_VERSION_NUM
- PRODUCTVERSION MPC_VERSION_NUM
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS VOS_NT_WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE VFT2_UNKNOWN
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", MPC_VERSION_COMMENTS
- VALUE "CompanyName", MPC_COMP_NAME_STR
- VALUE "FileDescription", "FLICSource Filter"
- VALUE "FileVersion", MPC_VERSION_STR_FULL
- VALUE "InternalName", "FLICSource Filter"
- VALUE "LegalCopyright", MPC_COPYRIGHT_STR
- VALUE "OriginalFilename", "FLICSource.ax"
- VALUE "ProductName", "FLICSource Filter"
- VALUE "ProductVersion", MPC_VERSION_STR_FULL
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // English (United States) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/src/filters/source/FLICSource/FLICSource.vcxproj b/src/filters/source/FLICSource/FLICSource.vcxproj
deleted file mode 100644
index 7971e75bc..000000000
--- a/src/filters/source/FLICSource/FLICSource.vcxproj
+++ /dev/null
@@ -1,250 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug Filter|Win32">
- <Configuration>Debug Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug Filter|x64">
- <Configuration>Debug Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|Win32">
- <Configuration>Release Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|x64">
- <Configuration>Release Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{431DD5B6-3F2F-47EE-A23F-514BC044B704}</ProjectGuid>
- <RootNamespace>FLICSource</RootNamespace>
- <Keyword>MFCProj</Keyword>
- <ProjectName>FLICSource</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <Import Project="..\..\..\platform.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">.ax</TargetExt>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>FLICSource.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>FLICSource.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>FLICSource.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>FLICSource.def</ModuleDefinitionFile>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="FLICSource.cpp" />
- <ClCompile Include="stdafx.cpp">
- <PrecompiledHeader>Create</PrecompiledHeader>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="FLICSource.def" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="FLICSource.h" />
- <ClInclude Include="resource.h">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ClInclude>
- <ClInclude Include="stdafx.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="FLICSource.rc">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ResourceCompile>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\DSUtil\DSUtil.vcxproj">
- <Project>{fc70988b-1ae5-4381-866d-4f405e28ac42}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\Kasumi\Kasumi.vcxproj">
- <Project>{0d252872-7542-4232-8d02-53f9182aee15}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\system\system.vcxproj">
- <Project>{c2082189-3ecb-4079-91fa-89d3c8a305c0}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\BaseClasses\BaseClasses.vcxproj">
- <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\Filters.vcxproj">
- <Project>{273b3149-3192-4b75-a791-470320b90812}</Project>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/source/FLICSource/FLICSource.vcxproj.filters b/src/filters/source/FLICSource/FLICSource.vcxproj.filters
deleted file mode 100644
index 71929cf6d..000000000
--- a/src/filters/source/FLICSource/FLICSource.vcxproj.filters
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{5e68c84f-8251-404c-aabb-d85fafac03eb}</UniqueIdentifier>
- <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{401f2450-a927-4ea5-ac7e-28c0b7818ad9}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{6d37d4cd-c29e-4fe9-9246-51fd9a5f2394}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="FLICSource.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="stdafx.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <None Include="FLICSource.def">
- <Filter>Source Files</Filter>
- </None>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="FLICSource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="resource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="stdafx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="FLICSource.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/source/FLICSource/resource.h b/src/filters/source/FLICSource/resource.h
deleted file mode 100644
index 2dec3b5b3..000000000
--- a/src/filters/source/FLICSource/resource.h
+++ /dev/null
@@ -1,14 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by FLICSource.rc
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 101
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/filters/source/FLICSource/stdafx.cpp b/src/filters/source/FLICSource/stdafx.cpp
deleted file mode 100644
index 784f2cebc..000000000
--- a/src/filters/source/FLICSource/stdafx.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
diff --git a/src/filters/source/FLICSource/stdafx.h b/src/filters/source/FLICSource/stdafx.h
deleted file mode 100644
index 5b6b09e05..000000000
--- a/src/filters/source/FLICSource/stdafx.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../../DSUtil/SharedInclude.h"
-#include "../../../../include/stdafx_common.h"
-#include "../../../../include/stdafx_common_afx.h"
-#include "../../../../include/stdafx_common_dshow.h"
diff --git a/src/filters/transform/MPCVideoDec/CpuId.cpp b/src/filters/transform/MPCVideoDec/CpuId.cpp
deleted file mode 100644
index 5c10d7ed4..000000000
--- a/src/filters/transform/MPCVideoDec/CpuId.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <intrin.h>
-#include "CpuId.h"
-
-#define CPUID_MMX (1 << 23)
-#define CPUID_SSE (1 << 25)
-#define CPUID_SSE2 (1 << 26)
-#define CPUID_SSE3 (1 << 0)
-#define CPUID_SSE41 (1 << 19)
-#define CPUID_SSE42 (1 << 20)
-#define CPUID_AVX ((1 << 27) | (1 << 28))
-
-// Intel specific
-#define CPUID_SSSE3 (1 << 9)
-
-// AMD specific
-#define CPUID_3DNOW (1 << 31)
-#define CPUID_MMXEXT (1 << 22)
-
-CCpuId::CCpuId()
-{
- unsigned nHighestFeature;
- unsigned nHighestFeatureEx;
- int nBuff[4];
- char szMan[13];
-
- // Get CPU manufacturer and highest CPUID
- __cpuid(nBuff, 0);
- nHighestFeature = (unsigned)nBuff[0];
- *(int*)&szMan[0] = nBuff[1];
- *(int*)&szMan[4] = nBuff[3];
- *(int*)&szMan[8] = nBuff[2];
- szMan[12] = 0;
-
- if (strcmp(szMan, "AuthenticAMD") == 0) {
- m_nType = PROCESSOR_AMD;
- } else if (strcmp(szMan, "GenuineIntel") == 0) {
- m_nType = PROCESSOR_INTEL;
- } else {
- m_nType = PROCESSOR_UNKNOWN;
- }
-
- // Get highest extended feature
- __cpuid(nBuff, 0x80000000);
- nHighestFeatureEx = (unsigned)nBuff[0];
-
- // Get CPU features
- m_nCPUFeatures = 0;
- if (nHighestFeature >= 1) {
- __cpuid(nBuff, 1);
- if (nBuff[3] & CPUID_MMX) {
- m_nCPUFeatures |= MPC_MM_MMX;
- }
- if (nBuff[3] & CPUID_SSE) {
- m_nCPUFeatures |= MPC_MM_SSE;
- }
- if (nBuff[3] & CPUID_SSE2) {
- m_nCPUFeatures |= MPC_MM_SSE2;
- }
- if (nBuff[2] & CPUID_SSE3) {
- m_nCPUFeatures |= MPC_MM_SSE3;
- }
- if (nBuff[2] & CPUID_SSE41) {
- m_nCPUFeatures |= MPC_MM_SSE4;
- }
- if (nBuff[2] & CPUID_SSE42) {
- m_nCPUFeatures |= MPC_MM_SSE42;
- }
-
- // Intel specific
- if (m_nType == PROCESSOR_INTEL) {
- if (nBuff[2] & CPUID_SSSE3) {
- m_nCPUFeatures |= MPC_MM_SSSE3;
- }
- if ((nBuff[2] & CPUID_AVX) == CPUID_AVX) {
- // Check for OS support
- unsigned long long xcrFeatureMask = _xgetbv(_XCR_XFEATURE_ENABLED_MASK);
- if ((xcrFeatureMask & 0x6) == 0x6) {
- m_nCPUFeatures |= MPC_MM_AVX;
- }
- }
- }
- }
-
- // AMD specific
- if (m_nType == PROCESSOR_AMD) {
- // Get extended features
- __cpuid(nBuff, 0x80000000);
- if (nHighestFeatureEx >= 0x80000001) {
- __cpuid(nBuff, 0x80000001);
- if (nBuff[3] & CPUID_3DNOW) {
- m_nCPUFeatures |= MPC_MM_3DNOW;
- }
- if (nBuff[3] & CPUID_MMXEXT) {
- m_nCPUFeatures |= MPC_MM_MMXEXT;
- }
- }
- }
-
-}
-
-int CCpuId::GetProcessorNumber()
-{
- SYSTEM_INFO SystemInfo;
- GetSystemInfo(&SystemInfo);
-
- return SystemInfo.dwNumberOfProcessors;
-}
diff --git a/src/filters/transform/MPCVideoDec/CpuId.h b/src/filters/transform/MPCVideoDec/CpuId.h
deleted file mode 100644
index 54ed12cfe..000000000
--- a/src/filters/transform/MPCVideoDec/CpuId.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-class CCpuId
-{
-public:
-
- typedef enum {
- PROCESSOR_AMD,
- PROCESSOR_INTEL,
- PROCESSOR_UNKNOWN
- } PROCESSOR_TYPE;
-
- // Enum codes identical to FFmpeg cpu features define
- typedef enum {
- MPC_MM_MMX = 0x0001, /* standard MMX */
- MPC_MM_3DNOW = 0x0004, /* AMD 3DNOW */
- MPC_MM_MMXEXT = 0x0002, /* SSE integer functions or AMD MMX ext */
- MPC_MM_SSE = 0x0008, /* SSE functions */
- MPC_MM_SSE2 = 0x0010, /* PIV SSE2 functions */
- MPC_MM_SSE3 = 0x0040, /* AMD64 & PIV SSE3 functions */
- MPC_MM_SSSE3 = 0x0080, /* PIV Core 2 SSSE3 functions */
- MPC_MM_SSE4 = 0x0100,
- MPC_MM_SSE42 = 0x0200,
- MPC_MM_AVX = 0x4000
- } PROCESSOR_FEATURES;
-
- CCpuId();
-
- int GetFeatures() const { return m_nCPUFeatures; };
- PROCESSOR_TYPE GetType() const { return m_nType; };
- int GetProcessorNumber();
-
-private:
- int m_nCPUFeatures;
- PROCESSOR_TYPE m_nType;
-};
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoder.cpp b/src/filters/transform/MPCVideoDec/DXVADecoder.cpp
deleted file mode 100644
index dda150c79..000000000
--- a/src/filters/transform/MPCVideoDec/DXVADecoder.cpp
+++ /dev/null
@@ -1,773 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <d3dx9.h>
-#include <dxva2api.h>
-#include <evr.h>
-#include "moreuuids.h"
-#include "DXVADecoderH264.h"
-#include "DXVADecoderVC1.h"
-#include "DXVADecoderMpeg2.h"
-#include "MPCVideoDecFilter.h"
-#include "VideoDecDXVAAllocator.h"
-#include "FfmpegContext.h"
-
-#define MAX_RETRY_ON_PENDING 50
-#define DO_DXVA_PENDING_LOOP(x) \
- nTry = 0; \
- while (FAILED(hr = x) && nTry < MAX_RETRY_ON_PENDING) { \
- if (hr != E_PENDING) \
- break; \
- Sleep(3); \
- nTry++; \
- }
-
-CDXVADecoder::CDXVADecoder(CMPCVideoDecFilter* pFilter,
- IAMVideoAccelerator* pAMVideoAccelerator,
- DXVAMode nMode,
- int nPicEntryNumber)
-{
- m_nEngine = ENGINE_DXVA1;
- m_pAMVideoAccelerator = pAMVideoAccelerator;
- m_dwBufferIndex = 0;
- m_nMaxWaiting = 3;
-
- Init(pFilter, nMode, nPicEntryNumber);
-}
-
-CDXVADecoder::CDXVADecoder(CMPCVideoDecFilter* pFilter,
- IDirectXVideoDecoder* pDirectXVideoDec,
- DXVAMode nMode,
- int nPicEntryNumber,
- DXVA2_ConfigPictureDecode* pDXVA2Config)
-{
- m_nEngine = ENGINE_DXVA2;
- m_pDirectXVideoDec = pDirectXVideoDec;
- m_dwBufferIndex = 0;
- m_nMaxWaiting = 3;
- memcpy(&m_DXVA2Config, pDXVA2Config, sizeof(DXVA2_ConfigPictureDecode));
-
- Init(pFilter, nMode, nPicEntryNumber);
-};
-
-CDXVADecoder::~CDXVADecoder()
-{
- SAFE_DELETE_ARRAY(m_pPictureStore);
- SAFE_DELETE_ARRAY(m_ExecuteParams.pCompressedBuffers);
-}
-
-void CDXVADecoder::Init(CMPCVideoDecFilter* pFilter, DXVAMode nMode, int nPicEntryNumber)
-{
- m_pFilter = pFilter;
- m_nMode = nMode;
- m_nPicEntryNumber = nPicEntryNumber;
- m_pPictureStore = DEBUG_NEW PICTURE_STORE[nPicEntryNumber];
- m_dwNumBuffersInfo = 0;
- m_bNeedChangeAspect = true;
-
- ZeroMemory(&m_DXVA1Config, sizeof(m_DXVA1Config));
- ZeroMemory(&m_DXVA1BufferDesc, sizeof(m_DXVA1BufferDesc));
- m_DXVA1Config.guidConfigBitstreamEncryption = DXVA_NoEncrypt;
- m_DXVA1Config.guidConfigMBcontrolEncryption = DXVA_NoEncrypt;
- m_DXVA1Config.guidConfigResidDiffEncryption = DXVA_NoEncrypt;
- m_DXVA1Config.bConfigBitstreamRaw = 2;
-
- ZeroMemory(&m_DXVA1BufferInfo, sizeof(m_DXVA1BufferInfo));
- ZeroMemory(&m_ExecuteParams, sizeof(m_ExecuteParams));
- Flush();
-}
-
-// === Public functions
-void CDXVADecoder::AllocExecuteParams(int nSize)
-{
- m_ExecuteParams.pCompressedBuffers = DEBUG_NEW DXVA2_DecodeBufferDesc[nSize];
-
- for (int i = 0; i < nSize; i++) {
- ZeroMemory(&m_ExecuteParams.pCompressedBuffers[i], sizeof(DXVA2_DecodeBufferDesc));
- }
-}
-
-void CDXVADecoder::SetExtraData(BYTE* pDataIn, UINT nSize)
-{
- // Extradata is codec dependant
- UNREFERENCED_PARAMETER(pDataIn);
- UNREFERENCED_PARAMETER(nSize);
-}
-
-void CDXVADecoder::CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize)
-{
- memcpy(pDXVABuffer, (BYTE*)pBuffer, nSize);
-}
-
-void CDXVADecoder::Flush()
-{
- TRACE(_T("CDXVADecoder::Flush\n"));
- for (int i = 0; i < m_nPicEntryNumber; i++) {
- m_pPictureStore[i].bRefPicture = false;
- m_pPictureStore[i].bInUse = false;
- m_pPictureStore[i].bDisplayed = false;
- m_pPictureStore[i].pSample = nullptr;
- m_pPictureStore[i].nCodecSpecific = -1;
- m_pPictureStore[i].dwDisplayCount = 0;
- }
-
- m_nWaitingPics = 0;
- m_bFlushed = true;
- m_nFieldSurface = -1;
- m_dwDisplayCount = 1;
- m_pFieldSample = nullptr;
-}
-
-HRESULT CDXVADecoder::ConfigureDXVA1()
-{
- HRESULT hr = S_FALSE;
- DXVA_ConfigPictureDecode ConfigRequested;
-
- if (m_pAMVideoAccelerator) {
- ZeroMemory(&ConfigRequested, sizeof(ConfigRequested));
- ConfigRequested.guidConfigBitstreamEncryption = DXVA_NoEncrypt;
- ConfigRequested.guidConfigMBcontrolEncryption = DXVA_NoEncrypt;
- ConfigRequested.guidConfigResidDiffEncryption = DXVA_NoEncrypt;
- ConfigRequested.bConfigBitstreamRaw = 2;
-
- writeDXVA_QueryOrReplyFunc(&ConfigRequested.dwFunction, DXVA_QUERYORREPLYFUNCFLAG_DECODER_PROBE_QUERY, DXVA_PICTURE_DECODING_FUNCTION);
- hr = m_pAMVideoAccelerator->Execute(ConfigRequested.dwFunction, &ConfigRequested, sizeof(DXVA_ConfigPictureDecode), &m_DXVA1Config, sizeof(DXVA_ConfigPictureDecode), 0, nullptr);
-
- // Copy to DXVA2 structure (simplify code based on accelerator config)
- m_DXVA2Config.guidConfigBitstreamEncryption = m_DXVA1Config.guidConfigBitstreamEncryption;
- m_DXVA2Config.guidConfigMBcontrolEncryption = m_DXVA1Config.guidConfigMBcontrolEncryption;
- m_DXVA2Config.guidConfigResidDiffEncryption = m_DXVA1Config.guidConfigResidDiffEncryption;
- m_DXVA2Config.ConfigBitstreamRaw = m_DXVA1Config.bConfigBitstreamRaw;
- m_DXVA2Config.ConfigMBcontrolRasterOrder = m_DXVA1Config.bConfigMBcontrolRasterOrder;
- m_DXVA2Config.ConfigResidDiffHost = m_DXVA1Config.bConfigResidDiffHost;
- m_DXVA2Config.ConfigSpatialResid8 = m_DXVA1Config.bConfigSpatialResid8;
- m_DXVA2Config.ConfigResid8Subtraction = m_DXVA1Config.bConfigResid8Subtraction;
- m_DXVA2Config.ConfigSpatialHost8or9Clipping = m_DXVA1Config.bConfigSpatialHost8or9Clipping;
- m_DXVA2Config.ConfigSpatialResidInterleaved = m_DXVA1Config.bConfigSpatialResidInterleaved;
- m_DXVA2Config.ConfigIntraResidUnsigned = m_DXVA1Config.bConfigIntraResidUnsigned;
- m_DXVA2Config.ConfigResidDiffAccelerator = m_DXVA1Config.bConfigResidDiffAccelerator;
- m_DXVA2Config.ConfigHostInverseScan = m_DXVA1Config.bConfigHostInverseScan;
- m_DXVA2Config.ConfigSpecificIDCT = m_DXVA1Config.bConfigSpecificIDCT;
- m_DXVA2Config.Config4GroupedCoefs = m_DXVA1Config.bConfig4GroupedCoefs;
-
- if (SUCCEEDED(hr)) {
- writeDXVA_QueryOrReplyFunc(&m_DXVA1Config.dwFunction, DXVA_QUERYORREPLYFUNCFLAG_DECODER_LOCK_QUERY, DXVA_PICTURE_DECODING_FUNCTION);
- hr = m_pAMVideoAccelerator->Execute(m_DXVA1Config.dwFunction, &m_DXVA1Config, sizeof(DXVA_ConfigPictureDecode), &ConfigRequested, sizeof(DXVA_ConfigPictureDecode), 0, nullptr);
-
- // TODO : check config!
- //ASSERT (ConfigRequested.bConfigBitstreamRaw == 2);
-
- AMVAUncompDataInfo DataInfo;
- DWORD dwNum = COMP_BUFFER_COUNT;
- DataInfo.dwUncompWidth = m_pFilter->PictWidthRounded();
- DataInfo.dwUncompHeight = m_pFilter->PictHeightRounded();
- memcpy(&DataInfo.ddUncompPixelFormat, m_pFilter->GetPixelFormat(), sizeof(DDPIXELFORMAT));
- hr = m_pAMVideoAccelerator->GetCompBufferInfo(m_pFilter->GetDXVADecoderGuid(), &DataInfo, &dwNum, m_ComBufferInfo);
- }
- }
- return hr;
-}
-
-CDXVADecoder* CDXVADecoder::CreateDecoder(CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, const GUID* guidDecoder, int nPicEntryNumber)
-{
- CDXVADecoder* pDecoder = nullptr;
-
- if ((*guidDecoder == DXVA2_ModeH264_E) || (*guidDecoder == DXVA2_ModeH264_F) || (*guidDecoder == DXVA_Intel_H264_ClearVideo)) {
- pDecoder = DEBUG_NEW CDXVADecoderH264(pFilter, pAMVideoAccelerator, H264_VLD, nPicEntryNumber);
- } else if (*guidDecoder == DXVA2_ModeVC1_D) {
- pDecoder = DEBUG_NEW CDXVADecoderVC1(pFilter, pAMVideoAccelerator, VC1_VLD, nPicEntryNumber);
- } else if (*guidDecoder == DXVA2_ModeMPEG2_VLD) {
- pDecoder = DEBUG_NEW CDXVADecoderMpeg2(pFilter, pAMVideoAccelerator, MPEG2_VLD, nPicEntryNumber);
- } else {
- ASSERT(FALSE); // Unknown decoder !!
- }
-
- return pDecoder;
-}
-
-CDXVADecoder* CDXVADecoder::CreateDecoder(CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, const GUID* guidDecoder, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config)
-{
- CDXVADecoder* pDecoder = nullptr;
-
- if ((*guidDecoder == DXVA2_ModeH264_E) || (*guidDecoder == DXVA2_ModeH264_F) || (*guidDecoder == DXVA_Intel_H264_ClearVideo)) {
- pDecoder = DEBUG_NEW CDXVADecoderH264(pFilter, pDirectXVideoDec, H264_VLD, nPicEntryNumber, pDXVA2Config);
- } else if (*guidDecoder == DXVA2_ModeVC1_D) {
- pDecoder = DEBUG_NEW CDXVADecoderVC1(pFilter, pDirectXVideoDec, VC1_VLD, nPicEntryNumber, pDXVA2Config);
- } else if (*guidDecoder == DXVA2_ModeMPEG2_VLD) {
- pDecoder = DEBUG_NEW CDXVADecoderMpeg2(pFilter, pDirectXVideoDec, MPEG2_VLD, nPicEntryNumber, pDXVA2Config);
- } else {
- ASSERT(FALSE); // Unknown decoder !!
- }
-
- return pDecoder;
-}
-
-// === DXVA functions
-
-HRESULT CDXVADecoder::AddExecuteBuffer(DWORD CompressedBufferType, UINT nSize, void* pBuffer, UINT* pRealSize)
-{
- HRESULT hr = E_INVALIDARG;
- DWORD dwNumMBs = 0;
- BYTE* pDXVABuffer;
-
- //if (CompressedBufferType != DXVA2_PictureParametersBufferType && CompressedBufferType != DXVA2_InverseQuantizationMatrixBufferType)
- // dwNumMBs = FFGetMBNumber (m_pFilter->GetAVCtx());
-
- switch (m_nEngine) {
- case ENGINE_DXVA1:
- DWORD dwTypeIndex;
- LONG lStride;
- dwTypeIndex = GetDXVA1CompressedType(CompressedBufferType);
-
- //TRACE(_T("Fill : %d - %d\n"), dwTypeIndex, m_dwBufferIndex);
- hr = m_pAMVideoAccelerator->GetBuffer(dwTypeIndex, m_dwBufferIndex, FALSE, (void**)&pDXVABuffer, &lStride);
- ASSERT(SUCCEEDED(hr));
-
- if (SUCCEEDED(hr)) {
- if (CompressedBufferType == DXVA2_BitStreamDateBufferType) {
- CopyBitstream(pDXVABuffer, (BYTE*)pBuffer, nSize);
- } else {
- memcpy(pDXVABuffer, (BYTE*)pBuffer, nSize);
- }
- m_DXVA1BufferInfo[m_dwNumBuffersInfo].dwTypeIndex = dwTypeIndex;
- m_DXVA1BufferInfo[m_dwNumBuffersInfo].dwBufferIndex = m_dwBufferIndex;
- m_DXVA1BufferInfo[m_dwNumBuffersInfo].dwDataSize = nSize;
-
- m_DXVA1BufferDesc[m_dwNumBuffersInfo].dwTypeIndex = dwTypeIndex;
- m_DXVA1BufferDesc[m_dwNumBuffersInfo].dwBufferIndex = m_dwBufferIndex;
- m_DXVA1BufferDesc[m_dwNumBuffersInfo].dwDataSize = nSize;
- m_DXVA1BufferDesc[m_dwNumBuffersInfo].dwNumMBsInBuffer = dwNumMBs;
-
- m_dwNumBuffersInfo++;
- }
- break;
-
- case ENGINE_DXVA2:
- UINT nDXVASize;
- hr = m_pDirectXVideoDec->GetBuffer(CompressedBufferType, (void**)&pDXVABuffer, &nDXVASize);
- ASSERT(nSize <= nDXVASize);
-
- if (SUCCEEDED(hr) && (nSize <= nDXVASize)) {
- if (CompressedBufferType == DXVA2_BitStreamDateBufferType) {
- CopyBitstream(pDXVABuffer, (BYTE*)pBuffer, nSize);
- } else {
- memcpy(pDXVABuffer, (BYTE*)pBuffer, nSize);
- }
-
- m_ExecuteParams.pCompressedBuffers[m_ExecuteParams.NumCompBuffers].CompressedBufferType = CompressedBufferType;
- m_ExecuteParams.pCompressedBuffers[m_ExecuteParams.NumCompBuffers].DataSize = nSize;
- m_ExecuteParams.pCompressedBuffers[m_ExecuteParams.NumCompBuffers].NumMBsInBuffer = dwNumMBs;
- m_ExecuteParams.NumCompBuffers++;
-
- }
- break;
- default:
- ASSERT(FALSE);
- break;
- }
- if (pRealSize) {
- *pRealSize = nSize;
- }
-
- return hr;
-}
-
-HRESULT CDXVADecoder::GetDeliveryBuffer(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, IMediaSample** ppSampleToDeliver)
-{
- HRESULT hr;
- CComPtr<IMediaSample> pNewSample;
-
- // Change aspect ratio for DXVA2
- if (m_nEngine == ENGINE_DXVA2) {
- if (m_bNeedChangeAspect) {
- m_pFilter->UpdateAspectRatio();
- m_pFilter->ReconnectOutput(m_pFilter->PictWidthRounded(), m_pFilter->PictHeightRounded(), true, m_pFilter->PictWidth(), m_pFilter->PictHeight());
- }
- }
- hr = m_pFilter->GetOutputPin()->GetDeliveryBuffer(&pNewSample, 0, 0, 0);
-
- if (SUCCEEDED(hr)) {
- pNewSample->SetTime(&rtStart, &rtStop);
- pNewSample->SetMediaTime(nullptr, nullptr);
- *ppSampleToDeliver = pNewSample.Detach();
- }
- return hr;
-}
-
-HRESULT CDXVADecoder::Execute()
-{
- HRESULT hr = E_INVALIDARG;
-
- switch (m_nEngine) {
- case ENGINE_DXVA1:
- DWORD dwFunction;
- HRESULT hr2;
-
- //writeDXVA_QueryOrReplyFunc(&dwFunction, DXVA_QUERYORREPLYFUNCFLAG_DECODER_LOCK_QUERY, DXVA_PICTURE_DECODING_FUNCTION);
- //hr = m_pAMVideoAccelerator->Execute (dwFunction, &m_DXVA1Config, sizeof(DXVA_ConfigPictureDecode), nullptr, 0, m_dwNumBuffersInfo, m_DXVA1BufferInfo);
-
- DWORD dwResult;
- dwFunction = 0x01000000;
- hr = m_pAMVideoAccelerator->Execute(dwFunction, m_DXVA1BufferDesc, sizeof(DXVA_BufferDescription) * m_dwNumBuffersInfo, &dwResult, sizeof(dwResult), m_dwNumBuffersInfo, m_DXVA1BufferInfo);
- ASSERT(SUCCEEDED(hr));
-
- for (DWORD i = 0; i < m_dwNumBuffersInfo; i++) {
- hr2 = m_pAMVideoAccelerator->ReleaseBuffer(m_DXVA1BufferInfo[i].dwTypeIndex, m_DXVA1BufferInfo[i].dwBufferIndex);
- ASSERT(SUCCEEDED(hr2));
- }
-
- m_dwNumBuffersInfo = 0;
- break;
- case ENGINE_DXVA2:
-
- for (DWORD i = 0; i < m_ExecuteParams.NumCompBuffers; i++) {
- hr2 = m_pDirectXVideoDec->ReleaseBuffer(m_ExecuteParams.pCompressedBuffers[i].CompressedBufferType);
- ASSERT(SUCCEEDED(hr2));
- }
-
- hr = m_pDirectXVideoDec->Execute(&m_ExecuteParams);
- m_ExecuteParams.NumCompBuffers = 0;
- break;
- default:
- ASSERT(FALSE);
- break;
- }
-
- return hr;
-}
-
-HRESULT CDXVADecoder::QueryStatus(PVOID LPDXVAStatus, UINT nSize)
-{
- HRESULT hr = E_INVALIDARG;
- DXVA2_DecodeExecuteParams ExecuteParams;
- DXVA2_DecodeExtensionData ExtensionData;
- DWORD dwFunction = 0x07000000;
-
- switch (m_nEngine) {
- case ENGINE_DXVA1:
- hr = m_pAMVideoAccelerator->Execute(dwFunction, nullptr, 0, LPDXVAStatus, nSize, 0, nullptr);
- break;
-
- case ENGINE_DXVA2:
- ZeroMemory(&ExecuteParams, sizeof(ExecuteParams));
- ZeroMemory(&ExtensionData, sizeof(ExtensionData));
- ExecuteParams.pExtensionData = &ExtensionData;
- ExtensionData.pPrivateOutputData = LPDXVAStatus;
- ExtensionData.PrivateOutputDataSize = nSize;
- ExtensionData.Function = 7;
- hr = m_pDirectXVideoDec->Execute(&ExecuteParams);
- break;
- default:
- ASSERT(FALSE);
- break;
- }
-
- return hr;
-}
-
-DWORD CDXVADecoder::GetDXVA1CompressedType(DWORD dwDXVA2CompressedType)
-{
- if (dwDXVA2CompressedType <= DXVA2_BitStreamDateBufferType) {
- return dwDXVA2CompressedType + 1;
- } else {
- switch (dwDXVA2CompressedType) {
- case DXVA2_MotionVectorBuffer:
- return DXVA_MOTION_VECTOR_BUFFER;
- break;
- case DXVA2_FilmGrainBuffer:
- return DXVA_FILM_GRAIN_BUFFER;
- break;
- default:
- ASSERT(FALSE);
- return DXVA_COMPBUFFER_TYPE_THAT_IS_NOT_USED;
- }
- }
-}
-
-HRESULT CDXVADecoder::FindFreeDXVA1Buffer(DWORD dwTypeIndex, DWORD& dwBufferIndex)
-{
- HRESULT hr = E_INVALIDARG;
- int nTry = 0;
-
- dwBufferIndex = 0; //(dwBufferIndex + 1) % m_ComBufferInfo[DXVA_PICTURE_DECODE_BUFFER].dwNumCompBuffers;
- DO_DXVA_PENDING_LOOP(m_pAMVideoAccelerator->QueryRenderStatus((DWORD) - 1, dwBufferIndex, 0));
-
- return hr;
-}
-
-HRESULT CDXVADecoder::BeginFrame(int nSurfaceIndex, IMediaSample* pSampleToDeliver)
-{
- HRESULT hr = E_INVALIDARG;
- int nTry = 0;
-
- for (int i = 0; i < 20; i++) {
- switch (m_nEngine) {
- case ENGINE_DXVA1:
- AMVABeginFrameInfo BeginFrameInfo;
-
- BeginFrameInfo.dwDestSurfaceIndex = nSurfaceIndex;
- BeginFrameInfo.dwSizeInputData = sizeof(nSurfaceIndex);
- BeginFrameInfo.pInputData = &nSurfaceIndex;
- BeginFrameInfo.dwSizeOutputData = 0;
- BeginFrameInfo.pOutputData = nullptr;
-
- DO_DXVA_PENDING_LOOP(m_pAMVideoAccelerator->BeginFrame(&BeginFrameInfo));
-
- ASSERT(SUCCEEDED(hr));
- if (SUCCEEDED(hr)) {
- hr = FindFreeDXVA1Buffer((DWORD) - 1, m_dwBufferIndex);
- }
- break;
-
- case ENGINE_DXVA2: {
- CComQIPtr<IMFGetService> pSampleService;
- CComPtr<IDirect3DSurface9> pDecoderRenderTarget;
- pSampleService = pSampleToDeliver;
- if (pSampleService) {
- hr = pSampleService->GetService(MR_BUFFER_SERVICE, __uuidof(IDirect3DSurface9), (void**) &pDecoderRenderTarget);
- if (SUCCEEDED(hr)) {
- DO_DXVA_PENDING_LOOP(m_pDirectXVideoDec->BeginFrame(pDecoderRenderTarget, nullptr));
- }
- }
- }
- break;
- default:
- ASSERT(FALSE);
- break;
- }
-
- // For slow accelerator wait a little...
- if (SUCCEEDED(hr)) {
- break;
- }
- Sleep(1);
- }
-
- return hr;
-}
-
-HRESULT CDXVADecoder::EndFrame(int nSurfaceIndex)
-{
- HRESULT hr = E_INVALIDARG;
- DWORD dwDummy = nSurfaceIndex;
-
- switch (m_nEngine) {
- case ENGINE_DXVA1:
- AMVAEndFrameInfo EndFrameInfo;
-
- EndFrameInfo.dwSizeMiscData = sizeof(dwDummy); // TODO : usefull ??
- EndFrameInfo.pMiscData = &dwDummy;
- hr = m_pAMVideoAccelerator->EndFrame(&EndFrameInfo);
- ASSERT(SUCCEEDED(hr));
- break;
-
- case ENGINE_DXVA2:
- hr = m_pDirectXVideoDec->EndFrame(nullptr);
- break;
- default:
- ASSERT(FALSE);
- break;
- }
-
- return hr;
-}
-
-// === Picture store functions
-bool CDXVADecoder::AddToStore(int nSurfaceIndex,
- IMediaSample* pSample,
- bool bRefPicture,
- REFERENCE_TIME rtStart,
- REFERENCE_TIME rtStop,
- bool bIsField,
- FF_FIELD_TYPE nFieldType,
- FF_SLICE_TYPE nSliceType,
- int nCodecSpecific)
-{
- if (bIsField && (m_nFieldSurface == -1)) {
- m_nFieldSurface = nSurfaceIndex;
- m_pFieldSample = pSample;
- m_pPictureStore[nSurfaceIndex].n1FieldType = nFieldType;
- m_pPictureStore[nSurfaceIndex].rtStart = rtStart;
- m_pPictureStore[nSurfaceIndex].rtStop = rtStop;
- m_pPictureStore[nSurfaceIndex].nCodecSpecific = nCodecSpecific;
- return false;
- } else {
- //TRACE(_T("Add Stor: [%10I64d - %10I64d], Ind = %d, Codec=%d\n"), rtStart, rtStop, nSurfaceIndex, nCodecSpecific);
- /*
- ASSERT(m_pPictureStore[nSurfaceIndex].pSample == nullptr);
- ASSERT(!m_pPictureStore[nSurfaceIndex].bInUse);
- ASSERT((nSurfaceIndex < m_nPicEntryNumber) && (m_pPictureStore[nSurfaceIndex].pSample == nullptr));
- */
-
- m_pPictureStore[nSurfaceIndex].bRefPicture = bRefPicture;
- m_pPictureStore[nSurfaceIndex].bInUse = true;
- m_pPictureStore[nSurfaceIndex].bDisplayed = false;
- m_pPictureStore[nSurfaceIndex].pSample = pSample;
- m_pPictureStore[nSurfaceIndex].nSliceType = nSliceType;
-
- if (!bIsField) {
- m_pPictureStore[nSurfaceIndex].rtStart = rtStart;
- m_pPictureStore[nSurfaceIndex].rtStop = rtStop;
- m_pPictureStore[nSurfaceIndex].n1FieldType = nFieldType;
- m_pPictureStore[nSurfaceIndex].nCodecSpecific = nCodecSpecific;
- }
-
- m_nFieldSurface = -1;
- m_nWaitingPics++;
- return true;
- }
-}
-
-void CDXVADecoder::UpdateStore(int nSurfaceIndex, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
-{
- ASSERT((nSurfaceIndex < m_nPicEntryNumber) && m_pPictureStore[nSurfaceIndex].bInUse && !m_pPictureStore[nSurfaceIndex].bDisplayed);
-
- m_pPictureStore[nSurfaceIndex].rtStart = rtStart;
- m_pPictureStore[nSurfaceIndex].rtStop = rtStop;
-}
-
-void CDXVADecoder::RemoveRefFrame(int nSurfaceIndex)
-{
- //ASSERT ((nSurfaceIndex < m_nPicEntryNumber) && m_pPictureStore[nSurfaceIndex].bInUse);
-
- m_pPictureStore[nSurfaceIndex].bRefPicture = false;
- if (m_pPictureStore[nSurfaceIndex].bDisplayed) {
- FreePictureSlot(nSurfaceIndex);
- }
-}
-
-int CDXVADecoder::FindOldestFrame()
-{
- REFERENCE_TIME rtMin = _I64_MAX;
- int nPos = -1;
-
- // TODO : find better solution...
- if (m_nWaitingPics > m_nMaxWaiting) {
- for (int i = 0; i < m_nPicEntryNumber; i++) {
- if (!m_pPictureStore[i].bDisplayed && m_pPictureStore[i].bInUse && (m_pPictureStore[i].rtStart < rtMin)) {
- rtMin = m_pPictureStore[i].rtStart;
- nPos = i;
- }
- }
- }
- return nPos;
-}
-
-void CDXVADecoder::SetTypeSpecificFlags(PICTURE_STORE* pPicture, IMediaSample* pMS)
-{
- if (CComQIPtr<IMediaSample2> pMS2 = pMS) {
- AM_SAMPLE2_PROPERTIES props;
- if (SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props))) {
- props.dwTypeSpecificFlags &= ~0x7f;
-
- FF_FIELD_TYPE fieldType;
- switch (m_pFilter->GetInterlacedFlag()) {
- case MPCVC_INTERLACED_PROGRESSIVE:
- fieldType = PICT_FRAME;
- break;
- case MPCVC_INTERLACED_TOP_FIELD_FIRST:
- fieldType = PICT_TOP_FIELD;
- break;
- case MPCVC_INTERLACED_BOTTOM_FIELD_FIRST:
- fieldType = PICT_BOTTOM_FIELD;
- break;
- default:
- fieldType = pPicture->n1FieldType;
- break;
- }
-
- m_pFilter->SetFrameType(fieldType);
-
- if (fieldType == PICT_FRAME) {
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
- } else if (fieldType == PICT_TOP_FIELD) {
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_FIELD1FIRST;
- }
-
- switch (pPicture->nSliceType) {
- case I_TYPE:
- case SI_TYPE:
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_I_SAMPLE;
- break;
- case P_TYPE:
- case SP_TYPE:
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_P_SAMPLE;
- break;
- default:
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_B_SAMPLE;
- break;
- }
-
- pMS2->SetProperties(sizeof(props), (BYTE*)&props);
- }
- }
- pMS->SetTime(&pPicture->rtStart, &pPicture->rtStop);
-}
-
-HRESULT CDXVADecoder::DisplayNextFrame()
-{
- HRESULT hr = S_FALSE;
- CComPtr<IMediaSample> pSampleToDeliver;
- int nPicIndex = FindOldestFrame();
-
- if (nPicIndex != -1) {
- if (m_pPictureStore[nPicIndex].rtStart >= 0) {
- switch (m_nEngine) {
- case ENGINE_DXVA1:
- // For DXVA1, query a media sample at the last time (only one in the allocator)
- hr = GetDeliveryBuffer(m_pPictureStore[nPicIndex].rtStart, m_pPictureStore[nPicIndex].rtStop, &pSampleToDeliver);
- SetTypeSpecificFlags(&m_pPictureStore[nPicIndex], pSampleToDeliver);
- if (SUCCEEDED(hr)) {
- hr = m_pAMVideoAccelerator->DisplayFrame(nPicIndex, pSampleToDeliver);
- }
- break;
- case ENGINE_DXVA2:
- // For DXVA2 media sample is in the picture store
- m_pPictureStore[nPicIndex].pSample->SetTime(&m_pPictureStore[nPicIndex].rtStart, &m_pPictureStore[nPicIndex].rtStop);
- SetTypeSpecificFlags(&m_pPictureStore[nPicIndex], m_pPictureStore[nPicIndex].pSample);
- hr = m_pFilter->GetOutputPin()->Deliver(m_pPictureStore[nPicIndex].pSample);
- break;
- }
-
-#if defined(_DEBUG) && 0
- static REFERENCE_TIME rtLast = 0;
- TRACE(_T("Deliver : %10I64d - %10I64d (Dur = %10I64d) {Delta = %10I64d} Ind = %02d Codec=%d Ref=%d\n"),
- m_pPictureStore[nPicIndex].rtStart,
- m_pPictureStore[nPicIndex].rtStop,
- m_pPictureStore[nPicIndex].rtStop - m_pPictureStore[nPicIndex].rtStart,
- m_pPictureStore[nPicIndex].rtStart - rtLast, nPicIndex,
- m_pPictureStore[nPicIndex].nCodecSpecific,
- m_pPictureStore[nPicIndex].bRefPicture);
- rtLast = m_pPictureStore[nPicIndex].rtStart;
-#endif
- }
- m_bNeedChangeAspect = false;
-
- m_pPictureStore[nPicIndex].bDisplayed = true;
- if (!m_pPictureStore[nPicIndex].bRefPicture) {
- FreePictureSlot(nPicIndex);
- }
- }
-
- return hr;
-}
-
-HRESULT CDXVADecoder::GetFreeSurfaceIndex(int& nSurfaceIndex, IMediaSample** ppSampleToDeliver, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
-{
- HRESULT hr = E_UNEXPECTED;
- int nPos = -1;
- DWORD dwMinDisplay = MAXDWORD;
-
- if (m_nFieldSurface != -1) {
- nSurfaceIndex = m_nFieldSurface;
- *ppSampleToDeliver = m_pFieldSample.Detach();
- return S_FALSE;
- }
-
- switch (m_nEngine) {
- case ENGINE_DXVA1:
- for (int i = 0; i < m_nPicEntryNumber; i++) {
- if (!m_pPictureStore[i].bInUse && m_pPictureStore[i].dwDisplayCount < dwMinDisplay) {
- dwMinDisplay = m_pPictureStore[i].dwDisplayCount;
- nPos = i;
- }
- }
-
- if (nPos != -1) {
- nSurfaceIndex = nPos;
- return S_OK;
- }
-
- // Ho ho...
- ASSERT(FALSE);
- Flush();
- break;
- case ENGINE_DXVA2:
- CComPtr<IMediaSample> pNewSample;
- CComQIPtr<IMPCDXVA2Sample> pMPCDXVA2Sample;
- // TODO : test IDirect3DDeviceManager9::TestDevice !!!
- if (SUCCEEDED(hr = GetDeliveryBuffer(rtStart, rtStop, &pNewSample))) {
- pMPCDXVA2Sample = pNewSample;
- nSurfaceIndex = pMPCDXVA2Sample ? pMPCDXVA2Sample->GetDXSurfaceId() : 0;
- *ppSampleToDeliver = pNewSample.Detach();
- }
- break;
- }
-
- return hr;
-}
-
-void CDXVADecoder::FreePictureSlot(int nSurfaceIndex)
-{
- m_pPictureStore[nSurfaceIndex].dwDisplayCount = m_dwDisplayCount++;
- m_pPictureStore[nSurfaceIndex].bInUse = false;
- m_pPictureStore[nSurfaceIndex].bDisplayed = false;
- m_pPictureStore[nSurfaceIndex].pSample = nullptr;
- m_pPictureStore[nSurfaceIndex].nCodecSpecific = -1;
- m_nWaitingPics--;
-}
-
-BYTE CDXVADecoder::GetConfigResidDiffAccelerator()
-{
- switch (m_nEngine) {
- case ENGINE_DXVA1:
- return m_DXVA1Config.bConfigResidDiffAccelerator;
- case ENGINE_DXVA2:
- return m_DXVA2Config.ConfigResidDiffAccelerator;
- }
- return 0;
-}
-
-BYTE CDXVADecoder::GetConfigIntraResidUnsigned()
-{
- switch (m_nEngine) {
- case ENGINE_DXVA1:
- return m_DXVA1Config.bConfigIntraResidUnsigned;
- case ENGINE_DXVA2:
- return m_DXVA2Config.ConfigIntraResidUnsigned;
- }
- return 0;
-}
-
-void CDXVADecoder::EndOfStream()
-{
- CComPtr<IMediaSample> pSampleToDeliver;
-
- for (int nPicIndex = 0; nPicIndex < m_nPicEntryNumber; nPicIndex++) {
- PICTURE_STORE& pic = m_pPictureStore[nPicIndex];
- if (pic.bInUse && !pic.bDisplayed && pic.rtStart != _I64_MIN) {
- switch (m_nEngine) {
- // TODO - need check under WinXP on DXVA1
- /*
- case ENGINE_DXVA1:
- if (SUCCEEDED (GetDeliveryBuffer (pic.rtStart, pic.rtStop, &pSampleToDeliver)) && pSampleToDeliver) {
- m_pAMVideoAccelerator->DisplayFrame(nPicIndex, pSampleToDeliver);
- }
- break;
- */
- case ENGINE_DXVA2:
- SetTypeSpecificFlags(&pic, pic.pSample);
- m_pFilter->GetOutputPin()->Deliver(pic.pSample);
- break;
- }
- }
- }
-}
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoder.h b/src/filters/transform/MPCVideoDec/DXVADecoder.h
deleted file mode 100644
index 638432a03..000000000
--- a/src/filters/transform/MPCVideoDec/DXVADecoder.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <dxva2api.h>
-#include <videoacc.h>
-#include "../../../DSUtil/DSUtil.h"
-
-typedef enum {
- ENGINE_DXVA1,
- ENGINE_DXVA2
-} DXVA_ENGINE;
-
-typedef enum {
- H264_VLD,
- VC1_VLD,
- MPEG2_VLD
-} DXVAMode;
-
-typedef enum {
- I_TYPE = 1, ///< Intra
- P_TYPE = 2, ///< Predicted
- B_TYPE = 3, ///< Bi-dir predicted
- S_TYPE = 4, ///< S(GMC)-VOP MPEG4
- SI_TYPE = 5, ///< Switching Intra
- SP_TYPE = 6, ///< Switching Predicted
- BI_TYPE = 7
-} FF_SLICE_TYPE;
-
-typedef struct {
- bool bRefPicture; // True if reference picture
- bool bInUse; // Slot in use
- bool bDisplayed; // True if picture have been presented
- CComPtr<IMediaSample> pSample; // Only for DXVA2 !
- REFERENCE_TIME rtStart;
- REFERENCE_TIME rtStop;
- FF_FIELD_TYPE n1FieldType; // Top or bottom for the 1st field
- FF_SLICE_TYPE nSliceType;
- int nCodecSpecific;
- DWORD dwDisplayCount;
-} PICTURE_STORE;
-
-#define MAX_COM_BUFFER 6 // Max uncompressed buffer for an Execute command (DXVA1)
-#define COMP_BUFFER_COUNT 18
-#define NO_REF_FRAME 0xFFFF
-
-class CMPCVideoDecFilter;
-
-class CDXVADecoder
-{
-public:
- // === Public functions
- virtual ~CDXVADecoder();
- DXVAMode GetMode() const { return m_nMode; };
- DXVA_ENGINE GetEngine() const { return m_nEngine; };
- void AllocExecuteParams(int nSize);
- void SetDirectXVideoDec(IDirectXVideoDecoder* pDirectXVideoDec) {
- m_pDirectXVideoDec = pDirectXVideoDec;
- };
-
- virtual HRESULT DecodeFrame(BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop) = 0;
- virtual void SetExtraData(BYTE* pDataIn, UINT nSize);
- virtual void CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize);
- virtual void Flush();
- HRESULT ConfigureDXVA1();
-
- static CDXVADecoder* CreateDecoder(CMPCVideoDecFilter* pFilter,
- IAMVideoAccelerator* pAMVideoAccelerator,
- const GUID* guidDecoder,
- int nPicEntryNumber);
- static CDXVADecoder* CreateDecoder(CMPCVideoDecFilter* pFilter,
- IDirectXVideoDecoder* pDirectXVideoDec,
- const GUID* guidDecoder,
- int nPicEntryNumber,
- DXVA2_ConfigPictureDecode* pDXVA2Config);
-
- void EndOfStream();
-
-protected:
- CDXVADecoder(CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber);
- CDXVADecoder(CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config);
-
- CMPCVideoDecFilter* m_pFilter;
- bool m_bFlushed;
- int m_nMaxWaiting;
-
- PICTURE_STORE* m_pPictureStore; // Store reference picture, and delayed B-frames
- int m_nPicEntryNumber; // Total number of picture in store
- int m_nWaitingPics; // Number of picture not yet displayed
-
- bool m_bNeedChangeAspect;
-
- // === DXVA functions
- HRESULT AddExecuteBuffer(DWORD CompressedBufferType, UINT nSize, void* pBuffer, UINT* pRealSize = nullptr);
- HRESULT GetDeliveryBuffer(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, IMediaSample** ppSampleToDeliver);
- HRESULT Execute();
- DWORD GetDXVA1CompressedType(DWORD dwDXVA2CompressedType);
- HRESULT FindFreeDXVA1Buffer(DWORD dwTypeIndex, DWORD& dwBufferIndex);
- HRESULT BeginFrame(int nSurfaceIndex, IMediaSample* pSampleToDeliver);
- HRESULT EndFrame(int nSurfaceIndex);
- HRESULT QueryStatus(PVOID LPDXVAStatus, UINT nSize);
- BYTE GetConfigIntraResidUnsigned();
- BYTE GetConfigResidDiffAccelerator();
- DXVA_ConfigPictureDecode* GetDXVA1Config() { return &m_DXVA1Config; };
- DXVA2_ConfigPictureDecode* GetDXVA2Config() { return &m_DXVA2Config; };
-
- // === Picture store functions
- bool AddToStore(int nSurfaceIndex, IMediaSample* pSample, bool bRefPicture,
- REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, bool bIsField,
- FF_FIELD_TYPE nFieldType, FF_SLICE_TYPE nSliceType, int nCodecSpecific);
- void UpdateStore(int nSurfaceIndex, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
- void RemoveRefFrame(int nSurfaceIndex);
- HRESULT DisplayNextFrame();
- HRESULT GetFreeSurfaceIndex(int& nSurfaceIndex, IMediaSample** ppSampleToDeliver,
- REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
- virtual int FindOldestFrame();
-
-private:
- DXVAMode m_nMode;
- DXVA_ENGINE m_nEngine;
-
- CComPtr<IMediaSample> m_pFieldSample;
- int m_nFieldSurface;
-
- // === DXVA1 variables
- CComQIPtr<IAMVideoAccelerator> m_pAMVideoAccelerator;
- AMVABUFFERINFO m_DXVA1BufferInfo[MAX_COM_BUFFER];
- DXVA_BufferDescription m_DXVA1BufferDesc[MAX_COM_BUFFER];
- DWORD m_dwNumBuffersInfo;
- DXVA_ConfigPictureDecode m_DXVA1Config;
- AMVACompBufferInfo m_ComBufferInfo[COMP_BUFFER_COUNT];
- DWORD m_dwBufferIndex;
- DWORD m_dwDisplayCount;
-
- // === DXVA2 variables
- CComPtr<IDirectXVideoDecoder> m_pDirectXVideoDec;
- DXVA2_ConfigPictureDecode m_DXVA2Config;
- DXVA2_DecodeExecuteParams m_ExecuteParams;
-
- void Init(CMPCVideoDecFilter* pFilter, DXVAMode nMode, int nPicEntryNumber);
- void FreePictureSlot(int nSurfaceIndex);
- void SetTypeSpecificFlags(PICTURE_STORE* pPicture, IMediaSample* pMS);
-};
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp b/src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp
deleted file mode 100644
index 3c46e62e8..000000000
--- a/src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp
+++ /dev/null
@@ -1,390 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "../../../DSUtil/DSUtil.h"
-#include "DXVADecoderH264.h"
-#include "MPCVideoDecFilter.h"
-#include "VideoDecDXVAAllocator.h"
-#include "ffmpeg/libavcodec/avcodec.h"
-
-#include "FfmpegContext.h"
-
-#if 0
-#define TRACE_H264 TRACE
-#else
-#define TRACE_H264 __noop
-#endif
-
-CDXVADecoderH264::CDXVADecoderH264(CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber)
- : CDXVADecoder(pFilter, pAMVideoAccelerator, nMode, nPicEntryNumber)
-{
- m_bUseLongSlice = (GetDXVA1Config()->bConfigBitstreamRaw != 2);
- Init();
-}
-
-CDXVADecoderH264::CDXVADecoderH264(CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config)
- : CDXVADecoder(pFilter, pDirectXVideoDec, nMode, nPicEntryNumber, pDXVA2Config)
-{
- m_bUseLongSlice = (m_pFilter->GetDXVA2Config()->ConfigBitstreamRaw != 2);
- Init();
-}
-
-CDXVADecoderH264::~CDXVADecoderH264()
-{
-}
-
-void CDXVADecoderH264::Init()
-{
- ZeroMemory(&m_DXVAPicParams, sizeof(m_DXVAPicParams));
- ZeroMemory(&m_DXVAPicParams, sizeof(DXVA_PicParams_H264));
- ZeroMemory(&m_pSliceLong, sizeof(DXVA_Slice_H264_Long) * MAX_SLICES);
- ZeroMemory(&m_pSliceShort, sizeof(DXVA_Slice_H264_Short) * MAX_SLICES);
-
- m_DXVAPicParams.MbsConsecutiveFlag = 1;
- if (m_pFilter->GetPCIVendor() == PCIV_Intel) {
- m_DXVAPicParams.Reserved16Bits = 0x534c;
- } else {
- m_DXVAPicParams.Reserved16Bits = 0;
- }
- m_DXVAPicParams.ContinuationFlag = 1;
- m_DXVAPicParams.Reserved8BitsA = 0;
- m_DXVAPicParams.Reserved8BitsB = 0;
- m_DXVAPicParams.MinLumaBipredSize8x8Flag = 1; // Improve accelerator performances
- m_DXVAPicParams.StatusReportFeedbackNumber = 0; // Use to report status
-
- for (int i = 0; i < 16; i++) {
- m_DXVAPicParams.RefFrameList[i].AssociatedFlag = 1;
- m_DXVAPicParams.RefFrameList[i].bPicEntry = 255;
- m_DXVAPicParams.RefFrameList[i].Index7Bits = 127;
- }
-
- m_nNALLength = 4;
- m_nMaxSlices = 0;
-
- switch (GetMode()) {
- case H264_VLD:
- AllocExecuteParams(3);
- break;
- default:
- ASSERT(FALSE);
- }
-}
-
-void CDXVADecoderH264::CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize)
-{
- CH264Nalu Nalu;
- int nDummy;
- int nSlices = 0;
- UINT m_nSize = nSize;
- int slice_step = 1;
- int nDxvaNalLength;
-
- while (!nSlices && slice_step <= 2) {
- Nalu.SetBuffer(pBuffer, m_nSize, slice_step == 1 ? m_nNALLength : 0);
- nSize = 0;
- while (Nalu.ReadNext()) {
- switch (Nalu.GetType()) {
- case NALU_TYPE_SLICE:
- case NALU_TYPE_IDR:
- // Skip the NALU if the data length is below 0
- if (Nalu.GetDataLength() < 0) {
- break;
- }
-
- // For AVC1, put startcode 0x000001
- pDXVABuffer[0] = pDXVABuffer[1] = 0;
- pDXVABuffer[2] = 1;
-
- // Copy NALU
- __try {
- memcpy(pDXVABuffer + 3, Nalu.GetDataBuffer(), Nalu.GetDataLength());
- } __except (EXCEPTION_EXECUTE_HANDLER) {
- break;
- }
-
- // Update slice control buffer
- nDxvaNalLength = (int)Nalu.GetDataLength() + 3;
- m_pSliceShort[nSlices].BSNALunitDataLocation = nSize;
- m_pSliceShort[nSlices].SliceBytesInBuffer = nDxvaNalLength;
-
- nSize += nDxvaNalLength;
- pDXVABuffer += nDxvaNalLength;
- nSlices++;
- break;
- }
- }
- slice_step++;
- }
-
- // Complete with zero padding (buffer size should be a multiple of 128)
- nDummy = 128 - (nSize % 128);
-
- ZeroMemory(pDXVABuffer, nDummy);
- m_pSliceShort[nSlices - 1].SliceBytesInBuffer += nDummy;
- nSize += nDummy;
-}
-
-void CDXVADecoderH264::Flush()
-{
- ClearRefFramesList();
- m_DXVAPicParams.UsedForReferenceFlags = 0;
- m_nOutPOC = INT_MIN;
- m_nPrevOutPOC = INT_MIN;
-
- m_nfield_pic_flag = 1;
- m_nRefPicFlag = 1;
- m_nBrokenFramesFlag = 0;
- m_nBrokenFramesFlag_POC = 0;
-
- __super::Flush();
-}
-
-HRESULT CDXVADecoderH264::DecodeFrame(BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
-{
- HRESULT hr = S_FALSE;
- UINT nSlices = 0;
- int nSurfaceIndex = -1;
- int nFieldType = -1;
- int nSliceType = -1;
- int nFramePOC = INT_MIN;
- int nOutPOC = INT_MIN;
- REFERENCE_TIME rtOutStart = _I64_MIN;
- CH264Nalu Nalu;
- UINT nNalOffset = 0;
- CComPtr<IMediaSample> pSampleToDeliver;
- CComQIPtr<IMPCDXVA2Sample> pDXVA2Sample;
- int slice_step = 1;
-
- if (FFH264DecodeBuffer(m_pFilter->GetAVCtx(), pDataIn, nSize, &nFramePOC, &nOutPOC, &rtOutStart) == -1) {
- return S_FALSE;
- }
-
- while (!nSlices && slice_step <= 2) {
- Nalu.SetBuffer(pDataIn, nSize, slice_step == 1 ? m_nNALLength : 0);
- while (Nalu.ReadNext()) {
- switch (Nalu.GetType()) {
- case NALU_TYPE_SLICE:
- case NALU_TYPE_IDR:
- if (m_bUseLongSlice) {
- m_pSliceLong[nSlices].BSNALunitDataLocation = nNalOffset;
- m_pSliceLong[nSlices].SliceBytesInBuffer = (UINT)Nalu.GetDataLength() + 3; //.GetRoundedDataLength();
- m_pSliceLong[nSlices].slice_id = nSlices;
- FF264UpdateRefFrameSliceLong(&m_DXVAPicParams, &m_pSliceLong[nSlices], m_pFilter->GetAVCtx());
-
- if (nSlices > 0) {
- m_pSliceLong[nSlices - 1].NumMbsForSlice = m_pSliceLong[nSlices].NumMbsForSlice = m_pSliceLong[nSlices].first_mb_in_slice - m_pSliceLong[nSlices - 1].first_mb_in_slice;
- }
- }
- nSlices++;
- nNalOffset += (UINT)(Nalu.GetDataLength() + 3);
- if (nSlices > MAX_SLICES) {
- break;
- }
- break;
- }
- }
- slice_step++;
- }
-
- if (!nSlices) {
- return S_FALSE;
- }
-
- m_nMaxWaiting = min(max(m_DXVAPicParams.num_ref_frames, 3), 8);
-
- // If parsing fail (probably no PPS/SPS), continue anyway it may arrived later (happen on truncated streams)
- if (FAILED(FFH264BuildPicParams(&m_DXVAPicParams, &m_DXVAScalingMatrix, &nFieldType, &nSliceType, m_pFilter->GetAVCtx(), m_pFilter->GetPCIVendor()))) {
- return S_FALSE;
- }
-
- TRACE_H264("CDXVADecoderH264::DecodeFrame() : nFramePOC = %11d, nOutPOC = %11d[%11d], [%d - %d], rtOutStart = [%20I64d]\n", nFramePOC, nOutPOC, m_nOutPOC, m_DXVAPicParams.field_pic_flag, m_DXVAPicParams.RefPicFlag, rtOutStart);
-
- // Wait I frame after a flush
- if (m_bFlushed && !m_DXVAPicParams.IntraPicFlag) {
- TRACE_H264("CDXVADecoderH264::DecodeFrame() : Flush - wait I frame\n");
- m_nBrokenFramesFlag = 0;
- m_nBrokenFramesFlag_POC = 0;
- m_nfield_pic_flag = m_DXVAPicParams.field_pic_flag;
- m_nRefPicFlag = m_DXVAPicParams.RefPicFlag;
- m_nPrevOutPOC = INT_MIN;
- return S_FALSE;
- }
-
- /* Disabled, because that causes serious problems.
- // Some magic code for detecting the incorrect decoding of interlaced frames ...
- // TODO : necessary to make it better, and preferably on the side of ffmpeg ...
- if (m_nfield_pic_flag && m_nfield_pic_flag == m_DXVAPicParams.field_pic_flag && m_nRefPicFlag == m_DXVAPicParams.RefPicFlag) {
- if (m_nPrevOutPOC == m_nOutPOC && m_nOutPOC == INT_MIN) {
- m_nBrokenFramesFlag_POC++;
- }
- m_nBrokenFramesFlag++;
- } else {
- m_nBrokenFramesFlag = 0;
- m_nBrokenFramesFlag_POC = 0;
- }
- m_nfield_pic_flag = m_DXVAPicParams.field_pic_flag;
- m_nRefPicFlag = m_DXVAPicParams.RefPicFlag;
- m_nPrevOutPOC = m_nOutPOC;
-
- if (m_nBrokenFramesFlag > 4) {
- m_nBrokenFramesFlag = 0;
- if (m_nBrokenFramesFlag_POC > 1) {
- TRACE_H264("CDXVADecoderH264::DecodeFrame() : Detected broken frames ... flush data\n");
- m_nBrokenFramesFlag_POC = 0;
- Flush();
- return S_FALSE;
- }
- }
- //
- */
-
- CHECK_HR_TRACE(GetFreeSurfaceIndex(nSurfaceIndex, &pSampleToDeliver, rtStart, rtStop));
- FFH264SetCurrentPicture(nSurfaceIndex, &m_DXVAPicParams, m_pFilter->GetAVCtx());
-
- CHECK_HR_TRACE(BeginFrame(nSurfaceIndex, pSampleToDeliver));
-
- m_DXVAPicParams.StatusReportFeedbackNumber++;
-
- // Send picture parameters
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_PictureParametersBufferType, sizeof(m_DXVAPicParams), &m_DXVAPicParams));
- CHECK_HR_TRACE(Execute());
-
- // Add bitstream, slice control and quantization matrix
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_BitStreamDateBufferType, nSize, pDataIn, &nSize));
-
- if (m_bUseLongSlice) {
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_SliceControlBufferType, sizeof(DXVA_Slice_H264_Long)*nSlices, m_pSliceLong));
- } else {
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_SliceControlBufferType, sizeof(DXVA_Slice_H264_Short)*nSlices, m_pSliceShort));
- }
-
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_InverseQuantizationMatrixBufferType, sizeof(DXVA_Qmatrix_H264), (void*)&m_DXVAScalingMatrix));
-
- // Decode bitstream
- CHECK_HR_TRACE(Execute());
- CHECK_HR_TRACE(EndFrame(nSurfaceIndex));
-
-#if defined(_DEBUG) && 0
- DisplayStatus();
-#endif
-
- bool bAdded = AddToStore(nSurfaceIndex, pSampleToDeliver, m_DXVAPicParams.RefPicFlag, rtStart, rtStop,
- m_DXVAPicParams.field_pic_flag, (FF_FIELD_TYPE)nFieldType,
- (FF_SLICE_TYPE)nSliceType, nFramePOC);
-
- FFH264UpdateRefFramesList(&m_DXVAPicParams, m_pFilter->GetAVCtx());
- ClearUnusedRefFrames();
-
- if (bAdded) {
- hr = DisplayNextFrame();
- }
-
- if (nOutPOC != INT_MIN) {
- m_nOutPOC = nOutPOC;
- m_rtOutStart = rtOutStart;
- }
-
- m_bFlushed = false;
- return hr;
-}
-
-void CDXVADecoderH264::RemoveUndisplayedFrame(int nPOC)
-{
- // Find frame with given POC, and free the slot
- for (int i = 0; i < m_nPicEntryNumber; i++) {
- if (m_pPictureStore[i].bInUse && m_pPictureStore[i].nCodecSpecific == nPOC) {
- m_pPictureStore[i].bDisplayed = true;
- RemoveRefFrame(i);
- return;
- }
- }
-}
-
-void CDXVADecoderH264::ClearUnusedRefFrames()
-{
- // Remove old reference frames (not anymore a short or long ref frame)
- for (int i = 0; i < m_nPicEntryNumber; i++) {
- if (m_pPictureStore[i].bRefPicture && m_pPictureStore[i].bDisplayed) {
- if (!FFH264IsRefFrameInUse(i, m_pFilter->GetAVCtx())) {
- RemoveRefFrame(i);
- }
- }
- }
-}
-
-void CDXVADecoderH264::SetExtraData(BYTE* pDataIn, UINT nSize)
-{
- AVCodecContext* pAVCtx = m_pFilter->GetAVCtx();
- m_nNALLength = pAVCtx->nal_length_size;
-
- FFH264DecodeBuffer(pAVCtx, pDataIn, nSize, nullptr, nullptr, nullptr);
- FFH264SetDxvaSliceLong(pAVCtx, m_pSliceLong);
-}
-
-void CDXVADecoderH264::ClearRefFramesList()
-{
- for (int i = 0; i < m_nPicEntryNumber; i++) {
- if (m_pPictureStore[i].bInUse) {
- m_pPictureStore[i].bDisplayed = true;
- RemoveRefFrame(i);
- }
- }
-}
-
-HRESULT CDXVADecoderH264::DisplayStatus()
-{
- HRESULT hr = E_INVALIDARG;
- DXVA_Status_H264 Status;
-
- ZeroMemory(&Status, sizeof(Status));
- CHECK_HR_TRACE(CDXVADecoder::QueryStatus(&Status, sizeof(Status)));
-
- TRACE_H264("CDXVADecoderH264::DisplayStatus() : Status for the frame %u : bBufType = %u, bStatus = %u, wNumMbsAffected = %u\n",
- Status.StatusReportFeedbackNumber,
- Status.bBufType,
- Status.bStatus,
- Status.wNumMbsAffected);
-
- return hr;
-}
-
-int CDXVADecoderH264::FindOldestFrame()
-{
- int nPos = -1;
- REFERENCE_TIME rtPos = _I64_MAX;
-
- for (int i = 0; i < m_nPicEntryNumber; i++) {
- if (m_pPictureStore[i].bInUse && !m_pPictureStore[i].bDisplayed) {
- if ((m_pPictureStore[i].nCodecSpecific == m_nOutPOC) && (m_pPictureStore[i].rtStart < rtPos) && (m_pPictureStore[i].rtStart >= m_rtOutStart)) {
- nPos = i;
- rtPos = m_pPictureStore[i].rtStart;
- }
- }
- }
-
- if (nPos != -1) {
- m_pPictureStore[nPos].rtStart = m_rtOutStart;
- m_pFilter->UpdateFrameTime(m_pPictureStore[nPos].rtStart, m_pPictureStore[nPos].rtStop);
- m_pFilter->ReorderBFrames(m_pPictureStore[nPos].rtStart, m_pPictureStore[nPos].rtStop);
- }
-
- return nPos;
-}
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderH264.h b/src/filters/transform/MPCVideoDec/DXVADecoderH264.h
deleted file mode 100644
index 5cf3a4fb7..000000000
--- a/src/filters/transform/MPCVideoDec/DXVADecoderH264.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * (C) 2007-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <dxva.h>
-#include "DXVADecoder.h"
-
-#define MAX_SLICES 16 // Also defined in libavcodec/h264.h
-
-class CDXVADecoderH264 : public CDXVADecoder
-{
-public:
- CDXVADecoderH264(CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber);
- CDXVADecoderH264(CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config);
- virtual ~CDXVADecoderH264();
-
- virtual HRESULT DecodeFrame(BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
- virtual void SetExtraData(BYTE* pDataIn, UINT nSize);
- virtual void CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize);
- virtual void Flush();
-
-protected:
- virtual int FindOldestFrame();
-
-private:
-
- DXVA_PicParams_H264 m_DXVAPicParams;
- DXVA_Qmatrix_H264 m_DXVAScalingMatrix;
- DXVA_Slice_H264_Short m_pSliceShort[MAX_SLICES];
- DXVA_Slice_H264_Long m_pSliceLong[MAX_SLICES];
- UINT m_nMaxSlices;
- int m_nNALLength;
- bool m_bUseLongSlice;
- int m_nOutPOC, m_nPrevOutPOC;
- REFERENCE_TIME m_rtOutStart;
-
- unsigned short m_nfield_pic_flag;
- unsigned short m_nRefPicFlag;
- UINT m_nBrokenFramesFlag, m_nBrokenFramesFlag_POC;
-
- // Private functions
- void Init();
- HRESULT DisplayStatus();
-
- // DXVA functions
- void RemoveUndisplayedFrame(int nPOC);
- void ClearRefFramesList();
- void ClearUnusedRefFrames();
-};
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.cpp b/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.cpp
deleted file mode 100644
index a6e7d8dd5..000000000
--- a/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.cpp
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * (C) 2010-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "DXVADecoderMpeg2.h"
-#include "MPCVideoDecFilter.h"
-
-#include "FfmpegContext.h"
-
-#if 0
-#define TRACE_MPEG2 TRACE
-#else
-#define TRACE_MPEG2 __noop
-#endif
-
-CDXVADecoderMpeg2::CDXVADecoderMpeg2(CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber)
- : CDXVADecoder(pFilter, pAMVideoAccelerator, nMode, nPicEntryNumber)
-{
- Init();
-}
-
-CDXVADecoderMpeg2::CDXVADecoderMpeg2(CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config)
- : CDXVADecoder(pFilter, pDirectXVideoDec, nMode, nPicEntryNumber, pDXVA2Config)
-{
- Init();
-}
-
-CDXVADecoderMpeg2::~CDXVADecoderMpeg2()
-{
- Flush();
-}
-
-void CDXVADecoderMpeg2::Init()
-{
- ZeroMemory(&m_PictureParams, sizeof(m_PictureParams));
- ZeroMemory(&m_SliceInfo, sizeof(m_SliceInfo));
- ZeroMemory(&m_QMatrixData, sizeof(m_QMatrixData));
-
- m_nMaxWaiting = 5;
- m_wRefPictureIndex[0] = NO_REF_FRAME;
- m_wRefPictureIndex[1] = NO_REF_FRAME;
- m_nSliceCount = 0;
-
- switch (GetMode()) {
- case MPEG2_VLD:
- AllocExecuteParams(4);
- break;
- default:
- ASSERT(FALSE);
- }
-}
-
-// === Public functions
-HRESULT CDXVADecoderMpeg2::DecodeFrame(BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
-{
- HRESULT hr;
- int nFieldType;
- int nSliceType;
-
- FFMpeg2DecodeFrame(&m_PictureParams, &m_QMatrixData, m_SliceInfo, &m_nSliceCount, m_pFilter->GetAVCtx(),
- m_pFilter->GetFrame(), &m_nNextCodecIndex, &nFieldType, &nSliceType, pDataIn, nSize);
-
- if (m_PictureParams.bSecondField && !m_bSecondField) {
- m_bSecondField = true;
- }
-
- // Wait I frame after a flush
- if (m_bFlushed && (!m_PictureParams.bPicIntra || (m_bSecondField && m_PictureParams.bSecondField))) {
- TRACE_MPEG2("CDXVADecoderMpeg2::DecodeFrame() : Flush - wait I frame\n");
- return S_FALSE;
- }
-
- if (m_bSecondField) {
- if (!m_PictureParams.bSecondField) {
- m_rtStart = rtStart;
- m_rtStop = rtStop;
- m_pSampleToDeliver = nullptr;
- hr = GetFreeSurfaceIndex(m_nSurfaceIndex, &m_pSampleToDeliver, rtStart, rtStop);
- if (FAILED(hr)) {
- ASSERT(hr == VFW_E_NOT_COMMITTED); // Normal when stop playing
- return hr;
- }
- }
- } else {
- m_rtStart = rtStart;
- m_rtStop = rtStop;
- m_pSampleToDeliver = nullptr;
- hr = GetFreeSurfaceIndex(m_nSurfaceIndex, &m_pSampleToDeliver, rtStart, rtStop);
- if (FAILED(hr)) {
- ASSERT(hr == VFW_E_NOT_COMMITTED); // Normal when stop playing
- return hr;
- }
- }
-
- // m_pSampleToDeliver is unused for DXVA1
- if (GetEngine() == ENGINE_DXVA2 && m_pSampleToDeliver == nullptr) {
- return S_FALSE;
- }
-
- CHECK_HR_TRACE(BeginFrame(m_nSurfaceIndex, m_pSampleToDeliver));
-
- if (m_bSecondField) {
- if (!m_PictureParams.bSecondField) {
- UpdatePictureParams(m_nSurfaceIndex);
- }
- } else {
- UpdatePictureParams(m_nSurfaceIndex);
- }
-
- TRACE_MPEG2("CDXVADecoderMpeg2::DecodeFrame() : Surf = %d, PictureType = %d, SecondField = %d, m_nNextCodecIndex = %d, rtStart = [%I64d]\n",
- m_nSurfaceIndex, nSliceType, m_PictureParams.bSecondField, m_nNextCodecIndex, rtStart);
-
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_PictureParametersBufferType, sizeof(m_PictureParams), &m_PictureParams));
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_InverseQuantizationMatrixBufferType, sizeof(m_QMatrixData), &m_QMatrixData));
-
- // Send bitstream to accelerator
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_SliceControlBufferType, sizeof(DXVA_SliceInfo)*m_nSliceCount, &m_SliceInfo));
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_BitStreamDateBufferType, nSize, pDataIn, &nSize));
-
- // Decode frame
- CHECK_HR_TRACE(Execute());
- CHECK_HR_TRACE(EndFrame(m_nSurfaceIndex));
-
- if (m_bSecondField) {
- if (m_PictureParams.bSecondField) {
- AddToStore(m_nSurfaceIndex, m_pSampleToDeliver, (m_PictureParams.bPicBackwardPrediction != 1), m_rtStart, m_rtStop,
- false, (FF_FIELD_TYPE)nFieldType, (FF_SLICE_TYPE)nSliceType, FFGetCodedPicture(m_pFilter->GetAVCtx()));
- hr = DisplayNextFrame();
- }
- } else {
- AddToStore(m_nSurfaceIndex, m_pSampleToDeliver, (m_PictureParams.bPicBackwardPrediction != 1), m_rtStart, m_rtStop,
- false, (FF_FIELD_TYPE)nFieldType, (FF_SLICE_TYPE)nSliceType, FFGetCodedPicture(m_pFilter->GetAVCtx()));
- hr = DisplayNextFrame();
- }
-
- m_bFlushed = false;
-
- return hr;
-}
-
-void CDXVADecoderMpeg2::UpdatePictureParams(int nSurfaceIndex)
-{
- DXVA2_ConfigPictureDecode* cpd = GetDXVA2Config(); // Ok for DXVA1 too (parameters have been copied)
-
- m_PictureParams.wDecodedPictureIndex = nSurfaceIndex;
-
- // Manage reference picture list
- if (!m_PictureParams.bPicBackwardPrediction) {
- if (m_wRefPictureIndex[0] != NO_REF_FRAME) {
- RemoveRefFrame(m_wRefPictureIndex[0]);
- }
- m_wRefPictureIndex[0] = m_wRefPictureIndex[1];
- m_wRefPictureIndex[1] = nSurfaceIndex;
- }
- m_PictureParams.wForwardRefPictureIndex = (m_PictureParams.bPicIntra == 0) ? m_wRefPictureIndex[0] : NO_REF_FRAME;
- m_PictureParams.wBackwardRefPictureIndex = (m_PictureParams.bPicBackwardPrediction == 1) ? m_wRefPictureIndex[1] : NO_REF_FRAME;
-
- // Shall be 0 if bConfigResidDiffHost is 0 or if BPP > 8
- if (cpd->ConfigResidDiffHost == 0 || m_PictureParams.bBPPminus1 > 7) {
- m_PictureParams.bPicSpatialResid8 = 0;
- } else {
- if (m_PictureParams.bBPPminus1 == 7 && m_PictureParams.bPicIntra && cpd->ConfigResidDiffHost)
- // Shall be 1 if BPP is 8 and bPicIntra is 1 and bConfigResidDiffHost is 1
- {
- m_PictureParams.bPicSpatialResid8 = 1;
- } else
- // Shall be 1 if bConfigSpatialResid8 is 1
- {
- m_PictureParams.bPicSpatialResid8 = cpd->ConfigSpatialResid8;
- }
- }
-
- // Shall be 0 if bConfigResidDiffHost is 0 or if bConfigSpatialResid8 is 0 or if BPP > 8
- if (cpd->ConfigResidDiffHost == 0 || cpd->ConfigSpatialResid8 == 0 || m_PictureParams.bBPPminus1 > 7) {
- m_PictureParams.bPicOverflowBlocks = 0;
- }
-
- // Shall be 1 if bConfigHostInverseScan is 1 or if bConfigResidDiffAccelerator is 0.
-
- if (cpd->ConfigHostInverseScan == 1 || cpd->ConfigResidDiffAccelerator == 0) {
- m_PictureParams.bPicScanFixed = 1;
-
- if (cpd->ConfigHostInverseScan != 0) {
- m_PictureParams.bPicScanMethod = 3; // 11 = Arbitrary scan with absolute coefficient address.
- } else if (FFGetAlternateScan(m_pFilter->GetAVCtx())) {
- m_PictureParams.bPicScanMethod = 1; // 00 = Zig-zag scan (MPEG-2 Figure 7-2)
- } else {
- m_PictureParams.bPicScanMethod = 0; // 01 = Alternate-vertical (MPEG-2 Figure 7-3),
- }
- }
-}
-
-void CDXVADecoderMpeg2::CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize)
-{
- while (*((DWORD*)pBuffer) != 0x01010000) {
- pBuffer++;
- nSize--;
-
- if (nSize <= 0) {
- return;
- }
- }
-
- memcpy(pDXVABuffer, pBuffer, nSize);
-}
-
-void CDXVADecoderMpeg2::Flush()
-{
- m_nNextCodecIndex = INT_MIN;
-
- if (m_wRefPictureIndex[0] != NO_REF_FRAME) {
- RemoveRefFrame(m_wRefPictureIndex[0]);
- }
- if (m_wRefPictureIndex[1] != NO_REF_FRAME) {
- RemoveRefFrame(m_wRefPictureIndex[1]);
- }
-
- m_wRefPictureIndex[0] = NO_REF_FRAME;
- m_wRefPictureIndex[1] = NO_REF_FRAME;
-
- m_nSurfaceIndex = 0;
- m_pSampleToDeliver = nullptr;
- m_bSecondField = false;
-
- m_rtStart = _I64_MIN;
- m_rtStop = _I64_MIN;
-
- m_rtLastStart = 0;
-
- __super::Flush();
-}
-
-int CDXVADecoderMpeg2::FindOldestFrame()
-{
- int nPos = -1;
-
- for (int i = 0; i < m_nPicEntryNumber; i++) {
- if (!m_pPictureStore[i].bDisplayed &&
- m_pPictureStore[i].bInUse &&
- (m_pPictureStore[i].nCodecSpecific == m_nNextCodecIndex)) {
- m_nNextCodecIndex = INT_MIN;
- nPos = i;
- }
- }
-
- if (nPos != -1) {
- UpdateFrameTime(m_pPictureStore[nPos].rtStart, m_pPictureStore[nPos].rtStop);
- }
-
- return nPos;
-}
-
-void CDXVADecoderMpeg2::UpdateFrameTime(REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop)
-{
- TRACE(_T("\n\nrtStart = [%10I64d - %10I64d] // "), rtStart, rtStop);
-
- if (m_rtLastStart && (rtStart == _I64_MIN || (rtStart < m_rtLastStart))) {
- rtStart = m_rtLastStart;
- }
-
- rtStop = rtStart + (REFERENCE_TIME)(m_pFilter->GetAvrTimePerFrame() / m_pFilter->GetRate());
- m_rtLastStart = rtStop;
-
- TRACE(_T("rtStart = [%10I64d - %10I64d]\n"), rtStart, rtStop);
-}
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.h b/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.h
deleted file mode 100644
index 3ab0db871..000000000
--- a/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * (C) 2010-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <dxva.h>
-#include "DXVADecoder.h"
-
-#define MAX_SLICE 1024 // Max slice number for Mpeg2 streams
-
-class CDXVADecoderMpeg2 : public CDXVADecoder
-{
-public:
- CDXVADecoderMpeg2(CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber);
- CDXVADecoderMpeg2(CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config);
- virtual ~CDXVADecoderMpeg2();
-
- virtual HRESULT DecodeFrame(BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
- virtual void CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize);
- virtual void Flush();
-
-protected:
- virtual int FindOldestFrame();
-
-private:
- DXVA_PictureParameters m_PictureParams;
- DXVA_QmatrixData m_QMatrixData;
- WORD m_wRefPictureIndex[2];
- DXVA_SliceInfo m_SliceInfo[MAX_SLICE];
- int m_nSliceCount;
-
- int m_nNextCodecIndex;
-
- int m_nSurfaceIndex;
- CComPtr<IMediaSample> m_pSampleToDeliver;
- bool m_bSecondField;
- REFERENCE_TIME m_rtStart;
- REFERENCE_TIME m_rtStop;
- REFERENCE_TIME m_rtLastStart;
-
- // Private functions
- void Init();
- void UpdatePictureParams(int nSurfaceIndex);
- void UpdateFrameTime(REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
-};
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp b/src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp
deleted file mode 100644
index acdd62520..000000000
--- a/src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "DXVADecoderVC1.h"
-#include "MPCVideoDecFilter.h"
-#include "ffmpeg/libavcodec/avcodec.h"
-
-#include "FfmpegContext.h"
-
-#if 0
-#define TRACE_VC1 TRACE
-#else
-#define TRACE_VC1 __noop
-#endif
-
-inline void SwapRT(REFERENCE_TIME& rtFirst, REFERENCE_TIME& rtSecond)
-{
- REFERENCE_TIME rtTemp = rtFirst;
- rtFirst = rtSecond;
- rtSecond = rtTemp;
-}
-
-CDXVADecoderVC1::CDXVADecoderVC1(CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber)
- : CDXVADecoder(pFilter, pAMVideoAccelerator, nMode, nPicEntryNumber)
-{
- Init();
-}
-
-CDXVADecoderVC1::CDXVADecoderVC1(CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config)
- : CDXVADecoder(pFilter, pDirectXVideoDec, nMode, nPicEntryNumber, pDXVA2Config)
-{
- Init();
-}
-
-CDXVADecoderVC1::~CDXVADecoderVC1()
-{
- Flush();
-}
-
-void CDXVADecoderVC1::Init()
-{
- ZeroMemory(&m_PictureParams, sizeof(m_PictureParams));
- ZeroMemory(&m_SliceInfo, sizeof(m_SliceInfo));
-
- m_nMaxWaiting = 5;
- m_wRefPictureIndex[0] = NO_REF_FRAME;
- m_wRefPictureIndex[1] = NO_REF_FRAME;
-
- switch (GetMode()) {
- case VC1_VLD:
- AllocExecuteParams(3);
- break;
- default:
- ASSERT(FALSE);
- }
-
- m_bFrame_repeat_pict = FALSE;
-}
-
-// === Public functions
-HRESULT CDXVADecoderVC1::DecodeFrame(BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
-{
- HRESULT hr;
- int nSurfaceIndex;
- CComPtr<IMediaSample> pSampleToDeliver;
- int nFieldType, nSliceType;
- UINT nFrameSize, nSize_Result;
-
- FFVC1UpdatePictureParam(&m_PictureParams, m_pFilter->GetAVCtx(), &nFieldType, &nSliceType, pDataIn, nSize, &nFrameSize, FALSE, &m_bFrame_repeat_pict);
-
- if (FFIsSkipped(m_pFilter->GetAVCtx())) {
- return S_OK;
- }
-
- // Wait I frame after a flush
- if (m_bFlushed && !m_PictureParams.bPicIntra) {
- return S_FALSE;
- }
-
- hr = GetFreeSurfaceIndex(nSurfaceIndex, &pSampleToDeliver, rtStart, rtStop);
- if (FAILED(hr)) {
- ASSERT(hr == VFW_E_NOT_COMMITTED); // Normal when stop playing
- return hr;
- }
-
- CHECK_HR_TRACE(BeginFrame(nSurfaceIndex, pSampleToDeliver));
-
- TRACE_VC1("CDXVADecoderVC1::DecodeFrame() : PictureType = %d, rtStart = %I64d, Surf = %d\n", nSliceType, rtStart, nSurfaceIndex);
-
- m_PictureParams.wDecodedPictureIndex = nSurfaceIndex;
- m_PictureParams.wDeblockedPictureIndex = m_PictureParams.wDecodedPictureIndex;
-
- // Manage reference picture list
- if (!m_PictureParams.bPicBackwardPrediction) {
- if (m_wRefPictureIndex[0] != NO_REF_FRAME) {
- RemoveRefFrame(m_wRefPictureIndex[0]);
- }
- m_wRefPictureIndex[0] = m_wRefPictureIndex[1];
- m_wRefPictureIndex[1] = nSurfaceIndex;
- }
- m_PictureParams.wForwardRefPictureIndex = (m_PictureParams.bPicIntra == 0) ? m_wRefPictureIndex[0] : NO_REF_FRAME;
- m_PictureParams.wBackwardRefPictureIndex = (m_PictureParams.bPicBackwardPrediction == 1) ? m_wRefPictureIndex[1] : NO_REF_FRAME;
-
- m_PictureParams.bPic4MVallowed = (m_PictureParams.wBackwardRefPictureIndex == NO_REF_FRAME && m_PictureParams.bPicStructure == 3) ? 1 : 0;
- m_PictureParams.bPicDeblockConfined |= (m_PictureParams.wBackwardRefPictureIndex == NO_REF_FRAME) ? 0x04 : 0;
-
- m_PictureParams.bPicScanMethod++; // Use for status reporting sections 3.8.1 and 3.8.2
-
- TRACE_VC1("CDXVADecoderVC1::DecodeFrame() : Decode frame %d\n", m_PictureParams.bPicScanMethod);
-
- // Send picture params to accelerator
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_PictureParametersBufferType, sizeof(m_PictureParams), &m_PictureParams));
-
- // Send bitstream to accelerator
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_BitStreamDateBufferType, nFrameSize ? nFrameSize : nSize, pDataIn, &nSize_Result));
-
- m_SliceInfo.wQuantizerScaleCode = 1; // TODO : 1->31 ???
- m_SliceInfo.dwSliceBitsInBuffer = nSize_Result * 8;
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_SliceControlBufferType, sizeof(m_SliceInfo), &m_SliceInfo));
-
- // Decode frame
- CHECK_HR_TRACE(Execute());
- CHECK_HR_TRACE(EndFrame(nSurfaceIndex));
-
- // ***************
- if (nFrameSize) { // Decoding Second Field
- FFVC1UpdatePictureParam(&m_PictureParams, m_pFilter->GetAVCtx(), nullptr, nullptr, pDataIn, nSize, nullptr, TRUE, &m_bFrame_repeat_pict);
-
- CHECK_HR_TRACE(BeginFrame(nSurfaceIndex, pSampleToDeliver));
-
- TRACE_VC1("CDXVADecoderVC1::DecodeFrame() : PictureType = %d\n", nSliceType);
-
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_PictureParametersBufferType, sizeof(m_PictureParams), &m_PictureParams));
-
- // Send bitstream to accelerator
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_BitStreamDateBufferType, nSize - nFrameSize, pDataIn + nFrameSize, &nSize_Result));
-
- m_SliceInfo.wQuantizerScaleCode = 1; // TODO : 1->31 ???
- m_SliceInfo.dwSliceBitsInBuffer = nSize_Result * 8;
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_SliceControlBufferType, sizeof(m_SliceInfo), &m_SliceInfo));
-
- // Decode frame
- CHECK_HR_TRACE(Execute());
- CHECK_HR_TRACE(EndFrame(nSurfaceIndex));
- }
- // ***************
-
-#ifdef _DEBUG
- DisplayStatus();
-#endif
-
- // Update timestamp & Re-order B frames
- if (m_bFrame_repeat_pict || m_pFilter->IsReorderBFrame()) {
- if (m_bFrame_repeat_pict || m_pFilter->GetCodec() == AV_CODEC_ID_WMV3) {
- m_pFilter->UpdateFrameTime(rtStart, rtStop, !!m_bFrame_repeat_pict);
- }
- if (m_pFilter->IsReorderBFrame() || m_pFilter->IsEvo()) {
- if (m_PictureParams.bPicBackwardPrediction == 1) {
- SwapRT(rtStart, m_rtStartDelayed);
- SwapRT(rtStop, m_rtStopDelayed);
- } else {
- // Save I or P reference time (swap later)
- if (!m_bFlushed) {
- if (m_nDelayedSurfaceIndex != -1) {
- UpdateStore(m_nDelayedSurfaceIndex, m_rtStartDelayed, m_rtStopDelayed);
- }
- m_rtStartDelayed = m_rtStopDelayed = _I64_MAX;
- SwapRT(rtStart, m_rtStartDelayed);
- SwapRT(rtStop, m_rtStopDelayed);
- m_nDelayedSurfaceIndex = nSurfaceIndex;
- }
- }
- }
- }
-
- AddToStore(nSurfaceIndex, pSampleToDeliver, (m_PictureParams.bPicBackwardPrediction != 1), rtStart, rtStop,
- false, (FF_FIELD_TYPE)nFieldType, (FF_SLICE_TYPE)nSliceType, 0);
- m_bFlushed = false;
-
- return DisplayNextFrame();
-}
-
-void CDXVADecoderVC1::SetExtraData(BYTE* pDataIn, UINT nSize)
-{
- m_PictureParams.bMacroblockWidthMinus1 = 15;
- m_PictureParams.bMacroblockHeightMinus1 = 15;
- m_PictureParams.bBlockWidthMinus1 = 7;
- m_PictureParams.bBlockHeightMinus1 = 7;
- m_PictureParams.bBPPminus1 = 7;
-
- m_PictureParams.bChromaFormat = VC1_CHROMA_420;
-
- m_PictureParams.bPicScanFixed = 0; // Use for status reporting sections 3.8.1 and 3.8.2
- m_PictureParams.bPicReadbackRequests = 0;
-
- m_PictureParams.bPicBinPB = 0; // TODO
- m_PictureParams.bMV_RPS = 0; // TODO
-
- m_PictureParams.bReservedBits = 0;
-
- // iWMV9 - i9IRU - iOHIT - iINSO - iWMVA - 0 - 0 - 0 | Section 3.2.5
- m_PictureParams.bBidirectionalAveragingMode = (1 << 7) |
- (GetConfigIntraResidUnsigned() << 6) | // i9IRU
- (GetConfigResidDiffAccelerator() << 5); // iOHIT
-}
-
-BYTE* CDXVADecoderVC1::FindNextStartCode(BYTE* pBuffer, UINT nSize, UINT& nPacketSize)
-{
- BYTE* pStart = pBuffer;
- BYTE bCode = 0;
- for (UINT i = 0; i < nSize - 4; i++) {
- if (((*((DWORD*)(pBuffer + i)) & 0x00FFFFFF) == 0x00010000) || (i >= nSize - 5)) {
- if (bCode == 0) {
- bCode = pBuffer[i + 3];
- if ((nSize == 5) && (bCode == 0x0D)) {
- nPacketSize = nSize;
- return pBuffer;
- }
- } else {
- if (bCode == 0x0D) {
- // Start code found!
- nPacketSize = i - (pStart - pBuffer) + (i >= nSize - 5 ? 5 : 1);
- return pStart;
- } else {
- // Other stuff, ignore it
- pStart = pBuffer + i;
- bCode = pBuffer[i + 3];
- }
- }
- }
- }
-
- ASSERT(FALSE); // Should never happen!
-
- return nullptr;
-}
-
-void CDXVADecoderVC1::CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize)
-{
- int nDummy;
-
- if (m_PictureParams.bSecondField) {
- memcpy(pDXVABuffer, (BYTE*)pBuffer, nSize);
- } else {
- if ((*((DWORD*)pBuffer) & 0x00FFFFFF) != 0x00010000) {
- if (m_pFilter->GetCodec() == AV_CODEC_ID_WMV3) {
- memcpy(pDXVABuffer, (BYTE*)pBuffer, nSize);
- } else {
- pDXVABuffer[0] = pDXVABuffer[1] = 0;
- pDXVABuffer[2] = 1;
- pDXVABuffer[3] = 0x0D;
- memcpy(pDXVABuffer + 4, (BYTE*)pBuffer, nSize);
- nSize += 4;
- }
- } else {
- BYTE* pStart;
- UINT nPacketSize;
-
- pStart = FindNextStartCode(pBuffer, nSize, nPacketSize);
- if (pStart) {
- // Startcode already present
- memcpy(pDXVABuffer, (BYTE*)pStart, nPacketSize);
- nSize = nPacketSize;
- }
- }
- }
-
- // Copy bitstream buffer, with zero padding (buffer is rounded to multiple of 128)
- nDummy = 128 - (nSize % 128);
-
- ZeroMemory(pDXVABuffer + nSize, nDummy);
- nSize += nDummy;
-}
-
-void CDXVADecoderVC1::Flush()
-{
- m_nDelayedSurfaceIndex = -1;
- m_rtStartDelayed = _I64_MAX;
- m_rtStopDelayed = _I64_MAX;
-
- if (m_wRefPictureIndex[0] != NO_REF_FRAME) {
- RemoveRefFrame(m_wRefPictureIndex[0]);
- }
- if (m_wRefPictureIndex[1] != NO_REF_FRAME) {
- RemoveRefFrame(m_wRefPictureIndex[1]);
- }
-
- m_wRefPictureIndex[0] = NO_REF_FRAME;
- m_wRefPictureIndex[1] = NO_REF_FRAME;
-
- __super::Flush();
-}
-
-HRESULT CDXVADecoderVC1::DisplayStatus()
-{
- HRESULT hr = E_INVALIDARG;
- DXVA_Status_VC1 Status;
-
- ZeroMemory(&Status, sizeof(Status));
-
- if (SUCCEEDED(hr = CDXVADecoder::QueryStatus(&Status, sizeof(Status)))) {
- Status.StatusReportFeedbackNumber = 0x00FF & Status.StatusReportFeedbackNumber;
-
- TRACE_VC1("CDXVADecoderVC1::DisplayStatus() : Status for the frame %u : bBufType = %u, bStatus = %u, wNumMbsAffected = %u\n",
- Status.StatusReportFeedbackNumber,
- Status.bBufType,
- Status.bStatus,
- Status.wNumMbsAffected);
- }
-
- return hr;
-}
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderVC1.h b/src/filters/transform/MPCVideoDec/DXVADecoderVC1.h
deleted file mode 100644
index 75781e180..000000000
--- a/src/filters/transform/MPCVideoDec/DXVADecoderVC1.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * (C) 2007-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <dxva.h>
-#include "DXVADecoder.h"
-
-class CDXVADecoderVC1 : public CDXVADecoder
-{
-public:
- CDXVADecoderVC1(CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber);
- CDXVADecoderVC1(CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config);
- virtual ~CDXVADecoderVC1();
-
- // === Public functions
- virtual HRESULT DecodeFrame(BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
- virtual void SetExtraData(BYTE* pDataIn, UINT nSize);
- virtual void CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize);
- virtual void Flush();
-
- typedef enum {
- VC1_PS_TOP_FIELD = 1,
- VC1_PS_BOTTOM_FIELD = 2,
- VC1_PS_PROGRESSIVE = 3
- } VC1_INTERLACING;
-
- typedef enum {
- VC1_CHROMA_420 = 1,
- VC1_CHROMA_422 = 2,
- VC1_CHROMA_444 = 3
- } VC1_CHROMA_FORMAT;
-
- typedef enum {
- VC1_CR_BICUBIC_QUARTER_CHROMA = 4,
- VC1_CR_BICUBIC_HALF_CHROMA = 5,
- VC1_CR_BILINEAR_QUARTER_CHROMA = 12,
- VC1_CR_BILINEAR_HALF_CHROMA = 13
- } VC1_CHROMA_RESIZE;
-
- typedef enum {
- VC1_SCAN_ZIGZAG = 0,
- VC1_SCAN_ALTERNATE_VERTICAL = 1,
- VC1_SCAN_ALTERNATE_HORIZONTAL = 2,
- VC1_SCAN_ARBITRARY = 3 // Use when bConfigHostInverseScan = 1
- } VC1_PIC_SCAN_METHOD;
-
- typedef enum { // Values for bPicDeblockConfined when bConfigBitstreamRaw = 1
- VC1_EXTENDED_DMV = 0x0001,
- VC1_PSF = 0x0002,
- VC1_REFPICFLAG = 0x0004,
- VC1_FINTERPFLAG = 0x0008,
- VC1_TFCNTRFLAG = 0x0010,
- VC1_INTERLACE = 0x0020,
- VC1_PULLDOWN = 0x0040,
- VC1_POSTPROCFLAG = 0x0080
- } VC1_DEBLOCK_CONFINED;
-
- typedef enum { // Values for bPicSpatialResid8
- VC1_VSTRANSFORM = 0x0001,
- VC1_DQUANT = 0x0002,
- VC1_EXTENDED_MV = 0x0004,
- VC1_FASTUVMC = 0x0008,
- VC1_LOOPFILTER = 0x0010,
- VC1_REDIST_FLAG = 0x0020,
- VC1_PANSCAN_FLAG = 0x0040
- } VC1_PIC_SPATIAL_RESID8;
-
-protected:
-
-private:
- DXVA_PictureParameters m_PictureParams;
- DXVA_SliceInfo m_SliceInfo;
- WORD m_wRefPictureIndex[2];
-
- int m_nDelayedSurfaceIndex;
- REFERENCE_TIME m_rtStartDelayed;
- REFERENCE_TIME m_rtStopDelayed;
-
- BOOL m_bFrame_repeat_pict;
-
- void Init();
- HRESULT DisplayStatus();
- BYTE* FindNextStartCode(BYTE* pBuffer, UINT nSize, UINT& nPacketSize);
-
-};
diff --git a/src/filters/transform/MPCVideoDec/FfmpegContext.cpp b/src/filters/transform/MPCVideoDec/FfmpegContext.cpp
deleted file mode 100644
index 06a9ea3fe..000000000
--- a/src/filters/transform/MPCVideoDec/FfmpegContext.cpp
+++ /dev/null
@@ -1,939 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <Windows.h>
-#include <WinNT.h>
-#include <vfwmsgs.h>
-#include <sys/timeb.h>
-#if defined(STANDALONE_FILTER) && defined(_WIN64)
-#include <time.h> // for the _time64 workaround
-#endif
-
-#include "FfmpegContext.h"
-#include "../../../DSUtil/SysVersion.h"
-
-#define HAVE_AV_CONFIG_H
-
-extern "C" {
-#pragma warning(push)
-#pragma warning(disable: 4244)
-#include "ffmpeg/libavcodec/avcodec.h"
- // This is kind of a hack but it avoids using a C++ keyword as a struct member name
-#define class classFFMPEG
-#include "ffmpeg/libavcodec/mpegvideo.h"
-#undef class
-
-#define new newC // hack since "h264.h" is using new as a variable
-#include "ffmpeg/libavcodec/h264.h"
-#undef new
-#include "ffmpeg/libavcodec/vc1.h"
-#include "ffmpeg/libavcodec/mpeg12.h"
-#pragma warning(pop)
-
- int av_h264_decode_frame(struct AVCodecContext* avctx, int* nOutPOC, int64_t* rtStartTime, uint8_t* buf, int buf_size);
- int av_vc1_decode_frame(AVCodecContext* avctx, uint8_t* buf, int buf_size, int* nFrameSize);
- void av_init_packet(AVPacket* pkt);
-
- // Hack to use MinGW64 from 2.x branch
- void __mingw_raise_matherr(int typ, const char* name, double a1, double a2, double rslt) {}
-}
-
-#if defined(STANDALONE_FILTER)
-void* __imp_toupper = toupper;
-#if defined(_WIN64)
-void* __imp_time64 = _time64;
-#endif
-#endif
-
-#define CHECK_AVC_L52_SIZE(w, h) ((w) <= 4096 && (h) <= 4096 && (w) * (h) <= 36864 * 16 * 16)
-
-const byte ZZ_SCAN[16] = {
- 0, 1, 4, 8,
- 5, 2, 3, 6,
- 9, 12, 13, 10,
- 7, 11, 14, 15
-};
-
-const byte ZZ_SCAN8[64] = {
- 0, 1, 8, 16, 9, 2, 3, 10,
- 17, 24, 32, 25, 18, 11, 4, 5,
- 12, 19, 26, 33, 40, 48, 41, 34,
- 27, 20, 13, 6, 7, 14, 21, 28,
- 35, 42, 49, 56, 57, 50, 43, 36,
- 29, 22, 15, 23, 30, 37, 44, 51,
- 58, 59, 52, 45, 38, 31, 39, 46,
- 53, 60, 61, 54, 47, 55, 62, 63
-};
-
-static const WORD PCID_NVIDIA_VP5[] = {
- // http://us.download.nvidia.com/XFree86/Linux-x86_64/313.26/README/supportedchips.html
- // Nvidia VDPAU Feature Set D
- 0x0FC6, // GeForce GTX 650
- 0x0FD1, // GeForce GT 650M
- 0x0FD2, // GeForce GT 640M
- 0x0FD4, // GeForce GTX 660M
- 0x0FD5, // GeForce GT 650M
- 0x0FD8, // GeForce GT 640M
- 0x0FD9, // GeForce GT 645M
- 0x0FE0, // GeForce GTX 660M
- 0x0FE1, // GeForce GT 730M
- 0x0FF2, // GRID K1
- 0x0FF9, // Quadro K2000D
- 0x0FFA, // Quadro K600
- 0x0FFB, // Quadro K2000M
- 0x0FFC, // Quadro K1000M
- 0x0FFD, // NVS 510
- 0x0FFE, // Quadro K2000
- 0x0FFF, // Quadro 410
- 0x1005, // GeForce GTX TITAN
- 0x1021, // Tesla K20Xm
- 0x1022, // Tesla K20c
- 0x1026, // Tesla K20s
- 0x1028, // Tesla K20m
- 0x1040, // GeForce GT 520 (not officially supported or typo) (4k tested)
- 0x1042, // GeForce 510
- 0x1048, // GeForce 605
- 0x104A, // GeForce GT 610 (fully tested)
- 0x104B, // GeForce GT 625 (OEM)
- 0x1051, // GeForce GT 520MX
- 0x1054, // GeForce 410M
- 0x1055, // GeForce 410M
- 0x1056, // NVS 4200M
- 0x1057, // NVS 4200M
- 0x105B, // GeForce 705M
- 0x107D, // NVS 310
- 0x1180, // GeForce GTX 680
- 0x1183, // GeForce GTX 660 Ti (fully tested)
- 0x1185, // GeForce GTX 660
- 0x1188, // GeForce GTX 690
- 0x1189, // GeForce GTX 670
- 0x118F, // Tesla K10
- 0x11A0, // GeForce GTX 680M
- 0x11A1, // GeForce GTX 670MX
- 0x11A2, // GeForce GTX 675MX
- 0x11A3, // GeForce GTX 680MX
- 0x11A7, // GeForce GTX 675MX
- 0x11BA, // Quadro K5000
- 0x11BC, // Quadro K5000M
- 0x11BD, // Quadro K4000M
- 0x11BE, // Quadro K3000M
- 0x11BF, // VGX K2
- 0x11C0, // GeForce GTX 660
- 0x11C3, // GeForce GTX 650 Ti
- 0x11C6, // GeForce GTX 650 Ti
- 0x11FA, // Quadro K4000
-};
-
-bool CheckPCID(WORD pcid, const WORD* pPCIDs, size_t len)
-{
- for (size_t i = 0; i < len; i++) {
- if (pcid == pPCIDs[i]) {
- return true;
- }
- }
-
- return false;
-}
-
-inline MpegEncContext* GetMpegEncContext(struct AVCodecContext* pAVCtx)
-{
- Mpeg1Context* s1;
- MpegEncContext* s = nullptr;
-
- switch (pAVCtx->codec_id) {
- case AV_CODEC_ID_VC1:
- case AV_CODEC_ID_H264:
- s = (MpegEncContext*)pAVCtx->priv_data;
- break;
- case AV_CODEC_ID_MPEG2VIDEO:
- s1 = (Mpeg1Context*)pAVCtx->priv_data;
- s = (MpegEncContext*)&s1->mpeg_enc_ctx;
- break;
- }
- return s;
-}
-
-int FFH264DecodeBuffer(struct AVCodecContext* pAVCtx,
- BYTE* pBuffer,
- UINT nSize,
- int* pFramePOC,
- int* pOutPOC,
- REFERENCE_TIME* pOutrtStart)
-{
- int result = -1;
- if (pBuffer != nullptr) {
- H264Context* h = (H264Context*) pAVCtx->priv_data;
- result = av_h264_decode_frame(pAVCtx, pOutPOC, pOutrtStart, pBuffer, nSize);
-
- if (result != -1 && h->s.current_picture_ptr != nullptr && pFramePOC) {
- *pFramePOC = h->s.current_picture_ptr->poc;
- }
- }
- return result;
-}
-
-// returns TRUE if version is equal to or higher than A.B.C.D, returns FALSE otherwise
-BOOL DriverVersionCheck(LARGE_INTEGER VideoDriverVersion, int A, int B, int C, int D)
-{
- if (HIWORD(VideoDriverVersion.HighPart) > A) {
- return TRUE;
- } else if (HIWORD(VideoDriverVersion.HighPart) == A) {
- if (LOWORD(VideoDriverVersion.HighPart) > B) {
- return TRUE;
- } else if (LOWORD(VideoDriverVersion.HighPart) == B) {
- if (HIWORD(VideoDriverVersion.LowPart) > C) {
- return TRUE;
- } else if (HIWORD(VideoDriverVersion.LowPart) == C) {
- if (LOWORD(VideoDriverVersion.LowPart) >= D) {
- return TRUE;
- }
- }
- }
- }
- return FALSE;
-}
-
-int FFH264CheckCompatibility(int nWidth,
- int nHeight,
- struct AVCodecContext* pAVCtx,
- BYTE* pBuffer,
- UINT nSize,
- DWORD nPCIVendor,
- DWORD nPCIDevice,
- LARGE_INTEGER VideoDriverVersion)
-{
- H264Context* pContext = (H264Context*) pAVCtx->priv_data;
- SPS* cur_sps;
- PPS* cur_pps;
-
- int video_is_level51 = 0;
- int no_level51_support = 1;
- int too_many_ref_frames = 0;
- int profile_higher_than_high = 0;
- int max_ref_frames_dpb41 = min(11, 8388608 / (nWidth * nHeight));
-
- if (pBuffer != nullptr) {
- av_h264_decode_frame(pAVCtx, nullptr, nullptr, pBuffer, nSize);
- }
-
- cur_sps = pContext->sps_buffers[0];
- cur_pps = pContext->pps_buffers[0];
-
- if (cur_sps != nullptr) {
- int max_ref_frames = 0;
-
- if (cur_sps->bit_depth_luma > 8 || cur_sps->chroma_format_idc > 1) {
- return DXVA_HIGH_BIT;
- }
-
- video_is_level51 = cur_sps->level_idc >= 51 ? 1 : 0;
- profile_higher_than_high = (cur_sps->profile_idc > 100);
- max_ref_frames = max_ref_frames_dpb41; // default value is calculate
-
- if (nPCIVendor == PCIV_nVidia) {
- // nVidia cards support level 5.1 since drivers v6.14.11.7800 for XP and drivers v7.15.11.7800 for Vista/7
- if (SysVersion::IsVistaOrLater()) {
- if (DriverVersionCheck(VideoDriverVersion, 7, 15, 11, 7800)) {
- no_level51_support = 0;
-
- // max ref frames is 16 for HD and 11 otherwise
- if (nWidth >= 1280) {
- max_ref_frames = 16;
- } else {
- max_ref_frames = 11;
- }
- }
- } else {
- if (DriverVersionCheck(VideoDriverVersion, 6, 14, 11, 7800)) {
- no_level51_support = 0;
-
- // max ref frames is 14
- max_ref_frames = 14;
- }
- }
- } else if (nPCIVendor == PCIV_S3_Graphics) {
- no_level51_support = 0;
- } else if (nPCIVendor == PCIV_ATI) {
- // HD4xxx, HD5xxx, and HD6xxx AMD/ATI cards support level 5.1 since drivers v8.14.1.6105 (Catalyst 10.4)
- if (nPCIDevice > 0x6700) {
- if (DriverVersionCheck(VideoDriverVersion, 8, 14, 1, 6105)) {
- no_level51_support = 0;
- max_ref_frames = 16;
- }
- }
- }
-
- // Check maximum allowed number reference frames
- if (cur_sps->ref_frame_count > max_ref_frames) {
- too_many_ref_frames = 1;
- }
- }
-
- return (video_is_level51 * no_level51_support * DXVA_UNSUPPORTED_LEVEL) +
- (too_many_ref_frames * DXVA_TOO_MANY_REF_FRAMES) +
- (profile_higher_than_high * DXVA_PROFILE_HIGHER_THAN_HIGH);
-}
-
-void CopyScalingMatrix(DXVA_Qmatrix_H264* pDest, PPS* pps, DWORD nPCIVendor)
-{
- int i, j;
- ZeroMemory(pDest, sizeof(DXVA_Qmatrix_H264));
- if (nPCIVendor == PCIV_ATI) {
- for (i = 0; i < 6; i++) {
- for (j = 0; j < 16; j++) {
- pDest->bScalingLists4x4[i][j] = pps->scaling_matrix4[i][j];
- }
- }
- for (i = 0; i < 64; i++) {
- pDest->bScalingLists8x8[0][i] = pps->scaling_matrix8[0][i];
- pDest->bScalingLists8x8[1][i] = pps->scaling_matrix8[3][i];
- }
- } else {
- for (i = 0; i < 6; i++) {
- for (j = 0; j < 16; j++) {
- pDest->bScalingLists4x4[i][j] = pps->scaling_matrix4[i][ZZ_SCAN[j]];
- }
- }
- for (i = 0; i < 64; i++) {
- pDest->bScalingLists8x8[0][i] = pps->scaling_matrix8[0][ZZ_SCAN8[i]];
- pDest->bScalingLists8x8[1][i] = pps->scaling_matrix8[3][ZZ_SCAN8[i]];
- }
- }
-}
-
-unsigned short FFH264FindRefFrameIndex(unsigned short num_frame, DXVA_PicParams_H264* pDXVAPicParams)
-{
- int i;
- for (i = 0; i < pDXVAPicParams->num_ref_frames; i++) {
- if (pDXVAPicParams->FrameNumList[i] == num_frame) {
- return pDXVAPicParams->RefFrameList[i].Index7Bits;
- }
- }
-
- return 127;
-}
-
-HRESULT FFH264BuildPicParams(DXVA_PicParams_H264* pDXVAPicParams,
- DXVA_Qmatrix_H264* pDXVAScalingMatrix,
- int* nFieldType,
- int* nSliceType,
- struct AVCodecContext* pAVCtx,
- DWORD nPCIVendor)
-{
- H264Context* h = (H264Context*) pAVCtx->priv_data;
- SPS* cur_sps;
- PPS* cur_pps;
- MpegEncContext* const s = &h->s;
- int field_pic_flag;
- HRESULT hr = E_FAIL;
- const Picture* current_picture = s->current_picture_ptr;
-
- field_pic_flag = (h->s.picture_structure != PICT_FRAME);
-
- cur_sps = &h->sps;
- cur_pps = &h->pps;
-
- if (cur_sps && cur_pps) {
- *nFieldType = h->s.picture_structure;
- if (h->sps.pic_struct_present_flag) {
- switch (h->sei_pic_struct) {
- case SEI_PIC_STRUCT_TOP_FIELD:
- case SEI_PIC_STRUCT_TOP_BOTTOM:
- case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
- *nFieldType = PICT_TOP_FIELD;
- break;
- case SEI_PIC_STRUCT_BOTTOM_FIELD:
- case SEI_PIC_STRUCT_BOTTOM_TOP:
- case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:
- *nFieldType = PICT_BOTTOM_FIELD;
- break;
- case SEI_PIC_STRUCT_FRAME_DOUBLING:
- case SEI_PIC_STRUCT_FRAME_TRIPLING:
- case SEI_PIC_STRUCT_FRAME:
- *nFieldType = PICT_FRAME;
- break;
- }
- }
-
- *nSliceType = h->slice_type;
-
- if (cur_sps->mb_width == 0 || cur_sps->mb_height == 0) {
- return VFW_E_INVALID_FILE_FORMAT;
- }
-
- pDXVAPicParams->wFrameWidthInMbsMinus1 = cur_sps->mb_width - 1; // pic_width_in_mbs_minus1;
- pDXVAPicParams->wFrameHeightInMbsMinus1 = cur_sps->mb_height * (2 - cur_sps->frame_mbs_only_flag) - 1; // pic_height_in_map_units_minus1;
- pDXVAPicParams->num_ref_frames = cur_sps->ref_frame_count; // num_ref_frames;
- pDXVAPicParams->field_pic_flag = field_pic_flag;
- pDXVAPicParams->MbaffFrameFlag = (h->sps.mb_aff && (field_pic_flag == 0));
- pDXVAPicParams->residual_colour_transform_flag = cur_sps->residual_color_transform_flag;
- pDXVAPicParams->sp_for_switch_flag = h->sp_for_switch_flag;
- pDXVAPicParams->chroma_format_idc = cur_sps->chroma_format_idc;
- pDXVAPicParams->RefPicFlag = h->ref_pic_flag;
- pDXVAPicParams->constrained_intra_pred_flag = cur_pps->constrained_intra_pred;
- pDXVAPicParams->weighted_pred_flag = cur_pps->weighted_pred;
- pDXVAPicParams->weighted_bipred_idc = cur_pps->weighted_bipred_idc;
- pDXVAPicParams->frame_mbs_only_flag = cur_sps->frame_mbs_only_flag;
- pDXVAPicParams->transform_8x8_mode_flag = cur_pps->transform_8x8_mode;
- pDXVAPicParams->MinLumaBipredSize8x8Flag = h->sps.level_idc >= 31;
- pDXVAPicParams->IntraPicFlag = (h->slice_type == AV_PICTURE_TYPE_I || h->slice_type == AV_PICTURE_TYPE_SI);
-
- pDXVAPicParams->bit_depth_luma_minus8 = cur_sps->bit_depth_luma - 8; // bit_depth_luma_minus8
- pDXVAPicParams->bit_depth_chroma_minus8 = cur_sps->bit_depth_chroma - 8; // bit_depth_chroma_minus8
-
- //pDXVAPicParams->StatusReportFeedbackNumber = SET IN DecodeFrame;
- //pDXVAPicParams->CurrFieldOrderCnt = SET IN UpdateRefFramesList;
- //pDXVAPicParams->FieldOrderCntList = SET IN UpdateRefFramesList;
- //pDXVAPicParams->FrameNumList = SET IN UpdateRefFramesList;
- //pDXVAPicParams->UsedForReferenceFlags = SET IN UpdateRefFramesList;
- //pDXVAPicParams->NonExistingFrameFlags
-
- pDXVAPicParams->frame_num = h->frame_num;
-
- pDXVAPicParams->log2_max_frame_num_minus4 = cur_sps->log2_max_frame_num - 4; // log2_max_frame_num_minus4;
- pDXVAPicParams->pic_order_cnt_type = cur_sps->poc_type; // pic_order_cnt_type;
- if (cur_sps->poc_type == 0) {
- pDXVAPicParams->log2_max_pic_order_cnt_lsb_minus4 = cur_sps->log2_max_poc_lsb - 4; // log2_max_pic_order_cnt_lsb_minus4;
- } else if (cur_sps->poc_type == 1) {
- pDXVAPicParams->delta_pic_order_always_zero_flag = cur_sps->delta_pic_order_always_zero_flag;
- }
- pDXVAPicParams->direct_8x8_inference_flag = cur_sps->direct_8x8_inference_flag;
- pDXVAPicParams->entropy_coding_mode_flag = cur_pps->cabac; // entropy_coding_mode_flag;
- pDXVAPicParams->pic_order_present_flag = cur_pps->pic_order_present; // pic_order_present_flag;
- pDXVAPicParams->num_slice_groups_minus1 = cur_pps->slice_group_count - 1; // num_slice_groups_minus1;
- pDXVAPicParams->slice_group_map_type = cur_pps->mb_slice_group_map_type; // slice_group_map_type;
- pDXVAPicParams->deblocking_filter_control_present_flag = cur_pps->deblocking_filter_parameters_present; // deblocking_filter_control_present_flag;
- pDXVAPicParams->redundant_pic_cnt_present_flag = cur_pps->redundant_pic_cnt_present; // redundant_pic_cnt_present_flag;
-
- pDXVAPicParams->chroma_qp_index_offset = cur_pps->chroma_qp_index_offset[0];
- pDXVAPicParams->second_chroma_qp_index_offset = cur_pps->chroma_qp_index_offset[1];
- pDXVAPicParams->num_ref_idx_l0_active_minus1 = cur_pps->ref_count[0] - 1; // num_ref_idx_l0_active_minus1;
- pDXVAPicParams->num_ref_idx_l1_active_minus1 = cur_pps->ref_count[1] - 1; // num_ref_idx_l1_active_minus1;
- pDXVAPicParams->pic_init_qp_minus26 = cur_pps->init_qp - 26;
- pDXVAPicParams->pic_init_qs_minus26 = cur_pps->init_qs - 26;
-
- pDXVAPicParams->CurrPic.AssociatedFlag = field_pic_flag && (h->s.picture_structure == PICT_BOTTOM_FIELD);
- pDXVAPicParams->CurrFieldOrderCnt[0] = 0;
- if ((h->s.picture_structure & PICT_TOP_FIELD) && current_picture->field_poc[0] != INT_MAX) {
- pDXVAPicParams->CurrFieldOrderCnt[0] = current_picture->field_poc[0];
- }
- pDXVAPicParams->CurrFieldOrderCnt[1] = 0;
- if ((h->s.picture_structure & PICT_BOTTOM_FIELD) && current_picture->field_poc[1] != INT_MAX) {
- pDXVAPicParams->CurrFieldOrderCnt[1] = current_picture->field_poc[1];
- }
-
- CopyScalingMatrix(pDXVAScalingMatrix, cur_pps, nPCIVendor);
- hr = S_OK;
- }
-
- return hr;
-}
-
-void FFH264SetCurrentPicture(int nIndex, DXVA_PicParams_H264* pDXVAPicParams, struct AVCodecContext* pAVCtx)
-{
- H264Context* h = (H264Context*) pAVCtx->priv_data;
- pDXVAPicParams->CurrPic.Index7Bits = nIndex;
-
- if (h->s.current_picture_ptr) {
- h->s.current_picture_ptr->f.opaque = (void*)nIndex;
- }
-}
-
-void FFH264UpdateRefFramesList(DXVA_PicParams_H264* pDXVAPicParams, struct AVCodecContext* pAVCtx)
-{
- H264Context* h = (H264Context*) pAVCtx->priv_data;
- UINT nUsedForReferenceFlags = 0;
- int i, j;
- Picture* pic;
- UCHAR AssociatedFlag;
-
- for (i = 0, j = 0; i < 16; i++) {
- if (i < h->short_ref_count) {
- // Short list reference frames
- pic = h->short_ref[h->short_ref_count - i - 1];
- AssociatedFlag = pic->long_ref != 0;
- } else {
- // Long list reference frames
- pic = nullptr;
- while (!pic && j < h->short_ref_count + 16) {
- pic = h->long_ref[j++ - h->short_ref_count];
- }
- AssociatedFlag = 1;
- }
-
- if (pic != nullptr) {
- pDXVAPicParams->FrameNumList[i] = pic->long_ref ? pic->pic_id : pic->frame_num;
- pDXVAPicParams->FieldOrderCntList[i][0] = 0;
- pDXVAPicParams->FieldOrderCntList[i][1] = 0;
-
- if (pic->field_poc[0] != INT_MAX) {
- pDXVAPicParams->FieldOrderCntList[i][0] = pic->field_poc [0];
- nUsedForReferenceFlags |= 1 << (i * 2);
- }
-
- if (pic->field_poc[1] != INT_MAX) {
- pDXVAPicParams->FieldOrderCntList[i][1] = pic->field_poc [1];
- nUsedForReferenceFlags |= 2 << (i * 2);
- }
-
- pDXVAPicParams->RefFrameList[i].AssociatedFlag = AssociatedFlag;
- pDXVAPicParams->RefFrameList[i].Index7Bits = (UCHAR)pic->f.opaque;
- } else {
- pDXVAPicParams->FrameNumList[i] = 0;
- pDXVAPicParams->FieldOrderCntList[i][0] = 0;
- pDXVAPicParams->FieldOrderCntList[i][1] = 0;
- pDXVAPicParams->RefFrameList[i].AssociatedFlag = 1;
- pDXVAPicParams->RefFrameList[i].Index7Bits = 127;
- }
- }
-
- pDXVAPicParams->UsedForReferenceFlags = nUsedForReferenceFlags;
-}
-
-BOOL FFH264IsRefFrameInUse(int nFrameNum, struct AVCodecContext* pAVCtx)
-{
- H264Context* h = (H264Context*) pAVCtx->priv_data;
- int i;
-
- for (i = 0; i < h->short_ref_count; i++) {
- if ((int)h->short_ref[i]->f.opaque == nFrameNum) {
- return TRUE;
- }
- }
-
- for (i = 0; i < h->long_ref_count; i++) {
- if ((int)h->long_ref[i]->f.opaque == nFrameNum) {
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-void FF264UpdateRefFrameSliceLong(DXVA_PicParams_H264* pDXVAPicParams,
- DXVA_Slice_H264_Long* pSlice,
- struct AVCodecContext* pAVCtx)
-{
- H264Context* h = (H264Context*) pAVCtx->priv_data;
- MpegEncContext* const s = &h->s;
- unsigned i, list;
-
- for (list = 0; list < 2; list++) {
- for (i = 0; i < 32; i++) {
- pSlice->RefPicList[list][i].AssociatedFlag = 1;
- pSlice->RefPicList[list][i].Index7Bits = 127;
- pSlice->RefPicList[list][i].bPicEntry = 255;
- }
- }
-
- for (list = 0; list < 2; list++) {
- for (i = 0; i < 32; i++) {
- if (list < h->list_count && i < h->ref_count[list]) {
- const Picture* r = &h->ref_list[list][i];
- pSlice->RefPicList[list][i].Index7Bits = FFH264FindRefFrameIndex(h->ref_list[list][i].frame_num, pDXVAPicParams);
- pSlice->RefPicList[list][i].AssociatedFlag = r->f.reference == PICT_BOTTOM_FIELD;
- }
- }
- }
-}
-
-void FFH264SetDxvaSliceLong(struct AVCodecContext* pAVCtx, void* pSliceLong)
-{
- H264Context* h = (H264Context*) pAVCtx->priv_data;
- h->dxva_slice_long = pSliceLong;
-}
-
-HRESULT FFVC1UpdatePictureParam(DXVA_PictureParameters* pPicParams,
- struct AVCodecContext* pAVCtx,
- int* nFieldType,
- int* nSliceType,
- BYTE* pBuffer,
- UINT nSize,
- UINT* nFrameSize,
- BOOL b_SecondField,
- BOOL* b_repeat_pict)
-{
- VC1Context* vc1 = (VC1Context*) pAVCtx->priv_data;
- int out_nFrameSize = 0;
-
- if (pBuffer && !b_SecondField) {
- av_vc1_decode_frame(pAVCtx, pBuffer, nSize, &out_nFrameSize);
- }
-
- // WARNING : vc1->interlace is not reliable (always set for progressive video on HD-DVD material)
- if (vc1->fcm == 0) {
- if (nFieldType) {
- *nFieldType = PICT_FRAME;
- }
- } else { // fcm : 2 or 3 frame or field interlaced
- if (nFieldType) {
- *nFieldType = (vc1->tff ? PICT_TOP_FIELD : PICT_BOTTOM_FIELD);
- }
- }
-
- if (b_SecondField) {
- vc1->second_field = 1;
- vc1->s.picture_structure = PICT_TOP_FIELD + vc1->tff;
- vc1->s.pict_type = (vc1->fptype & 1) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
- if (vc1->fptype & 4) {
- vc1->s.pict_type = (vc1->fptype & 1) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B;
- }
- }
-
- if (nFrameSize) {
- *nFrameSize = out_nFrameSize;
- }
-
- if (vc1->profile == PROFILE_ADVANCED) {
- /* It is the cropped width/height -1 of the frame */
- pPicParams->wPicWidthInMBminus1 = pAVCtx->width - 1;
- pPicParams->wPicHeightInMBminus1 = pAVCtx->height - 1;
- } else {
- /* It is the coded width/height in macroblock -1 of the frame */
- pPicParams->wPicWidthInMBminus1 = vc1->s.mb_width - 1;
- pPicParams->wPicHeightInMBminus1 = vc1->s.mb_height - 1;
- }
-
- pPicParams->bSecondField = (vc1->interlace && vc1->fcm == ILACE_FIELD && vc1->second_field);
- pPicParams->bPicIntra = vc1->s.pict_type == AV_PICTURE_TYPE_I;
- pPicParams->bPicBackwardPrediction = vc1->s.pict_type == AV_PICTURE_TYPE_B;
-
-
- // Init Init Init Todo
- // iWMV9 - i9IRU - iOHIT - iINSO - iWMVA - 0 - 0 - 0 | Section 3.2.5
- pPicParams->bBidirectionalAveragingMode = (pPicParams->bBidirectionalAveragingMode & 0xE0) | // init in SetExtraData
- ((vc1->lumshift != 0 || vc1->lumscale != 32) ? 0x10 : 0) | // iINSO
- ((vc1->profile == PROFILE_ADVANCED) << 3); // iWMVA
-
- // Section 3.2.20.3
- pPicParams->bPicSpatialResid8 = (vc1->panscanflag << 7) | (vc1->refdist_flag << 6) |
- (vc1->s.loop_filter << 5) | (vc1->fastuvmc << 4) |
- (vc1->extended_mv << 3) | (vc1->dquant << 1) |
- (vc1->vstransform);
-
- // Section 3.2.20.4
- pPicParams->bPicOverflowBlocks = (vc1->quantizer_mode << 6) | (vc1->multires << 5) |
- (vc1->s.resync_marker << 4) | (vc1->rangered << 3) |
- (vc1->s.max_b_frames);
-
- // Section 3.2.20.2
- pPicParams->bPicDeblockConfined = (vc1->postprocflag << 7) | (vc1->broadcast << 6) |
- (vc1->interlace << 5) | (vc1->tfcntrflag << 4) |
- (vc1->finterpflag << 3) | // (refpic << 2) set in DecodeFrame !
- (vc1->psf << 1) | vc1->extended_dmv;
-
-
- pPicParams->bPicStructure = 0;
- if (vc1->s.picture_structure & PICT_TOP_FIELD) {
- pPicParams->bPicStructure |= 0x01;
- }
- if (vc1->s.picture_structure & PICT_BOTTOM_FIELD) {
- pPicParams->bPicStructure |= 0x02;
- }
-
- pPicParams->bMVprecisionAndChromaRelation = ((vc1->mv_mode == MV_PMODE_1MV_HPEL_BILIN) << 3) |
- (1 << 2) |
- (0 << 1) |
- (!vc1->s.quarter_sample);
-
- // Cf page 17 : 2 for interlaced, 0 for progressive
- pPicParams->bPicExtrapolation = (!vc1->interlace || vc1->fcm == PROGRESSIVE) ? 1 : 2;
-
- if (vc1->s.picture_structure == PICT_FRAME) {
- pPicParams->wBitstreamFcodes = vc1->lumscale;
- pPicParams->wBitstreamPCEelements = vc1->lumshift;
- } else {
- /* Syntax: (top_field_param << 8) | bottom_field_param */
- pPicParams->wBitstreamFcodes = (vc1->lumscale << 8) | vc1->lumscale;
- pPicParams->wBitstreamPCEelements = (vc1->lumshift << 8) | vc1->lumshift;
- }
-
- if (vc1->profile == PROFILE_ADVANCED) {
- pPicParams->bPicOBMC = (vc1->range_mapy_flag << 7) |
- (vc1->range_mapy << 4) |
- (vc1->range_mapuv_flag << 3) |
- (vc1->range_mapuv);
- }
-
- // Section 3.2.16
- if (nSliceType) {
- *nSliceType = vc1->s.pict_type;
- }
-
- // Cf section 7.1.1.25 in VC1 specification, section 3.2.14.3 in DXVA spec
- pPicParams->bRcontrol = vc1->rnd;
-
- pPicParams->bPicDeblocked = ((vc1->profile == PROFILE_ADVANCED && vc1->overlap == 1 &&
- pPicParams->bPicBackwardPrediction == 0) << 6) |
- ((vc1->profile != PROFILE_ADVANCED && vc1->rangeredfrm) << 5) |
- (vc1->s.loop_filter << 1);
-
- if (vc1->profile == PROFILE_ADVANCED && (vc1->rff || vc1->rptfrm)) {
- *b_repeat_pict = TRUE;
- }
-
- return S_OK;
-}
-
-int MPEG2CheckCompatibility(struct AVCodecContext* pAVCtx, struct AVFrame* pFrame)
-{
- int got_picture = 0;
- Mpeg1Context* s1 = (Mpeg1Context*)pAVCtx->priv_data;
- MpegEncContext* s = (MpegEncContext*)&s1->mpeg_enc_ctx;
- AVPacket avpkt;
-
- av_init_packet(&avpkt);
- avpkt.data = (BYTE*)pAVCtx->extradata;
- avpkt.size = pAVCtx->extradata_size;
- avpkt.flags = AV_PKT_FLAG_KEY;
-
- avcodec_decode_video2(pAVCtx, pFrame, &got_picture, &avpkt);
-
- return (s->chroma_format < 2);
-}
-
-HRESULT FFMpeg2DecodeFrame(DXVA_PictureParameters* pPicParams,
- DXVA_QmatrixData* pQMatrixData,
- DXVA_SliceInfo* pSliceInfo,
- int* nSliceCount,
- struct AVCodecContext* pAVCtx,
- struct AVFrame* pFrame,
- int* nNextCodecIndex,
- int* nFieldType,
- int* nSliceType,
- BYTE* pBuffer,
- UINT nSize)
-{
- int i;
- int got_picture = 0;
- Mpeg1Context* s1 = (Mpeg1Context*)pAVCtx->priv_data;
- MpegEncContext* s = (MpegEncContext*)&s1->mpeg_enc_ctx;
- int is_field = 0;
- unsigned mb_count = 0;
- AVPacket avpkt;
-
- if (pBuffer) {
- s1->pSliceInfo = pSliceInfo;
-
- av_init_packet(&avpkt);
- avpkt.data = pBuffer;
- avpkt.size = nSize;
- avpkt.flags = AV_PKT_FLAG_KEY;
- avcodec_decode_video2(pAVCtx, pFrame, &got_picture, &avpkt);
-
- *nSliceCount = s1->slice_count;
- *nFieldType = s->progressive_frame ? PICT_FRAME : s->current_picture.f.top_field_first ? PICT_TOP_FIELD : PICT_BOTTOM_FIELD;
- *nSliceType = s->pict_type;
- }
-
- // pPicParams->wDecodedPictureIndex; set in DecodeFrame
- // pPicParams->wDeblockedPictureIndex; 0 for Mpeg2
- // pPicParams->wForwardRefPictureIndex; set in DecodeFrame
- // pPicParams->wBackwardRefPictureIndex; set in DecodeFrame
-
- is_field = s->picture_structure != PICT_FRAME;
-
- pPicParams->wPicWidthInMBminus1 = s->mb_width - 1;
- pPicParams->wPicHeightInMBminus1 = (s->mb_height >> is_field) - 1;
-
- pPicParams->bMacroblockWidthMinus1 = 15; // This is equal to "15" for MPEG-1, MPEG-2, H.263, and MPEG-4
- pPicParams->bMacroblockHeightMinus1 = 15; // This is equal to "15" for MPEG-1, MPEG-2, H.261, H.263, and MPEG-4
-
- pPicParams->bBlockWidthMinus1 = 7; // This is equal to "7" for MPEG-1, MPEG-2, H.261, H.263, and MPEG-4
- pPicParams->bBlockHeightMinus1 = 7; // This is equal to "7" for MPEG-1, MPEG-2, H.261, H.263, and MPEG-4
-
- pPicParams->bBPPminus1 = 7; // It is equal to "7" for MPEG-1, MPEG-2, H.261, and H.263
-
- pPicParams->bPicStructure = s->picture_structure;
- pPicParams->bSecondField = is_field && !s->first_field;
- pPicParams->bPicIntra = (s->current_picture.f.pict_type == AV_PICTURE_TYPE_I);
- pPicParams->bPicBackwardPrediction = (s->current_picture.f.pict_type == AV_PICTURE_TYPE_B);
-
- pPicParams->bBidirectionalAveragingMode = 0; // The value "0" indicates MPEG-1 and MPEG-2 rounded averaging (//2),
- //pPicParams->bMVprecisionAndChromaRelation = 0; // Indicates that luminance motion vectors have half-sample precision and that chrominance motion vectors are derived from luminance motion vectors according to the rules in MPEG-2
- pPicParams->bChromaFormat = 0x01; // For MPEG-1, MPEG-2 "Main Profile," H.261 and H.263 bitstreams, this value shall always be set to "01", indicating "4:2:0" format
-
- //pPicParams->bPicScanFixed = 1; // set in UpdatePicParams
- //pPicParams->bPicScanMethod = 1; // set in UpdatePicParams
- //pPicParams->bPicReadbackRequests; // ??
-
- //pPicParams->bRcontrol = 0; // It shall be set to "0" for all MPEG-1, and MPEG-2 bitstreams in order to conform with the rounding operator defined by those standards
- //pPicParams->bPicSpatialResid8; // set in UpdatePicParams
- //pPicParams->bPicOverflowBlocks; // set in UpdatePicParams
- //pPicParams->bPicExtrapolation; = 0; // by H.263 Annex D and MPEG-4
-
- //pPicParams->bPicDeblocked; = 0; // MPEG2_A Restricted Profile
- //pPicParams->bPicDeblockConfined; // ??
- //pPicParams->bPic4MVallowed; // See H.263 Annexes F and J
- //pPicParams->bPicOBMC; // H.263 Annex F
- //pPicParams->bPicBinPB; // Annexes G and M of H.263
- //pPicParams->bMV_RPS; // ???
- //pPicParams->bReservedBits; // ??
-
- pPicParams->wBitstreamFcodes = (s->mpeg_f_code[0][0] << 12) | (s->mpeg_f_code[0][1] << 8) |
- (s->mpeg_f_code[1][0] << 4) | (s->mpeg_f_code[1][1]);
-
- pPicParams->wBitstreamPCEelements = (s->intra_dc_precision << 14) | (s->picture_structure << 12) |
- (s->top_field_first << 11) | (s->frame_pred_frame_dct << 10) |
- (s->concealment_motion_vectors << 9) | (s->q_scale_type << 8) |
- (s->intra_vlc_format << 7) | (s->alternate_scan << 6) |
- (s->repeat_first_field << 5) | (s->chroma_420_type << 4) |
- (s->progressive_frame << 3);
-
- pPicParams->bBitstreamConcealmentNeed = 0;
- pPicParams->bBitstreamConcealmentMethod = 0;
-
- pQMatrixData->bNewQmatrix[0] = 1;
- pQMatrixData->bNewQmatrix[1] = 1;
- pQMatrixData->bNewQmatrix[2] = 1;
- pQMatrixData->bNewQmatrix[3] = 1;
- for (i = 0; i < 64; i++) {
- int n = s->dsp.idct_permutation[ZZ_SCAN8[i]];
- pQMatrixData->Qmatrix[0][i] = s->intra_matrix[n];
- pQMatrixData->Qmatrix[1][i] = s->inter_matrix[n];
- pQMatrixData->Qmatrix[2][i] = s->chroma_intra_matrix[n];
- pQMatrixData->Qmatrix[3][i] = s->chroma_inter_matrix[n];
- }
-
- mb_count = s->mb_width * (s->mb_height >> is_field);
- for (i = 0; i < s1->slice_count; i++) {
- DXVA_SliceInfo* slice = &s1->pSliceInfo[i];
-
- if (i < s1->slice_count - 1) {
- slice->wNumberMBsInSlice = slice[1].wNumberMBsInSlice - slice[0].wNumberMBsInSlice;
- } else {
- slice->wNumberMBsInSlice = mb_count - slice[0].wNumberMBsInSlice;
- }
- }
-
- if (got_picture) {
- *nNextCodecIndex = pFrame->coded_picture_number;
- }
-
- return S_OK;
-}
-
-unsigned long FFGetMBNumber(struct AVCodecContext* pAVCtx)
-{
- MpegEncContext* s = GetMpegEncContext(pAVCtx);
-
- return (s != nullptr) ? s->mb_num : 0;
-}
-
-int FFIsSkipped(struct AVCodecContext* pAVCtx)
-{
- VC1Context* vc1 = (VC1Context*) pAVCtx->priv_data;
- return vc1->p_frame_skipped;
-}
-
-int FFGetThreadType(enum AVCodecID nCodecId, int nThreadCount)
-{
- if (!nThreadCount) {
- return 0;
- }
- switch (nCodecId) {
- case AV_CODEC_ID_H264:
- return FF_THREAD_FRAME | FF_THREAD_SLICE;
- break;
- case AV_CODEC_ID_MPEG1VIDEO:
- case AV_CODEC_ID_DVVIDEO:
- case AV_CODEC_ID_FFV1:
- return FF_THREAD_SLICE;
- break;
- case AV_CODEC_ID_VP3:
- case AV_CODEC_ID_VP8:
- case AV_CODEC_ID_THEORA:
- case AV_CODEC_ID_RV30:
- case AV_CODEC_ID_RV40:
- return FF_THREAD_FRAME;
- break;
- default:
- return 0;
- }
-}
-
-void FFSetThreadNumber(struct AVCodecContext* pAVCtx, enum AVCodecID nCodecId, int nThreadCount)
-{
- pAVCtx->thread_count = nThreadCount;
- pAVCtx->thread_type = FFGetThreadType(nCodecId, nThreadCount);
-}
-
-BOOL FFSoftwareCheckCompatibility(struct AVCodecContext* pAVCtx)
-{
- if (pAVCtx->codec_id == AV_CODEC_ID_VC1) {
- VC1Context* vc1 = (VC1Context*) pAVCtx->priv_data;
- return !vc1->interlace;
- } else {
- return TRUE;
- }
-}
-
-int FFGetCodedPicture(struct AVCodecContext* pAVCtx)
-{
- MpegEncContext* s = GetMpegEncContext(pAVCtx);
-
- return (s != nullptr) ? s->current_picture.f.coded_picture_number : 0;
-}
-
-BOOL FFGetAlternateScan(struct AVCodecContext* pAVCtx)
-{
- MpegEncContext* s = GetMpegEncContext(pAVCtx);
-
- return (s != nullptr) ? s->alternate_scan : 0;
-}
-
-BOOL DXVACheckFramesize(int width, int height, DWORD nPCIVendor, DWORD nPCIDevice)
-{
- width = (width + 15) & ~15; // (width + 15) / 16 * 16;
- height = (height + 15) & ~15; // (height + 15) / 16 * 16;
-
- if (nPCIVendor == PCIV_nVidia) {
- if (CheckPCID((WORD)nPCIDevice, PCID_NVIDIA_VP5, _countof(PCID_NVIDIA_VP5)) && width <= 4096 && height <= 4096 && width * height <= 4080 * 4080) {
- // tested H.264 on VP5 (GT 610, GTX 660 Ti)
- // 4080x4080 = 65025 macroblocks
- return TRUE;
- } else if (width <= 2032 && height <= 2032 && width * height <= 8190 * 16 * 16) {
- // tested H.264, VC-1 and MPEG-2 on VP4 (feature set C) (G210M, GT220)
- return TRUE;
- }
- } else if (nPCIVendor == PCIV_ATI) {
- if (width <= 2048 && height <= 2304 && width * height <= 2048 * 2048) {
- // tested H.264 on UVD 2.2 (HD5670, HD5770, HD5850)
- // it may also work if width = 2064, but unstable
- return TRUE;
- }
- } else if (nPCIVendor == PCIV_Intel && nPCIDevice == PCID_Intel_HD4000) {
- //if (width <= 4096 && height <= 4096 && width * height <= 56672 * 16 * 16) {
- if (width <= 4096 && height <= 4096) { // driver v.9.17.10.2867
- // complete test was performed
- return TRUE;
- }
- } else if (nPCIVendor == PCIV_Intel && nPCIDevice == PCID_Intel_HD2500) {
- if (CHECK_AVC_L52_SIZE(width, height)) {
- // tested some media files with AVC Livel 5.1
- // complete test was NOT performed
- return TRUE;
- }
- } else if (width <= 1920 && height <= 1088) {
- return TRUE;
- }
-
- return FALSE;
-}
diff --git a/src/filters/transform/MPCVideoDec/FfmpegContext.h b/src/filters/transform/MPCVideoDec/FfmpegContext.h
deleted file mode 100644
index d6f5b8ed8..000000000
--- a/src/filters/transform/MPCVideoDec/FfmpegContext.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * (C) 2007-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <dxva.h>
-
-struct AVCodecContext;
-struct AVFrame;
-
-enum PCI_Vendors {
- PCIV_ATI = 0x1002,
- PCIV_nVidia = 0x10DE,
- PCIV_Intel = 0x8086,
- PCIV_S3_Graphics = 0x5333
-};
-
-#define PCID_Intel_HD2500 0x0152
-#define PCID_Intel_HD4000 0x0162
-
-// Bitmasks for DXVA compatibility check
-#define DXVA_UNSUPPORTED_LEVEL 1
-#define DXVA_TOO_MANY_REF_FRAMES 2
-#define DXVA_INCOMPATIBLE_SAR 4
-#define DXVA_PROFILE_HIGHER_THAN_HIGH 8
-#define DXVA_HIGH_BIT 16
-
-// === H264 functions
-int FFH264DecodeBuffer(struct AVCodecContext* pAVCtx, BYTE* pBuffer, UINT nSize,
- int* pFramePOC, int* pOutPOC, REFERENCE_TIME* pOutrtStart);
-HRESULT FFH264BuildPicParams(DXVA_PicParams_H264* pDXVAPicParams, DXVA_Qmatrix_H264* pDXVAScalingMatrix,
- int* nFieldType, int* nSliceType, struct AVCodecContext* pAVCtx, DWORD nPCIVendor);
-int FFH264CheckCompatibility(int nWidth, int nHeight, struct AVCodecContext* pAVCtx, BYTE* pBuffer,
- UINT nSize, DWORD nPCIVendor, DWORD nPCIDevice, LARGE_INTEGER VideoDriverVersion);
-void FFH264SetCurrentPicture(int nIndex, DXVA_PicParams_H264* pDXVAPicParams, struct AVCodecContext* pAVCtx);
-void FFH264UpdateRefFramesList(DXVA_PicParams_H264* pDXVAPicParams, struct AVCodecContext* pAVCtx);
-BOOL FFH264IsRefFrameInUse(int nFrameNum, struct AVCodecContext* pAVCtx);
-void FF264UpdateRefFrameSliceLong(DXVA_PicParams_H264* pDXVAPicParams, DXVA_Slice_H264_Long* pSlice,
- struct AVCodecContext* pAVCtx);
-void FFH264SetDxvaSliceLong(struct AVCodecContext* pAVCtx, void* pSliceLong);
-
-// === VC1 functions
-HRESULT FFVC1UpdatePictureParam(DXVA_PictureParameters* pPicParams, struct AVCodecContext* pAVCtx,
- int* nFieldType, int* nSliceType, BYTE* pBuffer, UINT nSize,
- UINT* nFrameSize, BOOL b_SecondField, BOOL* b_repeat_pict);
-int FFIsSkipped(struct AVCodecContext* pAVCtx);
-
-// === Mpeg2 functions
-int MPEG2CheckCompatibility(struct AVCodecContext* pAVCtx, struct AVFrame* pFrame);
-HRESULT FFMpeg2DecodeFrame(DXVA_PictureParameters* pPicParams, DXVA_QmatrixData* m_QMatrixData,
- DXVA_SliceInfo* pSliceInfo, int* nSliceCount, struct AVCodecContext* pAVCtx,
- struct AVFrame* pFrame, int* nNextCodecIndex, int* nFieldType, int* nSliceType,
- BYTE* pBuffer, UINT nSize);
-
-// === Common functions
-unsigned long FFGetMBNumber(struct AVCodecContext* pAVCtx);
-void FFSetThreadNumber(struct AVCodecContext* pAVCtx, enum AVCodecID nCodecId, int nThreadCount);
-BOOL FFSoftwareCheckCompatibility(struct AVCodecContext* pAVCtx);
-int FFGetCodedPicture(struct AVCodecContext* pAVCtx);
-BOOL FFGetAlternateScan(struct AVCodecContext* pAVCtx);
-BOOL DXVACheckFramesize(int width, int height, DWORD nPCIVendor, DWORD nPCIDevice);
diff --git a/src/filters/transform/MPCVideoDec/H264RandomAccess.cpp b/src/filters/transform/MPCVideoDec/H264RandomAccess.cpp
deleted file mode 100644
index 9922c9b41..000000000
--- a/src/filters/transform/MPCVideoDec/H264RandomAccess.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2010-2012 Hendrik Leppkes
- * http://www.1f0.de
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "stdafx.h"
-#include "H264RandomAccess.h"
-
-#pragma warning(push)
-#pragma warning(disable: 4005)
-extern "C" {
-#include "ffmpeg/libavcodec/avcodec.h"
-}
-#pragma warning(pop)
-
-CH264RandomAccess::CH264RandomAccess()
-{
- flush(0);
-}
-
-CH264RandomAccess::~CH264RandomAccess()
-{
-}
-
-void CH264RandomAccess::flush(int threadCount)
-{
- m_RecoveryMode = 1;
- m_RecoveryFrameCount = 0;
- m_ThreadDelay = threadCount;
-}
-
-BOOL CH264RandomAccess::searchRecoveryPoint(AVCodecContext* pAVCtx, BYTE *buf, int buf_size)
-{
- if (m_RecoveryMode == 1) {
- int recoveryPoint = avcodec_h264_search_recovery_point(pAVCtx, buf, buf_size, &m_RecoveryFrameCount);
- switch (recoveryPoint) {
- case 3: // IDRS
- m_RecoveryMode = 0;
- return TRUE;
- case 2: // SEI recovery
- m_RecoveryMode = 2;
- return TRUE;
- case 1: // I Frame
- m_RecoveryMode = 2;
- m_RecoveryFrameCount = 0;
- return TRUE;
- default:
- return FALSE;
- }
- } else {
- return TRUE;
- }
-}
-
-void CH264RandomAccess::judgeFrameUsability(AVFrame *pFrame, int *got_picture_ptr)
-{
- if ((m_ThreadDelay > 1 && --m_ThreadDelay > 0) || m_RecoveryMode == 0 || pFrame->h264_max_frame_num == 0) {
- return;
- }
-
- if (m_RecoveryMode == 1 || m_RecoveryMode == 2) {
- m_RecoveryFrameCount = (m_RecoveryFrameCount + pFrame->h264_frame_num_decoded) % pFrame->h264_max_frame_num;
- m_RecoveryMode = 3;
- }
-
- if (m_RecoveryMode == 3) {
- if (m_RecoveryFrameCount <= pFrame->h264_frame_num_decoded) {
- m_RecoveryPOC = pFrame->h264_poc_decoded;
- m_RecoveryMode = 4;
- }
- }
-
- if (m_RecoveryMode == 4) {
- if (pFrame->h264_poc_outputed >= m_RecoveryPOC) {
- m_RecoveryMode = 0;
- }
- }
-
- if (m_RecoveryMode != 0) {
- *got_picture_ptr = 0;
- }
-}
diff --git a/src/filters/transform/MPCVideoDec/H264RandomAccess.h b/src/filters/transform/MPCVideoDec/H264RandomAccess.h
deleted file mode 100644
index 5f9eced93..000000000
--- a/src/filters/transform/MPCVideoDec/H264RandomAccess.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2010-2012 Hendrik Leppkes
- * http://www.1f0.de
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#pragma once
-
-struct AVCodecContext;
-struct AVFrame;
-
-class CH264RandomAccess
-{
-public:
- CH264RandomAccess();
- ~CH264RandomAccess();
-
- void flush(int threadCount);
- BOOL searchRecoveryPoint(AVCodecContext* pAVCtx, BYTE *buf, int buf_size);
- void judgeFrameUsability(AVFrame *pFrame, int *got_picture_ptr);
-
-private:
- int m_RecoveryMode; // 0: OK; 1: Searching; 2: Found; 3:
- int m_RecoveryFrameCount;
- int m_RecoveryPOC;
- int m_ThreadDelay;
-};
diff --git a/src/filters/transform/MPCVideoDec/MPCFfmpegDec.cpp b/src/filters/transform/MPCVideoDec/MPCFfmpegDec.cpp
deleted file mode 100644
index 4528621d3..000000000
--- a/src/filters/transform/MPCVideoDec/MPCFfmpegDec.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "MPCVideoDecFilter.h"
-#include "../../../DSUtil/DSUtil.h"
-
-#ifdef STANDALONE_FILTER
-
-// Workaround: graphedit crashes when a filter exposes more than 115 input MediaTypes!
-const AMOVIESETUP_PIN sudpPinsVideoDec[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr, CMPCVideoDecFilter::sudPinTypesInCount > 115 ? 115 : CMPCVideoDecFilter::sudPinTypesInCount, CMPCVideoDecFilter::sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, CMPCVideoDecFilter::sudPinTypesOutCount, CMPCVideoDecFilter::sudPinTypesOut}
-};
-
-const AMOVIESETUP_FILTER sudFilters[] = {
- {&__uuidof(CMPCVideoDecFilter), MPCVideoDecName, /*MERIT_DO_NOT_USE*/0x40000001, _countof(sudpPinsVideoDec), sudpPinsVideoDec, CLSID_LegacyAmFilterCategory}
-};
-
-CFactoryTemplate g_Templates[] = {
- {sudFilters[0].strName, &__uuidof(CMPCVideoDecFilter), CreateInstance<CMPCVideoDecFilter>, nullptr, &sudFilters[0]},
- {L"CMPCVideoDecPropertyPage", &__uuidof(CMPCVideoDecSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CMPCVideoDecSettingsWnd>>},
- {L"CMPCVideoDecPropertyPage2", &__uuidof(CMPCVideoDecCodecWnd), CreateInstance<CInternalPropertyPageTempl<CMPCVideoDecCodecWnd>>},
-};
-
-int g_cTemplates = _countof(g_Templates);
-
-STDAPI DllRegisterServer()
-{
- return AMovieDllRegisterServer2(TRUE);
-}
-
-STDAPI DllUnregisterServer()
-{
- return AMovieDllRegisterServer2(FALSE);
-}
-
-#include "../../FilterApp.h"
-
-CFilterApp theApp;
-
-#endif
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDec.def b/src/filters/transform/MPCVideoDec/MPCVideoDec.def
deleted file mode 100644
index 6492e5cd6..000000000
--- a/src/filters/transform/MPCVideoDec/MPCVideoDec.def
+++ /dev/null
@@ -1,5 +0,0 @@
-EXPORTS
- DllCanUnloadNow PRIVATE
- DllGetClassObject PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDec.vcxproj b/src/filters/transform/MPCVideoDec/MPCVideoDec.vcxproj
deleted file mode 100644
index 051e260eb..000000000
--- a/src/filters/transform/MPCVideoDec/MPCVideoDec.vcxproj
+++ /dev/null
@@ -1,313 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug Filter|Win32">
- <Configuration>Debug Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug Filter|x64">
- <Configuration>Debug Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|Win32">
- <Configuration>Release Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|x64">
- <Configuration>Release Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}</ProjectGuid>
- <RootNamespace>MPCVideoDec</RootNamespace>
- <Keyword>MFCProj</Keyword>
- <ProjectName>MPCVideoDec</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <Import Project="..\..\..\platform.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">.ax</TargetExt>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\ffmpeg;$(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>libgcc.a;libmingwex.a;d3d9.lib;Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(SolutionDir)lib;$(DXSDK_DIR)Lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <ModuleDefinitionFile>MPCVideoDec.def</ModuleDefinitionFile>
- <ImageHasSafeExceptionHandlers Condition="'$(PlatformToolsetVersion)'=='110'">false</ImageHasSafeExceptionHandlers>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\ffmpeg;$(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>libgcc.a;libmingwex.a;d3d9.lib;Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(SolutionDir)lib64;$(DXSDK_DIR)Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <ModuleDefinitionFile>MPCVideoDec.def</ModuleDefinitionFile>
- <ImageHasSafeExceptionHandlers Condition="'$(PlatformToolsetVersion)'=='110'">false</ImageHasSafeExceptionHandlers>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\ffmpeg;$(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>libgcc.a;libmingwex.a;d3d9.lib;Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(SolutionDir)lib;$(DXSDK_DIR)Lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <ModuleDefinitionFile>MPCVideoDec.def</ModuleDefinitionFile>
- <ImageHasSafeExceptionHandlers Condition="'$(PlatformToolsetVersion)'=='110'">false</ImageHasSafeExceptionHandlers>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\ffmpeg;$(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>libgcc.a;libmingwex.a;d3d9.lib;Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(SolutionDir)lib64;$(DXSDK_DIR)Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <ModuleDefinitionFile>MPCVideoDec.def</ModuleDefinitionFile>
- <ImageHasSafeExceptionHandlers Condition="'$(PlatformToolsetVersion)'=='110'">false</ImageHasSafeExceptionHandlers>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\ffmpeg;$(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- <Lib>
- <AdditionalDependencies>d3d9.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(DXSDK_DIR)Lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- </Lib>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\ffmpeg;$(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- <Lib>
- <AdditionalDependencies>d3d9.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(DXSDK_DIR)Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- </Lib>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\ffmpeg;$(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- <Lib>
- <AdditionalDependencies>d3d9.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(DXSDK_DIR)Lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- </Lib>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\ffmpeg;$(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- <Lib>
- <AdditionalDependencies>d3d9.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(DXSDK_DIR)Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- </Lib>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="CpuId.cpp" />
- <ClCompile Include="DXVADecoder.cpp" />
- <ClCompile Include="DXVADecoderH264.cpp" />
- <ClCompile Include="DXVADecoderMpeg2.cpp" />
- <ClCompile Include="DXVADecoderVC1.cpp" />
- <ClCompile Include="ffImgfmt.cpp" />
- <ClCompile Include="FfmpegContext.cpp">
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
- </ClCompile>
- <ClCompile Include="H264RandomAccess.cpp" />
- <ClCompile Include="MPCFfmpegDec.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="MPCVideoDecFilter.cpp" />
- <ClCompile Include="MPCVideoDecSettingsWnd.cpp" />
- <ClCompile Include="stdafx.cpp">
- <PrecompiledHeader>Create</PrecompiledHeader>
- </ClCompile>
- <ClCompile Include="TlibavcodecExt.cpp" />
- <ClCompile Include="VideoDecDXVAAllocator.cpp" />
- <ClCompile Include="VideoDecOutputPin.cpp" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="array_allocator.h" />
- <ClInclude Include="char_t.h" />
- <ClInclude Include="CpuId.h" />
- <ClInclude Include="DXVADecoder.h" />
- <ClInclude Include="DXVADecoderH264.h" />
- <ClInclude Include="DXVADecoderMpeg2.h" />
- <ClInclude Include="DXVADecoderVC1.h" />
- <ClInclude Include="ffImgfmt.h" />
- <ClInclude Include="FfmpegContext.h" />
- <ClInclude Include="H264RandomAccess.h" />
- <ClInclude Include="IMPCVideoDecFilter.h" />
- <ClInclude Include="MPCVideoDecFilter.h" />
- <ClInclude Include="MPCVideoDecSettingsWnd.h" />
- <ClInclude Include="PODtypes.h" />
- <ClInclude Include="resource.h">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ClInclude>
- <ClInclude Include="stdafx.h" />
- <ClInclude Include="TlibavcodecExt.h" />
- <ClInclude Include="VideoDecDXVAAllocator.h" />
- <ClInclude Include="VideoDecOutputPin.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="MPCVideoDecFilter.rc">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ResourceCompile>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\DSUtil\DSUtil.vcxproj">
- <Project>{fc70988b-1ae5-4381-866d-4f405e28ac42}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\Kasumi\Kasumi.vcxproj">
- <Project>{0d252872-7542-4232-8d02-53f9182aee15}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\system\system.vcxproj">
- <Project>{c2082189-3ecb-4079-91fa-89d3c8a305c0}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\zlib\zlib.vcxproj">
- <Project>{2fcd4b66-9cf9-4c8f-bc70-37cd20002d49}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\BaseClasses\BaseClasses.vcxproj">
- <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\Filters.vcxproj">
- <Project>{273b3149-3192-4b75-a791-470320b90812}</Project>
- </ProjectReference>
- <ProjectReference Include="..\BaseVideoFilter\BaseVideoFilter.vcxproj">
- <Project>{54dda60f-e528-4d07-a152-960a1e818680}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\ffmpeg\ffmpeg.vcxproj">
- <Project>{438286b7-a9f4-411d-bcc5-948c40e37d8f}</Project>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDec.vcxproj.filters b/src/filters/transform/MPCVideoDec/MPCVideoDec.vcxproj.filters
deleted file mode 100644
index 98f3bc6e4..000000000
--- a/src/filters/transform/MPCVideoDec/MPCVideoDec.vcxproj.filters
+++ /dev/null
@@ -1,137 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{e15c9785-536b-4371-9e8e-ddbcfdb5c17e}</UniqueIdentifier>
- <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{2f29e203-dfe5-49ab-8326-55ff62a38d80}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{29435264-dc59-4006-a197-91a4bd1e583f}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="CpuId.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="DXVADecoder.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="DXVADecoderH264.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="DXVADecoderMpeg2.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="DXVADecoderVC1.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="ffImgfmt.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="MPCFfmpegDec.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="MPCVideoDecFilter.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="MPCVideoDecSettingsWnd.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="stdafx.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="TlibavcodecExt.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="VideoDecDXVAAllocator.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="VideoDecOutputPin.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="H264RandomAccess.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="FfmpegContext.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="CpuId.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="DXVADecoder.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="DXVADecoderH264.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="DXVADecoderMpeg2.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="DXVADecoderVC1.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="FfmpegContext.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="IMPCVideoDecFilter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="MPCVideoDecFilter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="MPCVideoDecSettingsWnd.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="resource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="stdafx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="TlibavcodecExt.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="VideoDecDXVAAllocator.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="VideoDecOutputPin.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="H264RandomAccess.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="char_t.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="ffImgfmt.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="array_allocator.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="PODtypes.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="MPCVideoDecFilter.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp b/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp
deleted file mode 100644
index 9ac369bfc..000000000
--- a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp
+++ /dev/null
@@ -1,2672 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <math.h>
-#include <atlbase.h>
-#include <MMReg.h>
-#include <evr.h>
-#include <vector>
-
-#ifdef STANDALONE_FILTER
-#include <InitGuid.h>
-#endif
-
-#include "MPCVideoDecFilter.h"
-#include "VideoDecOutputPin.h"
-#include "CpuId.h"
-
-#include "FfmpegContext.h"
-extern "C"
-{
-#include "ffmpeg/libavcodec/avcodec.h"
-#include "ffmpeg/libswscale/swscale.h"
-}
-#include "ffImgfmt.h"
-
-#include "../../../DSUtil/DSUtil.h"
-#include "../../../DSUtil/MediaTypes.h"
-#include "../../../DSUtil/SysVersion.h"
-#include "../../../DSUtil/WinAPIUtils.h"
-#include "../../parser/MpegSplitter/MpegSplitter.h"
-#include "../../parser/OggSplitter/OggSplitter.h"
-#include "../../parser/RealMediaSplitter/RealMediaSplitter.h"
-#include "moreuuids.h"
-#include "DXVADecoderH264.h"
-#include "../../../mpc-hc/FilterEnum.h"
-
-// options names
-#define OPT_REGKEY_VideoDec _T("Software\\Gabest\\Filters\\MPC Video Decoder")
-#define OPT_SECTION_VideoDec _T("Filters\\MPC Video Decoder")
-#define OPT_ThreadNumber _T("ThreadNumber")
-#define OPT_DiscardMode _T("DiscardMode")
-#define OPT_ActiveCodecs _T("ActiveCodecs")
-#define OPT_ARMode _T("ARMode")
-#define OPT_DXVACheck _T("DXVACheckCompatibility")
-#define OPT_DisableDXVA_SD _T("DisableDXVA_SD")
-#define OPT_InterlacedFlag _T("InterlacedFlag")
-
-#define MAX_SUPPORTED_MODE 5
-#define AVRTIMEPERFRAME_VC1_EVO 417083
-
-typedef struct {
- const int PicEntryNumber;
- const UINT PreferedConfigBitstream;
- const GUID* Decoder[MAX_SUPPORTED_MODE];
- const WORD RestrictedMode[MAX_SUPPORTED_MODE];
-} DXVA_PARAMS;
-
-typedef struct {
- const CLSID* clsMinorType;
- const enum AVCodecID nFFCodec;
- const DXVA_PARAMS* DXVAModes;
-
- int DXVAModeCount() {
- if (!DXVAModes) {
- return 0;
- }
- for (int i = 0; i < MAX_SUPPORTED_MODE; i++) {
- if (DXVAModes->Decoder[i] == &GUID_NULL) {
- return i;
- }
- }
- return MAX_SUPPORTED_MODE;
- }
-} FFMPEG_CODECS;
-
-// DXVA modes supported for Mpeg2
-DXVA_PARAMS DXVA_Mpeg2 = {
- 9, // PicEntryNumber
- 1, // PreferedConfigBitstream
- { &DXVA2_ModeMPEG2_VLD, &GUID_NULL },
- { DXVA_RESTRICTED_MODE_UNRESTRICTED, 0 } // Restricted mode for DXVA1?
-};
-
-// DXVA modes supported for H264
-DXVA_PARAMS DXVA_H264 = {
- 16, // PicEntryNumber
- 2, // PreferedConfigBitstream
- { &DXVA2_ModeH264_E, &DXVA2_ModeH264_F, &DXVA_Intel_H264_ClearVideo, &GUID_NULL },
- { DXVA_RESTRICTED_MODE_H264_E, 0}
-};
-
-DXVA_PARAMS DXVA_H264_VISTA = {
- 22, // PicEntryNumber
- 2, // PreferedConfigBitstream
- { &DXVA2_ModeH264_E, &DXVA2_ModeH264_F, &DXVA_Intel_H264_ClearVideo, &GUID_NULL },
- { DXVA_RESTRICTED_MODE_H264_E, 0}
-};
-
-// DXVA modes supported for VC1
-DXVA_PARAMS DXVA_VC1 = {
- 14, // PicEntryNumber
- 1, // PreferedConfigBitstream
- { &DXVA2_ModeVC1_D, &GUID_NULL },
- { DXVA_RESTRICTED_MODE_VC1_D, 0}
-};
-
-FFMPEG_CODECS ffCodecs[] = {
-#if HAS_FFMPEG_VIDEO_DECODERS
- // Flash video
- { &MEDIASUBTYPE_FLV1, AV_CODEC_ID_FLV1, nullptr },
- { &MEDIASUBTYPE_flv1, AV_CODEC_ID_FLV1, nullptr },
- { &MEDIASUBTYPE_FLV4, AV_CODEC_ID_VP6F, nullptr },
- { &MEDIASUBTYPE_flv4, AV_CODEC_ID_VP6F, nullptr },
- { &MEDIASUBTYPE_VP6F, AV_CODEC_ID_VP6F, nullptr },
- { &MEDIASUBTYPE_vp6f, AV_CODEC_ID_VP6F, nullptr },
-
- // VP3
- { &MEDIASUBTYPE_VP30, AV_CODEC_ID_VP3, nullptr },
- { &MEDIASUBTYPE_VP31, AV_CODEC_ID_VP3, nullptr },
-
- // VP5
- { &MEDIASUBTYPE_VP50, AV_CODEC_ID_VP5, nullptr },
- { &MEDIASUBTYPE_vp50, AV_CODEC_ID_VP5, nullptr },
-
- // VP6
- { &MEDIASUBTYPE_VP60, AV_CODEC_ID_VP6, nullptr },
- { &MEDIASUBTYPE_vp60, AV_CODEC_ID_VP6, nullptr },
- { &MEDIASUBTYPE_VP61, AV_CODEC_ID_VP6, nullptr },
- { &MEDIASUBTYPE_vp61, AV_CODEC_ID_VP6, nullptr },
- { &MEDIASUBTYPE_VP62, AV_CODEC_ID_VP6, nullptr },
- { &MEDIASUBTYPE_vp62, AV_CODEC_ID_VP6, nullptr },
- { &MEDIASUBTYPE_VP6A, AV_CODEC_ID_VP6A, nullptr },
- { &MEDIASUBTYPE_vp6a, AV_CODEC_ID_VP6A, nullptr },
-
- // VP8
- { &MEDIASUBTYPE_VP80, AV_CODEC_ID_VP8, nullptr },
-
- // Xvid
- { &MEDIASUBTYPE_XVID, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_xvid, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_XVIX, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_xvix, AV_CODEC_ID_MPEG4, nullptr },
-
- // DivX
- { &MEDIASUBTYPE_DX50, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_dx50, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_DIVX, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_divx, AV_CODEC_ID_MPEG4, nullptr },
-
- // WMV1/2/3
- { &MEDIASUBTYPE_WMV1, AV_CODEC_ID_WMV1, nullptr },
- { &MEDIASUBTYPE_wmv1, AV_CODEC_ID_WMV1, nullptr },
- { &MEDIASUBTYPE_WMV2, AV_CODEC_ID_WMV2, nullptr },
- { &MEDIASUBTYPE_wmv2, AV_CODEC_ID_WMV2, nullptr },
- { &MEDIASUBTYPE_WMV3, AV_CODEC_ID_WMV3, &DXVA_VC1 },
- { &MEDIASUBTYPE_wmv3, AV_CODEC_ID_WMV3, &DXVA_VC1 },
-
- // MPEG-2
- { &MEDIASUBTYPE_MPEG2_VIDEO, AV_CODEC_ID_MPEG2VIDEO, &DXVA_Mpeg2 },
- { &MEDIASUBTYPE_MPG2, AV_CODEC_ID_MPEG2VIDEO, &DXVA_Mpeg2 },
-
- // MSMPEG-4
- { &MEDIASUBTYPE_DIV3, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_div3, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_DVX3, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_dvx3, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_MP43, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_mp43, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_COL1, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_col1, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_DIV4, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_div4, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_DIV5, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_div5, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_DIV6, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_div6, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_AP41, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_ap41, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_MPG3, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_mpg3, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_DIV2, AV_CODEC_ID_MSMPEG4V2, nullptr },
- { &MEDIASUBTYPE_div2, AV_CODEC_ID_MSMPEG4V2, nullptr },
- { &MEDIASUBTYPE_MP42, AV_CODEC_ID_MSMPEG4V2, nullptr },
- { &MEDIASUBTYPE_mp42, AV_CODEC_ID_MSMPEG4V2, nullptr },
- { &MEDIASUBTYPE_MPG4, AV_CODEC_ID_MSMPEG4V1, nullptr },
- { &MEDIASUBTYPE_mpg4, AV_CODEC_ID_MSMPEG4V1, nullptr },
- { &MEDIASUBTYPE_DIV1, AV_CODEC_ID_MSMPEG4V1, nullptr },
- { &MEDIASUBTYPE_div1, AV_CODEC_ID_MSMPEG4V1, nullptr },
- { &MEDIASUBTYPE_MP41, AV_CODEC_ID_MSMPEG4V1, nullptr },
- { &MEDIASUBTYPE_mp41, AV_CODEC_ID_MSMPEG4V1, nullptr },
-
- // AMV Video
- { &MEDIASUBTYPE_AMVV, AV_CODEC_ID_AMV, nullptr },
-
- // MJPEG
- { &MEDIASUBTYPE_MJPG, AV_CODEC_ID_MJPEG, nullptr },
- { &MEDIASUBTYPE_QTJpeg, AV_CODEC_ID_MJPEG, nullptr },
- { &MEDIASUBTYPE_MJPA, AV_CODEC_ID_MJPEG, nullptr },
- { &MEDIASUBTYPE_MJPB, AV_CODEC_ID_MJPEGB, nullptr },
-
- // Indeo 3/4/5
- { &MEDIASUBTYPE_IV31, AV_CODEC_ID_INDEO3, nullptr },
- { &MEDIASUBTYPE_IV32, AV_CODEC_ID_INDEO3, nullptr },
- { &MEDIASUBTYPE_IV41, AV_CODEC_ID_INDEO4, nullptr },
- { &MEDIASUBTYPE_IV50, AV_CODEC_ID_INDEO5, nullptr },
-
- // Screen Capture(TSCC, VMnc)
- { &MEDIASUBTYPE_TSCC, AV_CODEC_ID_TSCC, nullptr },
- { &MEDIASUBTYPE_VMnc, AV_CODEC_ID_VMNC, nullptr },
-#endif /* HAS_FFMPEG_VIDEO_DECODERS */
-
- // H264/AVC
- { &MEDIASUBTYPE_H264, AV_CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_h264, AV_CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_X264, AV_CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_x264, AV_CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_VSSH, AV_CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_vssh, AV_CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_DAVC, AV_CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_davc, AV_CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_PAVC, AV_CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_pavc, AV_CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_AVC1, AV_CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_avc1, AV_CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_H264_bis, AV_CODEC_ID_H264, &DXVA_H264 },
-
-#if HAS_FFMPEG_VIDEO_DECODERS
- // SVQ3
- { &MEDIASUBTYPE_SVQ3, AV_CODEC_ID_SVQ3, nullptr },
-
- // SVQ1
- { &MEDIASUBTYPE_SVQ1, AV_CODEC_ID_SVQ1, nullptr },
-
- // H263
- { &MEDIASUBTYPE_H263, AV_CODEC_ID_H263, nullptr },
- { &MEDIASUBTYPE_h263, AV_CODEC_ID_H263, nullptr },
-
- { &MEDIASUBTYPE_S263, AV_CODEC_ID_H263, nullptr },
- { &MEDIASUBTYPE_s263, AV_CODEC_ID_H263, nullptr },
-
- // Real Video
- { &MEDIASUBTYPE_RV10, AV_CODEC_ID_RV10, nullptr },
- { &MEDIASUBTYPE_RV20, AV_CODEC_ID_RV20, nullptr },
- { &MEDIASUBTYPE_RV30, AV_CODEC_ID_RV30, nullptr },
- { &MEDIASUBTYPE_RV40, AV_CODEC_ID_RV40, nullptr },
-
- // Theora
- { &MEDIASUBTYPE_THEORA, AV_CODEC_ID_THEORA, nullptr },
- { &MEDIASUBTYPE_theora, AV_CODEC_ID_THEORA, nullptr },
-#endif /* HAS_FFMPEG_VIDEO_DECODERS */
-
- // WVC1
- { &MEDIASUBTYPE_WVC1, AV_CODEC_ID_VC1, &DXVA_VC1 },
- { &MEDIASUBTYPE_wvc1, AV_CODEC_ID_VC1, &DXVA_VC1 },
-
-#if HAS_FFMPEG_VIDEO_DECODERS
- // Other MPEG-4
- { &MEDIASUBTYPE_MP4V, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_mp4v, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_M4S2, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_m4s2, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_MP4S, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_mp4s, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_3IV1, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_3iv1, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_3IV2, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_3iv2, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_3IVX, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_3ivx, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_BLZ0, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_blz0, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_DM4V, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_dm4v, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_FFDS, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_ffds, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_FVFW, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_fvfw, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_DXGM, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_dxgm, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_FMP4, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_fmp4, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_HDX4, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_hdx4, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_LMP4, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_lmp4, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_NDIG, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_ndig, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_RMP4, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_rmp4, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_SMP4, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_smp4, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_SEDG, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_sedg, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_UMP4, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_ump4, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_WV1F, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_wv1f, AV_CODEC_ID_MPEG4, nullptr }
-#endif /* HAS_FFMPEG_VIDEO_DECODERS */
-};
-
-/* Important: the order should be exactly the same as in ffCodecs[] */
-const AMOVIESETUP_MEDIATYPE CMPCVideoDecFilter::sudPinTypesIn[] = {
-#if HAS_FFMPEG_VIDEO_DECODERS
- // Flash video
- { &MEDIATYPE_Video, &MEDIASUBTYPE_FLV1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_flv1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_FLV4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_flv4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP6F },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_vp6f },
-
- // VP3
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP30 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP31 },
-
- // VP5
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP50 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_vp50 },
-
- // VP6
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP60 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_vp60 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP61 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_vp61 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP62 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_vp62 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP6A },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_vp6a },
-
- // VP8
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP80 },
-
- // Xvid
- { &MEDIATYPE_Video, &MEDIASUBTYPE_XVID },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_xvid },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_XVIX },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_xvix },
-
- // DivX
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DX50 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_dx50 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DIVX },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_divx },
-
- // WMV1/2/3
- { &MEDIATYPE_Video, &MEDIASUBTYPE_WMV1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_wmv1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_WMV2 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_wmv2 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_WMV3 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_wmv3 },
-
- // MPEG-2
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MPEG2_VIDEO },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MPG2 },
-
- // MSMPEG-4
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV3 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_div3 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DVX3 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_dvx3 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MP43 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_mp43 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_COL1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_col1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_div4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV5 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_div5 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV6 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_div6 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_AP41 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_ap41 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MPG3 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_mpg3 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV2 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_div2 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MP42 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_mp42 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MPG4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_mpg4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_div1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MP41 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_mp41 },
-
- // AMV Video
- { &MEDIATYPE_Video, &MEDIASUBTYPE_AMVV },
-
- // MJPEG
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MJPG },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_QTJpeg },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MJPA },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MJPB },
-
- // Indeo 3/4/5
- { &MEDIATYPE_Video, &MEDIASUBTYPE_IV31 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_IV32 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_IV41 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_IV50 },
-
- // Screen Capture(TSCC, VMnc)
- { &MEDIATYPE_Video, &MEDIASUBTYPE_TSCC },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VMnc },
-#endif /* HAS_FFMPEG_VIDEO_DECODERS */
-
- // H264/AVC
- { &MEDIATYPE_Video, &MEDIASUBTYPE_H264 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_h264 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_X264 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_x264 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VSSH },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_vssh },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DAVC },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_davc },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_PAVC },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_pavc },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_AVC1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_avc1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_H264_bis },
-
-#if HAS_FFMPEG_VIDEO_DECODERS
- // SVQ3
- { &MEDIATYPE_Video, &MEDIASUBTYPE_SVQ3 },
-
- // SVQ1
- { &MEDIATYPE_Video, &MEDIASUBTYPE_SVQ1 },
-
- // H263
- { &MEDIATYPE_Video, &MEDIASUBTYPE_H263 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_h263 },
-
- { &MEDIATYPE_Video, &MEDIASUBTYPE_S263 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_s263 },
-
- // Real video
- { &MEDIATYPE_Video, &MEDIASUBTYPE_RV10 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_RV20 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_RV30 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_RV40 },
-
- // Theora
- { &MEDIATYPE_Video, &MEDIASUBTYPE_THEORA },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_theora },
-#endif /* HAS_FFMPEG_VIDEO_DECODERS */
-
- // VC1
- { &MEDIATYPE_Video, &MEDIASUBTYPE_WVC1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_wvc1 },
-
-#if HAS_FFMPEG_VIDEO_DECODERS
- // IMPORTANT : some of the last MediaTypes present in next group may be not available in
- // the standalone filter (workaround to prevent GraphEdit crash).
- // Other MPEG-4
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MP4V },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_mp4v },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_M4S2 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_m4s2 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MP4S },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_mp4s },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_3IV1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_3iv1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_3IV2 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_3iv2 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_3IVX },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_3ivx },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_BLZ0 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_blz0 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DM4V },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_dm4v },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_FFDS },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_ffds },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_FVFW },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_fvfw },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DXGM },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_dxgm },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_FMP4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_fmp4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_HDX4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_hdx4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_LMP4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_lmp4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_NDIG },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_ndig },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_RMP4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_rmp4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_SMP4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_smp4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_SEDG },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_sedg },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_UMP4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_ump4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_WV1F },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_wv1f }
-#endif /* HAS_FFMPEG_VIDEO_DECODERS */
-};
-
-const int CMPCVideoDecFilter::sudPinTypesInCount = _countof(CMPCVideoDecFilter::sudPinTypesIn);
-
-const AMOVIESETUP_MEDIATYPE CMPCVideoDecFilter::sudPinTypesOut[] = {
- {&MEDIATYPE_Video, &MEDIASUBTYPE_NV12},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_NV24}
-};
-const int CMPCVideoDecFilter::sudPinTypesOutCount = _countof(CMPCVideoDecFilter::sudPinTypesOut);
-
-BOOL CALLBACK EnumFindProcessWnd(HWND hwnd, LPARAM lParam)
-{
- DWORD procid = 0;
- TCHAR WindowClass [40];
- GetWindowThreadProcessId(hwnd, &procid);
- GetClassName(hwnd, WindowClass, _countof(WindowClass));
-
- if (procid == GetCurrentProcessId() && _tcscmp(WindowClass, _T("MediaPlayerClassicW")) == 0) {
- HWND* pWnd = (HWND*)lParam;
- *pWnd = hwnd;
- return FALSE;
- }
- return TRUE;
-}
-
-CMPCVideoDecFilter::CMPCVideoDecFilter(LPUNKNOWN lpunk, HRESULT* phr)
- : CBaseVideoFilter(MPCVideoDecName, lpunk, phr, __uuidof(this))
-{
- HWND hWnd = nullptr;
-
- if (SysVersion::IsVistaOrLater()) {
- for (int i = 0; i < _countof(ffCodecs); i++) {
- if (ffCodecs[i].nFFCodec == AV_CODEC_ID_H264) {
- ffCodecs[i].DXVAModes = &DXVA_H264_VISTA;
- }
- }
- }
-
- if (phr) {
- *phr = S_OK;
- }
-
- if (m_pOutput) {
- delete m_pOutput;
- }
- m_pOutput = DEBUG_NEW CVideoDecOutputPin(NAME("CVideoDecOutputPin"), this, phr, L"Output");
- if (!m_pOutput) {
- *phr = E_OUTOFMEMORY;
- }
-
- m_pCpuId = DEBUG_NEW CCpuId();
- m_pAVCodec = nullptr;
- m_pAVCtx = nullptr;
- m_pFrame = nullptr;
- m_nCodecNb = -1;
- m_nCodecId = AV_CODEC_ID_NONE;
- m_bReorderBFrame = true;
- m_DXVADecoderGUID = GUID_NULL;
- m_nActiveCodecs = MPCVD_H264 | MPCVD_VC1 | MPCVD_XVID | MPCVD_DIVX | MPCVD_MSMPEG4 |
- MPCVD_FLASH | MPCVD_WMV | MPCVD_H263 | MPCVD_SVQ3 | MPCVD_AMVV |
- MPCVD_THEORA | MPCVD_H264_DXVA | MPCVD_VC1_DXVA | MPCVD_VP356 |
- MPCVD_VP8 | MPCVD_MJPEG | MPCVD_INDEO | MPCVD_RV | MPCVD_WMV3_DXVA |
- MPCVD_MPEG2_DXVA;
-
- m_rtAvrTimePerFrame = 0;
- m_rtLastStart = 0;
- m_nCountEstimated = 0;
- m_rtPrevStop = 0;
-
- m_nWorkaroundBug = FF_BUG_AUTODETECT;
- m_nErrorConcealment = FF_EC_DEBLOCK | FF_EC_GUESS_MVS;
-
- m_nThreadNumber = 0;
- m_nDiscardMode = AVDISCARD_DEFAULT;
- m_bDXVACompatible = true;
- m_pFFBuffer = nullptr;
- m_nFFBufferSize = 0;
- m_pAlignedFFBuffer = nullptr;
- m_nAlignedFFBufferSize = 0;
- ResetBuffer();
-
- m_nWidth = 0;
- m_nHeight = 0;
- m_pSwsContext = nullptr;
-
- m_bUseDXVA = true;
- m_bUseFFmpeg = true;
-
- m_nDXVAMode = MODE_SOFTWARE;
- m_pDXVADecoder = nullptr;
- m_pVideoOutputFormat = nullptr;
- m_nVideoOutputCount = 0;
- m_hDevice = INVALID_HANDLE_VALUE;
-
- m_nARMode = 1;
- m_nDXVACheckCompatibility = 1; // skip level check by default
- m_nDXVA_SD = 0;
- m_par.SetSize(1, 1);
-
- m_interlacedFlag = MPCVC_INTERLACED_AUTO;
-
- m_bTheoraMTSupport = true;
- m_bWaitingForKeyFrame = TRUE;
- m_nPosB = 1;
- m_bFrame_repeat_pict = false;
- m_bIsEVO = false;
-
-#ifdef STANDALONE_FILTER
- CRegKey key;
- if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, OPT_REGKEY_VideoDec, KEY_READ)) {
- DWORD dw;
-#if HAS_FFMPEG_VIDEO_DECODERS
- if (ERROR_SUCCESS == key.QueryDWORDValue(OPT_ThreadNumber, dw)) {
- m_nThreadNumber = dw;
- }
-#if INTERNAL_DECODER_H264
- if (ERROR_SUCCESS == key.QueryDWORDValue(OPT_DiscardMode, dw)) {
- m_nDiscardMode = dw;
- }
-#endif
- if (ERROR_SUCCESS == key.QueryDWORDValue(OPT_ActiveCodecs, dw)) {
- m_nActiveCodecs = dw;
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(OPT_ARMode, dw)) {
- m_nARMode = dw;
- }
-#endif
- if (ERROR_SUCCESS == key.QueryDWORDValue(OPT_DXVACheck, dw)) {
- m_nDXVACheckCompatibility = dw;
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(OPT_DisableDXVA_SD, dw)) {
- m_nDXVA_SD = dw;
- }
-
- if (ERROR_SUCCESS == key.QueryDWORDValue(OPT_InterlacedFlag, dw)) {
- m_interlacedFlag = (MPCVD_INTERLACED_FLAG)dw;
- }
- }
-#else
-#if HAS_FFMPEG_VIDEO_DECODERS
- m_nThreadNumber = AfxGetApp()->GetProfileInt(OPT_SECTION_VideoDec, OPT_ThreadNumber, m_nThreadNumber);
-#if INTERNAL_DECODER_H264
- m_nDiscardMode = AfxGetApp()->GetProfileInt(OPT_SECTION_VideoDec, OPT_DiscardMode, m_nDiscardMode);
-#endif
- m_nARMode = AfxGetApp()->GetProfileInt(OPT_SECTION_VideoDec, OPT_ARMode, m_nARMode);
-#endif
- m_nDXVACheckCompatibility = AfxGetApp()->GetProfileInt(OPT_SECTION_VideoDec, OPT_DXVACheck, m_nDXVACheckCompatibility);
- m_nDXVA_SD = AfxGetApp()->GetProfileInt(OPT_SECTION_VideoDec, OPT_DisableDXVA_SD, m_nDXVA_SD);
-
- m_interlacedFlag = (MPCVD_INTERLACED_FLAG)AfxGetApp()->GetProfileInt(OPT_SECTION_VideoDec, OPT_InterlacedFlag, m_interlacedFlag);
-#endif
-
- if (m_nDXVACheckCompatibility > 3) {
- m_nDXVACheckCompatibility = 1; // skip level check by default
- }
-
- ff_avcodec_default_get_buffer = avcodec_default_get_buffer;
- ff_avcodec_default_release_buffer = avcodec_default_release_buffer;
- ff_avcodec_default_reget_buffer = avcodec_default_reget_buffer;
-
- avcodec_register_all();
- av_log_set_callback(LogLibavcodec);
-
- EnumWindows(EnumFindProcessWnd, (LPARAM)&hWnd);
- DetectVideoCard(hWnd);
-
-#ifdef _DEBUG
- // Check codec definition table
- int nCodecs = _countof(ffCodecs);
- int nPinTypes = _countof(sudPinTypesIn);
- ASSERT(nCodecs == nPinTypes);
- for (int i = 0; i < nPinTypes; i++) {
- ASSERT(ffCodecs[i].clsMinorType == sudPinTypesIn[i].clsMinorType);
- }
-#endif
-}
-
-void CMPCVideoDecFilter::DetectVideoCard(HWND hWnd)
-{
- IDirect3D9* pD3D9;
- m_nPCIVendor = 0;
- m_nPCIDevice = 0;
- m_VideoDriverVersion.HighPart = 0;
- m_VideoDriverVersion.LowPart = 0;
-
- pD3D9 = Direct3DCreate9(D3D_SDK_VERSION);
- if (pD3D9) {
- D3DADAPTER_IDENTIFIER9 adapterIdentifier;
- if (pD3D9->GetAdapterIdentifier(GetAdapter(pD3D9, hWnd), 0, &adapterIdentifier) == S_OK) {
- m_nPCIVendor = adapterIdentifier.VendorId;
- m_nPCIDevice = adapterIdentifier.DeviceId;
- m_VideoDriverVersion = adapterIdentifier.DriverVersion;
- m_strDeviceDescription = adapterIdentifier.Description;
- m_strDeviceDescription.AppendFormat(_T(" (%04X:%04X)"), m_nPCIVendor, m_nPCIDevice);
- }
- pD3D9->Release();
- }
-}
-
-CMPCVideoDecFilter::~CMPCVideoDecFilter()
-{
- Cleanup();
- SAFE_DELETE(m_pCpuId);
-}
-
-bool CMPCVideoDecFilter::IsVideoInterlaced()
-{
- // NOT A BUG : always tell DirectShow it's interlaced (progressive flags set in
- // SetTypeSpecificFlags function)
- return true;
-};
-
-void CMPCVideoDecFilter::UpdateFrameTime(REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop, bool b_repeat_pict)
-{
- bool m_PullDownFlag = (m_nCodecId == AV_CODEC_ID_VC1 && b_repeat_pict && m_rtAvrTimePerFrame == 333666);
- REFERENCE_TIME m_rtFrameDuration = m_PullDownFlag ? AVRTIMEPERFRAME_VC1_EVO : m_rtAvrTimePerFrame;
-
- if ((rtStart == _I64_MIN) || (m_PullDownFlag && m_rtPrevStop && (rtStart <= m_rtPrevStop))) {
- rtStart = m_rtLastStart + (REFERENCE_TIME)(m_rtFrameDuration / m_dRate) * m_nCountEstimated;
- m_nCountEstimated++;
- } else {
- m_rtLastStart = rtStart;
- m_nCountEstimated = 1;
- }
-
- rtStop = rtStart + (REFERENCE_TIME)(m_rtFrameDuration / m_dRate);
-}
-
-void CMPCVideoDecFilter::GetOutputSize(int& w, int& h, int& arx, int& ary, int& RealWidth, int& RealHeight)
-{
-#if 1
- RealWidth = m_nWidth;
- RealHeight = m_nHeight;
- w = PictWidthRounded();
- h = PictHeightRounded();
-#else
- if (m_nDXVAMode == MODE_SOFTWARE) {
- w = m_nWidth;
- h = m_nHeight;
- } else {
- // DXVA surfaces are multiple of 16 pixels!
- w = PictWidthRounded();
- h = PictHeightRounded();
- }
-#endif
-}
-
-int CMPCVideoDecFilter::PictWidth()
-{
- return m_nWidth;
-}
-
-int CMPCVideoDecFilter::PictHeight()
-{
- return m_nHeight;
-}
-
-int CMPCVideoDecFilter::PictWidthRounded()
-{
- // Picture height should be rounded to 16 for DXVA
- return ((m_nWidth + 15) / 16) * 16;
-}
-
-int CMPCVideoDecFilter::PictHeightRounded()
-{
- // Picture height should be rounded to 16 for DXVA
- return ((m_nHeight + 15) / 16) * 16;
-}
-
-int CMPCVideoDecFilter::FindCodec(const CMediaType* mtIn)
-{
- for (int i = 0; i < _countof(ffCodecs); i++) {
- if (mtIn->subtype == *ffCodecs[i].clsMinorType) {
-#ifndef STANDALONE_FILTER
-/*
- switch (ffCodecs[i].nFFCodec) {
- case AV_CODEC_ID_H264:
-#if INTERNAL_DECODER_H264_DXVA
- m_bUseDXVA = m_DXVAFilters && m_DXVAFilters[TRA_DXVA_H264];
-#else
- m_bUseDXVA = false;
-#endif
-#if INTERNAL_DECODER_H264
- m_bUseFFmpeg = m_FFmpegFilters && m_FFmpegFilters[FFM_H264];
-#else
- m_bUseFFmpeg = false;
-#endif
- break;
- case AV_CODEC_ID_VC1:
-#if INTERNAL_DECODER_VC1_DXVA
- m_bUseDXVA = m_DXVAFilters && m_DXVAFilters[TRA_DXVA_VC1];
-#else
- m_bUseDXVA = false;
-#endif
-#if INTERNAL_DECODER_VC1
- m_bUseFFmpeg = m_FFmpegFilters && m_FFmpegFilters[FFM_VC1];
-#else
- m_bUseFFmpeg = false;
-#endif
- break;
- case AV_CODEC_ID_WMV3:
-#if INTERNAL_DECODER_WMV3_DXVA
- m_bUseDXVA = m_DXVAFilters && m_DXVAFilters[TRA_DXVA_WMV3];
-#else
- m_bUseDXVA = false;
-#endif
-#if INTERNAL_DECODER_WMV
- m_bUseFFmpeg = m_FFmpegFilters && m_FFmpegFilters[FFM_WMV];
-#else
- m_bUseFFmpeg = false;
-#endif
- break;
- case AV_CODEC_ID_MPEG2VIDEO:
-#if INTERNAL_DECODER_MPEG2_DXVA
- m_bUseDXVA = true;
-#endif
- m_bUseFFmpeg = false; // No Mpeg2 software support with ffmpeg!
- break;
- default:
- m_bUseDXVA = false;
- }
-
- return ((m_bUseDXVA || m_bUseFFmpeg) ? i : -1);
-*/
-#else
- bool bCodecActivated = false;
- switch (ffCodecs[i].nFFCodec) {
- case AV_CODEC_ID_FLV1:
- case AV_CODEC_ID_VP6F:
- bCodecActivated = (m_nActiveCodecs & MPCVD_FLASH) != 0;
- break;
- case AV_CODEC_ID_MPEG4:
- if ((*ffCodecs[i].clsMinorType == MEDIASUBTYPE_DX50) || // DivX
- (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_dx50) ||
- (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_DIVX) ||
- (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_divx)) {
- bCodecActivated = (m_nActiveCodecs & MPCVD_DIVX) != 0;
- } else {
- bCodecActivated = (m_nActiveCodecs & MPCVD_XVID) != 0; // Xvid/MPEG-4
- }
- break;
- case AV_CODEC_ID_WMV1:
- case AV_CODEC_ID_WMV2:
- bCodecActivated = (m_nActiveCodecs & MPCVD_WMV) != 0;
- break;
- case AV_CODEC_ID_WMV3:
- m_bUseDXVA = (m_nActiveCodecs & MPCVD_WMV3_DXVA) != 0;
- m_bUseFFmpeg = (m_nActiveCodecs & MPCVD_WMV) != 0;
- bCodecActivated = m_bUseDXVA || m_bUseFFmpeg;
- break;
- case AV_CODEC_ID_MSMPEG4V3:
- case AV_CODEC_ID_MSMPEG4V2:
- case AV_CODEC_ID_MSMPEG4V1:
- bCodecActivated = (m_nActiveCodecs & MPCVD_MSMPEG4) != 0;
- break;
- case AV_CODEC_ID_H264:
- m_bUseDXVA = (m_nActiveCodecs & MPCVD_H264_DXVA) != 0;
- m_bUseFFmpeg = (m_nActiveCodecs & MPCVD_H264) != 0;
- bCodecActivated = m_bUseDXVA || m_bUseFFmpeg;
- break;
- case AV_CODEC_ID_SVQ3:
- case AV_CODEC_ID_SVQ1:
- bCodecActivated = (m_nActiveCodecs & MPCVD_SVQ3) != 0;
- break;
- case AV_CODEC_ID_H263:
- bCodecActivated = (m_nActiveCodecs & MPCVD_H263) != 0;
- break;
- case AV_CODEC_ID_THEORA:
- bCodecActivated = (m_nActiveCodecs & MPCVD_THEORA) != 0;
- break;
- case AV_CODEC_ID_VC1:
- m_bUseDXVA = (m_nActiveCodecs & MPCVD_VC1_DXVA) != 0;
- m_bUseFFmpeg = (m_nActiveCodecs & MPCVD_VC1) != 0;
- bCodecActivated = m_bUseDXVA || m_bUseFFmpeg;
- break;
- case AV_CODEC_ID_AMV:
- bCodecActivated = (m_nActiveCodecs & MPCVD_AMVV) != 0;
- break;
- case AV_CODEC_ID_VP3:
- case AV_CODEC_ID_VP5:
- case AV_CODEC_ID_VP6:
- case AV_CODEC_ID_VP6A:
- bCodecActivated = (m_nActiveCodecs & MPCVD_VP356) != 0;
- break;
- case AV_CODEC_ID_VP8:
- bCodecActivated = (m_nActiveCodecs & MPCVD_VP8) != 0;
- break;
- case AV_CODEC_ID_MJPEG:
- case AV_CODEC_ID_MJPEGB:
- bCodecActivated = (m_nActiveCodecs & MPCVD_MJPEG) != 0;
- break;
- case AV_CODEC_ID_INDEO3:
- case AV_CODEC_ID_INDEO4:
- case AV_CODEC_ID_INDEO5:
- bCodecActivated = (m_nActiveCodecs & MPCVD_INDEO) != 0;
- break;
- case AV_CODEC_ID_TSCC:
- case AV_CODEC_ID_VMNC:
- bCodecActivated = 1;
- break;
- case AV_CODEC_ID_RV10:
- case AV_CODEC_ID_RV20:
- case AV_CODEC_ID_RV30:
- case AV_CODEC_ID_RV40:
- bCodecActivated = (m_nActiveCodecs & MPCVD_RV) != 0;
- break;
- case AV_CODEC_ID_MPEG2VIDEO:
- m_bUseDXVA = (m_nActiveCodecs & MPCVD_MPEG2_DXVA) != 0;
- m_bUseFFmpeg = false;
- bCodecActivated = m_bUseDXVA;
- break;
- }
- return (bCodecActivated ? i : -1);
-#endif
- }
- }
-
- return -1;
-}
-
-void CMPCVideoDecFilter::Cleanup()
-{
- SAFE_DELETE(m_pDXVADecoder);
-
- // Release FFmpeg
- if (m_pAVCtx) {
- if (m_pAVCtx->extradata) {
- av_freep(&m_pAVCtx->extradata);
- }
- if (m_pFFBuffer) {
- av_freep(&m_pFFBuffer);
- }
- m_nFFBufferSize = 0;
- if (m_pAlignedFFBuffer) {
- av_freep(&m_pAlignedFFBuffer);
- }
- m_nAlignedFFBufferSize = 0;
-
- if (m_pAVCtx->codec) {
- avcodec_close(m_pAVCtx);
- }
-
- // Free thread resource if necessary
- FFSetThreadNumber(m_pAVCtx, m_pAVCtx->codec_id, 0);
-
- av_freep(&m_pAVCtx);
- }
-
- if (m_pFrame) {
- av_freep(&m_pFrame);
- }
-
-#if HAS_FFMPEG_VIDEO_DECODERS
- if (m_pSwsContext) {
- sws_freeContext(m_pSwsContext);
- m_pSwsContext = nullptr;
- }
-#endif /* HAS_FFMPEG_VIDEO_DECODERS */
-
- m_pAVCodec = nullptr;
- m_pAVCtx = nullptr;
- m_pFrame = nullptr;
- m_pFFBuffer = nullptr;
- m_nFFBufferSize = 0;
- m_nFFBufferPos = 0;
- m_nFFPicEnd = INT_MIN;
- m_nCodecNb = -1;
- m_nCodecId = AV_CODEC_ID_NONE;
- SAFE_DELETE_ARRAY(m_pVideoOutputFormat);
-
- // Release DXVA ressources
- if (m_hDevice != INVALID_HANDLE_VALUE) {
- m_pDeviceManager->CloseDeviceHandle(m_hDevice);
- m_hDevice = INVALID_HANDLE_VALUE;
- }
-
- m_pDeviceManager = nullptr;
- m_pDecoderService = nullptr;
- m_pDecoderRenderTarget = nullptr;
-}
-
-void CMPCVideoDecFilter::CalcAvgTimePerFrame()
-{
- CMediaType& mt = m_pInput->CurrentMediaType();
- if (mt.formattype == FORMAT_VideoInfo) {
- m_rtAvrTimePerFrame = ((VIDEOINFOHEADER*)mt.pbFormat)->AvgTimePerFrame;
- } else if (mt.formattype == FORMAT_VideoInfo2) {
- m_rtAvrTimePerFrame = ((VIDEOINFOHEADER2*)mt.pbFormat)->AvgTimePerFrame;
- } else if (mt.formattype == FORMAT_MPEGVideo) {
- m_rtAvrTimePerFrame = ((MPEG1VIDEOINFO*)mt.pbFormat)->hdr.AvgTimePerFrame;
- } else if (mt.formattype == FORMAT_MPEG2Video) {
- m_rtAvrTimePerFrame = ((MPEG2VIDEOINFO*)mt.pbFormat)->hdr.AvgTimePerFrame;
- } else {
- ASSERT(FALSE);
- m_rtAvrTimePerFrame = 1;
- }
-
- m_rtAvrTimePerFrame = max(1, m_rtAvrTimePerFrame);
-}
-
-void CMPCVideoDecFilter::LogLibavcodec(void* par, int level, const char* fmt, va_list valist)
-{
-#if defined(_DEBUG) && 0
- if (level <= AV_LOG_VERBOSE) {
- char Msg [500];
- vsnprintf_s(Msg, sizeof(Msg), _TRUNCATE, fmt, valist);
- TRACE(_T("AVLIB : %s\n"), Msg);
- }
-#endif
-}
-
-void CMPCVideoDecFilter::OnGetBuffer(AVFrame* pic)
-{
- // Callback from FFmpeg to store Ref Time in frame (needed to have correct rtStart after avcodec_decode_video calls)
- //pic->rtStart = m_rtStart;
-}
-
-STDMETHODIMP CMPCVideoDecFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
-{
- return
- QI(IMPCVideoDecFilter)
- QI(IMPCVideoDecFilter2)
- QI(ISpecifyPropertyPages)
- QI(ISpecifyPropertyPages2)
- __super::NonDelegatingQueryInterface(riid, ppv);
-}
-
-
-
-HRESULT CMPCVideoDecFilter::CheckInputType(const CMediaType* mtIn)
-{
- for (int i = 0; i < _countof(sudPinTypesIn); i++) {
- if ((mtIn->majortype == *sudPinTypesIn[i].clsMajorType) &&
- (mtIn->subtype == *sudPinTypesIn[i].clsMinorType)) {
- return S_OK;
- }
- }
-
- return VFW_E_TYPE_NOT_ACCEPTED;
-}
-
-bool CMPCVideoDecFilter::IsMultiThreadSupported(enum AVCodecID nCodec)
-{
- return
- (
- nCodec == AV_CODEC_ID_H264 ||
- nCodec == AV_CODEC_ID_MPEG1VIDEO ||
- nCodec == AV_CODEC_ID_FFV1 ||
- nCodec == AV_CODEC_ID_DVVIDEO ||
- nCodec == AV_CODEC_ID_VP3 ||
- nCodec == AV_CODEC_ID_VP8 ||
- nCodec == AV_CODEC_ID_THEORA ||
- nCodec == AV_CODEC_ID_RV30 ||
- nCodec == AV_CODEC_ID_RV40
- );
-}
-
-CString CMPCVideoDecFilter::GetFileExtension()
-{
- CString ext;
-
- BeginEnumFilters(m_pGraph, pEF, pBF) {
- CComQIPtr<IFileSourceFilter> pFSF = pBF;
- if (pFSF) {
- LPOLESTR pFN = nullptr;
- AM_MEDIA_TYPE mt;
- if (SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN) {
- ext = CPath(CStringW(pFN)).GetExtension();
- ext.MakeLower();
- CoTaskMemFree(pFN);
- }
- break;
- }
- }
- EndEnumFilters;
-
- return ext;
-}
-
-HRESULT CMPCVideoDecFilter::SetMediaType(PIN_DIRECTION direction, const CMediaType* pmt)
-{
- if (direction == PINDIR_INPUT) {
-
- int nNewCodec = FindCodec(pmt);
-
- if (nNewCodec == -1) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- if (nNewCodec != m_nCodecNb) {
- m_nCodecNb = nNewCodec;
- m_nCodecId = ffCodecs[nNewCodec].nFFCodec;
-
- CLSID ClsidSourceFilter = GetCLSID(m_pInput->GetConnected());
- if ((ClsidSourceFilter == __uuidof(COggSourceFilter)) || (ClsidSourceFilter == __uuidof(COggSplitterFilter))) {
- m_bTheoraMTSupport = false;
- } else if ((ClsidSourceFilter == __uuidof(CMpegSourceFilter)) || (ClsidSourceFilter == __uuidof(CMpegSplitterFilter))) {
- if (CComPtr<IBaseFilter> pFilter = GetFilterFromPin(m_pInput->GetConnected())) {
- if (CComQIPtr<IMpegSplitterFilter> MpegSplitterFilter = pFilter) {
- m_bIsEVO = (m_nCodecId == AV_CODEC_ID_VC1 && mpeg_ps == MpegSplitterFilter->GetMPEGType());
- }
- }
- }
-
- m_bReorderBFrame = true;
- m_pAVCodec = avcodec_find_decoder(m_nCodecId);
- CheckPointer(m_pAVCodec, VFW_E_UNSUPPORTED_VIDEO);
-
- m_pAVCtx = avcodec_alloc_context3(m_pAVCodec);
- CheckPointer(m_pAVCtx, E_POINTER);
-
- int nThreadNumber = m_nThreadNumber ? m_nThreadNumber : m_pCpuId->GetProcessorNumber() * 3 / 2;
- if ((nThreadNumber > 1) && IsMultiThreadSupported(m_nCodecId)) {
- FFSetThreadNumber(m_pAVCtx, m_nCodecId, (IsDXVASupported() || (m_nCodecId == AV_CODEC_ID_THEORA && !m_bTheoraMTSupport)) ? 1 : nThreadNumber);
- }
-
- m_pFrame = avcodec_alloc_frame();
- CheckPointer(m_pFrame, E_POINTER);
-
- m_h264RandomAccess.flush(m_pAVCtx->thread_count);
-
- if (pmt->formattype == FORMAT_VideoInfo) {
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
- m_pAVCtx->width = vih->bmiHeader.biWidth;
- m_pAVCtx->height = abs(vih->bmiHeader.biHeight);
- m_pAVCtx->codec_tag = vih->bmiHeader.biCompression;
- m_pAVCtx->bits_per_coded_sample = vih->bmiHeader.biBitCount;
- } else if (pmt->formattype == FORMAT_VideoInfo2) {
- VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)pmt->pbFormat;
- m_pAVCtx->width = vih2->bmiHeader.biWidth;
- m_pAVCtx->height = abs(vih2->bmiHeader.biHeight);
- m_pAVCtx->codec_tag = vih2->bmiHeader.biCompression;
- m_pAVCtx->bits_per_coded_sample = vih2->bmiHeader.biBitCount;
- } else if (pmt->formattype == FORMAT_MPEGVideo) {
- MPEG1VIDEOINFO* mpgv = (MPEG1VIDEOINFO*)pmt->pbFormat;
- m_pAVCtx->width = mpgv->hdr.bmiHeader.biWidth;
- m_pAVCtx->height = abs(mpgv->hdr.bmiHeader.biHeight);
- m_pAVCtx->codec_tag = mpgv->hdr.bmiHeader.biCompression;
- m_pAVCtx->bits_per_coded_sample = mpgv->hdr.bmiHeader.biBitCount;
- } else if (pmt->formattype == FORMAT_MPEG2Video) {
- MPEG2VIDEOINFO* mpg2v = (MPEG2VIDEOINFO*)pmt->pbFormat;
- m_pAVCtx->width = mpg2v->hdr.bmiHeader.biWidth;
- m_pAVCtx->height = abs(mpg2v->hdr.bmiHeader.biHeight);
- m_pAVCtx->codec_tag = mpg2v->hdr.bmiHeader.biCompression;
- m_pAVCtx->bits_per_coded_sample = mpg2v->hdr.bmiHeader.biBitCount;
-
- if (mpg2v->hdr.bmiHeader.biCompression == 0) {
- m_pAVCtx->codec_tag = pmt->subtype.Data1;
- } else if ((m_pAVCtx->codec_tag == MAKEFOURCC('a', 'v', 'c', '1')) || (m_pAVCtx->codec_tag == MAKEFOURCC('A', 'V', 'C', '1'))) {
- m_pAVCtx->nal_length_size = mpg2v->dwFlags;
- m_bReorderBFrame = (GetFileExtension() == _T(".avi")) ? true : false;
- } else if ((m_pAVCtx->codec_tag == MAKEFOURCC('m', 'p', '4', 'v')) || (m_pAVCtx->codec_tag == MAKEFOURCC('M', 'P', '4', 'V'))) {
- m_bReorderBFrame = false;
- }
- } else {
- return VFW_E_INVALIDMEDIATYPE;
- }
- m_nWidth = m_pAVCtx->width;
- m_nHeight = m_pAVCtx->height;
-
- if (m_pAVCtx->codec_tag == MAKEFOURCC('m', 'p', 'g', '2')) {
- m_pAVCtx->codec_tag = MAKEFOURCC('M', 'P', 'E', 'G');
- }
-
- if (m_nCodecId == AV_CODEC_ID_RV10 || m_nCodecId == AV_CODEC_ID_RV20 || m_nCodecId == AV_CODEC_ID_RV30 || m_nCodecId == AV_CODEC_ID_RV40) {
- m_bReorderBFrame = false;
- }
-
- m_pAVCtx->codec_id = m_nCodecId;
- m_pAVCtx->workaround_bugs = m_nWorkaroundBug;
- m_pAVCtx->error_concealment = m_nErrorConcealment;
- m_pAVCtx->err_recognition = AV_EF_CAREFUL;
- m_pAVCtx->idct_algo = FF_IDCT_AUTO;
- m_pAVCtx->skip_loop_filter = (AVDiscard)m_nDiscardMode;
- m_pAVCtx->dsp_mask = AV_CPU_FLAG_FORCE | m_pCpuId->GetFeatures();
-
- m_pAVCtx->debug_mv = 0;
-
- m_pAVCtx->opaque = this;
- m_pAVCtx->get_buffer = get_buffer;
-
- if (m_nCodecId == AV_CODEC_ID_H264) {
- m_pAVCtx->flags2 |= CODEC_FLAG2_SHOW_ALL;
- }
-
- AllocExtradata(m_pAVCtx, pmt);
- ConnectTo(m_pAVCtx);
- CalcAvgTimePerFrame();
-
- if (avcodec_open2(m_pAVCtx, m_pAVCodec, nullptr) < 0) {
- return VFW_E_INVALIDMEDIATYPE;
- }
-
- // if DXVA is supported in theory the file can still be incompatible
- bool bDXVAAvailableButUnused = IsDXVASupported();
- if (IsDXVASupported()) {
- do {
- m_bDXVACompatible = false;
-
- if (!DXVACheckFramesize(PictWidth(), PictHeight(), m_nPCIVendor, m_nPCIDevice)) { // check frame size
- break;
- }
-
- if (m_nCodecId == AV_CODEC_ID_H264) {
- if (m_nDXVA_SD && PictWidthRounded() < 1280) { // check "Disable DXVA for SD" option
- break;
- }
- int nCompat = FFH264CheckCompatibility(PictWidthRounded(), PictHeightRounded(), m_pAVCtx, (BYTE*)m_pAVCtx->extradata, m_pAVCtx->extradata_size, m_nPCIVendor, m_nPCIDevice, m_VideoDriverVersion);
- if (nCompat) {
- if (nCompat == DXVA_HIGH_BIT ||
- m_nDXVACheckCompatibility == 0 || // full check
- m_nDXVACheckCompatibility == 1 && nCompat != DXVA_UNSUPPORTED_LEVEL || // skip level check
- m_nDXVACheckCompatibility == 2 && nCompat != DXVA_TOO_MANY_REF_FRAMES) { // skip reference frame check
- break;
- }
- }
- } else if (m_nCodecId == AV_CODEC_ID_MPEG2VIDEO) {
- // DSP is disable for DXVA decoding (to keep default idct_permutation)
- m_pAVCtx->dsp_mask ^= AV_CPU_FLAG_FORCE;
- if (!MPEG2CheckCompatibility(m_pAVCtx, m_pFrame)) {
- break;
- }
- } else if (m_nCodecId == AV_CODEC_ID_WMV3) {
- if (PictWidth() <= 720) { // fixes color problem for some wmv files (profile <= MP@ML)
- break;
- }
- }
-
- m_bDXVACompatible = true;
- bDXVAAvailableButUnused = false;
- } while (false);
- }
-
- if (bDXVAAvailableButUnused) { // reset the threads count
- m_bUseDXVA = false;
- avcodec_close(m_pAVCtx);
- if ((nThreadNumber > 1) && IsMultiThreadSupported(m_nCodecId)) {
- FFSetThreadNumber(m_pAVCtx, m_nCodecId, nThreadNumber);
- }
- if (avcodec_open2(m_pAVCtx, m_pAVCodec, nullptr) < 0) {
- return VFW_E_INVALIDMEDIATYPE;
- }
- }
-
- BuildDXVAOutputFormat();
- }
- }
-
- HRESULT hr = __super::SetMediaType(direction, pmt);
-
- if (direction == PINDIR_INPUT) {
- // Compute the expected Pixel AR
- m_par.cx = m_arx * m_h;
- m_par.cy = m_ary * m_w;
- int gcd = GCD(m_par.cx, m_par.cy);
- if (gcd > 1) {
- m_par.cx /= gcd;
- m_par.cy /= gcd;
- }
- }
-
- return hr;
-}
-
-VIDEO_OUTPUT_FORMATS DXVAFormats[] = { // DXVA2
- {&MEDIASUBTYPE_NV12, 1, 12, 'avxd'},
- {&MEDIASUBTYPE_NV12, 1, 12, 'AVXD'},
- {&MEDIASUBTYPE_NV12, 1, 12, 'AVxD'},
- {&MEDIASUBTYPE_NV12, 1, 12, 'AvXD'}
-};
-
-VIDEO_OUTPUT_FORMATS SoftwareFormats1[] = { // Software
- {&MEDIASUBTYPE_NV12, 2, 12, '21VN'},
- {&MEDIASUBTYPE_YV12, 3, 12, '21VY'},
- {&MEDIASUBTYPE_YUY2, 1, 16, '2YUY'},
-};
-
-VIDEO_OUTPUT_FORMATS SoftwareFormats2[] = { // Software
- {&MEDIASUBTYPE_RGB32, 1, 32, BI_RGB},
-};
-
-bool CMPCVideoDecFilter::IsDXVASupported()
-{
- if (m_nCodecNb != -1) {
- // Does the codec suppport DXVA ?
- if (ffCodecs[m_nCodecNb].DXVAModes != nullptr) {
- // Enabled by user ?
- if (m_bUseDXVA) {
- // is the file compatible ?
- if (m_bDXVACompatible) {
- return true;
- }
- }
- }
- }
- return false;
-}
-
-void CMPCVideoDecFilter::BuildDXVAOutputFormat()
-{
- SAFE_DELETE_ARRAY(m_pVideoOutputFormat);
-
- m_nVideoOutputCount = IsDXVASupported() ? ffCodecs[m_nCodecNb].DXVAModeCount() + _countof(DXVAFormats) : 0;
- if (m_bUseFFmpeg) {
- if (!(m_pAVCtx->width & 1 || m_pAVCtx->height & 1)) { // Do not use NV12, YV12 and YUY2 if width or height is not even
- m_nVideoOutputCount += _countof(SoftwareFormats1);
- }
- m_nVideoOutputCount += _countof(SoftwareFormats2);
- }
- m_pVideoOutputFormat = DEBUG_NEW VIDEO_OUTPUT_FORMATS[m_nVideoOutputCount];
-
- int nPos = 0;
- if (IsDXVASupported()) {
- // Dynamic DXVA media types for DXVA1
- for (nPos = 0; nPos < ffCodecs[m_nCodecNb].DXVAModeCount(); nPos++) {
- m_pVideoOutputFormat[nPos].subtype = ffCodecs[m_nCodecNb].DXVAModes->Decoder[nPos];
- m_pVideoOutputFormat[nPos].biCompression = 'avxd';
- m_pVideoOutputFormat[nPos].biBitCount = 12;
- m_pVideoOutputFormat[nPos].biPlanes = 1;
- }
-
- // Static list for DXVA2
- memcpy(&m_pVideoOutputFormat[nPos], DXVAFormats, sizeof(DXVAFormats));
- nPos += _countof(DXVAFormats);
- }
- // Software rendering
- if (m_bUseFFmpeg) {
- if (!(m_pAVCtx->width & 1 || m_pAVCtx->height & 1)) { // Do not use NV12, YV12 and YUY2 if width or height is not even
- memcpy(&m_pVideoOutputFormat[nPos], SoftwareFormats1, sizeof(SoftwareFormats1));
- nPos += _countof(SoftwareFormats1);
- }
- memcpy(&m_pVideoOutputFormat[nPos], SoftwareFormats2, sizeof(SoftwareFormats2));
- }
-}
-
-int CMPCVideoDecFilter::GetPicEntryNumber()
-{
- if (IsDXVASupported()) {
- return ffCodecs[m_nCodecNb].DXVAModes->PicEntryNumber;
- } else {
- return 0;
- }
-}
-
-void CMPCVideoDecFilter::GetOutputFormats(int& nNumber, VIDEO_OUTPUT_FORMATS** ppFormats)
-{
- nNumber = m_nVideoOutputCount;
- *ppFormats = m_pVideoOutputFormat;
-}
-
-void CMPCVideoDecFilter::AllocExtradata(AVCodecContext* pAVCtx, const CMediaType* pmt)
-{
- // code from LAV ...
- // Process Extradata
- BYTE* extra = nullptr;
- unsigned int extralen = 0;
- getExtraData((const BYTE*)pmt->Format(), pmt->FormatType(), pmt->FormatLength(), nullptr, &extralen);
-
- BOOL bH264avc = FALSE;
- if (extralen > 0) {
- TRACE(_T("CMPCVideoDecFilter::AllocExtradata() : processing extradata of %d bytes\n"), extralen);
- // Reconstruct AVC1 extradata format
- if (pmt->formattype == FORMAT_MPEG2Video && (m_pAVCtx->codec_tag == MAKEFOURCC('a', 'v', 'c', '1') || m_pAVCtx->codec_tag == MAKEFOURCC('A', 'V', 'C', '1') || m_pAVCtx->codec_tag == MAKEFOURCC('C', 'C', 'V', '1'))) {
- MPEG2VIDEOINFO* mp2vi = (MPEG2VIDEOINFO*)pmt->Format();
- extralen += 7;
- extra = (uint8_t*)av_mallocz(extralen + FF_INPUT_BUFFER_PADDING_SIZE);
- extra[0] = 1;
- extra[1] = (BYTE)mp2vi->dwProfile;
- extra[2] = 0;
- extra[3] = (BYTE)mp2vi->dwLevel;
- extra[4] = (BYTE)(mp2vi->dwFlags ? mp2vi->dwFlags : 2) - 1;
-
- // Actually copy the metadata into our new buffer
- unsigned int actual_len;
- getExtraData((const BYTE*)pmt->Format(), pmt->FormatType(), pmt->FormatLength(), extra + 6, &actual_len);
-
- // Count the number of SPS/PPS in them and set the length
- // We'll put them all into one block and add a second block with 0 elements afterwards
- // The parsing logic does not care what type they are, it just expects 2 blocks.
- BYTE* p = extra + 6, *end = extra + 6 + actual_len;
- BOOL bSPS = FALSE, bPPS = FALSE;
- int count = 0;
- while (p + 1 < end) {
- unsigned len = (((unsigned)p[0] << 8) | p[1]) + 2;
- if (p + len > end) {
- break;
- }
- if ((p[2] & 0x1F) == 7) {
- bSPS = TRUE;
- }
- if ((p[2] & 0x1F) == 8) {
- bPPS = TRUE;
- }
- count++;
- p += len;
- }
- extra[5] = count;
- extra[extralen - 1] = 0;
-
- bH264avc = TRUE;
- if (!bSPS) {
- TRACE(_T("CMPCVideoDecFilter::AllocExtradata() : AVC1 extradata doesn't contain a SPS, setting thread_count = 1\n"));
- m_pAVCtx->thread_count = 1;
- }
- } else {
- // Just copy extradata for other formats
- extra = (uint8_t*)av_mallocz(extralen + FF_INPUT_BUFFER_PADDING_SIZE);
- getExtraData((const BYTE*)pmt->Format(), pmt->FormatType(), pmt->FormatLength(), extra, nullptr);
- }
- // Hack to discard invalid MP4 metadata with AnnexB style video
- if (m_nCodecId == AV_CODEC_ID_H264 && !bH264avc && extra[0] == 1) {
- av_freep(&extra);
- extralen = 0;
- }
- m_pAVCtx->extradata = extra;
- m_pAVCtx->extradata_size = (int)extralen;
- }
-}
-
-HRESULT CMPCVideoDecFilter::CompleteConnect(PIN_DIRECTION direction, IPin* pReceivePin)
-{
- LOG(_T("CMPCVideoDecFilter::CompleteConnect"));
-
- if (direction == PINDIR_INPUT && m_pOutput->IsConnected()) {
- ReconnectOutput(m_nWidth, m_nHeight);
- } else if (direction == PINDIR_OUTPUT) {
- if (IsDXVASupported()) {
- if (m_nDXVAMode == MODE_DXVA1) {
- m_pDXVADecoder->ConfigureDXVA1();
- } else if (SUCCEEDED(ConfigureDXVA2(pReceivePin)) && SUCCEEDED(SetEVRForDXVA2(pReceivePin))) {
- m_nDXVAMode = MODE_DXVA2;
- }
- }
- if (m_nDXVAMode == MODE_SOFTWARE && (!m_bUseFFmpeg || !FFSoftwareCheckCompatibility(m_pAVCtx))) {
- return VFW_E_INVALIDMEDIATYPE;
- }
-
- CLSID ClsidSourceFilter = GetCLSID(m_pInput->GetConnected());
- if ((ClsidSourceFilter == __uuidof(CMpegSourceFilter)) || (ClsidSourceFilter == __uuidof(CMpegSplitterFilter))) {
- m_bReorderBFrame = false;
- }
- }
-
- return __super::CompleteConnect(direction, pReceivePin);
-}
-
-HRESULT CMPCVideoDecFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
-{
- if (UseDXVA2()) {
- HRESULT hr;
- ALLOCATOR_PROPERTIES Actual;
-
- if (m_pInput->IsConnected() == FALSE) {
- return E_UNEXPECTED;
- }
-
- pProperties->cBuffers = GetPicEntryNumber();
-
- if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
- return hr;
- }
-
- return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR;
- } else {
- return __super::DecideBufferSize(pAllocator, pProperties);
- }
-}
-
-HRESULT CMPCVideoDecFilter::BeginFlush()
-{
- return __super::BeginFlush();
-}
-
-HRESULT CMPCVideoDecFilter::EndFlush()
-{
- CAutoLock cAutoLock(&m_csReceive);
- return __super::EndFlush();
-}
-
-HRESULT CMPCVideoDecFilter::NewSegment(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, double dRate)
-{
- CAutoLock cAutoLock(&m_csReceive);
-
- if (m_pAVCtx) {
- avcodec_flush_buffers(m_pAVCtx);
- }
-
- if (m_pDXVADecoder) {
- m_pDXVADecoder->Flush();
- }
-
- m_nPosB = 1;
- ZeroMemory(&m_BFrames, sizeof(m_BFrames));
- m_rtLastStart = 0;
- m_nCountEstimated = 0;
- m_dRate = dRate;
-
- ResetBuffer();
-
- m_h264RandomAccess.flush(m_pAVCtx->thread_count);
-
- m_bWaitingForKeyFrame = TRUE;
-
- m_rtPrevStop = 0;
-
- rm.video_after_seek = true;
- m_rtStart = rtStart;
-
- return __super::NewSegment(rtStart, rtStop, dRate);
-}
-
-HRESULT CMPCVideoDecFilter::EndOfStream()
-{
- CAutoLock cAutoLock(&m_csReceive);
-
-#if HAS_FFMPEG_VIDEO_DECODERS
- if (m_nDXVAMode == MODE_SOFTWARE) {
- REFERENCE_TIME rtStart = 0, rtStop = 0;
- SoftwareDecode(nullptr, nullptr, 0, rtStart, rtStop);
- } else
-#endif
- if (m_nDXVAMode == MODE_DXVA2) { // TODO - need to check DXVA1 on WinXP
- m_pDXVADecoder->EndOfStream();
- }
-
- return __super::EndOfStream();
-}
-
-HRESULT CMPCVideoDecFilter::BreakConnect(PIN_DIRECTION dir)
-{
- if (dir == PINDIR_INPUT) {
- Cleanup();
- }
-
- return __super::BreakConnect(dir);
-}
-
-void CMPCVideoDecFilter::SetTypeSpecificFlags(IMediaSample* pMS)
-{
- if (CComQIPtr<IMediaSample2> pMS2 = pMS) {
- AM_SAMPLE2_PROPERTIES props;
- if (SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props))) {
- props.dwTypeSpecificFlags &= ~0x7f;
-
- m_nFrameType = PICT_BOTTOM_FIELD;
- if ((m_interlacedFlag == MPCVC_INTERLACED_AUTO && !m_pFrame->interlaced_frame)
- || m_interlacedFlag == MPCVC_INTERLACED_PROGRESSIVE) {
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
- m_nFrameType = PICT_FRAME;
- } else {
- if ((m_interlacedFlag == MPCVC_INTERLACED_AUTO && m_pFrame->top_field_first)
- || m_interlacedFlag == MPCVC_INTERLACED_TOP_FIELD_FIRST) {
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_FIELD1FIRST;
- m_nFrameType = PICT_TOP_FIELD;
- }
- }
-
- switch (m_pFrame->pict_type) {
- case AV_PICTURE_TYPE_I:
- case AV_PICTURE_TYPE_SI:
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_I_SAMPLE;
- break;
- case AV_PICTURE_TYPE_P:
- case AV_PICTURE_TYPE_SP:
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_P_SAMPLE;
- break;
- default:
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_B_SAMPLE;
- break;
- }
-
- pMS2->SetProperties(sizeof(props), (BYTE*)&props);
- }
- }
-}
-
-#if HAS_FFMPEG_VIDEO_DECODERS
-unsigned __int64 CMPCVideoDecFilter::GetCspFromMediaType(GUID& subtype)
-{
- if (subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV || subtype == MEDIASUBTYPE_YV12) {
- return (FF_CSP_420P | FF_CSP_FLAGS_YUV_ADJ);
- } else if (subtype == MEDIASUBTYPE_NV12) {
- return FF_CSP_NV12;
- } else if (subtype == MEDIASUBTYPE_RGB32) {
- return FF_CSP_RGB32;
- } else if (subtype == MEDIASUBTYPE_YUY2) {
- return FF_CSP_YUY2;
- }
-
- ASSERT(FALSE);
- return FF_CSP_NULL;
-}
-
-void CMPCVideoDecFilter::InitSwscale()
-{
- if (m_pSwsContext == nullptr) {
- BITMAPINFOHEADER bihOut;
- ExtractBIH(&m_pOutput->CurrentMediaType(), &bihOut);
-
- int sws_Flags = SWS_BILINEAR | SWS_FULL_CHR_H_INT | SWS_FULL_CHR_H_INP | SWS_ACCURATE_RND;
-
- m_nOutCsp = GetCspFromMediaType(m_pOutput->CurrentMediaType().subtype);
-
- PixelFormat pix_fmt = csp_ffdshow2lavc(csp_lavc2ffdshow(m_pAVCtx->pix_fmt));
- if (pix_fmt == PIX_FMT_NB) {
- pix_fmt = m_pAVCtx->pix_fmt;
- }
-
- m_pSwsContext = sws_getCachedContext(
- nullptr,
- m_pAVCtx->width,
- m_pAVCtx->height,
- pix_fmt,
- m_pAVCtx->width,
- m_pAVCtx->height,
- csp_ffdshow2lavc(m_nOutCsp),
- sws_Flags | SWS_PRINT_INFO,
- nullptr,
- nullptr,
- nullptr);
-
- m_nSwOutBpp = bihOut.biBitCount;
- m_pOutSize.cx = bihOut.biWidth;
- m_pOutSize.cy = abs(bihOut.biHeight);
-
- int* inv_tbl = nullptr, *tbl = nullptr;
- int srcRange, dstRange, brightness, contrast, saturation;
- int ret = sws_getColorspaceDetails(m_pSwsContext, &inv_tbl, &srcRange, &tbl, &dstRange, &brightness, &contrast, &saturation);
- if (ret >= 0) {
- sws_setColorspaceDetails(m_pSwsContext, sws_getCoefficients((PictWidthRounded() > 768) ? SWS_CS_ITU709 : SWS_CS_ITU601), srcRange, tbl, dstRange, brightness, contrast, saturation);
- }
- }
-}
-
-#define RM_SKIP_BITS(n) (buffer <<= n)
-#define RM_SHOW_BITS(n) ((buffer) >> (32 - (n)))
-
-static int rm_fix_timestamp(uint8_t* buf, int64_t timestamp, enum AVCodecID nCodecId, int64_t* kf_base, int* kf_pts)
-{
- uint8_t* s = buf + 1 + (*buf + 1) * 8;
- uint32_t buffer = (s[0] << 24) + (s[1] << 16) + (s[2] << 8) + s[3];
- uint32_t kf = timestamp;
- int pict_type;
- uint32_t orig_kf;
-
- if (nCodecId == AV_CODEC_ID_RV30) {
- RM_SKIP_BITS(3);
- pict_type = RM_SHOW_BITS(2);
- RM_SKIP_BITS(2 + 7);
- } else {
- RM_SKIP_BITS(1);
- pict_type = RM_SHOW_BITS(2);
- RM_SKIP_BITS(2 + 7 + 3);
- }
- orig_kf = kf = RM_SHOW_BITS(13); // kf= 2*RM_SHOW_BITS(12);
- if (pict_type <= 1) {
- // I frame, sync timestamps:
- *kf_base = (int64_t)timestamp - kf;
- kf = timestamp;
- } else {
- // P/B frame, merge timestamps:
- int64_t tmp = (int64_t)timestamp - *kf_base;
- kf |= tmp & (~0x1fff); // combine with packet timestamp
- if (kf < tmp - 4096) {
- kf += 8192;
- } else if (kf > tmp + 4096) { // workaround wrap-around problems
- kf -= 8192;
- }
- kf += *kf_base;
- }
- if (pict_type != 3) { // P || I frame -> swap timestamps
- uint32_t tmp = kf;
- kf = *kf_pts;
- *kf_pts = tmp;
- }
-
- return kf;
-}
-
-static int64_t process_rv_timestamp(RMDemuxContext* rm, enum AVCodecID nCodecId, uint8_t* buf, int64_t timestamp)
-{
- if (rm->video_after_seek) {
- rm->kf_base = 0;
- rm->kf_pts = timestamp;
- rm->video_after_seek = false;
- }
- return rm_fix_timestamp(buf, timestamp, nCodecId, &rm->kf_base, &rm->kf_pts);
-}
-
-void copyPlane(BYTE* dstp, stride_t dst_pitch, const BYTE* srcp, stride_t src_pitch, int row_size, int height, bool flip = false)
-{
- if (!flip) {
- for (int y = height; y > 0; --y) {
- memcpy(dstp, srcp, row_size);
- dstp += dst_pitch;
- srcp += src_pitch;
- }
- } else {
- dstp += dst_pitch * (height - 1);
- for (int y = height; y > 0; --y) {
- memcpy(dstp, srcp, row_size);
- dstp -= dst_pitch;
- srcp += src_pitch;
- }
- }
-}
-
-HRESULT CMPCVideoDecFilter::SoftwareDecode(IMediaSample* pIn, BYTE* pDataIn, int nSize, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop)
-{
- HRESULT hr = S_OK;
- int got_picture;
- int used_bytes;
- BOOL bFlush = (pDataIn == nullptr);
-
- AVPacket avpkt;
- av_init_packet(&avpkt);
-
- if (!bFlush && m_nCodecId == AV_CODEC_ID_H264) {
- if (!m_h264RandomAccess.searchRecoveryPoint(m_pAVCtx, pDataIn, nSize)) {
- return S_OK;
- }
- }
-
- while (nSize > 0 || bFlush) {
- if (!bFlush) {
- if (nSize + FF_INPUT_BUFFER_PADDING_SIZE > m_nFFBufferSize) {
- m_nFFBufferSize = nSize + FF_INPUT_BUFFER_PADDING_SIZE;
- m_pFFBuffer = (BYTE*)av_realloc(m_pFFBuffer, m_nFFBufferSize);
- if (!m_pFFBuffer) {
- m_nFFBufferSize = 0;
- return E_FAIL;
- }
- }
-
- // Required number of additionally allocated bytes at the end of the input bitstream for decoding.
- // This is mainly needed because some optimized bitstream readers read
- // 32 or 64 bit at once and could read over the end.
- // Note: If the first 23 bits of the additional bytes are not 0, then damaged
- // MPEG bitstreams could cause overread and segfault.
- memcpy(m_pFFBuffer, pDataIn, nSize);
- ZeroMemory(m_pFFBuffer + nSize, FF_INPUT_BUFFER_PADDING_SIZE);
-
- avpkt.data = m_pFFBuffer;
- avpkt.size = nSize;
- avpkt.pts = rtStart;
- avpkt.dts = rtStop;
- avpkt.flags = AV_PKT_FLAG_KEY;
- } else {
- avpkt.data = nullptr;
- avpkt.size = 0;
- }
- used_bytes = avcodec_decode_video2(m_pAVCtx, m_pFrame, &got_picture, &avpkt);
-
- if (used_bytes < 0) {
- return S_OK;
- }
-
- // Comment from LAV Video code:
- // When Frame Threading, we won't know how much data has been consumed, so it by default eats everything.
- // In addition, if no data got consumed, and no picture was extracted, the frame probably isn't all that useufl.
- // The MJPEB decoder is somewhat buggy and doesn't let us know how much data was consumed really...
- if ((m_pAVCtx->active_thread_type & FF_THREAD_FRAME || (!got_picture && used_bytes == 0)) || m_nCodecId == AV_CODEC_ID_MJPEGB || bFlush) {
- nSize = 0;
- } else {
- nSize -= used_bytes;
- pDataIn += used_bytes;
- }
-
- if (m_nCodecId == AV_CODEC_ID_H264) {
- m_h264RandomAccess.judgeFrameUsability(m_pFrame, &got_picture);
- } else if (m_nCodecId == AV_CODEC_ID_VC1 || m_nCodecId == AV_CODEC_ID_RV30 || m_nCodecId == AV_CODEC_ID_RV40) {
- if (m_bWaitingForKeyFrame && got_picture) {
- if (m_pFrame->key_frame) {
- m_bWaitingForKeyFrame = FALSE;
- } else {
- got_picture = 0;
- }
- }
- }
-
- if (!got_picture || !m_pFrame->data[0]) {
- bFlush = FALSE;
- continue;
- }
-
- if ((pIn && pIn->IsPreroll() == S_OK) || rtStart < 0) {
- return S_OK;
- }
-
- if (!m_bFrame_repeat_pict && m_pFrame->repeat_pict) {
- m_bFrame_repeat_pict = true;
- }
-
- CComPtr<IMediaSample> pOut;
- BYTE* pDataOut = nullptr;
-
- UpdateAspectRatio();
- if (FAILED(hr = GetDeliveryBuffer(m_pAVCtx->width, m_pAVCtx->height, &pOut)) || FAILED(hr = pOut->GetPointer(&pDataOut))) {
- return hr;
- }
-
- if (m_nCodecId == AV_CODEC_ID_THEORA || (m_nCodecId == AV_CODEC_ID_VP8 && m_rtAvrTimePerFrame == 10000)) { // need more tests
- rtStart = m_pFrame->pkt_pts;
- rtStop = m_pFrame->pkt_dts;
- } else if ((m_nCodecId == AV_CODEC_ID_RV10 || m_nCodecId == AV_CODEC_ID_RV20) && m_pFrame->pict_type == AV_PICTURE_TYPE_B) {
- rtStart = m_rtPrevStop;
- rtStop = rtStart + m_rtAvrTimePerFrame;
- } else if ((m_nCodecId == AV_CODEC_ID_RV30 || m_nCodecId == AV_CODEC_ID_RV40) && avpkt.data) {
- rtStart = (rtStart == _I64_MIN) ? m_rtPrevStop : (10000i64 * process_rv_timestamp(&rm, m_nCodecId, avpkt.data, (rtStart + m_rtStart) / 10000) - m_rtStart);
- rtStop = rtStart + m_rtAvrTimePerFrame;
- } else if (!(m_nCodecId == AV_CODEC_ID_VC1 && m_bFrame_repeat_pict && m_rtAvrTimePerFrame == 333666)) {
- rtStart = m_pFrame->reordered_opaque;
- rtStop = m_pFrame->reordered_opaque2;
- }
-
- m_rtPrevStop = rtStop;
-
- ReorderBFrames(rtStart, rtStop);
-
- pOut->SetTime(&rtStart, &rtStop);
- pOut->SetMediaTime(nullptr, nullptr);
-
- if (m_pSwsContext == nullptr) {
- InitSwscale();
- }
- if (m_pSwsContext != nullptr) {
-
- int outStride = m_pOutSize.cx;
- BYTE* outData = pDataOut;
-
- // From LAVVideo ...
- // Check if we have proper pixel alignment and the dst memory is actually aligned
- if (FFALIGN(outStride, 16) != outStride || ((uintptr_t)pDataOut % 16u)) {
- outStride = FFALIGN(outStride, 16);
- int requiredSize = (outStride * m_pAVCtx->height * m_nSwOutBpp) << 3;
- if (requiredSize > m_nAlignedFFBufferSize) {
- av_freep(&m_pAlignedFFBuffer);
- m_nAlignedFFBufferSize = requiredSize;
- m_pAlignedFFBuffer = (BYTE*)av_malloc(m_nAlignedFFBufferSize + FF_INPUT_BUFFER_PADDING_SIZE);
- }
- outData = m_pAlignedFFBuffer;
- }
-
- uint8_t* dst[4] = {nullptr, nullptr, nullptr, nullptr};
- stride_t dstStride[4] = {0, 0, 0, 0};
- const TcspInfo* outcspInfo = csp_getInfo(m_nOutCsp);
-
- if (m_nOutCsp == FF_CSP_YUY2 || m_nOutCsp == FF_CSP_RGB32) {
- dst[0] = outData;
- dstStride[0] = (m_nSwOutBpp >> 3) * (outStride);
- } else {
- for (unsigned int i = 0; i < outcspInfo->numPlanes; i++) {
- dstStride[i] = outStride >> outcspInfo->shiftX[i];
- dst[i] = !i ? outData : dst[i - 1] + dstStride[i - 1] * (m_pOutSize.cy >> outcspInfo->shiftY[i - 1]);
- }
-
- if (m_nOutCsp & FF_CSP_420P) {
- std::swap(dst[1], dst[2]);
- }
- }
-
- sws_scale(m_pSwsContext, m_pFrame->data, m_pFrame->linesize, 0, m_pAVCtx->height, dst, dstStride);
-
- if (outData != pDataOut) {
- if (m_nOutCsp & FF_CSP_420P) {
- std::swap(dst[1], dst[2]);
- }
- int rowsize = 0, height = 0;
- for (unsigned int i = 0; i < outcspInfo->numPlanes; i++) {
- rowsize = (m_pOutSize.cx * outcspInfo->Bpp) >> outcspInfo->shiftX[i];
- height = m_pAVCtx->height >> outcspInfo->shiftY[i];
- copyPlane(pDataOut, rowsize, dst[i], (outStride * outcspInfo->Bpp) >> outcspInfo->shiftX[i], rowsize, height, (m_nOutCsp == FF_CSP_RGB32));
- pDataOut += rowsize * height;
- }
- }
- }
-
-#if defined(_DEBUG) && 0
- static REFERENCE_TIME rtLast = 0;
- TRACE(_T("Deliver : %10I64d - %10I64d (%10I64d) {%10I64d}\n"), rtStart, rtStop,
- rtStop - rtStart, rtStart - rtLast);
- rtLast = rtStart;
-#endif
-
- SetTypeSpecificFlags(pOut);
- hr = m_pOutput->Deliver(pOut);
- }
-
- return hr;
-}
-
-#endif /* HAS_FFMPEG_VIDEO_DECODERS */
-
-bool CMPCVideoDecFilter::FindPicture(int nIndex, int nStartCode)
-{
- DWORD dw = 0;
-
- for (int i = 0; i < m_nFFBufferPos - nIndex; i++) {
- dw = (dw << 8) + m_pFFBuffer[i + nIndex];
- if (i >= 4) {
- if (m_nFFPicEnd == INT_MIN) {
- if ((dw & 0xffffff00) == 0x00000100 &&
- (dw & 0x000000FF) == (DWORD)nStartCode) {
- m_nFFPicEnd = i + nIndex - 3;
- }
- } else {
- if ((dw & 0xffffff00) == 0x00000100 &&
- ((dw & 0x000000FF) == (DWORD)nStartCode || (dw & 0x000000FF) == 0xB3)) {
- m_nFFPicEnd = i + nIndex - 3;
- return true;
- }
- }
- }
-
- }
-
- return false;
-}
-
-void CMPCVideoDecFilter::ResetBuffer()
-{
- m_nFFBufferPos = 0;
- m_nFFPicEnd = INT_MIN;
-
- for (int i = 0; i < MAX_BUFF_TIME; i++) {
- m_FFBufferTime[i].nBuffPos = INT_MIN;
- m_FFBufferTime[i].rtStart = _I64_MIN;
- m_FFBufferTime[i].rtStop = _I64_MIN;
- }
-}
-
-void CMPCVideoDecFilter::PushBufferTime(int nPos, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop)
-{
- for (int i = 0; i < MAX_BUFF_TIME; i++) {
- if (m_FFBufferTime[i].nBuffPos == INT_MIN) {
- m_FFBufferTime[i].nBuffPos = nPos;
- m_FFBufferTime[i].rtStart = rtStart;
- m_FFBufferTime[i].rtStop = rtStop;
- break;
- }
- }
-}
-
-void CMPCVideoDecFilter::PopBufferTime(int nPos)
-{
- int nDestPos = 0;
- int i = 0;
-
- // Shift buffer time list
- while (i < MAX_BUFF_TIME && m_FFBufferTime[i].nBuffPos != INT_MIN) {
- if (m_FFBufferTime[i].nBuffPos >= nPos) {
- m_FFBufferTime[nDestPos].nBuffPos = m_FFBufferTime[i].nBuffPos - nPos;
- m_FFBufferTime[nDestPos].rtStart = m_FFBufferTime[i].rtStart;
- m_FFBufferTime[nDestPos].rtStop = m_FFBufferTime[i].rtStop;
- nDestPos++;
- }
- i++;
- }
-
- // Free unused slots
- for (i = nDestPos; i < MAX_BUFF_TIME; i++) {
- m_FFBufferTime[i].nBuffPos = INT_MIN;
- m_FFBufferTime[i].rtStart = _I64_MIN;
- m_FFBufferTime[i].rtStop = _I64_MIN;
- }
-}
-
-bool CMPCVideoDecFilter::AppendBuffer(BYTE* pDataIn, int nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
-{
- if (rtStart != _I64_MIN) {
- PushBufferTime(m_nFFBufferPos, rtStart, rtStop);
- }
-
- if (m_nFFBufferPos + nSize + FF_INPUT_BUFFER_PADDING_SIZE > m_nFFBufferSize) {
- m_nFFBufferSize = m_nFFBufferPos + nSize + FF_INPUT_BUFFER_PADDING_SIZE;
- m_pFFBuffer = (BYTE*)av_realloc(m_pFFBuffer, m_nFFBufferSize);
- }
-
- memcpy(m_pFFBuffer + m_nFFBufferPos, pDataIn, nSize);
-
- m_nFFBufferPos += nSize;
-
- return true;
-}
-
-void CMPCVideoDecFilter::ShrinkBuffer()
-{
- int nRemaining = m_nFFBufferPos - m_nFFPicEnd;
-
- ASSERT(m_nFFPicEnd != INT_MIN);
-
- PopBufferTime(m_nFFPicEnd);
- memcpy(m_pFFBuffer, m_pFFBuffer + m_nFFPicEnd, nRemaining);
- m_nFFBufferPos = nRemaining;
-
- m_nFFPicEnd = (m_pFFBuffer[3] == 0x00) ? 0 : INT_MIN;
-}
-
-HRESULT CMPCVideoDecFilter::Transform(IMediaSample* pIn)
-{
- CAutoLock cAutoLock(&m_csReceive);
- HRESULT hr;
- BYTE* pDataIn;
- int nSize;
- REFERENCE_TIME rtStart = _I64_MIN;
- REFERENCE_TIME rtStop = _I64_MIN;
-
- if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
- return hr;
- }
-
- nSize = pIn->GetActualDataLength();
- hr = pIn->GetTime(&rtStart, &rtStop);
-
- if (FAILED(hr)) {
- rtStart = rtStop = _I64_MIN;
- }
-
- if (m_nDXVAMode == MODE_SOFTWARE || (m_nCodecId == AV_CODEC_ID_VC1 && !m_bIsEVO)) {
- UpdateFrameTime(rtStart, rtStop, m_bFrame_repeat_pict);
- }
-
- m_pAVCtx->reordered_opaque = rtStart;
- m_pAVCtx->reordered_opaque2 = rtStop;
-
- if (m_pAVCtx->has_b_frames) {
- m_BFrames[m_nPosB].rtStart = rtStart;
- m_BFrames[m_nPosB].rtStop = rtStop;
- m_nPosB = 1 - m_nPosB;
- }
-
- switch (m_nDXVAMode) {
-#if HAS_FFMPEG_VIDEO_DECODERS
- case MODE_SOFTWARE:
- hr = SoftwareDecode(pIn, pDataIn, nSize, rtStart, rtStop);
- break;
-#endif
- case MODE_DXVA1:
- case MODE_DXVA2:
- CheckPointer(m_pDXVADecoder, E_UNEXPECTED);
- UpdateAspectRatio();
-
- // Change aspect ratio for DXVA1
- if ((m_nDXVAMode == MODE_DXVA1) &&
- ReconnectOutput(PictWidthRounded(), PictHeightRounded(), true, PictWidth(), PictHeight()) == S_OK) {
- m_pDXVADecoder->ConfigureDXVA1();
- }
-
- if (m_pAVCtx->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
- AppendBuffer(pDataIn, nSize, rtStart, rtStop);
- hr = S_OK;
-
- while (FindPicture(max(m_nFFBufferPos - nSize - 4, 0), 0x00)) {
- if (m_FFBufferTime[0].nBuffPos != INT_MIN && m_FFBufferTime[0].nBuffPos < m_nFFPicEnd) {
- rtStart = m_FFBufferTime[0].rtStart;
- rtStop = m_FFBufferTime[0].rtStop;
- } else {
- rtStart = rtStop = _I64_MIN;
- }
- hr = m_pDXVADecoder->DecodeFrame(m_pFFBuffer, m_nFFPicEnd, rtStart, rtStop);
- ShrinkBuffer();
- }
- } else {
- hr = m_pDXVADecoder->DecodeFrame(pDataIn, nSize, rtStart, rtStop);
- }
- break;
- default:
- ASSERT(FALSE);
- hr = E_UNEXPECTED;
- }
-
- return hr;
-}
-
-void CMPCVideoDecFilter::UpdateAspectRatio()
-{
- if (m_nARMode && m_pAVCtx && (m_pAVCtx->sample_aspect_ratio.num > 0) && (m_pAVCtx->sample_aspect_ratio.den > 0)) {
- CSize PAR(m_pAVCtx->sample_aspect_ratio.num, m_pAVCtx->sample_aspect_ratio.den);
- if (m_par != PAR) {
- m_par = PAR;
- CSize aspect(m_nWidth * PAR.cx, m_nHeight * PAR.cy);
- int gcd = GCD(aspect.cx, aspect.cy);
- if (gcd > 1) {
- aspect.cx /= gcd;
- aspect.cy /= gcd;
- }
- SetAspect(aspect);
- }
- }
-}
-
-void CMPCVideoDecFilter::ReorderBFrames(REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop)
-{
- // Re-order B-frames if needed
- if (m_pAVCtx->has_b_frames && m_bReorderBFrame) {
- rtStart = m_BFrames [m_nPosB].rtStart;
- rtStop = m_BFrames [m_nPosB].rtStop;
- }
-}
-
-void CMPCVideoDecFilter::FillInVideoDescription(DXVA2_VideoDesc* pDesc)
-{
- ZeroMemory(pDesc, sizeof(DXVA2_VideoDesc));
- pDesc->SampleWidth = PictWidthRounded();
- pDesc->SampleHeight = PictHeightRounded();
- pDesc->Format = D3DFMT_A8R8G8B8;
- pDesc->UABProtectionLevel = 1;
-}
-
-BOOL CMPCVideoDecFilter::IsSupportedDecoderMode(const GUID& mode)
-{
- if (IsDXVASupported()) {
- for (int i = 0; i < MAX_SUPPORTED_MODE; i++) {
- if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == GUID_NULL) {
- break;
- } else if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == mode) {
- return true;
- }
- }
- }
-
- return false;
-}
-
-BOOL CMPCVideoDecFilter::IsSupportedDecoderConfig(const D3DFORMAT nD3DFormat, const DXVA2_ConfigPictureDecode& config, bool& bIsPrefered)
-{
- bool bRet = false;
-
- bRet = (nD3DFormat == MAKEFOURCC('N', 'V', '1', '2') || nD3DFormat == MAKEFOURCC('I', 'M', 'C', '3'));
-
- bIsPrefered = (config.ConfigBitstreamRaw == ffCodecs[m_nCodecNb].DXVAModes->PreferedConfigBitstream);
- LOG(_T("IsSupportedDecoderConfig 0x%08x %d"), nD3DFormat, bRet);
- return bRet;
-}
-
-HRESULT CMPCVideoDecFilter::FindDXVA2DecoderConfiguration(IDirectXVideoDecoderService* pDecoderService,
- const GUID& guidDecoder,
- DXVA2_ConfigPictureDecode* pSelectedConfig,
- BOOL* pbFoundDXVA2Configuration)
-{
- HRESULT hr = S_OK;
- UINT cFormats = 0;
- UINT cConfigurations = 0;
- bool bIsPrefered = false;
-
- D3DFORMAT* pFormats = nullptr; // size = cFormats
- DXVA2_ConfigPictureDecode* pConfig = nullptr; // size = cConfigurations
-
- // Find the valid render target formats for this decoder GUID.
- hr = pDecoderService->GetDecoderRenderTargets(guidDecoder, &cFormats, &pFormats);
- LOG(_T("GetDecoderRenderTargets => %d"), cFormats);
-
- if (SUCCEEDED(hr)) {
- // Look for a format that matches our output format.
- for (UINT iFormat = 0; iFormat < cFormats; iFormat++) {
- LOG(_T("Try to negociate => 0x%08x"), pFormats[iFormat]);
-
- // Fill in the video description. Set the width, height, format, and frame rate.
- FillInVideoDescription(&m_VideoDesc); // Private helper function.
- m_VideoDesc.Format = pFormats[iFormat];
-
- // Get the available configurations.
- hr = pDecoderService->GetDecoderConfigurations(guidDecoder, &m_VideoDesc, nullptr, &cConfigurations, &pConfig);
-
- if (FAILED(hr)) {
- continue;
- }
-
- // Find a supported configuration.
- for (UINT iConfig = 0; iConfig < cConfigurations; iConfig++) {
- if (IsSupportedDecoderConfig(pFormats[iFormat], pConfig[iConfig], bIsPrefered)) {
- // This configuration is good.
- if (bIsPrefered || !*pbFoundDXVA2Configuration) {
- *pbFoundDXVA2Configuration = TRUE;
- *pSelectedConfig = pConfig[iConfig];
- }
-
- if (bIsPrefered) {
- break;
- }
- }
- }
-
- CoTaskMemFree(pConfig);
- } // End of formats loop.
- }
-
- CoTaskMemFree(pFormats);
-
- // Note: It is possible to return S_OK without finding a configuration.
- return hr;
-}
-
-HRESULT CMPCVideoDecFilter::ConfigureDXVA2(IPin* pPin)
-{
- HRESULT hr = S_OK;
- UINT cDecoderGuids = 0;
- BOOL bFoundDXVA2Configuration = FALSE;
- BOOL bHasIntelGuid = FALSE;
- GUID guidDecoder = GUID_NULL;
-
- DXVA2_ConfigPictureDecode config;
- ZeroMemory(&config, sizeof(config));
-
- CComPtr<IMFGetService> pGetService;
- CComPtr<IDirect3DDeviceManager9> pDeviceManager;
- CComPtr<IDirectXVideoDecoderService> pDecoderService;
- GUID* pDecoderGuids = nullptr;
- HANDLE hDevice = INVALID_HANDLE_VALUE;
-
- // Query the pin for IMFGetService.
- hr = pPin->QueryInterface(__uuidof(IMFGetService), (void**)&pGetService);
-
- // Get the Direct3D device manager.
- if (SUCCEEDED(hr)) {
- hr = pGetService->GetService(
- MR_VIDEO_ACCELERATION_SERVICE,
- __uuidof(IDirect3DDeviceManager9),
- (void**)&pDeviceManager);
- }
-
- // Open a new device handle.
- if (SUCCEEDED(hr)) {
- hr = pDeviceManager->OpenDeviceHandle(&hDevice);
- }
-
- // Get the video decoder service.
- if (SUCCEEDED(hr)) {
- hr = pDeviceManager->GetVideoService(
- hDevice,
- __uuidof(IDirectXVideoDecoderService),
- (void**)&pDecoderService);
- }
-
- // Get the decoder GUIDs.
- if (SUCCEEDED(hr)) {
- hr = pDecoderService->GetDecoderDeviceGuids(&cDecoderGuids, &pDecoderGuids);
- }
-
- if (SUCCEEDED(hr)) {
-
- // Intel patch for Ivy Bridge and Sandy Bridge
- if (m_nPCIVendor == PCIV_Intel) {
- for (UINT iCnt = 0; iCnt < cDecoderGuids; iCnt++) {
- if (pDecoderGuids[iCnt] == DXVA_Intel_H264_ClearVideo) {
- bHasIntelGuid = TRUE;
- }
- }
- }
- // Look for the decoder GUIDs we want.
- for (UINT iGuid = 0; iGuid < cDecoderGuids; iGuid++) {
- // Do we support this mode?
- if (!IsSupportedDecoderMode(pDecoderGuids[iGuid])) {
- continue;
- }
-
- // Find a configuration that we support.
- hr = FindDXVA2DecoderConfiguration(pDecoderService, pDecoderGuids[iGuid], &config, &bFoundDXVA2Configuration);
-
- if (FAILED(hr)) {
- break;
- }
-
- // Patch for the Sandy Bridge (prevent crash on Mode_E, fixme later)
- if (m_nPCIVendor == PCIV_Intel && pDecoderGuids[iGuid] == DXVA2_ModeH264_E && bHasIntelGuid) {
- continue;
- }
-
- if (bFoundDXVA2Configuration) {
- // Found a good configuration. Save the GUID.
- guidDecoder = pDecoderGuids[iGuid];
- if (!bHasIntelGuid) {
- break;
- }
- }
- }
- }
-
- if (pDecoderGuids) {
- CoTaskMemFree(pDecoderGuids);
- }
- if (!bFoundDXVA2Configuration) {
- hr = E_FAIL; // Unable to find a configuration.
- }
-
- if (SUCCEEDED(hr)) {
- // Store the things we will need later.
- m_pDeviceManager = pDeviceManager;
- m_pDecoderService = pDecoderService;
-
- m_DXVA2Config = config;
- m_DXVADecoderGUID = guidDecoder;
- m_hDevice = hDevice;
- }
-
- if (FAILED(hr)) {
- if (hDevice != INVALID_HANDLE_VALUE) {
- pDeviceManager->CloseDeviceHandle(hDevice);
- }
- }
-
- return hr;
-}
-
-HRESULT CMPCVideoDecFilter::SetEVRForDXVA2(IPin* pPin)
-{
- HRESULT hr = S_OK;
-
- CComPtr<IMFGetService> pGetService;
- CComPtr<IDirectXVideoMemoryConfiguration> pVideoConfig;
- CComPtr<IMFVideoDisplayControl> pVdc;
-
- // Query the pin for IMFGetService.
- hr = pPin->QueryInterface(__uuidof(IMFGetService), (void**)&pGetService);
-
- // Get the IDirectXVideoMemoryConfiguration interface.
- if (SUCCEEDED(hr)) {
- hr = pGetService->GetService(
- MR_VIDEO_ACCELERATION_SERVICE,
- __uuidof(IDirectXVideoMemoryConfiguration),
- (void**)&pVideoConfig);
-
- if (SUCCEEDED(pGetService->GetService(MR_VIDEO_RENDER_SERVICE, __uuidof(IMFVideoDisplayControl), (void**)&pVdc))) {
- HWND hWnd;
- if (SUCCEEDED(pVdc->GetVideoWindow(&hWnd))) {
- DetectVideoCard(hWnd);
- }
- }
- }
-
- // Notify the EVR.
- if (SUCCEEDED(hr)) {
- DXVA2_SurfaceType surfaceType;
-
- for (DWORD iTypeIndex = 0; ; iTypeIndex++) {
- hr = pVideoConfig->GetAvailableSurfaceTypeByIndex(iTypeIndex, &surfaceType);
-
- if (FAILED(hr)) {
- break;
- }
-
- if (surfaceType == DXVA2_SurfaceType_DecoderRenderTarget) {
- hr = pVideoConfig->SetSurfaceType(DXVA2_SurfaceType_DecoderRenderTarget);
- break;
- }
- }
- }
-
- return hr;
-}
-
-HRESULT CMPCVideoDecFilter::CreateDXVA2Decoder(UINT nNumRenderTargets, IDirect3DSurface9** pDecoderRenderTargets)
-{
- HRESULT hr;
- CComPtr<IDirectXVideoDecoder> pDirectXVideoDec;
-
- m_pDecoderRenderTarget = nullptr;
-
- if (m_pDXVADecoder) {
- m_pDXVADecoder->SetDirectXVideoDec(nullptr);
- }
-
- hr = m_pDecoderService->CreateVideoDecoder(m_DXVADecoderGUID, &m_VideoDesc, &m_DXVA2Config,
- pDecoderRenderTargets, nNumRenderTargets, &pDirectXVideoDec);
-
- if (SUCCEEDED(hr)) {
- if (m_nPCIVendor == PCIV_Intel) {
- // We need to recreate the dxva decoder after "stop" on Intel HD Graphics
- SAFE_DELETE(m_pDXVADecoder);
- }
- if (!m_pDXVADecoder) {
- m_pDXVADecoder = CDXVADecoder::CreateDecoder(this, pDirectXVideoDec, &m_DXVADecoderGUID, GetPicEntryNumber(), &m_DXVA2Config);
- if (m_pDXVADecoder) {
- m_pDXVADecoder->SetExtraData((BYTE*)m_pAVCtx->extradata, m_pAVCtx->extradata_size);
- }
- }
-
- m_pDXVADecoder->SetDirectXVideoDec(pDirectXVideoDec);
- }
-
- return hr;
-}
-
-HRESULT CMPCVideoDecFilter::FindDXVA1DecoderConfiguration(IAMVideoAccelerator* pAMVideoAccelerator, const GUID* guidDecoder, DDPIXELFORMAT* pPixelFormat)
-{
- HRESULT hr = E_FAIL;
- DWORD dwFormats = 0;
- DDPIXELFORMAT* pPixelFormats = nullptr;
-
-
- pAMVideoAccelerator->GetUncompFormatsSupported(guidDecoder, &dwFormats, nullptr);
- if (dwFormats > 0) {
- // Find the valid render target formats for this decoder GUID.
- pPixelFormats = DEBUG_NEW DDPIXELFORMAT[dwFormats];
- hr = pAMVideoAccelerator->GetUncompFormatsSupported(guidDecoder, &dwFormats, pPixelFormats);
- if (SUCCEEDED(hr)) {
- // Look for a format that matches our output format.
- for (DWORD iFormat = 0; iFormat < dwFormats; iFormat++) {
- if (pPixelFormats[iFormat].dwFourCC == MAKEFOURCC('N', 'V', '1', '2')) {
- memcpy(pPixelFormat, &pPixelFormats[iFormat], sizeof(DDPIXELFORMAT));
- SAFE_DELETE_ARRAY(pPixelFormats);
- return S_OK;
- }
- }
-
- SAFE_DELETE_ARRAY(pPixelFormats);
- hr = E_FAIL;
- }
- }
-
- return hr;
-}
-
-HRESULT CMPCVideoDecFilter::CheckDXVA1Decoder(const GUID* pGuid)
-{
- if (m_nCodecNb != -1) {
- for (int i = 0; i < MAX_SUPPORTED_MODE; i++) {
- if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == *pGuid) {
- return S_OK;
- }
- }
- }
-
- return E_INVALIDARG;
-}
-
-void CMPCVideoDecFilter::SetDXVA1Params(const GUID* pGuid, DDPIXELFORMAT* pPixelFormat)
-{
- m_DXVADecoderGUID = *pGuid;
- memcpy(&m_PixelFormat, pPixelFormat, sizeof(DDPIXELFORMAT));
-}
-
-WORD CMPCVideoDecFilter::GetDXVA1RestrictedMode()
-{
- if (m_nCodecNb != -1) {
- for (int i = 0; i < MAX_SUPPORTED_MODE; i++) {
- if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == m_DXVADecoderGUID) {
- return ffCodecs[m_nCodecNb].DXVAModes->RestrictedMode [i];
- }
- }
- }
-
- return DXVA_RESTRICTED_MODE_UNRESTRICTED;
-}
-
-HRESULT CMPCVideoDecFilter::CreateDXVA1Decoder(IAMVideoAccelerator* pAMVideoAccelerator, const GUID* pDecoderGuid, DWORD dwSurfaceCount)
-{
- if (m_pDXVADecoder && m_DXVADecoderGUID == *pDecoderGuid) {
- return S_OK;
- }
- SAFE_DELETE(m_pDXVADecoder);
-
- if (!m_bUseDXVA) {
- return E_FAIL;
- }
-
- m_nDXVAMode = MODE_DXVA1;
- m_DXVADecoderGUID = *pDecoderGuid;
- m_pDXVADecoder = CDXVADecoder::CreateDecoder(this, pAMVideoAccelerator, &m_DXVADecoderGUID, dwSurfaceCount);
- if (m_pDXVADecoder) {
- m_pDXVADecoder->SetExtraData((BYTE*)m_pAVCtx->extradata, m_pAVCtx->extradata_size);
- }
-
- return S_OK;
-}
-
-// ISpecifyPropertyPages2
-
-STDMETHODIMP CMPCVideoDecFilter::GetPages(CAUUID* pPages)
-{
- CheckPointer(pPages, E_POINTER);
-
- HRESULT hr = S_OK;
-
-#ifdef STANDALONE_FILTER
- pPages->cElems = 2;
-#else
- pPages->cElems = 1;
-#endif
-
- pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID) * pPages->cElems);
- if (pPages->pElems != nullptr) {
- pPages->pElems[0] = __uuidof(CMPCVideoDecSettingsWnd);
- if (pPages->cElems > 1) {
- pPages->pElems[1] = __uuidof(CMPCVideoDecCodecWnd);
- }
- } else {
- hr = E_OUTOFMEMORY;
- }
-
- return hr;
-}
-
-STDMETHODIMP CMPCVideoDecFilter::CreatePage(const GUID& guid, IPropertyPage** ppPage)
-{
- CheckPointer(ppPage, E_POINTER);
-
- if (*ppPage != nullptr) {
- return E_INVALIDARG;
- }
-
- HRESULT hr;
-
- if (guid == __uuidof(CMPCVideoDecSettingsWnd)) {
- (*ppPage = DEBUG_NEW CInternalPropertyPageTempl<CMPCVideoDecSettingsWnd>(nullptr, &hr))->AddRef();
- } else if (guid == __uuidof(CMPCVideoDecCodecWnd)) {
- (*ppPage = DEBUG_NEW CInternalPropertyPageTempl<CMPCVideoDecCodecWnd>(nullptr, &hr))->AddRef();
- }
-
- return *ppPage ? S_OK : E_FAIL;
-}
-
-void CMPCVideoDecFilter::SetFrameType(FF_FIELD_TYPE nFrameType)
-{
- m_nFrameType = nFrameType;
-}
-
-// IFFmpegDecFilter
-STDMETHODIMP CMPCVideoDecFilter::Apply()
-{
-#ifdef STANDALONE_FILTER
- CRegKey key;
- if (ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, OPT_REGKEY_VideoDec)) {
- key.SetDWORDValue(OPT_ThreadNumber, m_nThreadNumber);
- key.SetDWORDValue(OPT_DiscardMode, m_nDiscardMode);
- key.SetDWORDValue(OPT_ActiveCodecs, m_nActiveCodecs);
- key.SetDWORDValue(OPT_ARMode, m_nARMode);
- key.SetDWORDValue(OPT_DXVACheck, m_nDXVACheckCompatibility);
- key.SetDWORDValue(OPT_DisableDXVA_SD, m_nDXVA_SD);
- key.SetDWORDValue(OPT_InterlacedFlag, m_interlacedFlag);
- }
-#else
- AfxGetApp()->WriteProfileInt(OPT_SECTION_VideoDec, OPT_ThreadNumber, m_nThreadNumber);
- AfxGetApp()->WriteProfileInt(OPT_SECTION_VideoDec, OPT_DiscardMode, m_nDiscardMode);
- AfxGetApp()->WriteProfileInt(OPT_SECTION_VideoDec, OPT_ARMode, m_nARMode);
- AfxGetApp()->WriteProfileInt(OPT_SECTION_VideoDec, OPT_DXVACheck, m_nDXVACheckCompatibility);
- AfxGetApp()->WriteProfileInt(OPT_SECTION_VideoDec, OPT_DisableDXVA_SD, m_nDXVA_SD);
- AfxGetApp()->WriteProfileInt(OPT_SECTION_VideoDec, OPT_InterlacedFlag, m_interlacedFlag);
-#endif
-
- return S_OK;
-}
-
-// === IMPCVideoDecFilter
-
-STDMETHODIMP CMPCVideoDecFilter::SetThreadNumber(int nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_nThreadNumber = nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(int) CMPCVideoDecFilter::GetThreadNumber()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_nThreadNumber;
-}
-
-STDMETHODIMP CMPCVideoDecFilter::SetDiscardMode(int nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_nDiscardMode = nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(int) CMPCVideoDecFilter::GetDiscardMode()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_nDiscardMode;
-}
-
-STDMETHODIMP_(GUID*) CMPCVideoDecFilter::GetDXVADecoderGuid()
-{
- if (m_pGraph == nullptr) {
- return nullptr;
- } else {
- return &m_DXVADecoderGUID;
- }
-}
-
-STDMETHODIMP CMPCVideoDecFilter::SetActiveCodecs(MPC_VIDEO_CODEC nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_nActiveCodecs = (int)nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(MPC_VIDEO_CODEC) CMPCVideoDecFilter::GetActiveCodecs()
-{
- CAutoLock cAutoLock(&m_csProps);
- return (MPC_VIDEO_CODEC)m_nActiveCodecs;
-}
-
-STDMETHODIMP_(LPCTSTR) CMPCVideoDecFilter::GetVideoCardDescription()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_strDeviceDescription;
-}
-
-STDMETHODIMP CMPCVideoDecFilter::SetARMode(int nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_nARMode = nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(int) CMPCVideoDecFilter::GetARMode()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_nARMode;
-}
-
-STDMETHODIMP CMPCVideoDecFilter::SetDXVACheckCompatibility(int nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_nDXVACheckCompatibility = nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(int) CMPCVideoDecFilter::GetDXVACheckCompatibility()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_nDXVACheckCompatibility;
-}
-
-STDMETHODIMP CMPCVideoDecFilter::SetDXVA_SD(int nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_nDXVA_SD = nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(int) CMPCVideoDecFilter::GetDXVA_SD()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_nDXVA_SD;
-}
-
-// === IMPCVideoDecFilter2
-STDMETHODIMP_(int) CMPCVideoDecFilter::GetFrameType()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_nFrameType;
-}
-
-STDMETHODIMP CMPCVideoDecFilter::SetInterlacedFlag(MPCVD_INTERLACED_FLAG interlacedFlag)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_interlacedFlag = interlacedFlag;
- return S_OK;
-}
-
-STDMETHODIMP_(MPCVD_INTERLACED_FLAG) CMPCVideoDecFilter::GetInterlacedFlag()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_interlacedFlag;
-}
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h b/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h
deleted file mode 100644
index 9784bd999..000000000
--- a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <d3dx9.h>
-#include <videoacc.h> // DXVA1
-#include <dxva.h>
-#include <dxva2api.h> // DXVA2
-#include "../BaseVideoFilter/BaseVideoFilter.h"
-
-#include "IMPCVideoDecFilter.h"
-#include "MPCVideoDecSettingsWnd.h"
-#include "../../../DeCSS/DeCSSInputPin.h"
-#include "DXVADecoder.h"
-#include "TlibavcodecExt.h"
-
-#include "H264RandomAccess.h"
-#include <atlpath.h>
-
-// TODO: remove this when it's fixed in MSVC
-// Work around warning C4005: 'XXXX' : macro redefinition
-#pragma warning(push)
-#pragma warning(disable: 4005)
-#include <stdint.h>
-#pragma warning(pop)
-
-
-#define MPCVideoDecName L"MPC Video Decoder"
-
-#define MAX_BUFF_TIME 20
-
-#define CHECK_HR_TRACE(x) \
- hr = ##x; \
- if (FAILED(hr)) { \
- TRACE(_T("Error : 0x%08x\n"), hr); \
- ASSERT(hr == VFW_E_NOT_COMMITTED); \
- return hr; \
- }
-
-struct AVCodec;
-struct AVCodecContext;
-struct AVFrame;
-struct SwsContext;
-
-class CCpuId;
-
-typedef enum {
- MODE_SOFTWARE,
- MODE_DXVA1,
- MODE_DXVA2
-} DXVA_MODE;
-
-typedef struct {
- REFERENCE_TIME rtStart;
- REFERENCE_TIME rtStop;
-} B_FRAME;
-
-typedef struct {
- REFERENCE_TIME rtStart;
- REFERENCE_TIME rtStop;
- int nBuffPos;
-} BUFFER_TIME;
-
-typedef struct {
- bool video_after_seek;
- int kf_pts; ///< timestamp of next video keyframe
- int64_t kf_base; ///< timestamp of the previous video keyframe
-} RMDemuxContext;
-
-class __declspec(uuid("008BAC12-FBAF-497b-9670-BC6F6FBAE2C4"))
- CMPCVideoDecFilter
- : public CBaseVideoFilter
- , public TlibavcodecExt
- , public ISpecifyPropertyPages2
- , public IMPCVideoDecFilter2
-{
-protected:
-
- // === FFmpeg callbacks
- static void LogLibavcodec(void* par, int level, const char* fmt, va_list valist);
- virtual void OnGetBuffer(AVFrame* pic);
-
- friend class CVideoDecDXVAAllocator;
-
- CCpuId* m_pCpuId;
- CCritSec m_csProps;
-
- CAutoPtr<bool> m_DXVAFilters;
- CAutoPtr<bool> m_FFmpegFilters;
-
- // === Persistants parameters (registry)
- int m_nThreadNumber;
- int m_nDiscardMode;
- bool m_bDXVACompatible;
- int m_nActiveCodecs;
- int m_nARMode;
- int m_nDXVACheckCompatibility;
- int m_nDXVA_SD;
- MPCVD_INTERLACED_FLAG m_interlacedFlag;
-
- FF_FIELD_TYPE m_nFrameType;
-
- // === FFmpeg variables
- AVCodec* m_pAVCodec;
- AVCodecContext* m_pAVCtx;
- AVFrame* m_pFrame;
- int m_nCodecNb;
- enum AVCodecID m_nCodecId;
- int m_nWorkaroundBug;
- int m_nErrorConcealment;
- REFERENCE_TIME m_rtAvrTimePerFrame;
- bool m_bReorderBFrame;
- B_FRAME m_BFrames[2];
- int m_nPosB;
- int m_nWidth; // Frame width given to input pin
- int m_nHeight; // Frame height given to input pin
-
- bool m_bTheoraMTSupport;
- bool m_bIsEVO;
-
- // Buffer management for truncated stream (store stream chunks & reference time sent by splitter)
- BYTE* m_pFFBuffer;
- int m_nFFBufferSize;
- BYTE* m_pAlignedFFBuffer;
- int m_nAlignedFFBufferSize;
-
- int m_nFFBufferPos;
- int m_nFFPicEnd;
- BUFFER_TIME m_FFBufferTime[MAX_BUFF_TIME];
-
- REFERENCE_TIME m_rtLastStart; // rtStart for last delivered frame
- int m_nCountEstimated; // Number of rtStart estimated since last rtStart received
- double m_dRate;
- REFERENCE_TIME m_rtPrevStop;
- bool m_bFrame_repeat_pict;
-
- bool m_bUseDXVA;
- bool m_bUseFFmpeg;
- CSize m_par;
- SwsContext* m_pSwsContext;
- unsigned __int64 m_nOutCsp;
- CSize m_pOutSize; // Picture size on output pin
- int m_nSwOutBpp;
-
- // === DXVA common variables
- VIDEO_OUTPUT_FORMATS* m_pVideoOutputFormat;
- int m_nVideoOutputCount;
- DXVA_MODE m_nDXVAMode;
- CDXVADecoder* m_pDXVADecoder;
- GUID m_DXVADecoderGUID;
-
- DWORD m_nPCIVendor;
- DWORD m_nPCIDevice;
- LARGE_INTEGER m_VideoDriverVersion;
- CString m_strDeviceDescription;
-
- // === DXVA1 variables
- DDPIXELFORMAT m_PixelFormat;
-
- // === DXVA2 variables
- CComPtr<IDirect3DDeviceManager9> m_pDeviceManager;
- CComPtr<IDirectXVideoDecoderService> m_pDecoderService;
- CComPtr<IDirect3DSurface9> m_pDecoderRenderTarget;
- DXVA2_ConfigPictureDecode m_DXVA2Config;
- HANDLE m_hDevice;
- DXVA2_VideoDesc m_VideoDesc;
-
- CH264RandomAccess m_h264RandomAccess;
-
- BOOL m_bWaitingForKeyFrame;
-
- RMDemuxContext rm;
- REFERENCE_TIME m_rtStart;
-
- // === Private functions
- void Cleanup();
- int FindCodec(const CMediaType* mtIn);
- void AllocExtradata(AVCodecContext* pAVCtx, const CMediaType* mt);
- bool IsMultiThreadSupported(enum AVCodecID nCodec);
- void GetOutputFormats(int& nNumber, VIDEO_OUTPUT_FORMATS** ppFormats);
- void CalcAvgTimePerFrame();
- void DetectVideoCard(HWND hWnd);
- unsigned __int64 GetCspFromMediaType(GUID& subtype);
- void InitSwscale();
-
- void SetTypeSpecificFlags(IMediaSample* pMS);
- HRESULT SoftwareDecode(IMediaSample* pIn, BYTE* pDataIn, int nSize, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
- bool AppendBuffer(BYTE* pDataIn, int nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
- bool FindPicture(int nIndex, int nStartCode);
- void ShrinkBuffer();
- void ResetBuffer();
- void PushBufferTime(int nPos, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
- void PopBufferTime(int nPos);
-
-public:
-
- const static AMOVIESETUP_MEDIATYPE sudPinTypesIn[];
- const static int sudPinTypesInCount;
- const static AMOVIESETUP_MEDIATYPE sudPinTypesOut[];
- const static int sudPinTypesOutCount;
-
- CMPCVideoDecFilter(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CMPCVideoDecFilter();
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- virtual bool IsVideoInterlaced();
- virtual void GetOutputSize(int& w, int& h, int& arx, int& ary, int& RealWidth, int& RealHeight);
- CTransformOutputPin* GetOutputPin() { return m_pOutput; }
-
- void UpdateFrameTime(REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop, bool b_repeat_pict = false);
- CString GetFileExtension();
-
- void SetDXVAFilters(CAutoPtr<bool> DXVAFilters) { m_DXVAFilters = DXVAFilters; };
- void SetFFmpegFilters(CAutoPtr<bool> FFmpegFilters) { m_FFmpegFilters = FFmpegFilters; };
-
- // === Overriden DirectShow functions
- HRESULT SetMediaType(PIN_DIRECTION direction, const CMediaType* pmt);
- HRESULT CheckInputType(const CMediaType* mtIn);
- HRESULT Transform(IMediaSample* pIn);
- HRESULT CompleteConnect(PIN_DIRECTION direction, IPin* pReceivePin);
- HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT BeginFlush();
- HRESULT EndFlush();
- HRESULT NewSegment(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, double dRate);
- HRESULT EndOfStream();
-
- HRESULT BreakConnect(PIN_DIRECTION dir);
-
-
- // === ISpecifyPropertyPages2
-
- STDMETHODIMP GetPages(CAUUID* pPages);
- STDMETHODIMP CreatePage(const GUID& guid, IPropertyPage** ppPage);
-
- // === IMPCVideoDecFilter
- STDMETHODIMP Apply();
- STDMETHODIMP SetThreadNumber(int nValue);
- STDMETHODIMP_(int) GetThreadNumber();
- STDMETHOD(SetDiscardMode(int nValue));
- STDMETHOD_(int, GetDiscardMode());
- STDMETHOD_(GUID*, GetDXVADecoderGuid());
- STDMETHOD(SetActiveCodecs(MPC_VIDEO_CODEC nValue));
- STDMETHOD_(MPC_VIDEO_CODEC, GetActiveCodecs());
- STDMETHODIMP_(LPCTSTR) GetVideoCardDescription();
-
- STDMETHOD(SetARMode(int nValue));
- STDMETHOD_(int, GetARMode());
-
- STDMETHOD(SetDXVACheckCompatibility(int nValue));
- STDMETHOD_(int, GetDXVACheckCompatibility());
-
- STDMETHOD(SetDXVA_SD(int nValue));
- STDMETHOD_(int, GetDXVA_SD());
-
- // === IMPCVideoDecFilter2
- STDMETHOD_(int, GetFrameType());
-
- STDMETHOD(SetInterlacedFlag(MPCVD_INTERLACED_FLAG interlacedFlag));
- STDMETHOD_(MPCVD_INTERLACED_FLAG, GetInterlacedFlag());
-
- // === DXVA common functions
- BOOL IsSupportedDecoderConfig(const D3DFORMAT nD3DFormat, const DXVA2_ConfigPictureDecode& config, bool& bIsPrefered);
- BOOL IsSupportedDecoderMode(const GUID& mode);
- void BuildDXVAOutputFormat();
- int GetPicEntryNumber();
- int PictWidth();
- int PictHeight();
- int PictWidthRounded();
- int PictHeightRounded();
-
- inline bool UseDXVA2() { return (m_nDXVAMode == MODE_DXVA2); };
- inline AVCodecContext* GetAVCtx() { return m_pAVCtx; };
- inline AVFrame* GetFrame() { return m_pFrame; };
- inline enum AVCodecID GetCodec() { return m_nCodecId; };
- inline bool IsReorderBFrame() { return m_bReorderBFrame; };
- inline bool IsEvo() { return m_bIsEVO; };
- inline DWORD GetPCIVendor() { return m_nPCIVendor; };
- inline REFERENCE_TIME GetAvrTimePerFrame() { return m_rtAvrTimePerFrame; };
- inline double GetRate() { return m_dRate; };
- bool IsDXVASupported();
- void UpdateAspectRatio();
- void ReorderBFrames(REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
- void FlushDXVADecoder() {
- if (m_pDXVADecoder) {
- m_pDXVADecoder->Flush();
- }
- }
-
- void SetFrameType(FF_FIELD_TYPE nFrameType);
-
- // === DXVA1 functions
- DDPIXELFORMAT* GetPixelFormat() { return &m_PixelFormat; }
- HRESULT FindDXVA1DecoderConfiguration(IAMVideoAccelerator* pAMVideoAccelerator, const GUID* guidDecoder, DDPIXELFORMAT* pPixelFormat);
- HRESULT CheckDXVA1Decoder(const GUID* pGuid);
- void SetDXVA1Params(const GUID* pGuid, DDPIXELFORMAT* pPixelFormat);
- WORD GetDXVA1RestrictedMode();
- HRESULT CreateDXVA1Decoder(IAMVideoAccelerator* pAMVideoAccelerator, const GUID* pDecoderGuid, DWORD dwSurfaceCount);
-
-
- // === DXVA2 functions
- void FillInVideoDescription(DXVA2_VideoDesc* pDesc);
- DXVA2_ConfigPictureDecode* GetDXVA2Config() { return &m_DXVA2Config; };
- HRESULT ConfigureDXVA2(IPin* pPin);
- HRESULT SetEVRForDXVA2(IPin* pPin);
- HRESULT FindDXVA2DecoderConfiguration(IDirectXVideoDecoderService* pDecoderService,
- const GUID& guidDecoder,
- DXVA2_ConfigPictureDecode* pSelectedConfig,
- BOOL* pbFoundDXVA2Configuration);
- HRESULT CreateDXVA2Decoder(UINT nNumRenderTargets, IDirect3DSurface9** pDecoderRenderTargets);
-};
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.rc b/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.rc
deleted file mode 100644
index a59ca7eb9..000000000
--- a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.rc
+++ /dev/null
@@ -1,166 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-#include "version.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (United States) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
- "#define _AFX_NO_OLE_RESOURCES\r\n"
- "#define _AFX_NO_TRACKER_RESOURCES\r\n"
- "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
- "\r\n"
- "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
- "LANGUAGE 9, 1\r\n"
- "#pragma code_page(1252)\r\n"
- "#include ""afxres.rc"" // Standard components\r\n"
- "#endif\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION MPC_VERSION_NUM
- PRODUCTVERSION MPC_VERSION_NUM
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS VOS_NT_WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE VFT2_UNKNOWN
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", MPC_VERSION_COMMENTS
- VALUE "CompanyName", MPC_COMP_NAME_STR
- VALUE "FileDescription", "H.264/VC-1 DXVA video decoder"
- VALUE "FileVersion", MPC_VERSION_STR_FULL
- VALUE "InternalName", "MPCVideoDec Filter"
- VALUE "LegalCopyright", MPC_COPYRIGHT_STR
- VALUE "OriginalFilename", "MPCVideoDecFilter.ax"
- VALUE "ProductName", "MPCVideoDec Filter"
- VALUE "ProductVersion", MPC_VERSION_STR_FULL
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// String Table
-//
-
-STRINGTABLE
-BEGIN
-
- IDS_FILTER_SETTINGS_CAPTION "Settings"
- IDS_VDF_FFSETTINGS "FFmpeg settings"
- IDS_VDF_THREADNUMBER "Decoding thread number"
- IDS_VDF_SKIPDEBLOCK "H264 skip deblocking mode"
- IDS_VDF_DBLK_NONE "None"
- IDS_VDF_DBLK_DEFAULT "Default"
- IDS_VDF_DBLK_NONREF "Non Reference"
- IDS_VDF_DBLK_BIDIR "Bidirectional"
- IDS_VDF_DBLK_NONKFRM "Non keyframes"
- IDS_VDF_DBLK_ALL "All frames"
- IDS_VDF_AUTO "Auto"
- IDS_VDF_AR_MODE "Read AR from stream"
-END
-
-STRINGTABLE
-BEGIN
- IDS_VDF_DXVA_SETTING "DXVA settings"
- IDS_VDF_DXVA_MODE "DXVA Mode"
- IDS_VDF_DXVA_SD "Disable DXVA for SD"
- IDS_VDF_VIDEOCARD "Videocard"
-END
-
-STRINGTABLE
-BEGIN
- IDS_VDF_DXVACOMPATIBILITY "DXVA (H.264) Compatibility check"
- IDS_VDF_DXVA_FULLCHECK "Full check"
- IDS_VDF_DXVA_SKIP_LEVELCHECK "Skip level check"
- IDS_VDF_DXVA_SKIP_REFCHECK "Skip ref frame check"
- IDS_VDF_DXVA_SKIP_ALLCHECK "Skip all checks"
-END
-
-STRINGTABLE
-BEGIN
- IDS_VDF_INTERLACED_FLAG "Force the interlaced flag"
- IDS_VDF_IF_PROGRESSIVE "Progressive"
- IDS_VDF_IF_TOP_FIELD_FIRST "Top field first"
- IDS_VDF_IF_BOTTOM_FIELD_FIRST "Bottom field first"
-END
-
-#endif // English (United States) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-#define _AFX_NO_SPLITTER_RESOURCES
-#define _AFX_NO_OLE_RESOURCES
-#define _AFX_NO_TRACKER_RESOURCES
-#define _AFX_NO_PROPERTY_RESOURCES
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE 9, 1
-#pragma code_page(1252)
-#include "afxres.rc" // Standard components
-#endif
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.cpp b/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.cpp
deleted file mode 100644
index dfe2fb24b..000000000
--- a/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.cpp
+++ /dev/null
@@ -1,447 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "resource.h"
-#include "MPCVideoDecSettingsWnd.h"
-#include "../../../DSUtil/DSUtil.h"
-
-#include "ffmpeg/libavcodec/avcodec.h"
-
-#include "../../../mpc-hc/InternalFiltersConfig.h"
-
-
-//
-// CMPCVideoDecSettingsWnd
-//
-
-int g_AVDiscard[] = {
- AVDISCARD_NONE,
- AVDISCARD_DEFAULT,
- AVDISCARD_NONREF,
- AVDISCARD_BIDIR,
- AVDISCARD_NONKEY,
- AVDISCARD_ALL,
-};
-
-int FindDiscardIndex(int nValue)
-{
- for (int i = 0; i < _countof(g_AVDiscard); i++) {
- if (g_AVDiscard[i] == nValue) {
- return i;
- }
- }
- return 1;
-}
-
-int g_AVErrRecognition[] = {
- AV_EF_CAREFUL,
- AV_EF_COMPLIANT,
- AV_EF_AGGRESSIVE,
-};
-
-int FindErrRecognitionIndex(int nValue)
-{
- for (int i = 0; i < _countof(g_AVErrRecognition); i++) {
- if (g_AVErrRecognition[i] == nValue) {
- return i;
- }
- }
- return 1;
-}
-
-CMPCVideoDecSettingsWnd::CMPCVideoDecSettingsWnd()
-{
-}
-
-bool CMPCVideoDecSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
-{
- ASSERT(!m_pMDF);
-
- m_pMDF.Release();
-
- POSITION pos = pUnks.GetHeadPosition();
- while (pos && !(m_pMDF = pUnks.GetNext(pos))) {
- ;
- }
-
- if (!m_pMDF) {
- return false;
- }
-
- return true;
-}
-
-void CMPCVideoDecSettingsWnd::OnDisconnect()
-{
- m_pMDF.Release();
-}
-
-bool CMPCVideoDecSettingsWnd::OnActivate()
-{
- ASSERT(IPP_FONTSIZE == 13);
- const int h20 = IPP_SCALE(20);
- const int h25 = IPP_SCALE(25);
- DWORD dwStyle = WS_VISIBLE | WS_CHILD | WS_TABSTOP;
- CPoint p(10, 10);
- GUID* DxvaGui = nullptr;
-
-#if HAS_FFMPEG_VIDEO_DECODERS
- m_grpFFMpeg.Create(ResStr(IDS_VDF_FFSETTINGS), WS_VISIBLE | WS_CHILD | BS_GROUPBOX, CRect(p + CPoint(-5, 0), CSize(IPP_SCALE(350), h20 + h25 * 3 + h20)), this, (UINT)IDC_STATIC);
- p.y += h20;
-
- // Decoding threads
- m_txtThreadNumber.Create(ResStr(IDS_VDF_THREADNUMBER), WS_VISIBLE | WS_CHILD, CRect(p, CSize(IPP_SCALE(220), m_fontheight)), this, (UINT)IDC_STATIC);
- m_cbThreadNumber.Create(dwStyle | CBS_DROPDOWNLIST | WS_VSCROLL, CRect(p + CPoint(IPP_SCALE(230), -4), CSize(IPP_SCALE(110), 200)), this, IDC_PP_THREAD_COUNT);
- m_cbThreadNumber.AddString(ResStr(IDS_VDF_AUTO));
- CString ThreadNumberStr;
- for (int i = 0; i < 16; i++) {
- ThreadNumberStr.Format(_T("%d"), i + 1);
- m_cbThreadNumber.AddString(ThreadNumberStr);
- }
- p.y += h25;
-
-#if INTERNAL_DECODER_H264
- // H264 deblocking mode
- m_txtSkipDeblock.Create(ResStr(IDS_VDF_SKIPDEBLOCK), WS_VISIBLE | WS_CHILD, CRect(p, CSize(IPP_SCALE(220), m_fontheight)), this, (UINT)IDC_STATIC);
- m_cbSkipDeblock.Create(dwStyle | CBS_DROPDOWNLIST | WS_VSCROLL, CRect(p + CPoint(IPP_SCALE(230), -4), CSize(IPP_SCALE(110), 200)), this, IDC_PP_SKIP_DEBLOCK);
- m_cbSkipDeblock.AddString(ResStr(IDS_VDF_DBLK_NONE));
- m_cbSkipDeblock.AddString(ResStr(IDS_VDF_DBLK_DEFAULT));
- m_cbSkipDeblock.AddString(ResStr(IDS_VDF_DBLK_NONREF));
- m_cbSkipDeblock.AddString(ResStr(IDS_VDF_DBLK_BIDIR));
- m_cbSkipDeblock.AddString(ResStr(IDS_VDF_DBLK_NONKFRM));
- m_cbSkipDeblock.AddString(ResStr(IDS_VDF_DBLK_ALL));
-#endif /* INTERNAL_DECODER_H264 */
- p.y += h25;
-
- // Read AR from stream
- m_cbARMode.Create(ResStr(IDS_VDF_AR_MODE), dwStyle | BS_AUTOCHECKBOX | BS_LEFTTEXT, CRect(p, CSize(IPP_SCALE(340), m_fontheight)), this, IDC_PP_AR);
- m_cbARMode.SetCheck(FALSE);
- p.y += h25;
-#endif /* HAS_FFMPEG_VIDEO_DECODERS */
-
- // Interlaced flag
- m_txtInterlacedFlag.Create(ResStr(IDS_VDF_INTERLACED_FLAG), WS_VISIBLE | WS_CHILD, CRect(p, CSize(IPP_SCALE(220), m_fontheight)), this, (UINT)IDC_STATIC);
- m_cbInterlacedFlag.Create(dwStyle | CBS_DROPDOWNLIST | WS_VSCROLL, CRect(p + CPoint(IPP_SCALE(230), -6), CSize(IPP_SCALE(110), 200)), this, IDC_PP_INTERLACED_FLAG);
- m_cbInterlacedFlag.AddString(ResStr(IDS_VDF_AUTO));
- m_cbInterlacedFlag.AddString(ResStr(IDS_VDF_IF_PROGRESSIVE));
- m_cbInterlacedFlag.AddString(ResStr(IDS_VDF_IF_TOP_FIELD_FIRST));
- m_cbInterlacedFlag.AddString(ResStr(IDS_VDF_IF_BOTTOM_FIELD_FIRST));
- p.y += h25;
-
- m_grpDXVA.Create(ResStr(IDS_VDF_DXVA_SETTING), WS_VISIBLE | WS_CHILD | BS_GROUPBOX, CRect(p + CPoint(-5, 0), CSize(IPP_SCALE(350), h20 + h25 + h20 * 3 + m_fontheight)), this, (UINT)IDC_STATIC);
- p.y += h20;
-
- // DXVA Compatibility check
- m_txtDXVACompatibilityCheck.Create(ResStr(IDS_VDF_DXVACOMPATIBILITY), WS_VISIBLE | WS_CHILD, CRect(p, CSize(IPP_SCALE(225), m_fontheight)), this, (UINT)IDC_STATIC);
- m_cbDXVACompatibilityCheck.Create(dwStyle | CBS_DROPDOWNLIST | WS_VSCROLL, CRect(p + CPoint(IPP_SCALE(230), -4), CSize(IPP_SCALE(110), 200)), this, IDC_PP_DXVA_CHECK);
- m_cbDXVACompatibilityCheck.AddString(ResStr(IDS_VDF_DXVA_FULLCHECK));
- m_cbDXVACompatibilityCheck.AddString(ResStr(IDS_VDF_DXVA_SKIP_LEVELCHECK));
- m_cbDXVACompatibilityCheck.AddString(ResStr(IDS_VDF_DXVA_SKIP_REFCHECK));
- m_cbDXVACompatibilityCheck.AddString(ResStr(IDS_VDF_DXVA_SKIP_ALLCHECK));
- p.y += h25;
-
- // Set DXVA for SD (H.264)
- m_cbDXVA_SD.Create(ResStr(IDS_VDF_DXVA_SD), dwStyle | BS_AUTOCHECKBOX | BS_LEFTTEXT, CRect(p, CSize(IPP_SCALE(340), m_fontheight)), this, IDC_PP_DXVA_SD);
- m_cbDXVA_SD.SetCheck(FALSE);
- p.y += h20;
-
- // DXVA mode
- m_txtDXVAMode.Create(ResStr(IDS_VDF_DXVA_MODE), WS_VISIBLE | WS_CHILD, CRect(p, CSize(IPP_SCALE(120), m_fontheight)), this, (UINT)IDC_STATIC);
- m_edtDXVAMode.Create(WS_CHILD | WS_VISIBLE | WS_DISABLED, CRect(p + CPoint(IPP_SCALE(120), 0), CSize(IPP_SCALE(220), m_fontheight)), this, 0);
- p.y += h20;
-
- // Video card description
- m_txtVideoCardDescription.Create(ResStr(IDS_VDF_VIDEOCARD), WS_VISIBLE | WS_CHILD, CRect(p, CSize(IPP_SCALE(120), m_fontheight)), this, (UINT)IDC_STATIC);
- m_edtVideoCardDescription.Create(ES_MULTILINE | WS_CHILD | WS_VISIBLE | WS_DISABLED, CRect(p + CPoint(IPP_SCALE(120), 0), CSize(IPP_SCALE(220), m_fontheight * 2)), this, 0);
- m_edtVideoCardDescription.SetWindowText(m_pMDF->GetVideoCardDescription());
-
- DxvaGui = m_pMDF->GetDXVADecoderGuid();
- if (DxvaGui != nullptr) {
- CString DXVAMode = GetDXVAMode(DxvaGui);
- m_edtDXVAMode.SetWindowText(DXVAMode);
- } else {
- m_txtDXVAMode.ShowWindow(SW_HIDE);
- m_edtDXVAMode.ShowWindow(SW_HIDE);
- }
-
- for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
- pWnd->SetFont(&m_font, FALSE);
- }
-
- CorrectComboListWidth(m_cbDXVACompatibilityCheck);
-#if INTERNAL_DECODER_H264
- CorrectComboListWidth(m_cbSkipDeblock);
-#endif
-
- if (m_pMDF) {
-#if HAS_FFMPEG_VIDEO_DECODERS
-#if INTERNAL_DECODER_H264
- m_cbThreadNumber.SetCurSel(m_pMDF->GetThreadNumber());
- m_cbSkipDeblock.SetCurSel(FindDiscardIndex(m_pMDF->GetDiscardMode()));
-#endif
-
- m_cbARMode.SetCheck(m_pMDF->GetARMode());
-#endif /* HAS_FFMPEG_VIDEO_DECODERS */
-
- m_cbDXVACompatibilityCheck.SetCurSel(m_pMDF->GetDXVACheckCompatibility());
- m_cbDXVA_SD.SetCheck(m_pMDF->GetDXVA_SD());
-
- m_cbInterlacedFlag.SetCurSel(m_pMDF->GetInterlacedFlag());
- }
-
- return true;
-}
-
-void CMPCVideoDecSettingsWnd::OnDeactivate()
-{
-}
-
-bool CMPCVideoDecSettingsWnd::OnApply()
-{
- OnDeactivate();
-
- if (m_pMDF && m_cbDXVACompatibilityCheck.m_hWnd) {
-#if HAS_FFMPEG_VIDEO_DECODERS
-#if INTERNAL_DECODER_H264
- m_pMDF->SetThreadNumber(m_cbThreadNumber.GetCurSel());
- m_pMDF->SetDiscardMode(g_AVDiscard[m_cbSkipDeblock.GetCurSel()]);
-#endif /* INTERNAL_DECODER_H264 */
-
- m_pMDF->SetARMode(m_cbARMode.GetCheck());
-#endif /* HAS_FFMPEG_VIDEO_DECODERS */
-
- m_pMDF->SetDXVACheckCompatibility(m_cbDXVACompatibilityCheck.GetCurSel());
-
- m_pMDF->SetDXVA_SD(m_cbDXVA_SD.GetCheck());
-
- m_pMDF->SetInterlacedFlag((MPCVD_INTERLACED_FLAG)m_cbInterlacedFlag.GetCurSel());
-
- m_pMDF->Apply();
- }
-
- return true;
-}
-
-
-BEGIN_MESSAGE_MAP(CMPCVideoDecSettingsWnd, CInternalPropertyPageWnd)
-END_MESSAGE_MAP()
-
-
-// ====== Codec filter property page (for standalone filter only)
-
-CMPCVideoDecCodecWnd::CMPCVideoDecCodecWnd()
-{
-}
-
-bool CMPCVideoDecCodecWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
-{
- ASSERT(!m_pMDF);
-
- m_pMDF.Release();
-
- POSITION pos = pUnks.GetHeadPosition();
- while (pos && !(m_pMDF = pUnks.GetNext(pos))) {
- ;
- }
-
- if (!m_pMDF) {
- return false;
- }
-
- return true;
-}
-
-void CMPCVideoDecCodecWnd::OnDisconnect()
-{
- m_pMDF.Release();
-}
-
-bool CMPCVideoDecCodecWnd::OnActivate()
-{
- DWORD dwStyle = WS_VISIBLE | WS_CHILD | WS_BORDER;
- int nPos = 0;
- MPC_VIDEO_CODEC nActiveCodecs = (MPC_VIDEO_CODEC)(m_pMDF ? m_pMDF->GetActiveCodecs() : 0);
-
- m_grpSelectedCodec.Create(_T("Selected codecs"), WS_VISIBLE | WS_CHILD | BS_GROUPBOX, CRect(10, 10, 330, 280), this, (UINT)IDC_STATIC);
-
- m_lstCodecs.Create(dwStyle | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP, CRect(20, 30, 320, 270), this, 0);
-
-#if INTERNAL_DECODER_H264_DXVA
- m_lstCodecs.AddString(_T("H.264/AVC (DXVA)"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_H264_DXVA) != 0);
-#endif
-#if INTERNAL_DECODER_VC1_DXVA
- m_lstCodecs.AddString(_T("VC1 (DXVA)"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_VC1_DXVA) != 0);
-#endif
-#if INTERNAL_DECODER_WMV3_DXVA
- m_lstCodecs.AddString(_T("WMV3 (DXVA)"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_WMV3_DXVA) != 0);
-#endif
-#if INTERNAL_DECODER_MPEG2_DXVA
- m_lstCodecs.AddString(_T("MPEG2 (DXVA)"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_MPEG2_DXVA) != 0);
-#endif
-
-#if INTERNAL_DECODER_H264
- m_lstCodecs.AddString(_T("H.264/AVC (FFmpeg)"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_H264) != 0);
-#endif
-#if INTERNAL_DECODER_VC1
- m_lstCodecs.AddString(_T("VC1 (FFmpeg)"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_VC1) != 0);
-#endif
-
-#if HAS_FFMPEG_VIDEO_DECODERS
- m_lstCodecs.AddString(_T("Xvid/MPEG-4"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_XVID) != 0);
- m_lstCodecs.AddString(_T("DivX"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_DIVX) != 0);
- m_lstCodecs.AddString(_T("MS-MPEG4"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_MSMPEG4) != 0);
- m_lstCodecs.AddString(_T("FLV1/4"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_FLASH) != 0);
- m_lstCodecs.AddString(_T("VP3/5/6"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_VP356) != 0);
- m_lstCodecs.AddString(_T("VP8"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_VP8) != 0);
- m_lstCodecs.AddString(_T("WMV1/2/3"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_WMV) != 0);
- m_lstCodecs.AddString(_T("H.263"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_H263) != 0);
- m_lstCodecs.AddString(_T("SVQ1/3"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_SVQ3) != 0);
- m_lstCodecs.AddString(_T("AMV video"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_AMVV) != 0);
- m_lstCodecs.AddString(_T("Theora"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_THEORA) != 0);
- m_lstCodecs.AddString(_T("MJPEG"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_MJPEG) != 0);
- m_lstCodecs.AddString(_T("Indeo 3/4/5"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_INDEO) != 0);
- m_lstCodecs.AddString(_T("Real Video"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_RV) != 0);
-#endif
-
- for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
- pWnd->SetFont(&m_font, FALSE);
- }
-
- return true;
-}
-
-void CMPCVideoDecCodecWnd::OnDeactivate()
-{
-}
-
-bool CMPCVideoDecCodecWnd::OnApply()
-{
- OnDeactivate();
-
- if (m_pMDF) {
- int nActiveCodecs = 0;
- int nPos = 0;
-
-#if INTERNAL_DECODER_H264_DXVA
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_H264_DXVA;
- }
-#endif
-#if INTERNAL_DECODER_VC1_DXVA
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_VC1_DXVA;
- }
-#endif
-#if INTERNAL_DECODER_WMV3_DXVA
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_WMV3_DXVA;
- }
-#endif
-#if INTERNAL_DECODER_MPEG2_DXVA
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_MPEG2_DXVA;
- }
-#endif
-#if INTERNAL_DECODER_H264
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_H264;
- }
-#endif
-#if INTERNAL_DECODER_VC1
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_VC1;
- }
-#endif
-#if HAS_FFMPEG_VIDEO_DECODERS
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_XVID;
- }
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_DIVX;
- }
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_MSMPEG4;
- }
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_FLASH;
- }
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_VP356;
- }
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_VP8;
- }
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_WMV;
- }
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_H263;
- }
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_SVQ3;
- }
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_AMVV;
- }
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_THEORA;
- }
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_MJPEG;
- }
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_INDEO;
- }
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_RV;
- }
-#endif
- m_pMDF->SetActiveCodecs((MPC_VIDEO_CODEC)nActiveCodecs);
-
- m_pMDF->Apply();
- }
-
- return true;
-}
-
-
-BEGIN_MESSAGE_MAP(CMPCVideoDecCodecWnd, CInternalPropertyPageWnd)
-END_MESSAGE_MAP()
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.h b/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.h
deleted file mode 100644
index 248c984bc..000000000
--- a/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../InternalPropertyPage.h"
-#include "IMPCVideoDecFilter.h"
-#include "resource.h"
-#include <afxcmn.h>
-
-class __declspec(uuid("D5AA0389-D274-48e1-BF50-ACB05A56DDE0"))
- CMPCVideoDecSettingsWnd : public CInternalPropertyPageWnd
-{
- CComQIPtr<IMPCVideoDecFilter2> m_pMDF;
-
- CButton m_grpFFMpeg;
- CStatic m_txtThreadNumber;
- CComboBox m_cbThreadNumber;
- CStatic m_txtSkipDeblock;
- CComboBox m_cbSkipDeblock;
-
- CButton m_grpDXVA;
- CStatic m_txtDXVAMode;
- CEdit m_edtDXVAMode;
-
- CStatic m_txtInterlacedFlag;
- CComboBox m_cbInterlacedFlag;
-
- CStatic m_txtVideoCardDescription;
- CEdit m_edtVideoCardDescription;
-
- CButton m_cbARMode;
-
- CStatic m_txtDXVACompatibilityCheck;
- CComboBox m_cbDXVACompatibilityCheck;
-
- CButton m_cbDXVA_SD;
-
- enum {
- IDC_PP_THREAD_COUNT = 10000,
- IDC_PP_SKIP_DEBLOCK,
- IDC_PP_AR,
- IDC_PP_INTERLACED_FLAG,
- IDC_PP_DXVA_CHECK,
- IDC_PP_DXVA_SD
- };
-
-public:
- CMPCVideoDecSettingsWnd();
-
- bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
- void OnDisconnect();
- bool OnActivate();
- void OnDeactivate();
- bool OnApply();
-
- static LPCTSTR GetWindowTitle() { return MAKEINTRESOURCE(IDS_FILTER_SETTINGS_CAPTION); }
- static CSize GetWindowSize() { return CSize(360, 258); }
-
- DECLARE_MESSAGE_MAP()
-};
-
-class __declspec(uuid("3C395D46-8B0F-440d-B962-2F4A97355453"))
- CMPCVideoDecCodecWnd : public CInternalPropertyPageWnd
-{
- CComQIPtr<IMPCVideoDecFilter> m_pMDF;
-
- CButton m_grpSelectedCodec;
- CCheckListBox m_lstCodecs;
- CImageList m_onoff;
-
-public:
- CMPCVideoDecCodecWnd();
-
- bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
- void OnDisconnect();
- bool OnActivate();
- void OnDeactivate();
- bool OnApply();
-
- static LPCTSTR GetWindowTitle() { return _T("Codecs"); }
- static CSize GetWindowSize() { return CSize(360, 283); }
-
- DECLARE_MESSAGE_MAP()
-};
diff --git a/src/filters/transform/MPCVideoDec/PODtypes.h b/src/filters/transform/MPCVideoDec/PODtypes.h
deleted file mode 100644
index 33a200159..000000000
--- a/src/filters/transform/MPCVideoDec/PODtypes.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef _PODTYPES_H_
-#define _PODTYPES_H_
-
-template<class T> struct isPOD {enum {is = false};};
-template<> struct isPOD<bool> {enum {is = true};};
-
-template<> struct isPOD<char> {enum {is = true};};
-
-template<> struct isPOD<signed char> {enum {is = true};};
-template<> struct isPOD<short int> {enum {is = true};};
-template<> struct isPOD<int> {enum {is = true};};
-template<> struct isPOD<long int> {enum {is = true};};
-template<> struct isPOD<__int64> {enum {is = true};};
-
-template<> struct isPOD<unsigned char> {enum {is = true};};
-template<> struct isPOD<unsigned short int> {enum {is = true};};
-template<> struct isPOD<unsigned int> {enum {is = true};};
-template<> struct isPOD<unsigned long int> {enum {is = true};};
-template<> struct isPOD<unsigned __int64> {enum {is = true};};
-
-template<> struct isPOD<float> {enum {is = true};};
-template<> struct isPOD<double> {enum {is = true};};
-template<> struct isPOD<long double> {enum {is = true};};
-
-#if defined(__INTEL_COMPILER) || defined(__GNUC__) || (_MSC_VER >= 1300)
-template<> struct isPOD<wchar_t> {enum {is = true};};
-template<class Tp> struct isPOD<Tp*> {enum {is = true};};
-#endif
-
-template<class A> struct allocator_traits {enum {is_static = false};};
-
-#endif
diff --git a/src/filters/transform/MPCVideoDec/TlibavcodecExt.cpp b/src/filters/transform/MPCVideoDec/TlibavcodecExt.cpp
deleted file mode 100644
index b99d83c56..000000000
--- a/src/filters/transform/MPCVideoDec/TlibavcodecExt.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * (C) 2007-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-
-#include "stdafx.h"
-#include "ffmpeg/libavcodec/avcodec.h"
-#include "TlibavcodecExt.h"
-
-void TlibavcodecExt::ConnectTo(AVCodecContext* pAVCtx)
-{
- pAVCtx->opaque = this;
- pAVCtx->get_buffer = get_buffer;
- pAVCtx->reget_buffer = reget_buffer;
- pAVCtx->release_buffer = release_buffer;
-}
-
-int TlibavcodecExt::get_buffer(AVCodecContext* c, AVFrame* pic)
-{
- int ret = c->opaque->ff_avcodec_default_get_buffer(c, pic);
- if (ret == 0) {
- c->opaque->OnGetBuffer(pic);
- }
- return ret;
-}
-
-int TlibavcodecExt::reget_buffer(AVCodecContext* c, AVFrame* pic)
-{
- int ret = c->opaque->ff_avcodec_default_reget_buffer(c, pic);
- if (ret == 0) {
- c->opaque->OnRegetBuffer(pic);
- }
- return ret;
-}
-
-void TlibavcodecExt::release_buffer(AVCodecContext* c, AVFrame* pic)
-{
- c->opaque->ff_avcodec_default_release_buffer(c, pic);
- c->opaque->OnReleaseBuffer(pic);
-}
diff --git a/src/filters/transform/MPCVideoDec/TlibavcodecExt.h b/src/filters/transform/MPCVideoDec/TlibavcodecExt.h
deleted file mode 100644
index e77680f8f..000000000
--- a/src/filters/transform/MPCVideoDec/TlibavcodecExt.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * (C) 2007-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-struct AVCodecContext;
-struct AVFrame;
-
-typedef int (*FUNC_AV_DEFAULT_GET_BUFFER)(AVCodecContext* s, AVFrame* pic);
-typedef void (*FUNC_AV_DEFAULT_RELEASE_BUFFER)(AVCodecContext* s, AVFrame* pic);
-typedef int (*FUNC_AV_DEFAULT_REGET_BUFFER)(AVCodecContext* s, AVFrame* pic);
-
-
-struct TlibavcodecExt {
-protected:
- static int get_buffer(AVCodecContext* s, AVFrame* pic);
- static void release_buffer(AVCodecContext* s, AVFrame* pic);
- static int reget_buffer(AVCodecContext* s, AVFrame* pic);
-
- FUNC_AV_DEFAULT_GET_BUFFER ff_avcodec_default_get_buffer;
- FUNC_AV_DEFAULT_RELEASE_BUFFER ff_avcodec_default_release_buffer;
- FUNC_AV_DEFAULT_REGET_BUFFER ff_avcodec_default_reget_buffer;
-
-public:
- virtual ~TlibavcodecExt() {}
- void ConnectTo(AVCodecContext* pAVCtx);
- virtual void OnGetBuffer(AVFrame* pic) {}
- virtual void OnRegetBuffer(AVFrame* pic) {}
- virtual void OnReleaseBuffer(AVFrame* pic) {}
-};
diff --git a/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.cpp b/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.cpp
deleted file mode 100644
index 61d5fcc91..000000000
--- a/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.cpp
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-
-#include "stdafx.h"
-#include "VideoDecDXVAAllocator.h"
-#include "MPCVideoDecFilter.h"
-#include <Mferror.h>
-#include <d3dx9.h>
-#include <evr.h>
-
-
-CDXVA2Sample::CDXVA2Sample(CVideoDecDXVAAllocator* pAlloc, HRESULT* phr)
- : CMediaSample(NAME("CDXVA2Sample"), (CBaseAllocator*)pAlloc, phr, nullptr, 0)
- , m_dwSurfaceId(0)
-{
-}
-
-//Note: CMediaSample does not derive from CUnknown, so we cannot use the
-// DECLARE_IUNKNOWN macro that is used by most of the filter classes.
-
-STDMETHODIMP CDXVA2Sample::QueryInterface(REFIID riid, __deref_out void** ppv)
-{
- CheckPointer(ppv, E_POINTER);
- ValidateReadWritePtr(ppv, sizeof(PVOID));
-
- if (riid == __uuidof(IMFGetService)) {
- return GetInterface((IMFGetService*) this, ppv);
- }
- if (riid == __uuidof(IMPCDXVA2Sample)) {
- return GetInterface((IMPCDXVA2Sample*) this, ppv);
- } else {
- return CMediaSample::QueryInterface(riid, ppv);
- }
-}
-
-STDMETHODIMP_(ULONG) CDXVA2Sample::AddRef()
-{
- return __super::AddRef();
-}
-
-STDMETHODIMP_(ULONG) CDXVA2Sample::Release()
-{
- // Return a temporary variable for thread safety.
- ULONG cRef = __super::Release();
- return cRef;
-}
-
-// IMFGetService::GetService
-STDMETHODIMP CDXVA2Sample::GetService(REFGUID guidService, REFIID riid, LPVOID* ppv)
-{
- if (guidService != MR_BUFFER_SERVICE) {
- return MF_E_UNSUPPORTED_SERVICE;
- } else if (m_pSurface == nullptr) {
- return E_NOINTERFACE;
- } else {
- return m_pSurface->QueryInterface(riid, ppv);
- }
-}
-
-// Override GetPointer because this class does not manage a system memory buffer.
-// The EVR uses the MR_BUFFER_SERVICE service to get the Direct3D surface.
-STDMETHODIMP CDXVA2Sample::GetPointer(BYTE** ppBuffer)
-{
- return E_NOTIMPL;
-}
-
-// Sets the pointer to the Direct3D surface.
-void CDXVA2Sample::SetSurface(DWORD surfaceId, IDirect3DSurface9* pSurf)
-{
- m_pSurface = pSurf;
- m_dwSurfaceId = surfaceId;
-}
-
-STDMETHODIMP_(int) CDXVA2Sample::GetDXSurfaceId()
-{
- return m_dwSurfaceId;
-}
-
-CVideoDecDXVAAllocator::CVideoDecDXVAAllocator(CMPCVideoDecFilter* pVideoDecFilter, HRESULT* phr)
- : CBaseAllocator(NAME("CVideoDecDXVAAllocator"), nullptr, phr)
- , m_pVideoDecFilter(pVideoDecFilter)
- , m_ppRTSurfaceArray(nullptr)
- , m_nSurfaceArrayCount(0)
-{
-}
-
-CVideoDecDXVAAllocator::~CVideoDecDXVAAllocator()
-{
- Free();
-}
-
-HRESULT CVideoDecDXVAAllocator::Alloc()
-{
- HRESULT hr;
- CComPtr<IDirectXVideoDecoderService> pDXVA2Service;
-
- CheckPointer(m_pVideoDecFilter->m_pDeviceManager, E_UNEXPECTED);
- hr = m_pVideoDecFilter->m_pDeviceManager->GetVideoService(m_pVideoDecFilter->m_hDevice, IID_IDirectXVideoDecoderService, (void**)&pDXVA2Service);
- CheckPointer(pDXVA2Service, E_UNEXPECTED);
- CAutoLock lock(this);
-
- hr = __super::Alloc();
-
- if (SUCCEEDED(hr)) {
- // Free the old resources.
- Free();
-
- m_nSurfaceArrayCount = m_lCount;
-
- // Allocate a new array of pointers.
- m_ppRTSurfaceArray = DEBUG_NEW IDirect3DSurface9 * [m_lCount];
- if (m_ppRTSurfaceArray == nullptr) {
- hr = E_OUTOFMEMORY;
- } else {
- ZeroMemory(m_ppRTSurfaceArray, sizeof(IDirect3DSurface9*) * m_lCount);
- }
- }
-
- // Allocate the surfaces.
- D3DFORMAT m_dwFormat = m_pVideoDecFilter->m_VideoDesc.Format;
- if (SUCCEEDED(hr)) {
- hr = pDXVA2Service->CreateSurface(
- m_pVideoDecFilter->PictWidthRounded(),
- m_pVideoDecFilter->PictHeightRounded(),
- m_lCount - 1,
- (D3DFORMAT)m_dwFormat,
- D3DPOOL_DEFAULT,
- 0,
- DXVA2_VideoDecoderRenderTarget,
- m_ppRTSurfaceArray,
- nullptr
- );
- }
-
- if (SUCCEEDED(hr)) {
- // Important : create samples in reverse order !
- for (m_lAllocated = m_lCount - 1; m_lAllocated >= 0; m_lAllocated--) {
- CDXVA2Sample* pSample = DEBUG_NEW CDXVA2Sample(this, &hr);
- if (pSample == nullptr) {
- hr = E_OUTOFMEMORY;
- break;
- }
- if (FAILED(hr)) {
- break;
- }
- // Assign the Direct3D surface pointer and the index.
- pSample->SetSurface(m_lAllocated, m_ppRTSurfaceArray[m_lAllocated]);
-
- // Add to the sample list.
- m_lFree.Add(pSample);
- }
-
- hr = m_pVideoDecFilter->CreateDXVA2Decoder(m_lCount, m_ppRTSurfaceArray);
- if (FAILED(hr)) {
- Free();
- }
- }
-
- if (SUCCEEDED(hr)) {
- m_bChanged = FALSE;
- }
- return hr;
-}
-
-void CVideoDecDXVAAllocator::Free()
-{
- CMediaSample* pSample = nullptr;
-
- m_pVideoDecFilter->FlushDXVADecoder();
- // m_FreeSurface.RemoveAll();
- do {
- pSample = m_lFree.RemoveHead();
- if (pSample) {
- delete pSample;
- }
- } while (pSample);
-
- if (m_ppRTSurfaceArray) {
- for (UINT i = 0; i < m_nSurfaceArrayCount; i++) {
- if (m_ppRTSurfaceArray[i] != nullptr) {
- m_ppRTSurfaceArray[i]->Release();
- }
- }
-
- delete [] m_ppRTSurfaceArray;
- m_ppRTSurfaceArray = nullptr;
- }
- m_lAllocated = 0;
- m_nSurfaceArrayCount = 0;
-}
diff --git a/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.h b/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.h
deleted file mode 100644
index 71e362b94..000000000
--- a/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <dxva.h>
-#include <dxva2api.h>
-#include <evr.h>
-
-
-class CMPCVideoDecFilter;
-class CVideoDecDXVAAllocator;
-
-interface __declspec(uuid("AE7EC2A2-1913-4a80-8DD6-DF1497ABA494"))
-IMPCDXVA2Sample :
-public IUnknown {
- STDMETHOD_(int, GetDXSurfaceId()) PURE;
-};
-
-class CDXVA2Sample : public CMediaSample, public IMFGetService, public IMPCDXVA2Sample
-{
- friend class CVideoDecDXVAAllocator;
-
-public:
-
- CDXVA2Sample(CVideoDecDXVAAllocator* pAlloc, HRESULT* phr);
-
- //Note: CMediaSample does not derive from CUnknown, so we cannot use the
- // DECLARE_IUNKNOWN macro that is used by most of the filter classes.
-
- STDMETHODIMP QueryInterface(REFIID riid, __deref_out void** ppv);
- STDMETHODIMP_(ULONG) AddRef();
- STDMETHODIMP_(ULONG) Release();
-
- // IMFGetService::GetService
- STDMETHODIMP GetService(REFGUID guidService, REFIID riid, LPVOID* ppv);
-
- // IMPCDXVA2Sample
- STDMETHODIMP_(int) GetDXSurfaceId();
-
- // Override GetPointer because this class does not manage a system memory buffer.
- // The EVR uses the MR_BUFFER_SERVICE service to get the Direct3D surface.
- STDMETHODIMP GetPointer(BYTE** ppBuffer);
-
-private:
-
- // Sets the pointer to the Direct3D surface.
- void SetSurface(DWORD surfaceId, IDirect3DSurface9* pSurf);
-
- CComPtr<IDirect3DSurface9> m_pSurface;
- DWORD m_dwSurfaceId;
-};
-
-
-class CVideoDecDXVAAllocator : public CBaseAllocator
-{
-public:
- CVideoDecDXVAAllocator(CMPCVideoDecFilter* pVideoDecFilter, HRESULT* phr);
- virtual ~CVideoDecDXVAAllocator();
-
-protected:
- HRESULT Alloc();
- void Free();
-
-private:
- CMPCVideoDecFilter* m_pVideoDecFilter;
- IDirect3DSurface9** m_ppRTSurfaceArray;
- UINT m_nSurfaceArrayCount;
-
-};
diff --git a/src/filters/transform/MPCVideoDec/VideoDecOutputPin.cpp b/src/filters/transform/MPCVideoDec/VideoDecOutputPin.cpp
deleted file mode 100644
index a0b9e1c8e..000000000
--- a/src/filters/transform/MPCVideoDec/VideoDecOutputPin.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "VideoDecOutputPin.h"
-#include "VideoDecDXVAAllocator.h"
-#include "MPCVideoDecFilter.h"
-#include "../../../DSUtil/DSUtil.h"
-
-CVideoDecOutputPin::CVideoDecOutputPin(TCHAR* pObjectName, CBaseVideoFilter* pFilter, HRESULT* phr, LPCWSTR pName)
- : CBaseVideoOutputPin(pObjectName, pFilter, phr, pName)
-{
- m_pVideoDecFilter = static_cast<CMPCVideoDecFilter*>(pFilter);
- m_pDXVA2Allocator = nullptr;
- m_dwDXVA1SurfaceCount = 0;
- m_GuidDecoderDXVA1 = GUID_NULL;
- ZeroMemory(&m_ddUncompPixelFormat, sizeof(m_ddUncompPixelFormat));
-}
-
-CVideoDecOutputPin::~CVideoDecOutputPin()
-{
-}
-
-HRESULT CVideoDecOutputPin::InitAllocator(IMemAllocator** ppAlloc)
-{
- TRACE(_T("CVideoDecOutputPin::InitAllocator\n"));
- if (m_pVideoDecFilter->UseDXVA2()) {
- HRESULT hr = S_FALSE;
- m_pDXVA2Allocator = DEBUG_NEW CVideoDecDXVAAllocator(m_pVideoDecFilter, &hr);
- if (!m_pDXVA2Allocator) {
- return E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- delete m_pDXVA2Allocator;
- return hr;
- }
- // Return the IMemAllocator interface.
- return m_pDXVA2Allocator->QueryInterface(__uuidof(IMemAllocator), (void**)ppAlloc);
- } else {
- return __super::InitAllocator(ppAlloc);
- }
-}
-
-STDMETHODIMP CVideoDecOutputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv)
-{
- return
- QI(IAMVideoAcceleratorNotify)
- __super::NonDelegatingQueryInterface(riid, ppv);
-}
-
-// === IAMVideoAcceleratorNotify
-STDMETHODIMP CVideoDecOutputPin::GetUncompSurfacesInfo(const GUID* pGuid, LPAMVAUncompBufferInfo pUncompBufferInfo)
-{
- HRESULT hr = E_INVALIDARG;
-
- if (SUCCEEDED(m_pVideoDecFilter->CheckDXVA1Decoder(pGuid))) {
- CComQIPtr<IAMVideoAccelerator> pAMVideoAccelerator = GetConnected();
-
- if (pAMVideoAccelerator) {
- pUncompBufferInfo->dwMaxNumSurfaces = m_pVideoDecFilter->GetPicEntryNumber();
- pUncompBufferInfo->dwMinNumSurfaces = m_pVideoDecFilter->GetPicEntryNumber();
-
- hr = m_pVideoDecFilter->FindDXVA1DecoderConfiguration(pAMVideoAccelerator, pGuid, &pUncompBufferInfo->ddUncompPixelFormat);
- if (SUCCEEDED(hr)) {
- memcpy(&m_ddUncompPixelFormat, &pUncompBufferInfo->ddUncompPixelFormat, sizeof(DDPIXELFORMAT));
- m_GuidDecoderDXVA1 = *pGuid;
- }
- }
- }
- return hr;
-}
-
-STDMETHODIMP CVideoDecOutputPin::SetUncompSurfacesInfo(DWORD dwActualUncompSurfacesAllocated)
-{
- m_dwDXVA1SurfaceCount = dwActualUncompSurfacesAllocated;
- return S_OK;
-}
-
-STDMETHODIMP CVideoDecOutputPin::GetCreateVideoAcceleratorData(const GUID* pGuid, LPDWORD pdwSizeMiscData, LPVOID* ppMiscData)
-{
- HRESULT hr = E_UNEXPECTED;
- AMVAUncompDataInfo UncompInfo;
- AMVACompBufferInfo CompInfo[30];
- DWORD dwNumTypesCompBuffers = _countof(CompInfo);
- CComQIPtr<IAMVideoAccelerator> pAMVideoAccelerator = GetConnected();
- DXVA_ConnectMode* pConnectMode;
-
- if (pAMVideoAccelerator) {
- memcpy(&UncompInfo.ddUncompPixelFormat, &m_ddUncompPixelFormat, sizeof(DDPIXELFORMAT));
- UncompInfo.dwUncompWidth = m_pVideoDecFilter->PictWidthRounded();
- UncompInfo.dwUncompHeight = m_pVideoDecFilter->PictHeightRounded();
- hr = pAMVideoAccelerator->GetCompBufferInfo(&m_GuidDecoderDXVA1, &UncompInfo, &dwNumTypesCompBuffers, CompInfo);
-
- if (SUCCEEDED(hr)) {
- hr = m_pVideoDecFilter->CreateDXVA1Decoder(pAMVideoAccelerator, pGuid, m_dwDXVA1SurfaceCount);
-
- if (SUCCEEDED(hr)) {
- m_pVideoDecFilter->SetDXVA1Params(&m_GuidDecoderDXVA1, &m_ddUncompPixelFormat);
-
- pConnectMode = (DXVA_ConnectMode*)CoTaskMemAlloc(sizeof(DXVA_ConnectMode));
- if (pConnectMode != nullptr) {
- pConnectMode->guidMode = m_GuidDecoderDXVA1;
- pConnectMode->wRestrictedMode = m_pVideoDecFilter->GetDXVA1RestrictedMode();
- *pdwSizeMiscData = sizeof(DXVA_ConnectMode);
- *ppMiscData = pConnectMode;
- } else {
- hr = E_OUTOFMEMORY;
- }
- }
- }
- }
-
- return hr;
-}
diff --git a/src/filters/transform/MPCVideoDec/VideoDecOutputPin.h b/src/filters/transform/MPCVideoDec/VideoDecOutputPin.h
deleted file mode 100644
index d0254bd4c..000000000
--- a/src/filters/transform/MPCVideoDec/VideoDecOutputPin.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * (C) 2007-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <videoacc.h>
-#include "../BaseVideoFilter/BaseVideoFilter.h"
-
-
-class CMPCVideoDecFilter;
-class CVideoDecDXVAAllocator;
-
-
-class CVideoDecOutputPin : public CBaseVideoOutputPin
- , public IAMVideoAcceleratorNotify
-{
-public:
- CVideoDecOutputPin(TCHAR* pObjectName, CBaseVideoFilter* pFilter, HRESULT* phr, LPCWSTR pName);
-
- ~CVideoDecOutputPin();
-
- HRESULT InitAllocator(IMemAllocator** ppAlloc);
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // IAMVideoAcceleratorNotify
- STDMETHODIMP GetUncompSurfacesInfo(const GUID* pGuid, LPAMVAUncompBufferInfo pUncompBufferInfo);
- STDMETHODIMP SetUncompSurfacesInfo(DWORD dwActualUncompSurfacesAllocated);
- STDMETHODIMP GetCreateVideoAcceleratorData(const GUID* pGuid, LPDWORD pdwSizeMiscData, LPVOID* ppMiscData);
-
-private:
- CMPCVideoDecFilter* m_pVideoDecFilter;
- CVideoDecDXVAAllocator* m_pDXVA2Allocator;
- DWORD m_dwDXVA1SurfaceCount;
- GUID m_GuidDecoderDXVA1;
- DDPIXELFORMAT m_ddUncompPixelFormat;
-};
diff --git a/src/filters/transform/MPCVideoDec/array_allocator.h b/src/filters/transform/MPCVideoDec/array_allocator.h
deleted file mode 100644
index ea4241376..000000000
--- a/src/filters/transform/MPCVideoDec/array_allocator.h
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef _ARRAY_ALLOCATOR_H_
-#define _ARRAY_ALLOCATOR_H_
-
-#include "PODtypes.h"
-
-template <class T, size_t size> class array_allocator
-{
-private:
- T* p;
-public:
- typedef T value_type;
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
-
- typedef T* pointer;
- typedef const T* const_pointer;
-
- typedef T& reference;
- typedef const T& const_reference;
-
- pointer address(reference r) const {return &r;}
- const_pointer address(const_reference r) const {return &r;}
-
- array_allocator() throw() {}
- template <class U, size_t sz> array_allocator(const array_allocator<U, sz>&) throw() {}
- ~array_allocator() throw() {}
-
- pointer allocate(size_type n, const void* = 0) {
- p = ((T *)::operator new(size * sizeof(T)));
- return p;
- }
- void deallocate(pointer p, size_type) {delete p;}
-
- //Use placement new to engage the constructor
- void construct(pointer p, const T& val) {new((void*)p) T(val);}
- void destroy(pointer p) {((T*)p)->~T();}
-
- size_type max_size() const throw() {return size;}
- template<class U> struct rebind {typedef array_allocator<U, size> other;};
-};
-
-template<class T, size_t size> struct array_vector : std::vector<T, array_allocator<T, size> > {
-};
-
-#if defined(__INTEL_COMPILER) || defined(__GNUC__) || (_MSC_VER >= 1300)
-template<class T, size_t a> struct allocator_traits<array_allocator<T, a> > {enum {is_static = true};};
-#endif
-
-#endif
diff --git a/src/filters/transform/MPCVideoDec/char_t.h b/src/filters/transform/MPCVideoDec/char_t.h
deleted file mode 100644
index ad422fd10..000000000
--- a/src/filters/transform/MPCVideoDec/char_t.h
+++ /dev/null
@@ -1,291 +0,0 @@
-#ifndef _CHAR_T_H_
-#define _CHAR_T_H_
-
-#include <stdio.h>
-#include <time.h>
-#include <wchar.h>
-
-#pragma warning(push)
-#pragma warning(disable:4995 4996)
-
-#undef _l
-#ifdef UNICODE
-typedef wchar_t char_t;
-#define tsprintf swprintf
-#define tsnprintf_s _snwprintf_s
-#define tfprintf fwprintf
-#define tsscanf swscanf
-#define __l(x) L ## x
-#define _l(x) __l(x)
-#else
-typedef char char_t;
-#define tsprintf sprintf
-#define tsnprintf_s _snprintf_s
-#define tfprintf fprintf
-#define tsscanf sscanf
-#define _l(x) x
-#endif
-
-#ifdef __cplusplus
-
-#ifdef __GNUC__
-#ifndef __forceinline
-#define __forceinline __attribute__((__always_inline__)) inline
-#endif
-#endif
-
-static __forceinline errno_t strncat_s(wchar_t *a, size_t b, const wchar_t *c, size_t d)
-{
- return wcsncat_s(a, b, c, d);
-}
-static __forceinline int vsnprintf_s(wchar_t *a, size_t b, size_t c, const wchar_t *d, va_list e)
-{
- return _vsnwprintf_s(a, b, c, d, e);
-}
-static __forceinline errno_t _splitpath_s(const wchar_t * a,
- wchar_t * b, size_t c, wchar_t * d, size_t e,
- wchar_t * f, size_t g, wchar_t * h, size_t i)
-{
- return _wsplitpath_s(a, b, c, d, e, f, g, h, i);
-};
-static __forceinline errno_t _makepath_s(wchar_t *a, size_t b,
- const wchar_t *c, const wchar_t *d,
- const wchar_t *e, const wchar_t *f)
-{
- return _wmakepath_s(a, b, c, d, e, f);
-};
-static __forceinline wchar_t* ff_strncpy(wchar_t *dst, const wchar_t *src, size_t count)
-{
- wcsncpy_s(dst, count, src, _TRUNCATE);
- return dst;
-}
-static __forceinline char* ff_strncpy(char *dst, const char *src, size_t count)
-{
- strncpy_s(dst, count, src, _TRUNCATE);
- return dst;
-}
-
-static __forceinline wchar_t* strcat(wchar_t *a, const wchar_t *b)
-{
- return wcscat(a, b);
-}
-static __forceinline int strcmp(const wchar_t *a, const wchar_t *b)
-{
- return wcscmp(a, b);
-}
-static __forceinline int strncmp(const wchar_t *a, const wchar_t *b, size_t c)
-{
- return wcsncmp(a, b, c);
-}
-static __forceinline int strnicmp(const wchar_t *a, const wchar_t *b, size_t c)
-{
- return _wcsnicmp(a, b, c);
-}
-
-static __forceinline long strtol(const wchar_t *a, wchar_t **b, int c)
-{
- return wcstol(a, b, c);
-}
-static __forceinline wchar_t* strchr(const wchar_t *a, wchar_t b)
-{
- return (wchar_t*)wcschr(a, b);
-}
-static __forceinline int _strnicmp(const wchar_t *a, const wchar_t *b, size_t c)
-{
- return _wcsnicmp(a, b, c);
-}
-static __forceinline wchar_t* strstr(const wchar_t *a, const wchar_t *b)
-{
- return (wchar_t*)wcsstr(a, b);
-}
-static __forceinline size_t strlen(const wchar_t *a)
-{
- return wcslen(a);
-}
-static __forceinline wchar_t* strcpy(wchar_t *a, const wchar_t *b)
-{
- return wcscpy(a, b);
-}
-static __forceinline int atoi(const wchar_t *a)
-{
- return _wtoi(a);
-}
-static __forceinline wchar_t* _itoa(int a, wchar_t *b, int c)
-{
- return _itow(a, b, c);
-}
-static __forceinline int stricmp(const wchar_t *a, const wchar_t *b)
-{
- return _wcsicmp(a, b);
-}
-static __forceinline unsigned long strtoul(const wchar_t *a, wchar_t **b, int c)
-{
- return wcstoul(a, b, c);
-}
-static __forceinline double strtod(const wchar_t *a, wchar_t **b)
-{
- return wcstod(a, b);
-}
-static __forceinline int vsprintf(wchar_t *a, const wchar_t *b, va_list c)
-{
- return vswprintf(a, b, c);
-}
-static __forceinline int _vsnprintf(wchar_t *a, size_t b, const wchar_t *c, va_list d)
-{
- return _vsnwprintf(a, b, c, d);
-}
-
-static __forceinline FILE* fopen(const wchar_t *a, const wchar_t *b)
-{
- return _wfopen(a, b);
-}
-static __forceinline int fputs(const wchar_t *a, FILE *b)
-{
- return fputws(a, b);
-}
-static __forceinline int _stricoll(const wchar_t *a, const wchar_t *b)
-{
- return _wcsicoll(a, b);
-}
-static __forceinline wchar_t* strrchr(const wchar_t *a, wchar_t b)
-{
- return (wchar_t*)wcsrchr(a, b);
-}
-static __forceinline wchar_t* strupr(wchar_t *a)
-{
- return _wcsupr(a);
-}
-static __forceinline wchar_t* strlwr(wchar_t *a)
-{
- return _wcslwr(a);
-}
-static __forceinline wchar_t* _strtime(wchar_t *a)
-{
- return _wstrtime(a);
-}
-static __forceinline wchar_t* memchr(wchar_t *a, wchar_t b, size_t c)
-{
- return wmemchr(a, b, c);
-}
-static __forceinline const wchar_t* memchr(const wchar_t *a, wchar_t b, size_t c)
-{
- return wmemchr(a, b, c);
-}
-static __forceinline wchar_t* strpbrk(const wchar_t *a, const wchar_t *b)
-{
- return (wchar_t*)wcspbrk(a, b);
-}
-static __forceinline int64_t _strtoi64(const wchar_t *nptr, wchar_t **endptr, int base)
-{
- return _wcstoi64(nptr, endptr, base);
-};
-
-template<class Tout> struct text
- // ANSI <--> UNICODE conversion.
- // in : input string in char* or wchar_t*.
- // inlen : count of characters, not byte size!! -1 for null terminated string.
- // out : output string in char* or wchar_t*.
- // outlen : count of characters, not byte size!!
-{
-private:
- Tout *buf;
- bool own;
-public:
- template<class Tin> inline text(const Tin *in, int code_page = CP_ACP);
- template<class Tin> inline text(const Tin *in, Tout *Ibuf, int code_page = CP_ACP);
- template<class Tin> inline text(const Tin *in, int inlen, Tout *Ibuf, size_t outlen, int code_page = CP_ACP);
- ~text() {
- if (own) {
- delete []buf;
- }
- }
- operator const Tout*() const {
- return buf;
- }
-};
-
-
-template<> template<> inline text<char>::text(const char *in, int code_page): buf(const_cast<char*>(in)), own(false) {}
-template<> template<> inline text<char>::text(const char *in, char *Ibuf, int code_page): buf(strcpy(Ibuf, in)), own(false) {}
-template<> template<> inline text<char>::text(const char *in, int inlen, char *Ibuf, size_t outlen, int code_page): own(false)
-{
- if (inlen != -1) {
- buf = Ibuf;
- if ((size_t)inlen < outlen) {
- ff_strncpy(Ibuf, in, inlen + 1);
- } else {
- ff_strncpy(Ibuf, in, outlen);
- }
- } else {
- buf = Ibuf;
- ff_strncpy(Ibuf, in, outlen);
- }
-}
-
-
-template<> template<> inline text<wchar_t>::text(const wchar_t *in, int code_page): buf(const_cast<wchar_t*>(in)), own(false) {}
-template<> template<> inline text<wchar_t>::text(const wchar_t *in, wchar_t *Ibuf, int code_page): buf(strcpy(Ibuf, in)), own(false) {}
-template<> template<> inline text<wchar_t>::text(const wchar_t *in, int inlen, wchar_t *Ibuf, size_t outlen, int code_page): own(false)
-{
- if (inlen != -1) {
- buf = Ibuf;
- if ((size_t)inlen < outlen) {
- ff_strncpy(Ibuf, in, inlen + 1);
- } else {
- ff_strncpy(Ibuf, in, outlen);
- }
- } else {
- buf = Ibuf;
- ff_strncpy(Ibuf, in, outlen);
- }
-}
-
-
-template<> template<> inline text<wchar_t>::text(const char *in, int code_page): own(in ? true : false)
-{
- if (in) {
- size_t l = strlen(in);
- buf = new wchar_t[l + 1];
- MultiByteToWideChar(code_page, 0, in, int(l + 1), buf, int(l + 1));
- } else {
- buf = NULL;
- }
-}
-template<> template<> inline text<wchar_t>::text(const char *in, wchar_t *Ibuf, int code_page): own(false), buf(Ibuf)
-{
- size_t l = strlen(in);
- MultiByteToWideChar(code_page, 0, in, int(l + 1), buf, int(l + 1));
-}
-template<> template<> inline text<wchar_t>::text(const char *in, int inlen, wchar_t *Ibuf, size_t outlen, int code_page): own(false), buf(Ibuf)
-{
- MultiByteToWideChar(code_page, 0, in, int(inlen), buf, int(outlen));
-}
-
-
-template<> template<> inline text<char>::text(const wchar_t *in, int code_page): own(in ? true : false)
-{
- if (in) {
- size_t l = strlen(in);
- int length = WideCharToMultiByte(code_page, 0, in, int(l + 1), buf, 0, NULL, NULL);
- buf = new char[length + 1];
- WideCharToMultiByte(code_page, 0, in, int(l + 1), buf, int(length + 1), NULL, NULL);
- } else {
- buf = NULL;
- }
-}
-template<> template<> inline text<char>::text(const wchar_t *in, char *Ibuf, int code_page): own(false), buf(Ibuf)
-{
- size_t l = strlen(in);
- int length = WideCharToMultiByte(code_page, 0, in, int(l + 1), buf, 0, NULL, NULL);
- WideCharToMultiByte(code_page, 0, in, int(l + 1), buf, length, NULL, NULL);
-}
-template<> template<> inline text<char>::text(const wchar_t *in, int inlen, char *Ibuf, size_t outlen, int code_page): own(false), buf(Ibuf)
-{
- WideCharToMultiByte(code_page, 0, in, int(inlen), buf, int(outlen), NULL, NULL);
-}
-
-#endif
-
-#pragma warning(pop)
-
-#endif
diff --git a/src/filters/transform/MPCVideoDec/ffImgfmt.cpp b/src/filters/transform/MPCVideoDec/ffImgfmt.cpp
deleted file mode 100644
index 5bb8cbdd8..000000000
--- a/src/filters/transform/MPCVideoDec/ffImgfmt.cpp
+++ /dev/null
@@ -1,1562 +0,0 @@
-/*
- * Copyright (c) 2003-2006 Milan Cutka
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "stdafx.h"
-#include <vector>
-#include "ffmpeg/libavcodec/avcodec.h"
-#include <uuids.h>
-#include "moreuuids.h"
-#include "char_t.h"
-#include "ffImgfmt.h"
-
-const TcspInfo cspInfos[] = {
- {
- FF_CSP_420P, _l("YV12"),
- 1, 12, //Bpp
- 3, //numplanes
- {0, 1, 1, 0}, //shiftX
- {0, 1, 1, 0}, //shiftY
- {0, 128, 128, 0}, //black,
- FOURCC_YV12, FOURCC_YV12, &MEDIASUBTYPE_YV12
- },
- {
- FF_CSP_422P, _l("422P"),
- 1, 16, //Bpp
- 3, //numplanes
- {0, 1, 1, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 128, 128, 0}, //black
- FOURCC_422P, FOURCC_422P, &MEDIASUBTYPE_422P
- },
- {
- FF_CSP_444P, _l("444P"),
- 1, 24, //Bpp
- 3, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 128, 128, 0}, //black
- FOURCC_444P, FOURCC_444P, &MEDIASUBTYPE_444P
- },
- {
- FF_CSP_411P, _l("411P"),
- 1, 17, //Bpp
- 3, //numplanes
- {0, 2, 2, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 128, 128, 0}, //black
- FOURCC_411P, FOURCC_411P, &MEDIASUBTYPE_411P
- },
- {
- FF_CSP_410P, _l("410P"),
- 1, 10, //Bpp
- 3, //numplanes
- {0, 2, 2, 0}, //shiftX
- {0, 2, 2, 0}, //shiftY
- {0, 128, 128, 0}, //black
- FOURCC_410P, FOURCC_410P, &MEDIASUBTYPE_410P
- },
-
- {
- FF_CSP_YUY2, _l("YUY2"),
- 2, 16, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0x8000, 0, 0, 0}, //black
- FOURCC_YUY2, FOURCC_YUY2, &MEDIASUBTYPE_YUY2,
- 0, 1 //packedLumaOffset,packedChromaOffset
- },
- {
- FF_CSP_UYVY, _l("UYVY"),
- 2, 16, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0x0080, 0, 0, 0}, //black
- FOURCC_UYVY, FOURCC_UYVY, &MEDIASUBTYPE_UYVY,
- 1, 0 //packedLumaOffset,packedChromaOffset
- },
- {
- FF_CSP_YVYU, _l("YVYU"),
- 2, 16, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0x8000, 0, 0, 0}, //black
- FOURCC_YVYU, FOURCC_YVYU, &MEDIASUBTYPE_YVYU,
- 0, 1 //packedLumaOffset,packedChromaOffset
- },
- {
- FF_CSP_VYUY, _l("VYUY"),
- 2, 16, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0x0080, 0, 0, 0}, //black
- FOURCC_VYUY, FOURCC_VYUY, &MEDIASUBTYPE_VYUY,
- 1, 0 //packedLumaOffset,packedChromaOffset
- },
-
- {
- FF_CSP_ABGR, _l("ABGR"),
- 4, 32, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- BI_RGB, 0, &MEDIASUBTYPE_RGB32
- },
- {
- FF_CSP_RGBA, _l("RGBA"),
- 4, 32, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- BI_RGB, 0, &MEDIASUBTYPE_RGB32
- },
- {
- FF_CSP_BGR32, _l("BGR32"),
- 4, 32, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- BI_RGB, 0, &MEDIASUBTYPE_RGB32
- },
- {
- FF_CSP_BGR24, _l("BGR24"),
- 3, 24, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- BI_RGB, 0, &MEDIASUBTYPE_RGB24
- },
- {
- FF_CSP_BGR15, _l("BGR15"),
- 2, 16, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- BI_RGB, 0, &MEDIASUBTYPE_RGB555
- },
- {
- FF_CSP_BGR16, _l("BGR16"),
- 2, 16, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- BI_RGB, 0, &MEDIASUBTYPE_RGB565
- },
- {
- FF_CSP_RGB32, _l("RGB32"),
- 4, 32, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- BI_RGB, FOURCC_RGB3, &MEDIASUBTYPE_RGB32
- },
- {
- FF_CSP_RGB24, _l("RGB24"),
- 3, 24, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- BI_RGB, FOURCC_RGB2, &MEDIASUBTYPE_RGB24
- },
- {
- FF_CSP_RGB15, _l("RGB15"),
- 2, 16, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- BI_RGB, FOURCC_RGB5, &MEDIASUBTYPE_RGB555
- },
- {
- FF_CSP_RGB16, _l("RGB16"),
- 2, 16, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- BI_RGB, FOURCC_RGB6, &MEDIASUBTYPE_RGB565
- },
- {
- FF_CSP_CLJR, _l("cljr"),
- 1, 16, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- FOURCC_CLJR, FOURCC_CLJR, &MEDIASUBTYPE_CLJR
- },
- {
- FF_CSP_Y800, _l("gray"),
- 1, 8, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- FOURCC_Y800, FOURCC_Y800, &MEDIASUBTYPE_Y800
- },
- {
- FF_CSP_NV12, _l("NV12"),
- 1, 12, //Bpp
- 2, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 1, 1, 0}, //shiftY
- {0, 128, 128, 0}, //black
- FOURCC_NV12, FOURCC_NV12, &MEDIASUBTYPE_NV12
- },
- {
- FF_CSP_420P10, _l("420P10"),
- 2, 24, //Bpp
- 3, //numplanes
- {0, 1, 1, 0}, //shiftX
- {0, 1, 1, 0}, //shiftY
- {0, 512, 512, 0}, //black
- FOURCC_420R, FOURCC_420R, &MEDIASUBTYPE_420R
- },
- {
- FF_CSP_444P10, _l("444P10"),
- 2, 48, //Bpp
- 3, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 512, 512, 0}, //black
- FOURCC_444R, FOURCC_444R, &MEDIASUBTYPE_444R
- },
- {
- FF_CSP_P016, _l("P016"),
- 2, 24, //Bpp
- 2, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 1, 1, 0}, //shiftY
- {0, 32768, 32768, 0}, //black,
- FOURCC_P016, FOURCC_P016, &MEDIASUBTYPE_P016
- },
- {
- FF_CSP_P010, _l("P010"),
- 2, 24, //Bpp
- 2, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 1, 1, 0}, //shiftY
- {0, 32768, 32768, 0}, //black,
- FOURCC_P010, FOURCC_P010, &MEDIASUBTYPE_P010
- },
- {
- FF_CSP_422P10, _l("422P10"),
- 2, 32, //Bpp
- 3, //numplanes
- {0, 1, 1, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 512, 512, 0}, //black
- FOURCC_422R, FOURCC_422R, &MEDIASUBTYPE_422R
- },
- {
- FF_CSP_P210, _l("P210"),
- 2, 32, //Bpp
- 2, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 32768, 32768, 0}, //black,
- FOURCC_P210, FOURCC_P210, &MEDIASUBTYPE_P210
- },
- {
- FF_CSP_P216, _l("P216"),
- 2, 32, //Bpp
- 2, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 32768, 32768, 0}, //black,
- FOURCC_P216, FOURCC_P216, &MEDIASUBTYPE_P216
- },
- {
- FF_CSP_AYUV, _l("AYUV"),
- 4, 32, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 128, 128, 0}, //black
- FOURCC_AYUV, FOURCC_AYUV, &MEDIASUBTYPE_AYUV
- },
- {
- FF_CSP_Y416, _l("Y416"),
- 8, 64, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 32768, 32768, 0}, //black
- FOURCC_Y416, FOURCC_Y416, &MEDIASUBTYPE_Y416
- },
- {
- FF_CSP_PAL8, _l("pal8"),
- 1, 8, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- BI_RGB, 0, &MEDIASUBTYPE_RGB8
- },
- {
- FF_CSP_GBRP, _l("GBRP"),
- 1, 24, //Bpp
- 3, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- 0, 0, NULL
- },
- {
- FF_CSP_GBRP9, _l("GBRP9"),
- 2, 48, //Bpp
- 3, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- 0, 0, NULL
- },
- {
- FF_CSP_GBRP10, _l("GBRP10"),
- 2, 48, //Bpp
- 3, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- 0, 0, NULL
- },
- 0
-};
-
-TcspInfo cspInfoIYUV = {
- FF_CSP_420P, _l("YV12"),
- 1, 12, //Bpp
- 3, //numplanes
- {0, 1, 1, 0}, //shiftX
- {0, 1, 1, 0}, //shiftY
- {0, 128, 128, 0}, //black,
- FOURCC_IYUV, FOURCC_IYUV, &MEDIASUBTYPE_IYUV
-};
-
-const TcspFcc cspFccs[] = {
- _l("YV12") , FOURCC_YV12, FF_CSP_420P | FF_CSP_FLAGS_YUV_ADJ, false, true,
- _l("I420/IYUV"), FOURCC_I420, FF_CSP_420P | FF_CSP_FLAGS_YUV_ADJ | FF_CSP_FLAGS_YUV_ORDER, false, true,
- _l("YUY2") , FOURCC_YUY2, FF_CSP_YUY2, false, true,
- _l("YVYU") , FOURCC_YVYU, FF_CSP_YVYU, false, true,
- _l("UYVY") , FOURCC_UYVY, FF_CSP_UYVY, false, true,
- _l("VYUY") , FOURCC_VYUY, FF_CSP_VYUY, false, true,
- _l("RGB32") , FOURCC_RGB3, FF_CSP_RGB32, true, true,
- _l("RGB24") , FOURCC_RGB2, FF_CSP_RGB24, true, true,
- _l("RGB555") , FOURCC_RGB5, FF_CSP_RGB15, true, true,
- _l("RGB565") , FOURCC_RGB6, FF_CSP_RGB16, true, true,
- _l("CLJR") , FOURCC_CLJR, FF_CSP_CLJR, false, false,
- _l("Y800") , FOURCC_Y800, FF_CSP_Y800, false, true,
- _l("NV12") , FOURCC_NV12, FF_CSP_NV12, false, false,
- _l("P016") , FOURCC_P016, FF_CSP_P016, false, false,
- _l("P010") , FOURCC_P010, FF_CSP_P010, false, false,
- _l("P210") , FOURCC_P210, FF_CSP_P210, false, false,
- _l("P216") , FOURCC_P216, FF_CSP_P216, false, false,
- _l("AYUV") , FOURCC_AYUV, FF_CSP_AYUV, false, false,
- _l("Y416") , FOURCC_Y416, FF_CSP_Y416, false, false,
- NULL, 0
-};
-
-char_t* csp_getName(uint64_t csp, char_t *buf, size_t len)
-{
- return csp_getName2(csp_getInfo(csp), csp, buf, len);
-}
-char_t* csp_getName2(const TcspInfo *cspInfo, uint64_t csp, char_t *buf, size_t len)
-{
- const char_t *colorspaceName = cspInfo ? cspInfo->name : _l("unknown");
- tsnprintf_s(buf,
- len,
- _TRUNCATE,
- _l("%s%s%s"),
- colorspaceName,
- csp & FF_CSP_FLAGS_VFLIP ? _l(", flipped vertically") : _l(""),
- csp & FF_CSP_FLAGS_INTERLACED ? _l(", interlaced") : _l(""));
- return buf;
-}
-
-const TcspInfo* csp_getInfoFcc(FOURCC fcccsp)
-{
- if (fcccsp == FOURCC_IYUV || fcccsp == FOURCC_I420) {
- return &cspInfoIYUV;
- } else {
- for (int i = 0; i < FF_CSPS_NUM; i++) {
- if (cspInfos[i].fcccsp == fcccsp) {
- return cspInfos + i;
- }
- }
- return NULL;
- }
-}
-
-uint64_t csp_bestMatch(uint64_t inCSP, uint64_t wantedCSPS, int *rank, uint64_t outPrimaryCSP)
-{
- if (outPrimaryCSP & wantedCSPS & FF_CSPS_MASK) {
- if (rank) {
- *rank = 200;
- }
- return outPrimaryCSP | (inCSP&~FF_CSPS_MASK);
- }
- uint64_t outCSP = inCSP & wantedCSPS & FF_CSPS_MASK;
- if (outCSP) {
- if (rank) {
- *rank = 100;
- }
- return outCSP | (inCSP&~FF_CSPS_MASK);
- }
-
- const uint64_t *bestcsps = NULL;
- switch (inCSP & FF_CSPS_MASK) {
- case FF_CSP_420P: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_NV12 ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_422P: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_420P ,
- FF_CSP_NV12 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_444P: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_AYUV ,
- FF_CSP_444P10,
- FF_CSP_Y416 ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P ,
- FF_CSP_NV12 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_411P: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_420P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_410P: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_420P ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_411P ,
- FF_CSP_NV12 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
-
- case FF_CSP_YUY2: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_420P ,
- FF_CSP_NV12 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_UYVY: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_YUY2 ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_420P ,
- FF_CSP_NV12 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_YVYU: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_420P ,
- FF_CSP_NV12 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_VYUY: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_420P ,
- FF_CSP_NV12 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
-
- case FF_CSP_ABGR: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_RGBA: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_ABGR ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P ,
- FF_CSP_NV12 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_BGR32: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P ,
- FF_CSP_NV12 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_BGR24: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_RGB24,
- FF_CSP_BGR32,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_RGB32,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P ,
- FF_CSP_NV12 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_BGR15: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_BGR32,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR24,
- FF_CSP_BGR16,
- FF_CSP_RGB32,
- FF_CSP_RGB24,
- FF_CSP_RGB15,
- FF_CSP_RGB16,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_BGR16: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_BGR32,
- FF_CSP_BGR24,
- FF_CSP_BGR15,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_RGB32,
- FF_CSP_RGB24,
- FF_CSP_RGB15,
- FF_CSP_RGB16,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_RGB32: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P ,
- FF_CSP_420P10,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR15,
- FF_CSP_BGR16,
- FF_CSP_RGB15,
- FF_CSP_RGB16,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_RGB24: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_BGR24,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR15,
- FF_CSP_BGR16,
- FF_CSP_RGB15,
- FF_CSP_RGB16,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_RGB15: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_BGR15,
- FF_CSP_RGB32,
- FF_CSP_RGB24,
- FF_CSP_RGB16,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_BGR24,
- FF_CSP_BGR16,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_RGB16: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_RGB15,
- FF_CSP_RGB32,
- FF_CSP_RGB24,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_BGR24,
- FF_CSP_BGR15,
- FF_CSP_BGR16,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_CLJR: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_420P ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_Y800: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_420P ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_NV12: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_420P ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_420P10: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_444P10,
- FF_CSP_Y416 ,
- FF_CSP_NV12 ,
- FF_CSP_420P ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_444P ,
- FF_CSP_AYUV ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_422P10: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_Y416 ,
- FF_CSP_422P ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_444P10,
- FF_CSP_444P ,
- FF_CSP_AYUV ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_420P ,
- FF_CSP_NV12 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_444P10: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_Y416 ,
- FF_CSP_444P ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_AYUV ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_420P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_PAL8: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_RGB32,
- FF_CSP_BGR32,
- FF_CSP_RGB24,
- FF_CSP_BGR24,
- FF_CSP_RGB15,
- FF_CSP_BGR15,
- FF_CSP_RGB16,
- FF_CSP_BGR16,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_444P ,
- FF_CSP_422P ,
- FF_CSP_420P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_GBRP: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_RGB32,
- FF_CSP_BGR32,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P ,
- FF_CSP_420P10,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR15,
- FF_CSP_BGR16,
- FF_CSP_RGB15,
- FF_CSP_RGB16,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_GBRP9: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_RGB32,
- FF_CSP_BGR32,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_444P10,
- FF_CSP_444P ,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P10,
- FF_CSP_422P ,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P10,
- FF_CSP_420P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR15,
- FF_CSP_BGR16,
- FF_CSP_RGB15,
- FF_CSP_RGB16,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_GBRP10: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_RGB32,
- FF_CSP_BGR32,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_444P10,
- FF_CSP_444P ,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P10,
- FF_CSP_422P ,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P10,
- FF_CSP_420P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR15,
- FF_CSP_BGR16,
- FF_CSP_RGB15,
- FF_CSP_RGB16,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- default:
- return FF_CSP_NULL;
- }
- if (rank) {
- *rank = 99;
- }
- while (*bestcsps) {
- if (*bestcsps & wantedCSPS) {
- return *bestcsps | (inCSP&~FF_CSPS_MASK);
- }
- bestcsps++;
- if (rank) {
- (*rank)--;
- }
- }
- return FF_CSP_NULL;
-}
-
-/*
-bool csp_inFOURCCmask(uint64_t x, FOURCC fcc)
-{
- switch (fcc) {
- case FOURCC_MASK_YUV:
- return !!csp_isYUV(x);
- case FOURCC_MASK_RGB:
- return !!csp_isRGB(x);
- default:
- return false;
- }
-}
-*/
-
-bool TcspInfos::TsortFc::operator()(const TcspInfo* &csp1, const TcspInfo* &csp2)
-{
- int rank1;
- csp_bestMatch(csp, csp1->id, &rank1, outPrimaryCSP);
- int rank2;
- csp_bestMatch(csp, csp2->id, &rank2, outPrimaryCSP);
- return rank1 > rank2;
-}
-
-/*
-void TcspInfos::sort(uint64_t csp, uint64_t outPrimaryCSP)
-{
- std::sort(begin(), end(), TsortFc(csp & FF_CSPS_MASK, outPrimaryCSP));
-}
-
-uint64_t getBMPcolorspace(const BITMAPINFOHEADER *hdr, const TcspInfos &forcedCsps)
-{
- uint64_t csp;
- switch (hdr->biCompression) {
- case BI_RGB:
- switch (hdr->biBitCount) {
- case 15:
- csp = FF_CSP_RGB15 | FF_CSP_FLAGS_VFLIP;
- break;
- case 16:
- csp = FF_CSP_RGB16 | FF_CSP_FLAGS_VFLIP;
- break;
- case 24:
- csp = FF_CSP_RGB24 | FF_CSP_FLAGS_VFLIP;
- break;
- case 32:
- csp = FF_CSP_RGB32 | FF_CSP_FLAGS_VFLIP;
- break;
- default:
- return FF_CSP_NULL;
- }
- break;
- case FOURCC_I420:
- case FOURCC_IYUV:
- csp = FF_CSP_420P | FF_CSP_FLAGS_YUV_ADJ | FF_CSP_FLAGS_YUV_ORDER;
- break;
- case FOURCC_YV12:
- csp = FF_CSP_420P | FF_CSP_FLAGS_YUV_ADJ;
- break;
- case FOURCC_YUYV:
- case FOURCC_YUY2:
- case FOURCC_V422:
- csp = FF_CSP_YUY2;
- break;
- case FOURCC_YVYU:
- csp = FF_CSP_YVYU;
- break;
- case FOURCC_UYVY:
- csp = FF_CSP_UYVY;
- break;
- case FOURCC_VYUY:
- csp = FF_CSP_VYUY;
- break;
- case FOURCC_Y800:
- csp = FF_CSP_Y800;
- break;
- case FOURCC_444P:
- case FOURCC_YV24:
- csp = FF_CSP_444P;
- break;
- case FOURCC_422P:
- csp = FF_CSP_422P;
- break;
- case FOURCC_YV16:
- csp = FF_CSP_422P | FF_CSP_FLAGS_YUV_ADJ;
- break;
- case FOURCC_411P:
- case FOURCC_Y41B:
- csp = FF_CSP_411P;
- break;
- case FOURCC_410P:
- csp = FF_CSP_410P;
- break;
- case FOURCC_420R:
- csp = FF_CSP_420P10;
- break;
- case FOURCC_422R:
- csp = FF_CSP_422P10;
- break;
- case FOURCC_444R:
- csp = FF_CSP_444P10;
- break;
- case FOURCC_P016:
- csp = FF_CSP_P016;
- break;
- case FOURCC_P010:
- csp = FF_CSP_P010;
- break;
- case FOURCC_P210:
- csp = FF_CSP_P210;
- break;
- case FOURCC_P216:
- csp = FF_CSP_P216;
- break;
- case FOURCC_AYUV:
- csp = FF_CSP_AYUV;
- break;
- case FOURCC_Y416:
- csp = FF_CSP_Y416;
- break;
- default:
- return FF_CSP_NULL;
- }
- bool ok;
- if (!forcedCsps.empty()) {
- ok = std::find(forcedCsps.begin(), forcedCsps.end(), csp_getInfo(csp)) != forcedCsps.end();
- } else {
- ok = true;
- }
- return ok ? csp : FF_CSP_NULL;
-}
-*/
diff --git a/src/filters/transform/MPCVideoDec/ffImgfmt.h b/src/filters/transform/MPCVideoDec/ffImgfmt.h
deleted file mode 100644
index 30f3c77cc..000000000
--- a/src/filters/transform/MPCVideoDec/ffImgfmt.h
+++ /dev/null
@@ -1,489 +0,0 @@
-#ifndef _FFIMGFMT_H_
-#define _FFIMGFMT_H_
-
-#include "ffmpeg/libavutil/pixfmt.h"
-
-//================================ ffdshow ==================================
-// the RGB related values in this enum refers to the "memory byte order" (byte order as stored in memory).
-// under x86 architecture (little endians), the byte order is stored reversed (comparing to the write order),
-// this means RGB will be stored in the memory as BGR.
-// When working with DirectShow in the Red-Green-Blue colorspace, DirectShow always
-// expects RGB at the "memory byte order", so RGB should be selected.
-// When working with files, we are interested in the "write order", which is the opposite
-// of the "memory byte order" (under x86), so you should select the opposite from the
-// destination byte order for the file.
-// (e.g. PNG images uses RGB order, so select BGR order
-// BMP image uses BGR order, so select RGB order)
-
-/* ffdshow colorspace ids, values should be unique including flag values, and must fit inside a uint64_t
- * (an enum should be used instead of defines, but GCC does not support an enum with type uint64_t ?)
- */
-
-// Do not reorder or renumber! Values are stored in user's registry.
-#define FF_CSP_NULL (0ULL)
-
-#define FF_CSP_420P (1ULL << 0) // 0x0000001
-#define FF_CSP_422P (1ULL << 1) // 0x0000002
-#define FF_CSP_444P (1ULL << 2) // 0x0000004
-#define FF_CSP_411P (1ULL << 3) // 0x0000008
-#define FF_CSP_410P (1ULL << 4) // 0x0000010
-
-#define FF_CSP_YUY2 (1ULL << 5) // 0x0000020
-#define FF_CSP_UYVY (1ULL << 6) // 0x0000040
-#define FF_CSP_YVYU (1ULL << 7) // 0x0000080
-#define FF_CSP_VYUY (1ULL << 8) // 0x0000100
-
-#define FF_CSP_ABGR (1ULL << 9) // 0x0000200 [a|b|g|r]
-#define FF_CSP_RGBA (1ULL << 10) // 0x0000400 [r|g|b|a]
-#define FF_CSP_BGR32 (1ULL << 11) // 0x0000800
-#define FF_CSP_BGR24 (1ULL << 12) // 0x0001000
-#define FF_CSP_BGR15 (1ULL << 13) // 0x0002000
-#define FF_CSP_BGR16 (1ULL << 14) // 0x0004000
-#define FF_CSP_RGB32 (1ULL << 15) // 0x0008000
-#define FF_CSP_RGB24 (1ULL << 16) // 0x0010000
-#define FF_CSP_RGB15 (1ULL << 17) // 0x0020000
-#define FF_CSP_RGB16 (1ULL << 18) // 0x0040000
-
-#define FF_CSP_CLJR (1ULL << 19) // 0x0080000
-#define FF_CSP_Y800 (1ULL << 20) // 0x0100000
-#define FF_CSP_NV12 (1ULL << 21) // 0x0200000
-
-#define FF_CSP_420P10 (1ULL << 22) // 0x0400000
-#define FF_CSP_444P10 (1ULL << 23) // 0x0800000
-#define FF_CSP_P016 (1ULL << 24) // 0x1000000 P016 in Media Fundation (MFVideoFormat_P016). 16bit version of NV12.
-#define FF_CSP_P010 (1ULL << 25) // 0x2000000 P010 in Media Fundation (MFVideoFormat_P010). same as FF_CSP_P016
-#define FF_CSP_422P10 (1ULL << 26) // 0x4000000
-#define FF_CSP_P210 (1ULL << 27) // 0x8000000
-#define FF_CSP_P216 (1ULL << 28) // 0x10000000
-
-#define FF_CSP_AYUV (1ULL << 29) // 0x20000000
-#define FF_CSP_Y416 (1ULL << 30) // 0x40000000
-
-#define FF_CSP_PAL8 (1ULL << 31) // 0x80000000
-
-#define FF_CSP_GBRP (1ULL << 32) // 0x100000000
-#define FF_CSP_GBRP9 (1ULL << 33) // 0x200000000
-#define FF_CSP_GBRP10 (1ULL << 34) // 0x400000000
-
-#define FF_CSP_420P9 (1ULL << 35) // 0x800000000
-#define FF_CSP_422P9 (1ULL << 36) // 0x1000000000
-#define FF_CSP_444P9 (1ULL << 37) // 0x2000000000
-
-// Flags
-#define FF_CSP_FLAGS_YUV_JPEG (1ULL << 59)
-#define FF_CSP_FLAGS_YUV_ORDER (1ULL << 60) // UV ordered chroma planes (not VU as default)
-#define FF_CSP_FLAGS_YUV_ADJ (1ULL << 61) // YUV planes are stored consecutively in one memory block
-#define FF_CSP_FLAGS_INTERLACED (1ULL << 62)
-#define FF_CSP_FLAGS_VFLIP (1ULL << 63) // flip mask
-
-#define FF_CSPS_NUM 38
-
-#define FF_CSP_UNSUPPORTED (1ULL<<FF_CSPS_NUM)
-
-#define FF_CSPS_MASK (FF_CSP_UNSUPPORTED-1)
-#define FF_CSPS_MASK_HIGH_BIT (FF_CSP_420P10|FF_CSP_422P10|FF_CSP_444P10)
-#define FF_CSPS_MASK_YUV_PLANAR (FF_CSP_420P|FF_CSP_422P|FF_CSP_444P|FF_CSP_411P|FF_CSP_410P)
-#define FF_CSPS_MASK_RGB_PLANAR (FF_CSP_GBRP|FF_CSP_GBRP9|FF_CSP_GBRP10)
-#define FF_CSPS_MASK_YUV_PACKED (FF_CSP_YUY2|FF_CSP_UYVY|FF_CSP_YVYU|FF_CSP_VYUY)
-#define FF_CSPS_MASK_RGB (FF_CSP_RGBA|FF_CSP_RGB32|FF_CSP_RGB24|FF_CSP_RGB15|FF_CSP_RGB16)
-#define FF_CSPS_MASK_BGR (FF_CSP_ABGR|FF_CSP_BGR32|FF_CSP_BGR24|FF_CSP_BGR15|FF_CSP_BGR16)
-#define FF_CSPS_MASK_FFRGB (FF_CSP_RGB32|FF_CSP_RGB24|FF_CSP_BGR32|FF_CSP_BGR24) // ffdshow converters output color spaces. Require dst stride to be multiple of 4.
-
-#include <stddef.h>
-typedef int stride_t;
-
-//==================================== xvid4 =====================================
-
-#define XVID4_CSP_PLANAR (1<< 0) /* 4:2:0 planar */
-#define XVID4_CSP_I420 (1<< 1) /* 4:2:0 packed(planar win32) */
-#define XVID4_CSP_YV12 (1<< 2) /* 4:2:0 packed(planar win32) */
-#define XVID4_CSP_YUY2 (1<< 3) /* 4:2:2 packed */
-#define XVID4_CSP_UYVY (1<< 4) /* 4:2:2 packed */
-#define XVID4_CSP_YVYU (1<< 5) /* 4:2:2 packed */
-#define XVID4_CSP_BGRA (1<< 6) /* 32-bit bgra packed */
-#define XVID4_CSP_ABGR (1<< 7) /* 32-bit abgr packed */
-#define XVID4_CSP_RGBA (1<< 8) /* 32-bit rgba packed */
-#define XVID4_CSP_BGR (1<< 9) /* 24-bit bgr packed */
-#define XVID4_CSP_RGB555 (1<<10) /* 16-bit rgb555 packed */
-#define XVID4_CSP_RGB565 (1<<11) /* 16-bit rgb565 packed */
-#define XVID4_CSP_SLICE (1<<12) /* decoder only: 4:2:0 planar, per slice rendering */
-#define XVID4_CSP_INTERNAL (1<<13) /* decoder only: 4:2:0 planar, returns ptrs to internal buffers */
-#define XVID4_CSP_NULL (1<<14) /* decoder only: dont output anything */
-#define XVID4_CSP_VFLIP (1<<31) /* vertical flip mask */
-
-static __inline uint64_t csp_xvid4_2ffdshow(int csp)
-{
- switch (csp) {
- case XVID4_CSP_BGR :
- return FF_CSP_RGB24;
- case XVID4_CSP_YV12 :
- return FF_CSP_420P | FF_CSP_FLAGS_YUV_ADJ;
- case XVID4_CSP_YUY2 :
- return FF_CSP_YUY2;
- case XVID4_CSP_UYVY :
- return FF_CSP_UYVY;
- case XVID4_CSP_I420 :
- return FF_CSP_420P | FF_CSP_FLAGS_YUV_ADJ | FF_CSP_FLAGS_YUV_ORDER;
- case XVID4_CSP_RGB555:
- return FF_CSP_RGB15;
- case XVID4_CSP_RGB565:
- return FF_CSP_RGB16;
- case XVID4_CSP_PLANAR:
- return FF_CSP_420P;
- case XVID4_CSP_YVYU :
- return FF_CSP_YVYU;
- case XVID4_CSP_BGRA :
- return FF_CSP_RGB32;
- case XVID4_CSP_ABGR :
- return FF_CSP_ABGR;
- case XVID4_CSP_RGBA :
- return FF_CSP_RGBA;
- default :
- return FF_CSP_NULL;
- }
-}
-
-//================================= ffmpeg ===================================
-static __inline uint64_t csp_lavc2ffdshow(enum PixelFormat pix_fmt)
-{
- switch (pix_fmt) {
- case PIX_FMT_YUV420P :
- case PIX_FMT_YUVJ420P:
- return FF_CSP_420P;
- case PIX_FMT_YUV422P :
- case PIX_FMT_YUVJ422P:
- return FF_CSP_422P;
- case PIX_FMT_YUV444P :
- case PIX_FMT_YUVJ444P:
- return FF_CSP_444P;
- case PIX_FMT_YUV411P :
- return FF_CSP_411P;
- case PIX_FMT_YUV410P :
- return FF_CSP_410P;
- case PIX_FMT_YUYV422 :
- return FF_CSP_YUY2;
- case PIX_FMT_UYVY422 :
- return FF_CSP_UYVY;
- case PIX_FMT_YUV420P10:
- return FF_CSP_420P10;
- case PIX_FMT_YUV422P10:
- return FF_CSP_422P10;
- case PIX_FMT_YUV444P10:
- return FF_CSP_444P10;
- case PIX_FMT_BGR24 :
- return FF_CSP_RGB24;
- case PIX_FMT_RGB24 :
- return FF_CSP_BGR24;
- case PIX_FMT_RGB32 :
- case PIX_FMT_ARGB:
- return FF_CSP_RGB32;
- case PIX_FMT_RGB555 :
- return FF_CSP_RGB15;
- case PIX_FMT_RGB565 :
- return FF_CSP_RGB16;
- case PIX_FMT_GRAY8 :
- return FF_CSP_Y800;
- case PIX_FMT_PAL8 :
- return FF_CSP_PAL8;
- case PIX_FMT_NV12 :
- return FF_CSP_NV12;
- case PIX_FMT_GBRP :
- return FF_CSP_GBRP;
- case PIX_FMT_GBRP9 :
- return FF_CSP_GBRP9;
- case PIX_FMT_GBRP10 :
- return FF_CSP_GBRP10;
- case PIX_FMT_YUV420P9:
- return FF_CSP_420P9;
- case PIX_FMT_YUV422P9:
- return FF_CSP_422P9;
- case PIX_FMT_YUV444P9:
- return FF_CSP_444P9;
- default :
- return FF_CSP_NULL;
- }
-}
-static __inline enum PixelFormat csp_ffdshow2lavc(uint64_t pix_fmt)
-{
- switch (pix_fmt & FF_CSPS_MASK) {
- case FF_CSP_420P:
- return pix_fmt & FF_CSP_FLAGS_YUV_JPEG ? PIX_FMT_YUVJ420P : PIX_FMT_YUV420P;
- case FF_CSP_422P:
- return pix_fmt & FF_CSP_FLAGS_YUV_JPEG ? PIX_FMT_YUVJ422P : PIX_FMT_YUV422P;
- case FF_CSP_444P:
- return pix_fmt & FF_CSP_FLAGS_YUV_JPEG ? PIX_FMT_YUVJ444P : PIX_FMT_YUV444P;
- case FF_CSP_411P:
- return PIX_FMT_YUV411P;
- case FF_CSP_410P:
- return PIX_FMT_YUV410P;
- case FF_CSP_YUY2:
- return PIX_FMT_YUYV422;
- case FF_CSP_UYVY:
- return PIX_FMT_UYVY422;
- case FF_CSP_420P10:
- return PIX_FMT_YUV420P10;
- case FF_CSP_422P10:
- return PIX_FMT_YUV422P10;
- case FF_CSP_444P10:
- return PIX_FMT_YUV444P10;
- case FF_CSP_RGB24:
- return PIX_FMT_BGR24;
- case FF_CSP_BGR24:
- return PIX_FMT_RGB24;
- case FF_CSP_RGB32:
- return PIX_FMT_RGB32;
- case FF_CSP_BGR32:
- return PIX_FMT_BGR32;
- case FF_CSP_RGB15:
- return PIX_FMT_RGB555;
- case FF_CSP_RGB16:
- return PIX_FMT_RGB565;
- case FF_CSP_Y800:
- return PIX_FMT_GRAY8;
- case FF_CSP_PAL8:
- return PIX_FMT_PAL8;
- case FF_CSP_NV12:
- return PIX_FMT_NV12;
- case FF_CSP_ABGR:
- return PIX_FMT_ABGR;
- case FF_CSP_RGBA:
- return PIX_FMT_RGBA;
- case FF_CSP_GBRP:
- return PIX_FMT_GBRP;
- case FF_CSP_GBRP9:
- return PIX_FMT_GBRP9;
- case FF_CSP_GBRP10:
- return PIX_FMT_GBRP10;
- case FF_CSP_420P9:
- return PIX_FMT_YUV420P9;
- case FF_CSP_422P9:
- return PIX_FMT_YUV422P9;
- case FF_CSP_444P9:
- return PIX_FMT_YUV444P9;
- default :
- return PIX_FMT_NB;
- }
-}
-
-#define SWS_IN_CSPS \
- ( \
- FF_CSP_420P| \
- FF_CSP_444P| \
- FF_CSP_422P| \
- FF_CSP_411P| \
- FF_CSP_410P| \
- FF_CSP_YUY2| \
- FF_CSP_UYVY| \
- FF_CSP_YVYU| \
- FF_CSP_VYUY| \
- FF_CSP_BGR32| \
- FF_CSP_BGR24| \
- FF_CSP_BGR16| \
- FF_CSP_BGR15| \
- FF_CSP_RGB32| \
- FF_CSP_RGB24| \
- FF_CSP_RGB16| \
- FF_CSP_RGB15| \
- FF_CSP_NV12| \
- FF_CSP_420P10| \
- FF_CSP_422P10| \
- FF_CSP_444P10| \
- FF_CSP_420P9| \
- FF_CSP_422P9| \
- FF_CSP_444P9| \
- FF_CSP_Y800 \
- )
-#define SWS_OUT_CSPS \
- ( \
- FF_CSP_420P| \
- FF_CSP_444P| \
- FF_CSP_422P| \
- FF_CSP_411P| \
- FF_CSP_410P| \
- FF_CSP_YUY2| \
- FF_CSP_UYVY| \
- FF_CSP_YVYU| \
- FF_CSP_VYUY| \
- FF_CSP_RGB32| \
- FF_CSP_RGB24| \
- FF_CSP_RGB16| \
- FF_CSP_RGB15| \
- FF_CSP_BGR32| \
- FF_CSP_BGR24| \
- FF_CSP_BGR16| \
- FF_CSP_BGR15| \
- FF_CSP_NV12| \
- FF_CSP_420P10| \
- FF_CSP_422P10| \
- FF_CSP_444P10| \
- FF_CSP_420P9| \
- FF_CSP_422P9| \
- FF_CSP_444P9| \
- FF_CSP_Y800 \
- )
-
-static __inline uint64_t csp_supSWSin(uint64_t x)
-{
- return (x & FF_CSPS_MASK) & (SWS_IN_CSPS | FF_CSPS_MASK_HIGH_BIT);
-}
-static __inline uint64_t csp_supSWSout(uint64_t x)
-{
- return (x & FF_CSPS_MASK) & (SWS_OUT_CSPS | FF_CSPS_MASK_HIGH_BIT);
-}
-
-#endif
-
-#if defined(__cplusplus) && !defined(FF_CSP_ONLY)
-
-#ifndef _FFIMGFMTCPP_H_
-#define _FFIMGFMTCPP_H_
-
-#include "array_allocator.h"
-#include "char_t.h"
-
-struct TcspInfo {
- uint64_t id;
- const char_t *name;
- int Bpp; // Bytes per pixel for each plane.
- int bpp; // bits per pixel for all plane. (Memory usage, not the effective bit depth)
- unsigned int numPlanes;
- unsigned int shiftX[4], shiftY[4];
- unsigned int black[4];
- FOURCC fcc, fcccsp;
- const GUID *subtype;
- int packedLumaOffset, packedChromaOffset;
-};
-extern const TcspInfo cspInfos[];
-struct TcspInfos : std::vector<const TcspInfo*, array_allocator<const TcspInfo*, FF_CSPS_NUM*2> > {
-private:
- struct TsortFc {
- private:
- uint64_t csp, outPrimaryCSP;
- public:
- TsortFc(uint64_t Icsp, uint64_t IoutPrimaryCSP): csp(Icsp), outPrimaryCSP(IoutPrimaryCSP) {}
- bool operator()(const TcspInfo* &csp1, const TcspInfo* &csp2);
- };
-public:
- void sort(uint64_t csp, uint64_t outPrimaryCSP);
-};
-
-static __inline const TcspInfo* csp_getInfo(uint64_t csp)
-{
- switch (csp & (FF_CSPS_MASK | FF_CSP_FLAGS_YUV_ORDER)) {
- case FF_CSP_420P|FF_CSP_FLAGS_YUV_ORDER: {
- extern TcspInfo cspInfoIYUV;
- return &cspInfoIYUV;
- }
- default:
- csp &= FF_CSPS_MASK;
- if (csp == 0) {
- return NULL;
- }
- int i = 0;
- while (csp >>= 1) {
- i++;
- }
- if (i <= FF_CSPS_NUM) {
- return &cspInfos[i];
- } else {
- return NULL;
- }
- }
-}
-const TcspInfo* csp_getInfoFcc(FOURCC fcc);
-
-static __inline uint64_t csp_isYUVplanar(uint64_t x)
-{
- return x & FF_CSPS_MASK & FF_CSPS_MASK_YUV_PLANAR;
-}
-static __inline uint64_t csp_isRGBplanar(uint64_t x)
-{
- return x & FF_CSPS_MASK & FF_CSPS_MASK_RGB_PLANAR;
-}
-static __inline uint64_t csp_isYUVplanarHighBit(uint64_t x)
-{
- return x & FF_CSPS_MASK & FF_CSPS_MASK_HIGH_BIT;
-}
-static __inline uint64_t csp_isYUVpacked(uint64_t x)
-{
- return x & FF_CSPS_MASK & FF_CSPS_MASK_YUV_PACKED;
-}
-static __inline uint64_t csp_isYUV(uint64_t x)
-{
- return csp_isYUVpacked(x) | csp_isYUVplanar(x);
-}
-static __inline uint64_t csp_isYUV_NV(uint64_t x)
-{
- return csp_isYUVpacked(x) | csp_isYUVplanar(x) | (x & (FF_CSP_NV12 | FF_CSP_P016 | FF_CSP_P010 | FF_CSP_P210 | FF_CSP_P216));
-}
-static __inline uint64_t csp_isRGB_RGB(uint64_t x)
-{
- return x & FF_CSPS_MASK & FF_CSPS_MASK_RGB;
-}
-static __inline uint64_t csp_isRGB_BGR(uint64_t x)
-{
- return x & FF_CSPS_MASK & FF_CSPS_MASK_BGR;
-}
-static __inline uint64_t csp_isRGB(uint64_t x)
-{
- return csp_isRGB_RGB(x) | csp_isRGB_BGR(x);
-}
-static __inline uint64_t csp_supXvid(uint64_t x)
-{
- return (x & FF_CSPS_MASK) & (FF_CSP_RGB24 | FF_CSP_420P | FF_CSP_YUY2 | FF_CSP_UYVY | FF_CSP_YVYU | FF_CSP_VYUY | FF_CSP_RGB15 | FF_CSP_RGB16 | FF_CSP_RGB32 | FF_CSP_ABGR | FF_CSP_RGBA | FF_CSP_BGR24);
-}
-
-bool csp_inFOURCCmask(uint64_t x, FOURCC fcc);
-
-extern char_t* csp_getName2(const TcspInfo *cspInfo, uint64_t csp, char_t *buf, size_t len);
-extern char_t* csp_getName(uint64_t csp, char_t *buf, size_t len);
-extern uint64_t csp_bestMatch(uint64_t inCSP, uint64_t wantedCSPS, int *rank = NULL, uint64_t outPrimaryCSP = 0);
-
-static __inline void csp_yuv_adj_to_plane(uint64_t &csp, const TcspInfo *cspInfo, unsigned int dy, unsigned char *data[4], stride_t stride[4])
-{
- if (csp_isYUVplanar(csp) && (csp & FF_CSP_FLAGS_YUV_ADJ)) {
- csp &= ~FF_CSP_FLAGS_YUV_ADJ;
- data[2] = data[0] + stride[0] * (dy >> cspInfo->shiftY[0]);
- stride[1] = stride[0] >> cspInfo->shiftX[1];
- data[1] = data[2] + stride[1] * (dy >> cspInfo->shiftY[1]);
- stride[2] = stride[0] >> cspInfo->shiftX[2];
- } else if ((csp & (FF_CSP_NV12 | FF_CSP_P016 | FF_CSP_P010 | FF_CSP_P210 | FF_CSP_P216)) && (csp & FF_CSP_FLAGS_YUV_ADJ)) {
- csp &= ~FF_CSP_FLAGS_YUV_ADJ;
- data[1] = data[0] + stride[0] * dy;
- stride[1] = stride[0];
- }
-
-}
-static __inline void csp_yuv_order(uint64_t &csp, unsigned char *data[4], stride_t stride[4])
-{
- if (csp_isYUVplanar(csp) && (csp & FF_CSP_FLAGS_YUV_ORDER)) {
- csp &= ~FF_CSP_FLAGS_YUV_ORDER;
- std::swap(data[1], data[2]);
- std::swap(stride[1], stride[2]);
- }
-}
-static __inline void csp_vflip(uint64_t &csp, const TcspInfo *cspInfo, unsigned char *data[], stride_t stride[], unsigned int dy)
-{
- if (csp & FF_CSP_FLAGS_VFLIP) {
- csp &= ~FF_CSP_FLAGS_VFLIP;
- for (unsigned int i = 0; i < cspInfo->numPlanes; i++) {
- data[i] += stride[i] * ((dy >> cspInfo->shiftY[i]) - 1);
- stride[i] *= -1;
- }
- }
-}
-
-uint64_t getBMPcolorspace(const BITMAPINFOHEADER *hdr, const TcspInfos &forcedCsps);
-
-struct TcspFcc {
- const char_t *name;
- FOURCC fcc;
- uint64_t csp;
- bool flip;
- bool supEnc;
-};
-extern const TcspFcc cspFccs[];
-
-#endif
-
-#endif
diff --git a/src/filters/transform/MPCVideoDec/resource.h b/src/filters/transform/MPCVideoDec/resource.h
deleted file mode 100644
index 5367e2a85..000000000
--- a/src/filters/transform/MPCVideoDec/resource.h
+++ /dev/null
@@ -1,40 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by MPCVideoDecFilter.rc
-//
-#define IDS_FILTER_SETTINGS_CAPTION 7000
-#define IDS_VDF_FFSETTINGS 7400
-#define IDS_VDF_AUTO 7401
-#define IDS_VDF_THREADNUMBER 7402
-#define IDS_VDF_SKIPDEBLOCK 7403
-#define IDS_VDF_DBLK_NONE 7404
-#define IDS_VDF_DBLK_DEFAULT 7405
-#define IDS_VDF_DBLK_NONREF 7406
-#define IDS_VDF_DBLK_BIDIR 7407
-#define IDS_VDF_DBLK_NONKFRM 7408
-#define IDS_VDF_DBLK_ALL 7409
-#define IDS_VDF_AR_MODE 7410
-#define IDS_VDF_INTERLACED_FLAG 7411
-#define IDS_VDF_IF_PROGRESSIVE 7412
-#define IDS_VDF_IF_TOP_FIELD_FIRST 7413
-#define IDS_VDF_IF_BOTTOM_FIELD_FIRST 7414
-#define IDS_VDF_DXVA_SETTING 7415
-#define IDS_VDF_DXVACOMPATIBILITY 7416
-#define IDS_VDF_DXVA_FULLCHECK 7417
-#define IDS_VDF_DXVA_SKIP_LEVELCHECK 7418
-#define IDS_VDF_DXVA_SKIP_REFCHECK 7419
-#define IDS_VDF_DXVA_SKIP_ALLCHECK 7420
-#define IDS_VDF_DXVA_SD 7421
-#define IDS_VDF_VIDEOCARD 7422
-#define IDS_VDF_DXVA_MODE 7423
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 103
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/filters/transform/MPCVideoDec/stdafx.cpp b/src/filters/transform/MPCVideoDec/stdafx.cpp
deleted file mode 100644
index 85320ac36..000000000
--- a/src/filters/transform/MPCVideoDec/stdafx.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-
-#include "stdafx.h"
-
-//#define DXVA_LOGFILE_B
-
-#if defined(_DEBUG) && defined(DXVA_LOGFILE_B)
-
-#define LOG_FILE _T("dxva.log")
-
-void LOG(LPCTSTR fmt, ...)
-{
- va_list args;
- va_start(args, fmt);
- if (TCHAR* buff = DEBUG_NEW TCHAR[_vsctprintf(fmt, args) + 1]) {
- _vstprintf(buff, fmt, args);
- if (FILE* f = _tfopen(LOG_FILE, _T("at"))) {
- fseek(f, 0, 2);
- _ftprintf_s(f, _T("%s\n"), buff);
- fclose(f);
- }
- delete [] buff;
- }
- va_end(args);
-}
-
-#endif
diff --git a/src/filters/transform/MPCVideoDec/stdafx.h b/src/filters/transform/MPCVideoDec/stdafx.h
deleted file mode 100644
index 6b62890ae..000000000
--- a/src/filters/transform/MPCVideoDec/stdafx.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * (C) 2007-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../../DSUtil/SharedInclude.h"
-#include "../../../../include/stdafx_common.h"
-#include "../../../../include/stdafx_common_afx.h"
-#include "../../../../include/stdafx_common_dshow.h"
-
-#include <d3dx9.h>
-#include <evr.h>
-#include <atlcoll.h>
-
-#pragma warning(disable: 4005)
-/* this shouldn't be here but due to stdint.h/inttypes.h
-being included from various ffmpeg headers we get redefitions */
-
-#if defined(_DEBUG) && defined(DXVA_LOGFILE_B)
-void LOG(LPCTSTR fmt, ...);
-#else
-inline void LOG(LPCTSTR fmt, ...) {}
-#endif
diff --git a/src/filters/transform/MpaDecFilter/AudioHelper.cpp b/src/filters/transform/MpaDecFilter/AudioHelper.cpp
deleted file mode 100644
index 9daccdd0d..000000000
--- a/src/filters/transform/MpaDecFilter/AudioHelper.cpp
+++ /dev/null
@@ -1,453 +0,0 @@
-/*
- * (C) 2012-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "AudioHelper.h"
-#include "../../../DSUtil/AudioTools.h"
-
-#define F16MAX ( float(INT16_MAX) / INT16_PEAK)
-#define F24MAX ( float(INT24_MAX) / INT24_PEAK)
-#define D32MAX (double(INT32_MAX) / INT32_PEAK)
-
-#define round_f(x) ((x) > 0 ? (x) + 0.5f : (x) - 0.5f)
-#define round_d(x) ((x) > 0 ? (x) + 0.5 : (x) - 0.5)
-
-HRESULT convert_to_int16(enum AVSampleFormat avsf, WORD nChannels, DWORD nSamples, BYTE* pIn, int16_t* pOut)
-{
- size_t allsamples = nSamples * nChannels;
-
- switch (avsf) {
- case AV_SAMPLE_FMT_U8:
- for (size_t i = 0; i < allsamples; ++i) {
- *pOut++ = (int16_t)(*(int8_t*)pIn ^ 0x80) << 8;
- pIn += sizeof(uint8_t);
- }
- break;
- case AV_SAMPLE_FMT_S16:
- memcpy(pOut, pIn, allsamples * sizeof(int16_t));
- break;
- case AV_SAMPLE_FMT_S32:
- for (size_t i = 0; i < allsamples; ++i) {
- *pOut++ = *(int16_t*)(pIn + sizeof(int16_t)); // read the high bits only
- pIn += sizeof(int32_t);
- }
- break;
- case AV_SAMPLE_FMT_FLT:
- for (size_t i = 0; i < allsamples; ++i) {
- float f = *(float*)pIn;
- limit(-1, f, F16MAX);
- *pOut++ = (int16_t)round_f(f * INT16_PEAK);
- pIn += sizeof(float);
- }
- break;
- case AV_SAMPLE_FMT_DBL:
- for (size_t i = 0; i < allsamples; ++i) {
- float f = (float) * (double*)pIn;
- limit(-1, f, F16MAX);
- *pOut++ = (int16_t)round_f(f * INT16_PEAK);
- pIn += sizeof(double);
- }
- break;
- // planar
- case AV_SAMPLE_FMT_U8P:
- for (size_t i = 0; i < nSamples; ++i) {
- for (int ch = 0; ch < nChannels; ++ch) {
- int8_t b = ((int8_t*)pIn)[nSamples * ch + i];
- *pOut++ = (int16_t)(b ^ 0x80) << 8;
- }
- }
- break;
- case AV_SAMPLE_FMT_S16P:
- for (size_t i = 0; i < nSamples; ++i) {
- for (int ch = 0; ch < nChannels; ++ch) {
- *pOut++ = ((int16_t*)pIn)[nSamples * ch + i];
- }
- }
- break;
- case AV_SAMPLE_FMT_S32P:
- for (size_t i = 0; i < nSamples; ++i) {
- for (int ch = 0; ch < nChannels; ++ch) {
- *pOut++ = *(int16_t*)(pIn + (nSamples * ch + i) * sizeof(int32_t) + sizeof(int16_t)); // read the high bits only
- }
- }
- break;
- case AV_SAMPLE_FMT_FLTP:
- for (size_t i = 0; i < nSamples; ++i) {
- for (int ch = 0; ch < nChannels; ++ch) {
- float f = ((float*)pIn)[nSamples * ch + i];
- limit(-1, f, F16MAX);
- *pOut++ = (int16_t)round_f(f * INT16_PEAK);
- }
- }
- break;
- case AV_SAMPLE_FMT_DBLP:
- for (size_t i = 0; i < nSamples; ++i) {
- for (int ch = 0; ch < nChannels; ++ch) {
- float f = (float)((double*)pIn)[nSamples * ch + i];
- limit(-1, f, F16MAX);
- *pOut++ = (int16_t)round_f(f * INT16_PEAK);
- }
- }
- break;
- default:
- return E_INVALIDARG;
- }
- return S_OK;
-}
-
-HRESULT convert_to_int24(enum AVSampleFormat avsf, WORD nChannels, DWORD nSamples, BYTE* pIn, BYTE* pOut)
-{
- size_t allsamples = nSamples * nChannels;
-
- switch (avsf) {
- case AV_SAMPLE_FMT_U8:
- for (size_t i = 0; i < allsamples; ++i) {
- *pOut++ = 0;
- *pOut++ = 0;
- *pOut++ = *(pIn) ^ 0x80;
- pIn += sizeof(uint8_t);
- }
- break;
- case AV_SAMPLE_FMT_S16:
- for (size_t i = 0; i < allsamples; ++i) {
- *pOut++ = 0;
- *pOut++ = *(pIn);
- *pOut++ = *(pIn + 1);
- pIn += sizeof(int16_t);
- }
- break;
- case AV_SAMPLE_FMT_S32:
- for (size_t i = 0; i < allsamples; ++i) {
- *pOut++ = *(pIn + 1);
- *pOut++ = *(pIn + 2);
- *pOut++ = *(pIn + 3);
- pIn += sizeof(int32_t);
- }
- break;
- case AV_SAMPLE_FMT_FLT:
- for (size_t i = 0; i < allsamples; ++i) {
- double d = (double)(*(float*)pIn);
- limit(-1, d, D32MAX);
- uint32_t u32 = (uint32_t)(int32_t)round_d(d * INT32_PEAK);
- *pOut++ = (BYTE)(u32 >> 8);
- *pOut++ = (BYTE)(u32 >> 16);
- *pOut++ = (BYTE)(u32 >> 24);
- pIn += sizeof(float);
- }
- break;
- case AV_SAMPLE_FMT_DBL:
- for (size_t i = 0; i < allsamples; ++i) {
- double d = *(double*)pIn;
- limit(-1, d, D32MAX);
- uint32_t u32 = (uint32_t)(int32_t)round_d(d * INT32_PEAK);
- *pOut++ = (BYTE)(u32 >> 8);
- *pOut++ = (BYTE)(u32 >> 16);
- *pOut++ = (BYTE)(u32 >> 24);
- pIn += sizeof(double);
- }
- break;
- // planar
- case AV_SAMPLE_FMT_U8P:
- for (size_t i = 0; i < nSamples; ++i) {
- for (int ch = 0; ch < nChannels; ++ch) {
- *pOut++ = 0;
- *pOut++ = 0;
- *pOut++ = pIn[nSamples * ch + i] ^ 0x80;
- }
- }
- break;
- case AV_SAMPLE_FMT_S16P:
- for (size_t i = 0; i < nSamples; ++i) {
- for (int ch = 0; ch < nChannels; ++ch) {
- *pOut++ = 0;
- *pOut++ = pIn[nSamples * ch + i];
- *pOut++ = pIn[nSamples * ch + i + 1];
- }
- }
- break;
- case AV_SAMPLE_FMT_S32P:
- for (size_t i = 0; i < nSamples; ++i) {
- for (int ch = 0; ch < nChannels; ++ch) {
- *pOut++ = pIn[nSamples * ch + i + 1];
- *pOut++ = pIn[nSamples * ch + i + 2];
- *pOut++ = pIn[nSamples * ch + i + 3];
- }
- }
- break;
- case AV_SAMPLE_FMT_FLTP:
- for (size_t i = 0; i < nSamples; ++i) {
- for (int ch = 0; ch < nChannels; ++ch) {
- double d = (double)((float*)pIn)[nSamples * ch + i];
- limit(-1, d, D32MAX);
- uint32_t u32 = (uint32_t)(int32_t)round_d(d * INT32_PEAK);
- *pOut++ = (BYTE)(u32 >> 8);
- *pOut++ = (BYTE)(u32 >> 16);
- *pOut++ = (BYTE)(u32 >> 24);
- }
- }
- break;
- case AV_SAMPLE_FMT_DBLP:
- for (size_t i = 0; i < nSamples; ++i) {
- for (int ch = 0; ch < nChannels; ++ch) {
- double d = ((double*)pIn)[nSamples * ch + i];
- limit(-1, d, D32MAX);
- uint32_t u32 = (uint32_t)(int32_t)round_d(d * INT32_PEAK);
- *pOut++ = (BYTE)(u32 >> 8);
- *pOut++ = (BYTE)(u32 >> 16);
- *pOut++ = (BYTE)(u32 >> 24);
- }
- }
- break;
- default:
- return E_INVALIDARG;
- }
- return S_OK;
-}
-
-HRESULT convert_to_int32(enum AVSampleFormat avsf, WORD nChannels, DWORD nSamples, BYTE* pIn, int32_t* pOut)
-{
- size_t allsamples = nSamples * nChannels;
-
- switch (avsf) {
- case AV_SAMPLE_FMT_U8:
- for (size_t i = 0; i < allsamples; ++i) {
- *pOut++ = (int32_t)(*(int8_t*)pIn ^ 0x80) << 24;
- pIn += sizeof(uint8_t);
- }
- break;
- case AV_SAMPLE_FMT_S16:
- for (size_t i = 0; i < allsamples; ++i) {
- *pOut++ = (int32_t)(*(int16_t*)pIn) << 16;
- pIn += sizeof(int16_t);
- }
- break;
- case AV_SAMPLE_FMT_S32:
- memcpy(pOut, pIn, nSamples * nChannels * sizeof(int32_t));
- break;
- case AV_SAMPLE_FMT_FLT:
- for (size_t i = 0; i < allsamples; ++i) {
- double d = (double)(*(float*)pIn);
- limit(-1, d, D32MAX);
- *pOut++ = (int32_t)round_d(d * INT32_PEAK);
- pIn += sizeof(float);
- }
- break;
- case AV_SAMPLE_FMT_DBL:
- for (size_t i = 0; i < allsamples; ++i) {
- double d = *(double*)pIn;
- limit(-1, d, D32MAX);
- *pOut++ = (int32_t)round_d(d * INT32_PEAK);
- pIn += sizeof(double);
- }
- break;
- // planar
- case AV_SAMPLE_FMT_U8P:
- for (size_t i = 0; i < nSamples; ++i) {
- for (int ch = 0; ch < nChannels; ++ch) {
- int8_t b = ((int8_t*)pIn)[nSamples * ch + i];
- *pOut++ = (int32_t)(b ^ 0x80) << 24;
- }
- }
- break;
- case AV_SAMPLE_FMT_S16P:
- for (size_t i = 0; i < nSamples; ++i) {
- for (int ch = 0; ch < nChannels; ++ch) {
- *pOut++ = (int32_t)((int16_t*)pIn)[nSamples * ch + i] << 16;
- }
- }
- break;
- case AV_SAMPLE_FMT_S32P:
- for (size_t i = 0; i < nSamples; ++i) {
- for (int ch = 0; ch < nChannels; ++ch) {
- *pOut++ = ((int32_t*)pIn)[nSamples * ch + i];
- }
- }
- break;
- case AV_SAMPLE_FMT_FLTP:
- for (size_t i = 0; i < nSamples; ++i) {
- for (int ch = 0; ch < nChannels; ++ch) {
- double d = (double)((float*)pIn)[nSamples * ch + i];
- limit(-1, d, D32MAX);
- *pOut++ = (int32_t)round_d(d * INT32_PEAK);
- }
- }
- break;
- case AV_SAMPLE_FMT_DBLP:
- for (size_t i = 0; i < nSamples; ++i) {
- for (int ch = 0; ch < nChannels; ++ch) {
- double d = ((double*)pIn)[nSamples * ch + i];
- limit(-1, d, D32MAX);
- *pOut++ = (int32_t)round_d(d * INT32_PEAK);
- }
- }
- break;
- default:
- return E_INVALIDARG;
- }
- return S_OK;
-}
-
-HRESULT convert_to_float(enum AVSampleFormat avsf, WORD nChannels, DWORD nSamples, BYTE* pIn, float* pOut)
-{
- size_t allsamples = nSamples * nChannels;
-
- switch (avsf) {
- case AV_SAMPLE_FMT_U8:
- for (size_t i = 0; i < allsamples; ++i) {
- *pOut++ = (float)(*(int8_t*)pIn ^ 0x80) / INT8_PEAK;
- pIn += sizeof(uint8_t);
- }
- break;
- case AV_SAMPLE_FMT_S16:
- for (size_t i = 0; i < allsamples; ++i) {
- *pOut++ = (float)(*(int16_t*)pIn) / INT16_PEAK;
- pIn += sizeof(int16_t);
- }
- break;
- case AV_SAMPLE_FMT_S32:
- for (size_t i = 0; i < allsamples; ++i) {
- *pOut++ = (float)((double)(*(int32_t*)pIn) / INT32_PEAK);
- pIn += sizeof(int32_t);
- }
- break;
- case AV_SAMPLE_FMT_FLT:
- memcpy(pOut, pIn, allsamples * sizeof(float));
- break;
- case AV_SAMPLE_FMT_DBL:
- for (size_t i = 0; i < allsamples; ++i) {
- *pOut++ = (float) * (double*)pIn;
- pIn += sizeof(double);
- }
- break;
- // planar
- case AV_SAMPLE_FMT_U8P:
- for (size_t i = 0; i < nSamples; ++i) {
- for (int ch = 0; ch < nChannels; ++ch) {
- *pOut++ = (float)(((int8_t*)pIn)[nSamples * ch + i] ^ 0x80) / INT8_PEAK;
- }
- }
- break;
- case AV_SAMPLE_FMT_S16P:
- for (size_t i = 0; i < nSamples; ++i) {
- for (int ch = 0; ch < nChannels; ++ch) {
- *pOut++ = (float)((int16_t*)pIn)[nSamples * ch + i] / INT16_PEAK;
- }
- }
- break;
- case AV_SAMPLE_FMT_S32P:
- for (size_t i = 0; i < nSamples; ++i) {
- for (int ch = 0; ch < nChannels; ++ch) {
- *pOut++ = (float)((double)((int32_t*)pIn)[nSamples * ch + i] / INT32_PEAK);
- }
- }
- break;
- case AV_SAMPLE_FMT_FLTP:
- for (size_t i = 0; i < nSamples; ++i) {
- for (int ch = 0; ch < nChannels; ++ch) {
- *pOut++ = ((float*)pIn)[nSamples * ch + i];
- }
- }
- break;
- case AV_SAMPLE_FMT_DBLP:
- for (size_t i = 0; i < nSamples; ++i) {
- for (int ch = 0; ch < nChannels; ++ch) {
- *pOut++ = (float)((double*)pIn)[nSamples * ch + i];
- }
- }
- break;
- default:
- return E_INVALIDARG;
- }
- return S_OK;
-}
-
-HRESULT convert_to_planar_float(enum AVSampleFormat avsf, WORD nChannels, DWORD nSamples, BYTE* pIn, float* pOut)
-{
- size_t allsamples = nSamples * nChannels;
-
- switch (avsf) {
- case AV_SAMPLE_FMT_U8:
- for (int ch = 0; ch < nChannels; ++ch) {
- for (size_t i = 0; i < nSamples; ++i) {
- *pOut++ = (float)(((int8_t*)pIn)[nChannels * i + ch] ^ 0x80) / INT8_PEAK;
- }
- }
- break;
- case AV_SAMPLE_FMT_S16:
- for (int ch = 0; ch < nChannels; ++ch) {
- for (size_t i = 0; i < nSamples; ++i) {
- *pOut++ = (float)((int16_t*)pIn)[nChannels * i + ch] / INT16_PEAK;
- }
- }
- break;
- case AV_SAMPLE_FMT_S32:
- for (int ch = 0; ch < nChannels; ++ch) {
- for (size_t i = 0; i < nSamples; ++i) {
- *pOut++ = (float)((double)((int32_t*)pIn)[nChannels * i + ch] / INT32_PEAK);
- }
- }
- break;
- case AV_SAMPLE_FMT_FLT:
- for (int ch = 0; ch < nChannels; ++ch) {
- for (size_t i = 0; i < nSamples; ++i) {
- *pOut++ = ((float*)pIn)[nChannels * i + ch];
- }
- }
- break;
- case AV_SAMPLE_FMT_DBL:
- for (int ch = 0; ch < nChannels; ++ch) {
- for (size_t i = 0; i < nSamples; ++i) {
- *pOut++ = (float)((double*)pIn)[nChannels * i + ch];
- }
- }
- break;
- // planar
- case AV_SAMPLE_FMT_U8P:
- for (size_t i = 0; i < allsamples; ++i) {
- *pOut++ = (float)(*(int8_t*)pIn ^ 0x80) / INT8_PEAK;
- pIn += sizeof(uint8_t);
- }
- break;
- case AV_SAMPLE_FMT_S16P:
- for (size_t i = 0; i < allsamples; ++i) {
- *pOut++ = (float)(*(int16_t*)pIn) / INT16_PEAK;
- pIn += sizeof(int16_t);
- }
- break;
- case AV_SAMPLE_FMT_S32P:
- for (size_t i = 0; i < allsamples; ++i) {
- *pOut++ = (float)((double)(*(int32_t*)pIn) / INT32_PEAK);
- pIn += sizeof(int32_t);
- }
- break;
- case AV_SAMPLE_FMT_FLTP:
- memcpy(pOut, pIn, allsamples * sizeof(float));
- break;
- case AV_SAMPLE_FMT_DBLP:
- for (size_t i = 0; i < allsamples; ++i) {
- *pOut++ = (float) * (double*)pIn;
- pIn += sizeof(double);
- }
- break;
- default:
- return E_INVALIDARG;
- }
- return S_OK;
-}
diff --git a/src/filters/transform/MpaDecFilter/AudioHelper.h b/src/filters/transform/MpaDecFilter/AudioHelper.h
deleted file mode 100644
index a52b77438..000000000
--- a/src/filters/transform/MpaDecFilter/AudioHelper.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * (C) 2012-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#pragma warning(push)
-#pragma warning(disable: 4005 4244)
-extern "C" {
-#include "ffmpeg/libavutil/samplefmt.h"
-}
-#pragma warning(pop)
-
-#ifdef _MSC_VER
-#define bswap_16(x) _byteswap_ushort((unsigned short)(x))
-#define bswap_32(x) _byteswap_ulong ((unsigned long)(x))
-#define bswap_64(x) _byteswap_uint64((unsigned __int64)(x))
-#else
-#define bswap_16(x) ((uint16_t)(x) >> 8 | (uint16_t)(x) << 8)
-#define bswap_32(x) ((uint32_t)(x) >> 24 | \
- ((uint32_t)(x) & 0x00ff0000) >> 8 | \
- ((uint32_t)(x) & 0x0000ff00) << 8 | \
- (uint32_t)(x) << 24)
-#define bswap_64(x) ((uint64_t)(x) >> 56 | \
- ((uint64_t)(x) & 0x00FF000000000000) >> 40 | \
- ((uint64_t)(x) & 0x0000FF0000000000) >> 24 | \
- ((uint64_t)(x) & 0x000000FF00000000) >> 8 | \
- ((uint64_t)(x) & 0x00000000FF000000) << 8 | \
- ((uint64_t)(x) & 0x0000000000FF0000) << 24 | \
- ((uint64_t)(x) & 0x000000000000FF00) << 40 | \
- (uint64_t)(x) << 56)
-#endif
-
-HRESULT convert_to_int16(enum AVSampleFormat avsf, WORD nChannels, DWORD nSamples, BYTE* pIn, int16_t* pOut);
-HRESULT convert_to_int24(enum AVSampleFormat avsf, WORD nChannels, DWORD nSamples, BYTE* pIn, BYTE* pOut);
-HRESULT convert_to_int32(enum AVSampleFormat avsf, WORD nChannels, DWORD nSamples, BYTE* pIn, int32_t* pOut);
-HRESULT convert_to_float(enum AVSampleFormat avsf, WORD nChannels, DWORD nSamples, BYTE* pIn, float* pOut);
-
-HRESULT convert_to_planar_float(enum AVSampleFormat avsf, WORD nChannels, DWORD nSamples, BYTE* pIn, float* pOut);
-
-inline void convert_int24_to_int32(size_t allsamples, BYTE* pIn, int32_t* pOut)
-{
- for (size_t i = 0; i < allsamples; ++i) {
- pOut[i] = (uint32_t)pIn[3 * i] << 8 |
- (uint32_t)pIn[3 * i + 1] << 16 |
- (uint32_t)pIn[3 * i + 2] << 24;
- }
-}
diff --git a/src/filters/transform/MpaDecFilter/FFAudioDecoder.cpp b/src/filters/transform/MpaDecFilter/FFAudioDecoder.cpp
deleted file mode 100644
index 16d534219..000000000
--- a/src/filters/transform/MpaDecFilter/FFAudioDecoder.cpp
+++ /dev/null
@@ -1,579 +0,0 @@
-/*
- * (C) 2012-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "FFAudioDecoder.h"
-
-#pragma warning(push)
-#pragma warning(disable: 4005 4244)
-extern "C" {
-#include "ffmpeg/libavcodec/avcodec.h"
-#include "ffmpeg/libavutil/intreadwrite.h"
-#include "ffmpeg/libavutil/opt.h"
-}
-#pragma warning(pop)
-
-
-#include "moreuuids.h"
-#include "../../../DSUtil/DSUtil.h"
-#include "../../../DSUtil/AudioParser.h"
-#include "../../../mpc-hc/InternalFiltersConfig.h"
-
-#define INT16_PEAK 32768
-#define INT32_PEAK 2147483648
-
-typedef struct {
- const CLSID* clsMinorType;
- const enum AVCodecID nFFCodec;
-} FFMPEG_AUDIO_CODECS;
-
-static const FFMPEG_AUDIO_CODECS ffAudioCodecs[] = {
-#if INTERNAL_DECODER_AMR
- // AMR
- { &MEDIASUBTYPE_AMR, AV_CODEC_ID_AMR_NB },
- { &MEDIASUBTYPE_SAMR, AV_CODEC_ID_AMR_NB },
- { &MEDIASUBTYPE_SAWB, AV_CODEC_ID_AMR_WB },
-#endif
-#if INTERNAL_DECODER_AAC
- // AAC
- { &MEDIASUBTYPE_AAC, AV_CODEC_ID_AAC },
- { &MEDIASUBTYPE_MP4A, AV_CODEC_ID_AAC },
- { &MEDIASUBTYPE_mp4a, AV_CODEC_ID_AAC },
- { &MEDIASUBTYPE_AAC_ADTS, AV_CODEC_ID_AAC },
- { &MEDIASUBTYPE_LATM_AAC, AV_CODEC_ID_AAC_LATM },
-#endif
-#if INTERNAL_DECODER_ALAC
- // ALAC
- { &MEDIASUBTYPE_ALAC, AV_CODEC_ID_ALAC },
-#endif
-#if INTERNAL_DECODER_ALS
- // MPEG-4 ALS
- { &MEDIASUBTYPE_ALS, AV_CODEC_ID_MP4ALS },
-#endif
-#if INTERNAL_DECODER_VORBIS
- // Ogg Vorbis
- { &MEDIASUBTYPE_Vorbis2, AV_CODEC_ID_VORBIS },
-#endif
-#if INTERNAL_DECODER_NELLYMOSER
- // NellyMoser
- { &MEDIASUBTYPE_NELLYMOSER, AV_CODEC_ID_NELLYMOSER },
-#endif
-#if INTERNAL_DECODER_ADPCM
- // Qt ADPCM
- { &MEDIASUBTYPE_IMA4, AV_CODEC_ID_ADPCM_IMA_QT },
- // FLV ADPCM
- { &MEDIASUBTYPE_ADPCM_SWF, AV_CODEC_ID_ADPCM_SWF },
- // AMV IMA ADPCM
- { &MEDIASUBTYPE_ADPCM_AMV, AV_CODEC_ID_ADPCM_IMA_AMV },
-#endif
-#if INTERNAL_DECODER_MPEGAUDIO
- // MPEG Audio
- { &MEDIASUBTYPE_MPEG1Packet, AV_CODEC_ID_MP2 },
- { &MEDIASUBTYPE_MPEG1Payload, AV_CODEC_ID_MP2 },
- { &MEDIASUBTYPE_MPEG1AudioPayload, AV_CODEC_ID_MP2 },
- { &MEDIASUBTYPE_MPEG2_AUDIO, AV_CODEC_ID_MP2 },
- { &MEDIASUBTYPE_MP3, AV_CODEC_ID_MP3 },
-#endif
-#if INTERNAL_DECODER_REALAUDIO
- // RealMedia Audio
- { &MEDIASUBTYPE_14_4, AV_CODEC_ID_RA_144 },
- { &MEDIASUBTYPE_28_8, AV_CODEC_ID_RA_288 },
- { &MEDIASUBTYPE_ATRC, AV_CODEC_ID_ATRAC3 },
- { &MEDIASUBTYPE_COOK, AV_CODEC_ID_COOK },
- { &MEDIASUBTYPE_SIPR, AV_CODEC_ID_SIPR },
- { &MEDIASUBTYPE_RAAC, AV_CODEC_ID_AAC },
- { &MEDIASUBTYPE_RACP, AV_CODEC_ID_AAC },
- //{ &MEDIASUBTYPE_DNET, AV_CODEC_ID_AC3 },
-#endif
-#if INTERNAL_DECODER_AC3
- // AC3, E-AC3, TrueHD, MLP
- //{ &MEDIASUBTYPE_DOLBY_AC3, AV_CODEC_ID_AC3 },
- //{ &MEDIASUBTYPE_WAVE_DOLBY_AC3, AV_CODEC_ID_AC3 },
- { &MEDIASUBTYPE_DOLBY_DDPLUS, AV_CODEC_ID_EAC3 },
- { &MEDIASUBTYPE_DOLBY_TRUEHD, AV_CODEC_ID_TRUEHD },
- { &MEDIASUBTYPE_MLP, AV_CODEC_ID_MLP },
-#endif
-#if INTERNAL_DECODER_DTS
- // DTS
- { &MEDIASUBTYPE_DTS, AV_CODEC_ID_DTS },
- { &MEDIASUBTYPE_WAVE_DTS, AV_CODEC_ID_DTS },
-#endif
-#if INTERNAL_DECODER_FLAC
- // FLAC
- { &MEDIASUBTYPE_FLAC_FRAMED, AV_CODEC_ID_FLAC },
-#endif
-
- { &MEDIASUBTYPE_None, AV_CODEC_ID_NONE },
-};
-
-enum AVCodecID FindCodec(const GUID subtype)
-{
- for (int i = 0; i < _countof(ffAudioCodecs); i++) {
- if (subtype == *ffAudioCodecs[i].clsMinorType) {
- return ffAudioCodecs[i].nFFCodec;
- }
- }
-
- return AV_CODEC_ID_NONE;
-}
-
-static DWORD get_lav_channel_layout(uint64_t layout)
-{
- if (layout > UINT32_MAX) {
- if (layout & AV_CH_WIDE_LEFT) {
- layout = (layout & ~AV_CH_WIDE_LEFT) | AV_CH_FRONT_LEFT_OF_CENTER;
- }
- if (layout & AV_CH_WIDE_RIGHT) {
- layout = (layout & ~AV_CH_WIDE_RIGHT) | AV_CH_FRONT_RIGHT_OF_CENTER;
- }
-
- if (layout & AV_CH_SURROUND_DIRECT_LEFT) {
- layout = (layout & ~AV_CH_SURROUND_DIRECT_LEFT) | AV_CH_SIDE_LEFT;
- }
- if (layout & AV_CH_SURROUND_DIRECT_RIGHT) {
- layout = (layout & ~AV_CH_SURROUND_DIRECT_RIGHT) | AV_CH_SIDE_RIGHT;
- }
- }
-
- return (DWORD)layout;
-}
-
-// CFFAudioDecoder
-
-void CFFAudioDecoder::LogLibavcodec(void* par, int level, const char* fmt, va_list valist)
-{
-#if defined(_DEBUG) && 0
- if (level <= AV_LOG_VERBOSE) {
- char Msg [500];
- vsnprintf_s(Msg, sizeof(Msg), _TRUNCATE, fmt, valist);
- TRACE(_T("AVLIB : %s\n"), Msg);
- }
-#endif
-}
-
-CFFAudioDecoder::CFFAudioDecoder()
- : m_pAVCodec(nullptr)
- , m_pAVCtx(nullptr)
- , m_pParser(nullptr)
- , m_pFrame(nullptr)
-{
- ZeroMemory(&m_raData, sizeof(m_raData));
-}
-
-bool CFFAudioDecoder::Init(enum AVCodecID nCodecId, CTransformInputPin* pInput)
-{
- if (nCodecId == AV_CODEC_ID_NONE) {
- return false;
- }
-
- bool bRet = false;
-
- avcodec_register_all();
- av_log_set_callback(LogLibavcodec);
-
- if (m_pAVCodec) {
- StreamFinish();
- }
- switch (nCodecId) {
- case AV_CODEC_ID_MP1:
- m_pAVCodec = avcodec_find_decoder_by_name("mp1float");
- case AV_CODEC_ID_MP2:
- m_pAVCodec = avcodec_find_decoder_by_name("mp2float");
- case AV_CODEC_ID_MP3:
- m_pAVCodec = avcodec_find_decoder_by_name("mp3float");
- default:
- m_pAVCodec = avcodec_find_decoder(nCodecId);
- }
-
- if (m_pAVCodec) {
- DWORD nSamples, nBytesPerSec;
- WORD nChannels, nBitsPerSample, nBlockAlign;
- audioFormatTypeHandler((BYTE*)pInput->CurrentMediaType().Format(), pInput->CurrentMediaType().FormatType(), &nSamples, &nChannels, &nBitsPerSample, &nBlockAlign, &nBytesPerSec);
-
- if (nCodecId == AV_CODEC_ID_AMR_NB || nCodecId == AV_CODEC_ID_AMR_WB) {
- nChannels = 1;
- nSamples = 8000;
- }
-
- m_pAVCtx = avcodec_alloc_context3(m_pAVCodec);
- CheckPointer(m_pAVCtx, false);
-
- m_pAVCtx->sample_rate = nSamples;
- m_pAVCtx->channels = nChannels;
- m_pAVCtx->bit_rate = nBytesPerSec << 3;
- m_pAVCtx->bits_per_coded_sample = nBitsPerSample;
- m_pAVCtx->block_align = nBlockAlign;
-
- m_pAVCtx->err_recognition = AV_EF_CAREFUL;
- m_pAVCtx->codec_id = nCodecId;
- if (m_pAVCodec->capabilities & CODEC_CAP_TRUNCATED) {
- m_pAVCtx->flags |= CODEC_FLAG_TRUNCATED;
- }
-
- if (nCodecId != AV_CODEC_ID_AAC) {
- m_pParser = av_parser_init(nCodecId);
- }
-
- const void* format = pInput->CurrentMediaType().Format();
- GUID format_type = pInput->CurrentMediaType().formattype;
- DWORD formatlen = pInput->CurrentMediaType().cbFormat;
- unsigned extralen = 0;
- getExtraData((BYTE*)format, &format_type, formatlen, nullptr, &extralen);
-
- ZeroMemory(&m_raData, sizeof(m_raData));
-
- if (extralen) {
- if (nCodecId == AV_CODEC_ID_COOK || nCodecId == AV_CODEC_ID_ATRAC3 || nCodecId == AV_CODEC_ID_SIPR) {
- uint8_t* extra = (uint8_t*)av_mallocz(extralen + FF_INPUT_BUFFER_PADDING_SIZE);
- getExtraData((BYTE*)format, &format_type, formatlen, extra, nullptr);
-
- if (extra[0] == '.' && extra[1] == 'r' && extra[2] == 'a' && extra[3] == 0xfd) {
- HRESULT hr = ParseRealAudioHeader(extra, extralen);
- av_freep(&extra);
- if (FAILED(hr)) {
- return false;
- }
- if (nCodecId == AV_CODEC_ID_SIPR) {
- if (m_raData.flavor > 3) {
- TRACE(_T("FFAudioDecoder: Invalid SIPR flavor (%d)\n"), m_raData.flavor);
- return false;
- }
- static BYTE sipr_subpk_size[4] = { 29, 19, 37, 20 };
- m_pAVCtx->block_align = sipr_subpk_size[m_raData.flavor];
- }
- } else {
- // Try without any processing?
- m_pAVCtx->extradata_size = extralen;
- m_pAVCtx->extradata = extra;
- }
- } else {
- m_pAVCtx->extradata_size = extralen;
- m_pAVCtx->extradata = (uint8_t*)av_mallocz(m_pAVCtx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
- getExtraData((BYTE*)format, &format_type, formatlen, (BYTE*)m_pAVCtx->extradata, nullptr);
- }
- }
-
- if (avcodec_open2(m_pAVCtx, m_pAVCodec, nullptr) >= 0) {
- m_pFrame = avcodec_alloc_frame();
- bRet = true;
- }
- }
-
- if (!bRet) {
- StreamFinish();
- }
-
- return bRet;
-}
-
-void CFFAudioDecoder::SetDRC(bool fDRC)
-{
- if (m_pAVCtx) {
- AVCodecID codec_id = m_pAVCtx->codec_id;
- if (codec_id == AV_CODEC_ID_AC3 || codec_id == AV_CODEC_ID_EAC3) {
- av_opt_set_double(m_pAVCtx, "drc_scale", fDRC ? 1.0f : 0.0f, AV_OPT_SEARCH_CHILDREN);
- }
- }
-}
-
-HRESULT CFFAudioDecoder::Decode(enum AVCodecID nCodecId, BYTE* p, int buffsize, int& size, CAtlArray<BYTE>& BuffOut, enum AVSampleFormat& samplefmt)
-{
-
- if (GetCodecId() == AV_CODEC_ID_NONE) {
- return E_FAIL;
- }
-
- size = 0;
-
- int got_frame = 0;
- bool b_use_parse = m_pParser && ((nCodecId == AV_CODEC_ID_TRUEHD) ? ((buffsize > 2000) ? true : false) : true); // Dirty hack for use with MPC MPEGSplitter
-
- AVPacket avpkt;
- av_init_packet(&avpkt);
-
- if (b_use_parse) {
- BYTE* pOut = nullptr;
- int pOut_size = 0;
-
- int used_bytes = av_parser_parse2(m_pParser, m_pAVCtx, &pOut, &pOut_size, p, buffsize, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0);
- if (used_bytes < 0) {
- TRACE(_T("FFAudioDecoder: audio parsing failed (ret: %d)\n"), -used_bytes);
- return E_FAIL;
- } else if (used_bytes == 0 && pOut_size == 0) {
- TRACE(_T("FFAudioDecoder: could not process buffer while parsing\n"));
- }
-
- size = used_bytes;
-
- if (pOut_size > 0) {
- avpkt.data = pOut;
- avpkt.size = pOut_size;
-
- int ret2 = avcodec_decode_audio4(m_pAVCtx, m_pFrame, &got_frame, &avpkt);
- if (ret2 < 0) {
- TRACE(_T("FFAudioDecoder: decoding failed despite successfull parsing\n"));
- return S_FALSE;
- }
- }
- } else {
- avpkt.data = p;
- avpkt.size = buffsize;
-
- int used_bytes = avcodec_decode_audio4(m_pAVCtx, m_pFrame, &got_frame, &avpkt);
-
- if (used_bytes < 0) {
- TRACE(_T("FFAudioDecoder: decoding failed\n"));
- return E_FAIL;
- } else if (used_bytes == 0 && !got_frame) {
- TRACE(_T("FFAudioDecoder: could not process buffer while decoding\n"));
- } else if (m_pAVCtx->channels > 8) {
- // sometimes avcodec_decode_audio4 cannot identify the garbage and produces incorrect data.
- // this code does not solve the problem, it only reduces the likelihood of crash.
- // do it better!
- return E_FAIL;
- }
- ASSERT(buffsize >= used_bytes);
-
- size = used_bytes;
- }
-
- if (got_frame) {
- size_t nSamples = m_pFrame->nb_samples;
-
- if (nSamples) {
- WORD nChannels = m_pAVCtx->channels;
- /*DWORD dwChannelMask;
- if (m_pAVCtx->channel_layout) {
- dwChannelMask = get_lav_channel_layout(m_pAVCtx->channel_layout);
- } else {
- dwChannelMask = GetDefChannelMask(nChannels);
- }*/
- samplefmt = m_pAVCtx->sample_fmt;
- size_t monosize = nSamples * av_get_bytes_per_sample(samplefmt);
- BuffOut.SetCount(monosize * nChannels);
-
- if (av_sample_fmt_is_planar(samplefmt)) {
- BYTE* pOut = BuffOut.GetData();
- for (int ch = 0; ch < nChannels; ++ch) {
- memcpy(pOut, m_pFrame->extended_data[ch], monosize);
- pOut += monosize;
- }
- } else {
- memcpy(BuffOut.GetData(), m_pFrame->data[0], BuffOut.GetCount());
- }
- }
- }
-
- return S_OK;
-}
-
-void CFFAudioDecoder::FlushBuffers()
-{
- if (m_pParser) { // reset the parser
- av_parser_close(m_pParser);
- m_pParser = av_parser_init(GetCodecId());
- }
- if (m_pAVCtx) {
- avcodec_flush_buffers(m_pAVCtx);
- }
-}
-
-void CFFAudioDecoder::StreamFinish()
-{
- m_pAVCodec = nullptr;
- if (m_pAVCtx) {
- if (m_pAVCtx->extradata) {
- av_freep(&m_pAVCtx->extradata);
- }
- if (m_pAVCtx->codec) {
- avcodec_close(m_pAVCtx);
- }
- av_freep(&m_pAVCtx);
- }
-
- if (m_pParser) {
- av_parser_close(m_pParser);
- m_pParser = nullptr;
- }
-
- if (m_pFrame) {
- av_freep(&m_pFrame);
- }
-}
-
-// RealAudio
-
-HRESULT CFFAudioDecoder::ParseRealAudioHeader(const BYTE* extra, const int extralen)
-{
- const uint8_t* fmt = extra + 4;
- uint16_t version = AV_RB16(fmt);
- fmt += 2;
- if (version == 3) {
- TRACE(_T("FFAudioDecoder: RealAudio Header version 3 unsupported\n"));
- return VFW_E_UNSUPPORTED_AUDIO;
- } else if (version == 4 || version == 5 && extralen > 50) {
- // main format block
- fmt += 2; // word - unused (always 0)
- fmt += 4; // byte[4] - .ra4/.ra5 signature
- fmt += 4; // dword - unknown
- fmt += 2; // word - Version2
- fmt += 4; // dword - header size
- m_raData.flavor = AV_RB16(fmt);
- fmt += 2; // word - codec flavor
- m_raData.coded_frame_size = AV_RB32(fmt);
- fmt += 4; // dword - coded frame size
- fmt += 12; // byte[12] - unknown
- m_raData.sub_packet_h = AV_RB16(fmt);
- fmt += 2; // word - sub packet h
- fmt += 2; // word - frame size
- m_raData.sub_packet_size = m_pAVCtx->block_align = AV_RB16(fmt);
- fmt += 2; // word - subpacket size
- fmt += 2; // word - unknown
- // 6 Unknown bytes in ver 5
- if (version == 5) {
- fmt += 6;
- }
- // Audio format block
- fmt += 8;
- // Tag info in v4
- if (version == 4) {
- int len = *fmt++;
- m_raData.deint_id = AV_RB32(fmt);
- fmt += len;
- len = *fmt++;
- fmt += len;
- } else if (version == 5) {
- m_raData.deint_id = AV_RB32(fmt);
- fmt += 4;
- fmt += 4;
- }
- fmt += 3;
- if (version == 5) {
- fmt++;
- }
-
- int ra_extralen = AV_RB32(fmt);
- if (ra_extralen > 0) {
- m_pAVCtx->extradata_size = ra_extralen;
- m_pAVCtx->extradata = (uint8_t*)av_mallocz(ra_extralen + FF_INPUT_BUFFER_PADDING_SIZE);
- memcpy((void*)m_pAVCtx->extradata, fmt + 4, ra_extralen);
- }
- } else {
- TRACE(_T("FFAudioDecoder: unknown RealAudio Header version: %d\n"), version);
- return VFW_E_UNSUPPORTED_AUDIO;
- }
-
- return S_OK;
-}
-
-bool CFFAudioDecoder::RealPrepare(BYTE* p, int buffsize, CPaddedArray& BuffOut)
-{
- if (m_raData.deint_id == MAKEFOURCC('r', 'n', 'e', 'g') || m_raData.deint_id == MAKEFOURCC('r', 'p', 'i', 's')) {
-
- int w = m_raData.coded_frame_size;
- int h = m_raData.sub_packet_h;
- int len = w * h;
-
- if (buffsize >= len) {
- BuffOut.SetCount(len);
- BYTE* dest = BuffOut.GetData();
-
- int sps = m_raData.sub_packet_size;
- if (sps > 0 && m_raData.deint_id == MAKEFOURCC('r', 'n', 'e', 'g')) { // COOK and ATRAC codec
- for (int y = 0; y < h; y++) {
- for (int x = 0, w2 = w / sps; x < w2; x++) {
- memcpy(dest + sps * (h * x + ((h + 1) / 2) * (y & 1) + (y >> 1)), p, sps);
- p += sps;
- }
- }
- return true;
- }
-
- if (m_raData.deint_id == MAKEFOURCC('r', 'p', 'i', 's')) { // SIPR codec
- memcpy(dest, p, len);
-
- // http://mplayerhq.hu/pipermail/mplayer-dev-eng/2002-August/010569.html
- static BYTE sipr_swaps[38][2] = {
- {0, 63}, {1, 22}, {2, 44}, {3, 90}, {5, 81}, {7, 31}, {8, 86}, {9, 58}, {10, 36}, {12, 68},
- {13, 39}, {14, 73}, {15, 53}, {16, 69}, {17, 57}, {19, 88}, {20, 34}, {21, 71}, {24, 46},
- {25, 94}, {26, 54}, {28, 75}, {29, 50}, {32, 70}, {33, 92}, {35, 74}, {38, 85}, {40, 56},
- {42, 87}, {43, 65}, {45, 59}, {48, 79}, {49, 93}, {51, 89}, {55, 95}, {61, 76}, {67, 83},
- {77, 80}
- };
-
- int bs = h * w * 2 / 96; // nibbles per subpacket
- for (int n = 0; n < 38; n++) {
- int i = bs * sipr_swaps[n][0];
- int o = bs * sipr_swaps[n][1];
- // swap nibbles of block 'i' with 'o'
- for (int j = 0; j < bs; j++) {
- int x = (i & 1) ? (dest[(i >> 1)] >> 4) : (dest[(i >> 1)] & 15);
- int y = (o & 1) ? (dest[(o >> 1)] >> 4) : (dest[(o >> 1)] & 15);
- if (o & 1) {
- dest[(o >> 1)] = (dest[(o >> 1)] & 0x0F) | (x << 4);
- } else {
- dest[(o >> 1)] = (dest[(o >> 1)] & 0xF0) | x;
- }
- if (i & 1) {
- dest[(i >> 1)] = (dest[(i >> 1)] & 0x0F) | (y << 4);
- } else {
- dest[(i >> 1)] = (dest[(i >> 1)] & 0xF0) | y;
- }
- ++i;
- ++o;
- }
- }
- return true;
- }
- }
- }
- return false;
-}
-
-// Info
-
-enum AVCodecID CFFAudioDecoder::GetCodecId()
-{
- if (m_pAVCtx) {
- return m_pAVCtx->codec_id;
- }
- return AV_CODEC_ID_NONE;
-}
-
-enum AVSampleFormat CFFAudioDecoder::GetSampleFmt()
-{
- return m_pAVCtx->sample_fmt;
-}
-
-DWORD CFFAudioDecoder::GetSampleRate()
-{
- return (DWORD)m_pAVCtx->sample_rate;
-}
-
-WORD CFFAudioDecoder::GetChannels()
-{
- return (WORD)m_pAVCtx->channels;
-
-}
-
-DWORD CFFAudioDecoder::GetChannelMask()
-{
- return get_lav_channel_layout(m_pAVCtx->channel_layout);
-}
diff --git a/src/filters/transform/MpaDecFilter/FFAudioDecoder.h b/src/filters/transform/MpaDecFilter/FFAudioDecoder.h
deleted file mode 100644
index 18f5c86e7..000000000
--- a/src/filters/transform/MpaDecFilter/FFAudioDecoder.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * (C) 2012-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <atlcoll.h>
-#include "PaddedArray.h"
-
-struct AVCodec;
-struct AVCodecContext;
-struct AVCodecParserContext;
-struct AVFrame;
-
-enum AVCodecID FindCodec(const GUID subtype);
-
-class CFFAudioDecoder
-{
-protected:
- AVCodec* m_pAVCodec;
- AVCodecContext* m_pAVCtx;
- AVCodecParserContext* m_pParser;
- AVFrame* m_pFrame;
-
- struct {
- int flavor;
- int coded_frame_size;
- int sub_packet_h;
- int sub_packet_size;
- unsigned int deint_id;
- } m_raData;
-
- static void LogLibavcodec(void* par, int level, const char* fmt, va_list valist);
-
- HRESULT ParseRealAudioHeader(const BYTE* extra, const int extralen);
-
-public:
- CFFAudioDecoder();
-
- bool Init(enum AVCodecID nCodecId, CTransformInputPin* m_pInput);
- void SetDRC(bool fDRC);
-
- bool RealPrepare(BYTE* p, int buffsize, CPaddedArray& BuffOut);
- HRESULT Decode(enum AVCodecID nCodecId, BYTE* p, int buffsize, int& size, CAtlArray<BYTE>& BuffOut, enum AVSampleFormat& samplefmt);
- void FlushBuffers();
- void StreamFinish();
-
- // info
- enum AVCodecID GetCodecId(); // safe
- enum AVSampleFormat GetSampleFmt(); // unsafe
- DWORD GetSampleRate(); // unsafe
- WORD GetChannels(); // unsafe
- DWORD GetChannelMask(); // unsafe
-};
diff --git a/src/filters/transform/MpaDecFilter/IMpaDecFilter.h b/src/filters/transform/MpaDecFilter/IMpaDecFilter.h
deleted file mode 100644
index 50dfaa466..000000000
--- a/src/filters/transform/MpaDecFilter/IMpaDecFilter.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-enum MPCSampleFormat {
- SF_PCM16 = 0,
- SF_PCM32,
- SF_FLOAT,
- SF_PCM24,
- sfcount
-};
-
-interface __declspec(uuid("2067C60F-752F-4EBD-B0B1-4CBC5E00741C"))
-IMpaDecFilter :
-public IUnknown {
- enum enctype {
- ac3 = 0,
- eac3,
- truehd,
- dts,
- dtshd,
- etcount
- };
-
- STDMETHOD(SetSampleFormat(MPCSampleFormat sf, bool enable)) PURE;
- STDMETHOD_(bool, GetSampleFormat(MPCSampleFormat sf)) PURE;
- STDMETHOD_(MPCSampleFormat, SelectSampleFormat(MPCSampleFormat sf)) PURE;
- STDMETHOD(SetMixer(bool fMixer)) PURE;
- STDMETHOD_(bool, GetMixer()) PURE;
- STDMETHOD(SetMixerLayout(int sc)) PURE;
- STDMETHOD_(int, GetMixerLayout()) PURE;
- STDMETHOD(SetDynamicRangeControl(bool fDRC)) PURE;
- STDMETHOD_(bool, GetDynamicRangeControl()) PURE;
- STDMETHOD(SetSPDIF(enctype et, bool fSPDIF)) PURE;
- STDMETHOD_(bool, GetSPDIF(enctype et)) PURE;
-
- STDMETHOD(SaveSettings()) PURE;
-};
diff --git a/src/filters/transform/MpaDecFilter/Mixer.cpp b/src/filters/transform/MpaDecFilter/Mixer.cpp
deleted file mode 100644
index ec06d2686..000000000
--- a/src/filters/transform/MpaDecFilter/Mixer.cpp
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * (C) 2012-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "Mixer.h"
-
-#pragma warning(push)
-#pragma warning(disable: 4005)
-extern "C" {
-#include "ffmpeg/libavresample/avresample.h"
-#include "ffmpeg/libavutil/samplefmt.h"
-#include "ffmpeg/libavutil/opt.h"
-}
-#pragma warning(pop)
-#include "AudioHelper.h"
-
-CMixer::CMixer()
- : m_pAVRCxt(nullptr)
- , m_matrix_dbl(nullptr)
- , m_in_avsf(AV_SAMPLE_FMT_NONE)
- , m_in_layout(0)
- , m_out_layout(0)
- , m_matrix_norm(0.0f)
- , m_in_samplerate(0)
- , m_out_samplerate(0)
-{
- // Allocate Resample Context
- m_pAVRCxt = avresample_alloc_context();
-}
-
-CMixer::~CMixer()
-{
- avresample_free(&m_pAVRCxt);
- av_free(m_matrix_dbl);
-}
-
-void CMixer::Init(AVSampleFormat in_avsf, DWORD in_layout, DWORD out_layout, float matrix_norm, int in_samplerate, int out_samplerate)
-{
- // reset parameters
- m_in_avsf = AV_SAMPLE_FMT_NONE;
- m_in_layout = 0;
- m_out_layout = 0;
- m_matrix_norm = 0.0f;
- m_in_samplerate = 0;
- m_out_samplerate = 0;
- av_free(m_matrix_dbl);
-
- // Close Resample Context
- avresample_close(m_pAVRCxt);
-
- int ret = 0;
- // Set options
- av_opt_set_int(m_pAVRCxt, "in_sample_fmt", in_avsf, 0);
- av_opt_set_int(m_pAVRCxt, "out_sample_fmt", AV_SAMPLE_FMT_FLT, 0); // forced float output
- av_opt_set_int(m_pAVRCxt, "in_channel_layout", in_layout, 0);
- av_opt_set_int(m_pAVRCxt, "out_channel_layout", out_layout, 0);
- av_opt_set_int(m_pAVRCxt, "in_sample_rate", in_samplerate, 0);
- av_opt_set_int(m_pAVRCxt, "out_sample_rate", out_samplerate, 0);
-
- // Open Resample Context
- ret = avresample_open(m_pAVRCxt);
- if (ret < 0) {
- TRACE(_T("Mixer: avresample_open failed\n"));
- return;
- }
-
- // Create Matrix
- int in_ch = av_popcount(in_layout);
- int out_ch = av_popcount(out_layout);
- m_matrix_dbl = (double*)av_mallocz(in_ch * out_ch * sizeof(*m_matrix_dbl));
- // expand stereo
- if (in_layout == AV_CH_LAYOUT_STEREO && (out_layout == AV_CH_LAYOUT_QUAD || out_layout == AV_CH_LAYOUT_5POINT1 || out_layout == AV_CH_LAYOUT_7POINT1)) {
- m_matrix_dbl[0] = 1.0;
- m_matrix_dbl[1] = 0.0;
- m_matrix_dbl[2] = 0.0;
- m_matrix_dbl[3] = 1.0;
- if (out_layout == AV_CH_LAYOUT_QUAD) {
- m_matrix_dbl[4] = 0.6666;
- m_matrix_dbl[5] = (-0.2222);
- m_matrix_dbl[6] = (-0.2222);
- m_matrix_dbl[7] = 0.6666;
- } else if (out_layout == AV_CH_LAYOUT_5POINT1 || out_layout == AV_CH_LAYOUT_7POINT1) {
- m_matrix_dbl[4] = 0.5;
- m_matrix_dbl[5] = 0.5;
- m_matrix_dbl[6] = 0.0;
- m_matrix_dbl[7] = 0.0;
- m_matrix_dbl[8] = 0.6666;
- m_matrix_dbl[9] = (-0.2222);
- m_matrix_dbl[10] = (-0.2222);
- m_matrix_dbl[11] = 0.6666;
- if (out_layout == AV_CH_LAYOUT_7POINT1) {
- m_matrix_dbl[12] = 0.6666;
- m_matrix_dbl[13] = (-0.2222);
- m_matrix_dbl[14] = (-0.2222);
- m_matrix_dbl[15] = 0.6666;
- }
- }
- } else {
- const double center_mix_level = M_SQRT1_2;
- const double surround_mix_level = 1.0;
- const double lfe_mix_level = 1.0;
- const int normalize = 0;
- ret = avresample_build_matrix(in_layout, out_layout, center_mix_level, surround_mix_level, lfe_mix_level, normalize, m_matrix_dbl, in_ch, AV_MATRIX_ENCODING_NONE);
- if (ret < 0) {
- TRACE(_T("Mixer: avresample_build_matrix failed\n"));
- av_free(m_matrix_dbl);
- return;
- }
-
- // if back channels do not have sound, then divide side channels for the back and side
- if (out_layout == AV_CH_LAYOUT_7POINT1) {
- bool back_no_sound = true;
- for (int i = 0; i < in_ch * 2; i++) {
- if (m_matrix_dbl[4 * in_ch + i] != 0.0) {
- back_no_sound = false;
- }
- }
- if (back_no_sound) {
- for (int i = 0; i < in_ch * 2; i++) {
- m_matrix_dbl[4 * in_ch + i] = (m_matrix_dbl[6 * in_ch + i] *= M_SQRT1_2);
- }
- }
- }
- }
-
- if (matrix_norm > 0.0f && matrix_norm <= 1.0f) { // 0.0 - normalize off; 1.0 - full normalize matrix
- double max_peak = 0;
- for (int j = 0; j < out_ch; j++) {
- double peak = 0;
- for (int i = 0; i < in_ch; i++) {
- peak += fabs(m_matrix_dbl[j * in_ch + i]);
- }
- if (peak > max_peak) {
- max_peak = peak;
- }
- }
- if (max_peak > 1.0) {
- double g = ((max_peak - 1.0) * (1.0 - matrix_norm) + 1.0) / max_peak;
- for (int i = 0, n = in_ch * out_ch; i < n; i++) {
- m_matrix_dbl[i] *= g;
- }
- }
- }
-
-#ifdef _DEBUG
- CString matrix_str = _T("Mixer: matrix\n");
- for (int j = 0; j < out_ch; j++) {
- matrix_str.AppendFormat(_T("%d:"), j + 1);
- for (int i = 0; i < in_ch; i++) {
- double k = m_matrix_dbl[j * in_ch + i];
- matrix_str.AppendFormat(_T(" %.4f"), k);
- }
- matrix_str += _T("\n");
- }
- TRACE(matrix_str);
-#endif
-
- // Set Matrix on the context
- ret = avresample_set_matrix(m_pAVRCxt, m_matrix_dbl, in_ch);
- if (ret < 0) {
- TRACE(_T("Mixer: avresample_set_matrix failed\n"));
- av_free(m_matrix_dbl);
- return;
- }
-
- m_in_avsf = in_avsf;
- m_in_layout = in_layout;
- m_out_layout = out_layout;
- m_matrix_norm = matrix_norm;
- m_in_samplerate = in_samplerate;
- m_out_samplerate = out_samplerate;
-}
-
-void CMixer::Update(AVSampleFormat in_avsf, DWORD in_layout, DWORD out_layout, float matrix_norm, int in_samplerate, int out_samplerate)
-{
- if (in_avsf != m_in_avsf ||
- in_layout != m_in_layout ||
- out_layout != m_out_layout ||
- matrix_norm != m_matrix_norm ||
- in_samplerate != m_in_samplerate ||
- out_samplerate != m_out_samplerate) {
- Init(in_avsf, in_layout, out_layout, matrix_norm, in_samplerate, out_samplerate);
- }
-}
-
-int CMixer::Mixing(float* pOutput, int out_samples, BYTE* pInput, int in_samples)
-{
- int in_ch = av_popcount(m_in_layout);
- int out_ch = av_popcount(m_out_layout);
-
- int in_plane_nb = av_sample_fmt_is_planar(m_in_avsf) ? in_ch : 1;
- int in_plane_size = in_samples * (av_sample_fmt_is_planar(m_in_avsf) ? 1 : in_ch) * av_get_bytes_per_sample(m_in_avsf);
- static BYTE* ppInput[AVRESAMPLE_MAX_CHANNELS];
- for (int i = 0; i < in_plane_nb; i++) {
- ppInput[i] = pInput + i * in_plane_size;
- }
-
- int out_plane_size = out_samples * out_ch * sizeof(float);
-
- out_samples = avresample_convert(m_pAVRCxt, (uint8_t**)&pOutput, out_plane_size, out_samples, ppInput, in_plane_size, in_samples);
- if (out_samples < 0) {
- TRACE(_T("Mixer: avresample_convert failed\n"));
- return 0;
- }
-
- return out_samples;
-}
-
-int CMixer::CalcOutSamples(int in_samples)
-{
- if (m_in_samplerate == m_out_samplerate) {
- return in_samples;
- } else {
- return avresample_available(m_pAVRCxt) + (int)((__int64)(avresample_get_delay(m_pAVRCxt) + in_samples) * m_out_samplerate / m_in_samplerate);
- }
-}
-
-void CMixer::FlushBuffers()
-{
- if (m_in_samplerate != m_out_samplerate) {
- // Close Resample Context
- avresample_close(m_pAVRCxt);
-
- int ret = 0;
- // Open Resample Context
- ret = avresample_open(m_pAVRCxt);
- if (ret < 0) {
- TRACE(_T("Mixer: avresample_open failed\n"));
- return;
- }
-
- // Set Matrix on the context
- ret = avresample_set_matrix(m_pAVRCxt, m_matrix_dbl, av_popcount(m_in_layout));
- if (ret < 0) {
- TRACE(_T("Mixer: avresample_set_matrix failed\n"));
- return;
- }
- }
-}
diff --git a/src/filters/transform/MpaDecFilter/Mixer.h b/src/filters/transform/MpaDecFilter/Mixer.h
deleted file mode 100644
index 50764015e..000000000
--- a/src/filters/transform/MpaDecFilter/Mixer.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * (C) 2012-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-struct AVAudioResampleContext;
-
-class CMixer
-{
-protected:
- AVAudioResampleContext* m_pAVRCxt;
- double* m_matrix_dbl;
-
- enum AVSampleFormat m_in_avsf;
- DWORD m_in_layout;
- DWORD m_out_layout;
- float m_matrix_norm;
- int m_in_samplerate;
- int m_out_samplerate;
-
- void Init(AVSampleFormat in_avsf, DWORD in_layout, DWORD out_layout, float matrix_norm = 0.0f, int in_samplerate = 48000, int out_samplerate = 48000);
-
-public:
- CMixer();
- ~CMixer();
-
- void Update(AVSampleFormat in_avsf, DWORD in_layout, DWORD out_layout, float matrix_norm = 0.0f, int in_samplerate = 48000, int out_samplerate = 48000);
- int Mixing(float* pOutput, int out_samples, BYTE* pInput, int in_samples);
-
- int CalcOutSamples(int in_samples); // needed when using resampling
- void FlushBuffers(); // needed when using resampling
-};
diff --git a/src/filters/transform/MpaDecFilter/MpaDecFilter.cpp b/src/filters/transform/MpaDecFilter/MpaDecFilter.cpp
deleted file mode 100644
index e8e0f857d..000000000
--- a/src/filters/transform/MpaDecFilter/MpaDecFilter.cpp
+++ /dev/null
@@ -1,2325 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <math.h>
-#include <atlbase.h>
-#include <MMReg.h>
-#include <Ks.h>
-#include <KsMedia.h>
-#include <sys/timeb.h>
-
-#include "MpaDecFilter.h"
-#include "AudioHelper.h"
-
-#include "../../../DSUtil/DSUtil.h"
-#include "../../../DSUtil/AudioParser.h"
-
-#ifdef STANDALONE_FILTER
-void* __imp_toupper = toupper;
-#if defined(_WIN64)
-void* __imp_time64 = _time64;
-#endif
-
-#include <InitGuid.h>
-
-extern "C" {
- void __mingw_raise_matherr(int typ, const char* name, double a1, double a2, double rslt) {}
-}
-#endif // STANDALONE_FILTER
-
-#include "moreuuids.h"
-
-#include <vector>
-
-#include "ffmpeg/libavcodec/avcodec.h"
-
-// options names
-#define OPT_REGKEY_MpaDec _T("Software\\Gabest\\Filters\\MPEG Audio Decoder")
-#define OPT_SECTION_MpaDec _T("Filters\\MPEG Audio Decoder")
-#define OPTION_SFormat_i16 _T("SampleFormat_int16")
-#define OPTION_SFormat_i24 _T("SampleFormat_int24")
-#define OPTION_SFormat_i32 _T("SampleFormat_int32")
-#define OPTION_SFormat_flt _T("SampleFormat_float")
-#define OPTION_Mixer _T("Mixer")
-#define OPTION_MixerLayout _T("MixerLayout")
-#define OPTION_DRC _T("DRC")
-#define OPTION_SPDIF_ac3 _T("SPDIF_ac3")
-#define OPTION_SPDIF_eac3 _T("HDMI_eac3")
-#define OPTION_SPDIF_truehd _T("HDMI_truehd")
-#define OPTION_SPDIF_dts _T("SPDIF_dts")
-#define OPTION_SPDIF_dtshd _T("HDMI_dtshd")
-
-#define MAX_JITTER 1400000i64 // +-140ms jitter is allowed for now
-
-#define PADDING_SIZE FF_INPUT_BUFFER_PADDING_SIZE
-
-#define BS_HEADER_SIZE 8
-#define BS_AC3_SIZE 6144
-#define BS_EAC3_SIZE 24576 // 6144 for DD Plus * 4 for IEC 60958 frames
-#define BS_MAT_SIZE 61424 // max length of MAT data
-#define BS_MAT_OFFSET 2560
-#define BS_TRUEHD_SIZE 61440 // 8 header bytes + 61424 of MAT data + 8 zero byte
-#define BS_DTSHD_SIZE 32768
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
-#if INTERNAL_DECODER_MPEGAUDIO
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_MP3 },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG1AudioPayload },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG1Payload },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG1Packet },
- { &MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_MPEG2_AUDIO },
- { &MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_MPEG2_AUDIO },
- { &MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_MPEG2_AUDIO },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG2_AUDIO },
-#endif
-#if INTERNAL_DECODER_AC3
- { &MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DOLBY_AC3 },
- { &MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_DOLBY_AC3 },
- { &MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_DOLBY_AC3 },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_DOLBY_AC3 },
- { &MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_DOLBY_DDPLUS },
- { &MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_DOLBY_DDPLUS },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_DOLBY_DDPLUS },
- { &MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_DOLBY_TRUEHD },
- { &MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_DOLBY_TRUEHD },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_DOLBY_TRUEHD },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_WAVE_DOLBY_AC3 },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_MLP },
-#endif
-#if INTERNAL_DECODER_DTS
- { &MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DTS },
- { &MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_DTS },
- { &MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_DTS },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_DTS },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_WAVE_DTS },
-#endif
-#if INTERNAL_DECODER_LPCM
- { &MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DVD_LPCM_AUDIO },
- { &MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_DVD_LPCM_AUDIO },
- { &MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_DVD_LPCM_AUDIO },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_DVD_LPCM_AUDIO },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_HDMV_LPCM_AUDIO },
-#endif
-#if INTERNAL_DECODER_AAC
- { &MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_AAC },
- { &MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_AAC },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_AAC },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_LATM_AAC },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_AAC_ADTS },
- { &MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_MP4A },
- { &MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_MP4A },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_MP4A },
- { &MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_mp4a },
- { &MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_mp4a },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_mp4a },
-#endif
-#if INTERNAL_DECODER_AMR
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_AMR },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_SAMR },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_SAWB },
-#endif
-#if INTERNAL_DECODER_PS2AUDIO
- { &MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_PS2_PCM },
- { &MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_PS2_PCM },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_PS2_PCM },
- { &MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_PS2_ADPCM },
- { &MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_PS2_ADPCM },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_PS2_ADPCM },
-#endif
-#if INTERNAL_DECODER_VORBIS
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_Vorbis2 },
-#endif
-#if INTERNAL_DECODER_FLAC
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_FLAC_FRAMED },
-#endif
-#if INTERNAL_DECODER_NELLYMOSER
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_NELLYMOSER },
-#endif
-#if INTERNAL_DECODER_PCM
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_NONE },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_RAW },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_TWOS },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_SOWT },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_IN24 },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_IN32 },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_FL32 },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_FL64 },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_IEEE_FLOAT }, // only for 64-bit float PCM
-#endif
-#if INTERNAL_DECODER_ADPCM
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_IMA4 },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_ADPCM_SWF },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_ADPCM_AMV },
-#endif
-#if INTERNAL_DECODER_REALAUDIO
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_14_4 },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_28_8 },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_ATRC },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_COOK },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_DNET },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_SIPR },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_RAAC },
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_RACP },
-#endif
-#if INTERNAL_DECODER_ALAC
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_ALAC },
-#endif
-#if INTERNAL_DECODER_ALS
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_ALS },
-#endif
-#if !HAS_OTHER_AUDIO_DECODERS && !HAS_FFMPEG_AUDIO_DECODERS
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_None } // just to prevent compilation error
-#endif
-};
-
-#ifdef STANDALONE_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM},
-};
-
-const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesOut), sudPinTypesOut}
-};
-
-const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CMpaDecFilter), MPCAudioDecName, /*MERIT_DO_NOT_USE*/0x40000001, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
-};
-
-CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, &__uuidof(CMpaDecFilter), CreateInstance<CMpaDecFilter>, nullptr, &sudFilter[0]},
- {L"CMpaDecPropertyPage", &__uuidof(CMpaDecSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CMpaDecSettingsWnd>>},
-};
-
-int g_cTemplates = _countof(g_Templates);
-
-STDAPI DllRegisterServer()
-{
- return AMovieDllRegisterServer2(TRUE);
-}
-
-STDAPI DllUnregisterServer()
-{
- return AMovieDllRegisterServer2(FALSE);
-}
-
-//
-
-#include "../../FilterApp.h"
-
-CFilterApp theApp;
-
-#endif
-
-enum {
- IEC61937_AC3 = 0x01, ///< AC-3 data
- IEC61937_MPEG1_LAYER1 = 0x04, ///< MPEG-1 layer 1
- IEC61937_MPEG1_LAYER23 = 0x05, ///< MPEG-1 layer 2 or 3 data or MPEG-2 without extension
- IEC61937_MPEG2_EXT = 0x06, ///< MPEG-2 data with extension
- IEC61937_MPEG2_AAC = 0x07, ///< MPEG-2 AAC ADTS
- IEC61937_MPEG2_LAYER1_LSF = 0x08, ///< MPEG-2, layer-1 low sampling frequency
- IEC61937_MPEG2_LAYER2_LSF = 0x09, ///< MPEG-2, layer-2 low sampling frequency
- IEC61937_MPEG2_LAYER3_LSF = 0x0A, ///< MPEG-2, layer-3 low sampling frequency
- IEC61937_DTS1 = 0x0B, ///< DTS type I (512 samples)
- IEC61937_DTS2 = 0x0C, ///< DTS type II (1024 samples)
- IEC61937_DTS3 = 0x0D, ///< DTS type III (2048 samples)
- IEC61937_ATRAC = 0x0E, ///< Atrac data
- IEC61937_ATRAC3 = 0x0F, ///< Atrac 3 data
- IEC61937_ATRACX = 0x10, ///< Atrac 3 plus data
- IEC61937_DTSHD = 0x11, ///< DTS HD data
- IEC61937_WMAPRO = 0x12, ///< WMA 9 Professional data
- IEC61937_MPEG2_AAC_LSF_2048 = 0x13, ///< MPEG-2 AAC ADTS half-rate low sampling frequency
- IEC61937_MPEG2_AAC_LSF_4096 = 0x13 | 0x20, ///< MPEG-2 AAC ADTS quarter-rate low sampling frequency
- IEC61937_EAC3 = 0x15, ///< E-AC-3 data
- IEC61937_TRUEHD = 0x16, ///< TrueHD data
-};
-
-#pragma warning(push)
-#pragma warning(disable : 4245)
-static struct scmap_t {
- WORD nChannels;
- BYTE ch[8];
- DWORD dwChannelMask;
-}
-// dshow: left, right, center, LFE, left surround, right surround
-// lets see how we can map these things to dshow (oh the joy!)
-
-s_scmap_hdmv[] = {
- // FL FR FC LFe BL BR FLC FRC
- {0, { -1, -1, -1, -1, -1, -1, -1, -1 }, 0}, // INVALID
- {1, { 0, -1, -1, -1, -1, -1, -1, -1 }, SPEAKER_FRONT_CENTER}, // Mono M1, 0
- {0, { -1, -1, -1, -1, -1, -1, -1, -1 }, 0}, // INVALID
- {2, { 0, 1, -1, -1, -1, -1, -1, -1 }, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT}, // Stereo FL, FR
- {4, { 0, 1, 2, -1, -1, -1, -1, -1 }, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER}, // 3/0 FL, FR, FC
- {4, { 0, 1, 2, -1, -1, -1, -1, -1 }, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_CENTER}, // 2/1 FL, FR, Surround
- {4, { 0, 1, 2, 3, -1, -1, -1, -1 }, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_BACK_CENTER}, // 3/1 FL, FR, FC, Surround
- {4, { 0, 1, 2, 3, -1, -1, -1, -1 }, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT}, // 2/2 FL, FR, BL, BR
- {6, { 0, 1, 2, 3, 4, -1, -1, -1 }, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT}, // 3/2 FL, FR, FC, BL, BR
- {6, { 0, 1, 2, 5, 3, 4, -1, -1 }, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT}, // 3/2+LFe FL, FR, FC, BL, BR, LFe
- {8, { 0, 1, 2, 3, 6, 4, 5, -1 }, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT}, // 3/4 FL, FR, FC, BL, Bls, Brs, BR
- {8, { 0, 1, 2, 7, 4, 5, 3, 6 }, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT}, // 3/4+LFe FL, FR, FC, BL, Bls, Brs, BR, LFe
-};
-#pragma warning(pop)
-
-static struct channel_mode_t {
- WORD channels;
- DWORD ch_layout;
- LPCTSTR op_value;
-}
-channel_mode[] = {
- //n libavcodec ID Name
- {1, AV_CH_LAYOUT_MONO , _T("1.0") }, // SPK_MONO "Mono"
- {2, AV_CH_LAYOUT_STEREO , _T("2.0") }, // SPK_STEREO "Stereo"
- {4, AV_CH_LAYOUT_QUAD , _T("4.0") }, // SPK_4_0 "4.0"
- {6, AV_CH_LAYOUT_5POINT1, _T("5.1") }, // SPK_5_1 "5.1"
- {8, AV_CH_LAYOUT_7POINT1, _T("7.1") }, // SPK_7_1 "7.1"
-};
-
-void DD_stats_t::Reset()
-{
- mode = AV_CODEC_ID_NONE;
- ac3_frames = 0;
- eac3_frames = 0;
-}
-
-bool DD_stats_t::Desired(int type)
-{
- if (mode != AV_CODEC_ID_NONE) {
- return (mode == type);
- };
- // unknown mode
- if (type == AV_CODEC_ID_AC3) {
- ++ac3_frames;
- } else if (type == AV_CODEC_ID_EAC3) {
- ++eac3_frames;
- }
-
- if (ac3_frames + eac3_frames >= 4) {
- if (eac3_frames > 2 * ac3_frames) {
- mode = AV_CODEC_ID_EAC3; // EAC3
- } else {
- mode = AV_CODEC_ID_AC3; // AC3 or mixed AC3+EAC3
- }
- return (mode == type);
- }
-
- return true;
-}
-
-CMpaDecFilter::CMpaDecFilter(LPUNKNOWN lpunk, HRESULT* phr)
- : CTransformFilter(NAME("CMpaDecFilter"), lpunk, __uuidof(this))
- , m_rtStart(0)
- , m_fDiscontinuity(false)
- , m_bResync(false)
- , m_buff(PADDING_SIZE)
- , m_hdmicount(0)
- , m_hdmisize(0)
- , m_truehd_samplerate(0)
- , m_truehd_framelength(0)
-{
- if (phr) {
- *phr = S_OK;
- }
-
- m_pInput = DEBUG_NEW CMpaDecInputPin(this, phr, L"In");
- if (!m_pInput) {
- *phr = E_OUTOFMEMORY;
- }
- if (FAILED(*phr)) {
- return;
- }
-
- m_pOutput = DEBUG_NEW CTransformOutputPin(NAME("CTransformOutputPin"), this, phr, L"Out");
- if (!m_pOutput) {
- *phr = E_OUTOFMEMORY;
- }
- if (FAILED(*phr)) {
- delete m_pInput, m_pInput = nullptr;
- return;
- }
-
- m_DDstats.Reset();
-
- // default settings
- m_fSampleFmt[SF_PCM16] = true;
- m_fSampleFmt[SF_PCM24] = false;
- m_fSampleFmt[SF_PCM32] = false;
- m_fSampleFmt[SF_FLOAT] = false;
- m_fMixer = false;
- m_iMixerLayout = SPK_STEREO;
- m_fDRC = false;
- m_fSPDIF[ac3] = false;
- m_fSPDIF[eac3] = false;
- m_fSPDIF[truehd] = false;
- m_fSPDIF[dts] = false;
- m_fSPDIF[dtshd] = false;
-
- // read settings
- CString layout_str;
-#ifdef STANDALONE_FILTER
- CRegKey key;
- ULONG len = 8;
- if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, OPT_REGKEY_MpaDec, KEY_READ)) {
- DWORD dw;
- if (ERROR_SUCCESS == key.QueryDWORDValue(OPTION_SFormat_i16, dw)) {
- m_fSampleFmt[SF_PCM16] = !!dw;
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(OPTION_SFormat_i24, dw)) {
- m_fSampleFmt[SF_PCM24] = !!dw;
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(OPTION_SFormat_i32, dw)) {
- m_fSampleFmt[SF_PCM32] = !!dw;
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(OPTION_SFormat_flt, dw)) {
- m_fSampleFmt[SF_FLOAT] = !!dw;
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(OPTION_Mixer, dw)) {
- m_fMixer = !!dw;
- }
- if (ERROR_SUCCESS == key.QueryStringValue(OPTION_MixerLayout, layout_str.GetBuffer(8), &len)) {
- layout_str.ReleaseBufferSetLength(len);
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(OPTION_DRC, dw)) {
- m_fDRC = !!dw;
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(OPTION_SPDIF_ac3, dw)) {
- m_fSPDIF[ac3] = !!dw;
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(OPTION_SPDIF_eac3, dw)) {
- m_fSPDIF[eac3] = !!dw;
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(OPTION_SPDIF_truehd, dw)) {
- m_fSPDIF[truehd] = !!dw;
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(OPTION_SPDIF_dts, dw)) {
- m_fSPDIF[dts] = !!dw;
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(OPTION_SPDIF_dtshd, dw)) {
- m_fSPDIF[dtshd] = !!dw;
- }
- }
-#else
- m_fSampleFmt[SF_PCM16] = !!AfxGetApp()->GetProfileInt(OPT_SECTION_MpaDec, OPTION_SFormat_i16, m_fSampleFmt[SF_PCM16]);
- m_fSampleFmt[SF_PCM24] = !!AfxGetApp()->GetProfileInt(OPT_SECTION_MpaDec, OPTION_SFormat_i24, m_fSampleFmt[SF_PCM24]);
- m_fSampleFmt[SF_PCM32] = !!AfxGetApp()->GetProfileInt(OPT_SECTION_MpaDec, OPTION_SFormat_i32, m_fSampleFmt[SF_PCM32]);
- m_fSampleFmt[SF_FLOAT] = !!AfxGetApp()->GetProfileInt(OPT_SECTION_MpaDec, OPTION_SFormat_flt, m_fSampleFmt[SF_FLOAT]);
- m_fMixer = !!AfxGetApp()->GetProfileInt(OPT_SECTION_MpaDec, OPTION_Mixer, m_fMixer);
- layout_str = AfxGetApp()->GetProfileString(OPT_SECTION_MpaDec, OPTION_MixerLayout, channel_mode[m_iMixerLayout].op_value);
- m_fDRC = !!AfxGetApp()->GetProfileInt(OPT_SECTION_MpaDec, OPTION_DRC, m_fDRC);
- m_fSPDIF[ac3] = !!AfxGetApp()->GetProfileInt(OPT_SECTION_MpaDec, OPTION_SPDIF_ac3, m_fSPDIF[ac3]);
- m_fSPDIF[eac3] = !!AfxGetApp()->GetProfileInt(OPT_SECTION_MpaDec, OPTION_SPDIF_eac3, m_fSPDIF[eac3]);
- m_fSPDIF[truehd] = !!AfxGetApp()->GetProfileInt(OPT_SECTION_MpaDec, OPTION_SPDIF_truehd, m_fSPDIF[truehd]);
- m_fSPDIF[dts] = !!AfxGetApp()->GetProfileInt(OPT_SECTION_MpaDec, OPTION_SPDIF_dts, m_fSPDIF[dts]);
- m_fSPDIF[dtshd] = !!AfxGetApp()->GetProfileInt(OPT_SECTION_MpaDec, OPTION_SPDIF_dtshd, m_fSPDIF[dtshd]);
-#endif
- if (!(m_fSampleFmt[SF_PCM16] || m_fSampleFmt[SF_PCM24] || m_fSampleFmt[SF_PCM32] || m_fSampleFmt[SF_FLOAT])) {
- m_fSampleFmt[SF_PCM16] = true;
- }
-
- for (int i = SPK_MONO; i <= SPK_7_1; i++) {
- if (layout_str == channel_mode[i].op_value) {
- m_iMixerLayout = i;
- break;
- }
- }
-}
-
-CMpaDecFilter::~CMpaDecFilter()
-{
- StopStreaming();
-}
-
-STDMETHODIMP CMpaDecFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
-{
- return
- QI(IMpaDecFilter)
- QI(ISpecifyPropertyPages)
- QI(ISpecifyPropertyPages2)
- __super::NonDelegatingQueryInterface(riid, ppv);
-}
-
-HRESULT CMpaDecFilter::EndOfStream()
-{
- CAutoLock cAutoLock(&m_csReceive);
- return __super::EndOfStream();
-}
-
-HRESULT CMpaDecFilter::BeginFlush()
-{
- return __super::BeginFlush();
-}
-
-HRESULT CMpaDecFilter::EndFlush()
-{
- CAutoLock cAutoLock(&m_csReceive);
- m_buff.RemoveAll();
-#if defined(STANDALONE_FILTER) || HAS_FFMPEG_AUDIO_DECODERS
- m_FFAudioDec.FlushBuffers();
-#endif
- m_Mixer.FlushBuffers();
- return __super::EndFlush();
-}
-
-HRESULT CMpaDecFilter::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
-{
- CAutoLock cAutoLock(&m_csReceive);
- m_ps2_state.sync = false;
- m_hdmicount = 0;
- m_hdmisize = 0;
- m_truehd_samplerate = 0;
- m_truehd_framelength = 0;
- m_bResync = true;
-
- return __super::NewSegment(tStart, tStop, dRate);
-}
-
-HRESULT CMpaDecFilter::Receive(IMediaSample* pIn)
-{
- CAutoLock cAutoLock(&m_csReceive);
-
- HRESULT hr;
-
- AM_SAMPLE2_PROPERTIES* const pProps = m_pInput->SampleProps();
- if (pProps->dwStreamId != AM_STREAM_MEDIA) {
- return m_pOutput->Deliver(pIn);
- }
-
- AM_MEDIA_TYPE* pmt;
- if (SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt) {
- CMediaType mt(*pmt);
- m_pInput->SetMediaType(&mt);
- DeleteMediaType(pmt);
- pmt = nullptr;
- }
-
- BYTE* pDataIn = nullptr;
- if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
- return hr;
- }
-
- long len = pIn->GetActualDataLength();
- // skip empty packet (StreamBufferSource can produce empty data)
- if (len == 0) {
- return S_OK;
- }
-
- (static_cast<CDeCSSInputPin*>(m_pInput))->StripPacket(pDataIn, len);
-
- REFERENCE_TIME rtStart = _I64_MIN, rtStop = _I64_MIN;
- hr = pIn->GetTime(&rtStart, &rtStop);
-
-#if 0
- if (SUCCEEDED(hr)) {
- TRACE(_T("CMpaDecFilter::Receive(): rtStart = %10I64d, rtStop = %10I64d\n"), rtStart, rtStop);
- } else {
- TRACE(_T("CMpaDecFilter::Receive(): frame without timestamp\n"));
- }
-#endif
-
- if (pIn->IsDiscontinuity() == S_OK) {
- m_fDiscontinuity = true;
- m_buff.RemoveAll();
- m_rtStart = rtStart;
- m_bResync = true;
- if (FAILED(hr)) {
- TRACE(_T("CMpaDecFilter::Receive() : Discontinuity without timestamp\n"));
- return S_OK;
- }
- }
-
- const GUID& subtype = m_pInput->CurrentMediaType().subtype;
-
- if (subtype == MEDIASUBTYPE_COOK && S_OK == pIn->IsSyncPoint() ||
- _abs64(m_rtStart - rtStart) > MAX_JITTER && subtype != MEDIASUBTYPE_COOK && subtype != MEDIASUBTYPE_ATRC && subtype != MEDIASUBTYPE_SIPR) {
- m_bResync = true;
- }
-
- if (SUCCEEDED(hr) && m_bResync) {
- m_buff.RemoveAll();
- m_rtStart = rtStart;
- m_bResync = false;
- }
-
- size_t bufflen = m_buff.GetCount();
- m_buff.SetCount(bufflen + len, 4096);
- memcpy(m_buff.GetData() + bufflen, pDataIn, len);
- len += (long)bufflen;
-
-#if defined(STANDALONE_FILTER) || INTERNAL_DECODER_AC3
- if (subtype == MEDIASUBTYPE_DOLBY_AC3 || subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3 || subtype == MEDIASUBTYPE_DNET) {
- if (GetSPDIF(ac3)) {
- return ProcessAC3_SPDIF();
- } else {
- return ProcessAC3();
- }
- }
- if (GetSPDIF(eac3) && subtype == MEDIASUBTYPE_DOLBY_DDPLUS) {
- return ProcessEAC3_SPDIF();
- }
- if (GetSPDIF(truehd) && subtype == MEDIASUBTYPE_DOLBY_TRUEHD) {
- return ProcessTrueHD_SPDIF();
- }
-#endif
-#if defined(STANDALONE_FILTER) || INTERNAL_DECODER_DTS
- if (GetSPDIF(dts) && (subtype == MEDIASUBTYPE_DTS || subtype == MEDIASUBTYPE_WAVE_DTS)) {
- return ProcessDTS_SPDIF();
- }
-#endif
-#if defined(STANDALONE_FILTER) || HAS_FFMPEG_AUDIO_DECODERS
- enum AVCodecID nCodecId = FindCodec(subtype);
- if (nCodecId != AV_CODEC_ID_NONE) {
- return ProcessFFmpeg(nCodecId);
- }
-#endif
- if (0) {} // needed if decoders are disabled below
-#if defined(STANDALONE_FILTER) || INTERNAL_DECODER_LPCM
- else if (subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
- hr = ProcessLPCM();
- } else if (subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
- // TODO: check if the test is really correct
- hr = ProcessHdmvLPCM(pIn->IsSyncPoint() == S_FALSE);
- }
-#endif
-#if defined(STANDALONE_FILTER) || INTERNAL_DECODER_PS2AUDIO
- else if (subtype == MEDIASUBTYPE_PS2_PCM) {
- hr = ProcessPS2PCM();
- } else if (subtype == MEDIASUBTYPE_PS2_ADPCM) {
- hr = ProcessPS2ADPCM();
- }
-#endif
-#if defined(STANDALONE_FILTER) || INTERNAL_DECODER_PCM
- else if (subtype == MEDIASUBTYPE_PCM_NONE ||
- subtype == MEDIASUBTYPE_PCM_RAW) {
- hr = ProcessPCMraw();
- } else if (subtype == MEDIASUBTYPE_PCM_TWOS ||
- subtype == MEDIASUBTYPE_PCM_IN24 ||
- subtype == MEDIASUBTYPE_PCM_IN32) {
- hr = ProcessPCMintBE();
- } else if (subtype == MEDIASUBTYPE_PCM_SOWT) {
- hr = ProcessPCMintLE();
- } else if (subtype == MEDIASUBTYPE_PCM_FL32 ||
- subtype == MEDIASUBTYPE_PCM_FL64) {
- hr = ProcessPCMfloatBE();
- } else if (subtype == MEDIASUBTYPE_IEEE_FLOAT) {
- hr = ProcessPCMfloatLE();
- }
-#endif
-
- return hr;
-}
-
-#if defined(STANDALONE_FILTER) || INTERNAL_DECODER_LPCM
-HRESULT CMpaDecFilter::ProcessLPCM()
-{
- WAVEFORMATEX* wfein = (WAVEFORMATEX*)m_pInput->CurrentMediaType().Format();
-
- WORD nChannels = wfein->nChannels;
- if (nChannels < 1 || nChannels > 8) {
- return ERROR_NOT_SUPPORTED;
- }
-
- BYTE* const base = m_buff.GetData();
- BYTE* const end = base + m_buff.GetCount();
- BYTE* p = base;
-
- unsigned int blocksize = nChannels * 2 * wfein->wBitsPerSample / 8;
- size_t nSamples = (m_buff.GetCount() / blocksize) * 2 * nChannels;
-
- AVSampleFormat out_avsf = AV_SAMPLE_FMT_NONE;
- size_t outSize = nSamples * (wfein->wBitsPerSample <= 16 ? 2 : 4); // convert to 16 and 32-bit
- CAtlArray<BYTE> outBuff;
- outBuff.SetCount(outSize);
-
- switch (wfein->wBitsPerSample) {
- case 16: {
- out_avsf = AV_SAMPLE_FMT_S16;
- uint16_t* pDataOut = (uint16_t*)outBuff.GetData();
-
- for (size_t i = 0; i < nSamples; i++) {
- pDataOut[i] = (uint16_t)(*p) << 8 | (uint16_t)(*(p + 1));
- p += 2;
- }
- }
- break;
- case 24: {
- out_avsf = AV_SAMPLE_FMT_S32;
- uint32_t* pDataOut = (uint32_t*)outBuff.GetData();
-
- size_t m = nChannels * 2;
- for (size_t k = 0, n = nSamples / m; k < n; k++) {
- BYTE* q = p + m * 2;
- for (size_t i = 0; i < m; i++) {
- pDataOut[i] = (uint32_t)(*p) << 24 | (uint32_t)(*(p + 1)) << 16 | (uint32_t)(*q) << 8;
- p += 2;
- q++;
- }
- p += m;
- pDataOut += m;
- }
- }
- break;
- case 20: {
- out_avsf = AV_SAMPLE_FMT_S32;
- uint32_t* pDataOut = (uint32_t*)outBuff.GetData();
-
- size_t m = nChannels * 2;
- for (size_t k = 0, n = nSamples / m; k < n; k++) {
- BYTE* q = p + m * 2;
- for (size_t i = 0; i < m; i++) {
- uint32_t u32 = (uint32_t)(*p) << 24 | (uint32_t)(*(p + 1)) << 16;
- if (i & 1) {
- u32 |= (*(uint8_t*)q & 0x0F) << 12;
- q++;
- } else {
- u32 |= (*(uint8_t*)q & 0xF0) << 8;
- }
- pDataOut[i] = u32;
- p += 2;
- }
- p += nChannels;
- pDataOut += m;
- }
- }
- break;
- }
-
- memmove(base, p, end - p);
- m_buff.SetCount(end - p);
-
- return Deliver(outBuff.GetData(), (int)outSize, out_avsf, wfein->nSamplesPerSec, wfein->nChannels, GetDefChannelMask(wfein->nChannels));
-}
-
-
-HRESULT CMpaDecFilter::ProcessHdmvLPCM(bool bAlignOldBuffer) // Blu ray LPCM
-{
- WAVEFORMATEX_HDMV_LPCM* wfein = (WAVEFORMATEX_HDMV_LPCM*)m_pInput->CurrentMediaType().Format();
-
- scmap_t* remap = &s_scmap_hdmv [wfein->channel_conf];
- int nChannels = wfein->nChannels;
- int xChannels = nChannels + (nChannels % 2);
- int BytesPerSample = (wfein->wBitsPerSample + 7) / 8;
- int BytesPerFrame = BytesPerSample * xChannels;
-
- BYTE* pDataIn = m_buff.GetData();
- int len = (int)m_buff.GetCount();
- len -= len % BytesPerFrame;
- if (bAlignOldBuffer) {
- m_buff.SetCount(len);
- }
- int nFrames = len / xChannels / BytesPerSample;
-
- AVSampleFormat out_avsf = AV_SAMPLE_FMT_NONE;
- int outSize = nFrames * nChannels * (wfein->wBitsPerSample <= 16 ? 2 : 4); // convert to 16 and 32-bit
- CAtlArray<BYTE> outBuff;
- outBuff.SetCount(outSize);
-
- switch (wfein->wBitsPerSample) {
- case 16: {
- out_avsf = AV_SAMPLE_FMT_S16;
- int16_t* pDataOut = (int16_t*)outBuff.GetData();
-
- for (int i = 0; i < nFrames; i++) {
- for (int j = 0; j < nChannels; j++) {
- BYTE nRemap = remap->ch[j];
- *pDataOut = (int16_t)(pDataIn[nRemap * 2] << 8 | pDataIn[nRemap * 2 + 1]);
- pDataOut++;
- }
- pDataIn += xChannels * 2;
- }
- }
- break;
- case 24:
- case 20: {
- out_avsf = AV_SAMPLE_FMT_S32;
- int32_t* pDataOut = (int32_t*)outBuff.GetData();
-
- for (int i = 0; i < nFrames; i++) {
- for (int j = 0; j < nChannels; j++) {
- BYTE nRemap = remap->ch[j];
- *pDataOut = (int32_t)(pDataIn[nRemap * 3] << 24 | pDataIn[nRemap * 3 + 1] << 16 | pDataIn[nRemap * 3 + 2] << 8);
- pDataOut++;
- }
- pDataIn += xChannels * 3;
- }
- }
- break;
- }
- memmove(m_buff.GetData(), pDataIn, m_buff.GetCount() - len);
- m_buff.SetCount(m_buff.GetCount() - len);
-
- return Deliver(outBuff.GetData(), outSize, out_avsf, wfein->nSamplesPerSec, wfein->nChannels, remap->dwChannelMask);
-}
-#endif /* INTERNAL_DECODER_LPCM */
-
-#if defined(STANDALONE_FILTER) || HAS_FFMPEG_AUDIO_DECODERS
-HRESULT CMpaDecFilter::ProcessFFmpeg(enum AVCodecID nCodecId)
-{
- BYTE* const base = m_buff.GetData();
- BYTE* end = base + m_buff.GetCount();
- BYTE* p = base;
-
- if (m_FFAudioDec.GetCodecId() != nCodecId) {
- m_FFAudioDec.Init(nCodecId, m_pInput);
- m_FFAudioDec.SetDRC(GetDynamicRangeControl());
- }
-
-#if INTERNAL_DECODER_REALAUDIO
- // RealAudio
- CPaddedArray buffRA(FF_INPUT_BUFFER_PADDING_SIZE);
- bool isRA = false;
- if (nCodecId == AV_CODEC_ID_ATRAC3 || nCodecId == AV_CODEC_ID_COOK || nCodecId == AV_CODEC_ID_SIPR) {
- if (m_FFAudioDec.RealPrepare(p, int(end - p), buffRA)) {
- p = buffRA.GetData();
- end = p + buffRA.GetCount();
- isRA = true;
- } else {
- return S_OK;
- }
- }
-#endif
-
- while (p < end) {
- HRESULT hr;
- int size = 0;
- CAtlArray<BYTE> output;
- AVSampleFormat avsamplefmt = AV_SAMPLE_FMT_NONE;
-
- hr = m_FFAudioDec.Decode(nCodecId, p, int(end - p), size, output, avsamplefmt);
- if (FAILED(hr)) {
- m_buff.RemoveAll();
- m_bResync = true;
- return S_OK;
- } else if (hr == S_FALSE) {
- m_bResync = true;
- p += size;
- continue;
- } else if (!output.IsEmpty()) { // && SUCCEEDED(hr)
- hr = Deliver(output.GetData(), (int)output.GetCount(), avsamplefmt, m_FFAudioDec.GetSampleRate(), m_FFAudioDec.GetChannels(), m_FFAudioDec.GetChannelMask());
- } else if (size == 0) { // && pBuffOut.IsEmpty()
- break;
- }
-
- p += size;
- }
-
-#if INTERNAL_DECODER_REALAUDIO
- if (isRA) { // RealAudio
- p = base + buffRA.GetCount();
- end = base + m_buff.GetCount();
- }
-#endif
-
- memmove(base, p, end - p);
- m_buff.SetCount(end - p);
-
- return S_OK;
-}
-#endif /* HAS_FFMPEG_AUDIO_DECODERS */
-
-
-#if defined(STANDALONE_FILTER) || INTERNAL_DECODER_AC3
-HRESULT CMpaDecFilter::ProcessAC3()
-{
- HRESULT hr;
- BYTE* const base = m_buff.GetData();
- BYTE* const end = base + m_buff.GetCount();
- BYTE* p = base;
-
-
- while (p + 8 <= end) {
- if (*(WORD*)p != 0x770b) {
- p++;
- continue;
- }
-
- AVCodecID ftype;
- int size;
- if ((size = GetAC3FrameSize(p)) > 0) {
- ftype = AV_CODEC_ID_AC3;
- } else if ((size = GetEAC3FrameSize(p)) > 0) {
- ftype = AV_CODEC_ID_EAC3;
- } else {
- p += 2;
- continue;
- }
-
- if (p + size > end) {
- break;
- }
-
- if (m_DDstats.Desired(ftype)) {
- if (m_FFAudioDec.GetCodecId() != ftype) {
- m_FFAudioDec.Init(ftype, m_pInput);
- m_FFAudioDec.SetDRC(GetDynamicRangeControl());
- }
-
- CAtlArray<BYTE> output;
- AVSampleFormat avsamplefmt = AV_SAMPLE_FMT_NONE;
-
- hr = m_FFAudioDec.Decode(ftype, p, size, size, output, avsamplefmt);
- if (FAILED(hr)) {
- m_buff.RemoveAll();
- m_bResync = true;
- return S_OK;
- } else if (hr == S_FALSE) {
- m_bResync = true;
- p += size;
- continue;
- } else if (!output.IsEmpty()) { // && SUCCEEDED(hr)
- hr = Deliver(output.GetData(), (int)output.GetCount(), avsamplefmt, m_FFAudioDec.GetSampleRate(), m_FFAudioDec.GetChannels(), m_FFAudioDec.GetChannelMask());
- } else if (size == 0) { // && pBuffOut.IsEmpty()
- break;
- }
- }
- p += size;
- }
-
- memmove(base, p, end - p);
- m_buff.SetCount(end - p);
-
- return S_OK;
-}
-
-HRESULT CMpaDecFilter::ProcessAC3_SPDIF()
-{
- HRESULT hr;
- BYTE* const base = m_buff.GetData();
- BYTE* const end = base + m_buff.GetCount();
- BYTE* p = base;
-
- while (p + 8 <= end) { // 8 = AC3 header size + 1
- int samplerate, channels, framelength, bitrate;
-
- int size = ParseAC3Header(p, &samplerate, &channels, &framelength, &bitrate);
-
- if (size == 0) {
- p++;
- continue;
- }
- if (p + size > end) {
- break;
- }
-
- if (FAILED(hr = DeliverBitstream(p, size, IEC61937_AC3, samplerate, 1536))) {
- return hr;
- }
-
- p += size;
- }
-
- memmove(base, p, end - p);
- m_buff.SetCount(end - p);
-
- return S_OK;
-}
-
-HRESULT CMpaDecFilter::ProcessEAC3_SPDIF()
-{
- HRESULT hr;
- BYTE* const base = m_buff.GetData();
- BYTE* const end = base + m_buff.GetCount();
- BYTE* p = base;
-
- while (p + 8 <= end) {
- int samplerate, channels, framelength, frametype;
-
- int size = ParseEAC3Header(p, &samplerate, &channels, &framelength, &frametype);
-
- if (size == 0) {
- p++;
- continue;
- }
- if (p + size > end) {
- break;
- }
-
- static const uint8_t eac3_repeat[4] = {6, 3, 2, 1};
- int repeat = 1;
- if ((p[4] & 0xc0) != 0xc0) { /* fscod */
- repeat = eac3_repeat[(p[4] & 0x30) >> 4]; /* numblkscod */
- }
- m_hdmicount++;
- if (m_hdmisize + size <= BS_EAC3_SIZE - BS_HEADER_SIZE) {
- memcpy(m_hdmibuff + m_hdmisize, p, size);
- m_hdmisize += size;
- } else {
- ASSERT(0);
- }
- p += size;
-
- if (m_hdmicount < repeat) {
- break;
- }
-
- hr = DeliverBitstream(m_hdmibuff, m_hdmisize, IEC61937_EAC3, samplerate, framelength * repeat);
- m_hdmicount = 0;
- m_hdmisize = 0;
- if (FAILED(hr)) {
- return hr;
- }
- }
-
- memmove(base, p, end - p);
- m_buff.SetCount(end - p);
-
- return S_OK;
-}
-
-HRESULT CMpaDecFilter::ProcessTrueHD_SPDIF()
-{
- const BYTE mat_start_code[20] = { 0x07, 0x9E, 0x00, 0x03, 0x84, 0x01, 0x01, 0x01, 0x80, 0x00, 0x56, 0xA5, 0x3B, 0xF4, 0x81, 0x83, 0x49, 0x80, 0x77, 0xE0 };
- const BYTE mat_middle_code[12] = { 0xC3, 0xC1, 0x42, 0x49, 0x3B, 0xFA, 0x82, 0x83, 0x49, 0x80, 0x77, 0xE0 };
- const BYTE mat_end_code[16] = { 0xC3, 0xC2, 0xC0, 0xC4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x97, 0x11 };
-
- HRESULT hr;
- BYTE* const base = m_buff.GetData();
- BYTE* const end = base + m_buff.GetCount();
- BYTE* p = base;
-
- while (p + 16 <= end) {
- int samplerate, channels, framelength;
- WORD bitdepth;
- bool isTrueHD;
-
- int size = ParseMLPHeader(p, &samplerate, &channels, &framelength, &bitdepth, &isTrueHD);
- if (size > 0) {
- // sync frame
- m_truehd_samplerate = samplerate;
- m_truehd_framelength = framelength;
- } else {
- int ac3size = GetAC3FrameSize(p);
- if (ac3size == 0) {
- ac3size = GetEAC3FrameSize(p);
- }
- if (ac3size > 0) {
- if (p + ac3size > end) {
- break;
- }
- p += ac3size;
- continue; // skip ac3 frames
- }
- }
-
- if (size == 0 && m_truehd_framelength > 0) {
- // get not sync frame size
- size = ((p[0] << 8 | p[1]) & 0xfff) * 2;
- }
-
- if (size < 8) {
- p++;
- continue;
- }
- if (p + size > end) {
- break;
- }
-
- m_hdmicount++;
- if (m_hdmicount == 1) {
- // skip 8 header bytes and write MAT start code
- memcpy(m_hdmibuff + BS_HEADER_SIZE, mat_start_code, sizeof(mat_start_code));
- m_hdmisize = BS_HEADER_SIZE + sizeof(mat_start_code);
- } else if (m_hdmicount == 13) {
- memcpy(m_hdmibuff + (BS_HEADER_SIZE + BS_MAT_SIZE) / 2, mat_middle_code, sizeof(mat_middle_code));
- m_hdmisize = (BS_HEADER_SIZE + BS_MAT_SIZE) / 2 + sizeof(mat_middle_code);
- }
-
- if (m_hdmisize + size <= m_hdmicount * BS_MAT_OFFSET) {
- memcpy(m_hdmibuff + m_hdmisize, p, size);
- m_hdmisize += size;
- ZeroMemory(m_hdmibuff + m_hdmisize, m_hdmicount * BS_MAT_OFFSET - m_hdmisize);
- m_hdmisize = m_hdmicount * BS_MAT_OFFSET;
- } else {
- ASSERT(0);
- }
- p += size;
-
- if (m_hdmicount < 24) {
- break;
- }
-
- memcpy(m_hdmibuff + (BS_HEADER_SIZE + BS_MAT_SIZE) - sizeof(mat_end_code), mat_end_code, sizeof(mat_end_code));
- m_hdmisize = (BS_HEADER_SIZE + BS_MAT_SIZE);
-
- hr = DeliverBitstream(m_hdmibuff + BS_HEADER_SIZE, m_hdmisize - BS_HEADER_SIZE, IEC61937_TRUEHD, m_truehd_samplerate, m_truehd_framelength * 24);
- m_hdmicount = 0;
- m_hdmisize = 0;
- if (FAILED(hr)) {
- return hr;
- }
- }
-
- memmove(base, p, end - p);
- m_buff.SetCount(end - p);
-
- return S_OK;
-}
-#endif /* INTERNAL_DECODER_AC3 */
-
-#if defined(STANDALONE_FILTER) || INTERNAL_DECODER_DTS
-HRESULT CMpaDecFilter::ProcessDTS_SPDIF()
-{
- HRESULT hr;
- BYTE* const base = m_buff.GetData();
- BYTE* const end = base + m_buff.GetCount();
- BYTE* p = base;
-
- while (p + 16 <= end) {
- int samplerate = 0, channels, framelength = 0, bitrate;
-
- int size = GetDTSFrameSize(p);
- if (size > 0) {
- size = ParseDTSHeader(p, &samplerate, &channels, &framelength, &bitrate);
- }
- if (size == 0) {
- p++;
- continue;
- }
-
- int sizehd = 0;
- if (p + size + 16 <= end) {
- sizehd = GetDTSHDFrameSize(p + size);
- } else {
- break; // need more data
- }
-
- if (p + size + sizehd > end) {
- break; // need more data
- }
-
- bool usehdmi = sizehd && GetSPDIF(dtshd);
- if (usehdmi) {
- if (FAILED(hr = DeliverBitstream(p, size + sizehd, IEC61937_DTSHD, samplerate, framelength))) {
- return hr;
- }
- } else {
- BYTE type;
- switch (framelength) {
- case 512:
- type = IEC61937_DTS1;
- break;
- case 1024:
- type = IEC61937_DTS2;
- break;
- case 2048:
- type = IEC61937_DTS3;
- break;
- default:
- TRACE(_T("CMpaDecFilter:ProcessDTS_SPDIF() - framelength is not supported\n"));
- return E_FAIL;
- }
- if (FAILED(hr = DeliverBitstream(p, size, type, samplerate, framelength))) {
- return hr;
- }
- }
-
- p += (size + sizehd);
- }
-
- memmove(base, p, end - p);
- m_buff.SetCount(end - p);
-
- return S_OK;
-}
-#endif /* INTERNAL_DECODER_DTS */
-
-#if defined(STANDALONE_FILTER) || INTERNAL_DECODER_PCM
-HRESULT CMpaDecFilter::ProcessPCMraw() // 'raw'
-{
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_pInput->CurrentMediaType().Format();
- size_t size = m_buff.GetCount();
- size_t nSamples = size * 8 / wfe->wBitsPerSample;
-
- AVSampleFormat out_avsf = AV_SAMPLE_FMT_NONE;
- CAtlArray<BYTE> outBuff;
- outBuff.SetCount(size);
-
- switch (wfe->wBitsPerSample) {
- case 8: // unsigned 8-bit
- out_avsf = AV_SAMPLE_FMT_U8;
- memcpy(outBuff.GetData(), m_buff.GetData(), size);
- break;
- case 16: { // signed big-endian 16-bit
- out_avsf = AV_SAMPLE_FMT_S16;
- uint16_t* pIn = (uint16_t*)m_buff.GetData();
- uint16_t* pOut = (uint16_t*)outBuff.GetData();
-
- for (size_t i = 0; i < nSamples; i++) {
- pOut[i] = bswap_16(pIn[i]);
- }
- }
- break;
- }
-
- HRESULT hr;
- if (S_OK != (hr = Deliver(outBuff.GetData(), (int)size, out_avsf, wfe->nSamplesPerSec, wfe->nChannels))) {
- return hr;
- }
-
- m_buff.RemoveAll();
- return S_OK;
-}
-
-HRESULT CMpaDecFilter::ProcessPCMintBE() //'twos', big-endian 'in24' and 'in32'
-{
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_pInput->CurrentMediaType().Format();
- size_t nSamples = m_buff.GetCount() * 8 / wfe->wBitsPerSample;
-
- AVSampleFormat out_avsf = AV_SAMPLE_FMT_NONE;
- size_t outSize = nSamples * (wfe->wBitsPerSample <= 16 ? 2 : 4); // convert to 16 and 32-bit
- CAtlArray<BYTE> outBuff;
- outBuff.SetCount(outSize);
-
- switch (wfe->wBitsPerSample) {
- case 8: { // signed 8-bit
- out_avsf = AV_SAMPLE_FMT_S16;
- int8_t* pIn = (int8_t*)m_buff.GetData();
- int16_t* pOut = (int16_t*)outBuff.GetData();
-
- for (size_t i = 0; i < nSamples; i++) {
- pOut[i] = (int16_t)pIn[i] << 8;
- }
- }
- break;
- case 16: { // signed big-endian 16-bit
- out_avsf = AV_SAMPLE_FMT_S16;
- uint16_t* pIn = (uint16_t*)m_buff.GetData(); // signed take as an unsigned to shift operations.
- uint16_t* pOut = (uint16_t*)outBuff.GetData();
-
- for (size_t i = 0; i < nSamples; i++) {
- pOut[i] = bswap_16(pIn[i]);
- }
- }
- break;
- case 24: { // signed big-endian 24-bit
- out_avsf = AV_SAMPLE_FMT_S32;
- uint8_t* pIn = (uint8_t*)m_buff.GetData();
- uint32_t* pOut = (uint32_t*)outBuff.GetData();
-
- for (size_t i = 0; i < nSamples; i++) {
- pOut[i] = (uint32_t)pIn[3 * i] << 24 |
- (uint32_t)pIn[3 * i + 1] << 16 |
- (uint32_t)pIn[3 * i + 2] << 8;
- }
- }
- break;
- case 32: { // signed big-endian 32-bit
- out_avsf = AV_SAMPLE_FMT_S32;
- uint32_t* pIn = (uint32_t*)m_buff.GetData(); // signed take as an unsigned to shift operations.
- uint32_t* pOut = (uint32_t*)outBuff.GetData();
-
- for (size_t i = 0; i < nSamples; i++) {
- pOut[i] = bswap_32(pIn[i]);
- }
- }
- break;
- }
-
- HRESULT hr;
- if (S_OK != (hr = Deliver(outBuff.GetData(), (int)outSize, out_avsf, wfe->nSamplesPerSec, wfe->nChannels))) {
- return hr;
- }
-
- m_buff.RemoveAll();
- return S_OK;
-}
-
-HRESULT CMpaDecFilter::ProcessPCMintLE() // 'sowt', little-endian 'in24' and 'in32'
-{
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_pInput->CurrentMediaType().Format();
- size_t nSamples = m_buff.GetCount() * 8 / wfe->wBitsPerSample;
-
- AVSampleFormat out_avsf = AV_SAMPLE_FMT_NONE;
- size_t outSize = nSamples * (wfe->wBitsPerSample <= 16 ? 2 : 4); // convert to 16 and 32-bit
- CAtlArray<BYTE> outBuff;
- outBuff.SetCount(outSize);
-
- switch (wfe->wBitsPerSample) {
- case 8: { // signed 8-bit
- out_avsf = AV_SAMPLE_FMT_S16;
- int8_t* pIn = (int8_t*)m_buff.GetData();
- int16_t* pOut = (int16_t*)outBuff.GetData();
-
- for (size_t i = 0; i < nSamples; i++) {
- pOut[i] = (int16_t)pIn[i] << 8;
- }
- }
- break;
- case 16: // signed little-endian 16-bit
- out_avsf = AV_SAMPLE_FMT_S16;
- memcpy(outBuff.GetData(), m_buff.GetData(), outSize);
- break;
- case 24: // signed little-endian 24-bit
- out_avsf = AV_SAMPLE_FMT_S32;
- convert_int24_to_int32(nSamples, (uint8_t*)m_buff.GetData(), (int32_t*)outBuff.GetData());
- break;
- case 32: // signed little-endian 32-bit
- out_avsf = AV_SAMPLE_FMT_S32;
- memcpy(outBuff.GetData(), m_buff.GetData(), outSize);
- break;
- }
-
- HRESULT hr;
- if (S_OK != (hr = Deliver(outBuff.GetData(), (int)outSize, out_avsf, wfe->nSamplesPerSec, wfe->nChannels))) {
- return hr;
- }
-
- m_buff.RemoveAll();
- return S_OK;
-}
-
-HRESULT CMpaDecFilter::ProcessPCMfloatBE() // big-endian 'fl32' and 'fl64'
-{
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_pInput->CurrentMediaType().Format();
- size_t size = m_buff.GetCount();
- size_t nSamples = size * 8 / wfe->wBitsPerSample;
-
- AVSampleFormat out_avsf = AV_SAMPLE_FMT_NONE;
- CAtlArray<BYTE> outBuff;
- outBuff.SetCount(size);
-
- switch (wfe->wBitsPerSample) {
- case 32: {
- out_avsf = AV_SAMPLE_FMT_FLT;
- uint32_t* pIn = (uint32_t*)m_buff.GetData();
- uint32_t* pOut = (uint32_t*)outBuff.GetData();
- for (size_t i = 0; i < nSamples; i++) {
- pOut[i] = bswap_32(pIn[i]);
- }
- }
- break;
- case 64: {
- out_avsf = AV_SAMPLE_FMT_DBL;
- uint64_t* pIn = (uint64_t*)m_buff.GetData();
- uint64_t* pOut = (uint64_t*)outBuff.GetData();
- for (size_t i = 0; i < nSamples; i++) {
- pOut[i] = bswap_64(pIn[i]);
- }
- }
- break;
- }
-
- HRESULT hr;
- if (S_OK != (hr = Deliver(outBuff.GetData(), (int)size, out_avsf, wfe->nSamplesPerSec, wfe->nChannels))) {
- return hr;
- }
-
- m_buff.RemoveAll();
- return S_OK;
-}
-
-HRESULT CMpaDecFilter::ProcessPCMfloatLE() // little-endian 'fl32' and 'fl64'
-{
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_pInput->CurrentMediaType().Format();
- size_t size = m_buff.GetCount();
-
- AVSampleFormat out_avsf = AV_SAMPLE_FMT_NONE;
- CAtlArray<BYTE> outBuff;
- outBuff.SetCount(size);
-
- switch (wfe->wBitsPerSample) {
- case 32:
- out_avsf = AV_SAMPLE_FMT_FLT;
- break;
- case 64:
- out_avsf = AV_SAMPLE_FMT_DBL;
- break;
- }
- memcpy(outBuff.GetData(), m_buff.GetData(), size);
-
- HRESULT hr;
- if (S_OK != (hr = Deliver(outBuff.GetData(), (int)size, out_avsf, wfe->nSamplesPerSec, wfe->nChannels))) {
- return hr;
- }
-
- m_buff.RemoveAll();
- return S_OK;
-}
-#endif /* INTERNAL_DECODER_PCM */
-
-#if defined(STANDALONE_FILTER) || INTERNAL_DECODER_PS2AUDIO
-HRESULT CMpaDecFilter::ProcessPS2PCM()
-{
- BYTE* const base = m_buff.GetData();
- BYTE* const end = base + m_buff.GetCount();
- BYTE* p = base;
-
- WAVEFORMATEXPS2* wfe = (WAVEFORMATEXPS2*)m_pInput->CurrentMediaType().Format();
- size_t size = wfe->dwInterleave * wfe->nChannels;
-
- AVSampleFormat out_avsf = AV_SAMPLE_FMT_S16P;
- CAtlArray<BYTE> outBuff;
- outBuff.SetCount(size);
-
- while (p + size <= end) {
- DWORD* dw = (DWORD*)p;
-
- if (dw[0] == 'dhSS') {
- p += dw[1] + 8;
- } else if (dw[0] == 'dbSS') {
- p += 8;
- m_ps2_state.sync = true;
- } else {
- if (m_ps2_state.sync) {
- memcpy(outBuff.GetData(), p, size);
- } else {
- ZeroMemory(outBuff.GetData(), size);
- }
-
- HRESULT hr;
- if (S_OK != (hr = Deliver(outBuff.GetData(), (int)size, out_avsf, wfe->nSamplesPerSec, wfe->nChannels))) {
- return hr;
- }
-
- p += size;
- }
- }
-
- memmove(base, p, end - p);
- m_buff.SetCount(end - p);
-
- return S_OK;
-}
-
-static void decodeps2adpcm(ps2_state_t& s, int channel, BYTE* pin, float* pout)
-{
- int tbl_index = pin[0] >> 4;
- int shift = pin[0] & 0xf;
- int unk = pin[1]; // ?
- UNREFERENCED_PARAMETER(unk);
-
- if (tbl_index >= 10) {
- ASSERT(0);
- return;
- }
- // if (unk == 7) {ASSERT(0); return;} // ???
-
- static double s_tbl[] = {
- 0.0, 0.0, 0.9375, 0.0, 1.796875, -0.8125, 1.53125, -0.859375, 1.90625, -0.9375,
- 0.0, 0.0, -0.9375, 0.0, -1.796875, 0.8125, -1.53125, 0.859375, -1.90625, 0.9375
- };
-
- double* tbl = &s_tbl[tbl_index * 2];
- double& a = s.a[channel];
- double& b = s.b[channel];
-
- for (int i = 0; i < 28; i++) {
- short input = (short)(((pin[2 + i / 2] >> ((i & 1) << 2)) & 0xf) << 12) >> shift;
- double output = a * tbl[1] + b * tbl[0] + input;
-
- a = b;
- b = output;
-
- *pout++ = (float)(output / 32768);
- }
-}
-
-HRESULT CMpaDecFilter::ProcessPS2ADPCM()
-{
- BYTE* const base = m_buff.GetData();
- BYTE* const end = base + m_buff.GetCount();
- BYTE* p = base;
-
- WAVEFORMATEXPS2* wfe = (WAVEFORMATEXPS2*)m_pInput->CurrentMediaType().Format();
- size_t size = wfe->dwInterleave * wfe->nChannels;
- int samples = wfe->dwInterleave * 14 / 16 * 2;
- int channels = wfe->nChannels;
-
- AVSampleFormat out_avsf = AV_SAMPLE_FMT_FLTP;
- size_t outSize = samples * channels * sizeof(float); // convert to float
- CAtlArray<BYTE> outBuff;
- outBuff.SetCount(outSize);
- float* pOut = (float*)outBuff.GetData();
-
- while (p + size <= end) {
- DWORD* dw = (DWORD*)p;
-
- if (dw[0] == 'dhSS') {
- p += dw[1] + 8;
- } else if (dw[0] == 'dbSS') {
- p += 8;
- m_ps2_state.sync = true;
- } else {
- if (m_ps2_state.sync) {
- for (int ch = 0, j = 0, k = 0; ch < channels; ch++, j += wfe->dwInterleave) {
- for (DWORD i = 0; i < wfe->dwInterleave; i += 16, k += 28) {
- decodeps2adpcm(m_ps2_state, ch, p + i + j, pOut + k);
- }
- }
- } else {
- ZeroMemory(outBuff.GetData(), outSize);
- }
-
- HRESULT hr;
- if (S_OK != (hr = Deliver(outBuff.GetData(), (int)outSize, out_avsf, wfe->nSamplesPerSec, wfe->nChannels))) {
- return hr;
- }
-
- p += size;
- }
- }
-
- memmove(base, p, end - p);
- m_buff.SetCount(end - p);
-
- return S_OK;
-}
-#endif /* INTERNAL_DECODER_PS2AUDIO */
-
-HRESULT CMpaDecFilter::GetDeliveryBuffer(IMediaSample** pSample, BYTE** pData)
-{
- HRESULT hr;
- *pData = nullptr;
-
- if (FAILED(hr = m_pOutput->GetDeliveryBuffer(pSample, nullptr, nullptr, 0))
- || FAILED(hr = (*pSample)->GetPointer(pData))) {
- return hr;
- }
-
- AM_MEDIA_TYPE* pmt = nullptr;
- if (SUCCEEDED((*pSample)->GetMediaType(&pmt)) && pmt) {
- CMediaType mt = *pmt;
- m_pOutput->SetMediaType(&mt);
- DeleteMediaType(pmt);
- pmt = nullptr;
- }
-
- return S_OK;
-}
-
-HRESULT CMpaDecFilter::Deliver(BYTE* pBuff, int size, AVSampleFormat avsf, DWORD nSamplesPerSec, WORD nChannels, DWORD dwChannelMask)
-{
- if (dwChannelMask == 0) {
- dwChannelMask = GetDefChannelMask(nChannels);
- }
- ASSERT(nChannels == av_popcount(dwChannelMask));
-
- int nSamples = size / (nChannels * av_get_bytes_per_sample(avsf));
-
- REFERENCE_TIME rtDur = 10000000i64 * nSamples / nSamplesPerSec;
- REFERENCE_TIME rtStart = m_rtStart;
- REFERENCE_TIME rtStop = m_rtStart + rtDur;
- m_rtStart += rtDur;
- //TRACE(_T("CMpaDecFilter: %I64d - %I64d\n"), rtStart/10000, rtStop/10000);
- if (rtStart < 0 /*200000*/ /* < 0, FIXME: 0 makes strange noises */) {
- return S_OK;
- }
-
- BYTE* pDataIn = pBuff;
- CAtlArray<float> mixData;
-
- if (GetMixer()) {
- int sc = GetMixerLayout();
- WORD mixed_channels = channel_mode[sc].channels;
- DWORD mixed_mask = channel_mode[sc].ch_layout;
-
- if (dwChannelMask != mixed_mask) {
- mixData.SetCount(nSamples * mixed_channels);
- m_Mixer.Update(avsf, dwChannelMask, mixed_mask);
-
- if (m_Mixer.Mixing(mixData.GetData(), nSamples, pDataIn, nSamples) > 0) {
- pDataIn = (BYTE*)mixData.GetData();
- avsf = AV_SAMPLE_FMT_FLT; // float after mixing
- size = nSamples * mixed_channels * sizeof(float);
- nChannels = mixed_channels;
- dwChannelMask = mixed_mask;
- }
- }
- }
-
- MPCSampleFormat out_sf;
- switch (avsf) {
- case AV_SAMPLE_FMT_U8:
- case AV_SAMPLE_FMT_U8P:
- case AV_SAMPLE_FMT_S16:
- case AV_SAMPLE_FMT_S16P:
- out_sf = SF_PCM16;
- break;
- case AV_SAMPLE_FMT_S32:
- case AV_SAMPLE_FMT_S32P:
- out_sf = SF_PCM32;
- break;
- case AV_SAMPLE_FMT_FLT:
- case AV_SAMPLE_FMT_FLTP:
- case AV_SAMPLE_FMT_DBL:
- case AV_SAMPLE_FMT_DBLP:
- out_sf = SF_FLOAT;
- break;
- default:
- return E_INVALIDARG;
- }
- out_sf = SelectSampleFormat(out_sf);
-
- CMediaType mt = CreateMediaType(out_sf, nSamplesPerSec, nChannels, dwChannelMask);
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
-
- HRESULT hr;
- if (FAILED(hr = ReconnectOutput(nSamples, mt))) {
- return hr;
- }
-
- CComPtr<IMediaSample> pOut;
- BYTE* pDataOut = nullptr;
- if (FAILED(GetDeliveryBuffer(&pOut, &pDataOut))) {
- return E_FAIL;
- }
-
- if (hr == S_OK) {
- m_pOutput->SetMediaType(&mt);
- pOut->SetMediaType(&mt);
- }
-
- pOut->SetTime(&rtStart, &rtStop);
- pOut->SetMediaTime(nullptr, nullptr);
-
- pOut->SetPreroll(FALSE);
- pOut->SetDiscontinuity(m_fDiscontinuity);
- m_fDiscontinuity = false;
- pOut->SetSyncPoint(TRUE);
-
- pOut->SetActualDataLength(nSamples * nChannels * wfe->wBitsPerSample / 8);
-
- WAVEFORMATEX* wfeout = (WAVEFORMATEX*)m_pOutput->CurrentMediaType().Format();
- ASSERT(wfeout->nChannels == wfe->nChannels);
- ASSERT(wfeout->nSamplesPerSec == wfe->nSamplesPerSec);
- UNREFERENCED_PARAMETER(wfeout);
-
- switch (out_sf) {
- case SF_PCM16:
- convert_to_int16(avsf, nChannels, nSamples, pDataIn, (int16_t*)pDataOut);
- break;
- case SF_PCM24:
- convert_to_int24(avsf, nChannels, nSamples, pDataIn, pDataOut);
- break;
- case SF_PCM32:
- convert_to_int32(avsf, nChannels, nSamples, pDataIn, (int32_t*)pDataOut);
- break;
- case SF_FLOAT:
- convert_to_float(avsf, nChannels, nSamples, pDataIn, (float*)pDataOut);
- break;
- }
-
- return m_pOutput->Deliver(pOut);
-}
-
-HRESULT CMpaDecFilter::DeliverBitstream(BYTE* pBuff, int size, WORD type, int sample_rate, int samples)
-{
- HRESULT hr;
- WORD subtype = 0;
- bool isDTSWAV = false;
- bool isHDMI = false;
- int length = 0;
-
- switch (type) {
- case IEC61937_AC3:
- length = BS_AC3_SIZE;
- break;
- case IEC61937_DTS1:
- case IEC61937_DTS2:
- case IEC61937_DTS3:
- if (size == 4096 && sample_rate == 44100 && samples == 1024) { // DTSWAV
- length = size;
- isDTSWAV = true;
- } else {
- while (length < size + 16) {
- length += 2048;
- }
- }
- break;
- case IEC61937_DTSHD:
- length = BS_DTSHD_SIZE;
- subtype = 4;
- isHDMI = true;
- break;
- case IEC61937_EAC3:
- length = BS_EAC3_SIZE;
- isHDMI = true;
- break;
- case IEC61937_TRUEHD:
- length = BS_TRUEHD_SIZE;
- isHDMI = true;
- break;
- default:
- TRACE(_T("CMpaDecFilter::DeliverBitstream() - type is not supported\n"));
- return E_INVALIDARG;
- }
-
- CMediaType mt;
- if (isHDMI) {
- mt = CreateMediaTypeHDMI(type);
- } else {
- mt = CreateMediaTypeSPDIF(sample_rate);
- }
-
- if (FAILED(hr = ReconnectOutput(length, mt))) {
- return hr;
- }
-
- CComPtr<IMediaSample> pOut;
- BYTE* pDataOut = nullptr;
- if (FAILED(GetDeliveryBuffer(&pOut, &pDataOut))) {
- return E_FAIL;
- }
-
- if (isDTSWAV) {
- memcpy(pDataOut, pBuff, size);
- } else {
- ZeroMemory(pDataOut + BS_HEADER_SIZE + size, length - (BS_HEADER_SIZE + size)); // Fill after the input buffer with zeros if any extra bytes
-
- int index = 0;
- // Fill the 8 bytes (4 words) of IEC header
- WORD* pDataOutW = (WORD*)pDataOut;
- pDataOutW[index++] = 0xf872;
- pDataOutW[index++] = 0x4e1f;
- pDataOutW[index++] = type | subtype << 8;
- if (type == IEC61937_DTSHD) {
- pDataOutW[index++] = (size & ~0xf) + 0x18; // (size without 12 extra bytes) & 0xf + 0x18
- // begin dts-hd start code
- pDataOutW[index++] = 0x0100;
- pDataOutW[index++] = 0;
- pDataOutW[index++] = 0;
- pDataOutW[index++] = 0;
- pDataOutW[index++] = 0xfefe;
- // end dts-hd start code
- pDataOutW[index++] = size;
- } else if (type == IEC61937_EAC3 || type == IEC61937_TRUEHD) {
- pDataOutW[index++] = size;
- } else {
- pDataOutW[index++] = size * 8;
- }
- _swab((char*)pBuff, (char*)&pDataOutW[index], size & ~1);
- if (size & 1) { // _swab doesn't like odd number.
- pDataOut[index * 2 + size - 1] = 0;
- pDataOut[index * 2 + size] = pBuff[size - 1];
- }
- }
-
- REFERENCE_TIME rtDur;
- rtDur = 10000000i64 * samples / sample_rate;
- REFERENCE_TIME rtStart = m_rtStart, rtStop = m_rtStart + rtDur;
- m_rtStart += rtDur;
-
- if (rtStart < 0) {
- return S_OK;
- }
-
- if (hr == S_OK) {
- m_pOutput->SetMediaType(&mt);
- pOut->SetMediaType(&mt);
- }
-
- pOut->SetTime(&rtStart, &rtStop);
- pOut->SetMediaTime(nullptr, nullptr);
-
- pOut->SetPreroll(FALSE);
- pOut->SetDiscontinuity(m_fDiscontinuity);
- m_fDiscontinuity = false;
- pOut->SetSyncPoint(TRUE);
-
- pOut->SetActualDataLength(length);
-
- return m_pOutput->Deliver(pOut);
-}
-
-HRESULT CMpaDecFilter::ReconnectOutput(int nSamples, CMediaType& mt)
-{
- HRESULT hr;
-
- CComQIPtr<IMemInputPin> pPin = m_pOutput->GetConnected();
- if (!pPin) {
- return E_NOINTERFACE;
- }
-
- CComPtr<IMemAllocator> pAllocator;
- if (FAILED(hr = pPin->GetAllocator(&pAllocator)) || !pAllocator) {
- return hr;
- }
-
- ALLOCATOR_PROPERTIES props, actual;
- if (FAILED(hr = pAllocator->GetProperties(&props))) {
- return hr;
- }
-
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
- long cbBuffer = nSamples * wfe->nBlockAlign;
-
- if (mt != m_pOutput->CurrentMediaType() || cbBuffer > props.cbBuffer) {
- if (cbBuffer > props.cbBuffer) {
- props.cBuffers = 4;
- props.cbBuffer = cbBuffer * 3 / 2;
-
- if (FAILED(hr = m_pOutput->DeliverBeginFlush())
- || FAILED(hr = m_pOutput->DeliverEndFlush())
- || FAILED(hr = pAllocator->Decommit())
- || FAILED(hr = pAllocator->SetProperties(&props, &actual))
- || FAILED(hr = pAllocator->Commit())) {
- return hr;
- }
-
- if (props.cBuffers > actual.cBuffers || props.cbBuffer > actual.cbBuffer) {
- NotifyEvent(EC_ERRORABORT, hr, 0);
- return E_FAIL;
- }
- }
-
- return S_OK;
- }
-
- return S_FALSE;
-}
-
-CMediaType CMpaDecFilter::CreateMediaType(MPCSampleFormat sf, DWORD nSamplesPerSec, WORD nChannels, DWORD dwChannelMask)
-{
- CMediaType mt;
-
- mt.majortype = MEDIATYPE_Audio;
- mt.subtype = sf == SF_FLOAT ? MEDIASUBTYPE_IEEE_FLOAT : MEDIASUBTYPE_PCM;
- mt.formattype = FORMAT_WaveFormatEx;
-
- WAVEFORMATEXTENSIBLE wfex;
- //ZeroMemory(&wfex, sizeof(wfex));
-
- WAVEFORMATEX& wfe = wfex.Format;
- wfe.nChannels = nChannels;
- wfe.nSamplesPerSec = nSamplesPerSec;
- switch (sf) {
- default:
- case SF_PCM16:
- wfe.wBitsPerSample = 16;
- break;
- case SF_PCM24:
- wfe.wBitsPerSample = 24;
- break;
- case SF_PCM32:
- case SF_FLOAT:
- wfe.wBitsPerSample = 32;
- break;
- }
- wfe.nBlockAlign = nChannels * wfe.wBitsPerSample / 8;
- wfe.nAvgBytesPerSec = nSamplesPerSec * wfe.nBlockAlign;
-
- if (nChannels <= 2 && dwChannelMask <= 0x4 && (sf == SF_PCM16 || sf == SF_FLOAT)) {
- // WAVEFORMATEX
- wfe.wFormatTag = (sf == SF_FLOAT) ? WAVE_FORMAT_IEEE_FLOAT : WAVE_FORMAT_PCM;
- wfe.cbSize = 0;
-
- mt.SetFormat((BYTE*)&wfe, sizeof(wfe));
- } else {
- // WAVEFORMATEXTENSIBLE
- wfex.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
- wfex.Format.cbSize = sizeof(wfex) - sizeof(wfex.Format); // 22
- wfex.Samples.wValidBitsPerSample = wfex.Format.wBitsPerSample;
- if (dwChannelMask == 0) {
- dwChannelMask = GetDefChannelMask(nChannels);
- }
- wfex.dwChannelMask = dwChannelMask;
- wfex.SubFormat = mt.subtype;
-
- mt.SetFormat((BYTE*)&wfex, sizeof(wfex));
- }
- mt.SetSampleSize(wfex.Format.nBlockAlign);
-
- return mt;
-}
-
-CMediaType CMpaDecFilter::CreateMediaTypeSPDIF(DWORD nSamplesPerSec)
-{
- if (nSamplesPerSec % 11025 == 0) {
- nSamplesPerSec = 44100;
- } else {
- nSamplesPerSec = 48000;
- }
- CMediaType mt = CreateMediaType(SF_PCM16, nSamplesPerSec, 2, SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT);
- ((WAVEFORMATEX*)mt.pbFormat)->wFormatTag = WAVE_FORMAT_DOLBY_AC3_SPDIF;
- return mt;
-}
-
-CMediaType CMpaDecFilter::CreateMediaTypeHDMI(WORD type)
-{
- // some info here - http://msdn.microsoft.com/en-us/library/windows/desktop/dd316761%28v=vs.85%29.aspx
- // but we use WAVEFORMATEXTENSIBLE structure
- CMediaType mt;
- mt.majortype = MEDIATYPE_Audio;
- mt.subtype = MEDIASUBTYPE_PCM;
- mt.formattype = FORMAT_WaveFormatEx;
-
- WAVEFORMATEXTENSIBLE wfex;
- ZeroMemory(&wfex, sizeof(wfex));
-
- GUID subtype = GUID_NULL;
-
- switch (type) {
- case IEC61937_DTSHD:
- wfex.Format.nChannels = 8;
- wfex.dwChannelMask = KSAUDIO_SPEAKER_7POINT1_SURROUND;
- subtype = KSDATAFORMAT_SUBTYPE_IEC61937_DTS_HD;
- break;
- case IEC61937_EAC3:
- wfex.Format.nChannels = 2;
- wfex.dwChannelMask = KSAUDIO_SPEAKER_STEREO;
- subtype = KSDATAFORMAT_SUBTYPE_IEC61937_DOLBY_DIGITAL_PLUS;
- break;
- case IEC61937_TRUEHD:
- wfex.Format.nChannels = 8;
- wfex.dwChannelMask = KSAUDIO_SPEAKER_7POINT1_SURROUND;
- subtype = KSDATAFORMAT_SUBTYPE_IEC61937_DOLBY_MLP;
- break;
- default:
- ASSERT(0);
- break;
- }
-
- if (subtype != GUID_NULL) {
- wfex.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
- wfex.Format.nSamplesPerSec = 192000;
- wfex.Format.wBitsPerSample = 16;
- wfex.Format.nBlockAlign = wfex.Format.nChannels * wfex.Format.wBitsPerSample / 8;
- wfex.Format.nAvgBytesPerSec = wfex.Format.nSamplesPerSec * wfex.Format.nBlockAlign;
- wfex.Format.cbSize = sizeof(wfex) - sizeof(wfex.Format);
- wfex.Samples.wValidBitsPerSample = wfex.Format.wBitsPerSample;
- wfex.SubFormat = subtype;
- }
-
- mt.SetSampleSize(1);
- mt.SetFormat((BYTE*)&wfex, sizeof(wfex.Format) + wfex.Format.cbSize);
-
- return mt;
-}
-
-HRESULT CMpaDecFilter::CheckInputType(const CMediaType* mtIn)
-{
- if (0) {}
-#if defined(STANDALONE_FILTER) || INTERNAL_DECODER_LPCM
- else if (mtIn->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mtIn->Format();
- if (wfe->nChannels < 1 || wfe->nChannels > 8 || (wfe->wBitsPerSample != 16 && wfe->wBitsPerSample != 20 && wfe->wBitsPerSample != 24)) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- }
-#endif
-#if defined(STANDALONE_FILTER) || INTERNAL_DECODER_PS2AUDIO
- else if (mtIn->subtype == MEDIASUBTYPE_PS2_ADPCM) {
- WAVEFORMATEXPS2* wfe = (WAVEFORMATEXPS2*)mtIn->Format();
- if (wfe->dwInterleave & 0xf) { // has to be a multiple of the block size (16 bytes)
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- }
-#endif
-#if defined(STANDALONE_FILTER) || INTERNAL_DECODER_PCM
- else if (mtIn->subtype == MEDIASUBTYPE_IEEE_FLOAT) {
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mtIn->Format();
- if (wfe->wBitsPerSample != 64) { // only for 64-bit float PCM
- return VFW_E_TYPE_NOT_ACCEPTED; // not needed any decoders for 32-bit float
- }
- }
-#endif
-
- for (int i = 0; i < _countof(sudPinTypesIn); i++) {
- if (*sudPinTypesIn[i].clsMajorType == mtIn->majortype
- && *sudPinTypesIn[i].clsMinorType == mtIn->subtype) {
- return S_OK;
- }
- }
-
- return VFW_E_TYPE_NOT_ACCEPTED;
-}
-
-HRESULT CMpaDecFilter::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
-{
- return SUCCEEDED(CheckInputType(mtIn))
- && mtOut->majortype == MEDIATYPE_Audio && mtOut->subtype == MEDIASUBTYPE_PCM
- || mtOut->majortype == MEDIATYPE_Audio && mtOut->subtype == MEDIASUBTYPE_IEEE_FLOAT
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
-}
-
-HRESULT CMpaDecFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
-{
- if (m_pInput->IsConnected() == FALSE) {
- return E_UNEXPECTED;
- }
-
- CMediaType& mt = m_pInput->CurrentMediaType();
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
- UNREFERENCED_PARAMETER(wfe);
-
- pProperties->cBuffers = 4;
- // pProperties->cbBuffer = 1;
- pProperties->cbBuffer = 48000 * 6 * (32 / 8) / 10; // 48KHz 6ch 32bps 100ms
- pProperties->cbAlign = 1;
- pProperties->cbPrefix = 0;
-
- HRESULT hr;
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
- return hr;
- }
-
- return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR;
-}
-
-HRESULT CMpaDecFilter::GetMediaType(int iPosition, CMediaType* pmt)
-{
- if (m_pInput->IsConnected() == FALSE) {
- return E_UNEXPECTED;
- }
-
- if (iPosition < 0) {
- return E_INVALIDARG;
- }
- if (iPosition > 0) {
- return VFW_S_NO_MORE_ITEMS;
- }
-
- CMediaType mt = m_pInput->CurrentMediaType();
- WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
- if (wfe == nullptr) {
- return E_INVALIDARG;
- }
-
-#if defined(STANDALONE_FILTER) || INTERNAL_DECODER_AC3 || INTERNAL_DECODER_DTS
- const GUID& subtype = mt.subtype;
- if (GetSPDIF(ac3) && (subtype == MEDIASUBTYPE_DOLBY_AC3 || subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3) ||
- GetSPDIF(dts) && (subtype == MEDIASUBTYPE_DTS || subtype == MEDIASUBTYPE_WAVE_DTS)) {
- *pmt = CreateMediaTypeSPDIF(wfe->nSamplesPerSec);
- return S_OK;
- }
- if (GetSPDIF(eac3) && subtype == MEDIASUBTYPE_DOLBY_DDPLUS) {
- *pmt = CreateMediaTypeHDMI(IEC61937_EAC3);
- return S_OK;
- }
- if (GetSPDIF(truehd) && subtype == MEDIASUBTYPE_DOLBY_TRUEHD) {
- *pmt = CreateMediaTypeHDMI(IEC61937_TRUEHD);
- return S_OK;
- }
-#endif
-
- if (GetMixer()) {
- DWORD in_layout;
-#if defined(STANDALONE_FILTER) || HAS_FFMPEG_AUDIO_DECODERS
- if (m_FFAudioDec.GetCodecId() != AV_CODEC_ID_NONE) {
- in_layout = m_FFAudioDec.GetChannelMask();
- } else {
- in_layout = GetDefChannelMask(wfe->nChannels);
- }
-#else
- in_layout = GetDefChannelMask(wfe->nChannels);
-#endif
-
- int sc = GetMixerLayout();
- if (in_layout != channel_mode[sc].ch_layout) {
- *pmt = CreateMediaType(SelectSampleFormat(SF_FLOAT), wfe->nSamplesPerSec, channel_mode[sc].channels, channel_mode[sc].ch_layout);
- return S_OK;
- }
- }
-
-#if defined(STANDALONE_FILTER) || HAS_FFMPEG_AUDIO_DECODERS
- if (m_FFAudioDec.GetCodecId() != AV_CODEC_ID_NONE) {
- AVSampleFormat avsf = m_FFAudioDec.GetSampleFmt();
- MPCSampleFormat out_sf;
- switch (avsf) {
- case AV_SAMPLE_FMT_U8:
- case AV_SAMPLE_FMT_U8P:
- case AV_SAMPLE_FMT_S16:
- case AV_SAMPLE_FMT_S16P:
- out_sf = SF_PCM16;
- break;
- case AV_SAMPLE_FMT_S32:
- case AV_SAMPLE_FMT_S32P:
- out_sf = SF_PCM32;
- break;
- case AV_SAMPLE_FMT_FLT:
- case AV_SAMPLE_FMT_FLTP:
- case AV_SAMPLE_FMT_DBL:
- case AV_SAMPLE_FMT_DBLP:
- out_sf = SF_FLOAT;
- break;
- default:
- out_sf = SF_PCM16;
- }
- out_sf = SelectSampleFormat(out_sf);
-
- *pmt = CreateMediaType(out_sf, m_FFAudioDec.GetSampleRate(), m_FFAudioDec.GetChannels(), m_FFAudioDec.GetChannelMask());
- return S_OK;
- }
-#endif
-
- MPCSampleFormat out_sf;
- if (wfe->wFormatTag == WAVE_FORMAT_PCM && wfe->wBitsPerSample > 16) {
- out_sf = SF_PCM32;
- } else if (wfe->wFormatTag == WAVE_FORMAT_IEEE_FLOAT) {
- out_sf = SF_FLOAT;
- } else {
- out_sf = SF_PCM16;
- }
- out_sf = SelectSampleFormat(out_sf);
-
- *pmt = CreateMediaType(out_sf, wfe->nSamplesPerSec, wfe->nChannels);
-
- return S_OK;
-}
-
-HRESULT CMpaDecFilter::StartStreaming()
-{
- HRESULT hr = __super::StartStreaming();
- if (FAILED(hr)) {
- return hr;
- }
-
- m_ps2_state.reset();
-
- m_fDiscontinuity = false;
-
- return S_OK;
-}
-
-HRESULT CMpaDecFilter::StopStreaming()
-{
-#if defined(STANDALONE_FILTER) || HAS_FFMPEG_AUDIO_DECODERS
- m_FFAudioDec.StreamFinish();
-#endif
-
- return __super::StopStreaming();
-}
-
-HRESULT CMpaDecFilter::SetMediaType(PIN_DIRECTION dir, const CMediaType* pmt)
-{
-#if defined(STANDALONE_FILTER) || HAS_FFMPEG_AUDIO_DECODERS
- if (dir == PINDIR_INPUT) {
- enum AVCodecID nCodecId = FindCodec(pmt->subtype);
- if (nCodecId != AV_CODEC_ID_NONE) {
- if (m_FFAudioDec.Init(nCodecId, m_pInput)) {
- m_FFAudioDec.SetDRC(GetDynamicRangeControl());
- } else {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- }
- }
-#endif
-
- return __super::SetMediaType(dir, pmt);
-}
-
-// IMpaDecFilter
-
-STDMETHODIMP CMpaDecFilter::SetSampleFormat(MPCSampleFormat sf, bool enable)
-{
- CAutoLock cAutoLock(&m_csProps);
- if (sf >= 0 && sf < sfcount) {
- m_fSampleFmt[sf] = enable;
- } else {
- return E_INVALIDARG;
- }
-
- return S_OK;
-}
-
-STDMETHODIMP_(bool) CMpaDecFilter::GetSampleFormat(MPCSampleFormat sf)
-{
- CAutoLock cAutoLock(&m_csProps);
- if (sf >= 0 && sf < sfcount) {
- return m_fSampleFmt[sf];
- }
- return false;
-}
-
-STDMETHODIMP_(MPCSampleFormat) CMpaDecFilter::SelectSampleFormat(MPCSampleFormat sf)
-{
- CAutoLock cAutoLock(&m_csProps);
- if (sf >= 0 && sf < sfcount && m_fSampleFmt[sf]) {
- return sf;
- }
-
- if (m_fSampleFmt[SF_FLOAT]) {
- return SF_FLOAT;
- }
- if (m_fSampleFmt[SF_PCM24]) {
- return SF_PCM24;
- }
- if (m_fSampleFmt[SF_PCM16]) {
- return SF_PCM16;
- }
- if (m_fSampleFmt[SF_PCM32]) {
- return SF_PCM32;
- }
- return SF_PCM16;
-}
-
-STDMETHODIMP CMpaDecFilter::SetMixer(bool fMixer)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_fMixer = fMixer;
-
- return S_OK;
-}
-
-STDMETHODIMP_(bool) CMpaDecFilter::GetMixer()
-{
- CAutoLock cAutoLock(&m_csProps);
-
- return m_fMixer;
-}
-
-STDMETHODIMP CMpaDecFilter::SetMixerLayout(int sc)
-{
- CAutoLock cAutoLock(&m_csProps);
- if (sc < SPK_MONO || sc > SPK_7_1) {
- return E_INVALIDARG;
- }
- m_iMixerLayout = sc;
-
- return S_OK;
-}
-
-STDMETHODIMP_(int) CMpaDecFilter::GetMixerLayout()
-{
- CAutoLock cAutoLock(&m_csProps);
-
- return m_iMixerLayout;
-}
-
-STDMETHODIMP CMpaDecFilter::SetDynamicRangeControl(bool fDRC)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_fDRC = fDRC;
-
-#if HAS_FFMPEG_AUDIO_DECODERS
- m_FFAudioDec.SetDRC(fDRC);
-#endif
-
- return S_OK;
-}
-
-STDMETHODIMP_(bool) CMpaDecFilter::GetDynamicRangeControl()
-{
- CAutoLock cAutoLock(&m_csProps);
-
- return m_fDRC;
-}
-
-STDMETHODIMP CMpaDecFilter::SetSPDIF(enctype et, bool fSPDIF)
-{
- CAutoLock cAutoLock(&m_csProps);
- if (et < 0 || et >= etcount) {
- return E_INVALIDARG;
- }
-
- m_fSPDIF[et] = fSPDIF;
- return S_OK;
-}
-
-STDMETHODIMP_(bool) CMpaDecFilter::GetSPDIF(enctype et)
-{
- CAutoLock cAutoLock(&m_csProps);
- if (et < 0 || et >= etcount) {
- return false;
- }
- if (et == dtshd && !m_fSPDIF[dts]) {
- return false;
- }
-
- return m_fSPDIF[et];
-}
-
-STDMETHODIMP CMpaDecFilter::SaveSettings()
-{
- CAutoLock cAutoLock(&m_csProps);
-
-#ifdef STANDALONE_FILTER
- CRegKey key;
- if (ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, OPT_REGKEY_MpaDec)) {
- key.SetDWORDValue(OPTION_SFormat_i16, m_fSampleFmt[SF_PCM16]);
- key.SetDWORDValue(OPTION_SFormat_i24, m_fSampleFmt[SF_PCM24]);
- key.SetDWORDValue(OPTION_SFormat_i32, m_fSampleFmt[SF_PCM32]);
- key.SetDWORDValue(OPTION_SFormat_flt, m_fSampleFmt[SF_FLOAT]);
- key.SetDWORDValue(OPTION_Mixer, m_fMixer);
- key.SetStringValue(OPTION_MixerLayout, channel_mode[m_iMixerLayout].op_value);
- key.SetDWORDValue(OPTION_DRC, m_fDRC);
- key.SetDWORDValue(OPTION_SPDIF_ac3, m_fSPDIF[ac3]);
- key.SetDWORDValue(OPTION_SPDIF_eac3, m_fSPDIF[eac3]);
- key.SetDWORDValue(OPTION_SPDIF_truehd, m_fSPDIF[truehd]);
- key.SetDWORDValue(OPTION_SPDIF_dts, m_fSPDIF[dts]);
- key.SetDWORDValue(OPTION_SPDIF_dtshd, m_fSPDIF[dtshd]);
- }
-#else
- AfxGetApp()->WriteProfileInt(OPT_SECTION_MpaDec, OPTION_SFormat_i16, m_fSampleFmt[SF_PCM16]);
- AfxGetApp()->WriteProfileInt(OPT_SECTION_MpaDec, OPTION_SFormat_i24, m_fSampleFmt[SF_PCM24]);
- AfxGetApp()->WriteProfileInt(OPT_SECTION_MpaDec, OPTION_SFormat_i32, m_fSampleFmt[SF_PCM32]);
- AfxGetApp()->WriteProfileInt(OPT_SECTION_MpaDec, OPTION_SFormat_flt, m_fSampleFmt[SF_FLOAT]);
- AfxGetApp()->WriteProfileInt(OPT_SECTION_MpaDec, OPTION_Mixer, m_fMixer);
- AfxGetApp()->WriteProfileString(OPT_SECTION_MpaDec, OPTION_MixerLayout, channel_mode[m_iMixerLayout].op_value);
- AfxGetApp()->WriteProfileInt(OPT_SECTION_MpaDec, OPTION_DRC, m_fDRC);
- AfxGetApp()->WriteProfileInt(OPT_SECTION_MpaDec, OPTION_SPDIF_ac3, m_fSPDIF[ac3]);
- AfxGetApp()->WriteProfileInt(OPT_SECTION_MpaDec, OPTION_SPDIF_eac3, m_fSPDIF[eac3]);
- AfxGetApp()->WriteProfileInt(OPT_SECTION_MpaDec, OPTION_SPDIF_truehd, m_fSPDIF[truehd]);
- AfxGetApp()->WriteProfileInt(OPT_SECTION_MpaDec, OPTION_SPDIF_dts, m_fSPDIF[dts]);
- AfxGetApp()->WriteProfileInt(OPT_SECTION_MpaDec, OPTION_SPDIF_dtshd, m_fSPDIF[dtshd]);
-#endif
-
- return S_OK;
-}
-
-// ISpecifyPropertyPages2
-
-STDMETHODIMP CMpaDecFilter::GetPages(CAUUID* pPages)
-{
- CheckPointer(pPages, E_POINTER);
-
- HRESULT hr = S_OK;
-
- pPages->cElems = 1;
- pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID) * pPages->cElems);
- if (pPages->pElems != nullptr) {
- pPages->pElems[0] = __uuidof(CMpaDecSettingsWnd);
- } else {
- hr = E_OUTOFMEMORY;
- }
-
- return hr;
-}
-
-STDMETHODIMP CMpaDecFilter::CreatePage(const GUID& guid, IPropertyPage** ppPage)
-{
- CheckPointer(ppPage, E_POINTER);
-
- if (*ppPage != nullptr) {
- return E_INVALIDARG;
- }
-
- HRESULT hr;
-
- if (guid == __uuidof(CMpaDecSettingsWnd)) {
- (*ppPage = DEBUG_NEW CInternalPropertyPageTempl<CMpaDecSettingsWnd>(nullptr, &hr))->AddRef();
- }
-
- return *ppPage ? S_OK : E_FAIL;
-}
-
-//
-// CMpaDecInputPin
-//
-
-CMpaDecInputPin::CMpaDecInputPin(CTransformFilter* pFilter, HRESULT* phr, LPWSTR pName)
- : CDeCSSInputPin(NAME("CMpaDecInputPin"), pFilter, phr, pName)
-{
-}
diff --git a/src/filters/transform/MpaDecFilter/MpaDecFilter.def b/src/filters/transform/MpaDecFilter/MpaDecFilter.def
deleted file mode 100644
index 6492e5cd6..000000000
--- a/src/filters/transform/MpaDecFilter/MpaDecFilter.def
+++ /dev/null
@@ -1,5 +0,0 @@
-EXPORTS
- DllCanUnloadNow PRIVATE
- DllGetClassObject PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
diff --git a/src/filters/transform/MpaDecFilter/MpaDecFilter.h b/src/filters/transform/MpaDecFilter/MpaDecFilter.h
deleted file mode 100644
index 5a00a3bba..000000000
--- a/src/filters/transform/MpaDecFilter/MpaDecFilter.h
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <atlcoll.h>
-// TODO: remove this when it's fixed in MSVC
-// Work around warning C4005: 'XXXX' : macro redefinition
-#pragma warning(push)
-#pragma warning(disable: 4005)
-#include <stdint.h>
-#pragma warning(pop)
-
-#include "../../../DeCSS/DeCSSInputPin.h"
-#include "IMpaDecFilter.h"
-#include "MpaDecSettingsWnd.h"
-#include "../../../mpc-hc/InternalFiltersConfig.h"
-#include "Mixer.h"
-#include "PaddedArray.h"
-
-#if defined(STANDALONE_FILTER) || HAS_FFMPEG_AUDIO_DECODERS
-#include "FFAudioDecoder.h"
-#endif
-
-#define MPCAudioDecName L"MPC Audio Decoder"
-
-enum {
- SPK_MONO = 0,
- SPK_STEREO,
- SPK_4_0,
- SPK_5_1,
- SPK_7_1
-};
-
-struct ps2_state_t {
- bool sync;
- double a[2], b[2];
- ps2_state_t() {
- reset();
- }
- void reset() {
- sync = false;
- a[0] = a[1] = b[0] = b[1] = 0;
- }
-};
-
-struct DD_stats_t {
-protected:
- int mode;
- unsigned int ac3_frames;
- unsigned int eac3_frames;
-
-public:
- void Reset();
- bool Desired(int type);
-};
-
-class __declspec(uuid("3D446B6F-71DE-4437-BE15-8CE47174340F"))
- CMpaDecFilter
- : public CTransformFilter
- , public IMpaDecFilter
- , public ISpecifyPropertyPages2
-{
-protected:
- // settings
- CCritSec m_csProps;
- bool m_fSampleFmt[sfcount];
- bool m_fMixer;
- int m_iMixerLayout;
- bool m_fDRC;
- bool m_fSPDIF[etcount];
-
- CCritSec m_csReceive;
- CPaddedArray m_buff;
- REFERENCE_TIME m_rtStart;
- bool m_fDiscontinuity;
- bool m_bResync;
-
- // Mixer
- CMixer m_Mixer;
-
- ps2_state_t m_ps2_state;
- DD_stats_t m_DDstats;
-
- BYTE m_hdmibuff[61440];
- int m_hdmicount;
- int m_hdmisize;
- int m_truehd_samplerate;
- int m_truehd_framelength;
-
-#if defined(STANDALONE_FILTER) || HAS_FFMPEG_AUDIO_DECODERS
- CFFAudioDecoder m_FFAudioDec;
-
- HRESULT ProcessFFmpeg(enum AVCodecID nCodecId);
-#endif
-
-#if defined(STANDALONE_FILTER) || INTERNAL_DECODER_LPCM
- HRESULT ProcessLPCM();
- HRESULT ProcessHdmvLPCM(bool bAlignOldBuffer);
-#endif
-#if defined(STANDALONE_FILTER) || INTERNAL_DECODER_AC3
- HRESULT ProcessAC3();
- HRESULT ProcessAC3_SPDIF();
- HRESULT ProcessEAC3_SPDIF();
- HRESULT ProcessTrueHD_SPDIF();
-#endif
-#if defined(STANDALONE_FILTER) || INTERNAL_DECODER_DTS
- HRESULT ProcessDTS_SPDIF();
-#endif
-#if defined(STANDALONE_FILTER) || INTERNAL_DECODER_PS2AUDIO
- HRESULT ProcessPS2PCM();
- HRESULT ProcessPS2ADPCM();
-#endif
-#if defined(STANDALONE_FILTER) || INTERNAL_DECODER_PCM
- HRESULT ProcessPCMraw();
- HRESULT ProcessPCMintBE();
- HRESULT ProcessPCMintLE();
- HRESULT ProcessPCMfloatBE();
- HRESULT ProcessPCMfloatLE();
-#endif
-
- HRESULT GetDeliveryBuffer(IMediaSample** pSample, BYTE** pData);
- HRESULT Deliver(BYTE* pBuff, int size, AVSampleFormat avsf, DWORD nSamplesPerSec, WORD nChannels, DWORD dwChannelMask = 0);
- HRESULT DeliverBitstream(BYTE* pBuff, int size, WORD type, int sample_rate, int frame_length);
- HRESULT ReconnectOutput(int nSamples, CMediaType& mt);
- CMediaType CreateMediaType(MPCSampleFormat sf, DWORD nSamplesPerSec, WORD nChannels, DWORD dwChannelMask = 0);
- CMediaType CreateMediaTypeSPDIF(DWORD nSamplesPerSec = 48000);
- CMediaType CreateMediaTypeHDMI(WORD type);
-
-public:
- CMpaDecFilter(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CMpaDecFilter();
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- HRESULT EndOfStream();
- HRESULT BeginFlush();
- HRESULT EndFlush();
- HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
- HRESULT Receive(IMediaSample* pIn);
-
- HRESULT CheckInputType(const CMediaType* mtIn);
- HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
- HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT GetMediaType(int iPosition, CMediaType* pMediaType);
-
- HRESULT StartStreaming();
- HRESULT StopStreaming();
-
- HRESULT SetMediaType(PIN_DIRECTION dir, const CMediaType* pmt);
-
- // ISpecifyPropertyPages2
-
- STDMETHODIMP GetPages(CAUUID* pPages);
- STDMETHODIMP CreatePage(const GUID& guid, IPropertyPage** ppPage);
-
- // IMpaDecFilter
-
- STDMETHODIMP SetSampleFormat(MPCSampleFormat sf, bool enable);
- STDMETHODIMP_(bool) GetSampleFormat(MPCSampleFormat sf);
- STDMETHODIMP_(MPCSampleFormat) SelectSampleFormat(MPCSampleFormat sf);
- STDMETHODIMP SetMixer(bool fMixer);
- STDMETHODIMP_(bool) GetMixer();
- STDMETHODIMP SetMixerLayout(int sc);
- STDMETHODIMP_(int) GetMixerLayout();
- STDMETHODIMP SetDynamicRangeControl(bool fDRC);
- STDMETHODIMP_(bool) GetDynamicRangeControl();
- STDMETHODIMP SetSPDIF(enctype et, bool fSPDIF);
- STDMETHODIMP_(bool) GetSPDIF(enctype et);
-
- STDMETHODIMP SaveSettings();
-};
-
-class CMpaDecInputPin : public CDeCSSInputPin
-{
-public:
- CMpaDecInputPin(CTransformFilter* pFilter, HRESULT* phr, LPWSTR pName);
-};
diff --git a/src/filters/transform/MpaDecFilter/MpaDecFilter.rc b/src/filters/transform/MpaDecFilter/MpaDecFilter.rc
deleted file mode 100644
index fc719f710..000000000
--- a/src/filters/transform/MpaDecFilter/MpaDecFilter.rc
+++ /dev/null
@@ -1,120 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-#include "version.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (United States) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION MPC_VERSION_NUM
- PRODUCTVERSION MPC_VERSION_NUM
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS VOS_NT_WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE VFT2_UNKNOWN
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", MPC_VERSION_COMMENTS
- VALUE "CompanyName", MPC_COMP_NAME_STR
- VALUE "FileDescription", "Mpeg Audio Decoder for DirectShow"
- VALUE "FileVersion", MPC_VERSION_STR_FULL
- VALUE "InternalName", "MpaDecFilter Filter"
- VALUE "LegalCopyright", MPC_COPYRIGHT_STR
- VALUE "OriginalFilename", "MpaDecFilter.ax"
- VALUE "ProductName", "MpaDecFilter Filter"
- VALUE "ProductVersion", MPC_VERSION_STR_FULL
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// String Table
-//
-
-STRINGTABLE
-BEGIN
- IDS_FILTER_SETTINGS_CAPTION "Settings"
- IDS_MPADEC_SAMPLE_FMT "Output sample format:"
- IDS_MPADEC_DRC "Apply DRC for AC-3 and E-AC3"
- IDS_MPADEC_MIXER "Mixer"
- IDS_MPADEC_MIX_SPEAKERS "Output speakers:"
- IDS_MPADEC_MONO "Mono"
- IDS_MPADEC_STEREO "Stereo"
- IDS_MPADEC_SPDIF "Pass-through (S/PDIF, HDMI)"
-END
-
-#endif // English (United States) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/src/filters/transform/MpaDecFilter/MpaDecFilter.vcxproj b/src/filters/transform/MpaDecFilter/MpaDecFilter.vcxproj
deleted file mode 100644
index bfcce3bdc..000000000
--- a/src/filters/transform/MpaDecFilter/MpaDecFilter.vcxproj
+++ /dev/null
@@ -1,274 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug Filter|Win32">
- <Configuration>Debug Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug Filter|x64">
- <Configuration>Debug Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|Win32">
- <Configuration>Release Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|x64">
- <Configuration>Release Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{4421516D-10A6-41C1-ADF3-099573BBB0C6}</ProjectGuid>
- <RootNamespace>MpaDecFilter</RootNamespace>
- <Keyword>MFCProj</Keyword>
- <ProjectName>MpaDecFilter</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <Import Project="..\..\..\platform.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">.ax</TargetExt>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\ffmpeg;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>libgcc.a;libmingwex.a;Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(SolutionDir)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <ModuleDefinitionFile>MpaDecFilter.def</ModuleDefinitionFile>
- <ImageHasSafeExceptionHandlers Condition="'$(PlatformToolsetVersion)'=='110'">false</ImageHasSafeExceptionHandlers>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\ffmpeg;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>libgcc.a;libmingwex.a;Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(SolutionDir)lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <ModuleDefinitionFile>MpaDecFilter.def</ModuleDefinitionFile>
- <ImageHasSafeExceptionHandlers Condition="'$(PlatformToolsetVersion)'=='110'">false</ImageHasSafeExceptionHandlers>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\ffmpeg;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>libgcc.a;libmingwex.a;Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(SolutionDir)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <ModuleDefinitionFile>MpaDecFilter.def</ModuleDefinitionFile>
- <ImageHasSafeExceptionHandlers Condition="'$(PlatformToolsetVersion)'=='110'">false</ImageHasSafeExceptionHandlers>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\ffmpeg;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>libgcc.a;libmingwex.a;Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(SolutionDir)lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <ModuleDefinitionFile>MpaDecFilter.def</ModuleDefinitionFile>
- <ImageHasSafeExceptionHandlers Condition="'$(PlatformToolsetVersion)'=='110'">false</ImageHasSafeExceptionHandlers>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\ffmpeg;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\ffmpeg;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\ffmpeg;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\ffmpeg;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="AudioHelper.cpp" />
- <ClCompile Include="FFAudioDecoder.cpp" />
- <ClCompile Include="Mixer.cpp" />
- <ClCompile Include="MpaDecFilter.cpp" />
- <ClCompile Include="MpaDecSettingsWnd.cpp" />
- <ClCompile Include="stdafx.cpp">
- <PrecompiledHeader>Create</PrecompiledHeader>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="AudioHelper.h" />
- <ClInclude Include="PaddedArray.h" />
- <ClInclude Include="FFAudioDecoder.h" />
- <ClInclude Include="IMpaDecFilter.h" />
- <ClInclude Include="Mixer.h" />
- <ClInclude Include="MpaDecFilter.h" />
- <ClInclude Include="MpaDecSettingsWnd.h" />
- <ClInclude Include="resource.h">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ClInclude>
- <ClInclude Include="stdafx.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="MpaDecFilter.rc">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ResourceCompile>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\DeCSS\DeCSS.vcxproj">
- <Project>{1a2dfd1a-3c6c-44d1-909d-294af646b575}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\DSUtil\DSUtil.vcxproj">
- <Project>{fc70988b-1ae5-4381-866d-4f405e28ac42}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\Kasumi\Kasumi.vcxproj">
- <Project>{0d252872-7542-4232-8d02-53f9182aee15}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\system\system.vcxproj">
- <Project>{c2082189-3ecb-4079-91fa-89d3c8a305c0}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\zlib\zlib.vcxproj">
- <Project>{2fcd4b66-9cf9-4c8f-bc70-37cd20002d49}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\BaseClasses\BaseClasses.vcxproj">
- <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\Filters.vcxproj">
- <Project>{273b3149-3192-4b75-a791-470320b90812}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\ffmpeg\ffmpeg.vcxproj">
- <Project>{438286b7-a9f4-411d-bcc5-948c40e37d8f}</Project>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/transform/MpaDecFilter/MpaDecFilter.vcxproj.filters b/src/filters/transform/MpaDecFilter/MpaDecFilter.vcxproj.filters
deleted file mode 100644
index f79854e86..000000000
--- a/src/filters/transform/MpaDecFilter/MpaDecFilter.vcxproj.filters
+++ /dev/null
@@ -1,80 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{80757c1e-90e1-4636-bff8-170995c5ce51}</UniqueIdentifier>
- <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{17770671-53fc-494b-b198-c896cd3fa62f}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{9ecf2a6c-f5ed-4677-945a-5246bc5443ec}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="MpaDecFilter.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="MpaDecSettingsWnd.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="stdafx.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="Mixer.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="FFAudioDecoder.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="AudioHelper.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="IMpaDecFilter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="MpaDecFilter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="MpaDecSettingsWnd.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="resource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="stdafx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="Mixer.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="FFAudioDecoder.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="PaddedArray.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="AudioHelper.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="MpaDecFilter.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.cpp b/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.cpp
deleted file mode 100644
index 41168de9a..000000000
--- a/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.cpp
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "resource.h"
-#include "MpaDecSettingsWnd.h"
-#include "../../../DSUtil/DSUtil.h"
-
-
-//
-// CMpaDecSettingsWnd
-//
-
-CMpaDecSettingsWnd::CMpaDecSettingsWnd()
-{
-}
-
-bool CMpaDecSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
-{
- ASSERT(!m_pMDF);
-
- m_pMDF.Release();
-
- POSITION pos = pUnks.GetHeadPosition();
- while (pos && !(m_pMDF = pUnks.GetNext(pos))) {
- ;
- }
-
- if (!m_pMDF) {
- return false;
- }
-
- m_outfmt_i16 = m_pMDF->GetSampleFormat(SF_PCM16);
- m_outfmt_i24 = m_pMDF->GetSampleFormat(SF_PCM24);
- m_outfmt_i32 = m_pMDF->GetSampleFormat(SF_PCM32);
- m_outfmt_flt = m_pMDF->GetSampleFormat(SF_FLOAT);
- m_mixer = m_pMDF->GetMixer();
- m_mixer_layout = m_pMDF->GetMixerLayout();
- m_drc = m_pMDF->GetDynamicRangeControl();
- m_spdif_ac3 = m_pMDF->GetSPDIF(IMpaDecFilter::ac3);
- m_spdif_eac3 = m_pMDF->GetSPDIF(IMpaDecFilter::eac3);
- m_spdif_truehd = m_pMDF->GetSPDIF(IMpaDecFilter::truehd);
- m_spdif_dts = m_pMDF->GetSPDIF(IMpaDecFilter::dts);
- m_spdif_dtshd = m_pMDF->GetSPDIF(IMpaDecFilter::dtshd);
-
- return true;
-}
-
-void CMpaDecSettingsWnd::OnDisconnect()
-{
- m_pMDF.Release();
-}
-
-bool CMpaDecSettingsWnd::OnActivate()
-{
- ASSERT(IPP_FONTSIZE == 13);
- const int h20 = IPP_SCALE(20);
- const int h25 = IPP_SCALE(25);
- const int h30 = IPP_SCALE(30);
- DWORD dwStyle = WS_VISIBLE | WS_CHILD | WS_TABSTOP;
- CPoint p(10, 10);
- CRect r;
-
- m_outfmt_group.Create(ResStr(IDS_MPADEC_SAMPLE_FMT), WS_VISIBLE | WS_CHILD | BS_GROUPBOX, CRect(p + CPoint(-5, 0), CSize(IPP_SCALE(215), h20 + h20)), this, (UINT)IDC_STATIC);
- p.y += h20;
- m_outfmt_i16_check.Create(_T("Int16"), dwStyle | BS_AUTOCHECKBOX, CRect(p, CSize(IPP_SCALE(45), m_fontheight)), this, IDC_PP_CHECK_I16);
- m_outfmt_i24_check.Create(_T("Int24"), dwStyle | BS_AUTOCHECKBOX, CRect(p + CPoint(IPP_SCALE(50), 0), CSize(IPP_SCALE(45), m_fontheight)), this, IDC_PP_CHECK_I24);
- m_outfmt_i32_check.Create(_T("Int32"), dwStyle | BS_AUTOCHECKBOX, CRect(p + CPoint(IPP_SCALE(100), 0), CSize(IPP_SCALE(45), m_fontheight)), this, IDC_PP_CHECK_I32);
- m_outfmt_flt_check.Create(_T("Float"), dwStyle | BS_AUTOCHECKBOX, CRect(p + CPoint(IPP_SCALE(150), 0), CSize(IPP_SCALE(45), m_fontheight)), this, IDC_PP_CHECK_FLT);
- m_outfmt_i16_check.SetCheck(m_outfmt_i16);
- m_outfmt_i24_check.SetCheck(m_outfmt_i24);
- m_outfmt_i32_check.SetCheck(m_outfmt_i32);
- m_outfmt_flt_check.SetCheck(m_outfmt_flt);
- p.y += h25;
-
- m_drc_check.Create(ResStr(IDS_MPADEC_DRC), dwStyle | BS_AUTOCHECKBOX, CRect(p, CSize(IPP_SCALE(205), m_fontheight)), this, IDC_PP_CHECK_DRC);
- m_drc_check.SetCheck(m_drc);
- p.y += h25;
-
- m_mixer_group.Create(_T(""), WS_VISIBLE | WS_CHILD | BS_GROUPBOX, CRect(p + CPoint(-5, 0), CSize(IPP_SCALE(215), h20 + h25)), this, (UINT)IDC_STATIC);
- m_mixer_check.Create(ResStr(IDS_MPADEC_MIXER), dwStyle | BS_AUTOCHECKBOX, CRect(p, CSize(IPP_SCALE(60), m_fontheight)), this, IDC_PP_CHECK_MIXER);
- m_mixer_check.SetCheck(m_mixer);
- p.y += h20;
- m_mixer_layout_static.Create(ResStr(IDS_MPADEC_MIX_SPEAKERS), WS_VISIBLE | WS_CHILD, CRect(p, CSize(IPP_SCALE(120), m_fontheight)), this);
- m_mixer_layout_combo.Create(dwStyle | CBS_DROPDOWNLIST, CRect(p + CPoint(IPP_SCALE(125), -4), CSize(IPP_SCALE(80), 200)), this, IDC_PP_COMBO_MIXLAYOUT);
- m_mixer_layout_combo.SetItemData(m_mixer_layout_combo.AddString(ResStr(IDS_MPADEC_MONO)), SPK_MONO);
- m_mixer_layout_combo.SetItemData(m_mixer_layout_combo.AddString(ResStr(IDS_MPADEC_STEREO)), SPK_STEREO);
- m_mixer_layout_combo.SetItemData(m_mixer_layout_combo.AddString(_T("4.0")), SPK_4_0);
- m_mixer_layout_combo.SetItemData(m_mixer_layout_combo.AddString(_T("5.1")), SPK_5_1);
- m_mixer_layout_combo.SetItemData(m_mixer_layout_combo.AddString(_T("7.1")), SPK_7_1);
- for (int i = 0; i < m_mixer_layout_combo.GetCount(); i++) {
- if ((int)m_mixer_layout_combo.GetItemData(i) == m_mixer_layout) {
- m_mixer_layout_combo.SetCurSel(i);
- break;
- }
- }
- m_mixer_layout_combo.GetWindowRect(r);
- ScreenToClient(r);
- p.y += h30;
-
- m_spdif_group.Create(ResStr(IDS_MPADEC_SPDIF), WS_VISIBLE | WS_CHILD | BS_GROUPBOX, CRect(p + CPoint(-5, 0), CSize(IPP_SCALE(215), h20 + h20 * 3)), this, (UINT)IDC_STATIC);
- p.y += h20;
- m_spdif_ac3_check.Create(_T("AC-3"), dwStyle | BS_AUTOCHECKBOX, CRect(p, CSize(IPP_SCALE(45), m_fontheight)), this, IDC_PP_CHECK_SPDIF_AC3);
- m_spdif_dts_check.Create(_T("DTS"), dwStyle | BS_AUTOCHECKBOX, CRect(p + CPoint(IPP_SCALE(100), 0), CSize(IPP_SCALE(45), m_fontheight)), this, IDC_PP_CHECK_SPDIF_DTS);
- p.y += h20;
- m_spdif_eac3_check.Create(_T("E-AC3"), dwStyle | BS_AUTOCHECKBOX, CRect(p, CSize(IPP_SCALE(50), m_fontheight)), this, IDC_PP_CHECK_SPDIF_EAC3);
- m_spdif_dtshd_check.Create(_T("DTS-HD"), dwStyle | BS_AUTOCHECKBOX, CRect(p + CPoint(IPP_SCALE(100), 0), CSize(IPP_SCALE(60), m_fontheight)), this, IDC_PP_CHECK_SPDIF_DTSHD);
- p.y += h20;
- m_spdif_truehd_check.Create(_T("TrueHD"), dwStyle | BS_AUTOCHECKBOX, CRect(p, CSize(IPP_SCALE(55), m_fontheight)), this, IDC_PP_CHECK_SPDIF_TRUEHD);
- m_spdif_ac3_check.SetCheck(m_spdif_ac3);
- m_spdif_eac3_check.SetCheck(m_spdif_eac3);
- m_spdif_truehd_check.SetCheck(m_spdif_truehd);
- m_spdif_dts_check.SetCheck(m_spdif_dts);
- m_spdif_dtshd_check.SetCheck(m_spdif_dtshd);
- OnDTSCheck();
-
- for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
- pWnd->SetFont(&m_font, FALSE);
- }
-
- return true;
-}
-
-void CMpaDecSettingsWnd::OnDeactivate()
-{
- m_outfmt_i16 = !!m_outfmt_i16_check.GetCheck();
- m_outfmt_i24 = !!m_outfmt_i24_check.GetCheck();
- m_outfmt_i32 = !!m_outfmt_i32_check.GetCheck();
- m_outfmt_flt = !!m_outfmt_flt_check.GetCheck();
- m_mixer = !!m_mixer_check.GetCheck();
- m_mixer_layout = (int)m_mixer_layout_combo.GetItemData(m_mixer_layout_combo.GetCurSel());
- m_drc = !!m_drc_check.GetCheck();
- m_spdif_ac3 = !!m_spdif_ac3_check.GetCheck();
- m_spdif_eac3 = !!m_spdif_eac3_check.GetCheck();
- m_spdif_truehd = !!m_spdif_truehd_check.GetCheck();
- m_spdif_dts = !!m_spdif_dts_check.GetCheck();
- m_spdif_dtshd = !!m_spdif_dtshd_check.GetCheck();
-}
-
-bool CMpaDecSettingsWnd::OnApply()
-{
- OnDeactivate();
-
- if (m_pMDF) {
- m_pMDF->SetSampleFormat(SF_PCM16, m_outfmt_i16);
- m_pMDF->SetSampleFormat(SF_PCM24, m_outfmt_i24);
- m_pMDF->SetSampleFormat(SF_PCM32, m_outfmt_i32);
- m_pMDF->SetSampleFormat(SF_FLOAT, m_outfmt_flt);
- m_pMDF->SetMixer(m_mixer);
- m_pMDF->SetMixerLayout(m_mixer_layout);
- m_pMDF->SetDynamicRangeControl(m_drc);
- m_pMDF->SetSPDIF(IMpaDecFilter::ac3, m_spdif_ac3);
- m_pMDF->SetSPDIF(IMpaDecFilter::eac3, m_spdif_eac3);
- m_pMDF->SetSPDIF(IMpaDecFilter::truehd, m_spdif_truehd);
- m_pMDF->SetSPDIF(IMpaDecFilter::dts, m_spdif_dts);
- m_pMDF->SetSPDIF(IMpaDecFilter::dtshd, m_spdif_dtshd);
-
- m_pMDF->SaveSettings();
- }
-
- return true;
-}
-
-BEGIN_MESSAGE_MAP(CMpaDecSettingsWnd, CInternalPropertyPageWnd)
- ON_BN_CLICKED(IDC_PP_CHECK_I16, OnInt16Check)
- ON_BN_CLICKED(IDC_PP_CHECK_I24, OnInt24Check)
- ON_BN_CLICKED(IDC_PP_CHECK_I32, OnInt32Check)
- ON_BN_CLICKED(IDC_PP_CHECK_FLT, OnFloatCheck)
- ON_BN_CLICKED(IDC_PP_CHECK_SPDIF_DTS, OnDTSCheck)
-END_MESSAGE_MAP()
-
-void CMpaDecSettingsWnd::OnInt16Check()
-{
- if (m_outfmt_i16_check.GetCheck() == BST_UNCHECKED &&
- m_outfmt_i24_check.GetCheck() == BST_UNCHECKED &&
- m_outfmt_i32_check.GetCheck() == BST_UNCHECKED &&
- m_outfmt_flt_check.GetCheck() == BST_UNCHECKED) {
- m_outfmt_i16_check.SetCheck(BST_CHECKED);
- }
-}
-
-void CMpaDecSettingsWnd::OnInt24Check()
-{
- if (m_outfmt_i16_check.GetCheck() == BST_UNCHECKED &&
- m_outfmt_i24_check.GetCheck() == BST_UNCHECKED &&
- m_outfmt_i32_check.GetCheck() == BST_UNCHECKED &&
- m_outfmt_flt_check.GetCheck() == BST_UNCHECKED) {
- m_outfmt_i24_check.SetCheck(BST_CHECKED);
- }
-}
-
-void CMpaDecSettingsWnd::OnInt32Check()
-{
- if (m_outfmt_i16_check.GetCheck() == BST_UNCHECKED &&
- m_outfmt_i24_check.GetCheck() == BST_UNCHECKED &&
- m_outfmt_i32_check.GetCheck() == BST_UNCHECKED &&
- m_outfmt_flt_check.GetCheck() == BST_UNCHECKED) {
- m_outfmt_i32_check.SetCheck(BST_CHECKED);
- }
-}
-
-void CMpaDecSettingsWnd::OnFloatCheck()
-{
- if (m_outfmt_i16_check.GetCheck() == BST_UNCHECKED &&
- m_outfmt_i24_check.GetCheck() == BST_UNCHECKED &&
- m_outfmt_i32_check.GetCheck() == BST_UNCHECKED &&
- m_outfmt_flt_check.GetCheck() == BST_UNCHECKED) {
- m_outfmt_flt_check.SetCheck(BST_CHECKED);
- }
-}
-
-void CMpaDecSettingsWnd::OnDTSCheck()
-{
- m_spdif_dtshd_check.EnableWindow(!!m_spdif_dts_check.GetCheck());
-}
diff --git a/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.h b/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.h
deleted file mode 100644
index 1b8e044e9..000000000
--- a/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../InternalPropertyPage.h"
-#include "MpaDecFilter.h"
-#include "resource.h"
-#include <afxcmn.h>
-
-class __declspec(uuid("24103041-884B-4772-B0D3-A600E7CBFEC7"))
- CMpaDecSettingsWnd : public CInternalPropertyPageWnd
-{
- CComQIPtr<IMpaDecFilter> m_pMDF;
-
- bool m_outfmt_i16;
- bool m_outfmt_i24;
- bool m_outfmt_i32;
- bool m_outfmt_flt;
- bool m_mixer;
- int m_mixer_layout;
- bool m_drc;
- bool m_spdif_ac3;
- bool m_spdif_eac3;
- bool m_spdif_truehd;
- bool m_spdif_dts;
- bool m_spdif_dtshd;
-
- enum {
- IDC_PP_COMBO_MIXLAYOUT = 10000,
- IDC_PP_CHECK_I16,
- IDC_PP_CHECK_I24,
- IDC_PP_CHECK_I32,
- IDC_PP_CHECK_FLT,
- IDC_PP_CHECK_MIXER,
- IDC_PP_CHECK_DRC,
- IDC_PP_CHECK_SPDIF_AC3,
- IDC_PP_CHECK_SPDIF_EAC3,
- IDC_PP_CHECK_SPDIF_TRUEHD,
- IDC_PP_CHECK_SPDIF_DTS,
- IDC_PP_CHECK_SPDIF_DTSHD
- };
-
- CButton m_outfmt_group;
- CButton m_outfmt_i16_check;
- CButton m_outfmt_i24_check;
- CButton m_outfmt_i32_check;
- CButton m_outfmt_flt_check;
-
- CButton m_mixer_group;
- CButton m_mixer_check;
- CStatic m_mixer_layout_static;
- CComboBox m_mixer_layout_combo;
-
- CButton m_drc_check;
-
- CButton m_spdif_group;
- CButton m_spdif_ac3_check;
- CButton m_spdif_eac3_check;
- CButton m_spdif_truehd_check;
- CButton m_spdif_dts_check;
- CButton m_spdif_dtshd_check;
-
-public:
- CMpaDecSettingsWnd();
-
- bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
- void OnDisconnect();
- bool OnActivate();
- void OnDeactivate();
- bool OnApply();
-
- static LPCTSTR GetWindowTitle() { return MAKEINTRESOURCE(IDS_FILTER_SETTINGS_CAPTION); }
- static CSize GetWindowSize() { return CSize(225, 220); }
-
- DECLARE_MESSAGE_MAP()
-
- afx_msg void OnInt16Check();
- afx_msg void OnInt24Check();
- afx_msg void OnInt32Check();
- afx_msg void OnFloatCheck();
- afx_msg void OnDTSCheck();
-};
diff --git a/src/filters/transform/MpaDecFilter/PaddedArray.h b/src/filters/transform/MpaDecFilter/PaddedArray.h
deleted file mode 100644
index 2cf2257e0..000000000
--- a/src/filters/transform/MpaDecFilter/PaddedArray.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * (C) 2012-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <atlcoll.h>
-
-class CPaddedArray : public CAtlArray<BYTE>
-{
-protected:
- size_t m_padsize;
-
-public:
- CPaddedArray(size_t padsize)
- : m_padsize(padsize) {
- }
-
- size_t GetCount() {
- size_t count = __super::GetCount();
- return (count > m_padsize) ? count - m_padsize : 0;
- }
-
- bool SetCount(size_t nNewSize, int nGrowBy = - 1) {
- if (__super::SetCount(nNewSize + m_padsize, nGrowBy)) {
- ZeroMemory(GetData() + nNewSize, m_padsize);
- return true;
- }
- return false;
- }
-};
diff --git a/src/filters/transform/MpaDecFilter/resource.h b/src/filters/transform/MpaDecFilter/resource.h
deleted file mode 100644
index 32846d60b..000000000
--- a/src/filters/transform/MpaDecFilter/resource.h
+++ /dev/null
@@ -1,23 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by MpaDecFilter.rc
-//
-#define IDS_FILTER_SETTINGS_CAPTION 7000
-#define IDS_MPADEC_SAMPLE_FMT 7300
-#define IDS_MPADEC_DRC 7301
-#define IDS_MPADEC_MIXER 7302
-#define IDS_MPADEC_MIX_SPEAKERS 7303
-#define IDS_MPADEC_MONO 7304
-#define IDS_MPADEC_STEREO 7305
-#define IDS_MPADEC_SPDIF 7306
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 102
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/filters/transform/MpaDecFilter/stdafx.cpp b/src/filters/transform/MpaDecFilter/stdafx.cpp
deleted file mode 100644
index 784f2cebc..000000000
--- a/src/filters/transform/MpaDecFilter/stdafx.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
diff --git a/src/filters/transform/MpaDecFilter/stdafx.h b/src/filters/transform/MpaDecFilter/stdafx.h
deleted file mode 100644
index 5b6b09e05..000000000
--- a/src/filters/transform/MpaDecFilter/stdafx.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../../DSUtil/SharedInclude.h"
-#include "../../../../include/stdafx_common.h"
-#include "../../../../include/stdafx_common_afx.h"
-#include "../../../../include/stdafx_common_dshow.h"
diff --git a/src/filters/transform/Mpeg2DecFilter/IMpeg2DecFilter.h b/src/filters/transform/Mpeg2DecFilter/IMpeg2DecFilter.h
deleted file mode 100644
index 04580c72c..000000000
--- a/src/filters/transform/Mpeg2DecFilter/IMpeg2DecFilter.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-typedef enum {
- DIAuto,
- DIWeave,
- DIBlend,
- DIBob,
- DIFieldShift,
- DIELA
-} ditype;
-
-interface __declspec(uuid("0ABEAA65-0317-47B9-AE1D-D9EA905AFD25"))
-IMpeg2DecFilter :
-public IUnknown {
- STDMETHOD(SetDeinterlaceMethod(ditype di)) PURE;
- STDMETHOD_(ditype, GetDeinterlaceMethod()) PURE;
- // Brightness: -255.0 to 255.0, default 0.0
- // Contrast: 0.0 to 10.0, default 1.0
- // Hue: -180.0 to +180.0, default 0.0
- // Saturation: 0.0 to 10.0, default 1.0
-
- STDMETHOD(SetBrightness(float brightness)) PURE;
- STDMETHOD(SetContrast(float contrast)) PURE;
- STDMETHOD(SetHue(float hue)) PURE;
- STDMETHOD(SetSaturation(float saturation)) PURE;
- STDMETHOD_(float, GetBrightness()) PURE;
- STDMETHOD_(float, GetContrast()) PURE;
- STDMETHOD_(float, GetHue()) PURE;
- STDMETHOD_(float, GetSaturation()) PURE;
-
- STDMETHOD(EnableForcedSubtitles(bool fEnable)) PURE;
- STDMETHOD_(bool, IsForcedSubtitlesEnabled()) PURE;
-
- STDMETHOD(EnablePlanarYUV(bool fEnable)) PURE;
- STDMETHOD_(bool, IsPlanarYUVEnabled()) PURE;
-
- STDMETHOD(EnableInterlaced(bool fEnable)) PURE;
- STDMETHOD_(bool, IsInterlacedEnabled()) PURE;
-
- STDMETHOD(EnableReadARFromStream(bool fEnable)) PURE;
- STDMETHOD_(bool, IsReadARFromStreamEnabled()) PURE;
-
- STDMETHOD(Apply()) PURE;
-};
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp
deleted file mode 100644
index c072f9078..000000000
--- a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp
+++ /dev/null
@@ -1,2439 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <math.h>
-#include <atlbase.h>
-#include <ks.h>
-#include <ksmedia.h>
-#include "libmpeg2.h"
-#include "Mpeg2DecFilter.h"
-
-#include <xmmintrin.h>
-#include <emmintrin.h>
-
-#include "../../../DSUtil/DSUtil.h"
-#include "../../../DSUtil/MediaTypes.h"
-#include "../../../DSUtil/GolombBuffer.h"
-
-#ifdef STANDALONE_FILTER
-#include <InitGuid.h>
-#endif
-#include "moreuuids.h"
-#include "IFilterVersion.h"
-#include "detours/detours.h"
-
-#define EPSILON 1e-4
-
-#ifdef STANDALONE_FILTER
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
- {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_MPEG2_VIDEO},
- {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_MPEG2_VIDEO},
- {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_MPEG2_VIDEO},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_MPEG2_VIDEO},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_MPG2},
-#ifndef MPEG2ONLY
- {&MEDIATYPE_Video, &MEDIASUBTYPE_MPEG1Packet},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_MPEG1Payload},
-#endif
-};
-
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
- {&MEDIATYPE_Video, &MEDIASUBTYPE_IYUV},
-};
-
-const AMOVIESETUP_PIN sudpPins[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesIn), sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, _countof(sudPinTypesOut), sudPinTypesOut}
-};
-
-const AMOVIESETUP_FILTER sudFilter[] = {
- {&__uuidof(CMpeg2DecFilter), Mpeg2DecFilterName, 0x00600001, _countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
-};
-
-CFactoryTemplate g_Templates[] = {
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMpeg2DecFilter>, nullptr, &sudFilter[0]},
- {L"CMpeg2DecPropertyPage", &__uuidof(CMpeg2DecSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CMpeg2DecSettingsWnd>>},
-};
-
-int g_cTemplates = _countof(g_Templates);
-
-STDAPI DllRegisterServer()
-{
- return AMovieDllRegisterServer2(TRUE);
-}
-
-STDAPI DllUnregisterServer()
-{
- return AMovieDllRegisterServer2(FALSE);
-}
-
-//
-
-BOOL (__stdcall* Real_IsDebuggerPresent)()
- = IsDebuggerPresent;
-
-LONG(__stdcall* Real_ChangeDisplaySettingsExA)(LPCSTR a0,
- LPDEVMODEA a1,
- HWND a2,
- DWORD a3,
- LPVOID a4)
- = ChangeDisplaySettingsExA;
-
-LONG(__stdcall* Real_ChangeDisplaySettingsExW)(LPCWSTR a0,
- LPDEVMODEW a1,
- HWND a2,
- DWORD a3,
- LPVOID a4)
- = ChangeDisplaySettingsExW;
-
-
-BOOL WINAPI Mine_IsDebuggerPresent()
-{
- TRACE(_T("Oops, somebody was trying to be naughty! (called IsDebuggerPresent)\n"));
- return FALSE;
-}
-
-LONG WINAPI Mine_ChangeDisplaySettingsEx(LONG ret, DWORD dwFlags, LPVOID lParam)
-{
- if (dwFlags & CDS_VIDEOPARAMETERS) {
- VIDEOPARAMETERS* vp = (VIDEOPARAMETERS*)lParam;
-
- if (vp->Guid == GUIDFromCString(_T("{02C62061-1097-11d1-920F-00A024DF156E}"))
- && (vp->dwFlags & VP_FLAGS_COPYPROTECT)) {
- if (vp->dwCommand == VP_COMMAND_GET) {
- if ((vp->dwTVStandard & VP_TV_STANDARD_WIN_VGA) && vp->dwTVStandard != VP_TV_STANDARD_WIN_VGA) {
- TRACE(_T("Ooops, tv-out enabled? macrovision checks suck...\n"));
- vp->dwTVStandard = VP_TV_STANDARD_WIN_VGA;
- }
- } else if (vp->dwCommand == VP_COMMAND_SET) {
- TRACE(_T("Ooops, as I already told ya, no need for any macrovision bs here\n"));
- return 0;
- }
- }
- }
-
- return ret;
-}
-LONG WINAPI Mine_ChangeDisplaySettingsExA(LPCSTR lpszDeviceName, LPDEVMODEA lpDevMode, HWND hwnd, DWORD dwFlags, LPVOID lParam)
-{
- return Mine_ChangeDisplaySettingsEx(Real_ChangeDisplaySettingsExA(lpszDeviceName, lpDevMode, hwnd, dwFlags, lParam), dwFlags, lParam);
-}
-LONG WINAPI Mine_ChangeDisplaySettingsExW(LPCWSTR lpszDeviceName, LPDEVMODEW lpDevMode, HWND hwnd, DWORD dwFlags, LPVOID lParam)
-{
- return Mine_ChangeDisplaySettingsEx(Real_ChangeDisplaySettingsExW(lpszDeviceName, lpDevMode, hwnd, dwFlags, lParam), dwFlags, lParam);
-}
-
-//
-
-#include "../../FilterApp.h"
-
-class CMpeg2DecFilterApp : public CFilterApp
-{
-public:
- BOOL InitInstance() {
- long lError;
-
- if (!__super::InitInstance()) {
- return FALSE;
- }
-
- DetourRestoreAfterWith();
- DetourTransactionBegin();
- DetourUpdateThread(GetCurrentThread());
-
- DetourAttach(&(PVOID&)Real_IsDebuggerPresent, (PVOID)Mine_IsDebuggerPresent);
- DetourAttach(&(PVOID&)Real_ChangeDisplaySettingsExA, (PVOID)Mine_ChangeDisplaySettingsExA);
- DetourAttach(&(PVOID&)Real_ChangeDisplaySettingsExW, (PVOID)Mine_ChangeDisplaySettingsExW);
-
- lError = DetourTransactionCommit();
- ASSERT(lError == NOERROR);
-
- return TRUE;
- }
-};
-
-CMpeg2DecFilterApp theApp;
-
-#endif
-
-//
-// CMpeg2DecFilter
-//
-
-CMpeg2DecFilter::CMpeg2DecFilter(LPUNKNOWN lpunk, HRESULT* phr)
- : CBaseVideoFilter(NAME("CMpeg2DecFilter"), lpunk, phr, __uuidof(this), 1)
- , m_fWaitForKeyFrame(true)
- , m_fInitializedBuffer(true)
-{
- delete m_pInput;
- // delete m_pOutput;
-
- if (FAILED(*phr)) {
- return;
- }
-
- m_pInput = DEBUG_NEW CMpeg2DecInputPin(this, phr, L"Video");
- if (!m_pInput) {
- *phr = E_OUTOFMEMORY;
- }
- if (FAILED(*phr)) {
- return;
- }
-
- // m_pOutput = DEBUG_NEW CMpeg2DecOutputPin(this, phr, L"Output");
- // if (!m_pOutput) *phr = E_OUTOFMEMORY;
- // if (FAILED(*phr)) return;
-
- m_pSubpicInput = DEBUG_NEW CSubpicInputPin(this, phr);
- if (!m_pSubpicInput) {
- *phr = E_OUTOFMEMORY;
- }
- if (FAILED(*phr)) {
- return;
- }
-
- m_pClosedCaptionOutput = DEBUG_NEW CClosedCaptionOutputPin(this, m_pLock, phr);
- if (!m_pClosedCaptionOutput) {
- *phr = E_OUTOFMEMORY;
- }
- if (FAILED(*phr)) {
- return;
- }
-
- SetDeinterlaceMethod(DIAuto);
- SetBrightness(0.0f);
- SetContrast(1.0f);
- SetHue(0.0f);
- SetSaturation(1.0f);
- EnableForcedSubtitles(true);
- EnablePlanarYUV(true);
- EnableInterlaced(false);
- EnableReadARFromStream(true);
-
-#ifdef STANDALONE_FILTER
- CRegKey key;
- if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Video Decoder"), KEY_READ)) {
- DWORD dw;
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("DeinterlaceMethod"), dw)) {
- SetDeinterlaceMethod((ditype)dw);
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Brightness"), dw)) {
- SetBrightness(*(float*)&dw);
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Contrast"), dw)) {
- SetContrast(*(float*)&dw);
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Hue"), dw)) {
- SetHue(*(float*)&dw);
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Saturation"), dw)) {
- SetSaturation(*(float*)&dw);
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("ForcedSubtitles"), dw)) {
- EnableForcedSubtitles(!!dw);
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("PlanarYUV"), dw)) {
- EnablePlanarYUV(!!dw);
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("Interlaced"), dw)) {
- EnableInterlaced(!!dw);
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(_T("ReadARFromStream"), dw)) {
- EnableReadARFromStream(!!dw);
- }
- }
-#else
- DWORD dw;
- dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("DeinterlaceMethod"), m_ditype);
- SetDeinterlaceMethod((ditype)dw);
- dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Brightness"), *(DWORD*)&m_bright);
- SetBrightness(*(float*)&dw);
- dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Contrast"), *(DWORD*)&m_cont);
- SetContrast(*(float*)&dw);
- dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Hue"), *(DWORD*)&m_hue);
- SetHue(*(float*)&dw);
- dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Saturation"), *(DWORD*)&m_sat);
- SetSaturation(*(float*)&dw);
- dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("ForcedSubtitles"), m_fForcedSubs);
- EnableForcedSubtitles(!!dw);
- dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("PlanarYUV"), m_fPlanarYUV);
- EnablePlanarYUV(!!dw);
- dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Interlaced"), m_fInterlaced);
- EnableInterlaced(!!dw);
- dw = AfxGetApp()->GetProfileInt(_T("Filters\\MPEG Video Decoder"), _T("ReadARFromStream"), m_bReadARFromStream);
- EnableReadARFromStream(!!dw);
-
-#endif
-
- m_rate.Rate = 10000;
- m_rate.StartTime = 0;
-
- m_par.SetSize(1, 1);
-}
-
-CMpeg2DecFilter::~CMpeg2DecFilter()
-{
- delete m_pSubpicInput;
- delete m_pClosedCaptionOutput;
-}
-
-STDMETHODIMP CMpeg2DecFilter::Apply()
-{
-#ifdef STANDALONE_FILTER
- CRegKey key;
- if (ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Video Decoder"))) {
- key.SetDWORDValue(_T("DeinterlaceMethod"), m_ditype);
- key.SetDWORDValue(_T("Brightness"), *(DWORD*)&m_bright);
- key.SetDWORDValue(_T("Contrast"), *(DWORD*)&m_cont);
- key.SetDWORDValue(_T("Hue"), *(DWORD*)&m_hue);
- key.SetDWORDValue(_T("Saturation"), *(DWORD*)&m_sat);
- key.SetDWORDValue(_T("ForcedSubtitles"), m_fForcedSubs);
- key.SetDWORDValue(_T("PlanarYUV"), m_fPlanarYUV);
- key.SetDWORDValue(_T("Interlaced"), m_fInterlaced);
- key.SetDWORDValue(_T("ReadARFromStream"), m_bReadARFromStream);
- }
-#else
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("DeinterlaceMethod"), m_ditype);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Brightness"), *(DWORD*)&m_bright);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Contrast"), *(DWORD*)&m_cont);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Hue"), *(DWORD*)&m_hue);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Saturation"), *(DWORD*)&m_sat);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("ForcedSubtitles"), m_fForcedSubs);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("PlanarYUV"), m_fPlanarYUV);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("Interlaced"), m_fInterlaced);
- AfxGetApp()->WriteProfileInt(_T("Filters\\MPEG Video Decoder"), _T("ReadARFromStream"), m_bReadARFromStream);
-#endif
-
- return S_OK;
-}
-
-void CMpeg2DecFilter::GetOutputSize(int& w, int& h, int& arx, int& ary, int& RealWidth, int& RealHeight)
-{
- w = m_dec->m_info.m_sequence->picture_width;
- h = m_dec->m_info.m_sequence->picture_height;
-}
-
-STDMETHODIMP CMpeg2DecFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
-{
- return
- QI(IMpeg2DecFilter)
- QI(ISpecifyPropertyPages)
- QI(ISpecifyPropertyPages2)
- __super::NonDelegatingQueryInterface(riid, ppv);
-}
-
-int CMpeg2DecFilter::GetPinCount()
-{
- return 4;
-}
-
-CBasePin* CMpeg2DecFilter::GetPin(int n)
-{
- switch (n) {
- case 0:
- return m_pInput;
- case 1:
- return m_pOutput;
- case 2:
- return m_pSubpicInput;
- case 3:
- return m_pClosedCaptionOutput;
- }
- return nullptr;
-}
-
-HRESULT CMpeg2DecFilter::EndOfStream()
-{
- CAutoLock cAutoLock(&m_csReceive);
- m_pClosedCaptionOutput->EndOfStream();
- return __super::EndOfStream();
-}
-
-HRESULT CMpeg2DecFilter::BeginFlush()
-{
- m_pClosedCaptionOutput->DeliverBeginFlush();
- return __super::BeginFlush();
-}
-
-HRESULT CMpeg2DecFilter::EndFlush()
-{
- m_pClosedCaptionOutput->DeliverEndFlush();
- return __super::EndFlush();
-}
-
-HRESULT CMpeg2DecFilter::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
-{
- CAutoLock cAutoLock(&m_csReceive);
- m_pClosedCaptionOutput->DeliverNewSegment(tStart, tStop, dRate);
- m_fDropFrames = false;
- return __super::NewSegment(tStart, tStop, dRate);
-}
-
-void CMpeg2DecFilter::InputTypeChanged()
-{
- CAutoLock cAutoLock(&m_csReceive);
-
- TRACE(_T("ResetMpeg2Decoder()\n"));
-
- for (int i = 0; i < _countof(m_dec->m_pictures); i++) {
- m_dec->m_pictures[i].rtStart = m_dec->m_pictures[i].rtStop = _I64_MIN + 1;
- m_dec->m_pictures[i].fDelivered = false;
- m_dec->m_pictures[i].flags &= ~PIC_MASK_CODING_TYPE;
- }
-
- const CMediaType& mt = m_pInput->CurrentMediaType();
-
- BYTE* pSequenceHeader = nullptr;
- DWORD cbSequenceHeader = 0;
-
- if (mt.formattype == FORMAT_MPEGVideo) {
- pSequenceHeader = ((MPEG1VIDEOINFO*)mt.Format())->bSequenceHeader;
- cbSequenceHeader = ((MPEG1VIDEOINFO*)mt.Format())->cbSequenceHeader;
- } else if (mt.formattype == FORMAT_MPEG2_VIDEO) {
- pSequenceHeader = (BYTE*)((MPEG2VIDEOINFO*)mt.Format())->dwSequenceHeader;
- cbSequenceHeader = ((MPEG2VIDEOINFO*)mt.Format())->cbSequenceHeader;
- }
-
- m_dec->mpeg2_close();
- m_dec->mpeg2_init();
-
- m_dec->mpeg2_buffer(pSequenceHeader, pSequenceHeader + cbSequenceHeader);
-
- m_fWaitForKeyFrame = true;
-
- m_fFilm = false;
- m_fb.flags = 0;
-}
-
-void CMpeg2DecFilter::SetDeinterlaceMethod()
-{
- ASSERT(m_dec->m_info.m_sequence);
- ASSERT(m_dec->m_info.m_display_picture);
-
- DWORD seqflags = m_dec->m_info.m_sequence->flags;
- DWORD oldflags = m_fb.flags;
- DWORD newflags = m_dec->m_info.m_display_picture->flags;
-
- if (!(seqflags & SEQ_FLAG_PROGRESSIVE_SEQUENCE)
- && !(oldflags & PIC_FLAG_REPEAT_FIRST_FIELD)
- && (newflags & PIC_FLAG_PROGRESSIVE_FRAME)) {
- if (!m_fFilm && (newflags & PIC_FLAG_REPEAT_FIRST_FIELD)) {
- TRACE(_T("m_fFilm = true\n"));
- m_fFilm = true;
- } else if (m_fFilm && !(newflags & PIC_FLAG_REPEAT_FIRST_FIELD)) {
- TRACE(_T("m_fFilm = false\n"));
- m_fFilm = false;
- }
- }
-
- const CMediaType& mt = m_pOutput->CurrentMediaType();
-
- if (mt.formattype == FORMAT_VideoInfo2 && (((VIDEOINFOHEADER2*)mt.pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced)) {
- m_fb.di = DIWeave;
- } else {
- m_fb.di = GetDeinterlaceMethod();
-
- if (m_fb.di == DIAuto || m_fb.di != DIWeave && m_fb.di != DIBlend && m_fb.di != DIBob && m_fb.di != DIFieldShift && m_fb.di != DIELA) {
- if (seqflags & SEQ_FLAG_PROGRESSIVE_SEQUENCE) {
- m_fb.di = DIWeave; // hurray!
- } else if (m_fFilm) {
- m_fb.di = DIWeave; // we are lucky
- } else if (!(m_fb.flags & PIC_FLAG_PROGRESSIVE_FRAME)) {
- m_fb.di = DIBlend; // ok, clear thing
- } else
- // big trouble here, the progressive_frame bit is not reliable :'(
- // frames without temporal field diffs can be only detected when ntsc
- // uses the repeat field flag (signaled with m_fFilm), if it's not set
- // or we have pal then we might end up blending the fields unnecessarily...
- {
- m_fb.di = DIBlend;
- }
- }
- }
-
- m_fb.flags = newflags;
-}
-
-void CMpeg2DecFilter::SetTypeSpecificFlags(IMediaSample* pMS)
-{
- if (CComQIPtr<IMediaSample2> pMS2 = pMS) {
- AM_SAMPLE2_PROPERTIES props;
- if (SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props))) {
- props.dwTypeSpecificFlags &= ~0x7f;
-
- const CMediaType& mt = m_pOutput->CurrentMediaType();
- if (mt.formattype == FORMAT_VideoInfo2 && (((VIDEOINFOHEADER2*)mt.pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced)) {
- // props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
-
- if (m_dec->m_info.m_sequence->flags & SEQ_FLAG_PROGRESSIVE_SEQUENCE) {
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
- }
-
- if (m_fb.flags & PIC_FLAG_TOP_FIELD_FIRST) {
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_FIELD1FIRST;
- }
- if (m_fb.flags & PIC_FLAG_REPEAT_FIRST_FIELD) {
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_REPEAT_FIELD;
- }
-
- if ((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I) {
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_I_SAMPLE;
- }
- if ((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_P) {
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_P_SAMPLE;
- }
- if ((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_B) {
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_B_SAMPLE;
- }
- }
-
- pMS2->SetProperties(sizeof(props), (BYTE*)&props);
- }
- }
-}
-
-HRESULT CMpeg2DecFilter::Transform(IMediaSample* pIn)
-{
- HRESULT hr;
-
- BYTE* pDataIn = nullptr;
- if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
- return hr;
- }
-
- long len = pIn->GetActualDataLength();
-
- (static_cast<CDeCSSInputPin*>(m_pInput))->StripPacket(pDataIn, len);
-
- if (pIn->IsDiscontinuity() == S_OK) {
- InputTypeChanged();
- }
-
- REFERENCE_TIME rtStart = _I64_MIN, rtStop = _I64_MIN;
- hr = pIn->GetTime(&rtStart, &rtStop);
- if (FAILED(hr)) {
- rtStart = rtStop = _I64_MIN;
- }
-
- while (len >= 0) {
- mpeg2_state_t state = m_dec->mpeg2_parse();
-#ifndef _WIN64
- __asm emms; // this one is missing somewhere in the precompiled mmx obj files
-#endif
- switch (state) {
- case STATE_BUFFER:
- if (len > 0) {
- m_dec->mpeg2_buffer(pDataIn, pDataIn + len);
- len = 0;
- } else {
- len = -1;
- }
- break;
- case STATE_INVALID:
- TRACE(_T("*** STATE_INVALID\n"));
- break;
- case STATE_GOP:
- m_pClosedCaptionOutput->Deliver(m_dec->m_info.m_user_data, m_dec->m_info.m_user_data_len);
- break;
- case STATE_SEQUENCE:
- m_AvgTimePerFrame = m_dec->m_info.m_sequence->frame_period
- ? 10i64 * m_dec->m_info.m_sequence->frame_period / 27
- : ((VIDEOINFOHEADER*)m_pInput->CurrentMediaType().Format())->AvgTimePerFrame;
- break;
- case STATE_PICTURE:
- m_dec->m_picture->rtStart = rtStart;
- rtStart = _I64_MIN;
- m_dec->m_picture->fDelivered = false;
- m_dec->mpeg2_skip(m_fDropFrames && (m_dec->m_picture->flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_B);
- break;
- case STATE_SLICE:
- case STATE_END: {
- mpeg2_picture_t* picture = m_dec->m_info.m_display_picture;
- mpeg2_fbuf_t* fbuf = m_dec->m_info.m_display_fbuf;
-
- if (picture && !(picture->flags & PIC_FLAG_SKIP) && fbuf) {
- ASSERT(!picture->fDelivered);
-
- picture->fDelivered = true;
-
- // frame buffer
-
- int w = m_dec->m_info.m_sequence->picture_width;
- int h = m_dec->m_info.m_sequence->picture_height;
- int pitch = (m_dec->m_info.m_sequence->width + 31) & ~31;
-
- if (m_fb.w != w || m_fb.h != h || m_fb.pitch != pitch) {
- m_fb.Alloc(w, h, pitch);
- m_fInitializedBuffer = false;
- }
-
- // start - end
-
- m_fb.rtStart = picture->rtStart;
- if (m_fb.rtStart == _I64_MIN) {
- m_fb.rtStart = m_fb.rtStop;
- }
- m_fb.rtStop = m_fb.rtStart + m_AvgTimePerFrame * picture->nb_fields / (m_dec->m_info.m_display_picture_2nd ? 1 : 2);
-
- REFERENCE_TIME rtStart2 = m_fb.rtStart;
- REFERENCE_TIME rtStop2 = m_fb.rtStop;
- UNREFERENCED_PARAMETER(rtStart2);
- UNREFERENCED_PARAMETER(rtStop2);
-
- //
-
- SetDeinterlaceMethod();
- UpdateAspectRatio();
-
- hr = DeliverFast();
- if (hr != S_OK) {
- hr = DeliverNormal();
- }
- if (hr != S_OK) {
- return hr;
- }
- if (hr == S_OK && !m_fWaitForKeyFrame) {
- m_fInitializedBuffer = true;
- }
- }
- }
- break;
- default:
- break;
- }
- }
-
- return S_OK;
-}
-
-bool CMpeg2DecFilter::IsVideoInterlaced()
-{
- return IsInterlacedEnabled();
-}
-
-void CMpeg2DecFilter::UpdateAspectRatio()
-{
- if (m_bReadARFromStream && ((unsigned int)m_par.cx != m_dec->m_info.m_sequence->pixel_width || (unsigned int)m_par.cy != m_dec->m_info.m_sequence->pixel_height)) {
- m_par.cx = m_dec->m_info.m_sequence->pixel_width;
- m_par.cy = m_dec->m_info.m_sequence->pixel_height;
- CSize dar(m_dec->m_info.m_sequence->picture_width * m_par.cx,
- m_dec->m_info.m_sequence->picture_height * m_par.cy);
- int gcd = GCD(dar.cx, dar.cy);
- if (gcd > 1) {
- dar.cx /= gcd;
- dar.cy /= gcd;
- }
- SetAspect(dar);
- }
-}
-
-HRESULT CMpeg2DecFilter::DeliverFast()
-{
- HRESULT hr;
-
- CAutoLock cAutoLock(&m_csReceive);
-
- mpeg2_fbuf_t* fbuf = m_dec->m_info.m_display_fbuf;
- if (!fbuf) {
- return S_FALSE;
- }
-
- {
-
- CAutoLock cAutoLock2(&m_csProps);
-
- if (GetCLSID(m_pInput->GetConnected()) == CLSID_DVDNavigator
- || m_pSubpicInput->HasAnythingToRender(m_fb.rtStart)
- || fabs(m_bright) > EPSILON || fabs(m_cont - 1.0) > EPSILON
- || fabs(m_hue) > EPSILON || fabs(m_sat - 1.0) > EPSILON) {
- return S_FALSE;
- }
- }
-
- if ((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I) {
- m_fWaitForKeyFrame = false;
- }
-
- if (m_fb.rtStart < 0 || m_fWaitForKeyFrame) {
- return S_OK;
- }
-
- const CMediaType& mt = m_pOutput->CurrentMediaType();
-
- if (mt.subtype != MEDIASUBTYPE_I420 && mt.subtype != MEDIASUBTYPE_IYUV && mt.subtype != MEDIASUBTYPE_YV12) {
- return S_FALSE;
- }
-
- CComPtr<IMediaSample> pOut;
- BYTE* pDataOut = nullptr;
- if (FAILED(hr = GetDeliveryBuffer(m_fb.w, m_fb.h, &pOut))
- || FAILED(hr = pOut->GetPointer(&pDataOut))) {
- return hr;
- }
-
- if (mt.subtype != MEDIASUBTYPE_I420 && mt.subtype != MEDIASUBTYPE_IYUV && mt.subtype != MEDIASUBTYPE_YV12) {
- return S_FALSE;
- }
-
- BITMAPINFOHEADER bihOut;
- ExtractBIH(&mt, &bihOut);
-
- int w = bihOut.biWidth;
- int h = abs(bihOut.biHeight);
- int srcpitch = m_dec->m_info.m_sequence->width; // TODO (..+7)&~7; ?
- int dstpitch = bihOut.biWidth;
-
- BYTE* y = pDataOut;
- BYTE* u = y + dstpitch * h;
- BYTE* v = y + dstpitch * h * 5 / 4;
-
- if (bihOut.biCompression == '21VY') {
- BYTE* tmp = u;
- u = v;
- v = tmp;
- }
-
- if (m_fb.di == DIWeave) {
- BitBltFromI420ToI420(w, h, y, u, v, dstpitch, fbuf->buf[0], fbuf->buf[1], fbuf->buf[2], srcpitch);
- } else if (m_fb.di == DIBlend) {
- DeinterlaceBlend(y, fbuf->buf[0], w, h, dstpitch, srcpitch);
- DeinterlaceBlend(u, fbuf->buf[1], w / 2, h / 2, dstpitch / 2, srcpitch / 2);
- DeinterlaceBlend(v, fbuf->buf[2], w / 2, h / 2, dstpitch / 2, srcpitch / 2);
- } else { // TODO
- return S_FALSE;
- }
-
- if (h == 1088) {
- memset(y + dstpitch * (h - 8), 0xff, dstpitch * 8);
- memset(u + dstpitch * (h - 8) / 4, 0x80, dstpitch * 8 / 4);
- memset(v + dstpitch * (h - 8) / 4, 0x80, dstpitch * 8 / 4);
- }
-
- if (CMpeg2DecInputPin* pPin = dynamic_cast<CMpeg2DecInputPin*>(m_pInput)) {
- CAutoLock cAutoLock2(&pPin->m_csRateLock);
-
- if (m_rate.Rate != pPin->m_ratechange.Rate) {
- m_rate.Rate = pPin->m_ratechange.Rate;
- m_rate.StartTime = m_fb.rtStart;
- }
- }
-
- REFERENCE_TIME rtStart = m_fb.rtStart;
- REFERENCE_TIME rtStop = m_fb.rtStop;
-
- rtStart = m_rate.StartTime + (rtStart - m_rate.StartTime) * m_rate.Rate / 10000;
- rtStop = m_rate.StartTime + (rtStop - m_rate.StartTime) * m_rate.Rate / 10000;
-
- pOut->SetTime(&rtStart, &rtStop);
- pOut->SetMediaTime(nullptr, nullptr);
-
- //
-
- SetTypeSpecificFlags(pOut);
-
- //
-
- return m_pOutput->Deliver(pOut);
-}
-
-HRESULT CMpeg2DecFilter::DeliverNormal()
-{
- HRESULT hr = S_OK;
-
- CAutoLock cAutoLock(&m_csReceive);
-
- mpeg2_fbuf_t* fbuf = m_dec->m_info.m_display_fbuf;
- if (!fbuf) {
- return S_FALSE;
- }
-
- int w = m_fb.w;
- int h = m_fb.h;
- int spitch = m_dec->m_info.m_sequence->width; // TODO (..+7)&~7; ?
- int dpitch = m_fb.pitch;
-
- REFERENCE_TIME rtStart = m_fb.rtStart;
- REFERENCE_TIME rtStop = m_fb.rtStop;
-
- bool tff = !!(m_fb.flags & PIC_FLAG_TOP_FIELD_FIRST);
-
- // deinterlace
-
- if (m_fb.di == DIWeave) {
- BitBltFromI420ToI420(w, h, m_fb.buf[0], m_fb.buf[1], m_fb.buf[2], dpitch, fbuf->buf[0], fbuf->buf[1], fbuf->buf[2], spitch);
- } else if (m_fb.di == DIBlend) {
- DeinterlaceBlend(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch);
- DeinterlaceBlend(m_fb.buf[1], fbuf->buf[1], w / 2, h / 2, dpitch / 2, spitch / 2);
- DeinterlaceBlend(m_fb.buf[2], fbuf->buf[2], w / 2, h / 2, dpitch / 2, spitch / 2);
- } else if (m_fb.di == DIBob) {
- DeinterlaceBob(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch, tff);
- DeinterlaceBob(m_fb.buf[1], fbuf->buf[1], w / 2, h / 2, dpitch / 2, spitch / 2, tff);
- DeinterlaceBob(m_fb.buf[2], fbuf->buf[2], w / 2, h / 2, dpitch / 2, spitch / 2, tff);
-
- m_fb.rtStart = rtStart;
- m_fb.rtStop = (rtStart + rtStop) / 2;
- } else if (m_fb.di == DIFieldShift) {
- int soffset = tff ? 0 : spitch;
- int doffset = tff ? 0 : dpitch;
- BitBltFromRGBToRGB(w, h / 2, m_fb.buf[0] + doffset, dpitch * 2, 8, fbuf->buf[0] + soffset, spitch * 2, 8);
- BitBltFromRGBToRGB(w / 2, h / 4, m_fb.buf[1] + doffset / 2, dpitch, 8, fbuf->buf[1] + soffset / 2, spitch, 8);
- BitBltFromRGBToRGB(w / 2, h / 4, m_fb.buf[2] + doffset / 2, dpitch, 8, fbuf->buf[2] + soffset / 2, spitch, 8);
- } else if (m_fb.di == DIELA) {
- DeinterlaceELA(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch, tff);
- DeinterlaceELA(m_fb.buf[1], fbuf->buf[1], w / 2, h / 2, dpitch / 2, spitch / 2, tff);
- DeinterlaceELA(m_fb.buf[2], fbuf->buf[2], w / 2, h / 2, dpitch / 2, spitch / 2, tff);
- }
-
- // postproc
-
- ApplyBrContHueSat(m_fb.buf[0], m_fb.buf[1], m_fb.buf[2], w, h, dpitch);
-
- // deliver
-
- if (m_fb.di == DIWeave || m_fInitializedBuffer) {
- hr = Deliver(false);
- if (FAILED(hr)) {
- return hr;
- }
- }
-
- if (m_fb.di == DIBob) {
- DeinterlaceBob(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch, !tff);
- DeinterlaceBob(m_fb.buf[1], fbuf->buf[1], w / 2, h / 2, dpitch / 2, spitch / 2, !tff);
- DeinterlaceBob(m_fb.buf[2], fbuf->buf[2], w / 2, h / 2, dpitch / 2, spitch / 2, !tff);
-
- m_fb.rtStart = (rtStart + rtStop) / 2;
- m_fb.rtStop = rtStop;
-
- // postproc
-
- ApplyBrContHueSat(m_fb.buf[0], m_fb.buf[1], m_fb.buf[2], w, h, dpitch);
-
- // deliver
-
- hr = Deliver(false);
- } else if (m_fb.di == DIFieldShift) {
- int soffset = !tff ? 0 : spitch;
- int doffset = !tff ? 0 : dpitch;
- BitBltFromRGBToRGB(w, h / 2, m_fb.buf[0] + doffset, dpitch * 2, 8, fbuf->buf[0] + soffset, spitch * 2, 8);
- BitBltFromRGBToRGB(w / 2, h / 4, m_fb.buf[1] + doffset / 2, dpitch, 8, fbuf->buf[1] + soffset / 2, spitch, 8);
- BitBltFromRGBToRGB(w / 2, h / 4, m_fb.buf[2] + doffset / 2, dpitch, 8, fbuf->buf[2] + soffset / 2, spitch, 8);
- } else if (m_fb.di == DIELA) {
- DeinterlaceELA(m_fb.buf[0], fbuf->buf[0], w, h, dpitch, spitch, !tff);
- DeinterlaceELA(m_fb.buf[1], fbuf->buf[1], w / 2, h / 2, dpitch / 2, spitch / 2, !tff);
- DeinterlaceELA(m_fb.buf[2], fbuf->buf[2], w / 2, h / 2, dpitch / 2, spitch / 2, !tff);
- }
-
- if (!m_fInitializedBuffer) {
- hr = Deliver(false);
- }
-
- return hr;
-}
-
-HRESULT CMpeg2DecFilter::Deliver(bool fRepeatLast)
-{
- CAutoLock cAutoLock(&m_csReceive);
-
- if ((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I) {
- m_fWaitForKeyFrame = false;
- }
-
- if (m_fb.rtStart < 0 || m_fWaitForKeyFrame) {
- return S_OK;
- }
-
- HRESULT hr;
-
- CComPtr<IMediaSample> pOut;
- BYTE* pDataOut = nullptr;
- if (FAILED(hr = GetDeliveryBuffer(m_fb.w, m_fb.h, &pOut))
- || FAILED(hr = pOut->GetPointer(&pDataOut))) {
- return hr;
- }
-
- if (m_fb.h == 1088) {
- memset(m_fb.buf[0] + m_fb.w * (m_fb.h - 8), 0xff, m_fb.pitch * 8);
- memset(m_fb.buf[1] + m_fb.w * (m_fb.h - 8) / 4, 0x80, m_fb.pitch * 8 / 4);
- memset(m_fb.buf[2] + m_fb.w * (m_fb.h - 8) / 4, 0x80, m_fb.pitch * 8 / 4);
- }
-
- BYTE** buf = &m_fb.buf[0];
-
- if (m_pSubpicInput->HasAnythingToRender(m_fb.rtStart)) {
- BitBltFromI420ToI420(m_fb.w, m_fb.h,
- m_fb.buf[3], m_fb.buf[4], m_fb.buf[5], m_fb.pitch,
- m_fb.buf[0], m_fb.buf[1], m_fb.buf[2], m_fb.pitch);
-
- buf = &m_fb.buf[3];
-
- m_pSubpicInput->RenderSubpics(m_fb.rtStart, buf, m_fb.pitch, m_fb.h);
- }
-
- CopyBuffer(pDataOut, buf, (m_fb.w + 7)&~7, m_fb.h, m_fb.pitch, MEDIASUBTYPE_I420, !(m_fb.flags & PIC_FLAG_PROGRESSIVE_FRAME));
-
- //
-
- if (CMpeg2DecInputPin* pPin = dynamic_cast<CMpeg2DecInputPin*>(m_pInput)) {
- CAutoLock cAutoLock2(&pPin->m_csRateLock);
-
- if (m_rate.Rate != pPin->m_ratechange.Rate) {
- m_rate.Rate = pPin->m_ratechange.Rate;
- m_rate.StartTime = m_fb.rtStart;
- }
- }
-
- REFERENCE_TIME rtStart = m_fb.rtStart;
- REFERENCE_TIME rtStop = m_fb.rtStop;
-
- rtStart = m_rate.StartTime + (rtStart - m_rate.StartTime) * m_rate.Rate / 10000;
- rtStop = m_rate.StartTime + (rtStop - m_rate.StartTime) * m_rate.Rate / 10000;
-
- pOut->SetTime(&rtStart, &rtStop);
- pOut->SetMediaTime(nullptr, nullptr);
-
- //
-
- SetTypeSpecificFlags(pOut);
-
- //
-
- hr = m_pOutput->Deliver(pOut);
-
- return hr;
-}
-
-HRESULT CMpeg2DecFilter::CheckConnect(PIN_DIRECTION dir, IPin* pPin)
-{
- if (dir == PINDIR_OUTPUT) {
- if (GetCLSID(m_pInput->GetConnected()) == CLSID_DVDNavigator) {
- // one of these needed for dynamic format changes
-
- CLSID clsid = GetCLSID(pPin);
-
- DWORD ver = 0;
- if (CComQIPtr<IFilterVersion> pFV = GetFilterFromPin(pPin)) {
- ver = pFV->GetFilterVersion();
- }
-
- if (clsid != CLSID_OverlayMixer
- /*&& clsid != CLSID_OverlayMixer2*/
- && clsid != CLSID_VideoMixingRenderer
- && clsid != CLSID_VideoMixingRenderer9
- && clsid != CLSID_EnhancedVideoRenderer
- && clsid != GUIDFromCString(_T("{04FE9017-F873-410E-871E-AB91661A4EF7}")) // ffdshow
- && (clsid != GUIDFromCString(_T("{93A22E7A-5091-45ef-BA61-6DA26156A5D0}")) || ver < 0x0234) // dvobsub
- && (clsid != GUIDFromCString(_T("{9852A670-F845-491b-9BE6-EBD841B8A613}")) || ver < 0x0234) // dvobsub auto
- && clsid != CLSID_madVR
- && clsid != CLSID_DXR) { // Haali's video renderer
- return E_FAIL;
- }
- }
- }
-
- return __super::CheckConnect(dir, pPin);
-}
-
-int NextMpegStartCode(CGolombBuffer& gb, BYTE& code, __int64 len)
-{
- gb.BitByteAlign();
- DWORD dw = (DWORD) - 1;
- do {
- if (len-- == 0) {
- return false;
- }
- dw = (dw << 8) | (BYTE)gb.BitRead(8);
- } while ((dw & 0xffffff00) != 0x00000100);
- code = (BYTE)(dw & 0xff);
- return true;
-}
-
-HRESULT CMpeg2DecFilter::CheckInputType(const CMediaType* mtIn)
-{
- if (mtIn->formattype == FORMAT_MPEG2_VIDEO && mtIn->pbFormat) {
- MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mtIn->pbFormat;
- if (vih->cbSequenceHeader > 0 && (vih->dwSequenceHeader[0] & 0x00ffffff) != 0x00010000) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- BYTE* pSequenceHeader = (BYTE*)vih->dwSequenceHeader;
- DWORD cbSequenceHeader = vih->cbSequenceHeader;
-
- BYTE id = 0;
- CGolombBuffer gb(pSequenceHeader, cbSequenceHeader);
- while (gb.GetPos() < gb.GetSize() && id != 0xb5) {
- if (!NextMpegStartCode(gb, id, cbSequenceHeader)) {
- break;
- }
- }
- if (id == 0xb5) {
- gb.BitRead(4); // startcodeid
- gb.BitRead(1); // profile_levelescape
- gb.BitRead(3); // profile
- gb.BitRead(4); // level
- gb.BitRead(1); // interlaced
- BYTE chroma = (BYTE)gb.BitRead(2);
- if (chroma >= 2) { // current support only 4:2:0 profile
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
- }
- }
-
- return (mtIn->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK && mtIn->subtype == MEDIASUBTYPE_MPEG2_VIDEO
- || mtIn->majortype == MEDIATYPE_MPEG2_PACK && mtIn->subtype == MEDIASUBTYPE_MPEG2_VIDEO
- || mtIn->majortype == MEDIATYPE_MPEG2_PES && mtIn->subtype == MEDIASUBTYPE_MPEG2_VIDEO
- || mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_MPEG2_VIDEO
- || mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_MPG2
- || mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_MPEG1Packet
- || mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_MPEG1Payload)
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
-}
-
-HRESULT CMpeg2DecFilter::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
-{
- bool fPlanarYUV = mtOut->subtype == MEDIASUBTYPE_YV12
- || mtOut->subtype == MEDIASUBTYPE_I420
- || mtOut->subtype == MEDIASUBTYPE_IYUV;
-
- return SUCCEEDED(__super::CheckTransform(mtIn, mtOut))
- && (!fPlanarYUV || IsPlanarYUVEnabled())
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
-}
-
-HRESULT CMpeg2DecFilter::SetMediaType(PIN_DIRECTION dir, const CMediaType* pmt)
-{
- HRESULT hr = __super::SetMediaType(dir, pmt);
-
- if (dir == PINDIR_INPUT) {
- // Compute the expected Pixel AR
- m_par.cx = m_arx * m_h;
- m_par.cy = m_ary * m_w;
- int gcd = GCD(m_par.cx, m_par.cy);
- if (gcd > 1) {
- m_par.cx /= gcd;
- m_par.cy /= gcd;
- }
- }
-
- return hr;
-}
-
-DWORD g_clock;
-
-HRESULT CMpeg2DecFilter::StartStreaming()
-{
- HRESULT hr = __super::StartStreaming();
- if (FAILED(hr)) {
- return hr;
- }
-
- m_dec.Attach(DEBUG_NEW CMpeg2Dec());
- if (!m_dec) {
- return E_OUTOFMEMORY;
- }
-
- InputTypeChanged();
-
- // g_clock = clock();
-
- return S_OK;
-}
-
-HRESULT CMpeg2DecFilter::StopStreaming()
-{
- /*
- CString str;
- str.Format(_T("%d"), clock()-g_clock);
- AfxMessageBox(str);
- */
- m_dec.Free();
-
- return __super::StopStreaming();
-}
-
-HRESULT CMpeg2DecFilter::AlterQuality(Quality q)
-{
- if (q.Late > 100 * 10000i64) {
- m_fDropFrames = true;
- } else if (q.Late <= 0) {
- m_fDropFrames = false;
- }
-
- //TRACE(_T("CMpeg2DecFilter::AlterQuality: Type=%d, Proportion=%d, Late=%I64d, TimeStamp=%I64d\n"), q.Type, q.Proportion, q.Late, q.TimeStamp);
- return S_OK;
-}
-
-// ISpecifyPropertyPages2
-
-STDMETHODIMP CMpeg2DecFilter::GetPages(CAUUID* pPages)
-{
- CheckPointer(pPages, E_POINTER);
-
- HRESULT hr = S_OK;
-
- pPages->cElems = 1;
- pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID) * pPages->cElems);
- if (pPages->pElems != nullptr) {
- pPages->pElems[0] = __uuidof(CMpeg2DecSettingsWnd);
- } else {
- hr = E_OUTOFMEMORY;
- }
-
- return hr;
-}
-
-STDMETHODIMP CMpeg2DecFilter::CreatePage(const GUID& guid, IPropertyPage** ppPage)
-{
- CheckPointer(ppPage, E_POINTER);
-
- if (*ppPage != nullptr) {
- return E_INVALIDARG;
- }
-
- HRESULT hr;
-
- if (guid == __uuidof(CMpeg2DecSettingsWnd)) {
- (*ppPage = DEBUG_NEW CInternalPropertyPageTempl<CMpeg2DecSettingsWnd>(nullptr, &hr))->AddRef();
- }
-
- return *ppPage ? S_OK : E_FAIL;
-}
-
-// IMpeg2DecFilter
-
-STDMETHODIMP CMpeg2DecFilter::SetDeinterlaceMethod(ditype di)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_ditype = di;
- return S_OK;
-}
-
-STDMETHODIMP_(ditype) CMpeg2DecFilter::GetDeinterlaceMethod()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_ditype;
-}
-
-void CMpeg2DecFilter::CalcBrCont(BYTE* YTbl, float bright, float cont)
-{
- int Cont = (int)(cont * 512);
- int Bright = (int)bright;
-
- for (int i = 0; i < 256; i++) {
- int y = ((Cont * (i - 16)) >> 9) + Bright + 16;
- YTbl[i] = min(max(y, 0), 255);
- //YTbl[i] = min(max(y, 16), 235);
- }
-}
-
-void CMpeg2DecFilter::CalcHueSat(BYTE* UTbl, BYTE* VTbl, float hue, float sat)
-{
- int Sat = (int)(sat * 512);
- double Hue = (hue * M_PI) / 180.0;
- int Sin = (int)(sin(Hue) * 4096);
- int Cos = (int)(cos(Hue) * 4096);
-
- for (int y = 0; y < 256; y++) {
- for (int x = 0; x < 256; x++) {
- int u = x - 128;
- int v = y - 128;
- int ux = (u * Cos + v * Sin) >> 12;
- v = (v * Cos - u * Sin) >> 12;
- u = ((ux * Sat) >> 9) + 128;
- v = ((v * Sat) >> 9) + 128;
- u = min(max(u, 16), 235);
- v = min(max(v, 16), 235);
- UTbl[(y << 8) | x] = u;
- VTbl[(y << 8) | x] = v;
- }
- }
-}
-
-void CMpeg2DecFilter::ApplyBrContHueSat(BYTE* srcy, BYTE* srcu, BYTE* srcv, int w, int h, int pitch)
-{
- CAutoLock cAutoLock(&m_csProps);
-
- if (fabs(m_bright) > EPSILON || fabs(m_cont - 1.0) > EPSILON) {
- int size = pitch * h;
-
- if ((g_cpuid.m_flags & CCpuID::sse2) && ((DWORD_PTR)srcy & 15) == 0) {
- short Cont = (short)(min(max(m_cont, 0) * 512, (1 << 16) - 1));
- short Bright = (short)(m_bright + 16);
-
- __m128i bc = _mm_set_epi16(Bright, Cont, Bright, Cont, Bright, Cont, Bright, Cont);
-
- __m128i zero = _mm_setzero_si128();
- __m128i _16 = _mm_set1_epi16(16);
- __m128i _512 = _mm_set1_epi16(512);
-
- for (int i = 0, j = size >> 4; i < j; i++) {
- __m128i r = _mm_load_si128((__m128i*)&srcy[i * 16]);
-
- __m128i rl = _mm_unpacklo_epi8(r, zero);
- __m128i rh = _mm_unpackhi_epi8(r, zero);
-
- rl = _mm_subs_epi16(rl, _16);
- rh = _mm_subs_epi16(rh, _16);
-
- __m128i rll = _mm_unpacklo_epi16(rl, _512);
- __m128i rlh = _mm_unpackhi_epi16(rl, _512);
- __m128i rhl = _mm_unpacklo_epi16(rh, _512);
- __m128i rhh = _mm_unpackhi_epi16(rh, _512);
-
- rll = _mm_madd_epi16(rll, bc);
- rlh = _mm_madd_epi16(rlh, bc);
- rhl = _mm_madd_epi16(rhl, bc);
- rhh = _mm_madd_epi16(rhh, bc);
-
- rll = _mm_srai_epi32(rll, 9);
- rlh = _mm_srai_epi32(rlh, 9);
- rhl = _mm_srai_epi32(rhl, 9);
- rhh = _mm_srai_epi32(rhh, 9);
-
- rl = _mm_packs_epi32(rll, rlh);
- rh = _mm_packs_epi32(rhl, rhh);
-
- r = _mm_packus_epi16(rl, rh);
-
- _mm_store_si128((__m128i*)&srcy[i * 16], r);
- }
-
- srcy += size >> 4;
- size &= 15;
- }
-
- for (; size > 0; size--) {
- *srcy++ = m_YTbl[*srcy];
- }
- }
-
- pitch /= 2;
- w /= 2;
- h /= 2;
-
- if (fabs(m_hue) > EPSILON || fabs(m_sat - 1.0) > EPSILON) {
- for (int size = pitch * h; size > 0; size--) {
- WORD uv = (*srcv << 8) | *srcu;
- *srcu++ = m_UTbl[uv];
- *srcv++ = m_VTbl[uv];
- }
- }
-}
-
-STDMETHODIMP CMpeg2DecFilter::SetBrightness(float bright)
-{
- CAutoLock cAutoLock(&m_csProps);
- CalcBrCont(m_YTbl, m_bright = bright, m_cont);
- return S_OK;
-}
-
-STDMETHODIMP CMpeg2DecFilter::SetContrast(float cont)
-{
- CAutoLock cAutoLock(&m_csProps);
- CalcBrCont(m_YTbl, m_bright, m_cont = cont);
- return S_OK;
-}
-
-STDMETHODIMP CMpeg2DecFilter::SetHue(float hue)
-{
- CAutoLock cAutoLock(&m_csProps);
- CalcHueSat(m_UTbl, m_VTbl, m_hue = hue, m_sat);
- return S_OK;
-}
-
-STDMETHODIMP CMpeg2DecFilter::SetSaturation(float sat)
-{
- CAutoLock cAutoLock(&m_csProps);
- CalcHueSat(m_UTbl, m_VTbl, m_hue, m_sat = sat);
- return S_OK;
-}
-
-STDMETHODIMP_(float) CMpeg2DecFilter::GetBrightness()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_bright;
-}
-
-STDMETHODIMP_(float) CMpeg2DecFilter::GetContrast()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_cont;
-}
-
-STDMETHODIMP_(float) CMpeg2DecFilter::GetHue()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_hue;
-}
-
-STDMETHODIMP_(float) CMpeg2DecFilter::GetSaturation()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_sat;
-}
-
-STDMETHODIMP CMpeg2DecFilter::EnableForcedSubtitles(bool fEnable)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_fForcedSubs = fEnable;
- return S_OK;
-}
-
-STDMETHODIMP_(bool) CMpeg2DecFilter::IsForcedSubtitlesEnabled()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_fForcedSubs;
-}
-
-STDMETHODIMP CMpeg2DecFilter::EnablePlanarYUV(bool fEnable)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_fPlanarYUV = fEnable;
- return S_OK;
-}
-
-STDMETHODIMP_(bool) CMpeg2DecFilter::IsPlanarYUVEnabled()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_fPlanarYUV;
-}
-
-STDMETHODIMP CMpeg2DecFilter::EnableInterlaced(bool fEnable)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_fInterlaced = fEnable;
- return S_OK;
-}
-
-STDMETHODIMP_(bool) CMpeg2DecFilter::IsInterlacedEnabled()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_fInterlaced;
-}
-
-STDMETHODIMP CMpeg2DecFilter::EnableReadARFromStream(bool fEnable)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_bReadARFromStream = fEnable;
- return S_OK;
-}
-
-STDMETHODIMP_(bool) CMpeg2DecFilter::IsReadARFromStreamEnabled()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_bReadARFromStream;
-}
-
-//
-// CMpeg2DecInputPin
-//
-
-CMpeg2DecInputPin::CMpeg2DecInputPin(CTransformFilter* pFilter, HRESULT* phr, LPWSTR pName)
- : CDeCSSInputPin(NAME("CMpeg2DecInputPin"), pFilter, phr, pName)
-{
- m_CorrectTS = 0;
- m_ratechange.Rate = 10000;
- m_ratechange.StartTime = _I64_MAX;
-}
-
-// IKsPropertySet
-
-STDMETHODIMP CMpeg2DecInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength)
-{
- if (PropSet != AM_KSPROPSETID_TSRateChange /*&& PropSet != AM_KSPROPSETID_DVD_RateChange*/) {
- return __super::Set(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength);
- }
-
- if (PropSet == AM_KSPROPSETID_TSRateChange)
- switch (Id) {
- case AM_RATE_SimpleRateChange: {
- AM_SimpleRateChange* p = (AM_SimpleRateChange*)pPropertyData;
- if (!m_CorrectTS) {
- return E_PROP_ID_UNSUPPORTED;
- }
- CAutoLock cAutoLock(&m_csRateLock);
- m_ratechange = *p;
- DbgLog((LOG_TRACE, 0, _T("StartTime=%I64d, Rate=%d"), p->StartTime, p->Rate));
- }
- break;
- case AM_RATE_UseRateVersion: {
- WORD* p = (WORD*)pPropertyData;
- if (*p > 0x0101) {
- return E_PROP_ID_UNSUPPORTED;
- }
- }
- break;
- case AM_RATE_CorrectTS: {
- LONG* p = (LONG*)pPropertyData;
- m_CorrectTS = *p;
- }
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
- }
- /*
- if (PropSet == AM_KSPROPSETID_DVD_RateChange)
- switch (Id)
- {
- case AM_RATE_ChangeRate:
- {
- AM_DVD_ChangeRate* p = (AM_DVD_ChangeRate*)pPropertyData;
- }
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
- }
- */
- return S_OK;
-}
-
-STDMETHODIMP CMpeg2DecInputPin::Get(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength, ULONG* pBytesReturned)
-{
- if (PropSet != AM_KSPROPSETID_TSRateChange /*&& PropSet != AM_KSPROPSETID_DVD_RateChange*/) {
- return __super::Get(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength, pBytesReturned);
- }
-
- if (PropSet == AM_KSPROPSETID_TSRateChange)
- switch (Id) {
- case AM_RATE_SimpleRateChange: {
- AM_SimpleRateChange* p = (AM_SimpleRateChange*)pPropertyData;
- UNREFERENCED_PARAMETER(p);
- return E_PROP_ID_UNSUPPORTED;
- }
- break;
- case AM_RATE_MaxFullDataRate: {
- AM_MaxFullDataRate* p = (AM_MaxFullDataRate*)pPropertyData;
- UNREFERENCED_PARAMETER(p);
- *p = 8 * 10000;
- *pBytesReturned = sizeof(AM_MaxFullDataRate);
- }
- break;
- case AM_RATE_QueryFullFrameRate: {
- AM_QueryRate* p = (AM_QueryRate*)pPropertyData;
- p->lMaxForwardFullFrame = 8 * 10000;
- p->lMaxReverseFullFrame = 8 * 10000;
- *pBytesReturned = sizeof(AM_QueryRate);
- }
- break;
- case AM_RATE_QueryLastRateSegPTS: {
- //REFERENCE_TIME* p = (REFERENCE_TIME*)pPropertyData;
- return E_PROP_ID_UNSUPPORTED;
- }
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
- }
- /*
- if (PropSet == AM_KSPROPSETID_DVD_RateChange)
- switch (Id)
- {
- case AM_RATE_FullDataRateMax:
- {
- AM_MaxFullDataRate* p = (AM_MaxFullDataRate*)pPropertyData;
- }
- break;
- case AM_RATE_ReverseDecode:
- {
- LONG* p = (LONG*)pPropertyData;
- }
- break;
- case AM_RATE_DecoderPosition:
- {
- AM_DVD_DecoderPosition* p = (AM_DVD_DecoderPosition*)pPropertyData;
- }
- break;
- case AM_RATE_DecoderVersion:
- {
- LONG* p = (LONG*)pPropertyData;
- }
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
- }
- */
- return S_OK;
-}
-
-STDMETHODIMP CMpeg2DecInputPin::QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport)
-{
- if (PropSet != AM_KSPROPSETID_TSRateChange /*&& PropSet != AM_KSPROPSETID_DVD_RateChange*/) {
- return __super::QuerySupported(PropSet, Id, pTypeSupport);
- }
-
- if (PropSet == AM_KSPROPSETID_TSRateChange)
- switch (Id) {
- case AM_RATE_SimpleRateChange:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET | KSPROPERTY_SUPPORT_SET;
- break;
- case AM_RATE_MaxFullDataRate:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET;
- break;
- case AM_RATE_UseRateVersion:
- *pTypeSupport = KSPROPERTY_SUPPORT_SET;
- break;
- case AM_RATE_QueryFullFrameRate:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET;
- break;
- case AM_RATE_QueryLastRateSegPTS:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET;
- break;
- case AM_RATE_CorrectTS:
- *pTypeSupport = KSPROPERTY_SUPPORT_SET;
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
- }
- /*
- if (PropSet == AM_KSPROPSETID_DVD_RateChange)
- switch (Id)
- {
- case AM_RATE_ChangeRate:
- *pTypeSupport = KSPROPERTY_SUPPORT_SET;
- break;
- case AM_RATE_FullDataRateMax:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET;
- break;
- case AM_RATE_ReverseDecode:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET;
- break;
- case AM_RATE_DecoderPosition:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET;
- break;
- case AM_RATE_DecoderVersion:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET;
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
- }
- */
- return S_OK;
-}
-
-//
-// CMpeg2DecOutputPin
-//
-
-CMpeg2DecOutputPin::CMpeg2DecOutputPin(CBaseVideoFilter* pFilter, HRESULT* phr, LPWSTR pName)
- : CBaseVideoOutputPin(NAME("CMpeg2DecOutputPin"), pFilter, phr, pName)
-{
-}
-
-HRESULT CMpeg2DecOutputPin::Active()
-{
- CAutoLock cAutoLock(m_pLock);
-
- // TODO
-
- if (m_Connected && !m_pOutputQueue) {
- HRESULT hr = NOERROR;
-
- m_pOutputQueue.Attach(DEBUG_NEW COutputQueue(m_Connected, &hr));
- if (!m_pOutputQueue) {
- hr = E_OUTOFMEMORY;
- }
-
- if (FAILED(hr)) {
- m_pOutputQueue.Free();
- return hr;
- }
- }
-
- return __super::Active();
-}
-
-HRESULT CMpeg2DecOutputPin::Inactive()
-{
- CAutoLock cAutoLock(m_pLock);
- m_pOutputQueue.Free();
- return __super::Inactive();
-}
-
-HRESULT CMpeg2DecOutputPin::Deliver(IMediaSample* pMediaSample)
-{
- if (!m_pOutputQueue) {
- return NOERROR;
- }
- pMediaSample->AddRef();
- return m_pOutputQueue->Receive(pMediaSample);
-}
-
-HRESULT CMpeg2DecOutputPin::DeliverEndOfStream()
-{
- CallQueue(EOS());
-}
-
-HRESULT CMpeg2DecOutputPin::DeliverBeginFlush()
-{
- CallQueue(BeginFlush());
-}
-
-HRESULT CMpeg2DecOutputPin::DeliverEndFlush()
-{
- CallQueue(EndFlush());
-}
-
-HRESULT CMpeg2DecOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
-{
- CallQueue(NewSegment(tStart, tStop, dRate));
-}
-
-
-//
-// CSubpicInputPin
-//
-
-#define PTS2RT(pts) (10000i64 * pts / 90)
-
-CSubpicInputPin::CSubpicInputPin(CTransformFilter* pFilter, HRESULT* phr)
- : CMpeg2DecInputPin(pFilter, phr, L"SubPicture")
- , m_spon(TRUE)
- , m_fsppal(false)
-{
- m_sppal[0].Y = 0x00;
- m_sppal[0].U = m_sppal[0].V = 0x80;
- m_sppal[1].Y = 0xe0;
- m_sppal[1].U = m_sppal[1].V = 0x80;
- m_sppal[2].Y = 0x80;
- m_sppal[2].U = m_sppal[2].V = 0x80;
- m_sppal[3].Y = 0x20;
- m_sppal[3].U = m_sppal[3].V = 0x80;
-}
-
-HRESULT CSubpicInputPin::CheckMediaType(const CMediaType* mtIn)
-{
- return (mtIn->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK
- || mtIn->majortype == MEDIATYPE_MPEG2_PACK
- || mtIn->majortype == MEDIATYPE_MPEG2_PES
- || mtIn->majortype == MEDIATYPE_Video)
- && (mtIn->subtype == MEDIASUBTYPE_DVD_SUBPICTURE
- || mtIn->subtype == MEDIASUBTYPE_CVD_SUBPICTURE
- || mtIn->subtype == MEDIASUBTYPE_SVCD_SUBPICTURE)
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
-}
-
-HRESULT CSubpicInputPin::SetMediaType(const CMediaType* mtIn)
-{
- return CBasePin::SetMediaType(mtIn);
-}
-
-bool CSubpicInputPin::HasAnythingToRender(REFERENCE_TIME rt)
-{
- if (!IsConnected()) {
- return false;
- }
-
- CAutoLock cAutoLock(&m_csReceive);
-
- POSITION pos = m_sps.GetHeadPosition();
- while (pos) {
- spu* sp = m_sps.GetNext(pos);
- if (sp->m_rtStart <= rt && rt < sp->m_rtStop && (/*sp->m_psphli ||*/ sp->m_fForced || m_spon)) {
- return true;
- }
- }
-
- return false;
-}
-
-void CSubpicInputPin::RenderSubpics(REFERENCE_TIME rt, BYTE** yuv, int w, int h)
-{
- CAutoLock cAutoLock(&m_csReceive);
-
- POSITION pos;
-
- // remove no longer needed things first
- pos = m_sps.GetHeadPosition();
- while (pos) {
- POSITION cur = pos;
- spu* sp = m_sps.GetNext(pos);
- if (sp->m_rtStop <= rt) {
- m_sps.RemoveAt(cur);
- }
- }
-
- pos = m_sps.GetHeadPosition();
- while (pos) {
- spu* sp = m_sps.GetNext(pos);
- if (sp->m_rtStart <= rt && rt < sp->m_rtStop
- && (m_spon || sp->m_fForced && ((static_cast<CMpeg2DecFilter*>(m_pFilter))->IsForcedSubtitlesEnabled() || sp->m_psphli))) {
- sp->Render(rt, yuv, w, h, m_sppal, m_fsppal);
- }
- }
-}
-
-HRESULT CSubpicInputPin::Transform(IMediaSample* pSample)
-{
- HRESULT hr;
-
- AM_MEDIA_TYPE* pmt;
- if (SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
- CMediaType mt(*pmt);
- SetMediaType(&mt);
- DeleteMediaType(pmt);
- }
-
- BYTE* pDataIn = nullptr;
- if (FAILED(hr = pSample->GetPointer(&pDataIn))) {
- return hr;
- }
-
- long len = pSample->GetActualDataLength();
-
- StripPacket(pDataIn, len);
-
- if (len <= 0) {
- return S_FALSE;
- }
-
- if (m_mt.subtype == MEDIASUBTYPE_SVCD_SUBPICTURE) {
- pDataIn += 4;
- len -= 4;
- }
-
- if (len <= 0) {
- return S_FALSE;
- }
-
- CAutoLock cAutoLock(&m_csReceive);
-
- REFERENCE_TIME rtStart = 0, rtStop = 0;
- hr = pSample->GetTime(&rtStart, &rtStop);
-
- bool fRefresh = false;
-
- if (FAILED(hr)) {
- if (!m_sps.IsEmpty()) {
- spu* sp = m_sps.GetTail();
- sp->SetCount(sp->GetCount() + len);
- memcpy(sp->GetData() + sp->GetCount() - len, pDataIn, len);
- }
- } else {
- POSITION pos = m_sps.GetTailPosition();
- while (pos) {
- spu* sp = m_sps.GetPrev(pos);
- if (sp->m_rtStop == _I64_MAX) {
- sp->m_rtStop = rtStart;
- break;
- }
- }
-
- CAutoPtr<spu> p;
-
- if (m_mt.subtype == MEDIASUBTYPE_DVD_SUBPICTURE) {
- p.Attach(DEBUG_NEW dvdspu());
- } else if (m_mt.subtype == MEDIASUBTYPE_CVD_SUBPICTURE) {
- p.Attach(DEBUG_NEW cvdspu());
- } else if (m_mt.subtype == MEDIASUBTYPE_SVCD_SUBPICTURE) {
- p.Attach(DEBUG_NEW svcdspu());
- } else {
- return E_FAIL;
- }
-
- p->m_rtStart = rtStart;
- p->m_rtStop = _I64_MAX;
-
- p->SetCount(len);
- memcpy(p->GetData(), pDataIn, len);
-
- if (m_sphli && p->m_rtStart == PTS2RT(m_sphli->StartPTM)) {
- p->m_psphli = m_sphli;
- fRefresh = true;
- }
-
- m_sps.AddTail(p);
- }
-
- if (!m_sps.IsEmpty()) {
- m_sps.GetTail()->Parse();
- }
-
- if (fRefresh) {
- //((CMpeg2DecFilter*)m_pFilter)->Deliver(true);
- }
-
- return S_FALSE;
-}
-
-STDMETHODIMP CSubpicInputPin::EndFlush()
-{
- CAutoLock cAutoLock(&m_csReceive);
- m_sps.RemoveAll();
- return S_OK;
-}
-
-// IKsPropertySet
-
-STDMETHODIMP CSubpicInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength)
-{
- if (PropSet != AM_KSPROPSETID_DvdSubPic) {
- return __super::Set(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength);
- }
-
- bool fRefresh = false;
-
- switch (Id) {
- case AM_PROPERTY_DVDSUBPIC_PALETTE: {
- CAutoLock cAutoLock(&m_csReceive);
-
- AM_PROPERTY_SPPAL* pSPPAL = (AM_PROPERTY_SPPAL*)pPropertyData;
- memcpy(m_sppal, pSPPAL->sppal, sizeof(AM_PROPERTY_SPPAL));
- m_fsppal = true;
-
- DbgLog((LOG_TRACE, 0, _T("new palette")));
- }
- break;
- case AM_PROPERTY_DVDSUBPIC_HLI: {
- CAutoLock cAutoLock(&m_csReceive);
-
- AM_PROPERTY_SPHLI* pSPHLI = (AM_PROPERTY_SPHLI*)pPropertyData;
-
- m_sphli.Free();
-
- if (pSPHLI->HLISS) {
- POSITION pos = m_sps.GetHeadPosition();
- while (pos) {
- spu* sp = m_sps.GetNext(pos);
- if (sp->m_rtStart <= PTS2RT(pSPHLI->StartPTM) && PTS2RT(pSPHLI->StartPTM) < sp->m_rtStop) {
- fRefresh = true;
- sp->m_psphli.Free();
- sp->m_psphli.Attach(DEBUG_NEW AM_PROPERTY_SPHLI);
- memcpy((AM_PROPERTY_SPHLI*)sp->m_psphli, pSPHLI, sizeof(AM_PROPERTY_SPHLI));
- }
- }
-
- if (!fRefresh) { // save it for later, a subpic might be late for this hli
- m_sphli.Attach(DEBUG_NEW AM_PROPERTY_SPHLI);
- memcpy((AM_PROPERTY_SPHLI*)m_sphli, pSPHLI, sizeof(AM_PROPERTY_SPHLI));
- }
- } else {
- POSITION pos = m_sps.GetHeadPosition();
- while (pos) {
- spu* sp = m_sps.GetNext(pos);
- fRefresh |= !!sp->m_psphli;
- sp->m_psphli.Free();
- }
- }
-
- if (pSPHLI->HLISS)
- DbgLog((LOG_TRACE, 0, _T("hli: %I64d - %I64d, (%d,%d) - (%d,%d)"),
- PTS2RT(pSPHLI->StartPTM) / 10000, PTS2RT(pSPHLI->EndPTM) / 10000,
- pSPHLI->StartX, pSPHLI->StartY, pSPHLI->StopX, pSPHLI->StopY));
- }
- break;
- case AM_PROPERTY_DVDSUBPIC_COMPOSIT_ON: {
- CAutoLock cAutoLock(&m_csReceive);
-
- AM_PROPERTY_COMPOSIT_ON* pCompositOn = (AM_PROPERTY_COMPOSIT_ON*)pPropertyData;
- m_spon = *pCompositOn;
- }
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
- }
-
- if (fRefresh) {
- (static_cast<CMpeg2DecFilter*>(m_pFilter))->Deliver(true);
- }
-
- return S_OK;
-}
-
-STDMETHODIMP CSubpicInputPin::QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport)
-{
- if (PropSet != AM_KSPROPSETID_DvdSubPic) {
- return __super::QuerySupported(PropSet, Id, pTypeSupport);
- }
-
- switch (Id) {
- case AM_PROPERTY_DVDSUBPIC_PALETTE:
- *pTypeSupport = KSPROPERTY_SUPPORT_SET;
- break;
- case AM_PROPERTY_DVDSUBPIC_HLI:
- *pTypeSupport = KSPROPERTY_SUPPORT_SET;
- break;
- case AM_PROPERTY_DVDSUBPIC_COMPOSIT_ON:
- *pTypeSupport = KSPROPERTY_SUPPORT_SET;
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
- }
-
- return S_OK;
-}
-
-// CSubpicInputPin::spu
-
-static __inline BYTE GetNibble(BYTE* p, DWORD* offset, int& nField, int& fAligned)
-{
- BYTE ret = (p[offset[nField]] >> (fAligned << 2)) & 0x0f;
- offset[nField] += 1 - fAligned;
- fAligned = !fAligned;
- return ret;
-}
-
-static __inline BYTE GetHalfNibble(BYTE* p, DWORD* offset, int& nField, int& n)
-{
- BYTE ret = (p[offset[nField]] >> (n << 1)) & 0x03;
- if (!n) {
- offset[nField]++;
- }
- n = (n - 1 + 4) & 3;
- return ret;
-}
-
-static __inline void DrawPixel(BYTE** yuv, CPoint pt, int pitch, AM_DVD_YUV& c)
-{
- if (c.Reserved == 0) {
- return;
- }
-
- BYTE* p = &yuv[0][pt.y * pitch + pt.x];
- //*p = (*p*(15-contrast) + sppal[color].Y*contrast)>>4;
- *p -= (*p - c.Y) * c.Reserved >> 4;
-
- if (pt.y & 1) {
- return; // since U/V is half res there is no need to overwrite the same line again
- }
-
- pt.x = (pt.x + 1) / 2;
- pt.y = (pt.y /*+ 1*/) / 2; // only paint the upper field always, don't round it
- pitch /= 2;
-
- // U/V is exchanged? wierd but looks true when comparing the outputted colors from other decoders
-
- p = &yuv[1][pt.y * pitch + pt.x];
- //*p = (BYTE)(((((int)*p-0x80)*(15-contrast) + ((int)sppal[color].V-0x80)*contrast) >> 4) + 0x80);
- *p -= (*p - c.V) * c.Reserved >> 4;
-
- p = &yuv[2][pt.y * pitch + pt.x];
- //*p = (BYTE)(((((int)*p-0x80)*(15-contrast) + ((int)sppal[color].U-0x80)*contrast) >> 4) + 0x80);
- *p -= (*p - c.U) * c.Reserved >> 4;
-
- // Neighter of the blending formulas are accurate (">>4" should be "/15").
- // Even though the second one is a bit worse, since we are scaling the difference only,
- // the error is still not noticable.
-}
-
-static __inline void DrawPixels(BYTE** yuv, int pitch, CPoint pt, int len, AM_DVD_YUV& c, CRect& rc)
-{
- if (pt.y < rc.top || pt.y >= rc.bottom) {
- return;
- }
- if (pt.x < rc.left) {
- len -= rc.left - pt.x;
- pt.x = rc.left;
- }
- if (pt.x + len > rc.right) {
- len = rc.right - pt.x;
- }
- if (len <= 0 || pt.x >= rc.right) {
- return;
- }
-
- if (c.Reserved == 0) {
- if (rc.IsRectEmpty()) {
- return;
- }
-
- if (pt.y < rc.top || pt.y >= rc.bottom
- || pt.x + len < rc.left || pt.x >= rc.right) {
- return;
- }
- }
-
- while (len-- > 0) {
- DrawPixel(yuv, pt, pitch, c);
- pt.x++;
- }
-}
-
-// CSubpicInputPin::dvdspu
-
-bool CSubpicInputPin::dvdspu::Parse()
-{
- m_offsets.RemoveAll();
-
- BYTE* p = GetData();
-
- WORD packetsize = (p[0] << 8) | p[1];
- WORD datasize = (p[2] << 8) | p[3];
-
- if (packetsize > GetCount() || datasize > packetsize) {
- return false;
- }
-
- int i, next = datasize;
-
-#define GetWORD (p[i] << 8) | p[i+1]; i += 2
-
- do {
- i = next;
-
- int pts = GetWORD;
- next = GetWORD;
-
- if (next > packetsize || next < datasize) {
- return false;
- }
-
- REFERENCE_TIME rt = m_rtStart + 1024 * PTS2RT(pts);
-
- for (bool fBreak = false; !fBreak;) {
- int len = 0;
-
- switch (p[i]) {
- case 0x00:
- len = 0;
- break;
- case 0x01:
- len = 0;
- break;
- case 0x02:
- len = 0;
- break;
- case 0x03:
- len = 2;
- break;
- case 0x04:
- len = 2;
- break;
- case 0x05:
- len = 6;
- break;
- case 0x06:
- len = 4;
- break;
- case 0x07:
- len = 0;
- break; // TODO
- default:
- len = 0;
- break;
- }
-
- if (i + len >= packetsize) {
- TRACE(_T("Warning: Wrong subpicture parameter block ending\n"));
- break;
- }
-
- switch (p[i++]) {
- case 0x00: // forced start displaying
- m_fForced = true;
- break;
- case 0x01: // normal start displaying
- m_fForced = false;
- break;
- case 0x02: // stop displaying
- m_rtStop = rt;
- break;
- case 0x03:
- m_sphli.ColCon.emph2col = p[i] >> 4;
- m_sphli.ColCon.emph1col = p[i] & 0xf;
- m_sphli.ColCon.patcol = p[i + 1] >> 4;
- m_sphli.ColCon.backcol = p[i + 1] & 0xf;
- i += 2;
- break;
- case 0x04:
- m_sphli.ColCon.emph2con = p[i] >> 4;
- m_sphli.ColCon.emph1con = p[i] & 0xf;
- m_sphli.ColCon.patcon = p[i + 1] >> 4;
- m_sphli.ColCon.backcon = p[i + 1] & 0xf;
- i += 2;
- break;
- case 0x05:
- m_sphli.StartX = (p[i] << 4) + (p[i + 1] >> 4);
- m_sphli.StopX = ((p[i + 1] & 0x0f) << 8) + p[i + 2] + 1;
- m_sphli.StartY = (p[i + 3] << 4) + (p[i + 4] >> 4);
- m_sphli.StopY = ((p[i + 4] & 0x0f) << 8) + p[i + 5] + 1;
- i += 6;
- break;
- case 0x06:
- m_offset[0] = GetWORD;
- m_offset[1] = GetWORD;
- break;
- case 0x07:
- // TODO
- break;
- case 0xff: // end of ctrlblk
- fBreak = true;
- continue;
- default: // skip this ctrlblk
- fBreak = true;
- break;
- }
- }
-
- offset_t o = {rt, m_sphli};
- m_offsets.AddTail(o); // is it always going to be sorted?
- } while (i <= next && i < packetsize);
-
- return true;
-}
-
-void CSubpicInputPin::dvdspu::Render(REFERENCE_TIME rt, BYTE** yuv, int w, int h, AM_DVD_YUV* sppal, bool fsppal)
-{
- BYTE* p = GetData();
- DWORD offset[2] = {m_offset[0], m_offset[1]};
-
- AM_PROPERTY_SPHLI sphli = m_sphli;
- CPoint pt(sphli.StartX, sphli.StartY);
- CRect rc(pt, CPoint(sphli.StopX, sphli.StopY));
-
- CRect rcclip(0, 0, w, h);
- rcclip &= rc;
-
- if (m_psphli) {
- rcclip &= CRect(m_psphli->StartX, m_psphli->StartY, m_psphli->StopX, m_psphli->StopY);
- sphli = *m_psphli;
- } else if (m_offsets.GetCount() > 1) {
- POSITION pos = m_offsets.GetTailPosition();
- while (pos) {
- const offset_t& o = m_offsets.GetPrev(pos);
- if (rt >= o.rt) {
- sphli = o.sphli;
- break;
- }
- }
- }
-
- AM_DVD_YUV pal[4];
- pal[0] = sppal[fsppal ? sphli.ColCon.backcol : 0];
- pal[0].Reserved = sphli.ColCon.backcon;
- pal[1] = sppal[fsppal ? sphli.ColCon.patcol : 1];
- pal[1].Reserved = sphli.ColCon.patcon;
- pal[2] = sppal[fsppal ? sphli.ColCon.emph1col : 2];
- pal[2].Reserved = sphli.ColCon.emph1con;
- pal[3] = sppal[fsppal ? sphli.ColCon.emph2col : 3];
- pal[3].Reserved = sphli.ColCon.emph2con;
-
- int nField = 0;
- int fAligned = 1;
-
- DWORD end[2] = {offset[1], (p[2] << 8) | p[3]};
-
- while ((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1])) {
- DWORD code;
-
- if ((code = GetNibble(p, offset, nField, fAligned)) >= 0x4
- || (code = (code << 4) | GetNibble(p, offset, nField, fAligned)) >= 0x10
- || (code = (code << 4) | GetNibble(p, offset, nField, fAligned)) >= 0x40
- || (code = (code << 4) | GetNibble(p, offset, nField, fAligned)) >= 0x100) {
- DrawPixels(yuv, w, pt, code >> 2, pal[code & 3], rcclip);
- if ((pt.x += code >> 2) < rc.right) {
- continue;
- }
- }
-
- DrawPixels(yuv, w, pt, rc.right - pt.x, pal[code & 3], rcclip);
-
- if (!fAligned) {
- GetNibble(p, offset, nField, fAligned); // align to byte
- }
-
- pt.x = rc.left;
- pt.y++;
- nField = 1 - nField;
- }
-}
-
-// CSubpicInputPin::cvdspu
-
-bool CSubpicInputPin::cvdspu::Parse()
-{
- BYTE* p = GetData();
-
- WORD packetsize = (p[0] << 8) | p[1];
- WORD datasize = (p[2] << 8) | p[3];
-
- if (packetsize > GetCount() || datasize > packetsize) {
- return false;
- }
-
- p = GetData() + datasize;
-
- for (int i = datasize, j = packetsize - 4; i <= j; i += 4, p += 4) {
- switch (p[0]) {
- case 0x0c:
- break;
- case 0x04:
- m_rtStop = m_rtStart + 10000i64 * ((p[1] << 16) | (p[2] << 8) | p[3]) / 90;
- break;
- case 0x17:
- m_sphli.StartX = ((p[1] & 0x0f) << 6) + (p[2] >> 2);
- m_sphli.StartY = ((p[2] & 0x03) << 8) + p[3];
- break;
- case 0x1f:
- m_sphli.StopX = ((p[1] & 0x0f) << 6) + (p[2] >> 2);
- m_sphli.StopY = ((p[2] & 0x03) << 8) + p[3];
- break;
- case 0x24:
- case 0x25:
- case 0x26:
- case 0x27:
- m_sppal[0][p[0] - 0x24].Y = p[1];
- m_sppal[0][p[0] - 0x24].U = p[2];
- m_sppal[0][p[0] - 0x24].V = p[3];
- break;
- case 0x2c:
- case 0x2d:
- case 0x2e:
- case 0x2f:
- m_sppal[1][p[0] - 0x2c].Y = p[1];
- m_sppal[1][p[0] - 0x2c].U = p[2];
- m_sppal[1][p[0] - 0x2c].V = p[3];
- break;
- case 0x37:
- m_sppal[0][3].Reserved = p[2] >> 4;
- m_sppal[0][2].Reserved = p[2] & 0xf;
- m_sppal[0][1].Reserved = p[3] >> 4;
- m_sppal[0][0].Reserved = p[3] & 0xf;
- break;
- case 0x3f:
- m_sppal[1][3].Reserved = p[2] >> 4;
- m_sppal[1][2].Reserved = p[2] & 0xf;
- m_sppal[1][1].Reserved = p[3] >> 4;
- m_sppal[1][0].Reserved = p[3] & 0xf;
- break;
- case 0x47:
- m_offset[0] = (p[2] << 8) | p[3];
- break;
- case 0x4f:
- m_offset[1] = (p[2] << 8) | p[3];
- break;
- default:
- break;
- }
- }
-
- return true;
-}
-
-void CSubpicInputPin::cvdspu::Render(REFERENCE_TIME rt, BYTE** yuv, int w, int h, AM_DVD_YUV* sppal, bool fsppal)
-{
- BYTE* p = GetData();
- DWORD offset[2] = {m_offset[0], m_offset[1]};
-
- CRect rcclip(0, 0, w, h);
-
- /* FIXME: startx/y looks to be wrong in the sample I tested
- CPoint pt(m_sphli.StartX, m_sphli.StartY);
- CRect rc(pt, CPoint(m_sphli.StopX, m_sphli.StopY));
- */
-
- CSize size(m_sphli.StopX - m_sphli.StartX, m_sphli.StopY - m_sphli.StartY);
- CPoint pt((rcclip.Width() - size.cx) / 2, (rcclip.Height() * 3 - size.cy * 1) / 4);
- CRect rc(pt, size);
-
- int nField = 0;
- int fAligned = 1;
-
- DWORD end[2] = {offset[1], (p[2] << 8) | p[3]};
-
- while ((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1])) {
- BYTE code;
-
- if ((code = GetNibble(p, offset, nField, fAligned)) >= 0x4) {
- DrawPixels(yuv, w, pt, code >> 2, m_sppal[0][code & 3], rcclip);
- pt.x += code >> 2;
- continue;
- }
-
- code = GetNibble(p, offset, nField, fAligned);
- DrawPixels(yuv, w, pt, rc.right - pt.x, m_sppal[0][code & 3], rcclip);
-
- if (!fAligned) {
- GetNibble(p, offset, nField, fAligned); // align to byte
- }
-
- pt.x = rc.left;
- pt.y++;
- nField = 1 - nField;
- }
-}
-
-// CSubpicInputPin::svcdspu
-
-bool CSubpicInputPin::svcdspu::Parse()
-{
- BYTE* p = GetData();
- BYTE* p0 = p;
-
- if (GetCount() < 2) {
- return false;
- }
-
- WORD packetsize = (p[0] << 8) | p[1];
- p += 2;
-
- if (packetsize > GetCount()) {
- return false;
- }
-
- bool duration = !!(*p++ & 0x04);
-
- p++; // unknown
-
- if (duration) {
- m_rtStop = m_rtStart + 10000i64 * ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]) / 90;
- p += 4;
- }
-
- m_sphli.StartX = m_sphli.StopX = (p[0] << 8) | p[1];
- p += 2;
- m_sphli.StartY = m_sphli.StopY = (p[0] << 8) | p[1];
- p += 2;
- m_sphli.StopX += (p[0] << 8) | p[1];
- p += 2;
- m_sphli.StopY += (p[0] << 8) | p[1];
- p += 2;
-
- for (int i = 0; i < 4; i++) {
- m_sppal[i].Y = *p++;
- m_sppal[i].U = *p++;
- m_sppal[i].V = *p++;
- m_sppal[i].Reserved = *p++ >> 4;
- }
-
- if (*p++ & 0xc0) {
- p += 4; // duration of the shift operation should be here, but it is untested
- }
-
- m_offset[1] = (p[0] << 8) | p[1];
- p += 2;
-
- m_offset[0] = p - p0;
- m_offset[1] += m_offset[0];
-
- return true;
-}
-
-void CSubpicInputPin::svcdspu::Render(REFERENCE_TIME rt, BYTE** yuv, int w, int h, AM_DVD_YUV* sppal, bool fsppal)
-{
- BYTE* p = GetData();
- DWORD offset[2] = {m_offset[0], m_offset[1]};
-
- CRect rcclip(0, 0, w, h);
-
- /* FIXME: startx/y looks to be wrong in the sample I tested (yes, this one too!)
- CPoint pt(m_sphli.StartX, m_sphli.StartY);
- CRect rc(pt, CPoint(m_sphli.StopX, m_sphli.StopY));
- */
-
- CSize size(m_sphli.StopX - m_sphli.StartX, m_sphli.StopY - m_sphli.StartY);
- CPoint pt((rcclip.Width() - size.cx) / 2, (rcclip.Height() * 3 - size.cy * 1) / 4);
- CRect rc(pt, size);
-
- int nField = 0;
- int n = 3;
-
- DWORD end[2] = {offset[1], (p[2] << 8) | p[3]};
-
- while ((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1])) {
- BYTE code = GetHalfNibble(p, offset, nField, n);
- BYTE repeat = 1 + (code == 0 ? GetHalfNibble(p, offset, nField, n) : 0);
-
- DrawPixels(yuv, w, pt, repeat, m_sppal[code & 3], rcclip);
- if ((pt.x += repeat) < rc.right) {
- continue;
- }
-
- while (n != 3) {
- GetHalfNibble(p, offset, nField, n); // align to byte
- }
-
- pt.x = rc.left;
- pt.y++;
- nField = 1 - nField;
- }
-}
-
-//
-// CClosedCaptionOutputPin
-//
-
-CClosedCaptionOutputPin::CClosedCaptionOutputPin(CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
- : CBaseOutputPin(NAME("CClosedCaptionOutputPin"), pFilter, pLock, phr, L"~CC")
-{
-}
-
-HRESULT CClosedCaptionOutputPin::CheckMediaType(const CMediaType* mtOut)
-{
- return mtOut->majortype == MEDIATYPE_AUXLine21Data && mtOut->subtype == MEDIASUBTYPE_Line21_GOPPacket
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
-}
-
-HRESULT CClosedCaptionOutputPin::GetMediaType(int iPosition, CMediaType* pmt)
-{
- if (iPosition < 0) {
- return E_INVALIDARG;
- }
- if (iPosition > 0) {
- return VFW_S_NO_MORE_ITEMS;
- }
-
- pmt->InitMediaType();
- pmt->majortype = MEDIATYPE_AUXLine21Data;
- pmt->subtype = MEDIASUBTYPE_Line21_GOPPacket;
- pmt->formattype = FORMAT_None;
-
- return S_OK;
-}
-
-HRESULT CClosedCaptionOutputPin::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
-{
- pProperties->cBuffers = 1;
- pProperties->cbBuffer = 2048;
- pProperties->cbAlign = 1;
- pProperties->cbPrefix = 0;
-
- HRESULT hr;
- ALLOCATOR_PROPERTIES Actual;
- if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
- return hr;
- }
-
- return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR;
-}
-
-HRESULT CClosedCaptionOutputPin::Deliver(const void* ptr, int len)
-{
- HRESULT hr = S_FALSE;
-
- if (len > 4 && ptr && *(DWORD*)ptr == 0xf8014343 && IsConnected()) {
- CComPtr<IMediaSample> pSample;
- GetDeliveryBuffer(&pSample, nullptr, nullptr, 0);
- BYTE* pData = nullptr;
- pSample->GetPointer(&pData);
- *(DWORD*)pData = 0xb2010000;
- memcpy(pData + 4, ptr, len);
- pSample->SetActualDataLength(len + 4);
- hr = __super::Deliver(pSample);
- }
-
- return hr;
-}
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.def b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.def
deleted file mode 100644
index 6492e5cd6..000000000
--- a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.def
+++ /dev/null
@@ -1,5 +0,0 @@
-EXPORTS
- DllCanUnloadNow PRIVATE
- DllGetClassObject PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.h b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.h
deleted file mode 100644
index aa48e2ab8..000000000
--- a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.h
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <atlcoll.h>
-#include <videoacc.h>
-#include "../../../DeCSS/DeCSSInputPin.h"
-#include "../BaseVideoFilter/BaseVideoFilter.h"
-#include "IMpeg2DecFilter.h"
-#include "Mpeg2DecSettingsWnd.h"
-
-#ifdef MPEG2ONLY
-#define Mpeg2DecFilterName L"MPC MPEG-2 Video Decoder"
-#else
-#define Mpeg2DecFilterName L"MPC MPEG Video Decoder"
-#endif
-
-class CSubpicInputPin;
-class CClosedCaptionOutputPin;
-class CMpeg2Dec;
-
-class __declspec(uuid("39F498AF-1A09-4275-B193-673B0BA3D478"))
- CMpeg2DecFilter
- : public CBaseVideoFilter
- , public IMpeg2DecFilter
- , public ISpecifyPropertyPages2
-{
- CSubpicInputPin* m_pSubpicInput;
- CClosedCaptionOutputPin* m_pClosedCaptionOutput;
-
- CAutoPtr<CMpeg2Dec> m_dec;
-
- REFERENCE_TIME m_AvgTimePerFrame;
- bool m_fWaitForKeyFrame;
- bool m_fInitializedBuffer;
- CSize m_par;
-
- struct framebuf {
- int w, h, pitch;
- BYTE* buf_base;
- BYTE* buf[6];
- REFERENCE_TIME rtStart, rtStop;
- DWORD flags;
- ditype di;
- framebuf()
- : di(DIAuto) {
- w = h = pitch = 0;
- buf_base = nullptr;
- ZeroMemory(&buf, sizeof(buf));
- rtStart = rtStop = 0;
- flags = 0;
- }
- ~framebuf() {
- Free();
- }
- void Alloc(int w, int h, int pitch) {
- Free(); // Ensure there is no memory leak
- this->w = w;
- this->h = h;
- this->pitch = pitch;
- int size = pitch * h;
- buf_base = (BYTE*)_aligned_malloc(size * 3 + 6 * 32, 32);
- BYTE* p = buf_base;
- buf[0] = p;
- p += (size + 31) & ~31;
- buf[3] = p;
- p += (size + 31) & ~31;
- buf[1] = p;
- p += (size / 4 + 31) & ~31;
- buf[4] = p;
- p += (size / 4 + 31) & ~31;
- buf[2] = p;
- p += (size / 4 + 31) & ~31;
- buf[5] = p;
- p += (size / 4 + 31) & ~31;
- }
- void Free() {
- if (buf_base) {
- _aligned_free(buf_base);
- }
- buf_base = nullptr;
- }
- } m_fb;
-
- bool m_fFilm;
- void SetDeinterlaceMethod();
- void SetTypeSpecificFlags(IMediaSample* pMS);
-
- AM_SimpleRateChange m_rate;
-
-protected:
- void InputTypeChanged();
- HRESULT Transform(IMediaSample* pIn);
- bool IsVideoInterlaced();
- void UpdateAspectRatio();
-
-public:
- CMpeg2DecFilter(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CMpeg2DecFilter();
-
- virtual void GetOutputSize(int& w, int& h, int& arx, int& ary, int& RealWidth, int& RealHeight);
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- HRESULT DeliverFast();
- HRESULT DeliverNormal();
- HRESULT Deliver(bool fRepeatLast);
-
- int GetPinCount();
- CBasePin* GetPin(int n);
-
- HRESULT EndOfStream();
- HRESULT BeginFlush();
- HRESULT EndFlush();
- HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
-
- HRESULT CheckConnect(PIN_DIRECTION dir, IPin* pPin);
- HRESULT CheckInputType(const CMediaType* mtIn);
- HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
- HRESULT SetMediaType(PIN_DIRECTION dir, const CMediaType* pmt);
-
- HRESULT StartStreaming();
- HRESULT StopStreaming();
-
- bool m_fDropFrames;
- HRESULT AlterQuality(Quality q);
-
-protected:
- CCritSec m_csProps;
- ditype m_ditype;
- float m_bright, m_cont, m_hue, m_sat;
- BYTE m_YTbl[256], m_UTbl[256 * 256], m_VTbl[256 * 256];
- bool m_fForcedSubs;
- bool m_fPlanarYUV;
- bool m_fInterlaced;
- bool m_bReadARFromStream;
-
- static void CalcBrCont(BYTE* YTbl, float bright, float cont);
- static void CalcHueSat(BYTE* UTbl, BYTE* VTbl, float hue, float sat);
- void ApplyBrContHueSat(BYTE* srcy, BYTE* srcu, BYTE* srcv, int w, int h, int pitch);
-
-public:
-
- // ISpecifyPropertyPages2
-
- STDMETHODIMP GetPages(CAUUID* pPages);
- STDMETHODIMP CreatePage(const GUID& guid, IPropertyPage** ppPage);
-
- // IMpeg2DecFilter
-
- STDMETHODIMP SetDeinterlaceMethod(ditype di);
- STDMETHODIMP_(ditype) GetDeinterlaceMethod();
-
- STDMETHODIMP SetBrightness(float bright);
- STDMETHODIMP SetContrast(float cont);
- STDMETHODIMP SetHue(float hue);
- STDMETHODIMP SetSaturation(float sat);
- STDMETHODIMP_(float) GetBrightness();
- STDMETHODIMP_(float) GetContrast();
- STDMETHODIMP_(float) GetHue();
- STDMETHODIMP_(float) GetSaturation();
-
- STDMETHODIMP EnableForcedSubtitles(bool fEnable);
- STDMETHODIMP_(bool) IsForcedSubtitlesEnabled();
-
- STDMETHODIMP EnablePlanarYUV(bool fEnable);
- STDMETHODIMP_(bool) IsPlanarYUVEnabled();
- STDMETHODIMP Apply();
- // IMpeg2DecFilter2
-
- STDMETHODIMP EnableInterlaced(bool fEnable);
- STDMETHODIMP_(bool) IsInterlacedEnabled();
-
- STDMETHODIMP EnableReadARFromStream(bool fEnable);
- STDMETHODIMP_(bool) IsReadARFromStreamEnabled();
-};
-
-class CMpeg2DecInputPin : public CDeCSSInputPin
-{
- LONG m_CorrectTS;
-
-public:
- CMpeg2DecInputPin(CTransformFilter* pFilter, HRESULT* phr, LPWSTR pName);
-
- CCritSec m_csRateLock;
- AM_SimpleRateChange m_ratechange;
-
- // IKsPropertySet
- STDMETHODIMP Set(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData, ULONG DataLength);
- STDMETHODIMP Get(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData, ULONG DataLength, ULONG* pBytesReturned);
- STDMETHODIMP QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport);
-};
-
-class CMpeg2DecOutputPin : public CBaseVideoOutputPin
-{
-public:
- CMpeg2DecOutputPin(CBaseVideoFilter* pFilter, HRESULT* phr, LPWSTR pName);
-
- CAutoPtr<COutputQueue> m_pOutputQueue;
-
- HRESULT Active();
- HRESULT Inactive();
-
- HRESULT Deliver(IMediaSample* pMediaSample);
- HRESULT DeliverEndOfStream();
- HRESULT DeliverBeginFlush();
- HRESULT DeliverEndFlush();
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
-};
-
-class CSubpicInputPin : public CMpeg2DecInputPin
-{
- CCritSec m_csReceive;
-
- AM_PROPERTY_COMPOSIT_ON m_spon;
- AM_DVD_YUV m_sppal[16];
- bool m_fsppal;
- CAutoPtr<AM_PROPERTY_SPHLI> m_sphli; // temp
-
- class spu : public CAtlArray<BYTE>
- {
- public:
- bool m_fForced;
- REFERENCE_TIME m_rtStart, m_rtStop;
- DWORD m_offset[2];
- AM_PROPERTY_SPHLI m_sphli; // parsed
- CAutoPtr<AM_PROPERTY_SPHLI> m_psphli; // for the menu (optional)
- spu() {
- ZeroMemory(&m_sphli, sizeof(m_sphli));
- m_fForced = false;
- m_rtStart = m_rtStop = 0;
- }
- virtual ~spu() {}
- virtual bool Parse() = 0;
- virtual void Render(REFERENCE_TIME rt, BYTE** p, int w, int h, AM_DVD_YUV* sppal, bool fsppal) = 0;
- };
-
- class dvdspu : public spu
- {
- public:
- struct offset_t {
- REFERENCE_TIME rt;
- AM_PROPERTY_SPHLI sphli;
- };
- CAtlList<offset_t> m_offsets;
- bool Parse();
- void Render(REFERENCE_TIME rt, BYTE** p, int w, int h, AM_DVD_YUV* sppal, bool fsppal);
- };
-
- class cvdspu : public spu
- {
- public:
- AM_DVD_YUV m_sppal[2][4];
- cvdspu() {
- ZeroMemory(m_sppal, sizeof(m_sppal));
- }
- bool Parse();
- void Render(REFERENCE_TIME rt, BYTE** p, int w, int h, AM_DVD_YUV* sppal, bool fsppal);
- };
-
- class svcdspu : public spu
- {
- public:
- AM_DVD_YUV m_sppal[4];
- svcdspu() {
- ZeroMemory(m_sppal, sizeof(m_sppal));
- }
- bool Parse();
- void Render(REFERENCE_TIME rt, BYTE** p, int w, int h, AM_DVD_YUV* sppal, bool fsppal);
- };
-
- CAutoPtrList<spu> m_sps;
-
-protected:
- HRESULT Transform(IMediaSample* pSample);
-
-public:
- CSubpicInputPin(CTransformFilter* pFilter, HRESULT* phr);
-
- bool HasAnythingToRender(REFERENCE_TIME rt);
- void RenderSubpics(REFERENCE_TIME rt, BYTE** p, int w, int h);
-
- HRESULT CheckMediaType(const CMediaType* mtIn);
- HRESULT SetMediaType(const CMediaType* mtIn);
-
- // we shouldn't pass these to the filter from this pin
- STDMETHODIMP EndOfStream() { return S_OK; }
- STDMETHODIMP BeginFlush() { return S_OK; }
- STDMETHODIMP EndFlush();
- STDMETHODIMP NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate) { return S_OK; }
-
- // IKsPropertySet
- STDMETHODIMP Set(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData, ULONG DataLength);
- STDMETHODIMP QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport);
-};
-
-class CClosedCaptionOutputPin : public CBaseOutputPin
-{
-public:
- CClosedCaptionOutputPin(CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
-
- HRESULT CheckMediaType(const CMediaType* mtOut);
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
- HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
-
- CMediaType& CurrentMediaType() { return m_mt; }
-
- HRESULT Deliver(const void* ptr, int len);
-};
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.rc b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.rc
deleted file mode 100644
index 0a5b8560f..000000000
--- a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.rc
+++ /dev/null
@@ -1,124 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-#include "version.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (United States) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION MPC_VERSION_NUM
- PRODUCTVERSION MPC_VERSION_NUM
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS VOS_NT_WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE VFT2_UNKNOWN
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", MPC_VERSION_COMMENTS
- VALUE "CompanyName", MPC_COMP_NAME_STR
- VALUE "FileDescription", "MPEG-2 Decoder Filter for DirectShow"
- VALUE "FileVersion", MPC_VERSION_STR_FULL
- VALUE "InternalName", "Mpeg2Dec Filter"
- VALUE "LegalCopyright", MPC_COPYRIGHT_STR
- VALUE "OriginalFilename", "Mpeg2DecFilter.ax"
- VALUE "ProductName", "Mpeg2Dec Filter"
- VALUE "ProductVersion", MPC_VERSION_STR_FULL
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// String Table
-//
-
-STRINGTABLE
-BEGIN
- IDS_FILTER_SETTINGS_CAPTION "Settings"
- IDS_MPEG2_ENABLE_PLANAR "Enable planar YUV media types (VY12, I420, IYUY)"
- IDS_MPEG2_INTERLACE_FLAG "Set interlaced flag in output media type"
- IDS_MPEG2_FORCED_SUBS "Always display forced subtitles"
- IDS_MPEG2_DEINTERLACING "Deinterlacing"
- IDS_MPEG2_BRIGHTNESS "Brightness"
- IDS_MPEG2_RESET "Reset"
- IDS_MPEG2_NOTE1 "Note: Using a non-planar output format, bob deinterlacer, or adjusting color properies can degrade performance. ""Auto"" deinterlacer will switch to ""Blend"" when necessary."
- IDS_MPEG2_CONTRAST "Contrast"
- IDS_MPEG2_HUE "Hue"
- IDS_MPEG2_SATURATION "Saturation"
- IDS_MPEG2_READ_AR "Read AR from stream"
-END
-
-#endif // English (United States) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.vcxproj b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.vcxproj
deleted file mode 100644
index 573c6b3f0..000000000
--- a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.vcxproj
+++ /dev/null
@@ -1,277 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug Filter|Win32">
- <Configuration>Debug Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug Filter|x64">
- <Configuration>Debug Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|Win32">
- <Configuration>Release Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|x64">
- <Configuration>Release Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{305BAB2D-0D75-4FBC-8BCD-A2917392B48C}</ProjectGuid>
- <RootNamespace>Mpeg2DecFilter</RootNamespace>
- <Keyword>MFCProj</Keyword>
- <ProjectName>Mpeg2DecFilter</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <Import Project="..\..\..\platform.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">.ax</TargetExt>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>detours.lib;idct_mmx.obj;motion_comp_mmx.obj;Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(SolutionDir)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <IgnoreSpecificDefaultLibraries>LIBCMT;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
- <ModuleDefinitionFile>Mpeg2DecFilter.def</ModuleDefinitionFile>
- <ImageHasSafeExceptionHandlers Condition="'$(PlatformToolsetVersion)'=='110'">false</ImageHasSafeExceptionHandlers>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalLibraryDirectories>$(SolutionDir)lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <ImageHasSafeExceptionHandlers Condition="'$(PlatformToolsetVersion)'=='110'">false</ImageHasSafeExceptionHandlers>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>MPEG2ONLY;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- <Link>
- <AdditionalDependencies>detours.lib;idct_mmx.obj;motion_comp_mmx.obj;Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(SolutionDir)lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <ModuleDefinitionFile>Mpeg2DecFilter.def</ModuleDefinitionFile>
- <ImageHasSafeExceptionHandlers Condition="'$(PlatformToolsetVersion)'=='110'">false</ImageHasSafeExceptionHandlers>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>MPEG2ONLY;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- <Link>
- <AdditionalLibraryDirectories>$(SolutionDir)lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <ImageHasSafeExceptionHandlers Condition="'$(PlatformToolsetVersion)'=='110'">false</ImageHasSafeExceptionHandlers>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- <Lib>
- <AdditionalDependencies>idct_mmx.obj;motion_comp_mmx.obj;%(AdditionalDependencies)</AdditionalDependencies>
- </Lib>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- <Lib>
- <AdditionalDependencies>idct_mmx.obj;motion_comp_mmx.obj;%(AdditionalDependencies)</AdditionalDependencies>
- </Lib>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="idct_sse2.cpp" />
- <ClCompile Include="libmpeg2.cpp" />
- <ClCompile Include="mc_sse2.cpp" />
- <ClCompile Include="Mpeg2DecFilter.cpp" />
- <ClCompile Include="Mpeg2DecSettingsWnd.cpp" />
- <ClCompile Include="stdafx.cpp">
- <PrecompiledHeader>Create</PrecompiledHeader>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="attributes.h" />
- <ClInclude Include="IMpeg2DecFilter.h" />
- <ClInclude Include="libmpeg2.h" />
- <ClInclude Include="Mpeg2DecFilter.h" />
- <ClInclude Include="Mpeg2DecSettingsWnd.h" />
- <ClInclude Include="resource.h">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ClInclude>
- <ClInclude Include="..\..\..\DSUtil\simd.h" />
- <ClInclude Include="..\..\..\DSUtil\simd_common.h" />
- <ClInclude Include="..\..\..\DSUtil\simd_instructions.h" />
- <ClInclude Include="stdafx.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="Mpeg2DecFilter.rc">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ResourceCompile>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\DeCSS\DeCSS.vcxproj">
- <Project>{1a2dfd1a-3c6c-44d1-909d-294af646b575}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\DSUtil\DSUtil.vcxproj">
- <Project>{fc70988b-1ae5-4381-866d-4f405e28ac42}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\Kasumi\Kasumi.vcxproj">
- <Project>{0d252872-7542-4232-8d02-53f9182aee15}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\system\system.vcxproj">
- <Project>{c2082189-3ecb-4079-91fa-89d3c8a305c0}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\BaseClasses\BaseClasses.vcxproj">
- <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\Filters.vcxproj">
- <Project>{273b3149-3192-4b75-a791-470320b90812}</Project>
- </ProjectReference>
- <ProjectReference Include="..\BaseVideoFilter\BaseVideoFilter.vcxproj">
- <Project>{54dda60f-e528-4d07-a152-960a1e818680}</Project>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.vcxproj.filters b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.vcxproj.filters
deleted file mode 100644
index 54d431f5f..000000000
--- a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.vcxproj.filters
+++ /dev/null
@@ -1,83 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{fbdabc83-2c4a-4281-b29b-3deb304adccb}</UniqueIdentifier>
- <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{414034fb-1cd9-46a4-96c8-07498ccee353}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{135298f9-de49-4e12-a042-b10b9c34a459}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="idct_sse2.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="libmpeg2.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="mc_sse2.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="Mpeg2DecFilter.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="Mpeg2DecSettingsWnd.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="stdafx.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="attributes.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="IMpeg2DecFilter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="libmpeg2.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="Mpeg2DecFilter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="Mpeg2DecSettingsWnd.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="resource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\..\..\DSUtil\simd.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\..\..\DSUtil\simd_common.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\..\..\DSUtil\simd_instructions.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="stdafx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="Mpeg2DecFilter.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.cpp b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.cpp
deleted file mode 100644
index d0c054a59..000000000
--- a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.cpp
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "resource.h"
-#include "Mpeg2DecSettingsWnd.h"
-#include "../../../DSUtil/DSUtil.h"
-
-
-//
-// CMpeg2DecSettingsWnd
-//
-
-static TCHAR m_strBrightness[100];
-static TCHAR m_strContrast[100];
-static TCHAR m_strHue[100];
-static TCHAR m_strSaturation[100];
-
-CMpeg2DecSettingsWnd::CMpeg2DecSettingsWnd()
-{
- wcscpy_s(m_strBrightness, ResStr(IDS_MPEG2_BRIGHTNESS));
- wcscpy_s(m_strContrast, ResStr(IDS_MPEG2_CONTRAST));
- wcscpy_s(m_strHue, ResStr(IDS_MPEG2_HUE));
- wcscpy_s(m_strSaturation, ResStr(IDS_MPEG2_SATURATION));
-}
-
-bool CMpeg2DecSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
-{
- ASSERT(!m_pM2DF);
-
- m_pM2DF.Release();
-
- POSITION pos = pUnks.GetHeadPosition();
- while (pos && !(m_pM2DF = pUnks.GetNext(pos))) {
- ;
- }
-
- if (!m_pM2DF) {
- return false;
- }
-
- m_ditype = m_pM2DF->GetDeinterlaceMethod();
- m_procamp[0] = m_pM2DF->GetBrightness();
- m_procamp[1] = m_pM2DF->GetContrast();
- m_procamp[2] = m_pM2DF->GetHue();
- m_procamp[3] = m_pM2DF->GetSaturation();
- m_forcedsubs = m_pM2DF->IsForcedSubtitlesEnabled();
- m_planaryuv = m_pM2DF->IsPlanarYUVEnabled();
- m_interlaced = m_pM2DF->IsInterlacedEnabled();
- m_readARFromStream = m_pM2DF->IsReadARFromStreamEnabled();
-
- return true;
-}
-
-void CMpeg2DecSettingsWnd::OnDisconnect()
-{
- m_pM2DF.Release();
-}
-
-bool CMpeg2DecSettingsWnd::OnActivate()
-{
- ASSERT(IPP_FONTSIZE == 13);
- const int h20 = IPP_SCALE(20);
- const int h25 = IPP_SCALE(25);
- DWORD dwStyle = WS_VISIBLE | WS_CHILD | WS_TABSTOP;
- CPoint p(10, 10);
-
- m_planaryuv_check.Create(ResStr(IDS_MPEG2_ENABLE_PLANAR), dwStyle | BS_AUTOCHECKBOX, CRect(p, CSize(IPP_SCALE(300), m_fontheight)), this, IDC_PP_CHECK1);
- m_planaryuv_check.SetCheck(m_planaryuv ? BST_CHECKED : BST_UNCHECKED);
- p.y += h20;
-
- m_interlaced_check.Create(ResStr(IDS_MPEG2_INTERLACE_FLAG), dwStyle | BS_AUTOCHECKBOX, CRect(p, CSize(IPP_SCALE(300), m_fontheight)), this, IDC_PP_CHECK2);
- m_interlaced_check.SetCheck(m_interlaced ? BST_CHECKED : BST_UNCHECKED);
- p.y += h20;
-
- m_forcedsubs_check.Create(ResStr(IDS_MPEG2_FORCED_SUBS), dwStyle | BS_AUTOCHECKBOX, CRect(p, CSize(IPP_SCALE(300), m_fontheight)), this, IDC_PP_CHECK3);
- m_forcedsubs_check.SetCheck(m_forcedsubs ? BST_CHECKED : BST_UNCHECKED);
- p.y += h20;
-
- m_readARFromStream_check.Create(ResStr(IDS_MPEG2_READ_AR), dwStyle | BS_AUTOCHECKBOX, CRect(p, CSize(IPP_SCALE(300), m_fontheight)), this, IDC_PP_CHECK4);
- m_readARFromStream_check.SetCheck(m_readARFromStream ? BST_CHECKED : BST_UNCHECKED);
- p.y += h25;
-
- m_ditype_static.Create(ResStr(IDS_MPEG2_DEINTERLACING), WS_VISIBLE | WS_CHILD, CRect(p, CSize(IPP_SCALE(100), m_fontheight)), this);
- m_ditype_combo.Create(dwStyle | CBS_DROPDOWNLIST, CRect(p + CSize(IPP_SCALE(110), -4), CSize(IPP_SCALE(100), 200)), this, IDC_PP_COMBO1);
- m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Auto")), (DWORD)DIAuto);
- m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Weave")), (DWORD)DIWeave);
- m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Blend")), (DWORD)DIBlend);
- m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Bob")), (DWORD)DIBob);
- m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Field Shift")), (DWORD)DIFieldShift);
- m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("ELA")), (DWORD)DIELA);
- m_ditype_combo.SetCurSel(0);
- for (int i = 0; i < m_ditype_combo.GetCount(); i++)
- if ((int)m_ditype_combo.GetItemData(i) == m_ditype) {
- m_ditype_combo.SetCurSel(i);
- }
- m_ditype_combo.EnableWindow(!IsDlgButtonChecked(m_interlaced_check.GetDlgCtrlID()));
- p.y += h25;
-
- {
- int h = max(21, m_fontheight); // special size for sliders
- static const TCHAR* labels[] = {m_strBrightness, m_strContrast, m_strHue, m_strSaturation};
- for (int i = 0; i < _countof(m_procamp_slider); i++) {
- m_procamp_static[i].Create(labels[i], WS_VISIBLE | WS_CHILD, CRect(p, CSize(IPP_SCALE(80), m_fontheight)), this);
- m_procamp_slider[i].Create(dwStyle, CRect(p + CPoint(IPP_SCALE(85), 0), CSize(201, h)), this, IDC_PP_SLIDER1 + i);
- m_procamp_value[i].Create(_T(""), WS_VISIBLE | WS_CHILD, CRect(p + CPoint(IPP_SCALE(85) + 201, 0), CSize(IPP_SCALE(30), m_fontheight)), this);
- p.y += h;
- }
- m_procamp_slider[0].SetRange(0, 2 * 128);
- m_procamp_slider[0].SetTic(128);
- m_procamp_slider[0].SetPos((int)(m_procamp[0] + (m_procamp[0] >= 0 ? 0.5f : -0.5f)) + 128);
- m_procamp_slider[1].SetRange(0, 200);
- m_procamp_slider[1].SetTic(100);
- m_procamp_slider[1].SetPos((int)(100 * m_procamp[1] + 0.5f));
- m_procamp_slider[2].SetRange(0, 2 * 180);
- m_procamp_slider[2].SetTic(180);
- m_procamp_slider[2].SetPos((int)(m_procamp[2] + (m_procamp[2] >= 0 ? 0.5f : -0.5f)) + 180);
- m_procamp_slider[3].SetRange(0, 200);
- m_procamp_slider[3].SetTic(100);
- m_procamp_slider[3].SetPos((int)(100 * m_procamp[3] + 0.5f));
- p.y += 5;
- m_procamp_tv2pc.Create(_T("TV->PC"), dwStyle, CRect(p + CPoint(IPP_SCALE(85) + 200 / 2 - 80 - 5, 0), CSize(80, m_fontheight + 6)), this, IDC_PP_BUTTON1);
- m_procamp_reset.Create(ResStr(IDS_MPEG2_RESET), dwStyle, CRect(p + CPoint(IPP_SCALE(85) + 200 / 2 + 6, 0), CSize(80, m_fontheight + 6)), this, IDC_PP_BUTTON2);
- p.y += h25;
-
- UpdateProcampValues();
- }
-
- m_note_static.Create(
- ResStr(IDS_MPEG2_NOTE1), WS_VISIBLE | WS_CHILD, CRect(p, CSize(IPP_SCALE(320), m_fontheight * 4)), this);
-
- for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
- pWnd->SetFont(&m_font, FALSE);
- }
-
- return true;
-}
-
-void CMpeg2DecSettingsWnd::OnDeactivate()
-{
- m_ditype = (ditype)m_ditype_combo.GetItemData(m_ditype_combo.GetCurSel());
- m_procamp[0] = (float)m_procamp_slider[0].GetPos() - 128;
- m_procamp[1] = (float)m_procamp_slider[1].GetPos() / 100;
- m_procamp[2] = (float)m_procamp_slider[2].GetPos() - 180;
- m_procamp[3] = (float)m_procamp_slider[3].GetPos() / 100;
- m_planaryuv = !!IsDlgButtonChecked(m_planaryuv_check.GetDlgCtrlID());
- m_interlaced = !!IsDlgButtonChecked(m_interlaced_check.GetDlgCtrlID());
- m_forcedsubs = !!IsDlgButtonChecked(m_forcedsubs_check.GetDlgCtrlID());
- m_readARFromStream = !!IsDlgButtonChecked(m_readARFromStream_check.GetDlgCtrlID());
-}
-
-bool CMpeg2DecSettingsWnd::OnApply()
-{
- OnDeactivate();
-
- if (m_pM2DF) {
- m_pM2DF->SetDeinterlaceMethod(m_ditype);
- m_pM2DF->SetBrightness(m_procamp[0]);
- m_pM2DF->SetContrast(m_procamp[1]);
- m_pM2DF->SetHue(m_procamp[2]);
- m_pM2DF->SetSaturation(m_procamp[3]);
- m_pM2DF->EnableForcedSubtitles(m_forcedsubs);
- m_pM2DF->EnablePlanarYUV(m_planaryuv);
- m_pM2DF->EnableInterlaced(m_interlaced);
- m_pM2DF->EnableReadARFromStream(m_readARFromStream);
- m_pM2DF->Apply();
- }
-
- return true;
-}
-
-void CMpeg2DecSettingsWnd::UpdateProcampValues()
-{
- CString str;
-
- str.Format(_T("%d"), m_procamp_slider[0].GetPos() - 128);
- m_procamp_value[0].SetWindowText(str);
- str.Format(_T("%d%%"), m_procamp_slider[1].GetPos());
- m_procamp_value[1].SetWindowText(str);
- str.Format(_T("%d"), m_procamp_slider[2].GetPos() - 180);
- m_procamp_value[2].SetWindowText(str);
- str.Format(_T("%d%%"), m_procamp_slider[3].GetPos());
- m_procamp_value[3].SetWindowText(str);
-}
-
-BEGIN_MESSAGE_MAP(CMpeg2DecSettingsWnd, CInternalPropertyPageWnd)
- ON_BN_CLICKED(IDC_PP_BUTTON1, OnButtonProcampPc2Tv)
- ON_BN_CLICKED(IDC_PP_BUTTON2, OnButtonProcampReset)
- ON_BN_CLICKED(IDC_PP_CHECK2, OnButtonInterlaced)
- ON_WM_HSCROLL()
-END_MESSAGE_MAP()
-
-void CMpeg2DecSettingsWnd::OnButtonProcampPc2Tv()
-{
- m_procamp_slider[0].SetPos(128 - 16);
- m_procamp_slider[1].SetPos(100 * 255 / (235 - 16));
-
- UpdateProcampValues();
-}
-
-void CMpeg2DecSettingsWnd::OnButtonProcampReset()
-{
- m_procamp_slider[0].SetPos(128);
- m_procamp_slider[1].SetPos(100);
- m_procamp_slider[2].SetPos(180);
- m_procamp_slider[3].SetPos(100);
-
- UpdateProcampValues();
-}
-
-void CMpeg2DecSettingsWnd::OnButtonInterlaced()
-{
- m_ditype_combo.EnableWindow(!IsDlgButtonChecked(m_interlaced_check.GetDlgCtrlID()));
-}
-
-void CMpeg2DecSettingsWnd::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
-{
- UpdateProcampValues();
-
- __super::OnHScroll(nSBCode, nPos, pScrollBar);
-}
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.h b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.h
deleted file mode 100644
index 5e5586887..000000000
--- a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../InternalPropertyPage.h"
-#include "IMpeg2DecFilter.h"
-#include "resource.h"
-#include <afxcmn.h>
-
-class __declspec(uuid("E5FB6957-65E6-491B-BB37-B25C9FE3BEA7"))
- CMpeg2DecSettingsWnd : public CInternalPropertyPageWnd
-{
- CComQIPtr<IMpeg2DecFilter> m_pM2DF;
-
- ditype m_ditype;
- float m_procamp[4];
- bool m_planaryuv;
- bool m_interlaced;
- bool m_forcedsubs;
- bool m_readARFromStream;
-
- enum {
- IDC_PP_COMBO1 = 10000,
- IDC_PP_SLIDER1,
- IDC_PP_SLIDER2,
- IDC_PP_SLIDER3,
- IDC_PP_SLIDER4,
- IDC_PP_CHECK1,
- IDC_PP_CHECK2,
- IDC_PP_CHECK3,
- IDC_PP_CHECK4,
- IDC_PP_BUTTON1,
- IDC_PP_BUTTON2
- };
-
- CStatic m_ditype_static;
- CComboBox m_ditype_combo;
- CStatic m_procamp_static[4];
- CSliderCtrl m_procamp_slider[4];
- CStatic m_procamp_value[4];
- CButton m_procamp_tv2pc;
- CButton m_procamp_reset;
- CButton m_planaryuv_check;
- CButton m_interlaced_check;
- CButton m_forcedsubs_check;
- CButton m_readARFromStream_check;
- CStatic m_note_static;
-
- void UpdateProcampValues();
-
-public:
- CMpeg2DecSettingsWnd();
-
- bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
- void OnDisconnect();
- bool OnActivate();
- void OnDeactivate();
- bool OnApply();
-
- static LPCTSTR GetWindowTitle() { return MAKEINTRESOURCE(IDS_FILTER_SETTINGS_CAPTION); }
- static CSize GetWindowSize() { return CSize(340, 296); }
-
- DECLARE_MESSAGE_MAP()
-
- afx_msg void OnButtonProcampPc2Tv();
- afx_msg void OnButtonProcampReset();
- afx_msg void OnButtonInterlaced();
- afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
-};
diff --git a/src/filters/transform/Mpeg2DecFilter/attributes.h b/src/filters/transform/Mpeg2DecFilter/attributes.h
deleted file mode 100644
index e587e158f..000000000
--- a/src/filters/transform/Mpeg2DecFilter/attributes.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * attributes.h
- * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
- *
- * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
- * See http://libmpeg2.sourceforge.net/ for updates.
- *
- * mpeg2dec is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * mpeg2dec 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef _ATTRIBUTES_H_
-#define _ATTRIBUTES_H_
-
-/* use gcc attribs to align critical data structures */
-#ifdef __GNUC__
- #define __align8(t,v) t v __attribute__ ((aligned (8)))
- #define __align16(t,v) t v __attribute__ ((aligned (16)))
-#else
- #define __align8(t,v) __declspec(align(8)) t v
- #define __align16(t,v) __declspec(align(16)) t v
-#endif
-
-#ifdef HAVE_BUILTIN_EXPECT
-#define likely(x) __builtin_expect ((x) != 0, 1)
-#define unlikely(x) __builtin_expect ((x) != 0, 0)
-#else
-#define likely(x) (x)
-#define unlikely(x) (x)
-#endif
-
-#endif
diff --git a/src/filters/transform/Mpeg2DecFilter/idct_mmx.obj b/src/filters/transform/Mpeg2DecFilter/idct_mmx.obj
deleted file mode 100644
index d5dcbe5aa..000000000
--- a/src/filters/transform/Mpeg2DecFilter/idct_mmx.obj
+++ /dev/null
Binary files differ
diff --git a/src/filters/transform/Mpeg2DecFilter/idct_sse2.cpp b/src/filters/transform/Mpeg2DecFilter/idct_sse2.cpp
deleted file mode 100644
index 9fa45900b..000000000
--- a/src/filters/transform/Mpeg2DecFilter/idct_sse2.cpp
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <inttypes.h>
-#include "libmpeg2.h"
-#include "attributes.h"
-#include "../../../DSUtil/simd.h"
-
-// Intel's SSE2 implementation of iDCT
-// AP-945
-// http://cache-www.intel.com/cd/00/00/01/76/17680_w_idct.pdf
-
-static const int BITS_INV_ACC = 4;
-static const int SHIFT_INV_ROW = 16 - BITS_INV_ACC;
-static const int SHIFT_INV_COL = 1 + BITS_INV_ACC;
-static const int RND_INV_ROW = 1024 * (6 - BITS_INV_ACC);
-static const int RND_INV_COL = 16 * (BITS_INV_ACC - 3);
-static const int RND_INV_CORR = RND_INV_COL - 1;
-
-static __align16(const short, M128_round_inv_row[8]) = {RND_INV_ROW, 0, RND_INV_ROW, 0, RND_INV_ROW, 0, RND_INV_ROW, 0};
-static __align16(const short, M128_one_corr[8]) = {1, 1, 1, 1, 1, 1, 1, 1};
-static __align16(const short, M128_round_inv_col[8]) = {RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL, RND_INV_COL};
-static __align16(const short, M128_round_inv_corr[8]) = {RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR, RND_INV_CORR};
-static __align16(const short, M128_tg_1_16[8]) = {13036, 13036, 13036, 13036, 13036, 13036, 13036, 13036}; // tg * (2<<16) + 0.5
-static __align16(const short, M128_tg_2_16[8]) = {27146, 27146, 27146, 27146, 27146, 27146, 27146, 27146}; // tg * (2<<16) + 0.5
-static __align16(const short, M128_tg_3_16[8]) = { -21746, -21746, -21746, -21746, -21746, -21746, -21746, -21746}; // tg * (2<<16) + 0.5
-static __align16(const short, M128_cos_4_16[8]) = { -19195, -19195, -19195, -19195, -19195, -19195, -19195, -19195}; // cos * (2<<16) + 0.5
-
-static __align16(const int16_t, M128_tab_i_04[]) = {16384, 21407, 16384, 8867, 16384, -8867, 16384, -21407, 16384, 8867, -16384, -21407, -16384, 21407, 16384, -8867, 22725, 19266, 19266, -4520, 12873, -22725, 4520, -12873, 12873, 4520, -22725, -12873, 4520, 19266, 19266, -22725};
-static __align16(const int16_t, M128_tab_i_17[]) = {22725, 29692, 22725, 12299, 22725, -12299, 22725, -29692, 22725, 12299, -22725, -29692, -22725, 29692, 22725, -12299, 31521, 26722, 26722, -6270, 17855, -31521, 6270, -17855, 17855, 6270, -31521, -17855, 6270, 26722, 26722, -31521};
-static __align16(const int16_t, M128_tab_i_26[]) = {21407, 27969, 21407, 11585, 21407, -11585, 21407, -27969, 21407, 11585, -21407, -27969, -21407, 27969, 21407, -11585, 29692, 25172, 25172, -5906, 16819, -29692, 5906, -16819, 16819, 5906, -29692, -16819, 5906, 25172, 25172, -29692};
-static __align16(const int16_t, M128_tab_i_35[]) = {19266, 25172, 19266, 10426, 19266, -10426, 19266, -25172, 19266, 10426, -19266, -25172, -19266, 25172, 19266, -10426, 26722, 22654, 22654, -5315, 15137, -26722, 5315, -15137, 15137, 5315, -26722, -15137, 5315, 22654, 22654, -26722};
-
-static __forceinline void DCT_8_INV_ROW(const uint8_t* const ecx, const uint8_t* const esi, __m128i& xmm0, __m128i& xmm1, __m128i& xmm2, __m128i& xmm3, __m128i& xmm4, __m128i& xmm5, __m128i& xmm6, __m128i& xmm7)
-{
- xmm0 = _mm_shufflelo_epi16(xmm0, 0xD8);
- xmm1 = _mm_shuffle_epi32(xmm0, 0);
- pmaddwd(xmm1, esi);
- xmm3 = _mm_shuffle_epi32(xmm0, 0x55);
- xmm0 = _mm_shufflehi_epi16(xmm0, 0xD8);
- pmaddwd(xmm3, esi + 32);
- xmm2 = _mm_shuffle_epi32(xmm0, 0xAA);
- xmm0 = _mm_shuffle_epi32(xmm0, 0xFF);
- pmaddwd(xmm2, esi + 16);
- xmm4 = _mm_shufflehi_epi16(xmm4, 0xD8);
- paddd(xmm1, M128_round_inv_row);
- xmm4 = _mm_shufflelo_epi16(xmm4, 0xD8);
- pmaddwd(xmm0, esi + 48);
- xmm5 = _mm_shuffle_epi32(xmm4, 0);
- xmm6 = _mm_shuffle_epi32(xmm4, 0xAA);
- pmaddwd(xmm5, ecx);
- paddd(xmm1, xmm2);
- movdqa(xmm2, xmm1);
- xmm7 = _mm_shuffle_epi32(xmm4, 0x55);
- pmaddwd(xmm6, ecx + 16);
- paddd(xmm0, xmm3);
- xmm4 = _mm_shuffle_epi32(xmm4, 0xFF);
- psubd(xmm2, xmm0);
- pmaddwd(xmm7, ecx + 32);
- paddd(xmm0, xmm1);
- psrad(xmm2, 12);
- paddd(xmm5, M128_round_inv_row);
- pmaddwd(xmm4, ecx + 48);
- paddd(xmm5, xmm6);
- movdqa(xmm6, xmm5);
- psrad(xmm0, 12);
- xmm2 = _mm_shuffle_epi32(xmm2, 0x1B);
- packssdw(xmm0, xmm2);
- paddd(xmm4, xmm7);
- psubd(xmm6, xmm4);
- paddd(xmm4, xmm5);
- psrad(xmm6, 12);
- psrad(xmm4, 12);
- xmm6 = _mm_shuffle_epi32(xmm6, 0x1B);
- packssdw(xmm4, xmm6);
-}
-static __forceinline void DCT_8_INV_COL_8(__m128i& src0, __m128i& src1, __m128i& src2, __m128i& src3, __m128i& src4, __m128i& src5, __m128i& src6, __m128i& src7,
- __m128i& xmm0, __m128i& xmm1, __m128i& xmm2, __m128i& xmm3, __m128i& xmm4, __m128i& xmm5, __m128i& xmm6, __m128i& xmm7)
-{
- movdqa(xmm1, M128_tg_3_16);
- movdqa(xmm2, xmm0);
- movdqa(xmm3, src3);
- pmulhw(xmm0, xmm1);
- pmulhw(xmm1, xmm3);
- movdqa(xmm5, M128_tg_1_16);
- movdqa(xmm6, xmm4);
- pmulhw(xmm4, xmm5);
- paddsw(xmm0, xmm2);
- pmulhw(xmm5, src1);
- paddsw(xmm1, xmm3);
- movdqa(xmm7, src6);
- paddsw(xmm0, xmm3);
- movdqa(xmm3, M128_tg_2_16);
- psubsw(xmm2, xmm1);
- pmulhw(xmm7, xmm3);
- movdqa(xmm1, xmm0);
- pmulhw(xmm3, src2);
- psubsw(xmm5, xmm6);
- paddsw(xmm4, src1);
- paddsw(xmm0, xmm4);
- paddsw(xmm0, M128_one_corr);
- psubsw(xmm4, xmm1);
- movdqa(xmm6, xmm5);
- psubsw(xmm5, xmm2);
- paddsw(xmm5, M128_one_corr);
- paddsw(xmm6, xmm2);
- movdqa(src7, xmm0);
- movdqa(xmm1, xmm4);
- movdqa(xmm0, M128_cos_4_16);
- paddsw(xmm4, xmm5);
- movdqa(xmm2, M128_cos_4_16);
- pmulhw(xmm2, xmm4);
- movdqa(src3, xmm6);
- psubsw(xmm1, xmm5);
- paddsw(xmm7, src2);
- psubsw(xmm3, src6);
- movdqa(xmm6, src0);
- pmulhw(xmm0, xmm1);
- movdqa(xmm5, src4);
- paddsw(xmm5, xmm6);
- psubsw(xmm6, src4);
- paddsw(xmm4, xmm2);
- por(xmm4, M128_one_corr);
- paddsw(xmm0, xmm1);
- por(xmm0, M128_one_corr);
- movdqa(xmm2, xmm5);
- paddsw(xmm5, xmm7);
- movdqa(xmm1, xmm6);
- paddsw(xmm5, M128_round_inv_col);
- psubsw(xmm2, xmm7);
- movdqa(xmm7, src7);
- paddsw(xmm6, xmm3);
- paddsw(xmm6, M128_round_inv_col);
- paddsw(xmm7, xmm5);
- psraw(xmm7, SHIFT_INV_COL);
- psubsw(xmm1, xmm3);
- paddsw(xmm1, M128_round_inv_corr);
- movdqa(xmm3, xmm6);
- paddsw(xmm2, M128_round_inv_corr);
- paddsw(xmm6, xmm4);
- movdqa(src0, xmm7);
- psraw(xmm6, SHIFT_INV_COL);
- movdqa(xmm7, xmm1);
- paddsw(xmm1, xmm0);
- movdqa(src1, xmm6);
- psraw(xmm1, SHIFT_INV_COL);
- movdqa(xmm6, src3);
- psubsw(xmm7, xmm0);
- psraw(xmm7, SHIFT_INV_COL);
- movdqa(src2, xmm1);
- psubsw(xmm5, src7);
- psraw(xmm5, SHIFT_INV_COL);
- movdqa(src7, xmm5);
- psubsw(xmm3, xmm4);
- paddsw(xmm6, xmm2);
- psubsw(xmm2, src3);
- psraw(xmm6, SHIFT_INV_COL);
- psraw(xmm2, SHIFT_INV_COL);
- movdqa(src3, xmm6);
- psraw(xmm3, SHIFT_INV_COL);
- movdqa(src4, xmm2);
- movdqa(src5, xmm7);
- movdqa(src6, xmm3);
-}
-
-static __forceinline void idct_M128ASM(__m128i& src0, __m128i& src1, __m128i& src2, __m128i& src3, __m128i& src4, __m128i& src5, __m128i& src6, __m128i& src7)
-{
- __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;
- movdqa(xmm0, src0);
- uint8_t* esi = (uint8_t*)M128_tab_i_04;
- movdqa(xmm4, src2);
- uint8_t* ecx = (uint8_t*)M128_tab_i_26;
- DCT_8_INV_ROW(ecx, esi, xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7);
- movdqa(src0, xmm0);
- movdqa(src2, xmm4);
-
- movdqa(xmm0, src4);
- movdqa(xmm4, src6);
- DCT_8_INV_ROW(ecx, esi, xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7);
- movdqa(src4, xmm0);
- movdqa(src6, xmm4);
-
- movdqa(xmm0, src3);
- esi = (uint8_t*)M128_tab_i_35;
- movdqa(xmm4, src1);
- ecx = (uint8_t*)M128_tab_i_17;
- DCT_8_INV_ROW(ecx, esi, xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7);
- movdqa(src3, xmm0);
- movdqa(src1, xmm4);
-
- movdqa(xmm0, src5);
- movdqa(xmm4, src7);
- DCT_8_INV_ROW(ecx, esi, xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7);
- DCT_8_INV_COL_8(src0, src1, src2, src3, src4, src5, src6, src7,
- xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7);
-}
-
-void mpeg2_idct_copy_sse2(int16_t* block, uint8_t* dest, const int stride)
-{
- __m128i& src0 = *(__m128i*)(block + 0 * 16 / 2);
- __m128i& src1 = *(__m128i*)(block + 1 * 16 / 2);
- __m128i& src2 = *(__m128i*)(block + 2 * 16 / 2);
- __m128i& src3 = *(__m128i*)(block + 3 * 16 / 2);
- __m128i& src4 = *(__m128i*)(block + 4 * 16 / 2);
- __m128i& src5 = *(__m128i*)(block + 5 * 16 / 2);
- __m128i& src6 = *(__m128i*)(block + 6 * 16 / 2);
- __m128i& src7 = *(__m128i*)(block + 7 * 16 / 2);
- idct_M128ASM(src0, src1, src2, src3, src4, src5, src6, src7);
-
- __m128i zero = _mm_setzero_si128();
-
- __m128i r0 = _mm_packus_epi16(_mm_load_si128(&src0), _mm_load_si128(&src1));
- __m128i r1 = _mm_packus_epi16(_mm_load_si128(&src2), _mm_load_si128(&src3));
- __m128i r2 = _mm_packus_epi16(_mm_load_si128(&src4), _mm_load_si128(&src5));
- __m128i r3 = _mm_packus_epi16(_mm_load_si128(&src6), _mm_load_si128(&src7));
-
- _mm_storel_pi((__m64*)&dest[0 * stride], *(__m128*)&r0);
- _mm_storeh_pi((__m64*)&dest[1 * stride], *(__m128*)&r0);
- _mm_storel_pi((__m64*)&dest[2 * stride], *(__m128*)&r1);
- _mm_storeh_pi((__m64*)&dest[3 * stride], *(__m128*)&r1);
- _mm_storel_pi((__m64*)&dest[4 * stride], *(__m128*)&r2);
- _mm_storeh_pi((__m64*)&dest[5 * stride], *(__m128*)&r2);
- _mm_storel_pi((__m64*)&dest[6 * stride], *(__m128*)&r3);
- _mm_storeh_pi((__m64*)&dest[7 * stride], *(__m128*)&r3);
-
- _mm_store_si128(&src0, zero);
- _mm_store_si128(&src1, zero);
- _mm_store_si128(&src2, zero);
- _mm_store_si128(&src3, zero);
- _mm_store_si128(&src4, zero);
- _mm_store_si128(&src5, zero);
- _mm_store_si128(&src6, zero);
- _mm_store_si128(&src7, zero);
-}
-
-void mpeg2_idct_add_sse2(int, int16_t* block, uint8_t* dest, const int stride)
-{
- __m128i& src0 = *(__m128i*)(block + 0 * 16 / 2);
- __m128i& src1 = *(__m128i*)(block + 1 * 16 / 2);
- __m128i& src2 = *(__m128i*)(block + 2 * 16 / 2);
- __m128i& src3 = *(__m128i*)(block + 3 * 16 / 2);
- __m128i& src4 = *(__m128i*)(block + 4 * 16 / 2);
- __m128i& src5 = *(__m128i*)(block + 5 * 16 / 2);
- __m128i& src6 = *(__m128i*)(block + 6 * 16 / 2);
- __m128i& src7 = *(__m128i*)(block + 7 * 16 / 2);
- idct_M128ASM(src0, src1, src2, src3, src4, src5, src6, src7);
-
- __m128i zero = _mm_setzero_si128();
-
- __m128i r0 = _mm_load_si128(&src0);
- __m128i r1 = _mm_load_si128(&src1);
- __m128i r2 = _mm_load_si128(&src2);
- __m128i r3 = _mm_load_si128(&src3);
- __m128i r4 = _mm_load_si128(&src4);
- __m128i r5 = _mm_load_si128(&src5);
- __m128i r6 = _mm_load_si128(&src6);
- __m128i r7 = _mm_load_si128(&src7);
-
- __m128 q0 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[0 * stride]);
- __m128 q1 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[1 * stride]);
- __m128 q2 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[2 * stride]);
- __m128 q3 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[3 * stride]);
- __m128 q4 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[4 * stride]);
- __m128 q5 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[5 * stride]);
- __m128 q6 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[6 * stride]);
- __m128 q7 = _mm_loadl_pi(*(__m128*)&zero, (__m64*)&dest[7 * stride]);
-
- r0 = _mm_adds_epi16(r0, _mm_unpacklo_epi8(*(__m128i*)&q0, zero));
- r1 = _mm_adds_epi16(r1, _mm_unpacklo_epi8(*(__m128i*)&q1, zero));
- r2 = _mm_adds_epi16(r2, _mm_unpacklo_epi8(*(__m128i*)&q2, zero));
- r3 = _mm_adds_epi16(r3, _mm_unpacklo_epi8(*(__m128i*)&q3, zero));
- r4 = _mm_adds_epi16(r4, _mm_unpacklo_epi8(*(__m128i*)&q4, zero));
- r5 = _mm_adds_epi16(r5, _mm_unpacklo_epi8(*(__m128i*)&q5, zero));
- r6 = _mm_adds_epi16(r6, _mm_unpacklo_epi8(*(__m128i*)&q6, zero));
- r7 = _mm_adds_epi16(r7, _mm_unpacklo_epi8(*(__m128i*)&q7, zero));
-
- r0 = _mm_packus_epi16(r0, r1);
- r1 = _mm_packus_epi16(r2, r3);
- r2 = _mm_packus_epi16(r4, r5);
- r3 = _mm_packus_epi16(r6, r7);
-
- _mm_storel_pi((__m64*)&dest[0 * stride], *(__m128*)&r0);
- _mm_storeh_pi((__m64*)&dest[1 * stride], *(__m128*)&r0);
- _mm_storel_pi((__m64*)&dest[2 * stride], *(__m128*)&r1);
- _mm_storeh_pi((__m64*)&dest[3 * stride], *(__m128*)&r1);
- _mm_storel_pi((__m64*)&dest[4 * stride], *(__m128*)&r2);
- _mm_storeh_pi((__m64*)&dest[5 * stride], *(__m128*)&r2);
- _mm_storel_pi((__m64*)&dest[6 * stride], *(__m128*)&r3);
- _mm_storeh_pi((__m64*)&dest[7 * stride], *(__m128*)&r3);
-
- _mm_store_si128(&src0, zero);
- _mm_store_si128(&src1, zero);
- _mm_store_si128(&src2, zero);
- _mm_store_si128(&src3, zero);
- _mm_store_si128(&src4, zero);
- _mm_store_si128(&src5, zero);
- _mm_store_si128(&src6, zero);
- _mm_store_si128(&src7, zero);
-}
-
-void mpeg2_idct_init_sse2()
-{
-}
diff --git a/src/filters/transform/Mpeg2DecFilter/libmpeg2.cpp b/src/filters/transform/Mpeg2DecFilter/libmpeg2.cpp
deleted file mode 100644
index 10e9abd98..000000000
--- a/src/filters/transform/Mpeg2DecFilter/libmpeg2.cpp
+++ /dev/null
@@ -1,3743 +0,0 @@
-/*
- * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
- *
- * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
- * See http://libmpeg2.sourceforge.net/ for updates.
- *
- * mpeg2dec is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * mpeg2dec 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "stdafx.h"
-#include <stdlib.h>
-#include <string.h>
-#include <malloc.h>
-#include "libmpeg2.h"
-#include "../../../DSUtil/vd.h"
-
-#ifdef _WIN64
-#pragma warning(push)
-#pragma warning(disable:4244)
-#endif
-
-// decode
-
-#define SEQ_EXT 2
-#define SEQ_DISPLAY_EXT 4
-#define QUANT_MATRIX_EXT 8
-#define COPYRIGHT_EXT 0x10
-#define PIC_DISPLAY_EXT 0x80
-#define PIC_CODING_EXT 0x100
-
-/* default intra quant matrix, in zig-zag order */
-static const uint8_t default_intra_quantizer_matrix[64] = {
- 8,
- 16, 16,
- 19, 16, 19,
- 22, 22, 22, 22,
- 22, 22, 26, 24, 26,
- 27, 27, 27, 26, 26, 26,
- 26, 27, 27, 27, 29, 29, 29,
- 34, 34, 34, 29, 29, 29, 27, 27,
- 29, 29, 32, 32, 34, 34, 37,
- 38, 37, 35, 35, 34, 35,
- 38, 38, 40, 40, 40,
- 48, 48, 46, 46,
- 56, 56, 58,
- 69, 69,
- 83
-};
-
-static uint8_t mpeg2_scan_norm_2[64] = {
- /* Zig-Zag scan pattern */
- 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5,
- 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28,
- 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51,
- 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63
-};
-
-static uint8_t mpeg2_scan_alt_2[64] = {
- /* Alternate scan pattern */
- 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,
- 51, 59, 20, 28, 5, 13, 6, 14, 21, 29, 36, 44, 52, 60, 37, 45,
- 53, 61, 22, 30, 7, 15, 23, 31, 38, 46, 54, 62, 39, 47, 55, 63
-};
-
-// dummy
-extern "C" uint8_t mpeg2_scan_norm[64];
-extern "C" uint8_t mpeg2_scan_alt[64];
-uint8_t mpeg2_scan_norm[64];
-uint8_t mpeg2_scan_alt[64];
-
-// idct (c)
-
-#define W1 2841 /* 2048 * sqrt (2) * cos (1 * pi / 16) */
-#define W2 2676 /* 2048 * sqrt (2) * cos (2 * pi / 16) */
-#define W3 2408 /* 2048 * sqrt (2) * cos (3 * pi / 16) */
-#define W5 1609 /* 2048 * sqrt (2) * cos (5 * pi / 16) */
-#define W6 1108 /* 2048 * sqrt (2) * cos (6 * pi / 16) */
-#define W7 565 /* 2048 * sqrt (2) * cos (7 * pi / 16) */
-
-/*
- * In legal streams, the IDCT output should be between -384 and +384.
- * In corrupted streams, it is possible to force the IDCT output to go
- * to +-3826 - this is the worst case for a column IDCT where the
- * column inputs are 16-bit values.
- */
-static uint8_t mpeg2_clip[3840 * 2 + 256];
-#define CLIP(i) ((mpeg2_clip + 3840)[i])
-
-#define BUTTERFLY(t0,t1,W0,W1,d0,d1) \
-{ \
- int tmp = W0 * (d0 + d1); \
- t0 = tmp + (W1 - W0) * d1; \
- t1 = tmp - (W1 + W0) * d0; \
-}
-
-static void __inline idct_row(int16_t* block)
-{
- int d0, d1, d2, d3;
- int a0, a1, a2, a3, b0, b1, b2, b3;
- int t0, t1, t2, t3;
-
- /* shortcut */
- if(!(block[1] | ((int32_t *)block)[1] | ((int32_t *)block)[2] | ((int32_t *)block)[3]))
- {
- uint32_t tmp = (uint16_t) (block[0] << 3);
- tmp |= tmp << 16;
- ((int32_t *)block)[0] = tmp;
- ((int32_t *)block)[1] = tmp;
- ((int32_t *)block)[2] = tmp;
- ((int32_t *)block)[3] = tmp;
- return;
- }
-
- d0 = (block[0] << 11) + 128;
- d1 = block[1];
- d2 = block[2] << 11;
- d3 = block[3];
- t0 = d0 + d2;
- t1 = d0 - d2;
- BUTTERFLY(t2, t3, W6, W2, d3, d1);
- a0 = t0 + t2;
- a1 = t1 + t3;
- a2 = t1 - t3;
- a3 = t0 - t2;
-
- d0 = block[4];
- d1 = block[5];
- d2 = block[6];
- d3 = block[7];
- BUTTERFLY(t0, t1, W7, W1, d3, d0);
- BUTTERFLY(t2, t3, W3, W5, d1, d2);
- b0 = t0 + t2;
- b3 = t1 + t3;
- t0 -= t2;
- t1 -= t3;
- b1 = ((t0 + t1) * 181) >> 8;
- b2 = ((t0 - t1) * 181) >> 8;
-
- block[0] = (a0 + b0) >> 8;
- block[1] = (a1 + b1) >> 8;
- block[2] = (a2 + b2) >> 8;
- block[3] = (a3 + b3) >> 8;
- block[4] = (a3 - b3) >> 8;
- block[5] = (a2 - b2) >> 8;
- block[6] = (a1 - b1) >> 8;
- block[7] = (a0 - b0) >> 8;
-}
-
-static void __inline idct_col(int16_t* block)
-{
- int d0, d1, d2, d3;
- int a0, a1, a2, a3, b0, b1, b2, b3;
- int t0, t1, t2, t3;
-
- d0 = (block[8*0] << 11) + 65536;
- d1 = block[8*1];
- d2 = block[8*2] << 11;
- d3 = block[8*3];
- t0 = d0 + d2;
- t1 = d0 - d2;
- BUTTERFLY(t2, t3, W6, W2, d3, d1);
- a0 = t0 + t2;
- a1 = t1 + t3;
- a2 = t1 - t3;
- a3 = t0 - t2;
-
- d0 = block[8*4];
- d1 = block[8*5];
- d2 = block[8*6];
- d3 = block[8*7];
- BUTTERFLY(t0, t1, W7, W1, d3, d0);
- BUTTERFLY(t2, t3, W3, W5, d1, d2);
- b0 = t0 + t2;
- b3 = t1 + t3;
- t0 = (t0 - t2) >> 8;
- t1 = (t1 - t3) >> 8;
- b1 = (t0 + t1) * 181;
- b2 = (t0 - t1) * 181;
-
- block[8*0] = (a0 + b0) >> 17;
- block[8*1] = (a1 + b1) >> 17;
- block[8*2] = (a2 + b2) >> 17;
- block[8*3] = (a3 + b3) >> 17;
- block[8*4] = (a3 - b3) >> 17;
- block[8*5] = (a2 - b2) >> 17;
- block[8*6] = (a1 - b1) >> 17;
- block[8*7] = (a0 - b0) >> 17;
-}
-
-static void mpeg2_idct_copy_c(int16_t* block, uint8_t* dest, const int stride)
-{
- for(int i = 0; i < 8; i++) idct_row(block + 8 * i);
- for(int i = 0; i < 8; i++) idct_col(block + i);
- for(int i = 0; i < 8; i++)
- {
- dest[0] = CLIP(block[0]);
- dest[1] = CLIP(block[1]);
- dest[2] = CLIP(block[2]);
- dest[3] = CLIP(block[3]);
- dest[4] = CLIP(block[4]);
- dest[5] = CLIP(block[5]);
- dest[6] = CLIP(block[6]);
- dest[7] = CLIP(block[7]);
-
- block[0] = 0; block[1] = 0; block[2] = 0; block[3] = 0;
- block[4] = 0; block[5] = 0; block[6] = 0; block[7] = 0;
-
- dest += stride;
- block += 8;
- }
-}
-
-static void mpeg2_idct_add_c(const int last, int16_t* block, uint8_t* dest, const int stride)
-{
- if(last != 129 || (block[0] & 7) == 4)
- {
- for(int i = 0; i < 8; i++) idct_row(block + 8 * i);
- for(int i = 0; i < 8; i++) idct_col(block + i);
- for(int i = 0; i < 8; i++)
- {
- dest[0] = CLIP(block[0] + dest[0]);
- dest[1] = CLIP(block[1] + dest[1]);
- dest[2] = CLIP(block[2] + dest[2]);
- dest[3] = CLIP(block[3] + dest[3]);
- dest[4] = CLIP(block[4] + dest[4]);
- dest[5] = CLIP(block[5] + dest[5]);
- dest[6] = CLIP(block[6] + dest[6]);
- dest[7] = CLIP(block[7] + dest[7]);
-
- block[0] = 0; block[1] = 0; block[2] = 0; block[3] = 0;
- block[4] = 0; block[5] = 0; block[6] = 0; block[7] = 0;
-
- dest += stride;
- block += 8;
- }
- }
- else
- {
- int DC = (block[0] + 4) >> 3;
- block[0] = block[63] = 0;
- for(int i = 0; i < 8; i++)
- {
- dest[0] = CLIP(DC + dest[0]);
- dest[1] = CLIP(DC + dest[1]);
- dest[2] = CLIP(DC + dest[2]);
- dest[3] = CLIP(DC + dest[3]);
- dest[4] = CLIP(DC + dest[4]);
- dest[5] = CLIP(DC + dest[5]);
- dest[6] = CLIP(DC + dest[6]);
- dest[7] = CLIP(DC + dest[7]);
- dest += stride;
- }
- }
-}
-
-static void mpeg2_idct_init_c()
-{
- for(int i = -3840; i < 3840 + 256; i++)
- {
- CLIP(i) = (i < 0) ? 0 : ((i > 255) ? 255 : i);
- }
-
- // only needed with idct_c
-
- for(int i = 0; i < 64; i++)
- {
- mpeg2_scan_norm_2[i] = ((mpeg2_scan_norm_2[i] & 0x36) >> 1) | ((mpeg2_scan_norm_2[i] & 0x09) << 2);
- mpeg2_scan_alt_2[i] = ((mpeg2_scan_alt_2[i] & 0x36) >> 1) | ((mpeg2_scan_alt_2[i] & 0x09) << 2);
- }
-}
-
-// mc (c)
-
-#define avg2(a,b) ((a+b+1)>>1)
-#define avg4(a,b,c,d) ((a+b+c+d+2)>>2)
-
-#define predict_o(i) (ref[i])
-#define predict_x(i) (avg2(ref[i], ref[i+1]))
-#define predict_y(i) (avg2(ref[i], (ref+stride)[i]))
-#define predict_xy(i) (avg4(ref[i], ref[i+1], (ref+stride)[i], (ref+stride)[i+1]))
-
-#define put(predictor,i) dest[i] = predictor(i)
-#define avg(predictor,i) dest[i] = avg2(predictor(i), dest[i])
-
-/* mc function template */
-
-#define MC_FUNC(op,xy) \
-static void MC_##op##_##xy##_16_c (uint8_t* dest, const uint8_t* ref, const int stride, int height) \
-{ \
- do { \
- op (predict_##xy, 0); \
- op (predict_##xy, 1); \
- op (predict_##xy, 2); \
- op (predict_##xy, 3); \
- op (predict_##xy, 4); \
- op (predict_##xy, 5); \
- op (predict_##xy, 6); \
- op (predict_##xy, 7); \
- op (predict_##xy, 8); \
- op (predict_##xy, 9); \
- op (predict_##xy, 10); \
- op (predict_##xy, 11); \
- op (predict_##xy, 12); \
- op (predict_##xy, 13); \
- op (predict_##xy, 14); \
- op (predict_##xy, 15); \
- ref += stride; \
- dest += stride; \
- } while (--height); \
-} \
-static void MC_##op##_##xy##_8_c (uint8_t * dest, const uint8_t * ref, const int stride, int height) \
-{ \
- do { \
- op (predict_##xy, 0); \
- op (predict_##xy, 1); \
- op (predict_##xy, 2); \
- op (predict_##xy, 3); \
- op (predict_##xy, 4); \
- op (predict_##xy, 5); \
- op (predict_##xy, 6); \
- op (predict_##xy, 7); \
- ref += stride; \
- dest += stride; \
- } while (--height); \
-}
-
-/* definitions of the actual mc functions */
-
-MC_FUNC(put,o)
-MC_FUNC(avg,o)
-MC_FUNC(put,x)
-MC_FUNC(avg,x)
-MC_FUNC(put,y)
-MC_FUNC(avg,y)
-MC_FUNC(put,xy)
-MC_FUNC(avg,xy)
-
-#define MPEG2_MC_EXTERN(x) mpeg2_mc_t mpeg2_mc_##x = { \
- {MC_put_o_16_##x, MC_put_x_16_##x, MC_put_y_16_##x, MC_put_xy_16_##x, \
- MC_put_o_8_##x, MC_put_x_8_##x, MC_put_y_8_##x, MC_put_xy_8_##x}, \
- {MC_avg_o_16_##x, MC_avg_x_16_##x, MC_avg_y_16_##x, MC_avg_xy_16_##x, \
- MC_avg_o_8_##x, MC_avg_x_8_##x, MC_avg_y_8_##x, MC_avg_xy_8_##x} \
-};
-
-MPEG2_MC_EXTERN(c)
-
-// idct (mmx)
-
-extern "C" void mpeg2_idct_copy_mmx(int16_t* block, uint8_t* dest, const int stride);
-extern "C" void mpeg2_idct_add_mmx(const int last, int16_t* block, uint8_t* dest, const int stride);
-
-static void mpeg2_idct_init_mmx()
-{
- for(int i = 0; i < 64; i++)
- {
- mpeg2_scan_norm_2[i] = (mpeg2_scan_norm_2[i] & 0x38) | ((mpeg2_scan_norm_2[i] & 6) >> 1) | ((mpeg2_scan_norm_2[i] & 1) << 2);
- mpeg2_scan_alt_2[i] = (mpeg2_scan_alt_2[i] & 0x38) | ((mpeg2_scan_alt_2[i] & 6) >> 1) | ((mpeg2_scan_alt_2[i] & 1) << 2);
- }
-}
-
-// mc (mmx)
-
-extern "C" mpeg2_mc_t mpeg2_mc_mmx;
-
-// idct (sse2)
-
-extern void mpeg2_idct_init_sse2();
-extern void mpeg2_idct_copy_sse2(int16_t* block, uint8_t* dest, const int stride);
-extern void mpeg2_idct_add_sse2(const int last, int16_t* block, uint8_t* dest, const int stride);
-
-// mc (sse2)
-
-extern mpeg2_mc_t mpeg2_mc_sse2;
-
-// idct (c)
-
-static void mpeg2_idct_init_c();
-static void mpeg2_idct_copy_c(int16_t* block, uint8_t* dest, const int stride);
-static void mpeg2_idct_add_c(const int last, int16_t* block, uint8_t* dest, const int stride);
-
- // mc (c)
-
-static void MC_c(uint8_t* dest, const uint8_t* ref, const int stride, int height);
-
-extern mpeg2_mc_t mpeg2_mc_c;
-
-//
-
-CMpeg2Dec::CMpeg2Dec()
-{
- m_shift = 0;
- m_is_display_initialized = 0;
- m_action = NULL;
- m_state = STATE_BUFFER;
- m_ext_state = 0;
-
- m_chunk_buffer = m_chunk_start = m_chunk_ptr = NULL;
- m_code = 0;
-
- m_pts_current = m_pts_previous = 0;
- m_num_pts = m_bytes_since_pts = 0;
-
- m_first = 0;
- m_alloc_index = 0;
- m_first_decode_slice = m_nb_decode_slices = 0;
-
- memset(&m_new_sequence, 0, sizeof(m_new_sequence));
- memset(&m_sequence, 0, sizeof(m_sequence));
- memset(&m_gop, 0, sizeof(m_gop));
- memset(&m_pictures, 0, sizeof(m_pictures));
- m_picture = NULL;
- memset(&m_fbuf, 0, sizeof(m_fbuf));
- memset(&m_fbuf_alloc, 0, sizeof(m_fbuf_alloc));
-
- m_buf_start = m_buf_end = NULL;
-
- m_display_offset_x = m_display_offset_y = 0;
-
- m_copy_matrix = 0;
- memset(&m_intra_quantizer_matrix, 0, sizeof(m_intra_quantizer_matrix));
- memset(&m_non_intra_quantizer_matrix, 0, sizeof(m_non_intra_quantizer_matrix));
-
- //
-
- mpeg2_init();
-}
-
-CMpeg2Dec::~CMpeg2Dec()
-{
- mpeg2_close();
-}
-
-void CMpeg2Dec::mpeg2_init()
-{
- m_chunk_buffer = (uint8_t*)_aligned_malloc(BUFFER_SIZE + 4, 16);
- m_shift = 0xffffff00;
- m_code = 0xb4;
- m_action = &CMpeg2Dec::mpeg2_seek_sequence;
- m_sequence.width = (unsigned)-1;
-}
-
-void CMpeg2Dec::mpeg2_close()
-{
- /* static uint8_t finalizer[] = {0,0,1,0xb4}; */
- /* mpeg2_decode_data (mpeg2dec, finalizer, finalizer+4); */
-
- mpeg2_header_state_init();
- _aligned_free(m_chunk_buffer);
-}
-
-//
-
-int CMpeg2Dec::skip_chunk(int bytes)
-{
- if(!bytes)
- return 0;
-
- int len = 0;
-
- uint8_t* current = m_buf_start;
- uint8_t* limit = current + bytes;
-
- while(current < limit)
- {
- if(m_shift == 0x00000100)
- {
- m_shift = 0xffffff00;
- len = ++current - m_buf_start;
- break;
- }
-
- m_shift = (m_shift | *current++) << 8;
- }
-
- m_buf_start = current;
-
- return len;
-}
-
-int CMpeg2Dec::copy_chunk(int bytes)
-{
- if(!bytes)
- return 0;
-
- int len = 0;
-
- // this assembly gives us a nice speed up
- // 36 sec down to 32 sec decoding the ts.stream.tpr test file
- // (idtc, mc was set to null)
-#ifndef _WIN64
- __asm
- {
- mov ebx, this
- mov esi, [ebx].m_buf_start
- mov edi, [ebx].m_chunk_ptr
- mov ecx, bytes
- mov edx, [ebx].m_shift
-
- copy_chunk_loop:
-
- cmp edx, 0x00000100
- jne copy_chunk_continue
- mov edx, 0xffffff00
-
- inc edi
- mov [ebx].m_chunk_ptr, edi
-
- inc esi
- mov eax, esi
- sub eax, [ebx].m_buf_start
- mov len, eax
-
- jmp copy_chunk_end
-
- copy_chunk_continue:
-
- movzx eax, byte ptr [esi]
- or edx, eax
- shl edx, 8
- mov byte ptr [edi], al
- inc esi
- inc edi
- dec ecx
- jnz copy_chunk_loop
-
- copy_chunk_end:
-
- mov [ebx].m_buf_start, esi
- mov [ebx].m_shift, edx
- }
-#else
- uint8_t* chunk_ptr = m_chunk_ptr;
- uint8_t* current = m_buf_start;
- uint8_t* limit = current + bytes;
-
- while(current < limit)
- {
- if(m_shift == 0x00000100)
- {
- m_shift = 0xffffff00;
- len = ++current - m_buf_start;
- m_chunk_ptr = ++chunk_ptr;
- break;
- }
-
- m_shift = (m_shift | (*chunk_ptr++ = *current++)) << 8;
- }
-
- m_buf_start = current;
-#endif
- return len;
-}
-
-mpeg2_state_t CMpeg2Dec::seek_chunk()
-{
- int size = m_buf_end - m_buf_start;
-
- if(int skipped = skip_chunk(size))
- {
- m_bytes_since_pts += skipped;
- m_code = m_buf_start[-1];
- return (mpeg2_state_t)-1;
- }
-
- m_bytes_since_pts += size;
- return STATE_BUFFER;
-}
-
-mpeg2_state_t CMpeg2Dec::seek_header()
-{
- while(m_code != 0xb3 && (m_code != 0xb7 && m_code != 0xb8 && m_code || m_sequence.width == (unsigned)-1))
- {
- if(seek_chunk() == STATE_BUFFER)
- return STATE_BUFFER;
- }
-
- m_chunk_start = m_chunk_ptr = m_chunk_buffer;
-
- return m_code
- ? mpeg2_parse_header()
- : mpeg2_header_picture_start();
-}
-
-mpeg2_state_t CMpeg2Dec::seek_sequence()
-{
- mpeg2_header_state_init();
- m_action = &CMpeg2Dec::seek_header;
- return seek_header();
-}
-
-//
-
-void CMpeg2Dec::mpeg2_buffer(uint8_t* start, uint8_t* end)
-{
- m_buf_start = start;
- m_buf_end = end;
-}
-
-int CMpeg2Dec::mpeg2_getpos()
-{
- return m_buf_end - m_buf_start;
-}
-
-//
-
-mpeg2_state_t CMpeg2Dec::mpeg2_parse()
-{
- if(m_action)
- {
- mpeg2_state_t state = (this->*m_action)();
- if((int)state >= 0)
- return state;
- }
-
- while(1)
- {
- while((unsigned)(m_code - m_first_decode_slice) < m_nb_decode_slices)
- {
- int size_buffer = m_buf_end - m_buf_start;
- int size_chunk = (m_chunk_buffer + BUFFER_SIZE - m_chunk_ptr);
- int copied;
-
- if(size_buffer <= size_chunk)
- {
- copied = copy_chunk(size_buffer);
- if(!copied)
- {
- m_bytes_since_pts += size_buffer;
- m_chunk_ptr += size_buffer;
- return STATE_BUFFER;
- }
- }
- else
- {
- copied = copy_chunk(size_chunk);
- if(!copied)
- {
- /* filled the chunk buffer without finding a start code */
- m_bytes_since_pts += size_chunk;
- m_action = &CMpeg2Dec::seek_chunk;
- return STATE_INVALID;
- }
- }
-
- m_bytes_since_pts += copied;
-
- m_decoder.mpeg2_slice(m_code, m_chunk_start);
- m_code = m_buf_start[-1];
- m_chunk_ptr = m_chunk_start;
- }
-
- if((unsigned)(m_code - 1) >= 0xb0 - 1)
- break;
- if(seek_chunk() == STATE_BUFFER)
- return STATE_BUFFER;
- }
-
- switch(m_code)
- {
- case 0x00:
- m_action = &CMpeg2Dec::mpeg2_header_picture_start;
- return m_state;
- case 0xb7:
- m_action = &CMpeg2Dec::mpeg2_header_end;
- break;
- case 0xb3:
- case 0xb8:
- m_action = &CMpeg2Dec::mpeg2_parse_header;
- break;
- case 0xbe:
- m_action = &CMpeg2Dec::seek_chunk;
- return STATE_PADDING;
- default:
- m_action = &CMpeg2Dec::seek_chunk;
- return STATE_INVALID;
- }
-
- if(m_state != STATE_SLICE)
- m_state = STATE_INVALID;
-
- return m_state;
-}
-
-
-void CMpeg2Dec::mpeg2_skip(int skip)
-{
- m_first_decode_slice = 1;
- m_nb_decode_slices = skip ? 0 : (0xb0 - 1);
-}
-
-void CMpeg2Dec::mpeg2_slice_region(int start, int end)
-{
- start = (start < 1) ? 1 : (start > 0xb0) ? 0xb0 : start;
- end = (end < start) ? start : (end > 0xb0) ? 0xb0 : end;
- m_first_decode_slice = start;
- m_nb_decode_slices = end - start;
-}
-
-void CMpeg2Dec::mpeg2_pts(uint32_t pts)
-{
- m_pts_previous = m_pts_current;
- m_pts_current = pts;
- m_num_pts++;
- m_bytes_since_pts = 0;
-}
-
-//
-
-/* decode.c */
-
-#define RECEIVED(code,state) (((state) << 8) + (code))
-
-mpeg2_state_t CMpeg2Dec::mpeg2_seek_sequence()
-{
- mpeg2_header_state_init();
- m_action = &CMpeg2Dec::seek_header;
- return seek_header();
-}
-
-mpeg2_state_t CMpeg2Dec::mpeg2_parse_header()
-{
- static int (CMpeg2Dec::* process_header[]) () =
- {
- &CMpeg2Dec::mpeg2_header_picture,
- &CMpeg2Dec::mpeg2_header_extension,
- &CMpeg2Dec::mpeg2_header_user_data,
- &CMpeg2Dec::mpeg2_header_sequence,
- NULL, NULL, NULL, NULL,
- &CMpeg2Dec::mpeg2_header_gop
- };
-
- m_action = &CMpeg2Dec::mpeg2_parse_header;
-
- while(1)
- {
- int size_buffer = m_buf_end - m_buf_start;
- int size_chunk = (m_chunk_buffer + BUFFER_SIZE - m_chunk_ptr);
- int copied;
- if(size_buffer <= size_chunk)
- {
- copied = copy_chunk(size_buffer);
- if(!copied)
- {
- m_bytes_since_pts += size_buffer;
- m_chunk_ptr += size_buffer;
- return STATE_BUFFER;
- }
- }
- else
- {
- copied = copy_chunk(size_chunk);
- if(!copied)
- {
- /* filled the chunk buffer without finding a start code */
- m_bytes_since_pts += size_chunk;
- m_code = 0xb4;
- m_action = &CMpeg2Dec::seek_header;
- return STATE_INVALID;
- }
- }
- m_bytes_since_pts += copied;
-
- if((this->*(process_header[m_code & 0x0b]))())
- {
- m_code = m_buf_start[-1];
- m_action = &CMpeg2Dec::seek_header;
- return STATE_INVALID;
- }
-
- m_code = m_buf_start[-1];
-
- switch(RECEIVED(m_code, m_state))
- {
- /* state transition after a sequence header */
- case RECEIVED(0x00, STATE_SEQUENCE):
- m_action = &CMpeg2Dec::mpeg2_header_picture_start;
- case RECEIVED(0xb8, STATE_SEQUENCE):
- mpeg2_header_sequence_finalize();
- break;
-
- /* other legal state transitions */
- case RECEIVED (0x00, STATE_GOP):
- m_action = &CMpeg2Dec::mpeg2_header_picture_start;
- break;
- case RECEIVED (0x01, STATE_PICTURE):
- case RECEIVED (0x01, STATE_PICTURE_2ND):
- mpeg2_header_matrix_finalize();
- m_action = &CMpeg2Dec::mpeg2_header_slice_start;
- break;
-
- /* legal headers within a given state */
- case RECEIVED (0xb2, STATE_SEQUENCE):
- case RECEIVED (0xb2, STATE_GOP):
- case RECEIVED (0xb2, STATE_PICTURE):
- case RECEIVED (0xb2, STATE_PICTURE_2ND):
- case RECEIVED (0xb5, STATE_SEQUENCE):
- case RECEIVED (0xb5, STATE_PICTURE):
- case RECEIVED (0xb5, STATE_PICTURE_2ND):
- m_chunk_ptr = m_chunk_start;
- continue;
-
- default:
- m_action = &CMpeg2Dec::seek_header;
- return STATE_INVALID;
- }
-
- m_chunk_start = m_chunk_ptr = m_chunk_buffer;
- return m_state;
- }
-}
-
-/* header.c */
-
-void CMpeg2Dec::mpeg2_header_state_init()
-{
- if(m_sequence.width != (unsigned)-1)
- {
- m_sequence.width = (unsigned)-1;
- for(int i = 0; i < m_alloc_index; i++)
- _aligned_free(m_fbuf_alloc[i].buf[0]);
- }
-
- m_decoder.m_scan = mpeg2_scan_norm_2;
- m_picture = m_pictures;
- m_fbuf[0] = &m_fbuf_alloc[0];
- m_fbuf[1] = &m_fbuf_alloc[1];
- m_fbuf[2] = &m_fbuf_alloc[2];
- m_first = true;
- m_alloc_index = 0;
- m_first_decode_slice = 1;
- m_nb_decode_slices = 0xb0 - 1;
-}
-
-int CMpeg2Dec::mpeg2_header_sequence()
-{
- uint8_t* buffer = m_chunk_start;
- mpeg2_sequence_t* sequence = &m_new_sequence;
- static unsigned int frame_period[9] = {0, 1126125, 1125000, 1080000, 900900, 900000, 540000, 450450, 450000};
-
- if((buffer[6] & 0x20) != 0x20) /* missing marker_bit */
- return 1;
-
- int i = (buffer[0] << 16) | (buffer[1] << 8) | buffer[2];
- sequence->display_width = sequence->picture_width = i >> 12;
- if(!sequence->display_width)
- return 1;
- sequence->display_height = sequence->picture_height = i & 0xfff;
- if(!sequence->display_height)
- return 1;
-
- sequence->width = (sequence->picture_width + 15) & ~15;
- sequence->height = (sequence->picture_height + 15) & ~15;
- sequence->chroma_width = sequence->width >> 1;
- sequence->chroma_height = sequence->height >> 1;
- sequence->flags = (SEQ_FLAG_PROGRESSIVE_SEQUENCE | SEQ_VIDEO_FORMAT_UNSPECIFIED);
- sequence->pixel_width = buffer[3] >> 4; /* aspect ratio */
- sequence->frame_period = 0;
- if((buffer[3] & 15) < 9) sequence->frame_period = frame_period[buffer[3] & 15];
- sequence->byte_rate = (buffer[4]<<10) | (buffer[5]<<2) | (buffer[6]>>6);
- sequence->vbv_buffer_size = ((buffer[6]<<16)|(buffer[7]<<8))&0x1ff800;
- if(buffer[7] & 4) sequence->flags |= SEQ_FLAG_CONSTRAINED_PARAMETERS;
-
- m_copy_matrix = 3;
- if(buffer[7] & 2)
- {
- for(i = 0; i < 64; i++)
- m_intra_quantizer_matrix[mpeg2_scan_norm_2[i]] = (buffer[i+7] << 7) | (buffer[i+8] >> 1);
- buffer += 64;
- }
- else
- {
- for (i = 0; i < 64; i++)
- m_intra_quantizer_matrix[mpeg2_scan_norm_2[i]] = default_intra_quantizer_matrix[i];
- }
-
- if(buffer[7] & 1)
- {
- for(i = 0; i < 64; i++)
- m_non_intra_quantizer_matrix[mpeg2_scan_norm_2[i]] = buffer[i+8];
- }
- else
- {
- for(i = 0; i < 64; i++)
- m_non_intra_quantizer_matrix[i] = 16;
- }
-
- sequence->profile_level_id = 0x80;
- sequence->colour_primaries = 0;
- sequence->transfer_characteristics = 0;
- sequence->matrix_coefficients = 0;
-
- m_ext_state = SEQ_EXT;
- m_state = STATE_SEQUENCE;
- m_display_offset_x = m_display_offset_y = 0;
-
- m_info.Reset();
- m_info.m_gop = NULL;
-
- return 0;
-}
-
-int CMpeg2Dec::mpeg2_header_gop()
-{
- uint8_t* buffer = m_chunk_start;
- m_info.Reset();
- if(!(buffer[1] & 8))
- return 1;
- m_info.m_gop = &m_gop;
- m_gop.hours = (buffer[0] >> 2) & 31;
- m_gop.minutes = ((buffer[0] << 4) | (buffer[1] >> 4)) & 63;
- m_gop.seconds = ((buffer[1] << 3) | (buffer[2] >> 5)) & 63;
- m_gop.pictures = ((buffer[2] << 1) | (buffer[3] >> 7)) & 63;
- m_gop.flags = (buffer[0] >> 7) | ((buffer[3] >> 4) & 6);
- m_state = STATE_GOP;
- return 0;
-}
-
-mpeg2_state_t CMpeg2Dec::mpeg2_header_picture_start()
-{
- {
- mpeg2_picture_t* picture;
-
- if(m_state != STATE_SLICE_1ST)
- {
- m_state = STATE_PICTURE;
- picture = m_pictures;
- if((m_decoder.m_coding_type != PIC_FLAG_CODING_TYPE_B) ^ (m_picture >= m_pictures + 2))
- picture += 2;
- }
- else
- {
- m_state = STATE_PICTURE_2ND;
- picture = m_picture + 1; /* second field picture */
- }
-
- m_picture = picture;
- }
-
- m_picture->flags = 0;
-
- if(m_num_pts)
- {
- if(m_bytes_since_pts >= 4)
- {
- m_num_pts = 0;
- m_picture->pts = m_pts_current;
- m_picture->flags = PIC_FLAG_PTS;
- }
- else if(m_num_pts > 1)
- {
- m_num_pts = 1;
- m_picture->pts = m_pts_previous;
- m_picture->flags = PIC_FLAG_PTS;
- }
- }
-
- m_picture->display_offset[0].x =
- m_picture->display_offset[1].x =
- m_picture->display_offset[2].x = m_display_offset_x;
- m_picture->display_offset[0].y =
- m_picture->display_offset[1].y =
- m_picture->display_offset[2].y = m_display_offset_y;
-
- return mpeg2_parse_header();
-}
-
-int CMpeg2Dec::mpeg2_header_picture()
-{
- uint8_t* buffer = m_chunk_start;
- mpeg2_picture_t* picture = m_picture;
- int type;
- int low_delay;
-
- type = (buffer [1] >> 3) & 7;
- low_delay = m_sequence.flags & SEQ_FLAG_LOW_DELAY;
-
- if(m_state == STATE_PICTURE)
- {
- mpeg2_picture_t* other;
-
- m_decoder.m_second_field = 0;
- other = m_pictures;
- if(other == picture)
- other += 2;
- if(m_decoder.m_coding_type != PIC_FLAG_CODING_TYPE_B)
- {
- m_fbuf[2] = m_fbuf[1];
- m_fbuf[1] = m_fbuf[0];
- }
- m_fbuf[0] = NULL;
- m_info.Reset();
- m_info.m_current_picture = picture;
- m_info.m_display_picture = picture;
- if(type != PIC_FLAG_CODING_TYPE_B)
- {
- if(!low_delay)
- {
- if(m_first) {
- m_info.m_display_picture = NULL;
- m_first = false;
- }
- else
- {
- m_info.m_display_picture = other;
- if(other->nb_fields == 1)
- m_info.m_display_picture_2nd = other + 1;
- m_info.m_display_fbuf = m_fbuf[1];
- }
- }
-
- if(!low_delay + !NULL/*m_convert_start*/)
- m_info.m_discard_fbuf = m_fbuf[!low_delay + !NULL/*m_convert_start*/];
- }
-
- while(m_alloc_index < 3)
- {
- mpeg2_fbuf_t* fbuf = &m_fbuf_alloc[m_alloc_index++];
- fbuf->id = NULL;
-
- int size = m_decoder.m_width * m_decoder.m_height;
- fbuf->buf[0] = (uint8_t*)_aligned_malloc(6 * size >> 2, 16);
- fbuf->buf[1] = fbuf->buf[0] + size;
- fbuf->buf[2] = fbuf->buf[1] + (size >> 2);
- memset(fbuf->buf[0], 0x10, size);
- memset(fbuf->buf[1], 0x80, size >> 2);
- memset(fbuf->buf[2], 0x80, size >> 2);
- }
- mpeg2_set_fbuf(type);
- }
- else
- {
- m_decoder.m_second_field = 1;
- m_info.m_current_picture_2nd = picture;
- m_info.m_user_data = NULL; m_info.m_user_data_len = 0;
- if(low_delay || type == PIC_FLAG_CODING_TYPE_B)
- m_info.m_display_picture_2nd = picture;
- }
- m_ext_state = PIC_CODING_EXT;
-
- picture->temporal_reference = (buffer[0] << 2) | (buffer[1] >> 6);
-
- m_decoder.m_coding_type = type;
- picture->flags |= type;
-
- if(type == PIC_FLAG_CODING_TYPE_P || type == PIC_FLAG_CODING_TYPE_B)
- {
- /* forward_f_code and backward_f_code - used in mpeg1 only */
- m_decoder.m_f_motion.f_code[1] = (buffer[3] >> 2) & 1;
- m_decoder.m_f_motion.f_code[0] = (((buffer[3] << 1) | (buffer[4] >> 7)) & 7) - 1;
- m_decoder.m_b_motion.f_code[1] = (buffer[4] >> 6) & 1;
- m_decoder.m_b_motion.f_code[0] = ((buffer[4] >> 3) & 7) - 1;
- }
-
- /* XXXXXX decode extra_information_picture as well */
-
- picture->nb_fields = 2;
-
- m_decoder.m_intra_dc_precision = 0;
- m_decoder.m_frame_pred_frame_dct = 1;
- m_decoder.m_q_scale_type = 0;
- m_decoder.m_concealment_motion_vectors = 0;
- m_decoder.m_scan = mpeg2_scan_norm_2;
- m_decoder.m_picture_structure = FRAME_PICTURE;
- m_copy_matrix = 0;
-
- return 0;
-}
-
-int CMpeg2Dec::mpeg2_header_extension()
-{
- static int (CMpeg2Dec::* parser[]) () =
- {
- NULL,
- &CMpeg2Dec::sequence_ext,
- &CMpeg2Dec::sequence_display_ext,
- &CMpeg2Dec::quant_matrix_ext,
- &CMpeg2Dec::copyright_ext,
- NULL, NULL,
- &CMpeg2Dec::picture_display_ext,
- &CMpeg2Dec::picture_coding_ext
- };
-
- int ext, ext_bit;
-
- ext = m_chunk_start[0] >> 4;
- ext_bit = 1 << ext;
-
- if(!(m_ext_state & ext_bit)) /* ignore illegal extensions */
- return 0;
- m_ext_state &= ~ext_bit;
- return (this->*parser[ext])();
-}
-
-int CMpeg2Dec::mpeg2_header_user_data()
-{
- if(!m_info.m_user_data_len) m_info.m_user_data = m_chunk_start;
- else m_info.m_user_data_len += 3;
-
- m_info.m_user_data_len += (m_chunk_ptr - 4 - m_chunk_start);
- m_chunk_start = m_chunk_ptr - 1;
-
- return 0;
-}
-
-void CMpeg2Dec::mpeg2_header_matrix_finalize()
-{
- if(m_copy_matrix & 1)
- memcpy(m_decoder.m_intra_quantizer_matrix, m_intra_quantizer_matrix, 64);
-
- if(m_copy_matrix & 2)
- memcpy(m_decoder.m_non_intra_quantizer_matrix, m_non_intra_quantizer_matrix, 64);
-}
-
-void mpeg2_sequence_t::finalize()
-{
- int w, h;
-
- byte_rate *= 50;
-
- if(flags & SEQ_FLAG_MPEG2)
- {
- switch(pixel_width)
- {
- case 1: /* square pixels */
- pixel_width = pixel_height = 1; return;
- case 2: /* 4:3 aspect ratio */
- w = 4; h = 3; break;
- case 3: /* 16:9 aspect ratio */
- w = 16; h = 9; break;
- case 4: /* 2.21:1 aspect ratio */
- w = 221; h = 100; break;
- default: /* illegal */
- pixel_width = pixel_height = 0; return;
- }
-
- w *= display_height;
- h *= display_width;
- }
- else
- {
- if(byte_rate == 50 * 0x3ffff)
- byte_rate = 0; /* mpeg-1 VBR */
-
- switch(pixel_width)
- {
- case 0: case 15: /* illegal */
- pixel_width = pixel_height = 0; return;
- case 1: /* square pixels */
- pixel_width = pixel_height = 1; return;
- case 3: /* 720x576 16:9 */
- pixel_width = 64; pixel_height = 45; return;
- case 6: /* 720x480 16:9 */
- pixel_width = 32; pixel_height = 27; return;
- case 12: /* 720*480 4:3 */
- pixel_width = 8; pixel_height = 9; return;
- default:
- h = 88 * pixel_width + 1171;
- w = 2000;
- }
- }
-
- pixel_width = w;
- pixel_height = h;
-
- /* find greatest common divisor */
- while(w) {int tmp = w; w = h % tmp; h = tmp;}
-
- pixel_width /= h;
- pixel_height /= h;
-}
-
-void CMpeg2Dec::mpeg2_header_sequence_finalize()
-{
- mpeg2_sequence_t* sequence = &m_new_sequence;
-
- sequence->finalize();
-
- mpeg2_header_matrix_finalize();
-
- m_decoder.m_mpeg1 = !(sequence->flags & SEQ_FLAG_MPEG2);
- m_decoder.m_width = sequence->width;
- m_decoder.m_height = sequence->height;
- m_decoder.m_vertical_position_extension = (sequence->picture_height > 2800);
-
- /*
- * according to 6.1.1.6, repeat sequence headers should be
- * identical to the original. However some DVDs dont respect that
- * and have different bitrates in the repeat sequence headers. So
- * we'll ignore that in the comparison and still consider these as
- * repeat sequence headers.
- */
-
- // EDIT: some dvds will work if we allow the last three fields to vary (which aren't needed anyway)
- // EDIT2: vbv_buffer_size can be ignored as well, not used by libmpeg2
-
- m_sequence.byte_rate = sequence->byte_rate;
- m_sequence.vbv_buffer_size = sequence->vbv_buffer_size;
-
- if(!memcmp(&m_sequence, sequence, FIELD_OFFSET(mpeg2_sequence_t, colour_primaries) /*sizeof(mpeg2_sequence_t)*/))
- {
- m_state = STATE_SEQUENCE_REPEATED;
- }
- else if(m_sequence.width != (unsigned)-1)
- {
- m_action = &CMpeg2Dec::mpeg2_seek_sequence;
- m_state = STATE_INVALID; /* XXXX STATE_INVALID_END ? */
- return;
- }
-
- m_sequence = *sequence;
- m_info.m_sequence = &m_sequence;
-}
-
-mpeg2_state_t CMpeg2Dec::mpeg2_header_slice_start()
-{
- m_info.m_user_data = NULL;
- m_info.m_user_data_len = 0;
- m_state = (m_picture->nb_fields > 1 || m_state == STATE_PICTURE_2ND) ? STATE_SLICE : STATE_SLICE_1ST;
-
- if(!m_nb_decode_slices)
- {
- m_picture->flags |= PIC_FLAG_SKIP;
- }
- else
- {
- int b_type = m_decoder.m_coding_type == B_TYPE;
- m_decoder.mpeg2_init_fbuf(m_fbuf[0]->buf, m_fbuf[b_type + 1]->buf, m_fbuf[b_type]->buf);
- }
-
- m_action = NULL;
-
- return (mpeg2_state_t)-1;
-}
-
-mpeg2_state_t CMpeg2Dec::mpeg2_header_end()
-{
- mpeg2_picture_t* picture = m_pictures;
-
- int b_type = m_decoder.m_coding_type == B_TYPE;
-
- if((m_picture >= picture + 2) ^ b_type)
- picture = m_pictures + 2;
-
- m_state = STATE_END;
- m_info.Reset();
-
- if(!(m_sequence.flags & SEQ_FLAG_LOW_DELAY))
- {
- m_info.m_display_picture = picture;
- if(picture->nb_fields == 1)
- m_info.m_display_picture_2nd = picture + 1;
- m_info.m_display_fbuf = m_fbuf[b_type];
- m_info.m_discard_fbuf = m_fbuf[b_type + 1];
- }
- else
- {
- m_info.m_discard_fbuf = m_fbuf[b_type];
- }
-
- m_action = &CMpeg2Dec::mpeg2_seek_sequence;
- m_first = true;
-
- return STATE_END;
-}
-
-void CMpeg2Dec::mpeg2_set_fbuf(int coding_type)
-{
- for(int i = 0; i < 3; i++)
- {
- if(m_fbuf[1] != &m_fbuf_alloc[i] && m_fbuf[2] != &m_fbuf_alloc[i])
- {
- m_fbuf[0] = &m_fbuf_alloc[i];
- m_info.m_current_fbuf = m_fbuf[0];
- if(coding_type == B_TYPE || (m_sequence.flags & SEQ_FLAG_LOW_DELAY))
- {
- if(coding_type == B_TYPE)
- m_info.m_discard_fbuf = m_fbuf[0];
- m_info.m_display_fbuf = m_fbuf[0];
- }
- break;
- }
- }
-}
-
-//
-
-int CMpeg2Dec::sequence_ext()
-{
- uint8_t* buffer = m_chunk_start;
- mpeg2_sequence_t* sequence = &m_new_sequence;
-
- if(!(buffer[3]&1))
- return 1;
-
- sequence->profile_level_id = (buffer[0] << 4) | (buffer[1] >> 4);
-
- sequence->display_width =
- sequence->picture_width += ((buffer[1] << 13) | (buffer[2] << 5)) & 0x3000;
- sequence->display_height =
- sequence->picture_height += (buffer[2] << 7) & 0x3000;
-
- sequence->width = (sequence->picture_width + 15) & ~15;
- sequence->height = (sequence->picture_height + 15) & ~15;
-
- sequence->flags |= SEQ_FLAG_MPEG2;
-
- if(!(buffer[1] & 8))
- {
- sequence->flags &= ~SEQ_FLAG_PROGRESSIVE_SEQUENCE;
- sequence->width = (sequence->width + 31) & ~31;
- sequence->height = (sequence->height + 31) & ~31;
- }
-
- if(buffer[5] & 0x80)
- {
- sequence->flags |= SEQ_FLAG_LOW_DELAY;
- }
-
- sequence->chroma_width = sequence->width;
- sequence->chroma_height = sequence->height;
-
- switch(buffer[1] & 6)
- {
- case 0: /* invalid */
- return 1;
- case 2: /* 4:2:0 */
- sequence->chroma_height >>= 1;
- case 4: /* 4:2:2 */
- sequence->chroma_width >>= 1;
- }
-
- sequence->byte_rate += ((buffer[2]<<25) | (buffer[3]<<17)) & 0x3ffc0000;
-
- sequence->vbv_buffer_size |= buffer[4] << 21;
-
- sequence->frame_period =
- sequence->frame_period * ((buffer[5]&31)+1) / (((buffer[5]>>2)&3)+1);
-
- m_ext_state = SEQ_DISPLAY_EXT;
-
- return 0;
-}
-
-int CMpeg2Dec::sequence_display_ext()
-{
- uint8_t* buffer = m_chunk_start;
- mpeg2_sequence_t* sequence = &m_new_sequence;
-
- uint32_t flags = (sequence->flags & ~SEQ_MASK_VIDEO_FORMAT) | ((buffer[0]<<4) & SEQ_MASK_VIDEO_FORMAT);
- if(buffer[0] & 1)
- {
- flags |= SEQ_FLAG_COLOUR_DESCRIPTION;
- sequence->colour_primaries = buffer[1];
- sequence->transfer_characteristics = buffer[2];
- sequence->matrix_coefficients = buffer[3];
- buffer += 3;
- }
-
- if(!(buffer[2] & 2)) /* missing marker_bit */
- return 1;
-
- // ???
-// sequence->flags = flags;
-
- sequence->display_width = (buffer[1] << 6) | (buffer[2] >> 2);
- sequence->display_height = ((buffer[2]& 1 ) << 13) | (buffer[3] << 5) | (buffer[4] >> 3);
-
- return 0;
-}
-
-int CMpeg2Dec::quant_matrix_ext()
-{
- uint8_t* buffer = m_chunk_start;
-
- if(buffer[0] & 8)
- {
- for(int i = 0; i < 64; i++)
- m_intra_quantizer_matrix[mpeg2_scan_norm_2[i]] = (buffer[i] << 5) | (buffer[i+1] >> 3);
- m_copy_matrix |= 1;
- buffer += 64;
- }
-
- if(buffer[0] & 4)
- {
- for(int i = 0; i < 64; i++)
- m_non_intra_quantizer_matrix[mpeg2_scan_norm_2[i]] = (buffer[i] << 6) | (buffer[i+1] >> 2);
- m_copy_matrix |= 2;
- }
-
- return 0;
-}
-
-int CMpeg2Dec::copyright_ext()
-{
- return 0;
-}
-
-int CMpeg2Dec::picture_display_ext()
-{
- uint8_t* buffer = m_chunk_start;
- mpeg2_picture_t* picture = m_picture;
-
- int nb_pos = picture->nb_fields;
- if(m_sequence.flags & SEQ_FLAG_PROGRESSIVE_SEQUENCE)
- nb_pos >>= 1;
-
- int i = 0;
-
- for(; i < nb_pos; i++)
- {
- int x = ((buffer[4*i] << 24) | (buffer[4*i+1] << 16) |
- (buffer[4*i+2] << 8) | buffer[4*i+3]) >> (11-2*i);
- int y = ((buffer[4*i+2] << 24) | (buffer[4*i+3] << 16) |
- (buffer[4*i+4] << 8) | buffer[4*i+5]) >> (10-2*i);
- if(!(x&y&1))
- return 1;
-
- picture->display_offset[i].x = m_display_offset_x = x >> 1;
- picture->display_offset[i].y = m_display_offset_y = y >> 1;
- }
-
- for(; i < 3; i++)
- {
- picture->display_offset[i].x = m_display_offset_x;
- picture->display_offset[i].y = m_display_offset_y;
- }
-
- return 0;
-}
-
-int CMpeg2Dec::picture_coding_ext()
-{
- uint8_t* buffer = m_chunk_start;
- mpeg2_picture_t* picture = m_picture;
-
- /* pre subtract 1 for use later in compute_motion_vector */
- m_decoder.m_f_motion.f_code[0] = (buffer[0] & 15) - 1;
- m_decoder.m_f_motion.f_code[1] = (buffer[1] >> 4) - 1;
- m_decoder.m_b_motion.f_code[0] = (buffer[1] & 15) - 1;
- m_decoder.m_b_motion.f_code[1] = (buffer[2] >> 4) - 1;
-
- m_decoder.m_intra_dc_precision = (buffer[2] >> 2) & 3;
- m_decoder.m_picture_structure = buffer[2] & 3;
- switch(m_decoder.m_picture_structure)
- {
- case TOP_FIELD:
- picture->flags |= PIC_FLAG_TOP_FIELD_FIRST;
- case BOTTOM_FIELD:
- picture->nb_fields = 1;
- break;
- case FRAME_PICTURE:
- if(!(m_sequence.flags & SEQ_FLAG_PROGRESSIVE_SEQUENCE))
- {
- picture->nb_fields = (buffer[3] & 2) ? 3 : 2;
- picture->flags |= (buffer[3] & 128) ? PIC_FLAG_TOP_FIELD_FIRST : 0;
- }
- else
- {
- picture->nb_fields = (buffer[3]&2) ? ((buffer[3]&128) ? 6 : 4) : 2;
- }
- break;
- default:
- return 1;
- }
-
- m_decoder.m_top_field_first = buffer[3] >> 7;
- m_decoder.m_frame_pred_frame_dct = (buffer[3] >> 6) & 1;
- m_decoder.m_concealment_motion_vectors = (buffer[3] >> 5) & 1;
- m_decoder.m_q_scale_type = (buffer[3] >> 4) & 1;
- m_decoder.m_intra_vlc_format = (buffer[3] >> 3) & 1;
- m_decoder.m_scan = (buffer[3] & 4) ? mpeg2_scan_alt_2 : mpeg2_scan_norm_2;
-
- if(buffer[3] & 2)
- picture->flags |= PIC_FLAG_REPEAT_FIRST_FIELD;
-
- picture->flags |= (buffer[4] & 0x80) ? PIC_FLAG_PROGRESSIVE_FRAME : 0;
- if(buffer[4] & 0x40)
- picture->flags |= (((buffer[4]<<26) | (buffer[5]<<18) | (buffer[6]<<10)) & PIC_MASK_COMPOSITE_DISPLAY) | PIC_FLAG_COMPOSITE_DISPLAY;
-
- m_ext_state = PIC_DISPLAY_EXT | COPYRIGHT_EXT | QUANT_MATRIX_EXT;
-
- return 0;
-}
-
-//////////////////////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////////////////////
-
-// vlc
-
-#define GETWORD(bit_buf,shift,bit_ptr) \
-do { \
- bit_buf |= ((bit_ptr[0] << 8) | bit_ptr[1]) << (shift); \
- bit_ptr += 2; \
-} while (0)
-/*
-void bitstream_init(const uint8_t * start)
-{
- m_bitstream_buf =
- (start[0] << 24) | (start[1] << 16) | (start[2] << 8) | start[3];
- m_bitstream_ptr = start + 4;
- m_bitstream_bits = -16;
-}
-*/
-/* make sure that there are at least 16 valid bits in bit_buf */
-#define NEEDBITS \
-do { \
- if (bits > 0) { \
- GETWORD (bit_buf, bits, bit_ptr); \
- bits -= 16; \
- } \
-} while (0)
-
-/* remove num valid bits from bit_buf */
-#define DUMPBITS(num) \
-do { \
- bit_buf <<= (num); \
- bits += (num); \
-} while (0)
-
-/* take num bits from the high part of bit_buf and zero extend them */
-#define UBITS(bit_buf,num) (((uint32_t)(bit_buf)) >> (32 - (num)))
-
-/* take num bits from the high part of bit_buf and sign extend them */
-#define SBITS(bit_buf,num) (((int32_t)(bit_buf)) >> (32 - (num)))
-
-typedef struct {
- uint8_t modes;
- uint8_t len;
-} MBtab;
-
-typedef struct {
- uint8_t delta;
- uint8_t len;
-} MVtab;
-
-typedef struct {
- int8_t dmv;
- uint8_t len;
-} DMVtab;
-
-typedef struct {
- uint8_t cbp;
- uint8_t len;
-} CBPtab;
-
-typedef struct {
- uint8_t size;
- uint8_t len;
-} DCtab;
-
-typedef struct {
- uint8_t run;
- uint8_t level;
- uint8_t len;
-} DCTtab;
-
-typedef struct {
- uint8_t mba;
- uint8_t len;
-} MBAtab;
-
-
-#define INTRA MACROBLOCK_INTRA
-#define QUANT MACROBLOCK_QUANT
-
-static const MBtab MB_I [] = {
- {INTRA|QUANT, 2}, {INTRA, 1}
-};
-
-#define MC MACROBLOCK_MOTION_FORWARD
-#define CODED MACROBLOCK_PATTERN
-
-static const MBtab MB_P [] = {
- {INTRA|QUANT, 6}, {CODED|QUANT, 5}, {MC|CODED|QUANT, 5}, {INTRA, 5},
- {MC, 3}, {MC, 3}, {MC, 3}, {MC, 3},
- {CODED, 2}, {CODED, 2}, {CODED, 2}, {CODED, 2},
- {CODED, 2}, {CODED, 2}, {CODED, 2}, {CODED, 2},
- {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1},
- {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1},
- {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1},
- {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1}, {MC|CODED, 1}
-};
-
-#define FWD MACROBLOCK_MOTION_FORWARD
-#define BWD MACROBLOCK_MOTION_BACKWARD
-#define INTER MACROBLOCK_MOTION_FORWARD|MACROBLOCK_MOTION_BACKWARD
-
-static const MBtab MB_B [] = {
- {0, 0}, {INTRA|QUANT, 6},
- {BWD|CODED|QUANT, 6}, {FWD|CODED|QUANT, 6},
- {INTER|CODED|QUANT, 5}, {INTER|CODED|QUANT, 5},
- {INTRA, 5}, {INTRA, 5},
- {FWD, 4}, {FWD, 4}, {FWD, 4}, {FWD, 4},
- {FWD|CODED, 4}, {FWD|CODED, 4}, {FWD|CODED, 4}, {FWD|CODED, 4},
- {BWD, 3}, {BWD, 3}, {BWD, 3}, {BWD, 3},
- {BWD, 3}, {BWD, 3}, {BWD, 3}, {BWD, 3},
- {BWD|CODED, 3}, {BWD|CODED, 3}, {BWD|CODED, 3}, {BWD|CODED, 3},
- {BWD|CODED, 3}, {BWD|CODED, 3}, {BWD|CODED, 3}, {BWD|CODED, 3},
- {INTER, 2}, {INTER, 2}, {INTER, 2}, {INTER, 2},
- {INTER, 2}, {INTER, 2}, {INTER, 2}, {INTER, 2},
- {INTER, 2}, {INTER, 2}, {INTER, 2}, {INTER, 2},
- {INTER, 2}, {INTER, 2}, {INTER, 2}, {INTER, 2},
- {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2},
- {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2},
- {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2},
- {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}, {INTER|CODED, 2}
-};
-
-#undef INTRA
-#undef QUANT
-#undef MC
-#undef CODED
-#undef FWD
-#undef BWD
-#undef INTER
-
-
-static const MVtab MV_4 [] = {
- { 3, 6}, { 2, 4}, { 1, 3}, { 1, 3}, { 0, 2}, { 0, 2}, { 0, 2}, { 0, 2}
-};
-
-static const MVtab MV_10 [] = {
- { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10}, { 0,10},
- { 0,10}, { 0,10}, { 0,10}, { 0,10}, {15,10}, {14,10}, {13,10}, {12,10},
- {11,10}, {10,10}, { 9, 9}, { 9, 9}, { 8, 9}, { 8, 9}, { 7, 9}, { 7, 9},
- { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7}, { 6, 7},
- { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7}, { 5, 7},
- { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}, { 4, 7}
-};
-
-
-static const DMVtab DMV_2 [] = {
- { 0, 1}, { 0, 1}, { 1, 2}, {-1, 2}
-};
-
-
-static const CBPtab CBP_7 [] = {
- {0x22, 7}, {0x12, 7}, {0x0a, 7}, {0x06, 7},
- {0x21, 7}, {0x11, 7}, {0x09, 7}, {0x05, 7},
- {0x3f, 6}, {0x3f, 6}, {0x03, 6}, {0x03, 6},
- {0x24, 6}, {0x24, 6}, {0x18, 6}, {0x18, 6},
- {0x3e, 5}, {0x3e, 5}, {0x3e, 5}, {0x3e, 5},
- {0x02, 5}, {0x02, 5}, {0x02, 5}, {0x02, 5},
- {0x3d, 5}, {0x3d, 5}, {0x3d, 5}, {0x3d, 5},
- {0x01, 5}, {0x01, 5}, {0x01, 5}, {0x01, 5},
- {0x38, 5}, {0x38, 5}, {0x38, 5}, {0x38, 5},
- {0x34, 5}, {0x34, 5}, {0x34, 5}, {0x34, 5},
- {0x2c, 5}, {0x2c, 5}, {0x2c, 5}, {0x2c, 5},
- {0x1c, 5}, {0x1c, 5}, {0x1c, 5}, {0x1c, 5},
- {0x28, 5}, {0x28, 5}, {0x28, 5}, {0x28, 5},
- {0x14, 5}, {0x14, 5}, {0x14, 5}, {0x14, 5},
- {0x30, 5}, {0x30, 5}, {0x30, 5}, {0x30, 5},
- {0x0c, 5}, {0x0c, 5}, {0x0c, 5}, {0x0c, 5},
- {0x20, 4}, {0x20, 4}, {0x20, 4}, {0x20, 4},
- {0x20, 4}, {0x20, 4}, {0x20, 4}, {0x20, 4},
- {0x10, 4}, {0x10, 4}, {0x10, 4}, {0x10, 4},
- {0x10, 4}, {0x10, 4}, {0x10, 4}, {0x10, 4},
- {0x08, 4}, {0x08, 4}, {0x08, 4}, {0x08, 4},
- {0x08, 4}, {0x08, 4}, {0x08, 4}, {0x08, 4},
- {0x04, 4}, {0x04, 4}, {0x04, 4}, {0x04, 4},
- {0x04, 4}, {0x04, 4}, {0x04, 4}, {0x04, 4},
- {0x3c, 3}, {0x3c, 3}, {0x3c, 3}, {0x3c, 3},
- {0x3c, 3}, {0x3c, 3}, {0x3c, 3}, {0x3c, 3},
- {0x3c, 3}, {0x3c, 3}, {0x3c, 3}, {0x3c, 3},
- {0x3c, 3}, {0x3c, 3}, {0x3c, 3}, {0x3c, 3}
-};
-
-static const CBPtab CBP_9 [] = {
- {0, 0}, {0x00, 9}, {0x27, 9}, {0x1b, 9},
- {0x3b, 9}, {0x37, 9}, {0x2f, 9}, {0x1f, 9},
- {0x3a, 8}, {0x3a, 8}, {0x36, 8}, {0x36, 8},
- {0x2e, 8}, {0x2e, 8}, {0x1e, 8}, {0x1e, 8},
- {0x39, 8}, {0x39, 8}, {0x35, 8}, {0x35, 8},
- {0x2d, 8}, {0x2d, 8}, {0x1d, 8}, {0x1d, 8},
- {0x26, 8}, {0x26, 8}, {0x1a, 8}, {0x1a, 8},
- {0x25, 8}, {0x25, 8}, {0x19, 8}, {0x19, 8},
- {0x2b, 8}, {0x2b, 8}, {0x17, 8}, {0x17, 8},
- {0x33, 8}, {0x33, 8}, {0x0f, 8}, {0x0f, 8},
- {0x2a, 8}, {0x2a, 8}, {0x16, 8}, {0x16, 8},
- {0x32, 8}, {0x32, 8}, {0x0e, 8}, {0x0e, 8},
- {0x29, 8}, {0x29, 8}, {0x15, 8}, {0x15, 8},
- {0x31, 8}, {0x31, 8}, {0x0d, 8}, {0x0d, 8},
- {0x23, 8}, {0x23, 8}, {0x13, 8}, {0x13, 8},
- {0x0b, 8}, {0x0b, 8}, {0x07, 8}, {0x07, 8}
-};
-
-
-static const DCtab DC_lum_5 [] = {
- {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
- {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
- {0, 3}, {0, 3}, {0, 3}, {0, 3}, {3, 3}, {3, 3}, {3, 3}, {3, 3},
- {4, 3}, {4, 3}, {4, 3}, {4, 3}, {5, 4}, {5, 4}, {6, 5}
-};
-
-static const DCtab DC_chrom_5 [] = {
- {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2},
- {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
- {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
- {3, 3}, {3, 3}, {3, 3}, {3, 3}, {4, 4}, {4, 4}, {5, 5}
-};
-
-static const DCtab DC_long [] = {
- {6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, { 6, 5}, { 6, 5},
- {6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, {6, 5}, { 6, 5}, { 6, 5},
- {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, { 7, 6}, { 7, 6},
- {8, 7}, {8, 7}, {8, 7}, {8, 7}, {9, 8}, {9, 8}, {10, 9}, {11, 9}
-};
-
-
-static const DCTtab DCT_16 [] = {
- {129, 0, 0}, {129, 0, 0}, {129, 0, 0}, {129, 0, 0},
- {129, 0, 0}, {129, 0, 0}, {129, 0, 0}, {129, 0, 0},
- {129, 0, 0}, {129, 0, 0}, {129, 0, 0}, {129, 0, 0},
- {129, 0, 0}, {129, 0, 0}, {129, 0, 0}, {129, 0, 0},
- { 2,18, 0}, { 2,17, 0}, { 2,16, 0}, { 2,15, 0},
- { 7, 3, 0}, { 17, 2, 0}, { 16, 2, 0}, { 15, 2, 0},
- { 14, 2, 0}, { 13, 2, 0}, { 12, 2, 0}, { 32, 1, 0},
- { 31, 1, 0}, { 30, 1, 0}, { 29, 1, 0}, { 28, 1, 0}
-};
-
-static const DCTtab DCT_15 [] = {
- { 1,40,15}, { 1,39,15}, { 1,38,15}, { 1,37,15},
- { 1,36,15}, { 1,35,15}, { 1,34,15}, { 1,33,15},
- { 1,32,15}, { 2,14,15}, { 2,13,15}, { 2,12,15},
- { 2,11,15}, { 2,10,15}, { 2, 9,15}, { 2, 8,15},
- { 1,31,14}, { 1,31,14}, { 1,30,14}, { 1,30,14},
- { 1,29,14}, { 1,29,14}, { 1,28,14}, { 1,28,14},
- { 1,27,14}, { 1,27,14}, { 1,26,14}, { 1,26,14},
- { 1,25,14}, { 1,25,14}, { 1,24,14}, { 1,24,14},
- { 1,23,14}, { 1,23,14}, { 1,22,14}, { 1,22,14},
- { 1,21,14}, { 1,21,14}, { 1,20,14}, { 1,20,14},
- { 1,19,14}, { 1,19,14}, { 1,18,14}, { 1,18,14},
- { 1,17,14}, { 1,17,14}, { 1,16,14}, { 1,16,14}
-};
-
-static const DCTtab DCT_13 [] = {
- { 11, 2,13}, { 10, 2,13}, { 6, 3,13}, { 4, 4,13},
- { 3, 5,13}, { 2, 7,13}, { 2, 6,13}, { 1,15,13},
- { 1,14,13}, { 1,13,13}, { 1,12,13}, { 27, 1,13},
- { 26, 1,13}, { 25, 1,13}, { 24, 1,13}, { 23, 1,13},
- { 1,11,12}, { 1,11,12}, { 9, 2,12}, { 9, 2,12},
- { 5, 3,12}, { 5, 3,12}, { 1,10,12}, { 1,10,12},
- { 3, 4,12}, { 3, 4,12}, { 8, 2,12}, { 8, 2,12},
- { 22, 1,12}, { 22, 1,12}, { 21, 1,12}, { 21, 1,12},
- { 1, 9,12}, { 1, 9,12}, { 20, 1,12}, { 20, 1,12},
- { 19, 1,12}, { 19, 1,12}, { 2, 5,12}, { 2, 5,12},
- { 4, 3,12}, { 4, 3,12}, { 1, 8,12}, { 1, 8,12},
- { 7, 2,12}, { 7, 2,12}, { 18, 1,12}, { 18, 1,12}
-};
-
-static const DCTtab DCT_B14_10 [] = {
- { 17, 1,10}, { 6, 2,10}, { 1, 7,10}, { 3, 3,10},
- { 2, 4,10}, { 16, 1,10}, { 15, 1,10}, { 5, 2,10}
-};
-
-static const DCTtab DCT_B14_8 [] = {
- { 65, 0, 6}, { 65, 0, 6}, { 65, 0, 6}, { 65, 0, 6},
- { 3, 2, 7}, { 3, 2, 7}, { 10, 1, 7}, { 10, 1, 7},
- { 1, 4, 7}, { 1, 4, 7}, { 9, 1, 7}, { 9, 1, 7},
- { 8, 1, 6}, { 8, 1, 6}, { 8, 1, 6}, { 8, 1, 6},
- { 7, 1, 6}, { 7, 1, 6}, { 7, 1, 6}, { 7, 1, 6},
- { 2, 2, 6}, { 2, 2, 6}, { 2, 2, 6}, { 2, 2, 6},
- { 6, 1, 6}, { 6, 1, 6}, { 6, 1, 6}, { 6, 1, 6},
- { 14, 1, 8}, { 1, 6, 8}, { 13, 1, 8}, { 12, 1, 8},
- { 4, 2, 8}, { 2, 3, 8}, { 1, 5, 8}, { 11, 1, 8}
-};
-
-static const DCTtab DCT_B14AC_5 [] = {
- { 1, 3, 5}, { 5, 1, 5}, { 4, 1, 5},
- { 1, 2, 4}, { 1, 2, 4}, { 3, 1, 4}, { 3, 1, 4},
- { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
- {129, 0, 2}, {129, 0, 2}, {129, 0, 2}, {129, 0, 2},
- {129, 0, 2}, {129, 0, 2}, {129, 0, 2}, {129, 0, 2},
- { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
- { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}
-};
-
-static const DCTtab DCT_B14DC_5 [] = {
- { 1, 3, 5}, { 5, 1, 5}, { 4, 1, 5},
- { 1, 2, 4}, { 1, 2, 4}, { 3, 1, 4}, { 3, 1, 4},
- { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
- { 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}
-};
-
-static const DCTtab DCT_B15_10 [] = {
- { 6, 2, 9}, { 6, 2, 9}, { 15, 1, 9}, { 15, 1, 9},
- { 3, 4,10}, { 17, 1,10}, { 16, 1, 9}, { 16, 1, 9}
-};
-
-static const DCTtab DCT_B15_8 [] = {
- { 65, 0, 6}, { 65, 0, 6}, { 65, 0, 6}, { 65, 0, 6},
- { 8, 1, 7}, { 8, 1, 7}, { 9, 1, 7}, { 9, 1, 7},
- { 7, 1, 7}, { 7, 1, 7}, { 3, 2, 7}, { 3, 2, 7},
- { 1, 7, 6}, { 1, 7, 6}, { 1, 7, 6}, { 1, 7, 6},
- { 1, 6, 6}, { 1, 6, 6}, { 1, 6, 6}, { 1, 6, 6},
- { 5, 1, 6}, { 5, 1, 6}, { 5, 1, 6}, { 5, 1, 6},
- { 6, 1, 6}, { 6, 1, 6}, { 6, 1, 6}, { 6, 1, 6},
- { 2, 5, 8}, { 12, 1, 8}, { 1,11, 8}, { 1,10, 8},
- { 14, 1, 8}, { 13, 1, 8}, { 4, 2, 8}, { 2, 4, 8},
- { 3, 1, 5}, { 3, 1, 5}, { 3, 1, 5}, { 3, 1, 5},
- { 3, 1, 5}, { 3, 1, 5}, { 3, 1, 5}, { 3, 1, 5},
- { 2, 2, 5}, { 2, 2, 5}, { 2, 2, 5}, { 2, 2, 5},
- { 2, 2, 5}, { 2, 2, 5}, { 2, 2, 5}, { 2, 2, 5},
- { 4, 1, 5}, { 4, 1, 5}, { 4, 1, 5}, { 4, 1, 5},
- { 4, 1, 5}, { 4, 1, 5}, { 4, 1, 5}, { 4, 1, 5},
- { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
- { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
- { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
- { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
- { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
- { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
- { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
- { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3}, { 2, 1, 3},
- {129, 0, 4}, {129, 0, 4}, {129, 0, 4}, {129, 0, 4},
- {129, 0, 4}, {129, 0, 4}, {129, 0, 4}, {129, 0, 4},
- {129, 0, 4}, {129, 0, 4}, {129, 0, 4}, {129, 0, 4},
- {129, 0, 4}, {129, 0, 4}, {129, 0, 4}, {129, 0, 4},
- { 1, 3, 4}, { 1, 3, 4}, { 1, 3, 4}, { 1, 3, 4},
- { 1, 3, 4}, { 1, 3, 4}, { 1, 3, 4}, { 1, 3, 4},
- { 1, 3, 4}, { 1, 3, 4}, { 1, 3, 4}, { 1, 3, 4},
- { 1, 3, 4}, { 1, 3, 4}, { 1, 3, 4}, { 1, 3, 4},
- { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
- { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
- { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
- { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
- { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
- { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
- { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
- { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
- { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
- { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
- { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
- { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
- { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
- { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
- { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
- { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2}, { 1, 1, 2},
- { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3},
- { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3},
- { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3},
- { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3},
- { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3},
- { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3},
- { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3},
- { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3}, { 1, 2, 3},
- { 1, 4, 5}, { 1, 4, 5}, { 1, 4, 5}, { 1, 4, 5},
- { 1, 4, 5}, { 1, 4, 5}, { 1, 4, 5}, { 1, 4, 5},
- { 1, 5, 5}, { 1, 5, 5}, { 1, 5, 5}, { 1, 5, 5},
- { 1, 5, 5}, { 1, 5, 5}, { 1, 5, 5}, { 1, 5, 5},
- { 10, 1, 7}, { 10, 1, 7}, { 2, 3, 7}, { 2, 3, 7},
- { 11, 1, 7}, { 11, 1, 7}, { 1, 8, 7}, { 1, 8, 7},
- { 1, 9, 7}, { 1, 9, 7}, { 1,12, 8}, { 1,13, 8},
- { 3, 3, 8}, { 5, 2, 8}, { 1,14, 8}, { 1,15, 8}
-};
-
-
-static const MBAtab MBA_5 [] = {
- {6, 5}, {5, 5}, {4, 4}, {4, 4}, {3, 4}, {3, 4},
- {2, 3}, {2, 3}, {2, 3}, {2, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3},
- {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1},
- {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}
-};
-
-static const MBAtab MBA_11 [] = {
- {32, 11}, {31, 11}, {30, 11}, {29, 11},
- {28, 11}, {27, 11}, {26, 11}, {25, 11},
- {24, 11}, {23, 11}, {22, 11}, {21, 11},
- {20, 10}, {20, 10}, {19, 10}, {19, 10},
- {18, 10}, {18, 10}, {17, 10}, {17, 10},
- {16, 10}, {16, 10}, {15, 10}, {15, 10},
- {14, 8}, {14, 8}, {14, 8}, {14, 8},
- {14, 8}, {14, 8}, {14, 8}, {14, 8},
- {13, 8}, {13, 8}, {13, 8}, {13, 8},
- {13, 8}, {13, 8}, {13, 8}, {13, 8},
- {12, 8}, {12, 8}, {12, 8}, {12, 8},
- {12, 8}, {12, 8}, {12, 8}, {12, 8},
- {11, 8}, {11, 8}, {11, 8}, {11, 8},
- {11, 8}, {11, 8}, {11, 8}, {11, 8},
- {10, 8}, {10, 8}, {10, 8}, {10, 8},
- {10, 8}, {10, 8}, {10, 8}, {10, 8},
- { 9, 8}, { 9, 8}, { 9, 8}, { 9, 8},
- { 9, 8}, { 9, 8}, { 9, 8}, { 9, 8},
- { 8, 7}, { 8, 7}, { 8, 7}, { 8, 7},
- { 8, 7}, { 8, 7}, { 8, 7}, { 8, 7},
- { 8, 7}, { 8, 7}, { 8, 7}, { 8, 7},
- { 8, 7}, { 8, 7}, { 8, 7}, { 8, 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}
-};
-
-//////////////////////////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////////////////////////
-
-static int non_linear_quantizer_scale [] = {
- 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
-};
-
-bool CMpeg2Decoder::m_idct_initialized = false;
-
-CMpeg2Decoder::CMpeg2Decoder()
-{
- memset(&m_b_motion, 0, sizeof(m_b_motion));
- memset(&m_f_motion, 0, sizeof(m_f_motion));
-
- m_DCTblock = (int16_t*)_aligned_malloc(64*sizeof(int16_t), 16);
- memset(m_DCTblock, 0, 64*sizeof(int16_t));
-
- m_bitstream_buf = 0;
- m_bitstream_bits = 0;
- m_bitstream_ptr = NULL;
-
- memset(&m_dest, 0, sizeof(m_dest));
- memset(&m_picture_dest, 0, sizeof(m_picture_dest));
-
- m_offset = m_stride = m_uv_stride = 0;
- m_limit_x = m_limit_y_16 = m_limit_y_8 = m_limit_y = 0;
-
- memset(&m_dc_dct_pred, 0, sizeof(m_dc_dct_pred));
-
- m_quantizer_scale = m_dmv_offset = 0;
- m_v_offset = 0;
-
- memset(&m_intra_quantizer_matrix, 0, sizeof(m_intra_quantizer_matrix));
- memset(&m_non_intra_quantizer_matrix, 0, sizeof(m_non_intra_quantizer_matrix));
-
- m_width = m_height = 0;
- m_vertical_position_extension = 0;
-
- m_coding_type = 0;
-
- m_intra_dc_precision = 0;
- m_picture_structure = 0;
- m_frame_pred_frame_dct = 0;
- m_concealment_motion_vectors = 0;
- m_q_scale_type = 0;
- m_intra_vlc_format = 0;
- m_top_field_first = 0;
-
- m_scan = NULL;
-
- m_second_field = 0;
-
- m_mpeg1 = 0;
-
- if(g_cpuid.m_flags&CCpuID::sse2)
- {
- m_idct_init = mpeg2_idct_init_sse2;
- m_idct_copy = mpeg2_idct_copy_sse2;
- m_idct_add = mpeg2_idct_add_sse2;
- m_mc = &mpeg2_mc_sse2;
- }
-#ifndef _WIN64
- else if(g_cpuid.m_flags&CCpuID::mmx)
- {
- m_idct_init = mpeg2_idct_init_mmx;
- m_idct_copy = mpeg2_idct_copy_mmx;
- m_idct_add = mpeg2_idct_add_mmx;
- m_mc = &mpeg2_mc_mmx;
- }
- else
-#endif
- {
- m_idct_init = mpeg2_idct_init_c;
- m_idct_copy = mpeg2_idct_copy_c;
- m_idct_add = mpeg2_idct_add_c;
- m_mc = &mpeg2_mc_c;
- }
- if(!m_idct_initialized)
- {
- m_idct_init();
- m_idct_initialized = true;
- }
-}
-
-CMpeg2Decoder::~CMpeg2Decoder()
-{
- if(m_DCTblock) _aligned_free(m_DCTblock);
-}
-
-#define bit_buf (m_bitstream_buf)
-#define bits (m_bitstream_bits)
-#define bit_ptr (m_bitstream_ptr)
-
-int CMpeg2Decoder::get_macroblock_modes()
-{
- int macroblock_modes;
- const MBtab* tab;
-
- switch(m_coding_type)
- {
- case P_TYPE:
- tab = MB_P + UBITS(bit_buf, 5);
- DUMPBITS(tab->len);
- macroblock_modes = tab->modes;
-
- if(m_picture_structure != FRAME_PICTURE)
- {
- if(macroblock_modes & MACROBLOCK_MOTION_FORWARD)
- {
- macroblock_modes |= UBITS(bit_buf, 2) * MOTION_TYPE_BASE;
- DUMPBITS(2);
- }
-
- return macroblock_modes;
- }
- else if(m_frame_pred_frame_dct)
- {
- if(macroblock_modes & MACROBLOCK_MOTION_FORWARD)
- macroblock_modes |= MC_FRAME;
-
- return macroblock_modes;
- }
-
- if(macroblock_modes & MACROBLOCK_MOTION_FORWARD)
- {
- macroblock_modes |= UBITS(bit_buf, 2) * MOTION_TYPE_BASE;
- DUMPBITS(2);
- }
-
- if(macroblock_modes & (MACROBLOCK_INTRA|MACROBLOCK_PATTERN))
- {
- macroblock_modes |= UBITS(bit_buf, 1) * DCT_TYPE_INTERLACED;
- DUMPBITS(1);
- }
-
- return macroblock_modes;
-
- case B_TYPE:
- tab = MB_B + UBITS(bit_buf, 6);
- DUMPBITS(tab->len);
- macroblock_modes = tab->modes;
-
- if(m_picture_structure != FRAME_PICTURE)
- {
- if(!(macroblock_modes & MACROBLOCK_INTRA))
- {
- macroblock_modes |= UBITS(bit_buf, 2) * MOTION_TYPE_BASE;
- DUMPBITS(2);
- }
-
- return macroblock_modes;
- }
- else if(m_frame_pred_frame_dct)
- {
- // if(!(macroblock_modes & MACROBLOCK_INTRA))
- macroblock_modes |= MC_FRAME;
-
- return macroblock_modes;
- }
-/*
- if(macroblock_modes & MACROBLOCK_INTRA)
- goto intra;
-
- macroblock_modes |= UBITS(bit_buf, 2) * MOTION_TYPE_BASE;
- DUMPBITS(2);
-
- if(macroblock_modes & (MACROBLOCK_INTRA|MACROBLOCK_PATTERN))
- {
-intra:
- macroblock_modes |= UBITS(bit_buf, 1) * DCT_TYPE_INTERLACED;
- DUMPBITS(1);
- }
-*/
- if(!(macroblock_modes & MACROBLOCK_INTRA))
- {
- macroblock_modes |= UBITS(bit_buf, 2) * MOTION_TYPE_BASE;
- DUMPBITS(2);
- }
-
- if(macroblock_modes & (MACROBLOCK_INTRA|MACROBLOCK_PATTERN))
- {
- macroblock_modes |= UBITS(bit_buf, 1) * DCT_TYPE_INTERLACED;
- DUMPBITS(1);
- }
-
- return macroblock_modes;
-
- case I_TYPE:
- tab = MB_I + UBITS(bit_buf, 1);
- DUMPBITS(tab->len);
- macroblock_modes = tab->modes;
-
- if(!m_frame_pred_frame_dct && m_picture_structure == FRAME_PICTURE)
- {
- macroblock_modes |= UBITS(bit_buf, 1) * DCT_TYPE_INTERLACED;
- DUMPBITS(1);
- }
-
- return macroblock_modes;
-
- case D_TYPE:
-
- DUMPBITS(1);
- return MACROBLOCK_INTRA;
- }
-
- return 0;
-}
-
-int CMpeg2Decoder::get_quantizer_scale()
-{
- int quantizer_scale_code = UBITS(bit_buf, 5);
- DUMPBITS(5);
-
- return m_q_scale_type
- ? non_linear_quantizer_scale[quantizer_scale_code]
- : (quantizer_scale_code << 1);
-}
-
-int CMpeg2Decoder::get_motion_delta(const int f_code)
-{
- int delta;
- int sign;
- const MVtab* tab;
-
- if(bit_buf & 0x80000000)
- {
- DUMPBITS(1);
- return 0;
- }
- else if(bit_buf >= 0x0c000000)
- {
- tab = MV_4 + UBITS(bit_buf, 4);
- delta = (tab->delta << f_code) + 1;
- bits += tab->len + f_code + 1;
- bit_buf <<= tab->len;
-
- sign = SBITS(bit_buf, 1);
- bit_buf <<= 1;
-
- if(f_code)
- {
- delta += UBITS(bit_buf, f_code);
- }
-
- bit_buf <<= f_code;
-
- return (delta ^ sign) - sign;
- }
- else
- {
- tab = MV_10 + UBITS(bit_buf, 10);
- delta = (tab->delta << f_code) + 1;
- bits += tab->len + 1;
- bit_buf <<= tab->len;
-
- sign = SBITS(bit_buf, 1);
- bit_buf <<= 1;
-
- if(f_code)
- {
- NEEDBITS;
- delta += UBITS(bit_buf, f_code);
- DUMPBITS(f_code);
- }
-
- return (delta ^ sign) - sign;
- }
-}
-
-int CMpeg2Decoder::bound_motion_vector(const int vector, const int f_code)
-{
- return ((int32_t)vector << (27 - f_code)) >> (27 - f_code);
-}
-
-int CMpeg2Decoder::get_dmv()
-{
- const DMVtab* tab = DMV_2 + UBITS(bit_buf, 2);
- DUMPBITS(tab->len);
- return tab->dmv;
-}
-
-int CMpeg2Decoder::get_coded_block_pattern()
-{
- const CBPtab* tab;
-
- NEEDBITS;
-
- if(bit_buf >= 0x20000000)
- {
- tab = CBP_7 + (UBITS(bit_buf, 7) - 16);
- DUMPBITS(tab->len);
- return tab->cbp;
- }
- else
- {
- tab = CBP_9 + UBITS(bit_buf, 9);
- DUMPBITS(tab->len);
- return tab->cbp;
- }
-}
-
-int CMpeg2Decoder::get_luma_dc_dct_diff()
-{
- const DCtab* tab;
- int size;
- int dc_diff;
-
- if(bit_buf < 0xf8000000)
- {
- tab = DC_lum_5 + UBITS(bit_buf, 5);
- size = tab->size;
- if(size)
- {
- bits += tab->len + size;
- bit_buf <<= tab->len;
- dc_diff = UBITS(bit_buf, size) - UBITS(SBITS(~bit_buf, 1), size);
- bit_buf <<= size;
- return dc_diff;
- }
- else
- {
- DUMPBITS(3);
- return 0;
- }
- }
- else
- {
- tab = DC_long + (UBITS(bit_buf, 9) - 0x1e0);
- size = tab->size;
- DUMPBITS(tab->len);
- NEEDBITS;
- dc_diff = UBITS(bit_buf, size) - UBITS(SBITS(~bit_buf, 1), size);
- DUMPBITS(size);
- return dc_diff;
- }
-}
-
-int CMpeg2Decoder::get_chroma_dc_dct_diff()
-{
- const DCtab* tab;
- int size;
- int dc_diff;
-
- if(bit_buf < 0xf8000000)
- {
- tab = DC_chrom_5 + UBITS(bit_buf, 5);
- size = tab->size;
-
- if(size)
- {
- bits += tab->len + size;
- bit_buf <<= tab->len;
- dc_diff = UBITS(bit_buf, size) - UBITS(SBITS(~bit_buf, 1), size);
- bit_buf <<= size;
- return dc_diff;
- }
- else
- {
- DUMPBITS(2);
- return 0;
- }
- }
- else
- {
- tab = DC_long + (UBITS(bit_buf, 10) - 0x3e0);
- size = tab->size;
- DUMPBITS(tab->len + 1);
- NEEDBITS;
- dc_diff = UBITS(bit_buf, size) - UBITS(SBITS(~bit_buf, 1), size);
- DUMPBITS(size);
- return dc_diff;
- }
-}
-
-#undef bit_buf
-#undef bits
-#undef bit_ptr
-
-#define SATURATE(val) \
-do { \
- if((uint32_t)(val + 2048) > 4095) \
- val = SBITS(val, 1) ^ 2047; \
-} while (0)
-
-void CMpeg2Decoder::get_intra_block_B14()
-{
- int i, j;
- int val;
- const uint8_t* scan = m_scan;
- const uint8_t* quant_matrix = m_intra_quantizer_matrix;
- int quantizer_scale = m_quantizer_scale;
- int mismatch;
- const DCTtab* tab;
- uint32_t bit_buf;
- int bits;
- const uint8_t* bit_ptr;
- int16_t* dest;
-
- dest = m_DCTblock;
- i = 0;
- mismatch = ~dest[0];
-
- bit_buf = m_bitstream_buf;
- bits = m_bitstream_bits;
- bit_ptr = m_bitstream_ptr;
-
- NEEDBITS;
-
- while(1)
- {
- if(bit_buf >= 0x28000000)
- {
- tab = DCT_B14AC_5 + (UBITS(bit_buf, 5) - 5);
-
- i += tab->run;
- if(i >= 64)
- break; /* end of block */
-
-normal_code:
- j = scan[i];
- bit_buf <<= tab->len;
- bits += tab->len + 1;
- val = (tab->level * quantizer_scale * quant_matrix[j]) >> 4;
-
- // if(bitstream_get (1)) val = -val;
- val = (val ^ SBITS(bit_buf, 1)) - SBITS(bit_buf, 1);
-
- SATURATE(val);
- dest[j] = val;
- mismatch ^= val;
-
- bit_buf <<= 1;
- NEEDBITS;
-
- continue;
- }
- else if(bit_buf >= 0x04000000)
- {
- tab = DCT_B14_8 + (UBITS(bit_buf, 8) - 4);
-
- i += tab->run;
- if(i < 64)
- goto normal_code;
-
- /* escape code */
-
- i += UBITS(bit_buf << 6, 6) - 64;
- if(i >= 64)
- break; /* illegal, check needed to avoid buffer overflow */
-
- j = scan[i];
-
- DUMPBITS(12);
- NEEDBITS;
- val = (SBITS(bit_buf, 12) * quantizer_scale * quant_matrix[j]) / 16;
-
- SATURATE(val);
- dest[j] = val;
- mismatch ^= val;
-
- DUMPBITS(12);
- NEEDBITS;
-
- continue;
- }
- else if(bit_buf >= 0x02000000)
- {
- tab = DCT_B14_10 + (UBITS(bit_buf, 10) - 8);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else if(bit_buf >= 0x00800000)
- {
- tab = DCT_13 + (UBITS(bit_buf, 13) - 16);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else if(bit_buf >= 0x00200000)
- {
- tab = DCT_15 + (UBITS(bit_buf, 15) - 16);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else
- {
- tab = DCT_16 + UBITS(bit_buf, 16);
- bit_buf <<= 16;
- GETWORD (bit_buf, bits + 16, bit_ptr);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
-
- break; /* illegal, check needed to avoid buffer overflow */
- }
-
- dest[63] ^= mismatch & 1;
- DUMPBITS(2); /* dump end of block code */
- m_bitstream_buf = bit_buf;
- m_bitstream_bits = bits;
- m_bitstream_ptr = bit_ptr;
-}
-
-void CMpeg2Decoder::get_intra_block_B15()
-{
- int i, j;
- int val;
- const uint8_t* scan = m_scan;
- const uint8_t* quant_matrix = m_intra_quantizer_matrix;
- int quantizer_scale = m_quantizer_scale;
- int mismatch;
- const DCTtab* tab;
- uint32_t bit_buf;
- int bits;
- const uint8_t* bit_ptr;
- int16_t* dest;
-
- dest = m_DCTblock;
- i = 0;
- mismatch = ~dest[0];
-
- bit_buf = m_bitstream_buf;
- bits = m_bitstream_bits;
- bit_ptr = m_bitstream_ptr;
-
- NEEDBITS;
-
- while(1)
- {
- if(bit_buf >= 0x04000000)
- {
- tab = DCT_B15_8 + (UBITS(bit_buf, 8) - 4);
-
- i += tab->run;
- if(i < 64)
- {
-normal_code:
- j = scan[i];
- bit_buf <<= tab->len;
- bits += tab->len + 1;
- val = (tab->level * quantizer_scale * quant_matrix[j]) >> 4;
-
- // if(bitstream_get (1)) val = -val;
- val = (val ^ SBITS(bit_buf, 1)) - SBITS(bit_buf, 1);
-
- SATURATE(val);
- dest[j] = val;
- mismatch ^= val;
-
- bit_buf <<= 1;
- NEEDBITS;
-
- continue;
- }
- else
- {
- /* end of block. I commented out this code because if we */
- /* dont exit here we will still exit at the later test :) */
-
- /* if(i >= 128) break; */ /* end of block */
-
- /* escape code */
-
- i += UBITS(bit_buf << 6, 6) - 64;
- if(i >= 64)
- break; /* illegal, check against buffer overflow */
-
- j = scan[i];
-
- DUMPBITS(12);
- NEEDBITS;
- val = (SBITS(bit_buf, 12) *
- quantizer_scale * quant_matrix[j]) / 16;
-
- SATURATE(val);
- dest[j] = val;
- mismatch ^= val;
-
- DUMPBITS(12);
- NEEDBITS;
-
- continue;
- }
- }
- else if(bit_buf >= 0x02000000)
- {
- tab = DCT_B15_10 + (UBITS(bit_buf, 10) - 8);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else if(bit_buf >= 0x00800000)
- {
- tab = DCT_13 + (UBITS(bit_buf, 13) - 16);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else if(bit_buf >= 0x00200000)
- {
- tab = DCT_15 + (UBITS(bit_buf, 15) - 16);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else
- {
- tab = DCT_16 + UBITS(bit_buf, 16);
- bit_buf <<= 16;
- GETWORD(bit_buf, bits + 16, bit_ptr);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
-
- break; /* illegal, check needed to avoid buffer overflow */
- }
-
- dest[63] ^= mismatch & 1;
- DUMPBITS(4); /* dump end of block code */
- m_bitstream_buf = bit_buf;
- m_bitstream_bits = bits;
- m_bitstream_ptr = bit_ptr;
-}
-
-int CMpeg2Decoder::get_non_intra_block()
-{
- int i, j;
- int val;
- const uint8_t* scan = m_scan;
- const uint8_t* quant_matrix = m_non_intra_quantizer_matrix;
- int quantizer_scale = m_quantizer_scale;
- int mismatch;
- const DCTtab* tab;
- uint32_t bit_buf;
- int bits;
- const uint8_t* bit_ptr;
- int16_t* dest;
-
- i = -1;
- mismatch = 1;
- dest = m_DCTblock;
-
- bit_buf = m_bitstream_buf;
- bits = m_bitstream_bits;
- bit_ptr = m_bitstream_ptr;
-
- NEEDBITS;
- if(bit_buf >= 0x28000000)
- {
- tab = DCT_B14DC_5 + (UBITS(bit_buf, 5) - 5);
- goto entry_1;
- }
- else
- {
- goto entry_2;
- }
-
- while(1)
- {
- if(bit_buf >= 0x28000000)
- {
- tab = DCT_B14AC_5 + (UBITS(bit_buf, 5) - 5);
-entry_1:
- i += tab->run;
- if(i >= 64)
- break; /* end of block */
-normal_code:
- j = scan[i];
- bit_buf <<= tab->len;
- bits += tab->len + 1;
- val = ((2*tab->level+1) * quantizer_scale * quant_matrix[j]) >> 5;
-
- /* if(bitstream_get (1)) val = -val; */
- val = (val ^ SBITS(bit_buf, 1)) - SBITS(bit_buf, 1);
-
- SATURATE(val);
- dest[j] = val;
- mismatch ^= val;
-
- bit_buf <<= 1;
- NEEDBITS;
-
- continue;
- }
-
-entry_2:
- if(bit_buf >= 0x04000000)
- {
- tab = DCT_B14_8 + (UBITS(bit_buf, 8) - 4);
-
- i += tab->run;
- if(i < 64)
- goto normal_code;
-
- /* escape code */
-
- i += UBITS(bit_buf << 6, 6) - 64;
- if(i >= 64)
- break; /* illegal, check needed to avoid buffer overflow */
-
- j = scan[i];
-
- DUMPBITS(12);
- NEEDBITS;
- val = 2 * (SBITS(bit_buf, 12) + SBITS(bit_buf, 1)) + 1;
- val = (val * quantizer_scale * quant_matrix[j]) / 32;
-
- SATURATE(val);
- dest[j] = val;
- mismatch ^= val;
-
- DUMPBITS(12);
- NEEDBITS;
-
- continue;
- }
- else if(bit_buf >= 0x02000000)
- {
- tab = DCT_B14_10 + (UBITS(bit_buf, 10) - 8);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else if(bit_buf >= 0x00800000)
- {
- tab = DCT_13 + (UBITS(bit_buf, 13) - 16);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else if(bit_buf >= 0x00200000)
- {
- tab = DCT_15 + (UBITS(bit_buf, 15) - 16);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else
- {
- tab = DCT_16 + UBITS(bit_buf, 16);
- bit_buf <<= 16;
- GETWORD (bit_buf, bits + 16, bit_ptr);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
-
- break; /* illegal, check needed to avoid buffer overflow */
- }
-
- dest[63] ^= mismatch & 1;
- DUMPBITS(2); /* dump end of block code */
- m_bitstream_buf = bit_buf;
- m_bitstream_bits = bits;
- m_bitstream_ptr = bit_ptr;
-
- return i;
-}
-
-void CMpeg2Decoder::get_mpeg1_intra_block()
-{
- int i, j;
- int val;
- const uint8_t* scan = m_scan;
- const uint8_t* quant_matrix = m_intra_quantizer_matrix;
- int quantizer_scale = m_quantizer_scale;
- const DCTtab* tab;
- uint32_t bit_buf;
- int bits;
- const uint8_t* bit_ptr;
- int16_t* dest;
-
- i = 0;
- dest = m_DCTblock;
-
- bit_buf = m_bitstream_buf;
- bits = m_bitstream_bits;
- bit_ptr = m_bitstream_ptr;
-
- NEEDBITS;
-
- while(1)
- {
- if(bit_buf >= 0x28000000)
- {
- tab = DCT_B14AC_5 + (UBITS(bit_buf, 5) - 5);
-
- i += tab->run;
- if(i >= 64)
- break; /* end of block */
-normal_code:
- j = scan[i];
- bit_buf <<= tab->len;
- bits += tab->len + 1;
- val = (tab->level * quantizer_scale * quant_matrix[j]) >> 4;
-
- /* oddification */
- val = (val - 1) | 1;
-
- /* if(bitstream_get (1)) val = -val; */
- val = (val ^ SBITS(bit_buf, 1)) - SBITS(bit_buf, 1);
-
- SATURATE(val);
- dest[j] = val;
-
- bit_buf <<= 1;
- NEEDBITS;
-
- continue;
- }
- else if(bit_buf >= 0x04000000)
- {
- tab = DCT_B14_8 + (UBITS(bit_buf, 8) - 4);
-
- i += tab->run;
- if(i < 64)
- goto normal_code;
-
- /* escape code */
-
- i += UBITS(bit_buf << 6, 6) - 64;
- if(i >= 64)
- break; /* illegal, check needed to avoid buffer overflow */
-
- j = scan[i];
-
- DUMPBITS(12);
- NEEDBITS;
- val = SBITS(bit_buf, 8);
- if(!(val & 0x7f))
- {
- DUMPBITS(8);
- val = UBITS(bit_buf, 8) + 2 * val;
- }
- val = (val * quantizer_scale * quant_matrix[j]) / 16;
-
- /* oddification */
- val = (val + ~SBITS(val, 1)) | 1;
-
- SATURATE(val);
- dest[j] = val;
-
- DUMPBITS(8);
- NEEDBITS;
-
- continue;
- }
- else if(bit_buf >= 0x02000000)
- {
- tab = DCT_B14_10 + (UBITS(bit_buf, 10) - 8);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else if(bit_buf >= 0x00800000)
- {
- tab = DCT_13 + (UBITS(bit_buf, 13) - 16);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else if(bit_buf >= 0x00200000)
- {
- tab = DCT_15 + (UBITS(bit_buf, 15) - 16);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else
- {
- tab = DCT_16 + UBITS(bit_buf, 16);
- bit_buf <<= 16;
- GETWORD(bit_buf, bits + 16, bit_ptr);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
-
- break; /* illegal, check needed to avoid buffer overflow */
- }
-
- DUMPBITS(2); /* dump end of block code */
- m_bitstream_buf = bit_buf;
- m_bitstream_bits = bits;
- m_bitstream_ptr = bit_ptr;
-}
-
-int CMpeg2Decoder::get_mpeg1_non_intra_block()
-{
- int i, j;
- int val;
- const uint8_t* scan = m_scan;
- const uint8_t* quant_matrix = m_non_intra_quantizer_matrix;
- int quantizer_scale = m_quantizer_scale;
- const DCTtab* tab;
- uint32_t bit_buf;
- int bits;
- const uint8_t* bit_ptr;
- int16_t* dest;
-
- i = -1;
- dest = m_DCTblock;
-
- bit_buf = m_bitstream_buf;
- bits = m_bitstream_bits;
- bit_ptr = m_bitstream_ptr;
-
- NEEDBITS;
- if(bit_buf >= 0x28000000)
- {
- tab = DCT_B14DC_5 + (UBITS(bit_buf, 5) - 5);
- goto entry_1;
- }
- else
- {
- goto entry_2;
- }
-
- while(1)
- {
- if(bit_buf >= 0x28000000)
- {
- tab = DCT_B14AC_5 + (UBITS(bit_buf, 5) - 5);
-entry_1:
- i += tab->run;
- if(i >= 64)
- break; /* end of block */
-normal_code:
- j = scan[i];
- bit_buf <<= tab->len;
- bits += tab->len + 1;
- val = ((2*tab->level+1) * quantizer_scale * quant_matrix[j]) >> 5;
-
- /* oddification */
- val = (val - 1) | 1;
-
- /* if(bitstream_get (1)) val = -val; */
- val = (val ^ SBITS(bit_buf, 1)) - SBITS(bit_buf, 1);
-
- SATURATE(val);
- dest[j] = val;
-
- bit_buf <<= 1;
- NEEDBITS;
-
- continue;
- }
-
-entry_2:
- if(bit_buf >= 0x04000000)
- {
- tab = DCT_B14_8 + (UBITS(bit_buf, 8) - 4);
-
- i += tab->run;
- if(i < 64)
- goto normal_code;
-
- /* escape code */
-
- i += UBITS(bit_buf << 6, 6) - 64;
- if(i >= 64)
- break; /* illegal, check needed to avoid buffer overflow */
-
- j = scan[i];
-
- DUMPBITS(12);
- NEEDBITS;
- val = SBITS(bit_buf, 8);
- if(!(val & 0x7f))
- {
- DUMPBITS(8);
- val = UBITS(bit_buf, 8) + 2 * val;
- }
- val = 2 * (val + SBITS(val, 1)) + 1;
- val = (val * quantizer_scale * quant_matrix[j]) / 32;
-
- /* oddification */
- val = (val + ~SBITS(val, 1)) | 1;
-
- SATURATE(val);
- dest[j] = val;
-
- DUMPBITS(8);
- NEEDBITS;
-
- continue;
- }
- else if(bit_buf >= 0x02000000)
- {
- tab = DCT_B14_10 + (UBITS(bit_buf, 10) - 8);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else if(bit_buf >= 0x00800000)
- {
- tab = DCT_13 + (UBITS(bit_buf, 13) - 16);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else if(bit_buf >= 0x00200000)
- {
- tab = DCT_15 + (UBITS(bit_buf, 15) - 16);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
- else
- {
- tab = DCT_16 + UBITS(bit_buf, 16);
- bit_buf <<= 16;
- GETWORD (bit_buf, bits + 16, bit_ptr);
- i += tab->run;
- if(i < 64)
- goto normal_code;
- }
-
- break; /* illegal, check needed to avoid buffer overflow */
- }
-
- DUMPBITS(2); /* dump end of block code */
- m_bitstream_buf = bit_buf;
- m_bitstream_bits = bits;
- m_bitstream_ptr = bit_ptr;
-
- return i;
-}
-
-#define bit_buf (m_bitstream_buf)
-#define bits (m_bitstream_bits)
-#define bit_ptr (m_bitstream_ptr)
-
-void CMpeg2Decoder::slice_intra_DCT(const int cc, uint8_t* dest, int stride)
-{
- NEEDBITS;
-
- /* Get the intra DC coefficient and inverse quantize it */
- m_dc_dct_pred[cc] += (cc == 0)
- ? get_luma_dc_dct_diff()
- : get_chroma_dc_dct_diff();
-
- m_DCTblock[0] = m_dc_dct_pred[cc] << (3 - m_intra_dc_precision);
-
- if(m_mpeg1)
- {
- if(m_coding_type != D_TYPE)
- get_mpeg1_intra_block();
- }
- else if(m_intra_vlc_format)
- {
- get_intra_block_B15();
- }
- else
- {
- get_intra_block_B14();
- }
-
- m_idct_copy(m_DCTblock, dest, stride);
-}
-
-void CMpeg2Decoder::slice_non_intra_DCT(uint8_t* dest, int stride)
-{
- int last = m_mpeg1
- ? get_mpeg1_non_intra_block()
- : get_non_intra_block ();
-
- m_idct_add(last, m_DCTblock, dest, stride);
-}
-
-void CMpeg2Decoder::MOTION(
- mpeg2_mc_fct * const * const table, uint8_t** ref,
- int motion_x, int motion_y,
- unsigned int size, unsigned int y, unsigned int limit_y)
-{
- unsigned int pos_x, pos_y, xy_half, offset, dest_offset;
-
- pos_x = 2 * m_offset + motion_x;
- pos_y = 2 * m_v_offset + motion_y + 2 * y;
-
- if(pos_x > m_limit_x)
- {
- pos_x = ((int)pos_x < 0) ? 0 : m_limit_x;
- motion_x = pos_x - 2 * m_offset;
- }
-
- if(pos_y > limit_y)
- {
- pos_y = ((int)pos_y < 0) ? 0 : limit_y;
- motion_y = pos_y - 2 * m_v_offset - 2 * y;
- }
-
- xy_half = ((pos_y & 1) << 1) | (pos_x & 1);
- offset = (pos_x >> 1) + (pos_y >> 1) * m_stride;
- table[xy_half] (m_dest[0] + y * m_stride + m_offset, ref[0] + offset, m_stride, size);
-
- motion_x /= 2; motion_y /= 2;
-
- xy_half = ((motion_y & 1) << 1) | (motion_x & 1);
- offset = ((m_offset + motion_x) >> 1) + ((((m_v_offset + motion_y) >> 1) + y/2) * m_uv_stride);
- dest_offset = y/2 * m_uv_stride + (m_offset >> 1);
- table[4+xy_half] (m_dest[1] + dest_offset, ref[1] + offset, m_uv_stride, size/2);
- table[4+xy_half] (m_dest[2] + dest_offset, ref[2] + offset, m_uv_stride, size/2);
-}
-
-void CMpeg2Decoder::MOTION_FIELD(
- mpeg2_mc_fct * const * const table, uint8_t** ref,
- int motion_x, int motion_y,
- int dest_field, int src_field, unsigned int op)
-{
- unsigned int pos_x, pos_y, xy_half, offset, dest_offset;
-
- pos_x = 2 * m_offset + motion_x;
- pos_y = m_v_offset + motion_y;
-
- if(pos_x > m_limit_x)
- {
- pos_x = ((int)pos_x < 0) ? 0 : m_limit_x;
- motion_x = pos_x - 2 * m_offset;
- }
-
- if(pos_y > m_limit_y)
- {
- pos_y = ((int)pos_y < 0) ? 0 : m_limit_y;
- motion_y = pos_y - m_v_offset;
- }
-
- xy_half = ((pos_y & 1) << 1) | (pos_x & 1);
- offset = (pos_x >> 1) + ((op ? (pos_y | 1) : (pos_y & ~1)) + src_field) * m_stride;
- table[xy_half] (m_dest[0] + dest_field * m_stride + m_offset, ref[0] + offset, 2 * m_stride, 8);
-
- motion_x /= 2; motion_y /= 2;
-
- xy_half = ((motion_y & 1) << 1) | (motion_x & 1);
- offset = ((m_offset + motion_x) >> 1) + (((m_v_offset >> 1) + (op ? (motion_y | 1) :(motion_y & ~1)) + src_field) * m_uv_stride);
- dest_offset = dest_field * m_uv_stride + (m_offset >> 1);
- table[4+xy_half] (m_dest[1] + dest_offset, ref[1] + offset, 2 * m_uv_stride, 4);
- table[4+xy_half] (m_dest[2] + dest_offset, ref[2] + offset, 2 * m_uv_stride, 4);
-}
-
-void CMpeg2Decoder::motion_mp1(motion_t* motion, mpeg2_mc_fct * const * const table)
-{
- int motion_x, motion_y;
-
- NEEDBITS;
- motion_x = motion->pmv[0][0] + (get_motion_delta(motion->f_code[0]) << motion->f_code[1]);
- motion_x = bound_motion_vector(motion_x, motion->f_code[0] + motion->f_code[1]);
- motion->pmv[0][0] = motion_x;
-
- NEEDBITS;
- motion_y = motion->pmv[0][1] + (get_motion_delta(motion->f_code[0]) << motion->f_code[1]);
- motion_y = bound_motion_vector(motion_y, motion->f_code[0] + motion->f_code[1]);
- motion->pmv[0][1] = motion_y;
-
- MOTION(table, motion->ref[0], motion_x, motion_y, 16, 0, m_limit_y_16);
-}
-
-void CMpeg2Decoder::motion_fr_frame(motion_t* motion, mpeg2_mc_fct * const * const table)
-{
- int motion_x, motion_y;
-
- NEEDBITS;
- motion_x = motion->pmv[0][0] + get_motion_delta(motion->f_code[0]);
- motion_x = bound_motion_vector(motion_x, motion->f_code[0]);
- motion->pmv[1][0] = motion->pmv[0][0] = motion_x;
-
- NEEDBITS;
- motion_y = motion->pmv[0][1] + get_motion_delta(motion->f_code[1]);
- motion_y = bound_motion_vector (motion_y, motion->f_code[1]);
- motion->pmv[1][1] = motion->pmv[0][1] = motion_y;
-
- MOTION(table, motion->ref[0], motion_x, motion_y, 16, 0, m_limit_y_16);
-}
-
-void CMpeg2Decoder::motion_fr_field(motion_t* motion, mpeg2_mc_fct * const * const table)
-{
- int motion_x, motion_y, field;
-
- NEEDBITS;
- field = UBITS(bit_buf, 1);
- DUMPBITS(1);
-
- motion_x = motion->pmv[0][0] + get_motion_delta(motion->f_code[0]);
- motion_x = bound_motion_vector(motion_x, motion->f_code[0]);
- motion->pmv[0][0] = motion_x;
-
- NEEDBITS;
- motion_y = (motion->pmv[0][1] >> 1) + get_motion_delta(motion->f_code[1]);
- /* motion_y = bound_motion_vector(motion_y, motion->f_code[1]); */
- motion->pmv[0][1] = motion_y << 1;
-
- MOTION_FIELD(table, motion->ref[0], motion_x, motion_y, 0, field, 0);
-
- NEEDBITS;
- field = UBITS(bit_buf, 1);
- DUMPBITS(1);
-
- motion_x = motion->pmv[1][0] + get_motion_delta(motion->f_code[0]);
- motion_x = bound_motion_vector(motion_x, motion->f_code[0]);
- motion->pmv[1][0] = motion_x;
-
- NEEDBITS;
- motion_y = (motion->pmv[1][1] >> 1) + get_motion_delta(motion->f_code[1]);
- /* motion_y = bound_motion_vector(motion_y, motion->f_code[1]); */
- motion->pmv[1][1] = motion_y << 1;
-
- MOTION_FIELD(table, motion->ref[0], motion_x, motion_y, 1, field, 0);
-}
-
-void CMpeg2Decoder::motion_fr_dmv(motion_t* motion, mpeg2_mc_fct * const * const table)
-{
- int motion_x, motion_y, dmv_x, dmv_y, m, other_x, other_y;
-
- NEEDBITS;
- motion_x = motion->pmv[0][0] + get_motion_delta(motion->f_code[0]);
- motion_x = bound_motion_vector(motion_x, motion->f_code[0]);
- motion->pmv[1][0] = motion->pmv[0][0] = motion_x;
- NEEDBITS;
- dmv_x = get_dmv();
-
- motion_y = (motion->pmv[0][1] >> 1) + get_motion_delta(motion->f_code[1]);
- /* motion_y = bound_motion_vector (motion_y, motion->f_code[1]); */
- motion->pmv[1][1] = motion->pmv[0][1] = motion_y << 1;
- dmv_y = get_dmv();
-
- m = m_top_field_first ? 1 : 3;
- other_x = ((motion_x * m + (motion_x > 0)) >> 1) + dmv_x;
- other_y = ((motion_y * m + (motion_y > 0)) >> 1) + dmv_y - 1;
- MOTION_FIELD(m_mc->put, motion->ref[0], other_x, other_y, 0, 0, 1);
-
- m = m_top_field_first ? 3 : 1;
- other_x = ((motion_x * m + (motion_x > 0)) >> 1) + dmv_x;
- other_y = ((motion_y * m + (motion_y > 0)) >> 1) + dmv_y + 1;
- MOTION_FIELD(m_mc->put, motion->ref[0], other_x, other_y, 1, 0, 0);
-
- unsigned int pos_x, pos_y, xy_half, offset;
-
- pos_x = 2 * m_offset + motion_x;
- pos_y = m_v_offset + motion_y;
- if(pos_x > m_limit_x)
- {
- pos_x = ((int)pos_x < 0) ? 0 : m_limit_x;
- motion_x = pos_x - 2 * m_offset;
- }
- if(pos_y > m_limit_y)
- {
- pos_y = ((int)pos_y < 0) ? 0 : m_limit_y;
- motion_y = pos_y - m_v_offset;
- }
-
- xy_half = ((pos_y & 1) << 1) | (pos_x & 1);
- offset = (pos_x >> 1) + (pos_y & ~1) * m_stride;
- m_mc->avg[xy_half](m_dest[0] + m_offset, motion->ref[0][0] + offset, 2 * m_stride, 8);
- m_mc->avg[xy_half](m_dest[0] + m_stride + m_offset, motion->ref[0][0] + m_stride + offset, 2 * m_stride, 8);
- motion_x /= 2;
- motion_y /= 2;
- xy_half = ((motion_y & 1) << 1) | (motion_x & 1);
- offset = ((m_offset + motion_x) >> 1) + ((m_v_offset >> 1) + (motion_y & ~1)) * m_uv_stride;
- m_mc->avg[4+xy_half](m_dest[1] + (m_offset >> 1), motion->ref[0][1] + offset, 2 * m_uv_stride, 4);
- m_mc->avg[4+xy_half](m_dest[1] + m_uv_stride + (m_offset >> 1), motion->ref[0][1] + m_uv_stride + offset, 2 * m_uv_stride, 4);
- m_mc->avg[4+xy_half](m_dest[2] + (m_offset >> 1), motion->ref[0][2] + offset, 2 * m_uv_stride, 4);
- m_mc->avg[4+xy_half](m_dest[2] + m_uv_stride + (m_offset >> 1), motion->ref[0][2] + m_uv_stride + offset, 2 * m_uv_stride, 4);
-}
-
-void CMpeg2Decoder::motion_reuse(motion_t* motion, mpeg2_mc_fct * const * const table)
-{
- int motion_x, motion_y;
-
- motion_x = motion->pmv[0][0];
- motion_y = motion->pmv[0][1];
-
- MOTION(table, motion->ref[0], motion_x, motion_y, 16, 0, m_limit_y_16);
-}
-
-void CMpeg2Decoder::motion_zero(motion_t* motion, mpeg2_mc_fct * const * const table)
-{
- unsigned int offset;
-
- table[0](m_dest[0] + m_offset, motion->ref[0][0] + m_offset + m_v_offset * m_stride, m_stride, 16);
- offset = (m_offset >> 1) + (m_v_offset >> 1) * m_uv_stride;
- table[4](m_dest[1] + (m_offset >> 1), motion->ref[0][1] + offset, m_uv_stride, 8);
- table[4](m_dest[2] + (m_offset >> 1), motion->ref[0][2] + offset, m_uv_stride, 8);
-}
-
-/* like motion_frame, but parsing without actual motion compensation */
-void CMpeg2Decoder::motion_fr_conceal()
-{
- int tmp;
-
- NEEDBITS;
- tmp = (m_f_motion.pmv[0][0] + get_motion_delta(m_f_motion.f_code[0]));
- tmp = bound_motion_vector(tmp, m_f_motion.f_code[0]);
- m_f_motion.pmv[1][0] = m_f_motion.pmv[0][0] = tmp;
-
- NEEDBITS;
- tmp = m_f_motion.pmv[0][1] + get_motion_delta(m_f_motion.f_code[1]);
- tmp = bound_motion_vector(tmp, m_f_motion.f_code[1]);
- m_f_motion.pmv[1][1] = m_f_motion.pmv[0][1] = tmp;
-
- DUMPBITS(1); /* remove marker_bit */
-}
-
-void CMpeg2Decoder::motion_fi_field(motion_t * motion, mpeg2_mc_fct * const * const table)
-{
- int motion_x, motion_y;
- uint8_t** ref_field;
-
- NEEDBITS;
- ref_field = motion->ref2[UBITS(bit_buf, 1)];
- DUMPBITS(1);
-
- motion_x = motion->pmv[0][0] + get_motion_delta(motion->f_code[0]);
- motion_x = bound_motion_vector (motion_x, motion->f_code[0]);
- motion->pmv[1][0] = motion->pmv[0][0] = motion_x;
-
- NEEDBITS;
- motion_y = motion->pmv[0][1] + get_motion_delta(motion->f_code[1]);
- motion_y = bound_motion_vector(motion_y, motion->f_code[1]);
- motion->pmv[1][1] = motion->pmv[0][1] = motion_y;
-
- MOTION(table, ref_field, motion_x, motion_y, 16, 0, m_limit_y_16);
-}
-
-void CMpeg2Decoder::motion_fi_16x8(motion_t* motion, mpeg2_mc_fct * const * const table)
-{
- int motion_x, motion_y;
- uint8_t** ref_field;
-
- NEEDBITS;
- ref_field = motion->ref2[UBITS(bit_buf, 1)];
- DUMPBITS(1);
-
- motion_x = motion->pmv[0][0] + get_motion_delta(motion->f_code[0]);
- motion_x = bound_motion_vector(motion_x, motion->f_code[0]);
- motion->pmv[0][0] = motion_x;
-
- NEEDBITS;
- motion_y = motion->pmv[0][1] + get_motion_delta(motion->f_code[1]);
- motion_y = bound_motion_vector(motion_y, motion->f_code[1]);
- motion->pmv[0][1] = motion_y;
-
- MOTION(table, ref_field, motion_x, motion_y, 8, 0, m_limit_y_8);
-
- NEEDBITS;
- ref_field = motion->ref2[UBITS(bit_buf, 1)];
- DUMPBITS(1);
-
- motion_x = motion->pmv[1][0] + get_motion_delta(motion->f_code[0]);
- motion_x = bound_motion_vector (motion_x, motion->f_code[0]);
- motion->pmv[1][0] = motion_x;
-
- NEEDBITS;
- motion_y = motion->pmv[1][1] + get_motion_delta(motion->f_code[1]);
- motion_y = bound_motion_vector(motion_y, motion->f_code[1]);
- motion->pmv[1][1] = motion_y;
-
- MOTION(table, ref_field, motion_x, motion_y, 8, 8, m_limit_y_8);
-}
-
-void CMpeg2Decoder::motion_fi_dmv(motion_t* motion, mpeg2_mc_fct * const * const table)
-{
- int motion_x, motion_y, other_x, other_y;
-
- NEEDBITS;
- motion_x = motion->pmv[0][0] + get_motion_delta(motion->f_code[0]);
- motion_x = bound_motion_vector(motion_x, motion->f_code[0]);
- motion->pmv[1][0] = motion->pmv[0][0] = motion_x;
- NEEDBITS;
- other_x = ((motion_x + (motion_x > 0)) >> 1) + get_dmv();
-
- motion_y = motion->pmv[0][1] + get_motion_delta(motion->f_code[1]);
- motion_y = bound_motion_vector(motion_y, motion->f_code[1]);
- motion->pmv[1][1] = motion->pmv[0][1] = motion_y;
- other_y = ((motion_y + (motion_y > 0)) >> 1) + get_dmv () + m_dmv_offset;
-
- MOTION(m_mc->put, motion->ref[0], motion_x, motion_y, 16, 0, m_limit_y_16);
- MOTION(m_mc->avg, motion->ref[1], other_x, other_y, 16, 0, m_limit_y_16);
-}
-
-void CMpeg2Decoder::motion_fi_conceal()
-{
- int tmp;
-
- NEEDBITS;
- DUMPBITS(1); /* remove field_select */
-
- tmp = m_f_motion.pmv[0][0] + get_motion_delta (m_f_motion.f_code[0]);
- tmp = bound_motion_vector(tmp, m_f_motion.f_code[0]);
- m_f_motion.pmv[1][0] = m_f_motion.pmv[0][0] = tmp;
-
- NEEDBITS;
- tmp = m_f_motion.pmv[0][1] + get_motion_delta(m_f_motion.f_code[1]);
- tmp = bound_motion_vector(tmp, m_f_motion.f_code[1]);
- m_f_motion.pmv[1][1] = m_f_motion.pmv[0][1] = tmp;
-
- DUMPBITS(1); /* remove marker_bit */
-}
-
-#define MOTION_CALL(routine, direction) \
-do { \
- if((direction) & MACROBLOCK_MOTION_FORWARD) \
- routine(&m_f_motion, m_mc->put); \
- if((direction) & MACROBLOCK_MOTION_BACKWARD) \
- routine(&m_b_motion, (direction & MACROBLOCK_MOTION_FORWARD) ? m_mc->avg : m_mc->put); \
-} while (0)
-
-#define NEXT_MACROBLOCK \
-do { \
- m_offset += 16; \
- if(m_offset == m_width) { \
- m_dest[0] += 16 * m_stride; \
- m_dest[1] += 4 * m_stride; \
- m_dest[2] += 4 * m_stride; \
- m_v_offset += 16; \
- if(m_v_offset > m_limit_y) \
- return; \
- m_offset = 0; \
- } \
-} while (0)
-
-void CMpeg2Decoder::mpeg2_init_fbuf(uint8_t* current_fbuf[3], uint8_t* forward_fbuf[3], uint8_t* backward_fbuf[3])
-{
- int offset, stride, height, bottom_field;
-
- stride = m_width;
- bottom_field = (m_picture_structure == BOTTOM_FIELD);
- offset = bottom_field ? stride : 0;
- height = m_height;
-
- m_picture_dest[0] = current_fbuf[0] + offset;
- m_picture_dest[1] = current_fbuf[1] + (offset >> 1);
- m_picture_dest[2] = current_fbuf[2] + (offset >> 1);
-
- m_f_motion.ref[0][0] = forward_fbuf[0] + offset;
- m_f_motion.ref[0][1] = forward_fbuf[1] + (offset >> 1);
- m_f_motion.ref[0][2] = forward_fbuf[2] + (offset >> 1);
-
- m_b_motion.ref[0][0] = backward_fbuf[0] + offset;
- m_b_motion.ref[0][1] = backward_fbuf[1] + (offset >> 1);
- m_b_motion.ref[0][2] = backward_fbuf[2] + (offset >> 1);
-
- if(m_picture_structure != FRAME_PICTURE)
- {
- m_dmv_offset = bottom_field ? 1 : -1;
- m_f_motion.ref2[0] = m_f_motion.ref[bottom_field];
- m_f_motion.ref2[1] = m_f_motion.ref[!bottom_field];
- m_b_motion.ref2[0] = m_b_motion.ref[bottom_field];
- m_b_motion.ref2[1] = m_b_motion.ref[!bottom_field];
- offset = stride - offset;
-
- if(m_second_field && (m_coding_type != B_TYPE))
- forward_fbuf = current_fbuf;
-
- m_f_motion.ref[1][0] = forward_fbuf[0] + offset;
- m_f_motion.ref[1][1] = forward_fbuf[1] + (offset >> 1);
- m_f_motion.ref[1][2] = forward_fbuf[2] + (offset >> 1);
-
- m_b_motion.ref[1][0] = backward_fbuf[0] + offset;
- m_b_motion.ref[1][1] = backward_fbuf[1] + (offset >> 1);
- m_b_motion.ref[1][2] = backward_fbuf[2] + (offset >> 1);
-
- stride <<= 1;
- height >>= 1;
- }
-
- m_stride = stride;
- m_uv_stride = stride >> 1;
- m_limit_x = 2 * m_width - 32;
- m_limit_y_16 = 2 * height - 32;
- m_limit_y_8 = 2 * height - 16;
- m_limit_y = height - 16;
-}
-
-int CMpeg2Decoder::slice_init(int code)
-{
- int offset;
- const MBAtab* mba;
-
- m_dc_dct_pred[0] = m_dc_dct_pred[1] =
- m_dc_dct_pred[2] = 128 << m_intra_dc_precision;
-
- m_f_motion.pmv[0][0] = m_f_motion.pmv[0][1] = 0;
- m_f_motion.pmv[1][0] = m_f_motion.pmv[1][1] = 0;
- m_b_motion.pmv[0][0] = m_b_motion.pmv[0][1] = 0;
- m_b_motion.pmv[1][0] = m_b_motion.pmv[1][1] = 0;
-
- if(m_vertical_position_extension)
- {
- code += UBITS(bit_buf, 3) << 7;
- DUMPBITS(3);
- }
-
- m_v_offset = (code - 1) * 16;
- offset = (code - 1) * m_stride * 4;
-
- m_dest[0] = m_picture_dest[0] + offset * 4;
- m_dest[1] = m_picture_dest[1] + offset;
- m_dest[2] = m_picture_dest[2] + offset;
-
- m_quantizer_scale = get_quantizer_scale();
-
- /* ignore intra_slice and all the extra data */
- while(bit_buf & 0x80000000)
- {
- DUMPBITS(9);
- NEEDBITS;
- }
-
- /* decode initial macroblock address increment */
- offset = 0;
- while(1)
- {
- if(bit_buf >= 0x08000000)
- {
- mba = MBA_5 + (UBITS(bit_buf, 6) - 2);
- break;
- }
- else if(bit_buf >= 0x01800000)
- {
- mba = MBA_11 + (UBITS(bit_buf, 12) - 24);
- break;
- }
- else
- {
- switch(UBITS(bit_buf, 12))
- {
- case 8: /* macroblock_escape */
- offset += 33;
- DUMPBITS(11);
- NEEDBITS;
- continue;
- case 15: /* macroblock_stuffing (MPEG1 only) */
- bit_buf &= 0xfffff;
- DUMPBITS(11);
- NEEDBITS;
- continue;
- default: /* error */
- return 1;
- }
- }
- }
-
- DUMPBITS(mba->len + 1);
- m_offset = (offset + mba->mba) << 4;
-
- while(m_offset - m_width >= 0)
- {
- m_offset -= m_width;
- m_dest[0] += 16 * m_stride;
- m_dest[1] += 4 * m_stride;
- m_dest[2] += 4 * m_stride;
- m_v_offset += 16;
- }
-
- if(m_v_offset > m_limit_y)
- return 1;
-
- return 0;
-}
-
-void CMpeg2Decoder::mpeg2_slice(int code, const uint8_t* buffer)
-{
- m_bitstream_buf = (buffer[0] << 24) | (buffer[1] << 16) | (buffer[2] << 8) | buffer[3];
- m_bitstream_ptr = buffer + 4;
- m_bitstream_bits = -16;
-
- if(slice_init(code))
- return;
-
- while(1)
- {
- int macroblock_modes;
- int mba_inc;
- const MBAtab * mba;
-
- NEEDBITS;
-
- macroblock_modes = get_macroblock_modes();
-
- /* maybe integrate MACROBLOCK_QUANT test into get_macroblock_modes ? */
- if(macroblock_modes & MACROBLOCK_QUANT)
- m_quantizer_scale = get_quantizer_scale();
-
- if(macroblock_modes & MACROBLOCK_INTRA)
- {
- int DCT_offset, DCT_stride;
- int offset;
- uint8_t* dest_y;
-
- if(m_concealment_motion_vectors)
- {
- if(m_picture_structure == FRAME_PICTURE) motion_fr_conceal();
- else motion_fi_conceal();
- }
- else
- {
- m_f_motion.pmv[0][0] = m_f_motion.pmv[0][1] = 0;
- m_f_motion.pmv[1][0] = m_f_motion.pmv[1][1] = 0;
- m_b_motion.pmv[0][0] = m_b_motion.pmv[0][1] = 0;
- m_b_motion.pmv[1][0] = m_b_motion.pmv[1][1] = 0;
- }
-
- if(macroblock_modes & DCT_TYPE_INTERLACED)
- {
- DCT_offset = m_stride;
- DCT_stride = m_stride * 2;
- }
- else
- {
- DCT_offset = m_stride * 8;
- DCT_stride = m_stride;
- }
-
- offset = m_offset;
- dest_y = m_dest[0] + offset;
- slice_intra_DCT(0, dest_y, DCT_stride);
- slice_intra_DCT(0, dest_y + 8, DCT_stride);
- slice_intra_DCT(0, dest_y + DCT_offset, DCT_stride);
- slice_intra_DCT(0, dest_y + DCT_offset + 8, DCT_stride);
- slice_intra_DCT(1, m_dest[1] + (offset >> 1), m_uv_stride);
- slice_intra_DCT (2, m_dest[2] + (offset >> 1), m_uv_stride);
-
- if(m_coding_type == D_TYPE)
- {
- NEEDBITS;
- DUMPBITS(1);
- }
- }
- else
- {
- if(m_picture_structure == FRAME_PICTURE)
- {
- switch((macroblock_modes >> 6) & 3) // macroblock_modes & MOTION_TYPE_MASK
- {
- case 0:
- // non-intra mb without forward mv in a P picture //
- m_f_motion.pmv[0][0] = 0;
- m_f_motion.pmv[0][1] = 0;
- m_f_motion.pmv[1][0] = 0;
- m_f_motion.pmv[1][1] = 0;
- MOTION_CALL(motion_zero, MACROBLOCK_MOTION_FORWARD);
- break;
-
- case 1: // MC_FIELD:
- MOTION_CALL(motion_fr_field, macroblock_modes);
- break;
-
- case 2: // MC_FRAME:
-
- if(m_mpeg1) MOTION_CALL(motion_mp1, macroblock_modes);
- else MOTION_CALL (motion_fr_frame, macroblock_modes);
- break;
-
- case 3: // MC_DMV:
- MOTION_CALL(motion_fr_dmv, MACROBLOCK_MOTION_FORWARD);
- break;
-
- default:
- __assume(0);
- }
- }
- else
- {
- switch((macroblock_modes >> 6) & 3) // macroblock_modes & MOTION_TYPE_MASK
- {
- case 0:
- /* non-intra mb without forward mv in a P picture */
- m_f_motion.pmv[0][0] = 0;
- m_f_motion.pmv[0][1] = 0;
- m_f_motion.pmv[1][0] = 0;
- m_f_motion.pmv[1][1] = 0;
- MOTION_CALL(motion_zero, MACROBLOCK_MOTION_FORWARD);
- break;
-
- case 1: // MC_FIELD
- MOTION_CALL(motion_fi_field, macroblock_modes);
- break;
-
- case 2: // MC_16X8
- MOTION_CALL(motion_fi_16x8, macroblock_modes);
- break;
-
- case 3: // MC_DMV
- MOTION_CALL(motion_fi_dmv, MACROBLOCK_MOTION_FORWARD);
- break;
-
- default:
- __assume(0);
- }
- }
-
- if(macroblock_modes & MACROBLOCK_PATTERN)
- {
- int coded_block_pattern;
- int DCT_offset, DCT_stride;
- int offset;
- uint8_t* dest_y;
-
- if(macroblock_modes & DCT_TYPE_INTERLACED)
- {
- DCT_offset = m_stride;
- DCT_stride = m_stride * 2;
- }
- else
- {
- DCT_offset = m_stride * 8;
- DCT_stride = m_stride;
- }
-
- coded_block_pattern = get_coded_block_pattern();
-
- offset = m_offset;
- dest_y = m_dest[0] + offset;
-
- if(coded_block_pattern & 0x20)
- slice_non_intra_DCT(dest_y, DCT_stride);
- if(coded_block_pattern & 0x10)
- slice_non_intra_DCT(dest_y + 8, DCT_stride);
- if(coded_block_pattern & 0x08)
- slice_non_intra_DCT(dest_y + DCT_offset, DCT_stride);
- if(coded_block_pattern & 0x04)
- slice_non_intra_DCT(dest_y + DCT_offset + 8, DCT_stride);
- if(coded_block_pattern & 0x2)
- slice_non_intra_DCT(m_dest[1] + (offset >> 1), m_uv_stride);
- if(coded_block_pattern & 0x1)
- slice_non_intra_DCT(m_dest[2] + (offset >> 1), m_uv_stride);
- }
-
- m_dc_dct_pred[0] =
- m_dc_dct_pred[1] =
- m_dc_dct_pred[2] = 128 << m_intra_dc_precision;
- }
-
- NEXT_MACROBLOCK;
-
- NEEDBITS;
- mba_inc = 0;
- while(1)
- {
- if(bit_buf >= 0x10000000)
- {
- mba = MBA_5 + (UBITS(bit_buf, 5) - 2);
- break;
- }
- else if(bit_buf >= 0x03000000)
- {
- mba = MBA_11 + (UBITS(bit_buf, 11) - 24);
- break;
- }
- else
- {
- switch(UBITS(bit_buf, 11))
- {
- case 8: /* macroblock_escape */
- mba_inc += 33;
- /* pass through */
- case 15: /* macroblock_stuffing (MPEG1 only) */
- DUMPBITS(11);
- NEEDBITS;
- continue;
- default: /* end of slice, or error */
- return;
- }
- }
- }
-
- DUMPBITS(mba->len);
- mba_inc += mba->mba;
-
- if(mba_inc)
- {
- m_dc_dct_pred[0] =
- m_dc_dct_pred[1] =
- m_dc_dct_pred[2] = 128 << m_intra_dc_precision;
-
- if(m_coding_type == P_TYPE)
- {
- m_f_motion.pmv[0][0] = m_f_motion.pmv[0][1] = 0;
- m_f_motion.pmv[1][0] = m_f_motion.pmv[1][1] = 0;
-
- do {
- MOTION_CALL(motion_zero, MACROBLOCK_MOTION_FORWARD);
- NEXT_MACROBLOCK;
- } while(--mba_inc);
- }
- else
- {
- do {
- MOTION_CALL (motion_reuse, macroblock_modes);
- NEXT_MACROBLOCK;
- } while(--mba_inc);
- }
- }
- }
-}
-
-#undef bit_buf
-#undef bits
-#undef bit_ptr
-
-///////////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////////
-
-CMpeg2Info::CMpeg2Info()
-{
- m_sequence = NULL;
- m_gop = NULL;
- Reset();
-}
-
-CMpeg2Info::~CMpeg2Info()
-{
-}
-
-void CMpeg2Info::Reset()
-{
- m_current_picture = m_current_picture_2nd = NULL;
- m_display_picture = m_display_picture_2nd = NULL;
- m_current_fbuf = m_display_fbuf = m_discard_fbuf = NULL;
- m_user_data = NULL;
- m_user_data_len = 0;
-}
-
-#ifdef _WIN64
-#pragma warning(pop)
-#endif
diff --git a/src/filters/transform/Mpeg2DecFilter/libmpeg2.h b/src/filters/transform/Mpeg2DecFilter/libmpeg2.h
deleted file mode 100644
index 616a73f90..000000000
--- a/src/filters/transform/Mpeg2DecFilter/libmpeg2.h
+++ /dev/null
@@ -1,402 +0,0 @@
-/*
- * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
- * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
- *
- * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
- * See http://libmpeg2.sourceforge.net/ for updates.
- *
- * mpeg2dec is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * mpeg2dec 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#pragma once
-
-// TODO: remove this when it's fixed in MSVC
-// Work around warning C4005: 'XXXX' : macro redefinition
-#pragma warning(push)
-#pragma warning(disable: 4005)
-#include <stdint.h>
-#pragma warning(pop)
-
-#define MPEG2_VERSION(a,b,c) (((a)<<16)|((b)<<8)|(c))
-#define MPEG2_RELEASE MPEG2_VERSION (0, 3, 2) /* 0.3.2 */
-
-#define SEQ_FLAG_MPEG2 1
-#define SEQ_FLAG_CONSTRAINED_PARAMETERS 2
-#define SEQ_FLAG_PROGRESSIVE_SEQUENCE 4
-#define SEQ_FLAG_LOW_DELAY 8
-#define SEQ_FLAG_COLOUR_DESCRIPTION 16
-
-#define SEQ_MASK_VIDEO_FORMAT 0xe0
-#define SEQ_VIDEO_FORMAT_COMPONENT 0
-#define SEQ_VIDEO_FORMAT_PAL 0x20
-#define SEQ_VIDEO_FORMAT_NTSC 0x40
-#define SEQ_VIDEO_FORMAT_SECAM 0x60
-#define SEQ_VIDEO_FORMAT_MAC 0x80
-#define SEQ_VIDEO_FORMAT_UNSPECIFIED 0xa0
-
-typedef struct {
- unsigned int width, height;
- unsigned int chroma_width, chroma_height;
- unsigned int byte_rate;
- unsigned int vbv_buffer_size;
- uint32_t flags;
-
- unsigned int picture_width, picture_height;
- unsigned int display_width, display_height;
- unsigned int pixel_width, pixel_height;
- unsigned int frame_period;
-
- uint8_t profile_level_id;
- uint8_t colour_primaries;
- uint8_t transfer_characteristics;
- uint8_t matrix_coefficients;
-
- void finalize();
-} mpeg2_sequence_t;
-
-#define GOP_FLAG_DROP_FRAME 1
-#define GOP_FLAG_BROKEN_LINK 2
-#define GOP_FLAG_CLOSED_GOP 4
-
-typedef struct {
- uint8_t hours;
- uint8_t minutes;
- uint8_t seconds;
- uint8_t pictures;
- uint32_t flags;
-} mpeg2_gop_t;
-
-#define PIC_MASK_CODING_TYPE 7
-#define PIC_FLAG_CODING_TYPE_I 1
-#define PIC_FLAG_CODING_TYPE_P 2
-#define PIC_FLAG_CODING_TYPE_B 3
-#define PIC_FLAG_CODING_TYPE_D 4
-
-#define PIC_FLAG_TOP_FIELD_FIRST 8
-#define PIC_FLAG_PROGRESSIVE_FRAME 16
-#define PIC_FLAG_COMPOSITE_DISPLAY 32
-#define PIC_FLAG_SKIP 64
-#define PIC_FLAG_PTS 128
-#define PIC_FLAG_REPEAT_FIRST_FIELD 256
-#define PIC_MASK_COMPOSITE_DISPLAY 0xfffff000
-
-typedef struct {
- unsigned int temporal_reference;
- unsigned int nb_fields;
- uint32_t pts;
- uint32_t flags;
- struct {
- int x, y;
- } display_offset[3];
- __int64 rtStart, rtStop;
- bool fDiscontinuity, fDelivered;
-} mpeg2_picture_t;
-
-typedef struct {
- uint8_t* buf[3];
- void* id;
-} mpeg2_fbuf_t;
-
-typedef enum {
- STATE_BUFFER = 0,
- STATE_SEQUENCE = 1,
- STATE_SEQUENCE_REPEATED = 2,
- STATE_GOP = 3,
- STATE_PICTURE = 4,
- STATE_SLICE_1ST = 5,
- STATE_PICTURE_2ND = 6,
- STATE_SLICE = 7,
- STATE_END = 8,
- STATE_INVALID = 9,
- STATE_PADDING = 10
-} mpeg2_state_t;
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-/* macroblock modes */
-#define MACROBLOCK_INTRA 1
-#define MACROBLOCK_PATTERN 2
-#define MACROBLOCK_MOTION_BACKWARD 4
-#define MACROBLOCK_MOTION_FORWARD 8
-#define MACROBLOCK_QUANT 16
-#define DCT_TYPE_INTERLACED 32
-/* motion_type */
-#define MOTION_TYPE_MASK (3*64)
-#define MOTION_TYPE_BASE 64
-#define MC_FIELD (1*64)
-#define MC_FRAME (2*64)
-#define MC_16X8 (2*64)
-#define MC_DMV (3*64)
-
-/* picture structure */
-#define TOP_FIELD 1
-#define BOTTOM_FIELD 2
-#define FRAME_PICTURE 3
-
-/* picture coding type */
-#define I_TYPE 1
-#define P_TYPE 2
-#define B_TYPE 3
-#define D_TYPE 4
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-typedef void mpeg2_mc_fct(uint8_t*, const uint8_t*, int, int);
-typedef struct {mpeg2_mc_fct* put[8]; mpeg2_mc_fct* avg[8];} mpeg2_mc_t;
-
-class CMpeg2Decoder
-{
-public:
- /* Motion vectors */
- /* The f_ and b_ correspond to the forward and backward motion */
- /* predictors */
-
- struct motion_t {
- uint8_t* ref[2][3];
- uint8_t** ref2[2];
- int pmv[2][2];
- int f_code[2];
- } m_b_motion, m_f_motion;
-
-private:
- int get_macroblock_modes();
- int get_quantizer_scale();
- int get_motion_delta(const int f_code);
- int bound_motion_vector(const int vector, const int f_code);
- int get_dmv();
- int get_coded_block_pattern();
- int get_luma_dc_dct_diff();
- int get_chroma_dc_dct_diff();
-
- void get_intra_block_B14();
- void get_intra_block_B15();
- int get_non_intra_block();
- void get_mpeg1_intra_block();
- int get_mpeg1_non_intra_block();
- void slice_intra_DCT(const int cc, uint8_t* dest, int stride);
- void slice_non_intra_DCT(uint8_t* dest, int stride);
-
- void MOTION(mpeg2_mc_fct * const * const table, uint8_t** ref, int motion_x, int motion_y, unsigned int size, unsigned int y, unsigned int limit_y);
- void MOTION_FIELD(mpeg2_mc_fct * const * const table, uint8_t** ref, int motion_x, int motion_y, int dest_field, int src_field, unsigned int op);
-
- void motion_mp1(motion_t* motion, mpeg2_mc_fct * const * const table);
- void motion_fr_frame(motion_t* motion, mpeg2_mc_fct * const * const table);
- void motion_fr_field(motion_t* motion, mpeg2_mc_fct * const * const table);
- void motion_fr_dmv(motion_t* motion, mpeg2_mc_fct * const * const table);
- void motion_reuse(motion_t* motion, mpeg2_mc_fct * const * const table);
- void motion_zero(motion_t* motion, mpeg2_mc_fct * const * const table);
- void motion_fr_conceal();
- void motion_fi_field(motion_t * motion, mpeg2_mc_fct * const * const table);
- void motion_fi_16x8(motion_t* motion, mpeg2_mc_fct * const * const table);
- void motion_fi_dmv(motion_t* motion, mpeg2_mc_fct * const * const table);
- void motion_fi_conceal();
-
- int slice_init(int code);
-
- static bool m_idct_initialized;
- void (*m_idct_init)();
- void (*m_idct_copy)(int16_t* block, uint8_t* dest, const int stride);
- void (*m_idct_add)(const int last, int16_t* block, uint8_t* dest, const int stride);
- mpeg2_mc_t* m_mc;
-
-public:
- CMpeg2Decoder();
- virtual ~CMpeg2Decoder();
-
- void mpeg2_init_fbuf(uint8_t* current_fbuf[3], uint8_t* forward_fbuf[3], uint8_t* backward_fbuf[3]);
- void mpeg2_slice(int code, const uint8_t* buffer);
-
- int16_t* m_DCTblock;
-
- /* bit parsing stuff */
- uint32_t m_bitstream_buf; /* current 32 bit working set */
- int m_bitstream_bits; /* used bits in working set */
- const uint8_t* m_bitstream_ptr; /* buffer with stream data */
-
- uint8_t* m_dest[3];
- uint8_t* m_picture_dest[3];
-
- int m_offset, m_stride, m_uv_stride;
- unsigned int m_limit_x, m_limit_y_16, m_limit_y_8, m_limit_y;
-
- /* predictor for DC coefficients in intra blocks */
- int16_t m_dc_dct_pred[3];
-
- int m_quantizer_scale; /* remove */
- int m_dmv_offset; /* remove */
- unsigned int m_v_offset; /* remove */
-
- /* now non-slice-specific information */
-
- /* sequence header stuff */
- uint8_t m_intra_quantizer_matrix[64];
- uint8_t m_non_intra_quantizer_matrix[64];
-
- /* The width and height of the picture snapped to macroblock units */
- int m_width, m_height;
- int m_vertical_position_extension;
-
- /* picture header stuff */
-
- /* what type of picture this is (I, P, B, D) */
- int m_coding_type;
-
- /* picture coding extension stuff */
-
- /* quantization factor for intra dc coefficients */
- int m_intra_dc_precision;
- /* top/bottom/both fields */
- int m_picture_structure;
- /* bool to indicate all predictions are frame based */
- int m_frame_pred_frame_dct;
- /* bool to indicate whether intra blocks have motion vectors */
- /* (for concealment) */
- int m_concealment_motion_vectors;
- /* bit to indicate which quantization table to use */
- int m_q_scale_type;
- /* bool to use different vlc tables */
- int m_intra_vlc_format;
- /* used for DMV MC */
- int m_top_field_first;
-
- /* stuff derived from bitstream */
-
- /* pointer to the zigzag scan we're supposed to be using */
- const uint8_t* m_scan;
-
- int m_second_field;
-
- int m_mpeg1;
-};
-
-class CMpeg2Info
-{
-public:
- CMpeg2Info();
- virtual ~CMpeg2Info();
-
- void Reset();
-
- mpeg2_sequence_t* m_sequence;
- mpeg2_gop_t* m_gop;
- mpeg2_picture_t* m_current_picture;
- mpeg2_picture_t* m_current_picture_2nd;
- mpeg2_fbuf_t* m_current_fbuf;
- mpeg2_picture_t* m_display_picture;
- mpeg2_picture_t* m_display_picture_2nd;
- mpeg2_fbuf_t* m_display_fbuf;
- mpeg2_fbuf_t* m_discard_fbuf;
- const uint8_t* m_user_data;
- int m_user_data_len;
-};
-
-class CMpeg2Dec
-{
- int skip_chunk(int bytes);
- int copy_chunk(int bytes);
- mpeg2_state_t seek_chunk(), seek_header(), seek_sequence();
-
- int sequence_ext();
- int sequence_display_ext();
- int quant_matrix_ext();
- int copyright_ext();
- int picture_display_ext();
- int picture_coding_ext();
-
-public:
- CMpeg2Dec();
- virtual ~CMpeg2Dec();
-
- void mpeg2_init();
- void mpeg2_close();
-
- void mpeg2_buffer(uint8_t* start, uint8_t* end);
- int mpeg2_getpos();
- mpeg2_state_t mpeg2_parse();
-
- void mpeg2_skip(int skip);
- void mpeg2_slice_region(int start, int end);
-
- void mpeg2_pts(uint32_t pts);
-
- /* decode.c */
- mpeg2_state_t mpeg2_seek_sequence();
- mpeg2_state_t mpeg2_parse_header();
-
- /* header.c */
- void mpeg2_header_state_init();
- int mpeg2_header_sequence();
- int mpeg2_header_gop();
- mpeg2_state_t mpeg2_header_picture_start();
- int mpeg2_header_picture();
- int mpeg2_header_extension();
- int mpeg2_header_user_data();
- void mpeg2_header_matrix_finalize();
- void mpeg2_header_sequence_finalize();
- mpeg2_state_t mpeg2_header_slice_start();
- mpeg2_state_t mpeg2_header_end();
- void mpeg2_set_fbuf(int coding_type);
-
- enum {BUFFER_SIZE = 1194 * 1024};
-
-
- CMpeg2Decoder m_decoder;
- CMpeg2Info m_info;
-
- uint32_t m_shift;
- int m_is_display_initialized;
- mpeg2_state_t (CMpeg2Dec::* m_action)();
- mpeg2_state_t m_state;
- uint32_t m_ext_state;
-
- /* allocated in init - gcc has problems allocating such big structures */
- uint8_t* m_chunk_buffer;
- /* pointer to start of the current chunk */
- uint8_t* m_chunk_start;
- /* pointer to current position in chunk_buffer */
- uint8_t* m_chunk_ptr;
- /* last start code ? */
- uint8_t m_code;
-
- /* PTS */
- uint32_t m_pts_current, m_pts_previous;
- int m_num_pts;
- int m_bytes_since_pts;
-
- bool m_first;
- int m_alloc_index;
- uint8_t m_first_decode_slice;
- uint8_t m_nb_decode_slices;
-
- mpeg2_sequence_t m_new_sequence;
- mpeg2_sequence_t m_sequence;
- mpeg2_gop_t m_gop;
- mpeg2_picture_t m_pictures[4];
- mpeg2_picture_t* m_picture;
- /*const*/ mpeg2_fbuf_t* m_fbuf[3]; /* 0: current fbuf, 1-2: prediction fbufs */
-
- mpeg2_fbuf_t m_fbuf_alloc[3];
-
- uint8_t* m_buf_start;
- uint8_t* m_buf_end;
-
- int16_t m_display_offset_x, m_display_offset_y;
-
- int m_copy_matrix;
- uint8_t m_intra_quantizer_matrix[64];
- uint8_t m_non_intra_quantizer_matrix[64];
-};
diff --git a/src/filters/transform/Mpeg2DecFilter/mc_sse2.cpp b/src/filters/transform/Mpeg2DecFilter/mc_sse2.cpp
deleted file mode 100644
index 57cea4af5..000000000
--- a/src/filters/transform/Mpeg2DecFilter/mc_sse2.cpp
+++ /dev/null
@@ -1,483 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-
-// Based on Intel's AP-942
-
-#include "stdafx.h"
-#include <inttypes.h>
-#include "libmpeg2.h"
-#include "attributes.h"
-#include "../../../DSUtil/simd.h"
-
-static const __m128i const_1_16_bytes = _mm_set1_epi16(1);
-
-static void MC_put_o_16_sse2(uint8_t* ecx, const uint8_t* edx, const int eax, int esi)
-{
- const int edi = eax + eax;
- const int ebx = edi + eax;
- for (; esi; edx += edi * 2, ecx += edi * 2, esi -= 4) {
- __m128i xmm0, xmm1, xmm2, xmm3;
- movdqu(xmm0, edx);
- movdqu(xmm1, edx + eax);
- movdqu(xmm2, edx + edi);
- movdqu(xmm3, edx + ebx);
- movdqa(ecx, xmm0);
- movdqa(ecx + eax, xmm1);
- movdqa(ecx + edi, xmm2);
- movdqa(ecx + ebx, xmm3);
- }
-}
-
-static void MC_put_o_8_sse2(uint8_t* ecx, const uint8_t* edx, const int eax, int esi)
-{
- const int edi = eax + eax;
- const int ebx = edi + eax;
- for (; esi; edx += edi * 2, ecx += edi * 2, esi -= 4) {
- __m128d xmm0, xmm1, xmm2, xmm3;
- movlpd(xmm0, edx);
- movlpd(xmm1, edx + eax);
- movlpd(xmm2, edx + edi);
- movlpd(xmm3, edx + ebx);
- movlpd(ecx, xmm0);
- movlpd(ecx + eax, xmm1);
- movlpd(ecx + edi, xmm2);
- movlpd(ecx + ebx, xmm3);
- }
-}
-
-static void MC_put_x_16_sse2(uint8_t* ecx, const uint8_t* edx, const int eax, int esi)
-{
- const int edi = eax + eax;
- const int ebx = edi + eax;
- for (; esi; edx += edi * 2, ecx += edi * 2, esi -= 4) {
- __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;
- movdqu(xmm0, edx);
- movdqu(xmm1, edx + 1);
- movdqu(xmm2, edx + eax);
- movdqu(xmm3, edx + eax + 1);
- movdqu(xmm4, edx + edi);
- movdqu(xmm5, edx + edi + 1);
- movdqu(xmm6, edx + ebx);
- movdqu(xmm7, edx + ebx + 1);
- pavgb(xmm0, xmm1);
- pavgb(xmm2, xmm3);
- pavgb(xmm4, xmm5);
- pavgb(xmm6, xmm7);
- movdqa(ecx, xmm0);
- movdqa(ecx + eax, xmm2);
- movdqa(ecx + edi, xmm4);
- movdqa(ecx + ebx, xmm6);
- }
-}
-
-static void MC_put_x_8_sse2(uint8_t* ecx, const uint8_t* edx, const int eax, int esi)
-{
- const int edi = eax + eax;
- const int ebx = edi + eax;
- __m128i xmm0, xmm1, xmm2, xmm3;
- for (; esi; edx += edi * 2, ecx += edi * 2, esi -= 4) {
- movlpd(xmm0, edx);
- movlpd(xmm1, edx + 1);
- movhpd(xmm0, edx + eax);
- movhpd(xmm1, edx + eax + 1);
- movlpd(xmm2, edx + edi);
- movlpd(xmm3, edx + edi + 1);
- movhpd(xmm2, edx + ebx);
- movhpd(xmm3, edx + ebx + 1);
- pavgb(xmm0, xmm1);
- pavgb(xmm2, xmm3);
- movlpd(ecx, xmm0);
- movhpd(ecx + eax, xmm0);
- movlpd(ecx + edi, xmm2);
- movhpd(ecx + ebx, xmm2);
- }
-}
-
-static void MC_put_y_16_sse2(uint8_t* ecx, const uint8_t* edx, const int eax, int esi)
-{
- const int edi = eax + eax;
- const int ebx = edi + eax;
- __m128i xmm0;
- movdqu(xmm0, edx);
- for (; esi; edx += edi * 2, ecx += edi * 2, esi -= 4) {
- __m128i xmm1, xmm2, xmm3, xmm4;
- movdqu(xmm1, edx + eax);
- movdqu(xmm2, edx + edi);
- movdqu(xmm3, edx + ebx);
- movdqu(xmm4, edx + edi * 2);
- pavgb(xmm0, xmm1);
- pavgb(xmm1, xmm2);
- pavgb(xmm2, xmm3);
- pavgb(xmm3, xmm4);
- movdqa(ecx, xmm0);
- movdqa(ecx + eax, xmm1);
- movdqa(ecx + edi, xmm2);
- movdqa(ecx + ebx, xmm3);
- movdqa(xmm0, xmm4);
- }
-}
-
-static void MC_put_y_8_sse2(uint8_t* ecx, const uint8_t* edx, const int eax, int esi)
-{
- const int edi = eax + eax;
- const int ebx = edi + eax;
- __m128i xmm0;
- movlpd(xmm0, edx);
-
- for (; esi; edx += edi * 2, ecx += edi * 2, esi -= 4) {
- __m128i xmm1, xmm2, xmm3, xmm4;
- movlpd(xmm1, edx + eax);
- movlpd(xmm2, edx + edi);
- movlpd(xmm3, edx + ebx);
- movlpd(xmm4, edx + edi * 2);
- pavgb(xmm0, xmm1);
- pavgb(xmm1, xmm2);
- pavgb(xmm2, xmm3);
- pavgb(xmm3, xmm4);
- movlpd(ecx, xmm0);
- movlpd(ecx + eax, xmm1);
- movlpd(ecx + edi, xmm2);
- movlpd(ecx + ebx, xmm3);
- movdqa(xmm0, xmm4);
- }
-}
-
-static void MC_put_xy_16_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
-{
- const uint8_t* edx = ref ;
- uint8_t* ecx = dest;
- int eax = stride;
- int esi = height;
- int edi = eax + eax;
- __m128i xmm7, xmm0, xmm1, xmm4, xmm5, xmm2, xmm3;
- movdqa(xmm7, const_1_16_bytes);
- movdqu(xmm0, edx);
- movdqu(xmm1, edx + 1);
- for (; esi; edx += edi, ecx += edi, esi -= 2) {
- movdqu(xmm2, edx + eax);
- movdqu(xmm3, edx + eax + 1);
- movdqu(xmm4, edx + edi);
- movdqu(xmm5, edx + edi + 1);
- pavgb(xmm0, xmm1);
- pavgb(xmm2, xmm3);
- movdqa(xmm1, xmm5);
- pavgb(xmm5, xmm4);
- psubusb(xmm2, xmm7);
- pavgb(xmm0, xmm2);
- pavgb(xmm2, xmm5);
- movdqa(ecx, xmm0);
- movdqa(xmm0, xmm4);
- movdqa(ecx + eax, xmm2);
- }
-}
-
-static void MC_put_xy_8_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
-{
- const uint8_t* edx = ref;
- uint8_t* ecx = dest;
- int eax = stride;
- int esi = height;
- int edi = eax + eax;
- __m128i xmm7, xmm0, xmm2, xmm1, xmm3, xmm4, xmm5;
- movdqa(xmm7, const_1_16_bytes);
- movlpd(xmm0, edx);
- movlpd(xmm1, edx + 1);
- for (; esi; edx += edi, ecx += edi, esi -= 2) {
- movlpd(xmm2, edx + eax);
- movlpd(xmm3, edx + eax + 1);
- movlpd(xmm4, edx + edi);
- movlpd(xmm5, edx + edi + 1);
- pavgb(xmm0, xmm1);
- pavgb(xmm2, xmm3);
- movdqa(xmm1, xmm5);
- pavgb(xmm5, xmm4);
- psubusb(xmm2, xmm7);
- pavgb(xmm0, xmm2);
- pavgb(xmm2, xmm5);
- movlpd(ecx, xmm0);
- movdqa(xmm0, xmm4);
- movlpd(ecx + eax, xmm2);
- }
-}
-
-static void MC_avg_o_16_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
-{
- const uint8_t* edx = ref;
- uint8_t* ecx = dest;
- int esi = height;
- int eax = stride;
- int edi = eax + eax;
- int ebx = edi + eax;
-
- for (; esi; edx += edi * 2, ecx += edi * 2, esi -= 4) {
- __m128i xmm0, xmm1, xmm2, xmm3;
- movdqu(xmm0, edx);
- movdqu(xmm1, edx + eax);
- movdqu(xmm2, edx + edi);
- movdqu(xmm3, edx + ebx);
- pavgb(xmm0, ecx);
- pavgb(xmm1, ecx + eax);
- pavgb(xmm2, ecx + edi);
- pavgb(xmm3, ecx + ebx);
- movdqa(ecx, xmm0);
- movdqa(ecx + eax, xmm1);
- movdqa(ecx + edi, xmm2);
- movdqa(ecx + ebx, xmm3);
- }
-}
-
-static void MC_avg_o_8_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
-{
- const uint8_t* edx = ref;
- uint8_t* ecx = dest;
- int esi = height;
- int eax = stride;
- int edi = eax + eax;
- int ebx = edi + eax;
-
- __m128i xmm0, xmm1, xmm2, xmm3;
- for (; esi; edx += edi * 2, ecx += edi * 2, esi -= 4) {
- movlpd(xmm0, edx);
- movhpd(xmm0, edx + eax);
- movlpd(xmm2, edx + edi);
- movhpd(xmm2, edx + ebx);
- movlpd(xmm1, ecx);
- movhpd(xmm1, ecx + eax);
- movlpd(xmm3, ecx + edi);
- movhpd(xmm3, ecx + ebx);
- pavgb(xmm0, xmm1);
- pavgb(xmm2, xmm3);
- movlpd(ecx, xmm0);
- movhpd(ecx + eax, xmm0);
- movlpd(ecx + edi, xmm2);
- movhpd(ecx + ebx, xmm2);
- }
-}
-
-static void MC_avg_x_16_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
-{
- const uint8_t* edx = ref;
- uint8_t* ecx = dest;
- int esi = height;
- int eax = stride;
- int edi = eax + eax;
- int ebx = edi + eax;
-
- __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;
- for (; esi; edx += edi * 2, ecx += edi * 2, esi -= 4) {
- movdqu(xmm0, edx);
- movdqu(xmm1, edx + 1);
- movdqu(xmm2, edx + eax);
- movdqu(xmm3, edx + eax + 1);
- movdqu(xmm4, edx + edi);
- movdqu(xmm5, edx + edi + 1);
- movdqu(xmm6, edx + ebx);
- movdqu(xmm7, edx + ebx + 1);
- pavgb(xmm0, xmm1);
- pavgb(xmm2, xmm3);
- pavgb(xmm4, xmm5);
- pavgb(xmm6, xmm7);
- pavgb(xmm0, ecx);
- pavgb(xmm2, ecx + eax);
- pavgb(xmm4, ecx + edi);
- pavgb(xmm6, ecx + ebx);
- movdqa(ecx, xmm0);
- movdqa(ecx + eax, xmm2);
- movdqa(ecx + edi, xmm4);
- movdqa(ecx + ebx, xmm6);
- }
-}
-
-static void MC_avg_x_8_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
-{
- const uint8_t* edx = ref;
- uint8_t* ecx = dest;
- int esi = height;
- int eax = stride;
- int edi = eax + eax;
- int ebx = edi + eax;
-
- __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5;
- for (; esi; edx += edi * 2, ecx += edi * 2, esi -= 4) {
- movlpd(xmm0, edx);
- movlpd(xmm1, edx + 1);
- movhpd(xmm0, edx + eax);
- movhpd(xmm1, edx + eax + 1);
- movlpd(xmm2, edx + edi);
- movlpd(xmm3, edx + edi + 1);
- movhpd(xmm2, edx + ebx);
- movhpd(xmm3, edx + ebx + 1);
- movlpd(xmm4, ecx);
- movhpd(xmm4, ecx + eax);
- movlpd(xmm5, ecx + edi);
- movhpd(xmm5, ecx + ebx);
- pavgb(xmm0, xmm1);
- pavgb(xmm2, xmm3);
- pavgb(xmm0, xmm4);
- pavgb(xmm2, xmm5);
- movlpd(ecx, xmm0);
- movhpd(ecx + eax, xmm0);
- movlpd(ecx + edi, xmm2);
- movhpd(ecx + ebx, xmm2);
- }
-}
-
-static void MC_avg_y_16_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
-{
- const uint8_t* edx = ref;
- uint8_t* ecx = dest;
- int esi = height;
- int eax = stride;
- int edi = eax + eax;
- int ebx = edi + eax;
- __m128i xmm0, xmm1, xmm2, xmm3, xmm4;
-
- movdqu(xmm0, edx);
- for (; esi; edx += edi * 2, ecx += edi * 2, esi -= 4) {
- movdqu(xmm1, edx + eax);
- movdqu(xmm2, edx + edi);
- movdqu(xmm3, edx + ebx);
- movdqu(xmm4, edx + edi * 2);
- pavgb(xmm0, xmm1);
- pavgb(xmm1, xmm2);
- pavgb(xmm2, xmm3);
- pavgb(xmm3, xmm4);
- pavgb(xmm0, ecx);
- pavgb(xmm1, ecx + eax);
- pavgb(xmm2, ecx + edi);
- pavgb(xmm3, ecx + ebx);
- movdqa(ecx, xmm0);
- movdqa(ecx + eax, xmm1);
- movdqa(ecx + edi, xmm2);
- movdqa(ecx + ebx, xmm3);
- movdqa(xmm0, xmm4);
- }
-}
-
-static void MC_avg_y_8_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
-{
- const uint8_t* edx = ref;
- uint8_t* ecx = dest;
- int esi = height;
- int eax = stride;
- int edi = eax + eax;
- int ebx = edi + eax;
- __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5;
- movhpd(xmm0, edx);
- movlpd(xmm0, edx + eax);
- for (; esi; edx += edi * 2, ecx += edi * 2, esi -= 4) {
- movlhps(xmm1, xmm0);
- movlpd(xmm1, edx + edi);
- movlhps(xmm2, xmm1);
- movlpd(xmm2, edx + ebx);
- movlhps(xmm3, xmm2);
- movlpd(xmm3, edx + edi * 2);
- movhpd(xmm4, ecx);
- movlpd(xmm4, ecx + eax);
- movhpd(xmm5, ecx + edi);
- movlpd(xmm5, ecx + ebx);
- pavgb(xmm0, xmm1);
- pavgb(xmm2, xmm3);
- pavgb(xmm0, xmm4);
- pavgb(xmm2, xmm5);
- movhpd(ecx, xmm0);
- movlpd(ecx + eax, xmm0);
- movhpd(ecx + edi, xmm2);
- movlpd(ecx + ebx, xmm2);
- movdqa(xmm0, xmm3);
- }
-}
-
-static void MC_avg_xy_16_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
-{
- const uint8_t* edx = ref;
- uint8_t* ecx = dest;
- int esi = height;
- int eax = stride;
- int edi = eax + eax;
- __m128i xmm7, xmm0, xmm1, xmm2, xmm3, xmm4, xmm5;
- movdqa(xmm7, const_1_16_bytes);
- movdqu(xmm0, edx);
- movdqu(xmm1, edx + 1);
- for (; esi; edx += edi, ecx += edi, esi -= 2) {
- movdqu(xmm2, edx + eax);
- movdqu(xmm3, edx + eax + 1);
- movdqu(xmm4, edx + edi);
- movdqu(xmm5, edx + edi + 1);
- pavgb(xmm0, xmm1);
- pavgb(xmm2, xmm3);
- movdqa(xmm1, xmm5);
- pavgb(xmm5, xmm4);
- psubusb(xmm2, xmm7);
- pavgb(xmm0, xmm2);
- pavgb(xmm2, xmm5);
- pavgb(xmm0, ecx);
- pavgb(xmm2, ecx + eax);
- movdqa(ecx, xmm0);
- movdqa(xmm0, xmm4);
- movdqa(ecx + eax, xmm2);
- }
-}
-
-static void MC_avg_xy_8_sse2(uint8_t* dest, const uint8_t* ref, const int stride, int height)
-{
- const uint8_t* edx = ref;
- uint8_t* ecx = dest;
- int esi = height;
- int eax = stride;
- int edi = eax + eax;
- __m128i xmm7, xmm0, xmm2, xmm1, xmm3, xmm4;
- movdqa(xmm7, const_1_16_bytes);
- movhpd(xmm0, edx);
- movlpd(xmm0, edx + eax);
- movhpd(xmm2, edx + 1);
- movlpd(xmm2, edx + eax + 1);
- for (; esi; edx += edi, ecx += edi, esi -= 2) {
-
- movhpd(xmm1, edx + eax);
- movlpd(xmm1, edx + edi);
- movhpd(xmm3, edx + eax + 1);
- movlpd(xmm3, edx + edi + 1);
- pavgb(xmm0, xmm1);
- pavgb(xmm2, xmm3);
- psubusb(xmm0, xmm7);
- pavgb(xmm0, xmm2);
- movhpd(xmm4, ecx);
- movlpd(xmm4, ecx + eax);
- pavgb(xmm0, xmm4);
- movhpd(ecx, xmm0);
- movlpd(ecx + eax, xmm0);
- movdqa(xmm0, xmm1);
- movdqa(xmm2, xmm3);
- }
-}
-
-mpeg2_mc_t mpeg2_mc_sse2 = {
- {
- MC_put_o_16_sse2, MC_put_x_16_sse2, MC_put_y_16_sse2, MC_put_xy_16_sse2,
- MC_put_o_8_sse2, MC_put_x_8_sse2, MC_put_y_8_sse2, MC_put_xy_8_sse2
- },
- {
- MC_avg_o_16_sse2, MC_avg_x_16_sse2, MC_avg_y_16_sse2, MC_avg_xy_16_sse2,
- MC_avg_o_8_sse2, MC_avg_x_8_sse2, MC_avg_y_8_sse2, MC_avg_xy_8_sse2
- }
-};
diff --git a/src/filters/transform/Mpeg2DecFilter/motion_comp_mmx.obj b/src/filters/transform/Mpeg2DecFilter/motion_comp_mmx.obj
deleted file mode 100644
index 6be317582..000000000
--- a/src/filters/transform/Mpeg2DecFilter/motion_comp_mmx.obj
+++ /dev/null
Binary files differ
diff --git a/src/filters/transform/Mpeg2DecFilter/resource.h b/src/filters/transform/Mpeg2DecFilter/resource.h
deleted file mode 100644
index 21a1b6a08..000000000
--- a/src/filters/transform/Mpeg2DecFilter/resource.h
+++ /dev/null
@@ -1,27 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by Mpeg2DecFilter.rc
-//
-#define IDS_FILTER_SETTINGS_CAPTION 7000
-#define IDS_MPEG2_ENABLE_PLANAR 7500
-#define IDS_MPEG2_INTERLACE_FLAG 7501
-#define IDS_MPEG2_FORCED_SUBS 7502
-#define IDS_MPEG2_DEINTERLACING 7503
-#define IDS_MPEG2_BRIGHTNESS 7504
-#define IDS_MPEG2_RESET 7505
-#define IDS_MPEG2_NOTE1 7506
-#define IDS_MPEG2_CONTRAST 7507
-#define IDS_MPEG2_HUE 7508
-#define IDS_MPEG2_SATURATION 7509
-#define IDS_MPEG2_READ_AR 7511
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 102
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/filters/transform/Mpeg2DecFilter/stdafx.cpp b/src/filters/transform/Mpeg2DecFilter/stdafx.cpp
deleted file mode 100644
index 784f2cebc..000000000
--- a/src/filters/transform/Mpeg2DecFilter/stdafx.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
diff --git a/src/filters/transform/Mpeg2DecFilter/stdafx.h b/src/filters/transform/Mpeg2DecFilter/stdafx.h
deleted file mode 100644
index 5b6b09e05..000000000
--- a/src/filters/transform/Mpeg2DecFilter/stdafx.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * (C) 2003-2006 Gabest
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../../DSUtil/SharedInclude.h"
-#include "../../../../include/stdafx_common.h"
-#include "../../../../include/stdafx_common_afx.h"
-#include "../../../../include/stdafx_common_dshow.h"
diff --git a/src/mpc-hc/FGManagerBDA.cpp b/src/mpc-hc/FGManagerBDA.cpp
index 8d7ba8e2f..4fd040ffd 100644
--- a/src/mpc-hc/FGManagerBDA.cpp
+++ b/src/mpc-hc/FGManagerBDA.cpp
@@ -31,7 +31,6 @@
#include "DSUtil.h"
#include "GolombBuffer.h"
#include "../filters/switcher/AudioSwitcher/AudioSwitcher.h"
-#include "../filters/transform/MPCVideoDec/MPCVideoDecFilter.h"
#include "moreuuids.h"
#include "mplayerc.h"
#include "FGManagerBDA.h"
@@ -300,7 +299,7 @@ CFGManagerBDA::CFGManagerBDA(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd)
// - audio switcher
m_transform.AddHead(DEBUG_NEW CFGFilterRegistry(__uuidof(CAudioSwitcherFilter), MERIT64_DO_NOT_USE));
// - internal video decoder and ffdshow DXVA video decoder (cf ticket #730)
- m_transform.AddHead(DEBUG_NEW CFGFilterRegistry(__uuidof(CMPCVideoDecFilter), MERIT64_DO_NOT_USE));
+ m_transform.AddHead(DEBUG_NEW CFGFilterRegistry(CLSID_MPCVideoDecoder, MERIT64_DO_NOT_USE));
m_transform.AddHead(DEBUG_NEW CFGFilterRegistry(CLSID_FFDShowDXVADecoder, MERIT64_DO_NOT_USE));
// - Microsoft DTV-DVD Audio Decoder
m_transform.AddHead(DEBUG_NEW CFGFilterRegistry(CLSID_MSDVTDVDAudioDecoder, MERIT64_DO_NOT_USE));
diff --git a/src/mpc-hc/MainFrm.cpp b/src/mpc-hc/MainFrm.cpp
index 24f04504a..a87952861 100644
--- a/src/mpc-hc/MainFrm.cpp
+++ b/src/mpc-hc/MainFrm.cpp
@@ -11711,7 +11711,7 @@ DWORD CMainFrame::SetupSubtitleStreams()
if (!bAllowOverridingSplitterChoice && pSSF && SUCCEEDED(subInput.sourceFilter->GetClassID(&clsid))) {
// We always allow overriding the splitter choice for our splitters that
// support the IAMStreamSelect interface and thus would have been ignored.
- bAllowOverridingSplitterChoice = !!(clsid == __uuidof(CMpegSplitterFilter));
+ bAllowOverridingSplitterChoice = !!(clsid == CLSID_MPCMpegSplitter);
}
int count = 0;
@@ -13300,10 +13300,10 @@ void CMainFrame::SetupNavChaptersSubMenu()
IBaseFilter* CMainFrame::FindSourceSelectableFilter()
{
- // splitters for video files (mpeg files with only audio track is very rare)
- IBaseFilter* pSF = FindFilter(__uuidof(CMpegSplitterFilter), m_pGB);
+ // splitters for video files (MPEG files with only audio track is very rare)
+ IBaseFilter* pSF = FindFilter(CLSID_MPCMpegSplitter, m_pGB);
if (!pSF) {
- pSF = FindFilter(__uuidof(CMpegSourceFilter), m_pGB);
+ pSF = FindFilter(CLSID_MPCMpegSplitterSource, m_pGB);
}
// universal splitters
if (!pSF) {
diff --git a/src/thirdparty/Bento4/Bento4.vcxproj b/src/thirdparty/Bento4/Bento4.vcxproj
deleted file mode 100644
index 78ac697c3..000000000
--- a/src/thirdparty/Bento4/Bento4.vcxproj
+++ /dev/null
@@ -1,257 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{40177920-A66C-4647-B119-332A10224C83}</ProjectGuid>
- <Keyword>Win32Proj</Keyword>
- <RootNamespace>Bento4</RootNamespace>
- <ProjectName>Bento4</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <Import Project="..\..\platform.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\common.props" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\common.props" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup />
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <PreprocessorDefinitions>_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>Core;Crypto;..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <DisableSpecificWarnings>4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
- <PrecompiledHeaderFile>Ap4.h</PrecompiledHeaderFile>
- <EnablePREfast>false</EnablePREfast>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <PreprocessorDefinitions>_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>Core;Crypto;..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <DisableSpecificWarnings>4244;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
- <PrecompiledHeaderFile>Ap4.h</PrecompiledHeaderFile>
- <EnablePREfast>false</EnablePREfast>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <PreprocessorDefinitions>_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>Core;Crypto;..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <DisableSpecificWarnings>4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
- <PrecompiledHeaderFile>Ap4.h</PrecompiledHeaderFile>
- <EnablePREfast>false</EnablePREfast>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <PreprocessorDefinitions>_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>Core;Crypto;..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <DisableSpecificWarnings>4244;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
- <PrecompiledHeaderFile>Ap4.h</PrecompiledHeaderFile>
- <EnablePREfast>false</EnablePREfast>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClInclude Include="Core\Ap4.h" />
- <ClInclude Include="Core\Ap4Array.h" />
- <ClInclude Include="Core\Ap4Atom.h" />
- <ClInclude Include="Core\Ap4AtomFactory.h" />
- <ClInclude Include="Core\Ap4AtomSampleTable.h" />
- <ClInclude Include="Core\Ap4AvcCAtom.h" />
- <ClInclude Include="Core\Ap4ByteStream.h" />
- <ClInclude Include="Core\Ap4ChplAtom.h" />
- <ClInclude Include="Core\Ap4CmvdAtom.h" />
- <ClInclude Include="Core\Ap4Co64Atom.h" />
- <ClInclude Include="Core\Ap4Config.h" />
- <ClInclude Include="Core\Ap4Constants.h" />
- <ClInclude Include="Core\Ap4ContainerAtom.h" />
- <ClInclude Include="Core\Ap4CttsAtom.h" />
- <ClInclude Include="Core\Ap4DataAtom.h" />
- <ClInclude Include="Core\Ap4DataBuffer.h" />
- <ClInclude Include="Core\Ap4DcomAtom.h" />
- <ClInclude Include="Core\Ap4Debug.h" />
- <ClInclude Include="Core\Ap4DecoderConfigDescriptor.h" />
- <ClInclude Include="Core\Ap4DecoderSpecificInfoDescriptor.h" />
- <ClInclude Include="Core\Ap4Descriptor.h" />
- <ClInclude Include="Core\Ap4DescriptorFactory.h" />
- <ClInclude Include="Core\Ap4DrefAtom.h" />
- <ClInclude Include="Core\Ap4EndaAtom.h" />
- <ClInclude Include="Core\Ap4EsDescriptor.h" />
- <ClInclude Include="Core\Ap4EsdsAtom.h" />
- <ClInclude Include="Core\Ap4File.h" />
- <ClInclude Include="Core\Ap4FileByteStream.h" />
- <ClInclude Include="Core\Ap4FileWriter.h" />
- <ClInclude Include="Core\Ap4FrmaAtom.h" />
- <ClInclude Include="Core\Ap4FtabAtom.h" />
- <ClInclude Include="Core\Ap4FtypAtom.h" />
- <ClInclude Include="Core\Ap4HdlrAtom.h" />
- <ClInclude Include="Core\Ap4HintTrackReader.h" />
- <ClInclude Include="Core\Ap4HmhdAtom.h" />
- <ClInclude Include="Core\Ap4IkmsAtom.h" />
- <ClInclude Include="Core\Ap4Interfaces.h" />
- <ClInclude Include="Core\Ap4IsfmAtom.h" />
- <ClInclude Include="Core\Ap4IsmaCryp.h" />
- <ClInclude Include="Core\Ap4List.h" />
- <ClInclude Include="Core\Ap4MdhdAtom.h" />
- <ClInclude Include="Core\Ap4MoovAtom.h" />
- <ClInclude Include="Core\Ap4Movie.h" />
- <ClInclude Include="Core\Ap4MvhdAtom.h" />
- <ClInclude Include="Core\Ap4NmhdAtom.h" />
- <ClInclude Include="Core\Ap4PaspAtom.h" />
- <ClInclude Include="Core\Ap4Processor.h" />
- <ClInclude Include="Core\Ap4Results.h" />
- <ClInclude Include="Core\Ap4RtpAtom.h" />
- <ClInclude Include="Core\Ap4RtpHint.h" />
- <ClInclude Include="Core\Ap4Sample.h" />
- <ClInclude Include="Core\Ap4SampleDescription.h" />
- <ClInclude Include="Core\Ap4SampleEntry.h" />
- <ClInclude Include="Core\Ap4SampleTable.h" />
- <ClInclude Include="Core\Ap4SchmAtom.h" />
- <ClInclude Include="Core\Ap4SdpAtom.h" />
- <ClInclude Include="Core\Ap4SLConfigDescriptor.h" />
- <ClInclude Include="Core\Ap4SmhdAtom.h" />
- <ClInclude Include="Core\Ap4StcoAtom.h" />
- <ClInclude Include="Core\Ap4StscAtom.h" />
- <ClInclude Include="Core\Ap4StsdAtom.h" />
- <ClInclude Include="Core\Ap4StssAtom.h" />
- <ClInclude Include="Core\Ap4StszAtom.h" />
- <ClInclude Include="Core\Ap4SttsAtom.h" />
- <ClInclude Include="Core\Ap4SyntheticSampleTable.h" />
- <ClInclude Include="Core\Ap4TimsAtom.h" />
- <ClInclude Include="Core\Ap4TkhdAtom.h" />
- <ClInclude Include="Core\Ap4Track.h" />
- <ClInclude Include="Core\Ap4TrakAtom.h" />
- <ClInclude Include="Core\Ap4TrefTypeAtom.h" />
- <ClInclude Include="Core\Ap4Types.h" />
- <ClInclude Include="Core\Ap4UnknownDescriptor.h" />
- <ClInclude Include="Core\Ap4UrlAtom.h" />
- <ClInclude Include="Core\Ap4Utils.h" />
- <ClInclude Include="Core\Ap4VmhdAtom.h" />
- <ClInclude Include="Crypto\Ap4AesBlockCipher.h" />
- <ClInclude Include="Crypto\Ap4StreamCipher.h" />
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="Core\Ap4Atom.cpp" />
- <ClCompile Include="Core\Ap4AtomFactory.cpp" />
- <ClCompile Include="Core\Ap4AtomSampleTable.cpp" />
- <ClCompile Include="Core\Ap4AvcCAtom.cpp" />
- <ClCompile Include="Core\Ap4ByteStream.cpp" />
- <ClCompile Include="Core\Ap4ChplAtom.cpp" />
- <ClCompile Include="Core\Ap4CmvdAtom.cpp" />
- <ClCompile Include="Core\Ap4Co64Atom.cpp" />
- <ClCompile Include="Core\Ap4ContainerAtom.cpp" />
- <ClCompile Include="Core\Ap4CttsAtom.cpp" />
- <ClCompile Include="Core\Ap4DataAtom.cpp" />
- <ClCompile Include="Core\Ap4DataBuffer.cpp" />
- <ClCompile Include="Core\Ap4DcomAtom.cpp" />
- <ClCompile Include="Core\Ap4Debug.cpp" />
- <ClCompile Include="Core\Ap4DecoderConfigDescriptor.cpp" />
- <ClCompile Include="Core\Ap4DecoderSpecificInfoDescriptor.cpp" />
- <ClCompile Include="Core\Ap4Descriptor.cpp" />
- <ClCompile Include="Core\Ap4DescriptorFactory.cpp" />
- <ClCompile Include="Core\Ap4DrefAtom.cpp" />
- <ClCompile Include="Core\Ap4EndaAtom.cpp" />
- <ClCompile Include="Core\Ap4EsDescriptor.cpp" />
- <ClCompile Include="Core\Ap4EsdsAtom.cpp" />
- <ClCompile Include="Core\Ap4File.cpp" />
- <ClCompile Include="Core\Ap4FileWriter.cpp" />
- <ClCompile Include="Core\Ap4FrmaAtom.cpp" />
- <ClCompile Include="Core\Ap4FtabAtom.cpp" />
- <ClCompile Include="Core\Ap4FtypAtom.cpp" />
- <ClCompile Include="Core\Ap4HdlrAtom.cpp" />
- <ClCompile Include="Core\Ap4HintTrackReader.cpp" />
- <ClCompile Include="Core\Ap4HmhdAtom.cpp" />
- <ClCompile Include="Core\Ap4IkmsAtom.cpp" />
- <ClCompile Include="Core\Ap4IsfmAtom.cpp" />
- <ClCompile Include="Core\Ap4IsmaCryp.cpp" />
- <ClCompile Include="Core\Ap4MdhdAtom.cpp" />
- <ClCompile Include="Core\Ap4MoovAtom.cpp" />
- <ClCompile Include="Core\Ap4Movie.cpp" />
- <ClCompile Include="Core\Ap4MvhdAtom.cpp" />
- <ClCompile Include="Core\Ap4NmhdAtom.cpp" />
- <ClCompile Include="Core\Ap4PaspAtom.cpp" />
- <ClCompile Include="Core\Ap4Processor.cpp" />
- <ClCompile Include="Core\Ap4RtpAtom.cpp" />
- <ClCompile Include="Core\Ap4RtpHint.cpp" />
- <ClCompile Include="Core\Ap4Sample.cpp" />
- <ClCompile Include="Core\Ap4SampleDescription.cpp" />
- <ClCompile Include="Core\Ap4SampleEntry.cpp" />
- <ClCompile Include="Core\Ap4SampleTable.cpp" />
- <ClCompile Include="Core\Ap4SchmAtom.cpp" />
- <ClCompile Include="Core\Ap4SdpAtom.cpp" />
- <ClCompile Include="Core\Ap4SLConfigDescriptor.cpp" />
- <ClCompile Include="Core\Ap4SmhdAtom.cpp" />
- <ClCompile Include="Core\Ap4StcoAtom.cpp" />
- <ClCompile Include="Core\Ap4StscAtom.cpp" />
- <ClCompile Include="Core\Ap4StsdAtom.cpp" />
- <ClCompile Include="Core\Ap4StssAtom.cpp" />
- <ClCompile Include="Core\Ap4StszAtom.cpp" />
- <ClCompile Include="Core\Ap4SttsAtom.cpp" />
- <ClCompile Include="Core\Ap4SyntheticSampleTable.cpp" />
- <ClCompile Include="Core\Ap4TimsAtom.cpp" />
- <ClCompile Include="Core\Ap4TkhdAtom.cpp" />
- <ClCompile Include="Core\Ap4Track.cpp" />
- <ClCompile Include="Core\Ap4TrakAtom.cpp" />
- <ClCompile Include="Core\Ap4TrefTypeAtom.cpp" />
- <ClCompile Include="Core\Ap4UnknownDescriptor.cpp" />
- <ClCompile Include="Core\Ap4UrlAtom.cpp" />
- <ClCompile Include="Core\Ap4Utils.cpp" />
- <ClCompile Include="Core\Ap4VmhdAtom.cpp" />
- <ClCompile Include="Crypto\Ap4AesBlockCipher.cpp" />
- <ClCompile Include="Crypto\Ap4StreamCipher.cpp" />
- <ClCompile Include="precomp.cpp">
- <PrecompiledHeader>Create</PrecompiledHeader>
- </ClCompile>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/src/thirdparty/Bento4/Bento4.vcxproj.filters b/src/thirdparty/Bento4/Bento4.vcxproj.filters
deleted file mode 100644
index f8f9d4fad..000000000
--- a/src/thirdparty/Bento4/Bento4.vcxproj.filters
+++ /dev/null
@@ -1,451 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Core">
- <UniqueIdentifier>{c12f1597-4c19-42af-aff1-caed8b6a19a9}</UniqueIdentifier>
- </Filter>
- <Filter Include="Crypto">
- <UniqueIdentifier>{3945cbae-de84-443f-9a2e-416e964d8504}</UniqueIdentifier>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="Core\Ap4.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4Array.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4Atom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4AtomFactory.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4AtomSampleTable.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4AvcCAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4ByteStream.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4ChplAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4CmvdAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4Co64Atom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4Config.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4Constants.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4ContainerAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4CttsAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4DataAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4DataBuffer.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4DcomAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4Debug.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4DecoderConfigDescriptor.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4DecoderSpecificInfoDescriptor.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4Descriptor.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4DescriptorFactory.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4DrefAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4EndaAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4EsDescriptor.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4EsdsAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4File.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4FileByteStream.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4FileWriter.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4FrmaAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4FtabAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4FtypAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4HdlrAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4HintTrackReader.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4HmhdAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4IkmsAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4Interfaces.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4IsfmAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4IsmaCryp.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4List.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4MdhdAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4MoovAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4Movie.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4MvhdAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4NmhdAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4PaspAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4Processor.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4Results.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4RtpAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4RtpHint.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4Sample.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4SampleDescription.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4SampleEntry.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4SampleTable.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4SchmAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4SdpAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4SLConfigDescriptor.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4SmhdAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4StcoAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4StscAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4StsdAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4StssAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4StszAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4SttsAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4SyntheticSampleTable.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4TimsAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4TkhdAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4Track.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4TrakAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4TrefTypeAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4Types.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4UnknownDescriptor.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4UrlAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4Utils.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Core\Ap4VmhdAtom.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="Crypto\Ap4AesBlockCipher.h">
- <Filter>Crypto</Filter>
- </ClInclude>
- <ClInclude Include="Crypto\Ap4StreamCipher.h">
- <Filter>Crypto</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="Core\Ap4Atom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4AtomFactory.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4AtomSampleTable.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4AvcCAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4ByteStream.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4ChplAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4CmvdAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4Co64Atom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4ContainerAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4CttsAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4DataAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4DataBuffer.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4DcomAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4Debug.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4DecoderConfigDescriptor.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4DecoderSpecificInfoDescriptor.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4Descriptor.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4DescriptorFactory.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4DrefAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4EndaAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4EsDescriptor.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4EsdsAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4File.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4FileWriter.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4FrmaAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4FtabAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4FtypAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4HdlrAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4HintTrackReader.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4HmhdAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4IkmsAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4IsfmAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4IsmaCryp.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4MdhdAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4MoovAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4Movie.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4MvhdAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4NmhdAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4PaspAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4Processor.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4RtpAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4RtpHint.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4Sample.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4SampleDescription.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4SampleEntry.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4SampleTable.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4SchmAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4SdpAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4SLConfigDescriptor.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4SmhdAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4StcoAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4StscAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4StsdAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4StssAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4StszAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4SttsAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4SyntheticSampleTable.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4TimsAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4TkhdAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4Track.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4TrakAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4TrefTypeAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4UnknownDescriptor.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4UrlAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4Utils.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Core\Ap4VmhdAtom.cpp">
- <Filter>Core</Filter>
- </ClCompile>
- <ClCompile Include="Crypto\Ap4AesBlockCipher.cpp">
- <Filter>Crypto</Filter>
- </ClCompile>
- <ClCompile Include="Crypto\Ap4StreamCipher.cpp">
- <Filter>Crypto</Filter>
- </ClCompile>
- <ClCompile Include="precomp.cpp" />
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/src/thirdparty/Bento4/Core/Ap4.h b/src/thirdparty/Bento4/Core/Ap4.h
deleted file mode 100644
index d2263a7a1..000000000
--- a/src/thirdparty/Bento4/Core/Ap4.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Main Header
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_H_
-#define _AP4_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4Config.h"
-#include "Ap4Types.h"
-#include "Ap4Constants.h"
-#include "Ap4Results.h"
-#include "Ap4Debug.h"
-
-
-#endif // _AP4_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4Array.h b/src/thirdparty/Bento4/Core/Ap4Array.h
deleted file mode 100644
index faa22862a..000000000
--- a/src/thirdparty/Bento4/Core/Ap4Array.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Arrays
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_ARRAY_H_
-#define _AP4_ARRAY_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4Types.h"
-#include "Ap4Results.h"
-
-/*----------------------------------------------------------------------
-| constants
-+---------------------------------------------------------------------*/
-const int AP4_ARRAY_INITIAL_COUNT = 64;
-
-/*----------------------------------------------------------------------
-| AP4_Array
-+---------------------------------------------------------------------*/
-template <typename T>
-class AP4_Array
-{
-public:
- // methods
- AP4_Array<T>(): m_AllocatedCount(0), m_ItemCount(0), m_Items(0) {}
- virtual ~AP4_Array<T>();
- AP4_Cardinal ItemCount() { return m_ItemCount; }
- AP4_Result Append(const T& item);
- T& operator[](unsigned long idx);
- AP4_Result EnsureCapacity(AP4_Cardinal count);
-
-protected:
- // members
- AP4_Cardinal m_AllocatedCount;
- AP4_Cardinal m_ItemCount;
- T* m_Items;
- T m_OverflowItem;
-};
-
-/*----------------------------------------------------------------------
-| AP4_Array<T>::~AP4_Array<T>
-+---------------------------------------------------------------------*/
-template <typename T>
-AP4_Array<T>::~AP4_Array()
-{
- delete[] m_Items;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Array<T>::EnsureCapacity
-+---------------------------------------------------------------------*/
-template <typename T>
-AP4_Result
-AP4_Array<T>::EnsureCapacity(AP4_Cardinal count)
-{
- if (count <= m_AllocatedCount) return AP4_SUCCESS;
-
- unsigned long new_count;
- if (m_AllocatedCount) {
- new_count = 2*m_AllocatedCount;
- } else {
- new_count = AP4_ARRAY_INITIAL_COUNT;
- }
-
- // (re)allocate the items
- T* new_items = new T[new_count];
- if (new_items == NULL) {
- return AP4_ERROR_OUT_OF_MEMORY;
- }
- if (m_ItemCount && m_Items) {
- for (unsigned int i=0; i<m_ItemCount; i++) {
- new_items[i] = m_Items[i];
- }
- delete[] m_Items;
- }
- m_Items = new_items;
- m_AllocatedCount = new_count;
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Array<T>::operator[]
-+---------------------------------------------------------------------*/
-template <typename T>
-T&
-AP4_Array<T>::operator[](unsigned long idx)
-{
- if (idx >= m_ItemCount) {
- return m_OverflowItem;
- } else {
- return m_Items[idx];
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_Array<T>::Append
-+---------------------------------------------------------------------*/
-template <typename T>
-AP4_Result
-AP4_Array<T>::Append(const T& item)
-{
- // ensure capacity
- AP4_Result result = EnsureCapacity(m_ItemCount+1);
- if (result != AP4_SUCCESS) return result;
-
- // store the item
- m_Items[m_ItemCount++] = item;
-
- return AP4_SUCCESS;
-}
-
-#endif // _AP4_ARRAY_H_
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/thirdparty/Bento4/Core/Ap4Atom.cpp b/src/thirdparty/Bento4/Core/Ap4Atom.cpp
deleted file mode 100644
index d62a2f831..000000000
--- a/src/thirdparty/Bento4/Core/Ap4Atom.cpp
+++ /dev/null
@@ -1,433 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4Atom.h"
-#include "Ap4Utils.h"
-#include "Ap4ContainerAtom.h"
-#include "Ap4StsdAtom.h"
-#include "Ap4Debug.h"
-
-/*----------------------------------------------------------------------
-| AP4_Atom::AP4_Atom
-+---------------------------------------------------------------------*/
-AP4_Atom::AP4_Atom(Type type,
- bool is_full) :
- m_Type(type),
- m_Size(is_full ? AP4_FULL_ATOM_HEADER_SIZE : AP4_ATOM_HEADER_SIZE),
- m_IsFull(is_full),
- m_Version(0),
- m_Flags(0),
- m_Parent(NULL)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_Atom::AP4_Atom
-+---------------------------------------------------------------------*/
-AP4_Atom::AP4_Atom(Type type,
- AP4_Size size,
- bool is_full) :
- m_Type(type),
- m_Size(size),
- m_IsFull(is_full),
- m_Version(0),
- m_Flags(0),
- m_Parent(NULL)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_Atom::AP4_Atom
-+---------------------------------------------------------------------*/
-AP4_Atom::AP4_Atom(Type type,
- AP4_Size size,
- bool is_full,
- AP4_ByteStream& stream) :
- m_Type(type),
- m_Size(size),
- m_IsFull(is_full),
- m_Parent(NULL)
-{
- // if this is a full atom, read the version and flags
- if (is_full) {
- AP4_UI32 header;
- stream.ReadUI32(header);
- m_Version = (header>>24)&0xFF;
- m_Flags = (header&0xFFFFFF);
- } else {
- m_Version = 0;
- m_Flags = 0;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_Atom::GetHeaderSize
-+---------------------------------------------------------------------*/
-AP4_Size
-AP4_Atom::GetHeaderSize()
-{
- return m_IsFull ? AP4_FULL_ATOM_HEADER_SIZE : AP4_ATOM_HEADER_SIZE;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Atom::WriteHeader
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Atom::WriteHeader(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- // write the size
- result = stream.WriteUI32(m_Size);
- if (AP4_FAILED(result)) return result;
-
- // write the type
- result = stream.WriteUI32(m_Type);
- if (AP4_FAILED(result)) return result;
-
- // for full atoms, write version and flags
- if (m_IsFull) {
- result = stream.WriteUI08(m_Version);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI24(m_Flags);
- if (AP4_FAILED(result)) return result;
- }
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Atom::Write
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Atom::Write(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
-#if defined(AP4_DEBUG)
- AP4_Offset before;
- stream.Tell(before);
-#endif
-
- // write the header
- result = WriteHeader(stream);
- if (AP4_FAILED(result)) return result;
-
- // write the fields
- result = WriteFields(stream);
- if (AP4_FAILED(result)) return result;
-
-#if defined(AP4_DEBUG)
- AP4_Offset after;
- stream.Tell(after);
- AP4_ASSERT(after-before == m_Size);
-#endif
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Atom::Inspect
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Atom::Inspect(AP4_AtomInspector& inspector)
-{
- InspectHeader(inspector);
- InspectFields(inspector);
- inspector.EndElement();
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Atom::InspectHeader
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Atom::InspectHeader(AP4_AtomInspector& inspector)
-{
- // write atom name
- char name[7];
- name[0] = '[';
- AP4_FormatFourChars(&name[1], m_Type);
- name[5] = ']';
- name[6] = '\0';
- char size[64];
- AP4_StringFormat(size, sizeof(size), "size=%ld+%ld", GetHeaderSize(),
- m_Size-GetHeaderSize());
- inspector.StartElement(name, size);
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Atom::Detach
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Atom::Detach()
-{
- if (m_Parent) {
- return m_Parent->RemoveChild(this);
- } else {
- return AP4_SUCCESS;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_UnknownAtom::AP4_UnknownAtom
-+---------------------------------------------------------------------*/
-AP4_UnknownAtom::AP4_UnknownAtom(Type type,
- AP4_Size size,
- bool is_full,
- AP4_ByteStream& stream) :
- AP4_Atom(type, size, is_full, stream),
- m_SourceStream(&stream)
-{
- // store source stream offset
- stream.Tell(m_SourceOffset);
-
- // keep a reference to the source stream
- m_SourceStream->AddReference();
-}
-
-/*----------------------------------------------------------------------
-| AP4_UnknownAtom::~AP4_UnknownAtom
-+---------------------------------------------------------------------*/
-AP4_UnknownAtom::~AP4_UnknownAtom()
-{
- // release the source stream reference
- if (m_SourceStream) {
- m_SourceStream->Release();
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_UnknownAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_UnknownAtom::WriteFields(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- // check that we have a source stream
- // and a normal size
- if (m_SourceStream == NULL || m_Size < 8) {
- return AP4_FAILURE;
- }
-
- // seek into the source at the stored offset
- result = m_SourceStream->Seek(m_SourceOffset);
- if (AP4_FAILED(result)) return result;
-
- // copy the source stream to the output
- result = m_SourceStream->CopyTo(stream, m_Size-GetHeaderSize());
- if (AP4_FAILED(result)) return result;
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_AtomParent::~AP4_AtomParent
-+---------------------------------------------------------------------*/
-AP4_AtomParent::~AP4_AtomParent()
-{
- m_Children.DeleteReferences();
-}
-
-/*----------------------------------------------------------------------
-| AP4_AtomParent::AddChild
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_AtomParent::AddChild(AP4_Atom* child, int position)
-{
- // check that the child does not already have a parent
- if (child->GetParent() != NULL) return AP4_ERROR_INVALID_PARAMETERS;
-
- // attach the child
- AP4_Result result;
- if (position == -1) {
- // insert at the tail
- result = m_Children.Add(child);
- } else if (position == 0) {
- // insert at the head
- result = m_Children.Insert(NULL, child);
- } else {
- // insert after <n-1>
- AP4_List<AP4_Atom>::Item* insertion_point = m_Children.FirstItem();
- unsigned int count = position;
- while (insertion_point && --count) {
- insertion_point = insertion_point->GetNext();
- }
- if (insertion_point) {
- result = m_Children.Insert(insertion_point, child);
- } else {
- result = AP4_ERROR_OUT_OF_RANGE;
- }
- }
- if (AP4_FAILED(result)) return result;
-
- // notify the child of its parent
- child->SetParent(this);
-
- // get a chance to update
- OnChildAdded(child);
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_AtomParent::RemoveChild
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_AtomParent::RemoveChild(AP4_Atom* child)
-{
- // check that this is our child
- if (child->GetParent() != this) return AP4_ERROR_INVALID_PARAMETERS;
-
- // remove the child
- AP4_Result result = m_Children.Remove(child);
- if (AP4_FAILED(result)) return result;
-
- // notify that child that it is orphaned
- child->SetParent(NULL);
-
- // get a chance to update
- OnChildRemoved(child);
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_AtomParent::DeleteChild
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_AtomParent::DeleteChild(AP4_Atom::Type type)
-{
- // find the child
- AP4_Atom* child = GetChild(type);
- if (child == NULL) return AP4_FAILURE;
-
- // remove the child
- AP4_Result result = RemoveChild(child);
- if (AP4_FAILED(result)) return result;
-
- // delete the child
- delete child;
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_AtomParent::GetChild
-+---------------------------------------------------------------------*/
-AP4_Atom*
-AP4_AtomParent::GetChild(AP4_Atom::Type type, AP4_Ordinal index /* = 0 */)
-{
- AP4_Atom* atom;
- AP4_Result result = m_Children.Find(AP4_AtomFinder(type, index), atom);
- if (AP4_SUCCEEDED(result)) {
- return atom;
- } else {
- return NULL;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_AtomParent::FindChild
-+---------------------------------------------------------------------*/
-AP4_Atom*
-AP4_AtomParent::FindChild(const char* path,
- bool auto_create)
-{
- // start from here
- AP4_AtomParent* parent = this;
-
- // walk the path
- while (path[0] && path[1] && path[2] && path[3]) {
- // we have 4 valid chars
- const char* tail;
- int index = 0;
- if (path[4] == '\0') {
- tail = NULL;
- } else if (path[4] == '/') {
- // separator
- tail = &path[5];
- } else if (path[4] == '[') {
- const char* x = &path[5];
- while (*x >= '0' && *x <= '9') {
- index = 10*index+(*x++ - '0');
- }
- if (x[0] == ']') {
- if (x[1] == '\0') {
- tail = NULL;
- } else {
- tail = x+2;
- }
- } else {
- // malformed path
- return NULL;
- }
- } else {
- // malformed path
- return NULL;
- }
-
- // look for this atom in the current list
- AP4_Atom::Type type = AP4_ATOM_TYPE(path[0], path[1], path[2], path[3]);
- AP4_Atom* atom = parent->GetChild(type, index);
- if (atom == NULL) {
- // not found
- if (auto_create && (index == 0)) {
- AP4_ContainerAtom* container = dynamic_cast<AP4_ContainerAtom*>(parent);
- if (parent) {
- atom = new AP4_ContainerAtom(type, false);
- container->AddChild(atom);
- } else {
- return NULL;
- }
- } else {
- return NULL;
- }
- }
-
- if (tail) {
- path = tail;
- // if this atom is an atom parent, recurse
- parent = dynamic_cast<AP4_ContainerAtom*>(atom);
- if (parent == NULL) return NULL;
- } else {
- return atom;
- }
- }
-
- // not found
- return NULL;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4Atom.h b/src/thirdparty/Bento4/Core/Ap4Atom.h
deleted file mode 100644
index 2f29ebed1..000000000
--- a/src/thirdparty/Bento4/Core/Ap4Atom.h
+++ /dev/null
@@ -1,407 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_ATOM_H_
-#define _AP4_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4Types.h"
-#include "Ap4List.h"
-#include "Ap4ByteStream.h"
-#include "Ap4Debug.h"
-
-/*----------------------------------------------------------------------
-| macros
-+---------------------------------------------------------------------*/
-#define AP4_ATOM_TYPE(a,b,c,d) \
- ((((unsigned long)a)<<24) | \
- (((unsigned long)b)<<16) | \
- (((unsigned long)c)<< 8) | \
- (((unsigned long)d) ))
-
-/*----------------------------------------------------------------------
-| constants
-+---------------------------------------------------------------------*/
-const int AP4_ATOM_HEADER_SIZE = 8;
-const int AP4_FULL_ATOM_HEADER_SIZE = 12;
-const int AP4_ATOM_MAX_NAME_SIZE = 256;
-const int AP4_ATOM_MAX_URI_SIZE = 512;
-
-/*----------------------------------------------------------------------
-| forward references
-+---------------------------------------------------------------------*/
-class AP4_AtomParent;
-
-/*----------------------------------------------------------------------
-| AP4_AtomInspector
-+---------------------------------------------------------------------*/
-class AP4_AtomInspector {
-public:
- // types
- typedef enum {
- HINT_NONE,
- HINT_HEX,
- HINT_BOOLEAN
- } FormatHint;
-
- // constructor and destructor
- AP4_AtomInspector() {}
- virtual ~AP4_AtomInspector() {}
-
- // methods
- virtual void StartElement(const char* name, const char* extra = NULL) {}
- virtual void EndElement() {}
- virtual void AddField(const char* name, AP4_UI32 value, FormatHint hint = HINT_NONE) {}
- virtual void AddField(const char* name, const char* value, FormatHint hint = HINT_NONE) {}
-};
-
-/*----------------------------------------------------------------------
-| AP4_Atom
-+---------------------------------------------------------------------*/
-class AP4_Atom {
- public:
- // types
- typedef AP4_UI32 Type;
-
- // methods
- AP4_Atom(Type type,
- bool is_full = false);
- AP4_Atom(Type type,
- AP4_Size size,
- bool is_full = false);
- AP4_Atom(Type type,
- AP4_Size size,
- bool is_full,
- AP4_ByteStream& stream);
- virtual ~AP4_Atom() {}
- Type GetType() { return m_Type; }
- void SetType(Type type) { m_Type = type; }
- AP4_Size GetHeaderSize();
- virtual AP4_Size GetSize() { return m_Size; }
- virtual AP4_Result Write(AP4_ByteStream& stream);
- virtual AP4_Result WriteHeader(AP4_ByteStream& stream);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream) = 0;
- virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
- virtual AP4_Result InspectHeader(AP4_AtomInspector& inspector);
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector) {
- return AP4_SUCCESS;
- }
-
- // parent/child realtionship methods
- virtual AP4_Result SetParent(AP4_AtomParent* parent) {
- m_Parent = parent;
- return AP4_SUCCESS;
- }
- virtual AP4_AtomParent* GetParent() { return m_Parent; }
- virtual AP4_Result Detach();
-
- // override this if your want to make an atom cloneable
- virtual AP4_Atom* Clone() { return NULL; }
-
- protected:
- // members
- Type m_Type;
- AP4_Size m_Size;
- bool m_IsFull;
- AP4_UI32 m_Version;
- AP4_UI32 m_Flags;
- AP4_AtomParent* m_Parent;
-};
-
-/*----------------------------------------------------------------------
-| AP4_AtomParent
-+---------------------------------------------------------------------*/
-class AP4_AtomParent {
-public:
- // base methods
- virtual ~AP4_AtomParent();
- AP4_List<AP4_Atom>& GetChildren() { return m_Children; }
- virtual AP4_Result AddChild(AP4_Atom* child, int position = -1);
- virtual AP4_Result RemoveChild(AP4_Atom* child);
- virtual AP4_Result DeleteChild(AP4_Atom::Type type);
- virtual AP4_Atom* GetChild(AP4_Atom::Type type, AP4_Ordinal index = 0);
- virtual AP4_Atom* FindChild(const char* path,
- bool auto_create = false);
-
- // methods designed to be overridden
- virtual void OnChildChanged(AP4_Atom* child) {}
- virtual void OnChildAdded(AP4_Atom* child) {}
- virtual void OnChildRemoved(AP4_Atom* child) {}
-
-protected:
- // members
- AP4_List<AP4_Atom> m_Children;
-};
-
-/*----------------------------------------------------------------------
-| AP4_UnknownAtom
-+---------------------------------------------------------------------*/
-class AP4_UnknownAtom : public AP4_Atom {
-public:
- // constructor and destructor
- AP4_UnknownAtom(AP4_Atom::Type type,
- AP4_Size size,
- bool is_full,
- AP4_ByteStream& stream);
- ~AP4_UnknownAtom();
-
- // methods
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
-private:
- // members
- AP4_ByteStream* m_SourceStream;
- AP4_Offset m_SourceOffset;
-};
-
-/*----------------------------------------------------------------------
-| atom types
-+---------------------------------------------------------------------*/
-const AP4_Atom::Type AP4_ATOM_TYPE_UDTA = AP4_ATOM_TYPE('u','d','t','a');
-const AP4_Atom::Type AP4_ATOM_TYPE_URL = AP4_ATOM_TYPE('u','r','l',' ');
-const AP4_Atom::Type AP4_ATOM_TYPE_TRAK = AP4_ATOM_TYPE('t','r','a','k');
-const AP4_Atom::Type AP4_ATOM_TYPE_TKHD = AP4_ATOM_TYPE('t','k','h','d');
-const AP4_Atom::Type AP4_ATOM_TYPE_STTS = AP4_ATOM_TYPE('s','t','t','s');
-const AP4_Atom::Type AP4_ATOM_TYPE_STSZ = AP4_ATOM_TYPE('s','t','s','z');
-const AP4_Atom::Type AP4_ATOM_TYPE_STSS = AP4_ATOM_TYPE('s','t','s','s');
-const AP4_Atom::Type AP4_ATOM_TYPE_STSD = AP4_ATOM_TYPE('s','t','s','d');
-const AP4_Atom::Type AP4_ATOM_TYPE_STSC = AP4_ATOM_TYPE('s','t','s','c');
-const AP4_Atom::Type AP4_ATOM_TYPE_STCO = AP4_ATOM_TYPE('s','t','c','o');
-const AP4_Atom::Type AP4_ATOM_TYPE_CO64 = AP4_ATOM_TYPE('c','o','6','4');
-const AP4_Atom::Type AP4_ATOM_TYPE_STBL = AP4_ATOM_TYPE('s','t','b','l');
-const AP4_Atom::Type AP4_ATOM_TYPE_SINF = AP4_ATOM_TYPE('s','i','n','f');
-const AP4_Atom::Type AP4_ATOM_TYPE_SCHM = AP4_ATOM_TYPE('s','c','h','m');
-const AP4_Atom::Type AP4_ATOM_TYPE_SCHI = AP4_ATOM_TYPE('s','c','h','i');
-const AP4_Atom::Type AP4_ATOM_TYPE_MVHD = AP4_ATOM_TYPE('m','v','h','d');
-const AP4_Atom::Type AP4_ATOM_TYPE_MP4S = AP4_ATOM_TYPE('m','p','4','s');
-const AP4_Atom::Type AP4_ATOM_TYPE_MP4A = AP4_ATOM_TYPE('m','p','4','a');
-const AP4_Atom::Type AP4_ATOM_TYPE_MP4V = AP4_ATOM_TYPE('m','p','4','v');
-const AP4_Atom::Type AP4_ATOM_TYPE_AVC1 = AP4_ATOM_TYPE('a','v','c','1');
-const AP4_Atom::Type AP4_ATOM_TYPE_ENCA = AP4_ATOM_TYPE('e','n','c','a');
-const AP4_Atom::Type AP4_ATOM_TYPE_ENCV = AP4_ATOM_TYPE('e','n','c','v');
-const AP4_Atom::Type AP4_ATOM_TYPE_MOOV = AP4_ATOM_TYPE('m','o','o','v');
-const AP4_Atom::Type AP4_ATOM_TYPE_MINF = AP4_ATOM_TYPE('m','i','n','f');
-const AP4_Atom::Type AP4_ATOM_TYPE_META = AP4_ATOM_TYPE('m','e','t','a');
-const AP4_Atom::Type AP4_ATOM_TYPE_MDHD = AP4_ATOM_TYPE('m','d','h','d');
-const AP4_Atom::Type AP4_ATOM_TYPE_ILST = AP4_ATOM_TYPE('i','l','s','t');
-const AP4_Atom::Type AP4_ATOM_TYPE_HDLR = AP4_ATOM_TYPE('h','d','l','r');
-const AP4_Atom::Type AP4_ATOM_TYPE_FTYP = AP4_ATOM_TYPE('f','t','y','p');
-const AP4_Atom::Type AP4_ATOM_TYPE_ESDS = AP4_ATOM_TYPE('e','s','d','s');
-const AP4_Atom::Type AP4_ATOM_TYPE_EDTS = AP4_ATOM_TYPE('e','d','t','s');
-const AP4_Atom::Type AP4_ATOM_TYPE_DRMS = AP4_ATOM_TYPE('d','r','m','s');
-const AP4_Atom::Type AP4_ATOM_TYPE_DREF = AP4_ATOM_TYPE('d','r','e','f');
-const AP4_Atom::Type AP4_ATOM_TYPE_DINF = AP4_ATOM_TYPE('d','i','n','f');
-const AP4_Atom::Type AP4_ATOM_TYPE_CTTS = AP4_ATOM_TYPE('c','t','t','s');
-const AP4_Atom::Type AP4_ATOM_TYPE_MDIA = AP4_ATOM_TYPE('m','d','i','a');
-const AP4_Atom::Type AP4_ATOM_TYPE_VMHD = AP4_ATOM_TYPE('v','m','h','d');
-const AP4_Atom::Type AP4_ATOM_TYPE_SMHD = AP4_ATOM_TYPE('s','m','h','d');
-const AP4_Atom::Type AP4_ATOM_TYPE_NMHD = AP4_ATOM_TYPE('n','m','h','d');
-const AP4_Atom::Type AP4_ATOM_TYPE_HMHD = AP4_ATOM_TYPE('h','m','h','d');
-const AP4_Atom::Type AP4_ATOM_TYPE_FRMA = AP4_ATOM_TYPE('f','r','m','a');
-const AP4_Atom::Type AP4_ATOM_TYPE_MDAT = AP4_ATOM_TYPE('m','d','a','t');
-const AP4_Atom::Type AP4_ATOM_TYPE_FREE = AP4_ATOM_TYPE('f','r','e','e');
-const AP4_Atom::Type AP4_ATOM_TYPE_TIMS = AP4_ATOM_TYPE('t','i','m','s');
-const AP4_Atom::Type AP4_ATOM_TYPE_RTP = AP4_ATOM_TYPE('r','t','p',' ');
-const AP4_Atom::Type AP4_ATOM_TYPE_HNTI = AP4_ATOM_TYPE('h','n','t','i');
-const AP4_Atom::Type AP4_ATOM_TYPE_SDP = AP4_ATOM_TYPE('s','d','p',' ');
-const AP4_Atom::Type AP4_ATOM_TYPE_IKMS = AP4_ATOM_TYPE('i','K','M','S');
-const AP4_Atom::Type AP4_ATOM_TYPE_ISFM = AP4_ATOM_TYPE('i','S','F','M');
-const AP4_Atom::Type AP4_ATOM_TYPE_HINT = AP4_ATOM_TYPE('h','i','n','t');
-const AP4_Atom::Type AP4_ATOM_TYPE_TREF = AP4_ATOM_TYPE('t','r','e','f');
-
-const AP4_Atom::Type AP4_ATOM_TYPE_AVCC = AP4_ATOM_TYPE('a','v','c','C');
-const AP4_Atom::Type AP4_ATOM_TYPE_TEXT = AP4_ATOM_TYPE('t','e','x','t');
-const AP4_Atom::Type AP4_ATOM_TYPE_TX3G = AP4_ATOM_TYPE('t','x','3','g');
-const AP4_Atom::Type AP4_ATOM_TYPE_FTAB = AP4_ATOM_TYPE('f','t','a','b');
-const AP4_Atom::Type AP4_ATOM_TYPE_CVID = AP4_ATOM_TYPE('c','v','i','d');
-const AP4_Atom::Type AP4_ATOM_TYPE_SVQ1 = AP4_ATOM_TYPE('S','V','Q','1');
-const AP4_Atom::Type AP4_ATOM_TYPE_SVQ2 = AP4_ATOM_TYPE('S','V','Q','2');
-const AP4_Atom::Type AP4_ATOM_TYPE_SVQ3 = AP4_ATOM_TYPE('S','V','Q','3');
-const AP4_Atom::Type AP4_ATOM_TYPE_H261 = AP4_ATOM_TYPE('h','2','6','1');
-const AP4_Atom::Type AP4_ATOM_TYPE_H263 = AP4_ATOM_TYPE('h','2','6','3');
-const AP4_Atom::Type AP4_ATOM_TYPE_S263 = AP4_ATOM_TYPE('s','2','6','3');
-const AP4_Atom::Type AP4_ATOM_TYPE_SAMR = AP4_ATOM_TYPE('s','a','m','r');
-const AP4_Atom::Type AP4_ATOM_TYPE__MP3 = AP4_ATOM_TYPE('.','m','p','3');
-const AP4_Atom::Type AP4_ATOM_TYPE_IMA4 = AP4_ATOM_TYPE('i','m','a','4');
-const AP4_Atom::Type AP4_ATOM_TYPE_QDMC = AP4_ATOM_TYPE('Q','D','M','C');
-const AP4_Atom::Type AP4_ATOM_TYPE_QDM2 = AP4_ATOM_TYPE('Q','D','M','2');
-//PCM Audio
-const AP4_Atom::Type AP4_ATOM_TYPE_NONE = AP4_ATOM_TYPE('N','O','N','E');
-const AP4_Atom::Type AP4_ATOM_TYPE_TWOS = AP4_ATOM_TYPE('t','w','o','s');
-const AP4_Atom::Type AP4_ATOM_TYPE_SOWT = AP4_ATOM_TYPE('s','o','w','t');
-const AP4_Atom::Type AP4_ATOM_TYPE_IN24 = AP4_ATOM_TYPE('i','n','2','4');
-const AP4_Atom::Type AP4_ATOM_TYPE_IN32 = AP4_ATOM_TYPE('i','n','3','2');
-const AP4_Atom::Type AP4_ATOM_TYPE_FL32 = AP4_ATOM_TYPE('f','l','3','2');
-const AP4_Atom::Type AP4_ATOM_TYPE_FL64 = AP4_ATOM_TYPE('f','l','6','4');
-//LPCM
-const AP4_Atom::Type AP4_ATOM_TYPE_LPCM = AP4_ATOM_TYPE('l','p','c','m');
-//
-const AP4_Atom::Type AP4_ATOM_TYPE_CHPL = AP4_ATOM_TYPE('c','h','p','l');
-const AP4_Atom::Type AP4_ATOM_TYPE_NAM = AP4_ATOM_TYPE(169,'n','a','m');
-const AP4_Atom::Type AP4_ATOM_TYPE_ART = AP4_ATOM_TYPE(169,'A','R','T');
-const AP4_Atom::Type AP4_ATOM_TYPE_WRT = AP4_ATOM_TYPE(169,'w','r','t');
-const AP4_Atom::Type AP4_ATOM_TYPE_ALB = AP4_ATOM_TYPE(169,'a','l','b');
-const AP4_Atom::Type AP4_ATOM_TYPE_DAY = AP4_ATOM_TYPE(169,'d','a','y');
-const AP4_Atom::Type AP4_ATOM_TYPE_TOO = AP4_ATOM_TYPE(169,'t','o','o');
-const AP4_Atom::Type AP4_ATOM_TYPE_CMT = AP4_ATOM_TYPE(169,'c','m','t');
-const AP4_Atom::Type AP4_ATOM_TYPE_GEN = AP4_ATOM_TYPE(169,'g','e','n');
-const AP4_Atom::Type AP4_ATOM_TYPE_TRKN = AP4_ATOM_TYPE('t','r','k','n');
-const AP4_Atom::Type AP4_ATOM_TYPE_DATA = AP4_ATOM_TYPE('d','a','t','a');
-const AP4_Atom::Type AP4_ATOM_TYPE_WAVE = AP4_ATOM_TYPE('w','a','v','e');
-const AP4_Atom::Type AP4_ATOM_TYPE_ENDA = AP4_ATOM_TYPE('e','n','d','a');
-const AP4_Atom::Type AP4_ATOM_TYPE_CMOV = AP4_ATOM_TYPE('c','m','o','v');
-const AP4_Atom::Type AP4_ATOM_TYPE_DCOM = AP4_ATOM_TYPE('d','c','o','m');
-const AP4_Atom::Type AP4_ATOM_TYPE_CMVD = AP4_ATOM_TYPE('c','m','v','d');
-const AP4_Atom::Type AP4_ATOM_TYPE__AC3 = AP4_ATOM_TYPE('a','c','-','3');
-const AP4_Atom::Type AP4_ATOM_TYPE_SAC3 = AP4_ATOM_TYPE('s','a','c','3');
-const AP4_Atom::Type AP4_ATOM_TYPE_EAC3 = AP4_ATOM_TYPE('e','c','-','3');
-const AP4_Atom::Type AP4_ATOM_TYPE_DTSC = AP4_ATOM_TYPE('d','t','s','c');
-const AP4_Atom::Type AP4_ATOM_TYPE_DTSH = AP4_ATOM_TYPE('d','t','s','h');
-const AP4_Atom::Type AP4_ATOM_TYPE_DTSL = AP4_ATOM_TYPE('d','t','s','l');
-const AP4_Atom::Type AP4_ATOM_TYPE_RAW = AP4_ATOM_TYPE('r','a','w',' ');
-const AP4_Atom::Type AP4_ATOM_TYPE_JPEG = AP4_ATOM_TYPE('j','p','e','g');
-const AP4_Atom::Type AP4_ATOM_TYPE_PNG = AP4_ATOM_TYPE('p','n','g',' ');
-const AP4_Atom::Type AP4_ATOM_TYPE_ALAW = AP4_ATOM_TYPE('a','l','a','w');
-const AP4_Atom::Type AP4_ATOM_TYPE_ULAW = AP4_ATOM_TYPE('u','l','a','w');
-const AP4_Atom::Type AP4_ATOM_TYPE_RLE = AP4_ATOM_TYPE('r','l','e',' ');
-//Motion-JPEG
-const AP4_Atom::Type AP4_ATOM_TYPE_MJPA = AP4_ATOM_TYPE('m','j','p','a');
-const AP4_Atom::Type AP4_ATOM_TYPE_MJPB = AP4_ATOM_TYPE('m','j','p','b');
-const AP4_Atom::Type AP4_ATOM_TYPE_MJPG = AP4_ATOM_TYPE('M','J','P','G');//need a sample
-const AP4_Atom::Type AP4_ATOM_TYPE_AVDJ = AP4_ATOM_TYPE('A','V','D','J');
-const AP4_Atom::Type AP4_ATOM_TYPE_DMB1 = AP4_ATOM_TYPE('d','m','b','1');
-//
-const AP4_Atom::Type AP4_ATOM_TYPE_RPZA = AP4_ATOM_TYPE('r','p','z','a');
-const AP4_Atom::Type AP4_ATOM_TYPE_DIV3 = AP4_ATOM_TYPE('D','I','V','3');
-const AP4_Atom::Type AP4_ATOM_TYPE_DIVX = AP4_ATOM_TYPE('d','i','v','x');
-const AP4_Atom::Type AP4_ATOM_TYPE_8BPS = AP4_ATOM_TYPE('8','B','P','S');
-const AP4_Atom::Type AP4_ATOM_TYPE_3IV1 = AP4_ATOM_TYPE('3','I','V','1');
-const AP4_Atom::Type AP4_ATOM_TYPE_3IV2 = AP4_ATOM_TYPE('3','I','V','2');
-const AP4_Atom::Type AP4_ATOM_TYPE_IV32 = AP4_ATOM_TYPE('I','V','3','2');
-const AP4_Atom::Type AP4_ATOM_TYPE_IV41 = AP4_ATOM_TYPE('I','V','4','1');
-const AP4_Atom::Type AP4_ATOM_TYPE_VP31 = AP4_ATOM_TYPE('V','P','3','1');
-const AP4_Atom::Type AP4_ATOM_TYPE_YV12 = AP4_ATOM_TYPE('y','v','1','2');
-const AP4_Atom::Type AP4_ATOM_TYPE_2VUY = AP4_ATOM_TYPE('2','v','u','y');
-
-const AP4_Atom::Type AP4_ATOM_TYPE_PASP = AP4_ATOM_TYPE('p','a','s','p');
-
-const AP4_Atom::Type AP4_ATOM_TYPE_NMOS = AP4_ATOM_TYPE('n','m','o','s');
-const AP4_Atom::Type AP4_ATOM_TYPE_ALAC = AP4_ATOM_TYPE('a','l','a','c');
-const AP4_Atom::Type AP4_ATOM_TYPE_MAC3 = AP4_ATOM_TYPE('M','A','C','3');
-const AP4_Atom::Type AP4_ATOM_TYPE_MAC6 = AP4_ATOM_TYPE('M','A','C','6');
-// DV
-const AP4_Atom::Type AP4_ATOM_TYPE_DVC = AP4_ATOM_TYPE('d','v','c',' '); // NTSC DV-25 video
-const AP4_Atom::Type AP4_ATOM_TYPE_DVCP = AP4_ATOM_TYPE('d','v','c','p'); // PAL DV-25 video
-// DVPRO
-const AP4_Atom::Type AP4_ATOM_TYPE_DVPP = AP4_ATOM_TYPE('d','v','p','p'); // DVCPRO PAL
-const AP4_Atom::Type AP4_ATOM_TYPE_DV5N = AP4_ATOM_TYPE('d','v','5','n'); // DVCPRO50 NTSC
-const AP4_Atom::Type AP4_ATOM_TYPE_DV5P = AP4_ATOM_TYPE('d','v','5','p'); // DVCPRO50 PAL
-// DVCPRO HD
-const AP4_Atom::Type AP4_ATOM_TYPE_DVHQ = AP4_ATOM_TYPE('d','v','h','q');
-const AP4_Atom::Type AP4_ATOM_TYPE_DVH5 = AP4_ATOM_TYPE('d','v','h','5');
-// Apple ProRes
-const AP4_Atom::Type AP4_ATOM_TYPE_APCN = AP4_ATOM_TYPE('a','p','c','n'); // Standard Definition
-const AP4_Atom::Type AP4_ATOM_TYPE_APCH = AP4_ATOM_TYPE('a','p','c','h'); // High Quality
-const AP4_Atom::Type AP4_ATOM_TYPE_APCO = AP4_ATOM_TYPE('a','p','c','o'); // Proxy
-const AP4_Atom::Type AP4_ATOM_TYPE_APCS = AP4_ATOM_TYPE('a','p','c','s'); // LT
-/*----------------------------------------------------------------------
-| AP4_AtomListInspector
-+---------------------------------------------------------------------*/
-class AP4_AtomListInspector : public AP4_List<AP4_Atom>::Item::Operator
-{
- public:
- AP4_AtomListInspector(AP4_AtomInspector& inspector) :
- m_Inspector(inspector) {}
- AP4_Result Action(AP4_Atom* atom) const {
- atom->Inspect(m_Inspector);
- return AP4_SUCCESS;
- }
-
- private:
- AP4_AtomInspector& m_Inspector;
-};
-
-/*----------------------------------------------------------------------
-| AP4_AtomListWriter
-+---------------------------------------------------------------------*/
-class AP4_AtomListWriter : public AP4_List<AP4_Atom>::Item::Operator
-{
- public:
- AP4_AtomListWriter(AP4_ByteStream& stream) :
- m_Stream(stream) {}
- AP4_Result Action(AP4_Atom* atom) const {
- atom->Write(m_Stream);
- return AP4_SUCCESS;
- }
-
- private:
- AP4_ByteStream& m_Stream;
-};
-
-/*----------------------------------------------------------------------
-| AP4_AtomFinder
-+---------------------------------------------------------------------*/
-class AP4_AtomFinder : public AP4_List<AP4_Atom>::Item::Finder
-{
- public:
- AP4_AtomFinder(AP4_Atom::Type type, AP4_Ordinal index = 0) :
- m_Type(type), m_Index(index) {}
- AP4_Result Test(AP4_Atom* atom) const {
- if (atom->GetType() == m_Type) {
- if (m_Index-- == 0) {
- return AP4_SUCCESS;
- } else {
- return AP4_FAILURE;
- }
- } else {
- return AP4_FAILURE;
- }
- }
- private:
- AP4_Atom::Type m_Type;
- mutable AP4_Ordinal m_Index;
-};
-
-/*----------------------------------------------------------------------
-| AP4_AtomSizeAdder
-+---------------------------------------------------------------------*/
-class AP4_AtomSizeAdder : public AP4_List<AP4_Atom>::Item::Operator {
-public:
- AP4_AtomSizeAdder(AP4_Size& size) : m_Size(size) {}
-
-private:
- AP4_Result Action(AP4_Atom* atom) const {
- m_Size += atom->GetSize();
- return AP4_SUCCESS;
- }
- AP4_Size& m_Size;
-};
-
-#endif // _AP4_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4AtomFactory.cpp b/src/thirdparty/Bento4/Core/Ap4AtomFactory.cpp
deleted file mode 100644
index 941869702..000000000
--- a/src/thirdparty/Bento4/Core/Ap4AtomFactory.cpp
+++ /dev/null
@@ -1,542 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Atom Factory
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4SampleEntry.h"
-#include "Ap4IsmaCryp.h"
-#include "Ap4UrlAtom.h"
-#include "Ap4MoovAtom.h"
-#include "Ap4MvhdAtom.h"
-#include "Ap4TrakAtom.h"
-#include "Ap4HdlrAtom.h"
-#include "Ap4DrefAtom.h"
-#include "Ap4TkhdAtom.h"
-#include "Ap4MdhdAtom.h"
-#include "Ap4StsdAtom.h"
-#include "Ap4StscAtom.h"
-#include "Ap4StcoAtom.h"
-#include "Ap4Co64Atom.h"
-#include "Ap4StszAtom.h"
-#include "Ap4EsdsAtom.h"
-#include "Ap4SttsAtom.h"
-#include "Ap4CttsAtom.h"
-#include "Ap4StssAtom.h"
-#include "Ap4FtypAtom.h"
-#include "Ap4VmhdAtom.h"
-#include "Ap4SmhdAtom.h"
-#include "Ap4NmhdAtom.h"
-#include "Ap4HmhdAtom.h"
-#include "Ap4SchmAtom.h"
-#include "Ap4FrmaAtom.h"
-#include "Ap4TimsAtom.h"
-#include "Ap4RtpAtom.h"
-#include "Ap4SdpAtom.h"
-#include "Ap4IkmsAtom.h"
-#include "Ap4IsfmAtom.h"
-#include "Ap4TrefTypeAtom.h"
-#include "Ap4AvcCAtom.h"
-#include "Ap4FtabAtom.h"
-#include "Ap4ChplAtom.h"
-#include "Ap4DataAtom.h"
-#include "Ap4DcomAtom.h"
-#include "Ap4CmvdAtom.h"
-#include "Ap4EndaAtom.h"
-#include "Ap4PaspAtom.h"
-/*----------------------------------------------------------------------
-| class variables
-+---------------------------------------------------------------------*/
-AP4_AtomFactory AP4_AtomFactory::DefaultFactory;
-
-/*----------------------------------------------------------------------
-| AP4_AtomFactory::AddTypeHandler
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_AtomFactory::AddTypeHandler(TypeHandler* handler)
-{
- return m_TypeHandlers.Add(handler);
-}
-
-/*----------------------------------------------------------------------
-| AP4_AtomFactory::RemoveTypeHandler
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_AtomFactory::RemoveTypeHandler(TypeHandler* handler)
-{
- return m_TypeHandlers.Remove(handler);
-}
-
-/*----------------------------------------------------------------------
-| AP4_AtomFactory::CreateAtomFromStream
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream& stream,
- AP4_Atom*& atom)
-{
- AP4_Size bytes_available = 0;
- if (AP4_FAILED(stream.GetSize(bytes_available)) ||
- bytes_available == 0) {
- bytes_available = (AP4_Size)((unsigned long)(-1));
- }
- return CreateAtomFromStream(stream, bytes_available, atom, NULL);
-}
-
-/*----------------------------------------------------------------------
-| AP4_AtomFactory::CreateAtomFromStream
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream& stream,
- AP4_Size& bytes_available,
- AP4_Atom*& atom,
- AP4_Atom* parent)
-{
- AP4_Result result;
-
-
- // NULL by default
- atom = NULL;
-
- // check that there are enough bytes for at least a header
- if (bytes_available < 8) return AP4_ERROR_EOS;
-
- // remember current stream offset
- AP4_Offset start;
- stream.Tell(start);
-
- // read atom size
-
- AP4_UI64 size = 0;
- result = stream.ReadUI32((AP4_UI32&)size);
- if (AP4_FAILED(result)) {
- stream.Seek(start);
- return result;
- }
-
- if (size == 0) {
- // atom extends to end of file
- AP4_Size streamSize = 0;
- stream.GetSize(streamSize);
- if (streamSize >= start) {
- size = streamSize - start;
- }
- }
-
- // check the size (we don't handle extended size yet)
- if (size != 1 && size < 8 || size > bytes_available) {
- stream.Seek(start);
- return AP4_ERROR_INVALID_FORMAT;
- }
-
- // read atom type
- AP4_Atom::Type type;
- result = stream.ReadUI32(type);
- if (AP4_FAILED(result)) {
- stream.Seek(start);
- return result;
- }
-
- if (size == 1)
- {
- AP4_UI64 size_high;
-
- result = stream.ReadUI64(size_high);
- if (AP4_FAILED(result) ) {
- stream.Seek(start);
- return AP4_ERROR_INVALID_FORMAT;
- }
- size = size_high;
- }
-
- // create the atom
- switch (type) {
- case AP4_ATOM_TYPE_MOOV:
- atom = new AP4_MoovAtom(size, stream, *this);
- break;
-
- case AP4_ATOM_TYPE_MVHD:
- atom = new AP4_MvhdAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_TRAK:
- atom = new AP4_TrakAtom(size, stream, *this);
- break;
-
- case AP4_ATOM_TYPE_HDLR:
- atom = new AP4_HdlrAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_DREF:
- atom = new AP4_DrefAtom(size, stream, *this);
- break;
-
- case AP4_ATOM_TYPE_URL:
- atom = new AP4_UrlAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_TKHD:
- atom = new AP4_TkhdAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_MDHD:
- atom = new AP4_MdhdAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_STSD:
- atom = new AP4_StsdAtom(size, stream, *this);
- break;
-
- case AP4_ATOM_TYPE_STSC:
- atom = new AP4_StscAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_STCO:
- atom = new AP4_StcoAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_CO64:
- atom = new AP4_Co64Atom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_STSZ:
- atom = new AP4_StszAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_STTS:
- atom = new AP4_SttsAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_CTTS:
- atom = new AP4_CttsAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_STSS:
- atom = new AP4_StssAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_MP4S:
- atom = new AP4_Mp4sSampleEntry(size, stream, *this);
- break;
-
- case AP4_ATOM_TYPE_MP4A:
- atom = parent && parent->GetType() == AP4_ATOM_TYPE_STSD
- ? (AP4_Atom*)new AP4_Mp4aSampleEntry(size, stream, *this)
- : (AP4_Atom*)new AP4_UnknownAtom(type, size, false, stream);
- break;
-
- case AP4_ATOM_TYPE_MP4V:
- atom = new AP4_Mp4vSampleEntry(size, stream, *this);
- break;
-
- case AP4_ATOM_TYPE_AVC1:
- atom = new AP4_Avc1SampleEntry(size, stream, *this);
- break;
-
- case AP4_ATOM_TYPE_ENCA:
- atom = new AP4_EncaSampleEntry(size, stream, *this);
- break;
-
- case AP4_ATOM_TYPE_ENCV:
- atom = new AP4_EncvSampleEntry(size, stream, *this);
- break;
-
- case AP4_ATOM_TYPE_ESDS:
- atom = new AP4_EsdsAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_VMHD:
- atom = new AP4_VmhdAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_SMHD:
- atom = new AP4_SmhdAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_NMHD:
- atom = new AP4_NmhdAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_HMHD:
- atom = new AP4_HmhdAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_FRMA:
- atom = new AP4_FrmaAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_SCHM:
- atom = new AP4_SchmAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_FTYP:
- atom = new AP4_FtypAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_RTP:
- if (m_Context == AP4_ATOM_TYPE_HNTI) {
- atom = new AP4_RtpAtom(size, stream);
- } else {
- atom = new AP4_RtpHintSampleEntry(size, stream, *this);
- }
- break;
-
- case AP4_ATOM_TYPE_TIMS:
- atom = new AP4_TimsAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_SDP:
- atom = new AP4_SdpAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_IKMS:
- atom = new AP4_IkmsAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_ISFM:
- atom = new AP4_IsfmAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_HINT:
- atom = new AP4_TrefTypeAtom(type, size, stream);
- break;
-
- // container atoms
- case AP4_ATOM_TYPE_TREF:
- case AP4_ATOM_TYPE_HNTI:
- case AP4_ATOM_TYPE_STBL:
- case AP4_ATOM_TYPE_MDIA:
- case AP4_ATOM_TYPE_DINF:
- case AP4_ATOM_TYPE_MINF:
- case AP4_ATOM_TYPE_SCHI:
- case AP4_ATOM_TYPE_SINF:
- case AP4_ATOM_TYPE_UDTA:
- case AP4_ATOM_TYPE_ILST:
- case AP4_ATOM_TYPE_NAM:
- case AP4_ATOM_TYPE_ART:
- case AP4_ATOM_TYPE_WRT:
- case AP4_ATOM_TYPE_ALB:
- case AP4_ATOM_TYPE_DAY:
- case AP4_ATOM_TYPE_TOO:
- case AP4_ATOM_TYPE_CMT:
- case AP4_ATOM_TYPE_GEN:
- case AP4_ATOM_TYPE_TRKN:
- case AP4_ATOM_TYPE_EDTS:
- case AP4_ATOM_TYPE_WAVE:
- case AP4_ATOM_TYPE_CMOV: {
- AP4_UI32 context = m_Context;
- m_Context = type; // set the context for the children
- atom = new AP4_ContainerAtom(type, size, false, stream, *this);
- m_Context = context; // restore the previous context
- break;
- }
-
- // full container atoms
- case AP4_ATOM_TYPE_META:
- atom = new AP4_ContainerAtom(type, size, true, stream, *this);
- break;
-
- // other
- case AP4_ATOM_TYPE_AVCC:
- atom = new AP4_AvcCAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_TEXT:
- atom = new AP4_TextSampleEntry(size, stream, *this);
- break;
-
- case AP4_ATOM_TYPE_TX3G:
- atom = new AP4_Tx3gSampleEntry(size, stream, *this);
- break;
-
- case AP4_ATOM_TYPE_FTAB:
- atom = new AP4_FtabAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_RAW:
- {
- AP4_Offset pos;
- AP4_UI16 ch_count_test;
-
- stream.Tell(pos);
- stream.Seek(pos + 16);
- stream.ReadUI16(ch_count_test);
- stream.Seek(pos);
-
- if (ch_count_test == 0) {
- atom = new AP4_VisualSampleEntry(type, size, stream, *this);
- } else {
- atom = new AP4_AudioSampleEntry(type, size, stream, *this);
- }
- }
- break;
-
- case AP4_ATOM_TYPE_CVID:
- case AP4_ATOM_TYPE_SVQ1:
- case AP4_ATOM_TYPE_SVQ2:
- case AP4_ATOM_TYPE_SVQ3:
- case AP4_ATOM_TYPE_H261:
- case AP4_ATOM_TYPE_H263:
- case AP4_ATOM_TYPE_S263:
- case AP4_ATOM_TYPE_JPEG:
- case AP4_ATOM_TYPE_PNG:
- case AP4_ATOM_TYPE_RLE:
- case AP4_ATOM_TYPE_MJPA:
- case AP4_ATOM_TYPE_MJPB:
- case AP4_ATOM_TYPE_RPZA:
- case AP4_ATOM_TYPE_DIV3:
- case AP4_ATOM_TYPE_DIVX:
- case AP4_ATOM_TYPE_8BPS:
- case AP4_ATOM_TYPE_3IV1:
- case AP4_ATOM_TYPE_3IV2:
- case AP4_ATOM_TYPE_IV32:
- case AP4_ATOM_TYPE_IV41:
- case AP4_ATOM_TYPE_VP31:
- case AP4_ATOM_TYPE_YV12:
- case AP4_ATOM_TYPE_APCN:
- case AP4_ATOM_TYPE_APCH:
- case AP4_ATOM_TYPE_APCO:
- case AP4_ATOM_TYPE_APCS:
- atom = new AP4_VisualSampleEntry(type, size, stream, *this);
- break;
-
- // DV Video Subtypes - http://msdn.microsoft.com/en-us/library/windows/desktop/dd388646%28v=vs.85%29.aspx
- case AP4_ATOM_TYPE_DVC:
- case AP4_ATOM_TYPE_DVCP:
- atom = new AP4_VisualSampleEntry(AP4_ATOM_TYPE('d','v','s','d'), size, stream, *this); // MEDIASUBTYPE_dvsd (DV Video Decoder, ffdshow, LAV)
- break;
- case AP4_ATOM_TYPE_DVPP:
- atom = new AP4_VisualSampleEntry(AP4_ATOM_TYPE('d','v','2','5'), size, stream, *this); // MEDIASUBTYPE_dv25 (ffdshow, LAV)
- break;
- case AP4_ATOM_TYPE_DV5N:
- case AP4_ATOM_TYPE_DV5P:
- atom = new AP4_VisualSampleEntry(AP4_ATOM_TYPE('d','v','5','0'), size, stream, *this); // MEDIASUBTYPE_dv50 (ffdshow, LAV)
- break;
- case AP4_ATOM_TYPE_DVHQ:
- case AP4_ATOM_TYPE_DVH5:
- atom = new AP4_VisualSampleEntry(AP4_ATOM_TYPE('C','D','V','H'), size, stream, *this); // MEDIASUBTYPE_CDVH (LAV)
- break;
-
- case AP4_ATOM_TYPE_MJPG:
- case AP4_ATOM_TYPE_AVDJ: // uncommon fourcc
- case AP4_ATOM_TYPE_DMB1: // uncommon fourcc
- atom = new AP4_VisualSampleEntry(AP4_ATOM_TYPE_MJPG, size, stream, *this);
- break;
-
- case AP4_ATOM_TYPE_2VUY: // = 'UYVY'
- atom = new AP4_VisualSampleEntry(AP4_ATOM_TYPE('U','Y','V','Y'), size, stream, *this);
- break;
-
- case AP4_ATOM_TYPE_SAMR:
- case AP4_ATOM_TYPE__MP3:
- case AP4_ATOM_TYPE_IMA4:
- case AP4_ATOM_TYPE_QDMC:
- case AP4_ATOM_TYPE_QDM2:
- case AP4_ATOM_TYPE_NONE:
- case AP4_ATOM_TYPE_TWOS:
- case AP4_ATOM_TYPE_SOWT:
- case AP4_ATOM_TYPE_IN24:
- case AP4_ATOM_TYPE_IN32:
- case AP4_ATOM_TYPE_FL32:
- case AP4_ATOM_TYPE_FL64:
- case AP4_ATOM_TYPE_LPCM:
- case AP4_ATOM_TYPE_ALAW:
- case AP4_ATOM_TYPE_ULAW:
- case AP4_ATOM_TYPE_NMOS:
- case AP4_ATOM_TYPE_ALAC:
- case AP4_ATOM_TYPE_MAC3:
- case AP4_ATOM_TYPE_MAC6:
- atom = new AP4_AudioSampleEntry(type, size, stream, *this);
- break;
-
- case AP4_ATOM_TYPE__AC3: // AC3-in-MP4 from ISO Standard
- case AP4_ATOM_TYPE_SAC3: // AC3-in-MP4 from Nero Stuff >.<
- atom = new AP4_AC3SampleEntry(size, stream, *this);
- break;
- case AP4_ATOM_TYPE_EAC3:
- atom = new AP4_EAC3SampleEntry(size, stream, *this);
- break;
-
- case AP4_ATOM_TYPE_CHPL:
- atom = new AP4_ChplAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_DATA:
- atom = new AP4_DataAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_DCOM:
- atom = new AP4_DcomAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_CMVD:
- atom = new AP4_CmvdAtom(size, stream, *this);
- break;
-
- case AP4_ATOM_TYPE_ENDA:
- atom = new AP4_EndaAtom(size, stream);
- break;
-
- case AP4_ATOM_TYPE_PASP:
- atom = new AP4_PaspAtom(size, stream);
- break;
-
- default:
- if(parent && parent->GetType() == AP4_ATOM_TYPE_STSD && (type & 0xffff0000) == AP4_ATOM_TYPE('m', 's', 0, 0)) {
- atom = new AP4_AudioSampleEntry(type, size, stream, *this);
- } else {// try all the external type handlers
- atom = NULL;
- AP4_List<TypeHandler>::Item* handler_item = m_TypeHandlers.FirstItem();
- while (handler_item) {
- TypeHandler* handler = handler_item->GetData();
- if (AP4_SUCCEEDED(handler->CreateAtom(type, size, stream, atom))) {
- break;
- }
- handler_item = handler_item->GetNext();
- }
- if (atom == NULL) {
- // no custom handlers, create a generic atom
- atom = new AP4_UnknownAtom(type, size, false, stream);
- }
- }
-
- break;
- }
-
- // skip to the end of the atom
- bytes_available -= size;
- result = stream.Seek(start+size);
- if (AP4_FAILED(result)) {
- delete atom;
- atom = NULL;
- }
-
- return result;
-}
-
diff --git a/src/thirdparty/Bento4/Core/Ap4AtomFactory.h b/src/thirdparty/Bento4/Core/Ap4AtomFactory.h
deleted file mode 100644
index 1eafe31b0..000000000
--- a/src/thirdparty/Bento4/Core/Ap4AtomFactory.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Atom Factory
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_ATOM_FACTORY_H_
-#define _AP4_ATOM_FACTORY_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4Types.h"
-#include "Ap4Atom.h"
-
-/*----------------------------------------------------------------------
-| class references
-+---------------------------------------------------------------------*/
-class AP4_ByteStream;
-
-/*----------------------------------------------------------------------
-| AP4_AtomFactory
-+---------------------------------------------------------------------*/
-class AP4_AtomFactory {
- public:
- // types
- class TypeHandler {
- public:
- virtual ~TypeHandler() {};
- virtual AP4_Result CreateAtom(AP4_Atom::Type type,
- AP4_Size size,
- AP4_ByteStream& stream,
- AP4_Atom*& atom) = 0;
- };
-
- // class members
- static AP4_AtomFactory DefaultFactory;
-
- // constructor
- AP4_AtomFactory() : m_Context(0) {}
-
- // methods
- AP4_Result AddTypeHandler(TypeHandler* handler);
- AP4_Result RemoveTypeHandler(TypeHandler* handler);
- AP4_Result CreateAtomFromStream(AP4_ByteStream& stream,
- AP4_Size& bytes_available,
- AP4_Atom*& atom,
- AP4_Atom* parent);
- AP4_Result CreateAtomFromStream(AP4_ByteStream& stream,
- AP4_Atom*& atom);
-
- // context
- void SetContext(AP4_Atom::Type context) { m_Context = context; }
- AP4_Atom::Type GetContext() const { return m_Context; }
-
-private:
- // members
- AP4_Atom::Type m_Context;
- AP4_List<TypeHandler> m_TypeHandlers;
-};
-
-#endif // _AP4_ATOM_FACTORY_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4AtomSampleTable.cpp b/src/thirdparty/Bento4/Core/Ap4AtomSampleTable.cpp
deleted file mode 100644
index 225d29958..000000000
--- a/src/thirdparty/Bento4/Core/Ap4AtomSampleTable.cpp
+++ /dev/null
@@ -1,272 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Atom Based Sample Tables
-|
-| Copyright 2003 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This atom is part of AP4 (MP4 Audio Proatom Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the atom COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4AtomSampleTable.h"
-#include "Ap4ByteStream.h"
-#include "Ap4StsdAtom.h"
-#include "Ap4StscAtom.h"
-#include "Ap4StcoAtom.h"
-#include "Ap4Co64Atom.h"
-#include "Ap4StszAtom.h"
-#include "Ap4SttsAtom.h"
-#include "Ap4CttsAtom.h"
-#include "Ap4StssAtom.h"
-#include "Ap4Sample.h"
-#include "Ap4SampleEntry.h"
-#include "Ap4Atom.h"
-
-/*----------------------------------------------------------------------
-| AP4_AtomSampleTable::AP4_AtomSampleTable
-+---------------------------------------------------------------------*/
-AP4_AtomSampleTable::AP4_AtomSampleTable(AP4_ContainerAtom* stbl,
- AP4_ByteStream& sample_stream) :
- m_SampleStream(sample_stream)
-{
- m_StscAtom = dynamic_cast<AP4_StscAtom*>(stbl->GetChild(AP4_ATOM_TYPE_STSC));
- m_StcoAtom = dynamic_cast<AP4_StcoAtom*>(stbl->GetChild(AP4_ATOM_TYPE_STCO));
- m_Co64Atom = dynamic_cast<AP4_Co64Atom*>(stbl->GetChild(AP4_ATOM_TYPE_CO64));
- m_StszAtom = dynamic_cast<AP4_StszAtom*>(stbl->GetChild(AP4_ATOM_TYPE_STSZ));
- m_CttsAtom = dynamic_cast<AP4_CttsAtom*>(stbl->GetChild(AP4_ATOM_TYPE_CTTS));
- m_SttsAtom = dynamic_cast<AP4_SttsAtom*>(stbl->GetChild(AP4_ATOM_TYPE_STTS));
- m_StssAtom = dynamic_cast<AP4_StssAtom*>(stbl->GetChild(AP4_ATOM_TYPE_STSS));
- m_StsdAtom = dynamic_cast<AP4_StsdAtom*>(stbl->GetChild(AP4_ATOM_TYPE_STSD));
-
- // keep a reference to the sample stream
- m_SampleStream.AddReference();
-
- if(m_StsdAtom && m_StszAtom && m_StscAtom && m_SttsAtom
- && m_StszAtom->m_SampleSize == 1)
- {
- // fix mov files
- for(AP4_List<AP4_Atom>::Item* item = m_StsdAtom->GetChildren().FirstItem();
- item;
- item = item->GetNext())
- {
- AP4_Atom* atom = item->GetData();
-
- if(AP4_AudioSampleEntry* ase = dynamic_cast<AP4_AudioSampleEntry*>(atom))
- {
- AP4_UI32 SamplesPerPacket = ase->GetSamplesPerPacket();
- AP4_UI32 BytesPerFrame = ase->GetBytesPerFrame();
-
- if(SamplesPerPacket > 0 && BytesPerFrame > 0)
- {
- for(int i = 0, j = m_StscAtom->m_Entries.ItemCount(); i < j; i++)
- {
- AP4_StscTableEntry& e = m_StscAtom->m_Entries[i];
- AP4_ASSERT(e.m_SamplesPerChunk % SamplesPerPacket == 0);
- e.m_SamplesPerChunk = e.m_SamplesPerChunk / SamplesPerPacket;
- e.m_FirstSample = (e.m_FirstSample-1) / SamplesPerPacket + 1;
- }
-
- AP4_ASSERT(m_StszAtom->m_SampleCount % SamplesPerPacket == 0);
- m_StszAtom->m_SampleCount = m_StszAtom->m_SampleCount / SamplesPerPacket;
- m_StszAtom->m_SampleSize = BytesPerFrame;
-
- AP4_ASSERT(m_SttsAtom->m_Entries.ItemCount() == 1);
- m_SttsAtom->m_Entries[0].m_SampleCount = m_StszAtom->m_SampleCount;
- m_SttsAtom->m_Entries[0].m_SampleDuration = SamplesPerPacket;
- }
- }
- }
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_AtomSampleTable::~AP4_AtomSampleTable
-+---------------------------------------------------------------------*/
-AP4_AtomSampleTable::~AP4_AtomSampleTable()
-{
- m_SampleStream.Release();
-}
-
-/*----------------------------------------------------------------------
-| AP4_AtomSampleTable::GetSample
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_AtomSampleTable::GetSample(AP4_Ordinal index,
- AP4_Sample& sample)
-{
- AP4_Result result;
-
- // check that we have a chunk offset table
- if (m_StcoAtom == NULL && m_Co64Atom == NULL) {
- return AP4_ERROR_INVALID_FORMAT;
- }
-
- // MP4 uses 1-based indexes internally, so adjust by one
- index++;
-
- // find out in which chunk this sample is located
- AP4_Ordinal chunk, skip, desc;
- result = m_StscAtom->GetChunkForSample(index, chunk, skip, desc);
- if (AP4_FAILED(result)) return result;
-
- // check that the result is within bounds
- if (skip > index) return AP4_ERROR_INTERNAL;
-
- // get the atom offset for this chunk
- AP4_Offset offset = 0;
- if (m_StcoAtom) result = m_StcoAtom->GetChunkOffset(chunk, offset);
- else if (m_Co64Atom) result = m_Co64Atom->GetChunkOffset(chunk, offset);
- else result = AP4_ERROR_INTERNAL;
- if (AP4_FAILED(result)) return result;
-/*
- // compute the additional offset inside the chunk
- for (unsigned int i = index-skip; i < index; i++) {
- AP4_Size size;
- result = m_StszAtom->GetSampleSize(i, size);
- if (AP4_FAILED(result)) return result;
- offset += size;
- }
-*/
- AP4_Size size;
- result = m_StszAtom->GetSampleSize(index - skip, index, size);
- if (AP4_FAILED(result)) return result;
- offset += size;
-
- // set the description index
- sample.SetDescriptionIndex(desc-1); // adjust for 0-based indexes
-
- // set the dts and cts
- AP4_TimeStamp dts;
- AP4_Duration duration;
- result = m_SttsAtom->GetDts(index, dts, duration);
- if (AP4_FAILED(result)) return result;
- sample.SetDts(dts);
- sample.SetDuration(duration);
- if (m_CttsAtom == NULL) {
- sample.SetCts(dts);
- } else {
- AP4_UI32 cts_offset;
- result = m_CttsAtom->GetCtsOffset(index, cts_offset);
- if (AP4_FAILED(result)) return result;
- sample.SetCts(dts + *((signed long*)&cts_offset)); // HACK: it shouldn't be signed, but such files exist unfortunatelly
- }
-
- // set the size
- AP4_Size sample_size;
- result = m_StszAtom->GetSampleSize(index, sample_size);
- if (AP4_FAILED(result)) return result;
- sample.SetSize(sample_size);
-
- // set the offset
- sample.SetOffset(offset);
-
- // set the data stream
- sample.SetDataStream(m_SampleStream);
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_AtomSampleTable::GetSampleCount
-+---------------------------------------------------------------------*/
-AP4_Cardinal
-AP4_AtomSampleTable::GetSampleCount()
-{
- return m_StszAtom ? m_StszAtom->GetSampleCount() : 0;
-}
-
-/*----------------------------------------------------------------------
-| AP4_AtomSampleTable::GetSampleDescription
-+---------------------------------------------------------------------*/
-AP4_SampleDescription*
-AP4_AtomSampleTable::GetSampleDescription(AP4_Ordinal index)
-{
- return m_StsdAtom ? m_StsdAtom->GetSampleDescription(index) : NULL;
-}
-
-/*----------------------------------------------------------------------
-| AP4_AtomSampleTable::GetSampleDescriptionCount
-+---------------------------------------------------------------------*/
-AP4_Cardinal
-AP4_AtomSampleTable::GetSampleDescriptionCount()
-{
- return m_StsdAtom ? m_StsdAtom->GetSampleDescriptionCount() : 0;
-}
-
-/*----------------------------------------------------------------------
-| AP4_AtomSampleTable::GetChunkForSample
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_AtomSampleTable::GetChunkForSample(AP4_Ordinal sample,
- AP4_Ordinal& chunk,
- AP4_Ordinal& skip,
- AP4_Ordinal& sample_description)
-{
- return m_StscAtom ? m_StscAtom->GetChunkForSample(sample, chunk, skip, sample_description) : AP4_FAILURE;
-}
-
-/*----------------------------------------------------------------------
-| AP4_AtomSampleTable::GetChunkOffset
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_AtomSampleTable::GetChunkOffset(AP4_Ordinal chunk, AP4_Offset& offset)
-{
- return
- m_StcoAtom ? m_StcoAtom->GetChunkOffset(chunk, offset) :
- m_Co64Atom ? m_Co64Atom->GetChunkOffset(chunk, offset) :
- AP4_FAILURE;
-}
-
-/*----------------------------------------------------------------------
-| AP4_AtomSampleTable::SetChunkOffset
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_AtomSampleTable::SetChunkOffset(AP4_Ordinal chunk, AP4_Offset offset)
-{
- return
- m_StcoAtom ? m_StcoAtom->SetChunkOffset(chunk, offset) :
- m_Co64Atom ? m_Co64Atom->SetChunkOffset(chunk, offset) :
- AP4_FAILURE;
-}
-
-/*----------------------------------------------------------------------
-| AP4_AtomSampleTable::SetSampleSize
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_AtomSampleTable::SetSampleSize(AP4_Ordinal sample, AP4_Size size)
-{
- return m_StszAtom ? m_StszAtom->SetSampleSize(sample, size) : AP4_FAILURE;
-}
-
-/*----------------------------------------------------------------------
-| AP4_AtomSampleTable::GetSample
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_AtomSampleTable::GetSampleIndexForTimeStamp(AP4_TimeStamp ts,
- AP4_Ordinal& index)
-{
- return m_SttsAtom ? m_SttsAtom->GetSampleIndexForTimeStamp(ts, index)
- : AP4_FAILURE;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4AtomSampleTable.h b/src/thirdparty/Bento4/Core/Ap4AtomSampleTable.h
deleted file mode 100644
index 5f9e0b868..000000000
--- a/src/thirdparty/Bento4/Core/Ap4AtomSampleTable.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Atom Based Sample Table
-|
-| Copyright 2003 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This atom is part of AP4 (MP4 Audio Proatom Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the atom COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_ATOM_SAMPLE_TABLE_H_
-#define _AP4_ATOM_SAMPLE_TABLE_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4Types.h"
-#include "Ap4SampleTable.h"
-
-/*----------------------------------------------------------------------
-| forward declarations
-+---------------------------------------------------------------------*/
-class AP4_Atom;
-class AP4_ByteStream;
-class AP4_StscAtom;
-class AP4_StcoAtom;
-class AP4_Co64Atom;
-class AP4_StszAtom;
-class AP4_SttsAtom;
-class AP4_CttsAtom;
-class AP4_StssAtom;
-class AP4_StsdAtom;
-
-/*----------------------------------------------------------------------
-| AP4_AtomSampleTable
-+---------------------------------------------------------------------*/
-class AP4_AtomSampleTable : public AP4_SampleTable
-{
- public:
- // methods
- AP4_AtomSampleTable(AP4_ContainerAtom* stbl_atom,
- AP4_ByteStream& sample_stream);
- virtual ~AP4_AtomSampleTable();
-
- // AP4_SampleTable methods
- virtual AP4_Result GetSample(AP4_Ordinal index, AP4_Sample& sample);
- virtual AP4_Cardinal GetSampleCount();
- virtual AP4_SampleDescription* GetSampleDescription(AP4_Ordinal index);
- virtual AP4_Cardinal GetSampleDescriptionCount();
- virtual AP4_Result GetChunkForSample(AP4_Ordinal sample,
- AP4_Ordinal& chunk,
- AP4_Ordinal& skip,
- AP4_Ordinal& sample_description);
- virtual AP4_Result GetChunkOffset(AP4_Ordinal chunk, AP4_Offset& offset);
- virtual AP4_Result SetChunkOffset(AP4_Ordinal chunk, AP4_Offset offset);
- virtual AP4_Result SetSampleSize(AP4_Ordinal sample, AP4_Size size);
- virtual AP4_Result GetSampleIndexForTimeStamp(AP4_TimeStamp ts,
- AP4_Ordinal& index);
-
-private:
- // members
- AP4_ByteStream& m_SampleStream;
- AP4_StscAtom* m_StscAtom;
- AP4_StcoAtom* m_StcoAtom;
- AP4_Co64Atom* m_Co64Atom;
- AP4_StszAtom* m_StszAtom;
- AP4_SttsAtom* m_SttsAtom;
- AP4_CttsAtom* m_CttsAtom;
- AP4_StsdAtom* m_StsdAtom;
- AP4_StssAtom* m_StssAtom;
-};
-
-#endif // _AP4_ATOM_SAMPLE_TABLE_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4AvcCAtom.cpp b/src/thirdparty/Bento4/Core/Ap4AvcCAtom.cpp
deleted file mode 100644
index 15ee90273..000000000
--- a/src/thirdparty/Bento4/Core/Ap4AvcCAtom.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*****************************************************************
-|
-| AP4 - avcC Atom
-|
-| Copyright 2002 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-
-#include "Ap4.h"
-#include "Ap4AvcCAtom.h"
-
-/*----------------------------------------------------------------------
-| AP4_AvcCAtom::AP4_AvcCAtom
-+---------------------------------------------------------------------*/
-
-AP4_AvcCAtom::AP4_AvcCAtom(AP4_Size size,
- AP4_ByteStream& stream)
- : AP4_Atom(AP4_ATOM_TYPE_AVCC)
-{
- size -= AP4_ATOM_HEADER_SIZE;
- m_DecoderInfo.SetDataSize(size);
- stream.Read(m_DecoderInfo.UseData(), size);
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4AvcCAtom.h b/src/thirdparty/Bento4/Core/Ap4AvcCAtom.h
deleted file mode 100644
index 9f419e473..000000000
--- a/src/thirdparty/Bento4/Core/Ap4AvcCAtom.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*****************************************************************
-|
-| AP4 - avcC Atom
-|
-| Copyright 2002 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_AVCC_ATOM_H_
-#define _AP4_AVCC_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4Atom.h"
-#include "Ap4Types.h"
-#include "Ap4Array.h"
-#include "Ap4DataBuffer.h"
-
-/*----------------------------------------------------------------------
-| AP4_AvcCAtom
-+---------------------------------------------------------------------*/
-class AP4_AvcCAtom : public AP4_Atom
-{
-public:
- AP4_AvcCAtom(AP4_Size size,
- AP4_ByteStream& stream);
-
- AP4_Result WriteFields(AP4_ByteStream& stream) { return AP4_FAILURE; }
-
- const AP4_DataBuffer* GetDecoderInfo() const { return &m_DecoderInfo; }
-
-private:
- AP4_DataBuffer m_DecoderInfo;
-};
-
-#endif // _AP4_AVCC_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4ByteStream.cpp b/src/thirdparty/Bento4/Core/Ap4ByteStream.cpp
deleted file mode 100644
index 654983543..000000000
--- a/src/thirdparty/Bento4/Core/Ap4ByteStream.cpp
+++ /dev/null
@@ -1,596 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Byte Stream support
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4Utils.h"
-#include "Ap4Debug.h"
-
-/*----------------------------------------------------------------------
-| constants
-+---------------------------------------------------------------------*/
-const int AP4_BYTE_STREAM_COPY_BUFFER_SIZE = 4096;
-
-/*----------------------------------------------------------------------
-| AP4_ByteStream::WriteString
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_ByteStream::WriteString(const char* buffer)
-{
- AP4_Size string_length = static_cast<AP4_Size>(strlen(buffer));
-
- // shortcut
- if ((buffer == NULL) || (string_length == 0)) return AP4_SUCCESS;
-
- // write the string
- return Write((const void*)buffer, string_length);
-}
-
-/*----------------------------------------------------------------------
-| AP4_ByteStream::WriteUI64
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_ByteStream::WriteUI64(AP4_UI64 value)
-{
- unsigned char buffer[8];
-
- // convert value to bytes
- AP4_BytesFromUInt64BE(buffer, value);
-
- // write bytes to the stream
- return Write((void*)buffer, 8);
-}
-
-/*----------------------------------------------------------------------
-| AP4_ByteStream::WriteUI32
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_ByteStream::WriteUI32(AP4_UI32 value)
-{
- unsigned char buffer[4];
-
- // convert value to bytes
- AP4_BytesFromUInt32BE(buffer, value);
-
- // write bytes to the stream
- return Write((void*)buffer, 4);
-}
-
-/*----------------------------------------------------------------------
-| AP4_ByteStream::WriteUI24
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_ByteStream::WriteUI24(AP4_UI32 value)
-{
- unsigned char buffer[3];
-
- // convert value to bytes
- AP4_BytesFromUInt24BE(buffer, value);
-
- // write bytes to the stream
- return Write((void*)buffer, 3);
-}
-
-/*----------------------------------------------------------------------
-| AP4_ByteStream::WriteUI16
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_ByteStream::WriteUI16(AP4_UI16 value)
-{
- unsigned char buffer[2];
-
- // convert value to bytes
- AP4_BytesFromUInt16BE(buffer, value);
-
- // write bytes to the stream
- return Write((void*)buffer, 2);
-}
-
-/*----------------------------------------------------------------------
-| AP4_ByteStream::WriteUI08
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_ByteStream::WriteUI08(AP4_UI08 value)
-{
- return Write((void*)&value, 1);
-}
-
-/*----------------------------------------------------------------------
-| AP4_ByteStream::ReadUI64
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_ByteStream::ReadUI64(AP4_UI64& value)
-{
- unsigned char buffer[8];
-
- // read bytes from the stream
- AP4_Result result;
- result = Read((void*)buffer, 8);
- if (AP4_FAILED(result)) {
- value = 0;
- return result;
- }
-
- // convert bytes to value
- value = AP4_BytesToUInt64BE(buffer);
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_ByteStream::ReadDouble
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_ByteStream::ReadDouble(double& value)
-{
- unsigned char buffer[8];
-
- // read bytes from the stream
- AP4_Result result;
- result = Read((void*)buffer, 8);
- if (AP4_FAILED(result)) {
- value = 0;
- return result;
- }
-
- // convert bytes to value
- value = AP4_BytesToDoubleBE(buffer);
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_ByteStream::ReadUI32
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_ByteStream::ReadUI32(AP4_UI32& value)
-{
- unsigned char buffer[4];
-
- // read bytes from the stream
- AP4_Result result;
- result = Read((void*)buffer, 4);
- if (AP4_FAILED(result)) {
- value = 0;
- return result;
- }
-
- // convert bytes to value
- value = AP4_BytesToUInt32BE(buffer);
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_ByteStream::ReadUI24
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_ByteStream::ReadUI24(AP4_UI32& value)
-{
- unsigned char buffer[3];
-
- // read bytes from the stream
- AP4_Result result;
- result = Read((void*)buffer, 3);
- if (AP4_FAILED(result)) {
- value = 0;
- return result;
- }
-
- // convert bytes to value
- value = AP4_BytesToUInt24BE(buffer);
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_ByteStream::ReadUI16
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_ByteStream::ReadUI16(AP4_UI16& value)
-{
- unsigned char buffer[2];
-
- // read bytes from the stream
- AP4_Result result;
- result = Read((void*)buffer, 2);
- if (AP4_FAILED(result)) {
- value = 0;
- return result;
- }
-
- // convert bytes to value
- value = AP4_BytesToUInt16BE(buffer);
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_ByteStream::ReadUI08
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_ByteStream::ReadUI08(AP4_UI08& value)
-{
- unsigned char buffer[1];
-
- // read bytes from the stream
- AP4_Result result;
- result = Read((void*)buffer, 1);
- if (AP4_FAILED(result)) {
- value = 0;
- return result;
- }
-
- // convert bytes to value
- value = buffer[0];
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_ByteStream::ReadString
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_ByteStream::ReadString(char* buffer, AP4_Size size)
-{
- if (buffer == NULL || size == 0) {
- return AP4_ERROR_INVALID_PARAMETERS;
- }
-
- AP4_Size bytes_read = 0;
- while (bytes_read < size-1) {
- AP4_Result result;
- result = Read(&buffer[bytes_read], 1, NULL);
- if (AP4_FAILED(result)) {
- buffer[bytes_read] = '\0';
- return result;
- }
- if (buffer[bytes_read] == '\0') {
- // end of string
- return AP4_SUCCESS;
- }
- bytes_read++;
- }
-
- // the string was not null terminated, terminate it
- buffer[size-1] = '\0';
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_ByteStream::CopyTo
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_ByteStream::CopyTo(AP4_ByteStream& stream, AP4_Size size)
-{
- unsigned char buffer[AP4_BYTE_STREAM_COPY_BUFFER_SIZE];
- while (size) {
- AP4_Size bytes_read;
- AP4_Size bytes_to_read;
- AP4_Result result;
-
- // decide how much to read
- if (size >= sizeof(buffer)) {
- bytes_to_read = sizeof(buffer);
- } else {
- bytes_to_read = size;
- }
-
- // read up to one buffer full
- result = Read(buffer, bytes_to_read, &bytes_read);
- if (AP4_FAILED(result)) return result;
-
- // copy to destination
- if (bytes_read != 0) {
- result = stream.Write(buffer, bytes_read);
- if (AP4_FAILED(result)) return result;
- }
-
- // update the size
- size -= bytes_read;
- }
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_SubStream::AP4_SubStream
-+---------------------------------------------------------------------*/
-AP4_SubStream::AP4_SubStream(AP4_ByteStream& container,
- AP4_Offset offset,
- AP4_Size size) :
- m_Container(container),
- m_Offset(offset),
- m_Size(size),
- m_Position(0),
- m_ReferenceCount(1)
-{
- m_Container.AddReference();
-}
-
-/*----------------------------------------------------------------------
-| AP4_SubStream::~AP4_SubStream
-+---------------------------------------------------------------------*/
-AP4_SubStream::~AP4_SubStream()
-{
- m_Container.Release();
-}
-
-/*----------------------------------------------------------------------
-| AP4_SubStream::Read
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SubStream::Read(void* buffer,
- AP4_Size bytes_to_read,
- AP4_Size* bytes_read)
-{
- // default values
- if (bytes_read) *bytes_read = 0;
-
- // shortcut
- if (bytes_to_read == 0) {
- return AP4_SUCCESS;
- }
-
- // clamp to range
- if (m_Position+bytes_to_read > m_Size) {
- bytes_to_read = m_Size - m_Position;
- }
-
- // check for end of substream
- if (bytes_to_read == 0) {
- return AP4_ERROR_EOS;
- }
-
- // seek inside container
- //AP4_Result result;
- //result = m_Container.Seek(m_Offset+m_Position);
- //if (AP4_FAILED(result)) {
- // return result;
- //}
-
- // read from the container
- AP4_Size local_bytes_read;
- AP4_Result result = m_Container.Read(buffer, bytes_to_read, &local_bytes_read);
- if (bytes_read) *bytes_read = local_bytes_read;
- if (AP4_SUCCEEDED(result)) {
- m_Position += local_bytes_read;
- }
- return result;
-}
-
-/*----------------------------------------------------------------------
-| AP4_SubStream::Write
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SubStream::Write(const void* buffer,
- AP4_Size bytes_to_write,
- AP4_Size* bytes_written)
-{
- // default values
- if (bytes_written) *bytes_written = 0;
-
- // shortcut
- if (bytes_to_write == 0) {
- return AP4_SUCCESS;
- }
-
- // clamp to range
- if (m_Position+bytes_to_write > m_Size) {
- bytes_to_write = m_Size - m_Position;
- }
-
- // check for en of substream
- if (bytes_to_write == 0) {
- return AP4_ERROR_EOS;
- }
-
- // seek inside container
- //AP4_Result result;
- //result = m_Container.Seek(m_Offset+m_Position);
- //if (AP4_FAILED(result)) return result;
-
- // write to container
- AP4_Size local_bytes_written;
- AP4_Result result = m_Container.Write(buffer, bytes_to_write, &local_bytes_written);
- if (bytes_written) *bytes_written = local_bytes_written;
- if (AP4_SUCCEEDED(result)) {
- m_Position += local_bytes_written;
- }
- return result;
-}
-
-/*----------------------------------------------------------------------
-| AP4_SubStream::Seek
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SubStream::Seek(AP4_Offset offset)
-{
- if (offset > m_Size) return AP4_FAILURE;
- AP4_Result result;
- result = m_Container.Seek(m_Offset+offset);
- if (AP4_SUCCEEDED(result)) {
- m_Position = offset;
- }
- return result;
-}
-
-/*----------------------------------------------------------------------
-| AP4_SubStream::AddReference
-+---------------------------------------------------------------------*/
-void
-AP4_SubStream::AddReference()
-{
- m_ReferenceCount++;
-}
-
-/*----------------------------------------------------------------------
-| AP4_SubStream::Release
-+---------------------------------------------------------------------*/
-void
-AP4_SubStream::Release()
-{
- if (--m_ReferenceCount == 0) {
- delete this;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_MemoryByteStream::AP4_MemoryByteStream
-+---------------------------------------------------------------------*/
-AP4_MemoryByteStream::AP4_MemoryByteStream(AP4_Size size) :
- m_BufferIsLocal(true),
- m_Size(size),
- m_Position(0),
- m_ReferenceCount(1)
-{
- m_Buffer = new AP4_UI08[size];
-}
-
-/*----------------------------------------------------------------------
-| AP4_MemoryByteStream::AP4_MemoryByteStream
-+---------------------------------------------------------------------*/
-AP4_MemoryByteStream::AP4_MemoryByteStream(AP4_UI08* buffer, AP4_Size size) :
- m_BufferIsLocal(false),
- m_Buffer(buffer),
- m_Size(size),
- m_Position(0),
- m_ReferenceCount(1)
-{}
-
-/*----------------------------------------------------------------------
-| AP4_MemoryByteStream::~AP4_MemoryByteStream
-+---------------------------------------------------------------------*/
-AP4_MemoryByteStream::~AP4_MemoryByteStream()
-{
- if (m_BufferIsLocal) delete[] m_Buffer;
-}
-
-/*----------------------------------------------------------------------
-| AP4_MemoryByteStream::Read
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_MemoryByteStream::Read(void* buffer,
- AP4_Size bytes_to_read,
- AP4_Size* bytes_read)
-{
- // default values
- if (bytes_read) *bytes_read = 0;
-
- // shortcut
- if (bytes_to_read == 0) {
- return AP4_SUCCESS;
- }
-
- // clamp to range
- if (m_Position+bytes_to_read > m_Size) {
- bytes_to_read = m_Size - m_Position;
- }
-
- // check for end of stream
- if (bytes_to_read == 0) {
- return AP4_ERROR_EOS;
- }
-
- // read from the memory
- memcpy(buffer, &m_Buffer[m_Position], bytes_to_read);
- m_Position += bytes_to_read;
-
- if (bytes_read) *bytes_read = bytes_to_read;
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_MemoryByteStream::Write
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_MemoryByteStream::Write(const void* buffer,
- AP4_Size bytes_to_write,
- AP4_Size* bytes_written)
-{
- // default values
- if (bytes_written) *bytes_written = 0;
-
- // shortcut
- if (bytes_to_write == 0) {
- return AP4_SUCCESS;
- }
-
- // clamp to range
- if (m_Position+bytes_to_write > m_Size) {
- bytes_to_write = m_Size - m_Position;
- }
-
- // check for en of stream
- if (bytes_to_write == 0) {
- return AP4_ERROR_EOS;
- }
-
- // write to memory
- memcpy(&m_Buffer[m_Position], buffer, bytes_to_write);
- m_Position += bytes_to_write;
-
- if (bytes_written) *bytes_written = bytes_to_write;
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_MemoryByteStream::Seek
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_MemoryByteStream::Seek(AP4_Offset offset)
-{
- if (offset > m_Size) return AP4_FAILURE;
- m_Position = offset;
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_MemoryByteStream::AddReference
-+---------------------------------------------------------------------*/
-void
-AP4_MemoryByteStream::AddReference()
-{
- m_ReferenceCount++;
-}
-
-/*----------------------------------------------------------------------
-| AP4_MemoryByteStream::Release
-+---------------------------------------------------------------------*/
-void
-AP4_MemoryByteStream::Release()
-{
- if (--m_ReferenceCount == 0) {
- delete this;
- }
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4ByteStream.h b/src/thirdparty/Bento4/Core/Ap4ByteStream.h
deleted file mode 100644
index b0feb78f8..000000000
--- a/src/thirdparty/Bento4/Core/Ap4ByteStream.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/*****************************************************************
-|
-| AP4 - ByteStream Interface
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_BYTE_STREAM_H_
-#define _AP4_BYTE_STREAM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4Types.h"
-#include "Ap4Interfaces.h"
-#include "Ap4Results.h"
-
-/*----------------------------------------------------------------------
-| AP4_ByteStream
-+---------------------------------------------------------------------*/
-class AP4_ByteStream : public AP4_Referenceable
-{
- public:
- // methods
- virtual AP4_Result Read(void* buffer,
- AP4_Size bytes_to_read,
- AP4_Size* bytes_read = 0) = 0;
- virtual AP4_Result ReadDouble(double& value);
- virtual AP4_Result ReadUI64(AP4_UI64& value);
- virtual AP4_Result ReadUI32(AP4_UI32& value);
- virtual AP4_Result ReadUI24(AP4_UI32& value);
- virtual AP4_Result ReadUI16(AP4_UI16& value);
- virtual AP4_Result ReadUI08(AP4_UI08& value);
- virtual AP4_Result ReadString(char* buffer, AP4_Size size);
- virtual AP4_Result Write(const void* buffer,
- AP4_Size bytes_to_write,
- AP4_Size* bytes_written = 0) = 0;
- virtual AP4_Result WriteString(const char* stringBuffer);
- virtual AP4_Result WriteUI64(AP4_UI64 value);
- virtual AP4_Result WriteUI32(AP4_UI32 value);
- virtual AP4_Result WriteUI24(AP4_UI32 value);
- virtual AP4_Result WriteUI16(AP4_UI16 value);
- virtual AP4_Result WriteUI08(AP4_UI08 value);
- virtual AP4_Result Seek(AP4_Offset offset) = 0;
- virtual AP4_Result Tell(AP4_Offset& offset) = 0;
- virtual AP4_Result GetSize(AP4_Size& size) = 0;
- virtual AP4_Result CopyTo(AP4_ByteStream& stream, AP4_Size size);
-};
-
-/*----------------------------------------------------------------------
-| AP4_SubStream
-+---------------------------------------------------------------------*/
-class AP4_SubStream : public AP4_ByteStream
-{
- public:
- AP4_SubStream(AP4_ByteStream& container, AP4_Offset offset, AP4_Size size);
-
- // AP4_ByteStream methods
- AP4_Result Read(void* buffer,
- AP4_Size bytes_to_read,
- AP4_Size* bytes_read = 0);
- AP4_Result Write(const void* buffer,
- AP4_Size bytes_to_write,
- AP4_Size* bytes_written = 0);
- AP4_Result Seek(AP4_Offset offset);
- AP4_Result Tell(AP4_Offset& offset) {
- offset = m_Position;
- return AP4_SUCCESS;
- }
- AP4_Result GetSize(AP4_Size& size) {
- size = m_Size;
- return AP4_SUCCESS;
- }
-
- // AP4_Referenceable methods
- void AddReference();
- void Release();
-
- protected:
- virtual ~AP4_SubStream();
-
- private:
- AP4_ByteStream& m_Container;
- AP4_Offset m_Offset;
- AP4_Size m_Size;
- AP4_Offset m_Position;
- AP4_Cardinal m_ReferenceCount;
-};
-
-/*----------------------------------------------------------------------
-| AP4_MemoryByteStream
-+---------------------------------------------------------------------*/
-class AP4_MemoryByteStream : public AP4_ByteStream
-{
-public:
- AP4_MemoryByteStream(AP4_Size size);
- AP4_MemoryByteStream(AP4_UI08* buffer, AP4_Size size);
-
- // AP4_ByteStream methods
- AP4_Result Read(void* buffer,
- AP4_Size bytes_to_read,
- AP4_Size* bytes_read = 0);
- AP4_Result Write(const void* buffer,
- AP4_Size bytes_to_write,
- AP4_Size* bytes_written = 0);
- AP4_Result Seek(AP4_Offset offset);
- AP4_Result Tell(AP4_Offset& offset) {
- offset = m_Position;
- return AP4_SUCCESS;
- }
- AP4_Result GetSize(AP4_Size& size) {
- size = m_Size;
- return AP4_SUCCESS;
- }
-
- // AP4_Referenceable methods
- void AddReference();
- void Release();
-
- // methods
- AP4_UI08* GetBuffer() { return m_Buffer; }
-
-protected:
- virtual ~AP4_MemoryByteStream();
-
-private:
- bool m_BufferIsLocal;
- AP4_UI08* m_Buffer;
- AP4_Size m_Size;
- AP4_Offset m_Position;
- AP4_Cardinal m_ReferenceCount;
-};
-
-#endif // _AP4_BYTE_STREAM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4ChplAtom.cpp b/src/thirdparty/Bento4/Core/Ap4ChplAtom.cpp
deleted file mode 100644
index 05b075362..000000000
--- a/src/thirdparty/Bento4/Core/Ap4ChplAtom.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*****************************************************************
-|
-| AP4 - chpl Atom
-|
-| Copyright 2002 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-
-#include "Ap4.h"
-#include "Ap4ChplAtom.h"
-
-/*----------------------------------------------------------------------
-| AP4_ChplAtom::AP4_ChplAtom
-+---------------------------------------------------------------------*/
-
-AP4_ChplAtom::AP4_ChplAtom(AP4_Size size,
- AP4_ByteStream& stream)
- : AP4_Atom(AP4_ATOM_TYPE_CHPL, size, true, stream)
-{
- size -= AP4_FULL_ATOM_HEADER_SIZE;
-
- stream.ReadUI32(m_Reserved);
-
- AP4_UI08 cnt = 0;
- stream.ReadUI08(cnt);
-
- size -= 5;
-
- while(size > 0 && cnt-- > 0)
- {
- AP4_Chapter chapter;
-
- // time
- stream.ReadUI64(chapter.Time);
-
- // name
- AP4_UI08 len = 0;
- char buff[256];
- stream.ReadUI08(len);
- stream.Read(buff, len);
- buff[len] = 0;
- chapter.Name = buff;
-
- m_Chapters.Append(chapter);
-
- size -= 8+1+len;
- }
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4ChplAtom.h b/src/thirdparty/Bento4/Core/Ap4ChplAtom.h
deleted file mode 100644
index 130d65ec9..000000000
--- a/src/thirdparty/Bento4/Core/Ap4ChplAtom.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*****************************************************************
-|
-| AP4 - chpl Atom
-|
-| Copyright 2002 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_CHPL_ATOM_H_
-#define _AP4_CHPL_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4Atom.h"
-#include "Ap4Types.h"
-#include "Ap4Array.h"
-#include "Ap4DataBuffer.h"
-
-/*----------------------------------------------------------------------
-| AP4_ChplAtom
-+---------------------------------------------------------------------*/
-class AP4_ChplAtom : public AP4_Atom
-{
-public:
- AP4_ChplAtom(AP4_Size size,
- AP4_ByteStream& stream);
-
- AP4_Result WriteFields(AP4_ByteStream& stream) { return AP4_FAILURE; }
-
- struct AP4_Chapter {AP4_UI64 Time; AP4_String Name;};
-
- AP4_Array<AP4_Chapter>& GetChapters() { return m_Chapters; }
-
-private:
-
- // members
- AP4_UI32 m_Reserved;
- AP4_Array<AP4_Chapter> m_Chapters;
-};
-
-#endif // _AP4_CHPL_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4CmvdAtom.cpp b/src/thirdparty/Bento4/Core/Ap4CmvdAtom.cpp
deleted file mode 100644
index ed90592d9..000000000
--- a/src/thirdparty/Bento4/Core/Ap4CmvdAtom.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/*****************************************************************
-|
-| AP4 - cmvd Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4CmvdAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4ContainerAtom.h"
-
-/*----------------------------------------------------------------------
-| AP4_CmvdAtom::AP4_CmvdAtom
-+---------------------------------------------------------------------*/
-AP4_CmvdAtom::AP4_CmvdAtom(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
- AP4_ContainerAtom(AP4_ATOM_TYPE_CMVD, size, false, stream)
-{
- size -= AP4_ATOM_HEADER_SIZE;
-
- stream.ReadUI32(m_MovieResourceSize);
-
- size -= 4;
-
- m_Data.SetDataSize(size);
- stream.Read(m_Data.UseData(), size);
-
-/*
- // read children
- AP4_Size bytes_available = size-AP4_FULL_ATOM_HEADER_SIZE-4;
- while (entry_count--) {
- AP4_Atom* atom;
- while (AP4_SUCCEEDED(atom_factory.CreateAtomFromStream(stream,
- bytes_available,
- atom,
- this))) {
- m_Children.Add(atom);
- }
- }
-*/
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4CmvdAtom.h b/src/thirdparty/Bento4/Core/Ap4CmvdAtom.h
deleted file mode 100644
index 9d9a35b21..000000000
--- a/src/thirdparty/Bento4/Core/Ap4CmvdAtom.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*****************************************************************
-|
-| AP4 - cmvd Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_CMVD_ATOM_H_
-#define _AP4_CMVD_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4Array.h"
-#include "Ap4Atom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4ContainerAtom.h"
-#include "Ap4DataBuffer.h"
-
-/*----------------------------------------------------------------------
-| AP4_CmvdAtom
-+---------------------------------------------------------------------*/
-class AP4_CmvdAtom : public AP4_ContainerAtom
-{
-public:
- // methods
- AP4_CmvdAtom(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory);
-
- virtual AP4_Result WriteFields(AP4_ByteStream& stream) { return AP4_FAILURE; }
-
- AP4_UI32 GetMovieResourceSize() const { return m_MovieResourceSize; }
- const AP4_DataBuffer& GetDataBuffer() { return m_Data; }
-
-private:
- AP4_UI32 m_MovieResourceSize;
- AP4_DataBuffer m_Data;
-};
-
-#endif // _AP4_CMVD_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4Co64Atom.cpp b/src/thirdparty/Bento4/Core/Ap4Co64Atom.cpp
deleted file mode 100644
index 8a519d665..000000000
--- a/src/thirdparty/Bento4/Core/Ap4Co64Atom.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/*****************************************************************
-|
-| AP4 - co64 Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4Co64Atom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_Co64Atom::AP4_Co64Atom
-+---------------------------------------------------------------------*/
-AP4_Co64Atom::AP4_Co64Atom(AP4_UI64* entries, AP4_UI32 entry_count) :
-AP4_Atom(AP4_ATOM_TYPE_CO64,
- AP4_FULL_ATOM_HEADER_SIZE+4+entry_count*8,
- true),
- m_Entries(new AP4_UI64[entry_count]),
- m_EntryCount(entry_count)
-{
- memcpy(m_Entries, entries, m_EntryCount*8);
-}
-
-/*----------------------------------------------------------------------
-| AP4_Co64Atom::AP4_Co64Atom
-+---------------------------------------------------------------------*/
-AP4_Co64Atom::AP4_Co64Atom(AP4_Size size, AP4_ByteStream& stream) :
- AP4_Atom(AP4_ATOM_TYPE_CO64, size, true, stream)
-{
- stream.ReadUI32(m_EntryCount);
- if (m_EntryCount > (size-AP4_FULL_ATOM_HEADER_SIZE-4)/8) {
- m_EntryCount = (size-AP4_FULL_ATOM_HEADER_SIZE-4)/8;
- }
- m_Entries = new AP4_UI64[m_EntryCount];
- for (AP4_Ordinal i=0; i<m_EntryCount; i++) {
- stream.ReadUI64(m_Entries[i]);
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_Co64Atom::~AP4_Co64Atom
-+---------------------------------------------------------------------*/
-AP4_Co64Atom::~AP4_Co64Atom()
-{
- delete[] m_Entries;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Co64Atom::GetChunkOffset
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Co64Atom::GetChunkOffset(AP4_Ordinal chunk, AP4_Offset& chunk_offset)
-{
- // check the bounds
- if (chunk > m_EntryCount || chunk == 0) {
- return AP4_ERROR_OUT_OF_RANGE;
- }
-
- // FIXME!!!
-
- // get the chunk offset
- chunk_offset = m_Entries[chunk - 1]; // m_Entries is zero index based
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Co64Atom::SetChunkOffset
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Co64Atom::SetChunkOffset(AP4_Ordinal chunk, AP4_Offset chunk_offset)
-{
- // check the bounds
- if (chunk > m_EntryCount || chunk == 0) {
- return AP4_ERROR_OUT_OF_RANGE;
- }
-
- // get the chunk offset
- m_Entries[chunk - 1] = chunk_offset; // m_Entries is zero index based
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Co64Atom::AdjustChunkOffsets
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Co64Atom::AdjustChunkOffsets(AP4_Offset offset)
-{
- for (AP4_Ordinal i=0; i<m_EntryCount; i++) {
- m_Entries[i] += offset;
- }
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Co64Atom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Co64Atom::WriteFields(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- // entry count
- result = stream.WriteUI32(m_EntryCount);
- if (AP4_FAILED(result)) return result;
-
- // entries
- for (AP4_Ordinal i=0; i<m_EntryCount; i++) {
- result = stream.WriteUI64(m_Entries[i]);
- if (AP4_FAILED(result)) return result;
- }
-
- return result;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Co64Atom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Co64Atom::InspectFields(AP4_AtomInspector& inspector)
-{
- inspector.AddField("entry_count", m_EntryCount);
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4Co64Atom.h b/src/thirdparty/Bento4/Core/Ap4Co64Atom.h
deleted file mode 100644
index ff9a48120..000000000
--- a/src/thirdparty/Bento4/Core/Ap4Co64Atom.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*****************************************************************
-|
-| AP4 - co64 Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_CO64_ATOM_H_
-#define _AP4_CO64_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4Array.h"
-#include "Ap4Atom.h"
-
-/*----------------------------------------------------------------------
-| AP4_Co64Atom
-+---------------------------------------------------------------------*/
-class AP4_Co64Atom : public AP4_Atom
-{
- public:
- // methods
- AP4_Co64Atom(AP4_UI64* offsets, AP4_UI32 offset_count);
- AP4_Co64Atom(AP4_Size size, AP4_ByteStream& stream);
- ~AP4_Co64Atom();
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- AP4_Cardinal GetChunkCount() { return m_EntryCount; }
- AP4_Result GetChunkOffset(AP4_Ordinal chunk, AP4_Offset& chunk_offset);
- AP4_Result SetChunkOffset(AP4_Ordinal chunk, AP4_Offset chunk_offset);
- AP4_Result AdjustChunkOffsets(AP4_Offset offset);
-
- private:
- AP4_UI64* m_Entries;
- AP4_UI32 m_EntryCount;
-};
-
-#endif // _AP4_CO64_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4Config.h b/src/thirdparty/Bento4/Core/Ap4Config.h
deleted file mode 100644
index d18c12d61..000000000
--- a/src/thirdparty/Bento4/Core/Ap4Config.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Target Platform and Compiler Configuration
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_CONFIG_H_
-#define _AP4_CONFIG_H_
-
-/*----------------------------------------------------------------------
-| defaults
-+---------------------------------------------------------------------*/
-#define AP4_CONFIG_HAVE_CPP_STRING_H
-#define AP4_CONFIG_HAVE_STDIO_H
-#define AP4_CONFIG_HAVE_ASSERT_H
-
-#define AP4_CONFIG_HAVE_CPP_STRING
-
-#define AP4_CONFIG_HAVE_SNPRINTF
-
-/*----------------------------------------------------------------------
-| byte order
-+---------------------------------------------------------------------*/
-// define AP4_PLATFORM_BYTE_ORDER to one of these two choices
-#define AP4_PLATFORM_BYTE_ORDER_BIG_ENDIAN 0
-#define AP4_PLATFORM_BYTE_ORDER_LITTLE_ENDIAN 1
-
-#ifdef __ppc__
-#define AP4_PLATFORM_BYTE_ORDER AP4_PLATFORM_BYTE_ORDER_BIG_ENDIAN
-#endif
-
-#define AP4_PLATFORM_BYTE_ORDER AP4_PLATFORM_BYTE_ORDER_LITTLE_ENDIAN
-
-/*----------------------------------------------------------------------
-| Win32 specifics
-+---------------------------------------------------------------------*/
-#if defined(WIN32) || defined(_WIN64)
-#define snprintf _snprintf
-#if _MSC_VER < 1500
-#define vsnprintf _vsnprintf
-#endif
-#if defined(_DEBUG)
-#define AP4_DEBUG
-#endif
-#endif
-
-#endif // _AP4_CONFIG_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4Constants.h b/src/thirdparty/Bento4/Core/Ap4Constants.h
deleted file mode 100644
index 5e693f3a7..000000000
--- a/src/thirdparty/Bento4/Core/Ap4Constants.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Shared Constants
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_CONSTANTS_H_
-#define _AP4_CONSTANTS_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#ifndef NULL
-#define NULL 0
-#endif
-
-#endif // _AP4_CONSTANTS_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4ContainerAtom.cpp b/src/thirdparty/Bento4/Core/Ap4ContainerAtom.cpp
deleted file mode 100644
index e5095b9a4..000000000
--- a/src/thirdparty/Bento4/Core/Ap4ContainerAtom.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Container Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4Atom.h"
-#include "Ap4Utils.h"
-#include "Ap4ContainerAtom.h"
-#include "Ap4AtomFactory.h"
-
-/*----------------------------------------------------------------------
-| AP4_ContainerAtom::AP4_ContainerAtom
-+---------------------------------------------------------------------*/
-AP4_ContainerAtom::AP4_ContainerAtom(Type type, bool is_full) :
- AP4_Atom(type, is_full)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_ContainerAtom::AP4_ContainerAtom
-+---------------------------------------------------------------------*/
-AP4_ContainerAtom::AP4_ContainerAtom(Type type, AP4_Size size, bool is_full) :
- AP4_Atom(type, size, is_full)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_ContainerAtom::AP4_ContainerAtom
-+---------------------------------------------------------------------*/
-AP4_ContainerAtom::AP4_ContainerAtom(Type type,
- AP4_Size size,
- bool is_full,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
- AP4_Atom(type, size, is_full, stream)
-{
- ReadChildren(atom_factory, stream, size-GetHeaderSize());
-}
-
-/*----------------------------------------------------------------------
-| AP4_ContainerAtom::AP4_ContainerAtom
-+---------------------------------------------------------------------*/
-AP4_ContainerAtom::AP4_ContainerAtom(Type type,
- AP4_Size size,
- bool is_full,
- AP4_ByteStream& stream) :
- AP4_Atom(type, size, is_full, stream)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_ContainerAtom::ReadChildren
-+---------------------------------------------------------------------*/
-void
-AP4_ContainerAtom::ReadChildren(AP4_AtomFactory& atom_factory,
- AP4_ByteStream& stream,
- AP4_Size size)
-{
- AP4_Atom* atom;
- AP4_Size bytes_available = size;
- while (AP4_SUCCEEDED(
- atom_factory.CreateAtomFromStream(stream, bytes_available, atom, this))) {
- atom->SetParent(this);
- m_Children.Add(atom);
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_ContainerAtom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_ContainerAtom::InspectFields(AP4_AtomInspector& inspector)
-{
- return InspectChildren(inspector);
-}
-
-/*----------------------------------------------------------------------
-| AP4_ContainerAtom::InspectChildren
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_ContainerAtom::InspectChildren(AP4_AtomInspector& inspector)
-{
- // inspect children
- m_Children.Apply(AP4_AtomListInspector(inspector));
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_ContainerAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_ContainerAtom::WriteFields(AP4_ByteStream& stream)
-{
- // write all children
- return m_Children.Apply(AP4_AtomListWriter(stream));
-}
-
-/*----------------------------------------------------------------------
-| AP4_ContainerAtom::OnChildChanged
-+---------------------------------------------------------------------*/
-void
-AP4_ContainerAtom::OnChildChanged(AP4_Atom*)
-{
- // remcompute our size
- m_Size = GetHeaderSize();
- m_Children.Apply(AP4_AtomSizeAdder(m_Size));
-
- // update our parent
- if (m_Parent) m_Parent->OnChildChanged(this);
-}
-
-/*----------------------------------------------------------------------
-| AP4_ContainerAtom::OnChildAdded
-+---------------------------------------------------------------------*/
-void
-AP4_ContainerAtom::OnChildAdded(AP4_Atom* child)
-{
- // update our size
- m_Size += child->GetSize();
-
- // update our parent
- if (m_Parent) m_Parent->OnChildChanged(this);
-}
-
-/*----------------------------------------------------------------------
-| AP4_ContainerAtom::OnChildRemoved
-+---------------------------------------------------------------------*/
-void
-AP4_ContainerAtom::OnChildRemoved(AP4_Atom* child)
-{
- // update our size
- m_Size -= child->GetSize();
-
- // update our parent
- if (m_Parent) m_Parent->OnChildChanged(this);
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4ContainerAtom.h b/src/thirdparty/Bento4/Core/Ap4ContainerAtom.h
deleted file mode 100644
index ed68726b8..000000000
--- a/src/thirdparty/Bento4/Core/Ap4ContainerAtom.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Container Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_CONTAINER_ATOM_H_
-#define _AP4_CONTAINER_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4Types.h"
-#include "Ap4List.h"
-#include "Ap4Atom.h"
-
-/*----------------------------------------------------------------------
-| class references
-+---------------------------------------------------------------------*/
-class AP4_ByteStream;
-class AP4_AtomFactory;
-
-/*----------------------------------------------------------------------
-| AP4_ContainerAtom
-+---------------------------------------------------------------------*/
-class AP4_ContainerAtom : public AP4_Atom, public AP4_AtomParent {
-public:
- // methods
- AP4_ContainerAtom(Type type, bool is_full = false);
- AP4_ContainerAtom(Type type,
- AP4_Size size,
- bool is_full,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory);
- AP4_ContainerAtom(Type type,
- AP4_Size size,
- bool is_full,
- AP4_ByteStream& stream);
- AP4_List<AP4_Atom>& GetChildren() { return m_Children; }
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- virtual AP4_Result InspectChildren(AP4_AtomInspector& inspector);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
- // AP4_AtomParent methods
- void OnChildChanged(AP4_Atom* child);
- void OnChildAdded(AP4_Atom* child);
- void OnChildRemoved(AP4_Atom* child);
-
-protected:
- // constructor
- AP4_ContainerAtom(Type type, AP4_Size size, bool is_full = false);
-
- // methods
- void ReadChildren(AP4_AtomFactory& atom_factory,
- AP4_ByteStream& stream,
- AP4_Size size);
-};
-
-#endif // _AP4_CONTAINER_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4CttsAtom.cpp b/src/thirdparty/Bento4/Core/Ap4CttsAtom.cpp
deleted file mode 100644
index c66cd5e0b..000000000
--- a/src/thirdparty/Bento4/Core/Ap4CttsAtom.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/*****************************************************************
-|
-| AP4 - ctts Atoms
-|
-| Copyright 2003 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4CttsAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_CttsAtom::AP4_CttsAtom
-+---------------------------------------------------------------------*/
-AP4_CttsAtom::AP4_CttsAtom(AP4_Size size, AP4_ByteStream& stream) :
- AP4_Atom(AP4_ATOM_TYPE_CTTS, size, true, stream)
-{
- AP4_UI32 entry_count;
- stream.ReadUI32(entry_count);
- while (entry_count--) {
- AP4_UI32 sample_count;
- AP4_UI32 sample_offset;
- if (stream.ReadUI32(sample_count) == AP4_SUCCESS &&
- stream.ReadUI32(sample_offset) == AP4_SUCCESS) {
- m_Entries.Append(AP4_CttsTableEntry(sample_count,
- sample_offset));
- }
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_CttsAtom::GetCtsOffset
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_CttsAtom::GetCtsOffset(AP4_Ordinal sample, AP4_UI32& cts_offset)
-{
- AP4_Ordinal current_sample = 0;
-
- for (unsigned int i = 0; i < m_Entries.ItemCount(); i++) {
- AP4_CttsTableEntry& entry = m_Entries[i];
-
- current_sample += entry.m_SampleCount;
- // check if we have the right entry
- if (current_sample >= sample) {
- cts_offset = entry.m_SampleOffset;
- return AP4_SUCCESS;
- }
- }
-
- // sample is greater than the number of samples
- return AP4_FAILURE;
-}
-
-/*----------------------------------------------------------------------
-| AP4_CttsAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_CttsAtom::WriteFields(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- // write the entry count
- AP4_Cardinal entry_count = m_Entries.ItemCount();
- result = stream.WriteUI32(entry_count);
- if (AP4_FAILED(result)) return result;
-
- // write the entries
- for (AP4_Ordinal i=0; i<entry_count; i++) {
- // sample count
- result = stream.WriteUI32(m_Entries[i].m_SampleCount);
- if (AP4_FAILED(result)) return result;
-
- // time offset
- result = stream.WriteUI32(m_Entries[i].m_SampleOffset);
- if (AP4_FAILED(result)) return result;
- }
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_CttsAtom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_CttsAtom::InspectFields(AP4_AtomInspector& inspector)
-{
- inspector.AddField("entry_count", m_Entries.ItemCount());
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4CttsAtom.h b/src/thirdparty/Bento4/Core/Ap4CttsAtom.h
deleted file mode 100644
index 333966692..000000000
--- a/src/thirdparty/Bento4/Core/Ap4CttsAtom.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*****************************************************************
-|
-| AP4 - ctts Atoms
-|
-| Copyright 2003 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_CTTS_ATOM_H_
-#define _AP4_CTTS_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4Atom.h"
-#include "Ap4Types.h"
-#include "Ap4Array.h"
-
-/*----------------------------------------------------------------------
-| AP4_CttsTableEntry
-+---------------------------------------------------------------------*/
-class AP4_CttsTableEntry {
- public:
- AP4_CttsTableEntry() :
- m_SampleCount(0),
- m_SampleOffset(0) {}
- AP4_CttsTableEntry(AP4_Cardinal sample_count,
- AP4_Offset sample_offset) :
- m_SampleCount(sample_count),
- m_SampleOffset(sample_offset) {}
-
- AP4_Cardinal m_SampleCount;
- AP4_Offset m_SampleOffset;
-};
-
-/*----------------------------------------------------------------------
-| AP4_CttsAtom
-+---------------------------------------------------------------------*/
-class AP4_CttsAtom : public AP4_Atom
-{
- public:
- // methods
- AP4_CttsAtom(AP4_Size size, AP4_ByteStream& stream);
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- virtual AP4_Result GetCtsOffset(AP4_Ordinal sample,
- AP4_UI32& cts_offset);
-
- private:
- AP4_Array<AP4_CttsTableEntry> m_Entries;
-};
-
-#endif // _AP4_CTTS_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4DataAtom.cpp b/src/thirdparty/Bento4/Core/Ap4DataAtom.cpp
deleted file mode 100644
index 6f37b6092..000000000
--- a/src/thirdparty/Bento4/Core/Ap4DataAtom.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/*****************************************************************
-|
-| AP4 - data Atom
-|
-| Copyright 2002 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-
-#include "Ap4.h"
-#include "Ap4DataAtom.h"
-
-/*----------------------------------------------------------------------
-| AP4_DataAtom::AP4_DataAtom
-+---------------------------------------------------------------------*/
-
-AP4_DataAtom::AP4_DataAtom(AP4_Size size,
- AP4_ByteStream& stream)
- : AP4_Atom(AP4_ATOM_TYPE_DATA)
-{
- size -= AP4_ATOM_HEADER_SIZE;
-
- stream.ReadUI32(m_Reserved1);
- stream.ReadUI32(m_Reserved2);
-
- size -= 8;
-
- m_Data.SetDataSize(size);
- stream.Read(m_Data.UseData(), size);
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4DataAtom.h b/src/thirdparty/Bento4/Core/Ap4DataAtom.h
deleted file mode 100644
index f5d915a4d..000000000
--- a/src/thirdparty/Bento4/Core/Ap4DataAtom.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*****************************************************************
-|
-| AP4 - data Atom
-|
-| Copyright 2002 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_DATA_ATOM_H_
-#define _AP4_DATA_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4Atom.h"
-#include "Ap4Types.h"
-#include "Ap4Array.h"
-#include "Ap4DataBuffer.h"
-
-/*----------------------------------------------------------------------
-| AP4_DataAtom
-+---------------------------------------------------------------------*/
-class AP4_DataAtom : public AP4_Atom
-{
-public:
- AP4_DataAtom(AP4_Size size,
- AP4_ByteStream& stream);
-
- AP4_Result WriteFields(AP4_ByteStream& stream) { return AP4_FAILURE; }
-
- const AP4_DataBuffer* GetData() const { return &m_Data; }
-
-private:
- AP4_UI32 m_Reserved1;
- AP4_UI32 m_Reserved2;
- AP4_DataBuffer m_Data;
-};
-
-#endif // _AP4_DATA_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4DataBuffer.cpp b/src/thirdparty/Bento4/Core/Ap4DataBuffer.cpp
deleted file mode 100644
index fc2682a3b..000000000
--- a/src/thirdparty/Bento4/Core/Ap4DataBuffer.cpp
+++ /dev/null
@@ -1,178 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Data Buffer
-|
-| Copyright 2002-2005 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4DataBuffer.h"
-
-/*----------------------------------------------------------------------
-| AP4_DataBuffer::AP4_DataBuffer
-+---------------------------------------------------------------------*/
-AP4_DataBuffer::AP4_DataBuffer() :
- m_BufferIsLocal(true),
- m_Buffer(NULL),
- m_BufferSize(0),
- m_DataSize(0)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_DataBuffer::AP4_DataBuffer
-+---------------------------------------------------------------------*/
-AP4_DataBuffer::AP4_DataBuffer(AP4_Size buffer_size) :
- m_BufferIsLocal(true),
- m_Buffer(NULL),
- m_BufferSize(buffer_size),
- m_DataSize(0)
-{
- m_Buffer = new AP4_Byte[buffer_size];
-}
-
-/*----------------------------------------------------------------------
-| AP4_DataBuffer::AP4_DataBuffer
-+---------------------------------------------------------------------*/
-AP4_DataBuffer::AP4_DataBuffer(const AP4_DataBuffer& other) :
- m_BufferIsLocal(true),
- m_Buffer(NULL),
- m_BufferSize(other.m_DataSize),
- m_DataSize(other.m_DataSize)
-{
- m_Buffer = new AP4_Byte[m_BufferSize];
- memcpy(m_Buffer, other.m_Buffer, m_BufferSize);
-}
-
-/*----------------------------------------------------------------------
-| AP4_DataBuffer::~AP4_DataBuffer
-+---------------------------------------------------------------------*/
-AP4_DataBuffer::~AP4_DataBuffer()
-{
- if (m_BufferIsLocal) {
- delete[] m_Buffer;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_DataBuffer::SetBuffer
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_DataBuffer::SetBuffer(AP4_Byte* buffer, AP4_Size buffer_size)
-{
- if (m_BufferIsLocal) {
- // destroy the local buffer
- delete[] m_Buffer;
- }
-
- // we're now using an external buffer
- m_BufferIsLocal = false;
- m_Buffer = buffer;
- m_BufferSize = buffer_size;
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_DataBuffer::SetBufferSize
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_DataBuffer::SetBufferSize(AP4_Size buffer_size)
-{
- if (m_BufferIsLocal) {
- return ReallocateBuffer(buffer_size);
- } else {
- return AP4_FAILURE; // you cannot change the
- // buffer management mode
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_DataBuffer::SetDataSize
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_DataBuffer::SetDataSize(AP4_Size size)
-{
- if (size > m_BufferSize) {
- if (m_BufferIsLocal) {
- AP4_Result result = ReallocateBuffer(size);
- if (AP4_FAILED(result)) return result;
- } else {
- return AP4_FAILURE;
- }
- }
- m_DataSize = size;
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_DataBuffer::SetData
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_DataBuffer::SetData(AP4_Byte* data, AP4_Size size)
-{
- if (size > m_BufferSize) {
- if (m_BufferIsLocal) {
- AP4_Result result = ReallocateBuffer(size);
- if (AP4_FAILED(result)) return result;
- } else {
- return AP4_FAILURE;
- }
- }
- memcpy(m_Buffer, data, size);
- m_DataSize = size;
-
- return AP4_SUCCESS;
-}
-
-
-/*----------------------------------------------------------------------
-| AP4_DataBuffer::ReallocateBuffer
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_DataBuffer::ReallocateBuffer(AP4_Size size)
-{
- // check that the existing data fits
- if (m_DataSize > size) return AP4_FAILURE;
-
- // allocate a new buffer
- AP4_Byte* new_buffer = new AP4_Byte[size];
-
- // copy the contents of the previous buffer ,is any
- if (m_Buffer && m_DataSize) {
- memcpy(new_buffer, m_Buffer, m_DataSize);
- }
-
- // destroy the previous buffer
- delete[] m_Buffer;
-
- // use the new buffer
- m_Buffer = new_buffer;
- m_BufferSize = size;
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4DataBuffer.h b/src/thirdparty/Bento4/Core/Ap4DataBuffer.h
deleted file mode 100644
index 529e842d6..000000000
--- a/src/thirdparty/Bento4/Core/Ap4DataBuffer.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Data Buffer Objects
-|
-| Copyright 2002 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_DATA_BUFFER_H_
-#define _AP4_DATA_BUFFER_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-
-/*----------------------------------------------------------------------
-| AP4_DataBuffer
-+---------------------------------------------------------------------*/
-class AP4_DataBuffer
-{
- public:
- // constructors & destructor
- AP4_DataBuffer();
- AP4_DataBuffer(AP4_Size size);
- AP4_DataBuffer(const AP4_DataBuffer& other);
- virtual ~AP4_DataBuffer();
-
- // data buffer handling methods
- virtual AP4_Result SetBuffer(AP4_Byte* buffer, AP4_Size buffer_size);
- virtual AP4_Result SetBufferSize(AP4_Size buffer_size);
- virtual AP4_Size GetBufferSize() const { return m_BufferSize; }
-
- // data handling methods
- virtual const AP4_Byte* GetData() const { return m_Buffer; }
- virtual AP4_Byte* UseData() { return m_Buffer; };
- virtual AP4_Size GetDataSize() const { return m_DataSize; }
- virtual AP4_Result SetDataSize(AP4_Size size);
- virtual AP4_Result SetData(AP4_Byte* data, AP4_Size data_size);
-
- protected:
- // members
- bool m_BufferIsLocal;
- AP4_Byte* m_Buffer;
- AP4_Size m_BufferSize;
- AP4_Size m_DataSize;
-
- // methods
- AP4_Result ReallocateBuffer(AP4_Size size);
-};
-
-#endif // _AP4_DATA_BUFFER_H_
-
diff --git a/src/thirdparty/Bento4/Core/Ap4DcomAtom.cpp b/src/thirdparty/Bento4/Core/Ap4DcomAtom.cpp
deleted file mode 100644
index 002caab6e..000000000
--- a/src/thirdparty/Bento4/Core/Ap4DcomAtom.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*****************************************************************
-|
-| AP4 - dcom Atom
-|
-| Copyright 2002 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-
-#include "Ap4.h"
-#include "Ap4DcomAtom.h"
-
-/*----------------------------------------------------------------------
-| AP4_DcomAtom::AP4_DcomAtom
-+---------------------------------------------------------------------*/
-
-AP4_DcomAtom::AP4_DcomAtom(AP4_Size size,
- AP4_ByteStream& stream)
- : AP4_Atom(AP4_ATOM_TYPE_DCOM)
-{
- size -= AP4_ATOM_HEADER_SIZE;
-
- stream.ReadUI32(m_CompressorSubType);
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4DcomAtom.h b/src/thirdparty/Bento4/Core/Ap4DcomAtom.h
deleted file mode 100644
index def06cc19..000000000
--- a/src/thirdparty/Bento4/Core/Ap4DcomAtom.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*****************************************************************
-|
-| AP4 - dcom Atom
-|
-| Copyright 2002 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_DCOM_ATOM_H_
-#define _AP4_DCOM_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4Atom.h"
-#include "Ap4Types.h"
-
-/*----------------------------------------------------------------------
-| AP4_DcomAtom
-+---------------------------------------------------------------------*/
-class AP4_DcomAtom : public AP4_Atom
-{
-public:
- AP4_DcomAtom(AP4_Size size,
- AP4_ByteStream& stream);
-
- AP4_Result WriteFields(AP4_ByteStream& stream) { return AP4_FAILURE; }
-
- AP4_Atom::Type GetCompressorSubType() const { return m_CompressorSubType; }
-
-private:
- AP4_Atom::Type m_CompressorSubType;
-};
-
-#endif // _AP4_DCOM_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4Debug.cpp b/src/thirdparty/Bento4/Core/Ap4Debug.cpp
deleted file mode 100644
index 88b7cbd26..000000000
--- a/src/thirdparty/Bento4/Core/Ap4Debug.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Debug Support
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include <stdarg.h>
-#include <stdio.h>
-
-#include "Ap4Debug.h"
-
-/*----------------------------------------------------------------------
-| constants
-+---------------------------------------------------------------------*/
-const int AP4_DEBUG_MAX_BUFFER = 1024;
-
-/*----------------------------------------------------------------------
-| AP4_Print
-+---------------------------------------------------------------------*/
-static void
-AP4_Print(const char* message)
-{
- printf(message);
-}
-
-/*----------------------------------------------------------------------
-| AP4_Debug
-+---------------------------------------------------------------------*/
-void
-AP4_Debug(const char* format, ...)
-{
- va_list args;
-
- va_start(args, format);
-
- char buffer[AP4_DEBUG_MAX_BUFFER];
- vsnprintf(buffer, sizeof(buffer), format, args);
- AP4_Print(buffer);
-
- va_end(args);
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4Debug.h b/src/thirdparty/Bento4/Core/Ap4Debug.h
deleted file mode 100644
index f99aaa79e..000000000
--- a/src/thirdparty/Bento4/Core/Ap4Debug.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Debug Support
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_DEBUG_H_
-#define _AP4_DEBUG_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4Config.h"
-
-/*----------------------------------------------------------------------
-| AP4_Debug
-+---------------------------------------------------------------------*/
-extern void AP4_Debug(const char* format, ...);
-
-/*----------------------------------------------------------------------
-| AP4_ASSERT
-+---------------------------------------------------------------------*/
-#if defined (AP4_CONFIG_HAVE_ASSERT_H)
-#include <assert.h>
-#define AP4_ASSERT assert
-#endif
-
-
-#endif // _AP4_DEBUG_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4DecoderConfigDescriptor.cpp b/src/thirdparty/Bento4/Core/Ap4DecoderConfigDescriptor.cpp
deleted file mode 100644
index ba7c410fe..000000000
--- a/src/thirdparty/Bento4/Core/Ap4DecoderConfigDescriptor.cpp
+++ /dev/null
@@ -1,166 +0,0 @@
-/*****************************************************************
-|
-| AP4 - DecoderConfig Descriptors
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4DecoderConfigDescriptor.h"
-#include "Ap4DescriptorFactory.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_DecoderConfigDescriptor::AP4_DecoderConfigDescriptor
-+---------------------------------------------------------------------*/
-AP4_DecoderConfigDescriptor::AP4_DecoderConfigDescriptor(
- AP4_UI08 stream_type,
- AP4_UI08 oti,
- AP4_UI32 buffer_size,
- AP4_UI32 max_bitrate,
- AP4_UI32 avg_bitrate,
- AP4_DecoderSpecificInfoDescriptor* dsi) :
- AP4_Descriptor(AP4_DESCRIPTOR_TAG_DECODER_CONFIG, 2, 13),
- m_StreamType(stream_type),
- m_ObjectTypeIndication(oti),
- m_UpStream(false),
- m_BufferSize(buffer_size),
- m_MaxBitrate(max_bitrate),
- m_AverageBitrate(avg_bitrate)
-{
- if (dsi) {
- m_SubDescriptors.Add(dsi);
- m_PayloadSize += dsi->GetSize();
- m_HeaderSize = MinHeaderSize(m_PayloadSize);
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_DecoderConfigDescriptor::AP4_DecoderConfigDescriptor
-+---------------------------------------------------------------------*/
-AP4_DecoderConfigDescriptor::AP4_DecoderConfigDescriptor(
- AP4_ByteStream& stream, AP4_Size header_size, AP4_Size payload_size) :
- AP4_Descriptor(AP4_DESCRIPTOR_TAG_DECODER_CONFIG,
- header_size,
- payload_size)
-{
- // record the start position
- AP4_Offset start;
- stream.Tell(start);
-
- // read descriptor fields
- stream.ReadUI08(m_ObjectTypeIndication);
- unsigned char bits;
- stream.ReadUI08(bits);
- m_StreamType = (bits>>2)&0x3F;
- m_UpStream = bits&2 ? true:false;
- stream.ReadUI24(m_BufferSize);
- stream.ReadUI32(m_MaxBitrate);
- stream.ReadUI32(m_AverageBitrate);
-
- // read other descriptors
- AP4_SubStream* substream = new AP4_SubStream(stream, start+13, payload_size-13);
- AP4_Descriptor* descriptor = NULL;
- while (AP4_DescriptorFactory::CreateDescriptorFromStream(*substream,
- descriptor)
- == AP4_SUCCESS) {
- m_SubDescriptors.Add(descriptor);
- }
- substream->Release();
-}
-
-/*----------------------------------------------------------------------
-| AP4_DecoderConfigDescriptor::~AP4_DecoderConfigDescriptor
-+---------------------------------------------------------------------*/
-AP4_DecoderConfigDescriptor::~AP4_DecoderConfigDescriptor()
-{
- m_SubDescriptors.DeleteReferences();
-}
-
-/*----------------------------------------------------------------------
-| AP4_DecoderConfigDescriptor::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_DecoderConfigDescriptor::WriteFields(AP4_ByteStream& stream)
-{
- stream.WriteUI08(m_ObjectTypeIndication);
- AP4_UI08 bits = (m_StreamType<<2) | (m_UpStream? 2 : 0) | 1;
- stream.WriteUI08(bits);
- stream.WriteUI24(m_BufferSize);
- stream.WriteUI32(m_MaxBitrate);
- stream.WriteUI32(m_AverageBitrate);
-
- m_SubDescriptors.Apply(AP4_DescriptorListWriter(stream));
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_DecoderConfigDescriptor::Inspect
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_DecoderConfigDescriptor::Inspect(AP4_AtomInspector& inspector)
-{
- char info[64];
- AP4_StringFormat(info, sizeof(info), "size=%ld+%ld",
- GetHeaderSize(),
- m_PayloadSize);
- inspector.StartElement("#[DecoderConfig]", info);
- inspector.AddField("stream_type", m_StreamType);
- inspector.AddField("object_type", m_ObjectTypeIndication);
- inspector.AddField("up_stream", m_UpStream);
- inspector.AddField("buffer_size", m_BufferSize);
- inspector.AddField("max_bitrate", m_MaxBitrate);
- inspector.AddField("avg_bitrate", m_AverageBitrate);
-
- // inspect children
- m_SubDescriptors.Apply(AP4_DescriptorListInspector(inspector));
-
- inspector.EndElement();
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_DecoderConfigDescriptor::GetDecoderSpecificInfoDescriptor
-+---------------------------------------------------------------------*/
-const AP4_DecoderSpecificInfoDescriptor*
-AP4_DecoderConfigDescriptor::GetDecoderSpecificInfoDescriptor() const
-{
- // find the decoder specific info
- AP4_Descriptor* descriptor = NULL;
- AP4_Result result =
- m_SubDescriptors.Find(AP4_DescriptorFinder(AP4_DESCRIPTOR_TAG_DECODER_SPECIFIC_INFO),
- descriptor);
-
- // return it
- if (AP4_SUCCEEDED(result)) {
- return dynamic_cast<AP4_DecoderSpecificInfoDescriptor*>(descriptor);
- } else {
- return NULL;
- }
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4DecoderConfigDescriptor.h b/src/thirdparty/Bento4/Core/Ap4DecoderConfigDescriptor.h
deleted file mode 100644
index 1b7e02a77..000000000
--- a/src/thirdparty/Bento4/Core/Ap4DecoderConfigDescriptor.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*****************************************************************
-|
-| AP4 - DecoderConfig Descriptor
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_DECODER_CONFIG_DESCRIPTOR_H_
-#define _AP4_DECODER_CONFIG_DESCRIPTOR_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4List.h"
-#include "Ap4Descriptor.h"
-#include "Ap4DecoderSpecificInfoDescriptor.h"
-
-/*----------------------------------------------------------------------
-| constants
-+---------------------------------------------------------------------*/
-const AP4_Descriptor::Tag AP4_DESCRIPTOR_TAG_DECODER_CONFIG = 0x04;
-
-/*----------------------------------------------------------------------
-| AP4_DecoderConfigDescriptor
-+---------------------------------------------------------------------*/
-class AP4_DecoderConfigDescriptor : public AP4_Descriptor
-{
- public:
- // methods
- AP4_DecoderConfigDescriptor(AP4_UI08 stream_type,
- AP4_UI08 oti,
- AP4_UI32 buffer_size,
- AP4_UI32 max_bitrate,
- AP4_UI32 avg_bitrate,
- AP4_DecoderSpecificInfoDescriptor* dsi);
- AP4_DecoderConfigDescriptor(AP4_ByteStream& stream,
- AP4_Size header_size,
- AP4_Size payload_size);
- virtual ~AP4_DecoderConfigDescriptor();
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
-
- // accessors
- virtual const AP4_DecoderSpecificInfoDescriptor*
- GetDecoderSpecificInfoDescriptor() const;
- virtual AP4_UI08 GetObjectTypeIndication() const {
- return m_ObjectTypeIndication;
- }
- virtual AP4_UI08 GetStreamType() const { return m_StreamType; }
- virtual AP4_UI32 GetBufferSize() const { return m_BufferSize; }
- virtual AP4_UI32 GetMaxBitrate() const { return m_MaxBitrate; }
- virtual AP4_UI32 GetAvgBitrate() const { return m_AverageBitrate; }
-
- private:
- // members
- AP4_UI08 m_StreamType;
- AP4_UI08 m_ObjectTypeIndication;
- bool m_UpStream;
- AP4_UI32 m_BufferSize;
- AP4_UI32 m_MaxBitrate;
- AP4_UI32 m_AverageBitrate;
- mutable AP4_List<AP4_Descriptor> m_SubDescriptors;
-};
-
-#endif // _AP4_DECODER_CONFIG_DESCRIPTOR_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4DecoderSpecificInfoDescriptor.cpp b/src/thirdparty/Bento4/Core/Ap4DecoderSpecificInfoDescriptor.cpp
deleted file mode 100644
index d04c9d57c..000000000
--- a/src/thirdparty/Bento4/Core/Ap4DecoderSpecificInfoDescriptor.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/*****************************************************************
-|
-| AP4 - DecoderSpecificInfo Descriptors
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4DecoderSpecificInfoDescriptor.h"
-#include "Ap4DescriptorFactory.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_DecoderSpecificInfoDescriptor::AP4_DecoderSpecificInfoDescriptor
-+---------------------------------------------------------------------*/
-AP4_DecoderSpecificInfoDescriptor::AP4_DecoderSpecificInfoDescriptor(
- const AP4_DataBuffer& data) :
- AP4_Descriptor(AP4_DESCRIPTOR_TAG_DECODER_SPECIFIC_INFO,
- MinHeaderSize(data.GetDataSize()),
- data.GetDataSize()),
- m_Info(data)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_DecoderSpecificInfoDescriptor::AP4_DecoderSpecificInfoDescriptor
-+---------------------------------------------------------------------*/
-AP4_DecoderSpecificInfoDescriptor::AP4_DecoderSpecificInfoDescriptor(
- AP4_ByteStream& stream, AP4_Size header_size, AP4_Size payload_size) :
- AP4_Descriptor(AP4_DESCRIPTOR_TAG_DECODER_SPECIFIC_INFO,
- header_size, payload_size)
-{
- m_Info.SetDataSize(payload_size);
- stream.Read(m_Info.UseData(), payload_size);
-}
-
-/*----------------------------------------------------------------------
-| AP4_DecoderSpecificInfoDescriptor::~AP4_DecoderSpecificInfoDescriptor
-+---------------------------------------------------------------------*/
-AP4_DecoderSpecificInfoDescriptor::~AP4_DecoderSpecificInfoDescriptor()
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_DecoderSpecificInfoDescriptor::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_DecoderSpecificInfoDescriptor::WriteFields(AP4_ByteStream& stream)
-{
- // write the info buffer
- if (m_PayloadSize && m_Info.GetDataSize()) {
- stream.Write(m_Info.GetData(), m_Info.GetDataSize());
- }
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_DecoderSpecificInfoDescriptor::Inspect
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_DecoderSpecificInfoDescriptor::Inspect(AP4_AtomInspector& inspector)
-{
- char* info = new char[m_Info.GetDataSize()*3+1];
- for (unsigned int i=0; i<m_Info.GetDataSize(); i++) {
- AP4_StringFormat(&info[i*3], 3, "%02x ", m_Info.UseData()[i]);
- }
- info[m_Info.GetDataSize()*3] = '\0';
- inspector.AddField("#[DecoderSpecificInfo]", info);
- delete[] info;
-
- return AP4_SUCCESS;
-}
-
diff --git a/src/thirdparty/Bento4/Core/Ap4DecoderSpecificInfoDescriptor.h b/src/thirdparty/Bento4/Core/Ap4DecoderSpecificInfoDescriptor.h
deleted file mode 100644
index f5e6e3cd4..000000000
--- a/src/thirdparty/Bento4/Core/Ap4DecoderSpecificInfoDescriptor.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*****************************************************************
-|
-| AP4 - DecoderSpecificInfo Descriptor
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_DECODER_SPECIFIC_INFO_DESCRIPTOR_H_
-#define _AP4_DECODER_SPECIFIC_INFO_DESCRIPTOR_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4List.h"
-#include "Ap4Descriptor.h"
-#include "Ap4DataBuffer.h"
-
-/*----------------------------------------------------------------------
-| constants
-+---------------------------------------------------------------------*/
-const AP4_Descriptor::Tag AP4_DESCRIPTOR_TAG_DECODER_SPECIFIC_INFO = 0x05;
-
-/*----------------------------------------------------------------------
-| AP4_DecoderSpecificInfoDescriptor
-+---------------------------------------------------------------------*/
-class AP4_DecoderSpecificInfoDescriptor : public AP4_Descriptor
-{
-public:
- // methods
- AP4_DecoderSpecificInfoDescriptor(const AP4_DataBuffer& data);
- AP4_DecoderSpecificInfoDescriptor(AP4_ByteStream& stream,
- AP4_Size header_size,
- AP4_Size payload_size);
- virtual ~AP4_DecoderSpecificInfoDescriptor();
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
- virtual const AP4_DataBuffer& GetDecoderSpecificInfo() const { return m_Info; }
-
-private:
- // members
- AP4_DataBuffer m_Info;
-};
-
-#endif // _AP4_DECODER_SPECIFIC_INFO_DESCRIPTOR_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4Descriptor.cpp b/src/thirdparty/Bento4/Core/Ap4Descriptor.cpp
deleted file mode 100644
index e9edafbf3..000000000
--- a/src/thirdparty/Bento4/Core/Ap4Descriptor.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Descriptors
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4Descriptor.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_Descriptor::MinHeaderSize
-+---------------------------------------------------------------------*/
-AP4_Size
-AP4_Descriptor::MinHeaderSize(AP4_Size payload_size)
-{
- // compute how many bytes are needed to encode the payload size
- // plus tag
- return 2+(payload_size/128);
-}
-
-/*----------------------------------------------------------------------
-| AP4_Descriptor::AP4_Descriptor
-+---------------------------------------------------------------------*/
-AP4_Descriptor::AP4_Descriptor(Tag tag,
- AP4_Size header_size,
- AP4_Size payload_size) :
- m_Tag(tag),
- m_HeaderSize(header_size),
- m_PayloadSize(payload_size)
-{
- AP4_ASSERT(header_size >= 1+1);
- AP4_ASSERT(header_size <= 1+4);
-}
-
-/*----------------------------------------------------------------------
-| AP4_Descriptor::Write
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Descriptor::Write(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- // write the tag
- result = stream.WriteUI08(m_Tag);
- if (AP4_FAILED(result)) return result;
-
- // write the size
- AP4_ASSERT(m_HeaderSize-1 <= 8);
- AP4_ASSERT(m_HeaderSize >= 2);
- unsigned int size = m_PayloadSize;
- unsigned char bytes[8];
-
- // last bytes of the encoded size
- bytes[m_HeaderSize-2] = size&0x7F;
-
- // leading bytes of the encoded size
- for (int i=m_HeaderSize-3; i>=0; i--) {
- // move to the next 7 bits
- size >>= 7;
-
- // output a byte with a top bit marker
- bytes[i] = (size&0x7F) | 0x80;
- }
-
- result = stream.Write(bytes, m_HeaderSize-1);
- if (AP4_FAILED(result)) return result;
-
- // write the fields
- WriteFields(stream);
-
- return result;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Descriptor::Inspect
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Descriptor::Inspect(AP4_AtomInspector& inspector)
-{
- char name[6];
- AP4_StringFormat(name, sizeof(name), "#[%02x]", m_Tag);
- char info[64];
- AP4_StringFormat(info, sizeof(info), "size=%ld+%ld",
- GetHeaderSize(),
- m_PayloadSize);
- inspector.StartElement(name, info);
- inspector.EndElement();
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4Descriptor.h b/src/thirdparty/Bento4/Core/Ap4Descriptor.h
deleted file mode 100644
index e2e6689f9..000000000
--- a/src/thirdparty/Bento4/Core/Ap4Descriptor.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Descriptors
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_DESCRIPTOR_H_
-#define _AP4_DESCRIPTOR_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4List.h"
-#include "Ap4Atom.h"
-
-/*----------------------------------------------------------------------
-| AP4_Descriptor
-+---------------------------------------------------------------------*/
-class AP4_Descriptor
-{
- public:
- // types
- typedef unsigned char Tag;
-
- // class methods
- static AP4_Size MinHeaderSize(AP4_Size payload_size);
-
- // methods
- AP4_Descriptor(Tag tag, AP4_Size header_size, AP4_Size payload_size);
- virtual ~AP4_Descriptor() {}
- Tag GetTag() { return m_Tag; }
- AP4_Size GetSize() { return m_PayloadSize+m_HeaderSize; }
- AP4_Size GetHeaderSize() { return m_HeaderSize; }
- virtual AP4_Result Write(AP4_ByteStream& stream);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream) = 0;
- virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
-
- protected:
- // members
- Tag m_Tag;
- AP4_Size m_HeaderSize;
- AP4_Size m_PayloadSize;
-};
-
-/*----------------------------------------------------------------------
-| AP4_DescriptorFinder
-+---------------------------------------------------------------------*/
-class AP4_DescriptorFinder : public AP4_List<AP4_Descriptor>::Item::Finder
-{
- public:
- AP4_DescriptorFinder(AP4_Descriptor::Tag tag) : m_Tag(tag) {}
- AP4_Result Test(AP4_Descriptor* descriptor) const {
- return descriptor->GetTag() == m_Tag ? AP4_SUCCESS : AP4_FAILURE;
- }
- private:
- AP4_Descriptor::Tag m_Tag;
-};
-
-/*----------------------------------------------------------------------
-| AP4_DescriptorListWriter
-+---------------------------------------------------------------------*/
-class AP4_DescriptorListWriter : public AP4_List<AP4_Descriptor>::Item::Operator
-{
-public:
- AP4_DescriptorListWriter(AP4_ByteStream& stream) :
- m_Stream(stream) {}
- AP4_Result Action(AP4_Descriptor* descriptor) const {
- return descriptor->Write(m_Stream);
- }
-
-private:
- AP4_ByteStream& m_Stream;
-};
-
-/*----------------------------------------------------------------------
-| AP4_DescriptorListInspector
-+---------------------------------------------------------------------*/
-class AP4_DescriptorListInspector : public AP4_List<AP4_Descriptor>::Item::Operator
-{
- public:
- AP4_DescriptorListInspector(AP4_AtomInspector& inspector) :
- m_Inspector(inspector) {}
- AP4_Result Action(AP4_Descriptor* descriptor) const {
- descriptor->Inspect(m_Inspector);
- return AP4_SUCCESS;
- }
-
- private:
- AP4_AtomInspector& m_Inspector;
-};
-
-#endif // _AP4_DESCRIPTOR_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4DescriptorFactory.cpp b/src/thirdparty/Bento4/Core/Ap4DescriptorFactory.cpp
deleted file mode 100644
index 4db7b96f9..000000000
--- a/src/thirdparty/Bento4/Core/Ap4DescriptorFactory.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Descriptor Factory
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4DescriptorFactory.h"
-#include "Ap4EsDescriptor.h"
-#include "Ap4DecoderConfigDescriptor.h"
-#include "Ap4DecoderSpecificInfoDescriptor.h"
-#include "Ap4SLConfigDescriptor.h"
-#include "Ap4UnknownDescriptor.h"
-
-/*----------------------------------------------------------------------
-| AP4_DescriptorFactory::CreateDescriptorFromStream
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_DescriptorFactory::CreateDescriptorFromStream(AP4_ByteStream& stream,
- AP4_Descriptor*& descriptor)
-{
- AP4_Result result;
-
- // NULL by default
- descriptor = NULL;
-
- // remember current stream offset
- AP4_Offset offset;
- stream.Tell(offset);
-
- // read descriptor tag
- unsigned char tag;
- result = stream.ReadUI08(tag);
- if (AP4_FAILED(result)) {
- stream.Seek(offset);
- return result;
- }
-
- // read descriptor size
- unsigned long payload_size = 0;
- unsigned int header_size = 1;
- unsigned int max = 4;
- unsigned char ext = 0;
- do {
- header_size++;
- result = stream.ReadUI08(ext);
- if (AP4_FAILED(result)) {
- stream.Seek(offset);
- return result;
- }
- payload_size = (payload_size<<7) + (ext&0x7F);
- } while (--max && (ext&0x80));
-
- // create the descriptor
- switch (tag) {
- case AP4_DESCRIPTOR_TAG_ES:
- descriptor = new AP4_EsDescriptor(stream, header_size, payload_size);
- break;
-
- case AP4_DESCRIPTOR_TAG_DECODER_CONFIG:
- descriptor = new AP4_DecoderConfigDescriptor(stream, header_size, payload_size);
- break;
-
- case AP4_DESCRIPTOR_TAG_DECODER_SPECIFIC_INFO:
- descriptor = new AP4_DecoderSpecificInfoDescriptor(stream, header_size, payload_size);
- break;
-
- case AP4_DESCRIPTOR_TAG_SL_CONFIG:
- if (payload_size != 1) return AP4_ERROR_INVALID_FORMAT;
- descriptor = new AP4_SLConfigDescriptor(header_size);
- break;
-
- default:
- descriptor = new AP4_UnknownDescriptor(stream, tag, header_size, payload_size);
- break;
- }
-
- // skip to the end of the descriptor
- stream.Seek(offset+header_size+payload_size);
-
- return AP4_SUCCESS;
-}
-
diff --git a/src/thirdparty/Bento4/Core/Ap4DescriptorFactory.h b/src/thirdparty/Bento4/Core/Ap4DescriptorFactory.h
deleted file mode 100644
index 2d9ab4264..000000000
--- a/src/thirdparty/Bento4/Core/Ap4DescriptorFactory.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Descriptor Factory
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_DESCRIPTOR_FACTORY_H_
-#define _AP4_DESCRIPTOR_FACTORY_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4Descriptor.h"
-#include "Ap4ByteStream.h"
-
-/*----------------------------------------------------------------------
-| AP4_DescriptorFactory
-+---------------------------------------------------------------------*/
-class AP4_DescriptorFactory
-{
- public:
- // class methods
- static AP4_Result CreateDescriptorFromStream(AP4_ByteStream& stream,
- AP4_Descriptor*& descriptor);
-};
-
-#endif // _AP4_DESCRIPTOR_FACTORY_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4DrefAtom.cpp b/src/thirdparty/Bento4/Core/Ap4DrefAtom.cpp
deleted file mode 100644
index b495b2f78..000000000
--- a/src/thirdparty/Bento4/Core/Ap4DrefAtom.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*****************************************************************
-|
-| AP4 - dref Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4DrefAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4Utils.h"
-#include "Ap4ContainerAtom.h"
-
-/*----------------------------------------------------------------------
-| AP4_DrefAtom::AP4_DrefAtom
-+---------------------------------------------------------------------*/
-AP4_DrefAtom::AP4_DrefAtom(AP4_Atom** refs, AP4_Cardinal refs_count) :
- AP4_ContainerAtom(AP4_ATOM_TYPE_DREF, AP4_FULL_ATOM_HEADER_SIZE+4, true)
-{
- for (unsigned i=0; i<refs_count; i++) {
- m_Children.Add(refs[i]);
- m_Size += refs[i]->GetSize();
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_DrefAtom::AP4_DrefAtom
-+---------------------------------------------------------------------*/
-AP4_DrefAtom::AP4_DrefAtom(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
- AP4_ContainerAtom(AP4_ATOM_TYPE_DREF, size, true, stream)
-{
- // read the number of entries
- AP4_UI32 entry_count;
- stream.ReadUI32(entry_count);
-
- // read children
- AP4_Size bytes_available = size-AP4_FULL_ATOM_HEADER_SIZE-4;
- while (entry_count--) {
- AP4_Atom* atom;
- while (AP4_SUCCEEDED(atom_factory.CreateAtomFromStream(stream,
- bytes_available,
- atom,
- this))) {
- m_Children.Add(atom);
- }
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_DrefAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_DrefAtom::WriteFields(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- // write the number of entries
- result = stream.WriteUI32(m_Children.ItemCount());
- if (AP4_FAILED(result)) return result;
-
- // write the children
- return m_Children.Apply(AP4_AtomListWriter(stream));
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4DrefAtom.h b/src/thirdparty/Bento4/Core/Ap4DrefAtom.h
deleted file mode 100644
index 55679f0be..000000000
--- a/src/thirdparty/Bento4/Core/Ap4DrefAtom.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*****************************************************************
-|
-| AP4 - dref Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_DREF_ATOM_H_
-#define _AP4_DREF_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4Array.h"
-#include "Ap4Atom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4ContainerAtom.h"
-
-/*----------------------------------------------------------------------
-| AP4_DrefAtom
-+---------------------------------------------------------------------*/
-class AP4_DrefAtom : public AP4_ContainerAtom
-{
-public:
- // methods
- AP4_DrefAtom(AP4_Atom** refs, AP4_Cardinal refs_count);
- AP4_DrefAtom(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-};
-
-#endif // _AP4_DREF_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4EndaAtom.cpp b/src/thirdparty/Bento4/Core/Ap4EndaAtom.cpp
deleted file mode 100644
index b90ddcd36..000000000
--- a/src/thirdparty/Bento4/Core/Ap4EndaAtom.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-/*****************************************************************
-|
-| AP4 - enda Atom
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-
-#include "Ap4.h"
-#include "Ap4EndaAtom.h"
-
-/*----------------------------------------------------------------------
-| AP4_EndaAtom::AP4_EndaAtom
-+---------------------------------------------------------------------*/
-
-AP4_EndaAtom::AP4_EndaAtom(AP4_Size size,
- AP4_ByteStream& stream)
- : AP4_Atom(AP4_ATOM_TYPE_ENDA)
-{
- size -= AP4_ATOM_HEADER_SIZE;
-
- stream.ReadUI16(m_LittleEndian);
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4EndaAtom.h b/src/thirdparty/Bento4/Core/Ap4EndaAtom.h
deleted file mode 100644
index 8472fc5d2..000000000
--- a/src/thirdparty/Bento4/Core/Ap4EndaAtom.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*****************************************************************
-|
-| AP4 - enda Atom
-|
- ****************************************************************/
-
-#ifndef _AP4_ENDA_ATOM_H_
-#define _AP4_ENDA_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4Atom.h"
-#include "Ap4Types.h"
-
-/*----------------------------------------------------------------------
-| AP4_EndaAtom
-+---------------------------------------------------------------------*/
-class AP4_EndaAtom : public AP4_Atom
-{
-public:
- AP4_EndaAtom(AP4_Size size,
- AP4_ByteStream& stream);
-
- AP4_Result WriteFields(AP4_ByteStream& stream) { return AP4_FAILURE; }
-
- AP4_Atom::Type ReadEndian() const { return m_LittleEndian; }
-
-private:
- AP4_UI16 m_LittleEndian;
-};
-
-#endif // _AP4_ENDA_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4EsDescriptor.cpp b/src/thirdparty/Bento4/Core/Ap4EsDescriptor.cpp
deleted file mode 100644
index 059e15ba9..000000000
--- a/src/thirdparty/Bento4/Core/Ap4EsDescriptor.cpp
+++ /dev/null
@@ -1,205 +0,0 @@
-/*****************************************************************
-|
-| AP4 - ES Descriptors
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4EsDescriptor.h"
-#include "Ap4DescriptorFactory.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_EsDescriptor::AP4_EsDescriptor
-+---------------------------------------------------------------------*/
-AP4_EsDescriptor::AP4_EsDescriptor(AP4_UI16 es_id) :
- AP4_Descriptor(AP4_DESCRIPTOR_TAG_ES, 2, 2+1),
- m_EsId(es_id),
- m_OcrEsId(0),
- m_Flags(0),
- m_StreamPriority(0),
- m_DependsOn(0)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_EsDescriptor::AP4_EsDescriptor
-+---------------------------------------------------------------------*/
-AP4_EsDescriptor::AP4_EsDescriptor(AP4_ByteStream& stream,
- AP4_Size header_size,
- AP4_Size payload_size) :
- AP4_Descriptor(AP4_DESCRIPTOR_TAG_ES, header_size, payload_size)
-{
- AP4_Offset start;
- stream.Tell(start);
-
- // read descriptor fields
- stream.ReadUI16(m_EsId);
- unsigned char bits;
- stream.ReadUI08(bits);
- m_Flags = (bits>>5)&7;
- m_StreamPriority = bits&0x1F;
- if (m_Flags & AP4_ES_DESCRIPTOR_FLAG_STREAM_DEPENDENCY) {
- stream.ReadUI16(m_DependsOn);
- } else {
- m_DependsOn = 0;
- }
- if (m_Flags & AP4_ES_DESCRIPTOR_FLAG_URL) {
- unsigned char url_length;
- stream.ReadUI08(url_length);
- if (url_length) {
- char* url = new char[url_length+1];
- if (url) {
- stream.Read(url, url_length, NULL);
- url[url_length] = '\0';
- m_Url = url;
- delete[] url;
- }
- }
- }
- if (m_Flags & AP4_ES_DESCRIPTOR_FLAG_URL) {
- stream.ReadUI16(m_OcrEsId);
- } else {
- m_OcrEsId = 0;
- }
-
- // read other descriptors
- AP4_Offset offset;
- stream.Tell(offset);
- AP4_SubStream* substream = new AP4_SubStream(stream, offset,
- payload_size-(offset-start));
- AP4_Descriptor* descriptor = NULL;
- while (AP4_DescriptorFactory::CreateDescriptorFromStream(*substream,
- descriptor)
- == AP4_SUCCESS) {
- m_SubDescriptors.Add(descriptor);
- }
- substream->Release();
-}
-
-/*----------------------------------------------------------------------
-| AP4_EsDescriptor::~AP4_EsDescriptor
-+---------------------------------------------------------------------*/
-AP4_EsDescriptor::~AP4_EsDescriptor()
-{
- m_SubDescriptors.DeleteReferences();
-}
-
-/*----------------------------------------------------------------------
-| AP4_EsDescriptor::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_EsDescriptor::WriteFields(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- // es id
- result = stream.WriteUI16(m_EsId);
- if (AP4_FAILED(result)) return result;
-
- // flags and other bits
- AP4_UI08 bits = m_StreamPriority | (AP4_UI08)(m_Flags<<5);
- result = stream.WriteUI08(bits);
- if (AP4_FAILED(result)) return result;
-
- // optional fields
- if (m_Flags & AP4_ES_DESCRIPTOR_FLAG_STREAM_DEPENDENCY) {
- result = stream.WriteUI16(m_DependsOn);
- if (AP4_FAILED(result)) return result;
- }
- if (m_Flags & AP4_ES_DESCRIPTOR_FLAG_URL) {
- result = stream.WriteUI08(m_Url.length());
- if (AP4_FAILED(result)) return result;
- result = stream.WriteString(m_Url.c_str());
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI08(0);
- if (AP4_FAILED(result)) return result;
- }
- if (m_Flags & AP4_ES_DESCRIPTOR_FLAG_OCR_STREAM) {
- result = stream.WriteUI16(m_OcrEsId);
- if (AP4_FAILED(result)) return result;
- }
-
- // write the sub descriptors
- m_SubDescriptors.Apply(AP4_DescriptorListWriter(stream));
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_EsDescriptor::Inspect
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_EsDescriptor::Inspect(AP4_AtomInspector& inspector)
-{
- char info[64];
- AP4_StringFormat(info, sizeof(info), "size=%ld+%ld",
- GetHeaderSize(),m_PayloadSize);
- inspector.StartElement("#[ES]", info);
- inspector.AddField("es_id", m_EsId);
- inspector.AddField("stream_priority", m_StreamPriority);
-
- // inspect children
- m_SubDescriptors.Apply(AP4_DescriptorListInspector(inspector));
-
- inspector.EndElement();
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_EsDescriptor::AddSubDescriptor
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_EsDescriptor::AddSubDescriptor(AP4_Descriptor* descriptor)
-{
- m_SubDescriptors.Add(descriptor);
- m_PayloadSize += descriptor->GetSize();
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_EsDescriptor::GetDecoderConfigDescriptor
-+---------------------------------------------------------------------*/
-const AP4_DecoderConfigDescriptor*
-AP4_EsDescriptor::GetDecoderConfigDescriptor() const
-{
- // find the decoder config descriptor
- AP4_Descriptor* descriptor = NULL;
- AP4_Result result =
- m_SubDescriptors.Find(AP4_DescriptorFinder(AP4_DESCRIPTOR_TAG_DECODER_CONFIG),
- descriptor);
-
- // return it
- if (AP4_SUCCEEDED(result)) {
- return dynamic_cast<AP4_DecoderConfigDescriptor*>(descriptor);
- } else {
- return NULL;
- }
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4EsDescriptor.h b/src/thirdparty/Bento4/Core/Ap4EsDescriptor.h
deleted file mode 100644
index e52b67d1d..000000000
--- a/src/thirdparty/Bento4/Core/Ap4EsDescriptor.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*****************************************************************
-|
-| AP4 - ES Descriptor
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_ES_DESCRIPTOR_H_
-#define _AP4_ES_DESCRIPTOR_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4List.h"
-#include "Ap4Descriptor.h"
-#include "Ap4DecoderConfigDescriptor.h"
-
-/*----------------------------------------------------------------------
-| constants
-+---------------------------------------------------------------------*/
-const AP4_Descriptor::Tag AP4_DESCRIPTOR_TAG_ES = 0x03;
-
-const int AP4_ES_DESCRIPTOR_FLAG_STREAM_DEPENDENCY = 1;
-const int AP4_ES_DESCRIPTOR_FLAG_URL = 2;
-const int AP4_ES_DESCRIPTOR_FLAG_OCR_STREAM = 4;
-
-/*----------------------------------------------------------------------
-| AP4_EsDescriptor
-+---------------------------------------------------------------------*/
-class AP4_EsDescriptor : public AP4_Descriptor
-{
- public:
- // methods
- AP4_EsDescriptor(AP4_UI16 es_id);
- AP4_EsDescriptor(AP4_ByteStream& stream,
- AP4_Size header_size,
- AP4_Size payload_size);
- ~AP4_EsDescriptor();
- virtual AP4_Result AddSubDescriptor(AP4_Descriptor* descriptor);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
- virtual const AP4_DecoderConfigDescriptor* GetDecoderConfigDescriptor() const;
-
- private:
- // members
- unsigned short m_EsId;
- unsigned short m_OcrEsId;
- AP4_Flags m_Flags;
- unsigned char m_StreamPriority;
- unsigned short m_DependsOn;
- AP4_String m_Url;
- mutable AP4_List<AP4_Descriptor> m_SubDescriptors;
-};
-
-#endif // _AP4_ES_DESCRIPTOR_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4EsdsAtom.cpp b/src/thirdparty/Bento4/Core/Ap4EsdsAtom.cpp
deleted file mode 100644
index 7be18b6f8..000000000
--- a/src/thirdparty/Bento4/Core/Ap4EsdsAtom.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/*****************************************************************
-|
-| AP4 - esds Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4EsdsAtom.h"
-#include "Ap4DescriptorFactory.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_EsdsAtom::AP4_EsdsAtom
-+---------------------------------------------------------------------*/
-AP4_EsdsAtom::AP4_EsdsAtom(AP4_EsDescriptor* descriptor) :
- AP4_Atom(AP4_ATOM_TYPE_ESDS, AP4_FULL_ATOM_HEADER_SIZE, true),
- m_EsDescriptor(descriptor)
-{
- if (m_EsDescriptor) m_Size += m_EsDescriptor->GetSize();
-}
-
-/*----------------------------------------------------------------------
-| AP4_EsdsAtom::AP4_EsdsAtom
-+---------------------------------------------------------------------*/
-AP4_EsdsAtom::AP4_EsdsAtom(AP4_Size size, AP4_ByteStream& stream) :
- AP4_Atom(AP4_ATOM_TYPE_ESDS, size, true, stream)
-{
- // read descriptor
- AP4_Descriptor* descriptor = NULL;
- if (AP4_DescriptorFactory::CreateDescriptorFromStream(stream, descriptor)
- == AP4_SUCCESS) {
- m_EsDescriptor = dynamic_cast<AP4_EsDescriptor*>(descriptor);
- } else {
- m_EsDescriptor = NULL;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_EsdsAtom::~AP4_EsdsAtom
-+---------------------------------------------------------------------*/
-AP4_EsdsAtom::~AP4_EsdsAtom()
-{
- delete m_EsDescriptor;
-}
-
-/*----------------------------------------------------------------------
-| AP4_EsdsAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_EsdsAtom::WriteFields(AP4_ByteStream& stream)
-{
- // write the es descriptor
- if (m_EsDescriptor) return m_EsDescriptor->Write(stream);
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_EsdsAtom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_EsdsAtom::InspectFields(AP4_AtomInspector& inspector)
-{
- // inspect descriptor
- if (m_EsDescriptor) {
- m_EsDescriptor->Inspect(inspector);
- }
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4EsdsAtom.h b/src/thirdparty/Bento4/Core/Ap4EsdsAtom.h
deleted file mode 100644
index 2e3a114cd..000000000
--- a/src/thirdparty/Bento4/Core/Ap4EsdsAtom.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*****************************************************************
-|
-| AP4 - esds Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_ESDS_ATOM_H_
-#define _AP4_ESDS_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4List.h"
-#include "Ap4Atom.h"
-#include "Ap4EsDescriptor.h"
-#include "Ap4AtomFactory.h"
-
-/*----------------------------------------------------------------------
-| AP4_EsdsAtom
-+---------------------------------------------------------------------*/
-class AP4_EsdsAtom : public AP4_Atom
-{
- public:
- // methods
- AP4_EsdsAtom(AP4_EsDescriptor* descriptor);
- AP4_EsdsAtom(AP4_Size size, AP4_ByteStream& stream);
- ~AP4_EsdsAtom();
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- const AP4_EsDescriptor* GetEsDescriptor() const { return m_EsDescriptor; }
-
- private:
- // members
- AP4_EsDescriptor* m_EsDescriptor;
-};
-
-#endif // _AP4_ESDS_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4File.cpp b/src/thirdparty/Bento4/Core/Ap4File.cpp
deleted file mode 100644
index a2cd5341e..000000000
--- a/src/thirdparty/Bento4/Core/Ap4File.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/*****************************************************************
-|
-| AP4 - File
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4File.h"
-#include "Ap4Atom.h"
-#include "Ap4TrakAtom.h"
-#include "Ap4MoovAtom.h"
-#include "Ap4MvhdAtom.h"
-#include "Ap4AtomFactory.h"
-/*----------------------------------------------------------------------
-| AP4_File::AP4_File
-+---------------------------------------------------------------------*/
-AP4_File::AP4_File(AP4_Movie* movie) :
- m_Movie(movie)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_File::AP4_File
-+---------------------------------------------------------------------*/
-AP4_File::AP4_File(AP4_ByteStream& stream, AP4_AtomFactory& atom_factory) :
- m_Movie(NULL)
-{
- // get all atoms
- AP4_Atom* atom;
- while (AP4_SUCCEEDED(atom_factory.CreateAtomFromStream(stream, atom))) {
- switch (atom->GetType()) {
- case AP4_ATOM_TYPE_MOOV:
- m_Movie = new AP4_Movie(dynamic_cast<AP4_MoovAtom*>(atom),
- stream);
- break;
- case AP4_ATOM_TYPE_FTYP:
- //m_Movie = new AP4_Movie(dynamic_cast<AP4_FtypAtom*>(atom), stream);
- m_FileType = dynamic_cast<AP4_FtypAtom*>(atom);
- default:
- m_OtherAtoms.Add(atom);
- }
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_File::~AP4_File
-+---------------------------------------------------------------------*/
-AP4_File::~AP4_File()
-{
- delete m_Movie;
- m_OtherAtoms.DeleteReferences();
-}
-
-/*----------------------------------------------------------------------
-| AP4_File::Inspect
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_File::Inspect(AP4_AtomInspector& inspector)
-{
- // dump the moov atom first
- if (m_Movie) m_Movie->Inspect(inspector);
-
- // dump the other atoms
- m_OtherAtoms.Apply(AP4_AtomListInspector(inspector));
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4File.h b/src/thirdparty/Bento4/Core/Ap4File.h
deleted file mode 100644
index 351ea6304..000000000
--- a/src/thirdparty/Bento4/Core/Ap4File.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*****************************************************************
-|
-| AP4 - File
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_FILE_H_
-#define _AP4_FILE_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4Atom.h"
-#include "Ap4Track.h"
-#include "Ap4List.h"
-#include "Ap4Movie.h"
-#include "Ap4ByteStream.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4FtypAtom.h"
-
-/*----------------------------------------------------------------------
-| AP4_File
-+---------------------------------------------------------------------*/
-class AP4_File {
-public:
- // constructors and destructor
- AP4_File(AP4_Movie* movie);
- AP4_File(AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory = AP4_AtomFactory::DefaultFactory);
- virtual ~AP4_File();
-
- // methods
- AP4_List<AP4_Atom>& GetOtherAtoms() { return m_OtherAtoms;}
- AP4_Movie* GetMovie() { return m_Movie; }
- AP4_FtypAtom* GetFileType() { return m_FileType; }
- virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
-
-private:
- // members
- AP4_Movie* m_Movie;
- AP4_FtypAtom* m_FileType;
- AP4_List<AP4_Atom> m_OtherAtoms;
-};
-
-#endif // _AP4_FILE_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4FileByteStream.h b/src/thirdparty/Bento4/Core/Ap4FileByteStream.h
deleted file mode 100644
index 564813597..000000000
--- a/src/thirdparty/Bento4/Core/Ap4FileByteStream.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*****************************************************************
-|
-| AP4 - FileByteStream
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-
-#ifndef _AP4_FILE_BYTE_STREAM_H_
-#define _AP4_FILE_BYTE_STREAM_H_
-
-/*----------------------------------------------------------------------
-| AP4_FileByteStream
-+---------------------------------------------------------------------*/
-class AP4_FileByteStream: public AP4_ByteStream
-{
-public:
- // types
- typedef enum {
- STREAM_MODE_READ,
- STREAM_MODE_WRITE
- } Mode;
-
- // methods
- AP4_FileByteStream(const char* name, Mode mode);
-
- // AP4_ByteStream methods
- AP4_Result Read(void* buffer,
- AP4_Size bytesToRead,
- AP4_Size* bytesRead) {
- return m_Delegate->Read(buffer, bytesToRead, bytesRead);
- }
- AP4_Result Write(const void* buffer,
- AP4_Size bytesToWrite,
- AP4_Size* bytesWritten) {
- return m_Delegate->Write(buffer, bytesToWrite, bytesWritten);
- }
- AP4_Result Seek(AP4_Offset offset) { return m_Delegate->Seek(offset); }
- AP4_Result Tell(AP4_Offset& offset) { return m_Delegate->Tell(offset); }
- AP4_Result GetSize(AP4_Size& size) { return m_Delegate->GetSize(size);}
-
- // AP4_Referenceable methods
- void AddReference() { m_Delegate->AddReference(); }
- void Release() { m_Delegate->Release(); }
-
-protected:
- // methods
- virtual ~AP4_FileByteStream() {
- delete m_Delegate;
- }
-
- // members
- AP4_ByteStream* m_Delegate;
-};
-
-#endif // _AP4_FILE_BYTE_STREAM_H_
-
-
-
-
-
-
-
-
diff --git a/src/thirdparty/Bento4/Core/Ap4FileWriter.cpp b/src/thirdparty/Bento4/Core/Ap4FileWriter.cpp
deleted file mode 100644
index 39cc3e1f2..000000000
--- a/src/thirdparty/Bento4/Core/Ap4FileWriter.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/*****************************************************************
-|
-| AP4 - File Writer
-|
-| Copyright 2002-2005 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4MoovAtom.h"
-#include "Ap4FileWriter.h"
-
-/*----------------------------------------------------------------------
-| AP4_FileWriter::AP4_FileWriter
-+---------------------------------------------------------------------*/
-AP4_FileWriter::AP4_FileWriter(AP4_File& file) : m_File(file)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_FileWriter::~AP4_FileWriter
-+---------------------------------------------------------------------*/
-AP4_FileWriter::~AP4_FileWriter()
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_FileWriter::Write
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_FileWriter::Write(AP4_ByteStream& stream)
-{
- //AP4_Result result;
-
- // get the movie object
- AP4_Movie* movie = m_File.GetMovie();
- if (movie == NULL) return AP4_SUCCESS;
-
- // compute the final offset of the sample data in mdat
- AP4_Offset data_offset = movie->GetMoovAtom()->GetSize()+AP4_ATOM_HEADER_SIZE;
-
- // adjust the tracks
- AP4_List<AP4_Track>::Item* track_item = movie->GetTracks().FirstItem();
- while (track_item) {
- AP4_Track* track = track_item->GetData();
- track->GetTrakAtom()->AdjustChunkOffsets(data_offset);
- track_item = track_item->GetNext();
- }
-
- // write the moov atom
- movie->GetMoovAtom()->Write(stream);
-
- // create an mdat
- stream.WriteUI32(0);
- stream.Write("mdat", 4);
- AP4_Track* track = movie->GetTracks().FirstItem()->GetData();
- AP4_Cardinal sample_count = track->GetSampleCount();
- for (AP4_Ordinal i=0; i<sample_count; i++) {
- AP4_Sample sample;
- AP4_DataBuffer data;
- track->ReadSample(i, sample, data);
- stream.Write(data.GetData(), data.GetDataSize());
- }
-
- // TODO: update the mdat size
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4FileWriter.h b/src/thirdparty/Bento4/Core/Ap4FileWriter.h
deleted file mode 100644
index b8f5b3df8..000000000
--- a/src/thirdparty/Bento4/Core/Ap4FileWriter.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*****************************************************************
-|
-| AP4 - File Writer
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_FILE_WRITER_H_
-#define _AP4_FILE_WRITER_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4Atom.h"
-#include "Ap4Track.h"
-#include "Ap4List.h"
-#include "Ap4ByteStream.h"
-#include "Ap4File.h"
-
-/*----------------------------------------------------------------------
-| AP4_FileWriter
-+---------------------------------------------------------------------*/
-class AP4_FileWriter {
- public:
- // constructors and destructor
- AP4_FileWriter(AP4_File& file);
- virtual ~AP4_FileWriter();
-
- // methods
- AP4_Result Write(AP4_ByteStream& stream);
-
- private:
- AP4_File& m_File;
-};
-
-#endif // _AP4_FILE_WRITER_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4FrmaAtom.cpp b/src/thirdparty/Bento4/Core/Ap4FrmaAtom.cpp
deleted file mode 100644
index 41a8a92f0..000000000
--- a/src/thirdparty/Bento4/Core/Ap4FrmaAtom.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*****************************************************************
-|
-| AP4 - frma Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4FrmaAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_FrmaAtom::AP4_FrmaAtom
-+---------------------------------------------------------------------*/
-AP4_FrmaAtom::AP4_FrmaAtom(AP4_UI32 original_format) :
- AP4_Atom(AP4_ATOM_TYPE_FRMA, AP4_ATOM_HEADER_SIZE+4, false),
- m_OriginalFormat(original_format)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_FrmaAtom::AP4_FrmaAtom
-+---------------------------------------------------------------------*/
-AP4_FrmaAtom::AP4_FrmaAtom(AP4_Size size, AP4_ByteStream& stream) :
- AP4_Atom(AP4_ATOM_TYPE_FRMA, size, false, stream)
-{
- stream.ReadUI32(m_OriginalFormat);
-}
-
-/*----------------------------------------------------------------------
-| AP4_FrmaAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_FrmaAtom::WriteFields(AP4_ByteStream& stream)
-{
- // write the original format
- return stream.WriteUI32(m_OriginalFormat);
-}
-
-/*----------------------------------------------------------------------
-| AP4_FrmaAtom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_FrmaAtom::InspectFields(AP4_AtomInspector& inspector)
-{
- char format[5];
- AP4_FormatFourChars(format, m_OriginalFormat);
- inspector.AddField("original_format", format);
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4FrmaAtom.h b/src/thirdparty/Bento4/Core/Ap4FrmaAtom.h
deleted file mode 100644
index 8e15d7654..000000000
--- a/src/thirdparty/Bento4/Core/Ap4FrmaAtom.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*****************************************************************
-|
-| AP4 - frma Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_FRMA_ATOM_H_
-#define _AP4_FRMA_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4List.h"
-#include "Ap4Atom.h"
-
-/*----------------------------------------------------------------------
-| AP4_FrmaAtom
-+---------------------------------------------------------------------*/
-class AP4_FrmaAtom : public AP4_Atom
-{
- public:
- // constructors
- AP4_FrmaAtom(AP4_Size size, AP4_ByteStream& stream);
- AP4_FrmaAtom(AP4_UI32 original_format);
-
- // methods
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- AP4_UI32 GetOriginalFormat() { return m_OriginalFormat; }
-
- private:
- // members
- AP4_UI32 m_OriginalFormat;
-};
-
-#endif // _AP4_FRMA_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4FtabAtom.cpp b/src/thirdparty/Bento4/Core/Ap4FtabAtom.cpp
deleted file mode 100644
index 77fda4e43..000000000
--- a/src/thirdparty/Bento4/Core/Ap4FtabAtom.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*****************************************************************
-|
-| AP4 - ftab Atom
-|
-| Copyright 2002 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-
-#include "Ap4.h"
-#include "Ap4FtabAtom.h"
-
-/*----------------------------------------------------------------------
-| AP4_FtabAtom::AP4_FtabAtom
-+---------------------------------------------------------------------*/
-
-AP4_FtabAtom::AP4_FtabAtom(AP4_Size size,
- AP4_ByteStream& stream)
- : AP4_Atom(AP4_ATOM_TYPE_FTAB)
-{
- AP4_UI16 entryCount;
- stream.ReadUI16(entryCount);
-
- m_FontRecords.EnsureCapacity(entryCount);
-
- while(entryCount--)
- {
- AP4_Tx3gFontRecord fontRecord;
-
- stream.ReadUI16(fontRecord.Id);
-
- AP4_UI08 len;
- stream.ReadUI08(len);
-
- char buff[256];
- stream.ReadString(buff, len+1);
-
- fontRecord.Name = buff;
-
- m_FontRecords.Append(fontRecord);
- }
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4FtabAtom.h b/src/thirdparty/Bento4/Core/Ap4FtabAtom.h
deleted file mode 100644
index 3f401c9fb..000000000
--- a/src/thirdparty/Bento4/Core/Ap4FtabAtom.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*****************************************************************
-|
-| AP4 - ftab Atom
-|
-| Copyright 2002 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_FTAB_ATOM_H_
-#define _AP4_FTAB_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4Atom.h"
-#include "Ap4Types.h"
-#include "Ap4Array.h"
-
-/*----------------------------------------------------------------------
-| AP4_FtabAtom
-+---------------------------------------------------------------------*/
-class AP4_FtabAtom : public AP4_Atom
-{
-public:
- AP4_FtabAtom(AP4_Size size,
- AP4_ByteStream& stream);
-
- AP4_Result WriteFields(AP4_ByteStream& stream) { return AP4_FAILURE; }
-
- struct AP4_Tx3gFontRecord
- {
- AP4_UI16 Id;
- AP4_String Name;
- };
-
- AP4_Array<AP4_Tx3gFontRecord>& GetFontRecords() { return m_FontRecords; }
-
- AP4_Result LookupFont(AP4_UI16 Id, AP4_String& Name)
- {
- for(unsigned long i = 0; i < m_FontRecords.ItemCount(); i++)
- {
- if(m_FontRecords[i].Id == Id)
- {
- Name = m_FontRecords[i].Name;
- return AP4_SUCCESS;
- }
- }
-
- return AP4_FAILURE;
- }
-
-private:
-
- // members
- AP4_Array<AP4_Tx3gFontRecord> m_FontRecords;
-};
-
-#endif // _AP4_FTAB_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4FtypAtom.cpp b/src/thirdparty/Bento4/Core/Ap4FtypAtom.cpp
deleted file mode 100644
index a08637dbf..000000000
--- a/src/thirdparty/Bento4/Core/Ap4FtypAtom.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*****************************************************************
-|
-| AP4 - ftyp Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4FtypAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_FtypAtom::AP4_FtypAtom
-+---------------------------------------------------------------------*/
-AP4_FtypAtom::AP4_FtypAtom(AP4_Size size, AP4_ByteStream& stream) :
- AP4_Atom(AP4_ATOM_TYPE_FTYP, size, false, stream)
-{
- stream.ReadUI32(m_MajorBrand);
- stream.ReadUI32(m_MinorVersion);
- size -= 16;
- while (size) {
- AP4_UI32 compatible_brand;
- stream.ReadUI32(compatible_brand);
- m_CompatibleBrands.Append(compatible_brand);
- size -= 4;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_FtypAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_FtypAtom::WriteFields(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- // major brand
- result = stream.WriteUI32(m_MajorBrand);
- if (AP4_FAILED(result)) return result;
-
- // minor version
- result = stream.WriteUI32(m_MinorVersion);
- if (AP4_FAILED(result)) return result;
-
- // compatible brands
- AP4_Cardinal compat_brand_count = m_CompatibleBrands.ItemCount();
- for (AP4_Ordinal i=0; i<compat_brand_count; i++) {
- result = stream.WriteUI32(m_CompatibleBrands[i]);
- if (AP4_FAILED(result)) return result;
- }
-
- return result;
-}
-
-/*----------------------------------------------------------------------
-| AP4_FtypAtom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_FtypAtom::InspectFields(AP4_AtomInspector& inspector)
-{
- char name[5];
- AP4_FormatFourChars(name, m_MajorBrand);
- inspector.AddField("major_brand", name);
- inspector.AddField("minor_version", m_MinorVersion);
-
- // compatible brands
- for (unsigned int i=0; i<m_CompatibleBrands.ItemCount(); i++) {
- AP4_UI32 cb = m_CompatibleBrands[i];
- AP4_FormatFourChars(name, cb);
- inspector.AddField("compatible_brand", name);
- }
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4FtypAtom.h b/src/thirdparty/Bento4/Core/Ap4FtypAtom.h
deleted file mode 100644
index 0eec5905b..000000000
--- a/src/thirdparty/Bento4/Core/Ap4FtypAtom.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*****************************************************************
-|
-| AP4 - ftyp Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_FTYP_ATOM_H_
-#define _AP4_FTYP_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4List.h"
-#include "Ap4Atom.h"
-#include "Ap4Array.h"
-
-/*----------------------------------------------------------------------
-| AP4_FtypAtom
-+---------------------------------------------------------------------*/
-class AP4_FtypAtom : public AP4_Atom
-{
- public:
- // methods
- AP4_FtypAtom(AP4_Size size, AP4_ByteStream& stream);
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
- private:
- // members
- AP4_UI32 m_MajorBrand;
- AP4_UI32 m_MinorVersion;
- AP4_Array<AP4_UI32> m_CompatibleBrands;
-};
-
-#endif // _AP4_FTYP_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4HdlrAtom.cpp b/src/thirdparty/Bento4/Core/Ap4HdlrAtom.cpp
deleted file mode 100644
index b007c2ce6..000000000
--- a/src/thirdparty/Bento4/Core/Ap4HdlrAtom.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/*****************************************************************
-|
-| AP4 - hdlr Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4HdlrAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_HdlrAtom::AP4_HdlrAtom
-+---------------------------------------------------------------------*/
-AP4_HdlrAtom::AP4_HdlrAtom(AP4_Atom::Type hdlr_type, const char* hdlr_name) :
- AP4_Atom(AP4_ATOM_TYPE_HDLR, true),
- m_HandlerType(hdlr_type),
- m_HandlerName(hdlr_name)
-{
- m_Size += 20+m_HandlerName.length()+1;
-}
-
-/*----------------------------------------------------------------------
-| AP4_HdlrAtom::AP4_HdlrAtom
-+---------------------------------------------------------------------*/
-AP4_HdlrAtom::AP4_HdlrAtom(AP4_Size size, AP4_ByteStream& stream) :
- AP4_Atom(AP4_ATOM_TYPE_HDLR, size, true, stream)
-{
- unsigned char reserved[12];
- stream.Read(reserved, 4, NULL);
- stream.ReadUI32(m_HandlerType);
- stream.Read(reserved, 12, NULL);
-
- // read the name unless it is empty
- int name_size = size-(AP4_FULL_ATOM_HEADER_SIZE+20);
- if (name_size > 0) {
- char* name = new char[name_size+1];
- stream.Read(name, name_size);
- name[name_size] = '\0'; // force a null termination
- m_HandlerName = name;
- delete[] name;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_HdlrAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_HdlrAtom::WriteFields(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- // write the data
- unsigned char reserved[12];
- memset(reserved, 0, sizeof(reserved));
- result = stream.Write(reserved, 4);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI32(m_HandlerType);
- if (AP4_FAILED(result)) return result;
- result = stream.Write(reserved, 12);
- if (AP4_FAILED(result)) return result;
- result = stream.Write(m_HandlerName.c_str(),
- m_HandlerName.length()+1);
- if (AP4_FAILED(result)) return result;
-
- // pad with zeros if necessary
- AP4_Size padding = m_Size-(AP4_FULL_ATOM_HEADER_SIZE+20+m_HandlerName.length()+1);
- while (padding--) stream.WriteUI08(0);
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_HdlrAtom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_HdlrAtom::InspectFields(AP4_AtomInspector& inspector)
-{
- char type[5];
- AP4_FormatFourChars(type, m_HandlerType);
- inspector.AddField("handler_type", type);
- inspector.AddField("handler_name", m_HandlerName.c_str());
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4HdlrAtom.h b/src/thirdparty/Bento4/Core/Ap4HdlrAtom.h
deleted file mode 100644
index 18a073138..000000000
--- a/src/thirdparty/Bento4/Core/Ap4HdlrAtom.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*****************************************************************
-|
-| AP4 - hdlr Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_HDLR_ATOM_H_
-#define _AP4_HDLR_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4List.h"
-#include "Ap4Atom.h"
-
-/*----------------------------------------------------------------------
-| constants
-+---------------------------------------------------------------------*/
-const AP4_UI32 AP4_HANDLER_TYPE_SOUN = AP4_ATOM_TYPE('s','o','u','n');
-const AP4_UI32 AP4_HANDLER_TYPE_VIDE = AP4_ATOM_TYPE('v','i','d','e');
-const AP4_UI32 AP4_HANDLER_TYPE_TEXT = AP4_ATOM_TYPE('t','e','x','t');
-const AP4_UI32 AP4_HANDLER_TYPE_TX3G = AP4_ATOM_TYPE('t','x','3','g');
-const AP4_UI32 AP4_HANDLER_TYPE_SUBP = AP4_ATOM_TYPE('s','u','b','p');
-const AP4_UI32 AP4_HANDLER_TYPE_HINT = AP4_ATOM_TYPE('h','i','n','t');
-const AP4_UI32 AP4_HANDLER_TYPE_SBTL = AP4_ATOM_TYPE('s','b','t','l');
-
-/*----------------------------------------------------------------------
-| AP4_HdlrAtom
-+---------------------------------------------------------------------*/
-class AP4_HdlrAtom : public AP4_Atom
-{
-public:
- // methods
- AP4_HdlrAtom(AP4_UI32 hdlr_type, const char* hdlr_name);
- AP4_HdlrAtom(AP4_Size size, AP4_ByteStream& stream);
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
- AP4_UI32 GetHandlerType() { return m_HandlerType; }
- AP4_String GetHandlerName() { return m_HandlerName; }
-
-private:
- // members
- AP4_UI32 m_HandlerType;
- AP4_String m_HandlerName;
-};
-
-#endif // _AP4_HDLR_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4HintTrackReader.cpp b/src/thirdparty/Bento4/Core/Ap4HintTrackReader.cpp
deleted file mode 100644
index 27fa08710..000000000
--- a/src/thirdparty/Bento4/Core/Ap4HintTrackReader.cpp
+++ /dev/null
@@ -1,324 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Hint Track Reader
-|
-| Copyright 2002-2005 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include <stdlib.h>
-#include <time.h>
-#include "Ap4HintTrackReader.h"
-#include "Ap4DataBuffer.h"
-#include "Ap4Track.h"
-#include "Ap4Movie.h"
-#include "Ap4SdpAtom.h"
-#include "Ap4RtpHint.h"
-#include "Ap4TrakAtom.h"
-#include "Ap4TrefTypeAtom.h"
-#include "Ap4TimsAtom.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_HintTrackReader::AP4_HintTrackReader
-+---------------------------------------------------------------------*/
-AP4_HintTrackReader::AP4_HintTrackReader(AP4_Track& hint_track,
- AP4_Movie& movie,
- AP4_UI32 ssrc /* = 0 */) :
- m_HintTrack(hint_track),
- m_MediaTrack(NULL),
- m_MediaTimeScale(0),
- m_RtpSampleData(NULL),
- m_Ssrc(ssrc),
- m_SampleIndex(0),
- m_PacketIndex(0),
- m_RtpSequenceStart(0),
- m_RtpTimeStampStart(0),
- m_RtpTimeScale(0)
-{
- // check the type
- if (m_HintTrack.GetType() != AP4_Track::TYPE_HINT)
- throw AP4_Exception(AP4_ERROR_INVALID_TRACK_TYPE);
-
- // get the media track
- AP4_TrakAtom* hint_trak_atom = hint_track.GetTrakAtom();
- AP4_Atom* atom = hint_trak_atom->FindChild("tref/hint");
- if (atom != NULL) {
- AP4_UI32 media_track_id = ((AP4_TrefTypeAtom*) atom)->m_TrackIds[0];
- m_MediaTrack = movie.GetTrack(media_track_id);
-
- // get the media time scale
- m_MediaTimeScale = m_MediaTrack->GetMediaTimeScale();
- }
-
- // initiate random generator
- srand(time(NULL));
-
- // rtp sequence start init TODO!!
- m_RtpSequenceStart = rand();
-
- // rtp timestamp start init TODO!!
- m_RtpTimeStampStart = rand();
-
- // rtp time scale
- atom = hint_trak_atom->FindChild("mdia/minf/stbl/rtp /tims");
- if (atom) {
- AP4_TimsAtom* tims = (AP4_TimsAtom*)atom;
- m_RtpTimeScale = tims->GetTimeScale();
- }
-
- // generate a random ssrc if = 0
- if (m_Ssrc == 0) {
- m_Ssrc = rand();
- }
-
- // get the first sample
- GetRtpSample(0);
-}
-
-/*----------------------------------------------------------------------
-| AP4_HintTrackReader::~AP4_HintTrackReader
-+---------------------------------------------------------------------*/
-AP4_HintTrackReader::~AP4_HintTrackReader()
-{
- delete m_RtpSampleData;
-}
-
-/*----------------------------------------------------------------------
-| AP4_HintTrackReader::GetRtpSample
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_HintTrackReader::GetRtpSample(AP4_Ordinal index)
-{
- // get the sample
- AP4_Result result = m_HintTrack.GetSample(index, m_CurrentHintSample);
- if (AP4_FAILED(result)) return result;
-
- // renew the sample data
- delete m_RtpSampleData;
- AP4_ByteStream& rtp_data_stream = *m_CurrentHintSample.GetDataStream();
- rtp_data_stream.Seek(m_CurrentHintSample.GetOffset());
- m_RtpSampleData = new AP4_RtpSampleData(rtp_data_stream,
- m_CurrentHintSample.GetSize());
-
- // reinit the packet index
- m_PacketIndex = 0;
-
- // release the stream
- rtp_data_stream.Release();
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_HintTrackReader::GetCurrentTimeStampMs
-+---------------------------------------------------------------------*/
-AP4_TimeStamp
-AP4_HintTrackReader::GetCurrentTimeStampMs()
-{
- return AP4_ConvertTime(m_CurrentHintSample.GetCts(),
- m_HintTrack.GetMediaTimeScale(),
- 1000);
-}
-
-/*----------------------------------------------------------------------
-| AP4_HintTrackReader::Rewind
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_HintTrackReader::Rewind()
-{
- m_SampleIndex = 0;
- return GetRtpSample(m_SampleIndex);
-}
-
-/*----------------------------------------------------------------------
-| AP4_HintTrackReader::GetSdpText
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_HintTrackReader::GetSdpText(AP4_String& sdp_text)
-{
- AP4_Atom* sdp_atom = m_HintTrack.GetTrakAtom()->FindChild("udta/hnti/sdp ");
- if (sdp_atom == NULL) return AP4_FAILURE;
-
- // C cast is OK because we know the type of the atom
- sdp_text = ((AP4_SdpAtom*) sdp_atom)->GetSdpText();
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_HintTrackReader::SeekToTimeStampMs
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_HintTrackReader::SeekToTimeStampMs(AP4_TimeStamp desired_ts,
- AP4_TimeStamp& actual_ts)
-{
- // get the sample index
- AP4_Cardinal index;
- AP4_Result result = m_HintTrack.GetSampleIndexForTimeStampMs(desired_ts, index);
- if (AP4_FAILED(result)) return result;
-
- // get the current sample based on the index and renew the sample data
- result = GetRtpSample(index);
- if (AP4_FAILED(result)) return result;
-
- // set the actual ts
- actual_ts = GetCurrentTimeStampMs();
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_HintTrackReader::GetNextPacket
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_HintTrackReader::GetNextPacket(AP4_DataBuffer& packet_data,
- AP4_TimeStamp& ts_ms)
-{
- AP4_Result result = AP4_SUCCESS;
-
- // get the next rtp sample if needed
- AP4_List<AP4_RtpPacket>* packets = &m_RtpSampleData->GetPackets();
- while (m_PacketIndex == packets->ItemCount()) { // while: handle the 0 packet case
- result = GetRtpSample(++m_SampleIndex);
- if (AP4_FAILED(result)) return result;
- packets = &m_RtpSampleData->GetPackets();
- }
-
- // get the packet
- AP4_RtpPacket* packet;
- result = packets->Get(m_PacketIndex++, packet);
- if (AP4_FAILED(result)) return result;
-
- // build it
- result = BuildRtpPacket(packet, packet_data);
- if (AP4_FAILED(result)) return result;
-
- // set the time stamp
- ts_ms = GetCurrentTimeStampMs();
-
- return result;
-}
-
-/*----------------------------------------------------------------------
-| AP4_HintTrackReader::BuildRtpPacket
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_HintTrackReader::BuildRtpPacket(AP4_RtpPacket* packet,
- AP4_DataBuffer& packet_data)
-{
- // set the data size
- AP4_Result result = packet_data.SetDataSize(packet->GetConstructedDataSize());
- if (AP4_FAILED(result)) return result;
-
- // now write
- AP4_ByteStream* stream =
- new AP4_MemoryByteStream(packet_data.UseData(), packet_data.GetDataSize());
-
- // header + ssrc
- stream->WriteUI08(0x80 | (packet->GetPBit() << 5) | (packet->GetXBit() << 4));
- stream->WriteUI08((packet->GetMBit() << 7) | packet->GetPayloadType());
- stream->WriteUI16(m_RtpSequenceStart + packet->GetSequenceSeed());
- stream->WriteUI32(m_RtpTimeStampStart + m_CurrentHintSample.GetCts() + packet->GetTimeStampOffset());
- stream->WriteUI32(m_Ssrc);
-
- AP4_List<AP4_RtpConstructor>::Item* constructors_it
- = packet->GetConstructors().FirstItem();
- while (constructors_it != NULL) {
- AP4_RtpConstructor* constructor = constructors_it->GetData();
-
- // add data to the packet according to the constructor
- switch (constructor->GetType()) {
- case AP4_RTP_CONSTRUCTOR_TYPE_NOOP:
- // nothing to do here
- break;
- case AP4_RTP_CONSTRUCTOR_TYPE_IMMEDIATE:
- result = WriteImmediateRtpData(
- (AP4_ImmediateRtpConstructor*) constructor, stream);
- if (AP4_FAILED(result)) return result;
- break;
- case AP4_RTP_CONSTRUCTOR_TYPE_SAMPLE:
- result = WriteSampleRtpData(
- (AP4_SampleRtpConstructor*) constructor, stream);
- if (AP4_FAILED(result)) return result;
- break;
- case AP4_RTP_CONSTRUCTOR_TYPE_SAMPLE_DESC:
- return AP4_ERROR_NOT_SUPPORTED_YET;
- default:
- // unknown constructor type
- return AP4_FAILURE;
- }
-
- // iterate
- constructors_it = constructors_it->GetNext();
- }
-
- // release the stream
- stream->Release();
-
- return result;
-}
-
-/*----------------------------------------------------------------------
-| AP4_HintTrackReader::WriteImmediateRtpData
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_HintTrackReader::WriteImmediateRtpData(AP4_ImmediateRtpConstructor* constructor,
- AP4_ByteStream* data_stream)
-{
- const AP4_DataBuffer& data_buffer = constructor->GetData();
- return data_stream->Write(data_buffer.GetData(), data_buffer.GetDataSize());
-}
-
-/*----------------------------------------------------------------------
-| AP4_HintTrackReader::WriteSampleRtpData
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_HintTrackReader::WriteSampleRtpData(AP4_SampleRtpConstructor* constructor,
- AP4_ByteStream* data_stream)
-{
- AP4_Track* referenced_track = NULL;
- if (constructor->GetTrackRefIndex() == 0xFF) {
- // data is in the hint track
- referenced_track = &m_HintTrack;
- } else {
- // check if we have a media track
- if (m_MediaTrack == NULL) return AP4_FAILURE;
- referenced_track = m_MediaTrack;
- }
-
- // write the sample data
- AP4_Sample sample;
- AP4_Result result = referenced_track->GetSample(constructor->GetSampleNum()-1, // adjust
- sample);
- AP4_DataBuffer buffer(constructor->GetLength());
- result = sample.ReadData(
- buffer, constructor->GetLength(), constructor->GetSampleOffset());
- if (AP4_FAILED(result)) return result;
-
- // write the data
- return data_stream->Write(buffer.GetData(), buffer.GetDataSize());
-}
-
diff --git a/src/thirdparty/Bento4/Core/Ap4HintTrackReader.h b/src/thirdparty/Bento4/Core/Ap4HintTrackReader.h
deleted file mode 100644
index a17aa13ed..000000000
--- a/src/thirdparty/Bento4/Core/Ap4HintTrackReader.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Hint Track Reader
-|
-| Copyright 2002-2005 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-#ifndef _AP4_HINT_TRACK_READER_H_
-#define _AP4_HINT_TRACK_READER_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4Sample.h"
-
-/*----------------------------------------------------------------------
-| class declarations
-+---------------------------------------------------------------------*/
-class AP4_DataBuffer;
-class AP4_Movie;
-class AP4_Track;
-class AP4_RtpSampleData;
-class AP4_RtpPacket;
-class AP4_ImmediateRtpConstructor;
-class AP4_SampleRtpConstructor;
-
-/*----------------------------------------------------------------------
-| AP4_HintTrackReader
-+---------------------------------------------------------------------*/
-class AP4_HintTrackReader
-{
-public:
- // constructor and destructor
- AP4_HintTrackReader(AP4_Track& hint_track,
- AP4_Movie& movie,
- AP4_UI32 ssrc = 0); // if 0, random value is chosen
- ~AP4_HintTrackReader();
-
- // methods
- AP4_Result GetNextPacket(AP4_DataBuffer& packet,
- AP4_TimeStamp& ts_ms);
- AP4_Result SeekToTimeStampMs(AP4_TimeStamp desired_ts,
- AP4_TimeStamp& actual_ts);
- AP4_TimeStamp GetCurrentTimeStampMs();
- AP4_Result Rewind();
- AP4_Result GetSdpText(AP4_String& sdp);
- AP4_Track* GetMediaTrack() { return m_MediaTrack; }
-
-private:
- // methods
- AP4_Result GetRtpSample(AP4_Ordinal index);
- AP4_Result BuildRtpPacket(AP4_RtpPacket* packet,
- AP4_DataBuffer& packet_data);
- AP4_Result WriteImmediateRtpData(AP4_ImmediateRtpConstructor* constructor,
- AP4_ByteStream* data_stream);
- AP4_Result WriteSampleRtpData(AP4_SampleRtpConstructor* constructor,
- AP4_ByteStream* data_stream);
-
- // members
- AP4_Track& m_HintTrack;
- AP4_Track* m_MediaTrack;
- AP4_UI32 m_MediaTimeScale;
- AP4_Sample m_CurrentHintSample;
- AP4_RtpSampleData* m_RtpSampleData;
- AP4_UI32 m_Ssrc;
- AP4_Ordinal m_SampleIndex;
- AP4_Ordinal m_PacketIndex;
- AP4_UI16 m_RtpSequenceStart;
- AP4_TimeStamp m_RtpTimeStampStart;
- AP4_UI32 m_RtpTimeScale;
-};
-
-#endif // _AP4_HINT_TRACK_READER_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4HmhdAtom.cpp b/src/thirdparty/Bento4/Core/Ap4HmhdAtom.cpp
deleted file mode 100644
index cecac40da..000000000
--- a/src/thirdparty/Bento4/Core/Ap4HmhdAtom.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/*****************************************************************
-|
-| AP4 - hmhd Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4HmhdAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_HmhdAtom::AP4_HmhdAtom
-+---------------------------------------------------------------------*/
-AP4_HmhdAtom::AP4_HmhdAtom(AP4_Size size, AP4_ByteStream& stream) :
- AP4_Atom(AP4_ATOM_TYPE_HMHD, size, true, stream)
-{
- stream.ReadUI16(m_MaxPduSize);
- stream.ReadUI16(m_AvgPduSize);
- stream.ReadUI32(m_MaxBitrate);
- stream.ReadUI32(m_AvgBitrate);
- stream.ReadUI32(m_Reserved);
-}
-
-/*----------------------------------------------------------------------
-| AP4_HmhdAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_HmhdAtom::WriteFields(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- // max pdu size
- result = stream.WriteUI16(m_MaxPduSize);
- if (AP4_FAILED(result)) return result;
-
- // avg pdu size
- result = stream.WriteUI16(m_AvgPduSize);
- if (AP4_FAILED(result)) return result;
-
- // max bitrate
- result = stream.WriteUI32(m_MaxBitrate);
- if (AP4_FAILED(result)) return result;
-
- // avg bitrate
- result = stream.WriteUI32(m_AvgBitrate);
- if (AP4_FAILED(result)) return result;
-
- // reserved
- result = stream.WriteUI32(m_Reserved);
- if (AP4_FAILED(result)) return result;
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_HmhdAtom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_HmhdAtom::InspectFields(AP4_AtomInspector& inspector)
-{
- inspector.AddField("max_pdu_size", m_MaxPduSize);
- inspector.AddField("avg_pdu_size", m_AvgPduSize);
- inspector.AddField("max_bitrate", m_MaxBitrate);
- inspector.AddField("avg_bitrate", m_AvgBitrate);
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4HmhdAtom.h b/src/thirdparty/Bento4/Core/Ap4HmhdAtom.h
deleted file mode 100644
index a645dd3cc..000000000
--- a/src/thirdparty/Bento4/Core/Ap4HmhdAtom.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*****************************************************************
-|
-| AP4 - hmhd Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-#ifndef _AP4_HMHD_ATOM_H_
-#define _AP4_HMHD_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4Atom.h"
-
-/*----------------------------------------------------------------------
-| AP4_HmhdAtom
-+---------------------------------------------------------------------*/
-class AP4_HmhdAtom : public AP4_Atom
-{
-public:
- // methods
- AP4_HmhdAtom(AP4_Size size, AP4_ByteStream& stream);
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
-private:
- // members
- AP4_UI16 m_MaxPduSize;
- AP4_UI16 m_AvgPduSize;
- AP4_UI32 m_MaxBitrate;
- AP4_UI32 m_AvgBitrate;
- AP4_UI32 m_Reserved;
-};
-
-#endif // _AP4_HMHD_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4IkmsAtom.cpp b/src/thirdparty/Bento4/Core/Ap4IkmsAtom.cpp
deleted file mode 100644
index 4b0c8885c..000000000
--- a/src/thirdparty/Bento4/Core/Ap4IkmsAtom.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/*****************************************************************
-|
-| AP4 - iKMS Atoms
-|
-| Copyright 2002-2005 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4IkmsAtom.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_IkmsAtom::AP4_IkmsAtom
-+---------------------------------------------------------------------*/
-AP4_IkmsAtom::AP4_IkmsAtom(const char* kms_uri) :
- AP4_Atom(AP4_ATOM_TYPE_IKMS, AP4_FULL_ATOM_HEADER_SIZE, true),
- m_KmsUri(kms_uri)
-{
- m_Size += m_KmsUri.length()+1;
-}
-
-/*----------------------------------------------------------------------
-| AP4_IkmsAtom::AP4_IkmsAtom
-+---------------------------------------------------------------------*/
-AP4_IkmsAtom::AP4_IkmsAtom(AP4_Size size, AP4_ByteStream& stream) :
- AP4_Atom(AP4_ATOM_TYPE_IKMS, size, true, stream)
-{
- AP4_Size string_size = size-AP4_FULL_ATOM_HEADER_SIZE;
- if (string_size) {
- char* str = new char[string_size];
- stream.Read(str, string_size);
- str[string_size-1] = '\0'; // force null-termination
- m_KmsUri = str;
- delete[] str;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_IkmsAtom::Clone
-+---------------------------------------------------------------------*/
-AP4_Atom*
-AP4_IkmsAtom::Clone()
-{
- return new AP4_IkmsAtom(m_KmsUri.c_str());
-}
-
-/*----------------------------------------------------------------------
-| AP4_IkmsAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_IkmsAtom::WriteFields(AP4_ByteStream& stream)
-{
- // kms uri
- AP4_Result result = stream.Write(m_KmsUri.c_str(), m_KmsUri.length()+1);
- if (AP4_FAILED(result)) return result;
-
- // pad with zeros if necessary
- AP4_Size padding = m_Size-(AP4_FULL_ATOM_HEADER_SIZE+m_KmsUri.length()+1);
- while (padding--) stream.WriteUI08(0);
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_IkmsAtom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_IkmsAtom::InspectFields(AP4_AtomInspector& inspector)
-{
- inspector.AddField("kms_uri", m_KmsUri.c_str());
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4IkmsAtom.h b/src/thirdparty/Bento4/Core/Ap4IkmsAtom.h
deleted file mode 100644
index 7ff6efb40..000000000
--- a/src/thirdparty/Bento4/Core/Ap4IkmsAtom.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*****************************************************************
-|
-| AP4 - iKMS Atom
-|
-| Copyright 2002-2005 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-#ifndef _AP4_IKMS_ATOM_H_
-#define _AP4_IKMS_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4Types.h"
-#include "Ap4ByteStream.h"
-#include "Ap4Atom.h"
-
-/*----------------------------------------------------------------------
-| AP4_IkmsAtom
-+---------------------------------------------------------------------*/
-class AP4_IkmsAtom : public AP4_Atom
-{
-public:
- // methods
- AP4_IkmsAtom(const char* kms_uri);
- AP4_IkmsAtom(AP4_Size size, AP4_ByteStream& stream);
- virtual AP4_Atom* Clone();
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
- // accessors
- const AP4_String& GetKmsUri() { return m_KmsUri; }
-
-private:
- // members
- AP4_String m_KmsUri;
-};
-
-#endif // _AP4_IKMS_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4Interfaces.h b/src/thirdparty/Bento4/Core/Ap4Interfaces.h
deleted file mode 100644
index 8b505e93c..000000000
--- a/src/thirdparty/Bento4/Core/Ap4Interfaces.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Common Interfaces
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_INTERFACES_H_
-#define _AP4_INTERFACES_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4Types.h"
-
-/*----------------------------------------------------------------------
-| macros
-+---------------------------------------------------------------------*/
-#define AP4_RELEASE(o) do { if (o) (o)->Release(); (o) = NULL; } while (0)
-#define AP4_ADD_REFERENCE(o) do { if (o) (o)->AddReference(); } while (0)
-
-/*----------------------------------------------------------------------
-| AP4_Exception
-+---------------------------------------------------------------------*/
-class AP4_Exception
-{
-public:
- // methods
- AP4_Exception(AP4_Result error) : m_Error(error) {}
-
- // members
- AP4_Result m_Error;
-};
-
-/*----------------------------------------------------------------------
-| AP4_Referenceable
-+---------------------------------------------------------------------*/
-class AP4_Referenceable
-{
- public:
- // methods
- virtual ~AP4_Referenceable() {}
- virtual void AddReference() = 0;
- virtual void Release() = 0;
-};
-
-#endif // _AP4_INTERFACES_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4IsfmAtom.cpp b/src/thirdparty/Bento4/Core/Ap4IsfmAtom.cpp
deleted file mode 100644
index c54a8f13c..000000000
--- a/src/thirdparty/Bento4/Core/Ap4IsfmAtom.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/*****************************************************************
-|
-| AP4 - iSFM Atoms
-|
-| Copyright 2002-2005 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4Utils.h"
-#include "Ap4IsfmAtom.h"
-
-/*----------------------------------------------------------------------
-| AP4_IsfmAtom::AP4_IsfmAtom
-+---------------------------------------------------------------------*/
-AP4_IsfmAtom::AP4_IsfmAtom(bool selective_encryption,
- AP4_UI08 key_length_indicator,
- AP4_UI08 iv_length) :
- AP4_Atom(AP4_ATOM_TYPE_ISFM, AP4_FULL_ATOM_HEADER_SIZE+3, true),
- m_SelectiveEncryption(selective_encryption),
- m_KeyIndicatorLength(key_length_indicator),
- m_IvLength(iv_length)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsfmAtom::AP4_IsfmAtom
-+---------------------------------------------------------------------*/
-AP4_IsfmAtom::AP4_IsfmAtom(AP4_Size size, AP4_ByteStream& stream) :
- AP4_Atom(AP4_ATOM_TYPE_ISFM, size, true, stream)
-{
- AP4_UI08 s;
- stream.ReadUI08(s);
- m_SelectiveEncryption = ((s&1) != 0);
- stream.ReadUI08(m_KeyIndicatorLength);
- stream.ReadUI08(m_IvLength);
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsfmAtom::Clone
-+---------------------------------------------------------------------*/
-AP4_Atom*
-AP4_IsfmAtom::Clone()
-{
- return new AP4_IsfmAtom(m_SelectiveEncryption,
- m_KeyIndicatorLength,
- m_IvLength);
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsfmAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_IsfmAtom::WriteFields(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- // selective encryption
- result = stream.WriteUI08(m_SelectiveEncryption ? 1 : 0);
- if (AP4_FAILED(result)) return result;
-
- // key indicator length
- result = stream.WriteUI08(m_KeyIndicatorLength);
- if (AP4_FAILED(result)) return result;
-
- // IV length
- result = stream.WriteUI08(m_IvLength);
- if (AP4_FAILED(result)) return result;
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsfmAtom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_IsfmAtom::InspectFields(AP4_AtomInspector& inspector)
-{
- inspector.AddField("selective_encryption", m_SelectiveEncryption);
- inspector.AddField("key_indicator_length", m_KeyIndicatorLength);
- inspector.AddField("IV_length", m_IvLength);
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4IsfmAtom.h b/src/thirdparty/Bento4/Core/Ap4IsfmAtom.h
deleted file mode 100644
index fd07277f2..000000000
--- a/src/thirdparty/Bento4/Core/Ap4IsfmAtom.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*****************************************************************
-|
-| AP4 - iSFM Atom
-|
-| Copyright 2002-2005 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-#ifndef _AP4_ISFM_ATOM_H_
-#define _AP4_ISFM_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4Types.h"
-#include "Ap4ByteStream.h"
-#include "Ap4Atom.h"
-
-/*----------------------------------------------------------------------
-| AP4_IsfmAtom
-+---------------------------------------------------------------------*/
-class AP4_IsfmAtom : public AP4_Atom
-{
-public:
- // methods
- AP4_IsfmAtom(bool m_SelectiveEncryption,
- AP4_UI08 m_KeyIndicatorLength,
- AP4_UI08 m_IvLength);
- AP4_IsfmAtom(AP4_Size size, AP4_ByteStream& stream);
- virtual AP4_Atom* Clone();
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
- // accessors
- bool GetSelectiveEncryption() { return m_SelectiveEncryption; }
- AP4_UI08 GetKeyIndicatorLength() { return m_KeyIndicatorLength; }
- AP4_UI08 GetIvLength() { return m_IvLength; }
-
-private:
- // members
- bool m_SelectiveEncryption;
- AP4_UI08 m_KeyIndicatorLength;
- AP4_UI08 m_IvLength;
-};
-
-#endif // _AP4_ISFM_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4IsmaCryp.cpp b/src/thirdparty/Bento4/Core/Ap4IsmaCryp.cpp
deleted file mode 100644
index ca000db66..000000000
--- a/src/thirdparty/Bento4/Core/Ap4IsmaCryp.cpp
+++ /dev/null
@@ -1,717 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Sample Description Objects
-|
-| Copyright 2002 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4IsmaCryp.h"
-#include "Ap4SchmAtom.h"
-#include "Ap4StsdAtom.h"
-#include "Ap4Sample.h"
-#include "Ap4StreamCipher.h"
-#include "Ap4IsfmAtom.h"
-#include "Ap4FrmaAtom.h"
-#include "Ap4IkmsAtom.h"
-#include "Ap4IsfmAtom.h"
-#include "Ap4Utils.h"
-#include "Ap4TrakAtom.h"
-
-/*----------------------------------------------------------------------
-| AP4_EncaSampleEntry::AP4_EncaSampleEntry
-+---------------------------------------------------------------------*/
-AP4_EncaSampleEntry::AP4_EncaSampleEntry(AP4_UI32 sample_rate,
- AP4_UI16 sample_size,
- AP4_UI16 channel_count,
- AP4_EsDescriptor* descriptor) :
-AP4_AudioSampleEntry(AP4_ATOM_TYPE_ENCA,
- descriptor,
- sample_rate,
- sample_size,
- channel_count)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_EncaSampleEntry::AP4_EncaSampleEntry
-+---------------------------------------------------------------------*/
-AP4_EncaSampleEntry::AP4_EncaSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
-AP4_AudioSampleEntry(AP4_ATOM_TYPE_ENCA, size, stream, atom_factory)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_EncaSampleEntry::ToSampleDescription
-+---------------------------------------------------------------------*/
-AP4_SampleDescription*
-AP4_EncaSampleEntry::ToSampleDescription()
-{
- // get the original sample format
- AP4_FrmaAtom* frma = (AP4_FrmaAtom*)FindChild("sinf/frma");
-
- // get the scheme info
- AP4_SchmAtom* schm = (AP4_SchmAtom*)FindChild("sinf/schm");
- if (schm == NULL) return NULL;
-
- // get the sample description for the original sample entry
- AP4_MpegAudioSampleDescription* original_sample_description =
- (AP4_MpegAudioSampleDescription*)
- AP4_AudioSampleEntry::ToSampleDescription();
-
- // get the schi atom
- AP4_ContainerAtom* schi;
- schi = static_cast<AP4_ContainerAtom*>(FindChild("sinf/schi"));
-
- // create the sample description
- return new AP4_IsmaCrypSampleDescription(
- original_sample_description,
- frma?frma->GetOriginalFormat():AP4_ATOM_TYPE_MP4A,
- schm->GetSchemeType(),
- schm->GetSchemeVersion(),
- schm->GetSchemeUri().c_str(),
- schi);
-}
-
-/*----------------------------------------------------------------------
-| AP4_EncvSampleEntry::AP4_EncaSampleEntry
-+---------------------------------------------------------------------*/
-AP4_EncvSampleEntry::AP4_EncvSampleEntry(AP4_UI16 width,
- AP4_UI16 height,
- AP4_UI16 depth,
- const char* compressor_name,
- AP4_EsDescriptor* descriptor) :
- AP4_VisualSampleEntry(AP4_ATOM_TYPE_ENCV,
- descriptor,
- width,
- height,
- depth,
- compressor_name)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_EncvSampleEntry::AP4_EncvSampleEntry
-+---------------------------------------------------------------------*/
-AP4_EncvSampleEntry::AP4_EncvSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
- AP4_VisualSampleEntry(AP4_ATOM_TYPE_ENCV, size, stream, atom_factory)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_EncvSampleEntry::ToSampleDescription
-+---------------------------------------------------------------------*/
-AP4_SampleDescription*
-AP4_EncvSampleEntry::ToSampleDescription()
-{
- // get the original sample format
- AP4_FrmaAtom* frma = (AP4_FrmaAtom*)FindChild("sinf/frma");
-
- // get the scheme info
- AP4_SchmAtom* schm = (AP4_SchmAtom*)FindChild("sinf/schm");
- if (schm == NULL) return NULL;
-
- // get the sample description for the original sample entry
- AP4_MpegVideoSampleDescription* original_sample_description =
- (AP4_MpegVideoSampleDescription*)
- AP4_VisualSampleEntry::ToSampleDescription();
-
- // get the schi atom
- AP4_ContainerAtom* schi;
- schi = static_cast<AP4_ContainerAtom*>(FindChild("sinf/schi"));
-
- // create the sample description
- return new AP4_IsmaCrypSampleDescription(
- original_sample_description,
- frma?frma->GetOriginalFormat():AP4_ATOM_TYPE_MP4V,
- schm->GetSchemeType(),
- schm->GetSchemeVersion(),
- schm->GetSchemeUri().c_str(),
- schi);
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaCrypSampleDescription::AP4_IsmaCrypSampleDescription
-+---------------------------------------------------------------------*/
-AP4_IsmaCrypSampleDescription::AP4_IsmaCrypSampleDescription(
- AP4_MpegSampleDescription* original_sample_description,
- AP4_UI32 original_format,
- AP4_UI32 scheme_type,
- AP4_UI32 scheme_version,
- const char* scheme_uri,
- AP4_ContainerAtom* schi) :
- AP4_SampleDescription(TYPE_ISMACRYP),
- m_OriginalSampleDescription(original_sample_description),
- m_OriginalFormat(original_format),
- m_SchemeType(scheme_type),
- m_SchemeVersion(scheme_version),
- m_SchemeUri(scheme_uri)
-{
- m_SchemeInfo = new AP4_IsmaCrypSchemeInfo(schi);
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaCrypSampleDescription::~AP4_IsmaCrypSampleDescription
-+---------------------------------------------------------------------*/
-AP4_IsmaCrypSampleDescription::~AP4_IsmaCrypSampleDescription()
-{
- delete m_SchemeInfo;
- delete m_OriginalSampleDescription;
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaCrypSampleDescription::ToAtom
-+---------------------------------------------------------------------*/
-AP4_Atom*
-AP4_IsmaCrypSampleDescription::ToAtom() const
-{
- // TODO: not implemented yet
- return NULL;
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaCrypSchemeInfo::AP4_IsmaCrypSchemeInfo
-+---------------------------------------------------------------------*/
-AP4_IsmaCrypSchemeInfo::AP4_IsmaCrypSchemeInfo(AP4_ContainerAtom* schi) :
- m_SchiAtom(AP4_ATOM_TYPE_SCHI)
-{
- if (schi) {
- AP4_List<AP4_Atom>& children = schi->GetChildren();
- AP4_List<AP4_Atom>::Item* child_item = children.FirstItem();
- while (child_item) {
- AP4_Atom* child_atom = child_item->GetData();
- AP4_Atom* clone = child_atom->Clone();
- if (clone) m_SchiAtom.AddChild(clone);
- child_item = child_item->GetNext();
- }
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaCrypCipher::AP4_IsmaCipher
-+---------------------------------------------------------------------*/
-AP4_IsmaCipher::AP4_IsmaCipher(const AP4_UI08* key,
- const AP4_UI08* salt,
- AP4_Size iv_length,
- AP4_Size key_indicator_length,
- bool selective_encryption) :
- m_IvLength(iv_length),
- m_KeyIndicatorLength(key_indicator_length),
- m_SelectiveEncryption(selective_encryption)
-{
- // NOTE: we do not handle key indicators yey, so there is only one key.
-
- // left-align the salt
- unsigned char salt_128[AP4_ISMACRYP_IAEC_KEY_LENGTH];
- for (unsigned int i=0; i<8; i++) {
- salt_128[i] = salt[i];
- }
- for (unsigned int i=0; i<8; i++) {
- salt_128[8+i] = 0;
- }
-
- // create a cipher
- m_Cipher = new AP4_StreamCipher(key, salt_128);
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaCipher::~AP4_IsmaCipher
-+---------------------------------------------------------------------*/
-AP4_IsmaCipher::~AP4_IsmaCipher()
-{
- delete m_Cipher;
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaCipher::DecryptSample
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_IsmaCipher::DecryptSample(AP4_DataBuffer& data_in,
- AP4_DataBuffer& data_out)
-{
- bool is_encrypted = true;
- const unsigned char* in = data_in.GetData();
- if (m_SelectiveEncryption) {
- is_encrypted = ((in[0]&1)==1);
- in++;
- }
-
- // get the IV (this implementation only supports un to 32 bits of IV)
- // so we skip anything beyond the last 4 bytes
- unsigned int to_read = m_IvLength;
- if (to_read > 16 || to_read == 0) return AP4_ERROR_INVALID_FORMAT;
- while (to_read > 4) {
- to_read--;
- in++;
- }
- AP4_UI32 iv = 0;
- while (to_read--) {
- iv = (iv<<8) | *in++;
- }
-
- // get the key indicator (we only support up to 32 bits as well)
- to_read = m_KeyIndicatorLength;
- if (to_read > 4 ) return AP4_ERROR_INVALID_FORMAT;
- while (to_read > 4) {
- to_read--;
- in++;
- }
- AP4_UI32 key_indicator = 0;
- while (to_read--) {
- key_indicator = (key_indicator<<8) | *in++;
- }
- // we only support key indicator = 0 for now... (TODO)
- if (key_indicator != 0) {
- return AP4_FAILURE;
- }
-
- // process the sample data
- unsigned int header_size = in-data_in.GetData();
- unsigned int payload_size = data_in.GetDataSize()-header_size;
- data_out.SetDataSize(payload_size);
- unsigned char* out = data_out.UseData();
- if (is_encrypted) {
- m_Cipher->SetStreamOffset(iv);
- m_Cipher->ProcessBuffer(in, out, payload_size);
- } else {
- memcpy(out, in, payload_size);
- }
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaCipher::EncryptSample
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_IsmaCipher::EncryptSample(AP4_DataBuffer& data_in,
- AP4_DataBuffer& data_out,
- AP4_Offset iv,
- bool skip_encryption)
-{
- // setup the buffers
- const unsigned char* in = data_in.GetData();
- data_out.SetDataSize(data_in.GetDataSize()+4);
- unsigned char* out = data_out.UseData();
-
- // IV on 4 bytes
- AP4_BytesFromUInt32BE(out, iv);
- out += 4;
-
- // encrypt the payload
- m_Cipher->SetStreamOffset(iv);
- m_Cipher->ProcessBuffer(in, out, data_in.GetDataSize());
-
- return AP4_FAILURE;
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaTrackDecrypter
-+---------------------------------------------------------------------*/
-class AP4_IsmaTrackDecrypter : public AP4_Processor::TrackHandler {
-public:
- // constructor
- AP4_IsmaTrackDecrypter(const AP4_UI08* key,
- const AP4_UI08* salt,
- AP4_IsmaCrypSampleDescription* sample_description,
- AP4_SampleEntry* sample_entry);
- virtual ~AP4_IsmaTrackDecrypter();
-
- // methods
- virtual AP4_Size GetProcessedSampleSize(AP4_Sample& sample);
- virtual AP4_Result ProcessTrack();
- virtual AP4_Result ProcessSample(AP4_DataBuffer& data_in,
- AP4_DataBuffer& data_out);
-
-private:
- // members
- AP4_IsfmAtom* m_CipherParams;
- AP4_IsmaCipher* m_Cipher;
- AP4_SampleEntry* m_SampleEntry;
- AP4_UI32 m_OriginalFormat;
-};
-
-/*----------------------------------------------------------------------
-| AP4_IsmaTrackDecrypter::AP4_IsmaTrackDecrypter
-+---------------------------------------------------------------------*/
-AP4_IsmaTrackDecrypter::AP4_IsmaTrackDecrypter(
- const AP4_UI08* key,
- const AP4_UI08* salt,
- AP4_IsmaCrypSampleDescription* sample_description,
- AP4_SampleEntry* sample_entry) :
- m_SampleEntry(sample_entry)
-{
- // get the cipher params
- m_CipherParams = (AP4_IsfmAtom*)sample_description->GetSchemeInfo()->GetSchiAtom().FindChild("iSFM");
-
- // instantiate the cipher
- m_Cipher = new AP4_IsmaCipher(key, salt,
- m_CipherParams->GetIvLength(),
- m_CipherParams->GetKeyIndicatorLength(),
- m_CipherParams->GetSelectiveEncryption());
-
- // get the sample entry details
- m_OriginalFormat = sample_description->GetOriginalFormat();
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaTrackDecrypter::~AP4_IsmaTrackDecrypter
-+---------------------------------------------------------------------*/
-AP4_IsmaTrackDecrypter::~AP4_IsmaTrackDecrypter()
-{
- delete m_Cipher;
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaTrackDecrypter::GetProcessedSampleSize
-+---------------------------------------------------------------------*/
-AP4_Size
-AP4_IsmaTrackDecrypter::GetProcessedSampleSize(AP4_Sample& sample)
-{
- AP4_Size isma_header_size =
- m_CipherParams->GetKeyIndicatorLength() +
- m_CipherParams->GetIvLength();
- if (m_CipherParams->GetSelectiveEncryption()) {
- isma_header_size++;
- }
- return sample.GetSize()-isma_header_size;
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaTrackDecrypter::ProcessTrack
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_IsmaTrackDecrypter::ProcessTrack()
-{
- m_SampleEntry->SetType(m_OriginalFormat);
- m_SampleEntry->DeleteChild(AP4_ATOM_TYPE_SINF);
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaDecrypter::ProcessSample
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_IsmaTrackDecrypter::ProcessSample(AP4_DataBuffer& data_in,
- AP4_DataBuffer& data_out)
-{
- return m_Cipher->DecryptSample(data_in, data_out);
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaDecryptingProcessor:CreateTrackHandler
-+---------------------------------------------------------------------*/
-AP4_Processor::TrackHandler*
-AP4_IsmaDecryptingProcessor::CreateTrackHandler(AP4_TrakAtom* trak)
-{
- // find the stsd atom
- AP4_StsdAtom* stsd = dynamic_cast<AP4_StsdAtom*>(
- trak->FindChild("mdia/minf/stbl/stsd"));
-
- // avoid tracks with no stsd atom (should not happen)
- if (stsd == NULL) return NULL;
-
- // we only look at the first sample description
- AP4_SampleDescription* desc = stsd->GetSampleDescription(0);
- AP4_SampleEntry* entry = stsd->GetSampleEntry(0);
- if (desc == NULL || entry == NULL) return NULL;
- if (desc->GetType() == AP4_SampleDescription::TYPE_ISMACRYP) {
- // create a handler for this track
- AP4_IsmaCrypSampleDescription* ismacryp_desc =
- static_cast<AP4_IsmaCrypSampleDescription*>(desc);
- if (ismacryp_desc->GetSchemeType() == AP4_ISMACRYP_SCHEME_TYPE_IAEC) {
- const AP4_UI08* key;
- const AP4_UI08* salt;
- if (AP4_SUCCEEDED(m_KeyMap.GetKey(trak->GetId(), key, salt))) {
- return new AP4_IsmaTrackDecrypter(key, salt, ismacryp_desc, entry);
- }
- }
- }
-
- return NULL;
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaTrackEncrypter
-+---------------------------------------------------------------------*/
-class AP4_IsmaTrackEncrypter : public AP4_Processor::TrackHandler {
-public:
- // constructor
- AP4_IsmaTrackEncrypter(const char* kms_uri,
- const AP4_UI08* key,
- const AP4_UI08* salt,
- AP4_SampleEntry* sample_entry,
- AP4_UI32 format);
- virtual ~AP4_IsmaTrackEncrypter();
-
- // methods
- virtual AP4_Size GetProcessedSampleSize(AP4_Sample& sample);
- virtual AP4_Result ProcessTrack();
- virtual AP4_Result ProcessSample(AP4_DataBuffer& data_in,
- AP4_DataBuffer& data_out);
-
-private:
- // members
- AP4_String m_KmsUri;
- AP4_IsmaCipher* m_Cipher;
- AP4_SampleEntry* m_SampleEntry;
- AP4_UI32 m_Format;
- AP4_Offset m_ByteOffset;
-};
-
-/*----------------------------------------------------------------------
-| AP4_IsmaTrackEncrypter::AP4_IsmaTrackEncrypter
-+---------------------------------------------------------------------*/
-AP4_IsmaTrackEncrypter::AP4_IsmaTrackEncrypter(
- const char* kms_uri,
- const AP4_UI08* key,
- const AP4_UI08* salt,
- AP4_SampleEntry* sample_entry,
- AP4_UI32 format) :
- m_KmsUri(kms_uri),
- m_SampleEntry(sample_entry),
- m_Format(format),
- m_ByteOffset(0)
-{
- // instantiate the cipher (fixed params for now)
- m_Cipher = new AP4_IsmaCipher(key, salt, 4, 0, false);
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaTrackEncrypter::~AP4_IsmaTrackEncrypter
-+---------------------------------------------------------------------*/
-AP4_IsmaTrackEncrypter::~AP4_IsmaTrackEncrypter()
-{
- delete m_Cipher;
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaTrackEncrypter::GetProcessedSampleSize
-+---------------------------------------------------------------------*/
-AP4_Size
-AP4_IsmaTrackEncrypter::GetProcessedSampleSize(AP4_Sample& sample)
-{
- return sample.GetSize()+4; //fixed header size for now
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaTrackEncrypter::ProcessTrack
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_IsmaTrackEncrypter::ProcessTrack()
-{
- // sinf container
- AP4_ContainerAtom* sinf = new AP4_ContainerAtom(AP4_ATOM_TYPE_SINF);
-
- // original format
- AP4_FrmaAtom* frma = new AP4_FrmaAtom(m_SampleEntry->GetType());
-
- // scheme
- AP4_SchmAtom* schm = new AP4_SchmAtom(AP4_ISMACRYP_SCHEME_TYPE_IAEC, 1);
-
- // scheme info
- AP4_ContainerAtom* schi = new AP4_ContainerAtom(AP4_ATOM_TYPE_SCHI);
- AP4_IkmsAtom* ikms = new AP4_IkmsAtom(m_KmsUri.c_str());
- AP4_IsfmAtom* isfm = new AP4_IsfmAtom(false, 0, 4);
-
- // populate the schi container
- schi->AddChild(ikms);
- schi->AddChild(isfm);
-
- // populate the sinf container
- sinf->AddChild(frma);
- sinf->AddChild(schm);
- sinf->AddChild(schi);
-
- // add the sinf atom to the sample description
- m_SampleEntry->AddChild(sinf);
-
- // change the atom type of the sample description
- m_SampleEntry->SetType(m_Format);
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaTrackEncrypter::ProcessSample
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_IsmaTrackEncrypter::ProcessSample(AP4_DataBuffer& data_in,
- AP4_DataBuffer& data_out)
-{
- AP4_Result result = m_Cipher->EncryptSample(data_in, data_out, m_ByteOffset, false);
- if (AP4_FAILED(result)) return result;
-
- m_ByteOffset += data_in.GetDataSize();
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaEncryptingProcessor::AP4_IsmaEncryptingProcessor
-+---------------------------------------------------------------------*/
-AP4_IsmaEncryptingProcessor::AP4_IsmaEncryptingProcessor(const char* kms_uri) :
- m_KmsUri(kms_uri)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaEncryptingProcessor:CreateTrackHandler
-+---------------------------------------------------------------------*/
-AP4_Processor::TrackHandler*
-AP4_IsmaEncryptingProcessor::CreateTrackHandler(AP4_TrakAtom* trak)
-{
- // find the stsd atom
- AP4_StsdAtom* stsd = dynamic_cast<AP4_StsdAtom*>(
- trak->FindChild("mdia/minf/stbl/stsd"));
-
- // avoid tracks with no stsd atom (should not happen)
- if (stsd == NULL) return NULL;
-
- // only look at the first sample description
- AP4_SampleEntry* entry = stsd->GetSampleEntry(0);
- if (entry == NULL) return NULL;
-
- // create a handler for this track if we have a key for it and we know
- // how to map the type
- const AP4_UI08* key;
- const AP4_UI08* salt;
- AP4_UI32 format = 0;
- if (AP4_SUCCEEDED(m_KeyMap.GetKey(trak->GetId(), key, salt))) {
- switch (entry->GetType()) {
- case AP4_ATOM_TYPE_MP4A:
- format = AP4_ATOM_TYPE_ENCA;
- break;
-
- case AP4_ATOM_TYPE_MP4V:
- case AP4_ATOM_TYPE_AVC1:
- format = AP4_ATOM_TYPE_ENCV;
- break;
- }
- if (format) {
- return new AP4_IsmaTrackEncrypter(m_KmsUri.c_str(),
- key,
- salt,
- entry,
- format);
- }
- }
-
- return NULL;
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaKeyMap::AP4_IsmaKeyMap
-+---------------------------------------------------------------------*/
-AP4_IsmaKeyMap::AP4_IsmaKeyMap()
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaKeyMap::~AP4_IsmaKeyMap
-+---------------------------------------------------------------------*/
-AP4_IsmaKeyMap::~AP4_IsmaKeyMap()
-{
- m_KeyEntries.DeleteReferences();
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaKeyMap::SetKey
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_IsmaKeyMap::SetKey(AP4_UI32 track_id, const AP4_UI08* key, const AP4_UI08* salt)
-{
- KeyEntry* entry = GetEntry(track_id);
- if (entry == NULL) {
- m_KeyEntries.Add(new KeyEntry(track_id, key, salt));
- } else {
- entry->SetKey(key, salt);
- }
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaKeyMap::GetKey
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_IsmaKeyMap::GetKey(AP4_UI32 track_id, const AP4_UI08*& key, const AP4_UI08*& salt)
-{
- KeyEntry* entry = GetEntry(track_id);
- if (entry) {
- key = entry->m_Key;
- salt = entry->m_Salt;
- return AP4_SUCCESS;
- } else {
- return AP4_ERROR_NO_SUCH_ITEM;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaKeyMap::GetEntry
-+---------------------------------------------------------------------*/
-AP4_IsmaKeyMap::KeyEntry*
-AP4_IsmaKeyMap::GetEntry(AP4_UI32 track_id)
-{
- AP4_List<KeyEntry>::Item* item = m_KeyEntries.FirstItem();
- while (item) {
- KeyEntry* entry = (KeyEntry*)item->GetData();
- if (entry->m_TrackId == track_id) return entry;
- item = item->GetNext();
- }
-
- return NULL;
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaKeyMap::KeyEntry::KeyEntry
-+---------------------------------------------------------------------*/
-AP4_IsmaKeyMap::KeyEntry::KeyEntry(AP4_UI32 track_id,
- const AP4_UI08* key,
- const AP4_UI08* salt /* = NULL */) :
- m_TrackId(track_id)
-{
- SetKey(key, salt);
-}
-
-/*----------------------------------------------------------------------
-| AP4_IsmaKeyMap::KeyEntry::SetKey
-+---------------------------------------------------------------------*/
-void
-AP4_IsmaKeyMap::KeyEntry::SetKey(const AP4_UI08* key, const AP4_UI08* salt)
-{
- memcpy(m_Key, key, sizeof(m_Key));
- if (salt) {
- memcpy(m_Salt, salt, sizeof(m_Salt));
- } else {
- memset(m_Salt, 0, sizeof(m_Salt));
- }
-}
-
diff --git a/src/thirdparty/Bento4/Core/Ap4IsmaCryp.h b/src/thirdparty/Bento4/Core/Ap4IsmaCryp.h
deleted file mode 100644
index fd1ac7de4..000000000
--- a/src/thirdparty/Bento4/Core/Ap4IsmaCryp.h
+++ /dev/null
@@ -1,245 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Sample Description Objects
-|
-| Copyright 2002 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-#ifndef _AP4_ISMACRYP_H_
-#define _AP4_ISMACRYP_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4Types.h"
-#include "Ap4SampleEntry.h"
-#include "Ap4Atom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4SampleDescription.h"
-#include "Ap4Processor.h"
-
-/*----------------------------------------------------------------------
-| class references
-+---------------------------------------------------------------------*/
-class AP4_StreamCipher;
-
-/*----------------------------------------------------------------------
-| constants
-+---------------------------------------------------------------------*/
-const AP4_UI32 AP4_ISMACRYP_SCHEME_TYPE_IAEC = AP4_ATOM_TYPE('i','A','E','C');
-const AP4_Size AP4_ISMACRYP_IAEC_KEY_LENGTH = 16;
-
-/*----------------------------------------------------------------------
-| AP4_EncaSampleEntry
-+---------------------------------------------------------------------*/
-class AP4_EncaSampleEntry : public AP4_AudioSampleEntry
-{
-public:
- // methods
- AP4_EncaSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory);
- AP4_EncaSampleEntry(AP4_UI32 sample_rate,
- AP4_UI16 sample_size,
- AP4_UI16 channel_count,
- AP4_EsDescriptor* descriptor);
-
- // methods
- AP4_SampleDescription* ToSampleDescription();
-};
-
-/*----------------------------------------------------------------------
-| AP4_EncvSampleEntry
-+---------------------------------------------------------------------*/
-class AP4_EncvSampleEntry : public AP4_VisualSampleEntry
-{
-public:
- // constructors
- AP4_EncvSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory);
- AP4_EncvSampleEntry(AP4_UI16 width,
- AP4_UI16 height,
- AP4_UI16 depth,
- const char* compressor_name,
- AP4_EsDescriptor* descriptor);
-
- // methods
- AP4_SampleDescription* ToSampleDescription();
-};
-
-/*----------------------------------------------------------------------
-| AP4_IsmaKeyMap
-+---------------------------------------------------------------------*/
-class AP4_IsmaKeyMap
-{
-public:
- // constructors and destructor
- AP4_IsmaKeyMap();
- ~AP4_IsmaKeyMap();
-
- // methods
- AP4_Result SetKey(AP4_UI32 track_id, const AP4_UI08* key, const AP4_UI08* salt = NULL);
- AP4_Result GetKey(AP4_UI32 track_id, const AP4_UI08*& key, const AP4_UI08*& salt);
-
-private:
- // types
- class KeyEntry {
- public:
- KeyEntry(AP4_UI32 track_id, const AP4_UI08* key, const AP4_UI08* salt = NULL);
- void SetKey(const AP4_UI08* key, const AP4_UI08* salt);
- AP4_Ordinal m_TrackId;
- AP4_UI08 m_Key[AP4_ISMACRYP_IAEC_KEY_LENGTH];
- AP4_UI08 m_Salt[AP4_ISMACRYP_IAEC_KEY_LENGTH];
- };
-
- // methods
- KeyEntry* GetEntry(AP4_UI32 track_id);
-
- // members
- AP4_List<KeyEntry> m_KeyEntries;
-};
-
-/*----------------------------------------------------------------------
-| AP4_IsmaSchemeInfo
-+---------------------------------------------------------------------*/
-class AP4_IsmaCrypSchemeInfo
-{
-public:
- // constructors and destructor
- AP4_IsmaCrypSchemeInfo(AP4_ContainerAtom* schi);
- virtual ~AP4_IsmaCrypSchemeInfo(){}
-
- // accessors
- AP4_ContainerAtom& GetSchiAtom() { return m_SchiAtom; }
-
-protected:
- AP4_ContainerAtom m_SchiAtom;
-};
-
-/*----------------------------------------------------------------------
-| AP4_IsmaCrypSampleDescription
-+---------------------------------------------------------------------*/
-class AP4_IsmaCrypSampleDescription : public AP4_SampleDescription
-{
-public:
- // constructor and destructor
- AP4_IsmaCrypSampleDescription(AP4_MpegSampleDescription* original_sample_description,
- AP4_UI32 original_format,
- AP4_UI32 scheme_type,
- AP4_UI32 scheme_version,
- const char* scheme_uri,
- AP4_ContainerAtom* schi_atom);
- ~AP4_IsmaCrypSampleDescription();
-
- // accessors
- AP4_MpegSampleDescription* GetOriginalSampleDescription() {
- return m_OriginalSampleDescription;
- }
- AP4_UI32 GetOriginalFormat() { return m_OriginalFormat; }
- AP4_UI32 GetSchemeType() { return m_SchemeType; }
- AP4_UI32 GetSchemeVersion() { return m_SchemeVersion; }
- AP4_String& GetSchemeUri() { return m_SchemeUri; }
- AP4_IsmaCrypSchemeInfo* GetSchemeInfo() { return m_SchemeInfo; }
-
- // implementation of abstract base class methods
- virtual AP4_Atom* ToAtom() const;
-
-private:
- // members
- AP4_MpegSampleDescription* m_OriginalSampleDescription;
- AP4_UI32 m_OriginalFormat;
- AP4_UI32 m_SchemeType;
- AP4_UI32 m_SchemeVersion;
- AP4_String m_SchemeUri;
- AP4_IsmaCrypSchemeInfo* m_SchemeInfo;
-};
-
-/*----------------------------------------------------------------------
-| AP4_IsmaCipher
-+---------------------------------------------------------------------*/
-class AP4_IsmaCipher
-{
-public:
- // constructor and destructor
- AP4_IsmaCipher(const AP4_UI08* key,
- const AP4_UI08* salt,
- AP4_Size iv_length,
- AP4_Size key_indicator_length,
- bool selective_encryption);
- ~AP4_IsmaCipher();
- AP4_Result EncryptSample(AP4_DataBuffer& data_in,
- AP4_DataBuffer& data_out,
- AP4_Offset iv,
- bool skip_encryption);
- AP4_Result DecryptSample(AP4_DataBuffer& data_in,
- AP4_DataBuffer& data_out);
-
-private:
- // members
- AP4_StreamCipher* m_Cipher;
- AP4_Size m_IvLength;
- AP4_Size m_KeyIndicatorLength;
- bool m_SelectiveEncryption;
-};
-
-/*----------------------------------------------------------------------
-| AP4_IsmaDecryptingProcessor
-+---------------------------------------------------------------------*/
-class AP4_IsmaDecryptingProcessor : public AP4_Processor
-{
-public:
- // accessors
- AP4_IsmaKeyMap& GetKeyMap() { return m_KeyMap; }
-
- // methods
- virtual AP4_Processor::TrackHandler* CreateTrackHandler(AP4_TrakAtom* trak);
-
-private:
- // members
- AP4_IsmaKeyMap m_KeyMap;
-};
-
-/*----------------------------------------------------------------------
-| AP4_IsmaEncryptingProcessor
-+---------------------------------------------------------------------*/
-class AP4_IsmaEncryptingProcessor : public AP4_Processor
-{
-public:
- // constructors and destructor
- AP4_IsmaEncryptingProcessor(const char* kms_uri);
-
- // accessors
- AP4_IsmaKeyMap& GetKeyMap() { return m_KeyMap; }
-
- // methods
- virtual AP4_Processor::TrackHandler* CreateTrackHandler(AP4_TrakAtom* trak);
-
-private:
- // members
- AP4_IsmaKeyMap m_KeyMap;
- AP4_String m_KmsUri;
-};
-
-#endif // _AP4_ISMACRYP_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4List.h b/src/thirdparty/Bento4/Core/Ap4List.h
deleted file mode 100644
index ec81958d3..000000000
--- a/src/thirdparty/Bento4/Core/Ap4List.h
+++ /dev/null
@@ -1,474 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Lists
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_LIST_H_
-#define _AP4_LIST_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4Results.h"
-
-/*----------------------------------------------------------------------
-| forward references
-+---------------------------------------------------------------------*/
-template <typename T> class AP4_List;
-
-/*----------------------------------------------------------------------
-| AP4_List
-+---------------------------------------------------------------------*/
-template <typename T>
-class AP4_List
-{
-public:
- // types
- class Item
- {
- public:
- // types
- class Operator
- {
- public:
- // methods
- virtual ~Operator() {}
- virtual AP4_Result Action(T* data) const = 0;
- };
-
- class Finder
- {
- public:
- // methods
- virtual ~Finder() {}
- virtual AP4_Result Test(T* data) const = 0;
- };
-
- // methods
- Item(T* data) : m_Data(data), m_Next(0), m_Prev(0) {}
- ~Item() {}
- Item* GetNext() { return m_Next; }
- Item* GetPrev() { return m_Prev; }
- T* GetData() { return m_Data; }
-
- private:
- // members
- T* m_Data;
- Item* m_Next;
- Item* m_Prev;
-
- // friends
- friend class AP4_List;
- };
-
- // methods
- AP4_List<T>(): m_ItemCount(0), m_Head(0), m_Tail(0) {}
- virtual ~AP4_List<T>();
- AP4_Result Add(T* data);
- AP4_Result Add(Item* item);
- AP4_Result Remove(T* data);
- AP4_Result Insert(Item* where, T* data);
- AP4_Result Get(AP4_Ordinal idx, T*& data);
- AP4_Result PopHead(T*& data);
- AP4_Result Apply(const typename Item::Operator& op);
- AP4_Result ApplyUntilFailure(const typename Item::Operator& op);
- AP4_Result ApplyUntilSuccess(const typename Item::Operator& op);
- AP4_Result ReverseApply(const typename Item::Operator& op);
- AP4_Result Find(const typename Item::Finder& finder, T*& data);
- AP4_Result ReverseFind(const typename Item::Finder& finder, T*& data);
- AP4_Result DeleteReferences();
- AP4_Cardinal ItemCount() { return m_ItemCount; }
- Item* FirstItem() { return m_Head; }
- Item* LastItem() { return m_Tail; }
-
-protected:
- // members
- AP4_Cardinal m_ItemCount;
- Item* m_Head;
- Item* m_Tail;
-
-private:
- // these cannot be used
- AP4_List<T>(const AP4_List<T>&);
- AP4_List<T>& operator=(const AP4_List<T>&);
-};
-
-/*----------------------------------------------------------------------
-| AP4_List<T>::~AP4_List<T>
-+---------------------------------------------------------------------*/
-template <typename T>
-AP4_List<T>::~AP4_List()
-{
- Item* item = m_Head;
-
- while (item) {
- Item* next = item->m_Next;
- delete item;
- item = next;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_List<T>::Add
-+---------------------------------------------------------------------*/
-template <typename T>
-inline
-AP4_Result
-AP4_List<T>::Add(T* data)
-{
- return Add(new Item(data));
-}
-
-/*----------------------------------------------------------------------
-| AP4_List<T>::Add
-+---------------------------------------------------------------------*/
-template <typename T>
-AP4_Result
-AP4_List<T>::Add(Item* item)
-{
- // add element at the tail
- if (m_Tail) {
- item->m_Prev = m_Tail;
- item->m_Next = NULL;
- m_Tail->m_Next = item;
- m_Tail = item;
- } else {
- m_Head = item;
- m_Tail = item;
- item->m_Next = NULL;
- item->m_Prev = NULL;
- }
-
- // one more item in the list now
- m_ItemCount++;
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_List<T>::Remove
-+---------------------------------------------------------------------*/
-template <typename T>
-AP4_Result
-AP4_List<T>::Remove(T* data)
-{
- Item* item = m_Head;
-
- while (item) {
- if (item->m_Data == data) {
- // delete item
- if (item->m_Prev) {
- // item is not the head
- if (item->m_Next) {
- // item is not the tail
- item->m_Next->m_Prev = item->m_Prev;
- item->m_Prev->m_Next = item->m_Next;
- } else {
- // item is the tail
- m_Tail = item->m_Prev;
- m_Tail->m_Next = NULL;
- }
- } else {
- // item is the head
- m_Head = item->m_Next;
- if (m_Head) {
- // item is not the tail
- m_Head->m_Prev = NULL;
- } else {
- // item is also the tail
- m_Tail = NULL;
- }
- }
-
- // delete the item
- delete item;
-
- // one less item in the list now
- m_ItemCount--;
-
- return AP4_SUCCESS;
- }
- item = item->m_Next;
- }
-
- return AP4_ERROR_NO_SUCH_ITEM;
-}
-
-/*----------------------------------------------------------------------
-| AP4_List<T>::Insert
-+---------------------------------------------------------------------*/
-template <typename T>
-AP4_Result
-AP4_List<T>::Insert(Item* where, T* data)
-{
- Item* item = new Item(data);
-
- if (where == NULL) {
- // insert as the head
- if (m_Head) {
- // replace the current head
- item->m_Prev = NULL;
- item->m_Next = m_Head;
- m_Head->m_Prev = item;
- m_Head = item;
- } else {
- // this item becomes the head and tail
- m_Head = item;
- m_Tail = item;
- item->m_Next = NULL;
- item->m_Prev = NULL;
- }
- } else {
- // insert after the 'where' item
- if (where == m_Tail) {
- // add the item at the end
- return Add(item);
- } else {
- // update the links
- item->m_Prev = where;
- item->m_Next = where->m_Next;
- where->m_Next->m_Prev = item;
- where->m_Next = item;
- }
- }
-
- // one more item in the list now
- ++m_ItemCount;
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_List<T>::Get
-+---------------------------------------------------------------------*/
-template <typename T>
-AP4_Result
-AP4_List<T>::Get(AP4_Ordinal idx, T*& data)
-{
- Item* item = m_Head;
-
- if (idx < m_ItemCount) {
- while (idx--) item = item->m_Next;
- data = item->m_Data;
- return AP4_SUCCESS;
- } else {
- data = NULL;
- return AP4_ERROR_NO_SUCH_ITEM;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_List<T>::PopHead
-+---------------------------------------------------------------------*/
-template <typename T>
-AP4_Result
-AP4_List<T>::PopHead(T*& data)
-{
- // check that we have at least one item
- if (m_Head == NULL) {
- return AP4_ERROR_LIST_EMPTY;
- }
-
- // remove the item and return it
- data = m_Head->m_Data;
- Item* head = m_Head;
- m_Head = m_Head->m_Next;
- if (m_Head) {
- m_Head->m_Prev = NULL;
- } else {
- m_Tail = NULL;
- }
-
- // delete item
- delete head;
-
- // one less item in the list now
- m_ItemCount--;
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_List<T>::Apply
-+---------------------------------------------------------------------*/
-template <typename T>
-inline
-AP4_Result
-AP4_List<T>::Apply(const typename Item::Operator& op)
-{
- Item* item = m_Head;
-
- while (item) {
- op.Action(item->m_Data);
- item = item->m_Next;
- }
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_List<T>::ApplyUntilFailure
-+---------------------------------------------------------------------*/
-template <typename T>
-inline
-AP4_Result
-AP4_List<T>::ApplyUntilFailure(const typename Item::Operator& op)
-{
- Item* item = m_Head;
-
- while (item) {
- AP4_Result result;
- result = op.Action(item->m_Data);
- if (result != AP4_SUCCESS) return result;
- item = item->m_Next;
- }
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_List<T>::ApplyUntilSuccess
-+---------------------------------------------------------------------*/
-template <typename T>
-inline
-AP4_Result
-AP4_List<T>::ApplyUntilSuccess(const typename Item::Operator& op)
-{
- Item* item = m_Head;
-
- while (item) {
- AP4_Result result;
- result = op.Action(item->m_Data);
- if (result == AP4_SUCCESS) return AP4_SUCCESS;
- item = item->m_Next;
- }
-
- return AP4_FAILURE;
-}
-
-/*----------------------------------------------------------------------
-| AP4_List<T>::ReverseApply
-+---------------------------------------------------------------------*/
-template <typename T>
-inline
-AP4_Result
-AP4_List<T>::ReverseApply(const typename Item::Operator& op)
-{
- Item* item = m_Tail;
-
- while (item) {
- if (op.Action(item->m_Data) != AP4_SUCCESS) {
- return AP4_ERROR_LIST_OPERATION_ABORTED;
- }
- item = item->m_Prev;
- }
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_List<T>::Find
-+---------------------------------------------------------------------*/
-template <typename T>
-inline
-AP4_Result
-AP4_List<T>::Find(const typename Item::Finder& finder, T*& data)
-{
- Item* item = m_Head;
-
- while (item) {
- if (finder.Test(item->m_Data) == AP4_SUCCESS) {
- data = item->m_Data;
- return AP4_SUCCESS;
- }
- item = item->m_Next;
- }
-
- data = NULL;
- return AP4_ERROR_NO_SUCH_ITEM;
-}
-
-/*----------------------------------------------------------------------
-| AP4_List<T>::ReverseFind
-+---------------------------------------------------------------------*/
-template <typename T>
-inline
-AP4_Result
-AP4_List<T>::ReverseFind(const typename Item::Finder& finder, T*& data)
-{
- Item* item = m_Tail;
-
- while (item) {
- if (finder.Test(item->m_Data) == AP4_SUCCESS) {
- data = item->m_Data;
- return AP4_SUCCESS;
- }
- item = item->m_Prev;
- }
-
- data = NULL;
- return AP4_ERROR_NO_SUCH_ITEM;
-}
-
-/*----------------------------------------------------------------------
-| AP4_List<T>::DeleteReferences
-+---------------------------------------------------------------------*/
-template <typename T>
-inline
-AP4_Result
-AP4_List<T>::DeleteReferences()
-{
- Item* item = m_Head;
-
- while (item) {
- Item* next = item->m_Next;
- delete item->m_Data;
- delete item;
- item = next;
- }
-
- // no more items
- m_Head = m_Tail = NULL;
- m_ItemCount = 0;
-
- return AP4_SUCCESS;
-}
-
-#endif // _AP4_LIST_H_
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/thirdparty/Bento4/Core/Ap4MdhdAtom.cpp b/src/thirdparty/Bento4/Core/Ap4MdhdAtom.cpp
deleted file mode 100644
index 335452de1..000000000
--- a/src/thirdparty/Bento4/Core/Ap4MdhdAtom.cpp
+++ /dev/null
@@ -1,172 +0,0 @@
-/*****************************************************************
-|
-| AP4 - mdhd Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4MdhdAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_MdhdAtom::AP4_MdhdAtom
-+---------------------------------------------------------------------*/
-AP4_MdhdAtom::AP4_MdhdAtom(AP4_UI64 creation_time,
- AP4_UI64 modification_time,
- AP4_UI32 time_scale,
- AP4_UI64 duration,
- const char* language) :
- AP4_Atom(AP4_ATOM_TYPE_MDHD, 20+AP4_FULL_ATOM_HEADER_SIZE, true),
- m_CreationTime(creation_time),
- m_ModificationTime(modification_time),
- m_TimeScale(time_scale),
- m_Duration(duration)
-{
- m_Language[0] = language[0];
- m_Language[1] = language[1];
- m_Language[2] = language[2];
-}
-
-/*----------------------------------------------------------------------
-| AP4_MdhdAtom::AP4_MdhdAtom
-+---------------------------------------------------------------------*/
-AP4_MdhdAtom::AP4_MdhdAtom(AP4_Size size, AP4_ByteStream& stream) :
- AP4_Atom(AP4_ATOM_TYPE_MDHD, size, true, stream),
- m_CreationTime(0),
- m_ModificationTime(0),
- m_TimeScale(0),
- m_Duration(0)
-{
- m_Language[0] = 0;
- m_Language[1] = 0;
- m_Language[2] = 0;
-
- if (m_Version == 0) {
- AP4_UI32 tmp = 0;
- stream.ReadUI32(tmp); m_CreationTime = tmp;
- stream.ReadUI32(tmp); m_ModificationTime = tmp;
- stream.ReadUI32(m_TimeScale);
- stream.ReadUI32(tmp); m_Duration = tmp;
- } else if (m_Version == 1) {
- stream.ReadUI64(m_CreationTime);
- stream.ReadUI64(m_ModificationTime);
- stream.ReadUI32(m_TimeScale);
- stream.ReadUI64(m_Duration);
- } else {
- // TODO
- }
-
- unsigned char lang[2];
- stream.Read(lang, 2, NULL);
- char l0 = ((lang[0]>>2)&0x1F);
- char l1 = (((lang[0]&0x3)<<3) | ((lang[1]>>5)&0x7));
- char l2 = ((lang[1]&0x1F));
- if (l0) {
- m_Language[0] = l0+0x60;
- }
- if (l1) {
- m_Language[1] = l1+0x60;
- }
- if (l2) {
- m_Language[2] = l2+0x60;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_MdhdAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_MdhdAtom::WriteFields(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- if (m_Version == 0) {
- // we only deal with version 0 for the moment
- result = stream.WriteUI32((AP4_UI32)m_CreationTime);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI32((AP4_UI32)m_ModificationTime);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI32(m_TimeScale);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI32((AP4_UI32)m_Duration);
- if (AP4_FAILED(result)) return result;
- } else if (m_Version == 1) {
- result = stream.WriteUI64(m_CreationTime);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI64(m_ModificationTime);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI32(m_TimeScale);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI64(m_Duration);
- if (AP4_FAILED(result)) return result;
- } else {
- // TODO
- }
-
- // write the language
- AP4_UI08 l0 = (m_Language[0]==0)?0:(m_Language[0]-0x60);
- AP4_UI08 l1 = (m_Language[1]==0)?0:(m_Language[1]-0x60);
- AP4_UI08 l2 = (m_Language[2]==0)?0:(m_Language[2]-0x60);
- result = stream.WriteUI08(l0<<2 | l1>>3);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI08(l1<<5 | l2);
- if (AP4_FAILED(result)) return result;
-
- // pre-defined
- return stream.WriteUI16(0);
-}
-
-/*----------------------------------------------------------------------
-| AP4_MdhdAtom::GetDurationMs
-+---------------------------------------------------------------------*/
-AP4_UI32
-AP4_MdhdAtom::GetDurationMs()
-{
- return AP4_DurationMsFromUnits(m_Duration, m_TimeScale);
-}
-
-/*----------------------------------------------------------------------
-| AP4_MdhdAtom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_MdhdAtom::InspectFields(AP4_AtomInspector& inspector)
-{
- inspector.AddField("timescale", m_TimeScale);
- inspector.AddField("duration", (AP4_UI32)m_Duration); // TODO
- inspector.AddField("duration(ms)", GetDurationMs());
- char language[4];
- AP4_StringFormat(language, sizeof(language),
- "%c%c%c",
- m_Language[0] ? m_Language[0]:'-',
- m_Language[1] ? m_Language[1]:'-',
- m_Language[2] ? m_Language[2]:'-');
- inspector.AddField("language", (const char*)language);
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4MdhdAtom.h b/src/thirdparty/Bento4/Core/Ap4MdhdAtom.h
deleted file mode 100644
index 7174b9236..000000000
--- a/src/thirdparty/Bento4/Core/Ap4MdhdAtom.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*****************************************************************
-|
-| AP4 - mdhd Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_MDHD_ATOM_H_
-#define _AP4_MDHD_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4List.h"
-#include "Ap4Atom.h"
-
-/*----------------------------------------------------------------------
-| constants
-+---------------------------------------------------------------------*/
-const AP4_UI32 AP4_MDHD_DEFAULT_GENERIC_TIMESCALE = 1000;
-const AP4_UI32 AP4_MDHD_DEFAULT_VIDEO_TIMESCALE = 90000;
-
-/*----------------------------------------------------------------------
-| AP4_MdhdAtom
-+---------------------------------------------------------------------*/
-class AP4_MdhdAtom : public AP4_Atom
-{
- public:
- // methods
- AP4_MdhdAtom(AP4_UI64 creation_time,
- AP4_UI64 modification_time,
- AP4_UI32 time_scale,
- AP4_UI64 duration,
- const char* language);
- AP4_MdhdAtom(AP4_Size size, AP4_ByteStream& stream);
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
- AP4_UI32 GetDurationMs();
- AP4_UI64 GetDuration() { return m_Duration; }
- AP4_UI32 GetTimeScale() { return m_TimeScale; }
- AP4_String GetLanguage() { return AP4_String(m_Language, 3); }
-
- private:
- // members
- AP4_UI64 m_CreationTime;
- AP4_UI64 m_ModificationTime;
- AP4_UI32 m_TimeScale;
- AP4_UI64 m_Duration;
- char m_Language[3];
-};
-
-#endif // _AP4_MDHD_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4MoovAtom.cpp b/src/thirdparty/Bento4/Core/Ap4MoovAtom.cpp
deleted file mode 100644
index 758793c08..000000000
--- a/src/thirdparty/Bento4/Core/Ap4MoovAtom.cpp
+++ /dev/null
@@ -1,196 +0,0 @@
-/*****************************************************************
-|
-| AP4 - moov Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4MoovAtom.h"
-#include "Ap4TrakAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4DcomAtom.h"
-#include "Ap4CmvdAtom.h"
-#include "zlib/zlib.h"
-
-/*----------------------------------------------------------------------
-| AP4_TrakAtomCollector
-+---------------------------------------------------------------------*/
-class AP4_TrakAtomCollector : public AP4_List<AP4_Atom>::Item::Operator
-{
-public:
- AP4_TrakAtomCollector(AP4_List<AP4_TrakAtom>* track_atoms) :
- m_TrakAtoms(track_atoms) {}
-
- AP4_Result Action(AP4_Atom* atom) const {
- if (atom->GetType() == AP4_ATOM_TYPE_TRAK) {
- AP4_TrakAtom* trak = dynamic_cast<AP4_TrakAtom*>(atom);
- if (trak) {
- m_TrakAtoms->Add(trak);
- }
- }
- return AP4_SUCCESS;
- }
-
-private:
- AP4_List<AP4_TrakAtom>* m_TrakAtoms;
-};
-
-/*----------------------------------------------------------------------
-| AP4_MoovAtom::AP4_MoovAtom
-+---------------------------------------------------------------------*/
-AP4_MoovAtom::AP4_MoovAtom() :
- AP4_ContainerAtom(AP4_ATOM_TYPE_MOOV),
- m_TimeScale(0)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_MoovAtom::AP4_MoovAtom
-+---------------------------------------------------------------------*/
-AP4_MoovAtom::AP4_MoovAtom(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
- AP4_ContainerAtom(AP4_ATOM_TYPE_MOOV, size, false, stream, atom_factory),
- m_TimeScale(0)
-{
- if(AP4_ContainerAtom* cmov = dynamic_cast<AP4_ContainerAtom*>(GetChild(AP4_ATOM_TYPE_CMOV)))
- {
- AP4_DcomAtom* dcom = dynamic_cast<AP4_DcomAtom*>(cmov->GetChild(AP4_ATOM_TYPE_DCOM));
- AP4_CmvdAtom* cmvd = dynamic_cast<AP4_CmvdAtom*>(cmov->GetChild(AP4_ATOM_TYPE_CMVD));
-
- if(dcom && dcom->GetCompressorSubType() == AP4_ATOM_TYPE('z','l','i','b') && cmvd)
- {
- const AP4_DataBuffer& data = cmvd->GetDataBuffer();
-
- z_stream d_stream;
- d_stream.zalloc = (alloc_func)0;
- d_stream.zfree = (free_func)0;
- d_stream.opaque = (voidpf)0;
-
- int res;
-
- if(Z_OK == (res = inflateInit(&d_stream)))
- {
- d_stream.next_in = (Bytef*)data.GetData();
- d_stream.avail_in = data.GetDataSize();
-
- unsigned char* dst = NULL;
- int n = 0;
-
- do
- {
- dst = (unsigned char*)realloc(dst, ++n*1000);
- d_stream.next_out = &dst[(n-1)*1000];
- d_stream.avail_out = 1000;
-
- if(Z_OK != (res = inflate(&d_stream, Z_NO_FLUSH)) && Z_STREAM_END != res)
- {
- free(dst);
- dst = NULL;
- break;
- }
- }
- while(0 == d_stream.avail_out && 0 != d_stream.avail_in && Z_STREAM_END != res);
-
- inflateEnd(&d_stream);
-
- if(dst)
- {
- AP4_ByteStream* s = new AP4_MemoryByteStream(dst, d_stream.total_out);
- ReadChildren(atom_factory, *s, d_stream.total_out);
- s->Release();
- free(dst);
- }
-
- if(AP4_MoovAtom* moov = dynamic_cast<AP4_MoovAtom*>(GetChild(AP4_ATOM_TYPE_MOOV)))
- {
- AP4_List<AP4_Atom> Children;
-
- for(AP4_List<AP4_Atom>::Item* item = moov->GetChildren().FirstItem();
- item;
- item = item->GetNext())
- {
- Children.Add(item->GetData());
- }
-
- for(AP4_List<AP4_Atom>::Item* item = Children.FirstItem();
- item;
- item = item->GetNext())
- {
- AP4_Atom* atom = item->GetData();
- atom->Detach();
- atom->SetParent(this);
- m_Children.Add(atom);
- }
-
- moov->Detach();
- delete moov;
- }
- }
- }
- }
-
- // collect all trak atoms
- m_Children.Apply(AP4_TrakAtomCollector(&m_TrakAtoms));
-}
-
-/*----------------------------------------------------------------------
-| AP4_MoovAtom::OnChildAdded
-+---------------------------------------------------------------------*/
-void
-AP4_MoovAtom::OnChildAdded(AP4_Atom* atom)
-{
- // keep the atom in the list of trak atoms
- if (atom->GetType() == AP4_ATOM_TYPE_TRAK) {
- AP4_TrakAtom* trak = dynamic_cast<AP4_TrakAtom*>(atom);
- if (trak) {
- m_TrakAtoms.Add(trak);
- }
- }
-
- // call the base class implementation
- AP4_ContainerAtom::OnChildAdded(atom);
-}
-
-/*----------------------------------------------------------------------
-| AP4_MoovAtom::OnChildRemoved
-+---------------------------------------------------------------------*/
-void
-AP4_MoovAtom::OnChildRemoved(AP4_Atom* atom)
-{
- // remove the atom from the list of trak atoms
- if (atom->GetType() == AP4_ATOM_TYPE_TRAK) {
- AP4_TrakAtom* trak = dynamic_cast<AP4_TrakAtom*>(atom);
- if (trak) {
- m_TrakAtoms.Remove(trak);
- }
- }
-
- // call the base class implementation
- AP4_ContainerAtom::OnChildRemoved(atom);
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4MoovAtom.h b/src/thirdparty/Bento4/Core/Ap4MoovAtom.h
deleted file mode 100644
index 215423173..000000000
--- a/src/thirdparty/Bento4/Core/Ap4MoovAtom.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*****************************************************************
-|
-| AP4 - moov Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_MOOV_ATOM_H_
-#define _AP4_MOOV_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4List.h"
-#include "Ap4Atom.h"
-#include "Ap4TrakAtom.h"
-#include "Ap4ContainerAtom.h"
-#include "Ap4AtomFactory.h"
-
-/*----------------------------------------------------------------------
-| AP4_MoovAtom
-+---------------------------------------------------------------------*/
-class AP4_MoovAtom : public AP4_ContainerAtom
-{
-public:
- // methods
- AP4_MoovAtom();
- AP4_MoovAtom(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory);
- AP4_List<AP4_TrakAtom>& GetTrakAtoms() {
- return m_TrakAtoms;
- }
- AP4_UI32 GetTimeScale() {
- return m_TimeScale;
- }
-
- // AP4_AtomParent methods
- void OnChildAdded(AP4_Atom* atom);
- void OnChildRemoved(AP4_Atom* atom);
-
-private:
- // members
- AP4_List<AP4_TrakAtom> m_TrakAtoms;
- AP4_UI32 m_TimeScale;
-};
-
-#endif // _AP4_MOOV_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4Movie.cpp b/src/thirdparty/Bento4/Core/Ap4Movie.cpp
deleted file mode 100644
index 021a8c7ce..000000000
--- a/src/thirdparty/Bento4/Core/Ap4Movie.cpp
+++ /dev/null
@@ -1,235 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Movie
-|
-| Copyright 2002-2005 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4File.h"
-#include "Ap4Atom.h"
-#include "Ap4TrakAtom.h"
-#include "Ap4MoovAtom.h"
-#include "Ap4MvhdAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4Movie.h"
-
-/*----------------------------------------------------------------------
-| AP4_TrackFinderById
-+---------------------------------------------------------------------*/
-class AP4_TrackFinderById : public AP4_List<AP4_Track>::Item::Finder
-{
-public:
- AP4_TrackFinderById(AP4_UI32 track_id) : m_TrackId(track_id) {}
- AP4_Result Test(AP4_Track* track) const {
- return track->GetId() == m_TrackId ? AP4_SUCCESS : AP4_FAILURE;
- }
-private:
- AP4_UI32 m_TrackId;
-};
-
-/*----------------------------------------------------------------------
-| AP4_TrackFinderByType
-+---------------------------------------------------------------------*/
-class AP4_TrackFinderByType : public AP4_List<AP4_Track>::Item::Finder
-{
-public:
- AP4_TrackFinderByType(AP4_Track::Type type, AP4_Ordinal index = 0) :
- m_Type(type), m_Index(index) {}
- AP4_Result Test(AP4_Track* track) const {
- if (track->GetType() == m_Type && m_Index-- == 0) {
- return AP4_SUCCESS;
- } else {
- return AP4_FAILURE;
- }
- }
-private:
- AP4_Track::Type m_Type;
- mutable AP4_Ordinal m_Index;
-};
-
-/*----------------------------------------------------------------------
-| AP4_Movie::AP4_Movie
-+---------------------------------------------------------------------*/
-AP4_Movie::AP4_Movie(AP4_UI32 time_scale)
-{
- m_MoovAtom = new AP4_MoovAtom();
- m_MvhdAtom = new AP4_MvhdAtom(0, 0,
- time_scale,
- 0,
- 0x00010000,
- 0x0100);
- m_MoovAtom->AddChild(m_MvhdAtom);
-}
-
-/*----------------------------------------------------------------------
-| AP4_Movie::AP4_Moovie
-+---------------------------------------------------------------------*/
-AP4_Movie::AP4_Movie(AP4_MoovAtom* moov, AP4_ByteStream& mdat) :
- m_MoovAtom(moov)
-{
- // ignore null atoms
- if (moov == NULL) return;
-
- // get the time scale
- AP4_UI32 time_scale;
- m_MvhdAtom = dynamic_cast<AP4_MvhdAtom*>(moov->GetChild(AP4_ATOM_TYPE_MVHD));
- if (m_MvhdAtom) {
- time_scale = m_MvhdAtom->GetTimeScale();
- } else {
- time_scale = 0;
- }
-
- // get all tracks
- AP4_List<AP4_TrakAtom>* trak_atoms;
- trak_atoms = &moov->GetTrakAtoms();
- AP4_List<AP4_TrakAtom>::Item* item = trak_atoms->FirstItem();
- while (item) {
- AP4_Track* track = new AP4_Track(*item->GetData(),
- mdat,
- time_scale);
- m_Tracks.Add(track);
- item = item->GetNext();
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_Movie::~AP4_Movie
-+---------------------------------------------------------------------*/
-AP4_Movie::~AP4_Movie()
-{
- m_Tracks.DeleteReferences();
- delete m_MoovAtom;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Movie::Inspect
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Movie::Inspect(AP4_AtomInspector& inspector)
-{
- // dump the moov atom
- return m_MoovAtom->Inspect(inspector);
-}
-
-/*----------------------------------------------------------------------
-| AP4_Movie::GetTrack
-+---------------------------------------------------------------------*/
-AP4_Track*
-AP4_Movie::GetTrack(AP4_UI32 track_id)
-{
- AP4_Track* track = NULL;
- if (AP4_SUCCEEDED(m_Tracks.Find(AP4_TrackFinderById(track_id), track))) {
- return track;
- } else {
- return NULL;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_Movie::GetTrack
-+---------------------------------------------------------------------*/
-AP4_Track*
-AP4_Movie::GetTrack(AP4_Track::Type track_type, AP4_Ordinal index)
-{
- AP4_Track* track = NULL;
- if (AP4_SUCCEEDED(m_Tracks.Find(AP4_TrackFinderByType(track_type, index), track))) {
- return track;
- } else {
- return NULL;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_Movie::AddTrack
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Movie::AddTrack(AP4_Track* track)
-{
- // assign an ID to the track unless it already has one
- if (track->GetId() == 0) {
- track->SetId(m_Tracks.ItemCount()+1);
- }
-
- // if we don't have a time scale, use the one from the track
- if (m_MvhdAtom->GetTimeScale() == 0) {
- m_MvhdAtom->SetTimeScale(track->GetMediaTimeScale());
- }
-
- // adjust the parent time scale of the track
- track->SetMovieTimeScale(m_MvhdAtom->GetTimeScale());
-
- // update the movie duration
- if (m_MvhdAtom->GetDuration() < track->GetDuration()) {
- m_MvhdAtom->SetDuration(track->GetDuration());
- }
-
- // attach the track as a child
- m_MoovAtom->AddChild(track->GetTrakAtom());
- m_Tracks.Add(track);
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Movie::GetTimeScale
-+---------------------------------------------------------------------*/
-AP4_UI32
-AP4_Movie::GetTimeScale()
-{
- if (m_MvhdAtom) {
- return m_MvhdAtom->GetTimeScale();
- } else {
- return 0;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_Movie::GetDuration
-+---------------------------------------------------------------------*/
-AP4_UI64
-AP4_Movie::GetDuration()
-{
- if (m_MvhdAtom) {
- return m_MvhdAtom->GetDuration();
- } else {
- return 0;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_Movie::GetDurationMs
-+---------------------------------------------------------------------*/
-AP4_Duration
-AP4_Movie::GetDurationMs()
-{
- if (m_MvhdAtom) {
- return m_MvhdAtom->GetDurationMs();
- } else {
- return 0;
- }
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4Movie.h b/src/thirdparty/Bento4/Core/Ap4Movie.h
deleted file mode 100644
index 8c1ca5ca5..000000000
--- a/src/thirdparty/Bento4/Core/Ap4Movie.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Movie
-|
-| Copyright 2002-2005 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_MOVIE_H_
-#define _AP4_MOVIE_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4MoovAtom.h"
-#include "Ap4MvhdAtom.h"
-#include "Ap4Track.h"
-#include "Ap4List.h"
-#include "Ap4ByteStream.h"
-
-/*----------------------------------------------------------------------
-| AP4_Movie
-+---------------------------------------------------------------------*/
-class AP4_Movie {
-public:
- // methods
- AP4_Movie(AP4_UI32 time_scale = 0);
- AP4_Movie(AP4_MoovAtom* moov, AP4_ByteStream& mdat);
- virtual ~AP4_Movie();
- AP4_Result Inspect(AP4_AtomInspector& inspector);
-
- AP4_MoovAtom* GetMoovAtom() { return m_MoovAtom;}
- AP4_MvhdAtom* GetMvhdAtom() { return m_MvhdAtom;}
- AP4_List<AP4_Track>& GetTracks() { return m_Tracks; }
- AP4_Track* GetTrack(AP4_UI32 track_id);
- AP4_Track* GetTrack(AP4_Track::Type type, AP4_Ordinal index = 0);
- AP4_Result AddTrack(AP4_Track* track);
- AP4_UI32 GetTimeScale();
- AP4_Duration GetDuration();
- AP4_Duration GetDurationMs();
-
-private:
- // members
- AP4_MoovAtom* m_MoovAtom;
- AP4_MvhdAtom* m_MvhdAtom;
- AP4_List<AP4_Track> m_Tracks;
-};
-
-#endif // _AP4_MOVIE_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4MvhdAtom.cpp b/src/thirdparty/Bento4/Core/Ap4MvhdAtom.cpp
deleted file mode 100644
index fdd0defa3..000000000
--- a/src/thirdparty/Bento4/Core/Ap4MvhdAtom.cpp
+++ /dev/null
@@ -1,182 +0,0 @@
-/*****************************************************************
-|
-| AP4 - mvhd Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4MvhdAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_MvhdAtom::AP4_MvhdAtom
-+---------------------------------------------------------------------*/
-AP4_MvhdAtom::AP4_MvhdAtom(AP4_UI64 creation_time,
- AP4_UI64 modification_time,
- AP4_UI32 time_scale,
- AP4_UI64 duration,
- AP4_UI32 rate,
- AP4_UI16 volume) :
- AP4_Atom(AP4_ATOM_TYPE_MVHD, 96+AP4_FULL_ATOM_HEADER_SIZE, true),
- m_CreationTime(creation_time),
- m_ModificationTime(modification_time),
- m_TimeScale(time_scale),
- m_Duration(duration),
- m_Rate(rate),
- m_Volume(volume),
- m_NextTrackId(0xFFFFFFFF)
-{
- m_Matrix[0] = 0x00010000;
- m_Matrix[1] = 0;
- m_Matrix[2] = 0;
- m_Matrix[3] = 0;
- m_Matrix[4] = 0x00010000;
- m_Matrix[5] = 0;
- m_Matrix[6] = 0;
- m_Matrix[7] = 0;
- m_Matrix[8] = 0x40000000;
-
- memset(m_Reserved1, 0, sizeof(m_Reserved1));
- memset(m_Reserved2, 0, sizeof(m_Reserved2));
- memset(m_Predefined, 0, sizeof(m_Predefined));
-}
-
-/*----------------------------------------------------------------------
-| AP4_MvhdAtom::AP4_MvhdAtom
-+---------------------------------------------------------------------*/
-AP4_MvhdAtom::AP4_MvhdAtom(AP4_Size size, AP4_ByteStream& stream) :
- AP4_Atom(AP4_ATOM_TYPE_MVHD, size, true, stream)
-{
- if (m_Version == 0) {
- AP4_UI32 tmp = 0;
- stream.ReadUI32(tmp); m_CreationTime = tmp;
- stream.ReadUI32(tmp); m_ModificationTime = tmp;
- stream.ReadUI32(m_TimeScale);
- stream.ReadUI32(tmp); m_Duration = tmp;
- } else if (m_Version == 1) {
- stream.ReadUI64(m_CreationTime);
- stream.ReadUI64(m_ModificationTime);
- stream.ReadUI32(m_TimeScale);
- stream.ReadUI64(m_Duration);
- } else {
- // TODO
- }
-
- stream.ReadUI32(m_Rate);
- stream.ReadUI16(m_Volume);
- stream.Read(m_Reserved1, sizeof(m_Reserved1));
- stream.Read(m_Reserved2, sizeof(m_Reserved2));
- for (int i=0; i<9; i++) {
- stream.ReadUI32(m_Matrix[i]);
- }
- stream.Read(m_Predefined, sizeof(m_Predefined));
- stream.ReadUI32(m_NextTrackId);
-}
-
-/*----------------------------------------------------------------------
-| AP4_MvhdAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_MvhdAtom::WriteFields(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- if (m_Version == 0) {
- result = stream.WriteUI32((AP4_UI32)m_CreationTime);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI32((AP4_UI32)m_ModificationTime);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI32(m_TimeScale);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI32((AP4_UI32)m_Duration);
- if (AP4_FAILED(result)) return result;
- } else if (m_Version == 1) {
- result = stream.WriteUI64(m_CreationTime);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI64(m_ModificationTime);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI32(m_TimeScale);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI64(m_Duration);
- if (AP4_FAILED(result)) return result;
- } else {
- // TODO
- }
-
- // rate & volume
- result = stream.WriteUI32(m_Rate);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI16(m_Volume);
- if (AP4_FAILED(result)) return result;
-
- // reserved
- result = stream.Write(m_Reserved1, sizeof(m_Reserved1));
- if (AP4_FAILED(result)) return result;
- result = stream.Write(m_Reserved2, sizeof(m_Reserved2));
- if (AP4_FAILED(result)) return result;
-
- // matrix
- for (int i=0; i<9; i++) {
- result = stream.WriteUI32(m_Matrix[i]);
- if (AP4_FAILED(result)) return result;
- }
-
- // pre-defined
- result = stream.Write(m_Predefined, sizeof(m_Predefined));
- if (AP4_FAILED(result)) return result;
-
- // next track id
- return stream.WriteUI32(m_NextTrackId);
-}
-
-/*----------------------------------------------------------------------
-| AP4_MvhdAtom::GetDurationMs
-+---------------------------------------------------------------------*/
-AP4_Duration
-AP4_MvhdAtom::GetDurationMs()
-{
- if (m_TimeScale) {
- return AP4_ConvertTime(m_Duration, m_TimeScale, 1000);
- } else {
- return 0;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_MvhdAtom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_MvhdAtom::InspectFields(AP4_AtomInspector& inspector)
-{
- inspector.AddField("timescale", m_TimeScale);
- inspector.AddField("duration", (AP4_UI32)m_Duration);
- inspector.AddField("duration(ms)", (AP4_UI32)GetDurationMs());
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4MvhdAtom.h b/src/thirdparty/Bento4/Core/Ap4MvhdAtom.h
deleted file mode 100644
index c71df2e2f..000000000
--- a/src/thirdparty/Bento4/Core/Ap4MvhdAtom.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*****************************************************************
-|
-| AP4 - mvhd Atoms
-|
-| Copyright 2002-2005 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_MVHD_ATOM_H_
-#define _AP4_MVHD_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4List.h"
-#include "Ap4Atom.h"
-
-/*----------------------------------------------------------------------
-| AP4_MvhdAtom
-+---------------------------------------------------------------------*/
-class AP4_MvhdAtom : public AP4_Atom
-{
-public:
- // methods
- AP4_MvhdAtom(AP4_UI64 creation_time,
- AP4_UI64 modification_time,
- AP4_UI32 time_scale,
- AP4_UI64 duration,
- AP4_UI32 rate,
- AP4_UI16 volume);
- AP4_MvhdAtom(AP4_Size size, AP4_ByteStream& stream);
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- AP4_UI64 GetDuration() { return m_Duration; }
- void SetDuration(AP4_UI64 duration) { m_Duration = duration;}
- AP4_Duration GetDurationMs();
- AP4_UI32 GetTimeScale() { return m_TimeScale; }
- AP4_Result SetTimeScale(AP4_UI32 time_scale) {
- m_TimeScale = time_scale;
- return AP4_SUCCESS;
- }
-
-private:
- // members
- AP4_UI64 m_CreationTime;
- AP4_UI64 m_ModificationTime;
- AP4_UI32 m_TimeScale;
- AP4_UI64 m_Duration;
- AP4_UI32 m_Rate;
- AP4_UI16 m_Volume;
- AP4_UI08 m_Reserved1[2];
- AP4_UI08 m_Reserved2[8];
- AP4_UI32 m_Matrix[9];
- AP4_UI08 m_Predefined[24];
- AP4_UI32 m_NextTrackId;
-};
-
-#endif // _AP4_MVHD_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4NmhdAtom.cpp b/src/thirdparty/Bento4/Core/Ap4NmhdAtom.cpp
deleted file mode 100644
index 9a039b2d9..000000000
--- a/src/thirdparty/Bento4/Core/Ap4NmhdAtom.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*****************************************************************
-|
-| AP4 - nmhd Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4NmhdAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_NmhdAtom::AP4_NmhdAtom
-+---------------------------------------------------------------------*/
-AP4_NmhdAtom::AP4_NmhdAtom() :
- AP4_Atom(AP4_ATOM_TYPE_NMHD, AP4_FULL_ATOM_HEADER_SIZE, true)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_NmhdAtom::AP4_NmhdAtom
-+---------------------------------------------------------------------*/
-AP4_NmhdAtom::AP4_NmhdAtom(AP4_Size size, AP4_ByteStream& stream) :
- AP4_Atom(AP4_ATOM_TYPE_NMHD, size, true, stream)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_NmhdAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_NmhdAtom::WriteFields(AP4_ByteStream& stream)
-{
- // not implemented yet
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4NmhdAtom.h b/src/thirdparty/Bento4/Core/Ap4NmhdAtom.h
deleted file mode 100644
index b7ad7d3ce..000000000
--- a/src/thirdparty/Bento4/Core/Ap4NmhdAtom.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*****************************************************************
-|
-| AP4 - nmhd Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-#ifndef _AP4_NMHD_ATOM_H_
-#define _AP4_NMHD_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4Atom.h"
-
-/*----------------------------------------------------------------------
-| AP4_NmhdAtom
-+---------------------------------------------------------------------*/
-class AP4_NmhdAtom : public AP4_Atom
-{
-public:
- // methods
- AP4_NmhdAtom();
- AP4_NmhdAtom(AP4_Size size, AP4_ByteStream& stream);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-};
-
-#endif // _AP4_NMHD_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4PaspAtom.cpp b/src/thirdparty/Bento4/Core/Ap4PaspAtom.cpp
deleted file mode 100644
index d53508796..000000000
--- a/src/thirdparty/Bento4/Core/Ap4PaspAtom.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-/*****************************************************************
-|
-| AP4 - pasp Atom
-|
-| Copyright 2011 Aleksoid1978
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-
-#include "Ap4.h"
-#include "Ap4PaspAtom.h"
-
-/*----------------------------------------------------------------------
-| AP4_PaspAtom::AP4_PaspAtom
-+---------------------------------------------------------------------*/
-
-AP4_PaspAtom::AP4_PaspAtom(AP4_Size size,
- AP4_ByteStream& stream)
- : AP4_Atom(AP4_ATOM_TYPE_PASP)
-{
- size -= AP4_ATOM_HEADER_SIZE;
- stream.ReadUI32(m_num);
- stream.ReadUI32(m_den);
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4PaspAtom.h b/src/thirdparty/Bento4/Core/Ap4PaspAtom.h
deleted file mode 100644
index caa5ee9fb..000000000
--- a/src/thirdparty/Bento4/Core/Ap4PaspAtom.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*****************************************************************
-|
-| AP4 - pasp Atom
-|
-| Copyright 2011 Aleksoid1978
-|
- ****************************************************************/
-
-#ifndef _AP4_PASP_ATOM_H_
-#define _AP4_PASP_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4Atom.h"
-#include "Ap4Types.h"
-#include "Ap4Array.h"
-#include "Ap4DataBuffer.h"
-
-/*----------------------------------------------------------------------
-| AP4_PaspAtom
-+---------------------------------------------------------------------*/
-
-class AP4_PaspAtom : public AP4_Atom
-{
-public:
- AP4_PaspAtom(AP4_Size size,
- AP4_ByteStream& stream);
-
- AP4_Result WriteFields(AP4_ByteStream& stream) { return AP4_FAILURE; }
-
- AP4_UI32 GetNum() const { return m_num; }
- AP4_UI32 GetDen() const { return m_den; }
-
-private:
- AP4_UI32 m_num;
- AP4_UI32 m_den;
-
-};
-
-#endif // _AP4_PASP_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4Processor.cpp b/src/thirdparty/Bento4/Core/Ap4Processor.cpp
deleted file mode 100644
index d9bd5ec9b..000000000
--- a/src/thirdparty/Bento4/Core/Ap4Processor.cpp
+++ /dev/null
@@ -1,297 +0,0 @@
-/*****************************************************************
-|
-| AP4 - File Processor
-|
-| Copyright 2003-2005 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4Processor.h"
-#include "Ap4AtomSampleTable.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4MoovAtom.h"
-#include "Ap4Array.h"
-#include "Ap4Debug.h"
-
-/*----------------------------------------------------------------------
-| types
-+---------------------------------------------------------------------*/
-class AP4_SampleLocator {
-public:
- AP4_SampleLocator() :
- m_TrakIndex(0),
- m_SampleTable(NULL),
- m_SampleIndex(0),
- m_Chunk(0) {}
-
- AP4_Ordinal m_TrakIndex;
- AP4_AtomSampleTable* m_SampleTable;
- AP4_Ordinal m_SampleIndex;
- AP4_Sample m_Sample;
- AP4_Ordinal m_Chunk;
-};
-
-struct AP4_SampleCursor {
- AP4_SampleLocator m_Locator;
-};
-
-/*----------------------------------------------------------------------
-| AP4_Processor::Process
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Processor::Process(AP4_ByteStream& input,
- AP4_ByteStream& output,
- AP4_AtomFactory& atom_factory)
-{
- // read all atoms
- AP4_AtomParent top_level;
- AP4_Atom* atom;
- while (AP4_SUCCEEDED(atom_factory.CreateAtomFromStream(input, atom))) {
- top_level.AddChild(atom);
- }
-
- // remove the [mdat] and [free] atoms, keep a ref to [moov]
- AP4_MoovAtom* moov = NULL;
- AP4_List<AP4_Atom>::Item* atom_item = top_level.GetChildren().FirstItem();
- while (atom_item) {
- atom = atom_item->GetData();
- AP4_List<AP4_Atom>::Item* next = atom_item->GetNext();
- if (//atom->GetType() == AP4_ATOM_TYPE_FREE ||
- atom->GetType() == AP4_ATOM_TYPE_MDAT) {
- atom->Detach();
- delete atom;
- } else if (atom->GetType() == AP4_ATOM_TYPE_MOOV) {
- moov = (AP4_MoovAtom*)atom;
- }
- atom_item = next;
- }
-
- // check that we have a moov atom
- if (moov == NULL) return AP4_FAILURE;
-
- // initialize the processor
- AP4_Result result = Initialize(top_level);
- if (AP4_FAILED(result)) return result;
-
- // build an array of track sample cursors
- AP4_List<AP4_TrakAtom>& trak_atoms = moov->GetTrakAtoms();
- AP4_Cardinal track_count = trak_atoms.ItemCount();
- AP4_SampleCursor* cursors = new AP4_SampleCursor[track_count];
- TrackHandler** handlers = new TrackHandler*[track_count];
- AP4_List<AP4_TrakAtom>::Item* item = trak_atoms.FirstItem();
- unsigned int index = 0;
- while (item) {
- // create the track handler // find the stsd atom
- AP4_ContainerAtom* stbl = dynamic_cast<AP4_ContainerAtom*>(
- item->GetData()->FindChild("mdia/minf/stbl"));
- if (stbl == NULL) continue;
- handlers[index] = CreateTrackHandler(item->GetData());
- cursors[index].m_Locator.m_TrakIndex = index;
- cursors[index].m_Locator.m_SampleTable = new AP4_AtomSampleTable(stbl, input);
- cursors[index].m_Locator.m_SampleIndex = 0;
- cursors[index].m_Locator.m_SampleTable->GetSample(0, cursors[index].m_Locator.m_Sample);
- cursors[index].m_Locator.m_Chunk = 1;
- index++;
- item = item->GetNext();
- }
-
- // figure out the layout of the chunks
- AP4_Array<AP4_SampleLocator> locators;
- for (;;) {
- // see which is the next sample to write
- unsigned int min_offset = 0xFFFFFFFF;
- int cursor = -1;
- for (unsigned int i=0; i<track_count; i++) {
- if (cursors[i].m_Locator.m_SampleTable &&
- cursors[i].m_Locator.m_Sample.GetOffset() <= min_offset) {
- min_offset = cursors[i].m_Locator.m_Sample.GetOffset();
- cursor = i;
- }
- }
-
- // stop if all cursors are exhausted
- if (cursor == -1) break;
-
- // append this locator to the layout list
- AP4_SampleLocator& locator = cursors[cursor].m_Locator;
- locators.Append(locator);
- //AP4_Debug("NEXT: track %d, sample %d:%d: offset=%d, size=%d\n",
- // locator.m_TrakIndex,
- // locator.m_Chunk,
- // locator.m_SampleIndex,
- // locator.m_Sample.GetOffset(),
- // locator.m_Sample.GetSize());
-
- // move the cursor to the next sample
- locator.m_SampleIndex++;
- if (locator.m_SampleIndex == locator.m_SampleTable->GetSampleCount()) {
- // mark this track as completed
- locator.m_SampleTable = NULL;
- } else {
- // get the next sample info
- locator.m_SampleTable->GetSample(locator.m_SampleIndex,
- locator.m_Sample);
- AP4_Ordinal skip, sdesc;
- locator.m_SampleTable->GetChunkForSample(locator.m_SampleIndex+1, // the internal API is 1-based
- locator.m_Chunk,
- skip, sdesc);
- }
- }
-
- // update the stbl atoms and compute the mdat size
- AP4_Size mdat_size = 0;
- int current_track = -1;
- int current_chunk = -1;
- AP4_Offset current_chunk_offset = 0;
- AP4_Size current_chunk_size = 0;
- for (AP4_Ordinal i=0; i<locators.ItemCount(); i++) {
- AP4_SampleLocator& locator = locators[i];
- if ((int)locator.m_TrakIndex != current_track ||
- (int)locator.m_Chunk != current_chunk) {
- // start a new chunk for this track
- current_chunk_offset += current_chunk_size;
- current_chunk_size = 0;
- current_track = locator.m_TrakIndex;
- current_chunk = locator.m_Chunk;
- locator.m_SampleTable->SetChunkOffset(locator.m_Chunk,
- current_chunk_offset);
- }
- AP4_Size sample_size;
- TrackHandler* handler = handlers[locator.m_TrakIndex];
- if (handler) {
- sample_size = handler->GetProcessedSampleSize(locator.m_Sample);
- locator.m_SampleTable->SetSampleSize(locator.m_SampleIndex+1, sample_size);
- } else {
- sample_size = locator.m_Sample.GetSize();
- }
- current_chunk_size += sample_size;
- mdat_size += sample_size;
- }
-
- // process the tracks (ex: sample descriptions processing)
- for (AP4_Ordinal i=0; i<track_count; i++) {
- TrackHandler* handler = handlers[i];
- if (handler) handler->ProcessTrack();
- }
-
- // initialize the processor
- Finalize(top_level);
-
- // calculate the size of all atoms combined
- AP4_Size atoms_size = 0;
- top_level.GetChildren().Apply(AP4_AtomSizeAdder(atoms_size));
-
- // adjust the chunk offsets
- for (AP4_Ordinal i=0; i<track_count; i++) {
- AP4_TrakAtom* trak;
- trak_atoms.Get(i, trak);
- trak->AdjustChunkOffsets(atoms_size+AP4_ATOM_HEADER_SIZE);
- }
-
- // write all atoms
- top_level.GetChildren().Apply(AP4_AtomListWriter(output));
-
- // write mdat header
- output.WriteUI32(mdat_size+AP4_ATOM_HEADER_SIZE);
- output.WriteUI32(AP4_ATOM_TYPE_MDAT);
-
-#if defined(AP4_DEBUG)
- AP4_Offset before;
- output.Tell(before);
-#endif
-
- // write the samples
- AP4_Sample sample;
- AP4_DataBuffer data_in;
- AP4_DataBuffer data_out;
- for (unsigned int i=0; i<locators.ItemCount(); i++) {
- AP4_SampleLocator& locator = locators[i];
- locator.m_Sample.ReadData(data_in);
- TrackHandler* handler = handlers[locator.m_TrakIndex];
- if (handler) {
- handler->ProcessSample(data_in, data_out);
- output.Write(data_out.GetData(), data_out.GetDataSize());
- } else {
- output.Write(data_in.GetData(), data_in.GetDataSize());
- }
- }
-
-#if defined(AP4_DEBUG)
- AP4_Offset after;
- output.Tell(after);
- AP4_ASSERT(after-before == mdat_size);
-#endif
-
- // cleanup
- delete[] cursors;
- for (unsigned int i=0; i<track_count; i++) {
- delete handlers[i];
- }
- delete[] handlers;
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Processor:Initialize
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Processor::Initialize(AP4_AtomParent& top_level)
-{
- // default implementation: do nothing
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Processor:Finalize
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Processor::Finalize(AP4_AtomParent& top_level)
-{
- // default implementation: do nothing
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Processor:CreateTrackHandler
-+---------------------------------------------------------------------*/
-AP4_Processor::TrackHandler*
-AP4_Processor::CreateTrackHandler(AP4_TrakAtom* /* trak */)
-{
- // default implementation: no handler
- return NULL;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Processor::TrackHandler::GetProcessedSampleSize
-+---------------------------------------------------------------------*/
-AP4_Size
-AP4_Processor::TrackHandler::GetProcessedSampleSize(AP4_Sample& sample)
-{
- // default implementation: do no change the sample size
- return sample.GetSize();
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4Processor.h b/src/thirdparty/Bento4/Core/Ap4Processor.h
deleted file mode 100644
index 7d1f03d4f..000000000
--- a/src/thirdparty/Bento4/Core/Ap4Processor.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*****************************************************************
-|
-| AP4 - File Processor
-|
-| Copyright 2003 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4AtomFactory.h"
-
-/*----------------------------------------------------------------------
-| class references
-+---------------------------------------------------------------------*/
-class AP4_ContainerAtom;
-class AP4_Sample;
-class AP4_ByteStream;
-class AP4_DataBuffer;
-class AP4_TrakAtom;
-
-/*----------------------------------------------------------------------
-| AP4_Processor
-+---------------------------------------------------------------------*/
-class AP4_Processor {
-public:
- // types
- class TrackHandler {
- public:
- virtual ~TrackHandler() {}
- virtual AP4_Size GetProcessedSampleSize(AP4_Sample& sample);
- virtual AP4_Result ProcessTrack() { return AP4_SUCCESS; }
- virtual AP4_Result ProcessSample(AP4_DataBuffer& data_in,
- AP4_DataBuffer& data_out) = 0;
- };
-
- // constructor and destructor
- virtual ~AP4_Processor() {}
-
- // abstract base class methods
- AP4_Result Process(AP4_ByteStream& input,
- AP4_ByteStream& output,
- AP4_AtomFactory& atom_factory =
- AP4_AtomFactory::DefaultFactory);
-
- // overridable methods
- virtual AP4_Result Initialize(AP4_AtomParent& top_level);
- virtual AP4_Result Finalize(AP4_AtomParent& top_level);
- virtual TrackHandler* CreateTrackHandler(AP4_TrakAtom* trak);
-};
diff --git a/src/thirdparty/Bento4/Core/Ap4Results.h b/src/thirdparty/Bento4/Core/Ap4Results.h
deleted file mode 100644
index 21d3cf5ed..000000000
--- a/src/thirdparty/Bento4/Core/Ap4Results.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Result Codes
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_RESULTS_H_
-#define _AP4_RESULTS_H_
-
-/*----------------------------------------------------------------------
-| constants
-+---------------------------------------------------------------------*/
-const int AP4_SUCCESS = 0;
-const int AP4_FAILURE = -1;
-const int AP4_ERROR_OUT_OF_MEMORY = -2;
-const int AP4_ERROR_INVALID_PARAMETERS = -3;
-const int AP4_ERROR_NO_SUCH_FILE = -4;
-const int AP4_ERROR_PERMISSION_DENIED = -5;
-const int AP4_ERROR_CANNOT_OPEN_FILE = -6;
-const int AP4_ERROR_EOS = -7;
-const int AP4_ERROR_WRITE_FAILED = -8;
-const int AP4_ERROR_READ_FAILED = -9;
-const int AP4_ERROR_INVALID_FORMAT = -10;
-const int AP4_ERROR_NO_SUCH_ITEM = -11;
-const int AP4_ERROR_OUT_OF_RANGE = -12;
-const int AP4_ERROR_INTERNAL = -13;
-const int AP4_ERROR_INVALID_STATE = -14;
-const int AP4_ERROR_LIST_EMPTY = -15;
-const int AP4_ERROR_LIST_OPERATION_ABORTED = -16;
-const int AP4_ERROR_INVALID_RTP_CONSTRUCTOR_TYPE = -17;
-const int AP4_ERROR_NOT_SUPPORTED_YET = -18;
-const int AP4_ERROR_INVALID_TRACK_TYPE = -19;
-const int AP4_ERROR_INVALID_RTP_PACKET_EXTRA_DATA = -20;
-
-/*----------------------------------------------------------------------
-| macros
-+---------------------------------------------------------------------*/
-#define AP4_FAILED(result) ((result) != AP4_SUCCESS)
-#define AP4_SUCCEEDED(result) ((result) == AP4_SUCCESS)
-
-#endif // _AP4_RESULTS_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4RtpAtom.cpp b/src/thirdparty/Bento4/Core/Ap4RtpAtom.cpp
deleted file mode 100644
index 1cf72cfa2..000000000
--- a/src/thirdparty/Bento4/Core/Ap4RtpAtom.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/*****************************************************************
-|
-| AP4 - sdp Atoms
-|
-| Copyright 2002-2005 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4RtpAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4Utils.h"
-
-
-/*----------------------------------------------------------------------
-| AP4_RtpAtom::AP4_RtpAtom
-+---------------------------------------------------------------------*/
-AP4_RtpAtom::AP4_RtpAtom(AP4_Size size, AP4_ByteStream& stream) :
- AP4_Atom(AP4_ATOM_TYPE_RTP, size, false, stream)
-{
- // desc format
- stream.ReadUI32(m_DescriptionFormat);
-
- // sdptext
- int str_size = size-(AP4_ATOM_HEADER_SIZE+4);
- if (str_size) {
- char* str = new char[str_size+1];
- stream.Read(str, str_size);
- str[str_size] = '\0'; // force null-termination
- m_SdpText = str;
- delete[] str;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_RtpAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_RtpAtom::WriteFields(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- // description format
- result = stream.WriteUI32(m_DescriptionFormat);
- if (AP4_FAILED(result)) return result;
-
- // sdp text
- result = stream.Write(m_SdpText.c_str(), m_SdpText.length());
- if (AP4_FAILED(result)) return result;
-
- // pad with zeros if necessary
- AP4_Size padding = m_Size-(AP4_ATOM_HEADER_SIZE+4+m_SdpText.length());
- while (padding--) stream.WriteUI08(0);
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_RtpAtom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_RtpAtom::InspectFields(AP4_AtomInspector& inspector)
-{
- char format_string[5];
- AP4_FormatFourChars(format_string, m_DescriptionFormat);
- inspector.AddField("description_format", format_string);
- inspector.AddField("sdp_text", m_SdpText.c_str());
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4RtpAtom.h b/src/thirdparty/Bento4/Core/Ap4RtpAtom.h
deleted file mode 100644
index 1ae414f60..000000000
--- a/src/thirdparty/Bento4/Core/Ap4RtpAtom.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*****************************************************************
-|
-| AP4 - rtp Atoms
-|
-| Copyright 2002-2005 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-#ifndef _AP4_RTP_ATOM_H_
-#define _AP4_RTP_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4List.h"
-#include "Ap4Atom.h"
-#include "Ap4DataBuffer.h"
-
-/*----------------------------------------------------------------------
-| AP4_RtpAtom
-+---------------------------------------------------------------------*/
-class AP4_RtpAtom : public AP4_Atom
-{
-public:
- // methods
- AP4_RtpAtom(AP4_Size size, AP4_ByteStream& stream);
- const AP4_String& GetSdpText() { return m_SdpText; }
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
-private:
- // members
- AP4_UI32 m_DescriptionFormat;
- AP4_String m_SdpText;
-};
-
-#endif // _AP4_RTP_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4RtpHint.cpp b/src/thirdparty/Bento4/Core/Ap4RtpHint.cpp
deleted file mode 100644
index bdfbe4f71..000000000
--- a/src/thirdparty/Bento4/Core/Ap4RtpHint.cpp
+++ /dev/null
@@ -1,639 +0,0 @@
-/*****************************************************************
-|
-| AP4 - RTP Hint Objects
-|
-| Copyright 2002-2005 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4RtpHint.h"
-#include "Ap4ByteStream.h"
-#include "Ap4Atom.h"
-
-/*----------------------------------------------------------------------
-| AP4_RtpSampleData::~AP4_RtpSampleData
-+---------------------------------------------------------------------*/
-AP4_RtpSampleData::~AP4_RtpSampleData()
-{
- AP4_List<AP4_RtpPacket>::Item* it = m_Packets.FirstItem();
- while (it != NULL) {
- it->GetData()->Release();
- it = it->GetNext();
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_RtpSampleData::AP4_RtpSampleData
-+---------------------------------------------------------------------*/
-AP4_RtpSampleData::AP4_RtpSampleData(AP4_ByteStream& stream, AP4_Size size)
-{
- // save the start position
- AP4_Offset start, extra_data_start;
- stream.Tell(start);
-
- AP4_UI16 packet_count;
- stream.ReadUI16(packet_count);
-
- AP4_UI16 reserved;
- stream.ReadUI16(reserved); // later, check that reserved is 0
-
- // packets
- for (AP4_UI16 i=0; i<packet_count; i++) {
- AP4_RtpPacket* packet = new AP4_RtpPacket(stream);
- m_Packets.Add(packet);
- }
-
- // extra data
- stream.Tell(extra_data_start);
- AP4_Size extra_data_size = size - (extra_data_start-start);
- if (extra_data_size != 0) {
- m_ExtraData.SetDataSize(extra_data_size);
- stream.Read(m_ExtraData.UseData(), extra_data_size);
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_RtpSampleData::GetSize
-+---------------------------------------------------------------------*/
-AP4_Size
-AP4_RtpSampleData::GetSize()
-{
- // packet count and reserved
- AP4_Size result = 4;
-
- // packets
- AP4_List<AP4_RtpPacket>::Item* it = m_Packets.FirstItem();
- while (it != NULL) {
- result = it->GetData()->GetSize();
- it = it->GetNext();
- }
-
- // extra data
- result += m_ExtraData.GetDataSize();
-
- return result;
-}
-
-/*----------------------------------------------------------------------
-| AP4_RtpSampleData::ToByteStream
-+---------------------------------------------------------------------*/
-AP4_ByteStream*
-AP4_RtpSampleData::ToByteStream()
-{
- // refresh the size
- AP4_Size size = GetSize();
-
- // create a memory stream
- AP4_MemoryByteStream* stream = new AP4_MemoryByteStream(size);
-
- // write in it
- AP4_Result result = stream->WriteUI16(static_cast<AP4_UI16>(m_Packets.ItemCount()));
- if (AP4_FAILED(result)) goto bail;
-
- result = stream->WriteUI16(0); // reserved
- if (AP4_FAILED(result)) goto bail;
-
- {
- AP4_List<AP4_RtpPacket>::Item* it = m_Packets.FirstItem();
- while (it != NULL) {
- result = it->GetData()->Write(*stream);
- if (AP4_FAILED(result)) goto bail;
- it = it->GetNext();
- }
- }
-
- result = stream->Write(m_ExtraData.GetData(), m_ExtraData.GetDataSize());
- if (AP4_FAILED(result)) goto bail;
-
- // return
- return stream;
-
-bail:
- stream->Release();
- return NULL;
-}
-
-
-/*----------------------------------------------------------------------
-| AP4_RtpSampleData::AddPacket
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_RtpSampleData::AddPacket(AP4_RtpPacket* packet)
-{
- packet->AddReference();
- return m_Packets.Add(packet);
-}
-
-/*----------------------------------------------------------------------
-| AP4_RtpPacket::AP4_RtpPacket
-+---------------------------------------------------------------------*/
-AP4_RtpPacket::AP4_RtpPacket(AP4_Integer relative_time,
- bool p_bit,
- bool x_bit,
- bool m_bit,
- AP4_UI08 payload_type,
- AP4_UI16 sequence_seed,
- AP4_Integer time_stamp_offset /* = 0 */,
- bool bframe_flag /* = false */,
- bool repeat_flag /* = false */) :
- m_ReferenceCount(1),
- m_RelativeTime(relative_time),
- m_PBit(p_bit),
- m_XBit(x_bit),
- m_MBit(m_bit),
- m_PayloadType(payload_type),
- m_SequenceSeed(sequence_seed),
- m_TimeStampOffset(time_stamp_offset),
- m_BFrameFlag(bframe_flag),
- m_RepeatFlag(repeat_flag)
-{}
-
-/*----------------------------------------------------------------------
-| AP4_RtpPacket::AP4_RtpPacket
-+---------------------------------------------------------------------*/
-AP4_RtpPacket::AP4_RtpPacket(AP4_ByteStream& stream) :
- m_ReferenceCount(1),
- m_TimeStampOffset(0)
-{
- AP4_UI08 octet;
-
- // relative time
- AP4_UI32 relative_time;
- stream.ReadUI32(relative_time);
- m_RelativeTime = relative_time;
-
- // pbit and xbit
- stream.ReadUI08(octet);
- m_PBit = (octet & 0x20) != 0;
- m_XBit = (octet & 0x10) != 0;
-
- // mbit and payload type
- stream.ReadUI08(octet);
- m_MBit = (octet & 0x80) != 0;
- m_PayloadType = octet & 0x7F;
-
- // sequence seed
- stream.ReadUI16(m_SequenceSeed);
-
- // extra, bframe and repeat flags
- stream.ReadUI08(octet);
- stream.ReadUI08(octet); // repeat on purpose
- bool extra_flag = (octet & 0x04) != 0;
-
- // bframe and repeat flags
- m_BFrameFlag = (octet & 0x02) != 0;
- m_RepeatFlag = (octet & 0x01) != 0;
-
- // constructor count
- AP4_UI16 constructor_count;
- stream.ReadUI16(constructor_count);
-
- // parse the packet extra data
- if (extra_flag) {
- // read the length
- AP4_UI32 extra_length;
- stream.ReadUI32(extra_length);
-
- // check it
- if (extra_length < 4)
- throw AP4_Exception(AP4_ERROR_INVALID_RTP_PACKET_EXTRA_DATA);
-
- // now read the entries
- extra_length -= 4;
- while (extra_length > 0) {
- AP4_UI32 entry_length;
- AP4_UI32 entry_tag;
- stream.ReadUI32(entry_length);
- stream.ReadUI32(entry_tag);
-
- // check the entry
- if (entry_length < 8) {
- throw AP4_Exception(AP4_ERROR_INVALID_RTP_PACKET_EXTRA_DATA);
- }
-
- // parse the single entry that's currently defined in the spec
- if (entry_tag == AP4_ATOM_TYPE('r','t','p','o') && entry_length == 12) {
- AP4_UI32 time_stamp_offset;
- stream.ReadUI32(time_stamp_offset);
- m_TimeStampOffset = time_stamp_offset;
- } else {
- // ignore it
- AP4_Offset cur_pos;
- stream.Tell(cur_pos);
- stream.Seek(cur_pos + entry_length - 8); // 8 = length + tag
- }
-
- extra_length -= entry_length;
- }
- }
-
- // constructors
- for (AP4_UI16 i=0; i<constructor_count; i++) {
- AP4_RtpConstructor* constructor = NULL;
- AP4_RtpConstructorFactory::CreateConstructorFromStream(stream, constructor);
- m_Constructors.Add(constructor);
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_RtpPacket::AP4_RtpPacket
-+---------------------------------------------------------------------*/
-AP4_RtpPacket::~AP4_RtpPacket()
-{
- AP4_List<AP4_RtpConstructor>::Item* it = m_Constructors.FirstItem();
- while (it != NULL) {
- it->GetData()->Release();
- it = it->GetNext();
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_RtpPacket::AddReference
-+---------------------------------------------------------------------*/
-void
-AP4_RtpPacket::AddReference()
-{
- m_ReferenceCount++;
-}
-
-/*----------------------------------------------------------------------
-| AP4_RtpPacket::Release
-+---------------------------------------------------------------------*/
-void
-AP4_RtpPacket::Release()
-{
- if (--m_ReferenceCount == 0) {
- delete this;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_RtpPacket::GetSize
-+---------------------------------------------------------------------*/
-AP4_Size
-AP4_RtpPacket::GetSize()
-{
- AP4_Size result = 12 + (m_TimeStampOffset != 0)?16:0;
- result += m_Constructors.ItemCount() * AP4_RTP_CONSTRUCTOR_SIZE;
- return result;
-}
-
-/*----------------------------------------------------------------------
-| AP4_RtpPacket::Write
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_RtpPacket::Write(AP4_ByteStream& stream)
-{
- // check the payload type
- if (m_PayloadType > 128) return AP4_FAILURE;
-
- // now write
- AP4_Result result = stream.WriteUI32(m_RelativeTime);
- if (AP4_FAILED(result)) return result;
-
- result = stream.WriteUI08(0x80 | m_PBit << 5 | m_XBit << 4);
- if (AP4_FAILED(result)) return result;
-
- result = stream.WriteUI08(m_MBit << 7 | m_PayloadType);
- if (AP4_FAILED(result)) return result;
-
- result = stream.WriteUI16(m_SequenceSeed);
- if (AP4_FAILED(result)) return result;
-
- result = stream.WriteUI08(0);
- if (AP4_FAILED(result)) return result;
-
- // deal with extra flag
- bool extra_flag = m_TimeStampOffset != 0;
- result = stream.WriteUI08(0x00 | extra_flag << 2
- | m_BFrameFlag << 1
- | m_RepeatFlag << 0);
- if (AP4_FAILED(result)) return result;
-
-
- // constructor count
- result = stream.WriteUI16(static_cast<AP4_UI16>(m_Constructors.ItemCount()));
-
- // write extra data
- if (extra_flag) {
- // extra_length
- result = stream.WriteUI32(16); // 4 (extra_length) + 12 (rtpo atom)
- if (AP4_FAILED(result)) return result;
-
- // rtpo atom
- result = stream.WriteUI32(12); // size
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI32(AP4_ATOM_TYPE('r','t','p','o'));
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI32(m_TimeStampOffset);
- if (AP4_FAILED(result)) return result;
- }
-
- // constructors
- AP4_List<AP4_RtpConstructor>::Item* it = m_Constructors.FirstItem();
- while (it != NULL) {
- result = it->GetData()->Write(stream);
- if (AP4_FAILED(result)) return result;
- it = it->GetNext();
- }
- return result;
-}
-
-/*----------------------------------------------------------------------
-| AP4_RtpPacket::AddConstructor
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_RtpPacket::AddConstructor(AP4_RtpConstructor* constructor)
-{
- constructor->AddReference();
- return m_Constructors.Add(constructor);
-}
-
-/*----------------------------------------------------------------------
-| AP4_RtpConstructor::GetConstructedDataSize
-+---------------------------------------------------------------------*/
-AP4_Size
-AP4_RtpPacket::GetConstructedDataSize()
-{
- // header + ssrc
- AP4_Size size = 12;
-
- // constructed data from constructors
- AP4_List<AP4_RtpConstructor>::Item* constructors_it
- = m_Constructors.FirstItem();
- while (constructors_it != NULL) {
- size += constructors_it->GetData()->GetConstructedDataSize();
- constructors_it = constructors_it->GetNext();
- }
-
- return size;
-}
-
-
-/*----------------------------------------------------------------------
-| AP4_RtpConstructor::AddReference
-+---------------------------------------------------------------------*/
-void
-AP4_RtpConstructor::AddReference()
-{
- m_ReferenceCount++;
-}
-
-/*----------------------------------------------------------------------
-| AP4_RtpConstructor::Release
-+---------------------------------------------------------------------*/
-void
-AP4_RtpConstructor::Release()
-{
- if (--m_ReferenceCount == 0) {
- delete this;
- }
-}
-/*----------------------------------------------------------------------
-| AP4_RtpConstructor::Write
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_RtpConstructor::Write(AP4_ByteStream& stream)
-{
- AP4_Result result = stream.WriteUI08(m_Type);
- if (AP4_FAILED(result)) return result;
-
- return DoWrite(stream);
-}
-
-/*----------------------------------------------------------------------
-| AP4_NoopRtpConstructor::AP4_NoopRtpConstructor
-+---------------------------------------------------------------------*/
-AP4_NoopRtpConstructor::AP4_NoopRtpConstructor(AP4_ByteStream& stream) :
- AP4_RtpConstructor(AP4_RTP_CONSTRUCTOR_TYPE_NOOP)
-{
- AP4_Offset cur_offset;
- stream.Tell(cur_offset);
- stream.Seek(cur_offset+15);
-}
-
-/*----------------------------------------------------------------------
-| AP4_NoopRtpConstructor::DoWrite
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_NoopRtpConstructor::DoWrite(AP4_ByteStream& stream)
-{
- AP4_UI08 pad[15];
-
- return stream.Write(pad, sizeof(pad));
-}
-
-/*----------------------------------------------------------------------
-| AP4_ImmediateRtpConstructor::AP4_ImmediateRtpConstructor
-+---------------------------------------------------------------------*/
-AP4_ImmediateRtpConstructor::AP4_ImmediateRtpConstructor(const AP4_DataBuffer& data) :
- AP4_RtpConstructor(AP4_RTP_CONSTRUCTOR_TYPE_IMMEDIATE),
- m_Data(data)
-{}
-
-/*----------------------------------------------------------------------
-| AP4_ImmediateRtpConstructor::AP4_ImmediateRtpConstructor
-+---------------------------------------------------------------------*/
-AP4_ImmediateRtpConstructor::AP4_ImmediateRtpConstructor(AP4_ByteStream& stream) :
- AP4_RtpConstructor(AP4_RTP_CONSTRUCTOR_TYPE_IMMEDIATE)
-{
- AP4_Offset cur_offset;
- stream.Tell(cur_offset);
-
- // data
- AP4_UI08 data_size;
- stream.ReadUI08(data_size);
- m_Data.SetDataSize(data_size);
- stream.Read(m_Data.UseData(), data_size);
-
- // reposition the stream
- stream.Seek(cur_offset+15);
-}
-
-
-/*----------------------------------------------------------------------
-| AP4_ImmediateRtpConstructor::DoWrite
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_ImmediateRtpConstructor::DoWrite(AP4_ByteStream& stream)
-{
- // first check that the data is not too large
- if (m_Data.GetDataSize() > 14) return AP4_FAILURE;
-
- // now write
- AP4_Result result = stream.WriteUI08(static_cast<AP4_UI08>(m_Data.GetDataSize()));
- if (AP4_FAILED(result)) return result;
-
- result = stream.Write(m_Data.GetData(), m_Data.GetDataSize());
- if (AP4_FAILED(result)) return result;
-
- // pad
- AP4_Byte pad[14];
- return stream.Write(pad, sizeof(pad)-m_Data.GetDataSize());
-}
-/*----------------------------------------------------------------------
-| AP4_SampleRtpConstructor::AP4_SampleRtpConstructor
-+---------------------------------------------------------------------*/
-AP4_SampleRtpConstructor::AP4_SampleRtpConstructor(AP4_UI08 track_ref_index,
- AP4_UI16 length,
- AP4_UI32 sample_num,
- AP4_UI32 sample_offset) :
- AP4_RtpConstructor(AP4_RTP_CONSTRUCTOR_TYPE_SAMPLE),
- m_TrackRefIndex(track_ref_index),
- m_Length(length),
- m_SampleNum(sample_num),
- m_SampleOffset(sample_offset)
-{}
-
-/*----------------------------------------------------------------------
-| AP4_SampleRtpConstructor::AP4_SampleRtpConstructor
-+---------------------------------------------------------------------*/
-AP4_SampleRtpConstructor::AP4_SampleRtpConstructor(AP4_ByteStream& stream) :
- AP4_RtpConstructor(AP4_RTP_CONSTRUCTOR_TYPE_SAMPLE)
-{
- // offset
- AP4_Offset cur_offset;
- stream.Tell(cur_offset);
-
- // data
- stream.ReadUI08(m_TrackRefIndex);
- stream.ReadUI16(m_Length);
- stream.ReadUI32(m_SampleNum);
- stream.ReadUI32(m_SampleOffset);
-
- // reposition the stream
- stream.Seek(cur_offset+15);
-}
-/*----------------------------------------------------------------------
-| AP4_SampleRtpConstructor::DoWrite
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SampleRtpConstructor::DoWrite(AP4_ByteStream& stream)
-{
- AP4_Result result = stream.WriteUI08(m_TrackRefIndex);
- if (AP4_FAILED(result)) return result;
-
- result = stream.WriteUI16(m_Length);
- if (AP4_FAILED(result)) return result;
-
- result = stream.WriteUI32(m_SampleNum);
- if (AP4_FAILED(result)) return result;
-
- result = stream.WriteUI32(m_SampleOffset);
- if (AP4_FAILED(result)) return result;
-
- result = stream.WriteUI16(1); // bytes per block
- if (AP4_FAILED(result)) return result;
-
- return stream.WriteUI16(1); // samples per block
-}
-
-/*----------------------------------------------------------------------
-| AP4_SampleDescRtpConstructor::AP4_SampleDescRtpConstructor
-+---------------------------------------------------------------------*/
-AP4_SampleDescRtpConstructor::AP4_SampleDescRtpConstructor(AP4_UI08 track_ref_index,
- AP4_UI16 length,
- AP4_UI32 sample_desc_index,
- AP4_UI32 sample_desc_offset) :
- AP4_RtpConstructor(AP4_RTP_CONSTRUCTOR_TYPE_SAMPLE_DESC),
- m_TrackRefIndex(track_ref_index),
- m_Length(length),
- m_SampleDescIndex(sample_desc_index),
- m_SampleDescOffset(sample_desc_offset)
-{}
-
-/*----------------------------------------------------------------------
-| AP4_SampleDescRtpConstructor::AP4_SampleDescRtpConstructor
-+---------------------------------------------------------------------*/
-AP4_SampleDescRtpConstructor::AP4_SampleDescRtpConstructor(AP4_ByteStream& stream) :
- AP4_RtpConstructor(AP4_RTP_CONSTRUCTOR_TYPE_SAMPLE_DESC)
-{
- // offset
- AP4_Offset cur_offset;
- stream.Tell(cur_offset);
-
- // data
- stream.ReadUI08(m_TrackRefIndex);
- stream.ReadUI16(m_Length);
- stream.ReadUI32(m_SampleDescIndex);
- stream.ReadUI32(m_SampleDescOffset);
-
- // reposition the stream
- stream.Seek(cur_offset+15);
-}
-
-/*----------------------------------------------------------------------
-| AP4_SampleDescRtpConstructor::DoWrite
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SampleDescRtpConstructor::DoWrite(AP4_ByteStream& stream)
-{
- AP4_Result result = stream.WriteUI08(m_TrackRefIndex);
- if (AP4_FAILED(result)) return result;
-
- result = stream.WriteUI16(m_Length);
- if (AP4_FAILED(result)) return result;
-
- result = stream.WriteUI32(m_SampleDescIndex);
- if (AP4_FAILED(result)) return result;
-
- result = stream.WriteUI32(m_SampleDescOffset);
- if (AP4_FAILED(result)) return result;
-
- return stream.WriteUI32(0); // reserved
-}
-
-/*----------------------------------------------------------------------
-| AP4_RtpConstructorFactory::CreateConstructorFromStream
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_RtpConstructorFactory::CreateConstructorFromStream(AP4_ByteStream& stream,
- AP4_RtpConstructor*& constructor)
-{
- // read the first byte (type)
- AP4_RtpConstructor::Type type;
- AP4_Result result = stream.ReadUI08(type);
- if (AP4_FAILED(result)) return result;
-
- switch(type) {
- case AP4_RTP_CONSTRUCTOR_TYPE_NOOP:
- constructor = new AP4_NoopRtpConstructor(stream);
- break;
- case AP4_RTP_CONSTRUCTOR_TYPE_IMMEDIATE:
- constructor = new AP4_ImmediateRtpConstructor(stream);
- break;
- case AP4_RTP_CONSTRUCTOR_TYPE_SAMPLE:
- constructor = new AP4_SampleRtpConstructor(stream);
- break;
- case AP4_RTP_CONSTRUCTOR_TYPE_SAMPLE_DESC:
- constructor = new AP4_SampleDescRtpConstructor(stream);
- break;
- default:
- return AP4_ERROR_INVALID_RTP_CONSTRUCTOR_TYPE;
- }
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4RtpHint.h b/src/thirdparty/Bento4/Core/Ap4RtpHint.h
deleted file mode 100644
index b5cfd67f1..000000000
--- a/src/thirdparty/Bento4/Core/Ap4RtpHint.h
+++ /dev/null
@@ -1,297 +0,0 @@
-/*****************************************************************
-|
-| AP4 - RTP Hint Objects
-|
-| Copyright 2002-2005 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_RTP_HINT_H_
-#define _AP4_RTP_HINT_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4List.h"
-#include "Ap4DataBuffer.h"
-#include "Ap4Interfaces.h"
-
-/*----------------------------------------------------------------------
-| forward declarations
-+---------------------------------------------------------------------*/
-class AP4_ByteStream;
-class AP4_RtpConstructor;
-class AP4_RtpPacket;
-
-/*----------------------------------------------------------------------
-| AP4_RtpSampleData
-+---------------------------------------------------------------------*/
-class AP4_RtpSampleData
-{
-public:
- // constructors and destructor
- AP4_RtpSampleData(AP4_ByteStream& stream, AP4_Size size);
- AP4_RtpSampleData() {}
- virtual ~AP4_RtpSampleData();
-
- // methods
- virtual AP4_Result AddPacket(AP4_RtpPacket* packet);
- virtual AP4_Size GetSize();
- virtual AP4_ByteStream* ToByteStream();
-
- // accessors
- AP4_List<AP4_RtpPacket>& GetPackets() {
- return m_Packets;
- }
- const AP4_DataBuffer& GetExtraData() const {
- return m_ExtraData;
- }
-
-protected:
- // members
- AP4_List<AP4_RtpPacket> m_Packets;
- AP4_DataBuffer m_ExtraData;
-};
-
-/*----------------------------------------------------------------------
-| AP4_RtpPacket
-+---------------------------------------------------------------------*/
-class AP4_RtpPacket : public AP4_Referenceable
-{
-public:
- // constructor and destructor
- AP4_RtpPacket(AP4_ByteStream& stream);
- AP4_RtpPacket(AP4_Integer relative_time,
- bool p_bit,
- bool x_bit,
- bool m_bit,
- AP4_UI08 payload_type,
- AP4_UI16 sequence_seed,
- AP4_Integer time_stamp_offset = 0,
- bool bframe_flag = false,
- bool repeat_flag = false);
- ~AP4_RtpPacket();
-
- // methods
- AP4_Result Write(AP4_ByteStream& stream);
- AP4_Result AddConstructor(AP4_RtpConstructor* constructor);
- AP4_Size GetSize();
- AP4_Size GetConstructedDataSize();
-
- // Referenceable methods
- void AddReference();
- void Release();
-
- // Accessors
- AP4_Integer GetRelativeTime() const { return m_RelativeTime; }
- bool GetPBit() const { return m_PBit; }
- bool GetXBit() const { return m_XBit; }
- bool GetMBit() const { return m_MBit; }
- AP4_UI08 GetPayloadType() const { return m_PayloadType; }
- AP4_UI16 GetSequenceSeed() const { return m_SequenceSeed; }
- AP4_Integer GetTimeStampOffset() const { return m_TimeStampOffset; }
- bool GetBFrameFlag() const { return m_BFrameFlag; }
- bool GetRepeatFlag() const { return m_RepeatFlag; }
- AP4_List<AP4_RtpConstructor>& GetConstructors() {
- return m_Constructors;
- }
-
-private:
- // members
- AP4_Cardinal m_ReferenceCount;
- AP4_Integer m_RelativeTime;
- bool m_PBit;
- bool m_XBit;
- bool m_MBit;
- AP4_UI08 m_PayloadType;
- AP4_UI16 m_SequenceSeed;
- AP4_Integer m_TimeStampOffset;
- bool m_BFrameFlag;
- bool m_RepeatFlag;
- AP4_List<AP4_RtpConstructor> m_Constructors;
-};
-
-/*----------------------------------------------------------------------
-| AP4_RtpContructor
-+---------------------------------------------------------------------*/
-class AP4_RtpConstructor : public AP4_Referenceable
-{
-public:
- // types
- typedef AP4_UI08 Type;
-
- // constructor & destructor
- AP4_RtpConstructor(Type type) : m_ReferenceCount(1), m_Type(type) {}
-
- // methods
- Type GetType() const { return m_Type; }
- AP4_Result Write(AP4_ByteStream& stream);
- virtual AP4_Size GetConstructedDataSize() = 0;
-
- // Referenceable methods
- void AddReference();
- void Release();
-
-protected:
- // methods
- virtual ~AP4_RtpConstructor() {}
- virtual AP4_Result DoWrite(AP4_ByteStream& stream) = 0;
-
- // members
- AP4_Cardinal m_ReferenceCount;
- Type m_Type;
-};
-
-/*----------------------------------------------------------------------
-| constructor size
-+---------------------------------------------------------------------*/
-const AP4_Size AP4_RTP_CONSTRUCTOR_SIZE = 16;
-
-/*----------------------------------------------------------------------
-| constructor types
-+---------------------------------------------------------------------*/
-const AP4_RtpConstructor::Type AP4_RTP_CONSTRUCTOR_TYPE_NOOP = 0;
-const AP4_RtpConstructor::Type AP4_RTP_CONSTRUCTOR_TYPE_IMMEDIATE = 1;
-const AP4_RtpConstructor::Type AP4_RTP_CONSTRUCTOR_TYPE_SAMPLE = 2;
-const AP4_RtpConstructor::Type AP4_RTP_CONSTRUCTOR_TYPE_SAMPLE_DESC = 3;
-
-/*----------------------------------------------------------------------
-| AP4_NoopRtpConstructor
-+---------------------------------------------------------------------*/
-class AP4_NoopRtpConstructor : public AP4_RtpConstructor
-{
-public:
- // constructor
- AP4_NoopRtpConstructor(AP4_ByteStream& stream);
- AP4_NoopRtpConstructor() : AP4_RtpConstructor(AP4_RTP_CONSTRUCTOR_TYPE_NOOP) {}
-
- // methods
- virtual AP4_Size GetConstructedDataSize() { return 0; }
-
-protected:
- // methods
- virtual AP4_Result DoWrite(AP4_ByteStream& stream);
-};
-
-/*----------------------------------------------------------------------
-| AP4_ImmediateRtpConstructor
-+---------------------------------------------------------------------*/
-class AP4_ImmediateRtpConstructor : public AP4_RtpConstructor
-{
-public:
- // constructor
- AP4_ImmediateRtpConstructor(AP4_ByteStream& stream);
- AP4_ImmediateRtpConstructor(const AP4_DataBuffer& data);
-
- // accessors
- const AP4_DataBuffer& GetData() const { return m_Data; }
-
- // methods
- virtual AP4_Size GetConstructedDataSize() { return m_Data.GetDataSize(); }
-
-protected:
- // methods
- virtual AP4_Result DoWrite(AP4_ByteStream& stream);
-
- // members
- AP4_DataBuffer m_Data;
-};
-
-/*----------------------------------------------------------------------
-| AP4_SampleRtpConstructor
-+---------------------------------------------------------------------*/
-class AP4_SampleRtpConstructor : public AP4_RtpConstructor
-{
-public:
- // constructor
- AP4_SampleRtpConstructor(AP4_ByteStream& stream);
- AP4_SampleRtpConstructor(AP4_UI08 track_ref_index,
- AP4_UI16 length,
- AP4_UI32 sample_num,
- AP4_UI32 sample_offset);
-
- // accessors
- AP4_UI08 GetTrackRefIndex() const { return m_TrackRefIndex; }
- AP4_UI16 GetLength() const { return m_Length; }
- AP4_UI32 GetSampleNum() const { return m_SampleNum; }
- AP4_UI32 GetSampleOffset() const { return m_SampleOffset; }
-
- // methods
- virtual AP4_Size GetConstructedDataSize() { return m_Length; }
-
-protected:
- // methods
- virtual AP4_Result DoWrite(AP4_ByteStream& stream);
-
- // members
- AP4_UI08 m_TrackRefIndex;
- AP4_UI16 m_Length;
- AP4_UI32 m_SampleNum;
- AP4_UI32 m_SampleOffset;
-};
-
-/*----------------------------------------------------------------------
-| AP4_SampleDescRtpConstructor
-+---------------------------------------------------------------------*/
-class AP4_SampleDescRtpConstructor : public AP4_RtpConstructor
-{
-public:
- // constructor
- AP4_SampleDescRtpConstructor(AP4_ByteStream& stream);
- AP4_SampleDescRtpConstructor(AP4_UI08 track_ref_index,
- AP4_UI16 length,
- AP4_UI32 sample_desc_index,
- AP4_UI32 sample_desc_offset);
-
- // accessors
- AP4_UI08 GetTrackRefIndex() const { return m_TrackRefIndex; }
- AP4_UI16 GetLength() const { return m_Length; }
- AP4_UI32 GetSampleDescIndex() const { return m_SampleDescIndex; }
- AP4_UI32 GetSampleDescOffset() const { return m_SampleDescOffset; }
-
- // methods
- virtual AP4_Size GetConstructedDataSize() { return m_Length; }
-
-protected:
- // methods
- virtual AP4_Result DoWrite(AP4_ByteStream& stream);
-
- // members
- AP4_UI08 m_TrackRefIndex;
- AP4_UI16 m_Length;
- AP4_UI32 m_SampleDescIndex;
- AP4_UI32 m_SampleDescOffset;
-};
-
-/*----------------------------------------------------------------------
-| AP4_RtpConstructorFactory
-+---------------------------------------------------------------------*/
-class AP4_RtpConstructorFactory
-{
-public:
- static AP4_Result CreateConstructorFromStream(AP4_ByteStream& stream,
- AP4_RtpConstructor*& constructor);
-};
-
-#endif // _AP4_RTP_HINT_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4SLConfigDescriptor.cpp b/src/thirdparty/Bento4/Core/Ap4SLConfigDescriptor.cpp
deleted file mode 100644
index e15821f8e..000000000
--- a/src/thirdparty/Bento4/Core/Ap4SLConfigDescriptor.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*****************************************************************
-|
-| AP4 - SLConfig Descriptor
-|
-| Copyright 2002 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4SLConfigDescriptor.h"
-
-/*----------------------------------------------------------------------
-| AP4_SLConfigDescriptor::AP4_SLConfigDescriptor
-+---------------------------------------------------------------------*/
-AP4_SLConfigDescriptor::AP4_SLConfigDescriptor(AP4_Size header_size = 2) :
- AP4_Descriptor(AP4_DESCRIPTOR_TAG_SL_CONFIG, header_size, 1),
- m_Predefined(2)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_SLConfigDescriptor::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SLConfigDescriptor::WriteFields(AP4_ByteStream& stream)
-{
- // write the payload
- stream.WriteUI08(m_Predefined);
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4SLConfigDescriptor.h b/src/thirdparty/Bento4/Core/Ap4SLConfigDescriptor.h
deleted file mode 100644
index 19026b081..000000000
--- a/src/thirdparty/Bento4/Core/Ap4SLConfigDescriptor.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*****************************************************************
-|
-| AP4 - SLConfig Descriptor
-|
-| Copyright 2002 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-#ifndef _AP4_SLCONFIG_DESCRIPTOR_H_
-#define _AP4_SLCONFIG_DESCRIPTOR_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4List.h"
-#include "Ap4DataBuffer.h"
-#include "Ap4Descriptor.h"
-
-/*----------------------------------------------------------------------
-| constants
-+---------------------------------------------------------------------*/
-const AP4_Descriptor::Tag AP4_DESCRIPTOR_TAG_SL_CONFIG = 0x06;
-
-/*----------------------------------------------------------------------
-| AP4_SLConfigDescriptor
-+---------------------------------------------------------------------*/
-class AP4_SLConfigDescriptor : public AP4_Descriptor
-{
-public:
- // methods
- AP4_SLConfigDescriptor(AP4_Size header_size);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
-private:
- // members
- AP4_UI08 m_Predefined; // = 2 (fixed for MP4 files)
-};
-
-
-#endif // _AP4_SLCONFIG_DESCRIPTOR_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4Sample.cpp b/src/thirdparty/Bento4/Core/Ap4Sample.cpp
deleted file mode 100644
index 9e801dfd2..000000000
--- a/src/thirdparty/Bento4/Core/Ap4Sample.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Sample Objects
-|
-| Copyright 2002 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4Sample.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_Sample::AP4_Sample
-+---------------------------------------------------------------------*/
-AP4_Sample::AP4_Sample() :
- m_DataStream(NULL),
- m_Offset(0),
- m_Size(0),
- m_DescriptionIndex(0),
- m_Dts(0),
- m_Cts(0)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_Sample::AP4_Sample
-+---------------------------------------------------------------------*/
-AP4_Sample::AP4_Sample(AP4_ByteStream& data_stream,
- AP4_Offset offset,
- AP4_Size size,
- AP4_Ordinal description_index,
- AP4_TimeStamp dts,
- AP4_TimeStamp cts_offset /* = 0 */ ) :
- m_Offset(offset),
- m_Size(size),
- m_DescriptionIndex(description_index),
- m_Dts(dts),
- m_Cts(dts + cts_offset)
-{
- m_DataStream = &data_stream;
- AP4_ADD_REFERENCE(m_DataStream);
-}
-
-/*----------------------------------------------------------------------
-| AP4_Sample::AP4_Sample
-+---------------------------------------------------------------------*/
-AP4_Sample::AP4_Sample(const AP4_Sample& other) :
- m_DataStream(other.m_DataStream),
- m_Offset(other.m_Offset),
- m_Size(other.m_Size),
- m_DescriptionIndex(other.m_DescriptionIndex),
- m_Dts(other.m_Dts),
- m_Cts(other.m_Cts)
-{
- AP4_ADD_REFERENCE(m_DataStream);
-}
-
-/*----------------------------------------------------------------------
-| AP4_Sample::~AP4_Sample
-+---------------------------------------------------------------------*/
-AP4_Sample::~AP4_Sample()
-{
- AP4_RELEASE(m_DataStream);
-}
-
-/*----------------------------------------------------------------------
-| AP4_Sample::operator=
-+---------------------------------------------------------------------*/
-AP4_Sample&
-AP4_Sample::operator=(const AP4_Sample& other)
-{
- AP4_RELEASE(m_DataStream);
- m_DataStream = other.m_DataStream;
- AP4_ADD_REFERENCE(m_DataStream);
-
- m_Offset = other.m_Offset;
- m_Size = other.m_Size;
- m_DescriptionIndex = other.m_DescriptionIndex;
- m_Dts = other.m_Dts;
- m_Cts = other.m_Cts;
-
- return *this;
-}
-/*----------------------------------------------------------------------
-| AP4_Sample::ReadData
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Sample::ReadData(AP4_DataBuffer& data)
-{
- return ReadData(data, m_Size);
-}
-
-
-/*----------------------------------------------------------------------
-| AP4_Sample::ReadData
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Sample::ReadData(AP4_DataBuffer& data, AP4_Size size, AP4_Offset offset)
-{
- // check that we have a stream
- if (m_DataStream == NULL) return AP4_FAILURE;
-
- // shortcut
- if (size == 0) return AP4_SUCCESS;
-
- // check the size
- if (m_Size < size+offset) return AP4_FAILURE;
-
- // set the buffer size
- AP4_Result result = data.SetDataSize(size);
- if (AP4_FAILED(result)) return result;
-
- // get the data from the stream
- m_DataStream->Seek(m_Offset+offset);
- return m_DataStream->Read(data.UseData(), size);
-}
-
-/*----------------------------------------------------------------------
-| AP4_Sample::GetDataStream
-+---------------------------------------------------------------------*/
-AP4_ByteStream*
-AP4_Sample::GetDataStream()
-{
- AP4_ADD_REFERENCE(m_DataStream);
- return m_DataStream;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Sample::SetDataStream
-+---------------------------------------------------------------------*/
-void
-AP4_Sample::SetDataStream(AP4_ByteStream& stream)
-{
- AP4_RELEASE(m_DataStream);
- m_DataStream = &stream;
- AP4_ADD_REFERENCE(m_DataStream);
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4Sample.h b/src/thirdparty/Bento4/Core/Ap4Sample.h
deleted file mode 100644
index b68a68e2d..000000000
--- a/src/thirdparty/Bento4/Core/Ap4Sample.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Sample Objects
-|
-| Copyright 2002-2005 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_SAMPLE_H_
-#define _AP4_SAMPLE_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4DataBuffer.h"
-
-/*----------------------------------------------------------------------
-| AP4_Sample DO NOT DERIVE FROM THIS CLASS
-+---------------------------------------------------------------------*/
-class AP4_Sample
-{
-public:
- // constructors and destructor
- AP4_Sample();
- AP4_Sample(const AP4_Sample& other);
- AP4_Sample(AP4_ByteStream& data_stream,
- AP4_Offset offset,
- AP4_Size size,
- AP4_Ordinal description_index,
- AP4_TimeStamp dts,
- AP4_TimeStamp cts_offset = 0);
- ~AP4_Sample(); // not virtual on purpose: do not derive from it
-
- // operators
- AP4_Sample& operator=(const AP4_Sample& other);
-
- // methods
- AP4_Result ReadData(AP4_DataBuffer& data);
- AP4_Result ReadData(AP4_DataBuffer& data,
- AP4_Size size,
- AP4_Offset offset = 0);
-
- // sample properties accessors
- AP4_ByteStream* GetDataStream();
- void SetDataStream(AP4_ByteStream& stream);
- AP4_Offset GetOffset() const { return m_Offset; }
- void SetOffset(AP4_Offset offset) { m_Offset = offset; }
- AP4_Size GetSize() { return m_Size; }
- void SetSize(AP4_Size size) { m_Size = size; }
- AP4_Ordinal GetDescriptionIndex() const { return m_DescriptionIndex; }
- void SetDescriptionIndex(AP4_Ordinal index) { m_DescriptionIndex = index; }
- AP4_TimeStamp GetDts() const { return m_Dts; }
- void SetDts(AP4_TimeStamp dts) { m_Dts = dts; }
- AP4_TimeStamp GetDuration() const { return m_Duration; }
- void SetDuration(AP4_Duration duration) { m_Duration = duration;}
- AP4_TimeStamp GetCts() const { return m_Cts; }
- void SetCts(AP4_TimeStamp cts) { m_Cts = cts; }
-
-protected:
- AP4_ByteStream* m_DataStream;
- AP4_Offset m_Offset;
- AP4_Size m_Size;
- AP4_Ordinal m_DescriptionIndex;
- AP4_TimeStamp m_Dts;
- AP4_TimeStamp m_Cts;
- AP4_Duration m_Duration;
-};
-
-#endif // _AP4_SAMPLE_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4SampleDescription.cpp b/src/thirdparty/Bento4/Core/Ap4SampleDescription.cpp
deleted file mode 100644
index 17f965fcf..000000000
--- a/src/thirdparty/Bento4/Core/Ap4SampleDescription.cpp
+++ /dev/null
@@ -1,271 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Sample Description Objects
-|
-| Copyright 2002 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4SampleDescription.h"
-#include "Ap4EsDescriptor.h"
-#include "Ap4SampleEntry.h"
-
-/*----------------------------------------------------------------------
-| AP4_UnknownSampleDescription::AP4_UnknownSampleDescription
-+---------------------------------------------------------------------*/
-AP4_UnknownSampleDescription::AP4_UnknownSampleDescription(AP4_SampleEntry* entry) :
- AP4_SampleDescription(AP4_SampleDescription::TYPE_UNKNOWN),
- m_SampleEntry(entry)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_UnknownSampleDescription::~AP4_UnknownSampleDescription
-+---------------------------------------------------------------------*/
-AP4_UnknownSampleDescription::~AP4_UnknownSampleDescription()
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_UnknownSampleDescription::ToAtom
-+---------------------------------------------------------------------*/
-AP4_Atom*
-AP4_UnknownSampleDescription::ToAtom() const
-{
- return new AP4_SampleEntry(m_SampleEntry->GetType(),
- m_SampleEntry->GetDataReferenceIndex());
-}
-
-/*----------------------------------------------------------------------
-| AP4_MpegSampleDescription::AP4_MpegSampleDescription
-+---------------------------------------------------------------------*/
-AP4_MpegSampleDescription::AP4_MpegSampleDescription(
- StreamType stream_type,
- OTI oti,
- const AP4_DataBuffer* decoder_info,
- AP4_UI32 buffer_size,
- AP4_UI32 max_bitrate,
- AP4_UI32 avg_bitrate) :
- AP4_SampleDescription(TYPE_MPEG),
- m_StreamType(stream_type),
- m_ObjectTypeId(oti),
- m_DecoderInfo(NULL),
- m_BufferSize(buffer_size),
- m_MaxBitrate(max_bitrate),
- m_AvgBitrate(avg_bitrate)
-{
- if (decoder_info != NULL) {
- m_DecoderInfo = new AP4_DataBuffer(*decoder_info);
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_MpegSampleDescription::~AP4_MpegSampleDescription
-+---------------------------------------------------------------------*/
-AP4_MpegSampleDescription::~AP4_MpegSampleDescription()
-{
- delete m_DecoderInfo;
-}
-
-/*----------------------------------------------------------------------
-| AP4_MpegSampleDescription::CreateEsDescriptor
-+---------------------------------------------------------------------*/
-AP4_EsDescriptor*
-AP4_MpegSampleDescription::CreateEsDescriptor() const
-{
- AP4_EsDescriptor* desc = new AP4_EsDescriptor(0);
- AP4_DecoderSpecificInfoDescriptor* dsi_desc;
- if (m_DecoderInfo) {
- dsi_desc = new AP4_DecoderSpecificInfoDescriptor(*m_DecoderInfo);
- } else {
- dsi_desc = NULL;
- }
- AP4_DecoderConfigDescriptor* decoder_config =
- new AP4_DecoderConfigDescriptor(m_StreamType,
- m_ObjectTypeId,
- m_BufferSize,
- m_MaxBitrate,
- m_AvgBitrate,
- dsi_desc);
- desc->AddSubDescriptor(decoder_config);
- return desc;
-}
-
-/*----------------------------------------------------------------------
-| AP4_MpegSystemSampleDescription::AP4_MpegSystemSampleDescription
-+---------------------------------------------------------------------*/
-AP4_MpegSystemSampleDescription::AP4_MpegSystemSampleDescription(
- StreamType stream_type,
- OTI oti,
- const AP4_DataBuffer* decoder_info,
- AP4_UI32 buffer_size,
- AP4_UI32 max_bitrate,
- AP4_UI32 avg_bitrate) :
- AP4_MpegSampleDescription(stream_type,
- oti,
- decoder_info,
- buffer_size,
- max_bitrate,
- avg_bitrate)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_MpegSystemSampleDescription::ToAtom
-+---------------------------------------------------------------------*/
-AP4_Atom*
-AP4_MpegSystemSampleDescription::ToAtom() const
-{
- return new AP4_Mp4sSampleEntry(CreateEsDescriptor());
-}
-
-/*----------------------------------------------------------------------
-| AP4_MpegAudioSampleDescription::AP4_MpegAudioSampleDescription
-+---------------------------------------------------------------------*/
-AP4_MpegAudioSampleDescription::AP4_MpegAudioSampleDescription(
- OTI oti,
- unsigned int sample_rate,
- unsigned int sample_size,
- unsigned int channel_count,
- const AP4_DataBuffer* decoder_info,
- AP4_UI32 buffer_size,
- AP4_UI32 max_bitrate,
- AP4_UI32 avg_bitrate) :
- AP4_MpegSampleDescription(AP4_AUDIO_STREAM_TYPE,
- oti,
- decoder_info, buffer_size,
- max_bitrate, avg_bitrate),
- m_SampleRate(sample_rate),
- m_SampleSize(sample_size),
- m_ChannelCount(channel_count)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_MpegAudioSampleDescription::ToAtom
-+---------------------------------------------------------------------*/
-AP4_Atom*
-AP4_MpegAudioSampleDescription::ToAtom() const
-{
- return new AP4_Mp4aSampleEntry(m_SampleRate<<16,
- m_SampleSize,
- m_ChannelCount,
- CreateEsDescriptor());
-}
-
-/*----------------------------------------------------------------------
-| AP4_MpegVideoSampleDescription::AP4_MpegVideoSampleDescription
-+---------------------------------------------------------------------*/
-AP4_MpegVideoSampleDescription::AP4_MpegVideoSampleDescription(
- OTI oti,
- AP4_UI16 width,
- AP4_UI16 height,
- AP4_UI16 depth,
- const char* compressor_name,
- const AP4_DataBuffer* decoder_info,
- AP4_UI32 buffer_size,
- AP4_UI32 max_bitrate,
- AP4_UI32 avg_bitrate) :
- AP4_MpegSampleDescription(AP4_VISUAL_STREAM_TYPE,
- oti,
- decoder_info,
- buffer_size,
- max_bitrate,
- avg_bitrate),
- m_Width(width),
- m_Height(height),
- m_Depth(depth),
- m_CompressorName(compressor_name)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_MpegVideoSampleDescription::ToAtom
-+---------------------------------------------------------------------*/
-AP4_Atom*
-AP4_MpegVideoSampleDescription::ToAtom() const
-{
- return new AP4_Mp4vSampleEntry(m_Width,
- m_Height,
- m_Depth,
- m_CompressorName.c_str(),
- CreateEsDescriptor());
-}
-
-/*----------------------------------------------------------------------
-| AP4_MpegSampleDescription::GetStreamTypeString
-+---------------------------------------------------------------------*/
-const char*
-AP4_MpegSampleDescription::GetStreamTypeString(StreamType type)
-{
- switch (type) {
- case AP4_FORBIDDEN_STREAM_TYPE: return "INVALID";
- case AP4_OD_STREAM_TYPE: return "Object Descriptor";
- case AP4_CR_STREAM_TYPE: return "CR";
- case AP4_BIFS_STREAM_TYPE: return "BIFS";
- case AP4_VISUAL_STREAM_TYPE: return "Visual";
- case AP4_AUDIO_STREAM_TYPE: return "Audio";
- case AP4_MPEG7_STREAM_TYPE: return "MPEG-7";
- case AP4_IPMP_STREAM_TYPE: return "IPMP";
- case AP4_OCI_STREAM_TYPE: return "OCI";
- case AP4_MPEGJ_STREAM_TYPE: return "MPEG-J";
- default: return "UNKNOWN";
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_MpegSampleDescription::GetObjectTypeString
-+---------------------------------------------------------------------*/
-const char*
-AP4_MpegSampleDescription::GetObjectTypeString(OTI oti)
-{
- switch (oti) {
- case AP4_MPEG4_SYSTEM_OTI: return "MPEG-4 System";
- case AP4_MPEG4_SYSTEM_COR_OTI: return "MPEG-4 System COR";
- case AP4_MPEG4_VISUAL_OTI: return "MPEG-4 Video";
- case AP4_MPEG4_AUDIO_OTI: return "MPEG-4 Audio";
- case AP4_MPEG2_VISUAL_SIMPLE_OTI: return "MPEG-2 Video Simple Profile";
- case AP4_MPEG2_VISUAL_MAIN_OTI: return "MPEG-2 Video Main Profile";
- case AP4_MPEG2_VISUAL_SNR_OTI: return "MPEG-2 Video SNR";
- case AP4_MPEG2_VISUAL_SPATIAL_OTI: return "MPEG-2 Video Spatial";
- case AP4_MPEG2_VISUAL_HIGH_OTI: return "MPEG-2 Video High";
- case AP4_MPEG2_VISUAL_422_OTI: return "MPEG-2 Video 4:2:2";
- case AP4_MPEG2_AAC_AUDIO_MAIN_OTI: return "MPEG-2 Audio AAC Main Profile";
- case AP4_MPEG2_AAC_AUDIO_LC_OTI: return "MPEG-2 Audio AAC Low Complexity";
- case AP4_MPEG2_AAC_AUDIO_SSRP_OTI: return "MPEG-2 Audio AAC SSRP";
- case AP4_MPEG2_PART3_AUDIO_OTI: return "MPEG-2 Audio Part-3";
- case AP4_MPEG1_VISUAL_OTI: return "MPEG-1 Video";
- case AP4_MPEG1_AUDIO_OTI: return "MPEG-1 Audio";
- case AP4_JPEG_OTI: return "JPEG";
- case AP4_DTSC_AUDIO_OTI: return "DTS audio";
- case AP4_DTSH_AUDIO_OTI: return "DTS-HD High Resolution Audio";
- case AP4_DTSL_AUDIO_OTI: return "DTS-HD Master Audio";
- case AP4_NERO_VOBSUB: return "VobSub Subtitle";
- default: return "UNKNOWN";
- }
-}
-
diff --git a/src/thirdparty/Bento4/Core/Ap4SampleDescription.h b/src/thirdparty/Bento4/Core/Ap4SampleDescription.h
deleted file mode 100644
index 37148126e..000000000
--- a/src/thirdparty/Bento4/Core/Ap4SampleDescription.h
+++ /dev/null
@@ -1,256 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Sample Description Objects
-|
-| Copyright 2002 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_SAMPLE_DESCRIPTION_H_
-#define _AP4_SAMPLE_DESCRIPTION_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4DataBuffer.h"
-#include "Ap4Atom.h"
-#include "Ap4EsDescriptor.h"
-
-/*----------------------------------------------------------------------
-| class references
-+---------------------------------------------------------------------*/
-class AP4_SampleEntry;
-
-/*----------------------------------------------------------------------
-| AP4_SampleDescription
-+---------------------------------------------------------------------*/
-class AP4_SampleDescription
-{
- public:
- // type constants of the sample description
- enum Type {
- TYPE_UNKNOWN = 0x00,
- TYPE_MPEG = 0x01,
- TYPE_ISMACRYP = 0x02
- };
-
- // constructors & destructor
- AP4_SampleDescription(Type type) : m_Type(type) {}
- virtual ~AP4_SampleDescription() {}
-
- // accessors
- Type GetType() const { return m_Type; }
-
- // factories
- virtual AP4_Atom* ToAtom() const = 0;
-
- protected:
- Type m_Type;
-};
-
-/*----------------------------------------------------------------------
-| AP4_UnknownSampleDescription
-+---------------------------------------------------------------------*/
-class AP4_UnknownSampleDescription : public AP4_SampleDescription
-{
- public:
- // methods
- AP4_UnknownSampleDescription(AP4_SampleEntry* sample_entry);
- ~AP4_UnknownSampleDescription();
- AP4_SampleEntry* GetSampleEntry() { return m_SampleEntry; }
- AP4_Atom* ToAtom() const;
-
- protected:
- AP4_SampleEntry* m_SampleEntry;
-};
-
-/*----------------------------------------------------------------------
-| AP4_MpegSampleDescription
-+---------------------------------------------------------------------*/
-class AP4_MpegSampleDescription : public AP4_SampleDescription
-{
- public:
- // types
- typedef AP4_UI08 StreamType;
- typedef AP4_UI08 OTI;
-
- // class methods
- const char* GetStreamTypeString(StreamType type);
- const char* GetObjectTypeString(OTI oti);
-
- // constructors & destructor
- AP4_MpegSampleDescription(StreamType stream_type,
- OTI oti,
- const AP4_DataBuffer* decoder_info,
- AP4_UI32 buffer_size,
- AP4_UI32 max_bitrate,
- AP4_UI32 avg_bitrate);
- virtual ~AP4_MpegSampleDescription();
-
- // accessors
- AP4_Byte GetStreamType() const { return m_StreamType; }
- AP4_Byte GetObjectTypeId() const { return m_ObjectTypeId; }
- const AP4_DataBuffer* GetDecoderInfo() const { return m_DecoderInfo; }
- AP4_UI32 GetBufferSize() const { return m_BufferSize; }
- AP4_UI32 GetMaxBitrate() const { return m_MaxBitrate; }
- AP4_UI32 GetAvgBitrate() const { return m_AvgBitrate; }
-
- // methods
- AP4_EsDescriptor* CreateEsDescriptor() const;
-
- protected:
- // members
- StreamType m_StreamType;
- OTI m_ObjectTypeId;
- AP4_DataBuffer* m_DecoderInfo;
- AP4_UI32 m_BufferSize;
- AP4_UI32 m_MaxBitrate;
- AP4_UI32 m_AvgBitrate;
-
-};
-
-/*----------------------------------------------------------------------
-| AP4_MpegSystemSampleDescription
-+---------------------------------------------------------------------*/
-class AP4_MpegSystemSampleDescription : public AP4_MpegSampleDescription
-{
-public:
- // constructor
- AP4_MpegSystemSampleDescription(StreamType type,
- OTI oti,
- const AP4_DataBuffer* decoder_info,
- AP4_UI32 buffer_size,
- AP4_UI32 max_bitrate,
- AP4_UI32 avg_bitrate);
-
- // methods
- AP4_Atom* ToAtom() const;
-};
-
-/*----------------------------------------------------------------------
-| AP4_MpegAudioSampleDescription
-+---------------------------------------------------------------------*/
-class AP4_MpegAudioSampleDescription : public AP4_MpegSampleDescription
-{
-public:
- // constructor
- AP4_MpegAudioSampleDescription(OTI oti,
- unsigned int sample_rate,
- unsigned int sample_size,
- unsigned int channel_count,
- const AP4_DataBuffer* decoder_info,
- AP4_UI32 buffer_size,
- AP4_UI32 max_bitrate,
- AP4_UI32 avg_bitrate);
-
- // accessors
- AP4_UI32 GetSampleRate() { return m_SampleRate; }
- AP4_UI16 GetSampleSize() { return m_SampleSize; }
- AP4_UI16 GetChannelCount() { return m_ChannelCount; }
-
- // methods
- AP4_Atom* ToAtom() const;
-
-protected:
- // members
- AP4_UI32 m_SampleRate;
- AP4_UI16 m_SampleSize;
- AP4_UI16 m_ChannelCount;
-};
-
-/*----------------------------------------------------------------------
-| AP4_MpegVideoSampleDescription
-+---------------------------------------------------------------------*/
-class AP4_MpegVideoSampleDescription : public AP4_MpegSampleDescription
-{
-public:
- // constructor
- AP4_MpegVideoSampleDescription(OTI oti,
- AP4_UI16 width,
- AP4_UI16 height,
- AP4_UI16 depth,
- const char* compressor_name,
- const AP4_DataBuffer* decoder_info,
- AP4_UI32 buffer_size,
- AP4_UI32 max_bitrate,
- AP4_UI32 avg_bitrate);
-
- // accessors
- AP4_UI32 GetWidth() { return m_Width; }
- AP4_UI16 GetHeight() { return m_Height; }
- AP4_UI16 GetDepth() { return m_Depth; }
- const char* GetCompressorName() { return m_CompressorName.c_str(); }
-
- // methods
- AP4_Atom* ToAtom() const;
-
-protected:
- // members
- AP4_UI16 m_Width;
- AP4_UI16 m_Height;
- AP4_UI16 m_Depth;
- AP4_String m_CompressorName;
-};
-
-/*----------------------------------------------------------------------
-| constants
-+---------------------------------------------------------------------*/
-const AP4_MpegSampleDescription::StreamType AP4_FORBIDDEN_STREAM_TYPE = 0x00;
-const AP4_MpegSampleDescription::StreamType AP4_OD_STREAM_TYPE = 0x01;
-const AP4_MpegSampleDescription::StreamType AP4_CR_STREAM_TYPE = 0x02;
-const AP4_MpegSampleDescription::StreamType AP4_BIFS_STREAM_TYPE = 0x03;
-const AP4_MpegSampleDescription::StreamType AP4_VISUAL_STREAM_TYPE = 0x04;
-const AP4_MpegSampleDescription::StreamType AP4_AUDIO_STREAM_TYPE = 0x05;
-const AP4_MpegSampleDescription::StreamType AP4_MPEG7_STREAM_TYPE = 0x06;
-const AP4_MpegSampleDescription::StreamType AP4_IPMP_STREAM_TYPE = 0x07;
-const AP4_MpegSampleDescription::StreamType AP4_OCI_STREAM_TYPE = 0x08;
-const AP4_MpegSampleDescription::StreamType AP4_MPEGJ_STREAM_TYPE = 0x09;
-
-const AP4_MpegSampleDescription::OTI AP4_MPEG4_SYSTEM_OTI = 0x01;
-const AP4_MpegSampleDescription::OTI AP4_MPEG4_SYSTEM_COR_OTI = 0x02;
-const AP4_MpegSampleDescription::OTI AP4_MPEG4_VISUAL_OTI = 0x20;
-const AP4_MpegSampleDescription::OTI AP4_MPEG4_AUDIO_OTI = 0x40;
-const AP4_MpegSampleDescription::OTI AP4_MPEG2_VISUAL_SIMPLE_OTI = 0x60;
-const AP4_MpegSampleDescription::OTI AP4_MPEG2_VISUAL_MAIN_OTI = 0x61;
-const AP4_MpegSampleDescription::OTI AP4_MPEG2_VISUAL_SNR_OTI = 0x62;
-const AP4_MpegSampleDescription::OTI AP4_MPEG2_VISUAL_SPATIAL_OTI = 0x63;
-const AP4_MpegSampleDescription::OTI AP4_MPEG2_VISUAL_HIGH_OTI = 0x64;
-const AP4_MpegSampleDescription::OTI AP4_MPEG2_VISUAL_422_OTI = 0x65;
-const AP4_MpegSampleDescription::OTI AP4_MPEG2_AAC_AUDIO_MAIN_OTI = 0x66;
-const AP4_MpegSampleDescription::OTI AP4_MPEG2_AAC_AUDIO_LC_OTI = 0x67;
-const AP4_MpegSampleDescription::OTI AP4_MPEG2_AAC_AUDIO_SSRP_OTI = 0x68;
-const AP4_MpegSampleDescription::OTI AP4_MPEG2_PART3_AUDIO_OTI = 0x69;
-const AP4_MpegSampleDescription::OTI AP4_MPEG1_VISUAL_OTI = 0x6A;
-const AP4_MpegSampleDescription::OTI AP4_MPEG1_AUDIO_OTI = 0x6B;
-const AP4_MpegSampleDescription::OTI AP4_JPEG_OTI = 0x6C;
-
-const AP4_MpegSampleDescription::OTI AP4_DTSC_AUDIO_OTI = 0xA9;
-const AP4_MpegSampleDescription::OTI AP4_DTSH_AUDIO_OTI = 0xAA;
-const AP4_MpegSampleDescription::OTI AP4_DTSL_AUDIO_OTI = 0xAB;
-
-const AP4_MpegSampleDescription::OTI AP4_NERO_VOBSUB = 0xE0;
-
-#endif // _AP4_SAMPLE_DESCRIPTION_H_
-
diff --git a/src/thirdparty/Bento4/Core/Ap4SampleEntry.cpp b/src/thirdparty/Bento4/Core/Ap4SampleEntry.cpp
deleted file mode 100644
index 3b15b75af..000000000
--- a/src/thirdparty/Bento4/Core/Ap4SampleEntry.cpp
+++ /dev/null
@@ -1,1307 +0,0 @@
-/*****************************************************************
-|
-| AP4 - sample entries
-|
-| Copyright 2002 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4SampleEntry.h"
-#include "Ap4Utils.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4TimsAtom.h"
-#include "Ap4SampleDescription.h"
-#include "Ap4FtabAtom.h"
-#include "Ap4EndaAtom.h"
-
-/*----------------------------------------------------------------------
-| AP4_SampleEntry::AP4_SampleEntry
-+---------------------------------------------------------------------*/
-AP4_SampleEntry::AP4_SampleEntry(AP4_Atom::Type format,
- AP4_UI16 data_reference_index) :
- AP4_ContainerAtom(format, AP4_ATOM_HEADER_SIZE+8, false),
- m_DataReferenceIndex(data_reference_index)
-{
- m_Reserved1[0] = 0;
- m_Reserved1[1] = 0;
- m_Reserved1[2] = 0;
- m_Reserved1[3] = 0;
- m_Reserved1[4] = 0;
- m_Reserved1[5] = 0;
-}
-
-/*----------------------------------------------------------------------
-| AP4_SampleEntry::AP4_SampleEntry
-+---------------------------------------------------------------------*/
-AP4_SampleEntry::AP4_SampleEntry(AP4_Atom::Type format,
- AP4_Size size) :
- AP4_ContainerAtom(format, size)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_SampleEntry::AP4_SampleEntry
-+---------------------------------------------------------------------*/
-AP4_SampleEntry::AP4_SampleEntry(AP4_Atom::Type format,
- AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
- AP4_ContainerAtom(format, size)
-{
- // read the fields before the children atoms
- AP4_Size fields_size = GetFieldsSize();
- ReadFields(stream);
-
- // read children atoms (ex: esds and maybe others)
- ReadChildren(atom_factory, stream, size-AP4_ATOM_HEADER_SIZE-fields_size);
-}
-
-/*----------------------------------------------------------------------
-| AP4_SampleEntry::GetFieldsSize
-+---------------------------------------------------------------------*/
-AP4_Size
-AP4_SampleEntry::GetFieldsSize()
-{
- return 8;
-}
-
-/*----------------------------------------------------------------------
-| AP4_SampleEntry::ReadFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SampleEntry::ReadFields(AP4_ByteStream& stream)
-{
- stream.Read(m_Reserved1, sizeof(m_Reserved1), NULL);
- stream.ReadUI16(m_DataReferenceIndex);
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_SampleEntry::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SampleEntry::WriteFields(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- // reserved1
- result = stream.Write(m_Reserved1, sizeof(m_Reserved1));
- if (AP4_FAILED(result)) return result;
-
- // data reference index
- result = stream.WriteUI16(m_DataReferenceIndex);
- if (AP4_FAILED(result)) return result;
-
- return result;
-}
-
-/*----------------------------------------------------------------------
-| AP4_SampleEntry::Write
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SampleEntry::Write(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- // write the header
- result = WriteHeader(stream);
- if (AP4_FAILED(result)) return result;
-
- // write the fields
- result = WriteFields(stream);
- if (AP4_FAILED(result)) return result;
-
- // write the children atoms
- return m_Children.Apply(AP4_AtomListWriter(stream));
-}
-
-/*----------------------------------------------------------------------
-| AP4_SampleEntry::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SampleEntry::InspectFields(AP4_AtomInspector& inspector)
-{
- inspector.AddField("data_reference_index", m_DataReferenceIndex);
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_SampleEntry::Inspect
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SampleEntry::Inspect(AP4_AtomInspector& inspector)
-{
- // inspect the header
- InspectHeader(inspector);
-
- // inspect the fields
- InspectFields(inspector);
-
- // inspect children
- m_Children.Apply(AP4_AtomListInspector(inspector));
-
- // finish
- inspector.EndElement();
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_SampleEntry::OnChildChanged
-+---------------------------------------------------------------------*/
-void
-AP4_SampleEntry::OnChildChanged(AP4_Atom*)
-{
- // remcompute our size
- m_Size = GetHeaderSize()+GetFieldsSize();
- m_Children.Apply(AP4_AtomSizeAdder(m_Size));
-
- // update our parent
- if (m_Parent) m_Parent->OnChildChanged(this);
-}
-
-/*----------------------------------------------------------------------
-| AP4_SampleEntry::ToSampleDescription
-+---------------------------------------------------------------------*/
-AP4_SampleDescription*
-AP4_SampleEntry::ToSampleDescription()
-{
- return new AP4_UnknownSampleDescription(this);
-}
-
-/*----------------------------------------------------------------------
-| AP4_MpegSampleEntry::AP4_MpegSampleEntry
-+---------------------------------------------------------------------*/
-AP4_MpegSampleEntry::AP4_MpegSampleEntry(AP4_Atom::Type format,
- AP4_EsDescriptor* descriptor) :
- AP4_SampleEntry(format)
-{
- if (descriptor) AddChild(new AP4_EsdsAtom(descriptor));
-}
-
-/*----------------------------------------------------------------------
-| AP4_MpegSampleEntry::AP4_MpegSampleEntry
-+---------------------------------------------------------------------*/
-AP4_MpegSampleEntry::AP4_MpegSampleEntry(AP4_Atom::Type format,
- AP4_Size size) :
- AP4_SampleEntry(format, size)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_MpegSampleEntry::AP4_MpegSampleEntry
-+---------------------------------------------------------------------*/
-AP4_MpegSampleEntry::AP4_MpegSampleEntry(AP4_Atom::Type format,
- AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
- AP4_SampleEntry(format, size, stream, atom_factory)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_MpegSampleEntry::AP4_MpegSampleEntry
-+---------------------------------------------------------------------*/
-const AP4_DecoderConfigDescriptor*
-AP4_MpegSampleEntry::GetDecoderConfigDescriptor()
-{
- AP4_Atom* child = GetChild(AP4_ATOM_TYPE_ESDS);
-
- if(!child) {
- child = GetChild(AP4_ATOM_TYPE_WAVE);
- if (AP4_ContainerAtom* wave = dynamic_cast<AP4_ContainerAtom*>(child)) {
- child = wave->GetChild(AP4_ATOM_TYPE_ESDS);
- }
- }
-
- if (child) {
- AP4_EsdsAtom* esds = (AP4_EsdsAtom*)child;
-
- // get the es descriptor
- const AP4_EsDescriptor* es_desc = esds->GetEsDescriptor();
- if (es_desc == NULL) return NULL;
-
- // get the decoder config descriptor
- return es_desc->GetDecoderConfigDescriptor();
- } else {
- return NULL;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_Mp4sSampleEntry::AP4_Mp4sSampleEntry
-+---------------------------------------------------------------------*/
-AP4_Mp4sSampleEntry::AP4_Mp4sSampleEntry(AP4_EsDescriptor* descriptor) :
- AP4_MpegSampleEntry(AP4_ATOM_TYPE_MP4S, descriptor)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_Mp4sSampleEntry::AP4_Mp4sSampleEntry
-+---------------------------------------------------------------------*/
-AP4_Mp4sSampleEntry::AP4_Mp4sSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
- AP4_MpegSampleEntry(AP4_ATOM_TYPE_MP4S, size, stream, atom_factory)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_Mp4sSampleEntry::ToSampleDescription
-+---------------------------------------------------------------------*/
-AP4_SampleDescription*
-AP4_Mp4sSampleEntry::ToSampleDescription()
-{
- // get the decoder config descriptor
- const AP4_DecoderConfigDescriptor* dc_desc;
- dc_desc = GetDecoderConfigDescriptor();
- if (dc_desc == NULL) return NULL;
- const AP4_DataBuffer* dsi = NULL;
- const AP4_DecoderSpecificInfoDescriptor* dsi_desc =
- dc_desc->GetDecoderSpecificInfoDescriptor();
- if (dsi_desc != NULL) {
- dsi = &dsi_desc->GetDecoderSpecificInfo();
- }
-
- // create a sample description
- return new AP4_MpegSystemSampleDescription(
- dc_desc->GetStreamType(),
- dc_desc->GetObjectTypeIndication(),
- dsi,
- dc_desc->GetBufferSize(),
- dc_desc->GetMaxBitrate(),
- dc_desc->GetAvgBitrate());
-}
-
-/*----------------------------------------------------------------------
-| AP4_AudioSampleEntry::AP4_AudioSampleEntry
-+---------------------------------------------------------------------*/
-AP4_AudioSampleEntry::AP4_AudioSampleEntry(AP4_Atom::Type format,
- AP4_EsDescriptor* descriptor,
- AP4_UI32 sample_rate,
- AP4_UI16 sample_size,
- AP4_UI16 channel_count) :
- AP4_MpegSampleEntry(format, descriptor),
- m_QtVersion(0),
- m_QtRevision(0),
- m_QtVendor(0),
- m_ChannelCount(channel_count),
- m_SampleSize(sample_size),
- m_QtCompressionId(0),
- m_QtPacketSize(0),
- m_SampleRate(sample_rate),
- m_QtV1SamplesPerPacket(0),
- m_QtV1BytesPerPacket(0),
- m_QtV1BytesPerFrame(0),
- m_QtV1BytesPerSample(0),
- m_QtV2StructSize(0),
- m_QtV2SampleRate64(0.0),
- m_QtV2ChannelCount(0),
- m_QtV2Reserved(0),
- m_QtV2BitsPerChannel(0),
- m_QtV2FormatSpecificFlags(0),
- m_QtV2BytesPerAudioPacket(0),
- m_QtV2LPCMFramesPerAudioPacket(0),
-// mpc-hc custom code start
- m_Endian(ENDIAN_NOTSET)
-// mpc-hc custom code end
-{
- m_Size += 20;
-}
-
-/*----------------------------------------------------------------------
-| AP4_AudioSampleEntry::AP4_AudioSampleEntry
-+---------------------------------------------------------------------*/
-AP4_AudioSampleEntry::AP4_AudioSampleEntry(AP4_Atom::Type format,
- AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
- AP4_MpegSampleEntry(format, size)
-{
- // read fields
- ReadFields(stream);
-
- // hack to get the correct WAVEFORMATEX in MP4Splitter.cpp
- // (need more information about audio formats used in older movs (QuickTime 2.x))
- if (m_QtVersion == 0 || // fill QtV1 values for the old movs
- m_QtVersion == 1 && m_QtV1BytesPerPacket == 0) // fixing empty QtV1 values for some (broken?) movs.
- {
- switch( format )
- {
- case AP4_ATOM_TYPE_ALAW:
- case AP4_ATOM_TYPE_ULAW:
- m_SampleSize = 8; // sometimes this value is incorrect
- m_QtV1SamplesPerPacket = 1;
- m_QtV1BytesPerPacket = 1;
- break;
- case AP4_ATOM_TYPE_IMA4:
- m_QtV1SamplesPerPacket = 64;
- m_QtV1BytesPerPacket = 34;
- break;
- case AP4_ATOM_TYPE_MAC3:
- m_QtV1SamplesPerPacket = 3;
- m_QtV1BytesPerPacket = 1;
- break;
- case AP4_ATOM_TYPE_MAC6:
- m_QtV1SamplesPerPacket = 6;
- m_QtV1BytesPerPacket = 1;
- break;
- case AP4_ATOM_TYPE_SAMR:
- m_ChannelCount = 1; // sometimes this value is incorrect
- m_SampleRate = 8000<<16; // sometimes this value is zero
- //m_QtV1SamplesPerPacket = 160; // mean value, correct it if you know how.
- //m_QtV1BytesPerPacket = 20; // mean value, correct it if you know how.
- // disabled, because the wrong values can break playback.
- break;
- default: // NONE, RAW, TWOS, SOWT and other
- m_QtV1SamplesPerPacket = 1;
- m_QtV1BytesPerPacket = m_SampleSize / 8;
- }
- m_QtV1BytesPerFrame = m_ChannelCount * m_QtV1BytesPerPacket;
- m_QtV1BytesPerSample = m_SampleSize / 8;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
-
- // must be called after m_QtVersion was already set
- AP4_Size fields_size = GetFieldsSize();
-
- // read children atoms (ex: esds and maybe others)
- ReadChildren(atom_factory, stream, size-AP4_ATOM_HEADER_SIZE-fields_size);
-
- // read AP4_ATOM_TYPE_ENDA
- m_Endian = ENDIAN_NOTSET;
- if(AP4_Atom* child = GetChild(AP4_ATOM_TYPE_WAVE))
- if(AP4_ContainerAtom* wave = dynamic_cast<AP4_ContainerAtom*>(child))
- if (AP4_EndaAtom* endian = dynamic_cast<AP4_EndaAtom*>(wave->GetChild(AP4_ATOM_TYPE_ENDA)))
- m_Endian = endian->ReadEndian();
-}
-
-/*----------------------------------------------------------------------
-| AP4_AudioSampleEntry::AP4_AudioSampleEntry
-+---------------------------------------------------------------------*/
-AP4_AudioSampleEntry::AP4_AudioSampleEntry(AP4_Atom::Type format,
- AP4_Size size) :
- AP4_MpegSampleEntry(format, size)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_AudioSampleEntry::GetFieldsSize
-+---------------------------------------------------------------------*/
-AP4_Size
-AP4_AudioSampleEntry::GetFieldsSize()
-{
- AP4_Size size = AP4_SampleEntry::GetFieldsSize()+20;
- if (m_QtVersion == 1) {
- size += 16;
- } else if (m_QtVersion == 2) {
- size += 36+m_QtV2Extension.GetDataSize();
- }
-
- return size;
-}
-
-/*----------------------------------------------------------------------
-| AP4_AudioSampleEntry::GetSampleRate
-+---------------------------------------------------------------------*/
-AP4_UI32
-AP4_AudioSampleEntry::GetSampleRate()
-{
- if (m_QtVersion == 2) {
- return (AP4_UI32)(m_QtV2SampleRate64);
-// mpc-hc custom code start
- } else if (m_SampleRate>>16 == 0) {
- return m_SampleRate;
-// mpc-hc custom code end
- } else {
- return m_SampleRate>>16;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_AudioSampleEntry::GetChannelCount
-+---------------------------------------------------------------------*/
-AP4_UI16
-AP4_AudioSampleEntry::GetChannelCount()
-{
- if (m_QtVersion == 2) {
- return m_QtV2ChannelCount;
- } else {
- return m_ChannelCount;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_AudioSampleEntry::ReadFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_AudioSampleEntry::ReadFields(AP4_ByteStream& stream)
-{
- // sample entry
- AP4_Result result = AP4_SampleEntry::ReadFields(stream);
- if (result < 0) return result;
-
- // read the fields of this class
- stream.ReadUI16(m_QtVersion);
- stream.ReadUI16(m_QtRevision);
- stream.ReadUI32(m_QtVendor);
- stream.ReadUI16(m_ChannelCount);
- stream.ReadUI16(m_SampleSize);
- stream.ReadUI16(m_QtCompressionId);
- stream.ReadUI16(m_QtPacketSize);
- stream.ReadUI32(m_SampleRate);
-
- // if this is a QT V1 entry, read the extension
- if (m_QtVersion == 1) {
- stream.ReadUI32(m_QtV1SamplesPerPacket);
- stream.ReadUI32(m_QtV1BytesPerPacket);
- stream.ReadUI32(m_QtV1BytesPerFrame);
- stream.ReadUI32(m_QtV1BytesPerSample);
- } else if (m_QtVersion == 2) {
- stream.ReadUI32(m_QtV2StructSize);
- stream.ReadDouble(m_QtV2SampleRate64);
- stream.ReadUI32(m_QtV2ChannelCount);
- stream.ReadUI32(m_QtV2Reserved);
- stream.ReadUI32(m_QtV2BitsPerChannel);
- stream.ReadUI32(m_QtV2FormatSpecificFlags);
- stream.ReadUI32(m_QtV2BytesPerAudioPacket);
- stream.ReadUI32(m_QtV2LPCMFramesPerAudioPacket);
- if (m_QtV2StructSize > 72) {
- unsigned int ext_size = m_QtV2StructSize-72;
- m_QtV2Extension.SetDataSize(ext_size);
- stream.Read(m_QtV2Extension.UseData(), ext_size);
- }
- m_QtV1SamplesPerPacket =
- m_QtV1BytesPerPacket =
- m_QtV1BytesPerFrame =
- m_QtV1BytesPerSample = 0;
- } else {
- m_QtV1SamplesPerPacket = 0;
- m_QtV1BytesPerPacket = 0;
- m_QtV1BytesPerFrame = 0;
- m_QtV1BytesPerSample = 0;
- m_QtV2StructSize = 0;
- m_QtV2SampleRate64 = 0.0;
- m_QtV2ChannelCount = 0;
- m_QtV2Reserved = 0;
- m_QtV2BitsPerChannel = 0;
- m_QtV2FormatSpecificFlags = 0;
- m_QtV2BytesPerAudioPacket = 0;
- m_QtV2LPCMFramesPerAudioPacket = 0;
- }
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_AudioSampleEntry::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_AudioSampleEntry::WriteFields(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- // write the fields of the base class
- result = AP4_SampleEntry::WriteFields(stream);
-
- //
- result = stream.WriteUI16(m_QtVersion);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI16(m_QtRevision);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI32(m_QtVendor);
- if (AP4_FAILED(result)) return result;
-
- // channel count
- result = stream.WriteUI16(m_ChannelCount);
- if (AP4_FAILED(result)) return result;
-
- // sample size
- result = stream.WriteUI16(m_SampleSize);
- if (AP4_FAILED(result)) return result;
-
- // predefined1
- result = stream.WriteUI16(m_QtCompressionId);
- if (AP4_FAILED(result)) return result;
-
- // reserved3
- result = stream.WriteUI16(m_QtPacketSize);
- if (AP4_FAILED(result)) return result;
-
- // sample rate
- result = stream.WriteUI32(m_SampleRate);
- if (AP4_FAILED(result)) return result;
-
- if(m_QtVersion == 1)
- {
- result = stream.WriteUI32(m_QtV1SamplesPerPacket);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI32(m_QtV1BytesPerPacket);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI32(m_QtV1BytesPerFrame);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI32(m_QtV1BytesPerSample);
- if (AP4_FAILED(result)) return result;
- }
- else if(m_QtVersion != 0)
- {
- return AP4_FAILURE;
- }
-
- return result;
-}
-
-/*----------------------------------------------------------------------
-| AP4_AudioSampleEntry::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_AudioSampleEntry::InspectFields(AP4_AtomInspector& inspector)
-{
- // dump the fields from the base class
- AP4_SampleEntry::InspectFields(inspector);
-
- // fields
- inspector.AddField("channel_count", m_ChannelCount);
- inspector.AddField("sample_size", m_SampleSize);
- inspector.AddField("sample_rate", m_SampleRate>>16);
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_AudioSampleEntry::ToSampleDescription
-+---------------------------------------------------------------------*/
-AP4_SampleDescription*
-AP4_AudioSampleEntry::ToSampleDescription()
-{
- // get the decoder config descriptor
- const AP4_DecoderConfigDescriptor* dc_desc;
- dc_desc = GetDecoderConfigDescriptor();
- if (dc_desc == NULL) return NULL;
- const AP4_DataBuffer* dsi = NULL;
- const AP4_DecoderSpecificInfoDescriptor* dsi_desc =
- dc_desc->GetDecoderSpecificInfoDescriptor();
- if (dsi_desc != NULL) {
- dsi = &dsi_desc->GetDecoderSpecificInfo();
- }
-
- // create a sample description
- return new AP4_MpegAudioSampleDescription(
- dc_desc->GetObjectTypeIndication(),
- GetSampleRate(),
- GetSampleSize(),
- GetChannelCount(),
- dsi,
- dc_desc->GetBufferSize(),
- dc_desc->GetMaxBitrate(),
- dc_desc->GetAvgBitrate());
-}
-
-/*----------------------------------------------------------------------
-| AP4_Mp4aSampleEntry::AP4_Mp4aSampleEntry
-+---------------------------------------------------------------------*/
-AP4_Mp4aSampleEntry::AP4_Mp4aSampleEntry(AP4_UI32 sample_rate,
- AP4_UI16 sample_size,
- AP4_UI16 channel_count,
- AP4_EsDescriptor* descriptor) :
- AP4_AudioSampleEntry(AP4_ATOM_TYPE_MP4A,
- descriptor,
- sample_rate,
- sample_size,
- channel_count)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_Mp4aSampleEntry::AP4_Mp4aSampleEntry
-+---------------------------------------------------------------------*/
-AP4_Mp4aSampleEntry::AP4_Mp4aSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
- AP4_AudioSampleEntry(AP4_ATOM_TYPE_MP4A, size, stream, atom_factory)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_VisualSampleEntry::AP4_VisualSampleEntry
-+---------------------------------------------------------------------*/
-AP4_VisualSampleEntry::AP4_VisualSampleEntry(
- AP4_Atom::Type format,
- AP4_EsDescriptor* descriptor,
- AP4_UI16 width,
- AP4_UI16 height,
- AP4_UI16 depth,
- const char* compressor_name) :
- AP4_MpegSampleEntry(format, descriptor),
- m_Predefined1(0),
- m_Reserved2(0),
- m_Width(width),
- m_Height(height),
- m_HorizResolution(0x00480000),
- m_VertResolution(0x00480000),
- m_Reserved3(0),
- m_FrameCount(1),
- m_CompressorName(compressor_name),
- m_Depth(depth),
- m_Predefined3(0xFFFF)
-{
- memset(m_Predefined2, 0, sizeof(m_Predefined2));
- m_Size += 70;
-}
-
-/*----------------------------------------------------------------------
-| AP4_VisualSampleEntry::AP4_VisualSampleEntry
-+---------------------------------------------------------------------*/
-AP4_VisualSampleEntry::AP4_VisualSampleEntry(AP4_Atom::Type format,
- AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
- AP4_MpegSampleEntry(format, size)
-{
- // read fields
- AP4_Size fields_size = GetFieldsSize();
- ReadFields(stream);
-
- // read children atoms (ex: esds and maybe others)
- ReadChildren(atom_factory, stream, size-AP4_ATOM_HEADER_SIZE-fields_size);
-}
-
-/*----------------------------------------------------------------------
-| AP4_VisualSampleEntry::GetFieldsSize
-+---------------------------------------------------------------------*/
-AP4_Size
-AP4_VisualSampleEntry::GetFieldsSize()
-{
- return AP4_SampleEntry::GetFieldsSize()+70;
-}
-
-/*----------------------------------------------------------------------
-| AP4_VisualSampleEntry::ReadFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_VisualSampleEntry::ReadFields(AP4_ByteStream& stream)
-{
- // sample entry
- AP4_Result result = AP4_SampleEntry::ReadFields(stream);
- if (result < 0) return result;
-
- // read fields from this class
- stream.ReadUI16(m_Predefined1);
- stream.ReadUI16(m_Reserved2);
- stream.Read(m_Predefined2, sizeof(m_Predefined2), NULL);
- stream.ReadUI16(m_Width);
- stream.ReadUI16(m_Height);
- stream.ReadUI32(m_HorizResolution);
- stream.ReadUI32(m_VertResolution);
- stream.ReadUI32(m_Reserved3);
- stream.ReadUI16(m_FrameCount);
-
- char compressor_name[33];
- stream.Read(compressor_name, 32);
- int name_length = compressor_name[0];
- if (name_length < 32) {
- compressor_name[name_length+1] = 0;
- m_CompressorName = &compressor_name[1];
- }
-
- stream.ReadUI16(m_Depth);
- stream.ReadUI16(m_Predefined3);
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_VisualSampleEntry::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_VisualSampleEntry::WriteFields(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- // write the fields of the base class
- result = AP4_SampleEntry::WriteFields(stream);
- if (AP4_FAILED(result)) return result;
-
- // predefined1
- result = stream.WriteUI16(m_Predefined1);
- if (AP4_FAILED(result)) return result;
-
- // reserved2
- result = stream.WriteUI16(m_Reserved2);
- if (AP4_FAILED(result)) return result;
-
- // predefined2
- result = stream.Write(m_Predefined2, sizeof(m_Predefined2));
- if (AP4_FAILED(result)) return result;
-
- // width
- result = stream.WriteUI16(m_Width);
- if (AP4_FAILED(result)) return result;
-
- // height
- result = stream.WriteUI16(m_Height);
- if (AP4_FAILED(result)) return result;
-
- // horizontal resolution
- result = stream.WriteUI32(m_HorizResolution);
- if (AP4_FAILED(result)) return result;
-
- // vertical resolution
- result = stream.WriteUI32(m_VertResolution);
- if (AP4_FAILED(result)) return result;
-
- // reserved3
- result = stream.WriteUI32(m_Reserved3);
- if (AP4_FAILED(result)) return result;
-
- // frame count
- result = stream.WriteUI16(m_FrameCount);
- if (AP4_FAILED(result)) return result;
-
- // compressor name
- unsigned char compressor_name[32];
- unsigned int name_length = m_CompressorName.length();
- if (name_length > 31) name_length = 31;
- compressor_name[0] = name_length;
- for (unsigned int i=0; i<name_length; i++) {
- compressor_name[i+1] = m_CompressorName[i];
- }
- for (unsigned int i=name_length+1; i<32; i++) {
- compressor_name[i] = 0;
- }
- result = stream.Write(compressor_name, 32);
- if (AP4_FAILED(result)) return result;
-
- // depth
- result = stream.WriteUI16(m_Depth);
- if (AP4_FAILED(result)) return result;
-
- // predefined3
- result = stream.WriteUI16(m_Predefined3);
- if (AP4_FAILED(result)) return result;
-
- return result;
-}
-
-/*----------------------------------------------------------------------
-| AP4_VisualSampleEntry::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_VisualSampleEntry::InspectFields(AP4_AtomInspector& inspector)
-{
- // dump the fields of the base class
- AP4_SampleEntry::InspectFields(inspector);
-
- // fields
- inspector.AddField("width", m_Width);
- inspector.AddField("height", m_Height);
- inspector.AddField("compressor", m_CompressorName.c_str());
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_VisualSampleEntry::ToSampleDescription
-+---------------------------------------------------------------------*/
-AP4_SampleDescription*
-AP4_VisualSampleEntry::ToSampleDescription()
-{
- // get the decoder config descriptor
- const AP4_DecoderConfigDescriptor* dc_desc;
- dc_desc = GetDecoderConfigDescriptor();
- if (dc_desc == NULL) return NULL;
- const AP4_DataBuffer* dsi = NULL;
- const AP4_DecoderSpecificInfoDescriptor* dsi_desc =
- dc_desc->GetDecoderSpecificInfoDescriptor();
- if (dsi_desc != NULL) {
- dsi = &dsi_desc->GetDecoderSpecificInfo();
- }
-
- // create a sample description
- return new AP4_MpegVideoSampleDescription(
- dc_desc->GetObjectTypeIndication(),
- m_Width,
- m_Height,
- m_Depth,
- m_CompressorName.c_str(),
- dsi,
- dc_desc->GetBufferSize(),
- dc_desc->GetMaxBitrate(),
- dc_desc->GetAvgBitrate());
-}
-
-/*----------------------------------------------------------------------
-| AP4_Mp4vSampleEntry::AP4_Mp4vSampleEntry
-+---------------------------------------------------------------------*/
-AP4_Mp4vSampleEntry::AP4_Mp4vSampleEntry(AP4_UI16 width,
- AP4_UI16 height,
- AP4_UI16 depth,
- const char* compressor_name,
- AP4_EsDescriptor* descriptor) :
- AP4_VisualSampleEntry(AP4_ATOM_TYPE_MP4V,
- descriptor,
- width,
- height,
- depth,
- compressor_name)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_Mp4vSampleEntry::AP4_Mp4aSampleEntry
-+---------------------------------------------------------------------*/
-AP4_Mp4vSampleEntry::AP4_Mp4vSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
- AP4_VisualSampleEntry(AP4_ATOM_TYPE_MP4V, size, stream, atom_factory)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_Avc1SampleEntry::AP4_Avc1SampleEntry
-+---------------------------------------------------------------------*/
-AP4_Avc1SampleEntry::AP4_Avc1SampleEntry(AP4_UI16 width,
- AP4_UI16 height,
- AP4_UI16 depth,
- const char* compressor_name,
- AP4_EsDescriptor* descriptor) :
- AP4_VisualSampleEntry(AP4_ATOM_TYPE_AVC1,
- descriptor,
- width,
- height,
- depth,
- compressor_name)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_Avc1SampleEntry::AP4_Avc1SampleEntry
-+---------------------------------------------------------------------*/
-AP4_Avc1SampleEntry::AP4_Avc1SampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
- AP4_VisualSampleEntry(AP4_ATOM_TYPE_AVC1, size, stream, atom_factory)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_RtpHintSampleEntry::AP4_RtpHintSampleEntry
-+---------------------------------------------------------------------*/
-AP4_RtpHintSampleEntry::AP4_RtpHintSampleEntry(AP4_UI16 hint_track_version,
- AP4_UI16 highest_compatible_version,
- AP4_UI32 max_packet_size,
- AP4_UI32 timescale):
- AP4_SampleEntry(AP4_ATOM_TYPE_RTP),
- m_HintTrackVersion(hint_track_version),
- m_HighestCompatibleVersion(highest_compatible_version),
- m_MaxPacketSize(max_packet_size)
-{
- // build an atom for timescale
- AddChild(new AP4_TimsAtom(timescale));
-}
-
-/*----------------------------------------------------------------------
-| AP4_RtpHintSampleEntry::AP4_RtpHintSampleEntry
-+---------------------------------------------------------------------*/
-AP4_RtpHintSampleEntry::AP4_RtpHintSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory):
- AP4_SampleEntry(AP4_ATOM_TYPE_RTP, size)
-{
- // read fields
- AP4_Size fields_size = GetFieldsSize();
- ReadFields(stream);
-
- // read children atoms (ex: esds and maybe others)
- ReadChildren(atom_factory, stream, size-AP4_ATOM_HEADER_SIZE-fields_size);
-}
-
-/*----------------------------------------------------------------------
-| AP4_RtpHintSampleEntry::~AP4_RtpHintSampleEntry
-+---------------------------------------------------------------------*/
-AP4_RtpHintSampleEntry::~AP4_RtpHintSampleEntry()
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_RtpHintSampleEntry::GetFieldsSize
-+---------------------------------------------------------------------*/
-AP4_Size
-AP4_RtpHintSampleEntry::GetFieldsSize()
-{
- return AP4_SampleEntry::GetFieldsSize()+8;
-}
-
-/*----------------------------------------------------------------------
-| AP4_RtpHintSampleEntry::ReadFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_RtpHintSampleEntry::ReadFields(AP4_ByteStream& stream)
-{
- // sample entry
- AP4_Result result = AP4_SampleEntry::ReadFields(stream);
- if (result < 0) return result;
-
- // data
- result = stream.ReadUI16(m_HintTrackVersion);
- if (AP4_FAILED(result)) return result;
- result = stream.ReadUI16(m_HighestCompatibleVersion);
- if (AP4_FAILED(result)) return result;
- result = stream.ReadUI32(m_MaxPacketSize);
- if (AP4_FAILED(result)) return result;
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_RtpHintSampleEntry::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_RtpHintSampleEntry::WriteFields(AP4_ByteStream& stream)
-{
- // sample entry
- AP4_Result result = AP4_SampleEntry::WriteFields(stream);
- if (AP4_FAILED(result)) return result;
-
- // data
- result = stream.WriteUI16(m_HintTrackVersion);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI16(m_HighestCompatibleVersion);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI32(m_MaxPacketSize);
- if (AP4_FAILED(result)) return result;
-
- return result;
-}
-
-/*----------------------------------------------------------------------
-| AP4_RtpHintSampleEntry::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_RtpHintSampleEntry::InspectFields(AP4_AtomInspector& inspector)
-{
- // sample entry
- AP4_SampleEntry::InspectFields(inspector);
-
- // fields
- inspector.AddField("hint_track_version", m_HintTrackVersion);
- inspector.AddField("highest_compatible_version", m_HighestCompatibleVersion);
- inspector.AddField("max_packet_size", m_MaxPacketSize);
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_TextSampleEntry::AP4_TextSampleEntry
-+---------------------------------------------------------------------*/
-AP4_TextSampleEntry::AP4_TextSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory):
- AP4_SampleEntry(AP4_ATOM_TYPE_TEXT, size)
-{
- // read fields
- ReadFields(stream);
-}
-
-/*----------------------------------------------------------------------
-| AP4_TextSampleEntry::~AP4_TextSampleEntry
-+---------------------------------------------------------------------*/
-AP4_TextSampleEntry::~AP4_TextSampleEntry()
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_TextSampleEntry::ReadFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_TextSampleEntry::ReadFields(AP4_ByteStream& stream)
-{
- // sample entry
- AP4_Result result = AP4_SampleEntry::ReadFields(stream);
- if (result < 0) return result;
-
- // data
- result = stream.ReadUI32(m_Description.DisplayFlags);
- if (AP4_FAILED(result)) return result;
- result = stream.ReadUI32(m_Description.TextJustification);
- if (AP4_FAILED(result)) return result;
- result = stream.Read(&m_Description.BackgroundColor, 4);
- if (AP4_FAILED(result)) return result;
- result = stream.ReadUI16(m_Description.TextBox.Top);
- if (AP4_FAILED(result)) return result;
- result = stream.ReadUI16(m_Description.TextBox.Left);
- if (AP4_FAILED(result)) return result;
- result = stream.ReadUI16(m_Description.TextBox.Bottom);
- if (AP4_FAILED(result)) return result;
- result = stream.ReadUI16(m_Description.TextBox.Right);
- if (AP4_FAILED(result)) return result;
- result = stream.ReadUI16(m_Description.Style.StartChar);
- if (AP4_FAILED(result)) return result;
- result = stream.ReadUI16(m_Description.Style.EndChar);
- if (AP4_FAILED(result)) return result;
- result = stream.ReadUI16(m_Description.Style.Ascent);
- if (AP4_FAILED(result)) return result;
- result = stream.ReadUI16(m_Description.Style.Font.Id);
- if (AP4_FAILED(result)) return result;
- result = stream.ReadUI08(m_Description.Style.Font.Face);
- if (AP4_FAILED(result)) return result;
- result = stream.ReadUI08(m_Description.Style.Font.Size);
- if (AP4_FAILED(result)) return result;
- result = stream.Read(&m_Description.Style.Font.Color, 4);
- if (AP4_FAILED(result)) return result;
-
- // TODO: stream.ReadString(); -> m_Description.DefaultFontName
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_TextSampleEntry::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_TextSampleEntry::WriteFields(AP4_ByteStream& stream)
-{
- // sample entry
- AP4_Result result = AP4_SampleEntry::WriteFields(stream);
- if (AP4_FAILED(result)) return result;
-
- // TODO: data
-
- return result;
-}
-
-/*----------------------------------------------------------------------
-| AP4_TextSampleEntry::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_TextSampleEntry::InspectFields(AP4_AtomInspector& inspector)
-{
- // sample entry
- AP4_SampleEntry::InspectFields(inspector);
-
- // TODO: fields
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Tx3gSampleEntry::AP4_Tx3gSampleEntry
-+---------------------------------------------------------------------*/
-AP4_Tx3gSampleEntry::AP4_Tx3gSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory):
- AP4_SampleEntry(AP4_ATOM_TYPE_TX3G, size)
-{
- // read fields
- AP4_Size fields_size = GetFieldsSize();
- ReadFields(stream);
-
- // read children atoms (fdat? blnk?)
- ReadChildren(atom_factory, stream, size-AP4_ATOM_HEADER_SIZE-fields_size);
-}
-
-/*----------------------------------------------------------------------
-| AP4_Tx3gSampleEntry::~AP4_Tx3gSampleEntry
-+---------------------------------------------------------------------*/
-AP4_Tx3gSampleEntry::~AP4_Tx3gSampleEntry()
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_Tx3gSampleEntry::GetFieldsSize
-+---------------------------------------------------------------------*/
-AP4_Size
-AP4_Tx3gSampleEntry::GetFieldsSize()
-{
- return AP4_SampleEntry::GetFieldsSize()+4+1+1+4+2+2+2+2+2+2+2+1+1+4;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Tx3gSampleEntry::ReadFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Tx3gSampleEntry::ReadFields(AP4_ByteStream& stream)
-{
- // sample entry
- AP4_Result result = AP4_SampleEntry::ReadFields(stream);
- if (result < 0) return result;
-
- // data
- result = stream.ReadUI32(m_Description.DisplayFlags);
- if (AP4_FAILED(result)) return result;
- result = stream.ReadUI08(m_Description.HorizontalJustification);
- if (AP4_FAILED(result)) return result;
- result = stream.ReadUI08(m_Description.VerticalJustification);
- if (AP4_FAILED(result)) return result;
- result = stream.Read(&m_Description.BackgroundColor, 4);
- if (AP4_FAILED(result)) return result;
- result = stream.ReadUI16(m_Description.TextBox.Top);
- if (AP4_FAILED(result)) return result;
- result = stream.ReadUI16(m_Description.TextBox.Left);
- if (AP4_FAILED(result)) return result;
- result = stream.ReadUI16(m_Description.TextBox.Bottom);
- if (AP4_FAILED(result)) return result;
- result = stream.ReadUI16(m_Description.TextBox.Right);
- if (AP4_FAILED(result)) return result;
- result = stream.ReadUI16(m_Description.Style.StartChar);
- if (AP4_FAILED(result)) return result;
- result = stream.ReadUI16(m_Description.Style.EndChar);
- if (AP4_FAILED(result)) return result;
- result = stream.ReadUI16(m_Description.Style.Font.Id);
- if (AP4_FAILED(result)) return result;
- result = stream.ReadUI08(m_Description.Style.Font.Face);
- if (AP4_FAILED(result)) return result;
- result = stream.ReadUI08(m_Description.Style.Font.Size);
- if (AP4_FAILED(result)) return result;
- result = stream.Read(&m_Description.Style.Font.Color, 4);
- if (AP4_FAILED(result)) return result;
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Tx3gSampleEntry::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Tx3gSampleEntry::WriteFields(AP4_ByteStream& stream)
-{
- // sample entry
- AP4_Result result = AP4_SampleEntry::WriteFields(stream);
- if (AP4_FAILED(result)) return result;
-
- // TODO: data
-
- return result;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Tx3gSampleEntry::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Tx3gSampleEntry::InspectFields(AP4_AtomInspector& inspector)
-{
- // sample entry
- AP4_SampleEntry::InspectFields(inspector);
-
- // TODO: fields
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Tx3gSampleEntry::GetFontNameById
-+---------------------------------------------------------------------*/
-
-AP4_Result
-AP4_Tx3gSampleEntry::GetFontNameById(AP4_Ordinal Id, AP4_String& Name)
-{
- if(AP4_FtabAtom* ftab = dynamic_cast<AP4_FtabAtom*>(GetChild(AP4_ATOM_TYPE_FTAB)))
- {
- AP4_Array<AP4_FtabAtom::AP4_Tx3gFontRecord> FontRecords = ftab->GetFontRecords();
-
- for(int i = 0, j = FontRecords.ItemCount(); i < j; i++)
- {
- if(Id == FontRecords[i].Id)
- {
- Name = FontRecords[i].Name;
- return AP4_SUCCESS;
- }
- }
- }
-
- return AP4_FAILURE;
-}
-
-static int freq[] = {48000, 44100, 32000, 0};
-static int channels[] = {2, 1, 2, 3, 3, 4, 4, 5};
-
-/*----------------------------------------------------------------------
-| AP4_AC3SampleEntry::AP4_AC3SampleEntry
-+---------------------------------------------------------------------*/
-AP4_AC3SampleEntry::AP4_AC3SampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
- AP4_AudioSampleEntry(AP4_ATOM_TYPE__AC3, size)
-{
-
- // read fields
- ReadFields(stream);
-
- AP4_Size fields_size = GetFieldsSize();
-
- // read children atoms (ex: esds and maybe others)
- ReadChildren(atom_factory, stream, size-AP4_ATOM_HEADER_SIZE-fields_size);
-}
-
-/*----------------------------------------------------------------------
-| AP4_AC3SampleEntry::ReadFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_AC3SampleEntry::ReadFields(AP4_ByteStream& stream)
-{
-
- AP4_AudioSampleEntry::ReadFields(stream);
-
- // SampleSize field from AudioSampleEntry shall be ignored
- m_SampleSize = 0;
-
- // AC3SpecificBox
-
- // BoxHeader.Size, BoxHeader.Type
- char junk[8];
- stream.Read(junk, 8);
-
- AP4_UI32 data;
- stream.ReadUI24(data);
-
- // fscod
- m_SampleRate = freq[(data>>22) & 0x3];
- m_SampleRate <<= 16;
-
- // acmod
- m_ChannelCount = channels[(data>>11) & 0x7] + ((data>>10) & 0x1);
-
- return AP4_SUCCESS;
-}
-
-AP4_Size
-AP4_AC3SampleEntry::GetFieldsSize()
-{
- return AP4_AudioSampleEntry::GetFieldsSize() + 11;
-}
-
-/*----------------------------------------------------------------------
-| AP4_EAC3SampleEntry::AP4_EAC3SampleEntry
-+---------------------------------------------------------------------*/
-AP4_EAC3SampleEntry::AP4_EAC3SampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
- AP4_AudioSampleEntry(AP4_ATOM_TYPE_EAC3, size, stream, atom_factory)
-{
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4SampleEntry.h b/src/thirdparty/Bento4/Core/Ap4SampleEntry.h
deleted file mode 100644
index 22fa0a673..000000000
--- a/src/thirdparty/Bento4/Core/Ap4SampleEntry.h
+++ /dev/null
@@ -1,453 +0,0 @@
-/*****************************************************************
-|
-| AP4 - sample entries
-|
-| Copyright 2002 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_SAMPLE_ENTRY_H_
-#define _AP4_SAMPLE_ENTRY_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4List.h"
-#include "Ap4Atom.h"
-#include "Ap4EsdsAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4ContainerAtom.h"
-
-/*----------------------------------------------------------------------
-| class references
-+---------------------------------------------------------------------*/
-class AP4_SampleDescription;
-
-/*----------------------------------------------------------------------
-| AP4_SampleEntry
-+---------------------------------------------------------------------*/
-class AP4_SampleEntry : public AP4_ContainerAtom
-{
- public:
- // methods
- AP4_SampleEntry(AP4_Atom::Type format, AP4_UI16 data_ref_index = 1);
- AP4_SampleEntry(AP4_Atom::Type format,
- AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory);
- AP4_UI16 GetDataReferenceIndex() { return m_DataReferenceIndex; }
- virtual AP4_Result Write(AP4_ByteStream& stream);
- virtual AP4_Result Inspect(AP4_AtomInspector& inspector);
- virtual AP4_SampleDescription* ToSampleDescription();
-
- // AP4_AtomParent methods
- virtual void OnChildChanged(AP4_Atom* child);
-
- protected:
- // constructor
- AP4_SampleEntry(AP4_Atom::Type format, AP4_Size size);
-
- // methods
- virtual AP4_Size GetFieldsSize();
- virtual AP4_Result ReadFields(AP4_ByteStream& stream);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
-
- // members
- AP4_UI08 m_Reserved1[6]; // = 0
- AP4_UI16 m_DataReferenceIndex;
-};
-
-/*----------------------------------------------------------------------
-| AP4_MpegSampleEntry
-+---------------------------------------------------------------------*/
-class AP4_MpegSampleEntry : public AP4_SampleEntry
-{
-protected:
- // constructor
- AP4_MpegSampleEntry(AP4_Atom::Type format);
- AP4_MpegSampleEntry(AP4_Atom::Type format, AP4_Size size);
- AP4_MpegSampleEntry(AP4_Atom::Type format,
- AP4_EsDescriptor* descriptor);
- AP4_MpegSampleEntry(AP4_Atom::Type format,
- AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory);
-
- // methods
- const AP4_DecoderConfigDescriptor* GetDecoderConfigDescriptor();
-};
-
-/*----------------------------------------------------------------------
-| AP4_Mp4sSampleEntry
-+---------------------------------------------------------------------*/
-class AP4_Mp4sSampleEntry : public AP4_MpegSampleEntry
-{
- public:
- // constructors
- AP4_Mp4sSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory);
- AP4_Mp4sSampleEntry(AP4_EsDescriptor* descriptor);
-
- // methods
- AP4_SampleDescription* ToSampleDescription();
-};
-
-/*----------------------------------------------------------------------
-| AP4_AudioSampleEntry
-+---------------------------------------------------------------------*/
-class AP4_AudioSampleEntry : public AP4_MpegSampleEntry
-{
- public:
- // methods
- AP4_AudioSampleEntry(AP4_Atom::Type format,
- AP4_EsDescriptor* descriptor,
- AP4_UI32 sample_rate,
- AP4_UI16 sample_size,
- AP4_UI16 channel_count);
- AP4_AudioSampleEntry(AP4_Atom::Type format,
- AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory);
- AP4_AudioSampleEntry(AP4_Atom::Type format,
- AP4_Size size);
-
- // accessors
- AP4_UI32 GetSampleRate();
-// AP4_UI16 GetSampleSize() { return m_SampleSize; }
- AP4_UI16 GetChannelCount();
-// mpc-hc custom code start
- AP4_UI32 GetSamplesPerPacket()
- {
- if (m_QtVersion == 2) {
- return m_QtV2LPCMFramesPerAudioPacket;
- }
- return m_QtV1SamplesPerPacket;
- }
- AP4_UI32 GetBytesPerFrame()
- {
- if (m_QtVersion == 2) {
- return m_QtV2BytesPerAudioPacket;
- }
- return m_QtV1BytesPerFrame;
- }
- AP4_UI16 GetSampleSize()
- {
- if (m_QtVersion == 1 && m_SampleSize == 16) {
- //QuickTime File Format Specification->Sound Sample Description (Version 1)->Bytes per packet
- return m_QtV1BytesPerPacket * 8;
- } else if (m_QtVersion == 2) {
- return m_QtV2BitsPerChannel;
- }
- return m_SampleSize;
- }
- AP4_UI16 GetEndian()
- {
- /*if (m_QtVersion == 2) {
- if (m_QtV2FormatSpecificFlags & 2) {
- return ENDIAN_BIG;
- } else {
- return ENDIAN_LITTLE;
- }
- }*/
- return m_Endian;
- }
- AP4_UI32 GetFormatSpecificFlags() { return m_QtV2FormatSpecificFlags; }
-
-#define ENDIAN_NOTSET -1
-#define ENDIAN_BIG 0
-#define ENDIAN_LITTLE 1
-
-// mpc-hc custom code end
-
- // methods
- AP4_SampleDescription* ToSampleDescription();
-
-protected:
- // methods
- virtual AP4_Size GetFieldsSize();
- virtual AP4_Result ReadFields(AP4_ByteStream& stream);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
-
- // members
- AP4_UI16 m_QtVersion; // 0, 1 or 2
- AP4_UI16 m_QtRevision; // 0
- AP4_UI32 m_QtVendor; // 0
- AP4_UI16 m_ChannelCount;
- AP4_UI16 m_SampleSize;
- AP4_UI16 m_QtCompressionId; // 0 or -2
- AP4_UI16 m_QtPacketSize; // always 0
- AP4_UI32 m_SampleRate; // 16.16 fixed point
- // Version == 1
- AP4_UI32 m_QtV1SamplesPerPacket;
- AP4_UI32 m_QtV1BytesPerPacket;
- AP4_UI32 m_QtV1BytesPerFrame;
- AP4_UI32 m_QtV1BytesPerSample;
- // Version == 2
- AP4_UI32 m_QtV2StructSize;
- double m_QtV2SampleRate64;
- AP4_UI32 m_QtV2ChannelCount;
- AP4_UI32 m_QtV2Reserved;
- AP4_UI32 m_QtV2BitsPerChannel;
- AP4_UI32 m_QtV2FormatSpecificFlags;
- AP4_UI32 m_QtV2BytesPerAudioPacket;
- AP4_UI32 m_QtV2LPCMFramesPerAudioPacket;
- AP4_DataBuffer m_QtV2Extension;
- // from 'enda' atom
- AP4_UI16 m_Endian;
-
-};
-
-/*----------------------------------------------------------------------
-| AP4_Mp4aSampleEntry
-+---------------------------------------------------------------------*/
-class AP4_Mp4aSampleEntry : public AP4_AudioSampleEntry
-{
- public:
- // constructors
- AP4_Mp4aSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory);
- AP4_Mp4aSampleEntry(AP4_UI32 sample_rate,
- AP4_UI16 sample_size,
- AP4_UI16 channel_count,
- AP4_EsDescriptor* descriptor);
-};
-
-/*----------------------------------------------------------------------
-| AP4_VisualSampleEntry
-+---------------------------------------------------------------------*/
-class AP4_VisualSampleEntry : public AP4_MpegSampleEntry
-{
- public:
- // methods
- AP4_VisualSampleEntry(AP4_Atom::Type format,
- AP4_EsDescriptor* descriptor,
- AP4_UI16 width,
- AP4_UI16 height,
- AP4_UI16 depth,
- const char* compressor_name);
- AP4_VisualSampleEntry(AP4_Atom::Type format,
- AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory);
-
- // accessors
- AP4_UI16 GetWidth() { return m_Width; }
- AP4_UI16 GetHeight() { return m_Height; }
- AP4_UI16 GetHorizResolution(){ return m_HorizResolution; }
- AP4_UI16 GetVertResolution() { return m_VertResolution; }
- AP4_UI16 GetDepth() { return m_Depth; }
- const char* GetCompressorName() { return m_CompressorName.c_str(); }
-
- // methods
- AP4_SampleDescription* ToSampleDescription();
-
-protected:
- // methods
- virtual AP4_Size GetFieldsSize();
- virtual AP4_Result ReadFields(AP4_ByteStream& stream);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
-
- //members
- AP4_UI16 m_Predefined1; // = 0
- AP4_UI16 m_Reserved2; // = 0
- AP4_UI08 m_Predefined2[12]; // = 0
- AP4_UI16 m_Width;
- AP4_UI16 m_Height;
- AP4_UI32 m_HorizResolution; // = 0x00480000 (72 dpi)
- AP4_UI32 m_VertResolution; // = 0x00480000 (72 dpi)
- AP4_UI32 m_Reserved3; // = 0
- AP4_UI16 m_FrameCount; // = 1
- AP4_String m_CompressorName;
- AP4_UI16 m_Depth; // = 0x0018
- AP4_UI16 m_Predefined3; // = 0xFFFF
-};
-
-/*----------------------------------------------------------------------
-| AP4_Mp4vSampleEntry
-+---------------------------------------------------------------------*/
-class AP4_Mp4vSampleEntry : public AP4_VisualSampleEntry
-{
- public:
- // constructors
- AP4_Mp4vSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory);
- AP4_Mp4vSampleEntry(AP4_UI16 width,
- AP4_UI16 height,
- AP4_UI16 depth,
- const char* compressor_name,
- AP4_EsDescriptor* descriptor);
-};
-
-/*----------------------------------------------------------------------
-| AP4_Avc1SampleEntry
-+---------------------------------------------------------------------*/
-class AP4_Avc1SampleEntry : public AP4_VisualSampleEntry
-{
-public:
- // constructors
- AP4_Avc1SampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory);
- AP4_Avc1SampleEntry(AP4_UI16 width,
- AP4_UI16 height,
- AP4_UI16 depth,
- const char* compressor_name,
- AP4_EsDescriptor* descriptor);
-};
-
-/*----------------------------------------------------------------------
-| AP4_RtpHintSampleEntry
-+---------------------------------------------------------------------*/
-class AP4_RtpHintSampleEntry : public AP4_SampleEntry
-{
-public:
- // methods
- AP4_RtpHintSampleEntry(AP4_UI16 hint_track_version,
- AP4_UI16 highest_compatible_version,
- AP4_UI32 max_packet_size,
- AP4_UI32 timescale);
- AP4_RtpHintSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory);
- virtual ~AP4_RtpHintSampleEntry();
-
-protected:
- // methods
- virtual AP4_Size GetFieldsSize();
- virtual AP4_Result ReadFields(AP4_ByteStream& stream);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
-
- // members
- AP4_UI16 m_HintTrackVersion;
- AP4_UI16 m_HighestCompatibleVersion;
- AP4_UI32 m_MaxPacketSize;
-};
-
-/*----------------------------------------------------------------------
-| AP4_TextSampleEntry
-+---------------------------------------------------------------------*/
-class AP4_TextSampleEntry : public AP4_SampleEntry
-{
-public:
- // methods
- AP4_TextSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory);
- virtual ~AP4_TextSampleEntry();
-
- struct AP4_TextDescription
- {
- AP4_UI32 DisplayFlags;
- AP4_UI32 TextJustification;
- AP4_UI32 BackgroundColor;
- struct {AP4_UI16 Top, Left, Bottom, Right;} TextBox;
- struct {AP4_UI16 StartChar, EndChar, Ascent; struct {AP4_UI16 Id; AP4_UI08 Face, Size; AP4_UI32 Color;} Font;} Style;
- AP4_String DefaultFontName;
- };
-
- const AP4_TextDescription& GetDescription() const { return m_Description; };
-
-protected:
- // methods
- virtual AP4_Result ReadFields(AP4_ByteStream& stream);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
-
- // members
- AP4_TextDescription m_Description;
-};
-
-/*----------------------------------------------------------------------
-| AP4_Tx3gSampleEntry
-+---------------------------------------------------------------------*/
-class AP4_Tx3gSampleEntry : public AP4_SampleEntry
-{
-public:
- // methods
- AP4_Tx3gSampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory);
- virtual ~AP4_Tx3gSampleEntry();
-
- struct AP4_Tx3gDescription
- {
- AP4_UI32 DisplayFlags;
- AP4_UI08 HorizontalJustification;
- AP4_UI08 VerticalJustification;
- AP4_UI32 BackgroundColor;
- struct {AP4_UI16 Top, Left, Bottom, Right;} TextBox;
- struct {AP4_UI16 StartChar, EndChar; struct {AP4_UI16 Id; AP4_UI08 Face, Size; AP4_UI32 Color;} Font;} Style;
- };
-
- const AP4_Tx3gDescription& GetDescription() const { return m_Description; };
-
- AP4_Result GetFontNameById(AP4_Ordinal Id, AP4_String& Name);
-
-protected:
- // methods
- virtual AP4_Size GetFieldsSize();
- virtual AP4_Result ReadFields(AP4_ByteStream& stream);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
-
- // members
- AP4_Tx3gDescription m_Description;
-};
-
-/*----------------------------------------------------------------------
-| AP4_AC3SampleEntry
-+---------------------------------------------------------------------*/
-class AP4_AC3SampleEntry : public AP4_AudioSampleEntry
-{
- public:
- // constructors
- AP4_AC3SampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory);
-
- AP4_Result ReadFields(AP4_ByteStream& stream);
- AP4_Size GetFieldsSize();
-};
-
-/*----------------------------------------------------------------------
-| AP4_EAC3SampleEntry
-+---------------------------------------------------------------------*/
-class AP4_EAC3SampleEntry : public AP4_AudioSampleEntry
-{
- public:
- // constructors
- AP4_EAC3SampleEntry(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory);
-};
-
-#endif // _AP4_SAMPLE_ENTRY_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4SampleTable.cpp b/src/thirdparty/Bento4/Core/Ap4SampleTable.cpp
deleted file mode 100644
index d5ac995da..000000000
--- a/src/thirdparty/Bento4/Core/Ap4SampleTable.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Sample Table Interface
-|
-| Copyright 2003-2004 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4SampleTable.h"
-#include "Ap4ContainerAtom.h"
-#include "Ap4StsdAtom.h"
-#include "Ap4StszAtom.h"
-#include "Ap4StscAtom.h"
-#include "Ap4StcoAtom.h"
-#include "Ap4SttsAtom.h"
-
-/*----------------------------------------------------------------------
-| AP4_SampleTable::GenerateStblAtom
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SampleTable::GenerateStblAtom(AP4_ContainerAtom*& stbl)
-{
- // create the stbl container
- stbl = new AP4_ContainerAtom(AP4_ATOM_TYPE_STBL);
-
- // create the stsd atom
- AP4_StsdAtom* stsd = new AP4_StsdAtom(this);
-
- // create the stsz atom
- AP4_StszAtom* stsz = new AP4_StszAtom();
-
- // create the stsc atom
- AP4_StscAtom* stsc = new AP4_StscAtom();
-
- // start chunk table
- AP4_Cardinal samples_in_chunk = 0;
- AP4_Offset current_chunk_offset = 0;
- AP4_Size current_chunk_size = 0;
- AP4_Array<AP4_UI32> chunk_offsets;
-
- // process all the samples
- AP4_Cardinal sample_count = GetSampleCount();
- for (AP4_Ordinal i=0; i<sample_count; i++) {
- AP4_Sample sample;
- GetSample(i, sample);
-
- // add an entry into the stsz atom
- stsz->AddEntry(sample.GetSize());
-
- // adjust the current chunk info
- current_chunk_size += sample.GetSize();
-
- // count the sample
- samples_in_chunk++;
- if (samples_in_chunk == 10) {
- // new chunk
- chunk_offsets.Append(current_chunk_offset);
- stsc->AddEntry(1, 10, 1);
- samples_in_chunk = 0;
-
- // adjust the chunk offset
- current_chunk_offset += current_chunk_size;
- current_chunk_size = 0;
- }
- }
-
- // process any unfinished chunk
- if (samples_in_chunk != 0) {
- // new chunk
- chunk_offsets.Append(current_chunk_offset);
- stsc->AddEntry(1, samples_in_chunk, 1);
- }
-
- // create the stco atom
- AP4_StcoAtom* stco = new AP4_StcoAtom(&chunk_offsets[0],
- chunk_offsets.ItemCount());
-
- // create the stts atom (for now, we assume sample of equal duration)
- AP4_SttsAtom* stts = new AP4_SttsAtom();
- stts->AddEntry(sample_count, 1000); // FIXME
-
- // attach the children of stbl
- stbl->AddChild(stsd);
- stbl->AddChild(stsz);
- stbl->AddChild(stsc);
- stbl->AddChild(stco);
- stbl->AddChild(stts);
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4SampleTable.h b/src/thirdparty/Bento4/Core/Ap4SampleTable.h
deleted file mode 100644
index 55f97a1b6..000000000
--- a/src/thirdparty/Bento4/Core/Ap4SampleTable.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Sample Table Interface
-|
-| Copyright 2003-2004 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_SAMPLE_TABLE_H_
-#define _AP4_SAMPLE_TABLE_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4Sample.h"
-#include "Ap4Atom.h"
-#include "Ap4ContainerAtom.h"
-#include "Ap4SampleDescription.h"
-
-/*----------------------------------------------------------------------
-| AP4_SampleTable
-+---------------------------------------------------------------------*/
-class AP4_SampleTable {
-public:
- // constructors and destructor
- virtual ~AP4_SampleTable() {};
-
- // methods
- virtual AP4_Result GenerateStblAtom(AP4_ContainerAtom*& stbl);
- virtual AP4_Result GetSample(AP4_Ordinal index, AP4_Sample& sample) = 0;
- virtual AP4_Cardinal GetSampleCount() = 0;
- virtual AP4_Cardinal GetSampleDescriptionCount() = 0;
- virtual AP4_SampleDescription* GetSampleDescription(AP4_Ordinal index) = 0;
- virtual AP4_Result GetSampleIndexForTimeStamp(AP4_TimeStamp ts,
- AP4_Ordinal& index) = 0;
-};
-
-#endif // _AP4_SAMPLE_TABLE_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4SchmAtom.cpp b/src/thirdparty/Bento4/Core/Ap4SchmAtom.cpp
deleted file mode 100644
index e68b2e287..000000000
--- a/src/thirdparty/Bento4/Core/Ap4SchmAtom.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/*****************************************************************
-|
-| AP4 - schm Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4SchmAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_SchmAtom::AP4_SchmAtom
-+---------------------------------------------------------------------*/
-AP4_SchmAtom::AP4_SchmAtom(AP4_UI32 scheme_type,
- AP4_UI32 scheme_version,
- const char* scheme_uri) :
- AP4_Atom(AP4_ATOM_TYPE_SCHM, AP4_FULL_ATOM_HEADER_SIZE+8, true),
- m_SchemeType(scheme_type),
- m_SchemeVersion(scheme_version)
-{
- if (scheme_uri) {
- m_SchemeUri = scheme_uri;
- m_Flags = 1;
- m_Size += m_SchemeUri.length()+1;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_SchmAtom::AP4_SchmAtom
-+---------------------------------------------------------------------*/
-AP4_SchmAtom::AP4_SchmAtom(AP4_Size size, AP4_ByteStream& stream) :
- AP4_Atom(AP4_ATOM_TYPE_SCHM, size, true, stream)
-{
- stream.ReadUI32(m_SchemeType);
- stream.ReadUI32(m_SchemeVersion);
- if (m_Flags & 1) {
- int str_size = size-(AP4_FULL_ATOM_HEADER_SIZE+8);
- if (str_size > 0) {
- char* str = new char[str_size];
- stream.Read(str, str_size);
- str[str_size-1] = '\0'; // force null-termination
- m_SchemeUri = str;
- delete[] str;
- }
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_SchmAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SchmAtom::WriteFields(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- // scheme type
- result = stream.WriteUI32(m_SchemeType);
- if (AP4_FAILED(result)) return result;
-
- // scheme version
- result = stream.WriteUI32(m_SchemeVersion);
- if (AP4_FAILED(result)) return result;
-
- // uri if needed
- if (m_Flags & 1) {
- result = stream.Write(m_SchemeUri.c_str(), m_SchemeUri.length()+1);
- if (AP4_FAILED(result)) return result;
-
- // pad with zeros if necessary
- AP4_Size padding = m_Size-(AP4_FULL_ATOM_HEADER_SIZE+8+m_SchemeUri.length()+1);
- while (padding--) {
- stream.WriteUI08(0);
- }
- }
-
- return result;
-}
-
-/*----------------------------------------------------------------------
-| AP4_SchmAtom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SchmAtom::InspectFields(AP4_AtomInspector& inspector)
-{
- char st[5];
- AP4_FormatFourChars(st, m_SchemeType);
- inspector.AddField("scheme_type", st);
- inspector.AddField("scheme_version", m_SchemeVersion);
- if (m_Flags & 1) {
- inspector.AddField("scheme_uri", m_SchemeUri.c_str());
- }
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4SchmAtom.h b/src/thirdparty/Bento4/Core/Ap4SchmAtom.h
deleted file mode 100644
index d5149fa1c..000000000
--- a/src/thirdparty/Bento4/Core/Ap4SchmAtom.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*****************************************************************
-|
-| AP4 - schm Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_SCHM_ATOM_H_
-#define _AP4_SCHM_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4Array.h"
-#include "Ap4Atom.h"
-
-/*----------------------------------------------------------------------
-| AP4_SchmAtom
-+---------------------------------------------------------------------*/
-class AP4_SchmAtom : public AP4_Atom
-{
- public:
- // constructors
- AP4_SchmAtom(AP4_UI32 scheme_type,
- AP4_UI32 scheme_version,
- const char* scheme_uri = NULL);
- AP4_SchmAtom(AP4_Size size, AP4_ByteStream& stream);
-
- // methods
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
- // accessors
- AP4_UI32 GetSchemeType() { return m_SchemeType; }
- AP4_UI32 GetSchemeVersion() { return m_SchemeVersion; }
- AP4_String& GetSchemeUri() { return m_SchemeUri; }
-
- private:
- // members
- AP4_UI32 m_SchemeType;
- AP4_UI32 m_SchemeVersion;
- AP4_String m_SchemeUri;
-};
-
-#endif // _AP4_SCHM_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4SdpAtom.cpp b/src/thirdparty/Bento4/Core/Ap4SdpAtom.cpp
deleted file mode 100644
index 26d0e0410..000000000
--- a/src/thirdparty/Bento4/Core/Ap4SdpAtom.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/*****************************************************************
-|
-| AP4 - sdp Atoms
-|
-| Copyright 2002-2005 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4SdpAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4Utils.h"
-
-
-/*----------------------------------------------------------------------
-| AP4_SdpAtom::AP4_SdpAtom
-+---------------------------------------------------------------------*/
-AP4_SdpAtom::AP4_SdpAtom(const char* sdp_text) :
- AP4_Atom(AP4_ATOM_TYPE_SDP, AP4_ATOM_HEADER_SIZE, false),
- m_SdpText(sdp_text)
-{
- m_Size += m_SdpText.length()+1;
-}
-
-/*----------------------------------------------------------------------
-| AP4_SdpAtom::AP4_SdpAtom
-+---------------------------------------------------------------------*/
-AP4_SdpAtom::AP4_SdpAtom(AP4_Size size, AP4_ByteStream& stream) :
- AP4_Atom(AP4_ATOM_TYPE_SDP, size, false, stream)
-{
- // sdptext
- AP4_Size str_size = size-AP4_ATOM_HEADER_SIZE;
- if (str_size > 0) {
- char* str = new char[str_size+1];
- stream.Read(str, str_size);
- str[str_size] = '\0'; // force null-termination
- m_SdpText = str;
- delete[] str;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_SdpAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SdpAtom::WriteFields(AP4_ByteStream& stream)
-{
- // sdptext
- AP4_Result result = stream.Write(m_SdpText.c_str(), m_SdpText.length());
- if (AP4_FAILED(result)) return result;
-
- // pad with zeros if necessary
- AP4_Size padding = m_Size-(AP4_ATOM_HEADER_SIZE+m_SdpText.length());
- while (padding--) stream.WriteUI08(0);
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_SdpAtom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SdpAtom::InspectFields(AP4_AtomInspector& inspector)
-{
- inspector.AddField("sdp_text", m_SdpText.c_str());
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_SdpAtom::GetSdpText
-+---------------------------------------------------------------------*/
-const AP4_String&
-AP4_SdpAtom::GetSdpText() const
-{
- return m_SdpText;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4SdpAtom.h b/src/thirdparty/Bento4/Core/Ap4SdpAtom.h
deleted file mode 100644
index 5ed54c9c2..000000000
--- a/src/thirdparty/Bento4/Core/Ap4SdpAtom.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*****************************************************************
-|
-| AP4 - sdp Atoms
-|
-| Copyright 2002-2005 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-#ifndef _AP4_SDP_ATOM_H_
-#define _AP4_SDP_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4List.h"
-#include "Ap4Atom.h"
-#include "Ap4DataBuffer.h"
-
-/*----------------------------------------------------------------------
-| AP4_SdpAtom
-+---------------------------------------------------------------------*/
-class AP4_SdpAtom : public AP4_Atom
-{
-public:
- // methods
- AP4_SdpAtom(AP4_Size size, AP4_ByteStream& stream);
- AP4_SdpAtom(const char* sdp_text);
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
- // accessors
- const AP4_String& GetSdpText() const;
-
-private:
- // members
- AP4_String m_SdpText;
-};
-
-#endif // _AP4_SDP_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4SmhdAtom.cpp b/src/thirdparty/Bento4/Core/Ap4SmhdAtom.cpp
deleted file mode 100644
index 6aa5f7b58..000000000
--- a/src/thirdparty/Bento4/Core/Ap4SmhdAtom.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/*****************************************************************
-|
-| AP4 - smhd Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4SmhdAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_SmhdAtom::AP4_SmhdAtom
-+---------------------------------------------------------------------*/
-AP4_SmhdAtom::AP4_SmhdAtom(AP4_UI16 balance) :
- AP4_Atom(AP4_ATOM_TYPE_SMHD, 4+AP4_FULL_ATOM_HEADER_SIZE, true),
- m_Balance(balance)
-{
- m_Reserved = 0;
-}
-
-/*----------------------------------------------------------------------
-| AP4_SmhdAtom::AP4_SmhdAtom
-+---------------------------------------------------------------------*/
-AP4_SmhdAtom::AP4_SmhdAtom(AP4_Size size, AP4_ByteStream& stream) :
- AP4_Atom(AP4_ATOM_TYPE_SMHD, size, true, stream)
-{
- stream.ReadUI16(m_Balance);
- stream.ReadUI16(m_Reserved);
-}
-
-/*----------------------------------------------------------------------
-| AP4_SmhdAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SmhdAtom::WriteFields(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- // balance
- result = stream.WriteUI16(m_Balance);
- if (AP4_FAILED(result)) return result;
-
- // reserved
- result = stream.WriteUI16(m_Reserved);
- if (AP4_FAILED(result)) return result;
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_SmhdAtom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SmhdAtom::InspectFields(AP4_AtomInspector& inspector)
-{
- inspector.AddField("balance", m_Balance);
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4SmhdAtom.h b/src/thirdparty/Bento4/Core/Ap4SmhdAtom.h
deleted file mode 100644
index eaabb8458..000000000
--- a/src/thirdparty/Bento4/Core/Ap4SmhdAtom.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*****************************************************************
-|
-| AP4 - smhd Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-#ifndef _AP4_SMHD_ATOM_H_
-#define _AP4_SMHD_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4Atom.h"
-
-/*----------------------------------------------------------------------
-| AP4_SmhdAtom
-+---------------------------------------------------------------------*/
-class AP4_SmhdAtom : public AP4_Atom
-{
-public:
- // methods
- AP4_SmhdAtom(AP4_UI16 balance);
- AP4_SmhdAtom(AP4_Size size, AP4_ByteStream& stream);
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
-private:
- // members
- AP4_UI16 m_Balance;
- AP4_UI16 m_Reserved;
-};
-
-#endif // _AP4_SMHD_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4StcoAtom.cpp b/src/thirdparty/Bento4/Core/Ap4StcoAtom.cpp
deleted file mode 100644
index 3e6a96bc9..000000000
--- a/src/thirdparty/Bento4/Core/Ap4StcoAtom.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-/*****************************************************************
-|
-| AP4 - stco Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4StcoAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_StcoAtom::AP4_StcoAtom
-+---------------------------------------------------------------------*/
-AP4_StcoAtom::AP4_StcoAtom(AP4_UI32* entries, AP4_UI32 entry_count) :
-AP4_Atom(AP4_ATOM_TYPE_STCO,
- AP4_FULL_ATOM_HEADER_SIZE+4+entry_count*4,
- true),
- m_Entries(new AP4_UI32[entry_count]),
- m_EntryCount(entry_count)
-{
- memcpy(m_Entries, entries, m_EntryCount*4);
-}
-
-/*----------------------------------------------------------------------
-| AP4_StcoAtom::AP4_StcoAtom
-+---------------------------------------------------------------------*/
-AP4_StcoAtom::AP4_StcoAtom(AP4_Size size, AP4_ByteStream& stream) :
- AP4_Atom(AP4_ATOM_TYPE_STCO, size, true, stream)
-{
- stream.ReadUI32(m_EntryCount);
- if (m_EntryCount > (size-AP4_FULL_ATOM_HEADER_SIZE-4)/4) {
- m_EntryCount = (size-AP4_FULL_ATOM_HEADER_SIZE-4)/4;
- }
- m_Entries = new AP4_UI32[m_EntryCount];
- for (AP4_Ordinal i=0; i<m_EntryCount; i++) {
- stream.ReadUI32(m_Entries[i]);
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_StcoAtom::~AP4_StcoAtom
-+---------------------------------------------------------------------*/
-AP4_StcoAtom::~AP4_StcoAtom()
-{
- delete[] m_Entries;
-}
-
-/*----------------------------------------------------------------------
-| AP4_StcoAtom::GetChunkOffset
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_StcoAtom::GetChunkOffset(AP4_Ordinal chunk, AP4_Offset& chunk_offset)
-{
- // check the bounds
- if (chunk > m_EntryCount || chunk == 0) {
- return AP4_ERROR_OUT_OF_RANGE;
- }
-
- // get the chunk offset
- chunk_offset = m_Entries[chunk - 1]; // m_Entries is zero index based
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_StcoAtom::SetChunkOffset
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_StcoAtom::SetChunkOffset(AP4_Ordinal chunk, AP4_Offset chunk_offset)
-{
- // check the bounds
- if (chunk > m_EntryCount || chunk == 0) {
- return AP4_ERROR_OUT_OF_RANGE;
- }
-
- // get the chunk offset
- m_Entries[chunk - 1] = chunk_offset; // m_Entries is zero index based
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_StcoAtom::AdjustChunkOffsets
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_StcoAtom::AdjustChunkOffsets(AP4_Offset offset)
-{
- for (AP4_Ordinal i=0; i<m_EntryCount; i++) {
- m_Entries[i] += offset;
- }
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_StcoAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_StcoAtom::WriteFields(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- // entry count
- result = stream.WriteUI32(m_EntryCount);
- if (AP4_FAILED(result)) return result;
-
- // entries
- for (AP4_Ordinal i=0; i<m_EntryCount; i++) {
- result = stream.WriteUI32(m_Entries[i]);
- if (AP4_FAILED(result)) return result;
- }
-
- return result;
-}
-
-/*----------------------------------------------------------------------
-| AP4_StcoAtom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_StcoAtom::InspectFields(AP4_AtomInspector& inspector)
-{
- inspector.AddField("entry_count", m_EntryCount);
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4StcoAtom.h b/src/thirdparty/Bento4/Core/Ap4StcoAtom.h
deleted file mode 100644
index 7d34c932f..000000000
--- a/src/thirdparty/Bento4/Core/Ap4StcoAtom.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*****************************************************************
-|
-| AP4 - stco Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_STCO_ATOM_H_
-#define _AP4_STCO_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4Array.h"
-#include "Ap4Atom.h"
-
-/*----------------------------------------------------------------------
-| AP4_StcoAtom
-+---------------------------------------------------------------------*/
-class AP4_StcoAtom : public AP4_Atom
-{
- public:
- // methods
- AP4_StcoAtom(AP4_UI32* offsets, AP4_UI32 offset_count);
- AP4_StcoAtom(AP4_Size size, AP4_ByteStream& stream);
- ~AP4_StcoAtom();
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- AP4_Cardinal GetChunkCount() { return m_EntryCount; }
- AP4_Result GetChunkOffset(AP4_Ordinal chunk, AP4_Offset& chunk_offset);
- AP4_Result SetChunkOffset(AP4_Ordinal chunk, AP4_Offset chunk_offset);
- AP4_Result AdjustChunkOffsets(AP4_Offset offset);
-
- private:
- AP4_UI32* m_Entries;
- AP4_UI32 m_EntryCount;
-};
-
-#endif // _AP4_STCO_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4StscAtom.cpp b/src/thirdparty/Bento4/Core/Ap4StscAtom.cpp
deleted file mode 100644
index ce3101f02..000000000
--- a/src/thirdparty/Bento4/Core/Ap4StscAtom.cpp
+++ /dev/null
@@ -1,224 +0,0 @@
-/*****************************************************************
-|
-| AP4 - stsc Atoms
-|
-| Copyright 2002-2005 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4StscAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_StscAtom::AP4_StscAtom
-+---------------------------------------------------------------------*/
-AP4_StscAtom::AP4_StscAtom() :
- AP4_Atom(AP4_ATOM_TYPE_STSC, 4+AP4_FULL_ATOM_HEADER_SIZE, true),
- m_CachedChunkGroup(0)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_StscAtom::AP4_StscAtom
-+---------------------------------------------------------------------*/
-AP4_StscAtom::AP4_StscAtom(AP4_Size size, AP4_ByteStream& stream) :
- AP4_Atom(AP4_ATOM_TYPE_STSC, size, true, stream),
- m_CachedChunkGroup(0)
-{
- AP4_UI32 first_sample = 1;
- AP4_UI32 entry_count;
- stream.ReadUI32(entry_count);
- while (entry_count--) {
- AP4_UI32 first_chunk;
- AP4_UI32 samples_per_chunk;
- AP4_UI32 sample_description_index;
- if (stream.ReadUI32(first_chunk) == AP4_SUCCESS &&
- stream.ReadUI32(samples_per_chunk) == AP4_SUCCESS &&
- stream.ReadUI32(sample_description_index) == AP4_SUCCESS) {
- if (m_Entries.ItemCount() != 0) {
- AP4_Ordinal prev = m_Entries.ItemCount()-1;
- m_Entries[prev].m_ChunkCount =
- first_chunk-m_Entries[prev].m_FirstChunk;
- first_sample +=
- m_Entries[prev].m_ChunkCount *
- m_Entries[prev].m_SamplesPerChunk;
- }
- m_Entries.Append(AP4_StscTableEntry(first_chunk,
- first_sample,
- samples_per_chunk,
- sample_description_index));
- }
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_StscAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_StscAtom::WriteFields(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- // entry count
- AP4_Cardinal entry_count = m_Entries.ItemCount();
- result = stream.WriteUI32(entry_count);
-
- // entries
- for (AP4_Ordinal i=0; i<entry_count; i++) {
- stream.WriteUI32(m_Entries[i].m_FirstChunk);
- if (AP4_FAILED(result)) return result;
- stream.WriteUI32(m_Entries[i].m_SamplesPerChunk);
- if (AP4_FAILED(result)) return result;
- stream.WriteUI32(m_Entries[i].m_SampleDescriptionIndex);
- if (AP4_FAILED(result)) return result;
- }
-
- return result;
-}
-
-/*----------------------------------------------------------------------
-| AP4_StscAtom::AddEntry
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_StscAtom::AddEntry(AP4_Cardinal chunk_count,
- AP4_Cardinal samples_per_chunk,
- AP4_Ordinal sample_description_index)
-{
- AP4_Ordinal first_chunk;
- AP4_Ordinal first_sample;
- AP4_Cardinal entry_count = m_Entries.ItemCount();
- if (entry_count == 0) {
- // first entry
- first_chunk = 1;
- first_sample = 1;
- } else {
- first_chunk = m_Entries[entry_count-1].m_FirstChunk+
- m_Entries[entry_count-1].m_ChunkCount;
- first_sample = m_Entries[entry_count-1].m_FirstSample+
- m_Entries[entry_count-1].m_ChunkCount*
- m_Entries[entry_count-1].m_SamplesPerChunk;
- }
- m_Entries.Append(AP4_StscTableEntry(first_chunk, first_sample, chunk_count, samples_per_chunk, sample_description_index));
-
- // update the atom size
- m_Size += 12;
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_StscAtom::GetChunkForSample
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_StscAtom::GetChunkForSample(AP4_Ordinal sample,
- AP4_Ordinal& chunk,
- AP4_Ordinal& skip,
- AP4_Ordinal& sample_description)
-{
- // preconditions
- AP4_ASSERT(sample > 0);
-
- // decide whether to start the search from the cached index
- // or from the start
- AP4_Ordinal group;
- if (m_CachedChunkGroup < m_Entries.ItemCount() &&
- m_Entries[m_CachedChunkGroup].m_FirstSample <= sample) {
- group = m_CachedChunkGroup;
- } else {
- group = 0;
- }
-
- // find which group of chunk contains this one
- while (group < m_Entries.ItemCount()) {
- AP4_Cardinal sample_count =
- m_Entries[group].m_ChunkCount*m_Entries[group].m_SamplesPerChunk;
- if (sample_count == 0) {
- // unlimited samples in this group (last group)
- if (m_Entries[group].m_FirstSample > sample) {
- // something is wrong
- return AP4_ERROR_INVALID_FORMAT;
- }
- } else {
- // normal group
- if (m_Entries[group].m_FirstSample + sample_count <= sample) {
- // the sample is not in this group
- group++;
- continue;
- }
- }
-
- // the sample is in this group
- if (m_Entries[group].m_SamplesPerChunk == 0) {
- // something is wrong
- return AP4_ERROR_INVALID_FORMAT;
- }
- unsigned int chunk_offset =
- ((sample-m_Entries[group].m_FirstSample) /
- m_Entries[group].m_SamplesPerChunk);
- chunk = m_Entries[group].m_FirstChunk + chunk_offset;
- skip = sample -
- (m_Entries[group].m_FirstSample +
- m_Entries[group].m_SamplesPerChunk*chunk_offset);
- sample_description = m_Entries[group].m_SampleDescriptionIndex;
-
- // cache the result (to accelerate finding the right group
- // next time around
- m_CachedChunkGroup = group;
-
- return AP4_SUCCESS;
- }
-
- // chunk not found
- chunk = 0;
- skip = 0;
- sample_description = 0;
- return AP4_ERROR_OUT_OF_RANGE;
-}
-
-/*----------------------------------------------------------------------
-| AP4_StscAtom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_StscAtom::InspectFields(AP4_AtomInspector& inspector)
-{
- inspector.AddField("entry_count", m_Entries.ItemCount());
-
- // dump table entries
- //for (unsigned int i=0; i<m_Entries.GetItemCount(); i++) {
- // char dump[256];
- // sprintf(dump, " f=%ld, spc=%ld, sdi=%ld\n",
- // m_Entries[i].m_FirstChunk,
- // m_Entries[i].m_SamplesPerChunk,
- // m_Entries[i].m_SampleDescriptionIndex);
- // stream.WriteString(prefix);
- // stream.WriteString(dump);
- //}
-
- return AP4_SUCCESS;
-}
-
diff --git a/src/thirdparty/Bento4/Core/Ap4StscAtom.h b/src/thirdparty/Bento4/Core/Ap4StscAtom.h
deleted file mode 100644
index 4d5a0d449..000000000
--- a/src/thirdparty/Bento4/Core/Ap4StscAtom.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*****************************************************************
-|
-| AP4 - stsc Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_STSC_ATOM_H_
-#define _AP4_STSC_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4Array.h"
-#include "Ap4Atom.h"
-
-/*----------------------------------------------------------------------
-| AP4_StscTableEntry
-+---------------------------------------------------------------------*/
-class AP4_StscTableEntry {
- public:
- AP4_StscTableEntry() :
- m_FirstChunk(0),
- m_FirstSample(0),
- m_ChunkCount(0),
- m_SamplesPerChunk(0),
- m_SampleDescriptionIndex(0) {}
- AP4_StscTableEntry(AP4_Ordinal first_chunk,
- AP4_Ordinal first_sample,
- AP4_Cardinal samples_per_chunk,
- AP4_Ordinal sample_description_index) :
- m_FirstChunk(first_chunk),
- m_FirstSample(first_sample),
- m_ChunkCount(0),
- m_SamplesPerChunk(samples_per_chunk),
- m_SampleDescriptionIndex(sample_description_index) {}
- AP4_StscTableEntry(AP4_Ordinal first_chunk,
- AP4_Ordinal first_sample,
- AP4_Cardinal chunk_count,
- AP4_Cardinal samples_per_chunk,
- AP4_Ordinal sample_description_index) :
- m_FirstChunk(first_chunk),
- m_FirstSample(first_sample),
- m_ChunkCount(chunk_count),
- m_SamplesPerChunk(samples_per_chunk),
- m_SampleDescriptionIndex(sample_description_index) {}
- AP4_Ordinal m_FirstChunk;
- AP4_Ordinal m_FirstSample; // computed (not in file)
- AP4_Cardinal m_ChunkCount; // computed (not in file)
- AP4_Cardinal m_SamplesPerChunk;
- AP4_Ordinal m_SampleDescriptionIndex;
-};
-
-/*----------------------------------------------------------------------
-| AP4_StscAtom
-+---------------------------------------------------------------------*/
-class AP4_StscAtom : public AP4_Atom
-{
- public:
- // methods
- AP4_StscAtom();
- AP4_StscAtom(AP4_Size size, AP4_ByteStream& stream);
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- virtual AP4_Result GetChunkForSample(AP4_Ordinal sample,
- AP4_Ordinal& chunk,
- AP4_Ordinal& skip,
- AP4_Ordinal& sample_description);
- virtual AP4_Result AddEntry(AP4_Cardinal chunk_count,
- AP4_Cardinal samples_per_chunk,
- AP4_Ordinal sample_description_index);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
- // FIXME
- friend class AP4_AtomSampleTable;
-
- private:
- // data
- AP4_Array<AP4_StscTableEntry> m_Entries;
- AP4_Ordinal m_CachedChunkGroup;
-};
-
-#endif // _AP4_STSC_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4StsdAtom.cpp b/src/thirdparty/Bento4/Core/Ap4StsdAtom.cpp
deleted file mode 100644
index 74201486f..000000000
--- a/src/thirdparty/Bento4/Core/Ap4StsdAtom.cpp
+++ /dev/null
@@ -1,196 +0,0 @@
-/*****************************************************************
-|
-| AP4 - stsd Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4StsdAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4Utils.h"
-#include "Ap4SampleEntry.h"
-#include "Ap4SampleTable.h"
-
-/*----------------------------------------------------------------------
-| AP4_StsdAtom::AP4_StsdAtom
-+---------------------------------------------------------------------*/
-AP4_StsdAtom::AP4_StsdAtom(AP4_SampleTable* sample_table) :
- AP4_ContainerAtom(AP4_ATOM_TYPE_STSD, 4+AP4_FULL_ATOM_HEADER_SIZE, true)
-{
- AP4_Cardinal sample_description_count = sample_table->GetSampleDescriptionCount();
- m_SampleDescriptions.EnsureCapacity(sample_description_count);
- for (AP4_Ordinal i=0; i<sample_description_count; i++) {
- // clear the cache entry
- m_SampleDescriptions.Append(NULL);
-
- // create an entry for the description
- AP4_SampleDescription* sample_description = sample_table->GetSampleDescription(i);
- AP4_Atom* entry = sample_description->ToAtom();
- m_Children.Add(entry);
-
- // update the size
- m_Size += entry->GetSize();
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_StsdAtom::AP4_StsdAtom
-+---------------------------------------------------------------------*/
-AP4_StsdAtom::AP4_StsdAtom(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
- AP4_ContainerAtom(AP4_ATOM_TYPE_STSD, size, true, stream)
-{
- // read the number of entries
- AP4_UI32 entry_count;
- stream.ReadUI32(entry_count);
-
- // read all entries
- AP4_Size bytes_available = size-AP4_FULL_ATOM_HEADER_SIZE-4;
-
- m_Data.SetDataSize(bytes_available);
- stream.Read(m_Data.UseData(), m_Data.GetDataSize());
-
- AP4_ByteStream* s = new AP4_MemoryByteStream(m_Data.UseData(), m_Data.GetDataSize());
- for (unsigned int i=0; i<entry_count; i++) {
- AP4_Atom* atom;
- if (AP4_SUCCEEDED(atom_factory.CreateAtomFromStream(*s,
- bytes_available,
- atom,
- this))) {
- atom->SetParent(this);
- m_Children.Add(atom);
- }
- }
- s->Release();
-
- // initialize the sample description cache
- m_SampleDescriptions.EnsureCapacity(m_Children.ItemCount());
- for (AP4_Ordinal i=0; i<m_Children.ItemCount(); i++) {
- m_SampleDescriptions.Append(NULL);
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_StsdAtom::~AP4_StsdAtom
-+---------------------------------------------------------------------*/
-AP4_StsdAtom::~AP4_StsdAtom()
-{
- for (AP4_Ordinal i=0; i<m_SampleDescriptions.ItemCount(); i++) {
- delete m_SampleDescriptions[i];
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_StsdAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_StsdAtom::WriteFields(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- // entry count
- result = stream.WriteUI32(m_Children.ItemCount());
- if (AP4_FAILED(result)) return result;
-
- // entries
- return m_Children.Apply(AP4_AtomListWriter(stream));
-}
-
-/*----------------------------------------------------------------------
-| AP4_StsdAtom::OnChildChanged
-+---------------------------------------------------------------------*/
-void
-AP4_StsdAtom::OnChildChanged(AP4_Atom*)
-{
- // remcompute our size
- m_Size = GetHeaderSize()+4;
- m_Children.Apply(AP4_AtomSizeAdder(m_Size));
-
- // update our parent
- if (m_Parent) m_Parent->OnChildChanged(this);
-}
-
-/*----------------------------------------------------------------------
-| AP4_StsdAtom::GetSampleDescription
-+---------------------------------------------------------------------*/
-AP4_SampleDescription*
-AP4_StsdAtom::GetSampleDescription(AP4_Ordinal index)
-{
- // check index
- if (index >= m_Children.ItemCount()) return NULL;
-
- // return the description if we already have it in the internal table
- if (m_SampleDescriptions[index]) return m_SampleDescriptions[index];
-
- // create and cache a sample description for this entry
- AP4_Atom* entry;
- m_Children.Get(index, entry);
- AP4_SampleEntry* sample_entry = dynamic_cast<AP4_SampleEntry*>(entry);
- if (sample_entry == NULL) return NULL;
- m_SampleDescriptions[index] = sample_entry->ToSampleDescription();
- return m_SampleDescriptions[index];
-}
-
-/*----------------------------------------------------------------------
-| AP4_StsdAtom::GetSampleEntry
-+---------------------------------------------------------------------*/
-AP4_SampleEntry*
-AP4_StsdAtom::GetSampleEntry(AP4_Ordinal index)
-{
- // check index
- if (index >= m_Children.ItemCount()) return NULL;
-
- // return the sample entry
- AP4_Atom* entry;
- m_Children.Get(index, entry);
- return dynamic_cast<AP4_SampleEntry*>(entry);
-}
-
-/*----------------------------------------------------------------------
-| AP4_StsdAtom::GetSampleDescriptionCount
-+---------------------------------------------------------------------*/
-AP4_Cardinal
-AP4_StsdAtom::GetSampleDescriptionCount()
-{
- return m_Children.ItemCount();
-}
-
-/*----------------------------------------------------------------------
-| AP4_StsdAtom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_StsdAtom::InspectFields(AP4_AtomInspector& inspector)
-{
- inspector.AddField("entry-count", m_Children.ItemCount());
-
- // inspect children
- m_Children.Apply(AP4_AtomListInspector(inspector));
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4StsdAtom.h b/src/thirdparty/Bento4/Core/Ap4StsdAtom.h
deleted file mode 100644
index dfebf58b3..000000000
--- a/src/thirdparty/Bento4/Core/Ap4StsdAtom.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*****************************************************************
-|
-| AP4 - stsd Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_STSD_ATOM_H_
-#define _AP4_STSD_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4Types.h"
-#include "Ap4Array.h"
-#include "Ap4ByteStream.h"
-#include "Ap4List.h"
-#include "Ap4Atom.h"
-#include "Ap4SampleDescription.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4ContainerAtom.h"
-
-/*----------------------------------------------------------------------
-| class references
-+---------------------------------------------------------------------*/
-class AP4_SampleTable;
-
-/*----------------------------------------------------------------------
-| AP4_StsdAtom
-+---------------------------------------------------------------------*/
-class AP4_StsdAtom : public AP4_ContainerAtom
-{
- public:
- // methods
- AP4_StsdAtom(AP4_SampleTable* sample_table);
- AP4_StsdAtom(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory);
- ~AP4_StsdAtom();
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- virtual AP4_Cardinal GetSampleDescriptionCount();
- virtual AP4_SampleDescription* GetSampleDescription(AP4_Ordinal index);
- virtual AP4_SampleEntry* GetSampleEntry(AP4_Ordinal index);
-
- // AP4_AtomParent methods
- void OnChildChanged(AP4_Atom* child);
-
- const AP4_DataBuffer& GetDataBuffer() { return m_Data; }
-
-private:
- // members
- AP4_DataBuffer m_Data;
- AP4_Array<AP4_SampleDescription*> m_SampleDescriptions;
-};
-
-#endif // _AP4_STSD_ATOM_H_
-
diff --git a/src/thirdparty/Bento4/Core/Ap4StssAtom.cpp b/src/thirdparty/Bento4/Core/Ap4StssAtom.cpp
deleted file mode 100644
index e6eaaf284..000000000
--- a/src/thirdparty/Bento4/Core/Ap4StssAtom.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/*****************************************************************
-|
-| AP4 - stss Atoms
-|
-| Copyright 2003 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4StssAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_StssAtom::AP4_StssAtom
-+---------------------------------------------------------------------*/
-AP4_StssAtom::AP4_StssAtom(AP4_Size size, AP4_ByteStream& stream) :
- AP4_Atom(AP4_ATOM_TYPE_STSS, size, true, stream)
-{
- AP4_UI32 entry_count;
- stream.ReadUI32(entry_count);
- while (entry_count--) {
- AP4_UI32 entry_sample_index;
- if (stream.ReadUI32(entry_sample_index) == AP4_SUCCESS) {
- m_Entries.Append(entry_sample_index);
- }
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_StssAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_StssAtom::WriteFields(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- // entry count
- AP4_Cardinal entry_count = m_Entries.ItemCount();
- result = stream.WriteUI32(entry_count);
- if (AP4_FAILED(result)) return result;
-
- // entries
- for (AP4_Ordinal i=0; i<entry_count; i++) {
- result = stream.WriteUI32(m_Entries[i]);
- if (AP4_FAILED(result)) return result;
- }
-
- return result;
-}
-
-/*----------------------------------------------------------------------
-| AP4_StssAtom::IsSampleSync
-+---------------------------------------------------------------------*/
-bool
-AP4_StssAtom::IsSampleSync(AP4_Ordinal sample)
-{
- unsigned int entry_index = 0;
-
- while (entry_index < m_Entries.ItemCount() &&
- m_Entries[entry_index] >= sample) {
- if (m_Entries[entry_index] == sample) {
- return true;
- }
- entry_index++;
- }
-
- return false;
-}
-
-/*----------------------------------------------------------------------
-| AP4_StssAtom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_StssAtom::InspectFields(AP4_AtomInspector& inspector)
-{
- inspector.AddField("entry_count", m_Entries.ItemCount());
-
- return AP4_SUCCESS;
-}
-
diff --git a/src/thirdparty/Bento4/Core/Ap4StssAtom.h b/src/thirdparty/Bento4/Core/Ap4StssAtom.h
deleted file mode 100644
index 9f074b3f9..000000000
--- a/src/thirdparty/Bento4/Core/Ap4StssAtom.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*****************************************************************
-|
-| AP4 - stss Atoms
-|
-| Copyright 2003 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_STSS_ATOM_H_
-#define _AP4_STSS_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4Array.h"
-#include "Ap4Atom.h"
-
-/*----------------------------------------------------------------------
-| AP4_StssAtom
-+---------------------------------------------------------------------*/
-class AP4_StssAtom : public AP4_Atom
-{
- public:
- // methods
- AP4_StssAtom(AP4_Size size, AP4_ByteStream& stream);
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- virtual bool IsSampleSync(AP4_Ordinal sample);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
- AP4_Array<AP4_UI32> m_Entries; // FIXME
- private:
-};
-
-#endif // _AP4_STSS_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4StszAtom.cpp b/src/thirdparty/Bento4/Core/Ap4StszAtom.cpp
deleted file mode 100644
index de97cc2f7..000000000
--- a/src/thirdparty/Bento4/Core/Ap4StszAtom.cpp
+++ /dev/null
@@ -1,194 +0,0 @@
-/*****************************************************************
-|
-| AP4 - stsz Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4StszAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4Utils.h"
-/*----------------------------------------------------------------------
-| AP4_StszAtom::AP4_StszAtom
-+---------------------------------------------------------------------*/
-AP4_StszAtom::AP4_StszAtom() :
- AP4_Atom(AP4_ATOM_TYPE_STSZ, AP4_FULL_ATOM_HEADER_SIZE+8, true),
- m_SampleSize(0),
- m_SampleCount(0)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_StszAtom::AP4_StszAtom
-+---------------------------------------------------------------------*/
-AP4_StszAtom::AP4_StszAtom(AP4_Size size, AP4_ByteStream& stream) :
- AP4_Atom(AP4_ATOM_TYPE_STSZ, size, true, stream)
-{
- stream.ReadUI32(m_SampleSize);
- stream.ReadUI32(m_SampleCount);
-
- unsigned long sample_count = m_SampleCount;
- if (m_SampleSize == 0) { // means that the samples have different sizes
- while (sample_count--) {
- AP4_UI32 entry_size;
- if (stream.ReadUI32(entry_size) == AP4_SUCCESS) {
- m_Entries.Append(entry_size);
- }
- }
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_StszAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_StszAtom::WriteFields(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- // sample size
- result = stream.WriteUI32(m_SampleSize);
- if (AP4_FAILED(result)) return result;
-
- // sample count
- result = stream.WriteUI32(m_SampleCount);
- if (AP4_FAILED(result)) return result;
-
- // entries if needed (the samples have different sizes)
- if (m_SampleSize == 0) {
- for (AP4_UI32 i=0; i<m_SampleCount; i++) {
- result = stream.WriteUI32(m_Entries[i]);
- if (AP4_FAILED(result)) return result;
- }
- }
-
- return result;
-}
-
-/*----------------------------------------------------------------------
-| AP4_StszAtom::GetSampleCount
-+---------------------------------------------------------------------*/
-AP4_UI32
-AP4_StszAtom::GetSampleCount()
-{
- return m_SampleCount;
-}
-
-/*----------------------------------------------------------------------
-| AP4_StszAtom::GetSampleSize
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_StszAtom::GetSampleSize(AP4_Ordinal sample_start,
- AP4_Ordinal sample_end,
- AP4_Size& sample_size)
-{
- sample_size = 0;
-
- if(sample_start > m_SampleCount || sample_end > m_SampleCount)
- {
- return AP4_ERROR_OUT_OF_RANGE;
- }
-
- if(m_SampleSize != 0)
- {
- sample_size = m_SampleSize * (sample_end - sample_start);
- }
- else
- {
- // compute the additional offset inside the chunk
- for (unsigned int i = sample_start; i < sample_end; i++) {
- AP4_Size size;
- AP4_Result result = GetSampleSize(i, size);
- if (AP4_FAILED(result)) return result;
- sample_size += size;
- }
- }
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_StszAtom::GetSampleSize
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_StszAtom::GetSampleSize(AP4_Ordinal sample, AP4_Size& sample_size)
-{
- // check the sample index
- if (sample > m_SampleCount) {
- sample_size = 0;
- return AP4_ERROR_OUT_OF_RANGE;
- } else {
- // find the size
- if (m_SampleSize != 0) { // constant size
- sample_size = m_SampleSize;
- } else {
- sample_size = m_Entries[sample - 1];
- }
- return AP4_SUCCESS;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_StszAtom::SetSampleSize
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_StszAtom::SetSampleSize(AP4_Ordinal sample, AP4_Size sample_size)
-{
- // check the sample index
- if (sample > m_SampleCount) {
- return AP4_ERROR_OUT_OF_RANGE;
- } else {
- m_Entries[sample - 1] = sample_size;
- return AP4_SUCCESS;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_StszAtom::AddEntry
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_StszAtom::AddEntry(AP4_UI32 size)
-{
- m_Entries.Append(size);
- m_SampleCount++;
- m_Size += 4;
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_StszAtom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_StszAtom::InspectFields(AP4_AtomInspector& inspector)
-{
- inspector.AddField("sample_size", m_SampleSize);
- inspector.AddField("sample_count", m_Entries.ItemCount());
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4StszAtom.h b/src/thirdparty/Bento4/Core/Ap4StszAtom.h
deleted file mode 100644
index 1c57e6687..000000000
--- a/src/thirdparty/Bento4/Core/Ap4StszAtom.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*****************************************************************
-|
-| AP4 - stsz Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_STSZ_ATOM_H_
-#define _AP4_STSZ_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4Array.h"
-#include "Ap4Atom.h"
-
-/*----------------------------------------------------------------------
-| AP4_StszAtom
-+---------------------------------------------------------------------*/
-class AP4_StszAtom : public AP4_Atom
-{
- public:
- // methods
- AP4_StszAtom();
- AP4_StszAtom(AP4_Size size, AP4_ByteStream& stream);
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
- virtual AP4_UI32 GetSampleCount();
- virtual AP4_Result GetSampleSize(AP4_Ordinal sample_start,
- AP4_Ordinal sample_end,
- AP4_Size& sample_size);
- virtual AP4_Result GetSampleSize(AP4_Ordinal sample,
- AP4_Size& sample_size);
- virtual AP4_Result SetSampleSize(AP4_Ordinal sample,
- AP4_Size sample_size);
- virtual AP4_Result AddEntry(AP4_UI32 size);
-
- // FIXME
- friend class AP4_AtomSampleTable;
-
- private:
- AP4_UI32 m_SampleSize;
- AP4_UI32 m_SampleCount;
- AP4_Array<AP4_UI32> m_Entries;
-};
-
-#endif // _AP4_STSZ_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4SttsAtom.cpp b/src/thirdparty/Bento4/Core/Ap4SttsAtom.cpp
deleted file mode 100644
index 3e6165290..000000000
--- a/src/thirdparty/Bento4/Core/Ap4SttsAtom.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-/*****************************************************************
-|
-| AP4 - stts Atoms
-|
-| Copyright 2003 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4SttsAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_SttsAtom::AP4_SttsAtom
-+---------------------------------------------------------------------*/
-AP4_SttsAtom::AP4_SttsAtom() :
- AP4_Atom(AP4_ATOM_TYPE_STTS, AP4_FULL_ATOM_HEADER_SIZE+4, true)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_SttsAtom::AP4_SttsAtom
-+---------------------------------------------------------------------*/
-AP4_SttsAtom::AP4_SttsAtom(AP4_Size size, AP4_ByteStream& stream) :
- AP4_Atom(AP4_ATOM_TYPE_STTS, size, true, stream)
-{
- AP4_UI32 entry_count;
- stream.ReadUI32(entry_count);
- while (entry_count--) {
- AP4_UI32 sample_count;
- AP4_UI32 sample_duration;
- if (stream.ReadUI32(sample_count) == AP4_SUCCESS &&
- stream.ReadUI32(sample_duration) == AP4_SUCCESS) {
-// mpc-hc custom code start
- if((int)sample_duration < 0) {
- sample_duration = 0;
- }
-// mpc-hc custom code end
- m_Entries.Append(AP4_SttsTableEntry(sample_count,
- sample_duration));
- }
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_SttsAtom::GetDts
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SttsAtom::GetDts(AP4_Ordinal sample, AP4_TimeStamp& dts, AP4_Duration& duration)
-{
- AP4_Ordinal sample_count_in_entry = sample;
- dts = 0;
-
- for (AP4_UI32 i = 0; i < m_Entries.ItemCount(); i++) {
- AP4_SttsTableEntry& entry = m_Entries[i];
-
- // check if we have the correct entry
- if (sample_count_in_entry <= entry.m_SampleCount) {
- dts += (sample_count_in_entry - 1) * entry.m_SampleDuration;
- duration = entry.m_SampleDuration;
- return AP4_SUCCESS;
- } else {
- dts += entry.m_SampleCount * entry.m_SampleDuration;
- sample_count_in_entry -= entry.m_SampleCount;
- }
- }
-
- // sample is greater than the number of samples
- return AP4_FAILURE;
-}
-
-/*----------------------------------------------------------------------
-| AP4_SttsAtom::AddEntry
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SttsAtom::AddEntry(AP4_UI32 sample_count, AP4_UI32 sample_duration)
-{
- m_Entries.Append(AP4_SttsTableEntry(sample_count, sample_duration));
- m_Size += 8;
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_SttsAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SttsAtom::WriteFields(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- // write the entry count
- AP4_Cardinal entry_count = m_Entries.ItemCount();
- result = stream.WriteUI32(entry_count);
- if (AP4_FAILED(result)) return result;
-
- // write the entries
- for (AP4_Ordinal i=0; i<entry_count; i++) {
- // sample count
- result = stream.WriteUI32(m_Entries[i].m_SampleCount);
- if (AP4_FAILED(result)) return result;
-
- // time offset
- result = stream.WriteUI32(m_Entries[i].m_SampleDuration);
- if (AP4_FAILED(result)) return result;
- }
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_SttsAtom::GetSampleIndexForTimeStamp
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SttsAtom::GetSampleIndexForTimeStamp(AP4_TimeStamp ts, AP4_Ordinal& sample)
-{
- // init
- AP4_Cardinal entry_count = m_Entries.ItemCount();
- AP4_Duration accumulated = 0;
- sample = 0;
-
- for (AP4_Ordinal i=0; i<entry_count; i++) {
- AP4_Duration next_accumulated = accumulated
- + m_Entries[i].m_SampleCount * m_Entries[i].m_SampleDuration;
-
- // check if the ts is in the range of this entry
- if (ts < next_accumulated) {
- sample += (AP4_Ordinal) ((ts - accumulated) / m_Entries[i].m_SampleDuration);
- return AP4_SUCCESS;
- }
-
- // update accumulated and sample
- accumulated = next_accumulated;
- sample += m_Entries[i].m_SampleCount;
- }
-
- // ts not in range of the table
- return AP4_FAILURE;
-}
-
-/*----------------------------------------------------------------------
-| AP4_SttsAtom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SttsAtom::InspectFields(AP4_AtomInspector& inspector)
-{
- inspector.AddField("entry_count", m_Entries.ItemCount());
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4SttsAtom.h b/src/thirdparty/Bento4/Core/Ap4SttsAtom.h
deleted file mode 100644
index f5383fb3c..000000000
--- a/src/thirdparty/Bento4/Core/Ap4SttsAtom.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*****************************************************************
-|
-| AP4 - stts Atoms
-|
-| Copyright 2003 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_STTS_ATOM_H_
-#define _AP4_STTS_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4Array.h"
-#include "Ap4Atom.h"
-
-/*----------------------------------------------------------------------
-| AP4_SttsTableEntry
-+---------------------------------------------------------------------*/
-class AP4_SttsTableEntry {
- public:
- AP4_SttsTableEntry() :
- m_SampleCount(0),
- m_SampleDuration(0) {}
- AP4_SttsTableEntry(AP4_Cardinal sample_count,
- AP4_Duration sample_duration) :
- m_SampleCount(sample_count),
- m_SampleDuration(sample_duration) {}
-
- AP4_Cardinal m_SampleCount;
- AP4_Duration m_SampleDuration;
-};
-
-/*----------------------------------------------------------------------
-| AP4_SttsAtom
-+---------------------------------------------------------------------*/
-class AP4_SttsAtom : public AP4_Atom
-{
- public:
- // methods
- AP4_SttsAtom();
- AP4_SttsAtom(AP4_Size size, AP4_ByteStream& stream);
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- virtual AP4_Result GetDts(AP4_Ordinal sample, AP4_TimeStamp& dts, AP4_Duration& duration);
- virtual AP4_Result AddEntry(AP4_UI32 sample_count, AP4_UI32 sample_duration);
- virtual AP4_Result GetSampleIndexForTimeStamp(AP4_TimeStamp ts,
- AP4_Ordinal& sample);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
- // FIXME
- friend class AP4_AtomSampleTable;
-
- private:
- AP4_Array<AP4_SttsTableEntry> m_Entries;
-};
-
-#endif // _AP4_STTS_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4SyntheticSampleTable.cpp b/src/thirdparty/Bento4/Core/Ap4SyntheticSampleTable.cpp
deleted file mode 100644
index ae06d760a..000000000
--- a/src/thirdparty/Bento4/Core/Ap4SyntheticSampleTable.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Synthetic Sample Table
-|
-| Copyright 2003-2005 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4Atom.h"
-#include "Ap4SyntheticSampleTable.h"
-
-/*----------------------------------------------------------------------
-| AP4_SyntheticSampleTable::AP4_SyntheticSampleTable()
-+---------------------------------------------------------------------*/
-AP4_SyntheticSampleTable::AP4_SyntheticSampleTable()
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_SyntheticSampleTable::~AP4_SyntheticSampleTable()
-+---------------------------------------------------------------------*/
-AP4_SyntheticSampleTable::~AP4_SyntheticSampleTable()
-{
- m_SampleDescriptions.DeleteReferences();
-}
-
-/*----------------------------------------------------------------------
-| AP4_SyntheticSampleTable::GetSample
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SyntheticSampleTable::GetSample(AP4_Ordinal index, AP4_Sample& sample)
-{
- if (index < m_Samples.ItemCount()) {
- sample = m_Samples[index];
- return AP4_SUCCESS;
- } else {
- return AP4_ERROR_OUT_OF_RANGE;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_SyntheticSampleTable::GetSampleCount
-+---------------------------------------------------------------------*/
-AP4_Cardinal
-AP4_SyntheticSampleTable::GetSampleCount()
-{
- return m_Samples.ItemCount();
-}
-
-/*----------------------------------------------------------------------
-| AP4_SyntheticSampleTable::GetSampleDescriptionCount
-+---------------------------------------------------------------------*/
-AP4_Cardinal
-AP4_SyntheticSampleTable::GetSampleDescriptionCount()
-{
- return m_SampleDescriptions.ItemCount();
-}
-
-/*----------------------------------------------------------------------
-| AP4_SyntheticSampleTable::GetSampleDescription
-+---------------------------------------------------------------------*/
-AP4_SampleDescription*
-AP4_SyntheticSampleTable::GetSampleDescription(AP4_Ordinal index)
-{
- AP4_SampleDescription* description;
- if (AP4_SUCCEEDED(m_SampleDescriptions.Get(index, description))) {
- return description;
- } else {
- return NULL;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_SyntheticSampleTable::AddSampleDescription
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SyntheticSampleTable::AddSampleDescription(AP4_SampleDescription* description)
-{
- return m_SampleDescriptions.Add(description);
-}
-
-/*----------------------------------------------------------------------
-| AP4_SyntheticSampleTable::AddSample
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SyntheticSampleTable::AddSample(AP4_ByteStream& data_stream,
- AP4_Offset offset,
- AP4_Size size,
- AP4_Ordinal description_index,
- AP4_TimeStamp cts,
- AP4_TimeStamp dts,
- bool sync)
-{
- AP4_Sample sample(data_stream, offset, size, description_index, dts, cts-dts);
- return m_Samples.Append(sample);
-}
-
-/*----------------------------------------------------------------------
-| AP4_SyntheticSampleTable::GetSample
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SyntheticSampleTable::GetSampleIndexForTimeStamp(AP4_TimeStamp ts,
- AP4_Ordinal& index)
-{
- return AP4_ERROR_NOT_SUPPORTED_YET;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4SyntheticSampleTable.h b/src/thirdparty/Bento4/Core/Ap4SyntheticSampleTable.h
deleted file mode 100644
index b57639385..000000000
--- a/src/thirdparty/Bento4/Core/Ap4SyntheticSampleTable.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Synthetic Sample Table
-|
-| Copyright 2003-2005 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_SYNTHETIC_SAMPLE_TABLE_H_
-#define _AP4_SYNTHETIC_SAMPLE_TABLE_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4Atom.h"
-#include "Ap4Array.h"
-#include "Ap4SampleTable.h"
-
-/*----------------------------------------------------------------------
-| forward declarations
-+---------------------------------------------------------------------*/
-class AP4_ByteStream;
-
-/*----------------------------------------------------------------------
-| AP4_SyntheticSampleTable
-+---------------------------------------------------------------------*/
-class AP4_SyntheticSampleTable : public AP4_SampleTable
-{
- public:
- // methods
- AP4_SyntheticSampleTable();
- virtual ~AP4_SyntheticSampleTable();
-
- // AP4_SampleTable methods
- virtual AP4_Result GetSample(AP4_Ordinal index, AP4_Sample& sample);
- virtual AP4_Cardinal GetSampleCount();
- virtual AP4_Cardinal GetSampleDescriptionCount();
- virtual AP4_SampleDescription* GetSampleDescription(AP4_Ordinal index);
- virtual AP4_Result GetSampleIndexForTimeStamp(AP4_TimeStamp ts,
- AP4_Ordinal& index);
-
- // methods
- virtual AP4_Result AddSampleDescription(AP4_SampleDescription* description);
- virtual AP4_Result AddSample(AP4_ByteStream& data_stream,
- AP4_Offset offset,
- AP4_Size size,
- AP4_Ordinal description_index,
- AP4_TimeStamp cts = 0,
- AP4_TimeStamp dts = 0,
- bool sync = false);
-
-private:
- // members
- AP4_Array<AP4_Sample> m_Samples;
- AP4_List<AP4_SampleDescription> m_SampleDescriptions;
-};
-
-#endif // _AP4_SYNTHETIC_SAMPLE_TABLE_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4TimsAtom.cpp b/src/thirdparty/Bento4/Core/Ap4TimsAtom.cpp
deleted file mode 100644
index 50ab62618..000000000
--- a/src/thirdparty/Bento4/Core/Ap4TimsAtom.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*****************************************************************
-|
-| AP4 - tims Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4TimsAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4Utils.h"
-#include "Ap4Types.h"
-
-/*----------------------------------------------------------------------
-| AP4_TimsAtom::AP4_TimsAtom
-+---------------------------------------------------------------------*/
-AP4_TimsAtom::AP4_TimsAtom(AP4_UI32 timescale) :
- AP4_Atom(AP4_ATOM_TYPE_TIMS, 4, false),
- m_TimeScale(timescale)
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_TimsAtom::AP4_TimsAtom
-+---------------------------------------------------------------------*/
-AP4_TimsAtom::AP4_TimsAtom(AP4_Size size, AP4_ByteStream& stream) :
- AP4_Atom(AP4_ATOM_TYPE_TIMS, size, false, stream)
-{
- stream.ReadUI32(m_TimeScale);
-}
-
-/*----------------------------------------------------------------------
-| AP4_TimsAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_TimsAtom::WriteFields(AP4_ByteStream& stream)
-{
- // timescale
- return stream.WriteUI32(m_TimeScale);
-
-}
-
-/*----------------------------------------------------------------------
-| AP4_TimsAtom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_TimsAtom::InspectFields(AP4_AtomInspector& inspector)
-{
- inspector.AddField("timescale", m_TimeScale);
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4TimsAtom.h b/src/thirdparty/Bento4/Core/Ap4TimsAtom.h
deleted file mode 100644
index 8ae79ab5a..000000000
--- a/src/thirdparty/Bento4/Core/Ap4TimsAtom.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*****************************************************************
-|
-| AP4 - tims Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-#ifndef _AP4_TIMS_ATOM_H_
-#define _AP4_TIMS_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4Array.h"
-#include "Ap4Atom.h"
-
-/*----------------------------------------------------------------------
-| AP4_TimsAtom
-+---------------------------------------------------------------------*/
-class AP4_TimsAtom : public AP4_Atom
-{
-public:
- // methods
- AP4_TimsAtom(AP4_UI32 timescale);
- AP4_TimsAtom(AP4_Size size, AP4_ByteStream& stream);
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
- // accessors
- virtual AP4_UI32 GetTimeScale() { return m_TimeScale; }
-
-private:
- // members
- AP4_UI32 m_TimeScale;
-};
-
-#endif // _AP4_TIMS_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4TkhdAtom.cpp b/src/thirdparty/Bento4/Core/Ap4TkhdAtom.cpp
deleted file mode 100644
index c7cb4b12c..000000000
--- a/src/thirdparty/Bento4/Core/Ap4TkhdAtom.cpp
+++ /dev/null
@@ -1,187 +0,0 @@
-/*****************************************************************
-|
-| AP4 - tkhd Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4TkhdAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_TkhdAtom::AP4_TkhdAtom
-+---------------------------------------------------------------------*/
-AP4_TkhdAtom::AP4_TkhdAtom(AP4_UI64 creation_time,
- AP4_UI64 modification_time,
- AP4_UI32 track_id,
- AP4_UI64 duration,
- AP4_UI16 volume,
- AP4_UI32 width,
- AP4_UI32 height) :
- AP4_Atom(AP4_ATOM_TYPE_TKHD, 80+AP4_FULL_ATOM_HEADER_SIZE, true),
- m_CreationTime(creation_time),
- m_ModificationTime(modification_time),
- m_TrackId(track_id),
- m_Reserved1(0),
- m_Duration(duration),
- m_Layer(0),
- m_AlternateGroup(0),
- m_Volume(volume),
- m_Reserved3(0),
- m_Width(width),
- m_Height(height)
-{
- m_Flags = AP4_TKHD_FLAG_DEFAULTS;
-
- m_Matrix[0] = 0x00010000;
- m_Matrix[1] = 0;
- m_Matrix[2] = 0;
- m_Matrix[3] = 0;
- m_Matrix[4] = 0x00010000;
- m_Matrix[5] = 0;
- m_Matrix[6] = 0;
- m_Matrix[7] = 0;
- m_Matrix[8] = 0x40000000;
-
- m_Reserved2[0] = 0;
- m_Reserved2[1] = 0;
-}
-
-/*----------------------------------------------------------------------
-| AP4_TkhdAtom::AP4_TkhdAtom
-+---------------------------------------------------------------------*/
-AP4_TkhdAtom::AP4_TkhdAtom(AP4_Size size, AP4_ByteStream& stream) :
- AP4_Atom(AP4_ATOM_TYPE_TKHD, size, true, stream)
-{
- if (m_Version == 0) {
- AP4_UI32 tmp = 0;
- stream.ReadUI32(tmp); m_CreationTime = tmp;
- stream.ReadUI32(tmp); m_ModificationTime = tmp;
- stream.ReadUI32(m_TrackId);
- stream.ReadUI32(m_Reserved1);
- stream.ReadUI32(tmp); m_Duration = tmp;
- } else if (m_Version == 1) {
- stream.ReadUI64(m_CreationTime);
- stream.ReadUI64(m_ModificationTime);
- stream.ReadUI32(m_TrackId);
- stream.ReadUI32(m_Reserved1);
- stream.ReadUI64(m_Duration);
- } else {
- // TODO
- }
-
- stream.Read((void*)m_Reserved2, 8, NULL);
- stream.ReadUI16(m_Layer);
- stream.ReadUI16(m_AlternateGroup);
- stream.ReadUI16(m_Volume);
- stream.ReadUI16(m_Reserved3);
- for (int i=0; i<9; i++) {
- stream.ReadUI32(m_Matrix[i]);
- }
- stream.ReadUI32(m_Width);
- stream.ReadUI32(m_Height);
-}
-
-/*----------------------------------------------------------------------
-| AP4_TkhdAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_TkhdAtom::WriteFields(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- // creation/modification time, track id, reserved1 & duration
- if (m_Version == 0) {
- result = stream.WriteUI32((AP4_UI32)m_CreationTime);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI32((AP4_UI32)m_ModificationTime);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI32(m_TrackId);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI32(m_Reserved1);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI32((AP4_UI32)m_Duration);
- if (AP4_FAILED(result)) return result;
- } else if (m_Version == 1) {
- result = stream.WriteUI64(m_CreationTime);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI64(m_ModificationTime);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI32(m_TrackId);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI32(m_Reserved1);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI64(m_Duration);
- if (AP4_FAILED(result)) return result;
- } else {
- // TODO
- }
-
- // reserved2
- result = stream.Write(m_Reserved2, sizeof(m_Reserved2));
- if (AP4_FAILED(result)) return result;
-
- // layer, alternate group & volume
- result = stream.WriteUI16(m_Layer);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI16(m_AlternateGroup);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI16(m_Volume);
- if (AP4_FAILED(result)) return result;
-
- // reserved3
- result = stream.WriteUI16(m_Reserved3);
-
- // matrix
- for (int i=0; i<9; i++) {
- result = stream.WriteUI32(m_Matrix[i]);
- if (AP4_FAILED(result)) return result;
- }
-
- // width & height
- result = stream.WriteUI32(m_Width);
- if (AP4_FAILED(result)) return result;
- result = stream.WriteUI32(m_Height);
- if (AP4_FAILED(result)) return result;
-
- return result;
-}
-
-/*----------------------------------------------------------------------
-| AP4_TkhdAtom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_TkhdAtom::InspectFields(AP4_AtomInspector& inspector)
-{
- inspector.AddField("enabled", ((m_Flags & AP4_TKHD_FLAG_TRACK_ENABLED) ? 1 : 0), AP4_AtomInspector::HINT_BOOLEAN);
- inspector.AddField("id", m_TrackId);
- inspector.AddField("duration", (AP4_UI32)m_Duration);
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4TkhdAtom.h b/src/thirdparty/Bento4/Core/Ap4TkhdAtom.h
deleted file mode 100644
index 58d42f11c..000000000
--- a/src/thirdparty/Bento4/Core/Ap4TkhdAtom.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*****************************************************************
-|
-| AP4 - tkhd Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_TKHD_ATOM_H_
-#define _AP4_TKHD_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4List.h"
-#include "Ap4Atom.h"
-
-/*----------------------------------------------------------------------
-| constants
-+---------------------------------------------------------------------*/
-const int AP4_TKHD_FLAG_TRACK_ENABLED = 1;
-const int AP4_TKHD_FLAG_TRACK_IN_MOVIE = 2;
-const int AP4_TKHD_FLAG_TRACK_IN_PREVIEW = 4;
-
-const int AP4_TKHD_FLAG_DEFAULTS = 7;
-
-/*----------------------------------------------------------------------
-| AP4_TkhdAtom
-+---------------------------------------------------------------------*/
-class AP4_TkhdAtom : public AP4_Atom
-{
-public:
- // methods
- AP4_TkhdAtom(AP4_UI64 creation_time,
- AP4_UI64 modification_time,
- AP4_UI32 track_id,
- AP4_UI64 duration,
- AP4_UI16 volume,
- AP4_UI32 width,
- AP4_UI32 height);
- AP4_TkhdAtom(AP4_Size size, AP4_ByteStream& stream);
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
- AP4_UI64 GetDuration() { return m_Duration; }
- AP4_Result SetDuration(AP4_UI64 duration) {
- m_Duration = duration;
- return AP4_SUCCESS;
- }
- AP4_UI32 GetTrackId() { return m_TrackId; }
- AP4_Result SetTrackId(AP4_UI32 track_id) {
- m_TrackId = track_id;
- return AP4_SUCCESS;
- }
-
- void GetTranslation(AP4_Float& x, AP4_Float& y)
- {
- x = (AP4_Float)(*(int*)&m_Matrix[6]) / 65536;
- y = (AP4_Float)(*(int*)&m_Matrix[7]) / 65536;
- }
-
- AP4_UI32 GetWidth() const {return m_Width;}
- AP4_UI32 GetHeight() const {return m_Height;}
-
- private:
- // members
- AP4_UI64 m_CreationTime;
- AP4_UI64 m_ModificationTime;
- AP4_UI32 m_TrackId;
- AP4_UI32 m_Reserved1;
- AP4_UI64 m_Duration;
- AP4_UI08 m_DataVersion1[32];
- AP4_UI32 m_Reserved2[2];
- AP4_UI16 m_Layer;
- AP4_UI16 m_AlternateGroup;
- AP4_UI16 m_Volume;
- AP4_UI16 m_Reserved3;
- AP4_UI32 m_Matrix[9];
- AP4_UI32 m_Width;
- AP4_UI32 m_Height;
-};
-
-#endif // _AP4_TKHD_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4Track.cpp b/src/thirdparty/Bento4/Core/Ap4Track.cpp
deleted file mode 100644
index abbb191c9..000000000
--- a/src/thirdparty/Bento4/Core/Ap4Track.cpp
+++ /dev/null
@@ -1,369 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Track Objects
-|
-| Copyright 2002 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4HdlrAtom.h"
-#include "Ap4MvhdAtom.h"
-#include "Ap4Track.h"
-#include "Ap4Utils.h"
-#include "Ap4Sample.h"
-#include "Ap4DataBuffer.h"
-#include "Ap4TrakAtom.h"
-#include "Ap4MoovAtom.h"
-#include "Ap4AtomSampleTable.h"
-#include "Ap4SdpAtom.h"
-#include "Ap4MdhdAtom.h"
-
-/*----------------------------------------------------------------------
-| AP4_Track::AP4_Track
-+---------------------------------------------------------------------*/
-AP4_Track::AP4_Track(Type type,
- AP4_SampleTable* sample_table,
- AP4_UI32 track_id,
- AP4_UI32 movie_time_scale,
- AP4_UI32 media_time_scale,
- AP4_UI64 media_duration,
- const char* language,
- AP4_UI32 width,
- AP4_UI32 height) :
- m_TrakAtomIsOwned(true),
- m_Type(type),
- m_SampleTable(sample_table),
- m_SampleTableIsOwned(false),
- m_MovieTimeScale(movie_time_scale ?
- movie_time_scale :
- AP4_TRACK_DEFAULT_MOVIE_TIMESCALE),
- m_MediaTimeScale(media_time_scale)
-{
- // compute the default volume value
- unsigned int volume = 0;
- if (type == TYPE_AUDIO) volume = 0x100;
-
- // compute the handler type and name
- AP4_Atom::Type hdlr_type;
- const char* hdlr_name;
- switch (type) {
- case TYPE_AUDIO:
- hdlr_type = AP4_HANDLER_TYPE_SOUN;
- hdlr_name = "Bento4 Sound Handler";
- break;
-
- case TYPE_VIDEO:
- hdlr_type = AP4_HANDLER_TYPE_VIDE;
- hdlr_name = "Bento4 Video Handler";
- break;
-
- case TYPE_HINT:
- hdlr_type = AP4_HANDLER_TYPE_HINT;
- hdlr_name = "Bento4 Hint Handler";
- break;
-
- default:
- hdlr_type = 0;
- hdlr_name = NULL;
- break;
- }
-
- // compute the track duration in units of the movie time scale
- AP4_UI64 track_duration = AP4_ConvertTime(media_duration,
- media_time_scale,
- movie_time_scale);
-
- // create a trak atom
- m_TrakAtom = new AP4_TrakAtom(sample_table,
- hdlr_type,
- hdlr_name,
- track_id,
- 0,
- 0,
- track_duration,
- media_time_scale,
- media_duration,
- volume,
- language,
- width,
- height);
-}
-
-/*----------------------------------------------------------------------
-| AP4_Track::AP4_Track
-+---------------------------------------------------------------------*/
-AP4_Track::AP4_Track(AP4_TrakAtom& atom,
- AP4_ByteStream& sample_stream,
- AP4_UI32 movie_time_scale) :
- m_TrakAtom(&atom),
- m_TrakAtomIsOwned(false),
- m_Type(TYPE_UNKNOWN),
- m_SampleTable(NULL),
- m_SampleTableIsOwned(true),
- m_MovieTimeScale(movie_time_scale),
- m_MediaTimeScale(0)
-{
- // find the handler type
- AP4_Atom* sub = atom.FindChild("mdia/hdlr");
- if (sub) {
- AP4_HdlrAtom* hdlr = dynamic_cast<AP4_HdlrAtom*>(sub);
- if (hdlr) {
- AP4_Atom::Type type = hdlr->GetHandlerType();
- if (type == AP4_HANDLER_TYPE_SOUN) {
- m_Type = TYPE_AUDIO;
- } else if (type == AP4_HANDLER_TYPE_VIDE) {
- m_Type = TYPE_VIDEO;
- } else if (type == AP4_HANDLER_TYPE_TEXT ||
- type == AP4_HANDLER_TYPE_SBTL ||
- type == AP4_HANDLER_TYPE_TX3G) {
- m_Type = TYPE_TEXT;
- } else if (type == AP4_HANDLER_TYPE_SUBP) {
- m_Type = TYPE_SUBP;
- } else if (type == AP4_HANDLER_TYPE_HINT) {
- m_Type = TYPE_HINT;
- }
- }
- }
-
- // get the media time scale
- sub = atom.FindChild("mdia/mdhd");
- if (sub) {
- AP4_MdhdAtom* mdhd = dynamic_cast<AP4_MdhdAtom*>(sub);
- if (mdhd) {
- m_MediaTimeScale = mdhd->GetTimeScale();
- }
- }
-
- // create a facade for the stbl atom
- AP4_ContainerAtom* stbl = dynamic_cast<AP4_ContainerAtom*>(
- atom.FindChild("mdia/minf/stbl"));
- if (stbl) {
- m_SampleTable = new AP4_AtomSampleTable(stbl, sample_stream);
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_Track::~AP4_Track
-+---------------------------------------------------------------------*/
-AP4_Track::~AP4_Track()
-{
- if (m_TrakAtomIsOwned) delete m_TrakAtom;
- if (m_SampleTableIsOwned) delete m_SampleTable;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Track::GetId
-+---------------------------------------------------------------------*/
-AP4_UI32
-AP4_Track::GetId()
-{
- return m_TrakAtom->GetId();
-}
-
-/*----------------------------------------------------------------------
-| AP4_Track::SetId
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Track::SetId(AP4_UI32 id)
-{
- m_TrakAtom->SetId(id);
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Track::GetDuration
-+---------------------------------------------------------------------*/
-AP4_UI64
-AP4_Track::GetDuration()
-{
- return m_TrakAtom->GetDuration();
-}
-
-/*----------------------------------------------------------------------
-| AP4_Track::GetDurationMs
-+---------------------------------------------------------------------*/
-AP4_Duration
-AP4_Track::GetDurationMs()
-{
- AP4_UI64 duration = m_TrakAtom->GetDuration();
- return AP4_DurationMsFromUnits(duration, m_MovieTimeScale);
-}
-
-/*----------------------------------------------------------------------
-| AP4_Track::GetSampleCount
-+---------------------------------------------------------------------*/
-AP4_Cardinal
-AP4_Track::GetSampleCount()
-{
- // delegate to the sample table
- return m_SampleTable ? m_SampleTable->GetSampleCount() : 0;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Track::GetSample
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Track::GetSample(AP4_Ordinal index, AP4_Sample& sample)
-{
- // delegate to the sample table
- return m_SampleTable ? m_SampleTable->GetSample(index, sample) : AP4_FAILURE;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Track::GetSampleDescription
-+---------------------------------------------------------------------*/
-AP4_SampleDescription*
-AP4_Track::GetSampleDescription(AP4_Ordinal index)
-{
- // delegate to the sample table
- return m_SampleTable ? m_SampleTable->GetSampleDescription(index) : NULL;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Track::ReadSample
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Track::ReadSample(AP4_Ordinal index,
- AP4_Sample& sample,
- AP4_DataBuffer& data)
-{
- AP4_Result result;
-
- // get the sample
- result = GetSample(index, sample);
- if (AP4_FAILED(result)) return result;
-
- // read the data
- return sample.ReadData(data);
-}
-
-/*----------------------------------------------------------------------
-| AP4_Track::GetSampleIndexForTimeStampMs
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Track::GetSampleIndexForTimeStampMs(AP4_TimeStamp ts, AP4_Ordinal& index)
-{
- // convert the ts in the timescale of the track's media
- ts = AP4_ConvertTime(ts, 1000, m_MediaTimeScale);
-
- return m_SampleTable->GetSampleIndexForTimeStamp(ts, index);
-}
-
-// mpc-hc custom code start
-AP4_Result
-AP4_Track::GetSampleIndexForRefTime(REFERENCE_TIME rt, AP4_Ordinal& index)
-{
- AP4_TimeStamp ts = (AP4_TimeStamp)(double(rt) * m_MediaTimeScale / 10000000 + 0.5);
- // need calculate in double, because the (rt * m_MediaTimeScale) can give overflow
-
- return m_SampleTable->GetSampleIndexForTimeStamp(ts, index);
-}
-// mpc-hc custom code end
-
-/*----------------------------------------------------------------------
-| AP4_Track::SetMovieTimeScale
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_Track::SetMovieTimeScale(AP4_UI32 time_scale)
-{
- // check that we can convert
- if (m_MovieTimeScale == 0) return AP4_FAILURE;
-
- // convert from one time scale to the other
- m_TrakAtom->SetDuration(AP4_ConvertTime(m_TrakAtom->GetDuration(),
- m_MovieTimeScale,
- time_scale));
-
- // keep the new movie timescale
- m_MovieTimeScale = time_scale;
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Track::GetMediaTimeScale
-+---------------------------------------------------------------------*/
-AP4_UI32
-AP4_Track::GetMediaTimeScale()
-{
- return m_MediaTimeScale;
-}
-
-// save the implementation for later
-#if 0
-/*----------------------------------------------------------------------
-| AP4_HintTrack::SetSdpText
-+---------------------------------------------------------------------*/
-void
-AP4_HintTrack::SetSdpText(const char* text)
-{
- // build an sdp atom
- AP4_SdpAtom* sdp = new AP4_SdpAtom(text);
-
- // build the hnti
- AP4_ContainerAtom* hnti = new AP4_ContainerAtom(AP4_ATOM_TYPE_HNTI);
- hnti->AddChild(sdp);
-
- // check if there's already a user data atom
- AP4_ContainerAtom* udta = dynamic_cast<AP4_ContainerAtom*>(m_TrakAtom->FindChild("udta"));
- if (udta == NULL) {
- // otherwise create it
- udta = new AP4_ContainerAtom(AP4_ATOM_TYPE_UDTA);
- m_TrakAtom->AddChild(udta);
- }
- udta->AddChild(hnti);
-}
-
-#endif
-
-/*----------------------------------------------------------------------
-| AP4_Track::GetTrackName
-+---------------------------------------------------------------------*/
-
-AP4_String
-AP4_Track::GetTrackName()
-{
- AP4_String TrackName;
- if(AP4_HdlrAtom* hdlr = dynamic_cast<AP4_HdlrAtom*>(m_TrakAtom->FindChild("mdia/hdlr")))
- TrackName = hdlr->GetHandlerName();
- return TrackName;
-}
-
-/*----------------------------------------------------------------------
-| AP4_Track::GetTrackLanguage
-+---------------------------------------------------------------------*/
-
-AP4_String
-AP4_Track::GetTrackLanguage()
-{
- AP4_String TrackLanguage;
- if(AP4_MdhdAtom* mdhd = dynamic_cast<AP4_MdhdAtom*>(m_TrakAtom->FindChild("mdia/mdhd")))
- TrackLanguage = mdhd->GetLanguage().c_str();
- return TrackLanguage;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4Track.h b/src/thirdparty/Bento4/Core/Ap4Track.h
deleted file mode 100644
index d8a02bed5..000000000
--- a/src/thirdparty/Bento4/Core/Ap4Track.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Track Objects
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_TRAK_H_
-#define _AP4_TRAK_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4Array.h"
-#include "Ap4SampleDescription.h"
-#include "Ap4SampleTable.h"
-
-/*----------------------------------------------------------------------
-| forward declarations
-+---------------------------------------------------------------------*/
-class AP4_StblAtom;
-class AP4_ByteStream;
-class AP4_Sample;
-class AP4_DataBuffer;
-class AP4_TrakAtom;
-class AP4_MoovAtom;
-
-/*----------------------------------------------------------------------
-| constants
-+---------------------------------------------------------------------*/
-const AP4_UI32 AP4_TRACK_DEFAULT_MOVIE_TIMESCALE = 1000;
-
-/*----------------------------------------------------------------------
-| AP4_Track
-+---------------------------------------------------------------------*/
-class AP4_Track {
- public:
- // types
- typedef enum {
- TYPE_UNKNOWN,
- TYPE_AUDIO,
- TYPE_VIDEO,
- TYPE_TEXT,
- TYPE_SUBP,
- TYPE_HINT
- } Type;
-
- // methods
- AP4_Track(Type type,
- AP4_SampleTable* sample_table,
- AP4_UI32 track_id,
- AP4_UI32 movie_time_scale, // 0 = use default
- AP4_UI32 media_time_scale,
- AP4_UI64 media_duration,
- const char* language,
- AP4_UI32 width,
- AP4_UI32 height);
- AP4_Track(AP4_TrakAtom& atom,
- AP4_ByteStream& sample_stream,
- AP4_UI32 movie_time_scale);
- virtual ~AP4_Track();
- AP4_Track::Type GetType() { return m_Type; }
- AP4_UI64 GetDuration();
- AP4_Duration GetDurationMs();
- AP4_Cardinal GetSampleCount();
- AP4_Result GetSample(AP4_Ordinal index, AP4_Sample& sample);
- AP4_Result ReadSample(AP4_Ordinal index,
- AP4_Sample& sample,
- AP4_DataBuffer& data);
- AP4_Result GetSampleIndexForTimeStampMs(AP4_TimeStamp ts,
- AP4_Ordinal& index);
-// mpc-hc custom code start
- AP4_Result GetSampleIndexForRefTime(REFERENCE_TIME rt, AP4_Ordinal& index);
-// mpc-hc custom code end
- AP4_SampleDescription* GetSampleDescription(AP4_Ordinal index);
- AP4_UI32 GetId();
- AP4_Result SetId(AP4_UI32 track_id);
- AP4_TrakAtom* GetTrakAtom() { return m_TrakAtom; }
- AP4_Result SetMovieTimeScale(AP4_UI32 time_scale);
- AP4_UI32 GetMediaTimeScale();
-
- AP4_String GetTrackName();
- AP4_String GetTrackLanguage();
-
- protected:
- // members
- AP4_TrakAtom* m_TrakAtom;
- bool m_TrakAtomIsOwned;
- Type m_Type;
- AP4_SampleTable* m_SampleTable;
- bool m_SampleTableIsOwned;
- AP4_UI32 m_MovieTimeScale;
- AP4_UI32 m_MediaTimeScale;
-};
-
-#endif // _AP4_TRAK_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4TrakAtom.cpp b/src/thirdparty/Bento4/Core/Ap4TrakAtom.cpp
deleted file mode 100644
index 315055085..000000000
--- a/src/thirdparty/Bento4/Core/Ap4TrakAtom.cpp
+++ /dev/null
@@ -1,204 +0,0 @@
-/*****************************************************************
-|
-| AP4 - trak Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4TrakAtom.h"
-#include "Ap4MdhdAtom.h"
-#include "Ap4VmhdAtom.h"
-#include "Ap4SmhdAtom.h"
-#include "Ap4HmhdAtom.h"
-#include "Ap4NmhdAtom.h"
-#include "Ap4DrefAtom.h"
-#include "Ap4UrlAtom.h"
-#include "Ap4StcoAtom.h"
-#include "Ap4Co64Atom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_TrakAtom::AP4_TrakAtom
-+---------------------------------------------------------------------*/
-AP4_TrakAtom::AP4_TrakAtom(AP4_SampleTable* sample_table,
- AP4_Atom::Type hdlr_type,
- const char* hdlr_name,
- AP4_UI32 track_id,
- AP4_UI64 creation_time,
- AP4_UI64 modification_time,
- AP4_UI64 track_duration,
- AP4_UI32 media_time_scale,
- AP4_UI64 media_duration,
- AP4_UI16 volume,
- const char* language,
- AP4_UI32 width,
- AP4_UI32 height) :
- AP4_ContainerAtom(AP4_ATOM_TYPE_TRAK)
-{
- AP4_Result result;
-
- // create a tkhd atom
- m_TkhdAtom = new AP4_TkhdAtom(creation_time,
- modification_time,
- track_id,
- track_duration,
- volume,
- width,
- height);
-
- // create an edts
-
- // create a mdia atom
- AP4_ContainerAtom* mdia = new AP4_ContainerAtom(AP4_ATOM_TYPE_MDIA);
-
- // create a hdlr atom for the mdia atom
- m_HdlrAtom = new AP4_HdlrAtom(hdlr_type, hdlr_name);
-
- // create a minf atom
- AP4_ContainerAtom* minf = new AP4_ContainerAtom(AP4_ATOM_TYPE_MINF);
-
- // create a media header atom for minf (vmhd, smhd, hmhd or nmhd)
- AP4_Atom* minf_header;
- switch (hdlr_type) {
- case AP4_HANDLER_TYPE_VIDE:
- minf_header = new AP4_VmhdAtom(0, 0, 0, 0);
- break;
-
- case AP4_HANDLER_TYPE_SOUN:
- minf_header = new AP4_SmhdAtom(0);
- break;
-
- default:
- minf_header = new AP4_NmhdAtom();
- break;
- }
-
- // create a dinf atom for minf
- AP4_ContainerAtom* dinf = new AP4_ContainerAtom(AP4_ATOM_TYPE_DINF);
-
- // create a url atom as a ref for dref
- AP4_Atom* url = new AP4_UrlAtom(); // local ref
-
- // create a dref atom for dinf
- AP4_DrefAtom* dref = new AP4_DrefAtom(&url, 1);
-
- // create a stbl atom for minf
- AP4_ContainerAtom* stbl;
- result = sample_table->GenerateStblAtom(stbl);
- if (AP4_FAILED(result)) stbl = NULL;
-
- // populate the dinf atom
- dinf->AddChild(dref);
-
- // populate the minf atom
- minf->AddChild(minf_header);
- minf->AddChild(dinf);
- if (stbl) minf->AddChild(stbl);
-
- // create a mdhd atom for the mdia atom
- AP4_MdhdAtom* mdhd = new AP4_MdhdAtom(creation_time,
- modification_time,
- media_time_scale,
- media_duration,
- language);
-
- // populate the mdia atom
- mdia->AddChild(mdhd);
- mdia->AddChild(m_HdlrAtom);
- mdia->AddChild(minf);
-
- // attach the children
- AddChild(m_TkhdAtom);
- AddChild(mdia);
-}
-
-/*----------------------------------------------------------------------
-| AP4_TrakAtom::AP4_TrakAtom
-+---------------------------------------------------------------------*/
-AP4_TrakAtom::AP4_TrakAtom(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory) :
- AP4_ContainerAtom(AP4_ATOM_TYPE_TRAK, size, false, stream, atom_factory),
- m_HdlrAtom(NULL),
- m_TkhdAtom(NULL)
-{
- AP4_Atom* tkhd = FindChild("tkhd");
- if (tkhd != NULL) {
- m_TkhdAtom = dynamic_cast<AP4_TkhdAtom*>(tkhd);
- } else {
- m_TkhdAtom = NULL;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_TrakAtom::GetDuration
-+---------------------------------------------------------------------*/
-AP4_UI64
-AP4_TrakAtom::GetDuration()
-{
- if (m_TkhdAtom) {
- return m_TkhdAtom->GetDuration();
- } else {
- return 0;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_TrakAtom::SetDuration
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_TrakAtom::SetDuration(AP4_UI64 duration)
-{
- if (m_TkhdAtom) {
- return m_TkhdAtom->SetDuration(duration);
- } else {
- return AP4_FAILURE;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_TrakAtom::AdjustChunkOffsets
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_TrakAtom::AdjustChunkOffsets(AP4_Offset offset)
-{
- if (AP4_Atom* atom = FindChild("mdia/minf/stbl/co64")) {
- AP4_Co64Atom* co64 = dynamic_cast<AP4_Co64Atom*>(atom);
- co64->AdjustChunkOffsets(offset);
- }
-
- AP4_Atom* atom = FindChild("mdia/minf/stbl/stco");
- if (atom != NULL) {
- AP4_StcoAtom* stco = dynamic_cast<AP4_StcoAtom*>(atom);
- stco->AdjustChunkOffsets(offset);
- return AP4_SUCCESS;
- } else {
- return AP4_FAILURE;
- }
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4TrakAtom.h b/src/thirdparty/Bento4/Core/Ap4TrakAtom.h
deleted file mode 100644
index 7c40bef33..000000000
--- a/src/thirdparty/Bento4/Core/Ap4TrakAtom.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*****************************************************************
-|
-| AP4 - trak Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_TRAK_ATOM_H_
-#define _AP4_TRAK_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4List.h"
-#include "Ap4Atom.h"
-#include "Ap4HdlrAtom.h"
-#include "Ap4TkhdAtom.h"
-#include "Ap4ContainerAtom.h"
-#include "Ap4SampleTable.h"
-
-/*----------------------------------------------------------------------
-| AP4_TrakAtom
-+---------------------------------------------------------------------*/
-class AP4_TrakAtom : public AP4_ContainerAtom
-{
- public:
- // methods
- AP4_TrakAtom(AP4_SampleTable* sample_table,
- AP4_Atom::Type hdlr_type,
- const char* hdlr_name,
- AP4_UI32 track_id,
- AP4_UI64 creation_time,
- AP4_UI64 modification_time,
- AP4_UI64 track_duration,
- AP4_UI32 media_time_scale,
- AP4_UI64 media_duration,
- AP4_UI16 volume,
- const char* language,
- AP4_UI32 width,
- AP4_UI32 heigh);
- AP4_TrakAtom(AP4_Size size,
- AP4_ByteStream& stream,
- AP4_AtomFactory& atom_factory);
- AP4_Result AdjustChunkOffsets(AP4_Offset offset);
- AP4_UI32 GetId() {
- return m_TkhdAtom->GetTrackId();
- }
- AP4_Result SetId(AP4_UI32 track_id) {
- return m_TkhdAtom->SetTrackId(track_id);
- }
- AP4_UI64 GetDuration();
- AP4_Result SetDuration(AP4_UI64 duration);
- AP4_TkhdAtom* GetTkhdAtom() { return m_TkhdAtom; }
- AP4_HdlrAtom* GetHdlrAtom() { return m_HdlrAtom; }
-
- private:
- // members
- AP4_HdlrAtom* m_HdlrAtom;
- AP4_TkhdAtom* m_TkhdAtom;
-};
-
-#endif // _AP4_TRAK_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4TrefTypeAtom.cpp b/src/thirdparty/Bento4/Core/Ap4TrefTypeAtom.cpp
deleted file mode 100644
index 8c1bcf68f..000000000
--- a/src/thirdparty/Bento4/Core/Ap4TrefTypeAtom.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/*****************************************************************
-|
-| AP4 - tref type Atoms
-|
-| Copyright 2002-2005 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4TrefTypeAtom.h"
-
-/*----------------------------------------------------------------------
-| AP4_TrefTypeAtom::AP4_TrefTypeAtom
-+---------------------------------------------------------------------*/
-AP4_TrefTypeAtom::AP4_TrefTypeAtom(AP4_Atom::Type type,
- AP4_Size size,
- AP4_ByteStream& stream) :
- AP4_Atom(type, size, false, stream)
-{
- AP4_Size data_size = size - 8; // size and atom type
-
- // read the track ids
- while (data_size != 0) {
- AP4_UI32 track_id;
- stream.ReadUI32(track_id);
- m_TrackIds.Append(track_id);
- data_size -= 4;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_TrefTypeAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_TrefTypeAtom::WriteFields(AP4_ByteStream& stream)
-{
- AP4_Result result = AP4_SUCCESS;
-
- AP4_Size track_id_count = m_TrackIds.ItemCount();
- for (AP4_Ordinal i=0; i<track_id_count; i++) {
- result = stream.WriteUI32(m_TrackIds[i]);
- if (AP4_FAILED(result)) return result;
- }
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_TrefTypeAtom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_TrefTypeAtom::InspectFields(AP4_AtomInspector& inspector)
-{
- inspector.AddField("track_id_count", m_TrackIds.ItemCount());
- for (AP4_Ordinal i=0; i<m_TrackIds.ItemCount(); i++) {
- inspector.AddField("track id ", m_TrackIds[i]);
- }
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4TrefTypeAtom.h b/src/thirdparty/Bento4/Core/Ap4TrefTypeAtom.h
deleted file mode 100644
index 2c2f1412a..000000000
--- a/src/thirdparty/Bento4/Core/Ap4TrefTypeAtom.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*****************************************************************
-|
-| AP4 - tref type Atoms
-|
-| Copyright 2002-2005 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-#ifndef _AP4_TREF_TYPE_ATOM_H_
-#define _AP4_TREF_TYPE_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4Atom.h"
-#include "Ap4Array.h"
-
-/*----------------------------------------------------------------------
-| AP4_TrefTypeAtom
-+---------------------------------------------------------------------*/
-class AP4_TrefTypeAtom : public AP4_Atom
-{
-public:
- // methods
- AP4_TrefTypeAtom(AP4_Atom::Type type, AP4_Size size, AP4_ByteStream& stream);
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
- // accessors
- const AP4_Array<AP4_UI32>& GetTrackIds() { return m_TrackIds; }
-
- // members
- AP4_Array<AP4_UI32> m_TrackIds;
-};
-
-#endif
-
diff --git a/src/thirdparty/Bento4/Core/Ap4Types.h b/src/thirdparty/Bento4/Core/Ap4Types.h
deleted file mode 100644
index 4d36b1b2f..000000000
--- a/src/thirdparty/Bento4/Core/Ap4Types.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Shared Types
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_TYPES_H_
-#define _AP4_TYPES_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4Config.h"
-#if defined(AP4_CONFIG_HAVE_CPP_STRING_H)
-#include <string>
-#endif
-
-/*----------------------------------------------------------------------
-| types
-+---------------------------------------------------------------------*/
-typedef int AP4_Result;
-typedef unsigned long AP4_Flags;
-typedef unsigned long AP4_Mask;
-typedef unsigned long long AP4_Size;
-typedef unsigned long long AP4_Offset;
-typedef unsigned long AP4_Range;
-typedef unsigned long AP4_Cardinal;
-typedef unsigned long AP4_Ordinal;
-// typedef unsigned long AP4_TimeStamp;
-// typedef unsigned long AP4_Duration;
-typedef int AP4_Coordinate;
-typedef int AP4_Distance;
-typedef int AP4_Integer;
-typedef unsigned int AP4_UI32;
-typedef unsigned short AP4_UI16;
-typedef unsigned char AP4_UI08;
-typedef float AP4_Float;
-typedef std::string AP4_String;
-typedef unsigned char AP4_Byte;
-typedef __int64 REFERENCE_TIME; // MPC-HC patch
-
-typedef unsigned long long AP4_TimeStamp;
-typedef unsigned long long AP4_Duration;
-typedef unsigned long long AP4_UI64;
-
-#endif // _AP4_TYPES_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4UnknownDescriptor.cpp b/src/thirdparty/Bento4/Core/Ap4UnknownDescriptor.cpp
deleted file mode 100644
index 2b1c7414a..000000000
--- a/src/thirdparty/Bento4/Core/Ap4UnknownDescriptor.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Unknown Descriptors
-|
-| Copyright 2002 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4UnknownDescriptor.h"
-
-/*----------------------------------------------------------------------
-| AP4_UnknownDescriptor::AP4_UnknownDescriptor
-+---------------------------------------------------------------------*/
-AP4_UnknownDescriptor::AP4_UnknownDescriptor(AP4_ByteStream& stream,
- unsigned char tag,
- AP4_Size header_size,
- AP4_Size payload_size) :
- AP4_Descriptor(tag, header_size, payload_size)
-{
- m_Data.SetDataSize(payload_size);
- stream.Read(m_Data.UseData(), payload_size);
-}
-
-/*----------------------------------------------------------------------
-| AP4_UnknownDescriptor::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_UnknownDescriptor::WriteFields(AP4_ByteStream& stream)
-{
- // write the payload
- stream.Write(m_Data.GetData(), m_Data.GetDataSize());
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4UnknownDescriptor.h b/src/thirdparty/Bento4/Core/Ap4UnknownDescriptor.h
deleted file mode 100644
index 60d5f5ae4..000000000
--- a/src/thirdparty/Bento4/Core/Ap4UnknownDescriptor.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Unknown Descriptor
-|
-| Copyright 2002 Gilles Boccon-Gibod & Julien Boeuf
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-#ifndef _AP4_UNKNOWN_DESCRIPTOR_H_
-#define _AP4_UNKNOWN_DESCRIPTOR_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4List.h"
-#include "Ap4DataBuffer.h"
-#include "Ap4Descriptor.h"
-
-/*----------------------------------------------------------------------
-| AP4_UnknownDescriptor
-+---------------------------------------------------------------------*/
-class AP4_UnknownDescriptor : public AP4_Descriptor
-{
-public:
- // methods
- AP4_UnknownDescriptor(AP4_ByteStream& stream,
- unsigned char tag,
- AP4_Size header_size,
- AP4_Size payload_size);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
-private:
- // members
- AP4_DataBuffer m_Data;
-};
-
-
-#endif // _AP4_UNKNOWN_DESCRIPTOR_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4UrlAtom.cpp b/src/thirdparty/Bento4/Core/Ap4UrlAtom.cpp
deleted file mode 100644
index 516126386..000000000
--- a/src/thirdparty/Bento4/Core/Ap4UrlAtom.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*****************************************************************
-|
-| AP4 - url Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4UrlAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_UrlAtom::AP4_UrlAtom
-+---------------------------------------------------------------------*/
-AP4_UrlAtom::AP4_UrlAtom() :
- AP4_Atom(AP4_ATOM_TYPE_URL, AP4_FULL_ATOM_HEADER_SIZE, true)
-{
- m_Flags = 1; // local ref
-}
-
-/*----------------------------------------------------------------------
-| AP4_UrlAtom::AP4_UrlAtom
-+---------------------------------------------------------------------*/
-AP4_UrlAtom::AP4_UrlAtom(AP4_Size size, AP4_ByteStream& stream) :
- AP4_Atom(AP4_ATOM_TYPE_URL, size, true, stream)
-{
- if ((m_Flags & 1) == 0) {
- // not self contained
- AP4_Size str_size = size-AP4_FULL_ATOM_HEADER_SIZE;
- if (str_size > 0) {
- char* str = new char[str_size];
- stream.Read(str, str_size);
- str[str_size-1] = '\0'; // force null-termination
- m_Url = str;
- delete[] str;
- }
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_UrlAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_UrlAtom::WriteFields(AP4_ByteStream& stream)
-{
- if (m_Flags & 1) {
- // local ref (self contained)
- return AP4_SUCCESS;
- } else {
- // url (not self contained)
- AP4_Result result = stream.Write(m_Url.c_str(), m_Url.length()+1);
- if (AP4_FAILED(result)) return result;
-
- // pad with zeros if necessary
- AP4_Size padding = m_Size-(AP4_FULL_ATOM_HEADER_SIZE+m_Url.length()+1);
- while (padding--) stream.WriteUI08(0);
- return AP4_SUCCESS;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_UrlAtom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_UrlAtom::InspectFields(AP4_AtomInspector& inspector)
-{
- if (m_Flags & 1) {
- inspector.AddField("location", "[local to file]");
- } else {
- inspector.AddField("location", m_Url.c_str());
- }
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4UrlAtom.h b/src/thirdparty/Bento4/Core/Ap4UrlAtom.h
deleted file mode 100644
index ee63e365e..000000000
--- a/src/thirdparty/Bento4/Core/Ap4UrlAtom.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*****************************************************************
-|
-| AP4 - url Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_URL_ATOM_H_
-#define _AP4_URL_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4List.h"
-#include "Ap4Atom.h"
-
-/*----------------------------------------------------------------------
-| AP4_UrlAtom
-+---------------------------------------------------------------------*/
-class AP4_UrlAtom : public AP4_Atom
-{
- public:
- // methods
- AP4_UrlAtom(); // local ref only (no URL string)
- AP4_UrlAtom(AP4_Size size, AP4_ByteStream& stream);
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
- private:
- // members
- AP4_String m_Url;
-};
-
-#endif // _AP4_URL_ATOM_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4Utils.cpp b/src/thirdparty/Bento4/Core/Ap4Utils.cpp
deleted file mode 100644
index 4e4b4215e..000000000
--- a/src/thirdparty/Bento4/Core/Ap4Utils.cpp
+++ /dev/null
@@ -1,348 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Utilities
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4Utils.h"
-
-/*----------------------------------------------------------------------
-| AP4_BytesToDoubleBE
-+---------------------------------------------------------------------*/
-double
-AP4_BytesToDoubleBE(const unsigned char* bytes)
-{
- AP4_UI64 i_value = AP4_BytesToUInt64BE(bytes);
- void* v_value = reinterpret_cast<void*>(&i_value);
- double* d_value = reinterpret_cast<double*>(v_value);
-
- return *d_value;
-}
-
-/*----------------------------------------------------------------------
-| AP4_BytesToUInt64BE
-+---------------------------------------------------------------------*/
-unsigned long long
-AP4_BytesToUInt64BE(const unsigned char* bytes)
-{
- return
- ( ((unsigned long long)bytes[0])<<56 ) |
- ( ((unsigned long long)bytes[1])<<48 ) |
- ( ((unsigned long long)bytes[2])<<40 ) |
- ( ((unsigned long long)bytes[3])<<32 ) |
- ( ((unsigned long long)bytes[4])<<24 ) |
- ( ((unsigned long long)bytes[5])<<16 ) |
- ( ((unsigned long long)bytes[6])<<8 ) |
- ( ((unsigned long long)bytes[7]) );
-}
-
-/*----------------------------------------------------------------------
-| AP4_BytesToUInt32BE
-+---------------------------------------------------------------------*/
-unsigned long
-AP4_BytesToUInt32BE(const unsigned char* bytes)
-{
- return
- ( ((unsigned long)bytes[0])<<24 ) |
- ( ((unsigned long)bytes[1])<<16 ) |
- ( ((unsigned long)bytes[2])<<8 ) |
- ( ((unsigned long)bytes[3]) );
-}
-
-/*----------------------------------------------------------------------
-| AP4_BytesToUInt24BE
-+---------------------------------------------------------------------*/
-unsigned long
-AP4_BytesToUInt24BE(const unsigned char* bytes)
-{
- return
- ( ((unsigned long)bytes[0])<<16 ) |
- ( ((unsigned long)bytes[1])<<8 ) |
- ( ((unsigned long)bytes[2]) );
-}
-
-/*----------------------------------------------------------------------
-| AP4_BytesToUInt16BE
-+---------------------------------------------------------------------*/
-unsigned short
-AP4_BytesToUInt16BE(const unsigned char* bytes)
-{
- return
- ( ((unsigned short)bytes[0])<<8 ) |
- ( ((unsigned short)bytes[1]) );
-}
-
-/*----------------------------------------------------------------------
-| AP4_BytesFromUInt64BE
-+---------------------------------------------------------------------*/
-void
-AP4_BytesFromUInt64BE(unsigned char* bytes, unsigned long long value)
-{
- bytes[0] = (unsigned char)(value >> 56);
- bytes[1] = (unsigned char)(value >> 48);
- bytes[2] = (unsigned char)(value >> 40);
- bytes[3] = (unsigned char)(value >> 32);
- bytes[4] = (unsigned char)(value >> 24);
- bytes[5] = (unsigned char)(value >> 16);
- bytes[6] = (unsigned char)(value >> 8);
- bytes[7] = (unsigned char)(value );
-}
-
-/*----------------------------------------------------------------------
-| AP4_BytesFromUInt32BE
-+---------------------------------------------------------------------*/
-void
-AP4_BytesFromUInt32BE(unsigned char* bytes, unsigned long value)
-{
- bytes[0] = (unsigned char)(value >> 24);
- bytes[1] = (unsigned char)(value >> 16);
- bytes[2] = (unsigned char)(value >> 8);
- bytes[3] = (unsigned char)(value );
-}
-
-/*----------------------------------------------------------------------
-| AP4_BytesFromUInt24BE
-+---------------------------------------------------------------------*/
-void
-AP4_BytesFromUInt24BE(unsigned char* bytes, unsigned long value)
-{
- bytes[0] = (unsigned char)(value >> 16);
- bytes[1] = (unsigned char)(value >> 8);
- bytes[2] = (unsigned char)(value );
-}
-
-/*----------------------------------------------------------------------
-| AP4_BytesFromUInt16BE
-+---------------------------------------------------------------------*/
-void
-AP4_BytesFromUInt16BE(unsigned char* bytes, unsigned short value)
-{
- bytes[0] = (unsigned char)(value >> 8);
- bytes[1] = (unsigned char)(value );
-}
-
-/*----------------------------------------------------------------------
-| AP4_MakePrefixString
-+---------------------------------------------------------------------*/
-static void
-AP4_MakePrefixString(AP4_Offset indent, char* prefix, AP4_Size size)
-{
- if (size == 0) return;
- if (indent >= size-1) indent = size-1;
- for (unsigned int i=0; i<indent; i++) {
- prefix[i] = ' ';
- }
- prefix[indent] = '\0';
-}
-
-/*----------------------------------------------------------------------
-| AP4_DurationMsFromUnits
-+---------------------------------------------------------------------*/
-AP4_UI32
-AP4_DurationMsFromUnits(AP4_UI64 units, AP4_UI32 units_per_second)
-{
- if (units_per_second == 0) return 0;
- return (AP4_UI32)(((double)units*1000.0)/(double)units_per_second);
-}
-
-/*----------------------------------------------------------------------
-| AP4_ConvertTime
-+---------------------------------------------------------------------*/
-AP4_UI64
-AP4_ConvertTime(AP4_UI64 time_value,
- AP4_UI32 from_time_scale,
- AP4_UI32 to_time_scale)
-{
- if (from_time_scale == 0) return 0;
- double ratio = (double)to_time_scale/(double)from_time_scale;
- return ((AP4_UI64)((double)time_value*ratio));
-}
-
-/*----------------------------------------------------------------------
-| AP4_FormatFourChars
-+---------------------------------------------------------------------*/
-void
-AP4_FormatFourChars(char* str, AP4_UI32 value) {
- str[0] = (value >> 24) & 0xFF;
- str[1] = (value >> 16) & 0xFF;
- str[2] = (value >> 8) & 0xFF;
- str[3] = (value ) & 0xFF;
- str[4] = '\0';
-}
-
-/*----------------------------------------------------------------------
-| AP4_SplitArgs
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SplitArgs(char* arg, char*& arg0, char*& arg1)
-{
- arg0 = arg;
- char* c = arg;
- while (*c != 0 && *c != ':') {
- c++;
- }
- if (*c == ':') {
- *c++ = '\0';
- arg1 = c;
- return AP4_SUCCESS;
- } else {
- return AP4_FAILURE;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_SplitArgs
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_SplitArgs(char* arg, char*& arg0, char*& arg1, char*& arg2)
-{
- AP4_Result result = AP4_SplitArgs(arg, arg0, arg1);
- if (AP4_FAILED(result)) return result;
- return AP4_SplitArgs(arg1, arg1, arg2);
-}
-
-/*----------------------------------------------------------------------
-| AP4_HexNibble
-+---------------------------------------------------------------------*/
-static unsigned char
-AP4_HexNibble(char c)
-{
- switch (c) {
- case '0': return 0;
- case '1': return 1;
- case '2': return 2;
- case '3': return 3;
- case '4': return 4;
- case '5': return 5;
- case '6': return 6;
- case '7': return 7;
- case '8': return 8;
- case '9': return 9;
- case 'a': case 'A': return 10;
- case 'b': case 'B': return 11;
- case 'c': case 'C': return 12;
- case 'd': case 'D': return 13;
- case 'e': case 'E': return 14;
- case 'f': case 'F': return 15;
- default: return 0;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_ParseHex
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_ParseHex(const char* hex, unsigned char* bytes, unsigned int count)
-{
- if (strlen(hex) != 2*count) return AP4_ERROR_INVALID_PARAMETERS;
- for (unsigned int i=0; i<count; i++) {
- bytes[i] = (AP4_HexNibble(hex[2*i]) << 4) | (AP4_HexNibble(hex[2*i+1]));
- }
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_PrintInspector::AP4_PrintInspector
-+---------------------------------------------------------------------*/
-AP4_PrintInspector::AP4_PrintInspector(AP4_ByteStream& stream) :
- m_Stream(&stream),
- m_Indent(0)
-{
- m_Stream->AddReference();
-}
-
-/*----------------------------------------------------------------------
-| AP4_PrintInspector::~AP4_PrintInspector
-+---------------------------------------------------------------------*/
-AP4_PrintInspector::~AP4_PrintInspector()
-{
- m_Stream->Release();
-}
-
-/*----------------------------------------------------------------------
-| AP4_PrintInspector::StartElement
-+---------------------------------------------------------------------*/
-void
-AP4_PrintInspector::StartElement(const char* name, const char* info)
-{
- char prefix[256];
- AP4_MakePrefixString(m_Indent, prefix, sizeof(prefix));
- m_Stream->WriteString(prefix);
- m_Stream->WriteString(name);
- if (info) {
- m_Stream->Write(" ", 1);
- m_Stream->WriteString(info);
- }
- m_Stream->Write("\n", 1);
-
- m_Indent += 2;
-}
-
-/*----------------------------------------------------------------------
-| AP4_PrintInspector::EndElement
-+---------------------------------------------------------------------*/
-void
-AP4_PrintInspector::EndElement()
-{
- m_Indent -= 2;
-}
-
-/*----------------------------------------------------------------------
-| AP4_PrintInspector::AddField
-+---------------------------------------------------------------------*/
-void
-AP4_PrintInspector::AddField(const char* name, const char* value, FormatHint hint)
-{
- char prefix[256];
- AP4_MakePrefixString(m_Indent, prefix, sizeof(prefix));
- m_Stream->WriteString(prefix);
-
- m_Stream->WriteString(name);
- m_Stream->WriteString(" = ");
- m_Stream->WriteString(value);
- m_Stream->Write("\n", 1);
-}
-
-/*----------------------------------------------------------------------
-| AP4_PrintInspector::AddField
-+---------------------------------------------------------------------*/
-void
-AP4_PrintInspector::AddField(const char* name, AP4_UI32 value, FormatHint hint)
-{
- char prefix[256];
- AP4_MakePrefixString(m_Indent, prefix, sizeof(prefix));
- m_Stream->WriteString(prefix);
-
- char str[32];
- AP4_StringFormat(str, sizeof(str), "%d", value);
- m_Stream->WriteString(name);
- m_Stream->WriteString(" = ");
- m_Stream->WriteString(str);
- m_Stream->Write("\n", 1);
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4Utils.h b/src/thirdparty/Bento4/Core/Ap4Utils.h
deleted file mode 100644
index c4ce8d1b6..000000000
--- a/src/thirdparty/Bento4/Core/Ap4Utils.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*****************************************************************
-|
-| AP4 - Utilities
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
- ****************************************************************/
-
-#ifndef _AP4_UTILS_H_
-#define _AP4_UTILS_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4Config.h"
-#include "Ap4Atom.h"
-
-/*----------------------------------------------------------------------
-| MIN & MAX
-+---------------------------------------------------------------------*/
-#define MIN(a,b) (a<b)?a:b
-#define MAX(a,b) (a>b)?a:b
-
-/*----------------------------------------------------------------------
-| byte I/O
-+---------------------------------------------------------------------*/
-double AP4_BytesToDoubleBE(const unsigned char* bytes);
-unsigned long long AP4_BytesToUInt64BE(const unsigned char* bytes);
-unsigned long AP4_BytesToUInt32BE(const unsigned char* bytes);
-unsigned long AP4_BytesToUInt24BE(const unsigned char* bytes);
-unsigned short AP4_BytesToUInt16BE(const unsigned char* bytes);
-void AP4_BytesFromUInt64BE(unsigned char* bytes, unsigned long long value);
-void AP4_BytesFromUInt32BE(unsigned char* bytes, unsigned long value);
-void AP4_BytesFromUInt24BE(unsigned char* bytes, unsigned long value);
-void AP4_BytesFromUInt16BE(unsigned char* bytes, unsigned short value);
-AP4_UI32 AP4_DurationMsFromUnits(AP4_UI64 units,
- AP4_UI32 units_per_second);
-AP4_UI64 AP4_ConvertTime(AP4_UI64 time_value,
- AP4_UI32 from_time_scale,
- AP4_UI32 to_time_scale);
-
-/*----------------------------------------------------------------------
-| string utils
-+---------------------------------------------------------------------*/
-#if defined (AP4_CONFIG_HAVE_STDIO_H)
-#include <stdio.h>
-#endif
-
-#if defined (AP4_CONFIG_HAVE_SNPRINTF)
-#define AP4_StringFormat snprintf
-#else
-int AP4_StringFormat(char* str, AP4_Size size, const char* format, ...);
-#endif
-
-void AP4_FormatFourChars(char* str, AP4_UI32 value);
-AP4_Result
-AP4_ParseHex(const char* hex, unsigned char* bytes, unsigned int count);
-AP4_Result
-AP4_SplitArgs(char* arg, char*& arg0, char*& arg1, char*& arg2);
-AP4_Result
-AP4_SplitArgs(char* arg, char*& arg0, char*& arg1);
-
-/*----------------------------------------------------------------------
-| AP4_PrintInspector
-+---------------------------------------------------------------------*/
-class AP4_PrintInspector : public AP4_AtomInspector {
-public:
- AP4_PrintInspector(AP4_ByteStream& stream);
- ~AP4_PrintInspector();
-
- // methods
- void StartElement(const char* name, const char* info);
- void EndElement();
- void AddField(const char* name, AP4_UI32 value, FormatHint hint);
- void AddField(const char* name, const char* value, FormatHint hint);
-
-private:
- // members
- AP4_ByteStream* m_Stream;
- AP4_Cardinal m_Indent;
-};
-
-#endif // _AP4_UTILS_H_
diff --git a/src/thirdparty/Bento4/Core/Ap4VmhdAtom.cpp b/src/thirdparty/Bento4/Core/Ap4VmhdAtom.cpp
deleted file mode 100644
index fb0a5b032..000000000
--- a/src/thirdparty/Bento4/Core/Ap4VmhdAtom.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/*****************************************************************
-|
-| AP4 - vmhd Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4VmhdAtom.h"
-#include "Ap4AtomFactory.h"
-#include "Ap4Utils.h"
-#include "Ap4Types.h"
-
-/*----------------------------------------------------------------------
-| AP4_VmhdAtom::AP4_VmhdAtom
-+---------------------------------------------------------------------*/
-AP4_VmhdAtom::AP4_VmhdAtom(AP4_UI16 graphics_mode, AP4_UI16 r, AP4_UI16 g, AP4_UI16 b) :
- AP4_Atom(AP4_ATOM_TYPE_VMHD, 8+AP4_FULL_ATOM_HEADER_SIZE, true),
- m_GraphicsMode(graphics_mode)
-{
- m_OpColor[0] = r;
- m_OpColor[1] = g;
- m_OpColor[2] = b;
-}
-
-/*----------------------------------------------------------------------
-| AP4_VmhdAtom::AP4_VmhdAtom
-+---------------------------------------------------------------------*/
-AP4_VmhdAtom::AP4_VmhdAtom(AP4_Size size, AP4_ByteStream& stream) :
- AP4_Atom(AP4_ATOM_TYPE_VMHD, size, true, stream)
-{
- stream.ReadUI16(m_GraphicsMode);
- stream.Read(m_OpColor, sizeof(m_OpColor));
-}
-
-/*----------------------------------------------------------------------
-| AP4_VmhdAtom::WriteFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_VmhdAtom::WriteFields(AP4_ByteStream& stream)
-{
- AP4_Result result;
-
- // graphics mode
- result = stream.WriteUI16(m_GraphicsMode);
- if (AP4_FAILED(result)) return result;
-
- // op color
- result = stream.Write(m_OpColor, sizeof(m_OpColor));
- if (AP4_FAILED(result)) return result;
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_VmhdAtom::InspectFields
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_VmhdAtom::InspectFields(AP4_AtomInspector& inspector)
-{
- inspector.AddField("graphics_mode", m_GraphicsMode);
- char formatted[16];
- AP4_StringFormat(formatted, sizeof(formatted), "%04x,%04x,%04x",
- m_OpColor[0], m_OpColor[1], m_OpColor[2]);
- inspector.AddField("op_color", formatted);
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Core/Ap4VmhdAtom.h b/src/thirdparty/Bento4/Core/Ap4VmhdAtom.h
deleted file mode 100644
index 43c8ea2d5..000000000
--- a/src/thirdparty/Bento4/Core/Ap4VmhdAtom.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*****************************************************************
-|
-| AP4 - vmhd Atoms
-|
-| Copyright 2002 Gilles Boccon-Gibod
-|
-|
-| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
-|
-| Unless you have obtained Bento4 under a difference license,
-| this version of Bento4 is Bento4|GPL.
-| Bento4|GPL is free software; you can redistribute it and/or modify
-| it under the terms of the GNU General Public License as published by
-| the Free Software Foundation; either version 2, or (at your option)
-| any later version.
-|
-| Bento4|GPL 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 General Public License for more details.
-|
-| You should have received a copy of the GNU General Public License
-| along with Bento4|GPL; see the file COPYING. If not, write to the
-| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-| 02111-1307, USA.
-|
-****************************************************************/
-
-#ifndef _AP4_VMHD_ATOM_H_
-#define _AP4_VMHD_ATOM_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4ByteStream.h"
-#include "Ap4Array.h"
-#include "Ap4Atom.h"
-
-/*----------------------------------------------------------------------
-| AP4_VmhdAtom
-+---------------------------------------------------------------------*/
-class AP4_VmhdAtom : public AP4_Atom
-{
-public:
- // methods
- AP4_VmhdAtom(AP4_UI16 graphics_mode, AP4_UI16 r, AP4_UI16 g, AP4_UI16 b);
- AP4_VmhdAtom(AP4_Size size, AP4_ByteStream& stream);
- virtual AP4_Result InspectFields(AP4_AtomInspector& inspector);
- virtual AP4_Result WriteFields(AP4_ByteStream& stream);
-
-private:
- // members
- AP4_UI16 m_GraphicsMode;
- AP4_UI16 m_OpColor[3];
-};
-
-#endif // _AP4_VMHD_ATOM_H_
diff --git a/src/thirdparty/Bento4/Crypto/Ap4AesBlockCipher.cpp b/src/thirdparty/Bento4/Crypto/Ap4AesBlockCipher.cpp
deleted file mode 100644
index c5b16e0b7..000000000
--- a/src/thirdparty/Bento4/Crypto/Ap4AesBlockCipher.cpp
+++ /dev/null
@@ -1,1841 +0,0 @@
-/*
-* AES Block cipher
-* (c) 2005 Gilles Boccon-Gibod
-* Portions (c) 2001, Dr Brian Gladman (see below)
-*/
-
-/*
--------------------------------------------------------------------------
-Copyright (c) 2001, Dr Brian Gladman <brg@gladman.me.uk>, Worcester, UK.
-All rights reserved.
-
-LICENSE TERMS
-
-The free distribution and use of this software in both source and binary
-form is allowed (with or without changes) provided that:
-
-1. distributions of this source code include the above copyright
-notice, this list of conditions and the following disclaimer;
-
-2. distributions in binary form include the above copyright
-notice, this list of conditions and the following disclaimer
-in the documentation and/or other associated materials;
-
-3. the copyright holder's name is not used to endorse products
-built using this software without specific written permission.
-
-DISCLAIMER
-
-This software is provided 'as is' with no explicit or implied warranties
-in respect of its properties, including, but not limited to, correctness
-and fitness for purpose.
--------------------------------------------------------------------------
-Issue Date: 29/07/2002
-*/
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4AesBlockCipher.h"
-#include "Ap4Results.h"
-
-/*----------------------------------------------------------------------
-| build options
-+---------------------------------------------------------------------*/
-#define ENCRYPTION_KEY_SCHEDULE
-#define ENCRYPTION
-#define BLOCK_SIZE AP4_AES_BLOCK_SIZE
-
-/*----------------------------------------------------------------------
-| options
-+---------------------------------------------------------------------*/
-/* START OF CONFIGURATION OPTIONS
-
- USE OF DEFINES
-
- Later in this section there are a number of defines that control the
- operation of the code. In each section, the purpose of each define is
- explained so that the relevant form can be included or excluded by
- setting either 1's or 0's respectively on the branches of the related
- #if clauses.
-*/
-
-/* 1. BYTE ORDER IN 32-BIT WORDS
-
- To obtain the highest speed on processors with 32-bit words, this code
- needs to determine the order in which bytes are packed into such words.
- The following block of code is an attempt to capture the most obvious
- ways in which various environemnts define byte order. It may well fail,
- in which case the definitions will need to be set by editing at the
- points marked **** EDIT HERE IF NECESSARY **** below.
-*/
-#define AES_LITTLE_ENDIAN 1234 /* byte 0 is least significant (i386) */
-#define AES_BIG_ENDIAN 4321 /* byte 0 is most significant (mc68k) */
-
-#if !defined(AP4_PLATFORM_BYTE_ORDER)
-# error AP4_PLATFORM_BYTE_ORDER is not set
-#endif
-
-#if 0
-#if AP4_PLATFORM_BYTE_ORDER == AP4_PLATFORM_BIG_ENDIAN
-#define PLATFORM_BYTE_ORDER AES_BIG_ENDIAN
-#elif AP4_PLATFORM_BYTE_ORDER == AP4_PLATFORM_LITTLE_ENDIAN
-#define PLATFORM_BYTE_ORDER AES_LITTLE_ENDIAN
-#else
-#error unsupported value for AP4_PLATFORM_BYTE_ORDER
-#endif
-#endif
-
-#define PLATFORM_BYTE_ORDER AES_LITTLE_ENDIAN
-
-
-/* 2. BYTE ORDER WITHIN 32 BIT WORDS
-
- The fundamental data processing units in Rijndael are 8-bit bytes. The
- input, output and key input are all enumerated arrays of bytes in which
- bytes are numbered starting at zero and increasing to one less than the
- number of bytes in the array in question. This enumeration is only used
- for naming bytes and does not imply any adjacency or order relationship
- from one byte to another. When these inputs and outputs are considered
- as bit sequences, bits 8*n to 8*n+7 of the bit sequence are mapped to
- byte[n] with bit 8n+i in the sequence mapped to bit 7-i within the byte.
- In this implementation bits are numbered from 0 to 7 starting at the
- numerically least significant end of each byte (bit n represents 2^n).
-
- However, Rijndael can be implemented more efficiently using 32-bit
- words by packing bytes into words so that bytes 4*n to 4*n+3 are placed
- into word[n]. While in principle these bytes can be assembled into words
- in any positions, this implementation only supports the two formats in
- which bytes in adjacent positions within words also have adjacent byte
- numbers. This order is called big-endian if the lowest numbered bytes
- in words have the highest numeric significance and little-endian if the
- opposite applies.
-
- This code can work in either order irrespective of the order used by the
- machine on which it runs. Normally the internal byte order will be set
- to the order of the processor on which the code is to be run but this
- define can be used to reverse this in special situations
-*/
-#if 1
-#define INTERNAL_BYTE_ORDER PLATFORM_BYTE_ORDER
-#elif defined(AES_LITTLE_ENDIAN)
-#define INTERNAL_BYTE_ORDER AES_LITTLE_ENDIAN
-#elif defined(AES_BIG_ENDIAN)
-#define INTERNAL_BYTE_ORDER AES_BIG_ENDIAN
-#endif
-
-/* 3. FAST INPUT/OUTPUT OPERATIONS.
-
- On some machines it is possible to improve speed by transferring the
- bytes in the input and output arrays to and from the internal 32-bit
- variables by addressing these arrays as if they are arrays of 32-bit
- words. On some machines this will always be possible but there may
- be a large performance penalty if the byte arrays are not aligned on
- the normal word boundaries. On other machines this technique will
- lead to memory access errors when such 32-bit word accesses are not
- properly aligned. The option SAFE_IO avoids such problems but will
- often be slower on those machines that support misaligned access
- (especially so if care is taken to align the input and output byte
- arrays on 32-bit word boundaries). If SAFE_IO is not defined it is
- assumed that access to byte arrays as if they are arrays of 32-bit
- words will not cause problems when such accesses are misaligned.
-*/
-#if 1
-#define SAFE_IO
-#endif
-
-/* 4. LOOP UNROLLING
-
- The code for encryption and decrytpion cycles through a number of rounds
- that can be implemented either in a loop or by expanding the code into a
- long sequence of instructions, the latter producing a larger program but
- one that will often be much faster. The latter is called loop unrolling.
- There are also potential speed advantages in expanding two iterations in
- a loop with half the number of iterations, which is called partial loop
- unrolling. The following options allow partial or full loop unrolling
- to be set independently for encryption and decryption
-*/
-#if 1
-#define ENC_UNROLL FULL
-#elif 0
-#define ENC_UNROLL PARTIAL
-#else
-#define ENC_UNROLL NONE
-#endif
-
-#if 1
-#define DEC_UNROLL FULL
-#elif 0
-#define DEC_UNROLL PARTIAL
-#else
-#define DEC_UNROLL NONE
-#endif
-
-/* 5. FIXED OR DYNAMIC TABLES
-
- When this section is included the tables used by the code are comipled
- statically into the binary file. Otherwise they are computed once when
- the code is first used.
-*/
-#if 1
-#define FIXED_TABLES
-#endif
-
-/* 6. FAST FINITE FIELD OPERATIONS
-
- If this section is included, tables are used to provide faster finite
- field arithmetic (this has no effect if FIXED_TABLES is defined).
-*/
-#if 1
-#define FF_TABLES
-#endif
-
-/* 7. INTERNAL STATE VARIABLE FORMAT
-
- The internal state of Rijndael is stored in a number of local 32-bit
- word varaibles which can be defined either as an array or as individual
- names variables. Include this section if you want to store these local
- variables in arrays. Otherwise individual local variables will be used.
-*/
-#if 1
-#define ARRAYS
-#endif
-
-/* In this implementation the columns of the state array are each held in
- 32-bit words. The state array can be held in various ways: in an array
- of words, in a number of individual word variables or in a number of
- processor registers. The following define maps a variable name x and
- a column number c to the way the state array variable is to be held.
- The first define below maps the state into an array x[c] whereas the
- second form maps the state into a number of individual variables x0,
- x1, etc. Another form could map individual state colums to machine
- register names.
-*/
-
-#if defined(ARRAYS)
-#define s(x,c) x[c]
-#else
-#define s(x,c) x##c
-#endif
-
-/* 8. VARIABLE BLOCK SIZE SPEED
-
- This section is only relevant if you wish to use the variable block
- length feature of the code. Include this section if you place more
- emphasis on speed rather than code size.
-*/
-#if 1
-#define FAST_VARIABLE
-#endif
-
-/* 9. INTERNAL TABLE CONFIGURATION
-
- This cipher proceeds by repeating in a number of cycles known as 'rounds'
- which are implemented by a round function which can optionally be speeded
- up using tables. The basic tables are each 256 32-bit words, with either
- one or four tables being required for each round function depending on
- how much speed is required. The encryption and decryption round functions
- are different and the last encryption and decrytpion round functions are
- different again making four different round functions in all.
-
- This means that:
- 1. Normal encryption and decryption rounds can each use either 0, 1
- or 4 tables and table spaces of 0, 1024 or 4096 bytes each.
- 2. The last encryption and decryption rounds can also use either 0, 1
- or 4 tables and table spaces of 0, 1024 or 4096 bytes each.
-
- Include or exclude the appropriate definitions below to set the number
- of tables used by this implementation.
-*/
-
-#if 1 /* set tables for the normal encryption round */
-#define ENC_ROUND FOUR_TABLES
-#elif 0
-#define ENC_ROUND ONE_TABLE
-#else
-#define ENC_ROUND NO_TABLES
-#endif
-
-#if 1 /* set tables for the last encryption round */
-#define LAST_ENC_ROUND FOUR_TABLES
-#elif 0
-#define LAST_ENC_ROUND ONE_TABLE
-#else
-#define LAST_ENC_ROUND NO_TABLES
-#endif
-
-#if 1 /* set tables for the normal decryption round */
-#define DEC_ROUND FOUR_TABLES
-#elif 0
-#define DEC_ROUND ONE_TABLE
-#else
-#define DEC_ROUND NO_TABLES
-#endif
-
-#if 1 /* set tables for the last decryption round */
-#define LAST_DEC_ROUND FOUR_TABLES
-#elif 0
-#define LAST_DEC_ROUND ONE_TABLE
-#else
-#define LAST_DEC_ROUND NO_TABLES
-#endif
-
-/* The decryption key schedule can be speeded up with tables in the same
- way that the round functions can. Include or exclude the following
- defines to set this requirement.
-*/
-#if 1
-#define KEY_SCHED FOUR_TABLES
-#elif 0
-#define KEY_SCHED ONE_TABLE
-#else
-#define KEY_SCHED NO_TABLES
-#endif
-
-/* END OF CONFIGURATION OPTIONS */
-
-#define NO_TABLES 0 /* DO NOT CHANGE */
-#define ONE_TABLE 1 /* DO NOT CHANGE */
-#define FOUR_TABLES 4 /* DO NOT CHANGE */
-#define NONE 0 /* DO NOT CHANGE */
-#define PARTIAL 1 /* DO NOT CHANGE */
-#define FULL 2 /* DO NOT CHANGE */
-
-#if defined(BLOCK_SIZE) && ((BLOCK_SIZE & 3) || BLOCK_SIZE < 16 || BLOCK_SIZE > 32)
-#error An illegal block size has been specified.
-#endif
-
-#if !defined(BLOCK_SIZE)
-#define RC_LENGTH 29
-#else
-#define RC_LENGTH 5 * BLOCK_SIZE / 4 - (BLOCK_SIZE == 16 ? 10 : 11)
-#endif
-
-/* Disable at least some poor combinations of options */
-
-#if ENC_ROUND == NO_TABLES && LAST_ENC_ROUND != NO_TABLES
-#undef LAST_ENC_ROUND
-#define LAST_ENC_ROUND NO_TABLES
-#elif ENC_ROUND == ONE_TABLE && LAST_ENC_ROUND == FOUR_TABLES
-#undef LAST_ENC_ROUND
-#define LAST_ENC_ROUND ONE_TABLE
-#endif
-
-#if ENC_ROUND == NO_TABLES && ENC_UNROLL != NONE
-#undef ENC_UNROLL
-#define ENC_UNROLL NONE
-#endif
-
-#if DEC_ROUND == NO_TABLES && LAST_DEC_ROUND != NO_TABLES
-#undef LAST_DEC_ROUND
-#define LAST_DEC_ROUND NO_TABLES
-#elif DEC_ROUND == ONE_TABLE && LAST_DEC_ROUND == FOUR_TABLES
-#undef LAST_DEC_ROUND
-#define LAST_DEC_ROUND ONE_TABLE
-#endif
-
-#if DEC_ROUND == NO_TABLES && DEC_UNROLL != NONE
-#undef DEC_UNROLL
-#define DEC_UNROLL NONE
-#endif
-
-/* upr(x,n): rotates bytes within words by n positions, moving bytes to
- higher index positions with wrap around into low positions
- ups(x,n): moves bytes by n positions to higher index positions in
- words but without wrap around
- bval(x,n): extracts a byte from a word
-
- NOTE: The definitions given here are intended only for use with
- unsigned variables and with shift counts that are compile
- time constants
-*/
-
-#if (INTERNAL_BYTE_ORDER == AES_LITTLE_ENDIAN)
-#if defined(_MSC_VER)
-#define upr(x,n) _lrotl((aes_32t)(x), 8 * (n))
-#else
-#define upr(x,n) ((aes_32t)(x) << 8 * (n) | (aes_32t)(x) >> (32 - 8 * (n)))
-#endif
-#define ups(x,n) ((aes_32t)(x) << 8 * (n))
-#define bval(x,n) ((aes_08t)((x) >> 8 * (n)))
-#define bytes2word(b0, b1, b2, b3) \
- (((aes_32t)(b3) << 24) | ((aes_32t)(b2) << 16) | ((aes_32t)(b1) << 8) | (b0))
-#endif
-
-#if (INTERNAL_BYTE_ORDER == AES_BIG_ENDIAN)
-#define upr(x,n) ((aes_32t)(x) >> 8 * (n) | (aes_32t)(x) << 32 - 8 * (n))
-#define ups(x,n) ((aes_32t)(x) >> 8 * (n)))
-#define bval(x,n) ((aes_08t)((x) >> (24 - 8 * (n))))
-#define bytes2word(b0, b1, b2, b3) \
- (((aes_32t)(b0) << 24) | ((aes_32t)(b1) << 16) | ((aes_32t)(b2) << 8) | (b3))
-#endif
-
-#if defined(SAFE_IO)
-
-#define word_in(x) bytes2word((x)[0], (x)[1], (x)[2], (x)[3])
-#define word_out(x,v) { (x)[0] = bval(v,0); (x)[1] = bval(v,1); \
- (x)[2] = bval(v,2); (x)[3] = bval(v,3); }
-
-#elif (INTERNAL_BYTE_ORDER == PLATFORM_BYTE_ORDER)
-
-#define word_in(x) *(aes_32t*)(x)
-#define word_out(x,v) *(aes_32t*)(x) = (v)
-
-#else
-
-#if !defined(bswap_32)
-#if !defined(_MSC_VER)
-#define _lrotl(x,n) ((((aes_32t)(x)) << n) | (((aes_32t)(x)) >> (32 - n)))
-#endif
-#define bswap_32(x) ((_lrotl((x),8) & 0x00ff00ff) | (_lrotl((x),24) & 0xff00ff00))
-#endif
-
-#define word_in(x) bswap_32(*(aes_32t*)(x))
-#define word_out(x,v) *(aes_32t*)(x) = bswap_32(v)
-
-#endif
-
-/* the finite field modular polynomial and elements */
-
-#define WPOLY 0x011b
-#define BPOLY 0x1b
-
-/* multiply four bytes in GF(2^8) by 'x' {02} in parallel */
-
-#define m1 0x80808080
-#define m2 0x7f7f7f7f
-#define FFmulX(x) ((((x) & m2) << 1) ^ ((((x) & m1) >> 7) * BPOLY))
-
-/* The following defines provide alternative definitions of FFmulX that might
- give improved performance if a fast 32-bit multiply is not available. Note
- that a temporary variable u needs to be defined where FFmulX is used.
-
-#define FFmulX(x) (u = (x) & m1, u |= (u >> 1), ((x) & m2) << 1) ^ ((u >> 3) | (u >> 6))
-#define m4 (0x01010101 * BPOLY)
-#define FFmulX(x) (u = (x) & m1, ((x) & m2) << 1) ^ ((u - (u >> 7)) & m4)
-*/
-
-/* Work out which tables are needed for the different options */
-
-#ifdef AES_ASM
-#ifdef ENC_ROUND
-#undef ENC_ROUND
-#endif
-#define ENC_ROUND FOUR_TABLES
-#ifdef LAST_ENC_ROUND
-#undef LAST_ENC_ROUND
-#endif
-#define LAST_ENC_ROUND FOUR_TABLES
-#ifdef DEC_ROUND
-#undef DEC_ROUND
-#endif
-#define DEC_ROUND FOUR_TABLES
-#ifdef LAST_DEC_ROUND
-#undef LAST_DEC_ROUND
-#endif
-#define LAST_DEC_ROUND FOUR_TABLES
-#ifdef KEY_SCHED
-#undef KEY_SCHED
-#define KEY_SCHED FOUR_TABLES
-#endif
-#endif
-
-#if defined(ENCRYPTION) || defined(AES_ASM)
-#if ENC_ROUND == ONE_TABLE
-#define FT1_SET
-#elif ENC_ROUND == FOUR_TABLES
-#define FT4_SET
-#else
-#define SBX_SET
-#endif
-#if LAST_ENC_ROUND == ONE_TABLE
-#define FL1_SET
-#elif LAST_ENC_ROUND == FOUR_TABLES
-#define FL4_SET
-#elif !defined(SBX_SET)
-#define SBX_SET
-#endif
-#endif
-
-#if defined(DECRYPTION) || defined(AES_ASM)
-#if DEC_ROUND == ONE_TABLE
-#define IT1_SET
-#elif DEC_ROUND == FOUR_TABLES
-#define IT4_SET
-#else
-#define ISB_SET
-#endif
-#if LAST_DEC_ROUND == ONE_TABLE
-#define IL1_SET
-#elif LAST_DEC_ROUND == FOUR_TABLES
-#define IL4_SET
-#elif !defined(ISB_SET)
-#define ISB_SET
-#endif
-#endif
-
-#if defined(ENCRYPTION_KEY_SCHEDULE) || defined(DECRYPTION_KEY_SCHEDULE)
-#if KEY_SCHED == ONE_TABLE
-#define LS1_SET
-#define IM1_SET
-#elif KEY_SCHED == FOUR_TABLES
-#define LS4_SET
-#define IM4_SET
-#elif !defined(SBX_SET)
-#define SBX_SET
-#endif
-#endif
-
-#ifdef FIXED_TABLES
-#define prefx static const
-#else
-#define prefx extern
-extern aes_08t tab_init;
-void gen_tabs(void);
-#endif
-
-//prefx aes_32t rcon_tab[29];
-//
-//#ifdef SBX_SET
-//prefx aes_08t s_box[256];
-//#endif
-//
-//#ifdef ISB_SET
-//prefx aes_08t inv_s_box[256];
-//#endif
-//
-//#ifdef FT1_SET
-//prefx aes_32t ft_tab[256];
-//#endif
-//
-//#ifdef FT4_SET
-//prefx aes_32t ft_tab[4][256];
-//#endif
-//
-//#ifdef FL1_SET
-//prefx aes_32t fl_tab[256];
-//#endif
-//
-//#ifdef FL4_SET
-//prefx aes_32t fl_tab[4][256];
-//#endif
-//
-//#ifdef IT1_SET
-//prefx aes_32t it_tab[256];
-//#endif
-//
-//#ifdef IT4_SET
-//prefx aes_32t it_tab[4][256];
-//#endif
-//
-//#ifdef IL1_SET
-//prefx aes_32t il_tab[256];
-//#endif
-//
-//#ifdef IL4_SET
-//prefx aes_32t il_tab[4][256];
-//#endif
-//
-//#ifdef LS1_SET
-//#ifdef FL1_SET
-//#undef LS1_SET
-//#else
-//prefx aes_32t ls_tab[256];
-//#endif
-//#endif
-//
-//#ifdef LS4_SET
-//#ifdef FL4_SET
-//#undef LS4_SET
-//#else
-//prefx aes_32t ls_tab[4][256];
-//#endif
-//#endif
-//
-//#ifdef IM1_SET
-//prefx aes_32t im_tab[256];
-//#endif
-//
-//#ifdef IM4_SET
-//prefx aes_32t im_tab[4][256];
-//#endif
-
-/* Set the number of columns in nc. Note that it is important
- that nc is a constant which is known at compile time if the
- highest speed version of the code is needed.
-*/
-
-#if defined(BLOCK_SIZE)
-#define nc (BLOCK_SIZE >> 2)
-#else
-#define nc (cx->n_blk >> 2)
-#endif
-
-/* generic definitions of Rijndael macros that use tables */
-
-#define no_table(x,box,vf,rf,c) bytes2word( \
- box[bval(vf(x,0,c),rf(0,c))], \
- box[bval(vf(x,1,c),rf(1,c))], \
- box[bval(vf(x,2,c),rf(2,c))], \
- box[bval(vf(x,3,c),rf(3,c))])
-
-#define one_table(x,op,tab,vf,rf,c) \
- ( tab[bval(vf(x,0,c),rf(0,c))] \
- ^ op(tab[bval(vf(x,1,c),rf(1,c))],1) \
- ^ op(tab[bval(vf(x,2,c),rf(2,c))],2) \
- ^ op(tab[bval(vf(x,3,c),rf(3,c))],3))
-
-#define four_tables(x,tab,vf,rf,c) \
- ( tab[0][bval(vf(x,0,c),rf(0,c))] \
- ^ tab[1][bval(vf(x,1,c),rf(1,c))] \
- ^ tab[2][bval(vf(x,2,c),rf(2,c))] \
- ^ tab[3][bval(vf(x,3,c),rf(3,c))])
-
-#define vf1(x,r,c) (x)
-#define rf1(r,c) (r)
-#define rf2(r,c) ((r-c)&3)
-
-/* perform forward and inverse column mix operation on four bytes in long word x in */
-/* parallel. NOTE: x must be a simple variable, NOT an expression in these macros. */
-
-#define dec_fmvars
-#if defined(FM4_SET) /* not currently used */
-#define fwd_mcol(x) four_tables(x,fm_tab,vf1,rf1,0)
-#elif defined(FM1_SET) /* not currently used */
-#define fwd_mcol(x) one_table(x,upr,fm_tab,vf1,rf1,0)
-#else
-#undef dec_fmvars
-#define dec_fmvars aes_32t f1, f2;
-#define fwd_mcol(x) (f1 = (x), f2 = FFmulX(f1), f2 ^ upr(f1 ^ f2, 3) ^ upr(f1, 2) ^ upr(f1, 1))
-#endif
-
-#define dec_imvars
-#if defined(IM4_SET)
-#define inv_mcol(x) four_tables(x,im_tab,vf1,rf1,0)
-#elif defined(IM1_SET)
-#define inv_mcol(x) one_table(x,upr,im_tab,vf1,rf1,0)
-#else
-#undef dec_imvars
-#define dec_imvars aes_32t f2, f4, f8, f9;
-#define inv_mcol(x) \
- (f9 = (x), f2 = FFmulX(f9), f4 = FFmulX(f2), f8 = FFmulX(f4), f9 ^= f8, \
- f2 ^= f4 ^ f8 ^ upr(f2 ^ f9,3) ^ upr(f4 ^ f9,2) ^ upr(f9,1))
-#endif
-
-#if defined(FL4_SET)
-#define ls_box(x,c) four_tables(x,fl_tab,vf1,rf2,c)
-#elif defined(LS4_SET)
-#define ls_box(x,c) four_tables(x,ls_tab,vf1,rf2,c)
-#elif defined(FL1_SET)
-#define ls_box(x,c) one_table(x,upr,fl_tab,vf1,rf2,c)
-#elif defined(LS1_SET)
-#define ls_box(x,c) one_table(x,upr,ls_tab,vf1,rf2,c)
-#else
-#define ls_box(x,c) no_table(x,s_box,vf1,rf2,c)
-#endif
-
-/*----------------------------------------------------------------------
-| tables
-+---------------------------------------------------------------------*/
-#if defined(FIXED_TABLES) || !defined(FF_TABLES)
-
-/* finite field arithmetic operations */
-
-#define f2(x) ((x<<1) ^ (((x>>7) & 1) * WPOLY))
-#define f4(x) ((x<<2) ^ (((x>>6) & 1) * WPOLY) ^ (((x>>6) & 2) * WPOLY))
-#define f8(x) ((x<<3) ^ (((x>>5) & 1) * WPOLY) ^ (((x>>5) & 2) * WPOLY) \
- ^ (((x>>5) & 4) * WPOLY))
-#define f3(x) (f2(x) ^ x)
-#define f9(x) (f8(x) ^ x)
-#define fb(x) (f8(x) ^ f2(x) ^ x)
-#define fd(x) (f8(x) ^ f4(x) ^ x)
-#define fe(x) (f8(x) ^ f4(x) ^ f2(x))
-
-#endif
-
-#if defined(FIXED_TABLES)
-
-#define sb_data(w) \
- w(0x63), w(0x7c), w(0x77), w(0x7b), w(0xf2), w(0x6b), w(0x6f), w(0xc5),\
- w(0x30), w(0x01), w(0x67), w(0x2b), w(0xfe), w(0xd7), w(0xab), w(0x76),\
- w(0xca), w(0x82), w(0xc9), w(0x7d), w(0xfa), w(0x59), w(0x47), w(0xf0),\
- w(0xad), w(0xd4), w(0xa2), w(0xaf), w(0x9c), w(0xa4), w(0x72), w(0xc0),\
- w(0xb7), w(0xfd), w(0x93), w(0x26), w(0x36), w(0x3f), w(0xf7), w(0xcc),\
- w(0x34), w(0xa5), w(0xe5), w(0xf1), w(0x71), w(0xd8), w(0x31), w(0x15),\
- w(0x04), w(0xc7), w(0x23), w(0xc3), w(0x18), w(0x96), w(0x05), w(0x9a),\
- w(0x07), w(0x12), w(0x80), w(0xe2), w(0xeb), w(0x27), w(0xb2), w(0x75),\
- w(0x09), w(0x83), w(0x2c), w(0x1a), w(0x1b), w(0x6e), w(0x5a), w(0xa0),\
- w(0x52), w(0x3b), w(0xd6), w(0xb3), w(0x29), w(0xe3), w(0x2f), w(0x84),\
- w(0x53), w(0xd1), w(0x00), w(0xed), w(0x20), w(0xfc), w(0xb1), w(0x5b),\
- w(0x6a), w(0xcb), w(0xbe), w(0x39), w(0x4a), w(0x4c), w(0x58), w(0xcf),\
- w(0xd0), w(0xef), w(0xaa), w(0xfb), w(0x43), w(0x4d), w(0x33), w(0x85),\
- w(0x45), w(0xf9), w(0x02), w(0x7f), w(0x50), w(0x3c), w(0x9f), w(0xa8),\
- w(0x51), w(0xa3), w(0x40), w(0x8f), w(0x92), w(0x9d), w(0x38), w(0xf5),\
- w(0xbc), w(0xb6), w(0xda), w(0x21), w(0x10), w(0xff), w(0xf3), w(0xd2),\
- w(0xcd), w(0x0c), w(0x13), w(0xec), w(0x5f), w(0x97), w(0x44), w(0x17),\
- w(0xc4), w(0xa7), w(0x7e), w(0x3d), w(0x64), w(0x5d), w(0x19), w(0x73),\
- w(0x60), w(0x81), w(0x4f), w(0xdc), w(0x22), w(0x2a), w(0x90), w(0x88),\
- w(0x46), w(0xee), w(0xb8), w(0x14), w(0xde), w(0x5e), w(0x0b), w(0xdb),\
- w(0xe0), w(0x32), w(0x3a), w(0x0a), w(0x49), w(0x06), w(0x24), w(0x5c),\
- w(0xc2), w(0xd3), w(0xac), w(0x62), w(0x91), w(0x95), w(0xe4), w(0x79),\
- w(0xe7), w(0xc8), w(0x37), w(0x6d), w(0x8d), w(0xd5), w(0x4e), w(0xa9),\
- w(0x6c), w(0x56), w(0xf4), w(0xea), w(0x65), w(0x7a), w(0xae), w(0x08),\
- w(0xba), w(0x78), w(0x25), w(0x2e), w(0x1c), w(0xa6), w(0xb4), w(0xc6),\
- w(0xe8), w(0xdd), w(0x74), w(0x1f), w(0x4b), w(0xbd), w(0x8b), w(0x8a),\
- w(0x70), w(0x3e), w(0xb5), w(0x66), w(0x48), w(0x03), w(0xf6), w(0x0e),\
- w(0x61), w(0x35), w(0x57), w(0xb9), w(0x86), w(0xc1), w(0x1d), w(0x9e),\
- w(0xe1), w(0xf8), w(0x98), w(0x11), w(0x69), w(0xd9), w(0x8e), w(0x94),\
- w(0x9b), w(0x1e), w(0x87), w(0xe9), w(0xce), w(0x55), w(0x28), w(0xdf),\
- w(0x8c), w(0xa1), w(0x89), w(0x0d), w(0xbf), w(0xe6), w(0x42), w(0x68),\
- w(0x41), w(0x99), w(0x2d), w(0x0f), w(0xb0), w(0x54), w(0xbb), w(0x16)
-
-#define isb_data(w) \
- w(0x52), w(0x09), w(0x6a), w(0xd5), w(0x30), w(0x36), w(0xa5), w(0x38),\
- w(0xbf), w(0x40), w(0xa3), w(0x9e), w(0x81), w(0xf3), w(0xd7), w(0xfb),\
- w(0x7c), w(0xe3), w(0x39), w(0x82), w(0x9b), w(0x2f), w(0xff), w(0x87),\
- w(0x34), w(0x8e), w(0x43), w(0x44), w(0xc4), w(0xde), w(0xe9), w(0xcb),\
- w(0x54), w(0x7b), w(0x94), w(0x32), w(0xa6), w(0xc2), w(0x23), w(0x3d),\
- w(0xee), w(0x4c), w(0x95), w(0x0b), w(0x42), w(0xfa), w(0xc3), w(0x4e),\
- w(0x08), w(0x2e), w(0xa1), w(0x66), w(0x28), w(0xd9), w(0x24), w(0xb2),\
- w(0x76), w(0x5b), w(0xa2), w(0x49), w(0x6d), w(0x8b), w(0xd1), w(0x25),\
- w(0x72), w(0xf8), w(0xf6), w(0x64), w(0x86), w(0x68), w(0x98), w(0x16),\
- w(0xd4), w(0xa4), w(0x5c), w(0xcc), w(0x5d), w(0x65), w(0xb6), w(0x92),\
- w(0x6c), w(0x70), w(0x48), w(0x50), w(0xfd), w(0xed), w(0xb9), w(0xda),\
- w(0x5e), w(0x15), w(0x46), w(0x57), w(0xa7), w(0x8d), w(0x9d), w(0x84),\
- w(0x90), w(0xd8), w(0xab), w(0x00), w(0x8c), w(0xbc), w(0xd3), w(0x0a),\
- w(0xf7), w(0xe4), w(0x58), w(0x05), w(0xb8), w(0xb3), w(0x45), w(0x06),\
- w(0xd0), w(0x2c), w(0x1e), w(0x8f), w(0xca), w(0x3f), w(0x0f), w(0x02),\
- w(0xc1), w(0xaf), w(0xbd), w(0x03), w(0x01), w(0x13), w(0x8a), w(0x6b),\
- w(0x3a), w(0x91), w(0x11), w(0x41), w(0x4f), w(0x67), w(0xdc), w(0xea),\
- w(0x97), w(0xf2), w(0xcf), w(0xce), w(0xf0), w(0xb4), w(0xe6), w(0x73),\
- w(0x96), w(0xac), w(0x74), w(0x22), w(0xe7), w(0xad), w(0x35), w(0x85),\
- w(0xe2), w(0xf9), w(0x37), w(0xe8), w(0x1c), w(0x75), w(0xdf), w(0x6e),\
- w(0x47), w(0xf1), w(0x1a), w(0x71), w(0x1d), w(0x29), w(0xc5), w(0x89),\
- w(0x6f), w(0xb7), w(0x62), w(0x0e), w(0xaa), w(0x18), w(0xbe), w(0x1b),\
- w(0xfc), w(0x56), w(0x3e), w(0x4b), w(0xc6), w(0xd2), w(0x79), w(0x20),\
- w(0x9a), w(0xdb), w(0xc0), w(0xfe), w(0x78), w(0xcd), w(0x5a), w(0xf4),\
- w(0x1f), w(0xdd), w(0xa8), w(0x33), w(0x88), w(0x07), w(0xc7), w(0x31),\
- w(0xb1), w(0x12), w(0x10), w(0x59), w(0x27), w(0x80), w(0xec), w(0x5f),\
- w(0x60), w(0x51), w(0x7f), w(0xa9), w(0x19), w(0xb5), w(0x4a), w(0x0d),\
- w(0x2d), w(0xe5), w(0x7a), w(0x9f), w(0x93), w(0xc9), w(0x9c), w(0xef),\
- w(0xa0), w(0xe0), w(0x3b), w(0x4d), w(0xae), w(0x2a), w(0xf5), w(0xb0),\
- w(0xc8), w(0xeb), w(0xbb), w(0x3c), w(0x83), w(0x53), w(0x99), w(0x61),\
- w(0x17), w(0x2b), w(0x04), w(0x7e), w(0xba), w(0x77), w(0xd6), w(0x26),\
- w(0xe1), w(0x69), w(0x14), w(0x63), w(0x55), w(0x21), w(0x0c), w(0x7d),
-
-#define mm_data(w) \
- w(0x00), w(0x01), w(0x02), w(0x03), w(0x04), w(0x05), w(0x06), w(0x07),\
- w(0x08), w(0x09), w(0x0a), w(0x0b), w(0x0c), w(0x0d), w(0x0e), w(0x0f),\
- w(0x10), w(0x11), w(0x12), w(0x13), w(0x14), w(0x15), w(0x16), w(0x17),\
- w(0x18), w(0x19), w(0x1a), w(0x1b), w(0x1c), w(0x1d), w(0x1e), w(0x1f),\
- w(0x20), w(0x21), w(0x22), w(0x23), w(0x24), w(0x25), w(0x26), w(0x27),\
- w(0x28), w(0x29), w(0x2a), w(0x2b), w(0x2c), w(0x2d), w(0x2e), w(0x2f),\
- w(0x30), w(0x31), w(0x32), w(0x33), w(0x34), w(0x35), w(0x36), w(0x37),\
- w(0x38), w(0x39), w(0x3a), w(0x3b), w(0x3c), w(0x3d), w(0x3e), w(0x3f),\
- w(0x40), w(0x41), w(0x42), w(0x43), w(0x44), w(0x45), w(0x46), w(0x47),\
- w(0x48), w(0x49), w(0x4a), w(0x4b), w(0x4c), w(0x4d), w(0x4e), w(0x4f),\
- w(0x50), w(0x51), w(0x52), w(0x53), w(0x54), w(0x55), w(0x56), w(0x57),\
- w(0x58), w(0x59), w(0x5a), w(0x5b), w(0x5c), w(0x5d), w(0x5e), w(0x5f),\
- w(0x60), w(0x61), w(0x62), w(0x63), w(0x64), w(0x65), w(0x66), w(0x67),\
- w(0x68), w(0x69), w(0x6a), w(0x6b), w(0x6c), w(0x6d), w(0x6e), w(0x6f),\
- w(0x70), w(0x71), w(0x72), w(0x73), w(0x74), w(0x75), w(0x76), w(0x77),\
- w(0x78), w(0x79), w(0x7a), w(0x7b), w(0x7c), w(0x7d), w(0x7e), w(0x7f),\
- w(0x80), w(0x81), w(0x82), w(0x83), w(0x84), w(0x85), w(0x86), w(0x87),\
- w(0x88), w(0x89), w(0x8a), w(0x8b), w(0x8c), w(0x8d), w(0x8e), w(0x8f),\
- w(0x90), w(0x91), w(0x92), w(0x93), w(0x94), w(0x95), w(0x96), w(0x97),\
- w(0x98), w(0x99), w(0x9a), w(0x9b), w(0x9c), w(0x9d), w(0x9e), w(0x9f),\
- w(0xa0), w(0xa1), w(0xa2), w(0xa3), w(0xa4), w(0xa5), w(0xa6), w(0xa7),\
- w(0xa8), w(0xa9), w(0xaa), w(0xab), w(0xac), w(0xad), w(0xae), w(0xaf),\
- w(0xb0), w(0xb1), w(0xb2), w(0xb3), w(0xb4), w(0xb5), w(0xb6), w(0xb7),\
- w(0xb8), w(0xb9), w(0xba), w(0xbb), w(0xbc), w(0xbd), w(0xbe), w(0xbf),\
- w(0xc0), w(0xc1), w(0xc2), w(0xc3), w(0xc4), w(0xc5), w(0xc6), w(0xc7),\
- w(0xc8), w(0xc9), w(0xca), w(0xcb), w(0xcc), w(0xcd), w(0xce), w(0xcf),\
- w(0xd0), w(0xd1), w(0xd2), w(0xd3), w(0xd4), w(0xd5), w(0xd6), w(0xd7),\
- w(0xd8), w(0xd9), w(0xda), w(0xdb), w(0xdc), w(0xdd), w(0xde), w(0xdf),\
- w(0xe0), w(0xe1), w(0xe2), w(0xe3), w(0xe4), w(0xe5), w(0xe6), w(0xe7),\
- w(0xe8), w(0xe9), w(0xea), w(0xeb), w(0xec), w(0xed), w(0xee), w(0xef),\
- w(0xf0), w(0xf1), w(0xf2), w(0xf3), w(0xf4), w(0xf5), w(0xf6), w(0xf7),\
- w(0xf8), w(0xf9), w(0xfa), w(0xfb), w(0xfc), w(0xfd), w(0xfe), w(0xff)
-
-#define h0(x) (x)
-
-/* These defines are used to ensure tables are generated in the
- right format depending on the internal byte order required
-*/
-
-#define w0(p) bytes2word(p, 0, 0, 0)
-#define w1(p) bytes2word(0, p, 0, 0)
-#define w2(p) bytes2word(0, 0, p, 0)
-#define w3(p) bytes2word(0, 0, 0, p)
-
-/* Number of elements required in this table for different
- block and key lengths is:
-
- Rcon Table key length (bytes)
- Length 16 20 24 28 32
- ---------------------
- block 16 | 10 9 8 7 7
- length 20 | 14 11 10 9 9
- (bytes) 24 | 19 15 12 11 11
- 28 | 24 19 16 13 13
- 32 | 29 23 19 17 14
-
- this table can be a table of bytes if the key schedule
- code is adjusted accordingly
-*/
-
-#define u0(p) bytes2word(f2(p), p, p, f3(p))
-#define u1(p) bytes2word(f3(p), f2(p), p, p)
-#define u2(p) bytes2word(p, f3(p), f2(p), p)
-#define u3(p) bytes2word(p, p, f3(p), f2(p))
-
-#define v0(p) bytes2word(fe(p), f9(p), fd(p), fb(p))
-#define v1(p) bytes2word(fb(p), fe(p), f9(p), fd(p))
-#define v2(p) bytes2word(fd(p), fb(p), fe(p), f9(p))
-#define v3(p) bytes2word(f9(p), fd(p), fb(p), fe(p))
-
-static const aes_32t rcon_tab[29] =
-{
- w0(0x01), w0(0x02), w0(0x04), w0(0x08),
- w0(0x10), w0(0x20), w0(0x40), w0(0x80),
- w0(0x1b), w0(0x36), w0(0x6c), w0(0xd8),
- w0(0xab), w0(0x4d), w0(0x9a), w0(0x2f),
- w0(0x5e), w0(0xbc), w0(0x63), w0(0xc6),
- w0(0x97), w0(0x35), w0(0x6a), w0(0xd4),
- w0(0xb3), w0(0x7d), w0(0xfa), w0(0xef),
- w0(0xc5)
-};
-
-#ifdef SBX_SET
-static const aes_08t s_box[256] = { sb_data(h0) };
-#endif
-#ifdef ISB_SET
-static const aes_08t inv_s_box[256] = { isb_data(h0) };
-#endif
-
-#ifdef FT1_SET
-static const aes_32t ft_tab[256] = { sb_data(u0) };
-#endif
-#ifdef FT4_SET
-static const aes_32t ft_tab[4][256] =
- { { sb_data(u0) }, { sb_data(u1) }, { sb_data(u2) }, { sb_data(u3) } };
-#endif
-
-#ifdef FL1_SET
-static const aes_32t fl_tab[256] = { sb_data(w0) };
-#endif
-#ifdef FL4_SET
-static const aes_32t fl_tab[4][256] =
- { { sb_data(w0) }, { sb_data(w1) }, { sb_data(w2) }, { sb_data(w3) } };
-#endif
-
-#ifdef IT1_SET
-static const aes_32t it_tab[256] = { isb_data(v0) };
-#endif
-#ifdef IT4_SET
-static const aes_32t it_tab[4][256] =
- { { isb_data(v0) }, { isb_data(v1) }, { isb_data(v2) }, { isb_data(v3) } };
-#endif
-
-#ifdef IL1_SET
-static const aes_32t il_tab[256] = { isb_data(w0) };
-#endif
-#ifdef IL4_SET
-static const aes_32t il_tab[4][256] =
- { { isb_data(w0) }, { isb_data(w1) }, { isb_data(w2) }, { isb_data(w3) } };
-#endif
-
-#ifdef LS1_SET
-static const aes_32t ls_tab[256] = { sb_data(w0) };
-#endif
-#ifdef LS4_SET
-static const aes_32t ls_tab[4][256] =
- { { sb_data(w0) }, { sb_data(w1) }, { sb_data(w2) }, { sb_data(w3) } };
-#endif
-
-#ifdef IM1_SET
-static const aes_32t im_tab[256] = { mm_data(v0) };
-#endif
-#ifdef IM4_SET
-static const aes_32t im_tab[4][256] =
- { { mm_data(v0) }, { mm_data(v1) }, { mm_data(v2) }, { mm_data(v3) } };
-#endif
-
-#else /* dynamic table generation */
-
-aes_08t tab_init = 0;
-
-#define const
-
-static aes_32t rcon_tab[RC_LENGTH];
-
-#ifdef SBX_SET
-aes_08t s_box[256];
-#endif
-#ifdef ISB_SET
-aes_08t inv_s_box[256];
-#endif
-
-#ifdef FT1_SET
-aes_32t ft_tab[256];
-#endif
-#ifdef FT4_SET
-aes_32t ft_tab[4][256];
-#endif
-
-#ifdef FL1_SET
-aes_32t fl_tab[256];
-#endif
-#ifdef FL4_SET
-aes_32t fl_tab[4][256];
-#endif
-
-#ifdef IT1_SET
-aes_32t it_tab[256];
-#endif
-#ifdef IT4_SET
-aes_32t it_tab[4][256];
-#endif
-
-#ifdef IL1_SET
-aes_32t il_tab[256];
-#endif
-#ifdef IL4_SET
-aes_32t il_tab[4][256];
-#endif
-
-#ifdef LS1_SET
-aes_32t ls_tab[256];
-#endif
-#ifdef LS4_SET
-aes_32t ls_tab[4][256];
-#endif
-
-#ifdef IM1_SET
-aes_32t im_tab[256];
-#endif
-#ifdef IM4_SET
-aes_32t im_tab[4][256];
-#endif
-
-#if !defined(FF_TABLES)
-
-/* Generate the tables for the dynamic table option
-
- It will generally be sensible to use tables to compute finite
- field multiplies and inverses but where memory is scarse this
- code might sometimes be better. But it only has effect during
- initialisation so its pretty unimportant in overall terms.
-*/
-
-/* return 2 ^ (n - 1) where n is the bit number of the highest bit
- set in x with x in the range 1 < x < 0x00000200. This form is
- used so that locals within fi can be bytes rather than words
-*/
-
-static aes_08t hibit(const aes_32t x)
-{ aes_08t r = (aes_08t)((x >> 1) | (x >> 2));
-
- r |= (r >> 2);
- r |= (r >> 4);
- return (r + 1) >> 1;
-}
-
-/* return the inverse of the finite field element x */
-
-static aes_08t fi(const aes_08t x)
-{ aes_08t p1 = x, p2 = BPOLY, n1 = hibit(x), n2 = 0x80, v1 = 1, v2 = 0;
-
- if(x < 2) return x;
-
- for(;;)
- {
- if(!n1) return v1;
-
- while(n2 >= n1)
- {
- n2 /= n1; p2 ^= p1 * n2; v2 ^= v1 * n2; n2 = hibit(p2);
- }
-
- if(!n2) return v2;
-
- while(n1 >= n2)
- {
- n1 /= n2; p1 ^= p2 * n1; v1 ^= v2 * n1; n1 = hibit(p1);
- }
- }
-}
-
-#else
-
-/* define the finite field multiplies required for Rijndael */
-
-#define f2(x) ((x) ? pow[log[x] + 0x19] : 0)
-#define f3(x) ((x) ? pow[log[x] + 0x01] : 0)
-#define f9(x) ((x) ? pow[log[x] + 0xc7] : 0)
-#define fb(x) ((x) ? pow[log[x] + 0x68] : 0)
-#define fd(x) ((x) ? pow[log[x] + 0xee] : 0)
-#define fe(x) ((x) ? pow[log[x] + 0xdf] : 0)
-#define fi(x) ((x) ? pow[255 - log[x]]: 0)
-
-#endif
-
-/* The forward and inverse affine transformations used in the S-box */
-
-#define fwd_affine(x) \
- (w = (aes_32t)x, w ^= (w<<1)^(w<<2)^(w<<3)^(w<<4), 0x63^(aes_08t)(w^(w>>8)))
-
-#define inv_affine(x) \
- (w = (aes_32t)x, w = (w<<1)^(w<<3)^(w<<6), 0x05^(aes_08t)(w^(w>>8)))
-
-void gen_tabs(void)
-{ aes_32t i, w;
-
-#if defined(FF_TABLES)
-
- aes_08t pow[512], log[256];
-
- /* log and power tables for GF(2^8) finite field with
- WPOLY as modular polynomial - the simplest primitive
- root is 0x03, used here to generate the tables
- */
-
- i = 0; w = 1;
- do
- {
- pow[i] = (aes_08t)w;
- pow[i + 255] = (aes_08t)w;
- log[w] = (aes_08t)i++;
- w ^= (w << 1) ^ (w & 0x80 ? WPOLY : 0);
- }
- while (w != 1);
-
-#endif
-
- for(i = 0, w = 1; i < RC_LENGTH; ++i)
- {
- rcon_tab[i] = bytes2word(w, 0, 0, 0);
- w = f2(w);
- }
-
- for(i = 0; i < 256; ++i)
- { aes_08t b;
-
- b = fwd_affine(fi((aes_08t)i));
- w = bytes2word(f2(b), b, b, f3(b));
-
-#ifdef SBX_SET
- s_box[i] = b;
-#endif
-
-#ifdef FT1_SET /* tables for a normal encryption round */
- ft_tab[i] = w;
-#endif
-#ifdef FT4_SET
- ft_tab[0][i] = w;
- ft_tab[1][i] = upr(w,1);
- ft_tab[2][i] = upr(w,2);
- ft_tab[3][i] = upr(w,3);
-#endif
- w = bytes2word(b, 0, 0, 0);
-
-#ifdef FL1_SET /* tables for last encryption round (may also */
- fl_tab[i] = w; /* be used in the key schedule) */
-#endif
-#ifdef FL4_SET
- fl_tab[0][i] = w;
- fl_tab[1][i] = upr(w,1);
- fl_tab[2][i] = upr(w,2);
- fl_tab[3][i] = upr(w,3);
-#endif
-
-#ifdef LS1_SET /* table for key schedule if fl_tab above is */
- ls_tab[i] = w; /* not of the required form */
-#endif
-#ifdef LS4_SET
- ls_tab[0][i] = w;
- ls_tab[1][i] = upr(w,1);
- ls_tab[2][i] = upr(w,2);
- ls_tab[3][i] = upr(w,3);
-#endif
-
- b = fi(inv_affine((aes_08t)i));
- w = bytes2word(fe(b), f9(b), fd(b), fb(b));
-
-#ifdef IM1_SET /* tables for the inverse mix column operation */
- im_tab[b] = w;
-#endif
-#ifdef IM4_SET
- im_tab[0][b] = w;
- im_tab[1][b] = upr(w,1);
- im_tab[2][b] = upr(w,2);
- im_tab[3][b] = upr(w,3);
-#endif
-
-#ifdef ISB_SET
- inv_s_box[i] = b;
-#endif
-#ifdef IT1_SET /* tables for a normal decryption round */
- it_tab[i] = w;
-#endif
-#ifdef IT4_SET
- it_tab[0][i] = w;
- it_tab[1][i] = upr(w,1);
- it_tab[2][i] = upr(w,2);
- it_tab[3][i] = upr(w,3);
-#endif
- w = bytes2word(b, 0, 0, 0);
-#ifdef IL1_SET /* tables for last decryption round */
- il_tab[i] = w;
-#endif
-#ifdef IL4_SET
- il_tab[0][i] = w;
- il_tab[1][i] = upr(w,1);
- il_tab[2][i] = upr(w,2);
- il_tab[3][i] = upr(w,3);
-#endif
- }
-
- tab_init = 1;
-}
-
-#endif
-
-/*----------------------------------------------------------------------
-| key schedule
-+---------------------------------------------------------------------*/
-#if !defined(BLOCK_SIZE)
-
-static aes_rval aes_blk_len(unsigned int blen, aes_ctx cx[1])
-{
-#if !defined(FIXED_TABLES)
- if(!tab_init) gen_tabs();
-#endif
-
- if((blen & 7) || blen < 16 || blen > 32)
- {
- cx->n_blk = 0; return aes_bad;
- }
-
- cx->n_blk = blen;
- return aes_good;
-}
-
-#endif
-
-/* Initialise the key schedule from the user supplied key. The key
- length is now specified in bytes - 16, 24 or 32 as appropriate.
- This corresponds to bit lengths of 128, 192 and 256 bits, and
- to Nk values of 4, 6 and 8 respectively.
-
- The following macros implement a single cycle in the key
- schedule generation process. The number of cycles needed
- for each cx->n_col and nk value is:
-
- nk = 4 5 6 7 8
- ------------------------------
- cx->n_col = 4 10 9 8 7 7
- cx->n_col = 5 14 11 10 9 9
- cx->n_col = 6 19 15 12 11 11
- cx->n_col = 7 21 19 16 13 14
- cx->n_col = 8 29 23 19 17 14
-*/
-
-#define ke4(k,i) \
-{ k[4*(i)+4] = ss[0] ^= ls_box(ss[3],3) ^ rcon_tab[i]; k[4*(i)+5] = ss[1] ^= ss[0]; \
- k[4*(i)+6] = ss[2] ^= ss[1]; k[4*(i)+7] = ss[3] ^= ss[2]; \
-}
-#define kel4(k,i) \
-{ k[4*(i)+4] = ss[0] ^= ls_box(ss[3],3) ^ rcon_tab[i]; k[4*(i)+5] = ss[1] ^= ss[0]; \
- k[4*(i)+6] = ss[2] ^= ss[1]; k[4*(i)+7] = ss[3] ^= ss[2]; \
-}
-
-#define ke6(k,i) \
-{ k[6*(i)+ 6] = ss[0] ^= ls_box(ss[5],3) ^ rcon_tab[i]; k[6*(i)+ 7] = ss[1] ^= ss[0]; \
- k[6*(i)+ 8] = ss[2] ^= ss[1]; k[6*(i)+ 9] = ss[3] ^= ss[2]; \
- k[6*(i)+10] = ss[4] ^= ss[3]; k[6*(i)+11] = ss[5] ^= ss[4]; \
-}
-#define kel6(k,i) \
-{ k[6*(i)+ 6] = ss[0] ^= ls_box(ss[5],3) ^ rcon_tab[i]; k[6*(i)+ 7] = ss[1] ^= ss[0]; \
- k[6*(i)+ 8] = ss[2] ^= ss[1]; k[6*(i)+ 9] = ss[3] ^= ss[2]; \
-}
-
-#define ke8(k,i) \
-{ k[8*(i)+ 8] = ss[0] ^= ls_box(ss[7],3) ^ rcon_tab[i]; k[8*(i)+ 9] = ss[1] ^= ss[0]; \
- k[8*(i)+10] = ss[2] ^= ss[1]; k[8*(i)+11] = ss[3] ^= ss[2]; \
- k[8*(i)+12] = ss[4] ^= ls_box(ss[3],0); k[8*(i)+13] = ss[5] ^= ss[4]; \
- k[8*(i)+14] = ss[6] ^= ss[5]; k[8*(i)+15] = ss[7] ^= ss[6]; \
-}
-#define kel8(k,i) \
-{ k[8*(i)+ 8] = ss[0] ^= ls_box(ss[7],3) ^ rcon_tab[i]; k[8*(i)+ 9] = ss[1] ^= ss[0]; \
- k[8*(i)+10] = ss[2] ^= ss[1]; k[8*(i)+11] = ss[3] ^= ss[2]; \
-}
-
-#if defined(ENCRYPTION_KEY_SCHEDULE)
-
-static aes_rval aes_enc_key(const unsigned char in_key[], unsigned int klen, aes_ctx cx[1])
-{ aes_32t ss[8];
-
-#if !defined(FIXED_TABLES)
- if(!tab_init) gen_tabs();
-#endif
-
-#if !defined(BLOCK_SIZE)
- if(!cx->n_blk) cx->n_blk = 16;
-#else
- cx->n_blk = BLOCK_SIZE;
-#endif
-
- cx->n_blk = (cx->n_blk & ~3) | 1;
-
- cx->k_sch[0] = ss[0] = word_in(in_key );
- cx->k_sch[1] = ss[1] = word_in(in_key + 4);
- cx->k_sch[2] = ss[2] = word_in(in_key + 8);
- cx->k_sch[3] = ss[3] = word_in(in_key + 12);
-
-#if (BLOCK_SIZE == 16) && (ENC_UNROLL != NONE)
-
- switch(klen)
- {
- case 16: ke4(cx->k_sch, 0); ke4(cx->k_sch, 1);
- ke4(cx->k_sch, 2); ke4(cx->k_sch, 3);
- ke4(cx->k_sch, 4); ke4(cx->k_sch, 5);
- ke4(cx->k_sch, 6); ke4(cx->k_sch, 7);
- ke4(cx->k_sch, 8); kel4(cx->k_sch, 9);
- cx->n_rnd = 10; break;
- case 24: cx->k_sch[4] = ss[4] = word_in(in_key + 16);
- cx->k_sch[5] = ss[5] = word_in(in_key + 20);
- ke6(cx->k_sch, 0); ke6(cx->k_sch, 1);
- ke6(cx->k_sch, 2); ke6(cx->k_sch, 3);
- ke6(cx->k_sch, 4); ke6(cx->k_sch, 5);
- ke6(cx->k_sch, 6); kel6(cx->k_sch, 7);
- cx->n_rnd = 12; break;
- case 32: cx->k_sch[4] = ss[4] = word_in(in_key + 16);
- cx->k_sch[5] = ss[5] = word_in(in_key + 20);
- cx->k_sch[6] = ss[6] = word_in(in_key + 24);
- cx->k_sch[7] = ss[7] = word_in(in_key + 28);
- ke8(cx->k_sch, 0); ke8(cx->k_sch, 1);
- ke8(cx->k_sch, 2); ke8(cx->k_sch, 3);
- ke8(cx->k_sch, 4); ke8(cx->k_sch, 5);
- kel8(cx->k_sch, 6);
- cx->n_rnd = 14; break;
- default: cx->n_rnd = 0; return aes_bad;
- }
-#else
- { aes_32t i, l;
- cx->n_rnd = ((klen >> 2) > nc ? (klen >> 2) : nc) + 6;
- l = (nc * cx->n_rnd + nc - 1) / (klen >> 2);
-
- switch(klen)
- {
- case 16: for(i = 0; i < l; ++i)
- ke4(cx->k_sch, i);
- break;
- case 24: cx->k_sch[4] = ss[4] = word_in(in_key + 16);
- cx->k_sch[5] = ss[5] = word_in(in_key + 20);
- for(i = 0; i < l; ++i)
- ke6(cx->k_sch, i);
- break;
- case 32: cx->k_sch[4] = ss[4] = word_in(in_key + 16);
- cx->k_sch[5] = ss[5] = word_in(in_key + 20);
- cx->k_sch[6] = ss[6] = word_in(in_key + 24);
- cx->k_sch[7] = ss[7] = word_in(in_key + 28);
- for(i = 0; i < l; ++i)
- ke8(cx->k_sch, i);
- break;
- default: cx->n_rnd = 0; return aes_bad;
- }
- }
-#endif
-
- return aes_good;
-}
-
-#endif
-
-#if defined(DECRYPTION_KEY_SCHEDULE)
-
-#if (DEC_ROUND != NO_TABLES)
-#define d_vars dec_imvars
-#define ff(x) inv_mcol(x)
-#else
-#define ff(x) (x)
-#define d_vars
-#endif
-
-#if 1
-#define kdf4(k,i) \
-{ ss[0] = ss[0] ^ ss[2] ^ ss[1] ^ ss[3]; ss[1] = ss[1] ^ ss[3]; ss[2] = ss[2] ^ ss[3]; ss[3] = ss[3]; \
- ss[4] = ls_box(ss[(i+3) % 4], 3) ^ rcon_tab[i]; ss[i % 4] ^= ss[4]; \
- ss[4] ^= k[4*(i)]; k[4*(i)+4] = ff(ss[4]); ss[4] ^= k[4*(i)+1]; k[4*(i)+5] = ff(ss[4]); \
- ss[4] ^= k[4*(i)+2]; k[4*(i)+6] = ff(ss[4]); ss[4] ^= k[4*(i)+3]; k[4*(i)+7] = ff(ss[4]); \
-}
-#define kd4(k,i) \
-{ ss[4] = ls_box(ss[(i+3) % 4], 3) ^ rcon_tab[i]; ss[i % 4] ^= ss[4]; ss[4] = ff(ss[4]); \
- k[4*(i)+4] = ss[4] ^= k[4*(i)]; k[4*(i)+5] = ss[4] ^= k[4*(i)+1]; \
- k[4*(i)+6] = ss[4] ^= k[4*(i)+2]; k[4*(i)+7] = ss[4] ^= k[4*(i)+3]; \
-}
-#define kdl4(k,i) \
-{ ss[4] = ls_box(ss[(i+3) % 4], 3) ^ rcon_tab[i]; ss[i % 4] ^= ss[4]; \
- k[4*(i)+4] = (ss[0] ^= ss[1]) ^ ss[2] ^ ss[3]; k[4*(i)+5] = ss[1] ^ ss[3]; \
- k[4*(i)+6] = ss[0]; k[4*(i)+7] = ss[1]; \
-}
-#else
-#define kdf4(k,i) \
-{ ss[0] ^= ls_box(ss[3],3) ^ rcon_tab[i]; k[4*(i)+ 4] = ff(ss[0]); ss[1] ^= ss[0]; k[4*(i)+ 5] = ff(ss[1]); \
- ss[2] ^= ss[1]; k[4*(i)+ 6] = ff(ss[2]); ss[3] ^= ss[2]; k[4*(i)+ 7] = ff(ss[3]); \
-}
-#define kd4(k,i) \
-{ ss[4] = ls_box(ss[3],3) ^ rcon_tab[i]; \
- ss[0] ^= ss[4]; ss[4] = ff(ss[4]); k[4*(i)+ 4] = ss[4] ^= k[4*(i)]; \
- ss[1] ^= ss[0]; k[4*(i)+ 5] = ss[4] ^= k[4*(i)+ 1]; \
- ss[2] ^= ss[1]; k[4*(i)+ 6] = ss[4] ^= k[4*(i)+ 2]; \
- ss[3] ^= ss[2]; k[4*(i)+ 7] = ss[4] ^= k[4*(i)+ 3]; \
-}
-#define kdl4(k,i) \
-{ ss[0] ^= ls_box(ss[3],3) ^ rcon_tab[i]; k[4*(i)+ 4] = ss[0]; ss[1] ^= ss[0]; k[4*(i)+ 5] = ss[1]; \
- ss[2] ^= ss[1]; k[4*(i)+ 6] = ss[2]; ss[3] ^= ss[2]; k[4*(i)+ 7] = ss[3]; \
-}
-#endif
-
-#define kdf6(k,i) \
-{ ss[0] ^= ls_box(ss[5],3) ^ rcon_tab[i]; k[6*(i)+ 6] = ff(ss[0]); ss[1] ^= ss[0]; k[6*(i)+ 7] = ff(ss[1]); \
- ss[2] ^= ss[1]; k[6*(i)+ 8] = ff(ss[2]); ss[3] ^= ss[2]; k[6*(i)+ 9] = ff(ss[3]); \
- ss[4] ^= ss[3]; k[6*(i)+10] = ff(ss[4]); ss[5] ^= ss[4]; k[6*(i)+11] = ff(ss[5]); \
-}
-#define kd6(k,i) \
-{ ss[6] = ls_box(ss[5],3) ^ rcon_tab[i]; \
- ss[0] ^= ss[6]; ss[6] = ff(ss[6]); k[6*(i)+ 6] = ss[6] ^= k[6*(i)]; \
- ss[1] ^= ss[0]; k[6*(i)+ 7] = ss[6] ^= k[6*(i)+ 1]; \
- ss[2] ^= ss[1]; k[6*(i)+ 8] = ss[6] ^= k[6*(i)+ 2]; \
- ss[3] ^= ss[2]; k[6*(i)+ 9] = ss[6] ^= k[6*(i)+ 3]; \
- ss[4] ^= ss[3]; k[6*(i)+10] = ss[6] ^= k[6*(i)+ 4]; \
- ss[5] ^= ss[4]; k[6*(i)+11] = ss[6] ^= k[6*(i)+ 5]; \
-}
-#define kdl6(k,i) \
-{ ss[0] ^= ls_box(ss[5],3) ^ rcon_tab[i]; k[6*(i)+ 6] = ss[0]; ss[1] ^= ss[0]; k[6*(i)+ 7] = ss[1]; \
- ss[2] ^= ss[1]; k[6*(i)+ 8] = ss[2]; ss[3] ^= ss[2]; k[6*(i)+ 9] = ss[3]; \
-}
-
-#define kdf8(k,i) \
-{ ss[0] ^= ls_box(ss[7],3) ^ rcon_tab[i]; k[8*(i)+ 8] = ff(ss[0]); ss[1] ^= ss[0]; k[8*(i)+ 9] = ff(ss[1]); \
- ss[2] ^= ss[1]; k[8*(i)+10] = ff(ss[2]); ss[3] ^= ss[2]; k[8*(i)+11] = ff(ss[3]); \
- ss[4] ^= ls_box(ss[3],0); k[8*(i)+12] = ff(ss[4]); ss[5] ^= ss[4]; k[8*(i)+13] = ff(ss[5]); \
- ss[6] ^= ss[5]; k[8*(i)+14] = ff(ss[6]); ss[7] ^= ss[6]; k[8*(i)+15] = ff(ss[7]); \
-}
-#define kd8(k,i) \
-{ aes_32t g = ls_box(ss[7],3) ^ rcon_tab[i]; \
- ss[0] ^= g; g = ff(g); k[8*(i)+ 8] = g ^= k[8*(i)]; \
- ss[1] ^= ss[0]; k[8*(i)+ 9] = g ^= k[8*(i)+ 1]; \
- ss[2] ^= ss[1]; k[8*(i)+10] = g ^= k[8*(i)+ 2]; \
- ss[3] ^= ss[2]; k[8*(i)+11] = g ^= k[8*(i)+ 3]; \
- g = ls_box(ss[3],0); \
- ss[4] ^= g; g = ff(g); k[8*(i)+12] = g ^= k[8*(i)+ 4]; \
- ss[5] ^= ss[4]; k[8*(i)+13] = g ^= k[8*(i)+ 5]; \
- ss[6] ^= ss[5]; k[8*(i)+14] = g ^= k[8*(i)+ 6]; \
- ss[7] ^= ss[6]; k[8*(i)+15] = g ^= k[8*(i)+ 7]; \
-}
-#define kdl8(k,i) \
-{ ss[0] ^= ls_box(ss[7],3) ^ rcon_tab[i]; k[8*(i)+ 8] = ss[0]; ss[1] ^= ss[0]; k[8*(i)+ 9] = ss[1]; \
- ss[2] ^= ss[1]; k[8*(i)+10] = ss[2]; ss[3] ^= ss[2]; k[8*(i)+11] = ss[3]; \
-}
-
-static aes_rval aes_dec_key(const unsigned char in_key[], unsigned int klen, aes_ctx cx[1])
-{ aes_32t ss[8];
- d_vars
-
-#if !defined(FIXED_TABLES)
- if(!tab_init) gen_tabs();
-#endif
-
-#if !defined(BLOCK_SIZE)
- if(!cx->n_blk) cx->n_blk = 16;
-#else
- cx->n_blk = BLOCK_SIZE;
-#endif
-
- cx->n_blk = (cx->n_blk & ~3) | 2;
-
- cx->k_sch[0] = ss[0] = word_in(in_key );
- cx->k_sch[1] = ss[1] = word_in(in_key + 4);
- cx->k_sch[2] = ss[2] = word_in(in_key + 8);
- cx->k_sch[3] = ss[3] = word_in(in_key + 12);
-
-#if (BLOCK_SIZE == 16) && (DEC_UNROLL != NONE)
-
- switch(klen)
- {
- case 16: kdf4(cx->k_sch, 0); kd4(cx->k_sch, 1);
- kd4(cx->k_sch, 2); kd4(cx->k_sch, 3);
- kd4(cx->k_sch, 4); kd4(cx->k_sch, 5);
- kd4(cx->k_sch, 6); kd4(cx->k_sch, 7);
- kd4(cx->k_sch, 8); kdl4(cx->k_sch, 9);
- cx->n_rnd = 10; break;
- case 24: cx->k_sch[4] = ff(ss[4] = word_in(in_key + 16));
- cx->k_sch[5] = ff(ss[5] = word_in(in_key + 20));
- kdf6(cx->k_sch, 0); kd6(cx->k_sch, 1);
- kd6(cx->k_sch, 2); kd6(cx->k_sch, 3);
- kd6(cx->k_sch, 4); kd6(cx->k_sch, 5);
- kd6(cx->k_sch, 6); kdl6(cx->k_sch, 7);
- cx->n_rnd = 12; break;
- case 32: cx->k_sch[4] = ff(ss[4] = word_in(in_key + 16));
- cx->k_sch[5] = ff(ss[5] = word_in(in_key + 20));
- cx->k_sch[6] = ff(ss[6] = word_in(in_key + 24));
- cx->k_sch[7] = ff(ss[7] = word_in(in_key + 28));
- kdf8(cx->k_sch, 0); kd8(cx->k_sch, 1);
- kd8(cx->k_sch, 2); kd8(cx->k_sch, 3);
- kd8(cx->k_sch, 4); kd8(cx->k_sch, 5);
- kdl8(cx->k_sch, 6);
- cx->n_rnd = 14; break;
- default: cx->n_rnd = 0; return aes_bad;
- }
-#else
- { aes_32t i, l;
- cx->n_rnd = ((klen >> 2) > nc ? (klen >> 2) : nc) + 6;
- l = (nc * cx->n_rnd + nc - 1) / (klen >> 2);
-
- switch(klen)
- {
- case 16:
- for(i = 0; i < l; ++i)
- ke4(cx->k_sch, i);
- break;
- case 24: cx->k_sch[4] = ss[4] = word_in(in_key + 16);
- cx->k_sch[5] = ss[5] = word_in(in_key + 20);
- for(i = 0; i < l; ++i)
- ke6(cx->k_sch, i);
- break;
- case 32: cx->k_sch[4] = ss[4] = word_in(in_key + 16);
- cx->k_sch[5] = ss[5] = word_in(in_key + 20);
- cx->k_sch[6] = ss[6] = word_in(in_key + 24);
- cx->k_sch[7] = ss[7] = word_in(in_key + 28);
- for(i = 0; i < l; ++i)
- ke8(cx->k_sch, i);
- break;
- default: cx->n_rnd = 0; return aes_bad;
- }
-#if (DEC_ROUND != NO_TABLES)
- for(i = nc; i < nc * cx->n_rnd; ++i)
- cx->k_sch[i] = inv_mcol(cx->k_sch[i]);
-#endif
- }
-#endif
-
- return aes_good;
-}
-
-#endif
-
-/*----------------------------------------------------------------------
-| cipher
-+---------------------------------------------------------------------*/
-#define unused 77 /* Sunset Strip */
-
-#define si(y,x,k,c) s(y,c) = word_in(x + 4 * c) ^ k[c]
-#define so(y,x,c) word_out(y + 4 * c, s(x,c))
-
-#if BLOCK_SIZE == 16
-
-#if defined(ARRAYS)
-#define locals(y,x) x[4],y[4]
-#else
-#define locals(y,x) x##0,x##1,x##2,x##3,y##0,y##1,y##2,y##3
- /*
- the following defines prevent the compiler requiring the declaration
- of generated but unused variables in the fwd_var and inv_var macros
- */
-#define b04 unused
-#define b05 unused
-#define b06 unused
-#define b07 unused
-#define b14 unused
-#define b15 unused
-#define b16 unused
-#define b17 unused
-#endif
-#define l_copy(y, x) s(y,0) = s(x,0); s(y,1) = s(x,1); \
- s(y,2) = s(x,2); s(y,3) = s(x,3);
-#define state_in(y,x,k) si(y,x,k,0); si(y,x,k,1); si(y,x,k,2); si(y,x,k,3)
-#define state_out(y,x) so(y,x,0); so(y,x,1); so(y,x,2); so(y,x,3)
-#define round(rm,y,x,k) rm(y,x,k,0); rm(y,x,k,1); rm(y,x,k,2); rm(y,x,k,3)
-
-#elif BLOCK_SIZE == 24
-
-#if defined(ARRAYS)
-#define locals(y,x) x[6],y[6]
-#else
-#define locals(y,x) x##0,x##1,x##2,x##3,x##4,x##5, \
- y##0,y##1,y##2,y##3,y##4,y##5
-#define b06 unused
-#define b07 unused
-#define b16 unused
-#define b17 unused
-#endif
-#define l_copy(y, x) s(y,0) = s(x,0); s(y,1) = s(x,1); \
- s(y,2) = s(x,2); s(y,3) = s(x,3); \
- s(y,4) = s(x,4); s(y,5) = s(x,5);
-#define state_in(y,x,k) si(y,x,k,0); si(y,x,k,1); si(y,x,k,2); \
- si(y,x,k,3); si(y,x,k,4); si(y,x,k,5)
-#define state_out(y,x) so(y,x,0); so(y,x,1); so(y,x,2); \
- so(y,x,3); so(y,x,4); so(y,x,5)
-#define round(rm,y,x,k) rm(y,x,k,0); rm(y,x,k,1); rm(y,x,k,2); \
- rm(y,x,k,3); rm(y,x,k,4); rm(y,x,k,5)
-#else
-
-#if defined(ARRAYS)
-#define locals(y,x) x[8],y[8]
-#else
-#define locals(y,x) x##0,x##1,x##2,x##3,x##4,x##5,x##6,x##7, \
- y##0,y##1,y##2,y##3,y##4,y##5,y##6,y##7
-#endif
-#define l_copy(y, x) s(y,0) = s(x,0); s(y,1) = s(x,1); \
- s(y,2) = s(x,2); s(y,3) = s(x,3); \
- s(y,4) = s(x,4); s(y,5) = s(x,5); \
- s(y,6) = s(x,6); s(y,7) = s(x,7);
-
-#if BLOCK_SIZE == 32
-
-#define state_in(y,x,k) si(y,x,k,0); si(y,x,k,1); si(y,x,k,2); si(y,x,k,3); \
- si(y,x,k,4); si(y,x,k,5); si(y,x,k,6); si(y,x,k,7)
-#define state_out(y,x) so(y,x,0); so(y,x,1); so(y,x,2); so(y,x,3); \
- so(y,x,4); so(y,x,5); so(y,x,6); so(y,x,7)
-#define round(rm,y,x,k) rm(y,x,k,0); rm(y,x,k,1); rm(y,x,k,2); rm(y,x,k,3); \
- rm(y,x,k,4); rm(y,x,k,5); rm(y,x,k,6); rm(y,x,k,7)
-#else
-
-#define state_in(y,x,k) \
-switch(nc) \
-{ case 8: si(y,x,k,7); si(y,x,k,6); \
- case 6: si(y,x,k,5); si(y,x,k,4); \
- case 4: si(y,x,k,3); si(y,x,k,2); \
- si(y,x,k,1); si(y,x,k,0); \
-}
-
-#define state_out(y,x) \
-switch(nc) \
-{ case 8: so(y,x,7); so(y,x,6); \
- case 6: so(y,x,5); so(y,x,4); \
- case 4: so(y,x,3); so(y,x,2); \
- so(y,x,1); so(y,x,0); \
-}
-
-#if defined(FAST_VARIABLE)
-
-#define round(rm,y,x,k) \
-switch(nc) \
-{ case 8: rm(y,x,k,7); rm(y,x,k,6); \
- rm(y,x,k,5); rm(y,x,k,4); \
- rm(y,x,k,3); rm(y,x,k,2); \
- rm(y,x,k,1); rm(y,x,k,0); \
- break; \
- case 6: rm(y,x,k,5); rm(y,x,k,4); \
- rm(y,x,k,3); rm(y,x,k,2); \
- rm(y,x,k,1); rm(y,x,k,0); \
- break; \
- case 4: rm(y,x,k,3); rm(y,x,k,2); \
- rm(y,x,k,1); rm(y,x,k,0); \
- break; \
-}
-#else
-
-#define round(rm,y,x,k) \
-switch(nc) \
-{ case 8: rm(y,x,k,7); rm(y,x,k,6); \
- case 6: rm(y,x,k,5); rm(y,x,k,4); \
- case 4: rm(y,x,k,3); rm(y,x,k,2); \
- rm(y,x,k,1); rm(y,x,k,0); \
-}
-
-#endif
-
-#endif
-#endif
-
-#if defined(ENCRYPTION)
-
-/* I am grateful to Frank Yellin for the following construction
- (and that for decryption) which, given the column (c) of the
- output state variable, gives the input state variables which
- are needed in its computation for each row (r) of the state.
-
- For the fixed block size options, compilers should be able to
- reduce this complex expression (and the equivalent one for
- decryption) to a static variable reference at compile time.
- But for variable block size code, there will be some limbs on
- which conditional clauses will be returned.
-*/
-
-/* y = output word, x = input word, r = row, c = column for r = 0,
- 1, 2 and 3 = column accessed for row r.
-*/
-
-#define fwd_var(x,r,c)\
- ( r == 0 ? \
- ( c == 0 ? s(x,0) \
- : c == 1 ? s(x,1) \
- : c == 2 ? s(x,2) \
- : c == 3 ? s(x,3) \
- : c == 4 ? s(x,4) \
- : c == 5 ? s(x,5) \
- : c == 6 ? s(x,6) \
- : s(x,7))\
- : r == 1 ? \
- ( c == 0 ? s(x,1) \
- : c == 1 ? s(x,2) \
- : c == 2 ? s(x,3) \
- : c == 3 ? nc == 4 ? s(x,0) : s(x,4) \
- : c == 4 ? s(x,5) \
- : c == 5 ? nc == 8 ? s(x,6) : s(x,0) \
- : c == 6 ? s(x,7) \
- : s(x,0))\
- : r == 2 ? \
- ( c == 0 ? nc == 8 ? s(x,3) : s(x,2) \
- : c == 1 ? nc == 8 ? s(x,4) : s(x,3) \
- : c == 2 ? nc == 4 ? s(x,0) : nc == 8 ? s(x,5) : s(x,4) \
- : c == 3 ? nc == 4 ? s(x,1) : nc == 8 ? s(x,6) : s(x,5) \
- : c == 4 ? nc == 8 ? s(x,7) : s(x,0) \
- : c == 5 ? nc == 8 ? s(x,0) : s(x,1) \
- : c == 6 ? s(x,1) \
- : s(x,2))\
- : \
- ( c == 0 ? nc == 8 ? s(x,4) : s(x,3) \
- : c == 1 ? nc == 4 ? s(x,0) : nc == 8 ? s(x,5) : s(x,4) \
- : c == 2 ? nc == 4 ? s(x,1) : nc == 8 ? s(x,6) : s(x,5) \
- : c == 3 ? nc == 4 ? s(x,2) : nc == 8 ? s(x,7) : s(x,0) \
- : c == 4 ? nc == 8 ? s(x,0) : s(x,1) \
- : c == 5 ? nc == 8 ? s(x,1) : s(x,2) \
- : c == 6 ? s(x,2) \
- : s(x,3)))
-
-#if defined(FT4_SET)
-#undef dec_fmvars
-#define dec_fmvars
-#define fwd_rnd(y,x,k,c) s(y,c)= (k)[c] ^ four_tables(x,ft_tab,fwd_var,rf1,c)
-#elif defined(FT1_SET)
-#undef dec_fmvars
-#define dec_fmvars
-#define fwd_rnd(y,x,k,c) s(y,c)= (k)[c] ^ one_table(x,upr,ft_tab,fwd_var,rf1,c)
-#else
-#define fwd_rnd(y,x,k,c) s(y,c) = fwd_mcol(no_table(x,s_box,fwd_var,rf1,c)) ^ (k)[c]
-#endif
-
-#if defined(FL4_SET)
-#define fwd_lrnd(y,x,k,c) s(y,c)= (k)[c] ^ four_tables(x,fl_tab,fwd_var,rf1,c)
-#elif defined(FL1_SET)
-#define fwd_lrnd(y,x,k,c) s(y,c)= (k)[c] ^ one_table(x,ups,fl_tab,fwd_var,rf1,c)
-#else
-#define fwd_lrnd(y,x,k,c) s(y,c) = no_table(x,s_box,fwd_var,rf1,c) ^ (k)[c]
-#endif
-
-static aes_rval aes_enc_blk(const unsigned char in_blk[], unsigned char out_blk[], const aes_ctx cx[1])
-{ aes_32t locals(b0, b1);
- const aes_32t *kp = cx->k_sch;
- dec_fmvars /* declare variables for fwd_mcol() if needed */
-
- if(!(cx->n_blk & 1)) return aes_bad;
-
- state_in(b0, in_blk, kp);
-
-#if (ENC_UNROLL == FULL)
-
- kp += (cx->n_rnd - 9) * nc;
-
- switch(cx->n_rnd)
- {
- case 14: round(fwd_rnd, b1, b0, kp - 4 * nc);
- round(fwd_rnd, b0, b1, kp - 3 * nc);
- case 12: round(fwd_rnd, b1, b0, kp - 2 * nc);
- round(fwd_rnd, b0, b1, kp - nc);
- case 10: round(fwd_rnd, b1, b0, kp );
- round(fwd_rnd, b0, b1, kp + nc);
- round(fwd_rnd, b1, b0, kp + 2 * nc);
- round(fwd_rnd, b0, b1, kp + 3 * nc);
- round(fwd_rnd, b1, b0, kp + 4 * nc);
- round(fwd_rnd, b0, b1, kp + 5 * nc);
- round(fwd_rnd, b1, b0, kp + 6 * nc);
- round(fwd_rnd, b0, b1, kp + 7 * nc);
- round(fwd_rnd, b1, b0, kp + 8 * nc);
- round(fwd_lrnd, b0, b1, kp + 9 * nc);
- }
-#else
-
-#if (ENC_UNROLL == PARTIAL)
- { aes_32t rnd;
- for(rnd = 0; rnd < (cx->n_rnd >> 1) - 1; ++rnd)
- {
- kp += nc;
- round(fwd_rnd, b1, b0, kp);
- kp += nc;
- round(fwd_rnd, b0, b1, kp);
- }
- kp += nc;
- round(fwd_rnd, b1, b0, kp);
-#else
- { aes_32t rnd, *p0 = b0, *p1 = b1, *pt;
- for(rnd = 0; rnd < cx->n_rnd - 1; ++rnd)
- {
- kp += nc;
- round(fwd_rnd, p1, p0, kp);
- pt = p0, p0 = p1, p1 = pt;
- }
-#endif
- kp += nc;
- round(fwd_lrnd, b0, b1, kp);
- }
-#endif
-
- state_out(out_blk, b0);
- return aes_good;
-}
-
-#endif
-
-#if defined(DECRYPTION)
-
-#define inv_var(x,r,c) \
- ( r == 0 ? \
- ( c == 0 ? s(x,0) \
- : c == 1 ? s(x,1) \
- : c == 2 ? s(x,2) \
- : c == 3 ? s(x,3) \
- : c == 4 ? s(x,4) \
- : c == 5 ? s(x,5) \
- : c == 6 ? s(x,6) \
- : s(x,7))\
- : r == 1 ? \
- ( c == 0 ? nc == 4 ? s(x,3) : nc == 8 ? s(x,7) : s(x,5) \
- : c == 1 ? s(x,0) \
- : c == 2 ? s(x,1) \
- : c == 3 ? s(x,2) \
- : c == 4 ? s(x,3) \
- : c == 5 ? s(x,4) \
- : c == 6 ? s(x,5) \
- : s(x,6))\
- : r == 2 ? \
- ( c == 0 ? nc == 4 ? s(x,2) : nc == 8 ? s(x,5) : s(x,4) \
- : c == 1 ? nc == 4 ? s(x,3) : nc == 8 ? s(x,6) : s(x,5) \
- : c == 2 ? nc == 8 ? s(x,7) : s(x,0) \
- : c == 3 ? nc == 8 ? s(x,0) : s(x,1) \
- : c == 4 ? nc == 8 ? s(x,1) : s(x,2) \
- : c == 5 ? nc == 8 ? s(x,2) : s(x,3) \
- : c == 6 ? s(x,3) \
- : s(x,4))\
- : \
- ( c == 0 ? nc == 4 ? s(x,1) : nc == 8 ? s(x,4) : s(x,3) \
- : c == 1 ? nc == 4 ? s(x,2) : nc == 8 ? s(x,5) : s(x,4) \
- : c == 2 ? nc == 4 ? s(x,3) : nc == 8 ? s(x,6) : s(x,5) \
- : c == 3 ? nc == 8 ? s(x,7) : s(x,0) \
- : c == 4 ? nc == 8 ? s(x,0) : s(x,1) \
- : c == 5 ? nc == 8 ? s(x,1) : s(x,2) \
- : c == 6 ? s(x,2) \
- : s(x,3)))
-
-#if defined(IT4_SET)
-#undef dec_imvars
-#define dec_imvars
-#define inv_rnd(y,x,k,c) s(y,c)= (k)[c] ^ four_tables(x,it_tab,inv_var,rf1,c)
-#elif defined(IT1_SET)
-#undef dec_imvars
-#define dec_imvars
-#define inv_rnd(y,x,k,c) s(y,c)= (k)[c] ^ one_table(x,upr,it_tab,inv_var,rf1,c)
-#else
-#define inv_rnd(y,x,k,c) s(y,c) = inv_mcol(no_table(x,inv_s_box,inv_var,rf1,c) ^ (k)[c])
-#endif
-
-#if defined(IL4_SET)
-#define inv_lrnd(y,x,k,c) s(y,c)= (k)[c] ^ four_tables(x,il_tab,inv_var,rf1,c)
-#elif defined(IL1_SET)
-#define inv_lrnd(y,x,k,c) s(y,c)= (k)[c] ^ one_table(x,ups,il_tab,inv_var,rf1,c)
-#else
-#define inv_lrnd(y,x,k,c) s(y,c) = no_table(x,inv_s_box,inv_var,rf1,c) ^ (k)[c]
-#endif
-
-static aes_rval aes_dec_blk(const unsigned char in_blk[], unsigned char out_blk[], const aes_ctx cx[1])
-{ aes_32t locals(b0, b1);
- const aes_32t *kp = cx->k_sch + nc * cx->n_rnd;
- dec_imvars /* declare variables for inv_mcol() if needed */
-
- if(!(cx->n_blk & 2)) return aes_bad;
-
- state_in(b0, in_blk, kp);
-
-#if (DEC_UNROLL == FULL)
-
- kp = cx->k_sch + 9 * nc;
- switch(cx->n_rnd)
- {
- case 14: round(inv_rnd, b1, b0, kp + 4 * nc);
- round(inv_rnd, b0, b1, kp + 3 * nc);
- case 12: round(inv_rnd, b1, b0, kp + 2 * nc);
- round(inv_rnd, b0, b1, kp + nc );
- case 10: round(inv_rnd, b1, b0, kp );
- round(inv_rnd, b0, b1, kp - nc);
- round(inv_rnd, b1, b0, kp - 2 * nc);
- round(inv_rnd, b0, b1, kp - 3 * nc);
- round(inv_rnd, b1, b0, kp - 4 * nc);
- round(inv_rnd, b0, b1, kp - 5 * nc);
- round(inv_rnd, b1, b0, kp - 6 * nc);
- round(inv_rnd, b0, b1, kp - 7 * nc);
- round(inv_rnd, b1, b0, kp - 8 * nc);
- round(inv_lrnd, b0, b1, kp - 9 * nc);
- }
-#else
-
-#if (DEC_UNROLL == PARTIAL)
- { aes_32t rnd;
- for(rnd = 0; rnd < (cx->n_rnd >> 1) - 1; ++rnd)
- {
- kp -= nc;
- round(inv_rnd, b1, b0, kp);
- kp -= nc;
- round(inv_rnd, b0, b1, kp);
- }
- kp -= nc;
- round(inv_rnd, b1, b0, kp);
-#else
- { aes_32t rnd, *p0 = b0, *p1 = b1, *pt;
- for(rnd = 0; rnd < cx->n_rnd - 1; ++rnd)
- {
- kp -= nc;
- round(inv_rnd, p1, p0, kp);
- pt = p0, p0 = p1, p1 = pt;
- }
-#endif
- kp -= nc;
- round(inv_lrnd, b0, b1, kp);
- }
-#endif
-
- state_out(out_blk, b0);
- return aes_good;
-}
-
-#endif
-
-/*----------------------------------------------------------------------
-| AP4_AesBlockCipher::AP4_AesBlockCipher
-+---------------------------------------------------------------------*/
-AP4_AesBlockCipher::AP4_AesBlockCipher(const AP4_UI08* key)
-{
- aes_enc_key(key, AP4_AES_KEY_LENGTH, &m_Context);
-}
-
-/*----------------------------------------------------------------------
-| AP4_AesBlockCipher::~AP4_AesBlockCipher
-+---------------------------------------------------------------------*/
-AP4_AesBlockCipher::~AP4_AesBlockCipher()
-{
-}
-
-/*----------------------------------------------------------------------
-| AP4_AesCipher::EncryptBlock
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_AesBlockCipher::EncryptBlock(const AP4_UI08* block_in, AP4_UI08* block_out)
-{
- aes_rval result;
- result = aes_enc_blk(block_in, block_out, &m_Context);
- return result == aes_good ? AP4_SUCCESS : AP4_FAILURE;
-}
-
diff --git a/src/thirdparty/Bento4/Crypto/Ap4AesBlockCipher.h b/src/thirdparty/Bento4/Crypto/Ap4AesBlockCipher.h
deleted file mode 100644
index 71137a063..000000000
--- a/src/thirdparty/Bento4/Crypto/Ap4AesBlockCipher.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * AES Block cipher
- * (c) 2005 Gilles Boccon-Gibod
- * Portions (c) 2001, Dr Brian Gladman (see below)
- */
-
-/*
- -------------------------------------------------------------------------
- Copyright (c) 2001, Dr Brian Gladman <brg@gladman.me.uk>, Worcester, UK.
- All rights reserved.
-
- LICENSE TERMS
-
- The free distribution and use of this software in both source and binary
- form is allowed (with or without changes) provided that:
-
- 1. distributions of this source code include the above copyright
- notice, this list of conditions and the following disclaimer;
-
- 2. distributions in binary form include the above copyright
- notice, this list of conditions and the following disclaimer
- in the documentation and/or other associated materials;
-
- 3. the copyright holder's name is not used to endorse products
- built using this software without specific written permission.
-
- DISCLAIMER
-
- This software is provided 'as is' with no explicit or implied warranties
- in respect of its properties, including, but not limited to, correctness
- and fitness for purpose.
- -------------------------------------------------------------------------
- Issue Date: 29/07/2002
-*/
-
-#ifndef _AP4_AES_BLOCK_CIPHER_H_
-#define _AP4_AES_BLOCK_CIPHER_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4Types.h"
-#include "Ap4Config.h"
-
-/*----------------------------------------------------------------------
-| AES constants
-+---------------------------------------------------------------------*/
-#define AP4_AES_BLOCK_SIZE 16
-#define AP4_AES_KEY_LENGTH 16
-
-/*----------------------------------------------------------------------
-| AES types
-+---------------------------------------------------------------------*/
-typedef AP4_UI32 aes_32t;
-typedef AP4_UI08 aes_08t;
-typedef unsigned int aes_rval;
-typedef struct // the AES context for encryption
-{ aes_32t k_sch[4*AP4_AES_BLOCK_SIZE]; // the encryption key schedule
- aes_32t n_rnd; // the number of cipher rounds
- aes_32t n_blk; // the number of bytes in the state
-} aes_ctx;
-#define aes_bad 0 // bad function return value
-#define aes_good 1 // good function return value
-
-/*----------------------------------------------------------------------
-| AP4_AesBlockCipher class
-+---------------------------------------------------------------------*/
-class AP4_AesBlockCipher
-{
- public:
- // constructor and destructor
- AP4_AesBlockCipher(const AP4_UI08* key);
- ~AP4_AesBlockCipher();
-
- // methods
- AP4_Result EncryptBlock(const AP4_UI08* block_in, AP4_UI08* block_out);
-
- private:
- aes_ctx m_Context;
-};
-
-#endif // _AP4_AES_BLOCK_CIPHER_H_
diff --git a/src/thirdparty/Bento4/Crypto/Ap4StreamCipher.cpp b/src/thirdparty/Bento4/Crypto/Ap4StreamCipher.cpp
deleted file mode 100644
index dc150175a..000000000
--- a/src/thirdparty/Bento4/Crypto/Ap4StreamCipher.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (c) 2005 Gilles Boccon-Gibod
- */
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4.h"
-#include "Ap4StreamCipher.h"
-
-/*----------------------------------------------------------------------
-| AP4_StreamCipher::AP4_StreamCipher
-+---------------------------------------------------------------------*/
-AP4_StreamCipher::AP4_StreamCipher(const AP4_UI08* key,
- const AP4_UI08* salt,
- AP4_Size iv_size) :
- m_StreamOffset(0),
- m_IvSize(iv_size),
- m_BlockCipher(NULL)
-{
- // clamp the IV size to the max supported size
- if (iv_size > 4) {
- m_IvSize = 4;
- }
-
- // set the initial state
- Reset(key, salt);
-}
-
-/*----------------------------------------------------------------------
-| AP4_StreamCipher::~AP4_StreamCipher
-+---------------------------------------------------------------------*/
-AP4_StreamCipher::~AP4_StreamCipher()
-{
- // delete the block cipher
- if (m_BlockCipher) {
- delete m_BlockCipher;
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_StreamCipher::Reset
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_StreamCipher::Reset(const AP4_UI08* key, const AP4_UI08* salt)
-{
- if (salt) {
- // initialize the counter with a salting key
- for (AP4_UI32 i=0; i<AP4_AES_BLOCK_SIZE; i++) {
- m_CBlock[i] = salt[i];
- }
- } else {
- // initialize the counter with no salting key
- for (AP4_UI32 i = 0; i < AP4_AES_BLOCK_SIZE; i++) {
- m_CBlock[i] = 0;
- }
- }
-
- // (re)create the block cipher
- if (key != NULL) {
- // delete the block cipher if needed
- if (m_BlockCipher) {
- delete m_BlockCipher;
- }
-
- // (re)create one
- m_BlockCipher = new AP4_AesBlockCipher(key);
- }
-
- // reset the stream offset
- SetStreamOffset(0);
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_StreamCipher::SetCounter
-+---------------------------------------------------------------------*/
-void
-AP4_StreamCipher::SetCounter(AP4_Offset block_offset)
-{
- // set the counter bytes
- for (AP4_UI32 i = 0; i < m_IvSize; i++) {
- m_CBlock[AP4_AES_BLOCK_SIZE-1-i] =
- (AP4_UI08)((block_offset>>(8*i)) & 0xFF);
- }
-}
-
-/*----------------------------------------------------------------------
-| AP4_StreamCipher::SetStreamOffset
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_StreamCipher::SetStreamOffset(AP4_Offset offset)
-{
- // do nothing if we're already at that offset
- if (offset == m_StreamOffset) return AP4_SUCCESS;
-
- // update the offset
- m_StreamOffset = offset;
-
- // update the key stream if necessary
- if (m_StreamOffset & 0xF) {
- return UpdateKeyStream(m_StreamOffset/AP4_AES_BLOCK_SIZE);
- }
-
- return AP4_SUCCESS;
-}
-
-/*----------------------------------------------------------------------
-| AP4_StreamCipher::UpdateKeyStream
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_StreamCipher::UpdateKeyStream(AP4_Offset block_offset)
-{
- // compute the new counter
- SetCounter(block_offset);
-
- // compute the key block (x) from the counter block (c)
- return m_BlockCipher->EncryptBlock(m_CBlock, m_XBlock);
-}
-
-/*----------------------------------------------------------------------
-| AP4_StreamCipher::ProcessBuffer
-+---------------------------------------------------------------------*/
-AP4_Result
-AP4_StreamCipher::ProcessBuffer(const AP4_UI08* in,
- AP4_UI08* out,
- AP4_Size size)
-{
- if (m_BlockCipher == NULL) return AP4_ERROR_INVALID_STATE;
-
- while (size) {
- // compute the number of bytes available in this chunk
- AP4_UI32 index = m_StreamOffset & (AP4_AES_BLOCK_SIZE-1);
- AP4_UI32 chunk;
-
- // update the key stream if we are on a boundary
- if (index == 0) {
- UpdateKeyStream(m_StreamOffset/AP4_AES_BLOCK_SIZE);
- chunk = AP4_AES_BLOCK_SIZE;
- }
-
- // compute the number of bytes remaining in the chunk
- chunk = AP4_AES_BLOCK_SIZE - index;
- if (chunk > size) chunk = size;
-
- // encrypt/decrypt the chunk
- AP4_UI08* x = &m_XBlock[index];
- for (AP4_UI32 i = 0; i < chunk; i++) {
- *out++ = *in++ ^ *x++;
- }
-
- // update offset and size
- m_StreamOffset += chunk;
- size -= chunk;
- }
-
- return AP4_SUCCESS;
-}
diff --git a/src/thirdparty/Bento4/Crypto/Ap4StreamCipher.h b/src/thirdparty/Bento4/Crypto/Ap4StreamCipher.h
deleted file mode 100644
index 3328ac6be..000000000
--- a/src/thirdparty/Bento4/Crypto/Ap4StreamCipher.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2005 Gilles Boccon-Gibod
- */
-
-
-#ifndef _AP4_STREAM_CIPHER_H_
-#define _AP4_STREAM_CIPHER_H_
-
-/*----------------------------------------------------------------------
-| includes
-+---------------------------------------------------------------------*/
-#include "Ap4AesBlockCipher.h"
-#include "Ap4Results.h"
-#include "Ap4Types.h"
-
-/*----------------------------------------------------------------------
-| AP4_StreamCipher class
-+---------------------------------------------------------------------*/
-class AP4_StreamCipher
-{
- public:
- // methods
- AP4_StreamCipher(const AP4_UI08* key = NULL,
- const AP4_UI08* salt = NULL,
- AP4_Size iv_size = 4);
- ~AP4_StreamCipher();
- AP4_Result SetStreamOffset(AP4_Offset offset);
- AP4_Result Reset(const AP4_UI08* key, const AP4_UI08* salt);
- AP4_Result ProcessBuffer(const AP4_UI08* in,
- AP4_UI08* out,
- AP4_Size size);
- AP4_Offset GeStreamOffset() { return m_StreamOffset; }
-
- private:
- // members
- AP4_Offset m_StreamOffset;
- AP4_Size m_IvSize;
- AP4_UI08 m_CBlock[AP4_AES_BLOCK_SIZE];
- AP4_UI08 m_XBlock[AP4_AES_BLOCK_SIZE];
- AP4_AesBlockCipher* m_BlockCipher;
-
- // methods
- void SetCounter(AP4_Offset block_offset);
- AP4_Result UpdateKeyStream(AP4_Offset block_offset);
-};
-
-#endif // _AP4_STREAM_CIPHER_H_
diff --git a/src/thirdparty/Bento4/precomp.cpp b/src/thirdparty/Bento4/precomp.cpp
deleted file mode 100644
index 85cf1bc90..000000000
--- a/src/thirdparty/Bento4/precomp.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * (C) 2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-// precompiled headers support
-
-#include "Ap4.h"
diff --git a/src/thirdparty/ffmpeg/Makefile b/src/thirdparty/ffmpeg/Makefile
deleted file mode 100644
index 16696a47c..000000000
--- a/src/thirdparty/ffmpeg/Makefile
+++ /dev/null
@@ -1,427 +0,0 @@
-# (C) 2007-2013 see Authors.txt
-#
-# This file is part of MPC-HC.
-#
-# MPC-HC is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# MPC-HC 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-CC = gcc.exe
-
-ifeq ($(VS2012),yes)
- BIN_DIR = ../../../bin12
-else
- BIN_DIR = ../../../bin
-endif
-ZLIB_DIR = ../zlib
-
-ifeq ($(DEBUG),yes)
- OUT_DIR_PREFIX = Debug
-else
- OUT_DIR_PREFIX = Release
-endif
-
-ifeq ($(64BIT),yes)
- MY_ARCH = x64
-else
- MY_ARCH = Win32
-endif
-
-
-OBJ_DIR = $(BIN_DIR)/obj/$(OUT_DIR_PREFIX)_$(MY_ARCH)/ffmpeg/
-OUT_LIB_DIR = $(BIN_DIR)/lib/$(OUT_DIR_PREFIX)_$(MY_ARCH)
-OUT_LIB = $(OUT_LIB_DIR)/ffmpeg.lib
-
-
-# Compiler and yasm flags
-CFLAGS = -I. -I.. -I$(ZLIB_DIR) -DHAVE_AV_CONFIG_H -D_ISOC99_SOURCE \
- -D_XOPEN_SOURCE=600 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \
- -std=gnu99 -pipe -mthreads
-OPTFLAGS = -O2 -fno-common -fno-tree-vectorize -fomit-frame-pointer
-YASMFLAGS = -I. -Pconfig.asm
-
-ifeq ($(64BIT),yes)
- GCC_PREFIX = x86_64-w64-mingw32-
- TARGET_OS = x86_64-w64-mingw32
- CFLAGS += -DWIN64 -D_WIN64 -DARCH_X86_64 -DPIC
- OPTFLAGS += -m64 -fno-leading-underscore
- YASMFLAGS += -f win64 -m amd64 -DWIN64=1 -DARCH_X86_32=0 -DARCH_X86_64=1 -DPIC
-else
- TARGET_OS = i686-w64-mingw32
- CFLAGS += -DWIN32 -D_WIN32 -DARCH_X86_32
- OPTFLAGS += -m32 -march=i686 -mmmx -msse -mfpmath=sse
- YASMFLAGS += -f win32 -m x86 -DWIN32=1 -DARCH_X86_32=1 -DARCH_X86_64=0 -DPREFIX
-endif
-
-ifeq ($(DEBUG),yes)
- CFLAGS += -DDEBUG -D_DEBUG -g
-else
- CFLAGS += -DNDEBUG -UDEBUG -U_DEBUG
-endif
-
-
-# Object directories
-OBJ_DIRS = \
- $(OBJ_DIR)libavcodec \
- $(OBJ_DIR)libavcodec/x86 \
- $(OBJ_DIR)libavresample \
- $(OBJ_DIR)libavresample/x86 \
- $(OBJ_DIR)libavutil \
- $(OBJ_DIR)libavutil/x86 \
- $(OBJ_DIR)libswscale \
- $(OBJ_DIR)libswscale/x86 \
-
-# Targets
-all: create_dirs $(OUT_LIB)
-
-create_dirs: $(OBJ_DIRS) $(OUT_LIB_DIR)
-$(OBJ_DIRS) $(OUT_LIB_DIR):
- $(shell test -d $(@) || mkdir -p $(@))
-
-clean:
- @echo Cleaning ffmpeg...
- rm -f \
- $(OUT_LIB) \
- $(OBJ_DIR)mpc_helper.o \
- $(OBJ_DIR)mpc_helper.d
- rm -rf $(OBJ_DIRS)
-
-
-# Objects
-SRCS_C = \
- mpc_helper.c \
- libavcodec/aac_ac3_parser.c \
- libavcodec/aac_parser.c \
- libavcodec/aacadtsdec.c \
- libavcodec/aacdec.c \
- libavcodec/aacps.c \
- libavcodec/aacpsdsp.c \
- libavcodec/aacsbr.c \
- libavcodec/aactab.c \
- libavcodec/ac3.c \
- libavcodec/ac3_parser.c \
- libavcodec/ac3dec.c \
- libavcodec/ac3dec_data.c \
- libavcodec/ac3dsp.c \
- libavcodec/ac3tab.c \
- libavcodec/acelp_filters.c \
- libavcodec/acelp_pitch_delay.c \
- libavcodec/acelp_vectors.c \
- libavcodec/adpcm.c \
- libavcodec/adpcm_data.c \
- libavcodec/alac.c \
- libavcodec/alac_data.c \
- libavcodec/allcodecs.c \
- libavcodec/alsdec.c \
- libavcodec/amrnbdec.c \
- libavcodec/amrwbdec.c \
- libavcodec/atrac.c \
- libavcodec/atrac3.c \
- libavcodec/avfft.c \
- libavcodec/avpacket.c \
- libavcodec/avpicture.c \
- libavcodec/bgmc.c \
- libavcodec/bitstream.c \
- libavcodec/cabac.c \
- libavcodec/celp_filters.c \
- libavcodec/celp_math.c \
- libavcodec/codec_desc.c \
- libavcodec/cook.c \
- libavcodec/dca.c \
- libavcodec/dca_parser.c \
- libavcodec/dcadec.c \
- libavcodec/dcadsp.c \
- libavcodec/dct.c \
- libavcodec/dct32.c \
- libavcodec/dct32_float.c \
- libavcodec/dsputil.c \
- libavcodec/eac3_data.c \
- libavcodec/eac3dec.c \
- libavcodec/error_resilience.c \
- libavcodec/faandct.c \
- libavcodec/faanidct.c \
- libavcodec/fft.c \
- libavcodec/flac.c \
- libavcodec/flacdata.c \
- libavcodec/flacdec.c \
- libavcodec/flacdsp.c \
- libavcodec/flvdec.c \
- libavcodec/fmtconvert.c \
- libavcodec/frame_thread_encoder.c \
- libavcodec/golomb.c \
- libavcodec/h263.c \
- libavcodec/h263_parser.c \
- libavcodec/h263dec.c \
- libavcodec/h264.c \
- libavcodec/h264_cabac.c \
- libavcodec/h264_cavlc.c \
- libavcodec/h264_direct.c \
- libavcodec/h264_loopfilter.c \
- libavcodec/h264_parser.c \
- libavcodec/h264_ps.c \
- libavcodec/h264_refs.c \
- libavcodec/h264_sei.c \
- libavcodec/h264chroma.c \
- libavcodec/h264dsp.c \
- libavcodec/h264idct.c \
- libavcodec/h264pred.c \
- libavcodec/h264qpel.c \
- libavcodec/huffman.c \
- libavcodec/imgconvert.c \
- libavcodec/indeo3.c \
- libavcodec/indeo4.c \
- libavcodec/indeo5.c \
- libavcodec/intelh263dec.c \
- libavcodec/intrax8.c \
- libavcodec/intrax8dsp.c \
- libavcodec/ituh263dec.c \
- libavcodec/ivi_common.c \
- libavcodec/ivi_dsp.c \
- libavcodec/jpegls.c \
- libavcodec/jpeglsdec.c \
- libavcodec/jrevdct.c \
- libavcodec/kbdwin.c \
- libavcodec/latm_parser.c \
- libavcodec/log2_tab.c \
- libavcodec/lsp.c \
- libavcodec/mathtables.c \
- libavcodec/mdct.c \
- libavcodec/mjpeg.c \
- libavcodec/mjpegbdec.c \
- libavcodec/mjpegdec.c \
- libavcodec/mlp.c \
- libavcodec/mlp_parser.c \
- libavcodec/mlpdec.c \
- libavcodec/mlpdsp.c \
- libavcodec/mpeg12.c \
- libavcodec/mpeg12data.c \
- libavcodec/mpeg4audio.c \
- libavcodec/mpeg4video.c \
- libavcodec/mpeg4video_parser.c \
- libavcodec/mpeg4videodec.c \
- libavcodec/mpegaudio.c \
- libavcodec/mpegaudio_parser.c \
- libavcodec/mpegaudiodata.c \
- libavcodec/mpegaudiodec_float.c \
- libavcodec/mpegaudiodecheader.c \
- libavcodec/mpegaudiodsp.c \
- libavcodec/mpegaudiodsp_data.c \
- libavcodec/mpegaudiodsp_fixed.c \
- libavcodec/mpegaudiodsp_float.c \
- libavcodec/mpegvideo.c \
- libavcodec/mpegvideo_motion.c \
- libavcodec/mpegvideo_parser.c \
- libavcodec/msmpeg4.c \
- libavcodec/msmpeg4data.c \
- libavcodec/msrle.c \
- libavcodec/msrledec.c \
- libavcodec/nellymoser.c \
- libavcodec/nellymoserdec.c \
- libavcodec/options.c \
- libavcodec/parser.c \
- libavcodec/pthread.c \
- libavcodec/ra144.c \
- libavcodec/ra144dec.c \
- libavcodec/ra288.c \
- libavcodec/rdft.c \
- libavcodec/rv10.c \
- libavcodec/rv30.c \
- libavcodec/rv30dsp.c \
- libavcodec/rv34.c \
- libavcodec/rv34dsp.c \
- libavcodec/rv40.c \
- libavcodec/rv40dsp.c \
- libavcodec/sbrdsp.c \
- libavcodec/simple_idct.c \
- libavcodec/sinewin.c \
- libavcodec/sipr.c \
- libavcodec/sipr16k.c \
- libavcodec/sp5xdec.c \
- libavcodec/svq1.c \
- libavcodec/svq1dec.c \
- libavcodec/svq3.c \
- libavcodec/svq13.c \
- libavcodec/synth_filter.c \
- libavcodec/tscc.c \
- libavcodec/utils.c \
- libavcodec/vc1.c \
- libavcodec/vc1data.c \
- libavcodec/vc1dec.c \
- libavcodec/vc1dsp.c \
- libavcodec/videodsp.c \
- libavcodec/vmnc.c \
- libavcodec/vorbis.c \
- libavcodec/vorbis_data.c \
- libavcodec/vorbisdec.c \
- libavcodec/vorbisdsp.c \
- libavcodec/vp3.c \
- libavcodec/vp3dsp.c \
- libavcodec/vp5.c \
- libavcodec/vp56.c \
- libavcodec/vp56data.c \
- libavcodec/vp56dsp.c \
- libavcodec/vp56rac.c \
- libavcodec/vp6.c \
- libavcodec/vp6dsp.c \
- libavcodec/vp8.c \
- libavcodec/vp8dsp.c \
- libavcodec/wmv2.c \
- libavcodec/wmv2dec.c \
- libavcodec/wmv2dsp.c \
- libavcodec/xiph.c \
- libavcodec/x86/ac3dsp_init.c \
- libavcodec/x86/dsputil_mmx.c \
- libavcodec/x86/fdct.c \
- libavcodec/x86/fft_init.c \
- libavcodec/x86/fmtconvert_init.c \
- libavcodec/x86/h264_intrapred_init.c \
- libavcodec/x86/h264_qpel.c \
- libavcodec/x86/h264chroma_init.c \
- libavcodec/x86/h264dsp_init.c \
- libavcodec/x86/idct_mmx.c \
- libavcodec/x86/idct_mmx_xvid.c \
- libavcodec/x86/idct_sse2_xvid.c \
- libavcodec/x86/mlpdsp.c \
- libavcodec/x86/motion_est.c \
- libavcodec/x86/mpegaudiodec.c \
- libavcodec/x86/mpegvideo.c \
- libavcodec/x86/rv34dsp_init.c \
- libavcodec/x86/rv40dsp_init.c \
- libavcodec/x86/sbrdsp_init.c \
- libavcodec/x86/simple_idct.c \
- libavcodec/x86/vc1dsp_init.c \
- libavcodec/x86/vc1dsp_mmx.c \
- libavcodec/x86/videodsp_init.c \
- libavcodec/x86/vorbisdsp_init.c \
- libavcodec/x86/vp3dsp_init.c \
- libavcodec/x86/vp56dsp_init.c \
- libavcodec/x86/vp8dsp_init.c \
-\
- libavresample/audio_convert.c \
- libavresample/audio_data.c \
- libavresample/audio_mix.c \
- libavresample/audio_mix_matrix.c \
- libavresample/dither.c \
- libavresample/options.c \
- libavresample/resample.c \
- libavresample/utils.c \
- libavresample/x86/audio_convert_init.c \
- libavresample/x86/audio_mix_init.c \
- libavresample/x86/dither_init.c \
-\
- libavutil/audio_fifo.c \
- libavutil/avstring.c \
- libavutil/bprint.c \
- libavutil/channel_layout.c \
- libavutil/cpu.c \
- libavutil/crc.c \
- libavutil/dict.c \
- libavutil/error.c \
- libavutil/eval.c \
- libavutil/fifo.c \
- libavutil/float_dsp.c \
- libavutil/imgutils.c \
- libavutil/intfloat_readwrite.c \
- libavutil/lfg.c \
- libavutil/log.c \
- libavutil/mathematics.c \
- libavutil/md5.c \
- libavutil/mem.c \
- libavutil/opt.c \
- libavutil/parseutils.c \
- libavutil/pixdesc.c \
- libavutil/random_seed.c \
- libavutil/rational.c \
- libavutil/samplefmt.c \
- libavutil/sha.c \
- libavutil/time.c \
- libavutil/timecode.c \
- libavutil/utils.c \
- libavutil/x86/cpu.c \
- libavutil/x86/float_dsp_init.c \
-\
- libswscale/input.c \
- libswscale/options.c \
- libswscale/output.c \
- libswscale/rgb2rgb.c \
- libswscale/swscale.c \
- libswscale/swscale_unscaled.c \
- libswscale/utils.c \
- libswscale/yuv2rgb.c \
- libswscale/x86/rgb2rgb.c \
- libswscale/x86/swscale.c \
- libswscale/x86/yuv2rgb.c
-
-# Yasm objects
-SRCS_YASM = \
- libavcodec/x86/ac3dsp.asm \
- libavcodec/x86/dct32.asm \
- libavcodec/x86/deinterlace.asm \
- libavcodec/x86/dsputil.asm \
- libavcodec/x86/fft.asm \
- libavcodec/x86/fmtconvert.asm \
- libavcodec/x86/h264_chromamc.asm \
- libavcodec/x86/h264_chromamc_10bit.asm \
- libavcodec/x86/h264_deblock.asm \
- libavcodec/x86/h264_deblock_10bit.asm \
- libavcodec/x86/h264_idct.asm \
- libavcodec/x86/h264_idct_10bit.asm \
- libavcodec/x86/h264_intrapred.asm \
- libavcodec/x86/h264_intrapred_10bit.asm \
- libavcodec/x86/h264_qpel_8bit.asm \
- libavcodec/x86/h264_qpel_10bit.asm \
- libavcodec/x86/h264_weight.asm \
- libavcodec/x86/h264_weight_10bit.asm \
- libavcodec/x86/hpeldsp.asm \
- libavcodec/x86/imdct36.asm \
- libavcodec/x86/mpeg4qpel.asm \
- libavcodec/x86/rv34dsp.asm \
- libavcodec/x86/rv40dsp.asm \
- libavcodec/x86/sbrdsp.asm \
- libavcodec/x86/vc1dsp.asm \
- libavcodec/x86/videodsp.asm \
- libavcodec/x86/vorbisdsp.asm \
- libavcodec/x86/vp3dsp.asm \
- libavcodec/x86/vp56dsp.asm \
- libavcodec/x86/vp8dsp.asm \
- libavresample/x86/audio_convert.asm \
- libavresample/x86/audio_mix.asm \
- libavresample/x86/dither.asm \
- libavresample/x86/util.asm \
- libavutil/x86/cpuid.asm \
- libavutil/x86/emms.asm \
- libavutil/x86/float_dsp.asm \
- libswscale/x86/input.asm \
- libswscale/x86/output.asm \
- libswscale/x86/scale.asm
-
-OBJS = \
- $(SRCS_C:%.c=$(OBJ_DIR)%.o) \
- $(SRCS_YASM:%.asm=$(OBJ_DIR)%.o)
-
-
-# Commands
-$(OBJ_DIR)%.o: %.c
- @echo CC ' ' $<
- @$(GCC_PREFIX)$(CC) -c $(CFLAGS) $(OPTFLAGS) -MMD -o $@ $<
-
-$(OBJ_DIR)%.o: %.asm
- @echo YASM: ' ' Assembling $<
- @yasm $(YASMFLAGS) -I$(<D)/ -o $@ $<
-
-$(OUT_LIB): $(OBJS)
- @echo AR ' ' $@
- @$(GCC_PREFIX)ar rc $@ $(OBJS)
-
--include $(SRCS_C:%.c=$(OBJ_DIR)%.d)
-
-.PHONY: clean create_dirs $(OBJ_DIRS) $(OUT_LIB_DIR)
diff --git a/src/thirdparty/ffmpeg/config.asm b/src/thirdparty/ffmpeg/config.asm
deleted file mode 100644
index f3cf7ba87..000000000
--- a/src/thirdparty/ffmpeg/config.asm
+++ /dev/null
@@ -1,226 +0,0 @@
-%define ARCH_X86 1
-%define CONFIG_GPL 1
-%define HAVE_AMD3DNOW 1
-%define HAVE_AMD3DNOWEXT 1
-%define HAVE_AVX 1
-%define HAVE_FMA4 1
-%define HAVE_MMX 1
-%define HAVE_MMXEXT 1
-%define HAVE_SSE 1
-%define HAVE_SSE2 1
-%define HAVE_SSE3 1
-%define HAVE_SSE4 1
-%define HAVE_SSE42 1
-%define HAVE_SSSE3 1
-
-%ifdef ARCH_X86_64
- %define ARCH_X86_32 0
- %define ARCH_X86_64 1
- %define HAVE_FAST_64BIT 1
- %define HAVE_GETADDRINFO 1
-else
- %define ARCH_X86_32 1
- %define ARCH_X86_64 0
- %define HAVE_FAST_64BIT 0
- %define HAVE_GETADDRINFO 0
-%endif
-
-%define ARCH_ALPHA 0
-%define ARCH_ARM 0
-%define ARCH_AVR32 0
-%define ARCH_AVR32_AP 0
-%define ARCH_AVR32_UC 0
-%define ARCH_BFIN 0
-%define ARCH_IA64 0
-%define ARCH_M68K 0
-%define ARCH_MIPS 0
-%define ARCH_MIPS64 0
-%define ARCH_PARISC 0
-%define ARCH_PPC 0
-%define ARCH_PPC64 0
-%define ARCH_S390 0
-%define ARCH_SH4 0
-%define ARCH_SPARC 0
-%define ARCH_SPARC64 0
-%define ARCH_TOMI 0
-%define HAVE_ALIGNED_MALLOC 1
-%define HAVE_ALIGNED_STACK 1
-%define HAVE_ALSA_ASOUNDLIB_H 0
-%define HAVE_ALTIVEC 0
-%define HAVE_ALTIVEC_H 0
-%define HAVE_ARMV5TE 0
-%define HAVE_ARMV6 0
-%define HAVE_ARMV6T2 0
-%define HAVE_ARMVFP 0
-%define HAVE_ARPA_INET_H 0
-%define HAVE_ASM_MOD_Y 0
-%define HAVE_ASM_TYPES_H 0
-%define HAVE_ATTRIBUTE_MAY_ALIAS 1
-%define HAVE_ATTRIBUTE_PACKED 1
-%define HAVE_BIGENDIAN 0
-%define HAVE_CBRTF 1
-%define HAVE_CLOCK_GETTIME 0
-%define HAVE_CLOSESOCKET 1
-%define HAVE_CMOV 1
-%define HAVE_CPUNOP 1
-%define HAVE_CRYPTGENRANDOM 1
-%define HAVE_DCBZL 0
-%define HAVE_DEV_BKTR_IOCTL_BT848_H 0
-%define HAVE_DEV_BKTR_IOCTL_METEOR_H 0
-%define HAVE_DEV_IC_BT8XX_H 0
-%define HAVE_DEV_VIDEO_BKTR_IOCTL_BT848_H 0
-%define HAVE_DEV_VIDEO_METEOR_IOCTL_METEOR_H 0
-%define HAVE_DLFCN_H 1
-%define HAVE_DLOPEN 1
-%define HAVE_DOS_PATHS 1
-%define HAVE_EBP_AVAILABLE 1
-%define HAVE_EBX_AVAILABLE 1
-%define HAVE_EXP2 1
-%define HAVE_EXP2F 1
-%define HAVE_FAST_CLZ 1
-%define HAVE_FAST_CMOV 1
-%define HAVE_FCNTL 0
-%define HAVE_FORK 0
-%define HAVE_GETHRTIME 0
-%define HAVE_GETPROCESSAFFINITYMASK 1
-%define HAVE_GETPROCESSMEMORYINFO 1
-%define HAVE_GETPROCESSTIMES 1
-%define HAVE_GETRUSAGE 0
-%define HAVE_GETTIMEOFDAY 1
-%define HAVE_GLOB 0
-%define HAVE_GNU_AS 1
-%define HAVE_GNU_AS 1
-%define HAVE_IBM_ASM 0
-%define HAVE_INET_ATON 0
-%define HAVE_INLINE_ASM 1
-%define HAVE_ISATTY 1
-%define HAVE_ISINF 1
-%define HAVE_ISNAN 1
-%define HAVE_JACK_PORT_GET_LATENCY_RANGE 0
-%define HAVE_KBHIT 1
-%define HAVE_LDBRX 0
-%define HAVE_LIBDC1394_1 0
-%define HAVE_LIBDC1394_2 0
-%define HAVE_LLRINT 1
-%define HAVE_LLRINTF 1
-%define HAVE_LOCAL_ALIGNED_16 1
-%define HAVE_LOCAL_ALIGNED_8 1
-%define HAVE_LOCALTIME_R 0
-%define HAVE_LOG2 1
-%define HAVE_LOG2F 1
-%define HAVE_LOONGSON 0
-%define HAVE_LRINT 1
-%define HAVE_LRINTF 1
-%define HAVE_LZO1X_999_COMPRESS 0
-%define HAVE_MACHINE_IOCTL_BT848_H 0
-%define HAVE_MACHINE_IOCTL_METEOR_H 0
-%define HAVE_MAKEINFO 1
-%define HAVE_MALLOC_H 1
-%define HAVE_MAPVIEWOFFILE 1
-%define HAVE_MEMALIGN 0
-%define HAVE_MIPSFPU 0
-%define HAVE_MIPS32R2 0
-%define HAVE_MIPSDSPR1 0
-%define HAVE_MIPSDSPR2 0
-%define HAVE_AMD3DNOW_EXTERNAL 1
-%define HAVE_AMD3DNOWEXT_EXTERNAL 1
-%define HAVE_AVX_EXTERNAL 1
-%define HAVE_FMA4_EXTERNAL 1
-%define HAVE_MMX_EXTERNAL 1
-%define HAVE_MMXEXT_EXTERNAL 1
-%define HAVE_SSE_EXTERNAL 1
-%define HAVE_SSE2_EXTERNAL 1
-%define HAVE_SSE3_EXTERNAL 1
-%define HAVE_SSE4_EXTERNAL 1
-%define HAVE_SSE42_EXTERNAL 1
-%define HAVE_SSSE3_EXTERNAL 1
-%define HAVE_ALTIVEC_EXTERNAL 0
-%define HAVE_ARMV5TE_EXTERNAL 0
-%define HAVE_ARMV6_EXTERNAL 0
-%define HAVE_ARMV6T2_EXTERNAL 0
-%define HAVE_ARMVFP_EXTERNAL 0
-%define HAVE_NEON_EXTERNAL 0
-%define HAVE_PPC4XX_EXTERNAL 0
-%define HAVE_VFPV3_EXTERNAL 0
-%define HAVE_VIS_EXTERNAL 0
-%define HAVE_MIPSFPU_EXTERNAL 0
-%define HAVE_MIPS32R2_EXTERNAL 0
-%define HAVE_MIPSDSPR1_EXTERNAL 0
-%define HAVE_MIPSDSPR2_EXTERNAL 0
-%define HAVE_AMD3DNOW_INLINE 1
-%define HAVE_AMD3DNOWEXT_INLINE 1
-%define HAVE_AVX_INLINE 1
-%define HAVE_FMA4_INLINE 1
-%define HAVE_MMX_INLINE 1
-%define HAVE_MMXEXT_INLINE 1
-%define HAVE_SSE_INLINE 1
-%define HAVE_SSE2_INLINE 1
-%define HAVE_SSE3_INLINE 1
-%define HAVE_SSE4_INLINE 1
-%define HAVE_SSE42_INLINE 1
-%define HAVE_SSSE3_INLINE 1
-%define HAVE_MKSTEMP 0
-%define HAVE_MMAP 0
-%define HAVE_MM_EMPTY 0
-%define HAVE_NANOSLEEP 0
-%define HAVE_NEON 0
-%define HAVE_NETINET_SCTP_H 0
-%define HAVE_OS2THREADS 0
-%define HAVE_PEEKNAMEDPIPE 1
-%define HAVE_POLL_H 0
-%define HAVE_POSIX_MEMALIGN 0
-%define HAVE_PTHREAD_CANCEL 0
-%define HAVE_PPC4XX 0
-%define HAVE_PTHREADS 0
-%define HAVE_FAST_UNALIGNED 1
-%define HAVE_RDTSC 1
-%define HAVE_RINT 1
-%define HAVE_ROUND 1
-%define HAVE_ROUNDF 1
-%define HAVE_RWEFLAGS 0
-%define HAVE_SCHED_GETAFFINITY 0
-%define HAVE_SDL 0
-%define HAVE_SDL_VIDEO_SIZE 0
-%define HAVE_SETMODE 1
-%define HAVE_SETRLIMIT 0
-%define HAVE_SLEEP 1
-%define HAVE_SNDIO_H 0
-%define HAVE_SOCKLEN_T 1
-%define HAVE_SOUNDCARD_H 0
-%define HAVE_STRERROR_R 0
-%define HAVE_STRPTIME 0
-%define HAVE_STRUCT_ADDRINFO 1
-%define HAVE_STRUCT_IPV6_MREQ 1
-%define HAVE_STRUCT_RUSAGE_RU_MAXRSS 0
-%define HAVE_STRUCT_SOCKADDR_IN6 1
-%define HAVE_STRUCT_SOCKADDR_SA_LEN 0
-%define HAVE_STRUCT_SOCKADDR_STORAGE 1
-%define HAVE_STRUCT_V4L2_FRMIVALENUM_DISCRETE 0
-%define HAVE_SYMVER 1
-%define HAVE_SYMVER_ASM_LABEL 1
-%define HAVE_SYMVER_GNU_ASM 0
-%define HAVE_SYSCONF 0
-%define HAVE_SYSCTL 0
-%define HAVE_SYS_MMAN_H 0
-%define HAVE_SYS_PARAM_H 1
-%define HAVE_SYS_RESOURCE_H 0
-%define HAVE_SYS_SELECT_H 0
-%define HAVE_SYS_SOUNDCARD_H 0
-%define HAVE_SYS_VIDEOIO_H 0
-%define HAVE_TERMIOS_H 0
-%define HAVE_THREADS 1
-%define HAVE_TRUNC 1
-%define HAVE_TRUNCF 1
-%define HAVE_UNISTD_H 1
-%define HAVE_USLEEP 1
-%define HAVE_VFP_ARGS 0
-%define HAVE_VFPV3 0
-%define HAVE_VIRTUALALLOC 1
-%define HAVE_VIS 0
-%define HAVE_WINDOWS_H 1
-%define HAVE_W32THREADS 1
-%define HAVE_WINSOCK2_H 1
-%define HAVE_XFORM_ASM 0
-%define HAVE_XGETBV 0
-%define HAVE_XMM_CLOBBERS 1
-%define HAVE_YASM 1
diff --git a/src/thirdparty/ffmpeg/config.h b/src/thirdparty/ffmpeg/config.h
deleted file mode 100644
index ab5913af1..000000000
--- a/src/thirdparty/ffmpeg/config.h
+++ /dev/null
@@ -1,513 +0,0 @@
-#ifndef FFMPEG_CONFIG_H
-#define FFMPEG_CONFIG_H
-
-#ifdef __GNUC__
- #define ARCH_X86 1
- #define HAVE_INLINE_ASM 1
- #define HAVE_AMD3DNOW 1
- #define HAVE_AMD3DNOWEXT 1
- #define HAVE_AVX 1
- #define HAVE_FMA4 1
- #define HAVE_MMX 1
- #define HAVE_MMX2 HAVE_MMXEXT
- #define HAVE_MMXEXT 1
- #define HAVE_SSE 1
- #define HAVE_SSE2 1
- #define HAVE_SSE3 1
- #define HAVE_SSE4 1
- #define HAVE_SSE42 1
- #define HAVE_SSSE3 1
- #define HAVE_AMD3DNOW_EXTERNAL 1
- #define HAVE_AMD3DNOWEXT_EXTERNAL 1
- #define HAVE_AVX_EXTERNAL 1
- #define HAVE_FMA4_EXTERNAL 1
- #define HAVE_MMX_EXTERNAL 1
- #define HAVE_MMXEXT_EXTERNAL 1
- #define HAVE_SSE_EXTERNAL 1
- #define HAVE_SSE2_EXTERNAL 1
- #define HAVE_SSE3_EXTERNAL 1
- #define HAVE_SSE4_EXTERNAL 1
- #define HAVE_SSE42_EXTERNAL 1
- #define HAVE_SSSE3_EXTERNAL 1
- #define HAVE_ALTIVEC_EXTERNAL 0
- #define HAVE_ARMV5TE_EXTERNAL 0
- #define HAVE_ARMV6_EXTERNAL 0
- #define HAVE_ARMV6T2_EXTERNAL 0
- #define HAVE_ARMVFP_EXTERNAL 0
- #define HAVE_NEON_EXTERNAL 0
- #define HAVE_PPC4XX_EXTERNAL 0
- #define HAVE_VFPV3_EXTERNAL 0
- #define HAVE_VIS_EXTERNAL 0
- #define HAVE_MIPSFPU_EXTERNAL 0
- #define HAVE_MIPS32R2_EXTERNAL 0
- #define HAVE_MIPSDSPR1_EXTERNAL 0
- #define HAVE_MIPSDSPR2_EXTERNAL 0
- #define HAVE_AMD3DNOW_INLINE 1
- #define HAVE_AMD3DNOWEXT_INLINE 1
- #define HAVE_AVX_INLINE 1
- #define HAVE_FMA4_INLINE 1
- #define HAVE_MMX_INLINE 1
- #define HAVE_MMXEXT_INLINE 1
- #define HAVE_SSE_INLINE 1
- #define HAVE_SSE2_INLINE 1
- #define HAVE_SSE3_INLINE 1
- #define HAVE_SSE4_INLINE 1
- #define HAVE_SSE42_INLINE 1
- #define HAVE_SSSE3_INLINE 1
- #define HAVE_ALTIVEC_INLINE 0
- #define HAVE_ARMV5TE_INLINE 0
- #define HAVE_ARMV6_INLINE 0
- #define HAVE_ARMV6T2_INLINE 0
- #define HAVE_ARMVFP_INLINE 0
- #define HAVE_NEON_INLINE 0
- #define HAVE_PPC4XX_INLINE 0
- #define HAVE_VFPV3_INLINE 0
- #define HAVE_VIS_INLINE 0
- #define HAVE_MIPSFPU_INLINE 0
- #define HAVE_MIPS32R2_INLINE 0
- #define HAVE_MIPSDSPR1_INLINE 0
- #define HAVE_MIPSDSPR2_INLINE 0
-
- #ifdef ARCH_X86_64
- #define ARCH_X86_32 0
- #define ARCH_X86_64 1
- #define HAVE_FAST_64BIT 1
- #define HAVE_GETADDRINFO 1
- #else
- #define ARCH_X86_32 1
- #define ARCH_X86_64 0
- #define HAVE_FAST_64BIT 0
- #define HAVE_GETADDRINFO 0
- #endif
- #define av_restrict restrict
-#else
- #define restrict
- #define __asm__ __asm
-#endif
-
-#define FFMPEG_CONFIGURATION "ffmpeg configuration"
-#define FFMPEG_LICENSE "GPL version 2 or later"
-
-#define CC_TYPE "gcc"
-#define CC_VERSION __VERSION__
-
-// MPC custom code for linking with MSVC
-#if defined(__GNUC__) && ARCH_X86_64
- #define EXTERN_PREFIX ""
-#else
- #define EXTERN_PREFIX "_"
-#endif
-#define EXTERN_ASM _
-
-#define ARCH_AARCH64 0
-#define ARCH_ALPHA 0
-#define ARCH_ARM 0
-#define ARCH_AVR32 0
-#define ARCH_AVR32_AP 0
-#define ARCH_AVR32_UC 0
-#define ARCH_BFIN 0
-#define ARCH_IA64 0
-#define ARCH_M68K 0
-#define ARCH_MIPS 0
-#define ARCH_MIPS64 0
-#define ARCH_PARISC 0
-#define ARCH_PPC 0
-#define ARCH_PPC64 0
-#define ARCH_S390 0
-#define ARCH_SH4 0
-#define ARCH_SPARC 0
-#define ARCH_SPARC64 0
-#define ARCH_TILEGX 0
-#define ARCH_TILEPRO 0
-#define ARCH_TOMI 0
-
-#define HAVE_ALTIVEC 0
-#define HAVE_ARMV5TE 0
-#define HAVE_ARMV6 0
-#define HAVE_ARMV6T2 0
-#define HAVE_ARMVFP 0
-#define HAVE_MIPSFPU 0
-#define HAVE_MIPS32R2 0
-#define HAVE_MIPSDSPR1 0
-#define HAVE_MIPSDSPR2 0
-#define HAVE_NEON 0
-#define HAVE_PPC4XX 0
-#define HAVE_VFPV3 0
-#define HAVE_VIS 0
-
-#define HAVE_ALIGNED_MALLOC 1
-#define HAVE_ALIGNED_STACK 1
-#define HAVE_ALSA_ASOUNDLIB_H 0
-#define HAVE_ALTIVEC_H 0
-#define HAVE_ARPA_INET_H 0
-#define HAVE_ASM_MOD_Y 0
-#define HAVE_ASM_TYPES_H 0
-#define HAVE_BIGENDIAN 0
-#define HAVE_CLOCK_GETTIME 0
-#define HAVE_CLOSESOCKET 1
-#define HAVE_CMOV 1
-#define HAVE_CPUNOP 1
-#define HAVE_CRYPTGENRANDOM 1
-#define HAVE_DCBZL 0
-#define HAVE_DEV_BKTR_IOCTL_BT848_H 0
-#define HAVE_DEV_BKTR_IOCTL_METEOR_H 0
-#define HAVE_DEV_IC_BT8XX_H 0
-#define HAVE_DEV_VIDEO_BKTR_IOCTL_BT848_H 0
-#define HAVE_DEV_VIDEO_METEOR_IOCTL_METEOR_H 0
-#define HAVE_DLFCN_H 1
-#define HAVE_DLOPEN 1
-#define HAVE_DOS_PATHS 1
-#define HAVE_EBP_AVAILABLE 1
-#define HAVE_EBX_AVAILABLE 1
-#define HAVE_FAST_CLZ 1
-#define HAVE_FAST_CMOV 1
-#define HAVE_FCNTL 0
-#define HAVE_FORK 0
-#define HAVE_GETHRTIME 0
-#define HAVE_GETPROCESSAFFINITYMASK 1
-#define HAVE_GETPROCESSMEMORYINFO 1
-#define HAVE_GETPROCESSTIMES 1
-#define HAVE_GETRUSAGE 0
-#define HAVE_GETTIMEOFDAY 1
-#define HAVE_GLOB 0
-#define HAVE_GNU_AS 1
-#define HAVE_IBM_ASM 0
-#define HAVE_INET_ATON 0
-#define HAVE_FAST_UNALIGNED 1
-#define HAVE_ISATTY 1
-#define HAVE_JACK_PORT_GET_LATENCY_RANGE 0
-#define HAVE_KBHIT 1
-#define HAVE_LDBRX 0
-#define HAVE_LIBDC1394_1 0
-#define HAVE_LIBDC1394_2 0
-#define HAVE_LOCAL_ALIGNED_16 1
-#define HAVE_LOCAL_ALIGNED_8 1
-#define HAVE_LOCALTIME_R 0
-#define HAVE_LOONGSON 0
-#define HAVE_LZO1X_999_COMPRESS 0
-#define HAVE_MACHINE_IOCTL_BT848_H 0
-#define HAVE_MACHINE_IOCTL_METEOR_H 0
-#define HAVE_MAKEINFO 1
-#define HAVE_MALLOC_H 1
-#define HAVE_MAPVIEWOFFILE 1
-#define HAVE_MEMALIGN 0
-#define HAVE_MKSTEMP 0
-#define HAVE_MM_EMPTY 0
-#define HAVE_MMAP 0
-#define HAVE_MPROTECT 1
-#define HAVE_NANOSLEEP 0
-#define HAVE_NETINET_SCTP_H 0
-#define HAVE_PEEKNAMEDPIPE 1
-#define HAVE_PERL 0
-#define HAVE_POD2MAN 0
-#define HAVE_POLL_H 0
-#define HAVE_POSIX_MEMALIGN 0
-#define HAVE_PTHREAD_CANCEL 0
-#define HAVE_RDTSC 1
-#define HAVE_RWEFLAGS 0
-#define HAVE_SCHED_GETAFFINITY 0
-#define HAVE_SDL 0
-#define HAVE_SDL_VIDEO_SIZE 0
-#define HAVE_SETCONSOLETEXTATTRIBUTE 1
-#define HAVE_SETMODE 1
-#define HAVE_SETRLIMIT 0
-#define HAVE_SLEEP 1
-#define HAVE_SNDIO_H 0
-#define HAVE_SOCKLEN_T 1
-#define HAVE_SOUNDCARD_H 0
-#define HAVE_STRERROR_R 0
-#define HAVE_STRPTIME 0
-#define HAVE_STRUCT_ADDRINFO 1
-#define HAVE_STRUCT_IPV6_MREQ 1
-#define HAVE_STRUCT_RUSAGE_RU_MAXRSS 0
-#define HAVE_STRUCT_SOCKADDR_IN6 1
-#define HAVE_STRUCT_SOCKADDR_SA_LEN 0
-#define HAVE_STRUCT_SOCKADDR_STORAGE 1
-#define HAVE_STRUCT_V4L2_FRMIVALENUM_DISCRETE 0
-#define HAVE_SYMVER 1
-#define HAVE_SYMVER_ASM_LABEL 1
-#define HAVE_SYMVER_GNU_ASM 0
-#define HAVE_SYSCONF 0
-#define HAVE_SYSCTL 0
-#define HAVE_SYS_MMAN_H 0
-#define HAVE_SYS_PARAM_H 1
-#define HAVE_SYS_RESOURCE_H 0
-#define HAVE_SYS_SELECT_H 0
-#define HAVE_SYS_SOUNDCARD_H 0
-#define HAVE_SYS_TIME_H 1
-#define HAVE_SYS_VIDEOIO_H 0
-#define HAVE_TERMIOS_H 0
-#define HAVE_UNISTD_H 1
-#define HAVE_USLEEP 1
-#define HAVE_VFP_ARGS 0
-#define HAVE_WINDOWS_H 1
-#define HAVE_WINSOCK2_H 1
-#define HAVE_XFORM_ASM 0
-#define HAVE_XGETBV 0
-
-
-#define HAVE_THREADS 1
-#define HAVE_W32THREADS 1
-#define HAVE_PTHREADS 0
-#define HAVE_OS2THREADS 0
-#define HAVE_VIRTUALALLOC 1
-#define HAVE_XMM_CLOBBERS 1
-#define HAVE_YASM 1
-
-#define HAVE_ATTRIBUTE_PACKED 1
-#define HAVE_ATTRIBUTE_MAY_ALIAS 1
-
-#define HAVE_ACCESS 1
-#define HAVE_ATANF 1
-#define HAVE_ATAN2F 1
-#define HAVE_CBRT 1
-#define HAVE_CBRTF 1
-#define HAVE_COSF 1
-#define HAVE_EXP2 1
-#define HAVE_EXP2F 1
-#define HAVE_ISINF 1
-#define HAVE_ISNAN 1
-#define HAVE_LDEXPF 1
-#define HAVE_LLRINT 1
-#define HAVE_LLRINTF 1
-#define HAVE_LOG2 1
-#define HAVE_LOG2F 1
-#define HAVE_LOG10F 1
-#define HAVE_LRINT 1
-#define HAVE_LRINTF 1
-#define HAVE_POWF 1
-#define HAVE_RINT 1
-#define HAVE_ROUND 1
-#define HAVE_ROUNDF 1
-#define HAVE_SINF 1
-#define HAVE_TRUNC 1
-#define HAVE_TRUNCF 1
-
-
-#define CONFIG_DCT 1
-#define CONFIG_DWT 0
-#define CONFIG_FAST_UNALIGNED 1
-#define CONFIG_FFT 1
-#define CONFIG_FTRAPV 0
-#define CONFIG_GPL 1
-#define CONFIG_GRAY 1
-#define CONFIG_H264CHROMA 1
-#define CONFIG_H264DSP 1
-#define CONFIG_H264PRED 1
-#define CONFIG_H264QPEL 1
-#define CONFIG_HARDCODED_TABLES 0
-#define CONFIG_HUFFMAN 1
-#define CONFIG_LIBXVID 0
-#define CONFIG_LPC 0
-#define CONFIG_MDCT 1
-#define CONFIG_MEMALIGN_HACK 0
-#define CONFIG_MEMORY_POISONING 0
-#define CONFIG_MPEGAUDIODSP 1
-#define CONFIG_RDFT 1
-#define CONFIG_RUNTIME_CPUDETECT 1
-#define CONFIG_SMALL 0
-#define CONFIG_VIDEODSP 1
-#define CONFIG_VP3DSP 1
-#define CONFIG_ZLIB 1
-
-#define CONFIG_DECODERS 1
-#define CONFIG_ENCODERS 0
-#define CONFIG_SWSCALE 1
-#define CONFIG_SWSCALE_ALPHA 1
-#define CONFIG_POSTPROC 0
-
-/*
-Note: when adding a new codec, you have to:
-1) Add a
- #define CONFIG_<codec suffix>_<ENCODER|DECODER|PARSER>
- depending on the type of codec you are adding
-2) Add a
- REGISTER_<ENCODER|DECODER|PARSER> (<codec suffix>, <codec suffix lowercase>);
- line to libavcodec/allcodecs.c
-*/
-
-#include "../../mpc-hc/InternalFiltersConfig.h"
-
-#define CONFIG_AASC_DECODER 0
-#define CONFIG_AMV_DECODER INTERNAL_DECODER_AMVV
-#define CONFIG_ASV1_DECODER 0
-#define CONFIG_ASV2_DECODER 0
-#define CONFIG_AVS_DECODER 0
-#define CONFIG_CAVS_DECODER 0
-#define CONFIG_CINEPAK_DECODER 0
-#define CONFIG_CSCD_DECODER 0
-#define CONFIG_CYUV_DECODER 0
-#define CONFIG_DVVIDEO_DECODER 0
-#define CONFIG_EIGHTBPS_DECODER 0
-#define CONFIG_FFV1_DECODER 0
-#define CONFIG_FFVHUFF_DECODER 0
-#define CONFIG_FLV_DECODER INTERNAL_DECODER_FLV
-#define CONFIG_FRAPS_DECODER 0
-#define CONFIG_H261_DECODER 0
-#define CONFIG_H263_DECODER INTERNAL_DECODER_H263
-#define CONFIG_H263I_DECODER INTERNAL_DECODER_H263
-#define CONFIG_H263P_DECODER INTERNAL_DECODER_H263
-#define CONFIG_H264_DECODER (INTERNAL_DECODER_H264 || INTERNAL_DECODER_H264_DXVA)
-#define CONFIG_HUFFYUV_DECODER 0
-#define CONFIG_INDEO2_DECODER 0
-#define CONFIG_INDEO3_DECODER INTERNAL_DECODER_INDEO
-#define CONFIG_INDEO4_DECODER INTERNAL_DECODER_INDEO
-#define CONFIG_INDEO5_DECODER INTERNAL_DECODER_INDEO
-#define CONFIG_JPEGLS_DECODER 0
-#define CONFIG_LOCO_DECODER 0
-#define CONFIG_MJPEG_DECODER INTERNAL_DECODER_MJPEG
-#define CONFIG_MJPEGB_DECODER INTERNAL_DECODER_MJPEG
-#define CONFIG_MPEG1VIDEO_DECODER 0
-#define CONFIG_MPEG2VIDEO_DECODER INTERNAL_DECODER_MPEG2_DXVA
-#define CONFIG_MPEG4_DECODER (INTERNAL_DECODER_XVID || INTERNAL_DECODER_DIVX)
-#define CONFIG_MPEGVIDEO_DECODER 0
-#define CONFIG_MSMPEG4V1_DECODER INTERNAL_DECODER_MSMPEG4
-#define CONFIG_MSMPEG4V2_DECODER INTERNAL_DECODER_MSMPEG4
-#define CONFIG_MSMPEG4V3_DECODER INTERNAL_DECODER_MSMPEG4
-#define CONFIG_MSRLE_DECODER 0
-#define CONFIG_MSVIDEO1_DECODER 0
-#define CONFIG_MSZH_DECODER 0
-#define CONFIG_PNG_DECODER 0
-#define CONFIG_QPEG_DECODER 0
-#define CONFIG_QTRLE_DECODER 0
-#define CONFIG_RPZA_DECODER 0
-#define CONFIG_RV10_DECODER INTERNAL_DECODER_REALVIDEO
-#define CONFIG_RV20_DECODER INTERNAL_DECODER_REALVIDEO
-#define CONFIG_RV30_DECODER INTERNAL_DECODER_REALVIDEO
-#define CONFIG_RV40_DECODER INTERNAL_DECODER_REALVIDEO
-#define CONFIG_SNOW_DECODER 0
-#define CONFIG_SP5X_DECODER INTERNAL_DECODER_MJPEG
-#define CONFIG_SVQ1_DECODER INTERNAL_DECODER_SVQ
-#define CONFIG_SVQ3_DECODER INTERNAL_DECODER_SVQ
-#define CONFIG_THEORA_DECODER INTERNAL_DECODER_THEORA
-#define CONFIG_TRUEMOTION1_DECODER 0
-#define CONFIG_TRUEMOTION2_DECODER 0
-#define CONFIG_TSCC_DECODER INTERNAL_DECODER_SCREEN
-#define CONFIG_ULTI_DECODER 0
-#define CONFIG_VC1_DECODER (INTERNAL_DECODER_VC1 || INTERNAL_DECODER_VC1_DXVA)
-#define CONFIG_VC1IMAGE_DECODER 0
-#define CONFIG_VCR1_DECODER 0
-#define CONFIG_VMNC_DECODER INTERNAL_DECODER_SCREEN
-#define CONFIG_VP3_DECODER INTERNAL_DECODER_VP356
-#define CONFIG_VP5_DECODER INTERNAL_DECODER_VP356
-#define CONFIG_VP6_DECODER INTERNAL_DECODER_VP356
-#define CONFIG_VP6A_DECODER INTERNAL_DECODER_VP356
-#define CONFIG_VP6F_DECODER INTERNAL_DECODER_VP356
-#define CONFIG_VP8_DECODER INTERNAL_DECODER_VP8
-#define CONFIG_WMV1_DECODER INTERNAL_DECODER_WMV
-#define CONFIG_WMV2_DECODER INTERNAL_DECODER_WMV
-#define CONFIG_WMV3_DECODER INTERNAL_DECODER_WMV
-#define CONFIG_WMV3IMAGE_DECODER 0
-#define CONFIG_WNV1_DECODER 0
-#define CONFIG_XL_DECODER 0
-#define CONFIG_ZLIB_DECODER 0
-#define CONFIG_ZMBV_DECODER 0
-
-#define CONFIG_AAC_DECODER INTERNAL_DECODER_AAC
-#define CONFIG_AAC_LATM_DECODER INTERNAL_DECODER_AAC
-#define CONFIG_AC3_DECODER INTERNAL_DECODER_AC3
-#define CONFIG_ALAC_DECODER INTERNAL_DECODER_ALAC
-#define CONFIG_ALS_DECODER INTERNAL_DECODER_ALS
-#define CONFIG_ATRAC3_DECODER INTERNAL_DECODER_REALAUDIO
-#define CONFIG_COOK_DECODER INTERNAL_DECODER_REALAUDIO
-#define CONFIG_DCA_DECODER INTERNAL_DECODER_DTS
-#define CONFIG_EAC3_DECODER INTERNAL_DECODER_AC3
-#define CONFIG_FLAC_DECODER INTERNAL_DECODER_FLAC
-#define CONFIG_GSM_DECODER 0
-#define CONFIG_GSM_MS_DECODER 0
-#define CONFIG_IMC_DECODER 0
-#define CONFIG_MACE3_DECODER 0
-#define CONFIG_MACE6_DECODER 0
-#define CONFIG_MLP_DECODER INTERNAL_DECODER_AC3
-#define CONFIG_MP1_DECODER 0
-#define CONFIG_MP1FLOAT_DECODER INTERNAL_DECODER_MPEGAUDIO
-#define CONFIG_MP2_DECODER 0
-#define CONFIG_MP2FLOAT_DECODER INTERNAL_DECODER_MPEGAUDIO
-#define CONFIG_MP3_DECODER 0
-#define CONFIG_MP3FLOAT_DECODER INTERNAL_DECODER_MPEGAUDIO
-#define CONFIG_NELLYMOSER_DECODER INTERNAL_DECODER_NELLYMOSER
-#define CONFIG_QDM2_DECODER 0
-#define CONFIG_RA_144_DECODER INTERNAL_DECODER_REALAUDIO
-#define CONFIG_RA_288_DECODER INTERNAL_DECODER_REALAUDIO
-#define CONFIG_SIPR_DECODER INTERNAL_DECODER_REALAUDIO
-#define CONFIG_TRUEHD_DECODER INTERNAL_DECODER_AC3
-#define CONFIG_TRUESPEECH_DECODER 0
-#define CONFIG_TTA_DECODER 0
-#define CONFIG_VORBIS_DECODER INTERNAL_DECODER_VORBIS
-#define CONFIG_WAVPACK_DECODER 0
-#define CONFIG_WMAV1_DECODER 0
-#define CONFIG_WMAV2_DECODER 0
-#define CONFIG_PCM_ALAW_DECODER 0
-#define CONFIG_PCM_MULAW_DECODER 0
-#define CONFIG_ADPCM_4XM_DECODER INTERNAL_DECODER_ADPCM
-#define CONFIG_ADPCM_ADX_DECODER INTERNAL_DECODER_ADPCM
-#define CONFIG_ADPCM_CT_DECODER INTERNAL_DECODER_ADPCM
-#define CONFIG_ADPCM_EA_DECODER INTERNAL_DECODER_ADPCM
-#define CONFIG_ADPCM_G726_DECODER 0
-#define CONFIG_ADPCM_IMA_AMV_DECODER INTERNAL_DECODER_ADPCM
-#define CONFIG_ADPCM_IMA_DK3_DECODER INTERNAL_DECODER_ADPCM
-#define CONFIG_ADPCM_IMA_DK4_DECODER INTERNAL_DECODER_ADPCM
-#define CONFIG_ADPCM_IMA_QT_DECODER INTERNAL_DECODER_ADPCM
-#define CONFIG_ADPCM_IMA_SMJPEG_DECODER INTERNAL_DECODER_ADPCM
-#define CONFIG_ADPCM_IMA_WAV_DECODER INTERNAL_DECODER_ADPCM
-#define CONFIG_ADPCM_IMA_WS_DECODER INTERNAL_DECODER_ADPCM
-#define CONFIG_ADPCM_MS_DECODER 0
-#define CONFIG_ADPCM_SBPRO_2_DECODER INTERNAL_DECODER_ADPCM
-#define CONFIG_ADPCM_SBPRO_3_DECODER INTERNAL_DECODER_ADPCM
-#define CONFIG_ADPCM_SBPRO_4_DECODER INTERNAL_DECODER_ADPCM
-#define CONFIG_ADPCM_SWF_DECODER INTERNAL_DECODER_ADPCM
-#define CONFIG_ADPCM_XA_DECODER INTERNAL_DECODER_ADPCM
-#define CONFIG_ADPCM_YAMAHA_DECODER INTERNAL_DECODER_ADPCM
-
-#define CONFIG_DVVIDEO_ENCODER 0
-#define CONFIG_FFV1_ENCODER 0
-#define CONFIG_FFVHUFF_ENCODER 0
-#define CONFIG_FLV_ENCODER 0
-#define CONFIG_H261_ENCODER 0
-#define CONFIG_H263_ENCODER 0
-#define CONFIG_H263P_ENCODER 0
-#define CONFIG_H264_ENCODER 0
-#define CONFIG_HUFFYUV_ENCODER 0
-#define CONFIG_LJPEG_ENCODER 0
-#define CONFIG_MJPEG_ENCODER 0
-#define CONFIG_MPEG1VIDEO_ENCODER 0
-#define CONFIG_MPEG2VIDEO_ENCODER 0
-#define CONFIG_MPEG4_ENCODER 0
-#define CONFIG_MSMPEG4V1_ENCODER 0
-#define CONFIG_MSMPEG4V2_ENCODER 0
-#define CONFIG_MSMPEG4V3_ENCODER 0
-#define CONFIG_PNG_ENCODER 0
-#define CONFIG_RV10_ENCODER 0
-#define CONFIG_RV20_ENCODER 0
-#define CONFIG_SNOW_ENCODER 0
-#define CONFIG_WMV1_ENCODER 0
-#define CONFIG_WMV2_ENCODER 0
-
-#define CONFIG_AC3_ENCODER 0
-#define CONFIG_AC3_FIXED_ENCODER 0
-#define CONFIG_EAC3_ENCODER 0
-
-#define CONFIG_AAC_PARSER 0
-#define CONFIG_AAC_LATM_PARSER 1
-#define CONFIG_AC3_PARSER INTERNAL_DECODER_AC3
-#define CONFIG_DCA_PARSER INTERNAL_DECODER_DTS
-#define CONFIG_H263_PARSER 0
-#define CONFIG_H264_PARSER 0
-#define CONFIG_MJPEG_PARSER 0
-#define CONFIG_MPEGAUDIO_PARSER INTERNAL_DECODER_MPEGAUDIO
-#define CONFIG_MPEG4VIDEO_PARSER 0
-#define CONFIG_MLP_PARSER INTERNAL_DECODER_AC3
-#define CONFIG_MPEGVIDEO_PARSER INTERNAL_DECODER_MPEG2_DXVA
-
-#define CONFIG_AMRNB_DECODER INTERNAL_DECODER_AMR
-#define CONFIG_AMRWB_DECODER INTERNAL_DECODER_AMR
-
-#define CONFIG_VC1_VDPAU_DECODER 0
-#define CONFIG_MPEG_XVMC_DECODER 0
-
-#define CONFIG_EATGQ_DECODER 0
-#define CONFIG_MPEG4_VDPAU_DECODER 0
-#define CONFIG_H264_VDPAU_DECODER 0
-#define CONFIG_VDPAU 0
-
-#endif /* FFMPEG_CONFIG_H */
diff --git a/src/thirdparty/ffmpeg/custom_code.txt b/src/thirdparty/ffmpeg/custom_code.txt
deleted file mode 100644
index 43f6dc111..000000000
--- a/src/thirdparty/ffmpeg/custom_code.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-This list is compared against the FFmpeg repository.
-
-The following files have MPC-HC specific custom code:
-
-* config.asm
-* config.h
-* makefile
-
-* libavcodec/allcodecs.c
-* libavcodec/avcodec.h
-* libavcodec/h264.c
-* libavcodec/h264.h
-* libavcodec/mpeg12.c
-* libavcodec/mpeg12.h
-* libavcodec/mpegvideo.c
-* libavcodec/pthread.c
-* libavcodec/thread.h
-* libavcodec/utils.c
-* libavcodec/vc1dec.c
-
-* libavutil/mem.c
-
-
-The following files are available only in MPC-HC:
-
-* mpc_helper.c
-* libavcodec/dxva.h
-* libavcodec/h264_dxva.c
-* libavcodec/h264_recov.c
-* libavcodec/vc1_dxva.c
diff --git a/src/thirdparty/ffmpeg/ffmpeg.vcxproj b/src/thirdparty/ffmpeg/ffmpeg.vcxproj
deleted file mode 100644
index 2f91abeea..000000000
--- a/src/thirdparty/ffmpeg/ffmpeg.vcxproj
+++ /dev/null
@@ -1,724 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{438286B7-A9F4-411D-BCC5-948C40E37D8F}</ProjectGuid>
- <RootNamespace>ffmpeg</RootNamespace>
- <Keyword>MakeFileProj</Keyword>
- <ProjectName>ffmpeg</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <Import Project="..\..\platform.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>Makefile</ConfigurationType>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>Makefile</ConfigurationType>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>Makefile</ConfigurationType>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>Makefile</ConfigurationType>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)bin\lib\$(Configuration)_$(Platform)\</OutDir>
- <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)bin\obj\$(Configuration)_$(Platform)\$(ProjectName)\</IntDir>
- <NMakeBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">gccbuild.bat Build x86 Debug Silent Nocolors</NMakeBuildCommandLine>
- <NMakeReBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">gccbuild.bat Rebuild x86 Debug Silent Nocolors</NMakeReBuildCommandLine>
- <NMakeCleanCommandLine Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">gccbuild.bat Clean x86 Debug Silent Nocolors</NMakeCleanCommandLine>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32' And '$(PlatformToolsetVersion)'=='110'">$(SolutionDir)bin12\lib\$(Configuration)_$(Platform)\</OutDir>
- <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32' And '$(PlatformToolsetVersion)'=='110'">$(SolutionDir)bin12\obj\$(Configuration)_$(Platform)\$(ProjectName)\</IntDir>
- <NMakeBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Debug|Win32' And '$(PlatformToolsetVersion)'=='110'">gccbuild.bat Build x86 Debug VS2012 Silent Nocolors</NMakeBuildCommandLine>
- <NMakeReBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Debug|Win32' And '$(PlatformToolsetVersion)'=='110'">gccbuild.bat Rebuild x86 Debug VS2012 Silent Nocolors</NMakeReBuildCommandLine>
- <NMakeCleanCommandLine Condition="'$(Configuration)|$(Platform)'=='Debug|Win32' And '$(PlatformToolsetVersion)'=='110'">gccbuild.bat Clean x86 Debug VS2012 Silent Nocolors</NMakeCleanCommandLine>
- <NMakeOutput Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(OutDir)ffmpeg.lib</NMakeOutput>
- <NMakePreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
- <NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.;..;..\..;libavcodec;libavutil;..\zlib;..\..\..\include;$(NMakeIncludeSearchPath)</NMakeIncludeSearchPath>
- <NMakeForcedIncludes Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(NMakeForcedIncludes)</NMakeForcedIncludes>
- <NMakeAssemblySearchPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(NMakeAssemblySearchPath)</NMakeAssemblySearchPath>
- <NMakeForcedUsingAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(NMakeForcedUsingAssemblies)</NMakeForcedUsingAssemblies>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)bin\lib\$(Configuration)_$(Platform)\</OutDir>
- <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)bin\obj\$(Configuration)_$(Platform)\$(ProjectName)\</IntDir>
- <NMakeBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">gccbuild.bat Build x64 Debug Silent Nocolors</NMakeBuildCommandLine>
- <NMakeReBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">gccbuild.bat Rebuild x64 Debug Silent Nocolors</NMakeReBuildCommandLine>
- <NMakeCleanCommandLine Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">gccbuild.bat Clean x64 Debug Silent Nocolors</NMakeCleanCommandLine>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64' And '$(PlatformToolsetVersion)'=='110'">$(SolutionDir)bin12\lib\$(Configuration)_$(Platform)\</OutDir>
- <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64' And '$(PlatformToolsetVersion)'=='110'">$(SolutionDir)bin12\obj\$(Configuration)_$(Platform)\$(ProjectName)\</IntDir>
- <NMakeBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Debug|x64' And '$(PlatformToolsetVersion)'=='110'">gccbuild.bat Build x64 Debug VS2012 Silent Nocolors</NMakeBuildCommandLine>
- <NMakeReBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Debug|x64' And '$(PlatformToolsetVersion)'=='110'">gccbuild.bat Rebuild x64 Debug VS2012 Silent Nocolors</NMakeReBuildCommandLine>
- <NMakeCleanCommandLine Condition="'$(Configuration)|$(Platform)'=='Debug|x64' And '$(PlatformToolsetVersion)'=='110'">gccbuild.bat Clean x64 Debug VS2012 Silent Nocolors</NMakeCleanCommandLine>
- <NMakeOutput Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)ffmpeg.lib</NMakeOutput>
- <NMakePreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">WIN64;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
- <NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.;..;..\..;libavcodec;libavutil;..\zlib;..\..\..\include;$(NMakeIncludeSearchPath)</NMakeIncludeSearchPath>
- <NMakeForcedIncludes Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(NMakeForcedIncludes)</NMakeForcedIncludes>
- <NMakeAssemblySearchPath Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(NMakeAssemblySearchPath)</NMakeAssemblySearchPath>
- <NMakeForcedUsingAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(NMakeForcedUsingAssemblies)</NMakeForcedUsingAssemblies>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)bin\lib\$(Configuration)_$(Platform)\</OutDir>
- <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)bin\obj\$(Configuration)_$(Platform)\$(ProjectName)\</IntDir>
- <NMakeBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">gccbuild.bat Build x86 Silent Nocolors</NMakeBuildCommandLine>
- <NMakeReBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">gccbuild.bat Rebuild x86 Silent Nocolors</NMakeReBuildCommandLine>
- <NMakeCleanCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">gccbuild.bat Clean x86 Silent Nocolors</NMakeCleanCommandLine>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32' And '$(PlatformToolsetVersion)'=='110'">$(SolutionDir)bin12\lib\$(Configuration)_$(Platform)\</OutDir>
- <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32' And '$(PlatformToolsetVersion)'=='110'">$(SolutionDir)bin12\obj\$(Configuration)_$(Platform)\$(ProjectName)\</IntDir>
- <NMakeBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32' And '$(PlatformToolsetVersion)'=='110'">gccbuild.bat Build x86 VS2012 Silent Nocolors</NMakeBuildCommandLine>
- <NMakeReBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32' And '$(PlatformToolsetVersion)'=='110'">gccbuild.bat Rebuild x86 VS2012 Silent Nocolors</NMakeReBuildCommandLine>
- <NMakeCleanCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32' And '$(PlatformToolsetVersion)'=='110'">gccbuild.bat Clean x86 VS2012 Silent Nocolors</NMakeCleanCommandLine>
- <NMakeOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(OutDir)ffmpeg.lib</NMakeOutput>
- <NMakePreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">WIN32;NDEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
- <NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.;..;..\..;libavcodec;libavutil;..\zlib;..\..\..\include;$(NMakeIncludeSearchPath)</NMakeIncludeSearchPath>
- <NMakeForcedIncludes Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeForcedIncludes)</NMakeForcedIncludes>
- <NMakeAssemblySearchPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeAssemblySearchPath)</NMakeAssemblySearchPath>
- <NMakeForcedUsingAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeForcedUsingAssemblies)</NMakeForcedUsingAssemblies>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)bin\lib\$(Configuration)_$(Platform)\</OutDir>
- <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)bin\obj\$(Configuration)_$(Platform)\$(ProjectName)\</IntDir>
- <NMakeBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|x64'">gccbuild.bat Build x64 Silent Nocolors</NMakeBuildCommandLine>
- <NMakeReBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|x64'">gccbuild.bat Rebuild x64 Silent Nocolors</NMakeReBuildCommandLine>
- <NMakeCleanCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|x64'">gccbuild.bat Clean x64 Silent Nocolors</NMakeCleanCommandLine>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64' And '$(PlatformToolsetVersion)'=='110'">$(SolutionDir)bin12\lib\$(Configuration)_$(Platform)\</OutDir>
- <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64' And '$(PlatformToolsetVersion)'=='110'">$(SolutionDir)bin12\obj\$(Configuration)_$(Platform)\$(ProjectName)\</IntDir>
- <NMakeBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|x64' And '$(PlatformToolsetVersion)'=='110'">gccbuild.bat Build x64 VS2012 Silent Nocolors</NMakeBuildCommandLine>
- <NMakeReBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|x64' And '$(PlatformToolsetVersion)'=='110'">gccbuild.bat Rebuild x64 VS2012 Silent Nocolors</NMakeReBuildCommandLine>
- <NMakeCleanCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|x64' And '$(PlatformToolsetVersion)'=='110'">gccbuild.bat Clean x64 VS2012 Silent Nocolors</NMakeCleanCommandLine>
- <NMakeOutput Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)ffmpeg.lib</NMakeOutput>
- <NMakePreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">WIN64;NDEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
- <NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.;..;..\..;libavcodec;libavutil;..\zlib;..\..\..\include;$(NMakeIncludeSearchPath)</NMakeIncludeSearchPath>
- <NMakeForcedIncludes Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(NMakeForcedIncludes)</NMakeForcedIncludes>
- <NMakeAssemblySearchPath Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(NMakeAssemblySearchPath)</NMakeAssemblySearchPath>
- <NMakeForcedUsingAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(NMakeForcedUsingAssemblies)</NMakeForcedUsingAssemblies>
- </PropertyGroup>
- <ItemDefinitionGroup>
- </ItemDefinitionGroup>
- <ItemGroup>
- <None Include="config.asm" />
- <None Include="libavcodec\x86\ac3dsp.asm" />
- <None Include="libavcodec\x86\dct32.asm" />
- <None Include="libavcodec\x86\deinterlace.asm" />
- <None Include="libavcodec\x86\dsputil.asm" />
- <None Include="libavcodec\x86\fft.asm" />
- <None Include="libavcodec\x86\fmtconvert.asm" />
- <None Include="libavcodec\x86\h264_chromamc.asm" />
- <None Include="libavcodec\x86\h264_chromamc_10bit.asm" />
- <None Include="libavcodec\x86\h264_deblock.asm" />
- <None Include="libavcodec\x86\h264_deblock_10bit.asm" />
- <None Include="libavcodec\x86\h264_idct.asm" />
- <None Include="libavcodec\x86\h264_idct_10bit.asm" />
- <None Include="libavcodec\x86\h264_intrapred.asm" />
- <None Include="libavcodec\x86\h264_intrapred_10bit.asm" />
- <None Include="libavcodec\x86\h264_qpel_8bit.asm" />
- <None Include="libavcodec\x86\h264_qpel_10bit.asm" />
- <None Include="libavcodec\x86\h264_weight.asm" />
- <None Include="libavcodec\x86\h264_weight_10bit.asm" />
- <None Include="libavcodec\x86\hpeldsp.asm" />
- <None Include="libavcodec\x86\imdct36.asm" />
- <None Include="libavcodec\x86\mpeg4qpel.asm" />
- <None Include="libavcodec\x86\rv34dsp.asm" />
- <None Include="libavcodec\x86\rv40dsp.asm" />
- <None Include="libavcodec\x86\sbrdsp.asm" />
- <None Include="libavcodec\x86\vc1dsp.asm" />
- <None Include="libavcodec\x86\videodsp.asm" />
- <None Include="libavcodec\x86\vorbisdsp.asm" />
- <None Include="libavcodec\x86\vp3dsp.asm" />
- <None Include="libavcodec\x86\vp56dsp.asm" />
- <None Include="libavcodec\x86\vp8dsp.asm" />
- <None Include="libavresample\x86\audio_convert.asm" />
- <None Include="libavresample\x86\audio_mix.asm" />
- <None Include="libavresample\x86\dither.asm" />
- <None Include="libavresample\x86\util.asm" />
- <None Include="libavutil\x86\cpuid.asm" />
- <None Include="libavutil\x86\emms.asm" />
- <None Include="libavutil\x86\float_dsp.asm" />
- <None Include="libavutil\x86\x86inc.asm" />
- <None Include="libavutil\x86\x86util.asm" />
- <None Include="libswscale\x86\input.asm" />
- <None Include="libswscale\x86\output.asm" />
- <None Include="libswscale\x86\scale.asm" />
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="libavcodec\aacadtsdec.c" />
- <ClCompile Include="libavcodec\aacdec.c" />
- <ClCompile Include="libavcodec\aacps.c" />
- <ClCompile Include="libavcodec\aacpsdata.c" />
- <ClCompile Include="libavcodec\aacpsdsp.c" />
- <ClCompile Include="libavcodec\aacsbr.c" />
- <ClCompile Include="libavcodec\aactab.c" />
- <ClCompile Include="libavcodec\aac_ac3_parser.c" />
- <ClCompile Include="libavcodec\aac_parser.c" />
- <ClCompile Include="libavcodec\ac3.c" />
- <ClCompile Include="libavcodec\ac3dec.c" />
- <ClCompile Include="libavcodec\ac3dec_data.c" />
- <ClCompile Include="libavcodec\ac3dsp.c" />
- <ClCompile Include="libavcodec\ac3tab.c" />
- <ClCompile Include="libavcodec\ac3_parser.c" />
- <ClCompile Include="libavcodec\acelp_filters.c" />
- <ClCompile Include="libavcodec\acelp_pitch_delay.c" />
- <ClCompile Include="libavcodec\acelp_vectors.c" />
- <ClCompile Include="libavcodec\adpcm.c" />
- <ClCompile Include="libavcodec\adpcm_data.c" />
- <ClCompile Include="libavcodec\alac.c" />
- <ClCompile Include="libavcodec\alac_data.c" />
- <ClCompile Include="libavcodec\allcodecs.c" />
- <ClCompile Include="libavcodec\alsdec.c" />
- <ClCompile Include="libavcodec\amrnbdec.c" />
- <ClCompile Include="libavcodec\amrwbdec.c" />
- <ClCompile Include="libavcodec\atrac.c" />
- <ClCompile Include="libavcodec\atrac3.c" />
- <ClCompile Include="libavcodec\avfft.c" />
- <ClCompile Include="libavcodec\avpacket.c" />
- <ClCompile Include="libavcodec\avpicture.c" />
- <ClCompile Include="libavcodec\bgmc.c" />
- <ClCompile Include="libavcodec\bitstream.c" />
- <ClCompile Include="libavcodec\bit_depth_template.c" />
- <ClCompile Include="libavcodec\cabac.c" />
- <ClCompile Include="libavcodec\celp_filters.c" />
- <ClCompile Include="libavcodec\celp_math.c" />
- <ClCompile Include="libavcodec\codec_desc.c" />
- <ClCompile Include="libavcodec\cook.c" />
- <ClCompile Include="libavcodec\dca.c" />
- <ClCompile Include="libavcodec\dcadec.c" />
- <ClCompile Include="libavcodec\dcadsp.c" />
- <ClCompile Include="libavcodec\dca_parser.c" />
- <ClCompile Include="libavcodec\dct.c" />
- <ClCompile Include="libavcodec\dct32.c" />
- <ClCompile Include="libavcodec\dct32_float.c" />
- <ClCompile Include="libavcodec\dsputil.c" />
- <ClCompile Include="libavcodec\dsputil_template.c" />
- <ClCompile Include="libavcodec\eac3dec.c" />
- <ClCompile Include="libavcodec\eac3_data.c" />
- <ClCompile Include="libavcodec\error_resilience.c" />
- <ClCompile Include="libavcodec\faandct.c" />
- <ClCompile Include="libavcodec\faanidct.c" />
- <ClCompile Include="libavcodec\fft.c" />
- <ClCompile Include="libavcodec\flac.c" />
- <ClCompile Include="libavcodec\flacdata.c" />
- <ClCompile Include="libavcodec\flacdec.c" />
- <ClCompile Include="libavcodec\flacdsp.c" />
- <ClCompile Include="libavcodec\flacdsp_lpc_template.c" />
- <ClCompile Include="libavcodec\flacdsp_template.c" />
- <ClCompile Include="libavcodec\flvdec.c" />
- <ClCompile Include="libavcodec\fmtconvert.c" />
- <ClCompile Include="libavcodec\frame_thread_encoder.c" />
- <ClCompile Include="libavcodec\golomb.c" />
- <ClCompile Include="libavcodec\h261.c" />
- <ClCompile Include="libavcodec\h263.c" />
- <ClCompile Include="libavcodec\h263dec.c" />
- <ClCompile Include="libavcodec\h263_parser.c" />
- <ClCompile Include="libavcodec\h264.c" />
- <ClCompile Include="libavcodec\h264addpx_template.c" />
- <ClCompile Include="libavcodec\h264chroma.c" />
- <ClCompile Include="libavcodec\h264chroma_template.c" />
- <ClCompile Include="libavcodec\h264dsp.c" />
- <ClCompile Include="libavcodec\h264dsp_template.c" />
- <ClCompile Include="libavcodec\h264idct.c" />
- <ClCompile Include="libavcodec\h264idct_template.c" />
- <ClCompile Include="libavcodec\h264pred.c" />
- <ClCompile Include="libavcodec\h264pred_template.c" />
- <ClCompile Include="libavcodec\h264qpel.c" />
- <ClCompile Include="libavcodec\h264qpel_template.c" />
- <ClCompile Include="libavcodec\h264_cabac.c" />
- <ClCompile Include="libavcodec\h264_cavlc.c" />
- <ClCompile Include="libavcodec\h264_direct.c" />
- <ClCompile Include="libavcodec\h264_dxva.c" />
- <ClCompile Include="libavcodec\h264_loopfilter.c" />
- <ClCompile Include="libavcodec\h264_mb_template.c" />
- <ClCompile Include="libavcodec\h264_mc_template.c" />
- <ClCompile Include="libavcodec\h264_parser.c" />
- <ClCompile Include="libavcodec\h264_ps.c" />
- <ClCompile Include="libavcodec\h264_recov.c" />
- <ClCompile Include="libavcodec\h264_refs.c" />
- <ClCompile Include="libavcodec\h264_sei.c" />
- <ClCompile Include="libavcodec\hpel_template.c" />
- <ClCompile Include="libavcodec\huffman.c" />
- <ClCompile Include="libavcodec\imgconvert.c" />
- <ClCompile Include="libavcodec\indeo3.c" />
- <ClCompile Include="libavcodec\indeo4.c" />
- <ClCompile Include="libavcodec\indeo5.c" />
- <ClCompile Include="libavcodec\intelh263dec.c" />
- <ClCompile Include="libavcodec\intrax8.c" />
- <ClCompile Include="libavcodec\intrax8dsp.c" />
- <ClCompile Include="libavcodec\ituh263dec.c" />
- <ClCompile Include="libavcodec\ivi_common.c" />
- <ClCompile Include="libavcodec\ivi_dsp.c" />
- <ClCompile Include="libavcodec\jpegls.c" />
- <ClCompile Include="libavcodec\jpeglsdec.c" />
- <ClCompile Include="libavcodec\jrevdct.c" />
- <ClCompile Include="libavcodec\kbdwin.c" />
- <ClCompile Include="libavcodec\latm_parser.c" />
- <ClCompile Include="libavcodec\log2_tab.c" />
- <ClCompile Include="libavcodec\lsp.c" />
- <ClCompile Include="libavcodec\mathtables.c" />
- <ClCompile Include="libavcodec\mdct.c" />
- <ClCompile Include="libavcodec\mjpeg.c" />
- <ClCompile Include="libavcodec\mjpegbdec.c" />
- <ClCompile Include="libavcodec\mjpegdec.c" />
- <ClCompile Include="libavcodec\mlp.c" />
- <ClCompile Include="libavcodec\mlpdec.c" />
- <ClCompile Include="libavcodec\mlpdsp.c" />
- <ClCompile Include="libavcodec\mlp_parser.c" />
- <ClCompile Include="libavcodec\mpeg12.c" />
- <ClCompile Include="libavcodec\mpeg12data.c" />
- <ClCompile Include="libavcodec\mpeg4audio.c" />
- <ClCompile Include="libavcodec\mpeg4video.c" />
- <ClCompile Include="libavcodec\mpeg4videodec.c" />
- <ClCompile Include="libavcodec\mpeg4video_parser.c" />
- <ClCompile Include="libavcodec\mpegaudio.c" />
- <ClCompile Include="libavcodec\mpegaudiodata.c" />
- <ClCompile Include="libavcodec\mpegaudiodec.c" />
- <ClCompile Include="libavcodec\mpegaudiodecheader.c" />
- <ClCompile Include="libavcodec\mpegaudiodec_float.c" />
- <ClCompile Include="libavcodec\mpegaudiodsp.c" />
- <ClCompile Include="libavcodec\mpegaudiodsp_data.c" />
- <ClCompile Include="libavcodec\mpegaudiodsp_fixed.c" />
- <ClCompile Include="libavcodec\mpegaudiodsp_float.c" />
- <ClCompile Include="libavcodec\mpegaudiodsp_template.c" />
- <ClCompile Include="libavcodec\mpegaudio_parser.c" />
- <ClCompile Include="libavcodec\mpegvideo.c" />
- <ClCompile Include="libavcodec\mpegvideo_motion.c" />
- <ClCompile Include="libavcodec\mpegvideo_parser.c" />
- <ClCompile Include="libavcodec\msmpeg4.c" />
- <ClCompile Include="libavcodec\msmpeg4data.c" />
- <ClCompile Include="libavcodec\msrle.c" />
- <ClCompile Include="libavcodec\msrledec.c" />
- <ClCompile Include="libavcodec\nellymoser.c" />
- <ClCompile Include="libavcodec\nellymoserdec.c" />
- <ClCompile Include="libavcodec\options.c" />
- <ClCompile Include="libavcodec\parser.c" />
- <ClCompile Include="libavcodec\pthread.c" />
- <ClCompile Include="libavcodec\ra144.c" />
- <ClCompile Include="libavcodec\ra144dec.c" />
- <ClCompile Include="libavcodec\ra288.c" />
- <ClCompile Include="libavcodec\rdft.c" />
- <ClCompile Include="libavcodec\rv10.c" />
- <ClCompile Include="libavcodec\rv30.c" />
- <ClCompile Include="libavcodec\rv30dsp.c" />
- <ClCompile Include="libavcodec\rv34.c" />
- <ClCompile Include="libavcodec\rv34dsp.c" />
- <ClCompile Include="libavcodec\rv40.c" />
- <ClCompile Include="libavcodec\rv40dsp.c" />
- <ClCompile Include="libavcodec\sbrdsp.c" />
- <ClCompile Include="libavcodec\simple_idct.c" />
- <ClCompile Include="libavcodec\simple_idct_template.c" />
- <ClCompile Include="libavcodec\sinewin.c" />
- <ClCompile Include="libavcodec\sipr.c" />
- <ClCompile Include="libavcodec\sipr16k.c" />
- <ClCompile Include="libavcodec\sp5xdec.c" />
- <ClCompile Include="libavcodec\svq1.c" />
- <ClCompile Include="libavcodec\svq13.c" />
- <ClCompile Include="libavcodec\svq1dec.c" />
- <ClCompile Include="libavcodec\svq3.c" />
- <ClCompile Include="libavcodec\synth_filter.c" />
- <ClCompile Include="libavcodec\tscc.c" />
- <ClCompile Include="libavcodec\utils.c" />
- <ClCompile Include="libavcodec\vc1.c" />
- <ClCompile Include="libavcodec\vc1data.c" />
- <ClCompile Include="libavcodec\vc1dec.c" />
- <ClCompile Include="libavcodec\vc1dsp.c" />
- <ClCompile Include="libavcodec\vc1_dxva.c" />
- <ClCompile Include="libavcodec\videodsp.c" />
- <ClCompile Include="libavcodec\videodsp_template.c" />
- <ClCompile Include="libavcodec\vmnc.c" />
- <ClCompile Include="libavcodec\vorbis.c" />
- <ClCompile Include="libavcodec\vorbisdec.c" />
- <ClCompile Include="libavcodec\vorbisdsp.c" />
- <ClCompile Include="libavcodec\vorbis_data.c" />
- <ClCompile Include="libavcodec\vp3.c" />
- <ClCompile Include="libavcodec\vp3dsp.c" />
- <ClCompile Include="libavcodec\vp5.c" />
- <ClCompile Include="libavcodec\vp56.c" />
- <ClCompile Include="libavcodec\vp56data.c" />
- <ClCompile Include="libavcodec\vp56dsp.c" />
- <ClCompile Include="libavcodec\vp56rac.c" />
- <ClCompile Include="libavcodec\vp6.c" />
- <ClCompile Include="libavcodec\vp6dsp.c" />
- <ClCompile Include="libavcodec\vp8.c" />
- <ClCompile Include="libavcodec\vp8dsp.c" />
- <ClCompile Include="libavcodec\wmv2.c" />
- <ClCompile Include="libavcodec\wmv2dec.c" />
- <ClCompile Include="libavcodec\wmv2dsp.c" />
- <ClCompile Include="libavcodec\x86\ac3dsp_init.c" />
- <ClCompile Include="libavcodec\x86\dsputil_avg_template.c" />
- <ClCompile Include="libavcodec\x86\dsputil_mmx.c" />
- <ClCompile Include="libavcodec\x86\dsputil_qns_template.c" />
- <ClCompile Include="libavcodec\x86\dsputil_rnd_template.c" />
- <ClCompile Include="libavcodec\x86\fdct.c" />
- <ClCompile Include="libavcodec\x86\fft_init.c" />
- <ClCompile Include="libavcodec\x86\fmtconvert_init.c" />
- <ClCompile Include="libavcodec\x86\h264chroma_init.c" />
- <ClCompile Include="libavcodec\x86\h264dsp_init.c" />
- <ClCompile Include="libavcodec\x86\h264_intrapred_init.c" />
- <ClCompile Include="libavcodec\x86\h264_qpel.c" />
- <ClCompile Include="libavcodec\x86\idct_mmx.c" />
- <ClCompile Include="libavcodec\x86\idct_mmx_xvid.c" />
- <ClCompile Include="libavcodec\x86\idct_sse2_xvid.c" />
- <ClCompile Include="libavcodec\x86\mlpdsp.c" />
- <ClCompile Include="libavcodec\x86\motion_est.c" />
- <ClCompile Include="libavcodec\x86\mpegaudiodec.c" />
- <ClCompile Include="libavcodec\x86\mpegvideo.c" />
- <ClCompile Include="libavcodec\x86\rv34dsp_init.c" />
- <ClCompile Include="libavcodec\x86\rv40dsp_init.c" />
- <ClCompile Include="libavcodec\x86\sbrdsp_init.c" />
- <ClCompile Include="libavcodec\x86\simple_idct.c" />
- <ClCompile Include="libavcodec\x86\vc1dsp_init.c" />
- <ClCompile Include="libavcodec\x86\vc1dsp_mmx.c" />
- <ClCompile Include="libavcodec\x86\videodsp_init.c" />
- <ClCompile Include="libavcodec\x86\vorbisdsp_init.c" />
- <ClCompile Include="libavcodec\x86\vp3dsp_init.c" />
- <ClCompile Include="libavcodec\x86\vp56dsp_init.c" />
- <ClCompile Include="libavcodec\x86\vp8dsp_init.c" />
- <ClCompile Include="libavcodec\xiph.c" />
- <ClCompile Include="libavresample\audio_convert.c" />
- <ClCompile Include="libavresample\audio_data.c" />
- <ClCompile Include="libavresample\audio_mix.c" />
- <ClCompile Include="libavresample\audio_mix_matrix.c" />
- <ClCompile Include="libavresample\dither.c" />
- <ClCompile Include="libavresample\options.c" />
- <ClCompile Include="libavresample\resample.c" />
- <ClCompile Include="libavresample\resample_template.c" />
- <ClCompile Include="libavresample\utils.c" />
- <ClCompile Include="libavresample\x86\audio_convert_init.c" />
- <ClCompile Include="libavresample\x86\audio_mix_init.c" />
- <ClCompile Include="libavresample\x86\dither_init.c" />
- <ClCompile Include="libavutil\audio_fifo.c" />
- <ClCompile Include="libavutil\avstring.c" />
- <ClCompile Include="libavutil\bprint.c" />
- <ClCompile Include="libavutil\channel_layout.c" />
- <ClCompile Include="libavutil\cpu.c" />
- <ClCompile Include="libavutil\crc.c" />
- <ClCompile Include="libavutil\dict.c" />
- <ClCompile Include="libavutil\error.c" />
- <ClCompile Include="libavutil\eval.c" />
- <ClCompile Include="libavutil\fifo.c" />
- <ClCompile Include="libavutil\float_dsp.c" />
- <ClCompile Include="libavutil\imgutils.c" />
- <ClCompile Include="libavutil\intfloat_readwrite.c" />
- <ClCompile Include="libavutil\lfg.c" />
- <ClCompile Include="libavutil\lls.c" />
- <ClCompile Include="libavutil\log.c" />
- <ClCompile Include="libavutil\log2_tab.c" />
- <ClCompile Include="libavutil\lzo.c" />
- <ClCompile Include="libavutil\mathematics.c" />
- <ClCompile Include="libavutil\md5.c" />
- <ClCompile Include="libavutil\mem.c" />
- <ClCompile Include="libavutil\opt.c" />
- <ClCompile Include="libavutil\parseutils.c" />
- <ClCompile Include="libavutil\pixdesc.c" />
- <ClCompile Include="libavutil\random_seed.c" />
- <ClCompile Include="libavutil\rational.c" />
- <ClCompile Include="libavutil\samplefmt.c" />
- <ClCompile Include="libavutil\sha.c" />
- <ClCompile Include="libavutil\time.c" />
- <ClCompile Include="libavutil\timecode.c" />
- <ClCompile Include="libavutil\utils.c" />
- <ClCompile Include="libavutil\x86\cpu.c" />
- <ClCompile Include="libavutil\x86\float_dsp_init.c" />
- <ClCompile Include="libswscale\input.c" />
- <ClCompile Include="libswscale\options.c" />
- <ClCompile Include="libswscale\output.c" />
- <ClCompile Include="libswscale\rgb2rgb.c" />
- <ClCompile Include="libswscale\rgb2rgb_template.c" />
- <ClCompile Include="libswscale\swscale.c" />
- <ClCompile Include="libswscale\swscale_unscaled.c" />
- <ClCompile Include="libswscale\utils.c" />
- <ClCompile Include="libswscale\x86\rgb2rgb.c" />
- <ClCompile Include="libswscale\x86\rgb2rgb_template.c" />
- <ClCompile Include="libswscale\x86\swscale.c" />
- <ClCompile Include="libswscale\x86\swscale_template.c" />
- <ClCompile Include="libswscale\x86\yuv2rgb.c" />
- <ClCompile Include="libswscale\x86\yuv2rgb_template.c" />
- <ClCompile Include="libswscale\yuv2rgb.c" />
- <ClCompile Include="mpc_helper.c" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="config.h" />
- <ClInclude Include="libavcodec\aac.h" />
- <ClInclude Include="libavcodec\aacadtsdec.h" />
- <ClInclude Include="libavcodec\aacdectab.h" />
- <ClInclude Include="libavcodec\aacps.h" />
- <ClInclude Include="libavcodec\aacpsdsp.h" />
- <ClInclude Include="libavcodec\aacps_tablegen.h" />
- <ClInclude Include="libavcodec\aacsbr.h" />
- <ClInclude Include="libavcodec\aacsbrdata.h" />
- <ClInclude Include="libavcodec\aactab.h" />
- <ClInclude Include="libavcodec\aac_ac3_parser.h" />
- <ClInclude Include="libavcodec\aac_tablegen.h" />
- <ClInclude Include="libavcodec\aac_tablegen_decl.h" />
- <ClInclude Include="libavcodec\ac3.h" />
- <ClInclude Include="libavcodec\ac3dec.h" />
- <ClInclude Include="libavcodec\ac3dec_data.h" />
- <ClInclude Include="libavcodec\ac3dsp.h" />
- <ClInclude Include="libavcodec\ac3tab.h" />
- <ClInclude Include="libavcodec\ac3_parser.h" />
- <ClInclude Include="libavcodec\acelp_filters.h" />
- <ClInclude Include="libavcodec\acelp_pitch_delay.h" />
- <ClInclude Include="libavcodec\acelp_vectors.h" />
- <ClInclude Include="libavcodec\adpcm.h" />
- <ClInclude Include="libavcodec\adpcm_data.h" />
- <ClInclude Include="libavcodec\alac_data.h" />
- <ClInclude Include="libavcodec\amr.h" />
- <ClInclude Include="libavcodec\amrnbdata.h" />
- <ClInclude Include="libavcodec\amrwbdata.h" />
- <ClInclude Include="libavcodec\atrac.h" />
- <ClInclude Include="libavcodec\atrac3data.h" />
- <ClInclude Include="libavcodec\audioconvert.h" />
- <ClInclude Include="libavcodec\audio_frame_queue.h" />
- <ClInclude Include="libavcodec\avcodec.h" />
- <ClInclude Include="libavcodec\avfft.h" />
- <ClInclude Include="libavcodec\bgmc.h" />
- <ClInclude Include="libavcodec\bytestream.h" />
- <ClInclude Include="libavcodec\cabac.h" />
- <ClInclude Include="libavcodec\cabac_functions.h" />
- <ClInclude Include="libavcodec\cbrt_tablegen.h" />
- <ClInclude Include="libavcodec\celp_filters.h" />
- <ClInclude Include="libavcodec\celp_math.h" />
- <ClInclude Include="libavcodec\cookdata.h" />
- <ClInclude Include="libavcodec\copy_block.h" />
- <ClInclude Include="libavcodec\dca.h" />
- <ClInclude Include="libavcodec\dcadata.h" />
- <ClInclude Include="libavcodec\dcadsp.h" />
- <ClInclude Include="libavcodec\dcahuff.h" />
- <ClInclude Include="libavcodec\dca_parser.h" />
- <ClInclude Include="libavcodec\dct.h" />
- <ClInclude Include="libavcodec\dct32.h" />
- <ClInclude Include="libavcodec\diracdsp.h" />
- <ClInclude Include="libavcodec\dsputil.h" />
- <ClInclude Include="libavcodec\dxva.h" />
- <ClInclude Include="libavcodec\eac3_data.h" />
- <ClInclude Include="libavcodec\faandct.h" />
- <ClInclude Include="libavcodec\faanidct.h" />
- <ClInclude Include="libavcodec\fft-internal.h" />
- <ClInclude Include="libavcodec\fft.h" />
- <ClInclude Include="libavcodec\flac.h" />
- <ClInclude Include="libavcodec\flacdata.h" />
- <ClInclude Include="libavcodec\flacdsp.h" />
- <ClInclude Include="libavcodec\flv.h" />
- <ClInclude Include="libavcodec\fmtconvert.h" />
- <ClInclude Include="libavcodec\frame_thread_encoder.h" />
- <ClInclude Include="libavcodec\get_bits.h" />
- <ClInclude Include="libavcodec\golomb.h" />
- <ClInclude Include="libavcodec\h261.h" />
- <ClInclude Include="libavcodec\h261data.h" />
- <ClInclude Include="libavcodec\h263.h" />
- <ClInclude Include="libavcodec\h263data.h" />
- <ClInclude Include="libavcodec\h263_parser.h" />
- <ClInclude Include="libavcodec\h264.h" />
- <ClInclude Include="libavcodec\h264chroma.h" />
- <ClInclude Include="libavcodec\h264data.h" />
- <ClInclude Include="libavcodec\h264dsp.h" />
- <ClInclude Include="libavcodec\h264idct.h" />
- <ClInclude Include="libavcodec\h264pred.h" />
- <ClInclude Include="libavcodec\h264qpel.h" />
- <ClInclude Include="libavcodec\h264_mvpred.h" />
- <ClInclude Include="libavcodec\huffman.h" />
- <ClInclude Include="libavcodec\imgconvert.h" />
- <ClInclude Include="libavcodec\indeo3data.h" />
- <ClInclude Include="libavcodec\indeo4data.h" />
- <ClInclude Include="libavcodec\indeo5data.h" />
- <ClInclude Include="libavcodec\internal.h" />
- <ClInclude Include="libavcodec\intrax8.h" />
- <ClInclude Include="libavcodec\intrax8dsp.h" />
- <ClInclude Include="libavcodec\intrax8huf.h" />
- <ClInclude Include="libavcodec\ivi_common.h" />
- <ClInclude Include="libavcodec\ivi_dsp.h" />
- <ClInclude Include="libavcodec\jpegls.h" />
- <ClInclude Include="libavcodec\jpeglsdec.h" />
- <ClInclude Include="libavcodec\kbdwin.h" />
- <ClInclude Include="libavcodec\lpc.h" />
- <ClInclude Include="libavcodec\lsp.h" />
- <ClInclude Include="libavcodec\mathops.h" />
- <ClInclude Include="libavcodec\mjpeg.h" />
- <ClInclude Include="libavcodec\mjpegdec.h" />
- <ClInclude Include="libavcodec\mjpegenc.h" />
- <ClInclude Include="libavcodec\mlp.h" />
- <ClInclude Include="libavcodec\mlpdsp.h" />
- <ClInclude Include="libavcodec\mlp_parser.h" />
- <ClInclude Include="libavcodec\mpeg12.h" />
- <ClInclude Include="libavcodec\mpeg12data.h" />
- <ClInclude Include="libavcodec\mpeg12decdata.h" />
- <ClInclude Include="libavcodec\mpeg4audio.h" />
- <ClInclude Include="libavcodec\mpeg4data.h" />
- <ClInclude Include="libavcodec\mpeg4video.h" />
- <ClInclude Include="libavcodec\mpeg4video_parser.h" />
- <ClInclude Include="libavcodec\mpegaudio.h" />
- <ClInclude Include="libavcodec\mpegaudiodata.h" />
- <ClInclude Include="libavcodec\mpegaudiodecheader.h" />
- <ClInclude Include="libavcodec\mpegaudiodectab.h" />
- <ClInclude Include="libavcodec\mpegaudiodsp.h" />
- <ClInclude Include="libavcodec\mpegaudio_tablegen.h" />
- <ClInclude Include="libavcodec\mpegvideo.h" />
- <ClInclude Include="libavcodec\msmpeg4.h" />
- <ClInclude Include="libavcodec\msmpeg4data.h" />
- <ClInclude Include="libavcodec\msrledec.h" />
- <ClInclude Include="libavcodec\nellymoser.h" />
- <ClInclude Include="libavcodec\old_codec_ids.h" />
- <ClInclude Include="libavcodec\options_table.h" />
- <ClInclude Include="libavcodec\parser.h" />
- <ClInclude Include="libavcodec\png.h" />
- <ClInclude Include="libavcodec\put_bits.h" />
- <ClInclude Include="libavcodec\ra144.h" />
- <ClInclude Include="libavcodec\ra288.h" />
- <ClInclude Include="libavcodec\rangecoder.h" />
- <ClInclude Include="libavcodec\ratecontrol.h" />
- <ClInclude Include="libavcodec\rdft.h" />
- <ClInclude Include="libavcodec\rectangle.h" />
- <ClInclude Include="libavcodec\rl.h" />
- <ClInclude Include="libavcodec\rnd_avg.h" />
- <ClInclude Include="libavcodec\rv30data.h" />
- <ClInclude Include="libavcodec\rv34.h" />
- <ClInclude Include="libavcodec\rv34data.h" />
- <ClInclude Include="libavcodec\rv34dsp.h" />
- <ClInclude Include="libavcodec\rv34vlc.h" />
- <ClInclude Include="libavcodec\rv40data.h" />
- <ClInclude Include="libavcodec\rv40vlc2.h" />
- <ClInclude Include="libavcodec\sbr.h" />
- <ClInclude Include="libavcodec\sbrdsp.h" />
- <ClInclude Include="libavcodec\simple_idct.h" />
- <ClInclude Include="libavcodec\sinewin.h" />
- <ClInclude Include="libavcodec\sinewin_tablegen.h" />
- <ClInclude Include="libavcodec\sipr.h" />
- <ClInclude Include="libavcodec\sipr16kdata.h" />
- <ClInclude Include="libavcodec\siprdata.h" />
- <ClInclude Include="libavcodec\sp5x.h" />
- <ClInclude Include="libavcodec\svq1.h" />
- <ClInclude Include="libavcodec\svq1_cb.h" />
- <ClInclude Include="libavcodec\svq1_vlc.h" />
- <ClInclude Include="libavcodec\svq3.h" />
- <ClInclude Include="libavcodec\synth_filter.h" />
- <ClInclude Include="libavcodec\thread.h" />
- <ClInclude Include="libavcodec\unary.h" />
- <ClInclude Include="libavcodec\vc1.h" />
- <ClInclude Include="libavcodec\vc1acdata.h" />
- <ClInclude Include="libavcodec\vc1data.h" />
- <ClInclude Include="libavcodec\vc1dsp.h" />
- <ClInclude Include="libavcodec\vdpau_internal.h" />
- <ClInclude Include="libavcodec\version.h" />
- <ClInclude Include="libavcodec\videodsp.h" />
- <ClInclude Include="libavcodec\vorbis.h" />
- <ClInclude Include="libavcodec\vorbisdsp.h" />
- <ClInclude Include="libavcodec\vp3data.h" />
- <ClInclude Include="libavcodec\vp3dsp.h" />
- <ClInclude Include="libavcodec\vp56.h" />
- <ClInclude Include="libavcodec\vp56data.h" />
- <ClInclude Include="libavcodec\vp56dsp.h" />
- <ClInclude Include="libavcodec\vp5data.h" />
- <ClInclude Include="libavcodec\vp6data.h" />
- <ClInclude Include="libavcodec\vp8.h" />
- <ClInclude Include="libavcodec\vp8data.h" />
- <ClInclude Include="libavcodec\vp8dsp.h" />
- <ClInclude Include="libavcodec\w32pthreads.h" />
- <ClInclude Include="libavcodec\wmv2.h" />
- <ClInclude Include="libavcodec\wmv2dsp.h" />
- <ClInclude Include="libavcodec\x86\cabac.h" />
- <ClInclude Include="libavcodec\x86\diracdsp_mmx.h" />
- <ClInclude Include="libavcodec\x86\dsputil_mmx.h" />
- <ClInclude Include="libavcodec\x86\fft.h" />
- <ClInclude Include="libavcodec\x86\h264_i386.h" />
- <ClInclude Include="libavcodec\x86\idct_xvid.h" />
- <ClInclude Include="libavcodec\x86\mathops.h" />
- <ClInclude Include="libavcodec\x86\vc1dsp.h" />
- <ClInclude Include="libavcodec\x86\vp56_arith.h" />
- <ClInclude Include="libavcodec\xiph.h" />
- <ClInclude Include="libavcodec\xvmc_internal.h" />
- <ClInclude Include="libavresample\audio_convert.h" />
- <ClInclude Include="libavresample\audio_data.h" />
- <ClInclude Include="libavresample\audio_mix.h" />
- <ClInclude Include="libavresample\avresample.h" />
- <ClInclude Include="libavresample\dither.h" />
- <ClInclude Include="libavresample\internal.h" />
- <ClInclude Include="libavresample\resample.h" />
- <ClInclude Include="libavresample\version.h" />
- <ClInclude Include="libavutil\attributes.h" />
- <ClInclude Include="libavutil\audioconvert.h" />
- <ClInclude Include="libavutil\audio_fifo.h" />
- <ClInclude Include="libavutil\avassert.h" />
- <ClInclude Include="libavutil\avconfig.h" />
- <ClInclude Include="libavutil\avstring.h" />
- <ClInclude Include="libavutil\avutil.h" />
- <ClInclude Include="libavutil\bprint.h" />
- <ClInclude Include="libavutil\bswap.h" />
- <ClInclude Include="libavutil\channel_layout.h" />
- <ClInclude Include="libavutil\colorspace.h" />
- <ClInclude Include="libavutil\common.h" />
- <ClInclude Include="libavutil\cpu.h" />
- <ClInclude Include="libavutil\crc.h" />
- <ClInclude Include="libavutil\dict.h" />
- <ClInclude Include="libavutil\error.h" />
- <ClInclude Include="libavutil\eval.h" />
- <ClInclude Include="libavutil\fifo.h" />
- <ClInclude Include="libavutil\float_dsp.h" />
- <ClInclude Include="libavutil\imgutils.h" />
- <ClInclude Include="libavutil\internal.h" />
- <ClInclude Include="libavutil\intfloat.h" />
- <ClInclude Include="libavutil\intfloat_readwrite.h" />
- <ClInclude Include="libavutil\intmath.h" />
- <ClInclude Include="libavutil\intreadwrite.h" />
- <ClInclude Include="libavutil\lfg.h" />
- <ClInclude Include="libavutil\libm.h" />
- <ClInclude Include="libavutil\lls.h" />
- <ClInclude Include="libavutil\log.h" />
- <ClInclude Include="libavutil\lzo.h" />
- <ClInclude Include="libavutil\mathematics.h" />
- <ClInclude Include="libavutil\md5.h" />
- <ClInclude Include="libavutil\mem.h" />
- <ClInclude Include="libavutil\old_pix_fmts.h" />
- <ClInclude Include="libavutil\opt.h" />
- <ClInclude Include="libavutil\parseutils.h" />
- <ClInclude Include="libavutil\pixdesc.h" />
- <ClInclude Include="libavutil\pixfmt.h" />
- <ClInclude Include="libavutil\random_seed.h" />
- <ClInclude Include="libavutil\rational.h" />
- <ClInclude Include="libavutil\samplefmt.h" />
- <ClInclude Include="libavutil\sha.h" />
- <ClInclude Include="libavutil\time.h" />
- <ClInclude Include="libavutil\timecode.h" />
- <ClInclude Include="libavutil\timer.h" />
- <ClInclude Include="libavutil\version.h" />
- <ClInclude Include="libavutil\x86\asm.h" />
- <ClInclude Include="libavutil\x86\bswap.h" />
- <ClInclude Include="libavutil\x86\cpu.h" />
- <ClInclude Include="libavutil\x86\emms.h" />
- <ClInclude Include="libavutil\x86\intreadwrite.h" />
- <ClInclude Include="libavutil\x86\timer.h" />
- <ClInclude Include="libavutil\x86_cpu.h" />
- <ClInclude Include="libswscale\rgb2rgb.h" />
- <ClInclude Include="libswscale\swscale.h" />
- <ClInclude Include="libswscale\swscale_internal.h" />
- <ClInclude Include="libswscale\version.h" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/src/thirdparty/ffmpeg/ffmpeg.vcxproj.filters b/src/thirdparty/ffmpeg/ffmpeg.vcxproj.filters
deleted file mode 100644
index 9551a78b5..000000000
--- a/src/thirdparty/ffmpeg/ffmpeg.vcxproj.filters
+++ /dev/null
@@ -1,1796 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="libavcodec">
- <UniqueIdentifier>{c2fed7ea-5dd1-4366-b969-e4408a26e1a1}</UniqueIdentifier>
- </Filter>
- <Filter Include="libavutil">
- <UniqueIdentifier>{38a96b13-792e-4258-997a-6408508cbb4f}</UniqueIdentifier>
- </Filter>
- <Filter Include="libswscale">
- <UniqueIdentifier>{d1738ff1-c377-4452-b576-6ee9f937f3e9}</UniqueIdentifier>
- </Filter>
- <Filter Include="libswscale\x86">
- <UniqueIdentifier>{9d4ec9b5-51c2-46df-9b8a-0a7003ddd49f}</UniqueIdentifier>
- </Filter>
- <Filter Include="libavutil\x86">
- <UniqueIdentifier>{068000d1-640e-4c5b-b667-8da7ad8df9b8}</UniqueIdentifier>
- </Filter>
- <Filter Include="libavcodec\x86">
- <UniqueIdentifier>{927d8398-e10f-483b-8cb6-9698fad28e24}</UniqueIdentifier>
- </Filter>
- <Filter Include="libavresample">
- <UniqueIdentifier>{5fa17405-6935-47c1-906c-8bdd953556cb}</UniqueIdentifier>
- </Filter>
- <Filter Include="libavresample\x86">
- <UniqueIdentifier>{56d354fb-18f1-4525-b31e-ed4a8c1aebd9}</UniqueIdentifier>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <None Include="config.asm" />
- <None Include="libavcodec\x86\ac3dsp.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\dct32.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\deinterlace.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\dsputil.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\fft.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\fmtconvert.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\h264_chromamc.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\h264_chromamc_10bit.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\h264_deblock.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\h264_deblock_10bit.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\h264_idct.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\h264_idct_10bit.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\h264_intrapred.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\h264_intrapred_10bit.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\h264_qpel_8bit.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\h264_qpel_10bit.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\h264_weight.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\h264_weight_10bit.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\imdct36.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\rv34dsp.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\rv40dsp.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\sbrdsp.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\vc1dsp.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\vp3dsp.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\vp8dsp.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\vp56dsp.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavresample\x86\audio_convert.asm">
- <Filter>libavresample\x86</Filter>
- </None>
- <None Include="libavresample\x86\audio_mix.asm">
- <Filter>libavresample\x86</Filter>
- </None>
- <None Include="libavresample\x86\util.asm">
- <Filter>libavresample\x86</Filter>
- </None>
- <None Include="libavutil\x86\cpuid.asm">
- <Filter>libavutil\x86</Filter>
- </None>
- <None Include="libavutil\x86\float_dsp.asm">
- <Filter>libavutil\x86</Filter>
- </None>
- <None Include="libavutil\x86\x86inc.asm">
- <Filter>libavutil\x86</Filter>
- </None>
- <None Include="libavutil\x86\x86util.asm">
- <Filter>libavutil\x86</Filter>
- </None>
- <None Include="libswscale\x86\input.asm">
- <Filter>libswscale\x86</Filter>
- </None>
- <None Include="libswscale\x86\output.asm">
- <Filter>libswscale\x86</Filter>
- </None>
- <None Include="libswscale\x86\scale.asm">
- <Filter>libswscale\x86</Filter>
- </None>
- <None Include="libavcodec\x86\videodsp.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavresample\x86\dither.asm">
- <Filter>libavresample\x86</Filter>
- </None>
- <None Include="libavutil\x86\emms.asm">
- <Filter>libavutil\x86</Filter>
- </None>
- <None Include="libavcodec\x86\vorbisdsp.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\hpeldsp.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- <None Include="libavcodec\x86\mpeg4qpel.asm">
- <Filter>libavcodec\x86</Filter>
- </None>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="config.h" />
- <ClInclude Include="libavcodec\aac.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\aac_ac3_parser.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\aac_tablegen.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\aac_tablegen_decl.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\aacadtsdec.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\aacdectab.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\aacps.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\aacps_tablegen.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\aacpsdsp.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\aacsbr.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\aacsbrdata.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\aactab.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\ac3.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\ac3_parser.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\ac3dec.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\ac3dec_data.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\ac3dsp.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\ac3tab.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\acelp_filters.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\acelp_pitch_delay.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\acelp_vectors.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\adpcm.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\adpcm_data.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\alac_data.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\amr.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\amrnbdata.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\amrwbdata.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\atrac.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\atrac3data.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\audio_frame_queue.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\audioconvert.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\avcodec.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\avfft.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\bgmc.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\bytestream.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\cabac.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\cabac_functions.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\cbrt_tablegen.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\celp_filters.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\celp_math.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\cookdata.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\dca.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\dca_parser.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\dcadata.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\dcadsp.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\dcahuff.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\dct.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\dct32.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\diracdsp.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\dsputil.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\dxva.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\eac3_data.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\faandct.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\faanidct.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\fft.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\fft-internal.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\flac.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\flacdata.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\flacdsp.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\flv.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\fmtconvert.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\frame_thread_encoder.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\get_bits.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\golomb.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\h261.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\h261data.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\h263.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\h263_parser.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\h263data.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\h264.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\h264_mvpred.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\h264data.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\h264dsp.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\h264pred.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\huffman.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\indeo3data.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\indeo4data.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\indeo5data.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\internal.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\intrax8.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\intrax8dsp.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\intrax8huf.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\ivi_common.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\ivi_dsp.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\jpegls.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\jpeglsdec.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\kbdwin.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\lpc.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\lsp.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\mathops.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\mjpeg.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\mjpegdec.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\mjpegenc.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\mlp.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\mlp_parser.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\mlpdsp.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\mpeg4audio.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\mpeg4data.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\mpeg4video.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\mpeg4video_parser.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\mpeg12.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\mpeg12data.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\mpeg12decdata.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\mpegaudio.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\mpegaudio_tablegen.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\mpegaudiodata.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\mpegaudiodecheader.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\mpegaudiodectab.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\mpegaudiodsp.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\mpegvideo.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\msmpeg4.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\msmpeg4data.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\msrledec.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\nellymoser.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\old_codec_ids.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\options_table.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\parser.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\png.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\put_bits.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\ra144.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\ra288.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\rangecoder.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\ratecontrol.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\rdft.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\rectangle.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\rl.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\rv30data.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\rv34.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\rv34data.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\rv34dsp.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\rv34vlc.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\rv40data.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\rv40vlc2.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\sbr.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\sbrdsp.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\simple_idct.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\sinewin.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\sinewin_tablegen.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\sipr.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\sipr16kdata.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\siprdata.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\sp5x.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\svq1.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\svq1_cb.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\svq1_vlc.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\synth_filter.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\thread.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\unary.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\vc1.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\vc1acdata.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\vc1data.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\vc1dsp.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\vdpau_internal.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\version.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\vorbis.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\vp3data.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\vp3dsp.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\vp5data.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\vp6data.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\vp8.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\vp8data.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\vp8dsp.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\vp56.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\vp56data.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\vp56dsp.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\w32pthreads.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\wmv2.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\xiph.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\xvmc_internal.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\x86\cabac.h">
- <Filter>libavcodec\x86</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\x86\diracdsp_mmx.h">
- <Filter>libavcodec\x86</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\x86\dsputil_mmx.h">
- <Filter>libavcodec\x86</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\x86\fft.h">
- <Filter>libavcodec\x86</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\x86\h264_i386.h">
- <Filter>libavcodec\x86</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\x86\idct_xvid.h">
- <Filter>libavcodec\x86</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\x86\mathops.h">
- <Filter>libavcodec\x86</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\x86\vc1dsp.h">
- <Filter>libavcodec\x86</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\x86\vp56_arith.h">
- <Filter>libavcodec\x86</Filter>
- </ClInclude>
- <ClInclude Include="libavresample\audio_convert.h">
- <Filter>libavresample</Filter>
- </ClInclude>
- <ClInclude Include="libavresample\audio_data.h">
- <Filter>libavresample</Filter>
- </ClInclude>
- <ClInclude Include="libavresample\audio_mix.h">
- <Filter>libavresample</Filter>
- </ClInclude>
- <ClInclude Include="libavresample\avresample.h">
- <Filter>libavresample</Filter>
- </ClInclude>
- <ClInclude Include="libavresample\dither.h">
- <Filter>libavresample</Filter>
- </ClInclude>
- <ClInclude Include="libavresample\internal.h">
- <Filter>libavresample</Filter>
- </ClInclude>
- <ClInclude Include="libavresample\resample.h">
- <Filter>libavresample</Filter>
- </ClInclude>
- <ClInclude Include="libavresample\version.h">
- <Filter>libavresample</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\attributes.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\audio_fifo.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\audioconvert.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\avassert.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\avconfig.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\avstring.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\avutil.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\bprint.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\bswap.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\channel_layout.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\colorspace.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\common.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\cpu.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\crc.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\dict.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\error.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\eval.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\fifo.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\float_dsp.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\imgutils.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\internal.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\intfloat.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\intfloat_readwrite.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\intmath.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\intreadwrite.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\lfg.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\libm.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\lls.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\log.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\lzo.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\mathematics.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\md5.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\mem.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\old_pix_fmts.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\opt.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\parseutils.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\pixdesc.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\pixfmt.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\random_seed.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\rational.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\samplefmt.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\sha.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\timecode.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\timer.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\version.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\x86_cpu.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\x86\asm.h">
- <Filter>libavutil\x86</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\x86\bswap.h">
- <Filter>libavutil\x86</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\x86\cpu.h">
- <Filter>libavutil\x86</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\x86\intreadwrite.h">
- <Filter>libavutil\x86</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\x86\timer.h">
- <Filter>libavutil\x86</Filter>
- </ClInclude>
- <ClInclude Include="libswscale\rgb2rgb.h">
- <Filter>libswscale</Filter>
- </ClInclude>
- <ClInclude Include="libswscale\swscale.h">
- <Filter>libswscale</Filter>
- </ClInclude>
- <ClInclude Include="libswscale\swscale_internal.h">
- <Filter>libswscale</Filter>
- </ClInclude>
- <ClInclude Include="libswscale\version.h">
- <Filter>libswscale</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\videodsp.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\x86\emms.h">
- <Filter>libavutil\x86</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\vorbisdsp.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\wmv2dsp.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavutil\time.h">
- <Filter>libavutil</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\h264qpel.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\h264chroma.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\copy_block.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\h264idct.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\imgconvert.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\rnd_avg.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- <ClInclude Include="libavcodec\svq3.h">
- <Filter>libavcodec</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="mpc_helper.c" />
- <ClCompile Include="libavcodec\aac_ac3_parser.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\aac_parser.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\aacadtsdec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\aacdec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\aacps.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\aacpsdata.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\aacpsdsp.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\aacsbr.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\aactab.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\ac3.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\ac3_parser.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\ac3dec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\ac3dec_data.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\ac3dsp.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\ac3tab.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\acelp_filters.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\acelp_pitch_delay.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\acelp_vectors.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\adpcm.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\adpcm_data.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\alac.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\alac_data.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\allcodecs.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\alsdec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\amrnbdec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\amrwbdec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\atrac.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\atrac3.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\avfft.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\avpacket.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\avpicture.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\bgmc.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\bit_depth_template.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\bitstream.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\cabac.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\celp_filters.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\celp_math.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\codec_desc.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\cook.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\dca.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\dca_parser.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\dcadec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\dcadsp.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\dct.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\dct32.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\dct32_float.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\dsputil.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\dsputil_template.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\eac3_data.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\eac3dec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\error_resilience.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\faandct.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\faanidct.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\fft.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\flac.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\flacdata.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\flacdec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\flacdsp.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\flacdsp_lpc_template.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\flacdsp_template.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\flvdec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\fmtconvert.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\frame_thread_encoder.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\golomb.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h261.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h263.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h263_parser.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h263dec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h264.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h264_cabac.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h264_cavlc.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h264_direct.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h264_dxva.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h264_loopfilter.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h264_mb_template.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h264_mc_template.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h264_parser.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h264_ps.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h264_recov.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h264_refs.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h264_sei.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h264dsp.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h264dsp_template.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h264idct.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h264idct_template.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h264pred.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h264pred_template.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\huffman.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\imgconvert.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\indeo3.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\indeo4.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\indeo5.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\intelh263dec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\intrax8.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\intrax8dsp.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\ituh263dec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\ivi_common.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\ivi_dsp.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\jpegls.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\jpeglsdec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\jrevdct.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\kbdwin.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\latm_parser.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\log2_tab.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\lsp.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mathtables.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mdct.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mjpeg.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mjpegbdec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mjpegdec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mlp.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mlp_parser.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mlpdec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mlpdsp.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mpeg4audio.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mpeg4video.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mpeg4video_parser.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mpeg4videodec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mpeg12.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mpeg12data.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mpegaudio.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mpegaudio_parser.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mpegaudiodata.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mpegaudiodec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mpegaudiodec_float.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mpegaudiodecheader.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mpegaudiodsp.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mpegaudiodsp_data.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mpegaudiodsp_fixed.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mpegaudiodsp_float.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mpegaudiodsp_template.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mpegvideo.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mpegvideo_motion.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\mpegvideo_parser.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\msmpeg4.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\msmpeg4data.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\msrle.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\msrledec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\nellymoser.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\nellymoserdec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\options.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\parser.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\pthread.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\ra144.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\ra144dec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\ra288.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\rdft.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\rv10.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\rv30.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\rv30dsp.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\rv34.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\rv34dsp.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\rv40.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\rv40dsp.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\sbrdsp.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\simple_idct.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\simple_idct_template.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\sinewin.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\sipr.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\sipr16k.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\sp5xdec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\svq1.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\svq1dec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\svq3.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\svq13.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\synth_filter.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\tscc.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\utils.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\vc1.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\vc1_dxva.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\vc1data.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\vc1dec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\vc1dsp.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\vmnc.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\vorbis.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\vorbis_data.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\vorbisdec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\vp3.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\vp3dsp.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\vp5.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\vp6.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\vp6dsp.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\vp8.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\vp8dsp.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\vp56.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\vp56data.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\vp56dsp.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\vp56rac.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\wmv2.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\wmv2dec.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\xiph.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\ac3dsp_init.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\dsputil_avg_template.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\dsputil_mmx.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\dsputil_qns_template.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\dsputil_rnd_template.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\fdct.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\fft_init.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\fmtconvert_init.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\h264_intrapred_init.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\h264_qpel.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\h264dsp_init.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\idct_mmx.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\idct_mmx_xvid.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\idct_sse2_xvid.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\mlpdsp.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\motion_est.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\mpegaudiodec.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\mpegvideo.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\rv34dsp_init.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\rv40dsp_init.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\sbrdsp_init.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\simple_idct.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\vc1dsp_init.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\vc1dsp_mmx.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\vp3dsp_init.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\vp8dsp_init.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\vp56dsp_init.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavresample\audio_convert.c">
- <Filter>libavresample</Filter>
- </ClCompile>
- <ClCompile Include="libavresample\audio_data.c">
- <Filter>libavresample</Filter>
- </ClCompile>
- <ClCompile Include="libavresample\audio_mix.c">
- <Filter>libavresample</Filter>
- </ClCompile>
- <ClCompile Include="libavresample\audio_mix_matrix.c">
- <Filter>libavresample</Filter>
- </ClCompile>
- <ClCompile Include="libavresample\dither.c">
- <Filter>libavresample</Filter>
- </ClCompile>
- <ClCompile Include="libavresample\options.c">
- <Filter>libavresample</Filter>
- </ClCompile>
- <ClCompile Include="libavresample\resample.c">
- <Filter>libavresample</Filter>
- </ClCompile>
- <ClCompile Include="libavresample\resample_template.c">
- <Filter>libavresample</Filter>
- </ClCompile>
- <ClCompile Include="libavresample\utils.c">
- <Filter>libavresample</Filter>
- </ClCompile>
- <ClCompile Include="libavresample\x86\audio_convert_init.c">
- <Filter>libavresample\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavresample\x86\audio_mix_init.c">
- <Filter>libavresample\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\audio_fifo.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\avstring.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\bprint.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\channel_layout.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\cpu.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\crc.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\dict.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\error.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\eval.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\fifo.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\float_dsp.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\imgutils.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\intfloat_readwrite.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\lfg.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\lls.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\log.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\log2_tab.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\lzo.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\mathematics.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\md5.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\mem.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\opt.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\parseutils.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\pixdesc.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\random_seed.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\rational.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\samplefmt.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\sha.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\timecode.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\utils.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\x86\cpu.c">
- <Filter>libavutil\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\x86\float_dsp_init.c">
- <Filter>libavutil\x86</Filter>
- </ClCompile>
- <ClCompile Include="libswscale\input.c">
- <Filter>libswscale</Filter>
- </ClCompile>
- <ClCompile Include="libswscale\options.c">
- <Filter>libswscale</Filter>
- </ClCompile>
- <ClCompile Include="libswscale\output.c">
- <Filter>libswscale</Filter>
- </ClCompile>
- <ClCompile Include="libswscale\rgb2rgb.c">
- <Filter>libswscale</Filter>
- </ClCompile>
- <ClCompile Include="libswscale\rgb2rgb_template.c">
- <Filter>libswscale</Filter>
- </ClCompile>
- <ClCompile Include="libswscale\swscale.c">
- <Filter>libswscale</Filter>
- </ClCompile>
- <ClCompile Include="libswscale\swscale_unscaled.c">
- <Filter>libswscale</Filter>
- </ClCompile>
- <ClCompile Include="libswscale\utils.c">
- <Filter>libswscale</Filter>
- </ClCompile>
- <ClCompile Include="libswscale\yuv2rgb.c">
- <Filter>libswscale</Filter>
- </ClCompile>
- <ClCompile Include="libswscale\x86\rgb2rgb.c">
- <Filter>libswscale\x86</Filter>
- </ClCompile>
- <ClCompile Include="libswscale\x86\rgb2rgb_template.c">
- <Filter>libswscale\x86</Filter>
- </ClCompile>
- <ClCompile Include="libswscale\x86\swscale.c">
- <Filter>libswscale\x86</Filter>
- </ClCompile>
- <ClCompile Include="libswscale\x86\swscale_template.c">
- <Filter>libswscale\x86</Filter>
- </ClCompile>
- <ClCompile Include="libswscale\x86\yuv2rgb.c">
- <Filter>libswscale\x86</Filter>
- </ClCompile>
- <ClCompile Include="libswscale\x86\yuv2rgb_template.c">
- <Filter>libswscale\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\videodsp.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\videodsp_template.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\videodsp_init.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavresample\x86\dither_init.c">
- <Filter>libavresample\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\vorbisdsp_init.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\vorbisdsp.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\wmv2dsp.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavutil\time.c">
- <Filter>libavutil</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h264qpel.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h264qpel_template.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\hpel_template.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h264chroma.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h264chroma_template.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\x86\h264chroma_init.c">
- <Filter>libavcodec\x86</Filter>
- </ClCompile>
- <ClCompile Include="libavcodec\h264addpx_template.c">
- <Filter>libavcodec</Filter>
- </ClCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/src/thirdparty/ffmpeg/gccbuild.bat b/src/thirdparty/ffmpeg/gccbuild.bat
deleted file mode 100644
index f075722de..000000000
--- a/src/thirdparty/ffmpeg/gccbuild.bat
+++ /dev/null
@@ -1,242 +0,0 @@
-@ECHO OFF
-REM (C) 2009-2013 see Authors.txt
-REM
-REM This file is part of MPC-HC.
-REM
-REM MPC-HC is free software; you can redistribute it and/or modify
-REM it under the terms of the GNU General Public License as published by
-REM the Free Software Foundation; either version 3 of the License, or
-REM (at your option) any later version.
-REM
-REM MPC-HC is distributed in the hope that it will be useful,
-REM but WITHOUT ANY WARRANTY; without even the implied warranty of
-REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-REM GNU General Public License for more details.
-REM
-REM You should have received a copy of the GNU General Public License
-REM along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
-SETLOCAL
-PUSHD %~dp0
-
-SET ROOT_DIR=..\..\..
-
-IF EXIST "%ROOT_DIR%\build.user.bat" (
- CALL "%ROOT_DIR%\build.user.bat"
-) ELSE (
- IF DEFINED MINGW32 (SET MPCHC_MINGW32=%MINGW32%) ELSE (GOTO MissingVar)
- IF DEFINED MINGW64 (SET MPCHC_MINGW64=%MINGW64%) ELSE (GOTO MissingVar)
- IF DEFINED MSYS (SET MPCHC_MSYS=%MSYS%) ELSE (GOTO MissingVar)
-)
-
-IF NOT EXIST %MPCHC_MINGW32% GOTO MissingVar
-IF NOT EXIST %MPCHC_MINGW64% GOTO MissingVar
-IF NOT EXIST %MPCHC_MSYS% GOTO MissingVar
-
-SET PATH=%MPCHC_MSYS%\bin;%MPCHC_MINGW32%\bin;%PATH%
-FOR %%G IN (gcc.exe) DO (SET FOUND=%%~$PATH:G)
-IF NOT DEFINED FOUND GOTO MissingVar
-
-SET ARG=/%*
-SET ARG=%ARG:/=%
-SET ARG=%ARG:-=%
-SET ARGB=0
-SET ARGBC=0
-SET ARGCOMP=0
-SET ARGPL=0
-SET INPUT=0
-SET VALID=0
-
-IF /I "%ARG%" == "?" GOTO ShowHelp
-
-FOR %%G IN (%ARG%) DO (
- IF /I "%%G" == "help" GOTO ShowHelp
- IF /I "%%G" == "Build" SET "BUILDTYPE=Build" & SET /A ARGB+=1
- IF /I "%%G" == "Clean" SET "BUILDTYPE=Clean" & SET /A ARGB+=1
- IF /I "%%G" == "Rebuild" SET "BUILDTYPE=Rebuild" & SET /A ARGB+=1
- IF /I "%%G" == "Both" SET "ARCH=Both" & SET /A ARGPL+=1
- IF /I "%%G" == "Win32" SET "ARCH=x86" & SET /A ARGPL+=1
- IF /I "%%G" == "x86" SET "ARCH=x86" & SET /A ARGPL+=1
- IF /I "%%G" == "x64" SET "ARCH=x64" & SET /A ARGPL+=1
- IF /I "%%G" == "Debug" SET "DEBUG=DEBUG=yes" & SET /A ARGBC+=1
- IF /I "%%G" == "Release" SET "DEBUG= " & SET /A ARGBC+=1
- IF /I "%%G" == "VS2010" SET "COMPILER=VS2010" & SET /A ARGCOMP+=1
- IF /I "%%G" == "VS2012" SET "COMPILER=VS2012" & SET /A ARGCOMP+=1
- IF /I "%%G" == "Silent" SET "SILENT=True" & SET /A VALID+=1
- IF /I "%%G" == "Nocolors" SET "NOCOLORS=True" & SET /A VALID+=1
-)
-
-FOR %%X IN (%*) DO SET /A INPUT+=1
-SET /A VALID+=%ARGB%+%ARGPL%+%ARGBC%+%ARGCOMP%
-
-IF %VALID% NEQ %INPUT% GOTO UnsupportedSwitch
-
-IF %ARGB% GTR 1 (GOTO UnsupportedSwitch) ELSE IF %ARGB% == 0 (SET "BUILDTYPE=Build")
-IF %ARGPL% GTR 1 (GOTO UnsupportedSwitch) ELSE IF %ARGPL% == 0 (SET "ARCH=Both")
-IF %ARGBC% GTR 1 (GOTO UnsupportedSwitch) ELSE IF %ARGBC% == 0 (SET "DEBUG= ")
-IF %ARGCOMP% GTR 1 (GOTO UnsupportedSwitch) ELSE IF %ARGCOMP% == 0 (SET "COMPILER=VS2010")
-
-IF /I "%ARCH%" == "Both" (
- SET "ARCH=x86" & CALL :Main
- SET "ARCH=x64" & CALL :Main
-) ELSE (
- CALL :Main
-)
-GOTO End
-
-
-:Main
-IF %ERRORLEVEL% NEQ 0 EXIT /B
-IF /I "%ARCH%" == "x64" (SET "x64=64BIT=yes") ELSE (SET "x64= ")
-
-SET START_TIME=%TIME%
-SET START_DATE=%DATE%
-
-IF /I "%BUILDTYPE%" == "Rebuild" (
- SET "BUILDTYPE=Clean" & CALL :SubMake %x64% %DEBUG% %COMPILER%=yes clean
- CALL :SubCopyLibs
- SET "BUILDTYPE=Build" & CALL :SubMake %x64% %DEBUG% %COMPILER%=yes
- SET "BUILDTYPE=Rebuild"
- EXIT /B
-)
-
-IF /I "%BUILDTYPE%" == "Clean" (CALL :SubMake %x64% %DEBUG% %COMPILER%=yes clean & EXIT /B)
-
-CALL :SubCopyLibs
-CALL :SubMake %x64% %DEBUG% %COMPILER%=yes
-EXIT /B
-
-
-:End
-IF %ERRORLEVEL% NEQ 0 EXIT /B 1
-TITLE Compiling FFmpeg %COMPILER% [FINISHED]
-SET END_TIME=%TIME%
-CALL :SubGetDuration
-CALL :SubMsg "INFO" "FFmpeg compilation started on %START_DATE%-%START_TIME% and completed on %DATE%-%END_TIME% [%DURATION%]"
-POPD
-ENDLOCAL
-EXIT /B
-
-
-:SubMake
-IF %ERRORLEVEL% NEQ 0 EXIT /B
-IF DEFINED NUMBER_OF_PROCESSORS (SET JOBS=%NUMBER_OF_PROCESSORS%) ELSE (SET JOBS=4)
-IF /I "%BUILDTYPE%" == "Clean" (SET JOBS=1)
-
-TITLE make -j%JOBS% %*
-ECHO make -j%JOBS% %*
-make.exe -j%JOBS% %*
-IF %ERRORLEVEL% NEQ 0 CALL :SubMsg "ERROR" "'make -j%JOBS% %*' - failed!"
-EXIT /B
-
-
-:SubCopyLibs
-IF %ERRORLEVEL% NEQ 0 EXIT /B
-REM Set the GCC version
-FOR /F "tokens=1,2 delims= " %%G IN ('gcc -dumpversion') DO (SET "gccver=%%G")
-
-REM Copy the needed libraries
-COPY /Y /V "%MPCHC_MINGW32%\lib\gcc\i686-w64-mingw32\%gccver%\libgcc.a" "%ROOT_DIR%\lib\" >NUL
-COPY /Y /V "%MPCHC_MINGW32%\i686-w64-mingw32\lib\libmingwex.a" "%ROOT_DIR%\lib\" >NUL
-COPY /Y /V "%MPCHC_MINGW64%\lib\gcc\x86_64-w64-mingw32\%gccver%\libgcc.a" "%ROOT_DIR%\lib64\" >NUL
-COPY /Y /V "%MPCHC_MINGW64%\x86_64-w64-mingw32\lib\libmingwex.a" "%ROOT_DIR%\lib64\" >NUL
-EXIT /B
-
-
-:MissingVar
-ECHO Not all build dependencies were found.
-ECHO.
-ECHO See "%ROOT_DIR%\docs\Compilation.txt" for more information.
-CALL :SubMsg "ERROR" "FFmpeg compilation failed!" & EXIT /B 1
-
-
-:UnsupportedSwitch
-ECHO.
-ECHO Unsupported commandline switch!
-ECHO.
-ECHO "%~nx0 %*"
-ECHO.
-ECHO Run "%~nx0 help" for details about the commandline switches.
-CALL :SubMsg "ERROR" "FFmpeg compilation failed!" & EXIT /B 1
-
-
-:ShowHelp
-TITLE %~nx0 Help
-ECHO.
-ECHO Usage:
-ECHO %~nx0 [Clean^|Build^|Rebuild] [x86^|x64^|Both] [Debug^|Release] [VS2010^|VS2012]
-ECHO.
-ECHO Notes: You can also prefix the commands with "-", "--" or "/".
-ECHO The arguments are not case sensitive and can be ommitted.
-ECHO. & ECHO.
-ECHO Executing %~nx0 without any arguments will use the default ones:
-ECHO "%~nx0 Build Both Release VS2010"
-ECHO.
-POPD
-ENDLOCAL
-EXIT /B
-
-
-:SubMsg
-ECHO. & ECHO ------------------------------
-IF /I "%~1" == "ERROR" (
- CALL :SubColorText "0C" "[%~1]" "%~2"
-) ELSE IF /I "%~1" == "INFO" (
- CALL :SubColorText "0A" "[%~1]" "%~2"
-) ELSE IF /I "%~1" == "WARNING" (
- CALL :SubColorText "0E" "[%~1]" "%~2"
-)
-ECHO ------------------------------ & ECHO.
-IF /I "%~1" == "ERROR" (
- IF NOT DEFINED SILENT (
- ECHO Press any key to exit...
- PAUSE >NUL
- )
- POPD
- ENDLOCAL
- EXIT /B 1
-) ELSE (
- EXIT /B
-)
-
-
-:SubColorText
-IF DEFINED NOCOLORS ECHO %~2 %~3 & EXIT /B
-FOR /F "tokens=1,2 delims=#" %%G IN (
- '"PROMPT #$H#$E# & ECHO ON & FOR %%H IN (1) DO REM"') DO (
- SET "DEL=%%G")
-<NUL SET /p ".=%DEL%" > "%~2"
-FINDSTR /v /a:%1 /R ".18" "%~2" NUL
-DEL "%~2" > NUL 2>&1
-ECHO %~3
-EXIT /B
-
-
-:SubGetDuration
-SET START_TIME=%START_TIME: =%
-SET END_TIME=%END_TIME: =%
-
-FOR /F "tokens=1-4 delims=:.," %%G IN ("%START_TIME%") DO (
- SET /A "STARTTIME=(100%%G %% 100) * 360000 + (100%%H %% 100) * 6000 + (100%%I %% 100) * 100 + (100%%J %% 100)"
-)
-
-FOR /F "tokens=1-4 delims=:.," %%G IN ("%END_TIME%") DO (
- SET /A "ENDTIME=(100%%G %% 100) * 360000 + (100%%H %% 100) * 6000 + (100%%I %% 100) * 100 + (100%%J %% 100)"
-)
-
-SET /A DURATION=%ENDTIME%-%STARTTIME%
-IF %ENDTIME% LSS %STARTTIME% SET /A "DURATION+=24 * 360000"
-
-SET /A DURATIONH=%DURATION% / 360000
-SET /A DURATIONM=(%DURATION% - %DURATIONH%*360000) / 6000
-SET /A DURATIONS=(%DURATION% - %DURATIONH%*360000 - %DURATIONM%*6000) / 100
-SET /A DURATIONHS=(%DURATION% - %DURATIONH%*360000 - %DURATIONM%*6000 - %DURATIONS%*100)*10
-
-IF %DURATIONH% EQU 0 (SET DURATIONH=) ELSE (SET DURATIONH=%DURATIONH%h )
-IF %DURATIONM% EQU 0 (SET DURATIONM=) ELSE (SET DURATIONM=%DURATIONM%m )
-IF %DURATIONS% EQU 0 (SET DURATIONS=) ELSE (SET DURATIONS=%DURATIONS%s )
-IF %DURATIONHS% EQU 0 (SET DURATIONHS=) ELSE (SET DURATIONHS=%DURATIONHS%ms)
-
-SET "DURATION=%DURATIONH%%DURATIONM%%DURATIONS%%DURATIONHS%"
-EXIT /B
diff --git a/src/thirdparty/ffmpeg/libavcodec/aac.h b/src/thirdparty/ffmpeg/libavcodec/aac.h
deleted file mode 100644
index 2e97b1791..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/aac.h
+++ /dev/null
@@ -1,336 +0,0 @@
-/*
- * AAC definitions and structures
- * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org )
- * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov 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
- * AAC definitions and structures
- * @author Oded Shimon ( ods15 ods15 dyndns org )
- * @author Maxim Gavrilov ( maxim.gavrilov gmail com )
- */
-
-#ifndef AVCODEC_AAC_H
-#define AVCODEC_AAC_H
-
-#include "libavutil/float_dsp.h"
-#include "avcodec.h"
-#include "dsputil.h"
-#include "fft.h"
-#include "mpeg4audio.h"
-#include "sbr.h"
-#include "fmtconvert.h"
-
-#include <stdint.h>
-
-#define MAX_CHANNELS 64
-#define MAX_ELEM_ID 16
-
-#define TNS_MAX_ORDER 20
-#define MAX_LTP_LONG_SFB 40
-
-enum RawDataBlockType {
- TYPE_SCE,
- TYPE_CPE,
- TYPE_CCE,
- TYPE_LFE,
- TYPE_DSE,
- TYPE_PCE,
- TYPE_FIL,
- TYPE_END,
-};
-
-enum ExtensionPayloadID {
- EXT_FILL,
- EXT_FILL_DATA,
- EXT_DATA_ELEMENT,
- EXT_DYNAMIC_RANGE = 0xb,
- EXT_SBR_DATA = 0xd,
- EXT_SBR_DATA_CRC = 0xe,
-};
-
-enum WindowSequence {
- ONLY_LONG_SEQUENCE,
- LONG_START_SEQUENCE,
- EIGHT_SHORT_SEQUENCE,
- LONG_STOP_SEQUENCE,
-};
-
-enum BandType {
- ZERO_BT = 0, ///< Scalefactors and spectral data are all zero.
- FIRST_PAIR_BT = 5, ///< This and later band types encode two values (rather than four) with one code word.
- ESC_BT = 11, ///< Spectral data are coded with an escape sequence.
- NOISE_BT = 13, ///< Spectral data are scaled white noise not coded in the bitstream.
- INTENSITY_BT2 = 14, ///< Scalefactor data are intensity stereo positions.
- INTENSITY_BT = 15, ///< Scalefactor data are intensity stereo positions.
-};
-
-#define IS_CODEBOOK_UNSIGNED(x) ((x - 1) & 10)
-
-enum ChannelPosition {
- AAC_CHANNEL_OFF = 0,
- AAC_CHANNEL_FRONT = 1,
- AAC_CHANNEL_SIDE = 2,
- AAC_CHANNEL_BACK = 3,
- AAC_CHANNEL_LFE = 4,
- AAC_CHANNEL_CC = 5,
-};
-
-/**
- * The point during decoding at which channel coupling is applied.
- */
-enum CouplingPoint {
- BEFORE_TNS,
- BETWEEN_TNS_AND_IMDCT,
- AFTER_IMDCT = 3,
-};
-
-/**
- * Output configuration status
- */
-enum OCStatus {
- OC_NONE, ///< Output unconfigured
- OC_TRIAL_PCE, ///< Output configuration under trial specified by an inband PCE
- OC_TRIAL_FRAME, ///< Output configuration under trial specified by a frame header
- OC_GLOBAL_HDR, ///< Output configuration set in a global header but not yet locked
- OC_LOCKED, ///< Output configuration locked in place
-};
-
-typedef struct OutputConfiguration {
- MPEG4AudioConfig m4ac;
- uint8_t layout_map[MAX_ELEM_ID*4][3];
- int layout_map_tags;
- int channels;
- uint64_t channel_layout;
- enum OCStatus status;
-} OutputConfiguration;
-
-/**
- * Predictor State
- */
-typedef struct PredictorState {
- float cor0;
- float cor1;
- float var0;
- float var1;
- float r0;
- float r1;
-} PredictorState;
-
-#define MAX_PREDICTORS 672
-
-#define SCALE_DIV_512 36 ///< scalefactor difference that corresponds to scale difference in 512 times
-#define SCALE_ONE_POS 140 ///< scalefactor index that corresponds to scale=1.0
-#define SCALE_MAX_POS 255 ///< scalefactor index maximum value
-#define SCALE_MAX_DIFF 60 ///< maximum scalefactor difference allowed by standard
-#define SCALE_DIFF_ZERO 60 ///< codebook index corresponding to zero scalefactor indices difference
-
-/**
- * Long Term Prediction
- */
-typedef struct LongTermPrediction {
- int8_t present;
- int16_t lag;
- float coef;
- int8_t used[MAX_LTP_LONG_SFB];
-} LongTermPrediction;
-
-/**
- * Individual Channel Stream
- */
-typedef struct IndividualChannelStream {
- uint8_t max_sfb; ///< number of scalefactor bands per group
- enum WindowSequence window_sequence[2];
- uint8_t use_kb_window[2]; ///< If set, use Kaiser-Bessel window, otherwise use a sinus window.
- int num_window_groups;
- uint8_t group_len[8];
- LongTermPrediction ltp;
- const uint16_t *swb_offset; ///< table of offsets to the lowest spectral coefficient of a scalefactor band, sfb, for a particular window
- const uint8_t *swb_sizes; ///< table of scalefactor band sizes for a particular window
- int num_swb; ///< number of scalefactor window bands
- int num_windows;
- int tns_max_bands;
- int predictor_present;
- int predictor_initialized;
- int predictor_reset_group;
- uint8_t prediction_used[41];
-} IndividualChannelStream;
-
-/**
- * Temporal Noise Shaping
- */
-typedef struct TemporalNoiseShaping {
- int present;
- int n_filt[8];
- int length[8][4];
- int direction[8][4];
- int order[8][4];
- float coef[8][4][TNS_MAX_ORDER];
-} TemporalNoiseShaping;
-
-/**
- * Dynamic Range Control - decoded from the bitstream but not processed further.
- */
-typedef struct DynamicRangeControl {
- int pce_instance_tag; ///< Indicates with which program the DRC info is associated.
- int dyn_rng_sgn[17]; ///< DRC sign information; 0 - positive, 1 - negative
- int dyn_rng_ctl[17]; ///< DRC magnitude information
- int exclude_mask[MAX_CHANNELS]; ///< Channels to be excluded from DRC processing.
- int band_incr; ///< Number of DRC bands greater than 1 having DRC info.
- int interpolation_scheme; ///< Indicates the interpolation scheme used in the SBR QMF domain.
- int band_top[17]; ///< Indicates the top of the i-th DRC band in units of 4 spectral lines.
- int prog_ref_level; /**< A reference level for the long-term program audio level for all
- * channels combined.
- */
-} DynamicRangeControl;
-
-typedef struct Pulse {
- int num_pulse;
- int start;
- int pos[4];
- int amp[4];
-} Pulse;
-
-/**
- * coupling parameters
- */
-typedef struct ChannelCoupling {
- enum CouplingPoint coupling_point; ///< The point during decoding at which coupling is applied.
- int num_coupled; ///< number of target elements
- enum RawDataBlockType type[8]; ///< Type of channel element to be coupled - SCE or CPE.
- int id_select[8]; ///< element id
- int ch_select[8]; /**< [0] shared list of gains; [1] list of gains for right channel;
- * [2] list of gains for left channel; [3] lists of gains for both channels
- */
- float gain[16][120];
-} ChannelCoupling;
-
-/**
- * Single Channel Element - used for both SCE and LFE elements.
- */
-typedef struct SingleChannelElement {
- IndividualChannelStream ics;
- TemporalNoiseShaping tns;
- Pulse pulse;
- enum BandType band_type[128]; ///< band types
- int band_type_run_end[120]; ///< band type run end points
- float sf[120]; ///< scalefactors
- int sf_idx[128]; ///< scalefactor indices (used by encoder)
- uint8_t zeroes[128]; ///< band is not coded (used by encoder)
- DECLARE_ALIGNED(32, float, coeffs)[1024]; ///< coefficients for IMDCT
- DECLARE_ALIGNED(32, float, saved)[1024]; ///< overlap
- DECLARE_ALIGNED(32, float, ret_buf)[2048]; ///< PCM output buffer
- DECLARE_ALIGNED(16, float, ltp_state)[3072]; ///< time signal for LTP
- PredictorState predictor_state[MAX_PREDICTORS];
- float *ret; ///< PCM output
-} SingleChannelElement;
-
-/**
- * channel element - generic struct for SCE/CPE/CCE/LFE
- */
-typedef struct ChannelElement {
- // CPE specific
- int common_window; ///< Set if channels share a common 'IndividualChannelStream' in bitstream.
- int ms_mode; ///< Signals mid/side stereo flags coding mode (used by encoder)
- uint8_t ms_mask[128]; ///< Set if mid/side stereo is used for each scalefactor window band
- // shared
- SingleChannelElement ch[2];
- // CCE specific
- ChannelCoupling coup;
- SpectralBandReplication sbr;
-} ChannelElement;
-
-typedef struct AACContext AACContext;
-
-/**
- * main AAC context
- */
-struct AACContext {
- AVClass *class;
- AVCodecContext *avctx;
- AVFrame *frame;
-
- int is_saved; ///< Set if elements have stored overlap from previous frame.
- DynamicRangeControl che_drc;
-
- /**
- * @name Channel element related data
- * @{
- */
- ChannelElement *che[4][MAX_ELEM_ID];
- ChannelElement *tag_che_map[4][MAX_ELEM_ID];
- int tags_mapped;
- /** @} */
-
- /**
- * @name temporary aligned temporary buffers
- * (We do not want to have these on the stack.)
- * @{
- */
- DECLARE_ALIGNED(32, float, buf_mdct)[1024];
- /** @} */
-
- /**
- * @name Computed / set up during initialization
- * @{
- */
- FFTContext mdct;
- FFTContext mdct_small;
- FFTContext mdct_ltp;
- FmtConvertContext fmt_conv;
- AVFloatDSPContext fdsp;
- int random_state;
- /** @} */
-
- /**
- * @name Members used for output
- * @{
- */
- SingleChannelElement *output_element[MAX_CHANNELS]; ///< Points to each SingleChannelElement
- /** @} */
-
-
- /**
- * @name Japanese DTV specific extension
- * @{
- */
- int force_dmono_mode;///< 0->not dmono, 1->use first channel, 2->use second channel
- int dmono_mode; ///< 0->not dmono, 1->use first channel, 2->use second channel
- /** @} */
-
- DECLARE_ALIGNED(32, float, temp)[128];
-
- OutputConfiguration oc[2];
- int warned_num_aac_frames;
-
- /* aacdec functions pointers */
- void (*imdct_and_windowing)(AACContext *ac, SingleChannelElement *sce);
- void (*apply_ltp)(AACContext *ac, SingleChannelElement *sce);
- void (*apply_tns)(float coef[1024], TemporalNoiseShaping *tns,
- IndividualChannelStream *ics, int decode);
- void (*windowing_and_mdct_ltp)(AACContext *ac, float *out,
- float *in, IndividualChannelStream *ics);
- void (*update_ltp)(AACContext *ac, SingleChannelElement *sce);
-
-};
-
-void ff_aacdec_init_mips(AACContext *c);
-
-#endif /* AVCODEC_AAC_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/aac_ac3_parser.c b/src/thirdparty/ffmpeg/libavcodec/aac_ac3_parser.c
deleted file mode 100644
index 5e8be2bae..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/aac_ac3_parser.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Common AAC and AC-3 parser
- * Copyright (c) 2003 Fabrice Bellard
- * Copyright (c) 2003 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/common.h"
-#include "parser.h"
-#include "aac_ac3_parser.h"
-
-int ff_aac_ac3_parse(AVCodecParserContext *s1,
- AVCodecContext *avctx,
- const uint8_t **poutbuf, int *poutbuf_size,
- const uint8_t *buf, int buf_size)
-{
- AACAC3ParseContext *s = s1->priv_data;
- ParseContext *pc = &s->pc;
- int len, i;
- int new_frame_start;
-
-get_next:
- i=END_NOT_FOUND;
- if(s->remaining_size <= buf_size){
- if(s->remaining_size && !s->need_next_header){
- i= s->remaining_size;
- s->remaining_size = 0;
- }else{ //we need a header first
- len=0;
- for(i=s->remaining_size; i<buf_size; i++){
- s->state = (s->state<<8) + buf[i];
- if((len=s->sync(s->state, s, &s->need_next_header, &new_frame_start)))
- break;
- }
- if(len<=0){
- i=END_NOT_FOUND;
- }else{
- s->state=0;
- i-= s->header_size -1;
- s->remaining_size = len;
- if(!new_frame_start || pc->index+i<=0){
- s->remaining_size += i;
- goto get_next;
- }
- }
- }
- }
-
- if(ff_combine_frame(pc, i, &buf, &buf_size)<0){
- s->remaining_size -= FFMIN(s->remaining_size, buf_size);
- *poutbuf = NULL;
- *poutbuf_size = 0;
- return buf_size;
- }
-
- *poutbuf = buf;
- *poutbuf_size = buf_size;
-
- /* update codec info */
- if(s->codec_id)
- avctx->codec_id = s->codec_id;
-
- /* Due to backwards compatible HE-AAC the sample rate, channel count,
- and total number of samples found in an AAC ADTS header are not
- reliable. Bit rate is still accurate because the total frame duration in
- seconds is still correct (as is the number of bits in the frame). */
- if (avctx->codec_id != AV_CODEC_ID_AAC) {
- avctx->sample_rate = s->sample_rate;
-
- /* allow downmixing to stereo (or mono for AC-3) */
- if(avctx->request_channels > 0 &&
- avctx->request_channels < s->channels &&
- (avctx->request_channels <= 2 ||
- (avctx->request_channels == 1 &&
- (avctx->codec_id == AV_CODEC_ID_AC3 ||
- avctx->codec_id == AV_CODEC_ID_EAC3)))) {
- avctx->channels = avctx->request_channels;
- } else {
- avctx->channels = s->channels;
- avctx->channel_layout = s->channel_layout;
- }
- s1->duration = s->samples;
- avctx->audio_service_type = s->service_type;
- }
-
- avctx->bit_rate = s->bit_rate;
-
- return i;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/aac_ac3_parser.h b/src/thirdparty/ffmpeg/libavcodec/aac_ac3_parser.h
deleted file mode 100644
index 6ae8eee4f..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/aac_ac3_parser.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Common AAC and AC-3 parser prototypes
- * Copyright (c) 2003 Fabrice Bellard
- * Copyright (c) 2003 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
- */
-
-#ifndef AVCODEC_AAC_AC3_PARSER_H
-#define AVCODEC_AAC_AC3_PARSER_H
-
-#include <stdint.h>
-#include "avcodec.h"
-#include "parser.h"
-
-typedef enum {
- AAC_AC3_PARSE_ERROR_SYNC = -1,
- AAC_AC3_PARSE_ERROR_BSID = -2,
- AAC_AC3_PARSE_ERROR_SAMPLE_RATE = -3,
- AAC_AC3_PARSE_ERROR_FRAME_SIZE = -4,
- AAC_AC3_PARSE_ERROR_FRAME_TYPE = -5,
- AAC_AC3_PARSE_ERROR_CRC = -6,
- AAC_AC3_PARSE_ERROR_CHANNEL_CFG = -7,
-} AACAC3ParseError;
-
-typedef struct AACAC3ParseContext {
- ParseContext pc;
- int frame_size;
- int header_size;
- int (*sync)(uint64_t state, struct AACAC3ParseContext *hdr_info,
- int *need_next_header, int *new_frame_start);
-
- int channels;
- int sample_rate;
- int bit_rate;
- int samples;
- uint64_t channel_layout;
- int service_type;
-
- int remaining_size;
- uint64_t state;
-
- int need_next_header;
- enum AVCodecID codec_id;
-} AACAC3ParseContext;
-
-int ff_aac_ac3_parse(AVCodecParserContext *s1,
- AVCodecContext *avctx,
- const uint8_t **poutbuf, int *poutbuf_size,
- const uint8_t *buf, int buf_size);
-
-#endif /* AVCODEC_AAC_AC3_PARSER_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/aac_parser.c b/src/thirdparty/ffmpeg/libavcodec/aac_parser.c
deleted file mode 100644
index ab6ca4e26..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/aac_parser.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Audio and Video frame extraction
- * Copyright (c) 2003 Fabrice Bellard
- * Copyright (c) 2003 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 "parser.h"
-#include "aac_ac3_parser.h"
-#include "aacadtsdec.h"
-#include "get_bits.h"
-#include "mpeg4audio.h"
-
-static int aac_sync(uint64_t state, AACAC3ParseContext *hdr_info,
- int *need_next_header, int *new_frame_start)
-{
- GetBitContext bits;
- AACADTSHeaderInfo hdr;
- int size;
- union {
- uint64_t u64;
- uint8_t u8[8];
- } tmp;
-
- tmp.u64 = av_be2ne64(state);
- init_get_bits(&bits, tmp.u8+8-AAC_ADTS_HEADER_SIZE, AAC_ADTS_HEADER_SIZE * 8);
-
- if ((size = avpriv_aac_parse_header(&bits, &hdr)) < 0)
- return 0;
- *need_next_header = 0;
- *new_frame_start = 1;
- hdr_info->sample_rate = hdr.sample_rate;
- hdr_info->channels = ff_mpeg4audio_channels[hdr.chan_config];
- hdr_info->samples = hdr.samples;
- hdr_info->bit_rate = hdr.bit_rate;
- return size;
-}
-
-static av_cold int aac_parse_init(AVCodecParserContext *s1)
-{
- AACAC3ParseContext *s = s1->priv_data;
- s->header_size = AAC_ADTS_HEADER_SIZE;
- s->sync = aac_sync;
- return 0;
-}
-
-
-AVCodecParser ff_aac_parser = {
- .codec_ids = { AV_CODEC_ID_AAC },
- .priv_data_size = sizeof(AACAC3ParseContext),
- .parser_init = aac_parse_init,
- .parser_parse = ff_aac_ac3_parse,
- .parser_close = ff_parse_close,
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/aac_tablegen.h b/src/thirdparty/ffmpeg/libavcodec/aac_tablegen.h
deleted file mode 100644
index b4c472742..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/aac_tablegen.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Header file for hardcoded AAC tables
- *
- * Copyright (c) 2010 Alex Converse <alex.converse@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_AAC_TABLEGEN_H
-#define AVCODEC_AAC_TABLEGEN_H
-
-#include "aac_tablegen_decl.h"
-
-#if CONFIG_HARDCODED_TABLES
-#include "libavcodec/aac_tables.h"
-#else
-#include "libavutil/mathematics.h"
-float ff_aac_pow2sf_tab[428];
-
-void ff_aac_tableinit(void)
-{
- int i;
- for (i = 0; i < 428; i++)
- ff_aac_pow2sf_tab[i] = pow(2, (i - POW_SF2_ZERO) / 4.);
-}
-#endif /* CONFIG_HARDCODED_TABLES */
-
-#endif /* AVCODEC_AAC_TABLEGEN_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/aac_tablegen_decl.h b/src/thirdparty/ffmpeg/libavcodec/aac_tablegen_decl.h
deleted file mode 100644
index 0e7e77e6a..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/aac_tablegen_decl.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Header file for hardcoded AAC tables
- *
- * Copyright (c) 2010 Alex Converse <alex.converse@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_AAC_TABLEGEN_DECL_H
-#define AVCODEC_AAC_TABLEGEN_DECL_H
-
-#define POW_SF2_ZERO 200 ///< ff_aac_pow2sf_tab index corresponding to pow(2, 0);
-
-#if CONFIG_HARDCODED_TABLES
-#define ff_aac_tableinit()
-extern const float ff_aac_pow2sf_tab[428];
-#else
-void ff_aac_tableinit(void);
-extern float ff_aac_pow2sf_tab[428];
-#endif /* CONFIG_HARDCODED_TABLES */
-
-#endif /* AVCODEC_AAC_TABLEGEN_DECL_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/aacadtsdec.c b/src/thirdparty/ffmpeg/libavcodec/aacadtsdec.c
deleted file mode 100644
index 4f0beba1a..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/aacadtsdec.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Audio and Video frame extraction
- * Copyright (c) 2003 Fabrice Bellard
- * Copyright (c) 2003 Michael Niedermayer
- * Copyright (c) 2009 Alex Converse
- *
- * 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 "aac_ac3_parser.h"
-#include "aacadtsdec.h"
-#include "get_bits.h"
-#include "mpeg4audio.h"
-
-int avpriv_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr)
-{
- int size, rdb, ch, sr;
- int aot, crc_abs;
-
- if(get_bits(gbc, 12) != 0xfff)
- return AAC_AC3_PARSE_ERROR_SYNC;
-
- skip_bits1(gbc); /* id */
- skip_bits(gbc, 2); /* layer */
- 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])
- return AAC_AC3_PARSE_ERROR_SAMPLE_RATE;
- skip_bits1(gbc); /* private_bit */
- ch = get_bits(gbc, 3); /* channel_configuration */
-
- skip_bits1(gbc); /* original/copy */
- skip_bits1(gbc); /* home */
-
- /* 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)
- return AAC_AC3_PARSE_ERROR_FRAME_SIZE;
-
- skip_bits(gbc, 11); /* adts_buffer_fullness */
- rdb = get_bits(gbc, 2); /* number_of_raw_data_blocks_in_frame */
-
- hdr->object_type = aot + 1;
- hdr->chan_config = ch;
- hdr->crc_absent = crc_abs;
- hdr->num_aac_frames = rdb + 1;
- hdr->sampling_index = sr;
- hdr->sample_rate = avpriv_mpeg4audio_sample_rates[sr];
- hdr->samples = (rdb + 1) * 1024;
- hdr->bit_rate = size * 8 * hdr->sample_rate / hdr->samples;
-
- return size;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/aacadtsdec.h b/src/thirdparty/ffmpeg/libavcodec/aacadtsdec.h
deleted file mode 100644
index 827cd974d..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/aacadtsdec.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * AAC ADTS header decoding prototypes and structures
- * Copyright (c) 2003 Fabrice Bellard
- * Copyright (c) 2003 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
- */
-
-#ifndef AVCODEC_AACADTSDEC_H
-#define AVCODEC_AACADTSDEC_H
-
-#include <stdint.h>
-#include "get_bits.h"
-
-#define AAC_ADTS_HEADER_SIZE 7
-
-typedef struct AACADTSHeaderInfo {
- uint32_t sample_rate;
- uint32_t samples;
- uint32_t bit_rate;
- uint8_t crc_absent;
- uint8_t object_type;
- uint8_t sampling_index;
- uint8_t chan_config;
- uint8_t num_aac_frames;
-} AACADTSHeaderInfo;
-
-/**
- * Parse AAC frame header.
- * Parse the ADTS frame header to the end of the variable header, which is
- * the first 54 bits.
- * @param[in] gbc BitContext containing the first 54 bits of the frame.
- * @param[out] hdr Pointer to struct where header info is written.
- * @return Returns 0 on success, -1 if there is a sync word mismatch,
- * -2 if the version element is invalid, -3 if the sample rate
- * element is invalid, or -4 if the bit rate element is invalid.
- */
-int avpriv_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr);
-
-#endif /* AVCODEC_AACADTSDEC_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/aacdec.c b/src/thirdparty/ffmpeg/libavcodec/aacdec.c
deleted file mode 100644
index c29e079a1..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/aacdec.c
+++ /dev/null
@@ -1,3058 +0,0 @@
-/*
- * AAC decoder
- * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org )
- * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov gmail com )
- *
- * AAC LATM decoder
- * Copyright (c) 2008-2010 Paul Kendall <paul@kcbbs.gen.nz>
- * Copyright (c) 2010 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
- */
-
-/**
- * @file
- * AAC decoder
- * @author Oded Shimon ( ods15 ods15 dyndns org )
- * @author Maxim Gavrilov ( maxim.gavrilov gmail com )
- */
-
-/*
- * supported tools
- *
- * Support? Name
- * N (code in SoC repo) gain control
- * Y block switching
- * Y window shapes - standard
- * N window shapes - Low Delay
- * Y filterbank - standard
- * N (code in SoC repo) filterbank - Scalable Sample Rate
- * Y Temporal Noise Shaping
- * Y Long Term Prediction
- * Y intensity stereo
- * Y channel coupling
- * Y frequency domain prediction
- * Y Perceptual Noise Substitution
- * Y Mid/Side stereo
- * N Scalable Inverse AAC Quantization
- * N Frequency Selective Switch
- * N upsampling filter
- * Y quantization & coding - AAC
- * N quantization & coding - TwinVQ
- * N quantization & coding - BSAC
- * N AAC Error Resilience tools
- * N Error Resilience payload syntax
- * N Error Protection tool
- * N CELP
- * N Silence Compression
- * N HVXC
- * N HVXC 4kbits/s VR
- * N Structured Audio tools
- * N Structured Audio Sample Bank Format
- * N MIDI
- * N Harmonic and Individual Lines plus Noise
- * N Text-To-Speech Interface
- * Y Spectral Band Replication
- * Y (not in this code) Layer-1
- * Y (not in this code) Layer-2
- * Y (not in this code) Layer-3
- * N SinuSoidal Coding (Transient, Sinusoid, Noise)
- * Y Parametric Stereo
- * N Direct Stream Transfer
- *
- * Note: - HE AAC v1 comprises LC AAC with Spectral Band Replication.
- * - HE AAC v2 comprises LC AAC with Spectral Band Replication and
- Parametric Stereo.
- */
-
-#include "libavutil/float_dsp.h"
-#include "libavutil/opt.h"
-#include "avcodec.h"
-#include "internal.h"
-#include "get_bits.h"
-#include "dsputil.h"
-#include "fft.h"
-#include "fmtconvert.h"
-#include "lpc.h"
-#include "kbdwin.h"
-#include "sinewin.h"
-
-#include "aac.h"
-#include "aactab.h"
-#include "aacdectab.h"
-#include "cbrt_tablegen.h"
-#include "sbr.h"
-#include "aacsbr.h"
-#include "mpeg4audio.h"
-#include "aacadtsdec.h"
-#include "libavutil/intfloat.h"
-
-#include <assert.h>
-#include <errno.h>
-#include <math.h>
-#include <string.h>
-
-#if ARCH_ARM
-# include "arm/aac.h"
-#elif ARCH_MIPS
-# include "mips/aacdec_mips.h"
-#endif
-
-static VLC vlc_scalefactors;
-static VLC vlc_spectral[11];
-
-#define overread_err "Input buffer exhausted before END element found\n"
-
-static int count_channels(uint8_t (*layout)[3], int tags)
-{
- int i, sum = 0;
- for (i = 0; i < tags; i++) {
- int syn_ele = layout[i][0];
- int pos = layout[i][2];
- sum += (1 + (syn_ele == TYPE_CPE)) *
- (pos != AAC_CHANNEL_OFF && pos != AAC_CHANNEL_CC);
- }
- return sum;
-}
-
-/**
- * Check for the channel element in the current channel position configuration.
- * If it exists, make sure the appropriate element is allocated and map the
- * channel order to match the internal FFmpeg channel layout.
- *
- * @param che_pos current channel position configuration
- * @param type channel element type
- * @param id channel element id
- * @param channels count of the number of channels in the configuration
- *
- * @return Returns error status. 0 - OK, !0 - error
- */
-static av_cold int che_configure(AACContext *ac,
- enum ChannelPosition che_pos,
- int type, int id, int *channels)
-{
- if (che_pos) {
- if (!ac->che[type][id]) {
- if (!(ac->che[type][id] = av_mallocz(sizeof(ChannelElement))))
- return AVERROR(ENOMEM);
- ff_aac_sbr_ctx_init(ac, &ac->che[type][id]->sbr);
- }
- if (type != TYPE_CCE) {
- if (*channels >= MAX_CHANNELS - (type == TYPE_CPE || (type == TYPE_SCE && ac->oc[1].m4ac.ps == 1))) {
- av_log(ac->avctx, AV_LOG_ERROR, "Too many channels\n");
- return AVERROR_INVALIDDATA;
- }
- ac->output_element[(*channels)++] = &ac->che[type][id]->ch[0];
- if (type == TYPE_CPE ||
- (type == TYPE_SCE && ac->oc[1].m4ac.ps == 1)) {
- ac->output_element[(*channels)++] = &ac->che[type][id]->ch[1];
- }
- }
- } else {
- if (ac->che[type][id])
- ff_aac_sbr_ctx_close(&ac->che[type][id]->sbr);
- av_freep(&ac->che[type][id]);
- }
- return 0;
-}
-
-static int frame_configure_elements(AVCodecContext *avctx)
-{
- AACContext *ac = avctx->priv_data;
- int type, id, ch, ret;
-
- /* set channel pointers to internal buffers by default */
- for (type = 0; type < 4; type++) {
- for (id = 0; id < MAX_ELEM_ID; id++) {
- ChannelElement *che = ac->che[type][id];
- if (che) {
- che->ch[0].ret = che->ch[0].ret_buf;
- che->ch[1].ret = che->ch[1].ret_buf;
- }
- }
- }
-
- /* get output buffer */
- ac->frame->nb_samples = 2048;
- if ((ret = ff_get_buffer(avctx, ac->frame)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return ret;
- }
-
- /* map output channel pointers to AVFrame data */
- for (ch = 0; ch < avctx->channels; ch++) {
- if (ac->output_element[ch])
- ac->output_element[ch]->ret = (float *)ac->frame->extended_data[ch];
- }
-
- return 0;
-}
-
-struct elem_to_channel {
- uint64_t av_position;
- uint8_t syn_ele;
- uint8_t elem_id;
- uint8_t aac_position;
-};
-
-static int assign_pair(struct elem_to_channel e2c_vec[MAX_ELEM_ID],
- uint8_t (*layout_map)[3], int offset, uint64_t left,
- uint64_t right, int pos)
-{
- if (layout_map[offset][0] == TYPE_CPE) {
- e2c_vec[offset] = (struct elem_to_channel) {
- .av_position = left | right, .syn_ele = TYPE_CPE,
- .elem_id = layout_map[offset ][1], .aac_position = pos };
- return 1;
- } else {
- e2c_vec[offset] = (struct elem_to_channel) {
- .av_position = left, .syn_ele = TYPE_SCE,
- .elem_id = layout_map[offset ][1], .aac_position = pos };
- e2c_vec[offset + 1] = (struct elem_to_channel) {
- .av_position = right, .syn_ele = TYPE_SCE,
- .elem_id = layout_map[offset + 1][1], .aac_position = pos };
- return 2;
- }
-}
-
-static int count_paired_channels(uint8_t (*layout_map)[3], int tags, int pos, int *current) {
- int num_pos_channels = 0;
- int first_cpe = 0;
- int sce_parity = 0;
- int i;
- for (i = *current; i < tags; i++) {
- if (layout_map[i][2] != pos)
- break;
- if (layout_map[i][0] == TYPE_CPE) {
- if (sce_parity) {
- if (pos == AAC_CHANNEL_FRONT && !first_cpe) {
- sce_parity = 0;
- } else {
- return -1;
- }
- }
- num_pos_channels += 2;
- first_cpe = 1;
- } else {
- num_pos_channels++;
- sce_parity ^= 1;
- }
- }
- if (sce_parity &&
- ((pos == AAC_CHANNEL_FRONT && first_cpe) || pos == AAC_CHANNEL_SIDE))
- return -1;
- *current = i;
- return num_pos_channels;
-}
-
-static uint64_t sniff_channel_order(uint8_t (*layout_map)[3], int tags)
-{
- int i, n, total_non_cc_elements;
- struct elem_to_channel e2c_vec[4*MAX_ELEM_ID] = {{ 0 }};
- int num_front_channels, num_side_channels, num_back_channels;
- uint64_t layout;
-
- if (FF_ARRAY_ELEMS(e2c_vec) < tags)
- return 0;
-
- i = 0;
- num_front_channels =
- count_paired_channels(layout_map, tags, AAC_CHANNEL_FRONT, &i);
- if (num_front_channels < 0)
- return 0;
- num_side_channels =
- count_paired_channels(layout_map, tags, AAC_CHANNEL_SIDE, &i);
- if (num_side_channels < 0)
- return 0;
- num_back_channels =
- count_paired_channels(layout_map, tags, AAC_CHANNEL_BACK, &i);
- if (num_back_channels < 0)
- return 0;
-
- i = 0;
- if (num_front_channels & 1) {
- e2c_vec[i] = (struct elem_to_channel) {
- .av_position = AV_CH_FRONT_CENTER, .syn_ele = TYPE_SCE,
- .elem_id = layout_map[i][1], .aac_position = AAC_CHANNEL_FRONT };
- i++;
- num_front_channels--;
- }
- if (num_front_channels >= 4) {
- i += assign_pair(e2c_vec, layout_map, i,
- AV_CH_FRONT_LEFT_OF_CENTER,
- AV_CH_FRONT_RIGHT_OF_CENTER,
- AAC_CHANNEL_FRONT);
- num_front_channels -= 2;
- }
- if (num_front_channels >= 2) {
- i += assign_pair(e2c_vec, layout_map, i,
- AV_CH_FRONT_LEFT,
- AV_CH_FRONT_RIGHT,
- AAC_CHANNEL_FRONT);
- num_front_channels -= 2;
- }
- while (num_front_channels >= 2) {
- i += assign_pair(e2c_vec, layout_map, i,
- UINT64_MAX,
- UINT64_MAX,
- AAC_CHANNEL_FRONT);
- num_front_channels -= 2;
- }
-
- if (num_side_channels >= 2) {
- i += assign_pair(e2c_vec, layout_map, i,
- AV_CH_SIDE_LEFT,
- AV_CH_SIDE_RIGHT,
- AAC_CHANNEL_FRONT);
- num_side_channels -= 2;
- }
- while (num_side_channels >= 2) {
- i += assign_pair(e2c_vec, layout_map, i,
- UINT64_MAX,
- UINT64_MAX,
- AAC_CHANNEL_SIDE);
- num_side_channels -= 2;
- }
-
- while (num_back_channels >= 4) {
- i += assign_pair(e2c_vec, layout_map, i,
- UINT64_MAX,
- UINT64_MAX,
- AAC_CHANNEL_BACK);
- num_back_channels -= 2;
- }
- if (num_back_channels >= 2) {
- i += assign_pair(e2c_vec, layout_map, i,
- AV_CH_BACK_LEFT,
- AV_CH_BACK_RIGHT,
- AAC_CHANNEL_BACK);
- num_back_channels -= 2;
- }
- if (num_back_channels) {
- e2c_vec[i] = (struct elem_to_channel) {
- .av_position = AV_CH_BACK_CENTER, .syn_ele = TYPE_SCE,
- .elem_id = layout_map[i][1], .aac_position = AAC_CHANNEL_BACK };
- i++;
- num_back_channels--;
- }
-
- if (i < tags && layout_map[i][2] == AAC_CHANNEL_LFE) {
- e2c_vec[i] = (struct elem_to_channel) {
- .av_position = AV_CH_LOW_FREQUENCY, .syn_ele = TYPE_LFE,
- .elem_id = layout_map[i][1], .aac_position = AAC_CHANNEL_LFE };
- i++;
- }
- while (i < tags && layout_map[i][2] == AAC_CHANNEL_LFE) {
- e2c_vec[i] = (struct elem_to_channel) {
- .av_position = UINT64_MAX, .syn_ele = TYPE_LFE,
- .elem_id = layout_map[i][1], .aac_position = AAC_CHANNEL_LFE };
- i++;
- }
-
- // Must choose a stable sort
- total_non_cc_elements = n = i;
- do {
- int next_n = 0;
- for (i = 1; i < n; i++) {
- if (e2c_vec[i-1].av_position > e2c_vec[i].av_position) {
- FFSWAP(struct elem_to_channel, e2c_vec[i-1], e2c_vec[i]);
- next_n = i;
- }
- }
- n = next_n;
- } while (n > 0);
-
- layout = 0;
- for (i = 0; i < total_non_cc_elements; i++) {
- layout_map[i][0] = e2c_vec[i].syn_ele;
- layout_map[i][1] = e2c_vec[i].elem_id;
- layout_map[i][2] = e2c_vec[i].aac_position;
- if (e2c_vec[i].av_position != UINT64_MAX) {
- layout |= e2c_vec[i].av_position;
- }
- }
-
- return layout;
-}
-
-/**
- * Save current output configuration if and only if it has been locked.
- */
-static void push_output_configuration(AACContext *ac) {
- if (ac->oc[1].status == OC_LOCKED) {
- ac->oc[0] = ac->oc[1];
- }
- ac->oc[1].status = OC_NONE;
-}
-
-/**
- * Restore the previous output configuration if and only if the current
- * configuration is unlocked.
- */
-static void pop_output_configuration(AACContext *ac) {
- if (ac->oc[1].status != OC_LOCKED && ac->oc[0].status != OC_NONE) {
- ac->oc[1] = ac->oc[0];
- ac->avctx->channels = ac->oc[1].channels;
- ac->avctx->channel_layout = ac->oc[1].channel_layout;
- }
-}
-
-/**
- * Configure output channel order based on the current program configuration element.
- *
- * @return Returns error status. 0 - OK, !0 - error
- */
-static int output_configure(AACContext *ac,
- uint8_t layout_map[MAX_ELEM_ID*4][3], int tags,
- enum OCStatus oc_type, int get_new_frame)
-{
- AVCodecContext *avctx = ac->avctx;
- int i, channels = 0, ret;
- uint64_t layout = 0;
-
- if (ac->oc[1].layout_map != layout_map) {
- memcpy(ac->oc[1].layout_map, layout_map, tags * sizeof(layout_map[0]));
- ac->oc[1].layout_map_tags = tags;
- }
-
- // Try to sniff a reasonable channel order, otherwise output the
- // channels in the order the PCE declared them.
- if (avctx->request_channel_layout != AV_CH_LAYOUT_NATIVE)
- layout = sniff_channel_order(layout_map, tags);
- for (i = 0; i < tags; i++) {
- int type = layout_map[i][0];
- int id = layout_map[i][1];
- int position = layout_map[i][2];
- // Allocate or free elements depending on if they are in the
- // current program configuration.
- ret = che_configure(ac, position, type, id, &channels);
- if (ret < 0)
- return ret;
- }
- if (ac->oc[1].m4ac.ps == 1 && channels == 2) {
- if (layout == AV_CH_FRONT_CENTER) {
- layout = AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT;
- } else {
- layout = 0;
- }
- }
-
- memcpy(ac->tag_che_map, ac->che, 4 * MAX_ELEM_ID * sizeof(ac->che[0][0]));
- if (layout) avctx->channel_layout = layout;
- ac->oc[1].channel_layout = layout;
- avctx->channels = ac->oc[1].channels = channels;
- ac->oc[1].status = oc_type;
-
- if (get_new_frame) {
- if ((ret = frame_configure_elements(ac->avctx)) < 0)
- return ret;
- }
-
- return 0;
-}
-
-static void flush(AVCodecContext *avctx)
-{
- AACContext *ac= avctx->priv_data;
- int type, i, j;
-
- for (type = 3; type >= 0; type--) {
- for (i = 0; i < MAX_ELEM_ID; i++) {
- ChannelElement *che = ac->che[type][i];
- if (che) {
- for (j = 0; j <= 1; j++) {
- memset(che->ch[j].saved, 0, sizeof(che->ch[j].saved));
- }
- }
- }
- }
-}
-
-/**
- * Set up channel positions based on a default channel configuration
- * as specified in table 1.17.
- *
- * @return Returns error status. 0 - OK, !0 - error
- */
-static int set_default_channel_config(AVCodecContext *avctx,
- uint8_t (*layout_map)[3],
- int *tags,
- int channel_config)
-{
- if (channel_config < 1 || channel_config > 7) {
- av_log(avctx, AV_LOG_ERROR, "invalid default channel configuration (%d)\n",
- channel_config);
- return -1;
- }
- *tags = tags_per_config[channel_config];
- memcpy(layout_map, aac_channel_layout_map[channel_config-1], *tags * sizeof(*layout_map));
- return 0;
-}
-
-static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
-{
- // For PCE based channel configurations map the channels solely based on tags.
- if (!ac->oc[1].m4ac.chan_config) {
- return ac->tag_che_map[type][elem_id];
- }
- // Allow single CPE stereo files to be signalled with mono configuration.
- if (!ac->tags_mapped && type == TYPE_CPE && ac->oc[1].m4ac.chan_config == 1) {
- uint8_t layout_map[MAX_ELEM_ID*4][3];
- int layout_map_tags;
- push_output_configuration(ac);
-
- av_log(ac->avctx, AV_LOG_DEBUG, "mono with CPE\n");
-
- if (set_default_channel_config(ac->avctx, layout_map, &layout_map_tags,
- 2) < 0)
- return NULL;
- if (output_configure(ac, layout_map, layout_map_tags,
- OC_TRIAL_FRAME, 1) < 0)
- return NULL;
-
- ac->oc[1].m4ac.chan_config = 2;
- ac->oc[1].m4ac.ps = 0;
- }
- // And vice-versa
- if (!ac->tags_mapped && type == TYPE_SCE && ac->oc[1].m4ac.chan_config == 2) {
- uint8_t layout_map[MAX_ELEM_ID*4][3];
- int layout_map_tags;
- push_output_configuration(ac);
-
- av_log(ac->avctx, AV_LOG_DEBUG, "stereo with SCE\n");
-
- if (set_default_channel_config(ac->avctx, layout_map, &layout_map_tags,
- 1) < 0)
- return NULL;
- if (output_configure(ac, layout_map, layout_map_tags,
- OC_TRIAL_FRAME, 1) < 0)
- return NULL;
-
- ac->oc[1].m4ac.chan_config = 1;
- if (ac->oc[1].m4ac.sbr)
- ac->oc[1].m4ac.ps = -1;
- }
- // For indexed channel configurations map the channels solely based on position.
- switch (ac->oc[1].m4ac.chan_config) {
- case 7:
- if (ac->tags_mapped == 3 && type == TYPE_CPE) {
- ac->tags_mapped++;
- return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][2];
- }
- case 6:
- /* Some streams incorrectly code 5.1 audio as SCE[0] CPE[0] CPE[1] SCE[1]
- instead of SCE[0] CPE[0] CPE[1] LFE[0]. If we seem to have
- encountered such a stream, transfer the LFE[0] element to the SCE[1]'s mapping */
- if (ac->tags_mapped == tags_per_config[ac->oc[1].m4ac.chan_config] - 1 && (type == TYPE_LFE || type == TYPE_SCE)) {
- ac->tags_mapped++;
- return ac->tag_che_map[type][elem_id] = ac->che[TYPE_LFE][0];
- }
- case 5:
- if (ac->tags_mapped == 2 && type == TYPE_CPE) {
- ac->tags_mapped++;
- return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][1];
- }
- case 4:
- if (ac->tags_mapped == 2 && ac->oc[1].m4ac.chan_config == 4 && type == TYPE_SCE) {
- ac->tags_mapped++;
- return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][1];
- }
- case 3:
- case 2:
- if (ac->tags_mapped == (ac->oc[1].m4ac.chan_config != 2) && type == TYPE_CPE) {
- ac->tags_mapped++;
- return ac->tag_che_map[TYPE_CPE][elem_id] = ac->che[TYPE_CPE][0];
- } else if (ac->oc[1].m4ac.chan_config == 2) {
- return NULL;
- }
- case 1:
- if (!ac->tags_mapped && type == TYPE_SCE) {
- ac->tags_mapped++;
- return ac->tag_che_map[TYPE_SCE][elem_id] = ac->che[TYPE_SCE][0];
- }
- default:
- return NULL;
- }
-}
-
-/**
- * Decode an array of 4 bit element IDs, optionally interleaved with a stereo/mono switching bit.
- *
- * @param type speaker type/position for these channels
- */
-static void decode_channel_map(uint8_t layout_map[][3],
- enum ChannelPosition type,
- GetBitContext *gb, int n)
-{
- while (n--) {
- enum RawDataBlockType syn_ele;
- switch (type) {
- case AAC_CHANNEL_FRONT:
- case AAC_CHANNEL_BACK:
- case AAC_CHANNEL_SIDE:
- syn_ele = get_bits1(gb);
- break;
- case AAC_CHANNEL_CC:
- skip_bits1(gb);
- syn_ele = TYPE_CCE;
- break;
- case AAC_CHANNEL_LFE:
- syn_ele = TYPE_LFE;
- break;
- default:
- av_assert0(0);
- }
- layout_map[0][0] = syn_ele;
- layout_map[0][1] = get_bits(gb, 4);
- layout_map[0][2] = type;
- layout_map++;
- }
-}
-
-/**
- * Decode program configuration element; reference: table 4.2.
- *
- * @return Returns error status. 0 - OK, !0 - error
- */
-static int decode_pce(AVCodecContext *avctx, MPEG4AudioConfig *m4ac,
- uint8_t (*layout_map)[3],
- GetBitContext *gb)
-{
- int num_front, num_side, num_back, num_lfe, num_assoc_data, num_cc, sampling_index;
- int comment_len;
- int tags;
-
- skip_bits(gb, 2); // object_type
-
- sampling_index = get_bits(gb, 4);
- if (m4ac->sampling_index != sampling_index)
- av_log(avctx, AV_LOG_WARNING, "Sample rate index in program config element does not match the sample rate index configured by the container.\n");
-
- num_front = get_bits(gb, 4);
- num_side = get_bits(gb, 4);
- num_back = get_bits(gb, 4);
- num_lfe = get_bits(gb, 2);
- num_assoc_data = get_bits(gb, 3);
- num_cc = get_bits(gb, 4);
-
- if (get_bits1(gb))
- skip_bits(gb, 4); // mono_mixdown_tag
- if (get_bits1(gb))
- skip_bits(gb, 4); // stereo_mixdown_tag
-
- if (get_bits1(gb))
- skip_bits(gb, 3); // mixdown_coeff_index and pseudo_surround
-
- if (get_bits_left(gb) < 4 * (num_front + num_side + num_back + num_lfe + num_assoc_data + num_cc)) {
- av_log(avctx, AV_LOG_ERROR, "decode_pce: " overread_err);
- return -1;
- }
- decode_channel_map(layout_map , AAC_CHANNEL_FRONT, gb, num_front);
- tags = num_front;
- decode_channel_map(layout_map + tags, AAC_CHANNEL_SIDE, gb, num_side);
- tags += num_side;
- decode_channel_map(layout_map + tags, AAC_CHANNEL_BACK, gb, num_back);
- tags += num_back;
- decode_channel_map(layout_map + tags, AAC_CHANNEL_LFE, gb, num_lfe);
- tags += num_lfe;
-
- skip_bits_long(gb, 4 * num_assoc_data);
-
- decode_channel_map(layout_map + tags, AAC_CHANNEL_CC, gb, num_cc);
- tags += num_cc;
-
- align_get_bits(gb);
-
- /* comment field, first byte is length */
- comment_len = get_bits(gb, 8) * 8;
- if (get_bits_left(gb) < comment_len) {
- av_log(avctx, AV_LOG_ERROR, "decode_pce: " overread_err);
- return -1;
- }
- skip_bits_long(gb, comment_len);
- return tags;
-}
-
-/**
- * Decode GA "General Audio" specific configuration; reference: table 4.1.
- *
- * @param ac pointer to AACContext, may be null
- * @param avctx pointer to AVCCodecContext, used for logging
- *
- * @return Returns error status. 0 - OK, !0 - error
- */
-static int decode_ga_specific_config(AACContext *ac, AVCodecContext *avctx,
- GetBitContext *gb,
- MPEG4AudioConfig *m4ac,
- int channel_config)
-{
- int extension_flag, ret;
- uint8_t layout_map[MAX_ELEM_ID*4][3];
- int tags = 0;
-
- if (get_bits1(gb)) { // frameLengthFlag
- av_log_missing_feature(avctx, "960/120 MDCT window", 1);
- return AVERROR_PATCHWELCOME;
- }
-
- if (get_bits1(gb)) // dependsOnCoreCoder
- skip_bits(gb, 14); // coreCoderDelay
- extension_flag = get_bits1(gb);
-
- if (m4ac->object_type == AOT_AAC_SCALABLE ||
- m4ac->object_type == AOT_ER_AAC_SCALABLE)
- skip_bits(gb, 3); // layerNr
-
- if (channel_config == 0) {
- skip_bits(gb, 4); // element_instance_tag
- tags = decode_pce(avctx, m4ac, layout_map, gb);
- if (tags < 0)
- return tags;
- } else {
- if ((ret = set_default_channel_config(avctx, layout_map, &tags, channel_config)))
- return ret;
- }
-
- if (count_channels(layout_map, tags) > 1) {
- m4ac->ps = 0;
- } else if (m4ac->sbr == 1 && m4ac->ps == -1)
- m4ac->ps = 1;
-
- if (ac && (ret = output_configure(ac, layout_map, tags, OC_GLOBAL_HDR, 0)))
- return ret;
-
- if (extension_flag) {
- switch (m4ac->object_type) {
- case AOT_ER_BSAC:
- skip_bits(gb, 5); // numOfSubFrame
- skip_bits(gb, 11); // layer_length
- break;
- case AOT_ER_AAC_LC:
- case AOT_ER_AAC_LTP:
- case AOT_ER_AAC_SCALABLE:
- case AOT_ER_AAC_LD:
- skip_bits(gb, 3); /* aacSectionDataResilienceFlag
- * aacScalefactorDataResilienceFlag
- * aacSpectralDataResilienceFlag
- */
- break;
- }
- skip_bits1(gb); // extensionFlag3 (TBD in version 3)
- }
- return 0;
-}
-
-/**
- * Decode audio specific configuration; reference: table 1.13.
- *
- * @param ac pointer to AACContext, may be null
- * @param avctx pointer to AVCCodecContext, used for logging
- * @param m4ac pointer to MPEG4AudioConfig, used for parsing
- * @param data pointer to buffer holding an audio specific config
- * @param bit_size size of audio specific config or data in bits
- * @param sync_extension look for an appended sync extension
- *
- * @return Returns error status or number of consumed bits. <0 - error
- */
-static int decode_audio_specific_config(AACContext *ac,
- AVCodecContext *avctx,
- MPEG4AudioConfig *m4ac,
- const uint8_t *data, int bit_size,
- int sync_extension)
-{
- GetBitContext gb;
- int i;
- int ret;
-
- av_dlog(avctx, "audio specific config size %d\n", bit_size >> 3);
- for (i = 0; i < bit_size >> 3; i++)
- av_dlog(avctx, "%02x ", data[i]);
- av_dlog(avctx, "\n");
-
- if ((ret = init_get_bits(&gb, data, bit_size)) < 0)
- return ret;
-
- if ((i = avpriv_mpeg4audio_get_config(m4ac, data, bit_size, sync_extension)) < 0)
- return -1;
- if (m4ac->sampling_index > 12) {
- av_log(avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", m4ac->sampling_index);
- return -1;
- }
-
- skip_bits_long(&gb, i);
-
- switch (m4ac->object_type) {
- case AOT_AAC_MAIN:
- case AOT_AAC_LC:
- case AOT_AAC_LTP:
- if (decode_ga_specific_config(ac, avctx, &gb, m4ac, m4ac->chan_config))
- return -1;
- break;
- default:
- av_log(avctx, AV_LOG_ERROR, "Audio object type %s%d is not supported.\n",
- m4ac->sbr == 1? "SBR+" : "", m4ac->object_type);
- return -1;
- }
-
- av_dlog(avctx, "AOT %d chan config %d sampling index %d (%d) SBR %d PS %d\n",
- m4ac->object_type, m4ac->chan_config, m4ac->sampling_index,
- m4ac->sample_rate, m4ac->sbr, m4ac->ps);
-
- return get_bits_count(&gb);
-}
-
-/**
- * linear congruential pseudorandom number generator
- *
- * @param previous_val pointer to the current state of the generator
- *
- * @return Returns a 32-bit pseudorandom integer
- */
-static av_always_inline int lcg_random(unsigned previous_val)
-{
- union { unsigned u; int s; } v = { previous_val * 1664525u + 1013904223 };
- return v.s;
-}
-
-static av_always_inline void reset_predict_state(PredictorState *ps)
-{
- ps->r0 = 0.0f;
- ps->r1 = 0.0f;
- ps->cor0 = 0.0f;
- ps->cor1 = 0.0f;
- ps->var0 = 1.0f;
- ps->var1 = 1.0f;
-}
-
-static void reset_all_predictors(PredictorState *ps)
-{
- int i;
- for (i = 0; i < MAX_PREDICTORS; i++)
- reset_predict_state(&ps[i]);
-}
-
-static int sample_rate_idx (int rate)
-{
- if (92017 <= rate) return 0;
- else if (75132 <= rate) return 1;
- else if (55426 <= rate) return 2;
- else if (46009 <= rate) return 3;
- else if (37566 <= rate) return 4;
- else if (27713 <= rate) return 5;
- else if (23004 <= rate) return 6;
- else if (18783 <= rate) return 7;
- else if (13856 <= rate) return 8;
- else if (11502 <= rate) return 9;
- else if (9391 <= rate) return 10;
- else return 11;
-}
-
-static void reset_predictor_group(PredictorState *ps, int group_num)
-{
- int i;
- for (i = group_num - 1; i < MAX_PREDICTORS; i += 30)
- reset_predict_state(&ps[i]);
-}
-
-#define AAC_INIT_VLC_STATIC(num, size) \
- INIT_VLC_STATIC(&vlc_spectral[num], 8, ff_aac_spectral_sizes[num], \
- ff_aac_spectral_bits[num], sizeof( ff_aac_spectral_bits[num][0]), sizeof( ff_aac_spectral_bits[num][0]), \
- ff_aac_spectral_codes[num], sizeof(ff_aac_spectral_codes[num][0]), sizeof(ff_aac_spectral_codes[num][0]), \
- size);
-
-static void aacdec_init(AACContext *ac);
-
-static av_cold int aac_decode_init(AVCodecContext *avctx)
-{
- AACContext *ac = avctx->priv_data;
-
- ac->avctx = avctx;
- ac->oc[1].m4ac.sample_rate = avctx->sample_rate;
-
- aacdec_init(ac);
-
- avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
-
- if (avctx->extradata_size > 0) {
- if (decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac,
- avctx->extradata,
- avctx->extradata_size*8, 1) < 0)
- return -1;
- } else {
- int sr, i;
- uint8_t layout_map[MAX_ELEM_ID*4][3];
- int layout_map_tags;
-
- sr = sample_rate_idx(avctx->sample_rate);
- ac->oc[1].m4ac.sampling_index = sr;
- ac->oc[1].m4ac.channels = avctx->channels;
- ac->oc[1].m4ac.sbr = -1;
- ac->oc[1].m4ac.ps = -1;
-
- for (i = 0; i < FF_ARRAY_ELEMS(ff_mpeg4audio_channels); i++)
- if (ff_mpeg4audio_channels[i] == avctx->channels)
- break;
- if (i == FF_ARRAY_ELEMS(ff_mpeg4audio_channels)) {
- i = 0;
- }
- ac->oc[1].m4ac.chan_config = i;
-
- if (ac->oc[1].m4ac.chan_config) {
- int ret = set_default_channel_config(avctx, layout_map,
- &layout_map_tags, ac->oc[1].m4ac.chan_config);
- if (!ret)
- output_configure(ac, layout_map, layout_map_tags,
- OC_GLOBAL_HDR, 0);
- else if (avctx->err_recognition & AV_EF_EXPLODE)
- return AVERROR_INVALIDDATA;
- }
- }
-
- if (avctx->channels > MAX_CHANNELS) {
- av_log(avctx, AV_LOG_ERROR, "Too many channels\n");
- return AVERROR_INVALIDDATA;
- }
-
- AAC_INIT_VLC_STATIC( 0, 304);
- AAC_INIT_VLC_STATIC( 1, 270);
- AAC_INIT_VLC_STATIC( 2, 550);
- AAC_INIT_VLC_STATIC( 3, 300);
- AAC_INIT_VLC_STATIC( 4, 328);
- AAC_INIT_VLC_STATIC( 5, 294);
- AAC_INIT_VLC_STATIC( 6, 306);
- AAC_INIT_VLC_STATIC( 7, 268);
- AAC_INIT_VLC_STATIC( 8, 510);
- AAC_INIT_VLC_STATIC( 9, 366);
- AAC_INIT_VLC_STATIC(10, 462);
-
- ff_aac_sbr_init();
-
- ff_fmt_convert_init(&ac->fmt_conv, avctx);
- avpriv_float_dsp_init(&ac->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
-
- ac->random_state = 0x1f2e3d4c;
-
- ff_aac_tableinit();
-
- INIT_VLC_STATIC(&vlc_scalefactors,7,FF_ARRAY_ELEMS(ff_aac_scalefactor_code),
- ff_aac_scalefactor_bits, sizeof(ff_aac_scalefactor_bits[0]), sizeof(ff_aac_scalefactor_bits[0]),
- ff_aac_scalefactor_code, sizeof(ff_aac_scalefactor_code[0]), sizeof(ff_aac_scalefactor_code[0]),
- 352);
-
- ff_mdct_init(&ac->mdct, 11, 1, 1.0 / (32768.0 * 1024.0));
- ff_mdct_init(&ac->mdct_small, 8, 1, 1.0 / (32768.0 * 128.0));
- 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_short_128, 6.0, 128);
- ff_init_ff_sine_windows(10);
- ff_init_ff_sine_windows( 7);
-
- cbrt_tableinit();
-
- return 0;
-}
-
-/**
- * Skip data_stream_element; reference: table 4.10.
- */
-static int skip_data_stream_element(AACContext *ac, GetBitContext *gb)
-{
- int byte_align = get_bits1(gb);
- int count = get_bits(gb, 8);
- if (count == 255)
- count += get_bits(gb, 8);
- if (byte_align)
- align_get_bits(gb);
-
- if (get_bits_left(gb) < 8 * count) {
- av_log(ac->avctx, AV_LOG_ERROR, "skip_data_stream_element: "overread_err);
- return -1;
- }
- skip_bits_long(gb, 8 * count);
- return 0;
-}
-
-static int decode_prediction(AACContext *ac, IndividualChannelStream *ics,
- GetBitContext *gb)
-{
- int sfb;
- if (get_bits1(gb)) {
- ics->predictor_reset_group = get_bits(gb, 5);
- if (ics->predictor_reset_group == 0 || ics->predictor_reset_group > 30) {
- av_log(ac->avctx, AV_LOG_ERROR, "Invalid Predictor Reset Group.\n");
- return -1;
- }
- }
- for (sfb = 0; sfb < FFMIN(ics->max_sfb, ff_aac_pred_sfb_max[ac->oc[1].m4ac.sampling_index]); sfb++) {
- ics->prediction_used[sfb] = get_bits1(gb);
- }
- return 0;
-}
-
-/**
- * Decode Long Term Prediction data; reference: table 4.xx.
- */
-static void decode_ltp(LongTermPrediction *ltp,
- GetBitContext *gb, uint8_t max_sfb)
-{
- int sfb;
-
- ltp->lag = get_bits(gb, 11);
- ltp->coef = ltp_coef[get_bits(gb, 3)];
- for (sfb = 0; sfb < FFMIN(max_sfb, MAX_LTP_LONG_SFB); sfb++)
- ltp->used[sfb] = get_bits1(gb);
-}
-
-/**
- * Decode Individual Channel Stream info; reference: table 4.6.
- */
-static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics,
- GetBitContext *gb)
-{
- if (get_bits1(gb)) {
- av_log(ac->avctx, AV_LOG_ERROR, "Reserved bit set.\n");
- return AVERROR_INVALIDDATA;
- }
- ics->window_sequence[1] = ics->window_sequence[0];
- ics->window_sequence[0] = get_bits(gb, 2);
- ics->use_kb_window[1] = ics->use_kb_window[0];
- ics->use_kb_window[0] = get_bits1(gb);
- ics->num_window_groups = 1;
- ics->group_len[0] = 1;
- if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
- int i;
- ics->max_sfb = get_bits(gb, 4);
- for (i = 0; i < 7; i++) {
- if (get_bits1(gb)) {
- ics->group_len[ics->num_window_groups - 1]++;
- } else {
- ics->num_window_groups++;
- ics->group_len[ics->num_window_groups - 1] = 1;
- }
- }
- ics->num_windows = 8;
- ics->swb_offset = ff_swb_offset_128[ac->oc[1].m4ac.sampling_index];
- ics->num_swb = ff_aac_num_swb_128[ac->oc[1].m4ac.sampling_index];
- ics->tns_max_bands = ff_tns_max_bands_128[ac->oc[1].m4ac.sampling_index];
- ics->predictor_present = 0;
- } else {
- ics->max_sfb = get_bits(gb, 6);
- ics->num_windows = 1;
- 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->predictor_present = get_bits1(gb);
- ics->predictor_reset_group = 0;
- if (ics->predictor_present) {
- if (ac->oc[1].m4ac.object_type == AOT_AAC_MAIN) {
- if (decode_prediction(ac, ics, gb)) {
- goto fail;
- }
- } else if (ac->oc[1].m4ac.object_type == AOT_AAC_LC) {
- av_log(ac->avctx, AV_LOG_ERROR, "Prediction is not allowed in AAC-LC.\n");
- goto fail;
- } else {
- if ((ics->ltp.present = get_bits(gb, 1)))
- decode_ltp(&ics->ltp, gb, ics->max_sfb);
- }
- }
- }
-
- if (ics->max_sfb > ics->num_swb) {
- av_log(ac->avctx, AV_LOG_ERROR,
- "Number of scalefactor bands in group (%d) exceeds limit (%d).\n",
- ics->max_sfb, ics->num_swb);
- goto fail;
- }
-
- return 0;
-fail:
- ics->max_sfb = 0;
- return AVERROR_INVALIDDATA;
-}
-
-/**
- * Decode band types (section_data payload); reference: table 4.46.
- *
- * @param band_type array of the used band type
- * @param band_type_run_end array of the last scalefactor band of a band type run
- *
- * @return Returns error status. 0 - OK, !0 - error
- */
-static int decode_band_types(AACContext *ac, enum BandType band_type[120],
- int band_type_run_end[120], GetBitContext *gb,
- IndividualChannelStream *ics)
-{
- int g, idx = 0;
- const int bits = (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) ? 3 : 5;
- for (g = 0; g < ics->num_window_groups; g++) {
- int k = 0;
- while (k < ics->max_sfb) {
- uint8_t sect_end = k;
- int sect_len_incr;
- int sect_band_type = get_bits(gb, 4);
- if (sect_band_type == 12) {
- av_log(ac->avctx, AV_LOG_ERROR, "invalid band type\n");
- return -1;
- }
- do {
- sect_len_incr = get_bits(gb, bits);
- sect_end += sect_len_incr;
- if (get_bits_left(gb) < 0) {
- av_log(ac->avctx, AV_LOG_ERROR, "decode_band_types: "overread_err);
- return -1;
- }
- if (sect_end > ics->max_sfb) {
- av_log(ac->avctx, AV_LOG_ERROR,
- "Number of bands (%d) exceeds limit (%d).\n",
- sect_end, ics->max_sfb);
- return -1;
- }
- } while (sect_len_incr == (1 << bits) - 1);
- for (; k < sect_end; k++) {
- band_type [idx] = sect_band_type;
- band_type_run_end[idx++] = sect_end;
- }
- }
- }
- return 0;
-}
-
-/**
- * Decode scalefactors; reference: table 4.47.
- *
- * @param global_gain first scalefactor value as scalefactors are differentially coded
- * @param band_type array of the used band type
- * @param band_type_run_end array of the last scalefactor band of a band type run
- * @param sf array of scalefactors or intensity stereo positions
- *
- * @return Returns error status. 0 - OK, !0 - error
- */
-static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb,
- unsigned int global_gain,
- IndividualChannelStream *ics,
- enum BandType band_type[120],
- int band_type_run_end[120])
-{
- int g, i, idx = 0;
- int offset[3] = { global_gain, global_gain - 90, 0 };
- int clipped_offset;
- int noise_flag = 1;
- for (g = 0; g < ics->num_window_groups; g++) {
- for (i = 0; i < ics->max_sfb;) {
- int run_end = band_type_run_end[idx];
- if (band_type[idx] == ZERO_BT) {
- for (; i < run_end; i++, idx++)
- sf[idx] = 0.;
- } else if ((band_type[idx] == INTENSITY_BT) || (band_type[idx] == INTENSITY_BT2)) {
- for (; i < run_end; i++, idx++) {
- offset[2] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60;
- clipped_offset = av_clip(offset[2], -155, 100);
- if (offset[2] != clipped_offset) {
- av_log_ask_for_sample(ac->avctx, "Intensity stereo "
- "position clipped (%d -> %d).\nIf you heard an "
- "audible artifact, there may be a bug in the "
- "decoder. ", offset[2], clipped_offset);
- }
- sf[idx] = ff_aac_pow2sf_tab[-clipped_offset + POW_SF2_ZERO];
- }
- } else if (band_type[idx] == NOISE_BT) {
- for (; i < run_end; i++, idx++) {
- if (noise_flag-- > 0)
- offset[1] += get_bits(gb, 9) - 256;
- else
- offset[1] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60;
- clipped_offset = av_clip(offset[1], -100, 155);
- if (offset[1] != clipped_offset) {
- av_log_ask_for_sample(ac->avctx, "Noise gain clipped "
- "(%d -> %d).\nIf you heard an audible "
- "artifact, there may be a bug in the decoder. ",
- offset[1], clipped_offset);
- }
- sf[idx] = -ff_aac_pow2sf_tab[clipped_offset + POW_SF2_ZERO];
- }
- } else {
- for (; i < run_end; i++, idx++) {
- offset[0] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60;
- if (offset[0] > 255U) {
- av_log(ac->avctx, AV_LOG_ERROR,
- "Scalefactor (%d) out of range.\n", offset[0]);
- return -1;
- }
- sf[idx] = -ff_aac_pow2sf_tab[offset[0] - 100 + POW_SF2_ZERO];
- }
- }
- }
- }
- return 0;
-}
-
-/**
- * Decode pulse data; reference: table 4.7.
- */
-static int decode_pulses(Pulse *pulse, GetBitContext *gb,
- const uint16_t *swb_offset, int num_swb)
-{
- int i, pulse_swb;
- pulse->num_pulse = get_bits(gb, 2) + 1;
- pulse_swb = get_bits(gb, 6);
- if (pulse_swb >= num_swb)
- return -1;
- pulse->pos[0] = swb_offset[pulse_swb];
- pulse->pos[0] += get_bits(gb, 5);
- if (pulse->pos[0] > 1023)
- 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)
- return -1;
- pulse->amp[i] = get_bits(gb, 4);
- }
- return 0;
-}
-
-/**
- * Decode Temporal Noise Shaping data; reference: table 4.48.
- *
- * @return Returns error status. 0 - OK, !0 - error
- */
-static int decode_tns(AACContext *ac, TemporalNoiseShaping *tns,
- GetBitContext *gb, const IndividualChannelStream *ics)
-{
- int w, filt, i, coef_len, coef_res, coef_compress;
- const int is8 = ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE;
- const int tns_max_order = is8 ? 7 : ac->oc[1].m4ac.object_type == AOT_AAC_MAIN ? 20 : 12;
- for (w = 0; w < ics->num_windows; w++) {
- if ((tns->n_filt[w] = get_bits(gb, 2 - is8))) {
- coef_res = get_bits1(gb);
-
- for (filt = 0; filt < tns->n_filt[w]; filt++) {
- int tmp2_idx;
- tns->length[w][filt] = get_bits(gb, 6 - 2 * is8);
-
- if ((tns->order[w][filt] = get_bits(gb, 5 - 2 * is8)) > tns_max_order) {
- av_log(ac->avctx, AV_LOG_ERROR, "TNS filter order %d is greater than maximum %d.\n",
- tns->order[w][filt], tns_max_order);
- tns->order[w][filt] = 0;
- return -1;
- }
- if (tns->order[w][filt]) {
- tns->direction[w][filt] = get_bits1(gb);
- coef_compress = get_bits1(gb);
- coef_len = coef_res + 3 - coef_compress;
- tmp2_idx = 2 * coef_compress + coef_res;
-
- for (i = 0; i < tns->order[w][filt]; i++)
- tns->coef[w][filt][i] = tns_tmp2_map[tmp2_idx][get_bits(gb, coef_len)];
- }
- }
- }
- }
- return 0;
-}
-
-/**
- * Decode Mid/Side data; reference: table 4.54.
- *
- * @param ms_present Indicates mid/side stereo presence. [0] mask is all 0s;
- * [1] mask is decoded from bitstream; [2] mask is all 1s;
- * [3] reserved for scalable AAC
- */
-static void decode_mid_side_stereo(ChannelElement *cpe, GetBitContext *gb,
- int ms_present)
-{
- int idx;
- if (ms_present == 1) {
- for (idx = 0; idx < cpe->ch[0].ics.num_window_groups * cpe->ch[0].ics.max_sfb; idx++)
- cpe->ms_mask[idx] = get_bits1(gb);
- } else if (ms_present == 2) {
- memset(cpe->ms_mask, 1, sizeof(cpe->ms_mask[0]) * cpe->ch[0].ics.num_window_groups * cpe->ch[0].ics.max_sfb);
- }
-}
-
-#ifndef VMUL2
-static inline float *VMUL2(float *dst, const float *v, unsigned idx,
- const float *scale)
-{
- float s = *scale;
- *dst++ = v[idx & 15] * s;
- *dst++ = v[idx>>4 & 15] * s;
- return dst;
-}
-#endif
-
-#ifndef VMUL4
-static inline float *VMUL4(float *dst, const float *v, unsigned idx,
- const float *scale)
-{
- float s = *scale;
- *dst++ = v[idx & 3] * s;
- *dst++ = v[idx>>2 & 3] * s;
- *dst++ = v[idx>>4 & 3] * s;
- *dst++ = v[idx>>6 & 3] * s;
- return dst;
-}
-#endif
-
-#ifndef VMUL2S
-static inline float *VMUL2S(float *dst, const float *v, unsigned idx,
- unsigned sign, const float *scale)
-{
- union av_intfloat32 s0, s1;
-
- s0.f = s1.f = *scale;
- s0.i ^= sign >> 1 << 31;
- s1.i ^= sign << 31;
-
- *dst++ = v[idx & 15] * s0.f;
- *dst++ = v[idx>>4 & 15] * s1.f;
-
- return dst;
-}
-#endif
-
-#ifndef VMUL4S
-static inline float *VMUL4S(float *dst, const float *v, unsigned idx,
- unsigned sign, const float *scale)
-{
- unsigned nz = idx >> 12;
- union av_intfloat32 s = { .f = *scale };
- union av_intfloat32 t;
-
- t.i = s.i ^ (sign & 1U<<31);
- *dst++ = v[idx & 3] * t.f;
-
- sign <<= nz & 1; nz >>= 1;
- t.i = s.i ^ (sign & 1U<<31);
- *dst++ = v[idx>>2 & 3] * t.f;
-
- sign <<= nz & 1; nz >>= 1;
- t.i = s.i ^ (sign & 1U<<31);
- *dst++ = v[idx>>4 & 3] * t.f;
-
- sign <<= nz & 1;
- t.i = s.i ^ (sign & 1U<<31);
- *dst++ = v[idx>>6 & 3] * t.f;
-
- return dst;
-}
-#endif
-
-/**
- * Decode spectral data; reference: table 4.50.
- * Dequantize and scale spectral data; reference: 4.6.3.3.
- *
- * @param coef array of dequantized, scaled spectral data
- * @param sf array of scalefactors or intensity stereo positions
- * @param pulse_present set if pulses are present
- * @param pulse pointer to pulse data struct
- * @param band_type array of the used band type
- *
- * @return Returns error status. 0 - OK, !0 - error
- */
-static int decode_spectrum_and_dequant(AACContext *ac, float coef[1024],
- GetBitContext *gb, const float sf[120],
- int pulse_present, const Pulse *pulse,
- const IndividualChannelStream *ics,
- enum BandType band_type[120])
-{
- int i, k, g, idx = 0;
- const int c = 1024 / ics->num_windows;
- const uint16_t *offsets = ics->swb_offset;
- float *coef_base = coef;
-
- for (g = 0; g < ics->num_windows; g++)
- memset(coef + g * 128 + offsets[ics->max_sfb], 0, sizeof(float) * (c - offsets[ics->max_sfb]));
-
- for (g = 0; g < ics->num_window_groups; g++) {
- unsigned g_len = ics->group_len[g];
-
- for (i = 0; i < ics->max_sfb; i++, idx++) {
- const unsigned cbt_m1 = band_type[idx] - 1;
- float *cfo = coef + offsets[i];
- int off_len = offsets[i + 1] - offsets[i];
- int group;
-
- if (cbt_m1 >= INTENSITY_BT2 - 1) {
- for (group = 0; group < g_len; group++, cfo+=128) {
- memset(cfo, 0, off_len * sizeof(float));
- }
- } else if (cbt_m1 == NOISE_BT - 1) {
- for (group = 0; group < g_len; group++, cfo+=128) {
- float scale;
- float band_energy;
-
- for (k = 0; k < off_len; k++) {
- ac->random_state = lcg_random(ac->random_state);
- cfo[k] = ac->random_state;
- }
-
- band_energy = ac->fdsp.scalarproduct_float(cfo, cfo, off_len);
- scale = sf[idx] / sqrtf(band_energy);
- ac->fdsp.vector_fmul_scalar(cfo, cfo, scale, off_len);
- }
- } else {
- const float *vq = ff_aac_codebook_vector_vals[cbt_m1];
- const uint16_t *cb_vector_idx = ff_aac_codebook_vector_idx[cbt_m1];
- VLC_TYPE (*vlc_tab)[2] = vlc_spectral[cbt_m1].table;
- OPEN_READER(re, gb);
-
- switch (cbt_m1 >> 1) {
- case 0:
- for (group = 0; group < g_len; group++, cfo+=128) {
- float *cf = cfo;
- int len = off_len;
-
- do {
- int code;
- unsigned cb_idx;
-
- UPDATE_CACHE(re, gb);
- GET_VLC(code, re, gb, vlc_tab, 8, 2);
- cb_idx = cb_vector_idx[code];
- cf = VMUL4(cf, vq, cb_idx, sf + idx);
- } while (len -= 4);
- }
- break;
-
- case 1:
- for (group = 0; group < g_len; group++, cfo+=128) {
- float *cf = cfo;
- int len = off_len;
-
- do {
- int code;
- unsigned nnz;
- unsigned cb_idx;
- uint32_t bits;
-
- UPDATE_CACHE(re, gb);
- GET_VLC(code, re, gb, vlc_tab, 8, 2);
- cb_idx = cb_vector_idx[code];
- nnz = cb_idx >> 8 & 15;
- bits = nnz ? GET_CACHE(re, gb) : 0;
- LAST_SKIP_BITS(re, gb, nnz);
- cf = VMUL4S(cf, vq, cb_idx, bits, sf + idx);
- } while (len -= 4);
- }
- break;
-
- case 2:
- for (group = 0; group < g_len; group++, cfo+=128) {
- float *cf = cfo;
- int len = off_len;
-
- do {
- int code;
- unsigned cb_idx;
-
- UPDATE_CACHE(re, gb);
- GET_VLC(code, re, gb, vlc_tab, 8, 2);
- cb_idx = cb_vector_idx[code];
- cf = VMUL2(cf, vq, cb_idx, sf + idx);
- } while (len -= 2);
- }
- break;
-
- case 3:
- case 4:
- for (group = 0; group < g_len; group++, cfo+=128) {
- float *cf = cfo;
- int len = off_len;
-
- do {
- int code;
- unsigned nnz;
- unsigned cb_idx;
- unsigned sign;
-
- UPDATE_CACHE(re, gb);
- GET_VLC(code, re, gb, vlc_tab, 8, 2);
- cb_idx = cb_vector_idx[code];
- nnz = cb_idx >> 8 & 15;
- sign = nnz ? SHOW_UBITS(re, gb, nnz) << (cb_idx >> 12) : 0;
- LAST_SKIP_BITS(re, gb, nnz);
- cf = VMUL2S(cf, vq, cb_idx, sign, sf + idx);
- } while (len -= 2);
- }
- break;
-
- default:
- for (group = 0; group < g_len; group++, cfo+=128) {
- float *cf = cfo;
- uint32_t *icf = (uint32_t *) cf;
- int len = off_len;
-
- do {
- int code;
- unsigned nzt, nnz;
- unsigned cb_idx;
- uint32_t bits;
- int j;
-
- UPDATE_CACHE(re, gb);
- GET_VLC(code, re, gb, vlc_tab, 8, 2);
-
- if (!code) {
- *icf++ = 0;
- *icf++ = 0;
- continue;
- }
-
- cb_idx = cb_vector_idx[code];
- nnz = cb_idx >> 12;
- nzt = cb_idx >> 8;
- bits = SHOW_UBITS(re, gb, nnz) << (32-nnz);
- LAST_SKIP_BITS(re, gb, nnz);
-
- for (j = 0; j < 2; j++) {
- if (nzt & 1<<j) {
- uint32_t b;
- int n;
- /* The total length of escape_sequence must be < 22 bits according
- to the specification (i.e. max is 111111110xxxxxxxxxxxx). */
- UPDATE_CACHE(re, gb);
- b = GET_CACHE(re, gb);
- b = 31 - av_log2(~b);
-
- if (b > 8) {
- av_log(ac->avctx, AV_LOG_ERROR, "error in spectral data, ESC overflow\n");
- return -1;
- }
-
- SKIP_BITS(re, gb, b + 1);
- b += 4;
- n = (1 << b) + SHOW_UBITS(re, gb, b);
- LAST_SKIP_BITS(re, gb, b);
- *icf++ = cbrt_tab[n] | (bits & 1U<<31);
- bits <<= 1;
- } else {
- unsigned v = ((const uint32_t*)vq)[cb_idx & 15];
- *icf++ = (bits & 1U<<31) | v;
- bits <<= !!v;
- }
- cb_idx >>= 4;
- }
- } while (len -= 2);
-
- ac->fdsp.vector_fmul_scalar(cfo, cfo, sf[idx], off_len);
- }
- }
-
- CLOSE_READER(re, gb);
- }
- }
- coef += g_len << 7;
- }
-
- if (pulse_present) {
- idx = 0;
- for (i = 0; i < pulse->num_pulse; i++) {
- float co = coef_base[ pulse->pos[i] ];
- while (offsets[idx + 1] <= pulse->pos[i])
- idx++;
- if (band_type[idx] != NOISE_BT && sf[idx]) {
- float ico = -pulse->amp[i];
- if (co) {
- co /= sf[idx];
- ico = co / sqrtf(sqrtf(fabsf(co))) + (co > 0 ? -ico : ico);
- }
- coef_base[ pulse->pos[i] ] = cbrtf(fabsf(ico)) * ico * sf[idx];
- }
- }
- }
- return 0;
-}
-
-static av_always_inline float flt16_round(float pf)
-{
- union av_intfloat32 tmp;
- tmp.f = pf;
- tmp.i = (tmp.i + 0x00008000U) & 0xFFFF0000U;
- return tmp.f;
-}
-
-static av_always_inline float flt16_even(float pf)
-{
- union av_intfloat32 tmp;
- tmp.f = pf;
- tmp.i = (tmp.i + 0x00007FFFU + (tmp.i & 0x00010000U >> 16)) & 0xFFFF0000U;
- return tmp.f;
-}
-
-static av_always_inline float flt16_trunc(float pf)
-{
- union av_intfloat32 pun;
- pun.f = pf;
- pun.i &= 0xFFFF0000U;
- return pun.f;
-}
-
-static av_always_inline void predict(PredictorState *ps, float *coef,
- int output_enable)
-{
- const float a = 0.953125; // 61.0 / 64
- const float alpha = 0.90625; // 29.0 / 32
- float e0, e1;
- float pv;
- float k1, k2;
- float r0 = ps->r0, r1 = ps->r1;
- float cor0 = ps->cor0, cor1 = ps->cor1;
- float var0 = ps->var0, var1 = ps->var1;
-
- k1 = var0 > 1 ? cor0 * flt16_even(a / var0) : 0;
- k2 = var1 > 1 ? cor1 * flt16_even(a / var1) : 0;
-
- pv = flt16_round(k1 * r0 + k2 * r1);
- if (output_enable)
- *coef += pv;
-
- e0 = *coef;
- e1 = e0 - k1 * r0;
-
- ps->cor1 = flt16_trunc(alpha * cor1 + r1 * e1);
- ps->var1 = flt16_trunc(alpha * var1 + 0.5f * (r1 * r1 + e1 * e1));
- ps->cor0 = flt16_trunc(alpha * cor0 + r0 * e0);
- ps->var0 = flt16_trunc(alpha * var0 + 0.5f * (r0 * r0 + e0 * e0));
-
- ps->r1 = flt16_trunc(a * (r0 - k1 * e0));
- ps->r0 = flt16_trunc(a * e0);
-}
-
-/**
- * Apply AAC-Main style frequency domain prediction.
- */
-static void apply_prediction(AACContext *ac, SingleChannelElement *sce)
-{
- int sfb, k;
-
- if (!sce->ics.predictor_initialized) {
- reset_all_predictors(sce->predictor_state);
- sce->ics.predictor_initialized = 1;
- }
-
- if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) {
- for (sfb = 0; sfb < ff_aac_pred_sfb_max[ac->oc[1].m4ac.sampling_index]; sfb++) {
- for (k = sce->ics.swb_offset[sfb]; k < sce->ics.swb_offset[sfb + 1]; k++) {
- predict(&sce->predictor_state[k], &sce->coeffs[k],
- sce->ics.predictor_present && sce->ics.prediction_used[sfb]);
- }
- }
- if (sce->ics.predictor_reset_group)
- reset_predictor_group(sce->predictor_state, sce->ics.predictor_reset_group);
- } else
- reset_all_predictors(sce->predictor_state);
-}
-
-/**
- * Decode an individual_channel_stream payload; reference: table 4.44.
- *
- * @param common_window Channels have independent [0], or shared [1], Individual Channel Stream information.
- * @param scale_flag scalable [1] or non-scalable [0] AAC (Unused until scalable AAC is implemented.)
- *
- * @return Returns error status. 0 - OK, !0 - error
- */
-static int decode_ics(AACContext *ac, SingleChannelElement *sce,
- GetBitContext *gb, int common_window, int scale_flag)
-{
- Pulse pulse;
- TemporalNoiseShaping *tns = &sce->tns;
- IndividualChannelStream *ics = &sce->ics;
- float *out = sce->coeffs;
- int global_gain, pulse_present = 0;
-
- /* This assignment is to silence a GCC warning about the variable being used
- * uninitialized when in fact it always is.
- */
- pulse.num_pulse = 0;
-
- global_gain = get_bits(gb, 8);
-
- if (!common_window && !scale_flag) {
- if (decode_ics_info(ac, ics, gb) < 0)
- return AVERROR_INVALIDDATA;
- }
-
- if (decode_band_types(ac, sce->band_type, sce->band_type_run_end, gb, ics) < 0)
- return -1;
- if (decode_scalefactors(ac, sce->sf, gb, global_gain, ics, sce->band_type, sce->band_type_run_end) < 0)
- return -1;
-
- pulse_present = 0;
- if (!scale_flag) {
- if ((pulse_present = get_bits1(gb))) {
- if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
- av_log(ac->avctx, AV_LOG_ERROR, "Pulse tool not allowed in eight short sequence.\n");
- return -1;
- }
- if (decode_pulses(&pulse, gb, ics->swb_offset, ics->num_swb)) {
- av_log(ac->avctx, AV_LOG_ERROR, "Pulse data corrupt or invalid.\n");
- return -1;
- }
- }
- if ((tns->present = get_bits1(gb)) && decode_tns(ac, tns, gb, ics))
- return -1;
- if (get_bits1(gb)) {
- av_log_missing_feature(ac->avctx, "SSR", 1);
- return AVERROR_PATCHWELCOME;
- }
- }
-
- if (decode_spectrum_and_dequant(ac, out, gb, sce->sf, pulse_present, &pulse, ics, sce->band_type) < 0)
- return -1;
-
- if (ac->oc[1].m4ac.object_type == AOT_AAC_MAIN && !common_window)
- apply_prediction(ac, sce);
-
- return 0;
-}
-
-/**
- * Mid/Side stereo decoding; reference: 4.6.8.1.3.
- */
-static void apply_mid_side_stereo(AACContext *ac, ChannelElement *cpe)
-{
- const IndividualChannelStream *ics = &cpe->ch[0].ics;
- float *ch0 = cpe->ch[0].coeffs;
- float *ch1 = cpe->ch[1].coeffs;
- int g, i, group, idx = 0;
- const uint16_t *offsets = ics->swb_offset;
- for (g = 0; g < ics->num_window_groups; g++) {
- for (i = 0; i < ics->max_sfb; i++, idx++) {
- if (cpe->ms_mask[idx] &&
- cpe->ch[0].band_type[idx] < NOISE_BT && cpe->ch[1].band_type[idx] < NOISE_BT) {
- for (group = 0; group < ics->group_len[g]; group++) {
- ac->fdsp.butterflies_float(ch0 + group * 128 + offsets[i],
- ch1 + group * 128 + offsets[i],
- offsets[i+1] - offsets[i]);
- }
- }
- }
- ch0 += ics->group_len[g] * 128;
- ch1 += ics->group_len[g] * 128;
- }
-}
-
-/**
- * intensity stereo decoding; reference: 4.6.8.2.3
- *
- * @param ms_present Indicates mid/side stereo presence. [0] mask is all 0s;
- * [1] mask is decoded from bitstream; [2] mask is all 1s;
- * [3] reserved for scalable AAC
- */
-static void apply_intensity_stereo(AACContext *ac, ChannelElement *cpe, int ms_present)
-{
- const IndividualChannelStream *ics = &cpe->ch[1].ics;
- SingleChannelElement *sce1 = &cpe->ch[1];
- float *coef0 = cpe->ch[0].coeffs, *coef1 = cpe->ch[1].coeffs;
- const uint16_t *offsets = ics->swb_offset;
- int g, group, i, idx = 0;
- int c;
- float scale;
- for (g = 0; g < ics->num_window_groups; g++) {
- for (i = 0; i < ics->max_sfb;) {
- if (sce1->band_type[idx] == INTENSITY_BT || sce1->band_type[idx] == INTENSITY_BT2) {
- const int bt_run_end = sce1->band_type_run_end[idx];
- for (; i < bt_run_end; i++, idx++) {
- c = -1 + 2 * (sce1->band_type[idx] - 14);
- if (ms_present)
- c *= 1 - 2 * cpe->ms_mask[idx];
- scale = c * sce1->sf[idx];
- for (group = 0; group < ics->group_len[g]; group++)
- ac->fdsp.vector_fmul_scalar(coef1 + group * 128 + offsets[i],
- coef0 + group * 128 + offsets[i],
- scale,
- offsets[i + 1] - offsets[i]);
- }
- } else {
- int bt_run_end = sce1->band_type_run_end[idx];
- idx += bt_run_end - i;
- i = bt_run_end;
- }
- }
- coef0 += ics->group_len[g] * 128;
- coef1 += ics->group_len[g] * 128;
- }
-}
-
-/**
- * Decode a channel_pair_element; reference: table 4.4.
- *
- * @return Returns error status. 0 - OK, !0 - error
- */
-static int decode_cpe(AACContext *ac, GetBitContext *gb, ChannelElement *cpe)
-{
- int i, ret, common_window, ms_present = 0;
-
- common_window = get_bits1(gb);
- if (common_window) {
- if (decode_ics_info(ac, &cpe->ch[0].ics, gb))
- return AVERROR_INVALIDDATA;
- i = cpe->ch[1].ics.use_kb_window[0];
- cpe->ch[1].ics = cpe->ch[0].ics;
- cpe->ch[1].ics.use_kb_window[1] = i;
- if (cpe->ch[1].ics.predictor_present && (ac->oc[1].m4ac.object_type != AOT_AAC_MAIN))
- if ((cpe->ch[1].ics.ltp.present = get_bits(gb, 1)))
- decode_ltp(&cpe->ch[1].ics.ltp, gb, cpe->ch[1].ics.max_sfb);
- ms_present = get_bits(gb, 2);
- if (ms_present == 3) {
- av_log(ac->avctx, AV_LOG_ERROR, "ms_present = 3 is reserved.\n");
- return -1;
- } else if (ms_present)
- decode_mid_side_stereo(cpe, gb, ms_present);
- }
- if ((ret = decode_ics(ac, &cpe->ch[0], gb, common_window, 0)))
- return ret;
- if ((ret = decode_ics(ac, &cpe->ch[1], gb, common_window, 0)))
- return ret;
-
- if (common_window) {
- if (ms_present)
- apply_mid_side_stereo(ac, cpe);
- if (ac->oc[1].m4ac.object_type == AOT_AAC_MAIN) {
- apply_prediction(ac, &cpe->ch[0]);
- apply_prediction(ac, &cpe->ch[1]);
- }
- }
-
- apply_intensity_stereo(ac, cpe, ms_present);
- return 0;
-}
-
-static const float cce_scale[] = {
- 1.09050773266525765921, //2^(1/8)
- 1.18920711500272106672, //2^(1/4)
- M_SQRT2,
- 2,
-};
-
-/**
- * Decode coupling_channel_element; reference: table 4.8.
- *
- * @return Returns error status. 0 - OK, !0 - error
- */
-static int decode_cce(AACContext *ac, GetBitContext *gb, ChannelElement *che)
-{
- int num_gain = 0;
- int c, g, sfb, ret;
- int sign;
- float scale;
- SingleChannelElement *sce = &che->ch[0];
- ChannelCoupling *coup = &che->coup;
-
- coup->coupling_point = 2 * get_bits1(gb);
- coup->num_coupled = get_bits(gb, 3);
- for (c = 0; c <= coup->num_coupled; c++) {
- num_gain++;
- coup->type[c] = get_bits1(gb) ? TYPE_CPE : TYPE_SCE;
- coup->id_select[c] = get_bits(gb, 4);
- if (coup->type[c] == TYPE_CPE) {
- coup->ch_select[c] = get_bits(gb, 2);
- if (coup->ch_select[c] == 3)
- num_gain++;
- } else
- coup->ch_select[c] = 2;
- }
- coup->coupling_point += get_bits1(gb) || (coup->coupling_point >> 1);
-
- sign = get_bits(gb, 1);
- scale = cce_scale[get_bits(gb, 2)];
-
- if ((ret = decode_ics(ac, sce, gb, 0, 0)))
- return ret;
-
- for (c = 0; c < num_gain; c++) {
- int idx = 0;
- int cge = 1;
- int gain = 0;
- float gain_cache = 1.;
- if (c) {
- cge = coup->coupling_point == AFTER_IMDCT ? 1 : get_bits1(gb);
- gain = cge ? get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60: 0;
- gain_cache = powf(scale, -gain);
- }
- if (coup->coupling_point == AFTER_IMDCT) {
- coup->gain[c][0] = gain_cache;
- } else {
- for (g = 0; g < sce->ics.num_window_groups; g++) {
- for (sfb = 0; sfb < sce->ics.max_sfb; sfb++, idx++) {
- if (sce->band_type[idx] != ZERO_BT) {
- if (!cge) {
- int t = get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60;
- if (t) {
- int s = 1;
- t = gain += t;
- if (sign) {
- s -= 2 * (t & 0x1);
- t >>= 1;
- }
- gain_cache = powf(scale, -t) * s;
- }
- }
- coup->gain[c][idx] = gain_cache;
- }
- }
- }
- }
- }
- return 0;
-}
-
-/**
- * Parse whether channels are to be excluded from Dynamic Range Compression; reference: table 4.53.
- *
- * @return Returns number of bytes consumed.
- */
-static int decode_drc_channel_exclusions(DynamicRangeControl *che_drc,
- GetBitContext *gb)
-{
- int i;
- int num_excl_chan = 0;
-
- do {
- for (i = 0; i < 7; i++)
- che_drc->exclude_mask[num_excl_chan++] = get_bits1(gb);
- } while (num_excl_chan < MAX_CHANNELS - 7 && get_bits1(gb));
-
- return num_excl_chan / 7;
-}
-
-/**
- * Decode dynamic range information; reference: table 4.52.
- *
- * @return Returns number of bytes consumed.
- */
-static int decode_dynamic_range(DynamicRangeControl *che_drc,
- GetBitContext *gb)
-{
- int n = 1;
- int drc_num_bands = 1;
- int i;
-
- /* pce_tag_present? */
- if (get_bits1(gb)) {
- che_drc->pce_instance_tag = get_bits(gb, 4);
- skip_bits(gb, 4); // tag_reserved_bits
- n++;
- }
-
- /* excluded_chns_present? */
- if (get_bits1(gb)) {
- n += decode_drc_channel_exclusions(che_drc, gb);
- }
-
- /* drc_bands_present? */
- if (get_bits1(gb)) {
- che_drc->band_incr = get_bits(gb, 4);
- che_drc->interpolation_scheme = get_bits(gb, 4);
- n++;
- drc_num_bands += che_drc->band_incr;
- for (i = 0; i < drc_num_bands; i++) {
- che_drc->band_top[i] = get_bits(gb, 8);
- n++;
- }
- }
-
- /* prog_ref_level_present? */
- if (get_bits1(gb)) {
- che_drc->prog_ref_level = get_bits(gb, 7);
- skip_bits1(gb); // prog_ref_level_reserved_bits
- n++;
- }
-
- for (i = 0; i < drc_num_bands; i++) {
- che_drc->dyn_rng_sgn[i] = get_bits1(gb);
- che_drc->dyn_rng_ctl[i] = get_bits(gb, 7);
- n++;
- }
-
- return n;
-}
-
-static int decode_fill(AACContext *ac, GetBitContext *gb, int len) {
- uint8_t buf[256];
- int i, major, minor;
-
- if (len < 13+7*8)
- goto unknown;
-
- get_bits(gb, 13); len -= 13;
-
- for(i=0; i+1<sizeof(buf) && len>=8; i++, len-=8)
- buf[i] = get_bits(gb, 8);
-
- buf[i] = 0;
- if (ac->avctx->debug & FF_DEBUG_PICT_INFO)
- av_log(ac->avctx, AV_LOG_DEBUG, "FILL:%s\n", buf);
-
- if (sscanf(buf, "libfaac %d.%d", &major, &minor) == 2){
- ac->avctx->internal->skip_samples = 1024;
- }
-
-unknown:
- skip_bits_long(gb, len);
-
- return 0;
-}
-
-/**
- * Decode extension data (incomplete); reference: table 4.51.
- *
- * @param cnt length of TYPE_FIL syntactic element in bytes
- *
- * @return Returns number of bytes consumed
- */
-static int decode_extension_payload(AACContext *ac, GetBitContext *gb, int cnt,
- ChannelElement *che, enum RawDataBlockType elem_type)
-{
- int crc_flag = 0;
- int res = cnt;
- switch (get_bits(gb, 4)) { // extension type
- case EXT_SBR_DATA_CRC:
- crc_flag++;
- case EXT_SBR_DATA:
- if (!che) {
- av_log(ac->avctx, AV_LOG_ERROR, "SBR was found before the first channel element.\n");
- return res;
- } else if (!ac->oc[1].m4ac.sbr) {
- av_log(ac->avctx, AV_LOG_ERROR, "SBR signaled to be not-present but was found in the bitstream.\n");
- skip_bits_long(gb, 8 * cnt - 4);
- return res;
- } else if (ac->oc[1].m4ac.sbr == -1 && ac->oc[1].status == OC_LOCKED) {
- av_log(ac->avctx, AV_LOG_ERROR, "Implicit SBR was found with a first occurrence after the first frame.\n");
- skip_bits_long(gb, 8 * cnt - 4);
- return res;
- } else if (ac->oc[1].m4ac.ps == -1 && ac->oc[1].status < OC_LOCKED && ac->avctx->channels == 1) {
- ac->oc[1].m4ac.sbr = 1;
- ac->oc[1].m4ac.ps = 1;
- output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags,
- ac->oc[1].status, 1);
- } else {
- ac->oc[1].m4ac.sbr = 1;
- }
- res = ff_decode_sbr_extension(ac, &che->sbr, gb, crc_flag, cnt, elem_type);
- break;
- case EXT_DYNAMIC_RANGE:
- res = decode_dynamic_range(&ac->che_drc, gb);
- break;
- case EXT_FILL:
- decode_fill(ac, gb, 8 * cnt - 4);
- break;
- case EXT_FILL_DATA:
- case EXT_DATA_ELEMENT:
- default:
- skip_bits_long(gb, 8 * cnt - 4);
- break;
- };
- return res;
-}
-
-/**
- * Decode Temporal Noise Shaping filter coefficients and apply all-pole filters; reference: 4.6.9.3.
- *
- * @param decode 1 if tool is used normally, 0 if tool is used in LTP.
- * @param coef spectral coefficients
- */
-static void apply_tns(float coef[1024], TemporalNoiseShaping *tns,
- IndividualChannelStream *ics, int decode)
-{
- const int mmm = FFMIN(ics->tns_max_bands, ics->max_sfb);
- int w, filt, m, i;
- int bottom, top, order, start, end, size, inc;
- float lpc[TNS_MAX_ORDER];
- float tmp[TNS_MAX_ORDER+1];
-
- for (w = 0; w < ics->num_windows; w++) {
- bottom = ics->num_swb;
- for (filt = 0; filt < tns->n_filt[w]; filt++) {
- top = bottom;
- bottom = FFMAX(0, top - tns->length[w][filt]);
- order = tns->order[w][filt];
- if (order == 0)
- continue;
-
- // tns_decode_coef
- compute_lpc_coefs(tns->coef[w][filt], order, lpc, 0, 0, 0);
-
- start = ics->swb_offset[FFMIN(bottom, mmm)];
- end = ics->swb_offset[FFMIN( top, mmm)];
- if ((size = end - start) <= 0)
- continue;
- if (tns->direction[w][filt]) {
- inc = -1;
- start = end - 1;
- } else {
- inc = 1;
- }
- start += w * 128;
-
- if (decode) {
- // ar filter
- for (m = 0; m < size; m++, start += inc)
- for (i = 1; i <= FFMIN(m, order); i++)
- coef[start] -= coef[start - i * inc] * lpc[i - 1];
- } else {
- // ma filter
- for (m = 0; m < size; m++, start += inc) {
- tmp[0] = coef[start];
- for (i = 1; i <= FFMIN(m, order); i++)
- coef[start] += tmp[i] * lpc[i - 1];
- for (i = order; i > 0; i--)
- tmp[i] = tmp[i - 1];
- }
- }
- }
- }
-}
-
-/**
- * Apply windowing and MDCT to obtain the spectral
- * coefficient from the predicted sample by LTP.
- */
-static void windowing_and_mdct_ltp(AACContext *ac, float *out,
- float *in, IndividualChannelStream *ics)
-{
- const float *lwindow = ics->use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024;
- const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128;
- const float *lwindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_long_1024 : ff_sine_1024;
- const float *swindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128;
-
- if (ics->window_sequence[0] != LONG_STOP_SEQUENCE) {
- ac->fdsp.vector_fmul(in, in, lwindow_prev, 1024);
- } else {
- memset(in, 0, 448 * sizeof(float));
- ac->fdsp.vector_fmul(in + 448, in + 448, swindow_prev, 128);
- }
- if (ics->window_sequence[0] != LONG_START_SEQUENCE) {
- ac->fdsp.vector_fmul_reverse(in + 1024, in + 1024, lwindow, 1024);
- } else {
- ac->fdsp.vector_fmul_reverse(in + 1024 + 448, in + 1024 + 448, swindow, 128);
- memset(in + 1024 + 576, 0, 448 * sizeof(float));
- }
- ac->mdct_ltp.mdct_calc(&ac->mdct_ltp, out, in);
-}
-
-/**
- * Apply the long term prediction
- */
-static void apply_ltp(AACContext *ac, SingleChannelElement *sce)
-{
- const LongTermPrediction *ltp = &sce->ics.ltp;
- const uint16_t *offsets = sce->ics.swb_offset;
- int i, sfb;
-
- if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) {
- float *predTime = sce->ret;
- float *predFreq = ac->buf_mdct;
- int16_t num_samples = 2048;
-
- if (ltp->lag < 1024)
- num_samples = ltp->lag + 1024;
- for (i = 0; i < num_samples; i++)
- predTime[i] = sce->ltp_state[i + 2048 - ltp->lag] * ltp->coef;
- memset(&predTime[i], 0, (2048 - i) * sizeof(float));
-
- ac->windowing_and_mdct_ltp(ac, predFreq, predTime, &sce->ics);
-
- if (sce->tns.present)
- ac->apply_tns(predFreq, &sce->tns, &sce->ics, 0);
-
- for (sfb = 0; sfb < FFMIN(sce->ics.max_sfb, MAX_LTP_LONG_SFB); sfb++)
- if (ltp->used[sfb])
- for (i = offsets[sfb]; i < offsets[sfb + 1]; i++)
- sce->coeffs[i] += predFreq[i];
- }
-}
-
-/**
- * Update the LTP buffer for next frame
- */
-static void update_ltp(AACContext *ac, SingleChannelElement *sce)
-{
- IndividualChannelStream *ics = &sce->ics;
- float *saved = sce->saved;
- float *saved_ltp = sce->coeffs;
- const float *lwindow = ics->use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024;
- const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128;
- int i;
-
- if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
- memcpy(saved_ltp, saved, 512 * sizeof(float));
- memset(saved_ltp + 576, 0, 448 * sizeof(float));
- ac->fdsp.vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, &swindow[64], 64);
- for (i = 0; i < 64; i++)
- saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * swindow[63 - i];
- } else if (ics->window_sequence[0] == LONG_START_SEQUENCE) {
- memcpy(saved_ltp, ac->buf_mdct + 512, 448 * sizeof(float));
- memset(saved_ltp + 576, 0, 448 * sizeof(float));
- ac->fdsp.vector_fmul_reverse(saved_ltp + 448, ac->buf_mdct + 960, &swindow[64], 64);
- for (i = 0; i < 64; i++)
- saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * swindow[63 - i];
- } else { // LONG_STOP or ONLY_LONG
- ac->fdsp.vector_fmul_reverse(saved_ltp, ac->buf_mdct + 512, &lwindow[512], 512);
- for (i = 0; i < 512; i++)
- saved_ltp[i + 512] = ac->buf_mdct[1023 - i] * lwindow[511 - i];
- }
-
- memcpy(sce->ltp_state, sce->ltp_state+1024, 1024 * sizeof(*sce->ltp_state));
- memcpy(sce->ltp_state+1024, sce->ret, 1024 * sizeof(*sce->ltp_state));
- memcpy(sce->ltp_state+2048, saved_ltp, 1024 * sizeof(*sce->ltp_state));
-}
-
-/**
- * Conduct IMDCT and windowing.
- */
-static void imdct_and_windowing(AACContext *ac, SingleChannelElement *sce)
-{
- IndividualChannelStream *ics = &sce->ics;
- float *in = sce->coeffs;
- float *out = sce->ret;
- float *saved = sce->saved;
- const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128;
- const float *lwindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_long_1024 : ff_sine_1024;
- const float *swindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128;
- float *buf = ac->buf_mdct;
- float *temp = ac->temp;
- int i;
-
- // imdct
- if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
- for (i = 0; i < 1024; i += 128)
- ac->mdct_small.imdct_half(&ac->mdct_small, buf + i, in + i);
- } else
- ac->mdct.imdct_half(&ac->mdct, buf, in);
-
- /* window overlapping
- * NOTE: To simplify the overlapping code, all 'meaningless' short to long
- * and long to short transitions are considered to be short to short
- * transitions. This leaves just two cases (long to long and short to short)
- * with a little special sauce for EIGHT_SHORT_SEQUENCE.
- */
- if ((ics->window_sequence[1] == ONLY_LONG_SEQUENCE || ics->window_sequence[1] == LONG_STOP_SEQUENCE) &&
- (ics->window_sequence[0] == ONLY_LONG_SEQUENCE || ics->window_sequence[0] == LONG_START_SEQUENCE)) {
- ac->fdsp.vector_fmul_window( out, saved, buf, lwindow_prev, 512);
- } else {
- memcpy( out, saved, 448 * sizeof(float));
-
- if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
- ac->fdsp.vector_fmul_window(out + 448 + 0*128, saved + 448, buf + 0*128, swindow_prev, 64);
- ac->fdsp.vector_fmul_window(out + 448 + 1*128, buf + 0*128 + 64, buf + 1*128, swindow, 64);
- ac->fdsp.vector_fmul_window(out + 448 + 2*128, buf + 1*128 + 64, buf + 2*128, swindow, 64);
- ac->fdsp.vector_fmul_window(out + 448 + 3*128, buf + 2*128 + 64, buf + 3*128, swindow, 64);
- ac->fdsp.vector_fmul_window(temp, buf + 3*128 + 64, buf + 4*128, swindow, 64);
- memcpy( out + 448 + 4*128, temp, 64 * sizeof(float));
- } else {
- ac->fdsp.vector_fmul_window(out + 448, saved + 448, buf, swindow_prev, 64);
- memcpy( out + 576, buf + 64, 448 * sizeof(float));
- }
- }
-
- // buffer update
- if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
- memcpy( saved, temp + 64, 64 * sizeof(float));
- ac->fdsp.vector_fmul_window(saved + 64, buf + 4*128 + 64, buf + 5*128, swindow, 64);
- ac->fdsp.vector_fmul_window(saved + 192, buf + 5*128 + 64, buf + 6*128, swindow, 64);
- ac->fdsp.vector_fmul_window(saved + 320, buf + 6*128 + 64, buf + 7*128, swindow, 64);
- memcpy( saved + 448, buf + 7*128 + 64, 64 * sizeof(float));
- } else if (ics->window_sequence[0] == LONG_START_SEQUENCE) {
- memcpy( saved, buf + 512, 448 * sizeof(float));
- memcpy( saved + 448, buf + 7*128 + 64, 64 * sizeof(float));
- } else { // LONG_STOP or ONLY_LONG
- memcpy( saved, buf + 512, 512 * sizeof(float));
- }
-}
-
-/**
- * Apply dependent channel coupling (applied before IMDCT).
- *
- * @param index index into coupling gain array
- */
-static void apply_dependent_coupling(AACContext *ac,
- SingleChannelElement *target,
- ChannelElement *cce, int index)
-{
- IndividualChannelStream *ics = &cce->ch[0].ics;
- const uint16_t *offsets = ics->swb_offset;
- float *dest = target->coeffs;
- const float *src = cce->ch[0].coeffs;
- int g, i, group, k, idx = 0;
- if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) {
- av_log(ac->avctx, AV_LOG_ERROR,
- "Dependent coupling is not supported together with LTP\n");
- return;
- }
- for (g = 0; g < ics->num_window_groups; g++) {
- for (i = 0; i < ics->max_sfb; i++, idx++) {
- if (cce->ch[0].band_type[idx] != ZERO_BT) {
- 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
- dest[group * 128 + k] += gain * src[group * 128 + k];
- }
- }
- }
- }
- dest += ics->group_len[g] * 128;
- src += ics->group_len[g] * 128;
- }
-}
-
-/**
- * Apply independent channel coupling (applied after IMDCT).
- *
- * @param index index into coupling gain array
- */
-static void apply_independent_coupling(AACContext *ac,
- SingleChannelElement *target,
- ChannelElement *cce, int index)
-{
- int i;
- const float gain = cce->coup.gain[index][0];
- const float *src = cce->ch[0].ret;
- float *dest = target->ret;
- const int len = 1024 << (ac->oc[1].m4ac.sbr == 1);
-
- for (i = 0; i < len; i++)
- dest[i] += gain * src[i];
-}
-
-/**
- * channel coupling transformation interface
- *
- * @param apply_coupling_method pointer to (in)dependent coupling function
- */
-static void apply_channel_coupling(AACContext *ac, ChannelElement *cc,
- enum RawDataBlockType type, int elem_id,
- enum CouplingPoint coupling_point,
- void (*apply_coupling_method)(AACContext *ac, SingleChannelElement *target, ChannelElement *cce, int index))
-{
- int i, c;
-
- for (i = 0; i < MAX_ELEM_ID; i++) {
- ChannelElement *cce = ac->che[TYPE_CCE][i];
- int index = 0;
-
- if (cce && cce->coup.coupling_point == coupling_point) {
- ChannelCoupling *coup = &cce->coup;
-
- for (c = 0; c <= coup->num_coupled; c++) {
- if (coup->type[c] == type && coup->id_select[c] == elem_id) {
- if (coup->ch_select[c] != 1) {
- apply_coupling_method(ac, &cc->ch[0], cce, index);
- if (coup->ch_select[c] != 0)
- index++;
- }
- if (coup->ch_select[c] != 2)
- apply_coupling_method(ac, &cc->ch[1], cce, index++);
- } else
- index += 1 + (coup->ch_select[c] == 3);
- }
- }
- }
-}
-
-/**
- * Convert spectral data to float samples, applying all supported tools as appropriate.
- */
-static void spectral_to_sample(AACContext *ac)
-{
- int i, type;
- for (type = 3; type >= 0; type--) {
- for (i = 0; i < MAX_ELEM_ID; i++) {
- ChannelElement *che = ac->che[type][i];
- if (che) {
- if (type <= TYPE_CPE)
- apply_channel_coupling(ac, che, type, i, BEFORE_TNS, apply_dependent_coupling);
- if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP) {
- if (che->ch[0].ics.predictor_present) {
- if (che->ch[0].ics.ltp.present)
- ac->apply_ltp(ac, &che->ch[0]);
- if (che->ch[1].ics.ltp.present && type == TYPE_CPE)
- ac->apply_ltp(ac, &che->ch[1]);
- }
- }
- if (che->ch[0].tns.present)
- ac->apply_tns(che->ch[0].coeffs, &che->ch[0].tns, &che->ch[0].ics, 1);
- if (che->ch[1].tns.present)
- ac->apply_tns(che->ch[1].coeffs, &che->ch[1].tns, &che->ch[1].ics, 1);
- if (type <= TYPE_CPE)
- apply_channel_coupling(ac, che, type, i, BETWEEN_TNS_AND_IMDCT, apply_dependent_coupling);
- if (type != TYPE_CCE || che->coup.coupling_point == AFTER_IMDCT) {
- ac->imdct_and_windowing(ac, &che->ch[0]);
- if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP)
- ac->update_ltp(ac, &che->ch[0]);
- if (type == TYPE_CPE) {
- ac->imdct_and_windowing(ac, &che->ch[1]);
- if (ac->oc[1].m4ac.object_type == AOT_AAC_LTP)
- ac->update_ltp(ac, &che->ch[1]);
- }
- if (ac->oc[1].m4ac.sbr > 0) {
- ff_sbr_apply(ac, &che->sbr, type, che->ch[0].ret, che->ch[1].ret);
- }
- }
- if (type <= TYPE_CCE)
- apply_channel_coupling(ac, che, type, i, AFTER_IMDCT, apply_independent_coupling);
- }
- }
- }
-}
-
-static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb)
-{
- int size;
- AACADTSHeaderInfo hdr_info;
- uint8_t layout_map[MAX_ELEM_ID*4][3];
- int layout_map_tags;
-
- size = avpriv_aac_parse_header(gb, &hdr_info);
- if (size > 0) {
- if (!ac->warned_num_aac_frames && hdr_info.num_aac_frames != 1) {
- // This is 2 for "VLB " audio in NSV files.
- // See samples/nsv/vlb_audio.
- av_log_missing_feature(ac->avctx, "More than one AAC RDB per ADTS frame", 0);
- ac->warned_num_aac_frames = 1;
- }
- push_output_configuration(ac);
- if (hdr_info.chan_config) {
- ac->oc[1].m4ac.chan_config = hdr_info.chan_config;
- if (set_default_channel_config(ac->avctx, layout_map,
- &layout_map_tags, hdr_info.chan_config))
- return -7;
- if (output_configure(ac, layout_map, layout_map_tags,
- FFMAX(ac->oc[1].status, OC_TRIAL_FRAME), 0))
- return -7;
- } else {
- ac->oc[1].m4ac.chan_config = 0;
- /**
- * dual mono frames in Japanese DTV can have chan_config 0
- * WITHOUT specifying PCE.
- * thus, set dual mono as default.
- */
- if (ac->dmono_mode && ac->oc[0].status == OC_NONE) {
- layout_map_tags = 2;
- layout_map[0][0] = layout_map[1][0] = TYPE_SCE;
- layout_map[0][2] = layout_map[1][2] = AAC_CHANNEL_FRONT;
- layout_map[0][1] = 0;
- layout_map[1][1] = 1;
- if (output_configure(ac, layout_map, layout_map_tags,
- OC_TRIAL_FRAME, 0))
- return -7;
- }
- }
- ac->oc[1].m4ac.sample_rate = hdr_info.sample_rate;
- ac->oc[1].m4ac.sampling_index = hdr_info.sampling_index;
- ac->oc[1].m4ac.object_type = hdr_info.object_type;
- if (ac->oc[0].status != OC_LOCKED ||
- ac->oc[0].m4ac.chan_config != hdr_info.chan_config ||
- ac->oc[0].m4ac.sample_rate != hdr_info.sample_rate) {
- ac->oc[1].m4ac.sbr = -1;
- ac->oc[1].m4ac.ps = -1;
- }
- if (!hdr_info.crc_absent)
- skip_bits(gb, 16);
- }
- return size;
-}
-
-static int aac_decode_frame_int(AVCodecContext *avctx, void *data,
- int *got_frame_ptr, GetBitContext *gb, AVPacket *avpkt)
-{
- AACContext *ac = avctx->priv_data;
- ChannelElement *che = NULL, *che_prev = NULL;
- enum RawDataBlockType elem_type, elem_type_prev = TYPE_END;
- int err, elem_id;
- int samples = 0, multiplier, audio_found = 0, pce_found = 0;
- int is_dmono, sce_count = 0;
-
- ac->frame = data;
-
- if (show_bits(gb, 12) == 0xfff) {
- if (parse_adts_frame_header(ac, gb) < 0) {
- av_log(avctx, AV_LOG_ERROR, "Error decoding AAC frame header.\n");
- err = -1;
- goto fail;
- }
- if (ac->oc[1].m4ac.sampling_index > 12) {
- av_log(ac->avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", ac->oc[1].m4ac.sampling_index);
- err = -1;
- goto fail;
- }
- }
-
- if (frame_configure_elements(avctx) < 0) {
- err = -1;
- goto fail;
- }
-
- ac->tags_mapped = 0;
- // parse
- while ((elem_type = get_bits(gb, 3)) != TYPE_END) {
- elem_id = get_bits(gb, 4);
-
- if (elem_type < TYPE_DSE) {
- if (!(che=get_che(ac, elem_type, elem_id))) {
- av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d is not allocated\n",
- elem_type, elem_id);
- err = -1;
- goto fail;
- }
- samples = 1024;
- }
-
- switch (elem_type) {
-
- case TYPE_SCE:
- err = decode_ics(ac, &che->ch[0], gb, 0, 0);
- audio_found = 1;
- sce_count++;
- break;
-
- case TYPE_CPE:
- err = decode_cpe(ac, gb, che);
- audio_found = 1;
- break;
-
- case TYPE_CCE:
- err = decode_cce(ac, gb, che);
- break;
-
- case TYPE_LFE:
- err = decode_ics(ac, &che->ch[0], gb, 0, 0);
- audio_found = 1;
- break;
-
- case TYPE_DSE:
- err = skip_data_stream_element(ac, gb);
- break;
-
- case TYPE_PCE: {
- uint8_t layout_map[MAX_ELEM_ID*4][3];
- int tags;
- push_output_configuration(ac);
- tags = decode_pce(avctx, &ac->oc[1].m4ac, layout_map, gb);
- if (tags < 0) {
- err = tags;
- break;
- }
- if (pce_found) {
- av_log(avctx, AV_LOG_ERROR,
- "Not evaluating a further program_config_element as this construct is dubious at best.\n");
- pop_output_configuration(ac);
- } else {
- err = output_configure(ac, layout_map, tags, OC_TRIAL_PCE, 1);
- if (!err)
- ac->oc[1].m4ac.chan_config = 0;
- pce_found = 1;
- }
- break;
- }
-
- case TYPE_FIL:
- if (elem_id == 15)
- elem_id += get_bits(gb, 8) - 1;
- if (get_bits_left(gb) < 8 * elem_id) {
- av_log(avctx, AV_LOG_ERROR, "TYPE_FIL: "overread_err);
- err = -1;
- goto fail;
- }
- while (elem_id > 0)
- elem_id -= decode_extension_payload(ac, gb, elem_id, che_prev, elem_type_prev);
- err = 0; /* FIXME */
- break;
-
- default:
- err = -1; /* should not happen, but keeps compiler happy */
- break;
- }
-
- che_prev = che;
- elem_type_prev = elem_type;
-
- if (err)
- goto fail;
-
- if (get_bits_left(gb) < 3) {
- av_log(avctx, AV_LOG_ERROR, overread_err);
- err = -1;
- goto fail;
- }
- }
-
- spectral_to_sample(ac);
-
- 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;
- *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;
- avctx->frame_size = samples;
- ac->oc[1].status = OC_LOCKED;
- }
-
- if (multiplier) {
- int side_size;
- uint32_t *side = av_packet_get_side_data(avpkt, AV_PKT_DATA_SKIP_SAMPLES, &side_size);
- if (side && side_size>=4)
- AV_WL32(side, 2*AV_RL32(side));
- }
- return 0;
-fail:
- pop_output_configuration(ac);
- return err;
-}
-
-static int aac_decode_frame(AVCodecContext *avctx, void *data,
- int *got_frame_ptr, AVPacket *avpkt)
-{
- AACContext *ac = avctx->priv_data;
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
- GetBitContext gb;
- int buf_consumed;
- int buf_offset;
- int err;
- int new_extradata_size;
- const uint8_t *new_extradata = av_packet_get_side_data(avpkt,
- AV_PKT_DATA_NEW_EXTRADATA,
- &new_extradata_size);
- int jp_dualmono_size;
- const uint8_t *jp_dualmono = av_packet_get_side_data(avpkt,
- AV_PKT_DATA_JP_DUALMONO,
- &jp_dualmono_size);
-
- if (new_extradata && 0) {
- av_free(avctx->extradata);
- avctx->extradata = av_mallocz(new_extradata_size +
- FF_INPUT_BUFFER_PADDING_SIZE);
- if (!avctx->extradata)
- return AVERROR(ENOMEM);
- avctx->extradata_size = new_extradata_size;
- memcpy(avctx->extradata, new_extradata, new_extradata_size);
- push_output_configuration(ac);
- if (decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac,
- avctx->extradata,
- avctx->extradata_size*8, 1) < 0) {
- pop_output_configuration(ac);
- return AVERROR_INVALIDDATA;
- }
- }
-
- ac->dmono_mode = 0;
- if (jp_dualmono && jp_dualmono_size > 0)
- ac->dmono_mode = 1 + *jp_dualmono;
- if (ac->force_dmono_mode >= 0)
- ac->dmono_mode = ac->force_dmono_mode;
-
- if (INT_MAX / 8 <= buf_size)
- return AVERROR_INVALIDDATA;
-
- init_get_bits(&gb, buf, buf_size * 8);
-
- if ((err = aac_decode_frame_int(avctx, data, got_frame_ptr, &gb, avpkt)) < 0)
- return err;
-
- buf_consumed = (get_bits_count(&gb) + 7) >> 3;
- for (buf_offset = buf_consumed; buf_offset < buf_size; buf_offset++)
- if (buf[buf_offset])
- break;
-
- return buf_size > buf_offset ? buf_consumed : buf_size;
-}
-
-static av_cold int aac_decode_close(AVCodecContext *avctx)
-{
- AACContext *ac = avctx->priv_data;
- int i, type;
-
- for (i = 0; i < MAX_ELEM_ID; i++) {
- for (type = 0; type < 4; type++) {
- if (ac->che[type][i])
- ff_aac_sbr_ctx_close(&ac->che[type][i]->sbr);
- av_freep(&ac->che[type][i]);
- }
- }
-
- ff_mdct_end(&ac->mdct);
- ff_mdct_end(&ac->mdct_small);
- ff_mdct_end(&ac->mdct_ltp);
- return 0;
-}
-
-
-#define LOAS_SYNC_WORD 0x2b7 ///< 11 bits LOAS sync word
-
-struct LATMContext {
- AACContext aac_ctx; ///< containing AACContext
- int initialized; ///< initialized after a valid extradata was seen
-
- // parser data
- int audio_mux_version_A; ///< LATM syntax version
- int frame_length_type; ///< 0/1 variable/fixed frame length
- int frame_length; ///< frame length for fixed frame length
-};
-
-static inline uint32_t latm_get_value(GetBitContext *b)
-{
- int length = get_bits(b, 2);
-
- return get_bits_long(b, (length+1)*8);
-}
-
-static int latm_decode_audio_specific_config(struct LATMContext *latmctx,
- GetBitContext *gb, int asclen)
-{
- AACContext *ac = &latmctx->aac_ctx;
- AVCodecContext *avctx = ac->avctx;
- MPEG4AudioConfig m4ac = { 0 };
- int config_start_bit = get_bits_count(gb);
- int sync_extension = 0;
- int bits_consumed, esize;
-
- if (asclen) {
- sync_extension = 1;
- asclen = FFMIN(asclen, get_bits_left(gb));
- } else
- asclen = get_bits_left(gb);
-
- if (config_start_bit % 8) {
- av_log_missing_feature(latmctx->aac_ctx.avctx,
- "Non-byte-aligned audio-specific config", 1);
- return AVERROR_PATCHWELCOME;
- }
- if (asclen <= 0)
- return AVERROR_INVALIDDATA;
- bits_consumed = decode_audio_specific_config(NULL, avctx, &m4ac,
- gb->buffer + (config_start_bit / 8),
- asclen, sync_extension);
-
- if (bits_consumed < 0)
- return AVERROR_INVALIDDATA;
-
- if (!latmctx->initialized ||
- ac->oc[1].m4ac.sample_rate != m4ac.sample_rate ||
- ac->oc[1].m4ac.chan_config != m4ac.chan_config) {
-
- if(latmctx->initialized) {
- av_log(avctx, AV_LOG_INFO, "audio config changed\n");
- } else {
- av_log(avctx, AV_LOG_DEBUG, "initializing latmctx\n");
- }
- latmctx->initialized = 0;
-
- esize = (bits_consumed+7) / 8;
-
- if (avctx->extradata_size < esize) {
- av_free(avctx->extradata);
- avctx->extradata = av_malloc(esize + FF_INPUT_BUFFER_PADDING_SIZE);
- if (!avctx->extradata)
- return AVERROR(ENOMEM);
- }
-
- avctx->extradata_size = esize;
- memcpy(avctx->extradata, gb->buffer + (config_start_bit/8), esize);
- memset(avctx->extradata+esize, 0, FF_INPUT_BUFFER_PADDING_SIZE);
- }
- skip_bits_long(gb, bits_consumed);
-
- return bits_consumed;
-}
-
-static int read_stream_mux_config(struct LATMContext *latmctx,
- GetBitContext *gb)
-{
- int ret, audio_mux_version = get_bits(gb, 1);
-
- latmctx->audio_mux_version_A = 0;
- if (audio_mux_version)
- latmctx->audio_mux_version_A = get_bits(gb, 1);
-
- if (!latmctx->audio_mux_version_A) {
-
- if (audio_mux_version)
- latm_get_value(gb); // taraFullness
-
- skip_bits(gb, 1); // allStreamSameTimeFraming
- skip_bits(gb, 6); // numSubFrames
- // numPrograms
- if (get_bits(gb, 4)) { // numPrograms
- av_log_missing_feature(latmctx->aac_ctx.avctx,
- "Multiple programs", 1);
- return AVERROR_PATCHWELCOME;
- }
-
- // for each program (which there is only one in DVB)
-
- // for each layer (which there is only one in DVB)
- if (get_bits(gb, 3)) { // numLayer
- av_log_missing_feature(latmctx->aac_ctx.avctx,
- "Multiple layers", 1);
- return AVERROR_PATCHWELCOME;
- }
-
- // for all but first stream: use_same_config = get_bits(gb, 1);
- if (!audio_mux_version) {
- if ((ret = latm_decode_audio_specific_config(latmctx, gb, 0)) < 0)
- return ret;
- } else {
- int ascLen = latm_get_value(gb);
- if ((ret = latm_decode_audio_specific_config(latmctx, gb, ascLen)) < 0)
- return ret;
- ascLen -= ret;
- skip_bits_long(gb, ascLen);
- }
-
- latmctx->frame_length_type = get_bits(gb, 3);
- switch (latmctx->frame_length_type) {
- case 0:
- skip_bits(gb, 8); // latmBufferFullness
- break;
- case 1:
- latmctx->frame_length = get_bits(gb, 9);
- break;
- case 3:
- case 4:
- case 5:
- skip_bits(gb, 6); // CELP frame length table index
- break;
- case 6:
- case 7:
- skip_bits(gb, 1); // HVXC frame length table index
- break;
- }
-
- if (get_bits(gb, 1)) { // other data
- if (audio_mux_version) {
- latm_get_value(gb); // other_data_bits
- } else {
- int esc;
- do {
- esc = get_bits(gb, 1);
- skip_bits(gb, 8);
- } while (esc);
- }
- }
-
- if (get_bits(gb, 1)) // crc present
- skip_bits(gb, 8); // config_crc
- }
-
- return 0;
-}
-
-static int read_payload_length_info(struct LATMContext *ctx, GetBitContext *gb)
-{
- uint8_t tmp;
-
- if (ctx->frame_length_type == 0) {
- int mux_slot_length = 0;
- do {
- tmp = get_bits(gb, 8);
- mux_slot_length += tmp;
- } while (tmp == 255);
- return mux_slot_length;
- } else if (ctx->frame_length_type == 1) {
- return ctx->frame_length;
- } else if (ctx->frame_length_type == 3 ||
- ctx->frame_length_type == 5 ||
- ctx->frame_length_type == 7) {
- skip_bits(gb, 2); // mux_slot_length_coded
- }
- return 0;
-}
-
-static int read_audio_mux_element(struct LATMContext *latmctx,
- GetBitContext *gb)
-{
- int err;
- uint8_t use_same_mux = get_bits(gb, 1);
- if (!use_same_mux) {
- if ((err = read_stream_mux_config(latmctx, gb)) < 0)
- return err;
- } else if (!latmctx->aac_ctx.avctx->extradata) {
- av_log(latmctx->aac_ctx.avctx, AV_LOG_DEBUG,
- "no decoder config found\n");
- return AVERROR(EAGAIN);
- }
- if (latmctx->audio_mux_version_A == 0) {
- int mux_slot_length_bytes = read_payload_length_info(latmctx, gb);
- if (mux_slot_length_bytes * 8 > get_bits_left(gb)) {
- av_log(latmctx->aac_ctx.avctx, AV_LOG_ERROR, "incomplete frame\n");
- return AVERROR_INVALIDDATA;
- } else if (mux_slot_length_bytes * 8 + 256 < get_bits_left(gb)) {
- av_log(latmctx->aac_ctx.avctx, AV_LOG_ERROR,
- "frame length mismatch %d << %d\n",
- mux_slot_length_bytes * 8, get_bits_left(gb));
- return AVERROR_INVALIDDATA;
- }
- }
- return 0;
-}
-
-
-static int latm_decode_frame(AVCodecContext *avctx, void *out,
- int *got_frame_ptr, AVPacket *avpkt)
-{
- struct LATMContext *latmctx = avctx->priv_data;
- int muxlength, err;
- GetBitContext gb;
-
- if ((err = init_get_bits8(&gb, avpkt->data, avpkt->size)) < 0)
- return err;
-
- // check for LOAS sync word
- if (get_bits(&gb, 11) != LOAS_SYNC_WORD)
- return AVERROR_INVALIDDATA;
-
- muxlength = get_bits(&gb, 13) + 3;
- // not enough data, the parser should have sorted this out
- if (muxlength > avpkt->size)
- return AVERROR_INVALIDDATA;
-
- if ((err = read_audio_mux_element(latmctx, &gb)) < 0)
- return err;
-
- if (!latmctx->initialized) {
- if (!avctx->extradata) {
- *got_frame_ptr = 0;
- return avpkt->size;
- } else {
- push_output_configuration(&latmctx->aac_ctx);
- if ((err = decode_audio_specific_config(
- &latmctx->aac_ctx, avctx, &latmctx->aac_ctx.oc[1].m4ac,
- avctx->extradata, avctx->extradata_size*8, 1)) < 0) {
- pop_output_configuration(&latmctx->aac_ctx);
- return err;
- }
- latmctx->initialized = 1;
- }
- }
-
- if (show_bits(&gb, 12) == 0xfff) {
- av_log(latmctx->aac_ctx.avctx, AV_LOG_ERROR,
- "ADTS header detected, probably as result of configuration "
- "misparsing\n");
- return AVERROR_INVALIDDATA;
- }
-
- if ((err = aac_decode_frame_int(avctx, out, got_frame_ptr, &gb, avpkt)) < 0)
- return err;
-
- return muxlength;
-}
-
-static av_cold int latm_decode_init(AVCodecContext *avctx)
-{
- struct LATMContext *latmctx = avctx->priv_data;
- int ret = aac_decode_init(avctx);
-
- if (avctx->extradata_size > 0)
- latmctx->initialized = !ret;
-
- return ret;
-}
-
-static void aacdec_init(AACContext *c)
-{
- c->imdct_and_windowing = imdct_and_windowing;
- c->apply_ltp = apply_ltp;
- c->apply_tns = apply_tns;
- c->windowing_and_mdct_ltp = windowing_and_mdct_ltp;
- c->update_ltp = update_ltp;
-
- if(ARCH_MIPS)
- ff_aacdec_init_mips(c);
-}
-/**
- * AVOptions for Japanese DTV specific extensions (ADTS only)
- */
-#define AACDEC_FLAGS AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
-static const AVOption options[] = {
- {"dual_mono_mode", "Select the channel to decode for dual mono",
- offsetof(AACContext, force_dmono_mode), AV_OPT_TYPE_INT, {.i64=-1}, -1, 2,
- AACDEC_FLAGS, "dual_mono_mode"},
-
- {"auto", "autoselection", 0, AV_OPT_TYPE_CONST, {.i64=-1}, INT_MIN, INT_MAX, AACDEC_FLAGS, "dual_mono_mode"},
- {"main", "Select Main/Left channel", 0, AV_OPT_TYPE_CONST, {.i64= 1}, INT_MIN, INT_MAX, AACDEC_FLAGS, "dual_mono_mode"},
- {"sub" , "Select Sub/Right channel", 0, AV_OPT_TYPE_CONST, {.i64= 2}, INT_MIN, INT_MAX, AACDEC_FLAGS, "dual_mono_mode"},
- {"both", "Select both channels", 0, AV_OPT_TYPE_CONST, {.i64= 0}, INT_MIN, INT_MAX, AACDEC_FLAGS, "dual_mono_mode"},
-
- {NULL},
-};
-
-static const AVClass aac_decoder_class = {
- .class_name = "AAC decoder",
- .item_name = av_default_item_name,
- .option = options,
- .version = LIBAVUTIL_VERSION_INT,
-};
-
-AVCodec ff_aac_decoder = {
- .name = "aac",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_AAC,
- .priv_data_size = sizeof(AACContext),
- .init = aac_decode_init,
- .close = aac_decode_close,
- .decode = aac_decode_frame,
- .long_name = NULL_IF_CONFIG_SMALL("AAC (Advanced Audio Coding)"),
- .sample_fmts = (const enum AVSampleFormat[]) {
- AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE
- },
- .capabilities = CODEC_CAP_CHANNEL_CONF | CODEC_CAP_DR1,
- .channel_layouts = aac_channel_layout,
- .flush = flush,
- .priv_class = &aac_decoder_class,
-};
-
-/*
- Note: This decoder filter is intended to decode LATM streams transferred
- in MPEG transport streams which only contain one program.
- To do a more complex LATM demuxing a separate LATM demuxer should be used.
-*/
-AVCodec ff_aac_latm_decoder = {
- .name = "aac_latm",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_AAC_LATM,
- .priv_data_size = sizeof(struct LATMContext),
- .init = latm_decode_init,
- .close = aac_decode_close,
- .decode = latm_decode_frame,
- .long_name = NULL_IF_CONFIG_SMALL("AAC LATM (Advanced Audio Coding LATM syntax)"),
- .sample_fmts = (const enum AVSampleFormat[]) {
- AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE
- },
- .capabilities = CODEC_CAP_CHANNEL_CONF | CODEC_CAP_DR1,
- .channel_layouts = aac_channel_layout,
- .flush = flush,
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/aacdectab.h b/src/thirdparty/ffmpeg/libavcodec/aacdectab.h
deleted file mode 100644
index eabb7821b..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/aacdectab.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * AAC decoder data
- * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org )
- * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov 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
- * AAC decoder data
- * @author Oded Shimon ( ods15 ods15 dyndns org )
- * @author Maxim Gavrilov ( maxim.gavrilov gmail com )
- */
-
-#ifndef AVCODEC_AACDECTAB_H
-#define AVCODEC_AACDECTAB_H
-
-#include "libavutil/channel_layout.h"
-#include "aac.h"
-
-#include <stdint.h>
-
-/* @name ltp_coef
- * Table of the LTP coefficients
- */
-static const float ltp_coef[8] = {
- 0.570829, 0.696616, 0.813004, 0.911304,
- 0.984900, 1.067894, 1.194601, 1.369533,
-};
-
-/* @name tns_tmp2_map
- * Tables of the tmp2[] arrays of LPC coefficients used for TNS.
- * The suffix _M_N[] indicate the values of coef_compress and coef_res
- * respectively.
- * @{
- */
-static const float tns_tmp2_map_1_3[4] = {
- 0.00000000, -0.43388373, 0.64278758, 0.34202015,
-};
-
-static const float tns_tmp2_map_0_3[8] = {
- 0.00000000, -0.43388373, -0.78183150, -0.97492790,
- 0.98480773, 0.86602539, 0.64278758, 0.34202015,
-};
-
-static const float tns_tmp2_map_1_4[8] = {
- 0.00000000, -0.20791170, -0.40673664, -0.58778524,
- 0.67369562, 0.52643216, 0.36124167, 0.18374951,
-};
-
-static const float tns_tmp2_map_0_4[16] = {
- 0.00000000, -0.20791170, -0.40673664, -0.58778524,
- -0.74314481, -0.86602539, -0.95105654, -0.99452192,
- 0.99573416, 0.96182561, 0.89516330, 0.79801720,
- 0.67369562, 0.52643216, 0.36124167, 0.18374951,
-};
-
-static const float * const tns_tmp2_map[4] = {
- tns_tmp2_map_0_3,
- tns_tmp2_map_0_4,
- tns_tmp2_map_1_3,
- tns_tmp2_map_1_4
-};
-// @}
-
-static const int8_t tags_per_config[16] = { 0, 1, 1, 2, 3, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0 };
-
-static const uint8_t aac_channel_layout_map[7][5][3] = {
- { { TYPE_SCE, 0, AAC_CHANNEL_FRONT }, },
- { { TYPE_CPE, 0, AAC_CHANNEL_FRONT }, },
- { { TYPE_SCE, 0, AAC_CHANNEL_FRONT }, { TYPE_CPE, 0, AAC_CHANNEL_FRONT }, },
- { { TYPE_SCE, 0, AAC_CHANNEL_FRONT }, { TYPE_CPE, 0, AAC_CHANNEL_FRONT }, { TYPE_SCE, 1, AAC_CHANNEL_BACK }, },
- { { TYPE_SCE, 0, AAC_CHANNEL_FRONT }, { TYPE_CPE, 0, AAC_CHANNEL_FRONT }, { TYPE_CPE, 1, AAC_CHANNEL_BACK }, },
- { { TYPE_SCE, 0, AAC_CHANNEL_FRONT }, { TYPE_CPE, 0, AAC_CHANNEL_FRONT }, { TYPE_CPE, 1, AAC_CHANNEL_BACK }, { TYPE_LFE, 0, AAC_CHANNEL_LFE }, },
- { { TYPE_SCE, 0, AAC_CHANNEL_FRONT }, { TYPE_CPE, 0, AAC_CHANNEL_FRONT }, { TYPE_CPE, 1, AAC_CHANNEL_FRONT }, { TYPE_CPE, 2, AAC_CHANNEL_BACK }, { TYPE_LFE, 0, AAC_CHANNEL_LFE }, },
-};
-
-static const uint64_t aac_channel_layout[8] = {
- AV_CH_LAYOUT_MONO,
- AV_CH_LAYOUT_STEREO,
- AV_CH_LAYOUT_SURROUND,
- AV_CH_LAYOUT_4POINT0,
- AV_CH_LAYOUT_5POINT0_BACK,
- AV_CH_LAYOUT_5POINT1_BACK,
- AV_CH_LAYOUT_7POINT1_WIDE_BACK,
- 0,
-};
-
-#endif /* AVCODEC_AACDECTAB_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/aacps.c b/src/thirdparty/ffmpeg/libavcodec/aacps.c
deleted file mode 100644
index b3c203507..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/aacps.c
+++ /dev/null
@@ -1,968 +0,0 @@
-/*
- * MPEG-4 Parametric Stereo decoding functions
- * Copyright (c) 2010 Alex Converse <alex.converse@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 <stdint.h>
-#include "libavutil/common.h"
-#include "libavutil/internal.h"
-#include "libavutil/mathematics.h"
-#include "avcodec.h"
-#include "get_bits.h"
-#include "aacps.h"
-#include "aacps_tablegen.h"
-#include "aacpsdata.c"
-
-#define PS_BASELINE 0 ///< Operate in Baseline PS mode
- ///< Baseline implies 10 or 20 stereo bands,
- ///< mixing mode A, and no ipd/opd
-
-#define numQMFSlots 32 //numTimeSlots * RATE
-
-static const int8_t num_env_tab[2][4] = {
- { 0, 1, 2, 4, },
- { 1, 2, 3, 4, },
-};
-
-static const int8_t nr_iidicc_par_tab[] = {
- 10, 20, 34, 10, 20, 34,
-};
-
-static const int8_t nr_iidopd_par_tab[] = {
- 5, 11, 17, 5, 11, 17,
-};
-
-enum {
- huff_iid_df1,
- huff_iid_dt1,
- huff_iid_df0,
- huff_iid_dt0,
- huff_icc_df,
- huff_icc_dt,
- huff_ipd_df,
- huff_ipd_dt,
- huff_opd_df,
- huff_opd_dt,
-};
-
-static const int huff_iid[] = {
- huff_iid_df0,
- huff_iid_df1,
- huff_iid_dt0,
- huff_iid_dt1,
-};
-
-static VLC vlc_ps[10];
-
-#define READ_PAR_DATA(PAR, OFFSET, MASK, ERR_CONDITION) \
-/** \
- * Read Inter-channel Intensity Difference/Inter-Channel Coherence/ \
- * Inter-channel Phase Difference/Overall Phase Difference parameters from the \
- * bitstream. \
- * \
- * @param avctx contains the current codec context \
- * @param gb pointer to the input bitstream \
- * @param ps pointer to the Parametric Stereo context \
- * @param PAR pointer to the parameter to be read \
- * @param e envelope to decode \
- * @param dt 1: time delta-coded, 0: frequency delta-coded \
- */ \
-static int read_ ## PAR ## _data(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, \
- int8_t (*PAR)[PS_MAX_NR_IIDICC], int table_idx, int e, int dt) \
-{ \
- int b, num = ps->nr_ ## PAR ## _par; \
- VLC_TYPE (*vlc_table)[2] = vlc_ps[table_idx].table; \
- if (dt) { \
- int e_prev = e ? e - 1 : ps->num_env_old - 1; \
- e_prev = FFMAX(e_prev, 0); \
- for (b = 0; b < num; b++) { \
- int val = PAR[e_prev][b] + get_vlc2(gb, vlc_table, 9, 3) - OFFSET; \
- if (MASK) val &= MASK; \
- PAR[e][b] = val; \
- if (ERR_CONDITION) \
- goto err; \
- } \
- } else { \
- int val = 0; \
- for (b = 0; b < num; b++) { \
- val += get_vlc2(gb, vlc_table, 9, 3) - OFFSET; \
- if (MASK) val &= MASK; \
- PAR[e][b] = val; \
- if (ERR_CONDITION) \
- goto err; \
- } \
- } \
- return 0; \
-err: \
- av_log(avctx, AV_LOG_ERROR, "illegal "#PAR"\n"); \
- return -1; \
-}
-
-READ_PAR_DATA(iid, huff_offset[table_idx], 0, FFABS(ps->iid_par[e][b]) > 7 + 8 * ps->iid_quant)
-READ_PAR_DATA(icc, huff_offset[table_idx], 0, ps->icc_par[e][b] > 7U)
-READ_PAR_DATA(ipdopd, 0, 0x07, 0)
-
-static int ps_read_extension_data(GetBitContext *gb, PSContext *ps, int ps_extension_id)
-{
- int e;
- int count = get_bits_count(gb);
-
- if (ps_extension_id)
- return 0;
-
- ps->enable_ipdopd = get_bits1(gb);
- if (ps->enable_ipdopd) {
- for (e = 0; e < ps->num_env; e++) {
- int dt = get_bits1(gb);
- read_ipdopd_data(NULL, gb, ps, ps->ipd_par, dt ? huff_ipd_dt : huff_ipd_df, e, dt);
- dt = get_bits1(gb);
- read_ipdopd_data(NULL, gb, ps, ps->opd_par, dt ? huff_opd_dt : huff_opd_df, e, dt);
- }
- }
- skip_bits1(gb); //reserved_ps
- return get_bits_count(gb) - count;
-}
-
-static void ipdopd_reset(int8_t *ipd_hist, int8_t *opd_hist)
-{
- int i;
- for (i = 0; i < PS_MAX_NR_IPDOPD; i++) {
- opd_hist[i] = 0;
- ipd_hist[i] = 0;
- }
-}
-
-int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps, int bits_left)
-{
- int e;
- int bit_count_start = get_bits_count(gb_host);
- int header;
- int bits_consumed;
- GetBitContext gbc = *gb_host, *gb = &gbc;
-
- header = get_bits1(gb);
- if (header) { //enable_ps_header
- ps->enable_iid = get_bits1(gb);
- if (ps->enable_iid) {
- int iid_mode = get_bits(gb, 3);
- if (iid_mode > 5) {
- av_log(avctx, AV_LOG_ERROR, "iid_mode %d is reserved.\n",
- iid_mode);
- goto err;
- }
- ps->nr_iid_par = nr_iidicc_par_tab[iid_mode];
- ps->iid_quant = iid_mode > 2;
- ps->nr_ipdopd_par = nr_iidopd_par_tab[iid_mode];
- }
- ps->enable_icc = get_bits1(gb);
- if (ps->enable_icc) {
- ps->icc_mode = get_bits(gb, 3);
- if (ps->icc_mode > 5) {
- av_log(avctx, AV_LOG_ERROR, "icc_mode %d is reserved.\n",
- ps->icc_mode);
- goto err;
- }
- ps->nr_icc_par = nr_iidicc_par_tab[ps->icc_mode];
- }
- ps->enable_ext = get_bits1(gb);
- }
-
- ps->frame_class = get_bits1(gb);
- ps->num_env_old = ps->num_env;
- ps->num_env = num_env_tab[ps->frame_class][get_bits(gb, 2)];
-
- ps->border_position[0] = -1;
- if (ps->frame_class) {
- for (e = 1; e <= ps->num_env; e++)
- ps->border_position[e] = get_bits(gb, 5);
- } else
- for (e = 1; e <= ps->num_env; e++)
- ps->border_position[e] = (e * numQMFSlots >> ff_log2_tab[ps->num_env]) - 1;
-
- if (ps->enable_iid) {
- for (e = 0; e < ps->num_env; e++) {
- int dt = get_bits1(gb);
- if (read_iid_data(avctx, gb, ps, ps->iid_par, huff_iid[2*dt+ps->iid_quant], e, dt))
- goto err;
- }
- } else
- memset(ps->iid_par, 0, sizeof(ps->iid_par));
-
- if (ps->enable_icc)
- for (e = 0; e < ps->num_env; e++) {
- int dt = get_bits1(gb);
- if (read_icc_data(avctx, gb, ps, ps->icc_par, dt ? huff_icc_dt : huff_icc_df, e, dt))
- goto err;
- }
- else
- memset(ps->icc_par, 0, sizeof(ps->icc_par));
-
- if (ps->enable_ext) {
- int cnt = get_bits(gb, 4);
- if (cnt == 15) {
- cnt += get_bits(gb, 8);
- }
- cnt *= 8;
- while (cnt > 7) {
- int ps_extension_id = get_bits(gb, 2);
- cnt -= 2 + ps_read_extension_data(gb, ps, ps_extension_id);
- }
- if (cnt < 0) {
- av_log(avctx, AV_LOG_ERROR, "ps extension overflow %d\n", cnt);
- goto err;
- }
- skip_bits(gb, cnt);
- }
-
- ps->enable_ipdopd &= !PS_BASELINE;
-
- //Fix up envelopes
- if (!ps->num_env || ps->border_position[ps->num_env] < numQMFSlots - 1) {
- //Create a fake envelope
- int source = ps->num_env ? ps->num_env - 1 : ps->num_env_old - 1;
- int b;
- if (source >= 0 && source != ps->num_env) {
- if (ps->enable_iid) {
- memcpy(ps->iid_par+ps->num_env, ps->iid_par+source, sizeof(ps->iid_par[0]));
- }
- if (ps->enable_icc) {
- memcpy(ps->icc_par+ps->num_env, ps->icc_par+source, sizeof(ps->icc_par[0]));
- }
- if (ps->enable_ipdopd) {
- memcpy(ps->ipd_par+ps->num_env, ps->ipd_par+source, sizeof(ps->ipd_par[0]));
- memcpy(ps->opd_par+ps->num_env, ps->opd_par+source, sizeof(ps->opd_par[0]));
- }
- }
- if (ps->enable_iid){
- for (b = 0; b < ps->nr_iid_par; b++) {
- if (FFABS(ps->iid_par[ps->num_env][b]) > 7 + 8 * ps->iid_quant) {
- av_log(avctx, AV_LOG_ERROR, "iid_par invalid\n");
- goto err;
- }
- }
- }
- if (ps->enable_icc){
- for (b = 0; b < ps->nr_iid_par; b++) {
- if (ps->icc_par[ps->num_env][b] > 7U) {
- av_log(avctx, AV_LOG_ERROR, "icc_par invalid\n");
- goto err;
- }
- }
- }
- ps->num_env++;
- ps->border_position[ps->num_env] = numQMFSlots - 1;
- }
-
-
- ps->is34bands_old = ps->is34bands;
- if (!PS_BASELINE && (ps->enable_iid || ps->enable_icc))
- ps->is34bands = (ps->enable_iid && ps->nr_iid_par == 34) ||
- (ps->enable_icc && ps->nr_icc_par == 34);
-
- //Baseline
- if (!ps->enable_ipdopd) {
- memset(ps->ipd_par, 0, sizeof(ps->ipd_par));
- memset(ps->opd_par, 0, sizeof(ps->opd_par));
- }
-
- if (header)
- ps->start = 1;
-
- bits_consumed = get_bits_count(gb) - bit_count_start;
- if (bits_consumed <= bits_left) {
- skip_bits_long(gb_host, bits_consumed);
- return bits_consumed;
- }
- av_log(avctx, AV_LOG_ERROR, "Expected to read %d PS bits actually read %d.\n", bits_left, bits_consumed);
-err:
- ps->start = 0;
- skip_bits_long(gb_host, bits_left);
- memset(ps->iid_par, 0, sizeof(ps->iid_par));
- memset(ps->icc_par, 0, sizeof(ps->icc_par));
- memset(ps->ipd_par, 0, sizeof(ps->ipd_par));
- memset(ps->opd_par, 0, sizeof(ps->opd_par));
- return bits_left;
-}
-
-/** Split one subband into 2 subsubbands with a symmetric real filter.
- * The filter must have its non-center even coefficients equal to zero. */
-static void hybrid2_re(float (*in)[2], float (*out)[32][2], const float filter[8], int len, int reverse)
-{
- int i, j;
- for (i = 0; i < len; i++, in++) {
- float re_in = filter[6] * in[6][0]; //real inphase
- float re_op = 0.0f; //real out of phase
- float im_in = filter[6] * in[6][1]; //imag inphase
- float im_op = 0.0f; //imag out of phase
- for (j = 0; j < 6; j += 2) {
- re_op += filter[j+1] * (in[j+1][0] + in[12-j-1][0]);
- im_op += filter[j+1] * (in[j+1][1] + in[12-j-1][1]);
- }
- out[ reverse][i][0] = re_in + re_op;
- out[ reverse][i][1] = im_in + im_op;
- out[!reverse][i][0] = re_in - re_op;
- out[!reverse][i][1] = im_in - im_op;
- }
-}
-
-/** Split one subband into 6 subsubbands with a complex filter */
-static void hybrid6_cx(PSDSPContext *dsp, float (*in)[2], float (*out)[32][2], const float (*filter)[8][2], int len)
-{
- int i;
- int N = 8;
- LOCAL_ALIGNED_16(float, temp, [8], [2]);
-
- for (i = 0; i < len; i++, in++) {
- dsp->hybrid_analysis(temp, in, filter, 1, N);
- out[0][i][0] = temp[6][0];
- out[0][i][1] = temp[6][1];
- out[1][i][0] = temp[7][0];
- out[1][i][1] = temp[7][1];
- out[2][i][0] = temp[0][0];
- out[2][i][1] = temp[0][1];
- out[3][i][0] = temp[1][0];
- out[3][i][1] = temp[1][1];
- out[4][i][0] = temp[2][0] + temp[5][0];
- out[4][i][1] = temp[2][1] + temp[5][1];
- out[5][i][0] = temp[3][0] + temp[4][0];
- out[5][i][1] = temp[3][1] + temp[4][1];
- }
-}
-
-static void hybrid4_8_12_cx(PSDSPContext *dsp, float (*in)[2], float (*out)[32][2], const float (*filter)[8][2], int N, int len)
-{
- int i;
-
- for (i = 0; i < len; i++, in++) {
- dsp->hybrid_analysis(out[0] + i, in, filter, 32, N);
- }
-}
-
-static void hybrid_analysis(PSDSPContext *dsp, float out[91][32][2],
- float in[5][44][2], float L[2][38][64],
- int is34, int len)
-{
- int i, j;
- for (i = 0; i < 5; i++) {
- for (j = 0; j < 38; j++) {
- in[i][j+6][0] = L[0][j][i];
- in[i][j+6][1] = L[1][j][i];
- }
- }
- if (is34) {
- hybrid4_8_12_cx(dsp, in[0], out, f34_0_12, 12, len);
- hybrid4_8_12_cx(dsp, in[1], out+12, f34_1_8, 8, len);
- hybrid4_8_12_cx(dsp, in[2], out+20, f34_2_4, 4, len);
- hybrid4_8_12_cx(dsp, in[3], out+24, f34_2_4, 4, len);
- hybrid4_8_12_cx(dsp, in[4], out+28, f34_2_4, 4, len);
- dsp->hybrid_analysis_ileave(out + 27, L, 5, len);
- } else {
- hybrid6_cx(dsp, in[0], out, f20_0_8, len);
- hybrid2_re(in[1], out+6, g1_Q2, len, 1);
- hybrid2_re(in[2], out+8, g1_Q2, len, 0);
- dsp->hybrid_analysis_ileave(out + 7, L, 3, len);
- }
- //update in_buf
- for (i = 0; i < 5; i++) {
- memcpy(in[i], in[i]+32, 6 * sizeof(in[i][0]));
- }
-}
-
-static void hybrid_synthesis(PSDSPContext *dsp, float out[2][38][64],
- float in[91][32][2], int is34, int len)
-{
- int i, n;
- if (is34) {
- for (n = 0; n < len; n++) {
- memset(out[0][n], 0, 5*sizeof(out[0][n][0]));
- memset(out[1][n], 0, 5*sizeof(out[1][n][0]));
- for (i = 0; i < 12; i++) {
- out[0][n][0] += in[ i][n][0];
- out[1][n][0] += in[ i][n][1];
- }
- for (i = 0; i < 8; i++) {
- out[0][n][1] += in[12+i][n][0];
- out[1][n][1] += in[12+i][n][1];
- }
- for (i = 0; i < 4; i++) {
- out[0][n][2] += in[20+i][n][0];
- out[1][n][2] += in[20+i][n][1];
- out[0][n][3] += in[24+i][n][0];
- out[1][n][3] += in[24+i][n][1];
- out[0][n][4] += in[28+i][n][0];
- out[1][n][4] += in[28+i][n][1];
- }
- }
- dsp->hybrid_synthesis_deint(out, in + 27, 5, len);
- } else {
- for (n = 0; n < len; n++) {
- out[0][n][0] = in[0][n][0] + in[1][n][0] + in[2][n][0] +
- in[3][n][0] + in[4][n][0] + in[5][n][0];
- out[1][n][0] = in[0][n][1] + in[1][n][1] + in[2][n][1] +
- in[3][n][1] + in[4][n][1] + in[5][n][1];
- out[0][n][1] = in[6][n][0] + in[7][n][0];
- out[1][n][1] = in[6][n][1] + in[7][n][1];
- out[0][n][2] = in[8][n][0] + in[9][n][0];
- out[1][n][2] = in[8][n][1] + in[9][n][1];
- }
- dsp->hybrid_synthesis_deint(out, in + 7, 3, len);
- }
-}
-
-/// All-pass filter decay slope
-#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 };
-/// 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
-static const int DECAY_CUTOFF[] = { 10, 32 };
-/// Number of all-pass filer bands
-static const int NR_ALLPASS_BANDS[] = { 30, 50 };
-/// First stereo band using the short one sample delay
-static const int SHORT_DELAY_BAND[] = { 42, 62 };
-
-/** Table 8.46 */
-static void map_idx_10_to_20(int8_t *par_mapped, const int8_t *par, int full)
-{
- int b;
- if (full)
- b = 9;
- else {
- b = 4;
- par_mapped[10] = 0;
- }
- for (; b >= 0; b--) {
- par_mapped[2*b+1] = par_mapped[2*b] = par[b];
- }
-}
-
-static void map_idx_34_to_20(int8_t *par_mapped, const int8_t *par, int full)
-{
- par_mapped[ 0] = (2*par[ 0] + par[ 1]) / 3;
- par_mapped[ 1] = ( par[ 1] + 2*par[ 2]) / 3;
- par_mapped[ 2] = (2*par[ 3] + par[ 4]) / 3;
- par_mapped[ 3] = ( par[ 4] + 2*par[ 5]) / 3;
- par_mapped[ 4] = ( par[ 6] + par[ 7]) / 2;
- par_mapped[ 5] = ( par[ 8] + par[ 9]) / 2;
- par_mapped[ 6] = par[10];
- par_mapped[ 7] = par[11];
- par_mapped[ 8] = ( par[12] + par[13]) / 2;
- par_mapped[ 9] = ( par[14] + par[15]) / 2;
- par_mapped[10] = par[16];
- if (full) {
- par_mapped[11] = par[17];
- par_mapped[12] = par[18];
- par_mapped[13] = par[19];
- par_mapped[14] = ( par[20] + par[21]) / 2;
- par_mapped[15] = ( par[22] + par[23]) / 2;
- par_mapped[16] = ( par[24] + par[25]) / 2;
- par_mapped[17] = ( par[26] + par[27]) / 2;
- par_mapped[18] = ( par[28] + par[29] + par[30] + par[31]) / 4;
- par_mapped[19] = ( par[32] + par[33]) / 2;
- }
-}
-
-static void map_val_34_to_20(float par[PS_MAX_NR_IIDICC])
-{
- par[ 0] = (2*par[ 0] + par[ 1]) * 0.33333333f;
- par[ 1] = ( par[ 1] + 2*par[ 2]) * 0.33333333f;
- par[ 2] = (2*par[ 3] + par[ 4]) * 0.33333333f;
- par[ 3] = ( par[ 4] + 2*par[ 5]) * 0.33333333f;
- par[ 4] = ( par[ 6] + par[ 7]) * 0.5f;
- par[ 5] = ( par[ 8] + par[ 9]) * 0.5f;
- par[ 6] = par[10];
- par[ 7] = par[11];
- par[ 8] = ( par[12] + par[13]) * 0.5f;
- par[ 9] = ( par[14] + par[15]) * 0.5f;
- par[10] = par[16];
- par[11] = par[17];
- par[12] = par[18];
- par[13] = par[19];
- par[14] = ( par[20] + par[21]) * 0.5f;
- par[15] = ( par[22] + par[23]) * 0.5f;
- par[16] = ( par[24] + par[25]) * 0.5f;
- par[17] = ( par[26] + par[27]) * 0.5f;
- par[18] = ( par[28] + par[29] + par[30] + par[31]) * 0.25f;
- par[19] = ( par[32] + par[33]) * 0.5f;
-}
-
-static void map_idx_10_to_34(int8_t *par_mapped, const int8_t *par, int full)
-{
- if (full) {
- par_mapped[33] = par[9];
- par_mapped[32] = par[9];
- par_mapped[31] = par[9];
- par_mapped[30] = par[9];
- par_mapped[29] = par[9];
- par_mapped[28] = par[9];
- par_mapped[27] = par[8];
- par_mapped[26] = par[8];
- par_mapped[25] = par[8];
- par_mapped[24] = par[8];
- par_mapped[23] = par[7];
- par_mapped[22] = par[7];
- par_mapped[21] = par[7];
- par_mapped[20] = par[7];
- par_mapped[19] = par[6];
- par_mapped[18] = par[6];
- par_mapped[17] = par[5];
- par_mapped[16] = par[5];
- } else {
- par_mapped[16] = 0;
- }
- par_mapped[15] = par[4];
- par_mapped[14] = par[4];
- par_mapped[13] = par[4];
- par_mapped[12] = par[4];
- par_mapped[11] = par[3];
- par_mapped[10] = par[3];
- par_mapped[ 9] = par[2];
- par_mapped[ 8] = par[2];
- par_mapped[ 7] = par[2];
- par_mapped[ 6] = par[2];
- par_mapped[ 5] = par[1];
- par_mapped[ 4] = par[1];
- par_mapped[ 3] = par[1];
- par_mapped[ 2] = par[0];
- par_mapped[ 1] = par[0];
- par_mapped[ 0] = par[0];
-}
-
-static void map_idx_20_to_34(int8_t *par_mapped, const int8_t *par, int full)
-{
- if (full) {
- par_mapped[33] = par[19];
- par_mapped[32] = par[19];
- par_mapped[31] = par[18];
- par_mapped[30] = par[18];
- par_mapped[29] = par[18];
- par_mapped[28] = par[18];
- par_mapped[27] = par[17];
- par_mapped[26] = par[17];
- par_mapped[25] = par[16];
- par_mapped[24] = par[16];
- par_mapped[23] = par[15];
- par_mapped[22] = par[15];
- par_mapped[21] = par[14];
- par_mapped[20] = par[14];
- par_mapped[19] = par[13];
- par_mapped[18] = par[12];
- par_mapped[17] = par[11];
- }
- par_mapped[16] = par[10];
- par_mapped[15] = par[ 9];
- par_mapped[14] = par[ 9];
- par_mapped[13] = par[ 8];
- par_mapped[12] = par[ 8];
- par_mapped[11] = par[ 7];
- par_mapped[10] = par[ 6];
- par_mapped[ 9] = par[ 5];
- par_mapped[ 8] = par[ 5];
- par_mapped[ 7] = par[ 4];
- par_mapped[ 6] = par[ 4];
- par_mapped[ 5] = par[ 3];
- par_mapped[ 4] = (par[ 2] + par[ 3]) / 2;
- par_mapped[ 3] = par[ 2];
- par_mapped[ 2] = par[ 1];
- par_mapped[ 1] = (par[ 0] + par[ 1]) / 2;
- par_mapped[ 0] = par[ 0];
-}
-
-static void map_val_20_to_34(float par[PS_MAX_NR_IIDICC])
-{
- par[33] = par[19];
- par[32] = par[19];
- par[31] = par[18];
- par[30] = par[18];
- par[29] = par[18];
- par[28] = par[18];
- par[27] = par[17];
- par[26] = par[17];
- par[25] = par[16];
- par[24] = par[16];
- par[23] = par[15];
- par[22] = par[15];
- par[21] = par[14];
- par[20] = par[14];
- par[19] = par[13];
- par[18] = par[12];
- par[17] = par[11];
- par[16] = par[10];
- par[15] = par[ 9];
- par[14] = par[ 9];
- par[13] = par[ 8];
- par[12] = par[ 8];
- par[11] = par[ 7];
- par[10] = par[ 6];
- par[ 9] = par[ 5];
- par[ 8] = par[ 5];
- par[ 7] = par[ 4];
- par[ 6] = par[ 4];
- par[ 5] = par[ 3];
- par[ 4] = (par[ 2] + par[ 3]) * 0.5f;
- par[ 3] = par[ 2];
- par[ 2] = par[ 1];
- par[ 1] = (par[ 0] + par[ 1]) * 0.5f;
-}
-
-static void decorrelation(PSContext *ps, float (*out)[32][2], const float (*s)[32][2], int is34)
-{
- LOCAL_ALIGNED_16(float, power, [34], [PS_QMF_TIME_SLOTS]);
- LOCAL_ALIGNED_16(float, transient_gain, [34], [PS_QMF_TIME_SLOTS]);
- float *peak_decay_nrg = ps->peak_decay_nrg;
- float *power_smooth = ps->power_smooth;
- float *peak_decay_diff_smooth = ps->peak_decay_diff_smooth;
- float (*delay)[PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2] = ps->delay;
- float (*ap_delay)[PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2] = ps->ap_delay;
- const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20;
- const float peak_decay_factor = 0.76592833836465f;
- const float transient_impact = 1.5f;
- const float a_smooth = 0.25f; ///< Smoothing coefficient
- int i, k, m, n;
- int n0 = 0, nL = 32;
-
- memset(power, 0, 34 * sizeof(*power));
-
- if (is34 != ps->is34bands_old) {
- memset(ps->peak_decay_nrg, 0, sizeof(ps->peak_decay_nrg));
- memset(ps->power_smooth, 0, sizeof(ps->power_smooth));
- memset(ps->peak_decay_diff_smooth, 0, sizeof(ps->peak_decay_diff_smooth));
- memset(ps->delay, 0, sizeof(ps->delay));
- memset(ps->ap_delay, 0, sizeof(ps->ap_delay));
- }
-
- for (k = 0; k < NR_BANDS[is34]; k++) {
- int i = k_to_i[k];
- ps->dsp.add_squares(power[i], s[k], nL - n0);
- }
-
- //Transient detection
- for (i = 0; i < NR_PAR_BANDS[is34]; i++) {
- for (n = n0; n < nL; n++) {
- float decayed_peak = peak_decay_factor * peak_decay_nrg[i];
- float denom;
- peak_decay_nrg[i] = FFMAX(decayed_peak, power[i][n]);
- power_smooth[i] += a_smooth * (power[i][n] - power_smooth[i]);
- peak_decay_diff_smooth[i] += a_smooth * (peak_decay_nrg[i] - power[i][n] - peak_decay_diff_smooth[i]);
- denom = transient_impact * peak_decay_diff_smooth[i];
- transient_gain[i][n] = (denom > power_smooth[i]) ?
- power_smooth[i] / denom : 1.0f;
- }
- }
-
- //Decorrelation and transient reduction
- // PS_AP_LINKS - 1
- // -----
- // | | Q_fract_allpass[k][m]*z^-link_delay[m] - a[m]*g_decay_slope[k]
- //H[k][z] = z^-2 * phi_fract[k] * | | ----------------------------------------------------------------
- // | | 1 - a[m]*g_decay_slope[k]*Q_fract_allpass[k][m]*z^-link_delay[m]
- // m = 0
- //d[k][z] (out) = transient_gain_mapped[k][z] * H[k][z] * s[k][z]
- for (k = 0; k < NR_ALLPASS_BANDS[is34]; k++) {
- int b = k_to_i[k];
- float g_decay_slope = 1.f - DECAY_SLOPE * (k - DECAY_CUTOFF[is34]);
- g_decay_slope = av_clipf(g_decay_slope, 0.f, 1.f);
- memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0]));
- memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0]));
- for (m = 0; m < PS_AP_LINKS; m++) {
- memcpy(ap_delay[k][m], ap_delay[k][m]+numQMFSlots, 5*sizeof(ap_delay[k][m][0]));
- }
- ps->dsp.decorrelate(out[k], delay[k] + PS_MAX_DELAY - 2, ap_delay[k],
- phi_fract[is34][k], Q_fract_allpass[is34][k],
- transient_gain[b], g_decay_slope, nL - n0);
- }
- for (; k < SHORT_DELAY_BAND[is34]; k++) {
- int i = k_to_i[k];
- memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0]));
- memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0]));
- //H = delay 14
- ps->dsp.mul_pair_single(out[k], delay[k] + PS_MAX_DELAY - 14,
- transient_gain[i], nL - n0);
- }
- for (; k < NR_BANDS[is34]; k++) {
- int i = k_to_i[k];
- memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0]));
- memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0]));
- //H = delay 1
- ps->dsp.mul_pair_single(out[k], delay[k] + PS_MAX_DELAY - 1,
- transient_gain[i], nL - n0);
- }
-}
-
-static void remap34(int8_t (**p_par_mapped)[PS_MAX_NR_IIDICC],
- int8_t (*par)[PS_MAX_NR_IIDICC],
- int num_par, int num_env, int full)
-{
- int8_t (*par_mapped)[PS_MAX_NR_IIDICC] = *p_par_mapped;
- int e;
- if (num_par == 20 || num_par == 11) {
- for (e = 0; e < num_env; e++) {
- map_idx_20_to_34(par_mapped[e], par[e], full);
- }
- } else if (num_par == 10 || num_par == 5) {
- for (e = 0; e < num_env; e++) {
- map_idx_10_to_34(par_mapped[e], par[e], full);
- }
- } else {
- *p_par_mapped = par;
- }
-}
-
-static void remap20(int8_t (**p_par_mapped)[PS_MAX_NR_IIDICC],
- int8_t (*par)[PS_MAX_NR_IIDICC],
- int num_par, int num_env, int full)
-{
- int8_t (*par_mapped)[PS_MAX_NR_IIDICC] = *p_par_mapped;
- int e;
- if (num_par == 34 || num_par == 17) {
- for (e = 0; e < num_env; e++) {
- map_idx_34_to_20(par_mapped[e], par[e], full);
- }
- } else if (num_par == 10 || num_par == 5) {
- for (e = 0; e < num_env; e++) {
- map_idx_10_to_20(par_mapped[e], par[e], full);
- }
- } else {
- *p_par_mapped = par;
- }
-}
-
-static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2], int is34)
-{
- int e, b, k;
-
- float (*H11)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H11;
- float (*H12)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H12;
- float (*H21)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H21;
- float (*H22)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H22;
- int8_t *opd_hist = ps->opd_hist;
- int8_t *ipd_hist = ps->ipd_hist;
- int8_t iid_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
- int8_t icc_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
- int8_t ipd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
- int8_t opd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
- int8_t (*iid_mapped)[PS_MAX_NR_IIDICC] = iid_mapped_buf;
- int8_t (*icc_mapped)[PS_MAX_NR_IIDICC] = icc_mapped_buf;
- int8_t (*ipd_mapped)[PS_MAX_NR_IIDICC] = ipd_mapped_buf;
- int8_t (*opd_mapped)[PS_MAX_NR_IIDICC] = opd_mapped_buf;
- const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20;
- const float (*H_LUT)[8][4] = (PS_BASELINE || ps->icc_mode < 3) ? HA : HB;
-
- //Remapping
- if (ps->num_env_old) {
- memcpy(H11[0][0], H11[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[0][0][0]));
- memcpy(H11[1][0], H11[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[1][0][0]));
- memcpy(H12[0][0], H12[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[0][0][0]));
- memcpy(H12[1][0], H12[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[1][0][0]));
- memcpy(H21[0][0], H21[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[0][0][0]));
- memcpy(H21[1][0], H21[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[1][0][0]));
- memcpy(H22[0][0], H22[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[0][0][0]));
- memcpy(H22[1][0], H22[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[1][0][0]));
- }
-
- if (is34) {
- remap34(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1);
- remap34(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1);
- if (ps->enable_ipdopd) {
- remap34(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0);
- remap34(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0);
- }
- if (!ps->is34bands_old) {
- map_val_20_to_34(H11[0][0]);
- map_val_20_to_34(H11[1][0]);
- map_val_20_to_34(H12[0][0]);
- map_val_20_to_34(H12[1][0]);
- map_val_20_to_34(H21[0][0]);
- map_val_20_to_34(H21[1][0]);
- map_val_20_to_34(H22[0][0]);
- map_val_20_to_34(H22[1][0]);
- ipdopd_reset(ipd_hist, opd_hist);
- }
- } else {
- remap20(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1);
- remap20(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1);
- if (ps->enable_ipdopd) {
- remap20(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0);
- remap20(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0);
- }
- if (ps->is34bands_old) {
- map_val_34_to_20(H11[0][0]);
- map_val_34_to_20(H11[1][0]);
- map_val_34_to_20(H12[0][0]);
- map_val_34_to_20(H12[1][0]);
- map_val_34_to_20(H21[0][0]);
- map_val_34_to_20(H21[1][0]);
- map_val_34_to_20(H22[0][0]);
- map_val_34_to_20(H22[1][0]);
- ipdopd_reset(ipd_hist, opd_hist);
- }
- }
-
- //Mixing
- for (e = 0; e < ps->num_env; e++) {
- for (b = 0; b < NR_PAR_BANDS[is34]; b++) {
- float h11, h12, h21, h22;
- h11 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][0];
- h12 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][1];
- 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 && b < ps->nr_ipdopd_par) {
- //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;
- float ipd_adj_re, ipd_adj_im;
- int opd_idx = opd_hist[b] * 8 + opd_mapped[e][b];
- int ipd_idx = ipd_hist[b] * 8 + ipd_mapped[e][b];
- float opd_re = pd_re_smooth[opd_idx];
- float opd_im = pd_im_smooth[opd_idx];
- float ipd_re = pd_re_smooth[ipd_idx];
- float ipd_im = pd_im_smooth[ipd_idx];
- opd_hist[b] = opd_idx & 0x3F;
- ipd_hist[b] = ipd_idx & 0x3F;
-
- ipd_adj_re = opd_re*ipd_re + opd_im*ipd_im;
- ipd_adj_im = opd_im*ipd_re - opd_re*ipd_im;
- h11i = h11 * opd_im;
- h11 = h11 * opd_re;
- h12i = h12 * ipd_adj_im;
- h12 = h12 * ipd_adj_re;
- h21i = h21 * opd_im;
- h21 = h21 * opd_re;
- h22i = h22 * ipd_adj_im;
- h22 = h22 * ipd_adj_re;
- H11[1][e+1][b] = h11i;
- H12[1][e+1][b] = h12i;
- H21[1][e+1][b] = h21i;
- H22[1][e+1][b] = h22i;
- }
- H11[0][e+1][b] = h11;
- H12[0][e+1][b] = h12;
- H21[0][e+1][b] = h21;
- H22[0][e+1][b] = h22;
- }
- for (k = 0; k < NR_BANDS[is34]; k++) {
- float h[2][4];
- float h_step[2][4];
- int start = ps->border_position[e];
- int stop = ps->border_position[e+1];
- float width = 1.f / (stop - start);
- b = k_to_i[k];
- h[0][0] = H11[0][e][b];
- h[0][1] = H12[0][e][b];
- h[0][2] = H21[0][e][b];
- h[0][3] = H22[0][e][b];
- if (!PS_BASELINE && ps->enable_ipdopd) {
- //Is this necessary? ps_04_new seems unchanged
- if ((is34 && k <= 13 && k >= 9) || (!is34 && k <= 1)) {
- h[1][0] = -H11[1][e][b];
- h[1][1] = -H12[1][e][b];
- h[1][2] = -H21[1][e][b];
- h[1][3] = -H22[1][e][b];
- } else {
- h[1][0] = H11[1][e][b];
- h[1][1] = H12[1][e][b];
- h[1][2] = H21[1][e][b];
- h[1][3] = H22[1][e][b];
- }
- }
- //Interpolation
- h_step[0][0] = (H11[0][e+1][b] - h[0][0]) * width;
- h_step[0][1] = (H12[0][e+1][b] - h[0][1]) * width;
- h_step[0][2] = (H21[0][e+1][b] - h[0][2]) * width;
- h_step[0][3] = (H22[0][e+1][b] - h[0][3]) * width;
- if (!PS_BASELINE && ps->enable_ipdopd) {
- h_step[1][0] = (H11[1][e+1][b] - h[1][0]) * width;
- h_step[1][1] = (H12[1][e+1][b] - h[1][1]) * width;
- h_step[1][2] = (H21[1][e+1][b] - h[1][2]) * width;
- h_step[1][3] = (H22[1][e+1][b] - h[1][3]) * width;
- }
- ps->dsp.stereo_interpolate[!PS_BASELINE && ps->enable_ipdopd](
- l[k] + start + 1, r[k] + start + 1,
- h, h_step, stop - start);
- }
- }
-}
-
-int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float R[2][38][64], int top)
-{
- LOCAL_ALIGNED_16(float, Lbuf, [91], [32][2]);
- LOCAL_ALIGNED_16(float, Rbuf, [91], [32][2]);
- const int len = 32;
- int is34 = ps->is34bands;
-
- top += NR_BANDS[is34] - 64;
- memset(ps->delay+top, 0, (NR_BANDS[is34] - top)*sizeof(ps->delay[0]));
- if (top < NR_ALLPASS_BANDS[is34])
- memset(ps->ap_delay + top, 0, (NR_ALLPASS_BANDS[is34] - top)*sizeof(ps->ap_delay[0]));
-
- hybrid_analysis(&ps->dsp, Lbuf, ps->in_buf, L, is34, len);
- decorrelation(ps, Rbuf, Lbuf, is34);
- stereo_processing(ps, Lbuf, Rbuf, is34);
- hybrid_synthesis(&ps->dsp, L, Lbuf, is34, len);
- hybrid_synthesis(&ps->dsp, R, Rbuf, is34, len);
-
- return 0;
-}
-
-#define PS_INIT_VLC_STATIC(num, size) \
- INIT_VLC_STATIC(&vlc_ps[num], 9, ps_tmp[num].table_size / ps_tmp[num].elem_size, \
- ps_tmp[num].ps_bits, 1, 1, \
- ps_tmp[num].ps_codes, ps_tmp[num].elem_size, ps_tmp[num].elem_size, \
- size);
-
-#define PS_VLC_ROW(name) \
- { name ## _codes, name ## _bits, sizeof(name ## _codes), sizeof(name ## _codes[0]) }
-
-av_cold void ff_ps_init(void) {
- // Syntax initialization
- static const struct {
- const void *ps_codes, *ps_bits;
- const unsigned int table_size, elem_size;
- } ps_tmp[] = {
- PS_VLC_ROW(huff_iid_df1),
- PS_VLC_ROW(huff_iid_dt1),
- PS_VLC_ROW(huff_iid_df0),
- PS_VLC_ROW(huff_iid_dt0),
- PS_VLC_ROW(huff_icc_df),
- PS_VLC_ROW(huff_icc_dt),
- PS_VLC_ROW(huff_ipd_df),
- PS_VLC_ROW(huff_ipd_dt),
- PS_VLC_ROW(huff_opd_df),
- PS_VLC_ROW(huff_opd_dt),
- };
-
- PS_INIT_VLC_STATIC(0, 1544);
- PS_INIT_VLC_STATIC(1, 832);
- PS_INIT_VLC_STATIC(2, 1024);
- PS_INIT_VLC_STATIC(3, 1036);
- PS_INIT_VLC_STATIC(4, 544);
- PS_INIT_VLC_STATIC(5, 544);
- PS_INIT_VLC_STATIC(6, 512);
- PS_INIT_VLC_STATIC(7, 512);
- PS_INIT_VLC_STATIC(8, 512);
- PS_INIT_VLC_STATIC(9, 512);
-
- ps_tableinit();
-}
-
-av_cold void ff_ps_ctx_init(PSContext *ps)
-{
- ff_psdsp_init(&ps->dsp);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/aacps.h b/src/thirdparty/ffmpeg/libavcodec/aacps.h
deleted file mode 100644
index 1aaaec3f0..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/aacps.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * MPEG-4 Parametric Stereo definitions and declarations
- * Copyright (c) 2010 Alex Converse <alex.converse@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_PS_H
-#define AVCODEC_PS_H
-
-#include <stdint.h>
-
-#include "aacpsdsp.h"
-#include "avcodec.h"
-#include "get_bits.h"
-
-#define PS_MAX_NUM_ENV 5
-#define PS_MAX_NR_IIDICC 34
-#define PS_MAX_NR_IPDOPD 17
-#define PS_MAX_SSB 91
-#define PS_MAX_AP_BANDS 50
-#define PS_QMF_TIME_SLOTS 32
-#define PS_MAX_DELAY 14
-#define PS_AP_LINKS 3
-#define PS_MAX_AP_DELAY 5
-
-typedef struct PSContext {
- int start;
- int enable_iid;
- int iid_quant;
- int nr_iid_par;
- int nr_ipdopd_par;
- int enable_icc;
- int icc_mode;
- int nr_icc_par;
- int enable_ext;
- int frame_class;
- int num_env_old;
- int num_env;
- int enable_ipdopd;
- int border_position[PS_MAX_NUM_ENV+1];
- int8_t iid_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; ///< Inter-channel Intensity Difference Parameters
- int8_t icc_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; ///< Inter-Channel Coherence Parameters
- /* ipd/opd is iid/icc sized so that the same functions can handle both */
- int8_t ipd_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; ///< Inter-channel Phase Difference Parameters
- int8_t opd_par[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; ///< Overall Phase Difference Parameters
- int is34bands;
- int is34bands_old;
-
- DECLARE_ALIGNED(16, float, in_buf)[5][44][2];
- DECLARE_ALIGNED(16, float, delay)[PS_MAX_SSB][PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2];
- DECLARE_ALIGNED(16, float, ap_delay)[PS_MAX_AP_BANDS][PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2];
- DECLARE_ALIGNED(16, float, peak_decay_nrg)[34];
- DECLARE_ALIGNED(16, float, power_smooth)[34];
- DECLARE_ALIGNED(16, float, peak_decay_diff_smooth)[34];
- DECLARE_ALIGNED(16, float, H11)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC];
- DECLARE_ALIGNED(16, float, H12)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC];
- DECLARE_ALIGNED(16, float, H21)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC];
- DECLARE_ALIGNED(16, float, H22)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC];
- int8_t opd_hist[PS_MAX_NR_IIDICC];
- int8_t ipd_hist[PS_MAX_NR_IIDICC];
- PSDSPContext dsp;
-} PSContext;
-
-void ff_ps_init(void);
-void ff_ps_ctx_init(PSContext *ps);
-int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, int bits_left);
-int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float R[2][38][64], int top);
-
-#endif /* AVCODEC_PS_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/aacps_tablegen.h b/src/thirdparty/ffmpeg/libavcodec/aacps_tablegen.h
deleted file mode 100644
index ba7eaf964..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/aacps_tablegen.h
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Header file for hardcoded Parametric Stereo tables
- *
- * Copyright (c) 2010 Alex Converse <alex.converse@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 AACPS_TABLEGEN_H
-#define AACPS_TABLEGEN_H
-
-#include <math.h>
-#include <stdint.h>
-
-#if CONFIG_HARDCODED_TABLES
-#define ps_tableinit()
-#include "libavcodec/aacps_tables.h"
-#else
-#include "libavutil/common.h"
-#include "libavutil/libm.h"
-#include "libavutil/mathematics.h"
-#include "libavutil/mem.h"
-#define NR_ALLPASS_BANDS20 30
-#define NR_ALLPASS_BANDS34 50
-#define PS_AP_LINKS 3
-static float pd_re_smooth[8*8*8];
-static float pd_im_smooth[8*8*8];
-static float HA[46][8][4];
-static float HB[46][8][4];
-static DECLARE_ALIGNED(16, float, f20_0_8) [ 8][8][2];
-static DECLARE_ALIGNED(16, float, f34_0_12)[12][8][2];
-static DECLARE_ALIGNED(16, float, f34_1_8) [ 8][8][2];
-static DECLARE_ALIGNED(16, float, f34_2_4) [ 4][8][2];
-static DECLARE_ALIGNED(16, float, Q_fract_allpass)[2][50][3][2];
-static DECLARE_ALIGNED(16, float, phi_fract)[2][50][2];
-
-static const float g0_Q8[] = {
- 0.00746082949812f, 0.02270420949825f, 0.04546865930473f, 0.07266113929591f,
- 0.09885108575264f, 0.11793710567217f, 0.125f
-};
-
-static const float g0_Q12[] = {
- 0.04081179924692f, 0.03812810994926f, 0.05144908135699f, 0.06399831151592f,
- 0.07428313801106f, 0.08100347892914f, 0.08333333333333f
-};
-
-static const float g1_Q8[] = {
- 0.01565675600122f, 0.03752716391991f, 0.05417891378782f, 0.08417044116767f,
- 0.10307344158036f, 0.12222452249753f, 0.125f
-};
-
-static const float g2_Q4[] = {
- -0.05908211155639f, -0.04871498374946f, 0.0f, 0.07778723915851f,
- 0.16486303567403f, 0.23279856662996f, 0.25f
-};
-
-static void make_filters_from_proto(float (*filter)[8][2], const float *proto, int bands)
-{
- int q, n;
- for (q = 0; q < bands; q++) {
- for (n = 0; n < 7; n++) {
- double theta = 2 * M_PI * (q + 0.5) * (n - 6) / bands;
- filter[q][n][0] = proto[n] * cos(theta);
- filter[q][n][1] = proto[n] * -sin(theta);
- }
- }
-}
-
-static void ps_tableinit(void)
-{
- static const float ipdopd_sin[] = { 0, M_SQRT1_2, 1, M_SQRT1_2, 0, -M_SQRT1_2, -1, -M_SQRT1_2 };
- static const float ipdopd_cos[] = { 1, M_SQRT1_2, 0, -M_SQRT1_2, -1, -M_SQRT1_2, 0, M_SQRT1_2 };
- int pd0, pd1, pd2;
-
- static const float iid_par_dequant[] = {
- //iid_par_dequant_default
- 0.05623413251903, 0.12589254117942, 0.19952623149689, 0.31622776601684,
- 0.44668359215096, 0.63095734448019, 0.79432823472428, 1,
- 1.25892541179417, 1.58489319246111, 2.23872113856834, 3.16227766016838,
- 5.01187233627272, 7.94328234724282, 17.7827941003892,
- //iid_par_dequant_fine
- 0.00316227766017, 0.00562341325190, 0.01, 0.01778279410039,
- 0.03162277660168, 0.05623413251903, 0.07943282347243, 0.11220184543020,
- 0.15848931924611, 0.22387211385683, 0.31622776601684, 0.39810717055350,
- 0.50118723362727, 0.63095734448019, 0.79432823472428, 1,
- 1.25892541179417, 1.58489319246111, 1.99526231496888, 2.51188643150958,
- 3.16227766016838, 4.46683592150963, 6.30957344480193, 8.91250938133745,
- 12.5892541179417, 17.7827941003892, 31.6227766016838, 56.2341325190349,
- 100, 177.827941003892, 316.227766016837,
- };
- static const float icc_invq[] = {
- 1, 0.937, 0.84118, 0.60092, 0.36764, 0, -0.589, -1
- };
- static const float acos_icc_invq[] = {
- 0, 0.35685527, 0.57133466, 0.92614472, 1.1943263, M_PI/2, 2.2006171, M_PI
- };
- int iid, icc;
-
- int k, m;
- static const int8_t f_center_20[] = {
- -3, -1, 1, 3, 5, 7, 10, 14, 18, 22,
- };
- static const int8_t f_center_34[] = {
- 2, 6, 10, 14, 18, 22, 26, 30,
- 34,-10, -6, -2, 51, 57, 15, 21,
- 27, 33, 39, 45, 54, 66, 78, 42,
- 102, 66, 78, 90,102,114,126, 90,
- };
- static const float fractional_delay_links[] = { 0.43f, 0.75f, 0.347f };
- const float fractional_delay_gain = 0.39f;
-
- for (pd0 = 0; pd0 < 8; pd0++) {
- float pd0_re = ipdopd_cos[pd0];
- float pd0_im = ipdopd_sin[pd0];
- for (pd1 = 0; pd1 < 8; pd1++) {
- float pd1_re = ipdopd_cos[pd1];
- float pd1_im = ipdopd_sin[pd1];
- for (pd2 = 0; pd2 < 8; pd2++) {
- float pd2_re = ipdopd_cos[pd2];
- float pd2_im = ipdopd_sin[pd2];
- float re_smooth = 0.25f * pd0_re + 0.5f * pd1_re + pd2_re;
- float im_smooth = 0.25f * pd0_im + 0.5f * pd1_im + pd2_im;
- float pd_mag = 1 / sqrt(im_smooth * im_smooth + re_smooth * re_smooth);
- pd_re_smooth[pd0*64+pd1*8+pd2] = re_smooth * pd_mag;
- pd_im_smooth[pd0*64+pd1*8+pd2] = im_smooth * pd_mag;
- }
- }
- }
-
- for (iid = 0; iid < 46; iid++) {
- float c = iid_par_dequant[iid]; ///< Linear Inter-channel Intensity Difference
- float c1 = (float)M_SQRT2 / sqrtf(1.0f + c*c);
- float c2 = c * c1;
- for (icc = 0; icc < 8; icc++) {
- /*if (PS_BASELINE || ps->icc_mode < 3)*/ {
- float alpha = 0.5f * acos_icc_invq[icc];
- float beta = alpha * (c1 - c2) * (float)M_SQRT1_2;
- HA[iid][icc][0] = c2 * cosf(beta + alpha);
- HA[iid][icc][1] = c1 * cosf(beta - alpha);
- HA[iid][icc][2] = c2 * sinf(beta + alpha);
- HA[iid][icc][3] = c1 * sinf(beta - alpha);
- } /* else */ {
- float alpha, gamma, mu, rho;
- float alpha_c, alpha_s, gamma_c, gamma_s;
- rho = FFMAX(icc_invq[icc], 0.05f);
- alpha = 0.5f * atan2f(2.0f * c * rho, c*c - 1.0f);
- mu = c + 1.0f / c;
- mu = sqrtf(1 + (4 * rho * rho - 4)/(mu * mu));
- gamma = atanf(sqrtf((1.0f - mu)/(1.0f + mu)));
- if (alpha < 0) alpha += M_PI/2;
- alpha_c = cosf(alpha);
- alpha_s = sinf(alpha);
- gamma_c = cosf(gamma);
- gamma_s = sinf(gamma);
- HB[iid][icc][0] = M_SQRT2 * alpha_c * gamma_c;
- HB[iid][icc][1] = M_SQRT2 * alpha_s * gamma_c;
- HB[iid][icc][2] = -M_SQRT2 * alpha_s * gamma_s;
- HB[iid][icc][3] = M_SQRT2 * alpha_c * gamma_s;
- }
- }
- }
-
- for (k = 0; k < NR_ALLPASS_BANDS20; k++) {
- double f_center, theta;
- if (k < FF_ARRAY_ELEMS(f_center_20))
- f_center = f_center_20[k] * 0.125;
- else
- f_center = k - 6.5f;
- for (m = 0; m < PS_AP_LINKS; m++) {
- theta = -M_PI * fractional_delay_links[m] * f_center;
- Q_fract_allpass[0][k][m][0] = cos(theta);
- Q_fract_allpass[0][k][m][1] = sin(theta);
- }
- theta = -M_PI*fractional_delay_gain*f_center;
- phi_fract[0][k][0] = cos(theta);
- phi_fract[0][k][1] = sin(theta);
- }
- for (k = 0; k < NR_ALLPASS_BANDS34; k++) {
- double f_center, theta;
- if (k < FF_ARRAY_ELEMS(f_center_34))
- f_center = f_center_34[k] / 24.;
- else
- f_center = k - 26.5f;
- for (m = 0; m < PS_AP_LINKS; m++) {
- theta = -M_PI * fractional_delay_links[m] * f_center;
- Q_fract_allpass[1][k][m][0] = cos(theta);
- Q_fract_allpass[1][k][m][1] = sin(theta);
- }
- theta = -M_PI*fractional_delay_gain*f_center;
- phi_fract[1][k][0] = cos(theta);
- phi_fract[1][k][1] = sin(theta);
- }
-
- make_filters_from_proto(f20_0_8, g0_Q8, 8);
- make_filters_from_proto(f34_0_12, g0_Q12, 12);
- make_filters_from_proto(f34_1_8, g1_Q8, 8);
- make_filters_from_proto(f34_2_4, g2_Q4, 4);
-}
-#endif /* CONFIG_HARDCODED_TABLES */
-
-#endif /* AACPS_TABLEGEN_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/aacpsdata.c b/src/thirdparty/ffmpeg/libavcodec/aacpsdata.c
deleted file mode 100644
index 238fd09ad..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/aacpsdata.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * MPEG-4 Parametric Stereo data tables
- * Copyright (c) 2010 Alex Converse <alex.converse@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
- */
-
-static const uint8_t huff_iid_df1_bits[] = {
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 17, 18, 17, 17, 16, 16, 15, 14, 14,
- 13, 12, 12, 11, 10, 10, 8, 7, 6, 5, 4, 3, 1, 3, 4, 5, 6, 7,
- 8, 9, 10, 11, 11, 12, 13, 14, 14, 15, 16, 16, 17, 17, 18, 17, 18, 18,
- 18, 18, 18, 18, 18, 18, 18,
-};
-
-static const uint32_t huff_iid_df1_codes[] = {
- 0x01FEB4, 0x01FEB5, 0x01FD76, 0x01FD77, 0x01FD74, 0x01FD75, 0x01FE8A,
- 0x01FE8B, 0x01FE88, 0x00FE80, 0x01FEB6, 0x00FE82, 0x00FEB8, 0x007F42,
- 0x007FAE, 0x003FAF, 0x001FD1, 0x001FE9, 0x000FE9, 0x0007EA, 0x0007FB,
- 0x0003FB, 0x0001FB, 0x0001FF, 0x00007C, 0x00003C, 0x00001C, 0x00000C,
- 0x000000, 0x000001, 0x000001, 0x000002, 0x000001, 0x00000D, 0x00001D,
- 0x00003D, 0x00007D, 0x0000FC, 0x0001FC, 0x0003FC, 0x0003F4, 0x0007EB,
- 0x000FEA, 0x001FEA, 0x001FD6, 0x003FD0, 0x007FAF, 0x007F43, 0x00FEB9,
- 0x00FE83, 0x01FEB7, 0x00FE81, 0x01FE89, 0x01FE8E, 0x01FE8F, 0x01FE8C,
- 0x01FE8D, 0x01FEB2, 0x01FEB3, 0x01FEB0, 0x01FEB1,
-};
-
-static const uint8_t huff_iid_dt1_bits[] = {
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 14, 14, 13,
- 13, 13, 12, 12, 11, 10, 9, 9, 7, 6, 5, 3, 1, 2, 5, 6, 7, 8,
- 9, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16,
-};
-
-static const uint16_t huff_iid_dt1_codes[] = {
- 0x004ED4, 0x004ED5, 0x004ECE, 0x004ECF, 0x004ECC, 0x004ED6, 0x004ED8,
- 0x004F46, 0x004F60, 0x002718, 0x002719, 0x002764, 0x002765, 0x00276D,
- 0x0027B1, 0x0013B7, 0x0013D6, 0x0009C7, 0x0009E9, 0x0009ED, 0x0004EE,
- 0x0004F7, 0x000278, 0x000139, 0x00009A, 0x00009F, 0x000020, 0x000011,
- 0x00000A, 0x000003, 0x000001, 0x000000, 0x00000B, 0x000012, 0x000021,
- 0x00004C, 0x00009B, 0x00013A, 0x000279, 0x000270, 0x0004EF, 0x0004E2,
- 0x0009EA, 0x0009D8, 0x0013D7, 0x0013D0, 0x0027B2, 0x0027A2, 0x00271A,
- 0x00271B, 0x004F66, 0x004F67, 0x004F61, 0x004F47, 0x004ED9, 0x004ED7,
- 0x004ECD, 0x004ED2, 0x004ED3, 0x004ED0, 0x004ED1,
-};
-
-static const uint8_t huff_iid_df0_bits[] = {
- 17, 17, 17, 17, 16, 15, 13, 10, 9, 7, 6, 5, 4, 3, 1, 3, 4, 5,
- 6, 6, 8, 11, 13, 14, 14, 15, 17, 18, 18,
-};
-
-static const uint32_t huff_iid_df0_codes[] = {
- 0x01FFFB, 0x01FFFC, 0x01FFFD, 0x01FFFA, 0x00FFFC, 0x007FFC, 0x001FFD,
- 0x0003FE, 0x0001FE, 0x00007E, 0x00003C, 0x00001D, 0x00000D, 0x000005,
- 0x000000, 0x000004, 0x00000C, 0x00001C, 0x00003D, 0x00003E, 0x0000FE,
- 0x0007FE, 0x001FFC, 0x003FFC, 0x003FFD, 0x007FFD, 0x01FFFE, 0x03FFFE,
- 0x03FFFF,
-};
-
-static const uint8_t huff_iid_dt0_bits[] = {
- 19, 19, 19, 20, 20, 20, 17, 15, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7,
- 9, 11, 13, 14, 17, 19, 20, 20, 20, 20, 20,
-};
-
-static const uint32_t huff_iid_dt0_codes[] = {
- 0x07FFF9, 0x07FFFA, 0x07FFFB, 0x0FFFF8, 0x0FFFF9, 0x0FFFFA, 0x01FFFD,
- 0x007FFE, 0x000FFE, 0x0003FE, 0x0000FE, 0x00003E, 0x00000E, 0x000002,
- 0x000000, 0x000006, 0x00001E, 0x00007E, 0x0001FE, 0x0007FE, 0x001FFE,
- 0x003FFE, 0x01FFFC, 0x07FFF8, 0x0FFFFB, 0x0FFFFC, 0x0FFFFD, 0x0FFFFE,
- 0x0FFFFF,
-};
-
-static const uint8_t huff_icc_df_bits[] = {
- 14, 14, 12, 10, 7, 5, 3, 1, 2, 4, 6, 8, 9, 11, 13,
-};
-
-static const uint16_t huff_icc_df_codes[] = {
- 0x3FFF, 0x3FFE, 0x0FFE, 0x03FE, 0x007E, 0x001E, 0x0006, 0x0000,
- 0x0002, 0x000E, 0x003E, 0x00FE, 0x01FE, 0x07FE, 0x1FFE,
-};
-
-static const uint8_t huff_icc_dt_bits[] = {
- 14, 13, 11, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 14,
-};
-
-static const uint16_t huff_icc_dt_codes[] = {
- 0x3FFE, 0x1FFE, 0x07FE, 0x01FE, 0x007E, 0x001E, 0x0006, 0x0000,
- 0x0002, 0x000E, 0x003E, 0x00FE, 0x03FE, 0x0FFE, 0x3FFF,
-};
-
-static const uint8_t huff_ipd_df_bits[] = {
- 1, 3, 4, 4, 4, 4, 4, 4,
-};
-
-static const uint8_t huff_ipd_df_codes[] = {
- 0x01, 0x00, 0x06, 0x04, 0x02, 0x03, 0x05, 0x07,
-};
-
-static const uint8_t huff_ipd_dt_bits[] = {
- 1, 3, 4, 5, 5, 4, 4, 3,
-};
-
-static const uint8_t huff_ipd_dt_codes[] = {
- 0x01, 0x02, 0x02, 0x03, 0x02, 0x00, 0x03, 0x03,
-};
-
-static const uint8_t huff_opd_df_bits[] = {
- 1, 3, 4, 4, 5, 5, 4, 3,
-};
-
-static const uint8_t huff_opd_df_codes[] = {
- 0x01, 0x01, 0x06, 0x04, 0x0F, 0x0E, 0x05, 0x00,
-};
-
-static const uint8_t huff_opd_dt_bits[] = {
- 1, 3, 4, 5, 5, 4, 4, 3,
-};
-
-static const uint8_t huff_opd_dt_codes[] = {
- 0x01, 0x02, 0x01, 0x07, 0x06, 0x00, 0x02, 0x03,
-};
-
-static const int8_t huff_offset[] = {
- 30, 30,
- 14, 14,
- 7, 7,
- 0, 0,
- 0, 0,
-};
-
-///Table 8.48
-static const int8_t k_to_i_20[] = {
- 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 14, 15,
- 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19
-};
-///Table 8.49
-static const int8_t k_to_i_34[] = {
- 0, 1, 2, 3, 4, 5, 6, 6, 7, 2, 1, 0, 10, 10, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 9, 14, 11, 12, 13, 14, 15, 16, 13, 16, 17, 18, 19, 20, 21,
- 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29,
- 30, 30, 30, 31, 31, 31, 31, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33,
- 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33
-};
-
-static const float g1_Q2[] = {
- 0.0f, 0.01899487526049f, 0.0f, -0.07293139167538f,
- 0.0f, 0.30596630545168f, 0.5f
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/aacpsdsp.c b/src/thirdparty/ffmpeg/libavcodec/aacpsdsp.c
deleted file mode 100644
index a917a8cce..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/aacpsdsp.c
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "config.h"
-#include "libavutil/attributes.h"
-#include "aacpsdsp.h"
-
-static void ps_add_squares_c(float *dst, const float (*src)[2], int n)
-{
- int i;
- for (i = 0; i < n; i++)
- dst[i] += src[i][0] * src[i][0] + src[i][1] * src[i][1];
-}
-
-static void ps_mul_pair_single_c(float (*dst)[2], float (*src0)[2], float *src1,
- int n)
-{
- int i;
- for (i = 0; i < n; i++) {
- dst[i][0] = src0[i][0] * src1[i];
- dst[i][1] = src0[i][1] * src1[i];
- }
-}
-
-static void ps_hybrid_analysis_c(float (*out)[2], float (*in)[2],
- const float (*filter)[8][2],
- int stride, int n)
-{
- int i, j;
-
- for (i = 0; i < n; i++) {
- float sum_re = filter[i][6][0] * in[6][0];
- float sum_im = filter[i][6][0] * in[6][1];
-
- for (j = 0; j < 6; j++) {
- float in0_re = in[j][0];
- float in0_im = in[j][1];
- float in1_re = in[12-j][0];
- float in1_im = in[12-j][1];
- sum_re += filter[i][j][0] * (in0_re + in1_re) -
- filter[i][j][1] * (in0_im - in1_im);
- sum_im += filter[i][j][0] * (in0_im + in1_im) +
- filter[i][j][1] * (in0_re - in1_re);
- }
- out[i * stride][0] = sum_re;
- out[i * stride][1] = sum_im;
- }
-}
-
-static void ps_hybrid_analysis_ileave_c(float (*out)[32][2], float L[2][38][64],
- int i, int len)
-{
- int j;
-
- for (; i < 64; i++) {
- for (j = 0; j < len; j++) {
- out[i][j][0] = L[0][j][i];
- out[i][j][1] = L[1][j][i];
- }
- }
-}
-
-static void ps_hybrid_synthesis_deint_c(float out[2][38][64],
- float (*in)[32][2],
- int i, int len)
-{
- int n;
-
- for (; i < 64; i++) {
- for (n = 0; n < len; n++) {
- out[0][n][i] = in[i][n][0];
- out[1][n][i] = in[i][n][1];
- }
- }
-}
-
-static void ps_decorrelate_c(float (*out)[2], float (*delay)[2],
- float (*ap_delay)[PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2],
- const float phi_fract[2], float (*Q_fract)[2],
- const float *transient_gain,
- float g_decay_slope,
- int len)
-{
- static const float a[] = { 0.65143905753106f,
- 0.56471812200776f,
- 0.48954165955695f };
- float ag[PS_AP_LINKS];
- int m, n;
-
- for (m = 0; m < PS_AP_LINKS; m++)
- ag[m] = a[m] * g_decay_slope;
-
- for (n = 0; n < len; n++) {
- float in_re = delay[n][0] * phi_fract[0] - delay[n][1] * phi_fract[1];
- float in_im = delay[n][0] * phi_fract[1] + delay[n][1] * phi_fract[0];
- for (m = 0; m < PS_AP_LINKS; m++) {
- float a_re = ag[m] * in_re;
- float a_im = ag[m] * in_im;
- float link_delay_re = ap_delay[m][n+2-m][0];
- float link_delay_im = ap_delay[m][n+2-m][1];
- float fractional_delay_re = Q_fract[m][0];
- float fractional_delay_im = Q_fract[m][1];
- float apd_re = in_re;
- float apd_im = in_im;
- in_re = link_delay_re * fractional_delay_re -
- link_delay_im * fractional_delay_im - a_re;
- in_im = link_delay_re * fractional_delay_im +
- link_delay_im * fractional_delay_re - a_im;
- ap_delay[m][n+5][0] = apd_re + ag[m] * in_re;
- ap_delay[m][n+5][1] = apd_im + ag[m] * in_im;
- }
- out[n][0] = transient_gain[n] * in_re;
- out[n][1] = transient_gain[n] * in_im;
- }
-}
-
-static void ps_stereo_interpolate_c(float (*l)[2], float (*r)[2],
- float h[2][4], float h_step[2][4],
- int len)
-{
- float h0 = h[0][0];
- float h1 = h[0][1];
- float h2 = h[0][2];
- float h3 = h[0][3];
- float hs0 = h_step[0][0];
- float hs1 = h_step[0][1];
- float hs2 = h_step[0][2];
- float hs3 = h_step[0][3];
- int n;
-
- for (n = 0; n < len; n++) {
- //l is s, r is d
- float l_re = l[n][0];
- float l_im = l[n][1];
- float r_re = r[n][0];
- float r_im = r[n][1];
- h0 += hs0;
- h1 += hs1;
- h2 += hs2;
- h3 += hs3;
- l[n][0] = h0 * l_re + h2 * r_re;
- l[n][1] = h0 * l_im + h2 * r_im;
- r[n][0] = h1 * l_re + h3 * r_re;
- r[n][1] = h1 * l_im + h3 * r_im;
- }
-}
-
-static void ps_stereo_interpolate_ipdopd_c(float (*l)[2], float (*r)[2],
- float h[2][4], float h_step[2][4],
- int len)
-{
- float h00 = h[0][0], h10 = h[1][0];
- float h01 = h[0][1], h11 = h[1][1];
- float h02 = h[0][2], h12 = h[1][2];
- float h03 = h[0][3], h13 = h[1][3];
- float hs00 = h_step[0][0], hs10 = h_step[1][0];
- float hs01 = h_step[0][1], hs11 = h_step[1][1];
- float hs02 = h_step[0][2], hs12 = h_step[1][2];
- float hs03 = h_step[0][3], hs13 = h_step[1][3];
- int n;
-
- for (n = 0; n < len; n++) {
- //l is s, r is d
- float l_re = l[n][0];
- float l_im = l[n][1];
- float r_re = r[n][0];
- float r_im = r[n][1];
- h00 += hs00;
- h01 += hs01;
- h02 += hs02;
- h03 += hs03;
- h10 += hs10;
- h11 += hs11;
- h12 += hs12;
- h13 += hs13;
-
- l[n][0] = h00 * l_re + h02 * r_re - h10 * l_im - h12 * r_im;
- l[n][1] = h00 * l_im + h02 * r_im + h10 * l_re + h12 * r_re;
- r[n][0] = h01 * l_re + h03 * r_re - h11 * l_im - h13 * r_im;
- r[n][1] = h01 * l_im + h03 * r_im + h11 * l_re + h13 * r_re;
- }
-}
-
-av_cold void ff_psdsp_init(PSDSPContext *s)
-{
- s->add_squares = ps_add_squares_c;
- s->mul_pair_single = ps_mul_pair_single_c;
- s->hybrid_analysis = ps_hybrid_analysis_c;
- s->hybrid_analysis_ileave = ps_hybrid_analysis_ileave_c;
- s->hybrid_synthesis_deint = ps_hybrid_synthesis_deint_c;
- s->decorrelate = ps_decorrelate_c;
- s->stereo_interpolate[0] = ps_stereo_interpolate_c;
- s->stereo_interpolate[1] = ps_stereo_interpolate_ipdopd_c;
-
- if (ARCH_ARM)
- ff_psdsp_init_arm(s);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/aacpsdsp.h b/src/thirdparty/ffmpeg/libavcodec/aacpsdsp.h
deleted file mode 100644
index f2f6501ca..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/aacpsdsp.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2012 Mans Rullgard
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef LIBAVCODEC_AACPSDSP_H
-#define LIBAVCODEC_AACPSDSP_H
-
-#define PS_QMF_TIME_SLOTS 32
-#define PS_AP_LINKS 3
-#define PS_MAX_AP_DELAY 5
-
-typedef struct PSDSPContext {
- void (*add_squares)(float *dst, const float (*src)[2], int n);
- void (*mul_pair_single)(float (*dst)[2], float (*src0)[2], float *src1,
- int n);
- void (*hybrid_analysis)(float (*out)[2], float (*in)[2],
- const float (*filter)[8][2],
- int stride, int n);
- void (*hybrid_analysis_ileave)(float (*out)[32][2], float L[2][38][64],
- int i, int len);
- void (*hybrid_synthesis_deint)(float out[2][38][64], float (*in)[32][2],
- int i, int len);
- void (*decorrelate)(float (*out)[2], float (*delay)[2],
- float (*ap_delay)[PS_QMF_TIME_SLOTS+PS_MAX_AP_DELAY][2],
- const float phi_fract[2], float (*Q_fract)[2],
- const float *transient_gain,
- float g_decay_slope,
- int len);
- void (*stereo_interpolate[2])(float (*l)[2], float (*r)[2],
- float h[2][4], float h_step[2][4],
- int len);
-} PSDSPContext;
-
-void ff_psdsp_init(PSDSPContext *s);
-void ff_psdsp_init_arm(PSDSPContext *s);
-
-#endif /* LIBAVCODEC_AACPSDSP_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/aacsbr.c b/src/thirdparty/ffmpeg/libavcodec/aacsbr.c
deleted file mode 100644
index 8212f9ac6..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/aacsbr.c
+++ /dev/null
@@ -1,1722 +0,0 @@
-/*
- * AAC Spectral Band Replication decoding functions
- * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl )
- * Copyright (c) 2009-2010 Alex Converse <alex.converse@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
- * AAC Spectral Band Replication decoding functions
- * @author Robert Swain ( rob opendot cl )
- */
-
-#include "aac.h"
-#include "sbr.h"
-#include "aacsbr.h"
-#include "aacsbrdata.h"
-#include "fft.h"
-#include "aacps.h"
-#include "sbrdsp.h"
-#include "libavutil/internal.h"
-#include "libavutil/libm.h"
-#include "libavutil/avassert.h"
-
-#include <stdint.h>
-#include <float.h>
-#include <math.h>
-
-#define ENVELOPE_ADJUSTMENT_OFFSET 2
-#define NOISE_FLOOR_OFFSET 6.0f
-
-/**
- * SBR VLC tables
- */
-enum {
- T_HUFFMAN_ENV_1_5DB,
- F_HUFFMAN_ENV_1_5DB,
- T_HUFFMAN_ENV_BAL_1_5DB,
- F_HUFFMAN_ENV_BAL_1_5DB,
- T_HUFFMAN_ENV_3_0DB,
- F_HUFFMAN_ENV_3_0DB,
- T_HUFFMAN_ENV_BAL_3_0DB,
- F_HUFFMAN_ENV_BAL_3_0DB,
- T_HUFFMAN_NOISE_3_0DB,
- T_HUFFMAN_NOISE_BAL_3_0DB,
-};
-
-/**
- * bs_frame_class - frame class of current SBR frame (14496-3 sp04 p98)
- */
-enum {
- FIXFIX,
- FIXVAR,
- VARFIX,
- VARVAR,
-};
-
-enum {
- EXTENSION_ID_PS = 2,
-};
-
-static VLC vlc_sbr[10];
-static const int8_t vlc_sbr_lav[10] =
- { 60, 60, 24, 24, 31, 31, 12, 12, 31, 12 };
-
-#define SBR_INIT_VLC_STATIC(num, size) \
- INIT_VLC_STATIC(&vlc_sbr[num], 9, sbr_tmp[num].table_size / sbr_tmp[num].elem_size, \
- sbr_tmp[num].sbr_bits , 1, 1, \
- sbr_tmp[num].sbr_codes, sbr_tmp[num].elem_size, sbr_tmp[num].elem_size, \
- size)
-
-#define SBR_VLC_ROW(name) \
- { name ## _codes, name ## _bits, sizeof(name ## _codes), sizeof(name ## _codes[0]) }
-
-av_cold void ff_aac_sbr_init(void)
-{
- int n;
- static const struct {
- const void *sbr_codes, *sbr_bits;
- const unsigned int table_size, elem_size;
- } sbr_tmp[] = {
- SBR_VLC_ROW(t_huffman_env_1_5dB),
- SBR_VLC_ROW(f_huffman_env_1_5dB),
- SBR_VLC_ROW(t_huffman_env_bal_1_5dB),
- SBR_VLC_ROW(f_huffman_env_bal_1_5dB),
- SBR_VLC_ROW(t_huffman_env_3_0dB),
- SBR_VLC_ROW(f_huffman_env_3_0dB),
- SBR_VLC_ROW(t_huffman_env_bal_3_0dB),
- SBR_VLC_ROW(f_huffman_env_bal_3_0dB),
- SBR_VLC_ROW(t_huffman_noise_3_0dB),
- SBR_VLC_ROW(t_huffman_noise_bal_3_0dB),
- };
-
- // SBR VLC table initialization
- SBR_INIT_VLC_STATIC(0, 1098);
- SBR_INIT_VLC_STATIC(1, 1092);
- SBR_INIT_VLC_STATIC(2, 768);
- SBR_INIT_VLC_STATIC(3, 1026);
- SBR_INIT_VLC_STATIC(4, 1058);
- SBR_INIT_VLC_STATIC(5, 1052);
- SBR_INIT_VLC_STATIC(6, 544);
- SBR_INIT_VLC_STATIC(7, 544);
- SBR_INIT_VLC_STATIC(8, 592);
- SBR_INIT_VLC_STATIC(9, 512);
-
- for (n = 1; n < 320; n++)
- sbr_qmf_window_us[320 + n] = sbr_qmf_window_us[320 - n];
- sbr_qmf_window_us[384] = -sbr_qmf_window_us[384];
- sbr_qmf_window_us[512] = -sbr_qmf_window_us[512];
-
- for (n = 0; n < 320; n++)
- sbr_qmf_window_ds[n] = sbr_qmf_window_us[2*n];
-
- ff_ps_init();
-}
-
-/** Places SBR in pure upsampling mode. */
-static void sbr_turnoff(SpectralBandReplication *sbr) {
- sbr->start = 0;
- // Init defults used in pure upsampling mode
- sbr->kx[1] = 32; //Typo in spec, kx' inits to 32
- sbr->m[1] = 0;
- // Reset values for first SBR header
- sbr->data[0].e_a[1] = sbr->data[1].e_a[1] = -1;
- memset(&sbr->spectrum_params, -1, sizeof(SpectrumParameters));
-}
-
-av_cold void ff_aac_sbr_ctx_init(AACContext *ac, SpectralBandReplication *sbr)
-{
- if(sbr->mdct.mdct_bits)
- return;
- sbr->kx[0] = sbr->kx[1];
- sbr_turnoff(sbr);
- sbr->data[0].synthesis_filterbank_samples_offset = SBR_SYNTHESIS_BUF_SIZE - (1280 - 128);
- sbr->data[1].synthesis_filterbank_samples_offset = SBR_SYNTHESIS_BUF_SIZE - (1280 - 128);
- /* SBR requires samples to be scaled to +/-32768.0 to work correctly.
- * mdct scale factors are adjusted to scale up from +/-1.0 at analysis
- * and scale back down at synthesis. */
- ff_mdct_init(&sbr->mdct, 7, 1, 1.0 / (64 * 32768.0));
- ff_mdct_init(&sbr->mdct_ana, 7, 1, -2.0 * 32768.0);
- ff_ps_ctx_init(&sbr->ps);
- ff_sbrdsp_init(&sbr->dsp);
-}
-
-av_cold void ff_aac_sbr_ctx_close(SpectralBandReplication *sbr)
-{
- ff_mdct_end(&sbr->mdct);
- ff_mdct_end(&sbr->mdct_ana);
-}
-
-static int qsort_comparison_function_int16(const void *a, const void *b)
-{
- return *(const int16_t *)a - *(const int16_t *)b;
-}
-
-static inline int in_table_int16(const int16_t *table, int last_el, int16_t needle)
-{
- int i;
- for (i = 0; i <= last_el; i++)
- if (table[i] == needle)
- return 1;
- return 0;
-}
-
-/// Limiter Frequency Band Table (14496-3 sp04 p198)
-static void sbr_make_f_tablelim(SpectralBandReplication *sbr)
-{
- int k;
- if (sbr->bs_limiter_bands > 0) {
- static const float bands_warped[3] = { 1.32715174233856803909f, //2^(0.49/1.2)
- 1.18509277094158210129f, //2^(0.49/2)
- 1.11987160404675912501f }; //2^(0.49/3)
- const float lim_bands_per_octave_warped = bands_warped[sbr->bs_limiter_bands - 1];
- int16_t patch_borders[7];
- uint16_t *in = sbr->f_tablelim + 1, *out = sbr->f_tablelim;
-
- patch_borders[0] = sbr->kx[1];
- for (k = 1; k <= sbr->num_patches; k++)
- patch_borders[k] = patch_borders[k-1] + sbr->patch_num_subbands[k-1];
-
- memcpy(sbr->f_tablelim, sbr->f_tablelow,
- (sbr->n[0] + 1) * sizeof(sbr->f_tablelow[0]));
- if (sbr->num_patches > 1)
- memcpy(sbr->f_tablelim + sbr->n[0] + 1, patch_borders + 1,
- (sbr->num_patches - 1) * sizeof(patch_borders[0]));
-
- qsort(sbr->f_tablelim, sbr->num_patches + sbr->n[0],
- sizeof(sbr->f_tablelim[0]),
- qsort_comparison_function_int16);
-
- sbr->n_lim = sbr->n[0] + sbr->num_patches - 1;
- while (out < sbr->f_tablelim + sbr->n_lim) {
- if (*in >= *out * lim_bands_per_octave_warped) {
- *++out = *in++;
- } else if (*in == *out ||
- !in_table_int16(patch_borders, sbr->num_patches, *in)) {
- in++;
- sbr->n_lim--;
- } else if (!in_table_int16(patch_borders, sbr->num_patches, *out)) {
- *out = *in++;
- sbr->n_lim--;
- } else {
- *++out = *in++;
- }
- }
- } else {
- sbr->f_tablelim[0] = sbr->f_tablelow[0];
- sbr->f_tablelim[1] = sbr->f_tablelow[sbr->n[0]];
- sbr->n_lim = 1;
- }
-}
-
-static unsigned int read_sbr_header(SpectralBandReplication *sbr, GetBitContext *gb)
-{
- unsigned int cnt = get_bits_count(gb);
- uint8_t bs_header_extra_1;
- uint8_t bs_header_extra_2;
- int old_bs_limiter_bands = sbr->bs_limiter_bands;
- SpectrumParameters old_spectrum_params;
-
- sbr->start = 1;
-
- // Save last spectrum parameters variables to compare to new ones
- memcpy(&old_spectrum_params, &sbr->spectrum_params, sizeof(SpectrumParameters));
-
- sbr->bs_amp_res_header = get_bits1(gb);
- sbr->spectrum_params.bs_start_freq = get_bits(gb, 4);
- sbr->spectrum_params.bs_stop_freq = get_bits(gb, 4);
- sbr->spectrum_params.bs_xover_band = get_bits(gb, 3);
- skip_bits(gb, 2); // bs_reserved
-
- bs_header_extra_1 = get_bits1(gb);
- bs_header_extra_2 = get_bits1(gb);
-
- if (bs_header_extra_1) {
- sbr->spectrum_params.bs_freq_scale = get_bits(gb, 2);
- sbr->spectrum_params.bs_alter_scale = get_bits1(gb);
- sbr->spectrum_params.bs_noise_bands = get_bits(gb, 2);
- } else {
- sbr->spectrum_params.bs_freq_scale = 2;
- sbr->spectrum_params.bs_alter_scale = 1;
- sbr->spectrum_params.bs_noise_bands = 2;
- }
-
- // Check if spectrum parameters changed
- if (memcmp(&old_spectrum_params, &sbr->spectrum_params, sizeof(SpectrumParameters)))
- sbr->reset = 1;
-
- if (bs_header_extra_2) {
- sbr->bs_limiter_bands = get_bits(gb, 2);
- sbr->bs_limiter_gains = get_bits(gb, 2);
- sbr->bs_interpol_freq = get_bits1(gb);
- sbr->bs_smoothing_mode = get_bits1(gb);
- } else {
- sbr->bs_limiter_bands = 2;
- sbr->bs_limiter_gains = 2;
- sbr->bs_interpol_freq = 1;
- sbr->bs_smoothing_mode = 1;
- }
-
- if (sbr->bs_limiter_bands != old_bs_limiter_bands && !sbr->reset)
- sbr_make_f_tablelim(sbr);
-
- return get_bits_count(gb) - cnt;
-}
-
-static int array_min_int16(const int16_t *array, int nel)
-{
- int i, min = array[0];
- for (i = 1; i < nel; i++)
- min = FFMIN(array[i], min);
- return min;
-}
-
-static void make_bands(int16_t* bands, int start, int stop, int num_bands)
-{
- int k, previous, present;
- float base, prod;
-
- base = powf((float)stop / start, 1.0f / num_bands);
- prod = start;
- previous = start;
-
- for (k = 0; k < num_bands-1; k++) {
- prod *= base;
- present = lrintf(prod);
- bands[k] = present - previous;
- previous = present;
- }
- bands[num_bands-1] = stop - previous;
-}
-
-static int check_n_master(AVCodecContext *avctx, int n_master, int bs_xover_band)
-{
- // Requirements (14496-3 sp04 p205)
- if (n_master <= 0) {
- av_log(avctx, AV_LOG_ERROR, "Invalid n_master: %d\n", n_master);
- return -1;
- }
- if (bs_xover_band >= n_master) {
- av_log(avctx, AV_LOG_ERROR,
- "Invalid bitstream, crossover band index beyond array bounds: %d\n",
- bs_xover_band);
- return -1;
- }
- return 0;
-}
-
-/// Master Frequency Band Table (14496-3 sp04 p194)
-static int sbr_make_f_master(AACContext *ac, SpectralBandReplication *sbr,
- SpectrumParameters *spectrum)
-{
- unsigned int temp, max_qmf_subbands;
- unsigned int start_min, stop_min;
- int k;
- const int8_t *sbr_offset_ptr;
- int16_t stop_dk[13];
-
- if (sbr->sample_rate < 32000) {
- temp = 3000;
- } else if (sbr->sample_rate < 64000) {
- temp = 4000;
- } else
- temp = 5000;
-
- switch (sbr->sample_rate) {
- case 16000:
- sbr_offset_ptr = sbr_offset[0];
- break;
- case 22050:
- sbr_offset_ptr = sbr_offset[1];
- break;
- case 24000:
- sbr_offset_ptr = sbr_offset[2];
- break;
- case 32000:
- sbr_offset_ptr = sbr_offset[3];
- break;
- case 44100: case 48000: case 64000:
- sbr_offset_ptr = sbr_offset[4];
- break;
- case 88200: case 96000: case 128000: case 176400: case 192000:
- sbr_offset_ptr = sbr_offset[5];
- break;
- default:
- av_log(ac->avctx, AV_LOG_ERROR,
- "Unsupported sample rate for SBR: %d\n", sbr->sample_rate);
- return -1;
- }
-
- start_min = ((temp << 7) + (sbr->sample_rate >> 1)) / sbr->sample_rate;
- stop_min = ((temp << 8) + (sbr->sample_rate >> 1)) / sbr->sample_rate;
-
- sbr->k[0] = start_min + sbr_offset_ptr[spectrum->bs_start_freq];
-
- if (spectrum->bs_stop_freq < 14) {
- sbr->k[2] = stop_min;
- make_bands(stop_dk, stop_min, 64, 13);
- qsort(stop_dk, 13, sizeof(stop_dk[0]), qsort_comparison_function_int16);
- for (k = 0; k < spectrum->bs_stop_freq; k++)
- sbr->k[2] += stop_dk[k];
- } else if (spectrum->bs_stop_freq == 14) {
- sbr->k[2] = 2*sbr->k[0];
- } else if (spectrum->bs_stop_freq == 15) {
- sbr->k[2] = 3*sbr->k[0];
- } else {
- av_log(ac->avctx, AV_LOG_ERROR,
- "Invalid bs_stop_freq: %d\n", spectrum->bs_stop_freq);
- return -1;
- }
- sbr->k[2] = FFMIN(64, sbr->k[2]);
-
- // Requirements (14496-3 sp04 p205)
- if (sbr->sample_rate <= 32000) {
- max_qmf_subbands = 48;
- } else if (sbr->sample_rate == 44100) {
- max_qmf_subbands = 35;
- } else if (sbr->sample_rate >= 48000)
- max_qmf_subbands = 32;
-
- if (sbr->k[2] - sbr->k[0] > max_qmf_subbands) {
- av_log(ac->avctx, AV_LOG_ERROR,
- "Invalid bitstream, too many QMF subbands: %d\n", sbr->k[2] - sbr->k[0]);
- return -1;
- }
-
- if (!spectrum->bs_freq_scale) {
- int dk, k2diff;
-
- dk = spectrum->bs_alter_scale + 1;
- sbr->n_master = ((sbr->k[2] - sbr->k[0] + (dk&2)) >> dk) << 1;
- if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band))
- return -1;
-
- for (k = 1; k <= sbr->n_master; k++)
- sbr->f_master[k] = dk;
-
- k2diff = sbr->k[2] - sbr->k[0] - sbr->n_master * dk;
- if (k2diff < 0) {
- sbr->f_master[1]--;
- sbr->f_master[2]-= (k2diff < -1);
- } else if (k2diff) {
- sbr->f_master[sbr->n_master]++;
- }
-
- sbr->f_master[0] = sbr->k[0];
- for (k = 1; k <= sbr->n_master; k++)
- sbr->f_master[k] += sbr->f_master[k - 1];
-
- } else {
- int half_bands = 7 - spectrum->bs_freq_scale; // bs_freq_scale = {1,2,3}
- int two_regions, num_bands_0;
- int vdk0_max, vdk1_min;
- int16_t vk0[49];
-
- if (49 * sbr->k[2] > 110 * sbr->k[0]) {
- two_regions = 1;
- sbr->k[1] = 2 * sbr->k[0];
- } else {
- two_regions = 0;
- sbr->k[1] = sbr->k[2];
- }
-
- num_bands_0 = lrintf(half_bands * log2f(sbr->k[1] / (float)sbr->k[0])) * 2;
-
- if (num_bands_0 <= 0) { // Requirements (14496-3 sp04 p205)
- av_log(ac->avctx, AV_LOG_ERROR, "Invalid num_bands_0: %d\n", num_bands_0);
- return -1;
- }
-
- vk0[0] = 0;
-
- make_bands(vk0+1, sbr->k[0], sbr->k[1], num_bands_0);
-
- qsort(vk0 + 1, num_bands_0, sizeof(vk0[1]), qsort_comparison_function_int16);
- vdk0_max = vk0[num_bands_0];
-
- vk0[0] = sbr->k[0];
- for (k = 1; k <= num_bands_0; k++) {
- if (vk0[k] <= 0) { // Requirements (14496-3 sp04 p205)
- av_log(ac->avctx, AV_LOG_ERROR, "Invalid vDk0[%d]: %d\n", k, vk0[k]);
- return -1;
- }
- vk0[k] += vk0[k-1];
- }
-
- if (two_regions) {
- int16_t vk1[49];
- float invwarp = spectrum->bs_alter_scale ? 0.76923076923076923077f
- : 1.0f; // bs_alter_scale = {0,1}
- int num_bands_1 = lrintf(half_bands * invwarp *
- log2f(sbr->k[2] / (float)sbr->k[1])) * 2;
-
- make_bands(vk1+1, sbr->k[1], sbr->k[2], num_bands_1);
-
- vdk1_min = array_min_int16(vk1 + 1, num_bands_1);
-
- if (vdk1_min < vdk0_max) {
- int change;
- qsort(vk1 + 1, num_bands_1, sizeof(vk1[1]), qsort_comparison_function_int16);
- change = FFMIN(vdk0_max - vk1[1], (vk1[num_bands_1] - vk1[1]) >> 1);
- vk1[1] += change;
- vk1[num_bands_1] -= change;
- }
-
- qsort(vk1 + 1, num_bands_1, sizeof(vk1[1]), qsort_comparison_function_int16);
-
- vk1[0] = sbr->k[1];
- for (k = 1; k <= num_bands_1; k++) {
- if (vk1[k] <= 0) { // Requirements (14496-3 sp04 p205)
- av_log(ac->avctx, AV_LOG_ERROR, "Invalid vDk1[%d]: %d\n", k, vk1[k]);
- return -1;
- }
- vk1[k] += vk1[k-1];
- }
-
- sbr->n_master = num_bands_0 + num_bands_1;
- if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band))
- return -1;
- memcpy(&sbr->f_master[0], vk0,
- (num_bands_0 + 1) * sizeof(sbr->f_master[0]));
- memcpy(&sbr->f_master[num_bands_0 + 1], vk1 + 1,
- num_bands_1 * sizeof(sbr->f_master[0]));
-
- } else {
- sbr->n_master = num_bands_0;
- if (check_n_master(ac->avctx, sbr->n_master, sbr->spectrum_params.bs_xover_band))
- return -1;
- memcpy(sbr->f_master, vk0, (num_bands_0 + 1) * sizeof(sbr->f_master[0]));
- }
- }
-
- return 0;
-}
-
-/// High Frequency Generation - Patch Construction (14496-3 sp04 p216 fig. 4.46)
-static int sbr_hf_calc_npatches(AACContext *ac, SpectralBandReplication *sbr)
-{
- int i, k, sb = 0;
- int msb = sbr->k[0];
- int usb = sbr->kx[1];
- int goal_sb = ((1000 << 11) + (sbr->sample_rate >> 1)) / sbr->sample_rate;
-
- sbr->num_patches = 0;
-
- if (goal_sb < sbr->kx[1] + sbr->m[1]) {
- for (k = 0; sbr->f_master[k] < goal_sb; k++) ;
- } else
- k = sbr->n_master;
-
- do {
- int odd = 0;
- for (i = k; i == k || sb > (sbr->k[0] - 1 + msb - odd); i--) {
- sb = sbr->f_master[i];
- odd = (sb + sbr->k[0]) & 1;
- }
-
- // Requirements (14496-3 sp04 p205) sets the maximum number of patches to 5.
- // After this check the final number of patches can still be six which is
- // illegal however the Coding Technologies decoder check stream has a final
- // count of 6 patches
- if (sbr->num_patches > 5) {
- av_log(ac->avctx, AV_LOG_ERROR, "Too many patches: %d\n", sbr->num_patches);
- return -1;
- }
-
- sbr->patch_num_subbands[sbr->num_patches] = FFMAX(sb - usb, 0);
- sbr->patch_start_subband[sbr->num_patches] = sbr->k[0] - odd - sbr->patch_num_subbands[sbr->num_patches];
-
- if (sbr->patch_num_subbands[sbr->num_patches] > 0) {
- usb = sb;
- msb = sb;
- sbr->num_patches++;
- } else
- msb = sbr->kx[1];
-
- if (sbr->f_master[k] - sb < 3)
- k = sbr->n_master;
- } while (sb != sbr->kx[1] + sbr->m[1]);
-
- if (sbr->num_patches > 1 && sbr->patch_num_subbands[sbr->num_patches-1] < 3)
- sbr->num_patches--;
-
- return 0;
-}
-
-/// Derived Frequency Band Tables (14496-3 sp04 p197)
-static int sbr_make_f_derived(AACContext *ac, SpectralBandReplication *sbr)
-{
- int k, temp;
-
- sbr->n[1] = sbr->n_master - sbr->spectrum_params.bs_xover_band;
- sbr->n[0] = (sbr->n[1] + 1) >> 1;
-
- memcpy(sbr->f_tablehigh, &sbr->f_master[sbr->spectrum_params.bs_xover_band],
- (sbr->n[1] + 1) * sizeof(sbr->f_master[0]));
- sbr->m[1] = sbr->f_tablehigh[sbr->n[1]] - sbr->f_tablehigh[0];
- sbr->kx[1] = sbr->f_tablehigh[0];
-
- // Requirements (14496-3 sp04 p205)
- if (sbr->kx[1] + sbr->m[1] > 64) {
- av_log(ac->avctx, AV_LOG_ERROR,
- "Stop frequency border too high: %d\n", sbr->kx[1] + sbr->m[1]);
- return -1;
- }
- if (sbr->kx[1] > 32) {
- av_log(ac->avctx, AV_LOG_ERROR, "Start frequency border too high: %d\n", sbr->kx[1]);
- return -1;
- }
-
- sbr->f_tablelow[0] = sbr->f_tablehigh[0];
- temp = sbr->n[1] & 1;
- for (k = 1; k <= sbr->n[0]; k++)
- sbr->f_tablelow[k] = sbr->f_tablehigh[2 * k - temp];
-
- sbr->n_q = FFMAX(1, lrintf(sbr->spectrum_params.bs_noise_bands *
- log2f(sbr->k[2] / (float)sbr->kx[1]))); // 0 <= bs_noise_bands <= 3
- if (sbr->n_q > 5) {
- av_log(ac->avctx, AV_LOG_ERROR, "Too many noise floor scale factors: %d\n", sbr->n_q);
- return -1;
- }
-
- sbr->f_tablenoise[0] = sbr->f_tablelow[0];
- temp = 0;
- for (k = 1; k <= sbr->n_q; k++) {
- temp += (sbr->n[0] - temp) / (sbr->n_q + 1 - k);
- sbr->f_tablenoise[k] = sbr->f_tablelow[temp];
- }
-
- if (sbr_hf_calc_npatches(ac, sbr) < 0)
- return -1;
-
- sbr_make_f_tablelim(sbr);
-
- sbr->data[0].f_indexnoise = 0;
- sbr->data[1].f_indexnoise = 0;
-
- return 0;
-}
-
-static av_always_inline void get_bits1_vector(GetBitContext *gb, uint8_t *vec,
- int elements)
-{
- int i;
- for (i = 0; i < elements; i++) {
- vec[i] = get_bits1(gb);
- }
-}
-
-/** ceil(log2(index+1)) */
-static const int8_t ceil_log2[] = {
- 0, 1, 2, 2, 3, 3,
-};
-
-static int read_sbr_grid(AACContext *ac, SpectralBandReplication *sbr,
- GetBitContext *gb, SBRData *ch_data)
-{
- int i;
- unsigned bs_pointer = 0;
- // frameLengthFlag ? 15 : 16; 960 sample length frames unsupported; this value is numTimeSlots
- int abs_bord_trail = 16;
- int num_rel_lead, num_rel_trail;
- unsigned bs_num_env_old = ch_data->bs_num_env;
-
- ch_data->bs_freq_res[0] = ch_data->bs_freq_res[ch_data->bs_num_env];
- ch_data->bs_amp_res = sbr->bs_amp_res_header;
- ch_data->t_env_num_env_old = ch_data->t_env[bs_num_env_old];
-
- switch (ch_data->bs_frame_class = get_bits(gb, 2)) {
- case FIXFIX:
- ch_data->bs_num_env = 1 << get_bits(gb, 2);
- num_rel_lead = ch_data->bs_num_env - 1;
- if (ch_data->bs_num_env == 1)
- ch_data->bs_amp_res = 0;
-
- if (ch_data->bs_num_env > 4) {
- av_log(ac->avctx, AV_LOG_ERROR,
- "Invalid bitstream, too many SBR envelopes in FIXFIX type SBR frame: %d\n",
- ch_data->bs_num_env);
- return -1;
- }
-
- ch_data->t_env[0] = 0;
- ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail;
-
- abs_bord_trail = (abs_bord_trail + (ch_data->bs_num_env >> 1)) /
- ch_data->bs_num_env;
- for (i = 0; i < num_rel_lead; i++)
- ch_data->t_env[i + 1] = ch_data->t_env[i] + abs_bord_trail;
-
- ch_data->bs_freq_res[1] = get_bits1(gb);
- for (i = 1; i < ch_data->bs_num_env; i++)
- ch_data->bs_freq_res[i + 1] = ch_data->bs_freq_res[1];
- break;
- case FIXVAR:
- abs_bord_trail += get_bits(gb, 2);
- num_rel_trail = get_bits(gb, 2);
- ch_data->bs_num_env = num_rel_trail + 1;
- ch_data->t_env[0] = 0;
- ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail;
-
- for (i = 0; i < num_rel_trail; i++)
- ch_data->t_env[ch_data->bs_num_env - 1 - i] =
- ch_data->t_env[ch_data->bs_num_env - i] - 2 * get_bits(gb, 2) - 2;
-
- bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env]);
-
- for (i = 0; i < ch_data->bs_num_env; i++)
- ch_data->bs_freq_res[ch_data->bs_num_env - i] = get_bits1(gb);
- break;
- case VARFIX:
- ch_data->t_env[0] = get_bits(gb, 2);
- num_rel_lead = get_bits(gb, 2);
- ch_data->bs_num_env = num_rel_lead + 1;
- ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail;
-
- for (i = 0; i < num_rel_lead; i++)
- ch_data->t_env[i + 1] = ch_data->t_env[i] + 2 * get_bits(gb, 2) + 2;
-
- bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env]);
-
- get_bits1_vector(gb, ch_data->bs_freq_res + 1, ch_data->bs_num_env);
- break;
- case VARVAR:
- ch_data->t_env[0] = get_bits(gb, 2);
- abs_bord_trail += get_bits(gb, 2);
- num_rel_lead = get_bits(gb, 2);
- num_rel_trail = get_bits(gb, 2);
- ch_data->bs_num_env = num_rel_lead + num_rel_trail + 1;
-
- if (ch_data->bs_num_env > 5) {
- av_log(ac->avctx, AV_LOG_ERROR,
- "Invalid bitstream, too many SBR envelopes in VARVAR type SBR frame: %d\n",
- ch_data->bs_num_env);
- return -1;
- }
-
- ch_data->t_env[ch_data->bs_num_env] = abs_bord_trail;
-
- for (i = 0; i < num_rel_lead; i++)
- ch_data->t_env[i + 1] = ch_data->t_env[i] + 2 * get_bits(gb, 2) + 2;
- for (i = 0; i < num_rel_trail; i++)
- ch_data->t_env[ch_data->bs_num_env - 1 - i] =
- ch_data->t_env[ch_data->bs_num_env - i] - 2 * get_bits(gb, 2) - 2;
-
- bs_pointer = get_bits(gb, ceil_log2[ch_data->bs_num_env]);
-
- get_bits1_vector(gb, ch_data->bs_freq_res + 1, ch_data->bs_num_env);
- break;
- }
-
- if (bs_pointer > ch_data->bs_num_env + 1) {
- av_log(ac->avctx, AV_LOG_ERROR,
- "Invalid bitstream, bs_pointer points to a middle noise border outside the time borders table: %d\n",
- bs_pointer);
- return -1;
- }
-
- for (i = 1; i <= ch_data->bs_num_env; i++) {
- if (ch_data->t_env[i-1] > ch_data->t_env[i]) {
- av_log(ac->avctx, AV_LOG_ERROR, "Non monotone time borders\n");
- return -1;
- }
- }
-
- ch_data->bs_num_noise = (ch_data->bs_num_env > 1) + 1;
-
- ch_data->t_q[0] = ch_data->t_env[0];
- ch_data->t_q[ch_data->bs_num_noise] = ch_data->t_env[ch_data->bs_num_env];
- if (ch_data->bs_num_noise > 1) {
- unsigned int idx;
- if (ch_data->bs_frame_class == FIXFIX) {
- idx = ch_data->bs_num_env >> 1;
- } else if (ch_data->bs_frame_class & 1) { // FIXVAR or VARVAR
- idx = ch_data->bs_num_env - FFMAX((int)bs_pointer - 1, 1);
- } else { // VARFIX
- if (!bs_pointer)
- idx = 1;
- else if (bs_pointer == 1)
- idx = ch_data->bs_num_env - 1;
- else // bs_pointer > 1
- idx = bs_pointer - 1;
- }
- ch_data->t_q[1] = ch_data->t_env[idx];
- }
-
- ch_data->e_a[0] = -(ch_data->e_a[1] != bs_num_env_old); // l_APrev
- ch_data->e_a[1] = -1;
- if ((ch_data->bs_frame_class & 1) && bs_pointer) { // FIXVAR or VARVAR and bs_pointer != 0
- ch_data->e_a[1] = ch_data->bs_num_env + 1 - bs_pointer;
- } else if ((ch_data->bs_frame_class == 2) && (bs_pointer > 1)) // VARFIX and bs_pointer > 1
- ch_data->e_a[1] = bs_pointer - 1;
-
- return 0;
-}
-
-static void copy_sbr_grid(SBRData *dst, const SBRData *src) {
- //These variables are saved from the previous frame rather than copied
- dst->bs_freq_res[0] = dst->bs_freq_res[dst->bs_num_env];
- dst->t_env_num_env_old = dst->t_env[dst->bs_num_env];
- dst->e_a[0] = -(dst->e_a[1] != dst->bs_num_env);
-
- //These variables are read from the bitstream and therefore copied
- memcpy(dst->bs_freq_res+1, src->bs_freq_res+1, sizeof(dst->bs_freq_res)-sizeof(*dst->bs_freq_res));
- memcpy(dst->t_env, src->t_env, sizeof(dst->t_env));
- memcpy(dst->t_q, src->t_q, sizeof(dst->t_q));
- dst->bs_num_env = src->bs_num_env;
- dst->bs_amp_res = src->bs_amp_res;
- dst->bs_num_noise = src->bs_num_noise;
- dst->bs_frame_class = src->bs_frame_class;
- dst->e_a[1] = src->e_a[1];
-}
-
-/// Read how the envelope and noise floor data is delta coded
-static void read_sbr_dtdf(SpectralBandReplication *sbr, GetBitContext *gb,
- SBRData *ch_data)
-{
- get_bits1_vector(gb, ch_data->bs_df_env, ch_data->bs_num_env);
- get_bits1_vector(gb, ch_data->bs_df_noise, ch_data->bs_num_noise);
-}
-
-/// Read inverse filtering data
-static void read_sbr_invf(SpectralBandReplication *sbr, GetBitContext *gb,
- SBRData *ch_data)
-{
- int i;
-
- memcpy(ch_data->bs_invf_mode[1], ch_data->bs_invf_mode[0], 5 * sizeof(uint8_t));
- for (i = 0; i < sbr->n_q; i++)
- ch_data->bs_invf_mode[0][i] = get_bits(gb, 2);
-}
-
-static void read_sbr_envelope(SpectralBandReplication *sbr, GetBitContext *gb,
- SBRData *ch_data, int ch)
-{
- int bits;
- int i, j, k;
- VLC_TYPE (*t_huff)[2], (*f_huff)[2];
- int t_lav, f_lav;
- const int delta = (ch == 1 && sbr->bs_coupling == 1) + 1;
- const int odd = sbr->n[1] & 1;
-
- if (sbr->bs_coupling && ch) {
- if (ch_data->bs_amp_res) {
- bits = 5;
- t_huff = vlc_sbr[T_HUFFMAN_ENV_BAL_3_0DB].table;
- t_lav = vlc_sbr_lav[T_HUFFMAN_ENV_BAL_3_0DB];
- f_huff = vlc_sbr[F_HUFFMAN_ENV_BAL_3_0DB].table;
- f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_BAL_3_0DB];
- } else {
- bits = 6;
- t_huff = vlc_sbr[T_HUFFMAN_ENV_BAL_1_5DB].table;
- t_lav = vlc_sbr_lav[T_HUFFMAN_ENV_BAL_1_5DB];
- f_huff = vlc_sbr[F_HUFFMAN_ENV_BAL_1_5DB].table;
- f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_BAL_1_5DB];
- }
- } else {
- if (ch_data->bs_amp_res) {
- bits = 6;
- t_huff = vlc_sbr[T_HUFFMAN_ENV_3_0DB].table;
- t_lav = vlc_sbr_lav[T_HUFFMAN_ENV_3_0DB];
- f_huff = vlc_sbr[F_HUFFMAN_ENV_3_0DB].table;
- f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_3_0DB];
- } else {
- bits = 7;
- t_huff = vlc_sbr[T_HUFFMAN_ENV_1_5DB].table;
- t_lav = vlc_sbr_lav[T_HUFFMAN_ENV_1_5DB];
- f_huff = vlc_sbr[F_HUFFMAN_ENV_1_5DB].table;
- f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_1_5DB];
- }
- }
-
- for (i = 0; i < ch_data->bs_num_env; i++) {
- if (ch_data->bs_df_env[i]) {
- // bs_freq_res[0] == bs_freq_res[bs_num_env] from prev frame
- if (ch_data->bs_freq_res[i + 1] == ch_data->bs_freq_res[i]) {
- for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++)
- ch_data->env_facs[i + 1][j] = ch_data->env_facs[i][j] + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav);
- } else if (ch_data->bs_freq_res[i + 1]) {
- for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) {
- k = (j + odd) >> 1; // find k such that f_tablelow[k] <= f_tablehigh[j] < f_tablelow[k + 1]
- ch_data->env_facs[i + 1][j] = ch_data->env_facs[i][k] + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav);
- }
- } else {
- for (j = 0; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++) {
- k = j ? 2*j - odd : 0; // find k such that f_tablehigh[k] == f_tablelow[j]
- ch_data->env_facs[i + 1][j] = ch_data->env_facs[i][k] + delta * (get_vlc2(gb, t_huff, 9, 3) - t_lav);
- }
- }
- } else {
- ch_data->env_facs[i + 1][0] = delta * get_bits(gb, bits); // bs_env_start_value_balance
- for (j = 1; j < sbr->n[ch_data->bs_freq_res[i + 1]]; j++)
- ch_data->env_facs[i + 1][j] = ch_data->env_facs[i + 1][j - 1] + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav);
- }
- }
-
- //assign 0th elements of env_facs from last elements
- memcpy(ch_data->env_facs[0], ch_data->env_facs[ch_data->bs_num_env],
- sizeof(ch_data->env_facs[0]));
-}
-
-static void read_sbr_noise(SpectralBandReplication *sbr, GetBitContext *gb,
- SBRData *ch_data, int ch)
-{
- int i, j;
- VLC_TYPE (*t_huff)[2], (*f_huff)[2];
- int t_lav, f_lav;
- int delta = (ch == 1 && sbr->bs_coupling == 1) + 1;
-
- if (sbr->bs_coupling && ch) {
- t_huff = vlc_sbr[T_HUFFMAN_NOISE_BAL_3_0DB].table;
- t_lav = vlc_sbr_lav[T_HUFFMAN_NOISE_BAL_3_0DB];
- f_huff = vlc_sbr[F_HUFFMAN_ENV_BAL_3_0DB].table;
- f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_BAL_3_0DB];
- } else {
- t_huff = vlc_sbr[T_HUFFMAN_NOISE_3_0DB].table;
- t_lav = vlc_sbr_lav[T_HUFFMAN_NOISE_3_0DB];
- f_huff = vlc_sbr[F_HUFFMAN_ENV_3_0DB].table;
- f_lav = vlc_sbr_lav[F_HUFFMAN_ENV_3_0DB];
- }
-
- for (i = 0; i < ch_data->bs_num_noise; i++) {
- if (ch_data->bs_df_noise[i]) {
- for (j = 0; j < sbr->n_q; j++)
- ch_data->noise_facs[i + 1][j] = ch_data->noise_facs[i][j] + delta * (get_vlc2(gb, t_huff, 9, 2) - t_lav);
- } else {
- ch_data->noise_facs[i + 1][0] = delta * get_bits(gb, 5); // bs_noise_start_value_balance or bs_noise_start_value_level
- for (j = 1; j < sbr->n_q; j++)
- ch_data->noise_facs[i + 1][j] = ch_data->noise_facs[i + 1][j - 1] + delta * (get_vlc2(gb, f_huff, 9, 3) - f_lav);
- }
- }
-
- //assign 0th elements of noise_facs from last elements
- memcpy(ch_data->noise_facs[0], ch_data->noise_facs[ch_data->bs_num_noise],
- sizeof(ch_data->noise_facs[0]));
-}
-
-static void read_sbr_extension(AACContext *ac, SpectralBandReplication *sbr,
- GetBitContext *gb,
- int bs_extension_id, int *num_bits_left)
-{
- switch (bs_extension_id) {
- case EXTENSION_ID_PS:
- if (!ac->oc[1].m4ac.ps) {
- av_log(ac->avctx, AV_LOG_ERROR, "Parametric Stereo signaled to be not-present but was found in the bitstream.\n");
- skip_bits_long(gb, *num_bits_left); // bs_fill_bits
- *num_bits_left = 0;
- } else {
-#if 1
- *num_bits_left -= ff_ps_read_data(ac->avctx, gb, &sbr->ps, *num_bits_left);
-#else
- av_log_missing_feature(ac->avctx, "Parametric Stereo", 0);
- skip_bits_long(gb, *num_bits_left); // bs_fill_bits
- *num_bits_left = 0;
-#endif
- }
- break;
- default:
- // some files contain 0-padding
- if (bs_extension_id || *num_bits_left > 16 || show_bits(gb, *num_bits_left))
- av_log_missing_feature(ac->avctx, "Reserved SBR extensions", 1);
- skip_bits_long(gb, *num_bits_left); // bs_fill_bits
- *num_bits_left = 0;
- break;
- }
-}
-
-static int read_sbr_single_channel_element(AACContext *ac,
- SpectralBandReplication *sbr,
- GetBitContext *gb)
-{
- if (get_bits1(gb)) // bs_data_extra
- skip_bits(gb, 4); // bs_reserved
-
- if (read_sbr_grid(ac, sbr, gb, &sbr->data[0]))
- return -1;
- read_sbr_dtdf(sbr, gb, &sbr->data[0]);
- read_sbr_invf(sbr, gb, &sbr->data[0]);
- read_sbr_envelope(sbr, gb, &sbr->data[0], 0);
- read_sbr_noise(sbr, gb, &sbr->data[0], 0);
-
- if ((sbr->data[0].bs_add_harmonic_flag = get_bits1(gb)))
- get_bits1_vector(gb, sbr->data[0].bs_add_harmonic, sbr->n[1]);
-
- return 0;
-}
-
-static int read_sbr_channel_pair_element(AACContext *ac,
- SpectralBandReplication *sbr,
- GetBitContext *gb)
-{
- if (get_bits1(gb)) // bs_data_extra
- skip_bits(gb, 8); // bs_reserved
-
- if ((sbr->bs_coupling = get_bits1(gb))) {
- if (read_sbr_grid(ac, sbr, gb, &sbr->data[0]))
- return -1;
- copy_sbr_grid(&sbr->data[1], &sbr->data[0]);
- read_sbr_dtdf(sbr, gb, &sbr->data[0]);
- read_sbr_dtdf(sbr, gb, &sbr->data[1]);
- read_sbr_invf(sbr, gb, &sbr->data[0]);
- memcpy(sbr->data[1].bs_invf_mode[1], sbr->data[1].bs_invf_mode[0], sizeof(sbr->data[1].bs_invf_mode[0]));
- memcpy(sbr->data[1].bs_invf_mode[0], sbr->data[0].bs_invf_mode[0], sizeof(sbr->data[1].bs_invf_mode[0]));
- read_sbr_envelope(sbr, gb, &sbr->data[0], 0);
- read_sbr_noise(sbr, gb, &sbr->data[0], 0);
- read_sbr_envelope(sbr, gb, &sbr->data[1], 1);
- read_sbr_noise(sbr, gb, &sbr->data[1], 1);
- } else {
- if (read_sbr_grid(ac, sbr, gb, &sbr->data[0]) ||
- read_sbr_grid(ac, sbr, gb, &sbr->data[1]))
- return -1;
- read_sbr_dtdf(sbr, gb, &sbr->data[0]);
- read_sbr_dtdf(sbr, gb, &sbr->data[1]);
- read_sbr_invf(sbr, gb, &sbr->data[0]);
- read_sbr_invf(sbr, gb, &sbr->data[1]);
- read_sbr_envelope(sbr, gb, &sbr->data[0], 0);
- read_sbr_envelope(sbr, gb, &sbr->data[1], 1);
- read_sbr_noise(sbr, gb, &sbr->data[0], 0);
- read_sbr_noise(sbr, gb, &sbr->data[1], 1);
- }
-
- if ((sbr->data[0].bs_add_harmonic_flag = get_bits1(gb)))
- get_bits1_vector(gb, sbr->data[0].bs_add_harmonic, sbr->n[1]);
- if ((sbr->data[1].bs_add_harmonic_flag = get_bits1(gb)))
- get_bits1_vector(gb, sbr->data[1].bs_add_harmonic, sbr->n[1]);
-
- return 0;
-}
-
-static unsigned int read_sbr_data(AACContext *ac, SpectralBandReplication *sbr,
- GetBitContext *gb, int id_aac)
-{
- unsigned int cnt = get_bits_count(gb);
-
- if (id_aac == TYPE_SCE || id_aac == TYPE_CCE) {
- if (read_sbr_single_channel_element(ac, sbr, gb)) {
- sbr_turnoff(sbr);
- return get_bits_count(gb) - cnt;
- }
- } else if (id_aac == TYPE_CPE) {
- if (read_sbr_channel_pair_element(ac, sbr, gb)) {
- sbr_turnoff(sbr);
- return get_bits_count(gb) - cnt;
- }
- } else {
- av_log(ac->avctx, AV_LOG_ERROR,
- "Invalid bitstream - cannot apply SBR to element type %d\n", id_aac);
- sbr_turnoff(sbr);
- return get_bits_count(gb) - cnt;
- }
- if (get_bits1(gb)) { // bs_extended_data
- int num_bits_left = get_bits(gb, 4); // bs_extension_size
- if (num_bits_left == 15)
- num_bits_left += get_bits(gb, 8); // bs_esc_count
-
- num_bits_left <<= 3;
- while (num_bits_left > 7) {
- num_bits_left -= 2;
- read_sbr_extension(ac, sbr, gb, get_bits(gb, 2), &num_bits_left); // bs_extension_id
- }
- if (num_bits_left < 0) {
- av_log(ac->avctx, AV_LOG_ERROR, "SBR Extension over read.\n");
- }
- if (num_bits_left > 0)
- skip_bits(gb, num_bits_left);
- }
-
- return get_bits_count(gb) - cnt;
-}
-
-static void sbr_reset(AACContext *ac, SpectralBandReplication *sbr)
-{
- int err;
- err = sbr_make_f_master(ac, sbr, &sbr->spectrum_params);
- if (err >= 0)
- err = sbr_make_f_derived(ac, sbr);
- if (err < 0) {
- av_log(ac->avctx, AV_LOG_ERROR,
- "SBR reset failed. Switching SBR to pure upsampling mode.\n");
- sbr_turnoff(sbr);
- }
-}
-
-/**
- * Decode Spectral Band Replication extension data; reference: table 4.55.
- *
- * @param crc flag indicating the presence of CRC checksum
- * @param cnt length of TYPE_FIL syntactic element in bytes
- *
- * @return Returns number of bytes consumed from the TYPE_FIL element.
- */
-int ff_decode_sbr_extension(AACContext *ac, SpectralBandReplication *sbr,
- GetBitContext *gb_host, int crc, int cnt, int id_aac)
-{
- unsigned int num_sbr_bits = 0, num_align_bits;
- unsigned bytes_read;
- GetBitContext gbc = *gb_host, *gb = &gbc;
- skip_bits_long(gb_host, cnt*8 - 4);
-
- sbr->reset = 0;
-
- if (!sbr->sample_rate)
- sbr->sample_rate = 2 * ac->oc[1].m4ac.sample_rate; //TODO use the nominal sample rate for arbitrary sample rate support
- if (!ac->oc[1].m4ac.ext_sample_rate)
- ac->oc[1].m4ac.ext_sample_rate = 2 * ac->oc[1].m4ac.sample_rate;
-
- if (crc) {
- skip_bits(gb, 10); // bs_sbr_crc_bits; TODO - implement CRC check
- num_sbr_bits += 10;
- }
-
- //Save some state from the previous frame.
- sbr->kx[0] = sbr->kx[1];
- sbr->m[0] = sbr->m[1];
- sbr->kx_and_m_pushed = 1;
-
- num_sbr_bits++;
- if (get_bits1(gb)) // bs_header_flag
- num_sbr_bits += read_sbr_header(sbr, gb);
-
- if (sbr->reset)
- sbr_reset(ac, sbr);
-
- if (sbr->start)
- num_sbr_bits += read_sbr_data(ac, sbr, gb, id_aac);
-
- num_align_bits = ((cnt << 3) - 4 - num_sbr_bits) & 7;
- bytes_read = ((num_sbr_bits + num_align_bits + 4) >> 3);
-
- if (bytes_read > cnt) {
- av_log(ac->avctx, AV_LOG_ERROR,
- "Expected to read %d SBR bytes actually read %d.\n", cnt, bytes_read);
- }
- return cnt;
-}
-
-/// Dequantization and stereo decoding (14496-3 sp04 p203)
-static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
-{
- int k, e;
- int ch;
-
- if (id_aac == TYPE_CPE && sbr->bs_coupling) {
- float alpha = sbr->data[0].bs_amp_res ? 1.0f : 0.5f;
- float pan_offset = sbr->data[0].bs_amp_res ? 12.0f : 24.0f;
- for (e = 1; e <= sbr->data[0].bs_num_env; e++) {
- for (k = 0; k < sbr->n[sbr->data[0].bs_freq_res[e]]; k++) {
- float temp1 = exp2f(sbr->data[0].env_facs[e][k] * alpha + 7.0f);
- float temp2 = exp2f((pan_offset - sbr->data[1].env_facs[e][k]) * alpha);
- float fac = temp1 / (1.0f + temp2);
- sbr->data[0].env_facs[e][k] = fac;
- sbr->data[1].env_facs[e][k] = fac * temp2;
- }
- }
- for (e = 1; e <= sbr->data[0].bs_num_noise; e++) {
- for (k = 0; k < sbr->n_q; k++) {
- float temp1 = exp2f(NOISE_FLOOR_OFFSET - sbr->data[0].noise_facs[e][k] + 1);
- float temp2 = exp2f(12 - sbr->data[1].noise_facs[e][k]);
- float fac = temp1 / (1.0f + temp2);
- sbr->data[0].noise_facs[e][k] = fac;
- sbr->data[1].noise_facs[e][k] = fac * temp2;
- }
- }
- } else { // SCE or one non-coupled CPE
- for (ch = 0; ch < (id_aac == TYPE_CPE) + 1; ch++) {
- float alpha = sbr->data[ch].bs_amp_res ? 1.0f : 0.5f;
- for (e = 1; e <= sbr->data[ch].bs_num_env; e++)
- for (k = 0; k < sbr->n[sbr->data[ch].bs_freq_res[e]]; k++)
- sbr->data[ch].env_facs[e][k] =
- exp2f(alpha * sbr->data[ch].env_facs[e][k] + 6.0f);
- for (e = 1; e <= sbr->data[ch].bs_num_noise; e++)
- for (k = 0; k < sbr->n_q; k++)
- sbr->data[ch].noise_facs[e][k] =
- exp2f(NOISE_FLOOR_OFFSET - sbr->data[ch].noise_facs[e][k]);
- }
- }
-}
-
-/**
- * Analysis QMF Bank (14496-3 sp04 p206)
- *
- * @param x pointer to the beginning of the first sample window
- * @param W array of complex-valued samples split into subbands
- */
-static void sbr_qmf_analysis(AVFloatDSPContext *dsp, FFTContext *mdct,
- SBRDSPContext *sbrdsp, const float *in, float *x,
- float z[320], float W[2][32][32][2], int buf_idx)
-{
- int i;
- memcpy(x , x+1024, (320-32)*sizeof(x[0]));
- memcpy(x+288, in, 1024*sizeof(x[0]));
- for (i = 0; i < 32; i++) { // numTimeSlots*RATE = 16*2 as 960 sample frames
- // are not supported
- dsp->vector_fmul_reverse(z, sbr_qmf_window_ds, x, 320);
- sbrdsp->sum64x5(z);
- sbrdsp->qmf_pre_shuffle(z);
- mdct->imdct_half(mdct, z, z+64);
- sbrdsp->qmf_post_shuffle(W[buf_idx][i], z);
- x += 32;
- }
-}
-
-/**
- * Synthesis QMF Bank (14496-3 sp04 p206) and Downsampled Synthesis QMF Bank
- * (14496-3 sp04 p206)
- */
-static void sbr_qmf_synthesis(FFTContext *mdct,
- SBRDSPContext *sbrdsp, AVFloatDSPContext *dsp,
- float *out, float X[2][38][64],
- float mdct_buf[2][64],
- float *v0, int *v_off, const unsigned int div)
-{
- int i, n;
- const float *sbr_qmf_window = div ? sbr_qmf_window_ds : sbr_qmf_window_us;
- const int step = 128 >> div;
- float *v;
- for (i = 0; i < 32; i++) {
- if (*v_off < step) {
- int saved_samples = (1280 - 128) >> div;
- memcpy(&v0[SBR_SYNTHESIS_BUF_SIZE - saved_samples], v0, saved_samples * sizeof(float));
- *v_off = SBR_SYNTHESIS_BUF_SIZE - saved_samples - step;
- } else {
- *v_off -= step;
- }
- v = v0 + *v_off;
- if (div) {
- for (n = 0; n < 32; n++) {
- X[0][i][ n] = -X[0][i][n];
- X[0][i][32+n] = X[1][i][31-n];
- }
- mdct->imdct_half(mdct, mdct_buf[0], X[0][i]);
- sbrdsp->qmf_deint_neg(v, mdct_buf[0]);
- } else {
- sbrdsp->neg_odd_64(X[1][i]);
- mdct->imdct_half(mdct, mdct_buf[0], X[0][i]);
- mdct->imdct_half(mdct, mdct_buf[1], X[1][i]);
- sbrdsp->qmf_deint_bfly(v, mdct_buf[1], mdct_buf[0]);
- }
- dsp->vector_fmul (out, v , sbr_qmf_window , 64 >> div);
- dsp->vector_fmul_add(out, v + ( 192 >> div), sbr_qmf_window + ( 64 >> div), out , 64 >> div);
- dsp->vector_fmul_add(out, v + ( 256 >> div), sbr_qmf_window + (128 >> div), out , 64 >> div);
- dsp->vector_fmul_add(out, v + ( 448 >> div), sbr_qmf_window + (192 >> div), out , 64 >> div);
- dsp->vector_fmul_add(out, v + ( 512 >> div), sbr_qmf_window + (256 >> div), out , 64 >> div);
- dsp->vector_fmul_add(out, v + ( 704 >> div), sbr_qmf_window + (320 >> div), out , 64 >> div);
- dsp->vector_fmul_add(out, v + ( 768 >> div), sbr_qmf_window + (384 >> div), out , 64 >> div);
- dsp->vector_fmul_add(out, v + ( 960 >> div), sbr_qmf_window + (448 >> div), out , 64 >> div);
- dsp->vector_fmul_add(out, v + (1024 >> div), sbr_qmf_window + (512 >> div), out , 64 >> div);
- dsp->vector_fmul_add(out, v + (1216 >> div), sbr_qmf_window + (576 >> div), out , 64 >> div);
- out += 64 >> div;
- }
-}
-
-/** High Frequency Generation (14496-3 sp04 p214+) and Inverse Filtering
- * (14496-3 sp04 p214)
- * Warning: This routine does not seem numerically stable.
- */
-static void sbr_hf_inverse_filter(SBRDSPContext *dsp,
- float (*alpha0)[2], float (*alpha1)[2],
- const float X_low[32][40][2], int k0)
-{
- int k;
- for (k = 0; k < k0; k++) {
- LOCAL_ALIGNED_16(float, phi, [3], [2][2]);
- float dk;
-
- dsp->autocorrelate(X_low[k], phi);
-
- dk = phi[2][1][0] * phi[1][0][0] -
- (phi[1][1][0] * phi[1][1][0] + phi[1][1][1] * phi[1][1][1]) / 1.000001f;
-
- if (!dk) {
- alpha1[k][0] = 0;
- alpha1[k][1] = 0;
- } else {
- float temp_real, temp_im;
- temp_real = phi[0][0][0] * phi[1][1][0] -
- phi[0][0][1] * phi[1][1][1] -
- phi[0][1][0] * phi[1][0][0];
- temp_im = phi[0][0][0] * phi[1][1][1] +
- phi[0][0][1] * phi[1][1][0] -
- phi[0][1][1] * phi[1][0][0];
-
- alpha1[k][0] = temp_real / dk;
- alpha1[k][1] = temp_im / dk;
- }
-
- if (!phi[1][0][0]) {
- alpha0[k][0] = 0;
- alpha0[k][1] = 0;
- } else {
- float temp_real, temp_im;
- temp_real = phi[0][0][0] + alpha1[k][0] * phi[1][1][0] +
- alpha1[k][1] * phi[1][1][1];
- temp_im = phi[0][0][1] + alpha1[k][1] * phi[1][1][0] -
- alpha1[k][0] * phi[1][1][1];
-
- alpha0[k][0] = -temp_real / phi[1][0][0];
- alpha0[k][1] = -temp_im / phi[1][0][0];
- }
-
- if (alpha1[k][0] * alpha1[k][0] + alpha1[k][1] * alpha1[k][1] >= 16.0f ||
- alpha0[k][0] * alpha0[k][0] + alpha0[k][1] * alpha0[k][1] >= 16.0f) {
- alpha1[k][0] = 0;
- alpha1[k][1] = 0;
- alpha0[k][0] = 0;
- alpha0[k][1] = 0;
- }
- }
-}
-
-/// Chirp Factors (14496-3 sp04 p214)
-static void sbr_chirp(SpectralBandReplication *sbr, SBRData *ch_data)
-{
- int i;
- float new_bw;
- static const float bw_tab[] = { 0.0f, 0.75f, 0.9f, 0.98f };
-
- for (i = 0; i < sbr->n_q; i++) {
- if (ch_data->bs_invf_mode[0][i] + ch_data->bs_invf_mode[1][i] == 1) {
- new_bw = 0.6f;
- } else
- new_bw = bw_tab[ch_data->bs_invf_mode[0][i]];
-
- if (new_bw < ch_data->bw_array[i]) {
- new_bw = 0.75f * new_bw + 0.25f * ch_data->bw_array[i];
- } else
- new_bw = 0.90625f * new_bw + 0.09375f * ch_data->bw_array[i];
- ch_data->bw_array[i] = new_bw < 0.015625f ? 0.0f : new_bw;
- }
-}
-
-/// Generate the subband filtered lowband
-static int sbr_lf_gen(AACContext *ac, SpectralBandReplication *sbr,
- float X_low[32][40][2], const float W[2][32][32][2],
- int buf_idx)
-{
- int i, k;
- const int t_HFGen = 8;
- const int i_f = 32;
- memset(X_low, 0, 32*sizeof(*X_low));
- for (k = 0; k < sbr->kx[1]; k++) {
- for (i = t_HFGen; i < i_f + t_HFGen; i++) {
- X_low[k][i][0] = W[buf_idx][i - t_HFGen][k][0];
- X_low[k][i][1] = W[buf_idx][i - t_HFGen][k][1];
- }
- }
- buf_idx = 1-buf_idx;
- for (k = 0; k < sbr->kx[0]; k++) {
- for (i = 0; i < t_HFGen; i++) {
- X_low[k][i][0] = W[buf_idx][i + i_f - t_HFGen][k][0];
- X_low[k][i][1] = W[buf_idx][i + i_f - t_HFGen][k][1];
- }
- }
- return 0;
-}
-
-/// High Frequency Generator (14496-3 sp04 p215)
-static int sbr_hf_gen(AACContext *ac, SpectralBandReplication *sbr,
- float X_high[64][40][2], const float X_low[32][40][2],
- const float (*alpha0)[2], const float (*alpha1)[2],
- const float bw_array[5], const uint8_t *t_env,
- int bs_num_env)
-{
- int j, x;
- int g = 0;
- int k = sbr->kx[1];
- for (j = 0; j < sbr->num_patches; j++) {
- for (x = 0; x < sbr->patch_num_subbands[j]; x++, k++) {
- const int p = sbr->patch_start_subband[j] + x;
- while (g <= sbr->n_q && k >= sbr->f_tablenoise[g])
- g++;
- g--;
-
- if (g < 0) {
- av_log(ac->avctx, AV_LOG_ERROR,
- "ERROR : no subband found for frequency %d\n", k);
- return -1;
- }
-
- sbr->dsp.hf_gen(X_high[k] + ENVELOPE_ADJUSTMENT_OFFSET,
- X_low[p] + ENVELOPE_ADJUSTMENT_OFFSET,
- alpha0[p], alpha1[p], bw_array[g],
- 2 * t_env[0], 2 * t_env[bs_num_env]);
- }
- }
- if (k < sbr->m[1] + sbr->kx[1])
- memset(X_high + k, 0, (sbr->m[1] + sbr->kx[1] - k) * sizeof(*X_high));
-
- return 0;
-}
-
-/// Generate the subband filtered lowband
-static int sbr_x_gen(SpectralBandReplication *sbr, float X[2][38][64],
- const float Y0[38][64][2], const float Y1[38][64][2],
- const float X_low[32][40][2], int ch)
-{
- int k, i;
- const int i_f = 32;
- const int i_Temp = FFMAX(2*sbr->data[ch].t_env_num_env_old - i_f, 0);
- memset(X, 0, 2*sizeof(*X));
- for (k = 0; k < sbr->kx[0]; k++) {
- for (i = 0; i < i_Temp; i++) {
- X[0][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][0];
- X[1][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][1];
- }
- }
- for (; k < sbr->kx[0] + sbr->m[0]; k++) {
- for (i = 0; i < i_Temp; i++) {
- X[0][i][k] = Y0[i + i_f][k][0];
- X[1][i][k] = Y0[i + i_f][k][1];
- }
- }
-
- for (k = 0; k < sbr->kx[1]; k++) {
- for (i = i_Temp; i < 38; i++) {
- X[0][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][0];
- X[1][i][k] = X_low[k][i + ENVELOPE_ADJUSTMENT_OFFSET][1];
- }
- }
- for (; k < sbr->kx[1] + sbr->m[1]; k++) {
- for (i = i_Temp; i < i_f; i++) {
- X[0][i][k] = Y1[i][k][0];
- X[1][i][k] = Y1[i][k][1];
- }
- }
- return 0;
-}
-
-/** High Frequency Adjustment (14496-3 sp04 p217) and Mapping
- * (14496-3 sp04 p217)
- */
-static int sbr_mapping(AACContext *ac, SpectralBandReplication *sbr,
- SBRData *ch_data, int e_a[2])
-{
- int e, i, m;
-
- memset(ch_data->s_indexmapped[1], 0, 7*sizeof(ch_data->s_indexmapped[1]));
- for (e = 0; e < ch_data->bs_num_env; e++) {
- const unsigned int ilim = sbr->n[ch_data->bs_freq_res[e + 1]];
- uint16_t *table = ch_data->bs_freq_res[e + 1] ? sbr->f_tablehigh : sbr->f_tablelow;
- int k;
-
- if (sbr->kx[1] != table[0]) {
- av_log(ac->avctx, AV_LOG_ERROR, "kx != f_table{high,low}[0]. "
- "Derived frequency tables were not regenerated.\n");
- sbr_turnoff(sbr);
- return AVERROR_BUG;
- }
- for (i = 0; i < ilim; i++)
- for (m = table[i]; m < table[i + 1]; m++)
- sbr->e_origmapped[e][m - sbr->kx[1]] = ch_data->env_facs[e+1][i];
-
- // ch_data->bs_num_noise > 1 => 2 noise floors
- k = (ch_data->bs_num_noise > 1) && (ch_data->t_env[e] >= ch_data->t_q[1]);
- for (i = 0; i < sbr->n_q; i++)
- for (m = sbr->f_tablenoise[i]; m < sbr->f_tablenoise[i + 1]; m++)
- sbr->q_mapped[e][m - sbr->kx[1]] = ch_data->noise_facs[k+1][i];
-
- for (i = 0; i < sbr->n[1]; i++) {
- if (ch_data->bs_add_harmonic_flag) {
- const unsigned int m_midpoint =
- (sbr->f_tablehigh[i] + sbr->f_tablehigh[i + 1]) >> 1;
-
- ch_data->s_indexmapped[e + 1][m_midpoint - sbr->kx[1]] = ch_data->bs_add_harmonic[i] *
- (e >= e_a[1] || (ch_data->s_indexmapped[0][m_midpoint - sbr->kx[1]] == 1));
- }
- }
-
- for (i = 0; i < ilim; i++) {
- int additional_sinusoid_present = 0;
- for (m = table[i]; m < table[i + 1]; m++) {
- if (ch_data->s_indexmapped[e + 1][m - sbr->kx[1]]) {
- additional_sinusoid_present = 1;
- break;
- }
- }
- memset(&sbr->s_mapped[e][table[i] - sbr->kx[1]], additional_sinusoid_present,
- (table[i + 1] - table[i]) * sizeof(sbr->s_mapped[e][0]));
- }
- }
-
- memcpy(ch_data->s_indexmapped[0], ch_data->s_indexmapped[ch_data->bs_num_env], sizeof(ch_data->s_indexmapped[0]));
- return 0;
-}
-
-/// Estimation of current envelope (14496-3 sp04 p218)
-static void sbr_env_estimate(float (*e_curr)[48], float X_high[64][40][2],
- SpectralBandReplication *sbr, SBRData *ch_data)
-{
- int e, m;
- int kx1 = sbr->kx[1];
-
- if (sbr->bs_interpol_freq) {
- for (e = 0; e < ch_data->bs_num_env; e++) {
- const float recip_env_size = 0.5f / (ch_data->t_env[e + 1] - ch_data->t_env[e]);
- int ilb = ch_data->t_env[e] * 2 + ENVELOPE_ADJUSTMENT_OFFSET;
- int iub = ch_data->t_env[e + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET;
-
- for (m = 0; m < sbr->m[1]; m++) {
- float sum = sbr->dsp.sum_square(X_high[m+kx1] + ilb, iub - ilb);
- e_curr[e][m] = sum * recip_env_size;
- }
- }
- } else {
- int k, p;
-
- for (e = 0; e < ch_data->bs_num_env; e++) {
- const int env_size = 2 * (ch_data->t_env[e + 1] - ch_data->t_env[e]);
- int ilb = ch_data->t_env[e] * 2 + ENVELOPE_ADJUSTMENT_OFFSET;
- int iub = ch_data->t_env[e + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET;
- const uint16_t *table = ch_data->bs_freq_res[e + 1] ? sbr->f_tablehigh : sbr->f_tablelow;
-
- for (p = 0; p < sbr->n[ch_data->bs_freq_res[e + 1]]; p++) {
- float sum = 0.0f;
- const int den = env_size * (table[p + 1] - table[p]);
-
- for (k = table[p]; k < table[p + 1]; k++) {
- sum += sbr->dsp.sum_square(X_high[k] + ilb, iub - ilb);
- }
- sum /= den;
- for (k = table[p]; k < table[p + 1]; k++) {
- e_curr[e][k - kx1] = sum;
- }
- }
- }
- }
-}
-
-/**
- * Calculation of levels of additional HF signal components (14496-3 sp04 p219)
- * and Calculation of gain (14496-3 sp04 p219)
- */
-static void sbr_gain_calc(AACContext *ac, SpectralBandReplication *sbr,
- SBRData *ch_data, const int e_a[2])
-{
- int e, k, m;
- // max gain limits : -3dB, 0dB, 3dB, inf dB (limiter off)
- static const float limgain[4] = { 0.70795, 1.0, 1.41254, 10000000000 };
-
- for (e = 0; e < ch_data->bs_num_env; e++) {
- int delta = !((e == e_a[1]) || (e == e_a[0]));
- for (k = 0; k < sbr->n_lim; k++) {
- float gain_boost, gain_max;
- float sum[2] = { 0.0f, 0.0f };
- for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) {
- const float temp = sbr->e_origmapped[e][m] / (1.0f + sbr->q_mapped[e][m]);
- sbr->q_m[e][m] = sqrtf(temp * sbr->q_mapped[e][m]);
- sbr->s_m[e][m] = sqrtf(temp * ch_data->s_indexmapped[e + 1][m]);
- if (!sbr->s_mapped[e][m]) {
- sbr->gain[e][m] = sqrtf(sbr->e_origmapped[e][m] /
- ((1.0f + sbr->e_curr[e][m]) *
- (1.0f + sbr->q_mapped[e][m] * delta)));
- } else {
- sbr->gain[e][m] = sqrtf(sbr->e_origmapped[e][m] * sbr->q_mapped[e][m] /
- ((1.0f + sbr->e_curr[e][m]) *
- (1.0f + sbr->q_mapped[e][m])));
- }
- }
- for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) {
- sum[0] += sbr->e_origmapped[e][m];
- sum[1] += sbr->e_curr[e][m];
- }
- gain_max = limgain[sbr->bs_limiter_gains] * sqrtf((FLT_EPSILON + sum[0]) / (FLT_EPSILON + sum[1]));
- gain_max = FFMIN(100000.f, gain_max);
- for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) {
- float q_m_max = sbr->q_m[e][m] * gain_max / sbr->gain[e][m];
- sbr->q_m[e][m] = FFMIN(sbr->q_m[e][m], q_m_max);
- sbr->gain[e][m] = FFMIN(sbr->gain[e][m], gain_max);
- }
- sum[0] = sum[1] = 0.0f;
- for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) {
- sum[0] += sbr->e_origmapped[e][m];
- sum[1] += sbr->e_curr[e][m] * sbr->gain[e][m] * sbr->gain[e][m]
- + sbr->s_m[e][m] * sbr->s_m[e][m]
- + (delta && !sbr->s_m[e][m]) * sbr->q_m[e][m] * sbr->q_m[e][m];
- }
- gain_boost = sqrtf((FLT_EPSILON + sum[0]) / (FLT_EPSILON + sum[1]));
- gain_boost = FFMIN(1.584893192f, gain_boost);
- for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) {
- sbr->gain[e][m] *= gain_boost;
- sbr->q_m[e][m] *= gain_boost;
- sbr->s_m[e][m] *= gain_boost;
- }
- }
- }
-}
-
-/// Assembling HF Signals (14496-3 sp04 p220)
-static void sbr_hf_assemble(float Y1[38][64][2],
- const float X_high[64][40][2],
- SpectralBandReplication *sbr, SBRData *ch_data,
- const int e_a[2])
-{
- int e, i, j, m;
- const int h_SL = 4 * !sbr->bs_smoothing_mode;
- const int kx = sbr->kx[1];
- const int m_max = sbr->m[1];
- static const float h_smooth[5] = {
- 0.33333333333333,
- 0.30150283239582,
- 0.21816949906249,
- 0.11516383427084,
- 0.03183050093751,
- };
- float (*g_temp)[48] = ch_data->g_temp, (*q_temp)[48] = ch_data->q_temp;
- int indexnoise = ch_data->f_indexnoise;
- int indexsine = ch_data->f_indexsine;
-
- if (sbr->reset) {
- for (i = 0; i < h_SL; i++) {
- memcpy(g_temp[i + 2*ch_data->t_env[0]], sbr->gain[0], m_max * sizeof(sbr->gain[0][0]));
- memcpy(q_temp[i + 2*ch_data->t_env[0]], sbr->q_m[0], m_max * sizeof(sbr->q_m[0][0]));
- }
- } else if (h_SL) {
- memcpy(g_temp[2*ch_data->t_env[0]], g_temp[2*ch_data->t_env_num_env_old], 4*sizeof(g_temp[0]));
- memcpy(q_temp[2*ch_data->t_env[0]], q_temp[2*ch_data->t_env_num_env_old], 4*sizeof(q_temp[0]));
- }
-
- for (e = 0; e < ch_data->bs_num_env; e++) {
- for (i = 2 * ch_data->t_env[e]; i < 2 * ch_data->t_env[e + 1]; i++) {
- memcpy(g_temp[h_SL + i], sbr->gain[e], m_max * sizeof(sbr->gain[0][0]));
- memcpy(q_temp[h_SL + i], sbr->q_m[e], m_max * sizeof(sbr->q_m[0][0]));
- }
- }
-
- for (e = 0; e < ch_data->bs_num_env; e++) {
- for (i = 2 * ch_data->t_env[e]; i < 2 * ch_data->t_env[e + 1]; i++) {
- LOCAL_ALIGNED_16(float, g_filt_tab, [48]);
- LOCAL_ALIGNED_16(float, q_filt_tab, [48]);
- float *g_filt, *q_filt;
-
- if (h_SL && e != e_a[0] && e != e_a[1]) {
- g_filt = g_filt_tab;
- q_filt = q_filt_tab;
- for (m = 0; m < m_max; m++) {
- const int idx1 = i + h_SL;
- g_filt[m] = 0.0f;
- q_filt[m] = 0.0f;
- for (j = 0; j <= h_SL; j++) {
- g_filt[m] += g_temp[idx1 - j][m] * h_smooth[j];
- q_filt[m] += q_temp[idx1 - j][m] * h_smooth[j];
- }
- }
- } else {
- g_filt = g_temp[i + h_SL];
- q_filt = q_temp[i];
- }
-
- sbr->dsp.hf_g_filt(Y1[i] + kx, X_high + kx, g_filt, m_max,
- i + ENVELOPE_ADJUSTMENT_OFFSET);
-
- if (e != e_a[0] && e != e_a[1]) {
- sbr->dsp.hf_apply_noise[indexsine](Y1[i] + kx, sbr->s_m[e],
- q_filt, indexnoise,
- kx, m_max);
- } else {
- int idx = indexsine&1;
- int A = (1-((indexsine+(kx & 1))&2));
- int B = (A^(-idx)) + idx;
- float *out = &Y1[i][kx][idx];
- float *in = sbr->s_m[e];
- for (m = 0; m+1 < m_max; m+=2) {
- out[2*m ] += in[m ] * A;
- out[2*m+2] += in[m+1] * B;
- }
- if(m_max&1)
- out[2*m ] += in[m ] * A;
- }
- indexnoise = (indexnoise + m_max) & 0x1ff;
- indexsine = (indexsine + 1) & 3;
- }
- }
- ch_data->f_indexnoise = indexnoise;
- ch_data->f_indexsine = indexsine;
-}
-
-void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac,
- float* L, float* R)
-{
- int downsampled = ac->oc[1].m4ac.ext_sample_rate < sbr->sample_rate;
- int ch;
- int nch = (id_aac == TYPE_CPE) ? 2 : 1;
- int err;
-
- if (!sbr->kx_and_m_pushed) {
- sbr->kx[0] = sbr->kx[1];
- sbr->m[0] = sbr->m[1];
- } else {
- sbr->kx_and_m_pushed = 0;
- }
-
- if (sbr->start) {
- sbr_dequant(sbr, id_aac);
- }
- for (ch = 0; ch < nch; ch++) {
- /* decode channel */
- sbr_qmf_analysis(&ac->fdsp, &sbr->mdct_ana, &sbr->dsp, ch ? R : L, sbr->data[ch].analysis_filterbank_samples,
- (float*)sbr->qmf_filter_scratch,
- sbr->data[ch].W, sbr->data[ch].Ypos);
- sbr_lf_gen(ac, sbr, sbr->X_low, sbr->data[ch].W, sbr->data[ch].Ypos);
- sbr->data[ch].Ypos ^= 1;
- if (sbr->start) {
- sbr_hf_inverse_filter(&sbr->dsp, sbr->alpha0, sbr->alpha1, sbr->X_low, sbr->k[0]);
- sbr_chirp(sbr, &sbr->data[ch]);
- sbr_hf_gen(ac, sbr, sbr->X_high, sbr->X_low, sbr->alpha0, sbr->alpha1,
- sbr->data[ch].bw_array, sbr->data[ch].t_env,
- sbr->data[ch].bs_num_env);
-
- // hf_adj
- err = sbr_mapping(ac, sbr, &sbr->data[ch], sbr->data[ch].e_a);
- if (!err) {
- sbr_env_estimate(sbr->e_curr, sbr->X_high, sbr, &sbr->data[ch]);
- sbr_gain_calc(ac, sbr, &sbr->data[ch], sbr->data[ch].e_a);
- sbr_hf_assemble(sbr->data[ch].Y[sbr->data[ch].Ypos],
- sbr->X_high, sbr, &sbr->data[ch],
- sbr->data[ch].e_a);
- }
- }
-
- /* synthesis */
- sbr_x_gen(sbr, sbr->X[ch],
- sbr->data[ch].Y[1-sbr->data[ch].Ypos],
- sbr->data[ch].Y[ sbr->data[ch].Ypos],
- sbr->X_low, ch);
- }
-
- if (ac->oc[1].m4ac.ps == 1) {
- if (sbr->ps.start) {
- ff_ps_apply(ac->avctx, &sbr->ps, sbr->X[0], sbr->X[1], sbr->kx[1] + sbr->m[1]);
- } else {
- memcpy(sbr->X[1], sbr->X[0], sizeof(sbr->X[0]));
- }
- nch = 2;
- }
-
- sbr_qmf_synthesis(&sbr->mdct, &sbr->dsp, &ac->fdsp,
- L, sbr->X[0], sbr->qmf_filter_scratch,
- sbr->data[0].synthesis_filterbank_samples,
- &sbr->data[0].synthesis_filterbank_samples_offset,
- downsampled);
- if (nch == 2)
- sbr_qmf_synthesis(&sbr->mdct, &sbr->dsp, &ac->fdsp,
- R, sbr->X[1], sbr->qmf_filter_scratch,
- sbr->data[1].synthesis_filterbank_samples,
- &sbr->data[1].synthesis_filterbank_samples_offset,
- downsampled);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/aacsbr.h b/src/thirdparty/ffmpeg/libavcodec/aacsbr.h
deleted file mode 100644
index 32d026f83..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/aacsbr.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * AAC Spectral Band Replication function declarations
- * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl )
- * Copyright (c) 2010 Alex Converse <alex.converse@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
- * AAC Spectral Band Replication function declarations
- * @author Robert Swain ( rob opendot cl )
- */
-
-#ifndef AVCODEC_AACSBR_H
-#define AVCODEC_AACSBR_H
-
-#include "get_bits.h"
-#include "aac.h"
-#include "sbr.h"
-
-/** Initialize SBR. */
-av_cold void ff_aac_sbr_init(void);
-/** Initialize one SBR context. */
-av_cold void ff_aac_sbr_ctx_init(AACContext *ac, SpectralBandReplication *sbr);
-/** Close one SBR context. */
-av_cold void ff_aac_sbr_ctx_close(SpectralBandReplication *sbr);
-/** Decode one SBR element. */
-int ff_decode_sbr_extension(AACContext *ac, SpectralBandReplication *sbr,
- GetBitContext *gb, int crc, int cnt, int id_aac);
-/** Apply one SBR element to one AAC element. */
-void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac,
- float* L, float *R);
-
-#endif /* AVCODEC_AACSBR_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/aacsbrdata.h b/src/thirdparty/ffmpeg/libavcodec/aacsbrdata.h
deleted file mode 100644
index 5f4a7a478..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/aacsbrdata.h
+++ /dev/null
@@ -1,616 +0,0 @@
-/*
- * AAC Spectral Band Replication decoding data
- * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl )
- *
- * 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
- * AAC Spectral Band Replication decoding data
- * @author Robert Swain ( rob opendot cl )
- */
-
-#ifndef AVCODEC_AACSBRDATA_H
-#define AVCODEC_AACSBRDATA_H
-
-#include <stdint.h>
-#include "libavutil/mem.h"
-
-///< Huffman tables for SBR
-
-static const uint8_t t_huffman_env_1_5dB_bits[121] = {
- 18, 18, 18, 18, 18, 18, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 17, 18, 16, 17, 18, 17,
- 16, 16, 16, 16, 15, 14, 14, 13,
- 13, 12, 11, 10, 9, 8, 7, 6,
- 5, 4, 3, 2, 2, 3, 4, 5,
- 6, 7, 8, 9, 10, 12, 13, 14,
- 14, 15, 16, 17, 16, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19,
- 19,
-};
-
-static const uint32_t t_huffman_env_1_5dB_codes[121] = {
- 0x3ffd6, 0x3ffd7, 0x3ffd8, 0x3ffd9, 0x3ffda, 0x3ffdb, 0x7ffb8, 0x7ffb9,
- 0x7ffba, 0x7ffbb, 0x7ffbc, 0x7ffbd, 0x7ffbe, 0x7ffbf, 0x7ffc0, 0x7ffc1,
- 0x7ffc2, 0x7ffc3, 0x7ffc4, 0x7ffc5, 0x7ffc6, 0x7ffc7, 0x7ffc8, 0x7ffc9,
- 0x7ffca, 0x7ffcb, 0x7ffcc, 0x7ffcd, 0x7ffce, 0x7ffcf, 0x7ffd0, 0x7ffd1,
- 0x7ffd2, 0x7ffd3, 0x1ffe6, 0x3ffd4, 0x0fff0, 0x1ffe9, 0x3ffd5, 0x1ffe7,
- 0x0fff1, 0x0ffec, 0x0ffed, 0x0ffee, 0x07ff4, 0x03ff9, 0x03ff7, 0x01ffa,
- 0x01ff9, 0x00ffb, 0x007fc, 0x003fc, 0x001fd, 0x000fd, 0x0007d, 0x0003d,
- 0x0001d, 0x0000d, 0x00005, 0x00001, 0x00000, 0x00004, 0x0000c, 0x0001c,
- 0x0003c, 0x0007c, 0x000fc, 0x001fc, 0x003fd, 0x00ffa, 0x01ff8, 0x03ff6,
- 0x03ff8, 0x07ff5, 0x0ffef, 0x1ffe8, 0x0fff2, 0x7ffd4, 0x7ffd5, 0x7ffd6,
- 0x7ffd7, 0x7ffd8, 0x7ffd9, 0x7ffda, 0x7ffdb, 0x7ffdc, 0x7ffdd, 0x7ffde,
- 0x7ffdf, 0x7ffe0, 0x7ffe1, 0x7ffe2, 0x7ffe3, 0x7ffe4, 0x7ffe5, 0x7ffe6,
- 0x7ffe7, 0x7ffe8, 0x7ffe9, 0x7ffea, 0x7ffeb, 0x7ffec, 0x7ffed, 0x7ffee,
- 0x7ffef, 0x7fff0, 0x7fff1, 0x7fff2, 0x7fff3, 0x7fff4, 0x7fff5, 0x7fff6,
- 0x7fff7, 0x7fff8, 0x7fff9, 0x7fffa, 0x7fffb, 0x7fffc, 0x7fffd, 0x7fffe,
- 0x7ffff,
-};
-
-static const uint8_t f_huffman_env_1_5dB_bits[121] = {
- 19, 19, 20, 20, 20, 20, 20, 20,
- 20, 19, 20, 20, 20, 20, 19, 20,
- 19, 19, 20, 18, 20, 20, 20, 19,
- 20, 20, 20, 19, 20, 19, 18, 19,
- 18, 18, 17, 18, 17, 17, 17, 16,
- 16, 16, 15, 15, 14, 13, 13, 12,
- 12, 11, 10, 9, 9, 8, 7, 6,
- 5, 4, 3, 2, 2, 3, 4, 5,
- 6, 8, 8, 9, 10, 11, 11, 11,
- 12, 12, 13, 13, 14, 14, 16, 16,
- 17, 17, 18, 18, 18, 18, 18, 18,
- 18, 20, 19, 20, 20, 20, 20, 20,
- 20, 19, 20, 20, 20, 20, 19, 20,
- 18, 20, 20, 19, 19, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20,
- 20,
-};
-
-static const uint32_t f_huffman_env_1_5dB_codes[121] = {
- 0x7ffe7, 0x7ffe8, 0xfffd2, 0xfffd3, 0xfffd4, 0xfffd5, 0xfffd6, 0xfffd7,
- 0xfffd8, 0x7ffda, 0xfffd9, 0xfffda, 0xfffdb, 0xfffdc, 0x7ffdb, 0xfffdd,
- 0x7ffdc, 0x7ffdd, 0xfffde, 0x3ffe4, 0xfffdf, 0xfffe0, 0xfffe1, 0x7ffde,
- 0xfffe2, 0xfffe3, 0xfffe4, 0x7ffdf, 0xfffe5, 0x7ffe0, 0x3ffe8, 0x7ffe1,
- 0x3ffe0, 0x3ffe9, 0x1ffef, 0x3ffe5, 0x1ffec, 0x1ffed, 0x1ffee, 0x0fff4,
- 0x0fff3, 0x0fff0, 0x07ff7, 0x07ff6, 0x03ffa, 0x01ffa, 0x01ff9, 0x00ffa,
- 0x00ff8, 0x007f9, 0x003fb, 0x001fc, 0x001fa, 0x000fb, 0x0007c, 0x0003c,
- 0x0001c, 0x0000c, 0x00005, 0x00001, 0x00000, 0x00004, 0x0000d, 0x0001d,
- 0x0003d, 0x000fa, 0x000fc, 0x001fb, 0x003fa, 0x007f8, 0x007fa, 0x007fb,
- 0x00ff9, 0x00ffb, 0x01ff8, 0x01ffb, 0x03ff8, 0x03ff9, 0x0fff1, 0x0fff2,
- 0x1ffea, 0x1ffeb, 0x3ffe1, 0x3ffe2, 0x3ffea, 0x3ffe3, 0x3ffe6, 0x3ffe7,
- 0x3ffeb, 0xfffe6, 0x7ffe2, 0xfffe7, 0xfffe8, 0xfffe9, 0xfffea, 0xfffeb,
- 0xfffec, 0x7ffe3, 0xfffed, 0xfffee, 0xfffef, 0xffff0, 0x7ffe4, 0xffff1,
- 0x3ffec, 0xffff2, 0xffff3, 0x7ffe5, 0x7ffe6, 0xffff4, 0xffff5, 0xffff6,
- 0xffff7, 0xffff8, 0xffff9, 0xffffa, 0xffffb, 0xffffc, 0xffffd, 0xffffe,
- 0xfffff,
-};
-
-static const uint8_t t_huffman_env_bal_1_5dB_bits[49] = {
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 12, 11, 9, 7, 5, 3,
- 1, 2, 4, 6, 8, 11, 12, 15,
- 16, 16, 16, 16, 16, 16, 16, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17,
-};
-
-static const uint32_t t_huffman_env_bal_1_5dB_codes[49] = {
- 0x0ffe4, 0x0ffe5, 0x0ffe6, 0x0ffe7, 0x0ffe8, 0x0ffe9, 0x0ffea, 0x0ffeb,
- 0x0ffec, 0x0ffed, 0x0ffee, 0x0ffef, 0x0fff0, 0x0fff1, 0x0fff2, 0x0fff3,
- 0x0fff4, 0x0ffe2, 0x00ffc, 0x007fc, 0x001fe, 0x0007e, 0x0001e, 0x00006,
- 0x00000, 0x00002, 0x0000e, 0x0003e, 0x000fe, 0x007fd, 0x00ffd, 0x07ff0,
- 0x0ffe3, 0x0fff5, 0x0fff6, 0x0fff7, 0x0fff8, 0x0fff9, 0x0fffa, 0x1fff6,
- 0x1fff7, 0x1fff8, 0x1fff9, 0x1fffa, 0x1fffb, 0x1fffc, 0x1fffd, 0x1fffe,
- 0x1ffff,
-};
-
-static const uint8_t f_huffman_env_bal_1_5dB_bits[49] = {
- 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 16,
- 17, 14, 11, 11, 8, 7, 4, 2,
- 1, 3, 5, 6, 9, 11, 12, 15,
- 16, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 19,
- 19,
-};
-
-static const uint32_t f_huffman_env_bal_1_5dB_codes[49] = {
- 0x3ffe2, 0x3ffe3, 0x3ffe4, 0x3ffe5, 0x3ffe6, 0x3ffe7, 0x3ffe8, 0x3ffe9,
- 0x3ffea, 0x3ffeb, 0x3ffec, 0x3ffed, 0x3ffee, 0x3ffef, 0x3fff0, 0x0fff7,
- 0x1fff0, 0x03ffc, 0x007fe, 0x007fc, 0x000fe, 0x0007e, 0x0000e, 0x00002,
- 0x00000, 0x00006, 0x0001e, 0x0003e, 0x001fe, 0x007fd, 0x00ffe, 0x07ffa,
- 0x0fff6, 0x3fff1, 0x3fff2, 0x3fff3, 0x3fff4, 0x3fff5, 0x3fff6, 0x3fff7,
- 0x3fff8, 0x3fff9, 0x3fffa, 0x3fffb, 0x3fffc, 0x3fffd, 0x3fffe, 0x7fffe,
- 0x7ffff,
-};
-
-static const uint8_t t_huffman_env_3_0dB_bits[63] = {
- 18, 18, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 17, 16, 16, 16, 14, 14, 14,
- 13, 12, 11, 8, 6, 4, 2, 1,
- 3, 5, 7, 9, 11, 13, 14, 14,
- 15, 16, 17, 18, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19,
-};
-
-static const uint32_t t_huffman_env_3_0dB_codes[63] = {
- 0x3ffed, 0x3ffee, 0x7ffde, 0x7ffdf, 0x7ffe0, 0x7ffe1, 0x7ffe2, 0x7ffe3,
- 0x7ffe4, 0x7ffe5, 0x7ffe6, 0x7ffe7, 0x7ffe8, 0x7ffe9, 0x7ffea, 0x7ffeb,
- 0x7ffec, 0x1fff4, 0x0fff7, 0x0fff9, 0x0fff8, 0x03ffb, 0x03ffa, 0x03ff8,
- 0x01ffa, 0x00ffc, 0x007fc, 0x000fe, 0x0003e, 0x0000e, 0x00002, 0x00000,
- 0x00006, 0x0001e, 0x0007e, 0x001fe, 0x007fd, 0x01ffb, 0x03ff9, 0x03ffc,
- 0x07ffa, 0x0fff6, 0x1fff5, 0x3ffec, 0x7ffed, 0x7ffee, 0x7ffef, 0x7fff0,
- 0x7fff1, 0x7fff2, 0x7fff3, 0x7fff4, 0x7fff5, 0x7fff6, 0x7fff7, 0x7fff8,
- 0x7fff9, 0x7fffa, 0x7fffb, 0x7fffc, 0x7fffd, 0x7fffe, 0x7ffff,
-};
-
-static const uint8_t f_huffman_env_3_0dB_bits[63] = {
- 20, 20, 20, 20, 20, 20, 20, 18,
- 19, 19, 19, 19, 18, 18, 20, 19,
- 17, 18, 17, 16, 16, 15, 14, 12,
- 11, 10, 9, 8, 6, 4, 2, 1,
- 3, 5, 8, 9, 10, 11, 12, 13,
- 14, 15, 15, 16, 16, 17, 17, 18,
- 18, 18, 20, 19, 19, 19, 20, 19,
- 19, 20, 20, 20, 20, 20, 20,
-};
-
-static const uint32_t f_huffman_env_3_0dB_codes[63] = {
- 0xffff0, 0xffff1, 0xffff2, 0xffff3, 0xffff4, 0xffff5, 0xffff6, 0x3fff3,
- 0x7fff5, 0x7ffee, 0x7ffef, 0x7fff6, 0x3fff4, 0x3fff2, 0xffff7, 0x7fff0,
- 0x1fff5, 0x3fff0, 0x1fff4, 0x0fff7, 0x0fff6, 0x07ff8, 0x03ffb, 0x00ffd,
- 0x007fd, 0x003fd, 0x001fd, 0x000fd, 0x0003e, 0x0000e, 0x00002, 0x00000,
- 0x00006, 0x0001e, 0x000fc, 0x001fc, 0x003fc, 0x007fc, 0x00ffc, 0x01ffc,
- 0x03ffa, 0x07ff9, 0x07ffa, 0x0fff8, 0x0fff9, 0x1fff6, 0x1fff7, 0x3fff5,
- 0x3fff6, 0x3fff1, 0xffff8, 0x7fff1, 0x7fff2, 0x7fff3, 0xffff9, 0x7fff7,
- 0x7fff4, 0xffffa, 0xffffb, 0xffffc, 0xffffd, 0xffffe, 0xfffff,
-};
-
-static const uint8_t t_huffman_env_bal_3_0dB_bits[25] = {
- 13, 13, 13, 13, 13, 13, 13, 12,
- 8, 7, 4, 3, 1, 2, 5, 6,
- 9, 13, 13, 13, 13, 13, 13, 14,
- 14,
-};
-
-static const uint16_t t_huffman_env_bal_3_0dB_codes[25] = {
- 0x1ff2, 0x1ff3, 0x1ff4, 0x1ff5, 0x1ff6, 0x1ff7, 0x1ff8, 0x0ff8,
- 0x00fe, 0x007e, 0x000e, 0x0006, 0x0000, 0x0002, 0x001e, 0x003e,
- 0x01fe, 0x1ff9, 0x1ffa, 0x1ffb, 0x1ffc, 0x1ffd, 0x1ffe, 0x3ffe,
- 0x3fff,
-};
-
-static const uint8_t f_huffman_env_bal_3_0dB_bits[25] = {
- 13, 13, 13, 13, 13, 14, 14, 11,
- 8, 7, 4, 2, 1, 3, 5, 6,
- 9, 12, 13, 14, 14, 14, 14, 14,
- 14,
-};
-
-static const uint16_t f_huffman_env_bal_3_0dB_codes[25] = {
- 0x1ff7, 0x1ff8, 0x1ff9, 0x1ffa, 0x1ffb, 0x3ff8, 0x3ff9, 0x07fc,
- 0x00fe, 0x007e, 0x000e, 0x0002, 0x0000, 0x0006, 0x001e, 0x003e,
- 0x01fe, 0x0ffa, 0x1ff6, 0x3ffa, 0x3ffb, 0x3ffc, 0x3ffd, 0x3ffe,
- 0x3fff,
-};
-
-static const uint8_t t_huffman_noise_3_0dB_bits[63] = {
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 11, 8, 6, 4, 3, 1,
- 2, 5, 8, 10, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 14, 14,
-};
-
-static const uint16_t t_huffman_noise_3_0dB_codes[63] = {
- 0x1fce, 0x1fcf, 0x1fd0, 0x1fd1, 0x1fd2, 0x1fd3, 0x1fd4, 0x1fd5,
- 0x1fd6, 0x1fd7, 0x1fd8, 0x1fd9, 0x1fda, 0x1fdb, 0x1fdc, 0x1fdd,
- 0x1fde, 0x1fdf, 0x1fe0, 0x1fe1, 0x1fe2, 0x1fe3, 0x1fe4, 0x1fe5,
- 0x1fe6, 0x1fe7, 0x07f2, 0x00fd, 0x003e, 0x000e, 0x0006, 0x0000,
- 0x0002, 0x001e, 0x00fc, 0x03f8, 0x1fcc, 0x1fe8, 0x1fe9, 0x1fea,
- 0x1feb, 0x1fec, 0x1fcd, 0x1fed, 0x1fee, 0x1fef, 0x1ff0, 0x1ff1,
- 0x1ff2, 0x1ff3, 0x1ff4, 0x1ff5, 0x1ff6, 0x1ff7, 0x1ff8, 0x1ff9,
- 0x1ffa, 0x1ffb, 0x1ffc, 0x1ffd, 0x1ffe, 0x3ffe, 0x3fff,
-};
-
-static const uint8_t t_huffman_noise_bal_3_0dB_bits[25] = {
- 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 5, 2, 1, 3, 6, 8,
- 8, 8, 8, 8, 8, 8, 8, 8,
- 8,
-};
-
-static const uint8_t t_huffman_noise_bal_3_0dB_codes[25] = {
- 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3,
- 0xf4, 0xf5, 0x1c, 0x02, 0x00, 0x06, 0x3a, 0xf6,
- 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe,
- 0xff,
-};
-
-static const int8_t sbr_offset[6][16] = {
- {-8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7}, // fs_sbr = 16000 Hz
- {-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13}, // fs_sbr = 22050 Hz
- {-5, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16}, // fs_sbr = 24000 Hz
- {-6, -4, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16}, // fs_sbr = 32000 Hz
- {-4, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20}, // 44100 Hz <= fs_sbr <= 64000 Hz
- {-2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 16, 20, 24}, // 64000 Hz < fs_sbr
-};
-
-///< window coefficients for analysis/synthesis QMF banks
-static DECLARE_ALIGNED(32, float, sbr_qmf_window_ds)[320];
-static DECLARE_ALIGNED(32, float, sbr_qmf_window_us)[640] = {
- 0.0000000000, -0.0005525286, -0.0005617692, -0.0004947518,
- -0.0004875227, -0.0004893791, -0.0005040714, -0.0005226564,
- -0.0005466565, -0.0005677802, -0.0005870930, -0.0006132747,
- -0.0006312493, -0.0006540333, -0.0006777690, -0.0006941614,
- -0.0007157736, -0.0007255043, -0.0007440941, -0.0007490598,
- -0.0007681371, -0.0007724848, -0.0007834332, -0.0007779869,
- -0.0007803664, -0.0007801449, -0.0007757977, -0.0007630793,
- -0.0007530001, -0.0007319357, -0.0007215391, -0.0006917937,
- -0.0006650415, -0.0006341594, -0.0005946118, -0.0005564576,
- -0.0005145572, -0.0004606325, -0.0004095121, -0.0003501175,
- -0.0002896981, -0.0002098337, -0.0001446380, -0.0000617334,
- 0.0000134949, 0.0001094383, 0.0002043017, 0.0002949531,
- 0.0004026540, 0.0005107388, 0.0006239376, 0.0007458025,
- 0.0008608443, 0.0009885988, 0.0011250155, 0.0012577884,
- 0.0013902494, 0.0015443219, 0.0016868083, 0.0018348265,
- 0.0019841140, 0.0021461583, 0.0023017254, 0.0024625616,
- 0.0026201758, 0.0027870464, 0.0029469447, 0.0031125420,
- 0.0032739613, 0.0034418874, 0.0036008268, 0.0037603922,
- 0.0039207432, 0.0040819753, 0.0042264269, 0.0043730719,
- 0.0045209852, 0.0046606460, 0.0047932560, 0.0049137603,
- 0.0050393022, 0.0051407353, 0.0052461166, 0.0053471681,
- 0.0054196775, 0.0054876040, 0.0055475714, 0.0055938023,
- 0.0056220643, 0.0056455196, 0.0056389199, 0.0056266114,
- 0.0055917128, 0.0055404363, 0.0054753783, 0.0053838975,
- 0.0052715758, 0.0051382275, 0.0049839687, 0.0048109469,
- 0.0046039530, 0.0043801861, 0.0041251642, 0.0038456408,
- 0.0035401246, 0.0032091885, 0.0028446757, 0.0024508540,
- 0.0020274176, 0.0015784682, 0.0010902329, 0.0005832264,
- 0.0000276045, -0.0005464280, -0.0011568135, -0.0018039472,
- -0.0024826723, -0.0031933778, -0.0039401124, -0.0047222596,
- -0.0055337211, -0.0063792293, -0.0072615816, -0.0081798233,
- -0.0091325329, -0.0101150215, -0.0111315548, -0.0121849995,
- 0.0132718220, 0.0143904666, 0.0155405553, 0.0167324712,
- 0.0179433381, 0.0191872431, 0.0204531793, 0.0217467550,
- 0.0230680169, 0.0244160992, 0.0257875847, 0.0271859429,
- 0.0286072173, 0.0300502657, 0.0315017608, 0.0329754081,
- 0.0344620948, 0.0359697560, 0.0374812850, 0.0390053679,
- 0.0405349170, 0.0420649094, 0.0436097542, 0.0451488405,
- 0.0466843027, 0.0482165720, 0.0497385755, 0.0512556155,
- 0.0527630746, 0.0542452768, 0.0557173648, 0.0571616450,
- 0.0585915683, 0.0599837480, 0.0613455171, 0.0626857808,
- 0.0639715898, 0.0652247106, 0.0664367512, 0.0676075985,
- 0.0687043828, 0.0697630244, 0.0707628710, 0.0717002673,
- 0.0725682583, 0.0733620255, 0.0741003642, 0.0747452558,
- 0.0753137336, 0.0758008358, 0.0761992479, 0.0764992170,
- 0.0767093490, 0.0768173975, 0.0768230011, 0.0767204924,
- 0.0765050718, 0.0761748321, 0.0757305756, 0.0751576255,
- 0.0744664394, 0.0736406005, 0.0726774642, 0.0715826364,
- 0.0703533073, 0.0689664013, 0.0674525021, 0.0657690668,
- 0.0639444805, 0.0619602779, 0.0598166570, 0.0575152691,
- 0.0550460034, 0.0524093821, 0.0495978676, 0.0466303305,
- 0.0434768782, 0.0401458278, 0.0366418116, 0.0329583930,
- 0.0290824006, 0.0250307561, 0.0207997072, 0.0163701258,
- 0.0117623832, 0.0069636862, 0.0019765601, -0.0032086896,
- -0.0085711749, -0.0141288827, -0.0198834129, -0.0258227288,
- -0.0319531274, -0.0382776572, -0.0447806821, -0.0514804176,
- -0.0583705326, -0.0654409853, -0.0726943300, -0.0801372934,
- -0.0877547536, -0.0955533352, -0.1035329531, -0.1116826931,
- -0.1200077984, -0.1285002850, -0.1371551761, -0.1459766491,
- -0.1549607071, -0.1640958855, -0.1733808172, -0.1828172548,
- -0.1923966745, -0.2021250176, -0.2119735853, -0.2219652696,
- -0.2320690870, -0.2423016884, -0.2526480309, -0.2631053299,
- -0.2736634040, -0.2843214189, -0.2950716717, -0.3059098575,
- -0.3168278913, -0.3278113727, -0.3388722693, -0.3499914122,
- 0.3611589903, 0.3723795546, 0.3836350013, 0.3949211761,
- 0.4062317676, 0.4175696896, 0.4289119920, 0.4402553754,
- 0.4515996535, 0.4629308085, 0.4742453214, 0.4855253091,
- 0.4967708254, 0.5079817500, 0.5191234970, 0.5302240895,
- 0.5412553448, 0.5522051258, 0.5630789140, 0.5738524131,
- 0.5845403235, 0.5951123086, 0.6055783538, 0.6159109932,
- 0.6261242695, 0.6361980107, 0.6461269695, 0.6559016302,
- 0.6655139880, 0.6749663190, 0.6842353293, 0.6933282376,
- 0.7022388719, 0.7109410426, 0.7194462634, 0.7277448900,
- 0.7358211758, 0.7436827863, 0.7513137456, 0.7587080760,
- 0.7658674865, 0.7727780881, 0.7794287519, 0.7858353120,
- 0.7919735841, 0.7978466413, 0.8034485751, 0.8087695004,
- 0.8138191270, 0.8185776004, 0.8230419890, 0.8272275347,
- 0.8311038457, 0.8346937361, 0.8379717337, 0.8409541392,
- 0.8436238281, 0.8459818469, 0.8480315777, 0.8497805198,
- 0.8511971524, 0.8523047035, 0.8531020949, 0.8535720573,
- 0.8537385600,
-};
-
-/* First two entries repeated at end to simplify SIMD implementations. */
-const DECLARE_ALIGNED(16, float, ff_sbr_noise_table)[][2] = {
-{-0.99948153278296, -0.59483417516607}, { 0.97113454393991, -0.67528515225647},
-{ 0.14130051758487, -0.95090983575689}, {-0.47005496701697, -0.37340549728647},
-{ 0.80705063769351, 0.29653668284408}, {-0.38981478896926, 0.89572605717087},
-{-0.01053049862020, -0.66959058036166}, {-0.91266367957293, -0.11522938140034},
-{ 0.54840422910309, 0.75221367176302}, { 0.40009252867955, -0.98929400334421},
-{-0.99867974711855, -0.88147068645358}, {-0.95531076805040, 0.90908757154593},
-{-0.45725933317144, -0.56716323646760}, {-0.72929675029275, -0.98008272727324},
-{ 0.75622801399036, 0.20950329995549}, { 0.07069442601050, -0.78247898470706},
-{ 0.74496252926055, -0.91169004445807}, {-0.96440182703856, -0.94739918296622},
-{ 0.30424629369539, -0.49438267012479}, { 0.66565033746925, 0.64652935542491},
-{ 0.91697008020594, 0.17514097332009}, {-0.70774918760427, 0.52548653416543},
-{-0.70051415345560, -0.45340028808763}, {-0.99496513054797, -0.90071908066973},
-{ 0.98164490790123, -0.77463155528697}, {-0.54671580548181, -0.02570928536004},
-{-0.01689629065389, 0.00287506445732}, {-0.86110349531986, 0.42548583726477},
-{-0.98892980586032, -0.87881132267556}, { 0.51756627678691, 0.66926784710139},
-{-0.99635026409640, -0.58107730574765}, {-0.99969370862163, 0.98369989360250},
-{ 0.55266258627194, 0.59449057465591}, { 0.34581177741673, 0.94879421061866},
-{ 0.62664209577999, -0.74402970906471}, {-0.77149701404973, -0.33883658042801},
-{-0.91592244254432, 0.03687901376713}, {-0.76285492357887, -0.91371867919124},
-{ 0.79788337195331, -0.93180971199849}, { 0.54473080610200, -0.11919206037186},
-{-0.85639281671058, 0.42429854760451}, {-0.92882402971423, 0.27871809078609},
-{-0.11708371046774, -0.99800843444966}, { 0.21356749817493, -0.90716295627033},
-{-0.76191692573909, 0.99768118356265}, { 0.98111043100884, -0.95854459734407},
-{-0.85913269895572, 0.95766566168880}, {-0.93307242253692, 0.49431757696466},
-{ 0.30485754879632, -0.70540034357529}, { 0.85289650925190, 0.46766131791044},
-{ 0.91328082618125, -0.99839597361769}, {-0.05890199924154, 0.70741827819497},
-{ 0.28398686150148, 0.34633555702188}, { 0.95258164539612, -0.54893416026939},
-{-0.78566324168507, -0.75568541079691}, {-0.95789495447877, -0.20423194696966},
-{ 0.82411158711197, 0.96654618432562}, {-0.65185446735885, -0.88734990773289},
-{-0.93643603134666, 0.99870790442385}, { 0.91427159529618, -0.98290505544444},
-{-0.70395684036886, 0.58796798221039}, { 0.00563771969365, 0.61768196727244},
-{ 0.89065051931895, 0.52783352697585}, {-0.68683707712762, 0.80806944710339},
-{ 0.72165342518718, -0.69259857349564}, {-0.62928247730667, 0.13627037407335},
-{ 0.29938434065514, -0.46051329682246}, {-0.91781958879280, -0.74012716684186},
-{ 0.99298717043688, 0.40816610075661}, { 0.82368298622748, -0.74036047190173},
-{-0.98512833386833, -0.99972330709594}, {-0.95915368242257, -0.99237800466040},
-{-0.21411126572790, -0.93424819052545}, {-0.68821476106884, -0.26892306315457},
-{ 0.91851997982317, 0.09358228901785}, {-0.96062769559127, 0.36099095133739},
-{ 0.51646184922287, -0.71373332873917}, { 0.61130721139669, 0.46950141175917},
-{ 0.47336129371299, -0.27333178296162}, { 0.90998308703519, 0.96715662938132},
-{ 0.44844799194357, 0.99211574628306}, { 0.66614891079092, 0.96590176169121},
-{ 0.74922239129237, -0.89879858826087}, {-0.99571588506485, 0.52785521494349},
-{ 0.97401082477563, -0.16855870075190}, { 0.72683747733879, -0.48060774432251},
-{ 0.95432193457128, 0.68849603408441}, {-0.72962208425191, -0.76608443420917},
-{-0.85359479233537, 0.88738125901579}, {-0.81412430338535, -0.97480768049637},
-{-0.87930772356786, 0.74748307690436}, {-0.71573331064977, -0.98570608178923},
-{ 0.83524300028228, 0.83702537075163}, {-0.48086065601423, -0.98848504923531},
-{ 0.97139128574778, 0.80093621198236}, { 0.51992825347895, 0.80247631400510},
-{-0.00848591195325, -0.76670128000486}, {-0.70294374303036, 0.55359910445577},
-{-0.95894428168140, -0.43265504344783}, { 0.97079252950321, 0.09325857238682},
-{-0.92404293670797, 0.85507704027855}, {-0.69506469500450, 0.98633412625459},
-{ 0.26559203620024, 0.73314307966524}, { 0.28038443336943, 0.14537913654427},
-{-0.74138124825523, 0.99310339807762}, {-0.01752795995444, -0.82616635284178},
-{-0.55126773094930, -0.98898543862153}, { 0.97960898850996, -0.94021446752851},
-{-0.99196309146936, 0.67019017358456}, {-0.67684928085260, 0.12631491649378},
-{ 0.09140039465500, -0.20537731453108}, {-0.71658965751996, -0.97788200391224},
-{ 0.81014640078925, 0.53722648362443}, { 0.40616991671205, -0.26469008598449},
-{-0.67680188682972, 0.94502052337695}, { 0.86849774348749, -0.18333598647899},
-{-0.99500381284851, -0.02634122068550}, { 0.84329189340667, 0.10406957462213},
-{-0.09215968531446, 0.69540012101253}, { 0.99956173327206, -0.12358542001404},
-{-0.79732779473535, -0.91582524736159}, { 0.96349973642406, 0.96640458041000},
-{-0.79942778496547, 0.64323902822857}, {-0.11566039853896, 0.28587846253726},
-{-0.39922954514662, 0.94129601616966}, { 0.99089197565987, -0.92062625581587},
-{ 0.28631285179909, -0.91035047143603}, {-0.83302725605608, -0.67330410892084},
-{ 0.95404443402072, 0.49162765398743}, {-0.06449863579434, 0.03250560813135},
-{-0.99575054486311, 0.42389784469507}, {-0.65501142790847, 0.82546114655624},
-{-0.81254441908887, -0.51627234660629}, {-0.99646369485481, 0.84490533520752},
-{ 0.00287840603348, 0.64768261158166}, { 0.70176989408455, -0.20453028573322},
-{ 0.96361882270190, 0.40706967140989}, {-0.68883758192426, 0.91338958840772},
-{-0.34875585502238, 0.71472290693300}, { 0.91980081243087, 0.66507455644919},
-{-0.99009048343881, 0.85868021604848}, { 0.68865791458395, 0.55660316809678},
-{-0.99484402129368, -0.20052559254934}, { 0.94214511408023, -0.99696425367461},
-{-0.67414626793544, 0.49548221180078}, {-0.47339353684664, -0.85904328834047},
-{ 0.14323651387360, -0.94145598222488}, {-0.29268293575672, 0.05759224927952},
-{ 0.43793861458754, -0.78904969892724}, {-0.36345126374441, 0.64874435357162},
-{-0.08750604656825, 0.97686944362527}, {-0.96495267812511, -0.53960305946511},
-{ 0.55526940659947, 0.78891523734774}, { 0.73538215752630, 0.96452072373404},
-{-0.30889773919437, -0.80664389776860}, { 0.03574995626194, -0.97325616900959},
-{ 0.98720684660488, 0.48409133691962}, {-0.81689296271203, -0.90827703628298},
-{ 0.67866860118215, 0.81284503870856}, {-0.15808569732583, 0.85279555024382},
-{ 0.80723395114371, -0.24717418514605}, { 0.47788757329038, -0.46333147839295},
-{ 0.96367554763201, 0.38486749303242}, {-0.99143875716818, -0.24945277239809},
-{ 0.83081876925833, -0.94780851414763}, {-0.58753191905341, 0.01290772389163},
-{ 0.95538108220960, -0.85557052096538}, {-0.96490920476211, -0.64020970923102},
-{-0.97327101028521, 0.12378128133110}, { 0.91400366022124, 0.57972471346930},
-{-0.99925837363824, 0.71084847864067}, {-0.86875903507313, -0.20291699203564},
-{-0.26240034795124, -0.68264554369108}, {-0.24664412953388, -0.87642273115183},
-{ 0.02416275806869, 0.27192914288905}, { 0.82068619590515, -0.85087787994476},
-{ 0.88547373760759, -0.89636802901469}, {-0.18173078152226, -0.26152145156800},
-{ 0.09355476558534, 0.54845123045604}, {-0.54668414224090, 0.95980774020221},
-{ 0.37050990604091, -0.59910140383171}, {-0.70373594262891, 0.91227665827081},
-{-0.34600785879594, -0.99441426144200}, {-0.68774481731008, -0.30238837956299},
-{-0.26843291251234, 0.83115668004362}, { 0.49072334613242, -0.45359708737775},
-{ 0.38975993093975, 0.95515358099121}, {-0.97757125224150, 0.05305894580606},
-{-0.17325552859616, -0.92770672250494}, { 0.99948035025744, 0.58285545563426},
-{-0.64946246527458, 0.68645507104960}, {-0.12016920576437, -0.57147322153312},
-{-0.58947456517751, -0.34847132454388}, {-0.41815140454465, 0.16276422358861},
-{ 0.99885650204884, 0.11136095490444}, {-0.56649614128386, -0.90494866361587},
-{ 0.94138021032330, 0.35281916733018}, {-0.75725076534641, 0.53650549640587},
-{ 0.20541973692630, -0.94435144369918}, { 0.99980371023351, 0.79835913565599},
-{ 0.29078277605775, 0.35393777921520}, {-0.62858772103030, 0.38765693387102},
-{ 0.43440904467688, -0.98546330463232}, {-0.98298583762390, 0.21021524625209},
-{ 0.19513029146934, -0.94239832251867}, {-0.95476662400101, 0.98364554179143},
-{ 0.93379635304810, -0.70881994583682}, {-0.85235410573336, -0.08342347966410},
-{-0.86425093011245, -0.45795025029466}, { 0.38879779059045, 0.97274429344593},
-{ 0.92045124735495, -0.62433652524220}, { 0.89162532251878, 0.54950955570563},
-{-0.36834336949252, 0.96458298020975}, { 0.93891760988045, -0.89968353740388},
-{ 0.99267657565094, -0.03757034316958}, {-0.94063471614176, 0.41332338538963},
-{ 0.99740224117019, -0.16830494996370}, {-0.35899413170555, -0.46633226649613},
-{ 0.05237237274947, -0.25640361602661}, { 0.36703583957424, -0.38653265641875},
-{ 0.91653180367913, -0.30587628726597}, { 0.69000803499316, 0.90952171386132},
-{-0.38658751133527, 0.99501571208985}, {-0.29250814029851, 0.37444994344615},
-{-0.60182204677608, 0.86779651036123}, {-0.97418588163217, 0.96468523666475},
-{ 0.88461574003963, 0.57508405276414}, { 0.05198933055162, 0.21269661669964},
-{-0.53499621979720, 0.97241553731237}, {-0.49429560226497, 0.98183865291903},
-{-0.98935142339139, -0.40249159006933}, {-0.98081380091130, -0.72856895534041},
-{-0.27338148835532, 0.99950922447209}, { 0.06310802338302, -0.54539587529618},
-{-0.20461677199539, -0.14209977628489}, { 0.66223843141647, 0.72528579940326},
-{-0.84764345483665, 0.02372316801261}, {-0.89039863483811, 0.88866581484602},
-{ 0.95903308477986, 0.76744927173873}, { 0.73504123909879, -0.03747203173192},
-{-0.31744434966056, -0.36834111883652}, {-0.34110827591623, 0.40211222807691},
-{ 0.47803883714199, -0.39423219786288}, { 0.98299195879514, 0.01989791390047},
-{-0.30963073129751, -0.18076720599336}, { 0.99992588229018, -0.26281872094289},
-{-0.93149731080767, -0.98313162570490}, { 0.99923472302773, -0.80142993767554},
-{-0.26024169633417, -0.75999759855752}, {-0.35712514743563, 0.19298963768574},
-{-0.99899084509530, 0.74645156992493}, { 0.86557171579452, 0.55593866696299},
-{ 0.33408042438752, 0.86185953874709}, { 0.99010736374716, 0.04602397576623},
-{-0.66694269691195, -0.91643611810148}, { 0.64016792079480, 0.15649530836856},
-{ 0.99570534804836, 0.45844586038111}, {-0.63431466947340, 0.21079116459234},
-{-0.07706847005931, -0.89581437101329}, { 0.98590090577724, 0.88241721133981},
-{ 0.80099335254678, -0.36851896710853}, { 0.78368131392666, 0.45506999802597},
-{ 0.08707806671691, 0.80938994918745}, {-0.86811883080712, 0.39347308654705},
-{-0.39466529740375, -0.66809432114456}, { 0.97875325649683, -0.72467840967746},
-{-0.95038560288864, 0.89563219587625}, { 0.17005239424212, 0.54683053962658},
-{-0.76910792026848, -0.96226617549298}, { 0.99743281016846, 0.42697157037567},
-{ 0.95437383549973, 0.97002324109952}, { 0.99578905365569, -0.54106826257356},
-{ 0.28058259829990, -0.85361420634036}, { 0.85256524470573, -0.64567607735589},
-{-0.50608540105128, -0.65846015480300}, {-0.97210735183243, -0.23095213067791},
-{ 0.95424048234441, -0.99240147091219}, {-0.96926570524023, 0.73775654896574},
-{ 0.30872163214726, 0.41514960556126}, {-0.24523839572639, 0.63206633394807},
-{-0.33813265086024, -0.38661779441897}, {-0.05826828420146, -0.06940774188029},
-{-0.22898461455054, 0.97054853316316}, {-0.18509915019881, 0.47565762892084},
-{-0.10488238045009, -0.87769947402394}, {-0.71886586182037, 0.78030982480538},
-{ 0.99793873738654, 0.90041310491497}, { 0.57563307626120, -0.91034337352097},
-{ 0.28909646383717, 0.96307783970534}, { 0.42188998312520, 0.48148651230437},
-{ 0.93335049681047, -0.43537023883588}, {-0.97087374418267, 0.86636445711364},
-{ 0.36722871286923, 0.65291654172961}, {-0.81093025665696, 0.08778370229363},
-{-0.26240603062237, -0.92774095379098}, { 0.83996497984604, 0.55839849139647},
-{-0.99909615720225, -0.96024605713970}, { 0.74649464155061, 0.12144893606462},
-{-0.74774595569805, -0.26898062008959}, { 0.95781667469567, -0.79047927052628},
-{ 0.95472308713099, -0.08588776019550}, { 0.48708332746299, 0.99999041579432},
-{ 0.46332038247497, 0.10964126185063}, {-0.76497004940162, 0.89210929242238},
-{ 0.57397389364339, 0.35289703373760}, { 0.75374316974495, 0.96705214651335},
-{-0.59174397685714, -0.89405370422752}, { 0.75087906691890, -0.29612672982396},
-{-0.98607857336230, 0.25034911730023}, {-0.40761056640505, -0.90045573444695},
-{ 0.66929266740477, 0.98629493401748}, {-0.97463695257310, -0.00190223301301},
-{ 0.90145509409859, 0.99781390365446}, {-0.87259289048043, 0.99233587353666},
-{-0.91529461447692, -0.15698707534206}, {-0.03305738840705, -0.37205262859764},
-{ 0.07223051368337, -0.88805001733626}, { 0.99498012188353, 0.97094358113387},
-{-0.74904939500519, 0.99985483641521}, { 0.04585228574211, 0.99812337444082},
-{-0.89054954257993, -0.31791913188064}, {-0.83782144651251, 0.97637632547466},
-{ 0.33454804933804, -0.86231516800408}, {-0.99707579362824, 0.93237990079441},
-{-0.22827527843994, 0.18874759397997}, { 0.67248046289143, -0.03646211390569},
-{-0.05146538187944, -0.92599700120679}, { 0.99947295749905, 0.93625229707912},
-{ 0.66951124390363, 0.98905825623893}, {-0.99602956559179, -0.44654715757688},
-{ 0.82104905483590, 0.99540741724928}, { 0.99186510988782, 0.72023001312947},
-{-0.65284592392918, 0.52186723253637}, { 0.93885443798188, -0.74895312615259},
-{ 0.96735248738388, 0.90891816978629}, {-0.22225968841114, 0.57124029781228},
-{-0.44132783753414, -0.92688840659280}, {-0.85694974219574, 0.88844532719844},
-{ 0.91783042091762, -0.46356892383970}, { 0.72556974415690, -0.99899555770747},
-{-0.99711581834508, 0.58211560180426}, { 0.77638976371966, 0.94321834873819},
-{ 0.07717324253925, 0.58638399856595}, {-0.56049829194163, 0.82522301569036},
-{ 0.98398893639988, 0.39467440420569}, { 0.47546946844938, 0.68613044836811},
-{ 0.65675089314631, 0.18331637134880}, { 0.03273375457980, -0.74933109564108},
-{-0.38684144784738, 0.51337349030406}, {-0.97346267944545, -0.96549364384098},
-{-0.53282156061942, -0.91423265091354}, { 0.99817310731176, 0.61133572482148},
-{-0.50254500772635, -0.88829338134294}, { 0.01995873238855, 0.85223515096765},
-{ 0.99930381973804, 0.94578896296649}, { 0.82907767600783, -0.06323442598128},
-{-0.58660709669728, 0.96840773806582}, {-0.17573736667267, -0.48166920859485},
-{ 0.83434292401346, -0.13023450646997}, { 0.05946491307025, 0.20511047074866},
-{ 0.81505484574602, -0.94685947861369}, {-0.44976380954860, 0.40894572671545},
-{-0.89746474625671, 0.99846578838537}, { 0.39677256130792, -0.74854668609359},
-{-0.07588948563079, 0.74096214084170}, { 0.76343198951445, 0.41746629422634},
-{-0.74490104699626, 0.94725911744610}, { 0.64880119792759, 0.41336660830571},
-{ 0.62319537462542, -0.93098313552599}, { 0.42215817594807, -0.07712787385208},
-{ 0.02704554141885, -0.05417518053666}, { 0.80001773566818, 0.91542195141039},
-{-0.79351832348816, -0.36208897989136}, { 0.63872359151636, 0.08128252493444},
-{ 0.52890520960295, 0.60048872455592}, { 0.74238552914587, 0.04491915291044},
-{ 0.99096131449250, -0.19451182854402}, {-0.80412329643109, -0.88513818199457},
-{-0.64612616129736, 0.72198674804544}, { 0.11657770663191, -0.83662833815041},
-{-0.95053182488101, -0.96939905138082}, {-0.62228872928622, 0.82767262846661},
-{ 0.03004475787316, -0.99738896333384}, {-0.97987214341034, 0.36526129686425},
-{-0.99986980746200, -0.36021610299715}, { 0.89110648599879, -0.97894250343044},
-{ 0.10407960510582, 0.77357793811619}, { 0.95964737821728, -0.35435818285502},
-{ 0.50843233159162, 0.96107691266205}, { 0.17006334670615, -0.76854025314829},
-{ 0.25872675063360, 0.99893303933816}, {-0.01115998681937, 0.98496019742444},
-{-0.79598702973261, 0.97138411318894}, {-0.99264708948101, -0.99542822402536},
-{-0.99829663752818, 0.01877138824311}, {-0.70801016548184, 0.33680685948117},
-{-0.70467057786826, 0.93272777501857}, { 0.99846021905254, -0.98725746254433},
-{-0.63364968534650, -0.16473594423746}, {-0.16258217500792, -0.95939125400802},
-{-0.43645594360633, -0.94805030113284}, {-0.99848471702976, 0.96245166923809},
-{-0.16796458968998, -0.98987511890470}, {-0.87979225745213, -0.71725725041680},
-{ 0.44183099021786, -0.93568974498761}, { 0.93310180125532, -0.99913308068246},
-{-0.93941931782002, -0.56409379640356}, {-0.88590003188677, 0.47624600491382},
-{ 0.99971463703691, -0.83889954253462}, {-0.75376385639978, 0.00814643438625},
-{ 0.93887685615875, -0.11284528204636}, { 0.85126435782309, 0.52349251543547},
-{ 0.39701421446381, 0.81779634174316}, {-0.37024464187437, -0.87071656222959},
-{-0.36024828242896, 0.34655735648287}, {-0.93388812549209, -0.84476541096429},
-{-0.65298804552119, -0.18439575450921}, { 0.11960319006843, 0.99899346780168},
-{ 0.94292565553160, 0.83163906518293}, { 0.75081145286948, -0.35533223142265},
-{ 0.56721979748394, -0.24076836414499}, { 0.46857766746029, -0.30140233457198},
-{ 0.97312313923635, -0.99548191630031}, {-0.38299976567017, 0.98516909715427},
-{ 0.41025800019463, 0.02116736935734}, { 0.09638062008048, 0.04411984381457},
-{-0.85283249275397, 0.91475563922421}, { 0.88866808958124, -0.99735267083226},
-{-0.48202429536989, -0.96805608884164}, { 0.27572582416567, 0.58634753335832},
-{-0.65889129659168, 0.58835634138583}, { 0.98838086953732, 0.99994349600236},
-{-0.20651349620689, 0.54593044066355}, {-0.62126416356920, -0.59893681700392},
-{ 0.20320105410437, -0.86879180355289}, {-0.97790548600584, 0.96290806999242},
-{ 0.11112534735126, 0.21484763313301}, {-0.41368337314182, 0.28216837680365},
-{ 0.24133038992960, 0.51294362630238}, {-0.66393410674885, -0.08249679629081},
-{-0.53697829178752, -0.97649903936228}, {-0.97224737889348, 0.22081333579837},
-{ 0.87392477144549, -0.12796173740361}, { 0.19050361015753, 0.01602615387195},
-{-0.46353441212724, -0.95249041539006}, {-0.07064096339021, -0.94479803205886},
-{-0.92444085484466, -0.10457590187436}, {-0.83822593578728, -0.01695043208885},
-{ 0.75214681811150, -0.99955681042665}, {-0.42102998829339, 0.99720941999394},
-{-0.72094786237696, -0.35008961934255}, { 0.78843311019251, 0.52851398958271},
-{ 0.97394027897442, -0.26695944086561}, { 0.99206463477946, -0.57010120849429},
-{ 0.76789609461795, -0.76519356730966}, {-0.82002421836409, -0.73530179553767},
-{ 0.81924990025724, 0.99698425250579}, {-0.26719850873357, 0.68903369776193},
-{-0.43311260380975, 0.85321815947490}, { 0.99194979673836, 0.91876249766422},
-{-0.80692001248487, -0.32627540663214}, { 0.43080003649976, -0.21919095636638},
-{ 0.67709491937357, -0.95478075822906}, { 0.56151770568316, -0.70693811747778},
-{ 0.10831862810749, -0.08628837174592}, { 0.91229417540436, -0.65987351408410},
-{-0.48972893932274, 0.56289246362686}, {-0.89033658689697, -0.71656563987082},
-{ 0.65269447475094, 0.65916004833932}, { 0.67439478141121, -0.81684380846796},
-{-0.47770832416973, -0.16789556203025}, {-0.99715979260878, -0.93565784007648},
-{-0.90889593602546, 0.62034397054380}, {-0.06618622548177, -0.23812217221359},
-{ 0.99430266919728, 0.18812555317553}, { 0.97686402381843, -0.28664534366620},
-{ 0.94813650221268, -0.97506640027128}, {-0.95434497492853, -0.79607978501983},
-{-0.49104783137150, 0.32895214359663}, { 0.99881175120751, 0.88993983831354},
-{ 0.50449166760303, -0.85995072408434}, { 0.47162891065108, -0.18680204049569},
-{-0.62081581361840, 0.75000676218956}, {-0.43867015250812, 0.99998069244322},
-{ 0.98630563232075, -0.53578899600662}, {-0.61510362277374, -0.89515019899997},
-{-0.03841517601843, -0.69888815681179}, {-0.30102157304644, -0.07667808922205},
-{ 0.41881284182683, 0.02188098922282}, {-0.86135454941237, 0.98947480909359},
-{ 0.67226861393788, -0.13494389011014}, {-0.70737398842068, -0.76547349325992},
-{ 0.94044946687963, 0.09026201157416}, {-0.82386352534327, 0.08924768823676},
-{-0.32070666698656, 0.50143421908753}, { 0.57593163224487, -0.98966422921509},
-{-0.36326018419965, 0.07440243123228}, { 0.99979044674350, -0.14130287347405},
-{-0.92366023326932, -0.97979298068180}, {-0.44607178518598, -0.54233252016394},
-{ 0.44226800932956, 0.71326756742752}, { 0.03671907158312, 0.63606389366675},
-{ 0.52175424682195, -0.85396826735705}, {-0.94701139690956, -0.01826348194255},
-{-0.98759606946049, 0.82288714303073}, { 0.87434794743625, 0.89399495655433},
-{-0.93412041758744, 0.41374052024363}, { 0.96063943315511, 0.93116709541280},
-{ 0.97534253457837, 0.86150930812689}, { 0.99642466504163, 0.70190043427512},
-{-0.94705089665984, -0.29580042814306}, { 0.91599807087376, -0.98147830385781},
-{-0.99948153278296, -0.59483417516607}, { 0.97113454393991, -0.67528515225647},
-};
-
-#endif /* AVCODEC_AACSBRDATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/aactab.c b/src/thirdparty/ffmpeg/libavcodec/aactab.c
deleted file mode 100644
index 403459744..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/aactab.c
+++ /dev/null
@@ -1,1207 +0,0 @@
-/*
- * AAC data
- * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org )
- * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov 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
- * AAC data
- * @author Oded Shimon ( ods15 ods15 dyndns org )
- * @author Maxim Gavrilov ( maxim.gavrilov gmail com )
- */
-
-#include "libavutil/mem.h"
-#include "aac.h"
-#include "aac_tablegen.h"
-
-#include <stdint.h>
-
-DECLARE_ALIGNED(32, float, ff_aac_kbd_long_1024)[1024];
-DECLARE_ALIGNED(32, float, ff_aac_kbd_short_128)[128];
-
-const uint8_t ff_aac_num_swb_1024[] = {
- 41, 41, 47, 49, 49, 51, 47, 47, 43, 43, 43, 40, 40
-};
-
-const uint8_t ff_aac_num_swb_128[] = {
- 12, 12, 12, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15
-};
-
-const uint8_t ff_aac_pred_sfb_max[] = {
- 33, 33, 38, 40, 40, 40, 41, 41, 37, 37, 37, 34, 34
-};
-
-const uint32_t ff_aac_scalefactor_code[121] = {
- 0x3ffe8, 0x3ffe6, 0x3ffe7, 0x3ffe5, 0x7fff5, 0x7fff1, 0x7ffed, 0x7fff6,
- 0x7ffee, 0x7ffef, 0x7fff0, 0x7fffc, 0x7fffd, 0x7ffff, 0x7fffe, 0x7fff7,
- 0x7fff8, 0x7fffb, 0x7fff9, 0x3ffe4, 0x7fffa, 0x3ffe3, 0x1ffef, 0x1fff0,
- 0x0fff5, 0x1ffee, 0x0fff2, 0x0fff3, 0x0fff4, 0x0fff1, 0x07ff6, 0x07ff7,
- 0x03ff9, 0x03ff5, 0x03ff7, 0x03ff3, 0x03ff6, 0x03ff2, 0x01ff7, 0x01ff5,
- 0x00ff9, 0x00ff7, 0x00ff6, 0x007f9, 0x00ff4, 0x007f8, 0x003f9, 0x003f7,
- 0x003f5, 0x001f8, 0x001f7, 0x000fa, 0x000f8, 0x000f6, 0x00079, 0x0003a,
- 0x00038, 0x0001a, 0x0000b, 0x00004, 0x00000, 0x0000a, 0x0000c, 0x0001b,
- 0x00039, 0x0003b, 0x00078, 0x0007a, 0x000f7, 0x000f9, 0x001f6, 0x001f9,
- 0x003f4, 0x003f6, 0x003f8, 0x007f5, 0x007f4, 0x007f6, 0x007f7, 0x00ff5,
- 0x00ff8, 0x01ff4, 0x01ff6, 0x01ff8, 0x03ff8, 0x03ff4, 0x0fff0, 0x07ff4,
- 0x0fff6, 0x07ff5, 0x3ffe2, 0x7ffd9, 0x7ffda, 0x7ffdb, 0x7ffdc, 0x7ffdd,
- 0x7ffde, 0x7ffd8, 0x7ffd2, 0x7ffd3, 0x7ffd4, 0x7ffd5, 0x7ffd6, 0x7fff2,
- 0x7ffdf, 0x7ffe7, 0x7ffe8, 0x7ffe9, 0x7ffea, 0x7ffeb, 0x7ffe6, 0x7ffe0,
- 0x7ffe1, 0x7ffe2, 0x7ffe3, 0x7ffe4, 0x7ffe5, 0x7ffd7, 0x7ffec, 0x7fff4,
- 0x7fff3,
-};
-
-const uint8_t ff_aac_scalefactor_bits[121] = {
- 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 18, 19, 18, 17, 17, 16, 17, 16, 16, 16, 16, 15, 15,
- 14, 14, 14, 14, 14, 14, 13, 13, 12, 12, 12, 11, 12, 11, 10, 10,
- 10, 9, 9, 8, 8, 8, 7, 6, 6, 5, 4, 3, 1, 4, 4, 5,
- 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10, 11, 11, 11, 11, 12,
- 12, 13, 13, 13, 14, 14, 16, 15, 16, 15, 18, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19,
-};
-
-static const uint16_t codes1[81] = {
- 0x7f8, 0x1f1, 0x7fd, 0x3f5, 0x068, 0x3f0, 0x7f7, 0x1ec,
- 0x7f5, 0x3f1, 0x072, 0x3f4, 0x074, 0x011, 0x076, 0x1eb,
- 0x06c, 0x3f6, 0x7fc, 0x1e1, 0x7f1, 0x1f0, 0x061, 0x1f6,
- 0x7f2, 0x1ea, 0x7fb, 0x1f2, 0x069, 0x1ed, 0x077, 0x017,
- 0x06f, 0x1e6, 0x064, 0x1e5, 0x067, 0x015, 0x062, 0x012,
- 0x000, 0x014, 0x065, 0x016, 0x06d, 0x1e9, 0x063, 0x1e4,
- 0x06b, 0x013, 0x071, 0x1e3, 0x070, 0x1f3, 0x7fe, 0x1e7,
- 0x7f3, 0x1ef, 0x060, 0x1ee, 0x7f0, 0x1e2, 0x7fa, 0x3f3,
- 0x06a, 0x1e8, 0x075, 0x010, 0x073, 0x1f4, 0x06e, 0x3f7,
- 0x7f6, 0x1e0, 0x7f9, 0x3f2, 0x066, 0x1f5, 0x7ff, 0x1f7,
- 0x7f4,
-};
-
-static const uint8_t bits1[81] = {
- 11, 9, 11, 10, 7, 10, 11, 9, 11, 10, 7, 10, 7, 5, 7, 9,
- 7, 10, 11, 9, 11, 9, 7, 9, 11, 9, 11, 9, 7, 9, 7, 5,
- 7, 9, 7, 9, 7, 5, 7, 5, 1, 5, 7, 5, 7, 9, 7, 9,
- 7, 5, 7, 9, 7, 9, 11, 9, 11, 9, 7, 9, 11, 9, 11, 10,
- 7, 9, 7, 5, 7, 9, 7, 10, 11, 9, 11, 10, 7, 9, 11, 9,
- 11,
-};
-
-static const uint16_t codes2[81] = {
- 0x1f3, 0x06f, 0x1fd, 0x0eb, 0x023, 0x0ea, 0x1f7, 0x0e8,
- 0x1fa, 0x0f2, 0x02d, 0x070, 0x020, 0x006, 0x02b, 0x06e,
- 0x028, 0x0e9, 0x1f9, 0x066, 0x0f8, 0x0e7, 0x01b, 0x0f1,
- 0x1f4, 0x06b, 0x1f5, 0x0ec, 0x02a, 0x06c, 0x02c, 0x00a,
- 0x027, 0x067, 0x01a, 0x0f5, 0x024, 0x008, 0x01f, 0x009,
- 0x000, 0x007, 0x01d, 0x00b, 0x030, 0x0ef, 0x01c, 0x064,
- 0x01e, 0x00c, 0x029, 0x0f3, 0x02f, 0x0f0, 0x1fc, 0x071,
- 0x1f2, 0x0f4, 0x021, 0x0e6, 0x0f7, 0x068, 0x1f8, 0x0ee,
- 0x022, 0x065, 0x031, 0x002, 0x026, 0x0ed, 0x025, 0x06a,
- 0x1fb, 0x072, 0x1fe, 0x069, 0x02e, 0x0f6, 0x1ff, 0x06d,
- 0x1f6,
-};
-
-static const uint8_t bits2[81] = {
- 9, 7, 9, 8, 6, 8, 9, 8, 9, 8, 6, 7, 6, 5, 6, 7,
- 6, 8, 9, 7, 8, 8, 6, 8, 9, 7, 9, 8, 6, 7, 6, 5,
- 6, 7, 6, 8, 6, 5, 6, 5, 3, 5, 6, 5, 6, 8, 6, 7,
- 6, 5, 6, 8, 6, 8, 9, 7, 9, 8, 6, 8, 8, 7, 9, 8,
- 6, 7, 6, 4, 6, 8, 6, 7, 9, 7, 9, 7, 6, 8, 9, 7,
- 9,
-};
-
-static const uint16_t codes3[81] = {
- 0x0000, 0x0009, 0x00ef, 0x000b, 0x0019, 0x00f0, 0x01eb, 0x01e6,
- 0x03f2, 0x000a, 0x0035, 0x01ef, 0x0034, 0x0037, 0x01e9, 0x01ed,
- 0x01e7, 0x03f3, 0x01ee, 0x03ed, 0x1ffa, 0x01ec, 0x01f2, 0x07f9,
- 0x07f8, 0x03f8, 0x0ff8, 0x0008, 0x0038, 0x03f6, 0x0036, 0x0075,
- 0x03f1, 0x03eb, 0x03ec, 0x0ff4, 0x0018, 0x0076, 0x07f4, 0x0039,
- 0x0074, 0x03ef, 0x01f3, 0x01f4, 0x07f6, 0x01e8, 0x03ea, 0x1ffc,
- 0x00f2, 0x01f1, 0x0ffb, 0x03f5, 0x07f3, 0x0ffc, 0x00ee, 0x03f7,
- 0x7ffe, 0x01f0, 0x07f5, 0x7ffd, 0x1ffb, 0x3ffa, 0xffff, 0x00f1,
- 0x03f0, 0x3ffc, 0x01ea, 0x03ee, 0x3ffb, 0x0ff6, 0x0ffa, 0x7ffc,
- 0x07f2, 0x0ff5, 0xfffe, 0x03f4, 0x07f7, 0x7ffb, 0x0ff7, 0x0ff9,
- 0x7ffa,
-};
-
-static const uint8_t bits3[81] = {
- 1, 4, 8, 4, 5, 8, 9, 9, 10, 4, 6, 9, 6, 6, 9, 9,
- 9, 10, 9, 10, 13, 9, 9, 11, 11, 10, 12, 4, 6, 10, 6, 7,
- 10, 10, 10, 12, 5, 7, 11, 6, 7, 10, 9, 9, 11, 9, 10, 13,
- 8, 9, 12, 10, 11, 12, 8, 10, 15, 9, 11, 15, 13, 14, 16, 8,
- 10, 14, 9, 10, 14, 12, 12, 15, 11, 12, 16, 10, 11, 15, 12, 12,
- 15,
-};
-
-static const uint16_t codes4[81] = {
- 0x007, 0x016, 0x0f6, 0x018, 0x008, 0x0ef, 0x1ef, 0x0f3,
- 0x7f8, 0x019, 0x017, 0x0ed, 0x015, 0x001, 0x0e2, 0x0f0,
- 0x070, 0x3f0, 0x1ee, 0x0f1, 0x7fa, 0x0ee, 0x0e4, 0x3f2,
- 0x7f6, 0x3ef, 0x7fd, 0x005, 0x014, 0x0f2, 0x009, 0x004,
- 0x0e5, 0x0f4, 0x0e8, 0x3f4, 0x006, 0x002, 0x0e7, 0x003,
- 0x000, 0x06b, 0x0e3, 0x069, 0x1f3, 0x0eb, 0x0e6, 0x3f6,
- 0x06e, 0x06a, 0x1f4, 0x3ec, 0x1f0, 0x3f9, 0x0f5, 0x0ec,
- 0x7fb, 0x0ea, 0x06f, 0x3f7, 0x7f9, 0x3f3, 0xfff, 0x0e9,
- 0x06d, 0x3f8, 0x06c, 0x068, 0x1f5, 0x3ee, 0x1f2, 0x7f4,
- 0x7f7, 0x3f1, 0xffe, 0x3ed, 0x1f1, 0x7f5, 0x7fe, 0x3f5,
- 0x7fc,
-};
-
-static const uint8_t bits4[81] = {
- 4, 5, 8, 5, 4, 8, 9, 8, 11, 5, 5, 8, 5, 4, 8, 8,
- 7, 10, 9, 8, 11, 8, 8, 10, 11, 10, 11, 4, 5, 8, 4, 4,
- 8, 8, 8, 10, 4, 4, 8, 4, 4, 7, 8, 7, 9, 8, 8, 10,
- 7, 7, 9, 10, 9, 10, 8, 8, 11, 8, 7, 10, 11, 10, 12, 8,
- 7, 10, 7, 7, 9, 10, 9, 11, 11, 10, 12, 10, 9, 11, 11, 10,
- 11,
-};
-
-static const uint16_t codes5[81] = {
- 0x1fff, 0x0ff7, 0x07f4, 0x07e8, 0x03f1, 0x07ee, 0x07f9, 0x0ff8,
- 0x1ffd, 0x0ffd, 0x07f1, 0x03e8, 0x01e8, 0x00f0, 0x01ec, 0x03ee,
- 0x07f2, 0x0ffa, 0x0ff4, 0x03ef, 0x01f2, 0x00e8, 0x0070, 0x00ec,
- 0x01f0, 0x03ea, 0x07f3, 0x07eb, 0x01eb, 0x00ea, 0x001a, 0x0008,
- 0x0019, 0x00ee, 0x01ef, 0x07ed, 0x03f0, 0x00f2, 0x0073, 0x000b,
- 0x0000, 0x000a, 0x0071, 0x00f3, 0x07e9, 0x07ef, 0x01ee, 0x00ef,
- 0x0018, 0x0009, 0x001b, 0x00eb, 0x01e9, 0x07ec, 0x07f6, 0x03eb,
- 0x01f3, 0x00ed, 0x0072, 0x00e9, 0x01f1, 0x03ed, 0x07f7, 0x0ff6,
- 0x07f0, 0x03e9, 0x01ed, 0x00f1, 0x01ea, 0x03ec, 0x07f8, 0x0ff9,
- 0x1ffc, 0x0ffc, 0x0ff5, 0x07ea, 0x03f3, 0x03f2, 0x07f5, 0x0ffb,
- 0x1ffe,
-};
-
-static const uint8_t bits5[81] = {
- 13, 12, 11, 11, 10, 11, 11, 12, 13, 12, 11, 10, 9, 8, 9, 10,
- 11, 12, 12, 10, 9, 8, 7, 8, 9, 10, 11, 11, 9, 8, 5, 4,
- 5, 8, 9, 11, 10, 8, 7, 4, 1, 4, 7, 8, 11, 11, 9, 8,
- 5, 4, 5, 8, 9, 11, 11, 10, 9, 8, 7, 8, 9, 10, 11, 12,
- 11, 10, 9, 8, 9, 10, 11, 12, 13, 12, 12, 11, 10, 10, 11, 12,
- 13,
-};
-
-static const uint16_t codes6[81] = {
- 0x7fe, 0x3fd, 0x1f1, 0x1eb, 0x1f4, 0x1ea, 0x1f0, 0x3fc,
- 0x7fd, 0x3f6, 0x1e5, 0x0ea, 0x06c, 0x071, 0x068, 0x0f0,
- 0x1e6, 0x3f7, 0x1f3, 0x0ef, 0x032, 0x027, 0x028, 0x026,
- 0x031, 0x0eb, 0x1f7, 0x1e8, 0x06f, 0x02e, 0x008, 0x004,
- 0x006, 0x029, 0x06b, 0x1ee, 0x1ef, 0x072, 0x02d, 0x002,
- 0x000, 0x003, 0x02f, 0x073, 0x1fa, 0x1e7, 0x06e, 0x02b,
- 0x007, 0x001, 0x005, 0x02c, 0x06d, 0x1ec, 0x1f9, 0x0ee,
- 0x030, 0x024, 0x02a, 0x025, 0x033, 0x0ec, 0x1f2, 0x3f8,
- 0x1e4, 0x0ed, 0x06a, 0x070, 0x069, 0x074, 0x0f1, 0x3fa,
- 0x7ff, 0x3f9, 0x1f6, 0x1ed, 0x1f8, 0x1e9, 0x1f5, 0x3fb,
- 0x7fc,
-};
-
-static const uint8_t bits6[81] = {
- 11, 10, 9, 9, 9, 9, 9, 10, 11, 10, 9, 8, 7, 7, 7, 8,
- 9, 10, 9, 8, 6, 6, 6, 6, 6, 8, 9, 9, 7, 6, 4, 4,
- 4, 6, 7, 9, 9, 7, 6, 4, 4, 4, 6, 7, 9, 9, 7, 6,
- 4, 4, 4, 6, 7, 9, 9, 8, 6, 6, 6, 6, 6, 8, 9, 10,
- 9, 8, 7, 7, 7, 7, 8, 10, 11, 10, 9, 9, 9, 9, 9, 10,
- 11,
-};
-
-static const uint16_t codes7[64] = {
- 0x000, 0x005, 0x037, 0x074, 0x0f2, 0x1eb, 0x3ed, 0x7f7,
- 0x004, 0x00c, 0x035, 0x071, 0x0ec, 0x0ee, 0x1ee, 0x1f5,
- 0x036, 0x034, 0x072, 0x0ea, 0x0f1, 0x1e9, 0x1f3, 0x3f5,
- 0x073, 0x070, 0x0eb, 0x0f0, 0x1f1, 0x1f0, 0x3ec, 0x3fa,
- 0x0f3, 0x0ed, 0x1e8, 0x1ef, 0x3ef, 0x3f1, 0x3f9, 0x7fb,
- 0x1ed, 0x0ef, 0x1ea, 0x1f2, 0x3f3, 0x3f8, 0x7f9, 0x7fc,
- 0x3ee, 0x1ec, 0x1f4, 0x3f4, 0x3f7, 0x7f8, 0xffd, 0xffe,
- 0x7f6, 0x3f0, 0x3f2, 0x3f6, 0x7fa, 0x7fd, 0xffc, 0xfff,
-};
-
-static const uint8_t bits7[64] = {
- 1, 3, 6, 7, 8, 9, 10, 11, 3, 4, 6, 7, 8, 8, 9, 9,
- 6, 6, 7, 8, 8, 9, 9, 10, 7, 7, 8, 8, 9, 9, 10, 10,
- 8, 8, 9, 9, 10, 10, 10, 11, 9, 8, 9, 9, 10, 10, 11, 11,
- 10, 9, 9, 10, 10, 11, 12, 12, 11, 10, 10, 10, 11, 11, 12, 12,
-};
-
-static const uint16_t codes8[64] = {
- 0x00e, 0x005, 0x010, 0x030, 0x06f, 0x0f1, 0x1fa, 0x3fe,
- 0x003, 0x000, 0x004, 0x012, 0x02c, 0x06a, 0x075, 0x0f8,
- 0x00f, 0x002, 0x006, 0x014, 0x02e, 0x069, 0x072, 0x0f5,
- 0x02f, 0x011, 0x013, 0x02a, 0x032, 0x06c, 0x0ec, 0x0fa,
- 0x071, 0x02b, 0x02d, 0x031, 0x06d, 0x070, 0x0f2, 0x1f9,
- 0x0ef, 0x068, 0x033, 0x06b, 0x06e, 0x0ee, 0x0f9, 0x3fc,
- 0x1f8, 0x074, 0x073, 0x0ed, 0x0f0, 0x0f6, 0x1f6, 0x1fd,
- 0x3fd, 0x0f3, 0x0f4, 0x0f7, 0x1f7, 0x1fb, 0x1fc, 0x3ff,
-};
-
-static const uint8_t bits8[64] = {
- 5, 4, 5, 6, 7, 8, 9, 10, 4, 3, 4, 5, 6, 7, 7, 8,
- 5, 4, 4, 5, 6, 7, 7, 8, 6, 5, 5, 6, 6, 7, 8, 8,
- 7, 6, 6, 6, 7, 7, 8, 9, 8, 7, 6, 7, 7, 8, 8, 10,
- 9, 7, 7, 8, 8, 8, 9, 9, 10, 8, 8, 8, 9, 9, 9, 10,
-};
-
-static const uint16_t codes9[169] = {
- 0x0000, 0x0005, 0x0037, 0x00e7, 0x01de, 0x03ce, 0x03d9, 0x07c8,
- 0x07cd, 0x0fc8, 0x0fdd, 0x1fe4, 0x1fec, 0x0004, 0x000c, 0x0035,
- 0x0072, 0x00ea, 0x00ed, 0x01e2, 0x03d1, 0x03d3, 0x03e0, 0x07d8,
- 0x0fcf, 0x0fd5, 0x0036, 0x0034, 0x0071, 0x00e8, 0x00ec, 0x01e1,
- 0x03cf, 0x03dd, 0x03db, 0x07d0, 0x0fc7, 0x0fd4, 0x0fe4, 0x00e6,
- 0x0070, 0x00e9, 0x01dd, 0x01e3, 0x03d2, 0x03dc, 0x07cc, 0x07ca,
- 0x07de, 0x0fd8, 0x0fea, 0x1fdb, 0x01df, 0x00eb, 0x01dc, 0x01e6,
- 0x03d5, 0x03de, 0x07cb, 0x07dd, 0x07dc, 0x0fcd, 0x0fe2, 0x0fe7,
- 0x1fe1, 0x03d0, 0x01e0, 0x01e4, 0x03d6, 0x07c5, 0x07d1, 0x07db,
- 0x0fd2, 0x07e0, 0x0fd9, 0x0feb, 0x1fe3, 0x1fe9, 0x07c4, 0x01e5,
- 0x03d7, 0x07c6, 0x07cf, 0x07da, 0x0fcb, 0x0fda, 0x0fe3, 0x0fe9,
- 0x1fe6, 0x1ff3, 0x1ff7, 0x07d3, 0x03d8, 0x03e1, 0x07d4, 0x07d9,
- 0x0fd3, 0x0fde, 0x1fdd, 0x1fd9, 0x1fe2, 0x1fea, 0x1ff1, 0x1ff6,
- 0x07d2, 0x03d4, 0x03da, 0x07c7, 0x07d7, 0x07e2, 0x0fce, 0x0fdb,
- 0x1fd8, 0x1fee, 0x3ff0, 0x1ff4, 0x3ff2, 0x07e1, 0x03df, 0x07c9,
- 0x07d6, 0x0fca, 0x0fd0, 0x0fe5, 0x0fe6, 0x1feb, 0x1fef, 0x3ff3,
- 0x3ff4, 0x3ff5, 0x0fe0, 0x07ce, 0x07d5, 0x0fc6, 0x0fd1, 0x0fe1,
- 0x1fe0, 0x1fe8, 0x1ff0, 0x3ff1, 0x3ff8, 0x3ff6, 0x7ffc, 0x0fe8,
- 0x07df, 0x0fc9, 0x0fd7, 0x0fdc, 0x1fdc, 0x1fdf, 0x1fed, 0x1ff5,
- 0x3ff9, 0x3ffb, 0x7ffd, 0x7ffe, 0x1fe7, 0x0fcc, 0x0fd6, 0x0fdf,
- 0x1fde, 0x1fda, 0x1fe5, 0x1ff2, 0x3ffa, 0x3ff7, 0x3ffc, 0x3ffd,
- 0x7fff,
-};
-
-static const uint8_t bits9[169] = {
- 1, 3, 6, 8, 9, 10, 10, 11, 11, 12, 12, 13, 13, 3, 4, 6,
- 7, 8, 8, 9, 10, 10, 10, 11, 12, 12, 6, 6, 7, 8, 8, 9,
- 10, 10, 10, 11, 12, 12, 12, 8, 7, 8, 9, 9, 10, 10, 11, 11,
- 11, 12, 12, 13, 9, 8, 9, 9, 10, 10, 11, 11, 11, 12, 12, 12,
- 13, 10, 9, 9, 10, 11, 11, 11, 12, 11, 12, 12, 13, 13, 11, 9,
- 10, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 11, 10, 10, 11, 11,
- 12, 12, 13, 13, 13, 13, 13, 13, 11, 10, 10, 11, 11, 11, 12, 12,
- 13, 13, 14, 13, 14, 11, 10, 11, 11, 12, 12, 12, 12, 13, 13, 14,
- 14, 14, 12, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 12,
- 11, 12, 12, 12, 13, 13, 13, 13, 14, 14, 15, 15, 13, 12, 12, 12,
- 13, 13, 13, 13, 14, 14, 14, 14, 15,
-};
-
-static const uint16_t codes10[169] = {
- 0x022, 0x008, 0x01d, 0x026, 0x05f, 0x0d3, 0x1cf, 0x3d0,
- 0x3d7, 0x3ed, 0x7f0, 0x7f6, 0xffd, 0x007, 0x000, 0x001,
- 0x009, 0x020, 0x054, 0x060, 0x0d5, 0x0dc, 0x1d4, 0x3cd,
- 0x3de, 0x7e7, 0x01c, 0x002, 0x006, 0x00c, 0x01e, 0x028,
- 0x05b, 0x0cd, 0x0d9, 0x1ce, 0x1dc, 0x3d9, 0x3f1, 0x025,
- 0x00b, 0x00a, 0x00d, 0x024, 0x057, 0x061, 0x0cc, 0x0dd,
- 0x1cc, 0x1de, 0x3d3, 0x3e7, 0x05d, 0x021, 0x01f, 0x023,
- 0x027, 0x059, 0x064, 0x0d8, 0x0df, 0x1d2, 0x1e2, 0x3dd,
- 0x3ee, 0x0d1, 0x055, 0x029, 0x056, 0x058, 0x062, 0x0ce,
- 0x0e0, 0x0e2, 0x1da, 0x3d4, 0x3e3, 0x7eb, 0x1c9, 0x05e,
- 0x05a, 0x05c, 0x063, 0x0ca, 0x0da, 0x1c7, 0x1ca, 0x1e0,
- 0x3db, 0x3e8, 0x7ec, 0x1e3, 0x0d2, 0x0cb, 0x0d0, 0x0d7,
- 0x0db, 0x1c6, 0x1d5, 0x1d8, 0x3ca, 0x3da, 0x7ea, 0x7f1,
- 0x1e1, 0x0d4, 0x0cf, 0x0d6, 0x0de, 0x0e1, 0x1d0, 0x1d6,
- 0x3d1, 0x3d5, 0x3f2, 0x7ee, 0x7fb, 0x3e9, 0x1cd, 0x1c8,
- 0x1cb, 0x1d1, 0x1d7, 0x1df, 0x3cf, 0x3e0, 0x3ef, 0x7e6,
- 0x7f8, 0xffa, 0x3eb, 0x1dd, 0x1d3, 0x1d9, 0x1db, 0x3d2,
- 0x3cc, 0x3dc, 0x3ea, 0x7ed, 0x7f3, 0x7f9, 0xff9, 0x7f2,
- 0x3ce, 0x1e4, 0x3cb, 0x3d8, 0x3d6, 0x3e2, 0x3e5, 0x7e8,
- 0x7f4, 0x7f5, 0x7f7, 0xffb, 0x7fa, 0x3ec, 0x3df, 0x3e1,
- 0x3e4, 0x3e6, 0x3f0, 0x7e9, 0x7ef, 0xff8, 0xffe, 0xffc,
- 0xfff,
-};
-
-static const uint8_t bits10[169] = {
- 6, 5, 6, 6, 7, 8, 9, 10, 10, 10, 11, 11, 12, 5, 4, 4,
- 5, 6, 7, 7, 8, 8, 9, 10, 10, 11, 6, 4, 5, 5, 6, 6,
- 7, 8, 8, 9, 9, 10, 10, 6, 5, 5, 5, 6, 7, 7, 8, 8,
- 9, 9, 10, 10, 7, 6, 6, 6, 6, 7, 7, 8, 8, 9, 9, 10,
- 10, 8, 7, 6, 7, 7, 7, 8, 8, 8, 9, 10, 10, 11, 9, 7,
- 7, 7, 7, 8, 8, 9, 9, 9, 10, 10, 11, 9, 8, 8, 8, 8,
- 8, 9, 9, 9, 10, 10, 11, 11, 9, 8, 8, 8, 8, 8, 9, 9,
- 10, 10, 10, 11, 11, 10, 9, 9, 9, 9, 9, 9, 10, 10, 10, 11,
- 11, 12, 10, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 12, 11,
- 10, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 12, 11, 10, 10, 10,
- 10, 10, 10, 11, 11, 12, 12, 12, 12,
-};
-
-static const uint16_t codes11[289] = {
- 0x000, 0x006, 0x019, 0x03d, 0x09c, 0x0c6, 0x1a7, 0x390,
- 0x3c2, 0x3df, 0x7e6, 0x7f3, 0xffb, 0x7ec, 0xffa, 0xffe,
- 0x38e, 0x005, 0x001, 0x008, 0x014, 0x037, 0x042, 0x092,
- 0x0af, 0x191, 0x1a5, 0x1b5, 0x39e, 0x3c0, 0x3a2, 0x3cd,
- 0x7d6, 0x0ae, 0x017, 0x007, 0x009, 0x018, 0x039, 0x040,
- 0x08e, 0x0a3, 0x0b8, 0x199, 0x1ac, 0x1c1, 0x3b1, 0x396,
- 0x3be, 0x3ca, 0x09d, 0x03c, 0x015, 0x016, 0x01a, 0x03b,
- 0x044, 0x091, 0x0a5, 0x0be, 0x196, 0x1ae, 0x1b9, 0x3a1,
- 0x391, 0x3a5, 0x3d5, 0x094, 0x09a, 0x036, 0x038, 0x03a,
- 0x041, 0x08c, 0x09b, 0x0b0, 0x0c3, 0x19e, 0x1ab, 0x1bc,
- 0x39f, 0x38f, 0x3a9, 0x3cf, 0x093, 0x0bf, 0x03e, 0x03f,
- 0x043, 0x045, 0x09e, 0x0a7, 0x0b9, 0x194, 0x1a2, 0x1ba,
- 0x1c3, 0x3a6, 0x3a7, 0x3bb, 0x3d4, 0x09f, 0x1a0, 0x08f,
- 0x08d, 0x090, 0x098, 0x0a6, 0x0b6, 0x0c4, 0x19f, 0x1af,
- 0x1bf, 0x399, 0x3bf, 0x3b4, 0x3c9, 0x3e7, 0x0a8, 0x1b6,
- 0x0ab, 0x0a4, 0x0aa, 0x0b2, 0x0c2, 0x0c5, 0x198, 0x1a4,
- 0x1b8, 0x38c, 0x3a4, 0x3c4, 0x3c6, 0x3dd, 0x3e8, 0x0ad,
- 0x3af, 0x192, 0x0bd, 0x0bc, 0x18e, 0x197, 0x19a, 0x1a3,
- 0x1b1, 0x38d, 0x398, 0x3b7, 0x3d3, 0x3d1, 0x3db, 0x7dd,
- 0x0b4, 0x3de, 0x1a9, 0x19b, 0x19c, 0x1a1, 0x1aa, 0x1ad,
- 0x1b3, 0x38b, 0x3b2, 0x3b8, 0x3ce, 0x3e1, 0x3e0, 0x7d2,
- 0x7e5, 0x0b7, 0x7e3, 0x1bb, 0x1a8, 0x1a6, 0x1b0, 0x1b2,
- 0x1b7, 0x39b, 0x39a, 0x3ba, 0x3b5, 0x3d6, 0x7d7, 0x3e4,
- 0x7d8, 0x7ea, 0x0ba, 0x7e8, 0x3a0, 0x1bd, 0x1b4, 0x38a,
- 0x1c4, 0x392, 0x3aa, 0x3b0, 0x3bc, 0x3d7, 0x7d4, 0x7dc,
- 0x7db, 0x7d5, 0x7f0, 0x0c1, 0x7fb, 0x3c8, 0x3a3, 0x395,
- 0x39d, 0x3ac, 0x3ae, 0x3c5, 0x3d8, 0x3e2, 0x3e6, 0x7e4,
- 0x7e7, 0x7e0, 0x7e9, 0x7f7, 0x190, 0x7f2, 0x393, 0x1be,
- 0x1c0, 0x394, 0x397, 0x3ad, 0x3c3, 0x3c1, 0x3d2, 0x7da,
- 0x7d9, 0x7df, 0x7eb, 0x7f4, 0x7fa, 0x195, 0x7f8, 0x3bd,
- 0x39c, 0x3ab, 0x3a8, 0x3b3, 0x3b9, 0x3d0, 0x3e3, 0x3e5,
- 0x7e2, 0x7de, 0x7ed, 0x7f1, 0x7f9, 0x7fc, 0x193, 0xffd,
- 0x3dc, 0x3b6, 0x3c7, 0x3cc, 0x3cb, 0x3d9, 0x3da, 0x7d3,
- 0x7e1, 0x7ee, 0x7ef, 0x7f5, 0x7f6, 0xffc, 0xfff, 0x19d,
- 0x1c2, 0x0b5, 0x0a1, 0x096, 0x097, 0x095, 0x099, 0x0a0,
- 0x0a2, 0x0ac, 0x0a9, 0x0b1, 0x0b3, 0x0bb, 0x0c0, 0x18f,
- 0x004,
-};
-
-static const uint8_t bits11[289] = {
- 4, 5, 6, 7, 8, 8, 9, 10, 10, 10, 11, 11, 12, 11, 12, 12,
- 10, 5, 4, 5, 6, 7, 7, 8, 8, 9, 9, 9, 10, 10, 10, 10,
- 11, 8, 6, 5, 5, 6, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10,
- 10, 10, 8, 7, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 9, 10,
- 10, 10, 10, 8, 8, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9,
- 10, 10, 10, 10, 8, 8, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9,
- 9, 10, 10, 10, 10, 8, 9, 8, 8, 8, 8, 8, 8, 8, 9, 9,
- 9, 10, 10, 10, 10, 10, 8, 9, 8, 8, 8, 8, 8, 8, 9, 9,
- 9, 10, 10, 10, 10, 10, 10, 8, 10, 9, 8, 8, 9, 9, 9, 9,
- 9, 10, 10, 10, 10, 10, 10, 11, 8, 10, 9, 9, 9, 9, 9, 9,
- 9, 10, 10, 10, 10, 10, 10, 11, 11, 8, 11, 9, 9, 9, 9, 9,
- 9, 10, 10, 10, 10, 10, 11, 10, 11, 11, 8, 11, 10, 9, 9, 10,
- 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 8, 11, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 9, 11, 10, 9,
- 9, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 9, 11, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 9, 12,
- 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 12, 12, 9,
- 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9,
- 5,
-};
-
-const uint16_t * const ff_aac_spectral_codes[11] = {
- codes1, codes2, codes3, codes4, codes5, codes6, codes7, codes8,
- codes9, codes10, codes11,
-};
-
-const uint8_t * const ff_aac_spectral_bits[11] = {
- bits1, bits2, bits3, bits4, bits5, bits6, bits7, bits8,
- bits9, bits10, bits11,
-};
-
-const uint16_t ff_aac_spectral_sizes[11] = {
- 81, 81, 81, 81, 81, 81, 64, 64, 169, 169, 289,
-};
-
-/* NOTE:
- * 64.0f is a special value indicating the existence of an escape code in the
- * bitstream.
- */
-static const DECLARE_ALIGNED(16, float, codebook_vector0)[324] = {
- -1.0000000, -1.0000000, -1.0000000, -1.0000000,
- -1.0000000, -1.0000000, -1.0000000, 0.0000000,
- -1.0000000, -1.0000000, -1.0000000, 1.0000000,
- -1.0000000, -1.0000000, 0.0000000, -1.0000000,
- -1.0000000, -1.0000000, 0.0000000, 0.0000000,
- -1.0000000, -1.0000000, 0.0000000, 1.0000000,
- -1.0000000, -1.0000000, 1.0000000, -1.0000000,
- -1.0000000, -1.0000000, 1.0000000, 0.0000000,
- -1.0000000, -1.0000000, 1.0000000, 1.0000000,
- -1.0000000, 0.0000000, -1.0000000, -1.0000000,
- -1.0000000, 0.0000000, -1.0000000, 0.0000000,
- -1.0000000, 0.0000000, -1.0000000, 1.0000000,
- -1.0000000, 0.0000000, 0.0000000, -1.0000000,
- -1.0000000, 0.0000000, 0.0000000, 0.0000000,
- -1.0000000, 0.0000000, 0.0000000, 1.0000000,
- -1.0000000, 0.0000000, 1.0000000, -1.0000000,
- -1.0000000, 0.0000000, 1.0000000, 0.0000000,
- -1.0000000, 0.0000000, 1.0000000, 1.0000000,
- -1.0000000, 1.0000000, -1.0000000, -1.0000000,
- -1.0000000, 1.0000000, -1.0000000, 0.0000000,
- -1.0000000, 1.0000000, -1.0000000, 1.0000000,
- -1.0000000, 1.0000000, 0.0000000, -1.0000000,
- -1.0000000, 1.0000000, 0.0000000, 0.0000000,
- -1.0000000, 1.0000000, 0.0000000, 1.0000000,
- -1.0000000, 1.0000000, 1.0000000, -1.0000000,
- -1.0000000, 1.0000000, 1.0000000, 0.0000000,
- -1.0000000, 1.0000000, 1.0000000, 1.0000000,
- 0.0000000, -1.0000000, -1.0000000, -1.0000000,
- 0.0000000, -1.0000000, -1.0000000, 0.0000000,
- 0.0000000, -1.0000000, -1.0000000, 1.0000000,
- 0.0000000, -1.0000000, 0.0000000, -1.0000000,
- 0.0000000, -1.0000000, 0.0000000, 0.0000000,
- 0.0000000, -1.0000000, 0.0000000, 1.0000000,
- 0.0000000, -1.0000000, 1.0000000, -1.0000000,
- 0.0000000, -1.0000000, 1.0000000, 0.0000000,
- 0.0000000, -1.0000000, 1.0000000, 1.0000000,
- 0.0000000, 0.0000000, -1.0000000, -1.0000000,
- 0.0000000, 0.0000000, -1.0000000, 0.0000000,
- 0.0000000, 0.0000000, -1.0000000, 1.0000000,
- 0.0000000, 0.0000000, 0.0000000, -1.0000000,
- 0.0000000, 0.0000000, 0.0000000, 0.0000000,
- 0.0000000, 0.0000000, 0.0000000, 1.0000000,
- 0.0000000, 0.0000000, 1.0000000, -1.0000000,
- 0.0000000, 0.0000000, 1.0000000, 0.0000000,
- 0.0000000, 0.0000000, 1.0000000, 1.0000000,
- 0.0000000, 1.0000000, -1.0000000, -1.0000000,
- 0.0000000, 1.0000000, -1.0000000, 0.0000000,
- 0.0000000, 1.0000000, -1.0000000, 1.0000000,
- 0.0000000, 1.0000000, 0.0000000, -1.0000000,
- 0.0000000, 1.0000000, 0.0000000, 0.0000000,
- 0.0000000, 1.0000000, 0.0000000, 1.0000000,
- 0.0000000, 1.0000000, 1.0000000, -1.0000000,
- 0.0000000, 1.0000000, 1.0000000, 0.0000000,
- 0.0000000, 1.0000000, 1.0000000, 1.0000000,
- 1.0000000, -1.0000000, -1.0000000, -1.0000000,
- 1.0000000, -1.0000000, -1.0000000, 0.0000000,
- 1.0000000, -1.0000000, -1.0000000, 1.0000000,
- 1.0000000, -1.0000000, 0.0000000, -1.0000000,
- 1.0000000, -1.0000000, 0.0000000, 0.0000000,
- 1.0000000, -1.0000000, 0.0000000, 1.0000000,
- 1.0000000, -1.0000000, 1.0000000, -1.0000000,
- 1.0000000, -1.0000000, 1.0000000, 0.0000000,
- 1.0000000, -1.0000000, 1.0000000, 1.0000000,
- 1.0000000, 0.0000000, -1.0000000, -1.0000000,
- 1.0000000, 0.0000000, -1.0000000, 0.0000000,
- 1.0000000, 0.0000000, -1.0000000, 1.0000000,
- 1.0000000, 0.0000000, 0.0000000, -1.0000000,
- 1.0000000, 0.0000000, 0.0000000, 0.0000000,
- 1.0000000, 0.0000000, 0.0000000, 1.0000000,
- 1.0000000, 0.0000000, 1.0000000, -1.0000000,
- 1.0000000, 0.0000000, 1.0000000, 0.0000000,
- 1.0000000, 0.0000000, 1.0000000, 1.0000000,
- 1.0000000, 1.0000000, -1.0000000, -1.0000000,
- 1.0000000, 1.0000000, -1.0000000, 0.0000000,
- 1.0000000, 1.0000000, -1.0000000, 1.0000000,
- 1.0000000, 1.0000000, 0.0000000, -1.0000000,
- 1.0000000, 1.0000000, 0.0000000, 0.0000000,
- 1.0000000, 1.0000000, 0.0000000, 1.0000000,
- 1.0000000, 1.0000000, 1.0000000, -1.0000000,
- 1.0000000, 1.0000000, 1.0000000, 0.0000000,
- 1.0000000, 1.0000000, 1.0000000, 1.0000000,
-};
-
-static const DECLARE_ALIGNED(16, float, codebook_vector2)[324] = {
- 0.0000000, 0.0000000, 0.0000000, 0.0000000,
- 0.0000000, 0.0000000, 0.0000000, 1.0000000,
- 0.0000000, 0.0000000, 0.0000000, 2.5198421,
- 0.0000000, 0.0000000, 1.0000000, 0.0000000,
- 0.0000000, 0.0000000, 1.0000000, 1.0000000,
- 0.0000000, 0.0000000, 1.0000000, 2.5198421,
- 0.0000000, 0.0000000, 2.5198421, 0.0000000,
- 0.0000000, 0.0000000, 2.5198421, 1.0000000,
- 0.0000000, 0.0000000, 2.5198421, 2.5198421,
- 0.0000000, 1.0000000, 0.0000000, 0.0000000,
- 0.0000000, 1.0000000, 0.0000000, 1.0000000,
- 0.0000000, 1.0000000, 0.0000000, 2.5198421,
- 0.0000000, 1.0000000, 1.0000000, 0.0000000,
- 0.0000000, 1.0000000, 1.0000000, 1.0000000,
- 0.0000000, 1.0000000, 1.0000000, 2.5198421,
- 0.0000000, 1.0000000, 2.5198421, 0.0000000,
- 0.0000000, 1.0000000, 2.5198421, 1.0000000,
- 0.0000000, 1.0000000, 2.5198421, 2.5198421,
- 0.0000000, 2.5198421, 0.0000000, 0.0000000,
- 0.0000000, 2.5198421, 0.0000000, 1.0000000,
- 0.0000000, 2.5198421, 0.0000000, 2.5198421,
- 0.0000000, 2.5198421, 1.0000000, 0.0000000,
- 0.0000000, 2.5198421, 1.0000000, 1.0000000,
- 0.0000000, 2.5198421, 1.0000000, 2.5198421,
- 0.0000000, 2.5198421, 2.5198421, 0.0000000,
- 0.0000000, 2.5198421, 2.5198421, 1.0000000,
- 0.0000000, 2.5198421, 2.5198421, 2.5198421,
- 1.0000000, 0.0000000, 0.0000000, 0.0000000,
- 1.0000000, 0.0000000, 0.0000000, 1.0000000,
- 1.0000000, 0.0000000, 0.0000000, 2.5198421,
- 1.0000000, 0.0000000, 1.0000000, 0.0000000,
- 1.0000000, 0.0000000, 1.0000000, 1.0000000,
- 1.0000000, 0.0000000, 1.0000000, 2.5198421,
- 1.0000000, 0.0000000, 2.5198421, 0.0000000,
- 1.0000000, 0.0000000, 2.5198421, 1.0000000,
- 1.0000000, 0.0000000, 2.5198421, 2.5198421,
- 1.0000000, 1.0000000, 0.0000000, 0.0000000,
- 1.0000000, 1.0000000, 0.0000000, 1.0000000,
- 1.0000000, 1.0000000, 0.0000000, 2.5198421,
- 1.0000000, 1.0000000, 1.0000000, 0.0000000,
- 1.0000000, 1.0000000, 1.0000000, 1.0000000,
- 1.0000000, 1.0000000, 1.0000000, 2.5198421,
- 1.0000000, 1.0000000, 2.5198421, 0.0000000,
- 1.0000000, 1.0000000, 2.5198421, 1.0000000,
- 1.0000000, 1.0000000, 2.5198421, 2.5198421,
- 1.0000000, 2.5198421, 0.0000000, 0.0000000,
- 1.0000000, 2.5198421, 0.0000000, 1.0000000,
- 1.0000000, 2.5198421, 0.0000000, 2.5198421,
- 1.0000000, 2.5198421, 1.0000000, 0.0000000,
- 1.0000000, 2.5198421, 1.0000000, 1.0000000,
- 1.0000000, 2.5198421, 1.0000000, 2.5198421,
- 1.0000000, 2.5198421, 2.5198421, 0.0000000,
- 1.0000000, 2.5198421, 2.5198421, 1.0000000,
- 1.0000000, 2.5198421, 2.5198421, 2.5198421,
- 2.5198421, 0.0000000, 0.0000000, 0.0000000,
- 2.5198421, 0.0000000, 0.0000000, 1.0000000,
- 2.5198421, 0.0000000, 0.0000000, 2.5198421,
- 2.5198421, 0.0000000, 1.0000000, 0.0000000,
- 2.5198421, 0.0000000, 1.0000000, 1.0000000,
- 2.5198421, 0.0000000, 1.0000000, 2.5198421,
- 2.5198421, 0.0000000, 2.5198421, 0.0000000,
- 2.5198421, 0.0000000, 2.5198421, 1.0000000,
- 2.5198421, 0.0000000, 2.5198421, 2.5198421,
- 2.5198421, 1.0000000, 0.0000000, 0.0000000,
- 2.5198421, 1.0000000, 0.0000000, 1.0000000,
- 2.5198421, 1.0000000, 0.0000000, 2.5198421,
- 2.5198421, 1.0000000, 1.0000000, 0.0000000,
- 2.5198421, 1.0000000, 1.0000000, 1.0000000,
- 2.5198421, 1.0000000, 1.0000000, 2.5198421,
- 2.5198421, 1.0000000, 2.5198421, 0.0000000,
- 2.5198421, 1.0000000, 2.5198421, 1.0000000,
- 2.5198421, 1.0000000, 2.5198421, 2.5198421,
- 2.5198421, 2.5198421, 0.0000000, 0.0000000,
- 2.5198421, 2.5198421, 0.0000000, 1.0000000,
- 2.5198421, 2.5198421, 0.0000000, 2.5198421,
- 2.5198421, 2.5198421, 1.0000000, 0.0000000,
- 2.5198421, 2.5198421, 1.0000000, 1.0000000,
- 2.5198421, 2.5198421, 1.0000000, 2.5198421,
- 2.5198421, 2.5198421, 2.5198421, 0.0000000,
- 2.5198421, 2.5198421, 2.5198421, 1.0000000,
- 2.5198421, 2.5198421, 2.5198421, 2.5198421,
-};
-
-static const DECLARE_ALIGNED(16, float, codebook_vector4)[162] = {
- -6.3496042, -6.3496042, -6.3496042, -4.3267487,
- -6.3496042, -2.5198421, -6.3496042, -1.0000000,
- -6.3496042, 0.0000000, -6.3496042, 1.0000000,
- -6.3496042, 2.5198421, -6.3496042, 4.3267487,
- -6.3496042, 6.3496042, -4.3267487, -6.3496042,
- -4.3267487, -4.3267487, -4.3267487, -2.5198421,
- -4.3267487, -1.0000000, -4.3267487, 0.0000000,
- -4.3267487, 1.0000000, -4.3267487, 2.5198421,
- -4.3267487, 4.3267487, -4.3267487, 6.3496042,
- -2.5198421, -6.3496042, -2.5198421, -4.3267487,
- -2.5198421, -2.5198421, -2.5198421, -1.0000000,
- -2.5198421, 0.0000000, -2.5198421, 1.0000000,
- -2.5198421, 2.5198421, -2.5198421, 4.3267487,
- -2.5198421, 6.3496042, -1.0000000, -6.3496042,
- -1.0000000, -4.3267487, -1.0000000, -2.5198421,
- -1.0000000, -1.0000000, -1.0000000, 0.0000000,
- -1.0000000, 1.0000000, -1.0000000, 2.5198421,
- -1.0000000, 4.3267487, -1.0000000, 6.3496042,
- 0.0000000, -6.3496042, 0.0000000, -4.3267487,
- 0.0000000, -2.5198421, 0.0000000, -1.0000000,
- 0.0000000, 0.0000000, 0.0000000, 1.0000000,
- 0.0000000, 2.5198421, 0.0000000, 4.3267487,
- 0.0000000, 6.3496042, 1.0000000, -6.3496042,
- 1.0000000, -4.3267487, 1.0000000, -2.5198421,
- 1.0000000, -1.0000000, 1.0000000, 0.0000000,
- 1.0000000, 1.0000000, 1.0000000, 2.5198421,
- 1.0000000, 4.3267487, 1.0000000, 6.3496042,
- 2.5198421, -6.3496042, 2.5198421, -4.3267487,
- 2.5198421, -2.5198421, 2.5198421, -1.0000000,
- 2.5198421, 0.0000000, 2.5198421, 1.0000000,
- 2.5198421, 2.5198421, 2.5198421, 4.3267487,
- 2.5198421, 6.3496042, 4.3267487, -6.3496042,
- 4.3267487, -4.3267487, 4.3267487, -2.5198421,
- 4.3267487, -1.0000000, 4.3267487, 0.0000000,
- 4.3267487, 1.0000000, 4.3267487, 2.5198421,
- 4.3267487, 4.3267487, 4.3267487, 6.3496042,
- 6.3496042, -6.3496042, 6.3496042, -4.3267487,
- 6.3496042, -2.5198421, 6.3496042, -1.0000000,
- 6.3496042, 0.0000000, 6.3496042, 1.0000000,
- 6.3496042, 2.5198421, 6.3496042, 4.3267487,
- 6.3496042, 6.3496042,
-};
-
-static const DECLARE_ALIGNED(16, float, codebook_vector6)[128] = {
- 0.0000000, 0.0000000, 0.0000000, 1.0000000,
- 0.0000000, 2.5198421, 0.0000000, 4.3267487,
- 0.0000000, 6.3496042, 0.0000000, 8.5498797,
- 0.0000000, 10.9027236, 0.0000000, 13.3905183,
- 1.0000000, 0.0000000, 1.0000000, 1.0000000,
- 1.0000000, 2.5198421, 1.0000000, 4.3267487,
- 1.0000000, 6.3496042, 1.0000000, 8.5498797,
- 1.0000000, 10.9027236, 1.0000000, 13.3905183,
- 2.5198421, 0.0000000, 2.5198421, 1.0000000,
- 2.5198421, 2.5198421, 2.5198421, 4.3267487,
- 2.5198421, 6.3496042, 2.5198421, 8.5498797,
- 2.5198421, 10.9027236, 2.5198421, 13.3905183,
- 4.3267487, 0.0000000, 4.3267487, 1.0000000,
- 4.3267487, 2.5198421, 4.3267487, 4.3267487,
- 4.3267487, 6.3496042, 4.3267487, 8.5498797,
- 4.3267487, 10.9027236, 4.3267487, 13.3905183,
- 6.3496042, 0.0000000, 6.3496042, 1.0000000,
- 6.3496042, 2.5198421, 6.3496042, 4.3267487,
- 6.3496042, 6.3496042, 6.3496042, 8.5498797,
- 6.3496042, 10.9027236, 6.3496042, 13.3905183,
- 8.5498797, 0.0000000, 8.5498797, 1.0000000,
- 8.5498797, 2.5198421, 8.5498797, 4.3267487,
- 8.5498797, 6.3496042, 8.5498797, 8.5498797,
- 8.5498797, 10.9027236, 8.5498797, 13.3905183,
- 10.9027236, 0.0000000, 10.9027236, 1.0000000,
- 10.9027236, 2.5198421, 10.9027236, 4.3267487,
- 10.9027236, 6.3496042, 10.9027236, 8.5498797,
- 10.9027236, 10.9027236, 10.9027236, 13.3905183,
- 13.3905183, 0.0000000, 13.3905183, 1.0000000,
- 13.3905183, 2.5198421, 13.3905183, 4.3267487,
- 13.3905183, 6.3496042, 13.3905183, 8.5498797,
- 13.3905183, 10.9027236, 13.3905183, 13.3905183,
-};
-
-static const DECLARE_ALIGNED(16, float, codebook_vector8)[338] = {
- 0.0000000, 0.0000000, 0.0000000, 1.0000000,
- 0.0000000, 2.5198421, 0.0000000, 4.3267487,
- 0.0000000, 6.3496042, 0.0000000, 8.5498797,
- 0.0000000, 10.9027236, 0.0000000, 13.3905183,
- 0.0000000, 16.0000000, 0.0000000, 18.7207544,
- 0.0000000, 21.5443469, 0.0000000, 24.4637810,
- 0.0000000, 27.4731418, 1.0000000, 0.0000000,
- 1.0000000, 1.0000000, 1.0000000, 2.5198421,
- 1.0000000, 4.3267487, 1.0000000, 6.3496042,
- 1.0000000, 8.5498797, 1.0000000, 10.9027236,
- 1.0000000, 13.3905183, 1.0000000, 16.0000000,
- 1.0000000, 18.7207544, 1.0000000, 21.5443469,
- 1.0000000, 24.4637810, 1.0000000, 27.4731418,
- 2.5198421, 0.0000000, 2.5198421, 1.0000000,
- 2.5198421, 2.5198421, 2.5198421, 4.3267487,
- 2.5198421, 6.3496042, 2.5198421, 8.5498797,
- 2.5198421, 10.9027236, 2.5198421, 13.3905183,
- 2.5198421, 16.0000000, 2.5198421, 18.7207544,
- 2.5198421, 21.5443469, 2.5198421, 24.4637810,
- 2.5198421, 27.4731418, 4.3267487, 0.0000000,
- 4.3267487, 1.0000000, 4.3267487, 2.5198421,
- 4.3267487, 4.3267487, 4.3267487, 6.3496042,
- 4.3267487, 8.5498797, 4.3267487, 10.9027236,
- 4.3267487, 13.3905183, 4.3267487, 16.0000000,
- 4.3267487, 18.7207544, 4.3267487, 21.5443469,
- 4.3267487, 24.4637810, 4.3267487, 27.4731418,
- 6.3496042, 0.0000000, 6.3496042, 1.0000000,
- 6.3496042, 2.5198421, 6.3496042, 4.3267487,
- 6.3496042, 6.3496042, 6.3496042, 8.5498797,
- 6.3496042, 10.9027236, 6.3496042, 13.3905183,
- 6.3496042, 16.0000000, 6.3496042, 18.7207544,
- 6.3496042, 21.5443469, 6.3496042, 24.4637810,
- 6.3496042, 27.4731418, 8.5498797, 0.0000000,
- 8.5498797, 1.0000000, 8.5498797, 2.5198421,
- 8.5498797, 4.3267487, 8.5498797, 6.3496042,
- 8.5498797, 8.5498797, 8.5498797, 10.9027236,
- 8.5498797, 13.3905183, 8.5498797, 16.0000000,
- 8.5498797, 18.7207544, 8.5498797, 21.5443469,
- 8.5498797, 24.4637810, 8.5498797, 27.4731418,
- 10.9027236, 0.0000000, 10.9027236, 1.0000000,
- 10.9027236, 2.5198421, 10.9027236, 4.3267487,
- 10.9027236, 6.3496042, 10.9027236, 8.5498797,
- 10.9027236, 10.9027236, 10.9027236, 13.3905183,
- 10.9027236, 16.0000000, 10.9027236, 18.7207544,
- 10.9027236, 21.5443469, 10.9027236, 24.4637810,
- 10.9027236, 27.4731418, 13.3905183, 0.0000000,
- 13.3905183, 1.0000000, 13.3905183, 2.5198421,
- 13.3905183, 4.3267487, 13.3905183, 6.3496042,
- 13.3905183, 8.5498797, 13.3905183, 10.9027236,
- 13.3905183, 13.3905183, 13.3905183, 16.0000000,
- 13.3905183, 18.7207544, 13.3905183, 21.5443469,
- 13.3905183, 24.4637810, 13.3905183, 27.4731418,
- 16.0000000, 0.0000000, 16.0000000, 1.0000000,
- 16.0000000, 2.5198421, 16.0000000, 4.3267487,
- 16.0000000, 6.3496042, 16.0000000, 8.5498797,
- 16.0000000, 10.9027236, 16.0000000, 13.3905183,
- 16.0000000, 16.0000000, 16.0000000, 18.7207544,
- 16.0000000, 21.5443469, 16.0000000, 24.4637810,
- 16.0000000, 27.4731418, 18.7207544, 0.0000000,
- 18.7207544, 1.0000000, 18.7207544, 2.5198421,
- 18.7207544, 4.3267487, 18.7207544, 6.3496042,
- 18.7207544, 8.5498797, 18.7207544, 10.9027236,
- 18.7207544, 13.3905183, 18.7207544, 16.0000000,
- 18.7207544, 18.7207544, 18.7207544, 21.5443469,
- 18.7207544, 24.4637810, 18.7207544, 27.4731418,
- 21.5443469, 0.0000000, 21.5443469, 1.0000000,
- 21.5443469, 2.5198421, 21.5443469, 4.3267487,
- 21.5443469, 6.3496042, 21.5443469, 8.5498797,
- 21.5443469, 10.9027236, 21.5443469, 13.3905183,
- 21.5443469, 16.0000000, 21.5443469, 18.7207544,
- 21.5443469, 21.5443469, 21.5443469, 24.4637810,
- 21.5443469, 27.4731418, 24.4637810, 0.0000000,
- 24.4637810, 1.0000000, 24.4637810, 2.5198421,
- 24.4637810, 4.3267487, 24.4637810, 6.3496042,
- 24.4637810, 8.5498797, 24.4637810, 10.9027236,
- 24.4637810, 13.3905183, 24.4637810, 16.0000000,
- 24.4637810, 18.7207544, 24.4637810, 21.5443469,
- 24.4637810, 24.4637810, 24.4637810, 27.4731418,
- 27.4731418, 0.0000000, 27.4731418, 1.0000000,
- 27.4731418, 2.5198421, 27.4731418, 4.3267487,
- 27.4731418, 6.3496042, 27.4731418, 8.5498797,
- 27.4731418, 10.9027236, 27.4731418, 13.3905183,
- 27.4731418, 16.0000000, 27.4731418, 18.7207544,
- 27.4731418, 21.5443469, 27.4731418, 24.4637810,
- 27.4731418, 27.4731418,
-};
-
-static const DECLARE_ALIGNED(16, float, codebook_vector10)[578] = {
- 0.0000000, 0.0000000, 0.0000000, 1.0000000,
- 0.0000000, 2.5198421, 0.0000000, 4.3267487,
- 0.0000000, 6.3496042, 0.0000000, 8.5498797,
- 0.0000000, 10.9027236, 0.0000000, 13.3905183,
- 0.0000000, 16.0000000, 0.0000000, 18.7207544,
- 0.0000000, 21.5443469, 0.0000000, 24.4637810,
- 0.0000000, 27.4731418, 0.0000000, 30.5673509,
- 0.0000000, 33.7419917, 0.0000000, 36.9931811,
- 0.0000000, 64.0f, 1.0000000, 0.0000000,
- 1.0000000, 1.0000000, 1.0000000, 2.5198421,
- 1.0000000, 4.3267487, 1.0000000, 6.3496042,
- 1.0000000, 8.5498797, 1.0000000, 10.9027236,
- 1.0000000, 13.3905183, 1.0000000, 16.0000000,
- 1.0000000, 18.7207544, 1.0000000, 21.5443469,
- 1.0000000, 24.4637810, 1.0000000, 27.4731418,
- 1.0000000, 30.5673509, 1.0000000, 33.7419917,
- 1.0000000, 36.9931811, 1.0000000, 64.0f,
- 2.5198421, 0.0000000, 2.5198421, 1.0000000,
- 2.5198421, 2.5198421, 2.5198421, 4.3267487,
- 2.5198421, 6.3496042, 2.5198421, 8.5498797,
- 2.5198421, 10.9027236, 2.5198421, 13.3905183,
- 2.5198421, 16.0000000, 2.5198421, 18.7207544,
- 2.5198421, 21.5443469, 2.5198421, 24.4637810,
- 2.5198421, 27.4731418, 2.5198421, 30.5673509,
- 2.5198421, 33.7419917, 2.5198421, 36.9931811,
- 2.5198421, 64.0f, 4.3267487, 0.0000000,
- 4.3267487, 1.0000000, 4.3267487, 2.5198421,
- 4.3267487, 4.3267487, 4.3267487, 6.3496042,
- 4.3267487, 8.5498797, 4.3267487, 10.9027236,
- 4.3267487, 13.3905183, 4.3267487, 16.0000000,
- 4.3267487, 18.7207544, 4.3267487, 21.5443469,
- 4.3267487, 24.4637810, 4.3267487, 27.4731418,
- 4.3267487, 30.5673509, 4.3267487, 33.7419917,
- 4.3267487, 36.9931811, 4.3267487, 64.0f,
- 6.3496042, 0.0000000, 6.3496042, 1.0000000,
- 6.3496042, 2.5198421, 6.3496042, 4.3267487,
- 6.3496042, 6.3496042, 6.3496042, 8.5498797,
- 6.3496042, 10.9027236, 6.3496042, 13.3905183,
- 6.3496042, 16.0000000, 6.3496042, 18.7207544,
- 6.3496042, 21.5443469, 6.3496042, 24.4637810,
- 6.3496042, 27.4731418, 6.3496042, 30.5673509,
- 6.3496042, 33.7419917, 6.3496042, 36.9931811,
- 6.3496042, 64.0f, 8.5498797, 0.0000000,
- 8.5498797, 1.0000000, 8.5498797, 2.5198421,
- 8.5498797, 4.3267487, 8.5498797, 6.3496042,
- 8.5498797, 8.5498797, 8.5498797, 10.9027236,
- 8.5498797, 13.3905183, 8.5498797, 16.0000000,
- 8.5498797, 18.7207544, 8.5498797, 21.5443469,
- 8.5498797, 24.4637810, 8.5498797, 27.4731418,
- 8.5498797, 30.5673509, 8.5498797, 33.7419917,
- 8.5498797, 36.9931811, 8.5498797, 64.0f,
- 10.9027236, 0.0000000, 10.9027236, 1.0000000,
- 10.9027236, 2.5198421, 10.9027236, 4.3267487,
- 10.9027236, 6.3496042, 10.9027236, 8.5498797,
- 10.9027236, 10.9027236, 10.9027236, 13.3905183,
- 10.9027236, 16.0000000, 10.9027236, 18.7207544,
- 10.9027236, 21.5443469, 10.9027236, 24.4637810,
- 10.9027236, 27.4731418, 10.9027236, 30.5673509,
- 10.9027236, 33.7419917, 10.9027236, 36.9931811,
- 10.9027236, 64.0f, 13.3905183, 0.0000000,
- 13.3905183, 1.0000000, 13.3905183, 2.5198421,
- 13.3905183, 4.3267487, 13.3905183, 6.3496042,
- 13.3905183, 8.5498797, 13.3905183, 10.9027236,
- 13.3905183, 13.3905183, 13.3905183, 16.0000000,
- 13.3905183, 18.7207544, 13.3905183, 21.5443469,
- 13.3905183, 24.4637810, 13.3905183, 27.4731418,
- 13.3905183, 30.5673509, 13.3905183, 33.7419917,
- 13.3905183, 36.9931811, 13.3905183, 64.0f,
- 16.0000000, 0.0000000, 16.0000000, 1.0000000,
- 16.0000000, 2.5198421, 16.0000000, 4.3267487,
- 16.0000000, 6.3496042, 16.0000000, 8.5498797,
- 16.0000000, 10.9027236, 16.0000000, 13.3905183,
- 16.0000000, 16.0000000, 16.0000000, 18.7207544,
- 16.0000000, 21.5443469, 16.0000000, 24.4637810,
- 16.0000000, 27.4731418, 16.0000000, 30.5673509,
- 16.0000000, 33.7419917, 16.0000000, 36.9931811,
- 16.0000000, 64.0f, 18.7207544, 0.0000000,
- 18.7207544, 1.0000000, 18.7207544, 2.5198421,
- 18.7207544, 4.3267487, 18.7207544, 6.3496042,
- 18.7207544, 8.5498797, 18.7207544, 10.9027236,
- 18.7207544, 13.3905183, 18.7207544, 16.0000000,
- 18.7207544, 18.7207544, 18.7207544, 21.5443469,
- 18.7207544, 24.4637810, 18.7207544, 27.4731418,
- 18.7207544, 30.5673509, 18.7207544, 33.7419917,
- 18.7207544, 36.9931811, 18.7207544, 64.0f,
- 21.5443469, 0.0000000, 21.5443469, 1.0000000,
- 21.5443469, 2.5198421, 21.5443469, 4.3267487,
- 21.5443469, 6.3496042, 21.5443469, 8.5498797,
- 21.5443469, 10.9027236, 21.5443469, 13.3905183,
- 21.5443469, 16.0000000, 21.5443469, 18.7207544,
- 21.5443469, 21.5443469, 21.5443469, 24.4637810,
- 21.5443469, 27.4731418, 21.5443469, 30.5673509,
- 21.5443469, 33.7419917, 21.5443469, 36.9931811,
- 21.5443469, 64.0f, 24.4637810, 0.0000000,
- 24.4637810, 1.0000000, 24.4637810, 2.5198421,
- 24.4637810, 4.3267487, 24.4637810, 6.3496042,
- 24.4637810, 8.5498797, 24.4637810, 10.9027236,
- 24.4637810, 13.3905183, 24.4637810, 16.0000000,
- 24.4637810, 18.7207544, 24.4637810, 21.5443469,
- 24.4637810, 24.4637810, 24.4637810, 27.4731418,
- 24.4637810, 30.5673509, 24.4637810, 33.7419917,
- 24.4637810, 36.9931811, 24.4637810, 64.0f,
- 27.4731418, 0.0000000, 27.4731418, 1.0000000,
- 27.4731418, 2.5198421, 27.4731418, 4.3267487,
- 27.4731418, 6.3496042, 27.4731418, 8.5498797,
- 27.4731418, 10.9027236, 27.4731418, 13.3905183,
- 27.4731418, 16.0000000, 27.4731418, 18.7207544,
- 27.4731418, 21.5443469, 27.4731418, 24.4637810,
- 27.4731418, 27.4731418, 27.4731418, 30.5673509,
- 27.4731418, 33.7419917, 27.4731418, 36.9931811,
- 27.4731418, 64.0f, 30.5673509, 0.0000000,
- 30.5673509, 1.0000000, 30.5673509, 2.5198421,
- 30.5673509, 4.3267487, 30.5673509, 6.3496042,
- 30.5673509, 8.5498797, 30.5673509, 10.9027236,
- 30.5673509, 13.3905183, 30.5673509, 16.0000000,
- 30.5673509, 18.7207544, 30.5673509, 21.5443469,
- 30.5673509, 24.4637810, 30.5673509, 27.4731418,
- 30.5673509, 30.5673509, 30.5673509, 33.7419917,
- 30.5673509, 36.9931811, 30.5673509, 64.0f,
- 33.7419917, 0.0000000, 33.7419917, 1.0000000,
- 33.7419917, 2.5198421, 33.7419917, 4.3267487,
- 33.7419917, 6.3496042, 33.7419917, 8.5498797,
- 33.7419917, 10.9027236, 33.7419917, 13.3905183,
- 33.7419917, 16.0000000, 33.7419917, 18.7207544,
- 33.7419917, 21.5443469, 33.7419917, 24.4637810,
- 33.7419917, 27.4731418, 33.7419917, 30.5673509,
- 33.7419917, 33.7419917, 33.7419917, 36.9931811,
- 33.7419917, 64.0f, 36.9931811, 0.0000000,
- 36.9931811, 1.0000000, 36.9931811, 2.5198421,
- 36.9931811, 4.3267487, 36.9931811, 6.3496042,
- 36.9931811, 8.5498797, 36.9931811, 10.9027236,
- 36.9931811, 13.3905183, 36.9931811, 16.0000000,
- 36.9931811, 18.7207544, 36.9931811, 21.5443469,
- 36.9931811, 24.4637810, 36.9931811, 27.4731418,
- 36.9931811, 30.5673509, 36.9931811, 33.7419917,
- 36.9931811, 36.9931811, 36.9931811, 64.0f,
- 64.0f, 0.0000000, 64.0f, 1.0000000,
- 64.0f, 2.5198421, 64.0f, 4.3267487,
- 64.0f, 6.3496042, 64.0f, 8.5498797,
- 64.0f, 10.9027236, 64.0f, 13.3905183,
- 64.0f, 16.0000000, 64.0f, 18.7207544,
- 64.0f, 21.5443469, 64.0f, 24.4637810,
- 64.0f, 27.4731418, 64.0f, 30.5673509,
- 64.0f, 33.7419917, 64.0f, 36.9931811,
- 64.0f, 64.0f,
-};
-
-const float * const ff_aac_codebook_vectors[] = {
- codebook_vector0, codebook_vector0, codebook_vector2,
- codebook_vector2, codebook_vector4, codebook_vector4,
- codebook_vector6, codebook_vector6, codebook_vector8,
- codebook_vector8, codebook_vector10,
-};
-
-static const float codebook_vector0_vals[] = {
- -1.0000000, 0.0000000, 1.0000000
-};
-
-/*
- * bits 0:1, 2:3, 4:5, 6:7 index into _vals array
- * 8:11 number of non-zero values
- * 12:15 bit mask of non-zero values
- */
-static const uint16_t codebook_vector02_idx[] = {
- 0x0000, 0x8140, 0x8180, 0x4110, 0xc250, 0xc290, 0x4120, 0xc260, 0xc2a0,
- 0x2104, 0xa244, 0xa284, 0x6214, 0xe354, 0xe394, 0x6224, 0xe364, 0xe3a4,
- 0x2108, 0xa248, 0xa288, 0x6218, 0xe358, 0xe398, 0x6228, 0xe368, 0xe3a8,
- 0x1101, 0x9241, 0x9281, 0x5211, 0xd351, 0xd391, 0x5221, 0xd361, 0xd3a1,
- 0x3205, 0xb345, 0xb385, 0x7315, 0xf455, 0xf495, 0x7325, 0xf465, 0xf4a5,
- 0x3209, 0xb349, 0xb389, 0x7319, 0xf459, 0xf499, 0x7329, 0xf469, 0xf4a9,
- 0x1102, 0x9242, 0x9282, 0x5212, 0xd352, 0xd392, 0x5222, 0xd362, 0xd3a2,
- 0x3206, 0xb346, 0xb386, 0x7316, 0xf456, 0xf496, 0x7326, 0xf466, 0xf4a6,
- 0x320a, 0xb34a, 0xb38a, 0x731a, 0xf45a, 0xf49a, 0x732a, 0xf46a, 0xf4aa,
-};
-
-static const float codebook_vector4_vals[] = {
- -6.3496042, -4.3267487,
- -2.5198421, -1.0000000,
- 0.0000000, 1.0000000,
- 2.5198421, 4.3267487,
- 6.3496042,
-};
-
-/*
- * bits 0:3, 4:7 index into _vals array
- */
-static const uint16_t codebook_vector4_idx[] = {
- 0x0000, 0x0010, 0x0020, 0x0030, 0x0040, 0x0050, 0x0060, 0x0070, 0x0080,
- 0x0001, 0x0011, 0x0021, 0x0031, 0x0041, 0x0051, 0x0061, 0x0071, 0x0081,
- 0x0002, 0x0012, 0x0022, 0x0032, 0x0042, 0x0052, 0x0062, 0x0072, 0x0082,
- 0x0003, 0x0013, 0x0023, 0x0033, 0x0043, 0x0053, 0x0063, 0x0073, 0x0083,
- 0x0004, 0x0014, 0x0024, 0x0034, 0x0044, 0x0054, 0x0064, 0x0074, 0x0084,
- 0x0005, 0x0015, 0x0025, 0x0035, 0x0045, 0x0055, 0x0065, 0x0075, 0x0085,
- 0x0006, 0x0016, 0x0026, 0x0036, 0x0046, 0x0056, 0x0066, 0x0076, 0x0086,
- 0x0007, 0x0017, 0x0027, 0x0037, 0x0047, 0x0057, 0x0067, 0x0077, 0x0087,
- 0x0008, 0x0018, 0x0028, 0x0038, 0x0048, 0x0058, 0x0068, 0x0078, 0x0088,
-};
-
-/*
- * bits 0:3, 4:7 index into _vals array
- * 8:11 number of non-zero values
- * 12:15 1: only second value non-zero
- * 0: other cases
- */
-static const uint16_t codebook_vector6_idx[] = {
- 0x0000, 0x0110, 0x0120, 0x0130, 0x0140, 0x0150, 0x0160, 0x0170,
- 0x1101, 0x0211, 0x0221, 0x0231, 0x0241, 0x0251, 0x0261, 0x0271,
- 0x1102, 0x0212, 0x0222, 0x0232, 0x0242, 0x0252, 0x0262, 0x0272,
- 0x1103, 0x0213, 0x0223, 0x0233, 0x0243, 0x0253, 0x0263, 0x0273,
- 0x1104, 0x0214, 0x0224, 0x0234, 0x0244, 0x0254, 0x0264, 0x0274,
- 0x1105, 0x0215, 0x0225, 0x0235, 0x0245, 0x0255, 0x0265, 0x0275,
- 0x1106, 0x0216, 0x0226, 0x0236, 0x0246, 0x0256, 0x0266, 0x0276,
- 0x1107, 0x0217, 0x0227, 0x0237, 0x0247, 0x0257, 0x0267, 0x0277,
-};
-
-/*
- * bits 0:3, 4:7 index into _vals array
- * 8:11 number of non-zero values
- * 12:15 1: only second value non-zero
- * 0: other cases
- */
-static const uint16_t codebook_vector8_idx[] = {
- 0x0000, 0x0110, 0x0120, 0x0130, 0x0140, 0x0150, 0x0160,
- 0x0170, 0x0180, 0x0190, 0x01a0, 0x01b0, 0x01c0,
- 0x1101, 0x0211, 0x0221, 0x0231, 0x0241, 0x0251, 0x0261,
- 0x0271, 0x0281, 0x0291, 0x02a1, 0x02b1, 0x02c1,
- 0x1102, 0x0212, 0x0222, 0x0232, 0x0242, 0x0252, 0x0262,
- 0x0272, 0x0282, 0x0292, 0x02a2, 0x02b2, 0x02c2,
- 0x1103, 0x0213, 0x0223, 0x0233, 0x0243, 0x0253, 0x0263,
- 0x0273, 0x0283, 0x0293, 0x02a3, 0x02b3, 0x02c3,
- 0x1104, 0x0214, 0x0224, 0x0234, 0x0244, 0x0254, 0x0264,
- 0x0274, 0x0284, 0x0294, 0x02a4, 0x02b4, 0x02c4,
- 0x1105, 0x0215, 0x0225, 0x0235, 0x0245, 0x0255, 0x0265,
- 0x0275, 0x0285, 0x0295, 0x02a5, 0x02b5, 0x02c5,
- 0x1106, 0x0216, 0x0226, 0x0236, 0x0246, 0x0256, 0x0266,
- 0x0276, 0x0286, 0x0296, 0x02a6, 0x02b6, 0x02c6,
- 0x1107, 0x0217, 0x0227, 0x0237, 0x0247, 0x0257, 0x0267,
- 0x0277, 0x0287, 0x0297, 0x02a7, 0x02b7, 0x02c7,
- 0x1108, 0x0218, 0x0228, 0x0238, 0x0248, 0x0258, 0x0268,
- 0x0278, 0x0288, 0x0298, 0x02a8, 0x02b8, 0x02c8,
- 0x1109, 0x0219, 0x0229, 0x0239, 0x0249, 0x0259, 0x0269,
- 0x0279, 0x0289, 0x0299, 0x02a9, 0x02b9, 0x02c9,
- 0x110a, 0x021a, 0x022a, 0x023a, 0x024a, 0x025a, 0x026a,
- 0x027a, 0x028a, 0x029a, 0x02aa, 0x02ba, 0x02ca,
- 0x110b, 0x021b, 0x022b, 0x023b, 0x024b, 0x025b, 0x026b,
- 0x027b, 0x028b, 0x029b, 0x02ab, 0x02bb, 0x02cb,
- 0x110c, 0x021c, 0x022c, 0x023c, 0x024c, 0x025c, 0x026c,
- 0x027c, 0x028c, 0x029c, 0x02ac, 0x02bc, 0x02cc,
-};
-
-static const float codebook_vector10_vals[] = {
- 0.0000000, 1.0000000,
- 2.5198421, 4.3267487,
- 6.3496042, 8.5498797,
- 10.9027236, 13.3905183,
- 16.0000000, 18.7207544,
- 21.5443469, 24.4637810,
- 27.4731418, 30.5673509,
- 33.7419917, 36.9931811,
-};
-
-/*
- * bits 0:3, 4:7 index into _vals array
- * 8:9 bit mask of escape-coded entries
- * 12:15 number of non-zero values
- */
-static const uint16_t codebook_vector10_idx[] = {
- 0x0000, 0x1010, 0x1020, 0x1030, 0x1040, 0x1050, 0x1060, 0x1070,
- 0x1080, 0x1090, 0x10a0, 0x10b0, 0x10c0, 0x10d0, 0x10e0, 0x10f0, 0x1200,
- 0x1001, 0x2011, 0x2021, 0x2031, 0x2041, 0x2051, 0x2061, 0x2071,
- 0x2081, 0x2091, 0x20a1, 0x20b1, 0x20c1, 0x20d1, 0x20e1, 0x20f1, 0x2201,
- 0x1002, 0x2012, 0x2022, 0x2032, 0x2042, 0x2052, 0x2062, 0x2072,
- 0x2082, 0x2092, 0x20a2, 0x20b2, 0x20c2, 0x20d2, 0x20e2, 0x20f2, 0x2202,
- 0x1003, 0x2013, 0x2023, 0x2033, 0x2043, 0x2053, 0x2063, 0x2073,
- 0x2083, 0x2093, 0x20a3, 0x20b3, 0x20c3, 0x20d3, 0x20e3, 0x20f3, 0x2203,
- 0x1004, 0x2014, 0x2024, 0x2034, 0x2044, 0x2054, 0x2064, 0x2074,
- 0x2084, 0x2094, 0x20a4, 0x20b4, 0x20c4, 0x20d4, 0x20e4, 0x20f4, 0x2204,
- 0x1005, 0x2015, 0x2025, 0x2035, 0x2045, 0x2055, 0x2065, 0x2075,
- 0x2085, 0x2095, 0x20a5, 0x20b5, 0x20c5, 0x20d5, 0x20e5, 0x20f5, 0x2205,
- 0x1006, 0x2016, 0x2026, 0x2036, 0x2046, 0x2056, 0x2066, 0x2076,
- 0x2086, 0x2096, 0x20a6, 0x20b6, 0x20c6, 0x20d6, 0x20e6, 0x20f6, 0x2206,
- 0x1007, 0x2017, 0x2027, 0x2037, 0x2047, 0x2057, 0x2067, 0x2077,
- 0x2087, 0x2097, 0x20a7, 0x20b7, 0x20c7, 0x20d7, 0x20e7, 0x20f7, 0x2207,
- 0x1008, 0x2018, 0x2028, 0x2038, 0x2048, 0x2058, 0x2068, 0x2078,
- 0x2088, 0x2098, 0x20a8, 0x20b8, 0x20c8, 0x20d8, 0x20e8, 0x20f8, 0x2208,
- 0x1009, 0x2019, 0x2029, 0x2039, 0x2049, 0x2059, 0x2069, 0x2079,
- 0x2089, 0x2099, 0x20a9, 0x20b9, 0x20c9, 0x20d9, 0x20e9, 0x20f9, 0x2209,
- 0x100a, 0x201a, 0x202a, 0x203a, 0x204a, 0x205a, 0x206a, 0x207a,
- 0x208a, 0x209a, 0x20aa, 0x20ba, 0x20ca, 0x20da, 0x20ea, 0x20fa, 0x220a,
- 0x100b, 0x201b, 0x202b, 0x203b, 0x204b, 0x205b, 0x206b, 0x207b,
- 0x208b, 0x209b, 0x20ab, 0x20bb, 0x20cb, 0x20db, 0x20eb, 0x20fb, 0x220b,
- 0x100c, 0x201c, 0x202c, 0x203c, 0x204c, 0x205c, 0x206c, 0x207c,
- 0x208c, 0x209c, 0x20ac, 0x20bc, 0x20cc, 0x20dc, 0x20ec, 0x20fc, 0x220c,
- 0x100d, 0x201d, 0x202d, 0x203d, 0x204d, 0x205d, 0x206d, 0x207d,
- 0x208d, 0x209d, 0x20ad, 0x20bd, 0x20cd, 0x20dd, 0x20ed, 0x20fd, 0x220d,
- 0x100e, 0x201e, 0x202e, 0x203e, 0x204e, 0x205e, 0x206e, 0x207e,
- 0x208e, 0x209e, 0x20ae, 0x20be, 0x20ce, 0x20de, 0x20ee, 0x20fe, 0x220e,
- 0x100f, 0x201f, 0x202f, 0x203f, 0x204f, 0x205f, 0x206f, 0x207f,
- 0x208f, 0x209f, 0x20af, 0x20bf, 0x20cf, 0x20df, 0x20ef, 0x20ff, 0x220f,
- 0x1100, 0x2110, 0x2120, 0x2130, 0x2140, 0x2150, 0x2160, 0x2170,
- 0x2180, 0x2190, 0x21a0, 0x21b0, 0x21c0, 0x21d0, 0x21e0, 0x21f0, 0x2300,
-};
-
-const float *const ff_aac_codebook_vector_vals[] = {
- codebook_vector0_vals, codebook_vector0_vals,
- codebook_vector10_vals, codebook_vector10_vals,
- codebook_vector4_vals, codebook_vector4_vals,
- codebook_vector10_vals, codebook_vector10_vals,
- codebook_vector10_vals, codebook_vector10_vals,
- codebook_vector10_vals,
-};
-
-const uint16_t *const ff_aac_codebook_vector_idx[] = {
- codebook_vector02_idx, codebook_vector02_idx,
- codebook_vector02_idx, codebook_vector02_idx,
- codebook_vector4_idx, codebook_vector4_idx,
- codebook_vector6_idx, codebook_vector6_idx,
- codebook_vector8_idx, codebook_vector8_idx,
- codebook_vector10_idx,
-};
-
-/* @name swb_offsets
- * Sample offset into the window indicating the beginning of a scalefactor
- * window band
- *
- * scalefactor window band - term for scalefactor bands within a window,
- * given in Table 4.110 to Table 4.128.
- *
- * scalefactor band - a set of spectral coefficients which are scaled by one
- * scalefactor. In case of EIGHT_SHORT_SEQUENCE and grouping a scalefactor band
- * may contain several scalefactor window bands of corresponding frequency. For
- * all other window_sequences scalefactor bands and scalefactor window bands are
- * identical.
- * @{
- */
-
-static const uint16_t swb_offset_1024_96[] = {
- 0, 4, 8, 12, 16, 20, 24, 28,
- 32, 36, 40, 44, 48, 52, 56, 64,
- 72, 80, 88, 96, 108, 120, 132, 144,
- 156, 172, 188, 212, 240, 276, 320, 384,
- 448, 512, 576, 640, 704, 768, 832, 896,
- 960, 1024
-};
-
-static const uint16_t swb_offset_128_96[] = {
- 0, 4, 8, 12, 16, 20, 24, 32, 40, 48, 64, 92, 128
-};
-
-static const uint16_t swb_offset_1024_64[] = {
- 0, 4, 8, 12, 16, 20, 24, 28,
- 32, 36, 40, 44, 48, 52, 56, 64,
- 72, 80, 88, 100, 112, 124, 140, 156,
- 172, 192, 216, 240, 268, 304, 344, 384,
- 424, 464, 504, 544, 584, 624, 664, 704,
- 744, 784, 824, 864, 904, 944, 984, 1024
-};
-
-static const uint16_t swb_offset_1024_48[] = {
- 0, 4, 8, 12, 16, 20, 24, 28,
- 32, 36, 40, 48, 56, 64, 72, 80,
- 88, 96, 108, 120, 132, 144, 160, 176,
- 196, 216, 240, 264, 292, 320, 352, 384,
- 416, 448, 480, 512, 544, 576, 608, 640,
- 672, 704, 736, 768, 800, 832, 864, 896,
- 928, 1024
-};
-
-static const uint16_t swb_offset_128_48[] = {
- 0, 4, 8, 12, 16, 20, 28, 36,
- 44, 56, 68, 80, 96, 112, 128
-};
-
-static const uint16_t swb_offset_1024_32[] = {
- 0, 4, 8, 12, 16, 20, 24, 28,
- 32, 36, 40, 48, 56, 64, 72, 80,
- 88, 96, 108, 120, 132, 144, 160, 176,
- 196, 216, 240, 264, 292, 320, 352, 384,
- 416, 448, 480, 512, 544, 576, 608, 640,
- 672, 704, 736, 768, 800, 832, 864, 896,
- 928, 960, 992, 1024
-};
-
-static const uint16_t swb_offset_1024_24[] = {
- 0, 4, 8, 12, 16, 20, 24, 28,
- 32, 36, 40, 44, 52, 60, 68, 76,
- 84, 92, 100, 108, 116, 124, 136, 148,
- 160, 172, 188, 204, 220, 240, 260, 284,
- 308, 336, 364, 396, 432, 468, 508, 552,
- 600, 652, 704, 768, 832, 896, 960, 1024
-};
-
-static const uint16_t swb_offset_128_24[] = {
- 0, 4, 8, 12, 16, 20, 24, 28,
- 36, 44, 52, 64, 76, 92, 108, 128
-};
-
-static const uint16_t swb_offset_1024_16[] = {
- 0, 8, 16, 24, 32, 40, 48, 56,
- 64, 72, 80, 88, 100, 112, 124, 136,
- 148, 160, 172, 184, 196, 212, 228, 244,
- 260, 280, 300, 320, 344, 368, 396, 424,
- 456, 492, 532, 572, 616, 664, 716, 772,
- 832, 896, 960, 1024
-};
-
-static const uint16_t swb_offset_128_16[] = {
- 0, 4, 8, 12, 16, 20, 24, 28,
- 32, 40, 48, 60, 72, 88, 108, 128
-};
-
-static const uint16_t swb_offset_1024_8[] = {
- 0, 12, 24, 36, 48, 60, 72, 84,
- 96, 108, 120, 132, 144, 156, 172, 188,
- 204, 220, 236, 252, 268, 288, 308, 328,
- 348, 372, 396, 420, 448, 476, 508, 544,
- 580, 620, 664, 712, 764, 820, 880, 944,
- 1024
-};
-
-static const uint16_t swb_offset_128_8[] = {
- 0, 4, 8, 12, 16, 20, 24, 28,
- 36, 44, 52, 60, 72, 88, 108, 128
-};
-
-const uint16_t * const ff_swb_offset_1024[] = {
- swb_offset_1024_96, swb_offset_1024_96, swb_offset_1024_64,
- swb_offset_1024_48, swb_offset_1024_48, swb_offset_1024_32,
- swb_offset_1024_24, swb_offset_1024_24, swb_offset_1024_16,
- swb_offset_1024_16, swb_offset_1024_16, swb_offset_1024_8,
- swb_offset_1024_8
-};
-
-const uint16_t * const ff_swb_offset_128[] = {
- /* The last entry on the following row is swb_offset_128_64 but is a
- duplicate of swb_offset_128_96. */
- swb_offset_128_96, swb_offset_128_96, swb_offset_128_96,
- swb_offset_128_48, swb_offset_128_48, swb_offset_128_48,
- swb_offset_128_24, swb_offset_128_24, swb_offset_128_16,
- swb_offset_128_16, swb_offset_128_16, swb_offset_128_8,
- swb_offset_128_8
-};
-
-// @}
-
-/* @name ff_tns_max_bands
- * The maximum number of scalefactor bands on which TNS can operate for the long
- * and short transforms respectively. The index to these tables is related to
- * the sample rate of the audio.
- * @{
- */
-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_128[] = {
- 9, 9, 10, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14
-};
-// @}
diff --git a/src/thirdparty/ffmpeg/libavcodec/aactab.h b/src/thirdparty/ffmpeg/libavcodec/aactab.h
deleted file mode 100644
index c124febad..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/aactab.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * AAC data declarations
- * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org )
- * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov 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
- * AAC data declarations
- * @author Oded Shimon ( ods15 ods15 dyndns org )
- * @author Maxim Gavrilov ( maxim.gavrilov gmail com )
- */
-
-#ifndef AVCODEC_AACTAB_H
-#define AVCODEC_AACTAB_H
-
-#include "libavutil/mem.h"
-#include "aac.h"
-#include "aac_tablegen_decl.h"
-
-#include <stdint.h>
-
-/* NOTE:
- * Tables in this file are used by the AAC decoder and will be used by the AAC
- * encoder.
- */
-
-/* @name window coefficients
- * @{
- */
-DECLARE_ALIGNED(32, extern float, ff_aac_kbd_long_1024)[1024];
-DECLARE_ALIGNED(32, extern float, ff_aac_kbd_short_128)[128];
-// @}
-
-/* @name number of scalefactor window bands for long and short transform windows respectively
- * @{
- */
-extern const uint8_t ff_aac_num_swb_1024[];
-extern const uint8_t ff_aac_num_swb_128 [];
-// @}
-
-extern const uint8_t ff_aac_pred_sfb_max [];
-
-extern const uint32_t ff_aac_scalefactor_code[121];
-extern const uint8_t ff_aac_scalefactor_bits[121];
-
-extern const uint16_t * const ff_aac_spectral_codes[11];
-extern const uint8_t * const ff_aac_spectral_bits [11];
-extern const uint16_t ff_aac_spectral_sizes[11];
-
-extern const float *ff_aac_codebook_vectors[];
-extern const float *ff_aac_codebook_vector_vals[];
-extern const uint16_t *ff_aac_codebook_vector_idx[];
-
-extern const uint16_t * const ff_swb_offset_1024[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_128 [13];
-
-#endif /* AVCODEC_AACTAB_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/ac3.c b/src/thirdparty/ffmpeg/libavcodec/ac3.c
deleted file mode 100644
index 16077a5ca..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/ac3.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Common code between the AC-3 encoder and decoder
- * Copyright (c) 2000 Fabrice Bellard
- *
- * 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
- * Common code between the AC-3 encoder and decoder.
- */
-
-#include "avcodec.h"
-#include "ac3.h"
-#include "get_bits.h"
-
-/**
- * Starting frequency coefficient bin for each critical band.
- */
-const uint8_t ff_ac3_band_start_tab[AC3_CRITICAL_BANDS+1] = {
- 0, 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, 31,
- 34, 37, 40, 43, 46, 49, 55, 61, 67, 73,
- 79, 85, 97, 109, 121, 133, 157, 181, 205, 229, 253
-};
-
-#if CONFIG_HARDCODED_TABLES
-
-/**
- * Map each frequency coefficient bin to the critical band that contains it.
- */
-const uint8_t ff_ac3_bin_to_band_tab[253] = {
- 0,
- 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, 28, 28, 29, 29, 29, 30, 30, 30,
- 31, 31, 31, 32, 32, 32, 33, 33, 33, 34, 34, 34,
- 35, 35, 35, 35, 35, 35, 36, 36, 36, 36, 36, 36,
- 37, 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, 38,
- 39, 39, 39, 39, 39, 39, 40, 40, 40, 40, 40, 40,
- 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
- 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
- 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
- 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
- 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
- 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
- 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
- 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
- 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
- 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
- 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49
-};
-
-#else /* CONFIG_HARDCODED_TABLES */
-uint8_t ff_ac3_bin_to_band_tab[253];
-#endif
-
-static inline int calc_lowcomp1(int a, int b0, int b1, int c)
-{
- if ((b0 + 256) == b1) {
- a = c;
- } else if (b0 > b1) {
- a = FFMAX(a - 64, 0);
- }
- return a;
-}
-
-static inline int calc_lowcomp(int a, int b0, int b1, int bin)
-{
- if (bin < 7) {
- return calc_lowcomp1(a, b0, b1, 384);
- } else if (bin < 20) {
- return calc_lowcomp1(a, b0, b1, 320);
- } else {
- return FFMAX(a - 128, 0);
- }
-}
-
-void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd,
- int16_t *band_psd)
-{
- int bin, band;
-
- /* exponent mapping to PSD */
- for (bin = start; bin < end; bin++) {
- psd[bin]=(3072 - (exp[bin] << 7));
- }
-
- /* PSD integration */
- bin = start;
- band = ff_ac3_bin_to_band_tab[start];
- do {
- int v = psd[bin++];
- int band_end = FFMIN(ff_ac3_band_start_tab[band+1], end);
- for (; bin < band_end; bin++) {
- int max = FFMAX(v, psd[bin]);
- /* logadd */
- int adr = FFMIN(max - ((v + psd[bin] + 1) >> 1), 255);
- v = max + ff_ac3_log_add_tab[adr];
- }
- band_psd[band++] = v;
- } while (end > ff_ac3_band_start_tab[band]);
-}
-
-int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
- int start, int end, int fast_gain, int is_lfe,
- int dba_mode, int dba_nsegs, uint8_t *dba_offsets,
- uint8_t *dba_lengths, uint8_t *dba_values,
- int16_t *mask)
-{
- int16_t excite[AC3_CRITICAL_BANDS]; /* excitation */
- int band;
- int band_start, band_end, begin, end1;
- int lowcomp, fastleak, slowleak;
-
- /* excitation function */
- band_start = ff_ac3_bin_to_band_tab[start];
- band_end = ff_ac3_bin_to_band_tab[end-1] + 1;
-
- if (band_start == 0) {
- lowcomp = 0;
- lowcomp = calc_lowcomp1(lowcomp, band_psd[0], band_psd[1], 384);
- excite[0] = band_psd[0] - fast_gain - lowcomp;
- lowcomp = calc_lowcomp1(lowcomp, band_psd[1], band_psd[2], 384);
- excite[1] = band_psd[1] - fast_gain - lowcomp;
- begin = 7;
- for (band = 2; band < 7; band++) {
- if (!(is_lfe && band == 6))
- lowcomp = calc_lowcomp1(lowcomp, band_psd[band], band_psd[band+1], 384);
- fastleak = band_psd[band] - fast_gain;
- slowleak = band_psd[band] - s->slow_gain;
- excite[band] = fastleak - lowcomp;
- if (!(is_lfe && band == 6)) {
- if (band_psd[band] <= band_psd[band+1]) {
- begin = band + 1;
- break;
- }
- }
- }
-
- end1 = FFMIN(band_end, 22);
- for (band = begin; band < end1; band++) {
- if (!(is_lfe && band == 6))
- lowcomp = calc_lowcomp(lowcomp, band_psd[band], band_psd[band+1], band);
- fastleak = FFMAX(fastleak - s->fast_decay, band_psd[band] - fast_gain);
- slowleak = FFMAX(slowleak - s->slow_decay, band_psd[band] - s->slow_gain);
- excite[band] = FFMAX(fastleak - lowcomp, slowleak);
- }
- begin = 22;
- } else {
- /* coupling channel */
- begin = band_start;
- fastleak = (s->cpl_fast_leak << 8) + 768;
- slowleak = (s->cpl_slow_leak << 8) + 768;
- }
-
- for (band = begin; band < band_end; band++) {
- fastleak = FFMAX(fastleak - s->fast_decay, band_psd[band] - fast_gain);
- slowleak = FFMAX(slowleak - s->slow_decay, band_psd[band] - s->slow_gain);
- excite[band] = FFMAX(fastleak, slowleak);
- }
-
- /* compute masking curve */
-
- for (band = band_start; band < band_end; band++) {
- int tmp = s->db_per_bit - band_psd[band];
- if (tmp > 0) {
- excite[band] += tmp >> 2;
- }
- mask[band] = FFMAX(ff_ac3_hearing_threshold_tab[band >> s->sr_shift][s->sr_code], excite[band]);
- }
-
- /* delta bit allocation */
-
- if (dba_mode == DBA_REUSE || dba_mode == DBA_NEW) {
- int i, seg, delta;
- if (dba_nsegs > 8)
- return -1;
- band = band_start;
- for (seg = 0; seg < dba_nsegs; seg++) {
- band += dba_offsets[seg];
- if (band >= AC3_CRITICAL_BANDS || dba_lengths[seg] > AC3_CRITICAL_BANDS-band)
- return -1;
- if (dba_values[seg] >= 4) {
- delta = (dba_values[seg] - 3) << 7;
- } else {
- delta = (dba_values[seg] - 4) << 7;
- }
- for (i = 0; i < dba_lengths[seg]; i++) {
- mask[band++] += delta;
- }
- }
- }
- return 0;
-}
-
-/**
- * Initialize some tables.
- * note: This function must remain thread safe because it is called by the
- * AVParser init code.
- */
-av_cold void ff_ac3_common_init(void)
-{
-#if !CONFIG_HARDCODED_TABLES
- /* compute ff_ac3_bin_to_band_tab from ff_ac3_band_start_tab */
- int bin = 0, band;
- for (band = 0; band < AC3_CRITICAL_BANDS; band++) {
- int band_end = ff_ac3_band_start_tab[band+1];
- while (bin < band_end)
- ff_ac3_bin_to_band_tab[bin++] = band;
- }
-#endif /* !CONFIG_HARDCODED_TABLES */
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/ac3.h b/src/thirdparty/ffmpeg/libavcodec/ac3.h
deleted file mode 100644
index ecf5bedb8..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/ac3.h
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Common code between the AC-3 encoder and decoder
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
- *
- * 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
- * Common code between the AC-3 encoder and decoder.
- */
-
-#ifndef AVCODEC_AC3_H
-#define AVCODEC_AC3_H
-
-#define AC3_MAX_CODED_FRAME_SIZE 3840 /* in bytes */
-#define AC3_MAX_CHANNELS 7 /**< maximum number of channels, including coupling channel */
-#define CPL_CH 0 /**< coupling channel index */
-
-#define AC3_MAX_COEFS 256
-#define AC3_BLOCK_SIZE 256
-#define AC3_MAX_BLOCKS 6
-#define AC3_FRAME_SIZE (AC3_MAX_BLOCKS * 256)
-#define AC3_WINDOW_SIZE (AC3_BLOCK_SIZE * 2)
-#define AC3_CRITICAL_BANDS 50
-#define AC3_MAX_CPL_BANDS 18
-
-#include "libavutil/opt.h"
-#include "avcodec.h"
-#include "ac3tab.h"
-
-/* exponent encoding strategy */
-#define EXP_REUSE 0
-#define EXP_NEW 1
-
-#define EXP_D15 1
-#define EXP_D25 2
-#define EXP_D45 3
-
-/* pre-defined gain values */
-#define LEVEL_PLUS_3DB 1.4142135623730950
-#define LEVEL_PLUS_1POINT5DB 1.1892071150027209
-#define LEVEL_MINUS_1POINT5DB 0.8408964152537145
-#define LEVEL_MINUS_3DB 0.7071067811865476
-#define LEVEL_MINUS_4POINT5DB 0.5946035575013605
-#define LEVEL_MINUS_6DB 0.5000000000000000
-#define LEVEL_MINUS_9DB 0.3535533905932738
-#define LEVEL_ZERO 0.0000000000000000
-#define LEVEL_ONE 1.0000000000000000
-
-/** Delta bit allocation strategy */
-typedef enum {
- DBA_REUSE = 0,
- DBA_NEW,
- DBA_NONE,
- DBA_RESERVED
-} AC3DeltaStrategy;
-
-/** Channel mode (audio coding mode) */
-typedef enum {
- AC3_CHMODE_DUALMONO = 0,
- AC3_CHMODE_MONO,
- AC3_CHMODE_STEREO,
- AC3_CHMODE_3F,
- AC3_CHMODE_2F1R,
- AC3_CHMODE_3F1R,
- AC3_CHMODE_2F2R,
- AC3_CHMODE_3F2R
-} AC3ChannelMode;
-
-typedef struct AC3BitAllocParameters {
- int sr_code;
- int sr_shift;
- int slow_gain, slow_decay, fast_decay, db_per_bit, floor;
- int cpl_fast_leak, cpl_slow_leak;
-} AC3BitAllocParameters;
-
-/**
- * @struct AC3HeaderInfo
- * Coded AC-3 header values up to the lfeon element, plus derived values.
- */
-typedef struct AC3HeaderInfo {
- /** @name Coded elements
- * @{
- */
- uint16_t sync_word;
- uint16_t crc1;
- uint8_t sr_code;
- uint8_t bitstream_id;
- uint8_t bitstream_mode;
- uint8_t channel_mode;
- uint8_t lfe_on;
- uint8_t frame_type;
- int substreamid; ///< substream identification
- int center_mix_level; ///< Center mix level index
- int surround_mix_level; ///< Surround mix level index
- uint16_t channel_map;
- int num_blocks; ///< number of audio blocks
- /** @} */
-
- /** @name Derived values
- * @{
- */
- uint8_t sr_shift;
- uint16_t sample_rate;
- uint32_t bit_rate;
- uint8_t channels;
- uint16_t frame_size;
- uint64_t channel_layout;
- /** @} */
-} AC3HeaderInfo;
-
-typedef enum {
- EAC3_FRAME_TYPE_INDEPENDENT = 0,
- EAC3_FRAME_TYPE_DEPENDENT,
- EAC3_FRAME_TYPE_AC3_CONVERT,
- EAC3_FRAME_TYPE_RESERVED
-} EAC3FrameType;
-
-void ff_ac3_common_init(void);
-
-/**
- * Calculate the log power-spectral density of the input signal.
- * This gives a rough estimate of signal power in the frequency domain by using
- * the spectral envelope (exponents). The psd is also separately grouped
- * into critical bands for use in the calculating the masking curve.
- * 128 units in psd = -6 dB. The dbknee parameter in AC3BitAllocParameters
- * determines the reference level.
- *
- * @param[in] exp frequency coefficient exponents
- * @param[in] start starting bin location
- * @param[in] end ending bin location
- * @param[out] psd signal power for each frequency bin
- * @param[out] band_psd signal power for each critical band
- */
-void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd,
- int16_t *band_psd);
-
-/**
- * Calculate the masking curve.
- * First, the excitation is calculated using parameters in s and the signal
- * power in each critical band. The excitation is compared with a predefined
- * hearing threshold table to produce the masking curve. If delta bit
- * allocation information is provided, it is used for adjusting the masking
- * curve, usually to give a closer match to a better psychoacoustic model.
- *
- * @param[in] s adjustable bit allocation parameters
- * @param[in] band_psd signal power for each critical band
- * @param[in] start starting bin location
- * @param[in] end ending bin location
- * @param[in] fast_gain fast gain (estimated signal-to-mask ratio)
- * @param[in] is_lfe whether or not the channel being processed is the LFE
- * @param[in] dba_mode delta bit allocation mode (none, reuse, or new)
- * @param[in] dba_nsegs number of delta segments
- * @param[in] dba_offsets location offsets for each segment
- * @param[in] dba_lengths length of each segment
- * @param[in] dba_values delta bit allocation for each segment
- * @param[out] mask calculated masking curve
- * @return returns 0 for success, non-zero for error
- */
-int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd,
- int start, int end, int fast_gain, int is_lfe,
- int dba_mode, int dba_nsegs, uint8_t *dba_offsets,
- uint8_t *dba_lengths, uint8_t *dba_values,
- int16_t *mask);
-
-#endif /* AVCODEC_AC3_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/ac3_parser.c b/src/thirdparty/ffmpeg/libavcodec/ac3_parser.c
deleted file mode 100644
index 906fcc027..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/ac3_parser.c
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * AC-3 parser
- * Copyright (c) 2003 Fabrice Bellard
- * Copyright (c) 2003 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/channel_layout.h"
-#include "parser.h"
-#include "ac3_parser.h"
-#include "aac_ac3_parser.h"
-#include "get_bits.h"
-
-
-#define AC3_HEADER_SIZE 7
-
-
-static const uint8_t eac3_blocks[4] = {
- 1, 2, 3, 6
-};
-
-/**
- * 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 avpriv_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
-{
- int frame_size_code;
-
- memset(hdr, 0, sizeof(*hdr));
-
- hdr->sync_word = get_bits(gbc, 16);
- if(hdr->sync_word != 0x0B77)
- return AAC_AC3_PARSE_ERROR_SYNC;
-
- /* read ahead to bsid to distinguish between AC-3 and E-AC-3 */
- hdr->bitstream_id = show_bits_long(gbc, 29) & 0x1F;
- if(hdr->bitstream_id > 16)
- return AAC_AC3_PARSE_ERROR_BSID;
-
- hdr->num_blocks = 6;
-
- /* set default mix levels */
- hdr->center_mix_level = 5; // -4.5dB
- hdr->surround_mix_level = 6; // -6.0dB
-
- if(hdr->bitstream_id <= 10) {
- /* Normal AC-3 */
- hdr->crc1 = get_bits(gbc, 16);
- hdr->sr_code = get_bits(gbc, 2);
- if(hdr->sr_code == 3)
- return AAC_AC3_PARSE_ERROR_SAMPLE_RATE;
-
- frame_size_code = get_bits(gbc, 6);
- if(frame_size_code > 37)
- return AAC_AC3_PARSE_ERROR_FRAME_SIZE;
-
- skip_bits(gbc, 5); // skip bsid, already got it
-
- hdr->bitstream_mode = get_bits(gbc, 3);
- hdr->channel_mode = get_bits(gbc, 3);
-
- if(hdr->channel_mode == AC3_CHMODE_STEREO) {
- skip_bits(gbc, 2); // skip dsurmod
- } else {
- if((hdr->channel_mode & 1) && hdr->channel_mode != AC3_CHMODE_MONO)
- hdr-> center_mix_level = center_levels[get_bits(gbc, 2)];
- if(hdr->channel_mode & 4)
- hdr->surround_mix_level = surround_levels[get_bits(gbc, 2)];
- }
- hdr->lfe_on = get_bits1(gbc);
-
- hdr->sr_shift = FFMAX(hdr->bitstream_id, 8) - 8;
- hdr->sample_rate = ff_ac3_sample_rate_tab[hdr->sr_code] >> hdr->sr_shift;
- hdr->bit_rate = (ff_ac3_bitrate_tab[frame_size_code>>1] * 1000) >> hdr->sr_shift;
- hdr->channels = ff_ac3_channels_tab[hdr->channel_mode] + hdr->lfe_on;
- hdr->frame_size = ff_ac3_frame_size_tab[frame_size_code][hdr->sr_code] * 2;
- hdr->frame_type = EAC3_FRAME_TYPE_AC3_CONVERT; //EAC3_FRAME_TYPE_INDEPENDENT;
- hdr->substreamid = 0;
- } else {
- /* Enhanced AC-3 */
- hdr->crc1 = 0;
- hdr->frame_type = get_bits(gbc, 2);
- if(hdr->frame_type == EAC3_FRAME_TYPE_RESERVED)
- return AAC_AC3_PARSE_ERROR_FRAME_TYPE;
-
- hdr->substreamid = get_bits(gbc, 3);
-
- hdr->frame_size = (get_bits(gbc, 11) + 1) << 1;
- if(hdr->frame_size < AC3_HEADER_SIZE)
- return AAC_AC3_PARSE_ERROR_FRAME_SIZE;
-
- hdr->sr_code = get_bits(gbc, 2);
- if (hdr->sr_code == 3) {
- int sr_code2 = get_bits(gbc, 2);
- if(sr_code2 == 3)
- return AAC_AC3_PARSE_ERROR_SAMPLE_RATE;
- hdr->sample_rate = ff_ac3_sample_rate_tab[sr_code2] / 2;
- hdr->sr_shift = 1;
- } else {
- hdr->num_blocks = eac3_blocks[get_bits(gbc, 2)];
- hdr->sample_rate = ff_ac3_sample_rate_tab[hdr->sr_code];
- hdr->sr_shift = 0;
- }
-
- hdr->channel_mode = get_bits(gbc, 3);
- hdr->lfe_on = get_bits1(gbc);
-
- hdr->bit_rate = (uint32_t)(8.0 * hdr->frame_size * hdr->sample_rate /
- (hdr->num_blocks * 256.0));
- hdr->channels = ff_ac3_channels_tab[hdr->channel_mode] + hdr->lfe_on;
- }
- hdr->channel_layout = avpriv_ac3_channel_layout_tab[hdr->channel_mode];
- if (hdr->lfe_on)
- hdr->channel_layout |= AV_CH_LOW_FREQUENCY;
-
- return 0;
-}
-
-static int ac3_sync(uint64_t state, AACAC3ParseContext *hdr_info,
- int *need_next_header, int *new_frame_start)
-{
- int err;
- union {
- uint64_t u64;
- uint8_t u8[8];
- } tmp = { av_be2ne64(state) };
- AC3HeaderInfo hdr;
- GetBitContext gbc;
-
- init_get_bits(&gbc, tmp.u8+8-AC3_HEADER_SIZE, 54);
- err = avpriv_ac3_parse_header(&gbc, &hdr);
-
- if(err < 0)
- return 0;
-
- hdr_info->sample_rate = hdr.sample_rate;
- hdr_info->bit_rate = hdr.bit_rate;
- hdr_info->channels = hdr.channels;
- hdr_info->channel_layout = hdr.channel_layout;
- hdr_info->samples = hdr.num_blocks * 256;
- hdr_info->service_type = hdr.bitstream_mode;
- if (hdr.bitstream_mode == 0x7 && hdr.channels > 1)
- hdr_info->service_type = AV_AUDIO_SERVICE_TYPE_KARAOKE;
- if(hdr.bitstream_id>10)
- hdr_info->codec_id = AV_CODEC_ID_EAC3;
- else if (hdr_info->codec_id == AV_CODEC_ID_NONE)
- hdr_info->codec_id = AV_CODEC_ID_AC3;
-
- *need_next_header = (hdr.frame_type != EAC3_FRAME_TYPE_AC3_CONVERT);
- *new_frame_start = (hdr.frame_type != EAC3_FRAME_TYPE_DEPENDENT);
- return hdr.frame_size;
-}
-
-static av_cold int ac3_parse_init(AVCodecParserContext *s1)
-{
- AACAC3ParseContext *s = s1->priv_data;
- s->header_size = AC3_HEADER_SIZE;
- s->sync = ac3_sync;
- return 0;
-}
-
-
-AVCodecParser ff_ac3_parser = {
- .codec_ids = { AV_CODEC_ID_AC3, AV_CODEC_ID_EAC3 },
- .priv_data_size = sizeof(AACAC3ParseContext),
- .parser_init = ac3_parse_init,
- .parser_parse = ff_aac_ac3_parse,
- .parser_close = ff_parse_close,
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/ac3_parser.h b/src/thirdparty/ffmpeg/libavcodec/ac3_parser.h
deleted file mode 100644
index c3caf9964..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/ac3_parser.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * AC-3 parser prototypes
- * Copyright (c) 2003 Fabrice Bellard
- * Copyright (c) 2003 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
- */
-
-#ifndef AVCODEC_AC3_PARSER_H
-#define AVCODEC_AC3_PARSER_H
-
-#include "ac3.h"
-#include "get_bits.h"
-
-/**
- * Parse AC-3 frame header.
- * 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.
- * @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_header(GetBitContext *gbc, AC3HeaderInfo *hdr);
-
-#endif /* AVCODEC_AC3_PARSER_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/ac3dec.c b/src/thirdparty/ffmpeg/libavcodec/ac3dec.c
deleted file mode 100644
index a3e1e8ebe..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/ac3dec.c
+++ /dev/null
@@ -1,1492 +0,0 @@
-/*
- * 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
- */
-
-#include <stdio.h>
-#include <stddef.h>
-#include <math.h>
-#include <string.h>
-
-#include "libavutil/crc.h"
-#include "libavutil/opt.h"
-#include "internal.h"
-#include "aac_ac3_parser.h"
-#include "ac3_parser.h"
-#include "ac3dec.h"
-#include "ac3dec_data.h"
-#include "kbdwin.h"
-
-/**
- * table for ungrouping 3 values in 7 bits.
- * used for exponents and bap=2 mantissas
- */
-static uint8_t ungroup_3_in_7_bits_tab[128][3];
-
-/** tables for ungrouping mantissas */
-static int b1_mantissas[32][3];
-static int b2_mantissas[128][3];
-static int b3_mantissas[8];
-static int b4_mantissas[128][2];
-static int b5_mantissas[16];
-
-/**
- * Quantization table: levels for symmetric. bits for asymmetric.
- * reference: Table 7.18 Mapping of bap to Quantizer
- */
-static const uint8_t quantization_tab[16] = {
- 0, 3, 5, 7, 11, 15,
- 5, 6, 7, 8, 9, 10, 11, 12, 14, 16
-};
-
-/** dynamic range table. converts codes to scale factors. */
-static float dynamic_range_tab[256];
-
-/** Adjustments in dB gain */
-static const float gain_levels[9] = {
- LEVEL_PLUS_3DB,
- LEVEL_PLUS_1POINT5DB,
- LEVEL_ONE,
- LEVEL_MINUS_1POINT5DB,
- LEVEL_MINUS_3DB,
- LEVEL_MINUS_4POINT5DB,
- LEVEL_MINUS_6DB,
- LEVEL_ZERO,
- LEVEL_MINUS_9DB
-};
-
-/**
- * Table for default stereo downmixing coefficients
- * reference: Section 7.8.2 Downmixing Into Two Channels
- */
-static const uint8_t ac3_default_coeffs[8][5][2] = {
- { { 2, 7 }, { 7, 2 }, },
- { { 4, 4 }, },
- { { 2, 7 }, { 7, 2 }, },
- { { 2, 7 }, { 5, 5 }, { 7, 2 }, },
- { { 2, 7 }, { 7, 2 }, { 6, 6 }, },
- { { 2, 7 }, { 5, 5 }, { 7, 2 }, { 8, 8 }, },
- { { 2, 7 }, { 7, 2 }, { 6, 7 }, { 7, 6 }, },
- { { 2, 7 }, { 5, 5 }, { 7, 2 }, { 6, 7 }, { 7, 6 }, },
-};
-
-/**
- * Symmetrical Dequantization
- * reference: Section 7.3.3 Expansion of Mantissas for Symmetrical Quantization
- * Tables 7.19 to 7.23
- */
-static inline int
-symmetric_dequant(int code, int levels)
-{
- return ((code - (levels >> 1)) << 24) / levels;
-}
-
-/*
- * Initialize tables at runtime.
- */
-static av_cold void ac3_tables_init(void)
-{
- int i;
-
- /* generate table for ungrouping 3 values in 7 bits
- reference: Section 7.1.3 Exponent Decoding */
- for (i = 0; i < 128; i++) {
- ungroup_3_in_7_bits_tab[i][0] = i / 25;
- ungroup_3_in_7_bits_tab[i][1] = (i % 25) / 5;
- ungroup_3_in_7_bits_tab[i][2] = (i % 25) % 5;
- }
-
- /* generate grouped mantissa tables
- reference: Section 7.3.5 Ungrouping of Mantissas */
- for (i = 0; i < 32; i++) {
- /* bap=1 mantissas */
- b1_mantissas[i][0] = symmetric_dequant(ff_ac3_ungroup_3_in_5_bits_tab[i][0], 3);
- b1_mantissas[i][1] = symmetric_dequant(ff_ac3_ungroup_3_in_5_bits_tab[i][1], 3);
- b1_mantissas[i][2] = symmetric_dequant(ff_ac3_ungroup_3_in_5_bits_tab[i][2], 3);
- }
- for (i = 0; i < 128; i++) {
- /* bap=2 mantissas */
- b2_mantissas[i][0] = symmetric_dequant(ungroup_3_in_7_bits_tab[i][0], 5);
- b2_mantissas[i][1] = symmetric_dequant(ungroup_3_in_7_bits_tab[i][1], 5);
- b2_mantissas[i][2] = symmetric_dequant(ungroup_3_in_7_bits_tab[i][2], 5);
-
- /* bap=4 mantissas */
- b4_mantissas[i][0] = symmetric_dequant(i / 11, 11);
- b4_mantissas[i][1] = symmetric_dequant(i % 11, 11);
- }
- /* generate ungrouped mantissa tables
- reference: Tables 7.21 and 7.23 */
- for (i = 0; i < 7; i++) {
- /* bap=3 mantissas */
- b3_mantissas[i] = symmetric_dequant(i, 7);
- }
- for (i = 0; i < 15; i++) {
- /* bap=5 mantissas */
- b5_mantissas[i] = symmetric_dequant(i, 15);
- }
-
- /* generate dynamic range table
- reference: Section 7.7.1 Dynamic Range Control */
- for (i = 0; i < 256; i++) {
- int v = (i >> 5) - ((i >> 7) << 3) - 5;
- dynamic_range_tab[i] = powf(2.0f, v) * ((i & 0x1F) | 0x20);
- }
-}
-
-/**
- * AVCodec initialization
- */
-static av_cold int ac3_decode_init(AVCodecContext *avctx)
-{
- AC3DecodeContext *s = avctx->priv_data;
- int i;
-
- s->avctx = avctx;
-
- ff_ac3_common_init();
- 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);
- ff_dsputil_init(&s->dsp, avctx);
- avpriv_float_dsp_init(&s->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
- 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;
-
- /* allow downmixing to stereo or mono */
- if (avctx->channels > 0 && avctx->request_channels > 0 &&
- avctx->request_channels < avctx->channels &&
- avctx->request_channels <= 2) {
- avctx->channels = avctx->request_channels;
- }
- s->downmixed = 1;
-
- for (i = 0; i < AC3_MAX_CHANNELS; i++) {
- s->xcfptr[i] = s->transform_coeffs[i];
- s->dlyptr[i] = s->delay[i];
- }
-
- return 0;
-}
-
-/**
- * Parse the 'sync info' and 'bit stream info' from the AC-3 bitstream.
- * GetBitContext within AC3DecodeContext must point to
- * the start of the synchronized AC-3 bitstream.
- */
-static int ac3_parse_header(AC3DecodeContext *s)
-{
- GetBitContext *gbc = &s->gbc;
- int i;
-
- /* read the rest of the bsi. read twice for dual mono mode. */
- i = !s->channel_mode;
- do {
- skip_bits(gbc, 5); // skip dialog normalization
- if (get_bits1(gbc))
- skip_bits(gbc, 8); //skip compression
- if (get_bits1(gbc))
- skip_bits(gbc, 8); //skip language code
- if (get_bits1(gbc))
- skip_bits(gbc, 7); //skip audio production information
- } while (i--);
-
- 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 additional bitstream info */
- if (get_bits1(gbc)) {
- i = get_bits(gbc, 6);
- do {
- skip_bits(gbc, 8);
- } while (i--);
- }
-
- return 0;
-}
-
-/**
- * Common function to parse AC-3 or E-AC-3 frame header
- */
-static int parse_frame_header(AC3DecodeContext *s)
-{
- AC3HeaderInfo hdr;
- int err;
-
- err = avpriv_ac3_parse_header(&s->gbc, &hdr);
- if (err)
- return err;
-
- /* get decoding parameters from header info */
- s->bit_alloc_params.sr_code = hdr.sr_code;
- s->bitstream_mode = hdr.bitstream_mode;
- s->channel_mode = hdr.channel_mode;
- s->channel_layout = hdr.channel_layout;
- s->lfe_on = hdr.lfe_on;
- s->bit_alloc_params.sr_shift = hdr.sr_shift;
- s->sample_rate = hdr.sample_rate;
- s->bit_rate = hdr.bit_rate;
- s->channels = hdr.channels;
- s->fbw_channels = s->channels - s->lfe_on;
- s->lfe_ch = s->fbw_channels + 1;
- s->frame_size = hdr.frame_size;
- s->center_mix_level = hdr.center_mix_level;
- s->surround_mix_level = hdr.surround_mix_level;
- s->num_blocks = hdr.num_blocks;
- s->frame_type = hdr.frame_type;
- s->substreamid = hdr.substreamid;
-
- if (s->lfe_on) {
- s->start_freq[s->lfe_ch] = 0;
- s->end_freq[s->lfe_ch] = 7;
- s->num_exp_groups[s->lfe_ch] = 2;
- s->channel_in_cpl[s->lfe_ch] = 0;
- }
-
- if (hdr.bitstream_id <= 10) {
- s->eac3 = 0;
- s->snr_offset_strategy = 2;
- s->block_switch_syntax = 1;
- s->dither_flag_syntax = 1;
- s->bit_allocation_syntax = 1;
- s->fast_gain_syntax = 0;
- s->first_cpl_leak = 0;
- s->dba_syntax = 1;
- s->skip_syntax = 1;
- memset(s->channel_uses_aht, 0, sizeof(s->channel_uses_aht));
- return ac3_parse_header(s);
- } else if (CONFIG_EAC3_DECODER) {
- s->eac3 = 1;
- return ff_eac3_parse_header(s);
- } else {
- av_log(s->avctx, AV_LOG_ERROR, "E-AC-3 support not compiled in\n");
- return -1;
- }
-}
-
-/**
- * Set stereo downmixing coefficients based on frame header info.
- * reference: Section 7.8.2 Downmixing Into Two Channels
- */
-static void set_downmix_coeffs(AC3DecodeContext *s)
-{
- int i;
- float cmix = gain_levels[s-> center_mix_level];
- float smix = gain_levels[s->surround_mix_level];
- float norm0, norm1;
-
- 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]];
- }
- if (s->channel_mode > 1 && s->channel_mode & 1) {
- s->downmix_coeffs[1][0] = s->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;
- }
- 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;
- }
-
- /* 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 = 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;
- }
-
- 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;
- }
-}
-
-/**
- * Decode the grouped exponents according to exponent strategy.
- * reference: Section 7.1.3 Exponent Decoding
- */
-static int decode_exponents(GetBitContext *gbc, int exp_strategy, int ngrps,
- uint8_t absexp, int8_t *dexps)
-{
- int i, j, grp, group_size;
- int dexp[256];
- int expacc, prevexp;
-
- /* unpack groups */
- group_size = exp_strategy + (exp_strategy == EXP_D45);
- for (grp = 0, i = 0; grp < ngrps; grp++) {
- expacc = get_bits(gbc, 7);
- dexp[i++] = ungroup_3_in_7_bits_tab[expacc][0];
- dexp[i++] = ungroup_3_in_7_bits_tab[expacc][1];
- dexp[i++] = ungroup_3_in_7_bits_tab[expacc][2];
- }
-
- /* convert to absolute exps and expand groups */
- prevexp = absexp;
- for (i = 0, j = 0; i < ngrps * 3; i++) {
- prevexp += dexp[i] - 2;
- if (prevexp > 24U)
- return -1;
- switch (group_size) {
- case 4: dexps[j++] = prevexp;
- dexps[j++] = prevexp;
- case 2: dexps[j++] = prevexp;
- case 1: dexps[j++] = prevexp;
- }
- }
- return 0;
-}
-
-/**
- * Generate transform coefficients for each coupled channel in the coupling
- * range using the coupling coefficients and coupling coordinates.
- * reference: Section 7.4.3 Coupling Coordinate Format
- */
-static void calc_transform_coeffs_cpl(AC3DecodeContext *s)
-{
- int bin, band, ch;
-
- bin = s->start_freq[CPL_CH];
- for (band = 0; band < s->num_cpl_bands; band++) {
- int band_start = bin;
- int band_end = bin + s->cpl_band_sizes[band];
- for (ch = 1; ch <= s->fbw_channels; ch++) {
- if (s->channel_in_cpl[ch]) {
- int cpl_coord = s->cpl_coords[ch][band] << 5;
- for (bin = band_start; bin < band_end; bin++) {
- s->fixed_coeffs[ch][bin] =
- MULH(s->fixed_coeffs[CPL_CH][bin] << 4, cpl_coord);
- }
- if (ch == 2 && s->phase_flags[band]) {
- for (bin = band_start; bin < band_end; bin++)
- s->fixed_coeffs[2][bin] = -s->fixed_coeffs[2][bin];
- }
- }
- }
- bin = band_end;
- }
-}
-
-/**
- * Grouped mantissas for 3-level 5-level and 11-level quantization
- */
-typedef struct {
- int b1_mant[2];
- int b2_mant[2];
- int b4_mant;
- int b1;
- int b2;
- int b4;
-} mant_groups;
-
-/**
- * Decode the transform coefficients for a particular channel
- * reference: Section 7.3 Quantization and Decoding of Mantissas
- */
-static void ac3_decode_transform_coeffs_ch(AC3DecodeContext *s, int ch_index, mant_groups *m)
-{
- int start_freq = s->start_freq[ch_index];
- int end_freq = s->end_freq[ch_index];
- uint8_t *baps = s->bap[ch_index];
- int8_t *exps = s->dexps[ch_index];
- int *coeffs = s->fixed_coeffs[ch_index];
- int dither = (ch_index == CPL_CH) || s->dither_flag[ch_index];
- GetBitContext *gbc = &s->gbc;
- int freq;
-
- for (freq = start_freq; freq < end_freq; freq++) {
- int bap = baps[freq];
- int mantissa;
- switch (bap) {
- case 0:
- /* random noise with approximate range of -0.707 to 0.707 */
- if (dither)
- mantissa = (((av_lfg_get(&s->dith_state)>>8)*181)>>8) - 5931008;
- else
- mantissa = 0;
- break;
- case 1:
- if (m->b1) {
- m->b1--;
- mantissa = m->b1_mant[m->b1];
- } else {
- int bits = get_bits(gbc, 5);
- mantissa = b1_mantissas[bits][0];
- m->b1_mant[1] = b1_mantissas[bits][1];
- m->b1_mant[0] = b1_mantissas[bits][2];
- m->b1 = 2;
- }
- break;
- case 2:
- if (m->b2) {
- m->b2--;
- mantissa = m->b2_mant[m->b2];
- } else {
- int bits = get_bits(gbc, 7);
- mantissa = b2_mantissas[bits][0];
- m->b2_mant[1] = b2_mantissas[bits][1];
- m->b2_mant[0] = b2_mantissas[bits][2];
- m->b2 = 2;
- }
- break;
- case 3:
- mantissa = b3_mantissas[get_bits(gbc, 3)];
- break;
- case 4:
- if (m->b4) {
- m->b4 = 0;
- mantissa = m->b4_mant;
- } else {
- int bits = get_bits(gbc, 7);
- mantissa = b4_mantissas[bits][0];
- m->b4_mant = b4_mantissas[bits][1];
- m->b4 = 1;
- }
- break;
- case 5:
- mantissa = b5_mantissas[get_bits(gbc, 4)];
- break;
- default: /* 6 to 15 */
- /* Shift mantissa and sign-extend it. */
- mantissa = get_sbits(gbc, quantization_tab[bap]);
- mantissa <<= 24 - quantization_tab[bap];
- break;
- }
- coeffs[freq] = mantissa >> exps[freq];
- }
-}
-
-/**
- * Remove random dithering from coupling range coefficients with zero-bit
- * mantissas for coupled channels which do not use dithering.
- * reference: Section 7.3.4 Dither for Zero Bit Mantissas (bap=0)
- */
-static void remove_dithering(AC3DecodeContext *s) {
- int ch, i;
-
- for (ch = 1; ch <= s->fbw_channels; ch++) {
- if (!s->dither_flag[ch] && s->channel_in_cpl[ch]) {
- for (i = s->start_freq[CPL_CH]; i < s->end_freq[CPL_CH]; i++) {
- if (!s->bap[CPL_CH][i])
- s->fixed_coeffs[ch][i] = 0;
- }
- }
- }
-}
-
-static void decode_transform_coeffs_ch(AC3DecodeContext *s, int blk, int ch,
- mant_groups *m)
-{
- if (!s->channel_uses_aht[ch]) {
- ac3_decode_transform_coeffs_ch(s, ch, m);
- } else {
- /* if AHT is used, mantissas for all blocks are encoded in the first
- block of the frame. */
- int bin;
- if (!blk && CONFIG_EAC3_DECODER)
- ff_eac3_decode_transform_coeffs_aht_ch(s, ch);
- for (bin = s->start_freq[ch]; bin < s->end_freq[ch]; bin++) {
- s->fixed_coeffs[ch][bin] = s->pre_mantissa[ch][bin][blk] >> s->dexps[ch][bin];
- }
- }
-}
-
-/**
- * Decode the transform coefficients.
- */
-static void decode_transform_coeffs(AC3DecodeContext *s, int blk)
-{
- int ch, end;
- int got_cplchan = 0;
- mant_groups m;
-
- m.b1 = m.b2 = m.b4 = 0;
-
- for (ch = 1; ch <= s->channels; ch++) {
- /* transform coefficients for full-bandwidth channel */
- decode_transform_coeffs_ch(s, blk, ch, &m);
- /* transform coefficients for coupling channel come right after the
- coefficients for the first coupled channel*/
- if (s->channel_in_cpl[ch]) {
- if (!got_cplchan) {
- decode_transform_coeffs_ch(s, blk, CPL_CH, &m);
- calc_transform_coeffs_cpl(s);
- got_cplchan = 1;
- }
- end = s->end_freq[CPL_CH];
- } else {
- end = s->end_freq[ch];
- }
- do
- s->fixed_coeffs[ch][end] = 0;
- while (++end < 256);
- }
-
- /* zero the dithered coefficients for appropriate channels */
- remove_dithering(s);
-}
-
-/**
- * Stereo rematrixing.
- * reference: Section 7.5.4 Rematrixing : Decoding Technique
- */
-static void do_rematrixing(AC3DecodeContext *s)
-{
- int bnd, i;
- int end, bndend;
-
- end = FFMIN(s->end_freq[1], s->end_freq[2]);
-
- for (bnd = 0; bnd < s->num_rematrixing_bands; bnd++) {
- if (s->rematrixing_flags[bnd]) {
- bndend = FFMIN(end, ff_ac3_rematrix_band_tab[bnd + 1]);
- for (i = ff_ac3_rematrix_band_tab[bnd]; i < bndend; i++) {
- int tmp0 = s->fixed_coeffs[1][i];
- s->fixed_coeffs[1][i] += s->fixed_coeffs[2][i];
- s->fixed_coeffs[2][i] = tmp0 - s->fixed_coeffs[2][i];
- }
- }
- }
-}
-
-/**
- * Inverse MDCT Transform.
- * Convert frequency domain coefficients to time-domain audio samples.
- * reference: Section 7.9.4 Transformation Equations
- */
-static inline void do_imdct(AC3DecodeContext *s, int channels)
-{
- int ch;
-
- for (ch = 1; ch <= channels; ch++) {
- if (s->block_switch[ch]) {
- int i;
- float *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);
- s->fdsp.vector_fmul_window(s->outptr[ch - 1], s->delay[ch - 1],
- s->tmp_output, s->window, 128);
- 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]);
- 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));
- }
- }
-}
-
-/**
- * Upmix delay samples from stereo to original channel layout.
- */
-static void ac3_upmix_delay(AC3DecodeContext *s)
-{
- int channel_data_size = sizeof(s->delay[0]);
- switch (s->channel_mode) {
- case AC3_CHMODE_DUALMONO:
- case AC3_CHMODE_STEREO:
- /* upmix mono to stereo */
- memcpy(s->delay[1], s->delay[0], channel_data_size);
- break;
- case AC3_CHMODE_2F2R:
- memset(s->delay[3], 0, channel_data_size);
- case AC3_CHMODE_2F1R:
- memset(s->delay[2], 0, channel_data_size);
- break;
- case AC3_CHMODE_3F2R:
- memset(s->delay[4], 0, channel_data_size);
- case AC3_CHMODE_3F1R:
- memset(s->delay[3], 0, channel_data_size);
- case AC3_CHMODE_3F:
- memcpy(s->delay[2], s->delay[1], channel_data_size);
- memset(s->delay[1], 0, channel_data_size);
- break;
- }
-}
-
-/**
- * Decode band structure for coupling, spectral extension, or enhanced coupling.
- * The band structure defines how many subbands are in each band. For each
- * subband in the range, 1 means it is combined with the previous band, and 0
- * means that it starts a new band.
- *
- * @param[in] gbc bit reader context
- * @param[in] blk block number
- * @param[in] eac3 flag to indicate E-AC-3
- * @param[in] ecpl flag to indicate enhanced coupling
- * @param[in] start_subband subband number for start of range
- * @param[in] end_subband subband number for end of range
- * @param[in] default_band_struct default band structure table
- * @param[out] num_bands number of bands (optionally NULL)
- * @param[out] band_sizes array containing the number of bins in each band (optionally NULL)
- */
-static void decode_band_structure(GetBitContext *gbc, int blk, int eac3,
- int ecpl, int start_subband, int end_subband,
- const uint8_t *default_band_struct,
- int *num_bands, uint8_t *band_sizes)
-{
- int subbnd, bnd, n_subbands, n_bands=0;
- uint8_t bnd_sz[22];
- uint8_t coded_band_struct[22];
- const uint8_t *band_struct;
-
- n_subbands = end_subband - start_subband;
-
- /* decode band structure from bitstream or use default */
- if (!eac3 || get_bits1(gbc)) {
- for (subbnd = 0; subbnd < n_subbands - 1; subbnd++) {
- coded_band_struct[subbnd] = get_bits1(gbc);
- }
- band_struct = coded_band_struct;
- } else if (!blk) {
- band_struct = &default_band_struct[start_subband+1];
- } else {
- /* no change in band structure */
- return;
- }
-
- /* calculate number of bands and band sizes based on band structure.
- note that the first 4 subbands in enhanced coupling span only 6 bins
- instead of 12. */
- if (num_bands || band_sizes ) {
- n_bands = n_subbands;
- bnd_sz[0] = ecpl ? 6 : 12;
- for (bnd = 0, subbnd = 1; subbnd < n_subbands; subbnd++) {
- int subbnd_size = (ecpl && subbnd < 4) ? 6 : 12;
- if (band_struct[subbnd - 1]) {
- n_bands--;
- bnd_sz[bnd] += subbnd_size;
- } else {
- bnd_sz[++bnd] = subbnd_size;
- }
- }
- }
-
- /* set optional output params */
- if (num_bands)
- *num_bands = n_bands;
- if (band_sizes)
- memcpy(band_sizes, bnd_sz, n_bands);
-}
-
-/**
- * Decode a single audio block from the AC-3 bitstream.
- */
-static int decode_audio_block(AC3DecodeContext *s, int blk)
-{
- int fbw_channels = s->fbw_channels;
- int channel_mode = s->channel_mode;
- int i, bnd, seg, ch;
- int different_transforms;
- int downmix_output;
- int cpl_in_use;
- GetBitContext *gbc = &s->gbc;
- uint8_t bit_alloc_stages[AC3_MAX_CHANNELS] = { 0 };
-
- /* block switch flags */
- different_transforms = 0;
- if (s->block_switch_syntax) {
- for (ch = 1; ch <= fbw_channels; ch++) {
- s->block_switch[ch] = get_bits1(gbc);
- if (ch > 1 && s->block_switch[ch] != s->block_switch[1])
- different_transforms = 1;
- }
- }
-
- /* dithering flags */
- if (s->dither_flag_syntax) {
- for (ch = 1; ch <= fbw_channels; ch++) {
- s->dither_flag[ch] = get_bits1(gbc);
- }
- }
-
- /* dynamic range */
- i = !s->channel_mode;
- do {
- if (get_bits1(gbc)) {
- s->dynamic_range[i] = ((dynamic_range_tab[get_bits(gbc, 8)] - 1.0) *
- s->drc_scale) + 1.0;
- } else if (blk == 0) {
- s->dynamic_range[i] = 1.0f;
- }
- } while (i--);
-
- /* spectral extension strategy */
- if (s->eac3 && (!blk || get_bits1(gbc))) {
- s->spx_in_use = get_bits1(gbc);
- if (s->spx_in_use) {
- int dst_start_freq, dst_end_freq, src_start_freq,
- start_subband, end_subband;
-
- /* determine which channels use spx */
- if (s->channel_mode == AC3_CHMODE_MONO) {
- s->channel_uses_spx[1] = 1;
- } else {
- for (ch = 1; ch <= fbw_channels; ch++)
- s->channel_uses_spx[ch] = get_bits1(gbc);
- }
-
- /* get the frequency bins of the spx copy region and the spx start
- and end subbands */
- dst_start_freq = get_bits(gbc, 2);
- start_subband = get_bits(gbc, 3) + 2;
- if (start_subband > 7)
- start_subband += start_subband - 7;
- end_subband = get_bits(gbc, 3) + 5;
- if (end_subband > 7)
- end_subband += end_subband - 7;
- dst_start_freq = dst_start_freq * 12 + 25;
- src_start_freq = start_subband * 12 + 25;
- dst_end_freq = end_subband * 12 + 25;
-
- /* check validity of spx ranges */
- if (start_subband >= end_subband) {
- av_log(s->avctx, AV_LOG_ERROR, "invalid spectral extension "
- "range (%d >= %d)\n", start_subband, end_subband);
- return -1;
- }
- if (dst_start_freq >= src_start_freq) {
- av_log(s->avctx, AV_LOG_ERROR, "invalid spectral extension "
- "copy start bin (%d >= %d)\n", dst_start_freq, src_start_freq);
- return -1;
- }
-
- s->spx_dst_start_freq = dst_start_freq;
- s->spx_src_start_freq = src_start_freq;
- s->spx_dst_end_freq = dst_end_freq;
-
- decode_band_structure(gbc, blk, s->eac3, 0,
- start_subband, end_subband,
- ff_eac3_default_spx_band_struct,
- &s->num_spx_bands,
- s->spx_band_sizes);
- } else {
- for (ch = 1; ch <= fbw_channels; ch++) {
- s->channel_uses_spx[ch] = 0;
- s->first_spx_coords[ch] = 1;
- }
- }
- }
-
- /* spectral extension coordinates */
- if (s->spx_in_use) {
- 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;
- int bin, master_spx_coord;
-
- s->first_spx_coords[ch] = 0;
- spx_blend = get_bits(gbc, 5) * (1.0f/32);
- 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;
-
- /* calculate blending factors */
- bandsize = s->spx_band_sizes[bnd];
- nratio = ((float)((bin + (bandsize >> 1))) / s->spx_dst_end_freq) - spx_blend;
- nratio = av_clipf(nratio, 0.0f, 1.0f);
- nblend = sqrtf(3.0f * nratio); // noise is scaled by sqrt(3)
- // to give unity variance
- sblend = sqrtf(1.0f - nratio);
- bin += bandsize;
-
- /* decode spx coordinates */
- spx_coord_exp = get_bits(gbc, 4);
- spx_coord_mant = get_bits(gbc, 2);
- 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 */
- s->spx_noise_blend [ch][bnd] = nblend * spx_coord;
- s->spx_signal_blend[ch][bnd] = sblend * spx_coord;
- }
- }
- } else {
- s->first_spx_coords[ch] = 1;
- }
- }
- }
-
- /* coupling strategy */
- if (s->eac3 ? s->cpl_strategy_exists[blk] : get_bits1(gbc)) {
- memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS);
- if (!s->eac3)
- s->cpl_in_use[blk] = get_bits1(gbc);
- if (s->cpl_in_use[blk]) {
- /* coupling in use */
- int cpl_start_subband, cpl_end_subband;
-
- if (channel_mode < AC3_CHMODE_STEREO) {
- av_log(s->avctx, AV_LOG_ERROR, "coupling not allowed in mono or dual-mono\n");
- return -1;
- }
-
- /* check for enhanced coupling */
- if (s->eac3 && get_bits1(gbc)) {
- /* TODO: parse enhanced coupling strategy info */
- av_log_missing_feature(s->avctx, "Enhanced coupling", 1);
- return AVERROR_PATCHWELCOME;
- }
-
- /* determine which channels are coupled */
- if (s->eac3 && s->channel_mode == AC3_CHMODE_STEREO) {
- s->channel_in_cpl[1] = 1;
- s->channel_in_cpl[2] = 1;
- } else {
- for (ch = 1; ch <= fbw_channels; ch++)
- s->channel_in_cpl[ch] = get_bits1(gbc);
- }
-
- /* phase flags in use */
- if (channel_mode == AC3_CHMODE_STEREO)
- s->phase_flags_in_use = get_bits1(gbc);
-
- /* coupling frequency range */
- cpl_start_subband = get_bits(gbc, 4);
- cpl_end_subband = s->spx_in_use ? (s->spx_src_start_freq - 37) / 12 :
- get_bits(gbc, 4) + 3;
- if (cpl_start_subband >= cpl_end_subband) {
- av_log(s->avctx, AV_LOG_ERROR, "invalid coupling range (%d >= %d)\n",
- cpl_start_subband, cpl_end_subband);
- return -1;
- }
- s->start_freq[CPL_CH] = cpl_start_subband * 12 + 37;
- s->end_freq[CPL_CH] = cpl_end_subband * 12 + 37;
-
- decode_band_structure(gbc, blk, s->eac3, 0, cpl_start_subband,
- cpl_end_subband,
- ff_eac3_default_cpl_band_struct,
- &s->num_cpl_bands, s->cpl_band_sizes);
- } else {
- /* coupling not in use */
- for (ch = 1; ch <= fbw_channels; ch++) {
- s->channel_in_cpl[ch] = 0;
- s->first_cpl_coords[ch] = 1;
- }
- s->first_cpl_leak = s->eac3;
- s->phase_flags_in_use = 0;
- }
- } else if (!s->eac3) {
- if (!blk) {
- av_log(s->avctx, AV_LOG_ERROR, "new coupling strategy must "
- "be present in block 0\n");
- return -1;
- } else {
- s->cpl_in_use[blk] = s->cpl_in_use[blk-1];
- }
- }
- cpl_in_use = s->cpl_in_use[blk];
-
- /* coupling coordinates */
- if (cpl_in_use) {
- int cpl_coords_exist = 0;
-
- for (ch = 1; ch <= fbw_channels; ch++) {
- if (s->channel_in_cpl[ch]) {
- if ((s->eac3 && s->first_cpl_coords[ch]) || get_bits1(gbc)) {
- int master_cpl_coord, cpl_coord_exp, cpl_coord_mant;
- s->first_cpl_coords[ch] = 0;
- cpl_coords_exist = 1;
- master_cpl_coord = 3 * get_bits(gbc, 2);
- for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {
- cpl_coord_exp = get_bits(gbc, 4);
- cpl_coord_mant = get_bits(gbc, 4);
- if (cpl_coord_exp == 15)
- s->cpl_coords[ch][bnd] = cpl_coord_mant << 22;
- else
- s->cpl_coords[ch][bnd] = (cpl_coord_mant + 16) << 21;
- s->cpl_coords[ch][bnd] >>= (cpl_coord_exp + master_cpl_coord);
- }
- } else if (!blk) {
- av_log(s->avctx, AV_LOG_ERROR, "new coupling coordinates must "
- "be present in block 0\n");
- return -1;
- }
- } else {
- /* channel not in coupling */
- s->first_cpl_coords[ch] = 1;
- }
- }
- /* phase flags */
- if (channel_mode == AC3_CHMODE_STEREO && cpl_coords_exist) {
- for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {
- s->phase_flags[bnd] = s->phase_flags_in_use? get_bits1(gbc) : 0;
- }
- }
- }
-
- /* stereo rematrixing strategy and band structure */
- if (channel_mode == AC3_CHMODE_STEREO) {
- if ((s->eac3 && !blk) || get_bits1(gbc)) {
- s->num_rematrixing_bands = 4;
- if (cpl_in_use && s->start_freq[CPL_CH] <= 61) {
- s->num_rematrixing_bands -= 1 + (s->start_freq[CPL_CH] == 37);
- } else if (s->spx_in_use && s->spx_src_start_freq <= 61) {
- s->num_rematrixing_bands--;
- }
- for (bnd = 0; bnd < s->num_rematrixing_bands; bnd++)
- s->rematrixing_flags[bnd] = get_bits1(gbc);
- } else if (!blk) {
- av_log(s->avctx, AV_LOG_WARNING, "Warning: "
- "new rematrixing strategy not present in block 0\n");
- s->num_rematrixing_bands = 0;
- }
- }
-
- /* exponent strategies for each channel */
- for (ch = !cpl_in_use; ch <= s->channels; ch++) {
- if (!s->eac3)
- s->exp_strategy[blk][ch] = get_bits(gbc, 2 - (ch == s->lfe_ch));
- if (s->exp_strategy[blk][ch] != EXP_REUSE)
- bit_alloc_stages[ch] = 3;
- }
-
- /* channel bandwidth */
- for (ch = 1; ch <= fbw_channels; ch++) {
- s->start_freq[ch] = 0;
- if (s->exp_strategy[blk][ch] != EXP_REUSE) {
- int group_size;
- int prev = s->end_freq[ch];
- if (s->channel_in_cpl[ch])
- s->end_freq[ch] = s->start_freq[CPL_CH];
- else if (s->channel_uses_spx[ch])
- s->end_freq[ch] = s->spx_src_start_freq;
- else {
- int bandwidth_code = get_bits(gbc, 6);
- if (bandwidth_code > 60) {
- av_log(s->avctx, AV_LOG_ERROR, "bandwidth code = %d > 60\n", bandwidth_code);
- return -1;
- }
- s->end_freq[ch] = bandwidth_code * 3 + 73;
- }
- group_size = 3 << (s->exp_strategy[blk][ch] - 1);
- s->num_exp_groups[ch] = (s->end_freq[ch] + group_size-4) / group_size;
- if (blk > 0 && s->end_freq[ch] != prev)
- memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS);
- }
- }
- if (cpl_in_use && s->exp_strategy[blk][CPL_CH] != EXP_REUSE) {
- s->num_exp_groups[CPL_CH] = (s->end_freq[CPL_CH] - s->start_freq[CPL_CH]) /
- (3 << (s->exp_strategy[blk][CPL_CH] - 1));
- }
-
- /* decode exponents for each channel */
- for (ch = !cpl_in_use; ch <= s->channels; ch++) {
- if (s->exp_strategy[blk][ch] != EXP_REUSE) {
- s->dexps[ch][0] = get_bits(gbc, 4) << !ch;
- if (decode_exponents(gbc, s->exp_strategy[blk][ch],
- s->num_exp_groups[ch], s->dexps[ch][0],
- &s->dexps[ch][s->start_freq[ch]+!!ch])) {
- av_log(s->avctx, AV_LOG_ERROR, "exponent out-of-range\n");
- return -1;
- }
- if (ch != CPL_CH && ch != s->lfe_ch)
- skip_bits(gbc, 2); /* skip gainrng */
- }
- }
-
- /* bit allocation information */
- if (s->bit_allocation_syntax) {
- if (get_bits1(gbc)) {
- s->bit_alloc_params.slow_decay = ff_ac3_slow_decay_tab[get_bits(gbc, 2)] >> s->bit_alloc_params.sr_shift;
- s->bit_alloc_params.fast_decay = ff_ac3_fast_decay_tab[get_bits(gbc, 2)] >> s->bit_alloc_params.sr_shift;
- s->bit_alloc_params.slow_gain = ff_ac3_slow_gain_tab[get_bits(gbc, 2)];
- s->bit_alloc_params.db_per_bit = ff_ac3_db_per_bit_tab[get_bits(gbc, 2)];
- s->bit_alloc_params.floor = ff_ac3_floor_tab[get_bits(gbc, 3)];
- for (ch = !cpl_in_use; ch <= s->channels; ch++)
- bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);
- } else if (!blk) {
- av_log(s->avctx, AV_LOG_ERROR, "new bit allocation info must "
- "be present in block 0\n");
- return -1;
- }
- }
-
- /* signal-to-noise ratio offsets and fast gains (signal-to-mask ratios) */
- if (!s->eac3 || !blk) {
- if (s->snr_offset_strategy && get_bits1(gbc)) {
- int snr = 0;
- int csnr;
- csnr = (get_bits(gbc, 6) - 15) << 4;
- for (i = ch = !cpl_in_use; ch <= s->channels; ch++) {
- /* snr offset */
- if (ch == i || s->snr_offset_strategy == 2)
- snr = (csnr + get_bits(gbc, 4)) << 2;
- /* run at least last bit allocation stage if snr offset changes */
- if (blk && s->snr_offset[ch] != snr) {
- bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 1);
- }
- s->snr_offset[ch] = snr;
-
- /* fast gain (normal AC-3 only) */
- if (!s->eac3) {
- int prev = s->fast_gain[ch];
- s->fast_gain[ch] = ff_ac3_fast_gain_tab[get_bits(gbc, 3)];
- /* run last 2 bit allocation stages if fast gain changes */
- if (blk && prev != s->fast_gain[ch])
- bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);
- }
- }
- } else if (!s->eac3 && !blk) {
- av_log(s->avctx, AV_LOG_ERROR, "new snr offsets must be present in block 0\n");
- return -1;
- }
- }
-
- /* fast gain (E-AC-3 only) */
- if (s->fast_gain_syntax && get_bits1(gbc)) {
- for (ch = !cpl_in_use; ch <= s->channels; ch++) {
- int prev = s->fast_gain[ch];
- s->fast_gain[ch] = ff_ac3_fast_gain_tab[get_bits(gbc, 3)];
- /* run last 2 bit allocation stages if fast gain changes */
- if (blk && prev != s->fast_gain[ch])
- bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);
- }
- } else if (s->eac3 && !blk) {
- for (ch = !cpl_in_use; ch <= s->channels; ch++)
- s->fast_gain[ch] = ff_ac3_fast_gain_tab[4];
- }
-
- /* E-AC-3 to AC-3 converter SNR offset */
- if (s->frame_type == EAC3_FRAME_TYPE_INDEPENDENT && get_bits1(gbc)) {
- skip_bits(gbc, 10); // skip converter snr offset
- }
-
- /* coupling leak information */
- if (cpl_in_use) {
- if (s->first_cpl_leak || get_bits1(gbc)) {
- int fl = get_bits(gbc, 3);
- int sl = get_bits(gbc, 3);
- /* run last 2 bit allocation stages for coupling channel if
- coupling leak changes */
- if (blk && (fl != s->bit_alloc_params.cpl_fast_leak ||
- sl != s->bit_alloc_params.cpl_slow_leak)) {
- bit_alloc_stages[CPL_CH] = FFMAX(bit_alloc_stages[CPL_CH], 2);
- }
- s->bit_alloc_params.cpl_fast_leak = fl;
- s->bit_alloc_params.cpl_slow_leak = sl;
- } else if (!s->eac3 && !blk) {
- av_log(s->avctx, AV_LOG_ERROR, "new coupling leak info must "
- "be present in block 0\n");
- return -1;
- }
- s->first_cpl_leak = 0;
- }
-
- /* delta bit allocation information */
- if (s->dba_syntax && get_bits1(gbc)) {
- /* delta bit allocation exists (strategy) */
- for (ch = !cpl_in_use; ch <= fbw_channels; ch++) {
- s->dba_mode[ch] = get_bits(gbc, 2);
- if (s->dba_mode[ch] == DBA_RESERVED) {
- av_log(s->avctx, AV_LOG_ERROR, "delta bit allocation strategy reserved\n");
- return -1;
- }
- bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);
- }
- /* channel delta offset, len and bit allocation */
- for (ch = !cpl_in_use; ch <= fbw_channels; ch++) {
- if (s->dba_mode[ch] == DBA_NEW) {
- s->dba_nsegs[ch] = get_bits(gbc, 3) + 1;
- for (seg = 0; seg < s->dba_nsegs[ch]; seg++) {
- s->dba_offsets[ch][seg] = get_bits(gbc, 5);
- s->dba_lengths[ch][seg] = get_bits(gbc, 4);
- s->dba_values[ch][seg] = get_bits(gbc, 3);
- }
- /* run last 2 bit allocation stages if new dba values */
- bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);
- }
- }
- } else if (blk == 0) {
- for (ch = 0; ch <= s->channels; ch++) {
- s->dba_mode[ch] = DBA_NONE;
- }
- }
-
- /* Bit allocation */
- for (ch = !cpl_in_use; ch <= s->channels; ch++) {
- if (bit_alloc_stages[ch] > 2) {
- /* Exponent mapping into PSD and PSD integration */
- ff_ac3_bit_alloc_calc_psd(s->dexps[ch],
- s->start_freq[ch], s->end_freq[ch],
- s->psd[ch], s->band_psd[ch]);
- }
- if (bit_alloc_stages[ch] > 1) {
- /* Compute excitation function, Compute masking curve, and
- Apply delta bit allocation */
- if (ff_ac3_bit_alloc_calc_mask(&s->bit_alloc_params, s->band_psd[ch],
- s->start_freq[ch], s->end_freq[ch],
- s->fast_gain[ch], (ch == s->lfe_ch),
- s->dba_mode[ch], s->dba_nsegs[ch],
- s->dba_offsets[ch], s->dba_lengths[ch],
- s->dba_values[ch], s->mask[ch])) {
- av_log(s->avctx, AV_LOG_ERROR, "error in bit allocation\n");
- return -1;
- }
- }
- if (bit_alloc_stages[ch] > 0) {
- /* Compute bit allocation */
- const uint8_t *bap_tab = s->channel_uses_aht[ch] ?
- ff_eac3_hebap_tab : ff_ac3_bap_tab;
- s->ac3dsp.bit_alloc_calc_bap(s->mask[ch], s->psd[ch],
- s->start_freq[ch], s->end_freq[ch],
- s->snr_offset[ch],
- s->bit_alloc_params.floor,
- bap_tab, s->bap[ch]);
- }
- }
-
- /* unused dummy data */
- if (s->skip_syntax && get_bits1(gbc)) {
- int skipl = get_bits(gbc, 9);
- while (skipl--)
- skip_bits(gbc, 8);
- }
-
- /* unpack the transform coefficients
- this also uncouples channels if coupling is in use. */
- decode_transform_coeffs(s, blk);
-
- /* TODO: generate enhanced coupling coordinates and uncouple */
-
- /* recover coefficients if rematrixing is in use */
- if (s->channel_mode == AC3_CHMODE_STEREO)
- do_rematrixing(s);
-
- /* 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];
- } else {
- gain *= s->dynamic_range[0];
- }
- s->fmt_conv.int32_to_float_fmul_scalar(s->transform_coeffs[ch],
- s->fixed_coeffs[ch], gain, 256);
- }
-
- /* apply spectral extension to high frequency bins */
- if (s->spx_in_use && CONFIG_EAC3_DECODER) {
- ff_eac3_apply_spectral_extension(s);
- }
-
- /* downmix and MDCT. order depends on whether block switching is used for
- any channel in this block. this is because coefficients for the long
- and short transforms cannot be mixed. */
- downmix_output = s->channels != s->out_channels &&
- !((s->output_mode & AC3_OUTPUT_LFEON) &&
- s->fbw_channels == s->out_channels);
- if (different_transforms) {
- /* the delay samples have already been downmixed, so we upmix the delay
- samples in order to reconstruct all channels before downmixing. */
- if (s->downmixed) {
- s->downmixed = 0;
- ac3_upmix_delay(s);
- }
-
- do_imdct(s, s->channels);
-
- if (downmix_output) {
- s->ac3dsp.downmix(s->outptr, s->downmix_coeffs,
- s->out_channels, s->fbw_channels, 256);
- }
- } else {
- if (downmix_output) {
- s->ac3dsp.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);
- }
-
- do_imdct(s, s->out_channels);
- }
-
- return 0;
-}
-
-/**
- * Decode a single AC-3 frame.
- */
-static int ac3_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;
- AC3DecodeContext *s = avctx->priv_data;
- int blk, ch, err, ret;
- const uint8_t *channel_map;
- const float *output[AC3_MAX_CHANNELS];
-
- /* copy input buffer to decoder context to avoid reading past the end
- of the buffer, which can be caused by a damaged input stream. */
- if (buf_size >= 2 && AV_RB16(buf) == 0x770B) {
- // seems to be byte-swapped AC-3
- int cnt = FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE) >> 1;
- s->dsp.bswap16_buf((uint16_t *)s->input_buffer, (const uint16_t *)buf, cnt);
- } else
- memcpy(s->input_buffer, buf, FFMIN(buf_size, AC3_FRAME_BUFFER_SIZE));
- buf = s->input_buffer;
- /* initialize the GetBitContext with the start of valid AC-3 Frame */
- init_get_bits(&s->gbc, buf, buf_size * 8);
-
- /* parse the syncinfo */
- err = parse_frame_header(s);
-
- if (err) {
- switch (err) {
- case AAC_AC3_PARSE_ERROR_SYNC:
- av_log(avctx, AV_LOG_ERROR, "frame sync error\n");
- return -1;
- case AAC_AC3_PARSE_ERROR_BSID:
- av_log(avctx, AV_LOG_ERROR, "invalid bitstream id\n");
- break;
- case AAC_AC3_PARSE_ERROR_SAMPLE_RATE:
- av_log(avctx, AV_LOG_ERROR, "invalid sample rate\n");
- break;
- case AAC_AC3_PARSE_ERROR_FRAME_SIZE:
- av_log(avctx, AV_LOG_ERROR, "invalid frame size\n");
- break;
- case AAC_AC3_PARSE_ERROR_FRAME_TYPE:
- /* skip frame if CRC is ok. otherwise use error concealment. */
- /* TODO: add support for substreams and dependent frames */
- if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT || s->substreamid) {
- av_log(avctx, AV_LOG_ERROR, "unsupported frame type : "
- "skipping frame\n");
- *got_frame_ptr = 0;
- return s->frame_size;
- } else {
- av_log(avctx, AV_LOG_ERROR, "invalid frame type\n");
- }
- break;
- default:
- av_log(avctx, AV_LOG_ERROR, "invalid header\n");
- break;
- }
- } else {
- /* check that reported frame size fits in input buffer */
- if (s->frame_size > buf_size) {
- av_log(avctx, AV_LOG_ERROR, "incomplete frame\n");
- err = AAC_AC3_PARSE_ERROR_FRAME_SIZE;
- } else if (avctx->err_recognition & (AV_EF_CRCCHECK|AV_EF_CAREFUL)) {
- /* check for crc mismatch */
- if (av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &buf[2],
- s->frame_size - 2)) {
- av_log(avctx, AV_LOG_ERROR, "frame CRC mismatch\n");
- err = AAC_AC3_PARSE_ERROR_CRC;
- }
- }
- }
-
- /* if frame is ok, set audio parameters */
- if (!err) {
- avctx->sample_rate = s->sample_rate;
- avctx->bit_rate = s->bit_rate;
-
- /* channel config */
- s->out_channels = s->channels;
- s->output_mode = s->channel_mode;
- if (s->lfe_on)
- s->output_mode |= AC3_OUTPUT_LFEON;
- if (avctx->request_channels > 0 && avctx->request_channels <= 2 &&
- avctx->request_channels < s->channels) {
- s->out_channels = avctx->request_channels;
- s->output_mode = avctx->request_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO;
- s->channel_layout = avpriv_ac3_channel_layout_tab[s->output_mode];
- }
- avctx->channels = s->out_channels;
- avctx->channel_layout = s->channel_layout;
-
- s->loro_center_mix_level = gain_levels[s-> center_mix_level];
- s->loro_surround_mix_level = gain_levels[s->surround_mix_level];
- s->ltrt_center_mix_level = LEVEL_MINUS_3DB;
- s->ltrt_surround_mix_level = LEVEL_MINUS_3DB;
- /* set downmixing coefficients if needed */
- if (s->channels != s->out_channels && !((s->output_mode & AC3_OUTPUT_LFEON) &&
- s->fbw_channels == s->out_channels)) {
- set_downmix_coeffs(s);
- }
- } else if (!s->out_channels) {
- s->out_channels = avctx->channels;
- if (s->out_channels < s->channels)
- s->output_mode = s->out_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO;
- }
- if (avctx->channels != s->out_channels) {
- av_log(avctx, AV_LOG_ERROR, "channel number mismatching on damaged frame\n");
- return AVERROR_INVALIDDATA;
- }
- /* set audio service type based on bitstream mode for AC-3 */
- avctx->audio_service_type = s->bitstream_mode;
- if (s->bitstream_mode == 0x7 && s->channels > 1)
- avctx->audio_service_type = AV_AUDIO_SERVICE_TYPE_KARAOKE;
-
- /* get output buffer */
- avctx->channels = s->out_channels;
- frame->nb_samples = s->num_blocks * 256;
- if ((ret = ff_get_buffer(avctx, frame)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return ret;
- }
-
- /* decode the audio blocks */
- channel_map = ff_ac3_dec_channel_map[s->output_mode & ~AC3_OUTPUT_LFEON][s->lfe_on];
- for (ch = 0; ch < AC3_MAX_CHANNELS; ch++) {
- output[ch] = s->output[ch];
- s->outptr[ch] = s->output[ch];
- }
- for (ch = 0; ch < s->channels; ch++) {
- if (ch < s->out_channels)
- s->outptr[channel_map[ch]] = (float *)frame->data[ch];
- }
- for (blk = 0; blk < s->num_blocks; blk++) {
- if (!err && decode_audio_block(s, blk)) {
- av_log(avctx, AV_LOG_ERROR, "error decoding the audio block\n");
- err = 1;
- }
- if (err)
- for (ch = 0; ch < s->out_channels; ch++)
- memcpy(((float*)frame->data[ch]) + AC3_BLOCK_SIZE*blk, output[ch], 1024);
- for (ch = 0; ch < s->out_channels; ch++)
- output[ch] = s->outptr[channel_map[ch]];
- for (ch = 0; ch < s->out_channels; ch++) {
- if (!ch || channel_map[ch])
- s->outptr[channel_map[ch]] += AC3_BLOCK_SIZE;
- }
- }
-
- frame->decode_error_flags = err ? FF_DECODE_ERROR_INVALID_BITSTREAM : 0;
-
- /* keep last block for error concealment in next frame */
- for (ch = 0; ch < s->out_channels; ch++)
- memcpy(s->output[ch], output[ch], 1024);
-
- *got_frame_ptr = 1;
-
- return FFMIN(buf_size, s->frame_size);
-}
-
-/**
- * Uninitialize the AC-3 decoder.
- */
-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);
-
- 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",
- .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/src/thirdparty/ffmpeg/libavcodec/ac3dec.h b/src/thirdparty/ffmpeg/libavcodec/ac3dec.h
deleted file mode 100644
index fb681d08e..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/ac3dec.h
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * Common code between the AC-3 and E-AC-3 decoders
- * Copyright (c) 2007 Bartlomiej Wolowiec <bartek.wolowiec@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
- * Common code between the AC-3 and E-AC-3 decoders.
- *
- * Summary of MDCT Coefficient Grouping:
- * The individual MDCT coefficient indices are often referred to in the
- * (E-)AC-3 specification as frequency bins. These bins are grouped together
- * into subbands of 12 coefficients each. The subbands are grouped together
- * into bands as defined in the bitstream by the band structures, which
- * determine the number of bands and the size of each band. The full spectrum
- * of 256 frequency bins is divided into 1 DC bin + 21 subbands = 253 bins.
- * This system of grouping coefficients is used for channel bandwidth, stereo
- * rematrixing, channel coupling, enhanced coupling, and spectral extension.
- *
- * +-+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-+
- * |1| |12| | [12|12|12|12] | | | | | | | | | | | | |3|
- * +-+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-+
- * ~~~ ~~~~ ~~~~~~~~~~~~~ ~~~
- * | | | |
- * | | | 3 unused frequency bins--+
- * | | |
- * | | +--1 band containing 4 subbands
- * | |
- * | +--1 subband of 12 frequency bins
- * |
- * +--DC frequency bin
- */
-
-#ifndef AVCODEC_AC3DEC_H
-#define AVCODEC_AC3DEC_H
-
-#include "libavutil/float_dsp.h"
-#include "libavutil/lfg.h"
-#include "ac3.h"
-#include "ac3dsp.h"
-#include "get_bits.h"
-#include "dsputil.h"
-#include "fft.h"
-#include "fmtconvert.h"
-
-#define AC3_OUTPUT_LFEON 8
-
-#define SPX_MAX_BANDS 17
-
-/** Large enough for maximum possible frame size when the specification limit is ignored */
-#define AC3_FRAME_BUFFER_SIZE 32768
-
-typedef struct AC3DecodeContext {
- AVClass *class; ///< class for AVOptions
- AVCodecContext *avctx; ///< parent context
- GetBitContext gbc; ///< bitstream reader
-
-///@name Bit stream information
-///@{
- int frame_type; ///< frame type (strmtyp)
- int substreamid; ///< substream identification
- int frame_size; ///< current frame size, in bytes
- 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_mode; ///< bitstream mode (bsmod)
- int channel_mode; ///< channel mode (acmod)
- int channel_layout; ///< channel layout
- int lfe_on; ///< lfe channel in use
- int channel_map; ///< custom channel map
- int center_mix_level; ///< Center mix level index
- int surround_mix_level; ///< Surround mix level index
- int eac3; ///< indicates if current frame is E-AC-3
-///@}
-
- int preferred_stereo_downmix;
- float ltrt_center_mix_level;
- float ltrt_surround_mix_level;
- float loro_center_mix_level;
- float loro_surround_mix_level;
-
-///@name Frame syntax parameters
- int snr_offset_strategy; ///< SNR offset strategy (snroffststr)
- int block_switch_syntax; ///< block switch syntax enabled (blkswe)
- int dither_flag_syntax; ///< dither flag syntax enabled (dithflage)
- int bit_allocation_syntax; ///< bit allocation model syntax enabled (bamode)
- int fast_gain_syntax; ///< fast gain codes enabled (frmfgaincode)
- int dba_syntax; ///< delta bit allocation syntax enabled (dbaflde)
- int skip_syntax; ///< skip field syntax enabled (skipflde)
- ///@}
-
-///@name Standard coupling
- int cpl_in_use[AC3_MAX_BLOCKS]; ///< coupling in use (cplinu)
- int cpl_strategy_exists[AC3_MAX_BLOCKS];///< coupling strategy exists (cplstre)
- int channel_in_cpl[AC3_MAX_CHANNELS]; ///< channel in coupling (chincpl)
- int phase_flags_in_use; ///< phase flags in use (phsflginu)
- int phase_flags[AC3_MAX_CPL_BANDS]; ///< phase flags (phsflg)
- int num_cpl_bands; ///< number of coupling bands (ncplbnd)
- uint8_t cpl_band_sizes[AC3_MAX_CPL_BANDS]; ///< number of coeffs in each coupling band
- int firstchincpl; ///< first channel in coupling
- int first_cpl_coords[AC3_MAX_CHANNELS]; ///< first coupling coordinates states (firstcplcos)
- int cpl_coords[AC3_MAX_CHANNELS][AC3_MAX_CPL_BANDS]; ///< coupling coordinates (cplco)
-///@}
-
-///@name Spectral extension
-///@{
- int spx_in_use; ///< spectral extension in use (spxinu)
- uint8_t channel_uses_spx[AC3_MAX_CHANNELS]; ///< channel uses spectral extension (chinspx)
- int8_t spx_atten_code[AC3_MAX_CHANNELS]; ///< spx attenuation code (spxattencod)
- int spx_src_start_freq; ///< spx start frequency bin
- int spx_dst_end_freq; ///< spx end frequency bin
- int spx_dst_start_freq; ///< spx starting frequency bin for copying (copystartmant)
- ///< the copy region ends at the start of the spx region.
- 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)
-///@}
-
-///@name Adaptive hybrid transform
- int channel_uses_aht[AC3_MAX_CHANNELS]; ///< channel AHT in use (chahtinu)
- int pre_mantissa[AC3_MAX_CHANNELS][AC3_MAX_COEFS][AC3_MAX_BLOCKS]; ///< pre-IDCT mantissas
-///@}
-
-///@name Channel
- 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
- 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
-///@}
-
-///@name Bandwidth
- int start_freq[AC3_MAX_CHANNELS]; ///< start frequency bin (strtmant)
- int end_freq[AC3_MAX_CHANNELS]; ///< end frequency bin (endmant)
-///@}
-
-///@name Rematrixing
- int num_rematrixing_bands; ///< number of rematrixing bands (nrematbnd)
- int rematrixing_flags[4]; ///< rematrixing flags (rematflg)
-///@}
-
-///@name Exponents
- int num_exp_groups[AC3_MAX_CHANNELS]; ///< Number of exponent groups (nexpgrp)
- int8_t dexps[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< decoded exponents
- int exp_strategy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS]; ///< exponent strategies (expstr)
-///@}
-
-///@name Bit allocation
- AC3BitAllocParameters bit_alloc_params; ///< bit allocation parameters
- int first_cpl_leak; ///< first coupling leak state (firstcplleak)
- int snr_offset[AC3_MAX_CHANNELS]; ///< signal-to-noise ratio offsets (snroffst)
- int fast_gain[AC3_MAX_CHANNELS]; ///< fast gain values/SMR's (fgain)
- uint8_t bap[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< bit allocation pointers
- int16_t psd[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< scaled exponents
- int16_t band_psd[AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS]; ///< interpolated exponents
- int16_t mask[AC3_MAX_CHANNELS][AC3_CRITICAL_BANDS]; ///< masking curve values
- int dba_mode[AC3_MAX_CHANNELS]; ///< delta bit allocation mode
- int dba_nsegs[AC3_MAX_CHANNELS]; ///< number of delta segments
- uint8_t dba_offsets[AC3_MAX_CHANNELS][8]; ///< delta segment offsets
- uint8_t dba_lengths[AC3_MAX_CHANNELS][8]; ///< delta segment lengths
- uint8_t dba_values[AC3_MAX_CHANNELS][8]; ///< delta values for each segment
-///@}
-
-///@name Zero-mantissa dithering
- int dither_flag[AC3_MAX_CHANNELS]; ///< dither flags (dithflg)
- AVLFG dith_state; ///< for dither generation
-///@}
-
-///@name IMDCT
- int block_switch[AC3_MAX_CHANNELS]; ///< block switch flags (blksw)
- FFTContext imdct_512; ///< for 512 sample IMDCT
- FFTContext imdct_256; ///< for 256 sample IMDCT
-///@}
-
-///@name Optimization
- DSPContext dsp; ///< for optimization
- AVFloatDSPContext fdsp;
- AC3DSPContext ac3dsp;
- FmtConvertContext fmt_conv; ///< optimized conversion functions
-///@}
-
- float *outptr[AC3_MAX_CHANNELS];
- float *xcfptr[AC3_MAX_CHANNELS];
- float *dlyptr[AC3_MAX_CHANNELS];
-
-///@name Aligned arrays
- DECLARE_ALIGNED(16, int, 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(32, uint8_t, input_buffer)[AC3_FRAME_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; ///< temp buffer to prevent overread
-///@}
-} AC3DecodeContext;
-
-/**
- * Parse the E-AC-3 frame header.
- * This parses both the bit stream info and audio frame header.
- */
-int ff_eac3_parse_header(AC3DecodeContext *s);
-
-/**
- * Decode mantissas in a single channel for the entire frame.
- * This is used when AHT mode is enabled.
- */
-void ff_eac3_decode_transform_coeffs_aht_ch(AC3DecodeContext *s, int ch);
-
-/**
- * Apply spectral extension to each channel by copying lower frequency
- * coefficients to higher frequency bins and applying side information to
- * approximate the original high frequency signal.
- */
-void ff_eac3_apply_spectral_extension(AC3DecodeContext *s);
-
-#endif /* AVCODEC_AC3DEC_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/ac3dec_data.c b/src/thirdparty/ffmpeg/libavcodec/ac3dec_data.c
deleted file mode 100644
index c403f19ae..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/ac3dec_data.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * AC-3 and E-AC-3 decoder tables
- * Copyright (c) 2007 Bartlomiej Wolowiec <bartek.wolowiec@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
- * Tables taken directly from the AC-3 spec.
- */
-
-#include "ac3dec_data.h"
-#include "ac3.h"
-
-/**
- * Table used to ungroup 3 values stored in 5 bits.
- * Used by bap=1 mantissas and GAQ.
- * ff_ac3_ungroup_3_in_5_bits_tab[i] = { i/9, (i%9)/3, (i%9)%3 }
- */
-const uint8_t ff_ac3_ungroup_3_in_5_bits_tab[32][3] = {
- { 0, 0, 0 }, { 0, 0, 1 }, { 0, 0, 2 }, { 0, 1, 0 },
- { 0, 1, 1 }, { 0, 1, 2 }, { 0, 2, 0 }, { 0, 2, 1 },
- { 0, 2, 2 }, { 1, 0, 0 }, { 1, 0, 1 }, { 1, 0, 2 },
- { 1, 1, 0 }, { 1, 1, 1 }, { 1, 1, 2 }, { 1, 2, 0 },
- { 1, 2, 1 }, { 1, 2, 2 }, { 2, 0, 0 }, { 2, 0, 1 },
- { 2, 0, 2 }, { 2, 1, 0 }, { 2, 1, 1 }, { 2, 1, 2 },
- { 2, 2, 0 }, { 2, 2, 1 }, { 2, 2, 2 }, { 3, 0, 0 },
- { 3, 0, 1 }, { 3, 0, 2 }, { 3, 1, 0 }, { 3, 1, 1 }
-};
-
-const uint8_t ff_eac3_hebap_tab[64] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 8,
- 8, 8, 9, 9, 9, 10, 10, 10, 10, 11,
- 11, 11, 11, 12, 12, 12, 12, 13, 13, 13,
- 13, 14, 14, 14, 14, 15, 15, 15, 15, 16,
- 16, 16, 16, 17, 17, 17, 17, 18, 18, 18,
- 18, 18, 18, 18, 18, 19, 19, 19, 19, 19,
- 19, 19, 19, 19,
-};
-
-/**
- * Table E2.15 Default Spectral Extension Banding Structure
- */
-const uint8_t ff_eac3_default_spx_band_struct[17] =
-{ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 };
diff --git a/src/thirdparty/ffmpeg/libavcodec/ac3dec_data.h b/src/thirdparty/ffmpeg/libavcodec/ac3dec_data.h
deleted file mode 100644
index 3e53d5550..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/ac3dec_data.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * AC-3 and E-AC-3 decoder tables
- * Copyright (c) 2007 Bartlomiej Wolowiec <bartek.wolowiec@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_AC3DEC_DATA_H
-#define AVCODEC_AC3DEC_DATA_H
-
-#include <stdint.h>
-
-extern const uint8_t ff_ac3_ungroup_3_in_5_bits_tab[32][3];
-
-extern const uint8_t ff_eac3_hebap_tab[64];
-extern const uint8_t ff_eac3_default_spx_band_struct[17];
-
-#endif /* AVCODEC_AC3DEC_DATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/ac3dsp.c b/src/thirdparty/ffmpeg/libavcodec/ac3dsp.c
deleted file mode 100644
index 2f0f4c318..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/ac3dsp.c
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * AC-3 DSP utils
- * Copyright (c) 2011 Justin Ruggles
- *
- * 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/avassert.h"
-#include "avcodec.h"
-#include "ac3.h"
-#include "ac3dsp.h"
-#include "mathops.h"
-
-static void ac3_exponent_min_c(uint8_t *exp, int num_reuse_blocks, int nb_coefs)
-{
- int blk, i;
-
- if (!num_reuse_blocks)
- return;
-
- for (i = 0; i < nb_coefs; i++) {
- uint8_t min_exp = *exp;
- uint8_t *exp1 = exp + 256;
- for (blk = 0; blk < num_reuse_blocks; blk++) {
- uint8_t next_exp = *exp1;
- if (next_exp < min_exp)
- min_exp = next_exp;
- exp1 += 256;
- }
- *exp++ = min_exp;
- }
-}
-
-static int ac3_max_msb_abs_int16_c(const int16_t *src, int len)
-{
- int i, v = 0;
- for (i = 0; i < len; i++)
- v |= abs(src[i]);
- return v;
-}
-
-static void ac3_lshift_int16_c(int16_t *src, unsigned int len,
- unsigned int shift)
-{
- uint32_t *src32 = (uint32_t *)src;
- const uint32_t mask = ~(((1 << shift) - 1) << 16);
- int i;
- len >>= 1;
- for (i = 0; i < len; i += 8) {
- src32[i ] = (src32[i ] << shift) & mask;
- src32[i+1] = (src32[i+1] << shift) & mask;
- src32[i+2] = (src32[i+2] << shift) & mask;
- src32[i+3] = (src32[i+3] << shift) & mask;
- src32[i+4] = (src32[i+4] << shift) & mask;
- src32[i+5] = (src32[i+5] << shift) & mask;
- src32[i+6] = (src32[i+6] << shift) & mask;
- src32[i+7] = (src32[i+7] << shift) & mask;
- }
-}
-
-static void ac3_rshift_int32_c(int32_t *src, unsigned int len,
- unsigned int shift)
-{
- do {
- *src++ >>= shift;
- *src++ >>= shift;
- *src++ >>= shift;
- *src++ >>= shift;
- *src++ >>= shift;
- *src++ >>= shift;
- *src++ >>= shift;
- *src++ >>= shift;
- len -= 8;
- } while (len > 0);
-}
-
-static void float_to_fixed24_c(int32_t *dst, const float *src, unsigned int len)
-{
- const float scale = 1 << 24;
- do {
- *dst++ = lrintf(*src++ * scale);
- *dst++ = lrintf(*src++ * scale);
- *dst++ = lrintf(*src++ * scale);
- *dst++ = lrintf(*src++ * scale);
- *dst++ = lrintf(*src++ * scale);
- *dst++ = lrintf(*src++ * scale);
- *dst++ = lrintf(*src++ * scale);
- *dst++ = lrintf(*src++ * scale);
- len -= 8;
- } while (len > 0);
-}
-
-static void ac3_bit_alloc_calc_bap_c(int16_t *mask, int16_t *psd,
- int start, int end,
- int snr_offset, int floor,
- const uint8_t *bap_tab, uint8_t *bap)
-{
- int bin, band, band_end;
-
- /* special case, if snr offset is -960, set all bap's to zero */
- if (snr_offset == -960) {
- memset(bap, 0, AC3_MAX_COEFS);
- return;
- }
-
- bin = start;
- band = ff_ac3_bin_to_band_tab[start];
- do {
- int m = (FFMAX(mask[band] - snr_offset - floor, 0) & 0x1FE0) + floor;
- band_end = ff_ac3_band_start_tab[++band];
- band_end = FFMIN(band_end, end);
-
- for (; bin < band_end; bin++) {
- int address = av_clip((psd[bin] - m) >> 5, 0, 63);
- bap[bin] = bap_tab[address];
- }
- } while (end > band_end);
-}
-
-static void ac3_update_bap_counts_c(uint16_t mant_cnt[16], uint8_t *bap,
- int len)
-{
- while (len-- > 0)
- mant_cnt[bap[len]]++;
-}
-
-DECLARE_ALIGNED(16, const uint16_t, ff_ac3_bap_bits)[16] = {
- 0, 0, 0, 3, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16
-};
-
-static int ac3_compute_mantissa_size_c(uint16_t mant_cnt[6][16])
-{
- int blk, bap;
- int bits = 0;
-
- for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
- // bap=1 : 3 mantissas in 5 bits
- bits += (mant_cnt[blk][1] / 3) * 5;
- // bap=2 : 3 mantissas in 7 bits
- // bap=4 : 2 mantissas in 7 bits
- bits += ((mant_cnt[blk][2] / 3) + (mant_cnt[blk][4] >> 1)) * 7;
- // bap=3 : 1 mantissa in 3 bits
- bits += mant_cnt[blk][3] * 3;
- // bap=5 to 15 : get bits per mantissa from table
- for (bap = 5; bap < 16; bap++)
- bits += mant_cnt[blk][bap] * ff_ac3_bap_bits[bap];
- }
- return bits;
-}
-
-static void ac3_extract_exponents_c(uint8_t *exp, int32_t *coef, int nb_coefs)
-{
- int i;
-
- for (i = 0; i < nb_coefs; i++) {
- int v = abs(coef[i]);
- exp[i] = v ? 23 - av_log2(v) : 24;
- }
-}
-
-static void ac3_sum_square_butterfly_int32_c(int64_t sum[4],
- const int32_t *coef0,
- const int32_t *coef1,
- int len)
-{
- int i;
-
- sum[0] = sum[1] = sum[2] = sum[3] = 0;
-
- for (i = 0; i < len; i++) {
- int lt = coef0[i];
- int rt = coef1[i];
- int md = lt + rt;
- int sd = lt - rt;
- MAC64(sum[0], lt, lt);
- MAC64(sum[1], rt, rt);
- MAC64(sum[2], md, md);
- MAC64(sum[3], sd, sd);
- }
-}
-
-static void ac3_sum_square_butterfly_float_c(float sum[4],
- const float *coef0,
- const float *coef1,
- int len)
-{
- int i;
-
- sum[0] = sum[1] = sum[2] = sum[3] = 0;
-
- for (i = 0; i < len; i++) {
- float lt = coef0[i];
- float rt = coef1[i];
- float md = lt + rt;
- float sd = lt - rt;
- sum[0] += lt * lt;
- sum[1] += rt * rt;
- sum[2] += md * md;
- sum[3] += sd * sd;
- }
-}
-
-static void ac3_downmix_c(float **samples, float (*matrix)[2],
- int out_ch, int in_ch, int len)
-{
- int i, j;
- float v0, v1;
- if (out_ch == 2) {
- for (i = 0; i < len; i++) {
- v0 = v1 = 0.0f;
- 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;
- samples[1][i] = v1;
- }
- } else if (out_ch == 1) {
- for (i = 0; i < len; i++) {
- v0 = 0.0f;
- for (j = 0; j < in_ch; j++)
- v0 += samples[j][i] * matrix[j][0];
- samples[0][i] = v0;
- }
- }
-}
-
-av_cold void ff_ac3dsp_init(AC3DSPContext *c, int bit_exact)
-{
- c->ac3_exponent_min = ac3_exponent_min_c;
- c->ac3_max_msb_abs_int16 = ac3_max_msb_abs_int16_c;
- c->ac3_lshift_int16 = ac3_lshift_int16_c;
- c->ac3_rshift_int32 = ac3_rshift_int32_c;
- c->float_to_fixed24 = float_to_fixed24_c;
- c->bit_alloc_calc_bap = ac3_bit_alloc_calc_bap_c;
- c->update_bap_counts = ac3_update_bap_counts_c;
- c->compute_mantissa_size = ac3_compute_mantissa_size_c;
- c->extract_exponents = ac3_extract_exponents_c;
- 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;
-
- if (ARCH_ARM)
- ff_ac3dsp_init_arm(c, bit_exact);
- if (ARCH_X86)
- ff_ac3dsp_init_x86(c, bit_exact);
- if (ARCH_MIPS)
- ff_ac3dsp_init_mips(c, bit_exact);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/ac3dsp.h b/src/thirdparty/ffmpeg/libavcodec/ac3dsp.h
deleted file mode 100644
index 4cf98ae04..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/ac3dsp.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * AC-3 DSP utils
- * Copyright (c) 2011 Justin Ruggles
- *
- * 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_AC3DSP_H
-#define AVCODEC_AC3DSP_H
-
-#include <stdint.h>
-
-/**
- * Number of mantissa bits written for each bap value.
- * bap values with fractional bits are set to 0 and are calculated separately.
- */
-extern const uint16_t ff_ac3_bap_bits[16];
-
-typedef struct AC3DSPContext {
- /**
- * Set each encoded exponent in a block to the minimum of itself and the
- * exponents in the same frequency bin of up to 5 following blocks.
- * @param exp pointer to the start of the current block of exponents.
- * constraints: align 16
- * @param num_reuse_blocks number of blocks that will reuse exponents from the current block.
- * constraints: range 0 to 5
- * @param nb_coefs number of frequency coefficients.
- */
- void (*ac3_exponent_min)(uint8_t *exp, int num_reuse_blocks, int nb_coefs);
-
- /**
- * Calculate the maximum MSB of the absolute value of each element in an
- * array of int16_t.
- * @param src input array
- * constraints: align 16. values must be in range [-32767,32767]
- * @param len number of values in the array
- * constraints: multiple of 16 greater than 0
- * @return a value with the same MSB as max(abs(src[]))
- */
- int (*ac3_max_msb_abs_int16)(const int16_t *src, int len);
-
- /**
- * Left-shift each value in an array of int16_t by a specified amount.
- * @param src input array
- * constraints: align 16
- * @param len number of values in the array
- * constraints: multiple of 32 greater than 0
- * @param shift left shift amount
- * constraints: range [0,15]
- */
- void (*ac3_lshift_int16)(int16_t *src, unsigned int len, unsigned int shift);
-
- /**
- * Right-shift each value in an array of int32_t by a specified amount.
- * @param src input array
- * constraints: align 16
- * @param len number of values in the array
- * constraints: multiple of 16 greater than 0
- * @param shift right shift amount
- * constraints: range [0,31]
- */
- void (*ac3_rshift_int32)(int32_t *src, unsigned int len, unsigned int shift);
-
- /**
- * Convert an array of float in range [-1.0,1.0] to int32_t with range
- * [-(1<<24),(1<<24)]
- *
- * @param dst destination array of int32_t.
- * constraints: 16-byte aligned
- * @param src source array of float.
- * constraints: 16-byte aligned
- * @param len number of elements to convert.
- * constraints: multiple of 32 greater than zero
- */
- void (*float_to_fixed24)(int32_t *dst, const float *src, unsigned int len);
-
- /**
- * Calculate bit allocation pointers.
- * The SNR is the difference between the masking curve and the signal. AC-3
- * uses this value for each frequency bin to allocate bits. The snroffset
- * parameter is a global adjustment to the SNR for all bins.
- *
- * @param[in] mask masking curve
- * @param[in] psd signal power for each frequency bin
- * @param[in] start starting bin location
- * @param[in] end ending bin location
- * @param[in] snr_offset SNR adjustment
- * @param[in] floor noise floor
- * @param[in] bap_tab look-up table for bit allocation pointers
- * @param[out] bap bit allocation pointers
- */
- void (*bit_alloc_calc_bap)(int16_t *mask, int16_t *psd, int start, int end,
- int snr_offset, int floor,
- const uint8_t *bap_tab, uint8_t *bap);
-
- /**
- * Update bap counts using the supplied array of bap.
- *
- * @param[out] mant_cnt bap counts for 1 block
- * @param[in] bap array of bap, pointing to start coef bin
- * @param[in] len number of elements to process
- */
- void (*update_bap_counts)(uint16_t mant_cnt[16], uint8_t *bap, int len);
-
- /**
- * Calculate the number of bits needed to encode a set of mantissas.
- *
- * @param[in] mant_cnt bap counts for all blocks
- * @return mantissa bit count
- */
- int (*compute_mantissa_size)(uint16_t mant_cnt[6][16]);
-
- void (*extract_exponents)(uint8_t *exp, int32_t *coef, int nb_coefs);
-
- void (*sum_square_butterfly_int32)(int64_t sum[4], const int32_t *coef0,
- const int32_t *coef1, int len);
-
- void (*sum_square_butterfly_float)(float sum[4], const float *coef0,
- const float *coef1, int len);
-
- void (*downmix)(float **samples, float (*matrix)[2], int out_ch,
- int in_ch, int len);
-} AC3DSPContext;
-
-void ff_ac3dsp_init (AC3DSPContext *c, int bit_exact);
-void ff_ac3dsp_init_arm(AC3DSPContext *c, int bit_exact);
-void ff_ac3dsp_init_x86(AC3DSPContext *c, int bit_exact);
-void ff_ac3dsp_init_mips(AC3DSPContext *c, int bit_exact);
-
-#endif /* AVCODEC_AC3DSP_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/ac3tab.c b/src/thirdparty/ffmpeg/libavcodec/ac3tab.c
deleted file mode 100644
index c52365b24..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/ac3tab.c
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- * AC-3 tables
- * copyright (c) 2001 Fabrice Bellard
- *
- * 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
- * tables taken directly from the AC-3 spec.
- */
-
-#include "libavutil/channel_layout.h"
-#include "avcodec.h"
-#include "ac3tab.h"
-
-/**
- * Possible frame sizes.
- * from ATSC A/52 Table 5.18 Frame Size Code Table.
- */
-const uint16_t ff_ac3_frame_size_tab[38][3] = {
- { 64, 69, 96 },
- { 64, 70, 96 },
- { 80, 87, 120 },
- { 80, 88, 120 },
- { 96, 104, 144 },
- { 96, 105, 144 },
- { 112, 121, 168 },
- { 112, 122, 168 },
- { 128, 139, 192 },
- { 128, 140, 192 },
- { 160, 174, 240 },
- { 160, 175, 240 },
- { 192, 208, 288 },
- { 192, 209, 288 },
- { 224, 243, 336 },
- { 224, 244, 336 },
- { 256, 278, 384 },
- { 256, 279, 384 },
- { 320, 348, 480 },
- { 320, 349, 480 },
- { 384, 417, 576 },
- { 384, 418, 576 },
- { 448, 487, 672 },
- { 448, 488, 672 },
- { 512, 557, 768 },
- { 512, 558, 768 },
- { 640, 696, 960 },
- { 640, 697, 960 },
- { 768, 835, 1152 },
- { 768, 836, 1152 },
- { 896, 975, 1344 },
- { 896, 976, 1344 },
- { 1024, 1114, 1536 },
- { 1024, 1115, 1536 },
- { 1152, 1253, 1728 },
- { 1152, 1254, 1728 },
- { 1280, 1393, 1920 },
- { 1280, 1394, 1920 },
-};
-
-/**
- * Map audio coding mode (acmod) to number of full-bandwidth channels.
- * from ATSC A/52 Table 5.8 Audio Coding Mode
- */
-const uint8_t ff_ac3_channels_tab[8] = {
- 2, 1, 2, 3, 3, 4, 4, 5
-};
-
-/**
- * Map audio coding mode (acmod) to channel layout mask.
- */
-const uint16_t avpriv_ac3_channel_layout_tab[8] = {
- AV_CH_LAYOUT_STEREO,
- AV_CH_LAYOUT_MONO,
- AV_CH_LAYOUT_STEREO,
- AV_CH_LAYOUT_SURROUND,
- AV_CH_LAYOUT_2_1,
- AV_CH_LAYOUT_4POINT0,
- AV_CH_LAYOUT_2_2,
- AV_CH_LAYOUT_5POINT0
-};
-
-#define COMMON_CHANNEL_MAP \
- { { 0, 1, }, { 0, 1, 2, } },\
- { { 0, }, { 0, 1, } },\
- { { 0, 1, }, { 0, 1, 2, } },\
- { { 0, 2, 1, }, { 0, 2, 1, 3, } },\
- { { 0, 1, 2, }, { 0, 1, 3, 2, } },\
- { { 0, 2, 1, 3, }, { 0, 2, 1, 4, 3, } },
-
-/**
- * Table to remap channels from SMPTE order to AC-3 order.
- * [channel_mode][lfe][ch]
- */
-const uint8_t ff_ac3_enc_channel_map[8][2][6] = {
- COMMON_CHANNEL_MAP
- { { 0, 1, 2, 3, }, { 0, 1, 3, 4, 2, } },
- { { 0, 2, 1, 3, 4, }, { 0, 2, 1, 4, 5, 3 } },
-};
-
-/**
- * Table to remap channels from from AC-3 order to SMPTE order.
- * [channel_mode][lfe][ch]
- */
-const uint8_t ff_ac3_dec_channel_map[8][2][6] = {
- COMMON_CHANNEL_MAP
- { { 0, 1, 2, 3, }, { 0, 1, 4, 2, 3, } },
- { { 0, 2, 1, 3, 4, }, { 0, 2, 1, 5, 3, 4 } },
-};
-
-/* possible frequencies */
-const uint16_t ff_ac3_sample_rate_tab[3] = { 48000, 44100, 32000 };
-
-/* possible bitrates */
-const uint16_t ff_ac3_bitrate_tab[19] = {
- 32, 40, 48, 56, 64, 80, 96, 112, 128,
- 160, 192, 224, 256, 320, 384, 448, 512, 576, 640
-};
-
-/**
- * Table of bin locations for rematrixing bands
- * reference: Section 7.5.2 Rematrixing : Frequency Band Definitions
- */
-const uint8_t ff_ac3_rematrix_band_tab[5] = { 13, 25, 37, 61, 253 };
-
-/**
- * Table E2.16 Default Coupling Banding Structure
- */
-const uint8_t ff_eac3_default_cpl_band_struct[18] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1
-};
-
-/* AC-3 MDCT window */
-
-/* MDCT window */
-DECLARE_ALIGNED(16, const int16_t, ff_ac3_window)[AC3_WINDOW_SIZE/2] = {
- 4, 7, 12, 16, 21, 28, 34, 42,
- 51, 61, 72, 84, 97, 111, 127, 145,
- 164, 184, 207, 231, 257, 285, 315, 347,
- 382, 419, 458, 500, 544, 591, 641, 694,
- 750, 810, 872, 937, 1007, 1079, 1155, 1235,
- 1318, 1406, 1497, 1593, 1692, 1796, 1903, 2016,
- 2132, 2253, 2379, 2509, 2644, 2783, 2927, 3076,
- 3230, 3389, 3552, 3721, 3894, 4072, 4255, 4444,
- 4637, 4835, 5038, 5246, 5459, 5677, 5899, 6127,
- 6359, 6596, 6837, 7083, 7334, 7589, 7848, 8112,
- 8380, 8652, 8927, 9207, 9491, 9778,10069,10363,
-10660,10960,11264,11570,11879,12190,12504,12820,
-13138,13458,13780,14103,14427,14753,15079,15407,
-15735,16063,16392,16720,17049,17377,17705,18032,
-18358,18683,19007,19330,19651,19970,20287,20602,
-20914,21225,21532,21837,22139,22438,22733,23025,
-23314,23599,23880,24157,24430,24699,24964,25225,
-25481,25732,25979,26221,26459,26691,26919,27142,
-27359,27572,27780,27983,28180,28373,28560,28742,
-28919,29091,29258,29420,29577,29729,29876,30018,
-30155,30288,30415,30538,30657,30771,30880,30985,
-31086,31182,31274,31363,31447,31528,31605,31678,
-31747,31814,31877,31936,31993,32046,32097,32145,
-32190,32232,32272,32310,32345,32378,32409,32438,
-32465,32490,32513,32535,32556,32574,32592,32608,
-32623,32636,32649,32661,32671,32681,32690,32698,
-32705,32712,32718,32724,32729,32733,32737,32741,
-32744,32747,32750,32752,32754,32756,32757,32759,
-32760,32761,32762,32763,32764,32764,32765,32765,
-32766,32766,32766,32766,32767,32767,32767,32767,
-32767,32767,32767,32767,32767,32767,32767,32767,
-32767,32767,32767,32767,32767,32767,32767,32767,
-};
-
-const uint8_t ff_ac3_log_add_tab[260]= {
-0x40,0x3f,0x3e,0x3d,0x3c,0x3b,0x3a,0x39,0x38,0x37,
-0x36,0x35,0x34,0x34,0x33,0x32,0x31,0x30,0x2f,0x2f,
-0x2e,0x2d,0x2c,0x2c,0x2b,0x2a,0x29,0x29,0x28,0x27,
-0x26,0x26,0x25,0x24,0x24,0x23,0x23,0x22,0x21,0x21,
-0x20,0x20,0x1f,0x1e,0x1e,0x1d,0x1d,0x1c,0x1c,0x1b,
-0x1b,0x1a,0x1a,0x19,0x19,0x18,0x18,0x17,0x17,0x16,
-0x16,0x15,0x15,0x15,0x14,0x14,0x13,0x13,0x13,0x12,
-0x12,0x12,0x11,0x11,0x11,0x10,0x10,0x10,0x0f,0x0f,
-0x0f,0x0e,0x0e,0x0e,0x0d,0x0d,0x0d,0x0d,0x0c,0x0c,
-0x0c,0x0c,0x0b,0x0b,0x0b,0x0b,0x0a,0x0a,0x0a,0x0a,
-0x0a,0x09,0x09,0x09,0x09,0x09,0x08,0x08,0x08,0x08,
-0x08,0x08,0x07,0x07,0x07,0x07,0x07,0x07,0x06,0x06,
-0x06,0x06,0x06,0x06,0x06,0x06,0x05,0x05,0x05,0x05,
-0x05,0x05,0x05,0x05,0x04,0x04,0x04,0x04,0x04,0x04,
-0x04,0x04,0x04,0x04,0x04,0x03,0x03,0x03,0x03,0x03,
-0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x02,
-0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
-0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x01,
-0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
-0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
-0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-};
-
-const uint16_t ff_ac3_hearing_threshold_tab[AC3_CRITICAL_BANDS][3]= {
-{ 0x04d0,0x04f0,0x0580 },
-{ 0x04d0,0x04f0,0x0580 },
-{ 0x0440,0x0460,0x04b0 },
-{ 0x0400,0x0410,0x0450 },
-{ 0x03e0,0x03e0,0x0420 },
-{ 0x03c0,0x03d0,0x03f0 },
-{ 0x03b0,0x03c0,0x03e0 },
-{ 0x03b0,0x03b0,0x03d0 },
-{ 0x03a0,0x03b0,0x03c0 },
-{ 0x03a0,0x03a0,0x03b0 },
-{ 0x03a0,0x03a0,0x03b0 },
-{ 0x03a0,0x03a0,0x03b0 },
-{ 0x03a0,0x03a0,0x03a0 },
-{ 0x0390,0x03a0,0x03a0 },
-{ 0x0390,0x0390,0x03a0 },
-{ 0x0390,0x0390,0x03a0 },
-{ 0x0380,0x0390,0x03a0 },
-{ 0x0380,0x0380,0x03a0 },
-{ 0x0370,0x0380,0x03a0 },
-{ 0x0370,0x0380,0x03a0 },
-{ 0x0360,0x0370,0x0390 },
-{ 0x0360,0x0370,0x0390 },
-{ 0x0350,0x0360,0x0390 },
-{ 0x0350,0x0360,0x0390 },
-{ 0x0340,0x0350,0x0380 },
-{ 0x0340,0x0350,0x0380 },
-{ 0x0330,0x0340,0x0380 },
-{ 0x0320,0x0340,0x0370 },
-{ 0x0310,0x0320,0x0360 },
-{ 0x0300,0x0310,0x0350 },
-{ 0x02f0,0x0300,0x0340 },
-{ 0x02f0,0x02f0,0x0330 },
-{ 0x02f0,0x02f0,0x0320 },
-{ 0x02f0,0x02f0,0x0310 },
-{ 0x0300,0x02f0,0x0300 },
-{ 0x0310,0x0300,0x02f0 },
-{ 0x0340,0x0320,0x02f0 },
-{ 0x0390,0x0350,0x02f0 },
-{ 0x03e0,0x0390,0x0300 },
-{ 0x0420,0x03e0,0x0310 },
-{ 0x0460,0x0420,0x0330 },
-{ 0x0490,0x0450,0x0350 },
-{ 0x04a0,0x04a0,0x03c0 },
-{ 0x0460,0x0490,0x0410 },
-{ 0x0440,0x0460,0x0470 },
-{ 0x0440,0x0440,0x04a0 },
-{ 0x0520,0x0480,0x0460 },
-{ 0x0800,0x0630,0x0440 },
-{ 0x0840,0x0840,0x0450 },
-{ 0x0840,0x0840,0x04e0 },
-};
-
-const uint8_t ff_ac3_bap_tab[64]= {
- 0, 1, 1, 1, 1, 1, 2, 2, 3, 3,
- 3, 4, 4, 5, 5, 6, 6, 6, 6, 7,
- 7, 7, 7, 8, 8, 8, 8, 9, 9, 9,
- 9, 10, 10, 10, 10, 11, 11, 11, 11, 12,
- 12, 12, 12, 13, 13, 13, 13, 14, 14, 14,
- 14, 14, 14, 14, 14, 15, 15, 15, 15, 15,
- 15, 15, 15, 15,
-};
-
-const uint8_t ff_ac3_slow_decay_tab[4]={
- 0x0f, 0x11, 0x13, 0x15,
-};
-
-const uint8_t ff_ac3_fast_decay_tab[4]={
- 0x3f, 0x53, 0x67, 0x7b,
-};
-
-const uint16_t ff_ac3_slow_gain_tab[4]= {
- 0x540, 0x4d8, 0x478, 0x410,
-};
-
-const uint16_t ff_ac3_db_per_bit_tab[4]= {
- 0x000, 0x700, 0x900, 0xb00,
-};
-
-const int16_t ff_ac3_floor_tab[8]= {
- 0x2f0, 0x2b0, 0x270, 0x230, 0x1f0, 0x170, 0x0f0, 0xf800,
-};
-
-const uint16_t ff_ac3_fast_gain_tab[8]= {
- 0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x400,
-};
-
-/**
- * Default channel map for a dependent substream defined by acmod
- */
-const uint16_t ff_eac3_default_chmap[8] = {
- AC3_CHMAP_L | AC3_CHMAP_R, // FIXME Ch1+Ch2
- AC3_CHMAP_C,
- AC3_CHMAP_L | AC3_CHMAP_R,
- AC3_CHMAP_L | AC3_CHMAP_C | AC3_CHMAP_R,
- AC3_CHMAP_L | AC3_CHMAP_R | AC3_CHMAP_C_SUR,
- AC3_CHMAP_L | AC3_CHMAP_C | AC3_CHMAP_R | AC3_CHMAP_C_SUR,
- AC3_CHMAP_L | AC3_CHMAP_R | AC3_CHMAP_L_SUR | AC3_CHMAP_R_SUR,
- AC3_CHMAP_L | AC3_CHMAP_C | AC3_CHMAP_R | AC3_CHMAP_L_SUR | AC3_CHMAP_R_SUR
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/ac3tab.h b/src/thirdparty/ffmpeg/libavcodec/ac3tab.h
deleted file mode 100644
index 63b3df09d..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/ac3tab.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * AC-3 tables
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
- *
- * 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_AC3TAB_H
-#define AVCODEC_AC3TAB_H
-
-#include "libavutil/common.h"
-#include "ac3.h"
-
-#if CONFIG_HARDCODED_TABLES
-# define HCONST const
-#else
-# define HCONST
-#endif
-
-extern const uint16_t ff_ac3_frame_size_tab[38][3];
-extern const uint8_t ff_ac3_channels_tab[8];
-extern av_export const uint16_t avpriv_ac3_channel_layout_tab[8];
-extern const uint8_t ff_ac3_enc_channel_map[8][2][6];
-extern const uint8_t ff_ac3_dec_channel_map[8][2][6];
-extern const uint16_t ff_ac3_sample_rate_tab[3];
-extern const uint16_t ff_ac3_bitrate_tab[19];
-extern const uint8_t ff_ac3_rematrix_band_tab[5];
-extern const uint8_t ff_eac3_default_cpl_band_struct[18];
-extern const int16_t ff_ac3_window[AC3_WINDOW_SIZE/2];
-extern const uint8_t ff_ac3_log_add_tab[260];
-extern const uint16_t ff_ac3_hearing_threshold_tab[AC3_CRITICAL_BANDS][3];
-extern const uint8_t ff_ac3_bap_tab[64];
-extern const uint8_t ff_ac3_slow_decay_tab[4];
-extern const uint8_t ff_ac3_fast_decay_tab[4];
-extern const uint16_t ff_ac3_slow_gain_tab[4];
-extern const uint16_t ff_ac3_db_per_bit_tab[4];
-extern const int16_t ff_ac3_floor_tab[8];
-extern const uint16_t ff_ac3_fast_gain_tab[8];
-extern const uint16_t ff_eac3_default_chmap[8];
-extern const uint8_t ff_ac3_band_start_tab[AC3_CRITICAL_BANDS+1];
-extern HCONST uint8_t ff_ac3_bin_to_band_tab[253];
-
-/** Custom channel map locations bitmask
- * Other channels described in documentation:
- * Lc/Rc pair, Lrs/Rrs pair, Ts, Lsd/Rsd pair,
- * Lw/Rw pair, Lvh/Rvh pair, Cvh, Reserved, LFE2
- */
-enum CustomChannelMapLocation{
- AC3_CHMAP_L= 1<<(15-0),
- AC3_CHMAP_C= 1<<(15-1),
- AC3_CHMAP_R= 1<<(15-2),
- AC3_CHMAP_L_SUR= 1<<(15-3),
- AC3_CHMAP_R_SUR = 1<<(15-4),
- AC3_CHMAP_C_SUR= 1<<(15-7),
- AC3_CHMAP_LFE = 1<<(15-15)
-};
-
-#endif /* AVCODEC_AC3TAB_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/acelp_filters.c b/src/thirdparty/ffmpeg/libavcodec/acelp_filters.c
deleted file mode 100644
index 9da456ba7..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/acelp_filters.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * various filters for ACELP-based codecs
- *
- * Copyright (c) 2008 Vladimir Voroshilov
- *
- * 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 <inttypes.h>
-
-#include "libavutil/avassert.h"
-#include "libavutil/common.h"
-#include "avcodec.h"
-#include "acelp_filters.h"
-
-const int16_t ff_acelp_interp_filter[61] = { /* (0.15) */
- 29443, 28346, 25207, 20449, 14701, 8693,
- 3143, -1352, -4402, -5865, -5850, -4673,
- -2783, -672, 1211, 2536, 3130, 2991,
- 2259, 1170, 0, -1001, -1652, -1868,
- -1666, -1147, -464, 218, 756, 1060,
- 1099, 904, 550, 135, -245, -514,
- -634, -602, -451, -231, 0, 191,
- 308, 340, 296, 198, 78, -36,
- -120, -163, -165, -132, -79, -19,
- 34, 73, 91, 89, 70, 38,
- 0,
-};
-
-void ff_acelp_interpolate(int16_t* out, const int16_t* in,
- const int16_t* filter_coeffs, int precision,
- int frac_pos, int filter_length, int length)
-{
- int n, i;
-
- av_assert1(frac_pos >= 0 && frac_pos < precision);
-
- for (n = 0; n < length; n++) {
- int idx = 0;
- int v = 0x4000;
-
- for (i = 0; i < filter_length;) {
-
- /* The reference G.729 and AMR fixed point code performs clipping after
- each of the two following accumulations.
- Since clipping affects only the synthetic OVERFLOW test without
- causing an int type overflow, it was moved outside the loop. */
-
- /* R(x):=ac_v[-k+x]
- v += R(n-i)*ff_acelp_interp_filter(t+6i)
- v += R(n+i+1)*ff_acelp_interp_filter(6-t+6i) */
-
- v += in[n + i] * filter_coeffs[idx + frac_pos];
- idx += precision;
- i++;
- v += in[n - i] * filter_coeffs[idx - frac_pos];
- }
- if (av_clip_int16(v >> 15) != (v >> 15))
- av_log(NULL, AV_LOG_WARNING, "overflow that would need cliping in ff_acelp_interpolate()\n");
- out[n] = v >> 15;
- }
-}
-
-void ff_acelp_interpolatef(float *out, const float *in,
- const float *filter_coeffs, int precision,
- int frac_pos, int filter_length, int length)
-{
- int n, i;
-
- for (n = 0; n < length; n++) {
- int idx = 0;
- float v = 0;
-
- for (i = 0; i < filter_length;) {
- v += in[n + i] * filter_coeffs[idx + frac_pos];
- idx += precision;
- i++;
- v += in[n - i] * filter_coeffs[idx - frac_pos];
- }
- out[n] = v;
- }
-}
-
-
-void ff_acelp_high_pass_filter(int16_t* out, int hpf_f[2],
- const int16_t* in, int length)
-{
- int i;
- int tmp;
-
- for (i = 0; i < length; i++) {
- tmp = (hpf_f[0]* 15836LL) >> 13;
- tmp += (hpf_f[1]* -7667LL) >> 13;
- tmp += 7699 * (in[i] - 2*in[i-1] + in[i-2]);
-
- /* With "+0x800" rounding, clipping is needed
- for ALGTHM and SPEECH tests. */
- out[i] = av_clip_int16((tmp + 0x800) >> 12);
-
- hpf_f[1] = hpf_f[0];
- hpf_f[0] = tmp;
- }
-}
-
-void ff_acelp_apply_order_2_transfer_function(float *out, const float *in,
- const float zero_coeffs[2],
- const float pole_coeffs[2],
- float gain, float mem[2], int n)
-{
- int i;
- float tmp;
-
- for (i = 0; i < n; i++) {
- tmp = gain * in[i] - pole_coeffs[0] * mem[0] - pole_coeffs[1] * mem[1];
- out[i] = tmp + zero_coeffs[0] * mem[0] + zero_coeffs[1] * mem[1];
-
- mem[1] = mem[0];
- mem[0] = tmp;
- }
-}
-
-void ff_tilt_compensation(float *mem, float tilt, float *samples, int size)
-{
- float new_tilt_mem = samples[size - 1];
- int i;
-
- for (i = size - 1; i > 0; i--)
- samples[i] -= tilt * samples[i - 1];
-
- samples[0] -= tilt * *mem;
- *mem = new_tilt_mem;
-}
-
-void ff_acelp_filter_init(ACELPFContext *c)
-{
- c->acelp_interpolatef = ff_acelp_interpolatef;
- c->acelp_apply_order_2_transfer_function = ff_acelp_apply_order_2_transfer_function;
-
- if(HAVE_MIPSFPU)
- ff_acelp_filter_init_mips(c);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/acelp_filters.h b/src/thirdparty/ffmpeg/libavcodec/acelp_filters.h
deleted file mode 100644
index 990fa5aac..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/acelp_filters.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * various filters for ACELP-based codecs
- *
- * Copyright (c) 2008 Vladimir Voroshilov
- *
- * 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_ACELP_FILTERS_H
-#define AVCODEC_ACELP_FILTERS_H
-
-#include <stdint.h>
-
-typedef struct ACELPFContext {
- /**
- * Floating point version of ff_acelp_interpolate()
- */
- void (*acelp_interpolatef)(float *out, const float *in,
- const float *filter_coeffs, int precision,
- int frac_pos, int filter_length, int length);
-
- /**
- * Apply an order 2 rational transfer function in-place.
- *
- * @param out output buffer for filtered speech samples
- * @param in input buffer containing speech data (may be the same as out)
- * @param zero_coeffs z^-1 and z^-2 coefficients of the numerator
- * @param pole_coeffs z^-1 and z^-2 coefficients of the denominator
- * @param gain scale factor for final output
- * @param mem intermediate values used by filter (should be 0 initially)
- * @param n number of samples (should be a multiple of eight)
- */
- void (*acelp_apply_order_2_transfer_function)(float *out, const float *in,
- const float zero_coeffs[2],
- const float pole_coeffs[2],
- float gain,
- float mem[2], int n);
-
-}ACELPFContext;
-
-/**
- * Initialize ACELPFContext.
- */
-void ff_acelp_filter_init(ACELPFContext *c);
-void ff_acelp_filter_init_mips(ACELPFContext *c);
-
-/**
- * low-pass Finite Impulse Response filter coefficients.
- *
- * Hamming windowed sinc filter with cutoff freq 3/40 of the sampling freq,
- * the coefficients are scaled by 2^15.
- * This array only contains the right half of the filter.
- * This filter is likely identical to the one used in G.729, though this
- * could not be determined from the original comments with certainty.
- */
-extern const int16_t ff_acelp_interp_filter[61];
-
-/**
- * Generic FIR interpolation routine.
- * @param[out] out buffer for interpolated data
- * @param in input data
- * @param filter_coeffs interpolation filter coefficients (0.15)
- * @param precision sub sample factor, that is the precision of the position
- * @param frac_pos fractional part of position [0..precision-1]
- * @param filter_length filter length
- * @param length length of output
- *
- * filter_coeffs contains coefficients of the right half of the symmetric
- * interpolation filter. filter_coeffs[0] should the central (unpaired) coefficient.
- * See ff_acelp_interp_filter for an example.
- *
- */
-void ff_acelp_interpolate(int16_t* out, const int16_t* in,
- const int16_t* filter_coeffs, int precision,
- int frac_pos, int filter_length, int length);
-
-/**
- * Floating point version of ff_acelp_interpolate()
- */
-void ff_acelp_interpolatef(float *out, const float *in,
- const float *filter_coeffs, int precision,
- int frac_pos, int filter_length, int length);
-
-
-/**
- * high-pass filtering and upscaling (4.2.5 of G.729).
- * @param[out] out output buffer for filtered speech data
- * @param[in,out] hpf_f past filtered data from previous (2 items long)
- * frames (-0x20000000 <= (14.13) < 0x20000000)
- * @param in speech data to process
- * @param length input data size
- *
- * out[i] = 0.93980581 * in[i] - 1.8795834 * in[i-1] + 0.93980581 * in[i-2] +
- * 1.9330735 * out[i-1] - 0.93589199 * out[i-2]
- *
- * The filter has a cut-off frequency of 1/80 of the sampling freq
- *
- * @note Two items before the top of the in buffer must contain two items from the
- * tail of the previous subframe.
- *
- * @remark It is safe to pass the same array in in and out parameters.
- *
- * @remark AMR uses mostly the same filter (cut-off frequency 60Hz, same formula,
- * but constants differs in 5th sign after comma). Fortunately in
- * fixed-point all coefficients are the same as in G.729. Thus this
- * routine can be used for the fixed-point AMR decoder, too.
- */
-void ff_acelp_high_pass_filter(int16_t* out, int hpf_f[2],
- const int16_t* in, int length);
-
-/**
- * Apply an order 2 rational transfer function in-place.
- *
- * @param out output buffer for filtered speech samples
- * @param in input buffer containing speech data (may be the same as out)
- * @param zero_coeffs z^-1 and z^-2 coefficients of the numerator
- * @param pole_coeffs z^-1 and z^-2 coefficients of the denominator
- * @param gain scale factor for final output
- * @param mem intermediate values used by filter (should be 0 initially)
- * @param n number of samples
- */
-void ff_acelp_apply_order_2_transfer_function(float *out, const float *in,
- const float zero_coeffs[2],
- const float pole_coeffs[2],
- float gain,
- float mem[2], int n);
-
-/**
- * Apply tilt compensation filter, 1 - tilt * z-1.
- *
- * @param mem pointer to the filter's state (one single float)
- * @param tilt tilt factor
- * @param samples array where the filter is applied
- * @param size the size of the samples array
- */
-void ff_tilt_compensation(float *mem, float tilt, float *samples, int size);
-
-
-#endif /* AVCODEC_ACELP_FILTERS_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/acelp_pitch_delay.c b/src/thirdparty/ffmpeg/libavcodec/acelp_pitch_delay.c
deleted file mode 100644
index af47463c8..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/acelp_pitch_delay.c
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * gain code, gain pitch and pitch delay decoding
- *
- * Copyright (c) 2008 Vladimir Voroshilov
- *
- * 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 "libavutil/float_dsp.h"
-#include "libavutil/libm.h"
-#include "libavutil/mathematics.h"
-#include "avcodec.h"
-#include "acelp_pitch_delay.h"
-#include "celp_math.h"
-
-int ff_acelp_decode_8bit_to_1st_delay3(int ac_index)
-{
- ac_index += 58;
- if(ac_index > 254)
- ac_index = 3 * ac_index - 510;
- return ac_index;
-}
-
-int ff_acelp_decode_4bit_to_2nd_delay3(
- int ac_index,
- int pitch_delay_min)
-{
- if(ac_index < 4)
- return 3 * (ac_index + pitch_delay_min);
- else if(ac_index < 12)
- return 3 * pitch_delay_min + ac_index + 6;
- else
- return 3 * (ac_index + pitch_delay_min) - 18;
-}
-
-int ff_acelp_decode_5_6_bit_to_2nd_delay3(
- int ac_index,
- int pitch_delay_min)
-{
- return 3 * pitch_delay_min + ac_index - 2;
-}
-
-int ff_acelp_decode_9bit_to_1st_delay6(int ac_index)
-{
- if(ac_index < 463)
- return ac_index + 105;
- else
- return 6 * (ac_index - 368);
-}
-int ff_acelp_decode_6bit_to_2nd_delay6(
- int ac_index,
- int pitch_delay_min)
-{
- return 6 * pitch_delay_min + ac_index - 3;
-}
-
-void ff_acelp_update_past_gain(
- int16_t* quant_energy,
- int gain_corr_factor,
- int log2_ma_pred_order,
- int erasure)
-{
- int i;
- int avg_gain=quant_energy[(1 << log2_ma_pred_order) - 1]; // (5.10)
-
- for(i=(1 << log2_ma_pred_order) - 1; i>0; i--)
- {
- avg_gain += quant_energy[i-1];
- quant_energy[i] = quant_energy[i-1];
- }
-
- if(erasure)
- quant_energy[0] = FFMAX(avg_gain >> log2_ma_pred_order, -10240) - 4096; // -10 and -4 in (5.10)
- else
- quant_energy[0] = (6165 * ((ff_log2_q15(gain_corr_factor) >> 2) - (13 << 13))) >> 13;
-}
-
-int16_t ff_acelp_decode_gain_code(
- DSPContext *dsp,
- int gain_corr_factor,
- const int16_t* fc_v,
- int mr_energy,
- const int16_t* quant_energy,
- const int16_t* ma_prediction_coeff,
- int subframe_size,
- int ma_pred_order)
-{
- int i;
-
- mr_energy <<= 10;
-
- for(i=0; i<ma_pred_order; i++)
- mr_energy += quant_energy[i] * ma_prediction_coeff[i];
-
-#ifdef G729_BITEXACT
- mr_energy += (((-6165LL * ff_log2(dsp->scalarproduct_int16(fc_v, fc_v, subframe_size, 0))) >> 3) & ~0x3ff);
-
- mr_energy = (5439 * (mr_energy >> 15)) >> 8; // (0.15) = (0.15) * (7.23)
-
- return bidir_sal(
- ((ff_exp2(mr_energy & 0x7fff) + 16) >> 5) * (gain_corr_factor >> 1),
- (mr_energy >> 15) - 25
- );
-#else
- mr_energy = gain_corr_factor * exp(M_LN10 / (20 << 23) * mr_energy) /
- sqrt(dsp->scalarproduct_int16(fc_v, fc_v, subframe_size));
- return mr_energy >> 12;
-#endif
-}
-
-float ff_amr_set_fixed_gain(float fixed_gain_factor, float fixed_mean_energy,
- float *prediction_error, float energy_mean,
- const float *pred_table)
-{
- // Equations 66-69:
- // ^g_c = ^gamma_gc * 100.05 (predicted dB + mean dB - dB of fixed vector)
- // Note 10^(0.05 * -10log(average x2)) = 1/sqrt((average x2)).
- float val = fixed_gain_factor *
- exp2f(M_LOG2_10 * 0.05 *
- (avpriv_scalarproduct_float_c(pred_table, prediction_error, 4) +
- energy_mean)) /
- sqrtf(fixed_mean_energy);
-
- // update quantified prediction error energy history
- memmove(&prediction_error[0], &prediction_error[1],
- 3 * sizeof(prediction_error[0]));
- prediction_error[3] = 20.0 * log10f(fixed_gain_factor);
-
- return val;
-}
-
-void ff_decode_pitch_lag(int *lag_int, int *lag_frac, int pitch_index,
- const int prev_lag_int, const int subframe,
- int third_as_first, int resolution)
-{
- /* Note n * 10923 >> 15 is floor(x/3) for 0 <= n <= 32767 */
- if (subframe == 0 || (subframe == 2 && third_as_first)) {
-
- if (pitch_index < 197)
- pitch_index += 59;
- else
- pitch_index = 3 * pitch_index - 335;
-
- } else {
- if (resolution == 4) {
- int search_range_min = av_clip(prev_lag_int - 5, PITCH_DELAY_MIN,
- PITCH_DELAY_MAX - 9);
-
- // decoding with 4-bit resolution
- if (pitch_index < 4) {
- // integer only precision for [search_range_min, search_range_min+3]
- pitch_index = 3 * (pitch_index + search_range_min) + 1;
- } else if (pitch_index < 12) {
- // 1/3 fractional precision for [search_range_min+3 1/3, search_range_min+5 2/3]
- pitch_index += 3 * search_range_min + 7;
- } else {
- // integer only precision for [search_range_min+6, search_range_min+9]
- pitch_index = 3 * (pitch_index + search_range_min - 6) + 1;
- }
- } else {
- // decoding with 5 or 6 bit resolution, 1/3 fractional precision
- pitch_index--;
-
- if (resolution == 5) {
- pitch_index += 3 * av_clip(prev_lag_int - 10, PITCH_DELAY_MIN,
- PITCH_DELAY_MAX - 19);
- } else
- pitch_index += 3 * av_clip(prev_lag_int - 5, PITCH_DELAY_MIN,
- PITCH_DELAY_MAX - 9);
- }
- }
- *lag_int = pitch_index * 10923 >> 15;
- *lag_frac = pitch_index - 3 * *lag_int - 1;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/acelp_pitch_delay.h b/src/thirdparty/ffmpeg/libavcodec/acelp_pitch_delay.h
deleted file mode 100644
index 395e77e9b..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/acelp_pitch_delay.h
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * gain code, gain pitch and pitch delay decoding
- *
- * Copyright (c) 2008 Vladimir Voroshilov
- *
- * 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_ACELP_PITCH_DELAY_H
-#define AVCODEC_ACELP_PITCH_DELAY_H
-
-#include <stdint.h>
-#include "dsputil.h"
-
-#define PITCH_DELAY_MIN 20
-#define PITCH_DELAY_MAX 143
-
-/**
- * @brief Decode pitch delay of the first subframe encoded by 8 bits with 1/3
- * resolution.
- * @param ac_index adaptive codebook index (8 bits)
- *
- * @return pitch delay in 1/3 units
- *
- * Pitch delay is coded:
- * with 1/3 resolution, 19 < pitch_delay < 85
- * integers only, 85 <= pitch_delay <= 143
- */
-int ff_acelp_decode_8bit_to_1st_delay3(int ac_index);
-
-/**
- * @brief Decode pitch delay of the second subframe encoded by 5 or 6 bits
- * with 1/3 precision.
- * @param ac_index adaptive codebook index (5 or 6 bits)
- * @param pitch_delay_min lower bound (integer) of pitch delay interval
- * for second subframe
- *
- * @return pitch delay in 1/3 units
- *
- * Pitch delay is coded:
- * with 1/3 resolution, -6 < pitch_delay - int(prev_pitch_delay) < 5
- *
- * @remark The routine is used in G.729 @@8k, AMR @@10.2k, AMR @@7.95k,
- * AMR @@7.4k for the second subframe.
- */
-int ff_acelp_decode_5_6_bit_to_2nd_delay3(
- int ac_index,
- int pitch_delay_min);
-
-/**
- * @brief Decode pitch delay with 1/3 precision.
- * @param ac_index adaptive codebook index (4 bits)
- * @param pitch_delay_min lower bound (integer) of pitch delay interval for
- * second subframe
- *
- * @return pitch delay in 1/3 units
- *
- * Pitch delay is coded:
- * integers only, -6 < pitch_delay - int(prev_pitch_delay) <= -2
- * with 1/3 resolution, -2 < pitch_delay - int(prev_pitch_delay) < 1
- * integers only, 1 <= pitch_delay - int(prev_pitch_delay) < 5
- *
- * @remark The routine is used in G.729 @@6.4k, AMR @@6.7k, AMR @@5.9k,
- * AMR @@5.15k, AMR @@4.75k for the second subframe.
- */
-int ff_acelp_decode_4bit_to_2nd_delay3(
- int ac_index,
- int pitch_delay_min);
-
-/**
- * @brief Decode pitch delay of the first subframe encoded by 9 bits
- * with 1/6 precision.
- * @param ac_index adaptive codebook index (9 bits)
- *
- * @return pitch delay in 1/6 units
- *
- * Pitch delay is coded:
- * with 1/6 resolution, 17 < pitch_delay < 95
- * integers only, 95 <= pitch_delay <= 143
- *
- * @remark The routine is used in AMR @@12.2k for the first and third subframes.
- */
-int ff_acelp_decode_9bit_to_1st_delay6(int ac_index);
-
-/**
- * @brief Decode pitch delay of the second subframe encoded by 6 bits
- * with 1/6 precision.
- * @param ac_index adaptive codebook index (6 bits)
- * @param pitch_delay_min lower bound (integer) of pitch delay interval for
- * second subframe
- *
- * @return pitch delay in 1/6 units
- *
- * Pitch delay is coded:
- * with 1/6 resolution, -6 < pitch_delay - int(prev_pitch_delay) < 5
- *
- * @remark The routine is used in AMR @@12.2k for the second and fourth subframes.
- */
-int ff_acelp_decode_6bit_to_2nd_delay6(
- int ac_index,
- int pitch_delay_min);
-
-/**
- * @brief Update past quantized energies
- * @param[in,out] quant_energy past quantized energies (5.10)
- * @param gain_corr_factor gain correction factor
- * @param log2_ma_pred_order log2() of MA prediction order
- * @param erasure frame erasure flag
- *
- * If frame erasure flag is not equal to zero, memory is updated with
- * averaged energy, attenuated by 4dB:
- * max(avg(quant_energy[i])-4, -14), i=0,ma_pred_order
- *
- * In normal mode memory is updated with
- * Er - Ep = 20 * log10(gain_corr_factor)
- *
- * @remark The routine is used in G.729 and AMR (all modes).
- */
-void ff_acelp_update_past_gain(
- int16_t* quant_energy,
- int gain_corr_factor,
- int log2_ma_pred_order,
- int erasure);
-
-/**
- * @brief Decode the adaptive codebook gain and add
- * correction (4.1.5 and 3.9.1 of G.729).
- * @param dsp initialized dsputil context
- * @param gain_corr_factor gain correction factor (2.13)
- * @param fc_v fixed-codebook vector (2.13)
- * @param mr_energy mean innovation energy and fixed-point correction (7.13)
- * @param[in,out] quant_energy past quantized energies (5.10)
- * @param subframe_size length of subframe
- *
- * @return quantized fixed-codebook gain (14.1)
- *
- * The routine implements equations 69, 66 and 71 of the G.729 specification (3.9.1)
- *
- * Em - mean innovation energy (dB, constant, depends on decoding algorithm)
- * Ep - mean-removed predicted energy (dB)
- * Er - mean-removed innovation energy (dB)
- * Ei - mean energy of the fixed-codebook contribution (dB)
- * N - subframe_size
- * M - MA (Moving Average) prediction order
- * gc - fixed-codebook gain
- * gc_p - predicted fixed-codebook gain
- *
- * Fixed codebook gain is computed using predicted gain gc_p and
- * correction factor gain_corr_factor as shown below:
- *
- * gc = gc_p * gain_corr_factor
- *
- * The predicted fixed codebook gain gc_p is found by predicting
- * the energy of the fixed-codebook contribution from the energy
- * of previous fixed-codebook contributions.
- *
- * mean = 1/N * sum(i,0,N){ fc_v[i] * fc_v[i] }
- *
- * Ei = 10log(mean)
- *
- * Er = 10log(1/N * gc^2 * mean) - Em = 20log(gc) + Ei - Em
- *
- * Replacing Er with Ep and gc with gc_p we will receive:
- *
- * Ep = 10log(1/N * gc_p^2 * mean) - Em = 20log(gc_p) + Ei - Em
- *
- * and from above:
- *
- * gc_p = 10^((Ep - Ei + Em) / 20)
- *
- * Ep is predicted using past energies and prediction coefficients:
- *
- * Ep = sum(i,0,M){ ma_prediction_coeff[i] * quant_energy[i] }
- *
- * gc_p in fixed-point arithmetic is calculated as following:
- *
- * mean = 1/N * sum(i,0,N){ (fc_v[i] / 2^13) * (fc_v[i] / 2^13) } =
- * = 1/N * sum(i,0,N) { fc_v[i] * fc_v[i] } / 2^26
- *
- * Ei = 10log(mean) = -10log(N) - 10log(2^26) +
- * + 10log(sum(i,0,N) { fc_v[i] * fc_v[i] })
- *
- * Ep - Ei + Em = Ep + Em + 10log(N) + 10log(2^26) -
- * - 10log(sum(i,0,N) { fc_v[i] * fc_v[i] }) =
- * = Ep + mr_energy - 10log(sum(i,0,N) { fc_v[i] * fc_v[i] })
- *
- * gc_p = 10 ^ ((Ep - Ei + Em) / 20) =
- * = 2 ^ (3.3219 * (Ep - Ei + Em) / 20) = 2 ^ (0.166 * (Ep - Ei + Em))
- *
- * where
- *
- * mr_energy = Em + 10log(N) + 10log(2^26)
- *
- * @remark The routine is used in G.729 and AMR (all modes).
- */
-int16_t ff_acelp_decode_gain_code(
- DSPContext *dsp,
- int gain_corr_factor,
- const int16_t* fc_v,
- int mr_energy,
- const int16_t* quant_energy,
- const int16_t* ma_prediction_coeff,
- int subframe_size,
- int max_pred_order);
-
-/**
- * Calculate fixed gain (part of section 6.1.3 of AMR spec)
- *
- * @param fixed_gain_factor gain correction factor
- * @param fixed_mean_energy mean decoded algebraic codebook vector energy
- * @param prediction_error vector of the quantified predictor errors of
- * the four previous subframes. It is updated by this function.
- * @param energy_mean desired mean innovation energy
- * @param pred_table table of four moving average coefficients
- */
-float ff_amr_set_fixed_gain(float fixed_gain_factor, float fixed_mean_energy,
- float *prediction_error, float energy_mean,
- const float *pred_table);
-
-
-/**
- * Decode the adaptive codebook index to the integer and fractional parts
- * of the pitch lag for one subframe at 1/3 fractional precision.
- *
- * The choice of pitch lag is described in 3GPP TS 26.090 section 5.6.1.
- *
- * @param lag_int integer part of pitch lag of the current subframe
- * @param lag_frac fractional part of pitch lag of the current subframe
- * @param pitch_index parsed adaptive codebook (pitch) index
- * @param prev_lag_int integer part of pitch lag for the previous subframe
- * @param subframe current subframe number
- * @param third_as_first treat the third frame the same way as the first
- */
-void ff_decode_pitch_lag(int *lag_int, int *lag_frac, int pitch_index,
- const int prev_lag_int, const int subframe,
- int third_as_first, int resolution);
-
-#endif /* AVCODEC_ACELP_PITCH_DELAY_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/acelp_vectors.c b/src/thirdparty/ffmpeg/libavcodec/acelp_vectors.c
deleted file mode 100644
index bb5bc6ca2..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/acelp_vectors.c
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * adaptive and fixed codebook vector operations for ACELP-based codecs
- *
- * Copyright (c) 2008 Vladimir Voroshilov
- *
- * 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 <inttypes.h>
-
-#include "libavutil/common.h"
-#include "libavutil/float_dsp.h"
-#include "avcodec.h"
-#include "acelp_vectors.h"
-
-const uint8_t ff_fc_2pulses_9bits_track1[16] =
-{
- 1, 3,
- 6, 8,
- 11, 13,
- 16, 18,
- 21, 23,
- 26, 28,
- 31, 33,
- 36, 38
-};
-const uint8_t ff_fc_2pulses_9bits_track1_gray[16] =
-{
- 1, 3,
- 8, 6,
- 18, 16,
- 11, 13,
- 38, 36,
- 31, 33,
- 21, 23,
- 28, 26,
-};
-
-const uint8_t ff_fc_2pulses_9bits_track2_gray[32] =
-{
- 0, 2,
- 5, 4,
- 12, 10,
- 7, 9,
- 25, 24,
- 20, 22,
- 14, 15,
- 19, 17,
- 36, 31,
- 21, 26,
- 1, 6,
- 16, 11,
- 27, 29,
- 32, 30,
- 39, 37,
- 34, 35,
-};
-
-const uint8_t ff_fc_4pulses_8bits_tracks_13[16] =
-{
- 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75,
-};
-
-const uint8_t ff_fc_4pulses_8bits_track_4[32] =
-{
- 3, 4,
- 8, 9,
- 13, 14,
- 18, 19,
- 23, 24,
- 28, 29,
- 33, 34,
- 38, 39,
- 43, 44,
- 48, 49,
- 53, 54,
- 58, 59,
- 63, 64,
- 68, 69,
- 73, 74,
- 78, 79,
-};
-
-const float ff_pow_0_7[10] = {
- 0.700000, 0.490000, 0.343000, 0.240100, 0.168070,
- 0.117649, 0.082354, 0.057648, 0.040354, 0.028248
-};
-
-const float ff_pow_0_75[10] = {
- 0.750000, 0.562500, 0.421875, 0.316406, 0.237305,
- 0.177979, 0.133484, 0.100113, 0.075085, 0.056314
-};
-
-const float ff_pow_0_55[10] = {
- 0.550000, 0.302500, 0.166375, 0.091506, 0.050328,
- 0.027681, 0.015224, 0.008373, 0.004605, 0.002533
-};
-
-const float ff_b60_sinc[61] = {
- 0.898529 , 0.865051 , 0.769257 , 0.624054 , 0.448639 , 0.265289 ,
- 0.0959167 , -0.0412598 , -0.134338 , -0.178986 , -0.178528 , -0.142609 ,
--0.0849304 , -0.0205078 , 0.0369568 , 0.0773926 , 0.0955200 , 0.0912781 ,
- 0.0689392 , 0.0357056 , 0. , -0.0305481 , -0.0504150 , -0.0570068 ,
--0.0508423 , -0.0350037 , -0.0141602 , 0.00665283, 0.0230713 , 0.0323486 ,
- 0.0335388 , 0.0275879 , 0.0167847 , 0.00411987, -0.00747681, -0.0156860 ,
--0.0193481 , -0.0183716 , -0.0137634 , -0.00704956, 0. , 0.00582886 ,
- 0.00939941, 0.0103760 , 0.00903320, 0.00604248, 0.00238037, -0.00109863 ,
--0.00366211, -0.00497437, -0.00503540, -0.00402832, -0.00241089, -0.000579834,
- 0.00103760, 0.00222778, 0.00277710, 0.00271606, 0.00213623, 0.00115967 ,
- 0.
-};
-
-void ff_acelp_fc_pulse_per_track(
- int16_t* fc_v,
- const uint8_t *tab1,
- const uint8_t *tab2,
- int pulse_indexes,
- int pulse_signs,
- int pulse_count,
- int bits)
-{
- int mask = (1 << bits) - 1;
- int i;
-
- for(i=0; i<pulse_count; i++)
- {
- fc_v[i + tab1[pulse_indexes & mask]] +=
- (pulse_signs & 1) ? 8191 : -8192; // +/-1 in (2.13)
-
- pulse_indexes >>= bits;
- pulse_signs >>= 1;
- }
-
- fc_v[tab2[pulse_indexes]] += (pulse_signs & 1) ? 8191 : -8192;
-}
-
-void ff_decode_10_pulses_35bits(const int16_t *fixed_index,
- AMRFixed *fixed_sparse,
- const uint8_t *gray_decode,
- int half_pulse_count, int bits)
-{
- int i;
- int mask = (1 << bits) - 1;
-
- fixed_sparse->no_repeat_mask = 0;
- fixed_sparse->n = 2 * half_pulse_count;
- for (i = 0; i < half_pulse_count; i++) {
- const int pos1 = gray_decode[fixed_index[2*i+1] & mask] + i;
- const int pos2 = gray_decode[fixed_index[2*i ] & mask] + i;
- const float sign = (fixed_index[2*i+1] & (1 << bits)) ? -1.0 : 1.0;
- fixed_sparse->x[2*i+1] = pos1;
- fixed_sparse->x[2*i ] = pos2;
- fixed_sparse->y[2*i+1] = sign;
- fixed_sparse->y[2*i ] = pos2 < pos1 ? -sign : sign;
- }
-}
-
-void ff_acelp_weighted_vector_sum(
- int16_t* out,
- const int16_t *in_a,
- const int16_t *in_b,
- int16_t weight_coeff_a,
- int16_t weight_coeff_b,
- int16_t rounder,
- int shift,
- int length)
-{
- int i;
-
- // Clipping required here; breaks OVERFLOW test.
- for(i=0; i<length; i++)
- out[i] = av_clip_int16((
- in_a[i] * weight_coeff_a +
- in_b[i] * weight_coeff_b +
- rounder) >> shift);
-}
-
-void ff_weighted_vector_sumf(float *out, const float *in_a, const float *in_b,
- float weight_coeff_a, float weight_coeff_b, int length)
-{
- int i;
-
- for(i=0; i<length; i++)
- out[i] = weight_coeff_a * in_a[i]
- + weight_coeff_b * in_b[i];
-}
-
-void ff_adaptive_gain_control(float *out, const float *in, float speech_energ,
- int size, float alpha, float *gain_mem)
-{
- int i;
- float postfilter_energ = avpriv_scalarproduct_float_c(in, in, size);
- float gain_scale_factor = 1.0;
- float mem = *gain_mem;
-
- if (postfilter_energ)
- gain_scale_factor = sqrt(speech_energ / postfilter_energ);
-
- gain_scale_factor *= 1.0 - alpha;
-
- for (i = 0; i < size; i++) {
- mem = alpha * mem + gain_scale_factor;
- out[i] = in[i] * mem;
- }
-
- *gain_mem = mem;
-}
-
-void ff_scale_vector_to_given_sum_of_squares(float *out, const float *in,
- float sum_of_squares, const int n)
-{
- int i;
- float scalefactor = avpriv_scalarproduct_float_c(in, in, n);
- if (scalefactor)
- scalefactor = sqrt(sum_of_squares / scalefactor);
- for (i = 0; i < n; i++)
- out[i] = in[i] * scalefactor;
-}
-
-void ff_set_fixed_vector(float *out, const AMRFixed *in, float scale, int size)
-{
- int i;
-
- for (i=0; i < in->n; i++) {
- int x = in->x[i], repeats = !((in->no_repeat_mask >> i) & 1);
- float y = in->y[i] * scale;
-
- if (in->pitch_lag > 0)
- do {
- out[x] += y;
- y *= in->pitch_fac;
- x += in->pitch_lag;
- } while (x < size && repeats);
- }
-}
-
-void ff_clear_fixed_vector(float *out, const AMRFixed *in, int size)
-{
- int i;
-
- for (i=0; i < in->n; i++) {
- int x = in->x[i], repeats = !((in->no_repeat_mask >> i) & 1);
-
- if (in->pitch_lag > 0)
- do {
- out[x] = 0.0;
- x += in->pitch_lag;
- } while (x < size && repeats);
- }
-}
-
-void ff_acelp_vectors_init(ACELPVContext *c)
-{
- c->weighted_vector_sumf = ff_weighted_vector_sumf;
-
- if(HAVE_MIPSFPU)
- ff_acelp_vectors_init_mips(c);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/acelp_vectors.h b/src/thirdparty/ffmpeg/libavcodec/acelp_vectors.h
deleted file mode 100644
index 41729e649..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/acelp_vectors.h
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * adaptive and fixed codebook vector operations for ACELP-based codecs
- *
- * Copyright (c) 2008 Vladimir Voroshilov
- *
- * 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_ACELP_VECTORS_H
-#define AVCODEC_ACELP_VECTORS_H
-
-#include <stdint.h>
-
-typedef struct ACELPVContext {
- /**
- * float implementation of weighted sum of two vectors.
- * @param[out] out result of addition
- * @param in_a first vector
- * @param in_b second vector
- * @param weight_coeff_a first vector weight coefficient
- * @param weight_coeff_a second vector weight coefficient
- * @param length vectors length (should be a multiple of two)
- *
- * @note It is safe to pass the same buffer for out and in_a or in_b.
- */
- void (*weighted_vector_sumf)(float *out, const float *in_a, const float *in_b,
- float weight_coeff_a, float weight_coeff_b,
- int length);
-
-}ACELPVContext;
-
-/**
- * Initialize ACELPVContext.
- */
-void ff_acelp_vectors_init(ACELPVContext *c);
-void ff_acelp_vectors_init_mips(ACELPVContext *c);
-
-/** Sparse representation for the algebraic codebook (fixed) vector */
-typedef struct AMRFixed {
- int n;
- int x[10];
- float y[10];
- int no_repeat_mask;
- int pitch_lag;
- float pitch_fac;
-} AMRFixed;
-
-/**
- * Track|Pulse| Positions
- * -------------------------------------------------------------------------
- * 1 | 0 | 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75
- * -------------------------------------------------------------------------
- * 2 | 1 | 1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76
- * -------------------------------------------------------------------------
- * 3 | 2 | 2, 7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57, 62, 67, 72, 77
- * -------------------------------------------------------------------------
- *
- * Table contains only first the pulse indexes.
- *
- * Used in G.729 @@8k, G.729 @@4.4k, AMR @@7.95k, AMR @@7.40k
- */
-extern const uint8_t ff_fc_4pulses_8bits_tracks_13[16];
-
-/**
- * Track|Pulse| Positions
- * -------------------------------------------------------------------------
- * 4 | 3 | 3, 8, 13, 18, 23, 28, 33, 38, 43, 48, 53, 58, 63, 68, 73, 78
- * | | 4, 9, 14, 19, 24, 29, 34, 39, 44, 49, 54, 59, 64, 69, 74, 79
- * -------------------------------------------------------------------------
- *
- * @remark Track in the table should be read top-to-bottom, left-to-right.
- *
- * Used in G.729 @@8k, G.729 @@4.4k, AMR @@7.95k, AMR @@7.40k
- */
-extern const uint8_t ff_fc_4pulses_8bits_track_4[32];
-
-/**
- * Track|Pulse| Positions
- * -----------------------------------------
- * 1 | 0 | 1, 6, 11, 16, 21, 26, 31, 36
- * | | 3, 8, 13, 18, 23, 28, 33, 38
- * -----------------------------------------
- *
- * @remark Track in the table should be read top-to-bottom, left-to-right.
- *
- * @note (EE) Reference G.729D code also uses gray decoding for each
- * pulse index before looking up the value in the table.
- *
- * Used in G.729 @@6.4k (with gray coding), AMR @@5.9k (without gray coding)
- */
-extern const uint8_t ff_fc_2pulses_9bits_track1[16];
-extern const uint8_t ff_fc_2pulses_9bits_track1_gray[16];
-
-/**
- * Track|Pulse| Positions
- * -----------------------------------------
- * 2 | 1 | 0, 7, 14, 20, 27, 34, 1, 21
- * | | 2, 9, 15, 22, 29, 35, 6, 26
- * | | 4,10, 17, 24, 30, 37, 11, 31
- * | | 5,12, 19, 25, 32, 39, 16, 36
- * -----------------------------------------
- *
- * @remark Track in the table should be read top-to-bottom, left-to-right.
- *
- * @note (EE.1) This table (from the reference code) does not comply with
- * the specification.
- * The specification contains the following table:
- *
- * Track|Pulse| Positions
- * -----------------------------------------
- * 2 | 1 | 0, 5, 10, 15, 20, 25, 30, 35
- * | | 1, 6, 11, 16, 21, 26, 31, 36
- * | | 2, 7, 12, 17, 22, 27, 32, 37
- * | | 4, 9, 14, 19, 24, 29, 34, 39
- *
- * -----------------------------------------
- *
- * @note (EE.2) Reference G.729D code also uses gray decoding for each
- * pulse index before looking up the value in the table.
- *
- * Used in G.729 @@6.4k (with gray coding)
- */
-extern const uint8_t ff_fc_2pulses_9bits_track2_gray[32];
-
-/**
- * b60 hamming windowed sinc function coefficients
- */
-extern const float ff_b60_sinc[61];
-
-/**
- * Table of pow(0.7,n)
- */
-extern const float ff_pow_0_7[10];
-
-/**
- * Table of pow(0.75,n)
- */
-extern const float ff_pow_0_75[10];
-
-/**
- * Table of pow(0.55,n)
- */
-extern const float ff_pow_0_55[10];
-
-/**
- * Decode fixed-codebook vector (3.8 and D.5.8 of G.729, 5.7.1 of AMR).
- * @param[out] fc_v decoded fixed codebook vector (2.13)
- * @param tab1 table used for first pulse_count pulses
- * @param tab2 table used for last pulse
- * @param pulse_indexes fixed codebook indexes
- * @param pulse_signs signs of the excitation pulses (0 bit value
- * means negative sign)
- * @param bits number of bits per one pulse index
- * @param pulse_count number of pulses decoded using first table
- * @param bits length of one pulse index in bits
- *
- * Used in G.729 @@8k, G.729 @@4.4k, G.729 @@6.4k, AMR @@7.95k, AMR @@7.40k
- */
-void ff_acelp_fc_pulse_per_track(int16_t* fc_v,
- const uint8_t *tab1,
- const uint8_t *tab2,
- int pulse_indexes,
- int pulse_signs,
- int pulse_count,
- int bits);
-
-/**
- * Decode the algebraic codebook index to pulse positions and signs and
- * construct the algebraic codebook vector for MODE_12k2.
- *
- * @note: The positions and signs are explicitly coded in MODE_12k2.
- *
- * @param fixed_index positions of the ten pulses
- * @param fixed_sparse pointer to the algebraic codebook vector
- * @param gray_decode gray decoding table
- * @param half_pulse_count number of couples of pulses
- * @param bits length of one pulse index in bits
- */
-void ff_decode_10_pulses_35bits(const int16_t *fixed_index,
- AMRFixed *fixed_sparse,
- const uint8_t *gray_decode,
- int half_pulse_count, int bits);
-
-
-/**
- * weighted sum of two vectors with rounding.
- * @param[out] out result of addition
- * @param in_a first vector
- * @param in_b second vector
- * @param weight_coeff_a first vector weight coefficient
- * @param weight_coeff_a second vector weight coefficient
- * @param rounder this value will be added to the sum of the two vectors
- * @param shift result will be shifted to right by this value
- * @param length vectors length
- *
- * @note It is safe to pass the same buffer for out and in_a or in_b.
- *
- * out[i] = (in_a[i]*weight_a + in_b[i]*weight_b + rounder) >> shift
- */
-void ff_acelp_weighted_vector_sum(int16_t* out,
- const int16_t *in_a,
- const int16_t *in_b,
- int16_t weight_coeff_a,
- int16_t weight_coeff_b,
- int16_t rounder,
- int shift,
- int length);
-
-/**
- * float implementation of weighted sum of two vectors.
- * @param[out] out result of addition
- * @param in_a first vector
- * @param in_b second vector
- * @param weight_coeff_a first vector weight coefficient
- * @param weight_coeff_a second vector weight coefficient
- * @param length vectors length
- *
- * @note It is safe to pass the same buffer for out and in_a or in_b.
- */
-void ff_weighted_vector_sumf(float *out, const float *in_a, const float *in_b,
- float weight_coeff_a, float weight_coeff_b,
- int length);
-
-/**
- * Adaptive gain control (as used in AMR postfiltering)
- *
- * @param out output buffer for filtered speech data
- * @param in the input speech buffer (may be the same as out)
- * @param speech_energ input energy
- * @param size the input buffer size
- * @param alpha exponential filter factor
- * @param gain_mem a pointer to the filter memory (single float of size)
- */
-void ff_adaptive_gain_control(float *out, const float *in, float speech_energ,
- int size, float alpha, float *gain_mem);
-
-/**
- * Set the sum of squares of a signal by scaling
- *
- * @param out output samples
- * @param in input samples
- * @param sum_of_squares new sum of squares
- * @param n number of samples
- *
- * @note If the input is zero (or its energy underflows), the output is zero.
- * This is the behavior of AGC in the AMR reference decoder. The QCELP
- * reference decoder seems to have undefined behavior.
- *
- * TIA/EIA/IS-733 2.4.8.3-2/3/4/5, 2.4.8.6
- * 3GPP TS 26.090 6.1 (6)
- */
-void ff_scale_vector_to_given_sum_of_squares(float *out, const float *in,
- float sum_of_squares, const int n);
-
-/**
- * Add fixed vector to an array from a sparse representation
- *
- * @param out fixed vector with pitch sharpening
- * @param in sparse fixed vector
- * @param scale number to multiply the fixed vector by
- * @param size the output vector size
- */
-void ff_set_fixed_vector(float *out, const AMRFixed *in, float scale, int size);
-
-/**
- * Clear array values set by set_fixed_vector
- *
- * @param out fixed vector to be cleared
- * @param in sparse fixed vector
- * @param size the output vector size
- */
-void ff_clear_fixed_vector(float *out, const AMRFixed *in, int size);
-
-#endif /* AVCODEC_ACELP_VECTORS_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/adpcm.c b/src/thirdparty/ffmpeg/libavcodec/adpcm.c
deleted file mode 100644
index c487bf65c..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/adpcm.c
+++ /dev/null
@@ -1,1434 +0,0 @@
-/*
- * Copyright (c) 2001-2003 The ffmpeg Project
- *
- * 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 "get_bits.h"
-#include "put_bits.h"
-#include "bytestream.h"
-#include "adpcm.h"
-#include "adpcm_data.h"
-#include "internal.h"
-
-/**
- * @file
- * ADPCM decoders
- * First version by Francois Revol (revol@free.fr)
- * Fringe ADPCM codecs (e.g., DK3, DK4, Westwood)
- * by Mike Melanson (melanson@pcisys.net)
- * CD-ROM XA ADPCM codec by BERO
- * EA ADPCM decoder by Robin Kay (komadori@myrealbox.com)
- * EA ADPCM R1/R2/R3 decoder by Peter Ross (pross@xvid.org)
- * EA IMA EACS decoder by Peter Ross (pross@xvid.org)
- * EA IMA SEAD decoder by Peter Ross (pross@xvid.org)
- * EA ADPCM XAS decoder by Peter Ross (pross@xvid.org)
- * MAXIS EA ADPCM decoder by Robert Marston (rmarston@gmail.com)
- * THP ADPCM decoder by Marco Gerards (mgerards@xs4all.nl)
- *
- * Features and limitations:
- *
- * Reference documents:
- * http://wiki.multimedia.cx/index.php?title=Category:ADPCM_Audio_Codecs
- * http://www.pcisys.net/~melanson/codecs/simpleaudio.html [dead]
- * http://www.geocities.com/SiliconValley/8682/aud3.txt [dead]
- * http://openquicktime.sourceforge.net/
- * XAnim sources (xa_codec.c) http://xanim.polter.net/
- * http://www.cs.ucla.edu/~leec/mediabench/applications.html [dead]
- * SoX source code http://sox.sourceforge.net/
- *
- * CD-ROM XA:
- * http://ku-www.ss.titech.ac.jp/~yatsushi/xaadpcm.html [dead]
- * vagpack & depack http://homepages.compuserve.de/bITmASTER32/psx-index.html [dead]
- * readstr http://www.geocities.co.jp/Playtown/2004/
- */
-
-/* These are for CD-ROM XA ADPCM */
-static const int xa_adpcm_table[5][2] = {
- { 0, 0 },
- { 60, 0 },
- { 115, -52 },
- { 98, -55 },
- { 122, -60 }
-};
-
-static const int ea_adpcm_table[] = {
- 0, 240, 460, 392,
- 0, 0, -208, -220,
- 0, 1, 3, 4,
- 7, 8, 10, 11,
- 0, -1, -3, -4
-};
-
-// padded to zero where table size is less then 16
-static const int swf_index_tables[4][16] = {
- /*2*/ { -1, 2 },
- /*3*/ { -1, -1, 2, 4 },
- /*4*/ { -1, -1, -1, -1, 2, 4, 6, 8 },
- /*5*/ { -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 4, 6, 8, 10, 13, 16 }
-};
-
-/* end of tables */
-
-typedef struct ADPCMDecodeContext {
- ADPCMChannelStatus status[6];
- int vqa_version; /**< VQA version. Used for ADPCM_IMA_WS */
-} ADPCMDecodeContext;
-
-static av_cold int adpcm_decode_init(AVCodecContext * avctx)
-{
- ADPCMDecodeContext *c = avctx->priv_data;
- unsigned int min_channels = 1;
- unsigned int max_channels = 2;
-
- switch(avctx->codec->id) {
- case AV_CODEC_ID_ADPCM_EA:
- min_channels = 2;
- break;
- case AV_CODEC_ID_ADPCM_AFC:
- case AV_CODEC_ID_ADPCM_EA_R1:
- case AV_CODEC_ID_ADPCM_EA_R2:
- case AV_CODEC_ID_ADPCM_EA_R3:
- case AV_CODEC_ID_ADPCM_EA_XAS:
- case AV_CODEC_ID_ADPCM_THP:
- max_channels = 6;
- break;
- }
- if (avctx->channels < min_channels || avctx->channels > max_channels) {
- av_log(avctx, AV_LOG_ERROR, "Invalid number of channels\n");
- return AVERROR(EINVAL);
- }
-
- switch(avctx->codec->id) {
- case AV_CODEC_ID_ADPCM_CT:
- c->status[0].step = c->status[1].step = 511;
- break;
- case AV_CODEC_ID_ADPCM_IMA_WAV:
- if (avctx->bits_per_coded_sample != 4) {
- av_log(avctx, AV_LOG_ERROR, "Only 4-bit ADPCM IMA WAV files are supported\n");
- return -1;
- }
- break;
- case AV_CODEC_ID_ADPCM_IMA_APC:
- if (avctx->extradata && avctx->extradata_size >= 8) {
- c->status[0].predictor = AV_RL32(avctx->extradata);
- c->status[1].predictor = AV_RL32(avctx->extradata + 4);
- }
- break;
- case AV_CODEC_ID_ADPCM_IMA_WS:
- if (avctx->extradata && avctx->extradata_size >= 2)
- c->vqa_version = AV_RL16(avctx->extradata);
- break;
- default:
- break;
- }
-
- switch(avctx->codec->id) {
- case AV_CODEC_ID_ADPCM_IMA_QT:
- case AV_CODEC_ID_ADPCM_IMA_WAV:
- case AV_CODEC_ID_ADPCM_4XM:
- case AV_CODEC_ID_ADPCM_XA:
- case AV_CODEC_ID_ADPCM_EA_R1:
- case AV_CODEC_ID_ADPCM_EA_R2:
- case AV_CODEC_ID_ADPCM_EA_R3:
- case AV_CODEC_ID_ADPCM_EA_XAS:
- case AV_CODEC_ID_ADPCM_THP:
- case AV_CODEC_ID_ADPCM_AFC:
- avctx->sample_fmt = AV_SAMPLE_FMT_S16P;
- break;
- case AV_CODEC_ID_ADPCM_IMA_WS:
- avctx->sample_fmt = c->vqa_version == 3 ? AV_SAMPLE_FMT_S16P :
- AV_SAMPLE_FMT_S16;
- break;
- default:
- avctx->sample_fmt = AV_SAMPLE_FMT_S16;
- }
-
- return 0;
-}
-
-static inline short adpcm_ima_expand_nibble(ADPCMChannelStatus *c, char nibble, int shift)
-{
- int step_index;
- int predictor;
- int sign, delta, diff, step;
-
- step = ff_adpcm_step_table[c->step_index];
- step_index = c->step_index + ff_adpcm_index_table[(unsigned)nibble];
- step_index = av_clip(step_index, 0, 88);
-
- sign = nibble & 8;
- delta = nibble & 7;
- /* perform direct multiplication instead of series of jumps proposed by
- * the reference ADPCM implementation since modern CPUs can do the mults
- * quickly enough */
- diff = ((2 * delta + 1) * step) >> shift;
- predictor = c->predictor;
- if (sign) predictor -= diff;
- else predictor += diff;
-
- c->predictor = av_clip_int16(predictor);
- c->step_index = step_index;
-
- return (short)c->predictor;
-}
-
-static inline int adpcm_ima_qt_expand_nibble(ADPCMChannelStatus *c, int nibble, int shift)
-{
- int step_index;
- int predictor;
- int diff, step;
-
- step = ff_adpcm_step_table[c->step_index];
- step_index = c->step_index + ff_adpcm_index_table[nibble];
- step_index = av_clip(step_index, 0, 88);
-
- diff = step >> 3;
- if (nibble & 4) diff += step;
- if (nibble & 2) diff += step >> 1;
- if (nibble & 1) diff += step >> 2;
-
- if (nibble & 8)
- predictor = c->predictor - diff;
- else
- predictor = c->predictor + diff;
-
- c->predictor = av_clip_int16(predictor);
- c->step_index = step_index;
-
- return c->predictor;
-}
-
-static inline short adpcm_ms_expand_nibble(ADPCMChannelStatus *c, int nibble)
-{
- int predictor;
-
- predictor = (((c->sample1) * (c->coeff1)) + ((c->sample2) * (c->coeff2))) / 64;
- predictor += ((nibble & 0x08)?(nibble - 0x10):(nibble)) * c->idelta;
-
- c->sample2 = c->sample1;
- c->sample1 = av_clip_int16(predictor);
- c->idelta = (ff_adpcm_AdaptationTable[(int)nibble] * c->idelta) >> 8;
- if (c->idelta < 16) c->idelta = 16;
-
- return c->sample1;
-}
-
-static inline short adpcm_ima_oki_expand_nibble(ADPCMChannelStatus *c, int nibble)
-{
- int step_index, predictor, sign, delta, diff, step;
-
- step = ff_adpcm_oki_step_table[c->step_index];
- step_index = c->step_index + ff_adpcm_index_table[(unsigned)nibble];
- step_index = av_clip(step_index, 0, 48);
-
- sign = nibble & 8;
- delta = nibble & 7;
- diff = ((2 * delta + 1) * step) >> 3;
- predictor = c->predictor;
- if (sign) predictor -= diff;
- else predictor += diff;
-
- c->predictor = av_clip(predictor, -2048, 2047);
- c->step_index = step_index;
-
- return c->predictor << 4;
-}
-
-static inline short adpcm_ct_expand_nibble(ADPCMChannelStatus *c, char nibble)
-{
- int sign, delta, diff;
- int new_step;
-
- sign = nibble & 8;
- delta = nibble & 7;
- /* perform direct multiplication instead of series of jumps proposed by
- * the reference ADPCM implementation since modern CPUs can do the mults
- * quickly enough */
- diff = ((2 * delta + 1) * c->step) >> 3;
- /* predictor update is not so trivial: predictor is multiplied on 254/256 before updating */
- c->predictor = ((c->predictor * 254) >> 8) + (sign ? -diff : diff);
- c->predictor = av_clip_int16(c->predictor);
- /* calculate new step and clamp it to range 511..32767 */
- new_step = (ff_adpcm_AdaptationTable[nibble & 7] * c->step) >> 8;
- c->step = av_clip(new_step, 511, 32767);
-
- return (short)c->predictor;
-}
-
-static inline short adpcm_sbpro_expand_nibble(ADPCMChannelStatus *c, char nibble, int size, int shift)
-{
- int sign, delta, diff;
-
- sign = nibble & (1<<(size-1));
- delta = nibble & ((1<<(size-1))-1);
- diff = delta << (7 + c->step + shift);
-
- /* clamp result */
- c->predictor = av_clip(c->predictor + (sign ? -diff : diff), -16384,16256);
-
- /* calculate new step */
- if (delta >= (2*size - 3) && c->step < 3)
- c->step++;
- else if (delta == 0 && c->step > 0)
- c->step--;
-
- return (short) c->predictor;
-}
-
-static inline short adpcm_yamaha_expand_nibble(ADPCMChannelStatus *c, unsigned char nibble)
-{
- if(!c->step) {
- c->predictor = 0;
- c->step = 127;
- }
-
- c->predictor += (c->step * ff_adpcm_yamaha_difflookup[nibble]) / 8;
- c->predictor = av_clip_int16(c->predictor);
- c->step = (c->step * ff_adpcm_yamaha_indexscale[nibble]) >> 8;
- c->step = av_clip(c->step, 127, 24567);
- return c->predictor;
-}
-
-static int xa_decode(AVCodecContext *avctx, int16_t *out0, int16_t *out1,
- const uint8_t *in, ADPCMChannelStatus *left,
- ADPCMChannelStatus *right, int channels, int sample_offset)
-{
- int i, j;
- int shift,filter,f0,f1;
- int s_1,s_2;
- int d,s,t;
-
- out0 += sample_offset;
- if (channels == 1)
- out1 = out0 + 28;
- else
- out1 += sample_offset;
-
- for(i=0;i<4;i++) {
- shift = 12 - (in[4+i*2] & 15);
- filter = in[4+i*2] >> 4;
- if (filter >= FF_ARRAY_ELEMS(xa_adpcm_table)) {
- av_log_ask_for_sample(avctx, "unknown XA-ADPCM filter %d\n", filter);
- filter=0;
- }
- f0 = xa_adpcm_table[filter][0];
- f1 = xa_adpcm_table[filter][1];
-
- s_1 = left->sample1;
- s_2 = left->sample2;
-
- for(j=0;j<28;j++) {
- d = in[16+i+j*4];
-
- t = sign_extend(d, 4);
- s = ( t<<shift ) + ((s_1*f0 + s_2*f1+32)>>6);
- s_2 = s_1;
- s_1 = av_clip_int16(s);
- out0[j] = s_1;
- }
-
- if (channels == 2) {
- left->sample1 = s_1;
- left->sample2 = s_2;
- s_1 = right->sample1;
- s_2 = right->sample2;
- }
-
- shift = 12 - (in[5+i*2] & 15);
- filter = in[5+i*2] >> 4;
- if (filter >= FF_ARRAY_ELEMS(xa_adpcm_table)) {
- av_log_ask_for_sample(avctx, "unknown XA-ADPCM filter %d\n", filter);
- filter=0;
- }
-
- f0 = xa_adpcm_table[filter][0];
- f1 = xa_adpcm_table[filter][1];
-
- for(j=0;j<28;j++) {
- d = in[16+i+j*4];
-
- t = sign_extend(d >> 4, 4);
- s = ( t<<shift ) + ((s_1*f0 + s_2*f1+32)>>6);
- s_2 = s_1;
- s_1 = av_clip_int16(s);
- out1[j] = s_1;
- }
-
- if (channels == 2) {
- right->sample1 = s_1;
- right->sample2 = s_2;
- } else {
- left->sample1 = s_1;
- left->sample2 = s_2;
- }
-
- out0 += 28 * (3 - channels);
- out1 += 28 * (3 - channels);
- }
-
- return 0;
-}
-
-static void adpcm_swf_decode(AVCodecContext *avctx, const uint8_t *buf, int buf_size, int16_t *samples)
-{
- ADPCMDecodeContext *c = avctx->priv_data;
- GetBitContext gb;
- const int *table;
- int k0, signmask, nb_bits, count;
- int size = buf_size*8;
- int i;
-
- init_get_bits(&gb, buf, size);
-
- //read bits & initial values
- nb_bits = get_bits(&gb, 2)+2;
- table = swf_index_tables[nb_bits-2];
- k0 = 1 << (nb_bits-2);
- signmask = 1 << (nb_bits-1);
-
- while (get_bits_count(&gb) <= size - 22*avctx->channels) {
- for (i = 0; i < avctx->channels; i++) {
- *samples++ = c->status[i].predictor = get_sbits(&gb, 16);
- c->status[i].step_index = get_bits(&gb, 6);
- }
-
- for (count = 0; get_bits_count(&gb) <= size - nb_bits*avctx->channels && count < 4095; count++) {
- int i;
-
- for (i = 0; i < avctx->channels; i++) {
- // similar to IMA adpcm
- int delta = get_bits(&gb, nb_bits);
- int step = ff_adpcm_step_table[c->status[i].step_index];
- long vpdiff = 0; // vpdiff = (delta+0.5)*step/4
- int k = k0;
-
- do {
- if (delta & k)
- vpdiff += step;
- step >>= 1;
- k >>= 1;
- } while(k);
- vpdiff += step;
-
- if (delta & signmask)
- c->status[i].predictor -= vpdiff;
- else
- c->status[i].predictor += vpdiff;
-
- c->status[i].step_index += table[delta & (~signmask)];
-
- c->status[i].step_index = av_clip(c->status[i].step_index, 0, 88);
- c->status[i].predictor = av_clip_int16(c->status[i].predictor);
-
- *samples++ = c->status[i].predictor;
- }
- }
- }
-}
-
-/**
- * Get the number of samples that will be decoded from the packet.
- * In one case, this is actually the maximum number of samples possible to
- * decode with the given buf_size.
- *
- * @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.
- */
-static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
- int buf_size, int *coded_samples)
-{
- ADPCMDecodeContext *s = avctx->priv_data;
- int nb_samples = 0;
- int ch = avctx->channels;
- int has_coded_samples = 0;
- int header_size;
-
- *coded_samples = 0;
-
- if(ch <= 0)
- return 0;
-
- switch (avctx->codec->id) {
- /* constant, only check buf_size */
- case AV_CODEC_ID_ADPCM_EA_XAS:
- if (buf_size < 76 * ch)
- return 0;
- nb_samples = 128;
- break;
- case AV_CODEC_ID_ADPCM_IMA_QT:
- if (buf_size < 34 * ch)
- return 0;
- nb_samples = 64;
- break;
- /* simple 4-bit adpcm */
- case AV_CODEC_ID_ADPCM_CT:
- case AV_CODEC_ID_ADPCM_IMA_APC:
- case AV_CODEC_ID_ADPCM_IMA_EA_SEAD:
- case AV_CODEC_ID_ADPCM_IMA_OKI:
- case AV_CODEC_ID_ADPCM_IMA_WS:
- case AV_CODEC_ID_ADPCM_YAMAHA:
- nb_samples = buf_size * 2 / ch;
- break;
- }
- if (nb_samples)
- return nb_samples;
-
- /* simple 4-bit adpcm, with header */
- header_size = 0;
- switch (avctx->codec->id) {
- case AV_CODEC_ID_ADPCM_4XM:
- case AV_CODEC_ID_ADPCM_IMA_ISS: header_size = 4 * ch; break;
- case AV_CODEC_ID_ADPCM_IMA_AMV: header_size = 8; break;
- case AV_CODEC_ID_ADPCM_IMA_SMJPEG: header_size = 4 * ch; break;
- }
- if (header_size > 0)
- return (buf_size - header_size) * 2 / ch;
-
- /* more complex formats */
- switch (avctx->codec->id) {
- case AV_CODEC_ID_ADPCM_EA:
- has_coded_samples = 1;
- *coded_samples = bytestream2_get_le32(gb);
- *coded_samples -= *coded_samples % 28;
- nb_samples = (buf_size - 12) / 30 * 28;
- break;
- case AV_CODEC_ID_ADPCM_IMA_EA_EACS:
- has_coded_samples = 1;
- *coded_samples = bytestream2_get_le32(gb);
- nb_samples = (buf_size - (4 + 8 * ch)) * 2 / ch;
- break;
- case AV_CODEC_ID_ADPCM_EA_MAXIS_XA:
- nb_samples = (buf_size - ch) / ch * 2;
- break;
- case AV_CODEC_ID_ADPCM_EA_R1:
- case AV_CODEC_ID_ADPCM_EA_R2:
- case AV_CODEC_ID_ADPCM_EA_R3:
- /* maximum number of samples */
- /* has internal offsets and a per-frame switch to signal raw 16-bit */
- has_coded_samples = 1;
- switch (avctx->codec->id) {
- case AV_CODEC_ID_ADPCM_EA_R1:
- header_size = 4 + 9 * ch;
- *coded_samples = bytestream2_get_le32(gb);
- break;
- case AV_CODEC_ID_ADPCM_EA_R2:
- header_size = 4 + 5 * ch;
- *coded_samples = bytestream2_get_le32(gb);
- break;
- case AV_CODEC_ID_ADPCM_EA_R3:
- header_size = 4 + 5 * ch;
- *coded_samples = bytestream2_get_be32(gb);
- break;
- }
- *coded_samples -= *coded_samples % 28;
- nb_samples = (buf_size - header_size) * 2 / ch;
- nb_samples -= nb_samples % 28;
- break;
- case AV_CODEC_ID_ADPCM_IMA_DK3:
- if (avctx->block_align > 0)
- buf_size = FFMIN(buf_size, avctx->block_align);
- nb_samples = ((buf_size - 16) * 2 / 3 * 4) / ch;
- break;
- case AV_CODEC_ID_ADPCM_IMA_DK4:
- if (avctx->block_align > 0)
- buf_size = FFMIN(buf_size, avctx->block_align);
- nb_samples = 1 + (buf_size - 4 * ch) * 2 / ch;
- break;
- case AV_CODEC_ID_ADPCM_IMA_WAV:
- if (avctx->block_align > 0)
- buf_size = FFMIN(buf_size, avctx->block_align);
- nb_samples = 1 + (buf_size - 4 * ch) / (4 * ch) * 8;
- break;
- case AV_CODEC_ID_ADPCM_MS:
- if (avctx->block_align > 0)
- buf_size = FFMIN(buf_size, avctx->block_align);
- nb_samples = 2 + (buf_size - 7 * ch) * 2 / ch;
- break;
- case AV_CODEC_ID_ADPCM_SBPRO_2:
- case AV_CODEC_ID_ADPCM_SBPRO_3:
- case AV_CODEC_ID_ADPCM_SBPRO_4:
- {
- int samples_per_byte;
- switch (avctx->codec->id) {
- case AV_CODEC_ID_ADPCM_SBPRO_2: samples_per_byte = 4; break;
- case AV_CODEC_ID_ADPCM_SBPRO_3: samples_per_byte = 3; break;
- case AV_CODEC_ID_ADPCM_SBPRO_4: samples_per_byte = 2; break;
- }
- if (!s->status[0].step_index) {
- nb_samples++;
- buf_size -= ch;
- }
- nb_samples += buf_size * samples_per_byte / ch;
- break;
- }
- case AV_CODEC_ID_ADPCM_SWF:
- {
- int buf_bits = buf_size * 8 - 2;
- int nbits = (bytestream2_get_byte(gb) >> 6) + 2;
- int block_hdr_size = 22 * ch;
- int block_size = block_hdr_size + nbits * ch * 4095;
- int nblocks = buf_bits / block_size;
- int bits_left = buf_bits - nblocks * block_size;
- nb_samples = nblocks * 4096;
- if (bits_left >= block_hdr_size)
- nb_samples += 1 + (bits_left - block_hdr_size) / (nbits * ch);
- break;
- }
- case AV_CODEC_ID_ADPCM_THP:
- has_coded_samples = 1;
- bytestream2_skip(gb, 4); // channel size
- *coded_samples = bytestream2_get_be32(gb);
- *coded_samples -= *coded_samples % 14;
- nb_samples = (buf_size - (8 + 36 * ch)) / (8 * ch) * 14;
- break;
- case AV_CODEC_ID_ADPCM_AFC:
- nb_samples = buf_size / (9 * ch) * 16;
- break;
- case AV_CODEC_ID_ADPCM_XA:
- nb_samples = (buf_size / 128) * 224 / ch;
- break;
- }
-
- /* validate coded sample count */
- if (has_coded_samples && (*coded_samples <= 0 || *coded_samples > nb_samples))
- return AVERROR_INVALIDDATA;
-
- return nb_samples;
-}
-
-static int adpcm_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;
- ADPCMDecodeContext *c = avctx->priv_data;
- ADPCMChannelStatus *cs;
- int n, m, channel, i;
- short *samples;
- int16_t **samples_p;
- int st; /* stereo */
- int count1, count2;
- int nb_samples, coded_samples, ret;
- GetByteContext gb;
-
- bytestream2_init(&gb, buf, buf_size);
- nb_samples = get_nb_samples(avctx, &gb, buf_size, &coded_samples);
- if (nb_samples <= 0) {
- av_log(avctx, AV_LOG_ERROR, "invalid number of samples in packet\n");
- return AVERROR_INVALIDDATA;
- }
-
- /* get output buffer */
- frame->nb_samples = nb_samples;
- if ((ret = ff_get_buffer(avctx, frame)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return ret;
- }
- samples = (short *)frame->data[0];
- samples_p = (int16_t **)frame->extended_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)
- av_log(avctx, AV_LOG_WARNING, "mismatch in coded sample count\n");
- frame->nb_samples = nb_samples = coded_samples;
- }
-
- st = avctx->channels == 2 ? 1 : 0;
-
- switch(avctx->codec->id) {
- case AV_CODEC_ID_ADPCM_IMA_QT:
- /* In QuickTime, IMA is encoded by chunks of 34 bytes (=64 samples).
- Channel data is interleaved per-chunk. */
- for (channel = 0; channel < avctx->channels; channel++) {
- int predictor;
- int step_index;
- cs = &(c->status[channel]);
- /* (pppppp) (piiiiiii) */
-
- /* Bits 15-7 are the _top_ 9 bits of the 16-bit initial predictor value */
- predictor = sign_extend(bytestream2_get_be16u(&gb), 16);
- step_index = predictor & 0x7F;
- predictor &= ~0x7F;
-
- if (cs->step_index == step_index) {
- int diff = predictor - cs->predictor;
- if (diff < 0)
- diff = - diff;
- if (diff > 0x7f)
- goto update;
- } else {
- update:
- cs->step_index = step_index;
- cs->predictor = predictor;
- }
-
- if (cs->step_index > 88u){
- av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
- channel, cs->step_index);
- return AVERROR_INVALIDDATA;
- }
-
- samples = samples_p[channel];
-
- for (m = 0; m < 64; m += 2) {
- int byte = bytestream2_get_byteu(&gb);
- samples[m ] = adpcm_ima_qt_expand_nibble(cs, byte & 0x0F, 3);
- samples[m + 1] = adpcm_ima_qt_expand_nibble(cs, byte >> 4 , 3);
- }
- }
- break;
- case AV_CODEC_ID_ADPCM_IMA_WAV:
- for(i=0; i<avctx->channels; i++){
- cs = &(c->status[i]);
- cs->predictor = samples_p[i][0] = sign_extend(bytestream2_get_le16u(&gb), 16);
-
- cs->step_index = sign_extend(bytestream2_get_le16u(&gb), 16);
- if (cs->step_index > 88u){
- av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
- i, cs->step_index);
- return AVERROR_INVALIDDATA;
- }
- }
-
- for (n = 0; n < (nb_samples - 1) / 8; n++) {
- for (i = 0; i < avctx->channels; i++) {
- cs = &c->status[i];
- samples = &samples_p[i][1 + n * 8];
- for (m = 0; m < 8; m += 2) {
- int v = bytestream2_get_byteu(&gb);
- samples[m ] = adpcm_ima_expand_nibble(cs, v & 0x0F, 3);
- samples[m + 1] = adpcm_ima_expand_nibble(cs, v >> 4 , 3);
- }
- }
- }
- break;
- case AV_CODEC_ID_ADPCM_4XM:
- for (i = 0; i < avctx->channels; i++)
- c->status[i].predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
-
- for (i = 0; i < avctx->channels; i++) {
- c->status[i].step_index = sign_extend(bytestream2_get_le16u(&gb), 16);
- if (c->status[i].step_index > 88u) {
- av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
- i, c->status[i].step_index);
- return AVERROR_INVALIDDATA;
- }
- }
-
- for (i = 0; i < avctx->channels; i++) {
- samples = (int16_t *)frame->data[i];
- cs = &c->status[i];
- for (n = nb_samples >> 1; n > 0; n--) {
- int v = bytestream2_get_byteu(&gb);
- *samples++ = adpcm_ima_expand_nibble(cs, v & 0x0F, 4);
- *samples++ = adpcm_ima_expand_nibble(cs, v >> 4 , 4);
- }
- }
- break;
- case AV_CODEC_ID_ADPCM_MS:
- {
- int block_predictor;
-
- block_predictor = bytestream2_get_byteu(&gb);
- if (block_predictor > 6) {
- av_log(avctx, AV_LOG_ERROR, "ERROR: block_predictor[0] = %d\n",
- block_predictor);
- return AVERROR_INVALIDDATA;
- }
- c->status[0].coeff1 = ff_adpcm_AdaptCoeff1[block_predictor];
- c->status[0].coeff2 = ff_adpcm_AdaptCoeff2[block_predictor];
- if (st) {
- block_predictor = bytestream2_get_byteu(&gb);
- if (block_predictor > 6) {
- av_log(avctx, AV_LOG_ERROR, "ERROR: block_predictor[1] = %d\n",
- block_predictor);
- return AVERROR_INVALIDDATA;
- }
- c->status[1].coeff1 = ff_adpcm_AdaptCoeff1[block_predictor];
- c->status[1].coeff2 = ff_adpcm_AdaptCoeff2[block_predictor];
- }
- c->status[0].idelta = sign_extend(bytestream2_get_le16u(&gb), 16);
- if (st){
- c->status[1].idelta = sign_extend(bytestream2_get_le16u(&gb), 16);
- }
-
- c->status[0].sample1 = sign_extend(bytestream2_get_le16u(&gb), 16);
- if (st) c->status[1].sample1 = sign_extend(bytestream2_get_le16u(&gb), 16);
- c->status[0].sample2 = sign_extend(bytestream2_get_le16u(&gb), 16);
- if (st) c->status[1].sample2 = sign_extend(bytestream2_get_le16u(&gb), 16);
-
- *samples++ = c->status[0].sample2;
- if (st) *samples++ = c->status[1].sample2;
- *samples++ = c->status[0].sample1;
- if (st) *samples++ = c->status[1].sample1;
- for(n = (nb_samples - 2) >> (1 - st); n > 0; n--) {
- int byte = bytestream2_get_byteu(&gb);
- *samples++ = adpcm_ms_expand_nibble(&c->status[0 ], byte >> 4 );
- *samples++ = adpcm_ms_expand_nibble(&c->status[st], byte & 0x0F);
- }
- break;
- }
- case AV_CODEC_ID_ADPCM_IMA_DK4:
- for (channel = 0; channel < avctx->channels; channel++) {
- cs = &c->status[channel];
- cs->predictor = *samples++ = sign_extend(bytestream2_get_le16u(&gb), 16);
- cs->step_index = sign_extend(bytestream2_get_le16u(&gb), 16);
- if (cs->step_index > 88u){
- av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
- channel, cs->step_index);
- return AVERROR_INVALIDDATA;
- }
- }
- for (n = (nb_samples - 1) >> (1 - st); n > 0; n--) {
- int v = bytestream2_get_byteu(&gb);
- *samples++ = adpcm_ima_expand_nibble(&c->status[0 ], v >> 4 , 3);
- *samples++ = adpcm_ima_expand_nibble(&c->status[st], v & 0x0F, 3);
- }
- break;
- case AV_CODEC_ID_ADPCM_IMA_DK3:
- {
- int last_byte = 0;
- int nibble;
- int decode_top_nibble_next = 0;
- int diff_channel;
- const int16_t *samples_end = samples + avctx->channels * nb_samples;
-
- bytestream2_skipu(&gb, 10);
- c->status[0].predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
- c->status[1].predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
- c->status[0].step_index = bytestream2_get_byteu(&gb);
- c->status[1].step_index = bytestream2_get_byteu(&gb);
- if (c->status[0].step_index > 88u || c->status[1].step_index > 88u){
- av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i/%i\n",
- c->status[0].step_index, c->status[1].step_index);
- return AVERROR_INVALIDDATA;
- }
- /* sign extend the predictors */
- diff_channel = c->status[1].predictor;
-
- /* DK3 ADPCM support macro */
-#define DK3_GET_NEXT_NIBBLE() \
- if (decode_top_nibble_next) { \
- nibble = last_byte >> 4; \
- decode_top_nibble_next = 0; \
- } else { \
- last_byte = bytestream2_get_byteu(&gb); \
- nibble = last_byte & 0x0F; \
- decode_top_nibble_next = 1; \
- }
-
- while (samples < samples_end) {
-
- /* for this algorithm, c->status[0] is the sum channel and
- * c->status[1] is the diff channel */
-
- /* process the first predictor of the sum channel */
- DK3_GET_NEXT_NIBBLE();
- adpcm_ima_expand_nibble(&c->status[0], nibble, 3);
-
- /* process the diff channel predictor */
- DK3_GET_NEXT_NIBBLE();
- adpcm_ima_expand_nibble(&c->status[1], nibble, 3);
-
- /* process the first pair of stereo PCM samples */
- diff_channel = (diff_channel + c->status[1].predictor) / 2;
- *samples++ = c->status[0].predictor + c->status[1].predictor;
- *samples++ = c->status[0].predictor - c->status[1].predictor;
-
- /* process the second predictor of the sum channel */
- DK3_GET_NEXT_NIBBLE();
- adpcm_ima_expand_nibble(&c->status[0], nibble, 3);
-
- /* process the second pair of stereo PCM samples */
- diff_channel = (diff_channel + c->status[1].predictor) / 2;
- *samples++ = c->status[0].predictor + c->status[1].predictor;
- *samples++ = c->status[0].predictor - c->status[1].predictor;
- }
- break;
- }
- case AV_CODEC_ID_ADPCM_IMA_ISS:
- for (channel = 0; channel < avctx->channels; channel++) {
- cs = &c->status[channel];
- cs->predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
- cs->step_index = sign_extend(bytestream2_get_le16u(&gb), 16);
- if (cs->step_index > 88u){
- av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
- channel, cs->step_index);
- return AVERROR_INVALIDDATA;
- }
- }
-
- for (n = nb_samples >> (1 - st); n > 0; n--) {
- int v1, v2;
- int v = bytestream2_get_byteu(&gb);
- /* nibbles are swapped for mono */
- if (st) {
- v1 = v >> 4;
- v2 = v & 0x0F;
- } else {
- v2 = v >> 4;
- v1 = v & 0x0F;
- }
- *samples++ = adpcm_ima_expand_nibble(&c->status[0 ], v1, 3);
- *samples++ = adpcm_ima_expand_nibble(&c->status[st], v2, 3);
- }
- break;
- case AV_CODEC_ID_ADPCM_IMA_APC:
- while (bytestream2_get_bytes_left(&gb) > 0) {
- int v = bytestream2_get_byteu(&gb);
- *samples++ = adpcm_ima_expand_nibble(&c->status[0], v >> 4 , 3);
- *samples++ = adpcm_ima_expand_nibble(&c->status[st], v & 0x0F, 3);
- }
- break;
- case AV_CODEC_ID_ADPCM_IMA_OKI:
- while (bytestream2_get_bytes_left(&gb) > 0) {
- int v = bytestream2_get_byteu(&gb);
- *samples++ = adpcm_ima_oki_expand_nibble(&c->status[0], v >> 4 );
- *samples++ = adpcm_ima_oki_expand_nibble(&c->status[st], v & 0x0F);
- }
- break;
- case AV_CODEC_ID_ADPCM_IMA_WS:
- if (c->vqa_version == 3) {
- for (channel = 0; channel < avctx->channels; channel++) {
- int16_t *smp = samples_p[channel];
-
- for (n = nb_samples / 2; n > 0; n--) {
- int v = bytestream2_get_byteu(&gb);
- *smp++ = adpcm_ima_expand_nibble(&c->status[channel], v >> 4 , 3);
- *smp++ = adpcm_ima_expand_nibble(&c->status[channel], v & 0x0F, 3);
- }
- }
- } else {
- for (n = nb_samples / 2; n > 0; n--) {
- for (channel = 0; channel < avctx->channels; channel++) {
- int v = bytestream2_get_byteu(&gb);
- *samples++ = adpcm_ima_expand_nibble(&c->status[channel], v >> 4 , 3);
- samples[st] = adpcm_ima_expand_nibble(&c->status[channel], v & 0x0F, 3);
- }
- samples += avctx->channels;
- }
- }
- bytestream2_seek(&gb, 0, SEEK_END);
- break;
- case AV_CODEC_ID_ADPCM_XA:
- {
- int16_t *out0 = samples_p[0];
- int16_t *out1 = samples_p[1];
- int samples_per_block = 28 * (3 - avctx->channels) * 4;
- int sample_offset = 0;
- while (bytestream2_get_bytes_left(&gb) >= 128) {
- if ((ret = xa_decode(avctx, out0, out1, buf + bytestream2_tell(&gb),
- &c->status[0], &c->status[1],
- avctx->channels, sample_offset)) < 0)
- return ret;
- bytestream2_skipu(&gb, 128);
- sample_offset += samples_per_block;
- }
- break;
- }
- case AV_CODEC_ID_ADPCM_IMA_EA_EACS:
- for (i=0; i<=st; i++) {
- c->status[i].step_index = bytestream2_get_le32u(&gb);
- if (c->status[i].step_index > 88u) {
- av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
- i, c->status[i].step_index);
- return AVERROR_INVALIDDATA;
- }
- }
- for (i=0; i<=st; i++)
- c->status[i].predictor = bytestream2_get_le32u(&gb);
-
- for (n = nb_samples >> (1 - st); n > 0; n--) {
- int byte = bytestream2_get_byteu(&gb);
- *samples++ = adpcm_ima_expand_nibble(&c->status[0], byte >> 4, 3);
- *samples++ = adpcm_ima_expand_nibble(&c->status[st], byte & 0x0F, 3);
- }
- break;
- case AV_CODEC_ID_ADPCM_IMA_EA_SEAD:
- for (n = nb_samples >> (1 - st); n > 0; n--) {
- int byte = bytestream2_get_byteu(&gb);
- *samples++ = adpcm_ima_expand_nibble(&c->status[0], byte >> 4, 6);
- *samples++ = adpcm_ima_expand_nibble(&c->status[st], byte & 0x0F, 6);
- }
- break;
- case AV_CODEC_ID_ADPCM_EA:
- {
- int previous_left_sample, previous_right_sample;
- int current_left_sample, current_right_sample;
- int next_left_sample, next_right_sample;
- int coeff1l, coeff2l, coeff1r, coeff2r;
- int shift_left, shift_right;
-
- /* Each EA ADPCM frame has a 12-byte header followed by 30-byte pieces,
- each coding 28 stereo samples. */
-
- if(avctx->channels != 2)
- return AVERROR_INVALIDDATA;
-
- current_left_sample = sign_extend(bytestream2_get_le16u(&gb), 16);
- previous_left_sample = sign_extend(bytestream2_get_le16u(&gb), 16);
- current_right_sample = sign_extend(bytestream2_get_le16u(&gb), 16);
- previous_right_sample = sign_extend(bytestream2_get_le16u(&gb), 16);
-
- for (count1 = 0; count1 < nb_samples / 28; count1++) {
- int byte = bytestream2_get_byteu(&gb);
- coeff1l = ea_adpcm_table[ byte >> 4 ];
- coeff2l = ea_adpcm_table[(byte >> 4 ) + 4];
- coeff1r = ea_adpcm_table[ byte & 0x0F];
- coeff2r = ea_adpcm_table[(byte & 0x0F) + 4];
-
- byte = bytestream2_get_byteu(&gb);
- shift_left = 20 - (byte >> 4);
- shift_right = 20 - (byte & 0x0F);
-
- for (count2 = 0; count2 < 28; count2++) {
- byte = bytestream2_get_byteu(&gb);
- next_left_sample = sign_extend(byte >> 4, 4) << shift_left;
- next_right_sample = sign_extend(byte, 4) << shift_right;
-
- next_left_sample = (next_left_sample +
- (current_left_sample * coeff1l) +
- (previous_left_sample * coeff2l) + 0x80) >> 8;
- next_right_sample = (next_right_sample +
- (current_right_sample * coeff1r) +
- (previous_right_sample * coeff2r) + 0x80) >> 8;
-
- previous_left_sample = current_left_sample;
- current_left_sample = av_clip_int16(next_left_sample);
- previous_right_sample = current_right_sample;
- current_right_sample = av_clip_int16(next_right_sample);
- *samples++ = current_left_sample;
- *samples++ = current_right_sample;
- }
- }
-
- bytestream2_skip(&gb, 2); // Skip terminating 0x0000
-
- break;
- }
- case AV_CODEC_ID_ADPCM_EA_MAXIS_XA:
- {
- int coeff[2][2], shift[2];
-
- for(channel = 0; channel < avctx->channels; channel++) {
- int byte = bytestream2_get_byteu(&gb);
- for (i=0; i<2; i++)
- coeff[channel][i] = ea_adpcm_table[(byte >> 4) + 4*i];
- shift[channel] = 20 - (byte & 0x0F);
- }
- for (count1 = 0; count1 < nb_samples / 2; count1++) {
- int byte[2];
-
- byte[0] = bytestream2_get_byteu(&gb);
- if (st) byte[1] = bytestream2_get_byteu(&gb);
- for(i = 4; i >= 0; i-=4) { /* Pairwise samples LL RR (st) or LL LL (mono) */
- for(channel = 0; channel < avctx->channels; channel++) {
- int sample = sign_extend(byte[channel] >> i, 4) << shift[channel];
- sample = (sample +
- c->status[channel].sample1 * coeff[channel][0] +
- c->status[channel].sample2 * coeff[channel][1] + 0x80) >> 8;
- c->status[channel].sample2 = c->status[channel].sample1;
- c->status[channel].sample1 = av_clip_int16(sample);
- *samples++ = c->status[channel].sample1;
- }
- }
- }
- bytestream2_seek(&gb, 0, SEEK_END);
- break;
- }
- case AV_CODEC_ID_ADPCM_EA_R1:
- case AV_CODEC_ID_ADPCM_EA_R2:
- case AV_CODEC_ID_ADPCM_EA_R3: {
- /* channel numbering
- 2chan: 0=fl, 1=fr
- 4chan: 0=fl, 1=rl, 2=fr, 3=rr
- 6chan: 0=fl, 1=c, 2=fr, 3=rl, 4=rr, 5=sub */
- const int big_endian = avctx->codec->id == AV_CODEC_ID_ADPCM_EA_R3;
- int previous_sample, current_sample, next_sample;
- int coeff1, coeff2;
- int shift;
- unsigned int channel;
- uint16_t *samplesC;
- int count = 0;
- int offsets[6];
-
- for (channel=0; channel<avctx->channels; channel++)
- offsets[channel] = (big_endian ? bytestream2_get_be32(&gb) :
- bytestream2_get_le32(&gb)) +
- (avctx->channels + 1) * 4;
-
- for (channel=0; channel<avctx->channels; channel++) {
- bytestream2_seek(&gb, offsets[channel], SEEK_SET);
- samplesC = samples_p[channel];
-
- if (avctx->codec->id == AV_CODEC_ID_ADPCM_EA_R1) {
- current_sample = sign_extend(bytestream2_get_le16(&gb), 16);
- previous_sample = sign_extend(bytestream2_get_le16(&gb), 16);
- } else {
- current_sample = c->status[channel].predictor;
- previous_sample = c->status[channel].prev_sample;
- }
-
- for (count1 = 0; count1 < nb_samples / 28; count1++) {
- int byte = bytestream2_get_byte(&gb);
- if (byte == 0xEE) { /* only seen in R2 and R3 */
- current_sample = sign_extend(bytestream2_get_be16(&gb), 16);
- previous_sample = sign_extend(bytestream2_get_be16(&gb), 16);
-
- for (count2=0; count2<28; count2++)
- *samplesC++ = sign_extend(bytestream2_get_be16(&gb), 16);
- } else {
- coeff1 = ea_adpcm_table[ byte >> 4 ];
- coeff2 = ea_adpcm_table[(byte >> 4) + 4];
- shift = 20 - (byte & 0x0F);
-
- for (count2=0; count2<28; count2++) {
- if (count2 & 1)
- next_sample = sign_extend(byte, 4) << shift;
- else {
- byte = bytestream2_get_byte(&gb);
- next_sample = sign_extend(byte >> 4, 4) << shift;
- }
-
- next_sample += (current_sample * coeff1) +
- (previous_sample * coeff2);
- next_sample = av_clip_int16(next_sample >> 8);
-
- previous_sample = current_sample;
- current_sample = next_sample;
- *samplesC++ = current_sample;
- }
- }
- }
- if (!count) {
- count = count1;
- } else if (count != count1) {
- av_log(avctx, AV_LOG_WARNING, "per-channel sample count mismatch\n");
- count = FFMAX(count, count1);
- }
-
- if (avctx->codec->id != AV_CODEC_ID_ADPCM_EA_R1) {
- c->status[channel].predictor = current_sample;
- c->status[channel].prev_sample = previous_sample;
- }
- }
-
- frame->nb_samples = count * 28;
- bytestream2_seek(&gb, 0, SEEK_END);
- break;
- }
- case AV_CODEC_ID_ADPCM_EA_XAS:
- for (channel=0; channel<avctx->channels; channel++) {
- int coeff[2][4], shift[4];
- int16_t *s = samples_p[channel];
- for (n = 0; n < 4; n++, s += 32) {
- int val = sign_extend(bytestream2_get_le16u(&gb), 16);
- for (i=0; i<2; i++)
- coeff[i][n] = ea_adpcm_table[(val&0x0F)+4*i];
- s[0] = val & ~0x0F;
-
- val = sign_extend(bytestream2_get_le16u(&gb), 16);
- shift[n] = 20 - (val & 0x0F);
- s[1] = val & ~0x0F;
- }
-
- for (m=2; m<32; m+=2) {
- s = &samples_p[channel][m];
- for (n = 0; n < 4; n++, s += 32) {
- int level, pred;
- int byte = bytestream2_get_byteu(&gb);
-
- level = sign_extend(byte >> 4, 4) << shift[n];
- pred = s[-1] * coeff[0][n] + s[-2] * coeff[1][n];
- s[0] = av_clip_int16((level + pred + 0x80) >> 8);
-
- level = sign_extend(byte, 4) << shift[n];
- pred = s[0] * coeff[0][n] + s[-1] * coeff[1][n];
- s[1] = av_clip_int16((level + pred + 0x80) >> 8);
- }
- }
- }
- break;
- case AV_CODEC_ID_ADPCM_IMA_AMV:
- c->status[0].predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
- c->status[0].step_index = bytestream2_get_le16u(&gb);
- bytestream2_skipu(&gb, 4);
- if (c->status[0].step_index > 88u) {
- av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n",
- c->status[0].step_index);
- return AVERROR_INVALIDDATA;
- }
-
- for (n = nb_samples >> (1 - st); n > 0; n--) {
- int v = bytestream2_get_byteu(&gb);
-
- *samples++ = adpcm_ima_expand_nibble(&c->status[0], v >> 4, 3);
- *samples++ = adpcm_ima_expand_nibble(&c->status[0], v & 0xf, 3);
- }
- break;
- case AV_CODEC_ID_ADPCM_IMA_SMJPEG:
- for (i = 0; i < avctx->channels; i++) {
- c->status[i].predictor = sign_extend(bytestream2_get_be16u(&gb), 16);
- c->status[i].step_index = bytestream2_get_byteu(&gb);
- bytestream2_skipu(&gb, 1);
- if (c->status[i].step_index > 88u) {
- av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n",
- c->status[i].step_index);
- return AVERROR_INVALIDDATA;
- }
- }
-
- for (n = nb_samples >> (1 - st); n > 0; n--) {
- int v = bytestream2_get_byteu(&gb);
-
- *samples++ = adpcm_ima_qt_expand_nibble(&c->status[0 ], v >> 4, 3);
- *samples++ = adpcm_ima_qt_expand_nibble(&c->status[st], v & 0xf, 3);
- }
- break;
- case AV_CODEC_ID_ADPCM_CT:
- for (n = nb_samples >> (1 - st); n > 0; n--) {
- int v = bytestream2_get_byteu(&gb);
- *samples++ = adpcm_ct_expand_nibble(&c->status[0 ], v >> 4 );
- *samples++ = adpcm_ct_expand_nibble(&c->status[st], v & 0x0F);
- }
- break;
- case AV_CODEC_ID_ADPCM_SBPRO_4:
- case AV_CODEC_ID_ADPCM_SBPRO_3:
- case AV_CODEC_ID_ADPCM_SBPRO_2:
- if (!c->status[0].step_index) {
- /* the first byte is a raw sample */
- *samples++ = 128 * (bytestream2_get_byteu(&gb) - 0x80);
- if (st)
- *samples++ = 128 * (bytestream2_get_byteu(&gb) - 0x80);
- c->status[0].step_index = 1;
- nb_samples--;
- }
- if (avctx->codec->id == AV_CODEC_ID_ADPCM_SBPRO_4) {
- for (n = nb_samples >> (1 - st); n > 0; n--) {
- int byte = bytestream2_get_byteu(&gb);
- *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
- byte >> 4, 4, 0);
- *samples++ = adpcm_sbpro_expand_nibble(&c->status[st],
- byte & 0x0F, 4, 0);
- }
- } else if (avctx->codec->id == AV_CODEC_ID_ADPCM_SBPRO_3) {
- for (n = nb_samples / 3; n > 0; n--) {
- int byte = bytestream2_get_byteu(&gb);
- *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
- byte >> 5 , 3, 0);
- *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
- (byte >> 2) & 0x07, 3, 0);
- *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
- byte & 0x03, 2, 0);
- }
- } else {
- for (n = nb_samples >> (2 - st); n > 0; n--) {
- int byte = bytestream2_get_byteu(&gb);
- *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
- byte >> 6 , 2, 2);
- *samples++ = adpcm_sbpro_expand_nibble(&c->status[st],
- (byte >> 4) & 0x03, 2, 2);
- *samples++ = adpcm_sbpro_expand_nibble(&c->status[0],
- (byte >> 2) & 0x03, 2, 2);
- *samples++ = adpcm_sbpro_expand_nibble(&c->status[st],
- byte & 0x03, 2, 2);
- }
- }
- break;
- case AV_CODEC_ID_ADPCM_SWF:
- adpcm_swf_decode(avctx, buf, buf_size, samples);
- bytestream2_seek(&gb, 0, SEEK_END);
- break;
- case AV_CODEC_ID_ADPCM_YAMAHA:
- for (n = nb_samples >> (1 - st); n > 0; n--) {
- int v = bytestream2_get_byteu(&gb);
- *samples++ = adpcm_yamaha_expand_nibble(&c->status[0 ], v & 0x0F);
- *samples++ = adpcm_yamaha_expand_nibble(&c->status[st], v >> 4 );
- }
- break;
- case AV_CODEC_ID_ADPCM_AFC:
- {
- int samples_per_block;
- int blocks;
-
- if (avctx->extradata && avctx->extradata_size == 1 && avctx->extradata[0]) {
- samples_per_block = avctx->extradata[0] / 16;
- blocks = nb_samples / avctx->extradata[0];
- } else {
- samples_per_block = nb_samples / 16;
- blocks = 1;
- }
-
- for (m = 0; m < blocks; m++) {
- for (channel = 0; channel < avctx->channels; channel++) {
- int prev1 = c->status[channel].sample1;
- int prev2 = c->status[channel].sample2;
-
- samples = samples_p[channel] + m * 16;
- /* Read in every sample for this channel. */
- for (i = 0; i < samples_per_block; i++) {
- int byte = bytestream2_get_byteu(&gb);
- int scale = 1 << (byte >> 4);
- int index = byte & 0xf;
- int factor1 = ff_adpcm_afc_coeffs[0][index];
- int factor2 = ff_adpcm_afc_coeffs[1][index];
-
- /* Decode 16 samples. */
- for (n = 0; n < 16; n++) {
- int32_t sampledat;
-
- if (n & 1) {
- sampledat = sign_extend(byte, 4);
- } else {
- byte = bytestream2_get_byteu(&gb);
- sampledat = sign_extend(byte >> 4, 4);
- }
-
- sampledat = ((prev1 * factor1 + prev2 * factor2) +
- ((sampledat * scale) << 11)) >> 11;
- *samples = av_clip_int16(sampledat);
- prev2 = prev1;
- prev1 = *samples++;
- }
- }
-
- c->status[channel].sample1 = prev1;
- c->status[channel].sample2 = prev2;
- }
- }
- bytestream2_seek(&gb, 0, SEEK_END);
- break;
- }
- case AV_CODEC_ID_ADPCM_THP:
- {
- int table[6][16];
- int ch;
-
- for (i = 0; i < avctx->channels; i++)
- for (n = 0; n < 16; n++)
- table[i][n] = sign_extend(bytestream2_get_be16u(&gb), 16);
-
- /* Initialize the previous sample. */
- for (i = 0; i < avctx->channels; i++) {
- c->status[i].sample1 = sign_extend(bytestream2_get_be16u(&gb), 16);
- c->status[i].sample2 = sign_extend(bytestream2_get_be16u(&gb), 16);
- }
-
- for (ch = 0; ch < avctx->channels; ch++) {
- samples = samples_p[ch];
-
- /* Read in every sample for this channel. */
- for (i = 0; i < nb_samples / 14; i++) {
- int byte = bytestream2_get_byteu(&gb);
- int index = (byte >> 4) & 7;
- unsigned int exp = byte & 0x0F;
- int factor1 = table[ch][index * 2];
- int factor2 = table[ch][index * 2 + 1];
-
- /* Decode 14 samples. */
- for (n = 0; n < 14; n++) {
- int32_t sampledat;
-
- if (n & 1) {
- sampledat = sign_extend(byte, 4);
- } else {
- byte = bytestream2_get_byteu(&gb);
- sampledat = sign_extend(byte >> 4, 4);
- }
-
- sampledat = ((c->status[ch].sample1 * factor1
- + c->status[ch].sample2 * factor2) >> 11) + (sampledat << exp);
- *samples = av_clip_int16(sampledat);
- c->status[ch].sample2 = c->status[ch].sample1;
- c->status[ch].sample1 = *samples++;
- }
- }
- }
- break;
- }
-
- default:
- return -1;
- }
-
- if (avpkt->size && bytestream2_tell(&gb) == 0) {
- av_log(avctx, AV_LOG_ERROR, "Nothing consumed\n");
- return AVERROR_INVALIDDATA;
- }
-
- *got_frame_ptr = 1;
-
- return bytestream2_tell(&gb);
-}
-
-
-static const enum AVSampleFormat sample_fmts_s16[] = { AV_SAMPLE_FMT_S16,
- AV_SAMPLE_FMT_NONE };
-static const enum AVSampleFormat sample_fmts_s16p[] = { AV_SAMPLE_FMT_S16,
- AV_SAMPLE_FMT_NONE };
-static const enum AVSampleFormat sample_fmts_both[] = { AV_SAMPLE_FMT_S16,
- AV_SAMPLE_FMT_S16P,
- AV_SAMPLE_FMT_NONE };
-
-#define ADPCM_DECODER(id_, sample_fmts_, name_, long_name_) \
-AVCodec ff_ ## name_ ## _decoder = { \
- .name = #name_, \
- .type = AVMEDIA_TYPE_AUDIO, \
- .id = id_, \
- .priv_data_size = sizeof(ADPCMDecodeContext), \
- .init = adpcm_decode_init, \
- .decode = adpcm_decode_frame, \
- .capabilities = CODEC_CAP_DR1, \
- .long_name = NULL_IF_CONFIG_SMALL(long_name_), \
- .sample_fmts = sample_fmts_, \
-}
-
-/* Note: Do not forget to add new entries to the Makefile as well. */
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_4XM, sample_fmts_s16p, adpcm_4xm, "ADPCM 4X Movie");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_AFC, sample_fmts_s16p, adpcm_afc, "ADPCM Nintendo Gamecube AFC");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_CT, sample_fmts_s16, adpcm_ct, "ADPCM Creative Technology");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA, sample_fmts_s16, adpcm_ea, "ADPCM Electronic Arts");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_MAXIS_XA, sample_fmts_s16, adpcm_ea_maxis_xa, "ADPCM Electronic Arts Maxis CDROM XA");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R1, sample_fmts_s16p, adpcm_ea_r1, "ADPCM Electronic Arts R1");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R2, sample_fmts_s16p, adpcm_ea_r2, "ADPCM Electronic Arts R2");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R3, sample_fmts_s16p, adpcm_ea_r3, "ADPCM Electronic Arts R3");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_XAS, sample_fmts_s16p, adpcm_ea_xas, "ADPCM Electronic Arts XAS");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_AMV, sample_fmts_s16, adpcm_ima_amv, "ADPCM IMA AMV");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_APC, sample_fmts_s16, adpcm_ima_apc, "ADPCM IMA CRYO APC");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_DK3, sample_fmts_s16, adpcm_ima_dk3, "ADPCM IMA Duck DK3");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_DK4, sample_fmts_s16, adpcm_ima_dk4, "ADPCM IMA Duck DK4");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_EA_EACS, sample_fmts_s16, adpcm_ima_ea_eacs, "ADPCM IMA Electronic Arts EACS");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_EA_SEAD, sample_fmts_s16, adpcm_ima_ea_sead, "ADPCM IMA Electronic Arts SEAD");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_ISS, sample_fmts_s16, adpcm_ima_iss, "ADPCM IMA Funcom ISS");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_OKI, sample_fmts_s16, adpcm_ima_oki, "ADPCM IMA Dialogic OKI");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_QT, sample_fmts_s16p, adpcm_ima_qt, "ADPCM IMA QuickTime");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_SMJPEG, sample_fmts_s16, adpcm_ima_smjpeg, "ADPCM IMA Loki SDL MJPEG");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_WAV, sample_fmts_s16p, adpcm_ima_wav, "ADPCM IMA WAV");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_WS, sample_fmts_both, adpcm_ima_ws, "ADPCM IMA Westwood");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_MS, sample_fmts_s16, adpcm_ms, "ADPCM Microsoft");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_SBPRO_2, sample_fmts_s16, adpcm_sbpro_2, "ADPCM Sound Blaster Pro 2-bit");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_SBPRO_3, sample_fmts_s16, adpcm_sbpro_3, "ADPCM Sound Blaster Pro 2.6-bit");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_SBPRO_4, sample_fmts_s16, adpcm_sbpro_4, "ADPCM Sound Blaster Pro 4-bit");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_SWF, sample_fmts_s16, adpcm_swf, "ADPCM Shockwave Flash");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_THP, sample_fmts_s16p, adpcm_thp, "ADPCM Nintendo Gamecube THP");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_XA, sample_fmts_s16p, adpcm_xa, "ADPCM CDROM XA");
-ADPCM_DECODER(AV_CODEC_ID_ADPCM_YAMAHA, sample_fmts_s16, adpcm_yamaha, "ADPCM Yamaha");
diff --git a/src/thirdparty/ffmpeg/libavcodec/adpcm.h b/src/thirdparty/ffmpeg/libavcodec/adpcm.h
deleted file mode 100644
index c473ff524..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/adpcm.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2001-2003 The ffmpeg Project
- *
- * 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
- * ADPCM encoder/decoder common header.
- */
-
-#ifndef AVCODEC_ADPCM_H
-#define AVCODEC_ADPCM_H
-
-#include <stdint.h>
-
-#define BLKSIZE 1024
-
-typedef struct ADPCMChannelStatus {
- int predictor;
- int16_t step_index;
- int step;
- /* for encoding */
- int prev_sample;
-
- /* MS version */
- int16_t sample1;
- int16_t sample2;
- int coeff1;
- int coeff2;
- int idelta;
-} ADPCMChannelStatus;
-
-#endif /* AVCODEC_ADPCM_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/adpcm_data.c b/src/thirdparty/ffmpeg/libavcodec/adpcm_data.c
deleted file mode 100644
index e6639662c..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/adpcm_data.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2001-2003 The ffmpeg Project
- *
- * 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
- * ADPCM tables
- */
-
-#include <stdint.h>
-
-/* ff_adpcm_step_table[] and ff_adpcm_index_table[] are from the ADPCM
- reference source */
-/* This is the index table: */
-const int8_t ff_adpcm_index_table[16] = {
- -1, -1, -1, -1, 2, 4, 6, 8,
- -1, -1, -1, -1, 2, 4, 6, 8,
-};
-
-/**
- * This is the step table. Note that many programs use slight deviations from
- * this table, but such deviations are negligible:
- */
-const int16_t ff_adpcm_step_table[89] = {
- 7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
- 19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
- 50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
- 130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
- 337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
- 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
- 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
- 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
- 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
-};
-
-const int16_t ff_adpcm_oki_step_table[49] = {
- 16, 17, 19, 21, 23, 25, 28, 31, 34, 37,
- 41, 45, 50, 55, 60, 66, 73, 80, 88, 97,
- 107, 118, 130, 143, 157, 173, 190, 209, 230, 253,
- 279, 307, 337, 371, 408, 449, 494, 544, 598, 658,
- 724, 796, 876, 963, 1060, 1166, 1282, 1411, 1552
-};
-
-/* These are for MS-ADPCM */
-/* ff_adpcm_AdaptationTable[], ff_adpcm_AdaptCoeff1[], and
- ff_adpcm_AdaptCoeff2[] are from libsndfile */
-const int16_t ff_adpcm_AdaptationTable[] = {
- 230, 230, 230, 230, 307, 409, 512, 614,
- 768, 614, 512, 409, 307, 230, 230, 230
-};
-
-/** Divided by 4 to fit in 8-bit integers */
-const uint8_t ff_adpcm_AdaptCoeff1[] = {
- 64, 128, 0, 48, 60, 115, 98
-};
-
-/** Divided by 4 to fit in 8-bit integers */
-const int8_t ff_adpcm_AdaptCoeff2[] = {
- 0, -64, 0, 16, 0, -52, -58
-};
-
-const int16_t ff_adpcm_yamaha_indexscale[] = {
- 230, 230, 230, 230, 307, 409, 512, 614,
- 230, 230, 230, 230, 307, 409, 512, 614
-};
-
-const int8_t ff_adpcm_yamaha_difflookup[] = {
- 1, 3, 5, 7, 9, 11, 13, 15,
- -1, -3, -5, -7, -9, -11, -13, -15
-};
-
-const int16_t ff_adpcm_afc_coeffs[2][16] = {
- { 0, 2048, 0, 1024, 4096, 3584, 3072, 4608, 4200, 4800, 5120, 2048, 1024, 64512, 64512, 63488 },
- { 0, 0, 2048, 1024, 63488, 64000, 64512, 62976, 63288, 63236, 62464, 63488, 64512, 1024, 0, 0 }
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/adpcm_data.h b/src/thirdparty/ffmpeg/libavcodec/adpcm_data.h
deleted file mode 100644
index f24f5c617..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/adpcm_data.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2001-2003 The ffmpeg Project
- *
- * 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
- * ADPCM tables
- */
-
-#ifndef AVCODEC_ADPCM_DATA_H
-#define AVCODEC_ADPCM_DATA_H
-
-#include <stdint.h>
-
-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];
-extern const int16_t ff_adpcm_AdaptationTable[];
-extern const uint8_t ff_adpcm_AdaptCoeff1[];
-extern const int8_t ff_adpcm_AdaptCoeff2[];
-extern const int16_t ff_adpcm_yamaha_indexscale[];
-extern const int8_t ff_adpcm_yamaha_difflookup[];
-extern const int16_t ff_adpcm_afc_coeffs[2][16];
-
-#endif /* AVCODEC_ADPCM_DATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/alac.c b/src/thirdparty/ffmpeg/libavcodec/alac.c
deleted file mode 100644
index df6d6f377..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/alac.c
+++ /dev/null
@@ -1,631 +0,0 @@
-/*
- * ALAC (Apple Lossless Audio Codec) decoder
- * Copyright (c) 2005 David Hammerton
- *
- * 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
- * ALAC (Apple Lossless Audio Codec) decoder
- * @author 2005 David Hammerton
- * @see http://crazney.net/programs/itunes/alac.html
- *
- * Note: This decoder expects a 36-byte QuickTime atom to be
- * passed through the extradata[_size] fields. This atom is tacked onto
- * the end of an 'alac' stsd atom and has the following format:
- *
- * 32bit atom size
- * 32bit tag ("alac")
- * 32bit tag version (0)
- * 32bit samples per frame (used when not set explicitly in the frames)
- * 8bit compatible version (0)
- * 8bit sample size
- * 8bit history mult (40)
- * 8bit initial history (14)
- * 8bit rice param limit (10)
- * 8bit channels
- * 16bit maxRun (255)
- * 32bit max coded frame size (0 means unknown)
- * 32bit average bitrate (0 means unknown)
- * 32bit samplerate
- */
-
-#include "libavutil/channel_layout.h"
-#include "avcodec.h"
-#include "get_bits.h"
-#include "bytestream.h"
-#include "internal.h"
-#include "unary.h"
-#include "mathops.h"
-#include "alac_data.h"
-
-#define ALAC_EXTRADATA_SIZE 36
-
-typedef struct {
- AVCodecContext *avctx;
- GetBitContext gb;
- int channels;
-
- int32_t *predict_error_buffer[2];
- int32_t *output_samples_buffer[2];
- int32_t *extra_bits_buffer[2];
-
- uint32_t max_samples_per_frame;
- uint8_t sample_size;
- uint8_t rice_history_mult;
- uint8_t rice_initial_history;
- uint8_t rice_limit;
-
- int extra_bits; /**< number of extra bits beyond 16-bit */
- int nb_samples; /**< number of samples in the current frame */
-
- int direct_output;
-} ALACContext;
-
-static inline unsigned int decode_scalar(GetBitContext *gb, int k, int bps)
-{
- unsigned int x = get_unary_0_9(gb);
-
- if (x > 8) { /* RICE THRESHOLD */
- /* use alternative encoding */
- x = get_bits_long(gb, bps);
- } else if (k != 1) {
- int extrabits = show_bits(gb, k);
-
- /* multiply x by 2^k - 1, as part of their strange algorithm */
- x = (x << k) - x;
-
- if (extrabits > 1) {
- x += extrabits - 1;
- skip_bits(gb, k);
- } else
- skip_bits(gb, k - 1);
- }
- return x;
-}
-
-static int rice_decompress(ALACContext *alac, int32_t *output_buffer,
- int nb_samples, int bps, int rice_history_mult)
-{
- int i;
- unsigned int history = alac->rice_initial_history;
- int sign_modifier = 0;
-
- for (i = 0; i < nb_samples; i++) {
- int k;
- unsigned int x;
-
- if(get_bits_left(&alac->gb) <= 0)
- return -1;
-
- /* calculate rice param and decode next value */
- k = av_log2((history >> 9) + 3);
- k = FFMIN(k, alac->rice_limit);
- x = decode_scalar(&alac->gb, k, bps);
- x += sign_modifier;
- sign_modifier = 0;
- output_buffer[i] = (x >> 1) ^ -(x & 1);
-
- /* update the history */
- if (x > 0xffff)
- history = 0xffff;
- else
- history += x * rice_history_mult -
- ((history * rice_history_mult) >> 9);
-
- /* special case: there may be compressed blocks of 0 */
- if ((history < 128) && (i + 1 < nb_samples)) {
- int block_size;
-
- /* calculate rice param and decode block size */
- k = 7 - av_log2(history) + ((history + 16) >> 6);
- k = FFMIN(k, alac->rice_limit);
- block_size = decode_scalar(&alac->gb, k, 16);
-
- if (block_size > 0) {
- if (block_size >= nb_samples - i) {
- av_log(alac->avctx, AV_LOG_ERROR,
- "invalid zero block size of %d %d %d\n", block_size,
- nb_samples, i);
- block_size = nb_samples - i - 1;
- }
- memset(&output_buffer[i + 1], 0,
- block_size * sizeof(*output_buffer));
- i += block_size;
- }
- if (block_size <= 0xffff)
- sign_modifier = 1;
- history = 0;
- }
- }
- return 0;
-}
-
-static inline int sign_only(int v)
-{
- return v ? FFSIGN(v) : 0;
-}
-
-static void lpc_prediction(int32_t *error_buffer, int32_t *buffer_out,
- int nb_samples, int bps, int16_t *lpc_coefs,
- int lpc_order, int lpc_quant)
-{
- int i;
- int32_t *pred = buffer_out;
-
- /* first sample always copies */
- *buffer_out = *error_buffer;
-
- if (nb_samples <= 1)
- return;
-
- if (!lpc_order) {
- memcpy(&buffer_out[1], &error_buffer[1],
- (nb_samples - 1) * sizeof(*buffer_out));
- return;
- }
-
- if (lpc_order == 31) {
- /* simple 1st-order prediction */
- for (i = 1; i < nb_samples; i++) {
- buffer_out[i] = sign_extend(buffer_out[i - 1] + error_buffer[i],
- bps);
- }
- return;
- }
-
- /* read warm-up samples */
- for (i = 1; i <= lpc_order && i < nb_samples; i++)
- buffer_out[i] = sign_extend(buffer_out[i - 1] + error_buffer[i], bps);
-
- /* NOTE: 4 and 8 are very common cases that could be optimized. */
-
- for (; i < nb_samples; i++) {
- int j;
- int val = 0;
- int error_val = error_buffer[i];
- int error_sign;
- int d = *pred++;
-
- /* LPC prediction */
- for (j = 0; j < lpc_order; j++)
- val += (pred[j] - d) * lpc_coefs[j];
- val = (val + (1 << (lpc_quant - 1))) >> lpc_quant;
- val += d + error_val;
- buffer_out[i] = sign_extend(val, bps);
-
- /* adapt LPC coefficients */
- error_sign = sign_only(error_val);
- if (error_sign) {
- for (j = 0; j < lpc_order && error_val * error_sign > 0; j++) {
- int sign;
- val = d - pred[j];
- sign = sign_only(val) * error_sign;
- lpc_coefs[j] -= sign;
- val *= sign;
- error_val -= (val >> lpc_quant) * (j + 1);
- }
- }
- }
-}
-
-static void decorrelate_stereo(int32_t *buffer[2], int nb_samples,
- int decorr_shift, int decorr_left_weight)
-{
- int i;
-
- for (i = 0; i < nb_samples; i++) {
- int32_t a, b;
-
- a = buffer[0][i];
- b = buffer[1][i];
-
- a -= (b * decorr_left_weight) >> decorr_shift;
- b += a;
-
- buffer[0][i] = b;
- buffer[1][i] = a;
- }
-}
-
-static void append_extra_bits(int32_t *buffer[2], int32_t *extra_bits_buffer[2],
- int extra_bits, int channels, int nb_samples)
-{
- int i, ch;
-
- for (ch = 0; ch < channels; ch++)
- for (i = 0; i < nb_samples; i++)
- buffer[ch][i] = (buffer[ch][i] << extra_bits) | extra_bits_buffer[ch][i];
-}
-
-static int decode_element(AVCodecContext *avctx, AVFrame *frame, int ch_index,
- int channels)
-{
- ALACContext *alac = avctx->priv_data;
- int has_size, bps, is_compressed, decorr_shift, decorr_left_weight, ret;
- uint32_t output_samples;
- int i, ch;
-
- skip_bits(&alac->gb, 4); /* element instance tag */
- skip_bits(&alac->gb, 12); /* unused header bits */
-
- /* the number of output samples is stored in the frame */
- has_size = get_bits1(&alac->gb);
-
- alac->extra_bits = get_bits(&alac->gb, 2) << 3;
- bps = alac->sample_size - alac->extra_bits + channels - 1;
- if (bps > 32U) {
- av_log(avctx, AV_LOG_ERROR, "bps is unsupported: %d\n", bps);
- return AVERROR_PATCHWELCOME;
- }
-
- /* whether the frame is compressed */
- is_compressed = !get_bits1(&alac->gb);
-
- if (has_size)
- output_samples = get_bits_long(&alac->gb, 32);
- 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",
- output_samples);
- return AVERROR_INVALIDDATA;
- }
- if (!alac->nb_samples) {
- /* get output buffer */
- frame->nb_samples = output_samples;
- if ((ret = ff_get_buffer(avctx, frame)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return ret;
- }
- } else if (output_samples != alac->nb_samples) {
- av_log(avctx, AV_LOG_ERROR, "sample count mismatch: %u != %d\n",
- output_samples, alac->nb_samples);
- return AVERROR_INVALIDDATA;
- }
- alac->nb_samples = output_samples;
- if (alac->direct_output) {
- for (ch = 0; ch < channels; ch++)
- alac->output_samples_buffer[ch] = (int32_t *)frame->extended_data[ch_index + ch];
- }
-
- if (is_compressed) {
- int16_t lpc_coefs[2][32];
- int lpc_order[2];
- int prediction_type[2];
- int lpc_quant[2];
- int rice_history_mult[2];
-
- decorr_shift = get_bits(&alac->gb, 8);
- decorr_left_weight = get_bits(&alac->gb, 8);
-
- for (ch = 0; ch < channels; ch++) {
- prediction_type[ch] = get_bits(&alac->gb, 4);
- lpc_quant[ch] = get_bits(&alac->gb, 4);
- rice_history_mult[ch] = get_bits(&alac->gb, 3);
- lpc_order[ch] = get_bits(&alac->gb, 5);
-
- /* read the predictor table */
- for (i = lpc_order[ch] - 1; i >= 0; i--)
- lpc_coefs[ch][i] = get_sbits(&alac->gb, 16);
- }
-
- if (alac->extra_bits) {
- for (i = 0; i < alac->nb_samples; i++) {
- if(get_bits_left(&alac->gb) <= 0)
- return -1;
- for (ch = 0; ch < channels; ch++)
- alac->extra_bits_buffer[ch][i] = get_bits(&alac->gb, alac->extra_bits);
- }
- }
- for (ch = 0; ch < channels; ch++) {
- int ret=rice_decompress(alac, alac->predict_error_buffer[ch],
- alac->nb_samples, bps,
- rice_history_mult[ch] * alac->rice_history_mult / 4);
- if(ret<0)
- return ret;
-
- /* adaptive FIR filter */
- if (prediction_type[ch] == 15) {
- /* Prediction type 15 runs the adaptive FIR twice.
- * The first pass uses the special-case coef_num = 31, while
- * the second pass uses the coefs from the bitstream.
- *
- * However, this prediction type is not currently used by the
- * reference encoder.
- */
- lpc_prediction(alac->predict_error_buffer[ch],
- alac->predict_error_buffer[ch],
- alac->nb_samples, bps, NULL, 31, 0);
- } else if (prediction_type[ch] > 0) {
- av_log(avctx, AV_LOG_WARNING, "unknown prediction type: %i\n",
- prediction_type[ch]);
- }
- lpc_prediction(alac->predict_error_buffer[ch],
- alac->output_samples_buffer[ch], alac->nb_samples,
- bps, lpc_coefs[ch], lpc_order[ch], lpc_quant[ch]);
- }
- } else {
- /* not compressed, easy case */
- for (i = 0; i < alac->nb_samples; i++) {
- if(get_bits_left(&alac->gb) <= 0)
- return -1;
- for (ch = 0; ch < channels; ch++) {
- alac->output_samples_buffer[ch][i] =
- get_sbits_long(&alac->gb, alac->sample_size);
- }
- }
- alac->extra_bits = 0;
- decorr_shift = 0;
- decorr_left_weight = 0;
- }
-
- if (channels == 2 && decorr_left_weight) {
- decorrelate_stereo(alac->output_samples_buffer, alac->nb_samples,
- decorr_shift, decorr_left_weight);
- }
-
- if (alac->extra_bits) {
- append_extra_bits(alac->output_samples_buffer, alac->extra_bits_buffer,
- alac->extra_bits, channels, alac->nb_samples);
- }
-
- if(av_sample_fmt_is_planar(avctx->sample_fmt)) {
- switch(alac->sample_size) {
- case 16: {
- for (ch = 0; ch < channels; ch++) {
- int16_t *outbuffer = (int16_t *)frame->extended_data[ch_index + ch];
- for (i = 0; i < alac->nb_samples; i++)
- *outbuffer++ = alac->output_samples_buffer[ch][i];
- }}
- break;
- case 24: {
- for (ch = 0; ch < channels; ch++) {
- for (i = 0; i < alac->nb_samples; i++)
- alac->output_samples_buffer[ch][i] <<= 8;
- }}
- break;
- }
- }else{
- switch(alac->sample_size) {
- case 16: {
- int16_t *outbuffer = ((int16_t *)frame->extended_data[0]) + ch_index;
- for (i = 0; i < alac->nb_samples; i++) {
- for (ch = 0; ch < channels; ch++)
- *outbuffer++ = alac->output_samples_buffer[ch][i];
- outbuffer += alac->channels - channels;
- }
- }
- break;
- case 24: {
- int32_t *outbuffer = ((int32_t *)frame->extended_data[0]) + ch_index;
- for (i = 0; i < alac->nb_samples; i++) {
- for (ch = 0; ch < channels; ch++)
- *outbuffer++ = alac->output_samples_buffer[ch][i] << 8;
- outbuffer += alac->channels - channels;
- }
- }
- break;
- case 32: {
- int32_t *outbuffer = ((int32_t *)frame->extended_data[0]) + ch_index;
- for (i = 0; i < alac->nb_samples; i++) {
- for (ch = 0; ch < channels; ch++)
- *outbuffer++ = alac->output_samples_buffer[ch][i];
- outbuffer += alac->channels - channels;
- }
- }
- break;
- }
- }
-
- return 0;
-}
-
-static int alac_decode_frame(AVCodecContext *avctx, void *data,
- int *got_frame_ptr, AVPacket *avpkt)
-{
- ALACContext *alac = avctx->priv_data;
- AVFrame *frame = data;
- enum AlacRawDataBlockType element;
- int channels;
- int ch, ret, got_end;
-
- init_get_bits(&alac->gb, avpkt->data, avpkt->size * 8);
-
- got_end = 0;
- alac->nb_samples = 0;
- ch = 0;
- while (get_bits_left(&alac->gb) >= 3) {
- element = get_bits(&alac->gb, 3);
- if (element == TYPE_END) {
- got_end = 1;
- break;
- }
- if (element > TYPE_CPE && element != TYPE_LFE) {
- av_log(avctx, AV_LOG_ERROR, "syntax element unsupported: %d\n", element);
- return AVERROR_PATCHWELCOME;
- }
-
- channels = (element == TYPE_CPE) ? 2 : 1;
- if ( ch + channels > alac->channels
- || ff_alac_channel_layout_offsets[alac->channels - 1][ch] + channels > alac->channels
- ) {
- av_log(avctx, AV_LOG_ERROR, "invalid element channel count\n");
- return AVERROR_INVALIDDATA;
- }
-
- ret = decode_element(avctx, frame,
- ff_alac_channel_layout_offsets[alac->channels - 1][ch],
- channels);
- if (ret < 0 && get_bits_left(&alac->gb))
- return ret;
-
- ch += channels;
- }
- if (!got_end) {
- av_log(avctx, AV_LOG_ERROR, "no end tag found. incomplete packet.\n");
- return AVERROR_INVALIDDATA;
- }
-
- if (avpkt->size * 8 - get_bits_count(&alac->gb) > 8) {
- av_log(avctx, AV_LOG_ERROR, "Error : %d bits left\n",
- avpkt->size * 8 - get_bits_count(&alac->gb));
- }
-
- *got_frame_ptr = 1;
-
- return avpkt->size;
-}
-
-static av_cold int alac_decode_close(AVCodecContext *avctx)
-{
- ALACContext *alac = avctx->priv_data;
-
- int ch;
- for (ch = 0; ch < FFMIN(alac->channels, 2); ch++) {
- av_freep(&alac->predict_error_buffer[ch]);
- if (!alac->direct_output)
- av_freep(&alac->output_samples_buffer[ch]);
- av_freep(&alac->extra_bits_buffer[ch]);
- }
-
- return 0;
-}
-
-static int allocate_buffers(ALACContext *alac)
-{
- int ch;
- int buf_size;
-
- if (alac->max_samples_per_frame > INT_MAX / sizeof(int32_t))
- goto buf_alloc_fail;
- buf_size = alac->max_samples_per_frame * sizeof(int32_t);
-
- for (ch = 0; ch < FFMIN(alac->channels, 2); ch++) {
- FF_ALLOC_OR_GOTO(alac->avctx, alac->predict_error_buffer[ch],
- buf_size, buf_alloc_fail);
-
- alac->direct_output = alac->sample_size > 16 && av_sample_fmt_is_planar(alac->avctx->sample_fmt);
- if (!alac->direct_output) {
- FF_ALLOC_OR_GOTO(alac->avctx, alac->output_samples_buffer[ch],
- buf_size, buf_alloc_fail);
- }
-
- FF_ALLOC_OR_GOTO(alac->avctx, alac->extra_bits_buffer[ch],
- buf_size, buf_alloc_fail);
- }
- return 0;
-buf_alloc_fail:
- alac_decode_close(alac->avctx);
- return AVERROR(ENOMEM);
-}
-
-static int alac_set_info(ALACContext *alac)
-{
- GetByteContext gb;
-
- bytestream2_init(&gb, alac->avctx->extradata,
- alac->avctx->extradata_size);
-
- bytestream2_skipu(&gb, 12); // size:4, alac:4, version:4
-
- alac->max_samples_per_frame = bytestream2_get_be32u(&gb);
- if (!alac->max_samples_per_frame || alac->max_samples_per_frame > INT_MAX) {
- av_log(alac->avctx, AV_LOG_ERROR, "max samples per frame invalid: %u\n",
- alac->max_samples_per_frame);
- return AVERROR_INVALIDDATA;
- }
- bytestream2_skipu(&gb, 1); // compatible version
- alac->sample_size = bytestream2_get_byteu(&gb);
- alac->rice_history_mult = bytestream2_get_byteu(&gb);
- alac->rice_initial_history = bytestream2_get_byteu(&gb);
- alac->rice_limit = bytestream2_get_byteu(&gb);
- alac->channels = bytestream2_get_byteu(&gb);
- bytestream2_get_be16u(&gb); // maxRun
- bytestream2_get_be32u(&gb); // max coded frame size
- bytestream2_get_be32u(&gb); // average bitrate
- bytestream2_get_be32u(&gb); // samplerate
-
- return 0;
-}
-
-static av_cold int alac_decode_init(AVCodecContext * avctx)
-{
- int ret;
- int req_packed;
- ALACContext *alac = avctx->priv_data;
- alac->avctx = avctx;
-
- /* initialize from the extradata */
- if (alac->avctx->extradata_size < ALAC_EXTRADATA_SIZE) {
- av_log(avctx, AV_LOG_ERROR, "extradata is too small\n");
- return AVERROR_INVALIDDATA;
- }
- if (alac_set_info(alac)) {
- av_log(avctx, AV_LOG_ERROR, "set_info failed\n");
- return -1;
- }
-
- req_packed = LIBAVCODEC_VERSION_MAJOR < 55 && !av_sample_fmt_is_planar(avctx->request_sample_fmt);
- switch (alac->sample_size) {
- case 16: avctx->sample_fmt = req_packed ? AV_SAMPLE_FMT_S16 : AV_SAMPLE_FMT_S16P;
- break;
- case 24:
- case 32: avctx->sample_fmt = req_packed ? AV_SAMPLE_FMT_S32 : AV_SAMPLE_FMT_S32P;
- break;
- default: av_log_ask_for_sample(avctx, "Sample depth %d is not supported.\n",
- alac->sample_size);
- return AVERROR_PATCHWELCOME;
- }
- avctx->bits_per_raw_sample = alac->sample_size;
-
- if (alac->channels < 1) {
- av_log(avctx, AV_LOG_WARNING, "Invalid channel count\n");
- alac->channels = avctx->channels;
- } else {
- if (alac->channels > ALAC_MAX_CHANNELS)
- alac->channels = avctx->channels;
- else
- avctx->channels = alac->channels;
- }
- if (avctx->channels > ALAC_MAX_CHANNELS || avctx->channels <= 0 ) {
- av_log(avctx, AV_LOG_ERROR, "Unsupported channel count: %d\n",
- avctx->channels);
- return AVERROR_PATCHWELCOME;
- }
- avctx->channel_layout = ff_alac_channel_layouts[alac->channels - 1];
-
- if ((ret = allocate_buffers(alac)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "Error allocating buffers\n");
- return ret;
- }
-
- return 0;
-}
-
-AVCodec ff_alac_decoder = {
- .name = "alac",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_ALAC,
- .priv_data_size = sizeof(ALACContext),
- .init = alac_decode_init,
- .close = alac_decode_close,
- .decode = alac_decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"),
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/alac_data.c b/src/thirdparty/ffmpeg/libavcodec/alac_data.c
deleted file mode 100644
index 0bcb06c07..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/alac_data.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * ALAC encoder and decoder common data
- *
- * 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 "alac_data.h"
-
-const uint8_t ff_alac_channel_layout_offsets[ALAC_MAX_CHANNELS][ALAC_MAX_CHANNELS] = {
- { 0 },
- { 0, 1 },
- { 2, 0, 1 },
- { 2, 0, 1, 3 },
- { 2, 0, 1, 3, 4 },
- { 2, 0, 1, 4, 5, 3 },
- { 2, 0, 1, 4, 5, 6, 3 },
- { 2, 6, 7, 0, 1, 4, 5, 3 }
-};
-
-const uint64_t ff_alac_channel_layouts[ALAC_MAX_CHANNELS + 1] = {
- AV_CH_LAYOUT_MONO,
- AV_CH_LAYOUT_STEREO,
- AV_CH_LAYOUT_SURROUND,
- AV_CH_LAYOUT_4POINT0,
- AV_CH_LAYOUT_5POINT0_BACK,
- AV_CH_LAYOUT_5POINT1_BACK,
- AV_CH_LAYOUT_6POINT1_BACK,
- AV_CH_LAYOUT_7POINT1_WIDE_BACK,
- 0
-};
-
-const enum AlacRawDataBlockType ff_alac_channel_elements[ALAC_MAX_CHANNELS][5] = {
- { TYPE_SCE, },
- { TYPE_CPE, },
- { TYPE_SCE, TYPE_CPE, },
- { TYPE_SCE, TYPE_CPE, TYPE_SCE },
- { TYPE_SCE, TYPE_CPE, TYPE_CPE, },
- { TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_SCE, },
- { TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_SCE, TYPE_SCE, },
- { TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_CPE, TYPE_SCE, },
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/alac_data.h b/src/thirdparty/ffmpeg/libavcodec/alac_data.h
deleted file mode 100644
index 650d6dcd1..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/alac_data.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * ALAC encoder and decoder common data
- *
- * 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_ALAC_DATA_H
-#define AVCODEC_ALAC_DATA_H
-
-#include <stdint.h>
-
-enum AlacRawDataBlockType {
- /* At the moment, only SCE, CPE, LFE, and END are recognized. */
- TYPE_SCE,
- TYPE_CPE,
- TYPE_CCE,
- TYPE_LFE,
- TYPE_DSE,
- TYPE_PCE,
- TYPE_FIL,
- TYPE_END
-};
-
-#define ALAC_MAX_CHANNELS 8
-
-extern const uint8_t ff_alac_channel_layout_offsets[ALAC_MAX_CHANNELS][ALAC_MAX_CHANNELS];
-
-extern const uint64_t ff_alac_channel_layouts[ALAC_MAX_CHANNELS + 1];
-
-extern const enum AlacRawDataBlockType ff_alac_channel_elements[ALAC_MAX_CHANNELS][5];
-
-#endif /* AVCODEC_ALAC_DATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/allcodecs.c b/src/thirdparty/ffmpeg/libavcodec/allcodecs.c
deleted file mode 100644
index 7a0864a7f..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/allcodecs.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Provide registration of all codecs, parsers and bitstream filters for libavcodec.
- * Copyright (c) 2002 Fabrice Bellard
- *
- * 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
- * Provide registration of all codecs, parsers and bitstream filters for libavcodec.
- */
-
-#include "avcodec.h"
-#include "config.h"
-
-#if HAVE_THREADS
-#include "thread.h"
-#endif
-
-#define REGISTER_ENCODER(X,x) { \
- extern AVCodec ff_##x##_encoder; \
- if(CONFIG_##X##_ENCODER) avcodec_register(&ff_##x##_encoder); }
-#define REGISTER_DECODER(X,x) { \
- extern AVCodec ff_##x##_decoder; \
- if(CONFIG_##X##_DECODER) avcodec_register(&ff_##x##_decoder); }
-#define REGISTER_ENCDEC(X,x) REGISTER_ENCODER(X,x); REGISTER_DECODER(X,x)
-
-#define REGISTER_PARSER(X,x) { \
- extern AVCodecParser ff_##x##_parser; \
- if(CONFIG_##X##_PARSER) av_register_codec_parser(&ff_##x##_parser); }
-
-void avcodec_register_all(void)
-{
- static int initialized;
-
- if (initialized)
- return;
- initialized = 1;
-
-#if HAVE_THREADS
- av_lockmgr_register(&ff_pthread_lockmgr_cb);
-#endif
-
- /* video codecs */
- REGISTER_DECODER (AMV, amv);
- REGISTER_DECODER (FLV, flv);
- REGISTER_DECODER (H263, h263);
- REGISTER_DECODER (H264, h264);
- REGISTER_DECODER (INDEO3, indeo3);
- REGISTER_DECODER (INDEO4, indeo4);
- REGISTER_DECODER (INDEO5, indeo5);
- REGISTER_DECODER (MJPEG, mjpeg);
- REGISTER_DECODER (MJPEGB, mjpegb);
- REGISTER_DECODER (MPEG2VIDEO, mpeg2video);
- REGISTER_DECODER (MPEG4, mpeg4);
- REGISTER_DECODER (MSMPEG4V1, msmpeg4v1);
- REGISTER_DECODER (MSMPEG4V2, msmpeg4v2);
- REGISTER_DECODER (MSMPEG4V3, msmpeg4v3);
- REGISTER_DECODER (RV10, rv10);
- REGISTER_DECODER (RV20, rv20);
- REGISTER_DECODER (RV30, rv30);
- REGISTER_DECODER (RV40, rv40);
- REGISTER_DECODER (SVQ1, svq1);
- REGISTER_DECODER (SVQ3, svq3);
- REGISTER_DECODER (THEORA, theora);
- REGISTER_DECODER (TSCC, tscc);
- REGISTER_DECODER (VC1, vc1);
- REGISTER_DECODER (VMNC, vmnc);
- REGISTER_DECODER (VP3, vp3);
- REGISTER_DECODER (VP5, vp5);
- REGISTER_DECODER (VP6, vp6);
- REGISTER_DECODER (VP6A, vp6a);
- REGISTER_DECODER (VP6F, vp6f);
- REGISTER_DECODER (VP8, vp8);
- REGISTER_DECODER (WMV1, wmv1);
- REGISTER_DECODER (WMV2, wmv2);
- REGISTER_DECODER (WMV3, wmv3);
-
- /* audio codecs */
- REGISTER_DECODER (AAC, aac);
- REGISTER_DECODER (AAC_LATM, aac_latm);
- REGISTER_DECODER (AC3, ac3);
- REGISTER_DECODER (ALAC, alac);
- REGISTER_DECODER (ALS, als);
- REGISTER_DECODER (ATRAC3, atrac3);
- REGISTER_DECODER (COOK, cook);
- REGISTER_DECODER (DCA, dca);
- REGISTER_DECODER (EAC3, eac3);
- REGISTER_DECODER (FLAC, flac);
- REGISTER_DECODER (MLP, mlp);
- REGISTER_DECODER (MP1FLOAT, mp1float);
- REGISTER_DECODER (MP2FLOAT, mp2float);
- REGISTER_DECODER (MP3FLOAT, mp3float);
- REGISTER_DECODER (NELLYMOSER, nellymoser);
- REGISTER_DECODER (RA_144, ra_144);
- REGISTER_DECODER (RA_288, ra_288);
- REGISTER_DECODER (SIPR, sipr);
- REGISTER_DECODER (TRUEHD, truehd);
- REGISTER_DECODER (VORBIS, vorbis);
- REGISTER_DECODER (AMRNB, amrnb);
- REGISTER_DECODER (AMRWB, amrwb);
-
- /* ADPCM codecs */
- REGISTER_DECODER (ADPCM_4XM, adpcm_4xm);
- REGISTER_DECODER (ADPCM_CT, adpcm_ct);
- REGISTER_DECODER (ADPCM_EA, adpcm_ea);
- REGISTER_DECODER (ADPCM_IMA_AMV, adpcm_ima_amv);
- REGISTER_DECODER (ADPCM_IMA_DK3, adpcm_ima_dk3);
- REGISTER_DECODER (ADPCM_IMA_DK4, adpcm_ima_dk4);
- REGISTER_DECODER (ADPCM_IMA_QT, adpcm_ima_qt);
- REGISTER_DECODER (ADPCM_IMA_SMJPEG, adpcm_ima_smjpeg);
- REGISTER_DECODER (ADPCM_IMA_WAV, adpcm_ima_wav);
- REGISTER_DECODER (ADPCM_IMA_WS, adpcm_ima_ws);
- REGISTER_DECODER (ADPCM_MS, adpcm_ms);
- REGISTER_DECODER (ADPCM_SBPRO_2, adpcm_sbpro_2);
- REGISTER_DECODER (ADPCM_SBPRO_3, adpcm_sbpro_3);
- REGISTER_DECODER (ADPCM_SBPRO_4, adpcm_sbpro_4);
- REGISTER_DECODER (ADPCM_SWF, adpcm_swf);
- REGISTER_DECODER (ADPCM_XA, adpcm_xa);
- REGISTER_DECODER (ADPCM_YAMAHA, adpcm_yamaha);
-
- /* parsers */
- REGISTER_PARSER (AAC_LATM, aac_latm);
- REGISTER_PARSER (AC3, ac3);
- REGISTER_PARSER (DCA, dca);
- REGISTER_PARSER (MLP, mlp);
- REGISTER_PARSER (MPEGAUDIO, mpegaudio);
- REGISTER_PARSER (H264, h264);
- REGISTER_PARSER (MPEGVIDEO, mpegvideo);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/alsdec.c b/src/thirdparty/ffmpeg/libavcodec/alsdec.c
deleted file mode 100644
index ec81f0650..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/alsdec.c
+++ /dev/null
@@ -1,1787 +0,0 @@
-/*
- * MPEG-4 ALS decoder
- * Copyright (c) 2009 Thilo Borgmann <thilo.borgmann _at_ googlemail.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
- * MPEG-4 ALS decoder
- * @author Thilo Borgmann <thilo.borgmann _at_ googlemail.com>
- */
-
-
-//#define DEBUG
-
-
-#include "avcodec.h"
-#include "get_bits.h"
-#include "unary.h"
-#include "mpeg4audio.h"
-#include "bytestream.h"
-#include "bgmc.h"
-#include "dsputil.h"
-#include "internal.h"
-#include "libavutil/samplefmt.h"
-#include "libavutil/crc.h"
-
-#include <stdint.h>
-
-/** Rice parameters and corresponding index offsets for decoding the
- * indices of scaled PARCOR values. The table chosen is set globally
- * by the encoder and stored in ALSSpecificConfig.
- */
-static const int8_t parcor_rice_table[3][20][2] = {
- { {-52, 4}, {-29, 5}, {-31, 4}, { 19, 4}, {-16, 4},
- { 12, 3}, { -7, 3}, { 9, 3}, { -5, 3}, { 6, 3},
- { -4, 3}, { 3, 3}, { -3, 2}, { 3, 2}, { -2, 2},
- { 3, 2}, { -1, 2}, { 2, 2}, { -1, 2}, { 2, 2} },
- { {-58, 3}, {-42, 4}, {-46, 4}, { 37, 5}, {-36, 4},
- { 29, 4}, {-29, 4}, { 25, 4}, {-23, 4}, { 20, 4},
- {-17, 4}, { 16, 4}, {-12, 4}, { 12, 3}, {-10, 4},
- { 7, 3}, { -4, 4}, { 3, 3}, { -1, 3}, { 1, 3} },
- { {-59, 3}, {-45, 5}, {-50, 4}, { 38, 4}, {-39, 4},
- { 32, 4}, {-30, 4}, { 25, 3}, {-23, 3}, { 20, 3},
- {-20, 3}, { 16, 3}, {-13, 3}, { 10, 3}, { -7, 3},
- { 3, 3}, { 0, 3}, { -1, 3}, { 2, 3}, { -1, 2} }
-};
-
-
-/** Scaled PARCOR values used for the first two PARCOR coefficients.
- * To be indexed by the Rice coded indices.
- * Generated by: parcor_scaled_values[i] = 32 + ((i * (i+1)) << 7) - (1 << 20)
- * Actual values are divided by 32 in order to be stored in 16 bits.
- */
-static const int16_t parcor_scaled_values[] = {
- -1048544 / 32, -1048288 / 32, -1047776 / 32, -1047008 / 32,
- -1045984 / 32, -1044704 / 32, -1043168 / 32, -1041376 / 32,
- -1039328 / 32, -1037024 / 32, -1034464 / 32, -1031648 / 32,
- -1028576 / 32, -1025248 / 32, -1021664 / 32, -1017824 / 32,
- -1013728 / 32, -1009376 / 32, -1004768 / 32, -999904 / 32,
- -994784 / 32, -989408 / 32, -983776 / 32, -977888 / 32,
- -971744 / 32, -965344 / 32, -958688 / 32, -951776 / 32,
- -944608 / 32, -937184 / 32, -929504 / 32, -921568 / 32,
- -913376 / 32, -904928 / 32, -896224 / 32, -887264 / 32,
- -878048 / 32, -868576 / 32, -858848 / 32, -848864 / 32,
- -838624 / 32, -828128 / 32, -817376 / 32, -806368 / 32,
- -795104 / 32, -783584 / 32, -771808 / 32, -759776 / 32,
- -747488 / 32, -734944 / 32, -722144 / 32, -709088 / 32,
- -695776 / 32, -682208 / 32, -668384 / 32, -654304 / 32,
- -639968 / 32, -625376 / 32, -610528 / 32, -595424 / 32,
- -580064 / 32, -564448 / 32, -548576 / 32, -532448 / 32,
- -516064 / 32, -499424 / 32, -482528 / 32, -465376 / 32,
- -447968 / 32, -430304 / 32, -412384 / 32, -394208 / 32,
- -375776 / 32, -357088 / 32, -338144 / 32, -318944 / 32,
- -299488 / 32, -279776 / 32, -259808 / 32, -239584 / 32,
- -219104 / 32, -198368 / 32, -177376 / 32, -156128 / 32,
- -134624 / 32, -112864 / 32, -90848 / 32, -68576 / 32,
- -46048 / 32, -23264 / 32, -224 / 32, 23072 / 32,
- 46624 / 32, 70432 / 32, 94496 / 32, 118816 / 32,
- 143392 / 32, 168224 / 32, 193312 / 32, 218656 / 32,
- 244256 / 32, 270112 / 32, 296224 / 32, 322592 / 32,
- 349216 / 32, 376096 / 32, 403232 / 32, 430624 / 32,
- 458272 / 32, 486176 / 32, 514336 / 32, 542752 / 32,
- 571424 / 32, 600352 / 32, 629536 / 32, 658976 / 32,
- 688672 / 32, 718624 / 32, 748832 / 32, 779296 / 32,
- 810016 / 32, 840992 / 32, 872224 / 32, 903712 / 32,
- 935456 / 32, 967456 / 32, 999712 / 32, 1032224 / 32
-};
-
-
-/** Gain values of p(0) for long-term prediction.
- * To be indexed by the Rice coded indices.
- */
-static const uint8_t ltp_gain_values [4][4] = {
- { 0, 8, 16, 24},
- {32, 40, 48, 56},
- {64, 70, 76, 82},
- {88, 92, 96, 100}
-};
-
-
-/** Inter-channel weighting factors for multi-channel correlation.
- * To be indexed by the Rice coded indices.
- */
-static const int16_t mcc_weightings[] = {
- 204, 192, 179, 166, 153, 140, 128, 115,
- 102, 89, 76, 64, 51, 38, 25, 12,
- 0, -12, -25, -38, -51, -64, -76, -89,
- -102, -115, -128, -140, -153, -166, -179, -192
-};
-
-
-/** Tail codes used in arithmetic coding using block Gilbert-Moore codes.
- */
-static const uint8_t tail_code[16][6] = {
- { 74, 44, 25, 13, 7, 3},
- { 68, 42, 24, 13, 7, 3},
- { 58, 39, 23, 13, 7, 3},
- {126, 70, 37, 19, 10, 5},
- {132, 70, 37, 20, 10, 5},
- {124, 70, 38, 20, 10, 5},
- {120, 69, 37, 20, 11, 5},
- {116, 67, 37, 20, 11, 5},
- {108, 66, 36, 20, 10, 5},
- {102, 62, 36, 20, 10, 5},
- { 88, 58, 34, 19, 10, 5},
- {162, 89, 49, 25, 13, 7},
- {156, 87, 49, 26, 14, 7},
- {150, 86, 47, 26, 14, 7},
- {142, 84, 47, 26, 14, 7},
- {131, 79, 46, 26, 14, 7}
-};
-
-
-enum RA_Flag {
- RA_FLAG_NONE,
- RA_FLAG_FRAMES,
- RA_FLAG_HEADER
-};
-
-
-typedef struct {
- uint32_t samples; ///< number of samples, 0xFFFFFFFF if unknown
- int resolution; ///< 000 = 8-bit; 001 = 16-bit; 010 = 24-bit; 011 = 32-bit
- int floating; ///< 1 = IEEE 32-bit floating-point, 0 = integer
- int msb_first; ///< 1 = original CRC calculated on big-endian system, 0 = little-endian
- int frame_length; ///< frame length for each frame (last frame may differ)
- int ra_distance; ///< distance between RA frames (in frames, 0...255)
- enum RA_Flag ra_flag; ///< indicates where the size of ra units is stored
- int adapt_order; ///< adaptive order: 1 = on, 0 = off
- int coef_table; ///< table index of Rice code parameters
- int long_term_prediction; ///< long term prediction (LTP): 1 = on, 0 = off
- int max_order; ///< maximum prediction order (0..1023)
- int block_switching; ///< number of block switching levels
- int bgmc; ///< "Block Gilbert-Moore Code": 1 = on, 0 = off (Rice coding only)
- int sb_part; ///< sub-block partition
- int joint_stereo; ///< joint stereo: 1 = on, 0 = off
- int mc_coding; ///< extended inter-channel coding (multi channel coding): 1 = on, 0 = off
- int chan_config; ///< indicates that a chan_config_info field is present
- int chan_sort; ///< channel rearrangement: 1 = on, 0 = off
- int rlslms; ///< use "Recursive Least Square-Least Mean Square" predictor: 1 = on, 0 = off
- int chan_config_info; ///< mapping of channels to loudspeaker locations. Unused until setting channel configuration is implemented.
- int *chan_pos; ///< original channel positions
- int crc_enabled; ///< enable Cyclic Redundancy Checksum
-} ALSSpecificConfig;
-
-
-typedef struct {
- int stop_flag;
- int master_channel;
- int time_diff_flag;
- int time_diff_sign;
- int time_diff_index;
- int weighting[6];
-} ALSChannelData;
-
-
-typedef struct {
- AVCodecContext *avctx;
- ALSSpecificConfig sconf;
- GetBitContext gb;
- DSPContext dsp;
- const AVCRC *crc_table;
- uint32_t crc_org; ///< CRC value of the original input data
- uint32_t crc; ///< CRC value calculated from decoded data
- unsigned int cur_frame_length; ///< length of the current frame to decode
- unsigned int frame_id; ///< the frame ID / number of the current frame
- unsigned int js_switch; ///< if true, joint-stereo decoding is enforced
- unsigned int cs_switch; ///< if true, channel rearrangement is done
- unsigned int num_blocks; ///< number of blocks used in the current frame
- unsigned int s_max; ///< maximum Rice parameter allowed in entropy coding
- uint8_t *bgmc_lut; ///< pointer at lookup tables used for BGMC
- int *bgmc_lut_status; ///< pointer at lookup table status flags used for BGMC
- int ltp_lag_length; ///< number of bits used for ltp lag value
- int *const_block; ///< contains const_block flags for all channels
- unsigned int *shift_lsbs; ///< contains shift_lsbs flags for all channels
- unsigned int *opt_order; ///< contains opt_order flags for all channels
- int *store_prev_samples; ///< contains store_prev_samples flags for all channels
- int *use_ltp; ///< contains use_ltp flags for all channels
- int *ltp_lag; ///< contains ltp lag values for all channels
- int **ltp_gain; ///< gain values for ltp 5-tap filter for a channel
- int *ltp_gain_buffer; ///< contains all gain values for ltp 5-tap filter
- int32_t **quant_cof; ///< quantized parcor coefficients for a channel
- int32_t *quant_cof_buffer; ///< contains all quantized parcor coefficients
- int32_t **lpc_cof; ///< coefficients of the direct form prediction filter for a channel
- int32_t *lpc_cof_buffer; ///< contains all coefficients of the direct form prediction filter
- int32_t *lpc_cof_reversed_buffer; ///< temporary buffer to set up a reversed versio of lpc_cof_buffer
- ALSChannelData **chan_data; ///< channel data for multi-channel correlation
- ALSChannelData *chan_data_buffer; ///< contains channel data for all channels
- int *reverted_channels; ///< stores a flag for each reverted channel
- int32_t *prev_raw_samples; ///< contains unshifted raw samples from the previous block
- int32_t **raw_samples; ///< decoded raw samples for each channel
- int32_t *raw_buffer; ///< contains all decoded raw samples including carryover samples
- uint8_t *crc_buffer; ///< buffer of byte order corrected samples used for CRC check
-} ALSDecContext;
-
-
-typedef struct {
- unsigned int block_length; ///< number of samples within the block
- unsigned int ra_block; ///< if true, this is a random access block
- int *const_block; ///< if true, this is a constant value block
- int js_blocks; ///< true if this block contains a difference signal
- unsigned int *shift_lsbs; ///< shift of values for this block
- unsigned int *opt_order; ///< prediction order of this block
- int *store_prev_samples;///< if true, carryover samples have to be stored
- int *use_ltp; ///< if true, long-term prediction is used
- int *ltp_lag; ///< lag value for long-term prediction
- int *ltp_gain; ///< gain values for ltp 5-tap filter
- int32_t *quant_cof; ///< quantized parcor coefficients
- int32_t *lpc_cof; ///< coefficients of the direct form prediction
- int32_t *raw_samples; ///< decoded raw samples / residuals for this block
- int32_t *prev_raw_samples; ///< contains unshifted raw samples from the previous block
- int32_t *raw_other; ///< decoded raw samples of the other channel of a channel pair
-} ALSBlockData;
-
-
-static av_cold void dprint_specific_config(ALSDecContext *ctx)
-{
-#ifdef DEBUG
- AVCodecContext *avctx = ctx->avctx;
- ALSSpecificConfig *sconf = &ctx->sconf;
-
- av_dlog(avctx, "resolution = %i\n", sconf->resolution);
- av_dlog(avctx, "floating = %i\n", sconf->floating);
- av_dlog(avctx, "frame_length = %i\n", sconf->frame_length);
- av_dlog(avctx, "ra_distance = %i\n", sconf->ra_distance);
- av_dlog(avctx, "ra_flag = %i\n", sconf->ra_flag);
- av_dlog(avctx, "adapt_order = %i\n", sconf->adapt_order);
- av_dlog(avctx, "coef_table = %i\n", sconf->coef_table);
- av_dlog(avctx, "long_term_prediction = %i\n", sconf->long_term_prediction);
- av_dlog(avctx, "max_order = %i\n", sconf->max_order);
- av_dlog(avctx, "block_switching = %i\n", sconf->block_switching);
- av_dlog(avctx, "bgmc = %i\n", sconf->bgmc);
- av_dlog(avctx, "sb_part = %i\n", sconf->sb_part);
- av_dlog(avctx, "joint_stereo = %i\n", sconf->joint_stereo);
- av_dlog(avctx, "mc_coding = %i\n", sconf->mc_coding);
- av_dlog(avctx, "chan_config = %i\n", sconf->chan_config);
- av_dlog(avctx, "chan_sort = %i\n", sconf->chan_sort);
- av_dlog(avctx, "RLSLMS = %i\n", sconf->rlslms);
- av_dlog(avctx, "chan_config_info = %i\n", sconf->chan_config_info);
-#endif
-}
-
-
-/** Read an ALSSpecificConfig from a buffer into the output struct.
- */
-static av_cold int read_specific_config(ALSDecContext *ctx)
-{
- GetBitContext gb;
- uint64_t ht_size;
- int i, config_offset;
- MPEG4AudioConfig m4ac;
- ALSSpecificConfig *sconf = &ctx->sconf;
- AVCodecContext *avctx = ctx->avctx;
- uint32_t als_id, header_size, trailer_size;
- int ret;
-
- if ((ret = init_get_bits8(&gb, avctx->extradata, avctx->extradata_size)) < 0)
- return ret;
-
- config_offset = avpriv_mpeg4audio_get_config(&m4ac, avctx->extradata,
- avctx->extradata_size * 8, 1);
-
- if (config_offset < 0)
- return -1;
-
- skip_bits_long(&gb, config_offset);
-
- if (get_bits_left(&gb) < (30 << 3))
- return -1;
-
- // read the fixed items
- als_id = get_bits_long(&gb, 32);
- avctx->sample_rate = m4ac.sample_rate;
- skip_bits_long(&gb, 32); // sample rate already known
- sconf->samples = get_bits_long(&gb, 32);
- avctx->channels = m4ac.channels;
- skip_bits(&gb, 16); // number of channels already known
- skip_bits(&gb, 3); // skip file_type
- sconf->resolution = get_bits(&gb, 3);
- sconf->floating = get_bits1(&gb);
- sconf->msb_first = get_bits1(&gb);
- sconf->frame_length = get_bits(&gb, 16) + 1;
- sconf->ra_distance = get_bits(&gb, 8);
- sconf->ra_flag = get_bits(&gb, 2);
- sconf->adapt_order = get_bits1(&gb);
- sconf->coef_table = get_bits(&gb, 2);
- sconf->long_term_prediction = get_bits1(&gb);
- sconf->max_order = get_bits(&gb, 10);
- sconf->block_switching = get_bits(&gb, 2);
- sconf->bgmc = get_bits1(&gb);
- sconf->sb_part = get_bits1(&gb);
- sconf->joint_stereo = get_bits1(&gb);
- sconf->mc_coding = get_bits1(&gb);
- sconf->chan_config = get_bits1(&gb);
- sconf->chan_sort = get_bits1(&gb);
- sconf->crc_enabled = get_bits1(&gb);
- sconf->rlslms = get_bits1(&gb);
- skip_bits(&gb, 5); // skip 5 reserved bits
- skip_bits1(&gb); // skip aux_data_enabled
-
-
- // check for ALSSpecificConfig struct
- if (als_id != MKBETAG('A','L','S','\0'))
- return -1;
-
- ctx->cur_frame_length = sconf->frame_length;
-
- // read channel config
- if (sconf->chan_config)
- sconf->chan_config_info = get_bits(&gb, 16);
- // TODO: use this to set avctx->channel_layout
-
-
- // read channel sorting
- if (sconf->chan_sort && avctx->channels > 1) {
- int chan_pos_bits = av_ceil_log2(avctx->channels);
- int bits_needed = avctx->channels * chan_pos_bits + 7;
- if (get_bits_left(&gb) < bits_needed)
- return -1;
-
- if (!(sconf->chan_pos = av_malloc(avctx->channels * sizeof(*sconf->chan_pos))))
- return AVERROR(ENOMEM);
-
- ctx->cs_switch = 1;
-
- for (i = 0; i < avctx->channels; i++) {
- int idx;
-
- idx = get_bits(&gb, chan_pos_bits);
- if (idx >= avctx->channels) {
- av_log(avctx, AV_LOG_WARNING, "Invalid channel reordering.\n");
- ctx->cs_switch = 0;
- break;
- }
- sconf->chan_pos[idx] = i;
- }
-
- align_get_bits(&gb);
- }
-
-
- // read fixed header and trailer sizes,
- // if size = 0xFFFFFFFF then there is no data field!
- if (get_bits_left(&gb) < 64)
- return -1;
-
- header_size = get_bits_long(&gb, 32);
- trailer_size = get_bits_long(&gb, 32);
- if (header_size == 0xFFFFFFFF)
- header_size = 0;
- if (trailer_size == 0xFFFFFFFF)
- trailer_size = 0;
-
- ht_size = ((int64_t)(header_size) + (int64_t)(trailer_size)) << 3;
-
-
- // skip the header and trailer data
- if (get_bits_left(&gb) < ht_size)
- return -1;
-
- if (ht_size > INT32_MAX)
- return -1;
-
- skip_bits_long(&gb, ht_size);
-
-
- // initialize CRC calculation
- if (sconf->crc_enabled) {
- if (get_bits_left(&gb) < 32)
- return -1;
-
- if (avctx->err_recognition & (AV_EF_CRCCHECK|AV_EF_CAREFUL)) {
- ctx->crc_table = av_crc_get_table(AV_CRC_32_IEEE_LE);
- ctx->crc = 0xFFFFFFFF;
- ctx->crc_org = ~get_bits_long(&gb, 32);
- } else
- skip_bits_long(&gb, 32);
- }
-
-
- // no need to read the rest of ALSSpecificConfig (ra_unit_size & aux data)
-
- dprint_specific_config(ctx);
-
- return 0;
-}
-
-
-/** Check the ALSSpecificConfig for unsupported features.
- */
-static int check_specific_config(ALSDecContext *ctx)
-{
- ALSSpecificConfig *sconf = &ctx->sconf;
- int error = 0;
-
- // report unsupported feature and set error value
- #define MISSING_ERR(cond, str, errval) \
- { \
- if (cond) { \
- av_log_missing_feature(ctx->avctx, str, 0); \
- error = errval; \
- } \
- }
-
- MISSING_ERR(sconf->floating, "Floating point decoding", AVERROR_PATCHWELCOME);
- MISSING_ERR(sconf->rlslms, "Adaptive RLS-LMS prediction", AVERROR_PATCHWELCOME);
-
- return error;
-}
-
-
-/** Parse the bs_info field to extract the block partitioning used in
- * block switching mode, refer to ISO/IEC 14496-3, section 11.6.2.
- */
-static void parse_bs_info(const uint32_t bs_info, unsigned int n,
- unsigned int div, unsigned int **div_blocks,
- unsigned int *num_blocks)
-{
- if (n < 31 && ((bs_info << n) & 0x40000000)) {
- // if the level is valid and the investigated bit n is set
- // then recursively check both children at bits (2n+1) and (2n+2)
- n *= 2;
- div += 1;
- parse_bs_info(bs_info, n + 1, div, div_blocks, num_blocks);
- parse_bs_info(bs_info, n + 2, div, div_blocks, num_blocks);
- } else {
- // else the bit is not set or the last level has been reached
- // (bit implicitly not set)
- **div_blocks = div;
- (*div_blocks)++;
- (*num_blocks)++;
- }
-}
-
-
-/** Read and decode a Rice codeword.
- */
-static int32_t decode_rice(GetBitContext *gb, unsigned int k)
-{
- int max = get_bits_left(gb) - k;
- int q = get_unary(gb, 0, max);
- int r = k ? get_bits1(gb) : !(q & 1);
-
- if (k > 1) {
- q <<= (k - 1);
- q += get_bits_long(gb, k - 1);
- } else if (!k) {
- q >>= 1;
- }
- return r ? q : ~q;
-}
-
-
-/** Convert PARCOR coefficient k to direct filter coefficient.
- */
-static void parcor_to_lpc(unsigned int k, const int32_t *par, int32_t *cof)
-{
- int i, j;
-
- for (i = 0, j = k - 1; i < j; i++, j--) {
- int tmp1 = ((MUL64(par[k], cof[j]) + (1 << 19)) >> 20);
- cof[j] += ((MUL64(par[k], cof[i]) + (1 << 19)) >> 20);
- cof[i] += tmp1;
- }
- if (i == j)
- cof[i] += ((MUL64(par[k], cof[j]) + (1 << 19)) >> 20);
-
- cof[k] = par[k];
-}
-
-
-/** Read block switching field if necessary and set actual block sizes.
- * Also assure that the block sizes of the last frame correspond to the
- * actual number of samples.
- */
-static void get_block_sizes(ALSDecContext *ctx, unsigned int *div_blocks,
- uint32_t *bs_info)
-{
- ALSSpecificConfig *sconf = &ctx->sconf;
- GetBitContext *gb = &ctx->gb;
- unsigned int *ptr_div_blocks = div_blocks;
- unsigned int b;
-
- if (sconf->block_switching) {
- unsigned int bs_info_len = 1 << (sconf->block_switching + 2);
- *bs_info = get_bits_long(gb, bs_info_len);
- *bs_info <<= (32 - bs_info_len);
- }
-
- ctx->num_blocks = 0;
- parse_bs_info(*bs_info, 0, 0, &ptr_div_blocks, &ctx->num_blocks);
-
- // The last frame may have an overdetermined block structure given in
- // the bitstream. In that case the defined block structure would need
- // more samples than available to be consistent.
- // The block structure is actually used but the block sizes are adapted
- // to fit the actual number of available samples.
- // Example: 5 samples, 2nd level block sizes: 2 2 2 2.
- // This results in the actual block sizes: 2 2 1 0.
- // This is not specified in 14496-3 but actually done by the reference
- // codec RM22 revision 2.
- // This appears to happen in case of an odd number of samples in the last
- // frame which is actually not allowed by the block length switching part
- // of 14496-3.
- // The ALS conformance files feature an odd number of samples in the last
- // frame.
-
- for (b = 0; b < ctx->num_blocks; b++)
- div_blocks[b] = ctx->sconf.frame_length >> div_blocks[b];
-
- if (ctx->cur_frame_length != ctx->sconf.frame_length) {
- unsigned int remaining = ctx->cur_frame_length;
-
- for (b = 0; b < ctx->num_blocks; b++) {
- if (remaining <= div_blocks[b]) {
- div_blocks[b] = remaining;
- ctx->num_blocks = b + 1;
- break;
- }
-
- remaining -= div_blocks[b];
- }
- }
-}
-
-
-/** Read the block data for a constant block
- */
-static int read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
-{
- ALSSpecificConfig *sconf = &ctx->sconf;
- AVCodecContext *avctx = ctx->avctx;
- GetBitContext *gb = &ctx->gb;
-
- if (bd->block_length <= 0)
- return AVERROR_INVALIDDATA;
-
- *bd->raw_samples = 0;
- *bd->const_block = get_bits1(gb); // 1 = constant value, 0 = zero block (silence)
- bd->js_blocks = get_bits1(gb);
-
- // skip 5 reserved bits
- skip_bits(gb, 5);
-
- if (*bd->const_block) {
- unsigned int const_val_bits = sconf->floating ? 24 : avctx->bits_per_raw_sample;
- *bd->raw_samples = get_sbits_long(gb, const_val_bits);
- }
-
- // ensure constant block decoding by reusing this field
- *bd->const_block = 1;
-
- return 0;
-}
-
-
-/** Decode the block data for a constant block
- */
-static void decode_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
-{
- int smp = bd->block_length - 1;
- int32_t val = *bd->raw_samples;
- int32_t *dst = bd->raw_samples + 1;
-
- // write raw samples into buffer
- for (; smp; smp--)
- *dst++ = val;
-}
-
-
-/** Read the block data for a non-constant block
- */
-static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
-{
- ALSSpecificConfig *sconf = &ctx->sconf;
- AVCodecContext *avctx = ctx->avctx;
- GetBitContext *gb = &ctx->gb;
- unsigned int k;
- unsigned int s[8];
- unsigned int sx[8];
- unsigned int sub_blocks, log2_sub_blocks, sb_length;
- unsigned int start = 0;
- unsigned int opt_order;
- int sb;
- int32_t *quant_cof = bd->quant_cof;
- int32_t *current_res;
-
-
- // ensure variable block decoding by reusing this field
- *bd->const_block = 0;
-
- *bd->opt_order = 1;
- bd->js_blocks = get_bits1(gb);
-
- opt_order = *bd->opt_order;
-
- // determine the number of subblocks for entropy decoding
- if (!sconf->bgmc && !sconf->sb_part) {
- log2_sub_blocks = 0;
- } else {
- if (sconf->bgmc && sconf->sb_part)
- log2_sub_blocks = get_bits(gb, 2);
- else
- log2_sub_blocks = 2 * get_bits1(gb);
- }
-
- sub_blocks = 1 << log2_sub_blocks;
-
- // do not continue in case of a damaged stream since
- // block_length must be evenly divisible by sub_blocks
- if (bd->block_length & (sub_blocks - 1)) {
- av_log(avctx, AV_LOG_WARNING,
- "Block length is not evenly divisible by the number of subblocks.\n");
- return -1;
- }
-
- sb_length = bd->block_length >> log2_sub_blocks;
-
- if (sconf->bgmc) {
- s[0] = get_bits(gb, 8 + (sconf->resolution > 1));
- for (k = 1; k < sub_blocks; k++)
- s[k] = s[k - 1] + decode_rice(gb, 2);
-
- for (k = 0; k < sub_blocks; k++) {
- sx[k] = s[k] & 0x0F;
- s [k] >>= 4;
- }
- } else {
- s[0] = get_bits(gb, 4 + (sconf->resolution > 1));
- for (k = 1; k < sub_blocks; k++)
- s[k] = s[k - 1] + decode_rice(gb, 0);
- }
- for (k = 1; k < sub_blocks; k++)
- if (s[k] > 32) {
- av_log(avctx, AV_LOG_ERROR, "k invalid for rice code.\n");
- return AVERROR_INVALIDDATA;
- }
-
- if (get_bits1(gb))
- *bd->shift_lsbs = get_bits(gb, 4) + 1;
-
- *bd->store_prev_samples = (bd->js_blocks && bd->raw_other) || *bd->shift_lsbs;
-
-
- if (!sconf->rlslms) {
- if (sconf->adapt_order) {
- int opt_order_length = av_ceil_log2(av_clip((bd->block_length >> 3) - 1,
- 2, sconf->max_order + 1));
- *bd->opt_order = get_bits(gb, opt_order_length);
- if (*bd->opt_order > sconf->max_order) {
- *bd->opt_order = sconf->max_order;
- av_log(avctx, AV_LOG_ERROR, "Predictor order too large.\n");
- return AVERROR_INVALIDDATA;
- }
- } else {
- *bd->opt_order = sconf->max_order;
- }
-
- opt_order = *bd->opt_order;
-
- if (opt_order) {
- int add_base;
-
- if (sconf->coef_table == 3) {
- add_base = 0x7F;
-
- // read coefficient 0
- quant_cof[0] = 32 * parcor_scaled_values[get_bits(gb, 7)];
-
- // read coefficient 1
- if (opt_order > 1)
- quant_cof[1] = -32 * parcor_scaled_values[get_bits(gb, 7)];
-
- // read coefficients 2 to opt_order
- for (k = 2; k < opt_order; k++)
- quant_cof[k] = get_bits(gb, 7);
- } else {
- int k_max;
- add_base = 1;
-
- // read coefficient 0 to 19
- k_max = FFMIN(opt_order, 20);
- for (k = 0; k < k_max; k++) {
- int rice_param = parcor_rice_table[sconf->coef_table][k][1];
- 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]);
- return AVERROR_INVALIDDATA;
- }
- }
-
- // read coefficients 20 to 126
- k_max = FFMIN(opt_order, 127);
- for (; k < k_max; k++)
- quant_cof[k] = decode_rice(gb, 2) + (k & 1);
-
- // read coefficients 127 to opt_order
- for (; k < opt_order; k++)
- quant_cof[k] = decode_rice(gb, 1);
-
- quant_cof[0] = 32 * parcor_scaled_values[quant_cof[0] + 64];
-
- if (opt_order > 1)
- quant_cof[1] = -32 * parcor_scaled_values[quant_cof[1] + 64];
- }
-
- for (k = 2; k < opt_order; k++)
- quant_cof[k] = (quant_cof[k] << 14) + (add_base << 13);
- }
- }
-
- // read LTP gain and lag values
- if (sconf->long_term_prediction) {
- *bd->use_ltp = get_bits1(gb);
-
- if (*bd->use_ltp) {
- int r, c;
-
- bd->ltp_gain[0] = decode_rice(gb, 1) << 3;
- bd->ltp_gain[1] = decode_rice(gb, 2) << 3;
-
- r = get_unary(gb, 0, 3);
- c = get_bits(gb, 2);
- bd->ltp_gain[2] = ltp_gain_values[r][c];
-
- bd->ltp_gain[3] = decode_rice(gb, 2) << 3;
- bd->ltp_gain[4] = decode_rice(gb, 1) << 3;
-
- *bd->ltp_lag = get_bits(gb, ctx->ltp_lag_length);
- *bd->ltp_lag += FFMAX(4, opt_order + 1);
- }
- }
-
- // read first value and residuals in case of a random access block
- if (bd->ra_block) {
- if (opt_order)
- bd->raw_samples[0] = decode_rice(gb, avctx->bits_per_raw_sample - 4);
- if (opt_order > 1)
- bd->raw_samples[1] = decode_rice(gb, FFMIN(s[0] + 3, ctx->s_max));
- if (opt_order > 2)
- bd->raw_samples[2] = decode_rice(gb, FFMIN(s[0] + 1, ctx->s_max));
-
- start = FFMIN(opt_order, 3);
- }
-
- // read all residuals
- if (sconf->bgmc) {
- int delta[8];
- unsigned int k [8];
- unsigned int b = av_clip((av_ceil_log2(bd->block_length) - 3) >> 1, 0, 5);
-
- // read most significant bits
- unsigned int high;
- unsigned int low;
- unsigned int value;
-
- ff_bgmc_decode_init(gb, &high, &low, &value);
-
- current_res = bd->raw_samples + start;
-
- for (sb = 0; sb < sub_blocks; sb++) {
- unsigned int sb_len = sb_length - (sb ? 0 : start);
-
- k [sb] = s[sb] > b ? s[sb] - b : 0;
- delta[sb] = 5 - s[sb] + k[sb];
-
- ff_bgmc_decode(gb, sb_len, current_res,
- delta[sb], sx[sb], &high, &low, &value, ctx->bgmc_lut, ctx->bgmc_lut_status);
-
- current_res += sb_len;
- }
-
- ff_bgmc_decode_end(gb);
-
-
- // read least significant bits and tails
- current_res = bd->raw_samples + start;
-
- for (sb = 0; sb < sub_blocks; sb++, start = 0) {
- unsigned int cur_tail_code = tail_code[sx[sb]][delta[sb]];
- unsigned int cur_k = k[sb];
- unsigned int cur_s = s[sb];
-
- for (; start < sb_length; start++) {
- int32_t res = *current_res;
-
- if (res == cur_tail_code) {
- unsigned int max_msb = (2 + (sx[sb] > 2) + (sx[sb] > 10))
- << (5 - delta[sb]);
-
- res = decode_rice(gb, cur_s);
-
- if (res >= 0) {
- res += (max_msb ) << cur_k;
- } else {
- res -= (max_msb - 1) << cur_k;
- }
- } else {
- if (res > cur_tail_code)
- res--;
-
- if (res & 1)
- res = -res;
-
- res >>= 1;
-
- if (cur_k) {
- res <<= cur_k;
- res |= get_bits_long(gb, cur_k);
- }
- }
-
- *current_res++ = res;
- }
- }
- } else {
- current_res = bd->raw_samples + start;
-
- for (sb = 0; sb < sub_blocks; sb++, start = 0)
- for (; start < sb_length; start++)
- *current_res++ = decode_rice(gb, s[sb]);
- }
-
- if (!sconf->mc_coding || ctx->js_switch)
- align_get_bits(gb);
-
- return 0;
-}
-
-
-/** Decode the block data for a non-constant block
- */
-static int decode_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
-{
- ALSSpecificConfig *sconf = &ctx->sconf;
- unsigned int block_length = bd->block_length;
- unsigned int smp = 0;
- unsigned int k;
- int opt_order = *bd->opt_order;
- int sb;
- int64_t y;
- int32_t *quant_cof = bd->quant_cof;
- int32_t *lpc_cof = bd->lpc_cof;
- int32_t *raw_samples = bd->raw_samples;
- int32_t *raw_samples_end = bd->raw_samples + bd->block_length;
- int32_t *lpc_cof_reversed = ctx->lpc_cof_reversed_buffer;
-
- // reverse long-term prediction
- if (*bd->use_ltp) {
- int ltp_smp;
-
- for (ltp_smp = FFMAX(*bd->ltp_lag - 2, 0); ltp_smp < block_length; ltp_smp++) {
- int center = ltp_smp - *bd->ltp_lag;
- int begin = FFMAX(0, center - 2);
- int end = center + 3;
- int tab = 5 - (end - begin);
- int base;
-
- y = 1 << 6;
-
- for (base = begin; base < end; base++, tab++)
- y += MUL64(bd->ltp_gain[tab], raw_samples[base]);
-
- raw_samples[ltp_smp] += y >> 7;
- }
- }
-
- // reconstruct all samples from residuals
- if (bd->ra_block) {
- for (smp = 0; smp < opt_order; smp++) {
- y = 1 << 19;
-
- for (sb = 0; sb < smp; sb++)
- y += MUL64(lpc_cof[sb], raw_samples[-(sb + 1)]);
-
- *raw_samples++ -= y >> 20;
- parcor_to_lpc(smp, quant_cof, lpc_cof);
- }
- } else {
- for (k = 0; k < opt_order; k++)
- parcor_to_lpc(k, quant_cof, lpc_cof);
-
- // store previous samples in case that they have to be altered
- if (*bd->store_prev_samples)
- memcpy(bd->prev_raw_samples, raw_samples - sconf->max_order,
- sizeof(*bd->prev_raw_samples) * sconf->max_order);
-
- // reconstruct difference signal for prediction (joint-stereo)
- if (bd->js_blocks && bd->raw_other) {
- int32_t *left, *right;
-
- if (bd->raw_other > raw_samples) { // D = R - L
- left = raw_samples;
- right = bd->raw_other;
- } else { // D = R - L
- left = bd->raw_other;
- right = raw_samples;
- }
-
- for (sb = -1; sb >= -sconf->max_order; sb--)
- raw_samples[sb] = right[sb] - left[sb];
- }
-
- // reconstruct shifted signal
- if (*bd->shift_lsbs)
- for (sb = -1; sb >= -sconf->max_order; sb--)
- raw_samples[sb] >>= *bd->shift_lsbs;
- }
-
- // reverse linear prediction coefficients for efficiency
- lpc_cof = lpc_cof + opt_order;
-
- for (sb = 0; sb < opt_order; sb++)
- lpc_cof_reversed[sb] = lpc_cof[-(sb + 1)];
-
- // reconstruct raw samples
- raw_samples = bd->raw_samples + smp;
- lpc_cof = lpc_cof_reversed + opt_order;
-
- for (; raw_samples < raw_samples_end; raw_samples++) {
- y = 1 << 19;
-
- for (sb = -opt_order; sb < 0; sb++)
- y += MUL64(lpc_cof[sb], raw_samples[sb]);
-
- *raw_samples -= y >> 20;
- }
-
- raw_samples = bd->raw_samples;
-
- // restore previous samples in case that they have been altered
- if (*bd->store_prev_samples)
- memcpy(raw_samples - sconf->max_order, bd->prev_raw_samples,
- sizeof(*raw_samples) * sconf->max_order);
-
- return 0;
-}
-
-
-/** Read the block data.
- */
-static int read_block(ALSDecContext *ctx, ALSBlockData *bd)
-{
- GetBitContext *gb = &ctx->gb;
- int ret;
-
- *bd->shift_lsbs = 0;
- // read block type flag and read the samples accordingly
- if (get_bits1(gb)) {
- if ((ret = read_var_block_data(ctx, bd)) < 0)
- return ret;
- } else {
- if ((ret = read_const_block_data(ctx, bd)) < 0)
- return ret;
- }
-
- return 0;
-}
-
-
-/** Decode the block data.
- */
-static int decode_block(ALSDecContext *ctx, ALSBlockData *bd)
-{
- unsigned int smp;
-
- // read block type flag and read the samples accordingly
- if (*bd->const_block)
- decode_const_block_data(ctx, bd);
- else if (decode_var_block_data(ctx, bd))
- return -1;
-
- // TODO: read RLSLMS extension data
-
- if (*bd->shift_lsbs)
- for (smp = 0; smp < bd->block_length; smp++)
- bd->raw_samples[smp] <<= *bd->shift_lsbs;
-
- return 0;
-}
-
-
-/** Read and decode block data successively.
- */
-static int read_decode_block(ALSDecContext *ctx, ALSBlockData *bd)
-{
- int ret;
-
- ret = read_block(ctx, bd);
-
- if (ret)
- return ret;
-
- ret = decode_block(ctx, bd);
-
- return ret;
-}
-
-
-/** Compute the number of samples left to decode for the current frame and
- * sets these samples to zero.
- */
-static void zero_remaining(unsigned int b, unsigned int b_max,
- const unsigned int *div_blocks, int32_t *buf)
-{
- unsigned int count = 0;
-
- while (b < b_max)
- count += div_blocks[b++];
-
- if (count)
- memset(buf, 0, sizeof(*buf) * count);
-}
-
-
-/** Decode blocks independently.
- */
-static int decode_blocks_ind(ALSDecContext *ctx, unsigned int ra_frame,
- unsigned int c, const unsigned int *div_blocks,
- unsigned int *js_blocks)
-{
- unsigned int b;
- ALSBlockData bd = { 0 };
-
- bd.ra_block = ra_frame;
- bd.const_block = ctx->const_block;
- bd.shift_lsbs = ctx->shift_lsbs;
- bd.opt_order = ctx->opt_order;
- bd.store_prev_samples = ctx->store_prev_samples;
- bd.use_ltp = ctx->use_ltp;
- bd.ltp_lag = ctx->ltp_lag;
- bd.ltp_gain = ctx->ltp_gain[0];
- bd.quant_cof = ctx->quant_cof[0];
- bd.lpc_cof = ctx->lpc_cof[0];
- bd.prev_raw_samples = ctx->prev_raw_samples;
- bd.raw_samples = ctx->raw_samples[c];
-
-
- for (b = 0; b < ctx->num_blocks; b++) {
- bd.block_length = div_blocks[b];
-
- if (read_decode_block(ctx, &bd)) {
- // damaged block, write zero for the rest of the frame
- zero_remaining(b, ctx->num_blocks, div_blocks, bd.raw_samples);
- return -1;
- }
- bd.raw_samples += div_blocks[b];
- bd.ra_block = 0;
- }
-
- return 0;
-}
-
-
-/** Decode blocks dependently.
- */
-static int decode_blocks(ALSDecContext *ctx, unsigned int ra_frame,
- unsigned int c, const unsigned int *div_blocks,
- unsigned int *js_blocks)
-{
- ALSSpecificConfig *sconf = &ctx->sconf;
- unsigned int offset = 0;
- unsigned int b;
- ALSBlockData bd[2] = { { 0 } };
-
- bd[0].ra_block = ra_frame;
- bd[0].const_block = ctx->const_block;
- bd[0].shift_lsbs = ctx->shift_lsbs;
- bd[0].opt_order = ctx->opt_order;
- bd[0].store_prev_samples = ctx->store_prev_samples;
- bd[0].use_ltp = ctx->use_ltp;
- bd[0].ltp_lag = ctx->ltp_lag;
- bd[0].ltp_gain = ctx->ltp_gain[0];
- bd[0].quant_cof = ctx->quant_cof[0];
- bd[0].lpc_cof = ctx->lpc_cof[0];
- bd[0].prev_raw_samples = ctx->prev_raw_samples;
- bd[0].js_blocks = *js_blocks;
-
- bd[1].ra_block = ra_frame;
- bd[1].const_block = ctx->const_block;
- bd[1].shift_lsbs = ctx->shift_lsbs;
- bd[1].opt_order = ctx->opt_order;
- bd[1].store_prev_samples = ctx->store_prev_samples;
- bd[1].use_ltp = ctx->use_ltp;
- bd[1].ltp_lag = ctx->ltp_lag;
- bd[1].ltp_gain = ctx->ltp_gain[0];
- bd[1].quant_cof = ctx->quant_cof[0];
- bd[1].lpc_cof = ctx->lpc_cof[0];
- bd[1].prev_raw_samples = ctx->prev_raw_samples;
- bd[1].js_blocks = *(js_blocks + 1);
-
- // decode all blocks
- for (b = 0; b < ctx->num_blocks; b++) {
- unsigned int s;
-
- bd[0].block_length = div_blocks[b];
- bd[1].block_length = div_blocks[b];
-
- bd[0].raw_samples = ctx->raw_samples[c ] + offset;
- bd[1].raw_samples = ctx->raw_samples[c + 1] + offset;
-
- bd[0].raw_other = bd[1].raw_samples;
- bd[1].raw_other = bd[0].raw_samples;
-
- if(read_decode_block(ctx, &bd[0]) || read_decode_block(ctx, &bd[1])) {
- // damaged block, write zero for the rest of the frame
- zero_remaining(b, ctx->num_blocks, div_blocks, bd[0].raw_samples);
- zero_remaining(b, ctx->num_blocks, div_blocks, bd[1].raw_samples);
- return -1;
- }
-
- // reconstruct joint-stereo blocks
- if (bd[0].js_blocks) {
- if (bd[1].js_blocks)
- av_log(ctx->avctx, AV_LOG_WARNING, "Invalid channel pair.\n");
-
- for (s = 0; s < div_blocks[b]; s++)
- bd[0].raw_samples[s] = bd[1].raw_samples[s] - bd[0].raw_samples[s];
- } else if (bd[1].js_blocks) {
- for (s = 0; s < div_blocks[b]; s++)
- bd[1].raw_samples[s] = bd[1].raw_samples[s] + bd[0].raw_samples[s];
- }
-
- offset += div_blocks[b];
- bd[0].ra_block = 0;
- bd[1].ra_block = 0;
- }
-
- // store carryover raw samples,
- // the others channel raw samples are stored by the calling function.
- memmove(ctx->raw_samples[c] - sconf->max_order,
- ctx->raw_samples[c] - sconf->max_order + sconf->frame_length,
- sizeof(*ctx->raw_samples[c]) * sconf->max_order);
-
- return 0;
-}
-
-
-/** Read the channel data.
- */
-static int read_channel_data(ALSDecContext *ctx, ALSChannelData *cd, int c)
-{
- GetBitContext *gb = &ctx->gb;
- ALSChannelData *current = cd;
- unsigned int channels = ctx->avctx->channels;
- int entries = 0;
-
- while (entries < channels && !(current->stop_flag = get_bits1(gb))) {
- current->master_channel = get_bits_long(gb, av_ceil_log2(channels));
-
- if (current->master_channel >= channels) {
- av_log(ctx->avctx, AV_LOG_ERROR, "Invalid master channel.\n");
- return -1;
- }
-
- if (current->master_channel != c) {
- current->time_diff_flag = get_bits1(gb);
- current->weighting[0] = mcc_weightings[av_clip(decode_rice(gb, 1) + 16, 0, 31)];
- current->weighting[1] = mcc_weightings[av_clip(decode_rice(gb, 2) + 14, 0, 31)];
- current->weighting[2] = mcc_weightings[av_clip(decode_rice(gb, 1) + 16, 0, 31)];
-
- if (current->time_diff_flag) {
- current->weighting[3] = mcc_weightings[av_clip(decode_rice(gb, 1) + 16, 0, 31)];
- current->weighting[4] = mcc_weightings[av_clip(decode_rice(gb, 1) + 16, 0, 31)];
- current->weighting[5] = mcc_weightings[av_clip(decode_rice(gb, 1) + 16, 0, 31)];
-
- current->time_diff_sign = get_bits1(gb);
- current->time_diff_index = get_bits(gb, ctx->ltp_lag_length - 3) + 3;
- }
- }
-
- current++;
- entries++;
- }
-
- if (entries == channels) {
- av_log(ctx->avctx, AV_LOG_ERROR, "Damaged channel data.\n");
- return -1;
- }
-
- align_get_bits(gb);
- return 0;
-}
-
-
-/** Recursively reverts the inter-channel correlation for a block.
- */
-static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd,
- ALSChannelData **cd, int *reverted,
- unsigned int offset, int c)
-{
- ALSChannelData *ch = cd[c];
- unsigned int dep = 0;
- unsigned int channels = ctx->avctx->channels;
-
- if (reverted[c])
- return 0;
-
- reverted[c] = 1;
-
- while (dep < channels && !ch[dep].stop_flag) {
- revert_channel_correlation(ctx, bd, cd, reverted, offset,
- ch[dep].master_channel);
-
- dep++;
- }
-
- if (dep == channels) {
- av_log(ctx->avctx, AV_LOG_WARNING, "Invalid channel correlation.\n");
- return -1;
- }
-
- bd->const_block = ctx->const_block + c;
- bd->shift_lsbs = ctx->shift_lsbs + c;
- bd->opt_order = ctx->opt_order + c;
- bd->store_prev_samples = ctx->store_prev_samples + c;
- bd->use_ltp = ctx->use_ltp + c;
- bd->ltp_lag = ctx->ltp_lag + c;
- bd->ltp_gain = ctx->ltp_gain[c];
- bd->lpc_cof = ctx->lpc_cof[c];
- bd->quant_cof = ctx->quant_cof[c];
- bd->raw_samples = ctx->raw_samples[c] + offset;
-
- dep = 0;
- while (!ch[dep].stop_flag) {
- 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].time_diff_flag) {
- int t = ch[dep].time_diff_index;
-
- if (ch[dep].time_diff_sign) {
- t = -t;
- begin -= t;
- } else {
- end -= t;
- }
-
- for (smp = begin; smp < end; smp++) {
- y = (1 << 6) +
- MUL64(ch[dep].weighting[0], master[smp - 1 ]) +
- MUL64(ch[dep].weighting[1], master[smp ]) +
- MUL64(ch[dep].weighting[2], master[smp + 1 ]) +
- MUL64(ch[dep].weighting[3], master[smp - 1 + t]) +
- MUL64(ch[dep].weighting[4], master[smp + t]) +
- MUL64(ch[dep].weighting[5], master[smp + 1 + t]);
-
- bd->raw_samples[smp] += y >> 7;
- }
- } else {
- for (smp = begin; smp < end; smp++) {
- y = (1 << 6) +
- MUL64(ch[dep].weighting[0], master[smp - 1]) +
- MUL64(ch[dep].weighting[1], master[smp ]) +
- MUL64(ch[dep].weighting[2], master[smp + 1]);
-
- bd->raw_samples[smp] += y >> 7;
- }
- }
-
- dep++;
- }
-
- return 0;
-}
-
-
-/** Read the frame data.
- */
-static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
-{
- ALSSpecificConfig *sconf = &ctx->sconf;
- AVCodecContext *avctx = ctx->avctx;
- GetBitContext *gb = &ctx->gb;
- unsigned int div_blocks[32]; ///< block sizes.
- unsigned int c;
- unsigned int js_blocks[2];
-
- uint32_t bs_info = 0;
-
- // skip the size of the ra unit if present in the frame
- if (sconf->ra_flag == RA_FLAG_FRAMES && ra_frame)
- skip_bits_long(gb, 32);
-
- if (sconf->mc_coding && sconf->joint_stereo) {
- ctx->js_switch = get_bits1(gb);
- align_get_bits(gb);
- }
-
- if (!sconf->mc_coding || ctx->js_switch) {
- int independent_bs = !sconf->joint_stereo;
-
- for (c = 0; c < avctx->channels; c++) {
- js_blocks[0] = 0;
- js_blocks[1] = 0;
-
- get_block_sizes(ctx, div_blocks, &bs_info);
-
- // if joint_stereo and block_switching is set, independent decoding
- // is signaled via the first bit of bs_info
- if (sconf->joint_stereo && sconf->block_switching)
- if (bs_info >> 31)
- independent_bs = 2;
-
- // if this is the last channel, it has to be decoded independently
- if (c == avctx->channels - 1)
- independent_bs = 1;
-
- if (independent_bs) {
- if (decode_blocks_ind(ctx, ra_frame, c, div_blocks, js_blocks))
- return -1;
-
- independent_bs--;
- } else {
- if (decode_blocks(ctx, ra_frame, c, div_blocks, js_blocks))
- return -1;
-
- c++;
- }
-
- // store carryover raw samples
- memmove(ctx->raw_samples[c] - sconf->max_order,
- ctx->raw_samples[c] - sconf->max_order + sconf->frame_length,
- sizeof(*ctx->raw_samples[c]) * sconf->max_order);
- }
- } else { // multi-channel coding
- ALSBlockData bd = { 0 };
- int b, ret;
- int *reverted_channels = ctx->reverted_channels;
- unsigned int offset = 0;
-
- for (c = 0; c < avctx->channels; c++)
- if (ctx->chan_data[c] < ctx->chan_data_buffer) {
- av_log(ctx->avctx, AV_LOG_ERROR, "Invalid channel data.\n");
- return -1;
- }
-
- memset(reverted_channels, 0, sizeof(*reverted_channels) * avctx->channels);
-
- bd.ra_block = ra_frame;
- bd.prev_raw_samples = ctx->prev_raw_samples;
-
- get_block_sizes(ctx, div_blocks, &bs_info);
-
- for (b = 0; b < ctx->num_blocks; b++) {
- bd.block_length = div_blocks[b];
-
- for (c = 0; c < avctx->channels; c++) {
- bd.const_block = ctx->const_block + c;
- bd.shift_lsbs = ctx->shift_lsbs + c;
- bd.opt_order = ctx->opt_order + c;
- bd.store_prev_samples = ctx->store_prev_samples + c;
- bd.use_ltp = ctx->use_ltp + c;
- bd.ltp_lag = ctx->ltp_lag + c;
- bd.ltp_gain = ctx->ltp_gain[c];
- bd.lpc_cof = ctx->lpc_cof[c];
- bd.quant_cof = ctx->quant_cof[c];
- bd.raw_samples = ctx->raw_samples[c] + offset;
- bd.raw_other = NULL;
-
- if ((ret = read_block(ctx, &bd)) < 0)
- return ret;
- if ((ret = read_channel_data(ctx, ctx->chan_data[c], c)) < 0)
- return ret;
- }
-
- for (c = 0; c < avctx->channels; c++)
- if (revert_channel_correlation(ctx, &bd, ctx->chan_data,
- reverted_channels, offset, c))
- return -1;
-
- for (c = 0; c < avctx->channels; c++) {
- bd.const_block = ctx->const_block + c;
- bd.shift_lsbs = ctx->shift_lsbs + c;
- bd.opt_order = ctx->opt_order + c;
- bd.store_prev_samples = ctx->store_prev_samples + c;
- bd.use_ltp = ctx->use_ltp + c;
- bd.ltp_lag = ctx->ltp_lag + c;
- bd.ltp_gain = ctx->ltp_gain[c];
- bd.lpc_cof = ctx->lpc_cof[c];
- bd.quant_cof = ctx->quant_cof[c];
- bd.raw_samples = ctx->raw_samples[c] + offset;
-
- if ((ret = decode_block(ctx, &bd)) < 0)
- return ret;
- }
-
- memset(reverted_channels, 0, avctx->channels * sizeof(*reverted_channels));
- offset += div_blocks[b];
- bd.ra_block = 0;
- }
-
- // store carryover raw samples
- for (c = 0; c < avctx->channels; c++)
- memmove(ctx->raw_samples[c] - sconf->max_order,
- ctx->raw_samples[c] - sconf->max_order + sconf->frame_length,
- sizeof(*ctx->raw_samples[c]) * sconf->max_order);
- }
-
- // TODO: read_diff_float_data
-
- return 0;
-}
-
-
-/** Decode an ALS frame.
- */
-static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
- AVPacket *avpkt)
-{
- ALSDecContext *ctx = avctx->priv_data;
- AVFrame *frame = data;
- ALSSpecificConfig *sconf = &ctx->sconf;
- const uint8_t *buffer = avpkt->data;
- int buffer_size = avpkt->size;
- int invalid_frame, ret;
- unsigned int c, sample, ra_frame, bytes_read, shift;
-
- init_get_bits(&ctx->gb, buffer, buffer_size * 8);
-
- // In the case that the distance between random access frames is set to zero
- // (sconf->ra_distance == 0) no frame is treated as a random access frame.
- // For the first frame, if prediction is used, all samples used from the
- // previous frame are assumed to be zero.
- ra_frame = sconf->ra_distance && !(ctx->frame_id % sconf->ra_distance);
-
- // the last frame to decode might have a different length
- if (sconf->samples != 0xFFFFFFFF)
- ctx->cur_frame_length = FFMIN(sconf->samples - ctx->frame_id * (uint64_t) sconf->frame_length,
- sconf->frame_length);
- else
- ctx->cur_frame_length = sconf->frame_length;
-
- // decode the frame data
- if ((invalid_frame = read_frame_data(ctx, ra_frame)) < 0)
- av_log(ctx->avctx, AV_LOG_WARNING,
- "Reading frame data failed. Skipping RA unit.\n");
-
- ctx->frame_id++;
-
- /* get output buffer */
- frame->nb_samples = ctx->cur_frame_length;
- if ((ret = ff_get_buffer(avctx, frame)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed.\n");
- return ret;
- }
-
- // transform decoded frame into output format
- #define INTERLEAVE_OUTPUT(bps) \
- { \
- int##bps##_t *dest = (int##bps##_t*)frame->data[0]; \
- shift = bps - ctx->avctx->bits_per_raw_sample; \
- if (!ctx->cs_switch) { \
- for (sample = 0; sample < ctx->cur_frame_length; sample++) \
- for (c = 0; c < avctx->channels; c++) \
- *dest++ = ctx->raw_samples[c][sample] << shift; \
- } else { \
- for (sample = 0; sample < ctx->cur_frame_length; sample++) \
- for (c = 0; c < avctx->channels; c++) \
- *dest++ = ctx->raw_samples[sconf->chan_pos[c]][sample] << shift; \
- } \
- }
-
- if (ctx->avctx->bits_per_raw_sample <= 16) {
- INTERLEAVE_OUTPUT(16)
- } else {
- INTERLEAVE_OUTPUT(32)
- }
-
- // update CRC
- if (sconf->crc_enabled && (avctx->err_recognition & (AV_EF_CRCCHECK|AV_EF_CAREFUL))) {
- int swap = HAVE_BIGENDIAN != sconf->msb_first;
-
- if (ctx->avctx->bits_per_raw_sample == 24) {
- int32_t *src = (int32_t *)frame->data[0];
-
- for (sample = 0;
- sample < ctx->cur_frame_length * avctx->channels;
- sample++) {
- int32_t v;
-
- if (swap)
- v = av_bswap32(src[sample]);
- else
- v = src[sample];
- if (!HAVE_BIGENDIAN)
- v >>= 8;
-
- ctx->crc = av_crc(ctx->crc_table, ctx->crc, (uint8_t*)(&v), 3);
- }
- } else {
- uint8_t *crc_source;
-
- if (swap) {
- if (ctx->avctx->bits_per_raw_sample <= 16) {
- int16_t *src = (int16_t*) frame->data[0];
- int16_t *dest = (int16_t*) ctx->crc_buffer;
- for (sample = 0;
- sample < ctx->cur_frame_length * avctx->channels;
- sample++)
- *dest++ = av_bswap16(src[sample]);
- } else {
- ctx->dsp.bswap_buf((uint32_t*)ctx->crc_buffer,
- (uint32_t *)frame->data[0],
- ctx->cur_frame_length * avctx->channels);
- }
- crc_source = ctx->crc_buffer;
- } else {
- crc_source = frame->data[0];
- }
-
- ctx->crc = av_crc(ctx->crc_table, ctx->crc, crc_source,
- ctx->cur_frame_length * avctx->channels *
- av_get_bytes_per_sample(avctx->sample_fmt));
- }
-
-
- // check CRC sums if this is the last frame
- if (ctx->cur_frame_length != sconf->frame_length &&
- ctx->crc_org != ctx->crc) {
- av_log(avctx, AV_LOG_ERROR, "CRC error.\n");
- }
- }
-
- *got_frame_ptr = 1;
-
- bytes_read = invalid_frame ? buffer_size :
- (get_bits_count(&ctx->gb) + 7) >> 3;
-
- return bytes_read;
-}
-
-
-/** Uninitialize the ALS decoder.
- */
-static av_cold int decode_end(AVCodecContext *avctx)
-{
- ALSDecContext *ctx = avctx->priv_data;
-
- av_freep(&ctx->sconf.chan_pos);
-
- ff_bgmc_end(&ctx->bgmc_lut, &ctx->bgmc_lut_status);
-
- av_freep(&ctx->const_block);
- av_freep(&ctx->shift_lsbs);
- av_freep(&ctx->opt_order);
- av_freep(&ctx->store_prev_samples);
- av_freep(&ctx->use_ltp);
- av_freep(&ctx->ltp_lag);
- av_freep(&ctx->ltp_gain);
- av_freep(&ctx->ltp_gain_buffer);
- av_freep(&ctx->quant_cof);
- av_freep(&ctx->lpc_cof);
- av_freep(&ctx->quant_cof_buffer);
- av_freep(&ctx->lpc_cof_buffer);
- av_freep(&ctx->lpc_cof_reversed_buffer);
- av_freep(&ctx->prev_raw_samples);
- av_freep(&ctx->raw_samples);
- av_freep(&ctx->raw_buffer);
- av_freep(&ctx->chan_data);
- av_freep(&ctx->chan_data_buffer);
- av_freep(&ctx->reverted_channels);
- av_freep(&ctx->crc_buffer);
-
- return 0;
-}
-
-
-/** Initialize the ALS decoder.
- */
-static av_cold int decode_init(AVCodecContext *avctx)
-{
- unsigned int c;
- unsigned int channel_size;
- int num_buffers;
- ALSDecContext *ctx = avctx->priv_data;
- ALSSpecificConfig *sconf = &ctx->sconf;
- ctx->avctx = avctx;
-
- if (!avctx->extradata) {
- av_log(avctx, AV_LOG_ERROR, "Missing required ALS extradata.\n");
- return -1;
- }
-
- if (read_specific_config(ctx)) {
- av_log(avctx, AV_LOG_ERROR, "Reading ALSSpecificConfig failed.\n");
- decode_end(avctx);
- return -1;
- }
-
- if (check_specific_config(ctx)) {
- decode_end(avctx);
- return -1;
- }
-
- if (sconf->bgmc)
- ff_bgmc_init(avctx, &ctx->bgmc_lut, &ctx->bgmc_lut_status);
-
- if (sconf->floating) {
- avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
- avctx->bits_per_raw_sample = 32;
- } else {
- avctx->sample_fmt = sconf->resolution > 1
- ? AV_SAMPLE_FMT_S32 : AV_SAMPLE_FMT_S16;
- avctx->bits_per_raw_sample = (sconf->resolution + 1) * 8;
- }
-
- // set maximum Rice parameter for progressive decoding based on resolution
- // This is not specified in 14496-3 but actually done by the reference
- // codec RM22 revision 2.
- ctx->s_max = sconf->resolution > 1 ? 31 : 15;
-
- // set lag value for long-term prediction
- ctx->ltp_lag_length = 8 + (avctx->sample_rate >= 96000) +
- (avctx->sample_rate >= 192000);
-
- // allocate quantized parcor coefficient buffer
- num_buffers = sconf->mc_coding ? avctx->channels : 1;
-
- ctx->quant_cof = av_malloc(sizeof(*ctx->quant_cof) * num_buffers);
- ctx->lpc_cof = av_malloc(sizeof(*ctx->lpc_cof) * num_buffers);
- ctx->quant_cof_buffer = av_malloc(sizeof(*ctx->quant_cof_buffer) *
- num_buffers * sconf->max_order);
- ctx->lpc_cof_buffer = av_malloc(sizeof(*ctx->lpc_cof_buffer) *
- num_buffers * sconf->max_order);
- ctx->lpc_cof_reversed_buffer = av_malloc(sizeof(*ctx->lpc_cof_buffer) *
- sconf->max_order);
-
- if (!ctx->quant_cof || !ctx->lpc_cof ||
- !ctx->quant_cof_buffer || !ctx->lpc_cof_buffer ||
- !ctx->lpc_cof_reversed_buffer) {
- av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
- return AVERROR(ENOMEM);
- }
-
- // assign quantized parcor coefficient buffers
- for (c = 0; c < num_buffers; c++) {
- ctx->quant_cof[c] = ctx->quant_cof_buffer + c * sconf->max_order;
- ctx->lpc_cof[c] = ctx->lpc_cof_buffer + c * sconf->max_order;
- }
-
- // allocate and assign lag and gain data buffer for ltp mode
- ctx->const_block = av_malloc (sizeof(*ctx->const_block) * num_buffers);
- ctx->shift_lsbs = av_malloc (sizeof(*ctx->shift_lsbs) * num_buffers);
- ctx->opt_order = av_malloc (sizeof(*ctx->opt_order) * num_buffers);
- ctx->store_prev_samples = av_malloc(sizeof(*ctx->store_prev_samples) * num_buffers);
- ctx->use_ltp = av_mallocz(sizeof(*ctx->use_ltp) * num_buffers);
- ctx->ltp_lag = av_malloc (sizeof(*ctx->ltp_lag) * num_buffers);
- ctx->ltp_gain = av_malloc (sizeof(*ctx->ltp_gain) * num_buffers);
- ctx->ltp_gain_buffer = av_malloc (sizeof(*ctx->ltp_gain_buffer) *
- num_buffers * 5);
-
- if (!ctx->const_block || !ctx->shift_lsbs ||
- !ctx->opt_order || !ctx->store_prev_samples ||
- !ctx->use_ltp || !ctx->ltp_lag ||
- !ctx->ltp_gain || !ctx->ltp_gain_buffer) {
- av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
- decode_end(avctx);
- return AVERROR(ENOMEM);
- }
-
- for (c = 0; c < num_buffers; c++)
- ctx->ltp_gain[c] = ctx->ltp_gain_buffer + c * 5;
-
- // allocate and assign channel data buffer for mcc mode
- if (sconf->mc_coding) {
- ctx->chan_data_buffer = av_malloc(sizeof(*ctx->chan_data_buffer) *
- num_buffers * num_buffers);
- ctx->chan_data = av_malloc(sizeof(*ctx->chan_data) *
- num_buffers);
- ctx->reverted_channels = av_malloc(sizeof(*ctx->reverted_channels) *
- num_buffers);
-
- if (!ctx->chan_data_buffer || !ctx->chan_data || !ctx->reverted_channels) {
- av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
- decode_end(avctx);
- return AVERROR(ENOMEM);
- }
-
- for (c = 0; c < num_buffers; c++)
- ctx->chan_data[c] = ctx->chan_data_buffer + c * num_buffers;
- } else {
- ctx->chan_data = NULL;
- ctx->chan_data_buffer = NULL;
- ctx->reverted_channels = NULL;
- }
-
- channel_size = sconf->frame_length + sconf->max_order;
-
- ctx->prev_raw_samples = av_malloc (sizeof(*ctx->prev_raw_samples) * sconf->max_order);
- ctx->raw_buffer = av_mallocz(sizeof(*ctx-> raw_buffer) * avctx->channels * channel_size);
- ctx->raw_samples = av_malloc (sizeof(*ctx-> raw_samples) * avctx->channels);
-
- // allocate previous raw sample buffer
- if (!ctx->prev_raw_samples || !ctx->raw_buffer|| !ctx->raw_samples) {
- av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
- decode_end(avctx);
- return AVERROR(ENOMEM);
- }
-
- // assign raw samples buffers
- ctx->raw_samples[0] = ctx->raw_buffer + sconf->max_order;
- for (c = 1; c < avctx->channels; c++)
- ctx->raw_samples[c] = ctx->raw_samples[c - 1] + channel_size;
-
- // allocate crc buffer
- if (HAVE_BIGENDIAN != sconf->msb_first && sconf->crc_enabled &&
- (avctx->err_recognition & (AV_EF_CRCCHECK|AV_EF_CAREFUL))) {
- ctx->crc_buffer = av_malloc(sizeof(*ctx->crc_buffer) *
- ctx->cur_frame_length *
- avctx->channels *
- av_get_bytes_per_sample(avctx->sample_fmt));
- if (!ctx->crc_buffer) {
- av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
- decode_end(avctx);
- return AVERROR(ENOMEM);
- }
- }
-
- ff_dsputil_init(&ctx->dsp, avctx);
-
- return 0;
-}
-
-
-/** Flush (reset) the frame ID after seeking.
- */
-static av_cold void flush(AVCodecContext *avctx)
-{
- ALSDecContext *ctx = avctx->priv_data;
-
- ctx->frame_id = 0;
-}
-
-
-AVCodec ff_als_decoder = {
- .name = "als",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_MP4ALS,
- .priv_data_size = sizeof(ALSDecContext),
- .init = decode_init,
- .close = decode_end,
- .decode = decode_frame,
- .flush = flush,
- .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 Audio Lossless Coding (ALS)"),
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/amr.h b/src/thirdparty/ffmpeg/libavcodec/amr.h
deleted file mode 100644
index c5ba3a2fa..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/amr.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Shared functions between AMR codecs
- *
- * Copyright (c) 2010 Marcelo Galvao Povoa
- *
- * 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_AMR_H
-#define AVCODEC_AMR_H
-
-#include <string.h>
-
-#include "avcodec.h"
-
-#ifdef AMR_USE_16BIT_TABLES
-#define R_TABLE_TYPE uint16_t
-#else
-#define R_TABLE_TYPE uint8_t
-#endif
-
-/**
- * Fill the frame structure variables from bitstream by parsing the
- * given reordering table that uses the following format:
- *
- * Each field (16 bits) in the AMR Frame is stored as:
- * - one byte for the number of bits in the field
- * - one byte for the field index
- * - then, one byte for each bit of the field (from most-significant to least)
- * of the position of that bit in the AMR frame.
- *
- * @param out pointer to the frame struct
- * @param size the size in bytes of the frame struct
- * @param data input bitstream after the frame header
- * @param ord_table the reordering table as above
- */
-static inline void ff_amr_bit_reorder(uint16_t *out, int size,
- const uint8_t *data,
- const R_TABLE_TYPE *ord_table)
-{
- int field_size;
-
- memset(out, 0, size);
- while ((field_size = *ord_table++)) {
- int field = 0;
- int field_offset = *ord_table++;
- while (field_size--) {
- int bit = *ord_table++;
- field <<= 1;
- field |= data[bit >> 3] >> (bit & 7) & 1;
- }
- out[field_offset >> 1] = field;
- }
-}
-
-#endif /* AVCODEC_AMR_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/amrnbdata.h b/src/thirdparty/ffmpeg/libavcodec/amrnbdata.h
deleted file mode 100644
index 7a5038b12..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/amrnbdata.h
+++ /dev/null
@@ -1,1671 +0,0 @@
-/*
- * AMR narrowband data and definitions
- * Copyright (c) 2006-2007 Robert Swain
- * Copyright (c) 2009 Colin McQuillan
- *
- * 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
- * AMR narrowband data and definitions
- */
-
-#ifndef AVCODEC_AMRNBDATA_H
-#define AVCODEC_AMRNBDATA_H
-
-#include <stdint.h>
-
-#include "libavutil/common.h" /* offsetof */
-
-#define AMR_SUBFRAME_SIZE 40 ///< samples per subframe
-
-/** Frame type (Table 1a in 3GPP TS 26.101) */
-enum Mode {
- MODE_4k75 = 0, ///< 4.75 kbit/s
- MODE_5k15, ///< 5.15 kbit/s
- MODE_5k9, ///< 5.90 kbit/s
- MODE_6k7, ///< 6.70 kbit/s
- MODE_7k4, ///< 7.40 kbit/s
- MODE_7k95, ///< 7.95 kbit/s
- MODE_10k2, ///< 10.2 kbit/s
- MODE_12k2, ///< 12.2 kbit/s
- MODE_DTX, ///< silent frame
- N_MODES, ///< number of modes
- NO_DATA = 15 ///< no transmission
-};
-
-#define LP_FILTER_ORDER 10 ///< linear predictive coding filter order
-
-/**
- * AMRNB unpacked data subframe
- */
-typedef struct AMRNBSubframe {
- uint16_t p_lag; ///< index to decode the pitch lag
- uint16_t p_gain; ///< index to decode the pitch gain
- uint16_t fixed_gain; ///< index to decode the fixed gain factor, for MODE_12k2 and MODE_7k95
- uint16_t pulses[10]; ///< pulses: 10 for MODE_12k2, 7 for MODE_10k2, and index and sign for others
-} AMRNBSubframe;
-
-/**
- * AMRNB unpacked data frame
- */
-typedef struct AMRNBFrame {
- uint16_t lsf[5]; ///< lsf parameters: 5 parameters for MODE_12k2, only 3 for other modes
- AMRNBSubframe subframe[4]; ///< unpacked data for each subframe
-} AMRNBFrame;
-
-/** The index of a frame parameter */
-#define AMR_BIT(field) (offsetof(AMRNBFrame, field))
-/** The index of a subframe-specific parameter */
-#define AMR_OF(frame_num, variable) AMR_BIT(subframe[frame_num].variable)
-
-// The following order* tables are used to convert AMR frame parameters to and
-// from a bitstream. See 3GPP TS 26.101 for more information.
-// Each field in AMRNBFrame is stored as:
-// * one byte for the number of bits in the field
-// * one byte for the field index
-// * then, one byte for each bit of the field (from most-significant to least)
-// of the position of that bit in the AMR frame.
-static const uint8_t order_MODE_4k75[] = {
- 8, AMR_BIT(lsf[0]), 7, 6, 5, 4, 3, 2, 1, 0,
- 8, AMR_BIT(lsf[1]), 15, 14, 13, 12, 11, 10, 9, 8,
- 7, AMR_BIT(lsf[2]), 51, 35, 34, 50, 33, 49, 32,
- 8, AMR_OF(0,p_lag), 23, 22, 21, 20, 19, 18, 43, 42,
- 8, AMR_OF(0,p_gain), 54, 55, 40, 41, 24, 25, 26, 27,
- 7, AMR_OF(0,pulses[0]), 92, 68, 67, 84, 66, 65, 80,
- 2, AMR_OF(0,pulses[1]), 53, 52,
- 4, AMR_OF(1,p_lag), 17, 16, 48, 63,
- 7, AMR_OF(1,pulses[0]), 91, 64, 79, 83, 78, 77, 95,
- 2, AMR_OF(1,pulses[1]), 62, 61,
- 4, AMR_OF(2,p_lag), 31, 30, 60, 59,
- 8, AMR_OF(2,p_gain), 44, 45, 46, 47, 36, 37, 38, 39,
- 7, AMR_OF(2,pulses[0]), 90, 76, 75, 82, 74, 73, 94,
- 2, AMR_OF(2,pulses[1]), 58, 57,
- 4, AMR_OF(3,p_lag), 29, 28, 56, 71,
- 7, AMR_OF(3,pulses[0]), 89, 72, 87, 81, 86, 85, 93,
- 2, AMR_OF(3,pulses[1]), 70, 69,
- 0
-};
-
-static const uint8_t order_MODE_5k15[] = {
- 8, AMR_BIT(lsf[0]), 0, 1, 2, 3, 4, 5, 6, 7,
- 8, AMR_BIT(lsf[1]), 8, 9, 10, 11, 12, 13, 14, 15,
- 7, AMR_BIT(lsf[2]), 70, 51, 43, 71, 50, 60, 49,
- 8, AMR_OF(0,p_lag), 23, 22, 21, 20, 19, 47, 54, 59,
- 6, AMR_OF(0,p_gain), 48, 42, 35, 29, 30, 31,
- 7, AMR_OF(0,pulses[0]), 92, 84, 82, 100, 79, 72, 88,
- 2, AMR_OF(0,pulses[1]), 67, 68,
- 4, AMR_OF(1,p_lag), 18, 46, 53, 58,
- 6, AMR_OF(1,p_gain), 63, 41, 34, 26, 27, 28,
- 7, AMR_OF(1,pulses[0]), 91, 83, 81, 99, 78, 87, 103,
- 2, AMR_OF(1,pulses[1]), 65, 66,
- 4, AMR_OF(2,p_lag), 17, 45, 52, 57,
- 6, AMR_OF(2,p_gain), 62, 40, 33, 39, 24, 25,
- 7, AMR_OF(2,pulses[0]), 90, 80, 95, 98, 77, 86, 102,
- 2, AMR_OF(2,pulses[1]), 75, 64,
- 4, AMR_OF(3,p_lag), 16, 44, 56, 69,
- 6, AMR_OF(3,p_gain), 61, 55, 32, 36, 37, 38,
- 7, AMR_OF(3,pulses[0]), 89, 94, 93, 97, 76, 85, 101,
- 2, AMR_OF(3,pulses[1]), 73, 74,
- 0
-};
-
-static const uint8_t order_MODE_5k9[] = {
- 8, AMR_BIT(lsf[0]), 7, 6, 0, 3, 5, 4, 2, 1,
- 9, AMR_BIT(lsf[1]), 13, 12, 8, 11, 10, 15, 9, 14, 23,
- 9, AMR_BIT(lsf[2]), 71, 56, 60, 70, 59, 57, 58, 69, 76,
- 8, AMR_OF(0,p_lag), 16, 18, 22, 20, 30, 38, 44, 42,
- 6, AMR_OF(0,p_gain), 75, 48, 52, 40, 34, 26,
- 9, AMR_OF(0,pulses[0]), 101, 89, 93, 117, 105, 81, 85, 109, 97,
- 2, AMR_OF(0,pulses[1]), 67, 78,
- 4, AMR_OF(1,p_lag), 28, 36, 46, 87,
- 6, AMR_OF(1,p_gain), 74, 63, 51, 55, 33, 25,
- 9, AMR_OF(1,pulses[0]), 100, 88, 92, 116, 104, 80, 84, 108, 96,
- 2, AMR_OF(1,pulses[1]), 64, 79,
- 8, AMR_OF(2,p_lag), 31, 17, 21, 19, 29, 37, 43, 41,
- 6, AMR_OF(2,p_gain), 73, 62, 50, 54, 32, 24,
- 9, AMR_OF(2,pulses[0]), 99, 103, 91, 115, 119, 95, 83, 107, 111,
- 2, AMR_OF(2,pulses[1]), 66, 77,
- 4, AMR_OF(3,p_lag), 27, 35, 45, 86,
- 6, AMR_OF(3,p_gain), 72, 61, 49, 53, 47, 39,
- 9, AMR_OF(3,pulses[0]), 98, 102, 90, 114, 118, 94, 82, 106, 110,
- 2, AMR_OF(3,pulses[1]), 65, 68,
- 0
-};
-
-static const uint8_t order_MODE_6k7[] = {
- 8, AMR_BIT(lsf[0]), 7, 6, 15, 4, 5, 3, 2, 0,
- 9, AMR_BIT(lsf[1]), 14, 13, 8, 12, 10, 1, 9, 11, 29,
- 9, AMR_BIT(lsf[2]), 57, 58, 50, 56, 60, 59, 49, 71, 70,
- 8, AMR_OF(0,p_lag), 17, 19, 23, 21, 31, 24, 32, 52,
- 7, AMR_OF(0,p_gain), 36, 82, 69, 46, 42, 48, 77,
- 11, AMR_OF(0,pulses[0]), 109, 97, 133, 121, 101, 89, 125, 113, 93, 117,
- 105,
- 3, AMR_OF(0,pulses[1]), 81, 73, 65,
- 4, AMR_OF(1,p_lag), 28, 26, 38, 54,
- 7, AMR_OF(1,p_gain), 35, 83, 68, 45, 41, 63, 76,
- 11, AMR_OF(1,pulses[0]), 108, 96, 132, 120, 100, 88, 124, 112, 92, 116,
- 104,
- 3, AMR_OF(1,pulses[1]), 80, 72, 64,
- 8, AMR_OF(2,p_lag), 16, 18, 22, 20, 30, 39, 47, 51,
- 7, AMR_OF(2,p_gain), 34, 84, 67, 44, 40, 62, 75,
- 11, AMR_OF(2,pulses[0]), 107, 111, 131, 135, 99, 103, 123, 127, 91, 115,
- 119,
- 3, AMR_OF(2,pulses[1]), 95, 87, 79,
- 4, AMR_OF(3,p_lag), 27, 25, 37, 53,
- 7, AMR_OF(3,p_gain), 33, 85, 66, 43, 55, 61, 74,
- 11, AMR_OF(3,pulses[0]), 106, 110, 130, 134, 98, 102, 122, 126, 90, 114,
- 118,
- 3, AMR_OF(3,pulses[1]), 94, 86, 78,
- 0
-};
-
-static const uint8_t order_MODE_7k4[] = {
- 8, AMR_BIT(lsf[0]), 7, 6, 5, 4, 3, 2, 1, 0,
- 9, AMR_BIT(lsf[1]), 15, 14, 13, 12, 11, 10, 9, 8, 23,
- 9, AMR_BIT(lsf[2]), 53, 52, 51, 58, 40, 55, 54, 57, 56,
- 8, AMR_OF(0,p_lag), 22, 20, 18, 16, 30, 50, 95, 94,
- 7, AMR_OF(0,p_gain), 28, 24, 73, 36, 32, 62, 67,
- 13, AMR_OF(0,pulses[0]), 127, 123, 135, 131, 143, 139, 151, 103, 102, 101,
- 100, 99, 98,
- 4, AMR_OF(0,pulses[1]), 83, 75, 79, 71,
- 5, AMR_OF(1,p_lag), 44, 42, 49, 93, 92,
- 7, AMR_OF(1,p_gain), 27, 39, 72, 35, 47, 61, 66,
- 13, AMR_OF(1,pulses[0]), 126, 122, 134, 130, 142, 138, 150, 97, 96, 111,
- 110, 109, 108,
- 4, AMR_OF(1,pulses[1]), 82, 74, 78, 70,
- 8, AMR_OF(2,p_lag), 21, 19, 17, 31, 29, 48, 91, 90,
- 7, AMR_OF(2,p_gain), 26, 38, 87, 34, 46, 60, 65,
- 13, AMR_OF(2,pulses[0]), 125, 121, 133, 129, 141, 137, 149, 107, 106, 105,
- 104, 119, 118,
- 4, AMR_OF(2,pulses[1]), 81, 85, 77, 69,
- 5, AMR_OF(3,p_lag), 43, 41, 63, 89, 88,
- 7, AMR_OF(3,p_gain), 25, 37, 86, 33, 45, 59, 64,
- 13, AMR_OF(3,pulses[0]), 124, 120, 132, 128, 140, 136, 148, 117, 116, 115,
- 114, 113, 112,
- 4, AMR_OF(3,pulses[1]), 80, 84, 76, 68,
- 0
-};
-
-static const uint8_t order_MODE_7k95[] = {
- 9, AMR_BIT(lsf[0]), 67, 68, 1, 2, 3, 4, 5, 6, 7,
- 9, AMR_BIT(lsf[1]), 14, 13, 9, 12, 11, 0, 10, 15, 8,
- 9, AMR_BIT(lsf[2]), 18, 19, 23, 17, 22, 20, 21, 66, 65,
- 8, AMR_OF(0,p_lag), 44, 42, 40, 54, 52, 56, 64, 78,
- 4, AMR_OF(0,p_gain), 36, 32, 72, 80,
- 5, AMR_OF(0,fixed_gain), 16, 28, 24, 60, 84,
- 13, AMR_OF(0,pulses[0]), 135, 109, 144, 156, 120, 97, 148, 121, 101, 122,
- 123, 89, 124,
- 4, AMR_OF(0,pulses[1]), 125, 126, 127, 112,
- 6, AMR_OF(1,p_lag), 50, 48, 62, 70, 76, 74,
- 4, AMR_OF(1,p_gain), 35, 47, 87, 95,
- 5, AMR_OF(1,fixed_gain), 31, 27, 39, 59, 83,
- 13, AMR_OF(1,pulses[0]), 129, 108, 159, 155, 130, 96, 147, 131, 100, 132,
- 133, 88, 134,
- 4, AMR_OF(1,pulses[1]), 113, 114, 115, 116,
- 8, AMR_OF(2,p_lag), 43, 41, 55, 53, 51, 71, 79, 77,
- 4, AMR_OF(2,p_gain), 34, 46, 86, 94,
- 5, AMR_OF(2,fixed_gain), 30, 26, 38, 58, 82,
- 13, AMR_OF(2,pulses[0]), 139, 107, 158, 154, 140, 111, 146, 141, 99, 142,
- 143, 103, 128,
- 4, AMR_OF(2,pulses[1]), 105, 90, 91, 92,
- 6, AMR_OF(3,p_lag), 49, 63, 61, 69, 75, 73,
- 4, AMR_OF(3,p_gain), 33, 45, 85, 93,
- 5, AMR_OF(3,fixed_gain), 29, 25, 37, 57, 81,
- 13, AMR_OF(3,pulses[0]), 149, 106, 157, 153, 150, 110, 145, 151, 98, 136,
- 137, 102, 138,
- 4, AMR_OF(3,pulses[1]), 117, 118, 119, 104,
- 0
-};
-
-static const uint8_t order_MODE_10k2[] = {
- 8, AMR_BIT(lsf[0]), 0, 1, 2, 3, 4, 5, 6, 7,
- 9, AMR_BIT(lsf[1]), 23, 8, 9, 10, 11, 12, 13, 14, 15,
- 9, AMR_BIT(lsf[2]), 57, 58, 62, 56, 60, 59, 61, 71, 70,
- 8, AMR_OF(0,p_lag), 22, 21, 20, 19, 18, 17, 42, 41,
- 7, AMR_OF(0,p_gain), 38, 50, 84, 37, 36, 85, 83,
- 1, AMR_OF(0,pulses[0]), 66,
- 1, AMR_OF(0,pulses[1]), 67,
- 1, AMR_OF(0,pulses[2]), 68,
- 1, AMR_OF(0,pulses[3]), 69,
- 10, AMR_OF(0,pulses[4]), 145, 144, 156, 153, 154, 163, 161, 192, 206, 195,
- 10, AMR_OF(0,pulses[5]), 158, 159, 157, 152, 155, 165, 160, 205, 204, 194,
- 7, AMR_OF(0,pulses[6]), 167, 166, 162, 164, 196, 207, 193,
- 5, AMR_OF(1,p_lag), 26, 25, 54, 53, 89,
- 7, AMR_OF(1,p_gain), 35, 49, 81, 34, 33, 82, 80,
- 1, AMR_OF(1,pulses[0]), 78,
- 1, AMR_OF(1,pulses[1]), 79,
- 1, AMR_OF(1,pulses[2]), 64,
- 1, AMR_OF(1,pulses[3]), 65,
- 10, AMR_OF(1,pulses[4]), 103, 102, 98, 111, 96, 105, 119, 185, 199, 188,
- 10, AMR_OF(1,pulses[5]), 100, 101, 99, 110, 97, 107, 118, 198, 197, 187,
- 7, AMR_OF(1,pulses[6]), 109, 108, 104, 106, 189, 184, 186,
- 8, AMR_OF(2,p_lag), 16, 31, 30, 29, 28, 27, 40, 55,
- 7, AMR_OF(2,p_gain), 32, 48, 94, 47, 46, 95, 93,
- 1, AMR_OF(2,pulses[0]), 74,
- 1, AMR_OF(2,pulses[1]), 75,
- 1, AMR_OF(2,pulses[2]), 76,
- 1, AMR_OF(2,pulses[3]), 77,
- 10, AMR_OF(2,pulses[4]), 117, 116, 112, 125, 126, 135, 133, 178, 176, 181,
- 10, AMR_OF(2,pulses[5]), 114, 115, 113, 124, 127, 121, 132, 191, 190, 180,
- 7, AMR_OF(2,pulses[6]), 123, 122, 134, 120, 182, 177, 179,
- 5, AMR_OF(3,p_lag), 24, 39, 52, 51, 88,
- 7, AMR_OF(3,p_gain), 45, 63, 91, 44, 43, 92, 90,
- 1, AMR_OF(3,pulses[0]), 86,
- 1, AMR_OF(3,pulses[1]), 87,
- 1, AMR_OF(3,pulses[2]), 72,
- 1, AMR_OF(3,pulses[3]), 73,
- 10, AMR_OF(3,pulses[4]), 131, 130, 142, 139, 140, 149, 147, 171, 169, 174,
- 10, AMR_OF(3,pulses[5]), 128, 129, 143, 138, 141, 151, 146, 168, 183, 173,
- 7, AMR_OF(3,pulses[6]), 137, 136, 148, 150, 175, 170, 172,
- 0
-};
-
-static const uint8_t order_MODE_12k2[] = {
- 7, AMR_BIT(lsf[0]), 7, 6, 5, 4, 3, 2, 1,
- 8, AMR_BIT(lsf[1]), 0, 15, 14, 13, 12, 11, 10, 9,
- 9, AMR_BIT(lsf[2]), 23, 22, 21, 20, 19, 18, 17, 16, 8,
- 8, AMR_BIT(lsf[3]), 31, 30, 29, 28, 27, 86, 85, 84,
- 6, AMR_BIT(lsf[4]), 83, 82, 81, 80, 127, 126,
- 9, AMR_OF(0,p_lag), 26, 24, 38, 36, 34, 32, 46, 44, 42,
- 4, AMR_OF(0,p_gain), 40, 52, 48, 95,
- 5, AMR_OF(0,fixed_gain), 60, 56, 68, 91, 111,
- 3, AMR_OF(0,pulses[0]), 191, 176, 177,
- 4, AMR_OF(0,pulses[1]), 103, 123, 124, 125,
- 3, AMR_OF(0,pulses[2]), 188, 189, 190,
- 4, AMR_OF(0,pulses[3]), 99, 120, 121, 122,
- 3, AMR_OF(0,pulses[4]), 185, 186, 187,
- 4, AMR_OF(0,pulses[5]), 107, 133, 134, 135,
- 3, AMR_OF(0,pulses[6]), 198, 199, 184,
- 4, AMR_OF(0,pulses[7]), 119, 130, 131, 132,
- 3, AMR_OF(0,pulses[8]), 195, 196, 197,
- 4, AMR_OF(0,pulses[9]), 115, 143, 128, 129,
- 6, AMR_OF(1,p_lag), 64, 78, 76, 74, 72, 245,
- 4, AMR_OF(1,p_gain), 55, 51, 63, 94,
- 5, AMR_OF(1,fixed_gain), 59, 71, 67, 90, 110,
- 3, AMR_OF(1,pulses[0]), 192, 193, 194,
- 4, AMR_OF(1,pulses[1]), 102, 140, 141, 142,
- 3, AMR_OF(1,pulses[2]), 205, 206, 207,
- 4, AMR_OF(1,pulses[3]), 98, 137, 138, 139,
- 3, AMR_OF(1,pulses[4]), 202, 203, 204,
- 4, AMR_OF(1,pulses[5]), 106, 150, 151, 136,
- 3, AMR_OF(1,pulses[6]), 215, 200, 201,
- 4, AMR_OF(1,pulses[7]), 118, 147, 148, 149,
- 3, AMR_OF(1,pulses[8]), 212, 213, 214,
- 4, AMR_OF(1,pulses[9]), 114, 144, 145, 146,
- 9, AMR_OF(2,p_lag), 25, 39, 37, 35, 33, 47, 45, 43, 41,
- 4, AMR_OF(2,p_gain), 54, 50, 62, 93,
- 5, AMR_OF(2,fixed_gain), 58, 70, 66, 89, 109,
- 3, AMR_OF(2,pulses[0]), 209, 210, 211,
- 4, AMR_OF(2,pulses[1]), 101, 157, 158, 159,
- 3, AMR_OF(2,pulses[2]), 222, 223, 208,
- 4, AMR_OF(2,pulses[3]), 97, 154, 155, 156,
- 3, AMR_OF(2,pulses[4]), 219, 220, 221,
- 4, AMR_OF(2,pulses[5]), 105, 167, 152, 153,
- 3, AMR_OF(2,pulses[6]), 216, 217, 218,
- 4, AMR_OF(2,pulses[7]), 117, 164, 165, 166,
- 3, AMR_OF(2,pulses[8]), 229, 230, 231,
- 4, AMR_OF(2,pulses[9]), 113, 161, 162, 163,
- 6, AMR_OF(3,p_lag), 79, 77, 75, 73, 87, 244,
- 4, AMR_OF(3,p_gain), 53, 49, 61, 92,
- 5, AMR_OF(3,fixed_gain), 57, 69, 65, 88, 108,
- 3, AMR_OF(3,pulses[0]), 226, 227, 228,
- 4, AMR_OF(3,pulses[1]), 100, 174, 175, 160,
- 3, AMR_OF(3,pulses[2]), 239, 224, 225,
- 4, AMR_OF(3,pulses[3]), 96, 171, 172, 173,
- 3, AMR_OF(3,pulses[4]), 236, 237, 238,
- 4, AMR_OF(3,pulses[5]), 104, 168, 169, 170,
- 3, AMR_OF(3,pulses[6]), 233, 234, 235,
- 4, AMR_OF(3,pulses[7]), 116, 181, 182, 183,
- 3, AMR_OF(3,pulses[8]), 246, 247, 232,
- 4, AMR_OF(3,pulses[9]), 112, 178, 179, 180,
- 0
-};
-
-/**
- * position of the bitmapping data for each packet type in
- * the AMRNBFrame
- */
-static const uint8_t * const amr_unpacking_bitmaps_per_mode[N_MODES] = {
- order_MODE_4k75,
- order_MODE_5k15,
- order_MODE_5k9,
- order_MODE_6k7,
- order_MODE_7k4,
- order_MODE_7k95,
- order_MODE_10k2,
- order_MODE_12k2,
-};
-
-/** number of bytes for each mode */
-static const uint8_t frame_sizes_nb[N_MODES] = {
- 12, 13, 15, 17, 19, 20, 26, 31, 5
-};
-
-/**
- * Base-5 representation for values 0-124
- *
- * This is useful for decoding pulse positions in 10.2 kbit/s frames.
- * Safe values are provided for out of range positions 125-127.
- */
-static const uint8_t base_five_table[128][3] = {
- {0, 0, 0}, {0, 0, 1}, {0, 0, 2}, {0, 0, 3}, {0, 0, 4}, {0, 1, 0}, {0, 1, 1},
- {0, 1, 2}, {0, 1, 3}, {0, 1, 4}, {0, 2, 0}, {0, 2, 1}, {0, 2, 2}, {0, 2, 3},
- {0, 2, 4}, {0, 3, 0}, {0, 3, 1}, {0, 3, 2}, {0, 3, 3}, {0, 3, 4}, {0, 4, 0},
- {0, 4, 1}, {0, 4, 2}, {0, 4, 3}, {0, 4, 4}, {1, 0, 0}, {1, 0, 1}, {1, 0, 2},
- {1, 0, 3}, {1, 0, 4}, {1, 1, 0}, {1, 1, 1}, {1, 1, 2}, {1, 1, 3}, {1, 1, 4},
- {1, 2, 0}, {1, 2, 1}, {1, 2, 2}, {1, 2, 3}, {1, 2, 4}, {1, 3, 0}, {1, 3, 1},
- {1, 3, 2}, {1, 3, 3}, {1, 3, 4}, {1, 4, 0}, {1, 4, 1}, {1, 4, 2}, {1, 4, 3},
- {1, 4, 4}, {2, 0, 0}, {2, 0, 1}, {2, 0, 2}, {2, 0, 3}, {2, 0, 4}, {2, 1, 0},
- {2, 1, 1}, {2, 1, 2}, {2, 1, 3}, {2, 1, 4}, {2, 2, 0}, {2, 2, 1}, {2, 2, 2},
- {2, 2, 3}, {2, 2, 4}, {2, 3, 0}, {2, 3, 1}, {2, 3, 2}, {2, 3, 3}, {2, 3, 4},
- {2, 4, 0}, {2, 4, 1}, {2, 4, 2}, {2, 4, 3}, {2, 4, 4}, {3, 0, 0}, {3, 0, 1},
- {3, 0, 2}, {3, 0, 3}, {3, 0, 4}, {3, 1, 0}, {3, 1, 1}, {3, 1, 2}, {3, 1, 3},
- {3, 1, 4}, {3, 2, 0}, {3, 2, 1}, {3, 2, 2}, {3, 2, 3}, {3, 2, 4}, {3, 3, 0},
- {3, 3, 1}, {3, 3, 2}, {3, 3, 3}, {3, 3, 4}, {3, 4, 0}, {3, 4, 1}, {3, 4, 2},
- {3, 4, 3}, {3, 4, 4}, {4, 0, 0}, {4, 0, 1}, {4, 0, 2}, {4, 0, 3}, {4, 0, 4},
- {4, 1, 0}, {4, 1, 1}, {4, 1, 2}, {4, 1, 3}, {4, 1, 4}, {4, 2, 0}, {4, 2, 1},
- {4, 2, 2}, {4, 2, 3}, {4, 2, 4}, {4, 3, 0}, {4, 3, 1}, {4, 3, 2}, {4, 3, 3},
- {4, 3, 4}, {4, 4, 0}, {4, 4, 1}, {4, 4, 2}, {4, 4, 3}, {4, 4, 4}, {0, 0, 0},
- {0, 0, 0}, {0, 0, 0}
-};
-
-/**
- * Values for the lsp vector from the 4th subframe of the
- * previous subframe values.
- *
- * @note: Taken from Decoder_amr_reset in Q15 using val/1000
- */
-static const int8_t lsp_sub4_init[LP_FILTER_ORDER] = {
- 30, 26, 21, 15, 8, 0, -8, -15, -21, -26
-};
-
-/**
- * Mean lsp values.
- *
- * @note: Taken from Decoder_amr_reset in Q15
- */
-static const int16_t lsp_avg_init[LP_FILTER_ORDER] = {
- 1384, 2077, 3420, 5108, 6742, 8122, 9863, 11092, 12714, 13701
-};
-
-// LSF tables
-
-// These are stored as integers to save space. The values are taken from
-// q_plsf_3.tab and q_plsf_5.tab in 3GPP TS 26.090.
-
-static const int16_t lsf_3_3_MODE_5k15[128][4] = {
-{ 419, 163, -30, -262}, { -455, -789,-1430, -721}, { 1006, 664, 269, 25},
-{ 619, 260, 183, 96}, { -968,-1358, -388, 135}, { -693, 835, 456, 154},
-{ 1105, 703, 569, 363}, { 1625, 1326, 985, 748}, { -220, 219, 76, -208},
-{-1455,-1662, 49, 149}, { -964, -172, -752, -336}, { 625, 209, -250, -66},
-{-1017, -838, -2, 317}, {-2168,-1485, -138, 123}, {-1876,-2099, -521, 85},
-{ -967, -366, -695, -881}, { -921,-1011, -763, -949}, { -124, -256, -352, -660},
-{ 178, 463, 354, 304}, {-1744, -591, -282, 79}, {-2249, 175, 867, 499},
-{ -138, -180, -181, -21}, {-2291,-1241, -460, -520}, { -771, 451, -10, -308},
-{ 271, -65, 4, 214}, { -279, -435, -43, -348}, { -670, 35, -65, -211},
-{ 806, 535, 85, 297}, { 57, 239, 722, 493}, { 225, 661, 840, 547},
-{ -540, -376, 14, 349}, { 469, 721, 331, 162}, { -544, -752, -62, -10},
-{ 398, -88, 724, 701}, { -19, -533, -94, 601}, { 136, -71, -681, -747},
-{ -166, -344, 261, -50}, { 161, -52, 485, 337}, {-1675, 50, 190, -93},
-{-2282, -231, -194, -82}, { -95, -595, -154, 128}, { 894, 501, 588, 457},
-{ -345, 206, 122, 110}, { -631, -227, -569, 3}, { 408, 239, 397, 226},
-{ -197, -2, 128, 491}, { 1281, 904, 292, 215}, { 538, 306, 259, 509},
-{ -677,-1047, 13, 321}, { -679, -588, -358, -212}, { -558, 243, 646, 479},
-{ 486, 342, 634, 532}, { 107, 802, 331, 136}, { -112, -398,-1031, -286},
-{ -326, -705, 288, 272}, { 1299, 1144, 1178, 860}, { -423, 121, -385, -148},
-{ -295, -302, -834, -819}, { 16, -24, -201, -476}, { 555, 91, -245, 294},
-{ -38, -379, -962,-1221}, {-1191,-1518, -273, -395}, { -390,-1013, -645, 573},
-{-1843,-1030, 505, 468}, { 744, 947, 609, 493}, { -689,-1172, -628, -135},
-{-1026, 195, 411, 196}, { 1582, 1147, 575, 337}, {-1239, -777, -648, -142},
-{ 595, 825, 967, 735}, {-1206, -970, -81, -342}, { -745, 13, -72, 375},
-{ 454, 19, 1407, 921}, {-1647, -172, 861, 562}, { 928, 1537, 1063, 740},
-{-2472, -952, 264, 82}, { -502, -965,-1334, 123}, { 867, 1236, 534, 171},
-{-2320, -460, 780, 363}, {-1190, -617, 252, -61}, { -174, 34, 1011, 788},
-{-2333, 247, 423, 153}, { -16, -355, 262, 449}, {-1576,-1073, -544, -371},
-{ -615, -305, 1051, 805}, { 687, 528, 6, -182}, { 935, 875, 1002, 809},
-{ 199, 257, 126, 76}, { -584,-1138, 599, 556}, {-1105,-1391,-1591, -519},
-{ -977,-1325, 108, 347}, { -722, -975, 365, 101}, { -145, 681, 249, -153},
-{ 0, -334, -570, 159}, { 412, 285, -336, -617}, { -953, -966, 887, 689},
-{-1251, 84, -185, -398}, { -592, 433, 1044, 653}, { 85, 329, -40, 361},
-{ -433, -705, 466, 574}, { -154, 654, 592, 290}, { -167, 72, 349, 175},
-{ 674, 297, 977, 720}, { 1235, 1204, 757, 488}, { -400, -269, 538, 372},
-{-1350,-1387,-1194, -91}, { 1262, 876, 775, 700}, { -599, -38, -430, -722},
-{ 1976, 1630, 991, 608}, { 111, 276, -226, -96}, { -947, -388, -11, -7},
-{ -303, -531, -839, 338}, { 1734, 1710, 1405, 1013}, { -516, -855, -645, 210},
-{ -688, -416, 513, 230}, { -822, -637,-1146, -320}, { -952, -658, -694, 183},
-{ -114, -623, 818, 674}, { -191, -204, 731, 635}, { 51, 1221, 883, 576},
-{ -954, -431, 826, 598}, { -342, -755, -900, -407}, {-1126, -354, -206, -512},
-{ -547, -810, -357, -620}, { 66, 515, -73, -410}, { -872, -945,-1444,-1227},
-{ 191, -17, -544, -231}, {-1540, -544, -901, -886}
-};
-
-static const int16_t lsf_3_1_MODE_7k95[512][3] = {
-{ -890,-1550,-2541}, { -819, -970, 175}, { -826,-1234, -762},
-{ -599, -22, 634}, { -811, -987, -902}, { -323, 203, 26},
-{ -383, -235, -781}, { -399, 1262, 906}, { -932,-1399,-1380},
-{ -624, 93, 87}, { -414, -539, -691}, { 37, 633, 510},
-{ -387, -476,-1330}, { 399, 66, 263}, { -407, -49, -335},
-{ -417, 1041, 1865}, { -779,-1089,-1440}, { -746, -858, 832},
-{ -581, -759, -371}, { -673, -506, 2088}, { -560, -634,-1179},
-{ 271, 241, 14}, { -438, -244, -397}, { 463, 1202, 1047},
-{ -606, -797,-1438}, { -51, -323, 481}, { -224, -584, -527},
-{ 494, 881, 682}, { -433, -306,-1002}, { 554, 659, 222},
-{ 171, -160, -353}, { 681, 1798, 1565}, { -852,-1181,-1695},
-{ -336, -666, 114}, { -581, -756, -744}, { -195, 375, 497},
-{ -465, -804,-1098}, { 154, 282, -131}, { -50, -191, -719},
-{ 323, 732, 1542}, { -722, -819,-1404}, { 105, -250, 185},
-{ -178, -502, -742}, { 321, 510, 1111}, { -323, -567, -966},
-{ 127, 484, 338}, { -160, 52, -338}, { 732, 1367, 1554},
-{ -626, -802,-1696}, { -286, -586, 676}, { -695, -343, -370},
-{ -490, 295, 1893}, { -630, -574,-1014}, { -80, 645, -69},
-{ -6, -318, -364}, { 782, 1450, 1038}, { -313, -733,-1395},
-{ 120, 60, 477}, { -264, -585, -123}, { 711, 1245, 633},
-{ -91, -355,-1016}, { 771, 758, 261}, { 253, 81, -474},
-{ 930, 2215, 1720}, { -808,-1099,-1925}, { -560, -782, 169},
-{ -804,-1074, -188}, { -626, -55, 1405}, { -694, -716,-1194},
-{ -660, 354, 329}, { -514, -55, -543}, { 366, 1033, 1182},
-{ -658, -959,-1357}, { -55, -184, 93}, { -605, -286, -662},
-{ 404, 449, 827}, { -286, -350,-1263}, { 628, 306, 227},
-{ -16, 147, -623}, { 186, 923, 2146}, { -674, -890,-1606},
-{ -443, -228, 339}, { -369, -790, -409}, { 231, 86, 1469},
-{ -448, -581,-1061}, { 594, 450, -177}, { -124, -170, -447},
-{ 671, 1159, 1404}, { -476, -667,-1511}, { -77, -138, 716},
-{ -177, -372, -381}, { 451, 934, 915}, { -250, -432, -822},
-{ 272, 828, 446}, { 26, 19, -31}, { 698, 1692, 2168},
-{ -646, -977,-1924}, { -179, -473, 268}, { -379, -745, -691},
-{ 11, 127, 1033}, { -488, -917, -825}, { 61, 323, 135},
-{ 147, -145, -686}, { 685, 786, 1682}, { -506, -848,-1297},
-{ 35, 90, 222}, { -23, -346, -670}, { 455, 591, 1287},
-{ -203, -593,-1086}, { 652, 352, 437}, { 39, 63, -457},
-{ 841, 1265, 2105}, { -520, -882,-1584}, { -328, -711, 1421},
-{ -596, -342, -70}, { 209, 173, 1928}, { -423, -598, -921},
-{ 421, 605, -38}, { -2, -245, -127}, { 896, 1969, 1135},
-{ -379, -518,-1579}, { 173, 118, 753}, { -55, -381, -52},
-{ 985, 1021, 753}, { -2, -291, -891}, { 753, 992, 423},
-{ 264, 131, -196}, { 895, 2274, 2543}, { -635,-1088,-2499},
-{ -529, -982, 526}, { -764, -830, -548}, { -436, 316, 599},
-{ -675, -940, -746}, { -57, 236, -11}, { -201, -81, -798},
-{ 16, 845, 1558}, { -737, -985,-1212}, { -468, 17, 290},
-{ -279, -584, -700}, { 183, 822, 705}, { -265, -492,-1187},
-{ 421, 152, 468}, { -390, 166, -268}, { 39, 1550, 1868},
-{ -635, -966,-1571}, { -453, -492, 910}, { -284,-1027, -75},
-{ -181, -133, 1852}, { -445, -624,-1174}, { 420, 367, -49},
-{ -389, -212, -169}, { 707, 1073, 1208}, { -539, -710,-1449},
-{ 83, -163, 484}, { -236, -543, -355}, { 338, 1175, 814},
-{ -246, -309, -958}, { 606, 760, 60}, { 166, -8, -163},
-{ -306, 1849, 2563}, { -747,-1025,-1783}, { -419, -446, 209},
-{ -718, -566, -534}, { -506, 693, 857}, { -463, -697,-1082},
-{ 325, 431, -206}, { -15, -8, -763}, { 545, 919, 1518},
-{ -611, -783,-1313}, { 256, -55, 208}, { -165, -348, -662},
-{ 321, 680, 930}, { -326, -429, -951}, { 484, 446, 570},
-{ -197, 72, -73}, { 909, 1455, 1741}, { -563, -737,-1974},
-{ -124, -416, 718}, { -478, -404, -314}, { -16, 446, 1636},
-{ -551, -537, -750}, { -58, 638, 214}, { 55, -185, -271},
-{ 1148, 1301, 1212}, { -483, -671,-1264}, { 117, 285, 543},
-{ -204, -391, -111}, { 513, 1538, 854}, { -114, -190, -978},
-{ 877, 595, 464}, { 260, 260, -311}, { 748, 2283, 2216},
-{ -517, -945,-2171}, { -326, -708, 378}, { -812, -691, -232},
-{ -560, 687, 1409}, { -732, -690, -836}, { -359, 645, 386},
-{ -265, 62, -678}, { 145, 1644, 1208}, { -555, -988,-1233},
-{ -78, 14, 114}, { -327, -358, -489}, { 392, 677, 697},
-{ -201, -236,-1140}, { 693, 449, 178}, { -243, 256, -433},
-{ 611, 1385, 2456}, { -612, -901,-1464}, { -307, -17, 499},
-{ -315, -667, -254}, { 256, 428, 1463}, { -486, -422,-1056},
-{ 655, 370, 18}, { -102, -185, -276}, { 755, 1578, 1335},
-{ -488, -603,-1418}, { 182, -93, 870}, { -73, -458, -348},
-{ 835, 862, 957}, { -282, -333, -746}, { 547, 839, 428},
-{ 273, -89, 13}, { 940, 1708, 2576}, { -418,-1084,-1758},
-{ -44, -358, 259}, { -497, -643, -560}, { 99, 557, 961},
-{ -421, -766, -917}, { 295, 326, 184}, { 175, 15, -626},
-{ 532, 878, 1981}, { -443, -768,-1275}, { 221, 156, 268},
-{ 39, -363, -505}, { 695, 772, 1140}, { -162, -459, -912},
-{ 709, 444, 658}, { 25, 303, -312}, { 1268, 1410, 1715},
-{ -297, -766,-1836}, { -263, -108, 1070}, { -406, -13, -129},
-{ 57, 438, 2734}, { -374, -487, -835}, { 304, 696, 164},
-{ 104, -235, 5}, { 1611, 1900, 1399}, { -229, -582,-1325},
-{ 405, 192, 817}, { -87, -438, 111}, { 1028, 1199, 993},
-{ 68, -175, -934}, { 1033, 1117, 451}, { 478, 200, -248},
-{ 2127, 2696, 2042}, { -835,-1323,-2131}, { -799, -692, 466},
-{ -812,-1032, -469}, { -622, 288, 920}, { -701, -841,-1070},
-{ -411, 512, 8}, { -390, -91, -744}, { -30, 1043, 1161},
-{ -822,-1148,-1156}, { -294, -46, 110}, { -411, -374, -678},
-{ 214, 531, 668}, { -406, -420,-1194}, { 487, 232, 303},
-{ -318, 91, -472}, { 123, 1232, 2445}, { -722, -952,-1495},
-{ -738, -675, 1332}, { -543, -606, -211}, { -95, -98, 1508},
-{ -549, -514,-1193}, { 473, 211, 73}, { -288, -112, -389},
-{ 537, 1332, 1258}, { -567, -755,-1545}, { 71, -283, 632},
-{ -170, -481, -493}, { 681, 1002, 817}, { -356, -331, -877},
-{ 419, 706, 346}, { 241, -34, -326}, { 377, 1950, 1883},
-{ -727,-1075,-1625}, { -233, -543, 116}, { -524, -806, -585},
-{ -73, 478, 729}, { -288, -925,-1143}, { 173, 447, -52},
-{ 68, -229, -606}, { 449, 529, 1797}, { -591, -875,-1363},
-{ 183, -144, 324}, { -103, -452, -666}, { 623, 488, 1176},
-{ -238, -511,-1004}, { 326, 552, 458}, { 136, 108, -319},
-{ 626, 1343, 1883}, { -490, -646,-1730}, { -186, -449, 984},
-{ -738, -76, -170}, { -550, 755, 2560}, { -496, -510, -947},
-{ 210, 694, -52}, { 84, -322, -199}, { 1090, 1625, 1224},
-{ -376, -603,-1396}, { 343, 74, 632}, { -175, -502, -32},
-{ 972, 1332, 734}, { 52, -295,-1113}, { 1065, 918, 160},
-{ 393, 107, -397}, { 1214, 2649, 1741}, { -632,-1201,-1891},
-{ -719, -277, 353}, { -651, -880, -122}, { -211, 209, 1338},
-{ -562, -714,-1059}, { -208, 388, 159}, { -320, -61, -551},
-{ 293, 1092, 1443}, { -648, -865,-1253}, { -49, -143, 305},
-{ -401, -227, -585}, { 561, 532, 927}, { -117, -443,-1188},
-{ 507, 436, 292}, { -79, 233, -458}, { 671, 1025, 2396},
-{ -633, -842,-1525}, { -308, -286, 640}, { -373, -621, -407},
-{ 418, 253, 1305}, { -315, -581,-1137}, { 572, 685, -281},
-{ 61, -68, -371}, { 991, 1101, 1498}, { -493, -683,-1362},
-{ -47, 164, 704}, { -256, -314, -268}, { 631, 949, 1052},
-{ -118, -348, -833}, { 68, 1180, 568}, { 152, 117, 34},
-{ 1113, 1902, 2239}, { -601, -959,-1706}, { -143, -489, 480},
-{ -332, -655, -574}, { 54, 353, 1192}, { -462, -652, -796},
-{ 150, 549, 112}, { 195, -111, -515}, { 679, 1108, 1647},
-{ -558, -749,-1217}, { -9, 272, 341}, { -53, -265, -535},
-{ 489, 843, 1298}, { -120, -482,-1032}, { 632, 543, 408},
-{ 179, 306, -526}, { 1124, 1464, 2244}, { -417, -786,-1562},
-{ -224, -384, 1364}, { -377, -459, -25}, { 385, 489, 2174},
-{ -332, -651, -829}, { 544, 553, 61}, { 22, -113, -89},
-{ 1128, 1725, 1524}, { -216, -373,-1653}, { 161, 316, 908},
-{ -165, -222, -67}, { 1362, 1175, 789}, { 73, -252, -767},
-{ 738, 932, 616}, { 362, 246, -126}, { 787, 2654, 3027},
-{ -691,-1106,-2190}, { -565, -588, 524}, { -590, -979, -490},
-{ -263, 397, 982}, { -577, -837, -945}, { -22, 435, -49},
-{ -190, -118, -629}, { -88, 1240, 1513}, { -636,-1051,-1019},
-{ -291, 189, 259}, { -257, -470, -629}, { 145, 945, 894},
-{ -326, -364,-1094}, { 543, 260, 630}, { -202, 189, -209},
-{ 357, 1379, 2091}, { -569,-1075,-1449}, { -714, -239, 919},
-{ -420, -705, -84}, { -109, -114, 2407}, { -413, -529,-1177},
-{ 482, 368, 131}, { -186, -72, -131}, { 861, 1255, 1220},
-{ -611, -658,-1341}, { 227, -121, 631}, { -176, -489, -218},
-{ 745, 1175, 957}, { -321, -148, -936}, { 671, 966, 216},
-{ 340, -3, -143}, { 469, 1848, 2437}, { -729, -961,-1683},
-{ -213, -254, 321}, { -511, -438, -521}, { -126, 725, 903},
-{ -340, -685,-1032}, { 316, 480, 20}, { 23, -89, -551},
-{ 353, 1051, 1789}, { -544, -757,-1364}, { 298, -25, 436},
-{ -100, -392, -519}, { 467, 754, 1078}, { -210, -398,-1078},
-{ 620, 658, 630}, { 33, 147, -178}, { 921, 1687, 1921},
-{ -325, -528,-1978}, { 2, -285, 910}, { -371, -490, -230},
-{ 0, 597, 2010}, { -496, -395, -834}, { 37, 945, 245},
-{ 181, -160, -144}, { 1481, 1373, 1357}, { -355, -601,-1270},
-{ 298, 322, 672}, { -193, -336, 77}, { 1089, 1533, 922},
-{ 177, -39,-1125}, { 996, 781, 536}, { 456, 366, -432},
-{ 1415, 2440, 2279}, { -466, -758,-2325}, { -303, -509, 387},
-{ -727, -557, 66}, { -145, 643, 1248}, { -544, -676, -916},
-{ -225, 862, 588}, { -152, 40, -533}, { 423, 1423, 1558},
-{ -572, -843,-1145}, { -128, 85, 461}, { -238, -257, -584},
-{ 605, 748, 861}, { 24, -202,-1409}, { 797, 487, 303},
-{ -181, 364, -182}, { 616, 1378, 2942}, { -494, -852,-1441},
-{ -292, 61, 812}, { -84, -723, -182}, { 555, 532, 1506},
-{ -365, -493,-1057}, { 822, 588, 11}, { -14, -18, -230},
-{ 1001, 1401, 1451}, { -474, -569,-1292}, { 302, 62, 1062},
-{ -70, -376, -222}, { 982, 974, 1149}, { -196, -234, -795},
-{ 479, 1098, 499}, { 362, 58, 70}, { 1147, 2069, 2857},
-{ -487, -878,-1824}, { 73, -288, 348}, { -358, -500, -508},
-{ 199, 721, 1242}, { -78, -697, -795}, { 361, 536, 196},
-{ 374, 110, -735}, { 847, 1051, 1896}, { -366, -713,-1182},
-{ 315, 320, 429}, { 72, -215, -450}, { 759, 886, 1363},
-{ -30, -428, -834}, { 861, 627, 796}, { 118, 468, -279},
-{ 1355, 1883, 1893}, { -188, -642,-1612}, { 63, -175, 1198},
-{ -418, -211, 51}, { 414, 587, 2601}, { -234, -557, -858},
-{ 424, 889, 222}, { 136, -101, 83}, { 1413, 2278, 1383},
-{ -84, -445,-1389}, { 414, 313, 1045}, { 29, -343, 65},
-{ 1552, 1647, 980}, { 183, -91, -829}, { 1273, 1413, 360},
-{ 553, 272, -107}, { 1587, 3149, 2603}
-};
-
-static const int16_t lsf_3_1[256][3] = {
-{ 6, 82, -131}, { 154, -56, -735}, { 183, -65, -265},
-{ 9, -210, -361}, { 113, 718, 1817}, { 1010, 1214, 1573},
-{ 857, 1333, 2276}, { 827, 1568, 1933}, { 717, 1989, 2206},
-{ 838, 1172, 1823}, { 721, 1000, 2154}, { 286, 476, 1509},
-{ -247, -531, 230}, { 147, -82, 569}, { 26, -177, -944},
-{ -27, -273, 692}, { -164, -264, -183}, { 224, 790, 1039},
-{ 899, 946, 601}, { 485, 771, 1150}, { 524, 677, 903},
-{ -140, 375, 778}, { 410, 676, 429}, { 301, 530, 1009},
-{ 719, 646, 38}, { 226, 367, 40}, { 145, -45, -505},
-{ 290, 121, -121}, { 302, 127, 166}, { -124, -383, -956},
-{ -358, -455, -977}, { 715, 878, 894}, { 978, 923, 211},
-{ 477, 272, 64}, { 188, -78, 17}, { -143, -65, 38},
-{ 643, 586, 621}, { -134, -426, -651}, { 347, 545, 2820},
-{ 1188, 2726, 2442}, { 142, -80, 1735}, { 283, 130, 461},
-{ -262, -399,-1145}, { -411, 155, 430}, { 329, 375, 779},
-{ 53, -226, -139}, { -129, -236, 1682}, { 285, 744, 1327},
-{ 738, 697, 1664}, { 312, 409, 266}, { 325, 720, 135},
-{ 1, 221, 453}, { 8, 203, 145}, { 299, 640, 760},
-{ 29, 468, 638}, { 103, 429, 379}, { 420, 954, 932},
-{ 1326, 1210, 1258}, { 704, 1012, 1152}, { -166, -444, -266},
-{ -316, -130, -376}, { 191, 1151, 1904}, { -240, -543,-1260},
-{ -112, 268, 1207}, { 70, 1062, 1583}, { 278, 1360, 1574},
-{ -258, -272, -768}, { 19, 563, 2240}, { -3, -265, 135},
-{ -295, -591, -388}, { 140, 354, -206}, { -260, -504, -795},
-{ -433, -718,-1319}, { 109, 331, 962}, { -429, -87, 652},
-{ -296, 426, 1019}, { -239, 775, 851}, { 489, 1334, 1073},
-{ -334, -332, 25}, { 543, 1206, 1807}, { 326, 61, 727},
-{ 578, 849, 1405}, { -208, -277, 329}, { -152, 64, 669},
-{ -434, -678, -727}, { -454, -71, 251}, { 605, 480, 254},
-{ -482, 11, 996}, { -289, 395, 486}, { 722, 1049, 1440},
-{ -30, -316, -786}, { -106, -115, -619}, { 861, 1474, 1412},
-{ 1055, 1366, 1184}, { 812, 1237, 925}, { 42, -251, -576},
-{ 342, 141, -454}, { -168, -80, 1359}, { -342, -656,-1763},
-{ 100, 821, 725}, { 990, 747, 800}, { 332, 440, 568},
-{ 663, 379, 852}, { 112, 165, -369}, { 597, 910, 282},
-{ -8, 834, 1281}, { -352, 572, 695}, { 462, 2246, 1806},
-{ 345, 190, 1374}, { 416, 915, 2166}, { 168, -82, 280},
-{ -516, -446, 840}, { 47, 533, 44}, { -362, -711,-1143},
-{ 22, 193, 1472}, { -85, 233, 1813}, { -62, 579, 1504},
-{ 550, 944, 1749}, { 723, 650, 1148}, { 972, 884, 1395},
-{ -425, 643, 0}, { 1000, 952, 1098}, { 249, 1446, 672},
-{ -334, -87, 2172}, { -554, 1882, 2672}, { 140, 1826, 1853},
-{ 920, 1749, 2590}, { 1076, 1933, 2038}, { -137, -443,-1555},
-{ 1269, 1174, 468}, { -493, -122, 1521}, { -451, 1033, 1214},
-{ 482, 1695, 1118}, { 815, 649, 384}, { -446, -692, 107},
-{ -319, -605, -118}, { -207, -505, 525}, { -468, -12, 2736},
-{ 75, 1934, 1305}, { 880, 2358, 2267}, { 1285, 1575, 2004},
-{ -48, -304,-1186}, { -435, -461, -251}, { -366, -404, -547},
-{ -289, -605, -597}, { -538, -810, -165}, { -120, 3, 356},
-{ 639, 1241, 1502}, { 96, 177, 750}, { -435, -585,-1174},
-{ -356, 109, -79}, { -485, 288, 2005}, { 9, 1116, 731},
-{ 880, 2134, 946}, { -265, 1585, 1065}, { 1157, 1210, 843},
-{ -498, -668, 431}, { 374, 321, -229}, { 1440, 2101, 1381},
-{ 449, 461, 1155}, { -105, 39, -384}, { -263, 367, 182},
-{ -371, -660, 773}, { -188, 1151, 971}, { 1333, 1632, 1435},
-{ 774, 1267, 1221}, { -482, -832,-1489}, { -237, -210, 860},
-{ 890, 1615, 1064}, { 472, 1062, 1192}, { 185, 1077, 989},
-{ -568, -992,-1704}, { -449, -902,-2043}, { -142, -377, -458},
-{ -210, -554,-1029}, { -11, 1133, 2265}, { -329, -675, -893},
-{ -250, 657, 1187}, { 519, 1510, 1779}, { 520, 539, 1403},
-{ 527, 1421, 1302}, { -563, -871,-1248}, { -147, -463, 879},
-{ -76, 2334, 2840}, { 563, 2573, 2385}, { 632, 1926, 2920},
-{ 719, 2023, 1840}, { -545, -723, 1108}, { 129, -125, 884},
-{ 1417, 1632, 925}, { -94, 1566, 1751}, { -341, 1533, 1551},
-{ 591, 395, -274}, { -76, 981, 2831}, { 153, 2985, 1844},
-{ 1032, 2565, 2749}, { 1508, 2832, 1879}, { 791, 1199, 538},
-{ -190, -453, 1489}, { -278, -548, 1158}, { -245, 1941, 2044},
-{ 1024, 1560, 1650}, { 512, 253, 466}, { -62, -323, 1151},
-{ -473, -376, 507}, { -433, 1380, 2162}, { 899, 1943, 1445},
-{ 134, 704, 440}, { 460, 525, -28}, { -450, 279, 1338},
-{ 0, 971, 252}, { -445, -627, -991}, { -348, -602,-1424},
-{ 398, 712, 1656}, { -107, 314, -178}, { 93, 2226, 2238},
-{ 518, 849, 656}, { -462, -711, -447}, { 174, -34, 1191},
-{ -119, 42, 1005}, { -372, 274, 758}, { 1036, 2352, 1838},
-{ 675, 1724, 1498}, { 430, 1286, 2133}, { -129, -439, 0},
-{ -373, 800, 2144}, { 6, 1587, 2478}, { 478, 596, 2128},
-{ -428, -736, 1505}, { 385, 178, 980}, { 139, 449, 1225},
-{ -526, -842, -982}, { 145, 1554, 1242}, { 623, 1448, 656},
-{ 349, 1016, 1482}, { 31, -280, 415}, { -316, 724, 1641},
-{ 360, 1058, 556}, { -436, -358, 1201}, { -355, 1123, 1939},
-{ 401, 1584, 2248}, { -527,-1012, 355}, { 233, 238, 2233},
-{ -550, -897, -639}, { -365, -501, 1957}, { 389, 1860, 1621},
-{ 162, 1132, 1264}, { -237, 1174, 1390}, { -640, -411, 116},
-{ -228, 1694, 2298}, { 1639, 2186, 2267}, { 562, 1273, 2658},
-{ 323, 338, 1774}, { 578, 1107, 852}, { 22, 594, 934},
-{ -143, 718, 446}
-};
-
-
-static const int16_t lsf_3_2[512][3] = {
-{ 50, 71, -9}, { -338, -698,-1407}, { 102, -138, -820},
-{ -310, -469,-1147}, { 414, 67, -267}, { 1060, 814, 1441},
-{ 1548, 1360, 1272}, { 1754, 1895, 1661}, { 2019, 2133, 1820},
-{ 1808, 2318, 1845}, { 644, -93, 454}, { 858, 329, -136},
-{ 489, -258, -128}, { -198, -745, -41}, { -52, -265, -985},
-{ 346, 137, 479}, {-1741, -748, -684}, {-1163,-1725, -367},
-{ -895,-1145, -784}, { -488, -946, -968}, { -85, -390, -725},
-{ 215, -340, -171}, { 1020, 916, 1969}, { 564, 179, 746},
-{ 662, 977, 1734}, { 887, 622, 914}, { 939, 856, 1165},
-{ 309, 688, 803}, { 917, 161, 570}, { 118, -20, -283},
-{ -816, -42, 204}, {-1228, -325, -462}, { -963, -202, -143},
-{ -988, -484, -361}, { -702, -978, -477}, { -302, -790,-1188},
-{ -100, -786,-1088}, {-1054, -947,-1684}, { -202, -843, -782},
-{-1039,-1378, -901}, { -624, -110, -85}, { 356, 213, -10},
-{ -493, 364, 774}, { 425, 822, 479}, { -83, 557, 520},
-{ -992,-1560, -572}, { -603, -741, -26}, { -502, -638, -903},
-{ 209, 306, 147}, { -316, -593, -596}, { -85, -211, -225},
-{ -918, -529, 117}, { 233, -439, -738}, { 1101, 751, 633},
-{ 1457, 1716, 1511}, { 1765, 1457, 910}, { 1122, 1156, 849},
-{ 1354, 868, 470}, { -871,-1150,-1796}, { -871, -861, -992},
-{ -118, 155, 212}, {-1051, -849, -606}, {-1117,-1849,-2750},
-{-1019,-1427,-1869}, { 370, -184, -414}, { 959, 493, 104},
-{ 958, 1039, 543}, { 154, 653, 201}, { 1249, 507, 150},
-{ 663, 503, 230}, { 623, 777, 675}, { 659, 88, -110},
-{ 843, 244, 224}, { 382, 541, 302}, { 724, 433, 666},
-{ 1166, 734, 341}, { -138, 20, -397}, {-1183, -424, -46},
-{ -321, -352, -124}, { 1333, 1021, 1080}, { 262, 366, 723},
-{ 922, 283, -551}, { 31, -636, -611}, { -689, -697, -415},
-{ -952, -779, -201}, {-1329, -598, -359}, { -953,-1285, 166},
-{ 493, 305, 221}, { 846, 703, 610}, { 840, 936, 774},
-{ -723,-1324,-1261}, { -357,-1025,-1388}, {-1096,-1376, -365},
-{-1416,-1881, -608}, {-1798,-1727, -674}, { -545,-1173, -703},
-{ 678, 786, 148}, { -123, 696, 1288}, { 644, 350, -10},
-{ 414, 614, 15}, { 137, 344, -211}, { -814,-1512, -819},
-{ -391, -930, -588}, { 47, -591, -898}, { -909,-1097, -163},
-{-1272,-1167, -157}, {-1464,-1525, -389}, {-1274,-1188, -624},
-{ 671, 213, 454}, { 124, -274, -525}, { -729, -496, -152},
-{-1344, 122, 135}, {-2905, -589, -394}, {-1728, 441, -50},
-{ 1476, 904, 787}, { 316, 236, -440}, { -347, 217, 413},
-{ -911, -917, 121}, { -455, -932, 202}, { -92, -465, -375},
-{ 488, 390, 474}, { 876, 729, 316}, {-1815,-1312, -669},
-{ 87, 962, 432}, { 563, -249,-1058}, { 250, 285, 1105},
-{ 1141, 427, 696}, {-1038,-1664,-1582}, { -948, 346, 160},
-{ -309, -272, -858}, { 670, 624, 1250}, { -944, -408, -666},
-{ -606, -320, -384}, { -492, 230, 65}, { 334, -50, -16},
-{ -16, -690,-1397}, { 1791, 1716, 1399}, { 2478, 2063, 1404},
-{ 1245, 1471, 1426}, { -382,-1037, -2}, { 173, -398, 1145},
-{ 1491, 2024, 1801}, { 772, 1274, 1506}, { 1429, 1735, 2001},
-{ 1079, 1218, 1273}, {-1154,-1851,-1329}, { -808,-1133,-1096},
-{ -451,-1033,-1722}, { 65, 578, -84}, {-1476,-2434,-1778},
-{ -765,-1366, -494}, { -218, -594, -931}, { 337, -236, 562},
-{ 2357, 2662, 1938}, { 1489, 1276, 874}, { 189, 358, 374},
-{-1519,-2281,-2346}, { -967,-1271,-2095}, { -628,-1188,-1542},
-{ 1661, 1043, 546}, { 565, 1061, 732}, { -64, -836, -434},
-{ -436, -96, 203}, { 1078, 1216, 1636}, { 907, 1534, 986},
-{ 326, 965, 845}, { 142, -84, 197}, { 470, 2379, 1570},
-{ 1133, 470, 1214}, { 395, 1376, 1200}, { 1125, 1042, 348},
-{ -543,-1234, -376}, { -215, -181, 481}, {-1947,-1621, -210},
-{ -750,-1185, 390}, { 29, -399, 27}, { 820, 1236, 755},
-{ 695, 979, 409}, { -174, 1197, 1035}, { 912, 1356, 1846},
-{ -992,-1437, 484}, {-1485,-1700, 208}, { -412, 1204, 1432},
-{ -271, 896, 1144}, { -416, 1777, 1434}, {-1696,-2644, -204},
-{-1789,-1551, 1033}, {-1656,-1559, 1303}, {-1253,-1589, 1081},
-{ -669,-1095, -66}, { -682, 320, -345}, { 659, 305, 1069},
-{-1292, -804, -19}, {-1635,-1291, 29}, {-1683, -497, 71},
-{ -287, -7, -100}, { -494, -962, -237}, { 852, 1881, 1740},
-{-1217,-1387, 227}, { -660, 302, 373}, { 96, 1087, 1257},
-{-1074,-1669, 160}, { 485, 2076, 1798}, { -934, -220, 552},
-{ -596, -612, 237}, { 336, 1720, 879}, { 643, 629, 434},
-{ 1267, 522, 1633}, { 15, 244, -441}, { 1475, 717, 184},
-{ 1819, 1590, 1709}, { 988, 261, 937}, { 2093, 2345, 1520},
-{ 2139, 1858, 1606}, { -577, -579,-1203}, { -956, 135, -488},
-{ -464, 51, -338}, { -629, -348, -723}, { 1146, 2073, 1442},
-{ 2192, 1466, 911}, {-1444,-1572,-2278}, { 1400, 710, 1297},
-{ 1335, 633, 928}, { 1434, 2194, 2594}, { 2422, 2204, 1881},
-{ 982, 2242, 1854}, { 380, 792, 1145}, { -63, -539, 414},
-{ -252, -964, -314}, {-1261, -683, -780}, { -831, -526,-1005},
-{-1666,-1135, -424}, {-1611, -452, -299}, { 1268, 1048, 642},
-{ 1147, 853, 856}, { -675, -336, 139}, { 2268, 1343, 1418},
-{ 29, 768, 797}, {-1224, 423, 564}, {-1318,-1082, 245},
-{-1302, -812, 573}, {-1298,-1617, 646}, { -968, 834, 723},
-{ 993, 1652, 2027}, { -191, -817, 432}, { 662, 60, 198},
-{ 626, 997, 1330}, { 1648, 1963, 1289}, {-1597, -93, -45},
-{-1088, 37, -84}, { 1653, 2607, 2337}, { 1065, 2040, 2377},
-{ 1139, 2326, 2118}, { 859, 357, 1510}, { 664, 1227, 1099},
-{ 479, 1360, 912}, { 1897, 1754, 2019}, { 1168, 1909, 1784},
-{ 399, 34, 256}, { -593, -304,-1053}, { 547, 1694, 1407},
-{ 647, -99, -341}, { 1492, 1647, 1190}, { 38, -644, -212},
-{ 395, 846, 222}, { -704, -765, -716}, { -724,-1964,-2804},
-{ -150, 291, -82}, { 1233, 1459, 1007}, { -140, -155, 153},
-{ 439, 297, 1568}, {-1529, -410, -636}, { 1536, 455, -237},
-{-1328, -139, -260}, { 531, 554, 868}, { 269, 1264, 606},
-{ -233, 883, 463}, { 742, 600, -120}, { -73, 421, 212},
-{ -439, -58, 804}, {-1286,-1241, 728}, { 294, -490, 50},
-{ -591, -905,-1254}, { 42, -687, 147}, { -25, 273, 596},
-{ -311, 1213, 601}, { -754, 849, 584}, { 429, 607, 587},
-{ -602, -166, 461}, { -796, -823, 777}, { 1380, 910, 1755},
-{ 119, 1417, 972}, { -219, -880,-1596}, {-1049,-1010, 438},
-{ -713,-1379, 78}, { 0, -447,-1179}, {-1136,-1319,-1573},
-{ 2248, 1767, 1309}, { 946, 1583, 1432}, { 1150, 482, 436},
-{ -469,-1108, 618}, { -447, -966, 1088}, {-1252,-1515, -114},
-{-1104,-2008, -579}, { 210, 613, 497}, {-1975,-1437, 642},
-{-1269, -856, 1011}, {-1646,-1185, 1063}, {-1555, -672, 1204},
-{-1692,-1114, 623}, { -979,-1326,-1277}, { 539, -147, 894},
-{-1354, -897, -434}, { 888, 475, 428}, { 153, -384, 338},
-{-1492, -511, 359}, { -974,-1115, -470}, { 105, -550, 677},
-{ -937,-1145, 877}, { 380, -260, 210}, { 1685, 924, 1256},
-{ 1775, 1190, 1095}, { 1419, 631, 533}, { 627, 299, -347},
-{ -411, -534, 647}, { -650, 29, -595}, { -378,-1367, 1563},
-{ 1402, 1121, 1465}, { 1089, 1410, 648}, {-2096,-1090, -6},
-{ 311, -194, -869}, { -639, -831, 416}, {-1162,-1224, 1349},
-{-1247, -941, 1813}, {-2193,-1987, 453}, { -619,-1367, -956},
-{-1606,-1972,-1507}, {-1175,-1057,-1104}, { -377, 601, 201},
-{ 1876, 825, 374}, { -430,-1323, 29}, {-1397,-1249,-1331},
-{-1007,-1504, 960}, {-1401,-2009, 197}, {-1379,-1949, -236},
-{-1077, 123, 422}, { 615, 1269, 546}, { -306, 1526, 904},
-{ 1194, 1788, 1177}, { -626, -884,-1526}, { 199, 766, 1504},
-{-1065, 862, 197}, {-1034,-1773, -887}, { -800, 145, 599},
-{-1134, -519, 626}, {-1205,-1926, 500}, { -910,-1041,-1395},
-{-1476,-1567, -969}, { -523, 842, 34}, { 1794, 646, 862},
-{-1207,-1888,-1002}, { -78, -9, -672}, { 1044, 759, 80},
-{ -600, 1139, 1019}, { 57, 2000, 1422}, { -833, 1414, 1121},
-{-1202, 1630, 1260}, { -461, 1420, 1244}, { 1537, 975, 253},
-{ -283, 324, -359}, { 599, -195, 106}, { 588, 62, -587},
-{ -757, 645, 205}, { 51, 1201, 758}, {-1209, 673, -390},
-{ -624, 1581, 941}, { -151, 1023, 735}, { 2820, 1301, 690},
-{ -302, 524, -99}, { -900,-1588,-1189}, { 1084, 251, 238},
-{ 2014, 1792, 1010}, { 1245, 1633, 1741}, {-1227,-1540,-1208},
-{ -621, 456, -109}, { 40, -65, 788}, { -805, -699,-1350},
-{ -583, 904, 832}, { -801, 532, 594}, { 1972, 1408, 1351},
-{-1177,-1880,-2114}, { -773, 568, 948}, {-1015, 1079, 1260},
-{-1111, 482, -130}, { 1778, 1044, 780}, {-1491, 245, 912},
-{ -316,-1141, -917}, { -536,-1442,-2346}, { -785,-1546,-1988},
-{-2003, 257, 909}, {-1849, -633,-1209}, {-1538,-1918,-1054},
-{ 1606, 2239, 1576}, { -567,-1500,-1544}, {-1279, 195, 1369},
-{ -817, 293, 1219}, { -525, 630, 1197}, {-1698,-2425,-1840},
-{ -303, 731, 747}, {-1169, -251, 269}, { -950, -75, 1684},
-{-1182, -453, 1005}, {-1599, 585, 378}, {-2075, -571, -427},
-{ -529,-1159,-1171}, { -283, -205, -564}, { -796, 1246, 717},
-{ 2277, 927, 539}, { -454, 559, 440}, { -717, 1460, 1615},
-{-1030, 1052, 1610}, {-1169, -138, 847}, { 226, 39, -612},
-{-1251, -106, -729}, { -651, 968, 1302}, { -714, -636, 1727},
-{ 353, 1069, 410}, { -798, -156, 1099}, { -574, 918, 446},
-{-1310, 1012, 466}, { 1408, 1591, 765}, { 1429, 1380, 1757},
-{ 1949, 1956, 2378}, { 1578, 2047, 2148}, { 916, 98, -7},
-{ 1893, 1418, 2141}, { 348, 1405, 1579}, { 152, 1134, 1801},
-{ -267, 154, 1395}, {-1166, 469, 1054}, {-1142, -405,-1073},
-{-1341,-2264,-1581}, { -364, 869, 1706}, {-1162, 549, 1550},
-{-1225,-1932,-1666}, {-1485,-1977,-2055}, {-1727, -906, -98},
-{-1897, 233, 1492}, { 892, 108, -331}, {-1728,-1170,-1700},
-{-1060, 1980, 1790}, {-1070,-1741,-1909}, { -11, 1539, 1317},
-{-1600, 94, 497}, { 421, 443, -197}, {-1578, -349, -994},
-{ -599, -539, 1140}, { -965,-1419, -129}, {-1341, 175, -447},
-{ -375, 1311, 2055}, { -371, -650, -307}, {-1073, 605, 365},
-{-2057, -113, 430}, { 652, 914, 967}, {-1012,-1586,-2323},
-{ 1505, 1248, 559}, { 262, -486, -401}, {-1727, 1342, 1546},
-{ 50, 56, 432}, { -330, 119, -604}, {-1517,-1080, -810},
-{ 946, 1127, 1055}, {-1400,-1703,-1712}, {-1270, -704,-1317},
-{ 807, 1821, 1143}, { 2760, 1606, 2171}, { 1120, 409, -150},
-{ -147, 404, 959}, { 2439, 1911, 2189}, { -906, -141, -866},
-{ -904, -142, -458}, { -557, -708,-1679}, { -830,-1431,-1583},
-{-1842,-1346,-1086}, {-1604, -272, 915}, {-1196, 772, 1056},
-{ -638,-1234,-1897}, { -500, -81, -822}, {-1289,-1613, -735},
-{ -117, 785, 168}, {-1090, 1133, 922}, {-1096, -746, 1384},
-{ 287, -547,-1063}, {-1376,-2201,-1204}, {-2176,-1570,-1757},
-{-1511,-2241, -771}, {-1737, 1099, 830}, {-1588, 724, 1243},
-{-1542, 693, 805}, {-1690, -240, 1665}, {-1700, -4, -668},
-{ 2149, 816, 1042}, { -818,-1841, 22}, { -764, -507, 449},
-{-1151, -617, 289}, { -843,-1596, -240}, { 498, -234, -657},
-{ -752, 480, 1678}, { -319, -481, 193}, { -811, 171, -119},
-{-2128, -202, -848}, { 1717, 1140, 1700}
-};
-
-static const int16_t lsf_3_3[512][4] = {
-{ 67, -17, 66, -12}, {-1690, -581, -104, -272}, {-1076,-1186,-1845, -376},
-{-1140, -926, -420, -58}, { -259, -656,-1134, -553}, { 1788, 1227, 455, 129},
-{ 462, 441, -240, -528}, { 840, 514, 130, -75}, { 1114, 623, 153, 216},
-{ 1068, 564, -6, -276}, { 1119, 727, 190, -68}, { 704, 306, 119, -264},
-{ 329, 61, -100, 156}, { 364, 123, 183, -208}, { -171, -123, 220, -65},
-{ -306, -62, 402, 17}, { -660, -938, -266, 0}, { 385, 235, 276, 285},
-{ 320, 268, -336, -200}, { -724, 17, -84, 381}, { -544, 429, 494, 519},
-{ -117, 288, 304, 329}, { 643, 157, 701, 508}, { 1200, 625, 796, 608},
-{ 998, 421, 492, 632}, { 1204, 780, 446, 132}, { 1257, 844, 547, 449},
-{ 829, 658, 541, 470}, { 1132, 1258, 918, 639}, { 547, 51, 423, 279},
-{ 9, 392, 83, 94}, { 542, 543, 229, -147}, { -198, 129, 194, -185},
-{ -863,-1321, -302, 30}, { -597, -629, -19, 114}, { -900,-1081, 466, 353},
-{-1483,-1573, 15, -143}, {-1708,-2059, -751, 196}, {-1876,-2067, -642, -258},
-{-2335,-1470, -450, -564}, { -584, -186, -872, -414}, {-1805, -988,-1125,-1310},
-{ -726,-1129, 28, 169}, {-1039, -864, -718, -246}, { 484, 36, -233, -49},
-{ 265, 67, 289, 467}, { 178, 543, 810, 540}, { 84, 282, 672, 703},
-{ -975, -777, 129, 287}, { -938, -227, 955, 595}, {-1617, -289, 836, 649},
-{-1847, -215, 1106, 718}, {-2034,-1085, 650, 440}, {-2101, -529, 907, 575},
-{-2011, -336, 670, 204}, {-2389, -692, 360, 137}, {-2156,-2204, -9, 280},
-{ -266, 119, 39, 193}, { 78, -59, -120, 226}, { -975, -858, -781,-1095},
-{ -619, -413, -451, -842}, {-1216,-1321, -813, -883}, {-1376,-1615, -394, -428},
-{ -737,-1113, -549, -790}, { -880, -975, -967, -642}, { -985, -886,-1273,-1361},
-{ -473, -804,-1401,-1407}, { 160, -265, -919, -275}, { -248, -250, -718, -380},
-{ 97, -103, -375, -229}, { -415, -193, -135, -555}, { 628, 361, 119, 216},
-{ 579, 364, 391, 209}, { 634, 522, -154, -148}, { 526, 389, 170, 33},
-{ 105, 267, 64, 380}, {-1503,-1000, -30, -369}, {-1070, 58, 647, 223},
-{-1520, -291, 621, 307}, {-1531, 156, 762, 404}, {-2029, 141, 734, 499},
-{-1849, -650, 306, 512}, { -187, -104, -59, 438}, { 134, -230, 156, -186},
-{ -61, -260, -16, 10}, { -569, -3, -421, -297}, {-1725, -521, -346, 178},
-{-1362, -59, -44, 157}, {-2146, -461, -470, -349}, {-2170, -1, -369, -121},
-{-1579, -373, -900,-1015}, {-1117, -591, -613, -784}, { -561, 122, -75, -449},
-{ -4, -171, -123, -372}, { 192, 168, -76, -132}, { 252, -107, 340, 210},
-{ 392, 509, 272, 181}, { -109, 145, 218, 119}, { -416, -263, 485, 265},
-{ -181, -8, -286, 226}, { -244, -218, 69, -290}, { -158, 191, -1, -64},
-{ -592, -90, 213, -96}, { 255, 435, 178, -80}, { -369, -18, -33, -80},
-{ -42, 415, 140, -222}, { 1143, 651, 649, 329}, { 767, 556, 249, 235},
-{ 948, 413, 442, 279}, { 141, 339, 356, 557}, { -470, -170, 99, 237},
-{ -569, -800, 352, 565}, { 282, 473, 470, 332}, { -199, -690,-1284, -917},
-{ -193, -426, -800,-1122}, { -26, -371, -490, -193}, { 637, 595, 519, 330},
-{ 408, -115, 79, 12}, { 477, 87, -103, -376}, { -666, -347, -277, -291},
-{ -510, -481, 169, 297}, { -829, -738, -205, -171}, { -320, -540, 328, 283},
-{ -859, -958, 442, -2}, { 556, 686, 130, 56}, { 1383, 1012, 755, 427},
-{ 612, 741, 628, 553}, { -339, -796, 134, 277}, { -633,-1085, -2, -246},
-{ -880,-1035,-1607,-1064}, { -994, -474,-1138, -488}, { -414, -795, 73, -206},
-{ -8, -139, 439, 204}, { -176, -578, 23, 131}, { -269, -757, -191, 245},
-{ -109, -338, 112, 316}, { 120, -406, -118, 611}, { -180, -186, -645, 115},
-{ -173, 34, -518, -489}, { -151, 61, -583, -844}, { 220, -138, -681,-1020},
-{ 391, -17, -598, -321}, { 157, -295, 129, 155}, { -926, -875, -987, 285},
-{ 241, -83, -125, -125}, { 620, 597, 432, 92}, { 393, 78, 409, 61},
-{ -393, -739, -413, -748}, { 83, 54, 361, 27}, {-1084, 130, -337, -694},
-{-1565, 297, 318, -19}, {-1873, 36, 51, -317}, {-2323, -246, 231, -84},
-{-2306, -783, 40, -179}, {-2233, -930, -474, -462}, { -754, -86, -288, -626},
-{-2411, -455, -63, 171}, {-1099,-1094, -26, -143}, {-1193, -455, -406, -381},
-{ -605, -210, -96, -51}, { -580, -476, -276, -15}, {-1195, -634,-1203, -881},
-{ -378, -221, -669, -952}, { 594, 178, -403, -676}, { 763, 327, 601, 290},
-{ 172, 300, 203, 157}, { -56, -336, 356, 24}, { -228, -296, -259, -29},
-{ -186, 263, 416, 14}, { -353, 373, -12, -216}, { 257, 96, 174, 57},
-{-1526, -616, -954, -499}, { -497, -152, -333, 125}, { 105, 200, 179, -97},
-{ -331, -224, 765, 697}, { 760, 256, 301, 59}, { 455, -85, 204, 288},
-{ -514, 240, 251, -109}, { 256, 417, -34, -413}, { 101, 430, 384, 156},
-{ -31, -10, 206, 426}, { 589, 145, 143, 71}, { 808, 906, 333, 349},
-{ 986, 938, 589, 331}, { 1300, 824, 187, 509}, { 1062, 653, 379, 466},
-{ 1462, 937, 401, 274}, { 787, 861, 265, 2}, { 609, 553, 28, 305},
-{ 926, 340, 106, 386}, { 241, -267, -147, 225}, { -178, -534, 347, 502},
-{ -643, -381, 397, 30}, { -651, -733, -435, 398}, { -407, -726, -484, -248},
-{ -789, -914, -438, -476}, { -498, -390, 75, -295}, { -964, -590, -606, 150},
-{ -121, -49, -155, -78}, { 935, 550, 389, 38}, { -321, 127, 424, 315},
-{ -285, -113, 283, 259}, { 658, 203, 322, 486}, { 903, 505, 748, 417},
-{ 611, 423, 555, 512}, { 239, -83, -578, -19}, { -339, -731, 349, 13},
-{ -934,-1399, -114, -360}, { 107, 692, 182, 90}, {-1243,-1538,-1551, -725},
-{ -568, -903,-1363, -525}, { -517, -853, -861,-1004}, { -168, -690, -835, 63},
-{ -137, -556, -547, 144}, { -286, -817, 485, 319}, { -147, -408, 526, 246},
-{ -347, -434, 297, -28}, { -290, -471,-1110,-1285}, { -460, -359, -988, -794},
-{ 1347, 1299, 690, 523}, { 1216, 1068, 1094, 757}, { 825, 1140, 752, 494},
-{ 1252, 1365, 1195, 898}, { 521, 1053, 532, 432}, { -334, -216, -313, -263},
-{ -160, 52, -472, -155}, { 127, 136, -380, 44}, { 851, 410, -162, -489},
-{ 123, -255, -796, -667}, { 1090, 917, 789, 493}, { 1397, 1197, 558, 202},
-{ -51, -118, -342, -701}, { 83, 108, -42, -441}, { 61, 95, 287, 256},
-{ -27, 89, 524, 531}, { 351, 227, 592, 545}, { 697, 155, -164, 307},
-{ 638, 274, -489, -50}, { 754, 240, -166, -124}, { -116, -579,-1212, -63},
-{ 190, -295,-1040,-1296}, { 147, -376, -177, -113}, { 841, 1241, 1051, 668},
-{ 2, 293, 551, 304}, {-1096, -953, -248, 376}, { -750, -965, 87, 516},
-{ -275, -516, 689, 391}, { -379, -643, 876, 594}, { -390,-1013, -645, 573},
-{ -107, -568, -689, -826}, {-1025, -27, -328, -203}, { 861, 749, 548, 233},
-{-1660,-1043, 451, 108}, { -660, -620, 430, 236}, { 21, -396,-1158, -631},
-{ 1372, 1298, 967, 577}, { 1125, 1125, 589, 454}, { -323, -865, -467, 153},
-{ -468, -699, -804, -509}, { -392, -718, -204, -35}, { -603,-1093, -567, -162},
-{ -505,-1004, -102, 350}, { 219, 224, 423, 252}, { 395, 591, 608, 363},
-{ -746, -96, 373, 172}, { 171, 295, 714, 339}, { 233, 77, 107, 277},
-{ 157, 153, -499, -356}, { 1547, 1073, 576, 494}, { -292, -339, -504, -592},
-{ -903, -72, -619, -481}, {-1594,-1117, -567, -254}, { -793, -507, -564, -291},
-{ -492, -532, 502, 560}, { -382, 427, 600, 230}, { -227, 477, 251, 75},
-{ 285, 842, 813, 476}, {-1310,-1333, 186, 377}, { -587, -917, 643, 381},
-{-1186, -553, 411, 82}, {-1127, -820, -174, -540}, { -604, 119, 543, 205},
-{ -380, 657, 909, 567}, { 112, -298, -374, 114}, { -857, -251, 56, 159},
-{ 401, 345, -34, -140}, { -111, -607, 41, 614}, { 355, -114, -77, 474},
-{ 578, 56, 1450, 924}, { 1098, 1420, 741, 400}, { 246, 22, 588, 313},
-{ -121, 327, 831, 472}, {-1138, -608, 856, 552}, {-1241,-1072, 638, 600},
-{ -358, 254, -333, -303}, { -646, 739, 358, 74}, { 1226, 1671, 1221, 849},
-{ 2241, 1624, 983, 636}, { 1841, 1477, 749, 384}, { 350, 263, 87, 128},
-{-1902, -941, -144, -64}, {-1734, -255, 288, -31}, {-2644,-1238, 366, 235},
-{-1643,-1092,-1344, -304}, { -541,-1075,-1116, 123}, {-1178, -252, -816, -180},
-{-1016, 533, 565, 233}, { -487, -430, -188, 334}, { 867, 1236, 534, 171},
-{-1590,-1607, 635, 630}, {-2196, 310, 924, 412}, {-2358, -328, 956, 529},
-{-2639, -377, 630, 278}, {-2602, 317, 799, 299}, {-2406, 133, 340, 31},
-{-2156,-1468, 131, 125}, {-1184, -490, -139, 46}, { -744, 447, 891, 564},
-{ 67, -451, 646, 604}, { -553, -429, -876, 396}, { 162, -66, 1305, 915},
-{ 479, 579, 1088, 794}, { 450, 278, 566, 324}, {-1057, -154, 148, -177},
-{-2545, 168, 1070, 592}, {-2351, -42, 819, 345}, {-2344, -707, 721, 250},
-{-2175,-1497, -309, 122}, { -78, -73, 120, 173}, { -4, 262, -263, -261},
-{ -431, -64, -405, -732}, {-2609, 116, -83, -193}, {-1525, -944, -477, -725},
-{ -508, 307, 170, 172}, { 832, 417, 832, 686}, { -225, 177, 894, 818},
-{ -482, -389, 1279, 1039}, { -383, 201, -350, 40}, { 730, 635, 226, 526},
-{ 503, 462, 338, 398}, { 535, 714, 40, -282}, { 1482, 1471, 1085, 731},
-{ 1561, 1072, 909, 693}, { 1419, 1282, 889, 879}, { 1153, 728, 1186, 840},
-{ -226, 1130, 949, 689}, { -494, -986,-1556, -128}, { -568, -721, -713, -26},
-{ 317, 524, 70, 135}, { -405, -865,-1766, -652}, { -174, -801, 885, 773},
-{ -153, -91, 1099, 751}, { -506,-1149, 853, 646}, { 241, 782, 519, 539},
-{ 1853, 1700, 1101, 684}, {-1249,-1486, -464, 188}, { -893,-1409,-1312, -341},
-{ -135, 438, -175, 18}, { 1111, 976, 319, 208}, {-1430,-1768, 83, 458},
-{ -530,-1000, 307, 129}, { -840, -15, -29, -356}, { -911, -924,-1147, -242},
-{ -119, -528, 127, -133}, { -761, -765, 190, -83}, { -315, 895, 522, 231},
-{ -222, 102, -63, -428}, { 316, 699, 379, 70}, { 25, 716, 314, -108},
-{ 507, 874, 566, 238}, { 108, 941, 519, 195}, { 425, -60, -427, 257},
-{ 139, -103, -630, 446}, { 334, 370, 412, 48}, { -172, -690, -283, 557},
-{ 187, -286, 158, 483}, { 140, 270, -344, -631}, { 924, 579, -116, 132},
-{ 142, 466, -68, -64}, { 230, -145, -302, -542}, { -803, -912, 1018, 737},
-{ -773, 1015, 630, 297}, {-2596, 95, 445, 336}, {-2122, 491, 510, 191},
-{-1253, 161, -2, -324}, {-1450, -633, -712, -105}, { -842, -254, -411, 100},
-{ -640, -290, 1010, 763}, { -650, 313, 1169, 730}, { 140, 505, 1030, 766},
-{ 772, 287, 1067, 823}, { 495, 749, 305, 323}, { -164, 462, 78, 399},
-{ -342, -874, 69, 597}, { -16, 620, 621, 337}, { -138, -444, -265, 218},
-{ 84, -450, 953, 666}, { -222, -803, 541, 604}, { -921,-1376, 244, 116},
-{ -841, -723, 630, 588}, { 140, 663, 294, 368}, { 935, 1046, 881, 759},
-{ 1746, 1464, 916, 628}, { 436, 963, 281, 1}, { -119, 74, 542, 213},
-{ 1, -567, 301, 241}, { 260, 435, 222, 396}, { 936, 957, 1108, 703},
-{ 510, 506, 808, 478}, { 601, 694, 960, 620}, { 972, 741, 980, 600},
-{ 834, 717, 767, 684}, { 643, 972, 935, 638}, { 501, 661, 720, 851},
-{ -105, -632, -303, -117}, { -429, 130, 789, 442}, { -522, -188, 704, 373},
-{ -759, 42, 814, 523}, { -531,-1137, 373, 578}, { -682,-1203, -455, 285},
-{-1163,-1577,-1098, 44}, { 81, -82, 712, 363}, { 477, 246, 954, 622},
-{ 1604, 1622, 1277, 891}, { 1409, 859, 924, 892}, { 774, 1041, 947, 1142},
-{ 40, -546, -75, 288}, { -616, -106, -697, -26}, { -169, -160, -891, -739},
-{ -279, -384,-1029, -350}, { 1781, 1308, 1046, 816}, { 1580, 1533, 1472, 1178},
-{ 1505, 1076, 1216, 899}, { 890, 904, 564, 654}, { 920, 692, 1021, 856},
-{ -493, 132, 177, 505}, { 71, 195, -28, 97}, { 456, 351, -164, 88},
-{ 439, 278, -40, 350}, { 1395, 949, 234, -95}, { -805, -472, 38, -163},
-{ 367, -98, 489, 523}, { 1025, 1178, 1212, 906}, { 319, 1314, 814, 461},
-{ -123, -543, -804, 447}, { -748, -324, -897,-1127}, { -737, -501, -789, -713},
-{ 715, 777, 1239, 922}, { 1949, 1939, 1368, 865}, { 730, 880, 758, 388},
-{ -871, 454, 17, -251}, { -381, -810,-1583, 239}, { -521, -966, -792, 259},
-{ -890,-1358, -770, -73}, { 166, 349, -212, 323}, { -840, -301, 473, 435},
-{ -679, -464, 728, 351}, { -156, -199, 667, 432}, { 29, -252, 415, 480},
-{ -731, -379, 145, 559}, { -528, -631,-1158, -159}, { 445, 273, 123, 639},
-{ 373, -126, 800, 568}, { 84, -162, 720, 712}, { -830, -536, -185, 222},
-{ 408, 452, 501, 771}, { -897,-1355, -67, 442}, { -792,-1406, 566, 602},
-{ 167, -326, 509, 330}, { -95, -626, -730, -344}, { 1668, 1217, 779, 455},
-{ 1316, 828, 584, 719}, { 404, -31, 1013, 789}, { 89, 107, 891, 549},
-{ 871, 1581, 917, 671}, { 866, 1479, 1289, 854}, { 391, 1068, 1122, 812},
-{ 78, -562, 345, 563}, { 429, -103, 417, 787}, { -122, -437, 411, 788},
-{ -913, -417, 602, 754}, { -226, -16, 151, 760}, { -700, 118, -104, -14},
-{-1128, 48, 284, 393}, { -390, -419, -639, -116}, { -910, 306, 316, -13},
-{ 1207, 984, 821, 669}, {-1195, -693, 140, -213}, { -884, -416, -199, -558},
-{ -616, 245, -404, -664}, { 262, 56, -617, -724}, { -85, -491, -320, -656},
-{ -570, -831, -129, -528}, {-1506, -63, -367, -385}, { -358, -321, 4, 51},
-{ -366, -214, 319, 511}, { 146, 671, -17, -291}, { -110, 464, -139, -496},
-{ -202, 220, -312, -631}, { -660, -73, -655, -820}, { -662, -653,-1288, -857},
-{ -430, -953, -959, -264}, { -49, -468, -72, -381}, { -350, -563, -193, -407},
-{ 55, -408, -803, 11}, { -309, 649, 188, -198}, { -512, 461, -79, -458},
-{-1318, -263, -134, -523}, {-1657, -435, -495, -765}, { 57, -347, -414, 434},
-{-1141, -242, -664, -857}, { 34, -68, -707, -338}
-};
-
-static const int16_t lsf_5_1[128][4] = {
-{ -451,-1065, -529,-1305}, { -450, -756, -497, -863}, { -384, -619, -413, -669},
-{ -317, -538, -331, -556}, { -414, -508, -424, -378}, { -274, -324, -434, -614},
-{ -226, -500, -232, -514}, { -263, -377, -298, -410}, { -151, -710, -174, -818},
-{ -149, -412, -156, -429}, { -288, -462, -186, -203}, { -170, -302, -191, -321},
-{ -131, -147, -297, -395}, { -228, -214, -245, -192}, { -67, -316, -71, -327},
-{ -104, -205, -94, -183}, { -143, -38, -193, -95}, { 16, -76, -124, -248},
-{ 23, -237, 24, -244}, { 18, -136, 44, -111}, { -33, -24, -25, 0},
-{ 149, 19, 23, -143}, { 158, -169, 174, -181}, { 133, -55, 165, -26},
-{ 111, 84, 98, 75}, { 87, 183, -115, -11}, { -8, 130, 11, 170},
-{ 254, 77, 205, 17}, { 183, 112, 262, 194}, { 202, 287, 95, 189},
-{ -42, -105, 234, 179}, { 39, 186, 163, 345}, { 332, 199, 299, 161},
-{ -54, 285, -78, 281}, { -133, 141, -182, 111}, { 249, 341, 271, 364},
-{ 93, 403, 75, 391}, { 92, 510, -138, 220}, { -185, -29, -34, 361},
-{ -115, 320, 3, 554}, { 99, 286, 218, 591}, { -245, 406, -268, 453},
-{ 0, 580, 25, 606}, { 275, 532, 148, 450}, { -73, 739, -285, 518},
-{ -288, 94, -203, 674}, { -140, -74, 205, 714}, { -114, 299, 176, 923},
-{ 182, 557, 240, 705}, { -16, 513, 485, 593}, { 293, 384, 451, 617},
-{ -38, 50, 563, 529}, { 303, 209, 459, 363}, { 433, 452, 450, 454},
-{ 367, 606, 477, 741}, { 432, 353, 368, 267}, { 361, 716, 273, 583},
-{ 453, 166, 510, 172}, { 201, 629, 274, 191}, { 568, 639, 302, 298},
-{ 634, 387, 643, 350}, { 587, 560, 612, 565}, { 600, 788, 487, 672},
-{ 512, 1015, 321, 333}, { 357, 854, -125, 413}, { 474, 712, 17, -151},
-{ 564, 285, 270, -241}, { 971, 889, 489, 220}, { 510, 896, 549, 924},
-{ 327, 825, 290, 911}, { 540, 1108, 158, 805}, { 199, 957, 511, 730},
-{ 100, 874, 13, 791}, { 435, 632, 676, 972}, { 249, 900, 467, 1218},
-{ 781, 1074, 585, 785}, { -23, 669, 267, 1043}, { 619, 1084, 615, 1145},
-{ 622, 905, 916, 1049}, { 80, 331, 584, 1075}, { 89, 639, 988, 961},
-{ 770, 720, 798, 699}, { 492, 447, 899, 627}, { 271, 1188, 725, 1333},
-{ 87, 603, 832, 1603}, { 616, 1127, 890, 1505}, { 1000, 1156, 866, 1009},
-{ 995, 827, 1149, 858}, { 817, 1450, 773, 1320}, { 500, 1389, 312, 1153},
-{ -20, 1084, 64, 1283}, { 2, 1172, 399, 1869}, { 514, 1706, 502, 1636},
-{ 886, 1522, 416, 600}, { 1131, 1350, 1275, 1390}, { 889, 1795, 914, 1766},
-{ 227, 1183, 1250, 1826}, { 505, 1854, 919, 2353}, { -199, 431, 152, 1735},
-{ -213, -28, 392, 1334}, { -153, -52, 978, 1151}, { -323, -400, 813, 1703},
-{ -136, 84, 1449, 2015}, { -331, -143, -137, 1192}, { -256, 534, -157, 1031},
-{ -307, -439, 542, 731}, { -329, -420, -97, 616}, { -362, -168, -322, 366},
-{ -247, -110, -211, 89}, { -196, -309, 20, 59}, { -364, -463, -286, 89},
-{ -336, 175, -432, 141}, { -379, -190, -434, -196}, { -79, 150, -278, -227},
-{ -280, 166, -555, -422}, { -155, 541, -366, 54}, { -29, -83, -301, -774},
-{ 186, 628, -397, -264}, { 242, 293, -197, -585}, { 124, 410, 53, -133},
-{ 10, 340, -570,-1065}, { 65, -446, 68, -493}, { 383, 937, -357, -711},
-{ -359, -250, -677,-1068}, { 292, -26, 363, 6}, { 607, 1313, -127, -10},
-{ 1513, 1886, 713, 972}, { 1469, 2181, 1443, 2016}
-};
-
-static const int16_t lsf_5_2[256][4] = {
-{-1631,-1600,-1796,-2290}, {-1027,-1770,-1100,-2025}, {-1277,-1388,-1367,-1534},
-{ -947,-1461, -972,-1524}, { -999,-1222,-1020,-1172}, { -815, -987, -992,-1371},
-{-1216,-1006,-1289,-1094}, { -744,-1268, -755,-1293}, { -862, -923, -905, -984},
-{ -678,-1051, -685,-1050}, {-1087, -985,-1062, -679}, { -989, -641,-1127, -976},
-{ -762, -654, -890, -806}, { -833,-1091, -706, -629}, { -621, -806, -640, -812},
-{ -775, -634, -779, -543}, { -996, -565,-1075, -580}, { -546, -611, -572, -619},
-{ -760, -290, -879, -526}, { -823, -462, -795, -253}, { -553, -415, -589, -439},
-{ -533, -340, -692, -935}, { -505, -772, -702,-1131}, { -263, -306, -971, -483},
-{ -445, -74, -555, -548}, { -614, -129, -693, -234}, { -396, -246, -475, -250},
-{ -265, -404, -376, -514}, { -417, -510, -300, -313}, { -334, -664, -463, -814},
-{ -386, -704, -337, -615}, { -234, -201, -233, -239}, { -167, -567, -203, -619},
-{ -147, -415, -115, -352}, { -166, -750, -171, -761}, { -270, -879, -264, -903},
-{ -367, -744, 43, -475}, { 14, -653, 43, -670}, { 11, -448, -59, -521},
-{ -126, -119, -155, -613}, { -42, -863, -27, -931}, { 136, -483, 183, -468},
-{ 55, -298, 55, -304}, { 313, -609, 313, -720}, { 322, -167, 100, -541},
-{ -3, -119, -111, -187}, { 233, -236, 260, -234}, { 26, -165, 134, -45},
-{ -40, -549, 360, -203}, { 378, -388, 450, -383}, { 275, 20, 182, -103},
-{ 246, -111, 431, 37}, { 462, -146, 487, -157}, { -284, -59, 503, -184},
-{ 24, 53, -3, 54}, { 122, 259, 333, 66}, { 484, 104, 436, 68},
-{ 195, 116, 190, 206}, { 269, -9, 482, 352}, { 382, 285, 399, 277},
-{ 452, 256, 69, 186}, { 13, 297, -13, 259}, { -95, 30, 56, 394},
-{ 196, 425, 205, 456}, { 281, 577, 15, 191}, { 375, 290, 407, 576},
-{ -56, 227, 544, 405}, { 0, 549, -92, 528}, { -229, 351, -245, 338},
-{ -362, 435, 167, 527}, { -75, 302, 91, 824}, { 129, 599, 496, 679},
-{ 186, 749, 153, 737}, { -281, 600, -348, 615}, { -236, 769, 41, 881},
-{ 38, 890, -220, 841}, { -357, 883, -393, 903}, { -634, 474, -444, 850},
-{ -175, 678, -493, 242}, { -519, 785, -714, 582}, { -541, 366, -543, 434},
-{ -597, 500, -765, 222}, { -702, 917, -743, 962}, { -869, 501, -899, 548},
-{ -379, 200, -435, 157}, { -819, 214, -861, 157}, { -614, 40, -632, 94},
-{ -883, -54, -741, 516}, { -501, 298, -614, -171}, { -870, -161, -865, -23},
-{ -818, 93,-1015, -267}, { -662, -359, -549, 2}, { -442, -121, -377, 0},
-{ -227, 33, -414, -126}, { -129, 212, -934, 34}, {-1082, -282,-1119, -268},
-{ -710, -825, -420, -191}, {-1076, -928, -917, -93}, { -628, -358, 97, 7},
-{ -206, -393, -101, 24}, { -203, 38, -168, 83}, { -599, -423, -279, 426},
-{ -700, 118, -75, 206}, { -981, -673, -680, 417}, { -367, 37, -279, 474},
-{ -129, -318, 319, 296}, { -626, -39, 343, 602}, { -696, -39, -303, 940},
-{ 104, 233, -380, 137}, { -36, 269, -75, -214}, { 120, 43, -529, -477},
-{ 459, 164, -202, -229}, { -49, -167, 609, 792}, { 98, -220, 915, 148},
-{ 293, 283, 869, 91}, { 575, 394, 326, -78}, { 717, 67, 365, -323},
-{ 616, -36, 731, 27}, { 619, 238, 632, 273}, { 448, 99, 801, 476},
-{ 869, 273, 685, 64}, { 789, 72, 1021, 217}, { 793, 459, 734, 360},
-{ 646, 480, 360, 322}, { 429, 464, 638, 430}, { 756, 363, 1000, 404},
-{ 683, 528, 602, 615}, { 655, 413, 946, 687}, { 937, 602, 904, 604},
-{ 555, 737, 786, 662}, { 467, 654, 362, 589}, { 929, 710, 498, 478},
-{ 415, 420, 693, 883}, { 813, 683, 781, 925}, { 913, 939, 726, 732},
-{ 491, 853, 531, 948}, { 734, 963, 315, 808}, { 761, 755, 1144, 760},
-{ 655, 1076, 826, 1057}, { 1091, 838, 1003, 808}, { 1047, 1133, 659, 1101},
-{ 992, 1050, 1074, 1075}, { 971, 694, 1226, 1054}, { 571, 841, 884, 1404},
-{ 1379, 1096, 1080, 861}, { 1231, 735, 1284, 760}, { 1272, 991, 1367, 1053},
-{ 1257, 700, 1050, 534}, { 988, 453, 1264, 599}, { 1140, 679, 1621, 815},
-{ 1384, 521, 1317, 393}, { 1564, 805, 1448, 686}, { 1068, 648, 875, 307},
-{ 1083, 361, 1047, 317}, { 1417, 964, 675, 571}, { 1152, 79, 1114, -47},
-{ 1530, 311, 1721, 314}, { 1166, 689, 514, -94}, { 349, 282, 1412, 328},
-{ 1025, 487, -65, 57}, { 805, 970, 36, 62}, { 769, -263, 791, -346},
-{ 637, 699, -137, 620}, { 534, 541, -735, 194}, { 711, 300, -268, -863},
-{ 926, 769, -708, -428}, { 506, 174, -892, -630}, { 435, 547,-1435, -258},
-{ 621, 471,-1018,-1368}, { -393, 521, -920, -686}, { -25, 20, -982,-1156},
-{ 340, 9,-1558,-1135}, { -352, 48,-1579, -402}, { -887, 6,-1156, -888},
-{ -548, -352,-1643,-1168}, { -159, 610,-2024, -963}, { -225, 193,-1656,-1960},
-{ -245, -493, -964,-1680}, { -936, -635,-1299,-1744}, {-1388, -604,-1540, -835},
-{-1397, -135,-1588, -290}, {-1670, -712,-2011,-1632}, {-1663, -27,-2258, -811},
-{-1157, 184,-1265, 189}, {-1367, 586,-2011, 201}, { -790, 712,-1210, 3},
-{-1033, 808,-1251, 830}, { -111, 635,-1636, 447}, { -463, -949, -445, -928},
-{ -504,-1162, -501,-1211}, { 144, -351, -372,-1052}, { -283,-1059, -279,-1123},
-{ -575,-1438, -587,-1614}, { -935, -984, 229, 690}, { -921, -719, -403, 1362},
-{ -685, -465, 874, 397}, { -509, -46, 317, 1334}, { -485, 456, 813, 439},
-{ -411, 339, 898, 1067}, { -425, 46, 1441, 497}, { -909, -800, 1465, 1046},
-{ -254, -321, 1430, 1165}, { 68, 350, 1034, 666}, { 370, 11, 1311, 790},
-{ 143, 232, 1041, 1562}, { -114, 663, 1616, 1078}, { 454, 579, 1275, 1040},
-{ -76, 909, 752, 1067}, { 153, 512, 348, 1214}, { 614, 385, 1843, 808},
-{ 269, 1034, 203, 1086}, { 652, 1017, 1783, 1130}, { 429, 1327, 387, 1384},
-{ -49, 1183, -72, 1215}, { -416, 1001, 544, 1749}, { -352, 1223, -502, 1199},
-{ -589, 569, -227, 1630}, { -142, 1578, -230, 1715}, { -714, 1288, -838, 1398},
-{ 1131, 1357, -208, 1232}, { 437, 965, -929, 818}, { 811, 1410, 859, 1507},
-{ 164, 1212, 1387, 1793}, { 484, 1874, 456, 2063}, { 996, 1170, 1326, 1402},
-{ 1316, 1360, 1135, 1262}, { 1234, 1618, 1361, 1768}, { 1421, 1227, 1584, 1347},
-{ 854, 672, 1685, 1566}, { 1139, 1270, 2016, 1825}, { 1773, 1581, 1532, 1460},
-{ 1487, 946, 1659, 1021}, { 1744, 1212, 1392, 977}, { 1772, 1161, 1826, 1164},
-{ 1718, 1429, 1973, 1591}, { 1185, 864, 2132, 1061}, { 1799, 814, 1838, 757},
-{ 2104, 1315, 2054, 1258}, { 2113, 915, 2331, 930}, { 1467, 1147, 2590, 1439},
-{ 2245, 1744, 2090, 1620}, { 2358, 1454, 2666, 1506}, { 1876, 1837, 2070, 1975},
-{ 1739, 1577, 682, 1289}, { 1584, 2045, 1454, 2098}, { 2498, 2004, 2711, 2066},
-{ 726, 1588, 2756, 2336}, { 228, 847, 2456, 1659}, { 36, 301, 1942, 1957},
-{ -446, -96, 2154, 1396}, { 1533, 1101, 14, 608}, { -923, -732, 1383, 1982},
-{ 1345, 952, -680, 321}, { 1281, 1268,-1594, 365}, { 941, 946,-1737, -822},
-{ 2374, 2787, 1821, 2788}
-};
-
-static const int16_t lsf_5_3[256][4] = {
-{-1812,-2275,-1879,-2537}, {-1640,-1848,-1695,-2004}, {-1220,-1912,-1221,-2106},
-{-1559,-1588,-1573,-1556}, {-1195,-1615,-1224,-1727}, {-1359,-1151,-1616,-1948},
-{-1274,-1391,-1305,-1403}, {-1607,-1179,-1676,-1311}, {-1443,-1478,-1367, -898},
-{-1256,-1059,-1331,-1134}, { -982,-1133,-1149,-1504}, {-1080,-1308,-1020,-1183},
-{ -980,-1486, -967,-1495}, { -988, -922,-1047,-1077}, { -838,-1179, -858,-1222},
-{-1131,-1041,-1064, -767}, { -872,-1157, -701, -880}, { -706, -906, -774,-1016},
-{ -578,-1080, -801,-1478}, { -591,-1111, -592,-1146}, { -713,-1388, -640,-1376},
-{ -597,-1059, -416, -903}, { -686, -832, -661, -708}, { -444, -868, -490, -921},
-{ -374, -776, -619,-1170}, { -585, -549, -769, -795}, { -435, -659, -530, -741},
-{ -498, -837, -357, -597}, { -279, -871, -243, -887}, { -282, -665, -280, -667},
-{ -165, -560, -394, -903}, { -362, -410, -448, -583}, { -409, -574, -313, -357},
-{ -637, -548, -570, -436}, { -896, -504, -382, -757}, { -58, -481, -165, -618},
-{ -191, -374, -234, -382}, { -222, -683, -25, -480}, { -418, -359, -730, -353},
-{ -324, -157, -432, -322}, { -394, -303, -284, -104}, { -601, -289, -556, -196},
-{ -588, -150, -659, -608}, { -473, -24, -68, -448}, { -474, -8, -506, -45},
-{ -748, -184, -844, -252}, { -901, -91, -584, -97}, { -652, 138, -764, -131},
-{ -678, -12, -670, 165}, { -259, -3, -840, -107}, { -909, 37, -992, 44},
-{ -854, -415, -839, 13}, {-1001, -271,-1026, -309}, { -798, -478, -832, -488},
-{ -943, 168,-1112, -387}, {-1185, -101,-1183, -40}, { -941, -316,-1030, -770},
-{-1044, -625,-1081, -538}, {-1224, -299,-1312, -436}, {-1197, -663,-1167, -161},
-{-1216, -690,-1237, -831}, {-1432, -720,-1403, -493}, { -898, -740, -922, -801},
-{-1102, -402,-1579, -964}, {-1061, -638,-1269,-1438}, {-1499, -934,-1502, -895},
-{-1598, -564,-1723, -717}, { -606, -597,-1166,-1085}, {-1369, -468,-1946,-1493},
-{-1838, -953,-1932, -931}, {-1499, -188,-1635, -421}, {-1457, -338,-1448, -22},
-{-1942, -422,-2006, -249}, { -496, -114,-1910, -755}, {-1289, 174,-1451, -109},
-{ -482, -257,-1221, -508}, {-1617, 151,-1694, 208}, { -654, 107,-1651, 29},
-{-1141, 279,-1215, 306}, {-1228, -506, -730, -175}, {-1236, -101, -969, 551},
-{ -870, 278, -823, 315}, { -563, 376,-1051, 228}, { -507, 280, -599, 281},
-{ -758, 253, -305, 379}, { -755, -134, -611, 660}, { -824, 536, -817, 646},
-{ -413, 49, -341, 177}, { -453, 526, -482, 589}, { -71, 339, -657, 264},
-{ -244, 295, -237, 315}, { -387, 569, -506, -9}, { -377, 14, -160, 661},
-{ -216, 40, -308, -46}, { 95, 214, -242, 167}, { -86, 192, -56, 27},
-{ -76, 31, 36, 309}, { -106, -182, -113, 74}, { -441, -22, 23, 139},
-{ 81, -11, 44, 15}, { -87, -137, -118, -207}, { -158, -58, 272, -92},
-{ -156, -441, 8, -136}, { 128, -221, 101, -218}, { 40, -197, -76, -456},
-{ 9, -445, 33, -423}, { 226, 60, 73, -222}, { 156, -399, 280, -318},
-{ 245, -341, 166, -499}, { 339, -190, 327, -219}, { 325, -137, -89, -596},
-{ 100, -627, 144, -677}, { 487, 28, 252, -391}, { 214, -41, 282, -28},
-{ 99, -286, 331, 49}, { 459, -388, 565, -369}, { 436, 28, 336, -9},
-{ 397, -167, 618, 34}, { 596, -17, 561, -140}, { 299, 79, 522, 125},
-{ 203, 2, 244, 288}, { 255, 211, 175, 82}, { 596, 187, 517, 108},
-{ 381, 255, 365, 297}, { 497, 352, 327, -82}, { 25, 210, 371, 245},
-{ 261, 3, 545, 449}, { 140, 294, 44, 295}, { 212, 347, 244, 494},
-{ 331, 528, 201, 307}, { 349, 411, 613, 284}, { 614, 413, 464, 322},
-{ 624, 397, 97, 200}, { -160, 384, 149, 362}, { 495, 525, 269, 585},
-{ 33, 491, -121, 433}, { 427, 611, 498, 516}, { 171, 443, 497, 666},
-{ 440, 275, 566, 575}, { 146, 639, 155, 670}, { -33, 173, 212, 696},
-{ -166, 601, -191, 695}, { -489, 503, 175, 742}, { 214, 476, 372, 1083},
-{ 578, 530, 586, 777}, { 425, 874, 315, 841}, { 374, 848, -165, 565},
-{ 35, 991, -39, 1062}, { 329, 712, 786, 840}, { 645, 795, 661, 676},
-{ 571, 918, 632, 1079}, { 673, 817, 318, 388}, { 874, 1012, 564, 848},
-{ 880, 620, 557, 479}, { 671, 453, 692, 468}, { 840, 642, 844, 645},
-{ 506, 428, 897, 567}, { 837, 387, 962, 499}, { 691, 561, 939, 926},
-{ 783, 296, 790, 268}, { 1028, 530, 874, 329}, { 548, 143, 675, 291},
-{ 503, 66, 1041, 359}, { 786, 97, 805, 33}, { 837, 470, 511, 49},
-{ 1092, 327, 1174, 323}, { 3, 242, 872, 474}, { 689, 429, 1329, 678},
-{ 1042, 620, 1109, 664}, { 321, 193, 889, 950}, { 1153, 874, 893, 635},
-{ 877, 862, 948, 913}, { 1293, 665, 1320, 639}, { 997, 793, 1402, 1030},
-{ 1176, 1012, 1110, 959}, { 1410, 925, 1403, 915}, { 543, 862, 1116, 1222},
-{ 835, 1190, 835, 1190}, { 959, 1148, 1147, 1376}, { 1300, 1193, 1415, 1231},
-{ 1335, 1341, 746, 1092}, { 1711, 1283, 1389, 1073}, { 1334, 1566, 1153, 1475},
-{ 1645, 1137, 1825, 1220}, { 1056, 1382, 1521, 1730}, { 1632, 1545, 1620, 1542},
-{ 855, 1596, 865, 1667}, { 693, 885, 1716, 1519}, { 1167, 1296, 2209, 1760},
-{ 1952, 1493, 2020, 1482}, { 1534, 1866, 1694, 2008}, { 1566, 748, 1761, 825},
-{ 294, 1392, 1084, 2058}, { 621, 1315, 365, 1287}, { 198, 1028, 488, 1408},
-{ 249, 403, 1014, 1561}, { 324, 363, 1645, 1044}, { 193, 367, 2034, 1859},
-{ -251, 579, 750, 994}, { -243, 30, 1325, 879}, { -28, -169, 624, 917},
-{ -453, 159, 186, 1370}, { -614, 6, 537, 392}, { -94, -291, 781, 229},
-{ -128, -298, 245, 491}, { -701, -648, 972, 789}, { -501, -640, 178, 255},
-{ -365, -390, -255, 317}, { -958, -294, -191, 228}, { -775, -447, 157, -237},
-{ -657, -720, -407, 92}, { -117, -611, 334, -230}, { -679,-1084, -144, -317},
-{ -901, -861, -738, -360}, { -85, -727, -90, -787}, { 100, -22, -391, -263},
-{ -56, -73, -337, -754}, { 5, -189, -706, -624}, { 89, -344, -135,-1113},
-{ -353, -237, -684,-1135}, { -275,-1102, -269,-1203}, { 152, 145, -722,-1232},
-{ 49, 80,-1248, -776}, { -248, 391, -732, -547}, { 469, 218, -255, -864},
-{ 69, 366, -166, -485}, { -688, 191,-1212,-1196}, { -170, -169,-1308,-1631},
-{ 321, 470,-1419,-1243}, { -64, 272,-1361, -248}, { 492, 565, -721, -609},
-{ 195, 485, -573, -133}, { 427, 202, -171, -118}, { 199, 575, 2, -31},
-{ 694, 755,-1366, -39}, { 552, 557, -489, 271}, { 680, 537, 13, -453},
-{ 855, 954, -133, -52}, { -81, 738,-1169, 637}, { 1055, 1059, -95, 676},
-{ 1259, 1081, 489, 305}, { -449, 954, -534, 996}, { -969, 866,-1058, 1059},
-{-1294, 618,-1416, 617}, { -458, 1366, -159, 1821}, { -774, -528, -14, 1110},
-{-1202, -901, -772, 433}, {-1256,-1255,-1011, -302}, { -602, -585, -759,-1618},
-{ -760,-1549, -840,-1921}, { -816, -539,-1769,-2235}, { -227, -36,-2034,-1831},
-{-2107,-1126,-2471,-1816}, {-1470, 252,-2701, -415}, { -571, -467, 1509, 1554},
-{ 2180, 1975, 2326, 2020}
-};
-
-static const int16_t lsf_5_4[256][4] = {
-{-1857,-1681,-1857,-1755}, {-2056,-1150,-2134,-1654}, {-1619,-1099,-1704,-1131},
-{-1345,-1608,-1359,-1638}, {-1338,-1293,-1325,-1265}, {-1664,-1649,-1487, -851},
-{-1346,-1832,-1413,-2188}, {-1282, -681,-1785,-1649}, { -966,-1082,-1183,-1676},
-{-1054,-1073,-1142,-1158}, {-1207, -744,-1274, -997}, { -934,-1383, -927,-1416},
-{-1010,-1305, -783, -955}, {-1049, -900, -993, -817}, { -737, -823, -972,-1189},
-{ -738,-1094, -738,-1154}, { -784, -801, -810, -786}, { -892, -520,-1000, -818},
-{ -644, -965, -577, -882}, { -541, -694, -671, -917}, { -595, -642, -646, -615},
-{ -956, -621, -925, -515}, { -727, -483, -815, -485}, { -840, -578, -440, -713},
-{ -578, -325, -657, -670}, { -386, -570, -441, -666}, { -514, -787, -392, -529},
-{ -522, -453, -487, -423}, { -616, -585, -617, -157}, { -662, -268, -680, -348},
-{ -322, -323, -632, -444}, { -304, -430, -332, -458}, { -277, -468, -659, -793},
-{ -319, -636, -227, -554}, { -373, -347, -334, -210}, { -456, -192, -530, -242},
-{ -216, -198, -366, -370}, { -338, -161, -409, -748}, { -107, -380, -294, -643},
-{ -223, -665, -234, -741}, { -141, -496, -130, -510}, { -139, -327, -172, -305},
-{ -306, -580, -164, -263}, { -262, -172, -67, -402}, { 31, -366, -10, -436},
-{ -86, -527, 71, -377}, { -22, -609, -12, -678}, { -67, -319, 63, -191},
-{ 35, -181, -39, -242}, { 126, -167, -140, -544}, { 155, -297, 174, -297},
-{ 38, -8, 117, -380}, { 197, -452, 240, -522}, { 223, -103, 110, -187},
-{ 87, -155, 169, -47}, { 157, 26, -83, -100}, { 128, 80, 209, -62},
-{ 6, 7, 22, 5}, { 318, -20, 248, -45}, { -200, -63, 156, -69},
-{ 250, -183, 369, -126}, { -113, -76, -142, -122}, { -64, -254, -31, 35},
-{ -177, -71, -7, 171}, { 93, 27, 108, 212}, { -330, -209, -123, -70},
-{ -279, 95, -96, 20}, { -188, -61, -314, 87}, { -300, -78, -354, -134},
-{ 11, 122, -140, 122}, { -275, 152, -293, 140}, { -82, 138, -321, -111},
-{ -480, -156, -359, 76}, { -254, -40, -635, -96}, { -522, 79, -507, 8},
-{ -268, 303, -539, 68}, { -446, 61, -522, 306}, { 111, 189, -435, 122},
-{ -379, 166, -571, -398}, { -632, -74, -747, -95}, { -455, 194, -952, 83},
-{ -798, 192, -755, 192}, { -781, -162, -619, 234}, { -663, -297, -488, -109},
-{ -964, -132, -838, -68}, { -843, 58,-1112, -86}, { -805, -299, -944, -253},
-{ -778, -50, -965, -549}, { -352, -98, -992, -343}, {-1117, -315,-1117, -307},
-{-1155, -374, -637, -230}, {-1166, -43,-1299, -100}, { -925, -393,-1274, -600},
-{ -689, -130,-1479, -312}, {-1321, -254,-1464, -442}, {-1292, -613,-1261, -503},
-{-1501, -368,-1322, 26}, {-1432, -66,-1743, -161}, {-1644, -467,-1760, -548},
-{-1393, -568,-1556, -871}, {-1495,-1034,-1387, -571}, {-1917, -528,-1783, -123},
-{-1897, -231,-2054, -323}, {-2052, -906,-1976, -567}, {-1917, -620,-2047, -989},
-{-1077, -370,-2031, -704}, {-2355, -749,-2740,-1089}, {-1909, 159,-2012, 248},
-{ -626, -123,-2339, -962}, { -669, -408,-1379,-1174}, { -452, -364,-1044, -735},
-{ -132, 183,-1620, -752}, { -547, -307, -777,-1261}, { -98, 41, -880,-1091},
-{ -257, 97,-1602,-1833}, { 31, -26, -644, -561}, { -180, -546, -385,-1095},
-{ -410, -802, -414, -827}, { -457, -970, -490,-1109}, { -215, -916, -144, -937},
-{ -493,-1269, -517,-1507}, { 181, 101, -332, -889}, { -836, -937, -559, -429},
-{ -629, -547, -183, -337}, { -545, -82, -250, -286}, { 5, -132, -348, -252},
-{ -293, -472, -158, 100}, { -29, 197, -236, -424}, { -861, -213, -140, -7},
-{ -427, -443, 187, -97}, { -684, -736, -293, 258}, { -368, -152, -150, 392},
-{ -609, 175, -142, 299}, { -138, 152, -119, 329}, { -486, -52, 293, 198},
-{ -183, 117, 175, 331}, { -58, -274, 231, 300}, { -288, 330, -305, 372},
-{ -111, 409, -9, 423}, { 83, 256, 67, 367}, { -19, 248, 91, 113},
-{ -35, 406, -191, 154}, { 238, 296, 5, 197}, { 141, 221, 313, 198},
-{ 211, 421, 244, 334}, { 88, 426, -243, 454}, { 202, 552, -5, 403},
-{ 291, 185, 219, 301}, { 251, 138, 128, 69}, { 197, 288, -140, -61},
-{ 188, 361, 197, 598}, { 442, 273, 290, 143}, { 472, 482, 157, 370},
-{ 415, 321, 372, 385}, { 402, 552, 155, 24}, { 550, 263, -11, 21},
-{ 360, 227, 147, -254}, { 424, 97, 366, -13}, { 375, 141, 449, 232},
-{ 396, 507, 474, 272}, { 701, 324, 362, -47}, { 587, 148, 543, 69},
-{ 400, -51, 561, 59}, { 220, -10, 352, 147}, { 206, 211, 653, 185},
-{ 563, 297, 565, 284}, { 594, 121, 766, 192}, { 398, 118, 642, 434},
-{ 233, 264, 481, 467}, { 129, -165, 699, 239}, { 90, 26, 342, 474},
-{ -55, 27, 388, 94}, { -172, 0, 725, 379}, { -60, 337, 370, 465},
-{ 95, 319, 806, 595}, { 78, 260, 497, 851}, { 210, 560, 458, 574},
-{ -464, 202, 497, 625}, { -202, 152, 48, 712}, { -20, 566, 100, 715},
-{ 455, 468, 411, 605}, { 319, 646, 195, 615}, { 401, 538, 680, 739},
-{ 201, 667, 434, 954}, { 454, 425, 646, 491}, { 606, 681, 416, 508},
-{ 497, 822, 426, 815}, { 660, 647, 628, 716}, { 697, 466, 618, 457},
-{ 685, 460, 365, 309}, { 721, 567, 836, 601}, { 609, 300, 825, 459},
-{ 943, 687, 681, 533}, { 915, 598, 591, 243}, { 876, 451, 874, 420},
-{ 786, 317, 732, 220}, { 922, 317, 1108, 367}, { 531, 466, 1028, 649},
-{ 1053, 615, 1034, 553}, { 829, 602, 1021, 799}, { 927, 803, 878, 763},
-{ 799, 496, 1373, 773}, { 585, 770, 803, 930}, { 1099, 793, 1222, 862},
-{ 1209, 895, 1025, 727}, { 772, 845, 1172, 1115}, { 867, 1021, 830, 1013},
-{ 841, 910, 506, 703}, { 1239, 1077, 620, 819}, { 1196, 1083, 1155, 1081},
-{ 1142, 907, 1547, 1121}, { 1309, 648, 1343, 612}, { 1484, 988, 1479, 937},
-{ 985, 1328, 955, 1341}, { 429, 910, 841, 1338}, { 564, 1179, 412, 1156},
-{ 1427, 1320, 1434, 1330}, { 640, 760, 1726, 1410}, { 190, 555, 1073, 1005},
-{ 426, 257, 839, 980}, { 235, 231, 1520, 1167}, { 109, 293, 1014, 1569},
-{ 305, 142, 1148, 539}, { -291, -108, 1213, 972}, { 22, -216, 667, 828},
-{ -482, 438, 453, 1431}, { -581, -422, 789, 387}, { -358, -454, 174, 780},
-{ -36, -372, 390, -134}, { -629, 160, -306, 751}, {-1258, -331, 177, 522},
-{ -248, 574, -251, 639}, { -531, 407, -596, 394}, { -419, 789, -617, 801},
-{ -986, 399, -857, 727}, { -7, 518, -703, 310}, {-1143, -24,-1002, 287},
-{ -960, 363,-1299, 312}, {-1534, 245,-1557, 305}, { 28, 153, -859, -175},
-{ -33, 332,-1398, -154}, { 212, 410, -593, -197}, {-1092, -704, -904, -65},
-{ 282, 367, -918, -686}, { 345, 93, -258, -357}, { 696, 644, -693, -28},
-{ 448, 493, -273, 193}, { 527, 546, -243, -513}, { 384, -136, 273, -353},
-{ 512, -142, 537, -198}, { 941, 750, 83, 248}, { 578, 861, -56, 592},
-{ 842, 44, 892, 24}, { 33, 890, -16, 982}, { 831, 1398, 1535, 1898},
-{ 1716, 1376, 1948, 1465}
-};
-
-static const int16_t lsf_5_5[64][4] = {
-{-1002, -929,-1096,-1203}, { -641, -931, -604, -961}, { -779, -673, -835, -788},
-{ -416, -664, -458, -766}, { -652, -521, -662, -495}, {-1023, -509,-1023, -428},
-{ -444, -552, -368, -449}, { -479, -211,-1054, -903}, { -316, -249, -569, -591},
-{ -569, -275, -541, -191}, { -716, -188, -842, -264}, { -333, -248, -318, -228},
-{ -275, 1, -567, -228}, { -115, -221, -238, -374}, { -197, -507, -222, -579},
-{ -258, -432, -61, -244}, { -345, 2, -338, 39}, { -215, -169, -58, 0},
-{ -56, -6, -203, -131}, { 1, -186, -5, -211}, { 6, -380, 11, -418},
-{ -116, 131, -134, 113}, { 89, -4, 71, -2}, { -19, -192, 262, 24},
-{ 189, 151, -133, -109}, { 186, -153, 166, -219}, { 37, 139, 193, 171},
-{ 337, 124, 158, -61}, { 141, 226, -13, 190}, { 231, 34, 354, 109},
-{ 316, 201, 244, 164}, { 330, -85, 390, -84}, { 254, 327, 257, 335},
-{ 491, 147, 476, 105}, { 54, 77, 437, 370}, { 421, 314, 449, 342},
-{ 329, 126, 673, 292}, { 571, 388, 243, 193}, { 653, 320, 621, 280},
-{ 194, 380, 517, 581}, { 45, 323, 111, 422}, { 489, 395, 734, 534},
-{ 622, 546, 486, 502}, { 318, 572, 189, 550}, { 385, 422, -157, 153},
-{ -125, 382, -197, 386}, { -263, 334, 228, 697}, { -188, 1, 51, 297},
-{ -507, 213, -376, 397}, { -24, 255, -547, 89}, { -502, -94, 387, 179},
-{ -620, 68, -684, 112}, { -642, -350, -260, 172}, { -438, -324, 264, 648},
-{ -964, -4,-1121, 7}, { -134, 134,-1133, -306}, { 143, 96, -420, -497},
-{-1221, -350,-1527, -685}, { -161, 72, 873, 691}, { 732, 283, 921, 353},
-{ 334, 475, 1095, 821}, { 864, 524, 843, 497}, { 714, 711, 788, 750},
-{ 1076, 714, 1204, 753}
-};
-
-static const float lsf_3_mean[LP_FILTER_ORDER] = {
- 377.441, 554.688, 922.363, 1339.84, 1702.15,
- 2046.390, 2452.880, 2741.460, 3116.70, 3348.14
-};
-
-static const float lsf_5_mean[LP_FILTER_ORDER] = {
- 337.891, 507.080, 834.961, 1247.07, 1646.00,
- 1982.910, 2407.960, 2708.010, 3104.00, 3344.97
-};
-
-/** Prediction factor table for modes other than 12.2kbit/s */
-static const float pred_fac[LP_FILTER_ORDER] = {
- 0.291626, 0.328644, 0.383636, 0.405640, 0.438873,
- 0.355560, 0.323120, 0.298065, 0.262238, 0.197876,
-};
-
-// fixed tables
-
-/**
- * number of pulses per mode
- */
-static const uint8_t pulses_nb_per_mode[] = {2, 2, 2, 3, 4, 4, 8, 10};
-
-/** track start positions for algebraic code book routines */
-static const uint8_t track_position[16] = {
- 0, 2, 0, 3, 0, 2, 0, 3, 1, 3, 2, 4, 1, 4, 1, 4
-};
-
-/** 3-bit Gray code to binary lookup table */
-static const uint8_t gray_decode[8] = { 0, 5, 15, 10, 25, 30, 20, 35 };
-
-
-// gain tables
-
-/** scalar quantized pitch gain table for 7.95 and 12.2 kbps modes */
-static const uint16_t qua_gain_pit[16] = {
- 0, 3277, 6556, 8192, 9830, 11469, 12288, 13107,
- 13926, 14746, 15565, 16384, 17203, 18022, 18842, 19661
-};
-
-/** scalar quantized fixed gain table for 7.95 and 12.2 kbps modes */
-static const uint16_t qua_gain_code[32] = {
- 159, 206, 268, 349, 419, 482, 554, 637,
- 733, 842, 969, 1114, 1281, 1473, 1694, 1948,
- 2241, 2577, 2963, 3408, 3919, 4507, 5183, 5960,
- 6855, 7883, 9065, 10425, 12510, 16263, 21142, 27485
-};
-
-/** desired mean innovation energy, indexed by active mode */
-static const float energy_mean[8] = {
- 33.0, 33.0, 33.0, 28.75, 30.0, 36.0, 33.0, 36.0
-};
-
-/** 4-tap moving average prediction coefficients in reverse order */
-static const float energy_pred_fac[4] = { 0.19, 0.34, 0.58, 0.68 };
-
-/** gain table for 4.75 kbps mode
- *
- * first index has even/odd indexes for subframes 0,2/1,3
- * second index is {pitch_gain, fixed_gain_factor} */
-static const uint16_t gains_MODE_4k75[512][2] = {
-{ 812, 128}, { 542, 140}, { 2873, 1135}, { 2266, 3402}, { 2067, 563},
-{12677, 647}, { 4132, 1798}, { 5601, 5285}, { 7689, 374}, { 3735, 441},
-{10912, 2638}, {11807, 2494}, {20490, 797}, { 5218, 675}, { 6724, 8354},
-{ 5282, 1696}, { 1488, 428}, { 5882, 452}, { 5332, 4072}, { 3583, 1268},
-{ 2469, 901}, {15894, 1005}, {14982, 3271}, {10331, 4858}, { 3635, 2021},
-{ 2596, 835}, {12360, 4892}, {12206, 1704}, {13432, 1604}, { 9118, 2341},
-{ 3968, 1538}, { 5479, 9936}, { 3795, 417}, { 1359, 414}, { 3640, 1569},
-{ 7995, 3541}, {11405, 645}, { 8552, 635}, { 4056, 1377}, {16608, 6124},
-{11420, 700}, { 2007, 607}, {12415, 1578}, {11119, 4654}, {13680, 1708},
-{11990, 1229}, { 7996, 7297}, {13231, 5715}, { 2428, 1159}, { 2073, 1941},
-{ 6218, 6121}, { 3546, 1804}, { 8925, 1802}, { 8679, 1580}, {13935, 3576},
-{13313, 6237}, { 6142, 1130}, { 5994, 1734}, {14141, 4662}, {11271, 3321},
-{12226, 1551}, {13931, 3015}, { 5081,10464}, { 9444, 6706}, { 1689, 683},
-{ 1436, 1306}, { 7212, 3933}, { 4082, 2713}, { 7793, 704}, {15070, 802},
-{ 6299, 5212}, { 4337, 5357}, { 6676, 541}, { 6062, 626}, {13651, 3700},
-{11498, 2408}, {16156, 716}, {12177, 751}, { 8065,11489}, { 6314, 2256},
-{ 4466, 496}, { 7293, 523}, {10213, 3833}, { 8394, 3037}, { 8403, 966},
-{14228, 1880}, { 8703, 5409}, {16395, 4863}, { 7420, 1979}, { 6089, 1230},
-{ 9371, 4398}, {14558, 3363}, {13559, 2873}, {13163, 1465}, { 5534, 1678},
-{13138,14771}, { 7338, 600}, { 1318, 548}, { 4252, 3539}, {10044, 2364},
-{10587, 622}, {13088, 669}, {14126, 3526}, { 5039, 9784}, {15338, 619},
-{ 3115, 590}, {16442, 3013}, {15542, 4168}, {15537, 1611}, {15405, 1228},
-{16023, 9299}, { 7534, 4976}, { 1990, 1213}, {11447, 1157}, {12512, 5519},
-{ 9475, 2644}, { 7716, 2034}, {13280, 2239}, {16011, 5093}, { 8066, 6761},
-{10083, 1413}, { 5002, 2347}, {12523, 5975}, {15126, 2899}, {18264, 2289},
-{15827, 2527}, {16265,10254}, {14651,11319}, { 1797, 337}, { 3115, 397},
-{ 3510, 2928}, { 4592, 2670}, { 7519, 628}, {11415, 656}, { 5946, 2435},
-{ 6544, 7367}, { 8238, 829}, { 4000, 863}, {10032, 2492}, {16057, 3551},
-{18204, 1054}, { 6103, 1454}, { 5884, 7900}, {18752, 3468}, { 1864, 544},
-{ 9198, 683}, {11623, 4160}, { 4594, 1644}, { 3158, 1157}, {15953, 2560},
-{12349, 3733}, {17420, 5260}, { 6106, 2004}, { 2917, 1742}, {16467, 5257},
-{16787, 1680}, {17205, 1759}, { 4773, 3231}, { 7386, 6035}, {14342,10012},
-{ 4035, 442}, { 4194, 458}, { 9214, 2242}, { 7427, 4217}, {12860, 801},
-{11186, 825}, {12648, 2084}, {12956, 6554}, { 9505, 996}, { 6629, 985},
-{10537, 2502}, {15289, 5006}, {12602, 2055}, {15484, 1653}, {16194, 6921},
-{14231, 5790}, { 2626, 828}, { 5615, 1686}, {13663, 5778}, { 3668, 1554},
-{11313, 2633}, { 9770, 1459}, {14003, 4733}, {15897, 6291}, { 6278, 1870},
-{ 7910, 2285}, {16978, 4571}, {16576, 3849}, {15248, 2311}, {16023, 3244},
-{14459,17808}, {11847, 2763}, { 1981, 1407}, { 1400, 876}, { 4335, 3547},
-{ 4391, 4210}, { 5405, 680}, {17461, 781}, { 6501, 5118}, { 8091, 7677},
-{ 7355, 794}, { 8333, 1182}, {15041, 3160}, {14928, 3039}, {20421, 880},
-{14545, 852}, {12337,14708}, { 6904, 1920}, { 4225, 933}, { 8218, 1087},
-{10659, 4084}, {10082, 4533}, { 2735, 840}, {20657, 1081}, {16711, 5966},
-{15873, 4578}, {10871, 2574}, { 3773, 1166}, {14519, 4044}, {20699, 2627},
-{15219, 2734}, {15274, 2186}, { 6257, 3226}, {13125,19480}, { 7196, 930},
-{ 2462, 1618}, { 4515, 3092}, {13852, 4277}, {10460, 833}, {17339, 810},
-{16891, 2289}, {15546, 8217}, {13603, 1684}, { 3197, 1834}, {15948, 2820},
-{15812, 5327}, {17006, 2438}, {16788, 1326}, {15671, 8156}, {11726, 8556},
-{ 3762, 2053}, { 9563, 1317}, {13561, 6790}, {12227, 1936}, { 8180, 3550},
-{13287, 1778}, {16299, 6599}, {16291, 7758}, { 8521, 2551}, { 7225, 2645},
-{18269, 7489}, {16885, 2248}, {17882, 2884}, {17265, 3328}, { 9417,20162},
-{11042, 8320}, { 1286, 620}, { 1431, 583}, { 5993, 2289}, { 3978, 3626},
-{ 5144, 752}, {13409, 830}, { 5553, 2860}, {11764, 5908}, {10737, 560},
-{ 5446, 564}, {13321, 3008}, {11946, 3683}, {19887, 798}, { 9825, 728},
-{13663, 8748}, { 7391, 3053}, { 2515, 778}, { 6050, 833}, { 6469, 5074},
-{ 8305, 2463}, { 6141, 1865}, {15308, 1262}, {14408, 4547}, {13663, 4515},
-{ 3137, 2983}, { 2479, 1259}, {15088, 4647}, {15382, 2607}, {14492, 2392},
-{12462, 2537}, { 7539, 2949}, {12909,12060}, { 5468, 684}, { 3141, 722},
-{ 5081, 1274}, {12732, 4200}, {15302, 681}, { 7819, 592}, { 6534, 2021},
-{16478, 8737}, {13364, 882}, { 5397, 899}, {14656, 2178}, {14741, 4227},
-{14270, 1298}, {13929, 2029}, {15477, 7482}, {15815, 4572}, { 2521, 2013},
-{ 5062, 1804}, { 5159, 6582}, { 7130, 3597}, {10920, 1611}, {11729, 1708},
-{16903, 3455}, {16268, 6640}, { 9306, 1007}, { 9369, 2106}, {19182, 5037},
-{12441, 4269}, {15919, 1332}, {15357, 3512}, {11898,14141}, {16101, 6854},
-{ 2010, 737}, { 3779, 861}, {11454, 2880}, { 3564, 3540}, { 9057, 1241},
-{12391, 896}, { 8546, 4629}, {11561, 5776}, { 8129, 589}, { 8218, 588},
-{18728, 3755}, {12973, 3149}, {15729, 758}, {16634, 754}, {15222,11138},
-{15871, 2208}, { 4673, 610}, {10218, 678}, {15257, 4146}, { 5729, 3327},
-{ 8377, 1670}, {19862, 2321}, {15450, 5511}, {14054, 5481}, { 5728, 2888},
-{ 7580, 1346}, {14384, 5325}, {16236, 3950}, {15118, 3744}, {15306, 1435},
-{14597, 4070}, {12301,15696}, { 7617, 1699}, { 2170, 884}, { 4459, 4567},
-{18094, 3306}, {12742, 815}, {14926, 907}, {15016, 4281}, {15518, 8368},
-{17994, 1087}, { 2358, 865}, {16281, 3787}, {15679, 4596}, {16356, 1534},
-{16584, 2210}, {16833, 9697}, {15929, 4513}, { 3277, 1085}, { 9643, 2187},
-{11973, 6068}, { 9199, 4462}, { 8955, 1629}, {10289, 3062}, {16481, 5155},
-{15466, 7066}, {13678, 2543}, { 5273, 2277}, {16746, 6213}, {16655, 3408},
-{20304, 3363}, {18688, 1985}, {14172,12867}, {15154,15703}, { 4473, 1020},
-{ 1681, 886}, { 4311, 4301}, { 8952, 3657}, { 5893, 1147}, {11647, 1452},
-{15886, 2227}, { 4582, 6644}, { 6929, 1205}, { 6220, 799}, {12415, 3409},
-{15968, 3877}, {19859, 2109}, { 9689, 2141}, {14742, 8830}, {14480, 2599},
-{ 1817, 1238}, { 7771, 813}, {19079, 4410}, { 5554, 2064}, { 3687, 2844},
-{17435, 2256}, {16697, 4486}, {16199, 5388}, { 8028, 2763}, { 3405, 2119},
-{17426, 5477}, {13698, 2786}, {19879, 2720}, { 9098, 3880}, {18172, 4833},
-{17336,12207}, { 5116, 996}, { 4935, 988}, { 9888, 3081}, { 6014, 5371},
-{15881, 1667}, { 8405, 1183}, {15087, 2366}, {19777, 7002}, {11963, 1562},
-{ 7279, 1128}, {16859, 1532}, {15762, 5381}, {14708, 2065}, {20105, 2155},
-{17158, 8245}, {17911, 6318}, { 5467, 1504}, { 4100, 2574}, {17421, 6810},
-{ 5673, 2888}, {16636, 3382}, { 8975, 1831}, {20159, 4737}, {19550, 7294},
-{ 6658, 2781}, {11472, 3321}, {19397, 5054}, {18878, 4722}, {16439, 2373},
-{20430, 4386}, {11353,26526}, {11593, 3068}, { 2866, 1566}, { 5108, 1070},
-{ 9614, 4915}, { 4939, 3536}, { 7541, 878}, {20717, 851}, { 6938, 4395},
-{16799, 7733}, {10137, 1019}, { 9845, 964}, {15494, 3955}, {15459, 3430},
-{18863, 982}, {20120, 963}, {16876,12887}, {14334, 4200}, { 6599, 1220},
-{ 9222, 814}, {16942, 5134}, { 5661, 4898}, { 5488, 1798}, {20258, 3962},
-{17005, 6178}, {17929, 5929}, { 9365, 3420}, { 7474, 1971}, {19537, 5177},
-{19003, 3006}, {16454, 3788}, {16070, 2367}, { 8664, 2743}, { 9445,26358},
-{10856, 1287}, { 3555, 1009}, { 5606, 3622}, {19453, 5512}, {12453, 797},
-{20634, 911}, {15427, 3066}, {17037,10275}, {18883, 2633}, { 3913, 1268},
-{19519, 3371}, {18052, 5230}, {19291, 1678}, {19508, 3172}, {18072,10754},
-{16625, 6845}, { 3134, 2298}, {10869, 2437}, {15580, 6913}, {12597, 3381},
-{11116, 3297}, {16762, 2424}, {18853, 6715}, {17171, 9887}, {12743, 2605},
-{ 8937, 3140}, {19033, 7764}, {18347, 3880}, {20475, 3682}, {19602, 3380},
-{13044,19373}, {10526,23124}
-};
-
-/** gain table for 6.70, 7.40 and 10.2 kbps modes
- *
- * second index is {pitch_gain, fixed_gain_factor} */
-static const uint16_t gains_high[128][2] = {
-{ 577, 662}, { 806, 1836}, { 3109, 1052}, { 4181, 1387}, { 2373, 1425},
-{ 3248, 1985}, { 1827, 2320}, { 941, 3314}, { 2351, 2977}, { 3616, 2420},
-{ 3451, 3096}, { 2955, 4301}, { 1848, 4500}, { 3884, 5416}, { 1187, 7210},
-{ 3083, 9000}, { 7384, 883}, { 5962, 1506}, { 5155, 2134}, { 7944, 2009},
-{ 6507, 2250}, { 7670, 2752}, { 5952, 3016}, { 4898, 3764}, { 6989, 3588},
-{ 8174, 3978}, { 6064, 4404}, { 7709, 5087}, { 5523, 6021}, { 7769, 7126},
-{ 6060, 7938}, { 5594,11487}, {10581, 1356}, { 9049, 1597}, { 9794, 2035},
-{ 8946, 2415}, {10296, 2584}, { 9407, 2734}, { 8700, 3218}, { 9757, 3395},
-{10177, 3892}, { 9170, 4528}, {10152, 5004}, { 9114, 5735}, {10500, 6266},
-{10110, 7631}, { 8844, 8727}, { 8956,12496}, {12924, 976}, {11435, 1755},
-{12138, 2328}, {11388, 2368}, {10700, 3064}, {12332, 2861}, {11722, 3327},
-{11270, 3700}, {10861, 4413}, {12082, 4533}, {11283, 5205}, {11960, 6305},
-{11167, 7534}, {12128, 8329}, {10969,10777}, {10300,17376}, {13899, 1681},
-{12580, 2045}, {13265, 2439}, {14033, 2989}, {13452, 3098}, {12396, 3658},
-{13510, 3780}, {12880, 4272}, {13533, 4861}, {12667, 5457}, {13854, 6106},
-{13031, 6483}, {13557, 7721}, {12957, 9311}, {13714,11551}, {12591,15206},
-{15113, 1540}, {15072, 2333}, {14527, 2511}, {14692, 3199}, {15382, 3560},
-{14133, 3960}, {15102, 4236}, {14332, 4824}, {14846, 5451}, {15306, 6083},
-{14329, 6888}, {15060, 7689}, {14406, 9426}, {15387, 9741}, {14824,14271},
-{13600,24939}, {16396, 1969}, {16817, 2832}, {15713, 2843}, {16104, 3336},
-{16384, 3963}, {16940, 4579}, {15711, 4599}, {16222, 5448}, {16832, 6382},
-{15745, 7141}, {16326, 7469}, {16611, 8624}, {17028,10418}, {15905,11817},
-{16878,14690}, {16515,20870}, {18142, 2083}, {19401, 3178}, {17508, 3426},
-{20054, 4027}, {18069, 4249}, {18952, 5066}, {17711, 5402}, {19835, 6192},
-{17950, 7014}, {21318, 7877}, {17910, 9289}, {19144, 9290}, {20517,11381},
-{18075,14485}, {19999,17882}, {18842,32764}
-};
-
-/** gain table for 5.15 and 5.90 kbps modes
- *
- * second index is {pitch_gain, fixed_gain_factor} */
-static const uint16_t gains_low[64][2] = {
-{10813,28753}, {20480, 2785}, {18841, 6594}, { 6225, 7413}, {17203,10444},
-{21626, 1269}, {21135, 4423}, {11304, 1556}, {19005,12820}, {17367, 2498},
-{17858, 4833}, { 9994, 2498}, {17530, 7864}, {14254, 1884}, {15892, 3153},
-{ 6717, 1802}, {18186,20193}, {18022, 3031}, {16711, 5857}, { 8847, 4014},
-{15892, 8970}, {18022, 1392}, {16711, 4096}, { 8192, 655}, {15237,13926},
-{14254, 3112}, {14090, 4669}, { 5406, 2703}, {13434, 6553}, {12451, 901},
-{12451, 2662}, { 3768, 655}, {14745,23511}, {19169, 2457}, {20152, 5079},
-{ 6881, 4096}, {20480, 8560}, {19660, 737}, {19005, 4259}, { 7864, 2088},
-{11468,12288}, {15892, 1474}, {15728, 4628}, { 9175, 1433}, {16056, 7004},
-{14827, 737}, {15073, 2252}, { 5079, 1228}, {13271,17326}, {16547, 2334},
-{15073, 5816}, { 3932, 3686}, {14254, 8601}, {16875, 778}, {15073, 3809},
-{ 6062, 614}, { 9338, 9256}, {13271, 1761}, {13271, 3522}, { 2457, 1966},
-{11468, 5529}, {10485, 737}, {11632, 3194}, { 1474, 778}
-};
-
-
-// pre-processing tables
-
-/** impulse response filter tables converted to float from Q15 int32_t
- * used for anti-sparseness processing */
-static const float ir_filter_strong_MODE_7k95[AMR_SUBFRAME_SIZE] = {
- 0.817169, 0.024445, 0.076447, -0.020844, -0.042175, 0.017761, 0.018433,
--0.038879, 0.107147, -0.179871, 0.138367, -0.015228, -0.059204, 0.091888,
--0.154358, 0.171326, -0.060730, -0.032379, -0.044525, 0.135559, -0.021362,
--0.162811, 0.140656, 0.013794, -0.017975, -0.102295, 0.090118, 0.038666,
--0.036987, -0.079041, 0.052826, 0.112000, -0.136566, -0.029755, 0.134003,
--0.077423, 0.028961, -0.041595, -0.029877, 0.174988,
-};
-
-static const float ir_filter_strong[AMR_SUBFRAME_SIZE] = {
- 0.448303, 0.351501, 0.038696, -0.084259, -0.173065, 0.229309, -0.001068,
--0.085663, -0.092773, 0.147186, 0.090088, -0.257080, 0.115509, 0.044403,
- 0.066498, -0.263580, 0.245697, -0.064178, -0.044373, 0.023712, 0.033813,
--0.072784, 0.068787, -0.011078, -0.020569, -0.064178, 0.184509, -0.173370,
- 0.032715, 0.095306, -0.154358, 0.162109, -0.071075, -0.113770, 0.211304,
--0.118683, 0.020599, -0.054169, 0.000885, 0.309601,
-};
-
-static const float ir_filter_medium[AMR_SUBFRAME_SIZE] = {
- 0.923889, 0.116913, -0.123169, 0.090698, -0.031982, -0.030579, 0.075592,
--0.092865, 0.085907, -0.068085, 0.053497, -0.049164, 0.052307, -0.054169,
- 0.047089, -0.030762, 0.013092, -0.005157, 0.014404, -0.038574, 0.066406,
--0.082581, 0.076996, -0.049469, 0.010498, 0.025208, -0.046661, 0.052612,
--0.050568, 0.051910, -0.062958, 0.080688, -0.093384, 0.088409, -0.060364,
- 0.016998, 0.023804, -0.041779, 0.025696, 0.019989,
-};
-
-static const float * const ir_filters_lookup[2] = {
- ir_filter_strong, ir_filter_medium
-};
-static const float * const ir_filters_lookup_MODE_7k95[2] = {
- ir_filter_strong_MODE_7k95, ir_filter_medium
-};
-
-// High-pass coefficients
-
-static const float highpass_zeros[2] = { -2.0, 1.0 };
-static const float highpass_poles[2] = { -1.933105469, 0.935913085 };
-static const float highpass_gain = 0.939819335;
-
-#endif /* AVCODEC_AMRNBDATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/amrnbdec.c b/src/thirdparty/ffmpeg/libavcodec/amrnbdec.c
deleted file mode 100644
index ee1353641..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/amrnbdec.c
+++ /dev/null
@@ -1,1096 +0,0 @@
-/*
- * AMR narrowband decoder
- * Copyright (c) 2006-2007 Robert Swain
- * Copyright (c) 2009 Colin McQuillan
- *
- * 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
- * AMR narrowband decoder
- *
- * This decoder uses floats for simplicity and so is not bit-exact. One
- * difference is that differences in phase can accumulate. The test sequences
- * in 3GPP TS 26.074 can still be useful.
- *
- * - Comparing this file's output to the output of the ref decoder gives a
- * PSNR of 30 to 80. Plotting the output samples shows a difference in
- * phase in some areas.
- *
- * - Comparing both decoders against their input, this decoder gives a similar
- * PSNR. If the test sequence homing frames are removed (this decoder does
- * not detect them), the PSNR is at least as good as the reference on 140
- * out of 169 tests.
- */
-
-
-#include <string.h>
-#include <math.h>
-
-#include "libavutil/channel_layout.h"
-#include "libavutil/float_dsp.h"
-#include "avcodec.h"
-#include "libavutil/common.h"
-#include "libavutil/avassert.h"
-#include "celp_math.h"
-#include "celp_filters.h"
-#include "acelp_filters.h"
-#include "acelp_vectors.h"
-#include "acelp_pitch_delay.h"
-#include "lsp.h"
-#include "amr.h"
-#include "internal.h"
-
-#include "amrnbdata.h"
-
-#define AMR_BLOCK_SIZE 160 ///< samples per frame
-#define AMR_SAMPLE_BOUND 32768.0 ///< threshold for synthesis overflow
-
-/**
- * Scale from constructed speech to [-1,1]
- *
- * AMR is designed to produce 16-bit PCM samples (3GPP TS 26.090 4.2) but
- * upscales by two (section 6.2.2).
- *
- * Fundamentally, this scale is determined by energy_mean through
- * the fixed vector contribution to the excitation vector.
- */
-#define AMR_SAMPLE_SCALE (2.0 / 32768.0)
-
-/** Prediction factor for 12.2kbit/s mode */
-#define PRED_FAC_MODE_12k2 0.65
-
-#define LSF_R_FAC (8000.0 / 32768.0) ///< LSF residual tables to Hertz
-#define MIN_LSF_SPACING (50.0488 / 8000.0) ///< Ensures stability of LPC filter
-#define PITCH_LAG_MIN_MODE_12k2 18 ///< Lower bound on decoded lag search in 12.2kbit/s mode
-
-/** Initial energy in dB. Also used for bad frames (unimplemented). */
-#define MIN_ENERGY -14.0
-
-/** Maximum sharpening factor
- *
- * The specification says 0.8, which should be 13107, but the reference C code
- * uses 13017 instead. (Amusingly the same applies to SHARP_MAX in g729dec.c.)
- */
-#define SHARP_MAX 0.79449462890625
-
-/** Number of impulse response coefficients used for tilt factor */
-#define AMR_TILT_RESPONSE 22
-/** Tilt factor = 1st reflection coefficient * gamma_t */
-#define AMR_TILT_GAMMA_T 0.8
-/** Adaptive gain control factor used in post-filter */
-#define AMR_AGC_ALPHA 0.9
-
-typedef struct AMRContext {
- AMRNBFrame frame; ///< decoded AMR parameters (lsf coefficients, codebook indexes, etc)
- uint8_t bad_frame_indicator; ///< bad frame ? 1 : 0
- enum Mode cur_frame_mode;
-
- int16_t prev_lsf_r[LP_FILTER_ORDER]; ///< residual LSF vector from previous subframe
- double lsp[4][LP_FILTER_ORDER]; ///< lsp vectors from current frame
- double prev_lsp_sub4[LP_FILTER_ORDER]; ///< lsp vector for the 4th subframe of the previous frame
-
- float lsf_q[4][LP_FILTER_ORDER]; ///< Interpolated LSF vector for fixed gain smoothing
- float lsf_avg[LP_FILTER_ORDER]; ///< vector of averaged lsf vector
-
- float lpc[4][LP_FILTER_ORDER]; ///< lpc coefficient vectors for 4 subframes
-
- uint8_t pitch_lag_int; ///< integer part of pitch lag from current subframe
-
- float excitation_buf[PITCH_DELAY_MAX + LP_FILTER_ORDER + 1 + AMR_SUBFRAME_SIZE]; ///< current excitation and all necessary excitation history
- float *excitation; ///< pointer to the current excitation vector in excitation_buf
-
- float pitch_vector[AMR_SUBFRAME_SIZE]; ///< adaptive code book (pitch) vector
- float fixed_vector[AMR_SUBFRAME_SIZE]; ///< algebraic codebook (fixed) vector (must be kept zero between frames)
-
- float prediction_error[4]; ///< quantified prediction errors {20log10(^gamma_gc)} for previous four subframes
- float pitch_gain[5]; ///< quantified pitch gains for the current and previous four subframes
- float fixed_gain[5]; ///< quantified fixed gains for the current and previous four subframes
-
- float beta; ///< previous pitch_gain, bounded by [0.0,SHARP_MAX]
- uint8_t diff_count; ///< the number of subframes for which diff has been above 0.65
- uint8_t hang_count; ///< the number of subframes since a hangover period started
-
- float prev_sparse_fixed_gain; ///< previous fixed gain; used by anti-sparseness processing to determine "onset"
- uint8_t prev_ir_filter_nr; ///< previous impulse response filter "impNr": 0 - strong, 1 - medium, 2 - none
- uint8_t ir_filter_onset; ///< flag for impulse response filter strength
-
- float postfilter_mem[10]; ///< previous intermediate values in the formant filter
- float tilt_mem; ///< previous input to tilt compensation filter
- float postfilter_agc; ///< previous factor used for adaptive gain control
- float high_pass_mem[2]; ///< previous intermediate values in the high-pass filter
-
- float samples_in[LP_FILTER_ORDER + AMR_SUBFRAME_SIZE]; ///< floating point samples
-
- ACELPFContext acelpf_ctx; ///< context for filters for ACELP-based codecs
- ACELPVContext acelpv_ctx; ///< context for vector operations for ACELP-based codecs
- CELPFContext celpf_ctx; ///< context for filters for CELP-based codecs
- CELPMContext celpm_ctx; ///< context for fixed point math operations
-
-} AMRContext;
-
-/** Double version of ff_weighted_vector_sumf() */
-static void weighted_vector_sumd(double *out, const double *in_a,
- const double *in_b, double weight_coeff_a,
- double weight_coeff_b, int length)
-{
- int i;
-
- for (i = 0; i < length; i++)
- out[i] = weight_coeff_a * in_a[i]
- + weight_coeff_b * in_b[i];
-}
-
-static av_cold int amrnb_decode_init(AVCodecContext *avctx)
-{
- AMRContext *p = avctx->priv_data;
- int i;
-
- if (avctx->channels > 1) {
- av_log_missing_feature(avctx, "multi-channel AMR", 0);
- return AVERROR_PATCHWELCOME;
- }
-
- avctx->channels = 1;
- avctx->channel_layout = AV_CH_LAYOUT_MONO;
- if (!avctx->sample_rate)
- avctx->sample_rate = 8000;
- avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
-
- // p->excitation always points to the same position in p->excitation_buf
- p->excitation = &p->excitation_buf[PITCH_DELAY_MAX + LP_FILTER_ORDER + 1];
-
- for (i = 0; i < LP_FILTER_ORDER; i++) {
- p->prev_lsp_sub4[i] = lsp_sub4_init[i] * 1000 / (float)(1 << 15);
- p->lsf_avg[i] = p->lsf_q[3][i] = lsp_avg_init[i] / (float)(1 << 15);
- }
-
- for (i = 0; i < 4; i++)
- p->prediction_error[i] = MIN_ENERGY;
-
- ff_acelp_filter_init(&p->acelpf_ctx);
- ff_acelp_vectors_init(&p->acelpv_ctx);
- ff_celp_filter_init(&p->celpf_ctx);
- ff_celp_math_init(&p->celpm_ctx);
-
- return 0;
-}
-
-
-/**
- * Unpack an RFC4867 speech frame into the AMR frame mode and parameters.
- *
- * The order of speech bits is specified by 3GPP TS 26.101.
- *
- * @param p the context
- * @param buf pointer to the input buffer
- * @param buf_size size of the input buffer
- *
- * @return the frame mode
- */
-static enum Mode unpack_bitstream(AMRContext *p, const uint8_t *buf,
- int buf_size)
-{
- enum Mode mode;
-
- // Decode the first octet.
- mode = buf[0] >> 3 & 0x0F; // frame type
- p->bad_frame_indicator = (buf[0] & 0x4) != 0x4; // quality bit
-
- if (mode >= N_MODES || buf_size < frame_sizes_nb[mode] + 1) {
- return NO_DATA;
- }
-
- if (mode < MODE_DTX)
- ff_amr_bit_reorder((uint16_t *) &p->frame, sizeof(AMRNBFrame), buf + 1,
- amr_unpacking_bitmaps_per_mode[mode]);
-
- return mode;
-}
-
-
-/// @name AMR pitch LPC coefficient decoding functions
-/// @{
-
-/**
- * Interpolate the LSF vector (used for fixed gain smoothing).
- * The interpolation is done over all four subframes even in MODE_12k2.
- *
- * @param[in] ctx The Context
- * @param[in,out] lsf_q LSFs in [0,1] for each subframe
- * @param[in] lsf_new New LSFs in [0,1] for subframe 4
- */
-static void interpolate_lsf(ACELPVContext *ctx, float lsf_q[4][LP_FILTER_ORDER], float *lsf_new)
-{
- int i;
-
- for (i = 0; i < 4; i++)
- ctx->weighted_vector_sumf(lsf_q[i], lsf_q[3], lsf_new,
- 0.25 * (3 - i), 0.25 * (i + 1),
- LP_FILTER_ORDER);
-}
-
-/**
- * Decode a set of 5 split-matrix quantized lsf indexes into an lsp vector.
- *
- * @param p the context
- * @param lsp output LSP vector
- * @param lsf_no_r LSF vector without the residual vector added
- * @param lsf_quantizer pointers to LSF dictionary tables
- * @param quantizer_offset offset in tables
- * @param sign for the 3 dictionary table
- * @param update store data for computing the next frame's LSFs
- */
-static void lsf2lsp_for_mode12k2(AMRContext *p, double lsp[LP_FILTER_ORDER],
- const float lsf_no_r[LP_FILTER_ORDER],
- const int16_t *lsf_quantizer[5],
- const int quantizer_offset,
- const int sign, const int update)
-{
- int16_t lsf_r[LP_FILTER_ORDER]; // residual LSF vector
- float lsf_q[LP_FILTER_ORDER]; // quantified LSF vector
- int i;
-
- for (i = 0; i < LP_FILTER_ORDER >> 1; i++)
- memcpy(&lsf_r[i << 1], &lsf_quantizer[i][quantizer_offset],
- 2 * sizeof(*lsf_r));
-
- if (sign) {
- lsf_r[4] *= -1;
- lsf_r[5] *= -1;
- }
-
- if (update)
- memcpy(p->prev_lsf_r, lsf_r, LP_FILTER_ORDER * sizeof(*lsf_r));
-
- for (i = 0; i < LP_FILTER_ORDER; i++)
- lsf_q[i] = lsf_r[i] * (LSF_R_FAC / 8000.0) + lsf_no_r[i] * (1.0 / 8000.0);
-
- ff_set_min_dist_lsf(lsf_q, MIN_LSF_SPACING, LP_FILTER_ORDER);
-
- if (update)
- interpolate_lsf(&p->acelpv_ctx, p->lsf_q, lsf_q);
-
- ff_acelp_lsf2lspd(lsp, lsf_q, LP_FILTER_ORDER);
-}
-
-/**
- * Decode a set of 5 split-matrix quantized lsf indexes into 2 lsp vectors.
- *
- * @param p pointer to the AMRContext
- */
-static void lsf2lsp_5(AMRContext *p)
-{
- const uint16_t *lsf_param = p->frame.lsf;
- float lsf_no_r[LP_FILTER_ORDER]; // LSFs without the residual vector
- const int16_t *lsf_quantizer[5];
- int i;
-
- lsf_quantizer[0] = lsf_5_1[lsf_param[0]];
- lsf_quantizer[1] = lsf_5_2[lsf_param[1]];
- lsf_quantizer[2] = lsf_5_3[lsf_param[2] >> 1];
- lsf_quantizer[3] = lsf_5_4[lsf_param[3]];
- lsf_quantizer[4] = lsf_5_5[lsf_param[4]];
-
- for (i = 0; i < LP_FILTER_ORDER; i++)
- lsf_no_r[i] = p->prev_lsf_r[i] * LSF_R_FAC * PRED_FAC_MODE_12k2 + lsf_5_mean[i];
-
- lsf2lsp_for_mode12k2(p, p->lsp[1], lsf_no_r, lsf_quantizer, 0, lsf_param[2] & 1, 0);
- lsf2lsp_for_mode12k2(p, p->lsp[3], lsf_no_r, lsf_quantizer, 2, lsf_param[2] & 1, 1);
-
- // interpolate LSP vectors at subframes 1 and 3
- weighted_vector_sumd(p->lsp[0], p->prev_lsp_sub4, p->lsp[1], 0.5, 0.5, LP_FILTER_ORDER);
- weighted_vector_sumd(p->lsp[2], p->lsp[1] , p->lsp[3], 0.5, 0.5, LP_FILTER_ORDER);
-}
-
-/**
- * Decode a set of 3 split-matrix quantized lsf indexes into an lsp vector.
- *
- * @param p pointer to the AMRContext
- */
-static void lsf2lsp_3(AMRContext *p)
-{
- const uint16_t *lsf_param = p->frame.lsf;
- int16_t lsf_r[LP_FILTER_ORDER]; // residual LSF vector
- float lsf_q[LP_FILTER_ORDER]; // quantified LSF vector
- const int16_t *lsf_quantizer;
- int i, j;
-
- lsf_quantizer = (p->cur_frame_mode == MODE_7k95 ? lsf_3_1_MODE_7k95 : lsf_3_1)[lsf_param[0]];
- memcpy(lsf_r, lsf_quantizer, 3 * sizeof(*lsf_r));
-
- lsf_quantizer = lsf_3_2[lsf_param[1] << (p->cur_frame_mode <= MODE_5k15)];
- memcpy(lsf_r + 3, lsf_quantizer, 3 * sizeof(*lsf_r));
-
- lsf_quantizer = (p->cur_frame_mode <= MODE_5k15 ? lsf_3_3_MODE_5k15 : lsf_3_3)[lsf_param[2]];
- memcpy(lsf_r + 6, lsf_quantizer, 4 * sizeof(*lsf_r));
-
- // calculate mean-removed LSF vector and add mean
- for (i = 0; i < LP_FILTER_ORDER; i++)
- lsf_q[i] = (lsf_r[i] + p->prev_lsf_r[i] * pred_fac[i]) * (LSF_R_FAC / 8000.0) + lsf_3_mean[i] * (1.0 / 8000.0);
-
- ff_set_min_dist_lsf(lsf_q, MIN_LSF_SPACING, LP_FILTER_ORDER);
-
- // store data for computing the next frame's LSFs
- interpolate_lsf(&p->acelpv_ctx, p->lsf_q, lsf_q);
- memcpy(p->prev_lsf_r, lsf_r, LP_FILTER_ORDER * sizeof(*lsf_r));
-
- ff_acelp_lsf2lspd(p->lsp[3], lsf_q, LP_FILTER_ORDER);
-
- // interpolate LSP vectors at subframes 1, 2 and 3
- for (i = 1; i <= 3; i++)
- for(j = 0; j < LP_FILTER_ORDER; j++)
- p->lsp[i-1][j] = p->prev_lsp_sub4[j] +
- (p->lsp[3][j] - p->prev_lsp_sub4[j]) * 0.25 * i;
-}
-
-/// @}
-
-
-/// @name AMR pitch vector decoding functions
-/// @{
-
-/**
- * Like ff_decode_pitch_lag(), but with 1/6 resolution
- */
-static void decode_pitch_lag_1_6(int *lag_int, int *lag_frac, int pitch_index,
- const int prev_lag_int, const int subframe)
-{
- if (subframe == 0 || subframe == 2) {
- if (pitch_index < 463) {
- *lag_int = (pitch_index + 107) * 10923 >> 16;
- *lag_frac = pitch_index - *lag_int * 6 + 105;
- } else {
- *lag_int = pitch_index - 368;
- *lag_frac = 0;
- }
- } else {
- *lag_int = ((pitch_index + 5) * 10923 >> 16) - 1;
- *lag_frac = pitch_index - *lag_int * 6 - 3;
- *lag_int += av_clip(prev_lag_int - 5, PITCH_LAG_MIN_MODE_12k2,
- PITCH_DELAY_MAX - 9);
- }
-}
-
-static void decode_pitch_vector(AMRContext *p,
- const AMRNBSubframe *amr_subframe,
- const int subframe)
-{
- int pitch_lag_int, pitch_lag_frac;
- enum Mode mode = p->cur_frame_mode;
-
- if (p->cur_frame_mode == MODE_12k2) {
- decode_pitch_lag_1_6(&pitch_lag_int, &pitch_lag_frac,
- amr_subframe->p_lag, p->pitch_lag_int,
- subframe);
- } else
- ff_decode_pitch_lag(&pitch_lag_int, &pitch_lag_frac,
- amr_subframe->p_lag,
- p->pitch_lag_int, subframe,
- mode != MODE_4k75 && mode != MODE_5k15,
- mode <= MODE_6k7 ? 4 : (mode == MODE_7k95 ? 5 : 6));
-
- p->pitch_lag_int = pitch_lag_int; // store previous lag in a uint8_t
-
- pitch_lag_frac <<= (p->cur_frame_mode != MODE_12k2);
-
- pitch_lag_int += pitch_lag_frac > 0;
-
- /* Calculate the pitch vector by interpolating the past excitation at the
- pitch lag using a b60 hamming windowed sinc function. */
- p->acelpf_ctx.acelp_interpolatef(p->excitation,
- p->excitation + 1 - pitch_lag_int,
- ff_b60_sinc, 6,
- pitch_lag_frac + 6 - 6*(pitch_lag_frac > 0),
- 10, AMR_SUBFRAME_SIZE);
-
- memcpy(p->pitch_vector, p->excitation, AMR_SUBFRAME_SIZE * sizeof(float));
-}
-
-/// @}
-
-
-/// @name AMR algebraic code book (fixed) vector decoding functions
-/// @{
-
-/**
- * Decode a 10-bit algebraic codebook index from a 10.2 kbit/s frame.
- */
-static void decode_10bit_pulse(int code, int pulse_position[8],
- int i1, int i2, int i3)
-{
- // coded using 7+3 bits with the 3 LSBs being, individually, the LSB of 1 of
- // the 3 pulses and the upper 7 bits being coded in base 5
- const uint8_t *positions = base_five_table[code >> 3];
- pulse_position[i1] = (positions[2] << 1) + ( code & 1);
- pulse_position[i2] = (positions[1] << 1) + ((code >> 1) & 1);
- pulse_position[i3] = (positions[0] << 1) + ((code >> 2) & 1);
-}
-
-/**
- * Decode the algebraic codebook index to pulse positions and signs and
- * construct the algebraic codebook vector for MODE_10k2.
- *
- * @param fixed_index positions of the eight pulses
- * @param fixed_sparse pointer to the algebraic codebook vector
- */
-static void decode_8_pulses_31bits(const int16_t *fixed_index,
- AMRFixed *fixed_sparse)
-{
- int pulse_position[8];
- int i, temp;
-
- decode_10bit_pulse(fixed_index[4], pulse_position, 0, 4, 1);
- decode_10bit_pulse(fixed_index[5], pulse_position, 2, 6, 5);
-
- // coded using 5+2 bits with the 2 LSBs being, individually, the LSB of 1 of
- // the 2 pulses and the upper 5 bits being coded in base 5
- temp = ((fixed_index[6] >> 2) * 25 + 12) >> 5;
- pulse_position[3] = temp % 5;
- pulse_position[7] = temp / 5;
- if (pulse_position[7] & 1)
- pulse_position[3] = 4 - pulse_position[3];
- pulse_position[3] = (pulse_position[3] << 1) + ( fixed_index[6] & 1);
- pulse_position[7] = (pulse_position[7] << 1) + ((fixed_index[6] >> 1) & 1);
-
- fixed_sparse->n = 8;
- for (i = 0; i < 4; i++) {
- const int pos1 = (pulse_position[i] << 2) + i;
- const int pos2 = (pulse_position[i + 4] << 2) + i;
- const float sign = fixed_index[i] ? -1.0 : 1.0;
- fixed_sparse->x[i ] = pos1;
- fixed_sparse->x[i + 4] = pos2;
- fixed_sparse->y[i ] = sign;
- fixed_sparse->y[i + 4] = pos2 < pos1 ? -sign : sign;
- }
-}
-
-/**
- * Decode the algebraic codebook index to pulse positions and signs,
- * then construct the algebraic codebook vector.
- *
- * nb of pulses | bits encoding pulses
- * For MODE_4k75 or MODE_5k15, 2 | 1-3, 4-6, 7
- * MODE_5k9, 2 | 1, 2-4, 5-6, 7-9
- * MODE_6k7, 3 | 1-3, 4, 5-7, 8, 9-11
- * MODE_7k4 or MODE_7k95, 4 | 1-3, 4-6, 7-9, 10, 11-13
- *
- * @param fixed_sparse pointer to the algebraic codebook vector
- * @param pulses algebraic codebook indexes
- * @param mode mode of the current frame
- * @param subframe current subframe number
- */
-static void decode_fixed_sparse(AMRFixed *fixed_sparse, const uint16_t *pulses,
- const enum Mode mode, const int subframe)
-{
- av_assert1(MODE_4k75 <= (signed)mode && mode <= MODE_12k2);
-
- if (mode == MODE_12k2) {
- ff_decode_10_pulses_35bits(pulses, fixed_sparse, gray_decode, 5, 3);
- } else if (mode == MODE_10k2) {
- decode_8_pulses_31bits(pulses, fixed_sparse);
- } else {
- int *pulse_position = fixed_sparse->x;
- int i, pulse_subset;
- const int fixed_index = pulses[0];
-
- if (mode <= MODE_5k15) {
- pulse_subset = ((fixed_index >> 3) & 8) + (subframe << 1);
- pulse_position[0] = ( fixed_index & 7) * 5 + track_position[pulse_subset];
- pulse_position[1] = ((fixed_index >> 3) & 7) * 5 + track_position[pulse_subset + 1];
- fixed_sparse->n = 2;
- } else if (mode == MODE_5k9) {
- pulse_subset = ((fixed_index & 1) << 1) + 1;
- pulse_position[0] = ((fixed_index >> 1) & 7) * 5 + pulse_subset;
- pulse_subset = (fixed_index >> 4) & 3;
- pulse_position[1] = ((fixed_index >> 6) & 7) * 5 + pulse_subset + (pulse_subset == 3 ? 1 : 0);
- fixed_sparse->n = pulse_position[0] == pulse_position[1] ? 1 : 2;
- } else if (mode == MODE_6k7) {
- pulse_position[0] = (fixed_index & 7) * 5;
- pulse_subset = (fixed_index >> 2) & 2;
- pulse_position[1] = ((fixed_index >> 4) & 7) * 5 + pulse_subset + 1;
- pulse_subset = (fixed_index >> 6) & 2;
- pulse_position[2] = ((fixed_index >> 8) & 7) * 5 + pulse_subset + 2;
- fixed_sparse->n = 3;
- } else { // mode <= MODE_7k95
- pulse_position[0] = gray_decode[ fixed_index & 7];
- pulse_position[1] = gray_decode[(fixed_index >> 3) & 7] + 1;
- pulse_position[2] = gray_decode[(fixed_index >> 6) & 7] + 2;
- pulse_subset = (fixed_index >> 9) & 1;
- pulse_position[3] = gray_decode[(fixed_index >> 10) & 7] + pulse_subset + 3;
- fixed_sparse->n = 4;
- }
- for (i = 0; i < fixed_sparse->n; i++)
- fixed_sparse->y[i] = (pulses[1] >> i) & 1 ? 1.0 : -1.0;
- }
-}
-
-/**
- * Apply pitch lag to obtain the sharpened fixed vector (section 6.1.2)
- *
- * @param p the context
- * @param subframe unpacked amr subframe
- * @param mode mode of the current frame
- * @param fixed_sparse sparse respresentation of the fixed vector
- */
-static void pitch_sharpening(AMRContext *p, int subframe, enum Mode mode,
- AMRFixed *fixed_sparse)
-{
- // The spec suggests the current pitch gain is always used, but in other
- // modes the pitch and codebook gains are joinly quantized (sec 5.8.2)
- // so the codebook gain cannot depend on the quantized pitch gain.
- if (mode == MODE_12k2)
- p->beta = FFMIN(p->pitch_gain[4], 1.0);
-
- fixed_sparse->pitch_lag = p->pitch_lag_int;
- fixed_sparse->pitch_fac = p->beta;
-
- // Save pitch sharpening factor for the next subframe
- // MODE_4k75 only updates on the 2nd and 4th subframes - this follows from
- // the fact that the gains for two subframes are jointly quantized.
- if (mode != MODE_4k75 || subframe & 1)
- p->beta = av_clipf(p->pitch_gain[4], 0.0, SHARP_MAX);
-}
-/// @}
-
-
-/// @name AMR gain decoding functions
-/// @{
-
-/**
- * fixed gain smoothing
- * Note that where the spec specifies the "spectrum in the q domain"
- * in section 6.1.4, in fact frequencies should be used.
- *
- * @param p the context
- * @param lsf LSFs for the current subframe, in the range [0,1]
- * @param lsf_avg averaged LSFs
- * @param mode mode of the current frame
- *
- * @return fixed gain smoothed
- */
-static float fixed_gain_smooth(AMRContext *p , const float *lsf,
- const float *lsf_avg, const enum Mode mode)
-{
- float diff = 0.0;
- int i;
-
- for (i = 0; i < LP_FILTER_ORDER; i++)
- diff += fabs(lsf_avg[i] - lsf[i]) / lsf_avg[i];
-
- // If diff is large for ten subframes, disable smoothing for a 40-subframe
- // hangover period.
- p->diff_count++;
- if (diff <= 0.65)
- p->diff_count = 0;
-
- if (p->diff_count > 10) {
- p->hang_count = 0;
- p->diff_count--; // don't let diff_count overflow
- }
-
- if (p->hang_count < 40) {
- p->hang_count++;
- } else if (mode < MODE_7k4 || mode == MODE_10k2) {
- const float smoothing_factor = av_clipf(4.0 * diff - 1.6, 0.0, 1.0);
- const float fixed_gain_mean = (p->fixed_gain[0] + p->fixed_gain[1] +
- p->fixed_gain[2] + p->fixed_gain[3] +
- p->fixed_gain[4]) * 0.2;
- return smoothing_factor * p->fixed_gain[4] +
- (1.0 - smoothing_factor) * fixed_gain_mean;
- }
- return p->fixed_gain[4];
-}
-
-/**
- * Decode pitch gain and fixed gain factor (part of section 6.1.3).
- *
- * @param p the context
- * @param amr_subframe unpacked amr subframe
- * @param mode mode of the current frame
- * @param subframe current subframe number
- * @param fixed_gain_factor decoded gain correction factor
- */
-static void decode_gains(AMRContext *p, const AMRNBSubframe *amr_subframe,
- const enum Mode mode, const int subframe,
- float *fixed_gain_factor)
-{
- if (mode == MODE_12k2 || mode == MODE_7k95) {
- p->pitch_gain[4] = qua_gain_pit [amr_subframe->p_gain ]
- * (1.0 / 16384.0);
- *fixed_gain_factor = qua_gain_code[amr_subframe->fixed_gain]
- * (1.0 / 2048.0);
- } else {
- const uint16_t *gains;
-
- if (mode >= MODE_6k7) {
- gains = gains_high[amr_subframe->p_gain];
- } else if (mode >= MODE_5k15) {
- gains = gains_low [amr_subframe->p_gain];
- } else {
- // gain index is only coded in subframes 0,2 for MODE_4k75
- gains = gains_MODE_4k75[(p->frame.subframe[subframe & 2].p_gain << 1) + (subframe & 1)];
- }
-
- p->pitch_gain[4] = gains[0] * (1.0 / 16384.0);
- *fixed_gain_factor = gains[1] * (1.0 / 4096.0);
- }
-}
-
-/// @}
-
-
-/// @name AMR preprocessing functions
-/// @{
-
-/**
- * Circularly convolve a sparse fixed vector with a phase dispersion impulse
- * response filter (D.6.2 of G.729 and 6.1.5 of AMR).
- *
- * @param out vector with filter applied
- * @param in source vector
- * @param filter phase filter coefficients
- *
- * out[n] = sum(i,0,len-1){ in[i] * filter[(len + n - i)%len] }
- */
-static void apply_ir_filter(float *out, const AMRFixed *in,
- const float *filter)
-{
- float filter1[AMR_SUBFRAME_SIZE], ///< filters at pitch lag*1 and *2
- filter2[AMR_SUBFRAME_SIZE];
- int lag = in->pitch_lag;
- float fac = in->pitch_fac;
- int i;
-
- if (lag < AMR_SUBFRAME_SIZE) {
- ff_celp_circ_addf(filter1, filter, filter, lag, fac,
- AMR_SUBFRAME_SIZE);
-
- if (lag < AMR_SUBFRAME_SIZE >> 1)
- ff_celp_circ_addf(filter2, filter, filter1, lag, fac,
- AMR_SUBFRAME_SIZE);
- }
-
- memset(out, 0, sizeof(float) * AMR_SUBFRAME_SIZE);
- for (i = 0; i < in->n; i++) {
- int x = in->x[i];
- float y = in->y[i];
- const float *filterp;
-
- if (x >= AMR_SUBFRAME_SIZE - lag) {
- filterp = filter;
- } else if (x >= AMR_SUBFRAME_SIZE - (lag << 1)) {
- filterp = filter1;
- } else
- filterp = filter2;
-
- ff_celp_circ_addf(out, out, filterp, x, y, AMR_SUBFRAME_SIZE);
- }
-}
-
-/**
- * Reduce fixed vector sparseness by smoothing with one of three IR filters.
- * Also know as "adaptive phase dispersion".
- *
- * This implements 3GPP TS 26.090 section 6.1(5).
- *
- * @param p the context
- * @param fixed_sparse algebraic codebook vector
- * @param fixed_vector unfiltered fixed vector
- * @param fixed_gain smoothed gain
- * @param out space for modified vector if necessary
- */
-static const float *anti_sparseness(AMRContext *p, AMRFixed *fixed_sparse,
- const float *fixed_vector,
- float fixed_gain, float *out)
-{
- int ir_filter_nr;
-
- if (p->pitch_gain[4] < 0.6) {
- ir_filter_nr = 0; // strong filtering
- } else if (p->pitch_gain[4] < 0.9) {
- ir_filter_nr = 1; // medium filtering
- } else
- ir_filter_nr = 2; // no filtering
-
- // detect 'onset'
- if (fixed_gain > 2.0 * p->prev_sparse_fixed_gain) {
- p->ir_filter_onset = 2;
- } else if (p->ir_filter_onset)
- p->ir_filter_onset--;
-
- if (!p->ir_filter_onset) {
- int i, count = 0;
-
- for (i = 0; i < 5; i++)
- if (p->pitch_gain[i] < 0.6)
- count++;
- if (count > 2)
- ir_filter_nr = 0;
-
- if (ir_filter_nr > p->prev_ir_filter_nr + 1)
- ir_filter_nr--;
- } else if (ir_filter_nr < 2)
- ir_filter_nr++;
-
- // Disable filtering for very low level of fixed_gain.
- // Note this step is not specified in the technical description but is in
- // the reference source in the function Ph_disp.
- if (fixed_gain < 5.0)
- ir_filter_nr = 2;
-
- if (p->cur_frame_mode != MODE_7k4 && p->cur_frame_mode < MODE_10k2
- && ir_filter_nr < 2) {
- apply_ir_filter(out, fixed_sparse,
- (p->cur_frame_mode == MODE_7k95 ?
- ir_filters_lookup_MODE_7k95 :
- ir_filters_lookup)[ir_filter_nr]);
- fixed_vector = out;
- }
-
- // update ir filter strength history
- p->prev_ir_filter_nr = ir_filter_nr;
- p->prev_sparse_fixed_gain = fixed_gain;
-
- return fixed_vector;
-}
-
-/// @}
-
-
-/// @name AMR synthesis functions
-/// @{
-
-/**
- * Conduct 10th order linear predictive coding synthesis.
- *
- * @param p pointer to the AMRContext
- * @param lpc pointer to the LPC coefficients
- * @param fixed_gain fixed codebook gain for synthesis
- * @param fixed_vector algebraic codebook vector
- * @param samples pointer to the output speech samples
- * @param overflow 16-bit overflow flag
- */
-static int synthesis(AMRContext *p, float *lpc,
- float fixed_gain, const float *fixed_vector,
- float *samples, uint8_t overflow)
-{
- int i;
- float excitation[AMR_SUBFRAME_SIZE];
-
- // if an overflow has been detected, the pitch vector is scaled down by a
- // factor of 4
- if (overflow)
- for (i = 0; i < AMR_SUBFRAME_SIZE; i++)
- p->pitch_vector[i] *= 0.25;
-
- p->acelpv_ctx.weighted_vector_sumf(excitation, p->pitch_vector, fixed_vector,
- p->pitch_gain[4], fixed_gain, AMR_SUBFRAME_SIZE);
-
- // emphasize pitch vector contribution
- if (p->pitch_gain[4] > 0.5 && !overflow) {
- float energy = p->celpm_ctx.dot_productf(excitation, excitation,
- AMR_SUBFRAME_SIZE);
- float pitch_factor =
- p->pitch_gain[4] *
- (p->cur_frame_mode == MODE_12k2 ?
- 0.25 * FFMIN(p->pitch_gain[4], 1.0) :
- 0.5 * FFMIN(p->pitch_gain[4], SHARP_MAX));
-
- for (i = 0; i < AMR_SUBFRAME_SIZE; i++)
- excitation[i] += pitch_factor * p->pitch_vector[i];
-
- ff_scale_vector_to_given_sum_of_squares(excitation, excitation, energy,
- AMR_SUBFRAME_SIZE);
- }
-
- p->celpf_ctx.celp_lp_synthesis_filterf(samples, lpc, excitation,
- AMR_SUBFRAME_SIZE,
- LP_FILTER_ORDER);
-
- // detect overflow
- for (i = 0; i < AMR_SUBFRAME_SIZE; i++)
- if (fabsf(samples[i]) > AMR_SAMPLE_BOUND) {
- return 1;
- }
-
- return 0;
-}
-
-/// @}
-
-
-/// @name AMR update functions
-/// @{
-
-/**
- * Update buffers and history at the end of decoding a subframe.
- *
- * @param p pointer to the AMRContext
- */
-static void update_state(AMRContext *p)
-{
- memcpy(p->prev_lsp_sub4, p->lsp[3], LP_FILTER_ORDER * sizeof(p->lsp[3][0]));
-
- memmove(&p->excitation_buf[0], &p->excitation_buf[AMR_SUBFRAME_SIZE],
- (PITCH_DELAY_MAX + LP_FILTER_ORDER + 1) * sizeof(float));
-
- memmove(&p->pitch_gain[0], &p->pitch_gain[1], 4 * sizeof(float));
- memmove(&p->fixed_gain[0], &p->fixed_gain[1], 4 * sizeof(float));
-
- memmove(&p->samples_in[0], &p->samples_in[AMR_SUBFRAME_SIZE],
- LP_FILTER_ORDER * sizeof(float));
-}
-
-/// @}
-
-
-/// @name AMR Postprocessing functions
-/// @{
-
-/**
- * Get the tilt factor of a formant filter from its transfer function
- *
- * @param p The Context
- * @param lpc_n LP_FILTER_ORDER coefficients of the numerator
- * @param lpc_d LP_FILTER_ORDER coefficients of the denominator
- */
-static float tilt_factor(AMRContext *p, float *lpc_n, float *lpc_d)
-{
- float rh0, rh1; // autocorrelation at lag 0 and 1
-
- // LP_FILTER_ORDER prior zeros are needed for ff_celp_lp_synthesis_filterf
- float impulse_buffer[LP_FILTER_ORDER + AMR_TILT_RESPONSE] = { 0 };
- float *hf = impulse_buffer + LP_FILTER_ORDER; // start of impulse response
-
- hf[0] = 1.0;
- memcpy(hf + 1, lpc_n, sizeof(float) * LP_FILTER_ORDER);
- p->celpf_ctx.celp_lp_synthesis_filterf(hf, lpc_d, hf,
- AMR_TILT_RESPONSE,
- LP_FILTER_ORDER);
-
- rh0 = p->celpm_ctx.dot_productf(hf, hf, AMR_TILT_RESPONSE);
- rh1 = p->celpm_ctx.dot_productf(hf, hf + 1, AMR_TILT_RESPONSE - 1);
-
- // The spec only specifies this check for 12.2 and 10.2 kbit/s
- // modes. But in the ref source the tilt is always non-negative.
- return rh1 >= 0.0 ? rh1 / rh0 * AMR_TILT_GAMMA_T : 0.0;
-}
-
-/**
- * Perform adaptive post-filtering to enhance the quality of the speech.
- * See section 6.2.1.
- *
- * @param p pointer to the AMRContext
- * @param lpc interpolated LP coefficients for this subframe
- * @param buf_out output of the filter
- */
-static void postfilter(AMRContext *p, float *lpc, float *buf_out)
-{
- int i;
- float *samples = p->samples_in + LP_FILTER_ORDER; // Start of input
-
- float speech_gain = p->celpm_ctx.dot_productf(samples, samples,
- AMR_SUBFRAME_SIZE);
-
- float pole_out[AMR_SUBFRAME_SIZE + LP_FILTER_ORDER]; // Output of pole filter
- const float *gamma_n, *gamma_d; // Formant filter factor table
- float lpc_n[LP_FILTER_ORDER], lpc_d[LP_FILTER_ORDER]; // Transfer function coefficients
-
- if (p->cur_frame_mode == MODE_12k2 || p->cur_frame_mode == MODE_10k2) {
- gamma_n = ff_pow_0_7;
- gamma_d = ff_pow_0_75;
- } else {
- gamma_n = ff_pow_0_55;
- gamma_d = ff_pow_0_7;
- }
-
- for (i = 0; i < LP_FILTER_ORDER; i++) {
- lpc_n[i] = lpc[i] * gamma_n[i];
- lpc_d[i] = lpc[i] * gamma_d[i];
- }
-
- memcpy(pole_out, p->postfilter_mem, sizeof(float) * LP_FILTER_ORDER);
- p->celpf_ctx.celp_lp_synthesis_filterf(pole_out + LP_FILTER_ORDER, lpc_d, samples,
- AMR_SUBFRAME_SIZE, LP_FILTER_ORDER);
- memcpy(p->postfilter_mem, pole_out + AMR_SUBFRAME_SIZE,
- sizeof(float) * LP_FILTER_ORDER);
-
- p->celpf_ctx.celp_lp_zero_synthesis_filterf(buf_out, lpc_n,
- pole_out + LP_FILTER_ORDER,
- AMR_SUBFRAME_SIZE, LP_FILTER_ORDER);
-
- ff_tilt_compensation(&p->tilt_mem, tilt_factor(p, lpc_n, lpc_d), buf_out,
- AMR_SUBFRAME_SIZE);
-
- ff_adaptive_gain_control(buf_out, buf_out, speech_gain, AMR_SUBFRAME_SIZE,
- AMR_AGC_ALPHA, &p->postfilter_agc);
-}
-
-/// @}
-
-static int amrnb_decode_frame(AVCodecContext *avctx, void *data,
- int *got_frame_ptr, AVPacket *avpkt)
-{
-
- AMRContext *p = avctx->priv_data; // pointer to private data
- AVFrame *frame = data;
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
- float *buf_out; // pointer to the output data buffer
- int i, subframe, ret;
- float fixed_gain_factor;
- AMRFixed fixed_sparse = {0}; // fixed vector up to anti-sparseness processing
- float spare_vector[AMR_SUBFRAME_SIZE]; // extra stack space to hold result from anti-sparseness processing
- float synth_fixed_gain; // the fixed gain that synthesis should use
- const float *synth_fixed_vector; // pointer to the fixed vector that synthesis should use
-
- /* get output buffer */
- frame->nb_samples = AMR_BLOCK_SIZE;
- if ((ret = ff_get_buffer(avctx, frame)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return ret;
- }
- buf_out = (float *)frame->data[0];
-
- p->cur_frame_mode = unpack_bitstream(p, buf, buf_size);
- if (p->cur_frame_mode == NO_DATA) {
- av_log(avctx, AV_LOG_ERROR, "Corrupt bitstream\n");
- return AVERROR_INVALIDDATA;
- }
- if (p->cur_frame_mode == MODE_DTX) {
- av_log_missing_feature(avctx, "dtx mode", 0);
- av_log(avctx, AV_LOG_INFO, "Note: libopencore_amrnb supports dtx\n");
- return AVERROR_PATCHWELCOME;
- }
-
- if (p->cur_frame_mode == MODE_12k2) {
- lsf2lsp_5(p);
- } else
- lsf2lsp_3(p);
-
- for (i = 0; i < 4; i++)
- ff_acelp_lspd2lpc(p->lsp[i], p->lpc[i], 5);
-
- for (subframe = 0; subframe < 4; subframe++) {
- const AMRNBSubframe *amr_subframe = &p->frame.subframe[subframe];
-
- decode_pitch_vector(p, amr_subframe, subframe);
-
- decode_fixed_sparse(&fixed_sparse, amr_subframe->pulses,
- p->cur_frame_mode, subframe);
-
- // The fixed gain (section 6.1.3) depends on the fixed vector
- // (section 6.1.2), but the fixed vector calculation uses
- // pitch sharpening based on the on the pitch gain (section 6.1.3).
- // So the correct order is: pitch gain, pitch sharpening, fixed gain.
- decode_gains(p, amr_subframe, p->cur_frame_mode, subframe,
- &fixed_gain_factor);
-
- pitch_sharpening(p, subframe, p->cur_frame_mode, &fixed_sparse);
-
- if (fixed_sparse.pitch_lag == 0) {
- av_log(avctx, AV_LOG_ERROR, "The file is corrupted, pitch_lag = 0 is not allowed\n");
- return AVERROR_INVALIDDATA;
- }
- ff_set_fixed_vector(p->fixed_vector, &fixed_sparse, 1.0,
- AMR_SUBFRAME_SIZE);
-
- p->fixed_gain[4] =
- ff_amr_set_fixed_gain(fixed_gain_factor,
- p->celpm_ctx.dot_productf(p->fixed_vector,
- p->fixed_vector,
- AMR_SUBFRAME_SIZE) /
- AMR_SUBFRAME_SIZE,
- p->prediction_error,
- energy_mean[p->cur_frame_mode], energy_pred_fac);
-
- // The excitation feedback is calculated without any processing such
- // as fixed gain smoothing. This isn't mentioned in the specification.
- for (i = 0; i < AMR_SUBFRAME_SIZE; i++)
- p->excitation[i] *= p->pitch_gain[4];
- ff_set_fixed_vector(p->excitation, &fixed_sparse, p->fixed_gain[4],
- AMR_SUBFRAME_SIZE);
-
- // In the ref decoder, excitation is stored with no fractional bits.
- // This step prevents buzz in silent periods. The ref encoder can
- // emit long sequences with pitch factor greater than one. This
- // creates unwanted feedback if the excitation vector is nonzero.
- // (e.g. test sequence T19_795.COD in 3GPP TS 26.074)
- for (i = 0; i < AMR_SUBFRAME_SIZE; i++)
- p->excitation[i] = truncf(p->excitation[i]);
-
- // Smooth fixed gain.
- // The specification is ambiguous, but in the reference source, the
- // smoothed value is NOT fed back into later fixed gain smoothing.
- synth_fixed_gain = fixed_gain_smooth(p, p->lsf_q[subframe],
- p->lsf_avg, p->cur_frame_mode);
-
- synth_fixed_vector = anti_sparseness(p, &fixed_sparse, p->fixed_vector,
- synth_fixed_gain, spare_vector);
-
- if (synthesis(p, p->lpc[subframe], synth_fixed_gain,
- synth_fixed_vector, &p->samples_in[LP_FILTER_ORDER], 0))
- // overflow detected -> rerun synthesis scaling pitch vector down
- // by a factor of 4, skipping pitch vector contribution emphasis
- // and adaptive gain control
- synthesis(p, p->lpc[subframe], synth_fixed_gain,
- synth_fixed_vector, &p->samples_in[LP_FILTER_ORDER], 1);
-
- postfilter(p, p->lpc[subframe], buf_out + subframe * AMR_SUBFRAME_SIZE);
-
- // update buffers and history
- ff_clear_fixed_vector(p->fixed_vector, &fixed_sparse, AMR_SUBFRAME_SIZE);
- update_state(p);
- }
-
- p->acelpf_ctx.acelp_apply_order_2_transfer_function(buf_out,
- buf_out, highpass_zeros,
- highpass_poles,
- highpass_gain * AMR_SAMPLE_SCALE,
- p->high_pass_mem, AMR_BLOCK_SIZE);
-
- /* Update averaged lsf vector (used for fixed gain smoothing).
- *
- * Note that lsf_avg should not incorporate the current frame's LSFs
- * for fixed_gain_smooth.
- * The specification has an incorrect formula: the reference decoder uses
- * qbar(n-1) rather than qbar(n) in section 6.1(4) equation 71. */
- p->acelpv_ctx.weighted_vector_sumf(p->lsf_avg, p->lsf_avg, p->lsf_q[3],
- 0.84, 0.16, LP_FILTER_ORDER);
-
- *got_frame_ptr = 1;
-
- /* return the amount of bytes consumed if everything was OK */
- return frame_sizes_nb[p->cur_frame_mode] + 1; // +7 for rounding and +8 for TOC
-}
-
-
-AVCodec ff_amrnb_decoder = {
- .name = "amrnb",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_AMR_NB,
- .priv_data_size = sizeof(AMRContext),
- .init = amrnb_decode_init,
- .decode = amrnb_decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("AMR-NB (Adaptive Multi-Rate NarrowBand)"),
- .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLT,
- AV_SAMPLE_FMT_NONE },
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/amrwbdata.h b/src/thirdparty/ffmpeg/libavcodec/amrwbdata.h
deleted file mode 100644
index ac8ccf452..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/amrwbdata.h
+++ /dev/null
@@ -1,1890 +0,0 @@
-/*
- * AMR wideband data and definitions
- * Copyright (c) 2010 Marcelo Galvao Povoa
- *
- * 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
- * AMR wideband data and definitions
- */
-
-#ifndef AVCODEC_AMRWBDATA_H
-#define AVCODEC_AMRWBDATA_H
-
-#include <stdint.h>
-#include <stddef.h>
-
-#define LP_ORDER 16 ///< linear predictive coding filter order
-#define LP_ORDER_16k 20 ///< lpc filter order at 16kHz
-#define HB_FIR_SIZE 30 ///< amount of past data needed by HB filters
-#define UPS_FIR_SIZE 12 ///< upsampling filter size
-#define UPS_MEM_SIZE (2 * UPS_FIR_SIZE)
-
-#define MIN_ISF_SPACING (128.0 / 32768.0) ///< minimum isf gap
-#define PRED_FACTOR (1.0 / 3.0)
-#define MIN_ENERGY -14.0 ///< initial innnovation energy (dB)
-#define ENERGY_MEAN 30.0 ///< mean innovation energy (dB) in all modes
-#define PREEMPH_FAC 0.68 ///< factor used to de-emphasize synthesis
-
-#define AMRWB_SFR_SIZE 64 ///< samples per subframe at 12.8 kHz
-#define AMRWB_SFR_SIZE_16k 80 ///< samples per subframe at 16 kHz
-#define AMRWB_P_DELAY_MAX 231 ///< maximum pitch delay value
-#define AMRWB_P_DELAY_MIN 34
-
-/* Relative mode ordering is sensitive */
-enum Mode {
- MODE_6k60 = 0, ///< 6.60 kbit/s
- MODE_8k85, ///< 8.85 kbit/s
- MODE_12k65, ///< 12.65 kbit/s
- MODE_14k25, ///< 14.25 kbit/s
- MODE_15k85, ///< 15.85 kbit/s
- MODE_18k25, ///< 18.25 kbit/s
- MODE_19k85, ///< 19.85 kbit/s
- MODE_23k05, ///< 23.05 kbit/s
- MODE_23k85, ///< 23.85 kbit/s
- MODE_SID, ///< comfort noise frame
- /* 10-13: Future use */
- SP_LOST = 14, ///< speech lost
- NO_DATA ///< no transmission
-};
-
-/* All decoded parameters in these structs must be 2 bytes long
- * because of the direct indexing at the frame parsing */
-typedef struct AMRWBSubFrame {
- uint16_t adap; ///< adaptive codebook index
- uint16_t ltp; ///< ltp-filtering flag
- uint16_t vq_gain; ///< VQ adaptive and innovative gains
- uint16_t hb_gain; ///< high-band energy index (mode 23k85 only)
- uint16_t pul_ih[4]; ///< MSBs part of codebook index (high modes only)
- uint16_t pul_il[4]; ///< LSBs part of codebook index
-} AMRWBSubFrame;
-
-typedef struct AMRWBFrame {
- uint16_t vad; ///< voice activity detection flag
- uint16_t isp_id[7]; ///< index of ISP subvectors
- AMRWBSubFrame subframe[4]; ///< data for subframes
-} AMRWBFrame;
-
-/** The index of a frame parameter */
-#define AMR_BIT(field) (offsetof(AMRWBFrame, field))
-/** The index of a subframe-specific parameter */
-#define AMR_OF(frame_num, variable) AMR_BIT(subframe[frame_num].variable)
-
-//As defined in 3GPP TS 26.201 V9.0.0
-//Tables for bit parsing in Core Frame speech frames
-//The reordered bits are in order of decreasing importance and
-//may be contiguously separated in Class A, B and C bits.
-
-// Each field in AMRWBFrame is stored as:
-// * one byte for the number of bits in the field
-// * one byte for the field index
-// * then, one byte for each bit of the field (from most-significant to least)
-// of the position of that bit in the AMR frame.
-static const uint16_t order_MODE_6k60[] = {
- 1, AMR_BIT(vad), 7,
- 8, AMR_BIT(isp_id[0]), 24, 33, 39, 12, 6, 5, 4, 13,
- 8, AMR_BIT(isp_id[1]), 65, 79, 64, 78, 51, 61, 71, 70,
- 7, AMR_BIT(isp_id[2]), 52, 55, 44, 54, 53, 43, 42,
- 7, AMR_BIT(isp_id[3]), 60, 59, 58, 57, 56, 75, 74,
- 6, AMR_BIT(isp_id[4]), 73, 72, 86, 87, 85, 84,
- 8, AMR_OF(0, adap), 11, 10, 9, 8, 28, 27, 49, 69,
- 6, AMR_OF(0, pul_il[0]), 83, 91, 99, 107, 115, 123,
- 6, AMR_OF(0, pul_il[1]), 82, 103, 111, 119, 127, 135,
- 6, AMR_OF(0, vq_gain), 38, 23, 34, 19, 3, 15,
- 5, AMR_OF(1, adap), 32, 41, 63, 67, 77,
- 6, AMR_OF(1, pul_il[0]), 81, 90, 98, 106, 114, 122,
- 6, AMR_OF(1, pul_il[1]), 80, 102, 110, 118, 126, 134,
- 6, AMR_OF(1, vq_gain), 26, 22, 36, 18, 2, 14,
- 5, AMR_OF(2, adap), 45, 40, 50, 48, 68,
- 6, AMR_OF(2, pul_il[0]), 95, 89, 97, 105, 113, 121,
- 6, AMR_OF(2, pul_il[1]), 94, 101, 109, 117, 125, 133,
- 6, AMR_OF(2, vq_gain), 37, 21, 35, 17, 1, 31,
- 5, AMR_OF(3, adap), 47, 46, 62, 66, 76,
- 6, AMR_OF(3, pul_il[0]), 93, 88, 96, 104, 112, 120,
- 6, AMR_OF(3, pul_il[1]), 92, 100, 108, 116, 124, 132,
- 6, AMR_OF(3, vq_gain), 25, 20, 29, 16, 0, 30,
- 0
-};
-
-static const uint16_t order_MODE_8k85[] = {
- 1, AMR_BIT(vad), 7,
- 8, AMR_BIT(isp_id[0]), 47, 32, 2, 6, 3, 5, 4, 60,
- 8, AMR_BIT(isp_id[1]), 69, 50, 67, 41, 51, 49, 59, 53,
- 6, AMR_BIT(isp_id[2]), 40, 55, 43, 54, 42, 62,
- 7, AMR_BIT(isp_id[3]), 63, 48, 52, 61, 77, 78, 72,
- 7, AMR_BIT(isp_id[4]), 85, 56, 86, 68, 74, 73, 81,
- 5, AMR_BIT(isp_id[5]), 82, 95, 80, 94, 91,
- 5, AMR_BIT(isp_id[6]), 90, 89, 88, 103, 87,
- 8, AMR_OF(0, adap), 1, 0, 15, 35, 33, 58, 64, 84,
- 5, AMR_OF(0, pul_il[0]), 102, 118, 134, 150, 166,
- 5, AMR_OF(0, pul_il[1]), 101, 114, 130, 146, 162,
- 5, AMR_OF(0, pul_il[2]), 100, 126, 142, 158, 174,
- 5, AMR_OF(0, pul_il[3]), 99, 122, 138, 154, 170,
- 6, AMR_OF(0, vq_gain), 11, 39, 19, 31, 27, 23,
- 5, AMR_OF(1, adap), 46, 71, 66, 76, 93,
- 5, AMR_OF(1, pul_il[0]), 98, 117, 133, 149, 165,
- 5, AMR_OF(1, pul_il[1]), 97, 113, 129, 145, 161,
- 5, AMR_OF(1, pul_il[2]), 96, 125, 141, 157, 173,
- 5, AMR_OF(1, pul_il[3]), 111, 121, 137, 153, 169,
- 6, AMR_OF(1, vq_gain), 10, 38, 18, 30, 26, 22,
- 8, AMR_OF(2, adap), 14, 13, 12, 34, 45, 57, 79, 83,
- 5, AMR_OF(2, pul_il[0]), 110, 116, 132, 148, 164,
- 5, AMR_OF(2, pul_il[1]), 109, 112, 128, 144, 160,
- 5, AMR_OF(2, pul_il[2]), 108, 124, 140, 156, 172,
- 5, AMR_OF(2, pul_il[3]), 107, 120, 136, 152, 168,
- 6, AMR_OF(2, vq_gain), 9, 37, 17, 29, 25, 21,
- 5, AMR_OF(3, adap), 44, 70, 65, 75, 92,
- 5, AMR_OF(3, pul_il[0]), 106, 115, 131, 147, 163,
- 5, AMR_OF(3, pul_il[1]), 105, 127, 143, 159, 175,
- 5, AMR_OF(3, pul_il[2]), 104, 123, 139, 155, 171,
- 5, AMR_OF(3, pul_il[3]), 119, 135, 151, 167, 183,
- 6, AMR_OF(3, vq_gain), 8, 36, 16, 28, 24, 20,
- 0
-};
-
-static const uint16_t order_MODE_12k65[] = {
- 1, AMR_BIT(vad), 7,
- 8, AMR_BIT(isp_id[0]), 55, 40, 14, 6, 15, 5, 0, 68,
- 8, AMR_BIT(isp_id[1]), 77, 58, 75, 49, 59, 57, 67, 61,
- 6, AMR_BIT(isp_id[2]), 48, 63, 51, 62, 50, 70,
- 7, AMR_BIT(isp_id[3]), 71, 56, 60, 69, 85, 86, 80,
- 7, AMR_BIT(isp_id[4]), 93, 64, 94, 76, 82, 81, 89,
- 5, AMR_BIT(isp_id[5]), 90, 103, 88, 102, 99,
- 5, AMR_BIT(isp_id[6]), 98, 97, 96, 111, 95,
- 9, AMR_OF(0, adap), 13, 12, 11, 10, 9, 41, 66, 72,
- 92,
- 1, AMR_OF(0, ltp), 110,
- 9, AMR_OF(0, pul_il[0]), 106, 122, 154, 186, 218, 134, 166, 198,
- 230,
- 9, AMR_OF(0, pul_il[1]), 105, 130, 162, 194, 226, 142, 174, 206,
- 238,
- 9, AMR_OF(0, pul_il[2]), 104, 138, 170, 202, 234, 150, 182, 214,
- 246,
- 9, AMR_OF(0, pul_il[3]), 119, 146, 178, 210, 242, 158, 190, 222,
- 254,
- 7, AMR_OF(0, vq_gain), 4, 19, 45, 27, 39, 33, 31,
- 6, AMR_OF(1, adap), 35, 54, 79, 74, 84, 101,
- 1, AMR_OF(1, ltp), 109,
- 9, AMR_OF(1, pul_il[0]), 118, 121, 153, 185, 217, 133, 165, 197,
- 229,
- 9, AMR_OF(1, pul_il[1]), 117, 129, 161, 193, 225, 141, 173, 205,
- 237,
- 9, AMR_OF(1, pul_il[2]), 116, 137, 169, 201, 233, 149, 181, 213,
- 245,
- 9, AMR_OF(1, pul_il[3]), 115, 145, 177, 209, 241, 157, 189, 221,
- 253,
- 7, AMR_OF(1, vq_gain), 3, 18, 44, 26, 38, 32, 30,
- 9, AMR_OF(2, adap), 8, 23, 22, 21, 20, 52, 65, 87,
- 91,
- 1, AMR_OF(2, ltp), 108,
- 9, AMR_OF(2, pul_il[0]), 114, 120, 152, 184, 216, 132, 164, 196,
- 228,
- 9, AMR_OF(2, pul_il[1]), 113, 128, 160, 192, 224, 140, 172, 204,
- 236,
- 9, AMR_OF(2, pul_il[2]), 112, 136, 168, 200, 232, 148, 180, 212,
- 244,
- 9, AMR_OF(2, pul_il[3]), 127, 144, 176, 208, 240, 156, 188, 220,
- 252,
- 7, AMR_OF(2, vq_gain), 2, 17, 43, 25, 37, 47, 29,
- 6, AMR_OF(3, adap), 34, 53, 78, 73, 83, 100,
- 1, AMR_OF(3, ltp), 107,
- 9, AMR_OF(3, pul_il[0]), 126, 135, 167, 199, 231, 131, 163, 195,
- 227,
- 9, AMR_OF(3, pul_il[1]), 125, 143, 175, 207, 239, 139, 171, 203,
- 235,
- 9, AMR_OF(3, pul_il[2]), 124, 151, 183, 215, 247, 147, 179, 211,
- 243,
- 9, AMR_OF(3, pul_il[3]), 123, 159, 191, 223, 255, 155, 187, 219,
- 251,
- 7, AMR_OF(3, vq_gain), 1, 16, 42, 24, 36, 46, 28,
- 0
-};
-
-static const uint16_t order_MODE_14k25[] = {
- 1, AMR_BIT(vad), 7,
- 8, AMR_BIT(isp_id[0]), 55, 40, 14, 6, 15, 5, 0, 68,
- 8, AMR_BIT(isp_id[1]), 77, 58, 75, 49, 59, 57, 67, 61,
- 6, AMR_BIT(isp_id[2]), 48, 63, 51, 62, 50, 70,
- 7, AMR_BIT(isp_id[3]), 71, 56, 60, 69, 85, 86, 80,
- 7, AMR_BIT(isp_id[4]), 93, 64, 94, 76, 82, 81, 89,
- 5, AMR_BIT(isp_id[5]), 90, 103, 88, 102, 99,
- 5, AMR_BIT(isp_id[6]), 98, 97, 96, 111, 95,
- 9, AMR_OF(0, adap), 13, 12, 11, 10, 9, 41, 66, 72,
- 92,
- 1, AMR_OF(0, ltp), 110,
- 13, AMR_OF(0, pul_il[0]), 114, 186, 210, 234, 258, 106, 126, 162,
- 170, 198, 222, 246, 270,
- 13, AMR_OF(0, pul_il[1]), 122, 194, 218, 242, 266, 118, 134, 174,
- 182, 206, 230, 254, 278,
- 9, AMR_OF(0, pul_il[2]), 130, 138, 146, 154, 178, 202, 226, 250,
- 274,
- 9, AMR_OF(0, pul_il[3]), 142, 150, 158, 166, 190, 214, 238, 262,
- 286,
- 7, AMR_OF(0, vq_gain), 4, 19, 45, 27, 39, 33, 31,
- 6, AMR_OF(1, adap), 35, 54, 79, 74, 84, 101,
- 1, AMR_OF(1, ltp), 109,
- 13, AMR_OF(1, pul_il[0]), 113, 185, 209, 233, 257, 105, 125, 161,
- 169, 197, 221, 245, 269,
- 13, AMR_OF(1, pul_il[1]), 121, 193, 217, 241, 265, 117, 133, 173,
- 181, 205, 229, 253, 277,
- 9, AMR_OF(1, pul_il[2]), 129, 137, 145, 153, 177, 201, 225, 249,
- 273,
- 9, AMR_OF(1, pul_il[3]), 141, 149, 157, 165, 189, 213, 237, 261,
- 285,
- 7, AMR_OF(1, vq_gain), 3, 18, 44, 26, 38, 32, 30,
- 9, AMR_OF(2, adap), 8, 23, 22, 21, 20, 52, 65, 87,
- 91,
- 1, AMR_OF(2, ltp), 108,
- 13, AMR_OF(2, pul_il[0]), 112, 184, 208, 232, 256, 104, 124, 160,
- 168, 196, 220, 244, 268,
- 13, AMR_OF(2, pul_il[1]), 120, 192, 216, 240, 264, 116, 132, 172,
- 180, 204, 228, 252, 276,
- 9, AMR_OF(2, pul_il[2]), 128, 136, 144, 152, 176, 200, 224, 248,
- 272,
- 9, AMR_OF(2, pul_il[3]), 140, 148, 156, 164, 188, 212, 236, 260,
- 284,
- 7, AMR_OF(2, vq_gain), 2, 17, 43, 25, 37, 47, 29,
- 6, AMR_OF(3, adap), 34, 53, 78, 73, 83, 100,
- 1, AMR_OF(3, ltp), 107,
- 13, AMR_OF(3, pul_il[0]), 127, 199, 223, 247, 271, 119, 123, 175,
- 183, 195, 219, 243, 267,
- 13, AMR_OF(3, pul_il[1]), 135, 207, 231, 255, 279, 115, 131, 171,
- 179, 203, 227, 251, 275,
- 9, AMR_OF(3, pul_il[2]), 143, 151, 159, 167, 191, 215, 239, 263,
- 287,
- 9, AMR_OF(3, pul_il[3]), 139, 147, 155, 163, 187, 211, 235, 259,
- 283,
- 7, AMR_OF(3, vq_gain), 1, 16, 42, 24, 36, 46, 28,
- 0
-};
-
-static const uint16_t order_MODE_15k85[] = {
- 1, AMR_BIT(vad), 7,
- 8, AMR_BIT(isp_id[0]), 55, 40, 14, 6, 15, 5, 0, 68,
- 8, AMR_BIT(isp_id[1]), 77, 58, 75, 49, 59, 57, 67, 61,
- 6, AMR_BIT(isp_id[2]), 48, 63, 51, 62, 50, 70,
- 7, AMR_BIT(isp_id[3]), 71, 56, 60, 69, 85, 86, 80,
- 7, AMR_BIT(isp_id[4]), 93, 64, 94, 76, 82, 81, 89,
- 5, AMR_BIT(isp_id[5]), 90, 103, 88, 102, 99,
- 5, AMR_BIT(isp_id[6]), 98, 97, 96, 111, 95,
- 9, AMR_OF(0, adap), 13, 12, 11, 10, 9, 41, 66, 72,
- 92,
- 1, AMR_OF(0, ltp), 110,
- 13, AMR_OF(0, pul_il[0]), 122, 154, 170, 218, 266, 138, 106, 182,
- 230, 278, 178, 226, 274,
- 13, AMR_OF(0, pul_il[1]), 134, 166, 190, 238, 286, 150, 118, 186,
- 234, 282, 198, 246, 294,
- 13, AMR_OF(0, pul_il[2]), 130, 162, 194, 242, 290, 146, 114, 206,
- 254, 302, 202, 250, 298,
- 13, AMR_OF(0, pul_il[3]), 142, 174, 214, 262, 310, 158, 126, 210,
- 258, 306, 222, 270, 318,
- 7, AMR_OF(0, vq_gain), 4, 19, 45, 27, 39, 33, 31,
- 6, AMR_OF(1, adap), 35, 54, 79, 74, 84, 101,
- 1, AMR_OF(1, ltp), 109,
- 13, AMR_OF(1, pul_il[0]), 121, 153, 169, 217, 265, 137, 105, 181,
- 229, 277, 177, 225, 273,
- 13, AMR_OF(1, pul_il[1]), 133, 165, 189, 237, 285, 149, 117, 185,
- 233, 281, 197, 245, 293,
- 13, AMR_OF(1, pul_il[2]), 129, 161, 193, 241, 289, 145, 113, 205,
- 253, 301, 201, 249, 297,
- 13, AMR_OF(1, pul_il[3]), 141, 173, 213, 261, 309, 157, 125, 209,
- 257, 305, 221, 269, 317,
- 7, AMR_OF(1, vq_gain), 3, 18, 44, 26, 38, 32, 30,
- 9, AMR_OF(2, adap), 8, 23, 22, 21, 20, 52, 65, 87,
- 91,
- 1, AMR_OF(2, ltp), 108,
- 13, AMR_OF(2, pul_il[0]), 120, 152, 168, 216, 264, 136, 104, 180,
- 228, 276, 176, 224, 272,
- 13, AMR_OF(2, pul_il[1]), 132, 164, 188, 236, 284, 148, 116, 184,
- 232, 280, 196, 244, 292,
- 13, AMR_OF(2, pul_il[2]), 128, 160, 192, 240, 288, 144, 112, 204,
- 252, 300, 200, 248, 296,
- 13, AMR_OF(2, pul_il[3]), 140, 172, 212, 260, 308, 156, 124, 208,
- 256, 304, 220, 268, 316,
- 7, AMR_OF(2, vq_gain), 2, 17, 43, 25, 37, 47, 29,
- 6, AMR_OF(3, adap), 34, 53, 78, 73, 83, 100,
- 1, AMR_OF(3, ltp), 107,
- 13, AMR_OF(3, pul_il[0]), 135, 167, 183, 231, 279, 151, 119, 179,
- 227, 275, 191, 239, 287,
- 13, AMR_OF(3, pul_il[1]), 131, 163, 187, 235, 283, 147, 115, 199,
- 247, 295, 195, 243, 291,
- 13, AMR_OF(3, pul_il[2]), 143, 175, 207, 255, 303, 159, 127, 203,
- 251, 299, 215, 263, 311,
- 13, AMR_OF(3, pul_il[3]), 139, 171, 211, 259, 307, 155, 123, 223,
- 271, 319, 219, 267, 315,
- 7, AMR_OF(3, vq_gain), 1, 16, 42, 24, 36, 46, 28,
- 0
-};
-
-static const uint16_t order_MODE_18k25[] = {
- 1, AMR_BIT(vad), 7,
- 8, AMR_BIT(isp_id[0]), 55, 40, 14, 6, 15, 5, 0, 68,
- 8, AMR_BIT(isp_id[1]), 77, 58, 75, 49, 59, 57, 67, 61,
- 6, AMR_BIT(isp_id[2]), 48, 63, 51, 62, 50, 70,
- 7, AMR_BIT(isp_id[3]), 71, 56, 60, 69, 85, 86, 80,
- 7, AMR_BIT(isp_id[4]), 93, 64, 94, 76, 82, 81, 89,
- 5, AMR_BIT(isp_id[5]), 90, 103, 88, 102, 99,
- 5, AMR_BIT(isp_id[6]), 98, 97, 96, 111, 95,
- 9, AMR_OF(0, adap), 13, 12, 11, 10, 9, 41, 66, 72,
- 92,
- 1, AMR_OF(0, ltp), 110,
- 2, AMR_OF(0, pul_ih[0]), 124, 115,
- 2, AMR_OF(0, pul_ih[1]), 150, 117,
- 2, AMR_OF(0, pul_ih[2]), 129, 114,
- 2, AMR_OF(0, pul_ih[3]), 121, 131,
- 14, AMR_OF(0, pul_il[0]), 161, 257, 343, 199, 177, 303, 204, 173,
- 168, 260, 277, 307, 338, 128,
- 14, AMR_OF(0, pul_il[1]), 194, 286, 347, 222, 214, 316, 236, 152,
- 166, 242, 284, 308, 344, 142,
- 14, AMR_OF(0, pul_il[2]), 169, 273, 353, 202, 189, 311, 240, 200,
- 171, 261, 309, 296, 345, 130,
- 14, AMR_OF(0, pul_il[3]), 198, 275, 349, 187, 163, 282, 193, 195,
- 175, 234, 265, 289, 328, 119,
- 7, AMR_OF(0, vq_gain), 4, 19, 45, 27, 39, 33, 31,
- 6, AMR_OF(1, adap), 35, 54, 79, 74, 84, 101,
- 1, AMR_OF(1, ltp), 109,
- 2, AMR_OF(1, pul_ih[0]), 139, 104,
- 2, AMR_OF(1, pul_ih[1]), 135, 118,
- 2, AMR_OF(1, pul_ih[2]), 112, 127,
- 2, AMR_OF(1, pul_ih[3]), 140, 141,
- 14, AMR_OF(1, pul_il[0]), 179, 276, 340, 225, 223, 321, 235, 190,
- 182, 271, 310, 315, 352, 125,
- 14, AMR_OF(1, pul_il[1]), 153, 264, 329, 232, 209, 323, 231, 165,
- 191, 279, 290, 312, 367, 134,
- 14, AMR_OF(1, pul_il[2]), 167, 269, 341, 205, 197, 298, 224, 160,
- 170, 259, 280, 317, 357, 148,
- 14, AMR_OF(1, pul_il[3]), 203, 272, 342, 227, 192, 299, 233, 172,
- 183, 256, 283, 326, 355, 106,
- 7, AMR_OF(1, vq_gain), 3, 18, 44, 26, 38, 32, 30,
- 9, AMR_OF(2, adap), 8, 23, 22, 21, 20, 52, 65, 87,
- 91,
- 1, AMR_OF(2, ltp), 108,
- 2, AMR_OF(2, pul_ih[0]), 144, 120,
- 2, AMR_OF(2, pul_ih[1]), 157, 123,
- 2, AMR_OF(2, pul_ih[2]), 145, 138,
- 2, AMR_OF(2, pul_ih[3]), 132, 154,
- 14, AMR_OF(2, pul_il[0]), 241, 319, 365, 252, 253, 331, 254, 230,
- 220, 263, 285, 314, 364, 156,
- 14, AMR_OF(2, pul_il[1]), 247, 291, 339, 249, 250, 332, 267, 196,
- 207, 268, 304, 324, 356, 158,
- 14, AMR_OF(2, pul_il[2]), 210, 300, 348, 243, 237, 333, 246, 206,
- 219, 266, 318, 335, 363, 159,
- 14, AMR_OF(2, pul_il[3]), 239, 306, 366, 221, 226, 297, 251, 184,
- 178, 258, 292, 305, 346, 116,
- 7, AMR_OF(2, vq_gain), 2, 17, 43, 25, 37, 47, 29,
- 6, AMR_OF(3, adap), 34, 53, 78, 73, 83, 100,
- 1, AMR_OF(3, ltp), 107,
- 2, AMR_OF(3, pul_ih[0]), 143, 126,
- 2, AMR_OF(3, pul_ih[1]), 137, 122,
- 2, AMR_OF(3, pul_ih[2]), 149, 105,
- 2, AMR_OF(3, pul_ih[3]), 133, 136,
- 14, AMR_OF(3, pul_il[0]), 162, 287, 337, 244, 229, 322, 218, 180,
- 186, 262, 274, 288, 351, 146,
- 14, AMR_OF(3, pul_il[1]), 212, 294, 358, 248, 228, 334, 215, 174,
- 176, 270, 293, 301, 354, 147,
- 14, AMR_OF(3, pul_il[2]), 185, 327, 336, 211, 213, 313, 245, 181,
- 188, 255, 281, 325, 350, 151,
- 14, AMR_OF(3, pul_il[3]), 201, 295, 359, 216, 208, 320, 238, 164,
- 155, 217, 278, 302, 330, 113,
- 7, AMR_OF(3, vq_gain), 1, 16, 42, 24, 36, 46, 28,
- 0
-};
-
-static const uint16_t order_MODE_19k85[] = {
- 1, AMR_BIT(vad), 7,
- 8, AMR_BIT(isp_id[0]), 55, 40, 14, 6, 15, 5, 0, 68,
- 8, AMR_BIT(isp_id[1]), 77, 58, 75, 49, 59, 57, 67, 61,
- 6, AMR_BIT(isp_id[2]), 48, 63, 51, 62, 50, 70,
- 7, AMR_BIT(isp_id[3]), 71, 56, 60, 69, 85, 86, 80,
- 7, AMR_BIT(isp_id[4]), 93, 64, 94, 76, 82, 81, 89,
- 5, AMR_BIT(isp_id[5]), 90, 103, 88, 102, 99,
- 5, AMR_BIT(isp_id[6]), 98, 97, 96, 111, 95,
- 9, AMR_OF(0, adap), 13, 12, 11, 10, 9, 41, 66, 72,
- 92,
- 1, AMR_OF(0, ltp), 110,
- 10, AMR_OF(0, pul_ih[0]), 134, 153, 263, 342, 399, 154, 106, 177,
- 317, 265,
- 10, AMR_OF(0, pul_ih[1]), 128, 167, 270, 351, 385, 160, 105, 213,
- 329, 259,
- 2, AMR_OF(0, pul_ih[2]), 123, 147,
- 2, AMR_OF(0, pul_ih[3]), 131, 143,
- 10, AMR_OF(0, pul_il[0]), 346, 118, 170, 201, 296, 368, 250, 284,
- 341, 391,
- 10, AMR_OF(0, pul_il[1]), 345, 104, 166, 196, 281, 374, 242, 269,
- 327, 390,
- 14, AMR_OF(0, pul_il[2]), 141, 171, 291, 364, 229, 210, 308, 228,
- 206, 200, 258, 295, 313, 361,
- 14, AMR_OF(0, pul_il[3]), 144, 188, 282, 366, 217, 216, 309, 218,
- 193, 182, 245, 287, 300, 367,
- 7, AMR_OF(0, vq_gain), 4, 19, 45, 27, 39, 33, 31,
- 6, AMR_OF(1, adap), 35, 54, 79, 74, 84, 101,
- 1, AMR_OF(1, ltp), 109,
- 10, AMR_OF(1, pul_ih[0]), 139, 169, 267, 348, 389, 163, 116, 189,
- 343, 268,
- 10, AMR_OF(1, pul_ih[1]), 120, 161, 249, 339, 397, 152, 114, 230,
- 334, 303,
- 2, AMR_OF(1, pul_ih[2]), 125, 138,
- 2, AMR_OF(1, pul_ih[3]), 112, 129,
- 10, AMR_OF(1, pul_il[0]), 349, 122, 162, 203, 288, 372, 278, 274,
- 312, 377,
- 10, AMR_OF(1, pul_il[1]), 357, 126, 165, 214, 298, 362, 252, 260,
- 321, 378,
- 14, AMR_OF(1, pul_il[2]), 150, 199, 266, 355, 211, 180, 285, 241,
- 195, 198, 243, 275, 323, 375,
- 14, AMR_OF(1, pul_il[3]), 142, 191, 256, 353, 208, 220, 314, 237,
- 190, 212, 255, 304, 318, 371,
- 7, AMR_OF(1, vq_gain), 3, 18, 44, 26, 38, 32, 30,
- 9, AMR_OF(2, adap), 8, 23, 22, 21, 20, 52, 65, 87,
- 91,
- 1, AMR_OF(2, ltp), 108,
- 10, AMR_OF(2, pul_ih[0]), 159, 168, 302, 356, 395, 178, 132, 185,
- 330, 286,
- 10, AMR_OF(2, pul_ih[1]), 158, 181, 292, 358, 396, 176, 133, 235,
- 331, 276,
- 2, AMR_OF(2, pul_ih[2]), 130, 157,
- 2, AMR_OF(2, pul_ih[3]), 124, 136,
- 10, AMR_OF(2, pul_il[0]), 354, 121, 194, 246, 322, 379, 272, 273,
- 332, 398,
- 10, AMR_OF(2, pul_il[1]), 359, 140, 186, 236, 333, 376, 290, 301,
- 338, 387,
- 14, AMR_OF(2, pul_il[2]), 155, 227, 319, 369, 253, 254, 350, 248,
- 224, 239, 240, 293, 315, 383,
- 14, AMR_OF(2, pul_il[3]), 156, 209, 297, 373, 225, 215, 326, 247,
- 197, 184, 232, 289, 310, 365,
- 7, AMR_OF(2, vq_gain), 2, 17, 43, 25, 37, 47, 29,
- 6, AMR_OF(3, adap), 34, 53, 78, 73, 83, 100,
- 1, AMR_OF(3, ltp), 107,
- 10, AMR_OF(3, pul_ih[0]), 148, 164, 264, 340, 388, 183, 117, 205,
- 336, 261,
- 10, AMR_OF(3, pul_ih[1]), 146, 174, 257, 335, 384, 173, 113, 187,
- 320, 279,
- 2, AMR_OF(3, pul_ih[2]), 127, 151,
- 2, AMR_OF(3, pul_ih[3]), 119, 137,
- 10, AMR_OF(3, pul_il[0]), 352, 135, 172, 238, 306, 381, 262, 271,
- 328, 382,
- 10, AMR_OF(3, pul_il[1]), 347, 115, 179, 219, 305, 380, 277, 294,
- 337, 386,
- 14, AMR_OF(3, pul_il[2]), 145, 192, 307, 370, 234, 223, 324, 244,
- 202, 204, 251, 299, 325, 360,
- 14, AMR_OF(3, pul_il[3]), 149, 221, 311, 363, 226, 222, 316, 231,
- 207, 175, 233, 280, 283, 344,
- 7, AMR_OF(3, vq_gain), 1, 16, 42, 24, 36, 46, 28,
- 0
-};
-
-static const uint16_t order_MODE_23k05[] = {
- 1, AMR_BIT(vad), 7,
- 8, AMR_BIT(isp_id[0]), 55, 40, 14, 6, 15, 5, 0, 68,
- 8, AMR_BIT(isp_id[1]), 77, 58, 75, 49, 59, 57, 67, 61,
- 6, AMR_BIT(isp_id[2]), 48, 63, 51, 62, 50, 70,
- 7, AMR_BIT(isp_id[3]), 71, 56, 60, 69, 85, 86, 80,
- 7, AMR_BIT(isp_id[4]), 93, 64, 94, 76, 82, 81, 89,
- 5, AMR_BIT(isp_id[5]), 90, 103, 88, 102, 99,
- 5, AMR_BIT(isp_id[6]), 98, 97, 96, 111, 95,
- 9, AMR_OF(0, adap), 13, 12, 11, 10, 9, 41, 66, 72,
- 92,
- 1, AMR_OF(0, ltp), 110,
- 11, AMR_OF(0, pul_ih[0]), 118, 129, 131, 153, 170, 282, 298, 210,
- 191, 357, 317,
- 11, AMR_OF(0, pul_ih[1]), 126, 146, 135, 165, 187, 273, 345, 295,
- 172, 338, 340,
- 11, AMR_OF(0, pul_ih[2]), 119, 137, 141, 167, 208, 304, 366, 256,
- 177, 339, 328,
- 11, AMR_OF(0, pul_ih[3]), 116, 130, 120, 166, 190, 252, 311, 239,
- 173, 343, 318,
- 11, AMR_OF(0, pul_il[0]), 245, 180, 342, 424, 259, 277, 266, 380,
- 398, 423, 440,
- 11, AMR_OF(0, pul_il[1]), 218, 207, 367, 434, 201, 240, 275, 363,
- 399, 419, 452,
- 11, AMR_OF(0, pul_il[2]), 274, 188, 348, 425, 242, 204, 262, 365,
- 402, 431, 463,
- 11, AMR_OF(0, pul_il[3]), 221, 183, 337, 439, 243, 216, 251, 354,
- 390, 411, 462,
- 7, AMR_OF(0, vq_gain), 4, 19, 45, 27, 39, 33, 31,
- 6, AMR_OF(1, adap), 35, 54, 79, 74, 84, 101,
- 1, AMR_OF(1, ltp), 109,
- 11, AMR_OF(1, pul_ih[0]), 115, 140, 142, 161, 230, 291, 351, 235,
- 181, 293, 310,
- 11, AMR_OF(1, pul_ih[1]), 104, 138, 132, 162, 211, 315, 347, 233,
- 176, 320, 329,
- 11, AMR_OF(1, pul_ih[2]), 106, 134, 125, 154, 205, 267, 306, 220,
- 185, 330, 297,
- 11, AMR_OF(1, pul_ih[3]), 105, 148, 122, 152, 215, 302, 350, 254,
- 178, 319, 313,
- 11, AMR_OF(1, pul_il[0]), 269, 189, 382, 432, 272, 228, 263, 383,
- 406, 422, 453,
- 11, AMR_OF(1, pul_il[1]), 286, 206, 377, 446, 226, 222, 265, 368,
- 404, 416, 454,
- 11, AMR_OF(1, pul_il[2]), 247, 195, 358, 445, 224, 236, 309, 341,
- 375, 408, 449,
- 11, AMR_OF(1, pul_il[3]), 225, 192, 359, 436, 250, 258, 290, 389,
- 400, 420, 448,
- 7, AMR_OF(1, vq_gain), 3, 18, 44, 26, 38, 32, 30,
- 9, AMR_OF(2, adap), 8, 23, 22, 21, 20, 52, 65, 87,
- 91,
- 1, AMR_OF(2, ltp), 108,
- 11, AMR_OF(2, pul_ih[0]), 139, 144, 145, 169, 234, 327, 395, 299,
- 244, 356, 379,
- 11, AMR_OF(2, pul_ih[1]), 127, 156, 158, 171, 231, 308, 397, 355,
- 261, 371, 335,
- 11, AMR_OF(2, pul_ih[2]), 123, 155, 157, 193, 241, 362, 384, 323,
- 238, 392, 361,
- 11, AMR_OF(2, pul_ih[3]), 114, 147, 121, 175, 196, 333, 373, 303,
- 184, 353, 322,
- 11, AMR_OF(2, pul_il[0]), 271, 203, 385, 442, 307, 276, 334, 405,
- 412, 427, 459,
- 11, AMR_OF(2, pul_il[1]), 278, 200, 388, 447, 292, 288, 296, 403,
- 415, 429, 460,
- 11, AMR_OF(2, pul_il[2]), 312, 214, 393, 433, 279, 301, 314, 391,
- 410, 426, 450,
- 11, AMR_OF(2, pul_il[3]), 280, 186, 376, 437, 268, 260, 255, 364,
- 414, 417, 441,
- 7, AMR_OF(2, vq_gain), 2, 17, 43, 25, 37, 47, 29,
- 6, AMR_OF(3, adap), 34, 53, 78, 73, 83, 100,
- 1, AMR_OF(3, ltp), 107,
- 11, AMR_OF(3, pul_ih[0]), 112, 159, 143, 164, 213, 281, 332, 284,
- 168, 344, 325,
- 11, AMR_OF(3, pul_ih[1]), 113, 150, 149, 179, 199, 316, 324, 285,
- 237, 360, 336,
- 11, AMR_OF(3, pul_ih[2]), 124, 136, 151, 174, 209, 326, 349, 248,
- 198, 374, 331,
- 11, AMR_OF(3, pul_ih[3]), 117, 128, 133, 163, 202, 300, 372, 305,
- 194, 387, 321,
- 11, AMR_OF(3, pul_il[0]), 249, 182, 352, 428, 253, 264, 289, 413,
- 407, 418, 461,
- 11, AMR_OF(3, pul_il[1]), 287, 212, 369, 444, 223, 246, 217, 346,
- 394, 401, 451,
- 11, AMR_OF(3, pul_il[2]), 219, 197, 378, 435, 229, 257, 283, 396,
- 409, 430, 455,
- 11, AMR_OF(3, pul_il[3]), 232, 160, 370, 438, 227, 270, 294, 381,
- 386, 421, 443,
- 7, AMR_OF(3, vq_gain), 1, 16, 42, 24, 36, 46, 28,
- 0
-};
-
-static const uint16_t order_MODE_23k85[] = {
- 1, AMR_BIT(vad), 7,
- 8, AMR_BIT(isp_id[0]), 55, 40, 14, 6, 15, 5, 0, 68,
- 8, AMR_BIT(isp_id[1]), 93, 58, 91, 49, 59, 57, 67, 61,
- 6, AMR_BIT(isp_id[2]), 48, 63, 51, 62, 50, 70,
- 7, AMR_BIT(isp_id[3]), 71, 56, 60, 69, 101, 102, 96,
- 7, AMR_BIT(isp_id[4]), 109, 64, 110, 92, 98, 97, 105,
- 5, AMR_BIT(isp_id[5]), 106, 119, 104, 118, 115,
- 5, AMR_BIT(isp_id[6]), 114, 113, 112, 127, 111,
- 9, AMR_OF(0, adap), 13, 12, 11, 10, 9, 41, 66, 88,
- 108,
- 1, AMR_OF(0, ltp), 126,
- 11, AMR_OF(0, pul_ih[0]), 134, 145, 147, 169, 186, 298, 314, 226,
- 207, 373, 333,
- 11, AMR_OF(0, pul_ih[1]), 142, 162, 151, 181, 203, 289, 361, 311,
- 188, 354, 356,
- 11, AMR_OF(0, pul_ih[2]), 135, 153, 157, 183, 224, 320, 382, 272,
- 193, 355, 344,
- 11, AMR_OF(0, pul_ih[3]), 132, 146, 136, 182, 206, 268, 327, 255,
- 189, 359, 334,
- 11, AMR_OF(0, pul_il[0]), 261, 196, 358, 440, 275, 293, 282, 396,
- 414, 439, 456,
- 11, AMR_OF(0, pul_il[1]), 234, 223, 383, 450, 217, 256, 291, 379,
- 415, 435, 468,
- 11, AMR_OF(0, pul_il[2]), 290, 204, 364, 441, 258, 220, 278, 381,
- 418, 447, 479,
- 11, AMR_OF(0, pul_il[3]), 237, 199, 353, 455, 259, 232, 267, 370,
- 406, 427, 478,
- 7, AMR_OF(0, vq_gain), 4, 19, 45, 27, 39, 33, 31,
- 4, AMR_OF(0, hb_gain), 79, 78, 77, 76,
- 6, AMR_OF(1, adap), 35, 54, 95, 90, 100, 117,
- 1, AMR_OF(1, ltp), 125,
- 11, AMR_OF(1, pul_ih[0]), 131, 156, 158, 177, 246, 307, 367, 251,
- 197, 309, 326,
- 11, AMR_OF(1, pul_ih[1]), 120, 154, 148, 178, 227, 331, 363, 249,
- 192, 336, 345,
- 11, AMR_OF(1, pul_ih[2]), 122, 150, 141, 170, 221, 283, 322, 236,
- 201, 346, 313,
- 11, AMR_OF(1, pul_ih[3]), 121, 164, 138, 168, 231, 318, 366, 270,
- 194, 335, 329,
- 11, AMR_OF(1, pul_il[0]), 285, 205, 398, 448, 288, 244, 279, 399,
- 422, 438, 469,
- 11, AMR_OF(1, pul_il[1]), 302, 222, 393, 462, 242, 238, 281, 384,
- 420, 432, 470,
- 11, AMR_OF(1, pul_il[2]), 263, 211, 374, 461, 240, 252, 325, 357,
- 391, 424, 465,
- 11, AMR_OF(1, pul_il[3]), 241, 208, 375, 452, 266, 274, 306, 405,
- 416, 436, 464,
- 7, AMR_OF(1, vq_gain), 3, 18, 44, 26, 38, 32, 30,
- 4, AMR_OF(1, hb_gain), 75, 74, 73, 72,
- 9, AMR_OF(2, adap), 8, 23, 22, 21, 20, 52, 65, 103,
- 107,
- 1, AMR_OF(2, ltp), 124,
- 11, AMR_OF(2, pul_ih[0]), 155, 160, 161, 185, 250, 343, 411, 315,
- 260, 372, 395,
- 11, AMR_OF(2, pul_ih[1]), 143, 172, 174, 187, 247, 324, 413, 371,
- 277, 387, 351,
- 11, AMR_OF(2, pul_ih[2]), 139, 171, 173, 209, 257, 378, 400, 339,
- 254, 408, 377,
- 11, AMR_OF(2, pul_ih[3]), 130, 163, 137, 191, 212, 349, 389, 319,
- 200, 369, 338,
- 11, AMR_OF(2, pul_il[0]), 287, 219, 401, 458, 323, 292, 350, 421,
- 428, 443, 475,
- 11, AMR_OF(2, pul_il[1]), 294, 216, 404, 463, 308, 304, 312, 419,
- 431, 445, 476,
- 11, AMR_OF(2, pul_il[2]), 328, 230, 409, 449, 295, 317, 330, 407,
- 426, 442, 466,
- 11, AMR_OF(2, pul_il[3]), 296, 202, 392, 453, 284, 276, 271, 380,
- 430, 433, 457,
- 7, AMR_OF(2, vq_gain), 2, 17, 43, 25, 37, 47, 29,
- 4, AMR_OF(2, hb_gain), 87, 86, 85, 84,
- 6, AMR_OF(3, adap), 34, 53, 94, 89, 99, 116,
- 1, AMR_OF(3, ltp), 123,
- 11, AMR_OF(3, pul_ih[0]), 128, 175, 159, 180, 229, 297, 348, 300,
- 184, 360, 341,
- 11, AMR_OF(3, pul_ih[1]), 129, 166, 165, 195, 215, 332, 340, 301,
- 253, 376, 352,
- 11, AMR_OF(3, pul_ih[2]), 140, 152, 167, 190, 225, 342, 365, 264,
- 214, 390, 347,
- 11, AMR_OF(3, pul_ih[3]), 133, 144, 149, 179, 218, 316, 388, 321,
- 210, 403, 337,
- 11, AMR_OF(3, pul_il[0]), 265, 198, 368, 444, 269, 280, 305, 429,
- 423, 434, 477,
- 11, AMR_OF(3, pul_il[1]), 303, 228, 385, 460, 239, 262, 233, 362,
- 410, 417, 467,
- 11, AMR_OF(3, pul_il[2]), 235, 213, 394, 451, 245, 273, 299, 412,
- 425, 446, 471,
- 11, AMR_OF(3, pul_il[3]), 248, 176, 386, 454, 243, 286, 310, 397,
- 402, 437, 459,
- 7, AMR_OF(3, vq_gain), 1, 16, 42, 24, 36, 46, 28,
- 4, AMR_OF(3, hb_gain), 83, 82, 81, 80,
- 0
-};
-
-/** Reordering array addresses for each mode */
-static const uint16_t* amr_bit_orderings_by_mode[] = {
- order_MODE_6k60,
- order_MODE_8k85,
- order_MODE_12k65,
- order_MODE_14k25,
- order_MODE_15k85,
- order_MODE_18k25,
- order_MODE_19k85,
- order_MODE_23k05,
- order_MODE_23k85
-};
-
-// Extracted from 3GPP TS 26.173 V9.0.0 (qpisf_2s.tab)
-// The *_36b tables are used in 6k60 mode
-// Stored in fixed-point to save some space
-/** Indexed tables for retrieval of quantized ISF vectors in Q15 */
-static const int16_t dico1_isf[256][9] = {
- { 579, 1081, 1035, 390, 3, -263, -198, -82, 38},
- { 18, -68, -12, 313, 761, 405, 249, 111, -76},
- { 740, 1263, 1292, 1006, 997, 1019, 1017, 976, 923},
- { -91, 827, 948, 648, 613, 535, 522, 490, 421},
- { 41, -44, -281, -472, 652, 534, 193, 135, -90},
- { 41, -121, -356, -60, 663, 307, 61, -48, -344},
- { 557, 946, 1049, 867, 846, 990, 1112, 1262, 1241},
- { -118, -204, 328, 512, 870, 793, 610, 402, 186},
- { 156, 293, 74, -338, -475, -897, -594, -161, -497},
- { 226, 131, -138, 307, 169, -271, -164, -387, -624},
- { 62, -32, -61, -252, -541, -828, -1027, -523, -662},
- { 102, -61, 141, 112, -270, -251, -541, 25, -150},
- { 6, -132, -356, -686, -96, -322, -522, -31, -326},
- { -36, -209, -521, -229, 307, -132, -5, -99, -384},
- { 60, -51, -237, -668, -973, -407, -708, -75, -172},
- { 26, -138, -266, 111, -302, 43, -278, -356, -359},
- { 570, 822, 496, -154, -312, -92, 137, 279, 371},
- { -146, 368, 409, 68, 6, 77, 167, 202, 162},
- { 633, 898, 996, 756, 662, 683, 783, 909, 996},
- { -103, 294, 607, 415, 483, 462, 480, 431, 408},
- { -120, -338, -612, -524, 584, 331, 92, 433, 276},
- { -178, -293, -154, -41, 269, 100, -9, 213, 160},
- { 830, 736, 278, 820, 1254, 686, 712, 1039, 473},
- { -218, -304, 463, 454, 397, 273, 202, 286, 273},
- { -232, 7, 6, -388, -472, -427, -378, -167, -100},
- { -294, -183, 134, -47, 101, -88, -84, -117, -3},
- { 57, 17, -202, -634, -989, -1119, -533, 176, -36},
- { 120, -28, 23, 111, -319, 318, -22, -77, 266},
- { -271, -464, -434, -658, -640, -385, -385, -99, -69},
- { -198, -259, -266, -44, -39, -139, -137, 171, 66},
- { 9, -145, -377, -846, -1000, -111, -325, 342, 135},
- { -81, -286, -380, 192, -57, 307, 76, -24, -140},
- { 677, 702, 247, 56, 249, 141, -105, -236, -99},
- { 36, -39, -69, 348, 198, -93, 322, 91, -72},
- { 503, 885, 1508, 1307, 1282, 1172, 1119, 1209, 1061},
- { 416, 719, 989, 1227, 1001, 1052, 954, 741, 1044},
- { -127, -376, -657, 139, 623, 223, 501, 306, 220},
- { -113, -384, -796, 504, 438, 85, 213, -83, -194},
- { 585, 1132, 1233, 1091, 1247, 1433, 1512, 1448, 1314},
- { -174, -422, 7, 1155, 1089, 1182, 1003, 945, 806},
- { 8, -126, -317, -103, -351, -695, -98, -268, -537},
- { 33, -103, -290, 167, -39, -407, 44, -208, -375},
- { 104, -23, -64, -291, -637, -851, -1084, -61, -112},
- { -75, -306, -434, 218, -148, -354, -680, -133, -216},
- { -121, -377, -718, -97, -130, -361, -156, -379, -599},
- { -56, -254, -586, 235, 157, -214, 11, -260, -149},
- { -124, -267, -397, -580, -593, -527, -805, -385, 346},
- { -193, -440, -708, -351, -141, -255, -499, -147, -185},
- { 448, 660, 494, 208, 509, 461, 338, 291, 149},
- { -223, 88, 335, 159, 212, 191, 286, 308, 205},
- { -31, 469, 803, 659, 619, 658, 843, 987, 1113},
- { -171, -242, 514, 362, 295, 524, 552, 694, 585},
- { -64, -308, -448, -21, 284, 786, 446, 289, 92},
- { -218, -390, -7, 169, 206, 330, 352, 408, 358},
- { -36, 702, 959, 859, 861, 1115, 1269, 1357, 1305},
- { -133, -341, -65, 678, 417, 440, 486, 518, 780},
- { 33, -44, -191, -344, -461, -755, -201, 217, -31},
- { -353, -547, -44, 123, -61, -68, -79, 29, 60},
- { 73, -57, -406, -766, -1243, -1203, 240, 400, 165},
- { -73, -282, -601, -213, -171, -375, 332, 35, -103},
- { -29, -207, -553, -476, -638, -908, 172, -22, -135},
- { -192, -239, -164, -103, -111, -47, 153, 125, 110},
- { -1, -203, -570, -1030, -1424, -535, 155, 1, 147},
- { -333, -653, -865, -197, -158, -21, -44, 95, 108},
- { 389, 588, 490, 33, -237, -524, -628, -136, -260},
- { 40, -177, -462, 453, 862, 380, 131, -130, -405},
- { 842, 1678, 1841, 1549, 1474, 1256, 1082, 905, 742},
- { 370, 1216, 1768, 1633, 1212, 636, 22, -330, 71},
- { -76, -281, -741, -742, 898, 619, 277, 71, -222},
- { -32, -265, -556, -25, 994, 682, 305, 126, -165},
- { 73, 738, 893, 968, 993, 1768, 2273, 1840, 1391},
- { -69, -349, -585, 234, 1158, 903, 626, 510, 251},
- { -1, -99, -272, -210, -603, -351, -540, -811, -383},
- { -16, -230, -504, 410, 149, -205, -343, -651, -639},
- { 103, -9, -227, -205, -562, -781, -1079, -1208, -156},
- { 143, 63, -135, -67, -317, -602, -784, -1154, -640},
- { -144, -391, -674, -622, -200, -254, -660, -947, -395},
- { -40, -250, -625, 27, 543, 94, -131, -386, -673},
- { -123, -371, -757, -451, -564, -614, -415, -711, -35},
- { -116, -309, -593, -268, 239, -33, -338, -650, -135},
- { 94, 251, 554, 57, -312, -423, -154, -57, 235},
- { -268, -71, 381, 114, -44, -87, 125, 173, 133},
- { 1513, 1714, 1238, 534, 276, 315, 461, 459, 508},
- { -131, -19, 1149, 670, 486, 356, 309, 369, 296},
- { -223, -501, -899, -722, -70, 6, 131, 310, 394},
- { -99, -303, -517, 249, 64, -53, 135, -11, 453},
- { -147, -399, -730, -401, 817, 738, 802, 749, 575},
- { -154, -435, -739, 800, 593, 366, 529, 318, 326},
- { -224, 45, -39, -387, -515, -518, -608, -384, -321},
- { -315, -377, 143, -101, -113, -377, -177, -144, -12},
- { 117, 40, -239, -651, -1051, -581, -737, -990, -328},
- { 26, -50, -157, -23, -453, -283, -531, -546, 192},
- { -252, -501, -743, -589, -627, -499, -328, -118, -72},
- { -324, -494, -244, -306, -144, -177, -262, -135, -78},
- { -36, -234, -519, -961, -1290, -314, -479, -371, -45},
- { -95, -292, -535, -8, -300, 112, -164, -277, 198},
- { -99, -128, 880, 836, 579, 351, 23, -95, -217},
- { -27, -258, 124, 1011, 597, 425, 144, 7, -73},
- { 421, 1293, 1640, 1623, 1742, 1617, 1499, 1284, 1006},
- { -95, 752, 1680, 1569, 1618, 1436, 1200, 980, 712},
- { -69, -300, -683, -435, 1132, 899, 504, 332, 109},
- { -74, -323, -637, 563, 1074, 608, 371, 105, -49},
- { -78, 831, 1194, 1110, 1378, 1481, 1492, 1365, 1217},
- { -259, -121, 1440, 1334, 1628, 1490, 1438, 1223, 933},
- { -82, -306, -613, -222, -378, -675, -545, -671, -845},
- { 53, -124, -347, 422, 52, -125, -270, -529, 9},
- { 79, -89, -320, -662, -999, -1199, -1243, -676, -297},
- { -68, -273, -611, 137, -146, -397, -627, -845, -220},
- { -112, -346, -797, -826, 234, -132, -188, -278, -522},
- { -159, -405, -734, -419, 293, 74, -167, -167, 184},
- { -153, -437, -833, -1080, -336, -472, -561, -340, -253},
- { -169, -423, -820, -904, -131, -19, -346, -604, 31},
- { 33, -31, 312, 62, -148, 49, -59, 564, 486},
- { -306, -333, 194, -44, 67, 72, 147, 205, 243},
- { -207, -49, 1360, 983, 969, 991, 1014, 1110, 973},
- { -211, -172, 883, 627, 711, 674, 705, 798, 746},
- { -88, -325, -763, -974, 687, 908, 514, 382, 172},
- { -292, -612, -805, 63, 131, 270, 259, 352, 348},
- { -235, -84, 955, 818, 1120, 1289, 1559, 1480, 1285},
- { -180, -461, -614, 657, 691, 745, 854, 783, 713},
- { -97, -309, -477, -614, -777, -734, -768, -526, -472},
- { -344, -476, -35, -169, 49, -77, -150, -240, -141},
- { -52, -268, -639, -919, -1278, -1113, -342, -333, -151},
- { -68, -242, -585, -73, -209, -478, -159, -429, 133},
- { -197, -499, -1005, -1268, -272, -224, -105, -67, 17},
- { -363, -618, -414, -116, -62, 20, 10, 116, 108},
- { -195, -475, -906, -1260, -891, -441, -277, -142, -28},
- { -226, -519, -950, -700, -275, -266, -116, -105, 82},
- { 404, 511, 520, 327, 17, -194, -333, -536, -586},
- { -114, -130, 276, 237, 204, 342, 135, -16, -111},
- { 670, 1208, 1168, 860, 742, 601, 528, 403, 309},
- { 397, 621, 966, 752, 579, 398, 400, 329, 252},
- { 191, 180, -137, -467, 272, 106, -95, 17, -192},
- { -80, -290, -626, 194, 598, 196, 21, -281, 77},
- { 510, 864, 1108, 807, 939, 902, 925, 717, 481},
- { 137, 367, 534, 764, 670, 382, 296, 153, 84},
- { 303, 497, 144, -85, -125, -539, -482, -464, -764},
- { 233, 347, 68, -147, 169, -210, -242, -226, -482},
- { 307, 422, 154, -175, -386, -722, -724, -904, -1015},
- { 309, 308, 160, -60, -470, -420, -598, -791, -219},
- { 68, 121, -137, -560, -146, -446, -515, -494, -729},
- { 130, 53, -227, 46, 474, 32, -161, -192, -490},
- { 213, 164, -71, -465, -876, -161, -456, -587, -48},
- { 218, 117, 39, 177, -194, -88, -226, -418, 50},
- { 210, 547, 569, 279, 121, -44, -50, 10, -84},
- { 58, 140, 182, -5, 267, 117, 106, 211, 198},
- { 539, 835, 913, 719, 617, 544, 591, 565, 642},
- { 153, 559, 872, 460, 222, 108, 188, 180, 183},
- { 158, 119, 284, -153, -271, 229, 87, 110, -57},
- { -183, 82, 118, 21, 13, 40, 118, 191, 185},
- { 162, 889, 654, 108, -34, 244, 488, 561, 532},
- { 163, 56, 609, 341, 50, 329, 68, 266, 218},
- { 100, 206, 18, -304, -107, -436, -487, -65, -306},
- { -86, 154, 134, -30, -45, -73, -104, -80, -96},
- { 245, 330, 10, -440, -849, -1082, 79, 40, -265},
- { 196, 372, 272, -181, -493, -389, 275, 80, -59},
- { 2, -12, -246, -505, -100, -436, 21, -187, -431},
- { -221, -48, 36, -271, -186, -147, -109, 26, 71},
- { 213, 140, 72, -351, -620, -84, -363, 69, 46},
- { 91, 167, -3, -95, -99, -105, -48, 114, 147},
- { 259, 249, 172, 607, 406, 52, 59, -189, -320},
- { 115, -85, -54, 574, 128, 226, -59, -253, 130},
- { -62, 1033, 1308, 1035, 1127, 1098, 1029, 961, 823},
- { 39, 364, 757, 940, 728, 660, 659, 583, 770},
- { -115, -338, -760, -471, 394, 37, 441, 178, 6},
- { -57, -305, -525, 796, 453, 188, -4, -114, 248},
- { 71, 444, 797, 731, 1096, 1157, 1222, 1029, 811},
- { 135, 359, 551, 425, 749, 815, 874, 704, 502},
- { 132, 247, 0, -206, -449, -750, -258, -514, -633},
- { 248, 249, 91, 121, -195, -499, -90, -282, -435},
- { 78, 20, -277, -623, -983, -1224, -415, -458, -639},
- { 347, 509, 208, -179, -464, -728, -76, -237, -486},
- { -103, -343, -756, -713, -265, -609, -191, -398, -636},
- { -121, -383, -749, 567, 252, -36, -354, -417, -50},
- { 204, 100, -149, -650, -1081, -47, -7, -263, 111},
- { -46, -180, -267, -324, -562, -394, -692, 398, 292},
- { 482, 670, 683, 624, 442, 165, 116, 36, -149},
- { 108, 247, 291, 247, 355, 122, 109, 224, 296},
- { -14, 945, 990, 801, 755, 815, 847, 913, 892},
- { 292, 349, 725, 482, 388, 329, 429, 620, 667},
- { -34, 197, 213, -127, 84, 494, 620, 575, 375},
- { 126, 207, 172, 167, 362, 202, 296, 395, 455},
- { -6, 250, 539, 467, 636, 801, 1149, 1287, 1118},
- { 27, 240, 369, 280, 440, 411, 634, 892, 953},
- { 159, 170, -58, -395, -797, -690, 77, -211, -334},
- { -5, -28, -13, -74, -335, -603, 300, 88, -205},
- { 82, -33, -364, -698, -1203, -1153, 110, -146, -289},
- { 113, 1, -243, -588, -994, -496, 414, 160, 42},
- { -56, -247, -440, -693, -996, -479, 11, -178, -357},
- { -151, -353, -327, -211, -340, 141, 65, 425, 453},
- { 34, -169, -455, -932, -1215, 138, 499, 256, 324},
- { 68, 139, -15, -547, -478, 17, 306, 502, 481},
- { -32, -134, 445, 129, -143, -244, -503, -507, -599},
- { 61, -140, -345, 496, 458, -2, 20, -227, -514},
- { 394, 1765, 1666, 1339, 1117, 806, 642, 479, 380},
- { 215, 519, 920, 1053, 1090, 791, 528, 290, 155},
- { -54, -233, -647, -602, 639, 294, -2, -167, -442},
- { -78, -315, -791, -113, 820, 403, 158, -116, -356},
- { 529, 1851, 2003, 1228, 622, -41, -416, 344, 819},
- { -105, -379, -236, 1224, 893, 749, 568, 356, 214},
- { -17, -199, -144, 50, -283, -247, -578, -846, -1087},
- { 69, -11, -381, -206, 209, -284, -387, -416, -716},
- { 39, -5, -145, -374, -682, -909, -1074, -1169, -1066},
- { 287, 226, 67, -221, -662, -171, -421, -642, -707},
- { -132, -348, -538, -448, -20, -4, -354, -748, -933},
- { 4, -75, -289, -598, 317, 52, -208, -297, -559},
- { -88, -264, -358, -589, -631, -248, -523, -822, -1071},
- { 70, -8, 54, -314, -515, 92, -146, -274, -493},
- { 199, 62, 391, 158, -141, 71, -219, -203, -207},
- { 152, 40, 329, 162, -29, 48, -149, 108, 127},
- { 635, 1058, 883, 492, 372, 312, 317, 274, 241},
- { 267, 722, 1256, 882, 625, 248, 8, -81, -60},
- { -58, -138, -291, -600, -12, -2, -39, 147, 117},
- { -107, -345, -513, 459, 76, 92, -272, 388, 262},
- { 362, 516, 203, -409, -716, -831, -331, 185, 209},
- { -117, -391, -298, 671, 292, 538, 257, 166, -38},
- { -102, -319, -194, -283, -573, -262, -579, -219, -444},
- { -235, 78, 11, -168, -101, -229, -263, -321, -123},
- { 70, 50, -170, -599, -996, -588, -263, -516, -455},
- { 394, 363, 229, -136, -538, 21, -183, -348, -201},
- { -124, -368, -640, -879, -847, -209, -409, -494, -515},
- { -127, -341, -541, -425, -510, -10, -252, -473, -291},
- { 84, -69, -201, -676, -868, 103, -311, -132, -320},
- { 5, -173, -188, -297, -628, 197, -57, 7, -11},
- { 49, -160, 56, 558, 111, 33, -311, -440, -463},
- { -1, -246, -307, 862, 453, 139, -170, -355, -232},
- { 279, 966, 1642, 1478, 1463, 1123, 795, 525, 339},
- { -197, -38, 1702, 1331, 1252, 950, 692, 504, 426},
- { -108, -344, -861, -1172, 444, 354, 88, -46, -220},
- { -53, -321, -494, 1113, 744, 364, 198, -34, -75},
- { 457, 955, 1177, 1214, 1427, 1457, 1345, 917, 539},
- { -69, 199, 897, 1140, 1343, 1183, 977, 742, 522},
- { 122, 44, -269, 27, -155, -562, -307, -590, -773},
- { 154, 42, -160, 252, -129, -305, -471, -733, -371},
- { 135, 185, -82, -416, -722, -913, -504, -743, -880},
- { 149, 214, -84, -329, -680, -835, -426, -661, -81},
- { -128, -380, -735, -998, -337, 17, -182, -467, -697},
- { -84, -290, -510, -592, 13, 440, 154, -38, -279},
- { 70, -61, -246, -727, -1047, -80, -381, -535, -704},
- { 178, -2, -146, -670, -938, 482, 138, 63, 65},
- { -11, 15, 772, 443, 142, -20, -209, -126, -161},
- { -32, -249, 95, 552, 124, 30, -343, 82, -86},
- { 148, 751, 1515, 1105, 867, 606, 474, 448, 399},
- { -163, -257, 899, 1097, 906, 751, 502, 390, 294},
- { -51, -258, -447, -806, -368, 763, 464, 364, 183},
- { -166, -374, -367, 87, 35, 399, 418, 856, 833},
- { -205, -310, 588, 778, 785, 1065, 1118, 1245, 1157},
- { -173, -312, 107, 345, 400, 790, 870, 1113, 1001},
- { -7, -120, -387, -410, -614, -943, -226, -384, -491},
- { -203, -288, -51, -331, -90, -178, -408, -573, -338},
- { 56, -29, -273, -627, -1041, -798, -247, -467, 148},
- { 66, -2, -205, -205, -575, -349, -57, -352, -58},
- { -45, -225, -471, -924, -497, 77, -32, 44, -135},
- { -277, -491, -497, -502, -424, -202, -137, 77, 96},
- { 26, -179, -469, -1008, -1260, 262, -35, -132, -259},
- { -66, -232, -447, -533, -789, -191, -100, -267, 364}
-};
-
-static const int16_t dico2_isf[256][7] = {
- { 1357, 1313, 1136, 784, 438, 181, 145},
- { 636, 648, 667, 568, 442, 217, 362},
- { 427, 440, 674, 524, 332, 117, -417},
- { 121, 295, 468, 465, 230, 44, -221},
- { -147, -240, 149, 80, 390, 278, 106},
- { -418, -556, 552, 511, 235, 144, -95},
- { 43, 193, 274, 150, 67, 34, -273},
- { -43, -126, 171, 416, 282, 63, -354},
- { -372, -86, -344, -108, -94, -182, -89},
- { -600, -840, -200, 465, 258, -11, -253},
- { -48, 329, 97, -290, -543, -795, -354},
- { -570, -117, 187, 10, -133, -416, -76},
- { -618, -129, -247, -371, 45, -76, 277},
- { -1022, -1079, 126, 474, 254, 127, 52},
- { -281, 76, -167, -361, -283, -551, -283},
- { -119, -52, -1, 134, -32, -204, -415},
- { 1064, 827, 637, 684, 464, 209, 12},
- { 482, 416, 449, 371, 335, 294, 194},
- { 719, 576, 365, 135, 113, 91, -199},
- { 298, 176, 493, 366, 194, 163, 36},
- { -35, -236, -259, -36, -4, 99, 152},
- { -98, -306, -27, 228, 90, 111, -86},
- { 91, 13, -211, -258, -106, 86, -64},
- { 73, -35, -57, -31, 162, 35, -192},
- { -109, -335, -629, -66, -61, -128, 322},
- { -495, -669, -728, 193, 31, -220, 122},
- { 324, 95, -89, -91, -409, -710, -154},
- { 0, -234, 92, 33, -343, -609, -220},
- { -343, -408, -476, -655, -153, 82, 222},
- { -490, -745, -255, 49, -48, 135, -127},
- { 119, -67, -328, -390, -272, -545, -56},
- { -57, -130, -10, -7, -164, -47, -22},
- { 984, 1064, 961, 568, 210, -27, 16},
- { 811, 691, 754, 514, 224, -35, 166},
- { 662, 704, 618, 386, 57, -211, -257},
- { 510, 359, 418, 393, 91, -144, -18},
- { -193, -31, -27, 223, 89, -143, 24},
- { -112, -98, 471, 319, 185, 3, 175},
- { 252, 146, -47, 272, 48, -211, -234},
- { 146, 69, 203, 364, 68, -52, 51},
- { -259, -478, -697, -349, -758, -501, 63},
- { -501, -769, -289, 79, -311, -497, -106},
- { 251, 53, -235, -469, -895, -884, 145},
- { -416, -551, 140, -133, -523, -775, 44},
- { -326, -423, -713, -497, -86, -431, 99},
- { -757, -772, -160, -76, -46, -32, 379},
- { 85, -35, -200, -401, -663, -1040, -247},
- { -180, -330, -92, -376, 27, -183, -110},
- { 1279, 1086, 781, 502, 324, 164, 157},
- { 682, 466, 449, 277, 146, 28, 409},
- { 635, 472, 390, 107, -232, -538, -139},
- { 196, 396, 332, 213, 209, -29, -81},
- { 150, -95, -312, 76, -77, -320, -50},
- { 46, 9, 47, 175, 139, 30, 384},
- { 218, 206, -24, -250, -96, -276, -183},
- { 26, 119, 38, 14, -4, -133, -52},
- { -477, -614, -987, -715, -631, -813, 200},
- { -744, -1009, -1065, -745, -631, -171, 18},
- { -137, -251, -483, -613, -980, -1203, 12},
- { -605, -767, -562, -686, -1088, -515, 58},
- { -202, -428, -782, -1072, -96, -234, -179},
- { -480, -709, -1070, -897, -131, -92, 321},
- { -145, -193, -512, -729, -572, -765, -210},
- { -331, -585, -525, -631, -281, -208, -303},
- { 1165, 1104, 939, 828, 716, 426, 155},
- { 6, -109, 820, 778, 415, 113, -27},
- { 381, 339, 314, 265, 121, -9, -474},
- { -373, 47, 584, 442, 99, -231, -113},
- { -496, -38, -285, 262, 305, 170, 4},
- { -587, -556, 69, 66, 471, 354, 13},
- { -138, 70, -18, 106, 67, 167, -302},
- { -445, -141, 185, 191, 151, 83, -133},
- { -257, -521, -720, -198, 134, -46, -182},
- { -819, -1168, -777, 512, 359, 95, -113},
- { 137, -2, -74, -138, -401, -114, -371},
- { -242, -466, 204, 223, -31, -212, -192},
- { -532, -637, -466, -686, 256, 277, -139},
- { -1141, -1244, -381, -75, -54, 14, 88},
- { -311, 115, -143, -499, -343, 124, -416},
- { -616, -147, -135, 43, -4, 121, -369},
- { 835, 783, 641, 390, 355, 350, 64},
- { 72, 194, 443, 467, 436, 219, 372},
- { 464, 369, 192, 4, -156, -72, -226},
- { 57, 206, 303, 205, 188, 101, 265},
- { -40, -205, -488, -184, 276, 64, -26},
- { -217, -433, -297, 137, 328, 308, -289},
- { 378, 81, -308, -465, 57, -37, 227},
- { -100, 24, -36, -151, 199, 8, 143},
- { -426, -697, -1059, -133, 388, 161, 321},
- { -644, -1023, -1271, 39, 66, -123, 70},
- { 372, 177, -173, -556, -553, -304, -189},
- { -117, -369, -425, -122, -462, -152, -73},
- { -649, -850, -1189, -767, 497, 360, 222},
- { -798, -1139, -1455, -190, 430, 234, 179},
- { 42, -94, -405, -692, 38, -202, -246},
- { -169, -366, -290, -88, -64, 32, -292},
- { 1010, 923, 938, 710, 465, 230, 342},
- { 217, 300, 1054, 675, 68, -458, -179},
- { 78, 453, 316, 18, -237, -496, -243},
- { 167, 21, 424, 215, -91, -303, -170},
- { -290, -81, -70, -67, 40, 54, -59},
- { -353, -427, -90, 53, 94, 9, 54},
- { -28, 318, 283, 15, -240, -58, 79},
- { -75, -121, 229, 35, 58, 6, -133},
- { -351, -514, -744, -834, -705, -137, 164},
- { -1124, -1388, -1055, -230, -73, 40, 36},
- { -163, -233, -532, -785, -1170, -697, 96},
- { -788, -959, -246, -430, -624, -165, -8},
- { -856, -540, -630, -907, -337, -70, 76},
- { -937, -1042, -659, -733, -208, 199, -26},
- { -523, 78, -98, -501, -869, -890, -81},
- { -624, -703, -45, -348, -25, 87, -186},
- { 1005, 823, 546, 249, 90, -22, 207},
- { 298, 397, 381, 319, 200, 62, 303},
- { 473, 379, 133, -247, -632, -441, 75},
- { 284, 208, 391, 115, -25, 44, 95},
- { -72, 79, -95, -63, -129, -293, 203},
- { -164, -349, 115, 122, 69, -1, 378},
- { 348, 170, 99, 58, -179, -302, 188},
- { -190, -2, 150, 23, -51, -11, 216},
- { -615, -863, -1090, -1427, -802, -48, -6},
- { -961, -1276, -1548, -727, -58, 56, 223},
- { -124, -255, -561, -988, -1277, -148, -82},
- { -480, -660, -891, -1191, -1339, -325, 20},
- { -621, -917, -1296, -1350, 264, 289, 50},
- { -844, -1022, -1345, -1329, -293, 46, 278},
- { -260, -468, -829, -1176, -533, -560, -78},
- { -215, -484, -822, -1233, -791, 15, -138},
- { 1301, 1317, 1262, 1048, 716, 357, -64},
- { 578, 824, 925, 802, 630, 362, 102},
- { 470, 925, 767, 514, 327, 190, -112},
- { 225, 492, 495, 437, 598, 384, -45},
- { 43, 82, -42, 175, 519, 342, -64},
- { -304, -154, 159, 576, 403, 221, 327},
- { 214, 244, 122, -62, 312, 92, -160},
- { 218, 208, 310, 268, 306, 323, -199},
- { -285, -269, -79, -124, -143, -153, 236},
- { -205, -384, -426, 344, 59, -185, -184},
- { -272, 247, 126, -210, -518, -468, 78},
- { -99, -120, 502, 160, -280, -557, 304},
- { -423, -17, -283, -443, 215, 212, -140},
- { -564, -684, -228, 510, 361, 130, 323},
- { -428, 335, 98, -65, 36, -215, -246},
- { -362, 51, 364, -16, -234, 150, -165},
- { 914, 883, 751, 653, 676, 464, -153},
- { 631, 545, 535, 720, 596, 360, -81},
- { 783, 712, 512, 439, 341, 251, -391},
- { 497, 417, 249, 372, 295, 173, -193},
- { 128, -110, -385, 93, 39, 173, -231},
- { 216, -59, -253, 462, 389, 154, 69},
- { 455, 270, -4, -337, -49, 233, -322},
- { 307, 143, 53, 218, 128, 236, -156},
- { -37, -186, -240, -411, -110, 9, 399},
- { -140, -365, -628, 258, 380, 214, 277},
- { 131, 454, 177, -285, -520, 108, -214},
- { 77, -141, 201, -123, -490, -131, 60},
- { -14, -194, -521, -741, 273, 362, -33},
- { -362, -566, -287, -228, 161, 237, 317},
- { -269, 195, -75, -375, -204, 11, 77},
- { -128, -264, -156, -223, -475, 265, 27},
- { 1238, 1147, 916, 689, 432, 210, -280},
- { 800, 664, 879, 726, 411, 160, -164},
- { 454, 686, 536, 275, 147, 46, 111},
- { 303, 486, 512, 355, 241, 181, -69},
- { 79, 92, 29, 147, 233, 52, 17},
- { -171, 289, 131, 439, 271, 3, -10},
- { 413, 241, 144, 174, 155, -2, 14},
- { 58, 217, 247, 219, 149, 175, -18},
- { 228, -8, -240, -206, -513, -191, 202},
- { -96, -272, -454, 33, -300, -575, 46},
- { -10, -108, -246, -347, -770, -535, 9},
- { -326, -430, -61, -321, -704, -299, 201},
- { -1, -280, -603, -419, -185, 18, -36},
- { -516, -522, -379, -291, -181, -97, 27},
- { -159, -313, -525, -224, -510, -831, -197},
- { -292, -459, -59, -310, -562, -143, -351},
- { 1066, 912, 631, 389, 207, 86, -224},
- { 596, 512, 596, 505, 314, 122, -48},
- { 787, 861, 441, -93, -303, 33, -190},
- { 257, 469, 337, 51, 15, 298, -93},
- { 295, 73, -119, 25, 36, 23, 108},
- { -28, -3, -32, 114, 21, 185, 107},
- { 482, 305, 15, -279, -319, 52, 96},
- { 226, 46, 115, 72, -136, 133, -125},
- { 18, -207, -559, -590, -503, -482, 321},
- { -571, -789, -951, -172, -441, -538, 113},
- { 181, 14, -310, -641, -1001, -202, 159},
- { -136, -393, -433, -513, -911, -144, -22},
- { 72, -265, -706, -954, -159, 53, 332},
- { -338, -591, -852, -383, -395, 56, 44},
- { 43, -158, -464, -897, -631, -157, -294},
- { -161, -128, -328, -573, -483, -125, 11},
- { 1017, 906, 1051, 1005, 679, 341, -102},
- { 359, 334, 1567, 1314, 723, 105, 10},
- { -65, 726, 529, 301, 220, 43, -273},
- { -510, 436, 719, 566, 358, 179, 114},
- { -560, 298, 133, -120, 342, 225, 14},
- { -899, -101, 217, 617, 400, 146, -58},
- { -41, 352, 82, -196, 39, 121, -167},
- { -212, 59, 447, 284, 423, 250, -169},
- { -371, -484, -596, 30, -41, 249, 22},
- { -372, -650, -794, 477, 445, 216, -79},
- { -352, 275, 17, -443, -929, 92, 19},
- { -699, -696, 431, 264, -49, -310, 182},
- { -978, -217, -430, -400, 101, 261, 72},
- { -929, -889, -357, -13, 463, 378, 236},
- { -826, 56, 30, -299, -360, -128, -51},
- { -878, -299, -111, 75, 65, 36, 3},
- { 817, 368, -25, 354, 697, 591, -173},
- { 309, 212, 222, 751, 484, 140, -56},
- { 593, 379, 70, -8, 258, 180, 110},
- { 165, -46, 255, 297, 219, 273, 105},
- { 160, -70, -358, -181, 379, 330, 319},
- { -238, -369, -198, 740, 580, 319, -143},
- { 201, 109, -202, -456, 328, 276, -141},
- { 203, 170, 111, 42, 207, 360, 188},
- { -345, -399, -513, -233, 650, 422, 81},
- { -635, -961, -1220, 463, 539, 204, 209},
- { 202, -25, -194, -498, -787, 193, -143},
- { -449, -538, 195, -106, -331, 68, 62},
- { -228, -477, -840, -576, 317, 128, 283},
- { -671, -937, -807, -114, 391, 335, -62},
- { 246, 2, -314, -679, -303, 180, -88},
- { -107, -272, 90, -198, -28, 290, -112},
- { 885, 1149, 1021, 712, 496, 281, -83},
- { 269, 492, 787, 643, 347, 70, 124},
- { 336, 636, 499, 92, -229, -179, 191},
- { 26, 402, 564, 340, 149, -11, 135},
- { -440, 561, 470, 204, -72, -186, 140},
- { -720, 14, 355, 229, 68, -133, 465},
- { 110, 310, 103, 12, 106, 29, 158},
- { -178, 113, 161, 142, 121, 115, 27},
- { -651, -414, -645, -152, -164, -13, -429},
- { -639, -944, -681, -104, -81, 52, -189},
- { -663, -164, -316, -683, -954, -205, -83},
- { -609, -669, -172, -517, -694, 283, -80},
- { -646, -152, -383, -678, -246, -40, -143},
- { -747, -796, -745, -390, -98, 43, 275},
- { -599, -199, -398, -433, -436, -538, 31},
- { -1107, -568, -376, -265, -126, -21, 1},
- { 847, 573, 308, 392, 305, 101, 55},
- { 273, 293, 201, 267, 346, 201, 123},
- { 727, 480, 226, 2, -65, -138, 164},
- { 273, 208, 173, 292, 12, 253, 174},
- { 340, 207, 180, 88, 116, 46, 475},
- { -460, -166, -30, 13, 110, 173, 396},
- { 137, 88, 43, -137, -94, 34, 284},
- { 96, -14, 226, 40, 63, 70, 130},
- { -467, -735, -1012, -1174, -307, 305, -67},
- { -612, -920, -1146, -567, -8, 92, -25},
- { -182, -271, -492, -754, -857, 287, -75},
- { -494, -787, -689, -683, -709, 137, -326},
- { -288, -550, -903, -1105, 334, 321, -62},
- { -354, -653, -834, -445, 1, 377, -152},
- { -162, -306, -608, -937, -297, 247, -192},
- { -234, -477, -244, -488, -266, 342, -332}
-};
-
-static const int16_t dico21_isf[64][3] = {
- { 329, 409, 249}, { -33, 505, 160},
- { -29, -14, 582}, { -262, 127, 354},
- { 145, 237, 175}, { -152, 245, 122},
- { 27, 42, 340}, { -84, -93, 311},
- { 285, 222, -156}, { 47, -43, -504},
- { 234, 121, 385}, { 104, -317, 45},
- { 176, 195, 8}, { 104, -59, -94},
- { 177, 53, 192}, { -34, -127, 152},
- { 570, 277, -34}, { -67, -329, -639},
- { -157, -272, 462}, { -177, -462, 198},
- { 322, 179, 115}, { -386, 171, 19},
- { 19, -12, 195}, { -120, -252, 201},
- { 304, 36, -336}, { -128, -221, -380},
- { 171, -185, 296}, { -242, -312, 23},
- { 198, 39, 16}, { -3, -177, -111},
- { 111, -93, 76}, { -92, -223, 4},
- { 177, 406, -44}, { -168, 380, -149},
- { -4, 273, 331}, { -420, 513, 277},
- { 21, 247, 47}, { -58, 131, -2},
- { -3, 134, 180}, { -145, 40, 175},
- { 189, 74, -145}, { -27, -45, -325},
- { 370, -114, -21}, { -83, -415, -173},
- { 77, 95, -51}, { -40, -30, -67},
- { 71, 88, 86}, { -35, -98, 14},
- { 69, 197, -334}, { -196, 79, -231},
- { -348, -137, 218}, { -352, -89, -85},
- { 47, 201, -130}, { -165, 37, -15},
- { -43, 3, 86}, { -161, -108, 79},
- { 83, 21, -237}, { -81, -149, -238},
- { 150, -186, -251}, { -186, -249, -162},
- { -19, 66, -139}, { -26, -50, -181},
- { 24, 11, 0}, { -130, -105, -98}
-};
-
-static const int16_t dico22_isf[128][3] = {
- { -127, 310, 42}, { -242, 197, 5},
- { -151, 84, -17}, { -214, 127, -149},
- { -247, -131, 159}, { -268, -267, -95},
- { -217, 1, -79}, { -271, -80, -185},
- { -45, 436, 159}, { 165, 199, 391},
- { -33, 81, 187}, { -66, -42, 355},
- { -298, -57, 343}, { -108, -537, 226},
- { -144, -23, 193}, { 176, -402, 87},
- { 53, 296, 25}, { -84, 253, -104},
- { -58, 105, -126}, { -169, 174, -314},
- { -48, 44, -294}, { -164, -417, -242},
- { -139, 3, -194}, { -155, -207, -211},
- { 119, 322, 213}, { 333, 50, 380},
- { 237, 247, -2}, { 466, -16, 201},
- { 238, -255, -107}, { 67, -440, -149},
- { 122, -88, -139}, { 88, -247, -73},
- { -41, 231, 167}, { -62, 155, 16},
- { -65, 16, 77}, { -68, -2, -63},
- { -151, -300, 160}, { -18, -333, 54},
- { -56, -94, 5}, { 2, -190, 14},
- { 92, 148, 209}, { 108, 9, 272},
- { 108, 35, 110}, { 142, -85, 145},
- { 47, -157, 279}, { 3, -320, 246},
- { 43, -72, 68}, { 86, -217, 135},
- { 36, 140, 79}, { 56, 175, -49},
- { 26, 45, 3}, { 73, 55, -101},
- { 109, -183, -242}, { -4, -283, -242},
- { 48, -68, -48}, { -6, -153, -122},
- { 161, 196, 96}, { 232, 80, 190},
- { 165, 97, 11}, { 258, -31, 71},
- { 267, -77, -91}, { 311, -209, 87},
- { 152, -14, -22}, { 150, -149, 9},
- { -324, 557, 187}, { -384, 307, 46},
- { -251, 27, 77}, { -365, 77, -52},
- { -482, -84, 160}, { -424, -515, -64},
- { -294, -120, -4}, { -476, -116, -109},
- { -97, 318, 365}, { 106, 627, 445},
- { -190, 120, 287}, { -146, 65, 619},
- { -427, 242, 363}, { -361, -371, 432},
- { -347, 102, 168}, { -629, 195, -14},
- { -65, 476, -47}, { -297, 320, -168},
- { -55, 356, -264}, { -391, 82, -286},
- { -51, -31, -556}, { -178, -399, -586},
- { -205, -49, -360}, { -343, -238, -337},
- { 220, 457, 58}, { 561, 467, 259},
- { 340, 270, -168}, { 450, 77, -280},
- { 60, 167, -413}, { 133, -252, -492},
- { 216, 157, -290}, { 282, 0, -495},
- { -226, 293, 183}, { -157, 135, 122},
- { -158, -59, 39}, { -133, -118, -97},
- { -332, -309, 113}, { -160, -425, -6},
- { -149, -211, 24}, { -80, -277, -90},
- { -11, 125, 338}, { 130, -71, 465},
- { 5, -45, 184}, { 237, -95, 253},
- { -139, -197, 297}, { -19, -300, 511},
- { -63, -152, 139}, { 250, -289, 336},
- { 124, 339, -150}, { 34, 176, -208},
- { 171, 166, -116}, { 94, 38, -229},
- { 75, -65, -339}, { -78, -205, -385},
- { 0, -30, -163}, { -56, -110, -242},
- { 321, 244, 194}, { 505, 238, -1},
- { 317, 116, 65}, { 309, 88, -74},
- { 452, -51, -50}, { 334, -217, -290},
- { 211, 41, -152}, { 238, -55, -260}
-};
-
-static const int16_t dico23_isf[128][3] = {
- { -10, 151, 359}, { 136, 298, 223},
- { 255, -104, 290}, { 423, 6, 183},
- { -270, -269, -98}, { -52, -82, 13},
- { -82, -274, -97}, { 90, -246, -72},
- { -299, -70, 421}, { -88, 365, 430},
- { 187, -318, 381}, { 380, 37, 488},
- { -373, -316, 79}, { -308, -101, 5},
- { -135, -451, 8}, { 72, -421, -154},
- { 180, 170, -121}, { 62, 177, -40},
- { 326, 80, -105}, { 248, 263, -5},
- { -168, -181, -221}, { -2, -23, -158},
- { -14, -149, -121}, { 119, -91, -147},
- { 119, 332, -153}, { 49, 303, 34},
- { 442, -55, -69}, { 217, 454, 58},
- { -359, -187, -375}, { -42, 50, -274},
- { -8, -267, -249}, { 85, -86, -346},
- { -77, -40, 345}, { 89, 134, 219},
- { 156, -80, 160}, { 108, 40, 116},
- { -158, -206, 29}, { 5, -32, 175},
- { -65, -158, 146}, { 55, -78, 73},
- { -114, -222, 353}, { -47, 81, 211},
- { 49, -151, 268}, { 105, 4, 302},
- { -263, -132, 183}, { -151, -28, 201},
- { -177, -307, 166}, { 101, -221, 130},
- { 74, 58, -98}, { 32, 44, 13},
- { 194, 30, -142}, { 170, 96, 8},
- { -136, -119, -91}, { -65, 8, -55},
- { 3, -188, 12}, { 45, -63, -49},
- { 149, -21, -19}, { 24, 144, 95},
- { 254, -22, 60}, { 161, 196, 96},
- { -158, -61, 48}, { -70, 33, 82},
- { -23, -321, 58}, { 155, -147, 5},
- { -364, 328, 77}, { -21, 453, 173},
- { -108, 82, 630}, { 367, 263, 208},
- { -300, -62, -176}, { -205, 143, -158},
- { -169, -410, -264}, { 257, -269, -100},
- { -636, 289, -2}, { -292, 627, 173},
- { -382, -363, 387}, { 248, 524, 447},
- { -521, -111, -107}, { -395, 118, -274},
- { -343, -680, -125}, { -172, -447, -663},
- { 75, 148, -367}, { -79, 263, -94},
- { 249, 148, -286}, { 380, 271, -162},
- { -142, -4, -186}, { -57, 111, -125},
- { -35, -108, -254}, { 100, 29, -242},
- { -80, 303, -264}, { -78, 464, -57},
- { 248, -22, -494}, { 661, 662, 44},
- { -193, -40, -330}, { -178, 145, -337},
- { -90, -199, -400}, { -40, -23, -498},
- { -192, 114, 315}, { -41, 244, 190},
- { 88, -97, 485}, { 241, 80, 212},
- { -246, 40, 87}, { -156, 147, 134},
- { -2, -334, 239}, { 308, -203, 110},
- { -459, 251, 422}, { -218, 310, 228},
- { -86, -346, 654}, { 184, 175, 425},
- { -481, -63, 169}, { -349, 117, 188},
- { -125, -560, 310}, { 158, -416, 94},
- { 46, 171, -192}, { -63, 157, 14},
- { 256, -35, -271}, { 322, 123, 53},
- { -214, 4, -76}, { -156, 86, -18},
- { 128, -197, -232}, { 265, -90, -98},
- { -308, 332, -145}, { -131, 308, 58},
- { 509, 59, -339}, { 562, 196, -14},
- { -378, 100, -47}, { -234, 202, 1},
- { 104, -270, -493}, { 319, -210, -325}
-};
-
-static const int16_t dico24_isf[32][3] = {
- { -79, -89, -4}, { -171, 77, -211},
- { 160, -193, 98}, { 120, -103, 323},
- { 32, -22, -129}, { 72, 78, -268},
- { 182, -76, -66}, { 309, 99, -145},
- { -229, -157, -84}, { -383, 98, -71},
- { -90, -352, 12}, { -284, -178, 178},
- { -65, -125, -166}, { -87, -175, -351},
- { 42, -198, -48}, { 154, -140, -243},
- { -77, 18, 108}, { -39, 355, 91},
- { 87, 8, 155}, { -4, 158, 239},
- { 128, 95, -54}, { 7, 246, -124},
- { 258, 15, 89}, { 206, 216, 98},
- { -201, 9, 18}, { -312, 233, 204},
- { -39, -174, 155}, { -144, -9, 284},
- { -57, 70, -69}, { -157, 187, 18},
- { 54, -30, 23}, { 24, 135, 55}
-};
-
-static const int16_t dico25_isf[32][4] = {
- { 169, 142, -119, 115}, { 206, -20, 94, 226},
- { -106, 313, -21, 16}, { -62, 161, 71, 255},
- { -89, 101, -185, 125}, { 72, -30, -201, 344},
- { -258, 33, -8, 81}, { -104, -154, 72, 296},
- { 144, -68, -268, -25}, { 81, -78, -87, 106},
- { 22, 155, -186, -119}, { -46, -28, 27, 91},
- { -114, -37, -175, -33}, { -94, -222, -189, 122},
- { -132, -119, -191, -270}, { -172, -173, 18, -43},
- { 279, 135, -42, -128}, { 187, -86, 229, -138},
- { 159, 240, 140, 46}, { 69, 25, 227, 77},
- { 21, 115, 13, 8}, { 68, -248, 126, 81},
- { -150, 137, 207, -9}, { -154, -133, 289, 67},
- { 143, -37, -86, -326}, { 180, -32, 19, -23},
- { 26, 168, 116, -233}, { -32, -26, 118, -78},
- { 3, -8, -45, -115}, { 57, -215, -54, -83},
- { -209, 112, -22, -167}, { -91, -151, 168, -262}
-};
-
-static const int16_t dico21_isf_36b[128][5] = {
- { -52, -96, 212, 315, -73}, { 82, -204, 363, 136, -197},
- { -126, -331, 183, 218, 143}, { -49, -41, 557, 230, 72},
- { 2, -73, 163, 377, 221}, { 133, 111, 278, 215, -110},
- { -102, -20, 284, 113, 273}, { 84, 319, 290, 18, 85},
- { -25, -5, 125, 132, -204}, { -38, -5, 286, -9, -356},
- { -140, -256, 92, 117, -189}, { -144, 191, 313, 51, -98},
- { 167, -10, 44, 247, 36}, { 381, 197, 238, 74, 6},
- { 38, -408, 29, -3, -85}, { 92, 266, 157, -25, -200},
- { 161, -121, 70, 84, -140}, { -16, -86, 112, -94, -189},
- { -269, -270, 351, 107, -24}, { -68, -67, 492, -103, -155},
- { -53, -131, 62, 122, 10}, { 135, 84, 283, -55, -120},
- { -12, -219, 331, -81, 167}, { 220, -136, 147, -172, -42},
- { 140, -95, -109, -88, -194}, { 0, -2, -4, -33, -381},
- { -66, -217, 152, -186, -402}, { 244, 108, 156, -140, -395},
- { 113, -136, -196, 110, -24}, { 214, 118, 11, -64, -131},
- { -110, -286, -6, -332, 16}, { 94, 97, 79, -291, -205},
- { -5, -39, -20, 252, -96}, { 76, 174, 101, 163, 61},
- { -69, -239, -55, 399, 6}, { -115, 319, 164, 275, 196},
- { -15, 36, -47, 331, 121}, { 226, 209, 271, 325, 184},
- { 13, -80, -218, 471, 353}, { 288, 378, 16, -51, 251},
- { 174, 116, 52, 149, -279}, { 235, 276, 39, 120, -48},
- { 0, -108, -108, 241, -339}, { -93, 534, 45, 33, -87},
- { 194, 149, -71, 405, -44}, { 409, 370, 81, -186, -154},
- { 25, -102, -448, 124, -173}, { 22, 408, -110, -310, -214},
- { -26, 23, -83, 114, 14}, { -110, 164, 52, 223, -82},
- { 37, -25, -263, 306, -15}, { -466, 415, 292, 165, -18},
- { 29, -19, -171, 155, 182}, { 179, 144, -27, 231, 258},
- { -103, -247, -396, 238, 113}, { 375, -154, -109, -4, 156},
- { 98, 85, -292, -5, -124}, { 116, 139, -116, -98, -294},
- { -14, -83, -278, -117, -378}, { 106, 33, -106, -344, -484},
- { 119, 17, -412, 138, 166}, { 384, 101, -204, 88, -156},
- { -121, -284, -300, -1, -166}, { 280, 33, -152, -313, -81},
- { -37, 22, 229, 153, 37}, { -60, -83, 236, -8, -41},
- { -169, -228, 126, -20, 363}, { -235, 17, 364, -156, 156},
- { -25, -30, 72, 144, 156}, { 153, -26, 256, 97, 144},
- { -21, -37, 48, -65, 250}, { 63, 77, 273, -128, 124},
- { -129, -26, 40, 9, -115}, { -6, 82, 38, -90, -182},
- { -336, -13, 28, 158, 91}, { -30, 241, 137, -170, -17},
- { 146, 14, -11, 33, 61}, { 192, 197, 54, -84, 85},
- { 23, -200, -78, -29, 140}, { 122, 237, 106, -341, 136},
- { -57, -142, -85, -16, -74}, { -59, -90, -8, -187, -20},
- { -211, -267, 216, -179, -110}, { -50, -7, 220, -267, -70},
- { -57, -42, -17, -15, 71}, { 32, 21, 63, -137, 33},
- { -137, -175, 104, -68, 97}, { -67, -43, 133, -301, 221},
- { -116, -200, -81, -92, -272}, { -64, -41, -54, -244, -220},
- { -287, -242, -50, -87, -89}, { -245, 236, 102, -166, -295},
- { 66, 24, -162, -71, 95}, { 66, 136, -90, -220, -36},
- { -98, -161, -222, -188, 29}, { -18, 18, -19, -415, 9},
- { 49, 61, 100, 39, -56}, { -111, 82, 135, -31, 52},
- { -90, -153, -93, 189, 182}, { -214, 295, 119, -74, 284},
- { 2, 137, 37, 47, 182}, { 92, 117, 184, -53, 373},
- { -21, -14, -35, 136, 391}, { 146, 129, -164, -28, 333},
- { 92, 80, -84, 100, -134}, { -8, 217, -32, 3, -47},
- { -151, 251, -215, 142, 92}, { -224, 310, -172, -275, 98},
- { 159, 155, -177, 112, 53}, { 205, 27, 8, -240, 192},
- { 169, 120, -319, -201, 106}, { 11, 36, -86, -237, 455},
- { -109, -154, -163, 174, -55}, { -38, 32, -101, -78, -59},
- { -205, -321, -97, 69, 79}, { -310, 44, 18, -185, 34},
- { -115, -20, -148, -39, 203}, { -29, 154, -30, -158, 166},
- { -45, -131, -317, -24, 363}, { -165, -205, -112, -222, 265},
- { -32, -44, -150, 54, -193}, { -6, -38, -255, -169, -115},
- { -266, 87, -189, -36, -169}, { -60, -87, -266, -436, -170},
- { -68, -81, -278, 24, 38}, { -23, -19, -155, -256, 141},
- { -61, -226, -565, -175, 71}, { 9, -29, -237, -515, 263}
-};
-
-static const int16_t dico22_isf_36b[128][4] = {
- { -298, -6, 95, 31}, { -213, -87, -122, 261},
- { 4, -49, 208, 14}, { -129, -110, 30, 118},
- { -214, 258, 110, -235}, { -41, -18, -126, 120},
- { 103, 65, 127, -37}, { 126, -36, -24, 25},
- { -138, -67, -278, -186}, { -164, -194, -201, 78},
- { -211, -87, -51, -221}, { -174, -79, -94, -39},
- { 23, -6, -157, -240}, { 22, -110, -153, -68},
- { 148, -5, -2, -149}, { -1, -135, -39, -179},
- { 68, 360, -117, -15}, { 137, 47, -278, 146},
- { 136, 260, 135, 65}, { 61, 116, -45, 97},
- { 231, 379, 87, -120}, { 338, 177, -272, 3},
- { 266, 156, 28, -69}, { 260, 84, -85, 86},
- { -266, 154, -256, -182}, { -17, -65, -304, -6},
- { -40, 175, -151, -180}, { -27, 27, -87, -63},
- { 121, 114, -166, -469}, { 159, -66, -323, -231},
- { 214, 152, -141, -212}, { 137, 36, -184, -51},
- { -282, -237, 40, 10}, { -48, -235, -37, 251},
- { -54, -323, 136, 29}, { -88, -174, 213, 198},
- { -390, 99, -63, -375}, { 107, -169, -164, 424},
- { 69, -111, 141, -167}, { 74, -129, 65, 144},
- { -353, -207, -205, -109}, { -160, -386, -355, 98},
- { -176, -493, -20, -143}, { -252, -432, -2, 216},
- { -90, -174, -168, -411}, { 13, -284, -229, -160},
- { -87, -279, 34, -251}, { -75, -263, -58, -42},
- { 420, 53, -211, -358}, { 384, -35, -374, 396},
- { 68, -228, 323, -2}, { 167, -307, 192, 194},
- { 459, 329, -5, -332}, { 375, 79, -7, 313},
- { 282, -124, 200, -92}, { 271, -162, -70, 180},
- { -157, -298, -514, -309}, { 58, -163, -546, 18},
- { 124, -364, 167, -238}, { 83, -411, -117, 96},
- { 140, -112, -388, -624}, { 259, -133, -317, 41},
- { 163, -130, -64, -334}, { 226, -165, -124, -110},
- { -466, -61, 6, 229}, { -153, 205, -145, 242},
- { -159, 48, 195, 148}, { -58, 28, 31, 279},
- { -303, 185, 279, -4}, { -61, 197, 59, 86},
- { -114, 123, 168, -52}, { 35, 36, 100, 126},
- { -407, 102, -77, -40}, { -338, -1, -342, 156},
- { -179, 105, -34, -97}, { -185, 84, -35, 108},
- { -133, 107, -91, -357}, { -180, 54, -229, 24},
- { -44, 47, 47, -182}, { -66, 13, 45, 4},
- { -339, 251, 64, 226}, { -42, 101, -350, 275},
- { -99, 398, 142, 121}, { 111, 12, -102, 260},
- { 0, 505, 260, -94}, { 161, 285, -96, 224},
- { -4, 206, 314, 33}, { 167, 139, 88, 204},
- { -235, 316, -60, -25}, { -8, -150, -312, 201},
- { -36, 292, 61, -104}, { -40, 174, -162, 42},
- { -21, 402, -29, -351}, { 21, 152, -360, -93},
- { 57, 191, 212, -196}, { 76, 158, -21, -69},
- { -328, -185, 331, 119}, { -53, 285, 56, 337},
- { -107, -24, 405, 29}, { -18, 137, 272, 277},
- { -255, 22, 173, -191}, { 295, 322, 325, 302},
- { 21, -27, 332, -178}, { 119, 13, 271, 129},
- { -455, -180, 116, -191}, { -227, 62, -148, 524},
- { -176, -287, 282, -157}, { -243, 13, 199, 430},
- { -59, -49, 115, -365}, { 72, -172, -137, 93},
- { -138, -126, 141, -84}, { 5, -124, 38, -20},
- { -258, 311, 601, 213}, { 94, 130, -61, 502},
- { -1, -157, 485, 313}, { 146, -74, 158, 345},
- { 276, 135, 280, -57}, { 490, 252, 99, 43},
- { 267, -74, 429, 105}, { 278, -23, 119, 94},
- { -542, 488, 257, -115}, { -84, -244, -438, 478},
- { -113, -545, 387, 101}, { -95, -306, 111, 498},
- { 95, 166, 22, -301}, { 420, -15, -58, -78},
- { 270, 29, 122, -282}, { 160, -240, 50, -38}
-};
-
-static const int16_t dico23_isf_36b[64][7] = {
- { 81, -18, 68, -27, -122, -280, -4},
- { 45, -177, 209, -30, -136, -74, 131},
- { -44, 101, -75, -88, -48, -137, -54},
- { -245, -28, 63, -18, -112, -103, 58},
- { -79, -6, 220, -65, 114, -35, -50},
- { 109, -65, 143, -114, 129, 76, 125},
- { 166, 90, -61, -242, 186, -74, -43},
- { -46, -92, 49, -227, 24, -155, 39},
- { 67, 85, 99, -42, 53, -184, -281},
- { 142, -122, 0, 21, -142, -15, -17},
- { 223, 92, -21, -48, -82, -14, -167},
- { 51, -37, -243, -30, -90, 18, -56},
- { 54, 105, 74, 86, 69, 13, -101},
- { 196, 72, -89, 43, 65, 19, 39},
- { 121, 34, 131, -82, 25, 213, -156},
- { 101, -102, -136, -21, 57, 214, 22},
- { 36, -124, 205, 204, 58, -156, -83},
- { 83, -117, 137, 137, 85, 116, 44},
- { -92, -148, -68, 11, -102, -197, -220},
- { -76, -185, -58, 132, -26, -183, 85},
- { -7, -31, -2, 23, 205, -151, 10},
- { -27, -37, -5, -18, 292, 131, 1},
- { 117, -168, 9, -93, 80, -59, -125},
- { -182, -244, 98, -24, 135, -22, 94},
- { 221, 97, 106, 42, 43, -160, 83},
- { 25, -64, -21, 6, 14, -15, 154},
- { 126, 15, -140, 150, -10, -207, -114},
- { 79, -63, -211, -70, -28, -217, 165},
- { 46, 38, -22, 281, 132, -62, 109},
- { 112, 54, -112, -93, 208, 27, 296},
- { 115, 10, -147, 41, 216, 42, -276},
- { 50, -115, -254, 167, 117, -2, 61},
- { 17, 144, 34, -72, -186, -150, 272},
- { -29, -66, -89, -95, -149, 129, 251},
- { 122, 0, -50, -234, -91, 36, 26},
- { -105, -102, -88, -121, -236, -7, -11},
- { -204, 109, 5, -191, 105, -15, 163},
- { -80, 32, -24, -209, 41, 294, 70},
- { -106, -94, -204, -118, 120, -50, -37},
- { -82, -241, 46, -131, -29, 150, -55},
- { 33, 155, 120, -89, -8, 7, 62},
- { 213, 82, 61, 18, -161, 144, 152},
- { 30, 131, 65, -87, -255, -17, -107},
- { -8, 85, -64, 51, -162, 223, -53},
- { -134, 261, 69, -56, 218, 72, -111},
- { 2, 155, -113, -87, 49, 85, -28},
- { -163, 42, -1, -196, 7, 39, -245},
- { 14, -137, -79, 11, -160, 202, -293},
- { -94, 33, 208, 100, 56, -44, 326},
- { -78, -41, 232, 13, -142, 227, 80},
- { -16, -87, 201, 33, -133, 15, -183},
- { -58, -192, -47, 184, -128, 133, 99},
- { -205, 11, -155, 78, 52, 72, 141},
- { -246, 26, 99, 151, 59, 115, -64},
- { -79, -47, -16, -14, 6, 47, -43},
- { -72, -178, -27, 162, 112, 43, -174},
- { -175, 238, 186, 71, -54, -188, -76},
- { -225, 233, 39, -39, -158, 122, 44},
- { -26, 43, 84, 130, -93, -51, 22},
- { 3, 92, -150, 136, -182, -57, 97},
- { -131, 179, -78, 80, 91, -165, 90},
- { -2, 148, 15, 130, 65, 175, 117},
- { -138, 114, -137, 132, 3, -10, -186},
- { 140, -4, -37, 254, -62, 92, -109}
-};
-
-/** Means of ISF vectors in Q15 */
-static const int16_t isf_mean[LP_ORDER] = {
- 738, 1326, 2336, 3578, 4596, 5662, 6711, 7730,
- 8750, 9753, 10705, 11728, 12833, 13971, 15043, 4037
-};
-
-/** Initialization tables for the processed ISF vector in Q15 */
-static const int16_t isf_init[LP_ORDER] = {
- 1024, 2048, 3072, 4096, 5120, 6144, 7168, 8192,
- 9216, 10240, 11264, 12288, 13312, 14336, 15360, 3840
-};
-
-/** ISF/ISP interpolation coefficients for each subframe */
-static const float isfp_inter[4] = { 0.45, 0.8, 0.96, 1.0 };
-
-/** Coefficients for FIR interpolation of excitation vector
- * at pitch lag resulting the adaptive codebook vector */
-static const float ac_inter[65] = {
- 9.400024e-01,
- 8.563843e-01, 6.322632e-01, 3.375854e-01, 5.908203e-02,
- -1.310425e-01, -1.994019e-01, -1.585693e-01, -5.633545e-02,
- 4.760742e-02, 1.067505e-01, 1.036987e-01, 5.206299e-02,
- -1.519775e-02, -6.372070e-02, -7.366943e-02, -4.650879e-02,
- -9.765625e-04, 3.820801e-02, 5.316162e-02, 4.003906e-02,
- 9.338379e-03, -2.166748e-02, -3.778076e-02, -3.320312e-02,
- -1.300049e-02, 1.068115e-02, 2.587891e-02, 2.630615e-02,
- 1.379395e-02, -3.662109e-03, -1.678467e-02, -1.983643e-02,
- -1.275635e-02, -5.493164e-04, 1.007080e-02, 1.409912e-02,
- 1.068115e-02, 2.624512e-03, -5.371094e-03, -9.338379e-03,
- -8.117676e-03, -3.173828e-03, 2.319336e-03, 5.615234e-03,
- 5.554199e-03, 2.868652e-03, -6.103516e-04, -2.990723e-03,
- -3.356934e-03, -2.014160e-03, -1.220703e-04, 1.342773e-03,
- 1.708984e-03, 1.159668e-03, 2.441406e-04, -4.272461e-04,
- -6.103516e-04, -4.272461e-04, -1.220703e-04, 6.103516e-05,
- 1.220703e-04, 6.103516e-05, 0.000000e+00, 0.000000e+00
-};
-
-/** [i][j] is the number of pulses present in track j at mode i */
-static const uint8_t pulses_nb_per_mode_tr[][4] = {
- {1, 1, 0, 0}, {1, 1, 1, 1}, {2, 2, 2, 2},
- {3, 3, 2, 2}, {3, 3, 3, 3}, {4, 4, 4, 4},
- {5, 5, 4, 4}, {6, 6, 6, 6}, {6, 6, 6, 6}
-};
-
-/** Tables for decoding quantized gains { pitch (Q14), fixed factor (Q11) } */
-static const int16_t qua_gain_6b[64][2] = {
- { 1566, 1332}, { 1577, 3557},
- { 3071, 6490}, { 4193, 10163},
- { 4496, 2534}, { 5019, 4488},
- { 5586, 15614}, { 5725, 1422},
- { 6453, 580}, { 6724, 6831},
- { 7657, 3527}, { 8072, 2099},
- { 8232, 5319}, { 8827, 8775},
- { 9740, 2868}, { 9856, 1465},
- { 10087, 12488}, { 10241, 4453},
- { 10859, 6618}, { 11321, 3587},
- { 11417, 1800}, { 11643, 2428},
- { 11718, 988}, { 12312, 5093},
- { 12523, 8413}, { 12574, 26214},
- { 12601, 3396}, { 13172, 1623},
- { 13285, 2423}, { 13418, 6087},
- { 13459, 12810}, { 13656, 3607},
- { 14111, 4521}, { 14144, 1229},
- { 14425, 1871}, { 14431, 7234},
- { 14445, 2834}, { 14628, 10036},
- { 14860, 17496}, { 15161, 3629},
- { 15209, 5819}, { 15299, 2256},
- { 15518, 4722}, { 15663, 1060},
- { 15759, 7972}, { 15939, 11964},
- { 16020, 2996}, { 16086, 1707},
- { 16521, 4254}, { 16576, 6224},
- { 16894, 2380}, { 16906, 681},
- { 17213, 8406}, { 17610, 3418},
- { 17895, 5269}, { 18168, 11748},
- { 18230, 1575}, { 18607, 32767},
- { 18728, 21684}, { 19137, 2543},
- { 19422, 6577}, { 19446, 4097},
- { 19450, 9056}, { 20371, 14885}
-};
-
-static const int16_t qua_gain_7b[128][2] = {
- { 204, 441}, { 464, 1977},
- { 869, 1077}, { 1072, 3062},
- { 1281, 4759}, { 1647, 1539},
- { 1845, 7020}, { 1853, 634},
- { 1995, 2336}, { 2351, 15400},
- { 2661, 1165}, { 2702, 3900},
- { 2710, 10133}, { 3195, 1752},
- { 3498, 2624}, { 3663, 849},
- { 3984, 5697}, { 4214, 3399},
- { 4415, 1304}, { 4695, 2056},
- { 5376, 4558}, { 5386, 676},
- { 5518, 23554}, { 5567, 7794},
- { 5644, 3061}, { 5672, 1513},
- { 5957, 2338}, { 6533, 1060},
- { 6804, 5998}, { 6820, 1767},
- { 6937, 3837}, { 7277, 414},
- { 7305, 2665}, { 7466, 11304},
- { 7942, 794}, { 8007, 1982},
- { 8007, 1366}, { 8326, 3105},
- { 8336, 4810}, { 8708, 7954},
- { 8989, 2279}, { 9031, 1055},
- { 9247, 3568}, { 9283, 1631},
- { 9654, 6311}, { 9811, 2605},
- { 10120, 683}, { 10143, 4179},
- { 10245, 1946}, { 10335, 1218},
- { 10468, 9960}, { 10651, 3000},
- { 10951, 1530}, { 10969, 5290},
- { 11203, 2305}, { 11325, 3562},
- { 11771, 6754}, { 11839, 1849},
- { 11941, 4495}, { 11954, 1298},
- { 11975, 15223}, { 11977, 883},
- { 11986, 2842}, { 12438, 2141},
- { 12593, 3665}, { 12636, 8367},
- { 12658, 1594}, { 12886, 2628},
- { 12984, 4942}, { 13146, 1115},
- { 13224, 524}, { 13341, 3163},
- { 13399, 1923}, { 13549, 5961},
- { 13606, 1401}, { 13655, 2399},
- { 13782, 3909}, { 13868, 10923},
- { 14226, 1723}, { 14232, 2939},
- { 14278, 7528}, { 14439, 4598},
- { 14451, 984}, { 14458, 2265},
- { 14792, 1403}, { 14818, 3445},
- { 14899, 5709}, { 15017, 15362},
- { 15048, 1946}, { 15069, 2655},
- { 15405, 9591}, { 15405, 4079},
- { 15570, 7183}, { 15687, 2286},
- { 15691, 1624}, { 15699, 3068},
- { 15772, 5149}, { 15868, 1205},
- { 15970, 696}, { 16249, 3584},
- { 16338, 1917}, { 16424, 2560},
- { 16483, 4438}, { 16529, 6410},
- { 16620, 11966}, { 16839, 8780},
- { 17030, 3050}, { 17033, 18325},
- { 17092, 1568}, { 17123, 5197},
- { 17351, 2113}, { 17374, 980},
- { 17566, 26214}, { 17609, 3912},
- { 17639, 32767}, { 18151, 7871},
- { 18197, 2516}, { 18202, 5649},
- { 18679, 3283}, { 18930, 1370},
- { 19271, 13757}, { 19317, 4120},
- { 19460, 1973}, { 19654, 10018},
- { 19764, 6792}, { 19912, 5135},
- { 20040, 2841}, { 21234, 19833}
-};
-
-/** 4-tap moving average prediction coefficients in reverse order */
-static const float energy_pred_fac[4] = { 0.2, 0.3, 0.4, 0.5 };
-
-/** impulse response filter tables converted to float from Q15
- * used for anti-sparseness processing */
-static const float ir_filter_str[64] = {
- 6.159058e-01, 2.958069e-01, 9.979248e-02, -1.048889e-01,
- 8.740234e-02, -1.599121e-01, 4.849243e-02, -4.141235e-02,
- 1.831055e-02, 1.188049e-01, -4.568481e-02, -2.130127e-02,
- 3.671265e-02, -1.601868e-01, 3.659058e-02, 1.639099e-01,
- -4.541016e-02, -2.151489e-02, -8.810425e-02, 6.030273e-02,
- 2.740479e-02, 2.200317e-02, -1.182861e-01, 1.289978e-01,
- -1.560059e-01, 1.953125e-01, -3.149414e-02, -1.441956e-01,
- 1.249084e-01, -1.328125e-01, 9.780884e-02, 6.500244e-02,
- -6.091309e-02, -5.599976e-02, 8.081055e-02, -5.450439e-02,
- -1.239014e-02, 1.748657e-02, 7.580566e-02, -1.101074e-01,
- 9.579468e-02, -4.159546e-02, -7.830811e-02, 1.162109e-01,
- -1.950073e-02, -6.259155e-02, -1.651001e-02, 7.250977e-02,
- 1.199951e-01, -1.911011e-01, 4.370117e-02, -1.098938e-01,
- 1.492004e-01, 1.129150e-02, 1.730347e-02, -3.549194e-02,
- -8.709717e-02, 5.841064e-02, 1.190186e-03, -7.379150e-02,
- 1.054077e-01, 9.078979e-02, -1.227112e-01, 1.047058e-01
-};
-
-static const float ir_filter_mid[64] = {
- 7.354126e-01, 3.192139e-01, -1.606140e-01, -2.328491e-02,
- 6.250000e-02, -2.828979e-02, 5.349731e-02, -1.014099e-01,
- 6.750488e-02, 1.989746e-02, -6.549072e-02, 7.589722e-02,
- -1.080017e-01, 1.253967e-01, -6.430054e-02, -1.141357e-02,
- -1.910400e-02, 1.303101e-01, -1.673889e-01, 6.820679e-02,
- 5.670166e-02, -8.450317e-02, 2.270508e-02, 3.479004e-02,
- -2.328491e-02, -4.928589e-02, 1.239014e-01, -1.395874e-01,
- 9.100342e-02, -3.549194e-02, 2.230835e-02, -3.350830e-02,
- 2.450562e-02, 5.096436e-03, -2.178955e-02, 1.849365e-02,
- -1.708984e-02, 1.950073e-02, 1.312256e-03, -5.389404e-02,
- 9.851074e-02, -8.489990e-02, 2.029419e-02, 2.328491e-02,
- 7.110596e-03, -6.109619e-02, 3.939819e-02, 5.709839e-02,
- -1.058960e-01, 3.149414e-02, 8.270264e-02, -1.232910e-01,
- 1.105957e-01, -1.286011e-01, 1.614990e-01, -1.303101e-01,
- 4.769897e-02, 3.295898e-03, -1.770020e-02, 5.010986e-02,
- -7.501221e-02, 2.920532e-02, 1.660156e-02, 7.751465e-02
-};
-
-static const float * const ir_filters_lookup[2] = {
- ir_filter_str, ir_filter_mid
-};
-
-/** High-pass filters coefficients for 31 Hz and 400 Hz cutoff */
-static const float hpf_zeros[2] = { -2.0, 1.0 };
-static const float hpf_31_poles[2] = { -1.978881836, 0.979125977 };
-static const float hpf_31_gain = 0.989501953;
-
-static const float hpf_400_poles[2] = { -1.787109375, 0.864257812 };
-static const float hpf_400_gain = 0.893554687;
-
-/** Interpolation coefficients for 5/4 signal upsampling
- * Table from the reference source was reordered for efficiency */
-static const float upsample_fir[4][24] = {
- { -6.103516e-05, 7.324219e-04, -2.014160e-03, 4.150391e-03,
- -7.263184e-03, 1.165771e-02, -1.776123e-02, 2.624512e-02,
- -3.869629e-02, 5.877686e-02, -9.863281e-02, 2.314453e-01,
- 9.348755e-01, -1.523438e-01, 7.861328e-02, -4.937744e-02,
- 3.308105e-02, -2.252197e-02, 1.507568e-02, -9.765625e-03,
- 5.859375e-03, -3.173828e-03, 1.403809e-03, -3.662109e-04 },
- { -2.441406e-04, 1.464844e-03, -3.784180e-03, 7.568359e-03,
- -1.300049e-02, 2.062988e-02, -3.112793e-02, 4.589844e-02,
- -6.781006e-02, 1.042480e-01, -1.815186e-01, 5.016479e-01,
- 7.548828e-01, -2.094727e-01, 1.148071e-01, -7.348633e-02,
- 4.956055e-02, -3.369141e-02, 2.246094e-02, -1.434326e-02,
- 8.483887e-03, -4.455566e-03, 1.831055e-03, -4.272461e-04 },
- { -4.272461e-04, 1.831055e-03, -4.455566e-03, 8.483887e-03,
- -1.434326e-02, 2.246094e-02, -3.369141e-02, 4.956055e-02,
- -7.348633e-02, 1.148071e-01, -2.094727e-01, 7.548828e-01,
- 5.016479e-01, -1.815186e-01, 1.042480e-01, -6.781006e-02,
- 4.589844e-02, -3.112793e-02, 2.062988e-02, -1.300049e-02,
- 7.568359e-03, -3.784180e-03, 1.464844e-03, -2.441406e-04 },
- { -3.662109e-04, 1.403809e-03, -3.173828e-03, 5.859375e-03,
- -9.765625e-03, 1.507568e-02, -2.252197e-02, 3.308105e-02,
- -4.937744e-02, 7.861328e-02, -1.523438e-01, 9.348755e-01,
- 2.314453e-01, -9.863281e-02, 5.877686e-02, -3.869629e-02,
- 2.624512e-02, -1.776123e-02, 1.165771e-02, -7.263184e-03,
- 4.150391e-03, -2.014160e-03, 7.324219e-04, -6.103516e-05 }
-};
-
-/** High band quantized gains for 23k85 in Q14 */
-static const uint16_t qua_hb_gain[16] = {
- 3624, 4673, 5597, 6479, 7425, 8378, 9324, 10264,
- 11210, 12206, 13391, 14844, 16770, 19655, 24289, 32728
-};
-
-/** High-band post-processing FIR filters coefficients from Q15 */
-static const float bpf_6_7_coef[31] = { // band pass, 6kHz and 7kHz cutoffs
- -2.441406e-04, 3.585815e-04, 2.441406e-04,
- -2.059937e-04, -2.815248e-03, 8.560180e-03,
- -1.084137e-02, 0.000000e+00, 2.897645e-02,
- -6.774902e-02, 9.421540e-02, -8.380128e-02,
- 2.706910e-02, 5.924987e-02, -1.373367e-01,
- 1.687469e-01,
- -1.373367e-01, 5.924987e-02, 2.706910e-02,
- -8.380128e-02, 9.421540e-02, -6.774902e-02,
- 2.897645e-02, 0.000000e+00, -1.084137e-02,
- 8.560180e-03, -2.815248e-03, -2.059937e-04,
- 2.441406e-04, 3.585815e-04, -2.441406e-04
-};
-
-static const float lpf_7_coef[31] = { // low pass, 7kHz cutoff
- -6.408691e-04, 1.434326e-03, -2.716064e-03,
- 4.455566e-03, -6.195068e-03, 6.988525e-03,
- -5.401611e-03, 0.000000e+00, 1.022339e-02,
- -2.560425e-02, 4.531860e-02, -6.747437e-02,
- 8.944702e-02, -1.080933e-01, 1.206360e-01,
- 8.753052e-01,
- 1.206360e-01, -1.080933e-01, 8.944702e-02,
- -6.747437e-02, 4.531860e-02, -2.560425e-02,
- 1.022339e-02, 0.000000e+00, -5.401611e-03,
- 6.988525e-03, -6.195068e-03, 4.455566e-03,
- -2.716064e-03, 1.434326e-03, -6.408691e-04
-};
-
-/** Core frame sizes in each mode */
-static const uint16_t cf_sizes_wb[] = {
- 132, 177, 253, 285, 317, 365, 397, 461, 477,
- 40 /// SID/comfort noise frame
-};
-
-#endif /* AVCODEC_AMRWBDATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/amrwbdec.c b/src/thirdparty/ffmpeg/libavcodec/amrwbdec.c
deleted file mode 100644
index ffea0b22d..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/amrwbdec.c
+++ /dev/null
@@ -1,1281 +0,0 @@
-/*
- * AMR wideband decoder
- * Copyright (c) 2010 Marcelo Galvao Povoa
- *
- * 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
- * AMR wideband decoder
- */
-
-#include "libavutil/channel_layout.h"
-#include "libavutil/common.h"
-#include "libavutil/float_dsp.h"
-#include "libavutil/lfg.h"
-
-#include "avcodec.h"
-#include "lsp.h"
-#include "celp_filters.h"
-#include "celp_math.h"
-#include "acelp_filters.h"
-#include "acelp_vectors.h"
-#include "acelp_pitch_delay.h"
-#include "internal.h"
-
-#define AMR_USE_16BIT_TABLES
-#include "amr.h"
-
-#include "amrwbdata.h"
-#include "mips/amrwbdec_mips.h"
-
-typedef struct {
- AMRWBFrame frame; ///< AMRWB parameters decoded from bitstream
- enum Mode fr_cur_mode; ///< mode index of current frame
- uint8_t fr_quality; ///< frame quality index (FQI)
- float isf_cur[LP_ORDER]; ///< working ISF vector from current frame
- float isf_q_past[LP_ORDER]; ///< quantized ISF vector of the previous frame
- float isf_past_final[LP_ORDER]; ///< final processed ISF vector of the previous frame
- double isp[4][LP_ORDER]; ///< ISP vectors from current frame
- double isp_sub4_past[LP_ORDER]; ///< ISP vector for the 4th subframe of the previous frame
-
- float lp_coef[4][LP_ORDER]; ///< Linear Prediction Coefficients from ISP vector
-
- uint8_t base_pitch_lag; ///< integer part of pitch lag for the next relative subframe
- uint8_t pitch_lag_int; ///< integer part of pitch lag of the previous subframe
-
- float excitation_buf[AMRWB_P_DELAY_MAX + LP_ORDER + 2 + AMRWB_SFR_SIZE]; ///< current excitation and all necessary excitation history
- float *excitation; ///< points to current excitation in excitation_buf[]
-
- float pitch_vector[AMRWB_SFR_SIZE]; ///< adaptive codebook (pitch) vector for current subframe
- float fixed_vector[AMRWB_SFR_SIZE]; ///< algebraic codebook (fixed) vector for current subframe
-
- float prediction_error[4]; ///< quantified prediction errors {20log10(^gamma_gc)} for previous four subframes
- float pitch_gain[6]; ///< quantified pitch gains for the current and previous five subframes
- float fixed_gain[2]; ///< quantified fixed gains for the current and previous subframes
-
- float tilt_coef; ///< {beta_1} related to the voicing of the previous subframe
-
- float prev_sparse_fixed_gain; ///< previous fixed gain; used by anti-sparseness to determine "onset"
- uint8_t prev_ir_filter_nr; ///< previous impulse response filter "impNr": 0 - strong, 1 - medium, 2 - none
- float prev_tr_gain; ///< previous initial gain used by noise enhancer for threshold
-
- float samples_az[LP_ORDER + AMRWB_SFR_SIZE]; ///< low-band samples and memory from synthesis at 12.8kHz
- float samples_up[UPS_MEM_SIZE + AMRWB_SFR_SIZE]; ///< low-band samples and memory processed for upsampling
- float samples_hb[LP_ORDER_16k + AMRWB_SFR_SIZE_16k]; ///< high-band samples and memory from synthesis at 16kHz
-
- float hpf_31_mem[2], hpf_400_mem[2]; ///< previous values in the high pass filters
- float demph_mem[1]; ///< previous value in the de-emphasis filter
- float bpf_6_7_mem[HB_FIR_SIZE]; ///< previous values in the high-band band pass filter
- float lpf_7_mem[HB_FIR_SIZE]; ///< previous values in the high-band low pass filter
-
- AVLFG prng; ///< random number generator for white noise excitation
- uint8_t first_frame; ///< flag active during decoding of the first frame
- ACELPFContext acelpf_ctx; ///< context for filters for ACELP-based codecs
- ACELPVContext acelpv_ctx; ///< context for vector operations for ACELP-based codecs
- CELPFContext celpf_ctx; ///< context for filters for CELP-based codecs
- CELPMContext celpm_ctx; ///< context for fixed point math operations
-
-} AMRWBContext;
-
-static av_cold int amrwb_decode_init(AVCodecContext *avctx)
-{
- AMRWBContext *ctx = avctx->priv_data;
- int i;
-
- if (avctx->channels > 1) {
- av_log_missing_feature(avctx, "multi-channel AMR", 0);
- return AVERROR_PATCHWELCOME;
- }
-
- avctx->channels = 1;
- avctx->channel_layout = AV_CH_LAYOUT_MONO;
- if (!avctx->sample_rate)
- avctx->sample_rate = 16000;
- avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
-
- av_lfg_init(&ctx->prng, 1);
-
- ctx->excitation = &ctx->excitation_buf[AMRWB_P_DELAY_MAX + LP_ORDER + 1];
- ctx->first_frame = 1;
-
- for (i = 0; i < LP_ORDER; i++)
- ctx->isf_past_final[i] = isf_init[i] * (1.0f / (1 << 15));
-
- for (i = 0; i < 4; i++)
- ctx->prediction_error[i] = MIN_ENERGY;
-
- ff_acelp_filter_init(&ctx->acelpf_ctx);
- ff_acelp_vectors_init(&ctx->acelpv_ctx);
- ff_celp_filter_init(&ctx->celpf_ctx);
- ff_celp_math_init(&ctx->celpm_ctx);
-
- return 0;
-}
-
-/**
- * Decode the frame header in the "MIME/storage" format. This format
- * is simpler and does not carry the auxiliary frame information.
- *
- * @param[in] ctx The Context
- * @param[in] buf Pointer to the input buffer
- *
- * @return The decoded header length in bytes
- */
-static int decode_mime_header(AMRWBContext *ctx, const uint8_t *buf)
-{
- /* Decode frame header (1st octet) */
- ctx->fr_cur_mode = buf[0] >> 3 & 0x0F;
- ctx->fr_quality = (buf[0] & 0x4) == 0x4;
-
- return 1;
-}
-
-/**
- * Decode quantized ISF vectors using 36-bit indexes (6K60 mode only).
- *
- * @param[in] ind Array of 5 indexes
- * @param[out] isf_q Buffer for isf_q[LP_ORDER]
- *
- */
-static void decode_isf_indices_36b(uint16_t *ind, float *isf_q)
-{
- int i;
-
- for (i = 0; i < 9; i++)
- isf_q[i] = dico1_isf[ind[0]][i] * (1.0f / (1 << 15));
-
- for (i = 0; i < 7; i++)
- isf_q[i + 9] = dico2_isf[ind[1]][i] * (1.0f / (1 << 15));
-
- for (i = 0; i < 5; i++)
- isf_q[i] += dico21_isf_36b[ind[2]][i] * (1.0f / (1 << 15));
-
- for (i = 0; i < 4; i++)
- isf_q[i + 5] += dico22_isf_36b[ind[3]][i] * (1.0f / (1 << 15));
-
- for (i = 0; i < 7; i++)
- isf_q[i + 9] += dico23_isf_36b[ind[4]][i] * (1.0f / (1 << 15));
-}
-
-/**
- * Decode quantized ISF vectors using 46-bit indexes (except 6K60 mode).
- *
- * @param[in] ind Array of 7 indexes
- * @param[out] isf_q Buffer for isf_q[LP_ORDER]
- *
- */
-static void decode_isf_indices_46b(uint16_t *ind, float *isf_q)
-{
- int i;
-
- for (i = 0; i < 9; i++)
- isf_q[i] = dico1_isf[ind[0]][i] * (1.0f / (1 << 15));
-
- for (i = 0; i < 7; i++)
- isf_q[i + 9] = dico2_isf[ind[1]][i] * (1.0f / (1 << 15));
-
- for (i = 0; i < 3; i++)
- isf_q[i] += dico21_isf[ind[2]][i] * (1.0f / (1 << 15));
-
- for (i = 0; i < 3; i++)
- isf_q[i + 3] += dico22_isf[ind[3]][i] * (1.0f / (1 << 15));
-
- for (i = 0; i < 3; i++)
- isf_q[i + 6] += dico23_isf[ind[4]][i] * (1.0f / (1 << 15));
-
- for (i = 0; i < 3; i++)
- isf_q[i + 9] += dico24_isf[ind[5]][i] * (1.0f / (1 << 15));
-
- for (i = 0; i < 4; i++)
- isf_q[i + 12] += dico25_isf[ind[6]][i] * (1.0f / (1 << 15));
-}
-
-/**
- * Apply mean and past ISF values using the prediction factor.
- * Updates past ISF vector.
- *
- * @param[in,out] isf_q Current quantized ISF
- * @param[in,out] isf_past Past quantized ISF
- *
- */
-static void isf_add_mean_and_past(float *isf_q, float *isf_past)
-{
- int i;
- float tmp;
-
- for (i = 0; i < LP_ORDER; i++) {
- tmp = isf_q[i];
- isf_q[i] += isf_mean[i] * (1.0f / (1 << 15));
- isf_q[i] += PRED_FACTOR * isf_past[i];
- isf_past[i] = tmp;
- }
-}
-
-/**
- * Interpolate the fourth ISP vector from current and past frames
- * to obtain an ISP vector for each subframe.
- *
- * @param[in,out] isp_q ISPs for each subframe
- * @param[in] isp4_past Past ISP for subframe 4
- */
-static void interpolate_isp(double isp_q[4][LP_ORDER], const double *isp4_past)
-{
- int i, k;
-
- for (k = 0; k < 3; k++) {
- float c = isfp_inter[k];
- for (i = 0; i < LP_ORDER; i++)
- isp_q[k][i] = (1.0 - c) * isp4_past[i] + c * isp_q[3][i];
- }
-}
-
-/**
- * Decode an adaptive codebook index into pitch lag (except 6k60, 8k85 modes).
- * Calculate integer lag and fractional lag always using 1/4 resolution.
- * In 1st and 3rd subframes the index is relative to last subframe integer lag.
- *
- * @param[out] lag_int Decoded integer pitch lag
- * @param[out] lag_frac Decoded fractional pitch lag
- * @param[in] pitch_index Adaptive codebook pitch index
- * @param[in,out] base_lag_int Base integer lag used in relative subframes
- * @param[in] subframe Current subframe index (0 to 3)
- */
-static void decode_pitch_lag_high(int *lag_int, int *lag_frac, int pitch_index,
- uint8_t *base_lag_int, int subframe)
-{
- if (subframe == 0 || subframe == 2) {
- if (pitch_index < 376) {
- *lag_int = (pitch_index + 137) >> 2;
- *lag_frac = pitch_index - (*lag_int << 2) + 136;
- } else if (pitch_index < 440) {
- *lag_int = (pitch_index + 257 - 376) >> 1;
- *lag_frac = (pitch_index - (*lag_int << 1) + 256 - 376) << 1;
- /* the actual resolution is 1/2 but expressed as 1/4 */
- } else {
- *lag_int = pitch_index - 280;
- *lag_frac = 0;
- }
- /* minimum lag for next subframe */
- *base_lag_int = av_clip(*lag_int - 8 - (*lag_frac < 0),
- AMRWB_P_DELAY_MIN, AMRWB_P_DELAY_MAX - 15);
- // XXX: the spec states clearly that *base_lag_int should be
- // the nearest integer to *lag_int (minus 8), but the ref code
- // actually always uses its floor, I'm following the latter
- } else {
- *lag_int = (pitch_index + 1) >> 2;
- *lag_frac = pitch_index - (*lag_int << 2);
- *lag_int += *base_lag_int;
- }
-}
-
-/**
- * Decode an adaptive codebook index into pitch lag for 8k85 and 6k60 modes.
- * The description is analogous to decode_pitch_lag_high, but in 6k60 the
- * relative index is used for all subframes except the first.
- */
-static void decode_pitch_lag_low(int *lag_int, int *lag_frac, int pitch_index,
- uint8_t *base_lag_int, int subframe, enum Mode mode)
-{
- if (subframe == 0 || (subframe == 2 && mode != MODE_6k60)) {
- if (pitch_index < 116) {
- *lag_int = (pitch_index + 69) >> 1;
- *lag_frac = (pitch_index - (*lag_int << 1) + 68) << 1;
- } else {
- *lag_int = pitch_index - 24;
- *lag_frac = 0;
- }
- // XXX: same problem as before
- *base_lag_int = av_clip(*lag_int - 8 - (*lag_frac < 0),
- AMRWB_P_DELAY_MIN, AMRWB_P_DELAY_MAX - 15);
- } else {
- *lag_int = (pitch_index + 1) >> 1;
- *lag_frac = (pitch_index - (*lag_int << 1)) << 1;
- *lag_int += *base_lag_int;
- }
-}
-
-/**
- * Find the pitch vector by interpolating the past excitation at the
- * pitch delay, which is obtained in this function.
- *
- * @param[in,out] ctx The context
- * @param[in] amr_subframe Current subframe data
- * @param[in] subframe Current subframe index (0 to 3)
- */
-static void decode_pitch_vector(AMRWBContext *ctx,
- const AMRWBSubFrame *amr_subframe,
- const int subframe)
-{
- int pitch_lag_int, pitch_lag_frac;
- int i;
- float *exc = ctx->excitation;
- enum Mode mode = ctx->fr_cur_mode;
-
- if (mode <= MODE_8k85) {
- decode_pitch_lag_low(&pitch_lag_int, &pitch_lag_frac, amr_subframe->adap,
- &ctx->base_pitch_lag, subframe, mode);
- } else
- decode_pitch_lag_high(&pitch_lag_int, &pitch_lag_frac, amr_subframe->adap,
- &ctx->base_pitch_lag, subframe);
-
- ctx->pitch_lag_int = pitch_lag_int;
- pitch_lag_int += pitch_lag_frac > 0;
-
- /* Calculate the pitch vector by interpolating the past excitation at the
- pitch lag using a hamming windowed sinc function */
- ctx->acelpf_ctx.acelp_interpolatef(exc,
- exc + 1 - pitch_lag_int,
- ac_inter, 4,
- pitch_lag_frac + (pitch_lag_frac > 0 ? 0 : 4),
- LP_ORDER, AMRWB_SFR_SIZE + 1);
-
- /* Check which pitch signal path should be used
- * 6k60 and 8k85 modes have the ltp flag set to 0 */
- if (amr_subframe->ltp) {
- memcpy(ctx->pitch_vector, exc, AMRWB_SFR_SIZE * sizeof(float));
- } else {
- for (i = 0; i < AMRWB_SFR_SIZE; i++)
- ctx->pitch_vector[i] = 0.18 * exc[i - 1] + 0.64 * exc[i] +
- 0.18 * exc[i + 1];
- memcpy(exc, ctx->pitch_vector, AMRWB_SFR_SIZE * sizeof(float));
- }
-}
-
-/** Get x bits in the index interval [lsb,lsb+len-1] inclusive */
-#define BIT_STR(x,lsb,len) (((x) >> (lsb)) & ((1 << (len)) - 1))
-
-/** Get the bit at specified position */
-#define BIT_POS(x, p) (((x) >> (p)) & 1)
-
-/**
- * The next six functions decode_[i]p_track decode exactly i pulses
- * positions and amplitudes (-1 or 1) in a subframe track using
- * an encoded pulse indexing (TS 26.190 section 5.8.2).
- *
- * The results are given in out[], in which a negative number means
- * amplitude -1 and vice versa (i.e., ampl(x) = x / abs(x) ).
- *
- * @param[out] out Output buffer (writes i elements)
- * @param[in] code Pulse index (no. of bits varies, see below)
- * @param[in] m (log2) Number of potential positions
- * @param[in] off Offset for decoded positions
- */
-static inline void decode_1p_track(int *out, int code, int m, int off)
-{
- int pos = BIT_STR(code, 0, m) + off; ///code: m+1 bits
-
- out[0] = BIT_POS(code, m) ? -pos : pos;
-}
-
-static inline void decode_2p_track(int *out, int code, int m, int off) ///code: 2m+1 bits
-{
- int pos0 = BIT_STR(code, m, m) + off;
- int pos1 = BIT_STR(code, 0, m) + off;
-
- out[0] = BIT_POS(code, 2*m) ? -pos0 : pos0;
- out[1] = BIT_POS(code, 2*m) ? -pos1 : pos1;
- out[1] = pos0 > pos1 ? -out[1] : out[1];
-}
-
-static void decode_3p_track(int *out, int code, int m, int off) ///code: 3m+1 bits
-{
- int half_2p = BIT_POS(code, 2*m - 1) << (m - 1);
-
- decode_2p_track(out, BIT_STR(code, 0, 2*m - 1),
- m - 1, off + half_2p);
- decode_1p_track(out + 2, BIT_STR(code, 2*m, m + 1), m, off);
-}
-
-static void decode_4p_track(int *out, int code, int m, int off) ///code: 4m bits
-{
- int half_4p, subhalf_2p;
- int b_offset = 1 << (m - 1);
-
- switch (BIT_STR(code, 4*m - 2, 2)) { /* case ID (2 bits) */
- case 0: /* 0 pulses in A, 4 pulses in B or vice versa */
- half_4p = BIT_POS(code, 4*m - 3) << (m - 1); // which has 4 pulses
- subhalf_2p = BIT_POS(code, 2*m - 3) << (m - 2);
-
- decode_2p_track(out, BIT_STR(code, 0, 2*m - 3),
- m - 2, off + half_4p + subhalf_2p);
- decode_2p_track(out + 2, BIT_STR(code, 2*m - 2, 2*m - 1),
- m - 1, off + half_4p);
- break;
- case 1: /* 1 pulse in A, 3 pulses in B */
- decode_1p_track(out, BIT_STR(code, 3*m - 2, m),
- m - 1, off);
- decode_3p_track(out + 1, BIT_STR(code, 0, 3*m - 2),
- m - 1, off + b_offset);
- break;
- case 2: /* 2 pulses in each half */
- decode_2p_track(out, BIT_STR(code, 2*m - 1, 2*m - 1),
- m - 1, off);
- decode_2p_track(out + 2, BIT_STR(code, 0, 2*m - 1),
- m - 1, off + b_offset);
- break;
- case 3: /* 3 pulses in A, 1 pulse in B */
- decode_3p_track(out, BIT_STR(code, m, 3*m - 2),
- m - 1, off);
- decode_1p_track(out + 3, BIT_STR(code, 0, m),
- m - 1, off + b_offset);
- break;
- }
-}
-
-static void decode_5p_track(int *out, int code, int m, int off) ///code: 5m bits
-{
- int half_3p = BIT_POS(code, 5*m - 1) << (m - 1);
-
- decode_3p_track(out, BIT_STR(code, 2*m + 1, 3*m - 2),
- m - 1, off + half_3p);
-
- decode_2p_track(out + 3, BIT_STR(code, 0, 2*m + 1), m, off);
-}
-
-static void decode_6p_track(int *out, int code, int m, int off) ///code: 6m-2 bits
-{
- int b_offset = 1 << (m - 1);
- /* which half has more pulses in cases 0 to 2 */
- int half_more = BIT_POS(code, 6*m - 5) << (m - 1);
- int half_other = b_offset - half_more;
-
- switch (BIT_STR(code, 6*m - 4, 2)) { /* case ID (2 bits) */
- case 0: /* 0 pulses in A, 6 pulses in B or vice versa */
- decode_1p_track(out, BIT_STR(code, 0, m),
- m - 1, off + half_more);
- decode_5p_track(out + 1, BIT_STR(code, m, 5*m - 5),
- m - 1, off + half_more);
- break;
- case 1: /* 1 pulse in A, 5 pulses in B or vice versa */
- decode_1p_track(out, BIT_STR(code, 0, m),
- m - 1, off + half_other);
- decode_5p_track(out + 1, BIT_STR(code, m, 5*m - 5),
- m - 1, off + half_more);
- break;
- case 2: /* 2 pulses in A, 4 pulses in B or vice versa */
- decode_2p_track(out, BIT_STR(code, 0, 2*m - 1),
- m - 1, off + half_other);
- decode_4p_track(out + 2, BIT_STR(code, 2*m - 1, 4*m - 4),
- m - 1, off + half_more);
- break;
- case 3: /* 3 pulses in A, 3 pulses in B */
- decode_3p_track(out, BIT_STR(code, 3*m - 2, 3*m - 2),
- m - 1, off);
- decode_3p_track(out + 3, BIT_STR(code, 0, 3*m - 2),
- m - 1, off + b_offset);
- break;
- }
-}
-
-/**
- * Decode the algebraic codebook index to pulse positions and signs,
- * then construct the algebraic codebook vector.
- *
- * @param[out] fixed_vector Buffer for the fixed codebook excitation
- * @param[in] pulse_hi MSBs part of the pulse index array (higher modes only)
- * @param[in] pulse_lo LSBs part of the pulse index array
- * @param[in] mode Mode of the current frame
- */
-static void decode_fixed_vector(float *fixed_vector, const uint16_t *pulse_hi,
- const uint16_t *pulse_lo, const enum Mode mode)
-{
- /* sig_pos stores for each track the decoded pulse position indexes
- * (1-based) multiplied by its corresponding amplitude (+1 or -1) */
- int sig_pos[4][6];
- int spacing = (mode == MODE_6k60) ? 2 : 4;
- int i, j;
-
- switch (mode) {
- case MODE_6k60:
- for (i = 0; i < 2; i++)
- decode_1p_track(sig_pos[i], pulse_lo[i], 5, 1);
- break;
- case MODE_8k85:
- for (i = 0; i < 4; i++)
- decode_1p_track(sig_pos[i], pulse_lo[i], 4, 1);
- break;
- case MODE_12k65:
- for (i = 0; i < 4; i++)
- decode_2p_track(sig_pos[i], pulse_lo[i], 4, 1);
- break;
- case MODE_14k25:
- for (i = 0; i < 2; i++)
- decode_3p_track(sig_pos[i], pulse_lo[i], 4, 1);
- for (i = 2; i < 4; i++)
- decode_2p_track(sig_pos[i], pulse_lo[i], 4, 1);
- break;
- case MODE_15k85:
- for (i = 0; i < 4; i++)
- decode_3p_track(sig_pos[i], pulse_lo[i], 4, 1);
- break;
- case MODE_18k25:
- for (i = 0; i < 4; i++)
- decode_4p_track(sig_pos[i], (int) pulse_lo[i] +
- ((int) pulse_hi[i] << 14), 4, 1);
- break;
- case MODE_19k85:
- for (i = 0; i < 2; i++)
- decode_5p_track(sig_pos[i], (int) pulse_lo[i] +
- ((int) pulse_hi[i] << 10), 4, 1);
- for (i = 2; i < 4; i++)
- decode_4p_track(sig_pos[i], (int) pulse_lo[i] +
- ((int) pulse_hi[i] << 14), 4, 1);
- break;
- case MODE_23k05:
- case MODE_23k85:
- for (i = 0; i < 4; i++)
- decode_6p_track(sig_pos[i], (int) pulse_lo[i] +
- ((int) pulse_hi[i] << 11), 4, 1);
- break;
- }
-
- memset(fixed_vector, 0, sizeof(float) * AMRWB_SFR_SIZE);
-
- for (i = 0; i < 4; i++)
- for (j = 0; j < pulses_nb_per_mode_tr[mode][i]; j++) {
- int pos = (FFABS(sig_pos[i][j]) - 1) * spacing + i;
-
- fixed_vector[pos] += sig_pos[i][j] < 0 ? -1.0 : 1.0;
- }
-}
-
-/**
- * Decode pitch gain and fixed gain correction factor.
- *
- * @param[in] vq_gain Vector-quantized index for gains
- * @param[in] mode Mode of the current frame
- * @param[out] fixed_gain_factor Decoded fixed gain correction factor
- * @param[out] pitch_gain Decoded pitch gain
- */
-static void decode_gains(const uint8_t vq_gain, const enum Mode mode,
- float *fixed_gain_factor, float *pitch_gain)
-{
- const int16_t *gains = (mode <= MODE_8k85 ? qua_gain_6b[vq_gain] :
- qua_gain_7b[vq_gain]);
-
- *pitch_gain = gains[0] * (1.0f / (1 << 14));
- *fixed_gain_factor = gains[1] * (1.0f / (1 << 11));
-}
-
-/**
- * Apply pitch sharpening filters to the fixed codebook vector.
- *
- * @param[in] ctx The context
- * @param[in,out] fixed_vector Fixed codebook excitation
- */
-// XXX: Spec states this procedure should be applied when the pitch
-// lag is less than 64, but this checking seems absent in reference and AMR-NB
-static void pitch_sharpening(AMRWBContext *ctx, float *fixed_vector)
-{
- int i;
-
- /* Tilt part */
- for (i = AMRWB_SFR_SIZE - 1; i != 0; i--)
- fixed_vector[i] -= fixed_vector[i - 1] * ctx->tilt_coef;
-
- /* Periodicity enhancement part */
- for (i = ctx->pitch_lag_int; i < AMRWB_SFR_SIZE; i++)
- fixed_vector[i] += fixed_vector[i - ctx->pitch_lag_int] * 0.85;
-}
-
-/**
- * Calculate the voicing factor (-1.0 = unvoiced to 1.0 = voiced).
- *
- * @param[in] p_vector, f_vector Pitch and fixed excitation vectors
- * @param[in] p_gain, f_gain Pitch and fixed gains
- * @param[in] ctx The context
- */
-// XXX: There is something wrong with the precision here! The magnitudes
-// of the energies are not correct. Please check the reference code carefully
-static float voice_factor(float *p_vector, float p_gain,
- float *f_vector, float f_gain,
- CELPMContext *ctx)
-{
- double p_ener = (double) ctx->dot_productf(p_vector, p_vector,
- AMRWB_SFR_SIZE) *
- p_gain * p_gain;
- double f_ener = (double) ctx->dot_productf(f_vector, f_vector,
- AMRWB_SFR_SIZE) *
- f_gain * f_gain;
-
- return (p_ener - f_ener) / (p_ener + f_ener);
-}
-
-/**
- * Reduce fixed vector sparseness by smoothing with one of three IR filters,
- * also known as "adaptive phase dispersion".
- *
- * @param[in] ctx The context
- * @param[in,out] fixed_vector Unfiltered fixed vector
- * @param[out] buf Space for modified vector if necessary
- *
- * @return The potentially overwritten filtered fixed vector address
- */
-static float *anti_sparseness(AMRWBContext *ctx,
- float *fixed_vector, float *buf)
-{
- int ir_filter_nr;
-
- if (ctx->fr_cur_mode > MODE_8k85) // no filtering in higher modes
- return fixed_vector;
-
- if (ctx->pitch_gain[0] < 0.6) {
- ir_filter_nr = 0; // strong filtering
- } else if (ctx->pitch_gain[0] < 0.9) {
- ir_filter_nr = 1; // medium filtering
- } else
- ir_filter_nr = 2; // no filtering
-
- /* detect 'onset' */
- if (ctx->fixed_gain[0] > 3.0 * ctx->fixed_gain[1]) {
- if (ir_filter_nr < 2)
- ir_filter_nr++;
- } else {
- int i, count = 0;
-
- for (i = 0; i < 6; i++)
- if (ctx->pitch_gain[i] < 0.6)
- count++;
-
- if (count > 2)
- ir_filter_nr = 0;
-
- if (ir_filter_nr > ctx->prev_ir_filter_nr + 1)
- ir_filter_nr--;
- }
-
- /* update ir filter strength history */
- ctx->prev_ir_filter_nr = ir_filter_nr;
-
- ir_filter_nr += (ctx->fr_cur_mode == MODE_8k85);
-
- if (ir_filter_nr < 2) {
- int i;
- const float *coef = ir_filters_lookup[ir_filter_nr];
-
- /* Circular convolution code in the reference
- * decoder was modified to avoid using one
- * extra array. The filtered vector is given by:
- *
- * c2(n) = sum(i,0,len-1){ c(i) * coef( (n - i + len) % len ) }
- */
-
- memset(buf, 0, sizeof(float) * AMRWB_SFR_SIZE);
- for (i = 0; i < AMRWB_SFR_SIZE; i++)
- if (fixed_vector[i])
- ff_celp_circ_addf(buf, buf, coef, i, fixed_vector[i],
- AMRWB_SFR_SIZE);
- fixed_vector = buf;
- }
-
- return fixed_vector;
-}
-
-/**
- * Calculate a stability factor {teta} based on distance between
- * current and past isf. A value of 1 shows maximum signal stability.
- */
-static float stability_factor(const float *isf, const float *isf_past)
-{
- int i;
- float acc = 0.0;
-
- for (i = 0; i < LP_ORDER - 1; i++)
- acc += (isf[i] - isf_past[i]) * (isf[i] - isf_past[i]);
-
- // XXX: This part is not so clear from the reference code
- // the result is more accurate changing the "/ 256" to "* 512"
- return FFMAX(0.0, 1.25 - acc * 0.8 * 512);
-}
-
-/**
- * Apply a non-linear fixed gain smoothing in order to reduce
- * fluctuation in the energy of excitation.
- *
- * @param[in] fixed_gain Unsmoothed fixed gain
- * @param[in,out] prev_tr_gain Previous threshold gain (updated)
- * @param[in] voice_fac Frame voicing factor
- * @param[in] stab_fac Frame stability factor
- *
- * @return The smoothed gain
- */
-static float noise_enhancer(float fixed_gain, float *prev_tr_gain,
- float voice_fac, float stab_fac)
-{
- float sm_fac = 0.5 * (1 - voice_fac) * stab_fac;
- float g0;
-
- // XXX: the following fixed-point constants used to in(de)crement
- // gain by 1.5dB were taken from the reference code, maybe it could
- // be simpler
- if (fixed_gain < *prev_tr_gain) {
- g0 = FFMIN(*prev_tr_gain, fixed_gain + fixed_gain *
- (6226 * (1.0f / (1 << 15)))); // +1.5 dB
- } else
- g0 = FFMAX(*prev_tr_gain, fixed_gain *
- (27536 * (1.0f / (1 << 15)))); // -1.5 dB
-
- *prev_tr_gain = g0; // update next frame threshold
-
- return sm_fac * g0 + (1 - sm_fac) * fixed_gain;
-}
-
-/**
- * Filter the fixed_vector to emphasize the higher frequencies.
- *
- * @param[in,out] fixed_vector Fixed codebook vector
- * @param[in] voice_fac Frame voicing factor
- */
-static void pitch_enhancer(float *fixed_vector, float voice_fac)
-{
- int i;
- float cpe = 0.125 * (1 + voice_fac);
- float last = fixed_vector[0]; // holds c(i - 1)
-
- fixed_vector[0] -= cpe * fixed_vector[1];
-
- for (i = 1; i < AMRWB_SFR_SIZE - 1; i++) {
- float cur = fixed_vector[i];
-
- fixed_vector[i] -= cpe * (last + fixed_vector[i + 1]);
- last = cur;
- }
-
- fixed_vector[AMRWB_SFR_SIZE - 1] -= cpe * last;
-}
-
-/**
- * Conduct 16th order linear predictive coding synthesis from excitation.
- *
- * @param[in] ctx Pointer to the AMRWBContext
- * @param[in] lpc Pointer to the LPC coefficients
- * @param[out] excitation Buffer for synthesis final excitation
- * @param[in] fixed_gain Fixed codebook gain for synthesis
- * @param[in] fixed_vector Algebraic codebook vector
- * @param[in,out] samples Pointer to the output samples and memory
- */
-static void synthesis(AMRWBContext *ctx, float *lpc, float *excitation,
- float fixed_gain, const float *fixed_vector,
- float *samples)
-{
- ctx->acelpv_ctx.weighted_vector_sumf(excitation, ctx->pitch_vector, fixed_vector,
- ctx->pitch_gain[0], fixed_gain, AMRWB_SFR_SIZE);
-
- /* emphasize pitch vector contribution in low bitrate modes */
- if (ctx->pitch_gain[0] > 0.5 && ctx->fr_cur_mode <= MODE_8k85) {
- int i;
- float energy = ctx->celpm_ctx.dot_productf(excitation, excitation,
- AMRWB_SFR_SIZE);
-
- // XXX: Weird part in both ref code and spec. A unknown parameter
- // {beta} seems to be identical to the current pitch gain
- float pitch_factor = 0.25 * ctx->pitch_gain[0] * ctx->pitch_gain[0];
-
- for (i = 0; i < AMRWB_SFR_SIZE; i++)
- excitation[i] += pitch_factor * ctx->pitch_vector[i];
-
- ff_scale_vector_to_given_sum_of_squares(excitation, excitation,
- energy, AMRWB_SFR_SIZE);
- }
-
- ctx->celpf_ctx.celp_lp_synthesis_filterf(samples, lpc, excitation,
- AMRWB_SFR_SIZE, LP_ORDER);
-}
-
-/**
- * Apply to synthesis a de-emphasis filter of the form:
- * H(z) = 1 / (1 - m * z^-1)
- *
- * @param[out] out Output buffer
- * @param[in] in Input samples array with in[-1]
- * @param[in] m Filter coefficient
- * @param[in,out] mem State from last filtering
- */
-static void de_emphasis(float *out, float *in, float m, float mem[1])
-{
- int i;
-
- out[0] = in[0] + m * mem[0];
-
- for (i = 1; i < AMRWB_SFR_SIZE; i++)
- out[i] = in[i] + out[i - 1] * m;
-
- mem[0] = out[AMRWB_SFR_SIZE - 1];
-}
-
-/**
- * Upsample a signal by 5/4 ratio (from 12.8kHz to 16kHz) using
- * a FIR interpolation filter. Uses past data from before *in address.
- *
- * @param[out] out Buffer for interpolated signal
- * @param[in] in Current signal data (length 0.8*o_size)
- * @param[in] o_size Output signal length
- * @param[in] ctx The context
- */
-static void upsample_5_4(float *out, const float *in, int o_size, CELPMContext *ctx)
-{
- const float *in0 = in - UPS_FIR_SIZE + 1;
- int i, j, k;
- int int_part = 0, frac_part;
-
- i = 0;
- for (j = 0; j < o_size / 5; j++) {
- out[i] = in[int_part];
- frac_part = 4;
- i++;
-
- for (k = 1; k < 5; k++) {
- out[i] = ctx->dot_productf(in0 + int_part,
- upsample_fir[4 - frac_part],
- UPS_MEM_SIZE);
- int_part++;
- frac_part--;
- i++;
- }
- }
-}
-
-/**
- * Calculate the high-band gain based on encoded index (23k85 mode) or
- * on the low-band speech signal and the Voice Activity Detection flag.
- *
- * @param[in] ctx The context
- * @param[in] synth LB speech synthesis at 12.8k
- * @param[in] hb_idx Gain index for mode 23k85 only
- * @param[in] vad VAD flag for the frame
- */
-static float find_hb_gain(AMRWBContext *ctx, const float *synth,
- uint16_t hb_idx, uint8_t vad)
-{
- int wsp = (vad > 0);
- float tilt;
-
- if (ctx->fr_cur_mode == MODE_23k85)
- return qua_hb_gain[hb_idx] * (1.0f / (1 << 14));
-
- tilt = ctx->celpm_ctx.dot_productf(synth, synth + 1, AMRWB_SFR_SIZE - 1) /
- ctx->celpm_ctx.dot_productf(synth, synth, AMRWB_SFR_SIZE);
-
- /* return gain bounded by [0.1, 1.0] */
- return av_clipf((1.0 - FFMAX(0.0, tilt)) * (1.25 - 0.25 * wsp), 0.1, 1.0);
-}
-
-/**
- * Generate the high-band excitation with the same energy from the lower
- * one and scaled by the given gain.
- *
- * @param[in] ctx The context
- * @param[out] hb_exc Buffer for the excitation
- * @param[in] synth_exc Low-band excitation used for synthesis
- * @param[in] hb_gain Wanted excitation gain
- */
-static void scaled_hb_excitation(AMRWBContext *ctx, float *hb_exc,
- const float *synth_exc, float hb_gain)
-{
- int i;
- float energy = ctx->celpm_ctx.dot_productf(synth_exc, synth_exc,
- AMRWB_SFR_SIZE);
-
- /* Generate a white-noise excitation */
- for (i = 0; i < AMRWB_SFR_SIZE_16k; i++)
- hb_exc[i] = 32768.0 - (uint16_t) av_lfg_get(&ctx->prng);
-
- ff_scale_vector_to_given_sum_of_squares(hb_exc, hb_exc,
- energy * hb_gain * hb_gain,
- AMRWB_SFR_SIZE_16k);
-}
-
-/**
- * Calculate the auto-correlation for the ISF difference vector.
- */
-static float auto_correlation(float *diff_isf, float mean, int lag)
-{
- int i;
- float sum = 0.0;
-
- for (i = 7; i < LP_ORDER - 2; i++) {
- float prod = (diff_isf[i] - mean) * (diff_isf[i - lag] - mean);
- sum += prod * prod;
- }
- return sum;
-}
-
-/**
- * Extrapolate a ISF vector to the 16kHz range (20th order LP)
- * used at mode 6k60 LP filter for the high frequency band.
- *
- * @param[out] isf Buffer for extrapolated isf; contains LP_ORDER
- * values on input
- */
-static void extrapolate_isf(float isf[LP_ORDER_16k])
-{
- float diff_isf[LP_ORDER - 2], diff_mean;
- float corr_lag[3];
- float est, scale;
- int i, j, i_max_corr;
-
- isf[LP_ORDER_16k - 1] = isf[LP_ORDER - 1];
-
- /* Calculate the difference vector */
- for (i = 0; i < LP_ORDER - 2; i++)
- diff_isf[i] = isf[i + 1] - isf[i];
-
- diff_mean = 0.0;
- for (i = 2; i < LP_ORDER - 2; i++)
- diff_mean += diff_isf[i] * (1.0f / (LP_ORDER - 4));
-
- /* Find which is the maximum autocorrelation */
- i_max_corr = 0;
- for (i = 0; i < 3; i++) {
- corr_lag[i] = auto_correlation(diff_isf, diff_mean, i + 2);
-
- if (corr_lag[i] > corr_lag[i_max_corr])
- i_max_corr = i;
- }
- i_max_corr++;
-
- for (i = LP_ORDER - 1; i < LP_ORDER_16k - 1; i++)
- isf[i] = isf[i - 1] + isf[i - 1 - i_max_corr]
- - isf[i - 2 - i_max_corr];
-
- /* Calculate an estimate for ISF(18) and scale ISF based on the error */
- est = 7965 + (isf[2] - isf[3] - isf[4]) / 6.0;
- scale = 0.5 * (FFMIN(est, 7600) - isf[LP_ORDER - 2]) /
- (isf[LP_ORDER_16k - 2] - isf[LP_ORDER - 2]);
-
- for (i = LP_ORDER - 1, j = 0; i < LP_ORDER_16k - 1; i++, j++)
- diff_isf[j] = scale * (isf[i] - isf[i - 1]);
-
- /* Stability insurance */
- for (i = 1; i < LP_ORDER_16k - LP_ORDER; i++)
- if (diff_isf[i] + diff_isf[i - 1] < 5.0) {
- if (diff_isf[i] > diff_isf[i - 1]) {
- diff_isf[i - 1] = 5.0 - diff_isf[i];
- } else
- diff_isf[i] = 5.0 - diff_isf[i - 1];
- }
-
- for (i = LP_ORDER - 1, j = 0; i < LP_ORDER_16k - 1; i++, j++)
- isf[i] = isf[i - 1] + diff_isf[j] * (1.0f / (1 << 15));
-
- /* Scale the ISF vector for 16000 Hz */
- for (i = 0; i < LP_ORDER_16k - 1; i++)
- isf[i] *= 0.8;
-}
-
-/**
- * Spectral expand the LP coefficients using the equation:
- * y[i] = x[i] * (gamma ** i)
- *
- * @param[out] out Output buffer (may use input array)
- * @param[in] lpc LP coefficients array
- * @param[in] gamma Weighting factor
- * @param[in] size LP array size
- */
-static void lpc_weighting(float *out, const float *lpc, float gamma, int size)
-{
- int i;
- float fac = gamma;
-
- for (i = 0; i < size; i++) {
- out[i] = lpc[i] * fac;
- fac *= gamma;
- }
-}
-
-/**
- * Conduct 20th order linear predictive coding synthesis for the high
- * frequency band excitation at 16kHz.
- *
- * @param[in] ctx The context
- * @param[in] subframe Current subframe index (0 to 3)
- * @param[in,out] samples Pointer to the output speech samples
- * @param[in] exc Generated white-noise scaled excitation
- * @param[in] isf Current frame isf vector
- * @param[in] isf_past Past frame final isf vector
- */
-static void hb_synthesis(AMRWBContext *ctx, int subframe, float *samples,
- const float *exc, const float *isf, const float *isf_past)
-{
- float hb_lpc[LP_ORDER_16k];
- enum Mode mode = ctx->fr_cur_mode;
-
- if (mode == MODE_6k60) {
- float e_isf[LP_ORDER_16k]; // ISF vector for extrapolation
- double e_isp[LP_ORDER_16k];
-
- ctx->acelpv_ctx.weighted_vector_sumf(e_isf, isf_past, isf, isfp_inter[subframe],
- 1.0 - isfp_inter[subframe], LP_ORDER);
-
- extrapolate_isf(e_isf);
-
- e_isf[LP_ORDER_16k - 1] *= 2.0;
- ff_acelp_lsf2lspd(e_isp, e_isf, LP_ORDER_16k);
- ff_amrwb_lsp2lpc(e_isp, hb_lpc, LP_ORDER_16k);
-
- lpc_weighting(hb_lpc, hb_lpc, 0.9, LP_ORDER_16k);
- } else {
- lpc_weighting(hb_lpc, ctx->lp_coef[subframe], 0.6, LP_ORDER);
- }
-
- ctx->celpf_ctx.celp_lp_synthesis_filterf(samples, hb_lpc, exc, AMRWB_SFR_SIZE_16k,
- (mode == MODE_6k60) ? LP_ORDER_16k : LP_ORDER);
-}
-
-/**
- * Apply a 15th order filter to high-band samples.
- * The filter characteristic depends on the given coefficients.
- *
- * @param[out] out Buffer for filtered output
- * @param[in] fir_coef Filter coefficients
- * @param[in,out] mem State from last filtering (updated)
- * @param[in] in Input speech data (high-band)
- *
- * @remark It is safe to pass the same array in in and out parameters
- */
-
-#ifndef hb_fir_filter
-static void hb_fir_filter(float *out, const float fir_coef[HB_FIR_SIZE + 1],
- float mem[HB_FIR_SIZE], const float *in)
-{
- int i, j;
- float data[AMRWB_SFR_SIZE_16k + HB_FIR_SIZE]; // past and current samples
-
- memcpy(data, mem, HB_FIR_SIZE * sizeof(float));
- memcpy(data + HB_FIR_SIZE, in, AMRWB_SFR_SIZE_16k * sizeof(float));
-
- for (i = 0; i < AMRWB_SFR_SIZE_16k; i++) {
- out[i] = 0.0;
- for (j = 0; j <= HB_FIR_SIZE; j++)
- out[i] += data[i + j] * fir_coef[j];
- }
-
- memcpy(mem, data + AMRWB_SFR_SIZE_16k, HB_FIR_SIZE * sizeof(float));
-}
-#endif /* hb_fir_filter */
-
-/**
- * Update context state before the next subframe.
- */
-static void update_sub_state(AMRWBContext *ctx)
-{
- memmove(&ctx->excitation_buf[0], &ctx->excitation_buf[AMRWB_SFR_SIZE],
- (AMRWB_P_DELAY_MAX + LP_ORDER + 1) * sizeof(float));
-
- memmove(&ctx->pitch_gain[1], &ctx->pitch_gain[0], 5 * sizeof(float));
- memmove(&ctx->fixed_gain[1], &ctx->fixed_gain[0], 1 * sizeof(float));
-
- memmove(&ctx->samples_az[0], &ctx->samples_az[AMRWB_SFR_SIZE],
- LP_ORDER * sizeof(float));
- memmove(&ctx->samples_up[0], &ctx->samples_up[AMRWB_SFR_SIZE],
- UPS_MEM_SIZE * sizeof(float));
- memmove(&ctx->samples_hb[0], &ctx->samples_hb[AMRWB_SFR_SIZE_16k],
- LP_ORDER_16k * sizeof(float));
-}
-
-static int amrwb_decode_frame(AVCodecContext *avctx, void *data,
- int *got_frame_ptr, AVPacket *avpkt)
-{
- AMRWBContext *ctx = avctx->priv_data;
- AVFrame *frame = data;
- AMRWBFrame *cf = &ctx->frame;
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
- int expected_fr_size, header_size;
- float *buf_out;
- float spare_vector[AMRWB_SFR_SIZE]; // extra stack space to hold result from anti-sparseness processing
- float fixed_gain_factor; // fixed gain correction factor (gamma)
- float *synth_fixed_vector; // pointer to the fixed vector that synthesis should use
- float synth_fixed_gain; // the fixed gain that synthesis should use
- float voice_fac, stab_fac; // parameters used for gain smoothing
- float synth_exc[AMRWB_SFR_SIZE]; // post-processed excitation for synthesis
- float hb_exc[AMRWB_SFR_SIZE_16k]; // excitation for the high frequency band
- float hb_samples[AMRWB_SFR_SIZE_16k]; // filtered high-band samples from synthesis
- float hb_gain;
- int sub, i, ret;
-
- /* get output buffer */
- frame->nb_samples = 4 * AMRWB_SFR_SIZE_16k;
- if ((ret = ff_get_buffer(avctx, frame)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return ret;
- }
- buf_out = (float *)frame->data[0];
-
- header_size = decode_mime_header(ctx, buf);
- if (ctx->fr_cur_mode > MODE_SID) {
- av_log(avctx, AV_LOG_ERROR,
- "Invalid mode %d\n", ctx->fr_cur_mode);
- return AVERROR_INVALIDDATA;
- }
- expected_fr_size = ((cf_sizes_wb[ctx->fr_cur_mode] + 7) >> 3) + 1;
-
- if (buf_size < expected_fr_size) {
- av_log(avctx, AV_LOG_ERROR,
- "Frame too small (%d bytes). Truncated file?\n", buf_size);
- *got_frame_ptr = 0;
- return AVERROR_INVALIDDATA;
- }
-
- if (!ctx->fr_quality || ctx->fr_cur_mode > MODE_SID)
- av_log(avctx, AV_LOG_ERROR, "Encountered a bad or corrupted frame\n");
-
- if (ctx->fr_cur_mode == MODE_SID) { /* Comfort noise frame */
- av_log_missing_feature(avctx, "SID mode", 1);
- return AVERROR_PATCHWELCOME;
- }
-
- ff_amr_bit_reorder((uint16_t *) &ctx->frame, sizeof(AMRWBFrame),
- buf + header_size, amr_bit_orderings_by_mode[ctx->fr_cur_mode]);
-
- /* Decode the quantized ISF vector */
- if (ctx->fr_cur_mode == MODE_6k60) {
- decode_isf_indices_36b(cf->isp_id, ctx->isf_cur);
- } else {
- decode_isf_indices_46b(cf->isp_id, ctx->isf_cur);
- }
-
- isf_add_mean_and_past(ctx->isf_cur, ctx->isf_q_past);
- ff_set_min_dist_lsf(ctx->isf_cur, MIN_ISF_SPACING, LP_ORDER - 1);
-
- stab_fac = stability_factor(ctx->isf_cur, ctx->isf_past_final);
-
- ctx->isf_cur[LP_ORDER - 1] *= 2.0;
- ff_acelp_lsf2lspd(ctx->isp[3], ctx->isf_cur, LP_ORDER);
-
- /* Generate a ISP vector for each subframe */
- if (ctx->first_frame) {
- ctx->first_frame = 0;
- memcpy(ctx->isp_sub4_past, ctx->isp[3], LP_ORDER * sizeof(double));
- }
- interpolate_isp(ctx->isp, ctx->isp_sub4_past);
-
- for (sub = 0; sub < 4; sub++)
- ff_amrwb_lsp2lpc(ctx->isp[sub], ctx->lp_coef[sub], LP_ORDER);
-
- for (sub = 0; sub < 4; sub++) {
- const AMRWBSubFrame *cur_subframe = &cf->subframe[sub];
- float *sub_buf = buf_out + sub * AMRWB_SFR_SIZE_16k;
-
- /* Decode adaptive codebook (pitch vector) */
- decode_pitch_vector(ctx, cur_subframe, sub);
- /* Decode innovative codebook (fixed vector) */
- decode_fixed_vector(ctx->fixed_vector, cur_subframe->pul_ih,
- cur_subframe->pul_il, ctx->fr_cur_mode);
-
- pitch_sharpening(ctx, ctx->fixed_vector);
-
- decode_gains(cur_subframe->vq_gain, ctx->fr_cur_mode,
- &fixed_gain_factor, &ctx->pitch_gain[0]);
-
- ctx->fixed_gain[0] =
- ff_amr_set_fixed_gain(fixed_gain_factor,
- ctx->celpm_ctx.dot_productf(ctx->fixed_vector,
- ctx->fixed_vector,
- AMRWB_SFR_SIZE) /
- AMRWB_SFR_SIZE,
- ctx->prediction_error,
- ENERGY_MEAN, energy_pred_fac);
-
- /* Calculate voice factor and store tilt for next subframe */
- voice_fac = voice_factor(ctx->pitch_vector, ctx->pitch_gain[0],
- ctx->fixed_vector, ctx->fixed_gain[0],
- &ctx->celpm_ctx);
- ctx->tilt_coef = voice_fac * 0.25 + 0.25;
-
- /* Construct current excitation */
- for (i = 0; i < AMRWB_SFR_SIZE; i++) {
- ctx->excitation[i] *= ctx->pitch_gain[0];
- ctx->excitation[i] += ctx->fixed_gain[0] * ctx->fixed_vector[i];
- ctx->excitation[i] = truncf(ctx->excitation[i]);
- }
-
- /* Post-processing of excitation elements */
- synth_fixed_gain = noise_enhancer(ctx->fixed_gain[0], &ctx->prev_tr_gain,
- voice_fac, stab_fac);
-
- synth_fixed_vector = anti_sparseness(ctx, ctx->fixed_vector,
- spare_vector);
-
- pitch_enhancer(synth_fixed_vector, voice_fac);
-
- synthesis(ctx, ctx->lp_coef[sub], synth_exc, synth_fixed_gain,
- synth_fixed_vector, &ctx->samples_az[LP_ORDER]);
-
- /* Synthesis speech post-processing */
- de_emphasis(&ctx->samples_up[UPS_MEM_SIZE],
- &ctx->samples_az[LP_ORDER], PREEMPH_FAC, ctx->demph_mem);
-
- ctx->acelpf_ctx.acelp_apply_order_2_transfer_function(&ctx->samples_up[UPS_MEM_SIZE],
- &ctx->samples_up[UPS_MEM_SIZE], hpf_zeros, hpf_31_poles,
- hpf_31_gain, ctx->hpf_31_mem, AMRWB_SFR_SIZE);
-
- upsample_5_4(sub_buf, &ctx->samples_up[UPS_FIR_SIZE],
- AMRWB_SFR_SIZE_16k, &ctx->celpm_ctx);
-
- /* High frequency band (6.4 - 7.0 kHz) generation part */
- ctx->acelpf_ctx.acelp_apply_order_2_transfer_function(hb_samples,
- &ctx->samples_up[UPS_MEM_SIZE], hpf_zeros, hpf_400_poles,
- hpf_400_gain, ctx->hpf_400_mem, AMRWB_SFR_SIZE);
-
- hb_gain = find_hb_gain(ctx, hb_samples,
- cur_subframe->hb_gain, cf->vad);
-
- scaled_hb_excitation(ctx, hb_exc, synth_exc, hb_gain);
-
- hb_synthesis(ctx, sub, &ctx->samples_hb[LP_ORDER_16k],
- hb_exc, ctx->isf_cur, ctx->isf_past_final);
-
- /* High-band post-processing filters */
- hb_fir_filter(hb_samples, bpf_6_7_coef, ctx->bpf_6_7_mem,
- &ctx->samples_hb[LP_ORDER_16k]);
-
- if (ctx->fr_cur_mode == MODE_23k85)
- hb_fir_filter(hb_samples, lpf_7_coef, ctx->lpf_7_mem,
- hb_samples);
-
- /* Add the low and high frequency bands */
- for (i = 0; i < AMRWB_SFR_SIZE_16k; i++)
- sub_buf[i] = (sub_buf[i] + hb_samples[i]) * (1.0f / (1 << 15));
-
- /* Update buffers and history */
- update_sub_state(ctx);
- }
-
- /* update state for next frame */
- memcpy(ctx->isp_sub4_past, ctx->isp[3], LP_ORDER * sizeof(ctx->isp[3][0]));
- memcpy(ctx->isf_past_final, ctx->isf_cur, LP_ORDER * sizeof(float));
-
- *got_frame_ptr = 1;
-
- return expected_fr_size;
-}
-
-AVCodec ff_amrwb_decoder = {
- .name = "amrwb",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_AMR_WB,
- .priv_data_size = sizeof(AMRWBContext),
- .init = amrwb_decode_init,
- .decode = amrwb_decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("AMR-WB (Adaptive Multi-Rate WideBand)"),
- .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLT,
- AV_SAMPLE_FMT_NONE },
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/atrac.c b/src/thirdparty/ffmpeg/libavcodec/atrac.c
deleted file mode 100644
index bc5ebdde0..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/atrac.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Atrac common functions
- * Copyright (c) 2006-2008 Maxim Poliakovski
- * Copyright (c) 2006-2008 Benjamin Larsson
- *
- * 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
- */
-
-#include <math.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "avcodec.h"
-#include "dsputil.h"
-#include "atrac.h"
-
-float ff_atrac_sf_table[64];
-static float qmf_window[48];
-
-static const float qmf_48tap_half[24] = {
- -0.00001461907, -0.00009205479,-0.000056157569,0.00030117269,
- 0.0002422519, -0.00085293897,-0.0005205574, 0.0020340169,
- 0.00078333891, -0.0042153862, -0.00075614988, 0.0078402944,
- -0.000061169922,-0.01344162, 0.0024626821, 0.021736089,
- -0.007801671, -0.034090221, 0.01880949, 0.054326009,
- -0.043596379, -0.099384367, 0.13207909, 0.46424159
-};
-
-/**
- * Generate common tables
- */
-
-void ff_atrac_generate_tables(void)
-{
- int i;
- float s;
-
- /* Generate scale factors */
- if (!ff_atrac_sf_table[63])
- for (i=0 ; i<64 ; i++)
- ff_atrac_sf_table[i] = pow(2.0, (i - 15) / 3.0);
-
- /* Generate the QMF window. */
- if (!qmf_window[47])
- for (i=0 ; i<24; i++) {
- s = qmf_48tap_half[i] * 2.0;
- qmf_window[i] = qmf_window[47 - i] = s;
- }
-}
-
-
-/**
- * Quadrature mirror synthesis filter.
- *
- * @param inlo lower part of spectrum
- * @param inhi higher part of spectrum
- * @param nIn size of spectrum buffer
- * @param pOut out buffer
- * @param delayBuf delayBuf buffer
- * @param temp temp buffer
- */
-
-
-void ff_atrac_iqmf (float *inlo, float *inhi, unsigned int nIn, float *pOut, float *delayBuf, float *temp)
-{
- int i, j;
- float *p1, *p3;
-
- memcpy(temp, delayBuf, 46*sizeof(float));
-
- p3 = temp + 46;
-
- /* loop1 */
- for(i=0; i<nIn; i+=2){
- p3[2*i+0] = inlo[i ] + inhi[i ];
- p3[2*i+1] = inlo[i ] - inhi[i ];
- p3[2*i+2] = inlo[i+1] + inhi[i+1];
- p3[2*i+3] = inlo[i+1] - inhi[i+1];
- }
-
- /* loop2 */
- p1 = temp;
- for (j = nIn; j != 0; j--) {
- float s1 = 0.0;
- float s2 = 0.0;
-
- for (i = 0; i < 48; i += 2) {
- s1 += p1[i] * qmf_window[i];
- s2 += p1[i+1] * qmf_window[i+1];
- }
-
- pOut[0] = s2;
- pOut[1] = s1;
-
- p1 += 2;
- pOut += 2;
- }
-
- /* Update the delay buffer. */
- memcpy(delayBuf, temp + nIn*2, 46*sizeof(float));
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/atrac.h b/src/thirdparty/ffmpeg/libavcodec/atrac.h
deleted file mode 100644
index bb00f201c..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/atrac.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Atrac common data
- * Copyright (c) 2009 Maxim Poliakovski
- * Copyright (c) 2009 Benjamin Larsson
- *
- * 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
- * Atrac common header
- */
-
-#ifndef AVCODEC_ATRAC_H
-#define AVCODEC_ATRAC_H
-
-extern float ff_atrac_sf_table[64];
-
-void ff_atrac_generate_tables(void);
-void ff_atrac_iqmf (float *inlo, float *inhi, unsigned int nIn, float *pOut, float *delayBuf, float *temp);
-
-#endif /* AVCODEC_ATRAC_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/atrac3.c b/src/thirdparty/ffmpeg/libavcodec/atrac3.c
deleted file mode 100644
index e094c6c0b..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/atrac3.c
+++ /dev/null
@@ -1,1014 +0,0 @@
-/*
- * Atrac 3 compatible decoder
- * Copyright (c) 2006-2008 Maxim Poliakovski
- * Copyright (c) 2006-2008 Benjamin Larsson
- *
- * 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
- * Atrac 3 compatible decoder.
- * This decoder handles Sony's ATRAC3 data.
- *
- * Container formats used to store atrac 3 data:
- * RealMedia (.rm), RIFF WAV (.wav, .at3), Sony OpenMG (.oma, .aa3).
- *
- * To use this decoder, a calling application must supply the extradata
- * bytes provided in the containers above.
- */
-
-#include <math.h>
-#include <stddef.h>
-#include <stdio.h>
-
-#include "libavutil/float_dsp.h"
-#include "libavutil/libm.h"
-#include "avcodec.h"
-#include "bytestream.h"
-#include "fft.h"
-#include "fmtconvert.h"
-#include "get_bits.h"
-#include "internal.h"
-
-#include "atrac.h"
-#include "atrac3data.h"
-
-#define JOINT_STEREO 0x12
-#define STEREO 0x2
-
-#define SAMPLES_PER_FRAME 1024
-#define MDCT_SIZE 512
-
-typedef struct GainInfo {
- int num_gain_data;
- int lev_code[8];
- int loc_code[8];
-} GainInfo;
-
-typedef struct GainBlock {
- GainInfo g_block[4];
-} GainBlock;
-
-typedef struct TonalComponent {
- int pos;
- int num_coefs;
- float coef[8];
-} TonalComponent;
-
-typedef struct ChannelUnit {
- int bands_coded;
- int num_components;
- float prev_frame[SAMPLES_PER_FRAME];
- int gc_blk_switch;
- TonalComponent components[64];
- GainBlock gain_block[2];
-
- DECLARE_ALIGNED(32, float, spectrum)[SAMPLES_PER_FRAME];
- DECLARE_ALIGNED(32, float, imdct_buf)[SAMPLES_PER_FRAME];
-
- float delay_buf1[46]; ///<qmf delay buffers
- float delay_buf2[46];
- float delay_buf3[46];
-} ChannelUnit;
-
-typedef struct ATRAC3Context {
- GetBitContext gb;
- //@{
- /** stream data */
- int coding_mode;
-
- ChannelUnit *units;
- //@}
- //@{
- /** joint-stereo related variables */
- int matrix_coeff_index_prev[4];
- int matrix_coeff_index_now[4];
- int matrix_coeff_index_next[4];
- int weighting_delay[6];
- //@}
- //@{
- /** data buffers */
- uint8_t *decoded_bytes_buffer;
- float temp_buf[1070];
- //@}
- //@{
- /** extradata */
- int scrambled_stream;
- //@}
-
- FFTContext mdct_ctx;
- FmtConvertContext fmt_conv;
- AVFloatDSPContext fdsp;
-} ATRAC3Context;
-
-static DECLARE_ALIGNED(32, float, mdct_window)[MDCT_SIZE];
-static VLC_TYPE atrac3_vlc_table[4096][2];
-static VLC spectral_coeff_tab[7];
-static float gain_tab1[16];
-static float gain_tab2[31];
-
-
-/**
- * Regular 512 points IMDCT without overlapping, with the exception of the
- * swapping of odd bands caused by the reverse spectra of the QMF.
- *
- * @param odd_band 1 if the band is an odd band
- */
-static void imlt(ATRAC3Context *q, float *input, float *output, int odd_band)
-{
- int i;
-
- if (odd_band) {
- /**
- * Reverse the odd bands before IMDCT, this is an effect of the QMF
- * transform or it gives better compression to do it this way.
- * FIXME: It should be possible to handle this in imdct_calc
- * for that to happen a modification of the prerotation step of
- * all SIMD code and C code is needed.
- * Or fix the functions before so they generate a pre reversed spectrum.
- */
- for (i = 0; i < 128; i++)
- FFSWAP(float, input[i], input[255 - i]);
- }
-
- q->mdct_ctx.imdct_calc(&q->mdct_ctx, output, input);
-
- /* Perform windowing on the output. */
- q->fdsp.vector_fmul(output, output, mdct_window, MDCT_SIZE);
-}
-
-/*
- * indata descrambling, only used for data coming from the rm container
- */
-static int decode_bytes(const uint8_t *input, uint8_t *out, int bytes)
-{
- int i, off;
- uint32_t c;
- const uint32_t *buf;
- uint32_t *output = (uint32_t *)out;
-
- off = (intptr_t)input & 3;
- buf = (const uint32_t *)(input - off);
- c = av_be2ne32((0x537F6103 >> (off * 8)) | (0x537F6103 << (32 - (off * 8))));
- bytes += 3 + off;
- for (i = 0; i < bytes / 4; i++)
- output[i] = c ^ buf[i];
-
- if (off)
- av_log_ask_for_sample(NULL, "Offset of %d not handled.\n", off);
-
- return off;
-}
-
-static av_cold void init_atrac3_window(void)
-{
- int i, j;
-
- /* generate the mdct window, for details see
- * http://wiki.multimedia.cx/index.php?title=RealAudio_atrc#Windows */
- for (i = 0, j = 255; i < 128; i++, j--) {
- float wi = sin(((i + 0.5) / 256.0 - 0.5) * M_PI) + 1.0;
- float wj = sin(((j + 0.5) / 256.0 - 0.5) * M_PI) + 1.0;
- float w = 0.5 * (wi * wi + wj * wj);
- mdct_window[i] = mdct_window[511 - i] = wi / w;
- mdct_window[j] = mdct_window[511 - j] = wj / w;
- }
-}
-
-static av_cold int atrac3_decode_close(AVCodecContext *avctx)
-{
- ATRAC3Context *q = avctx->priv_data;
-
- av_free(q->units);
- av_free(q->decoded_bytes_buffer);
-
- ff_mdct_end(&q->mdct_ctx);
-
- return 0;
-}
-
-/**
- * Mantissa decoding
- *
- * @param selector which table the output values are coded with
- * @param coding_flag constant length coding or variable length coding
- * @param mantissas mantissa output table
- * @param num_codes number of values to get
- */
-static void read_quant_spectral_coeffs(GetBitContext *gb, int selector,
- int coding_flag, int *mantissas,
- int num_codes)
-{
- int i, code, huff_symb;
-
- if (selector == 1)
- num_codes /= 2;
-
- if (coding_flag != 0) {
- /* constant length coding (CLC) */
- int num_bits = clc_length_tab[selector];
-
- if (selector > 1) {
- for (i = 0; i < num_codes; i++) {
- if (num_bits)
- code = get_sbits(gb, num_bits);
- else
- code = 0;
- mantissas[i] = code;
- }
- } else {
- for (i = 0; i < num_codes; i++) {
- if (num_bits)
- code = get_bits(gb, num_bits); // num_bits is always 4 in this case
- else
- code = 0;
- mantissas[i * 2 ] = mantissa_clc_tab[code >> 2];
- mantissas[i * 2 + 1] = mantissa_clc_tab[code & 3];
- }
- }
- } else {
- /* variable length coding (VLC) */
- if (selector != 1) {
- for (i = 0; i < num_codes; i++) {
- huff_symb = get_vlc2(gb, spectral_coeff_tab[selector-1].table,
- spectral_coeff_tab[selector-1].bits, 3);
- huff_symb += 1;
- code = huff_symb >> 1;
- if (huff_symb & 1)
- code = -code;
- mantissas[i] = code;
- }
- } else {
- for (i = 0; i < num_codes; i++) {
- huff_symb = get_vlc2(gb, spectral_coeff_tab[selector - 1].table,
- spectral_coeff_tab[selector - 1].bits, 3);
- mantissas[i * 2 ] = mantissa_vlc_tab[huff_symb * 2 ];
- mantissas[i * 2 + 1] = mantissa_vlc_tab[huff_symb * 2 + 1];
- }
- }
- }
-}
-
-/**
- * Restore the quantized band spectrum coefficients
- *
- * @return subband count, fix for broken specification/files
- */
-static int decode_spectrum(GetBitContext *gb, float *output)
-{
- int num_subbands, coding_mode, i, j, first, last, subband_size;
- int subband_vlc_index[32], sf_index[32];
- int mantissas[128];
- float scale_factor;
-
- num_subbands = get_bits(gb, 5); // number of coded subbands
- coding_mode = get_bits1(gb); // coding Mode: 0 - VLC/ 1-CLC
-
- /* get the VLC selector table for the subbands, 0 means not coded */
- for (i = 0; i <= num_subbands; i++)
- subband_vlc_index[i] = get_bits(gb, 3);
-
- /* read the scale factor indexes from the stream */
- for (i = 0; i <= num_subbands; i++) {
- if (subband_vlc_index[i] != 0)
- sf_index[i] = get_bits(gb, 6);
- }
-
- for (i = 0; i <= num_subbands; i++) {
- first = subband_tab[i ];
- last = subband_tab[i + 1];
-
- subband_size = last - first;
-
- if (subband_vlc_index[i] != 0) {
- /* decode spectral coefficients for this subband */
- /* TODO: This can be done faster is several blocks share the
- * same VLC selector (subband_vlc_index) */
- read_quant_spectral_coeffs(gb, subband_vlc_index[i], coding_mode,
- mantissas, subband_size);
-
- /* decode the scale factor for this subband */
- scale_factor = ff_atrac_sf_table[sf_index[i]] *
- inv_max_quant[subband_vlc_index[i]];
-
- /* inverse quantize the coefficients */
- for (j = 0; first < last; first++, j++)
- output[first] = mantissas[j] * scale_factor;
- } else {
- /* this subband was not coded, so zero the entire subband */
- memset(output + first, 0, subband_size * sizeof(*output));
- }
- }
-
- /* clear the subbands that were not coded */
- first = subband_tab[i];
- memset(output + first, 0, (SAMPLES_PER_FRAME - first) * sizeof(*output));
- return num_subbands;
-}
-
-/**
- * Restore the quantized tonal components
- *
- * @param components tonal components
- * @param num_bands number of coded bands
- */
-static int decode_tonal_components(GetBitContext *gb,
- TonalComponent *components, int num_bands)
-{
- int i, b, c, m;
- int nb_components, coding_mode_selector, coding_mode;
- int band_flags[4], mantissa[8];
- int component_count = 0;
-
- nb_components = get_bits(gb, 5);
-
- /* no tonal components */
- if (nb_components == 0)
- return 0;
-
- coding_mode_selector = get_bits(gb, 2);
- if (coding_mode_selector == 2)
- return AVERROR_INVALIDDATA;
-
- coding_mode = coding_mode_selector & 1;
-
- for (i = 0; i < nb_components; i++) {
- int coded_values_per_component, quant_step_index;
-
- for (b = 0; b <= num_bands; b++)
- band_flags[b] = get_bits1(gb);
-
- coded_values_per_component = get_bits(gb, 3);
-
- quant_step_index = get_bits(gb, 3);
- if (quant_step_index <= 1)
- return AVERROR_INVALIDDATA;
-
- if (coding_mode_selector == 3)
- coding_mode = get_bits1(gb);
-
- for (b = 0; b < (num_bands + 1) * 4; b++) {
- int coded_components;
-
- if (band_flags[b >> 2] == 0)
- continue;
-
- coded_components = get_bits(gb, 3);
-
- for (c = 0; c < coded_components; c++) {
- TonalComponent *cmp = &components[component_count];
- int sf_index, coded_values, max_coded_values;
- float scale_factor;
-
- sf_index = get_bits(gb, 6);
- if (component_count >= 64)
- return AVERROR_INVALIDDATA;
-
- cmp->pos = b * 64 + get_bits(gb, 6);
-
- max_coded_values = SAMPLES_PER_FRAME - cmp->pos;
- coded_values = coded_values_per_component + 1;
- coded_values = FFMIN(max_coded_values, coded_values);
-
- scale_factor = ff_atrac_sf_table[sf_index] *
- inv_max_quant[quant_step_index];
-
- read_quant_spectral_coeffs(gb, quant_step_index, coding_mode,
- mantissa, coded_values);
-
- cmp->num_coefs = coded_values;
-
- /* inverse quant */
- for (m = 0; m < coded_values; m++)
- cmp->coef[m] = mantissa[m] * scale_factor;
-
- component_count++;
- }
- }
- }
-
- return component_count;
-}
-
-/**
- * Decode gain parameters for the coded bands
- *
- * @param block the gainblock for the current band
- * @param num_bands amount of coded bands
- */
-static int decode_gain_control(GetBitContext *gb, GainBlock *block,
- int num_bands)
-{
- int i, cf, num_data;
- int *level, *loc;
-
- GainInfo *gain = block->g_block;
-
- for (i = 0; i <= num_bands; i++) {
- num_data = get_bits(gb, 3);
- gain[i].num_gain_data = num_data;
- level = gain[i].lev_code;
- loc = gain[i].loc_code;
-
- for (cf = 0; cf < gain[i].num_gain_data; cf++) {
- level[cf] = get_bits(gb, 4);
- loc [cf] = get_bits(gb, 5);
- if (cf && loc[cf] <= loc[cf - 1])
- return AVERROR_INVALIDDATA;
- }
- }
-
- /* Clear the unused blocks. */
- for (; i < 4 ; i++)
- gain[i].num_gain_data = 0;
-
- return 0;
-}
-
-/**
- * Apply gain parameters and perform the MDCT overlapping part
- *
- * @param input input buffer
- * @param prev previous buffer to perform overlap against
- * @param output output buffer
- * @param gain1 current band gain info
- * @param gain2 next band gain info
- */
-static void gain_compensate_and_overlap(float *input, float *prev,
- float *output, GainInfo *gain1,
- GainInfo *gain2)
-{
- float g1, g2, gain_inc;
- int i, j, num_data, start_loc, end_loc;
-
-
- if (gain2->num_gain_data == 0)
- g1 = 1.0;
- else
- g1 = gain_tab1[gain2->lev_code[0]];
-
- if (gain1->num_gain_data == 0) {
- for (i = 0; i < 256; i++)
- output[i] = input[i] * g1 + prev[i];
- } else {
- num_data = gain1->num_gain_data;
- gain1->loc_code[num_data] = 32;
- gain1->lev_code[num_data] = 4;
-
- for (i = 0, j = 0; i < num_data; i++) {
- start_loc = gain1->loc_code[i] * 8;
- end_loc = start_loc + 8;
-
- g2 = gain_tab1[gain1->lev_code[i]];
- gain_inc = gain_tab2[gain1->lev_code[i + 1] -
- gain1->lev_code[i ] + 15];
-
- /* interpolate */
- for (; j < start_loc; j++)
- output[j] = (input[j] * g1 + prev[j]) * g2;
-
- /* interpolation is done over eight samples */
- for (; j < end_loc; j++) {
- output[j] = (input[j] * g1 + prev[j]) * g2;
- g2 *= gain_inc;
- }
- }
-
- for (; j < 256; j++)
- output[j] = input[j] * g1 + prev[j];
- }
-
- /* Delay for the overlapping part. */
- memcpy(prev, &input[256], 256 * sizeof(*prev));
-}
-
-/**
- * Combine the tonal band spectrum and regular band spectrum
- *
- * @param spectrum output spectrum buffer
- * @param num_components number of tonal components
- * @param components tonal components for this band
- * @return position of the last tonal coefficient
- */
-static int add_tonal_components(float *spectrum, int num_components,
- TonalComponent *components)
-{
- int i, j, last_pos = -1;
- float *input, *output;
-
- for (i = 0; i < num_components; i++) {
- last_pos = FFMAX(components[i].pos + components[i].num_coefs, last_pos);
- input = components[i].coef;
- output = &spectrum[components[i].pos];
-
- for (j = 0; j < components[i].num_coefs; j++)
- output[j] += input[j];
- }
-
- return last_pos;
-}
-
-#define INTERPOLATE(old, new, nsample) \
- ((old) + (nsample) * 0.125 * ((new) - (old)))
-
-static void reverse_matrixing(float *su1, float *su2, int *prev_code,
- int *curr_code)
-{
- int i, nsample, band;
- float mc1_l, mc1_r, mc2_l, mc2_r;
-
- for (i = 0, band = 0; band < 4 * 256; band += 256, i++) {
- int s1 = prev_code[i];
- int s2 = curr_code[i];
- nsample = band;
-
- if (s1 != s2) {
- /* Selector value changed, interpolation needed. */
- mc1_l = matrix_coeffs[s1 * 2 ];
- mc1_r = matrix_coeffs[s1 * 2 + 1];
- mc2_l = matrix_coeffs[s2 * 2 ];
- mc2_r = matrix_coeffs[s2 * 2 + 1];
-
- /* Interpolation is done over the first eight samples. */
- for (; nsample < band + 8; nsample++) {
- float c1 = su1[nsample];
- float c2 = su2[nsample];
- c2 = c1 * INTERPOLATE(mc1_l, mc2_l, nsample - band) +
- c2 * INTERPOLATE(mc1_r, mc2_r, nsample - band);
- su1[nsample] = c2;
- su2[nsample] = c1 * 2.0 - c2;
- }
- }
-
- /* Apply the matrix without interpolation. */
- switch (s2) {
- case 0: /* M/S decoding */
- for (; nsample < band + 256; nsample++) {
- float c1 = su1[nsample];
- float c2 = su2[nsample];
- su1[nsample] = c2 * 2.0;
- su2[nsample] = (c1 - c2) * 2.0;
- }
- break;
- case 1:
- for (; nsample < band + 256; nsample++) {
- float c1 = su1[nsample];
- float c2 = su2[nsample];
- su1[nsample] = (c1 + c2) * 2.0;
- su2[nsample] = c2 * -2.0;
- }
- break;
- case 2:
- case 3:
- for (; nsample < band + 256; nsample++) {
- float c1 = su1[nsample];
- float c2 = su2[nsample];
- su1[nsample] = c1 + c2;
- su2[nsample] = c1 - c2;
- }
- break;
- default:
- av_assert1(0);
- }
- }
-}
-
-static void get_channel_weights(int index, int flag, float ch[2])
-{
- if (index == 7) {
- ch[0] = 1.0;
- ch[1] = 1.0;
- } else {
- ch[0] = (index & 7) / 7.0;
- ch[1] = sqrt(2 - ch[0] * ch[0]);
- if (flag)
- FFSWAP(float, ch[0], ch[1]);
- }
-}
-
-static void channel_weighting(float *su1, float *su2, int *p3)
-{
- int band, nsample;
- /* w[x][y] y=0 is left y=1 is right */
- float w[2][2];
-
- if (p3[1] != 7 || p3[3] != 7) {
- get_channel_weights(p3[1], p3[0], w[0]);
- get_channel_weights(p3[3], p3[2], w[1]);
-
- for (band = 256; band < 4 * 256; band += 256) {
- for (nsample = band; nsample < band + 8; nsample++) {
- su1[nsample] *= INTERPOLATE(w[0][0], w[0][1], nsample - band);
- su2[nsample] *= INTERPOLATE(w[1][0], w[1][1], nsample - band);
- }
- for(; nsample < band + 256; nsample++) {
- su1[nsample] *= w[1][0];
- su2[nsample] *= w[1][1];
- }
- }
- }
-}
-
-/**
- * Decode a Sound Unit
- *
- * @param snd the channel unit to be used
- * @param output the decoded samples before IQMF in float representation
- * @param channel_num channel number
- * @param coding_mode the coding mode (JOINT_STEREO or regular stereo/mono)
- */
-static int decode_channel_sound_unit(ATRAC3Context *q, GetBitContext *gb,
- ChannelUnit *snd, float *output,
- int channel_num, int coding_mode)
-{
- int band, ret, num_subbands, last_tonal, num_bands;
- GainBlock *gain1 = &snd->gain_block[ snd->gc_blk_switch];
- GainBlock *gain2 = &snd->gain_block[1 - snd->gc_blk_switch];
-
- if (coding_mode == JOINT_STEREO && channel_num == 1) {
- if (get_bits(gb, 2) != 3) {
- av_log(NULL,AV_LOG_ERROR,"JS mono Sound Unit id != 3.\n");
- return AVERROR_INVALIDDATA;
- }
- } else {
- if (get_bits(gb, 6) != 0x28) {
- av_log(NULL,AV_LOG_ERROR,"Sound Unit id != 0x28.\n");
- return AVERROR_INVALIDDATA;
- }
- }
-
- /* number of coded QMF bands */
- snd->bands_coded = get_bits(gb, 2);
-
- ret = decode_gain_control(gb, gain2, snd->bands_coded);
- if (ret)
- return ret;
-
- snd->num_components = decode_tonal_components(gb, snd->components,
- snd->bands_coded);
- if (snd->num_components == -1)
- return -1;
-
- num_subbands = decode_spectrum(gb, snd->spectrum);
-
- /* Merge the decoded spectrum and tonal components. */
- last_tonal = add_tonal_components(snd->spectrum, snd->num_components,
- snd->components);
-
-
- /* calculate number of used MLT/QMF bands according to the amount of coded
- spectral lines */
- num_bands = (subband_tab[num_subbands] - 1) >> 8;
- if (last_tonal >= 0)
- num_bands = FFMAX((last_tonal + 256) >> 8, num_bands);
-
-
- /* Reconstruct time domain samples. */
- for (band = 0; band < 4; band++) {
- /* Perform the IMDCT step without overlapping. */
- if (band <= num_bands)
- imlt(q, &snd->spectrum[band * 256], snd->imdct_buf, band & 1);
- else
- memset(snd->imdct_buf, 0, 512 * sizeof(*snd->imdct_buf));
-
- /* gain compensation and overlapping */
- gain_compensate_and_overlap(snd->imdct_buf,
- &snd->prev_frame[band * 256],
- &output[band * 256],
- &gain1->g_block[band],
- &gain2->g_block[band]);
- }
-
- /* Swap the gain control buffers for the next frame. */
- snd->gc_blk_switch ^= 1;
-
- return 0;
-}
-
-static int decode_frame(AVCodecContext *avctx, const uint8_t *databuf,
- float **out_samples)
-{
- ATRAC3Context *q = avctx->priv_data;
- int ret, i;
- uint8_t *ptr1;
-
- if (q->coding_mode == JOINT_STEREO) {
- /* channel coupling mode */
- /* decode Sound Unit 1 */
- init_get_bits(&q->gb, databuf, avctx->block_align * 8);
-
- ret = decode_channel_sound_unit(q, &q->gb, q->units, out_samples[0], 0,
- JOINT_STEREO);
- if (ret != 0)
- return ret;
-
- /* Framedata of the su2 in the joint-stereo mode is encoded in
- * reverse byte order so we need to swap it first. */
- if (databuf == q->decoded_bytes_buffer) {
- uint8_t *ptr2 = q->decoded_bytes_buffer + avctx->block_align - 1;
- ptr1 = q->decoded_bytes_buffer;
- for (i = 0; i < avctx->block_align / 2; i++, ptr1++, ptr2--)
- FFSWAP(uint8_t, *ptr1, *ptr2);
- } else {
- const uint8_t *ptr2 = databuf + avctx->block_align - 1;
- for (i = 0; i < avctx->block_align; i++)
- q->decoded_bytes_buffer[i] = *ptr2--;
- }
-
- /* Skip the sync codes (0xF8). */
- ptr1 = q->decoded_bytes_buffer;
- for (i = 4; *ptr1 == 0xF8; i++, ptr1++) {
- if (i >= avctx->block_align)
- return AVERROR_INVALIDDATA;
- }
-
-
- /* set the bitstream reader at the start of the second Sound Unit*/
- init_get_bits8(&q->gb, ptr1, q->decoded_bytes_buffer + avctx->block_align - ptr1);
-
- /* Fill the Weighting coeffs delay buffer */
- memmove(q->weighting_delay, &q->weighting_delay[2],
- 4 * sizeof(*q->weighting_delay));
- q->weighting_delay[4] = get_bits1(&q->gb);
- q->weighting_delay[5] = get_bits(&q->gb, 3);
-
- for (i = 0; i < 4; i++) {
- q->matrix_coeff_index_prev[i] = q->matrix_coeff_index_now[i];
- q->matrix_coeff_index_now[i] = q->matrix_coeff_index_next[i];
- q->matrix_coeff_index_next[i] = get_bits(&q->gb, 2);
- }
-
- /* Decode Sound Unit 2. */
- ret = decode_channel_sound_unit(q, &q->gb, &q->units[1],
- out_samples[1], 1, JOINT_STEREO);
- if (ret != 0)
- return ret;
-
- /* Reconstruct the channel coefficients. */
- reverse_matrixing(out_samples[0], out_samples[1],
- q->matrix_coeff_index_prev,
- q->matrix_coeff_index_now);
-
- channel_weighting(out_samples[0], out_samples[1], q->weighting_delay);
- } else {
- /* normal stereo mode or mono */
- /* Decode the channel sound units. */
- for (i = 0; i < avctx->channels; i++) {
- /* Set the bitstream reader at the start of a channel sound unit. */
- init_get_bits(&q->gb,
- databuf + i * avctx->block_align / avctx->channels,
- avctx->block_align * 8 / avctx->channels);
-
- ret = decode_channel_sound_unit(q, &q->gb, &q->units[i],
- out_samples[i], i, q->coding_mode);
- if (ret != 0)
- return ret;
- }
- }
-
- /* Apply the iQMF synthesis filter. */
- for (i = 0; i < avctx->channels; i++) {
- float *p1 = out_samples[i];
- float *p2 = p1 + 256;
- float *p3 = p2 + 256;
- float *p4 = p3 + 256;
- ff_atrac_iqmf(p1, p2, 256, p1, q->units[i].delay_buf1, q->temp_buf);
- ff_atrac_iqmf(p4, p3, 256, p3, q->units[i].delay_buf2, q->temp_buf);
- ff_atrac_iqmf(p1, p3, 512, p1, q->units[i].delay_buf3, q->temp_buf);
- }
-
- return 0;
-}
-
-static int atrac3_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;
- ATRAC3Context *q = avctx->priv_data;
- int ret;
- const uint8_t *databuf;
-
- if (buf_size < avctx->block_align) {
- av_log(avctx, AV_LOG_ERROR,
- "Frame too small (%d bytes). Truncated file?\n", buf_size);
- return AVERROR_INVALIDDATA;
- }
-
- /* get output buffer */
- frame->nb_samples = SAMPLES_PER_FRAME;
- if ((ret = ff_get_buffer(avctx, frame)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return ret;
- }
-
- /* Check if we need to descramble and what buffer to pass on. */
- if (q->scrambled_stream) {
- decode_bytes(buf, q->decoded_bytes_buffer, avctx->block_align);
- databuf = q->decoded_bytes_buffer;
- } else {
- databuf = buf;
- }
-
- ret = decode_frame(avctx, databuf, (float **)frame->extended_data);
- if (ret) {
- av_log(NULL, AV_LOG_ERROR, "Frame decoding error!\n");
- return ret;
- }
-
- *got_frame_ptr = 1;
-
- return avctx->block_align;
-}
-
-static void atrac3_init_static_data(void)
-{
- int i;
-
- init_atrac3_window();
- ff_atrac_generate_tables();
-
- /* Initialize the VLC tables. */
- for (i = 0; i < 7; i++) {
- spectral_coeff_tab[i].table = &atrac3_vlc_table[atrac3_vlc_offs[i]];
- spectral_coeff_tab[i].table_allocated = atrac3_vlc_offs[i + 1] -
- atrac3_vlc_offs[i ];
- init_vlc(&spectral_coeff_tab[i], 9, huff_tab_sizes[i],
- huff_bits[i], 1, 1,
- huff_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC);
- }
-
- /* Generate gain tables */
- for (i = 0; i < 16; i++)
- gain_tab1[i] = exp2f (4 - i);
-
- for (i = -15; i < 16; i++)
- gain_tab2[i + 15] = exp2f (i * -0.125);
-}
-
-static av_cold int atrac3_decode_init(AVCodecContext *avctx)
-{
- static int static_init_done;
- int i, ret;
- int version, delay, samples_per_frame, frame_factor;
- const uint8_t *edata_ptr = avctx->extradata;
- ATRAC3Context *q = avctx->priv_data;
-
- if (avctx->channels <= 0 || avctx->channels > 2) {
- av_log(avctx, AV_LOG_ERROR, "Channel configuration error!\n");
- return AVERROR(EINVAL);
- }
-
- if (!static_init_done)
- atrac3_init_static_data();
- static_init_done = 1;
-
- /* Take care of the codec-specific extradata. */
- if (avctx->extradata_size == 14) {
- /* Parse the extradata, WAV format */
- av_log(avctx, AV_LOG_DEBUG, "[0-1] %d\n",
- bytestream_get_le16(&edata_ptr)); // Unknown value always 1
- edata_ptr += 4; // samples per channel
- q->coding_mode = bytestream_get_le16(&edata_ptr);
- av_log(avctx, AV_LOG_DEBUG,"[8-9] %d\n",
- bytestream_get_le16(&edata_ptr)); //Dupe of coding mode
- frame_factor = bytestream_get_le16(&edata_ptr); // Unknown always 1
- av_log(avctx, AV_LOG_DEBUG,"[12-13] %d\n",
- bytestream_get_le16(&edata_ptr)); // Unknown always 0
-
- /* setup */
- samples_per_frame = SAMPLES_PER_FRAME * avctx->channels;
- version = 4;
- delay = 0x88E;
- q->coding_mode = q->coding_mode ? JOINT_STEREO : STEREO;
- q->scrambled_stream = 0;
-
- if (avctx->block_align != 96 * avctx->channels * frame_factor &&
- avctx->block_align != 152 * avctx->channels * frame_factor &&
- avctx->block_align != 192 * avctx->channels * frame_factor) {
- av_log(avctx, AV_LOG_ERROR, "Unknown frame/channel/frame_factor "
- "configuration %d/%d/%d\n", avctx->block_align,
- avctx->channels, frame_factor);
- return AVERROR_INVALIDDATA;
- }
- } else if (avctx->extradata_size == 12 || avctx->extradata_size == 10) {
- /* Parse the extradata, RM format. */
- version = bytestream_get_be32(&edata_ptr);
- samples_per_frame = bytestream_get_be16(&edata_ptr);
- delay = bytestream_get_be16(&edata_ptr);
- q->coding_mode = bytestream_get_be16(&edata_ptr);
- q->scrambled_stream = 1;
-
- } else {
- av_log(NULL, AV_LOG_ERROR, "Unknown extradata size %d.\n",
- avctx->extradata_size);
- return AVERROR(EINVAL);
- }
-
- if (q->coding_mode == JOINT_STEREO && avctx->channels < 2) {
- av_log(avctx, AV_LOG_ERROR, "Invalid coding mode\n");
- return AVERROR_INVALIDDATA;
- }
-
- /* Check the extradata */
-
- if (version != 4) {
- av_log(avctx, AV_LOG_ERROR, "Version %d != 4.\n", version);
- return AVERROR_INVALIDDATA;
- }
-
- if (samples_per_frame != SAMPLES_PER_FRAME &&
- samples_per_frame != SAMPLES_PER_FRAME * 2) {
- av_log(avctx, AV_LOG_ERROR, "Unknown amount of samples per frame %d.\n",
- samples_per_frame);
- return AVERROR_INVALIDDATA;
- }
-
- if (delay != 0x88E) {
- av_log(avctx, AV_LOG_ERROR, "Unknown amount of delay %x != 0x88E.\n",
- delay);
- return AVERROR_INVALIDDATA;
- }
-
- if (q->coding_mode == STEREO)
- av_log(avctx, AV_LOG_DEBUG, "Normal stereo detected.\n");
- else if (q->coding_mode == JOINT_STEREO)
- av_log(avctx, AV_LOG_DEBUG, "Joint stereo detected.\n");
- else {
- av_log(avctx, AV_LOG_ERROR, "Unknown channel coding mode %x!\n",
- q->coding_mode);
- return AVERROR_INVALIDDATA;
- }
-
- if (avctx->block_align >= UINT_MAX / 2)
- return AVERROR(EINVAL);
-
- q->decoded_bytes_buffer = av_mallocz(FFALIGN(avctx->block_align, 4) +
- FF_INPUT_BUFFER_PADDING_SIZE);
- if (q->decoded_bytes_buffer == NULL)
- return AVERROR(ENOMEM);
-
- avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
-
- /* initialize the MDCT transform */
- if ((ret = ff_mdct_init(&q->mdct_ctx, 9, 1, 1.0 / 32768)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "Error initializing MDCT\n");
- av_freep(&q->decoded_bytes_buffer);
- return ret;
- }
-
- /* init the joint-stereo decoding data */
- q->weighting_delay[0] = 0;
- q->weighting_delay[1] = 7;
- q->weighting_delay[2] = 0;
- q->weighting_delay[3] = 7;
- q->weighting_delay[4] = 0;
- q->weighting_delay[5] = 7;
-
- for (i = 0; i < 4; i++) {
- q->matrix_coeff_index_prev[i] = 3;
- q->matrix_coeff_index_now[i] = 3;
- q->matrix_coeff_index_next[i] = 3;
- }
-
- avpriv_float_dsp_init(&q->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
- ff_fmt_convert_init(&q->fmt_conv, avctx);
-
- q->units = av_mallocz(sizeof(*q->units) * avctx->channels);
- if (!q->units) {
- atrac3_decode_close(avctx);
- return AVERROR(ENOMEM);
- }
-
- return 0;
-}
-
-AVCodec ff_atrac3_decoder = {
- .name = "atrac3",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_ATRAC3,
- .priv_data_size = sizeof(ATRAC3Context),
- .init = atrac3_decode_init,
- .close = atrac3_decode_close,
- .decode = atrac3_decode_frame,
- .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("Atrac 3 (Adaptive TRansform Acoustic Coding 3)"),
- .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
- AV_SAMPLE_FMT_NONE },
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/atrac3data.h b/src/thirdparty/ffmpeg/libavcodec/atrac3data.h
deleted file mode 100644
index 8296eb8bc..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/atrac3data.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Atrac 3 compatible decoder data
- * Copyright (c) 2006-2007 Maxim Poliakovski
- * Copyright (c) 2006-2007 Benjamin Larsson
- *
- * 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
- * Atrac 3 AKA RealAudio 8 compatible decoder data
- */
-
-#ifndef AVCODEC_ATRAC3DATA_H
-#define AVCODEC_ATRAC3DATA_H
-
-#include <stdint.h>
-
-/* VLC tables */
-
-static const uint8_t huffcode1[9] = {
- 0x0, 0x4, 0x5, 0xC, 0xD, 0x1C, 0x1D, 0x1E, 0x1F
-};
-
-static const uint8_t huffbits1[9] = { 1, 3, 3, 4, 4, 5, 5, 5, 5 };
-
-static const uint8_t huffcode2[5] = { 0x0, 0x4, 0x5, 0x6, 0x7 };
-
-static const uint8_t huffbits2[5] = { 1, 3, 3, 3, 3 };
-
-static const uint8_t huffcode3[7] = { 0x0, 0x4, 0x5, 0xC, 0xD, 0xE, 0xF };
-
-static const uint8_t huffbits3[7] = { 1, 3, 3, 4, 4, 4, 4 };
-
-static const uint8_t huffcode4[9] = {
- 0x0, 0x4, 0x5, 0xC, 0xD, 0x1C, 0x1D, 0x1E, 0x1F
-};
-
-static const uint8_t huffbits4[9] = { 1, 3, 3, 4, 4, 5, 5, 5, 5 };
-
-static const uint8_t huffcode5[15] = {
- 0x00, 0x02, 0x03, 0x08, 0x09, 0x0A, 0x0B, 0x1C,
- 0x1D, 0x3C, 0x3D, 0x3E, 0x3F, 0x0C, 0x0D
-};
-
-static const uint8_t huffbits5[15] = {
- 2, 3, 3, 4, 4, 4, 4, 5, 5, 6, 6, 6, 6, 4, 4
-};
-
-static const uint8_t huffcode6[31] = {
- 0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x14,
- 0x15, 0x16, 0x17, 0x18, 0x19, 0x34, 0x35, 0x36,
- 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x78, 0x79, 0x7A,
- 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x08, 0x09
-};
-
-static const uint8_t huffbits6[31] = {
- 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6,
- 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 4, 4
-};
-
-static const uint8_t huffcode7[63] = {
- 0x00, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
- 0x0F, 0x10, 0x11, 0x24, 0x25, 0x26, 0x27, 0x28,
- 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30,
- 0x31, 0x32, 0x33, 0x68, 0x69, 0x6A, 0x6B, 0x6C,
- 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74,
- 0x75, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2,
- 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA,
- 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, 0x02, 0x03
-};
-
-static const uint8_t huffbits7[63] = {
- 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 4
-};
-
-static const uint8_t huff_tab_sizes[7] = {
- 9, 5, 7, 9, 15, 31, 63,
-};
-
-static const uint8_t* const huff_codes[7] = {
- huffcode1, huffcode2, huffcode3, huffcode4, huffcode5, huffcode6, huffcode7
-};
-
-static const uint8_t* const huff_bits[7] = {
- huffbits1, huffbits2, huffbits3, huffbits4, huffbits5, huffbits6, huffbits7,
-};
-
-static const uint16_t atrac3_vlc_offs[9] = {
- 0, 512, 1024, 1536, 2048, 2560, 3072, 3584, 4096
-};
-
-/* selector tables */
-
-static const uint8_t clc_length_tab[8] = { 0, 4, 3, 3, 4, 4, 5, 6 };
-
-static const int8_t mantissa_clc_tab[4] = { 0, 1, -2, -1 };
-
-static const int8_t mantissa_vlc_tab[18] = {
- 0, 0, 0, 1, 0, -1, 1, 0, -1, 0, 1, 1, 1, -1, -1, 1, -1, -1
-};
-
-
-/* tables for the scalefactor decoding */
-
-static const float inv_max_quant[8] = {
- 0.0, 1.0 / 1.5, 1.0 / 2.5, 1.0 / 3.5,
- 1.0 / 4.5, 1.0 / 7.5, 1.0 / 15.5, 1.0 / 31.5
-};
-
-static const uint16_t subband_tab[33] = {
- 0, 8, 16, 24, 32, 40, 48, 56,
- 64, 80, 96, 112, 128, 144, 160, 176,
- 192, 224, 256, 288, 320, 352, 384, 416,
- 448, 480, 512, 576, 640, 704, 768, 896,
- 1024
-};
-
-/* joint stereo related tables */
-static const float matrix_coeffs[8] = {
- 0.0, 2.0, 2.0, 2.0, 0.0, 0.0, 1.0, 1.0
-};
-
-#endif /* AVCODEC_ATRAC3DATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/audio_frame_queue.h b/src/thirdparty/ffmpeg/libavcodec/audio_frame_queue.h
deleted file mode 100644
index 5528dbce5..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/audio_frame_queue.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Audio Frame Queue
- * Copyright (c) 2012 Justin Ruggles
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_AUDIO_FRAME_QUEUE_H
-#define AVCODEC_AUDIO_FRAME_QUEUE_H
-
-#include "avcodec.h"
-
-typedef struct AudioFrame {
- int64_t pts;
- int duration;
-} AudioFrame;
-
-typedef struct AudioFrameQueue {
- AVCodecContext *avctx;
- int remaining_delay;
- int remaining_samples;
- AudioFrame *frames;
- unsigned frame_count;
- unsigned frame_alloc;
-} AudioFrameQueue;
-
-/**
- * Initialize AudioFrameQueue.
- *
- * @param avctx context to use for time_base and av_log
- * @param afq queue context
- */
-void ff_af_queue_init(AVCodecContext *avctx, AudioFrameQueue *afq);
-
-/**
- * Close AudioFrameQueue.
- *
- * Frees memory if needed.
- *
- * @param afq queue context
- */
-void ff_af_queue_close(AudioFrameQueue *afq);
-
-/**
- * Add a frame to the queue.
- *
- * @param afq queue context
- * @param f frame to add to the queue
- */
-int ff_af_queue_add(AudioFrameQueue *afq, const AVFrame *f);
-
-/**
- * Remove frame(s) from the queue.
- *
- * Retrieves the pts of the next available frame, or a generated pts based on
- * the last frame duration if there are no frames left in the queue. The number
- * of requested samples should be the full number of samples represented by the
- * packet that will be output by the encoder. If fewer samples are available
- * in the queue, a smaller value will be used for the output duration.
- *
- * @param afq queue context
- * @param nb_samples number of samples to remove from the queue
- * @param[out] pts output packet pts
- * @param[out] duration output packet duration
- */
-void ff_af_queue_remove(AudioFrameQueue *afq, int nb_samples, int64_t *pts,
- int *duration);
-
-#endif /* AVCODEC_AUDIO_FRAME_QUEUE_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/audioconvert.h b/src/thirdparty/ffmpeg/libavcodec/audioconvert.h
deleted file mode 100644
index 3226ae83e..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/audioconvert.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * audio conversion
- * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
- * Copyright (c) 2008 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
- */
-
-#ifndef AVCODEC_AUDIOCONVERT_H
-#define AVCODEC_AUDIOCONVERT_H
-
-/**
- * @file
- * Audio format conversion routines
- */
-
-
-#include "libavutil/cpu.h"
-#include "avcodec.h"
-#include "libavutil/channel_layout.h"
-
-struct AVAudioConvert;
-typedef struct AVAudioConvert AVAudioConvert;
-
-/**
- * Create an audio sample format converter context
- * @param out_fmt Output sample format
- * @param out_channels Number of output channels
- * @param in_fmt Input sample format
- * @param in_channels Number of input channels
- * @param[in] matrix Channel mixing matrix (of dimension in_channel*out_channels). Set to NULL to ignore.
- * @param flags See AV_CPU_FLAG_xx
- * @return NULL on error
- */
-AVAudioConvert *av_audio_convert_alloc(enum AVSampleFormat out_fmt, int out_channels,
- enum AVSampleFormat in_fmt, int in_channels,
- const float *matrix, int flags);
-
-/**
- * Free audio sample format converter context
- */
-void av_audio_convert_free(AVAudioConvert *ctx);
-
-/**
- * Convert between audio sample formats
- * @param[in] out array of output buffers for each channel. set to NULL to ignore processing of the given channel.
- * @param[in] out_stride distance between consecutive output samples (measured in bytes)
- * @param[in] in array of input buffers for each channel
- * @param[in] in_stride distance between consecutive input samples (measured in bytes)
- * @param len length of audio frame size (measured in samples)
- */
-int av_audio_convert(AVAudioConvert *ctx,
- void * const out[6], const int out_stride[6],
- const void * const in[6], const int in_stride[6], int len);
-
-#endif /* AVCODEC_AUDIOCONVERT_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/avcodec.h b/src/thirdparty/ffmpeg/libavcodec/avcodec.h
deleted file mode 100644
index 298b4085b..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/avcodec.h
+++ /dev/null
@@ -1,5114 +0,0 @@
-/*
- * copyright (c) 2001 Fabrice Bellard
- *
- * 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_AVCODEC_H
-#define AVCODEC_AVCODEC_H
-
-/**
- * @file
- * external API header
- */
-
-#include <errno.h>
-#include "libavutil/samplefmt.h"
-#include "libavutil/avutil.h"
-#include "libavutil/cpu.h"
-#include "libavutil/channel_layout.h"
-#include "libavutil/dict.h"
-#include "libavutil/log.h"
-#include "libavutil/pixfmt.h"
-#include "libavutil/rational.h"
-
-#include "libavcodec/version.h"
-/**
- * @defgroup libavc Encoding/Decoding Library
- * @{
- *
- * @defgroup lavc_decoding Decoding
- * @{
- * @}
- *
- * @defgroup lavc_encoding Encoding
- * @{
- * @}
- *
- * @defgroup lavc_codec Codecs
- * @{
- * @defgroup lavc_codec_native Native Codecs
- * @{
- * @}
- * @defgroup lavc_codec_wrappers External library wrappers
- * @{
- * @}
- * @defgroup lavc_codec_hwaccel Hardware Accelerators bridge
- * @{
- * @}
- * @}
- * @defgroup lavc_internal Internal
- * @{
- * @}
- * @}
- *
- */
-
-/**
- * @defgroup lavc_core Core functions/structures.
- * @ingroup libavc
- *
- * Basic definitions, functions for querying libavcodec capabilities,
- * allocating core structures, etc.
- * @{
- */
-
-
-/**
- * Identify the syntax and semantics of the bitstream.
- * The principle is roughly:
- * Two decoders with the same ID can decode the same streams.
- * Two encoders with the same ID can encode compatible streams.
- * There may be slight deviations from the principle due to implementation
- * details.
- *
- * If you add a codec ID to this list, add it so that
- * 1. no value of a existing codec ID changes (that would break ABI),
- * 2. Give it a value which when taken as ASCII is recognized uniquely by a human as this specific codec.
- * This ensures that 2 forks can independently add AVCodecIDs without producing conflicts.
- *
- * After adding new codec IDs, do not forget to add an entry to the codec
- * descriptor list and bump libavcodec minor version.
- */
-enum AVCodecID {
- AV_CODEC_ID_NONE,
-
- /* video codecs */
- AV_CODEC_ID_MPEG1VIDEO,
- AV_CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding
- AV_CODEC_ID_MPEG2VIDEO_XVMC,
- AV_CODEC_ID_H261,
- AV_CODEC_ID_H263,
- AV_CODEC_ID_RV10,
- AV_CODEC_ID_RV20,
- AV_CODEC_ID_MJPEG,
- AV_CODEC_ID_MJPEGB,
- AV_CODEC_ID_LJPEG,
- AV_CODEC_ID_SP5X,
- AV_CODEC_ID_JPEGLS,
- AV_CODEC_ID_MPEG4,
- AV_CODEC_ID_RAWVIDEO,
- AV_CODEC_ID_MSMPEG4V1,
- AV_CODEC_ID_MSMPEG4V2,
- AV_CODEC_ID_MSMPEG4V3,
- AV_CODEC_ID_WMV1,
- AV_CODEC_ID_WMV2,
- AV_CODEC_ID_H263P,
- AV_CODEC_ID_H263I,
- AV_CODEC_ID_FLV1,
- AV_CODEC_ID_SVQ1,
- AV_CODEC_ID_SVQ3,
- AV_CODEC_ID_DVVIDEO,
- AV_CODEC_ID_HUFFYUV,
- AV_CODEC_ID_CYUV,
- AV_CODEC_ID_H264,
- AV_CODEC_ID_INDEO3,
- AV_CODEC_ID_VP3,
- AV_CODEC_ID_THEORA,
- AV_CODEC_ID_ASV1,
- AV_CODEC_ID_ASV2,
- AV_CODEC_ID_FFV1,
- AV_CODEC_ID_4XM,
- AV_CODEC_ID_VCR1,
- AV_CODEC_ID_CLJR,
- AV_CODEC_ID_MDEC,
- AV_CODEC_ID_ROQ,
- AV_CODEC_ID_INTERPLAY_VIDEO,
- AV_CODEC_ID_XAN_WC3,
- AV_CODEC_ID_XAN_WC4,
- AV_CODEC_ID_RPZA,
- AV_CODEC_ID_CINEPAK,
- AV_CODEC_ID_WS_VQA,
- AV_CODEC_ID_MSRLE,
- AV_CODEC_ID_MSVIDEO1,
- AV_CODEC_ID_IDCIN,
- AV_CODEC_ID_8BPS,
- AV_CODEC_ID_SMC,
- AV_CODEC_ID_FLIC,
- AV_CODEC_ID_TRUEMOTION1,
- AV_CODEC_ID_VMDVIDEO,
- AV_CODEC_ID_MSZH,
- AV_CODEC_ID_ZLIB,
- AV_CODEC_ID_QTRLE,
- AV_CODEC_ID_SNOW,
- AV_CODEC_ID_TSCC,
- AV_CODEC_ID_ULTI,
- AV_CODEC_ID_QDRAW,
- AV_CODEC_ID_VIXL,
- AV_CODEC_ID_QPEG,
- AV_CODEC_ID_PNG,
- AV_CODEC_ID_PPM,
- AV_CODEC_ID_PBM,
- AV_CODEC_ID_PGM,
- AV_CODEC_ID_PGMYUV,
- AV_CODEC_ID_PAM,
- AV_CODEC_ID_FFVHUFF,
- AV_CODEC_ID_RV30,
- AV_CODEC_ID_RV40,
- AV_CODEC_ID_VC1,
- AV_CODEC_ID_WMV3,
- AV_CODEC_ID_LOCO,
- AV_CODEC_ID_WNV1,
- AV_CODEC_ID_AASC,
- AV_CODEC_ID_INDEO2,
- AV_CODEC_ID_FRAPS,
- AV_CODEC_ID_TRUEMOTION2,
- AV_CODEC_ID_BMP,
- AV_CODEC_ID_CSCD,
- AV_CODEC_ID_MMVIDEO,
- AV_CODEC_ID_ZMBV,
- AV_CODEC_ID_AVS,
- AV_CODEC_ID_SMACKVIDEO,
- AV_CODEC_ID_NUV,
- AV_CODEC_ID_KMVC,
- AV_CODEC_ID_FLASHSV,
- AV_CODEC_ID_CAVS,
- AV_CODEC_ID_JPEG2000,
- AV_CODEC_ID_VMNC,
- AV_CODEC_ID_VP5,
- AV_CODEC_ID_VP6,
- AV_CODEC_ID_VP6F,
- AV_CODEC_ID_TARGA,
- AV_CODEC_ID_DSICINVIDEO,
- AV_CODEC_ID_TIERTEXSEQVIDEO,
- AV_CODEC_ID_TIFF,
- AV_CODEC_ID_GIF,
- AV_CODEC_ID_DXA,
- AV_CODEC_ID_DNXHD,
- AV_CODEC_ID_THP,
- AV_CODEC_ID_SGI,
- AV_CODEC_ID_C93,
- AV_CODEC_ID_BETHSOFTVID,
- AV_CODEC_ID_PTX,
- AV_CODEC_ID_TXD,
- AV_CODEC_ID_VP6A,
- AV_CODEC_ID_AMV,
- AV_CODEC_ID_VB,
- AV_CODEC_ID_PCX,
- AV_CODEC_ID_SUNRAST,
- AV_CODEC_ID_INDEO4,
- AV_CODEC_ID_INDEO5,
- AV_CODEC_ID_MIMIC,
- AV_CODEC_ID_RL2,
- AV_CODEC_ID_ESCAPE124,
- AV_CODEC_ID_DIRAC,
- AV_CODEC_ID_BFI,
- AV_CODEC_ID_CMV,
- AV_CODEC_ID_MOTIONPIXELS,
- AV_CODEC_ID_TGV,
- AV_CODEC_ID_TGQ,
- AV_CODEC_ID_TQI,
- AV_CODEC_ID_AURA,
- AV_CODEC_ID_AURA2,
- AV_CODEC_ID_V210X,
- AV_CODEC_ID_TMV,
- AV_CODEC_ID_V210,
- AV_CODEC_ID_DPX,
- AV_CODEC_ID_MAD,
- AV_CODEC_ID_FRWU,
- AV_CODEC_ID_FLASHSV2,
- AV_CODEC_ID_CDGRAPHICS,
- AV_CODEC_ID_R210,
- AV_CODEC_ID_ANM,
- AV_CODEC_ID_BINKVIDEO,
- AV_CODEC_ID_IFF_ILBM,
- AV_CODEC_ID_IFF_BYTERUN1,
- AV_CODEC_ID_KGV1,
- AV_CODEC_ID_YOP,
- AV_CODEC_ID_VP8,
- AV_CODEC_ID_PICTOR,
- AV_CODEC_ID_ANSI,
- AV_CODEC_ID_A64_MULTI,
- AV_CODEC_ID_A64_MULTI5,
- AV_CODEC_ID_R10K,
- AV_CODEC_ID_MXPEG,
- AV_CODEC_ID_LAGARITH,
- AV_CODEC_ID_PRORES,
- AV_CODEC_ID_JV,
- AV_CODEC_ID_DFA,
- AV_CODEC_ID_WMV3IMAGE,
- AV_CODEC_ID_VC1IMAGE,
- AV_CODEC_ID_UTVIDEO,
- AV_CODEC_ID_BMV_VIDEO,
- AV_CODEC_ID_VBLE,
- AV_CODEC_ID_DXTORY,
- AV_CODEC_ID_V410,
- AV_CODEC_ID_XWD,
- AV_CODEC_ID_CDXL,
- AV_CODEC_ID_XBM,
- AV_CODEC_ID_ZEROCODEC,
- AV_CODEC_ID_MSS1,
- AV_CODEC_ID_MSA1,
- AV_CODEC_ID_TSCC2,
- AV_CODEC_ID_MTS2,
- AV_CODEC_ID_CLLC,
- AV_CODEC_ID_MSS2,
- AV_CODEC_ID_VP9,
- AV_CODEC_ID_BRENDER_PIX= MKBETAG('B','P','I','X'),
- AV_CODEC_ID_Y41P = MKBETAG('Y','4','1','P'),
- AV_CODEC_ID_ESCAPE130 = MKBETAG('E','1','3','0'),
- AV_CODEC_ID_EXR = MKBETAG('0','E','X','R'),
- AV_CODEC_ID_AVRP = MKBETAG('A','V','R','P'),
-
- AV_CODEC_ID_012V = MKBETAG('0','1','2','V'),
- AV_CODEC_ID_G2M = MKBETAG( 0 ,'G','2','M'),
- AV_CODEC_ID_AVUI = MKBETAG('A','V','U','I'),
- AV_CODEC_ID_AYUV = MKBETAG('A','Y','U','V'),
- AV_CODEC_ID_TARGA_Y216 = MKBETAG('T','2','1','6'),
- AV_CODEC_ID_V308 = MKBETAG('V','3','0','8'),
- AV_CODEC_ID_V408 = MKBETAG('V','4','0','8'),
- AV_CODEC_ID_YUV4 = MKBETAG('Y','U','V','4'),
- AV_CODEC_ID_SANM = MKBETAG('S','A','N','M'),
- AV_CODEC_ID_PAF_VIDEO = MKBETAG('P','A','F','V'),
- AV_CODEC_ID_AVRN = MKBETAG('A','V','R','n'),
- AV_CODEC_ID_CPIA = MKBETAG('C','P','I','A'),
- AV_CODEC_ID_XFACE = MKBETAG('X','F','A','C'),
- AV_CODEC_ID_SGIRLE = MKBETAG('S','G','I','R'),
- AV_CODEC_ID_MVC1 = MKBETAG('M','V','C','1'),
- AV_CODEC_ID_MVC2 = MKBETAG('M','V','C','2'),
-
- /* various PCM "codecs" */
- AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
- AV_CODEC_ID_PCM_S16LE = 0x10000,
- AV_CODEC_ID_PCM_S16BE,
- AV_CODEC_ID_PCM_U16LE,
- AV_CODEC_ID_PCM_U16BE,
- AV_CODEC_ID_PCM_S8,
- AV_CODEC_ID_PCM_U8,
- AV_CODEC_ID_PCM_MULAW,
- AV_CODEC_ID_PCM_ALAW,
- AV_CODEC_ID_PCM_S32LE,
- AV_CODEC_ID_PCM_S32BE,
- AV_CODEC_ID_PCM_U32LE,
- AV_CODEC_ID_PCM_U32BE,
- AV_CODEC_ID_PCM_S24LE,
- AV_CODEC_ID_PCM_S24BE,
- AV_CODEC_ID_PCM_U24LE,
- AV_CODEC_ID_PCM_U24BE,
- AV_CODEC_ID_PCM_S24DAUD,
- AV_CODEC_ID_PCM_ZORK,
- AV_CODEC_ID_PCM_S16LE_PLANAR,
- AV_CODEC_ID_PCM_DVD,
- AV_CODEC_ID_PCM_F32BE,
- AV_CODEC_ID_PCM_F32LE,
- AV_CODEC_ID_PCM_F64BE,
- AV_CODEC_ID_PCM_F64LE,
- AV_CODEC_ID_PCM_BLURAY,
- AV_CODEC_ID_PCM_LXF,
- AV_CODEC_ID_S302M,
- AV_CODEC_ID_PCM_S8_PLANAR,
- AV_CODEC_ID_PCM_S24LE_PLANAR = MKBETAG(24,'P','S','P'),
- AV_CODEC_ID_PCM_S32LE_PLANAR = MKBETAG(32,'P','S','P'),
- AV_CODEC_ID_PCM_S16BE_PLANAR = MKBETAG('P','S','P',16),
-
- /* various ADPCM codecs */
- AV_CODEC_ID_ADPCM_IMA_QT = 0x11000,
- AV_CODEC_ID_ADPCM_IMA_WAV,
- AV_CODEC_ID_ADPCM_IMA_DK3,
- AV_CODEC_ID_ADPCM_IMA_DK4,
- AV_CODEC_ID_ADPCM_IMA_WS,
- AV_CODEC_ID_ADPCM_IMA_SMJPEG,
- AV_CODEC_ID_ADPCM_MS,
- AV_CODEC_ID_ADPCM_4XM,
- AV_CODEC_ID_ADPCM_XA,
- AV_CODEC_ID_ADPCM_ADX,
- AV_CODEC_ID_ADPCM_EA,
- AV_CODEC_ID_ADPCM_G726,
- AV_CODEC_ID_ADPCM_CT,
- AV_CODEC_ID_ADPCM_SWF,
- AV_CODEC_ID_ADPCM_YAMAHA,
- AV_CODEC_ID_ADPCM_SBPRO_4,
- AV_CODEC_ID_ADPCM_SBPRO_3,
- AV_CODEC_ID_ADPCM_SBPRO_2,
- AV_CODEC_ID_ADPCM_THP,
- AV_CODEC_ID_ADPCM_IMA_AMV,
- AV_CODEC_ID_ADPCM_EA_R1,
- AV_CODEC_ID_ADPCM_EA_R3,
- AV_CODEC_ID_ADPCM_EA_R2,
- AV_CODEC_ID_ADPCM_IMA_EA_SEAD,
- AV_CODEC_ID_ADPCM_IMA_EA_EACS,
- AV_CODEC_ID_ADPCM_EA_XAS,
- AV_CODEC_ID_ADPCM_EA_MAXIS_XA,
- AV_CODEC_ID_ADPCM_IMA_ISS,
- AV_CODEC_ID_ADPCM_G722,
- AV_CODEC_ID_ADPCM_IMA_APC,
- 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',' '),
-
- /* AMR */
- AV_CODEC_ID_AMR_NB = 0x12000,
- AV_CODEC_ID_AMR_WB,
-
- /* RealAudio codecs*/
- AV_CODEC_ID_RA_144 = 0x13000,
- AV_CODEC_ID_RA_288,
-
- /* various DPCM codecs */
- AV_CODEC_ID_ROQ_DPCM = 0x14000,
- AV_CODEC_ID_INTERPLAY_DPCM,
- AV_CODEC_ID_XAN_DPCM,
- AV_CODEC_ID_SOL_DPCM,
-
- /* audio codecs */
- AV_CODEC_ID_MP2 = 0x15000,
- AV_CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
- AV_CODEC_ID_AAC,
- AV_CODEC_ID_AC3,
- AV_CODEC_ID_DTS,
- AV_CODEC_ID_VORBIS,
- AV_CODEC_ID_DVAUDIO,
- AV_CODEC_ID_WMAV1,
- AV_CODEC_ID_WMAV2,
- AV_CODEC_ID_MACE3,
- AV_CODEC_ID_MACE6,
- AV_CODEC_ID_VMDAUDIO,
- AV_CODEC_ID_FLAC,
- AV_CODEC_ID_MP3ADU,
- AV_CODEC_ID_MP3ON4,
- AV_CODEC_ID_SHORTEN,
- AV_CODEC_ID_ALAC,
- AV_CODEC_ID_WESTWOOD_SND1,
- AV_CODEC_ID_GSM, ///< as in Berlin toast format
- AV_CODEC_ID_QDM2,
- AV_CODEC_ID_COOK,
- AV_CODEC_ID_TRUESPEECH,
- AV_CODEC_ID_TTA,
- AV_CODEC_ID_SMACKAUDIO,
- AV_CODEC_ID_QCELP,
- AV_CODEC_ID_WAVPACK,
- AV_CODEC_ID_DSICINAUDIO,
- AV_CODEC_ID_IMC,
- AV_CODEC_ID_MUSEPACK7,
- AV_CODEC_ID_MLP,
- AV_CODEC_ID_GSM_MS, /* as found in WAV */
- AV_CODEC_ID_ATRAC3,
- AV_CODEC_ID_VOXWARE,
- AV_CODEC_ID_APE,
- AV_CODEC_ID_NELLYMOSER,
- AV_CODEC_ID_MUSEPACK8,
- AV_CODEC_ID_SPEEX,
- AV_CODEC_ID_WMAVOICE,
- AV_CODEC_ID_WMAPRO,
- AV_CODEC_ID_WMALOSSLESS,
- AV_CODEC_ID_ATRAC3P,
- AV_CODEC_ID_EAC3,
- AV_CODEC_ID_SIPR,
- AV_CODEC_ID_MP1,
- AV_CODEC_ID_TWINVQ,
- AV_CODEC_ID_TRUEHD,
- AV_CODEC_ID_MP4ALS,
- AV_CODEC_ID_ATRAC1,
- AV_CODEC_ID_BINKAUDIO_RDFT,
- AV_CODEC_ID_BINKAUDIO_DCT,
- AV_CODEC_ID_AAC_LATM,
- AV_CODEC_ID_QDMC,
- AV_CODEC_ID_CELT,
- AV_CODEC_ID_G723_1,
- AV_CODEC_ID_G729,
- AV_CODEC_ID_8SVX_EXP,
- AV_CODEC_ID_8SVX_FIB,
- AV_CODEC_ID_BMV_AUDIO,
- AV_CODEC_ID_RALF,
- AV_CODEC_ID_IAC,
- AV_CODEC_ID_ILBC,
- AV_CODEC_ID_OPUS_DEPRECATED,
- AV_CODEC_ID_COMFORT_NOISE,
- AV_CODEC_ID_TAK_DEPRECATED,
- AV_CODEC_ID_FFWAVESYNTH = MKBETAG('F','F','W','S'),
-#if LIBAVCODEC_VERSION_MAJOR <= 54
- AV_CODEC_ID_8SVX_RAW = MKBETAG('8','S','V','X'),
-#endif
- AV_CODEC_ID_SONIC = MKBETAG('S','O','N','C'),
- AV_CODEC_ID_SONIC_LS = MKBETAG('S','O','N','L'),
- AV_CODEC_ID_PAF_AUDIO = MKBETAG('P','A','F','A'),
- AV_CODEC_ID_OPUS = MKBETAG('O','P','U','S'),
- 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'),
-
- /* subtitle codecs */
- AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs.
- AV_CODEC_ID_DVD_SUBTITLE = 0x17000,
- AV_CODEC_ID_DVB_SUBTITLE,
- AV_CODEC_ID_TEXT, ///< raw UTF-8 text
- AV_CODEC_ID_XSUB,
- AV_CODEC_ID_SSA,
- AV_CODEC_ID_MOV_TEXT,
- AV_CODEC_ID_HDMV_PGS_SUBTITLE,
- AV_CODEC_ID_DVB_TELETEXT,
- AV_CODEC_ID_SRT,
- AV_CODEC_ID_MICRODVD = MKBETAG('m','D','V','D'),
- AV_CODEC_ID_EIA_608 = MKBETAG('c','6','0','8'),
- AV_CODEC_ID_JACOSUB = MKBETAG('J','S','U','B'),
- AV_CODEC_ID_SAMI = MKBETAG('S','A','M','I'),
- AV_CODEC_ID_REALTEXT = MKBETAG('R','T','X','T'),
- AV_CODEC_ID_SUBVIEWER1 = MKBETAG('S','b','V','1'),
- AV_CODEC_ID_SUBVIEWER = MKBETAG('S','u','b','V'),
- AV_CODEC_ID_SUBRIP = MKBETAG('S','R','i','p'),
- AV_CODEC_ID_WEBVTT = MKBETAG('W','V','T','T'),
- AV_CODEC_ID_MPL2 = MKBETAG('M','P','L','2'),
- AV_CODEC_ID_VPLAYER = MKBETAG('V','P','l','r'),
- AV_CODEC_ID_PJS = MKBETAG('P','h','J','S'),
-
- /* other specific kind of codecs (generally used for attachments) */
- AV_CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs.
- AV_CODEC_ID_TTF = 0x18000,
- AV_CODEC_ID_BINTEXT = MKBETAG('B','T','X','T'),
- AV_CODEC_ID_XBIN = MKBETAG('X','B','I','N'),
- AV_CODEC_ID_IDF = MKBETAG( 0 ,'I','D','F'),
- AV_CODEC_ID_OTF = MKBETAG( 0 ,'O','T','F'),
- AV_CODEC_ID_SMPTE_KLV = MKBETAG('K','L','V','A'),
-
- AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it
-
- AV_CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS
- * stream (only used by libavformat) */
- AV_CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems
- * stream (only used by libavformat) */
- AV_CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information.
-
-#if FF_API_CODEC_ID
-#include "old_codec_ids.h"
-#endif
-};
-
-#if FF_API_CODEC_ID
-#define CodecID AVCodecID
-#endif
-
-/**
- * This struct describes the properties of a single codec described by an
- * AVCodecID.
- * @see avcodec_get_descriptor()
- */
-typedef struct AVCodecDescriptor {
- enum AVCodecID id;
- enum AVMediaType type;
- /**
- * Name of the codec described by this descriptor. It is non-empty and
- * unique for each codec descriptor. It should contain alphanumeric
- * characters and '_' only.
- */
- const char *name;
- /**
- * A more descriptive name for this codec. May be NULL.
- */
- const char *long_name;
- /**
- * Codec properties, a combination of AV_CODEC_PROP_* flags.
- */
- int props;
-} AVCodecDescriptor;
-
-/**
- * Codec uses only intra compression.
- * Video codecs only.
- */
-#define AV_CODEC_PROP_INTRA_ONLY (1 << 0)
-/**
- * Codec supports lossy compression. Audio and video codecs only.
- * @note a codec may support both lossy and lossless
- * compression modes
- */
-#define AV_CODEC_PROP_LOSSY (1 << 1)
-/**
- * Codec supports lossless compression. Audio and video codecs only.
- */
-#define AV_CODEC_PROP_LOSSLESS (1 << 2)
-
-#if FF_API_OLD_DECODE_AUDIO
-/* in bytes */
-#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
-#endif
-
-/**
- * @ingroup lavc_decoding
- * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
- * This is mainly needed because some optimized bitstream readers read
- * 32 or 64 bit at once and could read over the end.<br>
- * Note: If the first 23 bits of the additional bytes are not 0, then damaged
- * MPEG bitstreams could cause overread and segfault.
- */
-#define FF_INPUT_BUFFER_PADDING_SIZE 16
-
-/**
- * @ingroup lavc_encoding
- * minimum encoding buffer size
- * Used to avoid some checks during header writing.
- */
-#define FF_MIN_BUFFER_SIZE 16384
-
-
-/**
- * @ingroup lavc_encoding
- * motion estimation type.
- */
-enum Motion_Est_ID {
- ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed
- ME_FULL,
- ME_LOG,
- ME_PHODS,
- ME_EPZS, ///< enhanced predictive zonal search
- ME_X1, ///< reserved for experiments
- ME_HEX, ///< hexagon based search
- ME_UMH, ///< uneven multi-hexagon search
- ME_ITER, ///< iterative search
- ME_TESA, ///< transformed exhaustive search algorithm
-};
-
-/**
- * @ingroup lavc_decoding
- */
-enum AVDiscard{
- /* We leave some space between them for extensions (drop some
- * keyframes for intra-only or drop just some bidir frames). */
- AVDISCARD_NONE =-16, ///< discard nothing
- AVDISCARD_DEFAULT = 0, ///< discard useless packets like 0 size packets in avi
- AVDISCARD_NONREF = 8, ///< discard all non reference
- AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames
- AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes
- AVDISCARD_ALL = 48, ///< discard all
-};
-
-enum AVColorPrimaries{
- AVCOL_PRI_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
- AVCOL_PRI_UNSPECIFIED = 2,
- AVCOL_PRI_BT470M = 4,
- AVCOL_PRI_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
- AVCOL_PRI_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
- AVCOL_PRI_SMPTE240M = 7, ///< functionally identical to above
- AVCOL_PRI_FILM = 8,
- AVCOL_PRI_NB , ///< Not part of ABI
-};
-
-enum AVColorTransferCharacteristic{
- AVCOL_TRC_BT709 = 1, ///< also ITU-R BT1361
- AVCOL_TRC_UNSPECIFIED = 2,
- AVCOL_TRC_GAMMA22 = 4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
- AVCOL_TRC_GAMMA28 = 5, ///< also ITU-R BT470BG
- AVCOL_TRC_SMPTE240M = 7,
- AVCOL_TRC_NB , ///< Not part of ABI
-};
-
-enum AVColorSpace{
- AVCOL_SPC_RGB = 0,
- AVCOL_SPC_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
- AVCOL_SPC_UNSPECIFIED = 2,
- AVCOL_SPC_FCC = 4,
- AVCOL_SPC_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
- AVCOL_SPC_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
- AVCOL_SPC_SMPTE240M = 7,
- AVCOL_SPC_YCOCG = 8, ///< Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16
- AVCOL_SPC_NB , ///< Not part of ABI
-};
-#define AVCOL_SPC_YCGCO AVCOL_SPC_YCOCG
-
-enum AVColorRange{
- AVCOL_RANGE_UNSPECIFIED = 0,
- AVCOL_RANGE_MPEG = 1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges
- AVCOL_RANGE_JPEG = 2, ///< the normal 2^n-1 "JPEG" YUV ranges
- AVCOL_RANGE_NB , ///< Not part of ABI
-};
-
-/**
- * X X 3 4 X X are luma samples,
- * 1 2 1-6 are possible chroma positions
- * X X 5 6 X 0 is undefined/unknown position
- */
-enum AVChromaLocation{
- AVCHROMA_LOC_UNSPECIFIED = 0,
- AVCHROMA_LOC_LEFT = 1, ///< mpeg2/4, h264 default
- AVCHROMA_LOC_CENTER = 2, ///< mpeg1, jpeg, h263
- AVCHROMA_LOC_TOPLEFT = 3, ///< DV
- AVCHROMA_LOC_TOP = 4,
- AVCHROMA_LOC_BOTTOMLEFT = 5,
- AVCHROMA_LOC_BOTTOM = 6,
- AVCHROMA_LOC_NB , ///< Not part of ABI
-};
-
-enum AVAudioServiceType {
- AV_AUDIO_SERVICE_TYPE_MAIN = 0,
- AV_AUDIO_SERVICE_TYPE_EFFECTS = 1,
- AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED = 2,
- AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED = 3,
- AV_AUDIO_SERVICE_TYPE_DIALOGUE = 4,
- AV_AUDIO_SERVICE_TYPE_COMMENTARY = 5,
- AV_AUDIO_SERVICE_TYPE_EMERGENCY = 6,
- AV_AUDIO_SERVICE_TYPE_VOICE_OVER = 7,
- AV_AUDIO_SERVICE_TYPE_KARAOKE = 8,
- AV_AUDIO_SERVICE_TYPE_NB , ///< Not part of ABI
-};
-
-/**
- * @ingroup lavc_encoding
- */
-typedef struct RcOverride{
- int start_frame;
- int end_frame;
- int qscale; // If this is 0 then quality_factor will be used instead.
- float quality_factor;
-} RcOverride;
-
-#define FF_MAX_B_FRAMES 16
-
-/* encoding support
- These flags can be passed in AVCodecContext.flags before initialization.
- Note: Not everything is supported yet.
-*/
-
-#define CODEC_FLAG_QSCALE 0x0002 ///< Use fixed qscale.
-#define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / advanced prediction for H.263.
-#define CODEC_FLAG_QPEL 0x0010 ///< Use qpel MC.
-#define CODEC_FLAG_GMC 0x0020 ///< Use GMC.
-#define CODEC_FLAG_MV0 0x0040 ///< Always try a MB with MV=<0,0>.
-/**
- * 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.
- */
-#define CODEC_FLAG_INPUT_PRESERVED 0x0100
-#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.
-#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.
-#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.
-#define CODEC_FLAG_BITEXACT 0x00800000 ///< Use only bitexact stuff (except (I)DCT).
-/* Fx : Flag for h263+ extra options */
-#define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction
-#define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
-#define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
-#define CODEC_FLAG_CLOSED_GOP 0x80000000
-#define CODEC_FLAG2_FAST 0x00000001 ///< Allow non spec compliant speedup tricks.
-#define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding.
-#define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata.
-#define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format. DEPRECATED!!!!
-#define CODEC_FLAG2_IGNORE_CROP 0x00010000 ///< Discard cropping information from SPS.
-
-#if FF_API_MPV_GLOBAL_OPTS
-#define CODEC_FLAG_CBP_RD 0x04000000 ///< Use rate distortion optimization for cbp.
-#define CODEC_FLAG_QP_RD 0x08000000 ///< Use rate distortion optimization for qp selectioon.
-#define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< Strictly enforce GOP size.
-#define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping
-#endif
-#define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
-#define CODEC_FLAG2_SHOW_ALL 0x00400000 ///< Show all frames before the first keyframe
-
-/* Unsupported options :
- * Syntax Arithmetic coding (SAC)
- * Reference Picture Selection
- * Independent Segment Decoding */
-/* /Fx */
-/* codec capabilities */
-
-#define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< Decoder can use draw_horiz_band callback.
-/**
- * Codec uses get_buffer() for allocating buffers and supports custom allocators.
- * If not set, it might not use get_buffer() at all or use operations that
- * assume the buffer was allocated by avcodec_default_get_buffer.
- */
-#define CODEC_CAP_DR1 0x0002
-#define CODEC_CAP_TRUNCATED 0x0008
-/* Codec can export data for HW decoding (XvMC). */
-#define CODEC_CAP_HWACCEL 0x0010
-/**
- * Encoder or decoder requires flushing with NULL input at the end in order to
- * give the complete and correct output.
- *
- * NOTE: If this flag is not set, the codec is guaranteed to never be fed with
- * with NULL data. The user can still send NULL data to the public encode
- * or decode function, but libavcodec will not pass it along to the codec
- * unless this flag is set.
- *
- * Decoders:
- * The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL,
- * avpkt->size=0 at the end to get the delayed data until the decoder no longer
- * returns frames.
- *
- * Encoders:
- * The encoder needs to be fed with NULL data at the end of encoding until the
- * encoder no longer returns data.
- *
- * NOTE: For encoders implementing the AVCodec.encode2() function, setting this
- * flag also means that the encoder must set the pts and duration for
- * each output packet. If this flag is not set, the pts and duration will
- * be determined by libavcodec from the input frame.
- */
-#define CODEC_CAP_DELAY 0x0020
-/**
- * Codec can be fed a final frame with a smaller size.
- * This can be used to prevent truncation of the last audio samples.
- */
-#define CODEC_CAP_SMALL_LAST_FRAME 0x0040
-/**
- * Codec can export data for HW decoding (VDPAU).
- */
-#define CODEC_CAP_HWACCEL_VDPAU 0x0080
-/**
- * Codec can output multiple frames per AVPacket
- * Normally demuxers return one frame at a time, demuxers which do not do
- * are connected to a parser to split what they return into proper frames.
- * This flag is reserved to the very rare category of codecs which have a
- * bitstream that cannot be split into frames without timeconsuming
- * operations like full decoding. Demuxers carring such bitstreams thus
- * may return multiple frames in a packet. This has many disadvantages like
- * prohibiting stream copy in many cases thus it should only be considered
- * as a last resort.
- */
-#define CODEC_CAP_SUBFRAMES 0x0100
-/**
- * Codec is experimental and is thus avoided in favor of non experimental
- * encoders
- */
-#define CODEC_CAP_EXPERIMENTAL 0x0200
-/**
- * Codec should fill in channel configuration and samplerate instead of container
- */
-#define CODEC_CAP_CHANNEL_CONF 0x0400
-
-/**
- * Codec is able to deal with negative linesizes
- */
-#define CODEC_CAP_NEG_LINESIZES 0x0800
-
-/**
- * Codec supports frame-level multithreading.
- */
-#define CODEC_CAP_FRAME_THREADS 0x1000
-/**
- * Codec supports slice-based (or partition-based) multithreading.
- */
-#define CODEC_CAP_SLICE_THREADS 0x2000
-/**
- * Codec supports changed parameters at any point.
- */
-#define CODEC_CAP_PARAM_CHANGE 0x4000
-/**
- * Codec supports avctx->thread_count == 0 (auto).
- */
-#define CODEC_CAP_AUTO_THREADS 0x8000
-/**
- * Audio encoder supports receiving a different number of samples in each call.
- */
-#define CODEC_CAP_VARIABLE_FRAME_SIZE 0x10000
-/**
- * Codec is intra only.
- */
-#define CODEC_CAP_INTRA_ONLY 0x40000000
-/**
- * Codec is lossless.
- */
-#define CODEC_CAP_LOSSLESS 0x80000000
-
-//The following defines may change, don't expect compatibility if you use them.
-#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
-//Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...)
-
-/**
- * Pan Scan area.
- * This specifies the area which should be displayed.
- * Note there may be multiple such areas for one frame.
- */
-typedef struct AVPanScan{
- /**
- * id
- * - encoding: Set by user.
- * - decoding: Set by libavcodec.
- */
- int id;
-
- /**
- * width and height in 1/16 pel
- * - encoding: Set by user.
- * - decoding: Set by libavcodec.
- */
- int width;
- int height;
-
- /**
- * position of the top left corner in 1/16 pel for up to 3 fields/frames
- * - encoding: Set by user.
- * - decoding: Set by libavcodec.
- */
- int16_t position[3][2];
-}AVPanScan;
-
-#define FF_QSCALE_TYPE_MPEG1 0
-#define FF_QSCALE_TYPE_MPEG2 1
-#define FF_QSCALE_TYPE_H264 2
-#define FF_QSCALE_TYPE_VP56 3
-
-#define FF_BUFFER_TYPE_INTERNAL 1
-#define FF_BUFFER_TYPE_USER 2 ///< direct rendering buffers (image is (de)allocated by user)
-#define FF_BUFFER_TYPE_SHARED 4 ///< Buffer from somewhere else; don't deallocate image (data/base), all other tables are not shared.
-#define FF_BUFFER_TYPE_COPY 8 ///< Just a (modified) copy of some other buffer, don't deallocate anything.
-
-#define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore).
-#define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer.
-#define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content.
-#define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update).
-
-/**
- * @defgroup lavc_packet AVPacket
- *
- * Types and functions for working with AVPacket.
- * @{
- */
-enum AVPacketSideDataType {
- AV_PKT_DATA_PALETTE,
- AV_PKT_DATA_NEW_EXTRADATA,
-
- /**
- * An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
- * @code
- * u32le param_flags
- * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT)
- * s32le channel_count
- * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT)
- * u64le channel_layout
- * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE)
- * s32le sample_rate
- * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS)
- * s32le width
- * s32le height
- * @endcode
- */
- AV_PKT_DATA_PARAM_CHANGE,
-
- /**
- * An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of
- * structures with info about macroblocks relevant to splitting the
- * packet into smaller packets on macroblock edges (e.g. as for RFC 2190).
- * That is, it does not necessarily contain info about all macroblocks,
- * as long as the distance between macroblocks in the info is smaller
- * than the target payload size.
- * Each MB info structure is 12 bytes, and is laid out as follows:
- * @code
- * u32le bit offset from the start of the packet
- * u8 current quantizer at the start of the macroblock
- * u8 GOB number
- * u16le macroblock address within the GOB
- * u8 horizontal MV predictor
- * u8 vertical MV predictor
- * u8 horizontal MV predictor for block number 3
- * u8 vertical MV predictor for block number 3
- * @endcode
- */
- AV_PKT_DATA_H263_MB_INFO,
-
- /**
- * Recommmends skipping the specified number of samples
- * @code
- * u32le number of samples to skip from start of this packet
- * u32le number of samples to skip from end of this packet
- * u8 reason for start skip
- * u8 reason for end skip (0=padding silence, 1=convergence)
- * @endcode
- */
- AV_PKT_DATA_SKIP_SAMPLES=70,
-
- /**
- * An AV_PKT_DATA_JP_DUALMONO side data packet indicates that
- * the packet may contain "dual mono" audio specific to Japanese DTV
- * and if it is true, recommends only the selected channel to be used.
- * @code
- * u8 selected channels (0=mail/left, 1=sub/right, 2=both)
- * @endcode
- */
- AV_PKT_DATA_JP_DUALMONO,
-
- /**
- * A list of zero terminated key/value strings. There is no end marker for
- * the list, so it is required to rely on the side data size to stop.
- */
- AV_PKT_DATA_STRINGS_METADATA,
-
- /**
- * Subtitle event position
- * @code
- * u32le x1
- * u32le y1
- * u32le x2
- * u32le y2
- * @endcode
- */
- AV_PKT_DATA_SUBTITLE_POSITION,
-
- /**
- * Data found in BlockAdditional element of matroska container. There is
- * no end marker for the data, so it is required to rely on the side data
- * size to recognize the end. 8 byte id (as found in BlockAddId) followed
- * by data.
- */
- AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL,
-};
-
-/**
- * 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
- * then passed to muxers.
- *
- * For video, it should typically contain one compressed frame. For audio it may
- * contain several compressed frames.
- *
- * AVPacket is one of the few structs in FFmpeg, whose size is a part of public
- * ABI. Thus it may be allocated on stack and no new fields can be added to it
- * without libavcodec and libavformat major bump.
- *
- * The semantics of data ownership depends on the destruct field.
- * If it is set, the packet data is dynamically allocated and is valid
- * indefinitely until av_free_packet() is called (which in turn calls the
- * destruct callback to free the data). If destruct is not set, the packet data
- * is typically backed by some static buffer somewhere and is only valid for a
- * limited time (e.g. until the next read call when demuxing).
- *
- * The side data is always allocated with av_malloc() and is freed in
- * av_free_packet().
- */
-typedef struct AVPacket {
- /**
- * Presentation timestamp in AVStream->time_base units; the time at which
- * the decompressed packet will be presented to the user.
- * Can be AV_NOPTS_VALUE if it is not stored in the file.
- * pts MUST be larger or equal to dts as presentation cannot happen before
- * decompression, unless one wants to view hex dumps. Some formats misuse
- * the terms dts and pts/cts to mean something different. Such timestamps
- * must be converted to true pts/dts before they are stored in AVPacket.
- */
- int64_t pts;
- /**
- * Decompression timestamp in AVStream->time_base units; the time at which
- * the packet is decompressed.
- * Can be AV_NOPTS_VALUE if it is not stored in the file.
- */
- int64_t dts;
- uint8_t *data;
- int size;
- int stream_index;
- /**
- * A combination of AV_PKT_FLAG values
- */
- int flags;
- /**
- * 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;
- int side_data_elems;
-
- /**
- * Duration of this packet in AVStream->time_base units, 0 if unknown.
- * Equals next_pts - this_pts in presentation order.
- */
- int duration;
- void (*destruct)(struct AVPacket *);
- void *priv;
- int64_t pos; ///< byte position in stream, -1 if unknown
-
- /**
- * Time difference in AVStream->time_base units from the pts of this
- * packet to the point at which the output from the decoder has converged
- * independent from the availability of previous frames. That is, the
- * frames are virtually identical no matter if decoding started from
- * the very first frame or from this keyframe.
- * Is AV_NOPTS_VALUE if unknown.
- * This field is not the display duration of the current packet.
- * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY
- * set.
- *
- * The purpose of this field is to allow seeking in streams that have no
- * keyframes in the conventional sense. It corresponds to the
- * recovery point SEI in H.264 and match_time_delta in NUT. It is also
- * essential for some types of subtitle streams to ensure that all
- * subtitles are correctly displayed after seeking.
- */
- int64_t convergence_duration;
-} AVPacket;
-#define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe
-#define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted
-
-enum AVSideDataParamChangeFlags {
- AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001,
- AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002,
- AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004,
- AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008,
-};
-/**
- * @}
- */
-
-/**
- * This structure describes decoded (raw) audio or video data.
- *
- * AVFrame must be allocated using avcodec_alloc_frame() and freed with
- * avcodec_free_frame(). Note that this allocates only the AVFrame itself. The
- * buffers for the data must be managed through other means.
- *
- * AVFrame is typically allocated once and then reused multiple times to hold
- * different data (e.g. a single AVFrame to hold frames received from a
- * decoder). In such a case, avcodec_get_frame_defaults() should be used to
- * reset the frame to its original clean state before it is reused again.
- *
- * sizeof(AVFrame) is not a part of the public ABI, so new fields may be added
- * to the end with a minor bump.
- * Similarly fields that are marked as to be only accessed by
- * av_opt_ptr() can be reordered. This allows 2 forks to add fields
- * without breaking compatibility with each other.
- */
-typedef struct AVFrame {
-#define AV_NUM_DATA_POINTERS 8
- /**
- * pointer to the picture/channel planes.
- * This might be different from the first allocated byte
- * - encoding: Set by user
- * - decoding: set by AVCodecContext.get_buffer()
- */
- uint8_t *data[AV_NUM_DATA_POINTERS];
-
- /**
- * Size, in bytes, of the data for each picture/channel plane.
- *
- * For audio, only linesize[0] may be set. For planar audio, each channel
- * plane must be the same size.
- *
- * - encoding: Set by user
- * - decoding: set by AVCodecContext.get_buffer()
- */
- int linesize[AV_NUM_DATA_POINTERS];
-
- /**
- * pointers to the data planes/channels.
- *
- * For video, this should simply point to data[].
- *
- * For planar audio, each channel has a separate data pointer, and
- * linesize[0] contains the size of each channel buffer.
- * For packed audio, there is just one data pointer, and linesize[0]
- * contains the total size of the buffer for all channels.
- *
- * Note: Both data and extended_data will always be set by get_buffer(),
- * but for planar audio with more channels that can fit in data,
- * extended_data must be used by the decoder in order to access all
- * channels.
- *
- * encoding: set by user
- * decoding: set by AVCodecContext.get_buffer()
- */
- uint8_t **extended_data;
-
- /**
- * width and height of the video frame
- * - encoding: unused
- * - decoding: Read by user.
- */
- int width, height;
-
- /**
- * number of audio samples (per channel) described by this frame
- * - encoding: Set by user
- * - decoding: Set by libavcodec
- */
- int nb_samples;
-
- /**
- * format of the frame, -1 if unknown or unset
- * Values correspond to enum AVPixelFormat for video frames,
- * enum AVSampleFormat for audio)
- * - encoding: unused
- * - decoding: Read by user.
- */
- int format;
-
- /**
- * 1 -> keyframe, 0-> not
- * - encoding: Set by libavcodec.
- * - decoding: Set by libavcodec.
- */
- int key_frame;
-
- /**
- * Picture type of the frame, see ?_TYPE below.
- * - encoding: Set by libavcodec. for coded_picture (and set by user for input).
- * - decoding: Set by libavcodec.
- */
- enum AVPictureType pict_type;
-
- /**
- * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer.
- * This isn't used by libavcodec unless the default get/release_buffer() is used.
- * - encoding:
- * - decoding:
- */
- uint8_t *base[AV_NUM_DATA_POINTERS];
-
- /**
- * sample aspect ratio for the video frame, 0/1 if unknown/unspecified
- * - encoding: unused
- * - decoding: Read by user.
- */
- AVRational sample_aspect_ratio;
-
- /**
- * presentation timestamp in time_base units (time when frame should be shown to user)
- * If AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed.
- * - encoding: MUST be set by user.
- * - decoding: Set by libavcodec.
- */
- int64_t pts;
-
- /**
- * pts copied from the AVPacket that was decoded to produce this frame
- * - encoding: unused
- * - decoding: Read by user.
- */
- int64_t pkt_pts;
-
- /**
- * dts copied from the AVPacket that triggered returning this frame
- * - encoding: unused
- * - decoding: Read by user.
- */
- int64_t pkt_dts;
-
- /**
- * picture number in bitstream order
- * - encoding: set by
- * - decoding: Set by libavcodec.
- */
- int coded_picture_number;
- /**
- * picture number in display order
- * - encoding: set by
- * - decoding: Set by libavcodec.
- */
- int display_picture_number;
-
- /**
- * quality (between 1 (good) and FF_LAMBDA_MAX (bad))
- * - encoding: Set by libavcodec. for coded_picture (and set by user for input).
- * - decoding: Set by libavcodec.
- */
- int quality;
-
- /**
- * is this picture used as reference
- * The values for this are the same as the MpegEncContext.picture_structure
- * variable, that is 1->top field, 2->bottom field, 3->frame/both fields.
- * Set to 4 for delayed, non-reference frames.
- * - encoding: unused
- * - decoding: Set by libavcodec. (before get_buffer() call)).
- */
- int reference;
-
- /**
- * QP table
- * - encoding: unused
- * - decoding: Set by libavcodec.
- */
- int8_t *qscale_table;
- /**
- * QP store stride
- * - encoding: unused
- * - decoding: Set by libavcodec.
- */
- int qstride;
-
- /**
- *
- */
- int qscale_type;
-
- /**
- * mbskip_table[mb]>=1 if MB didn't change
- * stride= mb_width = (width+15)>>4
- * - encoding: unused
- * - decoding: Set by libavcodec.
- */
- uint8_t *mbskip_table;
-
- /**
- * motion vector table
- * @code
- * example:
- * int mv_sample_log2= 4 - motion_subsample_log2;
- * int mb_width= (width+15)>>4;
- * int mv_stride= (mb_width << mv_sample_log2) + 1;
- * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y];
- * @endcode
- * - encoding: Set by user.
- * - decoding: Set by libavcodec.
- */
- int16_t (*motion_val[2])[2];
-
- /**
- * macroblock type table
- * mb_type_base + mb_width + 2
- * - encoding: Set by user.
- * - decoding: Set by libavcodec.
- */
- uint32_t *mb_type;
-
- /**
- * DCT coefficients
- * - encoding: unused
- * - decoding: Set by libavcodec.
- */
- short *dct_coeff;
-
- /**
- * motion reference frame index
- * the order in which these are stored can depend on the codec.
- * - encoding: Set by user.
- * - decoding: Set by libavcodec.
- */
- int8_t *ref_index[2];
-
- /**
- * for some private data of the user
- * - encoding: unused
- * - decoding: Set by user.
- */
- void *opaque;
-
- /**
- * error
- * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR.
- * - decoding: unused
- */
- uint64_t error[AV_NUM_DATA_POINTERS];
-
- /**
- * type of the buffer (to keep track of who has to deallocate data[*])
- * - encoding: Set by the one who allocates it.
- * - decoding: Set by the one who allocates it.
- * Note: User allocated (direct rendering) & internal buffers cannot coexist currently.
- */
- int type;
-
- /**
- * When decoding, this signals how much the picture must be delayed.
- * extra_delay = repeat_pict / (2*fps)
- * - encoding: unused
- * - decoding: Set by libavcodec.
- */
- int repeat_pict;
-
- /**
- * The content of the picture is interlaced.
- * - encoding: Set by user.
- * - decoding: Set by libavcodec. (default 0)
- */
- int interlaced_frame;
-
- /**
- * If the content is interlaced, is top field displayed first.
- * - encoding: Set by user.
- * - decoding: Set by libavcodec.
- */
- int top_field_first;
-
- /**
- * Tell user application that palette has changed from previous frame.
- * - encoding: ??? (no palette-enabled encoder yet)
- * - decoding: Set by libavcodec. (default 0).
- */
- int palette_has_changed;
-
- /**
- * codec suggestion on buffer type if != 0
- * - encoding: unused
- * - decoding: Set by libavcodec. (before get_buffer() call)).
- */
- int buffer_hints;
-
- /**
- * Pan scan.
- * - encoding: Set by user.
- * - decoding: Set by libavcodec.
- */
- AVPanScan *pan_scan;
-
- /**
- * reordered opaque 64bit (generally an integer or a double precision float
- * PTS but can be anything).
- * The user sets AVCodecContext.reordered_opaque to represent the input at
- * that time,
- * the decoder reorders values as needed and sets AVFrame.reordered_opaque
- * to exactly one of the values provided by the user through AVCodecContext.reordered_opaque
- * @deprecated in favor of pkt_pts
- * - encoding: unused
- * - decoding: Read by user.
- */
- int64_t reordered_opaque;
-// ==> Start patch MPC
- int64_t reordered_opaque2;
-// <== End patch MPC
-
- /**
- * hardware accelerator private data (FFmpeg-allocated)
- * - encoding: unused
- * - decoding: Set by libavcodec
- */
- void *hwaccel_picture_private;
-
- /**
- * the AVCodecContext which ff_thread_get_buffer() was last called on
- * - encoding: Set by libavcodec.
- * - decoding: Set by libavcodec.
- */
- struct AVCodecContext *owner;
-
- /**
- * used by multithreading to store frame-specific info
- * - encoding: Set by libavcodec.
- * - decoding: Set by libavcodec.
- */
- void *thread_opaque;
-
- /**
- * log2 of the size of the block which a single vector in motion_val represents:
- * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)
- * - encoding: unused
- * - decoding: Set by libavcodec.
- */
- uint8_t motion_subsample_log2;
-
- /**
- * Sample rate of the audio data.
- *
- * - encoding: unused
- * - decoding: read by user
- */
- int sample_rate;
-
- /**
- * Channel layout of the audio data.
- *
- * - encoding: unused
- * - decoding: read by user.
- */
- uint64_t channel_layout;
-
- /**
- * frame timestamp estimated using various heuristics, in stream time base
- * Code outside libavcodec should access this field using:
- * av_frame_get_best_effort_timestamp(frame)
- * - encoding: unused
- * - decoding: set by libavcodec, read by user.
- */
- int64_t best_effort_timestamp;
-
- /**
- * reordered pos from the last AVPacket that has been input into the decoder
- * Code outside libavcodec should access this field using:
- * av_frame_get_pkt_pos(frame)
- * - encoding: unused
- * - decoding: Read by user.
- */
- int64_t pkt_pos;
-
- /**
- * duration of the corresponding packet, expressed in
- * AVStream->time_base units, 0 if unknown.
- * Code outside libavcodec should access this field using:
- * av_frame_get_pkt_duration(frame)
- * - encoding: unused
- * - decoding: Read by user.
- */
- int64_t pkt_duration;
-
- /**
- * metadata.
- * Code outside libavcodec should access this field using:
- * av_frame_get_metadata(frame)
- * - encoding: Set by user.
- * - decoding: Set by libavcodec.
- */
- AVDictionary *metadata;
-
- /**
- * decode error flags of the frame, set to a combination of
- * FF_DECODE_ERROR_xxx flags if the decoder produced a frame, but there
- * were errors during the decoding.
- * Code outside libavcodec should access this field using:
- * av_frame_get_decode_error_flags(frame)
- * - encoding: unused
- * - decoding: set by libavcodec, read by user.
- */
- int decode_error_flags;
-#define FF_DECODE_ERROR_INVALID_BITSTREAM 1
-#define FF_DECODE_ERROR_MISSING_REFERENCE 2
-
- /**
- * number of audio channels, only used for audio.
- * Code outside libavcodec should access this field using:
- * av_frame_get_channels(frame)
- * - encoding: unused
- * - decoding: Read by user.
- */
- int64_t channels;
-
- /**
- * size of the corresponding packet containing the compressed
- * frame. It must be accessed using av_frame_get_pkt_size() and
- * av_frame_set_pkt_size().
- * It is set to a negative value if unknown.
- * - encoding: unused
- * - decoding: set by libavcodec, read by user.
- */
- int pkt_size;
-
- /* ffdshow custom code (begin) */
- int h264_poc_decoded;
- int h264_poc_outputed;
- int h264_frame_num_decoded;
- int h264_max_frame_num;
- /* ffdshow custom code (end) */
-} AVFrame;
-
-/**
- * Accessors for some AVFrame fields.
- * The position of these field in the structure is not part of the ABI,
- * they should not be accessed directly outside libavcodec.
- */
-int64_t av_frame_get_best_effort_timestamp(const AVFrame *frame);
-void av_frame_set_best_effort_timestamp(AVFrame *frame, int64_t val);
-int64_t av_frame_get_pkt_duration (const AVFrame *frame);
-void av_frame_set_pkt_duration (AVFrame *frame, int64_t val);
-int64_t av_frame_get_pkt_pos (const AVFrame *frame);
-void av_frame_set_pkt_pos (AVFrame *frame, int64_t val);
-int64_t av_frame_get_channel_layout (const AVFrame *frame);
-void av_frame_set_channel_layout (AVFrame *frame, int64_t val);
-int av_frame_get_channels (const AVFrame *frame);
-void av_frame_set_channels (AVFrame *frame, int val);
-int av_frame_get_sample_rate (const AVFrame *frame);
-void av_frame_set_sample_rate (AVFrame *frame, int val);
-AVDictionary *av_frame_get_metadata (const AVFrame *frame);
-void av_frame_set_metadata (AVFrame *frame, AVDictionary *val);
-int av_frame_get_decode_error_flags (const AVFrame *frame);
-void av_frame_set_decode_error_flags (AVFrame *frame, int val);
-int av_frame_get_pkt_size(const AVFrame *frame);
-void av_frame_set_pkt_size(AVFrame *frame, int val);
-
-struct AVCodecInternal;
-
-enum AVFieldOrder {
- AV_FIELD_UNKNOWN,
- AV_FIELD_PROGRESSIVE,
- AV_FIELD_TT, //< Top coded_first, top displayed first
- AV_FIELD_BB, //< Bottom coded first, bottom displayed first
- AV_FIELD_TB, //< Top coded first, bottom displayed first
- AV_FIELD_BT, //< Bottom coded first, top displayed first
-};
-
-/**
- * main external API structure.
- * New fields can be added to the end with minor version bumps.
- * Removal, reordering and changes to existing fields require a major
- * version bump.
- * Please use AVOptions (av_opt* / av_set/get*()) to access these fields from user
- * applications.
- * sizeof(AVCodecContext) must not be used outside libav*.
- */
-
-// ==> Start patch MPC
-struct TlibavcodecExt;
-// <== End patch MPC
-
-typedef struct AVCodecContext {
- /**
- * information on struct for av_log
- * - set by avcodec_alloc_context3
- */
- const AVClass *av_class;
- int log_level_offset;
-
- enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */
- const struct AVCodec *codec;
- char codec_name[32];
- enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */
-
- /**
- * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
- * This is used to work around some encoder bugs.
- * A demuxer should set this to what is stored in the field used to identify the codec.
- * If there are multiple such fields in a container then the demuxer should choose the one
- * which maximizes the information about the used codec.
- * If the codec tag field in a container is larger than 32 bits then the demuxer should
- * remap the longer ID to 32 bits with a table or other structure. Alternatively a new
- * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated
- * first.
- * - encoding: Set by user, if not then the default based on codec_id will be used.
- * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
- */
- unsigned int codec_tag;
-
- /**
- * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
- * This is used to work around some encoder bugs.
- * - encoding: unused
- * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
- */
- unsigned int stream_codec_tag;
-
-#if FF_API_SUB_ID
- /**
- * @deprecated this field is unused
- */
- attribute_deprecated int sub_id;
-#endif
-
- void *priv_data;
-
- /**
- * Private context used for internal data.
- *
- * Unlike priv_data, this is not codec-specific. It is used in general
- * libavcodec functions.
- */
- struct AVCodecInternal *internal;
-
- /**
- * Private data of the user, can be used to carry app specific stuff.
- * - encoding: Set by user.
- * - decoding: Set by user.
- */
-// ==> Start patch MPC
- struct TlibavcodecExt *opaque;
-// ==> End patch MPC
-
- /**
- * the average bitrate
- * - encoding: Set by user; unused for constant quantizer encoding.
- * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream.
- */
- int bit_rate;
-
- /**
- * number of bits the bitstream is allowed to diverge from the reference.
- * the reference can be CBR (for CBR pass1) or VBR (for pass2)
- * - encoding: Set by user; unused for constant quantizer encoding.
- * - decoding: unused
- */
- int bit_rate_tolerance;
-
- /**
- * Global quality for codecs which cannot change it per frame.
- * This should be proportional to MPEG-1/2/4 qscale.
- * - encoding: Set by user.
- * - decoding: unused
- */
- int global_quality;
-
- /**
- * - encoding: Set by user.
- * - decoding: unused
- */
- int compression_level;
-#define FF_COMPRESSION_DEFAULT -1
-
- /**
- * CODEC_FLAG_*.
- * - encoding: Set by user.
- * - decoding: Set by user.
- */
- int flags;
-
- /**
- * CODEC_FLAG2_*
- * - encoding: Set by user.
- * - decoding: Set by user.
- */
- int flags2;
-
- /**
- * some codecs need / can use extradata like Huffman tables.
- * mjpeg: Huffman tables
- * rv10: additional flags
- * mpeg4: global headers (they can be in the bitstream or here)
- * The allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger
- * than extradata_size to avoid prolems if it is read with the bitstream reader.
- * The bytewise contents of extradata must not depend on the architecture or CPU endianness.
- * - encoding: Set/allocated/freed by libavcodec.
- * - decoding: Set/allocated/freed by user.
- */
- uint8_t *extradata;
- int extradata_size;
-
- /**
- * This is the fundamental unit of time (in seconds) in terms
- * of which frame timestamps are represented. For fixed-fps content,
- * timebase should be 1/framerate and timestamp increments should be
- * identically 1.
- * - encoding: MUST be set by user.
- * - decoding: Set by libavcodec.
- */
- AVRational time_base;
-
- /**
- * For some codecs, the time base is closer to the field rate than the frame rate.
- * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration
- * if no telecine is used ...
- *
- * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.
- */
- int ticks_per_frame;
-
- /**
- * Codec delay.
- *
- * Encoding: Number of frames delay there will be from the encoder input to
- * the decoder output. (we assume the decoder matches the spec)
- * Decoding: Number of frames delay in addition to what a standard decoder
- * as specified in the spec would produce.
- *
- * Video:
- * Number of frames the decoded output will be delayed relative to the
- * 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 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.
- *
- * - encoding: Set by libavcodec.
- * - decoding: Set by libavcodec.
- */
- int delay;
-
-
- /* video only */
- /**
- * picture width / height.
- * - encoding: MUST be set by user.
- * - decoding: Set by libavcodec.
- * Note: For compatibility it is possible to set this instead of
- * coded_width/height before decoding.
- */
- int width, height;
-
- /**
- * Bitstream width / height, may be different from width/height if lowres enabled.
- * - encoding: unused
- * - decoding: Set by user before init if known. Codec should override / dynamically change if needed.
- */
- int coded_width, coded_height;
-
-#define FF_ASPECT_EXTENDED 15
-
- /**
- * the number of pictures in a group of pictures, or 0 for intra_only
- * - encoding: Set by user.
- * - decoding: unused
- */
- int gop_size;
-
- /**
- * Pixel format, see AV_PIX_FMT_xxx.
- * May be set by the demuxer if known from headers.
- * May be overridden by the decoder if it knows better.
- * - encoding: Set by user.
- * - decoding: Set by user if known, overridden by libavcodec if known
- */
- enum AVPixelFormat pix_fmt;
-
- /**
- * Motion estimation algorithm used for video coding.
- * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex),
- * 8 (umh), 9 (iter), 10 (tesa) [7, 8, 10 are x264 specific, 9 is snow specific]
- * - encoding: MUST be set by user.
- * - decoding: unused
- */
- int me_method;
-
- /**
- * If non NULL, 'draw_horiz_band' is called by the libavcodec
- * decoder to draw a horizontal band. It improves cache usage. Not
- * all codecs can do that. You must check the codec capabilities
- * beforehand.
- * When multithreading is used, it may be called from multiple threads
- * at the same time; threads might draw different parts of the same AVFrame,
- * or multiple AVFrames, and there is no guarantee that slices will be drawn
- * in order.
- * The function is also used by hardware acceleration APIs.
- * It is called at least once during frame decoding to pass
- * the data needed for hardware render.
- * In that mode instead of pixel data, AVFrame points to
- * a structure specific to the acceleration API. The application
- * reads the structure and can change some fields to indicate progress
- * or mark state.
- * - encoding: unused
- * - decoding: Set by user.
- * @param height the height of the slice
- * @param y the y position of the slice
- * @param type 1->top field, 2->bottom field, 3->frame
- * @param offset offset into the AVFrame.data from which the slice should be read
- */
- void (*draw_horiz_band)(struct AVCodecContext *s,
- const AVFrame *src, int offset[AV_NUM_DATA_POINTERS],
- int y, int type, int height);
-
- /**
- * callback to negotiate the pixelFormat
- * @param fmt is the list of formats which are supported by the codec,
- * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality.
- * The first is always the native one.
- * @return the chosen format
- * - encoding: unused
- * - decoding: Set by user, if not set the native format will be chosen.
- */
- enum AVPixelFormat (*get_format)(struct AVCodecContext *s, const enum AVPixelFormat * fmt);
-
- /**
- * maximum number of B-frames between non-B-frames
- * Note: The output will be delayed by max_b_frames+1 relative to the input.
- * - encoding: Set by user.
- * - decoding: unused
- */
- int max_b_frames;
-
- /**
- * qscale factor between IP and B-frames
- * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset).
- * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
- * - encoding: Set by user.
- * - decoding: unused
- */
- float b_quant_factor;
-
- /** obsolete FIXME remove */
- int rc_strategy;
-#define FF_RC_STRATEGY_XVID 1
-
- int b_frame_strategy;
-
-#if FF_API_MPV_GLOBAL_OPTS
- /**
- * luma single coefficient elimination threshold
- * - encoding: Set by user.
- * - decoding: unused
- */
- attribute_deprecated int luma_elim_threshold;
-
- /**
- * chroma single coeff elimination threshold
- * - encoding: Set by user.
- * - decoding: unused
- */
- attribute_deprecated int chroma_elim_threshold;
-#endif
-
- /**
- * qscale offset between IP and B-frames
- * - encoding: Set by user.
- * - decoding: unused
- */
- float b_quant_offset;
-
- /**
- * Size of the frame reordering buffer in the decoder.
- * For MPEG-2 it is 1 IPB or 0 low delay IP.
- * - encoding: Set by libavcodec.
- * - decoding: Set by libavcodec.
- */
- int has_b_frames;
-
- /**
- * 0-> h263 quant 1-> mpeg quant
- * - encoding: Set by user.
- * - decoding: unused
- */
- int mpeg_quant;
-
- /**
- * qscale factor between P and I-frames
- * If > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset).
- * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
- * - encoding: Set by user.
- * - decoding: unused
- */
- float i_quant_factor;
-
- /**
- * qscale offset between P and I-frames
- * - encoding: Set by user.
- * - decoding: unused
- */
- float i_quant_offset;
-
- /**
- * luminance masking (0-> disabled)
- * - encoding: Set by user.
- * - decoding: unused
- */
- float lumi_masking;
-
- /**
- * temporary complexity masking (0-> disabled)
- * - encoding: Set by user.
- * - decoding: unused
- */
- float temporal_cplx_masking;
-
- /**
- * spatial complexity masking (0-> disabled)
- * - encoding: Set by user.
- * - decoding: unused
- */
- float spatial_cplx_masking;
-
- /**
- * p block masking (0-> disabled)
- * - encoding: Set by user.
- * - decoding: unused
- */
- float p_masking;
-
- /**
- * darkness masking (0-> disabled)
- * - encoding: Set by user.
- * - decoding: unused
- */
- float dark_masking;
-
- /**
- * slice count
- * - encoding: Set by libavcodec.
- * - decoding: Set by user (or 0).
- */
- int slice_count;
- /**
- * prediction method (needed for huffyuv)
- * - encoding: Set by user.
- * - decoding: unused
- */
- int prediction_method;
-#define FF_PRED_LEFT 0
-#define FF_PRED_PLANE 1
-#define FF_PRED_MEDIAN 2
-
- /**
- * slice offsets in the frame in bytes
- * - encoding: Set/allocated by libavcodec.
- * - decoding: Set/allocated by user (or NULL).
- */
- int *slice_offset;
-
- /**
- * sample aspect ratio (0 if unknown)
- * That is the width of a pixel divided by the height of the pixel.
- * Numerator and denominator must be relatively prime and smaller than 256 for some video standards.
- * - encoding: Set by user.
- * - decoding: Set by libavcodec.
- */
- AVRational sample_aspect_ratio;
-
- /**
- * motion estimation comparison function
- * - encoding: Set by user.
- * - decoding: unused
- */
- int me_cmp;
- /**
- * subpixel motion estimation comparison function
- * - encoding: Set by user.
- * - decoding: unused
- */
- int me_sub_cmp;
- /**
- * macroblock comparison function (not supported yet)
- * - encoding: Set by user.
- * - decoding: unused
- */
- int mb_cmp;
- /**
- * interlaced DCT comparison function
- * - encoding: Set by user.
- * - decoding: unused
- */
- int ildct_cmp;
-#define FF_CMP_SAD 0
-#define FF_CMP_SSE 1
-#define FF_CMP_SATD 2
-#define FF_CMP_DCT 3
-#define FF_CMP_PSNR 4
-#define FF_CMP_BIT 5
-#define FF_CMP_RD 6
-#define FF_CMP_ZERO 7
-#define FF_CMP_VSAD 8
-#define FF_CMP_VSSE 9
-#define FF_CMP_NSSE 10
-#define FF_CMP_W53 11
-#define FF_CMP_W97 12
-#define FF_CMP_DCTMAX 13
-#define FF_CMP_DCT264 14
-#define FF_CMP_CHROMA 256
-
- /**
- * ME diamond size & shape
- * - encoding: Set by user.
- * - decoding: unused
- */
- int dia_size;
-
- /**
- * amount of previous MV predictors (2a+1 x 2a+1 square)
- * - encoding: Set by user.
- * - decoding: unused
- */
- int last_predictor_count;
-
- /**
- * prepass for motion estimation
- * - encoding: Set by user.
- * - decoding: unused
- */
- int pre_me;
-
- /**
- * motion estimation prepass comparison function
- * - encoding: Set by user.
- * - decoding: unused
- */
- int me_pre_cmp;
-
- /**
- * ME prepass diamond size & shape
- * - encoding: Set by user.
- * - decoding: unused
- */
- int pre_dia_size;
-
- /**
- * subpel ME quality
- * - encoding: Set by user.
- * - decoding: unused
- */
- int me_subpel_quality;
-
- /**
- * DTG active format information (additional aspect ratio
- * information only used in DVB MPEG-2 transport streams)
- * 0 if not set.
- *
- * - encoding: unused
- * - decoding: Set by decoder.
- */
- int dtg_active_format;
-#define FF_DTG_AFD_SAME 8
-#define FF_DTG_AFD_4_3 9
-#define FF_DTG_AFD_16_9 10
-#define FF_DTG_AFD_14_9 11
-#define FF_DTG_AFD_4_3_SP_14_9 13
-#define FF_DTG_AFD_16_9_SP_14_9 14
-#define FF_DTG_AFD_SP_4_3 15
-
- /**
- * maximum motion estimation search range in subpel units
- * If 0 then no limit.
- *
- * - encoding: Set by user.
- * - decoding: unused
- */
- int me_range;
-
- /**
- * intra quantizer bias
- * - encoding: Set by user.
- * - decoding: unused
- */
- int intra_quant_bias;
-#define FF_DEFAULT_QUANT_BIAS 999999
-
- /**
- * inter quantizer bias
- * - encoding: Set by user.
- * - decoding: unused
- */
- int inter_quant_bias;
-
-#if FF_API_COLOR_TABLE_ID
- /**
- * color table ID
- * - encoding: unused
- * - decoding: Which clrtable should be used for 8bit RGB images.
- * Tables have to be stored somewhere. FIXME
- */
- attribute_deprecated int color_table_id;
-#endif
-
- /**
- * slice flags
- * - encoding: unused
- * - decoding: Set by user.
- */
- int slice_flags;
-#define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
-#define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
-#define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
-
- /**
- * XVideo Motion Acceleration
- * - encoding: forbidden
- * - decoding: set by decoder
- */
- int xvmc_acceleration;
-
- /**
- * macroblock decision mode
- * - encoding: Set by user.
- * - decoding: unused
- */
- int mb_decision;
-#define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp
-#define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits
-#define FF_MB_DECISION_RD 2 ///< rate distortion
-
- /**
- * custom intra quantization matrix
- * - encoding: Set by user, can be NULL.
- * - decoding: Set by libavcodec.
- */
- uint16_t *intra_matrix;
-
- /**
- * custom inter quantization matrix
- * - encoding: Set by user, can be NULL.
- * - decoding: Set by libavcodec.
- */
- uint16_t *inter_matrix;
-
- /**
- * scene change detection threshold
- * 0 is default, larger means fewer detected scene changes.
- * - encoding: Set by user.
- * - decoding: unused
- */
- int scenechange_threshold;
-
- /**
- * noise reduction strength
- * - encoding: Set by user.
- * - decoding: unused
- */
- int noise_reduction;
-
-#if FF_API_INTER_THRESHOLD
- /**
- * @deprecated this field is unused
- */
- attribute_deprecated int inter_threshold;
-#endif
-
-#if FF_API_MPV_GLOBAL_OPTS
- /**
- * @deprecated use mpegvideo private options instead
- */
- attribute_deprecated int quantizer_noise_shaping;
-#endif
-
- /**
- * Motion estimation threshold below which no motion estimation is
- * performed, but instead the user specified motion vectors are used.
- *
- * - encoding: Set by user.
- * - decoding: unused
- */
- int me_threshold;
-
- /**
- * Macroblock threshold below which the user specified macroblock types will be used.
- * - encoding: Set by user.
- * - decoding: unused
- */
- int mb_threshold;
-
- /**
- * precision of the intra DC coefficient - 8
- * - encoding: Set by user.
- * - decoding: unused
- */
- int intra_dc_precision;
-
- /**
- * Number of macroblock rows at the top which are skipped.
- * - encoding: unused
- * - decoding: Set by user.
- */
- int skip_top;
-
- /**
- * Number of macroblock rows at the bottom which are skipped.
- * - encoding: unused
- * - decoding: Set by user.
- */
- int skip_bottom;
-
- /**
- * Border processing masking, raises the quantizer for mbs on the borders
- * of the picture.
- * - encoding: Set by user.
- * - decoding: unused
- */
- float border_masking;
-
- /**
- * minimum MB lagrange multipler
- * - encoding: Set by user.
- * - decoding: unused
- */
- int mb_lmin;
-
- /**
- * maximum MB lagrange multipler
- * - encoding: Set by user.
- * - decoding: unused
- */
- int mb_lmax;
-
- /**
- *
- * - encoding: Set by user.
- * - decoding: unused
- */
- int me_penalty_compensation;
-
- /**
- *
- * - encoding: Set by user.
- * - decoding: unused
- */
- int bidir_refine;
-
- /**
- *
- * - encoding: Set by user.
- * - decoding: unused
- */
- int brd_scale;
-
- /**
- * minimum GOP size
- * - encoding: Set by user.
- * - decoding: unused
- */
- int keyint_min;
-
- /**
- * number of reference frames
- * - encoding: Set by user.
- * - decoding: Set by lavc.
- */
- int refs;
-
- /**
- * chroma qp offset from luma
- * - encoding: Set by user.
- * - decoding: unused
- */
- int chromaoffset;
-
- /**
- * Multiplied by qscale for each frame and added to scene_change_score.
- * - encoding: Set by user.
- * - decoding: unused
- */
- int scenechange_factor;
-
- /**
- *
- * Note: Value depends upon the compare function used for fullpel ME.
- * - encoding: Set by user.
- * - decoding: unused
- */
- int mv0_threshold;
-
- /**
- * Adjust sensitivity of b_frame_strategy 1.
- * - encoding: Set by user.
- * - decoding: unused
- */
- int b_sensitivity;
-
- /**
- * Chromaticity coordinates of the source primaries.
- * - encoding: Set by user
- * - decoding: Set by libavcodec
- */
- enum AVColorPrimaries color_primaries;
-
- /**
- * Color Transfer Characteristic.
- * - encoding: Set by user
- * - decoding: Set by libavcodec
- */
- enum AVColorTransferCharacteristic color_trc;
-
- /**
- * YUV colorspace type.
- * - encoding: Set by user
- * - decoding: Set by libavcodec
- */
- enum AVColorSpace colorspace;
-
- /**
- * MPEG vs JPEG YUV range.
- * - encoding: Set by user
- * - decoding: Set by libavcodec
- */
- enum AVColorRange color_range;
-
- /**
- * This defines the location of chroma samples.
- * - encoding: Set by user
- * - decoding: Set by libavcodec
- */
- enum AVChromaLocation chroma_sample_location;
-
- /**
- * Number of slices.
- * Indicates number of picture subdivisions. Used for parallelized
- * decoding.
- * - encoding: Set by user
- * - decoding: unused
- */
- int slices;
-
- /** Field order
- * - encoding: set by libavcodec
- * - decoding: Set by user.
- */
- enum AVFieldOrder field_order;
-
- /* audio only */
- int sample_rate; ///< samples per second
- int channels; ///< number of audio channels
-
- /**
- * audio sample format
- * - encoding: Set by user.
- * - decoding: Set by libavcodec.
- */
- enum AVSampleFormat sample_fmt; ///< sample format
-
- /* The following data should not be initialized. */
- /**
- * Number of samples per channel in an audio frame.
- *
- * - encoding: set by libavcodec in avcodec_open2(). Each submitted frame
- * except the last must contain exactly frame_size samples per channel.
- * May be 0 when the codec has CODEC_CAP_VARIABLE_FRAME_SIZE set, then the
- * frame size is not restricted.
- * - decoding: may be set by some decoders to indicate constant frame size
- */
- int frame_size;
-
- /**
- * Frame counter, set by libavcodec.
- *
- * - decoding: total number of frames returned from the decoder so far.
- * - encoding: total number of frames passed to the encoder so far.
- *
- * @note the counter is not incremented if encoding/decoding resulted in
- * an error.
- */
- int frame_number;
-
- /**
- * number of bytes per packet if constant and known or 0
- * Used by some WAV based audio codecs.
- */
- int block_align;
-
- /**
- * Audio cutoff bandwidth (0 means "automatic")
- * - encoding: Set by user.
- * - decoding: unused
- */
- int cutoff;
-
-#if FF_API_REQUEST_CHANNELS
- /**
- * Decoder should decode to this many channels if it can (0 for default)
- * - encoding: unused
- * - decoding: Set by user.
- * @deprecated Deprecated in favor of request_channel_layout.
- */
- int request_channels;
-#endif
-
- /**
- * Audio channel layout.
- * - encoding: set by user.
- * - decoding: set by user, may be overwritten by libavcodec.
- */
- uint64_t channel_layout;
-
- /**
- * Request decoder to use this channel layout if it can (0 for default)
- * - encoding: unused
- * - decoding: Set by user.
- */
- uint64_t request_channel_layout;
-
- /**
- * Type of service that the audio stream conveys.
- * - encoding: Set by user.
- * - decoding: Set by libavcodec.
- */
- enum AVAudioServiceType audio_service_type;
-
- /**
- * desired sample format
- * - encoding: Not used.
- * - decoding: Set by user.
- * Decoder will decode to this format if it can.
- */
- enum AVSampleFormat request_sample_fmt;
-
- /**
- * Called at the beginning of each frame to get a buffer for it.
- *
- * The function will set AVFrame.data[], AVFrame.linesize[].
- * AVFrame.extended_data[] must also be set, but it should be the same as
- * AVFrame.data[] except for planar audio with more channels than can fit
- * in AVFrame.data[]. In that case, AVFrame.data[] shall still contain as
- * many data pointers as it can hold.
- *
- * if CODEC_CAP_DR1 is not set then get_buffer() must call
- * avcodec_default_get_buffer() instead of providing buffers allocated by
- * some other means.
- *
- * AVFrame.data[] should be 32- or 16-byte-aligned unless the CPU doesn't
- * need it. avcodec_default_get_buffer() aligns the output buffer properly,
- * but if get_buffer() is overridden then alignment considerations should
- * be taken into account.
- *
- * @see avcodec_default_get_buffer()
- *
- * Video:
- *
- * If pic.reference is set then the frame will be read later by libavcodec.
- * 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.
- *
- * If frame multithreading is used and thread_safe_callbacks is set,
- * it may be called from a different thread, but not from more than one at
- * once. Does not need to be reentrant.
- *
- * @see release_buffer(), reget_buffer()
- * @see avcodec_align_dimensions2()
- *
- * Audio:
- *
- * Decoders request a buffer of a particular size by setting
- * AVFrame.nb_samples prior to calling get_buffer(). The decoder may,
- * however, utilize only part of the buffer by setting AVFrame.nb_samples
- * to a smaller value in the output frame.
- *
- * Decoders cannot use the buffer after returning from
- * avcodec_decode_audio4(), so they will not call release_buffer(), as it
- * is assumed to be released immediately upon return. In some rare cases,
- * a decoder may need to call get_buffer() more than once in a single
- * call to avcodec_decode_audio4(). In that case, when get_buffer() is
- * called again after it has already been called once, the previously
- * acquired buffer is assumed to be released at that time and may not be
- * reused by the decoder.
- *
- * As a convenience, av_samples_get_buffer_size() and
- * av_samples_fill_arrays() in libavutil may be used by custom get_buffer()
- * functions to find the required data size and to fill data pointers and
- * linesize. In AVFrame.linesize, only linesize[0] may be set for audio
- * since all planes must be the same size.
- *
- * @see av_samples_get_buffer_size(), av_samples_fill_arrays()
- *
- * - encoding: unused
- * - decoding: Set by libavcodec, user can override.
- */
- int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
-
- /**
- * Called to release buffers which were allocated with get_buffer.
- * A released buffer can be reused in get_buffer().
- * pic.data[*] must be set to NULL.
- * May be called from a different thread if frame multithreading is used,
- * but not by more than one thread at once, so does not need to be reentrant.
- * - encoding: unused
- * - decoding: Set by libavcodec, user can override.
- */
- void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
-
- /**
- * Called at the beginning of a frame to get cr buffer for it.
- * Buffer type (size, hints) must be the same. libavcodec won't check it.
- * libavcodec will pass previous buffer in pic, function should return
- * same buffer or new buffer with old frame "painted" into it.
- * If pic.data[0] == NULL must behave like get_buffer().
- * if CODEC_CAP_DR1 is not set then reget_buffer() must call
- * avcodec_default_reget_buffer() instead of providing buffers allocated by
- * some other means.
- * - encoding: unused
- * - decoding: Set by libavcodec, user can override.
- */
- int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);
-
-
- /* - encoding parameters */
- float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
- float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
-
- /**
- * minimum quantizer
- * - encoding: Set by user.
- * - decoding: unused
- */
- int qmin;
-
- /**
- * maximum quantizer
- * - encoding: Set by user.
- * - decoding: unused
- */
- int qmax;
-
- /**
- * maximum quantizer difference between frames
- * - encoding: Set by user.
- * - decoding: unused
- */
- int max_qdiff;
-
- /**
- * ratecontrol qmin qmax limiting method
- * 0-> clipping, 1-> use a nice continuous function to limit qscale wthin qmin/qmax.
- * - encoding: Set by user.
- * - decoding: unused
- */
- float rc_qsquish;
-
- float rc_qmod_amp;
- int rc_qmod_freq;
-
- /**
- * decoder bitstream buffer size
- * - encoding: Set by user.
- * - decoding: unused
- */
- int rc_buffer_size;
-
- /**
- * ratecontrol override, see RcOverride
- * - encoding: Allocated/set/freed by user.
- * - decoding: unused
- */
- int rc_override_count;
- RcOverride *rc_override;
-
- /**
- * rate control equation
- * - encoding: Set by user
- * - decoding: unused
- */
- const char *rc_eq;
-
- /**
- * maximum bitrate
- * - encoding: Set by user.
- * - decoding: unused
- */
- int rc_max_rate;
-
- /**
- * minimum bitrate
- * - encoding: Set by user.
- * - decoding: unused
- */
- int rc_min_rate;
-
- float rc_buffer_aggressivity;
-
- /**
- * initial complexity for pass1 ratecontrol
- * - encoding: Set by user.
- * - decoding: unused
- */
- float rc_initial_cplx;
-
- /**
- * Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow.
- * - encoding: Set by user.
- * - decoding: unused.
- */
- float rc_max_available_vbv_use;
-
- /**
- * Ratecontrol attempt to use, at least, <value> times the amount needed to prevent a vbv overflow.
- * - encoding: Set by user.
- * - decoding: unused.
- */
- float rc_min_vbv_overflow_use;
-
- /**
- * Number of bits which should be loaded into the rc buffer before decoding starts.
- * - encoding: Set by user.
- * - decoding: unused
- */
- int rc_initial_buffer_occupancy;
-
-#define FF_CODER_TYPE_VLC 0
-#define FF_CODER_TYPE_AC 1
-#define FF_CODER_TYPE_RAW 2
-#define FF_CODER_TYPE_RLE 3
-#define FF_CODER_TYPE_DEFLATE 4
- /**
- * coder type
- * - encoding: Set by user.
- * - decoding: unused
- */
- int coder_type;
-
- /**
- * context model
- * - encoding: Set by user.
- * - decoding: unused
- */
- int context_model;
-
- /**
- * minimum Lagrange multipler
- * - encoding: Set by user.
- * - decoding: unused
- */
- int lmin;
-
- /**
- * maximum Lagrange multipler
- * - encoding: Set by user.
- * - decoding: unused
- */
- int lmax;
-
- /**
- * frame skip threshold
- * - encoding: Set by user.
- * - decoding: unused
- */
- int frame_skip_threshold;
-
- /**
- * frame skip factor
- * - encoding: Set by user.
- * - decoding: unused
- */
- int frame_skip_factor;
-
- /**
- * frame skip exponent
- * - encoding: Set by user.
- * - decoding: unused
- */
- int frame_skip_exp;
-
- /**
- * frame skip comparison function
- * - encoding: Set by user.
- * - decoding: unused
- */
- int frame_skip_cmp;
-
- /**
- * trellis RD quantization
- * - encoding: Set by user.
- * - decoding: unused
- */
- int trellis;
-
- /**
- * - encoding: Set by user.
- * - decoding: unused
- */
- int min_prediction_order;
-
- /**
- * - encoding: Set by user.
- * - decoding: unused
- */
- int max_prediction_order;
-
- /**
- * GOP timecode frame start number
- * - encoding: Set by user, in non drop frame format
- * - decoding: Set by libavcodec (timecode in the 25 bits format, -1 if unset)
- */
- int64_t timecode_frame_start;
-
- /* The RTP callback: This function is called */
- /* every time the encoder has a packet to send. */
- /* It depends on the encoder if the data starts */
- /* with a Start Code (it should). H.263 does. */
- /* mb_nb contains the number of macroblocks */
- /* encoded in the RTP payload. */
- void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
-
- int rtp_payload_size; /* The size of the RTP payload: the coder will */
- /* do its best to deliver a chunk with size */
- /* below rtp_payload_size, the chunk will start */
- /* with a start code on some codecs like H.263. */
- /* This doesn't take account of any particular */
- /* headers inside the transmitted RTP payload. */
-
- /* statistics, used for 2-pass encoding */
- int mv_bits;
- int header_bits;
- int i_tex_bits;
- int p_tex_bits;
- int i_count;
- int p_count;
- int skip_count;
- int misc_bits;
-
- /**
- * number of bits used for the previously encoded frame
- * - encoding: Set by libavcodec.
- * - decoding: unused
- */
- int frame_bits;
-
- /**
- * pass1 encoding statistics output buffer
- * - encoding: Set by libavcodec.
- * - decoding: unused
- */
- char *stats_out;
-
- /**
- * pass2 encoding statistics input buffer
- * Concatenated stuff from stats_out of pass1 should be placed here.
- * - encoding: Allocated/set/freed by user.
- * - decoding: unused
- */
- char *stats_in;
-
- /**
- * Work around bugs in encoders which sometimes cannot be detected automatically.
- * - encoding: Set by user
- * - decoding: Set by user
- */
- int workaround_bugs;
-#define FF_BUG_AUTODETECT 1 ///< autodetection
-#define FF_BUG_OLD_MSMPEG4 2
-#define FF_BUG_XVID_ILACE 4
-#define FF_BUG_UMP4 8
-#define FF_BUG_NO_PADDING 16
-#define FF_BUG_AMV 32
-#define FF_BUG_AC_VLC 0 ///< Will be removed, libavcodec can now handle these non-compliant files by default.
-#define FF_BUG_QPEL_CHROMA 64
-#define FF_BUG_STD_QPEL 128
-#define FF_BUG_QPEL_CHROMA2 256
-#define FF_BUG_DIRECT_BLOCKSIZE 512
-#define FF_BUG_EDGE 1024
-#define FF_BUG_HPEL_CHROMA 2048
-#define FF_BUG_DC_CLIP 4096
-#define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders.
-#define FF_BUG_TRUNCATED 16384
-
- /**
- * strictly follow the standard (MPEG4, ...).
- * - encoding: Set by user.
- * - decoding: Set by user.
- * Setting this to STRICT or higher means the encoder and decoder will
- * generally do stupid things, whereas setting it to unofficial or lower
- * will mean the encoder might produce output that is not supported by all
- * spec-compliant decoders. Decoders don't differentiate between normal,
- * unofficial and experimental (that is, they always try to decode things
- * when they can) unless they are explicitly asked to behave stupidly
- * (=strictly conform to the specs)
- */
- int strict_std_compliance;
-#define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software.
-#define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences.
-#define FF_COMPLIANCE_NORMAL 0
-#define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions
-#define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things.
-
- /**
- * error concealment flags
- * - encoding: unused
- * - decoding: Set by user.
- */
- int error_concealment;
-#define FF_EC_GUESS_MVS 1
-#define FF_EC_DEBLOCK 2
-
- /**
- * debug
- * - encoding: Set by user.
- * - decoding: Set by user.
- */
- int debug;
-#define FF_DEBUG_PICT_INFO 1
-#define FF_DEBUG_RC 2
-#define FF_DEBUG_BITSTREAM 4
-#define FF_DEBUG_MB_TYPE 8
-#define FF_DEBUG_QP 16
-#define FF_DEBUG_MV 32
-#define FF_DEBUG_DCT_COEFF 0x00000040
-#define FF_DEBUG_SKIP 0x00000080
-#define FF_DEBUG_STARTCODE 0x00000100
-#define FF_DEBUG_PTS 0x00000200
-#define FF_DEBUG_ER 0x00000400
-#define FF_DEBUG_MMCO 0x00000800
-#define FF_DEBUG_BUGS 0x00001000
-#define FF_DEBUG_VIS_QP 0x00002000
-#define FF_DEBUG_VIS_MB_TYPE 0x00004000
-#define FF_DEBUG_BUFFERS 0x00008000
-#define FF_DEBUG_THREADS 0x00010000
-
- /**
- * debug
- * - encoding: Set by user.
- * - decoding: Set by user.
- */
- int debug_mv;
-#define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames
-#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
-
- /**
- * Error recognition; may misdetect some more or less valid parts as errors.
- * - encoding: unused
- * - decoding: Set by user.
- */
- int err_recognition;
-#define AV_EF_CRCCHECK (1<<0)
-#define AV_EF_BITSTREAM (1<<1)
-#define AV_EF_BUFFER (1<<2)
-#define AV_EF_EXPLODE (1<<3)
-
-#define AV_EF_CAREFUL (1<<16)
-#define AV_EF_COMPLIANT (1<<17)
-#define AV_EF_AGGRESSIVE (1<<18)
-
-
- /**
- * opaque 64bit number (generally a PTS) that will be reordered and
- * output in AVFrame.reordered_opaque
- * @deprecated in favor of pkt_pts
- * - encoding: unused
- * - decoding: Set by user.
- */
- int64_t reordered_opaque;
-// ==> Start patch MPC
- int64_t reordered_opaque2;
-// ==> End patch MPC
-
- /**
- * Hardware accelerator in use
- * - encoding: unused.
- * - decoding: Set by libavcodec
- */
- struct AVHWAccel *hwaccel;
-
- /**
- * Hardware accelerator context.
- * For some hardware accelerators, a global context needs to be
- * provided by the user. In that case, this holds display-dependent
- * data FFmpeg cannot instantiate itself. Please refer to the
- * FFmpeg HW accelerator documentation to know how to fill this
- * is. e.g. for VA API, this is a struct vaapi_context.
- * - encoding: unused
- * - decoding: Set by user
- */
- void *hwaccel_context;
-
- /**
- * error
- * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR.
- * - decoding: unused
- */
- uint64_t error[AV_NUM_DATA_POINTERS];
-
- /**
- * DCT algorithm, see FF_DCT_* below
- * - encoding: Set by user.
- * - decoding: unused
- */
- int dct_algo;
-#define FF_DCT_AUTO 0
-#define FF_DCT_FASTINT 1
-#define FF_DCT_INT 2
-#define FF_DCT_MMX 3
-#define FF_DCT_ALTIVEC 5
-#define FF_DCT_FAAN 6
-
- /**
- * IDCT algorithm, see FF_IDCT_* below.
- * - encoding: Set by user.
- * - decoding: Set by user.
- */
- int idct_algo;
-#define FF_IDCT_AUTO 0
-#define FF_IDCT_INT 1
-#define FF_IDCT_SIMPLE 2
-#define FF_IDCT_SIMPLEMMX 3
-#define FF_IDCT_LIBMPEG2MMX 4
-#if FF_API_MMI
-#define FF_IDCT_MMI 5
-#endif
-#define FF_IDCT_ARM 7
-#define FF_IDCT_ALTIVEC 8
-#define FF_IDCT_SH4 9
-#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
-#define FF_IDCT_SIMPLEVIS 18
-#define FF_IDCT_FAAN 20
-#define FF_IDCT_SIMPLENEON 22
-#define FF_IDCT_SIMPLEALPHA 23
-#if FF_API_IDCT
-#define FF_IDCT_H264 11
-#define FF_IDCT_VP3 12
-#define FF_IDCT_CAVS 15
-#define FF_IDCT_WMV2 19
-#define FF_IDCT_EA 21
-#define FF_IDCT_BINK 24
-#endif
-
-#if FF_API_DSP_MASK
- /**
- * Unused.
- * @deprecated use av_set_cpu_flags_mask() instead.
- */
- attribute_deprecated unsigned dsp_mask;
-#endif
-
- /**
- * bits per sample/pixel from the demuxer (needed for huffyuv).
- * - encoding: Set by libavcodec.
- * - decoding: Set by user.
- */
- int bits_per_coded_sample;
-
- /**
- * Bits per sample/pixel of internal libavcodec pixel/sample format.
- * - encoding: set by user.
- * - decoding: set by libavcodec.
- */
- int bits_per_raw_sample;
-
- /**
- * low resolution decoding, 1-> 1/2 size, 2->1/4 size
- * - encoding: unused
- * - decoding: Set by user.
- */
- int lowres;
-
- /**
- * the picture in the bitstream
- * - encoding: Set by libavcodec.
- * - decoding: Set by libavcodec.
- */
- AVFrame *coded_frame;
-
- /**
- * thread count
- * is used to decide how many independent tasks should be passed to execute()
- * - encoding: Set by user.
- * - decoding: Set by user.
- */
- int thread_count;
-
- /**
- * Which multithreading methods to use.
- * Use of FF_THREAD_FRAME will increase decoding delay by one frame per thread,
- * so clients which cannot provide future frames should not use it.
- *
- * - encoding: Set by user, otherwise the default is used.
- * - decoding: Set by user, otherwise the default is used.
- */
- int thread_type;
-#define FF_THREAD_FRAME 1 ///< Decode more than one frame at once
-#define FF_THREAD_SLICE 2 ///< Decode more than one part of a single frame at once
-
- /**
- * Which multithreading methods are in use by the codec.
- * - encoding: Set by libavcodec.
- * - decoding: Set by libavcodec.
- */
- int active_thread_type;
-
- /**
- * Set by the client if its custom get_buffer() callback can be called
- * synchronously from another thread, which allows faster multithreaded decoding.
- * draw_horiz_band() will be called from other threads regardless of this setting.
- * Ignored if the default get_buffer() is used.
- * - encoding: Set by user.
- * - decoding: Set by user.
- */
- int thread_safe_callbacks;
-
- /**
- * The codec may call this to execute several independent things.
- * It will return only after finishing all tasks.
- * The user may replace this with some multithreaded implementation,
- * the default implementation will execute the parts serially.
- * @param count the number of things to execute
- * - encoding: Set by libavcodec, user can override.
- * - decoding: Set by libavcodec, user can override.
- */
- int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size);
-
- /**
- * The codec may call this to execute several independent things.
- * It will return only after finishing all tasks.
- * The user may replace this with some multithreaded implementation,
- * the default implementation will execute the parts serially.
- * Also see avcodec_thread_init and e.g. the --enable-pthread configure option.
- * @param c context passed also to func
- * @param count the number of things to execute
- * @param arg2 argument passed unchanged to func
- * @param ret return values of executed functions, must have space for "count" values. May be NULL.
- * @param func function that will be called count times, with jobnr from 0 to count-1.
- * threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no
- * two instances of func executing at the same time will have the same threadnr.
- * @return always 0 currently, but code should handle a future improvement where when any call to func
- * returns < 0 no further calls to func may be done and < 0 is returned.
- * - encoding: Set by libavcodec, user can override.
- * - decoding: Set by libavcodec, user can override.
- */
- int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count);
-
- /**
- * thread opaque
- * Can be used by execute() to store some per AVCodecContext stuff.
- * - encoding: set by execute()
- * - decoding: set by execute()
- */
- void *thread_opaque;
-
- /**
- * noise vs. sse weight for the nsse comparsion function
- * - encoding: Set by user.
- * - decoding: unused
- */
- int nsse_weight;
-
- /**
- * profile
- * - encoding: Set by user.
- * - decoding: Set by libavcodec.
- */
- int profile;
-#define FF_PROFILE_UNKNOWN -99
-#define FF_PROFILE_RESERVED -100
-
-#define FF_PROFILE_AAC_MAIN 0
-#define FF_PROFILE_AAC_LOW 1
-#define FF_PROFILE_AAC_SSR 2
-#define FF_PROFILE_AAC_LTP 3
-#define FF_PROFILE_AAC_HE 4
-#define FF_PROFILE_AAC_HE_V2 28
-#define FF_PROFILE_AAC_LD 22
-#define FF_PROFILE_AAC_ELD 38
-
-#define FF_PROFILE_DTS 20
-#define FF_PROFILE_DTS_ES 30
-#define FF_PROFILE_DTS_96_24 40
-#define FF_PROFILE_DTS_HD_HRA 50
-#define FF_PROFILE_DTS_HD_MA 60
-
-#define FF_PROFILE_MPEG2_422 0
-#define FF_PROFILE_MPEG2_HIGH 1
-#define FF_PROFILE_MPEG2_SS 2
-#define FF_PROFILE_MPEG2_SNR_SCALABLE 3
-#define FF_PROFILE_MPEG2_MAIN 4
-#define FF_PROFILE_MPEG2_SIMPLE 5
-
-#define FF_PROFILE_H264_CONSTRAINED (1<<9) // 8+1; constraint_set1_flag
-#define FF_PROFILE_H264_INTRA (1<<11) // 8+3; constraint_set3_flag
-
-#define FF_PROFILE_H264_BASELINE 66
-#define FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED)
-#define FF_PROFILE_H264_MAIN 77
-#define FF_PROFILE_H264_EXTENDED 88
-#define FF_PROFILE_H264_HIGH 100
-#define FF_PROFILE_H264_HIGH_10 110
-#define FF_PROFILE_H264_HIGH_10_INTRA (110|FF_PROFILE_H264_INTRA)
-#define FF_PROFILE_H264_HIGH_422 122
-#define FF_PROFILE_H264_HIGH_422_INTRA (122|FF_PROFILE_H264_INTRA)
-#define FF_PROFILE_H264_HIGH_444 144
-#define FF_PROFILE_H264_HIGH_444_PREDICTIVE 244
-#define FF_PROFILE_H264_HIGH_444_INTRA (244|FF_PROFILE_H264_INTRA)
-#define FF_PROFILE_H264_CAVLC_444 44
-
-#define FF_PROFILE_VC1_SIMPLE 0
-#define FF_PROFILE_VC1_MAIN 1
-#define FF_PROFILE_VC1_COMPLEX 2
-#define FF_PROFILE_VC1_ADVANCED 3
-
-#define FF_PROFILE_MPEG4_SIMPLE 0
-#define FF_PROFILE_MPEG4_SIMPLE_SCALABLE 1
-#define FF_PROFILE_MPEG4_CORE 2
-#define FF_PROFILE_MPEG4_MAIN 3
-#define FF_PROFILE_MPEG4_N_BIT 4
-#define FF_PROFILE_MPEG4_SCALABLE_TEXTURE 5
-#define FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION 6
-#define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE 7
-#define FF_PROFILE_MPEG4_HYBRID 8
-#define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME 9
-#define FF_PROFILE_MPEG4_CORE_SCALABLE 10
-#define FF_PROFILE_MPEG4_ADVANCED_CODING 11
-#define FF_PROFILE_MPEG4_ADVANCED_CORE 12
-#define FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13
-#define FF_PROFILE_MPEG4_SIMPLE_STUDIO 14
-#define FF_PROFILE_MPEG4_ADVANCED_SIMPLE 15
-
- /**
- * level
- * - encoding: Set by user.
- * - decoding: Set by libavcodec.
- */
- int level;
-#define FF_LEVEL_UNKNOWN -99
-
- /**
- *
- * - encoding: unused
- * - decoding: Set by user.
- */
- enum AVDiscard skip_loop_filter;
-
- /**
- *
- * - encoding: unused
- * - decoding: Set by user.
- */
- enum AVDiscard skip_idct;
-
- /**
- *
- * - encoding: unused
- * - decoding: Set by user.
- */
- enum AVDiscard skip_frame;
-
- /**
- * Header containing style information for text subtitles.
- * For SUBTITLE_ASS subtitle type, it should contain the whole ASS
- * [Script Info] and [V4+ Styles] section, plus the [Events] line and
- * the Format line following. It shouldn't include any Dialogue line.
- * - encoding: Set/allocated/freed by user (before avcodec_open2())
- * - decoding: Set/allocated/freed by libavcodec (by avcodec_open2())
- */
- uint8_t *subtitle_header;
- int subtitle_header_size;
-
- /**
- * Simulates errors in the bitstream to test error concealment.
- * - encoding: Set by user.
- * - decoding: unused
- */
- int error_rate;
-
- /**
- * Current packet as passed into the decoder, to avoid having
- * to pass the packet into every function. Currently only valid
- * inside lavc and get/release_buffer callbacks.
- * - decoding: set by avcodec_decode_*, read by get_buffer() for setting pkt_pts
- * - encoding: unused
- */
- AVPacket *pkt;
-
- /**
- * VBV delay coded in the last frame (in periods of a 27 MHz clock).
- * Used for compliant TS muxing.
- * - encoding: Set by libavcodec.
- * - decoding: unused.
- */
- uint64_t vbv_delay;
-
- /**
- * Timebase in which pkt_dts/pts and AVPacket.dts/pts are.
- * Code outside libavcodec should access this field using:
- * avcodec_set_pkt_timebase(avctx)
- * - encoding unused.
- * - decodimg set by user
- */
- AVRational pkt_timebase;
-
- /**
- * AVCodecDescriptor
- * Code outside libavcodec should access this field using:
- * avcodec_get_codec_descriptior(avctx)
- * - encoding: unused.
- * - decoding: set by libavcodec.
- */
- const AVCodecDescriptor *codec_descriptor;
-
- /**
- * Current statistics for PTS correction.
- * - decoding: maintained and used by libavcodec, not intended to be used by user apps
- * - encoding: unused
- */
- int64_t pts_correction_num_faulty_pts; /// Number of incorrect PTS values so far
- int64_t pts_correction_num_faulty_dts; /// Number of incorrect DTS values so far
- int64_t pts_correction_last_pts; /// PTS of the last frame
- int64_t pts_correction_last_dts; /// DTS of the last frame
-
- /**
- * Current frame metadata.
- * - decoding: maintained and used by libavcodec, not intended to be used by user apps
- * - encoding: unused
- */
- AVDictionary *metadata;
-
- // ==> Start patch MPC
- int nal_length_size;
- // ==> End patch MPC
-} AVCodecContext;
-
-AVRational av_codec_get_pkt_timebase (const AVCodecContext *avctx);
-void av_codec_set_pkt_timebase (AVCodecContext *avctx, AVRational val);
-
-const AVCodecDescriptor *av_codec_get_codec_descriptor(const AVCodecContext *avctx);
-void av_codec_set_codec_descriptor(AVCodecContext *avctx, const AVCodecDescriptor *desc);
-
-/**
- * AVProfile.
- */
-typedef struct AVProfile {
- int profile;
- const char *name; ///< short name for the profile
-} AVProfile;
-
-typedef struct AVCodecDefault AVCodecDefault;
-
-struct AVSubtitle;
-
-/**
- * AVCodec.
- */
-typedef struct AVCodec {
- /**
- * Name of the codec implementation.
- * The name is globally unique among encoders and among decoders (but an
- * encoder and a decoder can share the same name).
- * This is the primary way to find a codec from the user perspective.
- */
- const char *name;
- /**
- * Descriptive name for the codec, meant to be more human readable than name.
- * You should use the NULL_IF_CONFIG_SMALL() macro to define it.
- */
- const char *long_name;
- enum AVMediaType type;
- enum AVCodecID id;
- /**
- * Codec capabilities.
- * see CODEC_CAP_*
- */
- int capabilities;
- const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0}
- const enum AVPixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1
- const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0
- const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1
- const uint64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
- uint8_t max_lowres; ///< maximum value for lowres supported by the decoder
- const AVClass *priv_class; ///< AVClass for the private context
- const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
-
- /*****************************************************************
- * 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.
- *****************************************************************
- */
- int priv_data_size;
- struct AVCodec *next;
- /**
- * @name Frame-level threading support functions
- * @{
- */
- /**
- * If defined, called on thread contexts when they are created.
- * If the codec allocates writable tables in init(), re-allocate them here.
- * priv_data will be set to a copy of the original.
- */
- int (*init_thread_copy)(AVCodecContext *);
- /**
- * Copy necessary context variables from a previous thread context to the current one.
- * If not defined, the next thread will start automatically; otherwise, the codec
- * must call ff_thread_finish_setup().
- *
- * dst and src will (rarely) point to the same context, in which case memcpy should be skipped.
- */
- int (*update_thread_context)(AVCodecContext *dst, const AVCodecContext *src);
- /** @} */
-
- /**
- * Private codec-specific defaults.
- */
- const AVCodecDefault *defaults;
-
- /**
- * Initialize codec static data, called from avcodec_register().
- */
- void (*init_static_data)(struct AVCodec *codec);
-
- int (*init)(AVCodecContext *);
- int (*encode_sub)(AVCodecContext *, uint8_t *buf, int buf_size,
- const struct AVSubtitle *sub);
- /**
- * Encode data to an AVPacket.
- *
- * @param avctx codec context
- * @param avpkt output AVPacket (may contain a user-provided buffer)
- * @param[in] frame AVFrame containing the raw data to be encoded
- * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a
- * non-empty packet was returned in avpkt.
- * @return 0 on success, negative error code on failure
- */
- int (*encode2)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame,
- int *got_packet_ptr);
- int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt);
- int (*close)(AVCodecContext *);
- /**
- * Flush buffers.
- * Will be called when seeking
- */
- void (*flush)(AVCodecContext *);
-} AVCodec;
-
-/**
- * AVHWAccel.
- */
-typedef struct AVHWAccel {
- /**
- * Name of the hardware accelerated codec.
- * The name is globally unique among encoders and among decoders (but an
- * encoder and a decoder can share the same name).
- */
- const char *name;
-
- /**
- * Type of codec implemented by the hardware accelerator.
- *
- * See AVMEDIA_TYPE_xxx
- */
- enum AVMediaType type;
-
- /**
- * Codec implemented by the hardware accelerator.
- *
- * See AV_CODEC_ID_xxx
- */
- enum AVCodecID id;
-
- /**
- * Supported pixel format.
- *
- * Only hardware accelerated formats are supported here.
- */
- enum AVPixelFormat pix_fmt;
-
- /**
- * Hardware accelerated codec capabilities.
- * see FF_HWACCEL_CODEC_CAP_*
- */
- int capabilities;
-
- struct AVHWAccel *next;
-
- /**
- * Called at the beginning of each frame or field picture.
- *
- * Meaningful frame information (codec specific) is guaranteed to
- * be parsed at this point. This function is mandatory.
- *
- * Note that buf can be NULL along with buf_size set to 0.
- * Otherwise, this means the whole frame is available at this point.
- *
- * @param avctx the codec context
- * @param buf the frame data buffer base
- * @param buf_size the size of the frame in bytes
- * @return zero if successful, a negative value otherwise
- */
- int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
-
- /**
- * Callback for each slice.
- *
- * Meaningful slice information (codec specific) is guaranteed to
- * be parsed at this point. This function is mandatory.
- *
- * @param avctx the codec context
- * @param buf the slice data buffer base
- * @param buf_size the size of the slice in bytes
- * @return zero if successful, a negative value otherwise
- */
- int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
-
- /**
- * Called at the end of each frame or field picture.
- *
- * The whole picture is parsed at this point and can now be sent
- * to the hardware accelerator. This function is mandatory.
- *
- * @param avctx the codec context
- * @return zero if successful, a negative value otherwise
- */
- int (*end_frame)(AVCodecContext *avctx);
-
- /**
- * Size of HW accelerator private data.
- *
- * Private data is allocated with av_mallocz() before
- * AVCodecContext.get_buffer() and deallocated after
- * AVCodecContext.release_buffer().
- */
- int priv_data_size;
-} AVHWAccel;
-
-/**
- * @defgroup lavc_picture AVPicture
- *
- * Functions for working with AVPicture
- * @{
- */
-
-/**
- * four components are given, that's all.
- * the last component is alpha
- */
-typedef struct AVPicture {
- uint8_t *data[AV_NUM_DATA_POINTERS];
- int linesize[AV_NUM_DATA_POINTERS]; ///< number of bytes per line
-} AVPicture;
-
-/**
- * @}
- */
-
-enum AVSubtitleType {
- SUBTITLE_NONE,
-
- SUBTITLE_BITMAP, ///< A bitmap, pict will be set
-
- /**
- * Plain text, the text field must be set by the decoder and is
- * authoritative. ass and pict fields may contain approximations.
- */
- SUBTITLE_TEXT,
-
- /**
- * Formatted text, the ass field must be set by the decoder and is
- * authoritative. pict and text fields may contain approximations.
- */
- SUBTITLE_ASS,
-};
-
-#define AV_SUBTITLE_FLAG_FORCED 0x00000001
-
-typedef struct AVSubtitleRect {
- int x; ///< top left corner of pict, undefined when pict is not set
- int y; ///< top left corner of pict, undefined when pict is not set
- int w; ///< width of pict, undefined when pict is not set
- int h; ///< height of pict, undefined when pict is not set
- int nb_colors; ///< number of colors in pict, undefined when pict is not set
-
- /**
- * data+linesize for the bitmap of this subtitle.
- * can be set for text/ass as well once they where rendered
- */
- AVPicture pict;
- enum AVSubtitleType type;
-
- char *text; ///< 0 terminated plain UTF-8 text
-
- /**
- * 0 terminated ASS/SSA compatible event line.
- * The presentation of this is unaffected by the other values in this
- * struct.
- */
- char *ass;
-
- int flags;
-} AVSubtitleRect;
-
-typedef struct AVSubtitle {
- uint16_t format; /* 0 = graphics */
- uint32_t start_display_time; /* relative to packet pts, in ms */
- uint32_t end_display_time; /* relative to packet pts, in ms */
- unsigned num_rects;
- AVSubtitleRect **rects;
- int64_t pts; ///< Same as packet pts, in AV_TIME_BASE
-} AVSubtitle;
-
-/**
- * If c is NULL, returns the first registered codec,
- * if c is non-NULL, returns the next registered codec after c,
- * or NULL if c is the last one.
- */
-AVCodec *av_codec_next(const AVCodec *c);
-
-/**
- * Return the LIBAVCODEC_VERSION_INT constant.
- */
-unsigned avcodec_version(void);
-
-/**
- * Return the libavcodec build-time configuration.
- */
-const char *avcodec_configuration(void);
-
-/**
- * Return the libavcodec license.
- */
-const char *avcodec_license(void);
-
-/**
- * Register the codec codec and initialize libavcodec.
- *
- * @warning either this function or avcodec_register_all() must be called
- * before any other libavcodec functions.
- *
- * @see avcodec_register_all()
- */
-void avcodec_register(AVCodec *codec);
-
-/**
- * Register all the codecs, parsers and bitstream filters which were enabled at
- * configuration time. If you do not call this function you can select exactly
- * which formats you want to support, by using the individual registration
- * functions.
- *
- * @see avcodec_register
- * @see av_register_codec_parser
- * @see av_register_bitstream_filter
- */
-void avcodec_register_all(void);
-
-
-#if FF_API_ALLOC_CONTEXT
-/**
- * Allocate an AVCodecContext and set its fields to default values. The
- * resulting struct can be deallocated by simply calling av_free().
- *
- * @return An AVCodecContext filled with default values or NULL on failure.
- * @see avcodec_get_context_defaults
- *
- * @deprecated use avcodec_alloc_context3()
- */
-attribute_deprecated
-AVCodecContext *avcodec_alloc_context(void);
-
-/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
- * we WILL change its arguments and name a few times! */
-attribute_deprecated
-AVCodecContext *avcodec_alloc_context2(enum AVMediaType);
-
-/**
- * Set the fields of the given AVCodecContext to default values.
- *
- * @param s The AVCodecContext of which the fields should be set to default values.
- * @deprecated use avcodec_get_context_defaults3
- */
-attribute_deprecated
-void avcodec_get_context_defaults(AVCodecContext *s);
-
-/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
- * we WILL change its arguments and name a few times! */
-attribute_deprecated
-void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType);
-#endif
-
-/**
- * Allocate an AVCodecContext and set its fields to default values. The
- * resulting struct can be deallocated by calling avcodec_close() on it followed
- * by av_free().
- *
- * @param codec if non-NULL, allocate private data and initialize defaults
- * for the given codec. It is illegal to then call avcodec_open2()
- * with a different codec.
- * If NULL, then the codec-specific defaults won't be initialized,
- * which may result in suboptimal default settings (this is
- * important mainly for encoders, e.g. libx264).
- *
- * @return An AVCodecContext filled with default values or NULL on failure.
- * @see avcodec_get_context_defaults
- */
-AVCodecContext *avcodec_alloc_context3(const AVCodec *codec);
-
-/**
- * Set the fields of the given AVCodecContext to default values corresponding
- * to the given codec (defaults may be codec-dependent).
- *
- * Do not call this function if a non-NULL codec has been passed
- * to avcodec_alloc_context3() that allocated this AVCodecContext.
- * If codec is non-NULL, it is illegal to call avcodec_open2() with a
- * different codec on this AVCodecContext.
- */
-int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec);
-
-/**
- * Get the AVClass for AVCodecContext. It can be used in combination with
- * AV_OPT_SEARCH_FAKE_OBJ for examining options.
- *
- * @see av_opt_find().
- */
-const AVClass *avcodec_get_class(void);
-
-/**
- * Get the AVClass for AVFrame. It can be used in combination with
- * AV_OPT_SEARCH_FAKE_OBJ for examining options.
- *
- * @see av_opt_find().
- */
-const AVClass *avcodec_get_frame_class(void);
-
-/**
- * Get the AVClass for AVSubtitleRect. It can be used in combination with
- * AV_OPT_SEARCH_FAKE_OBJ for examining options.
- *
- * @see av_opt_find().
- */
-const AVClass *avcodec_get_subtitle_rect_class(void);
-
-/**
- * Copy the settings of the source AVCodecContext into the destination
- * AVCodecContext. The resulting destination codec context will be
- * unopened, i.e. you are required to call avcodec_open2() before you
- * can use this AVCodecContext to decode/encode video/audio data.
- *
- * @param dest target codec context, should be initialized with
- * avcodec_alloc_context3(), but otherwise uninitialized
- * @param src source codec context
- * @return AVERROR() on error (e.g. memory allocation error), 0 on success
- */
-int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src);
-
-/**
- * Allocate an AVFrame and set its fields to default values. The resulting
- * struct must be freed using avcodec_free_frame().
- *
- * @return An AVFrame filled with default values or NULL on failure.
- * @see avcodec_get_frame_defaults
- */
-AVFrame *avcodec_alloc_frame(void);
-
-/**
- * Set the fields of the given AVFrame to default values.
- *
- * @param frame The AVFrame of which the fields should be set to default values.
- */
-void avcodec_get_frame_defaults(AVFrame *frame);
-
-/**
- * Free the frame and any dynamically allocated objects in it,
- * e.g. extended_data.
- *
- * @param frame frame to be freed. The pointer will be set to NULL.
- *
- * @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()).
- */
-void avcodec_free_frame(AVFrame **frame);
-
-#if FF_API_AVCODEC_OPEN
-/**
- * Initialize the AVCodecContext to use the given AVCodec. Prior to using this
- * function the context has to be allocated.
- *
- * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
- * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
- * retrieving a codec.
- *
- * @warning This function is not thread safe!
- *
- * @code
- * avcodec_register_all();
- * codec = avcodec_find_decoder(AV_CODEC_ID_H264);
- * if (!codec)
- * exit(1);
- *
- * context = avcodec_alloc_context3(codec);
- *
- * if (avcodec_open(context, codec) < 0)
- * exit(1);
- * @endcode
- *
- * @param avctx The context which will be set up to use the given codec.
- * @param codec The codec to use within the context.
- * @return zero on success, a negative value on error
- * @see avcodec_alloc_context3, avcodec_find_decoder, avcodec_find_encoder, avcodec_close
- *
- * @deprecated use avcodec_open2
- */
-attribute_deprecated
-int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
-#endif
-
-/**
- * Initialize the AVCodecContext to use the given AVCodec. Prior to using this
- * function the context has to be allocated with avcodec_alloc_context3().
- *
- * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
- * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
- * retrieving a codec.
- *
- * @warning This function is not thread safe!
- *
- * @code
- * avcodec_register_all();
- * av_dict_set(&opts, "b", "2.5M", 0);
- * codec = avcodec_find_decoder(AV_CODEC_ID_H264);
- * if (!codec)
- * exit(1);
- *
- * context = avcodec_alloc_context3(codec);
- *
- * if (avcodec_open2(context, codec, opts) < 0)
- * exit(1);
- * @endcode
- *
- * @param avctx The context to initialize.
- * @param codec The codec to open this context for. If a non-NULL codec has been
- * previously passed to avcodec_alloc_context3() or
- * avcodec_get_context_defaults3() for this context, then this
- * parameter MUST be either NULL or equal to the previously passed
- * codec.
- * @param options A dictionary filled with AVCodecContext and codec-private options.
- * On return this object will be filled with options that were not found.
- *
- * @return zero on success, a negative value on error
- * @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(),
- * av_dict_set(), av_opt_find().
- */
-int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options);
-
-/**
- * Close a given AVCodecContext and free all the data associated with it
- * (but not the AVCodecContext itself).
- *
- * Calling this function on an AVCodecContext that hasn't been opened will free
- * the codec-specific data allocated in avcodec_alloc_context3() /
- * avcodec_get_context_defaults3() with a non-NULL codec. Subsequent calls will
- * do nothing.
- */
-int avcodec_close(AVCodecContext *avctx);
-
-/**
- * Free all allocated data in the given subtitle struct.
- *
- * @param sub AVSubtitle to free.
- */
-void avsubtitle_free(AVSubtitle *sub);
-
-/**
- * @}
- */
-
-/**
- * @addtogroup lavc_packet
- * @{
- */
-
-/**
- * Default packet destructor.
- */
-void av_destruct_packet(AVPacket *pkt);
-
-/**
- * Initialize optional fields of a packet with default values.
- *
- * Note, this does not touch the data and size members, which have to be
- * initialized separately.
- *
- * @param pkt packet
- */
-void av_init_packet(AVPacket *pkt);
-
-/**
- * Allocate the payload of a packet and initialize its fields with
- * default values.
- *
- * @param pkt packet
- * @param size wanted payload size
- * @return 0 if OK, AVERROR_xxx otherwise
- */
-int av_new_packet(AVPacket *pkt, int size);
-
-/**
- * Reduce packet size, correctly zeroing padding
- *
- * @param pkt packet
- * @param size new size
- */
-void av_shrink_packet(AVPacket *pkt, int size);
-
-/**
- * Increase packet size, correctly zeroing padding
- *
- * @param pkt packet
- * @param grow_by number of bytes by which to increase the size of the packet
- */
-int av_grow_packet(AVPacket *pkt, int grow_by);
-
-/**
- * @warning This is a hack - the packet memory allocation stuff is broken. The
- * packet is allocated if it was not really allocated.
- */
-int av_dup_packet(AVPacket *pkt);
-
-/**
- * Copy packet, including contents
- *
- * @return 0 on success, negative AVERROR on fail
- */
-int av_copy_packet(AVPacket *dst, AVPacket *src);
-
-/**
- * Free a packet.
- *
- * @param pkt packet to free
- */
-void av_free_packet(AVPacket *pkt);
-
-/**
- * Allocate new information of a packet.
- *
- * @param pkt packet
- * @param type side information type
- * @param size side information size
- * @return pointer to fresh allocated data or NULL otherwise
- */
-uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
- int size);
-
-/**
- * Shrink the already allocated side data buffer
- *
- * @param pkt packet
- * @param type side information type
- * @param size new side information size
- * @return 0 on success, < 0 on failure
- */
-int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
- int size);
-
-/**
- * Get side information from packet.
- *
- * @param pkt packet
- * @param type desired side information type
- * @param size pointer for side information size to store (optional)
- * @return pointer to data if present or NULL otherwise
- */
-uint8_t* av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
- int *size);
-
-int av_packet_merge_side_data(AVPacket *pkt);
-
-int av_packet_split_side_data(AVPacket *pkt);
-
-
-/**
- * @}
- */
-
-/**
- * @addtogroup lavc_decoding
- * @{
- */
-
-/**
- * Find a registered decoder with a matching codec ID.
- *
- * @param id AVCodecID of the requested decoder
- * @return A decoder if one was found, NULL otherwise.
- */
-AVCodec *avcodec_find_decoder(enum AVCodecID id);
-
-/**
- * Find a registered decoder with the specified name.
- *
- * @param name name of the requested decoder
- * @return A decoder if one was found, NULL otherwise.
- */
-AVCodec *avcodec_find_decoder_by_name(const char *name);
-
-int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
-void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
-int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic);
-
-/**
- * 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.
- */
-unsigned avcodec_get_edge_width(void);
-
-/**
- * Modify width and height values so that they will result in a memory
- * buffer that is acceptable for the codec if you do not use any horizontal
- * 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);
-
-/**
- * Modify width and height values so that they will result in a memory
- * buffer that is acceptable for the codec if you also ensure that all
- * 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]);
-
-#if FF_API_OLD_DECODE_AUDIO
-/**
- * Wrapper function which calls avcodec_decode_audio4.
- *
- * @deprecated Use avcodec_decode_audio4 instead.
- *
- * Decode the audio frame of size avpkt->size from avpkt->data into samples.
- * Some decoders may support multiple frames in a single AVPacket, such
- * decoders would then just decode the first frame. In this case,
- * avcodec_decode_audio3 has to be called again with an AVPacket that contains
- * the remaining data in order to decode the second frame etc.
- * If no frame
- * could be outputted, frame_size_ptr is zero. Otherwise, it is the
- * decompressed frame size in bytes.
- *
- * @warning You must set frame_size_ptr to the allocated size of the
- * output buffer before calling avcodec_decode_audio3().
- *
- * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than
- * the actual read bytes because some optimized bitstream readers read 32 or 64
- * bits at once and could read over the end.
- *
- * @warning The end of the input buffer avpkt->data should be set to 0 to ensure that
- * no overreading happens for damaged MPEG streams.
- *
- * @warning You must not provide a custom get_buffer() when using
- * avcodec_decode_audio3(). Doing so will override it with
- * avcodec_default_get_buffer. Use avcodec_decode_audio4() instead,
- * which does allow the application to provide a custom get_buffer().
- *
- * @note You might have to align the input buffer avpkt->data and output buffer
- * samples. The alignment requirements depend on the CPU: On some CPUs it isn't
- * necessary at all, on others it won't work at all if not aligned and on others
- * it will work but it will have an impact on performance.
- *
- * In practice, avpkt->data should have 4 byte alignment at minimum and
- * samples should be 16 byte aligned unless the CPU doesn't need it
- * (AltiVec and SSE do).
- *
- * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay
- * between input and output, these need to be fed with avpkt->data=NULL,
- * avpkt->size=0 at the end to return the remaining frames.
- *
- * @param avctx the codec context
- * @param[out] samples the output buffer, sample type in avctx->sample_fmt
- * If the sample format is planar, each channel plane will
- * be the same size, with no padding between channels.
- * @param[in,out] frame_size_ptr the output buffer size in bytes
- * @param[in] avpkt The input AVPacket containing the input buffer.
- * You can create such packet with av_init_packet() and by then setting
- * data and size, some decoders might in addition need other fields.
- * All decoders are designed to use the least fields possible though.
- * @return On error a negative value is returned, otherwise the number of bytes
- * used or zero if no frame data was decompressed (used) from the input AVPacket.
- */
-attribute_deprecated int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
- int *frame_size_ptr,
- AVPacket *avpkt);
-#endif
-
-/**
- * Decode the audio frame of size avpkt->size from avpkt->data into frame.
- *
- * Some decoders may support multiple frames in a single AVPacket. Such
- * decoders would then just decode the first frame. In this case,
- * avcodec_decode_audio4 has to be called again with an AVPacket containing
- * the remaining data in order to decode the second frame, etc...
- * Even if no frames are returned, the packet needs to be fed to the decoder
- * with remaining data until it is completely consumed or an error occurs.
- *
- * @warning The input buffer, avpkt->data must be FF_INPUT_BUFFER_PADDING_SIZE
- * larger than the actual read bytes because some optimized bitstream
- * readers read 32 or 64 bits at once and could read over the end.
- *
- * @note You might have to align the input buffer. The alignment requirements
- * depend on the CPU and the decoder.
- *
- * @param avctx the codec context
- * @param[out] frame The AVFrame in which to store decoded audio samples.
- * Decoders request a buffer of a particular size by setting
- * AVFrame.nb_samples prior to calling get_buffer(). The
- * decoder may, however, only utilize part of the buffer by
- * setting AVFrame.nb_samples to a smaller value in the
- * output frame.
- * @param[out] got_frame_ptr Zero if no frame could be decoded, otherwise it is
- * non-zero.
- * @param[in] avpkt The input AVPacket containing the input buffer.
- * At least avpkt->data and avpkt->size should be set. Some
- * decoders might also require additional fields to be set.
- * @return A negative error code is returned if an error occurred during
- * decoding, otherwise the number of bytes consumed from the input
- * AVPacket is returned.
- */
-int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame,
- int *got_frame_ptr, const AVPacket *avpkt);
-
-/**
- * Decode the video frame of size avpkt->size from avpkt->data into picture.
- * Some decoders may support multiple frames in a single AVPacket, such
- * decoders would then just decode the first frame.
- *
- * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than
- * the actual read bytes because some optimized bitstream readers read 32 or 64
- * bits at once and could read over the end.
- *
- * @warning The end of the input buffer buf should be set to 0 to ensure that
- * no overreading happens for damaged MPEG streams.
- *
- * @note You might have to align the input buffer avpkt->data.
- * The alignment requirements depend on the CPU: on some CPUs it isn't
- * necessary at all, on others it won't work at all if not aligned and on others
- * it will work but it will have an impact on performance.
- *
- * In practice, avpkt->data should have 4 byte alignment at minimum.
- *
- * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay
- * between input and output, these need to be fed with avpkt->data=NULL,
- * avpkt->size=0 at the end to return the remaining frames.
- *
- * @param avctx the codec context
- * @param[out] picture The AVFrame in which the decoded video frame will be stored.
- * Use avcodec_alloc_frame to get an AVFrame, the codec will
- * allocate memory for the actual bitmap.
- * with default get/release_buffer(), the decoder frees/reuses the bitmap as it sees fit.
- * with overridden get/release_buffer() (needs CODEC_CAP_DR1) the user decides into what buffer the decoder
- * decodes and the decoder tells the user once it does not need the data anymore,
- * the user app can at this point free/reuse/keep the memory as it sees fit.
- *
- * @param[in] avpkt The input AVpacket containing the input buffer.
- * You can create such packet with av_init_packet() and by then setting
- * data and size, some decoders might in addition need other fields like
- * flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least
- * fields possible.
- * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero.
- * @return On error a negative value is returned, otherwise the number of bytes
- * used or zero if no frame could be decompressed.
- */
-int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
- int *got_picture_ptr,
- const AVPacket *avpkt);
-
-/**
- * Decode a subtitle message.
- * Return a negative value on error, otherwise return the number of bytes used.
- * If no subtitle could be decompressed, got_sub_ptr is zero.
- * Otherwise, the subtitle is stored in *sub.
- * Note that CODEC_CAP_DR1 is not available for subtitle codecs. This is for
- * simplicity, because the performance difference is expect to be negligible
- * and reusing a get_buffer written for video codecs would probably perform badly
- * due to a potentially very different allocation pattern.
- *
- * @param avctx the codec context
- * @param[out] sub The AVSubtitle in which the decoded subtitle will be stored, must be
- freed with avsubtitle_free if *got_sub_ptr is set.
- * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero.
- * @param[in] avpkt The input AVPacket containing the input buffer.
- */
-int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
- int *got_sub_ptr,
- AVPacket *avpkt);
-
-/**
- * @defgroup lavc_parsing Frame parsing
- * @{
- */
-
-typedef struct AVCodecParserContext {
- void *priv_data;
- struct AVCodecParser *parser;
- int64_t frame_offset; /* offset of the current frame */
- int64_t cur_offset; /* current offset
- (incremented by each av_parser_parse()) */
- int64_t next_frame_offset; /* offset of the next frame */
- /* video info */
- int pict_type; /* XXX: Put it back in AVCodecContext. */
- /**
- * This field is used for proper frame duration computation in lavf.
- * It signals, how much longer the frame duration of the current frame
- * is compared to normal frame duration.
- *
- * frame_duration = (1 + repeat_pict) * time_base
- *
- * It is used by codecs like H.264 to display telecined material.
- */
- int repeat_pict; /* XXX: Put it back in AVCodecContext. */
- int64_t pts; /* pts of the current frame */
- int64_t dts; /* dts of the current frame */
-
- /* private data */
- int64_t last_pts;
- int64_t last_dts;
- int fetch_timestamp;
-
-#define AV_PARSER_PTS_NB 4
- int cur_frame_start_index;
- int64_t cur_frame_offset[AV_PARSER_PTS_NB];
- int64_t cur_frame_pts[AV_PARSER_PTS_NB];
- int64_t cur_frame_dts[AV_PARSER_PTS_NB];
-
- int flags;
-#define PARSER_FLAG_COMPLETE_FRAMES 0x0001
-#define PARSER_FLAG_ONCE 0x0002
-/// Set if the parser has a valid file offset
-#define PARSER_FLAG_FETCHED_OFFSET 0x0004
-#define PARSER_FLAG_USE_CODEC_TS 0x1000
-
- int64_t offset; ///< byte offset from starting packet start
- int64_t cur_frame_end[AV_PARSER_PTS_NB];
-
- /**
- * Set by parser to 1 for key frames and 0 for non-key frames.
- * It is initialized to -1, so if the parser doesn't set this flag,
- * old-style fallback using AV_PICTURE_TYPE_I picture type as key frames
- * will be used.
- */
- int key_frame;
-
- /**
- * Time difference in stream time base units from the pts of this
- * packet to the point at which the output from the decoder has converged
- * independent from the availability of previous frames. That is, the
- * frames are virtually identical no matter if decoding started from
- * the very first frame or from this keyframe.
- * Is AV_NOPTS_VALUE if unknown.
- * This field is not the display duration of the current frame.
- * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY
- * set.
- *
- * The purpose of this field is to allow seeking in streams that have no
- * keyframes in the conventional sense. It corresponds to the
- * recovery point SEI in H.264 and match_time_delta in NUT. It is also
- * essential for some types of subtitle streams to ensure that all
- * subtitles are correctly displayed after seeking.
- */
- int64_t convergence_duration;
-
- // Timestamp generation support:
- /**
- * Synchronization point for start of timestamp generation.
- *
- * Set to >0 for sync point, 0 for no sync point and <0 for undefined
- * (default).
- *
- * For example, this corresponds to presence of H.264 buffering period
- * SEI message.
- */
- int dts_sync_point;
-
- /**
- * Offset of the current timestamp against last timestamp sync point in
- * units of AVCodecContext.time_base.
- *
- * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
- * contain a valid timestamp offset.
- *
- * Note that the timestamp of sync point has usually a nonzero
- * dts_ref_dts_delta, which refers to the previous sync point. Offset of
- * the next frame after timestamp sync point will be usually 1.
- *
- * For example, this corresponds to H.264 cpb_removal_delay.
- */
- int dts_ref_dts_delta;
-
- /**
- * Presentation delay of current frame in units of AVCodecContext.time_base.
- *
- * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
- * contain valid non-negative timestamp delta (presentation time of a frame
- * must not lie in the past).
- *
- * This delay represents the difference between decoding and presentation
- * time of the frame.
- *
- * For example, this corresponds to H.264 dpb_output_delay.
- */
- int pts_dts_delta;
-
- /**
- * Position of the packet in file.
- *
- * Analogous to cur_frame_pts/dts
- */
- int64_t cur_frame_pos[AV_PARSER_PTS_NB];
-
- /**
- * Byte position of currently parsed frame in stream.
- */
- int64_t pos;
-
- /**
- * Previous frame byte position.
- */
- int64_t last_pos;
-
- /**
- * Duration of the current frame.
- * For audio, this is in units of 1 / AVCodecContext.sample_rate.
- * For all other types, this is in units of AVCodecContext.time_base.
- */
- int duration;
-} AVCodecParserContext;
-
-typedef struct AVCodecParser {
- int codec_ids[5]; /* several codec IDs are permitted */
- int priv_data_size;
- int (*parser_init)(AVCodecParserContext *s);
- int (*parser_parse)(AVCodecParserContext *s,
- AVCodecContext *avctx,
- const uint8_t **poutbuf, int *poutbuf_size,
- const uint8_t *buf, int buf_size);
- void (*parser_close)(AVCodecParserContext *s);
- int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size);
- struct AVCodecParser *next;
-} AVCodecParser;
-
-AVCodecParser *av_parser_next(AVCodecParser *c);
-
-void av_register_codec_parser(AVCodecParser *parser);
-AVCodecParserContext *av_parser_init(int codec_id);
-
-/**
- * Parse a packet.
- *
- * @param s parser context.
- * @param avctx codec context.
- * @param poutbuf set to pointer to parsed buffer or NULL if not yet finished.
- * @param poutbuf_size set to size of parsed buffer or zero if not yet finished.
- * @param buf input buffer.
- * @param buf_size input length, to signal EOF, this should be 0 (so that the last frame can be output).
- * @param pts input presentation timestamp.
- * @param dts input decoding timestamp.
- * @param pos input byte position in stream.
- * @return the number of bytes of the input bitstream used.
- *
- * Example:
- * @code
- * while(in_len){
- * len = av_parser_parse2(myparser, AVCodecContext, &data, &size,
- * in_data, in_len,
- * pts, dts, pos);
- * in_data += len;
- * in_len -= len;
- *
- * if(size)
- * decode_frame(data, size);
- * }
- * @endcode
- */
-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);
-
-/**
- * @return 0 if the output buffer is a subset of the input, 1 if it is allocated and must be freed
- * @deprecated use AVBitstreamFilter
- */
-int av_parser_change(AVCodecParserContext *s,
- AVCodecContext *avctx,
- uint8_t **poutbuf, int *poutbuf_size,
- const uint8_t *buf, int buf_size, int keyframe);
-void av_parser_close(AVCodecParserContext *s);
-
-/**
- * @}
- * @}
- */
-
-/**
- * @addtogroup lavc_encoding
- * @{
- */
-
-/**
- * Find a registered encoder with a matching codec ID.
- *
- * @param id AVCodecID of the requested encoder
- * @return An encoder if one was found, NULL otherwise.
- */
-AVCodec *avcodec_find_encoder(enum AVCodecID id);
-
-/**
- * Find a registered encoder with the specified name.
- *
- * @param name name of the requested encoder
- * @return An encoder if one was found, NULL otherwise.
- */
-AVCodec *avcodec_find_encoder_by_name(const char *name);
-
-#if FF_API_OLD_ENCODE_AUDIO
-/**
- * Encode an audio frame from samples into buf.
- *
- * @deprecated Use avcodec_encode_audio2 instead.
- *
- * @note The output buffer should be at least FF_MIN_BUFFER_SIZE bytes large.
- * However, for codecs with avctx->frame_size equal to 0 (e.g. PCM) the user
- * will know how much space is needed because it depends on the value passed
- * in buf_size as described below. In that case a lower value can be used.
- *
- * @param avctx the codec context
- * @param[out] buf the output buffer
- * @param[in] buf_size the output buffer size
- * @param[in] samples the input buffer containing the samples
- * The number of samples read from this buffer is frame_size*channels,
- * both of which are defined in avctx.
- * For codecs which have avctx->frame_size equal to 0 (e.g. PCM) the number of
- * samples read from samples is equal to:
- * buf_size * 8 / (avctx->channels * av_get_bits_per_sample(avctx->codec_id))
- * This also implies that av_get_bits_per_sample() must not return 0 for these
- * codecs.
- * @return On error a negative value is returned, on success zero or the number
- * of bytes used to encode the data read from the input buffer.
- */
-int attribute_deprecated avcodec_encode_audio(AVCodecContext *avctx,
- uint8_t *buf, int buf_size,
- const short *samples);
-#endif
-
-/**
- * Encode a frame of audio.
- *
- * Takes input samples from frame and writes the next output packet, if
- * available, to avpkt. The output packet does not necessarily contain data for
- * the most recent frame, as encoders can delay, split, and combine input frames
- * internally as needed.
- *
- * @param avctx codec context
- * @param avpkt output AVPacket.
- * The user can supply an output buffer by setting
- * avpkt->data and avpkt->size prior to calling the
- * function, but if the size of the user-provided data is not
- * large enough, encoding will fail. If avpkt->data and
- * avpkt->size are set, avpkt->destruct must also be set. All
- * other AVPacket fields will be reset by the encoder using
- * av_init_packet(). If avpkt->data is NULL, the encoder will
- * allocate it. The encoder will set avpkt->size to the size
- * of the output packet.
- *
- * If this function fails or produces no output, avpkt will be
- * freed using av_free_packet() (i.e. avpkt->destruct will be
- * called to free the user supplied buffer).
- * @param[in] frame AVFrame containing the raw audio data to be encoded.
- * May be NULL when flushing an encoder that has the
- * CODEC_CAP_DELAY capability set.
- * If CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame
- * can have any number of samples.
- * If it is not set, frame->nb_samples must be equal to
- * avctx->frame_size for all frames except the last.
- * The final frame may be smaller than avctx->frame_size.
- * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the
- * output packet is non-empty, and to 0 if it is
- * empty. If the function returns an error, the
- * packet can be assumed to be invalid, and the
- * value of got_packet_ptr is undefined and should
- * not be used.
- * @return 0 on success, negative error code on failure
- */
-int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt,
- const AVFrame *frame, int *got_packet_ptr);
-
-#if FF_API_OLD_ENCODE_VIDEO
-/**
- * @deprecated use avcodec_encode_video2() instead.
- *
- * Encode a video frame from pict into buf.
- * The input picture should be
- * stored using a specific format, namely avctx.pix_fmt.
- *
- * @param avctx the codec context
- * @param[out] buf the output buffer for the bitstream of encoded frame
- * @param[in] buf_size the size of the output buffer in bytes
- * @param[in] pict the input picture to encode
- * @return On error a negative value is returned, on success zero or the number
- * of bytes used from the output buffer.
- */
-attribute_deprecated
-int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
- const AVFrame *pict);
-#endif
-
-/**
- * Encode a frame of video.
- *
- * Takes input raw video data from frame and writes the next output packet, if
- * available, to avpkt. The output packet does not necessarily contain data for
- * the most recent frame, as encoders can delay and reorder input frames
- * internally as needed.
- *
- * @param avctx codec context
- * @param avpkt output AVPacket.
- * The user can supply an output buffer by setting
- * avpkt->data and avpkt->size prior to calling the
- * function, but if the size of the user-provided data is not
- * large enough, encoding will fail. All other AVPacket fields
- * will be reset by the encoder using av_init_packet(). If
- * avpkt->data is NULL, the encoder will allocate it.
- * The encoder will set avpkt->size to the size of the
- * output packet. The returned data (if any) belongs to the
- * caller, he is responsible for freeing it.
- *
- * If this function fails or produces no output, avpkt will be
- * freed using av_free_packet() (i.e. avpkt->destruct will be
- * called to free the user supplied buffer).
- * @param[in] frame AVFrame containing the raw video data to be encoded.
- * May be NULL when flushing an encoder that has the
- * CODEC_CAP_DELAY capability set.
- * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the
- * output packet is non-empty, and to 0 if it is
- * empty. If the function returns an error, the
- * packet can be assumed to be invalid, and the
- * value of got_packet_ptr is undefined and should
- * not be used.
- * @return 0 on success, negative error code on failure
- */
-int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
- const AVFrame *frame, int *got_packet_ptr);
-
-int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
- const AVSubtitle *sub);
-
-
-/**
- * @}
- */
-
-#if FF_API_AVCODEC_RESAMPLE
-/**
- * @defgroup lavc_resample Audio resampling
- * @ingroup libavc
- * @deprecated use libswresample instead
- *
- * @{
- */
-struct ReSampleContext;
-struct AVResampleContext;
-
-typedef struct ReSampleContext ReSampleContext;
-
-/**
- * Initialize audio resampling context.
- *
- * @param output_channels number of output channels
- * @param input_channels number of input channels
- * @param output_rate output sample rate
- * @param input_rate input sample rate
- * @param sample_fmt_out requested output sample format
- * @param sample_fmt_in input sample format
- * @param filter_length length of each FIR filter in the filterbank relative to the cutoff frequency
- * @param log2_phase_count log2 of the number of entries in the polyphase filterbank
- * @param linear if 1 then the used FIR filter will be linearly interpolated
- between the 2 closest, if 0 the closest will be used
- * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate
- * @return allocated ReSampleContext, NULL if error occurred
- */
-attribute_deprecated
-ReSampleContext *av_audio_resample_init(int output_channels, int input_channels,
- int output_rate, int input_rate,
- enum AVSampleFormat sample_fmt_out,
- enum AVSampleFormat sample_fmt_in,
- int filter_length, int log2_phase_count,
- int linear, double cutoff);
-
-attribute_deprecated
-int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
-
-/**
- * Free resample context.
- *
- * @param s a non-NULL pointer to a resample context previously
- * created with av_audio_resample_init()
- */
-attribute_deprecated
-void audio_resample_close(ReSampleContext *s);
-
-
-/**
- * Initialize an audio resampler.
- * Note, if either rate is not an integer then simply scale both rates up so they are.
- * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq
- * @param log2_phase_count log2 of the number of entries in the polyphase filterbank
- * @param linear If 1 then the used FIR filter will be linearly interpolated
- between the 2 closest, if 0 the closest will be used
- * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate
- */
-attribute_deprecated
-struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff);
-
-/**
- * Resample an array of samples using a previously configured context.
- * @param src an array of unconsumed samples
- * @param consumed the number of samples of src which have been consumed are returned here
- * @param src_size the number of unconsumed samples available
- * @param dst_size the amount of space in samples available in dst
- * @param update_ctx If this is 0 then the context will not be modified, that way several channels can be resampled with the same context.
- * @return the number of samples written in dst or -1 if an error occurred
- */
-attribute_deprecated
-int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx);
-
-
-/**
- * Compensate samplerate/timestamp drift. The compensation is done by changing
- * the resampler parameters, so no audible clicks or similar distortions occur
- * @param compensation_distance distance in output samples over which the compensation should be performed
- * @param sample_delta number of output samples which should be output less
- *
- * example: av_resample_compensate(c, 10, 500)
- * here instead of 510 samples only 500 samples would be output
- *
- * note, due to rounding the actual compensation might be slightly different,
- * especially if the compensation_distance is large and the in_rate used during init is small
- */
-attribute_deprecated
-void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
-attribute_deprecated
-void av_resample_close(struct AVResampleContext *c);
-
-/**
- * @}
- */
-#endif
-
-/**
- * @addtogroup lavc_picture
- * @{
- */
-
-/**
- * Allocate memory for a picture. Call avpicture_free() to free it.
- *
- * @see avpicture_fill()
- *
- * @param picture the picture to be filled in
- * @param pix_fmt the format of the picture
- * @param width the width of the picture
- * @param height the height of the picture
- * @return zero if successful, a negative value if not
- */
-int avpicture_alloc(AVPicture *picture, enum AVPixelFormat pix_fmt, int width, int height);
-
-/**
- * Free a picture previously allocated by avpicture_alloc().
- * The data buffer used by the AVPicture is freed, but the AVPicture structure
- * itself is not.
- *
- * @param picture the AVPicture to be freed
- */
-void avpicture_free(AVPicture *picture);
-
-/**
- * Fill in the AVPicture fields, always assume a linesize alignment of
- * 1.
- *
- * @see av_image_fill_arrays()
- */
-int avpicture_fill(AVPicture *picture, const uint8_t *ptr,
- enum AVPixelFormat pix_fmt, int width, int height);
-
-/**
- * Copy pixel data from an AVPicture into a buffer, always assume a
- * linesize alignment of 1.
- *
- * @see av_image_copy_to_buffer()
- */
-int avpicture_layout(const AVPicture* src, enum AVPixelFormat pix_fmt,
- int width, int height,
- unsigned char *dest, int dest_size);
-
-/**
- * Calculate the size in bytes that a picture of the given width and height
- * would occupy if stored in the given picture format.
- * Always assume a linesize alignment of 1.
- *
- * @see av_image_get_buffer_size().
- */
-int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height);
-
-/**
- * deinterlace - if not supported return -1
- */
-int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
- enum AVPixelFormat pix_fmt, int width, int height);
-/**
- * Copy image src to dst. Wraps av_image_copy().
- */
-void av_picture_copy(AVPicture *dst, const AVPicture *src,
- enum AVPixelFormat pix_fmt, int width, int height);
-
-/**
- * Crop image top and left side.
- */
-int av_picture_crop(AVPicture *dst, const AVPicture *src,
- enum AVPixelFormat pix_fmt, int top_band, int left_band);
-
-/**
- * Pad image.
- */
-int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum AVPixelFormat pix_fmt,
- int padtop, int padbottom, int padleft, int padright, int *color);
-
-/**
- * @}
- */
-
-/**
- * @defgroup lavc_misc Utility functions
- * @ingroup libavc
- *
- * Miscellaneous utility functions related to both encoding and decoding
- * (or neither).
- * @{
- */
-
-/**
- * @defgroup lavc_misc_pixfmt Pixel formats
- *
- * Functions for working with pixel formats.
- * @{
- */
-
-/**
- * Utility function to access log2_chroma_w log2_chroma_h from
- * the pixel format AVPixFmtDescriptor.
- *
- * This function asserts that pix_fmt is valid. See av_pix_fmt_get_chroma_sub_sample
- * for one that returns a failure code and continues in case of invalid
- * pix_fmts.
- *
- * @param[in] pix_fmt the pixel format
- * @param[out] h_shift store log2_chroma_h
- * @param[out] v_shift store log2_chroma_w
- *
- * @see av_pix_fmt_get_chroma_sub_sample
- */
-
-void avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift);
-
-/**
- * Return a value representing the fourCC code associated to the
- * pixel format pix_fmt, or 0 if no associated fourCC code can be
- * found.
- */
-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).
- */
-int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat src_pix_fmt,
- int has_alpha);
-
-#if FF_API_FIND_BEST_PIX_FMT
-/**
- * @deprecated use avcodec_find_best_pix_fmt_of_2() instead.
- *
- * Find the best pixel format to convert to given a certain source pixel
- * format. 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() searches which of
- * the given pixel formats should be used to suffer the least amount of loss.
- * The pixel formats from which it chooses one, are determined by the
- * pix_fmt_mask parameter.
- *
- * Note, only the first 64 pixel formats will fit in pix_fmt_mask.
- *
- * @code
- * src_pix_fmt = AV_PIX_FMT_YUV420P;
- * pix_fmt_mask = (1 << AV_PIX_FMT_YUV422P) | (1 << AV_PIX_FMT_RGB24);
- * dst_pix_fmt = avcodec_find_best_pix_fmt(pix_fmt_mask, src_pix_fmt, alpha, &loss);
- * @endcode
- *
- * @param[in] pix_fmt_mask bitmask determining which pixel format 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[out] loss_ptr Combination of flags informing you what kind of losses will occur.
- * @return The best pixel format to convert to or -1 if none was found.
- */
-attribute_deprecated
-enum AVPixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum AVPixelFormat src_pix_fmt,
- int has_alpha, int *loss_ptr);
-#endif /* FF_API_FIND_BEST_PIX_FMT */
-
-/**
- * Find the best pixel format to convert to given a certain source pixel
- * format. 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() searches which of
- * the given pixel formats should be used to suffer the least amount of loss.
- * The pixel formats from which it chooses one, are determined by the
- * pix_fmt_list parameter.
- *
- *
- * @param[in] pix_fmt_list AV_PIX_FMT_NONE terminated array of 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[out] loss_ptr Combination of flags informing you what kind of losses will occur.
- * @return The best pixel format to convert to or -1 if none was found.
- */
-enum AVPixelFormat avcodec_find_best_pix_fmt_of_list(enum AVPixelFormat *pix_fmt_list,
- enum AVPixelFormat src_pix_fmt,
- 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.
- */
-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);
-
-attribute_deprecated
-#if AV_HAVE_INCOMPATIBLE_FORK_ABI
-enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat *pix_fmt_list,
- enum AVPixelFormat src_pix_fmt,
- int has_alpha, int *loss_ptr);
-#else
-enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
- enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr);
-#endif
-
-
-enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum AVPixelFormat * fmt);
-
-/**
- * @}
- */
-
-void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
-
-/**
- * Put a string representing the codec tag codec_tag in buf.
- *
- * @param buf_size size in bytes of buf
- * @return the length of the string that would have been generated if
- * enough space had been available, excluding the trailing null
- */
-size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag);
-
-void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
-
-/**
- * Return a name for the specified profile, if available.
- *
- * @param codec the codec that is searched for the given profile
- * @param profile the profile value for which a name is requested
- * @return A name for the profile if found, NULL otherwise.
- */
-const char *av_get_profile_name(const AVCodec *codec, int profile);
-
-int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size);
-int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count);
-//FIXME func typedef
-
-/**
- * Fill AVFrame audio data and linesize pointers.
- *
- * The buffer buf must be a preallocated buffer with a size big enough
- * to contain the specified samples amount. The filled AVFrame data
- * pointers will point to this buffer.
- *
- * AVFrame extended_data channel pointers are allocated if necessary for
- * planar audio.
- *
- * @param frame the AVFrame
- * frame->nb_samples must be set prior to calling the
- * function. This function fills in frame->data,
- * frame->extended_data, frame->linesize[0].
- * @param nb_channels channel count
- * @param sample_fmt sample format
- * @param buf buffer to use for frame data
- * @param buf_size size of buffer
- * @param align plane size sample alignment (0 = default)
- * @return >=0 on success, negative error code on failure
- * @todo return the size in bytes required to store the samples in
- * case of success, at the next libavutil bump
- */
-int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels,
- enum AVSampleFormat sample_fmt, const uint8_t *buf,
- int buf_size, int align);
-
-/**
- * Flush buffers, should be called when seeking or when switching to a different stream.
- */
-void avcodec_flush_buffers(AVCodecContext *avctx);
-
-void avcodec_default_free_buffers(AVCodecContext *s);
-
-/**
- * Return codec bits per sample.
- *
- * @param[in] codec_id the codec
- * @return Number of bits per sample or zero if unknown for the given codec.
- */
-int av_get_bits_per_sample(enum AVCodecID codec_id);
-
-/**
- * Return the PCM codec associated with a sample format.
- * @param be endianness, 0 for little, 1 for big,
- * -1 (or anything else) for native
- * @return AV_CODEC_ID_PCM_* or AV_CODEC_ID_NONE
- */
-enum AVCodecID av_get_pcm_codec(enum AVSampleFormat fmt, int be);
-
-/**
- * Return codec bits per sample.
- * Only return non-zero if the bits per sample is exactly correct, not an
- * approximation.
- *
- * @param[in] codec_id the codec
- * @return Number of bits per sample or zero if unknown for the given codec.
- */
-int av_get_exact_bits_per_sample(enum AVCodecID codec_id);
-
-/**
- * Return audio frame duration.
- *
- * @param avctx codec context
- * @param frame_bytes size of the frame, or 0 if unknown
- * @return frame duration, in samples, if known. 0 if not able to
- * determine.
- */
-int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes);
-
-
-typedef struct AVBitStreamFilterContext {
- void *priv_data;
- struct AVBitStreamFilter *filter;
- AVCodecParserContext *parser;
- struct AVBitStreamFilterContext *next;
-} AVBitStreamFilterContext;
-
-
-typedef struct AVBitStreamFilter {
- const char *name;
- int priv_data_size;
- int (*filter)(AVBitStreamFilterContext *bsfc,
- AVCodecContext *avctx, const char *args,
- uint8_t **poutbuf, int *poutbuf_size,
- const uint8_t *buf, int buf_size, int keyframe);
- void (*close)(AVBitStreamFilterContext *bsfc);
- struct AVBitStreamFilter *next;
-} AVBitStreamFilter;
-
-void av_register_bitstream_filter(AVBitStreamFilter *bsf);
-AVBitStreamFilterContext *av_bitstream_filter_init(const char *name);
-int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc,
- AVCodecContext *avctx, const char *args,
- uint8_t **poutbuf, int *poutbuf_size,
- const uint8_t *buf, int buf_size, int keyframe);
-void av_bitstream_filter_close(AVBitStreamFilterContext *bsf);
-
-AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f);
-
-/* memory */
-
-/**
- * Reallocate the given block if it is not large enough, otherwise do nothing.
- *
- * @see av_realloc
- */
-void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size);
-
-/**
- * Allocate a buffer, reusing the given one if large enough.
- *
- * Contrary to av_fast_realloc the current buffer contents might not be
- * preserved and on error the old buffer is freed, thus no special
- * handling to avoid memleaks is necessary.
- *
- * @param ptr pointer to pointer to already allocated buffer, overwritten with pointer to new buffer
- * @param size size of the buffer *ptr points to
- * @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and
- * *size 0 if an error occurred.
- */
-void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size);
-
-/**
- * Same behaviour av_fast_malloc but the buffer has additional
- * FF_INPUT_BUFFER_PADDING_SIZE at the end which will will always be 0.
- *
- * In addition the whole buffer will initially and after resizes
- * be 0-initialized so that no uninitialized data will ever appear.
- */
-void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size);
-
-/**
- * Same behaviour av_fast_padded_malloc except that buffer will always
- * be 0-initialized after call.
- */
-void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size);
-
-/**
- * Encode extradata length to a buffer. Used by xiph codecs.
- *
- * @param s buffer to write to; must be at least (v/255+1) bytes long
- * @param v size of extradata in bytes
- * @return number of bytes written to the buffer.
- */
-unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
-
-/**
- * Log a generic warning message about a missing feature. This function is
- * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.)
- * only, and would normally not be used by applications.
- * @param[in] avc a pointer to an arbitrary struct of which the first field is
- * a pointer to an AVClass struct
- * @param[in] feature string containing the name of the missing feature
- * @param[in] want_sample indicates if samples are wanted which exhibit this feature.
- * If want_sample is non-zero, additional verbage will be added to the log
- * message which tells the user how to report samples to the development
- * mailing list.
- */
-void av_log_missing_feature(void *avc, const char *feature, int want_sample);
-
-/**
- * Log a generic warning message asking for a sample. This function is
- * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.)
- * only, and would normally not be used by applications.
- * @param[in] avc a pointer to an arbitrary struct of which the first field is
- * a pointer to an AVClass struct
- * @param[in] msg string containing an optional message, or NULL if no message
- */
-void av_log_ask_for_sample(void *avc, const char *msg, ...) av_printf_format(2, 3);
-
-/**
- * Register the hardware accelerator hwaccel.
- */
-void av_register_hwaccel(AVHWAccel *hwaccel);
-
-/**
- * If hwaccel is NULL, returns the first registered hardware accelerator,
- * if hwaccel is non-NULL, returns the next registered hardware accelerator
- * after hwaccel, or NULL if hwaccel is the last one.
- */
-AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel);
-
-
-/**
- * Lock operation used by lockmgr
- */
-enum AVLockOp {
- AV_LOCK_CREATE, ///< Create a mutex
- AV_LOCK_OBTAIN, ///< Lock the mutex
- AV_LOCK_RELEASE, ///< Unlock the mutex
- AV_LOCK_DESTROY, ///< Free mutex resources
-};
-
-/**
- * Register a user provided lock manager supporting the operations
- * specified by AVLockOp. mutex points to a (void *) where the
- * lockmgr should store/get a pointer to a user allocated mutex. It's
- * NULL upon AV_LOCK_CREATE and != NULL for all other ops.
- *
- * @param cb User defined callback. Note: FFmpeg may invoke calls to this
- * callback during the call to av_lockmgr_register().
- * Thus, the application must be prepared to handle that.
- * If cb is set to NULL the lockmgr will be unregistered.
- * Also note that during unregistration the previously registered
- * lockmgr callback may also be invoked.
- */
-int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op));
-
-/**
- * Get the type of the given codec.
- */
-enum AVMediaType avcodec_get_type(enum AVCodecID codec_id);
-
-/**
- * Get the name of a codec.
- * @return a static string identifying the codec; never NULL
- */
-const char *avcodec_get_name(enum AVCodecID id);
-
-/**
- * @return a positive value if s is open (i.e. avcodec_open2() was called on it
- * with no corresponding avcodec_close()), 0 otherwise.
- */
-int avcodec_is_open(AVCodecContext *s);
-
-/**
- * @return a non-zero number if codec is an encoder, zero otherwise
- */
-int av_codec_is_encoder(const AVCodec *codec);
-
-/**
- * @return a non-zero number if codec is a decoder, zero otherwise
- */
-int av_codec_is_decoder(const AVCodec *codec);
-
-/**
- * @return descriptor for given codec ID or NULL if no descriptor exists.
- */
-const AVCodecDescriptor *avcodec_descriptor_get(enum AVCodecID id);
-
-/**
- * Iterate over all codec descriptors known to libavcodec.
- *
- * @param prev previous descriptor. NULL to get the first descriptor.
- *
- * @return next descriptor or NULL after the last descriptor
- */
-const AVCodecDescriptor *avcodec_descriptor_next(const AVCodecDescriptor *prev);
-
-/**
- * @return codec descriptor with the given name or NULL if no such descriptor
- * exists.
- */
-const AVCodecDescriptor *avcodec_descriptor_get_by_name(const char *name);
-
-/**
- * @}
- */
-
-/**
- * ffdshow custom stuff
- *
- * @param[out] recovery_frame_cnt. Valid only if GDR.
- * @return 0: no recovery point, 1: I-frame, 2: Recovery Point SEI (GDR), 3: IDR, -1: error
- */
-int avcodec_h264_search_recovery_point(AVCodecContext *avctx,
- const uint8_t *buf, int buf_size, int *recovery_frame_cnt);
-
-#endif /* AVCODEC_AVCODEC_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/avfft.c b/src/thirdparty/ffmpeg/libavcodec/avfft.c
deleted file mode 100644
index 3f37b0eb7..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/avfft.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * 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/mem.h"
-#include "avfft.h"
-#include "fft.h"
-#include "rdft.h"
-#include "dct.h"
-
-/* FFT */
-
-FFTContext *av_fft_init(int nbits, int inverse)
-{
- FFTContext *s = av_malloc(sizeof(*s));
-
- if (s && ff_fft_init(s, nbits, inverse))
- av_freep(&s);
-
- return s;
-}
-
-void av_fft_permute(FFTContext *s, FFTComplex *z)
-{
- s->fft_permute(s, z);
-}
-
-void av_fft_calc(FFTContext *s, FFTComplex *z)
-{
- s->fft_calc(s, z);
-}
-
-void av_fft_end(FFTContext *s)
-{
- if (s) {
- ff_fft_end(s);
- av_free(s);
- }
-}
-
-#if CONFIG_MDCT
-
-FFTContext *av_mdct_init(int nbits, int inverse, double scale)
-{
- FFTContext *s = av_malloc(sizeof(*s));
-
- if (s && ff_mdct_init(s, nbits, inverse, scale))
- av_freep(&s);
-
- return s;
-}
-
-void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input)
-{
- s->imdct_calc(s, output, input);
-}
-
-void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input)
-{
- s->imdct_half(s, output, input);
-}
-
-void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input)
-{
- s->mdct_calc(s, output, input);
-}
-
-void av_mdct_end(FFTContext *s)
-{
- if (s) {
- ff_mdct_end(s);
- av_free(s);
- }
-}
-
-#endif /* CONFIG_MDCT */
-
-#if CONFIG_RDFT
-
-RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans)
-{
- RDFTContext *s = av_malloc(sizeof(*s));
-
- if (s && ff_rdft_init(s, nbits, trans))
- av_freep(&s);
-
- return s;
-}
-
-void av_rdft_calc(RDFTContext *s, FFTSample *data)
-{
- s->rdft_calc(s, data);
-}
-
-void av_rdft_end(RDFTContext *s)
-{
- if (s) {
- ff_rdft_end(s);
- av_free(s);
- }
-}
-
-#endif /* CONFIG_RDFT */
-
-#if CONFIG_DCT
-
-DCTContext *av_dct_init(int nbits, enum DCTTransformType inverse)
-{
- DCTContext *s = av_malloc(sizeof(*s));
-
- if (s && ff_dct_init(s, nbits, inverse))
- av_freep(&s);
-
- return s;
-}
-
-void av_dct_calc(DCTContext *s, FFTSample *data)
-{
- s->dct_calc(s, data);
-}
-
-void av_dct_end(DCTContext *s)
-{
- if (s) {
- ff_dct_end(s);
- av_free(s);
- }
-}
-
-#endif /* CONFIG_DCT */
diff --git a/src/thirdparty/ffmpeg/libavcodec/avfft.h b/src/thirdparty/ffmpeg/libavcodec/avfft.h
deleted file mode 100644
index 48f43a7f5..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/avfft.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * 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_AVFFT_H
-#define AVCODEC_AVFFT_H
-
-/**
- * @file
- * @ingroup lavc_fft
- * FFT functions
- */
-
-/**
- * @defgroup lavc_fft FFT functions
- * @ingroup lavc_misc
- *
- * @{
- */
-
-typedef float FFTSample;
-
-typedef struct FFTComplex {
- FFTSample re, im;
-} FFTComplex;
-
-typedef struct FFTContext FFTContext;
-
-/**
- * Set up a complex FFT.
- * @param nbits log2 of the length of the input array
- * @param inverse if 0 perform the forward transform, if 1 perform the inverse
- */
-FFTContext *av_fft_init(int nbits, int inverse);
-
-/**
- * Do the permutation needed BEFORE calling ff_fft_calc().
- */
-void av_fft_permute(FFTContext *s, FFTComplex *z);
-
-/**
- * Do a complex FFT with the parameters defined in av_fft_init(). The
- * input data must be permuted before. No 1.0/sqrt(n) normalization is done.
- */
-void av_fft_calc(FFTContext *s, FFTComplex *z);
-
-void av_fft_end(FFTContext *s);
-
-FFTContext *av_mdct_init(int nbits, int inverse, double scale);
-void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input);
-void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input);
-void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input);
-void av_mdct_end(FFTContext *s);
-
-/* Real Discrete Fourier Transform */
-
-enum RDFTransformType {
- DFT_R2C,
- IDFT_C2R,
- IDFT_R2C,
- DFT_C2R,
-};
-
-typedef struct RDFTContext RDFTContext;
-
-/**
- * Set up a real FFT.
- * @param nbits log2 of the length of the input array
- * @param trans the type of transform
- */
-RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans);
-void av_rdft_calc(RDFTContext *s, FFTSample *data);
-void av_rdft_end(RDFTContext *s);
-
-/* Discrete Cosine Transform */
-
-typedef struct DCTContext DCTContext;
-
-enum DCTTransformType {
- DCT_II = 0,
- DCT_III,
- DCT_I,
- DST_I,
-};
-
-/**
- * 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
- *
- * @note the first element of the input of DST-I is ignored
- */
-DCTContext *av_dct_init(int nbits, enum DCTTransformType type);
-void av_dct_calc(DCTContext *s, FFTSample *data);
-void av_dct_end (DCTContext *s);
-
-/**
- * @}
- */
-
-#endif /* AVCODEC_AVFFT_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/avpacket.c b/src/thirdparty/ffmpeg/libavcodec/avpacket.c
deleted file mode 100644
index db082d4b5..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/avpacket.c
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * AVPacket functions for libavcodec
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
- *
- * 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 <string.h>
-
-#include "libavutil/avassert.h"
-#include "libavutil/mem.h"
-#include "avcodec.h"
-#include "bytestream.h"
-#include "internal.h"
-
-void ff_packet_free_side_data(AVPacket *pkt)
-{
- int i;
- for (i = 0; i < pkt->side_data_elems; i++)
- av_free(pkt->side_data[i].data);
- av_freep(&pkt->side_data);
- pkt->side_data_elems = 0;
-}
-
-void av_destruct_packet(AVPacket *pkt)
-{
- av_free(pkt->data);
- pkt->data = NULL;
- pkt->size = 0;
-}
-
-void av_init_packet(AVPacket *pkt)
-{
- pkt->pts = AV_NOPTS_VALUE;
- pkt->dts = AV_NOPTS_VALUE;
- pkt->pos = -1;
- pkt->duration = 0;
- pkt->convergence_duration = 0;
- pkt->flags = 0;
- pkt->stream_index = 0;
- pkt->destruct = NULL;
- pkt->side_data = NULL;
- pkt->side_data_elems = 0;
-}
-
-int av_new_packet(AVPacket *pkt, int size)
-{
- uint8_t *data = NULL;
- if ((unsigned)size < (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
- data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
- if (data) {
- memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
- } else
- size = 0;
-
- av_init_packet(pkt);
- pkt->data = data;
- pkt->size = size;
- pkt->destruct = av_destruct_packet;
- if (!data)
- return AVERROR(ENOMEM);
- return 0;
-}
-
-void av_shrink_packet(AVPacket *pkt, int size)
-{
- if (pkt->size <= size)
- return;
- pkt->size = size;
- memset(pkt->data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
-}
-
-int av_grow_packet(AVPacket *pkt, int grow_by)
-{
- void *new_ptr;
- av_assert0((unsigned)pkt->size <= INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE);
- if (!pkt->size)
- return av_new_packet(pkt, grow_by);
- if ((unsigned)grow_by >
- INT_MAX - (pkt->size + FF_INPUT_BUFFER_PADDING_SIZE))
- return -1;
- new_ptr = av_realloc(pkt->data,
- pkt->size + grow_by + FF_INPUT_BUFFER_PADDING_SIZE);
- if (!new_ptr)
- return AVERROR(ENOMEM);
- pkt->data = new_ptr;
- pkt->size += grow_by;
- memset(pkt->data + pkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
- return 0;
-}
-
-#define DUP_DATA(dst, src, size, padding) \
- do { \
- void *data; \
- if (padding) { \
- if ((unsigned)(size) > \
- (unsigned)(size) + FF_INPUT_BUFFER_PADDING_SIZE) \
- goto failed_alloc; \
- data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); \
- } else { \
- data = av_malloc(size); \
- } \
- if (!data) \
- goto failed_alloc; \
- memcpy(data, src, size); \
- if (padding) \
- memset((uint8_t *)data + size, 0, \
- FF_INPUT_BUFFER_PADDING_SIZE); \
- dst = data; \
- } while (0)
-
-/* Makes duplicates of data, side_data, but does not copy any other fields */
-static int copy_packet_data(AVPacket *dst, AVPacket *src)
-{
- dst->data = NULL;
- dst->side_data = NULL;
- DUP_DATA(dst->data, src->data, dst->size, 1);
- dst->destruct = av_destruct_packet;
-
- if (dst->side_data_elems) {
- int i;
-
- DUP_DATA(dst->side_data, src->side_data,
- dst->side_data_elems * sizeof(*dst->side_data), 0);
- memset(dst->side_data, 0,
- dst->side_data_elems * sizeof(*dst->side_data));
- for (i = 0; i < dst->side_data_elems; i++) {
- DUP_DATA(dst->side_data[i].data, src->side_data[i].data,
- src->side_data[i].size, 1);
- dst->side_data[i].size = src->side_data[i].size;
- dst->side_data[i].type = src->side_data[i].type;
- }
- }
- return 0;
-
-failed_alloc:
- av_destruct_packet(dst);
- return AVERROR(ENOMEM);
-}
-
-int av_dup_packet(AVPacket *pkt)
-{
- AVPacket tmp_pkt;
-
- if (pkt->destruct == NULL && pkt->data) {
- tmp_pkt = *pkt;
- return copy_packet_data(pkt, &tmp_pkt);
- }
- return 0;
-}
-
-int av_copy_packet(AVPacket *dst, AVPacket *src)
-{
- *dst = *src;
- return copy_packet_data(dst, src);
-}
-
-void av_free_packet(AVPacket *pkt)
-{
- if (pkt) {
- int i;
-
- if (pkt->destruct)
- pkt->destruct(pkt);
- pkt->data = NULL;
- pkt->size = 0;
-
- for (i = 0; i < pkt->side_data_elems; i++)
- av_free(pkt->side_data[i].data);
- av_freep(&pkt->side_data);
- pkt->side_data_elems = 0;
- }
-}
-
-uint8_t *av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
- int size)
-{
- int elems = pkt->side_data_elems;
-
- if ((unsigned)elems + 1 > INT_MAX / sizeof(*pkt->side_data))
- return NULL;
- if ((unsigned)size > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE)
- return NULL;
-
- pkt->side_data = av_realloc(pkt->side_data,
- (elems + 1) * sizeof(*pkt->side_data));
- if (!pkt->side_data)
- return NULL;
-
- pkt->side_data[elems].data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
- if (!pkt->side_data[elems].data)
- return NULL;
- pkt->side_data[elems].size = size;
- pkt->side_data[elems].type = type;
- pkt->side_data_elems++;
-
- return pkt->side_data[elems].data;
-}
-
-uint8_t *av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
- int *size)
-{
- int i;
-
- for (i = 0; i < pkt->side_data_elems; i++) {
- if (pkt->side_data[i].type == type) {
- if (size)
- *size = pkt->side_data[i].size;
- return pkt->side_data[i].data;
- }
- }
- return NULL;
-}
-
-#define FF_MERGE_MARKER 0x8c4d9d108e25e9feULL
-
-int av_packet_merge_side_data(AVPacket *pkt){
- if(pkt->side_data_elems){
- int i;
- uint8_t *p;
- uint64_t size= pkt->size + 8LL + FF_INPUT_BUFFER_PADDING_SIZE;
- AVPacket old= *pkt;
- for (i=0; i<old.side_data_elems; i++) {
- size += old.side_data[i].size + 5LL;
- }
- if (size > INT_MAX)
- return AVERROR(EINVAL);
- p = av_malloc(size);
- if (!p)
- return AVERROR(ENOMEM);
- pkt->data = p;
- pkt->destruct = av_destruct_packet;
- pkt->size = size - FF_INPUT_BUFFER_PADDING_SIZE;
- bytestream_put_buffer(&p, old.data, old.size);
- for (i=old.side_data_elems-1; i>=0; i--) {
- bytestream_put_buffer(&p, old.side_data[i].data, old.side_data[i].size);
- bytestream_put_be32(&p, old.side_data[i].size);
- *p++ = old.side_data[i].type | ((i==old.side_data_elems-1)*128);
- }
- bytestream_put_be64(&p, FF_MERGE_MARKER);
- av_assert0(p-pkt->data == pkt->size);
- memset(p, 0, FF_INPUT_BUFFER_PADDING_SIZE);
- av_free_packet(&old);
- pkt->side_data_elems = 0;
- pkt->side_data = NULL;
- return 1;
- }
- return 0;
-}
-
-int av_packet_split_side_data(AVPacket *pkt){
- if (!pkt->side_data_elems && pkt->size >12 && AV_RB64(pkt->data + pkt->size - 8) == FF_MERGE_MARKER){
- int i;
- unsigned int size;
- uint8_t *p;
-
- p = pkt->data + pkt->size - 8 - 5;
- for (i=1; ; i++){
- size = AV_RB32(p);
- if (size>INT_MAX || p - pkt->data < size)
- return 0;
- if (p[4]&128)
- break;
- p-= size+5;
- }
-
- pkt->side_data = av_malloc(i * sizeof(*pkt->side_data));
- if (!pkt->side_data)
- return AVERROR(ENOMEM);
-
- p= pkt->data + pkt->size - 8 - 5;
- for (i=0; ; i++){
- size= AV_RB32(p);
- av_assert0(size<=INT_MAX && p - pkt->data >= size);
- pkt->side_data[i].data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
- pkt->side_data[i].size = size;
- pkt->side_data[i].type = p[4]&127;
- if (!pkt->side_data[i].data)
- return AVERROR(ENOMEM);
- memcpy(pkt->side_data[i].data, p-size, size);
- pkt->size -= size + 5;
- if(p[4]&128)
- break;
- p-= size+5;
- }
- pkt->size -= 8;
- pkt->side_data_elems = i+1;
- return 1;
- }
- return 0;
-}
-
-int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
- int size)
-{
- int i;
-
- for (i = 0; i < pkt->side_data_elems; i++) {
- if (pkt->side_data[i].type == type) {
- if (size > pkt->side_data[i].size)
- return AVERROR(ENOMEM);
- pkt->side_data[i].size = size;
- return 0;
- }
- }
- return AVERROR(ENOENT);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/avpicture.c b/src/thirdparty/ffmpeg/libavcodec/avpicture.c
deleted file mode 100644
index a6f89ef88..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/avpicture.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * AVPicture management routines
- * Copyright (c) 2001, 2002, 2003 Fabrice Bellard
- *
- * 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
- * AVPicture management routines
- */
-
-#include "avcodec.h"
-#include "internal.h"
-#include "libavutil/common.h"
-#include "libavutil/pixdesc.h"
-#include "libavutil/imgutils.h"
-#include "libavutil/colorspace.h"
-
-int avpicture_fill(AVPicture *picture, const uint8_t *ptr,
- enum AVPixelFormat pix_fmt, int width, int height)
-{
- return av_image_fill_arrays(picture->data, picture->linesize,
- ptr, pix_fmt, width, height, 1);
-}
-
-int avpicture_layout(const AVPicture* src, enum AVPixelFormat pix_fmt, int width, int height,
- unsigned char *dest, int dest_size)
-{
- return av_image_copy_to_buffer(dest, dest_size,
- (const uint8_t * const*)src->data, src->linesize,
- pix_fmt, width, height, 1);
-}
-
-int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height)
-{
- return av_image_get_buffer_size(pix_fmt, width, height, 1);
-}
-
-int avpicture_alloc(AVPicture *picture,
- enum AVPixelFormat pix_fmt, int width, int height)
-{
- int ret = av_image_alloc(picture->data, picture->linesize,
- width, height, pix_fmt, 1);
- if (ret < 0) {
- memset(picture, 0, sizeof(AVPicture));
- return ret;
- }
-
- return 0;
-}
-
-void avpicture_free(AVPicture *picture)
-{
- av_free(picture->data[0]);
-}
-
-void av_picture_copy(AVPicture *dst, const AVPicture *src,
- enum AVPixelFormat pix_fmt, int width, int height)
-{
- av_image_copy(dst->data, dst->linesize, (const uint8_t **)src->data,
- src->linesize, pix_fmt, width, height);
-}
-
diff --git a/src/thirdparty/ffmpeg/libavcodec/bgmc.c b/src/thirdparty/ffmpeg/libavcodec/bgmc.c
deleted file mode 100644
index 2a7c6ae4e..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/bgmc.c
+++ /dev/null
@@ -1,558 +0,0 @@
-/*
- * Block Gilbert-Moore decoder
- * Copyright (c) 2010 Thilo Borgmann <thilo.borgmann _at_ googlemail.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
- * Block Gilbert-Moore decoder as used by MPEG-4 ALS
- * @author Thilo Borgmann <thilo.borgmann _at_ googlemail.com>
- */
-
-#include "bgmc.h"
-
-#define FREQ_BITS 14 // bits used by frequency counters
-#define VALUE_BITS 18 // bits used to represent the values
-#define TOP_VALUE ((1 << VALUE_BITS) - 1) // maximum value
-#define FIRST_QTR (TOP_VALUE / 4 + 1) // first quarter of values maximum value
-#define HALF (2 * FIRST_QTR) // first half of values maximum value
-#define THIRD_QTR (3 * FIRST_QTR) // third quarter of values maximum value
-
-#define LUT_BITS (FREQ_BITS - 8) // number of bits used to index lookup tables
-#define LUT_SIZE (1 << LUT_BITS) // size of the lookup tables
-#define LUT_BUFF 4 // number of buffered lookup tables
-
-
-/** Cumulative frequency tables for block Gilbert-Moore coding. */
-static const uint16_t cf_tables_1[3][129] = {
- {
- 16384, 16066, 15748, 15431, 15114, 14799, 14485, 14173, 13861, 13552,
- 13243, 12939, 12635, 12336, 12038, 11745, 11452, 11161, 10870, 10586,
- 10303, 10027, 9751, 9483, 9215, 8953, 8692, 8440, 8189, 7946,
- 7704, 7472, 7240, 7008, 6776, 6554, 6333, 6122, 5912, 5711,
- 5512, 5320, 5128, 4947, 4766, 4595, 4425, 4264, 4104, 3946,
- 3788, 3640, 3493, 3355, 3218, 3090, 2963, 2842, 2721, 2609,
- 2498, 2395, 2292, 2196, 2100, 2004, 1908, 1820, 1732, 1651,
- 1570, 1497, 1424, 1355, 1287, 1223, 1161, 1100, 1044, 988,
- 938, 888, 839, 790, 746, 702, 662, 623, 588, 553,
- 520, 488, 459, 431, 405, 380, 357, 334, 311, 288,
- 268, 248, 230, 213, 197, 182, 168, 154, 142, 130,
- 119, 108, 99, 90, 81, 72, 64, 56, 49, 42,
- 36, 30, 25, 20, 15, 11, 7, 3, 0
- },
- {
- 16384, 16080, 15776, 15473, 15170, 14868, 14567, 14268, 13970, 13674,
- 13378, 13086, 12794, 12505, 12218, 11936, 11654, 11373, 11092, 10818,
- 10544, 10276, 10008, 9749, 9490, 9236, 8982, 8737, 8492, 8256,
- 8020, 7792, 7564, 7336, 7108, 6888, 6669, 6459, 6249, 6050,
- 5852, 5660, 5468, 5286, 5104, 4931, 4760, 4598, 4436, 4275,
- 4115, 3965, 3816, 3674, 3534, 3403, 3272, 3147, 3023, 2907,
- 2792, 2684, 2577, 2476, 2375, 2274, 2173, 2079, 1986, 1897,
- 1810, 1724, 1645, 1567, 1493, 1419, 1351, 1284, 1222, 1161,
- 1105, 1050, 995, 941, 891, 842, 797, 753, 713, 673,
- 636, 599, 566, 533, 503, 473, 446, 419, 392, 365,
- 340, 316, 294, 272, 253, 234, 216, 199, 184, 169,
- 155, 142, 130, 118, 106, 95, 85, 75, 66, 57,
- 49, 41, 34, 27, 21, 15, 10, 5, 0
- },
- {
- 16384, 16092, 15801, 15510, 15219, 14930, 14641, 14355, 14069, 13785,
- 13501, 13219, 12938, 12661, 12384, 12112, 11841, 11571, 11301, 11037,
- 10773, 10514, 10256, 10005, 9754, 9508, 9263, 9025, 8787, 8557,
- 8327, 8103, 7879, 7655, 7431, 7215, 7000, 6792, 6585, 6387,
- 6190, 5998, 5807, 5625, 5445, 5272, 5100, 4937, 4774, 4613,
- 4452, 4301, 4150, 4007, 3865, 3731, 3597, 3469, 3341, 3218,
- 3099, 2981, 2869, 2758, 2652, 2546, 2440, 2334, 2234, 2134,
- 2041, 1949, 1864, 1779, 1699, 1620, 1547, 1474, 1407, 1340,
- 1278, 1217, 1157, 1097, 1043, 989, 940, 891, 846, 801,
- 759, 718, 680, 643, 609, 575, 543, 511, 479, 447,
- 418, 389, 363, 337, 314, 291, 270, 249, 230, 212,
- 195, 179, 164, 149, 135, 121, 108, 96, 85, 74,
- 64, 54, 45, 36, 28, 20, 13, 6, 0
- }
-};
-
-
-static const uint16_t cf_tables_2[8][193] = {
- {
- 16384, 16104, 15825, 15546, 15268, 14991, 14714, 14439, 14164, 13891,
- 13620, 13350, 13081, 12815, 12549, 12287, 12025, 11765, 11505, 11250,
- 10996, 10746, 10497, 10254, 10011, 9772, 9534, 9303, 9072, 8848,
- 8624, 8406, 8188, 7970, 7752, 7539, 7327, 7123, 6919, 6724,
- 6529, 6339, 6150, 5970, 5790, 5618, 5446, 5282, 5119, 4957,
- 4795, 4642, 4490, 4345, 4201, 4065, 3929, 3798, 3669, 3547,
- 3425, 3310, 3196, 3086, 2976, 2866, 2756, 2650, 2545, 2447,
- 2350, 2260, 2170, 2085, 2000, 1921, 1843, 1770, 1698, 1632,
- 1566, 1501, 1436, 1376, 1316, 1261, 1207, 1157, 1108, 1061,
- 1015, 973, 931, 893, 855, 819, 783, 747, 711, 677,
- 644, 614, 584, 557, 530, 505, 480, 458, 436, 416,
- 396, 378, 360, 343, 326, 310, 295, 281, 267, 255,
- 243, 232, 221, 211, 201, 192, 183, 174, 166, 158,
- 150, 142, 134, 126, 119, 112, 106, 100, 95, 90,
- 85, 80, 76, 72, 69, 66, 63, 60, 57, 54,
- 51, 48, 46, 44, 42, 40, 38, 36, 34, 33,
- 32, 31, 30, 29, 28, 27, 26, 25, 24, 23,
- 22, 21, 20, 19, 18, 17, 16, 15, 14, 13,
- 12, 11, 10, 9, 8, 7, 6, 5, 4, 3,
- 2, 1, 0
- },
- {
- 16384, 16116, 15849, 15582, 15316, 15050, 14785, 14521, 14257, 13995,
- 13734, 13476, 13218, 12963, 12708, 12457, 12206, 11956, 11706, 11460,
- 11215, 10975, 10735, 10500, 10265, 10034, 9803, 9579, 9355, 9136,
- 8917, 8703, 8489, 8275, 8061, 7853, 7645, 7444, 7244, 7051,
- 6858, 6671, 6484, 6305, 6127, 5956, 5785, 5622, 5459, 5298,
- 5137, 4983, 4830, 4684, 4539, 4401, 4263, 4131, 3999, 3874,
- 3750, 3632, 3515, 3401, 3287, 3173, 3059, 2949, 2840, 2737,
- 2635, 2539, 2444, 2354, 2264, 2181, 2098, 2020, 1943, 1872,
- 1801, 1731, 1661, 1596, 1532, 1472, 1412, 1357, 1303, 1251,
- 1200, 1153, 1106, 1063, 1020, 979, 938, 897, 856, 818,
- 780, 746, 712, 681, 650, 621, 592, 566, 540, 517,
- 494, 473, 452, 431, 410, 391, 373, 356, 340, 325,
- 310, 296, 282, 270, 258, 247, 236, 225, 214, 203,
- 192, 182, 172, 162, 153, 144, 136, 128, 121, 114,
- 108, 102, 97, 92, 87, 82, 77, 73, 69, 65,
- 62, 59, 56, 53, 50, 47, 45, 43, 41, 39,
- 37, 35, 33, 31, 29, 27, 26, 25, 24, 23,
- 22, 21, 20, 19, 18, 17, 16, 15, 14, 13,
- 12, 11, 10, 9, 8, 7, 6, 5, 4, 3,
- 2, 1, 0
- },
- {
- 16384, 16128, 15872, 15617, 15362, 15107, 14853, 14600, 14347, 14096,
- 13846, 13597, 13350, 13105, 12860, 12618, 12376, 12135, 11894, 11657,
- 11421, 11189, 10957, 10730, 10503, 10279, 10056, 9838, 9620, 9407,
- 9195, 8987, 8779, 8571, 8363, 8159, 7955, 7758, 7561, 7371,
- 7182, 6997, 6812, 6635, 6459, 6289, 6120, 5957, 5795, 5634,
- 5473, 5319, 5165, 5018, 4871, 4732, 4593, 4458, 4324, 4197,
- 4071, 3951, 3831, 3714, 3597, 3480, 3363, 3250, 3138, 3032,
- 2927, 2828, 2729, 2635, 2541, 2453, 2366, 2284, 2202, 2126,
- 2050, 1975, 1900, 1830, 1761, 1697, 1633, 1574, 1515, 1459,
- 1403, 1351, 1300, 1252, 1205, 1160, 1115, 1070, 1025, 982,
- 939, 899, 860, 824, 789, 756, 723, 693, 663, 636,
- 609, 584, 559, 535, 511, 489, 467, 447, 427, 409,
- 391, 374, 358, 343, 328, 313, 300, 287, 274, 261,
- 248, 235, 223, 211, 200, 189, 179, 169, 160, 151,
- 143, 135, 128, 121, 115, 109, 103, 97, 92, 87,
- 82, 77, 73, 69, 65, 61, 58, 55, 52, 49,
- 46, 43, 40, 37, 35, 33, 31, 29, 27, 25,
- 23, 21, 20, 19, 18, 17, 16, 15, 14, 13,
- 12, 11, 10, 9, 8, 7, 6, 5, 4, 3,
- 2, 1, 0
- },
- {
- 16384, 16139, 15894, 15649, 15405, 15162, 14919, 14677, 14435, 14195,
- 13955, 13717, 13479, 13243, 13008, 12775, 12542, 12310, 12079, 11851,
- 11623, 11399, 11176, 10956, 10737, 10521, 10305, 10094, 9883, 9677,
- 9471, 9268, 9065, 8862, 8659, 8459, 8260, 8067, 7874, 7688,
- 7502, 7321, 7140, 6965, 6790, 6621, 6452, 6290, 6128, 5968,
- 5808, 5655, 5503, 5356, 5209, 5069, 4929, 4794, 4660, 4532,
- 4404, 4282, 4160, 4041, 3922, 3803, 3684, 3568, 3452, 3343,
- 3234, 3131, 3029, 2931, 2833, 2741, 2649, 2563, 2477, 2396,
- 2316, 2236, 2157, 2083, 2009, 1940, 1871, 1807, 1743, 1683,
- 1623, 1567, 1511, 1459, 1407, 1357, 1307, 1257, 1207, 1159,
- 1111, 1067, 1023, 983, 943, 905, 868, 834, 800, 769,
- 738, 709, 681, 653, 625, 600, 575, 552, 529, 508,
- 487, 466, 447, 428, 410, 392, 376, 360, 344, 328,
- 313, 298, 283, 268, 255, 242, 230, 218, 207, 196,
- 186, 176, 167, 158, 150, 142, 135, 128, 121, 114,
- 108, 102, 97, 92, 87, 82, 78, 74, 70, 66,
- 62, 58, 54, 50, 47, 44, 41, 38, 35, 32,
- 30, 28, 26, 24, 22, 20, 18, 16, 14, 13,
- 12, 11, 10, 9, 8, 7, 6, 5, 4, 3,
- 2, 1, 0
- },
- {
- 16384, 16149, 15915, 15681, 15447, 15214, 14981, 14749, 14517, 14286,
- 14055, 13827, 13599, 13373, 13147, 12923, 12699, 12476, 12253, 12034,
- 11815, 11599, 11383, 11171, 10959, 10750, 10541, 10337, 10133, 9933,
- 9733, 9536, 9339, 9142, 8945, 8751, 8557, 8369, 8181, 7998,
- 7816, 7638, 7460, 7288, 7116, 6950, 6785, 6625, 6465, 6306,
- 6147, 5995, 5843, 5697, 5551, 5411, 5271, 5135, 5000, 4871,
- 4742, 4618, 4495, 4374, 4253, 4132, 4011, 3893, 3775, 3663,
- 3552, 3446, 3340, 3239, 3138, 3043, 2948, 2858, 2768, 2684,
- 2600, 2516, 2433, 2355, 2278, 2205, 2133, 2065, 1997, 1932,
- 1867, 1807, 1747, 1690, 1634, 1580, 1526, 1472, 1418, 1366,
- 1314, 1266, 1218, 1174, 1130, 1088, 1047, 1009, 971, 936,
- 901, 868, 836, 804, 772, 743, 714, 685, 658, 631,
- 606, 582, 559, 536, 515, 494, 475, 456, 437, 418,
- 399, 380, 362, 344, 328, 312, 297, 283, 270, 257,
- 245, 233, 222, 211, 201, 191, 181, 172, 163, 155,
- 147, 139, 132, 125, 119, 113, 107, 101, 96, 91,
- 86, 81, 76, 71, 66, 62, 58, 54, 50, 46,
- 43, 40, 37, 34, 31, 28, 26, 24, 22, 20,
- 18, 16, 14, 12, 10, 8, 6, 5, 4, 3,
- 2, 1, 0
- },
- {
- 16384, 16159, 15934, 15709, 15485, 15261, 15038, 14816, 14594, 14373,
- 14152, 13933, 13714, 13497, 13280, 13065, 12850, 12636, 12422, 12211,
- 12000, 11791, 11583, 11378, 11173, 10971, 10769, 10571, 10373, 10179,
- 9985, 9793, 9601, 9409, 9217, 9029, 8842, 8658, 8475, 8297,
- 8120, 7946, 7773, 7604, 7435, 7271, 7108, 6950, 6792, 6634,
- 6477, 6326, 6175, 6029, 5883, 5742, 5602, 5466, 5330, 5199,
- 5068, 4943, 4818, 4696, 4574, 4452, 4330, 4211, 4093, 3979,
- 3866, 3759, 3652, 3549, 3446, 3348, 3250, 3157, 3065, 2977,
- 2889, 2802, 2716, 2634, 2553, 2476, 2399, 2326, 2254, 2185,
- 2117, 2052, 1987, 1926, 1866, 1808, 1750, 1692, 1634, 1578,
- 1522, 1470, 1418, 1369, 1321, 1275, 1229, 1187, 1145, 1105,
- 1066, 1027, 991, 955, 919, 883, 850, 817, 786, 756,
- 728, 700, 674, 648, 624, 600, 578, 556, 534, 512,
- 490, 468, 447, 426, 407, 388, 371, 354, 338, 322,
- 307, 293, 280, 267, 255, 243, 231, 219, 209, 199,
- 189, 179, 170, 161, 153, 145, 138, 131, 124, 117,
- 111, 105, 99, 93, 87, 81, 76, 71, 66, 61,
- 57, 53, 49, 45, 42, 39, 36, 33, 30, 27,
- 24, 21, 19, 17, 15, 13, 11, 9, 7, 5,
- 3, 1, 0
- },
- {
- 16384, 16169, 15954, 15739, 15524, 15310, 15096, 14883, 14670, 14458,
- 14246, 14035, 13824, 13614, 13405, 13198, 12991, 12785, 12579, 12376,
- 12173, 11972, 11772, 11574, 11377, 11182, 10987, 10795, 10603, 10414,
- 10226, 10040, 9854, 9668, 9482, 9299, 9116, 8937, 8759, 8585,
- 8411, 8241, 8071, 7906, 7741, 7580, 7419, 7263, 7107, 6952,
- 6797, 6647, 6497, 6353, 6209, 6070, 5931, 5796, 5661, 5531,
- 5401, 5275, 5150, 5027, 4904, 4781, 4658, 4538, 4419, 4304,
- 4190, 4081, 3972, 3867, 3762, 3662, 3562, 3467, 3372, 3281,
- 3191, 3101, 3012, 2928, 2844, 2764, 2684, 2608, 2533, 2460,
- 2387, 2318, 2250, 2185, 2121, 2059, 1997, 1935, 1873, 1813,
- 1754, 1698, 1642, 1588, 1535, 1483, 1433, 1384, 1338, 1292,
- 1249, 1206, 1165, 1125, 1085, 1045, 1008, 971, 937, 903,
- 871, 840, 810, 780, 752, 724, 698, 672, 647, 622,
- 597, 572, 548, 524, 502, 480, 460, 440, 421, 403,
- 386, 369, 353, 337, 323, 309, 295, 281, 268, 255,
- 243, 231, 220, 209, 199, 189, 180, 171, 163, 155,
- 147, 139, 131, 123, 116, 109, 102, 95, 89, 83,
- 77, 72, 67, 62, 57, 52, 48, 44, 40, 36,
- 32, 28, 25, 22, 19, 16, 13, 10, 8, 6,
- 4, 2, 0
- },
- {
- 16384, 16177, 15970, 15764, 15558, 15353, 15148, 14944, 14740, 14537,
- 14334, 14132, 13930, 13729, 13529, 13330, 13131, 12933, 12735, 12539,
- 12343, 12150, 11957, 11766, 11576, 11388, 11200, 11015, 10830, 10647,
- 10465, 10285, 10105, 9925, 9745, 9568, 9391, 9218, 9045, 8876,
- 8707, 8541, 8375, 8213, 8051, 7894, 7737, 7583, 7429, 7277,
- 7125, 6977, 6830, 6687, 6544, 6406, 6268, 6133, 5998, 5868,
- 5738, 5612, 5487, 5364, 5241, 5118, 4995, 4875, 4755, 4640,
- 4525, 4414, 4304, 4198, 4092, 3990, 3888, 3790, 3693, 3600,
- 3507, 3415, 3323, 3235, 3147, 3064, 2981, 2902, 2823, 2746,
- 2670, 2594, 2522, 2450, 2382, 2314, 2248, 2182, 2116, 2050,
- 1987, 1924, 1864, 1804, 1748, 1692, 1638, 1585, 1534, 1484,
- 1437, 1390, 1346, 1302, 1258, 1215, 1174, 1133, 1095, 1057,
- 1021, 986, 952, 918, 887, 856, 827, 798, 770, 742,
- 714, 686, 659, 632, 607, 582, 559, 536, 514, 492,
- 472, 452, 433, 415, 398, 381, 364, 348, 333, 318,
- 304, 290, 277, 264, 252, 240, 229, 218, 208, 198,
- 188, 178, 168, 158, 149, 140, 132, 124, 116, 108,
- 101, 94, 87, 81, 75, 69, 64, 59, 54, 49,
- 44, 39, 35, 31, 27, 23, 19, 15, 12, 9,
- 6, 3, 0
- }
-};
-
-
-static const uint16_t cf_tables_3[5][257] = {
- {
- 16384, 16187, 15990, 15793, 15597, 15401, 15205, 15009, 14813, 14618,
- 14423, 14230, 14037, 13845, 13653, 13463, 13273, 13083, 12894, 12706,
- 12518, 12332, 12146, 11962, 11778, 11597, 11416, 11237, 11059, 10882,
- 10706, 10532, 10358, 10184, 10010, 9838, 9666, 9497, 9328, 9163,
- 8999, 8837, 8675, 8517, 8359, 8205, 8051, 7901, 7751, 7602,
- 7453, 7308, 7163, 7022, 6882, 6745, 6609, 6476, 6343, 6214,
- 6085, 5960, 5835, 5712, 5589, 5466, 5343, 5223, 5103, 4987,
- 4872, 4761, 4650, 4542, 4435, 4332, 4229, 4130, 4031, 3936,
- 3841, 3747, 3653, 3563, 3473, 3387, 3302, 3220, 3138, 3059,
- 2980, 2905, 2830, 2759, 2688, 2619, 2550, 2481, 2412, 2345,
- 2278, 2215, 2152, 2092, 2032, 1974, 1917, 1863, 1809, 1758,
- 1707, 1659, 1611, 1564, 1517, 1473, 1429, 1387, 1346, 1307,
- 1268, 1230, 1193, 1158, 1123, 1090, 1058, 1026, 994, 962,
- 930, 899, 869, 841, 813, 786, 760, 735, 710, 687,
- 664, 643, 622, 602, 582, 562, 543, 525, 507, 490,
- 473, 457, 442, 427, 412, 398, 385, 373, 361, 349,
- 337, 325, 313, 301, 290, 279, 269, 259, 249, 240,
- 231, 222, 214, 206, 199, 192, 185, 178, 171, 165,
- 159, 153, 148, 143, 138, 133, 128, 123, 119, 115,
- 111, 107, 103, 99, 95, 91, 87, 83, 80, 77,
- 74, 71, 68, 65, 63, 61, 59, 57, 55, 53,
- 51, 49, 47, 45, 43, 41, 40, 39, 38, 37,
- 36, 35, 34, 33, 32, 31, 30, 29, 28, 27,
- 26, 25, 24, 23, 22, 21, 20, 19, 18, 17,
- 16, 15, 14, 13, 12, 11, 10, 9, 8, 7,
- 6, 5, 4, 3, 2, 1, 0
- },
- {
- 16384, 16195, 16006, 15817, 15629, 15441, 15253, 15065, 14878, 14692,
- 14506, 14321, 14136, 13952, 13768, 13585, 13402, 13219, 13037, 12857,
- 12677, 12499, 12321, 12144, 11967, 11792, 11617, 11444, 11271, 11100,
- 10930, 10762, 10594, 10426, 10258, 10091, 9925, 9761, 9598, 9438,
- 9278, 9120, 8963, 8809, 8655, 8504, 8354, 8207, 8060, 7914,
- 7769, 7627, 7485, 7347, 7209, 7074, 6939, 6807, 6676, 6548,
- 6420, 6296, 6172, 6050, 5928, 5806, 5684, 5564, 5444, 5328,
- 5212, 5100, 4988, 4879, 4771, 4667, 4563, 4462, 4362, 4265,
- 4169, 4073, 3978, 3886, 3795, 3707, 3619, 3535, 3451, 3369,
- 3288, 3210, 3133, 3059, 2985, 2913, 2841, 2769, 2697, 2627,
- 2557, 2490, 2424, 2360, 2297, 2237, 2177, 2119, 2062, 2007,
- 1953, 1901, 1849, 1798, 1748, 1700, 1652, 1607, 1562, 1519,
- 1476, 1435, 1394, 1355, 1317, 1281, 1245, 1210, 1175, 1140,
- 1105, 1071, 1037, 1005, 973, 943, 913, 885, 857, 830,
- 804, 779, 754, 731, 708, 685, 663, 642, 621, 601,
- 581, 563, 545, 528, 511, 495, 479, 463, 448, 433,
- 419, 405, 391, 377, 364, 351, 338, 326, 314, 302,
- 291, 280, 270, 260, 251, 242, 234, 226, 218, 210,
- 202, 195, 188, 181, 174, 168, 162, 156, 150, 144,
- 139, 134, 129, 124, 119, 114, 109, 104, 100, 96,
- 92, 88, 84, 80, 77, 74, 71, 68, 65, 62,
- 59, 56, 54, 52, 50, 48, 46, 44, 42, 40,
- 38, 36, 34, 33, 32, 31, 30, 29, 28, 27,
- 26, 25, 24, 23, 22, 21, 20, 19, 18, 17,
- 16, 15, 14, 13, 12, 11, 10, 9, 8, 7,
- 6, 5, 4, 3, 2, 1, 0
- },
- {
- 16384, 16203, 16022, 15842, 15662, 15482, 15302, 15122, 14942, 14763,
- 14584, 14406, 14228, 14051, 13874, 13698, 13522, 13347, 13172, 12998,
- 12824, 12652, 12480, 12310, 12140, 11971, 11803, 11637, 11471, 11307,
- 11143, 10980, 10817, 10654, 10491, 10330, 10169, 10011, 9853, 9697,
- 9542, 9389, 9236, 9086, 8936, 8789, 8642, 8498, 8355, 8212,
- 8070, 7931, 7792, 7656, 7520, 7388, 7256, 7126, 6996, 6870,
- 6744, 6621, 6498, 6377, 6256, 6135, 6014, 5895, 5776, 5660,
- 5545, 5433, 5321, 5212, 5104, 4999, 4895, 4793, 4692, 4594,
- 4496, 4400, 4304, 4211, 4118, 4028, 3939, 3853, 3767, 3684,
- 3601, 3521, 3441, 3364, 3287, 3212, 3137, 3062, 2987, 2915,
- 2843, 2773, 2704, 2638, 2572, 2508, 2445, 2384, 2324, 2266,
- 2208, 2153, 2098, 2044, 1990, 1939, 1888, 1839, 1791, 1745,
- 1699, 1655, 1611, 1569, 1527, 1487, 1448, 1409, 1370, 1331,
- 1292, 1255, 1218, 1183, 1148, 1115, 1082, 1051, 1020, 990,
- 960, 932, 904, 878, 852, 826, 801, 777, 753, 731,
- 709, 687, 666, 645, 625, 605, 586, 567, 550, 533,
- 516, 499, 482, 465, 449, 433, 418, 403, 389, 375,
- 362, 349, 337, 325, 314, 303, 293, 283, 273, 263,
- 254, 245, 236, 227, 219, 211, 204, 197, 190, 183,
- 177, 171, 165, 159, 153, 147, 141, 135, 130, 125,
- 120, 115, 110, 105, 101, 97, 93, 89, 85, 81,
- 77, 74, 71, 68, 65, 62, 59, 56, 53, 51,
- 49, 47, 45, 43, 41, 39, 37, 35, 33, 31,
- 29, 27, 25, 23, 22, 21, 20, 19, 18, 17,
- 16, 15, 14, 13, 12, 11, 10, 9, 8, 7,
- 6, 5, 4, 3, 2, 1, 0
- },
- {
- 16384, 16210, 16036, 15863, 15690, 15517, 15344, 15172, 15000, 14828,
- 14656, 14485, 14314, 14145, 13976, 13808, 13640, 13472, 13304, 13137,
- 12970, 12804, 12639, 12475, 12312, 12149, 11987, 11827, 11667, 11508,
- 11349, 11192, 11035, 10878, 10721, 10565, 10410, 10257, 10104, 9953,
- 9802, 9654, 9506, 9359, 9213, 9070, 8927, 8787, 8647, 8508,
- 8369, 8233, 8097, 7964, 7831, 7700, 7570, 7442, 7315, 7190,
- 7065, 6943, 6821, 6701, 6581, 6461, 6341, 6223, 6105, 5990,
- 5876, 5764, 5653, 5545, 5437, 5331, 5226, 5124, 5022, 4924,
- 4826, 4729, 4632, 4538, 4444, 4353, 4262, 4174, 4087, 4002,
- 3917, 3835, 3753, 3674, 3595, 3518, 3441, 3364, 3287, 3212,
- 3138, 3066, 2995, 2926, 2858, 2792, 2726, 2662, 2599, 2538,
- 2478, 2420, 2362, 2305, 2249, 2195, 2141, 2089, 2037, 1988,
- 1939, 1891, 1844, 1799, 1754, 1711, 1668, 1626, 1584, 1542,
- 1500, 1459, 1418, 1380, 1342, 1305, 1269, 1234, 1199, 1166,
- 1133, 1102, 1071, 1041, 1012, 983, 954, 926, 899, 872,
- 847, 822, 798, 774, 751, 728, 707, 686, 666, 646,
- 627, 608, 589, 570, 552, 534, 517, 500, 484, 468,
- 453, 438, 424, 410, 397, 384, 372, 360, 348, 336,
- 325, 314, 303, 293, 283, 273, 264, 255, 246, 237,
- 229, 221, 213, 205, 197, 189, 181, 174, 167, 160,
- 154, 148, 142, 136, 131, 126, 121, 116, 111, 106,
- 101, 97, 93, 89, 85, 81, 77, 73, 70, 67,
- 64, 61, 58, 55, 52, 49, 46, 43, 40, 37,
- 35, 33, 31, 29, 27, 25, 23, 21, 19, 17,
- 16, 15, 14, 13, 12, 11, 10, 9, 8, 7,
- 6, 5, 4, 3, 2, 1, 0
- },
- {
- 16384, 16218, 16052, 15886, 15720, 15554, 15389, 15224, 15059, 14895,
- 14731, 14567, 14403, 14240, 14077, 13915, 13753, 13591, 13429, 13269,
- 13109, 12950, 12791, 12633, 12476, 12320, 12164, 12009, 11854, 11701,
- 11548, 11396, 11244, 11092, 10940, 10790, 10640, 10492, 10344, 10198,
- 10052, 9908, 9764, 9622, 9481, 9342, 9203, 9066, 8929, 8793,
- 8657, 8524, 8391, 8261, 8131, 8003, 7875, 7749, 7624, 7502,
- 7380, 7260, 7140, 7022, 6904, 6786, 6668, 6551, 6435, 6322,
- 6209, 6099, 5989, 5881, 5773, 5668, 5563, 5461, 5359, 5260,
- 5161, 5063, 4965, 4871, 4777, 4686, 4595, 4506, 4417, 4331,
- 4245, 4162, 4079, 3999, 3919, 3841, 3763, 3685, 3607, 3530,
- 3454, 3380, 3307, 3236, 3166, 3097, 3029, 2963, 2897, 2834,
- 2771, 2710, 2650, 2591, 2532, 2475, 2418, 2363, 2309, 2257,
- 2205, 2155, 2105, 2057, 2009, 1963, 1918, 1873, 1828, 1783,
- 1738, 1694, 1650, 1607, 1565, 1524, 1484, 1445, 1407, 1369,
- 1333, 1297, 1263, 1229, 1197, 1165, 1134, 1103, 1073, 1043,
- 1015, 987, 960, 933, 907, 882, 858, 834, 811, 788,
- 766, 744, 722, 700, 679, 658, 638, 618, 599, 581,
- 563, 545, 528, 511, 495, 480, 465, 451, 437, 423,
- 410, 397, 384, 372, 360, 348, 337, 326, 315, 305,
- 295, 285, 275, 265, 255, 245, 236, 227, 219, 211,
- 203, 195, 188, 181, 174, 167, 161, 155, 149, 143,
- 137, 131, 126, 121, 116, 111, 106, 101, 97, 93,
- 89, 85, 81, 77, 73, 69, 65, 61, 58, 55,
- 52, 49, 46, 43, 40, 37, 34, 32, 30, 28,
- 26, 24, 22, 20, 18, 16, 14, 12, 10, 8,
- 6, 5, 4, 3, 2, 1, 0
- }
-};
-
-
-static const uint16_t *const cf_table[16] = {
- cf_tables_1[0], cf_tables_1[1], cf_tables_1[2], cf_tables_2[0],
- cf_tables_2[1], cf_tables_2[2], cf_tables_2[3], cf_tables_2[4],
- cf_tables_2[5], cf_tables_2[6], cf_tables_2[7], cf_tables_3[0],
- cf_tables_3[1], cf_tables_3[2], cf_tables_3[3], cf_tables_3[4]
-};
-
-
-/** Initialize a given lookup table using a given delta */
-static void bgmc_lut_fillp(uint8_t *lut, int *lut_status, int delta)
-{
- unsigned int sx, i;
-
- for (sx = 0; sx < 16; sx++)
- for (i = 0; i < LUT_SIZE; i++) {
- unsigned int target = (i + 1) << (FREQ_BITS - LUT_BITS);
- unsigned int symbol = 1 << delta;
-
- while (cf_table[sx][symbol] > target)
- symbol += 1 << delta;
-
- *lut++ = symbol >> delta;
- }
-
- *lut_status = delta;
-}
-
-
-/** Retune the index of a suitable lookup table for a given delta */
-static uint8_t *bgmc_lut_getp(uint8_t *lut, int *lut_status, int delta)
-{
- unsigned int i = av_clip(delta, 0, LUT_BUFF - 1);
-
- lut += (i * LUT_SIZE) << 4;
-
- if (lut_status[i] != delta)
- bgmc_lut_fillp(lut, &lut_status[i], delta);
-
- return lut;
-}
-
-
-/** Initialize the lookup table arrays */
-int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, int **cf_lut_status)
-{
- *cf_lut = av_malloc(sizeof(**cf_lut) * LUT_BUFF * 16 * LUT_SIZE);
- *cf_lut_status = av_malloc(sizeof(**cf_lut_status) * LUT_BUFF);
-
- if (!*cf_lut || !*cf_lut_status) {
- ff_bgmc_end(cf_lut, cf_lut_status);
- av_log(avctx, AV_LOG_ERROR, "Allocating buffer memory failed.\n");
- return AVERROR(ENOMEM);
- } else {
- // initialize lut_status buffer to a value never used to compare against
- memset(*cf_lut_status, -1, sizeof(**cf_lut_status) * LUT_BUFF);
- }
-
- return 0;
-}
-
-
-/** Release the lookup table arrays */
-void ff_bgmc_end(uint8_t **cf_lut, int **cf_lut_status)
-{
- av_freep(cf_lut);
- av_freep(cf_lut_status);
-}
-
-
-/** Initialize decoding and reads the first value */
-void ff_bgmc_decode_init(GetBitContext *gb, unsigned int *h, unsigned int *l,
- unsigned int *v)
-{
- *h = TOP_VALUE;
- *l = 0;
- *v = get_bits_long(gb, VALUE_BITS);
-}
-
-
-/** Finish decoding */
-void ff_bgmc_decode_end(GetBitContext *gb)
-{
- skip_bits_long(gb, -(VALUE_BITS - 2));
-}
-
-
-/** Read and decode a block Gilbert-Moore coded symbol */
-void ff_bgmc_decode(GetBitContext *gb, unsigned int num, int32_t *dst,
- int delta, unsigned int sx,
- unsigned int *h, unsigned int *l, unsigned int *v,
- uint8_t *cf_lut, int *cf_lut_status)
-{
- unsigned int i;
- uint8_t *lut = bgmc_lut_getp(cf_lut, cf_lut_status, delta);
-
- // read current state
- unsigned int high = *h;
- unsigned int low = *l;
- unsigned int value = *v;
-
- lut += sx * LUT_SIZE;
-
- // decode num samples
- for (i = 0; i < num; i++) {
- unsigned int range = high - low + 1;
- unsigned int target = (((value - low + 1) << FREQ_BITS) - 1) / range;
- unsigned int symbol = lut[target >> (FREQ_BITS - LUT_BITS)] << delta;
-
- while (cf_table[sx][symbol] > target)
- symbol += 1 << delta;
-
- symbol = (symbol >> delta) - 1;
-
- high = low + ((range * cf_table[sx][(symbol) << delta] - (1 << FREQ_BITS)) >> FREQ_BITS);
- low = low + ((range * cf_table[sx][(symbol + 1) << delta]) >> FREQ_BITS);
-
- while (1) {
- if (high >= HALF) {
- if (low >= HALF) {
- value -= HALF;
- low -= HALF;
- high -= HALF;
- } else if (low >= FIRST_QTR && high < THIRD_QTR) {
- value -= FIRST_QTR;
- low -= FIRST_QTR;
- high -= FIRST_QTR;
- } else
- break;
- }
-
- low *= 2;
- high = 2 * high + 1;
- value = 2 * value + get_bits1(gb);
- }
-
- *dst++ = symbol;
- }
-
- // save current state
- *h = high;
- *l = low;
- *v = value;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/bgmc.h b/src/thirdparty/ffmpeg/libavcodec/bgmc.h
deleted file mode 100644
index 965c7a777..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/bgmc.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Block Gilbert-Moore decoder
- * Copyright (c) 2010 Thilo Borgmann <thilo.borgmann _at_ googlemail.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
- * Block Gilbert-Moore decoder header
- * @author Thilo Borgmann <thilo.borgmann _at_ googlemail.com>
- */
-
-
-#ifndef AVCODEC_BGMC_H
-#define AVCODEC_BGMC_H
-
-
-#include "avcodec.h"
-#include "get_bits.h"
-
-
-int ff_bgmc_init(AVCodecContext *avctx, uint8_t **cf_lut, int **cf_lut_status);
-
-
-void ff_bgmc_end(uint8_t **cf_lut, int **cf_lut_status);
-
-
-void ff_bgmc_decode_init(GetBitContext *gb,
- unsigned int *h, unsigned int *l, unsigned int *v);
-
-
-void ff_bgmc_decode_end(GetBitContext *gb);
-
-
-void ff_bgmc_decode(GetBitContext *gb, unsigned int num, int32_t *dst,
- int delta, unsigned int sx,
- unsigned int *h, unsigned int *l, unsigned int *v,
- uint8_t *cf_lut, int *cf_lut_status);
-
-
-#endif /* AVCODEC_BGMC_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/bit_depth_template.c b/src/thirdparty/ffmpeg/libavcodec/bit_depth_template.c
deleted file mode 100644
index fb62d2186..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/bit_depth_template.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "rnd_avg.h"
-#include "libavutil/intreadwrite.h"
-
-#ifndef BIT_DEPTH
-#define BIT_DEPTH 8
-#endif
-
-#ifdef AVCODEC_H264_HIGH_DEPTH_H
-# undef pixel
-# undef pixel2
-# undef pixel4
-# undef dctcoef
-# undef INIT_CLIP
-# undef no_rnd_avg_pixel4
-# undef rnd_avg_pixel4
-# undef AV_RN2P
-# undef AV_RN4P
-# undef AV_RN4PA
-# undef AV_WN2P
-# undef AV_WN4P
-# undef AV_WN4PA
-# undef CLIP
-# undef FUNC
-# undef FUNCC
-# undef av_clip_pixel
-# undef PIXEL_SPLAT_X4
-#else
-# define AVCODEC_H264_HIGH_DEPTH_H
-#endif
-
-#if BIT_DEPTH > 8
-# define pixel uint16_t
-# define pixel2 uint32_t
-# define pixel4 uint64_t
-# define dctcoef int32_t
-
-# define INIT_CLIP
-# define no_rnd_avg_pixel4 no_rnd_avg64
-# define rnd_avg_pixel4 rnd_avg64
-# define AV_RN2P AV_RN32
-# define AV_RN4P AV_RN64
-# define AV_RN4PA AV_RN64A
-# define AV_WN2P AV_WN32
-# define AV_WN4P AV_WN64
-# define AV_WN4PA AV_WN64A
-# define PIXEL_SPLAT_X4(x) ((x)*0x0001000100010001ULL)
-
-# define av_clip_pixel(a) av_clip_uintp2(a, BIT_DEPTH)
-# define CLIP(a) av_clip_uintp2(a, BIT_DEPTH)
-#else
-# define pixel uint8_t
-# define pixel2 uint16_t
-# define pixel4 uint32_t
-# define dctcoef int16_t
-
-# define INIT_CLIP
-# define no_rnd_avg_pixel4 no_rnd_avg32
-# define rnd_avg_pixel4 rnd_avg32
-# define AV_RN2P AV_RN16
-# define AV_RN4P AV_RN32
-# define AV_RN4PA AV_RN32A
-# define AV_WN2P AV_WN16
-# define AV_WN4P AV_WN32
-# define AV_WN4PA AV_WN32A
-# define PIXEL_SPLAT_X4(x) ((x)*0x01010101U)
-
-# define av_clip_pixel(a) av_clip_uint8(a)
-# define CLIP(a) av_clip_uint8(a)
-#endif
-
-#define FUNC3(a, b, c) a ## _ ## b ## c
-#define FUNC2(a, b, c) FUNC3(a, b, c)
-#define FUNC(a) FUNC2(a, BIT_DEPTH,)
-#define FUNCC(a) FUNC2(a, BIT_DEPTH, _c)
diff --git a/src/thirdparty/ffmpeg/libavcodec/bitstream.c b/src/thirdparty/ffmpeg/libavcodec/bitstream.c
deleted file mode 100644
index b0a960cf4..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/bitstream.c
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * Common bit i/o utils
- * Copyright (c) 2000, 2001 Fabrice Bellard
- * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
- * Copyright (c) 2010 Loren Merritt
- *
- * alternative bitstream reader & writer 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
- * bitstream api.
- */
-
-#include "libavutil/avassert.h"
-#include "avcodec.h"
-#include "mathops.h"
-#include "get_bits.h"
-#include "put_bits.h"
-
-const uint8_t ff_log2_run[41]={
- 0, 0, 0, 0, 1, 1, 1, 1,
- 2, 2, 2, 2, 3, 3, 3, 3,
- 4, 4, 5, 5, 6, 6, 7, 7,
- 8, 9,10,11,12,13,14,15,
-16,17,18,19,20,21,22,23,
-24,
-};
-
-void avpriv_align_put_bits(PutBitContext *s)
-{
- put_bits(s,s->bit_left & 7,0);
-}
-
-void avpriv_put_string(PutBitContext *pb, const char *string, int terminate_string)
-{
- while(*string){
- put_bits(pb, 8, *string);
- string++;
- }
- if(terminate_string)
- put_bits(pb, 8, 0);
-}
-
-void avpriv_copy_bits(PutBitContext *pb, const uint8_t *src, int length)
-{
- int words= length>>4;
- int bits= length&15;
- int i;
-
- if(length==0) return;
-
- if(CONFIG_SMALL || words < 16 || put_bits_count(pb)&7){
- for(i=0; i<words; i++) put_bits(pb, 16, AV_RB16(src + 2*i));
- }else{
- for(i=0; put_bits_count(pb)&31; i++)
- put_bits(pb, 8, src[i]);
- flush_put_bits(pb);
- memcpy(put_bits_ptr(pb), src+i, 2*words-i);
- skip_put_bytes(pb, 2*words-i);
- }
-
- put_bits(pb, bits, AV_RB16(src + 2*words)>>(16-bits));
-}
-
-/* VLC decoding */
-
-#define GET_DATA(v, table, i, wrap, size) \
-{\
- const uint8_t *ptr = (const uint8_t *)table + i * wrap;\
- switch(size) {\
- case 1:\
- v = *(const uint8_t *)ptr;\
- break;\
- case 2:\
- v = *(const uint16_t *)ptr;\
- break;\
- default:\
- v = *(const uint32_t *)ptr;\
- break;\
- }\
-}
-
-
-static int alloc_table(VLC *vlc, int size, int use_static)
-{
- int index;
- index = vlc->table_size;
- vlc->table_size += size;
- if (vlc->table_size > vlc->table_allocated) {
- if(use_static)
- abort(); // cannot do anything, init_vlc() is used with too little memory
- vlc->table_allocated += (1 << vlc->bits);
- vlc->table = av_realloc_f(vlc->table,
- vlc->table_allocated, sizeof(VLC_TYPE) * 2);
- if (!vlc->table)
- return -1;
- }
- return index;
-}
-
-static av_always_inline uint32_t bitswap_32(uint32_t x) {
- return (uint32_t)ff_reverse[x&0xFF]<<24
- | (uint32_t)ff_reverse[(x>>8)&0xFF]<<16
- | (uint32_t)ff_reverse[(x>>16)&0xFF]<<8
- | (uint32_t)ff_reverse[x>>24];
-}
-
-typedef struct {
- uint8_t bits;
- uint16_t symbol;
- /** codeword, with the first bit-to-be-read in the msb
- * (even if intended for a little-endian bitstream reader) */
- uint32_t code;
-} VLCcode;
-
-static int compare_vlcspec(const void *a, const void *b)
-{
- const VLCcode *sa=a, *sb=b;
- return (sa->code >> 1) - (sb->code >> 1);
-}
-
-/**
- * Build VLC decoding tables suitable for use with get_vlc().
- *
- * @param vlc the context to be initted
- *
- * @param table_nb_bits max length of vlc codes to store directly in this table
- * (Longer codes are delegated to subtables.)
- *
- * @param nb_codes number of elements in codes[]
- *
- * @param codes descriptions of the vlc codes
- * These must be ordered such that codes going into the same subtable are contiguous.
- * Sorting by VLCcode.code is sufficient, though not necessary.
- */
-static int build_table(VLC *vlc, int table_nb_bits, int nb_codes,
- VLCcode *codes, int flags)
-{
- int table_size, table_index, index, code_prefix, symbol, subtable_bits;
- int i, j, k, n, nb, inc;
- uint32_t code;
- VLC_TYPE (*table)[2];
-
- table_size = 1 << table_nb_bits;
- if (table_nb_bits > 30)
- return -1;
- table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_NEW_STATIC);
- av_dlog(NULL, "new table index=%d size=%d\n", table_index, table_size);
- if (table_index < 0)
- return -1;
- table = &vlc->table[table_index];
-
- for (i = 0; i < table_size; i++) {
- table[i][1] = 0; //bits
- table[i][0] = -1; //codes
- }
-
- /* first pass: map codes and compute auxiliary table sizes */
- for (i = 0; i < nb_codes; i++) {
- n = codes[i].bits;
- code = codes[i].code;
- symbol = codes[i].symbol;
- av_dlog(NULL, "i=%d n=%d code=0x%x\n", i, n, code);
- if (n <= table_nb_bits) {
- /* no need to add another table */
- j = code >> (32 - table_nb_bits);
- nb = 1 << (table_nb_bits - n);
- inc = 1;
- if (flags & INIT_VLC_LE) {
- j = bitswap_32(code);
- inc = 1 << n;
- }
- for (k = 0; k < nb; k++) {
- av_dlog(NULL, "%4x: code=%d n=%d\n", j, i, n);
- if (table[j][1] /*bits*/ != 0) {
- av_log(NULL, AV_LOG_ERROR, "incorrect codes\n");
- return -1;
- }
- table[j][1] = n; //bits
- table[j][0] = symbol;
- j += inc;
- }
- } else {
- /* fill auxiliary table recursively */
- n -= table_nb_bits;
- code_prefix = code >> (32 - table_nb_bits);
- subtable_bits = n;
- codes[i].bits = n;
- codes[i].code = code << table_nb_bits;
- for (k = i+1; k < nb_codes; k++) {
- n = codes[k].bits - table_nb_bits;
- if (n <= 0)
- break;
- code = codes[k].code;
- if (code >> (32 - table_nb_bits) != code_prefix)
- break;
- codes[k].bits = n;
- codes[k].code = code << table_nb_bits;
- subtable_bits = FFMAX(subtable_bits, n);
- }
- subtable_bits = FFMIN(subtable_bits, table_nb_bits);
- j = (flags & INIT_VLC_LE) ? bitswap_32(code_prefix) >> (32 - table_nb_bits) : code_prefix;
- table[j][1] = -subtable_bits;
- av_dlog(NULL, "%4x: n=%d (subtable)\n",
- j, codes[i].bits + table_nb_bits);
- index = build_table(vlc, subtable_bits, k-i, codes+i, flags);
- if (index < 0)
- return -1;
- /* note: realloc has been done, so reload tables */
- table = &vlc->table[table_index];
- table[j][0] = index; //code
- i = k-1;
- }
- }
- return table_index;
-}
-
-
-/* Build VLC decoding tables suitable for use with get_vlc().
-
- 'nb_bits' set thee decoding table size (2^nb_bits) entries. The
- bigger it is, the faster is the decoding. But it should not be too
- big to save memory and L1 cache. '9' is a good compromise.
-
- 'nb_codes' : number of vlcs codes
-
- 'bits' : table which gives the size (in bits) of each vlc code.
-
- 'codes' : table which gives the bit pattern of of each vlc code.
-
- 'symbols' : table which gives the values to be returned from get_vlc().
-
- 'xxx_wrap' : give the number of bytes between each entry of the
- 'bits' or 'codes' tables.
-
- 'xxx_size' : gives the number of bytes of each entry of the 'bits'
- or 'codes' tables.
-
- 'wrap' and 'size' allows to use any memory configuration and types
- (byte/word/long) to store the 'bits', 'codes', and 'symbols' tables.
-
- 'use_static' should be set to 1 for tables, which should be freed
- with av_free_static(), 0 if ff_free_vlc() will be used.
-*/
-int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
- const void *bits, int bits_wrap, int bits_size,
- const void *codes, int codes_wrap, int codes_size,
- const void *symbols, int symbols_wrap, int symbols_size,
- int flags)
-{
- VLCcode *buf;
- int i, j, ret;
-
- vlc->bits = nb_bits;
- if(flags & INIT_VLC_USE_NEW_STATIC){
- VLC dyn_vlc = *vlc;
-
- if (vlc->table_size)
- return 0;
-
- ret = ff_init_vlc_sparse(&dyn_vlc, nb_bits, nb_codes,
- bits, bits_wrap, bits_size,
- codes, codes_wrap, codes_size,
- symbols, symbols_wrap, symbols_size,
- flags & ~INIT_VLC_USE_NEW_STATIC);
- av_assert0(ret >= 0);
- av_assert0(dyn_vlc.table_size <= vlc->table_allocated);
- if(dyn_vlc.table_size < vlc->table_allocated)
- av_log(NULL, AV_LOG_ERROR, "needed %d had %d\n", dyn_vlc.table_size, vlc->table_allocated);
- memcpy(vlc->table, dyn_vlc.table, dyn_vlc.table_size * sizeof(*vlc->table));
- vlc->table_size = dyn_vlc.table_size;
- ff_free_vlc(&dyn_vlc);
- return 0;
- }else {
- vlc->table = NULL;
- vlc->table_allocated = 0;
- vlc->table_size = 0;
- }
-
- av_dlog(NULL, "build table nb_codes=%d\n", nb_codes);
-
- buf = av_malloc((nb_codes+1)*sizeof(VLCcode));
-
- av_assert0(symbols_size <= 2 || !symbols);
- j = 0;
-#define COPY(condition)\
- for (i = 0; i < nb_codes; i++) {\
- GET_DATA(buf[j].bits, bits, i, bits_wrap, bits_size);\
- if (!(condition))\
- continue;\
- GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size);\
- if (flags & INIT_VLC_LE)\
- buf[j].code = bitswap_32(buf[j].code);\
- else\
- buf[j].code <<= 32 - buf[j].bits;\
- if (symbols)\
- GET_DATA(buf[j].symbol, symbols, i, symbols_wrap, symbols_size)\
- else\
- buf[j].symbol = i;\
- j++;\
- }
- COPY(buf[j].bits > nb_bits);
- // qsort is the slowest part of init_vlc, and could probably be improved or avoided
- qsort(buf, j, sizeof(VLCcode), compare_vlcspec);
- COPY(buf[j].bits && buf[j].bits <= nb_bits);
- nb_codes = j;
-
- ret = build_table(vlc, nb_bits, nb_codes, buf, flags);
-
- av_free(buf);
- if (ret < 0) {
- av_freep(&vlc->table);
- return -1;
- }
- return 0;
-}
-
-
-void ff_free_vlc(VLC *vlc)
-{
- av_freep(&vlc->table);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/bytestream.h b/src/thirdparty/ffmpeg/libavcodec/bytestream.h
deleted file mode 100644
index b6c3dd6e7..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/bytestream.h
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
- * Bytestream functions
- * copyright (c) 2006 Baptiste Coudurier <baptiste.coudurier@free.fr>
- * Copyright (c) 2012 Aneesh Dogra (lionaneesh) <lionaneesh@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_BYTESTREAM_H
-#define AVCODEC_BYTESTREAM_H
-
-#include <stdint.h>
-#include <string.h>
-
-#include "libavutil/common.h"
-#include "libavutil/intreadwrite.h"
-
-typedef struct GetByteContext {
- const uint8_t *buffer, *buffer_end, *buffer_start;
-} GetByteContext;
-
-typedef struct PutByteContext {
- uint8_t *buffer, *buffer_end, *buffer_start;
- int eof;
-} PutByteContext;
-
-#define DEF(type, name, bytes, read, write) \
-static av_always_inline type bytestream_get_ ## name(const uint8_t **b) \
-{ \
- (*b) += bytes; \
- return read(*b - bytes); \
-} \
-static av_always_inline void bytestream_put_ ## name(uint8_t **b, \
- const type value) \
-{ \
- write(*b, value); \
- (*b) += bytes; \
-} \
-static av_always_inline void bytestream2_put_ ## name ## u(PutByteContext *p, \
- const type value) \
-{ \
- bytestream_put_ ## name(&p->buffer, value); \
-} \
-static av_always_inline void bytestream2_put_ ## name(PutByteContext *p, \
- const type value) \
-{ \
- if (!p->eof && (p->buffer_end - p->buffer >= bytes)) { \
- write(p->buffer, value); \
- p->buffer += bytes; \
- } else \
- p->eof = 1; \
-} \
-static av_always_inline type bytestream2_get_ ## name ## u(GetByteContext *g) \
-{ \
- return bytestream_get_ ## name(&g->buffer); \
-} \
-static av_always_inline type bytestream2_get_ ## name(GetByteContext *g) \
-{ \
- if (g->buffer_end - g->buffer < bytes) \
- return 0; \
- return bytestream2_get_ ## name ## u(g); \
-} \
-static av_always_inline type bytestream2_peek_ ## name(GetByteContext *g) \
-{ \
- if (g->buffer_end - g->buffer < bytes) \
- return 0; \
- return read(g->buffer); \
-}
-
-DEF(uint64_t, le64, 8, AV_RL64, AV_WL64)
-DEF(unsigned int, le32, 4, AV_RL32, AV_WL32)
-DEF(unsigned int, le24, 3, AV_RL24, AV_WL24)
-DEF(unsigned int, le16, 2, AV_RL16, AV_WL16)
-DEF(uint64_t, be64, 8, AV_RB64, AV_WB64)
-DEF(unsigned int, be32, 4, AV_RB32, AV_WB32)
-DEF(unsigned int, be24, 3, AV_RB24, AV_WB24)
-DEF(unsigned int, be16, 2, AV_RB16, AV_WB16)
-DEF(unsigned int, byte, 1, AV_RB8 , AV_WB8)
-
-#if HAVE_BIGENDIAN
-# define bytestream2_get_ne16 bytestream2_get_be16
-# define bytestream2_get_ne24 bytestream2_get_be24
-# define bytestream2_get_ne32 bytestream2_get_be32
-# define bytestream2_get_ne64 bytestream2_get_be64
-# define bytestream2_get_ne16u bytestream2_get_be16u
-# define bytestream2_get_ne24u bytestream2_get_be24u
-# define bytestream2_get_ne32u bytestream2_get_be32u
-# define bytestream2_get_ne64u bytestream2_get_be64u
-# define bytestream2_put_ne16 bytestream2_put_be16
-# define bytestream2_put_ne24 bytestream2_put_be24
-# define bytestream2_put_ne32 bytestream2_put_be32
-# define bytestream2_put_ne64 bytestream2_put_be64
-# define bytestream2_peek_ne16 bytestream2_peek_be16
-# define bytestream2_peek_ne24 bytestream2_peek_be24
-# define bytestream2_peek_ne32 bytestream2_peek_be32
-# define bytestream2_peek_ne64 bytestream2_peek_be64
-#else
-# define bytestream2_get_ne16 bytestream2_get_le16
-# define bytestream2_get_ne24 bytestream2_get_le24
-# define bytestream2_get_ne32 bytestream2_get_le32
-# define bytestream2_get_ne64 bytestream2_get_le64
-# define bytestream2_get_ne16u bytestream2_get_le16u
-# define bytestream2_get_ne24u bytestream2_get_le24u
-# define bytestream2_get_ne32u bytestream2_get_le32u
-# define bytestream2_get_ne64u bytestream2_get_le64u
-# define bytestream2_put_ne16 bytestream2_put_le16
-# define bytestream2_put_ne24 bytestream2_put_le24
-# define bytestream2_put_ne32 bytestream2_put_le32
-# define bytestream2_put_ne64 bytestream2_put_le64
-# define bytestream2_peek_ne16 bytestream2_peek_le16
-# define bytestream2_peek_ne24 bytestream2_peek_le24
-# define bytestream2_peek_ne32 bytestream2_peek_le32
-# define bytestream2_peek_ne64 bytestream2_peek_le64
-#endif
-
-static av_always_inline void bytestream2_init(GetByteContext *g,
- const uint8_t *buf,
- int buf_size)
-{
- g->buffer = buf;
- g->buffer_start = buf;
- g->buffer_end = buf + buf_size;
-}
-
-static av_always_inline void bytestream2_init_writer(PutByteContext *p,
- uint8_t *buf,
- int buf_size)
-{
- p->buffer = buf;
- p->buffer_start = buf;
- p->buffer_end = buf + buf_size;
- p->eof = 0;
-}
-
-static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
-{
- return g->buffer_end - g->buffer;
-}
-
-static av_always_inline unsigned int bytestream2_get_bytes_left_p(PutByteContext *p)
-{
- return p->buffer_end - p->buffer;
-}
-
-static av_always_inline void bytestream2_skip(GetByteContext *g,
- unsigned int size)
-{
- g->buffer += FFMIN(g->buffer_end - g->buffer, size);
-}
-
-static av_always_inline void bytestream2_skipu(GetByteContext *g,
- unsigned int size)
-{
- g->buffer += size;
-}
-
-static av_always_inline void bytestream2_skip_p(PutByteContext *p,
- unsigned int size)
-{
- int size2;
- if (p->eof)
- return;
- size2 = FFMIN(p->buffer_end - p->buffer, size);
- if (size2 != size)
- p->eof = 1;
- p->buffer += size2;
-}
-
-static av_always_inline int bytestream2_tell(GetByteContext *g)
-{
- return (int)(g->buffer - g->buffer_start);
-}
-
-static av_always_inline int bytestream2_tell_p(PutByteContext *p)
-{
- return (int)(p->buffer - p->buffer_start);
-}
-
-static av_always_inline int bytestream2_size(GetByteContext *g)
-{
- return (int)(g->buffer_end - g->buffer_start);
-}
-
-static av_always_inline int bytestream2_size_p(PutByteContext *p)
-{
- return (int)(p->buffer_end - p->buffer_start);
-}
-
-static av_always_inline int bytestream2_seek(GetByteContext *g,
- int offset,
- int whence)
-{
- switch (whence) {
- case SEEK_CUR:
- offset = av_clip(offset, -(g->buffer - g->buffer_start),
- g->buffer_end - g->buffer);
- g->buffer += offset;
- break;
- case SEEK_END:
- offset = av_clip(offset, -(g->buffer_end - g->buffer_start), 0);
- g->buffer = g->buffer_end + offset;
- break;
- case SEEK_SET:
- offset = av_clip(offset, 0, g->buffer_end - g->buffer_start);
- g->buffer = g->buffer_start + offset;
- break;
- default:
- return AVERROR(EINVAL);
- }
- return bytestream2_tell(g);
-}
-
-static av_always_inline int bytestream2_seek_p(PutByteContext *p,
- int offset,
- int whence)
-{
- p->eof = 0;
- switch (whence) {
- case SEEK_CUR:
- if (p->buffer_end - p->buffer < offset)
- p->eof = 1;
- offset = av_clip(offset, -(p->buffer - p->buffer_start),
- p->buffer_end - p->buffer);
- p->buffer += offset;
- break;
- case SEEK_END:
- if (offset > 0)
- p->eof = 1;
- offset = av_clip(offset, -(p->buffer_end - p->buffer_start), 0);
- p->buffer = p->buffer_end + offset;
- break;
- case SEEK_SET:
- if (p->buffer_end - p->buffer_start < offset)
- p->eof = 1;
- offset = av_clip(offset, 0, p->buffer_end - p->buffer_start);
- p->buffer = p->buffer_start + offset;
- break;
- default:
- return AVERROR(EINVAL);
- }
- return bytestream2_tell_p(p);
-}
-
-static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g,
- uint8_t *dst,
- unsigned int size)
-{
- int size2 = FFMIN(g->buffer_end - g->buffer, size);
- memcpy(dst, g->buffer, size2);
- g->buffer += size2;
- return size2;
-}
-
-static av_always_inline unsigned int bytestream2_get_bufferu(GetByteContext *g,
- uint8_t *dst,
- unsigned int size)
-{
- memcpy(dst, g->buffer, size);
- g->buffer += size;
- return size;
-}
-
-static av_always_inline unsigned int bytestream2_put_buffer(PutByteContext *p,
- const uint8_t *src,
- unsigned int size)
-{
- int size2;
- if (p->eof)
- return 0;
- size2 = FFMIN(p->buffer_end - p->buffer, size);
- if (size2 != size)
- p->eof = 1;
- memcpy(p->buffer, src, size2);
- p->buffer += size2;
- return size2;
-}
-
-static av_always_inline unsigned int bytestream2_put_bufferu(PutByteContext *p,
- const uint8_t *src,
- unsigned int size)
-{
- memcpy(p->buffer, src, size);
- p->buffer += size;
- return size;
-}
-
-static av_always_inline void bytestream2_set_buffer(PutByteContext *p,
- const uint8_t c,
- unsigned int size)
-{
- int size2;
- if (p->eof)
- return;
- size2 = FFMIN(p->buffer_end - p->buffer, size);
- if (size2 != size)
- p->eof = 1;
- memset(p->buffer, c, size2);
- p->buffer += size2;
-}
-
-static av_always_inline void bytestream2_set_bufferu(PutByteContext *p,
- const uint8_t c,
- unsigned int size)
-{
- memset(p->buffer, c, size);
- p->buffer += size;
-}
-
-static av_always_inline unsigned int bytestream2_get_eof(PutByteContext *p)
-{
- return p->eof;
-}
-
-static av_always_inline unsigned int bytestream_get_buffer(const uint8_t **b,
- uint8_t *dst,
- unsigned int size)
-{
- memcpy(dst, *b, size);
- (*b) += size;
- return size;
-}
-
-static av_always_inline void bytestream_put_buffer(uint8_t **b,
- const uint8_t *src,
- unsigned int size)
-{
- memcpy(*b, src, size);
- (*b) += size;
-}
-
-#endif /* AVCODEC_BYTESTREAM_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/cabac.c b/src/thirdparty/ffmpeg/libavcodec/cabac.c
deleted file mode 100644
index f0a4f3644..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/cabac.c
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * H.26L/H.264/AVC/JVT/14496-10/... encoder/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
- * Context Adaptive Binary Arithmetic Coder.
- */
-
-#include <string.h>
-
-#include "libavutil/common.h"
-#include "get_bits.h"
-#include "cabac.h"
-#include "cabac_functions.h"
-
-uint8_t ff_h264_cabac_tables[512 + 4*2*64 + 4*64 + 63] = {
- 9,8,7,7,6,6,6,6,5,5,5,5,5,5,5,5,
- 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
- 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
- 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
- 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
- 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
- 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
- 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
- 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,
- 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,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,
-};
-
-static const uint8_t lps_range[64][4]= {
-{128,176,208,240}, {128,167,197,227}, {128,158,187,216}, {123,150,178,205},
-{116,142,169,195}, {111,135,160,185}, {105,128,152,175}, {100,122,144,166},
-{ 95,116,137,158}, { 90,110,130,150}, { 85,104,123,142}, { 81, 99,117,135},
-{ 77, 94,111,128}, { 73, 89,105,122}, { 69, 85,100,116}, { 66, 80, 95,110},
-{ 62, 76, 90,104}, { 59, 72, 86, 99}, { 56, 69, 81, 94}, { 53, 65, 77, 89},
-{ 51, 62, 73, 85}, { 48, 59, 69, 80}, { 46, 56, 66, 76}, { 43, 53, 63, 72},
-{ 41, 50, 59, 69}, { 39, 48, 56, 65}, { 37, 45, 54, 62}, { 35, 43, 51, 59},
-{ 33, 41, 48, 56}, { 32, 39, 46, 53}, { 30, 37, 43, 50}, { 29, 35, 41, 48},
-{ 27, 33, 39, 45}, { 26, 31, 37, 43}, { 24, 30, 35, 41}, { 23, 28, 33, 39},
-{ 22, 27, 32, 37}, { 21, 26, 30, 35}, { 20, 24, 29, 33}, { 19, 23, 27, 31},
-{ 18, 22, 26, 30}, { 17, 21, 25, 28}, { 16, 20, 23, 27}, { 15, 19, 22, 25},
-{ 14, 18, 21, 24}, { 14, 17, 20, 23}, { 13, 16, 19, 22}, { 12, 15, 18, 21},
-{ 12, 14, 17, 20}, { 11, 14, 16, 19}, { 11, 13, 15, 18}, { 10, 12, 15, 17},
-{ 10, 12, 14, 16}, { 9, 11, 13, 15}, { 9, 11, 12, 14}, { 8, 10, 12, 14},
-{ 8, 9, 11, 13}, { 7, 9, 11, 12}, { 7, 9, 10, 12}, { 7, 8, 10, 11},
-{ 6, 8, 9, 11}, { 6, 7, 9, 10}, { 6, 7, 8, 9}, { 2, 2, 2, 2},
-};
-
-static uint8_t h264_lps_state[2*64];
-static uint8_t h264_mps_state[2*64];
-
-static const uint8_t mps_state[64]= {
- 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,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,
- 57,58,59,60,61,62,62,63,
-};
-
-static const uint8_t lps_state[64]= {
- 0, 0, 1, 2, 2, 4, 4, 5,
- 6, 7, 8, 9, 9,11,11,12,
- 13,13,15,15,16,16,18,18,
- 19,19,21,21,22,22,23,24,
- 24,25,26,26,27,27,28,29,
- 29,30,30,30,31,32,32,33,
- 33,33,34,34,35,35,35,36,
- 36,36,37,37,37,38,38,63,
-};
-
-static const uint8_t last_coeff_flag_offset_8x8[63] = {
- 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
- 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8
-};
-
-/**
- *
- * @param buf_size size of buf in bits
- */
-void ff_init_cabac_encoder(CABACContext *c, uint8_t *buf, int buf_size){
- init_put_bits(&c->pb, buf, buf_size);
-
- c->low= 0;
- c->range= 0x1FE;
- c->outstanding_count= 0;
- c->pb.bit_left++; //avoids firstBitFlag
-}
-
-/**
- *
- * @param buf_size size of buf in bits
- */
-void ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size){
- c->bytestream_start=
- c->bytestream= buf;
- c->bytestream_end= buf + buf_size;
-
-#if CABAC_BITS == 16
- c->low = (*c->bytestream++)<<18;
- c->low+= (*c->bytestream++)<<10;
-#else
- c->low = (*c->bytestream++)<<10;
-#endif
- c->low+= ((*c->bytestream++)<<2) + 2;
- c->range= 0x1FE;
-}
-
-void ff_init_cabac_states(){
- int i, j;
-
- for(i=0; i<64; i++){
- for(j=0; j<4; j++){ //FIXME check if this is worth the 1 shift we save
- ff_h264_lps_range[j*2*64+2*i+0]=
- ff_h264_lps_range[j*2*64+2*i+1]= lps_range[i][j];
- }
-
- ff_h264_mlps_state[128+2*i+0]=
- h264_mps_state[2 * i + 0] = 2 * mps_state[i] + 0;
- ff_h264_mlps_state[128+2*i+1]=
- h264_mps_state[2 * i + 1] = 2 * mps_state[i] + 1;
-
- if( i ){
- h264_lps_state[2*i+0]=
- ff_h264_mlps_state[128-2*i-1]= 2*lps_state[i]+0;
- h264_lps_state[2*i+1]=
- ff_h264_mlps_state[128-2*i-2]= 2*lps_state[i]+1;
- }else{
- h264_lps_state[2*i+0]=
- ff_h264_mlps_state[128-2*i-1]= 1;
- h264_lps_state[2*i+1]=
- ff_h264_mlps_state[128-2*i-2]= 0;
- }
- }
- for(i=0; i< 63; i++){
- ff_h264_last_coeff_flag_offset_8x8[i] = last_coeff_flag_offset_8x8[i];
- }
-}
-
-#ifdef TEST
-#define SIZE 10240
-
-#include "libavutil/lfg.h"
-#include "avcodec.h"
-#include "cabac.h"
-
-static inline void put_cabac_bit(CABACContext *c, int b){
- put_bits(&c->pb, 1, b);
- for(;c->outstanding_count; c->outstanding_count--){
- put_bits(&c->pb, 1, 1-b);
- }
-}
-
-static inline void renorm_cabac_encoder(CABACContext *c){
- while(c->range < 0x100){
- //FIXME optimize
- if(c->low<0x100){
- put_cabac_bit(c, 0);
- }else if(c->low<0x200){
- c->outstanding_count++;
- c->low -= 0x100;
- }else{
- put_cabac_bit(c, 1);
- c->low -= 0x200;
- }
-
- c->range+= c->range;
- c->low += c->low;
- }
-}
-
-static void put_cabac(CABACContext *c, uint8_t * const state, int bit){
- int RangeLPS= ff_h264_lps_range[2*(c->range&0xC0) + *state];
-
- if(bit == ((*state)&1)){
- c->range -= RangeLPS;
- *state = h264_mps_state[*state];
- }else{
- c->low += c->range - RangeLPS;
- c->range = RangeLPS;
- *state= h264_lps_state[*state];
- }
-
- renorm_cabac_encoder(c);
-}
-
-/**
- * @param bit 0 -> write zero bit, !=0 write one bit
- */
-static void put_cabac_bypass(CABACContext *c, int bit){
- c->low += c->low;
-
- if(bit){
- c->low += c->range;
- }
-//FIXME optimize
- if(c->low<0x200){
- put_cabac_bit(c, 0);
- }else if(c->low<0x400){
- c->outstanding_count++;
- c->low -= 0x200;
- }else{
- put_cabac_bit(c, 1);
- c->low -= 0x400;
- }
-}
-
-/**
- *
- * @return the number of bytes written
- */
-static int put_cabac_terminate(CABACContext *c, int bit){
- c->range -= 2;
-
- if(!bit){
- renorm_cabac_encoder(c);
- }else{
- c->low += c->range;
- c->range= 2;
-
- renorm_cabac_encoder(c);
-
- av_assert0(c->low <= 0x1FF);
- put_cabac_bit(c, c->low>>9);
- put_bits(&c->pb, 2, ((c->low>>7)&3)|1);
-
- flush_put_bits(&c->pb); //FIXME FIXME FIXME XXX wrong
- }
-
- return (put_bits_count(&c->pb)+7)>>3;
-}
-
-int main(void){
- CABACContext c;
- uint8_t b[9*SIZE];
- uint8_t r[9*SIZE];
- int i;
- uint8_t state[10]= {0};
- AVLFG prng;
-
- av_lfg_init(&prng, 1);
- ff_init_cabac_encoder(&c, b, SIZE);
- ff_init_cabac_states();
-
- for(i=0; i<SIZE; i++){
- if(2*i<SIZE) r[i] = av_lfg_get(&prng) % 7;
- else r[i] = (i>>8)&1;
- }
-
- for(i=0; i<SIZE; i++){
-START_TIMER
- put_cabac_bypass(&c, r[i]&1);
-STOP_TIMER("put_cabac_bypass")
- }
-
- for(i=0; i<SIZE; i++){
-START_TIMER
- put_cabac(&c, state, r[i]&1);
-STOP_TIMER("put_cabac")
- }
-
- put_cabac_terminate(&c, 1);
-
- ff_init_cabac_decoder(&c, b, SIZE);
-
- memset(state, 0, sizeof(state));
-
- for(i=0; i<SIZE; i++){
-START_TIMER
- if( (r[i]&1) != get_cabac_bypass(&c) )
- av_log(NULL, AV_LOG_ERROR, "CABAC bypass failure at %d\n", i);
-STOP_TIMER("get_cabac_bypass")
- }
-
- for(i=0; i<SIZE; i++){
-START_TIMER
- if( (r[i]&1) != get_cabac(&c, state) )
- av_log(NULL, AV_LOG_ERROR, "CABAC failure at %d\n", i);
-STOP_TIMER("get_cabac")
- }
- if(!get_cabac_terminate(&c))
- av_log(NULL, AV_LOG_ERROR, "where's the Terminator?\n");
-
- return 0;
-}
-
-#endif /* TEST */
diff --git a/src/thirdparty/ffmpeg/libavcodec/cabac.h b/src/thirdparty/ffmpeg/libavcodec/cabac.h
deleted file mode 100644
index ab14e8110..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/cabac.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * H.26L/H.264/AVC/JVT/14496-10/... encoder/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
- * Context Adaptive Binary Arithmetic Coder.
- */
-
-#ifndef AVCODEC_CABAC_H
-#define AVCODEC_CABAC_H
-
-#include <stdint.h>
-
-#include "put_bits.h"
-
-#define H264_NORM_SHIFT_OFFSET 0
-#define H264_LPS_RANGE_OFFSET 512
-#define H264_MLPS_STATE_OFFSET 1024
-#define H264_LAST_COEFF_FLAG_OFFSET_8x8_OFFSET 1280
-
-#define CABAC_BITS 16
-#define CABAC_MASK ((1<<CABAC_BITS)-1)
-
-typedef struct CABACContext{
- int low;
- int range;
- int outstanding_count;
- const uint8_t *bytestream_start;
- const uint8_t *bytestream;
- const uint8_t *bytestream_end;
- PutBitContext pb;
-}CABACContext;
-
-void ff_init_cabac_encoder(CABACContext *c, uint8_t *buf, int buf_size);
-void ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size);
-void ff_init_cabac_states(void);
-
-#endif /* AVCODEC_CABAC_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/cabac_functions.h b/src/thirdparty/ffmpeg/libavcodec/cabac_functions.h
deleted file mode 100644
index 307b81a23..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/cabac_functions.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * H.26L/H.264/AVC/JVT/14496-10/... encoder/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
- * Context Adaptive Binary Arithmetic Coder inline functions
- */
-
-#ifndef AVCODEC_CABAC_FUNCTIONS_H
-#define AVCODEC_CABAC_FUNCTIONS_H
-
-#include <stdint.h>
-
-#include "cabac.h"
-#include "config.h"
-
-#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;
-static uint8_t * const ff_h264_last_coeff_flag_offset_8x8 = ff_h264_cabac_tables + H264_LAST_COEFF_FLAG_OFFSET_8x8_OFFSET;
-
-static void refill(CABACContext *c){
-#if CABAC_BITS == 16
- c->low+= (c->bytestream[0]<<9) + (c->bytestream[1]<<1);
-#else
- c->low+= c->bytestream[0]<<1;
-#endif
- c->low -= CABAC_MASK;
- c->bytestream += CABAC_BITS / 8;
-}
-
-static inline void renorm_cabac_decoder_once(CABACContext *c){
- int shift= (uint32_t)(c->range - 0x100)>>31;
- c->range<<= shift;
- c->low <<= shift;
- if(!(c->low & CABAC_MASK))
- refill(c);
-}
-
-#ifndef get_cabac_inline
-static void refill2(CABACContext *c){
- int i, x;
-
- x= c->low ^ (c->low-1);
- i= 7 - ff_h264_norm_shift[x>>(CABAC_BITS-1)];
-
- x= -CABAC_MASK;
-
-#if CABAC_BITS == 16
- x+= (c->bytestream[0]<<9) + (c->bytestream[1]<<1);
-#else
- x+= c->bytestream[0]<<1;
-#endif
-
- c->low += x<<i;
- c->bytestream += CABAC_BITS/8;
-}
-
-static av_always_inline int get_cabac_inline(CABACContext *c, uint8_t * const state){
- int s = *state;
- int RangeLPS= ff_h264_lps_range[2*(c->range&0xC0) + s];
- int bit, lps_mask;
-
- c->range -= RangeLPS;
- lps_mask= ((c->range<<(CABAC_BITS+1)) - c->low)>>31;
-
- c->low -= (c->range<<(CABAC_BITS+1)) & lps_mask;
- c->range += (RangeLPS - c->range) & lps_mask;
-
- s^=lps_mask;
- *state= (ff_h264_mlps_state+128)[s];
- bit= s&1;
-
- lps_mask= ff_h264_norm_shift[c->range];
- c->range<<= lps_mask;
- c->low <<= lps_mask;
- if(!(c->low & CABAC_MASK))
- refill2(c);
- return bit;
-}
-#endif
-
-static int av_noinline av_unused get_cabac_noinline(CABACContext *c, uint8_t * const state){
- return get_cabac_inline(c,state);
-}
-
-static int av_unused get_cabac(CABACContext *c, uint8_t * const state){
- return get_cabac_inline(c,state);
-}
-
-static int av_unused get_cabac_bypass(CABACContext *c){
- int range;
- c->low += c->low;
-
- if(!(c->low & CABAC_MASK))
- refill(c);
-
- range= c->range<<(CABAC_BITS+1);
- if(c->low < range){
- return 0;
- }else{
- c->low -= range;
- return 1;
- }
-}
-
-
-#ifndef get_cabac_bypass_sign
-static av_always_inline int get_cabac_bypass_sign(CABACContext *c, int val){
- int range, mask;
- c->low += c->low;
-
- if(!(c->low & CABAC_MASK))
- refill(c);
-
- range= c->range<<(CABAC_BITS+1);
- c->low -= range;
- mask= c->low >> 31;
- range &= mask;
- c->low += range;
- return (val^mask)-mask;
-}
-#endif
-
-/**
- *
- * @return the number of bytes read or 0 if no end
- */
-static int av_unused get_cabac_terminate(CABACContext *c){
- c->range -= 2;
- if(c->low < c->range<<(CABAC_BITS+1)){
- renorm_cabac_decoder_once(c);
- return 0;
- }else{
- return c->bytestream - c->bytestream_start;
- }
-}
-
-#endif /* AVCODEC_CABAC_FUNCTIONS_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/cbrt_tablegen.h b/src/thirdparty/ffmpeg/libavcodec/cbrt_tablegen.h
deleted file mode 100644
index 1e893c5d1..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/cbrt_tablegen.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Header file for hardcoded AAC cube-root table
- *
- * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
- *
- * 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_CBRT_TABLEGEN_H
-#define AVCODEC_CBRT_TABLEGEN_H
-
-#include <stdint.h>
-#include <math.h>
-
-#if CONFIG_HARDCODED_TABLES
-#define cbrt_tableinit()
-#include "libavcodec/cbrt_tables.h"
-#else
-static uint32_t cbrt_tab[1 << 13];
-
-static void cbrt_tableinit(void)
-{
- if (!cbrt_tab[(1<<13) - 1]) {
- int i;
- for (i = 0; i < 1<<13; i++) {
- union {
- float f;
- uint32_t i;
- } f;
- f.f = cbrtf(i) * i;
- cbrt_tab[i] = f.i;
- }
- }
-}
-#endif /* CONFIG_HARDCODED_TABLES */
-
-#endif /* AVCODEC_CBRT_TABLEGEN_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/celp_filters.c b/src/thirdparty/ffmpeg/libavcodec/celp_filters.c
deleted file mode 100644
index 7d5d5ed48..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/celp_filters.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * various filters for ACELP-based codecs
- *
- * Copyright (c) 2008 Vladimir Voroshilov
- *
- * 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 <inttypes.h>
-
-#include "avcodec.h"
-#include "celp_filters.h"
-#include "libavutil/avassert.h"
-#include "libavutil/common.h"
-
-void ff_celp_convolve_circ(int16_t* fc_out, const int16_t* fc_in,
- const int16_t* filter, int len)
-{
- int i, k;
-
- memset(fc_out, 0, len * sizeof(int16_t));
-
- /* Since there are few pulses over an entire subframe (i.e. almost
- all fc_in[i] are zero) it is faster to loop over fc_in first. */
- for (i = 0; i < len; i++) {
- if (fc_in[i]) {
- for (k = 0; k < i; k++)
- fc_out[k] += (fc_in[i] * filter[len + k - i]) >> 15;
-
- for (k = i; k < len; k++)
- fc_out[k] += (fc_in[i] * filter[ k - i]) >> 15;
- }
- }
-}
-
-void ff_celp_circ_addf(float *out, const float *in,
- const float *lagged, int lag, float fac, int n)
-{
- int k;
- for (k = 0; k < lag; k++)
- out[k] = in[k] + fac * lagged[n + k - lag];
- for (; k < n; k++)
- out[k] = in[k] + fac * lagged[ k - lag];
-}
-
-int ff_celp_lp_synthesis_filter(int16_t *out, const int16_t *filter_coeffs,
- const int16_t *in, int buffer_length,
- int filter_length, int stop_on_overflow,
- int shift, int rounder)
-{
- int i,n;
-
- for (n = 0; n < buffer_length; n++) {
- int sum = -rounder, sum1;
- for (i = 1; i <= filter_length; i++)
- sum += filter_coeffs[i-1] * out[n-i];
-
- sum1 = ((-sum >> 12) + in[n]) >> shift;
- sum = av_clip_int16(sum1);
-
- if (stop_on_overflow && sum != sum1)
- return 1;
-
- out[n] = sum;
- }
-
- return 0;
-}
-
-void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs,
- const float* in, int buffer_length,
- int filter_length)
-{
- int i,n;
-
-#if 0 // Unoptimized code path for improved readability
- for (n = 0; n < buffer_length; n++) {
- out[n] = in[n];
- for (i = 1; i <= filter_length; i++)
- out[n] -= filter_coeffs[i-1] * out[n-i];
- }
-#else
- float out0, out1, out2, out3;
- float old_out0, old_out1, old_out2, old_out3;
- float a,b,c;
-
- a = filter_coeffs[0];
- b = filter_coeffs[1];
- c = filter_coeffs[2];
- b -= filter_coeffs[0] * filter_coeffs[0];
- c -= filter_coeffs[1] * filter_coeffs[0];
- c -= filter_coeffs[0] * b;
-
- av_assert2((filter_length&1)==0 && filter_length>=4);
-
- old_out0 = out[-4];
- old_out1 = out[-3];
- old_out2 = out[-2];
- old_out3 = out[-1];
- for (n = 0; n <= buffer_length - 4; n+=4) {
- float tmp0,tmp1,tmp2;
- float val;
-
- out0 = in[0];
- out1 = in[1];
- out2 = in[2];
- out3 = in[3];
-
- out0 -= filter_coeffs[2] * old_out1;
- out1 -= filter_coeffs[2] * old_out2;
- out2 -= filter_coeffs[2] * old_out3;
-
- out0 -= filter_coeffs[1] * old_out2;
- out1 -= filter_coeffs[1] * old_out3;
-
- out0 -= filter_coeffs[0] * old_out3;
-
- val = filter_coeffs[3];
-
- out0 -= val * old_out0;
- out1 -= val * old_out1;
- out2 -= val * old_out2;
- out3 -= val * old_out3;
-
- for (i = 5; i < filter_length; i += 2) {
- old_out3 = out[-i];
- val = filter_coeffs[i-1];
-
- out0 -= val * old_out3;
- out1 -= val * old_out0;
- out2 -= val * old_out1;
- out3 -= val * old_out2;
-
- old_out2 = out[-i-1];
-
- val = filter_coeffs[i];
-
- out0 -= val * old_out2;
- out1 -= val * old_out3;
- out2 -= val * old_out0;
- out3 -= val * old_out1;
-
- FFSWAP(float, old_out0, old_out2);
- old_out1 = old_out3;
- }
-
- tmp0 = out0;
- tmp1 = out1;
- tmp2 = out2;
-
- out3 -= a * tmp2;
- out2 -= a * tmp1;
- out1 -= a * tmp0;
-
- out3 -= b * tmp1;
- out2 -= b * tmp0;
-
- out3 -= c * tmp0;
-
-
- out[0] = out0;
- out[1] = out1;
- out[2] = out2;
- out[3] = out3;
-
- old_out0 = out0;
- old_out1 = out1;
- old_out2 = out2;
- old_out3 = out3;
-
- out += 4;
- in += 4;
- }
-
- out -= n;
- in -= n;
- for (; n < buffer_length; n++) {
- out[n] = in[n];
- for (i = 1; i <= filter_length; i++)
- out[n] -= filter_coeffs[i-1] * out[n-i];
- }
-#endif
-}
-
-void ff_celp_lp_zero_synthesis_filterf(float *out, const float *filter_coeffs,
- const float *in, int buffer_length,
- int filter_length)
-{
- int i,n;
-
- for (n = 0; n < buffer_length; n++) {
- out[n] = in[n];
- for (i = 1; i <= filter_length; i++)
- out[n] += filter_coeffs[i-1] * in[n-i];
- }
-}
-
-void ff_celp_filter_init(CELPFContext *c)
-{
- c->celp_lp_synthesis_filterf = ff_celp_lp_synthesis_filterf;
- c->celp_lp_zero_synthesis_filterf = ff_celp_lp_zero_synthesis_filterf;
-
- if(HAVE_MIPSFPU)
- ff_celp_filter_init_mips(c);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/celp_filters.h b/src/thirdparty/ffmpeg/libavcodec/celp_filters.h
deleted file mode 100644
index 54cb1e358..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/celp_filters.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * various filters for CELP-based codecs
- *
- * Copyright (c) 2008 Vladimir Voroshilov
- *
- * 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_CELP_FILTERS_H
-#define AVCODEC_CELP_FILTERS_H
-
-#include <stdint.h>
-
-typedef struct CELPFContext {
- /**
- * LP synthesis filter.
- * @param[out] out pointer to output buffer
- * - the array out[-filter_length, -1] must
- * contain the previous result of this filter
- * @param filter_coeffs filter coefficients.
- * @param in input signal
- * @param buffer_length amount of data to process
- * @param filter_length filter length (10 for 10th order LP filter). Must be
- * greater than 4 and even.
- *
- * @note Output buffer must contain filter_length samples of past
- * speech data before pointer.
- *
- * Routine applies 1/A(z) filter to given speech data.
- */
- void (*celp_lp_synthesis_filterf)(float *out, const float *filter_coeffs,
- const float *in, int buffer_length,
- int filter_length);
-
- /**
- * LP zero synthesis filter.
- * @param[out] out pointer to output buffer
- * @param filter_coeffs filter coefficients.
- * @param in input signal
- * - the array in[-filter_length, -1] must
- * contain the previous input of this filter
- * @param buffer_length amount of data to process (should be a multiple of eight)
- * @param filter_length filter length (10 for 10th order LP filter;
- * should be a multiple of two)
- *
- * @note Output buffer must contain filter_length samples of past
- * speech data before pointer.
- *
- * Routine applies A(z) filter to given speech data.
- */
- void (*celp_lp_zero_synthesis_filterf)(float *out, const float *filter_coeffs,
- const float *in, int buffer_length,
- int filter_length);
-
-}CELPFContext;
-
-/**
- * Initialize CELPFContext.
- */
-void ff_celp_filter_init(CELPFContext *c);
-void ff_celp_filter_init_mips(CELPFContext *c);
-
-/**
- * Circularly convolve fixed vector with a phase dispersion impulse
- * response filter (D.6.2 of G.729 and 6.1.5 of AMR).
- * @param fc_out vector with filter applied
- * @param fc_in source vector
- * @param filter phase filter coefficients
- *
- * fc_out[n] = sum(i,0,len-1){ fc_in[i] * filter[(len + n - i)%len] }
- *
- * @note fc_in and fc_out should not overlap!
- */
-void ff_celp_convolve_circ(int16_t *fc_out, const int16_t *fc_in,
- const int16_t *filter, int len);
-
-/**
- * Add an array to a rotated array.
- *
- * out[k] = in[k] + fac * lagged[k-lag] with wrap-around
- *
- * @param out result vector
- * @param in samples to be added unfiltered
- * @param lagged samples to be rotated, multiplied and added
- * @param lag lagged vector delay in the range [0, n]
- * @param fac scalefactor for lagged samples
- * @param n number of samples
- */
-void ff_celp_circ_addf(float *out, const float *in,
- const float *lagged, int lag, float fac, int n);
-
-/**
- * LP synthesis filter.
- * @param[out] out pointer to output buffer
- * @param filter_coeffs filter coefficients (-0x8000 <= (3.12) < 0x8000)
- * @param in input signal
- * @param buffer_length amount of data to process
- * @param filter_length filter length (10 for 10th order LP filter)
- * @param stop_on_overflow 1 - return immediately if overflow occurs
- * 0 - ignore overflows
- * @param shift the result is shifted right by this value
- * @param rounder the amount to add for rounding (usually 0x800 or 0xfff)
- *
- * @return 1 if overflow occurred, 0 - otherwise
- *
- * @note Output buffer must contain filter_length samples of past
- * speech data before pointer.
- *
- * Routine applies 1/A(z) filter to given speech data.
- */
-int ff_celp_lp_synthesis_filter(int16_t *out, const int16_t *filter_coeffs,
- const int16_t *in, int buffer_length,
- int filter_length, int stop_on_overflow,
- int shift, int rounder);
-
-/**
- * LP synthesis filter.
- * @param[out] out pointer to output buffer
- * - the array out[-filter_length, -1] must
- * contain the previous result of this filter
- * @param filter_coeffs filter coefficients.
- * @param in input signal
- * @param buffer_length amount of data to process
- * @param filter_length filter length (10 for 10th order LP filter). Must be
- * greater than 4 and even.
- *
- * @note Output buffer must contain filter_length samples of past
- * speech data before pointer.
- *
- * Routine applies 1/A(z) filter to given speech data.
- */
-void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs,
- const float *in, int buffer_length,
- int filter_length);
-
-/**
- * LP zero synthesis filter.
- * @param[out] out pointer to output buffer
- * @param filter_coeffs filter coefficients.
- * @param in input signal
- * - the array in[-filter_length, -1] must
- * contain the previous input of this filter
- * @param buffer_length amount of data to process
- * @param filter_length filter length (10 for 10th order LP filter)
- *
- * @note Output buffer must contain filter_length samples of past
- * speech data before pointer.
- *
- * Routine applies A(z) filter to given speech data.
- */
-void ff_celp_lp_zero_synthesis_filterf(float *out, const float *filter_coeffs,
- const float *in, int buffer_length,
- int filter_length);
-
-#endif /* AVCODEC_CELP_FILTERS_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/celp_math.c b/src/thirdparty/ffmpeg/libavcodec/celp_math.c
deleted file mode 100644
index b3bf92f34..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/celp_math.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Various fixed-point math operations
- *
- * Copyright (c) 2008 Vladimir Voroshilov
- *
- * 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 <inttypes.h>
-#include <limits.h>
-
-#include "libavutil/avassert.h"
-#include "avcodec.h"
-#include "mathops.h"
-#include "celp_math.h"
-#include "libavutil/common.h"
-
-static const uint16_t exp2a[]=
-{
- 0, 1435, 2901, 4400, 5931, 7496, 9096, 10730,
- 12400, 14106, 15850, 17632, 19454, 21315, 23216, 25160,
- 27146, 29175, 31249, 33368, 35534, 37747, 40009, 42320,
- 44682, 47095, 49562, 52082, 54657, 57289, 59979, 62727,
-};
-
-static const uint16_t exp2b[]=
-{
- 3, 712, 1424, 2134, 2845, 3557, 4270, 4982,
- 5696, 6409, 7124, 7839, 8554, 9270, 9986, 10704,
- 11421, 12138, 12857, 13576, 14295, 15014, 15734, 16455,
- 17176, 17898, 18620, 19343, 20066, 20790, 21514, 22238,
-};
-
-int ff_exp2(uint16_t power)
-{
- unsigned int result= exp2a[power>>10] + 0x10000;
-
- av_assert2(power <= 0x7fff);
-
- result= (result<<3) + ((result*exp2b[(power>>5)&31])>>17);
- return result + ((result*(power&31)*89)>>22);
-}
-
-/**
- * Table used to compute log2(x)
- *
- * tab_log2[i] = (1<<15) * log2(1 + i/32), i=0..32
- */
-static const uint16_t tab_log2[33] =
-{
-#ifdef G729_BITEXACT
- 0, 1455, 2866, 4236, 5568, 6863, 8124, 9352,
- 10549, 11716, 12855, 13967, 15054, 16117, 17156, 18172,
- 19167, 20142, 21097, 22033, 22951, 23852, 24735, 25603,
- 26455, 27291, 28113, 28922, 29716, 30497, 31266, 32023, 32767,
-#else
- 4, 1459, 2870, 4240, 5572, 6867, 8127, 9355,
- 10552, 11719, 12858, 13971, 15057, 16120, 17158, 18175,
- 19170, 20145, 21100, 22036, 22954, 23854, 24738, 25605,
- 26457, 27294, 28116, 28924, 29719, 30500, 31269, 32025, 32769,
-#endif
-};
-
-int ff_log2_q15(uint32_t value)
-{
- uint8_t power_int;
- uint8_t frac_x0;
- uint16_t frac_dx;
-
- // Stripping zeros from beginning
- power_int = av_log2(value);
- value <<= (31 - power_int);
-
- // b31 is always non-zero now
- frac_x0 = (value & 0x7c000000) >> 26; // b26-b31 and [32..63] -> [0..31]
- frac_dx = (value & 0x03fff800) >> 11;
-
- value = tab_log2[frac_x0];
- value += (frac_dx * (tab_log2[frac_x0+1] - tab_log2[frac_x0])) >> 15;
-
- return (power_int << 15) + value;
-}
-
-int64_t ff_dot_product(const int16_t *a, const int16_t *b, int length)
-{
- int i;
- int64_t sum = 0;
-
- for (i = 0; i < length; i++)
- sum += MUL16(a[i], b[i]);
-
- return sum;
-}
-
-float ff_dot_productf(const float* a, const float* b, int length)
-{
- float sum = 0;
- int i;
-
- for(i=0; i<length; i++)
- sum += a[i] * b[i];
-
- return sum;
-}
-
-void ff_celp_math_init(CELPMContext *c)
-{
- c->dot_productf = ff_dot_productf;
-
- if(HAVE_MIPSFPU)
- ff_celp_math_init_mips(c);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/celp_math.h b/src/thirdparty/ffmpeg/libavcodec/celp_math.h
deleted file mode 100644
index c682068a4..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/celp_math.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Various fixed-point math operations
- *
- * Copyright (c) 2008 Vladimir Voroshilov
- *
- * 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_CELP_MATH_H
-#define AVCODEC_CELP_MATH_H
-
-#include <stdint.h>
-
-typedef struct CELPMContext {
- /**
- * Return the dot product.
- * @param a input data array
- * @param b input data array
- * @param length number of elements
- *
- * @return dot product = sum of elementwise products
- */
- float (*dot_productf)(const float* a, const float* b, int length);
-
-}CELPMContext;
-
-/**
- * Initialize CELPMContext.
- */
-void ff_celp_math_init(CELPMContext *c);
-void ff_celp_math_init_mips(CELPMContext *c);
-
-/**
- * fixed-point implementation of exp2(x) in [0; 1] domain.
- * @param power argument to exp2, 0 <= power <= 0x7fff
- *
- * @return value of (1<<20) * exp2(power / (1<<15))
- * 0x8000c <= result <= 0xfffea
- */
-int ff_exp2(uint16_t power);
-
-/**
- * Calculate log2(x).
- * @param value function argument, 0 < value <= 7fff ffff
- *
- * @return value of (1<<15) * log2(value)
- */
-int ff_log2_q15(uint32_t value);
-
-/**
- * Shift value left or right depending on sign of offset parameter.
- * @param value value to shift
- * @param offset shift offset
- *
- * @return value << offset, if offset>=0; value >> -offset - otherwise
- */
-static inline int bidir_sal(int value, int offset)
-{
- if(offset < 0) return value >> -offset;
- else return value << offset;
-}
-
-/**
- * returns the dot product of 2 int16_t vectors.
- * @param a input data array
- * @param b input data array
- * @param length number of elements
- *
- * @return dot product = sum of elementwise products
- */
-int64_t ff_dot_product(const int16_t *a, const int16_t *b, int length);
-
-/**
- * Return the dot product.
- * @param a input data array
- * @param b input data array
- * @param length number of elements
- *
- * @return dot product = sum of elementwise products
- */
-float ff_dot_productf(const float* a, const float* b, int length);
-
-#endif /* AVCODEC_CELP_MATH_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/codec_desc.c b/src/thirdparty/ffmpeg/libavcodec/codec_desc.c
deleted file mode 100644
index 0806b5b1c..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/codec_desc.c
+++ /dev/null
@@ -1,2553 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * This table was generated from the long and short names of AVCodecs
- * please see the respective codec sources for authorship
- *
- * 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 <string.h>
-
-#include "avcodec.h"
-
-#include "libavutil/common.h"
-#include "libavutil/internal.h"
-
-static const AVCodecDescriptor codec_descriptors[] = {
- /* video codecs */
- {
- .id = AV_CODEC_ID_MPEG1VIDEO,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "mpeg1video",
- .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 video"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_MPEG2VIDEO,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "mpeg2video",
- .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 video"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_MPEG2VIDEO_XVMC,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "mpegvideo_xvmc",
- .long_name = NULL_IF_CONFIG_SMALL("MPEG-1/2 video XvMC (X-Video Motion Compensation)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_H261,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "h261",
- .long_name = NULL_IF_CONFIG_SMALL("H.261"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_H263,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "h263",
- .long_name = NULL_IF_CONFIG_SMALL("H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_RV10,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "rv10",
- .long_name = NULL_IF_CONFIG_SMALL("RealVideo 1.0"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_RV20,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "rv20",
- .long_name = NULL_IF_CONFIG_SMALL("RealVideo 1.0"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_MJPEG,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "mjpeg",
- .long_name = NULL_IF_CONFIG_SMALL("Motion JPEG"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_MJPEGB,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "mjpegb",
- .long_name = NULL_IF_CONFIG_SMALL("Apple MJPEG-B"),
- .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",
- .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_RAWVIDEO,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "rawvideo",
- .long_name = NULL_IF_CONFIG_SMALL("raw video"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_MSMPEG4V1,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "msmpeg4v1",
- .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 1"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_MSMPEG4V2,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "msmpeg4v2",
- .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 2"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_MSMPEG4V3,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "msmpeg4v3",
- .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 3"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_WMV1,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "wmv1",
- .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 7"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_WMV2,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "wmv2",
- .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 8"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_H263P,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "h263p",
- .long_name = NULL_IF_CONFIG_SMALL("H.263+ / H.263-1998 / H.263 version 2"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_H263I,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "h263i",
- .long_name = NULL_IF_CONFIG_SMALL("Intel H.263"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_FLV1,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "flv1",
- .long_name = NULL_IF_CONFIG_SMALL("FLV / Sorenson Spark / Sorenson H.263 (Flash Video)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_SVQ1,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "svq1",
- .long_name = NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_SVQ3,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "svq3",
- .long_name = NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 3 / Sorenson Video 3 / SVQ3"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_DVVIDEO,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "dvvideo",
- .long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_HUFFYUV,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "huffyuv",
- .long_name = NULL_IF_CONFIG_SMALL("HuffYUV"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_CYUV,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "cyuv",
- .long_name = NULL_IF_CONFIG_SMALL("Creative YUV (CYUV)"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_H264,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "h264",
- .long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
- .props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_INDEO3,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "indeo3",
- .long_name = NULL_IF_CONFIG_SMALL("Intel Indeo 3"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_VP3,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "vp3",
- .long_name = NULL_IF_CONFIG_SMALL("On2 VP3"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_THEORA,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "theora",
- .long_name = NULL_IF_CONFIG_SMALL("Theora"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ASV1,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "asv1",
- .long_name = NULL_IF_CONFIG_SMALL("ASUS V1"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ASV2,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "asv2",
- .long_name = NULL_IF_CONFIG_SMALL("ASUS V2"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_FFV1,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "ffv1",
- .long_name = NULL_IF_CONFIG_SMALL("FFmpeg video codec #1"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_4XM,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "4xm",
- .long_name = NULL_IF_CONFIG_SMALL("4X Movie"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_VCR1,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "vcr1",
- .long_name = NULL_IF_CONFIG_SMALL("ATI VCR1"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_CLJR,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "cljr",
- .long_name = NULL_IF_CONFIG_SMALL("Cirrus Logic AccuPak"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_MDEC,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "mdec",
- .long_name = NULL_IF_CONFIG_SMALL("Sony PlayStation MDEC (Motion DECoder)"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ROQ,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "roq",
- .long_name = NULL_IF_CONFIG_SMALL("id RoQ video"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_INTERPLAY_VIDEO,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "interplayvideo",
- .long_name = NULL_IF_CONFIG_SMALL("Interplay MVE video"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_XAN_WC3,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "xan_wc3",
- .long_name = NULL_IF_CONFIG_SMALL("Wing Commander III / Xan"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_XAN_WC4,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "xan_wc4",
- .long_name = NULL_IF_CONFIG_SMALL("Wing Commander IV / Xxan"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_RPZA,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "rpza",
- .long_name = NULL_IF_CONFIG_SMALL("QuickTime video (RPZA)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_CINEPAK,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "cinepak",
- .long_name = NULL_IF_CONFIG_SMALL("Cinepak"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_WS_VQA,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "ws_vqa",
- .long_name = NULL_IF_CONFIG_SMALL("Westwood Studios VQA (Vector Quantized Animation) video"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_MSRLE,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "msrle",
- .long_name = NULL_IF_CONFIG_SMALL("Microsoft RLE"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_MSVIDEO1,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "msvideo1",
- .long_name = NULL_IF_CONFIG_SMALL("Microsoft Video 1"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_IDCIN,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "idcin",
- .long_name = NULL_IF_CONFIG_SMALL("id Quake II CIN video"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_8BPS,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "8bps",
- .long_name = NULL_IF_CONFIG_SMALL("QuickTime 8BPS video"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_SMC,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "smc",
- .long_name = NULL_IF_CONFIG_SMALL("QuickTime Graphics (SMC)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_FLIC,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "flic",
- .long_name = NULL_IF_CONFIG_SMALL("Autodesk Animator Flic video"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_TRUEMOTION1,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "truemotion1",
- .long_name = NULL_IF_CONFIG_SMALL("Duck TrueMotion 1.0"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_VMDVIDEO,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "vmdvideo",
- .long_name = NULL_IF_CONFIG_SMALL("Sierra VMD video"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_MSZH,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "mszh",
- .long_name = NULL_IF_CONFIG_SMALL("LCL (LossLess Codec Library) MSZH"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_ZLIB,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "zlib",
- .long_name = NULL_IF_CONFIG_SMALL("LCL (LossLess Codec Library) ZLIB"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_QTRLE,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "qtrle",
- .long_name = NULL_IF_CONFIG_SMALL("QuickTime Animation (RLE) video"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_SNOW,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "snow",
- .long_name = NULL_IF_CONFIG_SMALL("Snow"),
- .props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_TSCC,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "tscc",
- .long_name = NULL_IF_CONFIG_SMALL("TechSmith Screen Capture Codec"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_ULTI,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "ulti",
- .long_name = NULL_IF_CONFIG_SMALL("IBM UltiMotion"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_QDRAW,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "qdraw",
- .long_name = NULL_IF_CONFIG_SMALL("Apple QuickDraw"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_VIXL,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "vixl",
- .long_name = NULL_IF_CONFIG_SMALL("Miro VideoXL"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_QPEG,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "qpeg",
- .long_name = NULL_IF_CONFIG_SMALL("Q-team QPEG"),
- .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",
- .long_name = NULL_IF_CONFIG_SMALL("Huffyuv FFmpeg variant"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_RV30,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "rv30",
- .long_name = NULL_IF_CONFIG_SMALL("RealVideo 3.0"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_RV40,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "rv40",
- .long_name = NULL_IF_CONFIG_SMALL("RealVideo 4.0"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_VC1,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "vc1",
- .long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_WMV3,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "wmv3",
- .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_LOCO,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "loco",
- .long_name = NULL_IF_CONFIG_SMALL("LOCO"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_WNV1,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "wnv1",
- .long_name = NULL_IF_CONFIG_SMALL("Winnov WNV1"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_AASC,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "aasc",
- .long_name = NULL_IF_CONFIG_SMALL("Autodesk RLE"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_INDEO2,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "indeo2",
- .long_name = NULL_IF_CONFIG_SMALL("Intel Indeo 2"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_FRAPS,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "fraps",
- .long_name = NULL_IF_CONFIG_SMALL("Fraps"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_TRUEMOTION2,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "truemotion2",
- .long_name = NULL_IF_CONFIG_SMALL("Duck TrueMotion 2.0"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_BMP,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "bmp",
- .long_name = NULL_IF_CONFIG_SMALL("BMP (Windows and OS/2 bitmap)"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_CSCD,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "cscd",
- .long_name = NULL_IF_CONFIG_SMALL("CamStudio"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_MMVIDEO,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "mmvideo",
- .long_name = NULL_IF_CONFIG_SMALL("American Laser Games MM Video"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ZMBV,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "zmbv",
- .long_name = NULL_IF_CONFIG_SMALL("Zip Motion Blocks Video"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_AVS,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "avs",
- .long_name = NULL_IF_CONFIG_SMALL("AVS (Audio Video Standard) video"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_SMACKVIDEO,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "smackvideo",
- .long_name = NULL_IF_CONFIG_SMALL("Smacker video"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_NUV,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "nuv",
- .long_name = NULL_IF_CONFIG_SMALL("NuppelVideo/RTJPEG"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_KMVC,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "kmvc",
- .long_name = NULL_IF_CONFIG_SMALL("Karl Morton's video codec"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_FLASHSV,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "flashsv",
- .long_name = NULL_IF_CONFIG_SMALL("Flash Screen Video v1"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_CAVS,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "cavs",
- .long_name = NULL_IF_CONFIG_SMALL("Chinese AVS (Audio Video Standard) (AVS1-P2, JiZhun profile)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_JPEG2000,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "jpeg2000",
- .long_name = NULL_IF_CONFIG_SMALL("JPEG 2000"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY |
- AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_VMNC,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "vmnc",
- .long_name = NULL_IF_CONFIG_SMALL("VMware Screen Codec / VMware Video"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_VP5,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "vp5",
- .long_name = NULL_IF_CONFIG_SMALL("On2 VP5"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_VP6,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "vp6",
- .long_name = NULL_IF_CONFIG_SMALL("On2 VP6"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_VP6F,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "vp6f",
- .long_name = NULL_IF_CONFIG_SMALL("On2 VP6 (Flash version)"),
- .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",
- .long_name = NULL_IF_CONFIG_SMALL("Delphine Software International CIN video"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_TIERTEXSEQVIDEO,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "tiertexseqvideo",
- .long_name = NULL_IF_CONFIG_SMALL("Tiertex Limited SEQ video"),
- .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",
- .long_name = NULL_IF_CONFIG_SMALL("Feeble Files/ScummVM DXA"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_DNXHD,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "dnxhd",
- .long_name = NULL_IF_CONFIG_SMALL("VC3/DNxHD"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_THP,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "thp",
- .long_name = NULL_IF_CONFIG_SMALL("Nintendo Gamecube THP video"),
- .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_LOSSY,
- },
- {
- .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",
- .long_name = NULL_IF_CONFIG_SMALL("Interplay C93"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_BETHSOFTVID,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "bethsoftvid",
- .long_name = NULL_IF_CONFIG_SMALL("Bethesda VID video"),
- .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",
- .long_name = NULL_IF_CONFIG_SMALL("On2 VP6 (Flash version, with alpha channel)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_AMV,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "amv",
- .long_name = NULL_IF_CONFIG_SMALL("AMV Video"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_VB,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "vb",
- .long_name = NULL_IF_CONFIG_SMALL("Beam Software VB"),
- .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",
- .long_name = NULL_IF_CONFIG_SMALL("Intel Indeo Video Interactive 4"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_INDEO5,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "indeo5",
- .long_name = NULL_IF_CONFIG_SMALL("Intel Indeo Video Interactive 5"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_MIMIC,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "mimic",
- .long_name = NULL_IF_CONFIG_SMALL("Mimic"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_RL2,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "rl2",
- .long_name = NULL_IF_CONFIG_SMALL("RL2 video"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ESCAPE124,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "escape124",
- .long_name = NULL_IF_CONFIG_SMALL("Escape 124"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_DIRAC,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "dirac",
- .long_name = NULL_IF_CONFIG_SMALL("Dirac"),
- .props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_BFI,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "bfi",
- .long_name = NULL_IF_CONFIG_SMALL("Brute Force & Ignorance"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_CMV,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "cmv",
- .long_name = NULL_IF_CONFIG_SMALL("Electronic Arts CMV video"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_MOTIONPIXELS,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "motionpixels",
- .long_name = NULL_IF_CONFIG_SMALL("Motion Pixels video"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_TGV,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "tgv",
- .long_name = NULL_IF_CONFIG_SMALL("Electronic Arts TGV video"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_TGQ,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "tgq",
- .long_name = NULL_IF_CONFIG_SMALL("Electronic Arts TGQ video"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_TQI,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "tqi",
- .long_name = NULL_IF_CONFIG_SMALL("Electronic Arts TQI video"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_AURA,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "aura",
- .long_name = NULL_IF_CONFIG_SMALL("Auravision AURA"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_AURA2,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "aura2",
- .long_name = NULL_IF_CONFIG_SMALL("Auravision Aura 2"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_V210X,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "v210x",
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_TMV,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "tmv",
- .long_name = NULL_IF_CONFIG_SMALL("8088flex TMV"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_V210,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "v210",
- .long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:2:2 10-bit"),
- .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 image"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_MAD,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "mad",
- .long_name = NULL_IF_CONFIG_SMALL("Electronic Arts Madcow Video"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_FRWU,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "frwu",
- .long_name = NULL_IF_CONFIG_SMALL("Forward Uncompressed"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_FLASHSV2,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "flashsv2",
- .long_name = NULL_IF_CONFIG_SMALL("Flash Screen Video v2"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_CDGRAPHICS,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "cdgraphics",
- .long_name = NULL_IF_CONFIG_SMALL("CD Graphics video"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_R210,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "r210",
- .long_name = NULL_IF_CONFIG_SMALL("Uncompressed RGB 10-bit"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_ANM,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "anm",
- .long_name = NULL_IF_CONFIG_SMALL("Deluxe Paint Animation"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_BINKVIDEO,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "binkvideo",
- .long_name = NULL_IF_CONFIG_SMALL("Bink video"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_IFF_ILBM,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "iff_ilbm",
- .long_name = NULL_IF_CONFIG_SMALL("IFF ILBM"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_IFF_BYTERUN1,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "iff_byterun1",
- .long_name = NULL_IF_CONFIG_SMALL("IFF ByteRun1"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_KGV1,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "kgv1",
- .long_name = NULL_IF_CONFIG_SMALL("Kega Game Video"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_YOP,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "yop",
- .long_name = NULL_IF_CONFIG_SMALL("Psygnosis YOP Video"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_VP8,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "vp8",
- .long_name = NULL_IF_CONFIG_SMALL("On2 VP8"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_VP9,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "vp9",
- .long_name = NULL_IF_CONFIG_SMALL("Google VP9"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_PICTOR,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "pictor",
- .long_name = NULL_IF_CONFIG_SMALL("Pictor/PC Paint"),
- .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",
- .long_name = NULL_IF_CONFIG_SMALL("Multicolor charset for Commodore 64"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_A64_MULTI5,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "a64_multi5",
- .long_name = NULL_IF_CONFIG_SMALL("Multicolor charset for Commodore 64, extended with 5th color (colram)"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_R10K,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "r10k",
- .long_name = NULL_IF_CONFIG_SMALL("AJA Kona 10-bit RGB Codec"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_MVC1,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "mvc1",
- .long_name = NULL_IF_CONFIG_SMALL("Silicon Graphics Motion Video Compressor 1"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_MVC2,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "mvc2",
- .long_name = NULL_IF_CONFIG_SMALL("Silicon Graphics Motion Video Compressor 2"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_MXPEG,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "mxpeg",
- .long_name = NULL_IF_CONFIG_SMALL("Mobotix MxPEG video"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_LAGARITH,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "lagarith",
- .long_name = NULL_IF_CONFIG_SMALL("Lagarith lossless"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PRORES,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "prores",
- .long_name = NULL_IF_CONFIG_SMALL("Apple ProRes (iCodec Pro)"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_JV,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "jv",
- .long_name = NULL_IF_CONFIG_SMALL("Bitmap Brothers JV video"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_DFA,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "dfa",
- .long_name = NULL_IF_CONFIG_SMALL("Chronomaster DFA"),
- .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",
- .long_name = NULL_IF_CONFIG_SMALL("Ut Video"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_BMV_VIDEO,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "bmv_video",
- .long_name = NULL_IF_CONFIG_SMALL("Discworld II BMV video"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_VBLE,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "vble",
- .long_name = NULL_IF_CONFIG_SMALL("VBLE Lossless Codec"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_DXTORY,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "dxtory",
- .long_name = NULL_IF_CONFIG_SMALL("Dxtory"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_V410,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "v410",
- .long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:4:4 10-bit"),
- .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",
- .long_name = NULL_IF_CONFIG_SMALL("Commodore CDXL video"),
- .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",
- .long_name = NULL_IF_CONFIG_SMALL("ZeroCodec Lossless Video"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_MSS1,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "mss1",
- .long_name = NULL_IF_CONFIG_SMALL("MS Screen 1"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_MSA1,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "msa1",
- .long_name = NULL_IF_CONFIG_SMALL("MS ATC Screen"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_TSCC2,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "tscc2",
- .long_name = NULL_IF_CONFIG_SMALL("TechSmith Screen Codec 2"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_MTS2,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "mts2",
- .long_name = NULL_IF_CONFIG_SMALL("MS Expression Encoder Screen"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_CLLC,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "cllc",
- .long_name = NULL_IF_CONFIG_SMALL("Canopus Lossless Codec"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_MSS2,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "mss2",
- .long_name = NULL_IF_CONFIG_SMALL("MS Windows Media Video V9 Screen"),
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_Y41P,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "y41p",
- .long_name = NULL_IF_CONFIG_SMALL("Uncompressed YUV 4:1:1 12-bit"),
- .props = AV_CODEC_PROP_INTRA_ONLY,
- },
- {
- .id = AV_CODEC_ID_ESCAPE130,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "escape130",
- .long_name = NULL_IF_CONFIG_SMALL("Escape 130"),
- .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",
- .long_name = NULL_IF_CONFIG_SMALL("Avid 1:1 10-bit RGB Packer"),
- .props = AV_CODEC_PROP_INTRA_ONLY,
- },
- {
- .id = AV_CODEC_ID_012V,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "012v",
- .long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:2:2 10-bit"),
- .props = AV_CODEC_PROP_INTRA_ONLY,
- },
- {
- .id = AV_CODEC_ID_G2M,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "g2m",
- .long_name = NULL_IF_CONFIG_SMALL("GoToMeeting"),
- },
- {
- .id = AV_CODEC_ID_AVUI,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "avui",
- .long_name = NULL_IF_CONFIG_SMALL("Avid Meridien Uncompressed"),
- .props = AV_CODEC_PROP_INTRA_ONLY,
- },
- {
- .id = AV_CODEC_ID_AYUV,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "ayuv",
- .long_name = NULL_IF_CONFIG_SMALL("Uncompressed packed MS 4:4:4:4"),
- .props = AV_CODEC_PROP_INTRA_ONLY,
- },
- {
- .id = AV_CODEC_ID_TARGA_Y216,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "targa_y216",
- .long_name = NULL_IF_CONFIG_SMALL("Pinnacle TARGA CineWave YUV16"),
- .props = AV_CODEC_PROP_INTRA_ONLY,
- },
- {
- .id = AV_CODEC_ID_V308,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "v308",
- .long_name = NULL_IF_CONFIG_SMALL("Uncompressed packed 4:4:4"),
- .props = AV_CODEC_PROP_INTRA_ONLY,
- },
- {
- .id = AV_CODEC_ID_V408,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "v408",
- .long_name = NULL_IF_CONFIG_SMALL("Uncompressed packed QT 4:4:4:4"),
- .props = AV_CODEC_PROP_INTRA_ONLY,
- },
- {
- .id = AV_CODEC_ID_YUV4,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "yuv4",
- .long_name = NULL_IF_CONFIG_SMALL("Uncompressed packed 4:2:0"),
- .props = AV_CODEC_PROP_INTRA_ONLY,
- },
- {
- .id = AV_CODEC_ID_SANM,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "sanm",
- .long_name = NULL_IF_CONFIG_SMALL("LucasArts SMUSH video"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_PAF_VIDEO,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "paf_video",
- .long_name = NULL_IF_CONFIG_SMALL("Amazing Studio Packed Animation File Video"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_AVRN,
- .type = AVMEDIA_TYPE_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"),
- },
- {
- .id = AV_CODEC_ID_BRENDER_PIX,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "brender_pix",
- .long_name = NULL_IF_CONFIG_SMALL("BRender PIX image"),
- },
-
- /* various PCM "codecs" */
- {
- .id = AV_CODEC_ID_PCM_S16LE,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_s16le",
- .long_name = NULL_IF_CONFIG_SMALL("PCM signed 16-bit little-endian"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PCM_S16BE,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_s16be",
- .long_name = NULL_IF_CONFIG_SMALL("PCM signed 16-bit big-endian"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PCM_U16LE,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_u16le",
- .long_name = NULL_IF_CONFIG_SMALL("PCM unsigned 16-bit little-endian"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PCM_U16BE,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_u16be",
- .long_name = NULL_IF_CONFIG_SMALL("PCM unsigned 16-bit big-endian"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PCM_S8,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_s8",
- .long_name = NULL_IF_CONFIG_SMALL("PCM signed 8-bit"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PCM_U8,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_u8",
- .long_name = NULL_IF_CONFIG_SMALL("PCM unsigned 8-bit"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PCM_MULAW,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_mulaw",
- .long_name = NULL_IF_CONFIG_SMALL("PCM mu-law / G.711 mu-law"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_PCM_ALAW,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_alaw",
- .long_name = NULL_IF_CONFIG_SMALL("PCM A-law / G.711 A-law"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_PCM_S32LE,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_s32le",
- .long_name = NULL_IF_CONFIG_SMALL("PCM signed 32-bit little-endian"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PCM_S32BE,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_s32be",
- .long_name = NULL_IF_CONFIG_SMALL("PCM signed 32-bit big-endian"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PCM_U32LE,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_u32le",
- .long_name = NULL_IF_CONFIG_SMALL("PCM unsigned 32-bit little-endian"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PCM_U32BE,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_u32be",
- .long_name = NULL_IF_CONFIG_SMALL("PCM unsigned 32-bit big-endian"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PCM_S24LE,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_s24le",
- .long_name = NULL_IF_CONFIG_SMALL("PCM signed 24-bit little-endian"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PCM_S24BE,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_s24be",
- .long_name = NULL_IF_CONFIG_SMALL("PCM signed 24-bit big-endian"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PCM_U24LE,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_u24le",
- .long_name = NULL_IF_CONFIG_SMALL("PCM unsigned 24-bit little-endian"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PCM_U24BE,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_u24be",
- .long_name = NULL_IF_CONFIG_SMALL("PCM unsigned 24-bit big-endian"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PCM_S24DAUD,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_s24daud",
- .long_name = NULL_IF_CONFIG_SMALL("PCM D-Cinema audio signed 24-bit"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PCM_ZORK,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_zork",
- .long_name = NULL_IF_CONFIG_SMALL("PCM Zork"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_PCM_S16BE_PLANAR,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_s16be_planar",
- .long_name = NULL_IF_CONFIG_SMALL("PCM signed 16-bit big-endian planar"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PCM_S16LE_PLANAR,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_s16le_planar",
- .long_name = NULL_IF_CONFIG_SMALL("PCM signed 16-bit little-endian planar"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PCM_S24LE_PLANAR,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_s24le_planar",
- .long_name = NULL_IF_CONFIG_SMALL("PCM signed 24-bit little-endian planar"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PCM_S32LE_PLANAR,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_s32le_planar",
- .long_name = NULL_IF_CONFIG_SMALL("PCM signed 32-bit little-endian planar"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PCM_DVD,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_dvd",
- .long_name = NULL_IF_CONFIG_SMALL("PCM signed 20|24-bit big-endian"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PCM_F32BE,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_f32be",
- .long_name = NULL_IF_CONFIG_SMALL("PCM 32-bit floating point big-endian"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PCM_F32LE,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_f32le",
- .long_name = NULL_IF_CONFIG_SMALL("PCM 32-bit floating point little-endian"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PCM_F64BE,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_f64be",
- .long_name = NULL_IF_CONFIG_SMALL("PCM 64-bit floating point big-endian"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PCM_F64LE,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_f64le",
- .long_name = NULL_IF_CONFIG_SMALL("PCM 64-bit floating point little-endian"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PCM_BLURAY,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_bluray",
- .long_name = NULL_IF_CONFIG_SMALL("PCM signed 16|20|24-bit big-endian for Blu-ray media"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_PCM_LXF,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_lxf",
- .long_name = NULL_IF_CONFIG_SMALL("PCM signed 20-bit little-endian planar"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_S302M,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "s302m",
- .long_name = NULL_IF_CONFIG_SMALL("SMPTE 302M"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_PCM_S8_PLANAR,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "pcm_s8_planar",
- .long_name = NULL_IF_CONFIG_SMALL("PCM signed 8-bit planar"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
-
- /* various ADPCM codecs */
- {
- .id = AV_CODEC_ID_ADPCM_IMA_QT,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_ima_qt",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM IMA QuickTime"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_IMA_WAV,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_ima_wav",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM IMA WAV"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_IMA_DK3,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_ima_dk3",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM IMA Duck DK3"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_IMA_DK4,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_ima_dk4",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM IMA Duck DK4"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_IMA_WS,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_ima_ws",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM IMA Westwood"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_IMA_SMJPEG,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_ima_smjpeg",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM IMA Loki SDL MJPEG"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_MS,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_ms",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM Microsoft"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_4XM,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_4xm",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM 4X Movie"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_XA,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_xa",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM CDROM XA"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_ADX,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_adx",
- .long_name = NULL_IF_CONFIG_SMALL("SEGA CRI ADX ADPCM"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_EA,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_ea",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM Electronic Arts"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_G726,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_g726",
- .long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_CT,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_ct",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM Creative Technology"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_SWF,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_swf",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM Shockwave Flash"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_YAMAHA,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_yamaha",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM Yamaha"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_SBPRO_4,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_sbpro_4",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM Sound Blaster Pro 4-bit"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_SBPRO_3,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_sbpro_3",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM Sound Blaster Pro 2.6-bit"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_SBPRO_2,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_sbpro_2",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM Sound Blaster Pro 2-bit"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_THP,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_thp",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM Nintendo Gamecube THP"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_IMA_AMV,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_ima_amv",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM IMA AMV"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_EA_R1,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_ea_r1",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM Electronic Arts R1"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_EA_R3,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_ea_r3",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM Electronic Arts R3"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_EA_R2,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_ea_r2",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM Electronic Arts R2"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_IMA_EA_SEAD,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_ima_ea_sead",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM IMA Electronic Arts SEAD"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_IMA_EA_EACS,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_ima_ea_eacs",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM IMA Electronic Arts EACS"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_EA_XAS,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_ea_xas",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM Electronic Arts XAS"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_EA_MAXIS_XA,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_ea_maxis_xa",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM Electronic Arts Maxis CDROM XA"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_IMA_ISS,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_ima_iss",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM IMA Funcom ISS"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_G722,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_g722",
- .long_name = NULL_IF_CONFIG_SMALL("G.722 ADPCM"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_IMA_APC,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_ima_apc",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM IMA CRYO APC"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_AFC,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_afc",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM Nintendo Gamecube AFC"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ADPCM_IMA_OKI,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "adpcm_ima_oki",
- .long_name = NULL_IF_CONFIG_SMALL("ADPCM IMA Dialogic OKI"),
- .props = AV_CODEC_PROP_LOSSY,
- },
-
- /* AMR */
- {
- .id = AV_CODEC_ID_AMR_NB,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "amr_nb",
- .long_name = NULL_IF_CONFIG_SMALL("AMR-NB (Adaptive Multi-Rate NarrowBand)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_AMR_WB,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "amr_wb",
- .long_name = NULL_IF_CONFIG_SMALL("AMR-WB (Adaptive Multi-Rate WideBand)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
-
- /* RealAudio codecs*/
- {
- .id = AV_CODEC_ID_RA_144,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "ra_144",
- .long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_RA_288,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "ra_288",
- .long_name = NULL_IF_CONFIG_SMALL("RealAudio 2.0 (28.8K)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
-
- /* various DPCM codecs */
- {
- .id = AV_CODEC_ID_ROQ_DPCM,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "roq_dpcm",
- .long_name = NULL_IF_CONFIG_SMALL("DPCM id RoQ"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_INTERPLAY_DPCM,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "interplay_dpcm",
- .long_name = NULL_IF_CONFIG_SMALL("DPCM Interplay"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_XAN_DPCM,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "xan_dpcm",
- .long_name = NULL_IF_CONFIG_SMALL("DPCM Xan"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_SOL_DPCM,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "sol_dpcm",
- .long_name = NULL_IF_CONFIG_SMALL("DPCM Sol"),
- .props = AV_CODEC_PROP_LOSSY,
- },
-
- /* audio codecs */
- {
- .id = AV_CODEC_ID_MP2,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "mp2",
- .long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_MP3,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "mp3",
- .long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_AAC,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "aac",
- .long_name = NULL_IF_CONFIG_SMALL("AAC (Advanced Audio Coding)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_AC3,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "ac3",
- .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_DTS,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "dts",
- .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"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_DVAUDIO,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "dvaudio",
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_WMAV1,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "wmav1",
- .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 1"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_WMAV2,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "wmav2",
- .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 2"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_MACE3,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "mace3",
- .long_name = NULL_IF_CONFIG_SMALL("MACE (Macintosh Audio Compression/Expansion) 3:1"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_MACE6,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "mace6",
- .long_name = NULL_IF_CONFIG_SMALL("MACE (Macintosh Audio Compression/Expansion) 6:1"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_VMDAUDIO,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "vmdaudio",
- .long_name = NULL_IF_CONFIG_SMALL("Sierra VMD audio"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_FLAC,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "flac",
- .long_name = NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_MP3ADU,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "mp3adu",
- .long_name = NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_MP3ON4,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "mp3on4",
- .long_name = NULL_IF_CONFIG_SMALL("MP3onMP4"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_SHORTEN,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "shorten",
- .long_name = NULL_IF_CONFIG_SMALL("Shorten"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_ALAC,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "alac",
- .long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_WESTWOOD_SND1,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "westwood_snd1",
- .long_name = NULL_IF_CONFIG_SMALL("Westwood Audio (SND1)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_GSM,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "gsm",
- .long_name = NULL_IF_CONFIG_SMALL("GSM"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_QDM2,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "qdm2",
- .long_name = NULL_IF_CONFIG_SMALL("QDesign Music Codec 2"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_COOK,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "cook",
- .long_name = NULL_IF_CONFIG_SMALL("Cook / Cooker / Gecko (RealAudio G2)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_TRUESPEECH,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "truespeech",
- .long_name = NULL_IF_CONFIG_SMALL("DSP Group TrueSpeech"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_TTA,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "tta",
- .long_name = NULL_IF_CONFIG_SMALL("TTA (True Audio)"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_SMACKAUDIO,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "smackaudio",
- .long_name = NULL_IF_CONFIG_SMALL("Smacker audio"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_QCELP,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "qcelp",
- .long_name = NULL_IF_CONFIG_SMALL("QCELP / PureVoice"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_WAVPACK,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "wavpack",
- .long_name = NULL_IF_CONFIG_SMALL("WavPack"),
- .props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_DSICINAUDIO,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "dsicinaudio",
- .long_name = NULL_IF_CONFIG_SMALL("Delphine Software International CIN audio"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_IMC,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "imc",
- .long_name = NULL_IF_CONFIG_SMALL("IMC (Intel Music Coder)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_MUSEPACK7,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "musepack7",
- .long_name = NULL_IF_CONFIG_SMALL("Musepack SV7"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_MLP,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "mlp",
- .long_name = NULL_IF_CONFIG_SMALL("MLP (Meridian Lossless Packing)"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_GSM_MS,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "gsm_ms",
- .long_name = NULL_IF_CONFIG_SMALL("GSM Microsoft variant"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ATRAC3,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "atrac3",
- .long_name = NULL_IF_CONFIG_SMALL("Atrac 3 (Adaptive TRansform Acoustic Coding 3)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_VOXWARE,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "voxware",
- .long_name = NULL_IF_CONFIG_SMALL("Voxware RT29 Metasound"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_APE,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "ape",
- .long_name = NULL_IF_CONFIG_SMALL("Monkey's Audio"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_NELLYMOSER,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "nellymoser",
- .long_name = NULL_IF_CONFIG_SMALL("Nellymoser Asao"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_MUSEPACK8,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "musepack8",
- .long_name = NULL_IF_CONFIG_SMALL("Musepack SV8"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_SPEEX,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "speex",
- .long_name = NULL_IF_CONFIG_SMALL("Speex"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_WMAVOICE,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "wmavoice",
- .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio Voice"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_WMAPRO,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "wmapro",
- .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 9 Professional"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_WMALOSSLESS,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "wmalossless",
- .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio Lossless"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_ATRAC3P,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "atrac3p",
- .long_name = NULL_IF_CONFIG_SMALL("Sony ATRAC3+"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_EAC3,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "eac3",
- .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_SIPR,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "sipr",
- .long_name = NULL_IF_CONFIG_SMALL("RealAudio SIPR / ACELP.NET"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_MP1,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "mp1",
- .long_name = NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_TWINVQ,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "twinvq",
- .long_name = NULL_IF_CONFIG_SMALL("VQF TwinVQ"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_TRUEHD,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "truehd",
- .long_name = NULL_IF_CONFIG_SMALL("TrueHD"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_MP4ALS,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "mp4als",
- .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 Audio Lossless Coding (ALS)"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_ATRAC1,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "atrac1",
- .long_name = NULL_IF_CONFIG_SMALL("Atrac 1 (Adaptive TRansform Acoustic Coding)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_BINKAUDIO_RDFT,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "binkaudio_rdft",
- .long_name = NULL_IF_CONFIG_SMALL("Bink Audio (RDFT)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_BINKAUDIO_DCT,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "binkaudio_dct",
- .long_name = NULL_IF_CONFIG_SMALL("Bink Audio (DCT)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_AAC_LATM,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "aac_latm",
- .long_name = NULL_IF_CONFIG_SMALL("AAC LATM (Advanced Audio Coding LATM syntax)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_QDMC,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "qdmc",
- .long_name = NULL_IF_CONFIG_SMALL("QDesign Music"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_CELT,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "celt",
- .long_name = NULL_IF_CONFIG_SMALL("Constrained Energy Lapped Transform (CELT)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_G723_1,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "g723_1",
- .long_name = NULL_IF_CONFIG_SMALL("G.723.1"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_G729,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "g729",
- .long_name = NULL_IF_CONFIG_SMALL("G.729"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_8SVX_EXP,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "8svx_exp",
- .long_name = NULL_IF_CONFIG_SMALL("8SVX exponential"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_8SVX_FIB,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "8svx_fib",
- .long_name = NULL_IF_CONFIG_SMALL("8SVX fibonacci"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_BMV_AUDIO,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "bmv_audio",
- .long_name = NULL_IF_CONFIG_SMALL("Discworld II BMV audio"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_RALF,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "ralf",
- .long_name = NULL_IF_CONFIG_SMALL("RealAudio Lossless"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_IAC,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "iac",
- .long_name = NULL_IF_CONFIG_SMALL("IAC (Indeo Audio Coder)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_ILBC,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "ilbc",
- .long_name = NULL_IF_CONFIG_SMALL("iLBC (Internet Low Bitrate Codec)"),
- .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",
- .long_name = NULL_IF_CONFIG_SMALL("Wave synthesis pseudo-codec"),
- },
- {
- .id = AV_CODEC_ID_SONIC,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "sonic",
- .long_name = NULL_IF_CONFIG_SMALL("Sonic"),
- },
- {
- .id = AV_CODEC_ID_SONIC_LS,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "sonicls",
- .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",
- .long_name = NULL_IF_CONFIG_SMALL("Opus (Opus Interactive Audio Codec)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_COMFORT_NOISE,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "comfortnoise",
- .long_name = NULL_IF_CONFIG_SMALL("RFC 3389 Comfort Noise"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_TAK,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "tak",
- .long_name = NULL_IF_CONFIG_SMALL("TAK (Tom's lossless Audio Kompressor)"),
- .props = AV_CODEC_PROP_LOSSLESS,
- },
- {
- .id = AV_CODEC_ID_EVRC,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "evrc",
- .long_name = NULL_IF_CONFIG_SMALL("EVRC (Enhanced Variable Rate Codec)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
- {
- .id = AV_CODEC_ID_SMV,
- .type = AVMEDIA_TYPE_AUDIO,
- .name = "smv",
- .long_name = NULL_IF_CONFIG_SMALL("SMV (Selectable Mode Vocoder)"),
- .props = AV_CODEC_PROP_LOSSY,
- },
-
- /* subtitle codecs */
- {
- .id = AV_CODEC_ID_DVD_SUBTITLE,
- .type = AVMEDIA_TYPE_SUBTITLE,
- .name = "dvd_subtitle",
- .long_name = NULL_IF_CONFIG_SMALL("DVD subtitles"),
- },
- {
- .id = AV_CODEC_ID_DVB_SUBTITLE,
- .type = AVMEDIA_TYPE_SUBTITLE,
- .name = "dvb_subtitle",
- .long_name = NULL_IF_CONFIG_SMALL("DVB subtitles"),
- },
- {
- .id = AV_CODEC_ID_TEXT,
- .type = AVMEDIA_TYPE_SUBTITLE,
- .name = "text",
- .long_name = NULL_IF_CONFIG_SMALL("raw UTF-8 text"),
- },
- {
- .id = AV_CODEC_ID_XSUB,
- .type = AVMEDIA_TYPE_SUBTITLE,
- .name = "xsub",
- .long_name = NULL_IF_CONFIG_SMALL("XSUB"),
- },
- {
- .id = AV_CODEC_ID_SSA,
- .type = AVMEDIA_TYPE_SUBTITLE,
- .name = "ssa",
- .long_name = NULL_IF_CONFIG_SMALL("SSA (SubStation Alpha) / ASS (Advanced SSA) subtitle"),
- },
- {
- .id = AV_CODEC_ID_MOV_TEXT,
- .type = AVMEDIA_TYPE_SUBTITLE,
- .name = "mov_text",
- .long_name = NULL_IF_CONFIG_SMALL("MOV text"),
- },
- {
- .id = AV_CODEC_ID_HDMV_PGS_SUBTITLE,
- .type = AVMEDIA_TYPE_SUBTITLE,
- .name = "hdmv_pgs_subtitle",
- .long_name = NULL_IF_CONFIG_SMALL("HDMV Presentation Graphic Stream subtitles"),
- },
- {
- .id = AV_CODEC_ID_DVB_TELETEXT,
- .type = AVMEDIA_TYPE_SUBTITLE,
- .name = "dvb_teletext",
- .long_name = NULL_IF_CONFIG_SMALL("DVB teletext"),
- },
- {
- .id = AV_CODEC_ID_SRT,
- .type = AVMEDIA_TYPE_SUBTITLE,
- .name = "srt",
- .long_name = NULL_IF_CONFIG_SMALL("SubRip subtitle with embedded timing"),
- },
- {
- .id = AV_CODEC_ID_SUBRIP,
- .type = AVMEDIA_TYPE_SUBTITLE,
- .name = "subrip",
- .long_name = NULL_IF_CONFIG_SMALL("SubRip subtitle"),
- },
- {
- .id = AV_CODEC_ID_MICRODVD,
- .type = AVMEDIA_TYPE_SUBTITLE,
- .name = "microdvd",
- .long_name = NULL_IF_CONFIG_SMALL("MicroDVD subtitle"),
- },
- {
- .id = AV_CODEC_ID_MPL2,
- .type = AVMEDIA_TYPE_SUBTITLE,
- .name = "mpl2",
- .long_name = NULL_IF_CONFIG_SMALL("MPL2 subtitle"),
- },
- {
- .id = AV_CODEC_ID_EIA_608,
- .type = AVMEDIA_TYPE_SUBTITLE,
- .name = "eia_608",
- .long_name = NULL_IF_CONFIG_SMALL("EIA-608 closed captions"),
- },
- {
- .id = AV_CODEC_ID_JACOSUB,
- .type = AVMEDIA_TYPE_SUBTITLE,
- .name = "jacosub",
- .long_name = NULL_IF_CONFIG_SMALL("JACOsub subtitle"),
- },
- {
- .id = AV_CODEC_ID_PJS,
- .type = AVMEDIA_TYPE_SUBTITLE,
- .name = "pjs",
- .long_name = NULL_IF_CONFIG_SMALL("PJS (Phoenix Japanimation Society) subtitle"),
- },
- {
- .id = AV_CODEC_ID_SAMI,
- .type = AVMEDIA_TYPE_SUBTITLE,
- .name = "sami",
- .long_name = NULL_IF_CONFIG_SMALL("SAMI subtitle"),
- },
- {
- .id = AV_CODEC_ID_REALTEXT,
- .type = AVMEDIA_TYPE_SUBTITLE,
- .name = "realtext",
- .long_name = NULL_IF_CONFIG_SMALL("RealText subtitle"),
- },
- {
- .id = AV_CODEC_ID_SUBVIEWER1,
- .type = AVMEDIA_TYPE_SUBTITLE,
- .name = "subviewer1",
- .long_name = NULL_IF_CONFIG_SMALL("SubViewer v1 subtitle"),
- },
- {
- .id = AV_CODEC_ID_SUBVIEWER,
- .type = AVMEDIA_TYPE_SUBTITLE,
- .name = "subviewer",
- .long_name = NULL_IF_CONFIG_SMALL("SubViewer subtitle"),
- },
- {
- .id = AV_CODEC_ID_VPLAYER,
- .type = AVMEDIA_TYPE_SUBTITLE,
- .name = "vplayer",
- .long_name = NULL_IF_CONFIG_SMALL("VPlayer subtitle"),
- },
- {
- .id = AV_CODEC_ID_WEBVTT,
- .type = AVMEDIA_TYPE_SUBTITLE,
- .name = "webvtt",
- .long_name = NULL_IF_CONFIG_SMALL("WebVTT subtitle"),
- },
- {
- .id = AV_CODEC_ID_BINTEXT,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "bintext",
- .long_name = NULL_IF_CONFIG_SMALL("Binary text"),
- .props = AV_CODEC_PROP_INTRA_ONLY,
- },
- {
- .id = AV_CODEC_ID_XBIN,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "xbin",
- .long_name = NULL_IF_CONFIG_SMALL("eXtended BINary text"),
- .props = AV_CODEC_PROP_INTRA_ONLY,
- },
- {
- .id = AV_CODEC_ID_IDF,
- .type = AVMEDIA_TYPE_VIDEO,
- .name = "idf",
- .long_name = NULL_IF_CONFIG_SMALL("iCEDraw text"),
- .props = AV_CODEC_PROP_INTRA_ONLY,
- },
- {
- .id = AV_CODEC_ID_SMPTE_KLV,
- .type = AVMEDIA_TYPE_DATA,
- .name = "klv",
- .long_name = NULL_IF_CONFIG_SMALL("SMPTE 336M Key-Length-Value (KLV) metadata"),
- },
-
-};
-
-const AVCodecDescriptor *avcodec_descriptor_get(enum AVCodecID id)
-{
- int i;
-
- for (i = 0; i < FF_ARRAY_ELEMS(codec_descriptors); i++)
- if (codec_descriptors[i].id == id)
- return &codec_descriptors[i];
- return NULL;
-}
-
-const AVCodecDescriptor *avcodec_descriptor_next(const AVCodecDescriptor *prev)
-{
- if (!prev)
- return &codec_descriptors[0];
- if (prev - codec_descriptors < FF_ARRAY_ELEMS(codec_descriptors) - 1)
- return prev + 1;
- return NULL;
-}
-
-const AVCodecDescriptor *avcodec_descriptor_get_by_name(const char *name)
-{
- const AVCodecDescriptor *desc = NULL;
-
- while ((desc = avcodec_descriptor_next(desc))) {
- if (!strcmp(desc->name, name))
- return desc;
- }
- return NULL;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/cook.c b/src/thirdparty/ffmpeg/libavcodec/cook.c
deleted file mode 100644
index ec57a598e..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/cook.c
+++ /dev/null
@@ -1,1289 +0,0 @@
-/*
- * COOK compatible decoder
- * Copyright (c) 2003 Sascha Sommer
- * Copyright (c) 2005 Benjamin Larsson
- *
- * 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
- * Cook compatible decoder. Bastardization of the G.722.1 standard.
- * This decoder handles RealNetworks, RealAudio G2 data.
- * Cook is identified by the codec name cook in RM files.
- *
- * To use this decoder, a calling application must supply the extradata
- * bytes provided from the RM container; 8+ bytes for mono streams and
- * 16+ for stereo streams (maybe more).
- *
- * Codec technicalities (all this assume a buffer length of 1024):
- * Cook works with several different techniques to achieve its compression.
- * In the timedomain the buffer is divided into 8 pieces and quantized. If
- * two neighboring pieces have different quantization index a smooth
- * quantization curve is used to get a smooth overlap between the different
- * pieces.
- * To get to the transformdomain Cook uses a modulated lapped transform.
- * The transform domain has 50 subbands with 20 elements each. This
- * means only a maximum of 50*20=1000 coefficients are used out of the 1024
- * available.
- */
-
-#include "libavutil/channel_layout.h"
-#include "libavutil/lfg.h"
-#include "avcodec.h"
-#include "get_bits.h"
-#include "dsputil.h"
-#include "bytestream.h"
-#include "fft.h"
-#include "internal.h"
-#include "sinewin.h"
-
-#include "cookdata.h"
-
-/* the different Cook versions */
-#define MONO 0x1000001
-#define STEREO 0x1000002
-#define JOINT_STEREO 0x1000003
-#define MC_COOK 0x2000000 // multichannel Cook, not supported
-
-#define SUBBAND_SIZE 20
-#define MAX_SUBPACKETS 5
-
-typedef struct {
- int *now;
- int *previous;
-} cook_gains;
-
-typedef struct {
- int ch_idx;
- int size;
- int num_channels;
- int cookversion;
- int subbands;
- int js_subband_start;
- int js_vlc_bits;
- int samples_per_channel;
- int log2_numvector_size;
- unsigned int channel_mask;
- VLC channel_coupling;
- int joint_stereo;
- int bits_per_subpacket;
- int bits_per_subpdiv;
- int total_subbands;
- int numvector_size; // 1 << log2_numvector_size;
-
- float mono_previous_buffer1[1024];
- float mono_previous_buffer2[1024];
-
- cook_gains gains1;
- cook_gains gains2;
- int gain_1[9];
- int gain_2[9];
- int gain_3[9];
- int gain_4[9];
-} COOKSubpacket;
-
-typedef struct cook {
- /*
- * The following 5 functions provide the lowlevel arithmetic on
- * the internal audio buffers.
- */
- void (*scalar_dequant)(struct cook *q, int index, int quant_index,
- int *subband_coef_index, int *subband_coef_sign,
- float *mlt_p);
-
- void (*decouple)(struct cook *q,
- COOKSubpacket *p,
- int subband,
- float f1, float f2,
- float *decode_buffer,
- float *mlt_buffer1, float *mlt_buffer2);
-
- void (*imlt_window)(struct cook *q, float *buffer1,
- cook_gains *gains_ptr, float *previous_buffer);
-
- void (*interpolate)(struct cook *q, float *buffer,
- int gain_index, int gain_index_next);
-
- void (*saturate_output)(struct cook *q, float *out);
-
- AVCodecContext* avctx;
- DSPContext dsp;
- GetBitContext gb;
- /* stream data */
- int num_vectors;
- int samples_per_channel;
- /* states */
- AVLFG random_state;
- int discarded_packets;
-
- /* transform data */
- FFTContext mdct_ctx;
- float* mlt_window;
-
- /* VLC data */
- VLC envelope_quant_index[13];
- VLC sqvh[7]; // scalar quantization
-
- /* generatable tables and related variables */
- int gain_size_factor;
- float gain_table[23];
-
- /* data buffers */
-
- uint8_t* decoded_bytes_buffer;
- DECLARE_ALIGNED(32, float, mono_mdct_output)[2048];
- float decode_buffer_1[1024];
- float decode_buffer_2[1024];
- float decode_buffer_0[1060]; /* static allocation for joint decode */
-
- const float *cplscales[5];
- int num_subpackets;
- COOKSubpacket subpacket[MAX_SUBPACKETS];
-} COOKContext;
-
-static float pow2tab[127];
-static float rootpow2tab[127];
-
-/*************** init functions ***************/
-
-/* table generator */
-static av_cold void init_pow2table(void)
-{
- int i;
- for (i = -63; i < 64; i++) {
- pow2tab[63 + i] = pow(2, i);
- rootpow2tab[63 + i] = sqrt(pow(2, i));
- }
-}
-
-/* table generator */
-static av_cold void init_gain_table(COOKContext *q)
-{
- int i;
- q->gain_size_factor = q->samples_per_channel / 8;
- for (i = 0; i < 23; i++)
- q->gain_table[i] = pow(pow2tab[i + 52],
- (1.0 / (double) q->gain_size_factor));
-}
-
-
-static av_cold int init_cook_vlc_tables(COOKContext *q)
-{
- int i, result;
-
- result = 0;
- for (i = 0; i < 13; i++) {
- result |= init_vlc(&q->envelope_quant_index[i], 9, 24,
- envelope_quant_index_huffbits[i], 1, 1,
- envelope_quant_index_huffcodes[i], 2, 2, 0);
- }
- av_log(q->avctx, AV_LOG_DEBUG, "sqvh VLC init\n");
- for (i = 0; i < 7; i++) {
- result |= init_vlc(&q->sqvh[i], vhvlcsize_tab[i], vhsize_tab[i],
- cvh_huffbits[i], 1, 1,
- cvh_huffcodes[i], 2, 2, 0);
- }
-
- for (i = 0; i < q->num_subpackets; i++) {
- if (q->subpacket[i].joint_stereo == 1) {
- result |= init_vlc(&q->subpacket[i].channel_coupling, 6,
- (1 << q->subpacket[i].js_vlc_bits) - 1,
- ccpl_huffbits[q->subpacket[i].js_vlc_bits - 2], 1, 1,
- ccpl_huffcodes[q->subpacket[i].js_vlc_bits - 2], 2, 2, 0);
- av_log(q->avctx, AV_LOG_DEBUG, "subpacket %i Joint-stereo VLC used.\n", i);
- }
- }
-
- av_log(q->avctx, AV_LOG_DEBUG, "VLC tables initialized.\n");
- return result;
-}
-
-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)
- return AVERROR(ENOMEM);
-
- /* Initialize the MLT window: simple sine window. */
- ff_sine_window_init(q->mlt_window, mlt_size);
- for (j = 0; j < mlt_size; j++)
- q->mlt_window[j] *= sqrt(2.0 / q->samples_per_channel);
-
- /* Initialize the MDCT. */
- if ((ret = ff_mdct_init(&q->mdct_ctx, av_log2(mlt_size) + 1, 1, 1.0 / 32768.0))) {
- av_free(q->mlt_window);
- return ret;
- }
- av_log(q->avctx, AV_LOG_DEBUG, "MDCT initialized, order = %d.\n",
- av_log2(mlt_size) + 1);
-
- return 0;
-}
-
-static av_cold void init_cplscales_table(COOKContext *q)
-{
- int i;
- for (i = 0; i < 5; i++)
- q->cplscales[i] = cplscales[i];
-}
-
-/*************** init functions end ***********/
-
-#define DECODE_BYTES_PAD1(bytes) (3 - ((bytes) + 3) % 4)
-#define DECODE_BYTES_PAD2(bytes) ((bytes) % 4 + DECODE_BYTES_PAD1(2 * (bytes)))
-
-/**
- * Cook indata decoding, every 32 bits are XORed with 0x37c511f2.
- * Why? No idea, some checksum/error detection method maybe.
- *
- * Out buffer size: extra bytes are needed to cope with
- * padding/misalignment.
- * Subpackets passed to the decoder can contain two, consecutive
- * half-subpackets, of identical but arbitrary size.
- * 1234 1234 1234 1234 extraA extraB
- * Case 1: AAAA BBBB 0 0
- * Case 2: AAAA ABBB BB-- 3 3
- * Case 3: AAAA AABB BBBB 2 2
- * Case 4: AAAA AAAB BBBB BB-- 1 5
- *
- * Nice way to waste CPU cycles.
- *
- * @param inbuffer pointer to byte array of indata
- * @param out pointer to byte array of outdata
- * @param bytes number of bytes
- */
-static inline int decode_bytes(const uint8_t *inbuffer, uint8_t *out, int bytes)
-{
- static const uint32_t tab[4] = {
- AV_BE2NE32C(0x37c511f2u), AV_BE2NE32C(0xf237c511u),
- AV_BE2NE32C(0x11f237c5u), AV_BE2NE32C(0xc511f237u),
- };
- int i, off;
- uint32_t c;
- const uint32_t *buf;
- uint32_t *obuf = (uint32_t *) out;
- /* FIXME: 64 bit platforms would be able to do 64 bits at a time.
- * I'm too lazy though, should be something like
- * for (i = 0; i < bitamount / 64; i++)
- * (int64_t) out[i] = 0x37c511f237c511f2 ^ av_be2ne64(int64_t) in[i]);
- * Buffer alignment needs to be checked. */
-
- off = (intptr_t) inbuffer & 3;
- buf = (const uint32_t *) (inbuffer - off);
- c = tab[off];
- bytes += 3 + off;
- for (i = 0; i < bytes / 4; i++)
- obuf[i] = c ^ buf[i];
-
- return off;
-}
-
-static av_cold int cook_decode_close(AVCodecContext *avctx)
-{
- int i;
- COOKContext *q = avctx->priv_data;
- av_log(avctx, AV_LOG_DEBUG, "Deallocating memory.\n");
-
- /* Free allocated memory buffers. */
- av_free(q->mlt_window);
- av_free(q->decoded_bytes_buffer);
-
- /* Free the transform. */
- ff_mdct_end(&q->mdct_ctx);
-
- /* Free the VLC tables. */
- for (i = 0; i < 13; i++)
- ff_free_vlc(&q->envelope_quant_index[i]);
- for (i = 0; i < 7; i++)
- ff_free_vlc(&q->sqvh[i]);
- for (i = 0; i < q->num_subpackets; i++)
- ff_free_vlc(&q->subpacket[i].channel_coupling);
-
- av_log(avctx, AV_LOG_DEBUG, "Memory deallocated.\n");
-
- return 0;
-}
-
-/**
- * Fill the gain array for the timedomain quantization.
- *
- * @param gb pointer to the GetBitContext
- * @param gaininfo array[9] of gain indexes
- */
-static void decode_gain_info(GetBitContext *gb, int *gaininfo)
-{
- int i, n;
-
- while (get_bits1(gb)) {
- /* NOTHING */
- }
-
- n = get_bits_count(gb) - 1; // amount of elements*2 to update
-
- i = 0;
- while (n--) {
- int index = get_bits(gb, 3);
- int gain = get_bits1(gb) ? get_bits(gb, 4) - 7 : -1;
-
- while (i <= index)
- gaininfo[i++] = gain;
- }
- while (i <= 8)
- gaininfo[i++] = 0;
-}
-
-/**
- * Create the quant index table needed for the envelope.
- *
- * @param q pointer to the COOKContext
- * @param quant_index_table pointer to the array
- */
-static int decode_envelope(COOKContext *q, COOKSubpacket *p,
- int *quant_index_table)
-{
- int i, j, vlc_index;
-
- quant_index_table[0] = get_bits(&q->gb, 6) - 6; // This is used later in categorize
-
- for (i = 1; i < p->total_subbands; i++) {
- vlc_index = i;
- if (i >= p->js_subband_start * 2) {
- vlc_index -= p->js_subband_start;
- } else {
- vlc_index /= 2;
- if (vlc_index < 1)
- vlc_index = 1;
- }
- if (vlc_index > 13)
- vlc_index = 13; // the VLC tables >13 are identical to No. 13
-
- j = get_vlc2(&q->gb, q->envelope_quant_index[vlc_index - 1].table,
- q->envelope_quant_index[vlc_index - 1].bits, 2);
- quant_index_table[i] = quant_index_table[i - 1] + j - 12; // differential encoding
- if (quant_index_table[i] > 63 || quant_index_table[i] < -63) {
- av_log(q->avctx, AV_LOG_ERROR,
- "Invalid quantizer %d at position %d, outside [-63, 63] range\n",
- quant_index_table[i], i);
- return AVERROR_INVALIDDATA;
- }
- }
-
- return 0;
-}
-
-/**
- * Calculate the category and category_index vector.
- *
- * @param q pointer to the COOKContext
- * @param quant_index_table pointer to the array
- * @param category pointer to the category array
- * @param category_index pointer to the category_index array
- */
-static void categorize(COOKContext *q, COOKSubpacket *p, const int *quant_index_table,
- int *category, int *category_index)
-{
- int exp_idx, bias, tmpbias1, tmpbias2, bits_left, num_bits, index, v, i, j;
- int exp_index2[102] = { 0 };
- int exp_index1[102] = { 0 };
-
- int tmp_categorize_array[128 * 2] = { 0 };
- int tmp_categorize_array1_idx = p->numvector_size;
- int tmp_categorize_array2_idx = p->numvector_size;
-
- bits_left = p->bits_per_subpacket - get_bits_count(&q->gb);
-
- if (bits_left > q->samples_per_channel)
- bits_left = q->samples_per_channel +
- ((bits_left - q->samples_per_channel) * 5) / 8;
-
- bias = -32;
-
- /* Estimate bias. */
- for (i = 32; i > 0; i = i / 2) {
- num_bits = 0;
- index = 0;
- for (j = p->total_subbands; j > 0; j--) {
- exp_idx = av_clip((i - quant_index_table[index] + bias) / 2, 0, 7);
- index++;
- num_bits += expbits_tab[exp_idx];
- }
- if (num_bits >= bits_left - 32)
- bias += i;
- }
-
- /* Calculate total number of bits. */
- num_bits = 0;
- for (i = 0; i < p->total_subbands; i++) {
- exp_idx = av_clip((bias - quant_index_table[i]) / 2, 0, 7);
- num_bits += expbits_tab[exp_idx];
- exp_index1[i] = exp_idx;
- exp_index2[i] = exp_idx;
- }
- tmpbias1 = tmpbias2 = num_bits;
-
- for (j = 1; j < p->numvector_size; j++) {
- if (tmpbias1 + tmpbias2 > 2 * bits_left) { /* ---> */
- int max = -999999;
- index = -1;
- for (i = 0; i < p->total_subbands; i++) {
- if (exp_index1[i] < 7) {
- v = (-2 * exp_index1[i]) - quant_index_table[i] + bias;
- if (v >= max) {
- max = v;
- index = i;
- }
- }
- }
- if (index == -1)
- break;
- tmp_categorize_array[tmp_categorize_array1_idx++] = index;
- tmpbias1 -= expbits_tab[exp_index1[index]] -
- expbits_tab[exp_index1[index] + 1];
- ++exp_index1[index];
- } else { /* <--- */
- int min = 999999;
- index = -1;
- for (i = 0; i < p->total_subbands; i++) {
- if (exp_index2[i] > 0) {
- v = (-2 * exp_index2[i]) - quant_index_table[i] + bias;
- if (v < min) {
- min = v;
- index = i;
- }
- }
- }
- if (index == -1)
- break;
- tmp_categorize_array[--tmp_categorize_array2_idx] = index;
- tmpbias2 -= expbits_tab[exp_index2[index]] -
- expbits_tab[exp_index2[index] - 1];
- --exp_index2[index];
- }
- }
-
- for (i = 0; i < p->total_subbands; i++)
- category[i] = exp_index2[i];
-
- for (i = 0; i < p->numvector_size - 1; i++)
- category_index[i] = tmp_categorize_array[tmp_categorize_array2_idx++];
-}
-
-
-/**
- * Expand the category vector.
- *
- * @param q pointer to the COOKContext
- * @param category pointer to the category array
- * @param category_index pointer to the category_index array
- */
-static inline void expand_category(COOKContext *q, int *category,
- int *category_index)
-{
- int i;
- for (i = 0; i < q->num_vectors; i++)
- {
- int idx = category_index[i];
- if (++category[idx] >= FF_ARRAY_ELEMS(dither_tab))
- --category[idx];
- }
-}
-
-/**
- * The real requantization of the mltcoefs
- *
- * @param q pointer to the COOKContext
- * @param index index
- * @param quant_index quantisation index
- * @param subband_coef_index array of indexes to quant_centroid_tab
- * @param subband_coef_sign signs of coefficients
- * @param mlt_p pointer into the mlt buffer
- */
-static void scalar_dequant_float(COOKContext *q, int index, int quant_index,
- int *subband_coef_index, int *subband_coef_sign,
- float *mlt_p)
-{
- int i;
- float f1;
-
- for (i = 0; i < SUBBAND_SIZE; i++) {
- if (subband_coef_index[i]) {
- f1 = quant_centroid_tab[index][subband_coef_index[i]];
- if (subband_coef_sign[i])
- f1 = -f1;
- } else {
- /* noise coding if subband_coef_index[i] == 0 */
- f1 = dither_tab[index];
- if (av_lfg_get(&q->random_state) < 0x80000000)
- f1 = -f1;
- }
- mlt_p[i] = f1 * rootpow2tab[quant_index + 63];
- }
-}
-/**
- * Unpack the subband_coef_index and subband_coef_sign vectors.
- *
- * @param q pointer to the COOKContext
- * @param category pointer to the category array
- * @param subband_coef_index array of indexes to quant_centroid_tab
- * @param subband_coef_sign signs of coefficients
- */
-static int unpack_SQVH(COOKContext *q, COOKSubpacket *p, int category,
- int *subband_coef_index, int *subband_coef_sign)
-{
- int i, j;
- int vlc, vd, tmp, result;
-
- vd = vd_tab[category];
- result = 0;
- for (i = 0; i < vpr_tab[category]; i++) {
- vlc = get_vlc2(&q->gb, q->sqvh[category].table, q->sqvh[category].bits, 3);
- if (p->bits_per_subpacket < get_bits_count(&q->gb)) {
- vlc = 0;
- result = 1;
- }
- for (j = vd - 1; j >= 0; j--) {
- tmp = (vlc * invradix_tab[category]) / 0x100000;
- subband_coef_index[vd * i + j] = vlc - tmp * (kmax_tab[category] + 1);
- vlc = tmp;
- }
- for (j = 0; j < vd; j++) {
- if (subband_coef_index[i * vd + j]) {
- if (get_bits_count(&q->gb) < p->bits_per_subpacket) {
- subband_coef_sign[i * vd + j] = get_bits1(&q->gb);
- } else {
- result = 1;
- subband_coef_sign[i * vd + j] = 0;
- }
- } else {
- subband_coef_sign[i * vd + j] = 0;
- }
- }
- }
- return result;
-}
-
-
-/**
- * Fill the mlt_buffer with mlt coefficients.
- *
- * @param q pointer to the COOKContext
- * @param category pointer to the category array
- * @param quant_index_table pointer to the array
- * @param mlt_buffer pointer to mlt coefficients
- */
-static void decode_vectors(COOKContext *q, COOKSubpacket *p, int *category,
- int *quant_index_table, float *mlt_buffer)
-{
- /* A zero in this table means that the subband coefficient is
- random noise coded. */
- int subband_coef_index[SUBBAND_SIZE];
- /* A zero in this table means that the subband coefficient is a
- positive multiplicator. */
- int subband_coef_sign[SUBBAND_SIZE];
- int band, j;
- int index = 0;
-
- for (band = 0; band < p->total_subbands; band++) {
- index = category[band];
- if (category[band] < 7) {
- if (unpack_SQVH(q, p, category[band], subband_coef_index, subband_coef_sign)) {
- index = 7;
- for (j = 0; j < p->total_subbands; j++)
- category[band + j] = 7;
- }
- }
- if (index >= 7) {
- memset(subband_coef_index, 0, sizeof(subband_coef_index));
- memset(subband_coef_sign, 0, sizeof(subband_coef_sign));
- }
- q->scalar_dequant(q, index, quant_index_table[band],
- subband_coef_index, subband_coef_sign,
- &mlt_buffer[band * SUBBAND_SIZE]);
- }
-
- /* FIXME: should this be removed, or moved into loop above? */
- if (p->total_subbands * SUBBAND_SIZE >= q->samples_per_channel)
- return;
-}
-
-
-static int mono_decode(COOKContext *q, COOKSubpacket *p, float *mlt_buffer)
-{
- int category_index[128] = { 0 };
- int category[128] = { 0 };
- int quant_index_table[102];
- int res, i;
-
- if ((res = decode_envelope(q, p, quant_index_table)) < 0)
- return res;
- q->num_vectors = get_bits(&q->gb, p->log2_numvector_size);
- categorize(q, p, quant_index_table, category, category_index);
- expand_category(q, category, category_index);
- for (i=0; i<p->total_subbands; i++) {
- if (category[i] > 7)
- return AVERROR_INVALIDDATA;
- }
- decode_vectors(q, p, category, quant_index_table, mlt_buffer);
-
- return 0;
-}
-
-
-/**
- * the actual requantization of the timedomain samples
- *
- * @param q pointer to the COOKContext
- * @param buffer pointer to the timedomain buffer
- * @param gain_index index for the block multiplier
- * @param gain_index_next index for the next block multiplier
- */
-static void interpolate_float(COOKContext *q, float *buffer,
- int gain_index, int gain_index_next)
-{
- int i;
- float fc1, fc2;
- fc1 = pow2tab[gain_index + 63];
-
- if (gain_index == gain_index_next) { // static gain
- for (i = 0; i < q->gain_size_factor; i++)
- buffer[i] *= fc1;
- } else { // smooth gain
- fc2 = q->gain_table[11 + (gain_index_next - gain_index)];
- for (i = 0; i < q->gain_size_factor; i++) {
- buffer[i] *= fc1;
- fc1 *= fc2;
- }
- }
-}
-
-/**
- * Apply transform window, overlap buffers.
- *
- * @param q pointer to the COOKContext
- * @param inbuffer pointer to the mltcoefficients
- * @param gains_ptr current and previous gains
- * @param previous_buffer pointer to the previous buffer to be used for overlapping
- */
-static void imlt_window_float(COOKContext *q, float *inbuffer,
- cook_gains *gains_ptr, float *previous_buffer)
-{
- const float fc = pow2tab[gains_ptr->previous[0] + 63];
- int i;
- /* The weird thing here, is that the two halves of the time domain
- * buffer are swapped. Also, the newest data, that we save away for
- * next frame, has the wrong sign. Hence the subtraction below.
- * Almost sounds like a complex conjugate/reverse data/FFT effect.
- */
-
- /* Apply window and overlap */
- for (i = 0; i < q->samples_per_channel; i++)
- inbuffer[i] = inbuffer[i] * fc * q->mlt_window[i] -
- previous_buffer[i] * q->mlt_window[q->samples_per_channel - 1 - i];
-}
-
-/**
- * The modulated lapped transform, this takes transform coefficients
- * and transforms them into timedomain samples.
- * Apply transform window, overlap buffers, apply gain profile
- * and buffer management.
- *
- * @param q pointer to the COOKContext
- * @param inbuffer pointer to the mltcoefficients
- * @param gains_ptr current and previous gains
- * @param previous_buffer pointer to the previous buffer to be used for overlapping
- */
-static void imlt_gain(COOKContext *q, float *inbuffer,
- cook_gains *gains_ptr, float *previous_buffer)
-{
- float *buffer0 = q->mono_mdct_output;
- float *buffer1 = q->mono_mdct_output + q->samples_per_channel;
- int i;
-
- /* Inverse modified discrete cosine transform */
- q->mdct_ctx.imdct_calc(&q->mdct_ctx, q->mono_mdct_output, inbuffer);
-
- q->imlt_window(q, buffer1, gains_ptr, previous_buffer);
-
- /* Apply gain profile */
- for (i = 0; i < 8; i++)
- if (gains_ptr->now[i] || gains_ptr->now[i + 1])
- q->interpolate(q, &buffer1[q->gain_size_factor * i],
- gains_ptr->now[i], gains_ptr->now[i + 1]);
-
- /* Save away the current to be previous block. */
- memcpy(previous_buffer, buffer0,
- q->samples_per_channel * sizeof(*previous_buffer));
-}
-
-
-/**
- * function for getting the jointstereo coupling information
- *
- * @param q pointer to the COOKContext
- * @param decouple_tab decoupling array
- */
-static int decouple_info(COOKContext *q, COOKSubpacket *p, int *decouple_tab)
-{
- int i;
- int vlc = get_bits1(&q->gb);
- int start = cplband[p->js_subband_start];
- int end = cplband[p->subbands - 1];
- int length = end - start + 1;
-
- if (start > end)
- return 0;
-
- if (vlc)
- for (i = 0; i < length; i++)
- decouple_tab[start + i] = get_vlc2(&q->gb,
- p->channel_coupling.table,
- p->channel_coupling.bits, 2);
- else
- for (i = 0; i < length; i++) {
- int v = get_bits(&q->gb, p->js_vlc_bits);
- if (v == (1<<p->js_vlc_bits)-1) {
- av_log(q->avctx, AV_LOG_ERROR, "decouple value too large\n");
- return AVERROR_INVALIDDATA;
- }
- decouple_tab[start + i] = v;
- }
- return 0;
-}
-
-/**
- * function decouples a pair of signals from a single signal via multiplication.
- *
- * @param q pointer to the COOKContext
- * @param subband index of the current subband
- * @param f1 multiplier for channel 1 extraction
- * @param f2 multiplier for channel 2 extraction
- * @param decode_buffer input buffer
- * @param mlt_buffer1 pointer to left channel mlt coefficients
- * @param mlt_buffer2 pointer to right channel mlt coefficients
- */
-static void decouple_float(COOKContext *q,
- COOKSubpacket *p,
- int subband,
- float f1, float f2,
- float *decode_buffer,
- float *mlt_buffer1, float *mlt_buffer2)
-{
- int j, tmp_idx;
- for (j = 0; j < SUBBAND_SIZE; j++) {
- tmp_idx = ((p->js_subband_start + subband) * SUBBAND_SIZE) + j;
- mlt_buffer1[SUBBAND_SIZE * subband + j] = f1 * decode_buffer[tmp_idx];
- mlt_buffer2[SUBBAND_SIZE * subband + j] = f2 * decode_buffer[tmp_idx];
- }
-}
-
-/**
- * function for decoding joint stereo data
- *
- * @param q pointer to the COOKContext
- * @param mlt_buffer1 pointer to left channel mlt coefficients
- * @param mlt_buffer2 pointer to right channel mlt coefficients
- */
-static int joint_decode(COOKContext *q, COOKSubpacket *p,
- float *mlt_buffer_left, float *mlt_buffer_right)
-{
- int i, j, res;
- int decouple_tab[SUBBAND_SIZE] = { 0 };
- float *decode_buffer = q->decode_buffer_0;
- int idx, cpl_tmp;
- float f1, f2;
- const float *cplscale;
-
- memset(decode_buffer, 0, sizeof(q->decode_buffer_0));
-
- /* Make sure the buffers are zeroed out. */
- memset(mlt_buffer_left, 0, 1024 * sizeof(*mlt_buffer_left));
- memset(mlt_buffer_right, 0, 1024 * sizeof(*mlt_buffer_right));
- if ((res = decouple_info(q, p, decouple_tab)) < 0)
- return res;
- if ((res = mono_decode(q, p, decode_buffer)) < 0)
- return res;
- /* The two channels are stored interleaved in decode_buffer. */
- for (i = 0; i < p->js_subband_start; i++) {
- for (j = 0; j < SUBBAND_SIZE; j++) {
- mlt_buffer_left[i * 20 + j] = decode_buffer[i * 40 + j];
- mlt_buffer_right[i * 20 + j] = decode_buffer[i * 40 + 20 + j];
- }
- }
-
- /* When we reach js_subband_start (the higher frequencies)
- the coefficients are stored in a coupling scheme. */
- idx = (1 << p->js_vlc_bits) - 1;
- for (i = p->js_subband_start; i < p->subbands; i++) {
- cpl_tmp = cplband[i];
- idx -= decouple_tab[cpl_tmp];
- cplscale = q->cplscales[p->js_vlc_bits - 2]; // choose decoupler table
- f1 = cplscale[decouple_tab[cpl_tmp] + 1];
- f2 = cplscale[idx];
- q->decouple(q, p, i, f1, f2, decode_buffer,
- mlt_buffer_left, mlt_buffer_right);
- idx = (1 << p->js_vlc_bits) - 1;
- }
-
- return 0;
-}
-
-/**
- * First part of subpacket decoding:
- * decode raw stream bytes and read gain info.
- *
- * @param q pointer to the COOKContext
- * @param inbuffer pointer to raw stream data
- * @param gains_ptr array of current/prev gain pointers
- */
-static inline void decode_bytes_and_gain(COOKContext *q, COOKSubpacket *p,
- const uint8_t *inbuffer,
- cook_gains *gains_ptr)
-{
- int offset;
-
- offset = decode_bytes(inbuffer, q->decoded_bytes_buffer,
- p->bits_per_subpacket / 8);
- init_get_bits(&q->gb, q->decoded_bytes_buffer + offset,
- p->bits_per_subpacket);
- decode_gain_info(&q->gb, gains_ptr->now);
-
- /* Swap current and previous gains */
- FFSWAP(int *, gains_ptr->now, gains_ptr->previous);
-}
-
-/**
- * Saturate the output signal and interleave.
- *
- * @param q pointer to the COOKContext
- * @param out pointer to the output vector
- */
-static void saturate_output_float(COOKContext *q, float *out)
-{
- q->dsp.vector_clipf(out, q->mono_mdct_output + q->samples_per_channel,
- -1.0f, 1.0f, FFALIGN(q->samples_per_channel, 8));
-}
-
-
-/**
- * Final part of subpacket decoding:
- * Apply modulated lapped transform, gain compensation,
- * clip and convert to integer.
- *
- * @param q pointer to the COOKContext
- * @param decode_buffer pointer to the mlt coefficients
- * @param gains_ptr array of current/prev gain pointers
- * @param previous_buffer pointer to the previous buffer to be used for overlapping
- * @param out pointer to the output buffer
- */
-static inline void mlt_compensate_output(COOKContext *q, float *decode_buffer,
- cook_gains *gains_ptr, float *previous_buffer,
- float *out)
-{
- imlt_gain(q, decode_buffer, gains_ptr, previous_buffer);
- if (out)
- q->saturate_output(q, out);
-}
-
-
-/**
- * Cook subpacket decoding. This function returns one decoded subpacket,
- * usually 1024 samples per channel.
- *
- * @param q pointer to the COOKContext
- * @param inbuffer pointer to the inbuffer
- * @param outbuffer pointer to the outbuffer
- */
-static int decode_subpacket(COOKContext *q, COOKSubpacket *p,
- const uint8_t *inbuffer, float **outbuffer)
-{
- int sub_packet_size = p->size;
- int res;
-
- memset(q->decode_buffer_1, 0, sizeof(q->decode_buffer_1));
- decode_bytes_and_gain(q, p, inbuffer, &p->gains1);
-
- if (p->joint_stereo) {
- if ((res = joint_decode(q, p, q->decode_buffer_1, q->decode_buffer_2)) < 0)
- return res;
- } else {
- if ((res = mono_decode(q, p, q->decode_buffer_1)) < 0)
- return res;
-
- if (p->num_channels == 2) {
- decode_bytes_and_gain(q, p, inbuffer + sub_packet_size / 2, &p->gains2);
- if ((res = mono_decode(q, p, q->decode_buffer_2)) < 0)
- return res;
- }
- }
-
- mlt_compensate_output(q, q->decode_buffer_1, &p->gains1,
- p->mono_previous_buffer1,
- outbuffer ? outbuffer[p->ch_idx] : NULL);
-
- if (p->num_channels == 2) {
- if (p->joint_stereo)
- mlt_compensate_output(q, q->decode_buffer_2, &p->gains1,
- p->mono_previous_buffer2,
- outbuffer ? outbuffer[p->ch_idx + 1] : NULL);
- else
- mlt_compensate_output(q, q->decode_buffer_2, &p->gains2,
- p->mono_previous_buffer2,
- outbuffer ? outbuffer[p->ch_idx + 1] : NULL);
- }
-
- return 0;
-}
-
-
-static int cook_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;
- COOKContext *q = avctx->priv_data;
- float **samples = NULL;
- int i, ret;
- int offset = 0;
- int chidx = 0;
-
- if (buf_size < avctx->block_align)
- return buf_size;
-
- /* get output buffer */
- if (q->discarded_packets >= 2) {
- frame->nb_samples = q->samples_per_channel;
- if ((ret = ff_get_buffer(avctx, frame)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return ret;
- }
- samples = (float **)frame->extended_data;
- }
-
- /* estimate subpacket sizes */
- q->subpacket[0].size = avctx->block_align;
-
- for (i = 1; i < q->num_subpackets; i++) {
- q->subpacket[i].size = 2 * buf[avctx->block_align - q->num_subpackets + i];
- q->subpacket[0].size -= q->subpacket[i].size + 1;
- if (q->subpacket[0].size < 0) {
- av_log(avctx, AV_LOG_DEBUG,
- "frame subpacket size total > avctx->block_align!\n");
- return AVERROR_INVALIDDATA;
- }
- }
-
- /* decode supbackets */
- for (i = 0; i < q->num_subpackets; i++) {
- q->subpacket[i].bits_per_subpacket = (q->subpacket[i].size * 8) >>
- q->subpacket[i].bits_per_subpdiv;
- q->subpacket[i].ch_idx = chidx;
- av_log(avctx, AV_LOG_DEBUG,
- "subpacket[%i] size %i js %i %i block_align %i\n",
- i, q->subpacket[i].size, q->subpacket[i].joint_stereo, offset,
- avctx->block_align);
-
- if ((ret = decode_subpacket(q, &q->subpacket[i], buf + offset, samples)) < 0)
- return ret;
- offset += q->subpacket[i].size;
- chidx += q->subpacket[i].num_channels;
- av_log(avctx, AV_LOG_DEBUG, "subpacket[%i] %i %i\n",
- i, q->subpacket[i].size * 8, get_bits_count(&q->gb));
- }
-
- /* Discard the first two frames: no valid audio. */
- if (q->discarded_packets < 2) {
- q->discarded_packets++;
- *got_frame_ptr = 0;
- return avctx->block_align;
- }
-
- *got_frame_ptr = 1;
-
- return avctx->block_align;
-}
-
-#ifdef DEBUG
-static void dump_cook_context(COOKContext *q)
-{
- //int i=0;
-#define PRINT(a, b) av_dlog(q->avctx, " %s = %d\n", a, b);
- av_dlog(q->avctx, "COOKextradata\n");
- av_dlog(q->avctx, "cookversion=%x\n", q->subpacket[0].cookversion);
- if (q->subpacket[0].cookversion > STEREO) {
- PRINT("js_subband_start", q->subpacket[0].js_subband_start);
- PRINT("js_vlc_bits", q->subpacket[0].js_vlc_bits);
- }
- av_dlog(q->avctx, "COOKContext\n");
- PRINT("nb_channels", q->avctx->channels);
- PRINT("bit_rate", q->avctx->bit_rate);
- PRINT("sample_rate", q->avctx->sample_rate);
- PRINT("samples_per_channel", q->subpacket[0].samples_per_channel);
- PRINT("subbands", q->subpacket[0].subbands);
- PRINT("js_subband_start", q->subpacket[0].js_subband_start);
- PRINT("log2_numvector_size", q->subpacket[0].log2_numvector_size);
- PRINT("numvector_size", q->subpacket[0].numvector_size);
- PRINT("total_subbands", q->subpacket[0].total_subbands);
-}
-#endif
-
-/**
- * Cook initialization
- *
- * @param avctx pointer to the AVCodecContext
- */
-static av_cold int cook_decode_init(AVCodecContext *avctx)
-{
- COOKContext *q = avctx->priv_data;
- const uint8_t *edata_ptr = avctx->extradata;
- const uint8_t *edata_ptr_end = edata_ptr + avctx->extradata_size;
- int extradata_size = avctx->extradata_size;
- int s = 0;
- unsigned int channel_mask = 0;
- int samples_per_frame = 0;
- int ret;
- q->avctx = avctx;
-
- /* Take care of the codec specific extradata. */
- if (extradata_size <= 0) {
- av_log(avctx, AV_LOG_ERROR, "Necessary extradata missing!\n");
- return AVERROR_INVALIDDATA;
- }
- av_log(avctx, AV_LOG_DEBUG, "codecdata_length=%d\n", avctx->extradata_size);
-
- /* Take data from the AVCodecContext (RM container). */
- if (!avctx->channels) {
- av_log(avctx, AV_LOG_ERROR, "Invalid number of channels\n");
- return AVERROR_INVALIDDATA;
- }
-
- /* Initialize RNG. */
- av_lfg_init(&q->random_state, 0);
-
- ff_dsputil_init(&q->dsp, avctx);
-
- while (edata_ptr < edata_ptr_end) {
- /* 8 for mono, 16 for stereo, ? for multichannel
- Swap to right endianness so we don't need to care later on. */
- if (extradata_size >= 8) {
- q->subpacket[s].cookversion = bytestream_get_be32(&edata_ptr);
- samples_per_frame = bytestream_get_be16(&edata_ptr);
- q->subpacket[s].subbands = bytestream_get_be16(&edata_ptr);
- extradata_size -= 8;
- }
- if (extradata_size >= 8) {
- bytestream_get_be32(&edata_ptr); // Unknown unused
- q->subpacket[s].js_subband_start = bytestream_get_be16(&edata_ptr);
- q->subpacket[s].js_vlc_bits = bytestream_get_be16(&edata_ptr);
- extradata_size -= 8;
- }
-
- /* Initialize extradata related variables. */
- q->subpacket[s].samples_per_channel = samples_per_frame / avctx->channels;
- q->subpacket[s].bits_per_subpacket = avctx->block_align * 8;
-
- /* Initialize default data states. */
- q->subpacket[s].log2_numvector_size = 5;
- q->subpacket[s].total_subbands = q->subpacket[s].subbands;
- q->subpacket[s].num_channels = 1;
-
- /* Initialize version-dependent variables */
-
- av_log(avctx, AV_LOG_DEBUG, "subpacket[%i].cookversion=%x\n", s,
- q->subpacket[s].cookversion);
- q->subpacket[s].joint_stereo = 0;
- switch (q->subpacket[s].cookversion) {
- case MONO:
- if (avctx->channels != 1) {
- av_log_ask_for_sample(avctx, "Container channels != 1.\n");
- return AVERROR_PATCHWELCOME;
- }
- av_log(avctx, AV_LOG_DEBUG, "MONO\n");
- break;
- case STEREO:
- if (avctx->channels != 1) {
- q->subpacket[s].bits_per_subpdiv = 1;
- q->subpacket[s].num_channels = 2;
- }
- av_log(avctx, AV_LOG_DEBUG, "STEREO\n");
- break;
- case JOINT_STEREO:
- if (avctx->channels != 2) {
- av_log_ask_for_sample(avctx, "Container channels != 2.\n");
- return AVERROR_PATCHWELCOME;
- }
- av_log(avctx, AV_LOG_DEBUG, "JOINT_STEREO\n");
- if (avctx->extradata_size >= 16) {
- q->subpacket[s].total_subbands = q->subpacket[s].subbands +
- q->subpacket[s].js_subband_start;
- q->subpacket[s].joint_stereo = 1;
- q->subpacket[s].num_channels = 2;
- }
- if (q->subpacket[s].samples_per_channel > 256) {
- q->subpacket[s].log2_numvector_size = 6;
- }
- if (q->subpacket[s].samples_per_channel > 512) {
- q->subpacket[s].log2_numvector_size = 7;
- }
- break;
- case MC_COOK:
- av_log(avctx, AV_LOG_DEBUG, "MULTI_CHANNEL\n");
- if (extradata_size >= 4)
- channel_mask |= q->subpacket[s].channel_mask = bytestream_get_be32(&edata_ptr);
-
- if (av_get_channel_layout_nb_channels(q->subpacket[s].channel_mask) > 1) {
- q->subpacket[s].total_subbands = q->subpacket[s].subbands +
- q->subpacket[s].js_subband_start;
- q->subpacket[s].joint_stereo = 1;
- q->subpacket[s].num_channels = 2;
- q->subpacket[s].samples_per_channel = samples_per_frame >> 1;
-
- if (q->subpacket[s].samples_per_channel > 256) {
- q->subpacket[s].log2_numvector_size = 6;
- }
- if (q->subpacket[s].samples_per_channel > 512) {
- q->subpacket[s].log2_numvector_size = 7;
- }
- } else
- q->subpacket[s].samples_per_channel = samples_per_frame;
-
- break;
- default:
- av_log_ask_for_sample(avctx, "Unknown Cook version.\n");
- return AVERROR_PATCHWELCOME;
- }
-
- if (s > 1 && q->subpacket[s].samples_per_channel != q->samples_per_channel) {
- av_log(avctx, AV_LOG_ERROR, "different number of samples per channel!\n");
- return AVERROR_INVALIDDATA;
- } else
- q->samples_per_channel = q->subpacket[0].samples_per_channel;
-
-
- /* Initialize variable relations */
- q->subpacket[s].numvector_size = (1 << q->subpacket[s].log2_numvector_size);
-
- /* Try to catch some obviously faulty streams, othervise it might be exploitable */
- if (q->subpacket[s].total_subbands > 53) {
- av_log_ask_for_sample(avctx, "total_subbands > 53\n");
- return AVERROR_PATCHWELCOME;
- }
-
- if ((q->subpacket[s].js_vlc_bits > 6) ||
- (q->subpacket[s].js_vlc_bits < 2 * q->subpacket[s].joint_stereo)) {
- av_log(avctx, AV_LOG_ERROR, "js_vlc_bits = %d, only >= %d and <= 6 allowed!\n",
- q->subpacket[s].js_vlc_bits, 2 * q->subpacket[s].joint_stereo);
- return AVERROR_INVALIDDATA;
- }
-
- if (q->subpacket[s].subbands > 50) {
- av_log_ask_for_sample(avctx, "subbands > 50\n");
- return AVERROR_PATCHWELCOME;
- }
- if (q->subpacket[s].subbands == 0) {
- av_log_ask_for_sample(avctx, "subbands is 0\n");
- return AVERROR_PATCHWELCOME;
- }
- q->subpacket[s].gains1.now = q->subpacket[s].gain_1;
- q->subpacket[s].gains1.previous = q->subpacket[s].gain_2;
- q->subpacket[s].gains2.now = q->subpacket[s].gain_3;
- q->subpacket[s].gains2.previous = q->subpacket[s].gain_4;
-
- if (q->num_subpackets + q->subpacket[s].num_channels > q->avctx->channels) {
- av_log(avctx, AV_LOG_ERROR, "Too many subpackets %d for channels %d\n", q->num_subpackets, q->avctx->channels);
- return AVERROR_INVALIDDATA;
- }
-
- q->num_subpackets++;
- s++;
- if (s > MAX_SUBPACKETS) {
- av_log_ask_for_sample(avctx, "Too many subpackets > 5\n");
- return AVERROR_PATCHWELCOME;
- }
- }
- /* Generate tables */
- init_pow2table();
- init_gain_table(q);
- init_cplscales_table(q);
-
- if ((ret = init_cook_vlc_tables(q)))
- return ret;
-
-
- if (avctx->block_align >= UINT_MAX / 2)
- return AVERROR(EINVAL);
-
- /* Pad the databuffer with:
- DECODE_BYTES_PAD1 or DECODE_BYTES_PAD2 for decode_bytes(),
- FF_INPUT_BUFFER_PADDING_SIZE, for the bitstreamreader. */
- q->decoded_bytes_buffer =
- av_mallocz(avctx->block_align
- + DECODE_BYTES_PAD1(avctx->block_align)
- + FF_INPUT_BUFFER_PADDING_SIZE);
- if (q->decoded_bytes_buffer == NULL)
- return AVERROR(ENOMEM);
-
- /* Initialize transform. */
- if ((ret = init_cook_mlt(q)))
- return ret;
-
- /* Initialize COOK signal arithmetic handling */
- if (1) {
- q->scalar_dequant = scalar_dequant_float;
- q->decouple = decouple_float;
- q->imlt_window = imlt_window_float;
- q->interpolate = interpolate_float;
- q->saturate_output = saturate_output_float;
- }
-
- /* Try to catch some obviously faulty streams, othervise it might be exploitable */
- if (q->samples_per_channel != 256 && q->samples_per_channel != 512 &&
- q->samples_per_channel != 1024) {
- av_log_ask_for_sample(avctx,
- "unknown amount of samples_per_channel = %d\n",
- q->samples_per_channel);
- return AVERROR_PATCHWELCOME;
- }
-
- avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
- if (channel_mask)
- avctx->channel_layout = channel_mask;
- else
- avctx->channel_layout = (avctx->channels == 2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
-
-#ifdef DEBUG
- dump_cook_context(q);
-#endif
- return 0;
-}
-
-AVCodec ff_cook_decoder = {
- .name = "cook",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_COOK,
- .priv_data_size = sizeof(COOKContext),
- .init = cook_decode_init,
- .close = cook_decode_close,
- .decode = cook_decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("Cook / Cooker / Gecko (RealAudio G2)"),
- .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
- AV_SAMPLE_FMT_NONE },
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/cookdata.h b/src/thirdparty/ffmpeg/libavcodec/cookdata.h
deleted file mode 100644
index 1e79089d5..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/cookdata.h
+++ /dev/null
@@ -1,580 +0,0 @@
-/*
- * COOK compatible decoder data
- * Copyright (c) 2003 Sascha Sommer
- * Copyright (c) 2005 Benjamin Larsson
- *
- * 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
- * Cook AKA RealAudio G2 compatible decoderdata
- */
-
-#ifndef AVCODEC_COOKDATA_H
-#define AVCODEC_COOKDATA_H
-
-#include <stdint.h>
-
-/* various data tables */
-
-static const int expbits_tab[8] = {
- 52,47,43,37,29,22,16,0,
-};
-
-static const float dither_tab[9] = {
- 0.0, 0.0, 0.0, 0.0, 0.0, 0.176777, 0.25, 0.707107, 1.0
-};
-
-static const float quant_centroid_tab[7][14] = {
- { 0.000, 0.392, 0.761, 1.120, 1.477, 1.832, 2.183, 2.541, 2.893, 3.245, 3.598, 3.942, 4.288, 4.724 },
- { 0.000, 0.544, 1.060, 1.563, 2.068, 2.571, 3.072, 3.562, 4.070, 4.620, 0.000, 0.000, 0.000, 0.000 },
- { 0.000, 0.746, 1.464, 2.180, 2.882, 3.584, 4.316, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000 },
- { 0.000, 1.006, 2.000, 2.993, 3.985, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000 },
- { 0.000, 1.321, 2.703, 3.983, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000 },
- { 0.000, 1.657, 3.491, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000 },
- { 0.000, 1.964, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000 }
-};
-
-static const int invradix_tab[7] = {
- 74899, 104858, 149797, 209716, 262144, 349526, 524288,
-};
-
-static const int kmax_tab[7] = {
- 13, 9, 6, 4, 3, 2, 1,
-};
-
-static const int vd_tab[7] = {
- 2, 2, 2, 4, 4, 5, 5,
-};
-
-static const int vpr_tab[7] = {
- 10, 10, 10, 5, 5, 4, 4,
-};
-
-
-
-/* VLC data */
-
-static const int vhsize_tab[7] = {
- 191, 97, 48, 607, 246, 230, 32,
-};
-
-static const int vhvlcsize_tab[7] = {
- 8, 7, 7, 10, 9, 9, 6,
-};
-
-static const uint8_t envelope_quant_index_huffbits[13][24] = {
- { 4, 6, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 4, 5, 7, 8, 9, 11, 11, 12, 12, 12, 12 },
- { 10, 8, 6, 5, 5, 4, 3, 3, 3, 3, 3, 3, 4, 5, 7, 9, 11, 12, 13, 15, 15, 15, 16, 16 },
- { 12, 10, 8, 6, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 4, 4, 5, 5, 7, 9, 11, 13, 14, 14 },
- { 13, 10, 9, 9, 7, 7, 5, 5, 4, 3, 3, 3, 3, 3, 4, 4, 4, 5, 7, 9, 11, 13, 13, 13 },
- { 12, 13, 10, 8, 6, 6, 5, 5, 4, 4, 3, 3, 3, 3, 3, 4, 5, 5, 6, 7, 9, 11, 14, 14 },
- { 12, 11, 9, 8, 8, 7, 5, 4, 4, 3, 3, 3, 3, 3, 4, 4, 5, 5, 7, 8, 10, 13, 14, 14 },
- { 15, 16, 15, 12, 10, 8, 6, 5, 4, 3, 3, 3, 2, 3, 4, 5, 5, 7, 9, 11, 13, 16, 16, 16 },
- { 14, 14, 11, 10, 9, 7, 7, 5, 5, 4, 3, 3, 2, 3, 3, 4, 5, 7, 9, 9, 12, 14, 15, 15 },
- { 9, 9, 9, 8, 7, 6, 5, 4, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 13 },
- { 14, 12, 10, 8, 6, 6, 5, 4, 3, 3, 3, 3, 3, 3, 4, 5, 6, 8, 8, 9, 11, 14, 14, 14 },
- { 13, 10, 9, 8, 6, 6, 5, 4, 4, 4, 3, 3, 2, 3, 4, 5, 6, 8, 9, 9, 11, 12, 14, 14 },
- { 16, 13, 12, 11, 9, 6, 5, 5, 4, 4, 4, 3, 2, 3, 3, 4, 5, 7, 8, 10, 14, 16, 16, 16 },
- { 13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14 },
-};
-
-static const uint16_t envelope_quant_index_huffcodes[13][24] = {
- {0x0006, 0x003e, 0x001c, 0x001d, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x0000, 0x0001,
- 0x0002, 0x000d, 0x001e, 0x007e, 0x00fe, 0x01fe, 0x07fc, 0x07fd, 0x0ffc, 0x0ffd, 0x0ffe, 0x0fff},
- {0x03fe, 0x00fe, 0x003e, 0x001c, 0x001d, 0x000c, 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005,
- 0x000d, 0x001e, 0x007e, 0x01fe, 0x07fe, 0x0ffe, 0x1ffe, 0x7ffc, 0x7ffd, 0x7ffe, 0xfffe, 0xffff},
- {0x0ffe, 0x03fe, 0x00fe, 0x003e, 0x001c, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x0000,
- 0x0001, 0x0002, 0x000c, 0x000d, 0x001d, 0x001e, 0x007e, 0x01fe, 0x07fe, 0x1ffe, 0x3ffe, 0x3fff},
- {0x1ffc, 0x03fe, 0x01fc, 0x01fd, 0x007c, 0x007d, 0x001c, 0x001d, 0x000a, 0x0000, 0x0001, 0x0002,
- 0x0003, 0x0004, 0x000b, 0x000c, 0x000d, 0x001e, 0x007e, 0x01fe, 0x07fe, 0x1ffd, 0x1ffe, 0x1fff},
- {0x0ffe, 0x1ffe, 0x03fe, 0x00fe, 0x003c, 0x003d, 0x001a, 0x001b, 0x000a, 0x000b, 0x0000, 0x0001,
- 0x0002, 0x0003, 0x0004, 0x000c, 0x001c, 0x001d, 0x003e, 0x007e, 0x01fe, 0x07fe, 0x3ffe, 0x3fff},
- {0x0ffe, 0x07fe, 0x01fe, 0x00fc, 0x00fd, 0x007c, 0x001c, 0x000a, 0x000b, 0x0000, 0x0001, 0x0002,
- 0x0003, 0x0004, 0x000c, 0x000d, 0x001d, 0x001e, 0x007d, 0x00fe, 0x03fe, 0x1ffe, 0x3ffe, 0x3fff},
- {0x7ffc, 0xfffc, 0x7ffd, 0x0ffe, 0x03fe, 0x00fe, 0x003e, 0x001c, 0x000c, 0x0002, 0x0003, 0x0004,
- 0x0000, 0x0005, 0x000d, 0x001d, 0x001e, 0x007e, 0x01fe, 0x07fe, 0x1ffe, 0xfffd, 0xfffe, 0xffff},
- {0x3ffc, 0x3ffd, 0x07fe, 0x03fe, 0x01fc, 0x007c, 0x007d, 0x001c, 0x001d, 0x000c, 0x0002, 0x0003,
- 0x0000, 0x0004, 0x0005, 0x000d, 0x001e, 0x007e, 0x01fd, 0x01fe, 0x0ffe, 0x3ffe, 0x7ffe, 0x7fff},
- {0x01fc, 0x01fd, 0x01fe, 0x00fc, 0x007c, 0x003c, 0x001c, 0x000c, 0x0000, 0x0001, 0x0002, 0x0003,
- 0x0004, 0x0005, 0x000d, 0x001d, 0x003d, 0x007d, 0x00fd, 0x03fe, 0x07fe, 0x0ffe, 0x1ffe, 0x1fff},
- {0x3ffc, 0x0ffe, 0x03fe, 0x00fc, 0x003c, 0x003d, 0x001c, 0x000c, 0x0000, 0x0001, 0x0002, 0x0003,
- 0x0004, 0x0005, 0x000d, 0x001d, 0x003e, 0x00fd, 0x00fe, 0x01fe, 0x07fe, 0x3ffd, 0x3ffe, 0x3fff},
- {0x1ffe, 0x03fe, 0x01fc, 0x00fc, 0x003c, 0x003d, 0x001c, 0x000a, 0x000b, 0x000c, 0x0002, 0x0003,
- 0x0000, 0x0004, 0x000d, 0x001d, 0x003e, 0x00fd, 0x01fd, 0x01fe, 0x07fe, 0x0ffe, 0x3ffe, 0x3fff},
- {0xfffc, 0x1ffe, 0x0ffe, 0x07fe, 0x01fe, 0x003e, 0x001c, 0x001d, 0x000a, 0x000b, 0x000c, 0x0002,
- 0x0000, 0x0003, 0x0004, 0x000d, 0x001e, 0x007e, 0x00fe, 0x03fe, 0x3ffe, 0xfffd, 0xfffe, 0xffff},
- {0x1ffc, 0x3ffa, 0x3ffb, 0x3ffc, 0x03fe, 0x00fe, 0x007c, 0x007d, 0x001c, 0x000c, 0x0002, 0x0003,
- 0x0000, 0x0004, 0x0005, 0x000d, 0x001d, 0x001e, 0x007e, 0x01fe, 0x07fe, 0x3ffd, 0x3ffe, 0x3fff},
-};
-
-
-static const uint8_t cvh_huffbits0[191] = {
- 1, 4, 6, 6, 7, 7, 8, 8, 8, 9, 9, 10,
- 11, 11, 4, 5, 6, 7, 7, 8, 8, 9, 9, 9,
- 9, 10, 11, 11, 5, 6, 7, 8, 8, 9, 9, 9,
- 9, 10, 10, 10, 11, 12, 6, 7, 8, 9, 9, 9,
- 9, 10, 10, 10, 10, 11, 12, 13, 7, 7, 8, 9,
- 9, 9, 10, 10, 10, 10, 11, 11, 12, 13, 8, 8,
- 9, 9, 9, 10, 10, 10, 10, 11, 11, 12, 13, 14,
- 8, 8, 9, 9, 10, 10, 11, 11, 11, 12, 12, 13,
- 13, 15, 8, 8, 9, 9, 10, 10, 11, 11, 11, 12,
- 12, 13, 14, 15, 9, 9, 9, 10, 10, 10, 11, 11,
- 12, 13, 12, 14, 15, 16, 9, 9, 10, 10, 10, 10,
- 11, 12, 12, 14, 14, 16, 16, 0, 9, 9, 10, 10,
- 11, 11, 12, 13, 13, 14, 14, 15, 0, 0, 10, 10,
- 10, 11, 11, 12, 12, 13, 15, 15, 16, 0, 0, 0,
- 11, 11, 11, 12, 13, 13, 13, 15, 16, 16, 0, 0,
- 0, 0, 11, 11, 12, 13, 13, 14, 15, 16, 16,
-};
-
-static const uint16_t cvh_huffcodes0[191] = {
- 0x0000,0x0008,0x002c,0x002d,0x0062,0x0063,0x00d4,0x00d5,0x00d6,0x01c6,0x01c7,0x03ca,
- 0x07d6,0x07d7,0x0009,0x0014,0x002e,0x0064,0x0065,0x00d7,0x00d8,0x01c8,0x01c9,0x01ca,
- 0x01cb,0x03cb,0x07d8,0x07d9,0x0015,0x002f,0x0066,0x00d9,0x00da,0x01cc,0x01cd,0x01ce,
- 0x01cf,0x03cc,0x03cd,0x03ce,0x07da,0x0fe4,0x0030,0x0067,0x00db,0x01d0,0x01d1,0x01d2,
- 0x01d3,0x03cf,0x03d0,0x03d1,0x03d2,0x07db,0x0fe5,0x1fea,0x0068,0x0069,0x00dc,0x01d4,
- 0x01d5,0x01d6,0x03d3,0x03d4,0x03d5,0x03d6,0x07dc,0x07dd,0x0fe6,0x1feb,0x00dd,0x00de,
- 0x01d7,0x01d8,0x01d9,0x03d7,0x03d8,0x03d9,0x03da,0x07de,0x07df,0x0fe7,0x1fec,0x3ff2,
- 0x00df,0x00e0,0x01da,0x01db,0x03db,0x03dc,0x07e0,0x07e1,0x07e2,0x0fe8,0x0fe9,0x1fed,
- 0x1fee,0x7ff4,0x00e1,0x00e2,0x01dc,0x01dd,0x03dd,0x03de,0x07e3,0x07e4,0x07e5,0x0fea,
- 0x0feb,0x1fef,0x3ff3,0x7ff5,0x01de,0x01df,0x01e0,0x03df,0x03e0,0x03e1,0x07e6,0x07e7,
- 0x0fec,0x1ff0,0x0fed,0x3ff4,0x7ff6,0xfff8,0x01e1,0x01e2,0x03e2,0x03e3,0x03e4,0x03e5,
- 0x07e8,0x0fee,0x0fef,0x3ff5,0x3ff6,0xfff9,0xfffa,0xfffa,0x01e3,0x01e4,0x03e6,0x03e7,
- 0x07e9,0x07ea,0x0ff0,0x1ff1,0x1ff2,0x3ff7,0x3ff8,0x7ff7,0x7ff7,0xfffa,0x03e8,0x03e9,
- 0x03ea,0x07eb,0x07ec,0x0ff1,0x0ff2,0x1ff3,0x7ff8,0x7ff9,0xfffb,0x3ff8,0x7ff7,0x7ff7,
- 0x07ed,0x07ee,0x07ef,0x0ff3,0x1ff4,0x1ff5,0x1ff6,0x7ffa,0xfffc,0xfffd,0xfffb,0xfffb,
- 0x3ff8,0x7ff7,0x07f0,0x07f1,0x0ff4,0x1ff7,0x1ff8,0x3ff9,0x7ffb,0xfffe,0xffff,
-};
-
-
-static const uint8_t cvh_huffbits1[97] = {
- 1, 4, 5, 6, 7, 8, 8, 9, 10, 10, 4, 5,
- 6, 7, 7, 8, 8, 9, 9, 11, 5, 5, 6, 7,
- 8, 8, 9, 9, 10, 11, 6, 6, 7, 8, 8, 9,
- 9, 10, 11, 12, 7, 7, 8, 8, 9, 9, 10, 11,
- 11, 13, 8, 8, 8, 9, 9, 10, 10, 11, 12, 14,
- 8, 8, 8, 9, 10, 11, 11, 12, 13, 15, 9, 9,
- 9, 10, 11, 12, 12, 14, 14, 0, 9, 9, 9, 10,
- 11, 12, 14, 16, 0, 0, 10, 10, 11, 12, 13, 14,
- 16,
-};
-
-
-static const uint16_t cvh_huffcodes1[97] = {
- 0x0000,0x0008,0x0014,0x0030,0x006a,0x00e2,0x00e3,0x01e4,0x03ec,0x03ed,0x0009,0x0015,
- 0x0031,0x006b,0x006c,0x00e4,0x00e5,0x01e5,0x01e6,0x07f0,0x0016,0x0017,0x0032,0x006d,
- 0x00e6,0x00e7,0x01e7,0x01e8,0x03ee,0x07f1,0x0033,0x0034,0x006e,0x00e8,0x00e9,0x01e9,
- 0x01ea,0x03ef,0x07f2,0x0ff6,0x006f,0x0070,0x00ea,0x00eb,0x01eb,0x01ec,0x03f0,0x07f3,
- 0x07f4,0x1ffa,0x00ec,0x00ed,0x00ee,0x01ed,0x01ee,0x03f1,0x03f2,0x07f5,0x0ff7,0x3ffa,
- 0x00ef,0x00f0,0x00f1,0x01ef,0x03f3,0x07f6,0x07f7,0x0ff8,0x1ffb,0x7ffe,0x01f0,0x01f1,
- 0x01f2,0x03f4,0x07f8,0x0ff9,0x0ffa,0x3ffb,0x3ffc,0x0000,0x01f3,0x01f4,0x01f5,0x03f5,
- 0x07f9,0x0ffb,0x3ffd,0xfffe,0x0000,0x0000,0x03f6,0x03f7,0x07fa,0x0ffc,0x1ffc,0x3ffe,
- 0xffff,
-};
-
-static const uint8_t cvh_huffbits2[48] = {
- 1, 4, 5, 7, 8, 9, 10, 3, 4, 5, 7, 8,
- 9, 10, 5, 5, 6, 7, 8, 10, 10, 7, 6, 7,
- 8, 9, 10, 12, 8, 8, 8, 9, 10, 12, 14, 8,
- 9, 9, 10, 11, 15, 16, 9, 10, 11, 12, 13, 16,
-};
-
-static const uint16_t cvh_huffcodes2[48] = {
- 0x0000,0x000a,0x0018,0x0074,0x00f2,0x01f4,0x03f6,0x0004,0x000b,0x0019,0x0075,0x00f3,
- 0x01f5,0x03f7,0x001a,0x001b,0x0038,0x0076,0x00f4,0x03f8,0x03f9,0x0077,0x0039,0x0078,
- 0x00f5,0x01f6,0x03fa,0x0ffc,0x00f6,0x00f7,0x00f8,0x01f7,0x03fb,0x0ffd,0x3ffe,0x00f9,
- 0x01f8,0x01f9,0x03fc,0x07fc,0x7ffe,0xfffe,0x01fa,0x03fd,0x07fd,0x0ffe,0x1ffe,0xffff,
-};
-
-static const uint8_t cvh_huffbits3[607] = {
- 2, 4, 6, 8, 10, 5, 5, 6, 8, 10, 7, 8,
- 8, 10, 12, 9, 9, 10, 12, 15, 10, 11, 13, 16,
- 16, 5, 6, 8, 10, 11, 5, 6, 8, 10, 12, 7,
- 7, 8, 10, 13, 9, 9, 10, 12, 15, 12, 11, 13,
- 16, 16, 7, 9, 10, 12, 15, 7, 8, 10, 12, 13,
- 9, 9, 11, 13, 16, 11, 11, 12, 14, 16, 12, 12,
- 14, 16, 0, 9, 11, 12, 16, 16, 9, 10, 13, 15,
- 16, 10, 11, 12, 16, 16, 13, 13, 16, 16, 16, 16,
- 16, 15, 16, 0, 11, 13, 16, 16, 15, 11, 13, 15,
- 16, 16, 13, 13, 16, 16, 0, 14, 16, 16, 16, 0,
- 16, 16, 0, 0, 0, 4, 6, 8, 10, 13, 6, 6,
- 8, 10, 13, 9, 8, 10, 12, 16, 10, 10, 11, 15,
- 16, 13, 12, 14, 16, 16, 5, 6, 8, 11, 13, 6,
- 6, 8, 10, 13, 8, 8, 9, 11, 14, 10, 10, 12,
- 12, 16, 13, 12, 13, 15, 16, 7, 8, 9, 12, 16,
- 7, 8, 10, 12, 14, 9, 9, 10, 13, 16, 11, 10,
- 12, 15, 16, 13, 13, 16, 16, 0, 9, 11, 13, 16,
- 16, 9, 10, 12, 15, 16, 10, 11, 13, 16, 16, 13,
- 12, 16, 16, 16, 16, 16, 16, 16, 0, 11, 13, 16,
- 16, 16, 11, 13, 16, 16, 16, 12, 13, 15, 16, 0,
- 16, 16, 16, 16, 0, 16, 16, 0, 0, 0, 6, 8,
- 11, 13, 16, 8, 8, 10, 12, 16, 11, 10, 11, 13,
- 16, 12, 13, 13, 15, 16, 16, 16, 14, 16, 0, 6,
- 8, 10, 13, 16, 8, 8, 10, 12, 16, 10, 10, 11,
- 13, 16, 13, 12, 13, 16, 16, 14, 14, 14, 16, 0,
- 8, 9, 11, 13, 16, 8, 9, 11, 16, 14, 10, 10,
- 12, 15, 16, 12, 12, 13, 16, 16, 15, 16, 16, 16,
- 0, 10, 12, 15, 16, 16, 10, 12, 12, 14, 16, 12,
- 12, 13, 16, 16, 14, 15, 16, 16, 0, 16, 16, 16,
- 0, 0, 12, 15, 15, 16, 0, 13, 13, 16, 16, 0,
- 14, 16, 16, 16, 0, 16, 16, 16, 0, 0, 0, 0,
- 0, 0, 0, 8, 10, 13, 15, 16, 10, 11, 13, 16,
- 16, 13, 13, 14, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 0, 8, 10, 11, 15, 16, 9, 10, 12,
- 16, 16, 12, 12, 15, 16, 16, 16, 14, 16, 16, 16,
- 16, 16, 16, 16, 0, 9, 11, 14, 16, 16, 10, 11,
- 13, 16, 16, 14, 13, 14, 16, 16, 16, 15, 15, 16,
- 0, 16, 16, 16, 0, 0, 11, 13, 16, 16, 16, 11,
- 13, 15, 16, 16, 13, 16, 16, 16, 0, 16, 16, 16,
- 16, 0, 16, 16, 0, 0, 0, 15, 16, 16, 16, 0,
- 14, 16, 16, 16, 0, 16, 16, 16, 0, 0, 16, 16,
- 0, 0, 0, 0, 0, 0, 0, 0, 9, 13, 16, 16,
- 16, 11, 13, 16, 16, 16, 14, 15, 16, 16, 0, 15,
- 16, 16, 16, 0, 16, 16, 0, 0, 0, 9, 13, 15,
- 15, 16, 12, 13, 14, 16, 16, 16, 15, 16, 16, 0,
- 16, 16, 16, 16, 0, 16, 16, 0, 0, 0, 11, 13,
- 15, 16, 0, 12, 14, 16, 16, 0, 16, 16, 16, 16,
- 0, 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, 16,
- 16, 16, 16, 0, 16, 16, 16, 16, 0, 16, 16, 16,
- 0, 0, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0,
- 16, 16, 0, 0, 0, 16, 16,
-};
-
-
-static const uint16_t cvh_huffcodes3[607] = {
- 0x0000,0x0004,0x0022,0x00c6,0x03b0,0x000c,0x000d,0x0023,0x00c7,0x03b1,0x005c,0x00c8,
- 0x00c9,0x03b2,0x0fa4,0x01c2,0x01c3,0x03b3,0x0fa5,0x7f72,0x03b4,0x07b2,0x1f9a,0xff24,
- 0xff25,0x000e,0x0024,0x00ca,0x03b5,0x07b3,0x000f,0x0025,0x00cb,0x03b6,0x0fa6,0x005d,
- 0x005e,0x00cc,0x03b7,0x1f9b,0x01c4,0x01c5,0x03b8,0x0fa7,0x7f73,0x0fa8,0x07b4,0x1f9c,
- 0xff26,0xff27,0x005f,0x01c6,0x03b9,0x0fa9,0x7f74,0x0060,0x00cd,0x03ba,0x0faa,0x1f9d,
- 0x01c7,0x01c8,0x07b5,0x1f9e,0xff28,0x07b6,0x07b7,0x0fab,0x3fa2,0xff29,0x0fac,0x0fad,
- 0x3fa3,0xff2a,0x3fa2,0x01c9,0x07b8,0x0fae,0xff2b,0xff2c,0x01ca,0x03bb,0x1f9f,0x7f75,
- 0xff2d,0x03bc,0x07b9,0x0faf,0xff2e,0xff2f,0x1fa0,0x1fa1,0xff30,0xff31,0xff32,0xff33,
- 0xff34,0x7f76,0xff35,0xff31,0x07ba,0x1fa2,0xff36,0xff37,0x7f77,0x07bb,0x1fa3,0x7f78,
- 0xff38,0xff39,0x1fa4,0x1fa5,0xff3a,0xff3b,0xff2e,0x3fa4,0xff3c,0xff3d,0xff3e,0xff31,
- 0xff3f,0xff40,0xff30,0xff31,0xff31,0x0005,0x0026,0x00ce,0x03bd,0x1fa6,0x0027,0x0028,
- 0x00cf,0x03be,0x1fa7,0x01cb,0x00d0,0x03bf,0x0fb0,0xff41,0x03c0,0x03c1,0x07bc,0x7f79,
- 0xff42,0x1fa8,0x0fb1,0x3fa5,0xff43,0xff44,0x0010,0x0029,0x00d1,0x07bd,0x1fa9,0x002a,
- 0x002b,0x00d2,0x03c2,0x1faa,0x00d3,0x00d4,0x01cc,0x07be,0x3fa6,0x03c3,0x03c4,0x0fb2,
- 0x0fb3,0xff45,0x1fab,0x0fb4,0x1fac,0x7f7a,0xff46,0x0061,0x00d5,0x01cd,0x0fb5,0xff47,
- 0x0062,0x00d6,0x03c5,0x0fb6,0x3fa7,0x01ce,0x01cf,0x03c6,0x1fad,0xff48,0x07bf,0x03c7,
- 0x0fb7,0x7f7b,0xff49,0x1fae,0x1faf,0xff4a,0xff4b,0x7f7b,0x01d0,0x07c0,0x1fb0,0xff4c,
- 0xff4d,0x01d1,0x03c8,0x0fb8,0x7f7c,0xff4e,0x03c9,0x07c1,0x1fb1,0xff4f,0xff50,0x1fb2,
- 0x0fb9,0xff51,0xff52,0xff53,0xff54,0xff55,0xff56,0xff57,0xff52,0x07c2,0x1fb3,0xff58,
- 0xff59,0xff5a,0x07c3,0x1fb4,0xff5b,0xff5c,0xff5d,0x0fba,0x1fb5,0x7f7d,0xff5e,0xff4f,
- 0xff5f,0xff60,0xff61,0xff62,0xff52,0xff63,0xff64,0xff51,0xff52,0xff52,0x002c,0x00d7,
- 0x07c4,0x1fb6,0xff65,0x00d8,0x00d9,0x03ca,0x0fbb,0xff66,0x07c5,0x03cb,0x07c6,0x1fb7,
- 0xff67,0x0fbc,0x1fb8,0x1fb9,0x7f7e,0xff68,0xff69,0xff6a,0x3fa8,0xff6b,0x7f7e,0x002d,
- 0x00da,0x03cc,0x1fba,0xff6c,0x00db,0x00dc,0x03cd,0x0fbd,0xff6d,0x03ce,0x03cf,0x07c7,
- 0x1fbb,0xff6e,0x1fbc,0x0fbe,0x1fbd,0xff6f,0xff70,0x3fa9,0x3faa,0x3fab,0xff71,0xff6f,
- 0x00dd,0x01d2,0x07c8,0x1fbe,0xff72,0x00de,0x01d3,0x07c9,0xff73,0x3fac,0x03d0,0x03d1,
- 0x0fbf,0x7f7f,0xff74,0x0fc0,0x0fc1,0x1fbf,0xff75,0xff76,0x7f80,0xff77,0xff78,0xff79,
- 0xff75,0x03d2,0x0fc2,0x7f81,0xff7a,0xff7b,0x03d3,0x0fc3,0x0fc4,0x3fad,0xff7c,0x0fc5,
- 0x0fc6,0x1fc0,0xff7d,0xff7e,0x3fae,0x7f82,0xff7f,0xff80,0xff80,0xff81,0xff82,0xff83,
- 0xff80,0xff80,0x0fc7,0x7f83,0x7f84,0xff84,0xff7a,0x1fc1,0x1fc2,0xff85,0xff86,0x3fad,
- 0x3faf,0xff87,0xff88,0xff89,0xff7d,0xff8a,0xff8b,0xff8c,0xff80,0xff80,0x3fae,0x7f82,
- 0xff7f,0xff80,0xff80,0x00df,0x03d4,0x1fc3,0x7f85,0xff8d,0x03d5,0x07ca,0x1fc4,0xff8e,
- 0xff8f,0x1fc5,0x1fc6,0x3fb0,0xff90,0xff91,0xff92,0xff93,0xff94,0xff95,0xff96,0xff97,
- 0xff98,0xff99,0xff9a,0xff95,0x00e0,0x03d6,0x07cb,0x7f86,0xff9b,0x01d4,0x03d7,0x0fc8,
- 0xff9c,0xff9d,0x0fc9,0x0fca,0x7f87,0xff9e,0xff9f,0xffa0,0x3fb1,0xffa1,0xffa2,0xffa3,
- 0xffa4,0xffa5,0xffa6,0xffa7,0xffa2,0x01d5,0x07cc,0x3fb2,0xffa8,0xffa9,0x03d8,0x07cd,
- 0x1fc7,0xffaa,0xffab,0x3fb3,0x1fc8,0x3fb4,0xffac,0xffad,0xffae,0x7f88,0x7f89,0xffaf,
- 0xffaf,0xffb0,0xffb1,0xffb2,0xffaf,0xffaf,0x07ce,0x1fc9,0xffb3,0xffb4,0xffb5,0x07cf,
- 0x1fca,0x7f8a,0xffb6,0xffb7,0x1fcb,0xffb8,0xffb9,0xffba,0xffba,0xffbb,0xffbc,0xffbd,
- 0xffbe,0xffbe,0xffbf,0xffc0,0xffbd,0xffbe,0xffbe,0x7f8b,0xffc1,0xffc2,0xffc3,0xffb4,
- 0x3fb5,0xffc4,0xffc5,0xffc6,0xffb6,0xffc7,0xffc8,0xffc9,0xffba,0xffba,0xffca,0xffcb,
- 0xffbd,0xffbe,0xffbe,0xffbb,0xffbc,0xffbd,0xffbe,0xffbe,0x01d6,0x1fcc,0xffcc,0xffcd,
- 0xffce,0x07d0,0x1fcd,0xffcf,0xffd0,0xffd1,0x3fb6,0x7f8c,0xffd2,0xffd3,0xff90,0x7f8d,
- 0xffd4,0xffd5,0xffd6,0xff95,0xffd7,0xffd8,0xff94,0xff95,0xff95,0x01d7,0x1fce,0x7f8e,
- 0x7f8f,0xffd9,0x0fcb,0x1fcf,0x3fb7,0xffda,0xffdb,0xffdc,0x7f90,0xffdd,0xffde,0xff9e,
- 0xffdf,0xffe0,0xffe1,0xffe2,0xffa2,0xffe3,0xffe4,0xffa1,0xffa2,0xffa2,0x07d1,0x1fd0,
- 0x7f91,0xffe5,0xffa8,0x0fcc,0x3fb8,0xffe6,0xffe7,0xffaa,0xffe8,0xffe9,0xffea,0xffeb,
- 0xffac,0xffec,0xffed,0xffee,0xffaf,0xffaf,0xffae,0x7f88,0x7f89,0xffaf,0xffaf,0xffef,
- 0xfff0,0xfff1,0xfff2,0xffb4,0xfff3,0xfff4,0xfff5,0xfff6,0xffb6,0xfff7,0xfff8,0xfff9,
- 0xffba,0xffba,0xfffa,0xfffb,0xffbd,0xffbe,0xffbe,0xffbb,0xffbc,0xffbd,0xffbe,0xffbe,
- 0xfffc,0xfffd,0xffb3,0xffb4,0xffb4,0xfffe,0xffff,
-};
-
-static const uint8_t cvh_huffbits4[246] = {
- 2, 4, 7, 10, 4, 5, 7, 10, 7, 8, 10, 14,
- 11, 11, 15, 15, 4, 5, 9, 12, 5, 5, 8, 12,
- 8, 7, 10, 15, 11, 11, 15, 15, 7, 9, 12, 15,
- 8, 8, 12, 15, 10, 10, 13, 15, 14, 14, 15, 0,
- 11, 13, 15, 15, 11, 13, 15, 15, 14, 15, 15, 0,
- 15, 15, 0, 0, 4, 5, 9, 13, 5, 6, 9, 13,
- 9, 9, 11, 15, 14, 13, 15, 15, 4, 6, 9, 12,
- 5, 6, 9, 13, 9, 8, 11, 15, 13, 12, 15, 15,
- 7, 9, 12, 15, 7, 8, 11, 15, 10, 10, 14, 15,
- 14, 15, 15, 0, 10, 12, 15, 15, 11, 13, 15, 15,
- 15, 15, 15, 0, 15, 15, 0, 0, 6, 9, 13, 14,
- 8, 9, 12, 15, 12, 12, 15, 15, 15, 15, 15, 0,
- 7, 9, 13, 15, 8, 9, 12, 15, 11, 12, 15, 15,
- 15, 15, 15, 0, 9, 11, 15, 15, 9, 11, 15, 15,
- 14, 14, 15, 0, 15, 15, 0, 0, 14, 15, 15, 0,
- 14, 15, 15, 0, 15, 15, 0, 0, 0, 0, 0, 0,
- 9, 12, 15, 15, 12, 13, 15, 15, 15, 15, 15, 0,
- 15, 15, 0, 0, 10, 12, 15, 15, 12, 14, 15, 15,
- 15, 15, 15, 0, 15, 15, 0, 0, 14, 15, 15, 0,
- 15, 15, 15, 0, 15, 15, 0, 0, 0, 0, 0, 0,
- 15, 15, 0, 0, 15, 15,
-};
-
-
-static const uint16_t cvh_huffcodes4[246] = {
- 0x0000,0x0004,0x006c,0x03e6,0x0005,0x0012,0x006d,0x03e7,0x006e,0x00e8,0x03e8,0x3fc4,
- 0x07e0,0x07e1,0x7fa4,0x7fa5,0x0006,0x0013,0x01e2,0x0fda,0x0014,0x0015,0x00e9,0x0fdb,
- 0x00ea,0x006f,0x03e9,0x7fa6,0x07e2,0x07e3,0x7fa7,0x7fa8,0x0070,0x01e3,0x0fdc,0x7fa9,
- 0x00eb,0x00ec,0x0fdd,0x7faa,0x03ea,0x03eb,0x1fd6,0x7fab,0x3fc5,0x3fc6,0x7fac,0x1fd6,
- 0x07e4,0x1fd7,0x7fad,0x7fae,0x07e5,0x1fd8,0x7faf,0x7fb0,0x3fc7,0x7fb1,0x7fb2,0x1fd6,
- 0x7fb3,0x7fb4,0x1fd6,0x1fd6,0x0007,0x0016,0x01e4,0x1fd9,0x0017,0x0032,0x01e5,0x1fda,
- 0x01e6,0x01e7,0x07e6,0x7fb5,0x3fc8,0x1fdb,0x7fb6,0x7fb7,0x0008,0x0033,0x01e8,0x0fde,
- 0x0018,0x0034,0x01e9,0x1fdc,0x01ea,0x00ed,0x07e7,0x7fb8,0x1fdd,0x0fdf,0x7fb9,0x7fba,
- 0x0071,0x01eb,0x0fe0,0x7fbb,0x0072,0x00ee,0x07e8,0x7fbc,0x03ec,0x03ed,0x3fc9,0x7fbd,
- 0x3fca,0x7fbe,0x7fbf,0x3fc9,0x03ee,0x0fe1,0x7fc0,0x7fc1,0x07e9,0x1fde,0x7fc2,0x7fc3,
- 0x7fc4,0x7fc5,0x7fc6,0x3fc9,0x7fc7,0x7fc8,0x3fc9,0x3fc9,0x0035,0x01ec,0x1fdf,0x3fcb,
- 0x00ef,0x01ed,0x0fe2,0x7fc9,0x0fe3,0x0fe4,0x7fca,0x7fcb,0x7fcc,0x7fcd,0x7fce,0x7fca,
- 0x0073,0x01ee,0x1fe0,0x7fcf,0x00f0,0x01ef,0x0fe5,0x7fd0,0x07ea,0x0fe6,0x7fd1,0x7fd2,
- 0x7fd3,0x7fd4,0x7fd5,0x7fd1,0x01f0,0x07eb,0x7fd6,0x7fd7,0x01f1,0x07ec,0x7fd8,0x7fd9,
- 0x3fcc,0x3fcd,0x7fda,0x7fda,0x7fdb,0x7fdc,0x7fda,0x7fda,0x3fce,0x7fdd,0x7fde,0x7fd6,
- 0x3fcf,0x7fdf,0x7fe0,0x7fd8,0x7fe1,0x7fe2,0x7fda,0x7fda,0x3fcc,0x3fcd,0x7fda,0x7fda,
- 0x01f2,0x0fe7,0x7fe3,0x7fe4,0x0fe8,0x1fe1,0x7fe5,0x7fe6,0x7fe7,0x7fe8,0x7fe9,0x7fca,
- 0x7fea,0x7feb,0x7fca,0x7fca,0x03ef,0x0fe9,0x7fec,0x7fed,0x0fea,0x3fd0,0x7fee,0x7fef,
- 0x7ff0,0x7ff1,0x7ff2,0x7fd1,0x7ff3,0x7ff4,0x7fd1,0x7fd1,0x3fd1,0x7ff5,0x7ff6,0x7fd6,
- 0x7ff7,0x7ff8,0x7ff9,0x7fd8,0x7ffa,0x7ffb,0x7fda,0x7fda,0x3fcc,0x3fcd,0x7fda,0x7fda,
- 0x7ffc,0x7ffd,0x7fd6,0x7fd6,0x7ffe,0x7fff,
-};
-
-
-static const uint8_t cvh_huffbits5[230] = {
- 2, 4, 8, 4, 5, 9, 9, 10, 14, 4, 6, 11,
- 5, 6, 12, 10, 11, 15, 9, 11, 15, 10, 13, 15,
- 14, 15, 0, 4, 6, 12, 6, 7, 12, 12, 12, 15,
- 5, 7, 13, 6, 7, 13, 12, 13, 15, 10, 12, 15,
- 11, 13, 15, 15, 15, 0, 8, 13, 15, 11, 12, 15,
- 15, 15, 0, 10, 13, 15, 12, 15, 15, 15, 15, 0,
- 15, 15, 0, 15, 15, 0, 0, 0, 0, 4, 5, 11,
- 5, 7, 12, 11, 12, 15, 6, 7, 13, 7, 8, 14,
- 12, 14, 15, 11, 13, 15, 12, 13, 15, 15, 15, 0,
- 5, 6, 13, 7, 8, 15, 12, 14, 15, 6, 8, 14,
- 7, 8, 15, 14, 15, 15, 12, 12, 15, 12, 13, 15,
- 15, 15, 0, 9, 13, 15, 12, 13, 15, 15, 15, 0,
- 11, 13, 15, 13, 13, 15, 15, 15, 0, 14, 15, 0,
- 15, 15, 0, 0, 0, 0, 8, 10, 15, 11, 12, 15,
- 15, 15, 0, 10, 12, 15, 12, 13, 15, 15, 15, 0,
- 14, 15, 0, 15, 15, 0, 0, 0, 0, 8, 12, 15,
- 12, 13, 15, 15, 15, 0, 11, 13, 15, 13, 15, 15,
- 15, 15, 0, 15, 15, 0, 15, 15, 0, 0, 0, 0,
- 14, 15, 0, 15, 15, 0, 0, 0, 0, 15, 15, 0,
- 15, 15,
-};
-
-
-
-static const uint16_t cvh_huffcodes5[230] = {
- 0x0000,0x0004,0x00f0,0x0005,0x0012,0x01f0,0x01f1,0x03e8,0x3fce,0x0006,0x0030,0x07de,
- 0x0013,0x0031,0x0fd2,0x03e9,0x07df,0x7fb0,0x01f2,0x07e0,0x7fb1,0x03ea,0x1fd2,0x7fb2,
- 0x3fcf,0x7fb3,0x0031,0x0007,0x0032,0x0fd3,0x0033,0x0070,0x0fd4,0x0fd5,0x0fd6,0x7fb4,
- 0x0014,0x0071,0x1fd3,0x0034,0x0072,0x1fd4,0x0fd7,0x1fd5,0x7fb5,0x03eb,0x0fd8,0x7fb6,
- 0x07e1,0x1fd6,0x7fb7,0x7fb8,0x7fb9,0x0072,0x00f1,0x1fd7,0x7fba,0x07e2,0x0fd9,0x7fbb,
- 0x7fbc,0x7fbd,0x0070,0x03ec,0x1fd8,0x7fbe,0x0fda,0x7fbf,0x7fc0,0x7fc1,0x7fc2,0x0072,
- 0x7fc3,0x7fc4,0x0071,0x7fc5,0x7fc6,0x0072,0x0034,0x0072,0x0072,0x0008,0x0015,0x07e3,
- 0x0016,0x0073,0x0fdb,0x07e4,0x0fdc,0x7fc7,0x0035,0x0074,0x1fd9,0x0075,0x00f2,0x3fd0,
- 0x0fdd,0x3fd1,0x7fc8,0x07e5,0x1fda,0x7fc9,0x0fde,0x1fdb,0x7fca,0x7fcb,0x7fcc,0x00f2,
- 0x0017,0x0036,0x1fdc,0x0076,0x00f3,0x7fcd,0x0fdf,0x3fd2,0x7fce,0x0037,0x00f4,0x3fd3,
- 0x0077,0x00f5,0x7fcf,0x3fd4,0x7fd0,0x7fd1,0x0fe0,0x0fe1,0x7fd2,0x0fe2,0x1fdd,0x7fd3,
- 0x7fd4,0x7fd5,0x00f5,0x01f3,0x1fde,0x7fd6,0x0fe3,0x1fdf,0x7fd7,0x7fd8,0x7fd9,0x00f3,
- 0x07e6,0x1fe0,0x7fda,0x1fe1,0x1fe2,0x7fdb,0x7fdc,0x7fdd,0x00f5,0x3fd5,0x7fde,0x00f4,
- 0x7fdf,0x7fe0,0x00f5,0x0077,0x00f5,0x00f5,0x00f6,0x03ed,0x7fe1,0x07e7,0x0fe4,0x7fe2,
- 0x7fe3,0x7fe4,0x0073,0x03ee,0x0fe5,0x7fe5,0x0fe6,0x1fe3,0x7fe6,0x7fe7,0x7fe8,0x00f2,
- 0x3fd6,0x7fe9,0x0074,0x7fea,0x7feb,0x00f2,0x0075,0x00f2,0x00f2,0x00f7,0x0fe7,0x7fec,
- 0x0fe8,0x1fe4,0x7fed,0x7fee,0x7fef,0x00f3,0x07e8,0x1fe5,0x7ff0,0x1fe6,0x7ff1,0x7ff2,
- 0x7ff3,0x7ff4,0x00f5,0x7ff5,0x7ff6,0x00f4,0x7ff7,0x7ff8,0x00f5,0x0077,0x00f5,0x00f5,
- 0x3fd7,0x7ff9,0x0036,0x7ffa,0x7ffb,0x00f3,0x0076,0x00f3,0x00f3,0x7ffc,0x7ffd,0x0000,
- 0x7ffe,0x7fff,
-};
-
-
-static const uint8_t cvh_huffbits6[32] = {
- 1, 4, 4, 6, 4, 6, 6, 8, 4, 6, 6, 8,
- 6, 9, 8, 10, 4, 6, 7, 8, 6, 9, 8, 11,
- 6, 9, 8, 10, 8, 10, 9, 11,
-};
-
-static const uint16_t cvh_huffcodes6[32] = {
- 0x0000,0x0008,0x0009,0x0034,0x000a,0x0035,0x0036,0x00f6,0x000b,0x0037,0x0038,0x00f7,
- 0x0039,0x01fa,0x00f8,0x03fc,0x000c,0x003a,0x007a,0x00f9,0x003b,0x01fb,0x00fa,0x07fe,
- 0x003c,0x01fc,0x00fb,0x03fd,0x00fc,0x03fe,0x01fd,0x07ff,
-};
-
-static const uint16_t* const cvh_huffcodes[7] = {
- cvh_huffcodes0, cvh_huffcodes1, cvh_huffcodes2, cvh_huffcodes3,
- cvh_huffcodes4, cvh_huffcodes5, cvh_huffcodes6,
-};
-
-static const uint8_t* const cvh_huffbits[7] = {
- cvh_huffbits0, cvh_huffbits1, cvh_huffbits2, cvh_huffbits3,
- cvh_huffbits4, cvh_huffbits5, cvh_huffbits6,
-};
-
-
-static const uint16_t ccpl_huffcodes2[3] = {
- 0x02,0x00,0x03,
-};
-
-static const uint16_t ccpl_huffcodes3[7] = {
- 0x3e,0x1e,0x02,0x00,0x06,0x0e,0x3f,
-};
-
-static const uint16_t ccpl_huffcodes4[15] = {
- 0xfc,0xfd,0x7c,0x3c,0x1c,0x0c,0x04,0x00,0x05,0x0d,0x1d,0x3d,
- 0x7d,0xfe,0xff,
-};
-
-static const uint16_t ccpl_huffcodes5[31] = {
- 0x03f8,0x03f9,0x03fa,0x03fb,0x01f8,0x01f9,0x00f8,0x00f9,0x0078,0x0079,0x0038,0x0039,
- 0x0018,0x0019,0x0004,0x0000,0x0005,0x001a,0x001b,0x003a,0x003b,0x007a,0x007b,0x00fa,
- 0x00fb,0x01fa,0x01fb,0x03fc,0x03fd,0x03fe,0x03ff,
-};
-
-static const uint16_t ccpl_huffcodes6[63] = {
- 0x0004,0x0005,0x0005,0x0006,0x0006,0x0007,0x0007,0x0007,0x0007,0x0008,0x0008,0x0008,
- 0x0008,0x0009,0x0009,0x0009,0x0009,0x000a,0x000a,0x000a,0x000a,0x000a,0x000b,0x000b,
- 0x000b,0x000b,0x000c,0x000d,0x000e,0x000e,0x0010,0x0000,0x000a,0x0018,0x0019,0x0036,
- 0x0037,0x0074,0x0075,0x0076,0x0077,0x00f4,0x00f5,0x00f6,0x00f7,0x01f5,0x01f6,0x01f7,
- 0x01f8,0x03f6,0x03f7,0x03f8,0x03f9,0x03fa,0x07fa,0x07fb,0x07fc,0x07fd,0x0ffd,0x1ffd,
- 0x3ffd,0x3ffe,0xffff,
-};
-
-static const uint8_t ccpl_huffbits2[3] = {
- 2,1,2,
-};
-
-static const uint8_t ccpl_huffbits3[7] = {
- 6,5,2,1,3,4,6,
-};
-
-static const uint8_t ccpl_huffbits4[15] = {
- 8,8,7,6,5,4,3,1,3,4,5,6,7,8,8,
-};
-
-static const uint8_t ccpl_huffbits5[31] = {
- 10,10,10,10,9,9,8,8,7,7,6,6,
- 5,5,3,1,3,5,5,6,6,7,7,8,
- 8,9,9,10,10,10,10,
-};
-
-static const uint8_t ccpl_huffbits6[63] = {
- 16,15,14,13,12,11,11,11,11,10,10,10,
- 10,9,9,9,9,9,8,8,8,8,7,7,
- 7,7,6,6,5,5,3,1,4,5,5,6,
- 6,7,7,7,7,8,8,8,8,9,9,9,
- 9,10,10,10,10,10,11,11,11,11,12,13,
- 14,14,16,
-};
-
-static const uint16_t* const ccpl_huffcodes[5] = {
- ccpl_huffcodes2,ccpl_huffcodes3,
- ccpl_huffcodes4,ccpl_huffcodes5,ccpl_huffcodes6
-};
-
-static const uint8_t* const ccpl_huffbits[5] = {
- ccpl_huffbits2,ccpl_huffbits3,
- ccpl_huffbits4,ccpl_huffbits5,ccpl_huffbits6
-};
-
-
-//Coupling tables
-
-static const int cplband[51] = {
- 0,1,2,3,4,5,6,7,8,9,
- 10,11,11,12,12,13,13,14,14,14,
- 15,15,15,15,16,16,16,16,16,17,
- 17,17,17,17,17,18,18,18,18,18,
- 18,18,19,19,19,19,19,19,19,19,
- 19,
-};
-
-// The 1 and 0 at the beginning/end are to prevent overflows with
-// bitstream-read indexes. E.g. if n_bits=5, we can access any
-// index from [1, (1<<n_bits)] for the first decoupling coeff,
-// and (1<<n_bits)-coeff1 as index for coeff2, i.e.:
-// coeff1_idx = [1, 32], and coeff2_idx = [0, 31].
-// These values aren't part of the tables in the original binary.
-
-static const float cplscale2[5] = {
-1,
-0.953020632266998,0.70710676908493,0.302905440330505,
-0,
-};
-
-static const float cplscale3[9] = {
-1,
-0.981279790401459,0.936997592449188,0.875934481620789,0.70710676908493,
-0.482430040836334,0.349335819482803,0.192587479948997,
-0,
-};
-
-static const float cplscale4[17] = {
-1,
-0.991486728191376,0.973249018192291,0.953020632266998,0.930133521556854,
-0.903453230857849,0.870746195316315,0.826180458068848,0.70710676908493,
-0.563405573368073,0.491732746362686,0.428686618804932,0.367221474647522,
-0.302905440330505,0.229752898216248,0.130207896232605,
-0,
-};
-
-static const float cplscale5[33] = {
-1,
-0.995926380157471,0.987517595291138,0.978726446628571,0.969505727291107,
-0.95979779958725,0.949531257152557,0.938616216182709,0.926936149597168,
-0.914336204528809,0.900602877140045,0.885426938533783,0.868331849575043,
-0.84851086139679,0.824381768703461,0.791833400726318,0.70710676908493,
-0.610737144947052,0.566034197807312,0.529177963733673,0.495983630418777,
-0.464778542518616,0.434642940759659,0.404955863952637,0.375219136476517,
-0.344963222742081,0.313672333955765,0.280692428350449,0.245068684220314,
-0.205169528722763,0.157508864998817,0.0901700109243393,
-0,
-};
-
-static const float cplscale6[65] = {
-1,
-0.998005926609039,0.993956744670868,0.989822506904602,0.985598564147949,
-0.981279790401459,0.976860702037811,0.972335040569305,0.967696130275726,
-0.962936460971832,0.958047747612000,0.953020632266998,0.947844684123993,
-0.942508161067963,0.936997592449188,0.931297719478607,0.925390899181366,
-0.919256627559662,0.912870943546295,0.906205296516418,0.899225592613220,
-0.891890347003937,0.884148240089417,0.875934481620789,0.867165684700012,
-0.857730865478516,0.847477376461029,0.836184680461884,0.823513329029083,
-0.808890223503113,0.791194140911102,0.767520070075989,0.707106769084930,
-0.641024887561798,0.611565053462982,0.587959706783295,0.567296981811523,
-0.548448026180267,0.530831515789032,0.514098942279816,0.498019754886627,
-0.482430040836334,0.467206478118896,0.452251672744751,0.437485188245773,
-0.422837972640991,0.408248275518417,0.393658757209778,0.379014074802399,
-0.364258885383606,0.349335819482803,0.334183186292648,0.318732559680939,
-0.302905440330505,0.286608695983887,0.269728302955627,0.252119421958923,
-0.233590632677078,0.213876649737358,0.192587479948997,0.169101938605309,
-0.142307326197624,0.109772264957428,0.0631198287010193,
-0,
-};
-
-static const float* const cplscales[5] = {
- cplscale2, cplscale3, cplscale4, cplscale5, cplscale6,
-};
-
-#endif /* AVCODEC_COOKDATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/copy_block.h b/src/thirdparty/ffmpeg/libavcodec/copy_block.h
deleted file mode 100644
index a73910d80..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/copy_block.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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_COPY_BLOCK_H
-#define AVCODEC_COPY_BLOCK_H
-
-#include <stdint.h>
-
-#include "libavutil/intreadwrite.h"
-
-static inline void copy_block2(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
-{
- int i;
- for(i=0; i<h; i++)
- {
- AV_COPY16U(dst, src);
- dst+=dstStride;
- src+=srcStride;
- }
-}
-
-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++)
- {
- AV_COPY32U(dst, src);
- 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++)
- {
- AV_COPY64U(dst, src);
- dst+=dstStride;
- src+=srcStride;
- }
-}
-
-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_COPY128U(dst, src);
- dst+=dstStride;
- src+=srcStride;
- }
-}
-
-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_COPY64U(dst, src);
- dst[8]= src[8];
- 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++)
- {
- AV_COPY128U(dst, src);
- dst[16]= src[16];
- dst+=dstStride;
- src+=srcStride;
- }
-}
-
-#endif /* AVCODEC_COPY_BLOCK_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/dca.c b/src/thirdparty/ffmpeg/libavcodec/dca.c
deleted file mode 100644
index 23c0bf490..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/dca.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * DCA compatible decoder data
- * Copyright (C) 2004 Gildas Bazin
- * Copyright (C) 2004 Benjamin Zores
- * Copyright (C) 2006 Benjamin Larsson
- * Copyright (C) 2007 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 <stdint.h>
-
-#include "dca.h"
-
-const uint32_t avpriv_dca_sample_rates[16] =
-{
- 0, 8000, 16000, 32000, 0, 0, 11025, 22050, 44100, 0, 0,
- 12000, 24000, 48000, 96000, 192000
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/dca.h b/src/thirdparty/ffmpeg/libavcodec/dca.h
deleted file mode 100644
index eec7b6f22..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/dca.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * DCA compatible decoder
- * Copyright (C) 2004 Gildas Bazin
- * Copyright (C) 2004 Benjamin Zores
- * Copyright (C) 2006 Benjamin Larsson
- * Copyright (C) 2007 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_DCA_H
-#define AVCODEC_DCA_H
-
-#include <stdint.h>
-#include "libavutil/internal.h"
-
-/** DCA syncwords, also used for bitstream type detection */
-#define DCA_MARKER_RAW_BE 0x7FFE8001
-#define DCA_MARKER_RAW_LE 0xFE7F0180
-#define DCA_MARKER_14B_BE 0x1FFFE800
-#define DCA_MARKER_14B_LE 0xFF1F00E8
-
-/** DCA-HD specific block starts with this marker. */
-#define DCA_HD_MARKER 0x64582025
-
-extern av_export const uint32_t avpriv_dca_sample_rates[16];
-
-#endif /* AVCODEC_DCA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/dca_parser.c b/src/thirdparty/ffmpeg/libavcodec/dca_parser.c
deleted file mode 100644
index d842b0f20..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/dca_parser.c
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * DCA parser
- * Copyright (C) 2004 Gildas Bazin
- * Copyright (C) 2004 Benjamin Zores
- * Copyright (C) 2006 Benjamin Larsson
- * Copyright (C) 2007 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 "parser.h"
-#include "dca.h"
-#include "dca_parser.h"
-#include "get_bits.h"
-#include "put_bits.h"
-
-typedef struct DCAParseContext {
- ParseContext pc;
- uint32_t lastmarker;
- int size;
- int framesize;
- int hd_pos;
-} DCAParseContext;
-
-#define IS_MARKER(state, i, buf, buf_size) \
- ((state == DCA_MARKER_14B_LE && (i < buf_size-2) && (buf[i+1] & 0xF0) == 0xF0 && buf[i+2] == 0x07) \
- || (state == DCA_MARKER_14B_BE && (i < buf_size-2) && buf[i+1] == 0x07 && (buf[i+2] & 0xF0) == 0xF0) \
- || state == DCA_MARKER_RAW_LE || state == DCA_MARKER_RAW_BE || state == DCA_HD_MARKER)
-
-/**
- * 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 dca_find_frame_end(DCAParseContext * pc1, const uint8_t * buf,
- int buf_size)
-{
- int start_found, i;
- uint32_t state;
- ParseContext *pc = &pc1->pc;
-
- start_found = pc->frame_start_found;
- state = pc->state;
-
- i = 0;
- if (!start_found) {
- for (i = 0; i < buf_size; i++) {
- state = (state << 8) | buf[i];
- if (IS_MARKER(state, i, buf, buf_size)) {
- if (!pc1->lastmarker || state == pc1->lastmarker || pc1->lastmarker == DCA_HD_MARKER) {
- start_found = 1;
- pc1->lastmarker = state;
- break;
- }
- }
- }
- }
- if (start_found) {
- for (; i < buf_size; i++) {
- pc1->size++;
- state = (state << 8) | buf[i];
- if (state == DCA_HD_MARKER && !pc1->hd_pos)
- pc1->hd_pos = pc1->size;
- if (IS_MARKER(state, i, buf, buf_size) && (state == pc1->lastmarker || pc1->lastmarker == DCA_HD_MARKER)) {
- if(pc1->framesize > pc1->size)
- continue;
- // We have to check that we really read a full frame here, and that it isn't a pure HD frame, because their size is not constant.
- if(!pc1->framesize && state == pc1->lastmarker && state != DCA_HD_MARKER){
- pc1->framesize = pc1->hd_pos ? pc1->hd_pos : pc1->size;
- }
- pc->frame_start_found = 0;
- pc->state = -1;
- pc1->size = 0;
- return i - 3;
- }
- }
- }
- pc->frame_start_found = start_found;
- pc->state = state;
- return END_NOT_FOUND;
-}
-
-static av_cold int dca_parse_init(AVCodecParserContext * s)
-{
- DCAParseContext *pc1 = s->priv_data;
-
- pc1->lastmarker = 0;
- return 0;
-}
-
-int ff_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst,
- int max_size)
-{
- uint32_t mrk;
- int i, tmp;
- const uint16_t *ssrc = (const uint16_t *) src;
- uint16_t *sdst = (uint16_t *) dst;
- PutBitContext pb;
-
- if ((unsigned) src_size > (unsigned) max_size)
- src_size = max_size;
-
- mrk = AV_RB32(src);
- switch (mrk) {
- case DCA_MARKER_RAW_BE:
- memcpy(dst, src, src_size);
- return src_size;
- case DCA_MARKER_RAW_LE:
- for (i = 0; i < (src_size + 1) >> 1; i++)
- *sdst++ = av_bswap16(*ssrc++);
- return src_size;
- case DCA_MARKER_14B_BE:
- case DCA_MARKER_14B_LE:
- init_put_bits(&pb, dst, max_size);
- for (i = 0; i < (src_size + 1) >> 1; i++, src += 2) {
- tmp = ((mrk == DCA_MARKER_14B_BE) ? AV_RB16(src) : AV_RL16(src)) & 0x3FFF;
- put_bits(&pb, 14, tmp);
- }
- flush_put_bits(&pb);
- return (put_bits_count(&pb) + 7) >> 3;
- default:
- return AVERROR_INVALIDDATA;
- }
-}
-
-static int dca_parse_params(const uint8_t *buf, int buf_size, int *duration,
- int *sample_rate)
-{
- GetBitContext gb;
- uint8_t hdr[12 + FF_INPUT_BUFFER_PADDING_SIZE] = { 0 };
- int ret, sample_blocks, sr_code;
-
- if (buf_size < 12)
- return AVERROR_INVALIDDATA;
-
- if ((ret = ff_dca_convert_bitstream(buf, 12, hdr, 12)) < 0)
- return ret;
-
- init_get_bits(&gb, hdr, 96);
-
- skip_bits_long(&gb, 39);
- sample_blocks = get_bits(&gb, 7) + 1;
- if (sample_blocks < 8)
- return AVERROR_INVALIDDATA;
- *duration = 256 * (sample_blocks / 8);
-
- skip_bits(&gb, 20);
- sr_code = get_bits(&gb, 4);
- *sample_rate = avpriv_dca_sample_rates[sr_code];
- if (*sample_rate == 0)
- return AVERROR_INVALIDDATA;
-
- return 0;
-}
-
-static int dca_parse(AVCodecParserContext * s,
- AVCodecContext * avctx,
- const uint8_t ** poutbuf, int *poutbuf_size,
- const uint8_t * buf, int buf_size)
-{
- DCAParseContext *pc1 = s->priv_data;
- ParseContext *pc = &pc1->pc;
- int next, duration, sample_rate;
-
- if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) {
- next = buf_size;
- } else {
- next = dca_find_frame_end(pc1, buf, buf_size);
-
- if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
- *poutbuf = NULL;
- *poutbuf_size = 0;
- return buf_size;
- }
- }
-
- /* read the duration and sample rate from the frame header */
- if (!dca_parse_params(buf, buf_size, &duration, &sample_rate)) {
- s->duration = duration;
- avctx->sample_rate = sample_rate;
- } else
- s->duration = 0;
-
- *poutbuf = buf;
- *poutbuf_size = buf_size;
- return next;
-}
-
-AVCodecParser ff_dca_parser = {
- .codec_ids = { AV_CODEC_ID_DTS },
- .priv_data_size = sizeof(DCAParseContext),
- .parser_init = dca_parse_init,
- .parser_parse = dca_parse,
- .parser_close = ff_parse_close,
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/dca_parser.h b/src/thirdparty/ffmpeg/libavcodec/dca_parser.h
deleted file mode 100644
index 0cf8e07dc..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/dca_parser.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * DCA parser
- * Copyright (C) 2004 Gildas Bazin
- * Copyright (C) 2004 Benjamin Zores
- * Copyright (C) 2006 Benjamin Larsson
- * Copyright (C) 2007 Konstantin Shishkov
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_DCA_PARSER_H
-#define AVCODEC_DCA_PARSER_H
-
-#include <stdint.h>
-
-/**
- * Convert bitstream to one representation based on sync marker
- */
-int ff_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst,
- int max_size);
-
-#endif /* AVCODEC_DCA_PARSER_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/dcadata.h b/src/thirdparty/ffmpeg/libavcodec/dcadata.h
deleted file mode 100644
index 81e9469e0..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/dcadata.h
+++ /dev/null
@@ -1,7664 +0,0 @@
-/*
- * DCA compatible decoder data
- * Copyright (C) 2004 Gildas Bazin
- * Copyright (c) 2006 Benjamin Larsson
- *
- * 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_DCADATA_H
-#define AVCODEC_DCADATA_H
-
-#include <stdint.h>
-#include "libavutil/mem.h"
-
-/* Generic tables */
-
-static const uint32_t dca_bit_rates[32] =
-{
- 32000, 56000, 64000, 96000, 112000, 128000,
- 192000, 224000, 256000, 320000, 384000,
- 448000, 512000, 576000, 640000, 768000,
- 896000, 1024000, 1152000, 1280000, 1344000,
- 1408000, 1411200, 1472000, 1536000, 1920000,
- 2048000, 3072000, 3840000, 1/*open*/, 2/*variable*/, 3/*lossless*/
-};
-
-static const uint8_t dca_channels[16] =
-{
- 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8
-};
-
-static const uint8_t dca_bits_per_sample[7] =
-{
- 16, 16, 20, 20, 0, 24, 24
-};
-
-
-/* Adpcm data */
-
-/* 16bits signed fractional Q13 binary codes */
-static const int16_t adpcm_vb[4096][4] =
-{
- { 9928, -2618, -1093, -1263 },
- { 11077, -2876, -1747, -308 },
- { 10503, -1082, -1426, -1167 },
- { 9337, -2403, -1495, 274 },
- { 10698, -2529, -532, -1122 },
- { 10368, -3974, -1264, -750 },
- { 10070, -3667, 346, 863 },
- { 10278, -3093, 311, -576 },
- { 9894, -1330, -1428, -860 },
- { 10544, -1923, -1058, -971 },
- { 10996, -1632, -841, -1404 },
- { 11832, -3465, 1658, -1990 },
- { 10852, -688, -2658, -499 },
- { 10546, -1749, -147, -1733 },
- { 10801, -1004, -708, -1453 },
- { 10588, -441, -2113, -952 },
- { 10141, -3331, -582, -1432 },
- { 9608, -2590, 383, 258 },
- { 11422, -3265, 229, -1544 },
- { 10460, -1338, -713, -1568 },
- { 10306, -1721, -1660, -603 },
- { 9580, -1812, -1235, -1061 },
- { 11471, -2285, -1617, -607 },
- { 10081, -2225, -1408, -868 },
- { 10715, -2624, -1367, -704 },
- { 10616, -1871, -2770, -35 },
- { 9352, -2340, -1024, -1566 },
- { 11065, -1458, -1926, -735 },
- { 11334, -2056, -1041, -1144 },
- { 9825, -2048, -794, -1536 },
- { 11850, -2695, -1123, -867 },
- { 10654, -2226, -1891, -373 },
- { 10024, -1557, -808, -1069 },
- { 11142, -1266, -3238, 128 },
- { 11729, -3282, -514, -1011 },
- { 11402, -2094, -2335, -189 },
- { 10195, -3658, 181, -1875 },
- { 11431, -2626, -404, -1377 },
- { 11001, -3868, -619, -1077 },
- { 10894, -2559, 274, -1758 },
- { 9633, -1482, -2253, -773 },
- { 11245, -3321, 830, -1972 },
- { 9768, -2701, -199, -1859 },
- { 10500, -2042, 525, -2043 },
- { 11669, -4069, 293, -1468 },
- { 9192, -1991, -583, -61 },
- { 10057, -3220, -2015, -473 },
- { 9497, -2315, -2490, -467 },
- { 10455, -3069, -1194, -1007 },
- { 9994, -1936, -60, -1225 },
- { 9295, -2156, -1761, -1134 },
- { 10085, -3748, -1026, 197 },
- { 9334, -2360, 804, -351 },
- { 11561, -2553, 1352, -2313 },
- { 12837, -3998, 1195, -1958 },
- { 10114, -1100, -2414, -394 },
- { 9341, -2530, 315, 755 },
- { 10131, -3164, 1411, -674 },
- { 9535, -905, -1551, 579 },
- { 11717, -1519, -3051, 91 },
- { 9824, -2911, -2775, 192 },
- { 9662, -2934, -561, 1450 },
- { 11085, -3392, -1298, -659 },
- { 8955, -2102, -1899, 703 },
- { 8607, -1742, -4348, 814 },
- { 7640, -2063, -3617, 52 },
- { 7074, -826, -4325, 4375 },
- { 7714, 584, -4238, 1927 },
- { 6355, -952, -4912, 3127 },
- { 7069, -660, -6413, 4087 },
- { 8313, -132, -2964, -876 },
- { 6952, -1422, -3962, -24 },
- { 9299, -734, -3088, -263 },
- { 9484, -574, -4513, 466 },
- { 7246, -91, -3735, -704 },
- { 8325, -1417, -3090, -530 },
- { 6469, -1226, -4757, 829 },
- { 6652, -368, -5682, 1393 },
- { 7971, -1278, -2284, 1205 },
- { 7229, -699, -3556, 1840 },
- { 7994, 1284, -2729, 732 },
- { 9005, -698, -4522, 2189 },
- { 6963, 197, -2727, 380 },
- { 8527, 135, -3991, -213 },
- { 8840, 934, -3014, -567 },
- { 10125, 418, -3284, -371 },
- { 6367, 361, -2318, 2554 },
- { 7892, 172, -5247, 4673 },
- { 6674, 387, -5424, 4398 },
- { 6240, 684, -4047, 1219 },
- { 11170, -794, -5081, 1195 },
- { 11765, -648, -6265, 2052 },
- { 10845, -775, -3837, 366 },
- { 12496, -689, -8260, 3562 },
- { 7893, -1166, -4972, 988 },
- { 8592, 1052, -5986, 3087 },
- { 7277, 1874, -5685, 3579 },
- { 6900, 2016, -4809, 3491 },
- { 8530, -2405, -3250, 1986 },
- { 9426, 494, -7067, 5038 },
- { 10285, 564, -8210, 5370 },
- { 8749, -2207, -3980, 2852 },
- { 9653, -2686, -4300, 1400 },
- { 9770, -2286, -5663, 4233 },
- { 8490, -4, -7048, 4496 },
- { 7697, -1209, -5328, 3183 },
- { 6451, 801, -4324, -554 },
- { 7387, 1806, -5265, 545 },
- { 7450, -2302, -4445, 1418 },
- { 8817, -1370, -5827, 2168 },
- { 10324, -2406, -5629, 2579 },
- { 8863, -2578, -3537, 467 },
- { 6901, -1624, -3169, 3392 },
- { 7846, 156, -6948, 3381 },
- { 7928, -1115, -5972, 4816 },
- { 6089, -599, -4368, -320 },
- { 7833, 1246, -3960, -621 },
- { 8931, 2521, -6768, 2052 },
- { 8900, 1944, -4126, 40 },
- { 7661, -34, -2855, 2480 },
- { 5873, 474, -3262, 3712 },
- { 7535, -234, -4699, 216 },
- { 5856, 143, -5142, 73 },
- { 8944, -106, -5874, 3663 },
- { 7134, 426, -5879, 2895 },
- { 10199, 1011, -4762, 369 },
- { 8454, 264, -5971, 1291 },
- { 7822, -2449, -4333, 4540 },
- { 6200, -2758, -2632, 1497 },
- { 6070, -4315, -2699, 414 },
- { 7047, -3739, -3210, 1060 },
- { 5675, -3801, -2717, -407 },
- { 4789, -4063, -2628, -744 },
- { 4023, -3366, -3133, -726 },
- { 4296, -2407, -3381, -513 },
- { 4388, -2931, -2820, 1512 },
- { 4559, -4233, -1941, 1976 },
- { 6702, -3208, -1755, 1680 },
- { 4416, -3521, -1052, 2984 },
- { 7154, -4266, -1203, 3732 },
- { 3625, -4242, -3244, 1395 },
- { 6518, -2856, -1304, 2887 },
- { 6170, -1949, -3014, 3973 },
- { 5189, -2451, -4020, 3477 },
- { 6218, -2988, -1921, 3844 },
- { 4827, -3688, -1928, 3343 },
- { 6668, -3991, -2805, 3095 },
- { 5297, -3115, -3684, 2390 },
- { 5354, -4614, -2662, 1504 },
- { 4196, -3091, -4147, 1135 },
- { 3540, -2893, -4007, 100 },
- { 5569, -1602, -4007, 1909 },
- { 4341, -2091, -4272, 252 },
- { 5559, -2878, -3832, 498 },
- { 4548, -4479, -2898, -27 },
- { 5176, -2494, -4635, 1476 },
- { 3294, -3485, -3738, 716 },
- { 4920, -1229, -4195, -365 },
- { 3257, -3518, -3349, 2862 },
- { 5286, -1948, -3485, -778 },
- { 6502, -3051, -152, 2854 },
- { 5864, -4192, -1076, 3451 },
- { 4656, -3122, -3448, 179 },
- { 5907, -754, -1596, 3116 },
- { 7229, -3680, -1590, 2892 },
- { 5107, -3888, -3364, 806 },
- { 6764, -2635, -3450, 134 },
- { 5258, -2827, -2844, -1052 },
- { 5798, -1725, -4305, 205 },
- { 5404, -1213, -3362, 449 },
- { 6224, -2738, -3046, -581 },
- { 4223, -2438, -2725, 3745 },
- { 4751, -3411, -2123, 116 },
- { 3868, -3000, -3954, 2297 },
- { 6819, -2899, -4277, 2825 },
- { 4207, -4754, -2808, 865 },
- { 4804, -1494, -1997, 4688 },
- { 5282, -2213, -548, 3559 },
- { 5580, -1912, -566, 4370 },
- { 6168, -2857, -672, 4053 },
- { 6583, -4515, -2850, 1670 },
- { 6511, -3093, -3988, 1421 },
- { 4646, -1790, -1443, 3650 },
- { 5915, -924, -2020, 896 },
- { 7814, -4181, -3152, 2007 },
- { 6190, -2238, -4817, 2279 },
- { 4737, -4034, -3288, 1835 },
- { 8161, -3633, -3423, 3137 },
- { 7415, -2351, -2088, 4290 },
- { 4106, -2517, -62, 2905 },
- { 4909, -3145, -614, 4112 },
- { 4938, -3281, -397, 1100 },
- { -173, 919, 1589, -5363 },
- { -13, 796, -295, -6655 },
- { -1860, -829, 1141, -4555 },
- { 2298, -838, -664, -5005 },
- { -884, -1097, 2074, -4613 },
- { -101, 281, 2846, -4535 },
- { 1166, 453, 2429, -5910 },
- { 879, -664, 2370, -5452 },
- { 1415, -370, -1699, -4727 },
- { -1413, 1277, -669, -6649 },
- { 2133, 304, -968, -4624 },
- { 380, 586, -2087, -4892 },
- { 1336, 275, -82, -5789 },
- { -2459, 1057, -34, -5416 },
- { 2278, -1758, 866, -5653 },
- { 1945, -2295, -149, -5302 },
- { 1287, -3525, 996, -5255 },
- { 2297, 803, 1177, -6067 },
- { 187, -180, -619, -6202 },
- { -793, -2537, 1554, -5057 },
- { -2703, -204, -629, -5853 },
- { -1007, -146, 313, -5582 },
- { 830, 357, 869, -6363 },
- { -228, -575, -3177, -4433 },
- { -1001, -1553, -142, -5708 },
- { -1644, 1683, 1721, -4533 },
- { 893, 1924, -15, -5791 },
- { 2195, 2061, -262, -5471 },
- { 3031, 270, 311, -5096 },
- { 1912, 1638, -1523, -4677 },
- { -3142, -55, 253, -4914 },
- { 356, -1680, 343, -6123 },
- { -2241, -1734, -976, -5939 },
- { -2196, -2893, 547, -4938 },
- { -1245, 126, -1916, -5419 },
- { -249, -3755, -1422, -5594 },
- { 575, -2683, -1926, -4566 },
- { -762, 1885, 192, -5880 },
- { -811, -2562, -1068, -6013 },
- { -2264, -3086, -976, -4775 },
- { 70, -1215, 2880, -4410 },
- { 714, -3760, 2916, -4691 },
- { -244, -3404, 1740, -4493 },
- { 684, -5137, -328, -5608 },
- { -529, -3825, -1786, -4535 },
- { -713, -4743, -1118, -5546 },
- { 2718, -3788, 1798, -5708 },
- { -1639, -3679, -1564, -6095 },
- { 1693, -2642, -1389, -4539 },
- { 505, -1573, -1651, -4878 },
- { -835, -2256, -1941, -5352 },
- { 1464, -411, 1993, -6441 },
- { 493, -3184, -145, -6148 },
- { -1413, 499, -1617, -6479 },
- { -294, 1722, -1419, -5725 },
- { -2937, -1528, -175, -4624 },
- { -594, -5911, -56, -6146 },
- { -300, -4275, 1156, -5947 },
- { 552, -2643, 2669, -3959 },
- { 905, -4158, 1789, -5809 },
- { 1336, -2009, 2108, -5903 },
- { 1555, -3600, 1110, -6759 },
- { -1294, -3464, 77, -6084 },
- { -1139, -4006, -1270, -4181 },
- { -5094, -3296, 1092, -2847 },
- { -5503, -2883, 1984, -2067 },
- { -4671, -4218, -1417, -4132 },
- { -3763, -3818, 1262, -3082 },
- { -5132, -3430, 2928, -728 },
- { -5957, -2877, 1251, -2446 },
- { -4425, -2319, -212, -4276 },
- { -6201, -1993, 1774, -2182 },
- { -5500, -3836, 2201, -1396 },
- { -6934, -2334, 2366, -1293 },
- { -6124, -4140, 1337, -1977 },
- { -6553, -4186, 1756, -1325 },
- { -5126, -1258, 744, -3656 },
- { -5167, -1390, 1581, -2895 },
- { -4525, -3398, 2429, -1865 },
- { -4076, -3183, 2027, -2510 },
- { -6191, -3274, 1838, -1814 },
- { -4454, -2753, 2723, -1185 },
- { -6655, -4797, 251, -2595 },
- { -6332, -2232, 1832, 217 },
- { -5869, -1698, 134, 340 },
- { -6614, -1045, 2126, -1932 },
- { -4859, -2107, 2010, -2435 },
- { -6274, -1622, 2808, -1374 },
- { -3119, -3209, 521, -3988 },
- { -5676, -2082, -420, -2711 },
- { -7073, -3623, 696, -2343 },
- { -5986, -4224, 572, -2454 },
- { -4340, -4521, 882, -2771 },
- { -6178, -1933, 535, -1444 },
- { -4923, -4163, 1744, -2066 },
- { -6410, -1519, 1058, -2683 },
- { -5077, -1185, 856, -2216 },
- { -7091, -2444, 687, -2597 },
- { -5284, -2165, 3239, -993 },
- { -4763, -1497, 197, -3179 },
- { -4128, -4958, -396, -3578 },
- { -5054, -3878, -647, -2672 },
- { -7005, -3348, 1679, -1579 },
- { -5767, -1017, 2582, -1915 },
- { -7069, -2787, 1331, -2070 },
- { -5532, -2296, 706, -2950 },
- { -5059, -3543, -821, -3637 },
- { -6639, -1835, 1016, -696 },
- { -5611, -5220, -694, -3371 },
- { -5994, -2803, 2933, -729 },
- { -5948, -619, 1596, -2676 },
- { -5486, -4419, 153, -3265 },
- { -4329, -3440, 1646, -1439 },
- { -4083, -3978, 177, -3569 },
- { -4289, -2599, 1224, -3075 },
- { -5707, -3253, 1912, -759 },
- { -6606, -3437, 2562, -571 },
- { -5254, -2444, 769, -352 },
- { -6545, -3154, 582, -1103 },
- { -5328, -2241, 2566, -1775 },
- { -7216, -1936, 1538, -1983 },
- { -3730, -2451, 426, -3869 },
- { -5110, -1385, 2031, -1169 },
- { -6470, -2715, 269, -3123 },
- { -5806, -2480, -97, -3832 },
- { -3683, -4916, -490, -4330 },
- { -6341, -2083, -669, -115 },
- { -4913, -4079, -837, -4673 },
- { -3274, -2497, 2334, -2652 },
- { -1286, -1731, 2550, -3756 },
- { -3375, -877, 926, -3977 },
- { -2525, -2079, 2879, -2625 },
- { -5308, -504, 3111, -1607 },
- { -4904, 460, 4093, -1232 },
- { -1993, 1616, 4656, -1913 },
- { -3481, -1176, 3119, -2236 },
- { -4132, -1502, 2339, -2545 },
- { -2542, 1151, 3569, -2550 },
- { -4381, 430, 3147, -2082 },
- { -3888, 867, 3899, -1657 },
- { -2861, 1290, 4202, -1979 },
- { -3893, -253, 2363, -2764 },
- { -1705, 688, 3827, -2923 },
- { -2223, 2312, 3700, -3148 },
- { -1986, -720, 5021, -795 },
- { -3177, 242, 1952, -3352 },
- { -1854, 1509, 2528, -3815 },
- { -3173, 97, 5019, -706 },
- { -2689, -145, 1375, -3915 },
- { -4838, -385, 2488, -2427 },
- { -4557, -355, 1603, -3060 },
- { -3522, 1832, 3292, -2674 },
- { -3769, 780, 2378, -2704 },
- { -4323, -1932, 3414, -1169 },
- { -2740, 1158, 2729, -3273 },
- { -3647, 210, 1464, -2892 },
- { -2342, -2097, 1513, -3727 },
- { -4422, -1242, 3130, -1833 },
- { -1308, -1039, 4290, -1875 },
- { -1754, -2535, 3298, -2314 },
- { -4102, -186, 4037, -1094 },
- { -1008, 1570, 3290, 171 },
- { -3322, -2621, 2791, -1536 },
- { -2539, -2597, 3442, -1672 },
- { -3411, -2015, 3670, -1174 },
- { -2097, 730, 5581, -1399 },
- { -1510, -74, 4820, -2004 },
- { -4086, -868, 4425, -771 },
- { -956, -986, 3640, -2925 },
- { -2087, -1250, 3464, -2458 },
- { -3308, -2411, 1334, -3667 },
- { -2264, -389, 4004, -1854 },
- { -680, 239, 4058, -3388 },
- { -1357, 30, 2993, -3658 },
- { -3601, -552, 1177, -1136 },
- { -2641, 442, 4374, -1625 },
- { -2525, 770, 1640, -3895 },
- { -3172, -891, 3893, -1608 },
- { -2996, 13, 3277, -2414 },
- { -899, 1055, 4470, -2501 },
- { -422, -584, 3475, -3787 },
- { -1978, -593, 2566, -3415 },
- { -3150, -1280, 2362, -3047 },
- { -3592, 224, 1026, -3932 },
- { -4840, -1189, 3633, -879 },
- { -3952, -2255, 2916, -1826 },
- { -1695, 28, 1810, -349 },
- { -745, -2484, 3308, -3293 },
- { -1016, 1563, 5365, -1823 },
- { -2172, -1787, 4266, -1287 },
- { -1241, -1951, 3982, -2413 },
- { -2009, -2639, 2330, -3480 },
- { 5105, -1618, -2588, -2015 },
- { 6497, -1523, -3218, -910 },
- { 6526, -2305, -2029, -1790 },
- { 5289, -99, -3436, -400 },
- { 5781, -1623, -1577, -2617 },
- { 5259, -670, -3125, -1700 },
- { 6343, -1256, -331, -3222 },
- { 7967, -678, -2195, -1462 },
- { 6119, -695, -2988, -1538 },
- { 6108, 494, -3359, -1548 },
- { 5067, 969, -2328, -2707 },
- { 7595, -435, -1497, -2056 },
- { 6929, -719, -2420, -1665 },
- { 5190, 584, -2982, -2103 },
- { 6106, -444, -1411, -2739 },
- { 5584, 289, -1804, -2803 },
- { 5276, 227, -1180, -3361 },
- { 7544, -1525, -1834, -1725 },
- { 5986, -1470, -2606, -1701 },
- { 5096, -765, -1712, -3006 },
- { 5423, -149, -3933, -1157 },
- { 7651, 26, -2445, -1507 },
- { 4745, -464, -1735, -2362 },
- { 5352, -1011, -1094, -1999 },
- { 6300, -672, -542, -1950 },
- { 6675, -1020, -1318, -1059 },
- { 7218, -2036, -603, -2462 },
- { 7755, -1514, -2430, -1229 },
- { 5041, 449, -1056, -2405 },
- { 6710, -2277, -1344, -2284 },
- { 6824, -1347, -2254, 251 },
- { 6068, -1857, -983, -1316 },
- { 5603, -2177, -2730, -1477 },
- { 5838, -1059, -3604, -970 },
- { 5076, -789, -335, -2413 },
- { 6191, -1634, -2000, -2129 },
- { 5092, -1292, -2543, -1034 },
- { 5305, 435, -1710, -1850 },
- { 6140, 561, -2176, -2380 },
- { 6752, 348, -2496, -1890 },
- { 6405, 273, -1098, -2778 },
- { 6942, -1340, -496, -1381 },
- { 5238, -687, -2454, -2349 },
- { 6959, -882, -1833, -2061 },
- { 6292, -253, -2125, -2199 },
- { 5838, -574, -759, -3215 },
- { 6954, -1484, -640, -2771 },
- { 7498, -1706, -1210, -2154 },
- { 6772, -1003, -1235, -2532 },
- { 6014, 228, -2154, -1108 },
- { 6943, -2178, -2644, -1122 },
- { 7262, -763, -3056, -1090 },
- { 6273, -1478, -1072, 177 },
- { 4734, 425, -2912, 357 },
- { 7129, 168, -1537, -2327 },
- { 7204, -434, -746, -2660 },
- { 6879, 57, -3087, -1310 },
- { 4623, -610, -718, -3459 },
- { 6565, -543, -1998, -339 },
- { 4752, -277, -2066, -1405 },
- { 7435, -1416, -1904, -505 },
- { 4076, 150, -1222, -3556 },
- { 7082, -28, -1456, -1174 },
- { 5941, -446, -1326, -1158 },
- { 3870, -1648, -2474, -2589 },
- { 858, 37, -3387, -3721 },
- { 3557, -1503, -1664, -3383 },
- { 3336, -1972, -3079, -2216 },
- { 3186, 60, -4185, -863 },
- { 3456, -773, -3066, -2457 },
- { 4131, -913, -2060, -2601 },
- { 4431, -691, -4114, -972 },
- { 3461, -334, -3680, -1751 },
- { 2006, -459, -2214, -3827 },
- { 1322, 32, -2816, -3203 },
- { 4425, -1897, -2791, -1946 },
- { 4504, 23, -3421, -1909 },
- { 3090, -885, -2366, -3264 },
- { 3209, -2363, -3730, -834 },
- { 3312, -1471, -3641, -1579 },
- { 4184, -1669, -3323, -1248 },
- { 2190, -931, -3302, -2944 },
- { 2947, -229, -4791, -1195 },
- { 2020, -1626, -2700, -3125 },
- { 2214, -326, -4352, -1683 },
- { 3286, -2619, -2412, -2458 },
- { 1000, -2571, -4129, -2158 },
- { 2496, -2627, -3611, -1433 },
- { 2043, -2191, -2167, -3827 },
- { 2571, -2544, -1915, -3222 },
- { 2022, -1501, -3856, -2165 },
- { 2685, -1180, -1461, -4038 },
- { 1610, -2313, -4391, -1173 },
- { 2340, -2490, -4215, -516 },
- { 1742, -2615, -3632, -2146 },
- { 523, -1293, -4246, -2442 },
- { 3725, -2723, -3014, -1576 },
- { 3554, -1381, -4200, -824 },
- { 1291, -1594, -4777, -1430 },
- { 1452, 515, -2960, -3830 },
- { 4264, -894, -3305, -1826 },
- { 2606, -1452, -4522, -966 },
- { 1196, -830, -4807, -1816 },
- { 1054, -775, -2616, -4071 },
- { 4206, 415, -4344, -1132 },
- { 3044, 491, -4126, -1934 },
- { 988, -901, -3353, -3443 },
- { 1729, -3063, -2267, -3370 },
- { 3915, 912, -2989, -2387 },
- { 3781, 300, -2457, -3050 },
- { 2712, 924, -1350, -1206 },
- { 4230, 405, -2343, 665 },
- { 1878, -873, -225, -29 },
- { 3510, 56, -1334, -3420 },
- { 2850, 1447, -2651, -3150 },
- { 1510, -706, -4125, -2483 },
- { 3115, 793, -1692, -3894 },
- { 2667, 213, -2973, -2786 },
- { 1184, -2384, -3051, -3173 },
- { 2139, 796, -2079, -3697 },
- { 1464, -1483, -3726, -2754 },
- { 2407, -1148, -3915, -1569 },
- { 2612, -1779, -3217, -2271 },
- { 2406, -2870, -2937, -2496 },
- { 2140, 126, -3646, -2758 },
- { 2952, -1036, 268, -1423 },
- { 93, -1931, -3841, -3535 },
- { 389, -2953, -3383, -3343 },
- { 8652, -5511, -1662, 565 },
- { 7427, -2791, -2535, -842 },
- { 8541, -4253, -1407, -988 },
- { 8018, -3203, -2998, 105 },
- { 7231, -3926, -958, 1308 },
- { 7331, -3690, -363, 2586 },
- { 6803, -3646, -2226, -903 },
- { 8163, -2811, -477, -2235 },
- { 9356, -3818, -1685, -684 },
- { 8466, -2854, -302, -698 },
- { 8458, -3224, 517, 279 },
- { 8074, -2619, -1326, 2596 },
- { 8779, -2761, -2527, -441 },
- { 6533, -2887, -899, -696 },
- { 7394, -2305, -1642, -120 },
- { 8281, -3780, -22, 1305 },
- { 9158, -4413, -779, 901 },
- { 9031, -5240, -1109, 1678 },
- { 8717, -3650, 410, -1075 },
- { 7317, -3197, -818, -2264 },
- { 7934, -2385, -1214, -1886 },
- { 8256, -4441, -291, -587 },
- { 7358, -3395, 1090, -270 },
- { 9446, -4910, -1343, -473 },
- { 8187, -4726, -808, 1166 },
- { 7504, -3845, -47, 267 },
- { 8029, -2146, -1283, -383 },
- { 7461, -2705, -853, 783 },
- { 9367, -3636, -645, -354 },
- { 8955, -3473, -308, -1947 },
- { 8676, -2683, -2099, 1485 },
- { 7481, -3003, -871, -444 },
- { 8015, -2839, -1673, 1175 },
- { 6947, -4643, -1527, -1047 },
- { 7622, -2575, -137, -960 },
- { 9388, -4279, -707, -1322 },
- { 8382, -5259, -1283, -565 },
- { 6856, -4138, -1030, 630 },
- { 8659, -2571, -1124, -1666 },
- { 8763, -3807, -537, 2543 },
- { 8049, -3578, -2186, -604 },
- { 8272, -2351, -1985, -1214 },
- { 6855, -3796, -1527, -1631 },
- { 7178, -2896, -1600, -1756 },
- { 7040, -2888, -89, -1586 },
- { 6261, -3403, -264, 998 },
- { 7756, -4699, -1543, -834 },
- { 7682, -4622, -758, -1721 },
- { 8839, -4232, -2932, 1959 },
- { 9363, -4679, -1956, 39 },
- { 7883, -3616, -1414, -1432 },
- { 8828, -3188, -1356, -1312 },
- { 7746, -3987, -121, -2424 },
- { 9262, -3256, -693, 818 },
- { 7670, -3420, -148, 3504 },
- { 7344, -3183, 608, 1595 },
- { 8976, -4139, -1848, 1304 },
- { 6708, -4131, 33, -852 },
- { 7840, -4429, -2275, 79 },
- { 8980, -3858, -2838, 453 },
- { 7815, -4604, -2563, 944 },
- { 8372, -4422, -1783, 3071 },
- { 8623, -5128, -1754, 2888 },
- { 7462, -3281, 889, 920 },
- { 8416, -59, -1320, -1825 },
- { 7928, -1488, -414, -2499 },
- { 8110, -977, -1047, -2042 },
- { 8278, -687, -1597, -1550 },
- { 7988, -174, -977, -2106 },
- { 8609, -1547, -1628, -1527 },
- { 9000, -1798, -946, -1761 },
- { 8954, -872, -1404, -1594 },
- { 8939, 466, -748, -1212 },
- { 9549, -329, -177, -1360 },
- { 9411, -18, -1126, -1568 },
- { 8859, -782, -488, -1338 },
- { 8955, -218, -43, -1209 },
- { 9131, -69, -453, -1001 },
- { 9069, -1519, -1091, -1199 },
- { 9247, -1309, -566, -1146 },
- { 8528, -1617, -287, -1313 },
- { 7763, -745, -149, -2040 },
- { 8294, -343, 257, -2633 },
- { 10149, -893, -552, -1649 },
- { 9398, -915, 218, -2042 },
- { 9703, -1194, -675, -1592 },
- { 9586, -700, -427, -1710 },
- { 8930, 497, -1445, -1218 },
- { 9285, -1323, -163, -1552 },
- { 8431, -1289, -985, -1404 },
- { 8965, -655, 653, -1483 },
- { 9542, -1001, -951, -1128 },
- { 9205, -647, -37, -882 },
- { 8603, -56, 514, -1793 },
- { 9300, -12, -1324, -567 },
- { 8773, 238, -184, -1456 },
- { 9941, -1306, -69, -1792 },
- { 9360, 279, -376, -1919 },
- { 9180, -285, 95, -2170 },
- { 9922, -501, -970, -1570 },
- { 8341, -1493, -856, -2092 },
- { 8780, -981, -850, -1014 },
- { 9721, -548, -1504, -1094 },
- { 9973, -1493, 482, -2105 },
- { 8707, -333, -1027, -1087 },
- { 9098, -469, -315, -1723 },
- { 8879, -1050, -661, -2020 },
- { 8857, 602, -866, -1918 },
- { 8945, -1025, -2154, -1071 },
- { 8484, -1930, -468, -2179 },
- { 9177, -1903, -224, -2112 },
- { 8652, -137, -2097, -1214 },
- { 9063, -973, -1405, -772 },
- { 9328, -456, 662, -2469 },
- { 10101, -697, 127, -2113 },
- { 9685, 811, -2359, -1024 },
- { 8586, -94, -460, -1982 },
- { 7924, -141, -509, -2513 },
- { 7773, -669, -107, -2835 },
- { 8636, -1064, -46, -2409 },
- { 9748, 596, -1815, -1349 },
- { 8924, 304, 547, -2614 },
- { 9442, 746, -1153, -1679 },
- { 9454, -278, -529, -1976 },
- { 8488, 561, -32, -2160 },
- { 10083, -63, -1544, -1364 },
- { 9390, -1278, 568, -1131 },
- { 9740, -49, -2253, -910 },
- { 3636, -2391, -1115, -3614 },
- { 6014, -3204, -1902, -1808 },
- { 5787, -3497, -1116, -2590 },
- { 4365, -3046, -1632, -2668 },
- { 4733, -2192, -2029, -2468 },
- { 5412, -2753, -1633, -2464 },
- { 4455, -3375, -767, -3399 },
- { 4456, -1644, -983, -2841 },
- { 4039, -2523, 38, -3967 },
- { 3406, -2662, 72, -4757 },
- { 4279, -2005, 1055, -4399 },
- { 4321, -1377, -860, -3786 },
- { 3743, -5739, -651, -3047 },
- { 3528, -5510, 361, -4060 },
- { 6496, -4886, -136, -2689 },
- { 4513, -5254, 551, -4010 },
- { 6557, -3413, -92, -3063 },
- { 4186, -2059, 187, 47 },
- { 6210, -4117, -1256, -1985 },
- { 6038, -4343, 351, -2124 },
- { 4305, -4780, -2077, -1897 },
- { 4480, -3815, -2228, -1533 },
- { 5582, -3689, 1221, -3429 },
- { 5532, -4874, 1195, -2765 },
- { 6518, -2853, -905, -2568 },
- { 5467, -2192, 470, -4115 },
- { 4139, -1577, 240, -3493 },
- { 5281, -1926, -729, -3340 },
- { 5214, -2870, 1359, -4289 },
- { 3046, -3510, -1536, -3214 },
- { 5433, -2881, -1230, -1184 },
- { 4861, -3932, -1071, -2791 },
- { 5693, -4234, -1906, -1502 },
- { 4004, -3935, -1804, -2383 },
- { 3728, -3792, 681, -4773 },
- { 3621, -3030, -1951, -2598 },
- { 5133, -3903, 44, -3700 },
- { 3561, -3451, 1183, -5301 },
- { 5026, -2762, -2341, -1780 },
- { 5841, -2492, -467, -3210 },
- { 5591, -1791, 497, -2472 },
- { 5054, -3898, -1822, -2097 },
- { 5813, -2792, 83, -1469 },
- { 4432, -4497, 1670, -5193 },
- { 5338, -4653, -1109, -2200 },
- { 3239, -4401, -648, -3655 },
- { 2147, -3598, -1200, -4242 },
- { 4417, -2271, -1552, -3210 },
- { 6494, -4360, 852, -3565 },
- { 2393, -6358, -856, -4524 },
- { 4959, -4196, -847, -1403 },
- { 4924, -5438, -226, -3026 },
- { 4254, -5303, -1306, -2424 },
- { 4121, -3126, -2334, -1981 },
- { 3437, -4443, -1464, -2953 },
- { 3203, -3459, -529, -4339 },
- { 5896, -5945, 543, -3246 },
- { 1987, -4733, -220, -4863 },
- { 4358, -4431, -514, -3081 },
- { 4583, -2416, -492, -2287 },
- { 2943, -5035, 419, -4927 },
- { 5358, -5129, 987, -4309 },
- { 4460, -3392, 1752, -5634 },
- { 3415, -4633, 1507, -5945 },
- { 811, -4692, -445, 2333 },
- { 1009, -5613, -1857, 1360 },
- { 1338, -2712, -2720, 3036 },
- { 1002, -3754, -2582, 2344 },
- { 750, -4608, -2334, 714 },
- { 2043, -3207, -2822, 2173 },
- { -140, -4654, -2953, 357 },
- { -54, -4026, -2376, 2695 },
- { 1858, -5022, -717, 2287 },
- { 2064, -3894, -722, 3255 },
- { 2727, -4558, -332, 2603 },
- { 1810, -5378, 283, 1826 },
- { 3935, -4326, 762, 3383 },
- { -767, -4697, -2510, 1922 },
- { 2146, -4312, -3090, 1641 },
- { 54, -5881, -2114, 921 },
- { 1992, -5766, -640, 1574 },
- { 1200, -5371, -1114, 1828 },
- { 2973, -5337, 34, 2266 },
- { 1531, -5018, -2817, 1192 },
- { 3078, -4570, 117, 1990 },
- { 924, -4286, -1388, 2713 },
- { 142, -5058, -2848, 1487 },
- { -106, -6180, -881, 842 },
- { 673, -5433, -229, 1596 },
- { 783, -5710, -2784, 562 },
- { 1935, -5729, -2009, 856 },
- { -410, -3375, -3326, 2734 },
- { 234, -3000, -2628, 3260 },
- { 733, -3405, -3806, 1589 },
- { 771, -4285, -3544, 1314 },
- { 1192, -3563, -3960, 2178 },
- { 206, -5555, -1250, 1546 },
- { -130, -3815, -1210, 3041 },
- { 646, -3940, -393, 2992 },
- { -184, -4931, -1767, 1925 },
- { 2746, -5120, -2275, 1464 },
- { 2440, -3731, -3352, 2729 },
- { -490, -4942, -3779, 997 },
- { 68, -2636, -4167, 3778 },
- { 48, -3986, -4118, 2106 },
- { -978, -5486, -1336, 1390 },
- { 1126, -5297, -855, 640 },
- { -472, -3975, -3622, 1557 },
- { 2456, -5344, -1523, 1648 },
- { -774, -5652, -2417, 1147 },
- { 995, -6122, -812, 1132 },
- { 3282, -4571, -1763, 2175 },
- { 3655, -3862, -676, 3568 },
- { 3038, -3647, -1672, 3381 },
- { 2595, -2964, -2772, 3263 },
- { 4176, -3353, -1148, 4354 },
- { 1603, -3442, -1500, 3444 },
- { 828, -6226, -1783, 678 },
- { 1421, -3333, -3080, 3403 },
- { 1121, -4727, -1924, 1984 },
- { -186, -5083, -682, 1796 },
- { 819, -2778, -3488, 530 },
- { 421, -2873, -3832, 2596 },
- { 2164, -4263, -1605, 2282 },
- { 585, -4437, -682, -491 },
- { -644, -4452, -1157, 2325 },
- { 1991, -4299, 210, 2834 },
- { 2135, -3632, -2113, 665 },
- { -7482, -2724, -2662, -1380 },
- { -6983, -2166, -3756, -3509 },
- { -7085, -1439, -2397, -3112 },
- { -7760, -3049, -3319, -2822 },
- { -8413, -2760, -4406, -3298 },
- { -5995, -3943, -1260, -3750 },
- { -7879, -1554, -3464, -2606 },
- { -6314, -2034, -3878, -1681 },
- { -8849, -2084, -1399, -1231 },
- { -7153, -2602, -1384, -817 },
- { -8041, -2571, -407, -2785 },
- { -7246, -2233, -1578, 260 },
- { -7336, -3883, -4061, -1342 },
- { -7619, -3908, -2342, 382 },
- { -8684, -3724, -1662, -727 },
- { -7850, -2922, -1770, -3449 },
- { -6766, -2034, -1293, -1988 },
- { -6895, -2116, -968, -3744 },
- { -7136, -5147, -2618, -2809 },
- { -8224, -3724, -2519, -1589 },
- { -6711, -2750, -3021, -219 },
- { -8059, -1638, -1102, -3175 },
- { -8710, -4839, -3963, -3143 },
- { -9363, -4965, -3257, -1002 },
- { -6099, -1751, -3157, -395 },
- { -6453, -3216, -4597, -483 },
- { -7879, -5477, -839, -2638 },
- { -7202, -4038, -526, -2856 },
- { -8022, -1228, -1910, -1646 },
- { -9117, -1393, -1582, -2535 },
- { -9095, -2693, -636, -2605 },
- { -9076, -2580, -3481, -2519 },
- { -8327, -4859, -2422, 83 },
- { -8368, -2129, -2324, -2173 },
- { -8554, -4563, -3842, -2007 },
- { -10462, -4261, -1934, -2084 },
- { -9717, -3187, -2294, -1896 },
- { -9625, -3889, -3020, -3224 },
- { -9857, -4955, -4239, -2184 },
- { -9752, -2351, -2277, -3129 },
- { -7219, -1302, -2639, -1603 },
- { -7477, -4360, -3718, -559 },
- { -5680, -2033, -2326, -3078 },
- { -10190, -5548, -4643, -3601 },
- { -9431, -4121, -879, -2479 },
- { -8365, -5450, -2020, -1439 },
- { -6289, -5178, -1605, -3845 },
- { -8319, -3866, -687, -2792 },
- { -8131, -1031, -3608, -3947 },
- { -10510, -2560, -1199, -2082 },
- { -11015, -3640, -2748, -3041 },
- { -8762, -5022, -5231, -1162 },
- { -10153, -2715, -4648, -4859 },
- { -7930, -5205, -1900, -3600 },
- { -9561, -3548, -4812, -3722 },
- { -7663, -4709, -1180, -1475 },
- { -9073, -5707, -1815, -2980 },
- { -8602, -2363, -2675, -3770 },
- { -9967, -5614, -3575, -3838 },
- { -8324, -1005, -2131, -3254 },
- { -10331, -5737, -2550, -2940 },
- { -8234, -3354, -3361, -4479 },
- { -8140, -1951, -4526, -4545 },
- { -6679, -2662, -2284, -4182 },
- { -1122, -1514, -6427, -212 },
- { 54, -1660, -5424, -1404 },
- { 254, -2778, -5222, 846 },
- { -267, -1661, -6577, 814 },
- { -305, -2021, -5759, 1484 },
- { -1791, -2446, -6867, -86 },
- { -2929, -3158, -6603, -1799 },
- { -1391, -3189, -5557, -1053 },
- { -1602, -884, -6767, -1213 },
- { -361, -318, -6219, -44 },
- { -4078, -2635, -5523, -433 },
- { -956, 478, -4382, 1470 },
- { -3300, -2462, -6021, -2721 },
- { 708, -2434, -5085, -540 },
- { -2435, -3607, -5647, -2110 },
- { -491, -1134, -4681, -2886 },
- { 87, -3435, -4641, -1194 },
- { -586, -2927, -4784, 366 },
- { -1394, -2326, -6021, 350 },
- { 97, -2519, -4678, -2120 },
- { -1547, -1907, -5069, -2993 },
- { 268, -3724, -4719, 127 },
- { -827, -1190, -5912, 1144 },
- { -3959, -2322, -6898, -1974 },
- { -2728, -2228, -6426, -562 },
- { -456, -666, -5785, -1609 },
- { 531, -1096, -5731, -656 },
- { -3569, -688, -3915, 110 },
- { -4752, -1725, -4393, -377 },
- { -3210, -3315, -6960, -840 },
- { -688, -3416, -4971, 1221 },
- { -1833, 77, -6491, -2434 },
- { -239, -255, -6850, -886 },
- { -2112, -1490, -6291, -2689 },
- { -1544, -4579, -5198, -1261 },
- { -2771, -4014, -5520, 683 },
- { -1635, -2829, -5512, 1214 },
- { -958, -2582, -4823, 2360 },
- { -2077, -4566, -4642, 365 },
- { -3112, -4214, -5960, -823 },
- { -2467, -2510, -4858, 1467 },
- { -1561, -3399, -5822, 211 },
- { -775, -1081, -4424, 2636 },
- { -1263, 25, -6378, -1392 },
- { -3476, -366, -5417, -1393 },
- { -3176, -1476, -4149, 1466 },
- { -2479, 518, -4448, -257 },
- { -2992, 158, -4660, -1279 },
- { -1320, -3872, -4479, 1147 },
- { -1475, -312, -5318, 539 },
- { -3527, -1679, -5860, -1681 },
- { -3397, -3438, -5593, 1866 },
- { -4089, -2439, -4763, 1275 },
- { -748, -4513, -4687, -48 },
- { -2166, -4531, -4691, -2856 },
- { -2385, -853, -6035, -627 },
- { -1194, -4091, -4472, -1963 },
- { -682, -3234, -4084, -3033 },
- { -3255, -5015, -5328, -12 },
- { -2313, -3436, -4601, -155 },
- { -2792, -1038, -6947, -2019 },
- { -1244, -1526, -5771, -1882 },
- { -4679, -3731, -5506, 283 },
- { -3062, -66, -3558, -758 },
- { -4895, -1187, 4751, 3728 },
- { -7600, -2752, 3320, 4613 },
- { -5703, -2975, 3944, 2659 },
- { -4972, -1257, -246, 2952 },
- { -4221, -2487, 1702, 4295 },
- { -2900, -1529, 2458, 4935 },
- { -5061, 407, 2416, 4050 },
- { -6931, -3478, 2761, 2213 },
- { -6037, -3921, 3192, 1866 },
- { -6113, -811, 2407, 3782 },
- { -5878, -1716, 1207, 3478 },
- { -5953, -2853, 2207, 2712 },
- { -6807, -3223, 2749, 3595 },
- { -3272, -3157, 1389, 3788 },
- { -5368, -1904, 1980, 5077 },
- { -7235, -1398, 3075, 4548 },
- { -4765, -3487, 2755, 2796 },
- { -7658, -4435, 2694, 2582 },
- { -6997, -4282, 456, 3832 },
- { -5563, -3115, -63, 3713 },
- { -4244, -4220, 1450, 2767 },
- { -3801, -2194, 190, 4303 },
- { -5458, -4119, 1958, 2274 },
- { -7300, -3469, 3514, 3193 },
- { -4594, -2067, 775, 4752 },
- { -3389, -1654, 1464, 5412 },
- { -4845, -3483, 964, 3437 },
- { -6007, -2818, 1666, 4659 },
- { -8709, -5007, 1757, 3287 },
- { -5833, -4389, 1025, 3171 },
- { -5788, -1780, 3944, 3661 },
- { -4430, -920, 1938, 4753 },
- { -7066, -1857, 4591, 4538 },
- { -3549, -513, 1427, 5317 },
- { -7517, -1220, 2883, 3049 },
- { -7605, -2687, 1874, 2735 },
- { -8718, -4035, 2676, 3730 },
- { -7990, -3907, 1185, 2607 },
- { -6058, -1744, 3349, 5157 },
- { -5954, 565, 3161, 3250 },
- { -6478, -612, 1930, 2271 },
- { -6535, -1445, -2, 1618 },
- { -8963, -4151, 1192, 4044 },
- { -7227, -3570, 1600, 4234 },
- { -4674, 79, 595, 3015 },
- { -3974, 430, 2727, 5137 },
- { -5299, 9, 3714, 4779 },
- { -6779, -2699, -8, 2436 },
- { -7016, -1145, 1293, 2310 },
- { -6955, -3312, 1534, 1801 },
- { -4025, 740, 1850, 4054 },
- { -9589, -3460, 4154, 5270 },
- { -4404, -1181, 4298, 5173 },
- { -7356, -4583, -18, 2644 },
- { -6516, -1235, 4439, 6234 },
- { -3453, -301, 4344, 4464 },
- { -4643, 1530, 3315, 4340 },
- { -4575, -2557, 3754, 3682 },
- { -3643, -3501, 2051, 2997 },
- { -5412, -2475, 2301, 1579 },
- { -5846, 259, 1360, 2348 },
- { -5258, -1358, 1050, 838 },
- { -5542, -219, 6377, 5750 },
- { -5713, -2952, 922, 899 },
- { -2049, -1135, 5206, 1033 },
- { -1693, -1886, 4835, -106 },
- { -2344, -3504, 4232, -13 },
- { -2475, -2334, 5043, 1126 },
- { -787, -2549, 3880, 2138 },
- { -3159, -2341, 4830, 2887 },
- { -1780, -1009, 6240, 2061 },
- { -4327, -3363, 2818, 886 },
- { -3376, -2743, 4104, 207 },
- { -3250, -4640, 2718, 1498 },
- { -382, -1075, 4382, 3460 },
- { -2416, -4168, 3530, 816 },
- { -1756, -2708, 4861, 622 },
- { -1879, -2097, 5156, 2889 },
- { -2496, -2418, 3722, 2671 },
- { -2717, -3252, 3341, 1944 },
- { -4063, -4091, 3306, 267 },
- { -3549, -3808, 3747, 842 },
- { -2635, 546, 5794, 1894 },
- { -1857, -1121, 4383, 3964 },
- { -2226, -2166, 3489, 3678 },
- { -3492, -660, 5323, 1063 },
- { -3033, -3130, 4382, 1828 },
- { -2703, -625, 6369, 2851 },
- { -1656, -2842, 4584, -528 },
- { -4781, -2622, 4390, 2097 },
- { -413, -2045, 5081, 3035 },
- { -3810, -2662, 4532, 1095 },
- { -3144, -1858, 5215, 1880 },
- { -3562, -1795, 4928, 670 },
- { -4800, -1509, 5189, 1859 },
- { -1085, -3832, 4169, 900 },
- { -1969, -3270, 2857, 2878 },
- { -4267, -4140, 3176, 1805 },
- { -5145, -3727, 3524, 1168 },
- { -1346, -1876, 5501, 1748 },
- { -4998, -2945, 3699, 338 },
- { -3458, -3096, 3406, -635 },
- { -1751, -3209, 3508, 395 },
- { -2507, 170, 5987, 705 },
- { -3756, -1072, 5647, 3536 },
- { -2870, -1439, 5026, 3212 },
- { -3913, -3225, 3669, 2144 },
- { -3739, 226, 5747, 764 },
- { -2052, -820, 5266, 3093 },
- { -3214, -3820, 2409, 2391 },
- { -4398, -2588, 3501, -218 },
- { -4484, -1763, 4180, -198 },
- { -3368, -1525, 4362, -134 },
- { -2407, 224, 4905, 3533 },
- { -1369, -2937, 4728, 1788 },
- { -4848, -1707, 4159, 851 },
- { -3454, -1749, 4281, 3230 },
- { -1990, -3853, 3487, 1735 },
- { -3117, 92, 6155, 4075 },
- { -2676, -2472, 4078, -589 },
- { -1547, -2012, 2626, 1835 },
- { -4275, -588, 4824, 725 },
- { -601, -2249, 3736, 3548 },
- { -4060, -61, 5333, 3097 },
- { -4303, 7, 6551, 3054 },
- { -5003, -1029, 5786, 3319 },
- { -2810, -728, 5392, 199 },
- { -1232, -200, 5228, 3121 },
- { 2621, 165, -6255, 298 },
- { 3669, 537, -6844, 1564 },
- { 1598, -1190, -6235, 2523 },
- { 2164, -32, -6894, 1383 },
- { 853, -1597, -6069, 1449 },
- { 1377, -1661, -5266, 108 },
- { 2660, 48, -5172, -517 },
- { 1903, -391, -5677, 1010 },
- { 3792, 206, -5274, -11 },
- { 1239, 2776, -2929, 2721 },
- { 4071, 149, -7259, 3125 },
- { 1436, -480, -6156, -196 },
- { 1373, -1960, -5005, 3122 },
- { 3413, -1271, -5176, 3283 },
- { 3060, -68, -6495, 2238 },
- { 2700, -2075, -4681, 91 },
- { 2928, -1728, -5168, 1858 },
- { 4424, 828, -4471, 88 },
- { 2672, -2604, -4038, 2753 },
- { 5223, -123, -6749, 2295 },
- { 4237, -420, -5538, 1353 },
- { 4744, -1281, -4097, 4708 },
- { 1103, -2764, -4751, 2024 },
- { 3747, -1913, -3911, 3960 },
- { 2470, -1416, -5542, 615 },
- { 4847, -1354, -5334, 1733 },
- { 5336, 88, -7593, 4007 },
- { 2388, -2880, -4807, 1037 },
- { 4495, 1391, -5685, -139 },
- { 5253, 1637, -6450, 1533 },
- { 1199, 795, -5515, 1261 },
- { 1397, -1259, -4252, 3838 },
- { 746, 70, -6640, 604 },
- { 1584, 166, -4972, 3072 },
- { 380, -999, -5397, 2267 },
- { 2974, 1707, -3242, 5360 },
- { 5202, -403, -5453, 2832 },
- { 3718, -1731, -4760, 714 },
- { 4150, -975, -4792, 61 },
- { 2925, -818, -4841, 15 },
- { 5301, 577, -4006, 3259 },
- { 5265, 1986, -5679, 3028 },
- { 3752, 1928, -4509, 3729 },
- { 3278, 1925, -6370, 1247 },
- { 5107, 1721, -4853, 3127 },
- { 3279, 2982, -2515, 4005 },
- { 4622, 668, -6204, 759 },
- { 6034, 317, -5763, 4818 },
- { -558, 57, -3785, 2817 },
- { 4476, 1616, -3965, 4536 },
- { 5953, 2056, -8215, 2715 },
- { 4387, 2613, -7463, 868 },
- { 5834, 1088, -4736, 4924 },
- { 6473, -856, -6991, 4172 },
- { 4959, -293, -5162, 76 },
- { 2731, -843, -6119, 3847 },
- { 3245, 1202, -6833, 616 },
- { 2553, 1383, -3829, 3859 },
- { 4332, 2099, -3480, 3622 },
- { 2110, 2683, -2728, 3990 },
- { 876, 1167, -3290, 3466 },
- { 3991, 1709, -2410, 4077 },
- { 5105, 939, -2584, 3256 },
- { 4719, 688, -1566, 3040 },
- { -3632, 4335, 1266, -3303 },
- { -4956, 3207, 1312, -2806 },
- { -4669, 2627, 2663, -2435 },
- { -4282, 3708, 2303, -3038 },
- { -4536, 2297, -175, -3350 },
- { -5234, 2503, -139, -880 },
- { -3978, 1512, 1092, -3619 },
- { -4519, 4649, 1363, -2455 },
- { -5118, 3132, 1961, -1577 },
- { -5196, 3379, -182, -1378 },
- { -6420, 4486, 2397, -1993 },
- { -5030, 5046, 1292, -1118 },
- { -4559, 2573, -927, -1406 },
- { -3501, 3730, 691, -4930 },
- { -4364, 2758, 1007, -3909 },
- { -4026, 2839, -1559, -2340 },
- { -5037, 4053, 836, -1571 },
- { -4727, 5136, 1110, -3588 },
- { -5245, 2799, -999, -2164 },
- { -4954, 1501, 422, -3963 },
- { -5994, 2726, 1462, -2833 },
- { -5621, 5159, 2038, -2512 },
- { -4991, 2291, 1917, -3151 },
- { -5469, 4382, -148, -2978 },
- { -5858, 1983, 807, -2720 },
- { -4709, 3556, 952, -467 },
- { -2489, 2362, 1714, -4230 },
- { -4717, 5004, -1180, -3672 },
- { -5914, 3653, 1359, -1317 },
- { -5506, 2995, 780, -1059 },
- { -5287, 3945, 2480, -2293 },
- { -3849, 4358, 322, -1770 },
- { -3911, 3570, 252, -3185 },
- { -3660, 5128, 158, -3719 },
- { -4599, 3277, -503, -2727 },
- { -3673, 3760, -1252, -3339 },
- { -5161, 2337, 388, -1943 },
- { -3529, 2216, 2156, -3080 },
- { -4309, 4331, 1808, -1460 },
- { -4782, 3820, 480, -2504 },
- { -4166, 3544, -378, -1567 },
- { -5572, 2466, -418, -2909 },
- { -6096, 2930, 119, -1878 },
- { -5963, 3554, 1011, -2233 },
- { -6433, 4335, 935, -2930 },
- { -5004, 3314, -1352, -3430 },
- { -6042, 3463, -1008, -3940 },
- { -4671, 2214, -640, -5040 },
- { -2795, 3759, 1412, -3803 },
- { -3647, 4436, 729, -515 },
- { -3594, 1033, 56, -4148 },
- { -2908, 3027, 2889, -3485 },
- { -3338, 2234, 313, -4285 },
- { -3825, 4497, -561, -2634 },
- { -6167, 3012, -48, -3149 },
- { -4828, 3515, -969, -4475 },
- { -5789, 2757, -539, -4173 },
- { -2452, 3067, 564, -4249 },
- { -4921, 1358, 1331, -2889 },
- { -3127, 4239, -1045, -1523 },
- { -4780, 2326, -1118, -3446 },
- { -3908, 5546, 152, -2622 },
- { -6972, 2976, 337, -2809 },
- { -4839, 4613, -35, -4077 },
- { -1408, 4822, -1149, -4997 },
- { -981, 4979, -912, -6304 },
- { -2098, 5689, -888, -2878 },
- { -3343, 4814, -657, -4434 },
- { -2461, 3601, -967, -4869 },
- { -2652, 3944, 87, -5520 },
- { -1104, 6076, 174, -6407 },
- { 355, 5370, -1721, -5869 },
- { 1242, 4497, -1107, -5091 },
- { -89, 4002, -1491, -5182 },
- { 1059, 5693, -1591, -4905 },
- { 1323, 4682, -2078, -4768 },
- { 818, 3996, -549, -5468 },
- { -287, 4529, 929, -5543 },
- { -919, 5519, -2791, -2844 },
- { -1407, 5679, -3289, -3974 },
- { -189, 6530, -3547, -4002 },
- { -900, 7039, -3371, -4855 },
- { -2983, 7211, -363, -4835 },
- { -814, 6503, -104, -5106 },
- { -2386, 6896, 809, -4919 },
- { 845, 4492, 352, -6621 },
- { -1998, 7237, -1646, -4231 },
- { -3380, 6251, 471, -4577 },
- { -1908, 7059, 84, -5726 },
- { -340, 6346, -803, -6265 },
- { -2279, 5834, -47, -4633 },
- { -1532, 5286, -1748, -1901 },
- { -2757, 6188, -453, -3415 },
- { -1255, 6405, -2043, -6357 },
- { 918, 5581, -121, -5667 },
- { 1840, 5336, -821, -5034 },
- { -2475, 4992, -1825, -3104 },
- { -2413, 5606, -1789, -4298 },
- { 132, 5128, -2389, -4442 },
- { 223, 6400, -2653, -4742 },
- { -673, 5012, 680, -4582 },
- { -1657, 6624, -349, -3596 },
- { -755, 6289, -1860, -3978 },
- { -572, 6894, -1946, -5207 },
- { -1141, 4756, -2665, -5586 },
- { -1073, 4269, -431, -4030 },
- { 186, 5761, 916, -5868 },
- { -1907, 4836, 1017, -5106 },
- { -963, 3363, -1248, -6348 },
- { -3262, 4774, -1818, -5858 },
- { 847, 3812, -2538, -4302 },
- { -1223, 5903, 1360, -5479 },
- { -1094, 6923, -1244, -2381 },
- { 267, 6276, -709, -2846 },
- { -157, 5840, 1124, -4266 },
- { 889, 3206, -910, -5305 },
- { -1736, 3344, 582, -4838 },
- { -2357, 5676, -2695, -6277 },
- { -1916, 6901, -986, -5397 },
- { -3062, 6028, -695, -5687 },
- { 1836, 3566, -1357, -5226 },
- { -2176, 4938, 646, -3872 },
- { -2199, 3055, -208, -6124 },
- { -236, 3032, -821, -5325 },
- { -3989, 7277, -565, -3899 },
- { -595, 4362, 74, -5975 },
- { 684, 5874, -841, -4424 },
- { -2731, 6305, -2389, -5465 },
- { -5775, 1325, -56, -2528 },
- { -7029, -534, -1890, -3278 },
- { -5798, -15, -2734, -2210 },
- { -5504, -1198, -353, -3659 },
- { -5079, 960, -894, -4336 },
- { -6073, -36, -133, -3014 },
- { -5782, -259, -1025, -3986 },
- { -6843, 1262, -807, -1639 },
- { -5263, -918, -3290, -579 },
- { -4840, 461, -2158, -533 },
- { -6014, -50, -620, 504 },
- { -5843, 241, -1359, -282 },
- { -5898, 577, 769, -3271 },
- { -6833, -946, -466, -3347 },
- { -6026, 1459, -512, -729 },
- { -7361, 747, -388, -1110 },
- { -6391, 2142, -1160, -2513 },
- { -6995, 304, 498, -2673 },
- { -6757, 679, -386, -433 },
- { -5222, 1688, -1093, -1032 },
- { -5019, 575, 184, -3627 },
- { -4237, 628, -3507, -1243 },
- { -7479, -456, -1722, -1486 },
- { -6464, 713, -1273, -1153 },
- { -6255, 1682, -606, -3607 },
- { -7033, 1497, -71, -1955 },
- { -6694, 1556, -1721, -3214 },
- { -6114, -356, 813, -2575 },
- { -5308, 632, -1851, -1636 },
- { -5742, -911, -1733, 383 },
- { -6083, -387, -2313, -879 },
- { -6535, -530, -1505, -2083 },
- { -4896, 1223, -2750, -1816 },
- { -6392, -463, -3247, -2093 },
- { -5373, 1264, -2706, -3042 },
- { -3894, -1390, -1020, -891 },
- { -6179, 1168, -1966, -1922 },
- { -5162, 1668, -1617, -1916 },
- { -6453, 920, -1169, -2432 },
- { -6130, 2005, -536, -1519 },
- { -6552, -98, -518, -1938 },
- { -7528, 355, -1101, -1772 },
- { -5745, 610, -247, -1360 },
- { -7003, 177, -2064, -1958 },
- { -6956, -570, -2220, -4225 },
- { -7830, 791, -1394, -2774 },
- { -7634, 480, -3171, -4224 },
- { -7913, 1154, -350, -2381 },
- { -5063, 1704, -1804, -2977 },
- { -4887, -524, -2703, 188 },
- { -5551, 406, -1620, -3063 },
- { -7109, 1342, 381, -3021 },
- { -6846, 631, -458, -3398 },
- { -4606, -605, 11, -3930 },
- { -8134, -225, -1738, -2648 },
- { -7043, 402, -2734, -3059 },
- { -7417, 1825, -2545, -4389 },
- { -6971, -236, -1031, -665 },
- { -5752, 2111, -1632, -3808 },
- { -7660, -78, -624, -3135 },
- { -6358, 619, -1951, -3911 },
- { -8134, 408, -1935, -3695 },
- { -6335, 1911, -2368, -4505 },
- { -7116, 2163, -344, -2753 },
- { 2357, 4488, 2220, -5682 },
- { 1385, 3206, 2300, -5305 },
- { 1419, 2557, 5203, -3516 },
- { 262, 4315, 3920, -1847 },
- { 3316, 3187, 1612, -5609 },
- { 1729, 2350, 1673, -6068 },
- { 1603, 6126, 1467, -2839 },
- { -1339, 3316, 3691, -3530 },
- { -563, 4618, 3180, -4548 },
- { 463, 4624, 3111, -5614 },
- { 1246, 5455, 3356, -5720 },
- { 480, 2149, 5422, -2893 },
- { 1768, 4827, 913, -5579 },
- { -149, 5381, 4366, -3297 },
- { 985, 3672, 2644, -92 },
- { -258, 2911, 5817, -2213 },
- { 3428, 3289, 3351, -3541 },
- { -666, 3295, 4727, -2869 },
- { 35, 6641, 4160, -4052 },
- { 623, 6787, 3156, -4560 },
- { 2654, 4360, 4676, -4632 },
- { 1386, 5246, 4834, -4497 },
- { 3488, 4574, 3856, -5946 },
- { 383, 4481, 4168, -4110 },
- { 1753, 3652, 4288, -3326 },
- { 1344, 4905, 2508, -4660 },
- { 1580, 4106, 3104, -2224 },
- { 2027, 5038, 1683, -1554 },
- { 446, 3699, 5872, -3013 },
- { 4637, 4087, 3578, -5018 },
- { 2629, 3560, 5331, -4900 },
- { 1527, 6674, 2523, -4131 },
- { -1437, 2804, 2528, -4464 },
- { -229, 3355, 2016, -5537 },
- { 3666, 3418, 4374, -4581 },
- { 1192, 3799, 923, -6596 },
- { 2040, 2956, 448, -5322 },
- { 2468, 5768, 4029, -5869 },
- { 3438, 6516, 3529, -6667 },
- { 2737, 5495, 680, -5535 },
- { 3896, 5727, 1801, -4958 },
- { 4988, 4957, 3592, -6518 },
- { -542, 4416, 5794, -2787 },
- { 4136, 4354, 2064, -4696 },
- { 3067, 5936, 1207, -3396 },
- { 2789, 4966, 2405, -3854 },
- { 1731, 3270, 3251, -1063 },
- { 1767, 5537, 2084, -2349 },
- { 465, 3116, 4532, -837 },
- { 1499, 2627, 4610, -2212 },
- { 122, 3095, 3642, -3552 },
- { 2542, 2866, 2705, -6402 },
- { 3134, 4323, 698, -4785 },
- { 731, 1859, 3112, -5242 },
- { 2553, 2980, 3241, -4846 },
- { 1329, 5310, 1607, -6624 },
- { 2468, 1858, 3476, -1034 },
- { -172, 4996, 2000, -5562 },
- { 2621, 4220, 1574, -3386 },
- { -333, 1832, 3362, -4117 },
- { 2169, 6762, 3065, -6225 },
- { 2844, 5528, 3223, -4765 },
- { 526, 5175, 1644, -4267 },
- { 2922, 4426, 2414, -2610 },
- { 452, 1399, -4516, -2636 },
- { 2872, 1720, -4667, -1435 },
- { 1279, 702, -5424, -1984 },
- { 2187, 870, -5021, -1341 },
- { 583, -144, -4628, -2464 },
- { 3, 2237, -5284, -2827 },
- { -19, 1005, -5460, -1819 },
- { 2897, 2084, -5885, -515 },
- { -400, 3370, -5527, -2947 },
- { 1505, 2593, -5518, -1802 },
- { 1341, 4534, -5094, -1899 },
- { 3241, 3670, -5493, -1252 },
- { -1287, 921, -5994, -1675 },
- { 627, 408, -6652, -364 },
- { -260, 1127, -4849, -3247 },
- { 371, 3400, -5976, -2285 },
- { 1533, 1566, -6373, -610 },
- { 2462, 4274, -6184, -1254 },
- { 1782, 3363, -6222, -1381 },
- { 572, 4650, -5673, -2754 },
- { 2674, 3414, -4460, -2154 },
- { 3614, 3820, -6883, -398 },
- { 1136, -1, -5511, -1112 },
- { -1773, 1137, -5647, -2377 },
- { -753, 2104, -6085, -2565 },
- { -204, 3025, -4731, -1418 },
- { -1486, 1438, -4380, -216 },
- { 302, 858, -5786, -264 },
- { 3486, 1495, -5234, -783 },
- { 888, 2327, -3423, -3720 },
- { -259, 772, -6596, -1311 },
- { -1197, 2073, -5174, -1826 },
- { 1500, 3470, -4462, -2645 },
- { 3072, 1960, -3277, -2264 },
- { 1841, 952, -4324, -2340 },
- { 1994, 2200, -3940, -2923 },
- { -1782, 1699, -4667, -1075 },
- { -1464, 2906, -3468, -375 },
- { 366, 2380, -3747, 1467 },
- { -545, 1645, -4619, 376 },
- { 1724, 2350, -2374, -3512 },
- { 3184, 2628, -2996, -3275 },
- { 734, 2010, -6239, -1479 },
- { 524, 3756, -4496, -3263 },
- { 1492, 3570, -3494, -3600 },
- { -932, 618, -5389, -2894 },
- { -133, 2161, -4083, -3267 },
- { 786, 774, -3279, -3731 },
- { 1078, 803, -3843, -3007 },
- { -332, 3405, -3347, 40 },
- { -17, 6, -4005, -3690 },
- { -189, 4372, -4488, -2561 },
- { -450, 3846, -3790, -1370 },
- { 362, 2212, -5272, -15 },
- { -1529, 791, -6802, -2296 },
- { 2145, 4241, -4474, 376 },
- { 1813, 2426, -2932, -2726 },
- { -542, 4557, -3140, -1080 },
- { 1192, 3784, -4371, -20 },
- { 2784, 5188, -6399, -1394 },
- { 431, 4561, -3673, -1398 },
- { 1382, 3096, -4083, 1253 },
- { 1209, 4224, -2930, 1500 },
- { 2798, 2684, -6676, -606 },
- { -2396, 1510, -5381, -2713 },
- { -2625, 2542, -4032, -2880 },
- { -1231, 3967, -4098, -2886 },
- { -1393, 2374, -3862, -4525 },
- { -2495, 1665, -1637, -5445 },
- { -3854, 1759, -1750, -4944 },
- { -2373, 1668, -2856, -6251 },
- { -2668, 1981, -886, -4557 },
- { -2927, 4427, -3451, -6172 },
- { -1925, 2596, -4696, -2527 },
- { -3202, 2847, -3928, -5896 },
- { -3332, 1665, -5025, -3412 },
- { -3212, 3115, -4155, -4062 },
- { -1013, 3205, -5133, -3751 },
- { -2022, 4595, -3947, -5611 },
- { -3556, 1755, -3715, -2300 },
- { -1784, 4114, -2723, -1773 },
- { -3586, 4081, -2733, -4942 },
- { -1608, 3685, -4154, -4573 },
- { -3368, 4042, -4452, -6227 },
- { -1407, 3881, -5729, -3719 },
- { -2751, 3281, -5077, -4999 },
- { -3791, 2410, -4906, -5288 },
- { -730, 2303, -4217, -3755 },
- { -1812, 2311, -5492, -3709 },
- { -610, 4336, -3915, -3783 },
- { -2841, 4337, -4278, -4430 },
- { -1662, 4666, -4661, -3964 },
- { -589, 5209, -4923, -3682 },
- { -4155, 2234, -4076, -4218 },
- { -3951, 2770, -2665, -2805 },
- { -2302, 3228, -3717, -1908 },
- { -3129, 4373, -2264, -2851 },
- { -447, 1363, -3578, -4323 },
- { -2648, 4237, -3159, -3071 },
- { -4072, 3241, -3541, -4605 },
- { -4507, 3458, -2339, -3838 },
- { -1646, 997, -4926, -3970 },
- { -3025, 1614, -3940, -1242 },
- { -1337, 1756, -3163, -5529 },
- { -3203, 1865, -3282, -4354 },
- { -1646, 2118, -2203, -6018 },
- { 174, 1871, -2707, -4639 },
- { -2607, 1485, -4778, -4750 },
- { -2199, 3991, -3134, -4879 },
- { -2962, 3323, -2816, -2419 },
- { -5286, 2495, -4548, -5395 },
- { -2810, 3710, -2274, -4211 },
- { -330, 3006, -2993, -4678 },
- { -1187, 2411, -2743, -5196 },
- { -664, 4033, -3101, -5641 },
- { -1458, 3602, -2816, -5371 },
- { -4116, 4923, -3321, -5630 },
- { -4165, 2528, -2592, -4798 },
- { -2759, 3080, -2333, -5719 },
- { -5157, 3011, -5526, -6348 },
- { -3095, 2126, -5881, -4234 },
- { -4377, 3849, -3600, -6099 },
- { -1994, 4947, -5235, -4753 },
- { -1067, 600, -3258, -5133 },
- { -4992, 3302, -2208, -5051 },
- { -3377, 2981, -1655, -4815 },
- { -3325, 2446, -1787, -6116 },
- { -2341, 2737, -3240, -6347 },
- { -2258, -3732, 3710, -1235 },
- { -1558, -3849, 2694, -3012 },
- { -599, -4837, 3050, -2951 },
- { -2246, -5433, 2798, -1910 },
- { -2255, -4989, 3260, 270 },
- { -3026, -5353, 2693, -1036 },
- { -1151, -6097, 1097, -3782 },
- { -3391, -6012, 2130, -1303 },
- { -2850, -4422, 3375, -480 },
- { -1138, -3779, 1491, -4162 },
- { -551, -3892, 3787, -2082 },
- { -3221, -3676, 3144, -1202 },
- { -3023, -5196, 2650, 605 },
- { -1756, -5729, 2646, 321 },
- { -2693, -4409, 494, -4797 },
- { -1913, -4573, 3372, -1730 },
- { -1277, -3604, 4061, -993 },
- { -420, -4993, 1351, -4796 },
- { -3052, -5333, 1435, -1242 },
- { -602, -5034, 3869, -1141 },
- { -2436, -4680, 1665, -3019 },
- { -2657, -3658, 1459, -3391 },
- { -1220, -6246, 2749, -525 },
- { -3838, -4844, 2265, -1735 },
- { -1247, -5679, 3356, -1417 },
- { -917, -5448, 3342, 105 },
- { -1756, -6839, 2276, -2350 },
- { -412, -5206, 1764, -3539 },
- { -1439, -6915, 1442, -3750 },
- { -1381, -4439, 3863, -282 },
- { -3482, -4953, 2726, -336 },
- { -1376, -5931, 1714, -1987 },
- { -1716, -4405, 2608, 105 },
- { -1590, -5191, 2652, -2704 },
- { -2149, -6442, 2453, -1263 },
- { -3426, -3832, 2334, -1829 },
- { -2747, -5948, 2362, -173 },
- { -2435, -3267, 2966, -1710 },
- { -3979, -4282, 2705, -775 },
- { -356, -4238, 2544, -4343 },
- { -1363, -6471, 2817, -1836 },
- { -2878, -5117, 218, -3149 },
- { -3539, -5196, 1710, -2356 },
- { -2888, -4537, 2746, -1701 },
- { -1870, -4439, 1496, -4121 },
- { -1486, -3388, 3349, -2145 },
- { -3333, -4138, 1467, -2876 },
- { -345, -5340, 1012, -1190 },
- { -1672, -4992, 2289, -1029 },
- { -2146, -5528, 3038, -635 },
- { -316, -3656, 3426, -3152 },
- { -2695, -5812, 2336, -2050 },
- { -2067, -6052, 737, -3258 },
- { -2664, -4205, -350, -1266 },
- { -617, -5406, 80, -4853 },
- { -2418, -3825, 1853, -1326 },
- { -1961, -4339, 583, -4315 },
- { -1495, -5141, -133, -5205 },
- { -3208, -6440, 1691, -2069 },
- { -2632, -3633, 2325, -2761 },
- { -2624, -5670, 1252, -3676 },
- { -3687, -5608, 687, -2833 },
- { -3320, -5707, 16, -3877 },
- { -2738, -6112, 84, -5135 },
- { 2277, -5661, 3076, 843 },
- { 1555, -5769, 2821, -5236 },
- { 536, -6381, 603, -4910 },
- { 734, -4609, 3314, -4092 },
- { 1836, -4547, 3267, -4322 },
- { -13, -5976, 3752, -1607 },
- { 1423, -6318, 2336, 398 },
- { 365, -7779, 1498, -534 },
- { 2104, -8366, 2946, -1345 },
- { 143, -5545, 1898, -3756 },
- { 655, -6852, 1430, 148 },
- { 4, -6653, 2397, -59 },
- { 2346, -5996, 4562, -934 },
- { 1229, -7104, 2963, -598 },
- { -528, -7048, 2887, -1790 },
- { 1451, -6857, 3900, -1637 },
- { 554, -6018, 3336, 9 },
- { 3278, -5758, 4034, 129 },
- { 3541, -7145, 4905, -1575 },
- { 2339, -6907, 3464, -301 },
- { 2775, -7301, 1667, -3894 },
- { 539, -7887, 991, -4156 },
- { 2115, -7421, 3131, -3075 },
- { 2803, -8546, 2564, -5836 },
- { 2869, -5833, 1620, -4561 },
- { 2591, -7281, 3215, -4719 },
- { -1228, -8477, 706, -4782 },
- { 1967, -5243, 4813, -1940 },
- { 701, -7010, 2273, -3893 },
- { 915, -8470, 1918, -5620 },
- { -94, -6715, 156, -3873 },
- { 1074, -5607, 4389, -1017 },
- { 2739, -6551, 1227, -3521 },
- { 725, -7835, 2701, -1291 },
- { -493, -7475, 2263, -1075 },
- { -412, -6508, 2984, -744 },
- { 665, -5451, 3725, -2692 },
- { 1499, -8129, 3564, -2072 },
- { 2870, -6333, 4487, -2108 },
- { 706, -5007, 3911, -152 },
- { -482, -8660, 1483, -2900 },
- { 2481, -6596, 2518, -1715 },
- { 1403, -6414, 1398, -5387 },
- { 652, -6267, 583, -5942 },
- { 694, -7540, 646, -6272 },
- { 2275, -7614, 256, -5015 },
- { 1416, -9727, 1900, -3153 },
- { 2760, -6433, 3875, -3771 },
- { 2325, -11196, 2182, -5155 },
- { 1223, -11061, 1377, -5097 },
- { 108, -10603, 307, -4952 },
- { -118, -8268, 1650, -1572 },
- { 1839, -7943, 1755, -612 },
- { 2501, -9056, 981, -2969 },
- { 2902, -8476, 1491, -5780 },
- { 1995, -11175, 1585, -3643 },
- { 696, -8212, 828, -2474 },
- { 1526, -8649, 1380, -1210 },
- { 461, -7253, 3222, -2229 },
- { 2966, -8641, 4121, -3271 },
- { 833, -6039, 2361, -1086 },
- { 3565, -7312, 1980, -5427 },
- { 2850, -8671, 3760, -1846 },
- { 2643, -7281, 2163, -173 },
- { 3463, -3706, -3132, -923 },
- { 1315, -3825, -3443, 2 },
- { 2594, -4083, -3815, 670 },
- { 1826, -4291, -2741, -155 },
- { 868, -3749, -4175, -298 },
- { 2008, -4237, -3897, -517 },
- { 1242, -3493, -4335, -1335 },
- { -88, -4142, -3390, -1529 },
- { 2176, -3488, -3822, -975 },
- { 1706, -5188, -3415, -637 },
- { 2717, -6159, -2333, -882 },
- { 1276, -3978, -4361, 537 },
- { 2471, -5556, -2866, -208 },
- { 799, -4673, -4086, 56 },
- { 1901, -4786, -3533, 270 },
- { 3036, -3902, -3606, -333 },
- { 2249, -3317, -4319, -144 },
- { 2594, -4207, -2105, -2930 },
- { 4008, -4774, -2626, -902 },
- { 1038, -3659, -3496, -2454 },
- { 2725, -3597, -3298, -1535 },
- { 1662, -5803, -2813, 175 },
- { 705, -3757, -3441, -1484 },
- { 1860, -5987, -2821, -886 },
- { 3786, -4918, -2199, -1929 },
- { 3683, -4235, -2547, -1287 },
- { 2531, -4896, -2956, -1593 },
- { 1005, -5585, -3324, -180 },
- { 1625, -5229, -1756, -3642 },
- { 1494, -5041, -2989, -2685 },
- { 2718, -4655, -3224, -867 },
- { 2374, -6640, -1745, -2975 },
- { 2133, -6436, -2477, -1499 },
- { 1833, -4418, -3523, -1512 },
- { 1128, -4910, -2658, -1106 },
- { 689, -4777, -2831, -2085 },
- { 3593, -5280, -2627, -315 },
- { 3264, -3771, -2673, -1861 },
- { 3202, -5602, -2409, 402 },
- { 552, -4618, -2221, -3002 },
- { 3095, -5356, -2666, -1083 },
- { 3401, -4609, -3146, 45 },
- { 3051, -4662, -2192, -2232 },
- { 2798, -5552, -2462, -1941 },
- { 2354, -5815, -2223, -2619 },
- { 192, -3708, -2807, -2658 },
- { 1886, -4226, -1862, -3529 },
- { 2526, -3976, -2819, -2332 },
- { 1577, -3870, -2711, -2806 },
- { 1288, -5588, -3382, -1403 },
- { 2711, -5399, -1564, -3253 },
- { 1459, -5492, -2222, -322 },
- { 2823, -5091, -2886, 776 },
- { 3559, -5821, -2109, -1360 },
- { 1587, -6331, -2760, -1909 },
- { 2139, -5213, -2874, -2120 },
- { 1318, -4337, -3695, -2098 },
- { 821, -4471, -1849, -565 },
- { 3329, -4782, -1725, -89 },
- { 582, -4914, -4105, -1119 },
- { 417, -4144, -4072, -2529 },
- { -199, -3803, -2765, -4042 },
- { 2731, -4283, -2143, 1 },
- { 2911, -6187, -1951, -2116 },
- { 1573, -6094, -493, -2838 },
- { 2081, -6927, -864, -3211 },
- { 1058, -7826, 79, -364 },
- { 3147, -5570, -684, -978 },
- { 3572, -5856, 1060, 1824 },
- { 1143, -6702, -1478, 338 },
- { 2341, -7220, -88, 260 },
- { 3639, -6861, 668, 815 },
- { 2227, -6268, -1706, 446 },
- { 3390, -6082, -353, 1302 },
- { 1123, -7556, -1237, -430 },
- { 1729, -7742, 729, -218 },
- { 1457, -6774, 587, 579 },
- { 505, -6919, -569, 371 },
- { 1106, -7245, 78, 158 },
- { 2755, -6745, -1122, 338 },
- { 3069, -6040, -1415, 986 },
- { 2174, -7064, -1430, -283 },
- { 1390, -8626, -446, -3031 },
- { 3534, -6890, -431, 547 },
- { 2267, -9618, 475, -2994 },
- { 3672, -7673, 75, -115 },
- { 2131, -7560, -1206, -750 },
- { 2972, -7477, -685, -262 },
- { 1604, -6637, -672, 699 },
- { 1666, -7577, -577, -240 },
- { 1591, -6554, -2158, -94 },
- { 2348, -6286, -353, 1123 },
- { 2017, -8810, -412, -1805 },
- { 2892, -6713, -1765, -554 },
- { 2500, -6828, -1995, -1197 },
- { 3877, -6639, -224, -1655 },
- { 2392, -7872, -91, -333 },
- { 3562, -7370, -532, -2836 },
- { 2552, -7614, 164, -1805 },
- { 990, -6104, 218, 438 },
- { 910, -7861, 312, -1195 },
- { 1472, -6327, 372, -640 },
- { 1576, -7143, -1983, -843 },
- { 422, -7625, -457, -278 },
- { 1797, -8532, 405, -1011 },
- { 1088, -7396, -238, -2277 },
- { 3209, -6753, -1431, -2072 },
- { 2617, -6839, 100, -2573 },
- { 2575, -8573, -387, -3188 },
- { 3618, -6971, -1190, -321 },
- { 2205, -7361, -1695, -2008 },
- { 2985, -6297, 1464, 1179 },
- { 2804, -7310, 1053, 338 },
- { 1362, -6074, -1163, -840 },
- { 3336, -6325, -1794, 21 },
- { 2836, -8109, 818, -329 },
- { 2791, -5879, 560, 1546 },
- { 2392, -6064, 135, 100 },
- { 1838, -6194, 596, 1085 },
- { 1926, -7515, -414, -4901 },
- { 3225, -7298, -1202, -1189 },
- { 3960, -7558, -659, -719 },
- { 3442, -6647, -1692, -1095 },
- { 3381, -6441, 262, -886 },
- { 1431, -8150, -1186, -1406 },
- { 340, -8498, -150, -899 },
- { 3004, -8149, -260, -953 },
- { 2749, -6611, 563, 873 },
- { -6647, -1325, -4517, -4691 },
- { -6005, -1657, -4089, -3797 },
- { -3157, 588, -5213, -3068 },
- { -3311, -1425, -6329, -3726 },
- { -5866, -819, -3857, -2744 },
- { -5001, -1799, -1075, -4621 },
- { -5330, -2650, -2672, -4664 },
- { -4930, -539, -2363, -4010 },
- { -2984, 10, -3863, -5749 },
- { -1055, -2106, -3713, -4267 },
- { -5476, -502, -4279, -6504 },
- { -5231, -1543, -5018, -6425 },
- { -5134, -363, -3165, -5109 },
- { -3953, -771, -4107, -6393 },
- { -2159, -563, -3652, -5342 },
- { -3888, -2321, -919, -5057 },
- { -1236, -597, -4235, -4193 },
- { -4053, 675, -3083, -6174 },
- { -2793, -1089, -5396, -3460 },
- { -3000, -44, -2209, -6575 },
- { -3336, -1531, -4313, -5160 },
- { -2127, 128, -4851, -3692 },
- { -3321, 136, -2067, -5660 },
- { -5215, 1404, -4374, -4356 },
- { -2747, 400, -6340, -3691 },
- { -3926, -599, -5361, -5006 },
- { -2875, -2592, -5143, -4092 },
- { -4991, -1958, -5322, -4891 },
- { -4965, -1318, -6652, -5333 },
- { -4920, -1691, -3388, -5561 },
- { -3644, -3354, -2688, -5982 },
- { -5076, -919, -4563, -2984 },
- { -6114, 250, -3884, -3915 },
- { -4014, 744, -3973, -1924 },
- { -5543, -1041, -5557, -3847 },
- { -4711, -1352, -5649, -2603 },
- { -3362, 775, -5305, -4879 },
- { -5001, 107, -3554, -2888 },
- { -6258, -1651, -6356, -6566 },
- { -4529, 407, -5003, -3865 },
- { -5154, 550, -5278, -5465 },
- { -4195, -467, -1894, -3129 },
- { -5022, 1127, -3349, -3314 },
- { -6075, 1250, -4313, -5641 },
- { -2677, -2283, -2312, -5903 },
- { -4113, 193, -1195, -4833 },
- { -3940, -1048, -1389, -5079 },
- { -3703, 917, -4043, -4451 },
- { -3366, -4231, -1534, -5488 },
- { -3326, -3583, -2091, -4903 },
- { -5144, 1254, -2532, -4949 },
- { -5982, -870, -2545, -4555 },
- { -3925, -157, -5367, -2281 },
- { -6419, -746, -5668, -4371 },
- { -5787, 518, -7096, -5805 },
- { -4258, 954, -6453, -4321 },
- { -4771, -695, -4158, -1639 },
- { -7078, -760, -5195, -5877 },
- { -7348, 83, -4101, -4586 },
- { -2430, 184, -2874, -1679 },
- { -2284, -3943, -2924, -5034 },
- { -1804, -1785, -3002, -4710 },
- { -4399, -2772, -1815, -4637 },
- { -6340, -2626, -2824, -5191 },
- { -4998, -5168, -3480, 1905 },
- { -3958, -5492, -1599, 1579 },
- { -2471, -3755, -276, 3182 },
- { -3033, -5779, -1063, 1554 },
- { -2936, -4829, -1290, 2386 },
- { -1835, -5073, -3051, 1299 },
- { -1724, -3771, -3935, 2324 },
- { -5070, -2550, -3692, 768 },
- { -4326, -5333, -297, 1878 },
- { -3472, -5619, -3094, 992 },
- { -3027, -4384, -3038, 2265 },
- { -3201, -5332, 67, 2200 },
- { -1681, -4373, -1947, 2461 },
- { -3221, -3329, -4238, 2564 },
- { -1262, -2968, -2915, 3227 },
- { -3419, -1878, -3373, 2110 },
- { -2244, -5583, -2012, 1288 },
- { -1971, -5266, -990, 1812 },
- { -2975, -2778, -452, 4063 },
- { -2198, -1165, -3298, 2965 },
- { -4782, -4894, -4767, 664 },
- { -6002, -3950, -2806, 2025 },
- { -3142, -3162, -2859, 3295 },
- { -3262, -3340, -4123, 1596 },
- { -4014, -3918, -1955, 3361 },
- { -1700, -3463, -1346, 3449 },
- { -4245, -4445, -4743, 1644 },
- { -4180, -3969, -401, 3281 },
- { -2782, -5240, -4117, 1156 },
- { -5744, -4040, -1439, 3470 },
- { -5063, -4663, -323, 3172 },
- { -4531, -3319, -844, 3988 },
- { -6226, -5125, -2064, 2976 },
- { -3115, -3267, -1531, 3898 },
- { -4628, -4421, -2864, 2808 },
- { -4559, -2989, -3442, 2024 },
- { -1775, -4487, -656, 2477 },
- { -2664, -1865, -1884, 4081 },
- { -1828, -2575, -3894, 3378 },
- { -6441, -3677, -2025, 1677 },
- { -4141, -2156, -1191, 3474 },
- { -4802, -1623, -1727, 2160 },
- { -5474, -2745, -1475, 2498 },
- { -3664, -1056, -1975, 2491 },
- { -4672, -3062, -2235, 2933 },
- { -4205, -5960, -2849, 1517 },
- { -4995, -5708, -1739, 1805 },
- { -4892, -6080, -4793, 872 },
- { -4270, -4172, -4263, 2185 },
- { -4687, -1470, -2905, 1023 },
- { -6446, -5017, -3919, 1000 },
- { -6046, -5538, -3943, 2006 },
- { -6028, -3750, -3953, 771 },
- { -5959, -4582, -5024, 824 },
- { -5818, -2576, -2249, 1326 },
- { -5659, -5345, -1119, 2500 },
- { -3346, -4155, 606, 2749 },
- { -5680, -4827, -2501, 1838 },
- { -6193, -2543, -1295, 840 },
- { -6871, -4925, -3512, 1801 },
- { -5605, -1788, -1895, 779 },
- { -3922, -5712, -4644, 510 },
- { -4745, -3869, -4533, 99 },
- { -2984, -4907, -399, 1497 },
- { 1847, -478, 3061, -5812 },
- { 4450, -1116, 3609, -6570 },
- { 3139, 99, 3007, -5532 },
- { 2590, -3782, 3138, -4770 },
- { 1881, 1204, 5778, -3404 },
- { 3631, 2060, 5566, -5038 },
- { 3461, 1961, 5167, -3800 },
- { 2947, 273, 4536, -4389 },
- { 4453, -1730, 5788, -4370 },
- { 4032, 1805, 2666, -4534 },
- { 3487, -944, 2313, -6028 },
- { 1313, 34, 4210, -4067 },
- { 5632, -1502, 5825, -5855 },
- { 7736, -547, 4879, -5476 },
- { 4906, -1512, 4760, -5760 },
- { 3843, 447, 1091, -4958 },
- { 2982, -1135, 5442, -4386 },
- { 3579, 271, 3031, -6770 },
- { 3932, -211, 4688, -5507 },
- { 4411, 1720, 2387, -5584 },
- { 5379, -479, 4575, -6280 },
- { 3613, -362, 2012, -4885 },
- { 3744, -2013, 4493, -5073 },
- { 5693, 109, 4379, -3362 },
- { 5475, -621, 5317, -3985 },
- { 6411, -673, 5708, -4752 },
- { 4933, -796, 7262, -4290 },
- { 2804, 444, 6276, -3655 },
- { 4120, -517, 6078, -4531 },
- { 5119, 841, 3486, -3910 },
- { 4738, 1539, 3525, -2970 },
- { 5086, 370, 5895, -5640 },
- { 4235, 2716, 4589, -5044 },
- { 3691, 682, 6199, -4700 },
- { 6111, -570, 6271, -6528 },
- { 2611, 1277, 3756, -4802 },
- { 4395, 970, 3807, -5879 },
- { 5225, 2299, 3242, -4333 },
- { 5144, 1778, 4946, -5545 },
- { 2989, -3016, 3247, -5495 },
- { 2983, 920, 2071, -6059 },
- { 5270, -903, 4434, -2350 },
- { 6415, -585, 3970, -3554 },
- { 3866, -197, 5216, -2884 },
- { 3767, -1298, 6702, -3315 },
- { 6299, 2620, 5284, -6824 },
- { 6654, 646, 3653, -4927 },
- { 4770, 3047, 5160, -6287 },
- { 5364, 434, 2919, -5207 },
- { 2998, 1344, 4801, -2456 },
- { 3896, 1013, 3773, -1864 },
- { 2115, 655, 2999, -6344 },
- { 5170, -981, 2849, -4464 },
- { 2735, -2159, 2717, -5776 },
- { 2430, -1952, 4392, -4559 },
- { 6143, -1180, 3659, -4746 },
- { 4978, -1483, 1726, -4875 },
- { 3486, -2383, 3306, -4301 },
- { 1434, -1372, 4171, -4770 },
- { 3354, -2627, 1525, -5093 },
- { 6790, 2386, 3995, -5909 },
- { 1475, -2674, 3451, -4204 },
- { 1999, -3494, 3693, -5556 },
- { 4764, -2848, 2856, -5589 },
- { -3677, 5131, 2827, -2934 },
- { -2844, 7078, 2852, -3580 },
- { -3902, 6434, 4118, -1911 },
- { -1769, 7530, 3492, -3541 },
- { -1937, 5679, -447, -1127 },
- { -2456, 4680, 4196, -2407 },
- { -2778, 8241, 1698, -4288 },
- { -2876, 6104, 5182, -2387 },
- { -2802, 7341, 4463, -2938 },
- { -1025, 6267, 4752, -3201 },
- { -2349, 5413, 2041, -3794 },
- { -2252, 8225, 2856, -4269 },
- { -1465, 4967, 4976, -2500 },
- { -636, 7565, 3517, -4233 },
- { -1905, 5618, 3904, -2942 },
- { -302, 6816, 3343, -3316 },
- { -2210, 4156, 2817, -3511 },
- { -717, 6568, 1863, -2951 },
- { -3873, 5682, 2164, -575 },
- { -2878, 5835, 440, -2597 },
- { -3228, 7701, 2610, -2514 },
- { -3608, 8888, 3377, -2468 },
- { -2582, 9717, 2519, -3126 },
- { -5238, 6202, 2866, -2831 },
- { -3428, 7370, 3056, -335 },
- { -1681, 8836, 1210, -2010 },
- { -3276, 6724, 1156, -3930 },
- { -894, 8149, 827, -1258 },
- { -2965, 8631, 2549, -1320 },
- { -3961, 6902, 3581, 55 },
- { -1894, 7745, 1750, -841 },
- { -821, 6844, 850, -676 },
- { -608, 6948, -4, -1376 },
- { 615, 6524, 1089, -1147 },
- { -2972, 5668, 1091, -489 },
- { -157, 4649, 2904, -413 },
- { 673, 5121, 1498, -66 },
- { -390, 5902, 1611, -245 },
- { -2349, 5478, 4772, -1320 },
- { 88, 6798, 1972, -1859 },
- { -1213, 5120, 2991, 200 },
- { -2347, 6040, 2839, 376 },
- { -578, 5976, 3364, -1796 },
- { -1391, 5872, 3002, -965 },
- { -564, 4496, 3946, -1186 },
- { -2299, 6386, 3135, -2176 },
- { -2131, 5641, 2011, 1223 },
- { -772, 5807, 1124, 895 },
- { -2837, 6758, 2297, -740 },
- { -3091, 6298, 1415, -2126 },
- { -4197, 6036, 1843, -3022 },
- { -41, 6459, 92, 344 },
- { -2241, 6860, 2095, -4396 },
- { -1931, 7088, 2117, -2135 },
- { -2375, 4422, 1688, -3169 },
- { -1742, 6674, 1538, -119 },
- { -4818, 7749, 4192, -1577 },
- { -2004, 5672, 193, -430 },
- { -3825, 6042, 2128, -1898 },
- { -1108, 8033, 2119, -3013 },
- { -2370, 5453, 1721, 266 },
- { -1570, 7134, 614, -2638 },
- { -1519, 8752, 3503, -4330 },
- { -2050, 3845, 2907, -1126 },
- { 5085, 4412, -335, -1923 },
- { 3618, 1423, -613, -4012 },
- { 4481, 3729, 589, -4631 },
- { 4270, 3216, -1763, -3168 },
- { 4241, 1796, -1701, -2796 },
- { 4787, 2338, -487, -3639 },
- { 2915, 3429, -621, -4753 },
- { 5175, 1660, -1265, -3223 },
- { 4280, 4057, -684, -4079 },
- { 4980, 4419, -1455, -2719 },
- { 5436, 2464, 387, -4197 },
- { 4507, 4018, 1121, -3314 },
- { 6020, 2401, -413, -3201 },
- { 4200, 3789, -333, -2813 },
- { 5229, 2493, -1194, -1878 },
- { 5851, 2695, -492, -2292 },
- { 5743, 3288, -697, -1221 },
- { 5692, 2612, 979, -2227 },
- { 5085, 2067, 1046, -1214 },
- { 3163, 2240, -2098, -3435 },
- { 5228, 1898, 145, -2397 },
- { 5860, 3976, -418, -2872 },
- { 6008, 3399, 1027, -3506 },
- { 4126, 2035, 1865, -893 },
- { 5375, 3596, 511, -2362 },
- { 1937, 1493, -852, -122 },
- { 3473, 4849, 547, -2603 },
- { 4631, 2977, 1141, -1768 },
- { 6149, 3050, -71, -1886 },
- { 4069, 4353, -289, -1429 },
- { 2884, 1225, -1388, 365 },
- { 5485, 2518, -235, -571 },
- { 1216, 4375, 1443, 398 },
- { 4988, 3106, 107, -1435 },
- { 4511, 2801, 307, -444 },
- { 3235, 4386, 327, -676 },
- { 2055, 3708, 1657, -305 },
- { 5839, 2374, 290, -1385 },
- { 5110, 3305, 1936, -4206 },
- { 6416, 2920, 338, -2736 },
- { 3350, 2824, -1269, -3881 },
- { 4840, 1815, 464, 186 },
- { 2399, 3332, 238, 1238 },
- { 3516, 1363, 1582, 688 },
- { 3582, 1874, 154, -4770 },
- { 3261, 2878, 886, 283 },
- { 3877, 2658, -327, 884 },
- { 4151, 3436, 2173, -2923 },
- { 3592, 3674, 1281, -1295 },
- { 4561, 3730, -1114, -1747 },
- { 4595, 3625, -558, -575 },
- { 2577, 2348, 2267, 120 },
- { 5242, 3299, 32, -3412 },
- { 4264, 3637, 709, -2320 },
- { 6556, 3570, -838, -2472 },
- { 5745, 4014, -940, -1973 },
- { 5629, 4475, 477, -3328 },
- { 5269, 3199, 1682, -3085 },
- { 4432, 2416, 1145, -3299 },
- { 4465, 2505, 2162, -2186 },
- { 4643, 4941, -88, -2885 },
- { 4568, 5231, 552, -3915 },
- { 5667, 3075, -1406, -2963 },
- { 5418, 5259, -771, -2818 },
- { -256, -7875, 511, -471 },
- { -1813, -7971, -424, -396 },
- { -306, -7006, 862, 282 },
- { -2306, -6422, -1440, 508 },
- { -245, -6787, 375, -100 },
- { -1309, -6065, -20, 779 },
- { -1656, -6047, -641, 1307 },
- { -1496, -6522, 964, 726 },
- { -2291, -6588, -202, 795 },
- { -762, -7522, 1454, -558 },
- { -2270, -7004, -834, -580 },
- { -1139, -7078, 259, 362 },
- { -2535, -7568, -1040, 49 },
- { -3786, -7280, 934, -476 },
- { -3336, -6368, 606, 1056 },
- { -3602, -6924, 52, 714 },
- { -2278, -6550, 1674, 204 },
- { -2855, -5765, 930, 1530 },
- { -2889, -7325, -215, 305 },
- { -2749, -6080, -237, 1452 },
- { -985, -6667, 1577, 400 },
- { -2036, -6083, 380, 1267 },
- { -2077, -7460, 380, -30 },
- { -1775, -7175, 1540, -386 },
- { -3065, -6927, 989, 168 },
- { -2836, -7602, 117, -3392 },
- { -1058, -6396, 593, -3078 },
- { -844, -6062, 999, -236 },
- { -3261, -6951, 1491, -720 },
- { -2186, -8484, 75, -1287 },
- { -2882, -7756, 456, -510 },
- { -1800, -6879, 960, -1183 },
- { -2554, -7241, 1614, -1474 },
- { -2608, -5305, 392, 851 },
- { -2973, -6562, -859, 858 },
- { -2640, -5989, 1031, -416 },
- { -977, -8366, 705, -1434 },
- { -1213, -7409, -77, -1390 },
- { -1335, -6657, 2125, -123 },
- { -2544, -6862, 1852, -737 },
- { -3235, -6422, 1752, -103 },
- { -1300, -7557, 939, -348 },
- { -3476, -7579, 202, -109 },
- { -2482, -6572, 753, 619 },
- { -2554, -8136, -648, -429 },
- { -1012, -7870, -3, -421 },
- { -3604, -6247, 32, -3102 },
- { -1486, -7271, 2013, -1021 },
- { -578, -6799, -523, 405 },
- { -2841, -5948, 1644, 911 },
- { -2411, -7473, 1084, -484 },
- { -2238, -6033, 294, -1059 },
- { -3459, -6470, -201, -790 },
- { -2027, -6009, 1833, 805 },
- { -1433, -8047, 1531, -1754 },
- { -3258, -7884, 763, -1422 },
- { -1544, -6928, -729, 478 },
- { -2314, -8415, 74, -3757 },
- { -3201, -5684, 95, -2214 },
- { -2423, -8694, 725, -3631 },
- { -3545, -7071, 1162, -1798 },
- { -294, -9662, 403, -2274 },
- { -2290, -5460, 1196, 402 },
- { -1603, -6713, 903, -2363 },
- { 4121, 2491, -3142, -2482 },
- { 4500, 3305, -3671, -1567 },
- { 5973, 3172, -1348, -534 },
- { 4830, 3379, -1549, 643 },
- { 5214, 3938, -2641, -2302 },
- { 4639, 4826, -5532, -847 },
- { 5639, 2731, -2170, -963 },
- { 6084, 3487, -3525, -1346 },
- { 5971, 3154, -2190, -2316 },
- { 5618, 4865, -6927, 116 },
- { 5345, 3568, -7391, 709 },
- { 5429, 5078, -3811, -1524 },
- { 6960, 2037, -3515, -1096 },
- { 7092, 2531, -4557, -588 },
- { 6061, 4247, -5651, -478 },
- { 4595, 3684, -4907, -827 },
- { 7497, 3213, -3048, -424 },
- { 5996, 2137, -3098, -1745 },
- { 6198, 5199, -2223, -2274 },
- { 6888, 2851, -2768, -1675 },
- { 6114, 4210, -2316, -954 },
- { 7127, 4242, -3041, -1408 },
- { 6126, 3668, -1517, -1427 },
- { 6245, 6129, -4225, -1186 },
- { 6816, 3213, -2101, -964 },
- { 5345, 5276, -2643, -847 },
- { 6592, 4665, -4338, 484 },
- { 6746, 3751, -3443, 124 },
- { 5453, 1980, -2738, 2606 },
- { 4662, 2179, -4226, -1059 },
- { 5571, 3208, -3554, 174 },
- { 5256, 4447, -1815, -1481 },
- { 5400, 2570, -1210, 235 },
- { 7056, 2549, -2674, 318 },
- { 4574, 4340, -2892, -130 },
- { 6203, 4587, -3273, -305 },
- { 5103, 1925, -2715, -2137 },
- { 3905, 4296, -1700, 247 },
- { 4421, 4605, -3299, 811 },
- { 5671, 1273, -3870, -924 },
- { 5486, 1805, -4901, 133 },
- { 6437, 2578, -1828, -106 },
- { 5530, 5253, -5058, 1223 },
- { 4816, 2025, -1215, 1443 },
- { 3457, 3525, -2456, 3217 },
- { 3316, 2595, -1108, 2459 },
- { 3068, 3810, -2207, 1926 },
- { 6351, 5436, -6470, 600 },
- { 6324, 4240, -5365, 2416 },
- { 4851, 4774, -4075, 1878 },
- { 4900, 3679, -5198, 1078 },
- { 8347, 3633, -4565, -171 },
- { 5244, 5718, -3853, 173 },
- { 3960, 3492, -2939, 2105 },
- { 6070, 3473, -2351, 161 },
- { 8228, 3034, -3360, -901 },
- { 7006, 3985, -1940, -1926 },
- { 7123, 4681, -4301, -878 },
- { 5122, 4097, -1851, -449 },
- { 6200, 2060, -2251, 1049 },
- { 7106, 3844, -7209, 2625 },
- { 7108, 3370, -6734, 533 },
- { 6859, 2849, -3992, 1360 },
- { 5458, 2278, -3253, 1131 },
- { -1072, -2109, 4783, -1073 },
- { -319, -2604, 4257, -2418 },
- { 2466, 1300, 3476, -314 },
- { 2847, -1502, 5296, -141 },
- { 1667, -1273, 5559, -2725 },
- { 2877, -3402, 6434, 204 },
- { 53, -2637, 5275, -1181 },
- { 1091, -2215, 5803, -1549 },
- { 2397, -922, 4327, 1182 },
- { 219, -3747, 4647, -1564 },
- { -29, -2705, 4812, 1277 },
- { 1499, -2608, 5648, 1407 },
- { 2139, -2399, 4202, 2791 },
- { -426, -2064, 5528, 151 },
- { 2560, -2803, 6179, -2806 },
- { 4537, -2479, 3797, 1095 },
- { 888, -3357, 5341, -415 },
- { 4460, -1814, 5388, -1227 },
- { 3920, -3268, 6364, -703 },
- { 3343, -4698, 4410, 784 },
- { 309, -1897, 6306, 1223 },
- { 958, -3318, 4254, -3167 },
- { -99, 1596, 6018, -1983 },
- { -429, -853, 6407, 878 },
- { 1170, -1322, 6290, -417 },
- { 2288, -505, 6303, -1999 },
- { 3312, -1674, 6749, -2494 },
- { -415, -3401, 4721, -371 },
- { -189, -1210, 4844, -2002 },
- { 888, -4142, 4377, 130 },
- { 2469, -4381, 5398, -2492 },
- { 2879, -2912, 5094, -2598 },
- { -717, -617, 5650, -685 },
- { 1470, -3863, 5352, -1684 },
- { 3935, -96, 3823, -730 },
- { 3769, -430, 3168, 694 },
- { 2556, 385, 3539, 512 },
- { 77, -1415, 5111, 2655 },
- { 2724, -2158, 6715, -822 },
- { 1832, 1001, 5385, -1900 },
- { 900, 2198, 4464, -559 },
- { 441, 69, 5921, -1743 },
- { -1161, 738, 6732, -308 },
- { 257, 2035, 4091, 736 },
- { 1607, 1288, 4355, -23 },
- { -13, 1316, 4180, 1672 },
- { 1511, 1336, 3057, 1435 },
- { 2189, -3813, 4530, 939 },
- { 3632, -706, 2646, 1375 },
- { 4266, -3761, 4241, 1077 },
- { 3101, -427, 5273, -1202 },
- { 2293, 276, 4810, -313 },
- { 3430, -1851, 3101, 2045 },
- { 3453, -2979, 5142, 942 },
- { 1683, -3281, 4802, 2002 },
- { 3954, -4715, 5611, 578 },
- { 1272, -155, 5085, 454 },
- { 128, -194, 5095, 1409 },
- { 820, 880, 5797, -2658 },
- { -1095, 656, 5774, 1095 },
- { 813, -1669, 4320, -3251 },
- { -119, 518, 6372, -651 },
- { 2922, -4299, 6115, -877 },
- { 4205, -4273, 4004, 2642 },
- { -1211, -3892, 224, 3127 },
- { -34, -4371, 1321, 2318 },
- { 77, -6326, 1201, 828 },
- { 3995, -3775, 1958, 3233 },
- { 178, -3301, 1985, 3318 },
- { 2330, -3801, 1033, 3195 },
- { 1413, -5536, 826, 1709 },
- { 2468, -3499, 3653, 3631 },
- { 741, -4617, 1723, 2008 },
- { 1246, -3043, 2978, 3949 },
- { -343, -4308, 2258, 2189 },
- { -682, -4640, 454, 2272 },
- { 1236, -4829, 2491, 1642 },
- { -512, -3766, 1182, 3052 },
- { 119, -3939, 3712, 971 },
- { -1145, -4624, 1360, 2281 },
- { 101, -4746, 2866, 1255 },
- { -1500, -5455, 539, 1637 },
- { -969, -5909, 1414, 1128 },
- { -1261, -4939, -231, 2022 },
- { -226, -5345, 1207, 705 },
- { 2712, -5109, 3205, 1866 },
- { -476, -5913, 273, 1208 },
- { -2039, -4464, 624, 2545 },
- { -2351, -3930, 2019, 2673 },
- { -2675, -4849, 1522, 1990 },
- { -1524, -3461, 1446, 3204 },
- { 477, -5314, 1710, 1577 },
- { 656, -3729, 2346, 2511 },
- { 550, -5917, 1975, 1040 },
- { 1728, -4704, 3067, 1058 },
- { -9, -5247, 506, 1760 },
- { -574, -5135, 1675, 1672 },
- { 2129, -3781, 3444, 2313 },
- { 1144, -4439, 2214, 2529 },
- { 1292, -4160, 3185, 1833 },
- { 2445, -3262, 2534, 3227 },
- { 2266, -4401, 2023, 2400 },
- { -587, -3602, 3408, 2067 },
- { -885, -4951, 3228, 1174 },
- { -728, -2711, 2807, 3552 },
- { 1019, -3043, 3195, 2954 },
- { 1888, -4615, 1140, 2454 },
- { 660, -5616, 754, 800 },
- { -1975, -5371, 1649, 1585 },
- { -1544, -5436, 2422, 1081 },
- { -422, -5882, 2390, 750 },
- { 1336, -5557, 2441, 1230 },
- { 136, -4001, 267, 2854 },
- { -522, -3289, 2226, 2728 },
- { -971, -4580, 2471, 708 },
- { 704, -5306, 3300, 1001 },
- { 325, -3464, 3555, 2398 },
- { 794, -3686, 848, 3169 },
- { 660, -3017, 4584, 3242 },
- { -1486, -3978, 2170, 1644 },
- { -1615, -4650, 2688, 1844 },
- { 750, -4578, 538, 2239 },
- { 1668, -5849, 1455, 1031 },
- { 3486, -4681, 2030, 2183 },
- { 2642, -5429, 1696, 1761 },
- { 4491, -4502, 3538, 2767 },
- { 3545, -4528, 3514, 2982 },
- { 3269, -3676, 2758, 3966 },
- { 5572, 1146, 209, -3379 },
- { 7459, 1053, 593, -1896 },
- { 4480, 200, -310, -4259 },
- { 5577, -939, 242, -3992 },
- { 8142, 442, 1257, -3083 },
- { 5442, 1261, 1424, -3236 },
- { 6260, -183, 3125, -2532 },
- { 7179, 889, 1618, -2548 },
- { 6416, 932, 2379, -2487 },
- { 7094, 2560, 961, -3392 },
- { 7322, 463, 2732, -3735 },
- { 6632, 1577, 1912, -3272 },
- { 6312, 1349, 3028, -3460 },
- { 6105, 386, 1213, -977 },
- { 5478, 1158, 1114, -486 },
- { 6493, 410, 1686, -2180 },
- { 6378, 1881, 1333, -2240 },
- { 5711, 812, 1958, -1300 },
- { 6844, 877, 730, -1189 },
- { 6824, -245, 2249, -2000 },
- { 7515, 1521, 1251, -3058 },
- { 6697, 1051, 1300, -1749 },
- { 6476, 1425, 811, -2773 },
- { 7350, 465, -76, -2849 },
- { 6975, 2095, 567, -2492 },
- { 4691, 1736, 2660, -2289 },
- { 7837, 1456, 340, -2767 },
- { 7930, 507, 838, -2074 },
- { 6106, 1502, 766, -1110 },
- { 4891, -659, 835, -3954 },
- { 7250, 141, 1369, -1523 },
- { 7651, 67, 1651, -2298 },
- { 7364, -305, 601, -3132 },
- { 7179, 193, 2491, -2871 },
- { 6504, -272, 2167, -1322 },
- { 4456, 983, 2300, -421 },
- { 4817, 457, 1695, 371 },
- { 6914, 555, 850, -3159 },
- { 5904, 1030, 202, -1959 },
- { 6258, 880, 2233, -4503 },
- { 6029, 10, 2130, -3600 },
- { 6449, 985, 1129, -3963 },
- { 6616, -18, -111, -3285 },
- { 4496, 775, 817, -4276 },
- { 6134, 2338, 1470, -2973 },
- { 6911, 152, 430, -1946 },
- { 4053, 991, 3218, -1193 },
- { 5435, 1285, 3124, -2412 },
- { 5507, 1836, 1935, -1988 },
- { 5240, 689, 2189, -2670 },
- { 6638, 1719, 606, -1799 },
- { 5556, -180, 129, -2595 },
- { 5644, 1918, 1281, -4316 },
- { 6410, 1088, -282, -3117 },
- { 6503, 1841, 312, -3514 },
- { 6947, 20, 1358, -3886 },
- { 5464, 2109, 2398, -3194 },
- { 5616, -407, 2140, -498 },
- { 6121, 2707, 2379, -4096 },
- { 7303, 1846, 2266, -4095 },
- { 5444, 470, 2718, -1553 },
- { 5817, -645, 3285, -1349 },
- { 5625, 1427, 1103, -1991 },
- { 6041, -806, 1196, -2943 },
- { 3050, -5722, 4070, -5460 },
- { 3420, -4386, 4078, -5155 },
- { 6020, -3982, 7268, -2689 },
- { 7502, -4317, 7894, -3973 },
- { 4156, -3558, 5247, -4316 },
- { 4725, -4401, 7290, -1540 },
- { 6688, -5122, 8216, -3210 },
- { 9176, -6576, 9276, -4963 },
- { 8706, -5708, 7987, -4621 },
- { 7060, -3535, 6532, -3308 },
- { 5600, -2719, 5363, -1568 },
- { 4661, -2803, 6263, -4716 },
- { 3673, -3636, 6147, -3433 },
- { 5305, -2585, 6073, -2638 },
- { 7614, -1962, 6079, -5266 },
- { 6760, -3366, 7382, -4322 },
- { 6385, -3883, 4797, -1353 },
- { 8182, -5120, 4298, -4641 },
- { 9130, -6198, 4975, -3063 },
- { 7421, -5436, 5576, -3713 },
- { 3483, -4898, 5443, -2745 },
- { 4907, -5643, 6390, -4105 },
- { 8119, -7008, 7992, -6764 },
- { 6528, -6122, 6967, -5590 },
- { 5890, -4190, 6624, -5688 },
- { 6815, -7934, 7275, -5456 },
- { 5434, -4306, 5169, -5378 },
- { 4364, -6436, 5376, -2604 },
- { 8152, -3404, 5913, -5048 },
- { 7983, -4863, 4262, -2461 },
- { 8023, -6188, 6238, -5062 },
- { 6753, -3692, 3935, -3723 },
- { 6826, -4760, 3284, -4051 },
- { 7224, -7423, 4492, -3875 },
- { 6904, -2590, 6587, -6248 },
- { 6106, -1944, 7345, -5506 },
- { 4956, -2990, 7808, -3146 },
- { 6908, -6885, 5949, -1288 },
- { 7162, -6058, 3419, -3401 },
- { 7015, -7080, 6907, -3018 },
- { 6971, -6832, 5646, -3273 },
- { 8014, -5546, 5471, -1544 },
- { 6792, -2220, 5105, -2879 },
- { 8494, -3974, 4408, -3999 },
- { 9591, -4866, 6027, -4558 },
- { 5264, -5161, 6101, -738 },
- { 5803, -6141, 5197, -5231 },
- { 4657, -6822, 3232, -5189 },
- { 4791, -5135, 3809, -4665 },
- { 6108, -5103, 2379, -3873 },
- { 4680, -3909, 3234, -5093 },
- { 5802, -3853, 3795, -4984 },
- { 4360, -7483, 4802, -3877 },
- { 5429, -7517, 5911, -3717 },
- { 6866, -2280, 4880, -4634 },
- { 10131, -4628, 4414, -4092 },
- { 10811, -5189, 7746, -5337 },
- { 5663, -8941, 5287, -5680 },
- { 8023, -5991, 7403, -2796 },
- { 9669, -6919, 6525, -4932 },
- { 7275, -3796, 4962, -2547 },
- { 8848, -4806, 5677, -3080 },
- { 8128, -4308, 7749, -6569 },
- { 4032, -5196, 2282, -6239 },
- { 6593, 700, -229, 304 },
- { 8260, 539, -66, -1259 },
- { 6605, 176, -814, -109 },
- { 8057, 0, -1, -136 },
- { 7382, -38, -484, -1129 },
- { 8373, -929, 682, -454 },
- { 7674, 690, -1278, 546 },
- { 7326, -517, 406, -1283 },
- { 7612, -1715, -1167, 1175 },
- { 8590, 441, -782, -710 },
- { 8572, -1202, -291, 260 },
- { 7308, -147, -1785, 414 },
- { 6787, -353, -672, 934 },
- { 5177, -133, 179, 82 },
- { 4161, -34, 447, 1497 },
- { 5997, -902, 1533, -121 },
- { 5727, -871, -1370, 945 },
- { 8386, -252, 293, -823 },
- { 6573, -1354, 682, 616 },
- { 7650, -2096, 725, 457 },
- { 8122, 78, 636, -1400 },
- { 8421, 428, -1620, 131 },
- { 7341, -1292, -717, 186 },
- { 7998, -49, -720, 266 },
- { 5987, -351, 669, 844 },
- { 7314, -1620, 250, -603 },
- { 7219, -1562, -572, 1994 },
- { 8682, -358, -290, -388 },
- { 5810, 155, -178, 1199 },
- { 7246, -12, 1042, -786 },
- { 7357, -923, 1468, -475 },
- { 7801, 621, -212, -724 },
- { 5346, -514, 1210, 1356 },
- { 8459, 36, -127, -779 },
- { 6878, -2429, 854, 1750 },
- { 7280, -1401, -1353, 2845 },
- { 7579, -2148, -1463, 2087 },
- { 6637, 946, -872, 750 },
- { 4807, -1100, 1289, 2602 },
- { 4495, 219, 1551, 1128 },
- { 7639, 506, 446, -1107 },
- { 6359, 188, 1009, -115 },
- { 6641, -1820, 1655, 723 },
- { 5394, -2382, 1604, 2542 },
- { 6021, -2644, 2396, 1407 },
- { 4698, 882, 245, 1525 },
- { 8103, 573, -798, -349 },
- { 8045, -519, 997, -1092 },
- { 7571, -122, 227, -338 },
- { 5347, -1200, 630, 1718 },
- { 7070, 790, 218, -544 },
- { 7440, 728, -527, -20 },
- { 6402, -355, 197, -736 },
- { 4031, 771, 866, 1895 },
- { 6009, 896, 445, -31 },
- { 5160, 1098, -856, 1784 },
- { 7980, -886, -1293, 1396 },
- { 6318, -1361, 2423, 252 },
- { 7547, -699, 133, 506 },
- { 8562, -2344, 940, 264 },
- { 5890, 1187, -1425, 2194 },
- { 6558, -645, -1311, 2621 },
- { 4634, -1671, 2075, 1623 },
- { 5614, 105, -816, 2376 },
- { 6646, 1558, -1365, 630 },
- { 6998, 1150, -2117, -990 },
- { 6555, 2311, -1093, -1783 },
- { 6682, 1430, -2391, -1940 },
- { 7861, 1555, -2977, -1188 },
- { 6745, 1723, -459, -2085 },
- { 7504, 1229, -1666, -2060 },
- { 7937, 671, -2128, -1529 },
- { 7139, 991, -735, -2632 },
- { 6867, 1592, -1303, -2324 },
- { 6401, 2230, -1732, -2508 },
- { 7201, 2184, -2169, -1988 },
- { 6636, 2190, -995, -2840 },
- { 7620, 2306, -2089, -651 },
- { 7584, 1875, -1438, -631 },
- { 9214, 1561, -2464, -1139 },
- { 6154, 1318, -1237, -2917 },
- { 7917, 2847, -1797, -1599 },
- { 8309, 2029, -2555, -465 },
- { 8204, 1282, -584, -2405 },
- { 8440, 1035, -1147, -1137 },
- { 7107, 1858, -60, -1568 },
- { 6781, 2912, -873, -1463 },
- { 7603, 1316, -319, -1249 },
- { 7833, 1335, -78, -1849 },
- { 7930, 1141, -1016, -695 },
- { 7883, 1610, -1017, -1314 },
- { 8069, 1409, -1811, -196 },
- { 8319, 1031, -582, -1590 },
- { 5948, 1537, -2153, -2373 },
- { 8684, 1171, -1871, -850 },
- { 8357, 2484, -2411, -1292 },
- { 6516, 2092, -193, -1167 },
- { 6112, 1697, 22, -525 },
- { 7161, 703, -602, -1879 },
- { 6047, 2351, -807, -219 },
- { 8072, 1854, -1817, -1553 },
- { 6956, 1304, 76, -1011 },
- { 6607, 1481, -544, -162 },
- { 6958, 2541, -265, -1938 },
- { 6416, 2514, -777, -850 },
- { 7272, 2110, -899, -1171 },
- { 7741, 2153, -283, -2614 },
- { 6482, 2041, -1758, -1221 },
- { 6762, 940, -1862, -2281 },
- { 5610, 1194, -1691, -1561 },
- { 7833, 2164, -823, -1952 },
- { 5460, 1438, -848, 1189 },
- { 6011, 1377, -771, -1557 },
- { 7679, 544, -1134, -2214 },
- { 7209, 1292, -2714, -1564 },
- { 5567, 1200, -404, -169 },
- { 5853, 1461, -1465, -518 },
- { 6782, 689, -844, -860 },
- { 7330, 1337, -1152, -71 },
- { 7189, 1506, -653, -685 },
- { 6860, 2116, -1403, -240 },
- { 8804, 1516, -1391, -1760 },
- { 7210, 2689, -1498, -989 },
- { 7030, 3022, -1441, -2083 },
- { 5649, 1836, -407, 525 },
- { 7451, 3099, -717, -2464 },
- { 7384, 1656, -2007, 398 },
- { 6504, 707, -1919, -134 },
- { -1851, 3639, -2279, -695 },
- { -4037, 1644, -77, 1329 },
- { -4025, 1960, -1565, -567 },
- { -3430, 2495, -795, 368 },
- { -4771, 2480, 993, 756 },
- { -3431, 2058, -2539, -971 },
- { -3802, 3418, 380, 217 },
- { -3074, 3350, -1652, -1056 },
- { -3705, 326, -1650, 1535 },
- { -3122, 1281, -1192, 1607 },
- { -4601, 1367, -968, 53 },
- { -3808, 958, 44, 2560 },
- { -2079, 2530, -1485, 1166 },
- { -3707, 343, -2889, 180 },
- { -5249, 1431, -31, 688 },
- { -4990, 125, -704, 1270 },
- { -2771, 1334, -2446, 746 },
- { -2292, 994, -1527, 2630 },
- { -1261, 3070, -2519, 268 },
- { -2544, 3890, -1057, -552 },
- { -4421, 255, -1980, 530 },
- { -2951, 454, -13, 3643 },
- { -2262, 1815, -370, 2880 },
- { -2383, 3657, -649, 576 },
- { -3541, -161, -1389, 2550 },
- { -4241, 1575, 1325, 2561 },
- { -2767, 4037, 1221, 1578 },
- { -3748, 2697, 1148, 1801 },
- { -4686, 2385, -220, 0 },
- { -1531, 1645, -2751, 1327 },
- { -45, 4032, -799, 2298 },
- { -2915, 2280, 709, 2495 },
- { -1199, 3278, -406, 2346 },
- { -2471, 116, -2706, 2060 },
- { -2440, 2173, -2894, -344 },
- { -3375, 2287, 1781, 3226 },
- { -2153, 3568, 1827, 2918 },
- { -862, 2267, -1626, 2527 },
- { -2698, 1135, 301, 4239 },
- { -2364, 2123, 1010, 3710 },
- { -2447, 3281, -81, 1408 },
- { -2660, 4735, 472, 258 },
- { -1053, 3097, 2682, 2398 },
- { -3366, -1037, -1152, -868 },
- { -643, 4242, 2212, 1259 },
- { 971, 3991, 934, 643 },
- { -1617, 2002, 2139, 2195 },
- { -4897, 972, 784, 1719 },
- { -1275, 2992, 1039, 3821 },
- { -392, 4973, -209, 1821 },
- { -1028, 4718, -1479, -137 },
- { 50, 3914, 553, 2210 },
- { 678, 4364, 359, 1303 },
- { -582, 4911, 514, 1671 },
- { 1276, 3914, -1252, 2934 },
- { -1496, 3984, 857, 2330 },
- { 772, 4744, -655, 2332 },
- { -799, 5283, -439, 624 },
- { 1341, 2937, 650, 2027 },
- { -1739, 4892, 1275, 1702 },
- { -892, 2596, -151, 3951 },
- { -3532, 1090, 1292, 32 },
- { 321, 3146, 2647, 1475 },
- { 264, 4199, -1591, 1317 },
- { -452, -2357, 2266, 4192 },
- { 3022, -1033, -2389, 5678 },
- { -1162, -1342, 3543, 4990 },
- { -474, -1477, -1223, 5016 },
- { -699, -2857, 900, 3835 },
- { -461, -2255, -117, 4626 },
- { 1204, -2062, -1211, 4403 },
- { 2192, -3035, -337, 3966 },
- { 108, -831, 279, 5643 },
- { 1457, -620, -2908, 5276 },
- { -2527, -78, 1085, 5460 },
- { -1978, -1918, -949, 4733 },
- { 32, 367, -1904, 5166 },
- { 1890, -1665, 440, 4752 },
- { -518, -348, 2816, 4891 },
- { 3695, -2490, -1374, 4603 },
- { 246, -1965, 3549, 3969 },
- { 1100, -3111, 656, 3737 },
- { -1379, 870, -414, 4575 },
- { 628, -357, -1227, 6179 },
- { -1129, -1318, -2457, 4576 },
- { -425, -98, -73, 6336 },
- { 367, -887, 2990, 4207 },
- { 2091, -1251, 2444, 3557 },
- { -1759, -1610, 2046, 5273 },
- { 3210, 1414, -20, 2616 },
- { 3303, -2636, 1005, 4237 },
- { -327, -3107, -640, 3687 },
- { -197, 764, 572, 5486 },
- { 646, -767, 1388, 5464 },
- { 104, 2742, -228, 3907 },
- { -236, 1829, -579, 4585 },
- { -2150, -474, -1525, 4006 },
- { -23, -2632, -2400, 3892 },
- { -12, -1739, -2910, 4867 },
- { -2310, -368, -102, 4583 },
- { -1991, -2061, 533, 4531 },
- { 3884, -1446, -153, 4393 },
- { 1568, 14, -289, 5268 },
- { -1376, -253, -2797, 3417 },
- { 3193, -2577, 2475, 3566 },
- { 3418, 617, 1350, 1857 },
- { 3792, -24, -272, 3370 },
- { 153, 1159, 2906, 2877 },
- { 511, 2162, 1548, 2741 },
- { 262, 819, -2791, 3734 },
- { 4232, -2015, 1486, 3477 },
- { 2943, -1110, -1014, 5480 },
- { 2842, 369, 703, 3476 },
- { 3011, 1634, -933, 3553 },
- { 4412, -1548, -942, 5021 },
- { -1405, 593, 2372, 5267 },
- { 2093, 2129, 896, 2365 },
- { 4845, -1980, 0, 3823 },
- { -2140, 81, 3278, 5637 },
- { 1484, 2665, -324, 3653 },
- { 10, 192, 1620, 5291 },
- { 2152, 738, -2269, 5000 },
- { 2102, 2748, -1652, 4707 },
- { 2855, -2131, -387, 5188 },
- { 1173, 676, 1338, 3277 },
- { 2340, -2329, -2064, 4095 },
- { 861, -2024, 1296, 5055 },
- { 2189, 3225, -695, 2626 },
- { 6196, -7079, 1943, -822 },
- { 4547, -4813, 3261, 1856 },
- { 4243, -6904, 3443, 448 },
- { 4581, -7503, 946, 506 },
- { 6626, -7754, 3427, 470 },
- { 3407, -9088, 3269, -1496 },
- { 4079, -6464, 2304, 777 },
- { 5621, -9336, 2684, -768 },
- { 5351, -6464, 5238, -214 },
- { 5961, -8007, 1724, -3091 },
- { 4213, -8067, 603, -246 },
- { 7208, -7403, 3168, -1738 },
- { 6098, -7700, 329, -1379 },
- { 6525, -6735, 4248, -1072 },
- { 6073, -6241, 2167, -2378 },
- { 4609, -9218, 3051, -1033 },
- { 6813, -7283, 1581, -1897 },
- { 6126, -6275, 2789, 681 },
- { 4423, -6538, 1621, -1692 },
- { 6272, -8298, 3167, -1855 },
- { 6172, -8558, 4498, -1169 },
- { 4844, -8588, 1647, -366 },
- { 6209, -8807, 1581, -369 },
- { 5389, -8059, 550, -192 },
- { 6654, -9775, 2504, -1063 },
- { 7103, -7998, 806, 530 },
- { 5662, -6736, 1565, -3620 },
- { 4165, -9564, 4191, -2131 },
- { 4526, -7181, 576, -2875 },
- { 4633, -8623, 2807, -4742 },
- { 3709, -7794, 1815, 34 },
- { 3634, -8622, 2313, -826 },
- { 6991, -8447, 2063, -3198 },
- { 7757, -9486, 2255, -558 },
- { 4149, -7778, 4728, -1696 },
- { 5767, -7427, 1113, 707 },
- { 4592, -6261, 2329, 1864 },
- { 3159, -10498, 1677, -4273 },
- { 3534, -9010, 2437, -3565 },
- { 4479, -10821, 2715, -4942 },
- { 3207, -9805, 3054, -3886 },
- { 4627, -8189, 3018, -2354 },
- { 5527, -10566, 3244, -2749 },
- { 4346, -10127, 3335, -3084 },
- { 6132, -10085, 3316, -1308 },
- { 5629, -9704, 2178, -3058 },
- { 3603, -8538, 1246, -624 },
- { 3737, -8488, 395, -3167 },
- { 5465, -11414, 2810, -4640 },
- { 5306, -7745, 2721, -3988 },
- { 7000, -9111, 1695, -1409 },
- { 6663, -7741, 2466, -4079 },
- { 4083, -7175, 1836, -4831 },
- { 3613, -9926, 1342, -3455 },
- { 6588, -8033, 457, -258 },
- { 4720, -8102, 17, -1209 },
- { 7414, -8709, 1294, -344 },
- { 5437, -10030, 4043, -1704 },
- { 4862, -9281, 1558, -1431 },
- { 6800, -6403, 5113, 862 },
- { 4623, -8242, 2667, -228 },
- { 5919, -5083, 3348, 2135 },
- { 5985, -8889, 2733, -5105 },
- { 5029, -5767, 4407, 719 },
- { 354, -6158, -838, -3001 },
- { 351, -5943, -2104, -1534 },
- { -633, -7190, -25, -4798 },
- { -1595, -7235, -3812, -1400 },
- { 103, -6197, -2933, -78 },
- { -1722, -5020, -3441, -4333 },
- { -1963, -5644, -4365, -270 },
- { -846, -5743, -3477, 196 },
- { -191, -5348, -4054, -469 },
- { -2515, -7754, -3495, -818 },
- { -2090, -6710, -2701, 117 },
- { -546, -7036, -1398, 163 },
- { -278, -7091, -2662, -536 },
- { -622, -7962, -2731, -1464 },
- { -1555, -8118, -3612, -2057 },
- { -1094, -6280, -2314, 505 },
- { -2556, -8538, -4024, -2247 },
- { 109, -7134, -3107, -1823 },
- { -900, -6954, -3340, -717 },
- { -605, -7113, -3656, -2154 },
- { 837, -6263, -3211, -2177 },
- { -417, -5810, -3871, -1469 },
- { -1318, -5649, -4207, -3198 },
- { 413, -6765, -2082, -33 },
- { -3101, -6450, -4362, -766 },
- { 755, -6489, -2967, -846 },
- { 1117, -7106, -2452, -1352 },
- { -1202, -8387, -3072, -2897 },
- { -365, -4894, -3561, -2937 },
- { -2372, -8776, -265, -4441 },
- { -1224, -8678, -896, -5074 },
- { -755, -10096, -600, -6623 },
- { 300, -8206, -225, -4568 },
- { -1176, -6824, -2633, -3527 },
- { -2006, -5443, -1526, -5849 },
- { -1115, -5540, -2363, -4785 },
- { 1059, -6812, -2543, -2654 },
- { -1976, -6861, -3062, -5508 },
- { -379, -5328, -2321, -3624 },
- { -2108, -5860, -4518, -1915 },
- { -379, -7885, -1329, -594 },
- { 774, -5389, -581, -5213 },
- { -2601, -5083, -1849, -4921 },
- { -176, -5580, 74, -5075 },
- { -204, -6780, -190, -6232 },
- { 418, -7594, -1987, -820 },
- { -1873, -8529, -2926, -1609 },
- { 1340, -6362, -919, -4975 },
- { 577, -7990, -2044, -1873 },
- { -2572, -7413, -1745, -2224 },
- { -2037, -7030, -1461, -7138 },
- { -2559, -8756, -2039, -5836 },
- { -2079, -6764, -1209, -5669 },
- { -1613, -7801, -2006, -685 },
- { -1865, -6583, -722, -3529 },
- { -589, -6358, -1377, -1003 },
- { -540, -7514, -1331, -3542 },
- { 419, -6192, -1677, -4927 },
- { -2786, -8763, -2966, -5065 },
- { -2172, -8411, -1726, -4675 },
- { -3382, -9833, -3497, -5722 },
- { -2433, -10169, -2077, -5775 },
- { -424, -9451, -1096, -3658 },
- { -537, -8522, -910, -1897 },
- { -5550, 2807, 1683, -693 },
- { -6395, 635, 3573, -1246 },
- { -7544, 2280, 2140, 44 },
- { -8751, 1136, 2951, -794 },
- { -5605, 2709, 2052, 916 },
- { -7650, 654, 869, 135 },
- { -6939, 967, 1409, 870 },
- { -7834, 2123, 3310, 974 },
- { -6935, 2818, 1274, -1678 },
- { -5605, 2233, 1013, 471 },
- { -7095, 1849, 1648, 198 },
- { -6636, 1634, 712, -37 },
- { -7279, 978, 296, -315 },
- { -7664, 3504, 3292, -216 },
- { -7836, 1209, 1221, -257 },
- { -7913, 2201, 1765, -1529 },
- { -7077, 3783, 2632, -1407 },
- { -5565, 1645, 1410, -622 },
- { -6494, 2879, 1181, -759 },
- { -7073, 3137, 3010, 550 },
- { -7249, 1839, 847, -805 },
- { -6630, 2197, 282, -1096 },
- { -8836, 1573, 1988, -1090 },
- { -7809, 1274, 836, -1198 },
- { -7895, 2970, 3511, -1097 },
- { -6960, 1664, 1356, -2442 },
- { -6582, 2866, 2273, 307 },
- { -7221, 821, 2851, -1435 },
- { -6015, 1703, 2001, -2367 },
- { -8082, 1034, 2103, 239 },
- { -5952, 1912, 301, -465 },
- { -6099, 841, 379, 567 },
- { -6343, 50, 494, 658 },
- { -6586, 983, 591, -893 },
- { -5500, 869, 2187, -2479 },
- { -6482, 60, 1545, -979 },
- { -6705, 515, 1974, -53 },
- { -6460, 1755, 1325, -1275 },
- { -6093, 2617, 2465, -623 },
- { -7330, 2161, 594, -2115 },
- { -7324, 762, 1593, -2004 },
- { -6385, 679, 1510, -2514 },
- { -6159, 241, 2976, -1631 },
- { -8583, 3030, 4045, -162 },
- { -6299, 66, 2209, -2103 },
- { -5428, 1279, 3267, -1846 },
- { -6438, 1335, 2728, -1631 },
- { -8012, 1070, 2428, -1151 },
- { -6201, 2781, 2349, -1918 },
- { -5918, 1139, 3121, -148 },
- { -6314, 2481, 3137, -1808 },
- { -7180, 1722, 2435, -1602 },
- { -6750, 1829, 3763, -1145 },
- { -6713, 1777, 2221, 1212 },
- { -7479, 1835, 3627, -479 },
- { -7299, 10, 2406, -1593 },
- { -8249, 3129, 996, -2870 },
- { -8374, 1534, 1333, -1882 },
- { -7507, 3353, 1598, -2299 },
- { -7379, 2701, 2326, -1167 },
- { -8440, 2276, 2796, -542 },
- { -10348, 1527, 2649, -1165 },
- { -8184, 3614, 2574, -1738 },
- { -5539, 1574, 1733, 1138 },
- { 9404, -7652, 67, 79 },
- { 8654, -3972, 1358, -60 },
- { 8617, -4794, 117, 2318 },
- { 7886, -4505, 1784, 1200 },
- { 8636, -6125, 3879, -1003 },
- { 9654, -6836, 1816, 205 },
- { 9374, -6553, 913, 1875 },
- { 8020, -6150, 1134, 2390 },
- { 7786, -4970, 2078, -1857 },
- { 8691, -6119, 711, 708 },
- { 9039, -5568, 2944, -1902 },
- { 9955, -5048, 1433, -601 },
- { 8089, -6927, 3093, -2846 },
- { 8487, -7024, 2415, 19 },
- { 9388, -5287, 3577, -2655 },
- { 8591, -7371, 2300, -996 },
- { 9104, -4763, 1453, -2558 },
- { 7615, -5457, 596, 164 },
- { 9860, -7047, 3433, -614 },
- { 8756, -4404, 2235, -964 },
- { 9462, -4660, 299, -1822 },
- { 10119, -5550, 2689, -1273 },
- { 10915, -7471, 2705, -1007 },
- { 11433, -7090, 1410, -1198 },
- { 9882, -7431, 2965, -1895 },
- { 7628, -5219, 769, -2661 },
- { 8169, -5318, 2262, 70 },
- { 8846, -6320, 1939, -754 },
- { 7147, -5593, 1248, -971 },
- { 10652, -5485, 935, 137 },
- { 7778, -6533, 2564, -1932 },
- { 8878, -5173, 1214, -361 },
- { 9828, -4943, 282, 510 },
- { 10042, -6134, 3895, -1914 },
- { 7965, -6630, 3566, -433 },
- { 8573, -4502, 3574, -1209 },
- { 8398, -4801, 1031, -1347 },
- { 10136, -7772, 2612, 1547 },
- { 9890, -7280, 1768, -1083 },
- { 8407, -6585, -706, -58 },
- { 7976, -7582, 229, -131 },
- { 10481, -8866, 1166, -147 },
- { 10914, -4342, 3189, -2412 },
- { 10440, -5198, -104, -1109 },
- { 11227, -6530, 2381, -2449 },
- { 8487, -8064, 1086, 230 },
- { 9975, -6123, -857, -134 },
- { 8339, -6498, 1232, -2337 },
- { 11042, -4506, 1119, -2098 },
- { 12563, -5592, 1837, -2062 },
- { 11801, -5590, 632, -1296 },
- { 10152, -5617, 1511, -1917 },
- { 7800, -6473, 51, -1337 },
- { 7941, -5560, 2438, -3270 },
- { 6554, -3834, 2100, 1476 },
- { 9065, -5520, -226, -1120 },
- { 10794, -7120, -243, 122 },
- { 10429, -6968, 272, -806 },
- { 8942, -8914, 1442, -392 },
- { 9969, -5051, 2033, -2953 },
- { 7275, -4152, 3058, -64 },
- { 11127, -5488, 4589, -3227 },
- { 9626, -6666, 2739, -2958 },
- { 6943, -5362, 4470, 1008 },
- { -7456, -967, 2936, -1002 },
- { -8622, -333, 6962, 2606 },
- { -7486, -3392, 3668, 1287 },
- { -8053, -827, 5148, 1097 },
- { -6610, 454, 4952, 96 },
- { -7701, -1982, 3161, -468 },
- { -7307, -1132, 4071, -36 },
- { -8125, -271, 5199, 3862 },
- { -9182, -1950, 2813, 1878 },
- { -9855, -952, 4794, 3010 },
- { -7241, 1431, 4202, 2468 },
- { -9646, 157, 4766, 1046 },
- { -9371, 1230, 6009, 2958 },
- { -11514, -64, 8630, 5248 },
- { -6766, 565, 2766, 2140 },
- { -8426, -9, 2852, 1271 },
- { -11291, -1113, 5087, 2937 },
- { -8297, 2092, 4495, 1264 },
- { -9983, 735, 3809, -51 },
- { -9048, -1000, 3191, -308 },
- { -7331, -1987, 2655, 1391 },
- { -7144, -21, 4333, 2161 },
- { -6032, -1540, 3543, 896 },
- { -7987, -1036, 1985, 1529 },
- { -9264, 2004, 5194, 290 },
- { -11308, -840, 5754, 1654 },
- { -9130, -2398, 4292, 2973 },
- { -6248, 838, 3563, 1223 },
- { -6819, -2760, 3511, 119 },
- { -7213, -2006, 4364, 762 },
- { -5431, -1047, 4533, 166 },
- { -7098, -641, 2021, 639 },
- { -8628, -2249, 3588, 399 },
- { -6352, -1498, 3560, -648 },
- { -7033, -2190, 4870, 2562 },
- { -7405, -46, 3772, -581 },
- { -6104, 796, 5143, 1965 },
- { -5787, 943, 5784, 3030 },
- { -8367, 1465, 7192, 4097 },
- { -8259, 789, 5694, 1963 },
- { -10614, -1899, 5748, 2645 },
- { -8258, -805, 3698, 2275 },
- { -6877, -972, 6431, 3160 },
- { -6483, 363, 7018, 3129 },
- { -6283, -1358, 5191, 1524 },
- { -8853, -3157, 4119, 1741 },
- { -6086, -267, 3883, -835 },
- { -7254, 1032, 6613, 4017 },
- { -11470, -3350, 4649, 3426 },
- { -6743, 481, 6148, 1239 },
- { -5394, -166, 5309, 3165 },
- { -7958, 1068, 4268, -240 },
- { -10520, 2256, 7916, 2828 },
- { -5132, -4, 5739, 1176 },
- { -8643, 120, 3255, -629 },
- { -9631, 1974, 8870, 4362 },
- { -10663, -1221, 3733, 589 },
- { -8224, -1843, 5806, 2655 },
- { -8282, 1255, 8647, 3478 },
- { -12311, -1505, 9043, 6256 },
- { -11312, -856, 7136, 4681 },
- { -11944, -722, 7941, 3309 },
- { -7868, -463, 6846, 4196 },
- { -8679, -241, 7410, 5347 },
- { 6759, -4680, -508, 1220 },
- { 5176, -6111, 944, 121 },
- { 6843, -5667, -1368, -533 },
- { 5616, -5884, -1471, -695 },
- { 6030, -5089, -1808, -940 },
- { 7444, -5463, -52, 1881 },
- { 4207, -6079, -506, 1571 },
- { 6785, -4410, -649, 3084 },
- { 4838, -5214, 2026, 2998 },
- { 4201, -5790, 645, 1811 },
- { 6930, -5129, -1940, 1698 },
- { 6332, -4627, 692, 3027 },
- { 6285, -4314, -106, 3644 },
- { 6255, -5450, -1975, 742 },
- { 4199, -4676, -459, 1796 },
- { 5592, -5500, 1345, 1300 },
- { 4358, -5556, -2236, 114 },
- { 4620, -5875, -1563, 888 },
- { 4892, -7550, -327, -419 },
- { 4734, -7085, 7, 613 },
- { 3883, -5562, -1969, 1080 },
- { 5610, -4990, -204, 834 },
- { 4117, -6482, -1271, 341 },
- { 6585, -5107, 892, 1169 },
- { 6632, -3683, 302, 3002 },
- { 6326, -5351, -983, -1250 },
- { 4382, -7192, -730, -158 },
- { 5227, -6540, -451, 1123 },
- { 5468, -6472, -870, -1471 },
- { 5191, -6402, -1365, -127 },
- { 7407, -6317, -973, -336 },
- { 4611, -6530, -820, -1980 },
- { 4963, -5159, -2050, -966 },
- { 4414, -5691, -211, -998 },
- { 5954, -5873, 750, -1749 },
- { 4394, -4796, -1268, 254 },
- { 7161, -6214, -1010, 689 },
- { 4965, -3598, 2372, 1711 },
- { 6248, -6180, 981, 864 },
- { 6473, -5336, 525, -600 },
- { 4591, -6864, -1131, -900 },
- { 6314, -6440, -1021, -375 },
- { 5838, -6209, -1199, 944 },
- { 5308, -5283, -2100, 1267 },
- { 4342, -5860, -1637, -1356 },
- { 5680, -4388, -1227, -104 },
- { 4900, -4098, 1449, 4046 },
- { 4677, -4284, -106, 3190 },
- { 7574, -6173, -848, 1859 },
- { 6493, -7207, -131, 726 },
- { 5513, -5261, -2117, 4 },
- { 6191, -7352, -193, -505 },
- { 5885, -4333, 324, -134 },
- { 6162, -6081, -312, -2044 },
- { 4216, -6200, -1810, -572 },
- { 5652, -7035, -696, -197 },
- { 7131, -7189, -366, -60 },
- { 5032, -4803, -1514, 2832 },
- { 7386, -4610, -606, 3489 },
- { 4211, -5031, 1221, 3047 },
- { 4050, -4653, 1584, 1469 },
- { 6852, -5302, -1861, 206 },
- { 7736, -4816, -1794, 3359 },
- { 6290, -3439, 1522, 2454 },
- { 1768, 5990, -5560, -2594 },
- { 3903, 5326, -1530, -1501 },
- { 2472, 3738, -2117, -4240 },
- { 3260, 5448, -904, -4733 },
- { 1435, 7297, -3676, -4102 },
- { 4096, 5951, -656, -3312 },
- { 2178, 6009, -3146, -3724 },
- { 3787, 5493, -5473, -1633 },
- { 2998, 7286, -3334, -3571 },
- { 2894, 6576, -4708, -2804 },
- { 830, 6163, -4286, -3348 },
- { 4755, 5569, -1730, -2739 },
- { 4604, 6065, -3562, -2605 },
- { 2749, 5141, -3986, -2775 },
- { 3942, 4875, -2143, -3340 },
- { 2819, 8517, -2004, -2724 },
- { 2146, 6298, -689, -3093 },
- { 5196, 6504, -3393, -1475 },
- { 1851, 8386, -1748, -1420 },
- { 3474, 8572, -3534, -2688 },
- { 4503, 7560, -3561, -2245 },
- { 4433, 6219, -2393, -1575 },
- { 3506, 7248, -2275, -1977 },
- { 3490, 7409, -3147, -604 },
- { 4214, 6447, -3520, 516 },
- { 619, 7034, -829, -1705 },
- { 1732, 7395, -356, -2208 },
- { 1226, 5204, -3294, -3732 },
- { 2027, 5619, -1813, -4146 },
- { 3078, 5877, 47, -2651 },
- { 1654, 5458, 424, -682 },
- { 3163, 5464, -2026, -270 },
- { 2884, 5375, -685, -530 },
- { 2950, 7286, -35, -2967 },
- { 1986, 5066, -597, 482 },
- { 3459, 4308, -3845, -2333 },
- { 3155, 7037, -1346, -4345 },
- { 2193, 6696, -717, -1319 },
- { 3677, 5089, -3892, -487 },
- { 2186, 5136, -4186, -1492 },
- { 773, 5796, -917, 817 },
- { 2489, 6546, -3570, -2117 },
- { 1223, 6469, -1362, -33 },
- { 271, 6061, -1466, -1725 },
- { 2540, 5171, -1847, 1032 },
- { 2548, 5251, -2697, 1677 },
- { 771, 7600, -768, -632 },
- { 4710, 6647, -4736, -1275 },
- { 1369, 5917, -2971, -1056 },
- { 163, 5239, -3499, -2275 },
- { 2104, 4285, -3211, -3286 },
- { 1107, 7411, -1972, -1671 },
- { 2196, 7262, -2310, -1926 },
- { -244, 6439, -1745, -839 },
- { 3293, 3832, -2890, -3000 },
- { 419, 6443, -379, -407 },
- { 3077, 4930, -1156, -2869 },
- { 2131, 5874, -2330, 224 },
- { 690, 6538, -2212, -2841 },
- { 1602, 4421, -2515, 1542 },
- { 3318, 9373, -3032, -3477 },
- { 5646, 7462, -5153, -1463 },
- { 4139, 7137, -1539, -3321 },
- { 3481, 9077, -1645, -3653 },
- { -7747, 375, -106, -543 },
- { -8587, -1379, -586, -461 },
- { -10146, -892, 2094, 694 },
- { -8103, 382, 504, -325 },
- { -8548, -92, 94, -656 },
- { -7460, 38, 152, 388 },
- { -8266, -271, -459, -883 },
- { -7935, -664, -1026, -802 },
- { -8341, -109, 853, 161 },
- { -8802, -1355, 1099, 630 },
- { -8957, -6, 1108, -669 },
- { -7260, -1520, -43, -407 },
- { -7555, -174, 668, -2562 },
- { -9014, -126, 227, -1191 },
- { -8184, 769, 290, -1375 },
- { -9476, 55, 962, -1528 },
- { -8679, 541, 755, -1030 },
- { -9842, -1626, 838, -1588 },
- { -8513, -702, 788, -1998 },
- { -10101, -1558, -366, -1841 },
- { -8135, 78, 1479, -1813 },
- { -9128, -454, 313, -1786 },
- { -7554, -1084, 831, -2442 },
- { -7576, -701, 2068, -1665 },
- { -7791, -1481, 1587, -1808 },
- { -6701, -596, -97, 802 },
- { -7418, -15, 684, -963 },
- { -7127, -477, -139, -426 },
- { -8097, -110, -36, -264 },
- { -7620, -1922, -590, -101 },
- { -7647, -1201, 279, 660 },
- { -7856, -1974, 758, -2271 },
- { -8496, -167, 2232, -1143 },
- { -8506, -1359, 624, -740 },
- { -7274, -1052, 1062, -139 },
- { -7800, -217, 91, -1794 },
- { -7030, -1694, -955, 615 },
- { -9020, -1864, 101, -2182 },
- { -9400, -740, 598, -667 },
- { -8448, -1184, 2024, -1272 },
- { -8812, -570, -897, -2384 },
- { -10559, -1286, 538, -1536 },
- { -8728, -888, -1089, -1397 },
- { -7080, -1185, 636, -1252 },
- { -9880, 233, 2344, -782 },
- { -7952, -1326, -378, -1947 },
- { -7207, -378, 1408, -2237 },
- { -8467, -1545, 902, -1987 },
- { -9163, -1474, 924, -1739 },
- { -8159, -992, -77, -2744 },
- { -8343, 148, -423, -1573 },
- { -9105, -649, -254, -1214 },
- { -8939, 456, 281, -1905 },
- { -8837, 179, -394, -2634 },
- { -9145, 757, 1547, -1319 },
- { -9775, -723, 441, -1680 },
- { -8910, -686, 1529, -1525 },
- { -9492, -1134, 2064, -938 },
- { -6111, -943, 677, -31 },
- { -7411, -613, -814, 46 },
- { -9479, -922, -430, -2061 },
- { -11298, -1268, 1318, -1117 },
- { -8190, 832, 671, -2214 },
- { -10453, -550, 1672, -886 },
- { 1044, 9353, -1651, -5423 },
- { 1034, 8149, -455, -6166 },
- { 761, 8293, -3214, -4838 },
- { 938, 8077, 164, -5130 },
- { 1295, 8673, 2582, -5490 },
- { -314, 7973, -2395, -5231 },
- { -507, 9012, -2497, -5775 },
- { 2396, 8314, -1022, -4673 },
- { -1516, 8501, 1950, -4969 },
- { -308, 7401, 1549, -4866 },
- { -112, 8340, 3003, -4920 },
- { -50, 9315, 1371, -5666 },
- { -659, 9449, 2496, -5547 },
- { 2573, 9148, -2270, -4783 },
- { 830, 7104, -438, -3907 },
- { 522, 10672, -677, -6483 },
- { -1190, 10108, -510, -6518 },
- { -427, 8271, -579, -6315 },
- { 1602, 8113, -1927, -4418 },
- { -2266, 8180, 448, -5190 },
- { -1633, 8816, -226, -5771 },
- { 759, 9481, -105, -5813 },
- { 2254, 6679, -466, -5662 },
- { -88, 6946, 895, -5958 },
- { -1705, 10009, 1394, -5574 },
- { 748, 7943, 540, -6692 },
- { 1411, 7009, 232, -6145 },
- { 697, 7290, -1221, -5342 },
- { -1764, 10580, 1944, -3981 },
- { -1334, 9124, 1195, -3903 },
- { -905, 10067, 635, -5039 },
- { 664, 10680, 49, -4625 },
- { 1374, 9536, -777, -3591 },
- { 252, 9698, -597, -2931 },
- { 824, 9164, -1014, -2144 },
- { 2438, 10569, -2289, -4424 },
- { 2101, 7102, 507, -3614 },
- { 294, 8051, -432, -1518 },
- { -665, 10337, 547, -2852 },
- { 1168, 11989, -492, -5427 },
- { 1344, 6416, 302, -5061 },
- { -1727, 12264, 1507, -4543 },
- { 674, 10889, -902, -3605 },
- { -582, 9504, 300, -3618 },
- { 641, 7654, 689, -2109 },
- { 2065, 9243, 508, -4367 },
- { 1055, 8373, 688, -3144 },
- { -641, 8185, 986, -3307 },
- { 1120, 7426, 1785, -3757 },
- { 1660, 8070, -593, -3104 },
- { 2002, 9467, -1722, -3475 },
- { 2361, 8368, 100, -3709 },
- { -772, 7845, -613, -4988 },
- { 1485, 7430, 1896, -6127 },
- { -432, 7823, -947, -2882 },
- { 313, 11122, -760, -4871 },
- { 412, 8412, -283, -4231 },
- { 1585, 10402, -1884, -3267 },
- { 321, 6952, 773, -3016 },
- { -105, 9014, 121, -2249 },
- { 1585, 10313, -977, -4812 },
- { 1619, 11869, 1306, -6876 },
- { -1168, 8886, -81, -2500 },
- { -395, 10886, 733, -6490 },
- { -4949, 4274, 3992, -1054 },
- { -4241, 5299, 4262, -1584 },
- { -2710, 3862, 4552, -1673 },
- { -4608, 2472, 3672, -1715 },
- { -2843, 2816, 4003, -2326 },
- { -5229, 2964, 5636, 90 },
- { -4924, 3442, 5015, -1096 },
- { -1281, 3313, 5537, -2066 },
- { -3808, 1939, 4351, -919 },
- { -1915, 2585, 4939, -1614 },
- { -3470, 1843, 5562, -682 },
- { -3800, 870, 5827, 144 },
- { -4985, 1452, 4728, -709 },
- { -3745, 2750, 7220, 259 },
- { -1875, 1900, 6514, -826 },
- { -4329, 1574, 7192, 1304 },
- { -5408, 1444, 6208, 631 },
- { -3327, 5312, 5707, -1541 },
- { -6966, 3334, 4034, 1028 },
- { -7484, 4245, 4218, -212 },
- { -6567, 5839, 4539, -512 },
- { -5715, 5935, 3747, -1186 },
- { -6410, 4881, 3356, -1610 },
- { -5146, 2590, 2850, 2172 },
- { -5196, 4095, 2569, -373 },
- { -5043, 6025, 4318, 692 },
- { -5525, 4884, 3513, 370 },
- { -6804, 7533, 5812, -488 },
- { -5657, 2480, 4061, 1234 },
- { -3155, 1472, 6071, 1188 },
- { -3427, 5217, 3442, 858 },
- { -4698, 3013, 5517, 2586 },
- { -4449, 2226, 5418, 3580 },
- { -6395, 3547, 5487, 2028 },
- { -3500, 5019, 4787, 1 },
- { -4038, 2578, 3073, 3151 },
- { -2750, 1955, 4469, 3856 },
- { -5696, 1659, 6118, 2469 },
- { -4350, 1241, 6840, 3126 },
- { -5565, 5058, 5196, 1314 },
- { -1642, 4190, 3948, 607 },
- { -1233, 4108, 4850, -640 },
- { -997, 3428, 3239, 1378 },
- { -6488, 2741, 6926, 2792 },
- { -4188, 3763, 4235, 2018 },
- { -3210, 3224, 5646, 1427 },
- { -5526, 6909, 5070, -627 },
- { -2815, 3994, 3425, 1903 },
- { -2163, 2734, 5423, 145 },
- { -4149, 4247, 2355, 734 },
- { -410, 2521, 4138, -16 },
- { -2411, 2385, 4927, 2105 },
- { -6077, 3591, 3114, 594 },
- { -4186, 4834, 5926, -1004 },
- { -7315, 3369, 5966, 448 },
- { -7042, 5721, 5771, 238 },
- { -4466, 3907, 3535, -1751 },
- { -2116, 3970, 6163, -1392 },
- { -7239, 2143, 8407, 3630 },
- { -5431, 4486, 6486, -42 },
- { -1874, 1617, 6333, 519 },
- { -6478, 2629, 4634, -505 },
- { -7784, 2342, 7216, 1365 },
- { -1154, 1432, 4831, 1544 },
- { -4964, -5801, 1797, 506 },
- { -4436, -6905, 1059, -1237 },
- { -5400, -6886, 884, -290 },
- { -6259, -7103, 523, -227 },
- { -4819, -6450, 1412, -450 },
- { -4056, -6213, 1725, -943 },
- { -5642, -6091, 1357, 605 },
- { -4196, -5678, 2187, -173 },
- { -4726, -5126, 2470, 321 },
- { -6642, -5091, 1507, -1005 },
- { -5304, -5250, 1944, 1579 },
- { -7179, -5520, 1468, -425 },
- { -6033, -4895, 1876, -955 },
- { -6595, -5143, 2207, 1291 },
- { -4224, -4943, 1846, 1792 },
- { -7128, -6950, 539, 724 },
- { -4369, -4901, 2590, 1103 },
- { -7413, -5696, 1712, 1440 },
- { -5885, -6821, 418, 871 },
- { -6828, -5599, 710, -1563 },
- { -6123, -5817, 1358, 1631 },
- { -5291, -5622, 578, 2138 },
- { -7171, -6004, 347, 2208 },
- { -6083, -5251, 2132, 425 },
- { -4329, -5721, 407, -2993 },
- { -5326, -5056, 1119, -1837 },
- { -5485, -5856, 185, -2389 },
- { -6529, -5178, 403, -697 },
- { -6719, -4412, 2726, 871 },
- { -5126, -5629, 1835, -771 },
- { -5622, -4361, 2973, 858 },
- { -5282, -5895, 45, -335 },
- { -4357, -5656, 1696, -1558 },
- { -7139, -6659, 627, -409 },
- { -4415, -6328, 35, 1306 },
- { -7639, -6110, 1134, 197 },
- { -3626, -5592, 2019, 901 },
- { -3547, -5064, 1176, 1738 },
- { -5075, -3899, 2087, 266 },
- { -4086, -6311, 1479, 360 },
- { -6210, -5220, -199, -1477 },
- { -3910, -5063, 1356, -15 },
- { -7616, -4977, 461, 2401 },
- { -6118, -6131, 1258, -563 },
- { -6127, -4968, 1286, -27 },
- { -4121, -5852, 1113, 1476 },
- { -5157, -4881, 1162, -662 },
- { -4637, -5031, 1179, 709 },
- { -5509, -5452, -397, 1224 },
- { -4597, -6861, 646, 467 },
- { -6247, -4043, 468, 278 },
- { -5336, -6465, 874, -1472 },
- { -6998, -6346, 78, -1798 },
- { -4915, -4530, 2756, -203 },
- { -6048, -4373, 1468, 1052 },
- { -4273, -7100, 942, -323 },
- { -6552, -4287, 2351, 69 },
- { -6954, -4613, 722, 1521 },
- { -4201, -5361, 763, -1562 },
- { -6881, -5596, -748, 669 },
- { -6695, -3547, -34, 1299 },
- { -3981, -5728, 84, 111 },
- { -4663, -4809, 2173, -1031 },
- { -6599, -6077, 1303, 256 },
- { -7596, -4265, -5791, -4140 },
- { -6610, -2758, -5288, -3936 },
- { -5880, -3865, -6563, -3088 },
- { -7228, -5510, -7677, -3912 },
- { -8854, -6553, -8318, -5361 },
- { -9362, -5249, -6413, -4319 },
- { -4418, -3110, -6368, -4358 },
- { -5544, -4203, -6863, -5013 },
- { -3056, -4316, -5567, -3181 },
- { -3078, -5999, -5051, -2657 },
- { -5884, -6292, -5756, -4013 },
- { -4825, -4549, -5535, -4053 },
- { -4443, -6126, -5316, -1368 },
- { -3972, -6341, -6098, -2686 },
- { -5751, -2781, -5398, -6230 },
- { -4466, -6135, -5570, -3679 },
- { -4291, -5992, -3564, -5189 },
- { -7189, -4429, -7279, -6082 },
- { -5076, -4433, -2748, -5366 },
- { -6225, -2825, -6833, -5663 },
- { -2989, -4792, -3960, -4492 },
- { -7836, -7773, -7722, -5741 },
- { -6559, -5703, -5844, -5589 },
- { -7612, -5438, -4136, -3774 },
- { -4218, -4176, -6591, -2333 },
- { -4837, -5063, -6581, 322 },
- { -6590, -5990, -2980, -3847 },
- { -5558, -2971, -5489, -1932 },
- { -7001, -5323, -4975, -1697 },
- { -4694, -2688, -6904, -3044 },
- { -8511, -5379, -5767, -2549 },
- { -7548, -5412, -6522, -2572 },
- { -6597, -4973, -6423, -1274 },
- { -6415, -4022, -5168, -1072 },
- { -5528, -5530, -7218, -2345 },
- { -4845, -4805, -5943, -1227 },
- { -6049, -7150, -6744, -2161 },
- { -9061, -7299, -8542, -4375 },
- { -5010, -5546, -5416, -82 },
- { -4135, -4205, -5109, -3373 },
- { -3311, -5869, -4007, -5061 },
- { -5993, -6472, -3962, -4718 },
- { -2966, -5832, -2821, -6305 },
- { -4851, -5152, -2067, -3930 },
- { -3620, -4441, -3362, -5836 },
- { -4469, -5221, -4534, -5592 },
- { -4022, -6335, -4321, -6107 },
- { -4899, -4503, -3084, -3725 },
- { -4490, -8276, -4620, -6236 },
- { -6591, -4342, -7365, -4063 },
- { -6498, -5057, -5553, 485 },
- { -6060, -2714, -7093, -4144 },
- { -6199, -7774, -7094, -4057 },
- { -7536, -6424, -6415, -4265 },
- { -7439, -2454, -6348, -4827 },
- { -5333, -7565, -4417, -4639 },
- { -4353, -7103, -4197, -2689 },
- { -5229, -6549, -5129, -6804 },
- { -6129, -7701, -5236, -4836 },
- { -6797, -3983, -3884, -4406 },
- { -6624, -4467, -4745, -5052 },
- { -3324, -7596, -2720, -6553 },
- { -5473, -6284, -1704, -4511 },
- { -4131, -7263, -3180, -5196 },
- { -7116, -5565, -3469, 685 },
- { -6002, -6021, -3858, 576 },
- { -3144, -8203, -1291, -434 },
- { -6096, -7027, -4004, 1353 },
- { -3943, -7709, -2344, -36 },
- { -4510, -6767, -2642, 631 },
- { -3657, -11541, -2570, -3984 },
- { -5959, -8854, -1333, -867 },
- { -6699, -8866, -1606, -344 },
- { -3836, -7961, -2334, -2028 },
- { -3430, -8045, -3037, -672 },
- { -3868, -9184, -3635, -1819 },
- { -4258, -9060, -2621, -1008 },
- { -3595, -8693, -2022, -752 },
- { -4573, -8048, -3166, -2622 },
- { -4852, -7903, -1405, 256 },
- { -4591, -7057, -1560, 965 },
- { -6963, -7655, -980, 808 },
- { -5179, -6641, -3356, 1196 },
- { -7102, -6941, -2798, 2123 },
- { -6867, -5834, -3320, -770 },
- { -5977, -7369, -2500, -778 },
- { -6160, -6400, -934, -2543 },
- { -6741, -7608, -355, -1289 },
- { -6856, -6466, -1433, -1643 },
- { -4786, -6292, -4970, 376 },
- { -5407, -8866, -2255, -400 },
- { -3814, -6506, -1387, -3620 },
- { -4998, -6137, -1200, -4092 },
- { -5123, -9557, -2849, -1306 },
- { -4259, -6444, -4395, -338 },
- { -5221, -6810, -883, 1225 },
- { -6137, -6215, -2165, 554 },
- { -3895, -6557, -3176, -1829 },
- { -3886, -8188, -87, -954 },
- { -7243, -6707, -2216, -316 },
- { -5592, -7606, 85, -432 },
- { -3957, -7945, -504, -144 },
- { -4617, -7624, 218, -312 },
- { -4797, -8737, -844, -1051 },
- { -4478, -8516, -1401, -454 },
- { -4557, -7058, -302, -2332 },
- { -6623, -7736, -271, -50 },
- { -3157, -7532, -1111, -2207 },
- { -3590, -7300, -1271, 517 },
- { -4442, -7306, -507, 590 },
- { -6458, -7524, -2807, 666 },
- { -4991, -8466, -3363, -785 },
- { -7474, -7541, -1056, -1839 },
- { -7501, -8316, -938, -180 },
- { -5329, -7739, -579, -2341 },
- { -4549, -7063, -176, -3539 },
- { -5191, -8612, -1504, -4250 },
- { -3083, -7058, -2251, 32 },
- { -4003, -7043, -1093, -791 },
- { -5523, -8093, -678, -114 },
- { -3022, -10265, -2070, -3109 },
- { -3905, -6274, -182, -3652 },
- { -3269, -9217, -551, -2650 },
- { -3138, -9314, -1726, -1704 },
- { -4420, -10339, -1744, -3459 },
- { -4163, -8609, -2298, -4113 },
- { -5566, -6505, -1241, -463 },
- { -3130, -9746, -2352, -4884 },
- { -7825, -3439, 1451, -1468 },
- { -8451, -3318, 2360, -435 },
- { -8462, -4130, 1438, -1024 },
- { -9425, -4564, 1328, -689 },
- { -11014, -3202, 2278, 2080 },
- { -8269, -2761, -146, -440 },
- { -7497, -2618, -166, 413 },
- { -8250, -3060, 522, -2133 },
- { -8365, -5366, 1347, -451 },
- { -8589, -3979, 2943, 714 },
- { -8111, -2572, 1272, -1748 },
- { -7830, -5193, 605, -1484 },
- { -8119, -4736, 2141, 256 },
- { -7724, -4769, 1463, -812 },
- { -7363, -3911, 2540, 4 },
- { -7974, -3397, 2363, 1366 },
- { -7359, -4204, 1752, -958 },
- { -7622, -3505, 660, 916 },
- { -9934, -3665, 3165, 828 },
- { -8721, -4162, 62, 1718 },
- { -9433, -4768, 2722, 1234 },
- { -7960, -4496, 138, 1528 },
- { -8198, -3454, -443, 631 },
- { -7756, -2246, 655, 1137 },
- { -8841, -3145, 1113, 829 },
- { -7817, -3298, 1251, 230 },
- { -9413, -2733, 323, -1862 },
- { -9408, -4168, 1270, 1549 },
- { -9037, -3892, -942, 283 },
- { -8255, -3849, 1301, 1762 },
- { -9057, -3987, -41, -682 },
- { -9441, -4187, 2019, -111 },
- { -9740, -3178, 1602, -871 },
- { -8344, -2474, 1461, 1506 },
- { -9752, -2925, 1996, 1243 },
- { -9199, -3796, 180, 537 },
- { -9060, -2405, 1140, -1562 },
- { -9348, -2376, 309, -162 },
- { -10786, -3182, -5, -1500 },
- { -8142, -4540, -434, -826 },
- { -7528, -2341, 1104, -73 },
- { -9360, -2658, 3062, 56 },
- { -8267, -2335, 2000, -1193 },
- { -12169, -3154, 1287, -640 },
- { -11398, -2120, 946, -1163 },
- { -8940, -4559, 328, -1696 },
- { -11025, -4213, 2813, 840 },
- { -9224, -3581, 2224, 2039 },
- { -8943, -3337, 1248, -1298 },
- { -7900, -4042, 485, -2080 },
- { -9221, -1947, 2191, -880 },
- { -10762, -1800, 2516, -324 },
- { -10095, -2238, 981, -1335 },
- { -11908, -2808, 3255, 645 },
- { -10640, -4105, 1283, -595 },
- { -7663, -2863, 2467, -797 },
- { -10712, -3854, 3710, 1538 },
- { -10823, -2893, 1408, -801 },
- { -9874, -3832, 256, -1638 },
- { -10394, -3391, 2315, -94 },
- { -11525, -4079, 4153, 2122 },
- { -9546, -2088, 1541, 481 },
- { -8731, -2433, 1042, 2160 },
- { -7852, -3977, -1370, 1677 },
- { 7072, -3420, 1398, -1741 },
- { 6180, -1976, 1280, -3557 },
- { 7692, -1793, 2844, -1700 },
- { 8363, -1773, 3104, -2679 },
- { 9213, -3266, 3756, -3542 },
- { 9650, -2644, 1426, -1318 },
- { 7712, -2796, 3686, -1975 },
- { 7316, -3517, 2821, -622 },
- { 7434, -2594, 2305, -2264 },
- { 7237, -1797, 255, -3114 },
- { 8663, -1983, 1338, -3056 },
- { 6616, -952, 4059, -2652 },
- { 8823, -1327, 1362, -1356 },
- { 9938, -1722, 1287, -2362 },
- { 7207, -1057, 1913, -1315 },
- { 7508, -1585, 870, -1982 },
- { 8217, -3680, 1417, -3170 },
- { 8329, -2541, 1684, -585 },
- { 8062, -2335, 252, -2800 },
- { 8204, -4108, 3097, -2569 },
- { 7701, -3367, 576, -3008 },
- { 7350, -786, 2414, -2129 },
- { 6948, -2568, 1607, -225 },
- { 7684, -2387, 1308, -3449 },
- { 8306, -3458, 2394, -1454 },
- { 8438, -2781, 1043, -1362 },
- { 9175, -2076, 2144, -1987 },
- { 8347, -2709, 3489, -4301 },
- { 5696, -2377, 2870, 851 },
- { 8825, -1243, 2219, -2603 },
- { 8801, -1614, 584, -2513 },
- { 8413, -384, 1421, -2244 },
- { 9228, -3050, 3279, -2164 },
- { 6342, -2698, 3547, -107 },
- { 10053, -2476, 2837, -3168 },
- { 7439, -604, 3177, -3991 },
- { 7749, -1064, 4329, -4855 },
- { 8655, -2177, 2252, -3519 },
- { 8490, -228, 1958, -3233 },
- { 10513, -2968, 1911, -2340 },
- { 8146, -862, 1884, -1723 },
- { 7788, -666, 3004, -2891 },
- { 7785, -1620, 4133, -3417 },
- { 10262, -3731, 3455, -2971 },
- { 8570, -905, 4519, -4649 },
- { 9129, -2562, 463, -2465 },
- { 9451, -3587, 1904, -3056 },
- { 6549, -2236, 3010, -4523 },
- { 7175, -2684, 2967, -3458 },
- { 9872, -3278, 1054, -2472 },
- { 9153, -931, 1217, -2565 },
- { 8789, -3469, 753, -2568 },
- { 6683, -3791, 1797, -3968 },
- { 6801, -1977, 2311, -452 },
- { 6336, -1572, 2612, -3264 },
- { 7996, -1008, 730, -2964 },
- { 7521, -1059, 1573, -3694 },
- { 8148, -3973, 2600, -3572 },
- { 7765, -1532, 2528, -3856 },
- { 7404, -3918, 4472, -143 },
- { 8894, -1398, 3299, -3685 },
- { 5768, -2041, 1487, -637 },
- { 5131, -2865, 2463, -811 },
- { 6439, -1568, 3500, -1550 },
- { -8878, -6798, -5319, -1452 },
- { -6332, -9713, -3112, -990 },
- { -8444, -6316, -3694, -687 },
- { -6123, -10840, -3637, -4358 },
- { -4784, -9580, -4577, -2581 },
- { -6108, -10515, -4859, -2524 },
- { -7605, -7518, -2327, -2797 },
- { -9662, -8775, -2467, -2010 },
- { -6494, -7523, -4715, -118 },
- { -8290, -8982, -1672, -317 },
- { -8798, -11051, -3888, -1426 },
- { -6273, -6623, -6791, -142 },
- { -8313, -7668, -2141, -1275 },
- { -6453, -8412, -3589, -4102 },
- { -6747, -7750, -5690, -2498 },
- { -7814, -6693, -3174, -2446 },
- { -10383, -10130, -3931, -2364 },
- { -10606, -8467, -5539, -2772 },
- { -9475, -6671, -3305, -2271 },
- { -8982, -9457, -5635, -4005 },
- { -10111, -7965, -6515, -4180 },
- { -7301, -6479, -5364, 720 },
- { -9543, -8999, -7921, -912 },
- { -9534, -8562, -3469, -384 },
- { -7601, -10344, -3205, -1127 },
- { -8088, -8620, -4954, -2888 },
- { -8202, -8406, -7038, -3775 },
- { -7312, -8324, -3334, -1775 },
- { -8566, -9262, -8071, -4174 },
- { -7068, -11300, -5573, -2907 },
- { -8295, -8952, -4366, -1544 },
- { -11104, -10210, -2285, -384 },
- { -5213, -7520, -5008, -1339 },
- { -5889, -7940, -5987, -1385 },
- { -10816, -8201, -4153, -1485 },
- { -10277, -8919, -6315, -1652 },
- { -5888, -10320, -3821, -1733 },
- { -10497, -7181, -6083, -3032 },
- { -7721, -9724, -6591, -5336 },
- { -5688, -7894, -3486, -2552 },
- { -10014, -10500, -3247, -820 },
- { -6301, -8765, -4506, -2923 },
- { -8261, -7847, -6213, -1552 },
- { -10212, -7481, -8113, -3954 },
- { -6938, -10874, -6074, -4703 },
- { -7183, -10968, -4446, -1773 },
- { -7120, -9193, -1966, -2509 },
- { -6234, -9263, -2313, -4284 },
- { -8503, -9857, -2429, -608 },
- { -9372, -7844, -8391, -2120 },
- { -7951, -7157, -6535, -11 },
- { -7256, -9473, -2172, -660 },
- { -10063, -9612, -2515, -15 },
- { -6684, -9134, -6109, -4206 },
- { -8204, -11932, -5220, -2306 },
- { -9710, -6706, -4115, -3275 },
- { -6855, -7078, -2409, -4447 },
- { -7344, -7673, -4479, -4116 },
- { -8851, -6842, -4927, -2948 },
- { -8927, -10452, -5633, -2194 },
- { -8627, -9002, -7176, -1575 },
- { -8209, -9722, -7021, -3324 },
- { -3770, -10249, -3623, -4816 },
- { -8183, -7465, -4090, 646 },
- { -8163, -7149, 200, 498 },
- { -8289, -6266, 686, -206 },
- { -10030, -6241, -1032, -1864 },
- { -8793, -8327, -773, -169 },
- { -9149, -6215, 969, -15 },
- { -8303, -5859, -7, 2006 },
- { -9682, -7283, 255, 1322 },
- { -9293, -7227, 71, -231 },
- { -8525, -6215, 287, -837 },
- { -10477, -5379, 1159, 1449 },
- { -10726, -7856, -130, 102 },
- { -8694, -7461, -1210, 690 },
- { -9367, -5324, 1103, 3170 },
- { -10686, -8055, -831, 1633 },
- { -9201, -6873, -2704, 2258 },
- { -8421, -5358, -1405, 226 },
- { -9066, -5830, -307, -1571 },
- { -11150, -7381, -2746, -900 },
- { -9978, -5925, -2006, -437 },
- { -9464, -4741, -273, 1061 },
- { -10543, -6684, -1113, 1660 },
- { -10073, -5576, 1083, -269 },
- { -8826, -5763, 1600, 1486 },
- { -10445, -9071, -1253, -64 },
- { -12085, -5799, 2, 769 },
- { -12939, -6663, 1650, 1437 },
- { -10932, -6434, -1252, -649 },
- { -11650, -7826, -2053, 710 },
- { -12122, -6733, -1889, -731 },
- { -9093, -6095, -2463, -842 },
- { -10977, -4364, 469, 420 },
- { -11488, -6908, -521, 893 },
- { -9669, -5478, -842, 337 },
- { -10606, -5203, -632, -1361 },
- { -10198, -6284, 1662, 1277 },
- { -10135, -5292, 2435, 3493 },
- { -11027, -6561, 655, 56 },
- { -10977, -5030, 1127, -358 },
- { -12766, -3986, 1348, -335 },
- { -14244, -7731, 264, 317 },
- { -15124, -10309, -508, 1447 },
- { -12821, -8638, -608, 137 },
- { -13076, -8693, -2852, -431 },
- { -11156, -5546, -2252, -1600 },
- { -8692, -7366, -819, -1223 },
- { -12507, -9816, -1714, -121 },
- { -10712, -6666, 544, 3349 },
- { -12462, -5890, -2491, -2318 },
- { -12468, -7226, 437, 232 },
- { -11300, -5226, 2068, 687 },
- { -11994, -8320, -626, 2728 },
- { -12222, -5476, 1142, 18 },
- { -10277, -8122, -2418, 2003 },
- { -13418, -6115, -3563, -2802 },
- { -14759, -9834, -1243, 21 },
- { -13699, -5665, 1525, 507 },
- { -16269, -9476, -701, 163 },
- { -12677, -5437, -247, -1019 },
- { -11827, -4295, -181, -1243 },
- { -12847, -4496, 2984, 1123 },
- { -13860, -7915, -1166, -547 },
- { -12276, -8145, -2290, -1527 },
- { -11417, -4830, 2983, 1854 },
- { -11793, -6002, 1163, 1940 },
- { 11443, -4920, -3235, 3151 },
- { 11300, -6616, -1506, 1175 },
- { 9198, -4628, -2060, 2390 },
- { 10532, -4027, -643, 912 },
- { 9902, -3573, -1606, 1327 },
- { 9653, -3536, -2240, 1869 },
- { 9948, -5171, -423, 2662 },
- { 12316, -4004, -1989, 281 },
- { 12125, -4800, -1265, -163 },
- { 10650, -2617, -2337, 1462 },
- { 9909, -4968, -2376, 916 },
- { 12944, -4647, -1958, 460 },
- { 12988, -5283, -1141, 41 },
- { 12321, -2915, -3621, 1025 },
- { 11449, -2894, -2728, 351 },
- { 12087, -3041, -2002, -32 },
- { 11558, -4031, -1343, -399 },
- { 12983, -3740, -3516, 1245 },
- { 12099, -2515, -2752, 225 },
- { 12515, -3465, -2701, 550 },
- { 14683, -5022, -5272, 2996 },
- { 12260, -3383, -1215, -528 },
- { 13810, -5422, -2443, 1166 },
- { 13421, -5378, -1886, 721 },
- { 12961, -4259, -2594, 796 },
- { 12266, -2104, -4768, 1591 },
- { 13523, -4710, -3045, 1342 },
- { 12437, -2099, -5610, 2117 },
- { 11850, -2183, -3497, 661 },
- { 12275, -3936, -597, -697 },
- { 12459, -5253, -517, -544 },
- { 12835, -4094, -1322, -168 },
- { 14360, -5677, -3305, 1859 },
- { 13905, -4552, -4309, 2117 },
- { 11559, -3412, -1847, -81 },
- { 13379, -3167, -5764, 2746 },
- { 11910, -1634, -4342, 1052 },
- { 12662, -4742, 71, -974 },
- { 13057, -3254, -4424, 1705 },
- { 15046, -5706, -4851, 3019 },
- { 14162, -4142, -5514, 2843 },
- { 12764, -1845, -6684, 2888 },
- { 13714, -2374, -7838, 3857 },
- { 13295, -1663, -8293, 4073 },
- { 10032, -4152, -3403, 1421 },
- { 10942, -5386, -2222, 950 },
- { 10532, -6385, -1750, 1925 },
- { 10273, -5972, -1534, 643 },
- { 10605, -4782, -1695, 27 },
- { 10988, -5153, -1123, -341 },
- { 11629, -5884, -1060, 48 },
- { 10441, -4045, -2431, 311 },
- { 10788, -3595, -4171, 1807 },
- { 12110, -5686, -2127, 976 },
- { 11746, -4773, -2639, 891 },
- { 11541, -5299, -3031, 1732 },
- { 11416, -2559, -5359, 2198 },
- { 11583, -5376, -704, 677 },
- { 10416, -3214, -3516, 872 },
- { 9651, -5435, -1618, 3255 },
- { 9973, -5133, -996, 3923 },
- { 11707, -4643, -430, -796 },
- { 10994, -2709, -3587, 2302 },
- { 10716, -5118, -645, 270 },
- { 14100, -10314, 1095, 1531 },
- { 12944, -8049, 1105, -741 },
- { 13276, -7035, -511, 274 },
- { 14008, -7254, -283, 139 },
- { 11594, -6536, -91, 1671 },
- { 11732, -8645, 746, 15 },
- { 14613, -7085, -1578, 1183 },
- { 13083, -6224, -750, -4 },
- { 13988, -6256, -1592, 820 },
- { 14678, -8683, 441, 126 },
- { 15571, -8872, -521, 1139 },
- { 15642, -9533, 341, 697 },
- { 15960, -9586, -168, 1121 },
- { 15464, -10239, 1433, -1 },
- { 14934, -7887, -1046, 1080 },
- { 15252, -7630, -1899, 1628 },
- { 15485, -8384, -1234, 1484 },
- { 15962, -8638, -1815, 1931 },
- { 16501, -10664, 398, 1167 },
- { 16146, -10145, 411, 918 },
- { 14573, -7475, -697, 601 },
- { 14302, -7996, 28, 257 },
- { 14769, -6792, -2286, 1574 },
- { 14144, -6137, -2169, 1257 },
- { 14770, -6271, -3111, 1933 },
- { 14110, -8312, 1083, -531 },
- { 15235, -6991, -2993, 2174 },
- { 13222, -5805, 547, -891 },
- { 14796, -8762, 1254, -246 },
- { 16040, -9181, -1005, 1551 },
- { 16487, -10086, -373, 1420 },
- { 15077, -9479, 966, 51 },
- { 13026, -6468, 932, -1080 },
- { 12703, -6152, -33, -573 },
- { 15641, -6810, -4128, 2874 },
- { 13282, -7673, 1583, -1283 },
- { 12373, -7150, 1512, -917 },
- { 12992, -7751, -678, 783 },
- { 10907, -6858, -313, 2597 },
- { 13026, -8963, 125, 2152 },
- { 12770, -9946, 1957, -505 },
- { 12482, -6849, -1268, 833 },
- { 13790, -6181, -138, -279 },
- { 12709, -8382, 2044, 227 },
- { 12244, -6630, 203, -457 },
- { 14209, -6816, -1032, 632 },
- { 15134, -8267, -288, 640 },
- { 13619, -6157, -1090, 356 },
- { 14044, -7413, 725, -484 },
- { 12958, -7753, 2585, -1980 },
- { 13188, -8396, 2306, -1558 },
- { 14379, -9980, 2132, -688 },
- { 14275, -9857, 1162, 179 },
- { 13690, -8648, 1621, -889 },
- { 11770, -6829, -746, 278 },
- { 12732, -8202, 286, 90 },
- { 13630, -10146, 1867, -207 },
- { 12072, -8740, 1299, -645 },
- { 12852, -9492, 1226, 62 },
- { 11792, -7382, -54, -116 },
- { 13779, -9014, 487, 351 },
- { 11951, -7729, 121, 834 },
- { 11970, -9781, 2276, -4 },
- { 12680, -7984, 2787, -787 },
- { 13300, -14488, 6408, -1927 },
- { 13635, -15355, 9153, -3073 },
- { 12804, -13566, 5517, -1625 },
- { 16624, -10854, 1690, 28 },
- { 20387, -18532, 6162, -261 },
- { 16515, -12642, 3392, -519 },
- { 15800, -11095, 2151, -202 },
- { 16824, -11790, 1651, 599 },
- { 17604, -13213, 2563, 538 },
- { 17892, -14177, 3562, 147 },
- { 16987, -11399, 869, 1052 },
- { 17003, -12456, 2442, 265 },
- { 21657, -21806, 9198, -1250 },
- { 16825, -13341, 3980, -686 },
- { 17525, -12714, 1887, 805 },
- { 16419, -11034, 1216, 617 },
- { 20931, -19939, 7469, -684 },
- { 18452, -15390, 4573, -191 },
- { 14778, -10077, 2841, -1209 },
- { 17402, -13319, 3042, 160 },
- { 19365, -17922, 7087, -1061 },
- { 16298, -11941, 2810, -351 },
- { 19087, -16176, 4775, -84 },
- { 17666, -12289, 938, 1224 },
- { 18581, -15894, 5132, -430 },
- { 19823, -16717, 4142, 545 },
- { 19960, -19423, 8400, -1492 },
- { 18973, -16817, 5906, -594 },
- { 19079, -15431, 3528, 503 },
- { 16667, -12485, 4467, -1302 },
- { 19791, -17797, 6196, -529 },
- { 20005, -17606, 5354, -20 },
- { 20123, -18599, 6886, -728 },
- { 19068, -14805, 2394, 1105 },
- { 14443, -13723, 5631, -2029 },
- { 14730, -14231, 5631, -1450 },
- { 16089, -15959, 7271, -2029 },
- { 13473, -11200, 3236, -924 },
- { 14413, -10902, 2347, -267 },
- { 17666, -18662, 11381, -3496 },
- { 14749, -11042, 3305, -275 },
- { 15304, -10486, 1869, -240 },
- { 14809, -12126, 3369, -616 },
- { 16896, -16561, 7307, -1845 },
- { 15782, -14336, 5380, -1264 },
- { 16395, -15520, 6415, -1588 },
- { 13681, -11114, 2584, -320 },
- { 14244, -12326, 4480, -1632 },
- { 15247, -13119, 4265, -898 },
- { 13987, -12091, 3469, -597 },
- { 13941, -12770, 4240, -839 },
- { 13771, -13627, 5252, -1384 },
- { 15010, -16074, 7592, -2249 },
- { 15852, -17226, 8619, -2655 },
- { 18921, -16916, 6875, -1501 },
- { 14909, -11678, 2768, -295 },
- { 18988, -18353, 8424, -2070 },
- { 15457, -15080, 6218, -1513 },
- { 14916, -15512, 6949, -1883 },
- { 18108, -14702, 4681, -701 },
- { 17600, -15733, 5616, -775 },
- { 14070, -13683, 6472, -2626 },
- { 13832, -11914, 5201, -2232 },
- { 18846, -19009, 9192, -1961 },
- { -11981, -10994, -6324, -2264 },
- { -10976, -9047, -6546, -3828 },
- { -11288, -10532, -7014, -4191 },
- { -10139, -10189, -7799, -2688 },
- { -10555, -9988, -9181, -2040 },
- { -11596, -11339, -10022, -2707 },
- { -13400, -13395, -11306, -4206 },
- { -9774, -12281, -7466, -4133 },
- { -10842, -13125, -8777, -4956 },
- { -11964, -15082, -9779, -5095 },
- { -9382, -10188, -9053, -4927 },
- { -11562, -11296, -3651, -985 },
- { -9287, -10083, -7918, -4069 },
- { -12821, -16556, -11410, -6195 },
- { -12628, -8959, -4521, -1113 },
- { -13845, -11581, -3649, -681 },
- { -12685, -10269, -5483, -1275 },
- { -14988, -12874, -5107, -1189 },
- { -13761, -11367, -6202, -1804 },
- { -13225, -11249, -7820, -3354 },
- { -14809, -11992, -3202, -312 },
- { -15620, -15519, -10210, -3433 },
- { -12954, -10200, -3139, -611 },
- { -11536, -9981, -5284, -923 },
- { -13034, -12417, -4612, -1098 },
- { -16911, -15505, -6123, -1352 },
- { -17396, -17685, -8330, -2171 },
- { -14120, -10764, -2265, -99 },
- { -12598, -7367, -5406, -3530 },
- { -14143, -12793, -10909, -5226 },
- { -14692, -16871, -11626, -5554 },
- { -12581, -11197, -9194, -3837 },
- { -16752, -16726, -9746, -2808 },
- { -10600, -10358, -6560, -1227 },
- { -14573, -13312, -8957, -3393 },
- { -10172, -8463, -8579, -3387 },
- { -11418, -12421, -5522, -1842 },
- { -11855, -14204, -6669, -2625 },
- { -13308, -8191, -3941, -2194 },
- { -10007, -12266, -5022, -1811 },
- { -13532, -15771, -9497, -3175 },
- { -11760, -11148, -10339, -5529 },
- { -12149, -12763, -11198, -3697 },
- { -12029, -12119, -8555, -1792 },
- { -16995, -19957, -11447, -3471 },
- { -13144, -14504, -9988, -3191 },
- { -9938, -11064, -6139, -3162 },
- { -8873, -11550, -8294, -6550 },
- { -9303, -13010, -6150, -2711 },
- { -15463, -10469, -1766, -170 },
- { -15985, -11693, -3007, -650 },
- { -17142, -10671, -1434, 47 },
- { -16063, -13858, -4817, -1058 },
- { -19446, -19599, -9594, -2464 },
- { -20076, -18744, -8313, -1889 },
- { -15047, -16085, -7590, -2250 },
- { -13481, -16195, -8552, -2998 },
- { -13829, -14869, -6704, -1932 },
- { -16357, -18484, -9802, -2959 },
- { -10551, -8393, -9303, -5070 },
- { -11345, -9156, -5641, -3107 },
- { -13217, -13449, -9270, -4541 },
- { -11988, -13732, -9995, -6374 },
- { -11007, -9519, -5168, -4107 },
- { 9930, -7858, 8061, -4375 },
- { 8274, -7867, 5992, -2096 },
- { 9692, -9675, 7621, -3670 },
- { 9589, -8110, 6509, -3010 },
- { 12617, -11976, 10122, -5360 },
- { 11867, -8895, 7948, -5323 },
- { 10388, -10482, 9234, -4324 },
- { 8188, -8220, 7810, -2737 },
- { 10407, -8787, 4806, -1930 },
- { 10348, -8845, 9233, -6614 },
- { 9422, -7091, 4820, -2878 },
- { 9758, -9796, 5584, -2256 },
- { 10188, -7994, 5347, -3343 },
- { 11133, -7455, 4015, -2306 },
- { 10676, -10744, 6093, -2629 },
- { 11522, -12184, 7848, -3375 },
- { 8805, -9883, 5317, -3071 },
- { 9498, -9654, 6555, -3592 },
- { 10488, -8008, 4066, -1252 },
- { 11261, -8930, 6068, -2738 },
- { 12180, -10397, 5027, -1531 },
- { 9138, -8531, 3601, -1959 },
- { 8107, -8380, 4970, -2061 },
- { 9737, -13248, 6438, -2617 },
- { 11178, -10423, 2622, -522 },
- { 9572, -12372, 5199, -2019 },
- { 12057, -12144, 4147, -1099 },
- { 9047, -9925, 2516, -665 },
- { 10790, -8030, 5882, -4386 },
- { 7199, -8426, 6337, -2841 },
- { 7778, -8285, 3529, -3442 },
- { 7559, -10569, 3484, -1332 },
- { 9404, -8115, 7484, -5541 },
- { 7792, -11976, 5546, -2573 },
- { 9313, -10264, 7661, -5195 },
- { 6701, -10725, 4370, -1784 },
- { 4918, -11361, 4507, -4527 },
- { 5147, -12305, 3978, -5556 },
- { 6525, -9899, 4481, -3129 },
- { 7538, -12855, 6060, -4826 },
- { 8659, -12111, 7159, -4430 },
- { 8440, -11304, 4547, -1747 },
- { 9216, -10918, 3507, -1195 },
- { 6165, -9254, 4771, -4677 },
- { 9163, -11019, 5637, -4935 },
- { 13441, -11509, 6676, -2434 },
- { 7912, -9398, 6663, -4048 },
- { 11723, -13745, 8131, -4148 },
- { 6065, -10257, 5005, -6327 },
- { 11618, -12417, 5336, -1894 },
- { 8891, -13924, 8407, -6131 },
- { 9622, -12563, 7908, -5109 },
- { 11479, -10315, 8349, -3991 },
- { 11676, -14103, 6611, -2330 },
- { 11951, -8953, 3829, -1550 },
- { 10486, -8044, 10493, -5920 },
- { 11801, -10769, 9763, -5305 },
- { 6109, -8676, 5827, -1346 },
- { 7030, -9611, 5624, -5761 },
- { 12808, -12886, 8683, -4148 },
- { 13213, -10464, 6381, -3189 },
- { 11796, -13681, 10703, -6075 },
- { 9639, -7949, 9625, -3944 },
- { 8538, -6997, 5309, 453 }
-};
-
-/* quantization tables */
-
-static const uint32_t scale_factor_quant6[64] = {
- 1, 2, 2, 3, 3, 4, 6, 7,
- 10, 12, 16, 20, 26, 34, 44, 56,
- 72, 93, 120, 155, 200, 257, 331, 427,
- 550, 708, 912, 1175, 1514, 1950, 2512, 3236,
- 4169, 5370, 6918, 8913, 11482, 14791, 19055, 24547,
- 31623, 40738, 52481, 67608, 87096, 112202, 144544, 186209,
- 239883, 309030, 398107, 512861, 660693, 851138, 1096478, 1412538,
- 1819701, 2344229, 3019952, 3890451, 5011872, 6456542, 8317638, 0
-};
-
-static const uint32_t scale_factor_quant7[128] = {
- 1, 1, 2, 2, 2, 2, 3, 3,
- 3, 4, 4, 5, 6, 7, 7, 8,
- 10, 11, 12, 14, 16, 18, 20, 23,
- 26, 30, 34, 38, 44, 50, 56, 64,
- 72, 82, 93, 106, 120, 136, 155, 176,
- 200, 226, 257, 292, 331, 376, 427, 484,
- 550, 624, 708, 804, 912, 1035, 1175, 1334,
- 1514, 1718, 1950, 2213, 2512, 2851, 3236, 3673,
- 4169, 4732, 5370, 6095, 6918, 7852, 8913, 10116,
- 11482, 13032, 14791, 16788, 19055, 21627, 24547, 27861,
- 31623, 35892, 40738, 46238, 52481, 59566, 67608, 76736,
- 87096, 98855, 112202, 127350, 144544, 164059, 186209, 211349,
- 239883, 272270, 309030, 350752, 398107, 451856, 512861, 582103,
- 660693, 749894, 851138, 966051, 1096478, 1244515, 1412538, 1603245,
- 1819701, 2065380, 2344229, 2660725, 3019952, 3427678, 3890451, 4415704,
- 5011872, 5688529, 6456542, 7328245, 8317638, 0, 0, 0
-};
-
-/* 20bits unsigned fractional binary codes */
-static const uint32_t lossy_quant[32] = {
- 0, 6710886, 4194304, 3355443, 2474639, 2097152, 1761608, 1426063,
- 796918, 461373, 251658, 146801, 79692, 46137, 27263, 16777,
- 10486, 5872, 3355, 1887, 1258, 713, 336, 168,
- 84, 42, 21, 0, 0, 0, 0, 0
-};
-
-static const float lossy_quant_d[32] = {
- 0, 1.6, 1.0, 0.8, 0.59, 0.50, 0.42, 0.34,
- 0.19, 0.11, 0.06, 0.035, 0.019, 0.011, 0.0065, 0.0040,
- 0.0025, 0.0014, 0.0008, 0.00045, 0.00030, 0.00017, 0.00008, 0.00004,
- 0.00002, 0.00001, 0.000005, 0, 0, 0, 0, 0
-};
-
-/* 20bits unsigned fractional binary codes */
-static const uint32_t lossless_quant[32] = {
- 0, 4194304, 2097152, 1384120, 1048576, 696254, 524288, 348127,
- 262144, 131072, 65431, 33026, 16450, 8208, 4100, 2049,
- 1024, 512, 256, 128, 64, 32, 16, 8,
- 4, 2, 1, 0, 0, 0, 0, 0
-};
-
-static const float lossless_quant_d[32] = {
- 0, 1.0, 0.5, 0.33, 0.25, 0.166, 0.125,
- 0.083, 0.0625, 0.03125, 0.0156, 7.874E-3, 3.922E-3, 1.957E-3,
- 9.775E-4, 4.885E-4, 2.442E-4, 1.221E-4, 6.104E-5, 3.052E-5, 1.526E-5,
- 7.629E-6, 3.815E-6, 1.907E-6, 9.537E-7, 4.768E-7, 2.384E-7, 0,
- 0, 0, 0, 0
-};
-
-
-/* Vector quantization tables */
-
-DECLARE_ALIGNED(8, static const int8_t, high_freq_vq)[1024][32] =
-{
- { 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 },
- { -4, -2, 2, 1,-16,-10, 1, 3, 1, 0, 6, 1, -3, 7, 1,-22,
- 2, -4, -3, 11, 14, 6, -1, 1,-13, 29,-28, 10, 10, -8, 0, -9 },
- { -8, 8, -7, 10, -3,-12, -5, -8, 1, -2, 9, -2, -5,-18, 1, 9,
- -8, -8, 3, 41, 7, -9, -9, 22,-42,-29, 14,-18,-14,-32, 1,-15 },
- {-16, 8, 15, 16,-16, 5, 2, 7, -6,-16, -7, 1, 1, -3, -2, 0,
- 8, 20,-26,-11, 2,-17, 0, -3,-34,-37, 10, 44, -2, 22, 2, -4 },
- { 7, 14, 5, 6, 15, -1, 3, -3, -9,-23, -5,-14, 8, -1,-14, -6,
- -5, -8, 54, 31, -6, 18, 2,-19, -2,-11,-30, -6,-19, 2, -2,-14 },
- { 1, 2, -2, -1, -3, -3, 1, -5, 1, -3, -4, -8, 5, -4, 0, 1,
- 3, 7, -5, -4, -3,-12, 3, -2, -3, 12,-53,-51, 6, -1, 6, 8 },
- { 0, -1, 5, 1, -6, -8, 7, 5,-18, -4, -1, 1, 0, -3, -3,-14,
- -1, -6, 0,-14, -1, -1, 5, -3,-11, 1,-20, 10, 2, 19, -2, -2 },
- { 2, 4, 3, 0, 5, 0, 3, 1, -2, 0, -6, -3, -4, -5, -3, -3,
- -7, 0,-34, 4,-43, 17, 0,-53,-13, -7, 24, 14, 5,-18, 9,-20 },
- { 1, 0, -3, 2, 3, -5, -2, 7,-21, 5,-25, 23, 11,-28, 2, 1,
- -11, 9, 13, -6,-12, 5, 7, 2, 4,-11, -6, -1, 8, 0, 1, -2 },
- { 2, -4, -6, -4, 0, -5,-29, 13, -6,-22, -3,-43, 12,-41, 5, 24,
- 18, -9,-36, -6, 4, -7, -4, 13, 4,-15, -1, -5, 1, 2, -5, 4 },
- { 0, -1, 13, -6, -5, 1, 0, -3, 1, -5, 19,-22, 31,-27, 4,-15,
- -6, 15, 9,-13, 1, -9, 10,-17, 4, -1, -1, 4, 2, 0, -3, -5 },
- { -7, 3, -8, 13, 19,-12, 8,-19, -3, -2,-24, 31, 14, 0, 7,-13,
- -18, 0, 3, 6, 13, -2, 1,-12,-21, 9, -2, 30, 21,-14, 2,-14 },
- { -3, -7, 8, -1, -2, -9, 6, 1, -7, 7, 13, 3, -1,-10, 30, 4,
- -10, 12, 5, 6,-13, -7, -4, -2, -2, 7, -3, -6, 3, 4, 1, 2 },
- { -8, 9, 2, -3, -5, 2, 0, 9, 3, 7, -4,-16,-13, 3, 23,-27,
- 18, 46,-38, 6, 4, 43, -1, 0, 8, -7, -4, -1, 11, -7, 6, -3 },
- { 1, 1, 18, -8, -6, 0, 3, 4, 22, -3, -4, -2, -4,-11, 40, -7,
- -3,-13,-14, -7,-10, 14, 7, 5,-14, 11, -5, 7, 21, -2, 9, -3 },
- { 0, 0, -2, 4, -2, 0, 2, 0, -1, 2, -1, 0, 0, 2, 2, 2,
- -1, 1, -3, -1,-15, -2,-63,-27,-21,-47,-14, 1,-14, 10, 0, 2 },
- { 1, 0, -4, 0, -3, -9, 4, 2, 6, -6, 0, -5, 11, -7,-15, 6,
- -7, -6, 3, 7,-15, -5, 23,-13, -6, 12, -8, 9, 2, -3, 3, 4 },
- { 6, 0, 3, 0, -2, -4, 2, 1, 1, -1, 1, -2, -1, -4,-22,-15,
- -46,-66, 10, 20, 2,-17, 12, -6, 1, -2, -2, 0, 1, -5, 1, 2 },
- { -1, 0, 0, 1, 0, -4, 0, 1,-10, -3, -8, 5, 7,-11, 2,-11,
- 29,-25, 11, 10, 0, -1, 5, -7, -2, -5, -2, 4, 4, -3, 5, -2 },
- { 1, -1, -1, -3, -2, 1, -8, -3, 2, -2, 4, -5, -1, -7, -2, 1,
- -14, -7, 3,-30,-15,-14, 3, -4, -1, 3,-13, -1, -3, 1, 2, 3 },
- { -1, -2, -3, 2, 2, -3, 3, 1, -3, 2, 0, -4, 6, 5, -5, 10,
- -57, 3, 22,-50, 1, -2, -5, -6, -1, 5, 1, 2, 2, 1, -2, 2 },
- { 2, 0, -1, -7, 2, 1, 3, 2, 0, 4, 3, -2, 3, -3, 4, -4,
- 24,-35, -3, 38, -6, -5, 15, 20, 3, 16, -7, -5, 0, -4, -5, 0 },
- { 0, 1, 0, 0, 0, -1, -1, 1, 1, -1, 1, -2, 0, 0, 0, 0,
- 0, -1, -2, -1, -5, -2,-43, -3, 46,-52,-10, 7, -8, 11, -2, -1 },
- { 0, 0, -1, 0, -1, 2,-41, 33,-44,-48,-15,-26, -9, 6, 3, 3,
- -3, 2, 2, 2, 2, -1, -1, -2, 1, 3, 0, 0, 5, 2, 3, 1 },
- { -4, 1, 6, 1, -6, -1, -2, 1,-14, -4, 0, -5, -2, 2, -2, 0,
- -6, 1, 0, 8,-21, 32, -3,-36, -6, -2, -1, -7, 3, 0, 1, -6 },
- { -3, -2, 3, 0, 2, 2, 8, -4, -4, 6, 2, 1, 3, -6, 4, 3,
- 13, 0,-12, -1, 25,-20, -2,-23,-15, 7, -3,-11, -3, 6, -1, 0 },
- { 0, 0, -3, -1, 0, 0, -2, -1, -2, -2, 1, -1, 0, 0, 10, 3,
- -2, 3, 3, -7, -6, -5, 0, -4,-60,-16, -6, 38, 5, 6, -5, 0 },
- { 0, 1, 0, 0, 0, 0, 0, 0, 1, -1, -1, 0, 1, 0, 0, 1,
- 0, 0, -1, 0, -8, 2, -9, 10, 40, 31,-56,-21, 4, 20, -4, 7 },
- { -2, -2, 0, 4, -3, -1, 7, 3, 1, 3, -8, 0, 3, 1, 2, 5,
- 1, -2, 14, 5, 4, 5, 5, 5, -5, 9,-66, 0,-20, -2, -8, 4 },
- { -2, -1, 4, -1, -8, -2, -4, -1, -3, -3, 2, -7, -3, 5, 7, -2,
- 45, 31,-17,-16, -2, -2, -1,-22, 1, -1, -3, 3, 5, -3, 5, -1 },
- { -4, 0, 7, 5, 8, 7, 2, 9, -9, -9, -7,-11, -3, -8, 17, -4,
- 34, 32, 18, 22, 1, 2, 1, -7, -5, 6, -1, 6, 4, 10, -2, -7 },
- { 6, 0, 14, 9, 6, -1, -2, -3, 4, -6, -8, 4, 7, -1, 28, 38,
- 15, -1, 16,-11, 5, 8, 4,-10, 3,-10,-17, 5, 3, 3, 3, 1 },
- { 1, 1, 2, -1, 2, 1, 0, 0, -1, 0, 0, -2, 1, -3, 0, 1,
- 2, -2, -4, -2, 0, -1, 1, -3, 1, 1, 1, -1, 8, 8, 66, 33 },
- { -5, 2, -3, -7, 2, -8, -4, 10, 17,-18, -7, 4, -4, -7, -6, -6,
- -5, 5,-12, 2, 0, 6, 8, -2, 1, 4,-11, 2, 1, 8, 31, 19 },
- { 6, 9, 16, -6, -6, -1, -2, -3,-11, -2, 7, 7, 17, 3, 4, 10,
- 2, 5,-13, 8, 7, 1, 4, 5, 7, 6, 7, -8, 9, -8, 33, 6 },
- { 3, -1, 1, 0, -7, -5, 0, 14, -7, 1, -7, 1, 2, -4, 7, 10,
- -16, 12, 1, -6, 3, 8, -1, 10,-13, -6,-12,-23, 12, -3, 30, 14 },
- { -2,-15, 0, 8, 3,-19, 5, -3, 2, 3, 13, 7, 14, -3,-10, 0,
- 8, 5, -6,-16, -8, -8, 14, 2, -1, 1, -9,-11, 11, -5, 27, 9 },
- { -8, 6, -4, 4, -4, -1, 5, 4, 1, -7, -5, -4,-15, 1, 9, 0,
- 8, 4, 1,-17, 11, -2,-19, -1, -6, -8, 3,-12, 3,-17, 33,-10 },
- { -3, -1, 2, 7, 7, -2, 9, 8,-18, -1,-13,-10, -3, -3, 11, 8,
- -2,-12, -8, 1, 4, 9, 14, 10, -3, 0, 2, 1, -2, 3, 31, 10 },
- { -3,-10, 8, -1, -5,-11, 7, -5, 3, 6, 1, 4,-16, 10, 5, -4,
- -2,-10, -1, 13, 6, -5, -7, 12, 7, -3,-17, 1, 12, -4, 29, 8 },
- { 1, 2, 5, 2, -6, -7, 0, -1, 6, -1, 10, 6, -4, 5, 2, 2,
- -2, -8, -6,-11, 14,-13, 27, 3, -2,-12, 5,-16, 2,-26, 20, 15 },
- { -1, -3, -5, -3, -3, 6, -1, 3, -5, 1, 7, 2, 1, 0, -1, -1,
- 0, -1, 9, 7, -6, -3, 4, -5, -4, 8, -8,-25, -8, -4, 34, 23 },
- { -1, -2, 1, 1, -1, -2, -1, 1, -1, 0, 0, 0, 0, -2, -1, 1,
- 0, 2, 1, -1, 4, 0, 0, 1, -1, 0, 5, 3, 12, -9, 68,-16 },
- { 10, 0, -8, 14, -6, 1,-12, 0, 0, -3, -5,-11, -6, 12, 9,-10,
- -3, 5, 0, 7, 11, 2, 4, -3, -8, -3, 7, 4, 3, -3, 34, 4 },
- {-12, 13, -5, 7,-11, -2, -1, 1, -4,-14,-21, 3, -3, -3, -4, -7,
- -9, -4, 3,-17, -2,-13, 10, -2, 12, -4, 0, -9, 1, -5, 31, 10 },
- {-10, 6, 5, 6, 4, -7, 10, 0,-28, -3, 0,-11, -1, -5, 16,-10,
- -16, 7, 20, 2, -4, 2, -5, 0, 15, 6, 5,-10, 7, -9, 20, 4 },
- { 1, -7, -2, -7, 4, -3, -2, -7, -1,-14, 6,-16, 4, -5, -4, -6,
- -5, 0, -2, 2, -6, 9, -5, 4,-18, 8,-10, 8, 15, 0, 32, 1 },
- { -5, 7, -3, 7, 15, -4, 0,-16, 9, 5, -5, 5, 4, -3,-12, -9,
- -18, 10, 2, 2, -3, 7, 3, -1, 6, -9,-10, 3, 15, -4, 35, -7 },
- { -1,-10, 2, 2, -4, -2, 10, 2, -1, 2, -2, 1, -1,-14,-11, 3,
- -8, 5, -8, -2, 6, -1, -7, 1, 7, 5, 7, 8, 30, -4, 30, 14 },
- { 2, -2, 1, 2, 3, -8, 3, 0, -2, 0, -9, 2, 1, 4, -6, -1,
- -2, 5, 0, 1, -2, 12, 6, -3, 9, -3, 4,-12, 21,-39, 24, -2 },
- { 3, 5, 1, -2, -2, -2, -3, 6, -8, -2,-11, -8, -1, 4, 2, 2,
- -4,-10, 12, -5,-11, 1,-15,-34,-11, -7,-11, -1, 7,-14, 38, -1 },
- { -4, 4, 8, 9, 8, 1, -5, -9, 4, -2, 15, -4, 11,-15, 20, -1,
- -1, -3, 4, -9, -2, -2, -2, 8, 6, 12, -5, 0, 11,-12, 27, -4 },
- { 0, 8, -4, 3,-11, 6,-11, 2, 3, 0, 5, -8, -7, -6, -9,-21,
- 4,-11, -1,-16, -7, 16, -3, 7, -7, 4, -5, 0, 11, -7, 31, 3 },
- { 1, 3, 4, 11,-11, -2, -3, -6, 6, 5, 0, 3, -9, -6, 4, -4,
- 0, 4, -8, 13, -6,-13, -1, -5, -1, 4, 0, 0, 9,-22, 24, 18 },
- { -7, 3, 10,-13, -6, 6, -6, 6, 22, 1, 0,-14, 2, 3, 7, -1,
- 8, 20, -1, 5, -4, 13, 9, -9, -9, 6, 0, -4, 0, -8, 31, -4 },
- { -3, -4, 0, 1, 7, 3, -7, 0, 5, -2, 1, 3, 3, 1, -5, -2,
- 5, 2,-11, 4, 0, -1, 12, 0, -3,-13, 15, 8, -6,-27, 34, 0 },
- { -3, -3, 10, -4, 2, -1, -3, 0, -1, -1, -4, 2, 6, -2, 12, 1,
- 3, -6, -7, -6, -5, 4,-19, -6, -8,-34, -4, -8, 10, -7, 23, 10 },
- { -7, 0, -1, -6, 8, 4, -4, 2, -5, -8, -7, -9, -8, 5, 9, 7,
- -6, 1,-12,-12, -1,-16, 5, 0, 16, 3, -7, -8, 27, -4, 23, 15 },
- { -8, 4, 8, 5, 6, 11, -3, 5, 3, -1,-11, 6, -5, 0, 2, -6,
- -3, -6, 4, -1, 5, -5,-12, -6, 7, -5, 9, 3, 6, -7, 29, 1 },
- { 1, 3, -2, -2, -6, -2, 1, 6, -6, -3, 1, 2, 3, 4, 1, 5,
- -1, 0, 4, 2, 11, 6, 2, -3, 13, -9,-19, 18,-15,-10, 36, 21 },
- { -3, -3, 2, -1, -7, 6, -4, 1, -3, -1, -2, 2, 3, -7, -3, 0,
- -2, 0, -2, 6,-19, 3, -8, 2, -6, 7, -1, 0, 29, -6, 28,-10 },
- { -5, 1, -3, -7,-12, -4, 1, 1, -1, 13,-10, -1, -9, -5,-13, 6,
- 13, 3, -4, 2, 3, 11, 2, 6,-25,-16, -6, 0, 14, -1, 27, 16 },
- { -6, -1, -7, -5, -2, -5, -5, -1, 9, 1, 0, 3, -8,-12, -6, 5,
- -6, 5, 3, -9, 1, 4, -7,-10, -9, -7,-17, -5,-15,-23, 25, 3 },
- { -8, -2, 9, -3, -4, 3, -1, 8, -7, -7, -5, -4, -2, 9, 4, -1,
- -7, -4, -5,-16, 3, -6, 18,-13, -9, 16,-15, 8, 15,-10, 24, 5 },
- { 1,-38, 2, 34, 9, 10, 11, 2, 2, -6, 3, 2, -2, 5, 4, -7,
- -1, 1, 4, 0, 3, 1, -8, -1, -6, 5, 4, 2, -4, 5, 2, -1 },
- { 1,-22, 15, 18, -2, 10,-16, -9, -8,-11, 8, 4, 0, 7,-14, -5,
- -1, -7, 12, 17, 9, 5, -7, -4,-12, -6, 7, 0, 7, 2, -2, 1 },
- {-11,-29, 7, 10, 19, -1, -8, -9, 7, 1, 9, 6, 8, -7,-14, 8,
- -3,-11,-13, 0, -7,-23, -2, -8, 12, 9, 2, 14, 19, 1, -1, 5 },
- {-24,-27,-11, 36, 2, 6, -3, 4, -6, 8, 0, 12, -1, -4, -6, 3,
- 4, -1, 2, -3, -2, 3, 2, -1, -2, -4, 0, -1, -2, 7, 2, 3 },
- { -9,-24, 11, 13,-10,-12, 12, -2, 7, 4, 8, 13, -3, -3, 2, 9,
- -3, -4, 4, 13, 5, 13, -6, -3, 1, 15, 7, -3, 0, 19, -2, -9 },
- { -8,-15, 7, 14, -4, -5, 2,-18,-19, -2, 2, 17, 16, 6,-10, 10,
- -9, 14, -1, -5, -1, -6, -7, 2, 9, 11, 13, 6, -5,-12, 3, 2 },
- {-10,-37, 13, 1, 3,-14, 0,-20, 4, -3, 8, 2, -2, -3, -9, -5,
- -3,-17, -1, 13,-11, 2, -6, 4, 4, 0, 3, 1, -9, -4, -5, -4 },
- { -2,-22, -5, 46, -8, 5, 9,-11, 8, 7, 7, -1, -1, -2, -7, 2,
- -3, 3, -1, -2, 7, 0, 2, -1, 1, -2, -2, -3, 6, 0, -4, -6 },
- {-16,-27, 15, 16, -4, 14, -7,-26, 2, -2, 6, 5, -3, 11, 0, 2,
- 3, 9, -7, -1, 2, -4, -4, -1, 6, 10, 1, 1, -3, -2, 3, 0 },
- { -3,-22, 10, 26, 1, 2, -3, 3, 17, -3, -7, 9, 1,-21, -4, 5,
- 3, 0, -7, -6, 3, 3, -8, -7, -9, 3, 7, 1, -8, 12, 6, -7 },
- { -9,-25, 3, 18, 9, -6,-11, 0, -5,-12, 9, -8, -7, -6, -6, 22,
- 2, -6, -3, 15, 3, 2, -2, 9, 14,-10, -7, 15, 13, 6, -2, 11 },
- { 5,-20, -5, 28, 11, 10, -4, -4, 0, -7, 3, 5, 2, -5, -8, 2,
- 6, 10, 9, -9,-18, 3, 14, 1, 3, -3, -1, -6, 7, 7, 2, -1 },
- { -8,-30, 7, 12, 10, 8, 7,-13,-16, 0, 1, -1, -6,-11,-15, 4,
- 1, -2, 10,-15, 1, 11, -2, 8, 9, -7, -7, 9, -5, 2, 7,-18 },
- {-10,-32, 10, 11, 3, -1, 3, -5, 5, 2, 14, -6, 3, 1, 5,-15,
- -11, 6, 20, 4, 0,-12, -7, 3, 1, -1, 10, 6, -1, -9, -4, -1 },
- { 1,-25,-14, 12,-11, 9, 9,-16,-24,-17, 22, -9, 11,-30, -3, -4,
- 6, -7, 9, 2, -1, -5, -6, 2, -1, -1, 10, 1, -3, 3, 4, 8 },
- {-14,-26, -6, 9, 8, 17,-11,-24, -7, -4, -8, -2, 10, 2, 2, -1,
- 2, 13, 12, -7, 4, -6,-10, 6, 6,-13,-11, -7,-16, 0, -2, 5 },
- { -4,-30,-13, 12, 16, -6, 12,-16,-13, 5, 15, -2, -2,-10, -7, 7,
- 11, -1, -4, -2, -4, 7, 4, -8, 1, 3, 0, 11, 3, -2, -5, 4 },
- { -4,-21, 20, 22, 2, 20, -8, 1,-12, -5, -9, 4,-10,-17, -3, -8,
- -3, 3,-12, 1, -3, 0, 7, 4, 7, 7, -3, 7, 5, 3, 1, -5 },
- {-12,-20, 2, 29, 11, -6, 9, -7, -6, -4, 0, 6, 17,-13, -2,-10,
- -17, -1,-18, 2, 0, 14, -6, 1, 0, 3, 2,-10, 1, -5, -2, 5 },
- { 16,-37, -1, 26, -2,-14, 1, -5,-14, 2, 2, 3, 6, 1, 1, 4,
- 0, -1, 0, -2, -2, 4, 9, -6, 0, -2, 10, -7, -2, 4, 1, 0 },
- { -9,-24,-12, 5, 5, 3,-17,-14, 4, 3, 2, -4, 10,-22, -8, -3,
- 6, 1, 12, -8, 4, 1, 9, -1, 18, -3, 6, 5, 3, -5, 9, -5 },
- {-14,-33, -2, 20,-13,-10, 2, -7, -1, 11, -9, -8, 18, -3, 1, 8,
- 0, -2, 10, 7, -2,-13, 9, -3, -4, 5, -2, -2, -1, -5, 1, -7 },
- {-10,-23, 8, 14, 1, 7, 1, -3, -7, 4, 1, 1, 8, -7, 15,-14,
- 13, 14, 2, 5,-13, -5, -8, -1, 6, 3, 6, 9, 6, 15, 14, 5 },
- {-13,-25,-10, 13,-17,-24, -7,-13, -6,-10, -8, 2, 0,-13,-10, -4,
- -8, 4, -9, 9, -4, 4, -3, -3, 3, 3, -5, -9, 1, -2, 11, 2 },
- {-12,-23, 1, 18,-11, -2, 5, 9, -5, 5, 14, -9, -3, -2, -6, 2,
- -2, 11,-13, 1, -3, 11, -9, -4, -2, -6, 8, 10, 1, 4, 2, 1 },
- { -5,-18, 16, 22, 2, 0, 8, -6, -9, -7, 10,-16, 23, 10,-11, -1,
- 7, 2, 7, 2, 1, -5, 6, 1, 0, -4, 9, 2, -3, 1, 0, -4 },
- { -3,-26, 14, 11, 2, -9, 17, -2, -1, -5,-16, -9, -5, 10,-13, 1,
- 6, 12, 10, 11, 0, 0, -3,-14, 6, -2, 0, 4, -5, -1, -7, -1 },
- {-10,-33, 1, 8, 11, -5, 1, -6, 7, 4, 5, 6, 1, -2,-10, -5,
- -6, 12,-11, 5,-10, 4, 12, -1, -1, -3, 4, -1, 9, 0, 16,-17 },
- {-14,-37, 7, 7, -2, 5, -8,-11, 2,-13, 4,-19, 1, 8, 8, 4,
- -9, 2, -4, 3, 12, 2, 4, -4, -8, 8, 1, 4, 8, -1, 6, -2 },
- { -6,-30, 18, 17, 1,-22, -3, 4, -7,-10, 7, 0, -8, 8, -1, 4,
- 2, 8, 6, -2, 2, 7, 4, 4, 3, -6, 2, 1, -3, 1, -1, -5 },
- {-17,-18, -3, 22, -8, 1, 9, -2,-17, 20, -5, -5,-12, -5, 4, -5,
- -9, 8, -2, 16, -3, 0, 19, -8, 8, 1, 2, -4, 0, 11, 0, -3 },
- { -9,-23, 3, 10, 4, 4, -3, -2, -2, -2, 1,-22, 11, 0, -2, 5,
- -2, 14, -9,-11, -4, 7, 5, 32, 1, -3, -7, 0, 21, -9, 7, -6 },
- { 0, 0, 0, 2, -1, 1, 0, 1, 3, 0, 0, 1, 0, 1, 0, 1,
- -3, 0, -1, -2, 0, -1, -1, -3, -1, 1, -4, 1, -1, -5,-69,-19 },
- { -3, -5, -8,-12, 4, -3,-19,-11, -5, 0,-14, 7, 18, -6, 7, 22,
- 8, 14, 15, 10, 3, -1, -3, 5, -1, 7, -7, 1, -6, 3,-26,-11 },
- { -1, -6, 4, -4, -5,-16, 0, -6, -3, 11, 1, 0, 9, 5, 16, 3,
- -4,-33, -4, 4, -7, 0, 1, 6,-11, -2,-13, -2,-18, 20,-25,-16 },
- { 4, 0, -1, 0, -5, 1, 0, 2, 0, 11,-10, 4,-10, 7, 16, 2,
- 16, 15, 2, -1, 2, 9, 2, 8, -3, -5, -2, 0, -3, 0,-33, -2 },
- { -3,-15, 10, 10, -9, -1, 7, 3, 5, -5, -8, -8, -3, 15, -9, 4,
- 12, 13,-13,-14, 10, -6, 9, 22,-27, 23, -1, 5,-24, 2,-30, 5 },
- { 0, -2, 7, -5, -5, 3, 5, 3, -3, -5, 2, 1, -4, 3, -3, -1,
- 1, -2, 10, 22, -3, -4, -2, -2, -7, 3, 8, 1, 14, 4,-37, 9 },
- { -3, -4, -1, 1, -4, 0, 6, 2, 6, -7,-10,-10, -1, -4, 11, -3,
- 7, -6, 4,-12, -1, 5, 1, -7, 10, -6, 17, -4, 8, 3,-40, 13 },
- { 2, 12, 4, -7, 14, -3, 16, -2, 18, 2, 13, 5, 5, 1, 11, -1,
- 0, 9, 2, -6, -1, 2, -6, 2, -5, 3, 5, 1, -1, 1,-32, -7 },
- {-16, 11, 7, -4, 2, -5, -9, 9, 11, 11, 15,-13,-11, 11, 9, 4,
- 3, -8,-10, 12, 12, 0, 0,-16, -9, 13, 2, 9, 4,-13,-33, 3 },
- { 6, 4, 5, 4, 3, -1, 5, 6, 4, 2,-11, -1,-15,-11, -1, 1,
- 11, -3, -2, 24, -4, -6,-25,-10,-15, -8, 0, 0, -5, 4,-30, 2 },
- { 10, -3, -6, 1, -9, -5, 6, 9,-10, -3, 8, -1, 4, -1, 11,-11,
- 3, 9, 11, -3, 6,-17, 5, -8,-33, 9,-13, 19, -2, 9,-25, 2 },
- { 0, 0, -1, -3, 0, -2, 1, 0, 0, 2, 1, 0, -2, 0, -1, 2,
- 0, -1, 4, -1, 2, -3, 4, -2, 3, 3, 1, 0,-15, 12,-63, 27 },
- { -2, 14, 9, -1, 3, 0, 1, 1,-19, 15, 3, 4, 0,-10, 1, -5,
- 3, 0, -5,-10, 2,-16, -4, 8,-12, -6, 7, -5,-10, -1,-33, -4 },
- { 0, 3, 1, 3, 1, 2, 4, 4, 9, -6, -8, -5, 1,-12, 3, 8,
- -10, 6, -1, 1, 13, -5, -5, 2, -4, 13,-18,-10, -7, -9,-33, 10 },
- { -6, -3,-12, 5, -1, 11, -6, 0, -2, 1, 2, -7, 3, 1, 3, -2,
- 1, 8,-10, 7, -1, -3, 3, 0, 13, 1, 6, 7,-16, -7,-39, 8 },
- { -6, -1, 11, 6, -3, 8, 3, -5, 3, 0, -5, -2, -6, -3, -4, 2,
- -3, 13,-11, 1, 7, 5, 19, -5, -3,-15, -1, 7, -1, 6,-33, 8 },
- { -7, 3, -4, -3, -4, 1, 6, -5, -5, 6, -8, -1, -7, 4, -1, -6,
- -2, 1, 7, 0, 1, 1, -5, 2, -2, 0,-13, -2,-31,-14,-39,-12 },
- {-10, 9, 0, -3, 1, -1, -1, 0, 1, -5, -1, -4, -2, 5, 2, -7,
- 18, -8, -2,-19, -7, -7,-12,-14,-11, -1, -9,-13, -7,-12,-31, -9 },
- { -3,-16, 10, 9, 1,-10,-12, 2, -2, 2, 7, -3, -3, 1, -4, -5,
- -9, 5, 7, 3, -1, 4,-11, -8, 4, 13,-10, 13, 10, -4,-36, 1 },
- { -7,-12, 4,-20, -7, -7, 2, 11, -1, -2, 3,-12, 1, 0, -6, -7,
- 6, 4, 13, 3, -3, 4, 3, -6,-12, 5, -5,-22,-13, -8,-37, -6 },
- { -7, 5, 3, 5, 7, 9,-14, -3, 10, 17, -1, 1,-12, 5, -6, 0,
- -4, -9, 0,-11,-14, 3, 13, 6,-25, -8,-12, 4,-10, 18,-30, -1 },
- {-10, 6,-10, 6, 6, 1,-10, 0, -7, 5, -2, 17,-18, -4, 0, -3,
- -16, -6, -3, -8, 5, 1, -4, 6, -7, 16, 6, 10, -1, 0,-32,-11 },
- { -1, 9, 9, -5, 4, 9, 6, 9, -4, -2, 7, 11, 4, 2, -5, -4,
- -6, 0, 2, -3, -1, 5, 10, 0, 12,-10,-18, -3, -1, 14,-33, 2 },
- { 4, -8,-18, -4, -5,-11, 4,-10, -4, 9, 13,-12, 1, -6, 1, 2,
- 4, -9, 8, 3, -6, 21, 13, -1, -2, 1, -2, 6, -7, 0,-30, 1 },
- { 6, -1, 2, -3, -1, -4, 6, -4, 0, 4, 2, 2, -9, 2, 6, 3,
- -2, 4, -1, 9, -6, 0, 7, -8, 5, 19, -2, 9, -5, 2,-33, -8 },
- { 2, 1, 12, -5, -8, 8, 3, -2, -4, 1, -2, 5, -4, -9, -8, -8,
- 7,-11, -4, 6,-10, 7, -1, -1, -2, -1, 16, 32, -7, 20,-33, -6 },
- {-18, 2, 6, 13, 9, 9, -1, 3,-17, 24, -2, -6, 28, 8, -2, 6,
- 3,-10,-34,-16,-13, -4,-15,-11,-12, -3,-10, 4, -8, 4,-31, -4 },
- {-11, 0, 18, 2,-16, -9,-13, -2, -2,-12, -3,-22, 30, 0, 8, 3,
- 9, -4,-16, 1, 0,-11, 15, -2, -4, 6, -5, 6, 1, 2,-25,-12 },
- { 14, -1, 5, 7, 3,-15, -8, 1, 5, -2, 12, 13, 11,-25, 3, 1,
- 0, -2, -4,-16,-23, 0, -5,-17, 7, 5, -9, 6, -5, 2,-32, -7 },
- { 3, -1, 6, 14, 2,-12, -9, -9, 4, 7, 4, 6, 5, -8, 4, 2,
- 4, 5, -2, 8, 8, -6, 0, 10,-20, -1, 3, -1, 8, 23,-33, -5 },
- { -3, 11, -6, 3, -4, 5, 7, 3, 4, 5, -2, 3, -1, 30, 6, 1,
- 8, -6, 0, 0, -9, 6, -9, 4, 2, 9, -6, 1,-12, 0,-34, 18 },
- {-17, 13, 0, 1, 9, -4,-11, 0, 7, 0,-10, -4, -1, 6, -6, 4,
- 1, 6, -9, 3, -5, -6,-11, 2, -4, 14, 23, -3, 2, 5,-30, 12 },
- {-14, 5,-27, 2, 0, 7, 1, 4, 30, 8, 7, 5, 1, -1, 0, 5,
- 8,-10, 48,-11, 12, 33, 6, 8,-15, 20, -2, -5, 32, 5,-19, 10 },
- {-16, -4,-12, -7, -2, 0, 8, -6,-20,-18, 16, -3, 0, 31, -2, 11,
- 2, -9, 49,-19,-12,-23, 10, 26, 16, -2, 4,-21,-14, 13,-11, -9 },
- { -5, -9, -1, 3, -5,-21, 2, 10, 0, 0, 10,-21, -7, 7,-26, -9,
- 22, 32, 58, 11, -3, 11, -5, -8,-13, 6, -5, -9, 1, 10, 14, -8 },
- { 7, 7, 10, 3, -2, -1,-11,-11, -6,-43, -3, 14,-19,-18, 19, 18,
- -32, 10, 45, -6, 6, 21,-20,-12, 2, 4, 6, 6, -4, 3, 3, 1 },
- { 21, 22, -3, -2,-11, -6, -1, -2, 8, 8, 32,-21, 7, 28, -4, -6,
- -3, -2, 50, 2, 2, 27, -5, -8, 12, 7, -5, -1, -4,-17, 27, 6 },
- { 13, 7, 2, -6,-12, 2,-10, -5,-17, 11, 4, 17,-12, -2, 5,-17,
- 37,-16, 48,-14,-18, 29, 8, 24, 11, -5, -9, 11, -1, 1,-13, -3 },
- { 1, 1, -1, 2, 0, 0, 0, -1, 1, -1, 7, 2, -3, 3, 0, 6,
- 2, 10, 54,-25, 7, 54, -5, -6, -1,-15, 9, 13,-24,-15,-12, 3 },
- { 21, 5, 8, 3, -3, -4, -2, -4, 3,-11, -5, -8, 9, 16, 8, -9,
- -10, -3, 46,-46, 2, 1,-10, 10, 17, 11,-20,-36, 10, 14, 0, -5 },
- { 7,-13, -6, -9,-24, 45, 2, 8, 8, 0, 17, 20, 12,-24, 1, -7,
- -15, -3, 46,-13, -2, 20, 1,-13,-11,-13, 2, 15, 1, 10, -1, 3 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -2, -1,
- -16, -9, 31,-69,-34, 26, 7, 17, -1, -6, -1, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -4,
- -5,-20, 18,-82, 22, 3, -7, 9, 4, 6, 2, -4, -1, 0, -2, 2 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 4, -1,
- 15, -5, 62,-36, 4, 52, -7, 5, 0, 6, 1, 2, 1, 1, -1, 0 },
- { 3,-19, 19,-20, 13, -4,-11, 8, 8,-16, 10, 1,-14, 30, 1,-33,
- 10,-11, 45,-30, 3, -4, -3,-13, 7, 12, 3,-22, 3, -2, -4, -2 },
- { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 1,
- 11, 8, 70, 48,-10, 21, 4, 9, -9, -9, -4, -6, 0, -1, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0,
- 2, -1, 80, 2,-15,-36,-10, -5, -2, 8, -2, 2, 0, 0, 0, 0 },
- { 10, 8, -8, -8,-24, 12, -1, 0, 20, 9, -1, -2, 2, -2, 12,-10,
- -2,-13, 35,-43, 44, 15,-10,-25, 4, 10, -3, -5, -5, 7, -1, 3 },
- { 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -2, -1,
- -18, 9, 49,-72, 7, -8, 7, -5, 2, 3, 2, -2, 1, -2, -3, 1 },
- { -1, 4, -3, 10, 19, 4, 3, 20, 6,-24, 6, 9, 8, 15, 18, 18,
- -36, 19, 57,-11, 4, -3, 8, 7, 2, -3, -2, -9,-15, -2, 12, -4 },
- { 20, 3, 11, -9, -4, 22, 42,-25, 1, 5,-10,-19, 0, 9,-16, 5,
- 2, 10, 44,-29, 17, -3, -9, -2, -1, 8, 14, -7, -1, 16, -5, 1 },
- { -7, 16,-11, 12, 6, 33,-15, 14,-23, 2,-26, 8, 2, 10, 0, -5,
- 8, -8, 38,-38, -4, 5, 5, 5, 1, 22,-15, 7, 6, 0, 4, 28 },
- { -1,-12, 2, 10, -2, 0, 7, 17, 12, 22, -4, 10, 25, 29, 5, 18,
- 4, 1, 27,-39, 31, 17, 2, 2, 22,-23, 13, 16, 1, -7, -4, -5 },
- { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -2, 0,-14, 0,
- -7,-11, 49,-22, -4, 19, 17,-39, 4,-29, 10, 2, 36, -4, 23, -1 },
- { -2, -2, -2, -2, 1, 15, -5, -7,-16, -8,-19, 16, -3,-20, 36, -9,
- -3, 20, 39,-20, 0, 2, 27,-16, 10, 10,-14,-22,-16, -3, 13, -8 },
- { 5, -9, 6,-25, 7, 37, 13,-10, -5, 3, -5, 7, 18,-22, -7, 9,
- -5, -4, 50,-11, -4, -5, -5, 8, -4, -2, -4,-27, 14, 20, 7, -9 },
- { 0,-14,-10,-27,-14,-17, -6, 26, 10, 2, 14,-12, -5, 0, 8, 9,
- 0,-28, 55, -7,-12, -7, 4,-10, 10, 7,-12, 11, 3, 5, 9, -8 },
- { 2, 23, 4, -2, -1,-20, -2, 14, 10, -9, -9,-24, 10, 0, 11,-12,
- 12, 11, 49,-25, -2, 29, 7,-13, 21,-10, 11,-17, 3, 1, -8, 5 },
- { 3, 0,-14, -6, 18, -2, 17, -9,-19, 9, -5, 9, 14, 6, 19, -3,
- 27, 1, 41,-21, 20,-15, 33, 0, 26, 14, 7, 10, 3, 20, -3,-12 },
- { -1, 16, 15, -8, 3, -8, -8, 21, -5,-16,-29, 4, 1, -6, -4,-28,
- 2, 31, 37,-26, -2, 13, 24, 8, -9, -6,-29, 10, 7, 2, 7, 8 },
- {-10,-10, 11, 13,-32, 2, 16, 9, 14, 23,-15,-13, 24, 13, 4,-27,
- 14, 12, 31,-18, 17, 23, -2, -7,-14, 9,-17, -6,-10, 20, 9, 6 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0,
- 5, 1, 89, 8, 10, -6, 2, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, -1,
- 4, -7, 64,-50, 7, 37, 2, 5, 0, 0, 0, 0, 0, 0, 0, 0 },
- { -2, 5, 3, -4, -4, -3, 2, -3, 3, -3, 5, 4, 1, -6, -1, 1,
- 6, -2, 50,-35, -7, 43, 7, -7, -5,-26, 24, 21, 3,-15, 5, 6 },
- { -8, 21,-19, 33, -8, 22,-11, 17, 3, 0, 0, -2, 1, -3, 6, -1,
- 10, -8, 4,-11, -4, -5, 0, 8, -4, 3, 1, -4, 4, 2, 8, 4 },
- { -7, 5,-20, 9,-22, 3,-14, 1, 6, 13, 23, -2, -4, -7, 2, 0,
- 11, 4, 6, 3, -7,-11, -7, 4, 5, 5,-12, 8, 2, 4, 7, -3 },
- { -7, 6, -4, 20,-20, 16, -2, 7, 6, 16, 11, 12, -7, -7, 5, 3,
- -9, -4, 1, 2, 5, 2, 1, -9, -2,-17, -4, 6,-10, 7, -7, -6 },
- { -9, 18,-17, 12,-24, 1, -1, 4, 14, 9, 4, 3, 2, 8,-12,-14,
- 4, -8, -4, 7, 7, 6, -1, 13, -9, -4, -1, 1, 0, -4, 15, 8 },
- {-25, 2,-11, 6, -5, 24,-28, -5, 8, 12, -2, 6, 8, -3, 8, -9,
- -1, -5, -1, -5, 6, -1, -1, -1, -4, 8,-12, -2,-13, 7, 2, 1 },
- {-14, 14,-18, 20,-10, 12, -2, 9, 1, 0, 12, -2, 15,-10, 26,-17,
- 16,-11, 10,-10, 9, -2, 4, -8, 2, -3, 4, 4, 2, -3, -5, 1 },
- {-18, 12,-18, 21, -6, 12, -6, 13,-25, 18, 1, 11, -9, -5, 0, 10,
- -5, 3, -3, 8, -9, 7, 4, 2, -9, 0, 5, 0, 2, -3, 9, -8 },
- { -4, 16, 1, 18,-30, 9, 1, 6, -8, 13, 13,-12, -6, -1, 13, 7,
- 6, 2,-15, -3, 5, 5, 1, -6, 1, -5, 0, 2,-16, 0, 3, -4 },
- {-21, 1, -2, 6,-43, 18, -1, 5, -1, 4, 6, -2, -1, -3, -1, -3,
- 0, 1, 2, -9, 0, -1, 0, -2, 0, -1, -1, -2, 6, 0, 1, -2 },
- {-23, 10, 4, 7,-32,-11,-18, 2, -2, -7, -6, -3, -3,-12, 19, 3,
- -5, -6, 16, -6, 16, 2, 16, 16, 8, -2, 13, 8,-15,-11, 2, 10 },
- { -8, 2,-13, 2,-29, 24,-20, 19, 1, 10, -4, 10, 1, 2, -9, 11,
- -1, -2, 9, -5, 19, -7, 16, -9, -2,-18, 11, 1, 1, 0, 7, -3 },
- { -6, 3, 4, 13,-26, 10,-10, 28, -7, 28, 1, 7, 0,-14, 5, 7,
- 4, -4, 3, -2, 3, 3,-11, 7, 6, 4, 0, -1, 2, -1, -3, 2 },
- { -6, 16,-31, 13,-10, 17, -6, 4,-14, 4, 4, -1,-10, 12, -5, 1,
- -14, 15, 0, -8, 1, -5, 3, 3, 9, -5, 7,-20, 7, 4, 11, -5 },
- {-19, 3,-17, 14,-12, 16,-22, 18, 14, 8, -2, 4, 10, 12,-14, 4,
- -3, 2, 3, 7, -7, 7, -6, 2, -2, -4, -5, 0, -5, -2, 2, 1 },
- { -9, -7,-11, 24,-36, -9,-11, 5, 7,-12,-13, 18, -2, 20, 1, -4,
- -1,-10, 15, -6, 14, 1, 0, 2, 1, 2, -9,-16,-11, 7, 13, 0 },
- {-24, 24,-18, 18,-22, 14,-11, 13,-12, 11,-10, 11, -7, 11, -5, -4,
- -1, 1, 5, 2, 3, -1, 1, -5, 7, -4, 5, -6, 8, -7, 8, -6 },
- { -6, 18,-22, 22, 5, 11, -1, 6, 19, 22, 8, 4, -8, 20, -2, 15,
- -6,-18, 0,-33, -9,-12, -1, 6, 5, 2, 5, 5, -5,-17, -3, -3 },
- { 1, 11,-16, 9,-18, 11, -4, 18, 20, 26,-10, 8, 1,-11, 8, -4,
- 0, 7, 3, 5, 2, 2, 10, -2, -4, 4, -4, -2, 1, -4, -5, -1 },
- {-10, 6, -1, 18,-17, 27, -3, 10, -2, 12, -7, -9, 1, 1, -1, 7,
- -12, -1, -7, -6, -1, 8, 3,-15, 8, 9, 3, -7, 4, -1, 1, -1 },
- {-14, 6,-16, 22, 2, 5, 0, 5,-18, 11, 6, -3, 22,-20, -9, -3,
- 6, -6, -7,-15, 1, 15, -8, 11, 8, -3, -8, 1, -8, 2, 6, -2 },
- {-21, 5,-19, 19, -7, 4, -7, 0, -8, 6, 12, 5, -3,-22,-13, -6,
- -1, -3, -2,-14, 6, -3, 1, -8, -7, -5, -6, 11, -3,-10, -5, 2 },
- { -1, 9,-12, 15, -6, 6,-19, 14, -9, 11, 3, 12,-17, -3, 8, -4,
- -3, -4, 1, -5, 4, 5, -7,-15, -7, 15, -6, -5, 1, -5, -3, 1 },
- {-12, 20,-15, 20,-14, 3,-14, 9, -6, 33,-13, 6, -2, 8, -6, 7,
- -5, -6, -3, -3, 0, 8, -3, -3, 1, -2, 2, 2, 6, -5, -5, -2 },
- { -7, 12,-18, 12,-18, 10, -4, 8, 2, 4, 8, 9, 0, 3, -8, 3,
- 6,-12, -4, 1, 25, -5, -9, 6, -7, 0, -9, -7, 3, -5, -4, -4 },
- {-18, 12,-10, 11,-22, 0,-15, 5, -2, 2, -3, 6, -4, -4, -3,-15,
- -2, -3, 21, 6,-12,-11, 19, 3, 3,-14, 7, 0,-11,-22,-10, 0 },
- {-15, 2,-30, 15,-17, 13,-16, 8, -7, 10, -8, 2, 11, 3, 10, -7,
- 7,-22, 12,-10, 3,-12, 6,-10, 12,-10, 7, -8, 5, 2, 9, 1 },
- { -9, 11,-14, 6,-10, 21, 5, 12, -5, 5, 7, 21, 6, 2, -2, -1,
- -1, 4, 2,-20,-18, -1,-14, 3, -1, 4, -7, 10, 1, 11, 4, -4 },
- {-22, 8,-30, 13,-21, -4, 4, -1, 12, 9, -2, -3, 2, -6, 4,-13,
- -2, 8, 8, 1, -7, 3, -4, -5, -1, -7, -2, 8, 8, 7, 8, 0 },
- { -6, -4,-35, 16,-13, 15,-11, 14, -7, 9, -1, 11, 7, 0, 13, 10,
- -1, 8, 1, 1, -2, 8, -1, 2, 2, 3,-10, -1, 7,-13, -3, -7 },
- {-15, 7,-16, 14,-18, 17, -6, 14, 3, 4, 7, -3, 10,-22, 5,-15,
- 4, -4,-11, 15,-15, 11,-11, 20, 1, 0, 2, 1, 11, -3, 11, -7 },
- {-12, 3, 5, 16,-37, -1, 15, 15,-15, 10, 3,-10, 1, 15, 7,-15,
- -13, 8, 9, -3, 2, 12, -8, 2, -5, 0, -3, 4, 5, -9, -4, 5 },
- {-16, 26, -4, 14,-22, 26, 6, -3, -8, 4, 21, 6, 16, -4,-11, 7,
- -10, 3, 3, 7, -4, 2, -9, 8, -2, 2, 5, -2, -4, -2, 7, -1 },
- { -7,-10, 4, 3, 2, -4,-12,-10, -4, -5, 16, 19,-16, 1, 2, -9,
- -10, 0, 9, 7, -8, 3, 12, 8, -6,-11,-13, -1, -3,-20, 6, -5 },
- {-14,-17, 3, -5, 14,-12,-12, 8, -6,-25, 21, 21, 10, -8,-12, 4,
- 10, -4, 3, -9, 11, 9, 0, 4, 2,-15, 1,-14, 4, 1, 0, -4 },
- { -4, -9, -3, -1, 6, 3, -6, 6,-10, -4, 14, 8, 2, -3,-12,-19,
- 0, 11,-20, 1, 6, -2,-27, -6, 10,-17,-14,-17, -9, 8, -8, 3 },
- {-12,-13, 16, -4, -2, 12, -7,-11, 2,-13, 3, 7,-16,-18, -1,-12,
- -2, 1,-12, -9, -2, -6, 2, 9,-22, -3, -4,-14, -7, 7, -1, 2 },
- { -7, -8, -8, 15, 15, 18, 15, 16, -4,-37, 11, 15,-12, -1, -3, 3,
- 6, 6, 0, -5, -3, -5, 9, 1, 1,-11, -1, -8, -6, 2, 3, 0 },
- { -6, 7, -5,-12, 13, 10,-18, -4, -3,-21, 6, 16,-15, -7,-12, -9,
- 1,-12, -1, 10, -2, -1, -3, 4, -4, 1,-16, -1, 12, -9, 5, 9 },
- {-14, -5, 9, 3, 4, 26,-28, 3, -6,-24, 4, 5, 3, 13, 5, -1,
- 3, -1, 3, 1, 1, -5, 3, 0, -7, -8, -7, -3, 3, -5, 4, 0 },
- { -4, 2,-10, -6, 25, 26, -6, 10, -6, -8, 15, 11, -6, -3, 2, -7,
- 5, 14, 9, -1, 0,-12, 4, -4,-10, 1, -3, 3, -2, -2, -6, -1 },
- {-10, 8,-15,-10, 19, 17, -8, 0, -3, -7, 7, 5,-13, -1, 7, -7,
- 1, 13,-12,-13, 17,-12, 1, 26,-18, -3, -5, -6, 4, 5, 8, 1 },
- { 2, -5, 3, 0, 0, 0, 2, -3, -2, -5, 7, 13, -4, 9, 0, -5,
- 4, -1,-11, -8, -4, 0,-13, 2,-47,-23, -8,-11, -4, 4, -2, -3 },
- {-18, -4, 4, 5, -1, 17,-12, -8, 1,-12, 7, 20,-12, 3, -2,-11,
- 16, 12, -6, 1,-13,-16, -6, -3, -3, -5, 4,-12, -5, -9, 10, 1 },
- {-11, 0, 4, 7, 7, 8, 3, -1, 3,-19, 32, 8,-19, -8, 2, 4,
- -12, 15,-16, 3, 1, 9, -2, 1, -2, 8, 5, 6, -4, -1, 11, -8 },
- { 3, -1, 4, -2, 14, 32, -9,-23,-10,-12, 22, 15, -1, -2, 10, 0,
- 4, 6, -8, 4,-15, -2, -1, -4, 0, -8, 4, 1, -8, 3, 4, 1 },
- {-17,-12, 6, -8, 16, 13,-20, -8, -1,-16, 10, 21,-19, 11, -9, -5,
- 7, 18, -6, 7, -7,-18, 13, 2, -2, 8,-12, -9, 2, 4, -5, 16 },
- { 4, 0, 17,-11, 12, 7,-12, 5, -1,-25, 30, -8, -7, -6, -4, -7,
- 9, 8, 7, 3, 3,-16, 8, 0, -2, -2,-18, -3, -4, -5, 1, 4 },
- { -3, -6, 6,-16, 17, 6, -3, 2, -9,-17, 12, 11, 11, 2,-20, 8,
- 1, 1, 0, 2, -2, -6,-21,-13, -9,-15, -1, -8, -6, -8, 0, -2 },
- {-11, -7, 6, -9, 3, 6, 8, 16, 4, -5, 23, 26,-10, -3, 4, 0,
- 2, 2, -4, 4, -2,-12, 12, 10,-11, 0,-10,-16, 3, 0, 0,-10 },
- { -5,-16, 10, -6, 27, 13, -3, 4, -2,-13, 15, 5, 2, 5, 3, -4,
- 13, 12,-11, -7, 0, 1, 11, 12, 2, 13,-15, -8, 9, -2, 3, 8 },
- { -5, -8, 4, 3, 9, 3,-11, 10, 14,-25, 14, 8, -2, 5,-12,-21,
- 2, 10, -7, 2, -3, 2, 0, 2, -1, -3, -5, -6, -1,-16, 2, 8 },
- { -1, 5, 1,-11, 5, 9, -7, 8,-13,-12, 4, 12, -4, 1, -1, -1,
- 27, 29, 10, 15, 2, -6, -3, 4,-21, 10, -9,-11, -6, -1, -9, -3 },
- { -6, -3, -1, -6, 11, -5, 0, -2, -5,-31, 11, 3, -1, 5, -3, 4,
- 5, 7,-10, 5,-10,-13, 4, 12,-15, -2, 2, -7, 1, -9, -3,-10 },
- { -3, -7, 17, -8, -5, 36, 8, -7, -8,-20, 12, 8, 1, -1, 3, 0,
- 1, 4,-10, 3, 1, 4, -2, -3, -2, -3,-10, 4, -1, -7, 3, 2 },
- {-13, -3, -5, 9, 22, 6,-23, 3,-10, -7, 17, 17, 18,-14, -8, -8,
- 2, 4, -8, 2, -3, -8, 6, 4, -1, 7, 0, 0, -3, 0,-12, -3 },
- { -3,-10,-15, -3, 9, 3,-23, -9,-13,-18, 12, 13, -2, 0, 1, 8,
- -1, 2, -7,-12, -5, 14, 2, 1,-22, 6,-10, -8, -9, 28, -7,-14 },
- { -3, 1, 2, -1, 13, 7, -2, -7, 1, -3, 6, 9, -3, -2, 4, -2,
- 2, 1,-10, -2, -2,-22, -2, -7,-10, -5,-11,-27,-12,-16, 4, -7 },
- { 2, -6, -3, 1, 8, 0, -2, 12, -3, -4, 58, 15,-10, -4, -2, 2,
- -2, 0, -2, -6, 2, 4, -1, 1, -4, 1, -1, -5, -4, -3, 3, 1 },
- { 10, -1, 0, 5, 21, 7,-14, 6, -3,-16, 15, 17,-16, 13, 3, -6,
- -4, 6,-12, -5, 1, -4, -7, -8, 2, 3, -6, 6, -1, -8, 5, 4 },
- { -6, -2, -8,-11, 15, 10, 0, 8, -6,-15, 33, 8, -2, 18,-15,-11,
- 5, -1, 0, 15,-15, -4, -4, -1, 10, 7,-13, 4, -4, 0, 8, 3 },
- { -7, -2, 0, -2, 0, -2, -4, -5,-14,-16, 12, 38, 7, 12, 6, -4,
- 0, -1, 0, 3, -2, -6, 0, 2, -9, 1, 0, -1, 0, -2, 4, 1 },
- { -8, -4, 18, 1, 14, 5,-12, -3, 20,-17, 5, 19,-11, -8, 11, -3,
- 3, 9, -7, -8, 9,-17, 2, 15,-10,-11, 5, -5, 7, 15, -6, -2 },
- { -7, 2, 38, 5, 19, 16, -5, 4,-13,-20, 0, 4, -4, 6, 4, 2,
- -7, 6, -8, -2, -5, -7, 6, 3, -4, -3, -2, -3, 7, -6, -4, 0 },
- {-11,-12, 8,-15, -3, 14, -7,-22,-11, 2, 22, 14,-19, 2,-19, -6,
- 1, 3,-18, 14, 2, -6, -2, -8, -3, -6, 5, -7, -8, -4, 1, 1 },
- { 8, 7, 25,-21, 12, -6, -5, -4,-10, 6, 0, 10, 1,-12, 18, -5,
- -15, 4, 1, 14, -1, 5, 8, -7, 1, -7, -3, 9, 10, 1, -1, 0 },
- { 9, 10, 32,-15, 8, 2, 11, -7,-18, -8, 2, -6, -9,-16, -3, 3,
- -1, 3, 1, -5, 4, -2, 1, -8, 0, -6, -3,-11, 1, 5, 0, 0 },
- { 14, 0, 23,-25, 22, 3, 7, 10, 0, -2, 7, 8, 0, 10, 0, 0,
- 3, 2, 3,-10, 0, 10, 0, -7, 0, 10, -1, -5, -7, 1, -1, 2 },
- { 12, 0, 25,-18, -5, -4, 13,-10, 3, -6, 7, 21, 0,-16, 3,-10,
- -6, 5, -7, -3, 2, 5, 3, -6, 4, 9, -8, 12, -2, 3, 2, 4 },
- { 31, 15, 27,-20, 10, -7, 15,-10, 9, -8, 4, -5, 3, -3, 5, 6,
- 11, -2,-12, -2, 6, -2, 1, 2, -1, -1, 1, 1, 3, 1, 1, 2 },
- { 12, -4, 13,-23, 12, -6, 2, 4, -3, 13, 6, -7, 5,-19, -7, 18,
- 1, -7, 7, 1, 16, -7, 3, 0, 3, 0,-12, 8,-11, 9, 4, 7 },
- { 29, 1, 3,-22, -5, 6, 0, 12,-14, 11, 1, 6, -3, 4, 6, -2,
- 4,-13, 12, 1, 1, 3,-11, 9,-10, -1, -7, 16,-11, -1, 3, 9 },
- { 4, 4, 36,-23, -5, -8,-15, 1, -6, 3, 13, -1, -5, -7, 4, 9,
- 2,-11, -3, 5, 1, 3, -6, -1, -4, -4, -2, 2, 3, -1, -5, -2 },
- { 19, 10, 6,-17, 2, -4, -2, -4, -3, 13, 2, 2,-13, -7, -3,-11,
- 9, -6, 1, -9, -5, 4, -5, -9,-18, -7,-11, 9, 4,-11, 8, 4 },
- { 16, -3, 9,-16, 18, -2,-12,-16,-11, 11,-18, 16,-13, 6, 2, 8,
- 3, 8, -4,-16, 10,-11, -1, -3, -8, 5, -9, -4, 9, -4, 0, -3 },
- { 14, 15, 3,-23, -5, 7, -8, -6, 2, 17, 2, 12, -8,-12, 13, -1,
- -9, 3, 1, 1, 19, 15, 4, -1, 1, 2, -3, 2, -3, 1, 5, 3 },
- { 32, 5,-10,-47, -5, -1, 4, 11, -7, 0, 2, -2, 1, -7, 6, -4,
- 6, 2, -4, -2, 2, -2, 0, -4, 1, -6, -5, 2, -2, -1, -3, -4 },
- { 20, 8, 10,-21, -7, -9,-16, 12, 1, 4, 6, -5, 9,-11, -7, 4,
- -11, 28, -3, 2, 4, -6, 10, -8, -5, -5, -9, 9, -2, -1, 6, -5 },
- { 38, 3, 23,-25, -6,-18, 3,-10, -8, 6,-10, 1,-10, 2, 2, 0,
- -7, 2, -4, 5, -1, 8, -3, 0, 3, 3, -1, 1, 0, -4, -4, 0 },
- { 20, 5, 16,-22, 24,-18, 2,-12,-14, -7, -3, 10, 2, 7,-10, 2,
- -8, 1, 8, -1, 4, 1, 4, -2, 5, -9,-18, -8,-13, 5,-11, 10 },
- { 14, 8,-12,-16, 9,-11, -3, -6,-25, -7, 6, 5, -7,-16, 10, 2,
- -7, -1, -9, -3, 16, 4, 3, 3, -3, -3,-15, 13, -3, 4, 13, -7 },
- { 16, -9, 19,-23, 7,-19, -3, -5,-15, 11,-21, 21,-16, 18, -1, 6,
- 10,-10, 18,-14, 16,-15, 6, -5, -9, 5,-17, 13,-10, 13, 0, 10 },
- { 8, -4, 4,-24, 8,-21,-18, 9,-11, 4, -6, 17, 5, -9, -2, -2,
- 2, 15, -2, -3, -2, 1, 7,-13, 15,-10, -8,-11, 3, 3, -1, -1 },
- { 14, 17, 6,-32, 5,-17, -2, 0, 15, -1, -5, 16, 1, -5, -2, 9,
- -3, 8, 4, -2, -2, -4, -3, 1, 0, 7, -3, 4, -5, 0, -7, 2 },
- { 24, 6, 22,-12, 8, 3,-14, 4, -7, 8, 6, 5, 6, 1, 6,-12,
- 15, 10, 4, 11, 9, 6, -7, -4, 10, -9, 2, -1, -5, 11, 15, 3 },
- { 17, 12, 3,-23, 5, -1, -2, 1, -9, -1, -3, 1, 8, 1, -5, 17,
- 11, 0, -2,-11, 7, 4, 0,-27, -7, 1, 2, -8, 9, 7, 5, 3 },
- { 12, 10, 12,-10, -4, 5, -1, 2,-24, 5, -8, 2, 6,-17, 19, 5,
- 12, -2, 16, -7, -6,-14, 4, 1, -3, 13,-16, 5, -1, 4, 1, 1 },
- { 31, 9, 11,-17, 10, -3, -7, 7, 1, 2, 2, 4, -3, -1, 11, 4,
- -5, -8, 1, 4, 15, -6,-28, 1, 8, 3, -6, 5, 17, -2, 2, -4 },
- { 11, 19, 16,-26, 0, -7, -7, 2,-13,-15,-12, 9, -3, 27, 8, 4,
- -6, 1, 4, -6, 11, -1, -6, -7, -3, 0, -6, 4, -6, -7, -3, -1 },
- { 10, 18, 16,-32, 19, -9, -4, -3, -7, 8, 8, -3,-11, -2, -6,-16,
- 13, 13, -6, -1, 10, -2, -2, -9, 0, -3, 9, 4, 11, -2, -6, 6 },
- { 9, 4, 19,-33, 4, 7,-12, 36, -3, -1, 8, -2, 2, -8, -9, -4,
- -8, 0, 1, -1, 0, -4, -4, 3, 0, 3, 6, 0, -6, 2, 0, -2 },
- { 25, 7, 15,-12, 2,-24, -1, 24, -4, 4, 9, 0, -2, -9, 4, 6,
- 3, 13, -3, 1, 5, -1, -3, -5, -1, 7, -2, 3, 4, 4, 1, 0 },
- { 19, 6, 8,-20, 9, -9, 5, -4,-13, 7, 11, -3, 5,-13, -9, 6,
- -11, -1, 0, 4, 11, 26, 3, 6, -7, 12, 6, -3, 1, -9, 7, 1 },
- { 15, 6, 19,-23, -3, -9, 3, 16, -6, -4, 6, -5,-10, 1, 16,-14,
- 2, 0, 2,-13, -3, 8, -6, 3, 1, 1, 2, -5, 12, -4, -8, -3 },
- { 14, 4, 16,-20, 1, 12, 0, 6, -3, 9, 4, 16, 10,-16, 5, 7,
- 5, -4, -4,-18, -3,-11, -4, 4, -7, 3, 13, 7, 3, 3, 2, -7 },
- { 22, 3, -1,-30, 18, -3, -9, 9, -2, 11,-16, -2,-14, 12, 0, 4,
- -5, 4, -1, 3,-20, 12, 4,-10, -2, -2,-12,-12, 10, 6, 11, -3 },
- { 15, 7, 2,-21, 5, 4, 9, -9,-33, 7, 7, 3, -6,-14, -8, 10,
- 12, 0, 2, -1, 5, 4, -2, 0, -7, 0, 2, 4, 0, 1, -3, 8 },
- { -7, 0, 12, 3, 0, -6, 8, -4, 0, 2, 14,-15, 2, -7,-31, -3,
- 14, 0, 14,-15, -1, -4,-15, 10, 1, -3, 1, 2, 5, 2, -8, 1 },
- { -2, 5, 1, 0, -3, 3, 3, -6, -1, 2, -4, 1,-19, 0,-11, 18,
- 11, 10, 21, 5, 6, 2, 10, 3, -6, 0, -2, 13, 5, -1, -2, 9 },
- { -9, 1, -5, 0, 0,-15, 8, 4, 8, 3, 8, 12,-13, -2,-39, -2,
- 4, -4, 5, -3, -4, 3, -3, 3, 10, 5, 3, 2, -3, 5, -2, 8 },
- { -9, 6, 6, -8, 12,-12, 23,-18, 4,-15, -5, 2,-20, 13, -7, 7,
- 7,-12, 14,-12, 6, 1, 1, -3, -8, 9, 0, 1, -7, 3, 7, -6 },
- {-18, 13, 4, 3,-10,-30,-10, -6,-14, 1, -7, -4,-35, 5,-25, 11,
- 9, 8, 19, -4, -7, -3,-18, -8, 1, 5, 10, -4,-14, -9, 3, -4 },
- { -6, -1, 4, -9, -9, 4, 20, 0, 0, 3, 11, 7,-16,-17,-20, 11,
- -6,-14, 1, 4, 19, 2, -8, 6,-15, 3, 6, -5,-14, 3, 7, 2 },
- { 1, 6, -2, -8, -5, -3, 3, -8, 21, 1, 3, 16,-14, -2, -9, -4,
- 13, -2, 18, 14, 14, 19,-13, 5,-10, 2, -3, 3, 5, 5, 1, -1 },
- { -1, -5, -6, -2,-11, -7, 5, -4, 5, -1, 0, 3, -3, 2,-19, 18,
- 16, 4, 14,-22, -2,-11,-22, 1, -1, 11, 1, 2, 11,-10, 7,-12 },
- { 1, 4, 5, -1, -9, -5, 1, 12, 5, 6, 12, 9,-24, 23, 1, 20,
- 14,-11, 13, 5, -2, -2, 5, 6, 2, 1, -9, 6, 10, 5, -4, 11 },
- { -1, -1, 1, 7, -3, -4, 8,-16, 15, -1, -7, 9,-22,-11,-11, 10,
- 16, 9, -2, 4, 13, 10, 6, 16, 4, 7, 1, -8, -7,-14, -7, 4 },
- { 1, 3, -6, 0, 15, -9, -4, 0, 4, 6, 12, 9, -6, -5,-22, 17,
- 7,-11, 15, -5, 1, 3,-19, 0,-15, -3, 16, 5, 5, -7,-11, 12 },
- { -2, -1, 13, 2, 4,-24, 37, -5, -2, -6, 12, 7, -2,-23, -4, 9,
- 2, -3, 3, 2, 3, 3,-14, 11, 0, -4, -2, -2, 3, 10,-10, 4 },
- { 2, 9, 8, -6,-28, 14, 28,-11, 18,-11, 0, 2, -2, 4,-12, 3,
- 6, 0, 7, -7, -6, 2, 5, -1, -1, -1, 5, 2, 3, 0, -3, 9 },
- { -7, 14, 5,-10, -3, 7, 4, -5, 7, -8, -7, 4,-12, 14,-16, 25,
- 3, 0, 1, -5, 12,-10, 0,-10, 0, 12, 12, 17, 12, 10, -1, 0 },
- { -4, -2, 5, -2,-17, -3, 5, -5, 7,-17, 1, 5, -4, 4,-20, 0,
- 11,-15, 13, -8, 10, 1, 1, 5,-12, 9, -8, 0, 6, -1,-11, 4 },
- { -3, 12, 13,-15, -7, -7, 0, 5, 33, 3, 3, -6,-13, -7,-15, 10,
- 3, 3, 3, -5, 2, 7, -1, 0,-12, 2, 11, -6, -9, 0, 5, 11 },
- { -8, 5, 10, -7,-14, -4, 13, 0, 18, -3, -6, 7, 1, -6, 0, 21,
- 8, -7, 10, -8, -3, 17, -9, 0, -5, 1, 4, 8, -3, 11, -5, 0 },
- { -8, 8, -3, -8, 8,-11, 16,-16, 17, 0, 8, 16,-17, 10,-16, 10,
- -8, 6, 11, 0, 10, 7, 4, 5, 7, -5, -5, -6, -7, -5, -1, 16 },
- { -6, 0, 6, 1, -8, -8, 8, -7, -5,-10,-11, 8,-19, 6, -7, 13,
- 5, -3, 4, -8, 7, -1,-18, 9, 0, -5, 6, 26, 3, 8, 2, 4 },
- { -2, -2, 23, -2,-20, 2, 7, -7, -6,-15, 3, 9,-19, -2,-10, 7,
- -2, 7, 9, 11, 0, 4, -4, 6, 9, -2, 4, -3, 4, 3, 2, 8 },
- { -6, 12, 10,-10, -7, 4, 17, 11, -6, 1, 12, 11,-18, 8,-12, 4,
- 1, 13, 6,-13, 23, 9, -5, 8, -2, -5, 1, 3, 0, -2, -4, 4 },
- { 7, 1, 7,-17, -8, 8, -1, -7, 5, -6, 4, -3,-16, 9,-24, 18,
- -3, 10, 13,-11, -6,-11, -4, 10, 0, 11, 8, 2, 6, -5,-11, 4 },
- { -4, 1, -5,-10, 0, -3, 9, -2, 4, -1, 1, 5,-41,-10, -7, 4,
- -3, 3, 1, 0,-12, 4, -3, 0, 2, -1, -2, -5, 3, 2, -7, 5 },
- { -2, 1, 4, 4, -3, -6, 1, 0, 12, -5, 11, 0,-17, -3, -1, 11,
- 4, 1, 27,-12, 0,-14, 2,-15, -3, -9, 0, -7, -3, 15, -8, 6 },
- { -6, 4, 9, 2, 4, 3, 7,-10, 28, 1, -2, 48, 7, 0,-10, 10,
- 1, -9, 2, -1, 0, 3, -5, 5, -4, -2, 7, 7, 1, 3, 2, 5 },
- { -3, 3, -1, 3, -9, 0, -1, 3, 2, -6, 39,-14,-12, 5,-19, 21,
- 7, -6, 4, -1, -4, 0, -4, 1, 0, -9, 1, 10, 0, -2, 0, 7 },
- { 4, 2,-29, 12, 5, -3, 16, -6, 15,-13, -4, -1,-13, 22,-16, 17,
- 16, 4, 9, -4, 4, -6, -4, 11, -8, 7, 8, 4, 3, -3, -7,-13 },
- { 0, 3, 3, -6, -4, 0, 9, 0, 5, 0, 10, 10, 4,-13,-12, 16,
- 23, -4,-12, -6, -4, 20, 2, 0, -4, 23, 1, 8, 11, -4, -5, 15 },
- { -6, 4,-15, -9, -1,-19, 12,-30,-17, -4, 1,-13,-13, 4, -3, 26,
- 5,-25, 11,-14, -6,-13, 0, -7, 9, 2, 8, -1, -8, 1, -8, 13 },
- { 1, 6, 1, -4, -4, 1, 2, 0, -3, 2, 10, 6, -6, -2,-11, 4,
- 32, 15, 15,-47, -8, 3,-12, 4, -5, 4, -1, 0, -5, 5, 1, -7 },
- { 2, -1, 0, 0, -1, -6, 0, -6, 4, -4, 5, 9, -5, 1, -3, 51,
- 4, -5, 4,-14, -1, -4, -3, 1, -4, -1, 0, 2, -8, 0, 1, 2 },
- { 0, 4, -2, -7, -2, -9, 6, -8, 11, -3, -6, 3,-11, -8,-12, 8,
- 11, 5, 19, 3,-24, 19,-14, 11, -5,-18, -8,-12, -5, -4, -1, 4 },
- { 16, 9, 10, 14,-18, -2,-18,-27, 10, -5, 12, 14, 4, 0, -2, -6,
- -12, -7, -1, 3, 4, 7, 11, 10, 5, -5, -7,-16, -3, -6, 6, 9 },
- { 7, 15, -9, 10,-19, 4, -5,-37, -2, -4, 8, 2, 4, -1, 1, 9,
- -5, -5,-12, 1, -1, -8, 3, -3, 4, 6, 9, 3, 3, -1, 2, 4 },
- { 13, 17, 3, 9, -7, -7,-15,-17, -8,-13, -4, -8, 19, 2, 16, 25,
- 7, 15, 2, 16, -5, -6,-10, -9, -7, -6, -2, -7, 7, 2, 4, 5 },
- { 24, 7, 9, 8,-13, -2, 0, -4, 1,-13, 3, 6, 7, 10, -4, 15,
- 5, 7, -4, 5, -5, 3, 13, -7, 5, 15,-11, -2, 7, 5, 8, 6 },
- { 17, 6,-15, 23, -2, -1, -6, -2, 0, -4, 11, -3, 12, 15, 6, -8,
- -15, 10, -9, 7, -1,-11, 2, -8, -4, 3, 4,-10, 4, 4, 11, 1 },
- { 21, 12, -3, 6, -8, 8,-11, -8, -5, -5, 3, 7, -1, -5, 12, 15,
- -10,-11, 3, 15, 8, 4, 2,-15, 0, 14, 1, -8, -1, 3, 10, -7 },
- { 16, 12, 5, 13, -6, 15,-23, 0,-17, -9, 0, 4, -9, 13, 6, 18,
- 0, 0, -4, -1, 0, 14, 5, -1, 8, -4, -8, -6, 5, -2, -2, 0 },
- { 14, 16, -1, 12,-15, -9, -6,-20, 4, 6, 8, 9, 3, 1, -9, -4,
- -1,-11, 9, 11,-12, 1,-14, -7, 2, -8, 11, 9, -4, 10, 4,-16 },
- { 13, 10, 3, 7, 0, -8,-33, -6, 4, -4, 19, -2, 14, 6, 5, 7,
- 6, -3, -1,-10,-10, -9, 4, -3, 5, 9, 2, 2, 10, 9, -2, -3 },
- { 11, 10, 25, 18, -1, -6,-21,-21,-11,-16, 6, 5, 14, 4, 8, 7,
- 0,-10, -7, -9, -5, -4, 3, -1, 1, 6, -1, 6, -2, 2, -3, -9 },
- { 15, 9, 5, 22,-17, 15, -9, 7, 7, -9, 13, 9, 10, -1, 8, -3,
- -2, 6, 1, 17, 8,-14, 7, -3, 12, 9, 1, 0, 1, -5, 17,-18 },
- { 25, 19,-17, 12, -4,-10, 1,-13,-19, -7, -3, 9, 6, -2, 3, 1,
- 4, -2,-11,-14, -1, -7, -5, -9, 7, -1, -3, 4, -5, 1, 0, -1 },
- { 20, 8, -3,-10,-24, 3, -6, -2, 0,-12, 14, 6, 7, 11, 4, 7,
- -12, -5, -8,-10, 5, -1, -4, 4, 16, 7,-14, 6, -1, -2, -7,-11 },
- { 16, 18, 17, 1,-15, -6, -5, -3, -1,-19, 8, -2, 2, 8, 12,-19,
- -12, 8, 0, -3, -1, -1, 4,-14, 9, -1,-12, -1, -7, 10, -3, 5 },
- { 18, 12, -7, 7, 0, -3,-13, 0, -1, -4, 9, -2, 6, -1, 0, 1,
- 15,-21, 1, -8, 25,-19, 13, -9, 2, 12, 5, -7, -3, -1, -3, 1 },
- { 13, 16, -4, 9, -2, 2, -1,-19, -7, -4, 18, -6, 14, 18, -5, 4,
- -6, -3,-19,-14, -1,-12, 10, 6, 7, 17,-12,-13,-10, -4, 5, 4 },
- { 27, 17, 4, 14, -9, -2, -4, -8, 0, -6, 14,-11, -7, 2, -3, -3,
- -2, -3,-13, 12, 16, 1, -5, -9,-10,-11, -2, 3, -7, 5, 11, -7 },
- { 7, 17,-16, -2,-14,-28, -7, -8, 15,-10, 7, 15, 8, 17, 13, -1,
- 4, -7,-12,-11, 0, 0, 2, 3, -3, 7, -6, 6, 1,-16, 1, -2 },
- { 23, 11, -9, 15,-23, -4, -6, -4, 2, -9, -7, 9, -8, 3,-13, -4,
- 8, 18, -6, -2, 1, -5, 6,-14, -5, -2, -6, -5, -3, -2, 4, -5 },
- { 12, 13, 18, 18,-35, 2, 7,-17, 3,-11, 6, 9, -3, -2, 10, -4,
- 3, 3, -2, -7, 0, 2, -4, 0, -4, 0, -6, 5, 10, 4, -3, -1 },
- { 19, 11, 1, 20,-14, 4, -9,-13, -2, 11, 0, 17, -1, -1, -1, -1,
- -5, -8, 0, 5, -1, -8, 5, -1, 3, 2,-12, 21, -2,-24, 5, 7 },
- { 15, 15,-15, 17,-14,-22, 3, -4,-11, -3, -7, 1, 18, 10, 1, 10,
- -6, -3, 8, 2, -7, 0, -2, 1, 1, 2, -9, -2, 1, 2, -3, 4 },
- { 45, 13, 8, 17, -5, 2,-16, 2, 8, -2, 8,-15, 4, 5, -1, 7,
- -6, -2, -6, 2, -3, 0, 0, -9, -1, 7, 2, 3, -3, -3, -1, 5 },
- { 1, 18, -8, 18,-12,-10, 3, 4,-22,-12, 20, 8, -3, 9, 2, 10,
- -10, -3, 9, 3, 6, -3, 10, -1, -3, 2, -2, 4, 2, 3, -3,-18 },
- { 9, 10, -5, 9,-35,-21,-18,-16, -1,-12, -6, -7,-15,-19, 12, 4,
- 4, 9, -7, 2, 14, 1, 4, 0, -1, 6, -7, 2, 1, 1, -4, 4 },
- { 31, 8,-17, 35, -8, 1, -5, -6, -7, -6, 10, -2, -3, 6, 9, 3,
- -6, -2, 3, 3, 5, -3, 0, 6, 0, 1, -5, -3, -2, -4, -1, 0 },
- { 18, 4, -8, 7, -8,-15, -1,-16, 12, 18, 3, 19, 2, 4, 8, 8,
- 0, -5, -8,-12, 10, -5, 0, 1, 0, 4, -3, 16, 11, 11, -2, -6 },
- { 27, 15,-17,-10,-23,-22, -1,-14, -4, -7, 20, -2, -7, 6, 15, -5,
- 32, 4, 9,-11, -3, -8, 11, -4, -1, -4, -8, -6, -4, -5, -2, -7 },
- { 22, 4, -7, 2,-15,-11,-17,-10, 2, 0, 15, 11, 7, 12, -8, 6,
- -10,-18, -6,-12, 7, 3, 22, 3, -7, 14, -5, -2,-13, -7, -1, -7 },
- { 18, 13, 9, 24, -4,-19, -9,-11, 13, 8, 2, 4, -1, 8, 14, 10,
- -12, 0, 0, 5, 10, 5, 4, -1, 5, 1, -1, 11, 2, -4, 0, -9 },
- { 15, 19, -5, 1, -4,-10, -8,-27, 6, 8, 5, 10, 4, 11, 5, -5,
- -11, 0,-11,-14, -4, -9, -8, -8, 6, -9, 4, -5, -1, 1, 5, -4 },
- { 18, 1,-13, 14,-14, 9,-15, -7, 12, 1, 13, -4,-20, 12, 10, 12,
- -12, 7, 1,-13, 10, -6, 5, -3, 4, 8, 10,-13, -3, -6, 9, -3 },
- { 19,-14, 5, -8, -6, 2, -5, 5, -3, -1,-28, 11, 18, -6, -4, -2,
- 11, 14,-43,-42, 9, 2, 20,-23, 6, 32, 0, 5, 0, 6, 9, 5 },
- { 8, 11,-14, -1, 7, 12, -7, 2,-16, 2, 10, -3, -1, -7, -7, -1,
- 1,-10,-60,-23,-18, 42,-13, 9, 18,-11, 0, 1, 0, 2, -5, 1 },
- { -5, -1, 2, 0, 3, -3, 3, -2, -6, 0, -3, -3, 7, 2, 0, -2,
- -2, 3,-34,-15, 37, 47, 10, 20, 9, 1, 3,-21,-25,-33,-14, 8 },
- { 5, 6, 2, -2, -2, -2, 6, 5, -5, 7, -3, 1, -5,-13, 9, 3,
- -17,-19, -2,-79,-12, -7, -8, -6, -2, -2, -1, -1, -7,-13, 6, -1 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1,
- 0, 3, 4,-87, 6,-11, 16, -9, -1, 8, 0, 5, 0, 1, 2, 1 },
- { -5, 6, 2,-24, 5, -9, -7, 0, 7, 3, -3, 16,-14,-16, 0, 18,
- 15, -9,-14,-28,-17, 53, 14, -6,-28, -1, -3,-10, -7,-14, 19,-15 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -3, 0,
- -13, 0,-53, 3,-22, 63, 19, 16, 1,-11, 0, -3, 0, -3, 0, 1 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1,
- -1, -6,-43,-43, -2, 65,-13, -4, 9, 1, 1, 2, 1, 0, 0, 1 },
- { 0, 1, 0, 0, -1, 0, 1, 1, 0, 0, 1, 2, -1, -1, -3, -1,
- -23, 1,-61,-55, 3,-28, -6, -4, -4, 8, 2, 1, 1, -1, 0, 0 },
- { 0, 1, -1, 1, -1, 0, -1, 0, 1, -1, 0, 1, -1, 0, -9, -4,
- -48,-19,-52,-46, 11,-12, 5,-14, 0,-10, 0, 0, -1, -2, -1, 0 },
- { 0, -3, -1, -4, 2, -1, -7, 3, 1, 3, -1, 1, -3, 0, -7, 0,
- 3, -7,-61,-51, -4,-21,-16,-21,-11, 14, -7, 8, 3, -5, 1, 2 },
- { 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, -1, 9, -3,
- 56,-11, -6,-67, -1, 13, 0, 7, 1, -9, -1, -1, 0, 0, 1, 0 },
- { 14, 9, -2, 14,-10,-10, 9, -5, 1, -8,-23, 30, 8, -7, 23, 8,
- 2, 10, -1,-27,-17, 57, 22, 4, -5, 2,-12, -6, 2, -7, -4, -9 },
- { 1, 5, 12, -2, -2, -3, 2, -3, 6, 0, 4, -2, -8, -6, 0, 16,
- -15, 29,-55,-29,-24, 29, 3, 10, 6, 13, 10, -5, 21, 11,-14, 5 },
- { 4, 2, 26, -6, 10, 11,-23,-10,-27,-20, 3,-24,-11,-10,-13, 25,
- -10, 5, -9,-36, -7, 43, 3,-13, 6, 13, -2, 0, 1, 3, -3, -4 },
- { -1, 0, -1, 0, 0, 0, 0, -1, 1, 0, -1, 0, 0, 0, -1, 1,
- -12, 12,-26,-64,-15, 29, 37, -7, -3,-12, -5, 14, 8, -8,-10, -2 },
- { 19, -4,-11,-16, 8, 14, 5, 19, 3, 22,-11,-21, -1, -6,-11, 11,
- 10,-24,-23,-40, -8, 20, 17, 5, 13, -6, 3, 14,-20, -8, 3, 28 },
- { 2,-12, 10,-14,-18, 26,-22, 4, -2, 5,-21, 8, 3, 1, 19, 0,
- -12, 24,-14,-40, 15, 29,-15, 6, 15, 1,-19, 2, 4, 7,-12, -3 },
- { 0, 17, 13, 7, -5,-11, 2,-19, 3, 38,-21, -3, -6, -4, 7, 1,
- 1, -5,-40,-10, -2, 35, 8, 8,-10, -8, -9, 33, 4, 4, 0, -2 },
- { -2,-12, 7, 29,-24, 2, 16, -1, -7, 16, 10, -2, -2, -2, 13, -2,
- -37, 15,-22,-40,-11, 33, 10, -1, 8, 10, 6, 8, 9, 0,-12, 2 },
- { 15, -8, -9, -2, 7,-17, 7, 19, 14, 4, 12, 27, 11, 10, 4, 11,
- -15, 14,-13,-48, 5, 18, 0, -9,-36,-11, 2, 4, 5, 5,-15,-12 },
- {-12, 0, 3, 4, 7, -5, 5,-14,-24,-18, -6,-15, -8,-20, 1, -7,
- -33,-28,-40,-38,-18,-10, -5, 17,-12, 4, 3, -5, 5,-13, 4, -7 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1,
- -3, -9,-49,-60, -5, 45, -1, 6, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1,
- -3, -9,-49,-60, -5, 45, -1, 6, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 3, -2, 9,-29,-11, 55, 8, 32,-36,-13, -7, 37, 4, 11, 0, 3 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 4, -1,-39, -4,-30, 63, 28,-17, -6, 10, 7,-14, -9, 11, 9, 7 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1,
- 13, -2,-50,-32, 22, 51, 4, 7, 6, 11,-20,-13, 9, -5, 21, -4 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1,
- -3, -9,-49,-60, -5, 45, -1, 6, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1,
- -3, -9,-49,-60, -5, 45, -1, 6, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 3, -2, 9,-29,-11, 55, 8, 32,-36,-13, -7, 37, 4, 11, 0, 3 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 4, -1,-39, -4,-30, 63, 28,-17, -6, 10, 7,-14, -9, 11, 9, 7 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1,
- 13, -2,-50,-32, 22, 51, 4, 7, 6, 11,-20,-13, 9, -5, 21, -4 },
- { -8, 2, 1, 22,-31, -6,-25, -3, -3, 1,-15,-11, -2, -3, 4,-13,
- -9, 15,-18, 37, -7,-37, 12,-13,-11,-25,-10,-11,-22, 7, 16, 7 },
- { 14, 10, 4,-10, -1, -5, -7, -3, 16, 13, -5,-15, 5, 11, -1, 8,
- -27, 7,-12, 49, 17,-22, 9, -2, -9, -1, 2,-15, -1, 41,-18,-17 },
- { -4, -9,-15, -3, 3, 4, 4, 2, 7, -3, -7, -8, -5, 17,-19, -7,
- 36, -9,-38, 17, 1,-48, 11,-18,-13, -2, -8, 4,-10, -5, 21, 11 },
- { 15,-13, 4, 2, 1, -5, -2, 1,-10, 7, -1, 3, -6, 0, 11,-11,
- 8, 20,-17, 51,-17,-41, 2, 15, 4, 8, -2, 16,-32, -1, 17, 6 },
- { -8, 8,-18, -5, 4, 6, -3, 8, 0, -4, 2, 0, -1, -4, 5, 8,
- 30, 30, -8, 70, 2, 8, 2, 0, 7, 1, 13, -1, -6, -7,-11, 2 },
- { -8, -7, 9,-10,-13, 6,-11,-14, 13, 25,-26, 5, 2, -5, -5, 5,
- -8, 4, 0, 33, 12,-38, -4, 6, 13, 6, 25, 34, -1, 25,-19, -5 },
- { 18, 3,-17, 4, -8, 7, 20, 1, -1, 5, -5, -2, -8, 8,-35, 15,
- 24, 43, -5, 51, 5,-12, -3, 1, -2, 3, -3, -3, -9, 8, -9, 2 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
- 2, 10, 24, 76, -2,-22, 11, -1, 4, 33, 4, 1, -1, 1, 2, 0 },
- { 0, -1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 2, 0,
- 24, 13, 32, 70, 26, 5,-21, -9, -6,-15, 2, -2, 2, 4, 1, 1 },
- { 5, -4,-11, 4, -4, 22, 10, -2, 13,-11, -4,-21,-17, 0, -7, 4,
- 10,-34, 11, 52, 2,-46, -5, 0, 0, -1, 2, 4, -9, 1, 1, -7 },
- { 0, 1, 1, 0, -1, 0, 1, 0, 1, 1, 0, 1, 0, 0, -3, 1,
- -8, 9, -1, 64,-13,-61, -3, 3, -5, 10, 1, 3, -1, -1, -1, -1 },
- { 0, 1, 0, -1, 0, -1, 0, 0, 1, 0, 0, 0, 1, 1, 2, 1,
- 10, -2,-31, 79,-10, 27, 0, -1, 3, 8, 1, 1, 0, -1, 0, -1 },
- { 3, 12, 10, 26,-19, 10, -9, 6, -4,-15, 10, 3,-16, 6, 11,-19,
- 3, 10, 18, 44, 5,-30, 5, -9, 21, 4, 20, 10, 14,-25, 8,-17 },
- { 0, 0, 0, 1, -1, 0, -1, 0, 1, 0, 1, 1, 0, 0, -6, -2,
- 8, -8, 13, 69, 26,-19,-25,-17, 16, 6,-12, 22, 2, -6, 9, 5 },
- { 0, -1, 0, 1, 0, -1, -1, 0, 0, 1, -2, 1, 0, 0, -4, -1,
- -34,-15,-33, 56, 9,-42, 9, 10, 6, 9, -8,-11, 0, -6, 15, 5 },
- { 10, 2,-14, -3,-15,-35, -1, 7,-18, 14, 8, -1,-15,-26, 6,-15,
- -18, 22, 9, 33, 0,-32, -9, 3,-11, 7, 4, -1, 5, 30, 9, 1 },
- { 4, 15, 0, 6, -5,-11, 9, 6, 6, 6, 14, 2, -1, 10,-24,-25,
- -2, -4, -1, 37, 2,-29, 14, -9, 22, 17, -2, 33, 10,-25, 11,-11 },
- { 0, 5, 2, 18,-12, 21, 22, 33, -7, 21, -9, -7, 7,-15, -7, 16,
- 7, 0,-14, 44, 10,-25, 5, -4, 15, -8, 10, -4, 5, 9, -1, 16 },
- { 3, 13, 12, 12, 8, 25,-23, 8,-22, -3,-18, -8, 15, 12, 9, 19,
- 0, 0, -9, 49,-27,-15, -9,-15, 12, -8,-16, -7, 13, 5, 13, 2 },
- { 12, -6, 7, -2, 20, -9,-14, 12, 13, -5,-17, 22, -8, -4, 2, 7,
- -13, -2,-15, 43, -5,-30, 27, 4, 10,-27, 5, 27,-10,-10,-18, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
- -1, 10,-18, 70, -2,-52, -1, -7, 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, 10,-18, 70, -2,-52, -1, -7, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 15,-13,-20, 16, 2, 13, 5,-11, -8, -5, -3, 2, 24,-23, 30, -7,
- 11, 30,-15, 43, 5,-15, 15, -3,-14, 1,-23, 8, 3, 9, 4,-11 },
- { 0, -1, 0, 1, 0, -1, -1, 0, 0, 1, -2, 1, 0, 0, -4, -1,
- -34,-15,-33, 56, 9,-42, 9, 10, 6, 9, -8,-11, 0, -6, 15, 5 },
- { 10, 2,-14, -3,-15,-35, -1, 7,-18, 14, 8, -1,-15,-26, 6,-15,
- -18, 22, 9, 33, 0,-32, -9, 3,-11, 7, 4, -1, 5, 30, 9, 1 },
- { 4, 15, 0, 6, -5,-11, 9, 6, 6, 6, 14, 2, -1, 10,-24,-25,
- -2, -4, -1, 37, 2,-29, 14, -9, 22, 17, -2, 33, 10,-25, 11,-11 },
- { 0, 5, 2, 18,-12, 21, 22, 33, -7, 21, -9, -7, 7,-15, -7, 16,
- 7, 0,-14, 44, 10,-25, 5, -4, 15, -8, 10, -4, 5, 9, -1, 16 },
- { 3, 13, 12, 12, 8, 25,-23, 8,-22, -3,-18, -8, 15, 12, 9, 19,
- 0, 0, -9, 49,-27,-15, -9,-15, 12, -8,-16, -7, 13, 5, 13, 2 },
- { 12, -6, 7, -2, 20, -9,-14, 12, 13, -5,-17, 22, -8, -4, 2, 7,
- -13, -2,-15, 43, -5,-30, 27, 4, 10,-27, 5, 27,-10,-10,-18, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
- -1, 10,-18, 70, -2,-52, -1, -7, 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, 10,-18, 70, -2,-52, -1, -7, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 15,-13,-20, 16, 2, 13, 5,-11, -8, -5, -3, 2, 24,-23, 30, -7,
- 11, 30,-15, 43, 5,-15, 15, -3,-14, 1,-23, 8, 3, 9, 4,-11 },
- { 16,-18, 7, -4, 31,-15, -9,-13, 20,-12, -6, 0, 12, -6, -2, 4,
- 3, -3, -1, 0, 1, 3, 3, -2, 1, 6, 4, 0, -3, 2, -5, 1 },
- { 38, -5,-13, -4, 8,-15, 11, 1, 2, -4, -1, 9, 13, 4,-12, -7,
- 0, -2, 7, 2, -6, -2, -3, -2, 3, -4, 6, 15, 1, 1,-11, -2 },
- { 47,-22, 9,-26, 3, -5, 2, -7, 4, -2, 2, -2, 3, 0, 3, -4,
- 3, -3, 2, -3, 7, -3, -1, 1, 1, -5, 5, 0, 2, -5, -3, -2 },
- { 14,-16, 2, -6, 7, -2, -7, -4, -4, -7, 14, -3, 7,-19,-14,-17,
- -29, 6, 26, 16, -5, 13, -4, -1, 21, 14, 1, 3, -6, 0, -7, -1 },
- { 29,-11, 5, -3, 4, 11, 4,-10, 1,-22, -3,-10, 5, 4, 2, 8,
- -2, -7,-12,-12, -8, -3,-18, -2, -9, -5, -1, -3, 2,-14,-14, 7 },
- { 28,-12, 5, 3, 9, -7, 0, -2, 2, 1, 4, 0, -7, -3, -2, 4,
- 4, 14, 8, -1, -4, 14, -7, 17, -2, -2, -9, 2, 19, -7, 9, -8 },
- { 31,-18,-22, 8, 15, -5,-10,-15, 1, 10, 6, 7, 6, -8, 2, -1,
- 12, -3, 3, -1, 1, 5, -6, -4, 0, 1, 7,-10, -2, 4, -3, -4 },
- { 53,-30, -4, 12, 2, 3, -3, -3, 0, 1, 6, 5, -5, -4, -7, 1,
- 0, 2, 1, 3, 1, 5, 0, 2, 2, -1, 0, 4, 2, 0, -2, 0 },
- { 27,-18, -3, -2, 4, -8, 3, -2,-11, 2, 10, -8, -8, -4, 0, -2,
- 8, 0, 9, 0,-16, 11, 1, -6, 13, -3,-10,-13,-15, 25, 1, 0 },
- { 35, -5, -1, -8, 23, 11,-14, -3, 2, -2, 8, -6, 17, -2, 7, 0,
- -2, 10,-17, 13, -2, -2, 11, 11,-14, 2, -2, -3, -8, -1,-12, -5 },
- { 29, -9, 7, 3, 2,-10, 0, 3, 9, 0, -3, 5, 1,-10, 10, -5,
- 3, 6,-20, -9, -6, -4, 1, 0, 12, 17, -8, 9, 3, -1, -9, 0 },
- { 15,-16, 18,-19, 16,-15, 17,-18, 13,-16, 17,-14, 15, -9, 13,-17,
- 9, -7, 4, -5, 3, -4, -3, 0, -6, 7, -9, 7, -2, 7, -9, 9 },
- { 21,-10, 7, -2, 12, -7, 13,-17, 11, -2, 20, 3, 5,-11, -6, -6,
- -15, 0, -9, 5,-11, 7, -1, 7, 8,-10, -9, 3, -5, 9, -8, -2 },
- { 23,-22, 15, -5, 16, -4, -3,-12, 9, 3, -1, -2, -8, 2, -2,-16,
- 3, 4, -2, -6, -7, 12, -8, 2,-14, 2, -7, 11, -2, 6, -4, -1 },
- { 34,-17, -4, 8, 4, -6, 1, 8, 4, 16, 3, 6, 12, -1, -1,-15,
- 6, 4, -7, -6, 6, 0, 2, 1, -2, 2, 3, 3, -3, -2, 8, -6 },
- { 18,-18, 2, -2, 10, 1, 18,-23, -3,-10, 0, 4, 20,-19, -3, -4,
- 2, 8, 6, 1, -3, 1, 1, 3, 5, -1,-11, 3, -7, 5, -1, 1 },
- { 15,-14, 2, 3, 10, -8, 12,-13, 13,-15, 6, -8, -4,-10, 14, -9,
- 24, 2, -7,-18, 13,-11, 8, 14, -6, -2, 3, -1, -4, 7, -7, -4 },
- { 20,-12, 13, 5, -1,-10, 15, -6, 8, -1, -3,-10, 17, 0, -6,-19,
- 2, -1, 8, -3,-16, 0, -3, 2, -2, 0, 8, -9, 0, 1,-10, -9 },
- { 32, 0, -9, -5, -1, 5, 13,-11, 8, 3, 11,-11, 0, -8, -2,-14,
- 7, 10, 6, -5, 1, 10, 2, 12,-10, 4, 4, 6, 4, 0, -7,-10 },
- { 16,-14, 10, -7, 11,-11, 11,-11, 18,-13, 8,-15, 16,-11, 13, -9,
- 8, -7, 12,-11, 7, -6, 3, -5, 9, -5, 4, -1, 7, -4, 8, -3 },
- { 24,-27, -1, 5, 8, -5, 12, 7, 4, -3, 3, -1, -9,-11,-13, -5,
- 10, 0,-13, 7, 1, -5, 4, -9, 7, -3, 13, 2, -5, -3,-17, -2 },
- { 23,-19, 15, 1,-10,-18,-12, -6, 8, -3, 12, 0,-12,-10, -4, -4,
- 8,-10, 4, 2, -2, -8, 13, -3, -2, -6, 2, -3, 5, -2, 2, 11 },
- { 25,-12, 4, 2, 24, -3, 3, -6, 14, 11, 0,-21, -3, -3, 1, -8,
- 7, 0, 0, 3, 3, -6, -7, 6, 2, 1, -4, 5, -1, 10, -2, 9 },
- { 24, -8, -6, 7, 16,-12, 13, -1, 11,-21, 2, -6, 3,-12, 0, 9,
- 4, 11, -7, 1, 4, 1, -8, 3, 3, -6, 3, 3, 0, -8, 8, 4 },
- { 25,-21, 13, 14, 13,-18, 4, -3, 0, -5, -4, 5, -3, 0, 4, 12,
- 7, 3, 5, -5, 2, -2, 3,-10, 2, -9,-15, 6, 1, 7, -5, 1 },
- { 23,-16, -2, 10, 4, -1, 3, 1, 32, 3, -5, -2, 9, 10, -1, -4,
- -6, 2, 9, -1, 14, 12, -6, -1,-17, -2, -4, -9, -7, -6, -8, 3 },
- { 50, -8, 5, 2,-11, 10, 0, 0, 6, -3, 7, 0, -3, -2, -3, 0,
- 6, -4, 2, -5, -9, 0, 3, 10, 1, -7, -2, -3, -6, -9, 1, -2 },
- { 28,-17, 0, -2, 2, -9, 1, 5, -4, -1, 0, 0, 19,-27, 5,-12,
- 7,-14, -3, -6, 10, -2, -4, -2, 4, -5, -2, -7, 1, 7, -9, 4 },
- { 22,-19, -6, -6, 3,-22, 3, 5, 20, -8,-14, -5, 1, 1, 20, 2,
- 16, 6, 3, 14, 4, 3, 5, 1, 5, -7,-10, -6, 3, -6, 1,-14 },
- { 29,-14, -8, 13, 8,-10, -6, 4, 4, -6, 5, -7, 1, 12, 14, 11,
- -7, 1, 2, -9,-11, -9, 0, 4, -1, 7, 10, 4, 4, 20, -1,-11 },
- { 18, -9, 4, 1, 7,-29, 12, 1, -1, -9, -2, -1, -2, 2, 9, -8,
- -13, 5, 4,-13, -4, 2, -5, -7, -6, 14,-10,-34, -3, 1, -3,-13 },
- { 38, -9, 24, 8, 11, 4, -6,-11, -2,-12, 1, 1,-11, -8, -5, -2,
- -15, -8, 8, 0, 1, -7, 5, 4, -1, 8, -2, 11, -3, -1, -5, -5 },
- {-20, 11, -4, 24,-11, 1, 15, 4, 0,-28,-10, -1, 10, 10, -6, 5,
- -6, 2, 7, -2, 1, -2, -6, -3, -7, 1, 2, 12, -1, 7, 0, -2 },
- { -9, 10,-23, 27, -4,-17, 20, -6, 14,-17, 5, -1, 5, -9, -7, 5,
- -6, 4, -2, 9, 0, 8, 0, 1, -3, -3, -5, -8, 5, -2, -2, 12 },
- {-10, 19, 4, 9, 1,-16, 17, -2, 9,-29,-16,-11, -4, 7, -5, 4,
- -1, -3, 3, 2, 3, -4, 5,-12, -2, 6, 5, -4, 4, 1, 4, 10 },
- {-20, 10,-24, 14, -5, 11, 9, 0, 16,-20, 10, -5, -6, -6, -1, 2,
- -4, 5,-16, 8, -2, 5, 5,-11, 9,-11, 4,-11, -1, -1, 4, 3 },
- { -9, 11, 3, 19, 24, 4, 5,-14, 30,-17, -4, -2,-17, 7, 2, 3,
- 1, 3, -7, -4, 2, -3, 1, 4, -1, -1, 3,-12, -2, 3, -3, 10 },
- {-19, 18, 11, 19, 19, 19, 10, 4, 13, 6, 5, 4, 8, 3, -2, 12,
- -6, -2, 7, -6, 15, 12, 16, 16, 18, -3, -4,-20, 0, 10, -9, -3 },
- {-21, 9, 20, 12, 0, -3, 5, -9, 15,-13, 5, -5, -6, 24, 2, 9,
- -5, 2, -7, 2, 5, 7, -5, 2, 15, 3, 1, -1, -4, -2, 7, 0 },
- {-18, 16, 13, 15, 2,-10, 14,-11, 4,-11, 5, 12, 12, 20, 8, 30,
- 2, 11, -9, 7, 0, -3,-16, -5, -6, 5, -4,-21, 0, 5, 6, 1 },
- {-26, 8,-13, 9, 6,-10, 2,-11, 7, -4, 6,-19,-11, -6,-12, 16,
- 0, 5, -7, 8, 5, 6, 17, -9, 10,-10, 5, -3,-11, 2, 4, 10 },
- {-11, 17, -3, 22, -5, 18, 3, 1, 4, -5, 14,-27, 5, -7, -4, -5,
- -10, 11, 1, 15, 1, 1, -6, -5, 10,-22, -7, -7,-15, 13, -4, 5 },
- {-17, 14, -7, 13, 3, 0, 13, -6, 9,-14,-22, -1, 1, 19, 14, -3,
- 4,-13,-13, 2, -4, 8, -2, -2, 13,-12, 13,-12, -7, -5, -3, 6 },
- {-17, 17, -1, 33, 6, 3, 9,-16, 3,-14, -8, 6,-17, 8, 3, 13,
- 8, -6, 3, 1, -2, 0, -2, 8, 4, 9, 13,-10, 4,-17, 0, -6 },
- {-20, 7, 7, 21, 1, -3, 7, -3, -2,-12, 9, -7, 2, -3, 14, 1,
- -1, -7, 12,-10, 5,-20, 11, -2, 0,-24,-17, 6, 6, -4, 3, -1 },
- { -8, 10, 6, 7, -1, -6, 28, -6, 10,-33, 1,-20, 0,-12, 10, 1,
- -6, 8, -3, -1,-10, 8, 5, 0, 10, -2, 8, 16, -5, -3, -7, 4 },
- {-17, 13, 3, 15, 1, -5, 27, -5, 6, -6, 12, 2, -4, 8, -1, -3,
- -2, 12,-15, 3, 4, 1, 2, -9, 0,-16,-21, 2, -4, 16, -7, 4 },
- {-15, 20, 8, 17, 5,-14, 15,-11, 21,-11, 13,-13, 2,-15,-13, 1,
- -5, 5, 2, 10, -9, 4, -1, 3, 2, -4, 13, -5, 1, -4, 5, -3 },
- {-21, 8, 2, 16, -1, 2, 15,-16, 13,-12,-12, -7, -8, 2, -7, 11,
- -8, 5, 2, -7, 16, -4, 1, -7, 3,-15, 6, -5, -8, 2, -8, 5 },
- {-15, 17, -6, 3, -3, 3, 9, -7, 14,-23, 11, 1, -1, 4, 7, 6,
- -1,-14, 7, 6, -8, 5, 1,-15, 10, -9, 2, -3, -1, 4,-10, -4 },
- {-10, 18, 3, 11, 1, 4, 14,-14, 7, -4, 15,-10, 10,-11, 10, -4,
- 5,-14, 10, 4, 15,-12, 15,-13, 20,-15, 14,-15, 8,-11, 4, -6 },
- { -7, 23, 2, 20, 7, 8, 19, -5, 9,-16, -8,-17, -5, 1, 5, -6,
- -8, 1, -6, -4, 10, 6, 6, 2,-11, -4, 0, 2, 4, 7, 9, -4 },
- {-15, 20, -5, 22, 11, -8, 9, -5, 10,-13, -8, 8, 2, -2, -3, 7,
- 6, 10, 1, 2, -5, -9, 1, 10, 16,-22, -7, 0, 7, 7, 6, 1 },
- {-26, 19, -5, 3, 5, 25, 18, -5, 9,-14, -8, -6, -2, -6, 2, 3,
- -8, -2, -7, 7, -3, 7, 3, 4, -8, 0, 1, -8, -4, -2, -2, 1 },
- {-20, 14,-10, 6, -3, 7, 8,-32, -2, -7, -2,-10, 16,-12, -9, 15,
- -2, -5, -6, 2, -7, 5, 9, 1, 6, -7, -1, 0, -2, -4, -7, 3 },
- {-14, 16, 4, 11, -8, 1, 23, -4, 17,-13,-10, 1, 12, 9, 12, -4,
- 7, -1, -1, 5, -8, -6, 3, 3, -6, -3,-18, 0, 18, 20, 4, -2 },
- {-33, 19,-10, 30, 15, 2, -3, -1, -4,-14, 7, -7, -1, 7, -8, 9,
- -1, -3, -5, 2, 2, 4, 0, 5, 0, 0, 2, 3, 3, -3, -3, 4 },
- { -6, 20, 0, 5, 17,-10, 18,-17, 9,-16, 4,-13, -6, 2,-14, 14,
- -28, 9,-12, 25, -4, 7, 7, -8, 6, -6, -2,-10, 2,-11, -1, 2 },
- {-12, 14, 12, 52, -3, 5, -5, 4, 8,-13, 2, -5, -4, 2, -2, -1,
- -2, 3, 3, 5, 2, 3, 0, 1, -5, 2, -4, -3, 1, -5, -2, 0 },
- {-13, 6, 9, 24, 0, 8, 14,-15, 18, -9,-11, -8, 3, 15, -2, -4,
- -9, 4, -3, 12, 14,-13, 11, -4, 2, -4, 0, -6, -6, -6,-14, -1 },
- {-10, 28, 3, 12, 9, 3, 11,-28, 6,-11, -7, 4, 0, 7, 8, -9,
- 0, -6, 0,-16, 4, 7, 4, 4, 7, 3, 4, -7, 0, -3,-10, 6 },
- {-11, 14, -2, 19, -1, -1, 7, 9, -2,-27, 10,-14, 15, -4, 12, -4,
- 2, -2, -6, 12, -6, 0, -5, -4, -5, 1, 3,-11, 5, -9, 3, -8 },
- {-18, 7, 13, 16, -4, 3, 9,-10, 10,-10, -3,-22, -4,-12, 3,-16,
- 0, -3,-16, 8,-11, 1, 10, -7, 15, 3, 0, -1,-13, 8, 1, 6 },
- {-20, 10,-10, 10, 8, -1, 6, 0, 16,-12, 9,-10, -1, -5, -4,-13,
- 13, 16, -8, 12, -2, 14, 18, 13, 0,-16, 2, -5, -5, -5, -4, 3 },
- {-14, 5, -7,-17, 5,-13, 23, 20, -4, -1, 1, -6, 13, 5, -1, 4,
- -14, -2, -7, 8, 3, 2, 2, -7, 2, -1, 4, 7, 3, -9, -1, -5 },
- {-19, 3,-24,-28, -9, -7, 19, 3, 2, 19, 7, 5,-13, 8,-15,-17,
- 3,-11, 4, 13, 3, 2, -1, -3, -4, -4, 2, 0, -5, -6, 6, 2 },
- {-17, 18,-30,-20, -2, -3, 1, 15, -1,-11, 6, -4, 11, 11, -4, -5,
- -10, 0, 0, 1, 3, -7, 8, 2, 5, 1, 5, -5, 1, 6, 4, 1 },
- { -6, 1,-30,-25, -1, -8, -2, -9,-17, 16, 3, -1, -2, -9, -6, -7,
- -3, 12, 6, -4,-10, 0, 10, -8, -6, -5, -3,-11, -4, 0, -1, -3 },
- { -1, -1,-34,-28, 1,-10, 2, 9, 4, 16, 2, 6, 14, 17, 0, 7,
- -4, 4, 4, 4, 0, 1, -1, -5, 8, 1, -4, 1, -9, -2, 5, 6 },
- {-11, 14, 1,-31, -7,-24, 9, 7, 6, 5,-13, 1, -1, 3, 4, -1,
- -2, -8, -6, 3, 5, -4, -6, 7, -2, 5, 3, 3, 0, 0, -5, 2 },
- {-25, 8,-11,-18, 1, -4, 8, -3, -4, 15, 6, -5, 8, 2, 3, 4,
- -4, 5, 6, 8, -7, 6, 1,-11,-15,-13, 9, -4,-14, 10, 12, 7 },
- {-20, 11,-15,-25, 3, 4, 18, 13, -4, -5, -9, -1, -5, -2, -2, -7,
- 16, 5, -4, -5, -7, -2, -3, -9, 11, -2, 0, -7,-17, -6,-11, 6 },
- {-11, 18, -5,-20,-15, -3, 9, 11,-20, 12, 5, 5, 11, -3, 7, 1,
- 10, -6, -3, -3, 3, 3, 14, -7, 10,-17, 9,-11, -2, -6, 7,-12 },
- {-20, 8,-14,-17, -9,-13, -3, 0,-27,-14, -3,-14, 4, 3, 6, -6,
- 7, 4, 23, 9, 11, 9, 3, -4, 9, 2, 4, -1, -6, 1, -8,-11 },
- { -9, 14, 2,-37, -7, 13, 6,-11, -6, 9, 18,-11, -6, 2, 12, 4,
- -1, 3, 1, -2, -2, 1, -9, -4, -2, -3, 3, 5, -6, 0, -2, -8 },
- {-29, 8, -1,-13, -2, 8, 23, 2,-10, 7, 13, -6, -5, 11, 13, 0,
- -10,-13, 11,-12,-10, 6, 4, 6, 4, 3, 6, -5, -9, -2, -1, 3 },
- {-18, 6,-10,-55, -4,-11, -2, 0, 1, -3, -9, -6, 3, -2, -1, 6,
- 3, -1, 3, 1, -4, -7, -2, 6, 3, -2, -1, -3, -2, 0, 4, 1 },
- {-14, 5, 3,-21, -8,-16, -4, -2,-11, 27, 15,-20, 3, 0, 1, 1,
- 2, -5, -5, 4, 1, -9, 5, -3, 3, 0, -4, -2,-11, -4, -3, 7 },
- {-17, -1, -9,-17, -8,-18, 12,-13, -9, 13, -3, 3, 3, -3, 1, -2,
- 0, 16, -9, 6, 12, 9, 5, 11, 2,-15, 1, -4,-16, 7, -4,-12 },
- {-18, 8, -6,-11, -8, -7, 13, 7, 1, 6, 8, -1, 21, -4, 14, 15,
- 18, -4, -3, 15, 0, 9, 4, 7, 3, -1, 9, -2, 0, 7, -8, 2 },
- {-10, 7,-18,-29, 3, 12, 12, 9, 11, 4, -1,-15, 1, -1, 8, -2,
- -2, 10,-15, -1, 0, 6, 12, -6, -1, 10, -6, -3,-11, -4, 9, -6 },
- {-14, 14, -9,-21,-12, -2, -1, -7, -5,-10, 5, -8, 0, 6, 9,-11,
- 11, -3, -5, 3, 8, 15, -2, -4,-22, 4, -6, 12, 2, 13, 6, -7 },
- {-12, 11, -5,-29,-25, 4, 12,-13,-11, -7, 4, 2, 2, -5, 5, 8,
- 7, -5, -5, 6, 3,-10, 1, -6, 6, -6, -5, -1, -2, -4, 7, 6 },
- {-15, 11, -5,-16, 0,-13, 26,-23, -6, -3, 5, -2, -2, 21, -6, -3,
- -5, -1, 6, -1, 0,-13, 2, -3, -9, -1, -4, -3, 5, -4, 12,-16 },
- { -9, 9, -1,-17, -3, -6, 12, 6,-18, -2, 11,-14, -6, 3, 14,-12,
- -11, -5, 14, 2, 5, -8, -4,-11, 2, -5, 16, 6, -7, -4, 8, 13 },
- {-13, 5, 3,-28,-14, 0, 6, 23, 5, 4, -1,-17, 1, -3, 0, 0,
- 5, 4, 0,-18, 14, 10, 4, 2, 5, -2, 4, -3, 2, 0, 2, 0 },
- {-15, 4,-13,-16, -3,-12, -2, 2, 7, 10, 9, 3, 11, 4, 23, 14,
- 9, 16, 4, 1,-12, -3, 4, -7,-15, -7,-10,-14, -6, -8, -1, -6 },
- { -7, 10, -5,-10, -3,-13, 16, -1,-12, 7, -3,-12, 2, 13, 13, 2,
- 17, 15,-13, 1, -5, -2, 3, -1, 1, -3, 6, -3,-12,-16, 7, -7 },
- {-11, -5,-12,-30, -6,-22, 1, 4, -6, -3, 12, 6, 7, 0, 16, 6,
- -2, 0,-22, -2, -9, 2,-13, 8, 6, -8, 4, -7, -1, -6, 4, 6 },
- {-14, 5, 1,-27, -4, 2, 1, 14,-11, -7, -8, -4, 1, 8, 0, -6,
- -13, 11,-12, -7, -5, 1, 10, 7, 3, -2, 0, 6, -8, 2, 10, -1 },
- {-10, 10,-25,-13,-20, -4, 19, 3, 13, 5, 5, 7, -8, 2, 4, 2,
- 3, -1, -1, -9, 14, 10, 9, 14, 3, 3, -6, 0, -5, 4, 1, -1 },
- { -9, 15,-18,-17, 4,-11, 6, 7,-12, 8, -1,-11, 2, 3, 7, 16,
- -3, -9, 7,-12, 23, 0, 6, 7,-14, -9, 8, 1, -2, 6, -2, -1 },
- { -6, 9,-16,-26,-14,-11, 9, -6, 5, -2, 13, 17, 21, 7, 18,-19,
- 6,-23, -2,-15, -2, 2,-10, -8, 2, 1, -2, 4, -3, -4, -5, -4 },
- { 0, 6, -5,-28,-17,-32, 2,-10, 11, 3, -5, 9, 10, 3, 11, 11,
- -3, 12, -2, 2, 4, -6, 9, -4, -4, -4, -4, -9, 2, 0, 2, 4 },
- { 0, -8,-18,-34, -9, -7, -4,-11, 10, 15, 11, -1, -8, 15, 6,-13,
- 9, 2, -4,-12, 0, -1, 19, 12, 6, 5, 0, -3,-10,-12, 3, -5 },
- {-10, 6, -9,-17,-12,-11, 9, -6, 11, 11, 18, -7, 0, 16, 4, 2,
- -6, 3,-12, -1, 0, 1, -5,-22, -2,-12, 0, 6, 17, 5, 5, 6 },
- { 12, -5, 7, 1, -5, -2, -1, 2, 2, -4, -3, -3, -3, -2,-29, 11,
- 5,-13,-73, 24, 12, 4,-14,-10, 5, 1, 0,-11, -7, -7, 7, 3 },
- { 10, -3, -1, -3, 4,-11, -5, -2, -8, 7, 9, 2, -8, -6, 6, 7,
- 21, 17,-54, 47,-14,-10, 14, 19, 13, 21, -4, 3, 1, 2, -4, 2 },
- {-12, 4,-16,-12, 5, -9, -4, 19, -7,-22,-22,-17, 3, 0, -6, 8,
- 23, -4,-55,-28, 2,-26, 2, 1, 4, 0,-13, 6, 0, 10, -7,-11 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, -1,
- 35, -1,-67,-35,-24,-24, -6, 2, 2, -2, 1, 3, 2, 0, -1, 1 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 5, 0,
- 41, -4,-73,-15, 18, 4, 17, 8, -1,-16, -1, -2, 1, 0, 0, 0 },
- { -4, -4, 4, 6, -1, 2,-16,-10,-15,-10, 21, -2, -6, -2, 14, -7,
- 10, -5,-55, 34,-12, 11,-13, -2, 2, 28,-26, 0, 7, 4, 21, -7 },
- { 2, 1, 15,-22, 10, -3, 14, -6, -2, 15, -2, -7, 20, 6,-15, -7,
- 23, 10,-60, 8, -4, 29,-22, 2,-13, 9,-10, 12, -1, -3, 4, 7 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, -2, 11, -5,
- -21,-11,-60,-27,-17,-39, 6, 36, 0, -8, 2, 2, 0, 0, -2, 3 },
- { 2, -5, 9,-17, -1, 2, -3, -6, 8, 12, 7, -6,-33,-11,-14,-40,
- 10, 36,-46, 0,-19, 5, 0,-10, 3, 12, -6, -8, 6,-12, -7, 1 },
- { 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, -1, 0, 1, 0, -2, 0,
- 4, -2,-87, -3, -2, 2, -2, 20, 2, 6, -1, 6, 0, 0, 2, -1 },
- { 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, -1, 0, 0, 1,
- 1, 7,-76, 41, -7,-24, 0, -6, 3, 6, 0, -2, -1, 1, 0, 0 },
- { 0, -3, 4, 2, 3, 2, 2, 0, 3, -1, 4, 0, -1, 4, -2, -4,
- -32,-11,-64,-29, -9,-43, 2,-11, -1, -7, 0, -4, -2, -2, -2, 2 },
- { 10,-20, 3, -3, 13, 13, 0, -4, 2, 7, -8, 7, -2, 2,-20,-20,
- -19, 3,-47,-18,-16, -6,-15,-42,-17, 14, -6, 8, 12,-10, 11,-12 },
- { -3, -2, -2, -1, -1, 4, -3, -1, -6, -2, 3, 2, -3, 6, -1, -9,
- 10, 13,-68, -9, 26, 3, 5, 3,-21, 10,-15, 21,-22, 19, 11,-14 },
- { 1, 5, 18,-19,-29,-13, -2, 18,-10, 20, 2, 10,-10, 11, 1, 8,
- -16,-17,-41, 10,-14,-25, 0,-14,-19, 17, 7,-12, 14,-11, 14, 5 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, -1,-43, 5,
- 6,-12,-48, 19, 8,-38, -8, -3, 22,-21,-10, 15, 20, -9, -5, 8 },
- { 0, 0, 0, 0, -1, 1, -1, 0, 0, 0, 0, 0, 0, 0, 6, -3,
- 22,-14,-71,-24, -2,-33, 23, 7, -8, 7, -3, 2, -4, 1, -8, -2 },
- { 1, 0, -1, 2, 0, -2, 0, 0, -1, 0, 4, 0, 26, -1, 10,-11,
- -17,-32,-58, 14,-14,-11, -2, 15, 2, -8, 12, 10, -9, 13,-33,-14 },
- { 15,-17,-19, 7, -8,-15,-32,-22, 7, 12, 18, 0, 0,-15, -4, 16,
- 37, -2,-46, 11, 2, -8,-10, -8, 14, 9, -4, 5, 7,-17, 4, 3 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0,
- -5, 3,-85, 23, -9,-17, -2, -2, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0,
- -5, 3,-85, 23, -9,-17, -2, -2, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, -1, 0, 0, 1,
- 1, 7,-76, 41, -7,-24, 0, -6, 3, 6, 0, -2, -1, 1, 0, 0 },
- { 0, -3, 4, 2, 3, 2, 2, 0, 3, -1, 4, 0, -1, 4, -2, -4,
- -32,-11,-64,-29, -9,-43, 2,-11, -1, -7, 0, -4, -2, -2, -2, 2 },
- { 10,-20, 3, -3, 13, 13, 0, -4, 2, 7, -8, 7, -2, 2,-20,-20,
- -19, 3,-47,-18,-16, -6,-15,-42,-17, 14, -6, 8, 12,-10, 11,-12 },
- { -3, -2, -2, -1, -1, 4, -3, -1, -6, -2, 3, 2, -3, 6, -1, -9,
- 10, 13,-68, -9, 26, 3, 5, 3,-21, 10,-15, 21,-22, 19, 11,-14 },
- { 1, 5, 18,-19,-29,-13, -2, 18,-10, 20, 2, 10,-10, 11, 1, 8,
- -16,-17,-41, 10,-14,-25, 0,-14,-19, 17, 7,-12, 14,-11, 14, 5 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, -1,-43, 5,
- 6,-12,-48, 19, 8,-38, -8, -3, 22,-21,-10, 15, 20, -9, -5, 8 },
- { 0, 0, 0, 0, -1, 1, -1, 0, 0, 0, 0, 0, 0, 0, 6, -3,
- 22,-14,-71,-24, -2,-33, 23, 7, -8, 7, -3, 2, -4, 1, -8, -2 },
- { 1, 0, -1, 2, 0, -2, 0, 0, -1, 0, 4, 0, 26, -1, 10,-11,
- -17,-32,-58, 14,-14,-11, -2, 15, 2, -8, 12, 10, -9, 13,-33,-14 },
- { 15,-17,-19, 7, -8,-15,-32,-22, 7, 12, 18, 0, 0,-15, -4, 16,
- 37, -2,-46, 11, 2, -8,-10, -8, 14, 9, -4, 5, 7,-17, 4, 3 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0,
- -5, 3,-85, 23, -9,-17, -2, -2, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0,
- -5, 3,-85, 23, -9,-17, -2, -2, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 16, 65, -2, -2, 4, 3, 0, -7, 3, 1, 3, 1, 0, 5, 1, -5,
- 0, 2, -1, 3, 0, 0, -1, -2, 6, 0, -2, 0, 0, -1, 1, 1 },
- { 5, 37, -4, 8, -4, -1, 9, 17, 6, -7, 5, -1, 11, 6, -4, 7,
- -2, 4, 1, -3, 11, 3, 3, -9, 6, 0, -2, -4, -5, 4,-12,-11 },
- { 15, 24,-14, 2, 6, 17, 26, 5, 8, 11, -9, -7, -6, -8, 3, -5,
- 9, 10, -3, 10, 0, 1, 4, -9, 4, 9, 3, 0, 4, 0, -5, 3 },
- { 9, 36, -9, -8, 7, 7, 4, 3, -1,-16, -2, 7, -5, -6, 6, 12,
- -11,-12, 9, -1, -3, -9, 12, 6, -6, 2, 2, 5, 0, 5, 6, -6 },
- { 25, 39, -5, 24, 3, 10, 3, -6, 13, -8, 3, -7, 2,-10, -5, 2,
- -2, 3, 5, -2, 1, 5, -2, 3, -4, 1, -5, -4, 0, 1, -2, 0 },
- { 16, 27, -1, 0,-14, 6, 4, -5, 7, -2, -6, 0, -3, -5, 2, -1,
- -1,-19, 5, -8, 0, 11, 12, 5, 0, 3, 10, 6,-14, 14,-13,-15 },
- { 12, 23,-14, 2, 1, 4, -3, 16, 7, -8, 2, -8, 8, 6, -8, -7,
- -3, 0, 2, 8,-13, 7, 13, -6, -4, 6,-13,-16, 14, 11, -7, 5 },
- { 16, 28, -7, -1, 6, -3, 9, 0, -7, 3, 0, 3,-12, 20, 8, 9,
- 8, 23, 8,-13, -2, 4, 9, 3, -5, 13, 5, -2, 12, 14, 5, -1 },
- { 19, 37, 19, 5, 7, 5, 10, 5, 19, 10, 14, 0, 2, 5, 1, -4,
- -4, 2, 2, -5, -2, -1, 2, -6, -4, -4, -5, -3, 2, -2, -2, -2 },
- { 24, 21, 1,-11,-10, 17,-14, 14, 6, -1, -6, -1, 0,-13, -1,-12,
- -2, -5, 6, -4,-12, 14, 5, -2, -8, -8, 15, -7,-30,-12, 4, 0 },
- { 11, 26, -3, 3, 5, -1, -2, 3, -2, 10, 15, -4, 10,-28, 10,-17,
- -8, 1, 2, -7, -1, -6,-15, -1, 4, 5, -7, 9, 0, -5, -4, 4 },
- { 18, 32, 1, 2, -7, 4, 15, 2, -9, -2, 12,-11, 7, 11, 13, 2,
- 0, 5, 9,-10, 16, 3, -3, 5, -9,-23, 2, -2, -1, 5, 2, 11 },
- { 35, 24,-20, 2, 4, -1, 5, 14,-10, -9, 8, -7, 0, 5, -7, -7,
- 11, 1, 5, 3, 2, 0, -2, 3, 0, 1, 4, 0, -2, -8, 0, -4 },
- { 9, 35, -1, 2, -1,-19, -3, 12, -1, 8, 8,-13, -1, -2, 2, 5,
- -8, -1, 13, -2, 11, 1, 0,-10, 0, -3, -7, 2, 1,-12, 3, 12 },
- { 20, 27,-12,-12, 7, 4, -1,-13, -1, -9, 2, 13,-11, 5, 7, -9,
- 9, 1, 1, 8, -9, 0, -6, 7, 4, 2, -2, 7, 3, -2, 1, -9 },
- { 8, 37,-20, -5, 0,-21, 10, -8, 3, 19, -9, 7, -3, -8, 10, -2,
- 0, 5, 6, -4, -2, -1, 0, -7, 6, 1, 0, 4, -5, 6, -8, 2 },
- { 8, 27, 1, -3, -5, 1, 6, 0, 15, 2, 17, -1, 3,-17, 10, 5,
- 5, -6, -6, 6,-10, 18, -5, 0, 0, 13, 7, 10, -5, -6, -2, -4 },
- { 14, 29,-20, -4, -3, 1, -5, -1, 2, 12,-10, -3, 4,-18, 4, 14,
- -4, -1, -9, 15, -2, 2, -5, -3, 2, 9, -2,-14, -3, 4, -4, -7 },
- { 23, 23,-23,-11, 27, 4, 4, -1, 7, 0, -5, 9, 2,-11, 3, 7,
- -2, -5, 2, -7, -7, 13, -3, -6, 2, 3, 3, -4, -1, -8, 5, -2 },
- { 16, 26, -6, 8, -9, -1, -2, -1, -8, 4, -2, 0,-12, 9, -1, 0,
- -17, -9, 30, -5,-15,-16,-13, 0, 10,-11, -7, -3, -1, 0,-11, -2 },
- { 12, 32, -4, -5, 10, 19,-10, 4,-12, 5, -6, 9,-12, -6, -6, -8,
- 4, 1, 3, 0, 8, 0, -3, -4, -7, -4, 10, 8, 6, 5, -1, 4 },
- { 46, 42, -3,-14, -2, -6, 6, -2, -5, -1, -3, -3, 1, -1, 3, 1,
- 1, 4, -1, 2, 3, 1, -2, 6, 0, -1, -2, 4, -2, -1, 2, 2 },
- { 9, 33,-13, 4,-11, 3, -8, 22, 12, -2, 4, 0,-16, 5, 4, -1,
- 7, -6, -9, 1, 7, 5, 0, -5, 5, -1, 10, 3, -2, -1, 3, -2 },
- { 9, 30, 6, -3, 6, 1, -7, 5, 11, 14, 7, 1, 0, 2, 2, -1,
- 8, 7, -6,-13,-10, -2, 1, -6, 10, 7, 6, 5, -2, -5, -1,-16 },
- { 9, 28,-11,-10, 9,-10, 15, 8, 4, 9, -4, -7, 0, -5, 9, 8,
- -7, 2,-15,-23, 4, -4, 4, 16, -8, -3, 0, -8, 14, 5, -3, 15 },
- { 17, 26, -5, -5, -1, -8, 20, 18, -7, -2, 4, -7, -8, -5, -4, 16,
- 0, 0, -7, -2,-13, -5, -2, 3, 12, 1, 3, -5, 2, 2, 0, -1 },
- { 11, 37, 7,-23, 6, -1, 15, 13, 4, -9, 7, 5, 3, -3, -5, -8,
- -2, 3, -5, -1, -8, 7, 2, 13, 1, 3, 0, -3, -1, 2, 0, -2 },
- { 21, 33, 7, 20, 21,-10, 6, -5, -5, -6, -9, 2, 10, 0, 8, -4,
- 10, 2, -2, -2, 0,-10, -6, -2, 0, -5, 3,-11, 3, -9, -3, 1 },
- { 6, 30,-15, -8, 16, 1, 4, 6, 4, 5, 8, -3, 8, -9, -1, -6,
- 8, 2, -2, 4, -2, 5, 11,-21, 3,-10, 16,-11, 24, 10, 14, -6 },
- { 15, 36, -3, -9,-20, 12, 0, -7,-18, -4, -8, -9, 9, -7, -3, -1,
- 2, 7, -5, -8, 6, 2, 2, -1, 7, 1, 1, -3, 3, -4, -8, 1 },
- { 16, 34, 21, 3, -9, 10, 7, 9, -7, 1, -4, -9, -4, -5, -5, 3,
- 3,-19, 1, 5, 4, -2, -6, -5,-10,-11, -8, -2, 2, -5, -8, -7 },
- { 28, 29, -3, 18, -2, 0, -6, 12, -2, 10,-11, -4,-13,-12, -6, -4,
- 0, 4, -1, -8, 6, 4, 12, 11, 10, 10, -3, -6, 1, 2, 1, 7 },
- { 3, 8, 22, -8, 3, 36, -8, -1, 9, 6,-13,-14, 8, -1, 1, 2,
- -2, -8, 0, 3, 1, 2, -1, 5, -1, -8, 0, -2, 2, 2, -1, 1 },
- { 0, 6, 0, 0, 4, 13, -7,-16, -6, 15,-14,-21, -9,-10,-10, -6,
- -21, 5, 4, 2, 12, 4, 12, 11, -4, -6, -6,-10, -7,-18, 1, 4 },
- { -1, 3, 10, 1, -1, 15, 4, -7,-16, 3, 0,-22, 10, 2, -3, -2,
- 13, 5, -8, 16, -5, 4, 0,-11,-10,-22, 0, -4,-17, 5, 2, 1 },
- { 12, 8, -4, -9, 14, 40,-21, 0, 1,-15,-10,-12, 12, 6,-10, 2,
- 8, 6,-12,-10,-11, 1, 0,-11, 2, 1, 13, 0, 6, 3, 8, 4 },
- {-10, 3, 5, -4, -3, 3, 0, -9, 2, 8,-22,-23, 17, 8,-17, -3,
- 14, -8, -4, 1, -8, 3, 0, 5, -1, -3, -2, -4, 1,-10, 0, -2 },
- { 0, -1, 5, -7, 4, 12, -2, 0, -7, 2,-16,-15, 12, 21, -7, -4,
- 7, -7,-11,-15, -7, -9, -5, -8, 0, -6, 8, -3, -8, 22, -7, -9 },
- { 7, 19, 4, -9, 24, 22, 2, -6, 8, 13,-14,-20, -4, 11, 8, -4,
- -1, 2, 0, -7, 5,-17, -3, 3, -6, 5, 3, 4, -5, -7, -3, 14 },
- { -2, 6, 2, 8, -2, 5, -4, -2,-10, 3,-45,-30, -3, -3,-12, -4,
- -3, -3, -1, 9, -6, -6, 5, -4, 0, 5, -1, -2, -1, 0, -6, -1 },
- { -3, 14,-16,-10, 10, 0, -2,-40, -9, 12, 2,-19, 15, -4, 4, 3,
- 3, -4, 7, 1, -4, -5, 0, 4, -1, 0, -9, -2, -4, -1, -2, 0 },
- { 7, 16, 2, -7, 8, 2, 0, 1, 5, 21,-10,-26, 7, 2, -9, -7,
- -3,-16, 8, 5, 5, -6, 10, 4,-14, -6, 5, 3, -2, -2, -4, 1 },
- { -9, 14, -1, 3, 3, 11, 1, -5, -3, 13,-16,-18, 20, 6, -5, 0,
- -3, 2, 8, 4,-19, -9, 12, 0, -8, 2, 2, 1, 6, 13, -7,-11 },
- { 2, 5, 16, -4, 19, 15, 4, 0,-11, 7,-10,-10,-16, 18,-11,-12,
- -9, -4, 7, -4, -4,-17, 1, 1, -8, -3, -3, 5, -2, -6,-11, -5 },
- { 2, 12, 0, -9,-10, 14, 6, 2, -3, 2,-12,-28, 12, 1, -1, 2,
- 0, -3, -4, 7, 16, 5, -7, 8, -4, -3, -1, 3,-12, 4,-17, -5 },
- { -4, 7, 11, 6, 1, 14, -4, -6, 5, 5, -6,-24, 23, -9,-15, 13,
- -7, -9,-15, 10, -1, 8, -5, 1, 12, 6, 2, 0, 4, -2, 9,-10 },
- { 1, 5, 11, 3, 6, 12, -3, 8,-21, 5, -7,-20, 12, -2, -9, -3,
- 17, -7, -8, -9,-14, 3,-13, 18, -8, 9, 2, -8, 4, -8, -5, -2 },
- { -3, -3, -1, 5, -2, 15, 3, 2, 1, -8, 1,-39, -6, 13,-13, 0,
- -2, -5, -6, -3, 0, -5, -2, 15, -9, 5, -3, -6, -2, 7, 0,-13 },
- { 2, 8, 5,-12,-13, 22, 8,-16, 11, 5, -2,-32, -2, -4, 11, 5,
- 5, -6, 1, 3, 1, 5, 3, 6, -5, 4, 4, -8, 8, 4, 1, 3 },
- { 13, 9, 5, -4, 9, 18,-11, 2, -1, 15,-10,-19, -2, 14, 0,-10,
- 1, 1,-18, 3, 2, -6, -8, 20, 7, -8, 16, 9, 9,-13, -3, -2 },
- {-13, 11, 11, -9,-10, 13, -3,-18, 2, 10, 5,-21, 6, 15,-11,-21,
- 3, 14, 0,-12, 9, -1, -2, -4, 3, -3, -9, -8, -5, -2, -8, 2 },
- { 3, 3, 11, 4, 0, 13, 1, -8, 10, 13, -6,-26, 2, 12, -3, -5,
- 12, -2, 1, 8, -7,-17,-19, 5, 10, 7, -3, 2, -3, 0, 5, 0 },
- { 5, 0, 3, -3, -9, 5,-15, -5, -5, 17, -5,-31, 0, 13, 13, 5,
- -1, -6,-14, 7, -8, 9,-14, -2,-16, -4, -4, -6, 6, -6,-10, 6 },
- { 13, 3, 1, 7, -3, 4, -1, -2, -1, 4, -8,-32, -1, -4, 0, 3,
- -10, 7, 10,-10, 4, -1, 6, 2,-16, -9, 4, 3, 13,-23, -3, -4 },
- { 4, 11, -4, -9, 4, 11,-12,-12,-12, 6, 1,-28, -3, 14, 18, -2,
- -12, 7, 15, -3, -5, -7, -3, 2, -6, 4, 4, -2, -5, -3, 2,-13 },
- { 8, 7, -7, 0, 13, 7, -8, -7, 8, 36,-10,-22, 3, 23, -3,-10,
- -3, 11, 1, -7, 3, 3, -1, -7, -4, 2, 3, 2, 5, 3, -4, -1 },
- { -1, 1, 13, 1, -6, -1, -6, -9,-18, 17, -5,-37, -1, -1, -6, -4,
- 1, -6,-15, 2, 17, -9, 0, -3, 0, 4, 0, -5, 0, 4, 1, -5 },
- { 0, 14, 5, 0, -7, 2, -6, 17, -6, -9, 7,-16, -5, 23,-14,-13,
- 8,-15, 11, 10,-11,-13,-33, -5, -2, 1, 6, 8, 0,-13, -9, 5 },
- { 11, 7, -2, -8, 9, 11, 25,-14, 7, 3, -1,-33, 14, 8, -6,-19,
- 3, 3, 2, -1, -3, -1, -2,-10, -3, 1, 2, 1, 4, 2, -3, 4 },
- { -2, 8, 4, -2, 9, 13, -4, -2,-15, -3, 19,-37, 9, 25, -9, 2,
- -5, -2, -2, -4, 4, 2, 2, 0, 3, 3, 3, 5, -2, -3, -4, -3 },
- { 10, 13, -1,-15, 4, 6,-18, -4, 25, 1,-23,-17, 15, 13, -8, -8,
- 7, 4, -5, 3, 6, 9, -7, 6, 0, -5, 8, 0, -6, -1, -2, -2 },
- { 1, 3, 9, -5, 27, 15, -9,-31, -1, 23, -2, -9, 1, 8, -1, -7,
- -2, -8, -4, -4, -2, -1, 3, 5, 0, 0, -1, 1, -7, 7, -3, -3 },
- { -8, 7, 3, -6, 8, 3,-11, -2, 36, 14, 1,-30, 6, 10,-12, -6,
- -6, -2, -4, -3, -5, 0, 9, 4, -5, -5, -8, 12, 4, -3, 1, -8 },
- { -2, 9, 33, 0, 12, -3, -7, -4, -4, -1, 6,-25, 11, -6, -9,-11,
- -2, -4, -2, 6, -1, -3, -6, 15, -6, 3, 10, -4, 1, 0, 5, 8 },
- {-22,-21, -9,-19, -5, -7,-12,-15, -8, 9,-19, 14, -7, -4, 5, -8,
- -2, 7, 1, -3, 4, -4, 6, 11, 2, 6, -3, -5, 2, -2, 0, -3 },
- {-32,-13, 3,-24, 3, -8, 4, 1,-10, 14,-15, 0, 4, 6, -1, 6,
- 7, -1, 6, 4, -3,-17, 1, 4, -6, -1, 1, 0, 3, 3, -7, -4 },
- {-32,-11, 7, -8,-12, 13, -5,-22, -4, 12,-16, 2, 0, 4, 0, 1,
- 0, 6, -5, -8, 2, 6, 5, 0, -3, -6, 5, 6, 5, 5, 13, -4 },
- {-44,-33, 6, -4, 2, 0, -9, 10, 3, 4, 7, 0, -1, 7, 5, 1,
- 1, -3, 1, 6, -1, 0, 2, 3, -4, 0, 0, 1, 0, -1, -2, -1 },
- {-30,-18,-24, -8, 5, 0, -2, 14, 7, 0, 1, 12, 6, 4, -9, 7,
- 5, 7,-11, -5, 1, -8, -1, 2, 2, -9, 7, -1, 7, 5, 6, 6 },
- {-22,-20,-13, -9, 20, -3, 10, -8, 6, -4, 2, -7, 10, 8, 0, -1,
- 2, -3, 6,-19, 2, 4, 3, 3, -7, 2, -1, -6, 1, 1, 6, -2 },
- {-27, -8, -1, 3, -1,-11, 24, 4, -1, 1, -8, 8, 5,-11, 15, -3,
- -15, -1, -1,-13, -1, 1, -5, 5, 2, 3, -9, 0, 4, 3, -7, 6 },
- {-33,-16, -1, -8, 10,-23, 6, 13, -1, -3, -9, 0, 5, -7, -5,-12,
- -2, 3, 3, 6, -2, -3, 2, -3, 9, -6, -3, -2, 0, 5, -3, -4 },
- {-22,-17, 11, -3, 3, 1, -1, -5, 17, 2,-15, -2, 10, -9, 6, 14,
- -16,-12, 20, -1, -7, 6, -3,-12, 1, 10,-10, -1, 7, -3, -1, 10 },
- {-28,-13, 1, -3, -1, -1, 0, 3, 3, 5, 1, 10,-10, -3, 7, 2,
- 4, 19, -1, -1, 10, 5, -8, 1, 11,-15, -4, -3, -5, 4,-13, 3 },
- {-22,-13, 42,-20, 5,-13, 7,-11, 1, 1, -1, 1, 6, 3, 6,-11,
- 3, 3, -2, 0, -4, 4, -3, -1, -5, 2, 0, 0, -9, -1, 4, 4 },
- {-26,-15, -2, -6, -4, -2, 16, 8, 21, 8, 1, -3,-10, 7, -8,-12,
- -5, 12, -9, 3, -2, -3, 18, 1,-12,-15, -4, 5, -3, 0, 12, 7 },
- {-26,-16, 5, 6, 14, -3, 15, 6, 1, -7,-13, 16,-15, 5, 11, -2,
- 9, -7, -4, -2, 0, 0, -2, 7, -8, -6, -5, 2, 7, -3, 2, 12 },
- {-31,-17, -8,-30, 4, 14, 6, -6, 6,-11, 0, 3, -4, 0, 0, -4,
- 0, -4, 1, 4, 3, 4, 0, -5, 3, 2, 2, 0, 2, 1, 3, 5 },
- {-61,-10, 4, 10, 4, 7, 0, -3, 0, 1, 0, -3, 0, 1, 0, -2,
- -1, 1, 2, -2, 4, -3, 1, 1, -1, 1, -2, -4, -4, 4, 0, 0 },
- {-28,-13, -8, -4, 3, -3, 2, 1, 11, 14, 3, 9, 1, 13, 3, 5,
- -3, -2, -2,-12,-14, -9,-11,-15,-12, -5, -4,-12, 3, -3, 0, -5 },
- {-41, 0, 12,-24, 13, 4, 5, 16, -5, -4, 0, 0, 13, -4, 1, -9,
- 9, -6, -1, 6, -2, 5, 2, 9, 6, -9, -8, 8, -2, -3, -6, -4 },
- {-26,-19, -2,-15, 4,-14, 6, 0, 26, 20, 8, 9, 9, 3, -4, -5,
- -8, 1, 0, -1, 5, 9, 3, 4, 4, 7, 1, 3, -2, -2,-10, 0 },
- {-29,-18, 9, -4, 1, -5,-14,-12, 5,-10, -5, 4, -5, 0, -1, -1,
- 4, -5, 7,-16,-11, 2, 7,-15, 2, -4, 6, -4, -6, 7, -3, 7 },
- {-27,-16, 9,-14, 3, -8, 9, 0, 7, -4, -3, -7, 0,-10, -1, 2,
- 1, -2, 15,-10, 14, 7, 6, 17, 3, -4, 3,-10, 8, -8, 3, 11 },
- {-21,-20, -8, -8, 4, 5, -3, -2, 0, -5, 14,-10, 11, -4, 13, 0,
- 5,-11, 19,-18, 18, 3, -5, -3, -4, -8, 11,-10, 10, 3, 4, -9 },
- {-35,-15, 13,-12, 4, 0, -2, -4,-12, -3, -8,-24, -7, 1, 7, 8,
- -3, 0, -2, -1, 3, -2, -2, -6, 8, 1, 0, 1, -6, -1, 2, -6 },
- {-19,-14, 13,-10, 9, -1, 1, 3,-12, 5,-16, 7, 13, 9, 4, -4,
- 6, -5, 4, 9, -3, 17, -4, 12,-11, -6, -5, -6, 13, 2, 7, -9 },
- {-34, -8, -4, 1, 2, -1, 3, 6,-20,-11, 8, -1, 4, 2, -9, 4,
- -4, -5, 16, 10, -4, 14,-13, 1, -6, 0, 2,-10, 0, -3, -3, 7 },
- {-36,-10, -8, -3, 2, -2, 14, -4, -1, -7, -4, 10, -1, -3, 15,-11,
- 0, 2, 3, -1, 4, 0, 8, -1, 0, 18,-11, -5, 15, -5, 13,-12 },
- {-22,-13, 14,-20, 15, 25, 16, 10, 8, -2,-10, -5, -1, -8, 11, 8,
- -1, -2, -4, 1, 2, -1, -7, 0, 0, 0, -3, 0, 2, -1, 0, 2 },
- {-31,-22, 7, 6, -2, 5,-20, 14, -6, 7, 0, 14, 3, -7, 3, -6,
- -2, 1, -3, -5, 1,-10, 1,-24, 6, -2, 3, -7, 1, -7, 8, 7 },
- {-25,-20, -3, -9, 10, 6, 12, 7, 5, 4, -3, 6, -1, -5, -6, -8,
- 3, 5, 6, 5,-10, 10, -4,-15,-15, -2, -9, 2, 18, 1, 8, 12 },
- {-24,-19, -2, -4, -7, 11, 6, 9, 16, 2, -7, 18, 6, -7, 6, 6,
- -2, -9, 3, 12, -2, 3, -1, 6, 7, 8, 0, 8,-11, 8, 4, 2 },
- {-26,-20,-12,-12, -2, -3, 1, -5, -1, -2, 0, 3, 7, 9, -2, 2,
- 9, 22, 13, 4, -4, -1, -2,-14, 5, 15, -8, -5, -7,-11,-14, -6 },
- {-21,-18, -1, -4, 0, 3, 7, -2, 10, 8, -8, -1, 15, 1, -9, 3,
- 1, 3, -5, -2, 2, 4, 0, -1, 10, 2,-19, -8, 8, 30, -7, 8 },
- {-25, -6, 26, 4, -8, 4, -2, 21, 5, -4,-16, 5, 13, 4,-10, -1,
- -6, -2, 2,-10,-13, 1, 3, -3, -6, -8, 2, 11, 1, -7, 0, 5 },
- { 0, -1, -2, 19,-12,-48, -6, 11, 8, -2, -4, -2, -7, 5, -3, 2,
- -2, -1, -1, -7, 0, -3, -3, -4, -4, 4, 1, 3, -3, -1, -2, -5 },
- {-11, -8,-28, 18, 16,-24, -8, 19, 4, 8,-12, 9, -4, -2, 4, -7,
- 6, 2, 3, 3, -4, 0, 1, -6, -4, -2, 2, 6, 0, -3, 1,-16 },
- { -9, -5,-26, 7, -3,-37,-16, -2, 2, -7, 4,-13, 0, -4, -6, -5,
- -6, -4, 0, 3, 4, -3, -4, -4, 4, -3, 9, -4, -2, 2, 7, -4 },
- { 2, 9,-18, 7, 29,-24, -1, 7, 14, 10, 3, -3, -2, -5, 6,-10,
- -6, -3, -8, 0, 5, 1, 4, 3,-12, 2, 6, 1, 3, 4, 1, -3 },
- {-20, 2, 8, 20, -9,-24, -4, 18, 3, 11, -1,-11, 6, 9, -1, -3,
- 1, -1,-15, 3, 15, 9, 3, 2,-13, 2, -8, 8, 1, -1, 1, -8 },
- {-12, 5,-11, 6, 19,-26,-17, -6, 4, 14, 6, -8, 9, 5, -6, -5,
- 2, -1, 20, 1,-11,-10,-18, 20, -7, 0, -3, 4, 2, 0, 10, 4 },
- {-15, 1, -2, 13, -8,-21,-22, 4, 4, 3, 3, -7,-31, 4,-10,-14,
- 0, 8, 4, 5, 8, 11, 2, -8, 6, 7, 0, -2, 6, 8, 8, 7 },
- {-13,-10, -9, 12, 19,-16, -3, -2, 9, 2, 11,-29, -1, 9, 4, -3,
- 1,-10,-10, 16, 1, 7, -7, -6, -4, -1, -5, 3, 6, 0, 3, 1 },
- {-17, -1, -5, 19, 12, -9,-21, -5, 2, 12, -7, -7, -3, 8, 7, -2,
- 6, -9, -9, 1, -4, 1, 1, 3,-14, 2, -8, 0, 10, 1,-12, -6 },
- {-13, -5, 8, 15, 0,-20, -2, 20, 8, -8, 8,-19, 12, 10, 2,-11,
- 0, 12, 1,-11, 0,-11,-15, 5,-11, 2, 4, -4,-11, 5, -4, -5 },
- { 3,-11, -7, 8, 0,-17,-26, 15, 19, -7, 10, -9, -5, -5, 14,-25,
- 0, -8, 2, -9, -3, 9, 1, -6, 4, -4, 3, -9, -1, 6, 2, 2 },
- {-12, 5, 5, 9, 14,-18,-19, 4, 2, 16, 14,-21,-15, -9, -1, 16,
- 12,-11,-10, -5, -7, 4, 15, -8, -5, -1, 1, 14, 13, -7, -1, -4 },
- {-10, -5, -1, 8, 7,-23,-10, 14, 6, 11, 10,-16, -3, 16, 6, 0,
- 0, 9, 6, -2, -7, 1, 22, 5, 3, -8, 0, 3, -2,-10, 3, 0 },
- { -2,-14, 2, 16, 15,-17,-17, 6, 19, 4,-10,-15, -1, 15, 11,-14,
- -8, 5, 8, 8, -2, -8,-11, 10, 10, -8,-14, 2, 13, 4, -2,-12 },
- {-10, 3, 6, 4, 19,-23,-19, 1, 4, -9,-30, 3, -6, 18, 0, 2,
- 0,-11, 0, 3, 7, -2, 8, 5, 2, -3, 6, -9, 1, -4, 7, -6 },
- { 9, 5, -2, 21, 20,-33,-13, 7,-10, 8, 8,-15, -6, -4, 1, 5,
- 3, 7, -2, -9, -1, 4, -6, 1, 0, 9, -1, -5, 2, 1, -3, 3 },
- { -9, -3, 3, 15, -3,-30, -7, -7,-25, 6, 2, -6, 1, 19, 1,-12,
- 1, -8,-13, 9, 13, 1, 8, 2, 5, 15, -2, 3, -9, 0, -4, 4 },
- { -6,-12,-17, 25, 22,-13,-10, 9, 2, 11, -7,-16, 4, 6, 1, 0,
- 0, 18, -4, -5, 4, -2, -1, -5, 0, -4, 6, 1, 6, -1, 7, 0 },
- { -1, 0,-10, 8, 8,-27, 0, -2, 29, 16, -2, -4, 9, -1, 2, 0,
- 6, 10, 6, 4, 2, -7, 9,-18, 3, 3, 3,-10, 17, 10, 9, -6 },
- { -3,-12, -6, 11, 20,-32, 5, 21, 3, -4, -9, 2,-10, 1, 7, -4,
- 5, 0, 0, -1, -8, -9, -7, 4,-10, 5, 0, 2, -5, 4, 9, 1 },
- { -5, -1, -5, 1, 2,-19,-13, 1, 6, 12, 2,-16,-17, 11, 10, 13,
- 16,-12,-11, 3, -6, 0, 6, 4, -3, 1, 8, 2, 5,-11, 3,-14 },
- {-19, 5, 10, 11, 2,-23, -9, 16, -2, 7, 0,-11, -7, 10, 6, -7,
- 26,-15, -4, 8, 6, -4, 7, -9,-15, 1, 8, -4, 4, 2,-12, 16 },
- {-11, 1, 11, -4, 1,-31,-13, -1, 8, 5, 4, -2, 0, 13, 7,-17,
- 7,-10, -6, 1, 4, -1, 2, -9, -4, 9, 3, 3, -4, -5, 3, 4 },
- { -3, 1, 10, -1, 0,-15,-22, 4, 40,-11, -4, -3,-14, 9, 11, -1,
- 9, -1, -6, 6, 3, -6, 0, 0,-12, 7, -2, 0, 9, 3, 1, 3 },
- { -1, -1, -1, 14, 8,-24,-14, -8, 5, 8, 5,-12,-17, 8, 2, 7,
- 10, -8, 0, 4, -6, -6,-10, 8, 4,-12, 3, -9,-12, 5, 4, -3 },
- { -5, 1,-11, 8, 9,-24, 0, 2, 2, 14,-12,-13, 1, 6, 7, 0,
- 7, -6, 9, 26, 11,-14, 8, 10, 1, 9, 0, 11, -2, 6, 2,-10 },
- {-13, 1, 4, 34, 19,-17,-15, 0, 3, -2, -7, -1, 0, -3, -3, -1,
- 1, -1,-10, 8, 5, 0, -8, 4,-17, 9, -2, 0, 0, 6, 2, -3 },
- { -6, -4, 1, 2, 2,-14,-29, 0, 9, 34, -3, -5,-14, 6,-10, -9,
- -5, -1, 0, 3, 3, 0, 1, -1, -2, -1, -1, -3, -3, -4, 3, -3 },
- { -4, 6, 3, 14, 14, -8,-29, 31, 11, 14, -4, -5, -6, 10, 6, -9,
- -1,-11, -7, 1, 7, 4, 1, -6, 4, 0, 10, -7, -5, -1, 2, 4 },
- { -4, -4, -2, 14, 6,-32, -6,-14, 14, -5,-11, 10,-18, -4, 6, -8,
- 9, 5, -4, 1, -4, 5, -2, -9, 3, 5, 2,-10, -6,-17, 3, 17 },
- {-16, 9, 21, 19, 4,-20,-17, 14, 9, 15, -6,-17, -1, 1, 6, -3,
- 1, 1, 8, -3, -6, 6, 9, 4, 9, -9, -5, 1, -1, 0, -1, 2 },
- { -7, -5, 3, 19, 1,-20, -9, 14, 21, -7,-18, -9, 26, -7,-17, -7,
- 12, 6, 0, -9, -6, 14, 9, -9, -8, 4, 15, -7, -9, -1, 9, 1 },
- {-20, 30, -6, 11, 24, -4, 0, -6, -2, 8, -4, 12, -8,-17, 0, 5,
- -4, 1, -1, 3, -3, 5, 3, 3, 7, -2, -3, -2, 4, 0, 0, -1 },
- {-35, 17, 6, 1, -9, -1,-16, 3,-20,-13, 8, 7, -4, -7, -4,-20,
- 7, 12, -5, 5, -5,-11, 12, -1, 15, -9, -6, 16, -4, -9,-13, 4 },
- {-21, 36,-19, 9, 0, -7, -8, 9, -4, -3, 3, 0, 7, -8, -2, -2,
- -11, 13, -1, 5, -3, 7, 2, 3, -1, -2, -5, 1, -1, -2, -5, -3 },
- {-12, 33, -4, 1,-12, -9, 0,-13, -1, 2, -8, 4,-10, 6,-16, -7,
- -1, -4,-10, 15, -1, 0, -5, -8, 5, 5, -3, 0, 2, -7, 1, -7 },
- {-14, 32, 5, -7,-15, 3, -5, 8, 14, 5, 9, 13, 3, 18, -3, 7,
- 4,-10,-10, 10, -1, 2, 0, -2,-11, 5, -3, -4, 2, 2, 7, 4 },
- {-14, 34, 1, 20, -1,-12, 0, -3, -7, -4, 7, 18, 9, -3, 14, -7,
- -9,-20, -7, -4,-13, 12, 1, 12, 5, -6, 2, -4, 0,-15, 1, 3 },
- {-21, 23, 7, -8, 3,-13, -3, 0, -6, -2, -7, 6,-12, 9, -6, -2,
- -2, -4, -1, 6, 9, 5, -9, 15, 0, 8, -8, 7, 6,-15, 3, -5 },
- {-27, 32, -1, -4, -2, 4,-10, 12, -3, 8, 13, 7, 0,-15, 4, -2,
- 3, 5, 7, -4, 9,-12, -1, -2, -1, -4, 0, -4, 2, -5, 6, -6 },
- {-17, 29, 15, 0, -1, -4,-10, 13, 12, -1, -8,-10,-10, 4, 7, -2,
- 6, -5,-13, 19, 6, 1, -7, 2, -9, -2, 12, -4, -8, -3, 2, 4 },
- {-38, 27, 16,-15, -6, 3, -7, -4, 0, -1, 6, -2, -3, -6, 6, -6,
- -3, 0, 2, 0, -4, 6, 1, -1, 0, 4, -1, 3, 4, 1, -2, 5 },
- {-33, 40, -4, 2, 1, 0, 0,-10,-14, 0, -7, 4, -1, 3, -2, 5,
- 7, 6, -1, 4, 1, 3, 1, -7, 1, -4, 5, 7, 0, 4, 3, -4 },
- {-20, 25, 12, -4, 16, -4, 2, 2,-14, -2, -3, 29, -1, 1, 3, 1,
- 9, -5, 2, -8, -3, 1, -7, -2, -7, 1, 0, 4, 16, -2, -1, -1 },
- {-10, 30, 17, 3, -5, -2, 0, -5,-22, 4, 5, 5, -3,-18, -6, 10,
- -5, -7, 2, 8, 7, -7,-11, -2, 0, -3, 3, 2, 11, -4, 4, -4 },
- {-11, 30, 11, 4, -3, -8, 1, -2, 4, 18, 3, 1, -1, 0, -8, -4,
- -3, 10, 13, 14, 5, -5, 1, 1,-10, 2, 15, 4, 9, -1, -5, -3 },
- {-17, 32, 18,-18, -3, -5, 6, 10, 1,-15, -5, 9, 8,-12,-10, -6,
- 11, 9, -5, -8, -7, 10, 5,-10,-14, -4, -3, 1, 9,-11, 2, 1 },
- {-13, 28,-11, -1, 2,-16, -2, 7,-24, 0, 3, 6, 3, -1, -8, -7,
- -12, 2, 2,-20, 10, 4, 0,-13, -2, -2, 1, 8,-14, 0, 4, 1 },
- {-14, 23, 12, 8, 8,-26, 2, -4,-14, 13,-14, 15, 3, -9, -1,-13,
- -10, -2,-10, 6,-16, 12, 8, 0, 9,-10, -7, -4, -4, 7, -8, 8 },
- {-20, 45, 10,-14, 4, 16, 8, -9, 1, -8, 10, 5, -7, -2, 2, -5,
- -1, 0, -5, 4, -6, -2, 4, 1, 3, 4, -4, 2, -2, -2, 5, 1 },
- {-20, 26, -4, 1, 7, 4, -8, 1, -5,-13, 2, 13, -7, -3, 6, -6,
- 22, 0, 5, 11, -4,-11, 8, -9, 2, -2, -4, -2, 2,-13, -4, -8 },
- {-28, 18, 17, 3, -8,-23,-16, -6, 5,-10, 14, 10, 5, -1, -8, 4,
- -2, 13, -3, -2, 3, 4, 3, -2, -3, -4, 0, 1, 3, 4, 0, 4 },
- {-12, 32, -6,-16, 18, 12,-16, 0, 7, 13, -4, 5, -8, -1, -3, 4,
- 6, -2, -1,-13, 4, -1, 3, 12, -3,-10, 1, 6, 8,-11, -2, 4 },
- {-18, 26, 2, 5, 0, -9,-17, 14, 5, 1, 7, -3, -8, -3, 11, 7,
- -5,-12, -8, 7, 0, -7, 2,-12, -9, 13,-11, 9, 6,-11, -5, 11 },
- {-24, 22,-15, -9, 8, 1, -7,-12, -9, 3, 11, 15, 14,-11, 12,-15,
- -5, 7, -2, 0, -8, 3, 3, -1, 2, 11,-11, 14, -6, 13, 1, -6 },
- {-20, 28, 18, -4, -6, -5, 12, 14, 2, 10,-13, -6, -8, -6,-13, -1,
- -26, 22, -3,-14, 6, 0, 10,-15,-13, -9, 6, -7, 1, -5, -4, -1 },
- {-19, 26, -8, -3,-14, -6, -9, -4, -8, 15, -8, 3,-12, -4, -2, -7,
- -5, 3, 13, -3, -4,-25, 4, -1, 5,-12, -1,-13, 5, 2, 0, 6 },
- {-18, 43, 14, -8, 1,-23, -2, -2, 1, 3, -7, 0, 0, 8, -1, -3,
- -5, 1, 5, 2, 0, -2, -2, -2, 1, -1, -1, -7, 0, 3, -3, 9 },
- {-11, 30, 10,-14, 3, 1, 10,-11, 1, -7, -4, 14, 2, 1, -9, 1,
- -11, -2, -7, 5,-11, 1, 3, 14, 1,-16, -8, 3, -5, 7, -4, 4 },
- {-18, 24, 6, 3, 8, 7,-22, -7, -7, 3, -8, 4, 23, 9, 3, -1,
- 3, 6, 7, -1, -7, 6, 4, 1, -3, 1, -6, -1, 2, -7, 3, 3 },
- {-15, 38, -7, -1,-11, 2,-17,-24, 24, 8, 7, -4, -5, 2, 2, -7,
- 1, 4, 0, -9, 5, 0, -1, 1, -1, -5, -6, 3, 0, 7, 8, -3 },
- {-14, 22, 1, -5, 9,-12, -9, -5, -6, 5, 7, 8, -1, -4, -9, -3,
- -33,-16, -9, -1, 12,-11, 17, -7, -3, -1, -7, 3, 2, -3, 16, -4 },
- {-14, 20, 6, 4,-10, -4, -4, -4, 1, -7, 2, 6, 8,-12, 4, 1,
- -1, 12, 10, 3,-14,-10, -3, 18, -2, 33, -5,-17, 17, -5, 9, 7 },
- {-12, 23, 13, 0,-11, -8,-11, 12, -5, -9,-16, 11, 6, 4, 12, -5,
- 5,-13, 7,-12, -3, 1, 2, 12, 1, -4, -1, 5, 4, 11,-12, -3 },
- { 15, 2, 14, 7, 1, 2, 1, 12, 10, 23, 4, 6,-20,-10, 4, 26,
- -6, 13, 4, 3, 2,-11, 5, -7,-10, 4, 9, 1, 10, -4, 11, 4 },
- { 17, 15, 31, 17, 18, 16, 11, 24, 2, 4, 2, 3, -8, -3, 7, -3,
- -5, -7, -2, -6, -4, -5, -4, -1, -4, -2, -5, -6, 2, -1, 4, -2 },
- { 16, 8, 15, 14, 3, 7, 21, 9, 8, 15, 21, 6, 8, 12, 5, -5,
- 7, -3, 10, 2, -3, 8, 6, 0, 5, 5, 6, -3, 2, 4, 0, -5 },
- { 5, -4, 6, 12, 6, 13, 24, 17, -5, 17, -1, -6, -7,-10, -8,-18,
- 3, -2, 2, 7,-15,-11, 12, -3, -2, -2, -4, -7, 2, 0, 5, 5 },
- { 10, -6, 8, 11, 12, 20, 22,-11, -3, 15, -3, 15, -2, -2, 0, 2,
- 5, -8, 4, -5, -9, -4, -1, 2, -1, -3, 1, 3, 13, -1, 9, 7 },
- { -5, 8, 5, 11, 14, -5, 14, -9, 2, 35, 8, 15, 1, -2, 2, -2,
- 4, -9, -3,-14,-12, -2, -2, -4, -2, -8, -3, 1, -6, 3, 10, 0 },
- { 16, 0, -6, 15, -3, 4, 4, 3, 3, 20, 5, -4, 10, 9, -9, -3,
- -10, -2, -7, 11,-11,-10, 17, -1, 3,-15, 2, 9,-15,-10, 16, 10 },
- { 14, 4, -7, 19, 3, 0, 19, 8, 16, 34, -9, 6,-13, -1, 6, 5,
- -1, -2, 4, 3, 2, 1, 1, -1, 0, -7, 2, -1, 1, 0, 6, -1 },
- { 1, 6, 9, 13, 9, 10, 15, 16, 10, 18, 13, 17, 3, -1, -7, 2,
- -15,-11,-10, -4,-13, -6,-17,-13, -6,-14, 1,-10, 6, 4, -1, -1 },
- { 13, 1, 7, 10, 14, 13, -7, 5, 5, 28, 14, 14, -2, 2, 3, -3,
- -13, -4, 10, -9, 19, -4, -3, 4, -5, -5, 0, 5, -5, 0, 3, -4 },
- { 1, 0, 6, 22, 9, 18, 18, -3, 5, 10, 12, -2, 1, -3, -8,-12,
- 9,-10, -7, 1, -1, 19, 0, 2, -8,-11,-10, 9, 6, 11, 0, 3 },
- { 10, 11, 19, 44, 0, 14, 1, -7, 6, 22, 2, -1, 9, 2, 0, -4,
- 4, 0, -6, -6, 3, 0, 0, -2, 2, -5, 1, -2, 0, 1, 1, 1 },
- { 5, 7, 0, 32, 30, 26, 5, 4, -7, -3, 15, -6, 3,-10, 7, 6,
- -8, -7, 2,-13, -5, -1, -3, 7, 3, -2, -8, 0, 6, 4, 5, 0 },
- { 9, 8, -2, 4, 2, 11, 4, 29, -5, 14, 8, -5,-14, 8, 0, 9,
- 8,-10, 5,-15, -6, -9, 9, -1, 18,-16, 9,-21, -3,-13, -2, 8 },
- { 25, 7, -9, 23, 20, 18, 6, 16, -9, 8, 8, -5, 11, 13, -8, 7,
- 4, 10, -2, -1, -7, -9, -7, -9, -4, 1, 1, -5,-10, 8, 4, -5 },
- { 9, 2, 16, 14, -5, 14, 1, 0,-21, 17, -1, 9, 12, -3, -3, 4,
- -4, 14, 10, 3, 0,-10, 7, 4, 4,-11, 2, 4, -1, -3, 9, -1 },
- { 17, 8, 11, 26, 15, -3, 14, -1, 12, 9, 10, -8, 8,-18,-11, -3,
- -14, -7, 7, -3, -3, -4, 1, -7, -3, 2, -3, 16, 10, 0, 9, 6 },
- { 9, 8, 3, 8, 18, 14, 11, 1, 10, 6, 1, -4,-16, -2, 14, -2,
- 1, 8, 12, 14, 3, -3, 8, 8, 12,-15, 3, -3, 3, -2, 14, 10 },
- { 22, -3,-11, 13, -7, 11, 4, 11, 3, 14, 0, -6, -2, -9, 4, 2,
- -2, 0, -5,-27,-10, 3, -1, 5, 8,-24, -3,-11, -3, 2, 11, -1 },
- { 19, 2, 8, 36, 5, -6, 3, 15, -3, -4, -5, 14,-10, 1,-12,-10,
- -3, -4, 3, -2, 1, -8, 4, 3, 5, -3, 0, 4, 8, -2, 8, 4 },
- { 8, 14, 15, 9, -4, 10, 5, 11, 9, 10, 8, 9,-15, 15, 6, -8,
- -10,-13, 5, -8,-20,-13, -6,-11, -1, -3, -6, -4, -1, 0, 13, 15 },
- { -2, -1, 9, 12, 2, 2, 13, 3,-23, 33, 15, 2, -4, -1, 3, 8,
- 8, 6, 6, -7, 8, 6, 9, -1, 3, -8, 0, -4, 1, -8, 11, -1 },
- { 6, 5, -6, 16, 2, -3, 31, 21, -9, 12, 0, -1, -4, 1,-12, 3,
- -13,-18, 2,-11, -9, 2, -8, -6, 11, -3, -1, 0, -1, 0, 13, 5 },
- { 5, -1, 2, 0, 25, 5, 10, 16, -5, 21, 14, 12, 13, 2, -5, 5,
- 5, -3, -2,-14, 0,-12, 7, 11, -1, -7, 19, -1, -1, -1, 8, -1 },
- { 10, 7, 3, 11, 0, 8, 22, 3, 3, 19, -4, 12, 15, 9, 5, 15,
- 2, 1, 2,-10,-10, 0, 2, -1, 0, 1,-12, -1, 21, 16, 9, -7 },
- { 11, -4, -5, 24, -7, 11, 20, 11,-15, 18, 5,-13,-15, 0, -5, 9,
- 1, 0, -1, -9, 4, -8, 6, -8, 1, -2, -7, 20, 9, 3, 9, 3 },
- { 20, 0,-12, -6, 9, 31, 9, 12, 8, 27, 15, 7,-16, 5, -3, -7,
- -1, -9, -2, -7, -3, 4, -8, -3, 3, -6, -2, -2, -3, -6, -1, 2 },
- { 6, -6, 48, 8, -3, 19, 12, 11, -7, 2, 3, 0, -1, 1, 8, -4,
- 4, -6, 0, -4, -4, -3, 3, 6, 3,-13, -8, 5, -3, -7, 8, 5 },
- { 7, -2, 6, 11, 12, 2, 14, 4, -5, 12, 2, 9, 4, 2, 0, -1,
- 2, 0,-15, -9,-16, -2, 8,-17, -5,-22,-19, -5, -1,-10, 1, -2 },
- { 11, -9, 3, 12, 6, 6, 1, 17, -6, 19, 14, 7, -7, -1, -1, -9,
- 9,-11,-17, 0, -6, 16, 0, 1, 9,-24, 3, 3, -9, -3, 3, -2 },
- { 9, 0, 1, 8, 1, 7, 2, -5, -3, 8, -1, 7, 2, 6, -3, -6,
- 5, -2, 6, -2, -4, -3, 0, -3, 13,-50, 1, -2, 2, 4, 4, 3 },
- { 7, 0, 26, 21, -4, 2, 17, 8, 7, 11, -7, 1, -1,-15, -1,-15,
- -11, -4,-17, -4, 1, -7, 3, 6, 3, -9, 2, 3, 6, 10, 6, 12 },
- { 1, -2, 2, -1,-10, -4, 6, -3, -5, -2, -8, 2, 2, 2, 8, 0,
- 1, 1, 6, 0, 11, 13, 3, 4, 0,-12, 11, -5, 19, 20, 2, 5 },
- { 5, 3,-13, -2, 1,-12, 11, -7,-12, 7, 10, 0, 7, 0, -2, 4,
- -6, -9,-11,-12,-23, 12, 10, -3, 0, 6, 19, -1, 24, 18, 9, 12 },
- { 6, -3, 2, 5, 2, 2, -2, -5, -8,-11, -4, 3, -8, -4, 5, -3,
- -16, -4, 3,-12, -4, 3, 32, 7, 2, 8, 32,-18, -1, 12, 1, 7 },
- { 0, -8, -1, 0, -8, 7, -8, -1, -1, 4,-12, -1, 3, 0, 1,-18,
- 8, 8,-14,-10,-11, 19, 9, 5, -7, 6, 8, -4, 26, 12, -1, 6 },
- { 3, 5,-14, 7, 14, 8, 20,-13,-16,-10, -2, 17, -7, 4, -8, -9,
- 14, -5, 3, -4,-12, 7, 14,-10,-19,-20, 35, 8, 13, 14, -2, 9 },
- { -2, -4, -1, 1, -3, 0, -1, 1, 2, 2, 6, 0, 0, 4, 5, -2,
- 3, 3, 3, -2, -7, -3, -3, -1, 6, -2, 29, 22, 13, 34, 0, 14 },
- { -3, -9, 3, 1, 5, -4, 2, 0, 7, -9, 0, 2, -5, -3, 0, 6,
- -1, -1, -1, 2, 2, 4, 8, 7, 20, -6, 7, 16, 33, 20, 6, -1 },
- {-11, 1, -3, -3,-11, 3, -9,-25, -1,-16, 4, -8, 15, 1, -2, 7,
- 8, 23, 2, 18,-13, 16, 3, -7, 6, 3, 16, -8, 12, 16, 3, 4 },
- { 0, 5, 5, -5, 1, -1, 2, -3, -2, 1,-13, 2, 2, 10, 6, 7,
- 18, 18, 7, 9, 8, 9, 21, 14, 7, 12, 15, 14, 15, 12, 11, 5 },
- { 1, -5, 11, -2, 17, 8, 3, 0, -1, 6, 11, -7, 6, 6, 7, 5,
- -15, 14, 1, 11, 4, 10, 12, 1, 2, 4, 30, 1, 11, 1, 6, 13 },
- { 2, 4, 3, -7, 5, 8,-11, 7, -5, 9,-10, 6, 8,-10, -3, 10,
- 1,-29, -4,-26, 5, -8, 13, 4, 3, 6, 35, 1, 3, 6, 3, 0 },
- { -2, 1, 0, 0, -1, -3, -7, -3, -9, -3, -1, -6, 3, 4, 4, 0,
- 5, -1, -2, -2, -1, -4,-10, 8, 0, -6, 10, -4, 46, 12, 2, 28 },
- { 4, -1, 4, 1, 0, 4, -2, -2, -2, -1, 2, -4, 1, 5, 0, -3,
- 1, 1, -2, 0, 1, -2, -1, -1, 3, -6, 35,-11, 13, 53, -3, -1 },
- { -5, -2, 0,-13,-16, 5,-12,-11, 1,-30, 3,-18,-24, -8, -5,-19,
- 1, -3, -8, 7, -7, -8, 15,-19, 4, 10, 30, 24, 6, 1, -9, 10 },
- { -4, 8, -7, -4, -6, 12, -1, -9, -4, 2, -9, 3, 2, -2, 4, 2,
- 22, 9, 4, -5, 0, 5, -2, -9, -3, 1, 18,-12, 18, 16, 4, 16 },
- { -5, -8, -3, -5, -3, 6, -7, -3, -2, -5, -3, 1, 2, 2, 4, -6,
- 10, 3, 12, -3, 20, 0, 27, -4, 16, 5, 18, -3, 23, 4, 12, 11 },
- { 0, 1, 0, 1, -2, 1, 2, 1, -1, 0, -2, 2, -2, -4, 1, -2,
- -2, -1, -5, -2, 0, 0, -2, 2, 9, 7, 63, 5, 12, -1, 1, 0 },
- { 4, -3, -7, -5,-11, -5,-12,-10,-10,-12,-15,-12,-14,-14, 1, 1,
- 10,-10, 16, 6, 2, 9, 11, 9, 9, 8, 12, -1, 13, 12, 6, 3 },
- { 7, -3, -2, 4, 6, -8, 2, -3,-12, -5, -9, -8,-10, 15, -2, -4,
- 8, 9, 7,-13,-18, 34, -5, 7, 12, 22, 16,-11, 13, 25,-15,-11 },
- { -3, -2, 0, -4, 1, 0, -3,-13, -7, 13, 12, -7,-10, 13, 19, 6,
- 16, 15,-12,-15, -3, 34, 1, 5, 1, -9, 11, 21, 8, 17, -5, -6 },
- { 3, -5, 0, -4, 0, 4,-11, 4, -7, -3, -1, -8, 3, -2, 2, 1,
- 11, 5, 6, 14, -3, 2, -4, -7, 0, 31, 15, -2, 24, 11, 5, 4 },
- { -1, -4, -9, 5, -8,-18, -4, -9,-20,-18, 7,-14,-16, 3, 8, -3,
- 29, 11,-13,-13, 7, 1, 17, 6, 6, 21, 11, 1, 14, -8, 2, 5 },
- { -3, 8,-10, -6, 12, 2, 1, 3, 3, 3, 3, -6, -8,-14, 15, -5,
- 16, 4, 16, 0, 7, -1, 0, 16, 2, 1, 22, 4, 19, 13,-11, 1 },
- { 2, -3, 10, 20, -4, -1, -8, 5, -8, -9, -6, -2, -4, -7, 8,-10,
- 0, 8, -6, 1, -8, 14, 13, 5, 17, -6, 26, -1, 7, -1, 0, 12 },
- { -4, -7,-31, -2, -7, -1, 5, -5, -5,-12, 4, -7, -6, 3, 15, -2,
- 5, -2, 7, -1, 10, 7, 8, -1, 14, 20, 14, 9, 16, 16, 8, 24 },
- { -7, 0, -3, -6, 1, 3,-13, -6, -4, -4, -5, -9, -1,-10, -4, -8,
- 2, 0, -1, 1, 24, 24, 21, 31, 5, 2, 11, 12, 7, 4, 3, 6 },
- { -3, -5, 6, -4, -3, -1, 2, -1, -2, 1, 0, -8, -1, 2, 0, -4,
- 6, 22, -1, -5, 8, 12, -1, -2, 28, 27, 20,-27, 14, 1, 2, -3 },
- { 1, -5, -2, -2, 6, -2, 9, 1, -2, -5, 3, 4, 11, 5, 2, 8,
- -3, -1, 1, -2, -3, -5, 5, 8, 49, 12, 8, -3, 9, 20, 12, 17 },
- { -6, 0, 1, 7, 0, 9, -2, -4, 8, 0, -2,-10, 0, 7, 21, -1,
- 0, 1, 17, -7, -5, 2, 4, 16, -2, 17, 14,-20, 15, 14, 4, 15 },
- { 0, 3, -4, 9, -4, 0, 6, 4, -6, -6, -5, -7, 2, -9,-10, -2,
- -5, 0, -3,-21, 9, 14,-11, 13, 29, 2, 25, 4, 22, -1, 2, -3 },
- { 2, 12,-11, 2, 16, 9, -4, 7, 1,-10,-15, 11, -4, 3, -2, 4,
- 4, -5,-10, 1, 4, 19,-15, 6, -4, -2, 30, -7, 11, 21,-12, 5 },
- { -2, -3, -2, 4, -1, -5, -3, -7, -5, 1, 0, -6, 1, -6, 7, 0,
- 8, -7, -3, -2, 2, 14, 2, -3,-26, -1, 26, 22, 32, 1, -2, 6 },
- { 1,-38, -1,-20, -2, -3, -6, -4, 2, 2, 7, 0, 3, 5, 3, 10,
- 6, 1, -3, -5, 7, 5, -5, -4, 8, 3, 1,-14, -1, -9, -5, -4 },
- { -5,-26, -7,-19,-10, -5,-11, 5,-11,-25, -8,-14, -9,-16, -8, -6,
- -17,-14, -1, -1, 6, 2, 2, 2, 3, 0, 2, 8, -8, 3, 0, -3 },
- { 17,-49, -3,-23, -1, 11, 7, 3, 4, -4, 0, 0, -1, 4, 2, 4,
- -2, -4, 2, -2, -1, -2, 2, 0, 0, -1, 0, 0, 1, 2, 0, 0 },
- { 4,-34, -6, -9, 1, 21, -7, 3, -2, -1, -3, 18, 2,-16, 7, -3,
- 8, 7, -5, 7, 2, 4, 8, -6, -7, -2, -5, -1, 4, 1, 2, -4 },
- { 5,-29, 13, -2,-14, 3, 1, 18,-15, 4, -8, 8,-10, 8, 2, 1,
- -8, 15, 3,-10, -4, -4, -2, 0, -3, -4, 2, -3, -4, -3, 12, -6 },
- { 13,-20, 3,-18,-17, 4,-14, 13, 28, 11, -8, -6, 16, 6, 0, 10,
- 3, 4, -9, 13, 5, -7, 12, -5, 0, -7, 5, 1, 3, 3, 2, 1 },
- { 3,-27, -5,-11,-21,-11,-12, 0, -5, 7,-22, 1, 3, 5, 0, -5,
- 8, 7, 1, -5, -7, 2, -5, 4, 1, 3, -8, -2, 0, 4, -2, 6 },
- { 31,-45, 0, -1,-12, 1, 2, -6, 4, 3, -1, 3, 3, 0, 5, 3,
- -5, 12, 4, 6, 2, 1, -2, 1, 3, 2, 5, 2, 2, 2, 3, -1 },
- { 9,-45, 6, 5, -1,-17, -2, 18, -3, 2, 0, 1, 0, -1, 10, 8,
- -7, -2, -5, -8, 6, -1, 0, 4, 6, -3, 12, -1, -2, 0, 5, -7 },
- { 3,-26, -2,-12,-12, 2,-10, 16, -3, 12, 4, 5, 11, 8,-16,-17,
- -2, -3, -3, 2, 5, -9, 13, 1, 10, 11, 3, 5, -2, 2, 2, -7 },
- { 8,-26, 32, -7, -5, 22, 2, 14,-10, -8, -7, 3, 3, 7, 0, -5,
- 0, -1, -3, 0, 8, 4, -5, -7, 6, -1, 4, 8, 1, 1, 7, -6 },
- { 4,-31, 2,-14, 2, 0, 1, 8, -6, -1, 17, -3, 13, -6, 5,-10,
- -2,-10, -2,-10, -3, 7, 1, 5, -8, 8,-14, -3,-15, 7,-10, -6 },
- { 16,-27, 13, -4,-23, 7, -9, 6, -7, 5, 4, 2, -1, -3, 23,-18,
- 7, 0, -3, 4, -3, 9, -6, -2, -1, 8, -6, 2, 6, -3, 2, -2 },
- { -1,-35, -2, -8, 11, -1, -7, -3, -2, 11, 7, 6, -6,-10, 9, 6,
- -3, -5, -6, -3, 9, 16,-16, -9,-20, 12, 3, 5, -3, 1, -9, 4 },
- { 2,-24, 1,-12,-16, 5, -4, 3, -4, -1,-11,-11, -8,-14, 14, 10,
- -8, 20, 8, -3,-11, 1, 1, -4, -4, -7, -3, 15, 2, -6, -2, 7 },
- { 9,-21, 2,-19, -7, -5, -8, 25, 3, 17, 5, -3, 9,-12, 8, 2,
- -4, 3, 3, 1, 11, -9, -4, -3, 4, 3,-22, 6, 4, 6, 11, -5 },
- { 16,-23, 13,-17,-21,-12, 5, 9,-20, 7, 6, -6, 0, 2, -9, 6,
- -6,-13, -7, -1, 5, -3, 5, -7,-10, 1, 0, 8, -9, 11, 0, -8 },
- { 10,-26, -9, -7,-19, -4, 6, 16, -7, 5, -4, 4, 8, 0, 4, -1,
- 6, -7, 1, -8,-11, 10,-14, 0,-16, 6, -3, 5, -1, 14, 12, 1 },
- { 8,-27, 12,-14, -1, -1,-19, 10,-11, 21,-14, 9, -8, -3, 8, -1,
- 12,-13, 3, -4, -2, 0, -9, 0, -7, 2, -3, 12, 1, -3, 3, 1 },
- { 18,-20,-14,-14,-16, -3,-24, 6,-17, 2, -3,-11, 2, -3, 12, 10,
- 10, 1, 10, 7, 8, 5, 5, 4, -1, 7, 2, 2, 0, 4, 7, 0 },
- { 0,-30, 9,-16,-18, 15, 12, -3, 4, -4, -5,-11, -4,-12,-10, 0,
- 2, -2, -4, -1, 2, 0, -1, -6, 2, -3, 4, -5, 7, 3, 5, 7 },
- { 25,-24, -1, -6, -9, 6,-13, -2, 3, 15, -3, 11, 4, -8,-11, 2,
- 0, -9, -2, 7, 4, 8, 5, -8, 5, 6, -1,-11,-15, -5, 0, 11 },
- { 0,-34, -7,-11, -7, 9, -3, 19, 4, -8, 3,-11, 11, -3, -9, 12,
- 9, 9, 2, 1, -7, 1, -3, 0, -6, -2, -1, 3, 0, -7, -2, -5 },
- { 6,-34, -4, -5, -3, -9, 2, 9, -1, 9, -5, -3,-26,-12, 8, -6,
- -7, 11, -8, 4, 4, 1, -1, 0, 8, 9, -4, 7, -1, 1, -3, -1 },
- { 3,-30, 5, 6,-10, 3, -7, 6, 3, 3,-26,-19, -3, 1, 7, 5,
- -4, -5, 6, 10, 13,-10, 4, -7, -4, 5, -3, 9, -6, 3, 9, 5 },
- { 4,-24, 9,-19, 2, -4, -5, 8, -3, 2, 0,-15, -1, 9, -4, 22,
- 6, 9, 3, 7, 11, -9, 0, -3, 4, 5, -5, 10, -8, 5, -7, -3 },
- { 8,-27, 7, -3, -1, 2, -9, 13, 7, 12, -4, -6, -6, 5, 0, 7,
- 5, 1, 15, -3, -4, 0, -5, -2, 7, -5, -7, 1, -2, 13, -8, 13 },
- { 17,-22,-15,-11, -8, 16,-14, 18, 2, -1, 14, -7, 14, -6, -6, -7,
- -8, 17, 6, 4, 4, -7, -5, -9,-14, -6, -1, 9, -3, 1, 6, -5 },
- { 25,-30, 2,-12,-13, 18,-18, 16, 8, -3, 10, -8, -3, -1, -6, 3,
- -5, -7, 4, 6, 7, 1, 1,-11, -5, 6, 2, -4, 9, -1, -5, -2 },
- { 7,-23, 7,-15, -1, -3, -1, 0,-10, 12, 2, 5, -4, 0, 4, 6,
- -1, 5, -9, -1, -1, -7, 1, 17, 9,-17,-16, 8, 4,-14, 11, 14 },
- { 0,-31, 7,-13, 3,-11, -7, 6, 1,-11, 8, -7, 15, -3, 16,-11,
- -1,-15, 16, -3, 5, 0, -2, -2, -6, 11, 5, 6, 5, -5, 6, 3 },
- { 13,-24, -2,-20,-10, 7, -3, -1, 15, 2, 6, -5, -7,-10,-20, 1,
- -4, 14, 8, -2, 3,-13, -3, 1, -4, 1, -3, 2, 8, -7, 16, -4 },
- { 1, -2, -2, -3, -4, -7, 0, 3, 6, 7, 3, 2, 1, -2, -1, 0,
- -6, 4, 2, -4, -3, -4, 5, 9, 5, 0, -3, -3, -4, -7,-31,-50 },
- { -1, -3, 7, 2, -1, 2, 4, 6, 0, 10, -2, 0,-20, -6, -3, 9,
- -20,-22, -1, -1, 15, 9,-12, 10,-13,-20, 12, 3, 5, 6, -7,-26 },
- { 0, 4, -2,-14,-12, 6,-13, 11,-10, 3, 22, 6, 16, -2, -5, 1,
- -3,-11, 0, -7, 5, -5, 0, 1, -1, -6, 8, 8, 10, 9, -5,-27 },
- { -5, 10, -2, 7, 9, -9, 5, -9, 5, 4,-15, 14, 1, 3,-10, 5,
- 0, -2, 7, 3,-13, 6, 9, -6, 5,-14,-17, -1, 11, 14, -2,-26 },
- { 0, 6, -3, 0, -8, 6, 0, 1, 4, -8, 2, -5, 4, 7, 15, 11,
- 9, 19, -2, 14, -8, 7, -1, 3, -3, -3,-10, -2, 12, -2,-12,-29 },
- {-12, -5, 0, -3, -2, 6, 3, -3, 2, -2, 1, 11, 2, -7, 5, 1,
- 2, -2,-14, 0, -1, -5, 3, 8,-28,-26, 6, -6, 3, 8,-10,-27 },
- { -1, -3, 6, 2, 4, 15, 1, 0, 2, -2, -2, 13, 3, 6, 0, 6,
- -1, -4, -1, -5, 8, -1, 5, -5,-15, 11, -8, -5, 14, -6,-14,-29 },
- { -5, -6, 0, 1, 0, 6, -3, 2, -5, -1, 5, -3, 2,-10, 3, 4,
- 3, 0, 13, -3, -1, 4, -4, -6, 2, 9, 8, 2, -3, 28,-11,-31 },
- { 1, -4,-10, -9, -4, -3,-15, -6, 1, 5, -3, -6, 5, -6,-22, 27,
- -13, 5, 3, -7, -4, 20, -7,-12, -1,-24, -4,-13, -8,-11,-15,-21 },
- { -6, -4, 19, -6, 2, 11, -6, 1, -3,-10, 9, -9, 12,-10, 2, 1,
- -9, 1, 15, 7, -5, 5,-29,-35, 4,-30, 9, 9, 19, 17, 2,-17 },
- { -3, 3, -3, 1, 2, 5, -1, 5, -2, -3, 1, -3, -8, 3, -4, -2,
- -4, -1, 12, 0, 2, -8, -6, -4, 16, -1,-14, -2, 25, -6,-15,-36 },
- { 0, -1, 3, -4, -4, -1, 7, -4, 8, 0, 10, 9, -4, 1, 10, -1,
- -3,-13, -5, -4, -1, -4, 8, 11, 14, -7, -5, 16, 12, 13, -1,-28 },
- { 1, -2, 2, -3, -8, 10, 4, 9, 12, 3, 5, 0, 8, -3, -6, 2,
- 16,-11, 11, 0, 1, 6, 1, 18,-10,-16, -1, -4, 5,-14,-15,-20 },
- { 1,-12, 5, 4, -7, 8, -1,-17, -2, -9,-14,-11, 6, -9, 5, -4,
- 3, -2, 7, 18, -5, 5, 6, -1,-11, -2,-10, -3, 8, -3, -2,-32 },
- {-12, 5, 20, -5, -6,-11, -6, -6,-13, 4, -6, 19, -8, 2, 3, -9,
- -4, -4, -1, 9, -1, 21, -1, 7, 15,-10, -1, -3, 9, -3, 2,-24 },
- { 0, -3, 2, -6, 4, -1, -9, -2, -1, -3, 6, -1, -5, -6, -5, -8,
- 0, -2, -6, 9, -4, 3, 2,-13, 1, -7, 23,-13, 4, -3,-15,-33 },
- { -7, 2,-15, 11,-10, 14, 0,-11, 3, -1, 12, -4, -4, 9, 11,-13,
- -13, -3,-14, 1, 3, 6, -5, 8, 0, 5, 5,-10, 4, 5, -6,-30 },
- { -6, 4, 0, -5, 4, 1, -1, -1, 3, 6, 5, -2, -5, 0, -2, 5,
- -4, -2, -4, -2, 4, 7, -7, -1, 1, -4, -3,-19, 37, 12, 10,-40 },
- { -7, 2, -7,-12, 17, 11, -7, 2, 2, 3, 1, -1, 3, 4, -2, -5,
- 9, -9, 6, 4, 9, 12, 11, -5, 2, -1, 0, 9, 5, -7, -2,-24 },
- { -7, 6, 1, 3, 1, 0, 6, 0, 4,-12, -2, -2, 1, -9, 10, -2,
- 11, -1, 21,-12, 15, -5, 10, -5, 5, -5, 14, -6, 5, -7, -3,-29 },
- { -2, 0, -5, -2, -3, 1, -3, 0, 4, 2, 3, 0, 2, -2, 7, -2,
- 3, -5, 2, -1, 6, -4, 0, -3, 8,-11, 19, -8, 22,-34, 13,-35 },
- { -1, -3, -1, 9, 11, -3, -3, -1, 7, 18, 11, -5, 2,-12,-11, 18,
- 9, -5, 1, -6, -9, 12, 1, -3, -3, -9,-14, 9, 9, 8, -6,-26 },
- { 0, 5, -5, -1, -1, -2, 4, 6, 8, 2, -1, -2, 5, 1, -5, -4,
- 1, 1, 18, 1, 7,-10, 3, -2, 12, -1,-15, 9, 12,-14, 13,-38 },
- { 3, 0, -8, -1, 0, 8, -9, -3, -8, 16, 3, 16, -5, -9, 0, -1,
- -7, -1, -4, 13, 7, 0, 1, 2, -1,-16, 0, -2, 1, 8, -8,-28 },
- { 7, 9, -5, -3, -2, 2, 0, 3, 11, -6, -4, -2, -2, -5, 28,-18,
- -6, 2, 15,-10,-15,-10, -2, 0, -2, -2, 4, -3, 7, 11, 5,-30 },
- { 9, 0, -7, -1, -4, -7, 2, 2, 9, -2, 2, 3, -8, -6, -6, 3,
- -10, 4, 10, 5, 21, -4, 14,-18, 1, 3,-10, -2, 6, 14, -8,-26 },
- {-14, -1, 2, 3, -3, 7, 1,-22, -1, -1, 0, 1, 12,-14, 3, -5,
- 0, 10, -3, 1, -5, 12, -3, 10, -8,-22,-11,-13, -7,-10,-13,-25 },
- { -2, -5, -4, -4, -9,-18, 9, -3, -5, 17, 13, 5, 6, 11, 3, 8,
- 20, 4, 2, 9, 8, 5, 6, 1, 7, -7, -6, -2, -7, 0,-17,-23 },
- { -5, -5, 2, 0, 6, 2, -2, 2, -3, 4, 4, 0, -5, -2, -4, 6,
- 8, 10, -1, 1, -5, 5,-14, -2,-11, 8, 6, 25, 7, -1, 0,-43 },
- { -4, 0, 4, -2, 7, 0, 3, 17, 5, 2, -5, 1, 21, 3, -2,-10,
- -16, -9, 7,-12, 9, -8, 2, 5, -5,-10, -2,-11, -5, -1, -9,-30 },
- { -2, 3, 1, -4, -1, 0, 8, 1, 12, 4, -1, -1, 3,-17, 13, 9,
- 0, 7, -6, -5, 9, 1, 5, 4,-10,-18, 0, 14, 11, -4,-16,-28 },
- { -1, 0, 2, -1, 4, 1, -1, 1, -1, -2, -1, -2, 3, 0, 0, -1,
- -1, 1, 2, -2, 3, 3, -2, 4, -2, -1, -6, 1, -1, -1, 6,-70 },
- { 7, 3,-11, -1, 12, -4,-14, 4, 4, -4, 4, -2, 2,-12, -4, 15,
- -17, -4, -3, 6, 8, -5, 22,-22, 5,-11, 15, -4, 4, -1,-21, -1 },
- { 10, -2,-13, 11, 4, 14, 4, 9, 8, 8, 19, 15, 14, 15, 5, 10,
- 8, 15, -5, 4, 14, -8, 1, 1, 2, 1, -1, -3, 21, 8,-29, 13 },
- { -6, 0, -6, 6, -1, 2, 8, -4, -5, 4, -4, -5, 0, -2, -4, 0,
- 9, -2, 1, -2, 26,-19, 21,-10, 4, 1, -8, 5, 22,-10,-13, 15 },
- { 11, -5, 1, 0, 6, 3, 7, -2, -2, -3, -5, -1, -2, -6, 1, 1,
- -8, -5,-13, 13, -2, -3, -1, -9,-28, 4, 2,-11, 18,-20,-24, 9 },
- { 7, 4, -3, 6, 6, -6, -7, -5, -7, -4, -4, 0, -7, -5, -6, -5,
- 2,-13,-12, 2, 0, 5, 18, 15,-13, -7, 13,-20, 16,-10,-19, 6 },
- { 5, -8, -1, 5, 10, 2, -1,-10,-11, 23, 8, -5, -8, 4, -5, -4,
- -5, -5,-11, -8, 5, 1, 7, -9, -9, -6, 12, 14, 17,-12,-22, 3 },
- { -5, -8, -3, 3, 12, -1, 0, -4, -5, 1, 1, 6, 1, 5, -5, 7,
- -2, 7, 1, 6, 6, 2, 0, -5, 17, -4, -5,-24, 13,-20,-27, 14 },
- { -1, 2, -3, 1, -3, 1, -3, 0, -2, 3, -2, 1, 2, -1, -2, -1,
- -2, -5, 5, -2, 0, -7, 1, -6, 8, 8, 11, -5, 24,-43,-13, 2 },
- { -2, 4, 7, -3, -4, 4, 13, -4, 0, 0, -2, 9, 0, -3, -6, 1,
- -7, 1, -1, 10, 0, 5, -1,-24, 25,-15, 7, 2, 22,-10,-21, 0 },
- { -5, 2, 6, -2, 13, 3, 5,-12,-11, 16, 6, 10, -5, 0, -3, 6,
- 5, -5, -5, 10, 12, 10, 11, -7, 8,-14, 2,-15, 13,-14, -8, -3 },
- { 5, 6, -7, -5, 5, 2, 9, 5, 0, -1, -4, 2, 8, 0, 3, 5,
- -12, 3, -3, -6, 2, -1, -5, 14, 11,-20,-21,-25, 24, -1,-10, 6 },
- { -5, 5, -2, 9, 4, -4, -1, -6, 11, -6, 5, 0, 2, -3, 6, -1,
- -17,-18, -4,-13, 9, -1, 9, -7, -4, -8, 2, -3, 12,-31,-18, 5 },
- { -7,-11, 6, -8, 4, -3,-12, 0, -1, -6, -3, 0, 5, 9, 7, 2,
- 1, -8, -6, 8, 2, -5, 7, -1, 16,-10, 16,-12, 18, -1,-25,-12 },
- { 3,-12, 1, 2, -2,-18, -8,-15,-10, -9, 2, -7, 11,-11, 2, -1,
- -1, -1, -9, -6, 3,-14, -2, -1, 2,-13, -7, -9, 19, -5,-17, 2 },
- { 7, 1, -8, 7, 17,-13,-10, 5, 7, 1, -6, 4, 9, -4, 0, 3,
- 8, 1,-14, -9, 4, 7, -9, 0, 6, -5,-12, -2, 25, -2,-19, 1 },
- { 7, -3, 6, -3, 1, 6, -7, 0, 10, 0, 4, -5,-17, -4, 4, -1,
- 0, -3, -7, 19, 24, -1, 21, 8, 10, 9, 8, -1, 23, -2,-18, -2 },
- { 3, -3, 0, 5, 8, -2, -9, 2, 9, 6, 19, 8, 2, 6, -9, -2,
- -4, -3, -8, 7, -7, -8, 5, 4, 26, -6, 7, 18, 24, 0,-13, 4 },
- { 0,-13,-11, -1, 3, -9, 5, 4, -7, 3, 0, 2, -1, 4, -5, 2,
- 9, -2,-11, 15, 1,-21, 1, -1, 0, 4,-14, -4, 24,-16,-13, 1 },
- { 1, -9, -8, 0, 0, -4, 11, -1, 14, 16, 0, 17, -2, -9,-12, 0,
- -1,-14, -9,-14, 0, -2, 19, 4, 6, 4, 4,-11, 8,-17,-19, -5 },
- { -3, 1, 2, 12, -4,-18, -1, -4, -7, 14, -3, 2, 0, -7, -8, 12,
- -5, -9, 14, 12, -9, -2, 4, -6, 4, 18, -1,-25, 22, 2,-23, -5 },
- { -2, 0, 0, 0, 1, 3, 5, -1, 5, -2, -2, 2, -3, 0, 1, 2,
- 0, -1, 2, -1, -9, -6, -7, -4, -2, 4, -7, -5, 64, -3,-25, 4 },
- { 12, -2, -3, 0, 8, -9, 13, -7, 6, -3,-12, 12, 15, -9, -4, 2,
- 9, -4,-12, 3, 14, 1, 7,-15, 15, 0, -6,-12, 0, -3,-20, 6 },
- { 2, -1, -4, 5, 9, 6, -7, 2, -2, -7, -2, 0, -1,-18, -4, -6,
- -15, -5, 11, 5,-10, -1, 2, 7, 12,-19, -7, 8, 21, -4,-15, 4 },
- { 4, 2, 5, 5, -5, 1, 3, 2, -8, 13, 0, -5, -2,-14,-11, 6,
- 2, 17, 8,-13, 26, -2, 5,-15, -4,-14, 12, -9, 13,-21,-23, -4 },
- { 2, -3, -2, -3, 3, -2, 6, 9, -9, 13, 4, 2, 12, -3, -3, 1,
- -17,-22, -3, 4, 3, -2, 1, -9, 1, -6, 11,-13, 14, 0,-15, 6 },
- {-16, -4, 17, -2,-20,-11, 11, 10, 5, -8, 16, 2,-17,-14, 11, 11,
- -6,-11, -7, 12, 12,-10, -6, 5, 8, -4, -2, -5, 28, 3,-13, 4 },
- { 0, -3, 3, -7, 6, 8,-12, 20,-19, 18,-11, 10, -5, 0, -9, 11,
- 3, 0, -2, 9, -7, -5, 18, 3, -2,-16, 1, 6, 12, -7,-16, 1 },
- { 4, 1, 5, -5, 15, 2, -8, 3, 5,-11, 15, -3, 8, -8, -1, 7,
- 4, 7, -2, 6, -9, 5, 12, 2, 33, -2, -6,-18, 4, 0,-18, 11 },
- { 3, -1, 1, -1, 0, 1, 4, -1, -5, 0, 1, 0, 4, 2, -1, 4,
- -3, 2, 0, -2, 4, 6, -1, 6, 42, 19, -4,-37, 19, 1,-15, -4 },
- { 2, 0, -5, 0, 10, 0, 0, -5, 3, 0, 0, -3, -3, 0, 2, -4,
- -10, 2, -6, 4, 4, 1, 27, -7, 17,-34, 5, -9, 15,-16, -7, -5 },
- { -2, 7, 7, -2, 9, -2,-15, 11, 11, 7, 5, 1, 15, 1, -9, 31,
- 2,-15, 2, 4, 3, 4, -1, -8, 2, -7, 6,-17, 11,-14,-11, 2 },
- { 1, 1,-11, 9, 9, -6,-14,-11,-10, 8, -3, 11, 16, -9, -8,-13,
- -8, 9, 0, 6, 6, -2, 13, -8, -2, 3, 13, -3, 10, -6,-17, 4 },
- { 14, 5, 4, -6,-12, 10, -7, 8, 21, -8,-30, 15, -2, 1, 11, -9,
- -5, 1, 0, -1, -1, -6, -2, 3, -5, 7, 9, 5, -5, 2, 0, 1 },
- { -1, 2, 20,-17,-15, 3, 3, 7, 11,-17,-13, -6, -3, 18, 17,-15,
- -4, -4, -5, 22, 14,-14, -2,-10, -7, 11, 8, -7, -3, 0, -7, 11 },
- { 7,-11, -7, -8,-14, 22, 5, 2, 6, 13,-12, -2, 10, 3, 0,-21,
- -4, 20, 3, 10, 21,-10,-12, 8, 11, 2, -5, 2, 1, 3, -1, 15 },
- { -1, -2, -1, -2,-13, 8, -4, 0, 7, -2,-17, 8, 18, 5, 3, 8,
- -8, -2, 3, -4, 14,-18,-13, 14, 15,-13, -1, -2, 4, 11, 1, 12 },
- { 13, -6, -4,-16,-17, 16, 21, -2, 5,-11, -9, 19, 21,-17, -3,-17,
- 3, 12, 8,-12, -6, 1, -7, 9, 9, -7, -5, -1, -3, 5, -6, -4 },
- { 11, 5, 12,-20, -6, 10, 4, 12, 8, -5,-10, 15, 13, 14, 10,-15,
- -13, 1, 6, 14, 15,-17,-13, 4, -5, 10, 7, -6, -8, -3, -4, 12 },
- { 25, -1, 7, -5, -7, 11, 1, 17, 13,-15,-14, -4, 5, 3, 8, -3,
- -2, 2, 0, 6, 16,-12, -6, -4, 4, -3, 7,-10, -3, -7,-13, 7 },
- { -8, 10, -3,-13, 5, 2, 4, 9, 9,-17,-13, 2, 11, 1, 6, -4,
- 8,-10, 4, 1, 19,-15, -4, 12, 31, 7, -5,-17, -4, 9, -2, 7 },
- { 14, -6, -6, -6,-14, 13, 17, -5, 4,-14, -9, 7, 7, -9, 3,-16,
- -15, 11, 11, 6, 4,-11,-19, 3, 5, 8, 13,-14,-14, 3, -4, 12 },
- { -2, -4, 10, -4, -7, -1, 27, 5, 2,-16,-18, 4, 12, -2, -3, -2,
- -1, 1, -8,-12, 3, -4, 8, 15, 2, 4, 9,-13,-14, 9, -7, 5 },
- { 4, 2,-10, -5, -7, 2, 1, 4, -1, -6,-15, 6, 1, 10, 5,-10,
- -9, -1, 13, -3, 5,-21,-11, 8, 8, 5, 27,-21,-18, -5, -1, 15 },
- { 11, 1,-16, -8,-11, 0, 5, -8,-12,-13,-17, 22, 4, -6, -1,-18,
- -10, 0, 19, 2, -2, -8, -7, -3, 2, -2, -9,-17, -5, 4, 4, 10 },
- { 8, -6,-19, -5, -4, 12, 14, 15, 10, -9, -1, -9, 19, 12, 0, -1,
- 2, 4, 7, 9, 16,-16,-14, 9, -4, 3, 1, 0, -2, 10, -1, -1 },
- { 12, -8, 12, -9, 0, 25, 7, 9, 2,-31, -9, -4, 15, 4, -5, 1,
- -10, 11, 8, 10, 0, -6, 5, 11, -1, -6, 4,-10, -9, 6, 4, 5 },
- { 14, 6,-17, -2, 17, 12, -9, 2, 0,-25,-14, 5, 20, 14, 8,-20,
- 5, 2, -2, -3, 9,-13, -3, -1, -6, 3, 7, -6, 0, 2, 3, 1 },
- { 8, 4,-15, -3, 10, 18, -4, 13, 8,-22,-10, 9, 19,-15, 7, -5,
- -13, 12, -4, 9, 2, -9, -6, 0, 2, 1, -9, -6, 6, 1, -1, 11 },
- { 4, 1, 4, -5,-10, 18, 7, 2, -4, -9,-11, 0, 32, -7, 4,-16,
- -1, 0, 6, 3, 6, -3,-14, 16, 9, -2, 7, -1, 0, -5, 5, -3 },
- { -3, 2, 3, -8, -6, 4, 6, 2, 4,-12,-15, 2, 8, 8, 9, -3,
- -18, 6, 34, 11, 12,-15, -1, 2, 9, 2, -4, -4, 2, 4, 2, -3 },
- { 18, -6,-12, -8, -1, 15, 20, -4, -1,-11, -5, 6, 6,-11,-15, -7,
- 3, 7, 10, 2, 8,-10, -5, 8, 15, -5, 5,-17,-13, 13, 11, 7 },
- { 8, -4, -6, -1,-14, -3, 6, -2, 1, -5, -1, 10, 10,-15, 5, 0,
- -10, -4, -3, 7, -4,-19,-15, 27, 11, 18, 3,-19, -2, 6, 0, 12 },
- { 12, 0, -5, 0, 4, -5, 1, 5, 10, -7,-11, 21, 29, 1, -2, 1,
- -4,-11, -1, 13, 11,-20, -1, 4, 4, 4, -5, 6,-13, -2, 11, 9 },
- { 2, -7, -7, -3,-10, -1, 20, 12, 1,-19,-19, -1, 5, 4, -7,-25,
- 14, 1, -3, 2, 12, -4, -3, -3, -2, 6, 1, 0, 3, 2, 5, -1 },
- { 12, -8, 3,-12,-10, 10, 13, 0, 23,-14,-18, 10, 0, 15, 3,-12,
- -3, -5, 5, -4, 2,-14,-10, 8, 2, 9, -1,-11, -3, 5, 13, 2 },
- { 9, -6, 7, -7,-30, 17, 6, 13, 1,-14, 0, -1, 6, -9, 8, 3,
- -4, 0, -1, -7, -5,-13,-19, -3, -4, 4, -6, -2,-13, 1, -2, 3 },
- { 10, 1, 3,-18,-26, 17, 4,-16, 4, -3,-13, -4, -6,-11, -4,-21,
- 7, 8, 2, 5, 13, -6, 1, 5, 8, 7, 9, -6, -6, 1, -1, 2 },
- { -3, -1, 0, -2, -2, 0, -1, 3, 4,-14, -8, -9, 13, 2, 50,-23,
- -8, 8, 7, 11, 16, 3, -7, 0, -2, 6, 5, -1, 1, -2, 4, 3 },
- { 1, 3, 1, 1, -6, 3, 6, 6, 2, -2, -3, 10, 2, -8, -5, -5,
- 5, 4, 4, -2, 10, -8,-40, -1, 21, 8, 3, -4, -1, 13, 4, 7 },
- { 2, 0, -4, -8, 5, 2, 7, -5, 5, -8, -4, -1, 12, 2, 12,-13,
- -9, 0, 1,-12, 9,-43, 1, -5, 12, 1, 3, 6, 1, -1, 3, -2 },
- { 6, -2, -1, 1, 0, 4, 8, 14, 4, -7,-23, -5, 23,-17, -6,-15,
- -8, 7, 10, -1, 7,-16, 4, -6, 2, 3, -3, -3, -1, 8, -1, 4 },
- { 10, 4, -4, 1, 7, -3, 2, 11, 4, -6, -3, 8, 5, 4, 1,-45,
- -6, -4, 4, 2, 1,-14,-10, 1, 1, 6, 2, -8, -1, -3, 3, 3 },
- { 1, -1, 2, -3, -8, 9, 3, 3, -2, -5, -8, 8, 7, -7, -4, -6,
- 5, -9, 11, -2, 46, -5, -1, 9, -2, 0, 3, -5, -3, -5, 7, 0 },
- { -4, 1, -2, -1,-11, 11, 8, -3, -2,-10, 0, 4, 9, 9,-17,-17,
- -34, -4, -5, -7, -3,-12, -3, 11, 18, 3, -2, -5,-18, -5, -3, 6 },
- { 7, -5, -3, 1, -4, -3, -5, -1, 2, 5, -2, 3,-10, 12,-18, -5,
- -10, 12, -9, 4, -6, 2, 0, 16,-17, 15, 14,-12,-10, -2, -9, -1 },
- { 4, -5, -3, -5, -3, -1, 7, 18, -7, 12, 3, 5, -8, -4,-20, 1,
- -25, 1, -8, 13,-10, 8,-19, -1, -8, 10, 6, -9, -1, 0, 12, 4 },
- { -4, 5, 0, -1, 2, 5, -8, -2, -6, 4, -8, 9, 3, 2, -7, 4,
- -25, 13,-23, 10, 14, 15,-11, 3,-18, 4, 16, -4, 1,-10,-10, 3 },
- { 5, -3, -1, -3, 4, 1, -3, -4, -5, 1,-12, 14, -7, 11,-15, 6,
- -6, 24, -4, 13, -1, 15,-13, 8, 3, 7, -5, 2, 2, 0, 3, -7 },
- { -3, 1, 0, 8, 6, -1, 6, 5, -5, -2,-12, 4, 0, -2, -3, 5,
- -6, 0, -8, 9,-10, 4,-28, 12,-20, 11,-13, 7,-18, 1,-11, 1 },
- { 1, -4,-15, 5, 0,-13, -5, 13,-11, 4, -4, -5, 5,-14,-16, 0,
- -14, 5,-20, 12, 10, -7, -5, 6, 6, 22, 6, -4, -2, 3, 8, 11 },
- { 13,-11, -2, 16, 16, -7, 0, 20, -7, -1, 0, 5, -9, 12, -2, -5,
- -22, 5,-10, 12, -6, 11, 9, 21, -8, 15, 4, 0, -8, -4, -4, 10 },
- { 18, -4,-13, 0, 1,-15, -1, -3, 2, 10, -1, 6, 1, -4,-20, -5,
- -8, 6, -8, 17, -5, 5,-10, 8,-22, 6, -5, -2, 8,-17, 8, 2 },
- { 1, -2, -9, 6,-31, -8, -8, 8, 0, 5, -9, -4, 2, 3,-12, 11,
- -18, 10, -5, 3,-11, 13, -6, 11, -3, 12, -7, 3, -9, -1, 2, 11 },
- { -9, -6, 21, -8,-15, 4,-11, 12,-11, 17, -1, 2, -6, 0,-15, 13,
- -12, 19, 0, 2, -6, -3, -9, 10, 3, 17, -2, 5,-10, -3, 0, 1 },
- { 4, -6, 5,-10, 1, -5, 1, 0, 0, 0, 2, 7, -2, 2, -2, 0,
- -4, 3, -4, 1,-12, 6,-49, 16,-10, 13, 0, -2, 8, 6, 1, 8 },
- { 5, -8, -7, 9, 13, -5, 7, 0, 10, 11, -4, -3, -1, 13,-14, 6,
- -15, -6,-14, 16, 15, 1,-18, -4,-20, 20, -7, -1, -9, -2,-10, 10 },
- {-12, 4, 0, 10, 0, 3, 8, 4,-27, -1, -2, 19, -4, 2,-13, 3,
- 1, 9,-12, 1,-22, 19, -5, 4, -9, 12, 2, -9, -8, 11, -3, 7 },
- { 4, -5, 11, -6, 17,-17, 5, -4, -2, -6, 1, -5, 2, 4,-14, 6,
- -20, 19,-20, 12,-21, 5,-14, 13, -2, 11, 4, -3, 0,-10, -4, -2 },
- { -2, -1, -3, 8, -9, -7,-22, -3,-24, 13, -2, 10,-15, 5, -9, 4,
- -7, 0, -5, 15, -8, 11,-13, 6, -4, 19, -8, 12, -4, 6, 9, 7 },
- { 2, -3, 2, -1, 0, 3, 1, 2, 1, -4, -2, -3, 1, 5,-12, 6,
- -16, 14,-23, 10,-14, 17,-15, 16, -2, 9,-25, 9,-10, 16, 4, 9 },
- { -3, 7, -8, -3, 2, 2, -4, -8, -9, 10, 3,-11, 25,-10,-28, 27,
- -9, 7,-13, 9, -2, 4,-12, -8,-14, 6, 7,-10, 3, 3, -3, 5 },
- { -8, -3, 1,-10, 8, -3, -9, -4, 13, 7, 2, 4,-10, 4, 3, 7,
- -18, 2,-22, 15, 4, 20, -7, 5, -6, 13, -1, 4, -7, -6, 6, 13 },
- { -2, 3, 0, 2, -4, -2, 0, 0, 1, 2, -2, -5, 0, 1, -4, 0,
- -2, -3, 1, 2, -1, 2, -8, -1,-24, 68, -3, 8, 3, 3, -1, -1 },
- {-15, -2, -9, -7, -1, 8,-14, 8, 3, 6, 0, -1, -8, 8,-23, 2,
- -14, 17,-15, 8, -4, 7,-18, 0, -8, -3, -1, -4,-10, 4, -1, 4 },
- { 8, 0, 2, -7, 0, 5, 1, 3,-11, 4, -8, 14, 3, 20, 1, 26,
- -11, 13,-13, 20, -2, 0, -8, 2, -6, 6, -1, 9, 3, -6, -3, 10 },
- { 5, 0, -1, -7, 10, 1, -3, 5, 4, 7, -5, -1, -3, -1, 12, -3,
- -15, 7, -9, 22,-19, 8, -9, 4,-23, 13,-14, 6, -6,-14, -4, 7 },
- { 14, -5, -8,-10, 25, 3,-23, -7,-28, 0, -1, -9, 4, 1,-13, 20,
- -8, 10,-16, 8, 12,-13,-21, 5,-13, 11, -2, 1, 12, -7, 2,-10 },
- { -5, -4, 9, 5, -6, 35, -7, 8, 15, 2, -1, -9, -6, 2,-18, 7,
- -15, 6, -3, 2, 8, 12,-30, 7, -4, 20, 2, 6, 13, -6, -4, 0 },
- { 1, 8, -9, 9, -5, 12, -9, 16, -9, 16,-17, 14,-13, 15,-18, 14,
- -15, 17,-12, 14,-13, 7,-16, 13, -9, 5,-11, 10, -9, 6,-12, 13 },
- {-10, -4, 5, 3, 1, 6, 8,-14, -5, 15, 7, 4, 8, 7,-22, 8,
- -7, -8,-15, 26, 1, 13, -3, 17, -5, 9, -2, 4, -6, 3, -8, 9 },
- { 8, -3, 2, 3, 3, 1, -2, -1,-11, 8, -4, 0, -6, -5, -1, 13,
- -37, 9, 1, -6,-10, -2,-10, 11, 8, 13, -3, -2, -6, 8, -4, 13 },
- { 3, 2, -3, -4, -4, 7, -8, 9, -8, 9,-20, 12,-19, 15,-18, 17,
- -15, 7, -1, 20,-11, 6, -6, 3, 1, 9, 2,-14, -2, -2, 2, 1 },
- { -7, 1, -1, -3, -6, 4, 4, -3, 3, -1, 5, -4, 3, 2, -1, 9,
- -59, 5, -4, 30, 3, 3, -2, -3, -1, 2, 2, 1, -1, -1, -2, 1 },
- { 0, -3, 2, 0, -1, -8, 0, 2, -3, 4, -4, 1, 10, 6, -6, 8,
- -7, 4, 10, 11,-41, 27,-20, 3, -3, 8, 1, 11, -5, -8, 0, 4 },
- { 5, 1, 4, -2, 1, 2, -1, 6, -7, 2, 11, 4, 0, 0, -8, 7,
- -10, 0, 0, 8, 2, 10, -1, 1, -2, 44, -2,-21,-12, -3, -1, 2 },
- { -4, 4, -2, -2, 6, -8, 2, 1,-10, 14, 8, 6, 5, 1, -2, 4,
- -13, 4, 2, 5, 10, -2,-21, 32, -3, 18, 9, -6, -9, -9, 10, 2 },
- { 9,-16, -6, -2, 1, 4, 22, 2, -2, 1, -3, -2, -9, 3, 16, 19,
- -24, -6, -6, -5, -8, -7, 8, -7, -1,-12, 5, -3, 0, 4, 2, -3 },
- { 10, 3,-16, -4, -1, 13, 4, 4, 1, -3, 1, -6,-14, 18, 3, 8,
- -8,-28,-16, 4, 4, 2, 12, 7, 9, -4, -4, 5, -1, -1, 2, 2 },
- { -5,-13,-22, -3, -8, 21, -2, -9, 21, -4, -9, 5, -8, 15, 5, 1,
- -5, -9, -7, -2, -5, -5, -1, -5, -5, -5, 3, 10, -4, 0, -7, -2 },
- { 5,-10,-18, 2, 20, 4, 13,-10, 8,-15,-11, -3, -1, 16, 10, 9,
- -8, 6, 7, -5, 6, 11, 5, 17, -4, 7,-11, 5, -3, -6, 2, 1 },
- { 3, -5,-19, 1, 1, -3, -2,-25,-11,-17, 0,-13, -4, 10, 10, 2,
- -5, 4, 0, 3, -3, -5,-10, -2, 13,-22, 0, 3,-11, -5, 7, -1 },
- { 12,-14,-29, 6, -1, 10, 7,-17,-12, 14, 3, 9, -9, 9, 7, 6,
- -3,-13, 0, 5, 3, -1, -6, -1, 0, 2, 4,-12, -5, -1, 2, 11 },
- { 12,-15, -7, -2,-12, 17, 20,-16, -2,-12, -6, 15, -6, 12, 11, 9,
- 7, -6, 7, -4,-19, 6, 2, 2, 3,-11,-10, -4, -5, -3, 3, 2 },
- { 11,-22, -6, 0, 8, 18, 3,-11, -4, -7,-15,-17,-12, 6, 16, 4,
- -9, 4, -5, 3, 6,-16, 10, -7, -7, -3, 5, 0, 1,-15, -4, 5 },
- { 12,-22,-16, 5, -6, 8, 12, -4, -9,-17,-11, 3, 5, 8,-17, 0,
- 11, -4,-13, -6, 2, -1, -1, 3, 3,-11,-12, -1, 1, 1, 12, -2 },
- { 8,-10,-33, -5, -3, -6, 1, -7, -8, -4, -6, -1, 5, -4, -6,-12,
- -16, -8, 11, 8,-14, 7, 12, 11, 4,-14, -3, 6, -7, -5, -3, 3 },
- { 0, -8, -7, 2, -4, 24, 2, -9,-11, -3, -7, 11,-12, 17, 1, -1,
- 3, -5, -7, 12, 4, 11, 0, 3, 2,-18, -3, 4, 7, -6, 3, 15 },
- { 10,-15,-16, -2, -4, -9, 7,-15, -6, 2,-16, 13, -8, 7, 19,-21,
- -4,-12, -9, -3, -3, 6, 11, -3, -1,-19, 3, -7, -9, -4, 3, -6 },
- { -5,-10,-21, 0, -3, -7, 18,-21, 15, -5,-12, -4,-13, 2, 6, -9,
- -9,-11, -4, 13, -3, 6, 4, -1, 7, -9, -4, 9, 5, 2, 6, 3 },
- { 15, -1,-27, -2, 10, 3, 7, -8, 9, -2, 7, 1, -2, -5, 18, 9,
- -11,-17, -2, 7, -9, 11, 10, 0, -8, 6,-16, -3, 2, -7, 3, 11 },
- { 4, -9,-39, 19, 6,-13, 13, -5, -5,-15, -2, 9, 0, 4, 14, 6,
- -10, -4, -5, 2, -4, -2, 5,-11, 3, 3, -2, -2, -7, 9, 7,-10 },
- { 5,-11, -8, 10, -2, 12, 16, 0, 12, -2, -6, 8, 14, 8, 7, 1,
- 18,-30, 4, 10, -4, -6, 2,-11, 9,-10, -8, 5, 0, 0, -7, 6 },
- { -1,-16,-10, 11, 0, 13, 12, -4, -4, -5,-21, 12, 4, 13, 14, -7,
- 6,-16,-13, 8, 2, 9, 15,-12, 1, -9,-22, 10, -9, 9, 9, -7 },
- { 4,-12,-27, 1, -2, 11, 15, 3, 14,-14, -9, 0, -9, 16, 22, 10,
- 16,-10, 5, -5, -9, 1, 1, 6, 6, -4, 2,-17, -5, -6,-15, -1 },
- { 7,-12,-17, 1, -9, 5, 20, -7, 3, 23, -8, -8, -8, -1, 13, 17,
- -7,-13, 4, -4, 7, 14, 8, 11, -3, -3, 4, 0, 4, 6, -1, -9 },
- { 7,-15,-15, -4, 10, 12, 3,-13, 6, 14, 9, -8,-15, 14, 23, -5,
- -10, -5, 1, 15,-10, -7, 1, 9, 4,-13,-10, 10, 7, -3, 2, 3 },
- { 4,-10,-14, 0, 3, 4, 0, -9, -3, -4,-11, 2,-17, 8, 2, 15,
- 6,-12,-12, 15, -5, 17, 18, 3, -3, -3, -4, -6, -8, 13, 4, 10 },
- { -2,-18,-26, 10, -4, 10, 13, 4, -4,-16, -7,-17, -3, 5, -4, 2,
- -15,-10, -1, -8, -7, -3, 2, 2, 8,-10, -7, 2, 2, -4, 4, -1 },
- { 4,-19, -5, -1, -1, -6, 2, -8, 10,-16,-28, -6, 8, -1, 11, 28,
- 2,-10, -4, 6, -6, 6, 11, 15, -4, -2, 7, 3, 7, -7, 4, 1 },
- { -3, -6,-10, -5, 13, 18, 10,-15, -5, -3,-13, 5, 1, 2, 18, -5,
- -10,-10, -7, 4, 2, 1, 5, 4, 2, 5, 4, 8, -9,-17, 7, 7 },
- { 20,-12, -2, -4, 5, 14, 7,-11, -1,-16, -6, -4,-11, 17, 14, 0,
- -8,-10, -8, 10, 3, 5, 10,-16, 3, -8,-14, 10, 3, 9, 0, 3 },
- { 12,-10,-36, 0, 7, 15, 2,-16, 2, -1, 0, -1, 5, 4, 5, -3,
- 1,-10, 5, -1,-15, -3,-12, 12, 2, 5, -1, 5, 6, -3, -2, 2 },
- { 17,-15,-31, 23, -4, 15, -2, -3, 6, -7, -5, 1,-12, 4, 6, 8,
- -10, 8, 3, 5, -4, 1, 5, 3, -1, -4, -3, 1, 10, -4, -2, -2 },
- { 6,-18, -5, 12, 10, 12, 14,-11, 15, 2, -9, -6, -5, -2, -9, 4,
- -5,-28, -4, 14, 0,-16, 9, 14, -1, 3, -4, -4, 2, 1, 0, 4 },
- { -5,-14,-31, 8, 16, 7, 13,-13, 5, 6,-16, 10, -5, 2, -2, 2,
- 14, -5, 8, -5, 7,-16, 6,-13, -5, 0, -5, 8, -3, -1, 4, 3 },
- { 1, -2, -1, 0, 6, 5, 2, -4, -3, -1, 0, 1, 4, 2, 43, 28,
- -12,-35, -2, -2, -7, -1, 0, 2, -1, -2, -2, 1, -4, 0, -2, 3 },
- { 2, -9,-22, 12, 3, 3, -7, -4,-19,-22,-14, -4, -1, 21, 9, -3,
- -15,-16,-13, 1,-11, 4, -9, 1, -7, -1, -1, 0, -2, 9,-13, -3 },
- { -1, -3,-23, 0, 2, 12, 3, -9, -4, 7, 3, 9,-10, 1, 27, 28,
- 0, 9,-15, -2, -2, 1, 6, 8, -8, 7, -3, 20, 0, 0, -1, -6 },
- { -1, 11, 8, -2, 1, 5, -6, -1, 4, 2, -4, 0, -1, -5, 4, -6,
- -10,-12, 19, 1, -7, 9, -8, -9,-16,-11, -2, 12, 14, 4, 4, 34 },
- { 17, 7, -6, 1, 4,-10, -5, 4,-11, 3,-18, 4, 14,-13, -3, 1,
- 0, 0,-11, 0, 7,-17, -4, 4,-11, -6, -8, 18, 0, 0, 0, 26 },
- { -6, -7, -1, -1, 11, -8, 1, 3, 2, 11, -6, -6, 10, -3, 1, -3,
- 7, 4,-12, -8, 0, -9, 8,-22, -5, 0, -6, 22, -2, 11,-13, 24 },
- { -3, 4, 0, 3, 9, 10, -1, 3, -9,-12, 1, -5, 18, 0, -3, 8,
- 25, 15, -8, 2, 2, -2, 4, 8, 9, -1, -5, 10, -3, 1, -1, 23 },
- { -5, 2, -9, -1, -3, 0, 3, -1,-10, -4, 0,-13, 16, 9, -1,-14,
- 2, 6, -2, -6, -5, -2, -7, 7, 5, 3, 11, -2,-14, 0, -9, 30 },
- { 4, 6, 6, 5, -3, -1, 4, 5, 10, 0, 5, -4, 7,-11, 14, 14,
- 7, 34, -9, 0,-10, 22, -7, -1, 7, -9, 2, -8, 0, -7, -5, 29 },
- { -4, 3, -1, -4, -3, 5, 1, -4, 0, 2, 4, 2, 1, -1,-10, 1,
- 6, -6, -4, 1, 4, -3, -3, -5, 0, 3, 7,-12, 0, -2,-10, 55 },
- { 5, 9, -1, 0, 4, 9,-21, -9, 4, 2, 6, -7, 11, -7, 1, -5,
- 0, -4, 2, -3,-13, -8, 0, -9, -4, 2, 16, -2,-15, -7,-11, 31 },
- { 8, 2, -1, 0, 3, -5, -5, 5, 1, -1, -9, 1, 0, -6, -2, -1,
- 5, 2, 0, 0, 12, 20,-19, 1, 8,-12,-11, 0, 6, -5, 2, 31 },
- { -1, -1, -2, 1, -1, 3, -9, -5, 8, -2, 5, -1, 0, -2, 4, -2,
- -3,-12, 0, -2, 3, 0, 9, 4, -1, 21, -8, 3, -4, 9, -6, 30 },
- { -4, 0, -7, 17, 10,-12, -2,-10,-12, -3, 10, 0, 11, -4,-13, -3,
- 5, 6, 10, 7, -8, 0, -7,-13, 1, 0, -2, 7,-12, 4, -3, 24 },
- {-13, 9, 4, -2, 2, -4,-14, -1, -3, -5,-10, 4, 13, -2, 5, 13,
- 8, 3, -2, 1, 5, -6, 7,-18,-10, 1, -1, 5, 4, 1, 0, 25 },
- { -5, -1, 18, 12, 8, 8,-16, -1, 1, 1, 1, -4, -5, 3, 3, 4,
- 4,-11,-12,-16, -6, 2, 12,-13, 0, 9, 7, 9, -9, 0,-10, 24 },
- { -4, 1, -3, 0, 2, -4, 4, 1, 5, 0, -3, 2, -3, -2, 2, -1,
- 1, 4, -1, -2, -2, 1, -1, -1, -4, -1, -4, -2, -6, 6, 12, 69 },
- { 8, 5, 11, 0,-15, -4, 13, 6, 0, -4, 9, 1, -5, -3, 15, 0,
- 1, 6, -5, 0, 1, 6, 5, 8, 0, 7, 1, -1, -4,-11, -9, 41 },
- { -4, -9, 32, -6, 0, 7, -4, 6, -6, 1, -6, -2, 4, -8, -5, -3,
- -16, -1, -2, -6, 1, 15, 0, 21, 3, -3, -4, 3,-12, 16, 2, 27 },
- { -6, -5, 1, -9, -5, 3, 7, -3, 5, 5, 14, 13, 20, -7, -1, 12,
- -1, 10,-11,-11, -7, -4,-14, 7,-14, 13, 22, 18, -1, 0, 14, 28 },
- { -8, 3, -2, 0, 5, 6, -1, -4, 1, 3, -7, 3, 1,-15, 4, -9,
- 22,-10, -9, -4, 1, 8, -4, 9,-15, 2, -6, -4,-16, 12,-10, 23 },
- { 0, 0, 2, 0, -1, 3, -3, -1, 3, -5, 7, 1, 5, -5, -8, 1,
- 13,-15, -5, -7, 12, -6, -2, 3, 10, -5, -8, 17, -5,-11,-14, 23 },
- { -7, -4, 6, -4, 5, -6, -5, 2, -4, 11, 9, -4, 2, -2, -4, 6,
- 15, 3, -3, 18,-15, -2, -6, 3, 3,-20, 17, 11, -4, 2, 3, 29 },
- { 6, 1, -6, 2, 3, 0, 0, -3, 3, 3, -1, 3, -4, -6, -6, -7,
- -3, -2, -7, -2, -4, 5, 3, -5,-20,-13, -4, 10,-14,-29, 14, 37 },
- { 3, 4, 3, -6, -4, 5, 0, 3, 2, 3, 0, -2, 4, 0, -3, -5,
- -4, 4, -4, 4, 4, 3, 1, -4, -4, -9,-14, 20,-30, 3,-18, 33 },
- { 0, 2, 5, -2, -4, -2, -1, 2, -6, -3, -2, -2, 2, -5, -1, 4,
- 3, 2, -3, 0, -1, -1,-10, -7, 2, -4,-18, 2,-37, -1, 12, 40 },
- { -7, 2, -1, 0, -2, 4, -8, 1, -4, 12, 7, 4, 15, -7, 1, -9,
- 18, 0, 12,-17, -3, -1, 0, 0, 0, 2, -6, 0, -4, -3, -1, 26 },
- { -6, 4, 8, -5, -6, -2, 2, -1, 1, -1,-15, 8, 7, -1,-17, -4,
- 1, 5, 6,-11, -6, 14, 17, -5,-15, 11, 8, 0, -3,-15, -6, 28 },
- { -1, 0, 0, 0, 1, 0, -1, 0, 1, 3, 2, -2, 3, -1, -1, 2,
- 2, -1, -1, -7, 1, 2, -9, 0, -1, -4,-18, 7,-10, 49,-13, 32 },
- { -1, -3, 4, 1, 2, -5, 1, -7, -1, 5, -9, 4, 4, 25, 1, -1,
- 2, -5, 2, -7, 17, -2, 10, -5, 0, 2,-15, 3, -9, 7, -9, 30 },
- { -5, -1, 0, 2, 1, -1, 2, 5,-33, 3, -5, 14, 11, 7, 5, -3,
- 2, -8, -4, -2, -7, -6, 4, -8, -1, -8, 2, -2, -8, -1, -4, 27 },
- { -1, 0, -1, -2, 1, -1, -2, -1, 2, 0, 1, 2, 2, 4, 1, 3,
- 4, 2, 1, -7, -4, 1, -3, -4,-35,-25, 17, 10, -3,-26, -7, 32 },
- { -5, 1, 6, -2, 6, 6, -9, 3, -1, -4, 5, -4, -2, -2, -9, 2,
- -5, 2, 2, 4, 3, 5, -5,-16,-31,-12,-11, 2,-19, 20, -2, 21 },
- { -5, 2, 7, -7, -7, 5, -7, 2, 0, 0, -4, 3, -1, 0, -1, -2,
- 0, -3, 5,-11, -8, -3, -7, -7, 28,-11, -7, 0,-16,-11, -4, 29 },
- { 2, 1, -3, -2, -1, 3, 4, 0, 1, 0, -1, -5, 4, -5,-12, 2,
- -2, -5,-22, -2, -1, 11, 8, -7,-12, 0,-34, 6, -5, 11, -8, 19 },
- { -1, -3, 5, 11, 18, -2, -2, -5, -2, 4, -1, 8, 5, -6, 1, -1,
- 2, 8, 4, -5, -8, -2, 5,-18, 7, 12, 7, 19,-18, 2, -6,-13 },
- { 9, 0, 0, 5, 4, 3, -6, 4, 1, -4, 5, -1, -4, 8, 8, 6,
- -8, -6, 0, 6, -3, 3, 5, -3, 17, 31, 16, 10,-13, 0, -9,-19 },
- { 12,-10, 2, -2, -2, -1, -3, 6,-12, -5, -2, 14,-16, 4, 12, 12,
- 17, 4, 7,-16, 7, -6, 11, 7, 7, 2,-25, 23,-24, 5, -7, -9 },
- { 10, 4, 13, 10, 10, 3, -6, 3, 3, 2, -1, -6, 8, 4, 10, 0,
- 1, 2, -4, 2, -3, -8, 0, -1, 9, 9,-10, -3,-29, 1, -1,-27 },
- { 2, 2, 0, 7, 9, -2,-10, -1, -1, 1, -9, -5, 8, 4, 1, 2,
- -10, 1, 13, 12, -3, 15, -9, 2, -7, 1,-10, 23,-20,-18, -9,-15 },
- { -3, -5, -1, 8, 0, -5, -1, 4, 7, -1, -7, 2, -8, -5, 11, 7,
- -6, 3, -3, -9, 7, 9,-22, 1, 6, -4, 14, 27,-25,-14, 3, -5 },
- { 1, 3, 8, 4, 7, 6, 12,-17,-15, 1, -8,-10, 7,-14, -8, 6,
- -2, -2,-11,-11, -7, 13, -2, -2, 4, 5, -5, 13,-23, -6,-17, -8 },
- { -5, 4,-14, -5, -4, -5, 6, 5, -8, -5, -2,-11, -7,-12, 3,-11,
- 2, -6, 4,-10, -5, -7, 14, 5, 23, 11, 7, 12,-16, -6, -4,-16 },
- { 5, 6, 2, 5, -2, -5, -5, -6, -5,-19,-13, -1, -3,-13, 5, 0,
- 6, -2, -2, -6, -7, -7, -1, -9, 4, 14, 17,-12,-27, 3, 0, -1 },
- { 7, -1, 9,-10, 8, 2, -7, -2, 5, 2, -3, -7, 3, 0, 6, 4,
- 12, 5, 11, 14,-13, -1, 8, 1, 13, 9, 12, 12,-18,-14,-11,-16 },
- { -7, -5, -6, -5, 0, -1, -3, 2, 2, 1, 4, 9, 2, 3, 5, -2,
- 2, 1, 8, 0, 3, 0, -2, 2, 1, 7, 29, 0,-36, -5, -9,-21 },
- { 14, -6, -9, 0, -1, -8, -8,-11, 2, 2, -9,-12, 12, -4, 5, 3,
- -5, -9, 11, -1, -3, 12,-21, -3, 12, 5, 3, 11,-18,-15, 1, -2 },
- { -1, 3, -9, -3, 7, -7,-18, 2, 4, 12,-10, 2, 8, -3,-14, 13,
- 17, -5, 5, -9, 13, -3, -7,-18, 17, -2, 5, 7,-20, -3, -6,-11 },
- { -3, 3, 3, -1, 1, -6, -5, 1, 5, -3,-14, -6, -5, -8, 14, -6,
- 7, -1, 5, 1, 15, -1, -7, -4, 6,-11, 9, -2,-37, 16, -7, -3 },
- { -1, 0, 6, 1, -3, -9, 0, 11, -8, 2, -2, 0, 5, 2, 12,-10,
- 10, 13, 2, 7, -6, 2,-10,-10, 21, -5, 5, 5,-12,-23, 3,-14 },
- { 6, 0, -2, 1, 0, 1, 0, -4, 1, 1, 8, -2, 2, -5, -2, 1,
- 8, -4, -1, -1, 4, -1, 2, 6, 32, 1, -5,-20,-40, -4,-18,-14 },
- { 2, 2, -7, -2, 4, 4, -1, 2, 0, -2, -4, -7, 3, 5, 0, -5,
- 1, 2, -6, 4, -1, -2, -1,-15, 8, 3, 9, 46, -7,-18, 6,-11 },
- { 5, 5, 16, 21, 3,-11, -4, 11,-12, 2, 4,-12, -1, 11, 8, 1,
- -4, 11,-11,-21, 1, 1,-11, 3, 13, 1, 5, 12,-25, 1, -3, -2 },
- { 1, 6, -7, 4, 2, 3, 1, -5, 8, 9,-15, 3, -3,-14, 17, 4,
- -8, 14, -2, -8, -4, 5, 8, -7, 8, 9, 7, 6,-29,-17, 8, 4 },
- { -7, -7, 4, 0, 13, 1, 0, 4, 4,-16,-10, -7, 5, 9,-15,-10,
- -10, 8, -4, -1,-11, -1,-10,-15, 3, 3, 14, 10,-19, 2,-18,-12 },
- { -4, 0, 2, 0, 5, -2, -9, 0, 4, -4, 2, -1, -2, 2, -4, 9,
- 2, -6, -4, -2, -1, -3, -3, -1, 2, 5, -1, 11,-24,-44, -9,-15 },
- { -1,-10, 6, 21, 11, 15, -7, 10,-14, -9, -8, -8, 4, 6, 19, 1,
- -6, 1, -5,-17, -8,-10, 9, 5, 11, 18, -1, 10,-16, -7, -9, -8 },
- { 3, -5, 0, 0, -2, -2, -6, 4, -4, 1, -1, 0, 7, -3, 4, -4,
- -7, 7, 17,-20, 6, 4, 1, -6,-12, 31, 13, 19,-14,-10, -7, -2 },
- { -2, 6,-10, 3, 9, 6,-14, 15, 2, -5, 2,-11, 9, -8, 4, 6,
- 20,-15, -3, -3, -1, 32,-21, 6, 1, 9, 11, 17,-19, 6, -1, -3 },
- { 8, 10, -2, 0, -8,-16, 7, 7, 6, 10, 4,-14, 7, -6, 21, -7,
- 10, 5, 5, 0, -7, 2, -6, 0, -7, 11, -9, 15,-20, -7,-11, 2 },
- { 0, -7, 5, 2, 0, -3, -6, -4, -2, -1, -4, -5,-13, -1, 27, -9,
- -6,-11, -7, 1, 11, -4, -4,-14, -2, 11, 6, 10,-19, -6,-15, 2 },
- { 0, 7, -1, 2, -7,-15, -2, -3, 13, -5, -5, 12, 3, 0, 5, -5,
- -22, 2, 7, 22, 13, 0, -1, 2, 3, 2, -7, 7,-27, -4, -4,-12 },
- { 11, 1,-16, 6,-15, 1, 3, 2, 0, 2, -3, 2, 5, -2, -5, 9,
- 5, -3, 3, -2,-11, 3, 9, 6, 9, 3, -1, 12,-41, 8, -6, 9 },
- { 3, -7, 3, 2, 5, 5, 0, -1, 1, 3, -5, -2,-13, 7, -1, -2,
- -2, -6, 4, -6, 0, 2, -2, 2, 4, 1, -4, 1,-47,-21, 7, -6 },
- { 3, 16, -7, 13, -4, -2, 10, -3, -1, 18,-13, 7,-13, -4, 8, 4,
- 8, 9, -5, 13, 8, -5, 3, -6, 7, 18, -8, 10,-25, -3,-12,-12 },
- { 1, -1, -1, 0, 2, 5, -5, -3, 0, -5, -1, 0, -4, -8, -2, 3,
- 2, -2,-17, -6, -4, 1, 33, -6,-20, -6, 8, 31,-26, -8, -1, -4 },
- { 3, -3, -3, 5, -3, -2, 1, 7, 0, 3, 6, 3, 6, -2, 9, 15,
- -10, -3,-15, -5, -3, -4, -6,-30, 17, -8, -2, 2,-20, 0, -8, -2 },
- { -2, -1, -1, -1, 3, -5, -2, -3, 4, -2, 0, 5, 8, -3, 1, -4,
- 1, 1, -3, 4, 4,-14, 3, 11, -5, 3, -3, 7, -3, 13, 23,-16 },
- { 2, -6, 1, -3, 5, 0, -6,-11, -7, -4, -1, 2, -7, -1, -1, 7,
- 1, -2, 6, 12, -6, 8,-13, 17, 25,-23,-19, -7,-12, 9, 16,-17 },
- { 9, 4, 4, 4, -3, -1, 6, -2, -3, 0, 13, -4, -7, 14, 1, -7,
- 0, -5, 3,-19, -3, 5, 3, 9, -1, 9,-13, 13,-17, 4, 21,-26 },
- { 0, -5, 0, 0, -4, -5, 2, -6, -4, 5, -7, 10, 0, 2, 0, -2,
- -2, 0, 4, -6, 7, -2, 6, 5, -5, 2,-12, 1,-29, 29, 27, 12 },
- { 9,-10,-22, 6, -1, -1, 9,-14,-12, -2, 1, -1, 10,-11,-16, 0,
- 3, 11, 13,-14, -9, -2, -1, 6, 4,-14, 0,-10, -2, 16, 17,-11 },
- { 2, 0, -1, -2, 4, 3, -6, -2, 1, -1, 1, 3, -4, 1, 3, -4,
- -1, -1, 4, -1, 1, 0, 1, 6, -5, -7, 2, 1,-47, -3, 50,-17 },
- { 8, -4,-11, -7, 11, 11, 14, -7, 12, -7, 6, 2, 13, -6, -3, -2,
- -14, 6, 6, 6, 0, 2, -1, 5,-20, 2, -1, 4, -5, 6, 21,-11 },
- { -2, -9, 3, 0, -6, 7, 8, -8, 1, -3, 4, 1, 5, -2, -3, -7,
- 4, 7,-12, -9, -2, 10, -6, 13, 6, 5, 20, 2,-15, 9, 28, -7 },
- { 0, -5, -6, -6, -6, 1, -6, 6, -2, 4, 8, -3, 12, -1, -4, -2,
- 6, 16,-14, 9,-14, -2, -8,-27, -3, 18, -1, -7, -3, 8, 23,-23 },
- { 1, 4, -9, -1, -5, 10, -2, 1,-11, 1, -9, 4, 7, 14, -9, -2,
- -3, 2, -5, -1, -6,-10, -7, 11, 20, 2, 3,-19, 3, 15, 30, -9 },
- { 7, 2,-14, -4, 0, -2, 5, 2, 5, -2, 8, -3, -7, 6, 6,-11,
- -14, 1, 10, -1, -7, -8, 1, 10, 3, -6,-15,-12,-17, 4, 30, -6 },
- { 4, 2, 1, -2, 3, 0, 1, 0, 2, 0, 1, 6, -7, 0, 3, 4,
- 4, -4, -2, -5, -2, 2, -1, -2, 0, -2,-11, -7, -3, 42, 24,-14 },
- { 4, 1, 3, 2, 0, -2, -3, -2, 2, -1, 4, 11, -2, 2, 3, -4,
- -5, 9, 2, -4, -9, 5, 8, -1, -7, 1, 24,-13,-28, 20, 15,-22 },
- { -3, 7, 6, 3, -2, -5,-10, -2, -2, -1, -6, -6, -2,-14,-16, -6,
- -5, 0, 18, 0, 9, 1, 7,-13, -5, -6, -9, 11,-15, 9, 22,-11 },
- { 9, -2, 6, 5, 2, 9,-10, 1, 1, 5, -4, 12, 2, 2,-10, -7,
- -4, -6, 7, 9, 6, 15, 6, 6,-10, 10, 5,-13, -5, 6, 24,-12 },
- { 1, 3, -3, -3, 8, 1, -6, 2, -5, -3, 7, 2, 14, 6, 9, -6,
- -5, -4, 27, 7, -3, 8, -6, 3, -8, 8, 22, -5, -6, -2, 22,-17 },
- { -2, -2, 3, 10, 9, 9, 12,-15, -1,-11,-13, 3, -2, 1, -3,-11,
- 7, 9, 16, -3,-10, -5, -5, 1, 8, -3, 9, 9, -5, 3, 31,-12 },
- { 7, -5, 10, -4, -8, 2, 16, -2, 10, 10, -3, -2, 3, -8, -3, 3,
- -13, -6, 15, 20, -9, -3,-12, 1, -2,-16, 8, 8, -1, 16, 22, -5 },
- { 5, -3,-15, -2, 12, -8, 8, -5, 2, -8, 20,-18, 14, -4, 3, 3,
- 7,-13,-16, 1,-10, 7, 16, 7, 4,-14, -4, -5, -9, 8, 23, -6 },
- { 5, -4, -5, -4, 1, 8, 4, -7, -5, 8, 10, 6, -6,-10, -2, 6,
- 9,-17,-14, 11, 12, -3,-13, -7, 2, 18, 3,-25,-16, 18, 22, -5 },
- { 5, 6, -7,-20, -4, 2, 8, 4,-24, -4, 1, 4, -5, -2, 1,-10,
- -2, 9, 3, -4, -3, -4, -4, -4, 10, 10, 3, 0, -6, 25, 21,-11 },
- { 0, 7, -1, 14, -6, -4,-10, 5, 4, 4, 4, -5, 3, 4, -1, -7,
- 8,-19, 0, 6, 2, 3,-18, -3, -6, 2, 8, 14,-26, 22, 27,-13 },
- { -2, -6, 7, -5, 12, -7, 8, -1, 3, -2, 4, 1, 8, -2, 0, 14,
- 6, -5, 6, -4, -7, 7,-21, 8, 1, 8, -9, -4, -3, 11, 25,-13 },
- { 4, 4, -1, -6, 4, 9, -8, 1, -3,-10, -2, 0, 15, -9,-16, 11,
- 1, 1, 6, 3, -9, -5, 16, 26, 1,-14, 1, -3,-14, 7, 15, -9 },
- {-12, -2, -9,-13, 2, 6, 14, 0, 1, 0, -1,-13, 0, 10, -1, 6,
- 9, -7, 8, 8, 19, 6, -1, 9, 10, -4, 1, -7,-22, -2, 29, -7 },
- { 2, 4, 13,-12, -8, -4, -5, 13, 12, -5, -3, -3, -4, 1, -1, 10,
- 15, -6, -1,-11,-30, 4, 15, -1, 9, -7, 0, -2, -7, 10, 25,-16 },
- { 7,-15, -7, -7, -1, -5, -5,-11,-20, 10, 3,-10, -3, 5, 20, -4,
- 0, -2, -2, 17, 2, 0, -3, 3, 6, 5, -1,-12, -3, 15, 22,-16 },
- { 4, -1, 3, 4, -5, 0, -1, -5,-24,-29, 4, -9, 1, -3, 0, 0,
- 0, -4, 7, -4, -4, -4, 3, 1, -6, 5, -3, -5,-10, 3, 25,-10 },
- { -2, -1, -1, 4, 4, -1, 2, 0, -4, -4, 2, -1, -3, -1, -2, -2,
- 1, -3, -5, -1, 2, -3, -4, -4, -3, 5, -9, 1,-11, 7, 46,-46 },
- { 0, -9, 3, 4, 4, 3, -5, -6, 5, -4, 4, -2, 1, 7, -4,-10,
- 13, 1, 3, -6, 4, -4, 7, 2,-19,-25, -3,-16,-12, 16, 20, -1 },
- { 18, 6, 4,-12, 0,-14, 9, -6, -1, -4, -5, 2, 1, 12, 4, 2,
- 7, 0, 2, 5,-11, -5, -2, 2, -4, 10, 0, -9, -7, 9, 25, -8 },
- { 5, 0, -6, 5, 6, 3, 3,-10, -5, 1, -1, 4, 3,-11, -8, 5,
- 4, -5, 5, -5, -7, -5, 11, 5, 20, -8,-16, 21, -4, 27, 23, -5 }
-};
-
-
-/* FIR filter coefficients, they can be cut on half and maybe use float instead of double*/
-
-DECLARE_ALIGNED(16, static const float, fir_32bands_perfect)[] =
-{
-+1.135985195E-010,
-+7.018770981E-011,
--1.608403011E-008,
--5.083275667E-008,
--1.543309907E-007,
--3.961981463E-007,
--7.342250683E-007,
--3.970030775E-007,
--4.741137047E-007,
--6.022448247E-007,
--6.628192182E-007,
--6.982898526E-007,
--7.020648809E-007,
--6.767839409E-007,
--6.262345096E-007,
--5.564140224E-007,
-+7.003467317E-007,
-+8.419976893E-007,
-+9.742954035E-007,
-+1.085227950E-006,
-+1.162929266E-006,
-+1.194632091E-006,
-+1.179182050E-006,
-+1.033426656E-006,
-+9.451737242E-007,
-+1.975324267E-006,
-+1.190443072E-006,
-+5.234479659E-007,
-+2.014677420E-007,
-+7.834767501E-008,
--6.702406963E-010,
--1.613285505E-009,
--2.682709610E-009,
--3.399493131E-009,
-+1.314406006E-008,
-+7.506701927E-009,
-+2.788728892E-008,
-+1.444918922E-007,
-+3.132386439E-007,
-+1.399798180E-006,
-+2.032118118E-006,
-+2.715013807E-006,
-+3.453840463E-006,
-+4.195037945E-006,
-+4.896494374E-006,
-+5.516381407E-006,
-+6.015239251E-006,
-+6.361419310E-006,
-+8.006985809E-006,
-+8.087732567E-006,
-+7.941360309E-006,
-+7.568834008E-006,
-+6.986399967E-006,
-+6.225028756E-006,
-+5.315936960E-006,
-+4.429412002E-006,
-+3.332600045E-006,
-+8.427224429E-007,
-+4.341498823E-007,
-+9.458596395E-008,
-+2.975164826E-008,
-+6.402664354E-008,
--3.246264413E-008,
--3.809887872E-008,
-+8.434094667E-008,
-+6.437721822E-008,
-+1.189317118E-006,
-+2.497214155E-006,
-+3.617151151E-006,
-+3.157242645E-006,
-+2.319611212E-006,
-+7.869333785E-006,
-+9.826449968E-006,
-+1.177108606E-005,
-+1.379448349E-005,
-+1.571428584E-005,
-+1.743183020E-005,
-+1.884208177E-005,
-+1.987093310E-005,
-+2.042970118E-005,
--3.144468428E-005,
--3.334947178E-005,
--3.460439257E-005,
--3.515914432E-005,
--3.495384954E-005,
--3.397853652E-005,
--3.225446198E-005,
--2.978993689E-005,
--2.677291741E-005,
--1.806914770E-005,
--1.776598037E-005,
--1.661818715E-005,
--1.207003334E-005,
--6.993315310E-006,
--5.633860383E-007,
--9.984935332E-007,
--1.470520488E-006,
--1.853591357E-006,
-+7.198007665E-007,
-+3.086857760E-006,
-+6.084746474E-006,
-+9.561075785E-006,
-+1.309637537E-005,
-+2.263354872E-005,
-+2.847247197E-005,
-+3.415624451E-005,
-+3.946387005E-005,
-+4.425736552E-005,
-+4.839275425E-005,
-+5.176846025E-005,
-+5.429694284E-005,
-+5.595519906E-005,
-+4.916387297E-006,
-+9.299508747E-006,
-+1.356193479E-005,
-+1.751866148E-005,
-+2.093936746E-005,
-+2.362549276E-005,
-+2.537086584E-005,
-+2.618136386E-005,
-+2.554462844E-005,
-+3.018750249E-005,
-+2.570833203E-005,
-+1.985177369E-005,
-+1.191342653E-005,
-+2.525620175E-006,
--1.521241393E-005,
--1.617751332E-005,
-+1.992636317E-005,
-+1.774702469E-005,
-+4.624524081E-005,
-+5.610509834E-005,
-+6.568001118E-005,
-+7.513730816E-005,
-+8.413690375E-005,
-+8.757545584E-005,
-+9.517164290E-005,
-+1.020687996E-004,
-+1.084438481E-004,
-+1.140582463E-004,
-+1.187910311E-004,
-+1.224978914E-004,
-+1.250260248E-004,
-+1.262027217E-004,
-+1.226499153E-004,
-+1.213575742E-004,
-+1.180980107E-004,
-+1.126275165E-004,
-+1.047207043E-004,
-+9.417100227E-005,
-+8.078388782E-005,
-+6.447290798E-005,
-+4.491530854E-005,
-+2.470704203E-005,
--1.714242217E-006,
--3.193307566E-005,
--6.541742187E-005,
--1.024175072E-004,
--1.312203676E-004,
--1.774113771E-004,
--2.233728592E-004,
--2.682086197E-004,
--3.347633174E-004,
--3.906481725E-004,
--4.490280990E-004,
--5.099929986E-004,
--5.729619297E-004,
--6.358824321E-004,
--7.021900383E-004,
--7.698345580E-004,
--8.385353722E-004,
--9.078957955E-004,
--9.775133803E-004,
--1.046945457E-003,
--1.115717343E-003,
--1.183370827E-003,
--1.252829796E-003,
--1.316190348E-003,
--1.376571832E-003,
--1.433344092E-003,
--1.485876855E-003,
--1.533520175E-003,
--1.575609902E-003,
--1.611457788E-003,
--1.640390139E-003,
--1.661288203E-003,
--1.674512983E-003,
--1.678415807E-003,
--1.672798418E-003,
--1.656501088E-003,
--1.633993932E-003,
--1.593449386E-003,
-+1.542080659E-003,
-+1.479332102E-003,
-+1.395521569E-003,
-+1.303116791E-003,
-+1.196175464E-003,
-+1.073757303E-003,
-+9.358961834E-004,
-+7.817269652E-004,
-+6.114174030E-004,
-+4.244441516E-004,
-+2.206075296E-004,
--2.719412748E-007,
--2.382978710E-004,
--4.935106263E-004,
--7.658848190E-004,
--1.055365428E-003,
--1.361547387E-003,
--1.684492454E-003,
--2.023874084E-003,
--2.379294252E-003,
--2.750317100E-003,
--3.136433195E-003,
--3.537061159E-003,
--3.951539751E-003,
--4.379155114E-003,
--4.819062538E-003,
--5.270531867E-003,
--5.732392892E-003,
--6.203945260E-003,
--6.683901884E-003,
--7.170005701E-003,
--7.664063945E-003,
--8.162760176E-003,
--8.665001951E-003,
--9.170533158E-003,
--9.676489048E-003,
--1.018219907E-002,
--1.068630442E-002,
--1.118756086E-002,
--1.168460958E-002,
--1.217562053E-002,
--1.265939046E-002,
--1.313448418E-002,
--1.359948888E-002,
--1.405300573E-002,
--1.449365262E-002,
--1.492007636E-002,
--1.533095632E-002,
--1.572482102E-002,
--1.610082202E-002,
--1.645756140E-002,
--1.679391414E-002,
--1.710879989E-002,
--1.740120351E-002,
--1.767017506E-002,
--1.791484281E-002,
--1.813439466E-002,
--1.832821220E-002,
--1.849545911E-002,
--1.863567345E-002,
--1.874836907E-002,
--1.883326657E-002,
--1.889026538E-002,
--1.891860925E-002,
-+1.891860925E-002,
-+1.889026538E-002,
-+1.883326657E-002,
-+1.874836907E-002,
-+1.863567345E-002,
-+1.849545911E-002,
-+1.832821220E-002,
-+1.813439466E-002,
-+1.791484281E-002,
-+1.767017506E-002,
-+1.740120351E-002,
-+1.710879989E-002,
-+1.679391414E-002,
-+1.645756140E-002,
-+1.610082202E-002,
-+1.572482102E-002,
-+1.533095632E-002,
-+1.492007636E-002,
-+1.449365262E-002,
-+1.405300573E-002,
-+1.359948888E-002,
-+1.313448418E-002,
-+1.265939046E-002,
-+1.217562053E-002,
-+1.168460958E-002,
-+1.118756086E-002,
-+1.068630442E-002,
-+1.018219907E-002,
-+9.676489048E-003,
-+9.170533158E-003,
-+8.665001951E-003,
-+8.162760176E-003,
-+7.664063945E-003,
-+7.170005701E-003,
-+6.683901884E-003,
-+6.203945260E-003,
-+5.732392892E-003,
-+5.270531867E-003,
-+4.819062538E-003,
-+4.379155114E-003,
-+3.951539751E-003,
-+3.537061159E-003,
-+3.136433195E-003,
-+2.750317100E-003,
-+2.379294252E-003,
-+2.023874084E-003,
-+1.684492454E-003,
-+1.361547387E-003,
-+1.055365428E-003,
-+7.658848190E-004,
-+4.935106263E-004,
-+2.382978710E-004,
-+2.719412748E-007,
--2.206075296E-004,
--4.244441516E-004,
--6.114174030E-004,
--7.817269652E-004,
--9.358961834E-004,
--1.073757303E-003,
--1.196175464E-003,
--1.303116791E-003,
--1.395521569E-003,
--1.479332102E-003,
--1.542080659E-003,
-+1.593449386E-003,
-+1.633993932E-003,
-+1.656501088E-003,
-+1.672798418E-003,
-+1.678415807E-003,
-+1.674512983E-003,
-+1.661288203E-003,
-+1.640390139E-003,
-+1.611457788E-003,
-+1.575609902E-003,
-+1.533520175E-003,
-+1.485876855E-003,
-+1.433344092E-003,
-+1.376571832E-003,
-+1.316190348E-003,
-+1.252829796E-003,
-+1.183370827E-003,
-+1.115717343E-003,
-+1.046945457E-003,
-+9.775133803E-004,
-+9.078957955E-004,
-+8.385353722E-004,
-+7.698345580E-004,
-+7.021900383E-004,
-+6.358824321E-004,
-+5.729619297E-004,
-+5.099929986E-004,
-+4.490280990E-004,
-+3.906481725E-004,
-+3.347633174E-004,
-+2.682086197E-004,
-+2.233728592E-004,
-+1.774113771E-004,
-+1.312203676E-004,
-+1.024175072E-004,
-+6.541742187E-005,
-+3.193307566E-005,
-+1.714242217E-006,
--2.470704203E-005,
--4.491530854E-005,
--6.447290798E-005,
--8.078388782E-005,
--9.417100227E-005,
--1.047207043E-004,
--1.126275165E-004,
--1.180980107E-004,
--1.213575742E-004,
--1.226499153E-004,
--1.262027217E-004,
--1.250260248E-004,
--1.224978914E-004,
--1.187910311E-004,
--1.140582463E-004,
--1.084438481E-004,
--1.020687996E-004,
--9.517164290E-005,
--8.757545584E-005,
--8.413690375E-005,
--7.513730816E-005,
--6.568001118E-005,
--5.610509834E-005,
--4.624524081E-005,
--1.774702469E-005,
--1.992636317E-005,
-+1.617751332E-005,
-+1.521241393E-005,
--2.525620175E-006,
--1.191342653E-005,
--1.985177369E-005,
--2.570833203E-005,
--3.018750249E-005,
--2.554462844E-005,
--2.618136386E-005,
--2.537086584E-005,
--2.362549276E-005,
--2.093936746E-005,
--1.751866148E-005,
--1.356193479E-005,
--9.299508747E-006,
--4.916387297E-006,
--5.595519906E-005,
--5.429694284E-005,
--5.176846025E-005,
--4.839275425E-005,
--4.425736552E-005,
--3.946387005E-005,
--3.415624451E-005,
--2.847247197E-005,
--2.263354872E-005,
--1.309637537E-005,
--9.561075785E-006,
--6.084746474E-006,
--3.086857760E-006,
--7.198007665E-007,
-+1.853591357E-006,
-+1.470520488E-006,
-+9.984935332E-007,
-+5.633860383E-007,
-+6.993315310E-006,
-+1.207003334E-005,
-+1.661818715E-005,
-+1.776598037E-005,
-+1.806914770E-005,
-+2.677291741E-005,
-+2.978993689E-005,
-+3.225446198E-005,
-+3.397853652E-005,
-+3.495384954E-005,
-+3.515914432E-005,
-+3.460439257E-005,
-+3.334947178E-005,
-+3.144468428E-005,
--2.042970118E-005,
--1.987093310E-005,
--1.884208177E-005,
--1.743183020E-005,
--1.571428584E-005,
--1.379448349E-005,
--1.177108606E-005,
--9.826449968E-006,
--7.869333785E-006,
--2.319611212E-006,
--3.157242645E-006,
--3.617151151E-006,
--2.497214155E-006,
--1.189317118E-006,
--6.437721822E-008,
--8.434094667E-008,
-+3.809887872E-008,
-+3.246264413E-008,
--6.402664354E-008,
--2.975164826E-008,
--9.458596395E-008,
--4.341498823E-007,
--8.427224429E-007,
--3.332600045E-006,
--4.429412002E-006,
--5.315936960E-006,
--6.225028756E-006,
--6.986399967E-006,
--7.568834008E-006,
--7.941360309E-006,
--8.087732567E-006,
--8.006985809E-006,
--6.361419310E-006,
--6.015239251E-006,
--5.516381407E-006,
--4.896494374E-006,
--4.195037945E-006,
--3.453840463E-006,
--2.715013807E-006,
--2.032118118E-006,
--1.399798180E-006,
--3.132386439E-007,
--1.444918922E-007,
--2.788728892E-008,
--7.506701927E-009,
--1.314406006E-008,
-+3.399493131E-009,
-+2.682709610E-009,
-+1.613285505E-009,
-+6.702406963E-010,
--7.834767501E-008,
--2.014677420E-007,
--5.234479659E-007,
--1.190443072E-006,
--1.975324267E-006,
--9.451737242E-007,
--1.033426656E-006,
--1.179182050E-006,
--1.194632091E-006,
--1.162929266E-006,
--1.085227950E-006,
--9.742954035E-007,
--8.419976893E-007,
--7.003467317E-007,
-+5.564140224E-007,
-+6.262345096E-007,
-+6.767839409E-007,
-+7.020648809E-007,
-+6.982898526E-007,
-+6.628192182E-007,
-+6.022448247E-007,
-+4.741137047E-007,
-+3.970030775E-007,
-+7.342250683E-007,
-+3.961981463E-007,
-+1.543309907E-007,
-+5.083275667E-008,
-+1.608403011E-008,
--7.018770981E-011,
--1.135985195E-010
-};
-
-DECLARE_ALIGNED(16, static const float, fir_32bands_nonperfect)[] =
-{
--1.390191784E-007,
--1.693738625E-007,
--2.030677564E-007,
--2.404238444E-007,
--2.818143514E-007,
--3.276689142E-007,
--3.784752209E-007,
--4.347855338E-007,
--4.972276315E-007,
--5.665120852E-007,
--6.434325428E-007,
--7.288739425E-007,
--8.238164355E-007,
--9.293416952E-007,
--1.046637067E-006,
--1.176999604E-006,
--1.321840614E-006,
--1.482681114E-006,
--1.661159786E-006,
--1.859034001E-006,
--2.078171747E-006,
--2.320550948E-006,
--2.588257530E-006,
--2.883470643E-006,
--3.208459020E-006,
--3.565570978E-006,
--3.957220997E-006,
--4.385879038E-006,
--4.854050530E-006,
--5.364252502E-006,
--5.918994248E-006,
--6.520755960E-006,
--7.171964626E-006,
--7.874960829E-006,
--8.631964192E-006,
--9.445050637E-006,
--1.031611009E-005,
--1.124680875E-005,
--1.223855270E-005,
--1.329243969E-005,
--1.440921824E-005,
--1.558924305E-005,
--1.683242772E-005,
--1.813820381E-005,
--1.950545993E-005,
--2.093250441E-005,
--2.241701623E-005,
--2.395598858E-005,
--2.554569073E-005,
--2.718161704E-005,
--2.885844333E-005,
--3.056998685E-005,
--3.230916263E-005,
--3.406793985E-005,
--3.583733633E-005,
--3.760734762E-005,
--3.936696885E-005,
--4.110412556E-005,
--4.280570283E-005,
--4.445751256E-005,
--4.604430433E-005,
--4.754976908E-005,
--4.895655002E-005,
--5.024627535E-005,
-+5.139957648E-005,
-+5.239612074E-005,
-+5.321469871E-005,
-+5.383323878E-005,
-+5.422891263E-005,
-+5.437819709E-005,
-+5.425697600E-005,
-+5.384063843E-005,
-+5.310418419E-005,
-+5.202236207E-005,
-+5.056979353E-005,
-+4.872112549E-005,
-+4.645117951E-005,
-+4.373511547E-005,
-+4.054862075E-005,
-+3.686808850E-005,
-+3.267079956E-005,
-+2.793515523E-005,
-+2.264085742E-005,
-+1.676913780E-005,
-+1.030297699E-005,
-+3.227306706E-006,
--4.470633485E-006,
--1.280130618E-005,
--2.177240640E-005,
--3.138873581E-005,
--4.165195787E-005,
--5.256036457E-005,
--6.410864444E-005,
--7.628766616E-005,
--8.908427117E-005,
--1.024810626E-004,
--1.164562127E-004,
--1.309833024E-004,
--1.460311323E-004,
--1.615635992E-004,
--1.775395358E-004,
--1.939126523E-004,
--2.106313768E-004,
--2.276388550E-004,
--2.448728774E-004,
--2.622658503E-004,
--2.797449124E-004,
--2.972317743E-004,
--3.146430245E-004,
--3.318900708E-004,
--3.488793736E-004,
--3.655125911E-004,
--3.816867538E-004,
--3.972945851E-004,
--4.122247046E-004,
--4.263620067E-004,
--4.395879805E-004,
--4.517810594E-004,
--4.628172028E-004,
--4.725702747E-004,
--4.809123348E-004,
--4.877146275E-004,
--4.928477574E-004,
--4.961824161E-004,
--4.975944757E-004,
--4.969481961E-004,
--4.941228544E-004,
--4.889960401E-004,
-+4.814492422E-004,
-+4.713678791E-004,
-+4.586426076E-004,
-+4.431701091E-004,
-+4.248536134E-004,
-+4.036037717E-004,
-+3.793396754E-004,
-+3.519894381E-004,
-+3.214911267E-004,
-+2.877934603E-004,
-+2.508567995E-004,
-+2.106537577E-004,
-+1.671699720E-004,
-+1.204049113E-004,
-+7.037253090E-005,
-+1.710198012E-005,
--3.936182839E-005,
--9.895755647E-005,
--1.616069785E-004,
--2.272142592E-004,
--2.956659591E-004,
--3.668301215E-004,
--4.405563814E-004,
--5.166754709E-004,
--5.949990009E-004,
--6.753197522E-004,
--7.574109477E-004,
--8.410271257E-004,
--9.259034996E-004,
--1.011756598E-003,
--1.098284614E-003,
--1.185167348E-003,
--1.272067428E-003,
--1.358630019E-003,
--1.444484224E-003,
--1.529243193E-003,
--1.612505526E-003,
--1.693855622E-003,
--1.772865304E-003,
--1.849094522E-003,
--1.922092517E-003,
--1.991399564E-003,
--2.056547208E-003,
--2.117061289E-003,
--2.172462177E-003,
--2.222266514E-003,
--2.265989315E-003,
--2.303145360E-003,
--2.333251061E-003,
--2.355825622E-003,
--2.370394068E-003,
--2.376487479E-003,
--2.373647178E-003,
--2.361423569E-003,
--2.339380793E-003,
--2.307097195E-003,
--2.264167881E-003,
--2.210205887E-003,
--2.144844970E-003,
--2.067740774E-003,
--1.978572691E-003,
--1.877046190E-003,
--1.762894331E-003,
--1.635878929E-003,
-+1.495792647E-003,
-+1.342460280E-003,
-+1.175740734E-003,
-+9.955273708E-004,
-+8.017504588E-004,
-+5.943773431E-004,
-+3.734139318E-004,
-+1.389056415E-004,
--1.090620208E-004,
--3.703625989E-004,
--6.448282511E-004,
--9.322494152E-004,
--1.232374110E-003,
--1.544908970E-003,
--1.869517611E-003,
--2.205822384E-003,
--2.553403843E-003,
--2.911801683E-003,
--3.280514618E-003,
--3.659002949E-003,
--4.046686925E-003,
--4.442950245E-003,
--4.847140983E-003,
--5.258570891E-003,
--5.676518660E-003,
--6.100233644E-003,
--6.528933067E-003,
--6.961807609E-003,
--7.398022339E-003,
--7.836719044E-003,
--8.277016692E-003,
--8.718019351E-003,
--9.158811532E-003,
--9.598465636E-003,
--1.003604382E-002,
--1.047059800E-002,
--1.090117730E-002,
--1.132682897E-002,
--1.174659748E-002,
--1.215953380E-002,
--1.256469358E-002,
--1.296114177E-002,
--1.334795821E-002,
--1.372423489E-002,
--1.408908330E-002,
--1.444163360E-002,
--1.478104480E-002,
--1.510649733E-002,
--1.541720331E-002,
--1.571240649E-002,
--1.599138230E-002,
--1.625344716E-002,
--1.649795473E-002,
--1.672429405E-002,
--1.693190821E-002,
--1.712027565E-002,
--1.728892699E-002,
--1.743743755E-002,
--1.756543480E-002,
--1.767260395E-002,
--1.775865816E-002,
--1.782339066E-002,
--1.786663756E-002,
--1.788828894E-002,
-+1.788828894E-002,
-+1.786663756E-002,
-+1.782339066E-002,
-+1.775865816E-002,
-+1.767260395E-002,
-+1.756543480E-002,
-+1.743743755E-002,
-+1.728892699E-002,
-+1.712027565E-002,
-+1.693190821E-002,
-+1.672429405E-002,
-+1.649795473E-002,
-+1.625344716E-002,
-+1.599138230E-002,
-+1.571240649E-002,
-+1.541720331E-002,
-+1.510649733E-002,
-+1.478104480E-002,
-+1.444163360E-002,
-+1.408908330E-002,
-+1.372423489E-002,
-+1.334795821E-002,
-+1.296114177E-002,
-+1.256469358E-002,
-+1.215953380E-002,
-+1.174659748E-002,
-+1.132682897E-002,
-+1.090117730E-002,
-+1.047059800E-002,
-+1.003604382E-002,
-+9.598465636E-003,
-+9.158811532E-003,
-+8.718019351E-003,
-+8.277016692E-003,
-+7.836719044E-003,
-+7.398022339E-003,
-+6.961807609E-003,
-+6.528933067E-003,
-+6.100233644E-003,
-+5.676518660E-003,
-+5.258570891E-003,
-+4.847140983E-003,
-+4.442950245E-003,
-+4.046686925E-003,
-+3.659002949E-003,
-+3.280514618E-003,
-+2.911801683E-003,
-+2.553403843E-003,
-+2.205822384E-003,
-+1.869517611E-003,
-+1.544908970E-003,
-+1.232374110E-003,
-+9.322494152E-004,
-+6.448282511E-004,
-+3.703625989E-004,
-+1.090620208E-004,
--1.389056415E-004,
--3.734139318E-004,
--5.943773431E-004,
--8.017504588E-004,
--9.955273708E-004,
--1.175740734E-003,
--1.342460280E-003,
--1.495792647E-003,
-+1.635878929E-003,
-+1.762894331E-003,
-+1.877046190E-003,
-+1.978572691E-003,
-+2.067740774E-003,
-+2.144844970E-003,
-+2.210205887E-003,
-+2.264167881E-003,
-+2.307097195E-003,
-+2.339380793E-003,
-+2.361423569E-003,
-+2.373647178E-003,
-+2.376487479E-003,
-+2.370394068E-003,
-+2.355825622E-003,
-+2.333251061E-003,
-+2.303145360E-003,
-+2.265989315E-003,
-+2.222266514E-003,
-+2.172462177E-003,
-+2.117061289E-003,
-+2.056547208E-003,
-+1.991399564E-003,
-+1.922092517E-003,
-+1.849094522E-003,
-+1.772865304E-003,
-+1.693855622E-003,
-+1.612505526E-003,
-+1.529243193E-003,
-+1.444484224E-003,
-+1.358630019E-003,
-+1.272067428E-003,
-+1.185167348E-003,
-+1.098284614E-003,
-+1.011756598E-003,
-+9.259034996E-004,
-+8.410271257E-004,
-+7.574109477E-004,
-+6.753197522E-004,
-+5.949990009E-004,
-+5.166754709E-004,
-+4.405563814E-004,
-+3.668301215E-004,
-+2.956659591E-004,
-+2.272142592E-004,
-+1.616069785E-004,
-+9.895755647E-005,
-+3.936182839E-005,
--1.710198012E-005,
--7.037253090E-005,
--1.204049113E-004,
--1.671699720E-004,
--2.106537577E-004,
--2.508567995E-004,
--2.877934603E-004,
--3.214911267E-004,
--3.519894381E-004,
--3.793396754E-004,
--4.036037717E-004,
--4.248536134E-004,
--4.431701091E-004,
--4.586426076E-004,
--4.713678791E-004,
--4.814492422E-004,
-+4.889960401E-004,
-+4.941228544E-004,
-+4.969481961E-004,
-+4.975944757E-004,
-+4.961824161E-004,
-+4.928477574E-004,
-+4.877146275E-004,
-+4.809123348E-004,
-+4.725702747E-004,
-+4.628172028E-004,
-+4.517810594E-004,
-+4.395879805E-004,
-+4.263620067E-004,
-+4.122247046E-004,
-+3.972945851E-004,
-+3.816867538E-004,
-+3.655125911E-004,
-+3.488793736E-004,
-+3.318900708E-004,
-+3.146430245E-004,
-+2.972317743E-004,
-+2.797449124E-004,
-+2.622658503E-004,
-+2.448728774E-004,
-+2.276388550E-004,
-+2.106313768E-004,
-+1.939126523E-004,
-+1.775395358E-004,
-+1.615635992E-004,
-+1.460311323E-004,
-+1.309833024E-004,
-+1.164562127E-004,
-+1.024810626E-004,
-+8.908427117E-005,
-+7.628766616E-005,
-+6.410864444E-005,
-+5.256036457E-005,
-+4.165195787E-005,
-+3.138873581E-005,
-+2.177240640E-005,
-+1.280130618E-005,
-+4.470633485E-006,
--3.227306706E-006,
--1.030297699E-005,
--1.676913780E-005,
--2.264085742E-005,
--2.793515523E-005,
--3.267079956E-005,
--3.686808850E-005,
--4.054862075E-005,
--4.373511547E-005,
--4.645117951E-005,
--4.872112549E-005,
--5.056979353E-005,
--5.202236207E-005,
--5.310418419E-005,
--5.384063843E-005,
--5.425697600E-005,
--5.437819709E-005,
--5.422891263E-005,
--5.383323878E-005,
--5.321469871E-005,
--5.239612074E-005,
--5.139957648E-005,
-+5.024627535E-005,
-+4.895655002E-005,
-+4.754976908E-005,
-+4.604430433E-005,
-+4.445751256E-005,
-+4.280570283E-005,
-+4.110412556E-005,
-+3.936696885E-005,
-+3.760734762E-005,
-+3.583733633E-005,
-+3.406793985E-005,
-+3.230916263E-005,
-+3.056998685E-005,
-+2.885844333E-005,
-+2.718161704E-005,
-+2.554569073E-005,
-+2.395598858E-005,
-+2.241701623E-005,
-+2.093250441E-005,
-+1.950545993E-005,
-+1.813820381E-005,
-+1.683242772E-005,
-+1.558924305E-005,
-+1.440921824E-005,
-+1.329243969E-005,
-+1.223855270E-005,
-+1.124680875E-005,
-+1.031611009E-005,
-+9.445050637E-006,
-+8.631964192E-006,
-+7.874960829E-006,
-+7.171964626E-006,
-+6.520755960E-006,
-+5.918994248E-006,
-+5.364252502E-006,
-+4.854050530E-006,
-+4.385879038E-006,
-+3.957220997E-006,
-+3.565570978E-006,
-+3.208459020E-006,
-+2.883470643E-006,
-+2.588257530E-006,
-+2.320550948E-006,
-+2.078171747E-006,
-+1.859034001E-006,
-+1.661159786E-006,
-+1.482681114E-006,
-+1.321840614E-006,
-+1.176999604E-006,
-+1.046637067E-006,
-+9.293416952E-007,
-+8.238164355E-007,
-+7.288739425E-007,
-+6.434325428E-007,
-+5.665120852E-007,
-+4.972276315E-007,
-+4.347855338E-007,
-+3.784752209E-007,
-+3.276689142E-007,
-+2.818143514E-007,
-+2.404238444E-007,
-+2.030677564E-007,
-+1.693738625E-007,
-+1.390191784E-007
-};
-
-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,
-};
-
-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,
-};
-
-/* 10^-(dB/20), with dB being a list of dB values ranging from 0 to -72 */
-/* do a 20*log10(dca_downmix_coeffs) to reconvert the values */
-
-static const float dca_downmix_coeffs[65] = {
- 1.000000000000000, 0.988553094656939, 0.971627951577106, 0.944060876285923, 0.917275935389780, 0.891250938133746,
- 0.865964323360065, 0.841395141645195, 0.817523037943650, 0.794328234724281, 0.771791515585012, 0.749894209332456,
- 0.728618174513228, 0.707945784384138, 0.687859912308808, 0.668343917568615, 0.649381631576211, 0.630957344480193,
- 0.613055792149821, 0.595662143529010, 0.578761988349121, 0.562341325190349, 0.546386549881854, 0.530884444230988,
- 0.515822165072306, 0.501187233627272, 0.446683592150963, 0.398107170553497, 0.354813389233575, 0.316227766016838,
- 0.281838293126445, 0.251188643150958, 0.223872113856834, 0.199526231496888, 0.177827941003892, 0.158489319246111,
- 0.141253754462275, 0.125892541179417, 0.112201845430196, 0.100000000000000, 0.089125093813374, 0.079432823472428,
- 0.070794578438414, 0.063095734448019, 0.053088444423099, 0.044668359215096, 0.037583740428844, 0.031622776601684,
- 0.026607250597988, 0.022387211385683, 0.018836490894898, 0.015848931924611, 0.013335214321633, 0.011220184543020,
- 0.009440608762859, 0.007943282347243, 0.005623413251903, 0.003981071705535, 0.002818382931264, 0.001995262314969,
- 0.001412537544623, 0.001000000000000, 0.000501187233627, 0.000251188643151, 0.000000000000000,
-};
-
-static const float dca_downmix_scale_factors[241] = {
- 0.001000, 0.001059, 0.001122, 0.001189, 0.001259, 0.001334, 0.001413, 0.001496,
- 0.001585, 0.001679, 0.001778, 0.001884, 0.001995, 0.002113, 0.002239, 0.002371,
- 0.002512, 0.002661, 0.002818, 0.002985, 0.003162, 0.003350, 0.003548, 0.003758,
- 0.003981, 0.004217, 0.004467, 0.004732, 0.005012, 0.005309, 0.005623, 0.005957,
- 0.006310, 0.006683, 0.007079, 0.007499, 0.007943, 0.008414, 0.008913, 0.009441,
- 0.010000, 0.010593, 0.011220, 0.011885, 0.012589, 0.013335, 0.014125, 0.014962,
- 0.015849, 0.016788, 0.017783, 0.018836, 0.019953, 0.021135, 0.022387, 0.023714,
- 0.025119, 0.026607, 0.028184, 0.029854, 0.031623, 0.032546, 0.033497, 0.034475,
- 0.035481, 0.036517, 0.037584, 0.038681, 0.039811, 0.040973, 0.042170, 0.043401,
- 0.044668, 0.045973, 0.047315, 0.048697, 0.050119, 0.051582, 0.053088, 0.054639,
- 0.056234, 0.057876, 0.059566, 0.061306, 0.063096, 0.064938, 0.066834, 0.068786,
- 0.070795, 0.072862, 0.074989, 0.077179, 0.079433, 0.081752, 0.084140, 0.086596,
- 0.089125, 0.091728, 0.094406, 0.097163, 0.100000, 0.102920, 0.105925, 0.109018,
- 0.112202, 0.115478, 0.118850, 0.122321, 0.125893, 0.129569, 0.133352, 0.137246,
- 0.141254, 0.145378, 0.149624, 0.153993, 0.158489, 0.163117, 0.167880, 0.172783,
- 0.177828, 0.180406, 0.183021, 0.185674, 0.188365, 0.191095, 0.193865, 0.196675,
- 0.199526, 0.202418, 0.205353, 0.208329, 0.211349, 0.214412, 0.217520, 0.220673,
- 0.223872, 0.227117, 0.230409, 0.233749, 0.237137, 0.240575, 0.244062, 0.247600,
- 0.251189, 0.254830, 0.258523, 0.262271, 0.266073, 0.269929, 0.273842, 0.277811,
- 0.281838, 0.285924, 0.290068, 0.294273, 0.298538, 0.302866, 0.307256, 0.311709,
- 0.316228, 0.320812, 0.325462, 0.330179, 0.334965, 0.339821, 0.344747, 0.349744,
- 0.354813, 0.359956, 0.365174, 0.370467, 0.375837, 0.381285, 0.386812, 0.392419,
- 0.398107, 0.403878, 0.409732, 0.415671, 0.421697, 0.427809, 0.434010, 0.440301,
- 0.446684, 0.453158, 0.459727, 0.466391, 0.473151, 0.480010, 0.486968, 0.494026,
- 0.501187, 0.508452, 0.515822, 0.523299, 0.530884, 0.538580, 0.546387, 0.554307,
- 0.562341, 0.570493, 0.578762, 0.587151, 0.595662, 0.604296, 0.613056, 0.621942,
- 0.630957, 0.640103, 0.649382, 0.658795, 0.668344, 0.678032, 0.687860, 0.697831,
- 0.707107, 0.718208, 0.728618, 0.739180, 0.749894, 0.760764, 0.771792, 0.782979,
- 0.794328, 0.805842, 0.817523, 0.829373, 0.841395, 0.853591, 0.865964, 0.878517,
- 0.891251, 0.904170, 0.917276, 0.930572, 0.944061, 0.957745, 0.971628, 0.985712,
- 1.000000
-};
-
-static const uint8_t dca_default_coeffs[10][5][2] = {
- { { 13, 13 }, },
- { { 0, 64 }, { 64, 0 }, },
- { { 0, 64 }, { 64, 0 }, },
- { { 0, 64 }, { 64, 0 }, },
- { { 0, 64 }, { 64, 0 }, },
- { { 6, 6 }, { 0, 25 }, { 25, 0 }, },
- { { 0, 25 }, { 25, 0 }, { 13, 13 }, },
- { { 6, 6 }, { 0, 25 }, { 25, 0 }, { 13, 13 }, },
- { { 0, 25 }, { 25, 0 }, { 0, 13 }, { 13, 0 }, },
- { { 6, 6 }, { 0, 25 }, { 25, 0 }, { 0, 13 }, { 13, 0 }, },
-};
-
-/* downmix coeffs
-
- TABLE 9
-______________________________________
-Down-mix coefficients for 8-channel source
-audio (5 + 3 format)
- lt
- cen- rt lt ctr rt
-lt ter ctr center
- rt srd srd srd
-______________________________________
-1 0.71 0.74 1.0 0.71 0.71 0.58 0.58 0.58
-2 left 1.0 0.89 0.71 0.46 0.71 0.50
- rt 0.45 0.71 0.89 1.0 0.50 0.71
-3 lt 1.0 0.89 0.71 0.45
- rt 0.45 0.71 0.89 1.0
- srd 0.71 0.71 0.71
-4 lt 1.0 0.89 0.71 0.45
- rt 0.45 0.71 0.89 1.0
- lt srd 1.0 0.71
- rt srd 0.71 0.71
-4 lt 1.0 0.5
- ctr 0.87 1.0 0.87
- rt 0.5 1.0
- srd 0.71 0.71 0.71
-5 lt 1.0 0.5
- ctr 0.87 1.0 0.87
- rt 0.5 1.0
- lt srd 1.0 0.71
- rt srd 0.71 1.0
-6 lt 1.0 0.5
- lt ctr 0.87 0.71
- rt ctr 0.71 0.87
- rt 0.5 1.0
- lt srd 1.0 0.71
- rt srd 0.71 1.0
-6 lt 1.0 0.5
- ctr 0.86 1.0 0.86
- rt 0.5 1.0
- lt srd 1.0
- ctr srd 1.0
- rt srd 1.0
-7 lt 1.0
- lt ctr 1.0
- ctr 1.0
- rt ctr 1.0
- rt 1.0
- lt srd 1.0 0.71
- rt srd 0.71 1.0
-7 lt 1.0 0.5
- lt ctr 0.87 0.71
- rt ctr 0.71 0.87
- rt 0.5 1.0
- lt srd 1.0
- ctr srd 1.0
- rt srd 1.0
-8 lt 1.0 0.5
- lt ctr 0.87 0.71
- rt ctr 0.71 0.87
- rt 0.5 1.0
- lt 1 srd 0.87 0.35
- lt 2 srd 0.5 0.61
- rt 2 srd 0.61 0.50
- rt 2 srd 0.35 0.87
-
- Generation of Lt Rt
-
-In the case when the playback system has analog or digital surround multi-channel capability, a down matrix from 5, 4, or 3 channel to Lt Rt may be desirable. In the case when the number of decoded audio channels exceeds 5, 4 or 3 respectively a first stage down mix to 5, 4 or 3 chs should be used as described above.
-
-The down matrixing equations for 5-channel source audio to a two-channel Lt Rt playback system are given by:
-
-Left left+0.7*center-0.7*(lt surround+rt surround)
-
-Right=right+0.7*center+0.7*(lt surround+rt surround)
-
-Embedded mixing to 2-channel
-
-One concern arising from the proliferation of multi-channel audio systems is that most home systems presently have only two channel playback capability. To accommodate this a fixed 2-channel down matrix processes is commonly used following the multi-channel decoding stage. However, for music only applications the image quality etc. of the down matrixed signal may not match that of an equivalent stereo recording found on CD.
-
-The concept of embedded mixing is to allow the producer to dynamically specify the matrixing coefficients within the audio frame itself. In this way the stereo down mix at the decoder may be better matched to a 2-channel playback environment.
-
-CHS*2, 7-bit down mix indexes (MCOEFFS) are transmitted along with the multi-channel audio once in every frame. The indexes are converted to attenuation factors using a 7 bit LUT. The 2-ch down mix equations are as follows,
-
-Left Ch=sum (MCOEFF[n]*Ch[n]) for n=1, CHS
-
-Right Ch sum (MCOEFF[n+CHS]*Ch[n]) for n=1, CHS
-
-where Ch(n) represents the subband samples in the (n)th audio channel.
-
-
-*/
-
-#endif /* AVCODEC_DCADATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/dcadec.c b/src/thirdparty/ffmpeg/libavcodec/dcadec.c
deleted file mode 100644
index e2f37328a..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/dcadec.c
+++ /dev/null
@@ -1,2526 +0,0 @@
-/*
- * DCA compatible decoder
- * Copyright (C) 2004 Gildas Bazin
- * Copyright (C) 2004 Benjamin Zores
- * Copyright (C) 2006 Benjamin Larsson
- * Copyright (C) 2007 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 <math.h>
-#include <stddef.h>
-#include <stdio.h>
-
-#include "libavutil/channel_layout.h"
-#include "libavutil/common.h"
-#include "libavutil/float_dsp.h"
-#include "libavutil/internal.h"
-#include "libavutil/intmath.h"
-#include "libavutil/intreadwrite.h"
-#include "libavutil/mathematics.h"
-#include "libavutil/samplefmt.h"
-#include "avcodec.h"
-#include "fft.h"
-#include "get_bits.h"
-#include "put_bits.h"
-#include "dcadata.h"
-#include "dcahuff.h"
-#include "dca.h"
-#include "dca_parser.h"
-#include "synth_filter.h"
-#include "dcadsp.h"
-#include "fmtconvert.h"
-#include "internal.h"
-
-#if ARCH_ARM
-# include "arm/dca.h"
-#endif
-
-//#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)
-#define DCA_BLOCKS_MAX (16)
-#define DCA_LFE_MAX (3)
-#define DCA_CHSETS_MAX (4)
-#define DCA_CHSET_CHANS_MAX (8)
-
-enum DCAMode {
- DCA_MONO = 0,
- DCA_CHANNEL,
- DCA_STEREO,
- DCA_STEREO_SUMDIFF,
- DCA_STEREO_TOTAL,
- DCA_3F,
- DCA_2F1R,
- DCA_3F1R,
- DCA_2F2R,
- DCA_3F2R,
- DCA_4F2R
-};
-
-/* these are unconfirmed but should be mostly correct */
-enum DCAExSSSpeakerMask {
- DCA_EXSS_FRONT_CENTER = 0x0001,
- DCA_EXSS_FRONT_LEFT_RIGHT = 0x0002,
- DCA_EXSS_SIDE_REAR_LEFT_RIGHT = 0x0004,
- DCA_EXSS_LFE = 0x0008,
- DCA_EXSS_REAR_CENTER = 0x0010,
- DCA_EXSS_FRONT_HIGH_LEFT_RIGHT = 0x0020,
- DCA_EXSS_REAR_LEFT_RIGHT = 0x0040,
- DCA_EXSS_FRONT_HIGH_CENTER = 0x0080,
- DCA_EXSS_OVERHEAD = 0x0100,
- DCA_EXSS_CENTER_LEFT_RIGHT = 0x0200,
- DCA_EXSS_WIDE_LEFT_RIGHT = 0x0400,
- DCA_EXSS_SIDE_LEFT_RIGHT = 0x0800,
- DCA_EXSS_LFE2 = 0x1000,
- DCA_EXSS_SIDE_HIGH_LEFT_RIGHT = 0x2000,
- DCA_EXSS_REAR_HIGH_CENTER = 0x4000,
- DCA_EXSS_REAR_HIGH_LEFT_RIGHT = 0x8000,
-};
-
-enum DCAXxchSpeakerMask {
- DCA_XXCH_FRONT_CENTER = 0x0000001,
- DCA_XXCH_FRONT_LEFT = 0x0000002,
- DCA_XXCH_FRONT_RIGHT = 0x0000004,
- DCA_XXCH_SIDE_REAR_LEFT = 0x0000008,
- DCA_XXCH_SIDE_REAR_RIGHT = 0x0000010,
- DCA_XXCH_LFE1 = 0x0000020,
- DCA_XXCH_REAR_CENTER = 0x0000040,
- DCA_XXCH_SURROUND_REAR_LEFT = 0x0000080,
- DCA_XXCH_SURROUND_REAR_RIGHT = 0x0000100,
- DCA_XXCH_SIDE_SURROUND_LEFT = 0x0000200,
- DCA_XXCH_SIDE_SURROUND_RIGHT = 0x0000400,
- DCA_XXCH_FRONT_CENTER_LEFT = 0x0000800,
- DCA_XXCH_FRONT_CENTER_RIGHT = 0x0001000,
- DCA_XXCH_FRONT_HIGH_LEFT = 0x0002000,
- DCA_XXCH_FRONT_HIGH_CENTER = 0x0004000,
- DCA_XXCH_FRONT_HIGH_RIGHT = 0x0008000,
- DCA_XXCH_LFE2 = 0x0010000,
- DCA_XXCH_SIDE_FRONT_LEFT = 0x0020000,
- DCA_XXCH_SIDE_FRONT_RIGHT = 0x0040000,
- DCA_XXCH_OVERHEAD = 0x0080000,
- DCA_XXCH_SIDE_HIGH_LEFT = 0x0100000,
- DCA_XXCH_SIDE_HIGH_RIGHT = 0x0200000,
- DCA_XXCH_REAR_HIGH_CENTER = 0x0400000,
- DCA_XXCH_REAR_HIGH_LEFT = 0x0800000,
- DCA_XXCH_REAR_HIGH_RIGHT = 0x1000000,
- DCA_XXCH_REAR_LOW_CENTER = 0x2000000,
- DCA_XXCH_REAR_LOW_LEFT = 0x4000000,
- DCA_XXCH_REAR_LOW_RIGHT = 0x8000000,
-};
-
-static const uint32_t map_xxch_to_native[28] = {
- AV_CH_FRONT_CENTER,
- AV_CH_FRONT_LEFT,
- AV_CH_FRONT_RIGHT,
- AV_CH_SIDE_LEFT,
- AV_CH_SIDE_RIGHT,
- AV_CH_LOW_FREQUENCY,
- AV_CH_BACK_CENTER,
- AV_CH_BACK_LEFT,
- AV_CH_BACK_RIGHT,
- AV_CH_SIDE_LEFT, /* side surround left -- dup sur side L */
- AV_CH_SIDE_RIGHT, /* side surround right -- dup sur side R */
- AV_CH_FRONT_LEFT_OF_CENTER,
- AV_CH_FRONT_RIGHT_OF_CENTER,
- AV_CH_TOP_FRONT_LEFT,
- AV_CH_TOP_FRONT_CENTER,
- AV_CH_TOP_FRONT_RIGHT,
- AV_CH_LOW_FREQUENCY, /* lfe2 -- duplicate lfe1 position */
- AV_CH_FRONT_LEFT_OF_CENTER, /* side front left -- dup front cntr L */
- AV_CH_FRONT_RIGHT_OF_CENTER,/* side front right -- dup front cntr R */
- AV_CH_TOP_CENTER, /* overhead */
- AV_CH_TOP_FRONT_LEFT, /* side high left -- dup */
- AV_CH_TOP_FRONT_RIGHT, /* side high right -- dup */
- AV_CH_TOP_BACK_CENTER,
- AV_CH_TOP_BACK_LEFT,
- AV_CH_TOP_BACK_RIGHT,
- AV_CH_BACK_CENTER, /* rear low center -- dup */
- AV_CH_BACK_LEFT, /* rear low left -- dup */
- AV_CH_BACK_RIGHT /* read low right -- dup */
-};
-
-enum DCAExtensionMask {
- DCA_EXT_CORE = 0x001, ///< core in core substream
- DCA_EXT_XXCH = 0x002, ///< XXCh channels extension in core substream
- DCA_EXT_X96 = 0x004, ///< 96/24 extension in core substream
- DCA_EXT_XCH = 0x008, ///< XCh channel extension in core substream
- DCA_EXT_EXSS_CORE = 0x010, ///< core in ExSS (extension substream)
- DCA_EXT_EXSS_XBR = 0x020, ///< extended bitrate extension in ExSS
- DCA_EXT_EXSS_XXCH = 0x040, ///< XXCh channels extension in ExSS
- DCA_EXT_EXSS_X96 = 0x080, ///< 96/24 extension in ExSS
- DCA_EXT_EXSS_LBR = 0x100, ///< low bitrate component in ExSS
- DCA_EXT_EXSS_XLL = 0x200, ///< lossless extension in ExSS
-};
-
-/* -1 are reserved or unknown */
-static const int dca_ext_audio_descr_mask[] = {
- DCA_EXT_XCH,
- -1,
- DCA_EXT_X96,
- DCA_EXT_XCH | DCA_EXT_X96,
- -1,
- -1,
- DCA_EXT_XXCH,
- -1,
-};
-
-/* extensions that reside in core substream */
-#define DCA_CORE_EXTS (DCA_EXT_XCH | DCA_EXT_XXCH | DCA_EXT_X96)
-
-/* Tables for mapping dts channel configurations to libavcodec multichannel api.
- * Some compromises have been made for special configurations. Most configurations
- * are never used so complete accuracy is not needed.
- *
- * L = left, R = right, C = center, S = surround, F = front, R = rear, T = total, OV = overhead.
- * S -> side, when both rear and back are configured move one of them to the side channel
- * OV -> center back
- * All 2 channel configurations -> AV_CH_LAYOUT_STEREO
- */
-static const uint64_t dca_core_channel_layout[] = {
- AV_CH_FRONT_CENTER, ///< 1, A
- AV_CH_LAYOUT_STEREO, ///< 2, A + B (dual mono)
- AV_CH_LAYOUT_STEREO, ///< 2, L + R (stereo)
- AV_CH_LAYOUT_STEREO, ///< 2, (L + R) + (L - R) (sum-difference)
- AV_CH_LAYOUT_STEREO, ///< 2, LT + RT (left and right total)
- AV_CH_LAYOUT_STEREO | AV_CH_FRONT_CENTER, ///< 3, C + L + R
- AV_CH_LAYOUT_STEREO | AV_CH_BACK_CENTER, ///< 3, L + R + S
- AV_CH_LAYOUT_STEREO | AV_CH_FRONT_CENTER | AV_CH_BACK_CENTER, ///< 4, C + L + R + S
- AV_CH_LAYOUT_STEREO | AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT, ///< 4, L + R + SL + SR
-
- AV_CH_LAYOUT_STEREO | AV_CH_FRONT_CENTER | AV_CH_SIDE_LEFT |
- AV_CH_SIDE_RIGHT, ///< 5, C + L + R + SL + SR
-
- AV_CH_LAYOUT_STEREO | AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT |
- AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER, ///< 6, CL + CR + L + R + SL + SR
-
- AV_CH_LAYOUT_STEREO | AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT |
- AV_CH_FRONT_CENTER | AV_CH_BACK_CENTER, ///< 6, C + L + R + LR + RR + OV
-
- AV_CH_FRONT_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER |
- AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_BACK_CENTER |
- AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT, ///< 6, CF + CR + LF + RF + LR + RR
-
- AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_CENTER |
- AV_CH_FRONT_RIGHT_OF_CENTER | AV_CH_LAYOUT_STEREO |
- AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT, ///< 7, CL + C + CR + L + R + SL + SR
-
- AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER |
- AV_CH_LAYOUT_STEREO | AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT |
- AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT, ///< 8, CL + CR + L + R + SL1 + SL2 + SR1 + SR2
-
- AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_CENTER |
- AV_CH_FRONT_RIGHT_OF_CENTER | AV_CH_LAYOUT_STEREO |
- AV_CH_SIDE_LEFT | AV_CH_BACK_CENTER | AV_CH_SIDE_RIGHT, ///< 8, CL + C + CR + L + R + SL + S + SR
-};
-
-static const int8_t dca_lfe_index[] = {
- 1, 2, 2, 2, 2, 3, 2, 3, 2, 3, 2, 3, 1, 3, 2, 3
-};
-
-static const int8_t dca_channel_reorder_lfe[][9] = {
- { 0, -1, -1, -1, -1, -1, -1, -1, -1},
- { 0, 1, -1, -1, -1, -1, -1, -1, -1},
- { 0, 1, -1, -1, -1, -1, -1, -1, -1},
- { 0, 1, -1, -1, -1, -1, -1, -1, -1},
- { 0, 1, -1, -1, -1, -1, -1, -1, -1},
- { 2, 0, 1, -1, -1, -1, -1, -1, -1},
- { 0, 1, 3, -1, -1, -1, -1, -1, -1},
- { 2, 0, 1, 4, -1, -1, -1, -1, -1},
- { 0, 1, 3, 4, -1, -1, -1, -1, -1},
- { 2, 0, 1, 4, 5, -1, -1, -1, -1},
- { 3, 4, 0, 1, 5, 6, -1, -1, -1},
- { 2, 0, 1, 4, 5, 6, -1, -1, -1},
- { 0, 6, 4, 5, 2, 3, -1, -1, -1},
- { 4, 2, 5, 0, 1, 6, 7, -1, -1},
- { 5, 6, 0, 1, 7, 3, 8, 4, -1},
- { 4, 2, 5, 0, 1, 6, 8, 7, -1},
-};
-
-static const int8_t dca_channel_reorder_lfe_xch[][9] = {
- { 0, 2, -1, -1, -1, -1, -1, -1, -1},
- { 0, 1, 3, -1, -1, -1, -1, -1, -1},
- { 0, 1, 3, -1, -1, -1, -1, -1, -1},
- { 0, 1, 3, -1, -1, -1, -1, -1, -1},
- { 0, 1, 3, -1, -1, -1, -1, -1, -1},
- { 2, 0, 1, 4, -1, -1, -1, -1, -1},
- { 0, 1, 3, 4, -1, -1, -1, -1, -1},
- { 2, 0, 1, 4, 5, -1, -1, -1, -1},
- { 0, 1, 4, 5, 3, -1, -1, -1, -1},
- { 2, 0, 1, 5, 6, 4, -1, -1, -1},
- { 3, 4, 0, 1, 6, 7, 5, -1, -1},
- { 2, 0, 1, 4, 5, 6, 7, -1, -1},
- { 0, 6, 4, 5, 2, 3, 7, -1, -1},
- { 4, 2, 5, 0, 1, 7, 8, 6, -1},
- { 5, 6, 0, 1, 8, 3, 9, 4, 7},
- { 4, 2, 5, 0, 1, 6, 9, 8, 7},
-};
-
-static const int8_t dca_channel_reorder_nolfe[][9] = {
- { 0, -1, -1, -1, -1, -1, -1, -1, -1},
- { 0, 1, -1, -1, -1, -1, -1, -1, -1},
- { 0, 1, -1, -1, -1, -1, -1, -1, -1},
- { 0, 1, -1, -1, -1, -1, -1, -1, -1},
- { 0, 1, -1, -1, -1, -1, -1, -1, -1},
- { 2, 0, 1, -1, -1, -1, -1, -1, -1},
- { 0, 1, 2, -1, -1, -1, -1, -1, -1},
- { 2, 0, 1, 3, -1, -1, -1, -1, -1},
- { 0, 1, 2, 3, -1, -1, -1, -1, -1},
- { 2, 0, 1, 3, 4, -1, -1, -1, -1},
- { 2, 3, 0, 1, 4, 5, -1, -1, -1},
- { 2, 0, 1, 3, 4, 5, -1, -1, -1},
- { 0, 5, 3, 4, 1, 2, -1, -1, -1},
- { 3, 2, 4, 0, 1, 5, 6, -1, -1},
- { 4, 5, 0, 1, 6, 2, 7, 3, -1},
- { 3, 2, 4, 0, 1, 5, 7, 6, -1},
-};
-
-static const int8_t dca_channel_reorder_nolfe_xch[][9] = {
- { 0, 1, -1, -1, -1, -1, -1, -1, -1},
- { 0, 1, 2, -1, -1, -1, -1, -1, -1},
- { 0, 1, 2, -1, -1, -1, -1, -1, -1},
- { 0, 1, 2, -1, -1, -1, -1, -1, -1},
- { 0, 1, 2, -1, -1, -1, -1, -1, -1},
- { 2, 0, 1, 3, -1, -1, -1, -1, -1},
- { 0, 1, 2, 3, -1, -1, -1, -1, -1},
- { 2, 0, 1, 3, 4, -1, -1, -1, -1},
- { 0, 1, 3, 4, 2, -1, -1, -1, -1},
- { 2, 0, 1, 4, 5, 3, -1, -1, -1},
- { 2, 3, 0, 1, 5, 6, 4, -1, -1},
- { 2, 0, 1, 3, 4, 5, 6, -1, -1},
- { 0, 5, 3, 4, 1, 2, 6, -1, -1},
- { 3, 2, 4, 0, 1, 6, 7, 5, -1},
- { 4, 5, 0, 1, 7, 2, 8, 3, 6},
- { 3, 2, 4, 0, 1, 5, 8, 7, 6},
-};
-
-#define DCA_DOLBY 101 /* FIXME */
-
-#define DCA_CHANNEL_BITS 6
-#define DCA_CHANNEL_MASK 0x3F
-
-#define DCA_LFE 0x80
-
-#define HEADER_SIZE 14
-
-#define DCA_MAX_FRAME_SIZE 16384
-#define DCA_MAX_EXSS_HEADER_SIZE 4096
-
-#define DCA_BUFFER_PADDING_SIZE 1024
-
-/** Bit allocation */
-typedef struct {
- int offset; ///< code values offset
- int maxbits[8]; ///< max bits in VLC
- int wrap; ///< wrap for get_vlc2()
- VLC vlc[8]; ///< actual codes
-} BitAlloc;
-
-static BitAlloc dca_bitalloc_index; ///< indexes for samples VLC select
-static BitAlloc dca_tmode; ///< transition mode VLCs
-static BitAlloc dca_scalefactor; ///< scalefactor VLCs
-static BitAlloc dca_smpl_bitalloc[11]; ///< samples VLCs
-
-static av_always_inline int get_bitalloc(GetBitContext *gb, BitAlloc *ba,
- int idx)
-{
- return get_vlc2(gb, ba->vlc[idx].table, ba->vlc[idx].bits, ba->wrap) +
- ba->offset;
-}
-
-typedef struct {
- AVCodecContext *avctx;
- /* Frame header */
- int frame_type; ///< type of the current frame
- int samples_deficit; ///< deficit sample count
- int crc_present; ///< crc is present in the bitstream
- int sample_blocks; ///< number of PCM sample blocks
- int frame_size; ///< primary frame byte size
- int amode; ///< audio channels arrangement
- int sample_rate; ///< audio sampling rate
- int bit_rate; ///< transmission bit rate
- int bit_rate_index; ///< transmission bit rate index
-
- int downmix; ///< embedded downmix enabled
- int dynrange; ///< embedded dynamic range flag
- int timestamp; ///< embedded time stamp flag
- int aux_data; ///< auxiliary data flag
- int hdcd; ///< source material is mastered in HDCD
- int ext_descr; ///< extension audio descriptor flag
- int ext_coding; ///< extended coding flag
- int aspf; ///< audio sync word insertion flag
- int lfe; ///< low frequency effects flag
- int predictor_history; ///< predictor history flag
- int header_crc; ///< header crc check bytes
- int multirate_inter; ///< multirate interpolator switch
- int version; ///< encoder software revision
- int copy_history; ///< copy history
- int source_pcm_res; ///< source pcm resolution
- int front_sum; ///< front sum/difference flag
- int surround_sum; ///< surround sum/difference flag
- int dialog_norm; ///< dialog normalisation parameter
-
- /* Primary audio coding header */
- int subframes; ///< number of subframes
- int total_channels; ///< number of channels including extensions
- int prim_channels; ///< number of primary audio channels
- int subband_activity[DCA_PRIM_CHANNELS_MAX]; ///< subband activity count
- int vq_start_subband[DCA_PRIM_CHANNELS_MAX]; ///< high frequency vq start subband
- int joint_intensity[DCA_PRIM_CHANNELS_MAX]; ///< joint intensity coding index
- int transient_huffman[DCA_PRIM_CHANNELS_MAX]; ///< transient mode code book
- int scalefactor_huffman[DCA_PRIM_CHANNELS_MAX]; ///< scale factor code book
- int bitalloc_huffman[DCA_PRIM_CHANNELS_MAX]; ///< bit allocation quantizer select
- int quant_index_huffman[DCA_PRIM_CHANNELS_MAX][DCA_ABITS_MAX]; ///< quantization index codebook select
- float scalefactor_adj[DCA_PRIM_CHANNELS_MAX][DCA_ABITS_MAX]; ///< scale factor adjustment
-
- /* Primary audio coding side information */
- int subsubframes[DCA_SUBFRAMES_MAX]; ///< number of subsubframes
- int partial_samples[DCA_SUBFRAMES_MAX]; ///< partial subsubframe samples count
- int prediction_mode[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< prediction mode (ADPCM used or not)
- 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)
- 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
- int downmix_coef[DCA_PRIM_CHANNELS_MAX][2]; ///< stereo downmix coefficients
- int dynrange_coef; ///< dynamic range coefficient
-
- int 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;
-
- /* Subband samples history (for ADPCM) */
- DECLARE_ALIGNED(16, float, subband_samples_hist)[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][4];
- DECLARE_ALIGNED(32, float, subband_fir_hist)[DCA_PRIM_CHANNELS_MAX][512];
- DECLARE_ALIGNED(32, float, subband_fir_noidea)[DCA_PRIM_CHANNELS_MAX][32];
- int hist_index[DCA_PRIM_CHANNELS_MAX];
- DECLARE_ALIGNED(32, float, raXin)[32];
-
- int output; ///< type of output
-
- DECLARE_ALIGNED(32, float, subband_samples)[DCA_BLOCKS_MAX][DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][8];
- float *samples_chanptr[DCA_PRIM_CHANNELS_MAX + 1];
- float *extra_channels[DCA_PRIM_CHANNELS_MAX + 1];
- uint8_t *extra_channels_buffer;
- unsigned int extra_channels_buffer_size;
-
- uint8_t dca_buffer[DCA_MAX_FRAME_SIZE + DCA_MAX_EXSS_HEADER_SIZE + DCA_BUFFER_PADDING_SIZE];
- int dca_buffer_size; ///< how much data is in the dca_buffer
-
- const int8_t *channel_order_tab; ///< channel reordering table, lfe and non lfe
- GetBitContext gb;
- /* Current position in DCA frame */
- int current_subframe;
- int current_subsubframe;
-
- int core_ext_mask; ///< present extensions in the core substream
-
- /* XCh extension information */
- int xch_present; ///< XCh extension present and valid
- int xch_base_channel; ///< index of first (only) channel containing XCH data
-
- /* XXCH extension information */
- int xxch_chset;
- int xxch_nbits_spk_mask;
- uint32_t xxch_core_spkmask;
- uint32_t xxch_spk_masks[4]; /* speaker masks, last element is core mask */
- int xxch_chset_nch[4];
- float xxch_dmix_sf[DCA_CHSETS_MAX];
-
- uint32_t xxch_dmix_embedded; /* lower layer has mix pre-embedded, per chset */
- float xxch_dmix_coeff[DCA_PRIM_CHANNELS_MAX][32]; /* worst case sizing */
-
- int8_t xxch_order_tab[32];
- int8_t lfe_index;
-
- /* ExSS header parser */
- int static_fields; ///< static fields present
- int mix_metadata; ///< mixing metadata present
- int num_mix_configs; ///< number of mix out configurations
- int mix_config_num_ch[4]; ///< number of channels in each mix out configuration
-
- int profile;
-
- int debug_flag; ///< used for suppressing repeated error messages output
- AVFloatDSPContext fdsp;
- FFTContext imdct;
- SynthFilterContext synth;
- DCADSPContext dcadsp;
- FmtConvertContext fmt_conv;
-} DCAContext;
-
-static const uint16_t dca_vlc_offs[] = {
- 0, 512, 640, 768, 1282, 1794, 2436, 3080, 3770, 4454, 5364,
- 5372, 5380, 5388, 5392, 5396, 5412, 5420, 5428, 5460, 5492, 5508,
- 5572, 5604, 5668, 5796, 5860, 5892, 6412, 6668, 6796, 7308, 7564,
- 7820, 8076, 8620, 9132, 9388, 9910, 10166, 10680, 11196, 11726, 12240,
- 12752, 13298, 13810, 14326, 14840, 15500, 16022, 16540, 17158, 17678, 18264,
- 18796, 19352, 19926, 20468, 21472, 22398, 23014, 23622,
-};
-
-static av_cold void dca_init_vlcs(void)
-{
- static int vlcs_initialized = 0;
- int i, j, c = 14;
- static VLC_TYPE dca_table[23622][2];
-
- if (vlcs_initialized)
- return;
-
- dca_bitalloc_index.offset = 1;
- dca_bitalloc_index.wrap = 2;
- for (i = 0; i < 5; i++) {
- dca_bitalloc_index.vlc[i].table = &dca_table[dca_vlc_offs[i]];
- dca_bitalloc_index.vlc[i].table_allocated = dca_vlc_offs[i + 1] - dca_vlc_offs[i];
- init_vlc(&dca_bitalloc_index.vlc[i], bitalloc_12_vlc_bits[i], 12,
- bitalloc_12_bits[i], 1, 1,
- bitalloc_12_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC);
- }
- dca_scalefactor.offset = -64;
- dca_scalefactor.wrap = 2;
- for (i = 0; i < 5; i++) {
- dca_scalefactor.vlc[i].table = &dca_table[dca_vlc_offs[i + 5]];
- dca_scalefactor.vlc[i].table_allocated = dca_vlc_offs[i + 6] - dca_vlc_offs[i + 5];
- init_vlc(&dca_scalefactor.vlc[i], SCALES_VLC_BITS, 129,
- scales_bits[i], 1, 1,
- scales_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC);
- }
- dca_tmode.offset = 0;
- dca_tmode.wrap = 1;
- for (i = 0; i < 4; i++) {
- dca_tmode.vlc[i].table = &dca_table[dca_vlc_offs[i + 10]];
- dca_tmode.vlc[i].table_allocated = dca_vlc_offs[i + 11] - dca_vlc_offs[i + 10];
- init_vlc(&dca_tmode.vlc[i], tmode_vlc_bits[i], 4,
- tmode_bits[i], 1, 1,
- tmode_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC);
- }
-
- for (i = 0; i < 10; i++)
- for (j = 0; j < 7; j++) {
- if (!bitalloc_codes[i][j])
- break;
- dca_smpl_bitalloc[i + 1].offset = bitalloc_offsets[i];
- dca_smpl_bitalloc[i + 1].wrap = 1 + (j > 4);
- dca_smpl_bitalloc[i + 1].vlc[j].table = &dca_table[dca_vlc_offs[c]];
- dca_smpl_bitalloc[i + 1].vlc[j].table_allocated = dca_vlc_offs[c + 1] - dca_vlc_offs[c];
-
- init_vlc(&dca_smpl_bitalloc[i + 1].vlc[j], bitalloc_maxbits[i][j],
- bitalloc_sizes[i],
- bitalloc_bits[i][j], 1, 1,
- bitalloc_codes[i][j], 2, 2, INIT_VLC_USE_NEW_STATIC);
- c++;
- }
- vlcs_initialized = 1;
-}
-
-static inline void get_array(GetBitContext *gb, int *dst, int len, int bits)
-{
- while (len--)
- *dst++ = get_bits(gb, bits);
-}
-
-static inline int dca_xxch2index(DCAContext *s, int xxch_ch)
-{
- int i, base, mask;
-
- /* locate channel set containing the channel */
- for (i = -1, base = 0, mask = (s->xxch_core_spkmask & ~DCA_XXCH_LFE1);
- i <= s->xxch_chset && !(mask & xxch_ch); mask = s->xxch_spk_masks[++i])
- base += av_popcount(mask);
-
- return base + av_popcount(mask & (xxch_ch - 1));
-}
-
-static int dca_parse_audio_coding_header(DCAContext *s, int base_channel,
- int xxch)
-{
- int i, j;
- static const float adj_table[4] = { 1.0, 1.1250, 1.2500, 1.4375 };
- static const int bitlen[11] = { 0, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3 };
- static const int thr[11] = { 0, 1, 3, 3, 3, 3, 7, 7, 7, 7, 7 };
- int hdr_pos = 0, hdr_size = 0;
- float sign, mag, scale_factor;
- int this_chans, acc_mask;
- int embedded_downmix;
- int nchans, mask[8];
- int coeff, ichan;
-
- /* xxch has arbitrary sized audio coding headers */
- if (xxch) {
- hdr_pos = get_bits_count(&s->gb);
- hdr_size = get_bits(&s->gb, 7) + 1;
- }
-
- nchans = get_bits(&s->gb, 3) + 1;
- s->total_channels = nchans + base_channel;
- s->prim_channels = s->total_channels;
-
- /* obtain speaker layout mask & downmix coefficients for XXCH */
- if (xxch) {
- acc_mask = s->xxch_core_spkmask;
-
- this_chans = get_bits(&s->gb, s->xxch_nbits_spk_mask - 6) << 6;
- s->xxch_spk_masks[s->xxch_chset] = this_chans;
- s->xxch_chset_nch[s->xxch_chset] = nchans;
-
- for (i = 0; i <= s->xxch_chset; i++)
- acc_mask |= s->xxch_spk_masks[i];
-
- /* check for downmixing information */
- if (get_bits1(&s->gb)) {
- embedded_downmix = get_bits1(&s->gb);
- scale_factor =
- 1.0f / dca_downmix_scale_factors[(get_bits(&s->gb, 6) - 1) << 2];
-
- s->xxch_dmix_sf[s->xxch_chset] = scale_factor;
-
- for (i = base_channel; i < s->prim_channels; i++) {
- mask[i] = get_bits(&s->gb, s->xxch_nbits_spk_mask);
- }
-
- for (j = base_channel; j < s->prim_channels; j++) {
- memset(s->xxch_dmix_coeff[j], 0, sizeof(s->xxch_dmix_coeff[0]));
- s->xxch_dmix_embedded |= (embedded_downmix << j);
- for (i = 0; i < s->xxch_nbits_spk_mask; i++) {
- if (mask[j] & (1 << i)) {
- if ((1 << i) == DCA_XXCH_LFE1) {
- av_log(s->avctx, AV_LOG_WARNING,
- "DCA-XXCH: dmix to LFE1 not supported.\n");
- continue;
- }
-
- coeff = get_bits(&s->gb, 7);
- sign = (coeff & 64) ? 1.0 : -1.0;
- mag = dca_downmix_scale_factors[((coeff & 63) - 1) << 2];
- ichan = dca_xxch2index(s, 1 << i);
- s->xxch_dmix_coeff[j][ichan] = sign * mag;
- }
- }
- }
- }
- }
-
- if (s->prim_channels > DCA_PRIM_CHANNELS_MAX)
- s->prim_channels = DCA_PRIM_CHANNELS_MAX;
-
-
- for (i = base_channel; i < s->prim_channels; i++) {
- s->subband_activity[i] = get_bits(&s->gb, 5) + 2;
- if (s->subband_activity[i] > DCA_SUBBANDS)
- s->subband_activity[i] = DCA_SUBBANDS;
- }
- for (i = base_channel; i < s->prim_channels; i++) {
- s->vq_start_subband[i] = get_bits(&s->gb, 5) + 1;
- if (s->vq_start_subband[i] > DCA_SUBBANDS)
- s->vq_start_subband[i] = DCA_SUBBANDS;
- }
- get_array(&s->gb, s->joint_intensity + base_channel, s->prim_channels - base_channel, 3);
- get_array(&s->gb, s->transient_huffman + base_channel, s->prim_channels - base_channel, 2);
- get_array(&s->gb, s->scalefactor_huffman + base_channel, s->prim_channels - base_channel, 3);
- get_array(&s->gb, s->bitalloc_huffman + base_channel, s->prim_channels - base_channel, 3);
-
- /* Get codebooks quantization indexes */
- if (!base_channel)
- memset(s->quant_index_huffman, 0, sizeof(s->quant_index_huffman));
- for (j = 1; j < 11; j++)
- for (i = base_channel; i < s->prim_channels; i++)
- s->quant_index_huffman[i][j] = get_bits(&s->gb, bitlen[j]);
-
- /* Get scale factor adjustment */
- for (j = 0; j < 11; j++)
- for (i = base_channel; i < s->prim_channels; i++)
- s->scalefactor_adj[i][j] = 1;
-
- for (j = 1; j < 11; j++)
- for (i = base_channel; i < s->prim_channels; i++)
- if (s->quant_index_huffman[i][j] < thr[j])
- s->scalefactor_adj[i][j] = adj_table[get_bits(&s->gb, 2)];
-
- if (!xxch) {
- if (s->crc_present) {
- /* Audio header CRC check */
- get_bits(&s->gb, 16);
- }
- } else {
- /* Skip to the end of the header, also ignore CRC if present */
- i = get_bits_count(&s->gb);
- if (hdr_pos + 8 * hdr_size > i)
- skip_bits_long(&s->gb, hdr_pos + 8 * hdr_size - i);
- }
-
- s->current_subframe = 0;
- s->current_subsubframe = 0;
-
-#ifdef TRACE
- av_log(s->avctx, AV_LOG_DEBUG, "subframes: %i\n", s->subframes);
- av_log(s->avctx, AV_LOG_DEBUG, "prim channels: %i\n", s->prim_channels);
- for (i = base_channel; i < s->prim_channels; i++) {
- av_log(s->avctx, AV_LOG_DEBUG, "subband activity: %i\n",
- s->subband_activity[i]);
- av_log(s->avctx, AV_LOG_DEBUG, "vq start subband: %i\n",
- s->vq_start_subband[i]);
- av_log(s->avctx, AV_LOG_DEBUG, "joint intensity: %i\n",
- s->joint_intensity[i]);
- av_log(s->avctx, AV_LOG_DEBUG, "transient mode codebook: %i\n",
- s->transient_huffman[i]);
- av_log(s->avctx, AV_LOG_DEBUG, "scale factor codebook: %i\n",
- s->scalefactor_huffman[i]);
- av_log(s->avctx, AV_LOG_DEBUG, "bit allocation quantizer: %i\n",
- s->bitalloc_huffman[i]);
- av_log(s->avctx, AV_LOG_DEBUG, "quant index huff:");
- for (j = 0; j < 11; j++)
- av_log(s->avctx, AV_LOG_DEBUG, " %i", s->quant_index_huffman[i][j]);
- av_log(s->avctx, AV_LOG_DEBUG, "\n");
- av_log(s->avctx, AV_LOG_DEBUG, "scalefac adj:");
- for (j = 0; j < 11; j++)
- av_log(s->avctx, AV_LOG_DEBUG, " %1.3f", s->scalefactor_adj[i][j]);
- av_log(s->avctx, AV_LOG_DEBUG, "\n");
- }
-#endif
-
- return 0;
-}
-
-static int dca_parse_frame_header(DCAContext *s)
-{
- init_get_bits(&s->gb, s->dca_buffer, s->dca_buffer_size * 8);
-
- /* Sync code */
- skip_bits_long(&s->gb, 32);
-
- /* Frame header */
- s->frame_type = get_bits(&s->gb, 1);
- s->samples_deficit = get_bits(&s->gb, 5) + 1;
- s->crc_present = get_bits(&s->gb, 1);
- s->sample_blocks = get_bits(&s->gb, 7) + 1;
- s->frame_size = get_bits(&s->gb, 14) + 1;
- if (s->frame_size < 95)
- return AVERROR_INVALIDDATA;
- s->amode = get_bits(&s->gb, 6);
- s->sample_rate = avpriv_dca_sample_rates[get_bits(&s->gb, 4)];
- if (!s->sample_rate)
- return AVERROR_INVALIDDATA;
- s->bit_rate_index = get_bits(&s->gb, 5);
- s->bit_rate = dca_bit_rates[s->bit_rate_index];
- if (!s->bit_rate)
- return AVERROR_INVALIDDATA;
-
- s->downmix = get_bits(&s->gb, 1); /* note: this is FixedBit == 0 */
- s->dynrange = get_bits(&s->gb, 1);
- s->timestamp = get_bits(&s->gb, 1);
- s->aux_data = get_bits(&s->gb, 1);
- s->hdcd = get_bits(&s->gb, 1);
- s->ext_descr = get_bits(&s->gb, 3);
- s->ext_coding = get_bits(&s->gb, 1);
- s->aspf = get_bits(&s->gb, 1);
- s->lfe = get_bits(&s->gb, 2);
- s->predictor_history = get_bits(&s->gb, 1);
-
- if (s->lfe == 3) {
- s->lfe = 0;
- av_log_ask_for_sample(s->avctx, "LFE is 3\n");
- return AVERROR_PATCHWELCOME;
- }
-
- /* TODO: check CRC */
- if (s->crc_present)
- s->header_crc = get_bits(&s->gb, 16);
-
- s->multirate_inter = get_bits(&s->gb, 1);
- s->version = get_bits(&s->gb, 4);
- s->copy_history = get_bits(&s->gb, 2);
- s->source_pcm_res = get_bits(&s->gb, 3);
- s->front_sum = get_bits(&s->gb, 1);
- s->surround_sum = get_bits(&s->gb, 1);
- s->dialog_norm = get_bits(&s->gb, 4);
-
- /* FIXME: channels mixing levels */
- s->output = s->amode;
- if (s->lfe)
- s->output |= DCA_LFE;
-
-#ifdef TRACE
- av_log(s->avctx, AV_LOG_DEBUG, "frame type: %i\n", s->frame_type);
- av_log(s->avctx, AV_LOG_DEBUG, "samples deficit: %i\n", s->samples_deficit);
- av_log(s->avctx, AV_LOG_DEBUG, "crc present: %i\n", s->crc_present);
- av_log(s->avctx, AV_LOG_DEBUG, "sample blocks: %i (%i samples)\n",
- s->sample_blocks, s->sample_blocks * 32);
- av_log(s->avctx, AV_LOG_DEBUG, "frame size: %i bytes\n", s->frame_size);
- av_log(s->avctx, AV_LOG_DEBUG, "amode: %i (%i channels)\n",
- s->amode, dca_channels[s->amode]);
- av_log(s->avctx, AV_LOG_DEBUG, "sample rate: %i Hz\n",
- s->sample_rate);
- av_log(s->avctx, AV_LOG_DEBUG, "bit rate: %i bits/s\n",
- s->bit_rate);
- av_log(s->avctx, AV_LOG_DEBUG, "downmix: %i\n", s->downmix);
- av_log(s->avctx, AV_LOG_DEBUG, "dynrange: %i\n", s->dynrange);
- av_log(s->avctx, AV_LOG_DEBUG, "timestamp: %i\n", s->timestamp);
- av_log(s->avctx, AV_LOG_DEBUG, "aux_data: %i\n", s->aux_data);
- av_log(s->avctx, AV_LOG_DEBUG, "hdcd: %i\n", s->hdcd);
- av_log(s->avctx, AV_LOG_DEBUG, "ext descr: %i\n", s->ext_descr);
- av_log(s->avctx, AV_LOG_DEBUG, "ext coding: %i\n", s->ext_coding);
- av_log(s->avctx, AV_LOG_DEBUG, "aspf: %i\n", s->aspf);
- av_log(s->avctx, AV_LOG_DEBUG, "lfe: %i\n", s->lfe);
- av_log(s->avctx, AV_LOG_DEBUG, "predictor history: %i\n",
- s->predictor_history);
- av_log(s->avctx, AV_LOG_DEBUG, "header crc: %i\n", s->header_crc);
- av_log(s->avctx, AV_LOG_DEBUG, "multirate inter: %i\n",
- s->multirate_inter);
- av_log(s->avctx, AV_LOG_DEBUG, "version number: %i\n", s->version);
- av_log(s->avctx, AV_LOG_DEBUG, "copy history: %i\n", s->copy_history);
- av_log(s->avctx, AV_LOG_DEBUG,
- "source pcm resolution: %i (%i bits/sample)\n",
- s->source_pcm_res, dca_bits_per_sample[s->source_pcm_res]);
- av_log(s->avctx, AV_LOG_DEBUG, "front sum: %i\n", s->front_sum);
- av_log(s->avctx, AV_LOG_DEBUG, "surround sum: %i\n", s->surround_sum);
- av_log(s->avctx, AV_LOG_DEBUG, "dialog norm: %i\n", s->dialog_norm);
- av_log(s->avctx, AV_LOG_DEBUG, "\n");
-#endif
-
- /* Primary audio coding header */
- s->subframes = get_bits(&s->gb, 4) + 1;
-
- return dca_parse_audio_coding_header(s, 0, 0);
-}
-
-
-static inline int get_scale(GetBitContext *gb, int level, int value, int log2range)
-{
- if (level < 5) {
- /* huffman encoded */
- value += get_bitalloc(gb, &dca_scalefactor, level);
- value = av_clip(value, 0, (1 << log2range) - 1);
- } else if (level < 8) {
- if (level + 1 > log2range) {
- skip_bits(gb, level + 1 - log2range);
- value = get_bits(gb, log2range);
- } else {
- value = get_bits(gb, level + 1);
- }
- }
- return value;
-}
-
-static int dca_subframe_header(DCAContext *s, int base_channel, int block_index)
-{
- /* Primary audio coding side information */
- int j, k;
-
- if (get_bits_left(&s->gb) < 0)
- return AVERROR_INVALIDDATA;
-
- if (!base_channel) {
- s->subsubframes[s->current_subframe] = get_bits(&s->gb, 2) + 1;
- s->partial_samples[s->current_subframe] = get_bits(&s->gb, 3);
- }
-
- for (j = base_channel; j < s->prim_channels; j++) {
- for (k = 0; k < s->subband_activity[j]; k++)
- s->prediction_mode[j][k] = get_bits(&s->gb, 1);
- }
-
- /* Get prediction codebook */
- for (j = base_channel; j < s->prim_channels; j++) {
- for (k = 0; k < s->subband_activity[j]; k++) {
- if (s->prediction_mode[j][k] > 0) {
- /* (Prediction coefficient VQ address) */
- s->prediction_vq[j][k] = get_bits(&s->gb, 12);
- }
- }
- }
-
- /* Bit allocation index */
- for (j = base_channel; j < s->prim_channels; j++) {
- for (k = 0; k < s->vq_start_subband[j]; k++) {
- if (s->bitalloc_huffman[j] == 6)
- s->bitalloc[j][k] = get_bits(&s->gb, 5);
- else if (s->bitalloc_huffman[j] == 5)
- s->bitalloc[j][k] = get_bits(&s->gb, 4);
- else if (s->bitalloc_huffman[j] == 7) {
- av_log(s->avctx, AV_LOG_ERROR,
- "Invalid bit allocation index\n");
- return AVERROR_INVALIDDATA;
- } else {
- s->bitalloc[j][k] =
- get_bitalloc(&s->gb, &dca_bitalloc_index, s->bitalloc_huffman[j]);
- }
-
- if (s->bitalloc[j][k] > 26) {
- av_dlog(s->avctx, "bitalloc index [%i][%i] too big (%i)\n",
- j, k, s->bitalloc[j][k]);
- return AVERROR_INVALIDDATA;
- }
- }
- }
-
- /* Transition mode */
- for (j = base_channel; j < s->prim_channels; j++) {
- for (k = 0; k < s->subband_activity[j]; k++) {
- s->transition_mode[j][k] = 0;
- if (s->subsubframes[s->current_subframe] > 1 &&
- k < s->vq_start_subband[j] && s->bitalloc[j][k] > 0) {
- s->transition_mode[j][k] =
- get_bitalloc(&s->gb, &dca_tmode, s->transient_huffman[j]);
- }
- }
- }
-
- if (get_bits_left(&s->gb) < 0)
- return AVERROR_INVALIDDATA;
-
- for (j = base_channel; j < s->prim_channels; j++) {
- const uint32_t *scale_table;
- int scale_sum, log_size;
-
- memset(s->scale_factor[j], 0,
- s->subband_activity[j] * sizeof(s->scale_factor[0][0][0]) * 2);
-
- if (s->scalefactor_huffman[j] == 6) {
- scale_table = scale_factor_quant7;
- log_size = 7;
- } else {
- scale_table = scale_factor_quant6;
- log_size = 6;
- }
-
- /* When huffman coded, only the difference is encoded */
- scale_sum = 0;
-
- for (k = 0; k < s->subband_activity[j]; k++) {
- if (k >= s->vq_start_subband[j] || s->bitalloc[j][k] > 0) {
- scale_sum = get_scale(&s->gb, s->scalefactor_huffman[j], scale_sum, log_size);
- s->scale_factor[j][k][0] = scale_table[scale_sum];
- }
-
- if (k < s->vq_start_subband[j] && s->transition_mode[j][k]) {
- /* Get second scale factor */
- scale_sum = get_scale(&s->gb, s->scalefactor_huffman[j], scale_sum, log_size);
- s->scale_factor[j][k][1] = scale_table[scale_sum];
- }
- }
- }
-
- /* Joint subband scale factor codebook select */
- for (j = base_channel; j < s->prim_channels; j++) {
- /* Transmitted only if joint subband coding enabled */
- if (s->joint_intensity[j] > 0)
- s->joint_huff[j] = get_bits(&s->gb, 3);
- }
-
- if (get_bits_left(&s->gb) < 0)
- return AVERROR_INVALIDDATA;
-
- /* Scale factors for joint subband coding */
- for (j = base_channel; j < s->prim_channels; j++) {
- int source_channel;
-
- /* Transmitted only if joint subband coding enabled */
- if (s->joint_intensity[j] > 0) {
- int scale = 0;
- source_channel = s->joint_intensity[j] - 1;
-
- /* When huffman coded, only the difference is encoded
- * (is this valid as well for joint scales ???) */
-
- for (k = s->subband_activity[j]; k < s->subband_activity[source_channel]; k++) {
- scale = get_scale(&s->gb, s->joint_huff[j], 64 /* bias */, 7);
- s->joint_scale_factor[j][k] = scale; /*joint_scale_table[scale]; */
- }
-
- if (!(s->debug_flag & 0x02)) {
- av_log(s->avctx, AV_LOG_DEBUG,
- "Joint stereo coding not supported\n");
- s->debug_flag |= 0x02;
- }
- }
- }
-
- /* Stereo downmix coefficients */
- if (!base_channel && s->prim_channels > 2) {
- if (s->downmix) {
- for (j = base_channel; j < s->prim_channels; j++) {
- s->downmix_coef[j][0] = get_bits(&s->gb, 7);
- s->downmix_coef[j][1] = get_bits(&s->gb, 7);
- }
- } else {
- int am = s->amode & DCA_CHANNEL_MASK;
- if (am >= FF_ARRAY_ELEMS(dca_default_coeffs)) {
- av_log(s->avctx, AV_LOG_ERROR,
- "Invalid channel mode %d\n", am);
- return AVERROR_INVALIDDATA;
- }
- for (j = base_channel; j < FFMIN(s->prim_channels, FF_ARRAY_ELEMS(dca_default_coeffs[am])); j++) {
- s->downmix_coef[j][0] = dca_default_coeffs[am][j][0];
- s->downmix_coef[j][1] = dca_default_coeffs[am][j][1];
- }
- }
- }
-
- /* Dynamic range coefficient */
- if (!base_channel && s->dynrange)
- s->dynrange_coef = get_bits(&s->gb, 8);
-
- /* Side information CRC check word */
- if (s->crc_present) {
- get_bits(&s->gb, 16);
- }
-
- /*
- * Primary audio data arrays
- */
-
- /* VQ encoded high frequency subbands */
- for (j = base_channel; j < s->prim_channels; j++)
- for (k = s->vq_start_subband[j]; k < s->subband_activity[j]; k++)
- /* 1 vector -> 32 samples */
- s->high_freq_vq[j][k] = get_bits(&s->gb, 10);
-
- /* Low frequency effect data */
- if (!base_channel && s->lfe) {
- int quant7;
- /* LFE samples */
- int lfe_samples = 2 * s->lfe * (4 + block_index);
- int lfe_end_sample = 2 * s->lfe * (4 + block_index + s->subsubframes[s->current_subframe]);
- float lfe_scale;
-
- for (j = lfe_samples; j < lfe_end_sample; j++) {
- /* Signed 8 bits int */
- s->lfe_data[j] = get_sbits(&s->gb, 8);
- }
-
- /* Scale factor index */
- quant7 = get_bits(&s->gb, 8);
- if (quant7 > 127) {
- av_log_ask_for_sample(s->avctx, "LFEScaleIndex larger than 127\n");
- return AVERROR_INVALIDDATA;
- }
- s->lfe_scale_factor = scale_factor_quant7[quant7];
-
- /* Quantization step size * scale factor */
- lfe_scale = 0.035 * s->lfe_scale_factor;
-
- for (j = lfe_samples; j < lfe_end_sample; j++)
- s->lfe_data[j] *= lfe_scale;
- }
-
-#ifdef TRACE
- av_log(s->avctx, AV_LOG_DEBUG, "subsubframes: %i\n",
- s->subsubframes[s->current_subframe]);
- av_log(s->avctx, AV_LOG_DEBUG, "partial samples: %i\n",
- s->partial_samples[s->current_subframe]);
-
- for (j = base_channel; j < s->prim_channels; j++) {
- av_log(s->avctx, AV_LOG_DEBUG, "prediction mode:");
- for (k = 0; k < s->subband_activity[j]; k++)
- av_log(s->avctx, AV_LOG_DEBUG, " %i", s->prediction_mode[j][k]);
- av_log(s->avctx, AV_LOG_DEBUG, "\n");
- }
- for (j = base_channel; j < s->prim_channels; j++) {
- for (k = 0; k < s->subband_activity[j]; k++)
- av_log(s->avctx, AV_LOG_DEBUG,
- "prediction coefs: %f, %f, %f, %f\n",
- (float) adpcm_vb[s->prediction_vq[j][k]][0] / 8192,
- (float) adpcm_vb[s->prediction_vq[j][k]][1] / 8192,
- (float) adpcm_vb[s->prediction_vq[j][k]][2] / 8192,
- (float) adpcm_vb[s->prediction_vq[j][k]][3] / 8192);
- }
- for (j = base_channel; j < s->prim_channels; j++) {
- av_log(s->avctx, AV_LOG_DEBUG, "bitalloc index: ");
- for (k = 0; k < s->vq_start_subband[j]; k++)
- av_log(s->avctx, AV_LOG_DEBUG, "%2.2i ", s->bitalloc[j][k]);
- av_log(s->avctx, AV_LOG_DEBUG, "\n");
- }
- for (j = base_channel; j < s->prim_channels; j++) {
- av_log(s->avctx, AV_LOG_DEBUG, "Transition mode:");
- for (k = 0; k < s->subband_activity[j]; k++)
- av_log(s->avctx, AV_LOG_DEBUG, " %i", s->transition_mode[j][k]);
- av_log(s->avctx, AV_LOG_DEBUG, "\n");
- }
- for (j = base_channel; j < s->prim_channels; j++) {
- av_log(s->avctx, AV_LOG_DEBUG, "Scale factor:");
- for (k = 0; k < s->subband_activity[j]; k++) {
- if (k >= s->vq_start_subband[j] || s->bitalloc[j][k] > 0)
- av_log(s->avctx, AV_LOG_DEBUG, " %i", s->scale_factor[j][k][0]);
- if (k < s->vq_start_subband[j] && s->transition_mode[j][k])
- av_log(s->avctx, AV_LOG_DEBUG, " %i(t)", s->scale_factor[j][k][1]);
- }
- av_log(s->avctx, AV_LOG_DEBUG, "\n");
- }
- for (j = base_channel; j < s->prim_channels; j++) {
- if (s->joint_intensity[j] > 0) {
- int source_channel = s->joint_intensity[j] - 1;
- av_log(s->avctx, AV_LOG_DEBUG, "Joint scale factor index:\n");
- for (k = s->subband_activity[j]; k < s->subband_activity[source_channel]; k++)
- av_log(s->avctx, AV_LOG_DEBUG, " %i", s->joint_scale_factor[j][k]);
- av_log(s->avctx, AV_LOG_DEBUG, "\n");
- }
- }
- if (!base_channel && s->prim_channels > 2 && s->downmix) {
- av_log(s->avctx, AV_LOG_DEBUG, "Downmix coeffs:\n");
- for (j = 0; j < s->prim_channels; j++) {
- av_log(s->avctx, AV_LOG_DEBUG, "Channel 0, %d = %f\n", j,
- dca_downmix_coeffs[s->downmix_coef[j][0]]);
- av_log(s->avctx, AV_LOG_DEBUG, "Channel 1, %d = %f\n", j,
- dca_downmix_coeffs[s->downmix_coef[j][1]]);
- }
- av_log(s->avctx, AV_LOG_DEBUG, "\n");
- }
- for (j = base_channel; j < s->prim_channels; j++)
- for (k = s->vq_start_subband[j]; k < s->subband_activity[j]; k++)
- av_log(s->avctx, AV_LOG_DEBUG, "VQ index: %i\n", s->high_freq_vq[j][k]);
- if (!base_channel && s->lfe) {
- int lfe_samples = 2 * s->lfe * (4 + block_index);
- int lfe_end_sample = 2 * s->lfe * (4 + block_index + s->subsubframes[s->current_subframe]);
-
- av_log(s->avctx, AV_LOG_DEBUG, "LFE samples:\n");
- for (j = lfe_samples; j < lfe_end_sample; j++)
- av_log(s->avctx, AV_LOG_DEBUG, " %f", s->lfe_data[j]);
- av_log(s->avctx, AV_LOG_DEBUG, "\n");
- }
-#endif
-
- return 0;
-}
-
-static void qmf_32_subbands(DCAContext *s, int chans,
- float samples_in[32][8], float *samples_out,
- float scale)
-{
- const float *prCoeff;
- int i;
-
- int sb_act = s->subband_activity[chans];
- int subindex;
-
- scale *= sqrt(1 / 8.0);
-
- /* Select filter */
- if (!s->multirate_inter) /* Non-perfect reconstruction */
- prCoeff = fir_32bands_nonperfect;
- else /* Perfect reconstruction */
- prCoeff = fir_32bands_perfect;
-
- for (i = sb_act; i < 32; i++)
- s->raXin[i] = 0.0;
-
- /* Reconstructed channel sample index */
- for (subindex = 0; subindex < 8; subindex++) {
- /* Load in one sample from each subband and clear inactive subbands */
- for (i = 0; i < sb_act; i++) {
- unsigned sign = (i - 1) & 2;
- uint32_t v = AV_RN32A(&samples_in[i][subindex]) ^ sign << 30;
- AV_WN32A(&s->raXin[i], v);
- }
-
- s->synth.synth_filter_float(&s->imdct,
- s->subband_fir_hist[chans],
- &s->hist_index[chans],
- s->subband_fir_noidea[chans], prCoeff,
- samples_out, s->raXin, scale);
- samples_out += 32;
- }
-}
-
-static void lfe_interpolation_fir(DCAContext *s, int decimation_select,
- int num_deci_sample, float *samples_in,
- float *samples_out, float scale)
-{
- /* samples_in: An array holding decimated samples.
- * Samples in current subframe starts from samples_in[0],
- * while samples_in[-1], samples_in[-2], ..., stores samples
- * from last subframe as history.
- *
- * samples_out: An array holding interpolated samples
- */
-
- int decifactor;
- const float *prCoeff;
- int deciindex;
-
- /* Select decimation filter */
- if (decimation_select == 1) {
- decifactor = 64;
- prCoeff = lfe_fir_128;
- } else {
- decifactor = 32;
- prCoeff = lfe_fir_64;
- }
- /* Interpolation */
- for (deciindex = 0; deciindex < num_deci_sample; deciindex++) {
- s->dcadsp.lfe_fir(samples_out, samples_in, prCoeff, decifactor, scale);
- samples_in++;
- samples_out += 2 * decifactor;
- }
-}
-
-/* downmixing routines */
-#define MIX_REAR1(samples, s1, rs, coef) \
- samples[0][i] += samples[s1][i] * coef[rs][0]; \
- samples[1][i] += samples[s1][i] * coef[rs][1];
-
-#define MIX_REAR2(samples, s1, s2, rs, coef) \
- samples[0][i] += samples[s1][i] * coef[rs][0] + samples[s2][i] * coef[rs + 1][0]; \
- samples[1][i] += samples[s1][i] * coef[rs][1] + samples[s2][i] * coef[rs + 1][1];
-
-#define MIX_FRONT3(samples, coef) \
- t = samples[c][i]; \
- u = samples[l][i]; \
- v = samples[r][i]; \
- samples[0][i] = t * coef[0][0] + u * coef[1][0] + v * coef[2][0]; \
- samples[1][i] = t * coef[0][1] + u * coef[1][1] + v * coef[2][1];
-
-#define DOWNMIX_TO_STEREO(op1, op2) \
- for (i = 0; i < 256; i++) { \
- op1 \
- op2 \
- }
-
-static void dca_downmix(float **samples, int srcfmt,
- int downmix_coef[DCA_PRIM_CHANNELS_MAX][2],
- const int8_t *channel_mapping)
-{
- int c, l, r, sl, sr, s;
- int i;
- float t, u, v;
- float coef[DCA_PRIM_CHANNELS_MAX][2];
-
- for (i = 0; i < DCA_PRIM_CHANNELS_MAX; i++) {
- coef[i][0] = dca_downmix_coeffs[downmix_coef[i][0]];
- coef[i][1] = dca_downmix_coeffs[downmix_coef[i][1]];
- }
-
- switch (srcfmt) {
- case DCA_MONO:
- case DCA_CHANNEL:
- case DCA_STEREO_TOTAL:
- case DCA_STEREO_SUMDIFF:
- case DCA_4F2R:
- av_log(NULL, AV_LOG_ERROR, "Not implemented!\n");
- break;
- case DCA_STEREO:
- break;
- case DCA_3F:
- c = channel_mapping[0];
- l = channel_mapping[1];
- r = channel_mapping[2];
- DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef), );
- break;
- case DCA_2F1R:
- s = channel_mapping[2];
- DOWNMIX_TO_STEREO(MIX_REAR1(samples, s, 2, coef), );
- break;
- case DCA_3F1R:
- c = channel_mapping[0];
- l = channel_mapping[1];
- r = channel_mapping[2];
- s = channel_mapping[3];
- DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef),
- MIX_REAR1(samples, s, 3, coef));
- break;
- case DCA_2F2R:
- sl = channel_mapping[2];
- sr = channel_mapping[3];
- DOWNMIX_TO_STEREO(MIX_REAR2(samples, sl, sr, 2, coef), );
- break;
- case DCA_3F2R:
- c = channel_mapping[0];
- l = channel_mapping[1];
- r = channel_mapping[2];
- sl = channel_mapping[3];
- sr = channel_mapping[4];
- DOWNMIX_TO_STEREO(MIX_FRONT3(samples, coef),
- MIX_REAR2(samples, sl, sr, 3, coef));
- break;
- }
-}
-
-
-#ifndef decode_blockcodes
-/* Very compact version of the block code decoder that does not use table
- * look-up but is slightly slower */
-static int decode_blockcode(int code, int levels, int *values)
-{
- int i;
- int offset = (levels - 1) >> 1;
-
- for (i = 0; i < 4; i++) {
- int div = FASTDIV(code, levels);
- values[i] = code - offset - div * levels;
- code = div;
- }
-
- return code;
-}
-
-static int decode_blockcodes(int code1, int code2, int levels, int *values)
-{
- return decode_blockcode(code1, levels, values) |
- decode_blockcode(code2, levels, values + 4);
-}
-#endif
-
-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;
- int subsubframe = s->current_subsubframe;
-
- const float *quant_step_table;
-
- /* FIXME */
- float (*subband_samples)[DCA_SUBBANDS][8] = s->subband_samples[block_index];
- LOCAL_ALIGNED_16(int, block, [8]);
-
- /*
- * Audio data
- */
-
- /* Select quantization step size table */
- if (s->bit_rate_index == 0x1f)
- quant_step_table = lossless_quant_d;
- else
- quant_step_table = lossy_quant_d;
-
- for (k = base_channel; k < s->prim_channels; k++) {
- if (get_bits_left(&s->gb) < 0)
- return AVERROR_INVALIDDATA;
-
- for (l = 0; l < s->vq_start_subband[k]; l++) {
- int m;
-
- /* Select the mid-tread linear quantizer */
- int abits = s->bitalloc[k][l];
-
- float quant_step_size = quant_step_table[abits];
-
- /*
- * Determine quantization index code book and its type
- */
-
- /* Select quantization index code book */
- int sel = s->quant_index_huffman[k][abits];
-
- /*
- * Extract bits from the bit stream
- */
- if (!abits) {
- memset(subband_samples[k][l], 0, 8 * sizeof(subband_samples[0][0][0]));
- } else {
- /* Deal with transients */
- int sfi = s->transition_mode[k][l] && subsubframe >= s->transition_mode[k][l];
- float rscale = quant_step_size * s->scale_factor[k][l][sfi] *
- s->scalefactor_adj[k][sel];
-
- if (abits >= 11 || !dca_smpl_bitalloc[abits].vlc[sel].table) {
- if (abits <= 7) {
- /* Block code */
- int block_code1, block_code2, size, levels, err;
-
- size = abits_sizes[abits - 1];
- levels = abits_levels[abits - 1];
-
- block_code1 = get_bits(&s->gb, size);
- block_code2 = get_bits(&s->gb, size);
- err = decode_blockcodes(block_code1, block_code2,
- levels, block);
- if (err) {
- av_log(s->avctx, AV_LOG_ERROR,
- "ERROR: block code look-up failed\n");
- return AVERROR_INVALIDDATA;
- }
- } else {
- /* no coding */
- for (m = 0; m < 8; m++)
- block[m] = get_sbits(&s->gb, abits - 3);
- }
- } else {
- /* Huffman coded */
- for (m = 0; m < 8; m++)
- block[m] = get_bitalloc(&s->gb,
- &dca_smpl_bitalloc[abits], sel);
- }
-
- s->fmt_conv.int32_to_float_fmul_scalar(subband_samples[k][l],
- block, rscale, 8);
- }
-
- /*
- * Inverse ADPCM if in prediction mode
- */
- if (s->prediction_mode[k][l]) {
- int n;
- for (m = 0; m < 8; m++) {
- for (n = 1; 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);
- 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);
- }
- }
- }
-
- /*
- * 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) {
- 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]);
- }
- }
-
- /* Check for DSYNC after subsubframe */
- if (s->aspf || subsubframe == s->subsubframes[s->current_subframe] - 1) {
- if (0xFFFF == get_bits(&s->gb, 16)) { /* 0xFFFF */
-#ifdef TRACE
- av_log(s->avctx, AV_LOG_DEBUG, "Got subframe DSYNC\n");
-#endif
- } else {
- av_log(s->avctx, AV_LOG_ERROR, "Didn't get subframe DSYNC\n");
- }
- }
-
- /* 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]));
-
- return 0;
-}
-
-static int dca_filter_channels(DCAContext *s, int block_index)
-{
- float (*subband_samples)[DCA_SUBBANDS][8] = s->subband_samples[block_index];
- int k;
-
- /* 32 subbands QMF */
- for (k = 0; k < s->prim_channels; k++) {
-/* static float pcm_to_double[8] = { 32768.0, 32768.0, 524288.0, 524288.0,
- 0, 8388608.0, 8388608.0 };*/
- if (s->channel_order_tab[k] >= 0)
- qmf_32_subbands(s, k, subband_samples[k],
- s->samples_chanptr[s->channel_order_tab[k]],
- M_SQRT1_2 / 32768.0 /* pcm_to_double[s->source_pcm_res] */);
- }
-
- /* Down mixing */
- if (s->avctx->request_channels == 2 && s->prim_channels > 2) {
- dca_downmix(s->samples_chanptr, s->amode, s->downmix_coef, s->channel_order_tab);
- }
-
- /* Generate LFE samples for this subsubframe FIXME!!! */
- if (s->output & DCA_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));
- /* Outputs 20bits pcm samples */
- }
-
- return 0;
-}
-
-
-static int dca_subframe_footer(DCAContext *s, int base_channel)
-{
- int aux_data_count = 0, i;
-
- /*
- * Unpack optional information
- */
-
- /* presumably optional information only appears in the core? */
- if (!base_channel) {
- if (s->timestamp)
- skip_bits_long(&s->gb, 32);
-
- if (s->aux_data)
- aux_data_count = get_bits(&s->gb, 6);
-
- for (i = 0; i < aux_data_count; i++)
- get_bits(&s->gb, 8);
-
- if (s->crc_present && (s->downmix || s->dynrange))
- get_bits(&s->gb, 16);
- }
-
- return 0;
-}
-
-/**
- * Decode a dca frame block
- *
- * @param s pointer to the DCAContext
- */
-
-static int dca_decode_block(DCAContext *s, int base_channel, int block_index)
-{
- int ret;
-
- /* Sanity check */
- if (s->current_subframe >= s->subframes) {
- av_log(s->avctx, AV_LOG_DEBUG, "check failed: %i>%i",
- s->current_subframe, s->subframes);
- return AVERROR_INVALIDDATA;
- }
-
- if (!s->current_subsubframe) {
-#ifdef TRACE
- av_log(s->avctx, AV_LOG_DEBUG, "DSYNC dca_subframe_header\n");
-#endif
- /* Read subframe header */
- if ((ret = dca_subframe_header(s, base_channel, block_index)))
- return ret;
- }
-
- /* Read subsubframe */
-#ifdef TRACE
- av_log(s->avctx, AV_LOG_DEBUG, "DSYNC dca_subsubframe\n");
-#endif
- if ((ret = dca_subsubframe(s, base_channel, block_index)))
- return ret;
-
- /* Update state */
- s->current_subsubframe++;
- if (s->current_subsubframe >= s->subsubframes[s->current_subframe]) {
- s->current_subsubframe = 0;
- s->current_subframe++;
- }
- if (s->current_subframe >= s->subframes) {
-#ifdef TRACE
- av_log(s->avctx, AV_LOG_DEBUG, "DSYNC dca_subframe_footer\n");
-#endif
- /* Read subframe footer */
- if ((ret = dca_subframe_footer(s, base_channel)))
- return ret;
- }
-
- return 0;
-}
-
-/**
- * Return the number of channels in an ExSS speaker mask (HD)
- */
-static int dca_exss_mask2count(int mask)
-{
- /* count bits that mean speaker pairs twice */
- return av_popcount(mask) +
- av_popcount(mask & (DCA_EXSS_CENTER_LEFT_RIGHT |
- DCA_EXSS_FRONT_LEFT_RIGHT |
- DCA_EXSS_FRONT_HIGH_LEFT_RIGHT |
- DCA_EXSS_WIDE_LEFT_RIGHT |
- DCA_EXSS_SIDE_LEFT_RIGHT |
- DCA_EXSS_SIDE_HIGH_LEFT_RIGHT |
- DCA_EXSS_SIDE_REAR_LEFT_RIGHT |
- DCA_EXSS_REAR_LEFT_RIGHT |
- DCA_EXSS_REAR_HIGH_LEFT_RIGHT));
-}
-
-/**
- * Skip mixing coefficients of a single mix out configuration (HD)
- */
-static void dca_exss_skip_mix_coeffs(GetBitContext *gb, int channels, int out_ch)
-{
- int i;
-
- for (i = 0; i < channels; i++) {
- int mix_map_mask = get_bits(gb, out_ch);
- int num_coeffs = av_popcount(mix_map_mask);
- skip_bits_long(gb, num_coeffs * 6);
- }
-}
-
-/**
- * Parse extension substream asset header (HD)
- */
-static int dca_exss_parse_asset_header(DCAContext *s)
-{
- int header_pos = get_bits_count(&s->gb);
- int header_size;
- int channels = 0;
- int embedded_stereo = 0;
- int embedded_6ch = 0;
- int drc_code_present;
- int av_uninit(extensions_mask);
- int i, j;
-
- if (get_bits_left(&s->gb) < 16)
- return -1;
-
- /* We will parse just enough to get to the extensions bitmask with which
- * we can set the profile value. */
-
- header_size = get_bits(&s->gb, 9) + 1;
- skip_bits(&s->gb, 3); // asset index
-
- if (s->static_fields) {
- if (get_bits1(&s->gb))
- skip_bits(&s->gb, 4); // asset type descriptor
- if (get_bits1(&s->gb))
- skip_bits_long(&s->gb, 24); // language descriptor
-
- if (get_bits1(&s->gb)) {
- /* How can one fit 1024 bytes of text here if the maximum value
- * for the asset header size field above was 512 bytes? */
- int text_length = get_bits(&s->gb, 10) + 1;
- if (get_bits_left(&s->gb) < text_length * 8)
- return -1;
- skip_bits_long(&s->gb, text_length * 8); // info text
- }
-
- skip_bits(&s->gb, 5); // bit resolution - 1
- skip_bits(&s->gb, 4); // max sample rate code
- channels = get_bits(&s->gb, 8) + 1;
-
- if (get_bits1(&s->gb)) { // 1-to-1 channels to speakers
- int spkr_remap_sets;
- int spkr_mask_size = 16;
- int num_spkrs[7];
-
- if (channels > 2)
- embedded_stereo = get_bits1(&s->gb);
- if (channels > 6)
- embedded_6ch = get_bits1(&s->gb);
-
- if (get_bits1(&s->gb)) {
- spkr_mask_size = (get_bits(&s->gb, 2) + 1) << 2;
- skip_bits(&s->gb, spkr_mask_size); // spkr activity mask
- }
-
- spkr_remap_sets = get_bits(&s->gb, 3);
-
- for (i = 0; i < spkr_remap_sets; i++) {
- /* std layout mask for each remap set */
- num_spkrs[i] = dca_exss_mask2count(get_bits(&s->gb, spkr_mask_size));
- }
-
- for (i = 0; i < spkr_remap_sets; i++) {
- int num_dec_ch_remaps = get_bits(&s->gb, 5) + 1;
- if (get_bits_left(&s->gb) < 0)
- return -1;
-
- for (j = 0; j < num_spkrs[i]; j++) {
- int remap_dec_ch_mask = get_bits_long(&s->gb, num_dec_ch_remaps);
- int num_dec_ch = av_popcount(remap_dec_ch_mask);
- skip_bits_long(&s->gb, num_dec_ch * 5); // remap codes
- }
- }
-
- } else {
- skip_bits(&s->gb, 3); // representation type
- }
- }
-
- drc_code_present = get_bits1(&s->gb);
- if (drc_code_present)
- get_bits(&s->gb, 8); // drc code
-
- if (get_bits1(&s->gb))
- skip_bits(&s->gb, 5); // dialog normalization code
-
- if (drc_code_present && embedded_stereo)
- get_bits(&s->gb, 8); // drc stereo code
-
- if (s->mix_metadata && get_bits1(&s->gb)) {
- skip_bits(&s->gb, 1); // external mix
- skip_bits(&s->gb, 6); // post mix gain code
-
- if (get_bits(&s->gb, 2) != 3) // mixer drc code
- skip_bits(&s->gb, 3); // drc limit
- else
- skip_bits(&s->gb, 8); // custom drc code
-
- if (get_bits1(&s->gb)) // channel specific scaling
- for (i = 0; i < s->num_mix_configs; i++)
- skip_bits_long(&s->gb, s->mix_config_num_ch[i] * 6); // scale codes
- else
- skip_bits_long(&s->gb, s->num_mix_configs * 6); // scale codes
-
- for (i = 0; i < s->num_mix_configs; i++) {
- if (get_bits_left(&s->gb) < 0)
- return -1;
- dca_exss_skip_mix_coeffs(&s->gb, channels, s->mix_config_num_ch[i]);
- if (embedded_6ch)
- dca_exss_skip_mix_coeffs(&s->gb, 6, s->mix_config_num_ch[i]);
- if (embedded_stereo)
- dca_exss_skip_mix_coeffs(&s->gb, 2, s->mix_config_num_ch[i]);
- }
- }
-
- switch (get_bits(&s->gb, 2)) {
- case 0: extensions_mask = get_bits(&s->gb, 12); break;
- case 1: extensions_mask = DCA_EXT_EXSS_XLL; break;
- case 2: extensions_mask = DCA_EXT_EXSS_LBR; break;
- case 3: extensions_mask = 0; /* aux coding */ break;
- }
-
- /* not parsed further, we were only interested in the extensions mask */
-
- if (get_bits_left(&s->gb) < 0)
- return -1;
-
- if (get_bits_count(&s->gb) - header_pos > header_size * 8) {
- av_log(s->avctx, AV_LOG_WARNING, "Asset header size mismatch.\n");
- return -1;
- }
- skip_bits_long(&s->gb, header_pos + header_size * 8 - get_bits_count(&s->gb));
-
- if (extensions_mask & DCA_EXT_EXSS_XLL)
- s->profile = FF_PROFILE_DTS_HD_MA;
- else if (extensions_mask & (DCA_EXT_EXSS_XBR | DCA_EXT_EXSS_X96 |
- DCA_EXT_EXSS_XXCH))
- s->profile = FF_PROFILE_DTS_HD_HRA;
-
- if (!(extensions_mask & DCA_EXT_CORE))
- av_log(s->avctx, AV_LOG_WARNING, "DTS core detection mismatch.\n");
- if ((extensions_mask & DCA_CORE_EXTS) != s->core_ext_mask)
- av_log(s->avctx, AV_LOG_WARNING,
- "DTS extensions detection mismatch (%d, %d)\n",
- extensions_mask & DCA_CORE_EXTS, s->core_ext_mask);
-
- return 0;
-}
-
-static int dca_xbr_parse_frame(DCAContext *s)
-{
- int scale_table_high[DCA_CHSET_CHANS_MAX][DCA_SUBBANDS][2];
- int active_bands[DCA_CHSETS_MAX][DCA_CHSET_CHANS_MAX];
- int abits_high[DCA_CHSET_CHANS_MAX][DCA_SUBBANDS];
- int anctemp[DCA_CHSET_CHANS_MAX];
- int chset_fsize[DCA_CHSETS_MAX];
- int n_xbr_ch[DCA_CHSETS_MAX];
- int hdr_size, num_chsets, xbr_tmode, hdr_pos;
- int i, j, k, l, chset, chan_base;
-
- av_log(s->avctx, AV_LOG_DEBUG, "DTS-XBR: decoding XBR extension\n");
-
- /* get bit position of sync header */
- hdr_pos = get_bits_count(&s->gb) - 32;
-
- hdr_size = get_bits(&s->gb, 6) + 1;
- num_chsets = get_bits(&s->gb, 2) + 1;
-
- for(i = 0; i < num_chsets; i++)
- chset_fsize[i] = get_bits(&s->gb, 14) + 1;
-
- xbr_tmode = get_bits1(&s->gb);
-
- for(i = 0; i < num_chsets; i++) {
- n_xbr_ch[i] = get_bits(&s->gb, 3) + 1;
- k = get_bits(&s->gb, 2) + 5;
- for(j = 0; j < n_xbr_ch[i]; j++)
- active_bands[i][j] = get_bits(&s->gb, k) + 1;
- }
-
- /* skip to the end of the header */
- i = get_bits_count(&s->gb);
- if(hdr_pos + hdr_size * 8 > i)
- skip_bits_long(&s->gb, hdr_pos + hdr_size * 8 - i);
-
- /* loop over the channel data sets */
- /* only decode as many channels as we've decoded base data for */
- for(chset = 0, chan_base = 0;
- chset < num_chsets && chan_base + n_xbr_ch[chset] <= s->prim_channels;
- chan_base += n_xbr_ch[chset++]) {
- int start_posn = get_bits_count(&s->gb);
- int subsubframe = 0;
- int subframe = 0;
-
- /* loop over subframes */
- for (k = 0; k < (s->sample_blocks / 8); k++) {
- /* parse header if we're on first subsubframe of a block */
- if(subsubframe == 0) {
- /* Parse subframe header */
- for(i = 0; i < n_xbr_ch[chset]; i++) {
- anctemp[i] = get_bits(&s->gb, 2) + 2;
- }
-
- for(i = 0; i < n_xbr_ch[chset]; i++) {
- get_array(&s->gb, abits_high[i], active_bands[chset][i], anctemp[i]);
- }
-
- for(i = 0; i < n_xbr_ch[chset]; i++) {
- anctemp[i] = get_bits(&s->gb, 3);
- if(anctemp[i] < 1) {
- av_log(s->avctx, AV_LOG_ERROR, "DTS-XBR: SYNC ERROR\n");
- return AVERROR_INVALIDDATA;
- }
- }
-
- /* generate scale factors */
- for(i = 0; i < n_xbr_ch[chset]; i++) {
- const uint32_t *scale_table;
- int nbits;
-
- if (s->scalefactor_huffman[chan_base+i] == 6) {
- scale_table = scale_factor_quant7;
- } else {
- scale_table = scale_factor_quant6;
- }
-
- nbits = anctemp[i];
-
- for(j = 0; j < active_bands[chset][i]; j++) {
- if(abits_high[i][j] > 0) {
- scale_table_high[i][j][0] =
- scale_table[get_bits(&s->gb, nbits)];
-
- if(xbr_tmode && s->transition_mode[i][j]) {
- scale_table_high[i][j][1] =
- scale_table[get_bits(&s->gb, nbits)];
- }
- }
- }
- }
- }
-
- /* decode audio array for this block */
- for(i = 0; i < n_xbr_ch[chset]; i++) {
- for(j = 0; j < active_bands[chset][i]; j++) {
- const int xbr_abits = abits_high[i][j];
- const float quant_step_size = lossless_quant_d[xbr_abits];
- const int sfi = xbr_tmode && s->transition_mode[i][j] && subsubframe >= s->transition_mode[i][j];
- const float rscale = quant_step_size * scale_table_high[i][j][sfi];
- float *subband_samples = s->subband_samples[k][chan_base+i][j];
- int block[8];
-
- if(xbr_abits <= 0)
- continue;
-
- if(xbr_abits > 7) {
- get_array(&s->gb, block, 8, xbr_abits - 3);
- } else {
- int block_code1, block_code2, size, levels, err;
-
- size = abits_sizes[xbr_abits - 1];
- levels = abits_levels[xbr_abits - 1];
-
- block_code1 = get_bits(&s->gb, size);
- block_code2 = get_bits(&s->gb, size);
- err = decode_blockcodes(block_code1, block_code2,
- levels, block);
- if (err) {
- av_log(s->avctx, AV_LOG_ERROR,
- "ERROR: DTS-XBR: block code look-up failed\n");
- return AVERROR_INVALIDDATA;
- }
- }
-
- /* scale & sum into subband */
- for(l = 0; l < 8; l++)
- subband_samples[l] += (float)block[l] * rscale;
- }
- }
-
- /* check DSYNC marker */
- if(s->aspf || subsubframe == s->subsubframes[subframe] - 1) {
- if(get_bits(&s->gb, 16) != 0xffff) {
- av_log(s->avctx, AV_LOG_ERROR, "DTS-XBR: Didn't get subframe DSYNC\n");
- return AVERROR_INVALIDDATA;
- }
- }
-
- /* advance sub-sub-frame index */
- if(++subsubframe >= s->subsubframes[subframe]) {
- subsubframe = 0;
- subframe++;
- }
- }
-
- /* skip to next channel set */
- i = get_bits_count(&s->gb);
- if(start_posn + chset_fsize[chset] * 8 != i) {
- j = start_posn + chset_fsize[chset] * 8 - i;
- if(j < 0 || j >= 8)
- av_log(s->avctx, AV_LOG_ERROR, "DTS-XBR: end of channel set,"
- " skipping further than expected (%d bits)\n", j);
- skip_bits_long(&s->gb, j);
- }
- }
-
- return 0;
-}
-
-/* parse initial header for XXCH and dump details */
-static int dca_xxch_decode_frame(DCAContext *s)
-{
- int hdr_size, spkmsk_bits, num_chsets, core_spk, hdr_pos;
- int i, chset, base_channel, chstart, fsize[8];
-
- /* assume header word has already been parsed */
- hdr_pos = get_bits_count(&s->gb) - 32;
- hdr_size = get_bits(&s->gb, 6) + 1;
- /*chhdr_crc =*/ skip_bits1(&s->gb);
- spkmsk_bits = get_bits(&s->gb, 5) + 1;
- num_chsets = get_bits(&s->gb, 2) + 1;
-
- for (i = 0; i < num_chsets; i++)
- fsize[i] = get_bits(&s->gb, 14) + 1;
-
- core_spk = get_bits(&s->gb, spkmsk_bits);
- s->xxch_core_spkmask = core_spk;
- s->xxch_nbits_spk_mask = spkmsk_bits;
- s->xxch_dmix_embedded = 0;
-
- /* skip to the end of the header */
- i = get_bits_count(&s->gb);
- if (hdr_pos + hdr_size * 8 > i)
- skip_bits_long(&s->gb, hdr_pos + hdr_size * 8 - i);
-
- for (chset = 0; chset < num_chsets; chset++) {
- chstart = get_bits_count(&s->gb);
- base_channel = s->prim_channels;
- s->xxch_chset = chset;
-
- /* XXCH and Core headers differ, see 6.4.2 "XXCH Channel Set Header" vs.
- 5.3.2 "Primary Audio Coding Header", DTS Spec 1.3.1 */
- dca_parse_audio_coding_header(s, base_channel, 1);
-
- /* decode channel data */
- for (i = 0; i < (s->sample_blocks / 8); i++) {
- if (dca_decode_block(s, base_channel, i)) {
- av_log(s->avctx, AV_LOG_ERROR,
- "Error decoding DTS-XXCH extension\n");
- continue;
- }
- }
-
- /* skip to end of this section */
- i = get_bits_count(&s->gb);
- if (chstart + fsize[chset] * 8 > i)
- skip_bits_long(&s->gb, chstart + fsize[chset] * 8 - i);
- }
- s->xxch_chset = num_chsets;
-
- return 0;
-}
-
-/**
- * Parse extension substream header (HD)
- */
-static void dca_exss_parse_header(DCAContext *s)
-{
- int asset_size[8];
- int ss_index;
- int blownup;
- int num_audiop = 1;
- int num_assets = 1;
- int active_ss_mask[8];
- int i, j;
- int start_posn;
- int hdrsize;
- uint32_t mkr;
-
- if (get_bits_left(&s->gb) < 52)
- return;
-
- start_posn = get_bits_count(&s->gb) - 32;
-
- skip_bits(&s->gb, 8); // user data
- ss_index = get_bits(&s->gb, 2);
-
- blownup = get_bits1(&s->gb);
- hdrsize = get_bits(&s->gb, 8 + 4 * blownup) + 1; // header_size
- skip_bits(&s->gb, 16 + 4 * blownup); // hd_size
-
- s->static_fields = get_bits1(&s->gb);
- if (s->static_fields) {
- skip_bits(&s->gb, 2); // reference clock code
- skip_bits(&s->gb, 3); // frame duration code
-
- if (get_bits1(&s->gb))
- skip_bits_long(&s->gb, 36); // timestamp
-
- /* a single stream can contain multiple audio assets that can be
- * combined to form multiple audio presentations */
-
- num_audiop = get_bits(&s->gb, 3) + 1;
- if (num_audiop > 1) {
- av_log_ask_for_sample(s->avctx, "Multiple DTS-HD audio presentations.");
- /* ignore such streams for now */
- return;
- }
-
- num_assets = get_bits(&s->gb, 3) + 1;
- if (num_assets > 1) {
- av_log_ask_for_sample(s->avctx, "Multiple DTS-HD audio assets.");
- /* ignore such streams for now */
- return;
- }
-
- for (i = 0; i < num_audiop; i++)
- active_ss_mask[i] = get_bits(&s->gb, ss_index + 1);
-
- for (i = 0; i < num_audiop; i++)
- for (j = 0; j <= ss_index; j++)
- if (active_ss_mask[i] & (1 << j))
- skip_bits(&s->gb, 8); // active asset mask
-
- s->mix_metadata = get_bits1(&s->gb);
- if (s->mix_metadata) {
- int mix_out_mask_size;
-
- skip_bits(&s->gb, 2); // adjustment level
- mix_out_mask_size = (get_bits(&s->gb, 2) + 1) << 2;
- s->num_mix_configs = get_bits(&s->gb, 2) + 1;
-
- for (i = 0; i < s->num_mix_configs; i++) {
- int mix_out_mask = get_bits(&s->gb, mix_out_mask_size);
- s->mix_config_num_ch[i] = dca_exss_mask2count(mix_out_mask);
- }
- }
- }
-
- for (i = 0; i < num_assets; i++)
- asset_size[i] = get_bits_long(&s->gb, 16 + 4 * blownup);
-
- for (i = 0; i < num_assets; i++) {
- if (dca_exss_parse_asset_header(s))
- return;
- }
-
- /* 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);
-
- for (i = 0; i < num_assets; i++) {
- start_posn = get_bits_count(&s->gb);
- mkr = get_bits_long(&s->gb, 32);
-
- /* parse extensions that we know about */
- if (mkr == 0x655e315e) {
- dca_xbr_parse_frame(s);
- } else if (mkr == 0x47004a03) {
- dca_xxch_decode_frame(s);
- s->core_ext_mask |= DCA_EXT_XXCH; /* xxx use for chan reordering */
- } else {
- av_log(s->avctx, AV_LOG_DEBUG,
- "DTS-ExSS: unknown marker = 0x%08x\n", mkr);
- }
-
- /* skip to end of block */
- j = get_bits_count(&s->gb);
- if (start_posn + asset_size[i] * 8 > j)
- skip_bits_long(&s->gb, start_posn + asset_size[i] * 8 - j);
- }
- }
-}
-
-/**
- * Main frame decoding function
- * FIXME add arguments
- */
-static int dca_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;
- int channel_mask;
- int channel_layout;
- int lfe_samples;
- int num_core_channels = 0;
- int i, ret;
- float **samples_flt;
- float *src_chan;
- float *dst_chan;
- DCAContext *s = avctx->priv_data;
- int core_ss_end;
- int channels, full_channels;
- float scale;
- int achan;
- int chset;
- int mask;
- int lavc;
- int posn;
- int j, k;
- int endch;
-
- s->xch_present = 0;
-
- s->dca_buffer_size = ff_dca_convert_bitstream(buf, buf_size, s->dca_buffer,
- DCA_MAX_FRAME_SIZE + DCA_MAX_EXSS_HEADER_SIZE);
- if (s->dca_buffer_size == AVERROR_INVALIDDATA) {
- av_log(avctx, AV_LOG_ERROR, "Not a valid DCA frame\n");
- 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;
- }
- //set AVCodec values with parsed data
- avctx->sample_rate = s->sample_rate;
- avctx->bit_rate = s->bit_rate;
-
- s->profile = FF_PROFILE_DTS;
-
- for (i = 0; i < (s->sample_blocks / 8); i++) {
- if ((ret = dca_decode_block(s, 0, i))) {
- av_log(avctx, AV_LOG_ERROR, "error decoding block\n");
- return ret;
- }
- }
-
- /* record number of core channels incase less than max channels are requested */
- num_core_channels = s->prim_channels;
-
- if (s->ext_coding)
- s->core_ext_mask = dca_ext_audio_descr_mask[s->ext_descr];
- else
- s->core_ext_mask = 0;
-
- core_ss_end = FFMIN(s->frame_size, s->dca_buffer_size) * 8;
-
- /* only scan for extensions if ext_descr was unknown or indicated a
- * supported XCh extension */
- if (s->core_ext_mask < 0 || s->core_ext_mask & (DCA_EXT_XCH | DCA_EXT_XXCH)) {
-
- /* if ext_descr was unknown, clear s->core_ext_mask so that the
- * extensions scan can fill it up */
- s->core_ext_mask = FFMAX(s->core_ext_mask, 0);
-
- /* extensions start at 32-bit boundaries into bitstream */
- skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31);
-
- while (core_ss_end - get_bits_count(&s->gb) >= 32) {
- uint32_t bits = get_bits_long(&s->gb, 32);
-
- switch (bits) {
- case 0x5a5a5a5a: {
- int ext_amode, xch_fsize;
-
- s->xch_base_channel = s->prim_channels;
-
- /* validate sync word using XCHFSIZE field */
- xch_fsize = show_bits(&s->gb, 10);
- if ((s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + xch_fsize) &&
- (s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + xch_fsize + 1))
- continue;
-
- /* skip length-to-end-of-frame field for the moment */
- skip_bits(&s->gb, 10);
-
- s->core_ext_mask |= DCA_EXT_XCH;
-
- /* extension amode(number of channels in extension) should be 1 */
- /* AFAIK XCh is not used for more channels */
- if ((ext_amode = get_bits(&s->gb, 4)) != 1) {
- av_log(avctx, AV_LOG_ERROR, "XCh extension amode %d not"
- " supported!\n", ext_amode);
- continue;
- }
-
- if (s->xch_base_channel < 2) {
- av_log_ask_for_sample(avctx, "XCh with fewer than 2 base channels is not supported\n");
- continue;
- }
-
- /* much like core primary audio coding header */
- dca_parse_audio_coding_header(s, s->xch_base_channel, 0);
-
- for (i = 0; i < (s->sample_blocks / 8); i++)
- if ((ret = dca_decode_block(s, s->xch_base_channel, i))) {
- av_log(avctx, AV_LOG_ERROR, "error decoding XCh extension\n");
- continue;
- }
-
- s->xch_present = 1;
- break;
- }
- case 0x47004a03:
- /* XXCh: extended channels */
- /* usually found either in core or HD part in DTS-HD HRA streams,
- * but not in DTS-ES which contains XCh extensions instead */
- s->core_ext_mask |= DCA_EXT_XXCH;
- dca_xxch_decode_frame(s);
- break;
-
- case 0x1d95f262: {
- int fsize96 = show_bits(&s->gb, 12) + 1;
- if (s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + fsize96)
- continue;
-
- av_log(avctx, AV_LOG_DEBUG, "X96 extension found at %d bits\n",
- get_bits_count(&s->gb));
- skip_bits(&s->gb, 12);
- av_log(avctx, AV_LOG_DEBUG, "FSIZE96 = %d bytes\n", fsize96);
- av_log(avctx, AV_LOG_DEBUG, "REVNO = %d\n", get_bits(&s->gb, 4));
-
- s->core_ext_mask |= DCA_EXT_X96;
- break;
- }
- }
-
- skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31);
- }
- } else {
- /* no supported extensions, skip the rest of the core substream */
- skip_bits_long(&s->gb, core_ss_end - get_bits_count(&s->gb));
- }
-
- if (s->core_ext_mask & DCA_EXT_X96)
- s->profile = FF_PROFILE_DTS_96_24;
- else if (s->core_ext_mask & (DCA_EXT_XCH | DCA_EXT_XXCH))
- s->profile = FF_PROFILE_DTS_ES;
-
- /* check for ExSS (HD part) */
- if (s->dca_buffer_size - s->frame_size > 32 &&
- get_bits_long(&s->gb, 32) == DCA_HD_MARKER)
- dca_exss_parse_header(s);
-
- avctx->profile = s->profile;
-
- full_channels = channels = s->prim_channels + !!s->lfe;
-
- /* If we have XXCH then the channel layout is managed differently */
- /* note that XLL will also have another way to do things */
- if (!(s->core_ext_mask & DCA_EXT_XXCH)
- || (s->core_ext_mask & DCA_EXT_XXCH && avctx->request_channels > 0
- && avctx->request_channels
- < num_core_channels + !!s->lfe + s->xxch_chset_nch[0]))
- { /* xxx should also do MA extensions */
- if (s->amode < 16) {
- avctx->channel_layout = dca_core_channel_layout[s->amode];
-
- if (s->xch_present && (!avctx->request_channels ||
- avctx->request_channels
- > num_core_channels + !!s->lfe)) {
- avctx->channel_layout |= AV_CH_BACK_CENTER;
- if (s->lfe) {
- avctx->channel_layout |= AV_CH_LOW_FREQUENCY;
- s->channel_order_tab = dca_channel_reorder_lfe_xch[s->amode];
- } else {
- s->channel_order_tab = dca_channel_reorder_nolfe_xch[s->amode];
- }
- if (s->channel_order_tab[s->xch_base_channel] < 0)
- return AVERROR_INVALIDDATA;
- } else {
- channels = num_core_channels + !!s->lfe;
- s->xch_present = 0; /* disable further xch processing */
- if (s->lfe) {
- avctx->channel_layout |= AV_CH_LOW_FREQUENCY;
- s->channel_order_tab = dca_channel_reorder_lfe[s->amode];
- } else
- s->channel_order_tab = dca_channel_reorder_nolfe[s->amode];
- }
-
- if (channels > !!s->lfe &&
- s->channel_order_tab[channels - 1 - !!s->lfe] < 0)
- return AVERROR_INVALIDDATA;
-
- if (av_get_channel_layout_nb_channels(avctx->channel_layout) != channels) {
- av_log(avctx, AV_LOG_ERROR, "Number of channels %d mismatches layout %d\n", channels, av_get_channel_layout_nb_channels(avctx->channel_layout));
- return AVERROR_INVALIDDATA;
- }
-
- if (avctx->request_channels == 2 && s->prim_channels > 2) {
- channels = 2;
- s->output = DCA_STEREO;
- avctx->channel_layout = AV_CH_LAYOUT_STEREO;
- }
- else if (avctx->request_channel_layout & AV_CH_LAYOUT_NATIVE) {
- static const int8_t dca_channel_order_native[9] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
- s->channel_order_tab = dca_channel_order_native;
- }
- s->lfe_index = dca_lfe_index[s->amode];
- } else {
- av_log(avctx, AV_LOG_ERROR,
- "Non standard configuration %d !\n", s->amode);
- return AVERROR_INVALIDDATA;
- }
-
- s->xxch_dmix_embedded = 0;
- } else {
- /* we only get here if an XXCH channel set can be added to the mix */
- channel_mask = s->xxch_core_spkmask;
-
- if (avctx->request_channels > 0
- && avctx->request_channels < s->prim_channels) {
- channels = num_core_channels + !!s->lfe;
- for (i = 0; i < s->xxch_chset && channels + s->xxch_chset_nch[i]
- <= avctx->request_channels; i++) {
- channels += s->xxch_chset_nch[i];
- channel_mask |= s->xxch_spk_masks[i];
- }
- } else {
- channels = s->prim_channels + !!s->lfe;
- for (i = 0; i < s->xxch_chset; i++) {
- channel_mask |= s->xxch_spk_masks[i];
- }
- }
-
- /* Given the DTS spec'ed channel mask, generate an avcodec version */
- channel_layout = 0;
- for (i = 0; i < s->xxch_nbits_spk_mask; ++i) {
- if (channel_mask & (1 << i)) {
- channel_layout |= map_xxch_to_native[i];
- }
- }
-
- /* make sure that we have managed to get equivelant dts/avcodec channel
- * 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");
- return AVERROR_INVALIDDATA;
- }
-
- avctx->channel_layout = channel_layout;
-
- if (!(avctx->request_channel_layout & AV_CH_LAYOUT_NATIVE)) {
- /* Estimate DTS --> avcodec ordering table */
- for (chset = -1, j = 0; chset < s->xxch_chset; ++chset) {
- mask = chset >= 0 ? s->xxch_spk_masks[chset]
- : s->xxch_core_spkmask;
- for (i = 0; i < s->xxch_nbits_spk_mask; i++) {
- if (mask & ~(DCA_XXCH_LFE1 | DCA_XXCH_LFE2) & (1 << i)) {
- lavc = map_xxch_to_native[i];
- posn = av_popcount(channel_layout & (lavc - 1));
- s->xxch_order_tab[j++] = posn;
- }
- }
- }
-
- s->lfe_index = av_popcount(channel_layout & (AV_CH_LOW_FREQUENCY-1));
- } else { /* native ordering */
- for (i = 0; i < channels; i++)
- s->xxch_order_tab[i] = i;
-
- s->lfe_index = channels - 1;
- }
-
- s->channel_order_tab = s->xxch_order_tab;
- }
-
- if (avctx->channels != channels) {
- if (avctx->channels)
- av_log(avctx, AV_LOG_INFO, "Number of channels changed in DCA decoder (%d -> %d)\n", avctx->channels, channels);
- avctx->channels = channels;
- }
-
- /* get output buffer */
- frame->nb_samples = 256 * (s->sample_blocks / 8);
- if ((ret = ff_get_buffer(avctx, frame)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return ret;
- }
- samples_flt = (float **)frame->extended_data;
-
- /* allocate buffer for extra channels if downmixing */
- if (avctx->channels < full_channels) {
- ret = av_samples_get_buffer_size(NULL, full_channels - channels,
- frame->nb_samples,
- avctx->sample_fmt, 0);
- if (ret < 0)
- return ret;
-
- av_fast_malloc(&s->extra_channels_buffer,
- &s->extra_channels_buffer_size, ret);
- if (!s->extra_channels_buffer)
- return AVERROR(ENOMEM);
-
- ret = av_samples_fill_arrays((uint8_t **)s->extra_channels, NULL,
- s->extra_channels_buffer,
- full_channels - channels,
- frame->nb_samples, avctx->sample_fmt, 0);
- if (ret < 0)
- return ret;
- }
-
- /* filter to get final output */
- for (i = 0; i < (s->sample_blocks / 8); i++) {
- int ch;
-
- for (ch = 0; ch < channels; ch++)
- s->samples_chanptr[ch] = samples_flt[ch] + i * 256;
- for (; ch < full_channels; ch++)
- s->samples_chanptr[ch] = s->extra_channels[ch - channels] + i * 256;
-
- dca_filter_channels(s, i);
-
- /* If this was marked as a DTS-ES stream we need to subtract back- */
- /* channel from SL & SR to remove matrixed back-channel signal */
- if ((s->source_pcm_res & 1) && s->xch_present) {
- float *back_chan = s->samples_chanptr[s->channel_order_tab[s->xch_base_channel]];
- float *lt_chan = s->samples_chanptr[s->channel_order_tab[s->xch_base_channel - 2]];
- float *rt_chan = s->samples_chanptr[s->channel_order_tab[s->xch_base_channel - 1]];
- s->fdsp.vector_fmac_scalar(lt_chan, back_chan, -M_SQRT1_2, 256);
- s->fdsp.vector_fmac_scalar(rt_chan, back_chan, -M_SQRT1_2, 256);
- }
-
- /* If stream contains XXCH, we might need to undo an embedded downmix */
- if (s->xxch_dmix_embedded) {
- /* Loop over channel sets in turn */
- ch = num_core_channels;
- for (chset = 0; chset < s->xxch_chset; chset++) {
- endch = ch + s->xxch_chset_nch[chset];
- mask = s->xxch_dmix_embedded;
-
- /* undo downmix */
- for (j = ch; j < endch; j++) {
- if (mask & (1 << j)) { /* this channel has been mixed-out */
- src_chan = s->samples_chanptr[s->channel_order_tab[j]];
- for (k = 0; k < endch; k++) {
- achan = s->channel_order_tab[k];
- scale = s->xxch_dmix_coeff[j][k];
- if (scale != 0.0) {
- dst_chan = s->samples_chanptr[achan];
- s->fdsp.vector_fmac_scalar(dst_chan, src_chan,
- -scale, 256);
- }
- }
- }
- }
-
- /* if a downmix has been embedded then undo the pre-scaling */
- if ((mask & (1 << ch)) && s->xxch_dmix_sf[chset] != 1.0f) {
- scale = s->xxch_dmix_sf[chset];
-
- for (j = 0; j < ch; j++) {
- src_chan = s->samples_chanptr[s->channel_order_tab[j]];
- for (k = 0; k < 256; k++)
- src_chan[k] *= scale;
- }
-
- /* LFE channel is always part of core, scale if it exists */
- if (s->lfe) {
- src_chan = s->samples_chanptr[s->lfe_index];
- for (k = 0; k < 256; k++)
- src_chan[k] *= scale;
- }
- }
-
- ch = endch;
- }
-
- }
- }
-
- /* update lfe history */
- lfe_samples = 2 * s->lfe * (s->sample_blocks / 8);
- for (i = 0; i < 2 * s->lfe * 4; i++)
- s->lfe_data[i] = s->lfe_data[i + lfe_samples];
-
- *got_frame_ptr = 1;
-
- return buf_size;
-}
-
-
-
-/**
- * DCA initialization
- *
- * @param avctx pointer to the AVCodecContext
- */
-
-static av_cold int dca_decode_init(AVCodecContext *avctx)
-{
- DCAContext *s = avctx->priv_data;
-
- s->avctx = avctx;
- dca_init_vlcs();
-
- avpriv_float_dsp_init(&s->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
- ff_mdct_init(&s->imdct, 6, 1, 1.0);
- ff_synth_filter_init(&s->synth);
- ff_dcadsp_init(&s->dcadsp);
- ff_fmt_convert_init(&s->fmt_conv, avctx);
-
- avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
-
- /* allow downmixing to stereo */
- if (avctx->channels > 0 && avctx->request_channels < avctx->channels &&
- avctx->request_channels == 2) {
- avctx->channels = avctx->request_channels;
- }
-
- return 0;
-}
-
-static av_cold int dca_decode_end(AVCodecContext *avctx)
-{
- DCAContext *s = avctx->priv_data;
- ff_mdct_end(&s->imdct);
- av_freep(&s->extra_channels_buffer);
- return 0;
-}
-
-static const AVProfile profiles[] = {
- { FF_PROFILE_DTS, "DTS" },
- { FF_PROFILE_DTS_ES, "DTS-ES" },
- { FF_PROFILE_DTS_96_24, "DTS 96/24" },
- { FF_PROFILE_DTS_HD_HRA, "DTS-HD HRA" },
- { FF_PROFILE_DTS_HD_MA, "DTS-HD MA" },
- { FF_PROFILE_UNKNOWN },
-};
-
-AVCodec ff_dca_decoder = {
- .name = "dca",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_DTS,
- .priv_data_size = sizeof(DCAContext),
- .init = dca_decode_init,
- .decode = dca_decode_frame,
- .close = dca_decode_end,
- .long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"),
- .capabilities = CODEC_CAP_CHANNEL_CONF | CODEC_CAP_DR1,
- .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
- AV_SAMPLE_FMT_NONE },
- .profiles = NULL_IF_CONFIG_SMALL(profiles),
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/dcadsp.c b/src/thirdparty/ffmpeg/libavcodec/dcadsp.c
deleted file mode 100644
index 65a2ecefa..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/dcadsp.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2004 Gildas Bazin
- * 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 "config.h"
-#include "dcadsp.h"
-
-static void dca_lfe_fir_c(float *out, const float *in, const float *coefs,
- int decifactor, float scale)
-{
- float *out2 = out + decifactor;
- const float *cf0 = coefs;
- const float *cf1 = coefs + 256;
- 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;
- }
- *out++ = v0 * scale;
- *out2++ = v1 * scale;
- }
-}
-
-void ff_dcadsp_init(DCADSPContext *s)
-{
- s->lfe_fir = dca_lfe_fir_c;
- if (ARCH_ARM) ff_dcadsp_init_arm(s);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/dcadsp.h b/src/thirdparty/ffmpeg/libavcodec/dcadsp.h
deleted file mode 100644
index 0297620ab..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/dcadsp.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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_DCADSP_H
-#define AVCODEC_DCADSP_H
-
-typedef struct DCADSPContext {
- void (*lfe_fir)(float *out, const float *in, const float *coefs,
- int decifactor, float scale);
-} DCADSPContext;
-
-void ff_dcadsp_init(DCADSPContext *s);
-void ff_dcadsp_init_arm(DCADSPContext *s);
-
-#endif /* AVCODEC_DCADSP_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/dcahuff.h b/src/thirdparty/ffmpeg/libavcodec/dcahuff.h
deleted file mode 100644
index 3f4e568b4..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/dcahuff.h
+++ /dev/null
@@ -1,1076 +0,0 @@
-/*
- * DCA compatible decoder - huffman tables
- * Copyright (C) 2004 Gildas Bazin
- * Copyright (C) 2007 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_DCAHUFF_H
-#define AVCODEC_DCAHUFF_H
-
-#include <stdint.h>
-#include <stdlib.h>
-
-#define TMODE_COUNT 4
-static const uint8_t tmode_vlc_bits[TMODE_COUNT] = { 3, 3, 3, 2 };
-static const uint16_t tmode_codes[TMODE_COUNT][4] = {
- { 0x0000, 0x0002, 0x0006, 0x0007 },
- { 0x0002, 0x0006, 0x0007, 0x0000 },
- { 0x0006, 0x0007, 0x0000, 0x0002 },
- { 0x0000, 0x0001, 0x0002, 0x0003 }
-};
-static const uint8_t tmode_bits[TMODE_COUNT][4] = {
- { 1, 2, 3, 3 },
- { 2, 3, 3, 1 },
- { 3, 3, 1, 2 },
- { 2, 2, 2, 2 }
-};
-
-
-#define BITALLOC_12_COUNT 5
-#define BITALLOC_12_VLC_BITS 9
-static const uint8_t bitalloc_12_vlc_bits[BITALLOC_12_COUNT] = {
- 9, 7, 7, 9, 9
-};
-static const uint16_t bitalloc_12_codes[BITALLOC_12_COUNT][12] = {
- {
- 0x0000, 0x0002, 0x0006, 0x000E, 0x001E, 0x003E, 0x00FF, 0x00FE,
- 0x01FB, 0x01FA, 0x01F9, 0x01F8,
- },
- {
- 0x0001, 0x0000, 0x0002, 0x000F, 0x000C, 0x001D, 0x0039, 0x0038,
- 0x0037, 0x0036, 0x0035, 0x0034,
- },
- {
- 0x0000, 0x0007, 0x0005, 0x0004, 0x0002, 0x000D, 0x000C, 0x0006,
- 0x000F, 0x001D, 0x0039, 0x0038,
- },
- {
- 0x0003, 0x0002, 0x0000, 0x0002, 0x0006, 0x000E, 0x001E, 0x003E,
- 0x007E, 0x00FE, 0x01FF, 0x01FE,
- },
- {
- 0x0001, 0x0000, 0x0002, 0x0006, 0x000E, 0x003F, 0x003D, 0x007C,
- 0x0079, 0x0078, 0x00FB, 0x00FA,
- }
-};
-static const uint8_t bitalloc_12_bits[BITALLOC_12_COUNT][12] = {
- { 1, 2, 3, 4, 5, 6, 8, 8, 9, 9, 9, 9 },
- { 1, 2, 3, 5, 5, 6, 7, 7, 7, 7, 7, 7 },
- { 2, 3, 3, 3, 3, 4, 4, 4, 5, 6, 7, 7 },
- { 2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10 },
- { 1, 2, 3, 4, 5, 7, 7, 8, 8, 8, 9, 9 }
-};
-
-
-#define SCALES_COUNT 5
-#define SCALES_VLC_BITS 9
-static const uint16_t scales_codes[SCALES_COUNT][129] = {
- {
- 0x3AB0, 0x3AB2, 0x3AB4, 0x3AB6, 0x3AB8, 0x3ABA, 0x3ABC, 0x3ABE,
- 0x3AC0, 0x3AC2, 0x3AC4, 0x3AC6, 0x3AC8, 0x3ACA, 0x3ACC, 0x3ACE,
- 0x3AD0, 0x3AD2, 0x3AD4, 0x3AD6, 0x3AD8, 0x3ADA, 0x3ADC, 0x3ADE,
- 0x3AE0, 0x3AE2, 0x3AE4, 0x3AE6, 0x3AE8, 0x3AEA, 0x3AEC, 0x3AEE,
- 0x3AF0, 0x3AF2, 0x3AF4, 0x3AF6, 0x3AF8, 0x3AFA, 0x3AFC, 0x3AFE,
- 0x0540, 0x0542, 0x0544, 0x0546, 0x0548, 0x054A, 0x054C, 0x054E,
- 0x0558, 0x055E, 0x02AD, 0x0154, 0x0754, 0x03A8, 0x0056, 0x0028,
- 0x00E8, 0x004A, 0x000B, 0x003B, 0x0013, 0x0003, 0x000F, 0x0005,
- 0x0001, 0x0006, 0x0000, 0x0008, 0x001C, 0x0004, 0x0024, 0x004B,
- 0x00E9, 0x0029, 0x0057, 0x03A9, 0x0755, 0x0155, 0x02AE, 0x055F,
- 0x0559, 0x054F, 0x054D, 0x054B, 0x0549, 0x0547, 0x0545, 0x0543,
- 0x0541, 0x3AFF, 0x3AFD, 0x3AFB, 0x3AF9, 0x3AF7, 0x3AF5, 0x3AF3,
- 0x3AF1, 0x3AEF, 0x3AED, 0x3AEB, 0x3AE9, 0x3AE7, 0x3AE5, 0x3AE3,
- 0x3AE1, 0x3ADF, 0x3ADD, 0x3ADB, 0x3AD9, 0x3AD7, 0x3AD5, 0x3AD3,
- 0x3AD1, 0x3ACF, 0x3ACD, 0x3ACB, 0x3AC9, 0x3AC7, 0x3AC5, 0x3AC3,
- 0x3AC1, 0x3ABF, 0x3ABD, 0x3ABB, 0x3AB9, 0x3AB7, 0x3AB5, 0x3AB3,
- 0x3AB1,
- },
- {
- 0x0F60, 0x0F62, 0x0F64, 0x0F66, 0x0F68, 0x0F6A, 0x0F6C, 0x0F6E,
- 0x0F70, 0x0F72, 0x0F74, 0x0F76, 0x0F78, 0x0F7A, 0x0F7C, 0x0F7E,
- 0x0F80, 0x0F82, 0x0F84, 0x0F86, 0x0F88, 0x0F8A, 0x0F8C, 0x0F8E,
- 0x0F90, 0x0F92, 0x0F94, 0x0F96, 0x0F98, 0x0F9A, 0x0F9C, 0x0F9E,
- 0x0FA0, 0x0FA2, 0x0FA4, 0x0FA6, 0x0FA8, 0x0FAA, 0x0FAC, 0x0FAE,
- 0x0FB0, 0x0FB2, 0x0FB4, 0x0FB6, 0x0FB8, 0x0FBA, 0x0FBC, 0x0FBE,
- 0x07A0, 0x07A2, 0x03D2, 0x01EA, 0x00FC, 0x007F, 0x001C, 0x000C,
- 0x0004, 0x0034, 0x0010, 0x001B, 0x0009, 0x000B, 0x000E, 0x0001,
- 0x0003, 0x0002, 0x000F, 0x000C, 0x000A, 0x0000, 0x0011, 0x0035,
- 0x0005, 0x000D, 0x001D, 0x003C, 0x00FD, 0x01EB, 0x03D3, 0x07A3,
- 0x07A1, 0x0FBF, 0x0FBD, 0x0FBB, 0x0FB9, 0x0FB7, 0x0FB5, 0x0FB3,
- 0x0FB1, 0x0FAF, 0x0FAD, 0x0FAB, 0x0FA9, 0x0FA7, 0x0FA5, 0x0FA3,
- 0x0FA1, 0x0F9F, 0x0F9D, 0x0F9B, 0x0F99, 0x0F97, 0x0F95, 0x0F93,
- 0x0F91, 0x0F8F, 0x0F8D, 0x0F8B, 0x0F89, 0x0F87, 0x0F85, 0x0F83,
- 0x0F81, 0x0F7F, 0x0F7D, 0x0F7B, 0x0F79, 0x0F77, 0x0F75, 0x0F73,
- 0x0F71, 0x0F6F, 0x0F6D, 0x0F6B, 0x0F69, 0x0F67, 0x0F65, 0x0F63,
- 0x0F61,
- },
- {
- 0x51D0, 0x51D2, 0x51D4, 0x51D6, 0x51D8, 0x51DA, 0x51DC, 0x51DE,
- 0x51E0, 0x51E2, 0x51E4, 0x51E6, 0x51E8, 0x51EA, 0x51EC, 0x51EE,
- 0x51F0, 0x51F2, 0x51F4, 0x51F6, 0x51F8, 0x51FA, 0x51FC, 0x51FE,
- 0x70C0, 0x70C2, 0x70C4, 0x70C6, 0x70C8, 0x70CA, 0x70CC, 0x70CE,
- 0x70EC, 0x10EA, 0x3868, 0x3877, 0x0876, 0x1C35, 0x0434, 0x0A34,
- 0x0E1B, 0x021B, 0x051B, 0x070F, 0x010F, 0x0380, 0x0080, 0x0140,
- 0x01C1, 0x0041, 0x00A1, 0x00E2, 0x0022, 0x0052, 0x0072, 0x0012,
- 0x002A, 0x003A, 0x000A, 0x0016, 0x001E, 0x0006, 0x000C, 0x0000,
- 0x0004, 0x0001, 0x000D, 0x0007, 0x001F, 0x0017, 0x000B, 0x003B,
- 0x002B, 0x0013, 0x0073, 0x0053, 0x0023, 0x00E3, 0x00A2, 0x0042,
- 0x01C2, 0x0141, 0x0081, 0x0381, 0x028C, 0x010C, 0x051C, 0x021C,
- 0x0E1C, 0x0A35, 0x0435, 0x1C3A, 0x0877, 0x0874, 0x3869, 0x10EB,
- 0x70ED, 0x70CF, 0x70CD, 0x70CB, 0x70C9, 0x70C7, 0x70C5, 0x70C3,
- 0x70C1, 0x51FF, 0x51FD, 0x51FB, 0x51F9, 0x51F7, 0x51F5, 0x51F3,
- 0x51F1, 0x51EF, 0x51ED, 0x51EB, 0x51E9, 0x51E7, 0x51E5, 0x51E3,
- 0x51E1, 0x51DF, 0x51DD, 0x51DB, 0x51D9, 0x51D7, 0x51D5, 0x51D3,
- 0x51D1,
- },
- {
- 0x6F64, 0x6F66, 0x6F68, 0x6F6A, 0x6F6C, 0x6F6E, 0x6F70, 0x6F72,
- 0x6F74, 0x6F76, 0x6F78, 0x6F7A, 0x6F7C, 0x6F7E, 0x6F80, 0x6F82,
- 0x6F84, 0x6F86, 0x6F88, 0x6F8A, 0x6F8C, 0x6F8E, 0x6F90, 0x6F92,
- 0x6F94, 0x6F96, 0x6F98, 0x6F9A, 0x6F9C, 0x6F9E, 0x6FA0, 0x6FA2,
- 0x6FA4, 0x6FA6, 0x6FA8, 0x6FAA, 0x6FAC, 0x6FAE, 0x6FB0, 0x6FB2,
- 0x6FB4, 0x6FB6, 0x17B4, 0x37DC, 0x0BDB, 0x1BEF, 0x05EE, 0x0DF8,
- 0x02F8, 0x06FD, 0x017D, 0x037F, 0x00BF, 0x0040, 0x00C0, 0x0021,
- 0x0061, 0x0011, 0x0031, 0x0009, 0x0019, 0x0006, 0x000E, 0x0004,
- 0x0000, 0x0005, 0x000F, 0x0007, 0x001A, 0x000A, 0x0036, 0x0016,
- 0x006E, 0x002E, 0x00C1, 0x0041, 0x01BC, 0x00BC, 0x037A, 0x017A,
- 0x02F9, 0x0DF9, 0x05EF, 0x05EC, 0x1BD8, 0x37DD, 0x17B5, 0x6FB7,
- 0x6FB5, 0x6FB3, 0x6FB1, 0x6FAF, 0x6FAD, 0x6FAB, 0x6FA9, 0x6FA7,
- 0x6FA5, 0x6FA3, 0x6FA1, 0x6F9F, 0x6F9D, 0x6F9B, 0x6F99, 0x6F97,
- 0x6F95, 0x6F93, 0x6F91, 0x6F8F, 0x6F8D, 0x6F8B, 0x6F89, 0x6F87,
- 0x6F85, 0x6F83, 0x6F81, 0x6F7F, 0x6F7D, 0x6F7B, 0x6F79, 0x6F77,
- 0x6F75, 0x6F73, 0x6F71, 0x6F6F, 0x6F6D, 0x6F6B, 0x6F69, 0x6F67,
- 0x6F65,
- },
- {
- 0xDF54, 0xDF56, 0xDFC8, 0xDFCA, 0xDFCC, 0xDFCE, 0xDFD0, 0xDFD2,
- 0xDFD4, 0xDFD6, 0xDFD8, 0xDFDA, 0xDFDC, 0xDFDE, 0xDFE0, 0xDFE2,
- 0x0FE8, 0x2FEA, 0x6FA8, 0x6FF6, 0x07F5, 0x07F7, 0x37D2, 0x37F9,
- 0x03F8, 0x0BF8, 0x0BFB, 0x1BEB, 0x01FA, 0x05FA, 0x09FA, 0x0DFA,
- 0x0DFF, 0x00FF, 0x02FF, 0x06FB, 0x007C, 0x017C, 0x027C, 0x027F,
- 0x003C, 0x00BC, 0x013C, 0x01BC, 0x001C, 0x005C, 0x009C, 0x00DC,
- 0x000C, 0x002C, 0x004C, 0x006C, 0x0004, 0x0014, 0x0024, 0x0034,
- 0x0000, 0x0008, 0x0010, 0x0018, 0x001E, 0x0002, 0x0006, 0x000A,
- 0x000E, 0x000B, 0x0007, 0x0003, 0x001F, 0x0019, 0x0011, 0x0009,
- 0x0001, 0x0035, 0x0025, 0x0015, 0x0005, 0x006D, 0x004D, 0x002D,
- 0x000D, 0x00DD, 0x009D, 0x005D, 0x001D, 0x01BD, 0x013D, 0x00BD,
- 0x003D, 0x037C, 0x027D, 0x017D, 0x007D, 0x06FC, 0x04FC, 0x02FC,
- 0x00FC, 0x0DFB, 0x09FB, 0x05FB, 0x01FB, 0x1BF8, 0x1BE8, 0x0BF9,
- 0x03F9, 0x37FA, 0x37D3, 0x17F4, 0x07F6, 0x6FF7, 0x6FA9, 0x2FEB,
- 0x0FE9, 0xDFE3, 0xDFE1, 0xDFDF, 0xDFDD, 0xDFDB, 0xDFD9, 0xDFD7,
- 0xDFD5, 0xDFD3, 0xDFD1, 0xDFCF, 0xDFCD, 0xDFCB, 0xDFC9, 0xDF57,
- 0xDF55,
- }
-};
-
-static const uint8_t scales_bits[SCALES_COUNT][129] = {
- {
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 12, 11, 11, 10, 9, 8,
- 8, 7, 6, 6, 5, 4, 4, 3,
- 2, 3, 3, 4, 5, 5, 6, 7,
- 8, 8, 9, 10, 11, 11, 12, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14,
- },
- {
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 14, 14, 13, 12, 11, 10, 8, 7,
- 6, 6, 5, 5, 4, 4, 4, 3,
- 3, 3, 4, 4, 4, 4, 5, 6,
- 6, 7, 8, 9, 11, 12, 13, 14,
- 14, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15,
- },
- {
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 14, 14, 14, 13, 13, 12, 12,
- 12, 11, 11, 11, 10, 10, 9, 9,
- 9, 8, 8, 8, 7, 7, 7, 6,
- 6, 6, 5, 5, 5, 4, 4, 3,
- 3, 3, 4, 4, 5, 5, 5, 6,
- 6, 6, 7, 7, 7, 8, 8, 8,
- 9, 9, 9, 10, 10, 10, 11, 11,
- 12, 12, 12, 13, 13, 13, 14, 14,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15,
- },
- {
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 14, 14, 13, 13, 12, 12,
- 11, 11, 10, 10, 9, 8, 8, 7,
- 7, 6, 6, 5, 5, 4, 4, 3,
- 2, 3, 4, 4, 5, 5, 6, 6,
- 7, 7, 8, 8, 9, 9, 10, 10,
- 11, 12, 12, 12, 13, 14, 14, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15,
- },
- {
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 15, 15, 15, 15, 14, 14, 14, 14,
- 13, 13, 13, 13, 12, 12, 12, 12,
- 12, 11, 11, 11, 10, 10, 10, 10,
- 9, 9, 9, 9, 8, 8, 8, 8,
- 7, 7, 7, 7, 6, 6, 6, 6,
- 5, 5, 5, 5, 5, 4, 4, 4,
- 4, 4, 4, 4, 5, 5, 5, 5,
- 5, 6, 6, 6, 6, 7, 7, 7,
- 7, 8, 8, 8, 8, 9, 9, 9,
- 9, 10, 10, 10, 10, 11, 11, 11,
- 11, 12, 12, 12, 12, 13, 13, 13,
- 13, 14, 14, 14, 14, 15, 15, 15,
- 15, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16,
- }
-};
-
-static const uint16_t bitalloc_3_codes[3] =
-{
- 0x0003, 0x0000, 0x0002,
-};
-static const uint8_t bitalloc_3_bits[3] =
-{
- 2, 1, 2,
-};
-
-static const uint16_t bitalloc_5_codes_a[5] =
-{
- 0x000F, 0x0006, 0x0000, 0x0002, 0x000E,
-};
-static const uint16_t bitalloc_5_codes_b[5] =
-{
- 0x0007, 0x0001, 0x0002, 0x0000, 0x0006,
-};
-static const uint16_t bitalloc_5_codes_c[5] =
-{
- 0x0007, 0x0005, 0x0000, 0x0004, 0x0006,
-};
-static const uint8_t bitalloc_5_bits_a[5] =
-{
- 4, 3, 1, 2, 4,
-};
-static const uint8_t bitalloc_5_bits_b[5] =
-{
- 3, 2, 2, 2, 3,
-};
-static const uint8_t bitalloc_5_bits_c[5] =
-{
- 3, 3, 1, 3, 3,
-};
-
-static const uint16_t bitalloc_7_codes_a[7] =
-{
- 0x001E, 0x000E, 0x0005, 0x0000, 0x0006, 0x0004, 0x001F,
-};
-static const uint16_t bitalloc_7_codes_b[7] =
-{
- 0x0014, 0x000B, 0x0000, 0x0003, 0x0001, 0x0004, 0x0015,
-};
-static const uint16_t bitalloc_7_codes_c[7] =
-{
- 0x0000, 0x0002, 0x0001, 0x0003, 0x0002, 0x0003, 0x0001,
-};
-static const uint8_t bitalloc_7_bits_a[7] =
-{
- 5, 4, 3, 1, 3, 3, 5,
-};
-static const uint8_t bitalloc_7_bits_b[7] =
-{
- 5, 4, 2, 2, 2, 3, 5,
-};
-static const uint8_t bitalloc_7_bits_c[7] =
-{
- 4, 4, 2, 2, 2, 4, 4,
-};
-
-static const uint16_t bitalloc_9_codes_a[9] =
-{
- 0x0030, 0x0019, 0x0009, 0x0005, 0x0000, 0x0007, 0x000D, 0x0008,
- 0x0031,
-};
-static const uint16_t bitalloc_9_codes_b[9] =
-{
- 0x0018, 0x001A, 0x0002, 0x0007, 0x0002, 0x0000, 0x0003, 0x001B,
- 0x0019,
-};
-static const uint16_t bitalloc_9_codes_c[9] =
-{
- 0x001C, 0x000F, 0x0002, 0x0007, 0x0002, 0x0000, 0x0006, 0x0006,
- 0x001D,
-};
-static const uint8_t bitalloc_9_bits_a[9] =
-{
- 6, 5, 4, 3, 1, 3, 4, 4, 6,
-};
-static const uint8_t bitalloc_9_bits_b[9] =
-{
- 5, 5, 3, 3, 2, 2, 3, 5, 5,
-};
-static const uint8_t bitalloc_9_bits_c[9] =
-{
- 6, 5, 3, 3, 2, 2, 3, 4, 6,
-};
-
-static const uint16_t bitalloc_13_codes_a[13] =
-{
- 0x0070, 0x002E, 0x0039, 0x001D, 0x000C, 0x000F, 0x0000, 0x0004,
- 0x000D, 0x000A, 0x0016, 0x002F, 0x0071,
-};
-static const uint16_t bitalloc_13_codes_b[13] =
-{
- 0x0038, 0x0010, 0x001D, 0x0007, 0x000F, 0x0005, 0x0000, 0x0006,
- 0x0002, 0x0009, 0x0006, 0x0011, 0x0039,
-};
-static const uint16_t bitalloc_13_codes_c[13] =
-{
- 0x0004, 0x001A, 0x0003, 0x000E, 0x0000, 0x0003, 0x0005, 0x0004,
- 0x0002, 0x000F, 0x000C, 0x001B, 0x0005,
-};
-static const uint8_t bitalloc_13_bits_a[13] =
-{
- 7, 6, 6, 5, 4, 4, 1, 3, 4, 4, 5, 6, 7,
-};
-static const uint8_t bitalloc_13_bits_b[13] =
-{
- 6, 5, 5, 4, 4, 3, 2, 3, 3, 4, 4, 5, 6,
-};
-static const uint8_t bitalloc_13_bits_c[13] =
-{
- 5, 5, 4, 4, 3, 3, 3, 3, 3, 4, 4, 5, 5,
-};
-
-static const uint16_t bitalloc_17_codes_a[17] =
-{
- 0x0154, 0x00AB, 0x002B, 0x000B, 0x0003, 0x000A, 0x0001, 0x0006,
- 0x0001, 0x0007, 0x0004, 0x000B, 0x0000, 0x0004, 0x0014, 0x0054,
- 0x0155,
-};
-static const uint16_t bitalloc_17_codes_b[17] =
-{
- 0x007C, 0x003F, 0x0019, 0x000D, 0x001C, 0x0008, 0x000F, 0x0005,
- 0x0000, 0x0006, 0x0002, 0x0009, 0x001D, 0x000E, 0x001E, 0x0018,
- 0x007D,
-};
-static const uint16_t bitalloc_17_codes_c[17] =
-{
- 0x002C, 0x0017, 0x0005, 0x001C, 0x0003, 0x000A, 0x000F, 0x0003,
- 0x0006, 0x0004, 0x0000, 0x000B, 0x0004, 0x001D, 0x000A, 0x0004,
- 0x002D,
-};
-static const uint16_t bitalloc_17_codes_d[17] =
-{
- 0x0100, 0x0102, 0x0082, 0x0042, 0x0022, 0x0012, 0x000A, 0x0006,
- 0x0000, 0x0007, 0x000B, 0x0013, 0x0023, 0x0043, 0x0083, 0x0103,
- 0x0101,
-};
-static const uint16_t bitalloc_17_codes_e[17] =
-{
- 0x00E8, 0x00F6, 0x0075, 0x0034, 0x003B, 0x001B, 0x001F, 0x0004,
- 0x0000, 0x0005, 0x000C, 0x001C, 0x003C, 0x0035, 0x007A, 0x00F7,
- 0x00E9,
-};
-static const uint16_t bitalloc_17_codes_f[17] =
-{
- 0x0004, 0x0003, 0x001E, 0x0001, 0x0001, 0x000E, 0x0001, 0x0004,
- 0x0006, 0x0005, 0x0002, 0x000F, 0x0006, 0x000E, 0x001F, 0x0000,
- 0x0005,
-};
-static const uint16_t bitalloc_17_codes_g[17] =
-{
- 0x0060, 0x007E, 0x0031, 0x0019, 0x000D, 0x0004, 0x0000, 0x0006,
- 0x0002, 0x0007, 0x0001, 0x0005, 0x000E, 0x001E, 0x003E, 0x007F,
- 0x0061,
-};
-static const uint8_t bitalloc_17_bits_a[17] =
-{
- 12, 11, 9, 7, 5, 4, 3, 3, 2, 3, 3, 4, 4, 6, 8, 10,
- 12,
-};
-static const uint8_t bitalloc_17_bits_b[17] =
-{
- 8, 7, 6, 5, 5, 4, 4, 3, 2, 3, 3, 4, 5, 5, 6, 6,
- 8,
-};
-static const uint8_t bitalloc_17_bits_c[17] =
-{
- 7, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 4, 4, 5, 5, 5,
- 7,
-};
-static const uint8_t bitalloc_17_bits_d[17] =
-{
- 9, 9, 8, 7, 6, 5, 4, 3, 1, 3, 4, 5, 6, 7, 8, 9,
- 9,
-};
-static const uint8_t bitalloc_17_bits_e[17] =
-{
- 8, 8, 7, 6, 6, 5, 5, 3, 1, 3, 4, 5, 6, 6, 7, 8,
- 8,
-};
-static const uint8_t bitalloc_17_bits_f[17] =
-{
- 8, 7, 6, 5, 4, 4, 3, 3, 3, 3, 3, 4, 4, 5, 6, 6,
- 8,
-};
-static const uint8_t bitalloc_17_bits_g[17] =
-{
- 8, 8, 7, 6, 5, 4, 3, 3, 2, 3, 3, 4, 5, 6, 7, 8,
- 8,
-};
-
-static const uint16_t bitalloc_25_codes_a[25] =
-{
- 0x2854, 0x142B, 0x050B, 0x0143, 0x00A2, 0x0052, 0x002E, 0x0015,
- 0x0004, 0x000E, 0x0000, 0x0003, 0x0006, 0x0004, 0x0001, 0x000F,
- 0x0005, 0x0016, 0x002F, 0x0053, 0x00A3, 0x00A0, 0x0284, 0x0A14,
- 0x2855,
-};
-static const uint16_t bitalloc_25_codes_b[25] =
-{
- 0x001C, 0x000F, 0x0005, 0x0000, 0x0030, 0x0036, 0x000E, 0x0019,
- 0x0001, 0x0008, 0x000E, 0x0001, 0x0005, 0x0002, 0x000F, 0x0009,
- 0x0006, 0x001A, 0x000F, 0x0037, 0x0031, 0x0001, 0x0006, 0x0004,
- 0x001D,
-};
-static const uint16_t bitalloc_25_codes_c[25] =
-{
- 0x004C, 0x0027, 0x006D, 0x0028, 0x0037, 0x000E, 0x0015, 0x0000,
- 0x0005, 0x0008, 0x000B, 0x000E, 0x0001, 0x000F, 0x000C, 0x0009,
- 0x0006, 0x0001, 0x001A, 0x000F, 0x0008, 0x0029, 0x0012, 0x006C,
- 0x004D,
-};
-static const uint16_t bitalloc_25_codes_d[25] =
-{
- 0x0780, 0x0782, 0x03C2, 0x01E2, 0x00FE, 0x0079, 0x003D, 0x001C,
- 0x000C, 0x0004, 0x0000, 0x0006, 0x0002, 0x0007, 0x0001, 0x0005,
- 0x000D, 0x001D, 0x003E, 0x007E, 0x00FF, 0x01E3, 0x03C3, 0x0783,
- 0x0781,
-};
-static const uint16_t bitalloc_25_codes_e[25] =
-{
- 0x003C, 0x0092, 0x0018, 0x001F, 0x004E, 0x000D, 0x0025, 0x0004,
- 0x0010, 0x0000, 0x000A, 0x0002, 0x0003, 0x0003, 0x000B, 0x0001,
- 0x0011, 0x0005, 0x0026, 0x000E, 0x004F, 0x0048, 0x0019, 0x0093,
- 0x003D,
-};
-static const uint16_t bitalloc_25_codes_f[25] =
-{
- 0x0324, 0x0193, 0x00CE, 0x0065, 0x0024, 0x000C, 0x0013, 0x0004,
- 0x0007, 0x000A, 0x000D, 0x000F, 0x0001, 0x0000, 0x000E, 0x000B,
- 0x0008, 0x0005, 0x0018, 0x000D, 0x0025, 0x0066, 0x00CF, 0x00C8,
- 0x0325,
-};
-static const uint16_t bitalloc_25_codes_g[25] =
-{
- 0x03A8, 0x03AE, 0x01D5, 0x0094, 0x0014, 0x004B, 0x000B, 0x003B,
- 0x0013, 0x0003, 0x000F, 0x0005, 0x0001, 0x0006, 0x0000, 0x0008,
- 0x001C, 0x0004, 0x0024, 0x0074, 0x0015, 0x0095, 0x01D6, 0x03AF,
- 0x03A9,
-};
-static const uint8_t bitalloc_25_bits_a[25] =
-{
- 14, 13, 11, 9, 8, 7, 6, 5, 4, 4, 3, 3, 3, 3, 3, 4,
- 4, 5, 6, 7, 8, 8, 10, 12, 14,
-};
-static const uint8_t bitalloc_25_bits_b[25] =
-{
- 9, 8, 7, 6, 6, 6, 5, 5, 4, 4, 4, 3, 3, 3, 4, 4,
- 4, 5, 5, 6, 6, 6, 7, 7, 9,
-};
-static const uint8_t bitalloc_25_bits_c[25] =
-{
- 8, 7, 7, 6, 6, 5, 5, 4, 4, 4, 4, 4, 3, 4, 4, 4,
- 4, 4, 5, 5, 5, 6, 6, 7, 8,
-};
-static const uint8_t bitalloc_25_bits_d[25] =
-{
- 12, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 3, 2, 3, 3, 4,
- 5, 6, 7, 8, 9, 10, 11, 12, 12,
-};
-static const uint8_t bitalloc_25_bits_e[25] =
-{
- 8, 8, 7, 7, 7, 6, 6, 5, 5, 4, 4, 3, 2, 3, 4, 4,
- 5, 5, 6, 6, 7, 7, 7, 8, 8,
-};
-static const uint8_t bitalloc_25_bits_f[25] =
-{
- 10, 9, 8, 7, 6, 5, 5, 4, 4, 4, 4, 4, 3, 3, 4, 4,
- 4, 4, 5, 5, 6, 7, 8, 8, 10,
-};
-static const uint8_t bitalloc_25_bits_g[25] =
-{
- 10, 10, 9, 8, 7, 7, 6, 6, 5, 4, 4, 3, 2, 3, 3, 4,
- 5, 5, 6, 7, 7, 8, 9, 10, 10,
-};
-
-static const uint16_t bitalloc_33_codes_a[33] =
-{
- 0x1580, 0x1582, 0x0AC2, 0x0562, 0x02B2, 0x015E, 0x00AD, 0x0054,
- 0x001C, 0x003C, 0x000F, 0x001F, 0x0008, 0x000B, 0x000D, 0x0000,
- 0x0002, 0x0001, 0x000E, 0x000C, 0x0009, 0x0006, 0x0014, 0x003D,
- 0x001D, 0x0055, 0x00AE, 0x015F, 0x02B3, 0x0563, 0x0AC3, 0x1583,
- 0x1581,
-};
-static const uint16_t bitalloc_33_codes_b[33] =
-{
- 0x030C, 0x0187, 0x006D, 0x0028, 0x0037, 0x0066, 0x0015, 0x0031,
- 0x0000, 0x000B, 0x0012, 0x001A, 0x0001, 0x0007, 0x000A, 0x000E,
- 0x0001, 0x000F, 0x000B, 0x0008, 0x0004, 0x001B, 0x0013, 0x000C,
- 0x0001, 0x0032, 0x001A, 0x0067, 0x0060, 0x0029, 0x00C2, 0x006C,
- 0x030D,
-};
-static const uint16_t bitalloc_33_codes_c[33] =
-{
- 0x00CC, 0x0067, 0x0005, 0x0070, 0x0003, 0x001A, 0x0039, 0x003F,
- 0x000A, 0x0012, 0x0018, 0x001D, 0x0001, 0x0003, 0x0007, 0x000A,
- 0x000D, 0x000B, 0x0008, 0x0004, 0x0002, 0x001E, 0x0019, 0x0013,
- 0x000B, 0x0000, 0x003E, 0x001B, 0x0018, 0x0071, 0x0032, 0x0004,
- 0x00CD,
-};
-static const uint16_t bitalloc_33_codes_d[33] =
-{
- 0x3AF8, 0x3AFA, 0x1D7E, 0x0EBC, 0x075C, 0x03AC, 0x01D4, 0x0094,
- 0x0014, 0x004B, 0x000B, 0x003B, 0x0013, 0x0003, 0x000F, 0x0005,
- 0x0001, 0x0006, 0x0000, 0x0008, 0x001C, 0x0004, 0x0024, 0x0074,
- 0x0015, 0x0095, 0x01D5, 0x03AD, 0x075D, 0x0EBD, 0x1D7F, 0x3AFB,
- 0x3AF9,
-};
-static const uint16_t bitalloc_33_codes_e[33] =
-{
- 0x01C8, 0x01E6, 0x0064, 0x00E2, 0x00E5, 0x0030, 0x0033, 0x0073,
- 0x007A, 0x001A, 0x003A, 0x0002, 0x001A, 0x001F, 0x0007, 0x0001,
- 0x0002, 0x0002, 0x000C, 0x0000, 0x001B, 0x0003, 0x003B, 0x001B,
- 0x007B, 0x0078, 0x0070, 0x0031, 0x00F2, 0x00E3, 0x0065, 0x01E7,
- 0x01C9,
-};
-static const uint16_t bitalloc_33_codes_f[33] =
-{
- 0x0724, 0x0393, 0x01CE, 0x00E5, 0x002C, 0x0008, 0x0017, 0x003E,
- 0x0005, 0x0014, 0x001D, 0x0000, 0x0003, 0x0006, 0x0008, 0x000B,
- 0x000D, 0x000C, 0x0009, 0x0007, 0x0004, 0x0001, 0x001E, 0x0015,
- 0x000A, 0x003F, 0x0038, 0x0009, 0x002D, 0x00E6, 0x01CF, 0x01C8,
- 0x0725,
-};
-static const uint16_t bitalloc_33_codes_g[33] =
-{
- 0x0284, 0x0042, 0x0140, 0x0143, 0x003E, 0x00BE, 0x0011, 0x0051,
- 0x0009, 0x0029, 0x0005, 0x0015, 0x0000, 0x0008, 0x000E, 0x0002,
- 0x0006, 0x0003, 0x000F, 0x0009, 0x0001, 0x0016, 0x0006, 0x002E,
- 0x000E, 0x005E, 0x001E, 0x00BF, 0x003F, 0x0020, 0x0141, 0x0043,
- 0x0285,
-};
-static const uint8_t bitalloc_33_bits_a[33] =
-{
- 13, 13, 12, 11, 10, 9, 8, 7, 6, 6, 5, 5, 4, 4, 4, 3,
- 3, 3, 4, 4, 4, 4, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13,
- 13,
-};
-static const uint8_t bitalloc_33_bits_b[33] =
-{
- 10, 9, 8, 7, 7, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4,
- 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8,
- 10,
-};
-static const uint8_t bitalloc_33_bits_c[33] =
-{
- 9, 8, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 7, 7, 7,
- 9,
-};
-static const uint8_t bitalloc_33_bits_d[33] =
-{
- 14, 14, 13, 12, 11, 10, 9, 8, 7, 7, 6, 6, 5, 4, 4, 3,
- 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9, 10, 11, 12, 13, 14,
- 14,
-};
-static const uint8_t bitalloc_33_bits_e[33] =
-{
- 9, 9, 8, 8, 8, 7, 7, 7, 7, 6, 6, 5, 5, 5, 4, 3,
- 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9,
- 9,
-};
-static const uint8_t bitalloc_33_bits_f[33] =
-{
- 11, 10, 9, 8, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 8, 9, 9,
- 11,
-};
-static const uint8_t bitalloc_33_bits_g[33] =
-{
- 10, 9, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 4, 3,
- 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 8, 9, 9,
- 10,
-};
-
-static const uint16_t bitalloc_65_codes_a[65] =
-{
- 0x9E5C, 0x9E5E, 0x4F2C, 0x2794, 0x13C4, 0x1E44, 0x09E3, 0x0F23,
- 0x04F3, 0x0792, 0x027E, 0x03CE, 0x013D, 0x01E5, 0x009C, 0x00CC,
- 0x0040, 0x0058, 0x0067, 0x001E, 0x0021, 0x002D, 0x003D, 0x0007,
- 0x0011, 0x0014, 0x0017, 0x001A, 0x001C, 0x001F, 0x0001, 0x0004,
- 0x0006, 0x0005, 0x0002, 0x0000, 0x001D, 0x001B, 0x0018, 0x0015,
- 0x0012, 0x000E, 0x0006, 0x0032, 0x0026, 0x001F, 0x0078, 0x0059,
- 0x0041, 0x00CD, 0x009D, 0x01E6, 0x013E, 0x03CF, 0x027F, 0x0793,
- 0x0790, 0x04F0, 0x09E4, 0x1E45, 0x13C5, 0x2795, 0x4F2D, 0x9E5F,
- 0x9E5D,
-};
-static const uint16_t bitalloc_65_codes_b[65] =
-{
- 0x0A8C, 0x0547, 0x01B5, 0x0008, 0x00DB, 0x0152, 0x0005, 0x000B,
- 0x008E, 0x00AE, 0x00E4, 0x0003, 0x0037, 0x0039, 0x0055, 0x006C,
- 0x0073, 0x0003, 0x0015, 0x001D, 0x0028, 0x0030, 0x0037, 0x003E,
- 0x0006, 0x000B, 0x000F, 0x0012, 0x0016, 0x0019, 0x001D, 0x0001,
- 0x0004, 0x0002, 0x001E, 0x001A, 0x0017, 0x0013, 0x0010, 0x000C,
- 0x0007, 0x003F, 0x0038, 0x0031, 0x0029, 0x0022, 0x001A, 0x0014,
- 0x0000, 0x006D, 0x0056, 0x0046, 0x0038, 0x0004, 0x00E5, 0x00AF,
- 0x008F, 0x006C, 0x000A, 0x0153, 0x0150, 0x0009, 0x02A2, 0x01B4,
- 0x0A8D,
-};
-static const uint16_t bitalloc_65_codes_c[65] =
-{
- 0x045C, 0x022F, 0x03F5, 0x01BC, 0x01FB, 0x0059, 0x00D0, 0x00DF,
- 0x000A, 0x002D, 0x002F, 0x0052, 0x0069, 0x0078, 0x007F, 0x000A,
- 0x0010, 0x001C, 0x0023, 0x002A, 0x0035, 0x003A, 0x003D, 0x0000,
- 0x0003, 0x0006, 0x0009, 0x000C, 0x000F, 0x0012, 0x0016, 0x0018,
- 0x001C, 0x0019, 0x0017, 0x0013, 0x0010, 0x000D, 0x000A, 0x0007,
- 0x0004, 0x0001, 0x003E, 0x003B, 0x0036, 0x002B, 0x0028, 0x001D,
- 0x0011, 0x000B, 0x0004, 0x0079, 0x006E, 0x0053, 0x0044, 0x002E,
- 0x000B, 0x00FC, 0x00D1, 0x008A, 0x0058, 0x01BD, 0x0116, 0x03F4,
- 0x045D,
-};
-static const uint16_t bitalloc_65_codes_d[65] =
-{
- 0x70B0, 0x70B2, 0x70B4, 0x2852, 0x385B, 0x142E, 0x1C2E, 0x0A15,
- 0x0E14, 0x0214, 0x0704, 0x0104, 0x010B, 0x0383, 0x0083, 0x0143,
- 0x01C3, 0x0043, 0x00A2, 0x00E2, 0x0022, 0x0052, 0x0072, 0x0012,
- 0x002A, 0x003A, 0x000A, 0x0016, 0x001E, 0x0006, 0x000C, 0x0000,
- 0x0004, 0x0001, 0x000D, 0x0007, 0x001F, 0x0017, 0x000B, 0x003B,
- 0x002B, 0x0013, 0x0073, 0x0053, 0x0023, 0x00E3, 0x00A3, 0x00A0,
- 0x0040, 0x01C0, 0x0084, 0x0384, 0x0284, 0x0105, 0x0705, 0x0215,
- 0x0E15, 0x0A16, 0x1C2F, 0x142F, 0x1428, 0x2853, 0x70B5, 0x70B3,
- 0x70B1,
-};
-static const uint16_t bitalloc_65_codes_e[65] =
-{
- 0x032C, 0x0332, 0x0378, 0x037E, 0x008C, 0x014A, 0x0188, 0x0197,
- 0x019E, 0x01BD, 0x0044, 0x0047, 0x00AA, 0x00C5, 0x00CD, 0x00DC,
- 0x001C, 0x002C, 0x0053, 0x0063, 0x0068, 0x0008, 0x000F, 0x0017,
- 0x002B, 0x0035, 0x0005, 0x0009, 0x0016, 0x001C, 0x0006, 0x000F,
- 0x0004, 0x0000, 0x0007, 0x001D, 0x0017, 0x000A, 0x0006, 0x0036,
- 0x0030, 0x0028, 0x0010, 0x0009, 0x0069, 0x0064, 0x0054, 0x002D,
- 0x001D, 0x00DD, 0x00CE, 0x00CA, 0x00AB, 0x00A4, 0x0045, 0x01BE,
- 0x019F, 0x0198, 0x0189, 0x014B, 0x008D, 0x037F, 0x0379, 0x0333,
- 0x032D,
-};
-static const uint16_t bitalloc_65_codes_f[65] =
-{
- 0x0FE0, 0x0FE2, 0x0FE8, 0x0FEA, 0x0FEC, 0x0FEE, 0x0FF0, 0x0FF2,
- 0x0FF4, 0x2FF2, 0x07F2, 0x07FB, 0x03F6, 0x0BFA, 0x0BFD, 0x01FF,
- 0x05FF, 0x02FC, 0x007C, 0x017C, 0x003C, 0x00BC, 0x001C, 0x005C,
- 0x000C, 0x002C, 0x0004, 0x0014, 0x0000, 0x0008, 0x000E, 0x0002,
- 0x0006, 0x0003, 0x000F, 0x0009, 0x0001, 0x0015, 0x0005, 0x002D,
- 0x000D, 0x005D, 0x001D, 0x00BD, 0x003D, 0x017D, 0x007D, 0x02FD,
- 0x00FC, 0x05FC, 0x01FA, 0x0BFB, 0x03F7, 0x17F8, 0x07F3, 0x2FF3,
- 0x0FF5, 0x0FF3, 0x0FF1, 0x0FEF, 0x0FED, 0x0FEB, 0x0FE9, 0x0FE3,
- 0x0FE1,
-};
-static const uint16_t bitalloc_65_codes_g[65] =
-{
- 0x010C, 0x038A, 0x0608, 0x0786, 0x0084, 0x0087, 0x0302, 0x0305,
- 0x0040, 0x00E0, 0x00E3, 0x0183, 0x001E, 0x005E, 0x009E, 0x00DE,
- 0x00F1, 0x0011, 0x0039, 0x0061, 0x0079, 0x0009, 0x001D, 0x0031,
- 0x003D, 0x0005, 0x000F, 0x0019, 0x001F, 0x0003, 0x0006, 0x000A,
- 0x000E, 0x000B, 0x0008, 0x0004, 0x0000, 0x001A, 0x0012, 0x000A,
- 0x0002, 0x0036, 0x0026, 0x0016, 0x0006, 0x006E, 0x004E, 0x002E,
- 0x000E, 0x00DF, 0x009F, 0x005F, 0x001F, 0x01E0, 0x0180, 0x00E1,
- 0x0041, 0x03C2, 0x0303, 0x01C4, 0x0085, 0x0787, 0x0609, 0x038B,
- 0x010D,
-};
-static const uint8_t bitalloc_65_bits_a[65] =
-{
- 16, 16, 15, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8,
- 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 4, 4,
- 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 7, 7,
- 7, 8, 8, 9, 9, 10, 10, 11, 11, 11, 12, 13, 13, 14, 15, 16,
- 16,
-};
-static const uint8_t bitalloc_65_bits_b[65] =
-{
- 12, 11, 10, 9, 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7,
- 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 4,
- 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6,
- 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 10, 10,
- 12,
-};
-static const uint8_t bitalloc_65_bits_c[65] =
-{
- 11, 10, 10, 9, 9, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6,
- 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 10,
- 11,
-};
-static const uint8_t bitalloc_65_bits_d[65] =
-{
- 15, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 10, 9, 9,
- 9, 8, 8, 8, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 3,
- 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8,
- 8, 9, 9, 10, 10, 10, 11, 11, 12, 12, 13, 13, 13, 14, 15, 15,
- 15,
-};
-static const uint8_t bitalloc_65_bits_e[65] =
-{
- 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8,
- 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 4, 4,
- 3, 3, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7,
- 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10,
- 10,
-};
-static const uint8_t bitalloc_65_bits_f[65] =
-{
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 13, 12, 12, 12, 11,
- 11, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 4, 3,
- 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10,
- 10, 11, 11, 12, 12, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14,
-};
-static const uint8_t bitalloc_65_bits_g[65] =
-{
- 11, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 8, 8, 8, 8,
- 8, 7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 4, 4, 4,
- 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7,
- 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11,
- 11,
-};
-
-static const uint16_t bitalloc_129_codes_a[129] =
-{
- 0x0660, 0x0666, 0x06EC, 0x0722, 0x0760, 0x076E, 0x004C, 0x004E,
- 0x00F4, 0x010A, 0x0148, 0x0156, 0x01D4, 0x01F2, 0x0331, 0x0370,
- 0x0377, 0x0396, 0x03B1, 0x0024, 0x0064, 0x007B, 0x008A, 0x00A5,
- 0x00D4, 0x00EB, 0x00FA, 0x019A, 0x01B9, 0x01C9, 0x01D9, 0x0010,
- 0x0030, 0x0033, 0x0043, 0x0053, 0x006B, 0x007A, 0x00CA, 0x00D2,
- 0x00DE, 0x00E6, 0x00F6, 0x000E, 0x001F, 0x0023, 0x002B, 0x003B,
- 0x003F, 0x0067, 0x0070, 0x0077, 0x0005, 0x000D, 0x0012, 0x001B,
- 0x002C, 0x0035, 0x003A, 0x0004, 0x000B, 0x0017, 0x001F, 0x0009,
- 0x0008, 0x000A, 0x0000, 0x0018, 0x000C, 0x0005, 0x003C, 0x0036,
- 0x002D, 0x001C, 0x0013, 0x000E, 0x0006, 0x007A, 0x0071, 0x0068,
- 0x0064, 0x003C, 0x0034, 0x0028, 0x0020, 0x000F, 0x00F7, 0x00E7,
- 0x00DF, 0x00D3, 0x00CB, 0x007B, 0x0074, 0x0054, 0x0044, 0x003C,
- 0x0031, 0x0011, 0x01DA, 0x01CA, 0x01BA, 0x019B, 0x00FB, 0x00F8,
- 0x00D5, 0x00AA, 0x008B, 0x0084, 0x0065, 0x0025, 0x03B6, 0x0397,
- 0x0390, 0x0371, 0x0332, 0x01F3, 0x01D5, 0x0157, 0x0149, 0x010B,
- 0x00F5, 0x004F, 0x004D, 0x076F, 0x0761, 0x0723, 0x06ED, 0x0667,
- 0x0661,
-};
-static const uint16_t bitalloc_129_codes_b[129] =
-{
- 0x29DC, 0x14EF, 0x0455, 0x0E9C, 0x022B, 0x0489, 0x0740, 0x074F,
- 0x0172, 0x0245, 0x0247, 0x030A, 0x03A1, 0x001C, 0x008B, 0x00D6,
- 0x010C, 0x0148, 0x014F, 0x0186, 0x01D1, 0x0008, 0x000F, 0x0046,
- 0x005D, 0x0078, 0x0087, 0x0096, 0x00A5, 0x00BC, 0x00D8, 0x00DE,
- 0x00F6, 0x0005, 0x0014, 0x0024, 0x002F, 0x003A, 0x003D, 0x0049,
- 0x0050, 0x0058, 0x005F, 0x0066, 0x006D, 0x0075, 0x007C, 0x0004,
- 0x000B, 0x0013, 0x0018, 0x001B, 0x001F, 0x0022, 0x0026, 0x002A,
- 0x002D, 0x0031, 0x0034, 0x0038, 0x003B, 0x003F, 0x0003, 0x0006,
- 0x000A, 0x0007, 0x0004, 0x0000, 0x003C, 0x0039, 0x0035, 0x0032,
- 0x002E, 0x002B, 0x0027, 0x0023, 0x0020, 0x001C, 0x0019, 0x0016,
- 0x0010, 0x0005, 0x007D, 0x007A, 0x006E, 0x0067, 0x0060, 0x0059,
- 0x0051, 0x004A, 0x0042, 0x003B, 0x0034, 0x0025, 0x0015, 0x0006,
- 0x00F7, 0x00DF, 0x00D9, 0x00BD, 0x00A6, 0x0097, 0x0090, 0x0079,
- 0x006A, 0x0047, 0x0044, 0x0009, 0x01D2, 0x0187, 0x0184, 0x0149,
- 0x010D, 0x00D7, 0x00B8, 0x001D, 0x03A6, 0x030B, 0x029C, 0x0246,
- 0x0173, 0x0114, 0x0741, 0x053A, 0x0488, 0x0E9D, 0x0A76, 0x0454,
- 0x29DD,
-};
-static const uint16_t bitalloc_129_codes_c[129] =
-{
- 0x0E5C, 0x072F, 0x001D, 0x0724, 0x000F, 0x010D, 0x0324, 0x0393,
- 0x03E9, 0x0080, 0x0087, 0x00FA, 0x0164, 0x0193, 0x01DE, 0x01F5,
- 0x0010, 0x002A, 0x0041, 0x0064, 0x0073, 0x008E, 0x00A4, 0x00B3,
- 0x00D6, 0x00E5, 0x00F4, 0x00FB, 0x0002, 0x0009, 0x0013, 0x001E,
- 0x0026, 0x002C, 0x0033, 0x003F, 0x0041, 0x004C, 0x0053, 0x005E,
- 0x0065, 0x0070, 0x0073, 0x0078, 0x007B, 0x007E, 0x0002, 0x0005,
- 0x0007, 0x000B, 0x000D, 0x0011, 0x0014, 0x0017, 0x001A, 0x001D,
- 0x0021, 0x0024, 0x0027, 0x002A, 0x002D, 0x0030, 0x0033, 0x0036,
- 0x003A, 0x0037, 0x0034, 0x0031, 0x002E, 0x002B, 0x0028, 0x0025,
- 0x0022, 0x001E, 0x001B, 0x0018, 0x0015, 0x0012, 0x000E, 0x000C,
- 0x0008, 0x0006, 0x0003, 0x007F, 0x007C, 0x0079, 0x0076, 0x0071,
- 0x006A, 0x005F, 0x0058, 0x004D, 0x0046, 0x0040, 0x0038, 0x002D,
- 0x0027, 0x001F, 0x0014, 0x0012, 0x0003, 0x0000, 0x00F5, 0x00EE,
- 0x00D7, 0x00C8, 0x00A5, 0x008F, 0x007C, 0x0065, 0x0042, 0x002B,
- 0x0011, 0x0002, 0x01DF, 0x01C8, 0x0165, 0x00FB, 0x00E4, 0x0081,
- 0x0006, 0x03E8, 0x0325, 0x01CA, 0x010C, 0x0725, 0x0396, 0x001C,
- 0x0E5D,
-};
-static const uint16_t bitalloc_129_codes_d[129] =
-{
- 0xA598, 0xA59A, 0xA59C, 0xA59E, 0xC598, 0xE586, 0x3ACC, 0x52CA,
- 0x62CD, 0x0D48, 0x1D67, 0x2978, 0x3167, 0x3966, 0x06A5, 0x0EBC,
- 0x14BD, 0x1CB1, 0x0350, 0x0353, 0x075F, 0x0A5F, 0x0C5E, 0x0E5E,
- 0x01AE, 0x03AD, 0x052D, 0x062D, 0x072D, 0x00D5, 0x01D4, 0x0294,
- 0x0314, 0x0394, 0x0014, 0x0094, 0x0114, 0x0174, 0x01B4, 0x01F4,
- 0x000B, 0x004B, 0x008B, 0x00BB, 0x00DB, 0x00FB, 0x001B, 0x003B,
- 0x0053, 0x0063, 0x0073, 0x0003, 0x0013, 0x0023, 0x002F, 0x0037,
- 0x003F, 0x0007, 0x000F, 0x0015, 0x0019, 0x001D, 0x0001, 0x0005,
- 0x0009, 0x0006, 0x0002, 0x001E, 0x001A, 0x0016, 0x0010, 0x0008,
- 0x0000, 0x0038, 0x0030, 0x0028, 0x001C, 0x000C, 0x007C, 0x006C,
- 0x005C, 0x0044, 0x0024, 0x0004, 0x00E4, 0x00C4, 0x00A4, 0x0074,
- 0x0034, 0x01F5, 0x01B5, 0x0175, 0x0115, 0x0095, 0x0015, 0x0395,
- 0x0315, 0x0295, 0x01D5, 0x00D6, 0x072E, 0x062E, 0x052E, 0x03AE,
- 0x01AF, 0x0E5F, 0x0C5F, 0x0C58, 0x0A58, 0x0758, 0x0351, 0x1CB2,
- 0x18B2, 0x0EBD, 0x0EB2, 0x3967, 0x3960, 0x2979, 0x2964, 0x0D49,
- 0x72C2, 0x52CB, 0x3ACD, 0xE587, 0xC599, 0xA59F, 0xA59D, 0xA59B,
- 0xA599,
-};
-static const uint16_t bitalloc_129_codes_e[129] =
-{
- 0xA13C, 0xC720, 0xA13F, 0xA13E, 0xA13D, 0xE722, 0x5090, 0x6393,
- 0x7392, 0x2849, 0x31CE, 0x39CE, 0x1425, 0x18E5, 0x1CE5, 0x0844,
- 0x0A1C, 0x0C7C, 0x036C, 0x0423, 0x050F, 0x063F, 0x01B7, 0x0216,
- 0x0285, 0x031D, 0x039D, 0x0109, 0x0140, 0x0180, 0x01C8, 0x01CF,
- 0x007A, 0x008A, 0x00A2, 0x00C1, 0x00E5, 0x0014, 0x0037, 0x0043,
- 0x004E, 0x0056, 0x0061, 0x006C, 0x007C, 0x000B, 0x001C, 0x001F,
- 0x0023, 0x0025, 0x0029, 0x002C, 0x002E, 0x0032, 0x0034, 0x0037,
- 0x003A, 0x003C, 0x003F, 0x0001, 0x0003, 0x0006, 0x0008, 0x000A,
- 0x000C, 0x000B, 0x0009, 0x0007, 0x0004, 0x0002, 0x0000, 0x003D,
- 0x003B, 0x0038, 0x0035, 0x0033, 0x002F, 0x002D, 0x002A, 0x0026,
- 0x0024, 0x0020, 0x001D, 0x001A, 0x007D, 0x006D, 0x0062, 0x0057,
- 0x004F, 0x0044, 0x003C, 0x0015, 0x00E6, 0x00C6, 0x00A3, 0x008B,
- 0x007B, 0x006C, 0x01C9, 0x0181, 0x0141, 0x010A, 0x00DA, 0x031E,
- 0x0286, 0x0217, 0x0210, 0x0738, 0x0638, 0x0508, 0x036D, 0x0C7D,
- 0x0A1D, 0x0845, 0x1CE6, 0x18E6, 0x1426, 0x39CF, 0x31CF, 0x284E,
- 0x7393, 0x7390, 0x5091, 0xE723, 0xC724, 0xC725, 0xC722, 0xC723,
- 0xC721,
-};
-static const uint16_t bitalloc_129_codes_f[129] =
-{
- 0x762C, 0x3B17, 0x1555, 0x0608, 0x0AAB, 0x0FF2, 0x0305, 0x0307,
- 0x0763, 0x0046, 0x010C, 0x01BC, 0x02AB, 0x03B6, 0x03FD, 0x0080,
- 0x0087, 0x00DF, 0x0156, 0x01D9, 0x01F8, 0x01FF, 0x002A, 0x0041,
- 0x0061, 0x0094, 0x00D4, 0x00EA, 0x00F2, 0x00FD, 0x0009, 0x000B,
- 0x001A, 0x0026, 0x0031, 0x0040, 0x004B, 0x006B, 0x0073, 0x0077,
- 0x007A, 0x007C, 0x0000, 0x0002, 0x0006, 0x0008, 0x000B, 0x000E,
- 0x0011, 0x0014, 0x0016, 0x0019, 0x001C, 0x001E, 0x0021, 0x0023,
- 0x0026, 0x0028, 0x002B, 0x002D, 0x002F, 0x0031, 0x0033, 0x0036,
- 0x0038, 0x0037, 0x0034, 0x0032, 0x0030, 0x002E, 0x002C, 0x0029,
- 0x0027, 0x0024, 0x0022, 0x001F, 0x001D, 0x001A, 0x0017, 0x0015,
- 0x0012, 0x000F, 0x000C, 0x0009, 0x0007, 0x0003, 0x0001, 0x007D,
- 0x007B, 0x0078, 0x0074, 0x0072, 0x0054, 0x0041, 0x0036, 0x0027,
- 0x001B, 0x0014, 0x000A, 0x00FE, 0x00F3, 0x00EB, 0x00D5, 0x0095,
- 0x006E, 0x0042, 0x002B, 0x0010, 0x01F9, 0x01DA, 0x0157, 0x0154,
- 0x00C0, 0x0081, 0x0022, 0x03B7, 0x03B0, 0x01BD, 0x010D, 0x0047,
- 0x07F8, 0x0554, 0x0306, 0x0FF3, 0x0EC4, 0x0609, 0x1D8A, 0x1554,
- 0x762D,
-};
-static const uint16_t bitalloc_129_codes_g[129] =
-{
- 0x1E20, 0x1E5E, 0x031C, 0x051A, 0x0718, 0x0916, 0x0B14, 0x0D12,
- 0x0F11, 0x0090, 0x018F, 0x028E, 0x038D, 0x048C, 0x058B, 0x068A,
- 0x0789, 0x0049, 0x00C8, 0x0148, 0x01C7, 0x0247, 0x02C6, 0x0346,
- 0x03C5, 0x0025, 0x0065, 0x00A5, 0x00E4, 0x0124, 0x0164, 0x01A4,
- 0x01E3, 0x0013, 0x0033, 0x0053, 0x0073, 0x0093, 0x00B3, 0x00D3,
- 0x00F3, 0x000A, 0x001A, 0x002A, 0x003A, 0x004A, 0x005A, 0x006A,
- 0x007A, 0x0006, 0x000E, 0x0016, 0x001E, 0x0026, 0x002E, 0x0036,
- 0x003E, 0x0004, 0x0008, 0x000C, 0x0010, 0x0014, 0x0018, 0x001C,
- 0x0000, 0x001D, 0x0019, 0x0015, 0x0011, 0x000D, 0x0009, 0x0005,
- 0x003F, 0x0037, 0x002F, 0x0027, 0x001F, 0x0017, 0x000F, 0x0007,
- 0x007B, 0x006B, 0x005B, 0x004B, 0x003B, 0x002B, 0x001B, 0x000B,
- 0x0008, 0x00F0, 0x00D0, 0x00B0, 0x0090, 0x0070, 0x0050, 0x0030,
- 0x01E4, 0x01A5, 0x0165, 0x0125, 0x00E5, 0x00E2, 0x00A2, 0x0062,
- 0x03CA, 0x0347, 0x02C7, 0x02C4, 0x0244, 0x0149, 0x00C9, 0x00C6,
- 0x0796, 0x068B, 0x0688, 0x048D, 0x048A, 0x028F, 0x028C, 0x0091,
- 0x0F2E, 0x0D13, 0x0B15, 0x0917, 0x0719, 0x051B, 0x031D, 0x1E5F,
- 0x1E21,
-};
-static const uint8_t bitalloc_129_bits_a[129] =
-{
- 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 4,
- 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11,
- 11,
-};
-static const uint8_t bitalloc_129_bits_b[129] =
-{
- 14, 13, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 10, 9, 9, 9,
- 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5,
- 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9,
- 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 11, 11, 11, 12, 12, 12,
- 14,
-};
-static const uint8_t bitalloc_129_bits_c[129] =
-{
- 13, 12, 11, 11, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11,
- 13,
-};
-static const uint8_t bitalloc_129_bits_d[129] =
-{
- 16, 16, 16, 16, 16, 16, 15, 15, 15, 14, 14, 14, 14, 14, 13, 13,
- 13, 13, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 10, 10, 10,
- 10, 10, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 7, 7,
- 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4,
- 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7,
- 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10,
- 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 13,
- 13, 13, 13, 14, 14, 14, 14, 14, 15, 15, 15, 16, 16, 16, 16, 16,
- 16,
-};
-static const uint8_t bitalloc_129_bits_e[129] =
-{
- 16, 16, 16, 16, 16, 16, 15, 15, 15, 14, 14, 14, 13, 13, 13, 12,
- 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9,
- 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8,
- 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12,
- 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 16, 16,
- 16,
-};
-static const uint8_t bitalloc_129_bits_f[129] =
-{
- 15, 14, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 10, 10, 10, 9,
- 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9,
- 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13,
- 15,
-};
-static const uint8_t bitalloc_129_bits_g[129] =
-{
- 13, 13, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11,
- 11, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9,
- 9, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7,
- 7, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5,
- 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6,
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8,
- 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
- 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 13,
- 13,
-};
-
-static const uint8_t bitalloc_sizes[10] = { 3, 5, 7, 9, 13, 17, 25, 33, 65, 129 };
-
-static const int8_t bitalloc_offsets[10] =
- { -1, -2, -3, -4, -6, -8, -12, -16, -32, -64 };
-
-static const uint8_t bitalloc_maxbits[10][7] = {
- { 2 },
- { 4, 3, 3 },
- { 5, 5, 4 },
- { 6, 5, 6 },
- { 7, 6, 5 },
- { 9, 8, 7, 9, 8, 8, 8 },
- { 9, 9, 8, 9, 8, 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 uint16_t* const bitalloc_codes[10][8] = {
- { bitalloc_3_codes, NULL },
- { bitalloc_5_codes_a, bitalloc_5_codes_b, bitalloc_5_codes_c, NULL },
- { bitalloc_7_codes_a, bitalloc_7_codes_b, bitalloc_7_codes_c, NULL },
- { bitalloc_9_codes_a, bitalloc_9_codes_b, bitalloc_9_codes_c, NULL },
- { bitalloc_13_codes_a, bitalloc_13_codes_b, bitalloc_13_codes_c, NULL },
- { bitalloc_17_codes_a, bitalloc_17_codes_b, bitalloc_17_codes_c, bitalloc_17_codes_d,
- bitalloc_17_codes_e, bitalloc_17_codes_f, bitalloc_17_codes_g, NULL },
- { bitalloc_25_codes_a, bitalloc_25_codes_b, bitalloc_25_codes_c, bitalloc_25_codes_d,
- bitalloc_25_codes_e, bitalloc_25_codes_f, bitalloc_25_codes_g, NULL },
- { bitalloc_33_codes_a, bitalloc_33_codes_b, bitalloc_33_codes_c, bitalloc_33_codes_d,
- bitalloc_33_codes_e, bitalloc_33_codes_f, bitalloc_33_codes_g, NULL },
- { bitalloc_65_codes_a, bitalloc_65_codes_b, bitalloc_65_codes_c, bitalloc_65_codes_d,
- bitalloc_65_codes_e, bitalloc_65_codes_f, bitalloc_65_codes_g, NULL },
- { bitalloc_129_codes_a, bitalloc_129_codes_b, bitalloc_129_codes_c, bitalloc_129_codes_d,
- bitalloc_129_codes_e, bitalloc_129_codes_f, bitalloc_129_codes_g, NULL }
-};
-
-static const uint8_t* const bitalloc_bits[10][8] = {
- { bitalloc_3_bits, NULL },
- { bitalloc_5_bits_a, bitalloc_5_bits_b, bitalloc_5_bits_c, NULL },
- { bitalloc_7_bits_a, bitalloc_7_bits_b, bitalloc_7_bits_c, NULL },
- { bitalloc_9_bits_a, bitalloc_9_bits_b, bitalloc_9_bits_c, NULL },
- { bitalloc_13_bits_a, bitalloc_13_bits_b, bitalloc_13_bits_c, NULL },
- { bitalloc_17_bits_a, bitalloc_17_bits_b, bitalloc_17_bits_c, bitalloc_17_bits_d,
- bitalloc_17_bits_e, bitalloc_17_bits_f, bitalloc_17_bits_g, NULL },
- { bitalloc_25_bits_a, bitalloc_25_bits_b, bitalloc_25_bits_c, bitalloc_25_bits_d,
- bitalloc_25_bits_e, bitalloc_25_bits_f, bitalloc_25_bits_g, NULL },
- { bitalloc_33_bits_a, bitalloc_33_bits_b, bitalloc_33_bits_c, bitalloc_33_bits_d,
- bitalloc_33_bits_e, bitalloc_33_bits_f, bitalloc_33_bits_g, NULL },
- { bitalloc_65_bits_a, bitalloc_65_bits_b, bitalloc_65_bits_c, bitalloc_65_bits_d,
- bitalloc_65_bits_e, bitalloc_65_bits_f, bitalloc_65_bits_g, NULL },
- { bitalloc_129_bits_a, bitalloc_129_bits_b, bitalloc_129_bits_c, bitalloc_129_bits_d,
- bitalloc_129_bits_e, bitalloc_129_bits_f, bitalloc_129_bits_g, NULL }
-};
-
-#endif /* AVCODEC_DCAHUFF_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/dct.c b/src/thirdparty/ffmpeg/libavcodec/dct.c
deleted file mode 100644
index 567506bb5..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/dct.c
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * (I)DCT Transforms
- * Copyright (c) 2009 Peter Ross <pross@xvid.org>
- * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com>
- * Copyright (c) 2010 Vitor Sessak
- *
- * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * (Inverse) Discrete Cosine Transforms. These are also known as the
- * type II and type III DCTs respectively.
- */
-
-#include <math.h>
-#include <string.h>
-
-#include "libavutil/mathematics.h"
-#include "dct.h"
-#include "dct32.h"
-
-/* sin((M_PI * x / (2 * n)) */
-#define SIN(s, n, x) (s->costab[(n) - (x)])
-
-/* cos((M_PI * x / (2 * n)) */
-#define COS(s, n, x) (s->costab[x])
-
-static void ff_dst_calc_I_c(DCTContext *ctx, FFTSample *data)
-{
- int n = 1 << ctx->nbits;
- int i;
-
- data[0] = 0;
- for (i = 1; i < n / 2; i++) {
- float tmp1 = data[i ];
- float tmp2 = data[n - i];
- float s = SIN(ctx, n, 2 * i);
-
- s *= tmp1 + tmp2;
- tmp1 = (tmp1 - tmp2) * 0.5f;
- data[i] = s + tmp1;
- data[n - i] = s - tmp1;
- }
-
- data[n / 2] *= 2;
- ctx->rdft.rdft_calc(&ctx->rdft, data);
-
- data[0] *= 0.5f;
-
- for (i = 1; i < n - 2; i += 2) {
- data[i + 1] += data[i - 1];
- data[i] = -data[i + 2];
- }
-
- data[n - 1] = 0;
-}
-
-static void ff_dct_calc_I_c(DCTContext *ctx, FFTSample *data)
-{
- int n = 1 << ctx->nbits;
- int i;
- float next = -0.5f * (data[0] - data[n]);
-
- for (i = 0; i < n / 2; i++) {
- float tmp1 = data[i];
- float tmp2 = data[n - i];
- float s = SIN(ctx, n, 2 * i);
- float c = COS(ctx, n, 2 * i);
-
- c *= tmp1 - tmp2;
- s *= tmp1 - tmp2;
-
- next += c;
-
- tmp1 = (tmp1 + tmp2) * 0.5f;
- data[i] = tmp1 - s;
- data[n - i] = tmp1 + s;
- }
-
- ctx->rdft.rdft_calc(&ctx->rdft, data);
- data[n] = data[1];
- data[1] = next;
-
- for (i = 3; i <= n; i += 2)
- data[i] = data[i - 2] - data[i];
-}
-
-static void ff_dct_calc_III_c(DCTContext *ctx, FFTSample *data)
-{
- int n = 1 << ctx->nbits;
- int i;
-
- float next = data[n - 1];
- float inv_n = 1.0f / n;
-
- for (i = n - 2; i >= 2; i -= 2) {
- float val1 = data[i];
- float val2 = data[i - 1] - data[i + 1];
- float c = COS(ctx, n, i);
- float s = SIN(ctx, n, i);
-
- data[i] = c * val1 + s * val2;
- data[i + 1] = s * val1 - c * val2;
- }
-
- data[1] = 2 * next;
-
- ctx->rdft.rdft_calc(&ctx->rdft, data);
-
- for (i = 0; i < n / 2; i++) {
- float tmp1 = data[i] * inv_n;
- float tmp2 = data[n - i - 1] * inv_n;
- float csc = ctx->csc2[i] * (tmp1 - tmp2);
-
- tmp1 += tmp2;
- data[i] = tmp1 + csc;
- data[n - i - 1] = tmp1 - csc;
- }
-}
-
-static void ff_dct_calc_II_c(DCTContext *ctx, FFTSample *data)
-{
- int n = 1 << ctx->nbits;
- int i;
- float next;
-
- for (i = 0; i < n / 2; i++) {
- float tmp1 = data[i];
- float tmp2 = data[n - i - 1];
- float s = SIN(ctx, n, 2 * i + 1);
-
- s *= tmp1 - tmp2;
- tmp1 = (tmp1 + tmp2) * 0.5f;
-
- data[i] = tmp1 + s;
- data[n-i-1] = tmp1 - s;
- }
-
- ctx->rdft.rdft_calc(&ctx->rdft, data);
-
- next = data[1] * 0.5;
- data[1] *= -1;
-
- for (i = n - 2; i >= 0; i -= 2) {
- float inr = data[i ];
- float ini = data[i + 1];
- float c = COS(ctx, n, i);
- float s = SIN(ctx, n, i);
-
- data[i] = c * inr + s * ini;
- data[i + 1] = next;
-
- next += s * inr - c * ini;
- }
-}
-
-static void dct32_func(DCTContext *ctx, FFTSample *data)
-{
- ctx->dct32(data, data);
-}
-
-av_cold int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType inverse)
-{
- int n = 1 << nbits;
- int i;
-
- memset(s, 0, sizeof(*s));
-
- s->nbits = nbits;
- s->inverse = inverse;
-
- if (inverse == DCT_II && nbits == 5) {
- s->dct_calc = dct32_func;
- } else {
- ff_init_ff_cos_tabs(nbits + 2);
-
- s->costab = ff_cos_tabs[nbits + 2];
- s->csc2 = av_malloc(n / 2 * sizeof(FFTSample));
-
- if (ff_rdft_init(&s->rdft, nbits, inverse == DCT_III) < 0) {
- av_free(s->csc2);
- return -1;
- }
-
- for (i = 0; i < n / 2; i++)
- s->csc2[i] = 0.5 / sin((M_PI / (2 * n) * (2 * i + 1)));
-
- switch (inverse) {
- case DCT_I : s->dct_calc = ff_dct_calc_I_c; break;
- case DCT_II : s->dct_calc = ff_dct_calc_II_c; break;
- case DCT_III: s->dct_calc = ff_dct_calc_III_c; break;
- case DST_I : s->dct_calc = ff_dst_calc_I_c; break;
- }
- }
-
- s->dct32 = ff_dct32_float;
- if (ARCH_X86)
- ff_dct_init_x86(s);
-
- return 0;
-}
-
-av_cold void ff_dct_end(DCTContext *s)
-{
- ff_rdft_end(&s->rdft);
- av_free(s->csc2);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/dct.h b/src/thirdparty/ffmpeg/libavcodec/dct.h
deleted file mode 100644
index 602416e92..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/dct.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * (I)DCT Transforms
- * Copyright (c) 2009 Peter Ross <pross@xvid.org>
- * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com>
- * Copyright (c) 2010 Vitor Sessak
- *
- * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_DCT_H
-#define AVCODEC_DCT_H
-
-#include <stdint.h>
-
-#include "rdft.h"
-
-struct DCTContext {
- int nbits;
- int inverse;
- RDFTContext rdft;
- const float *costab;
- FFTSample *csc2;
- void (*dct_calc)(struct DCTContext *s, FFTSample *data);
- void (*dct32)(FFTSample *out, const FFTSample *in);
-};
-
-/**
- * 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
- *
- * @note the first element of the input of DST-I is ignored
- */
-int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType type);
-void ff_dct_end (DCTContext *s);
-
-void ff_dct_init_x86(DCTContext *s);
-
-void ff_fdct_ifast(int16_t *data);
-void ff_fdct_ifast248(int16_t *data);
-void ff_jpeg_fdct_islow_8(int16_t *data);
-void ff_jpeg_fdct_islow_10(int16_t *data);
-void ff_fdct248_islow_8(int16_t *data);
-void ff_fdct248_islow_10(int16_t *data);
-
-void ff_j_rev_dct(int16_t *data);
-void ff_j_rev_dct4(int16_t *data);
-void ff_j_rev_dct2(int16_t *data);
-void ff_j_rev_dct1(int16_t *data);
-
-void ff_fdct_mmx(int16_t *block);
-void ff_fdct_mmxext(int16_t *block);
-void ff_fdct_sse2(int16_t *block);
-
-#endif /* AVCODEC_DCT_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/dct32.c b/src/thirdparty/ffmpeg/libavcodec/dct32.c
deleted file mode 100644
index f41aaa40f..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/dct32.c
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * Template for the Discrete Cosine Transform for 32 samples
- * Copyright (c) 2001, 2002 Fabrice Bellard
- *
- * 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 "dct32.h"
-#include "mathops.h"
-
-#if DCT32_FLOAT
-# define dct32 ff_dct32_float
-# define FIXHR(x) ((float)(x))
-# define MULH3(x, y, s) ((s)*(y)*(x))
-# define INTFLOAT float
-#else
-# define dct32 ff_dct32_fixed
-# define FIXHR(a) ((int)((a) * (1LL<<32) + 0.5))
-# define MULH3(x, y, s) MULH((s)*(x), y)
-# define INTFLOAT int
-#endif
-
-
-/* tab[i][j] = 1.0 / (2.0 * cos(pi*(2*k+1) / 2^(6 - j))) */
-
-/* cos(i*pi/64) */
-
-#define COS0_0 FIXHR(0.50060299823519630134/2)
-#define COS0_1 FIXHR(0.50547095989754365998/2)
-#define COS0_2 FIXHR(0.51544730992262454697/2)
-#define COS0_3 FIXHR(0.53104259108978417447/2)
-#define COS0_4 FIXHR(0.55310389603444452782/2)
-#define COS0_5 FIXHR(0.58293496820613387367/2)
-#define COS0_6 FIXHR(0.62250412303566481615/2)
-#define COS0_7 FIXHR(0.67480834145500574602/2)
-#define COS0_8 FIXHR(0.74453627100229844977/2)
-#define COS0_9 FIXHR(0.83934964541552703873/2)
-#define COS0_10 FIXHR(0.97256823786196069369/2)
-#define COS0_11 FIXHR(1.16943993343288495515/4)
-#define COS0_12 FIXHR(1.48416461631416627724/4)
-#define COS0_13 FIXHR(2.05778100995341155085/8)
-#define COS0_14 FIXHR(3.40760841846871878570/8)
-#define COS0_15 FIXHR(10.19000812354805681150/32)
-
-#define COS1_0 FIXHR(0.50241928618815570551/2)
-#define COS1_1 FIXHR(0.52249861493968888062/2)
-#define COS1_2 FIXHR(0.56694403481635770368/2)
-#define COS1_3 FIXHR(0.64682178335999012954/2)
-#define COS1_4 FIXHR(0.78815462345125022473/2)
-#define COS1_5 FIXHR(1.06067768599034747134/4)
-#define COS1_6 FIXHR(1.72244709823833392782/4)
-#define COS1_7 FIXHR(5.10114861868916385802/16)
-
-#define COS2_0 FIXHR(0.50979557910415916894/2)
-#define COS2_1 FIXHR(0.60134488693504528054/2)
-#define COS2_2 FIXHR(0.89997622313641570463/2)
-#define COS2_3 FIXHR(2.56291544774150617881/8)
-
-#define COS3_0 FIXHR(0.54119610014619698439/2)
-#define COS3_1 FIXHR(1.30656296487637652785/4)
-
-#define COS4_0 FIXHR(0.70710678118654752439/2)
-
-/* butterfly operator */
-#define BF(a, b, c, s)\
-{\
- tmp0 = val##a + val##b;\
- tmp1 = val##a - val##b;\
- val##a = tmp0;\
- val##b = MULH3(tmp1, c, 1<<(s));\
-}
-
-#define BF0(a, b, c, s)\
-{\
- tmp0 = tab[a] + tab[b];\
- tmp1 = tab[a] - tab[b];\
- val##a = tmp0;\
- val##b = MULH3(tmp1, c, 1<<(s));\
-}
-
-#define BF1(a, b, c, d)\
-{\
- BF(a, b, COS4_0, 1);\
- BF(c, d,-COS4_0, 1);\
- val##c += val##d;\
-}
-
-#define BF2(a, b, c, d)\
-{\
- BF(a, b, COS4_0, 1);\
- BF(c, d,-COS4_0, 1);\
- val##c += val##d;\
- val##a += val##c;\
- val##c += val##b;\
- val##b += val##d;\
-}
-
-#define ADD(a, b) val##a += val##b
-
-/* DCT32 without 1/sqrt(2) coef zero scaling. */
-void dct32(INTFLOAT *out, const INTFLOAT *tab)
-{
- INTFLOAT tmp0, tmp1;
-
- INTFLOAT val0 , val1 , val2 , val3 , val4 , val5 , val6 , val7 ,
- val8 , val9 , val10, val11, val12, val13, val14, val15,
- val16, val17, val18, val19, val20, val21, val22, val23,
- val24, val25, val26, val27, val28, val29, val30, val31;
-
- /* pass 1 */
- BF0( 0, 31, COS0_0 , 1);
- BF0(15, 16, COS0_15, 5);
- /* pass 2 */
- BF( 0, 15, COS1_0 , 1);
- BF(16, 31,-COS1_0 , 1);
- /* pass 1 */
- BF0( 7, 24, COS0_7 , 1);
- BF0( 8, 23, COS0_8 , 1);
- /* pass 2 */
- BF( 7, 8, COS1_7 , 4);
- BF(23, 24,-COS1_7 , 4);
- /* pass 3 */
- BF( 0, 7, COS2_0 , 1);
- BF( 8, 15,-COS2_0 , 1);
- BF(16, 23, COS2_0 , 1);
- BF(24, 31,-COS2_0 , 1);
- /* pass 1 */
- BF0( 3, 28, COS0_3 , 1);
- BF0(12, 19, COS0_12, 2);
- /* pass 2 */
- BF( 3, 12, COS1_3 , 1);
- BF(19, 28,-COS1_3 , 1);
- /* pass 1 */
- BF0( 4, 27, COS0_4 , 1);
- BF0(11, 20, COS0_11, 2);
- /* pass 2 */
- BF( 4, 11, COS1_4 , 1);
- BF(20, 27,-COS1_4 , 1);
- /* pass 3 */
- BF( 3, 4, COS2_3 , 3);
- BF(11, 12,-COS2_3 , 3);
- BF(19, 20, COS2_3 , 3);
- BF(27, 28,-COS2_3 , 3);
- /* pass 4 */
- BF( 0, 3, COS3_0 , 1);
- BF( 4, 7,-COS3_0 , 1);
- BF( 8, 11, COS3_0 , 1);
- BF(12, 15,-COS3_0 , 1);
- BF(16, 19, COS3_0 , 1);
- BF(20, 23,-COS3_0 , 1);
- BF(24, 27, COS3_0 , 1);
- BF(28, 31,-COS3_0 , 1);
-
-
-
- /* pass 1 */
- BF0( 1, 30, COS0_1 , 1);
- BF0(14, 17, COS0_14, 3);
- /* pass 2 */
- BF( 1, 14, COS1_1 , 1);
- BF(17, 30,-COS1_1 , 1);
- /* pass 1 */
- BF0( 6, 25, COS0_6 , 1);
- BF0( 9, 22, COS0_9 , 1);
- /* pass 2 */
- BF( 6, 9, COS1_6 , 2);
- BF(22, 25,-COS1_6 , 2);
- /* pass 3 */
- BF( 1, 6, COS2_1 , 1);
- BF( 9, 14,-COS2_1 , 1);
- BF(17, 22, COS2_1 , 1);
- BF(25, 30,-COS2_1 , 1);
-
- /* pass 1 */
- BF0( 2, 29, COS0_2 , 1);
- BF0(13, 18, COS0_13, 3);
- /* pass 2 */
- BF( 2, 13, COS1_2 , 1);
- BF(18, 29,-COS1_2 , 1);
- /* pass 1 */
- BF0( 5, 26, COS0_5 , 1);
- BF0(10, 21, COS0_10, 1);
- /* pass 2 */
- BF( 5, 10, COS1_5 , 2);
- BF(21, 26,-COS1_5 , 2);
- /* pass 3 */
- BF( 2, 5, COS2_2 , 1);
- BF(10, 13,-COS2_2 , 1);
- BF(18, 21, COS2_2 , 1);
- BF(26, 29,-COS2_2 , 1);
- /* pass 4 */
- BF( 1, 2, COS3_1 , 2);
- BF( 5, 6,-COS3_1 , 2);
- BF( 9, 10, COS3_1 , 2);
- BF(13, 14,-COS3_1 , 2);
- BF(17, 18, COS3_1 , 2);
- BF(21, 22,-COS3_1 , 2);
- BF(25, 26, COS3_1 , 2);
- BF(29, 30,-COS3_1 , 2);
-
- /* pass 5 */
- BF1( 0, 1, 2, 3);
- BF2( 4, 5, 6, 7);
- BF1( 8, 9, 10, 11);
- BF2(12, 13, 14, 15);
- BF1(16, 17, 18, 19);
- BF2(20, 21, 22, 23);
- BF1(24, 25, 26, 27);
- BF2(28, 29, 30, 31);
-
- /* pass 6 */
-
- ADD( 8, 12);
- ADD(12, 10);
- ADD(10, 14);
- ADD(14, 9);
- ADD( 9, 13);
- ADD(13, 11);
- ADD(11, 15);
-
- out[ 0] = val0;
- out[16] = val1;
- out[ 8] = val2;
- out[24] = val3;
- out[ 4] = val4;
- out[20] = val5;
- out[12] = val6;
- out[28] = val7;
- out[ 2] = val8;
- out[18] = val9;
- out[10] = val10;
- out[26] = val11;
- out[ 6] = val12;
- out[22] = val13;
- out[14] = val14;
- out[30] = val15;
-
- ADD(24, 28);
- ADD(28, 26);
- ADD(26, 30);
- ADD(30, 25);
- ADD(25, 29);
- ADD(29, 27);
- ADD(27, 31);
-
- out[ 1] = val16 + val24;
- out[17] = val17 + val25;
- out[ 9] = val18 + val26;
- out[25] = val19 + val27;
- out[ 5] = val20 + val28;
- out[21] = val21 + val29;
- out[13] = val22 + val30;
- out[29] = val23 + val31;
- out[ 3] = val24 + val20;
- out[19] = val25 + val21;
- out[11] = val26 + val22;
- out[27] = val27 + val23;
- out[ 7] = val28 + val18;
- out[23] = val29 + val19;
- out[15] = val30 + val17;
- out[31] = val31;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/dct32.h b/src/thirdparty/ffmpeg/libavcodec/dct32.h
deleted file mode 100644
index 529ee78e0..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/dct32.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_DCT32_H
-#define AVCODEC_DCT32_H
-
-void ff_dct32_float(float *dst, const float *src);
-void ff_dct32_fixed(int *dst, const int *src);
-
-#endif
diff --git a/src/thirdparty/ffmpeg/libavcodec/dct32_float.c b/src/thirdparty/ffmpeg/libavcodec/dct32_float.c
deleted file mode 100644
index a0bf786a1..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/dct32_float.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#define DCT32_FLOAT 1
-#include "dct32.c"
diff --git a/src/thirdparty/ffmpeg/libavcodec/diracdsp.h b/src/thirdparty/ffmpeg/libavcodec/diracdsp.h
deleted file mode 100644
index 426d4e4aa..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/diracdsp.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2010 David Conrad
- *
- * 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_DIRACDSP_H
-#define AVCODEC_DIRACDSP_H
-
-#include <stdint.h>
-
-typedef void (*dirac_weight_func)(uint8_t *block, int stride, int log2_denom, int weight, int h);
-typedef void (*dirac_biweight_func)(uint8_t *dst, const uint8_t *src, int stride, int log2_denom, int weightd, int weights, int h);
-
-typedef struct {
- void (*dirac_hpel_filter)(uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, const uint8_t *src, int stride, int width, int height);
- /**
- * dirac_pixels_tab[width][subpel]
- * width is 2 for 32, 1 for 16, 0 for 8
- * subpel is 0 for fpel and hpel (only need to copy from the first plane in src)
- * 1 if an average of the first 2 planes is needed (TODO: worth it?)
- * 2 for general qpel (avg of 4)
- * 3 for general epel (biweight of 4 using the weights in src[4])
- * src[0-3] is each of the hpel planes
- * src[4] is the 1/8 pel weights if needed
- */
- void (*put_dirac_pixels_tab[3][4])(uint8_t *dst, const uint8_t *src[5], int stride, int h);
- void (*avg_dirac_pixels_tab[3][4])(uint8_t *dst, const uint8_t *src[5], int stride, int h);
-
- void (*put_signed_rect_clamped)(uint8_t *dst/*align 16*/, int dst_stride, const int16_t *src/*align 16*/, int src_stride, int width, int height/*mod 2*/);
- void (*put_rect_clamped)(uint8_t *dst/*align 16*/, int dst_stride, const int16_t *src/*align 16*/, int src_stride, int width, int height/*mod 2*/);
- void (*add_rect_clamped)(uint8_t *dst/*align 16*/, const uint16_t *src/*align 16*/, int stride, const int16_t *idwt/*align 16*/, int idwt_stride, int width, int height/*mod 2*/);
- void (*add_dirac_obmc[3])(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen);
-
- dirac_weight_func weight_dirac_pixels_tab[3];
- dirac_biweight_func biweight_dirac_pixels_tab[3];
-} DiracDSPContext;
-
-#define DECL_DIRAC_PIXOP(PFX, EXT) \
- void ff_ ## PFX ## _dirac_pixels8_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h); \
- void ff_ ## PFX ## _dirac_pixels16_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h); \
- void ff_ ## PFX ## _dirac_pixels32_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)
-
-DECL_DIRAC_PIXOP(put, c);
-DECL_DIRAC_PIXOP(avg, c);
-DECL_DIRAC_PIXOP(put, l2_c);
-DECL_DIRAC_PIXOP(avg, l2_c);
-DECL_DIRAC_PIXOP(put, l4_c);
-DECL_DIRAC_PIXOP(avg, l4_c);
-
-void ff_diracdsp_init(DiracDSPContext *c);
-
-#endif /* AVCODEC_DIRACDSP_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/dsputil.c b/src/thirdparty/ffmpeg/libavcodec/dsputil.c
deleted file mode 100644
index daafcdfb7..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/dsputil.c
+++ /dev/null
@@ -1,2959 +0,0 @@
-/*
- * 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 "libavutil/imgutils.h"
-#include "libavutil/internal.h"
-#include "avcodec.h"
-#include "copy_block.h"
-#include "dct.h"
-#include "dsputil.h"
-#include "simple_idct.h"
-#include "faandct.h"
-#include "faanidct.h"
-#include "imgconvert.h"
-#include "mathops.h"
-#include "mpegvideo.h"
-#include "config.h"
-#include "diracdsp.h"
-
-uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP] = {0, };
-uint32_t ff_squareTbl[512] = {0, };
-
-#define BIT_DEPTH 9
-#include "dsputil_template.c"
-#undef BIT_DEPTH
-
-#define BIT_DEPTH 10
-#include "dsputil_template.c"
-#undef BIT_DEPTH
-
-#define BIT_DEPTH 12
-#include "dsputil_template.c"
-#undef BIT_DEPTH
-
-#define BIT_DEPTH 14
-#include "dsputil_template.c"
-#undef BIT_DEPTH
-
-#define BIT_DEPTH 8
-#include "dsputil_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)
-
-const uint8_t ff_zigzag_direct[64] = {
- 0, 1, 8, 16, 9, 2, 3, 10,
- 17, 24, 32, 25, 18, 11, 4, 5,
- 12, 19, 26, 33, 40, 48, 41, 34,
- 27, 20, 13, 6, 7, 14, 21, 28,
- 35, 42, 49, 56, 57, 50, 43, 36,
- 29, 22, 15, 23, 30, 37, 44, 51,
- 58, 59, 52, 45, 38, 31, 39, 46,
- 53, 60, 61, 54, 47, 55, 62, 63
-};
-
-/* 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,
-};
-
-/* not permutated inverse zigzag_direct + 1 for MMX quantizer */
-DECLARE_ALIGNED(16, uint16_t, ff_inv_zigzag_direct16)[64];
-
-const uint8_t ff_alternate_horizontal_scan[64] = {
- 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,
- 30, 31, 34, 35, 40, 41, 48, 49,
- 42, 43, 36, 37, 38, 39, 44, 45,
- 46, 47, 50, 51, 56, 57, 58, 59,
- 52, 53, 54, 55, 60, 61, 62, 63,
-};
-
-const uint8_t ff_alternate_vertical_scan[64] = {
- 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,
- 51, 59, 20, 28, 5, 13, 6, 14,
- 21, 29, 36, 44, 52, 60, 37, 45,
- 53, 61, 22, 30, 7, 15, 23, 31,
- 38, 46, 54, 62, 39, 47, 55, 63,
-};
-
-/* 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 idct_sse2_row_perm[8] = {0, 4, 1, 5, 2, 6, 3, 7};
-
-void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable){
- int i;
- int end;
-
- st->scantable= src_scantable;
-
- for(i=0; i<64; i++){
- int j;
- 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;
- }
-}
-
-void ff_init_scantable_permutation(uint8_t *idct_permutation,
- int idct_permutation_type)
-{
- int i;
-
- switch(idct_permutation_type){
- case FF_NO_IDCT_PERM:
- 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);
- break;
- case FF_SIMPLE_IDCT_PERM:
- 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);
- break;
- case FF_PARTTRANS_IDCT_PERM:
- 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];
- break;
- default:
- av_log(NULL, AV_LOG_ERROR, "Internal error, IDCT permutation not set\n");
- }
-}
-
-static int pix_sum_c(uint8_t * pix, int line_size)
-{
- int s, 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];
- pix += 8;
- }
- pix += line_size - 16;
- }
- return s;
-}
-
-static int pix_norm1_c(uint8_t * pix, int line_size)
-{
- int s, i, j;
- uint32_t *sq = ff_squareTbl + 256;
-
- s = 0;
- for (i = 0; i < 16; i++) {
- for (j = 0; j < 16; j += 8) {
-#if 0
- s += sq[pix[0]];
- s += sq[pix[1]];
- s += sq[pix[2]];
- s += sq[pix[3]];
- s += sq[pix[4]];
- s += sq[pix[5]];
- s += sq[pix[6]];
- 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];
-#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];
-#endif
-#endif
- pix += 8;
- }
- pix += line_size - 16;
- }
- return s;
-}
-
-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]);
- }
-}
-
-static void bswap16_buf(uint16_t *dst, const uint16_t *src, int len)
-{
- while (len--)
- *dst++ = av_bswap16(*src++);
-}
-
-static int sse4_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h)
-{
- int s, i;
- uint32_t *sq = ff_squareTbl + 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]];
- 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)
-{
- int s, i;
- uint32_t *sq = ff_squareTbl + 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]];
- 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)
-{
- int s, i;
- uint32_t *sq = ff_squareTbl + 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[10] - pix2[10]];
- s += sq[pix1[11] - pix2[11]];
- s += sq[pix1[12] - pix2[12]];
- s += sq[pix1[13] - pix2[13]];
- s += sq[pix1[14] - pix2[14]];
- s += sq[pix1[15] - pix2[15]];
-
- pix1 += line_size;
- pix2 += line_size;
- }
- return s;
-}
-
-static void diff_pixels_c(int16_t *av_restrict block, const uint8_t *s1,
- const uint8_t *s2, int stride){
- int i;
-
- /* read the pixels */
- for(i=0;i<8;i++) {
- block[0] = s1[0] - s2[0];
- block[1] = s1[1] - s2[1];
- block[2] = s1[2] - s2[2];
- block[3] = s1[3] - s2[3];
- block[4] = s1[4] - s2[4];
- block[5] = s1[5] - s2[5];
- block[6] = s1[6] - s2[6];
- block[7] = s1[7] - s2[7];
- s1 += stride;
- s2 += stride;
- block += 8;
- }
-}
-
-static void put_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels,
- int line_size)
-{
- int i;
-
- /* read the pixels */
- 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]);
- pixels[3] = av_clip_uint8(block[3]);
- pixels[4] = av_clip_uint8(block[4]);
- pixels[5] = av_clip_uint8(block[5]);
- pixels[6] = av_clip_uint8(block[6]);
- pixels[7] = av_clip_uint8(block[7]);
-
- pixels += line_size;
- block += 8;
- }
-}
-
-static void put_pixels_clamped4_c(const int16_t *block, uint8_t *av_restrict pixels,
- int line_size)
-{
- int i;
-
- /* read the pixels */
- for(i=0;i<4;i++) {
- pixels[0] = av_clip_uint8(block[0]);
- pixels[1] = av_clip_uint8(block[1]);
- pixels[2] = av_clip_uint8(block[2]);
- pixels[3] = av_clip_uint8(block[3]);
-
- pixels += line_size;
- block += 8;
- }
-}
-
-static void put_pixels_clamped2_c(const int16_t *block, uint8_t *av_restrict pixels,
- int line_size)
-{
- int i;
-
- /* read the pixels */
- for(i=0;i<2;i++) {
- pixels[0] = av_clip_uint8(block[0]);
- pixels[1] = av_clip_uint8(block[1]);
-
- pixels += line_size;
- block += 8;
- }
-}
-
-static void put_signed_pixels_clamped_c(const int16_t *block,
- uint8_t *av_restrict pixels,
- int line_size)
-{
- int i, j;
-
- for (i = 0; i < 8; i++) {
- for (j = 0; j < 8; j++) {
- if (*block < -128)
- *pixels = 0;
- else if (*block > 127)
- *pixels = 255;
- else
- *pixels = (uint8_t)(*block + 128);
- block++;
- pixels++;
- }
- pixels += (line_size - 8);
- }
-}
-
-static void add_pixels8_c(uint8_t *av_restrict pixels,
- int16_t *block,
- int line_size)
-{
- int i;
-
- for(i=0;i<8;i++) {
- pixels[0] += block[0];
- pixels[1] += block[1];
- pixels[2] += block[2];
- pixels[3] += block[3];
- pixels[4] += block[4];
- pixels[5] += block[5];
- pixels[6] += block[6];
- pixels[7] += block[7];
- pixels += line_size;
- block += 8;
- }
-}
-
-
-static void add_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels,
- int line_size)
-{
- int i;
-
- /* read the pixels */
- 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]);
- pixels[3] = av_clip_uint8(pixels[3] + block[3]);
- pixels[4] = av_clip_uint8(pixels[4] + block[4]);
- 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;
- }
-}
-
-static void add_pixels_clamped4_c(const int16_t *block, uint8_t *av_restrict pixels,
- int line_size)
-{
- int i;
-
- /* read the pixels */
- for(i=0;i<4;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]);
- pixels[3] = av_clip_uint8(pixels[3] + block[3]);
- pixels += line_size;
- block += 8;
- }
-}
-
-static void add_pixels_clamped2_c(const int16_t *block, uint8_t *av_restrict pixels,
- int line_size)
-{
- int i;
-
- /* read the pixels */
- for(i=0;i<2;i++) {
- pixels[0] = av_clip_uint8(pixels[0] + block[0]);
- pixels[1] = av_clip_uint8(pixels[1] + block[1]);
- pixels += line_size;
- block += 8;
- }
-}
-
-static int sum_abs_dctelem_c(int16_t *block)
-{
- int sum=0, i;
- for(i=0; i<64; i++)
- sum+= FFABS(block[i]);
- return sum;
-}
-
-static void fill_block16_c(uint8_t *block, uint8_t value, int line_size, int h)
-{
- int i;
-
- for (i = 0; i < h; i++) {
- memset(block, value, 16);
- block += line_size;
- }
-}
-
-static void fill_block8_c(uint8_t *block, uint8_t value, int line_size, int h)
-{
- int i;
-
- for (i = 0; i < h; i++) {
- memset(block, value, 8);
- block += line_size;
- }
-}
-
-#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)
-{
- 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;
- }
-}
-
-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 y, vx, vy;
- const int s= 1<<shift;
-
- width--;
- height--;
-
- 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);
- }
- }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;
- }
- 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){\
- 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;\
- 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){\
- 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){\
- 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, int 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, int stride){\
- OPNAME ## mpeg4_qpel8_h_lowpass(dst, src, stride, stride, 8);\
-}\
-\
-static void OPNAME ## qpel8_mc30_c(uint8_t *dst, uint8_t *src, int 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, int 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, int 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, int 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, int 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, int 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, int 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, int 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, int 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, int 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, int 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, int 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, int 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, int 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, int 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, int 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, int 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, int 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, int 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, int 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, int stride){\
- OPNAME ## mpeg4_qpel16_h_lowpass(dst, src, stride, stride, 16);\
-}\
-\
-static void OPNAME ## qpel16_mc30_c(uint8_t *dst, uint8_t *src, int 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, int 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, int 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, int 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, int 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, int 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, int 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, int 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, int 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, int 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, int 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, int 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, int 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, int 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, int 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, int 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, int 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, int 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, int 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)
-#undef op_avg
-#undef op_avg_no_rnd
-#undef op_put
-#undef op_put_no_rnd
-
-#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_8_c
-
-static void wmv2_mspel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){
- uint8_t *cm = ff_cropTbl + 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;
- }
-}
-
-#if CONFIG_RV40_DECODER
-void ff_put_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride){
- put_pixels16_xy2_8_c(dst, src, stride, 16);
-}
-void ff_avg_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride){
- avg_pixels16_xy2_8_c(dst, src, stride, 16);
-}
-void ff_put_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, int stride){
- put_pixels8_xy2_8_c(dst, src, stride, 8);
-}
-void ff_avg_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, int 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)\
-{\
- OPNAME ## _pixels8_8_c(dst, src[0], stride, h);\
-}\
-void ff_ ## OPNAME ## _dirac_pixels16_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
-{\
- OPNAME ## _pixels16_8_c(dst, src[0], stride, h);\
-}\
-void ff_ ## OPNAME ## _dirac_pixels32_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
-{\
- OPNAME ## _pixels16_8_c(dst , src[0] , stride, h);\
- OPNAME ## _pixels16_8_c(dst+16, src[0]+16, stride, h);\
-}\
-void ff_ ## OPNAME ## _dirac_pixels8_l2_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
-{\
- OPNAME ## _pixels8_l2_8(dst, src[0], src[1], stride, stride, stride, h);\
-}\
-void ff_ ## OPNAME ## _dirac_pixels16_l2_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
-{\
- OPNAME ## _pixels16_l2_8(dst, src[0], src[1], stride, stride, stride, h);\
-}\
-void ff_ ## OPNAME ## _dirac_pixels32_l2_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
-{\
- OPNAME ## _pixels16_l2_8(dst , src[0] , src[1] , stride, stride, stride, h);\
- OPNAME ## _pixels16_l2_8(dst+16, src[0]+16, src[1]+16, stride, stride, stride, h);\
-}\
-void ff_ ## OPNAME ## _dirac_pixels8_l4_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
-{\
- OPNAME ## _pixels8_l4_8(dst, src[0], src[1], src[2], src[3], stride, stride, stride, stride, stride, h);\
-}\
-void ff_ ## OPNAME ## _dirac_pixels16_l4_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
-{\
- OPNAME ## _pixels16_l4_8(dst, src[0], src[1], src[2], src[3], stride, stride, stride, stride, stride, h);\
-}\
-void ff_ ## OPNAME ## _dirac_pixels32_l4_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
-{\
- OPNAME ## _pixels16_l4_8(dst , src[0] , src[1] , src[2] , src[3] , stride, stride, stride, stride, stride, h);\
- OPNAME ## _pixels16_l4_8(dst+16, src[0]+16, src[1]+16, src[2]+16, src[3]+16, stride, stride, stride, stride, stride, h);\
-}
-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){
- uint8_t *cm = ff_cropTbl + 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];
- src++;
- dst++;
- }
-}
-
-static void put_mspel8_mc10_c(uint8_t *dst, uint8_t *src, int 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);
-}
-
-static void put_mspel8_mc20_c(uint8_t *dst, uint8_t *src, int stride){
- wmv2_mspel8_h_lowpass(dst, src, stride, stride, 8);
-}
-
-static void put_mspel8_mc30_c(uint8_t *dst, uint8_t *src, int 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);
-}
-
-static void put_mspel8_mc02_c(uint8_t *dst, uint8_t *src, int stride){
- wmv2_mspel8_v_lowpass(dst, src, stride, stride, 8);
-}
-
-static void put_mspel8_mc12_c(uint8_t *dst, uint8_t *src, int 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, 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_mc32_c(uint8_t *dst, uint8_t *src, int 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);
- put_pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8);
-}
-static void put_mspel8_mc22_c(uint8_t *dst, uint8_t *src, int 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 void h263_v_loop_filter_c(uint8_t *src, int stride, int qscale){
- if(CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
- int x;
- const int strength= ff_h263_loop_filter_strength[qscale];
-
- for(x=0; x<8; x++){
- int d1, d2, ad1;
- int p0= src[x-2*stride];
- int p1= src[x-1*stride];
- int p2= src[x+0*stride];
- int p3= src[x+1*stride];
- int d = (p0 - p3 + 4*(p2 - p1)) / 8;
-
- if (d<-2*strength) d1= 0;
- else if(d<- strength) d1=-2*strength - d;
- else if(d< strength) d1= d;
- else if(d< 2*strength) d1= 2*strength - d;
- else d1= 0;
-
- p1 += d1;
- p2 -= d1;
- if(p1&256) p1= ~(p1>>31);
- if(p2&256) p2= ~(p2>>31);
-
- src[x-1*stride] = p1;
- src[x+0*stride] = p2;
-
- ad1= FFABS(d1)>>1;
-
- d2= av_clip((p0-p3)/4, -ad1, ad1);
-
- src[x-2*stride] = p0 - d2;
- src[x+ stride] = p3 + d2;
- }
- }
-}
-
-static void h263_h_loop_filter_c(uint8_t *src, int stride, int qscale){
- if(CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
- int y;
- const int strength= ff_h263_loop_filter_strength[qscale];
-
- for(y=0; y<8; y++){
- int d1, d2, ad1;
- int p0= src[y*stride-2];
- int p1= src[y*stride-1];
- int p2= src[y*stride+0];
- int p3= src[y*stride+1];
- int d = (p0 - p3 + 4*(p2 - p1)) / 8;
-
- if (d<-2*strength) d1= 0;
- else if(d<- strength) d1=-2*strength - d;
- else if(d< strength) d1= d;
- else if(d< 2*strength) d1= 2*strength - d;
- else d1= 0;
-
- p1 += d1;
- p2 -= d1;
- if(p1&256) p1= ~(p1>>31);
- if(p2&256) p2= ~(p2>>31);
-
- src[y*stride-1] = p1;
- src[y*stride+0] = p2;
-
- ad1= FFABS(d1)>>1;
-
- d2= av_clip((p0-p3)/4, -ad1, ad1);
-
- src[y*stride-2] = p0 - d2;
- src[y*stride+1] = p3 + d2;
- }
- }
-}
-
-static void h261_loop_filter_c(uint8_t *src, int stride){
- int x,y,xy,yz;
- int temp[64];
-
- for(x=0; x<8; x++){
- temp[x ] = 4*src[x ];
- temp[x + 7*8] = 4*src[x + 7*stride];
- }
- for(y=1; y<7; y++){
- for(x=0; x<8; x++){
- xy = y * stride + x;
- yz = y * 8 + x;
- temp[yz] = src[xy - stride] + 2*src[xy] + src[xy + stride];
- }
- }
-
- for(y=0; y<8; y++){
- src[ y*stride] = (temp[ y*8] + 2)>>2;
- src[7+y*stride] = (temp[7+y*8] + 2)>>2;
- for(x=1; x<7; x++){
- xy = y * stride + x;
- yz = y * 8 + x;
- src[xy] = (temp[yz-1] + 2*temp[yz] + temp[yz+1] + 8)>>4;
- }
- }
-}
-
-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]);
- 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]));
- 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)
-{
- int s, 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]));
- pix1 += line_size;
- pix2 += line_size;
- pix3 += line_size;
- }
- return s;
-}
-
-static int pix_abs16_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
-{
- int s, 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]));
- pix1 += line_size;
- pix2 += line_size;
- pix3 += line_size;
- }
- return s;
-}
-
-static inline int pix_abs8_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]);
- 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)
-{
- 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]));
- 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)
-{
- int s, 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]));
- pix1 += line_size;
- pix2 += line_size;
- pix3 += line_size;
- }
- return s;
-}
-
-static int pix_abs8_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
-{
- int s, 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]));
- pix1 += line_size;
- pix2 += line_size;
- pix3 += 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]);
- }
- }
- s1+= stride;
- s2+= stride;
- }
-
- 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]);
- }
- }
- s1+= stride;
- s2+= stride;
- }
-
- 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){
- int i;
- 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);
-
- sum += (w*b)*(w*b)>>4;
- }
- return sum>>2;
-}
-
-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);
- }
-}
-
-static int zero_cmp(void *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){
- int i;
-
- memset(cmp, 0, sizeof(void*)*6);
-
- for(i=0; i<6; i++){
- switch(type&0xFF){
- case FF_CMP_SAD:
- cmp[i]= c->sad[i];
- break;
- case FF_CMP_SATD:
- cmp[i]= c->hadamard8_diff[i];
- break;
- case FF_CMP_SSE:
- cmp[i]= c->sse[i];
- break;
- case FF_CMP_DCT:
- cmp[i]= c->dct_sad[i];
- break;
- case FF_CMP_DCT264:
- cmp[i]= c->dct264_sad[i];
- break;
- case FF_CMP_DCTMAX:
- cmp[i]= c->dct_max[i];
- break;
- case FF_CMP_PSNR:
- cmp[i]= c->quant_psnr[i];
- break;
- case FF_CMP_BIT:
- cmp[i]= c->bit[i];
- break;
- case FF_CMP_RD:
- cmp[i]= c->rd[i];
- break;
- case FF_CMP_VSAD:
- cmp[i]= c->vsad[i];
- break;
- case FF_CMP_VSSE:
- cmp[i]= c->vsse[i];
- break;
- case FF_CMP_ZERO:
- cmp[i]= zero_cmp;
- break;
- case FF_CMP_NSSE:
- cmp[i]= c->nsse[i];
- break;
-#if CONFIG_DWT
- case FF_CMP_W53:
- cmp[i]= c->w53[i];
- break;
- case FF_CMP_W97:
- cmp[i]= c->w97[i];
- break;
-#endif
- default:
- 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){
- long i;
- for(i=0; i<=w-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];
-}
-
-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];
- }
- }else
-#endif
- for(i=0; i<=w-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];
-}
-
-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;
-
- 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;
-}
-
-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;
-
- 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;
-}
-
-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;
- i++;
- acc+= src[i];
- dst[i]= acc;
- }
-
- for(; i<w; i++){
- acc+= src[i];
- dst[i]= acc;
- }
-
- return acc;
-}
-
-#if HAVE_BIGENDIAN
-#define B 3
-#define G 2
-#define R 1
-#define A 0
-#else
-#define B 0
-#define G 1
-#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;
-
- 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;
- }
-
- *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 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;
-
- 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]-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]);
-
- 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]);
- }
- 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]);
-
- 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]);
-
- 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 -= 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;
- LOCAL_ALIGNED_16(int16_t, temp, [64]);
-
- av_assert2(h==8);
-
- s->dsp.diff_pixels(temp, src1, src2, stride);
- s->dsp.fdct(temp);
- return s->dsp.sum_abs_dctelem(temp);
-}
-
-#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;
- int16_t dct[8][8];
- int i;
- int 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++ )
- 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
-#undef SRC
-#undef DST
- 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;
- LOCAL_ALIGNED_16(int16_t, temp, [64]);
- int sum=0, i;
-
- 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]));
-
- 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;
-
- av_assert2(h==8);
- s->mb_intra=0;
-
- s->dsp.diff_pixels(temp, src1, src2, stride);
-
- 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->dct_unquantize_inter(s, temp, 0, s->qscale);
- ff_simple_idct_8(temp); //FIXME
-
- 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;
- 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;
-
- 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);
-
- 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
- } 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];
-
- 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(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);
- }
-
- s->dsp.idct_add(lsrc2, 8, temp);
-
- distortion= s->dsp.sse[1](NULL, lsrc2, lsrc1, 8, 8);
-
- 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;
- 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;
-
- 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);
-
- 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
- } 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];
-
- 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;
- }
-
- 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; \
-}
-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;
-
- 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; \
-}
-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;
-
- 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]);
- 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;\
-}
-
-WRAPPER8_16_SQ(hadamard8_diff8x8_c, hadamard8_diff16_c)
-WRAPPER8_16_SQ(hadamard8_intra8x8_c, hadamard8_intra16_c)
-WRAPPER8_16_SQ(dct_sad8x8_c, dct_sad16_c)
-#if CONFIG_GPL
-WRAPPER8_16_SQ(dct264_sad8x8_c, dct264_sad16_c)
-#endif
-WRAPPER8_16_SQ(dct_max8x8_c, dct_max16_c)
-WRAPPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c)
-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)
-{
-
- 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){
- 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) {
- 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);
- dsti[i + 3] = clipf_c_one(srci[i + 3], mini, maxi, maxisign);
- dsti[i + 4] = clipf_c_one(srci[i + 4], mini, maxi, maxisign);
- dsti[i + 5] = clipf_c_one(srci[i + 5], mini, maxi, maxisign);
- dsti[i + 6] = clipf_c_one(srci[i + 6], mini, maxi, maxisign);
- 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){
- int i;
- 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);
- 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);
- dst[i + 4] = av_clipf(src[i + 4], min, max);
- dst[i + 5] = av_clipf(src[i + 5], min, max);
- dst[i + 6] = av_clipf(src[i + 6], min, max);
- dst[i + 7] = av_clipf(src[i + 7], min, max);
- }
- }
-}
-
-static int32_t scalarproduct_int16_c(const int16_t * v1, const int16_t * v2, int order)
-{
- int res = 0;
-
- while (order--)
- 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)
-{
- int res = 0;
- while (order--) {
- res += *v1 * *v2++;
- *v1++ += mul * *v3++;
- }
- return res;
-}
-
-static void apply_window_int16_c(int16_t *output, const int16_t *input,
- const int16_t *window, unsigned int len)
-{
- int i;
- int len2 = len >> 1;
-
- for (i = 0; i < len2; i++) {
- int16_t w = window[i];
- output[i] = (MUL16(input[i], w) + (1 << 14)) >> 15;
- output[len-i-1] = (MUL16(input[len-i-1], w) + (1 << 14)) >> 15;
- }
-}
-
-static void vector_clip_int32_c(int32_t *dst, const int32_t *src, int32_t min,
- int32_t max, unsigned int len)
-{
- do {
- *dst++ = av_clip(*src++, min, max);
- *dst++ = av_clip(*src++, min, max);
- *dst++ = av_clip(*src++, min, max);
- *dst++ = av_clip(*src++, min, max);
- *dst++ = av_clip(*src++, min, max);
- *dst++ = av_clip(*src++, min, max);
- *dst++ = av_clip(*src++, min, max);
- *dst++ = av_clip(*src++, min, max);
- len -= 8;
- } while (len > 0);
-}
-
-static void ff_jref_idct_put(uint8_t *dest, int line_size, int16_t *block)
-{
- ff_j_rev_dct (block);
- put_pixels_clamped_c(block, dest, line_size);
-}
-static void ff_jref_idct_add(uint8_t *dest, int line_size, int16_t *block)
-{
- ff_j_rev_dct (block);
- add_pixels_clamped_c(block, dest, line_size);
-}
-
-static void ff_jref_idct4_put(uint8_t *dest, int line_size, int16_t *block)
-{
- ff_j_rev_dct4 (block);
- put_pixels_clamped4_c(block, dest, line_size);
-}
-static void ff_jref_idct4_add(uint8_t *dest, int line_size, int16_t *block)
-{
- ff_j_rev_dct4 (block);
- add_pixels_clamped4_c(block, dest, line_size);
-}
-
-static void ff_jref_idct2_put(uint8_t *dest, int line_size, int16_t *block)
-{
- ff_j_rev_dct2 (block);
- put_pixels_clamped2_c(block, dest, line_size);
-}
-static void ff_jref_idct2_add(uint8_t *dest, int line_size, int16_t *block)
-{
- ff_j_rev_dct2 (block);
- add_pixels_clamped2_c(block, dest, line_size);
-}
-
-static void ff_jref_idct1_put(uint8_t *dest, int line_size, int16_t *block)
-{
- dest[0] = av_clip_uint8((block[0] + 4)>>3);
-}
-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));
-}
-
-/* init static data */
-av_cold void ff_dsputil_static_init(void)
-{
- int i;
-
- for(i=0;i<256;i++) ff_cropTbl[i + MAX_NEG_CROP] = i;
- for(i=0;i<MAX_NEG_CROP;i++) {
- ff_cropTbl[i] = 0;
- ff_cropTbl[i + MAX_NEG_CROP + 256] = 255;
- }
-
- for(i=0;i<512;i++) {
- ff_squareTbl[i] = (i - 256) * (i - 256);
- }
-
- for(i=0; i<64; i++) ff_inv_zigzag_direct16[ff_zigzag_direct[i]]= i+1;
-}
-
-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 HAVE_MMX || HAVE_ALTIVEC
- av_log(NULL, AV_LOG_ERROR,
- "Compiler did not align stack variables. Libavcodec has been miscompiled\n"
- "and may be very slow or crash. This is not a bug in libavcodec,\n"
- "but in the compiler. You may try recompiling using gcc >= 4.2.\n"
- "Do not report crashes to FFmpeg developers.\n");
-#endif
- did_fail=1;
- }
- return -1;
- }
- return 0;
-}
-
-av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx)
-{
- ff_check_alignment();
-
-#if CONFIG_ENCODERS
- if (avctx->bits_per_raw_sample == 10) {
- c->fdct = ff_jpeg_fdct_islow_10;
- c->fdct248 = ff_fdct248_islow_10;
- } else {
- 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) {
- c->fdct = ff_faandct;
- c->fdct248 = ff_faandct248;
- }
- 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{
- if (avctx->bits_per_raw_sample == 10) {
- c->idct_put = ff_simple_idct_put_10;
- c->idct_add = ff_simple_idct_add_10;
- c->idct = ff_simple_idct_10;
- c->idct_permutation_type = FF_NO_IDCT_PERM;
- } else {
- if(avctx->idct_algo==FF_IDCT_INT){
- c->idct_put= ff_jref_idct_put;
- c->idct_add= ff_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_signed_pixels_clamped = put_signed_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->pix_norm1 = pix_norm1_c;
-
- c->fill_block_tab[0] = fill_block16_c;
- c->fill_block_tab[1] = fill_block8_c;
-
- /* TODO [0] 16 [1] 8 */
- c->pix_abs[0][0] = pix_abs16_c;
- c->pix_abs[0][1] = pix_abs16_x2_c;
- c->pix_abs[0][2] = pix_abs16_y2_c;
- c->pix_abs[0][3] = pix_abs16_xy2_c;
- c->pix_abs[1][0] = pix_abs8_c;
- c->pix_abs[1][1] = pix_abs8_x2_c;
- 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; \
- 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; \
- c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_c; \
- c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_c; \
- 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, 1, 8);
-
- 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;
-
-#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;
- 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;
- 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;
-#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_hfyu_left_prediction_bgr32 = add_hfyu_left_prediction_bgr32_c;
- c->bswap_buf= bswap_buf;
- c->bswap16_buf = bswap16_buf;
-
- if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
- c->h263_h_loop_filter= h263_h_loop_filter_c;
- c->h263_v_loop_filter= h263_v_loop_filter_c;
- }
-
- c->h261_loop_filter= h261_loop_filter_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->apply_window_int16 = apply_window_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->add_pixels8 = add_pixels8_c;
-
-#define hpel_funcs(prefix, idx, num) \
- c->prefix ## _pixels_tab idx [0] = prefix ## _pixels ## num ## _8_c; \
- c->prefix ## _pixels_tab idx [1] = prefix ## _pixels ## num ## _x2_8_c; \
- c->prefix ## _pixels_tab idx [2] = prefix ## _pixels ## num ## _y2_8_c; \
- c->prefix ## _pixels_tab idx [3] = prefix ## _pixels ## num ## _xy2_8_c
-
- hpel_funcs(put, [0], 16);
- hpel_funcs(put, [1], 8);
- hpel_funcs(put, [2], 4);
- hpel_funcs(put, [3], 2);
- hpel_funcs(put_no_rnd, [0], 16);
- hpel_funcs(put_no_rnd, [1], 8);
- hpel_funcs(avg, [0], 16);
- hpel_funcs(avg, [1], 8);
- hpel_funcs(avg, [2], 4);
- hpel_funcs(avg, [3], 2);
- hpel_funcs(avg_no_rnd,, 16);
-
-#undef FUNC
-#undef FUNCC
-#define FUNC(f, depth) f ## _ ## depth
-#define FUNCC(f, depth) f ## _ ## depth ## _c
-
-#define BIT_DEPTH_FUNCS(depth, dct)\
- c->get_pixels = FUNCC(get_pixels ## dct , depth);\
- c->draw_edges = FUNCC(draw_edges , depth);\
- c->clear_block = FUNCC(clear_block ## dct , depth);\
- c->clear_blocks = FUNCC(clear_blocks ## dct , depth)
-
- switch (avctx->bits_per_raw_sample) {
- case 9:
- if (c->dct_bits == 32) {
- BIT_DEPTH_FUNCS(9, _32);
- } else {
- BIT_DEPTH_FUNCS(9, _16);
- }
- break;
- case 10:
- if (c->dct_bits == 32) {
- BIT_DEPTH_FUNCS(10, _32);
- } else {
- BIT_DEPTH_FUNCS(10, _16);
- }
- break;
- case 12:
- if (c->dct_bits == 32) {
- BIT_DEPTH_FUNCS(12, _32);
- } else {
- BIT_DEPTH_FUNCS(12, _16);
- }
- break;
- case 14:
- if (c->dct_bits == 32) {
- BIT_DEPTH_FUNCS(14, _32);
- } else {
- BIT_DEPTH_FUNCS(14, _16);
- }
- break;
- default:
- if(avctx->bits_per_raw_sample<=8 || avctx->codec_type != AVMEDIA_TYPE_VIDEO) {
- BIT_DEPTH_FUNCS(8, _16);
- }
- break;
- }
-
-
- if (HAVE_MMX) ff_dsputil_init_mmx (c, avctx);
- if (ARCH_ARM) ff_dsputil_init_arm (c, avctx);
- if (HAVE_VIS) ff_dsputil_init_vis (c, avctx);
- if (ARCH_ALPHA) ff_dsputil_init_alpha (c, avctx);
- if (ARCH_PPC) ff_dsputil_init_ppc (c, avctx);
- if (ARCH_SH4) ff_dsputil_init_sh4 (c, avctx);
- if (ARCH_BFIN) ff_dsputil_init_bfin (c, avctx);
-
- ff_init_scantable_permutation(c->idct_permutation,
- c->idct_permutation_type);
-}
-
-av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
-{
- ff_dsputil_init(c, avctx);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/dsputil.h b/src/thirdparty/ffmpeg/libavcodec/dsputil.h
deleted file mode 100644
index 2b1cdfd63..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/dsputil.h
+++ /dev/null
@@ -1,407 +0,0 @@
-/*
- * DSP utils
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
- * Copyright (c) 2002-2004 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.
- * 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"
-
-
-//#define DEBUG
-
-/* 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 uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP];
-
-#define PUTAVG_PIXELS(depth)\
-void ff_put_pixels8x8_ ## depth ## _c(uint8_t *dst, uint8_t *src, int stride);\
-void ff_avg_pixels8x8_ ## depth ## _c(uint8_t *dst, uint8_t *src, int stride);\
-void ff_put_pixels16x16_ ## depth ## _c(uint8_t *dst, uint8_t *src, int stride);\
-void ff_avg_pixels16x16_ ## depth ## _c(uint8_t *dst, uint8_t *src, int stride);
-
-PUTAVG_PIXELS( 8)
-PUTAVG_PIXELS( 9)
-PUTAVG_PIXELS(10)
-PUTAVG_PIXELS(12)
-PUTAVG_PIXELS(14)
-
-#define ff_put_pixels8x8_c ff_put_pixels8x8_8_c
-#define ff_avg_pixels8x8_c ff_avg_pixels8x8_8_c
-#define ff_put_pixels16x16_c ff_put_pixels16x16_8_c
-#define ff_avg_pixels16x16_c ff_avg_pixels16x16_8_c
-
-/* RV40 functions */
-void ff_put_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride);
-void ff_avg_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride);
-void ff_put_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, int stride);
-void ff_avg_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, int 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);
-
-/* 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
-*/
-
-/* 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 (*op_pixels_func)(uint8_t *block/*align width (8 or 16)*/, const uint8_t *pixels/*align 1*/, ptrdiff_t line_size, int h);
-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*/, int stride);
-
-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*/, int stride);\
-void ff_put_no_rnd_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);\
-void ff_avg_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);
-
-DEF_OLD_QPEL(qpel16_mc11_old_c)
-DEF_OLD_QPEL(qpel16_mc31_old_c)
-DEF_OLD_QPEL(qpel16_mc12_old_c)
-DEF_OLD_QPEL(qpel16_mc32_old_c)
-DEF_OLD_QPEL(qpel16_mc13_old_c)
-DEF_OLD_QPEL(qpel16_mc33_old_c)
-DEF_OLD_QPEL(qpel8_mc11_old_c)
-DEF_OLD_QPEL(qpel8_mc31_old_c)
-DEF_OLD_QPEL(qpel8_mc12_old_c)
-DEF_OLD_QPEL(qpel8_mc32_old_c)
-DEF_OLD_QPEL(qpel8_mc13_old_c)
-DEF_OLD_QPEL(qpel8_mc33_old_c)
-
-#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);\
-}
-
-/* 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))*/;
-
-/**
- * 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_permutation(uint8_t *idct_permutation,
- int idct_permutation_type);
-
-/**
- * DSPContext.
- */
-typedef struct DSPContext {
- /**
- * Size of DCT coefficients.
- */
- int dct_bits;
-
- /* 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 (*add_pixels8)(uint8_t *pixels, int16_t *block, int line_size);
- 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);
- /**
- * 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
-
- me_cmp_func sad[6]; /* identical to pix_absAxA except additional void * */
- me_cmp_func sse[6];
- me_cmp_func hadamard8_diff[6];
- me_cmp_func dct_sad[6];
- me_cmp_func quant_psnr[6];
- me_cmp_func bit[6];
- me_cmp_func rd[6];
- me_cmp_func vsad[6];
- me_cmp_func vsse[6];
- me_cmp_func nsse[6];
- me_cmp_func w53[6];
- me_cmp_func w97[6];
- me_cmp_func dct_max[6];
- me_cmp_func dct264_sad[6];
-
- me_cmp_func me_pre_cmp[6];
- 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
-
- int (*ssd_int8_vs_int16)(const int8_t *pix1, const int16_t *pix2,
- int size);
-
- /**
- * Halfpel motion compensation with rounding (a+b+1)>>1.
- * this is an array[4][4] of motion compensation functions for 4
- * horizontal blocksizes (8,16) and the 4 halfpel positions<br>
- * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
- * @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
- */
- op_pixels_func put_pixels_tab[4][4];
-
- /**
- * Halfpel motion compensation with rounding (a+b+1)>>1.
- * This is an array[4][4] of motion compensation functions for 4
- * horizontal blocksizes (8,16) and the 4 halfpel positions<br>
- * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
- * @param block destination into which the result is averaged (a+b+1)>>1
- * @param pixels source
- * @param line_size number of bytes in a horizontal line of block
- * @param h height
- */
- op_pixels_func avg_pixels_tab[4][4];
-
- /**
- * Halfpel motion compensation with no rounding (a+b)>>1.
- * this is an array[2][4] of motion compensation functions for 2
- * horizontal blocksizes (8,16) and the 4 halfpel positions<br>
- * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ]
- * @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
- */
- op_pixels_func put_no_rnd_pixels_tab[4][4];
-
- /**
- * Halfpel motion compensation with no rounding (a+b)>>1.
- * this is an array[4] of motion compensation functions for 1
- * horizontal blocksize (16) and the 4 halfpel positions<br>
- * *pixels_tab[0][ xhalfpel + 2*yhalfpel ]
- * @param block destination into which the result is averaged (a+b)>>1
- * @param pixels source
- * @param line_size number of bytes in a horizontal line of block
- * @param h height
- */
- op_pixels_func avg_no_rnd_pixels_tab[4];
-
- /**
- * 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];
- qpel_mc_func put_mspel_pixels_tab[8];
-
- 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);
- /**
- * 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);
- /* 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);
-
- void (*h263_v_loop_filter)(uint8_t *src, int stride, int qscale);
- void (*h263_h_loop_filter)(uint8_t *src, int stride, int qscale);
-
- void (*h261_loop_filter)(uint8_t *src, int stride);
-
- /* 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 */);
-
- /* (I)DCT */
- void (*fdct)(int16_t *block/* align 16*/);
- void (*fdct248)(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*/);
-
- /**
- * 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*/);
-
- /**
- * 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;
-#define FF_NO_IDCT_PERM 1
-#define FF_LIBMPEG2_IDCT_PERM 2
-#define FF_SIMPLE_IDCT_PERM 3
-#define FF_TRANSPOSE_IDCT_PERM 4
-#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);
- 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);
-#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);
-
- /**
- * 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);
- /* 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);
-
- /**
- * Apply symmetric window in 16-bit fixed-point.
- * @param output destination array
- * constraints: 16-byte aligned
- * @param input source array
- * constraints: 16-byte aligned
- * @param window window array
- * constraints: 16-byte aligned, at least len/2 elements
- * @param len full window length
- * constraints: multiple of ? greater than zero
- */
- void (*apply_window_int16)(int16_t *output, const int16_t *input,
- const int16_t *window, unsigned int len);
-
- /**
- * 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
- * constraints: 16-byte aligned
- * @param min minimum value
- * constraints: must be in the range [-(1 << 24), 1 << 24]
- * @param max maximum value
- * constraints: must be in the range [-(1 << 24), 1 << 24]
- * @param len number of elements in the array
- * constraints: multiple of 32 greater than zero
- */
- void (*vector_clip_int32)(int32_t *dst, const int32_t *src, int32_t min,
- int32_t max, unsigned int len);
-
- op_fill_func fill_block_tab[2];
-} DSPContext;
-
-void ff_dsputil_static_init(void);
-void ff_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_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_mmx(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_dwt(DSPContext *c);
-
-#endif /* AVCODEC_DSPUTIL_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/dsputil_template.c b/src/thirdparty/ffmpeg/libavcodec/dsputil_template.c
deleted file mode 100644
index f9577cbb6..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/dsputil_template.c
+++ /dev/null
@@ -1,436 +0,0 @@
-/*
- * 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"
-
-/* 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++) {
-#if BIT_DEPTH > 8
- int j;
- for (j = 0; j < w; j++) {
- ptr[j-w] = ptr[0];
- ptr[j+width] = ptr[width-1];
- }
-#else
- memset(ptr - w, ptr[0], w);
- memset(ptr + width, ptr[width-1], w);
-#endif
- 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
-}
-
-#define DCTELEM_FUNCS(dctcoef, suffix) \
-static void FUNCC(get_pixels ## suffix)(int16_t *av_restrict _block, \
- const uint8_t *_pixels, \
- int line_size) \
-{ \
- const pixel *pixels = (const pixel *) _pixels; \
- dctcoef *av_restrict block = (dctcoef *) _block; \
- 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; \
- } \
-} \
- \
-static void FUNCC(clear_block ## suffix)(int16_t *block) \
-{ \
- memset(block, 0, sizeof(dctcoef)*64); \
-} \
- \
-/** \
- * memset(blocks, 0, sizeof(int16_t)*6*64) \
- */ \
-static void FUNCC(clear_blocks ## suffix)(int16_t *blocks) \
-{ \
- memset(blocks, 0, sizeof(dctcoef)*6*64); \
-}
-
-DCTELEM_FUNCS(int16_t, _16)
-#if BIT_DEPTH > 8
-DCTELEM_FUNCS(dctcoef, _32)
-#endif
-
-#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 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 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 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 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 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 ## _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
-
-void FUNCC(ff_put_pixels8x8)(uint8_t *dst, uint8_t *src, int stride) {
- FUNCC(put_pixels8)(dst, src, stride, 8);
-}
-void FUNCC(ff_avg_pixels8x8)(uint8_t *dst, uint8_t *src, int stride) {
- FUNCC(avg_pixels8)(dst, src, stride, 8);
-}
-void FUNCC(ff_put_pixels16x16)(uint8_t *dst, uint8_t *src, int stride) {
- FUNCC(put_pixels16)(dst, src, stride, 16);
-}
-void FUNCC(ff_avg_pixels16x16)(uint8_t *dst, uint8_t *src, int stride) {
- FUNCC(avg_pixels16)(dst, src, stride, 16);
-}
-
diff --git a/src/thirdparty/ffmpeg/libavcodec/dxva.h b/src/thirdparty/ffmpeg/libavcodec/dxva.h
deleted file mode 100644
index c752c1ade..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/dxva.h
+++ /dev/null
@@ -1,1966 +0,0 @@
-//------------------------------------------------------------------------------
-// File: DXVA.h
-//
-// Desc: DirectX Video Acceleration header file.
-//
-// Copyright (c) 1999 - 2002, Microsoft Corporation. All rights reserved.
-//------------------------------------------------------------------------------
-
-
-#ifndef __DIRECTX_VA__
-#define __DIRECTX_VA__
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1200)
-#pragma warning(push)
-#endif
-
-#pragma warning(disable:4201) // named type definition in parentheses
-#if defined(__INTEL_COMPILER)
-#pragma warning(disable:272) // warning #272: bit field cannot contain all values of the enumerated type
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef __DIRECTX_VA_COPP_ONLY
-#define __DIRECTX_VA_DECODER__
-#define __DIRECTX_VA_PROCAMPCONTROL__
-#define __DIRECTX_VA_DEINTERLACE__
-#endif
-
-#ifndef DXVABit
-#define DXVABit(__x) (1 << __x)
-#endif
-
-// -------------------------------------------------------------------------
-//
-// The definitions that follow describe the DirectX Video Acceleration
-// decoding interface.
-// This interface is accessable via the IAMVideoAccelerator interface.
-//
-// -------------------------------------------------------------------------
-//
-#ifndef __DIRECTX_VA_DECODER__
-#define __DIRECTX_VA_DECODER__
-
-DEFINE_GUID(DXVA_ModeNone, 0x1b81be00, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-DEFINE_GUID(DXVA_ModeH261_A, 0x1b81be01, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-DEFINE_GUID(DXVA_ModeH261_B, 0x1b81be02, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-
-DEFINE_GUID(DXVA_ModeH263_A, 0x1b81be03, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-DEFINE_GUID(DXVA_ModeH263_B, 0x1b81be04, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-DEFINE_GUID(DXVA_ModeH263_C, 0x1b81be05, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-DEFINE_GUID(DXVA_ModeH263_D, 0x1b81be06, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-DEFINE_GUID(DXVA_ModeH263_E, 0x1b81be07, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-DEFINE_GUID(DXVA_ModeH263_F, 0x1b81be08, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-
-DEFINE_GUID(DXVA_ModeMPEG1_A, 0x1b81be09, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-
-DEFINE_GUID(DXVA_ModeMPEG2_A, 0x1b81be0A, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-DEFINE_GUID(DXVA_ModeMPEG2_B, 0x1b81be0B, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-DEFINE_GUID(DXVA_ModeMPEG2_C, 0x1b81be0C, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-DEFINE_GUID(DXVA_ModeMPEG2_D, 0x1b81be0D, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-
-DEFINE_GUID(DXVA_ModeH264_A, 0x1b81be64, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-DEFINE_GUID(DXVA_ModeH264_B, 0x1b81be65, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-DEFINE_GUID(DXVA_ModeH264_C, 0x1b81be66, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-DEFINE_GUID(DXVA_ModeH264_D, 0x1b81be67, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-DEFINE_GUID(DXVA_ModeH264_E, 0x1b81be68, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-DEFINE_GUID(DXVA_ModeH264_F, 0x1b81be69, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-
-DEFINE_GUID(DXVA_ModeWMV8_A, 0x1b81be80, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-DEFINE_GUID(DXVA_ModeWMV8_B, 0x1b81be81, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-
-DEFINE_GUID(DXVA_ModeWMV9_A, 0x1b81be90, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-DEFINE_GUID(DXVA_ModeWMV9_B, 0x1b81be91, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-DEFINE_GUID(DXVA_ModeWMV9_C, 0x1b81be94, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-
-DEFINE_GUID(DXVA_ModeVC1_A, 0x1b81beA0, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-DEFINE_GUID(DXVA_ModeVC1_B, 0x1b81beA1, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-DEFINE_GUID(DXVA_ModeVC1_C, 0x1b81beA2, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-DEFINE_GUID(DXVA_ModeVC1_D, 0x1b81beA3, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-
-DEFINE_GUID(DXVA_NoEncrypt, 0x1b81beD0, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5);
-
-#define DXVA_ModeWMV8_PostProc DXVA_ModeWMV8_A
-#define DXVA_ModeWMV8_MoComp DXVA_ModeWMV8_B
-
-#define DXVA_ModeWMV9_PostProc DXVA_ModeWMV9_A
-#define DXVA_ModeWMV9_MoComp DXVA_ModeWMV9_B
-#define DXVA_ModeWMV9_IDCT DXVA_ModeWMV9_C
-
-#define DXVA_ModeVC1_PostProc DXVA_ModeVC1_A
-#define DXVA_ModeVC1_MoComp DXVA_ModeVC1_B
-#define DXVA_ModeVC1_IDCT DXVA_ModeVC1_C
-#define DXVA_ModeVC1_VLD DXVA_ModeVC1_D
-
-#define DXVA_ModeH264_MoComp_NoFGT DXVA_ModeH264_A
-#define DXVA_ModeH264_MoComp_FGT DXVA_ModeH264_B
-#define DXVA_ModeH264_IDCT_NoFGT DXVA_ModeH264_C
-#define DXVA_ModeH264_IDCT_FGT DXVA_ModeH264_D
-#define DXVA_ModeH264_VLD_NoFGT DXVA_ModeH264_E
-#define DXVA_ModeH264_VLD_FGT DXVA_ModeH264_F
-
-#define DXVA_RESTRICTED_MODE_UNRESTRICTED 0xFFFF
-#define DXVA_RESTRICTED_MODE_H261_A 1
-#define DXVA_RESTRICTED_MODE_H261_B 2
-
-#define DXVA_RESTRICTED_MODE_H263_A 3
-#define DXVA_RESTRICTED_MODE_H263_B 4
-#define DXVA_RESTRICTED_MODE_H263_C 5
-#define DXVA_RESTRICTED_MODE_H263_D 6
-#define DXVA_RESTRICTED_MODE_H263_E 7
-#define DXVA_RESTRICTED_MODE_H263_F 8
-
-#define DXVA_RESTRICTED_MODE_MPEG1_A 9
-
-#define DXVA_RESTRICTED_MODE_MPEG2_A 0xA
-#define DXVA_RESTRICTED_MODE_MPEG2_B 0xB
-#define DXVA_RESTRICTED_MODE_MPEG2_C 0xC
-#define DXVA_RESTRICTED_MODE_MPEG2_D 0xD
-
-#define DXVA_RESTRICTED_MODE_H264_A 0x64
-#define DXVA_RESTRICTED_MODE_H264_B 0x65
-#define DXVA_RESTRICTED_MODE_H264_C 0x66
-#define DXVA_RESTRICTED_MODE_H264_D 0x67
-#define DXVA_RESTRICTED_MODE_H264_E 0x68
-#define DXVA_RESTRICTED_MODE_H264_F 0x69
-
-#define DXVA_RESTRICTED_MODE_WMV8_A 0x80
-#define DXVA_RESTRICTED_MODE_WMV8_B 0x81
-
-#define DXVA_RESTRICTED_MODE_WMV9_A 0x90
-#define DXVA_RESTRICTED_MODE_WMV9_B 0x91
-#define DXVA_RESTRICTED_MODE_WMV9_C 0x94
-
-#define DXVA_RESTRICTED_MODE_VC1_A 0xA0
-#define DXVA_RESTRICTED_MODE_VC1_B 0xA1
-#define DXVA_RESTRICTED_MODE_VC1_C 0xA2
-#define DXVA_RESTRICTED_MODE_VC1_D 0xA3
-
-#define DXVA_RESTRICTED_MODE_WMV8_POSTPROC DXVA_RESTRICTED_MODE_WMV8_A
-#define DXVA_RESTRICTED_MODE_WMV8_MOCOMP DXVA_RESTRICTED_MODE_WMV8_B
-
-#define DXVA_RESTRICTED_MODE_WMV9_POSTPROC DXVA_RESTRICTED_MODE_WMV9_A
-#define DXVA_RESTRICTED_MODE_WMV9_MOCOMP DXVA_RESTRICTED_MODE_WMV9_B
-#define DXVA_RESTRICTED_MODE_WMV9_IDCT DXVA_RESTRICTED_MODE_WMV9_C
-
-#define DXVA_RESTRICTED_MODE_VC1_POSTPROC DXVA_RESTRICTED_MODE_VC1_A
-#define DXVA_RESTRICTED_MODE_VC1_MOCOMP DXVA_RESTRICTED_MODE_VC1_B
-#define DXVA_RESTRICTED_MODE_VC1_IDCT DXVA_RESTRICTED_MODE_VC1_C
-#define DXVA_RESTRICTED_MODE_VC1_VLD DXVA_RESTRICTED_MODE_VC1_D
-
-#define DXVA_RESTRICTED_MODE_H264_MOCOMP_NOFGT DXVA_RESTRICTED_MODE_H264_A
-#define DXVA_RESTRICTED_MODE_H264_MOCOMP_FGT DXVA_RESTRICTED_MODE_H264_B
-#define DXVA_RESTRICTED_MODE_H264_IDCT_NOFGT DXVA_RESTRICTED_MODE_H264_C
-#define DXVA_RESTRICTED_MODE_H264_IDCT_FGT DXVA_RESTRICTED_MODE_H264_D
-#define DXVA_RESTRICTED_MODE_H264_VLD_NOFGT DXVA_RESTRICTED_MODE_H264_E
-#define DXVA_RESTRICTED_MODE_H264_VLD_FGT DXVA_RESTRICTED_MODE_H264_F
-
-#define DXVA_COMPBUFFER_TYPE_THAT_IS_NOT_USED 0
-#define DXVA_PICTURE_DECODE_BUFFER 1
-#define DXVA_MACROBLOCK_CONTROL_BUFFER 2
-#define DXVA_RESIDUAL_DIFFERENCE_BUFFER 3
-#define DXVA_DEBLOCKING_CONTROL_BUFFER 4
-#define DXVA_INVERSE_QUANTIZATION_MATRIX_BUFFER 5
-#define DXVA_SLICE_CONTROL_BUFFER 6
-#define DXVA_BITSTREAM_DATA_BUFFER 7
-#define DXVA_AYUV_BUFFER 8
-#define DXVA_IA44_SURFACE_BUFFER 9
-#define DXVA_DPXD_SURFACE_BUFFER 10
-#define DXVA_HIGHLIGHT_BUFFER 11
-#define DXVA_DCCMD_SURFACE_BUFFER 12
-#define DXVA_ALPHA_BLEND_COMBINATION_BUFFER 13
-#define DXVA_PICTURE_RESAMPLE_BUFFER 14
-#define DXVA_READ_BACK_BUFFER 15
-
-/* H.264/AVC Additional buffer types */
-#define DXVA_MOTION_VECTOR_BUFFER 16
-#define DXVA_FILM_GRAIN_BUFFER 17
-
-#define DXVA_NUM_TYPES_COMP_BUFFERS 18
-
-/* values for bDXVA_Func */
-#define DXVA_PICTURE_DECODING_FUNCTION 1
-#define DXVA_ALPHA_BLEND_DATA_LOAD_FUNCTION 2
-#define DXVA_ALPHA_BLEND_COMBINATION_FUNCTION 3
-#define DXVA_PICTURE_RESAMPLE_FUNCTION 4
-#define DXVA_DEBLOCKING_FILTER_FUNCTION 5
-#define DXVA_FILM_GRAIN_SYNTHESIS_FUNCTION 6
-#define DXVA_STATUS_REPORTING_FUNCTION 7
-
-/* values returned from Execute command in absence of read-back */
-#define DXVA_EXECUTE_RETURN_OK 0
-#define DXVA_EXECUTE_RETURN_DATA_ERROR_MINOR 1
-#define DXVA_EXECUTE_RETURN_DATA_ERROR_SIGNIF 2
-#define DXVA_EXECUTE_RETURN_DATA_ERROR_SEVERE 3
-#define DXVA_EXECUTE_RETURN_OTHER_ERROR_SEVERE 4
-
-
-#pragma pack(push, BeforeDXVApacking, 1)
-
-
-typedef struct _DXVA_ConnectMode {
- GUID guidMode;
- WORD wRestrictedMode;
-} DXVA_ConnectMode, *LPDXVA_ConnectMode;
-
-
-typedef DWORD DXVA_ConfigQueryOrReplyFunc, *LPDXVA_ConfigQueryOrReplyFunc;
-
-#define DXVA_QUERYORREPLYFUNCFLAG_DECODER_PROBE_QUERY 0xFFFFF1
-#define DXVA_QUERYORREPLYFUNCFLAG_DECODER_LOCK_QUERY 0xFFFFF5
-#define DXVA_QUERYORREPLYFUNCFLAG_ACCEL_PROBE_OK_COPY 0xFFFFF8
-#define DXVA_QUERYORREPLYFUNCFLAG_ACCEL_PROBE_OK_PLUS 0xFFFFF9
-#define DXVA_QUERYORREPLYFUNCFLAG_ACCEL_LOCK_OK_COPY 0xFFFFFC
-#define DXVA_QUERYORREPLYFUNCFLAG_ACCEL_PROBE_FALSE_PLUS 0xFFFFFB
-#define DXVA_QUERYORREPLYFUNCFLAG_ACCEL_LOCK_FALSE_PLUS 0xFFFFFF
-
-#define readDXVA_QueryOrReplyFuncFlag(ptr) ((*(ptr)) >> 8)
-
-#define readDXVA_QueryOrReplyFuncFlag_ACCEL(ptr) (((*(ptr)) >> 11) & 1)
-#define readDXVA_QueryOrReplyFuncFlag_LOCK(ptr) (((*(ptr)) >> 10) & 1)
-#define readDXVA_QueryOrReplyFuncFlag_BAD(ptr) (((*(ptr)) >> 9) & 1)
-#define readDXVA_QueryOrReplyFuncFlag_PLUS(ptr) (((*(ptr)) >> 8) & 1)
-
-#define readDXVA_QueryOrReplyFuncFunc(ptr) ((*(ptr)) & 0xFF)
-
-#define writeDXVA_QueryOrReplyFunc(ptr, flg, fnc) ((*(ptr)) = ((flg) << 8) | (fnc))
-
-#define setDXVA_QueryOrReplyFuncFlag(ptr, flg) ((*(ptr)) |= ((flg) << 8))
-#define setDXVA_QueryOrReplyFuncFunc(ptr, fnc) ((*(ptr)) |= (fnc));
-
-typedef DWORD DXVA_EncryptProtocolFunc, *LPDXVA_EncryptProtocolFunc;
-
-#define DXVA_ENCRYPTPROTOCOLFUNCFLAG_HOST 0xFFFF00
-#define DXVA_ENCRYPTPROTOCOLFUNCFLAG_ACCEL 0xFFFF08
-
-#define readDXVA_EncryptProtocolFuncFlag(ptr) ((*(ptr)) >> 8)
-#define readDXVA_EncryptProtocolFuncFlag_ACCEL(ptr) (((*(ptr)) >> 11) & 1)
-
-#define readDXVA_EncryptProtocolFuncFunc(ptr) ((*(ptr)) & 0xFF)
-
-#define writeDXVA_EncryptProtocolFunc(ptr, flg, fnc) ((*(ptr)) = ((flg) << 8) | (fnc))
-
-#define setDXVA_EncryptProtocolFuncFlag(ptr, flg) ((*(ptr)) |= ((flg) << 8))
-#define setDXVA_EncryptProtocolFuncFunc(ptr, fnc) ((*(ptr)) |= (fnc));
-
-typedef struct _DXVA_EncryptProtocolHeader {
- DXVA_EncryptProtocolFunc dwFunction;
- DWORD ReservedBits[3];
- GUID guidEncryptProtocol;
-} DXVA_EncryptProtocolHeader, *LPDXVA_EncryptProtocolHeader;
-
-typedef struct _DXVA_ConfigPictureDecode {
-
- // Operation Indicated
- DXVA_ConfigQueryOrReplyFunc dwFunction;
-
- // Alignment
- DWORD dwReservedBits[3];
-
- // Encryption GUIDs
- GUID guidConfigBitstreamEncryption;
- GUID guidConfigMBcontrolEncryption;
- GUID guidConfigResidDiffEncryption;
-
- // Bitstream Processing Indicator
- BYTE bConfigBitstreamRaw;
-
- // Macroblock Control Config
- BYTE bConfigMBcontrolRasterOrder;
-
- // Host Resid Diff Config
- BYTE bConfigResidDiffHost;
- BYTE bConfigSpatialResid8;
- BYTE bConfigResid8Subtraction;
- BYTE bConfigSpatialHost8or9Clipping;
- BYTE bConfigSpatialResidInterleaved;
- BYTE bConfigIntraResidUnsigned;
-
- // Accelerator Resid Diff Config
- BYTE bConfigResidDiffAccelerator;
- BYTE bConfigHostInverseScan;
- BYTE bConfigSpecificIDCT;
- BYTE bConfig4GroupedCoefs;
-} DXVA_ConfigPictureDecode, *LPDXVA_ConfigPictureDecode;
-
-
-/* Picture Decoding Parameters */
-
-typedef struct _DXVA_PictureParameters {
-
- WORD wDecodedPictureIndex;
- WORD wDeblockedPictureIndex;
-
- WORD wForwardRefPictureIndex;
- WORD wBackwardRefPictureIndex;
-
- WORD wPicWidthInMBminus1;
- WORD wPicHeightInMBminus1;
-
- BYTE bMacroblockWidthMinus1;
- BYTE bMacroblockHeightMinus1;
-
- BYTE bBlockWidthMinus1;
- BYTE bBlockHeightMinus1;
-
- BYTE bBPPminus1;
-
- BYTE bPicStructure;
- BYTE bSecondField;
- BYTE bPicIntra;
- BYTE bPicBackwardPrediction;
-
- BYTE bBidirectionalAveragingMode;
- BYTE bMVprecisionAndChromaRelation;
- BYTE bChromaFormat;
-
- BYTE bPicScanFixed;
- BYTE bPicScanMethod;
- BYTE bPicReadbackRequests;
-
- BYTE bRcontrol;
- BYTE bPicSpatialResid8;
- BYTE bPicOverflowBlocks;
- BYTE bPicExtrapolation;
-
- BYTE bPicDeblocked;
- BYTE bPicDeblockConfined;
- BYTE bPic4MVallowed;
- BYTE bPicOBMC;
- BYTE bPicBinPB;
- BYTE bMV_RPS;
-
- BYTE bReservedBits;
-
- WORD wBitstreamFcodes;
- WORD wBitstreamPCEelements;
- BYTE bBitstreamConcealmentNeed;
- BYTE bBitstreamConcealmentMethod;
-
-} DXVA_PictureParameters, *LPDXVA_PictureParameters;
-
-
-
-/* Picture Resampling */
-
-typedef struct _DXVA_PicResample {
-
- WORD wPicResampleSourcePicIndex;
- WORD wPicResampleDestPicIndex;
-
- WORD wPicResampleRcontrol;
- BYTE bPicResampleExtrapWidth;
- BYTE bPicResampleExtrapHeight;
-
- DWORD dwPicResampleSourceWidth;
- DWORD dwPicResampleSourceHeight;
-
- DWORD dwPicResampleDestWidth;
- DWORD dwPicResampleDestHeight;
-
- DWORD dwPicResampleFullDestWidth;
- DWORD dwPicResampleFullDestHeight;
-
-} DXVA_PicResample, *LPDXVA_PicResample;
-
-
-#define DXVA_CHROMA_FORMAT_420 1
-#define DXVA_CHROMA_FORMAT_422 2
-#define DXVA_CHROMA_FORMAT_444 3
-
-#define DXVA_PICTURE_STRUCTURE_TOP_FIELD 1
-#define DXVA_PICTURE_STRUCTURE_BOTTOM_FIELD 2
-#define DXVA_PICTURE_STRUCTURE_FRAME 3
-
-#define DXVA_BIDIRECTIONAL_AVERAGING_MPEG2_ROUND 0
-#define DXVA_BIDIRECTIONAL_AVERAGING_H263_TRUNC 1
-
-#define DXVA_MV_PRECISION_AND_CHROMA_RELATION_MPEG2 0
-#define DXVA_MV_PRECISION_AND_CHROMA_RELATION_H263 1
-#define DXVA_MV_PRECISION_AND_CHROMA_RELATION_H261 2
-
-#define DXVA_SCAN_METHOD_ZIG_ZAG 0
-#define DXVA_SCAN_METHOD_ALTERNATE_VERTICAL 1
-#define DXVA_SCAN_METHOD_ALTERNATE_HORIZONTAL 2
-#define DXVA_SCAN_METHOD_ARBITRARY 3
-
-#define DXVA_BITSTREAM_CONCEALMENT_NEED_UNLIKELY 0
-#define DXVA_BITSTREAM_CONCEALMENT_NEED_MILD 1
-#define DXVA_BITSTREAM_CONCEALMENT_NEED_LIKELY 2
-#define DXVA_BITSTREAM_CONCEALMENT_NEED_SEVERE 3
-
-#define DXVA_BITSTREAM_CONCEALMENT_METHOD_UNSPECIFIED 0
-#define DXVA_BITSTREAM_CONCEALMENT_METHOD_INTRA 1
-#define DXVA_BITSTREAM_CONCEALMENT_METHOD_FORWARD 2
-#define DXVA_BITSTREAM_CONCEALMENT_METHOD_BACKWARD 3
-
-
-/* Buffer Description Data */
-
-typedef struct _DXVA_BufferDescription {
- DWORD dwTypeIndex;
- DWORD dwBufferIndex;
- DWORD dwDataOffset;
- DWORD dwDataSize;
- DWORD dwFirstMBaddress;
- DWORD dwNumMBsInBuffer;
- DWORD dwWidth;
- DWORD dwHeight;
- DWORD dwStride;
- DWORD dwReservedBits;
-} DXVA_BufferDescription, *LPDXVA_BufferDescription;
-
-
-/* Off-Host IDCT Coefficient Data Structures */
-
-typedef struct _DXVA_TCoef4Group {
- BYTE TCoefIDX[4];
- SHORT TCoefValue[4];
-} DXVA_TCoef4Group, *LPDXVA_TCoef4Group;
-
-typedef struct _DXVA_TCoefSingle {
- WORD wIndexWithEOB;
- SHORT TCoefValue;
-} DXVA_TCoefSingle, *LPDXVA_TCoefSingle;
-
-/* Macros for Reading EOB and Index Values */
-
-#define readDXVA_TCoefSingleIDX(ptr) ((ptr)->wIndexWithEOB >> 1)
-#define readDXVA_TCoefSingleEOB(ptr) ((ptr)->wIndexWithEOB & 1)
-
-/* Macro for Writing EOB and Index Values */
-
-#define writeDXVA_TCoefSingleIndexWithEOB(ptr, idx, eob) ((ptr)->wIndexWithEOB = ((idx) << 1) | (eob))
-#define setDXVA_TCoefSingleIDX(ptr, idx) ((ptr)->wIndexWithEOB |= ((idx) << 1))
-#define setDXVA_TCoefSingleEOB(ptr) ((ptr)->wIndexWithEOB |= 1)
-
-/* Spatial-Domain Residual Difference Blocks */
-
-#define DXVA_USUAL_BLOCK_WIDTH 8
-#define DXVA_USUAL_BLOCK_HEIGHT 8
-#define DXVA_USUAL_BLOCK_SIZE (DXVA_USUAL_BLOCK_WIDTH * DXVA_USUAL_BLOCK_HEIGHT)
-
-typedef SHORT DXVA_Sample16[DXVA_USUAL_BLOCK_SIZE];
-typedef signed char DXVA_Sample8 [DXVA_USUAL_BLOCK_SIZE];
-
-/* Deblocking Filter Control Structure */
-
-typedef BYTE DXVA_DeblockingEdgeControl;
-
-typedef DXVA_DeblockingEdgeControl * LPDXVA_DeblockingEdgeControl;
-
-/* Macros for Reading STRENGTH and FilterOn */
-
-#define readDXVA_EdgeFilterStrength(ptr) ((*(ptr)) >> 1)
-#define readDXVA_EdgeFilterOn(ptr) ((*(ptr)) & 1)
-
-/* Macro for Writing STRENGTH and FilterOn */
-
-#define writeDXVA_DeblockingEdgeControl(ptr, str, fon) ((*(ptr)) = ((str) << 1) | (fon))
-#define setDXVA_EdgeFilterStrength(ptr, str) ((*(ptr)) |= ((str) << 1))
-#define setDXVA_EdgeFilterOn(ptr) ((*(ptr)) |= 1)
-
-
-/* Macroblock Control Command Data Structures */
-
-typedef struct _DXVA_MVvalue {
- SHORT horz, vert;
-} DXVA_MVvalue, *LPDXVA_MVvalue;
-
-
-/* Inverse Quantization Matrices */
-
-typedef struct _DXVA_QmatrixData {
- BYTE bNewQmatrix[4]; /* intra Y, inter Y, intra chroma, inter chroma */
- WORD Qmatrix[4][DXVA_USUAL_BLOCK_WIDTH * DXVA_USUAL_BLOCK_HEIGHT];
-} DXVA_QmatrixData, *LPDXVA_QmatrixData;
-
-
-/* Slice Control Buffer Data */
-
-typedef struct _DXVA_SliceInfo {
- WORD wHorizontalPosition;
- WORD wVerticalPosition;
- DWORD dwSliceBitsInBuffer;
- DWORD dwSliceDataLocation;
- BYTE bStartCodeBitOffset;
- BYTE bReservedBits;
- WORD wMBbitOffset;
- WORD wNumberMBsInSlice;
- WORD wQuantizerScaleCode;
- WORD wBadSliceChopping;
-} DXVA_SliceInfo, *LPDXVA_SliceInfo;
-
-
-#define DXVA_NumMV_OBMC_off_BinPBwith4MV_off 4
-#define DXVA_NumMV_OBMC_off_BinPBwith4MV_on (4+1)
-#define DXVA_NumMV_OBMC_on__BinPB_off (10)
-#define DXVA_NumMV_OBMC_on__BinPB_on (11) /* not current standards */
-
-#define DXVA_NumBlocksPerMB_420 (4+2+0)
-#define DXVA_NumBlocksPerMB_422 (4+2+2)
-#define DXVA_NumBlocksPerMB_444 (4+4+4)
-
-/* Basic form for I pictures */
-/* Host Residual Differences */
-typedef struct _DXVA_MBctrl_I_HostResidDiff_1 {
- WORD wMBaddress;
- WORD wMBtype;
- DWORD dwMB_SNL;
- WORD wPatternCode;
- WORD wPC_Overflow; /* zero if not overflow format */
- DWORD dwReservedBits2;
-} DXVA_MBctrl_I_HostResidDiff_1;
-
-/* Basic form for I pictures */
-/* Off-Host IDCT, 4:2:0 sampling */
-typedef struct _DXVA_MBctrl_I_OffHostIDCT_1 {
- WORD wMBaddress;
- WORD wMBtype;
- DWORD dwMB_SNL;
- WORD wPatternCode;
- BYTE bNumCoef[DXVA_NumBlocksPerMB_420];
-} DXVA_MBctrl_I_OffHostIDCT_1;
-
-/* Basic form for P and B pictures */
-/* Should also be used for concealment MVs in MPEG-2 I pictures */
-/* Without OBMC, without BinPB and 4MV together, without MV RPS */
-/* Host Residual Differences */
-typedef struct _DXVA_MBctrl_P_HostResidDiff_1 {
- WORD wMBaddress;
- WORD wMBtype;
- DWORD dwMB_SNL;
- WORD wPatternCode;
- WORD wPC_Overflow; /* zero if not overflow format */
- DWORD dwReservedBits2;
- DXVA_MVvalue MVector[DXVA_NumMV_OBMC_off_BinPBwith4MV_off];
-} DXVA_MBctrl_P_HostResidDiff_1;
-
-/* Basic form for P and B pictures */
-/* Without OBMC, without BinPB and 4MV together, without MV RPS */
-/* Off-Host IDCT, 4:2:0 sampling */
-typedef struct _DXVA_MBctrl_P_OffHostIDCT_1 {
- WORD wMBaddress;
- WORD wMBtype;
- DWORD dwMB_SNL;
- WORD wPatternCode;
- BYTE bNumCoef[DXVA_NumBlocksPerMB_420];
- DXVA_MVvalue MVector[DXVA_NumMV_OBMC_off_BinPBwith4MV_off];
-} DXVA_MBctrl_P_OffHostIDCT_1;
-
-/* How to load alpha blending graphic data */
-typedef struct _DXVA_ConfigAlphaLoad {
-
- // Operation Indicated
- DXVA_ConfigQueryOrReplyFunc dwFunction;
-
- // Alignment
- DWORD dwReservedBits[3];
-
- BYTE bConfigDataType;
-} DXVA_ConfigAlphaLoad, *LPDXVA_ConfigAlphaLoad;
-
-#define DXVA_CONFIG_DATA_TYPE_IA44 0
-#define DXVA_CONFIG_DATA_TYPE_AI44 1
-#define DXVA_CONFIG_DATA_TYPE_DPXD 2
-#define DXVA_CONFIG_DATA_TYPE_AYUV 3
-
-
-/* How to combine alpha blending graphic data */
-typedef struct _DXVA_ConfigAlphaCombine {
-
- // Operation Indicated
- DXVA_ConfigQueryOrReplyFunc dwFunction;
-
- // Alignment
- DWORD dwReservedBits[3];
-
- BYTE bConfigBlendType;
- BYTE bConfigPictureResizing;
- BYTE bConfigOnlyUsePicDestRectArea;
- BYTE bConfigGraphicResizing;
- BYTE bConfigWholePlaneAlpha;
-
-} DXVA_ConfigAlphaCombine, *LPDXVA_ConfigAlphaCombine;
-
-#define DXVA_CONFIG_BLEND_TYPE_FRONT_BUFFER 0
-#define DXVA_CONFIG_BLEND_TYPE_BACK_HARDWARE 1
-
-
-/* AYUV sample for 16-entry YUV palette or graphic surface */
-
-typedef struct _DXVA_AYUVsample2 {
- BYTE bCrValue;
- BYTE bCbValue;
- BYTE bY_Value;
- BYTE bSampleAlpha8;
-} DXVA_AYUVsample2, *LPDXVA_AYUVsample2;
-
-/* Macros for IA44 alpha blending surface samples */
-
-typedef BYTE DXVA_IA44sample, *LPDXVA_IA44sample;
-
-#define readDXVA_IA44index(ptr) (((*(ptr)) & 0xF0) >> 4)
-#define readDXVA_IA44alpha(ptr) ((*(ptr)) & 0x0F)
-
-#define writeDXVA_IA44(ptr, idx, alpha) ((*(ptr)) = (((idx) << 4) | (alpha)))
-
-#define setDXVA_IA44index(ptr, idx) ((*(ptr)) |= ((idx) << 4))
-#define setDXVA_IA44alpha(ptr, alpha) ((*(ptr)) |= (alpha))
-
-/* Macros for AI44 alpha blending surface samples */
-
-typedef BYTE DXVA_AI44sample, *LPDXVA_AI44sample;
-
-#define readDXVA_AI44index(ptr) ((*(ptr)) & 0x0F)
-#define readDXVA_AI44alpha(ptr) (((*(ptr)) & 0xF0) >> 4)
-
-#define writeDXVA_AI44(ptr, idx, alpha) ((*(ptr)) = (((alpha) << 4) | (idx)))
-
-#define setDXVA_AI44index(ptr, idx) ((*(ptr)) |= (idx))
-#define setDXVA_AI44alpha(ptr, alpha) ((*(ptr)) |= ((alpha) << 4))
-
-
-/* Highlight data structure */
-
-typedef struct _DXVA_Highlight {
- WORD wHighlightActive;
- WORD wHighlightIndices;
- WORD wHighlightAlphas;
- RECT HighlightRect;
-} DXVA_Highlight, *LPDXVA_Highlight;
-
-typedef BYTE DXVA_DPXD, *LPDXVA_DPXD;
-typedef WORD DXVA_DCCMD, *LPDXVA_DCCMD;
-
-/* Alpha blend combination */
-
-typedef struct _DXVA_BlendCombination {
- WORD wPictureSourceIndex;
- WORD wBlendedDestinationIndex;
- RECT PictureSourceRect16thPel;
- RECT PictureDestinationRect;
- RECT GraphicSourceRect;
- RECT GraphicDestinationRect;
- WORD wBlendDelay;
- BYTE bBlendOn;
- BYTE bWholePlaneAlpha;
- DXVA_AYUVsample2 OutsideYUVcolor;
-} DXVA_BlendCombination, *LPDXVA_BlendCombination;
-
-/* H.264/AVC-specific structures */
-
-/* H.264/AVC picture entry data structure */
-typedef struct _DXVA_PicEntry_H264 {
- union {
- struct {
- UCHAR Index7Bits : 7;
- UCHAR AssociatedFlag : 1;
- };
- UCHAR bPicEntry;
- };
-} DXVA_PicEntry_H264, *LPDXVA_PicEntry_H264; /* 1 byte */
-
-/* H.264/AVC picture parameters structure */
-typedef struct _DXVA_PicParams_H264 {
- USHORT wFrameWidthInMbsMinus1;
- USHORT wFrameHeightInMbsMinus1;
- DXVA_PicEntry_H264 CurrPic; /* flag is bot field flag */
- UCHAR num_ref_frames;
-
- union {
- struct {
- USHORT field_pic_flag : 1;
- USHORT MbaffFrameFlag : 1;
- USHORT residual_colour_transform_flag : 1;
- USHORT sp_for_switch_flag : 1;
- USHORT chroma_format_idc : 2;
- USHORT RefPicFlag : 1;
- USHORT constrained_intra_pred_flag : 1;
-
- USHORT weighted_pred_flag : 1;
- USHORT weighted_bipred_idc : 2;
- USHORT MbsConsecutiveFlag : 1;
- USHORT frame_mbs_only_flag : 1;
- USHORT transform_8x8_mode_flag : 1;
- USHORT MinLumaBipredSize8x8Flag : 1;
- USHORT IntraPicFlag : 1;
- };
- USHORT wBitFields;
- };
- UCHAR bit_depth_luma_minus8;
- UCHAR bit_depth_chroma_minus8;
-
- USHORT Reserved16Bits;
- UINT StatusReportFeedbackNumber;
-
- DXVA_PicEntry_H264 RefFrameList[16]; /* flag LT */
- INT CurrFieldOrderCnt[2];
- INT FieldOrderCntList[16][2];
-
- CHAR pic_init_qs_minus26;
- CHAR chroma_qp_index_offset; /* also used for QScb */
- CHAR second_chroma_qp_index_offset; /* also for QScr */
- UCHAR ContinuationFlag;
-
-/* remainder for parsing */
- CHAR pic_init_qp_minus26;
- UCHAR num_ref_idx_l0_active_minus1;
- UCHAR num_ref_idx_l1_active_minus1;
- UCHAR Reserved8BitsA;
-
- USHORT FrameNumList[16];
- UINT UsedForReferenceFlags;
- USHORT NonExistingFrameFlags;
- USHORT frame_num;
-
- UCHAR log2_max_frame_num_minus4;
- UCHAR pic_order_cnt_type;
- UCHAR log2_max_pic_order_cnt_lsb_minus4;
- UCHAR delta_pic_order_always_zero_flag;
-
- UCHAR direct_8x8_inference_flag;
- UCHAR entropy_coding_mode_flag;
- UCHAR pic_order_present_flag;
- UCHAR num_slice_groups_minus1;
-
- UCHAR slice_group_map_type;
- UCHAR deblocking_filter_control_present_flag;
- UCHAR redundant_pic_cnt_present_flag;
- UCHAR Reserved8BitsB;
-
- USHORT slice_group_change_rate_minus1;
-
- UCHAR SliceGroupMap[810]; /* 4b/sgmu, Size BT.601 */
-
-} DXVA_PicParams_H264, *LPDXVA_PicParams_H264;
-
-/* H.264/AVC quantization weighting matrix data structure */
-typedef struct _DXVA_Qmatrix_H264 {
- UCHAR bScalingLists4x4[6][16];
- UCHAR bScalingLists8x8[2][64];
-
-} DXVA_Qmatrix_H264, *LPDXVA_Qmatrix_H264;
-
-/* H.264/AVC slice control data structure - short form */
-typedef struct _DXVA_Slice_H264_Short {
- UINT BSNALunitDataLocation; /* type 1..5 */
- UINT SliceBytesInBuffer; /* for off-host parse */
- USHORT wBadSliceChopping; /* for off-host parse */
-} DXVA_Slice_H264_Short, *LPDXVA_Slice_H264_Short;
-
-/* H.264/AVC picture entry data structure - long form */
-typedef struct _DXVA_Slice_H264_Long {
- UINT BSNALunitDataLocation; /* type 1..5 */
- UINT SliceBytesInBuffer; /* for off-host parse */
- USHORT wBadSliceChopping; /* for off-host parse */
-
- USHORT first_mb_in_slice;
- USHORT NumMbsForSlice;
-
- USHORT BitOffsetToSliceData; /* after CABAC alignment */
-
- UCHAR slice_type;
- UCHAR luma_log2_weight_denom;
- UCHAR chroma_log2_weight_denom;
- UCHAR num_ref_idx_l0_active_minus1;
- UCHAR num_ref_idx_l1_active_minus1;
- CHAR slice_alpha_c0_offset_div2;
- CHAR slice_beta_offset_div2;
- UCHAR Reserved8Bits;
- DXVA_PicEntry_H264 RefPicList[2][32]; /* L0 & L1 */
- SHORT Weights[2][32][3][2]; /* L0 & L1; Y, Cb, Cr */
- CHAR slice_qs_delta;
- /* rest off-host parse */
- CHAR slice_qp_delta;
- UCHAR redundant_pic_cnt;
- UCHAR direct_spatial_mv_pred_flag;
- UCHAR cabac_init_idc;
- UCHAR disable_deblocking_filter_idc;
- USHORT slice_id;
-} DXVA_Slice_H264_Long, *LPDXVA_Slice_H264_Long;
-
-/* H.264/AVC macroblock control command data structure */
-typedef struct _DXVA_MBctrl_H264 {
- union {
- struct {
- UINT bSliceID : 8; /* 1 byte */
- UINT MbType5Bits : 5;
- UINT IntraMbFlag : 1;
- UINT mb_field_decoding_flag : 1;
- UINT transform_size_8x8_flag : 1; /* 2 bytes */
- UINT HostResidDiff : 1;
- UINT DcBlockCodedCrFlag : 1;
- UINT DcBlockCodedCbFlag : 1;
- UINT DcBlockCodedYFlag : 1;
- UINT FilterInternalEdgesFlag : 1;
- UINT FilterLeftMbEdgeFlag : 1;
- UINT FilterTopMbEdgeFlag : 1;
- UINT ReservedBit : 1;
- UINT bMvQuantity : 8; /* 4 bytes */
- };
- UINT dwMBtype; /* 4 bytes so far */
- };
- USHORT CurrMbAddr; /* 6 bytes so far */
- USHORT wPatternCode[3];/* YCbCr, 16 4x4 blks, 1b each */
- /* 12 bytes so far */
- UCHAR bQpPrime[3]; /* Y, Cb, Cr, need just 7b QpY */
- UCHAR bMBresidDataQuantity;
- ULONG dwMBdataLocation; /* offset into resid buffer */
- /* 20 bytes so far */
- union {
- struct {
-/* start here for Intra MB's (9 useful bytes in branch) */
- USHORT LumaIntraPredModes[4];/* 16 blocks, 4b each */
- /* 28 bytes so far */
- union {
- struct {
- UCHAR intra_chroma_pred_mode : 2;
- UCHAR IntraPredAvailFlags : 5;
- UCHAR ReservedIntraBit : 1;
- };
- UCHAR bMbIntraStruct; /* 29 bytes so far */
- };
- UCHAR ReservedIntra24Bits[3]; /* 32 bytes total */
- };
- struct {
-/* start here for non-Intra MB's (12 bytes in branch) */
- UCHAR bSubMbShapes; /* 4 subMbs, 2b each */
- UCHAR bSubMbPredModes; /* 4 subMBs, 2b each */
- /* 22 bytes so far */
- USHORT wMvBuffOffset; /* offset into MV buffer */
- UCHAR bRefPicSelect[2][4]; /* 32 bytes total */
- };
- };
-} DXVA_MBctrl_H264, *LPDXVA_MBctrl_H264;
-
-/* H.264/AVC IndexA and IndexB data structure */
-typedef struct _DXVA_DeblockIndexAB_H264 {
- UCHAR bIndexAinternal; /* 6b - could get from MB CC */
- UCHAR bIndexBinternal; /* 6b - could get from MB CC */
-
- UCHAR bIndexAleft0;
- UCHAR bIndexBleft0;
-
- UCHAR bIndexAleft1;
- UCHAR bIndexBleft1;
-
- UCHAR bIndexAtop0;
- UCHAR bIndexBtop0;
-
- UCHAR bIndexAtop1;
- UCHAR bIndexBtop1;
-} DXVA_DeblockIndexAB_H264, *LPDXVA_DeblockIndexAB_H264;
- /* 10 bytes in struct */
-
-/* H.264/AVC deblocking filter control data structure */
-typedef struct _DXVA_Deblock_H264 {
- USHORT CurrMbAddr; /* dup info */ /* 2 bytes so far */
- union {
- struct {
- UCHAR ReservedBit : 1;
- UCHAR FieldModeCurrentMbFlag : 1; /* dup info */
- UCHAR FieldModeLeftMbFlag : 1;
- UCHAR FieldModeAboveMbFlag : 1;
- UCHAR FilterInternal8x8EdgesFlag : 1;
- UCHAR FilterInternal4x4EdgesFlag : 1;
- UCHAR FilterLeftMbEdgeFlag : 1;
- UCHAR FilterTopMbEdgeFlag : 1;
- };
- UCHAR FirstByte;
- };
- UCHAR Reserved8Bits; /* 4 bytes so far */
-
- UCHAR bbSinternalLeftVert; /* 2 bits per bS */
- UCHAR bbSinternalMidVert;
-
- UCHAR bbSinternalRightVert;
- UCHAR bbSinternalTopHorz; /* 8 bytes so far */
-
- UCHAR bbSinternalMidHorz;
- UCHAR bbSinternalBotHorz; /* 10 bytes so far */
-
- USHORT wbSLeft0; /* 4 bits per bS (1 wasted) */
- USHORT wbSLeft1; /* 4 bits per bS (1 wasted) */
-
- USHORT wbSTop0; /* 4 bits per bS (1 wasted) */
- USHORT wbSTop1; /* 4b (2 wasted) 18 bytes so far*/
-
- DXVA_DeblockIndexAB_H264 IndexAB[3]; /* Y, Cb, Cr */
-
-} DXVA_Deblock_H264, *LPDXVA_Deblock_H264;/* 48 bytes */
-
-/* H.264/AVC film grain characteristics data structure */
-typedef struct _DXVA_FilmGrainCharacteristics {
-
- USHORT wFrameWidthInMbsMinus1;
- USHORT wFrameHeightInMbsMinus1;
-
- DXVA_PicEntry_H264 InPic; /* flag is bot field flag */
- DXVA_PicEntry_H264 OutPic; /* flag is field pic flag */
-
- USHORT PicOrderCnt_offset;
- INT CurrPicOrderCnt;
- UINT StatusReportFeedbackNumber;
-
- UCHAR model_id;
- UCHAR separate_colour_description_present_flag;
- UCHAR film_grain_bit_depth_luma_minus8;
- UCHAR film_grain_bit_depth_chroma_minus8;
-
- UCHAR film_grain_full_range_flag;
- UCHAR film_grain_colour_primaries;
- UCHAR film_grain_transfer_characteristics;
- UCHAR film_grain_matrix_coefficients;
-
- UCHAR blending_mode_id;
- UCHAR log2_scale_factor;
-
- UCHAR comp_model_present_flag[4];
- UCHAR num_intensity_intervals_minus1[4];
- UCHAR num_model_values_minus1[4];
-
- UCHAR intensity_interval_lower_bound[3][16];
- UCHAR intensity_interval_upper_bound[3][16];
- SHORT comp_model_value[3][16][8];
-} DXVA_FilmGrainChar_H264, *LPDXVA_FilmGrainChar_H264;
-
-/* H.264/AVC status reporting data structure */
-typedef struct _DXVA_Status_H264 {
- UINT StatusReportFeedbackNumber;
- DXVA_PicEntry_H264 CurrPic; /* flag is bot field flag */
- UCHAR field_pic_flag;
- UCHAR bDXVA_Func;
- UCHAR bBufType;
- UCHAR bStatus;
- UCHAR bReserved8Bits;
- USHORT wNumMbsAffected;
-} DXVA_Status_H264, *LPDXVA_Status_H264;
-
-/* VC-1 status reporting data structure */
-typedef struct _DXVA_Status_VC1 {
- USHORT StatusReportFeedbackNumber;
- WORD wDecodedPictureIndex;
- WORD wDeblockedPictureIndex;
- UCHAR bPicStructure;
- UCHAR bBufType;
- UCHAR bStatus;
- UCHAR bReserved8Bits;
- USHORT wNumMbsAffected;
-} DXVA_Status_VC1, *LPDXVA_Status_VC1;
-
-
-#pragma pack(push, 16)
-
-
-typedef DXVA_MBctrl_I_HostResidDiff_1 *
- LPDXVA_MBctrl_I_HostResidDiff_1;
-
-typedef DXVA_MBctrl_I_OffHostIDCT_1 *
- LPDXVA_MBctrl_I_OffHostIDCT_1;
-
-typedef DXVA_MBctrl_P_HostResidDiff_1 *
- LPDXVA_MBctrl_P_HostResidDiff_1;
-
-typedef DXVA_MBctrl_P_OffHostIDCT_1 *
- LPDXVA_MBctrl_P_OffHostIDCT_1;
-
-
-#pragma pack(pop)
-
-/*
- * Other forms of pictures are constructed in the obvious way
- * from the above by adjusting the number of residual difference
- * blocks, the number of motion vectors per macroblock, etc.
- */
-
-#define readDXVA_MBskipsFollowing(ptr) (((ptr)->dwMB_SNL & 0xFF000000) >> 24)
-#define readDXVA_MBdataLocation(ptr) (((ptr)->dwMB_SNL & 0x00FFFFFF))
-
-#define writeDXVA_MB_SNL(ptr, skips, dloc) ((ptr)->dwMB_SNL = (((skips) << 24) | (dloc)))
-#define setDXVA_MBskipsFollowing(ptr, skips) ((ptr)->dwMB_SNL |= ((skips) << 24))
-#define setDXVA_MBdataLocation(ptr, dloc) ((ptr)->dwMB_SNL |= (dloc))
-
-#define readDXVA_MvertFieldSel_3(ptr) (((ptr)->wMBtype & 0x8000) >> 15)
-#define readDXVA_MvertFieldSel_2(ptr) (((ptr)->wMBtype & 0x4000) >> 14)
-#define readDXVA_MvertFieldSel_1(ptr) (((ptr)->wMBtype & 0x2000) >> 13)
-#define readDXVA_MvertFieldSel_0(ptr) (((ptr)->wMBtype & 0x1000) >> 12)
-#define readDXVA_ReservedBits(ptr) (((ptr)->wMBtype & 0x0800) >> 11)
-#define readDXVA_HostResidDiff(ptr) (((ptr)->wMBtype & 0x0400) >> 10)
-#define readDXVA_MotionType(ptr) (((ptr)->wMBtype & 0x0300) >> 8)
-#define readDXVA_MBscanMethod(ptr) (((ptr)->wMBtype & 0x00C0) >> 6)
-#define readDXVA_FieldResidual(ptr) (((ptr)->wMBtype & 0x0020) >> 5)
-#define readDXVA_H261LoopFilter(ptr) (((ptr)->wMBtype & 0x0010) >> 4)
-#define readDXVA_Motion4MV(ptr) (((ptr)->wMBtype & 0x0008) >> 3)
-#define readDXVA_MotionBackward(ptr) (((ptr)->wMBtype & 0x0004) >> 2)
-#define readDXVA_MotionForward(ptr) (((ptr)->wMBtype & 0x0002) >> 1)
-#define readDXVA_IntraMacroblock(ptr) (((ptr)->wMBtype & 0x0001))
-
-#define setDXVA_MvertFieldSel_3(ptr) ((ptr)->wMBtype |= 0x8000)
-#define setDXVA_MvertFieldSel_2(ptr) ((ptr)->wMBtype |= 0x4000)
-#define setDXVA_MvertFieldSel_1(ptr) ((ptr)->wMBtype |= 0x2000)
-#define setDXVA_MvertFieldSel_0(ptr) ((ptr)->wMBtype |= 0x1000)
-#define setDXVA_ReservedBits(ptr) ((ptr)->wMBtype |= 0x0800)
-#define setDXVA_HostResidDiff(ptr) ((ptr)->wMBtype |= 0x0400)
-#define setDXVA_MotionType(ptr, value) ((ptr)->wMBtype |= ((value) << 8))
-#define setDXVA_MBscanMethod(ptr, value) ((ptr)->wMBtype |= ((value) << 6))
-#define setDXVA_FieldResidual(ptr) ((ptr)->wMBtype |= 0x0020)
-#define setDXVA_H261LoopFilter(ptr) ((ptr)->wMBtype |= 0x0010)
-#define setDXVA_Motion4MV(ptr) ((ptr)->wMBtype |= 0x0008)
-#define setDXVA_MotionBackward(ptr) ((ptr)->wMBtype |= 0x0004)
-#define setDXVA_MotionForward(ptr) ((ptr)->wMBtype |= 0x0002)
-#define setDXVA_IntraMacroblock(ptr) ((ptr)->wMBtype |= 0x0001)
-
-#define readDXVA_Y___0coded(ptr) (((ptr)->wPatternCode & 0x0800) >> 11)
-#define readDXVA_Y___1coded(ptr) (((ptr)->wPatternCode & 0x0400) >> 10)
-#define readDXVA_Y___2coded(ptr) (((ptr)->wPatternCode & 0x0200) >> 9)
-#define readDXVA_Y___3coded(ptr) (((ptr)->wPatternCode & 0x0100) >> 8)
-#define readDXVA_Cb__4coded(ptr) (((ptr)->wPatternCode & 0x0080) >> 7)
-#define readDXVA_Cr__5coded(ptr) (((ptr)->wPatternCode & 0x0040) >> 6)
-#define readDXVA_Cb__6coded(ptr) (((ptr)->wPatternCode & 0x0020) >> 5)
-#define readDXVA_Cr__7coded(ptr) (((ptr)->wPatternCode & 0x0010) >> 4)
-#define readDXVA_Cb__8coded(ptr) (((ptr)->wPatternCode & 0x0008) >> 3)
-#define readDXVA_Cb__9coded(ptr) (((ptr)->wPatternCode & 0x0004) >> 2)
-#define readDXVA_Cr_10coded(ptr) (((ptr)->wPatternCode & 0x0002) >> 1)
-#define readDXVA_Cr_11coded(ptr) (((ptr)->wPatternCode & 0x0001))
-
-#define readDXVA_Y___0oflow(ptr) (((ptr)->wPC_Overflow & 0x0800) >> 11)
-#define readDXVA_Y___1oflow(ptr) (((ptr)->wPC_Overflow & 0x0400) >> 10)
-#define readDXVA_Y___2oflow(ptr) (((ptr)->wPC_Overflow & 0x0200) >> 9)
-#define readDXVA_Y___3oflow(ptr) (((ptr)->wPC_Overflow & 0x0100) >> 8)
-#define readDXVA_Cb__4oflow(ptr) (((ptr)->wPC_Overflow & 0x0080) >> 7)
-#define readDXVA_Cr__5oflow(ptr) (((ptr)->wPC_Overflow & 0x0040) >> 6)
-#define readDXVA_Cb__6oflow(ptr) (((ptr)->wPC_Overflow & 0x0020) >> 5)
-#define readDXVA_Cr__7oflow(ptr) (((ptr)->wPC_Overflow & 0x0010) >> 4)
-#define readDXVA_Cb__8oflow(ptr) (((ptr)->wPC_Overflow & 0x0008) >> 3)
-#define readDXVA_Cb__9oflow(ptr) (((ptr)->wPC_Overflow & 0x0004) >> 2)
-#define readDXVA_Cr_10oflow(ptr) (((ptr)->wPC_Overflow & 0x0002) >> 1)
-#define readDXVA_Cr_11oflow(ptr) (((ptr)->wPC_Overflow & 0x0001))
-
-#pragma pack(pop, BeforeDXVApacking)
-#endif /* __DIRECTX_VA_DECODER__ */
-
-
-// -------------------------------------------------------------------------
-//
-// D3DFORMAT describes a pixel memory layout, DXVA sample format contains
-// additional information that describes how the pixels should be interpreted.
-//
-// DXVA Extended color data - occupies the SampleFormat DWORD
-// data fields.
-// -------------------------------------------------------------------------
-#ifndef __DIRECTX_VA_SAMPLEFORMAT__
-#define __DIRECTX_VA_SAMPLEFORMAT__
-
-typedef enum _DXVA_SampleFormat {
- DXVA_SampleFormatMask = 0xFF, // 8 bits used for DXVA Sample format
- DXVA_SampleUnknown = 0,
- DXVA_SamplePreviousFrame = 1,
- DXVA_SampleProgressiveFrame = 2,
- DXVA_SampleFieldInterleavedEvenFirst = 3,
- DXVA_SampleFieldInterleavedOddFirst = 4,
- DXVA_SampleFieldSingleEven = 5,
- DXVA_SampleFieldSingleOdd = 6,
- DXVA_SampleSubStream = 7
-} DXVA_SampleFormat;
-
-#define DXVA_ExtractSampleFormat(_sf) ((_sf) & (DXVA_SampleFormatMask))
-
-#define DXVA_ExtractExtColorData(_sf, _Mask, _Shift) \
- (((_sf) & (_Mask)) >> (_Shift))
-
-#define DXVABitMask(__n) (~((~0) << __n))
-#define DXVA_ExtColorData_ShiftBase 8
-#define DXVAColorMask(__bits,__base) (DXVABitMask(__bits) << (__base))
-
-typedef enum _DXVA_VideoTransferFunction
-{
- DXVA_VideoTransFuncShift = (DXVA_ExtColorData_ShiftBase + 19),
- DXVA_VideoTransFuncMask = DXVAColorMask(5, DXVA_VideoTransFuncShift),
-
- DXVA_VideoTransFunc_Unknown = 0,
- DXVA_VideoTransFunc_10 = 1,
- DXVA_VideoTransFunc_18 = 2,
- DXVA_VideoTransFunc_20 = 3,
- DXVA_VideoTransFunc_22 = 4,
- DXVA_VideoTransFunc_22_709 = 5,
- DXVA_VideoTransFunc_22_240M = 6,
- DXVA_VideoTransFunc_22_8bit_sRGB = 7,
- DXVA_VideoTransFunc_28 = 8
-} DXVA_VideoTransferFunction;
-
-typedef enum _DXVA_VideoPrimaries
-{
- DXVA_VideoPrimariesShift = (DXVA_ExtColorData_ShiftBase + 14),
- DXVA_VideoPrimariesMask = DXVAColorMask(5, DXVA_VideoPrimariesShift),
-
- DXVA_VideoPrimaries_Unknown = 0,
- DXVA_VideoPrimaries_reserved = 1,
- DXVA_VideoPrimaries_BT709 = 2,
- DXVA_VideoPrimaries_BT470_2_SysM = 3,
- DXVA_VideoPrimaries_BT470_2_SysBG = 4,
- DXVA_VideoPrimaries_SMPTE170M = 5,
- DXVA_VideoPrimaries_SMPTE240M = 6,
- DXVA_VideoPrimaries_EBU3213 = 7,
- DXVA_VideoPrimaries_SMPTE_C = 8
-} DXVA_VideoPrimaries;
-
-typedef enum _DXVA_VideoLighting
-{
- DXVA_VideoLightingShift = (DXVA_ExtColorData_ShiftBase + 10),
- DXVA_VideoLightingMask = DXVAColorMask(4, DXVA_VideoLightingShift),
-
- DXVA_VideoLighting_Unknown = 0,
- DXVA_VideoLighting_bright = 1,
- DXVA_VideoLighting_office = 2,
- DXVA_VideoLighting_dim = 3,
- DXVA_VideoLighting_dark = 4
-} DXVA_VideoLighting;
-
-typedef enum _DXVA_VideoTransferMatrix
-{
- DXVA_VideoTransferMatrixShift = (DXVA_ExtColorData_ShiftBase + 7),
- DXVA_VideoTransferMatrixMask = DXVAColorMask(3, DXVA_VideoTransferMatrixShift),
-
- DXVA_VideoTransferMatrix_Unknown = 0,
- DXVA_VideoTransferMatrix_BT709 = 1,
- DXVA_VideoTransferMatrix_BT601 = 2,
- DXVA_VideoTransferMatrix_SMPTE240M = 3
-} DXVA_VideoTransferMatrix;
-
-typedef enum _DXVA_NominalRange
-{
- DXVA_NominalRangeShift = (DXVA_ExtColorData_ShiftBase + 4),
- DXVA_NominalRangeMask = DXVAColorMask(3, DXVA_NominalRangeShift),
-
- DXVA_NominalRange_Unknown = 0,
- DXVA_NominalRange_Normal = 1,
- DXVA_NominalRange_Wide = 2,
-
- DXVA_NominalRange_0_255 = 1,
- DXVA_NominalRange_16_235 = 2,
- DXVA_NominalRange_48_208 = 3
-} DXVA_NominalRange;
-
-
-typedef enum _DXVA_VideoChromaSubsampling
-{
- DXVA_VideoChromaSubsamplingShift = (DXVA_ExtColorData_ShiftBase + 0),
- DXVA_VideoChromaSubsamplingMask = DXVAColorMask(4, DXVA_VideoChromaSubsamplingShift),
-
- DXVA_VideoChromaSubsampling_Unknown = 0,
- DXVA_VideoChromaSubsampling_ProgressiveChroma = 0x8,
- DXVA_VideoChromaSubsampling_Horizontally_Cosited = 0x4,
- DXVA_VideoChromaSubsampling_Vertically_Cosited = 0x2,
- DXVA_VideoChromaSubsampling_Vertically_AlignedChromaPlanes = 0x1,
-
- // 4:2:0 variations
- DXVA_VideoChromaSubsampling_MPEG2 = DXVA_VideoChromaSubsampling_Horizontally_Cosited |
- DXVA_VideoChromaSubsampling_Vertically_AlignedChromaPlanes,
-
- DXVA_VideoChromaSubsampling_MPEG1 = DXVA_VideoChromaSubsampling_Vertically_AlignedChromaPlanes,
-
- DXVA_VideoChromaSubsampling_DV_PAL = DXVA_VideoChromaSubsampling_Horizontally_Cosited |
- DXVA_VideoChromaSubsampling_Vertically_Cosited,
- // 4:4:4, 4:2:2, 4:1:1
- DXVA_VideoChromaSubsampling_Cosited = DXVA_VideoChromaSubsampling_Horizontally_Cosited |
- DXVA_VideoChromaSubsampling_Vertically_Cosited |
- DXVA_VideoChromaSubsampling_Vertically_AlignedChromaPlanes,
-} DXVA_VideoChromaSubsampling;
-
-typedef struct _DXVA_ExtendedFormat
-{
- UINT SampleFormat : 8; // See DXVA_SampleFormat
- UINT VideoChromaSubsampling : 4; // See DXVA_VideoChromaSubSampling
- DXVA_NominalRange NominalRange : 3; // See DXVA_NominalRange
- DXVA_VideoTransferMatrix VideoTransferMatrix : 3; // See DXVA_VideoTransferMatrix
- DXVA_VideoLighting VideoLighting : 4; // See DXVA_VideoLighting
- DXVA_VideoPrimaries VideoPrimaries : 5; // See DXVA_VideoPrimaries
- DXVA_VideoTransferFunction VideoTransferFunction : 5; // See DXVA_VideoTransferFunction
-} DXVA_ExtendedFormat;
-
-#endif
-
-
-
-// -------------------------------------------------------------------------
-//
-// The definitions that follow describe the video de-interlace interface
-// between the VMR and the graphics device driver. This interface is not
-// accessable via the IAMVideoAccelerator interface.
-//
-// -------------------------------------------------------------------------
-//
-#ifndef __DIRECTX_VA_DEINTERLACE__
-#define __DIRECTX_VA_DEINTERLACE__
-
-typedef LONGLONG REFERENCE_TIME;
-
-DEFINE_GUID(DXVA_DeinterlaceBobDevice,
- 0x335aa36e,0x7884,0x43a4,0x9c,0x91,0x7f,0x87,0xfa,0xf3,0xe3,0x7e);
-
-DEFINE_GUID(DXVA_DeinterlaceContainerDevice,
- 0x0e85cb93,0x3046,0x4ff0,0xae,0xcc,0xd5,0x8c,0xb5,0xf0,0x35,0xfd);
-
-
-#if !defined(DIRECT3D_VERSION) || (DIRECT3D_VERSION < 0x0800)
-typedef DWORD D3DFORMAT;
-enum {
- D3DPOOL_DEFAULT = 0,
- D3DPOOL_MANAGED = 1,
- D3DPOOL_SYSTEMMEM = 2,
- D3DPOOL_SCRATCH = 3,
- D3DPOOL_LOCALVIDMEM = 4,
- D3DPOOL_NONLOCALVIDMEM = 5,
- D3DPOOL_FORCE_DWORD = 0x7fffffff
-};
-#endif
-
-
-// -------------------------------------------------------------------------
-// data structures shared by User mode and Kernel mode.
-// -------------------------------------------------------------------------
-//
-
-typedef struct _DXVA_Frequency {
- DWORD Numerator;
- DWORD Denominator;
-} DXVA_Frequency;
-
-typedef struct _DXVA_VideoDesc {
- DWORD Size;
- DWORD SampleWidth;
- DWORD SampleHeight;
- DWORD SampleFormat; // also contains extend color data
- D3DFORMAT d3dFormat;
- DXVA_Frequency InputSampleFreq;
- DXVA_Frequency OutputFrameFreq;
-} DXVA_VideoDesc, *LPDXVA_VideoDesc;
-
-typedef enum _DXVA_VideoProcessCaps {
- DXVA_VideoProcess_None = 0x0000,
- DXVA_VideoProcess_YUV2RGB = 0x0001,
- DXVA_VideoProcess_StretchX = 0x0002,
- DXVA_VideoProcess_StretchY = 0x0004,
- DXVA_VideoProcess_AlphaBlend = 0x0008,
- DXVA_VideoProcess_SubRects = 0x0010,
- DXVA_VideoProcess_SubStreams = 0x0020,
- DXVA_VideoProcess_SubStreamsExtended = 0x0040,
- DXVA_VideoProcess_YUV2RGBExtended = 0x0080,
- DXVA_VideoProcess_AlphaBlendExtended = 0x0100
-} DXVA_VideoProcessCaps;
-
-typedef enum _DXVA_DeinterlaceTech {
-
- // the algorithm is unknown or proprietary
- DXVA_DeinterlaceTech_Unknown = 0x0000,
-
- // the algorithm creates the missing lines by repeating
- // the line either above or below it - this method will look very jaggy and
- // isn't recommended
- DXVA_DeinterlaceTech_BOBLineReplicate = 0x0001,
-
- // The algorithm creates the missing lines by vertically stretching each
- // video field by a factor of two by averaging two lines
- DXVA_DeinterlaceTech_BOBVerticalStretch = 0x0002,
-
- // or using a [-1, 9, 9, -1]/16 filter across four lines.
- DXVA_DeinterlaceTech_BOBVerticalStretch4Tap = 0x0100,
-
- // the pixels in the missing line are recreated by a median filtering operation
- DXVA_DeinterlaceTech_MedianFiltering = 0x0004,
-
- // the pixels in the missing line are recreated by an edge filter.
- // In this process, spatial directional filters are applied to determine
- // the orientation of edges in the picture content, and missing
- // pixels are created by filtering along (rather than across) the
- // detected edges.
- DXVA_DeinterlaceTech_EdgeFiltering = 0x0010,
-
- // the pixels in the missing line are recreated by switching on a field by
- // field basis between using either spatial or temporal interpolation
- // depending on the amount of motion.
- DXVA_DeinterlaceTech_FieldAdaptive = 0x0020,
-
- // the pixels in the missing line are recreated by switching on a pixel by pixel
- // basis between using either spatial or temporal interpolation depending on
- // the amount of motion..
- DXVA_DeinterlaceTech_PixelAdaptive = 0x0040,
-
- // Motion Vector Steering identifies objects within a sequence of video
- // fields. The missing pixels are recreated after first aligning the
- // movement axes of the individual objects in the scene to make them
- // parallel with the time axis.
- DXVA_DeinterlaceTech_MotionVectorSteered = 0x0080
-
-} DXVA_DeinterlaceTech;
-
-
-typedef struct _DXVA_VideoSample {
- REFERENCE_TIME rtStart;
- REFERENCE_TIME rtEnd;
- DXVA_SampleFormat SampleFormat; // only lower 8 bits used
- VOID* lpDDSSrcSurface;
-} DXVA_VideoSample, *LPDXVA_VideoSample;
-
-
-
-// -------------------------------------------------------------------------
-// DeinterlaceBltEx declarations
-// -------------------------------------------------------------------------
-//
-
-typedef enum _DXVA_SampleFlags {
- DXVA_SampleFlagsMask = DXVABit(3)|DXVABit(2)|DXVABit(1)|DXVABit(0),
-
- DXVA_SampleFlag_Palette_Changed = 0x0001,
- DXVA_SampleFlag_SrcRect_Changed = 0x0002,
- DXVA_SampleFlag_DstRect_Changed = 0x0004,
- DXVA_SampleFlag_ColorData_Changed = 0x0008,
-} DXVA_SampleFlags;
-
-typedef enum _DXVA_DestinationFlags {
- DXVA_DestinationFlagMask = DXVABit(3)|DXVABit(2)|DXVABit(1)|DXVABit(0),
-
- DXVA_DestinationFlag_Background_Changed = 0x0001,
- DXVA_DestinationFlag_TargetRect_Changed = 0x0002,
- DXVA_DestinationFlag_ColorData_Changed = 0x0004,
- DXVA_DestinationFlag_Alpha_Changed = 0x0008
-} DXVA_DestinationFlags;
-
-
-
-
-typedef struct _DXVA_VideoSample2 {
-#ifdef _WIN64
- DWORD Size;
- DWORD Reserved;
-#endif
- REFERENCE_TIME rtStart;
- REFERENCE_TIME rtEnd;
- DWORD SampleFormat; // cast to DXVA_ExtendedFormat, or use Extract macros
- DWORD SampleFlags;
- VOID* lpDDSSrcSurface;
- RECT rcSrc;
- RECT rcDst;
- DXVA_AYUVsample2 Palette[16];
-} DXVA_VideoSample2, *LPDXVA_VideoSample2;
-
-typedef struct _DXVA_DeinterlaceCaps {
- DWORD Size;
- DWORD NumPreviousOutputFrames;
- DWORD InputPool;
- DWORD NumForwardRefSamples;
- DWORD NumBackwardRefSamples;
- D3DFORMAT d3dOutputFormat;
- DXVA_VideoProcessCaps VideoProcessingCaps;
- DXVA_DeinterlaceTech DeinterlaceTechnology;
-} DXVA_DeinterlaceCaps, *LPDXVA_DeinterlaceCaps;
-
-
-
-
-// -------------------------------------------------------------------------
-// Data types used with RenderMoComp in kernel mode
-// -------------------------------------------------------------------------
-//
-
-// Function codes for RenderMoComp
-
-#define MAX_DEINTERLACE_SURFACES 32
-
-#ifdef _WIN64
-//
-// These structures are used for thunking 32 bit DeinterlaceBltEx calls on
-// 64 bit drivers.
-//
-typedef struct _DXVA_VideoSample32 {
- REFERENCE_TIME rtStart;
- REFERENCE_TIME rtEnd;
- DWORD SampleFormat;
- DWORD SampleFlags;
- DWORD lpDDSSrcSurface; // 32 bit pointer size
- RECT rcSrc;
- RECT rcDst;
- DXVA_AYUVsample2 Palette[16];
- // DWORD Pad;
- // 4 bytes of padding added by the compiler to align the struct to 8 bytes.
-} DXVA_VideoSample32;
-
-typedef struct _DXVA_DeinterlaceBltEx32 {
- DWORD Size;
- DXVA_AYUVsample2 BackgroundColor;
- RECT rcTarget;
- REFERENCE_TIME rtTarget;
- DWORD NumSourceSurfaces;
- FLOAT Alpha;
- DXVA_VideoSample32 Source[MAX_DEINTERLACE_SURFACES];
- DWORD DestinationFormat;
- DWORD DestinationFlags;
-} DXVA_DeinterlaceBltEx32;
-#endif
-
-
-typedef struct _DXVA_DeinterlaceBlt {
- DWORD Size;
- DWORD Reserved;
- REFERENCE_TIME rtTarget;
- RECT DstRect;
- RECT SrcRect;
- DWORD NumSourceSurfaces;
- FLOAT Alpha;
- DXVA_VideoSample Source[MAX_DEINTERLACE_SURFACES];
-} DXVA_DeinterlaceBlt;
-
-#define DXVA_DeinterlaceBltFnCode 0x01
-// lpInput => DXVA_DeinterlaceBlt*
-// lpOuput => NULL /* not currently used */
-
-
-typedef struct _DXVA_DeinterlaceBltEx {
- DWORD Size;
- DXVA_AYUVsample2 BackgroundColor;
- RECT rcTarget;
- REFERENCE_TIME rtTarget;
- DWORD NumSourceSurfaces;
- FLOAT Alpha;
- DXVA_VideoSample2 Source[MAX_DEINTERLACE_SURFACES];
- DWORD DestinationFormat;
- DWORD DestinationFlags;
-} DXVA_DeinterlaceBltEx;
-
-#define DXVA_DeinterlaceBltExFnCode 0x02
-// lpInput => DXVA_DeinterlaceBltEx*
-// lpOuput => NULL /* not currently used */
-
-
-#define MAX_DEINTERLACE_DEVICE_GUIDS 32
-typedef struct _DXVA_DeinterlaceQueryAvailableModes {
- DWORD Size;
- DWORD NumGuids;
- GUID Guids[MAX_DEINTERLACE_DEVICE_GUIDS];
-} DXVA_DeinterlaceQueryAvailableModes;
-
-#define DXVA_DeinterlaceQueryAvailableModesFnCode 0x01
-// lpInput => DXVA_VideoDesc*
-// lpOuput => DXVA_DeinterlaceQueryAvailableModes*
-
-
-typedef struct _DXVA_DeinterlaceQueryModeCaps {
- DWORD Size;
- GUID Guid;
- DXVA_VideoDesc VideoDesc;
-} DXVA_DeinterlaceQueryModeCaps;
-
-#define DXVA_DeinterlaceQueryModeCapsFnCode 0x02
-// lpInput => DXVA_DeinterlaceQueryModeCaps*
-// lpOuput => DXVA_DeinterlaceCaps*
-
-#endif /* __DIRECTX_VA_DEINTERLACE__ */
-
-
-// -------------------------------------------------------------------------
-//
-// The definitions that follow describe the video ProcAmp interface
-// between the VMR and the graphics device driver. This interface is not
-// accessable via the IAMVideoAccelerator interface.
-//
-// -------------------------------------------------------------------------
-//
-#ifndef __DIRECTX_VA_PROCAMPCONTROL__
-#define __DIRECTX_VA_PROCAMPCONTROL__
-
-DEFINE_GUID(DXVA_ProcAmpControlDevice,
- 0x9f200913,0x2ffd,0x4056,0x9f,0x1e,0xe1,0xb5,0x08,0xf2,0x2d,0xcf);
-
-typedef enum _DXVA_ProcAmpControlProp {
- DXVA_ProcAmp_None = 0x0000,
- DXVA_ProcAmp_Brightness = 0x0001,
- DXVA_ProcAmp_Contrast = 0x0002,
- DXVA_ProcAmp_Hue = 0x0004,
- DXVA_ProcAmp_Saturation = 0x0008
-} DXVA_ProcAmpControlProp;
-
-
-typedef struct _DXVA_ProcAmpControlCaps {
- DWORD Size;
- DWORD InputPool;
- D3DFORMAT d3dOutputFormat;
- DWORD ProcAmpControlProps;// see DXVA_ProcAmpControlProp
- DWORD VideoProcessingCaps;// see DXVA_VideoProcessCaps
-} DXVA_ProcAmpControlCaps, *LPDXVA_ProcAmpControlCaps;
-
-#define DXVA_ProcAmpControlQueryCapsFnCode 0x03
-// lpInput => DXVA_VideoDesc*
-// lpOuput => DXVA_ProcAmpControlCaps*
-
-
-typedef struct _DXVA_ProcAmpControlQueryRange {
- DWORD Size;
- DXVA_ProcAmpControlProp ProcAmpControlProp;
- DXVA_VideoDesc VideoDesc;
-} DXVA_ProcAmpControlQueryRange, *LPDXVA_ProcAmpControlQueryRange;
-
-typedef struct _DXVA_VideoPropertyRange {
- FLOAT MinValue;
- FLOAT MaxValue;
- FLOAT DefaultValue;
- FLOAT StepSize;
-} DXVA_VideoPropertyRange, *LPDXVA_VideoPropertyRange;
-
-#define DXVA_ProcAmpControlQueryRangeFnCode 0x04
-// lpInput => DXVA_ProcAmpControlQueryRange*
-// lpOuput => DXVA_VideoPropertyRange*
-
-
-typedef struct _DXVA_ProcAmpControlBlt {
- DWORD Size;
- RECT DstRect;
- RECT SrcRect;
- FLOAT Alpha;
- FLOAT Brightness;
- FLOAT Contrast;
- FLOAT Hue;
- FLOAT Saturation;
-} DXVA_ProcAmpControlBlt;
-
-#define DXVA_ProcAmpControlBltFnCode 0x01
-// lpInput => DXVA_ProcAmpControlBlt*
-// lpOuput => NULL /* not currently used */
-
-#endif /* __DIRECTX_VA_PROCAMPCONTROL__ */
-
-
-// -------------------------------------------------------------------------
-//
-// The definitions that follow describe the Certified Output Protection
-// Protocol between the VMR and the graphics device driver. This interface
-// is not accessable via the IAMVideoAccelerator interface.
-//
-// -------------------------------------------------------------------------
-//
-
-#ifndef __DIRECTX_VA_CERTOUTPUTPROTECT__
-#define __DIRECTX_VA_CERTOUTPUTPROTECT__
-
-
-DEFINE_GUID(DXVA_COPPDevice,
- 0xd2457add,0x8999,0x45ed,0x8a,0x8a,0xd1,0xaa,0x04,0x7b,0xa4,0xd5);
-
-
-// -------------------------------------------------------------------------
-// COPPGetCertificateLength
-// -------------------------------------------------------------------------
-#define DXVA_COPPGetCertificateLengthFnCode 0x01
-// lpInput => NULL
-// lpOuput => DWORD*
-
-
-// -------------------------------------------------------------------------
-// COPPKeyExchange
-// -------------------------------------------------------------------------
-#define DXVA_COPPKeyExchangeFnCode 0x02
-// lpInputData => NULL
-// lpOuputData => GUID*
-
-
-// -------------------------------------------------------------------------
-// COPPSequenceStart
-// -------------------------------------------------------------------------
-typedef struct _DXVA_COPPSignature {
- UCHAR Signature[256];
-} DXVA_COPPSignature, *LPDXVA_COPPSignature;
-
-#define DXVA_COPPSequenceStartFnCode 0x03
-// lpInputData => DXVA_COPPSignature*
-// lpOuputData => NULL
-
-
-
-// -------------------------------------------------------------------------
-// COPPCommand
-// -------------------------------------------------------------------------
-typedef struct _DXVA_COPPCommand {
- GUID macKDI; // 16 bytes
- GUID guidCommandID; // 16 bytes
- ULONG dwSequence; // 4 bytes
- ULONG cbSizeData; // 4 bytes
- UCHAR CommandData[4056]; // 4056 bytes (4056+4+4+16+16 = 4096)
-} DXVA_COPPCommand, *LPDXVA_COPPCommand;
-
-#define DXVA_COPPCommandFnCode 0x04
-// lpInputData => DXVA_COPPCommand*
-// lpOuputData => NULL
-
-
-DEFINE_GUID(DXVA_COPPSetProtectionLevel,
- 0x9bb9327c,0x4eb5,0x4727,0x9f,0x00,0xb4,0x2b,0x09,0x19,0xc0,0xda);
-
-typedef struct _DXVA_COPPSetProtectionLevelCmdData {
- ULONG ProtType;
- ULONG ProtLevel;
- ULONG ExtendedInfoChangeMask;
- ULONG ExtendedInfoData;
-} DXVA_COPPSetProtectionLevelCmdData;
-
-typedef enum _COPP_DPCP_Protection_Level {
- COPP_DPCP_Level0 = 0,
- COPP_DPCP_LevelMin = COPP_DPCP_Level0,
- COPP_DPCP_Level1 = 1,
- COPP_DPCP_LevelMax = COPP_DPCP_Level1,
- COPP_DPCP_ForceDWORD = 0x7fffffff
-} COPP_DPCP_Protection_Level;
-
-// Set the HDCP protection level - (0 - 1 DWORD, 4 bytes)
-
-typedef enum _COPP_HDCP_Protection_Level {
- COPP_HDCP_Level0 = 0,
- COPP_HDCP_LevelMin = COPP_HDCP_Level0,
- COPP_HDCP_Level1 = 1,
- COPP_HDCP_LevelMax = COPP_HDCP_Level1,
- COPP_HDCP_ForceDWORD = 0x7fffffff
-} COPP_HDCP_Protection_Level;
-
-typedef enum _COPP_CGMSA_Protection_Level {
- COPP_CGMSA_Disabled = 0,
- COPP_CGMSA_LevelMin = COPP_CGMSA_Disabled,
- COPP_CGMSA_CopyFreely = 1,
- COPP_CGMSA_CopyNoMore = 2,
- COPP_CGMSA_CopyOneGeneration = 3,
- COPP_CGMSA_CopyNever = 4,
- COPP_CGMSA_RedistributionControlRequired = 0x08,
- COPP_CGMSA_LevelMax = (COPP_CGMSA_RedistributionControlRequired + COPP_CGMSA_CopyNever),
- COPP_CGMSA_ForceDWORD = 0x7fffffff
-} COPP_CGMSA_Protection_Level;
-
-typedef enum _COPP_ACP_Protection_Level {
- COPP_ACP_Level0 = 0,
- COPP_ACP_LevelMin = COPP_ACP_Level0,
- COPP_ACP_Level1 = 1,
- COPP_ACP_Level2 = 2,
- COPP_ACP_Level3 = 3,
- COPP_ACP_LevelMax = COPP_ACP_Level3,
- COPP_ACP_ForceDWORD = 0x7fffffff
-} COPP_ACP_Protection_Level;
-
-#define COPP_NoProtectionLevelAvailable -1
-#define COPP_DefaultProtectionLevel 0
-
-
-//
-// Bit flags of possible protection types. Note that it is possible to apply
-// different protection settings to a single connector.
-//
-enum {
- COPP_ProtectionType_Unknown = 0x80000000,
- COPP_ProtectionType_None = 0x00000000,
- COPP_ProtectionType_HDCP = 0x00000001,
- COPP_ProtectionType_ACP = 0x00000002,
- COPP_ProtectionType_CGMSA = 0x00000004,
- COPP_ProtectionType_DPCP = 0x00000010,
- COPP_ProtectionType_Mask = 0x80000017,
- COPP_ProtectionType_Reserved = 0x7FFFFFF8
-};
-
-DEFINE_GUID(DXVA_COPPSetSignaling,
- 0x9a631a5, 0xd684, 0x4c60, 0x8e, 0x4d, 0xd3, 0xbb, 0xf, 0xb, 0xe3, 0xee);
-
-typedef struct _DXVA_COPPSetSignalingCmdData {
- ULONG ActiveTVProtectionStandard; // See COPP_TVProtectionStandard
- ULONG AspectRatioChangeMask1;
- ULONG AspectRatioData1; // See COPP_ImageAspectRatio_EN300294 for ETSI EN 300 294 values
- ULONG AspectRatioChangeMask2;
- ULONG AspectRatioData2;
- ULONG AspectRatioChangeMask3;
- ULONG AspectRatioData3;
- ULONG ExtendedInfoChangeMask[4];
- ULONG ExtendedInfoData[4];
- ULONG Reserved;
-} DXVA_COPPSetSignalingCmdData;
-
-// Add format enum and data enum
-typedef enum _COPP_TVProtectionStandard {
- COPP_ProtectionStandard_Unknown = 0x80000000,
- COPP_ProtectionStandard_None = 0x00000000,
- COPP_ProtectionStandard_IEC61880_525i = 0x00000001,
- COPP_ProtectionStandard_IEC61880_2_525i = 0x00000002,
- COPP_ProtectionStandard_IEC62375_625p = 0x00000004,
- COPP_ProtectionStandard_EIA608B_525 = 0x00000008,
- COPP_ProtectionStandard_EN300294_625i = 0x00000010,
- COPP_ProtectionStandard_CEA805A_TypeA_525p = 0x00000020,
- COPP_ProtectionStandard_CEA805A_TypeA_750p = 0x00000040,
- COPP_ProtectionStandard_CEA805A_TypeA_1125i = 0x00000080,
- COPP_ProtectionStandard_CEA805A_TypeB_525p = 0x00000100,
- COPP_ProtectionStandard_CEA805A_TypeB_750p = 0x00000200,
- COPP_ProtectionStandard_CEA805A_TypeB_1125i = 0x00000400,
- COPP_ProtectionStandard_ARIBTRB15_525i = 0x00000800,
- COPP_ProtectionStandard_ARIBTRB15_525p = 0x00001000,
- COPP_ProtectionStandard_ARIBTRB15_750p = 0x00002000,
- COPP_ProtectionStandard_ARIBTRB15_1125i = 0x00004000,
- COPP_ProtectionStandard_Mask = 0x80007FFF,
- COPP_ProtectionStandard_Reserved = 0x7FFF8000
-} COPP_TVProtectionStandard;
-
-#define COPP_ImageAspectRatio_EN300294_Mask 0x00000007
-
-typedef enum _COPP_ImageAspectRatio_EN300294 {
- COPP_AspectRatio_EN300294_FullFormat4by3 = 0,
- COPP_AspectRatio_EN300294_Box14by9Center = 1,
- COPP_AspectRatio_EN300294_Box14by9Top = 2,
- COPP_AspectRatio_EN300294_Box16by9Center = 3,
- COPP_AspectRatio_EN300294_Box16by9Top = 4,
- COPP_AspectRatio_EN300294_BoxGT16by9Center = 5,
- COPP_AspectRatio_EN300294_FullFormat4by3ProtectedCenter = 6,
- COPP_AspectRatio_EN300294_FullFormat16by9Anamorphic = 7,
- COPP_AspectRatio_ForceDWORD = 0x7fffffff
-} COPP_ImageAspectRatio_EN300294;
-
-
-// -------------------------------------------------------------------------
-// COPPQueryStatus
-// -------------------------------------------------------------------------
-typedef struct _DXVA_COPPStatusInput {
- GUID rApp; // 16 bytes
- GUID guidStatusRequestID;// 16 bytes
- ULONG dwSequence; // 4 bytes
- ULONG cbSizeData; // 4 bytes
- UCHAR StatusData[4056]; // 4056 bytes (4056+4+4+16+16 = 4096)
-} DXVA_COPPStatusInput, *LPDXVA_COPPStatusInput;
-
-typedef struct _DXVA_COPPStatusOutput {
- GUID macKDI; // 16 bytes
- ULONG cbSizeData; // 4 bytes
- UCHAR COPPStatus[4076]; // 4076 bytes (4076+16+4 = 4096)
-} DXVA_COPPStatusOutput, *LPDXVA_COPPStatusOutput;
-
-typedef enum _COPP_StatusFlags {
- COPP_StatusNormal = 0x00,
- COPP_LinkLost = 0x01,
- COPP_RenegotiationRequired = 0x02,
- COPP_StatusFlagsReserved = 0xFFFFFFFC
-} COPP_StatusFlags;
-
-typedef struct _DXVA_COPPStatusData {
- GUID rApp;
- ULONG dwFlags; // See COPP_StatusFlags above
- ULONG dwData;
- ULONG ExtendedInfoValidMask;
- ULONG ExtendedInfoData;
-} DXVA_COPPStatusData;
-
-typedef struct _DXVA_COPPStatusDisplayData {
- GUID rApp;
- ULONG dwFlags; // See COPP_StatusFlags above
- ULONG DisplayWidth;
- ULONG DisplayHeight;
- ULONG Format; // also contains extended color data
- ULONG d3dFormat;
- ULONG FreqNumerator;
- ULONG FreqDenominator;
-} DXVA_COPPStatusDisplayData;
-
-typedef enum _COPP_StatusHDCPFlags {
- COPP_HDCPRepeater = 0x01,
- COPP_HDCPFlagsReserved = 0xFFFFFFFE
-} COPP_StatusHDCPFlags;
-
-typedef struct _DXVA_COPPStatusHDCPKeyData {
- GUID rApp;
- ULONG dwFlags; // See COPP_StatusFlags above
- ULONG dwHDCPFlags; // See COPP_StatusHDCPFlags above
- GUID BKey; // Lower 40 bits
- GUID Reserved1;
- GUID Reserved2;
-} DXVA_COPPStatusHDCPKeyData;
-
-
-#define DXVA_COPPQueryStatusFnCode 0x05
-// lpInputData => DXVA_COPPStatusInput*
-// lpOuputData => DXVA_COPPStatusOutput*
-
-
-//
-// Status GUID and enumerations
-//
-DEFINE_GUID(DXVA_COPPQueryConnectorType,
- 0x81d0bfd5,0x6afe,0x48c2,0x99,0xc0,0x95,0xa0,0x8f,0x97,0xc5,0xda);
-
-typedef enum _COPP_ConnectorType {
- COPP_ConnectorType_Unknown = -1,
- COPP_ConnectorType_VGA = 0,
- COPP_ConnectorType_SVideo = 1,
- COPP_ConnectorType_CompositeVideo = 2,
- COPP_ConnectorType_ComponentVideo = 3,
- COPP_ConnectorType_DVI = 4,
- COPP_ConnectorType_HDMI = 5,
- COPP_ConnectorType_LVDS = 6,
- COPP_ConnectorType_TMDS = 7,
- COPP_ConnectorType_D_JPN = 8,
- COPP_ConnectorType_SDI = 9,
- COPP_ConnectorType_DisplayPortExternal = 10,
- COPP_ConnectorType_DisplayPortEmbedded = 11,
- COPP_ConnectorType_UDIExternal = 12,
- COPP_ConnectorType_UDIEmbedded = 13,
- COPP_ConnectorType_Internal = 0x80000000, // can be combined with the other connector types
- COPP_ConnectorType_ForceDWORD = 0x7fffffff /* force 32-bit size enum */
-} COPP_ConnectorType;
-
-DEFINE_GUID(DXVA_COPPQueryProtectionType,
- 0x38f2a801,0x9a6c,0x48bb,0x91,0x07,0xb6,0x69,0x6e,0x6f,0x17,0x97);
-
-DEFINE_GUID(DXVA_COPPQueryLocalProtectionLevel,
- 0xb2075857,0x3eda,0x4d5d,0x88,0xdb,0x74,0x8f,0x8c,0x1a,0x05,0x49);
-
-DEFINE_GUID(DXVA_COPPQueryGlobalProtectionLevel,
- 0x1957210a,0x7766,0x452a,0xb9,0x9a,0xd2,0x7a,0xed,0x54,0xf0,0x3a);
-
-DEFINE_GUID(DXVA_COPPQueryDisplayData,
- 0xd7bf1ba3,0xad13,0x4f8e,0xaf,0x98,0x0d,0xcb,0x3c,0xa2,0x04,0xcc);
-
-DEFINE_GUID(DXVA_COPPQueryHDCPKeyData,
- 0xdb59d74, 0xa992, 0x492e, 0xa0, 0xbd, 0xc2, 0x3f, 0xda, 0x56, 0x4e, 0x0);
-
-DEFINE_GUID(DXVA_COPPQueryBusData,
- 0xc6f4d673, 0x6174, 0x4184, 0x8e, 0x35, 0xf6, 0xdb, 0x52, 0x0, 0xbc, 0xba);
-
-typedef enum _COPP_BusType {
- COPP_BusType_Unknown = 0,
- COPP_BusType_PCI = 1,
- COPP_BusType_PCIX = 2,
- COPP_BusType_PCIExpress = 3,
- COPP_BusType_AGP = 4,
- COPP_BusType_Integrated = 0x80000000, // can be combined with the other bus types
- COPP_BusType_ForceDWORD = 0x7fffffff /* force 32-bit size enum */
-} COPP_BusType;
-
-DEFINE_GUID(DXVA_COPPQuerySignaling,
- 0x6629a591, 0x3b79, 0x4cf3, 0x92, 0x4a, 0x11, 0xe8, 0xe7, 0x81, 0x16, 0x71);
-
-typedef struct _DXVA_COPPStatusSignalingCmdData {
- GUID rApp;
- ULONG dwFlags; // See COPP_StatusFlags above
- ULONG AvailableTVProtectionStandards; // See COPP_TVProtectionStandard
- ULONG ActiveTVProtectionStandard; // See COPP_TVProtectionStandard
- ULONG TVType;
- ULONG AspectRatioValidMask1;
- ULONG AspectRatioData1; // See COPP_AspectRatio_EN300294 for ETSI EN 300 294 values
- ULONG AspectRatioValidMask2;
- ULONG AspectRatioData2;
- ULONG AspectRatioValidMask3;
- ULONG AspectRatioData3;
- ULONG ExtendedInfoValidMask[4];
- ULONG ExtendedInfoData[4];
-} DXVA_COPPStatusSignalingCmdData;
-
-
-#endif /* __DIRECTX_VA_CERTOUTPUTPROTECT__ */
-
-#ifdef __cplusplus
-}
-#endif
-
-#ifdef __DXVA1_DEPRECATED_INTERFACES__
-
-#if !defined(__cplusplus)
-#error C++ compiler required.
-#endif
-
-/* IID_IDirect3DVideoDevice9 */
-DEFINE_GUID(IID_IDirect3DVideoDevice9,
-0x694036ac, 0x542a, 0x4a3a, 0x9a, 0x32, 0x53, 0xbc, 0x20, 0x0, 0x2c, 0x1b);
-
-/* IID_IDirect3DDXVADevice9 */
-DEFINE_GUID(IID_IDirect3DDXVADevice9,
-0x9f00c3d3, 0x5ab6, 0x465f, 0xb9, 0x55, 0x9f, 0xe, 0xbb, 0x2c, 0x56, 0x6);
-
-interface IDirect3DVideoDevice9;
-interface IDirect3DDXVADevice9;
-
-typedef struct _DXVAUncompDataInfo
-{
- DWORD UncompWidth; /* Width of uncompressed data */
- DWORD UncompHeight; /* Height of uncompressed data */
- D3DFORMAT UncompFormat; /* Format of uncompressed data */
-} DXVAUncompDataInfo;
-
-typedef struct _DXVACompBufferInfo
-{
- DWORD NumCompBuffers; /* Number of buffers reqd for compressed data */
- DWORD WidthToCreate; /* Width of surface to create */
- DWORD HeightToCreate; /* Height of surface to create */
- DWORD BytesToAllocate; /* Total number of bytes used by each surface */
- DWORD Usage; /* Usage used to create the compressed buffer */
- D3DPOOL Pool; /* Pool where the compressed buffer belongs */
- D3DFORMAT Format; /* Format used to create the compressed buffer */
-} DXVACompBufferInfo;
-
-typedef struct _DXVABufferInfo
-{
- VOID* pCompSurface; /* Pointer to buffer containing compressed data */
- DWORD DataOffset; /* Offset of relevant data from the beginning of buffer */
- DWORD DataSize; /* Size of relevant data */
-} DXVABufferInfo;
-
-#undef INTERFACE
-#define INTERFACE IDirect3DVideoDevice9
-
-DECLARE_INTERFACE_(IDirect3DVideoDevice9, IUnknown)
-{
- /*** IUnknown methods ***/
- STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE;
- STDMETHOD_(ULONG,AddRef)(THIS) PURE;
- STDMETHOD_(ULONG,Release)(THIS) PURE;
-
- /*** IDirect3DVideoDevice9 methods ***/
- STDMETHOD(CreateSurface)(THIS_ UINT Width,UINT Height,UINT BackBuffers,
- D3DFORMAT Format,D3DPOOL Pool,DWORD Usage,
- IDirect3DSurface9** ppSurface,
- HANDLE* pSharedHandle) PURE;
- STDMETHOD(GetDXVACompressedBufferInfo)(THIS_ GUID* pGuid,
- DXVAUncompDataInfo* pUncompData,
- DWORD* pNumBuffers,
- DXVACompBufferInfo* pBufferInfo) PURE;
- STDMETHOD(GetDXVAGuids)(THIS_ DWORD* pNumGuids,GUID* pGuids) PURE;
- STDMETHOD(GetDXVAInternalInfo)(THIS_ GUID* pGuid,
- DXVAUncompDataInfo* pUncompData,
- DWORD* pMemoryUsed) PURE;
- STDMETHOD(GetUncompressedDXVAFormats)(THIS_ GUID* pGuid,
- DWORD* pNumFormats,
- D3DFORMAT* pFormats) PURE;
- STDMETHOD(CreateDXVADevice)(THIS_ GUID* pGuid,
- DXVAUncompDataInfo* pUncompData,
- LPVOID pData,DWORD DataSize,
- IDirect3DDXVADevice9** ppDXVADevice) PURE;
-};
-
-#undef INTERFACE
-#define INTERFACE IDirect3DDXVADevice9
-
-DECLARE_INTERFACE_(IDirect3DDXVADevice9, IUnknown)
-{
- /*** IUnknown methods ***/
- STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE;
- STDMETHOD_(ULONG,AddRef)(THIS) PURE;
- STDMETHOD_(ULONG,Release)(THIS) PURE;
-
- /*** IDirect3DDXVADevice9 methods ***/
- STDMETHOD(BeginFrame)(THIS_ IDirect3DSurface9* pDstSurface,
- DWORD SizeInputData,VOID* pInputData,
- DWORD* pSizeOutputData,VOID* pOutputData) PURE;
- STDMETHOD(EndFrame)(THIS_ DWORD SizeMiscData,VOID* pMiscData) PURE;
- STDMETHOD(Execute)(THIS_ DWORD FunctionNum,VOID* pInputData,
- DWORD InputSize,VOID* OuputData,DWORD OutputSize,
- DWORD NumBuffers,DXVABufferInfo* pBufferInfo) PURE;
- STDMETHOD(QueryStatus)(THIS_ IDirect3DSurface9* pSurface,DWORD Flags) PURE;
-};
-
-#endif /* __DXVA1_DEPRECATED_INTERFACES__ */
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1200)
-#pragma warning(pop)
-#endif
-
-#endif /* __DIRECTX_VA__ */
diff --git a/src/thirdparty/ffmpeg/libavcodec/eac3_data.c b/src/thirdparty/ffmpeg/libavcodec/eac3_data.c
deleted file mode 100644
index f1f2dc71a..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/eac3_data.c
+++ /dev/null
@@ -1,1134 +0,0 @@
-/*
- * E-AC-3 tables
- * Copyright (c) 2007 Bartlomiej Wolowiec <bartek.wolowiec@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
- * Tables taken directly from the E-AC-3 spec.
- */
-
-#include "eac3_data.h"
-#include "ac3.h"
-
-const uint8_t ff_eac3_bits_vs_hebap[20] = {
- 0, 2, 3, 4, 5, 7, 8, 9, 3, 4,
- 5, 6, 7, 8, 9, 10, 11, 12, 14, 16,
-};
-
-/**
- * Table E3.6, Gk=1
- * No gain (Gk=1) inverse quantization, remapping scale factors
- * ff_eac3_gaq_remap[hebap+8]
- */
-const int16_t ff_eac3_gaq_remap_1[12] = {
- 4681, 2185, 1057, 520, 258, 129, 64, 32, 16, 8, 2, 0
-};
-
-/**
- * Table E3.6, Gk=2 & Gk=4, A
- * Large mantissa inverse quantization, remapping scale factors
- * ff_eac3_gaq_remap_2_4_a[hebap-8][Gk=2,4]
- */
-const int16_t ff_eac3_gaq_remap_2_4_a[9][2] = {
- { -10923, -4681 },
- { -14043, -6554 },
- { -15292, -7399 },
- { -15855, -7802 },
- { -16124, -7998 },
- { -16255, -8096 },
- { -16320, -8144 },
- { -16352, -8168 },
- { -16368, -8180 }
-};
-
-/**
- * Table E3.6, Gk=2 & Gk=4, B
- * Large mantissa inverse quantization, negative mantissa remapping offsets
- * ff_eac3_gaq_remap_3_4_b[hebap-8][Gk=2,4]
- */
-const int16_t ff_eac3_gaq_remap_2_4_b[9][2] = {
- { -5461, -1170 },
- { -11703, -4915 },
- { -14199, -6606 },
- { -15327, -7412 },
- { -15864, -7805 },
- { -16126, -7999 },
- { -16255, -8096 },
- { -16320, -8144 },
- { -16352, -8168 }
-};
-
-static const int16_t vq_hebap1[4][6] = {
-{ 7167, 4739, 1106, 4269, 10412, 4820},
-{ -5702, -3187, -14483, -1392, -2027, 849},
-{ 633, 6199, 7009, -12779, -2306, -2636},
-{ -1468, -7031, 7592, 10617, -5946, -3062},
-};
-static const int16_t vq_hebap2[8][6] = {
-{ -12073, 608, -7019, 590, 4000, 869},
-{ 6692, 15689, -6178, -9239, -74, 133},
-{ 1855, -989, 20596, -2920, -4475, 225},
-{ -1194, -3901, -821, -6566, -875, -20298},
-{ -2762, -3181, -4094, -5623, -16945, 9765},
-{ 1547, 6839, 1980, 20233, -1071, -4986},
-{ 6221, -17915, -5516, 6266, 358, 1162},
-{ 3753, -1066, 4283, -3227, 15928, 10186},
-};
-static const int16_t vq_hebap3[16][6] = {
-{ -10028, 20779, 10982, -4560, 798, -68},
-{ 11050, 20490, -6617, -5342, -1797, -1631},
-{ 3977, -542, 7118, -1166, 18844, 14678},
-{ -4320, -96, -7295, -492, -22050, -4277},
-{ 2692, 5856, 5530, 21862, -7212, -5325},
-{ -135, -23391, 962, 8115, -644, 382},
-{ -1563, 3400, -3299, 4693, -6892, 22398},
-{ 3535, 3030, 7296, 6214, 20476, -12099},
-{ 57, -6823, 1848, -22349, -5919, 6823},
-{ -821, -3655, -387, -6253, -1735, -22373},
-{ -6046, 1586, -18890, -14392, 9214, 705},
-{ -5716, 264, -17964, 14618, 7921, -337},
-{ -110, 108, 8, 74, -89, -50},
-{ 6612, -1517, 21687, -1658, -7949, -246},
-{ 21667, -6335, -8290, -101, -1349, -22},
-{ -22003, -6476, 7974, 648, 2054, -331},
-};
-static const int16_t vq_hebap4[32][6] = {
-{ 6636, -4593, 14173, -17297, -16523, 864},
-{ 3658, 22540, 104, -1763, -84, 6},
-{ 21580, -17815, -7282, -1575, -2078, -320},
-{ -2233, 10017, -2728, 14938, -13640, -17659},
-{ -1564, -17738, -19161, 13735, 2757, 2951},
-{ 4520, 5510, 7393, 10799, 19231, -13770},
-{ 399, 2976, -1099, 5013, -1159, 22095},
-{ 3624, -2359, 4680, -2238, 22702, 3765},
-{ -4201, -8285, -6810, -12390, -18414, 15382},
-{ -5198, -6869, -10047, -8364, -16022, -20562},
-{ -142, -22671, -368, 4391, -464, -13},
-{ 814, -1118, -1089, -22019, 74, 1553},
-{ -1618, 19222, -17642, -13490, 842, -2309},
-{ 4689, 16490, 20813, -15387, -4164, -3968},
-{ -3308, 11214, -13542, 13599, -19473, 13770},
-{ 1817, 854, 21225, -966, -1643, -268},
-{ -2587, -107, -20154, 376, 1174, -304},
-{ -2919, 453, -5390, 750, -22034, -978},
-{ -19012, 16839, 10000, -3580, 2211, 1459},
-{ 1363, -2658, -33, -4067, 1165, -21985},
-{ -8592, -2760, -17520, -15985, 14897, 1323},
-{ 652, -9331, 3253, -14622, 12181, 19692},
-{ -6361, 5773, -15395, 17291, 16590, -2922},
-{ -661, -601, 1609, 22610, 992, -1045},
-{ 4961, 9107, 11225, 7829, 16320, 18627},
-{ -21872, -1433, 138, 1470, -1891, -196},
-{ -19499, -18203, 11056, -516, 2543, -2249},
-{ -1196, -17574, 20150, 11462, -401, 2619},
-{ 4638, -8154, 11891, -15759, 17615, -14955},
-{ -83, 278, 323, 55, -154, 232},
-{ 7788, 1462, 18395, 15296, -15763, -1131},
-};
-static const int16_t vq_hebap5[128][6] = {
-{ -3394, -19730, 2963, 9590, 4660, 19673},
-{ -15665, -6405, 17671, 3860, -8232, -19429},
-{ 4467, 412, -17873, -8037, 691, -17307},
-{ 3580, 2363, 6886, 3763, 6379, -20522},
-{ -17230, -14133, -1396, -23939, 8373, -12537},
-{ -8073, -21469, -15638, 3214, 8105, -5965},
-{ 4343, 5169, 2683, -16822, -5146, -16558},
-{ 6348, -10668, 12995, -25500, -22090, 4091},
-{ -2880, -8366, -5968, -17158, -2638, 23132},
-{ -5095, -14281, -22371, 21741, 3689, 2961},
-{ -2443, -17739, 25155, 2707, 1594, 7},
-{ -18379, 9010, 4270, 731, -426, -640},
-{ -23695, 24732, 5642, 612, -308, -964},
-{ -767, 1268, 225, 1635, 173, 916},
-{ 5455, 6493, 4902, 10560, 23041, -17140},
-{ 17219, -21054, -18716, 4936, -3420, 3357},
-{ -1390, 15488, -21946, -14611, 1339, 542},
-{ -6866, -2254, -12070, -3075, -19981, -20622},
-{ -1803, 11775, 1343, 8917, 693, 24497},
-{ -21610, 9462, 4681, 9254, -7815, 15904},
-{ -5559, -3018, -9169, -1347, -22547, 12868},
-{ -366, 5076, -1727, 20427, -283, -2923},
-{ -1886, -6313, -939, -2081, -1399, 3513},
-{ -3161, -537, -5075, 11268, 19396, 989},
-{ 2345, 4153, 5769, -4273, 233, -399},
-{ -21894, -1138, -16474, 5902, 5488, -3211},
-{ 10007, -12530, 18829, 20932, -1158, 1790},
-{ -1165, 5014, -1199, 6415, -8418, -21038},
-{ 1892, -3534, 3815, -5846, 16427, 20288},
-{ -2664, -11627, -4147, -18311, -22710, 14848},
-{ 17256, 10419, 7764, 12040, 18956, 2525},
-{ -21419, -18685, -10897, 4368, -7051, 4539},
-{ -1574, 2050, 5760, 24756, 15983, 17678},
-{ -538, -22867, 11067, 10301, 385, 528},
-{ -8465, -3025, -16357, -23237, 16491, 3654},
-{ 5840, 575, 11890, 1947, 25157, 6653},
-{ 6625, -3516, -1964, 3850, -390, -116},
-{ 18005, 20900, 14323, -7621, -10922, 11802},
-{ -4857, -2932, -13334, -7815, 21622, 2267},
-{ -579, -9431, -748, -21321, 12367, 8265},
-{ -8317, 1375, -17847, 2921, 9062, 22046},
-{ 18398, 8635, -1503, -2418, -18295, -14734},
-{ -2987, 15129, -3331, 22300, 13878, -13639},
-{ 5874, -19026, 15587, 11350, -20738, 1971},
-{ 1581, -6955, -21440, 2455, 65, 414},
-{ 515, -4468, -665, -4672, 125, -19222},
-{ 21495, -20301, -1872, -1926, -211, -1022},
-{ 5189, -12250, -1775, -23550, -4546, 5813},
-{ 321, -6331, 14646, 6975, -1773, 867},
-{ -13814, 3180, 7927, 444, 19552, 3146},
-{ -6660, 12252, -1972, 17408, -24280, -12956},
-{ -745, 14356, -1107, 23742, -9631, -18344},
-{ 18284, -7909, -7531, 19118, 7721, -12659},
-{ 1926, 15101, -12848, 2153, 21631, 1864},
-{ -2130, 23416, 17056, -15597, -1544, 87},
-{ 8314, -11824, 14581, -20591, 7891, -2099},
-{ 19600, 22814, -17304, -2040, 285, -3863},
-{ -8214, -18322, 10724, -13744, -13469, -1666},
-{ 14351, 4880, -20034, 964, -4221, -180},
-{ -24598, -16635, 19724, 5925, 4777, 4414},
-{ -2495, 23493, -16141, 2918, -1038, -2010},
-{ 18974, -2540, 13343, 1405, -6194, -1136},
-{ 2489, 13670, 22638, -7311, -129, -2792},
-{ -13962, 16775, 23012, 728, 3397, 162},
-{ 3038, 993, 8774, -21969, -6609, 910},
-{ -12444, -22386, -2626, -5295, 19520, 9872},
-{ -1911, -18274, -18506, -14962, 4760, 7119},
-{ 8298, -2978, 25886, 7660, -7897, 1020},
-{ 6132, 15127, 18757, -24370, -6529, -6627},
-{ 7924, 12125, -9459, -23962, 5502, 937},
-{ -17056, -5373, 2522, 327, 1129, -390},
-{ 15774, 19955, -10380, 11172, -3107, 14853},
-{ -11904, -8091, -17928, -22287, -17237, -6803},
-{ -12862, -2172, -6509, 5927, 12458, -22355},
-{ -497, 322, 1038, -6643, -5404, 20311},
-{ 1083, -22984, -8494, 12130, -762, 2623},
-{ 5067, 19712, -1901, -30, -325, 85},
-{ 987, -5830, 4212, -9030, 9121, -25038},
-{ -7868, 7284, -12292, 12914, -21592, 20941},
-{ -1630, -7694, -2187, -8525, -5604, -25196},
-{ -6668, 388, -22535, 1526, 9082, 193},
-{ -7867, -22308, 5163, 362, 944, -259},
-{ 3824, -11850, 7591, -23176, 25342, 23771},
-{ -10504, 4123, -21111, 21173, 22439, -838},
-{ -4723, 21795, 6184, -122, 1642, -717},
-{ 24504, 19887, -2043, 986, 7, -55},
-{ -27313, -135, 2437, 259, 89, 307},
-{ 24446, -3873, -5391, -820, -2387, 361},
-{ 5529, 5784, 18682, 242, -21896, -4003},
-{ 22304, 4483, 722, -12242, 7570, 15448},
-{ 8673, 3009, 20437, 21108, -21100, -3080},
-{ -1132, 2705, -1825, 5420, -785, 18532},
-{ 16932, -13517, -16509, -14858, -20327, -14221},
-{ 2219, 1380, 21474, -1128, 327, 83},
-{ -2177, 21517, -3856, -14180, -204, -2191},
-{ 953, -9426, 15874, -10710, -3231, 21030},
-{ -421, -1377, 640, -8239, -20976, 2174},
-{ 4309, 18514, -9100, -18319, -15518, 3704},
-{ -5943, 449, -8387, 1075, -22210, -4992},
-{ 2953, 12788, 18285, 1430, 14937, 21731},
-{ -2913, 401, -4739, -20105, 1699, -1147},
-{ 3449, 5241, 8853, 22134, -7547, 1451},
-{ -2154, 8584, 18120, -15614, 19319, -5991},
-{ 3501, 2841, 5897, 6397, 8630, 23018},
-{ 2467, 2956, 379, 5703, -22047, -2189},
-{ -16963, -594, 18822, -5295, 1640, 774},
-{ 2896, -1424, 3586, -2292, 19910, -1822},
-{ -18575, 21219, -14001, -12573, 16466, 635},
-{ -1998, -19314, -16527, 12208, -16576, -7854},
-{ -9674, 1012, -21645, 2883, -12712, 2321},
-{ -1005, 471, -3629, 8045, -11087, 25533},
-{ 4141, -21472, -2673, 756, -663, -523},
-{ 6490, 8531, 19289, 18949, 6092, -9347},
-{ 16965, 24599, 14024, 10072, -536, -10438},
-{ -8147, 2145, -23028, -17073, 5451, -4401},
-{ -14873, 20520, -18303, -9717, -11885, -17831},
-{ -2290, -14120, 2070, 22467, 1671, 725},
-{ -8538, 14629, 3521, -20577, 6673, 8200},
-{ 20248, 4410, -1366, -585, 1229, -2449},
-{ 7467, -7148, 13667, -8246, 22392, -17320},
-{ -1932, 3875, -9064, -3812, 958, 265},
-{ -4399, 2959, -15911, 19598, 4954, -1105},
-{ 18009, -9923, -18137, -3862, 11178, 5821},
-{ -14596, -1227, 9660, 21619, 11228, -11721},
-{ -721, -1700, 109, -2142, 61, -6772},
-{ -24619, -22520, 5608, -1957, -1761, -1012},
-{ -23728, -4451, -2688, -14679, -4266, 9919},
-{ 8495, -894, 20438, -13820, -17267, 139},
-};
-static const int16_t vq_hebap6[256][6] = {
-{ 10154, 7365, 16861, 18681, -22893, -3636},
-{ -2619, -3788, -5529, -5192, -9009, -20298},
-{ -5583, -22800, 21297, 7012, 745, 720},
-{ 428, -1459, 109, -3082, 361, -8403},
-{ 8161, 22401, 241, 1755, -874, -2824},
-{ 1140, 12643, 2306, 22263, -25146, -17557},
-{ -2609, 3379, 10337, -19730, -15468, -23944},
-{ -4040, -12796, -25772, 13096, 3905, 1315},
-{ 4624, -23799, 13608, 25317, -1175, 2173},
-{ -97, 13747, -5122, 23255, 4214, -22145},
-{ 6878, -322, 18264, -854, -11916, -733},
-{ 17280, -12669, -9693, 23563, -16240, -1309},
-{ 5802, -4968, 19526, -21194, -24622, -183},
-{ 5851, -16137, 15229, -9496, -1538, 377},
-{ 14096, 25057, 13419, 8290, 23320, 16818},
-{ -7261, 118, -15867, 19097, 9781, -277},
-{ -4288, 21589, -13288, -16259, 16633, -4862},
-{ 4909, -19217, 23411, 14705, -722, 125},
-{ 19462, -4732, -1928, -11527, 20770, 5425},
-{ -27562, -2881, -4331, 384, -2103, 1367},
-{ -266, -9175, 5441, 26333, -1924, 4221},
-{ -2970, -20170, -21816, 5450, -7426, 5344},
-{ -221, -6696, 603, -9140, 1308, -27506},
-{ 9621, -8380, -1967, 9403, -1651, 22817},
-{ 7566, -5250, -4165, 1385, -990, 560},
-{ -1262, 24738, -19057, 10741, 7585, -7098},
-{ 451, 20130, -9949, -6015, -2188, -1458},
-{ 22249, 9380, 9096, 10959, -2365, -3724},
-{ 18668, -650, -1234, 11092, 7678, 5969},
-{ 19207, -1485, -1076, -731, -684, 43},
-{ -4973, 13430, 20139, 60, 476, -935},
-{ -20029, 8710, 2499, 1016, -1158, 335},
-{ -26413, 18598, -2201, -669, 3409, 793},
-{ -4726, 8875, -24607, -9646, 3643, -283},
-{ 13303, -21404, -3691, -1184, -1970, 1612},
-{ 173, 60, 919, 1229, 6942, -665},
-{ 16377, 16991, 5341, -14015, -2304, -20390},
-{ 25334, -10609, 11947, -7653, -6363, 14058},
-{ 23929, -13259, -7226, -937, 234, -187},
-{ 6311, -1877, 12506, -1879, 18751, -23341},
-{ 621, 6445, 3354, -24274, 8406, 5315},
-{ -3297, -5034, -4704, -5080, -25730, 5347},
-{ -1275, -13295, -965, -23318, 1214, 26259},
-{ -6252, 10035, -20105, 15301, -16073, 5136},
-{ 9562, -3911, -19510, 4745, 22270, -4171},
-{ 7978, -19600, 14024, -5745, -20855, 8939},
-{ 7, -4039, 991, -6065, 52, -19423},
-{ 3485, 2969, 7732, 7786, 25312, 6206},
-{ -959, -12812, -1840, -22743, 7324, 10830},
-{ -4686, 1678, -10172, -5205, 4294, -1271},
-{ 3889, 1302, 7450, 638, 20374, -3133},
-{ -12496, -9123, 18463, -12343, -7238, 18552},
-{ -6185, 8649, -6903, -895, 17109, 16604},
-{ -9896, 28579, 2845, 1640, 2925, -298},
-{ 14968, -25988, 14878, -24012, 1815, -6474},
-{ 26107, 5166, 21225, 15873, 21617, 14825},
-{ -21684, 16438, 20504, -14346, -7114, -4162},
-{ 28647, 90, -1572, 789, -902, -75},
-{ -1479, 2471, -4061, 3612, -2240, 10914},
-{ 8616, 17491, 17255, -17456, 17022, -16357},
-{ -20722, -18597, 25274, 17720, -3573, 1695},
-{ -997, 6129, -6303, 11250, -11359, -19739},
-{ -74, -4001, -1584, 13384, 162, -144},
-{ -529, 21068, 7923, -11396, 422, -26},
-{ 7102, -13531, -20055, 2629, -178, -429},
-{ 9201, 1368, -22238, 2623, -20499, 24889},
-{ -432, 6675, -266, 8723, 80, 28024},
-{ 19493, -3108, -9261, 1910, -21777, 5345},
-{ 14079, -11489, 12604, 6079, 19877, 1315},
-{ 10947, 9837, -18612, 15742, 4792, 605},
-{ -1777, 3758, -4087, 21696, 6024, -576},
-{ 3567, -3578, 16379, 2680, -1752, 716},
-{ -5049, -1399, -4550, -652, -17721, -3366},
-{ -3635, -4372, -6522, -22152, 7382, 1458},
-{ 12242, 19190, 5646, -7815, -20289, 21344},
-{ -7508, 19952, 23542, -9753, 5669, -1990},
-{ -2275, 15438, 10907, -17879, 6497, 13582},
-{ -15894, -15646, -4716, 6019, 24250, -6179},
-{ -2049, -6856, -1208, 918, 17735, -69},
-{ -3721, 9099, -16065, -23621, 5981, -2344},
-{ 7862, -8918, 24033, 25508, -11033, -741},
-{ -12588, 19468, 14649, 15451, -21226, 1171},
-{ 2102, 1147, 2789, 4096, 2179, 8750},
-{ -18214, -17758, -10366, -5203, -1066, -3541},
-{ -2819, -19958, -11921, 6032, 8315, 10374},
-{ -9078, -2100, 19431, -17, 732, -689},
-{ -14512, -19224, -7095, 18727, 1870, 22906},
-{ 3912, 659, 25597, -4006, 9619, 877},
-{ 2616, 22695, -5770, 17920, 3812, 20220},
-{ 2561, 26847, -5245, -10908, 2256, -517},
-{ -4974, 198, -21983, -3608, 22174, -18924},
-{ 21308, -1211, 19144, 16691, -1588, 11390},
-{ -1790, 3959, -3488, 7003, -7107, 20877},
-{ -6108, -17955, -18722, 24763, 16508, 3211},
-{ 20462, -24987, -20361, 4484, -5111, -478},
-{ -6378, -1998, -10229, -561, -22039, -22339},
-{ 3047, -18850, 7586, 14743, -19862, 6351},
-{ -5047, 1405, -9672, 1055, -21881, 11170},
-{ 3481, -9699, 6526, -16655, 22813, 21907},
-{ -18570, 17501, 14664, 1291, 5026, 19676},
-{ 16134, -19810, -16956, -17939, -16933, 5800},
-{ -8224, 4908, 8935, 2272, -1140, -23217},
-{ 1572, 2753, -1598, 2143, -3346, -21926},
-{ -9832, -1060, -27818, 1214, 7289, 150},
-{ 98, 1538, 535, 17429, -23198, -901},
-{ 21340, -20146, 3297, -1744, -8207, -21462},
-{ -4166, -4633, -17902, 5478, 1285, 136},
-{ 18713, 21003, 24818, 11421, 1282, -4618},
-{ -3535, 7636, -265, 2141, -829, -2035},
-{ -3184, 19713, 2775, -2, 1090, 104},
-{ -6771, -20185, 2938, -2125, -36, 1268},
-{ 9560, 9430, 9586, 22100, 13827, 6296},
-{ -535, -20018, 4276, -1868, -448, -17183},
-{ -24352, 14244, -13647, -21040, 2271, 11555},
-{ -2646, 15437, -4589, 18638, -4299, -622},
-{ -20064, 4169, 18115, -1404, 13722, -1825},
-{ -16359, 9080, 744, 22021, 125, 10794},
-{ 9644, -14607, -18479, -14714, 11174, -20754},
-{ -326, -23762, 6144, 7909, 602, 1540},
-{ -6650, 6634, -12683, 21396, 20785, -6839},
-{ 4252, -21043, 5628, 18687, 23860, 8328},
-{ 17986, 5704, -5245, -18093, -555, 3219},
-{ 6091, 14232, -5117, -17456, -19452, -11649},
-{ -21586, 11302, 15434, 25590, 6777, -26683},
-{ 21355, -8244, 5877, -3540, 6079, -2567},
-{ 2603, -2455, 5421, -12286, -19100, 5574},
-{ -1721, -26393, -23664, 22904, -349, 3787},
-{ 2189, -1203, 5340, 3249, -22617, 104},
-{ -1664, -11020, -2857, -20723, -24049, 19900},
-{ 22873, -7345, -18481, -14616, -8400, -12965},
-{ 3777, 3958, 8239, 20494, -6991, -1201},
-{ -160, -1613, -793, -8681, 573, 776},
-{ 4297, -3786, 20373, 6082, -5321, -18400},
-{ 18745, 2463, 12546, -7749, -7734, -2183},
-{ 11074, -4720, 22119, 1825, -24351, 4080},
-{ 1503, -19178, -1569, 13, -313, 375},
-{ 318, -575, 2544, 178, 102, 40},
-{ -15996, -26897, 5008, 3320, 686, 1159},
-{ 25755, 26886, 574, -5930, -3916, 1407},
-{ -9148, -7665, -2875, -8384, -18663, 26400},
-{ -7445, -18040, -18396, 8802, -2252, -21886},
-{ 7851, 11773, 27485, -12847, -1410, 19590},
-{ 2240, 5947, 11247, 15980, -6499, 24280},
-{ 21673, -18515, 9771, 6550, -2730, 334},
-{ -4149, 1576, -11010, 89, -24429, -5710},
-{ 7720, 1478, 21412, -25025, -8385, 9},
-{ -2448, 10218, -12756, -16079, 1161, -21284},
-{ -8757, -14429, -22918, -14812, 2629, 13844},
-{ -7252, 2843, -9639, 2882, -14625, 24497},
-{ -674, -6530, 414, -23333, -21343, 454},
-{ 2104, -6312, 10887, 18087, -1199, 175},
-{ -493, -562, -2739, 118, -1074, 93},
-{ -10011, -4075, -28071, 22180, 15077, -636},
-{ -4637, -16408, -9003, -20418, -11608, -20932},
-{ 4815, 15892, 24238, -13634, -3074, -1059},
-{ -6724, 4610, -18772, -15283, -16685, 23988},
-{ 15349, -674, -3682, 21679, 4475, -12088},
-{ 4756, 2593, 5354, 6001, 15063, 26490},
-{ -23815, -17251, 6944, 378, 694, 670},
-{ 23392, -8839, -14713, 7544, -876, 11088},
-{ 3640, 3336, 22593, -3495, -2328, -113},
-{ 284, 6914, 3097, 10171, 6638, -18621},
-{ 2472, 5976, 11054, -11936, -603, -663},
-{ 16175, 16441, 13164, -4043, 4667, 7431},
-{ 19338, 15534, -6533, 1681, -4857, 17048},
-{ 17027, 532, -19064, -1441, -5130, 1085},
-{ -12617, -17609, 2062, -25332, 19009, -16121},
-{ 10056, -21000, -13634, -2949, 15367, 19934},
-{ -648, -1605, 10046, -1592, 13296, 19808},
-{ -1054, 10744, 538, 24938, 9630, -9052},
-{ -10099, 3042, -25076, -24052, 13971, 100},
-{ 6547, 6907, 7031, 10348, 23775, -17886},
-{ -22793, -1984, -1393, -3330, 9267, 14317},
-{ -14346, -3967, 3042, 16254, -17303, 9646},
-{ -21393, 23628, 16773, 716, 2663, 114},
-{ -19016, -3038, 1574, -245, 1463, -793},
-{ 22410, 23441, -14637, -530, 17310, 13617},
-{ -11582, 7935, -13954, 23465, -24628, 26550},
-{ -1045, 3679, -2218, 10572, 20999, -3702},
-{ -15513, 197, 16718, -24603, 4945, 5},
-{ 10781, 4335, 26790, -9059, -16152, -2840},
-{ 16075, -24100, -3933, -6833, 12645, -7029},
-{ 2096, -25572, -8370, 6814, 11, 1178},
-{ -11848, -583, -8889, -20543, -10471, -380},
-{ -2487, 24777, -21639, -19341, 1660, -732},
-{ 2313, 13679, 4085, 24549, 24691, -21179},
-{ -2366, -504, -4130, -10570, 23668, 1961},
-{ 20379, 17809, -9506, 3733, -18954, -6292},
-{ -3856, 16802, -929, -20310, -17739, 6797},
-{ 12431, 6078, -11272, -14450, 6913, 23476},
-{ 7636, -1655, 23017, 10719, -8292, 838},
-{ -8559, -1235, -18096, 3897, 16093, 1490},
-{ -3586, 8276, 15165, -3791, -21149, 1741},
-{ -4497, 21739, 2366, -278, -4792, 15549},
-{ -23122, -13708, 7668, 16232, 24120, 15025},
-{ -20043, 12821, -20160, 16691, -11655, -16081},
-{ -12601, 20239, 3496, -2549, -6745, -11850},
-{ 4441, 7812, 20783, 17080, 11523, -9643},
-{ 24766, 8494, -23298, -3262, 11101, -7120},
-{ -10107, -7623, -22152, -18303, 26645, 9550},
-{ -25549, 477, 7874, -1538, 1123, -168},
-{ 470, 9834, -347, 23945, -10381, -9467},
-{ -4096, -9702, -6856, -21544, 20845, 7174},
-{ 5370, 9748, -23765, -1190, 512, -1538},
-{ -1006, -10046, -12649, 19234, -1790, -890},
-{ 15108, 23620, -15646, -2522, -1203, -1325},
-{ -7406, -2605, 1095, -247, -473, 177},
-{ 8089, 4, 12424, -22284, 10405, -7728},
-{ 22196, 10775, -5043, 690, 534, -212},
-{ -3153, -1418, -16835, 18426, 15821, 22956},
-{ 5681, -2229, 3196, -3414, -21817, -14807},
-{ 19, 787, 1032, 170, -8295, -645},
-{ -882, -2319, -27105, 432, -4392, 1499},
-{ -1354, -11819, -76, -20380, -10293, 11328},
-{ 211, -4753, -4675, -6933, -13538, 14479},
-{ 6043, 5260, -459, -462, 143, -65},
-{ -2572, 7256, -3317, 9212, -23184, -9990},
-{ -24882, -9532, 18874, 6101, 2429, -14482},
-{ 8314, 2277, 14192, 3512, 25881, 22000},
-{ 208, 20218, -281, -24778, -63, -1183},
-{ 1095, -6034, 2706, -21935, -2655, 563},
-{ 23, -5930, 243, -8989, 5345, 20558},
-{ -15466, 12699, 4160, 11087, 20621, -10416},
-{ 20995, -85, -8468, 194, 1003, -9515},
-{ -19637, -3335, -14081, 3574, -23381, -667},
-{ -2076, 3489, -3192, -19367, 539, -1530},
-{ 7352, -15213, 22596, 19369, 1043, 16627},
-{ -1872, -413, 1235, -5276, -3550, 21903},
-{ 7931, -2008, 16968, -6799, 29393, -2475},
-{ -13589, 8389, -23636, -22091, -14178, -14297},
-{ -11575, -20090, 16056, -1848, 15721, 4500},
-{ 3849, -16581, 20161, -21155, 7778, 11864},
-{ -6547, -1273, -18837, -11218, 11636, 1044},
-{ 2528, -6691, -17917, -11362, -4894, -1008},
-{ 1241, 4260, 2319, 6111, 3485, 20209},
-{ 3014, -3048, 5316, -4539, 20831, 8702},
-{ -1790, -14683, 278, 13956, -10065, -10547},
-{ -22732, -7957, -1154, 13821, -1484, -1247},
-{ -7317, -615, 13094, 18927, 9897, 1452},
-{ 2552, -2338, 3424, -4630, 11124, -19584},
-{ -11125, -20553, -10855, -10783, -20767, 6833},
-{ 984, -15095, 5775, 25125, 5377, -19799},
-{ 517, 13272, -7458, -1711, 20612, -6013},
-{ -21417, 13251, -20795, 13449, 17281, 13104},
-{ -15811, -16248, 23093, -4037, -8195, 871},
-{ 582, 12571, -21129, -14766, -9187, 5685},
-{ 4318, -1776, 11425, -17763, -9921, 577},
-{ 6013, 16830, 17655, -25766, -4400, -3550},
-{ -13744, -16541, 3636, -3330, -21091, -15886},
-{ 6565, -11147, 8649, -13114, 23345, -13565},
-{ -2542, -9046, -7558, 29240, 3701, -383},
-{ -10612, 24995, 1893, -8210, 20920, -16210},
-{ 5276, 16726, 10659, 19940, -4799, -19324},
-{ -532, -9300, 27856, 4965, -241, 536},
-{ -765, -20706, -3412, 18870, 2765, 1420},
-{ -3059, 2708, -19022, -331, 3537, 116},
-};
-static const int16_t vq_hebap7[512][6] = {
-{ -21173, 21893, 10390, 13646, 10718, -9177},
-{ -22519, -8193, 18328, -6629, 25518, -10848},
-{ 6800, -13758, -13278, 22418, 14667, -20938},
-{ 2347, 10516, 1125, -3455, 5569, 27136},
-{ -6617, 11851, -24524, 22937, 20362, -6019},
-{ -21768, 10681, -19615, -15021, -8478, -2081},
-{ -2745, 8684, -4895, 27739, 7554, -11961},
-{ -1020, 2460, -954, 4754, -627, -16368},
-{ -19702, 23097, 75, -13684, -2644, 2108},
-{ 4049, -2872, 5851, -4459, 22150, 12560},
-{ -21304, -17129, -730, 7419, -11658, -10523},
-{ 11332, 1792, 26666, 23518, -19561, -491},
-{ -17827, -16777, -13606, -14389, -22029, -2464},
-{ 1091, -5967, -7975, -16977, -20432, -21931},
-{ 18388, -1103, 1933, 13342, -17463, 18114},
-{ 22646, 17345, -9966, 17919, 18274, 698},
-{ 1484, 20297, -5754, -26515, 4941, -22263},
-{ -2603, 4587, -5842, 18464, 8767, -2568},
-{ -2797, -1602, 21713, 3099, -25683, 3224},
-{ -19027, 4693, -5007, 6060, 1972, -15095},
-{ -2189, 9516, -530, 20669, -4662, -8301},
-{ -22325, -8887, 2529, -11352, 5476, 998},
-{ 22100, -5052, 1651, -2657, 4615, 2319},
-{ 20855, -3078, -3330, 4105, 13470, 3069},
-{ 85, 17289, 10264, -14752, 214, 90},
-{ -26365, -18849, -19352, 19244, -10218, 9909},
-{ -9739, 20497, -6579, -6983, 2891, -738},
-{ 20575, -15860, -22913, 6870, 76, 327},
-{ 8744, -12877, -22945, -2372, -19424, -9771},
-{ -12886, 16183, 21084, 3821, 749, -13792},
-{ -15995, 18399, 2391, -17661, 19484, -6018},
-{ 1423, 11734, 4051, 19290, 6857, -19681},
-{ -5200, 9766, 18246, 2463, 18764, -4852},
-{ -597, 19498, 1323, -9096, -308, -1104},
-{ -3099, -25731, -15665, 25332, 4634, 2635},
-{ 19623, -2384, -7913, 11796, -9333, -14084},
-{ 2642, 26453, -21091, -10354, -1693, -1711},
-{ 22031, 21625, 11580, -22915, -4141, 129},
-{ -6122, 3542, 915, -261, -17, -383},
-{ 1696, 6704, -1425, 20838, 857, -4416},
-{ 1423, -15280, -8550, -9667, 5210, 5687},
-{ -4520, -613, -11683, 5618, 4230, 619},
-{ 937, -4963, -14102, -17104, -6906, -5952},
-{ -15068, -481, -7237, -14894, 18876, 21673},
-{ -25658, 2910, 1143, -327, -458, -995},
-{ -9656, -819, -24900, 2804, 20225, 1083},
-{ -1111, -3682, -1788, -19492, 966, 821},
-{ 7293, -21759, 10790, -7059, -23293, -1723},
-{ -282, -11093, 170, -20950, -28926, 12615},
-{ 17938, 3713, -1563, 885, 5, 564},
-{ 6116, 22696, 2242, -6951, 9975, -6132},
-{ 4338, 26808, -3705, 1976, -1079, -2570},
-{ -661, -7901, -2668, -15194, 17722, 4375},
-{ -4174, -11053, 717, -22506, 1562, 12252},
-{ -6405, 18334, 6103, 6983, 5956, 18195},
-{ 9851, 5370, 23604, -6861, -6569, -62},
-{ 21964, 13359, -683, 3785, 2168, 209},
-{ -3569, -1127, -19724, -1544, 1308, -803},
-{ -3083, 16049, -13791, -3077, 4294, 23713},
-{ -9999, 9943, -15872, 12934, -23631, 21699},
-{ 9722, 22837, 12192, 15091, 5533, 4837},
-{ 2243, 2099, 1243, 4089, 4748, 12956},
-{ 4007, -2468, 3353, -3092, 8843, 17024},
-{ 4330, 6127, 5549, 9249, 11226, 28592},
-{ -9586, -8825, 236, 1009, 455, -964},
-{ 6829, 19290, -1018, 200, 1821, 578},
-{ 5196, 957, 10372, 3330, -12800, -127},
-{ -3022, -8193, -14557, 22061, 5920, 1053},
-{ 10982, 25942, -24546, -23278, -11905, -6789},
-{ 22667, -11010, 5736, 2567, 23705, -10253},
-{ -3343, -4233, -5458, 20667, -10843, -3605},
-{ -4131, -3612, 4575, -829, -350, -847},
-{ -3303, 3451, -7398, -11604, 3023, 455},
-{ 3200, -9547, 3202, -22893, 11184, -26466},
-{ -14093, -4117, 15382, 14295, -10915, -20377},
-{ 3807, -11016, 22052, 14370, -15328, -7733},
-{ -6291, -17719, -1560, 12048, -19805, -443},
-{ -6147, -4234, -160, 8363, 22638, 11911},
-{ 19197, 1175, 7422, -9875, -4136, 4704},
-{ -72, -7652, -112, -11955, -3230, 27175},
-{ 3274, 5963, 7501, -17019, 866, -25452},
-{ 737, 1861, 1833, 2022, 2384, 4755},
-{ -5217, 7512, 3323, 2715, 3065, -1606},
-{ 4247, 565, 5629, 2497, 18019, -4920},
-{ -2833, -17920, -8062, 15738, -1018, 2136},
-{ 3050, -19483, 16930, 29835, -10222, 15153},
-{ -11346, 118, -25796, -13761, 15320, -468},
-{ -4824, 4960, -4263, 1575, -10593, 19561},
-{ -8203, -1409, -763, -1139, -607, 1408},
-{ -2203, -11415, 2021, -6388, -2600, 711},
-{ -413, -2511, -216, -3519, -28267, 1719},
-{ -14446, 17050, 13917, 13499, -25762, -16121},
-{ 19228, 7341, -12301, 682, -3791, -199},
-{ -4193, 20746, -15651, 11349, 5860, -824},
-{ -21490, -3546, -3, -1705, -3959, 9213},
-{ 15445, -1876, 2012, -19627, 16228, -4845},
-{ -2867, -3733, -7354, -175, -20119, 11174},
-{ -3571, -24587, 19700, 6654, 979, -654},
-{ 21820, -7430, -6639, -10767, -8362, 15543},
-{ 14827, 17977, -7204, -3409, 1906, -17288},
-{ 3525, -3947, -1415, -2798, 17648, 2082},
-{ -6580, -15255, -17913, 1337, 15338, 21158},
-{ 6210, 9698, 15155, -24666, -22507, -3999},
-{ -1740, -593, 1095, -7779, 25058, 5601},
-{ 21415, -432, -1658, -6898, -1438, -14454},
-{ -6943, 700, -12139, -745, -24187, 22466},
-{ 6287, 3283, 11006, 3844, 19184, 14781},
-{ -22502, 15274, 5443, -2808, -970, -3343},
-{ 3257, -3708, 4744, -8301, 22814, -10208},
-{ 24346, -20970, 19846, 987, -11958, -6277},
-{ 3906, -19701, 13060, -1609, 18641, 7466},
-{ -26409, -22549, 16305, 2014, 10975, 18032},
-{ -7039, 4655, -14818, 18739, 15789, 1296},
-{ 9310, -1681, 14667, -3326, 26535, -11853},
-{ 5728, 5917, 13400, 10020, -2236, -24704},
-{ 1741, -6727, 12695, -22009, 4080, 5450},
-{ -2621, 9393, 21143, -25938, -3162, -2529},
-{ 20672, 18894, -13939, 6990, -8260, 15811},
-{ -23818, 11183, -13639, 11868, 16045, 2630},
-{ 18361, -10220, 829, 856, -1010, 157},
-{ 14400, -4678, 5153, -13290, -27434, -11028},
-{ 21613, 11256, 17453, 7604, 13130, -484},
-{ 7, 1236, 573, 4214, 5576, -3081},
-{ 916, -9092, 1285, -8958, 1185, -28699},
-{ 21587, 23695, 19116, -2885, -14282, -8438},
-{ 23414, -6161, 12978, 3061, -9351, 2236},
-{ -3070, -7344, -20140, 5788, 582, -551},
-{ -3993, 315, -7773, 8224, -28082, -12465},
-{ 13766, -15357, 19205, -20624, 13043, -19247},
-{ 3777, -177, 8029, -1001, 17812, 5162},
-{ -7308, -4327, -18096, -620, -1350, 14932},
-{ 14756, -1221, -12819, -14922, -547, 27125},
-{ 2234, 1708, 2764, 5416, 7986, -25163},
-{ 2873, 3636, 3992, 5344, 10142, 21259},
-{ 1158, 5379, 508, -10514, 290, -1615},
-{ 1114, 24789, 16575, -25168, -298, -2832},
-{ -1107, -6144, -1918, -7791, -2971, -23276},
-{ 4016, 10793, 17317, -4342, -20982, -3383},
-{ -4494, -207, -9951, -3575, 7947, 1154},
-{ -7576, 8117, -14047, 16982, -26457, -27540},
-{ -15164, 16096, -16844, -8886, -23720, 15906},
-{ 24922, 5680, -1874, 420, 132, 117},
-{ -506, -19310, -198, 412, -311, 752},
-{ -1906, 3981, -7688, 16566, -19291, -14722},
-{ -399, -729, -3807, -4196, -12395, 7639},
-{ 3368, 2330, 9092, 23686, -10290, -1705},
-{ -3148, 2596, -7986, 14602, -4807, 16627},
-{ 8057, 1481, 49, 17205, 24869, 7474},
-{ -19304, -513, 11905, 2346, 5588, 3365},
-{ -5063, -21812, 11370, 10896, 4881, 261},
-{ 4794, 20577, 5109, -6025, -8049, -1521},
-{ 8125, -14756, 20639, -14918, 23941, -3650},
-{ 12451, 1381, 3613, 8687, -24002, 4848},
-{ 6726, 10643, 10086, 25217, -25159, -1065},
-{ 6561, 13977, 2911, 21737, 16465, -26050},
-{ -1776, 2575, -19606, -16800, 3032, 6679},
-{ 15012, -17910, -8438, -21554, -27111, 11808},
-{ 3448, -924, -15913, -1135, 5126, -20613},
-{ 7720, 2226, 17463, 5434, 28942, 17552},
-{ 1246, 15614, -11743, 24618, -17539, 3272},
-{ 3215, 17950, 2783, -722, -22672, 5979},
-{ -5678, -3184, -26087, 26034, 6583, 3302},
-{ 20310, -3555, -2715, -444, -1487, 1526},
-{ -20640, -21970, -12207, -25793, 8863, -1036},
-{ 17888, 570, -16102, 8329, -2553, 15275},
-{ -2677, 9950, -1879, 16477, -12762, -29007},
-{ -120, -2221, 219, 97, 365, 35},
-{ 1270, -718, 1480, -2689, 1930, -7527},
-{ 1896, 8750, 1906, 18235, -12692, -6174},
-{ -3733, 13713, -9882, -15960, -1376, -7146},
-{ -10600, 8496, 15967, -8792, 7532, 20439},
-{ 3041, -13457, 1032, -26952, 5787, 24984},
-{ -4590, -8220, -9322, -6112, -17243, 25745},
-{ -17808, 6970, 3752, 626, -114, 2178},
-{ 4449, -4862, 7054, -5404, 4738, -2827},
-{ 4922, -651, 18939, -9866, 848, 1886},
-{ -336, -5410, 7234, 20444, -9583, -600},
-{ 781, -19474, -12648, 6634, 1414, 450},
-{ -3399, -16770, 11107, 13200, -5498, 21663},
-{ -3265, 4859, -5961, 7530, -10837, 28086},
-{ 10350, -12901, 25699, 25640, -639, 351},
-{ 1163, 18763, -5466, -15087, -145, -1377},
-{ -14477, 27229, -31383, -32653, 21439, -2894},
-{ 15420, 18823, 22128, 19398, 22583, 13587},
-{ -10674, 10710, 5089, -4756, 909, -20760},
-{ -12948, -20660, 7410, 2722, 3427, 11585},
-{ -1105, 18374, 19731, -9650, 22442, 19634},
-{ -296, -6798, -14677, 21603, 19796, 21399},
-{ -19350, -7501, 25446, 13144, 8588, -25298},
-{ 3092, -10618, 20896, 9249, -3326, 1796},
-{ -811, 1449, 3106, 4748, 12073, -14262},
-{ -20720, 14275, -4332, -25838, -5781, -21149},
-{ -5132, 10554, -14020, -22150, 2840, -554},
-{ 25533, 17648, 14886, -21074, 2459, 25142},
-{ -9370, -1788, -12862, -5870, -25811, -11023},
-{ 6698, 819, 10313, 166, 27581, 523},
-{ 101, -19388, 3413, 9638, 64, 806},
-{ -2742, -17931, -2576, 22818, 8553, 1126},
-{ 2972, 15203, 1792, 25434, -5728, -17265},
-{ -1419, 1604, 4398, 11452, 1731, 23787},
-{ -5136, 4625, -10653, 27981, 9897, -2510},
-{ -10528, -28033, 2999, -1530, -832, -830},
-{ -11133, -12511, 22206, -7243, -23578, -21698},
-{ 16935, -21892, 1861, -9606, 9432, 19026},
-{ 10277, 9516, 26815, 2010, -4943, -9080},
-{ 5547, -2210, 14270, -15300, -19316, 1822},
-{ -4850, -783, -8959, -3076, -20056, -3197},
-{ 8232, -2794, -17752, 13308, 3229, -991},
-{ -12237, -6581, 10315, -9552, 2260, -20648},
-{ -7000, 5529, -7553, -7490, -10342, -10266},
-{ 3641, 19479, -5972, -19097, -18570, 12805},
-{ 1283, -4164, 4198, -28473, -2498, 1866},
-{ 16047, 26826, -13053, -6316, 985, -1597},
-{ -403, 13680, 6457, 25070, 27124, -20710},
-{ -18070, -1790, -24986, 5953, -954, 26600},
-{ -24224, -15383, 24788, 1953, -1136, 187},
-{ -2289, 12505, -20738, -904, 18324, 21258},
-{ 2658, -6140, 16179, 22276, -556, 2154},
-{ -6087, 13950, -25682, -27713, 4049, -4795},
-{ -21452, 26473, 19435, -9124, 895, 303},
-{ -22200, -26177, -6026, 24729, -22926, -9030},
-{ -14276, -15982, 23732, -22851, 9268, -3841},
-{ 29482, 21923, -6213, 1679, -2059, -1120},
-{ -435, 9802, -3891, 12359, -4288, -18971},
-{ 19768, -86, 2467, 1990, -1021, -5354},
-{ 20986, -8783, -5329, -23562, -4730, 2673},
-{ -5095, 5605, -4629, 19150, 26037, -12259},
-{ 972, 6858, 4551, 27949, -4025, -2272},
-{ 6075, -3260, -4989, -373, -1571, -3730},
-{ -7256, -12992, -8820, -5109, 23054, 5054},
-{ 920, 2615, 7912, -7353, -4905, 20186},
-{ -250, 5454, 3140, 6928, -18723, -2051},
-{ -10299, -4372, 19608, 4879, -661, -1885},
-{ 14816, -8603, -19815, 6135, -21210, 14108},
-{ -11945, -2223, 5018, 11892, 22741, 406},
-{ -13184, -2613, -13256, -22433, -12482, -8380},
-{ 17066, 25267, -2273, 5056, -342, 145},
-{ 8401, -17683, 19112, 10615, -19453, 17083},
-{ 20821, -5700, 12298, -25598, 10391, 7692},
-{ 4550, 15779, 17338, -19379, -4768, 1206},
-{ -7723, 10836, -27164, -11439, 6835, -1776},
-{ 2542, 3199, 4442, 17513, -3711, -914},
-{ 20960, -16774, -5814, 11087, -70, 22961},
-{ 3305, 2919, 6256, -4800, -20966, -3230},
-{ 5924, -16547, 2183, 2733, 3446, -23306},
-{ -6061, -194, -13852, -10971, 19488, 1029},
-{ 4467, -5964, -19004, 1519, -359, 855},
-{ -1581, -7607, 22070, -11580, -10032, 17102},
-{ -12412, 2553, 4324, 22500, 5751, 12170},
-{ -25127, 17996, -6384, 1180, 1182, 9622},
-{ 23462, -8471, -4392, -2669, 7638, -16835},
-{ -5511, -2887, -10757, -20883, 7246, 1053},
-{ 2703, -20602, -7554, 7516, -7740, 5868},
-{ 20670, 21901, 457, 14969, -17657, -11921},
-{ 3603, -1595, -2177, -157, -43, 605},
-{ 2513, 8954, 10527, 22559, -16100, -16041},
-{ 6002, 4951, 6795, -4862, -22400, 18849},
-{ 7590, -1693, -24688, -3404, 14169, 1214},
-{ -4398, -6663, -6870, -10083, -24596, 9253},
-{ 10468, 17751, -7748, 147, -6314, 4419},
-{ 16187, -16557, -4119, 4302, 7625, 5409},
-{ 3303, 2735, 7458, -19902, -2254, -3702},
-{ -2077, 21609, 14870, 12545, -6081, -1764},
-{ 4678, 11740, 2859, 6953, 1919, -3871},
-{ 3522, -21853, -2469, -10453, 18893, -10742},
-{ 3759, -10191, -4866, -2659, -17831, -1242},
-{ 14991, 9351, 11870, -1573, -4848, 22549},
-{ 9509, -27152, 10734, 20851, -26185, -17878},
-{ -7170, -1392, -19495, 12746, 8198, -1988},
-{ 1883, 28158, -846, -7235, 249, 233},
-{ -7200, 669, -371, -2948, 23234, -5635},
-{ 3141, 288, 3223, -1258, -98, -27607},
-{ 17373, -23235, 5110, -11199, -2574, -11487},
-{ -4928, 1518, -5456, 670, -18278, 1951},
-{ 10334, -19865, -4649, 361, -160, -923},
-{ 18732, 14264, -3155, -7485, -3328, 5959},
-{ -3614, 21077, 7276, 3536, 8121, -1528},
-{ -8422, 500, -19182, 18929, 26392, -1039},
-{ 15639, 25668, 8375, 1903, 1945, -11979},
-{ -2716, 3389, 26850, -4587, 1803, 22},
-{ 1177, -655, 1233, -2128, 7844, 1767},
-{ -761, 8209, -19290, -4593, 1923, -343},
-{ -689, -3530, -3267, -3804, -2753, 18566},
-{ -2110, 1962, -1353, 16643, 2765, -23102},
-{ -433, 4905, 302, 13016, 15933, -5905},
-{ 3203, 4126, 11181, -5496, -2529, -1160},
-{ -1091, -6469, -1415, 5682, -268, 583},
-{ -9405, -19572, 6216, 1658, 993, -75},
-{ -1695, -4504, -2289, -4088, -6556, -16577},
-{ 4760, -892, -10902, 6516, 24199, -6011},
-{ -253, 1000, 63, -81, -115, -382},
-{ -1333, 24224, -698, -4667, -2801, -19144},
-{ -876, -28866, -21873, 12677, -6344, 3235},
-{ 16847, 21145, -26172, -3183, -396, 230},
-{ 18296, -7790, -12857, -679, -1473, 5},
-{ -10488, 11429, 25805, -1122, 1401, -438},
-{ 3782, -7429, 26720, 17567, 19257, 12542},
-{ 6332, -746, 12789, 9316, -22542, -5354},
-{ 3418, -22728, 26978, 18303, 1076, 956},
-{ -27315, -2988, 920, 235, 2233, 81},
-{ 6199, 5296, 16093, 14768, -8429, -1112},
-{ -6432, 19244, 9921, -3253, 1278, -954},
-{ 24213, 2049, -22931, 2585, -2410, -4216},
-{ 9286, 14282, -19735, -3985, -2344, 1028},
-{ -20128, 17993, -9458, 23012, -16983, 8625},
-{ -6896, -20730, 3762, 17415, 22341, 19024},
-{ 842, 24181, 25062, -5839, -78, 937},
-{ -621, 19722, -24204, -1962, -14854, -56},
-{ 22766, -5119, 17365, 23868, -19480, -6558},
-{ -2158, 17490, -21435, 3340, -12819, -20295},
-{ -9621, 17325, 715, 2265, -4123, -492},
-{ 9156, 12947, 27303, -21175, -6072, -9457},
-{ -13164, -23269, -14006, -4184, 6978, 2},
-{ 938, -13381, 3520, -24297, 22902, 19589},
-{ -4911, -19774, 19764, -9310, -12650, 3819},
-{ -5462, -4249, -6987, -6260, -13943, -25150},
-{ 9341, 10369, -13862, -6704, 22556, -519},
-{ 6651, 18768, -4855, 12570, 14730, -10209},
-{ -823, 18119, 398, -1582, -116, -363},
-{ -6935, -12694, -28392, 8552, 6961, -239},
-{ -2602, -4704, -1021, 2015, 5129, 23670},
-{ -12559, -8190, -25028, 18544, 14179, 1663},
-{ 3813, 21036, -9620, -5051, -1800, -1087},
-{ -22057, 16675, 14960, 9459, 2786, 16991},
-{ -26040, -19318, -6414, 1104, 5798, -18039},
-{ -1737, 24825, 10417, -11087, 896, -5273},
-{ -1855, 11661, -2803, 24809, -21435, -19792},
-{ -23473, -16729, -5782, 5643, 2636, 4940},
-{ -1724, 4388, -26673, -13695, 10570, -25895},
-{ 15358, -19496, 26242, -18493, 1736, 8054},
-{ 5684, 20890, 4091, -19100, -14588, -10468},
-{ 17260, -16291, 14859, -17711, -19174, 12435},
-{ -27185, -12573, 6743, -562, 976, -257},
-{ 12395, -8618, -22248, -19843, 11013, 7762},
-{ 3799, 11853, -27622, -8473, 1089, -1495},
-{ 4141, -2182, -26720, -735, -774, 1469},
-{ 3125, 13762, 4606, 29257, 18771, -9958},
-{ -17465, -9445, -17562, -2530, -6435, -3726},
-{ -1742, 4351, -6841, -19773, 9627, -10654},
-{ 7251, 3525, 10835, 5601, 25198, -23348},
-{ -10300, -17830, 631, 11640, 2044, -20878},
-{ -873, -8502, -1063, -15674, -10693, 14934},
-{ -15957, 28137, 5268, 477, -1053, 1158},
-{ -1495, -8814, -5764, -24965, 25988, 7907},
-{ -1038, -114, -2308, -1319, -6480, 1472},
-{ 4895, -17897, -25850, 5301, -188, 1581},
-{ 3200, 17225, 4346, 22101, -18543, 22028},
-{ -10250, 545, -10932, 2276, -28070, 8118},
-{ 15343, 2329, 9316, 20537, 14908, 21021},
-{ 6329, 6130, -24508, 837, -8637, -5844},
-{ 7386, -501, 10503, 20131, 11435, -4755},
-{ -2745, 24174, -9274, 15273, -8389, -5835},
-{ 2992, -2864, 6048, -7473, 11687, -19996},
-{ -883, -11954, -9976, -21829, -4436, -27178},
-{ 3458, 19626, 1280, 2597, 19849, 5255},
-{ -5315, 19133, -14518, -8946, 13749, -1352},
-{ 18642, 17655, 11001, 6817, -18418, 6336},
-{ -1697, 2244, -4640, 3948, -12890, -5273},
-{ 20428, 10542, 4170, -1012, 19439, 21691},
-{ -2943, -19735, -4208, 1320, 909, -8897},
-{ 9351, -8066, -2618, -12933, 26582, 3507},
-{ 9705, -22628, 8311, 8167, -13293, 5608},
-{ 3222, 3749, -1508, 165, -52, -196},
-{ 102, -22744, -8832, 903, -11421, -14662},
-{ -120, 5998, 19765, 13401, 3628, 5197},
-{ 8528, 5827, -1066, 774, -39, -166},
-{ 9411, -9476, 9581, -13004, 24456, 24900},
-{ 17878, 2235, -21639, 20478, 4716, -7190},
-{ -2482, 9511, 1611, -21943, 14230, -1289},
-{ 9288, -2291, 23215, -3452, -10842, 11},
-{ 9496, 3041, 5130, -3890, -21219, -22589},
-{ 14262, -9838, 20195, 14019, 91, -17200},
-{ -18591, 980, 17, 821, 120, -574},
-{ 12285, -19269, 13742, 16373, -161, 6025},
-{ -3364, 1530, -4005, 2454, -10872, -23839},
-{ 105, 5085, -260, 5790, -588, 19170},
-{ 4121, 4169, 13439, 14644, 20899, 7434},
-{ -175, 13101, -3704, 23233, 3907, 10106},
-{ -6101, 23467, 5204, -1341, 1599, 13174},
-{ -3217, -3494, 15117, -8387, -11762, -4750},
-{ 1146, 4675, -19378, 14917, -5091, 249},
-{ -21506, 10136, -16473, -13305, 18382, -8601},
-{ 628, 2447, 3344, 3130, -5115, 119},
-{ 17900, -22422, -17633, 21967, -16293, -7676},
-{ 16863, 24214, 5612, -3858, -809, 3822},
-{ -2291, 10091, -2360, -25109, -1226, 312},
-{ 2957, 11256, 26745, -13266, -3455, -1128},
-{ -19762, -2708, 4604, 6355, 1638, 25501},
-{ -19593, -7753, 3159, -85, -489, -1855},
-{ 814, 12510, 19077, -4681, -2610, -1474},
-{ -23408, -19027, 8137, 19878, 7912, -282},
-{ 839, -19652, 11927, 27278, -3211, 2266},
-{ 4020, -1110, 8226, -1274, 20922, 25060},
-{ 26576, 325, -8693, -232, -2218, -699},
-{ -11293, -4200, 1805, -6673, -22940, -1339},
-{ -2005, -15886, -1047, -27687, -13235, 14370},
-{ -22073, 1949, 13175, -15656, -1846, 8055},
-{ 3039, 12025, 7132, -24632, 413, -2347},
-{ -24048, -206, 12459, -6654, -417, -10091},
-{ 18179, -23688, -20515, -16396, 7230, 763},
-{ 5659, -5085, 13878, -23729, -11077, -19587},
-{ 11340, 501, 25040, 7616, -19658, 1605},
-{ -26650, 8878, 10544, 417, 1299, 261},
-{ 14460, 11369, -3263, 9990, 8194, 18111},
-{ 1355, -20838, -9196, -16060, -8559, -730},
-{ -1918, -20937, -18293, -2461, -2651, 4316},
-{ -2810, 24521, -10996, -25721, 308, -1234},
-{ -9075, -17280, -1833, -29342, -24213, -16631},
-{ -2843, 10165, -5339, -2888, 21858, -21340},
-{ -15832, 14849, -23780, 5184, 10113, -20639},
-{ -19535, -11361, 8413, 1486, -23658, -5759},
-{ -7512, 1027, -20794, 13732, 19892, -21934},
-{ -12132, -7022, -19175, -8840, 22125, -16490},
-{ 1937, 5210, -6318, -23788, 13141, 11082},
-{ -205, 6036, -380, 8658, -233, 28020},
-{ -5523, 7477, 7635, 23595, 9763, -2590},
-{ 21658, -28313, -3086, -300, -1032, 1744},
-{ -22352, 16646, 208, 6665, -17400, -3028},
-{ 18482, 9336, -2737, -19372, 407, -4389},
-{ -4913, -17370, 18819, -17654, 13416, 15232},
-{ 7749, 6368, 23135, -18174, 7584, -4248},
-{ -1489, -6523, 586, -10157, 14964, 25568},
-{ 3844, -6156, 4897, -13045, -22526, 5647},
-{ -8491, -2105, -24774, 905, -9326, 1456},
-{ -3040, -1476, 1166, -4428, 11236, 9204},
-{ 3397, -1451, 13598, -15841, 24540, 5819},
-{ 8483, -2993, 21547, -16916, 7741, 24018},
-{ -14932, -23758, -5332, -6664, -4497, 13267},
-{ 19379, 12916, -2142, -737, 21100, -22101},
-{ 3393, -4629, 5735, -18913, -6969, 2687},
-{ 1148, -16147, -21433, -28095, -630, -14449},
-{ 7300, 672, 18530, -17452, -10149, 351},
-{ 11356, -10974, 17212, 4624, 145, 17791},
-{ -711, -3479, -2238, 15887, 2027, 0},
-{ -28048, 1794, -593, -2758, -21852, 11535},
-{ -19683, 4937, 22004, 21523, -3148, 1790},
-{ 813, 8231, 2633, 11981, -3043, 22201},
-{ 8952, -24760, -690, 14873, -2366, -5372},
-{ 8406, -5439, -274, -642, -145, 778},
-{ -6605, 7258, 20780, -23507, -18625, 22782},
-{ -22896, -25488, 10020, -1614, 1508, -1393},
-{ 7607, 407, -24678, -16385, -1804, -4699},
-{ -10592, -19139, 10462, -3747, 8721, -6919},
-{ 13010, 5292, -6230, -4884, -20904, -1797},
-{ 16891, -13770, -465, 19343, -10741, -12959},
-{ 25193, -14799, -5681, -521, -321, -1211},
-{ 6917, -3093, 20183, -26903, -12026, 1295},
-{ 305, 1992, 19457, -985, 25, -521},
-{ 6707, -3698, 8365, -8687, 21921, -27166},
-{ 4668, 5997, 7117, 11696, 24401, -10794},
-{ 744, -9416, 19893, 1963, 7922, -9824},
-{ 3430, 21282, -1736, 10844, 8821, 27015},
-{ -8813, 1521, -24038, 1651, 7838, -1208},
-{ 3911, -11221, 3273, -12541, 7168, 18402},
-{ 21642, 9117, -11536, -5256, 7077, 2382},
-{ 100, 3817, -6713, 1244, 1518, -321},
-{ 7946, -18670, 10667, -4866, 727, 776},
-{ -15883, -8150, -2087, 22739, 1567, -3482},
-{ 4380, -2735, 8469, -7025, -11424, 1317},
-{ 26970, 4393, 7665, 17561, -714, 650},
-{ -16191, -835, 8365, 1795, -14314, 16297},
-{ 4504, -10048, 7662, -26690, -17428, 2580},
-{ 48, -3984, 564, -5871, 2658, -18658},
-{ 12579, -26016, -15642, 2672, -1347, -887},
-{ -4950, 4208, -6811, 2569, -20621, -8658},
-{ -1836, -14818, -5571, -23322, -14800, 25867},
-{ 5434, -28139, -2357, -2883, -570, 2431},
-{ 13096, -2771, 24994, -12496, -24723, -1025},
-{ -5676, -4339, 1908, 18628, -21323, 17366},
-{ 27660, -27897, -15409, 1436, -7112, -2241},
-{ 8019, 3847, 24568, -469, 9674, 10683},
-{ -903, -10149, 1801, -21260, 4795, -8751},
-{ 1122, -9582, 2625, 22791, 956, 882},
-{ 7876, 19075, -9900, -24266, 7496, 9277},
-{ 980, -26764, -5386, 5396, 1086, 1648},
-{ 28838, -1270, -447, 5, -429, -20},
-{ -15283, 6132, 22812, 1252, -9963, 511},
-{ 851, 7925, -457, -12210, 4261, 7579},
-{ -4530, 8452, -1246, 14501, -24951, -5760},
-{ -17814, -10727, 9887, -23929, -13432, 1878},
-{ -15049, 10165, 16491, -14603, -11712, -21156},
-{ -3317, 840, -5683, 22413, 1994, 586},
-{ 23158, -5788, -15043, -10372, -9271, -13523},
-{ -773, -9509, -3993, -24264, 8463, 5804},
-{ -8545, -703, -12440, -3985, -25122, -28147},
-{ -16659, 16001, 2746, 1611, 5097, -1043},
-{ 41, -7181, 19903, 31555, -32237, 13927},
-{ -5658, 845, -12774, 5705, 16695, -86},
-{ 5282, 14875, 27026, 21124, 15776, -10477},
-{ 14712, 19648, -11487, -13361, -20196, -15229},
-{ 8597, -9138, -626, 10891, -6015, 6346},
-{ -1488, -1272, -1479, -1303, -3704, -5485},
-{ -3370, 17871, -6604, 24930, 25886, -3127},
-{ 8416, 27783, -1385, 5350, -4260, 19993},
-{ 5688, 362, 17246, 3809, -3246, 1088},
-{ -105, -29607, 2747, 15223, -167, 3722},
-{ 3502, -3195, 8602, 7772, -1566, -915},
-{ -491, 3257, -2423, 5522, 20606, -100},
-{ -13948, -11368, -15375, -21866, -8520, 12221},
-{ -616, 2424, -2023, 4398, -3805, 8108},
-{ -7204, 21043, 21211, -9395, -19391, 896},
-{ -5737, -15160, -21298, 17066, -1006, -366},
-{ 6261, 3240, -11937, -16213, -15820, 6581},
-{ -3155, 24796, 2733, -1257, -875, -1597},
-{ -20469, 11094, 24071, -8987, 14136, 2220},
-{ -14106, 11959, -22495, 4135, -1055, -5420},
-{ 801, -2655, 60, -5324, -790, 5937},
-{ -7372, -1764, -22433, -26060, 21707, 4178},
-{ -5715, -6648, -14908, 1325, -24044, 1493},
-{ -6024, -12488, 23930, 2950, 1601, 1173},
-{ 19067, 17630, 17929, -10654, 10928, -4958},
-{ 3231, -3284, 27336, 4174, -1683, 497},
-};
-
-const int16_t (* const ff_eac3_mantissa_vq[8])[6] = {
- NULL,
- vq_hebap1,
- vq_hebap2,
- vq_hebap3,
- vq_hebap4,
- vq_hebap5,
- vq_hebap6,
- vq_hebap7,
-};
-
-/**
- * Table E2.14 Frame Exponent Strategy Combinations
- */
-const uint8_t ff_eac3_frm_expstr[32][6] = {
-{ EXP_D15, EXP_REUSE, EXP_REUSE, EXP_REUSE, EXP_REUSE, EXP_REUSE},
-{ EXP_D15, EXP_REUSE, EXP_REUSE, EXP_REUSE, EXP_REUSE, EXP_D45},
-{ EXP_D15, EXP_REUSE, EXP_REUSE, EXP_REUSE, EXP_D25, EXP_REUSE},
-{ EXP_D15, EXP_REUSE, EXP_REUSE, EXP_REUSE, EXP_D45, EXP_D45},
-{ EXP_D25, EXP_REUSE, EXP_REUSE, EXP_D25, EXP_REUSE, EXP_REUSE},
-{ EXP_D25, EXP_REUSE, EXP_REUSE, EXP_D25, EXP_REUSE, EXP_D45},
-{ EXP_D25, EXP_REUSE, EXP_REUSE, EXP_D45, EXP_D25, EXP_REUSE},
-{ EXP_D25, EXP_REUSE, EXP_REUSE, EXP_D45, EXP_D45, EXP_D45},
-{ EXP_D25, EXP_REUSE, EXP_D15, EXP_REUSE, EXP_REUSE, EXP_REUSE},
-{ EXP_D25, EXP_REUSE, EXP_D25, EXP_REUSE, EXP_REUSE, EXP_D45},
-{ EXP_D25, EXP_REUSE, EXP_D25, EXP_REUSE, EXP_D25, EXP_REUSE},
-{ EXP_D25, EXP_REUSE, EXP_D25, EXP_REUSE, EXP_D45, EXP_D45},
-{ EXP_D25, EXP_REUSE, EXP_D45, EXP_D25, EXP_REUSE, EXP_REUSE},
-{ EXP_D25, EXP_REUSE, EXP_D45, EXP_D25, EXP_REUSE, EXP_D45},
-{ EXP_D25, EXP_REUSE, EXP_D45, EXP_D45, EXP_D25, EXP_REUSE},
-{ EXP_D25, EXP_REUSE, EXP_D45, EXP_D45, EXP_D45, EXP_D45},
-{ EXP_D45, EXP_D15, EXP_REUSE, EXP_REUSE, EXP_REUSE, EXP_REUSE},
-{ EXP_D45, EXP_D15, EXP_REUSE, EXP_REUSE, EXP_REUSE, EXP_D45},
-{ EXP_D45, EXP_D25, EXP_REUSE, EXP_REUSE, EXP_D25, EXP_REUSE},
-{ EXP_D45, EXP_D25, EXP_REUSE, EXP_REUSE, EXP_D45, EXP_D45},
-{ EXP_D45, EXP_D25, EXP_REUSE, EXP_D25, EXP_REUSE, EXP_REUSE},
-{ EXP_D45, EXP_D25, EXP_REUSE, EXP_D25, EXP_REUSE, EXP_D45},
-{ EXP_D45, EXP_D25, EXP_REUSE, EXP_D45, EXP_D25, EXP_REUSE},
-{ EXP_D45, EXP_D25, EXP_REUSE, EXP_D45, EXP_D45, EXP_D45},
-{ EXP_D45, EXP_D45, EXP_D15, EXP_REUSE, EXP_REUSE, EXP_REUSE},
-{ EXP_D45, EXP_D45, EXP_D25, EXP_REUSE, EXP_REUSE, EXP_D45},
-{ EXP_D45, EXP_D45, EXP_D25, EXP_REUSE, EXP_D25, EXP_REUSE},
-{ EXP_D45, EXP_D45, EXP_D25, EXP_REUSE, EXP_D45, EXP_D45},
-{ EXP_D45, EXP_D45, EXP_D45, EXP_D25, EXP_REUSE, EXP_REUSE},
-{ EXP_D45, EXP_D45, EXP_D45, EXP_D25, EXP_REUSE, EXP_D45},
-{ EXP_D45, EXP_D45, EXP_D45, EXP_D45, EXP_D25, EXP_REUSE},
-{ EXP_D45, EXP_D45, EXP_D45, EXP_D45, EXP_D45, EXP_D45},
-};
-
-/**
- * Table E.25: Spectral Extension Attenuation Table
- * ff_eac3_spx_atten_tab[code][bin]=pow(2.0,(bin+1)*(code+1)/-15.0);
- */
-const float ff_eac3_spx_atten_tab[32][3] = {
- { 0.954841603910416503f, 0.911722488558216804f, 0.870550563296124125f },
- { 0.911722488558216804f, 0.831237896142787758f, 0.757858283255198995f },
- { 0.870550563296124125f, 0.757858283255198995f, 0.659753955386447100f },
- { 0.831237896142787758f, 0.690956439983888004f, 0.574349177498517438f },
- { 0.793700525984099792f, 0.629960524947436595f, 0.500000000000000000f },
- { 0.757858283255198995f, 0.574349177498517438f, 0.435275281648062062f },
- { 0.723634618720189082f, 0.523647061410313364f, 0.378929141627599553f },
- { 0.690956439983888004f, 0.477420801955208307f, 0.329876977693223550f },
- { 0.659753955386447100f, 0.435275281648062062f, 0.287174588749258719f },
- { 0.629960524947436595f, 0.396850262992049896f, 0.250000000000000000f },
- { 0.601512518041058319f, 0.361817309360094541f, 0.217637640824031003f },
- { 0.574349177498517438f, 0.329876977693223550f, 0.189464570813799776f },
- { 0.548412489847312945f, 0.300756259020529160f, 0.164938488846611775f },
- { 0.523647061410313364f, 0.274206244923656473f, 0.143587294374629387f },
- { 0.500000000000000000f, 0.250000000000000000f, 0.125000000000000000f },
- { 0.477420801955208307f, 0.227930622139554201f, 0.108818820412015502f },
- { 0.455861244279108402f, 0.207809474035696939f, 0.094732285406899888f },
- { 0.435275281648062062f, 0.189464570813799776f, 0.082469244423305887f },
- { 0.415618948071393879f, 0.172739109995972029f, 0.071793647187314694f },
- { 0.396850262992049896f, 0.157490131236859149f, 0.062500000000000000f },
- { 0.378929141627599553f, 0.143587294374629387f, 0.054409410206007751f },
- { 0.361817309360094541f, 0.130911765352578369f, 0.047366142703449930f },
- { 0.345478219991944002f, 0.119355200488802049f, 0.041234622211652958f },
- { 0.329876977693223550f, 0.108818820412015502f, 0.035896823593657347f },
- { 0.314980262473718298f, 0.099212565748012460f, 0.031250000000000000f },
- { 0.300756259020529160f, 0.090454327340023621f, 0.027204705103003875f },
- { 0.287174588749258719f, 0.082469244423305887f, 0.023683071351724965f },
- { 0.274206244923656473f, 0.075189064755132290f, 0.020617311105826479f },
- { 0.261823530705156682f, 0.068551561230914118f, 0.017948411796828673f },
- { 0.250000000000000000f, 0.062500000000000000f, 0.015625000000000000f },
- { 0.238710400977604098f, 0.056982655534888536f, 0.013602352551501938f },
- { 0.227930622139554201f, 0.051952368508924235f, 0.011841535675862483f }
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/eac3_data.h b/src/thirdparty/ffmpeg/libavcodec/eac3_data.h
deleted file mode 100644
index 0c8302da1..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/eac3_data.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * E-AC-3 tables
- * Copyright (c) 2007 Bartlomiej Wolowiec <bartek.wolowiec@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_EAC3_DATA_H
-#define AVCODEC_EAC3_DATA_H
-
-#include <stdint.h>
-
-extern const uint8_t ff_eac3_bits_vs_hebap[20];
-extern const int16_t ff_eac3_gaq_remap_1[12];
-extern const int16_t ff_eac3_gaq_remap_2_4_a[9][2];
-extern const int16_t ff_eac3_gaq_remap_2_4_b[9][2];
-
-extern const int16_t (* const ff_eac3_mantissa_vq[8])[6];
-extern const uint8_t ff_eac3_frm_expstr[32][6];
-extern const float ff_eac3_spx_atten_tab[32][3];
-
-#endif /* AVCODEC_EAC3_DATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/eac3dec.c b/src/thirdparty/ffmpeg/libavcodec/eac3dec.c
deleted file mode 100644
index 3fb78b91c..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/eac3dec.c
+++ /dev/null
@@ -1,607 +0,0 @@
-/*
- * E-AC-3 decoder
- * Copyright (c) 2007 Bartlomiej Wolowiec <bartek.wolowiec@gmail.com>
- * Copyright (c) 2008 Justin Ruggles
- *
- * 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
- */
-
-/*
- * There are several features of E-AC-3 that this decoder does not yet support.
- *
- * Enhanced Coupling
- * No known samples exist. If any ever surface, this feature should not be
- * too difficult to implement.
- *
- * Reduced Sample Rates
- * No known samples exist. The spec also does not give clear information
- * on how this is to be implemented.
- *
- * Dependent Streams
- * Only the independent stream is currently decoded. Any dependent
- * streams are skipped. We have only come across two examples of this, and
- * they are both just test streams, one for HD-DVD and the other for
- * Blu-ray.
- *
- * Transient Pre-noise Processing
- * This is side information which a decoder should use to reduce artifacts
- * caused by transients. There are samples which are known to have this
- * information, but this decoder currently ignores it.
- */
-
-
-#include "avcodec.h"
-#include "internal.h"
-#include "aac_ac3_parser.h"
-#include "ac3.h"
-#include "ac3_parser.h"
-#include "ac3dec.h"
-#include "ac3dec_data.h"
-#include "eac3_data.h"
-
-/** gain adaptive quantization mode */
-typedef enum {
- EAC3_GAQ_NO =0,
- EAC3_GAQ_12,
- EAC3_GAQ_14,
- EAC3_GAQ_124
-} EAC3GaqMode;
-
-#define EAC3_SR_CODE_REDUCED 3
-
-void ff_eac3_apply_spectral_extension(AC3DecodeContext *s)
-{
- int bin, bnd, ch, i;
- uint8_t wrapflag[SPX_MAX_BANDS]={1,0,}, num_copy_sections, copy_sizes[SPX_MAX_BANDS];
- float rms_energy[SPX_MAX_BANDS];
-
- /* Set copy index mapping table. Set wrap flags to apply a notch filter at
- wrap points later on. */
- bin = s->spx_dst_start_freq;
- num_copy_sections = 0;
- for (bnd = 0; bnd < s->num_spx_bands; bnd++) {
- int copysize;
- int bandsize = s->spx_band_sizes[bnd];
- if (bin + bandsize > s->spx_src_start_freq) {
- copy_sizes[num_copy_sections++] = bin - s->spx_dst_start_freq;
- bin = s->spx_dst_start_freq;
- wrapflag[bnd] = 1;
- }
- for (i = 0; i < bandsize; i += copysize) {
- if (bin == s->spx_src_start_freq) {
- copy_sizes[num_copy_sections++] = bin - s->spx_dst_start_freq;
- bin = s->spx_dst_start_freq;
- }
- copysize = FFMIN(bandsize - i, s->spx_src_start_freq - bin);
- bin += copysize;
- }
- }
- copy_sizes[num_copy_sections++] = bin - s->spx_dst_start_freq;
-
- for (ch = 1; ch <= s->fbw_channels; ch++) {
- if (!s->channel_uses_spx[ch])
- continue;
-
- /* Copy coeffs from normal bands to extension bands */
- bin = s->spx_src_start_freq;
- for (i = 0; i < num_copy_sections; i++) {
- memcpy(&s->transform_coeffs[ch][bin],
- &s->transform_coeffs[ch][s->spx_dst_start_freq],
- copy_sizes[i]*sizeof(float));
- bin += copy_sizes[i];
- }
-
- /* Calculate RMS energy for each SPX band. */
- bin = s->spx_src_start_freq;
- for (bnd = 0; bnd < s->num_spx_bands; bnd++) {
- int bandsize = s->spx_band_sizes[bnd];
- float accum = 0.0f;
- for (i = 0; i < bandsize; i++) {
- float coeff = s->transform_coeffs[ch][bin++];
- accum += coeff * coeff;
- }
- rms_energy[bnd] = sqrtf(accum / bandsize);
- }
-
- /* Apply a notch filter at transitions between normal and extension
- bands and at all wrap points. */
- if (s->spx_atten_code[ch] >= 0) {
- const float *atten_tab = ff_eac3_spx_atten_tab[s->spx_atten_code[ch]];
- bin = s->spx_src_start_freq - 2;
- for (bnd = 0; bnd < s->num_spx_bands; bnd++) {
- if (wrapflag[bnd]) {
- float *coeffs = &s->transform_coeffs[ch][bin];
- coeffs[0] *= atten_tab[0];
- coeffs[1] *= atten_tab[1];
- coeffs[2] *= atten_tab[2];
- coeffs[3] *= atten_tab[1];
- coeffs[4] *= atten_tab[0];
- }
- bin += s->spx_band_sizes[bnd];
- }
- }
-
- /* Apply noise-blended coefficient scaling based on previously
- calculated RMS energy, blending factors, and SPX coordinates for
- each band. */
- bin = s->spx_src_start_freq;
- for (bnd = 0; bnd < s->num_spx_bands; bnd++) {
- float nscale = s->spx_noise_blend[ch][bnd] * rms_energy[bnd] * (1.0f / INT32_MIN);
- float sscale = s->spx_signal_blend[ch][bnd];
- for (i = 0; i < s->spx_band_sizes[bnd]; i++) {
- float noise = nscale * (int32_t)av_lfg_get(&s->dith_state);
- s->transform_coeffs[ch][bin] *= sscale;
- s->transform_coeffs[ch][bin++] += noise;
- }
- }
- }
-}
-
-
-/** lrint(M_SQRT2*cos(2*M_PI/12)*(1<<23)) */
-#define COEFF_0 10273905LL
-
-/** lrint(M_SQRT2*cos(0*M_PI/12)*(1<<23)) = lrint(M_SQRT2*(1<<23)) */
-#define COEFF_1 11863283LL
-
-/** lrint(M_SQRT2*cos(5*M_PI/12)*(1<<23)) */
-#define COEFF_2 3070444LL
-
-/**
- * Calculate 6-point IDCT of the pre-mantissas.
- * All calculations are 24-bit fixed-point.
- */
-static void idct6(int pre_mant[6])
-{
- int tmp;
- int even0, even1, even2, odd0, odd1, odd2;
-
- odd1 = pre_mant[1] - pre_mant[3] - pre_mant[5];
-
- even2 = ( pre_mant[2] * COEFF_0) >> 23;
- tmp = ( pre_mant[4] * COEFF_1) >> 23;
- odd0 = ((pre_mant[1] + pre_mant[5]) * COEFF_2) >> 23;
-
- even0 = pre_mant[0] + (tmp >> 1);
- even1 = pre_mant[0] - tmp;
-
- tmp = even0;
- even0 = tmp + even2;
- even2 = tmp - even2;
-
- tmp = odd0;
- odd0 = tmp + pre_mant[1] + pre_mant[3];
- odd2 = tmp + pre_mant[5] - pre_mant[3];
-
- pre_mant[0] = even0 + odd0;
- pre_mant[1] = even1 + odd1;
- pre_mant[2] = even2 + odd2;
- pre_mant[3] = even2 - odd2;
- pre_mant[4] = even1 - odd1;
- pre_mant[5] = even0 - odd0;
-}
-
-void ff_eac3_decode_transform_coeffs_aht_ch(AC3DecodeContext *s, int ch)
-{
- int bin, blk, gs;
- int end_bap, gaq_mode;
- GetBitContext *gbc = &s->gbc;
- int gaq_gain[AC3_MAX_COEFS];
-
- gaq_mode = get_bits(gbc, 2);
- end_bap = (gaq_mode < 2) ? 12 : 17;
-
- /* if GAQ gain is used, decode gain codes for bins with hebap between
- 8 and end_bap */
- gs = 0;
- if (gaq_mode == EAC3_GAQ_12 || gaq_mode == EAC3_GAQ_14) {
- /* read 1-bit GAQ gain codes */
- for (bin = s->start_freq[ch]; bin < s->end_freq[ch]; bin++) {
- if (s->bap[ch][bin] > 7 && s->bap[ch][bin] < end_bap)
- gaq_gain[gs++] = get_bits1(gbc) << (gaq_mode-1);
- }
- } else if (gaq_mode == EAC3_GAQ_124) {
- /* read 1.67-bit GAQ gain codes (3 codes in 5 bits) */
- int gc = 2;
- for (bin = s->start_freq[ch]; bin < s->end_freq[ch]; bin++) {
- if (s->bap[ch][bin] > 7 && s->bap[ch][bin] < 17) {
- if (gc++ == 2) {
- int group_code = get_bits(gbc, 5);
- if (group_code > 26) {
- av_log(s->avctx, AV_LOG_WARNING, "GAQ gain group code out-of-range\n");
- group_code = 26;
- }
- gaq_gain[gs++] = ff_ac3_ungroup_3_in_5_bits_tab[group_code][0];
- gaq_gain[gs++] = ff_ac3_ungroup_3_in_5_bits_tab[group_code][1];
- gaq_gain[gs++] = ff_ac3_ungroup_3_in_5_bits_tab[group_code][2];
- gc = 0;
- }
- }
- }
- }
-
- gs=0;
- for (bin = s->start_freq[ch]; bin < s->end_freq[ch]; bin++) {
- int hebap = s->bap[ch][bin];
- int bits = ff_eac3_bits_vs_hebap[hebap];
- if (!hebap) {
- /* zero-mantissa dithering */
- for (blk = 0; blk < 6; blk++) {
- s->pre_mantissa[ch][bin][blk] = (av_lfg_get(&s->dith_state) & 0x7FFFFF) - 0x400000;
- }
- } else if (hebap < 8) {
- /* Vector Quantization */
- int v = get_bits(gbc, bits);
- for (blk = 0; blk < 6; blk++) {
- s->pre_mantissa[ch][bin][blk] = ff_eac3_mantissa_vq[hebap][v][blk] << 8;
- }
- } else {
- /* Gain Adaptive Quantization */
- int gbits, log_gain;
- if (gaq_mode != EAC3_GAQ_NO && hebap < end_bap) {
- log_gain = gaq_gain[gs++];
- } else {
- log_gain = 0;
- }
- gbits = bits - log_gain;
-
- for (blk = 0; blk < 6; blk++) {
- int mant = get_sbits(gbc, gbits);
- if (log_gain && mant == -(1 << (gbits-1))) {
- /* large mantissa */
- int b;
- int mbits = bits - (2 - log_gain);
- mant = get_sbits(gbc, mbits);
- mant <<= (23 - (mbits - 1));
- /* remap mantissa value to correct for asymmetric quantization */
- if (mant >= 0)
- b = 1 << (23 - log_gain);
- else
- b = ff_eac3_gaq_remap_2_4_b[hebap-8][log_gain-1] << 8;
- mant += ((ff_eac3_gaq_remap_2_4_a[hebap-8][log_gain-1] * (int64_t)mant) >> 15) + b;
- } else {
- /* small mantissa, no GAQ, or Gk=1 */
- mant <<= 24 - bits;
- if (!log_gain) {
- /* remap mantissa value for no GAQ or Gk=1 */
- mant += (ff_eac3_gaq_remap_1[hebap-8] * (int64_t)mant) >> 15;
- }
- }
- s->pre_mantissa[ch][bin][blk] = mant;
- }
- }
- idct6(s->pre_mantissa[ch][bin]);
- }
-}
-
-int ff_eac3_parse_header(AC3DecodeContext *s)
-{
- int i, blk, ch;
- int ac3_exponent_strategy, parse_aht_info, parse_spx_atten_data;
- int parse_transient_proc_info;
- int num_cpl_blocks;
- GetBitContext *gbc = &s->gbc;
-
- /* An E-AC-3 stream can have multiple independent streams which the
- application can select from. each independent stream can also contain
- dependent streams which are used to add or replace channels. */
- if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT) {
- av_log_missing_feature(s->avctx, "Dependent substream decoding", 1);
- return AAC_AC3_PARSE_ERROR_FRAME_TYPE;
- } else if (s->frame_type == EAC3_FRAME_TYPE_RESERVED) {
- av_log(s->avctx, AV_LOG_ERROR, "Reserved frame type\n");
- return AAC_AC3_PARSE_ERROR_FRAME_TYPE;
- }
-
- /* The substream id indicates which substream this frame belongs to. each
- independent stream has its own substream id, and the dependent streams
- associated to an independent stream have matching substream id's. */
- if (s->substreamid) {
- /* only decode substream with id=0. skip any additional substreams. */
- av_log_missing_feature(s->avctx, "Additional substreams", 1);
- return AAC_AC3_PARSE_ERROR_FRAME_TYPE;
- }
-
- if (s->bit_alloc_params.sr_code == EAC3_SR_CODE_REDUCED) {
- /* The E-AC-3 specification does not tell how to handle reduced sample
- rates in bit allocation. The best assumption would be that it is
- handled like AC-3 DolbyNet, but we cannot be sure until we have a
- sample which utilizes this feature. */
- av_log_missing_feature(s->avctx, "Reduced sampling rate", 1);
- return AVERROR_PATCHWELCOME;
- }
- skip_bits(gbc, 5); // skip bitstream id
-
- /* volume control params */
- for (i = 0; i < (s->channel_mode ? 1 : 2); i++) {
- skip_bits(gbc, 5); // skip dialog normalization
- if (get_bits1(gbc)) {
- skip_bits(gbc, 8); // skip compression gain word
- }
- }
-
- /* dependent stream channel map */
- if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT) {
- if (get_bits1(gbc)) {
- skip_bits(gbc, 16); // skip custom channel map
- }
- }
-
- /* mixing metadata */
- 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
- 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);
- }
- 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);
- }
- }
-
- /* lfe mix level */
- if (s->lfe_on && get_bits1(gbc)) {
- // TODO: use LFE mix level
- skip_bits(gbc, 5); // skip LFE mix level code
- }
-
- /* info for mixing with other streams and substreams */
- if (s->frame_type == EAC3_FRAME_TYPE_INDEPENDENT) {
- for (i = 0; i < (s->channel_mode ? 1 : 2); i++) {
- // TODO: apply program scale factor
- if (get_bits1(gbc)) {
- skip_bits(gbc, 6); // skip program scale factor
- }
- }
- if (get_bits1(gbc)) {
- skip_bits(gbc, 6); // skip external program scale factor
- }
- /* skip mixing parameter data */
- switch(get_bits(gbc, 2)) {
- case 1: skip_bits(gbc, 5); break;
- case 2: skip_bits(gbc, 12); break;
- case 3: {
- int mix_data_size = (get_bits(gbc, 5) + 2) << 3;
- skip_bits_long(gbc, mix_data_size);
- break;
- }
- }
- /* skip pan information for mono or dual mono source */
- if (s->channel_mode < AC3_CHMODE_STEREO) {
- for (i = 0; i < (s->channel_mode ? 1 : 2); i++) {
- if (get_bits1(gbc)) {
- /* note: this is not in the ATSC A/52B specification
- reference: ETSI TS 102 366 V1.1.1
- section: E.1.3.1.25 */
- skip_bits(gbc, 8); // skip pan mean direction index
- skip_bits(gbc, 6); // skip reserved paninfo bits
- }
- }
- }
- /* skip mixing configuration information */
- if (get_bits1(gbc)) {
- for (blk = 0; blk < s->num_blocks; blk++) {
- if (s->num_blocks == 1 || get_bits1(gbc)) {
- skip_bits(gbc, 5);
- }
- }
- }
- }
- }
-
- /* informational metadata */
- if (get_bits1(gbc)) {
- 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
- }
- if (s->channel_mode >= AC3_CHMODE_2F2R) {
- skip_bits(gbc, 2); // skip Dolby surround EX mode
- }
- for (i = 0; i < (s->channel_mode ? 1 : 2); i++) {
- if (get_bits1(gbc)) {
- skip_bits(gbc, 8); // skip mix level, room type, and A/D converter type
- }
- }
- if (s->bit_alloc_params.sr_code != EAC3_SR_CODE_REDUCED) {
- skip_bits1(gbc); // skip source sample rate code
- }
- }
-
- /* converter synchronization flag
- If frames are less than six blocks, this bit should be turned on
- once every 6 blocks to indicate the start of a frame set.
- reference: RFC 4598, Section 2.1.3 Frame Sets */
- if (s->frame_type == EAC3_FRAME_TYPE_INDEPENDENT && s->num_blocks != 6) {
- skip_bits1(gbc); // skip converter synchronization flag
- }
-
- /* original frame size code if this stream was converted from AC-3 */
- if (s->frame_type == EAC3_FRAME_TYPE_AC3_CONVERT &&
- (s->num_blocks == 6 || get_bits1(gbc))) {
- skip_bits(gbc, 6); // skip frame size code
- }
-
- /* additional bitstream info */
- if (get_bits1(gbc)) {
- int addbsil = get_bits(gbc, 6);
- for (i = 0; i < addbsil + 1; i++) {
- skip_bits(gbc, 8); // skip additional bit stream info
- }
- }
-
- /* audio frame syntax flags, strategy data, and per-frame data */
-
- if (s->num_blocks == 6) {
- ac3_exponent_strategy = get_bits1(gbc);
- parse_aht_info = get_bits1(gbc);
- } else {
- /* less than 6 blocks, so use AC-3-style exponent strategy syntax, and
- do not use AHT */
- ac3_exponent_strategy = 1;
- parse_aht_info = 0;
- }
-
- s->snr_offset_strategy = get_bits(gbc, 2);
- parse_transient_proc_info = get_bits1(gbc);
-
- s->block_switch_syntax = get_bits1(gbc);
- if (!s->block_switch_syntax)
- memset(s->block_switch, 0, sizeof(s->block_switch));
-
- s->dither_flag_syntax = get_bits1(gbc);
- if (!s->dither_flag_syntax) {
- for (ch = 1; ch <= s->fbw_channels; ch++)
- s->dither_flag[ch] = 1;
- }
- s->dither_flag[CPL_CH] = s->dither_flag[s->lfe_ch] = 0;
-
- s->bit_allocation_syntax = get_bits1(gbc);
- if (!s->bit_allocation_syntax) {
- /* set default bit allocation parameters */
- s->bit_alloc_params.slow_decay = ff_ac3_slow_decay_tab[2];
- s->bit_alloc_params.fast_decay = ff_ac3_fast_decay_tab[1];
- s->bit_alloc_params.slow_gain = ff_ac3_slow_gain_tab [1];
- s->bit_alloc_params.db_per_bit = ff_ac3_db_per_bit_tab[2];
- s->bit_alloc_params.floor = ff_ac3_floor_tab [7];
- }
-
- s->fast_gain_syntax = get_bits1(gbc);
- s->dba_syntax = get_bits1(gbc);
- s->skip_syntax = get_bits1(gbc);
- parse_spx_atten_data = get_bits1(gbc);
-
- /* coupling strategy occurrence and coupling use per block */
- num_cpl_blocks = 0;
- if (s->channel_mode > 1) {
- for (blk = 0; blk < s->num_blocks; blk++) {
- s->cpl_strategy_exists[blk] = (!blk || get_bits1(gbc));
- if (s->cpl_strategy_exists[blk]) {
- s->cpl_in_use[blk] = get_bits1(gbc);
- } else {
- s->cpl_in_use[blk] = s->cpl_in_use[blk-1];
- }
- num_cpl_blocks += s->cpl_in_use[blk];
- }
- } else {
- memset(s->cpl_in_use, 0, sizeof(s->cpl_in_use));
- }
-
- /* exponent strategy data */
- if (ac3_exponent_strategy) {
- /* AC-3-style exponent strategy syntax */
- for (blk = 0; blk < s->num_blocks; blk++) {
- for (ch = !s->cpl_in_use[blk]; ch <= s->fbw_channels; ch++) {
- s->exp_strategy[blk][ch] = get_bits(gbc, 2);
- }
- }
- } else {
- /* LUT-based exponent strategy syntax */
- for (ch = !((s->channel_mode > 1) && num_cpl_blocks); ch <= s->fbw_channels; ch++) {
- int frmchexpstr = get_bits(gbc, 5);
- for (blk = 0; blk < 6; blk++) {
- s->exp_strategy[blk][ch] = ff_eac3_frm_expstr[frmchexpstr][blk];
- }
- }
- }
- /* LFE exponent strategy */
- if (s->lfe_on) {
- for (blk = 0; blk < s->num_blocks; blk++) {
- s->exp_strategy[blk][s->lfe_ch] = get_bits1(gbc);
- }
- }
- /* original exponent strategies if this stream was converted from AC-3 */
- if (s->frame_type == EAC3_FRAME_TYPE_INDEPENDENT &&
- (s->num_blocks == 6 || get_bits1(gbc))) {
- skip_bits(gbc, 5 * s->fbw_channels); // skip converter channel exponent strategy
- }
-
- /* determine which channels use AHT */
- if (parse_aht_info) {
- /* For AHT to be used, all non-zero blocks must reuse exponents from
- the first block. Furthermore, for AHT to be used in the coupling
- channel, all blocks must use coupling and use the same coupling
- strategy. */
- s->channel_uses_aht[CPL_CH]=0;
- for (ch = (num_cpl_blocks != 6); ch <= s->channels; ch++) {
- int use_aht = 1;
- for (blk = 1; blk < 6; blk++) {
- if ((s->exp_strategy[blk][ch] != EXP_REUSE) ||
- (!ch && s->cpl_strategy_exists[blk])) {
- use_aht = 0;
- break;
- }
- }
- s->channel_uses_aht[ch] = use_aht && get_bits1(gbc);
- }
- } else {
- memset(s->channel_uses_aht, 0, sizeof(s->channel_uses_aht));
- }
-
- /* per-frame SNR offset */
- if (!s->snr_offset_strategy) {
- int csnroffst = (get_bits(gbc, 6) - 15) << 4;
- int snroffst = (csnroffst + get_bits(gbc, 4)) << 2;
- for (ch = 0; ch <= s->channels; ch++)
- s->snr_offset[ch] = snroffst;
- }
-
- /* transient pre-noise processing data */
- if (parse_transient_proc_info) {
- for (ch = 1; ch <= s->fbw_channels; ch++) {
- if (get_bits1(gbc)) { // channel in transient processing
- skip_bits(gbc, 10); // skip transient processing location
- skip_bits(gbc, 8); // skip transient processing length
- }
- }
- }
-
- /* spectral extension attenuation data */
- for (ch = 1; ch <= s->fbw_channels; ch++) {
- if (parse_spx_atten_data && get_bits1(gbc)) {
- s->spx_atten_code[ch] = get_bits(gbc, 5);
- } else {
- s->spx_atten_code[ch] = -1;
- }
- }
-
- /* block start information */
- if (s->num_blocks > 1 && get_bits1(gbc)) {
- /* reference: Section E2.3.2.27
- nblkstrtbits = (numblks - 1) * (4 + ceiling(log2(words_per_frame)))
- The spec does not say what this data is or what it's used for.
- It is likely the offset of each block within the frame. */
- int block_start_bits = (s->num_blocks-1) * (4 + av_log2(s->frame_size-2));
- skip_bits_long(gbc, block_start_bits);
- av_log_missing_feature(s->avctx, "Block start info", 1);
- }
-
- /* syntax state initialization */
- for (ch = 1; ch <= s->fbw_channels; ch++) {
- s->first_spx_coords[ch] = 1;
- s->first_cpl_coords[ch] = 1;
- }
- s->first_cpl_leak = 1;
-
- return 0;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/error_resilience.c b/src/thirdparty/ffmpeg/libavcodec/error_resilience.c
deleted file mode 100644
index 570250c9a..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/error_resilience.c
+++ /dev/null
@@ -1,1322 +0,0 @@
-/*
- * Error resilience / concealment
- *
- * Copyright (c) 2002-2004 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
- * Error resilience / concealment.
- */
-
-#include <limits.h>
-
-#include "avcodec.h"
-#include "dsputil.h"
-#include "mpegvideo.h"
-#include "h264.h"
-#include "rectangle.h"
-#include "thread.h"
-
-/*
- * H264 redefines mb_intra so it is not mistakely used (its uninitialized in h264)
- * but error concealment must support both h264 and h263 thus we must undo this
- */
-#undef mb_intra
-
-static void decode_mb(MpegEncContext *s, int ref)
-{
- 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);
-
- ff_init_block_index(s);
- ff_update_block_index(s);
- s->dest[1] += (16 >> s->chroma_x_shift) - 8;
- s->dest[2] += (16 >> s->chroma_x_shift) - 8;
-
- if (CONFIG_H264_DECODER && s->codec_id == AV_CODEC_ID_H264) {
- H264Context *h = (void*)s;
- h->mb_xy = s->mb_x + s->mb_y * s->mb_stride;
- memset(h->non_zero_count_cache, 0, sizeof(h->non_zero_count_cache));
- av_assert1(ref >= 0);
- /* FIXME: It is possible albeit uncommon that slice references
- * differ between slices. We take the easy approach and ignore
- * it for now. If this turns out to have any relevance in
- * practice then correct remapping should be added. */
- if (ref >= h->ref_count[0])
- ref = 0;
- if (!h->ref_list[0][ref].f.data[0]) {
- av_log(s->avctx, AV_LOG_DEBUG, "Reference not available for error concealing\n");
- ref = 0;
- }
- if ((h->ref_list[0][ref].f.reference&3) != 3) {
- av_log(s->avctx, AV_LOG_DEBUG, "Reference invalid\n");
- return;
- }
- fill_rectangle(&s->current_picture.f.ref_index[0][4 * h->mb_xy],
- 2, 2, 2, ref, 1);
- fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1);
- fill_rectangle(h->mv_cache[0][scan8[0]], 4, 4, 8,
- pack16to32(s->mv[0][0][0], s->mv[0][0][1]), 4);
- h->mb_mbaff =
- h->mb_field_decoding_flag = 0;
- ff_h264_hl_decode_mb(h);
- } else {
- assert(ref == 0);
- ff_MPV_decode_mb(s, s->block);
- }
-}
-
-/**
- * @param stride the number of MVs to get to the next row
- * @param mv_step the number of MVs per row or column in a macroblock
- */
-static void set_mv_strides(MpegEncContext *s, int *mv_step, int *stride)
-{
- if (s->codec_id == AV_CODEC_ID_H264) {
- H264Context *h = (void*)s;
- av_assert0(s->quarter_sample);
- *mv_step = 4;
- *stride = h->b_stride;
- } else {
- *mv_step = 2;
- *stride = s->b8_stride;
- }
-}
-
-/**
- * Replace the current MB with a flat dc-only version.
- */
-static void put_dc(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb,
- uint8_t *dest_cr, int mb_x, int mb_y)
-{
- 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];
- if (dc < 0)
- dc = 0;
- else if (dc > 2040)
- dc = 2040;
- for (y = 0; y < 8; y++) {
- int x;
- for (x = 0; x < 8; x++)
- dest_y[x + (i & 1) * 8 + (y + (i >> 1) * 8) * s->linesize] = dc / 8;
- }
- }
- dcu = s->dc_val[1][mb_x + mb_y * s->mb_stride];
- dcv = s->dc_val[2][mb_x + mb_y * s->mb_stride];
- if (dcu < 0)
- dcu = 0;
- else if (dcu > 2040)
- dcu = 2040;
- if (dcv < 0)
- dcv = 0;
- else if (dcv > 2040)
- dcv = 2040;
- for (y = 0; y < 8; y++) {
- int x;
- for (x = 0; x < 8; x++) {
- dest_cb[x + y * s->uvlinesize] = dcu / 8;
- dest_cr[x + y * s->uvlinesize] = dcv / 8;
- }
- }
-}
-
-static void filter181(int16_t *data, int width, int height, int stride)
-{
- int x, y;
-
- /* horizontal filter */
- for (y = 1; y < height - 1; y++) {
- int prev_dc = data[0 + y * stride];
-
- for (x = 1; x < width - 1; x++) {
- int dc;
- dc = -prev_dc +
- data[x + y * stride] * 8 -
- data[x + 1 + y * stride];
- dc = (dc * 10923 + 32768) >> 16;
- prev_dc = data[x + y * stride];
- data[x + y * stride] = dc;
- }
- }
-
- /* vertical filter */
- for (x = 1; x < width - 1; x++) {
- int prev_dc = data[x];
-
- for (y = 1; y < height - 1; y++) {
- int dc;
-
- dc = -prev_dc +
- data[x + y * stride] * 8 -
- data[x + (y + 1) * stride];
- dc = (dc * 10923 + 32768) >> 16;
- prev_dc = data[x + y * stride];
- data[x + y * stride] = dc;
- }
- }
-}
-
-/**
- * guess the dc of blocks which do not have an undamaged dc
- * @param w width in 8 pixel blocks
- * @param h height in 8 pixel blocks
- */
-static void guess_dc(MpegEncContext *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);
-
- if(!col || !dist) {
- av_log(s->avctx, AV_LOG_ERROR, "guess_dc() is out of memory\n");
- goto fail;
- }
-
- for(b_y=0; b_y<h; b_y++){
- int color= 1024;
- int distance= -1;
- 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->current_picture.f.mb_type[mb_index_j]);
- if(intra_j==0 || !(error_j&ER_DC_ERROR)){
- color= dc[b_x + b_y*stride];
- distance= b_x;
- }
- col [b_x + b_y*stride][1]= color;
- dist[b_x + b_y*stride][1]= distance >= 0 ? b_x-distance : 9999;
- }
- color= 1024;
- distance= -1;
- 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->current_picture.f.mb_type[mb_index_j]);
- if(intra_j==0 || !(error_j&ER_DC_ERROR)){
- color= dc[b_x + b_y*stride];
- distance= b_x;
- }
- col [b_x + b_y*stride][0]= color;
- dist[b_x + b_y*stride][0]= distance >= 0 ? distance-b_x : 9999;
- }
- }
- for(b_x=0; b_x<w; b_x++){
- int color= 1024;
- int distance= -1;
- 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->current_picture.f.mb_type[mb_index_j]);
- if(intra_j==0 || !(error_j&ER_DC_ERROR)){
- color= dc[b_x + b_y*stride];
- distance= b_y;
- }
- col [b_x + b_y*stride][3]= color;
- dist[b_x + b_y*stride][3]= distance >= 0 ? b_y-distance : 9999;
- }
- color= 1024;
- distance= -1;
- 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->current_picture.f.mb_type[mb_index_j]);
- if(intra_j==0 || !(error_j&ER_DC_ERROR)){
- color= dc[b_x + b_y*stride];
- distance= b_y;
- }
- col [b_x + b_y*stride][2]= color;
- dist[b_x + b_y*stride][2]= distance >= 0 ? distance-b_y : 9999;
- }
- }
-
- for (b_y = 0; b_y < h; b_y++) {
- for (b_x = 0; b_x < w; b_x++) {
- int mb_index, error, j;
- int64_t guess, weight_sum;
- mb_index = (b_x >> is_luma) + (b_y >> is_luma) * s->mb_stride;
- error = s->error_status_table[mb_index];
-
- if (IS_INTER(s->current_picture.f.mb_type[mb_index]))
- continue; // inter
- if (!(error & ER_DC_ERROR))
- continue; // dc-ok
-
- weight_sum = 0;
- guess = 0;
- for (j = 0; j < 4; j++) {
- int64_t weight = 256 * 256 * 256 * 16 / FFMAX(dist[b_x + b_y*stride][j], 1);
- guess += weight*(int64_t)col[b_x + b_y*stride][j];
- weight_sum += weight;
- }
- guess = (guess + weight_sum / 2) / weight_sum;
- dc[b_x + b_y * stride] = guess;
- }
- }
-
-fail:
- av_freep(&col);
- av_freep(&dist);
-}
-
-/**
- * simple horizontal deblocking filter used for error resilience
- * @param w width in 8 pixel blocks
- * @param h height in 8 pixel blocks
- */
-static void h_block_filter(MpegEncContext *s, uint8_t *dst, int w,
- int h, int stride, int is_luma)
-{
- int b_x, b_y, mvx_stride, mvy_stride;
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
- set_mv_strides(s, &mvx_stride, &mvy_stride);
- mvx_stride >>= is_luma;
- mvy_stride *= mvx_stride;
-
- for (b_y = 0; b_y < h; b_y++) {
- for (b_x = 0; b_x < w - 1; b_x++) {
- 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->current_picture.f.mb_type[( b_x >> is_luma) + (b_y >> is_luma) * s->mb_stride]);
- int right_intra = IS_INTRA(s->current_picture.f.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->current_picture.f.motion_val[0][mvy_stride * b_y + mvx_stride * b_x];
- int16_t *right_mv = s->current_picture.f.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) &&
- FFABS(left_mv[0] - right_mv[0]) +
- FFABS(left_mv[1] + right_mv[1]) < 2)
- continue;
-
- for (y = 0; y < 8; y++) {
- int a, b, c, d;
-
- a = dst[offset + 7 + y * stride] - dst[offset + 6 + y * stride];
- b = dst[offset + 8 + y * stride] - dst[offset + 7 + y * stride];
- c = dst[offset + 9 + y * stride] - dst[offset + 8 + y * stride];
-
- d = FFABS(b) - ((FFABS(a) + FFABS(c) + 1) >> 1);
- d = FFMAX(d, 0);
- if (b < 0)
- d = -d;
-
- if (d == 0)
- continue;
-
- if (!(left_damage && right_damage))
- d = d * 16 / 9;
-
- if (left_damage) {
- dst[offset + 7 + y * stride] = cm[dst[offset + 7 + y * stride] + ((d * 7) >> 4)];
- dst[offset + 6 + y * stride] = cm[dst[offset + 6 + y * stride] + ((d * 5) >> 4)];
- dst[offset + 5 + y * stride] = cm[dst[offset + 5 + y * stride] + ((d * 3) >> 4)];
- dst[offset + 4 + y * stride] = cm[dst[offset + 4 + y * stride] + ((d * 1) >> 4)];
- }
- if (right_damage) {
- dst[offset + 8 + y * stride] = cm[dst[offset + 8 + y * stride] - ((d * 7) >> 4)];
- dst[offset + 9 + y * stride] = cm[dst[offset + 9 + y * stride] - ((d * 5) >> 4)];
- dst[offset + 10+ y * stride] = cm[dst[offset + 10 + y * stride] - ((d * 3) >> 4)];
- dst[offset + 11+ y * stride] = cm[dst[offset + 11 + y * stride] - ((d * 1) >> 4)];
- }
- }
- }
- }
-}
-
-/**
- * simple vertical deblocking filter used for error resilience
- * @param w width in 8 pixel blocks
- * @param h height in 8 pixel blocks
- */
-static void v_block_filter(MpegEncContext *s, uint8_t *dst, int w, int h,
- int stride, int is_luma)
-{
- int b_x, b_y, mvx_stride, mvy_stride;
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
- set_mv_strides(s, &mvx_stride, &mvy_stride);
- mvx_stride >>= is_luma;
- mvy_stride *= mvx_stride;
-
- for (b_y = 0; b_y < h - 1; b_y++) {
- for (b_x = 0; b_x < w; b_x++) {
- 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->current_picture.f.mb_type[(b_x >> is_luma) + ( b_y >> is_luma) * s->mb_stride]);
- int bottom_intra = IS_INTRA(s->current_picture.f.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->current_picture.f.motion_val[0][mvy_stride * b_y + mvx_stride * b_x];
- int16_t *bottom_mv = s->current_picture.f.motion_val[0][mvy_stride * (b_y + 1) + mvx_stride * b_x];
-
- if (!(top_damage || bottom_damage))
- continue; // both undamaged
-
- if ((!top_intra) && (!bottom_intra) &&
- FFABS(top_mv[0] - bottom_mv[0]) +
- FFABS(top_mv[1] + bottom_mv[1]) < 2)
- continue;
-
- for (x = 0; x < 8; x++) {
- int a, b, c, d;
-
- a = dst[offset + x + 7 * stride] - dst[offset + x + 6 * stride];
- b = dst[offset + x + 8 * stride] - dst[offset + x + 7 * stride];
- c = dst[offset + x + 9 * stride] - dst[offset + x + 8 * stride];
-
- d = FFABS(b) - ((FFABS(a) + FFABS(c) + 1) >> 1);
- d = FFMAX(d, 0);
- if (b < 0)
- d = -d;
-
- if (d == 0)
- continue;
-
- if (!(top_damage && bottom_damage))
- d = d * 16 / 9;
-
- if (top_damage) {
- dst[offset + x + 7 * stride] = cm[dst[offset + x + 7 * stride] + ((d * 7) >> 4)];
- dst[offset + x + 6 * stride] = cm[dst[offset + x + 6 * stride] + ((d * 5) >> 4)];
- dst[offset + x + 5 * stride] = cm[dst[offset + x + 5 * stride] + ((d * 3) >> 4)];
- dst[offset + x + 4 * stride] = cm[dst[offset + x + 4 * stride] + ((d * 1) >> 4)];
- }
- if (bottom_damage) {
- dst[offset + x + 8 * stride] = cm[dst[offset + x + 8 * stride] - ((d * 7) >> 4)];
- dst[offset + x + 9 * stride] = cm[dst[offset + x + 9 * stride] - ((d * 5) >> 4)];
- dst[offset + x + 10 * stride] = cm[dst[offset + x + 10 * stride] - ((d * 3) >> 4)];
- dst[offset + x + 11 * stride] = cm[dst[offset + x + 11 * stride] - ((d * 1) >> 4)];
- }
- }
- }
- }
-}
-
-static void guess_mv(MpegEncContext *s)
-{
- uint8_t *fixed = s->er_temp_buffer;
-#define MV_FROZEN 3
-#define MV_CHANGED 2
-#define MV_UNCHANGED 1
- const int mb_stride = s->mb_stride;
- const int mb_width = s->mb_width;
- const int mb_height = s->mb_height;
- int i, depth, num_avail;
- int mb_x, mb_y, mot_step, mot_stride;
-
- set_mv_strides(s, &mot_step, &mot_stride);
-
- num_avail = 0;
- for (i = 0; i < s->mb_num; i++) {
- const int mb_xy = s->mb_index2xy[i];
- int f = 0;
- int error = s->error_status_table[mb_xy];
-
- if (IS_INTRA(s->current_picture.f.mb_type[mb_xy]))
- f = MV_FROZEN; // intra // FIXME check
- if (!(error & ER_MV_ERROR))
- f = MV_FROZEN; // inter with undamaged MV
-
- fixed[mb_xy] = f;
- if (f == MV_FROZEN)
- num_avail++;
- else if(s->last_picture.f.data[0] && s->last_picture.f.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->current_picture.f.motion_val[0][mot_index][0]= s->last_picture.f.motion_val[0][mot_index][0];
- s->current_picture.f.motion_val[0][mot_index][1]= s->last_picture.f.motion_val[0][mot_index][1];
- s->current_picture.f.ref_index[0][4*mb_xy] = s->last_picture.f.ref_index[0][4*mb_xy];
- }
- }
-
- if ((!(s->avctx->error_concealment&FF_EC_GUESS_MVS)) ||
- num_avail <= mb_width / 2) {
- 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;
-
- if (IS_INTRA(s->current_picture.f.mb_type[mb_xy]))
- continue;
- if (!(s->error_status_table[mb_xy] & ER_MV_ERROR))
- continue;
-
- s->mv_dir = s->last_picture.f.data[0] ? MV_DIR_FORWARD
- : MV_DIR_BACKWARD;
- s->mb_intra = 0;
- s->mv_type = MV_TYPE_16X16;
- s->mb_skipped = 0;
-
- s->dsp.clear_blocks(s->block[0]);
-
- s->mb_x = mb_x;
- s->mb_y = mb_y;
- s->mv[0][0][0] = 0;
- s->mv[0][0][1] = 0;
- decode_mb(s, 0);
- }
- }
- return;
- }
-
- for (depth = 0; ; depth++) {
- int changed, pass, none_left;
-
- none_left = 1;
- changed = 1;
- for (pass = 0; (changed || pass < 2) && pass < 10; pass++) {
- int mb_x, mb_y;
- int score_sum = 0;
-
- changed = 0;
- 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_predictor[8][2] = { { 0 } };
- int ref[8] = { 0 };
- int pred_count = 0;
- int j;
- int best_score = 256 * 256 * 256 * 64;
- int best_pred = 0;
- const int mot_index = (mb_x + mb_y * mot_stride) * mot_step;
- int prev_x, prev_y, prev_ref;
-
- if ((mb_x ^ mb_y ^ pass) & 1)
- continue;
-
- if (fixed[mb_xy] == MV_FROZEN)
- continue;
- av_assert1(!IS_INTRA(s->current_picture.f.mb_type[mb_xy]));
- av_assert1(s->last_picture_ptr && s->last_picture_ptr->f.data[0]);
-
- j = 0;
- if (mb_x > 0 && fixed[mb_xy - 1] == MV_FROZEN)
- j = 1;
- if (mb_x + 1 < mb_width && fixed[mb_xy + 1] == MV_FROZEN)
- j = 1;
- if (mb_y > 0 && fixed[mb_xy - mb_stride] == MV_FROZEN)
- j = 1;
- if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride] == MV_FROZEN)
- j = 1;
- if (j == 0)
- continue;
-
- j = 0;
- if (mb_x > 0 && fixed[mb_xy - 1 ] == MV_CHANGED)
- j = 1;
- if (mb_x + 1 < mb_width && fixed[mb_xy + 1 ] == MV_CHANGED)
- j = 1;
- if (mb_y > 0 && fixed[mb_xy - mb_stride] == MV_CHANGED)
- j = 1;
- if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride] == MV_CHANGED)
- j = 1;
- if (j == 0 && pass > 1)
- continue;
-
- none_left = 0;
-
- if (mb_x > 0 && fixed[mb_xy - 1]) {
- mv_predictor[pred_count][0] =
- s->current_picture.f.motion_val[0][mot_index - mot_step][0];
- mv_predictor[pred_count][1] =
- s->current_picture.f.motion_val[0][mot_index - mot_step][1];
- ref[pred_count] =
- s->current_picture.f.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->current_picture.f.motion_val[0][mot_index + mot_step][0];
- mv_predictor[pred_count][1] =
- s->current_picture.f.motion_val[0][mot_index + mot_step][1];
- ref[pred_count] =
- s->current_picture.f.ref_index[0][4 * (mb_xy + 1)];
- pred_count++;
- }
- if (mb_y > 0 && fixed[mb_xy - mb_stride]) {
- mv_predictor[pred_count][0] =
- s->current_picture.f.motion_val[0][mot_index - mot_stride * mot_step][0];
- mv_predictor[pred_count][1] =
- s->current_picture.f.motion_val[0][mot_index - mot_stride * mot_step][1];
- ref[pred_count] =
- s->current_picture.f.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->current_picture.f.motion_val[0][mot_index + mot_stride * mot_step][0];
- mv_predictor[pred_count][1] =
- s->current_picture.f.motion_val[0][mot_index + mot_stride * mot_step][1];
- ref[pred_count] =
- s->current_picture.f.ref_index[0][4 * (mb_xy + s->mb_stride)];
- pred_count++;
- }
- if (pred_count == 0)
- continue;
-
- if (pred_count > 1) {
- int sum_x = 0, sum_y = 0, sum_r = 0;
- int max_x, max_y, min_x, min_y, max_r, min_r;
-
- for (j = 0; j < pred_count; j++) {
- sum_x += mv_predictor[j][0];
- sum_y += mv_predictor[j][1];
- sum_r += ref[j];
- if (j && ref[j] != ref[j - 1])
- goto skip_mean_and_median;
- }
-
- /* mean */
- mv_predictor[pred_count][0] = sum_x / j;
- mv_predictor[pred_count][1] = sum_y / j;
- ref[pred_count] = sum_r / j;
-
- /* median */
- if (pred_count >= 3) {
- min_y = min_x = min_r = 99999;
- max_y = max_x = max_r = -99999;
- } else {
- min_x = min_y = max_x = max_y = min_r = max_r = 0;
- }
- for (j = 0; j < pred_count; j++) {
- max_x = FFMAX(max_x, mv_predictor[j][0]);
- max_y = FFMAX(max_y, mv_predictor[j][1]);
- max_r = FFMAX(max_r, ref[j]);
- min_x = FFMIN(min_x, mv_predictor[j][0]);
- min_y = FFMIN(min_y, mv_predictor[j][1]);
- min_r = FFMIN(min_r, ref[j]);
- }
- mv_predictor[pred_count + 1][0] = sum_x - max_x - min_x;
- mv_predictor[pred_count + 1][1] = sum_y - max_y - min_y;
- ref[pred_count + 1] = sum_r - max_r - min_r;
-
- if (pred_count == 4) {
- mv_predictor[pred_count + 1][0] /= 2;
- mv_predictor[pred_count + 1][1] /= 2;
- ref[pred_count + 1] /= 2;
- }
- pred_count += 2;
- }
-
-skip_mean_and_median:
- /* zero MV */
- pred_count++;
-
- if (!fixed[mb_xy] && 0) {
- if (s->avctx->codec_id == AV_CODEC_ID_H264) {
- // FIXME
- } else {
- ff_thread_await_progress(&s->last_picture_ptr->f,
- mb_y, 0);
- }
- if (!s->last_picture.f.motion_val[0] ||
- !s->last_picture.f.ref_index[0])
- goto skip_last_mv;
- prev_x = s->last_picture.f.motion_val[0][mot_index][0];
- prev_y = s->last_picture.f.motion_val[0][mot_index][1];
- prev_ref = s->last_picture.f.ref_index[0][4 * mb_xy];
- } else {
- prev_x = s->current_picture.f.motion_val[0][mot_index][0];
- prev_y = s->current_picture.f.motion_val[0][mot_index][1];
- prev_ref = s->current_picture.f.ref_index[0][4 * mb_xy];
- }
-
- /* last MV */
- mv_predictor[pred_count][0] = prev_x;
- mv_predictor[pred_count][1] = prev_y;
- ref[pred_count] = prev_ref;
- pred_count++;
-
-skip_last_mv:
- s->mv_dir = MV_DIR_FORWARD;
- s->mb_intra = 0;
- s->mv_type = MV_TYPE_16X16;
- s->mb_skipped = 0;
-
- s->dsp.clear_blocks(s->block[0]);
-
- s->mb_x = mb_x;
- s->mb_y = mb_y;
-
- for (j = 0; j < pred_count; j++) {
- int score = 0;
- uint8_t *src = s->current_picture.f.data[0] +
- mb_x * 16 + mb_y * 16 * s->linesize;
-
- s->current_picture.f.motion_val[0][mot_index][0] =
- s->mv[0][0][0] = mv_predictor[j][0];
- s->current_picture.f.motion_val[0][mot_index][1] =
- s->mv[0][0][1] = mv_predictor[j][1];
-
- // predictor intra or otherwise not available
- if (ref[j] < 0)
- continue;
-
- decode_mb(s, ref[j]);
-
- if (mb_x > 0 && fixed[mb_xy - 1]) {
- int k;
- for (k = 0; k < 16; k++)
- score += FFABS(src[k * s->linesize - 1] -
- src[k * s->linesize]);
- }
- if (mb_x + 1 < mb_width && fixed[mb_xy + 1]) {
- int k;
- for (k = 0; k < 16; k++)
- score += FFABS(src[k * s->linesize + 15] -
- src[k * s->linesize + 16]);
- }
- if (mb_y > 0 && fixed[mb_xy - mb_stride]) {
- int k;
- for (k = 0; k < 16; k++)
- score += FFABS(src[k - s->linesize] - src[k]);
- }
- if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride]) {
- int k;
- for (k = 0; k < 16; k++)
- score += FFABS(src[k + s->linesize * 15] -
- src[k + s->linesize * 16]);
- }
-
- if (score <= best_score) { // <= will favor the last MV
- best_score = score;
- best_pred = j;
- }
- }
- score_sum += best_score;
- s->mv[0][0][0] = mv_predictor[best_pred][0];
- s->mv[0][0][1] = mv_predictor[best_pred][1];
-
- for (i = 0; i < mot_step; i++)
- for (j = 0; j < mot_step; j++) {
- s->current_picture.f.motion_val[0][mot_index + i + j * mot_stride][0] = s->mv[0][0][0];
- s->current_picture.f.motion_val[0][mot_index + i + j * mot_stride][1] = s->mv[0][0][1];
- }
-
- decode_mb(s, ref[best_pred]);
-
-
- if (s->mv[0][0][0] != prev_x || s->mv[0][0][1] != prev_y) {
- fixed[mb_xy] = MV_CHANGED;
- changed++;
- } else
- fixed[mb_xy] = MV_UNCHANGED;
- }
- }
- }
-
- if (none_left)
- return;
-
- for (i = 0; i < s->mb_num; i++) {
- int mb_xy = s->mb_index2xy[i];
- if (fixed[mb_xy])
- fixed[mb_xy] = MV_FROZEN;
- }
- }
-}
-
-static int is_intra_more_likely(MpegEncContext *s)
-{
- int is_intra_likely, i, j, undamaged_count, skip_amount, mb_x, mb_y;
-
- if (!s->last_picture_ptr || !s->last_picture_ptr->f.data[0])
- return 1; // no previous frame available -> use spatial prediction
-
- undamaged_count = 0;
- for (i = 0; i < s->mb_num; i++) {
- const int mb_xy = s->mb_index2xy[i];
- const int error = s->error_status_table[mb_xy];
- if (!((error & ER_DC_ERROR) && (error & ER_MV_ERROR)))
- undamaged_count++;
- }
-
- if (s->codec_id == AV_CODEC_ID_H264) {
- H264Context *h = (void*) s;
- if (h->list_count <= 0 || h->ref_count[0] <= 0 ||
- !h->ref_list[0][0].f.data[0])
- return 1;
- }
-
- if (undamaged_count < 5)
- return 0; // almost all MBs damaged -> use temporal prediction
-
- // prevent dsp.sad() check, that requires access to the image
- if (CONFIG_MPEG_XVMC_DECODER &&
- s->avctx->xvmc_acceleration &&
- s->pict_type == AV_PICTURE_TYPE_I)
- return 1;
-
- skip_amount = FFMAX(undamaged_count / 50, 1); // check only up to 50 MBs
- is_intra_likely = 0;
-
- j = 0;
- for (mb_y = 0; mb_y < s->mb_height - 1; mb_y++) {
- for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
- int error;
- const int mb_xy = mb_x + mb_y * s->mb_stride;
-
- error = s->error_status_table[mb_xy];
- if ((error & ER_DC_ERROR) && (error & ER_MV_ERROR))
- continue; // skip damaged
-
- j++;
- // skip a few to speed things up
- if ((j % skip_amount) != 0)
- continue;
-
- if (s->pict_type == AV_PICTURE_TYPE_I) {
- uint8_t *mb_ptr = s->current_picture.f.data[0] +
- mb_x * 16 + mb_y * 16 * s->linesize;
- uint8_t *last_mb_ptr = s->last_picture.f.data[0] +
- mb_x * 16 + mb_y * 16 * s->linesize;
-
- if (s->avctx->codec_id == AV_CODEC_ID_H264) {
- // FIXME
- } else {
- ff_thread_await_progress(&s->last_picture_ptr->f,
- mb_y, 0);
- }
- is_intra_likely += s->dsp.sad[0](NULL, last_mb_ptr, mb_ptr , s->linesize, 16);
- // FIXME need await_progress() here
- is_intra_likely -= s->dsp.sad[0](NULL, last_mb_ptr, last_mb_ptr+s->linesize*16, s->linesize, 16);
- } else {
- if (IS_INTRA(s->current_picture.f.mb_type[mb_xy]))
- is_intra_likely++;
- else
- is_intra_likely--;
- }
- }
- }
- // printf("is_intra_likely: %d type:%d\n", is_intra_likely, s->pict_type);
- return is_intra_likely > 0;
-}
-
-void ff_er_frame_start(MpegEncContext *s)
-{
- if (!s->err_recognition)
- return;
-
- memset(s->error_status_table, ER_MB_ERROR | VP_START | ER_MB_END,
- s->mb_stride * s->mb_height * sizeof(uint8_t));
- s->error_count = 3 * s->mb_num;
- s->error_occurred = 0;
-}
-
-/**
- * Add a slice.
- * @param endx x component of the last macroblock, can be -1
- * for the last of the previous line
- * @param status the status at the end (ER_MV_END, ER_AC_ERROR, ...), it is
- * assumed that no earlier end or error of the same type occurred
- */
-void ff_er_add_slice(MpegEncContext *s, int startx, int starty,
- int endx, int endy, int status)
-{
- const int start_i = av_clip(startx + starty * s->mb_width, 0, s->mb_num - 1);
- const int end_i = av_clip(endx + endy * s->mb_width, 0, s->mb_num);
- const int start_xy = s->mb_index2xy[start_i];
- const int end_xy = s->mb_index2xy[end_i];
- int mask = -1;
-
- if (s->avctx->hwaccel)
- return;
-
- if (start_i > end_i || start_xy > end_xy) {
- av_log(s->avctx, AV_LOG_ERROR,
- "internal error, slice end before start\n");
- return;
- }
-
- if (!s->err_recognition)
- return;
-
- mask &= ~VP_START;
- if (status & (ER_AC_ERROR | ER_AC_END)) {
- mask &= ~(ER_AC_ERROR | ER_AC_END);
- s->error_count -= end_i - start_i + 1;
- }
- if (status & (ER_DC_ERROR | ER_DC_END)) {
- mask &= ~(ER_DC_ERROR | ER_DC_END);
- s->error_count -= end_i - start_i + 1;
- }
- if (status & (ER_MV_ERROR | ER_MV_END)) {
- mask &= ~(ER_MV_ERROR | ER_MV_END);
- s->error_count -= end_i - start_i + 1;
- }
-
- if (status & ER_MB_ERROR) {
- s->error_occurred = 1;
- s->error_count = INT_MAX;
- }
-
- if (mask == ~0x7F) {
- memset(&s->error_status_table[start_xy], 0,
- (end_xy - start_xy) * sizeof(uint8_t));
- } else {
- int i;
- for (i = start_xy; i < end_xy; i++)
- s->error_status_table[i] &= mask;
- }
-
- if (end_i == s->mb_num)
- s->error_count = INT_MAX;
- else {
- s->error_status_table[end_xy] &= mask;
- s->error_status_table[end_xy] |= status;
- }
-
- s->error_status_table[start_xy] |= VP_START;
-
- if (start_xy > 0 && s->avctx->thread_count <= 1 &&
- s->avctx->skip_top * s->mb_width < start_i) {
- int prev_status = s->error_status_table[s->mb_index2xy[start_i - 1]];
-
- prev_status &= ~ VP_START;
- if (prev_status != (ER_MV_END | ER_DC_END | ER_AC_END))
- s->error_count = INT_MAX;
- }
-}
-
-void ff_er_frame_end(MpegEncContext *s)
-{
- int i, mb_x, mb_y, error, error_type, dc_error, mv_error, ac_error;
- int distance;
- int threshold_part[4] = { 100, 100, 100 };
- int threshold = 50;
- int is_intra_likely;
- int size = s->b8_stride * 2 * s->mb_height;
- Picture *pic = s->current_picture_ptr;
-
- /* We do not support ER of field pictures yet,
- * though it should not crash if enabled. */
- if (!s->err_recognition || s->error_count == 0 || s->avctx->lowres ||
- s->avctx->hwaccel ||
- s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU ||
- s->picture_structure != PICT_FRAME ||
- s->error_count == 3 * s->mb_width *
- (s->avctx->skip_top + s->avctx->skip_bottom)) {
- return;
- };
-
- if ( s->picture_structure == PICT_FRAME
- && s->current_picture.f.linesize[0] != s->current_picture_ptr->f.linesize[0]) {
- av_log(s->avctx, AV_LOG_ERROR, "Error concealment not possible, frame not fully initialized\n");
- return;
- }
-
- if (s->current_picture.f.motion_val[0] == NULL) {
- av_log(s->avctx, AV_LOG_ERROR, "Warning MVs not available\n");
-
- for (i = 0; i < 2; i++) {
- pic->f.ref_index[i] = av_mallocz(s->mb_stride * s->mb_height * 4 * sizeof(uint8_t));
- pic->motion_val_base[i] = av_mallocz((size + 4) * 2 * sizeof(uint16_t));
- pic->f.motion_val[i] = pic->motion_val_base[i] + 4;
- }
- pic->f.motion_subsample_log2 = 3;
- s->current_picture = *s->current_picture_ptr;
- }
-
- if (s->avctx->debug & FF_DEBUG_ER) {
- for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
- for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
- int status = s->error_status_table[mb_x + mb_y * s->mb_stride];
-
- av_log(s->avctx, AV_LOG_DEBUG, "%2X ", status);
- }
- av_log(s->avctx, AV_LOG_DEBUG, "\n");
- }
- }
-
-#if 1
- /* handle overlapping slices */
- for (error_type = 1; error_type <= 3; error_type++) {
- int end_ok = 0;
-
- for (i = s->mb_num - 1; i >= 0; i--) {
- const int mb_xy = s->mb_index2xy[i];
- int error = s->error_status_table[mb_xy];
-
- if (error & (1 << error_type))
- end_ok = 1;
- if (error & (8 << error_type))
- end_ok = 1;
-
- if (!end_ok)
- s->error_status_table[mb_xy] |= 1 << error_type;
-
- if (error & VP_START)
- end_ok = 0;
- }
- }
-#endif
-#if 1
- /* handle slices with partitions of different length */
- if (s->partitioned_frame) {
- int end_ok = 0;
-
- for (i = s->mb_num - 1; i >= 0; i--) {
- const int mb_xy = s->mb_index2xy[i];
- int error = s->error_status_table[mb_xy];
-
- if (error & ER_AC_END)
- end_ok = 0;
- if ((error & ER_MV_END) ||
- (error & ER_DC_END) ||
- (error & ER_AC_ERROR))
- end_ok = 1;
-
- if (!end_ok)
- s->error_status_table[mb_xy]|= ER_AC_ERROR;
-
- if (error & VP_START)
- end_ok = 0;
- }
- }
-#endif
- /* handle missing slices */
- if (s->err_recognition & AV_EF_EXPLODE) {
- int end_ok = 1;
-
- // FIXME + 100 hack
- for (i = s->mb_num - 2; i >= s->mb_width + 100; i--) {
- const int mb_xy = s->mb_index2xy[i];
- int error1 = s->error_status_table[mb_xy];
- int error2 = s->error_status_table[s->mb_index2xy[i + 1]];
-
- if (error1 & VP_START)
- end_ok = 1;
-
- if (error2 == (VP_START | ER_MB_ERROR | ER_MB_END) &&
- error1 != (VP_START | ER_MB_ERROR | ER_MB_END) &&
- ((error1 & ER_AC_END) || (error1 & ER_DC_END) ||
- (error1 & ER_MV_END))) {
- // end & uninit
- end_ok = 0;
- }
-
- if (!end_ok)
- s->error_status_table[mb_xy] |= ER_MB_ERROR;
- }
- }
-
-#if 1
- /* backward mark errors */
- distance = 9999999;
- for (error_type = 1; error_type <= 3; error_type++) {
- for (i = s->mb_num - 1; i >= 0; i--) {
- const int mb_xy = s->mb_index2xy[i];
- int error = s->error_status_table[mb_xy];
-
- if (!s->mbskip_table[mb_xy]) // FIXME partition specific
- distance++;
- if (error & (1 << error_type))
- distance = 0;
-
- if (s->partitioned_frame) {
- if (distance < threshold_part[error_type - 1])
- s->error_status_table[mb_xy] |= 1 << error_type;
- } else {
- if (distance < threshold)
- s->error_status_table[mb_xy] |= 1 << error_type;
- }
-
- if (error & VP_START)
- distance = 9999999;
- }
- }
-#endif
-
- /* forward mark errors */
- error = 0;
- for (i = 0; i < s->mb_num; i++) {
- const int mb_xy = s->mb_index2xy[i];
- int old_error = s->error_status_table[mb_xy];
-
- if (old_error & VP_START) {
- error = old_error & ER_MB_ERROR;
- } else {
- error |= old_error & ER_MB_ERROR;
- s->error_status_table[mb_xy] |= error;
- }
- }
-#if 1
- /* handle not partitioned case */
- if (!s->partitioned_frame) {
- for (i = 0; i < s->mb_num; i++) {
- const int mb_xy = s->mb_index2xy[i];
- error = s->error_status_table[mb_xy];
- if (error & ER_MB_ERROR)
- error |= ER_MB_ERROR;
- s->error_status_table[mb_xy] = error;
- }
- }
-#endif
-
- dc_error = ac_error = mv_error = 0;
- for (i = 0; i < s->mb_num; i++) {
- const int mb_xy = s->mb_index2xy[i];
- error = s->error_status_table[mb_xy];
- if (error & ER_DC_ERROR)
- dc_error++;
- if (error & ER_AC_ERROR)
- ac_error++;
- if (error & ER_MV_ERROR)
- 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->pict_type));
-
- is_intra_likely = is_intra_more_likely(s);
-
- /* set unknown mb-type to most likely */
- for (i = 0; i < s->mb_num; i++) {
- const int mb_xy = s->mb_index2xy[i];
- error = s->error_status_table[mb_xy];
- if (!((error & ER_DC_ERROR) && (error & ER_MV_ERROR)))
- continue;
-
- if (is_intra_likely)
- s->current_picture.f.mb_type[mb_xy] = MB_TYPE_INTRA4x4;
- else
- s->current_picture.f.mb_type[mb_xy] = MB_TYPE_16x16 | MB_TYPE_L0;
- }
-
- // change inter to intra blocks if no reference frames are available
- if (!s->last_picture.f.data[0] && !s->next_picture.f.data[0])
- for (i = 0; i < s->mb_num; i++) {
- const int mb_xy = s->mb_index2xy[i];
- if (!IS_INTRA(s->current_picture.f.mb_type[mb_xy]))
- s->current_picture.f.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->current_picture.f.mb_type[mb_xy];
- int dir = !s->last_picture.f.data[0];
-
- error = s->error_status_table[mb_xy];
-
- if (IS_INTRA(mb_type))
- continue; // intra
- if (error & ER_MV_ERROR)
- continue; // inter with damaged MV
- if (!(error & ER_AC_ERROR))
- continue; // undamaged inter
-
- s->mv_dir = dir ? MV_DIR_BACKWARD : MV_DIR_FORWARD;
- s->mb_intra = 0;
- s->mb_skipped = 0;
- if (IS_8X8(mb_type)) {
- int mb_index = mb_x * 2 + mb_y * 2 * s->b8_stride;
- int j;
- s->mv_type = MV_TYPE_8X8;
- for (j = 0; j < 4; j++) {
- s->mv[0][j][0] = s->current_picture.f.motion_val[dir][mb_index + (j & 1) + (j >> 1) * s->b8_stride][0];
- s->mv[0][j][1] = s->current_picture.f.motion_val[dir][mb_index + (j & 1) + (j >> 1) * s->b8_stride][1];
- }
- } else {
- s->mv_type = MV_TYPE_16X16;
- s->mv[0][0][0] = s->current_picture.f.motion_val[dir][mb_x * 2 + mb_y * 2 * s->b8_stride][0];
- s->mv[0][0][1] = s->current_picture.f.motion_val[dir][mb_x * 2 + mb_y * 2 * s->b8_stride][1];
- }
-
- s->dsp.clear_blocks(s->block[0]);
-
- s->mb_x = mb_x;
- s->mb_y = mb_y;
- decode_mb(s, 0 /* FIXME h264 partitioned slices need this set */);
- }
- }
-
- /* guess MVs */
- if (s->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->current_picture.f.mb_type[mb_xy];
-
- error = s->error_status_table[mb_xy];
-
- if (IS_INTRA(mb_type))
- continue;
- if (!(error & ER_MV_ERROR))
- continue; // inter with undamaged MV
- if (!(error & ER_AC_ERROR))
- continue; // undamaged inter
-
- s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
- if (!s->last_picture.f.data[0])
- s->mv_dir &= ~MV_DIR_FORWARD;
- if (!s->next_picture.f.data[0])
- s->mv_dir &= ~MV_DIR_BACKWARD;
- s->mb_intra = 0;
- s->mv_type = MV_TYPE_16X16;
- s->mb_skipped = 0;
-
- if (s->pp_time) {
- int time_pp = s->pp_time;
- int time_pb = s->pb_time;
-
- av_assert0(s->avctx->codec_id != AV_CODEC_ID_H264);
- ff_thread_await_progress(&s->next_picture_ptr->f, mb_y, 0);
- s->mv[0][0][0] = s->next_picture.f.motion_val[0][xy][0] * time_pb / time_pp;
- s->mv[0][0][1] = s->next_picture.f.motion_val[0][xy][1] * time_pb / time_pp;
- s->mv[1][0][0] = s->next_picture.f.motion_val[0][xy][0] * (time_pb - time_pp) / time_pp;
- s->mv[1][0][1] = s->next_picture.f.motion_val[0][xy][1] * (time_pb - time_pp) / time_pp;
- } else {
- s->mv[0][0][0] = 0;
- s->mv[0][0][1] = 0;
- s->mv[1][0][0] = 0;
- s->mv[1][0][1] = 0;
- }
-
- s->dsp.clear_blocks(s->block[0]);
- s->mb_x = mb_x;
- s->mb_y = mb_y;
- decode_mb(s, 0);
- }
- }
- } else
- guess_mv(s);
-
- /* the filters below are not XvMC compatible, skip them */
- if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)
- goto ec_clean;
- /* 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++) {
- int dc, dcu, dcv, y, n;
- 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->current_picture.f.mb_type[mb_xy];
-
- error = s->error_status_table[mb_xy];
-
- if (IS_INTRA(mb_type) && s->partitioned_frame)
- continue;
- // if (error & ER_MV_ERROR)
- // continue; // inter data damaged FIXME is this good?
-
- dest_y = s->current_picture.f.data[0] + mb_x * 16 + mb_y * 16 * s->linesize;
- dest_cb = s->current_picture.f.data[1] + mb_x * 8 + mb_y * 8 * s->uvlinesize;
- dest_cr = s->current_picture.f.data[2] + mb_x * 8 + mb_y * 8 * s->uvlinesize;
-
- dc_ptr = &s->dc_val[0][mb_x * 2 + mb_y * 2 * s->b8_stride];
- for (n = 0; n < 4; n++) {
- dc = 0;
- for (y = 0; y < 8; y++) {
- int x;
- for (x = 0; x < 8; x++)
- dc += dest_y[x + (n & 1) * 8 +
- (y + (n >> 1) * 8) * s->linesize];
- }
- dc_ptr[(n & 1) + (n >> 1) * s->b8_stride] = (dc + 4) >> 3;
- }
-
- dcu = dcv = 0;
- for (y = 0; y < 8; y++) {
- int x;
- for (x = 0; x < 8; x++) {
- dcu += dest_cb[x + y * s->uvlinesize];
- dcv += dest_cr[x + y * s->uvlinesize];
- }
- }
- s->dc_val[1][mb_x + mb_y * s->mb_stride] = (dcu + 4) >> 3;
- s->dc_val[2][mb_x + mb_y * s->mb_stride] = (dcv + 4) >> 3;
- }
- }
-#if 1
- /* guess DC for damaged blocks */
- guess_dc(s, s->dc_val[0], s->mb_width*2, s->mb_height*2, s->b8_stride, 1);
- guess_dc(s, s->dc_val[1], s->mb_width , s->mb_height , s->mb_stride, 0);
- guess_dc(s, s->dc_val[2], s->mb_width , s->mb_height , s->mb_stride, 0);
-#endif
-
- /* filter luma DC */
- filter181(s->dc_val[0], s->mb_width * 2, s->mb_height * 2, s->b8_stride);
-
-#if 1
- /* render DC only intra */
- for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
- 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->current_picture.f.mb_type[mb_xy];
-
- error = s->error_status_table[mb_xy];
-
- if (IS_INTER(mb_type))
- continue;
- if (!(error & ER_AC_ERROR))
- continue; // undamaged
-
- dest_y = s->current_picture.f.data[0] + mb_x * 16 + mb_y * 16 * s->linesize;
- dest_cb = s->current_picture.f.data[1] + mb_x * 8 + mb_y * 8 * s->uvlinesize;
- dest_cr = s->current_picture.f.data[2] + mb_x * 8 + mb_y * 8 * s->uvlinesize;
-
- put_dc(s, dest_y, dest_cb, dest_cr, mb_x, mb_y);
- }
- }
-#endif
-
- if (s->avctx->error_concealment & FF_EC_DEBLOCK) {
- /* filter horizontal block boundaries */
- h_block_filter(s, s->current_picture.f.data[0], s->mb_width * 2,
- s->mb_height * 2, s->linesize, 1);
- h_block_filter(s, s->current_picture.f.data[1], s->mb_width,
- s->mb_height , s->uvlinesize, 0);
- h_block_filter(s, s->current_picture.f.data[2], s->mb_width,
- s->mb_height , s->uvlinesize, 0);
-
- /* filter vertical block boundaries */
- v_block_filter(s, s->current_picture.f.data[0], s->mb_width * 2,
- s->mb_height * 2, s->linesize, 1);
- v_block_filter(s, s->current_picture.f.data[1], s->mb_width,
- s->mb_height , s->uvlinesize, 0);
- v_block_filter(s, s->current_picture.f.data[2], s->mb_width,
- s->mb_height , s->uvlinesize, 0);
- }
-
-ec_clean:
- /* clean a few tables */
- for (i = 0; i < s->mb_num; i++) {
- const int mb_xy = s->mb_index2xy[i];
- int error = s->error_status_table[mb_xy];
-
- if (s->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;
- }
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/faandct.c b/src/thirdparty/ffmpeg/libavcodec/faandct.c
deleted file mode 100644
index 5096c6f2c..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/faandct.c
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Floating point AAN DCT
- * this implementation is based upon the IJG integer AAN DCT (see jfdctfst.c)
- *
- * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
- * Copyright (c) 2003 Roman Shaposhnik
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-/**
- * @file
- * @brief
- * Floating point AAN DCT
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#include "dsputil.h"
-#include "faandct.h"
-#include "libavutil/internal.h"
-#include "libavutil/libm.h"
-
-#define FLOAT float
-
-//numbers generated by simple c code (not as accurate as they could be)
-/*
-for(i=0; i<8; i++){
- printf("#define B%d %1.20llf\n", i, (long double)1.0/(cosl(i*acosl(-1.0)/(long double)16.0)*sqrtl(2)));
-}
-*/
-#define B0 1.00000000000000000000
-#define B1 0.72095982200694791383 // (cos(pi*1/16)sqrt(2))^-1
-#define B2 0.76536686473017954350 // (cos(pi*2/16)sqrt(2))^-1
-#define B3 0.85043009476725644878 // (cos(pi*3/16)sqrt(2))^-1
-#define B4 1.00000000000000000000 // (cos(pi*4/16)sqrt(2))^-1
-#define B5 1.27275858057283393842 // (cos(pi*5/16)sqrt(2))^-1
-#define B6 1.84775906502257351242 // (cos(pi*6/16)sqrt(2))^-1
-#define B7 3.62450978541155137218 // (cos(pi*7/16)sqrt(2))^-1
-
-
-#define A1 0.70710678118654752438 // cos(pi*4/16)
-#define A2 0.54119610014619698435 // cos(pi*6/16)sqrt(2)
-#define A5 0.38268343236508977170 // cos(pi*6/16)
-#define A4 1.30656296487637652774 // cos(pi*2/16)sqrt(2)
-
-static const FLOAT postscale[64]={
-B0*B0, B0*B1, B0*B2, B0*B3, B0*B4, B0*B5, B0*B6, B0*B7,
-B1*B0, B1*B1, B1*B2, B1*B3, B1*B4, B1*B5, B1*B6, B1*B7,
-B2*B0, B2*B1, B2*B2, B2*B3, B2*B4, B2*B5, B2*B6, B2*B7,
-B3*B0, B3*B1, B3*B2, B3*B3, B3*B4, B3*B5, B3*B6, B3*B7,
-B4*B0, B4*B1, B4*B2, B4*B3, B4*B4, B4*B5, B4*B6, B4*B7,
-B5*B0, B5*B1, B5*B2, B5*B3, B5*B4, B5*B5, B5*B6, B5*B7,
-B6*B0, B6*B1, B6*B2, B6*B3, B6*B4, B6*B5, B6*B6, B6*B7,
-B7*B0, B7*B1, B7*B2, B7*B3, B7*B4, B7*B5, B7*B6, B7*B7,
-};
-
-static av_always_inline void row_fdct(FLOAT temp[64], int16_t *data)
-{
- FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
- FLOAT tmp10, tmp11, tmp12, tmp13;
- FLOAT z2, z4, z11, z13;
- FLOAT av_unused z5;
- int i;
-
- for (i=0; i<8*8; i+=8) {
- tmp0= data[0 + i] + data[7 + i];
- tmp7= data[0 + i] - data[7 + i];
- tmp1= data[1 + i] + data[6 + i];
- tmp6= data[1 + i] - data[6 + i];
- tmp2= data[2 + i] + data[5 + i];
- tmp5= data[2 + i] - data[5 + i];
- tmp3= data[3 + i] + data[4 + i];
- tmp4= data[3 + i] - data[4 + i];
-
- tmp10= tmp0 + tmp3;
- tmp13= tmp0 - tmp3;
- tmp11= tmp1 + tmp2;
- tmp12= tmp1 - tmp2;
-
- temp[0 + i]= tmp10 + tmp11;
- temp[4 + i]= tmp10 - tmp11;
-
- tmp12 += tmp13;
- tmp12 *= A1;
- temp[2 + i]= tmp13 + tmp12;
- temp[6 + i]= tmp13 - tmp12;
-
- tmp4 += tmp5;
- tmp5 += tmp6;
- tmp6 += tmp7;
-
-#if 0
- z5= (tmp4 - tmp6) * A5;
- z2= tmp4*A2 + z5;
- z4= tmp6*A4 + z5;
-#else
- z2= tmp4*(A2+A5) - tmp6*A5;
- z4= tmp6*(A4-A5) + tmp4*A5;
-#endif
- tmp5*=A1;
-
- z11= tmp7 + tmp5;
- z13= tmp7 - tmp5;
-
- temp[5 + i]= z13 + z2;
- temp[3 + i]= z13 - z2;
- temp[1 + i]= z11 + z4;
- temp[7 + i]= z11 - z4;
- }
-}
-
-void ff_faandct(int16_t *data)
-{
- FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
- FLOAT tmp10, tmp11, tmp12, tmp13;
- FLOAT z2, z4, z11, z13;
- FLOAT av_unused z5;
- FLOAT temp[64];
- int i;
-
- emms_c();
-
- row_fdct(temp, data);
-
- for (i=0; i<8; i++) {
- tmp0= temp[8*0 + i] + temp[8*7 + i];
- tmp7= temp[8*0 + i] - temp[8*7 + i];
- tmp1= temp[8*1 + i] + temp[8*6 + i];
- tmp6= temp[8*1 + i] - temp[8*6 + i];
- tmp2= temp[8*2 + i] + temp[8*5 + i];
- tmp5= temp[8*2 + i] - temp[8*5 + i];
- tmp3= temp[8*3 + i] + temp[8*4 + i];
- tmp4= temp[8*3 + i] - temp[8*4 + i];
-
- tmp10= tmp0 + tmp3;
- tmp13= tmp0 - tmp3;
- tmp11= tmp1 + tmp2;
- tmp12= tmp1 - tmp2;
-
- data[8*0 + i]= lrintf(postscale[8*0 + i] * (tmp10 + tmp11));
- data[8*4 + i]= lrintf(postscale[8*4 + i] * (tmp10 - tmp11));
-
- tmp12 += tmp13;
- tmp12 *= A1;
- data[8*2 + i]= lrintf(postscale[8*2 + i] * (tmp13 + tmp12));
- data[8*6 + i]= lrintf(postscale[8*6 + i] * (tmp13 - tmp12));
-
- tmp4 += tmp5;
- tmp5 += tmp6;
- tmp6 += tmp7;
-
-#if 0
- z5= (tmp4 - tmp6) * A5;
- z2= tmp4*A2 + z5;
- z4= tmp6*A4 + z5;
-#else
- z2= tmp4*(A2+A5) - tmp6*A5;
- z4= tmp6*(A4-A5) + tmp4*A5;
-#endif
- tmp5*=A1;
-
- z11= tmp7 + tmp5;
- z13= tmp7 - tmp5;
-
- data[8*5 + i]= lrintf(postscale[8*5 + i] * (z13 + z2));
- data[8*3 + i]= lrintf(postscale[8*3 + i] * (z13 - z2));
- data[8*1 + i]= lrintf(postscale[8*1 + i] * (z11 + z4));
- data[8*7 + i]= lrintf(postscale[8*7 + i] * (z11 - z4));
- }
-}
-
-void ff_faandct248(int16_t *data)
-{
- FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
- FLOAT tmp10, tmp11, tmp12, tmp13;
- FLOAT temp[64];
- int i;
-
- emms_c();
-
- row_fdct(temp, data);
-
- for (i=0; i<8; i++) {
- tmp0 = temp[8*0 + i] + temp[8*1 + i];
- tmp1 = temp[8*2 + i] + temp[8*3 + i];
- tmp2 = temp[8*4 + i] + temp[8*5 + i];
- tmp3 = temp[8*6 + i] + temp[8*7 + i];
- tmp4 = temp[8*0 + i] - temp[8*1 + i];
- tmp5 = temp[8*2 + i] - temp[8*3 + i];
- tmp6 = temp[8*4 + i] - temp[8*5 + i];
- tmp7 = temp[8*6 + i] - temp[8*7 + i];
-
- tmp10 = tmp0 + tmp3;
- tmp11 = tmp1 + tmp2;
- tmp12 = tmp1 - tmp2;
- tmp13 = tmp0 - tmp3;
-
- data[8*0 + i] = lrintf(postscale[8*0 + i] * (tmp10 + tmp11));
- data[8*4 + i] = lrintf(postscale[8*4 + i] * (tmp10 - tmp11));
-
- tmp12 += tmp13;
- tmp12 *= A1;
- data[8*2 + i] = lrintf(postscale[8*2 + i] * (tmp13 + tmp12));
- data[8*6 + i] = lrintf(postscale[8*6 + i] * (tmp13 - tmp12));
-
- tmp10 = tmp4 + tmp7;
- tmp11 = tmp5 + tmp6;
- tmp12 = tmp5 - tmp6;
- tmp13 = tmp4 - tmp7;
-
- data[8*1 + i] = lrintf(postscale[8*0 + i] * (tmp10 + tmp11));
- data[8*5 + i] = lrintf(postscale[8*4 + i] * (tmp10 - tmp11));
-
- tmp12 += tmp13;
- tmp12 *= A1;
- data[8*3 + i] = lrintf(postscale[8*2 + i] * (tmp13 + tmp12));
- data[8*7 + i] = lrintf(postscale[8*6 + i] * (tmp13 - tmp12));
- }
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/faandct.h b/src/thirdparty/ffmpeg/libavcodec/faandct.h
deleted file mode 100644
index 7d9e2a289..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/faandct.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Floating point AAN DCT
- * 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
- * @brief
- * Floating point AAN DCT
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#ifndef AVCODEC_FAANDCT_H
-#define AVCODEC_FAANDCT_H
-
-#include <stdint.h>
-
-void ff_faandct(int16_t *data);
-void ff_faandct248(int16_t *data);
-
-#endif /* AVCODEC_FAANDCT_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/faanidct.c b/src/thirdparty/ffmpeg/libavcodec/faanidct.c
deleted file mode 100644
index 8defb8b36..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/faanidct.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Floating point AAN IDCT
- * Copyright (c) 2008 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
- */
-#include "faanidct.h"
-#include "libavutil/common.h"
-
-/* To allow switching to double. */
-#define FLOAT float
-
-#define B0 1.0000000000000000000000
-#define B1 1.3870398453221474618216 // cos(pi*1/16)sqrt(2)
-#define B2 1.3065629648763765278566 // cos(pi*2/16)sqrt(2)
-#define B3 1.1758756024193587169745 // cos(pi*3/16)sqrt(2)
-#define B4 1.0000000000000000000000 // cos(pi*4/16)sqrt(2)
-#define B5 0.7856949583871021812779 // cos(pi*5/16)sqrt(2)
-#define B6 0.5411961001461969843997 // cos(pi*6/16)sqrt(2)
-#define B7 0.2758993792829430123360 // cos(pi*7/16)sqrt(2)
-
-#define A4 0.70710678118654752438 // cos(pi*4/16)
-#define A2 0.92387953251128675613 // cos(pi*2/16)
-
-static const FLOAT prescale[64]={
-B0*B0/8, B0*B1/8, B0*B2/8, B0*B3/8, B0*B4/8, B0*B5/8, B0*B6/8, B0*B7/8,
-B1*B0/8, B1*B1/8, B1*B2/8, B1*B3/8, B1*B4/8, B1*B5/8, B1*B6/8, B1*B7/8,
-B2*B0/8, B2*B1/8, B2*B2/8, B2*B3/8, B2*B4/8, B2*B5/8, B2*B6/8, B2*B7/8,
-B3*B0/8, B3*B1/8, B3*B2/8, B3*B3/8, B3*B4/8, B3*B5/8, B3*B6/8, B3*B7/8,
-B4*B0/8, B4*B1/8, B4*B2/8, B4*B3/8, B4*B4/8, B4*B5/8, B4*B6/8, B4*B7/8,
-B5*B0/8, B5*B1/8, B5*B2/8, B5*B3/8, B5*B4/8, B5*B5/8, B5*B6/8, B5*B7/8,
-B6*B0/8, B6*B1/8, B6*B2/8, B6*B3/8, B6*B4/8, B6*B5/8, B6*B6/8, B6*B7/8,
-B7*B0/8, B7*B1/8, B7*B2/8, B7*B3/8, B7*B4/8, B7*B5/8, B7*B6/8, B7*B7/8,
-};
-
-static inline void p8idct(int16_t data[64], FLOAT temp[64], uint8_t *dest, int stride, int x, int y, int type){
- int i;
- FLOAT av_unused tmp0;
- FLOAT s04, d04, s17, d17, s26, d26, s53, d53;
- FLOAT os07, os16, os25, os34;
- FLOAT od07, od16, od25, od34;
-
- for(i=0; i<y*8; i+=y){
- s17= temp[1*x + i] + temp[7*x + i];
- d17= temp[1*x + i] - temp[7*x + i];
- s53= temp[5*x + i] + temp[3*x + i];
- d53= temp[5*x + i] - temp[3*x + i];
-
- od07= s17 + s53;
- od25= (s17 - s53)*(2*A4);
-
-#if 0 //these 2 are equivalent
- tmp0= (d17 + d53)*(2*A2);
- od34= d17*( 2*B6) - tmp0;
- od16= d53*(-2*B2) + tmp0;
-#else
- od34= d17*(2*(B6-A2)) - d53*(2*A2);
- od16= d53*(2*(A2-B2)) + d17*(2*A2);
-#endif
-
- od16 -= od07;
- od25 -= od16;
- od34 += od25;
-
- s26 = temp[2*x + i] + temp[6*x + i];
- d26 = temp[2*x + i] - temp[6*x + i];
- d26*= 2*A4;
- d26-= s26;
-
- s04= temp[0*x + i] + temp[4*x + i];
- d04= temp[0*x + i] - temp[4*x + i];
-
- os07= s04 + s26;
- os34= s04 - s26;
- os16= d04 + d26;
- os25= d04 - d26;
-
- if(type==0){
- temp[0*x + i]= os07 + od07;
- temp[7*x + i]= os07 - od07;
- temp[1*x + i]= os16 + od16;
- temp[6*x + i]= os16 - od16;
- temp[2*x + i]= os25 + od25;
- temp[5*x + i]= os25 - od25;
- temp[3*x + i]= os34 - od34;
- temp[4*x + i]= os34 + od34;
- }else if(type==1){
- data[0*x + i]= lrintf(os07 + od07);
- data[7*x + i]= lrintf(os07 - od07);
- data[1*x + i]= lrintf(os16 + od16);
- data[6*x + i]= lrintf(os16 - od16);
- data[2*x + i]= lrintf(os25 + od25);
- data[5*x + i]= lrintf(os25 - od25);
- data[3*x + i]= lrintf(os34 - od34);
- data[4*x + i]= lrintf(os34 + od34);
- }else if(type==2){
- dest[0*stride + i]= av_clip_uint8(((int)dest[0*stride + i]) + lrintf(os07 + od07));
- dest[7*stride + i]= av_clip_uint8(((int)dest[7*stride + i]) + lrintf(os07 - od07));
- dest[1*stride + i]= av_clip_uint8(((int)dest[1*stride + i]) + lrintf(os16 + od16));
- dest[6*stride + i]= av_clip_uint8(((int)dest[6*stride + i]) + lrintf(os16 - od16));
- dest[2*stride + i]= av_clip_uint8(((int)dest[2*stride + i]) + lrintf(os25 + od25));
- dest[5*stride + i]= av_clip_uint8(((int)dest[5*stride + i]) + lrintf(os25 - od25));
- dest[3*stride + i]= av_clip_uint8(((int)dest[3*stride + i]) + lrintf(os34 - od34));
- dest[4*stride + i]= av_clip_uint8(((int)dest[4*stride + i]) + lrintf(os34 + od34));
- }else{
- dest[0*stride + i]= av_clip_uint8(lrintf(os07 + od07));
- dest[7*stride + i]= av_clip_uint8(lrintf(os07 - od07));
- dest[1*stride + i]= av_clip_uint8(lrintf(os16 + od16));
- dest[6*stride + i]= av_clip_uint8(lrintf(os16 - od16));
- dest[2*stride + i]= av_clip_uint8(lrintf(os25 + od25));
- dest[5*stride + i]= av_clip_uint8(lrintf(os25 - od25));
- dest[3*stride + i]= av_clip_uint8(lrintf(os34 - od34));
- dest[4*stride + i]= av_clip_uint8(lrintf(os34 + od34));
- }
- }
-}
-
-void ff_faanidct(int16_t block[64]){
- FLOAT temp[64];
- int i;
-
- emms_c();
-
- for(i=0; i<64; i++)
- temp[i] = block[i] * prescale[i];
-
- p8idct(block, temp, NULL, 0, 1, 8, 0);
- p8idct(block, temp, NULL, 0, 8, 1, 1);
-}
-
-void ff_faanidct_add(uint8_t *dest, int line_size, int16_t block[64]){
- FLOAT temp[64];
- int i;
-
- emms_c();
-
- for(i=0; i<64; i++)
- temp[i] = block[i] * prescale[i];
-
- p8idct(block, temp, NULL, 0, 1, 8, 0);
- p8idct(NULL , temp, dest, line_size, 8, 1, 2);
-}
-
-void ff_faanidct_put(uint8_t *dest, int line_size, int16_t block[64]){
- FLOAT temp[64];
- int i;
-
- emms_c();
-
- for(i=0; i<64; i++)
- temp[i] = block[i] * prescale[i];
-
- p8idct(block, temp, NULL, 0, 1, 8, 0);
- p8idct(NULL , temp, dest, line_size, 8, 1, 3);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/faanidct.h b/src/thirdparty/ffmpeg/libavcodec/faanidct.h
deleted file mode 100644
index 874f5f474..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/faanidct.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Floating point AAN IDCT
- * Copyright (c) 2008 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
- */
-
-#ifndef AVCODEC_FAANIDCT_H
-#define AVCODEC_FAANIDCT_H
-
-#include <stdint.h>
-
-void ff_faanidct(int16_t block[64]);
-void ff_faanidct_add(uint8_t *dest, int line_size, int16_t block[64]);
-void ff_faanidct_put(uint8_t *dest, int line_size, int16_t block[64]);
-
-#endif /* AVCODEC_FAANIDCT_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/fft-internal.h b/src/thirdparty/ffmpeg/libavcodec/fft-internal.h
deleted file mode 100644
index eabf2e7b5..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/fft-internal.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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_FFT_INTERNAL_H
-#define AVCODEC_FFT_INTERNAL_H
-
-#if CONFIG_FFT_FLOAT
-
-#define FIX15(v) (v)
-#define sqrthalf (float)M_SQRT1_2
-
-#define BF(x, y, a, b) do { \
- x = a - b; \
- y = a + b; \
- } while (0)
-
-#define CMUL(dre, dim, are, aim, bre, bim) do { \
- (dre) = (are) * (bre) - (aim) * (bim); \
- (dim) = (are) * (bim) + (aim) * (bre); \
- } while (0)
-
-#else
-
-#include "libavutil/intmath.h"
-#include "mathops.h"
-
-void ff_mdct_calcw_c(FFTContext *s, FFTDouble *output, const FFTSample *input);
-
-#define SCALE_FLOAT(a, bits) lrint((a) * (double)(1 << (bits)))
-#define FIX15(a) av_clip(SCALE_FLOAT(a, 15), -32767, 32767)
-
-#define sqrthalf ((int16_t)((1<<15)*M_SQRT1_2))
-
-#define BF(x, y, a, b) do { \
- x = (a - b) >> 1; \
- y = (a + b) >> 1; \
- } while (0)
-
-#define CMULS(dre, dim, are, aim, bre, bim, sh) do { \
- (dre) = (MUL16(are, bre) - MUL16(aim, bim)) >> sh; \
- (dim) = (MUL16(are, bim) + MUL16(aim, bre)) >> sh; \
- } while (0)
-
-#define CMUL(dre, dim, are, aim, bre, bim) \
- CMULS(dre, dim, are, aim, bre, bim, 15)
-
-#define CMULL(dre, dim, are, aim, bre, bim) \
- CMULS(dre, dim, are, aim, bre, bim, 0)
-
-#endif /* CONFIG_FFT_FLOAT */
-
-#define ff_imdct_calc_c FFT_NAME(ff_imdct_calc_c)
-#define ff_imdct_half_c FFT_NAME(ff_imdct_half_c)
-#define ff_mdct_calc_c FFT_NAME(ff_mdct_calc_c)
-
-void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input);
-void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input);
-void ff_mdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input);
-
-#endif /* AVCODEC_FFT_INTERNAL_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/fft.c b/src/thirdparty/ffmpeg/libavcodec/fft.c
deleted file mode 100644
index f5a2af4a0..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/fft.c
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- * FFT/IFFT transforms
- * Copyright (c) 2008 Loren Merritt
- * Copyright (c) 2002 Fabrice Bellard
- * Partly 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
- */
-
-/**
- * @file
- * FFT/IFFT transforms.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include "libavutil/mathematics.h"
-#include "fft.h"
-#include "fft-internal.h"
-
-/* cos(2*pi*x/n) for 0<=x<=n/4, followed by its reverse */
-#if !CONFIG_HARDCODED_TABLES
-COSTABLE(16);
-COSTABLE(32);
-COSTABLE(64);
-COSTABLE(128);
-COSTABLE(256);
-COSTABLE(512);
-COSTABLE(1024);
-COSTABLE(2048);
-COSTABLE(4096);
-COSTABLE(8192);
-COSTABLE(16384);
-COSTABLE(32768);
-COSTABLE(65536);
-#endif
-COSTABLE_CONST FFTSample * const FFT_NAME(ff_cos_tabs)[] = {
- NULL, NULL, NULL, NULL,
- FFT_NAME(ff_cos_16),
- FFT_NAME(ff_cos_32),
- FFT_NAME(ff_cos_64),
- FFT_NAME(ff_cos_128),
- FFT_NAME(ff_cos_256),
- FFT_NAME(ff_cos_512),
- FFT_NAME(ff_cos_1024),
- FFT_NAME(ff_cos_2048),
- FFT_NAME(ff_cos_4096),
- FFT_NAME(ff_cos_8192),
- FFT_NAME(ff_cos_16384),
- FFT_NAME(ff_cos_32768),
- FFT_NAME(ff_cos_65536),
-};
-
-static void ff_fft_permute_c(FFTContext *s, FFTComplex *z);
-static void ff_fft_calc_c(FFTContext *s, FFTComplex *z);
-
-static int split_radix_permutation(int i, int n, int inverse)
-{
- int m;
- if(n <= 2) return i&1;
- m = n >> 1;
- if(!(i&m)) return split_radix_permutation(i, m, inverse)*2;
- m >>= 1;
- if(inverse == !(i&m)) return split_radix_permutation(i, m, inverse)*4 + 1;
- else return split_radix_permutation(i, m, inverse)*4 - 1;
-}
-
-av_cold void ff_init_ff_cos_tabs(int index)
-{
-#if !CONFIG_HARDCODED_TABLES
- int i;
- int m = 1<<index;
- double freq = 2*M_PI/m;
- FFTSample *tab = FFT_NAME(ff_cos_tabs)[index];
- for(i=0; i<=m/4; i++)
- tab[i] = FIX15(cos(i*freq));
- for(i=1; i<m/4; i++)
- tab[m/2-i] = tab[i];
-#endif
-}
-
-static const int avx_tab[] = {
- 0, 4, 1, 5, 8, 12, 9, 13, 2, 6, 3, 7, 10, 14, 11, 15
-};
-
-static int is_second_half_of_fft32(int i, int n)
-{
- if (n <= 32)
- return i >= 16;
- else if (i < n/2)
- return is_second_half_of_fft32(i, n/2);
- else if (i < 3*n/4)
- return is_second_half_of_fft32(i - n/2, n/4);
- else
- return is_second_half_of_fft32(i - 3*n/4, n/4);
-}
-
-static av_cold void fft_perm_avx(FFTContext *s)
-{
- int i;
- int n = 1 << s->nbits;
-
- for (i = 0; i < n; i += 16) {
- int k;
- if (is_second_half_of_fft32(i, n)) {
- for (k = 0; k < 16; k++)
- s->revtab[-split_radix_permutation(i + k, n, s->inverse) & (n - 1)] =
- i + avx_tab[k];
-
- } else {
- for (k = 0; k < 16; k++) {
- int j = i + k;
- j = (j & ~7) | ((j >> 1) & 3) | ((j << 2) & 4);
- s->revtab[-split_radix_permutation(i + k, n, s->inverse) & (n - 1)] = j;
- }
- }
- }
-}
-
-av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse)
-{
- int i, j, n;
-
- if (nbits < 2 || nbits > 16)
- goto fail;
- s->nbits = nbits;
- n = 1 << nbits;
-
- s->revtab = av_malloc(n * sizeof(uint16_t));
- if (!s->revtab)
- goto fail;
- s->tmp_buf = av_malloc(n * sizeof(FFTComplex));
- if (!s->tmp_buf)
- goto fail;
- s->inverse = inverse;
- s->fft_permutation = FF_FFT_PERM_DEFAULT;
-
- s->fft_permute = ff_fft_permute_c;
- s->fft_calc = ff_fft_calc_c;
-#if CONFIG_MDCT
- s->imdct_calc = ff_imdct_calc_c;
- s->imdct_half = ff_imdct_half_c;
- s->mdct_calc = ff_mdct_calc_c;
-#endif
-
-#if CONFIG_FFT_FLOAT
- if (ARCH_ARM) ff_fft_init_arm(s);
- if (HAVE_ALTIVEC) ff_fft_init_altivec(s);
- if (ARCH_X86) ff_fft_init_x86(s);
- if (CONFIG_MDCT) s->mdct_calcw = s->mdct_calc;
- if (HAVE_MIPSFPU) ff_fft_init_mips(s);
-#else
- if (CONFIG_MDCT) s->mdct_calcw = ff_mdct_calcw_c;
- if (ARCH_ARM) ff_fft_fixed_init_arm(s);
-#endif
-
- for(j=4; j<=nbits; j++) {
- ff_init_ff_cos_tabs(j);
- }
-
- if (s->fft_permutation == FF_FFT_PERM_AVX) {
- fft_perm_avx(s);
- } else {
- for(i=0; i<n; i++) {
- int j = i;
- if (s->fft_permutation == FF_FFT_PERM_SWAP_LSBS)
- j = (j&~3) | ((j>>1)&1) | ((j<<1)&2);
- s->revtab[-split_radix_permutation(i, n, s->inverse) & (n-1)] = j;
- }
- }
-
- return 0;
- fail:
- av_freep(&s->revtab);
- av_freep(&s->tmp_buf);
- return -1;
-}
-
-static void ff_fft_permute_c(FFTContext *s, FFTComplex *z)
-{
- int j, np;
- const uint16_t *revtab = s->revtab;
- np = 1 << s->nbits;
- /* TODO: handle split-radix permute in a more optimal way, probably in-place */
- for(j=0;j<np;j++) s->tmp_buf[revtab[j]] = z[j];
- memcpy(z, s->tmp_buf, np * sizeof(FFTComplex));
-}
-
-av_cold void ff_fft_end(FFTContext *s)
-{
- av_freep(&s->revtab);
- av_freep(&s->tmp_buf);
-}
-
-#define BUTTERFLIES(a0,a1,a2,a3) {\
- BF(t3, t5, t5, t1);\
- BF(a2.re, a0.re, a0.re, t5);\
- BF(a3.im, a1.im, a1.im, t3);\
- BF(t4, t6, t2, t6);\
- BF(a3.re, a1.re, a1.re, t4);\
- BF(a2.im, a0.im, a0.im, t6);\
-}
-
-// force loading all the inputs before storing any.
-// this is slightly slower for small data, but avoids store->load aliasing
-// for addresses separated by large powers of 2.
-#define BUTTERFLIES_BIG(a0,a1,a2,a3) {\
- FFTSample r0=a0.re, i0=a0.im, r1=a1.re, i1=a1.im;\
- BF(t3, t5, t5, t1);\
- BF(a2.re, a0.re, r0, t5);\
- BF(a3.im, a1.im, i1, t3);\
- BF(t4, t6, t2, t6);\
- BF(a3.re, a1.re, r1, t4);\
- BF(a2.im, a0.im, i0, t6);\
-}
-
-#define TRANSFORM(a0,a1,a2,a3,wre,wim) {\
- CMUL(t1, t2, a2.re, a2.im, wre, -wim);\
- CMUL(t5, t6, a3.re, a3.im, wre, wim);\
- BUTTERFLIES(a0,a1,a2,a3)\
-}
-
-#define TRANSFORM_ZERO(a0,a1,a2,a3) {\
- t1 = a2.re;\
- t2 = a2.im;\
- t5 = a3.re;\
- t6 = a3.im;\
- BUTTERFLIES(a0,a1,a2,a3)\
-}
-
-/* z[0...8n-1], w[1...2n-1] */
-#define PASS(name)\
-static void name(FFTComplex *z, const FFTSample *wre, unsigned int n)\
-{\
- FFTDouble t1, t2, t3, t4, t5, t6;\
- int o1 = 2*n;\
- int o2 = 4*n;\
- int o3 = 6*n;\
- const FFTSample *wim = wre+o1;\
- n--;\
-\
- TRANSFORM_ZERO(z[0],z[o1],z[o2],z[o3]);\
- TRANSFORM(z[1],z[o1+1],z[o2+1],z[o3+1],wre[1],wim[-1]);\
- do {\
- z += 2;\
- wre += 2;\
- wim -= 2;\
- TRANSFORM(z[0],z[o1],z[o2],z[o3],wre[0],wim[0]);\
- TRANSFORM(z[1],z[o1+1],z[o2+1],z[o3+1],wre[1],wim[-1]);\
- } while(--n);\
-}
-
-PASS(pass)
-#undef BUTTERFLIES
-#define BUTTERFLIES BUTTERFLIES_BIG
-PASS(pass_big)
-
-#define DECL_FFT(n,n2,n4)\
-static void fft##n(FFTComplex *z)\
-{\
- fft##n2(z);\
- fft##n4(z+n4*2);\
- fft##n4(z+n4*3);\
- pass(z,FFT_NAME(ff_cos_##n),n4/2);\
-}
-
-static void fft4(FFTComplex *z)
-{
- FFTDouble t1, t2, t3, t4, t5, t6, t7, t8;
-
- BF(t3, t1, z[0].re, z[1].re);
- BF(t8, t6, z[3].re, z[2].re);
- BF(z[2].re, z[0].re, t1, t6);
- BF(t4, t2, z[0].im, z[1].im);
- BF(t7, t5, z[2].im, z[3].im);
- BF(z[3].im, z[1].im, t4, t8);
- BF(z[3].re, z[1].re, t3, t7);
- BF(z[2].im, z[0].im, t2, t5);
-}
-
-static void fft8(FFTComplex *z)
-{
- FFTDouble t1, t2, t3, t4, t5, t6;
-
- fft4(z);
-
- BF(t1, z[5].re, z[4].re, -z[5].re);
- BF(t2, z[5].im, z[4].im, -z[5].im);
- BF(t5, z[7].re, z[6].re, -z[7].re);
- BF(t6, z[7].im, z[6].im, -z[7].im);
-
- BUTTERFLIES(z[0],z[2],z[4],z[6]);
- TRANSFORM(z[1],z[3],z[5],z[7],sqrthalf,sqrthalf);
-}
-
-#if !CONFIG_SMALL
-static void fft16(FFTComplex *z)
-{
- FFTDouble t1, t2, t3, t4, t5, t6;
- FFTSample cos_16_1 = FFT_NAME(ff_cos_16)[1];
- FFTSample cos_16_3 = FFT_NAME(ff_cos_16)[3];
-
- fft8(z);
- fft4(z+8);
- fft4(z+12);
-
- TRANSFORM_ZERO(z[0],z[4],z[8],z[12]);
- TRANSFORM(z[2],z[6],z[10],z[14],sqrthalf,sqrthalf);
- TRANSFORM(z[1],z[5],z[9],z[13],cos_16_1,cos_16_3);
- TRANSFORM(z[3],z[7],z[11],z[15],cos_16_3,cos_16_1);
-}
-#else
-DECL_FFT(16,8,4)
-#endif
-DECL_FFT(32,16,8)
-DECL_FFT(64,32,16)
-DECL_FFT(128,64,32)
-DECL_FFT(256,128,64)
-DECL_FFT(512,256,128)
-#if !CONFIG_SMALL
-#define pass pass_big
-#endif
-DECL_FFT(1024,512,256)
-DECL_FFT(2048,1024,512)
-DECL_FFT(4096,2048,1024)
-DECL_FFT(8192,4096,2048)
-DECL_FFT(16384,8192,4096)
-DECL_FFT(32768,16384,8192)
-DECL_FFT(65536,32768,16384)
-
-static void (* const fft_dispatch[])(FFTComplex*) = {
- fft4, fft8, fft16, fft32, fft64, fft128, fft256, fft512, fft1024,
- fft2048, fft4096, fft8192, fft16384, fft32768, fft65536,
-};
-
-static void ff_fft_calc_c(FFTContext *s, FFTComplex *z)
-{
- fft_dispatch[s->nbits-2](z);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/fft.h b/src/thirdparty/ffmpeg/libavcodec/fft.h
deleted file mode 100644
index 0d6c9d4db..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/fft.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
- * Copyright (c) 2002-2004 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
- */
-
-#ifndef AVCODEC_FFT_H
-#define AVCODEC_FFT_H
-
-#ifndef CONFIG_FFT_FLOAT
-#define CONFIG_FFT_FLOAT 1
-#endif
-
-#include <stdint.h>
-#include "config.h"
-#include "libavutil/mem.h"
-
-#if CONFIG_FFT_FLOAT
-
-#include "avfft.h"
-
-#define FFT_NAME(x) x
-
-typedef float FFTDouble;
-
-#else
-
-#define FFT_NAME(x) x ## _fixed
-
-typedef int16_t FFTSample;
-typedef int FFTDouble;
-
-typedef struct FFTComplex {
- int16_t re, im;
-} FFTComplex;
-
-typedef struct FFTContext FFTContext;
-
-#endif /* CONFIG_FFT_FLOAT */
-
-typedef struct FFTDComplex {
- FFTDouble re, im;
-} FFTDComplex;
-
-/* FFT computation */
-
-struct FFTContext {
- int nbits;
- int inverse;
- uint16_t *revtab;
- FFTComplex *tmp_buf;
- int mdct_size; /* size of MDCT (i.e. number of input data * 2) */
- int mdct_bits; /* n = 2^nbits */
- /* pre/post rotation tables */
- FFTSample *tcos;
- FFTSample *tsin;
- /**
- * Do the permutation needed BEFORE calling fft_calc().
- */
- void (*fft_permute)(struct FFTContext *s, FFTComplex *z);
- /**
- * Do a complex FFT with the parameters defined in ff_fft_init(). The
- * input data must be permuted before. No 1.0/sqrt(n) normalization is done.
- */
- void (*fft_calc)(struct FFTContext *s, FFTComplex *z);
- void (*imdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
- void (*imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
- void (*mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input);
- void (*mdct_calcw)(struct FFTContext *s, FFTDouble *output, const FFTSample *input);
- int fft_permutation;
-#define FF_FFT_PERM_DEFAULT 0
-#define FF_FFT_PERM_SWAP_LSBS 1
-#define FF_FFT_PERM_AVX 2
- int mdct_permutation;
-#define FF_MDCT_PERM_NONE 0
-#define FF_MDCT_PERM_INTERLEAVE 1
-};
-
-#if CONFIG_HARDCODED_TABLES
-#define COSTABLE_CONST const
-#else
-#define COSTABLE_CONST
-#endif
-
-#define COSTABLE(size) \
- COSTABLE_CONST DECLARE_ALIGNED(32, FFTSample, FFT_NAME(ff_cos_##size))[size/2]
-
-extern COSTABLE(16);
-extern COSTABLE(32);
-extern COSTABLE(64);
-extern COSTABLE(128);
-extern COSTABLE(256);
-extern COSTABLE(512);
-extern COSTABLE(1024);
-extern COSTABLE(2048);
-extern COSTABLE(4096);
-extern COSTABLE(8192);
-extern COSTABLE(16384);
-extern COSTABLE(32768);
-extern COSTABLE(65536);
-extern COSTABLE_CONST FFTSample* const FFT_NAME(ff_cos_tabs)[17];
-
-#define ff_init_ff_cos_tabs FFT_NAME(ff_init_ff_cos_tabs)
-
-/**
- * Initialize the cosine table in ff_cos_tabs[index]
- * @param index index in ff_cos_tabs array of the table to initialize
- */
-void ff_init_ff_cos_tabs(int index);
-
-#define ff_fft_init FFT_NAME(ff_fft_init)
-#define ff_fft_end FFT_NAME(ff_fft_end)
-
-/**
- * Set up a complex FFT.
- * @param nbits log2 of the length of the input array
- * @param inverse if 0 perform the forward transform, if 1 perform the inverse
- */
-int ff_fft_init(FFTContext *s, int nbits, int inverse);
-
-#if CONFIG_FFT_FLOAT
-void ff_fft_init_altivec(FFTContext *s);
-void ff_fft_init_x86(FFTContext *s);
-void ff_fft_init_arm(FFTContext *s);
-void ff_fft_init_mips(FFTContext *s);
-#else
-void ff_fft_fixed_init_arm(FFTContext *s);
-#endif
-
-void ff_fft_end(FFTContext *s);
-
-#define ff_mdct_init FFT_NAME(ff_mdct_init)
-#define ff_mdct_end FFT_NAME(ff_mdct_end)
-
-int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale);
-void ff_mdct_end(FFTContext *s);
-
-#endif /* AVCODEC_FFT_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/flac.c b/src/thirdparty/ffmpeg/libavcodec/flac.c
deleted file mode 100644
index ec5c2a8d9..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/flac.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * FLAC common code
- * Copyright (c) 2009 Justin Ruggles
- *
- * 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/crc.h"
-#include "libavutil/log.h"
-#include "bytestream.h"
-#include "get_bits.h"
-#include "flac.h"
-#include "flacdata.h"
-
-static const int8_t sample_size_table[] = { 0, 8, 12, 0, 16, 20, 24, 0 };
-
-static const uint64_t flac_channel_layouts[8] = {
- AV_CH_LAYOUT_MONO,
- AV_CH_LAYOUT_STEREO,
- AV_CH_LAYOUT_SURROUND,
- AV_CH_LAYOUT_QUAD,
- AV_CH_LAYOUT_5POINT0,
- AV_CH_LAYOUT_5POINT1,
- AV_CH_LAYOUT_6POINT1,
- AV_CH_LAYOUT_7POINT1
-};
-
-static int64_t get_utf8(GetBitContext *gb)
-{
- int64_t val;
- GET_UTF8(val, get_bits(gb, 8), return -1;)
- return val;
-}
-
-int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
- FLACFrameInfo *fi, int log_level_offset)
-{
- int bs_code, sr_code, bps_code;
-
- /* frame sync code */
- if ((get_bits(gb, 15) & 0x7FFF) != 0x7FFC) {
- av_log(avctx, AV_LOG_ERROR + log_level_offset, "invalid sync code\n");
- return -1;
- }
-
- /* variable block size stream code */
- fi->is_var_size = get_bits1(gb);
-
- /* block size and sample rate codes */
- bs_code = get_bits(gb, 4);
- sr_code = get_bits(gb, 4);
-
- /* channels and decorrelation */
- fi->ch_mode = get_bits(gb, 4);
- if (fi->ch_mode < FLAC_MAX_CHANNELS) {
- fi->channels = fi->ch_mode + 1;
- fi->ch_mode = FLAC_CHMODE_INDEPENDENT;
- } else if (fi->ch_mode < FLAC_MAX_CHANNELS + FLAC_CHMODE_MID_SIDE) {
- fi->channels = 2;
- fi->ch_mode -= FLAC_MAX_CHANNELS - 1;
- } else {
- av_log(avctx, AV_LOG_ERROR + log_level_offset,
- "invalid channel mode: %d\n", fi->ch_mode);
- return -1;
- }
-
- /* bits per sample */
- bps_code = get_bits(gb, 3);
- if (bps_code == 3 || bps_code == 7) {
- av_log(avctx, AV_LOG_ERROR + log_level_offset,
- "invalid sample size code (%d)\n",
- bps_code);
- return -1;
- }
- fi->bps = sample_size_table[bps_code];
-
- /* reserved bit */
- if (get_bits1(gb)) {
- av_log(avctx, AV_LOG_ERROR + log_level_offset,
- "broken stream, invalid padding\n");
- return -1;
- }
-
- /* sample or frame count */
- fi->frame_or_sample_num = get_utf8(gb);
- if (fi->frame_or_sample_num < 0) {
- av_log(avctx, AV_LOG_ERROR + log_level_offset,
- "sample/frame number invalid; utf8 fscked\n");
- return -1;
- }
-
- /* blocksize */
- if (bs_code == 0) {
- av_log(avctx, AV_LOG_ERROR + log_level_offset,
- "reserved blocksize code: 0\n");
- return -1;
- } else if (bs_code == 6) {
- fi->blocksize = get_bits(gb, 8) + 1;
- } else if (bs_code == 7) {
- fi->blocksize = get_bits(gb, 16) + 1;
- } else {
- fi->blocksize = ff_flac_blocksize_table[bs_code];
- }
-
- /* sample rate */
- if (sr_code < 12) {
- fi->samplerate = ff_flac_sample_rate_table[sr_code];
- } else if (sr_code == 12) {
- fi->samplerate = get_bits(gb, 8) * 1000;
- } else if (sr_code == 13) {
- fi->samplerate = get_bits(gb, 16);
- } else if (sr_code == 14) {
- fi->samplerate = get_bits(gb, 16) * 10;
- } else {
- av_log(avctx, AV_LOG_ERROR + log_level_offset,
- "illegal sample rate code %d\n",
- sr_code);
- return -1;
- }
-
- /* header CRC-8 check */
- skip_bits(gb, 8);
- if (av_crc(av_crc_get_table(AV_CRC_8_ATM), 0, gb->buffer,
- get_bits_count(gb)/8)) {
- av_log(avctx, AV_LOG_ERROR + log_level_offset,
- "header crc mismatch\n");
- return -1;
- }
-
- return 0;
-}
-
-int ff_flac_get_max_frame_size(int blocksize, int ch, int bps)
-{
- /* Technically, there is no limit to FLAC frame size, but an encoder
- should not write a frame that is larger than if verbatim encoding mode
- were to be used. */
-
- int count;
-
- count = 16; /* frame header */
- count += ch * ((7+bps+7)/8); /* subframe headers */
- if (ch == 2) {
- /* for stereo, need to account for using decorrelation */
- count += (( 2*bps+1) * blocksize + 7) / 8;
- } else {
- count += ( ch*bps * blocksize + 7) / 8;
- }
- count += 2; /* frame footer */
-
- return count;
-}
-
-int avpriv_flac_is_extradata_valid(AVCodecContext *avctx,
- enum FLACExtradataFormat *format,
- uint8_t **streaminfo_start)
-{
- if (!avctx->extradata || avctx->extradata_size < FLAC_STREAMINFO_SIZE) {
- av_log(avctx, AV_LOG_ERROR, "extradata NULL or too small.\n");
- return 0;
- }
- if (AV_RL32(avctx->extradata) != MKTAG('f','L','a','C')) {
- /* extradata contains STREAMINFO only */
- if (avctx->extradata_size != FLAC_STREAMINFO_SIZE) {
- av_log(avctx, AV_LOG_WARNING, "extradata contains %d bytes too many.\n",
- FLAC_STREAMINFO_SIZE-avctx->extradata_size);
- }
- *format = FLAC_EXTRADATA_FORMAT_STREAMINFO;
- *streaminfo_start = avctx->extradata;
- } else {
- if (avctx->extradata_size < 8+FLAC_STREAMINFO_SIZE) {
- av_log(avctx, AV_LOG_ERROR, "extradata too small.\n");
- return 0;
- }
- *format = FLAC_EXTRADATA_FORMAT_FULL_HEADER;
- *streaminfo_start = &avctx->extradata[8];
- }
- return 1;
-}
-
-void ff_flac_set_channel_layout(AVCodecContext *avctx)
-{
- if (avctx->channels <= FF_ARRAY_ELEMS(flac_channel_layouts))
- avctx->channel_layout = flac_channel_layouts[avctx->channels - 1];
- else
- avctx->channel_layout = 0;
-}
-
-void avpriv_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
- const uint8_t *buffer)
-{
- GetBitContext gb;
- init_get_bits(&gb, buffer, FLAC_STREAMINFO_SIZE*8);
-
- skip_bits(&gb, 16); /* skip min blocksize */
- s->max_blocksize = get_bits(&gb, 16);
- if (s->max_blocksize < FLAC_MIN_BLOCKSIZE) {
- av_log(avctx, AV_LOG_WARNING, "invalid max blocksize: %d\n",
- s->max_blocksize);
- s->max_blocksize = 16;
- }
-
- skip_bits(&gb, 24); /* skip min frame size */
- s->max_framesize = get_bits_long(&gb, 24);
-
- s->samplerate = get_bits_long(&gb, 20);
- s->channels = get_bits(&gb, 3) + 1;
- s->bps = get_bits(&gb, 5) + 1;
-
- avctx->channels = s->channels;
- avctx->sample_rate = s->samplerate;
- avctx->bits_per_raw_sample = s->bps;
- ff_flac_set_channel_layout(avctx);
-
- s->samples = get_bits64(&gb, 36);
-
- skip_bits_long(&gb, 64); /* md5 sum */
- skip_bits_long(&gb, 64); /* md5 sum */
-}
-
-void avpriv_flac_parse_block_header(const uint8_t *block_header,
- int *last, int *type, int *size)
-{
- int tmp = bytestream_get_byte(&block_header);
- if (last)
- *last = tmp & 0x80;
- if (type)
- *type = tmp & 0x7F;
- if (size)
- *size = bytestream_get_be24(&block_header);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/flac.h b/src/thirdparty/ffmpeg/libavcodec/flac.h
deleted file mode 100644
index cbd8bcf6c..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/flac.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * FLAC (Free Lossless Audio Codec) decoder/demuxer common functions
- * Copyright (c) 2008 Justin Ruggles
- *
- * 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
- * FLAC (Free Lossless Audio Codec) decoder/demuxer common functions
- */
-
-#ifndef AVCODEC_FLAC_H
-#define AVCODEC_FLAC_H
-
-#include "avcodec.h"
-#include "get_bits.h"
-
-#define FLAC_STREAMINFO_SIZE 34
-#define FLAC_MAX_CHANNELS 8
-#define FLAC_MIN_BLOCKSIZE 16
-#define FLAC_MAX_BLOCKSIZE 65535
-#define FLAC_MIN_FRAME_SIZE 11
-
-enum {
- FLAC_CHMODE_INDEPENDENT = 0,
- FLAC_CHMODE_LEFT_SIDE = 1,
- FLAC_CHMODE_RIGHT_SIDE = 2,
- FLAC_CHMODE_MID_SIDE = 3,
-};
-
-enum {
- FLAC_METADATA_TYPE_STREAMINFO = 0,
- FLAC_METADATA_TYPE_PADDING,
- FLAC_METADATA_TYPE_APPLICATION,
- FLAC_METADATA_TYPE_SEEKTABLE,
- FLAC_METADATA_TYPE_VORBIS_COMMENT,
- FLAC_METADATA_TYPE_CUESHEET,
- FLAC_METADATA_TYPE_PICTURE,
- FLAC_METADATA_TYPE_INVALID = 127
-};
-
-enum FLACExtradataFormat {
- FLAC_EXTRADATA_FORMAT_STREAMINFO = 0,
- FLAC_EXTRADATA_FORMAT_FULL_HEADER = 1
-};
-
-#define FLACCOMMONINFO \
- int samplerate; /**< sample rate */\
- int channels; /**< number of channels */\
- int bps; /**< bits-per-sample */\
-
-/**
- * Data needed from the Streaminfo header for use by the raw FLAC demuxer
- * and/or the FLAC decoder.
- */
-#define FLACSTREAMINFO \
- FLACCOMMONINFO \
- int max_blocksize; /**< maximum block size, in samples */\
- int max_framesize; /**< maximum frame size, in bytes */\
- int64_t samples; /**< total number of samples */\
-
-typedef struct FLACStreaminfo {
- FLACSTREAMINFO
-} FLACStreaminfo;
-
-typedef struct FLACFrameInfo {
- FLACCOMMONINFO
- int blocksize; /**< block size of the frame */
- int ch_mode; /**< channel decorrelation mode */
- int64_t frame_or_sample_num; /**< frame number or sample number */
- int is_var_size; /**< specifies if the stream uses variable
- block sizes or a fixed block size;
- also determines the meaning of
- frame_or_sample_num */
-} FLACFrameInfo;
-
-/**
- * Parse the Streaminfo metadata block
- * @param[out] avctx codec context to set basic stream parameters
- * @param[out] s where parsed information is stored
- * @param[in] buffer pointer to start of 34-byte streaminfo data
- */
-void avpriv_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
- const uint8_t *buffer);
-
-/**
- * Validate the FLAC extradata.
- * @param[in] avctx codec context containing the extradata.
- * @param[out] format extradata format.
- * @param[out] streaminfo_start pointer to start of 34-byte STREAMINFO data.
- * @return 1 if valid, 0 if not valid.
- */
-int avpriv_flac_is_extradata_valid(AVCodecContext *avctx,
- enum FLACExtradataFormat *format,
- uint8_t **streaminfo_start);
-
-/**
- * Parse the metadata block parameters from the header.
- * @param[in] block_header header data, at least 4 bytes
- * @param[out] last indicator for last metadata block
- * @param[out] type metadata block type
- * @param[out] size metadata block size
- */
-void avpriv_flac_parse_block_header(const uint8_t *block_header,
- int *last, int *type, int *size);
-
-/**
- * Calculate an estimate for the maximum frame size based on verbatim mode.
- * @param blocksize block size, in samples
- * @param ch number of channels
- * @param bps bits-per-sample
- */
-int ff_flac_get_max_frame_size(int blocksize, int ch, int bps);
-
-/**
- * Validate and decode a frame header.
- * @param avctx AVCodecContext to use as av_log() context
- * @param gb GetBitContext from which to read frame header
- * @param[out] fi frame information
- * @param log_level_offset log level offset. can be used to silence error messages.
- * @return non-zero on error, 0 if ok
- */
-int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
- FLACFrameInfo *fi, int log_level_offset);
-
-void ff_flac_set_channel_layout(AVCodecContext *avctx);
-
-#endif /* AVCODEC_FLAC_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/flacdata.c b/src/thirdparty/ffmpeg/libavcodec/flacdata.c
deleted file mode 100644
index a161deb8f..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/flacdata.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * FLAC data
- * Copyright (c) 2003 Alex Beregszaszi
- *
- * 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 "internal.h"
-
-const int ff_flac_sample_rate_table[16] =
-{ 0,
- 88200, 176400, 192000,
- 8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000,
- 0, 0, 0, 0 };
-
-const int16_t ff_flac_blocksize_table[16] = {
- 0, 192, 576<<0, 576<<1, 576<<2, 576<<3, 0, 0,
-256<<0, 256<<1, 256<<2, 256<<3, 256<<4, 256<<5, 256<<6, 256<<7
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/flacdata.h b/src/thirdparty/ffmpeg/libavcodec/flacdata.h
deleted file mode 100644
index f89e974f8..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/flacdata.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * FLAC data header
- * Copyright (c) 2003 Alex Beregszaszi
- *
- * 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_FLACDATA_H
-#define AVCODEC_FLACDATA_H
-
-#include "internal.h"
-
-extern const int ff_flac_sample_rate_table[16];
-
-extern const int16_t ff_flac_blocksize_table[16];
-
-#endif /* AVCODEC_FLACDATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/flacdec.c b/src/thirdparty/ffmpeg/libavcodec/flacdec.c
deleted file mode 100644
index 4f7145026..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/flacdec.c
+++ /dev/null
@@ -1,586 +0,0 @@
-/*
- * FLAC (Free Lossless Audio Codec) decoder
- * Copyright (c) 2003 Alex Beregszaszi
- *
- * 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
- * FLAC (Free Lossless Audio Codec) decoder
- * @author Alex Beregszaszi
- * @see http://flac.sourceforge.net/
- *
- * This decoder can be used in 1 of 2 ways: Either raw FLAC data can be fed
- * through, starting from the initial 'fLaC' signature; or by passing the
- * 34-byte streaminfo structure through avctx->extradata[_size] followed
- * by data starting with the 0xFFF8 marker.
- */
-
-#include <limits.h>
-
-#include "libavutil/avassert.h"
-#include "libavutil/channel_layout.h"
-#include "libavutil/crc.h"
-#include "avcodec.h"
-#include "internal.h"
-#include "get_bits.h"
-#include "bytestream.h"
-#include "golomb.h"
-#include "flac.h"
-#include "flacdata.h"
-#include "flacdsp.h"
-
-typedef struct FLACContext {
- FLACSTREAMINFO
-
- AVCodecContext *avctx; ///< parent AVCodecContext
- GetBitContext gb; ///< GetBitContext initialized to start at the current frame
-
- int blocksize; ///< number of samples in the current frame
- int sample_shift; ///< shift required to make output samples 16-bit or 32-bit
- int ch_mode; ///< channel decorrelation type in the current frame
- int got_streaminfo; ///< indicates if the STREAMINFO has been read
-
- int32_t *decoded[FLAC_MAX_CHANNELS]; ///< decoded samples
- uint8_t *decoded_buffer;
- unsigned int decoded_buffer_size;
-
- FLACDSPContext dsp;
-} FLACContext;
-
-static int allocate_buffers(FLACContext *s);
-
-static void flac_set_bps(FLACContext *s)
-{
- enum AVSampleFormat req = s->avctx->request_sample_fmt;
- int need32 = s->bps > 16;
- int want32 = av_get_bytes_per_sample(req) > 2;
- int planar = av_sample_fmt_is_planar(req);
-
- if (need32 || want32) {
- if (planar)
- s->avctx->sample_fmt = AV_SAMPLE_FMT_S32P;
- else
- s->avctx->sample_fmt = AV_SAMPLE_FMT_S32;
- s->sample_shift = 32 - s->bps;
- } else {
- if (planar)
- s->avctx->sample_fmt = AV_SAMPLE_FMT_S16P;
- else
- s->avctx->sample_fmt = AV_SAMPLE_FMT_S16;
- s->sample_shift = 16 - s->bps;
- }
-}
-
-static av_cold int flac_decode_init(AVCodecContext *avctx)
-{
- enum FLACExtradataFormat format;
- uint8_t *streaminfo;
- int ret;
- FLACContext *s = avctx->priv_data;
- s->avctx = avctx;
-
- /* for now, the raw FLAC header is allowed to be passed to the decoder as
- frame data instead of extradata. */
- if (!avctx->extradata)
- return 0;
-
- if (!avpriv_flac_is_extradata_valid(avctx, &format, &streaminfo))
- return -1;
-
- /* initialize based on the demuxer-supplied streamdata header */
- avpriv_flac_parse_streaminfo(avctx, (FLACStreaminfo *)s, streaminfo);
- ret = allocate_buffers(s);
- if (ret < 0)
- return ret;
- flac_set_bps(s);
- ff_flacdsp_init(&s->dsp, avctx->sample_fmt, s->bps);
- s->got_streaminfo = 1;
-
- return 0;
-}
-
-static void dump_headers(AVCodecContext *avctx, FLACStreaminfo *s)
-{
- av_log(avctx, AV_LOG_DEBUG, " Max Blocksize: %d\n", s->max_blocksize);
- av_log(avctx, AV_LOG_DEBUG, " Max Framesize: %d\n", s->max_framesize);
- av_log(avctx, AV_LOG_DEBUG, " Samplerate: %d\n", s->samplerate);
- av_log(avctx, AV_LOG_DEBUG, " Channels: %d\n", s->channels);
- av_log(avctx, AV_LOG_DEBUG, " Bits: %d\n", s->bps);
-}
-
-static int allocate_buffers(FLACContext *s)
-{
- int buf_size;
-
- av_assert0(s->max_blocksize);
-
- buf_size = av_samples_get_buffer_size(NULL, s->channels, s->max_blocksize,
- AV_SAMPLE_FMT_S32P, 0);
- if (buf_size < 0)
- return buf_size;
-
- av_fast_malloc(&s->decoded_buffer, &s->decoded_buffer_size, buf_size);
- if (!s->decoded_buffer)
- return AVERROR(ENOMEM);
-
- return av_samples_fill_arrays((uint8_t **)s->decoded, NULL,
- s->decoded_buffer, s->channels,
- s->max_blocksize, AV_SAMPLE_FMT_S32P, 0);
-}
-
-/**
- * Parse the STREAMINFO from an inline header.
- * @param s the flac decoding context
- * @param buf input buffer, starting with the "fLaC" marker
- * @param buf_size buffer size
- * @return non-zero if metadata is invalid
- */
-static int parse_streaminfo(FLACContext *s, const uint8_t *buf, int buf_size)
-{
- int metadata_type, metadata_size, ret;
-
- if (buf_size < FLAC_STREAMINFO_SIZE+8) {
- /* need more data */
- return 0;
- }
- avpriv_flac_parse_block_header(&buf[4], NULL, &metadata_type, &metadata_size);
- if (metadata_type != FLAC_METADATA_TYPE_STREAMINFO ||
- metadata_size != FLAC_STREAMINFO_SIZE) {
- return AVERROR_INVALIDDATA;
- }
- avpriv_flac_parse_streaminfo(s->avctx, (FLACStreaminfo *)s, &buf[8]);
- ret = allocate_buffers(s);
- if (ret < 0)
- return ret;
- flac_set_bps(s);
- ff_flacdsp_init(&s->dsp, s->avctx->sample_fmt, s->bps);
- s->got_streaminfo = 1;
-
- return 0;
-}
-
-/**
- * Determine the size of an inline header.
- * @param buf input buffer, starting with the "fLaC" marker
- * @param buf_size buffer size
- * @return number of bytes in the header, or 0 if more data is needed
- */
-static int get_metadata_size(const uint8_t *buf, int buf_size)
-{
- int metadata_last, metadata_size;
- const uint8_t *buf_end = buf + buf_size;
-
- buf += 4;
- do {
- if (buf_end - buf < 4)
- return 0;
- avpriv_flac_parse_block_header(buf, &metadata_last, NULL, &metadata_size);
- buf += 4;
- if (buf_end - buf < metadata_size) {
- /* need more data in order to read the complete header */
- return 0;
- }
- buf += metadata_size;
- } while (!metadata_last);
-
- return buf_size - (buf_end - buf);
-}
-
-static int decode_residuals(FLACContext *s, int32_t *decoded, int pred_order)
-{
- int i, tmp, partition, method_type, rice_order;
- int rice_bits, rice_esc;
- int samples;
-
- method_type = get_bits(&s->gb, 2);
- if (method_type > 1) {
- av_log(s->avctx, AV_LOG_ERROR, "illegal residual coding method %d\n",
- method_type);
- return -1;
- }
-
- rice_order = get_bits(&s->gb, 4);
-
- samples= s->blocksize >> rice_order;
- if (pred_order > samples) {
- av_log(s->avctx, AV_LOG_ERROR, "invalid predictor order: %i > %i\n",
- pred_order, samples);
- return -1;
- }
-
- rice_bits = 4 + method_type;
- rice_esc = (1 << rice_bits) - 1;
-
- decoded += pred_order;
- i= pred_order;
- for (partition = 0; partition < (1 << rice_order); partition++) {
- tmp = get_bits(&s->gb, rice_bits);
- if (tmp == rice_esc) {
- tmp = get_bits(&s->gb, 5);
- for (; i < samples; i++)
- *decoded++ = get_sbits_long(&s->gb, tmp);
- } else {
- for (; i < samples; i++) {
- *decoded++ = get_sr_golomb_flac(&s->gb, tmp, INT_MAX, 0);
- }
- }
- i= 0;
- }
-
- return 0;
-}
-
-static int decode_subframe_fixed(FLACContext *s, int32_t *decoded,
- int pred_order, int bps)
-{
- const int blocksize = s->blocksize;
- int av_uninit(a), av_uninit(b), av_uninit(c), av_uninit(d), i;
-
- /* warm up samples */
- for (i = 0; i < pred_order; i++) {
- decoded[i] = get_sbits_long(&s->gb, bps);
- }
-
- if (decode_residuals(s, decoded, pred_order) < 0)
- return -1;
-
- if (pred_order > 0)
- a = decoded[pred_order-1];
- if (pred_order > 1)
- b = a - decoded[pred_order-2];
- if (pred_order > 2)
- c = b - decoded[pred_order-2] + decoded[pred_order-3];
- if (pred_order > 3)
- d = c - decoded[pred_order-2] + 2*decoded[pred_order-3] - decoded[pred_order-4];
-
- switch (pred_order) {
- case 0:
- break;
- case 1:
- for (i = pred_order; i < blocksize; i++)
- decoded[i] = a += decoded[i];
- break;
- case 2:
- for (i = pred_order; i < blocksize; i++)
- decoded[i] = a += b += decoded[i];
- break;
- case 3:
- for (i = pred_order; i < blocksize; i++)
- decoded[i] = a += b += c += decoded[i];
- break;
- case 4:
- for (i = pred_order; i < blocksize; i++)
- decoded[i] = a += b += c += d += decoded[i];
- break;
- default:
- av_log(s->avctx, AV_LOG_ERROR, "illegal pred order %d\n", pred_order);
- return -1;
- }
-
- return 0;
-}
-
-static int decode_subframe_lpc(FLACContext *s, int32_t *decoded, int pred_order,
- int bps)
-{
- int i;
- int coeff_prec, qlevel;
- int coeffs[32];
-
- /* warm up samples */
- for (i = 0; i < pred_order; i++) {
- decoded[i] = get_sbits_long(&s->gb, bps);
- }
-
- coeff_prec = get_bits(&s->gb, 4) + 1;
- if (coeff_prec == 16) {
- av_log(s->avctx, AV_LOG_ERROR, "invalid coeff precision\n");
- return -1;
- }
- qlevel = get_sbits(&s->gb, 5);
- if (qlevel < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "qlevel %d not supported, maybe buggy stream\n",
- qlevel);
- return -1;
- }
-
- for (i = 0; i < pred_order; i++) {
- coeffs[pred_order - i - 1] = get_sbits(&s->gb, coeff_prec);
- }
-
- if (decode_residuals(s, decoded, pred_order) < 0)
- return -1;
-
- s->dsp.lpc(decoded, coeffs, pred_order, qlevel, s->blocksize);
-
- return 0;
-}
-
-static inline int decode_subframe(FLACContext *s, int channel)
-{
- int32_t *decoded = s->decoded[channel];
- int type, wasted = 0;
- int bps = s->bps;
- int i, tmp;
-
- if (channel == 0) {
- if (s->ch_mode == FLAC_CHMODE_RIGHT_SIDE)
- bps++;
- } else {
- if (s->ch_mode == FLAC_CHMODE_LEFT_SIDE || s->ch_mode == FLAC_CHMODE_MID_SIDE)
- bps++;
- }
-
- if (get_bits1(&s->gb)) {
- av_log(s->avctx, AV_LOG_ERROR, "invalid subframe padding\n");
- return -1;
- }
- type = get_bits(&s->gb, 6);
-
- if (get_bits1(&s->gb)) {
- int left = get_bits_left(&s->gb);
- wasted = 1;
- if ( left < 0 ||
- (left < bps && !show_bits_long(&s->gb, left)) ||
- !show_bits_long(&s->gb, bps)) {
- av_log(s->avctx, AV_LOG_ERROR,
- "Invalid number of wasted bits > available bits (%d) - left=%d\n",
- bps, left);
- return AVERROR_INVALIDDATA;
- }
- while (!get_bits1(&s->gb))
- wasted++;
- bps -= wasted;
- }
- if (bps > 32) {
- av_log_missing_feature(s->avctx, "Decorrelated bit depth > 32", 0);
- return AVERROR_PATCHWELCOME;
- }
-
-//FIXME use av_log2 for types
- if (type == 0) {
- tmp = get_sbits_long(&s->gb, bps);
- for (i = 0; i < s->blocksize; i++)
- decoded[i] = tmp;
- } else if (type == 1) {
- for (i = 0; i < s->blocksize; i++)
- decoded[i] = get_sbits_long(&s->gb, bps);
- } else if ((type >= 8) && (type <= 12)) {
- if (decode_subframe_fixed(s, decoded, type & ~0x8, bps) < 0)
- return -1;
- } else if (type >= 32) {
- if (decode_subframe_lpc(s, decoded, (type & ~0x20)+1, bps) < 0)
- return -1;
- } else {
- av_log(s->avctx, AV_LOG_ERROR, "invalid coding type\n");
- return -1;
- }
-
- if (wasted) {
- int i;
- for (i = 0; i < s->blocksize; i++)
- decoded[i] <<= wasted;
- }
-
- return 0;
-}
-
-static int decode_frame(FLACContext *s)
-{
- int i, ret;
- GetBitContext *gb = &s->gb;
- FLACFrameInfo fi;
-
- if (ff_flac_decode_frame_header(s->avctx, gb, &fi, 0)) {
- av_log(s->avctx, AV_LOG_ERROR, "invalid frame header\n");
- return -1;
- }
-
- if (s->channels && fi.channels != s->channels && s->got_streaminfo) {
- s->channels = s->avctx->channels = fi.channels;
- ff_flac_set_channel_layout(s->avctx);
- ret = allocate_buffers(s);
- if (ret < 0)
- return ret;
- }
- s->channels = s->avctx->channels = fi.channels;
- if (!s->avctx->channel_layout)
- ff_flac_set_channel_layout(s->avctx);
- s->ch_mode = fi.ch_mode;
-
- if (!s->bps && !fi.bps) {
- av_log(s->avctx, AV_LOG_ERROR, "bps not found in STREAMINFO or frame header\n");
- return -1;
- }
- if (!fi.bps) {
- fi.bps = s->bps;
- } else if (s->bps && fi.bps != s->bps) {
- av_log(s->avctx, AV_LOG_ERROR, "switching bps mid-stream is not "
- "supported\n");
- return -1;
- }
-
- if (!s->bps) {
- s->bps = s->avctx->bits_per_raw_sample = fi.bps;
- flac_set_bps(s);
- }
-
- if (!s->max_blocksize)
- s->max_blocksize = FLAC_MAX_BLOCKSIZE;
- if (fi.blocksize > s->max_blocksize) {
- av_log(s->avctx, AV_LOG_ERROR, "blocksize %d > %d\n", fi.blocksize,
- s->max_blocksize);
- return -1;
- }
- s->blocksize = fi.blocksize;
-
- if (!s->samplerate && !fi.samplerate) {
- av_log(s->avctx, AV_LOG_ERROR, "sample rate not found in STREAMINFO"
- " or frame header\n");
- return -1;
- }
- if (fi.samplerate == 0)
- fi.samplerate = s->samplerate;
- s->samplerate = s->avctx->sample_rate = fi.samplerate;
-
- if (!s->got_streaminfo) {
- ret = allocate_buffers(s);
- if (ret < 0)
- return ret;
- ff_flacdsp_init(&s->dsp, s->avctx->sample_fmt, s->bps);
- s->got_streaminfo = 1;
- dump_headers(s->avctx, (FLACStreaminfo *)s);
- }
-
-// dump_headers(s->avctx, (FLACStreaminfo *)s);
-
- /* subframes */
- for (i = 0; i < s->channels; i++) {
- if (decode_subframe(s, i) < 0)
- return -1;
- }
-
- align_get_bits(gb);
-
- /* frame footer */
- skip_bits(gb, 16); /* data crc */
-
- return 0;
-}
-
-static int flac_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;
- FLACContext *s = avctx->priv_data;
- int bytes_read = 0;
- int ret;
-
- *got_frame_ptr = 0;
-
- if (s->max_framesize == 0) {
- s->max_framesize =
- ff_flac_get_max_frame_size(s->max_blocksize ? s->max_blocksize : FLAC_MAX_BLOCKSIZE,
- FLAC_MAX_CHANNELS, 32);
- }
-
- if (buf_size > 5 && !memcmp(buf, "\177FLAC", 5)) {
- av_log(s->avctx, AV_LOG_DEBUG, "skiping 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");
- return buf_size;
- }
-
- /* check that there is at least the smallest decodable amount of data.
- this amount corresponds to the smallest valid FLAC frame possible.
- FF F8 69 02 00 00 9A 00 00 34 46 */
- if (buf_size < FLAC_MIN_FRAME_SIZE)
- return buf_size;
-
- /* check for inline header */
- if (AV_RB32(buf) == MKBETAG('f','L','a','C')) {
- if (!s->got_streaminfo && parse_streaminfo(s, buf, buf_size)) {
- av_log(s->avctx, AV_LOG_ERROR, "invalid header\n");
- return -1;
- }
- return get_metadata_size(buf, buf_size);
- }
-
- /* decode frame */
- init_get_bits(&s->gb, buf, buf_size*8);
- if (decode_frame(s) < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "decode_frame() failed\n");
- return -1;
- }
- bytes_read = (get_bits_count(&s->gb)+7)/8;
-
- /* get output buffer */
- frame->nb_samples = s->blocksize;
- if ((ret = ff_get_buffer(avctx, frame)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return ret;
- }
-
- s->dsp.decorrelate[s->ch_mode](frame->data, s->decoded, s->channels,
- s->blocksize, s->sample_shift);
-
- if (bytes_read > buf_size) {
- av_log(s->avctx, AV_LOG_ERROR, "overread: %d\n", bytes_read - buf_size);
- return -1;
- }
- if (bytes_read < buf_size) {
- av_log(s->avctx, AV_LOG_DEBUG, "underread: %d orig size: %d\n",
- buf_size - bytes_read, buf_size);
- }
-
- *got_frame_ptr = 1;
-
- return bytes_read;
-}
-
-static av_cold int flac_decode_close(AVCodecContext *avctx)
-{
- FLACContext *s = avctx->priv_data;
-
- av_freep(&s->decoded_buffer);
-
- return 0;
-}
-
-AVCodec ff_flac_decoder = {
- .name = "flac",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_FLAC,
- .priv_data_size = sizeof(FLACContext),
- .init = flac_decode_init,
- .close = flac_decode_close,
- .decode = flac_decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("FLAC (Free Lossless Audio Codec)"),
- .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16,
- AV_SAMPLE_FMT_S16P,
- AV_SAMPLE_FMT_S32,
- AV_SAMPLE_FMT_S32P,
- AV_SAMPLE_FMT_NONE },
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/flacdsp.c b/src/thirdparty/ffmpeg/libavcodec/flacdsp.c
deleted file mode 100644
index 469e100e1..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/flacdsp.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (c) 2012 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/attributes.h"
-#include "libavutil/samplefmt.h"
-#include "flacdsp.h"
-#include "config.h"
-
-#define SAMPLE_SIZE 16
-#define PLANAR 0
-#include "flacdsp_template.c"
-#include "flacdsp_lpc_template.c"
-
-#undef PLANAR
-#define PLANAR 1
-#include "flacdsp_template.c"
-
-#undef SAMPLE_SIZE
-#undef PLANAR
-#define SAMPLE_SIZE 32
-#define PLANAR 0
-#include "flacdsp_template.c"
-#include "flacdsp_lpc_template.c"
-
-#undef PLANAR
-#define PLANAR 1
-#include "flacdsp_template.c"
-
-static void flac_lpc_16_c(int32_t *decoded, const int coeffs[32],
- int pred_order, int qlevel, int len)
-{
- int i, j;
-
- for (i = pred_order; i < len - 1; i += 2, decoded += 2) {
- int c = coeffs[0];
- int d = decoded[0];
- int s0 = 0, s1 = 0;
- for (j = 1; j < pred_order; j++) {
- s0 += c*d;
- d = decoded[j];
- s1 += c*d;
- c = coeffs[j];
- }
- s0 += c*d;
- d = decoded[j] += s0 >> qlevel;
- s1 += c*d;
- decoded[j + 1] += s1 >> qlevel;
- }
- if (i < len) {
- int sum = 0;
- for (j = 0; j < pred_order; j++)
- sum += coeffs[j] * decoded[j];
- decoded[j] += sum >> qlevel;
- }
-}
-
-static void flac_lpc_32_c(int32_t *decoded, const int coeffs[32],
- int pred_order, int qlevel, int len)
-{
- int i, j;
-
- for (i = pred_order; i < len; i++, decoded++) {
- int64_t sum = 0;
- for (j = 0; j < pred_order; j++)
- sum += (int64_t)coeffs[j] * decoded[j];
- decoded[j] += sum >> qlevel;
- }
-
-}
-
-av_cold void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt,
- int bps)
-{
- if (bps > 16) {
- c->lpc = flac_lpc_32_c;
- c->lpc_encode = flac_lpc_encode_c_32;
- } else {
- c->lpc = flac_lpc_16_c;
- c->lpc_encode = flac_lpc_encode_c_16;
- }
-
- switch (fmt) {
- case AV_SAMPLE_FMT_S32:
- c->decorrelate[0] = flac_decorrelate_indep_c_32;
- c->decorrelate[1] = flac_decorrelate_ls_c_32;
- c->decorrelate[2] = flac_decorrelate_rs_c_32;
- c->decorrelate[3] = flac_decorrelate_ms_c_32;
- break;
-
- case AV_SAMPLE_FMT_S32P:
- c->decorrelate[0] = flac_decorrelate_indep_c_32p;
- c->decorrelate[1] = flac_decorrelate_ls_c_32p;
- c->decorrelate[2] = flac_decorrelate_rs_c_32p;
- c->decorrelate[3] = flac_decorrelate_ms_c_32p;
- break;
-
- case AV_SAMPLE_FMT_S16:
- c->decorrelate[0] = flac_decorrelate_indep_c_16;
- c->decorrelate[1] = flac_decorrelate_ls_c_16;
- c->decorrelate[2] = flac_decorrelate_rs_c_16;
- c->decorrelate[3] = flac_decorrelate_ms_c_16;
- break;
-
- case AV_SAMPLE_FMT_S16P:
- c->decorrelate[0] = flac_decorrelate_indep_c_16p;
- c->decorrelate[1] = flac_decorrelate_ls_c_16p;
- c->decorrelate[2] = flac_decorrelate_rs_c_16p;
- c->decorrelate[3] = flac_decorrelate_ms_c_16p;
- break;
- }
-
- if (ARCH_ARM)
- ff_flacdsp_init_arm(c, fmt, bps);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/flacdsp.h b/src/thirdparty/ffmpeg/libavcodec/flacdsp.h
deleted file mode 100644
index 272bc4080..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/flacdsp.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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_FLACDSP_H
-#define AVCODEC_FLACDSP_H
-
-#include <stdint.h>
-#include "libavutil/samplefmt.h"
-
-typedef struct FLACDSPContext {
- void (*decorrelate[4])(uint8_t **out, int32_t **in, int channels,
- int len, int shift);
- void (*lpc)(int32_t *samples, const int coeffs[32], int order,
- int qlevel, int len);
- void (*lpc_encode)(int32_t *res, const int32_t *smp, int len, int order,
- const int32_t *coefs, int shift);
-} FLACDSPContext;
-
-void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt, int bps);
-void ff_flacdsp_init_arm(FLACDSPContext *c, enum AVSampleFormat fmt, int bps);
-
-#endif /* AVCODEC_FLACDSP_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/flacdsp_lpc_template.c b/src/thirdparty/ffmpeg/libavcodec/flacdsp_lpc_template.c
deleted file mode 100644
index 0c453aee8..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/flacdsp_lpc_template.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * 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/avutil.h"
-#include "mathops.h"
-
-#undef FUNC
-#undef sum_type
-#undef MUL
-#undef CLIP
-#undef FSUF
-
-#define FUNC(n) AV_JOIN(n ## _, SAMPLE_SIZE)
-
-#if SAMPLE_SIZE == 32
-# define sum_type int64_t
-# define MUL(a, b) MUL64(a, b)
-# define CLIP(x) av_clipl_int32(x)
-#else
-# define sum_type int32_t
-# define MUL(a, b) ((a) * (b))
-# define CLIP(x) (x)
-#endif
-
-#define LPC1(x) { \
- int c = coefs[(x)-1]; \
- p0 += MUL(c, s); \
- s = smp[i-(x)+1]; \
- p1 += MUL(c, s); \
-}
-
-static av_always_inline void FUNC(lpc_encode_unrolled)(int32_t *res,
- const int32_t *smp, int len, int order,
- const int32_t *coefs, int shift, int big)
-{
- int i;
- for (i = order; i < len; i += 2) {
- int s = smp[i-order];
- sum_type p0 = 0, p1 = 0;
- if (big) {
- switch (order) {
- case 32: LPC1(32)
- case 31: LPC1(31)
- case 30: LPC1(30)
- case 29: LPC1(29)
- case 28: LPC1(28)
- case 27: LPC1(27)
- case 26: LPC1(26)
- case 25: LPC1(25)
- case 24: LPC1(24)
- case 23: LPC1(23)
- case 22: LPC1(22)
- case 21: LPC1(21)
- case 20: LPC1(20)
- case 19: LPC1(19)
- case 18: LPC1(18)
- case 17: LPC1(17)
- case 16: LPC1(16)
- case 15: LPC1(15)
- case 14: LPC1(14)
- case 13: LPC1(13)
- case 12: LPC1(12)
- case 11: LPC1(11)
- case 10: LPC1(10)
- case 9: LPC1( 9)
- LPC1( 8)
- LPC1( 7)
- LPC1( 6)
- LPC1( 5)
- LPC1( 4)
- LPC1( 3)
- LPC1( 2)
- LPC1( 1)
- }
- } else {
- switch (order) {
- case 8: LPC1( 8)
- case 7: LPC1( 7)
- case 6: LPC1( 6)
- case 5: LPC1( 5)
- case 4: LPC1( 4)
- case 3: LPC1( 3)
- case 2: LPC1( 2)
- case 1: LPC1( 1)
- }
- }
- res[i ] = smp[i ] - CLIP(p0 >> shift);
- res[i+1] = smp[i+1] - CLIP(p1 >> shift);
- }
-}
-
-static void FUNC(flac_lpc_encode_c)(int32_t *res, const int32_t *smp, int len,
- int order, const int32_t *coefs, int shift)
-{
- int i;
- for (i = 0; i < order; i++)
- res[i] = smp[i];
-#if CONFIG_SMALL
- for (i = order; i < len; i += 2) {
- int j;
- int s = smp[i];
- sum_type p0 = 0, p1 = 0;
- for (j = 0; j < order; j++) {
- int c = coefs[j];
- p1 += MUL(c, s);
- s = smp[i-j-1];
- p0 += MUL(c, s);
- }
- res[i ] = smp[i ] - CLIP(p0 >> shift);
- res[i+1] = smp[i+1] - CLIP(p1 >> shift);
- }
-#else
- switch (order) {
- case 1: FUNC(lpc_encode_unrolled)(res, smp, len, 1, coefs, shift, 0); break;
- case 2: FUNC(lpc_encode_unrolled)(res, smp, len, 2, coefs, shift, 0); break;
- case 3: FUNC(lpc_encode_unrolled)(res, smp, len, 3, coefs, shift, 0); break;
- case 4: FUNC(lpc_encode_unrolled)(res, smp, len, 4, coefs, shift, 0); break;
- case 5: FUNC(lpc_encode_unrolled)(res, smp, len, 5, coefs, shift, 0); break;
- case 6: FUNC(lpc_encode_unrolled)(res, smp, len, 6, coefs, shift, 0); break;
- case 7: FUNC(lpc_encode_unrolled)(res, smp, len, 7, coefs, shift, 0); break;
- case 8: FUNC(lpc_encode_unrolled)(res, smp, len, 8, coefs, shift, 0); break;
- default: FUNC(lpc_encode_unrolled)(res, smp, len, order, coefs, shift, 1); break;
- }
-#endif
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/flacdsp_template.c b/src/thirdparty/ffmpeg/libavcodec/flacdsp_template.c
deleted file mode 100644
index 1a37a391b..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/flacdsp_template.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 2012 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/avutil.h"
-
-#undef FUNC
-#undef FSUF
-#undef sample
-#undef sample_type
-#undef OUT
-#undef S
-
-#if SAMPLE_SIZE == 32
-# define sample_type int32_t
-#else
-# define sample_type int16_t
-#endif
-
-#if PLANAR
-# define FSUF AV_JOIN(SAMPLE_SIZE, p)
-# define sample sample_type *
-# define OUT(n) n
-# define S(s, c, i) (s[c][i])
-#else
-# define FSUF SAMPLE_SIZE
-# define sample sample_type
-# define OUT(n) n[0]
-# define S(s, c, i) (*s++)
-#endif
-
-#define FUNC(n) AV_JOIN(n ## _, FSUF)
-
-static void FUNC(flac_decorrelate_indep_c)(uint8_t **out, int32_t **in,
- int channels, int len, int shift)
-{
- sample *samples = (sample *) OUT(out);
- int i, j;
-
- for (j = 0; j < len; j++)
- for (i = 0; i < channels; i++)
- S(samples, i, j) = in[i][j] << shift;
-}
-
-static void FUNC(flac_decorrelate_ls_c)(uint8_t **out, int32_t **in,
- int channels, int len, int shift)
-{
- sample *samples = (sample *) OUT(out);
- int i;
-
- for (i = 0; i < len; i++) {
- int a = in[0][i];
- int b = in[1][i];
- S(samples, 0, i) = a << shift;
- S(samples, 1, i) = (a - b) << shift;
- }
-}
-
-static void FUNC(flac_decorrelate_rs_c)(uint8_t **out, int32_t **in,
- int channels, int len, int shift)
-{
- sample *samples = (sample *) OUT(out);
- int i;
-
- for (i = 0; i < len; i++) {
- int a = in[0][i];
- int b = in[1][i];
- S(samples, 0, i) = (a + b) << shift;
- S(samples, 1, i) = b << shift;
- }
-}
-
-static void FUNC(flac_decorrelate_ms_c)(uint8_t **out, int32_t **in,
- int channels, int len, int shift)
-{
- sample *samples = (sample *) OUT(out);
- int i;
-
- for (i = 0; i < len; i++) {
- int a = in[0][i];
- int b = in[1][i];
- a -= b >> 1;
- S(samples, 0, i) = (a + b) << shift;
- S(samples, 1, i) = a << shift;
- }
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/flv.h b/src/thirdparty/ffmpeg/libavcodec/flv.h
deleted file mode 100644
index 2dac8977b..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/flv.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * FLV specific private header.
- * 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_FLV_H
-#define AVCODEC_FLV_H
-
-#include "mpegvideo.h"
-#include "get_bits.h"
-#include "put_bits.h"
-
-void ff_flv_encode_picture_header(MpegEncContext * s, int picture_number);
-void ff_flv2_encode_ac_esc(PutBitContext *pb, int slevel, int level, int run, int last);
-
-int ff_flv_decode_picture_header(MpegEncContext *s);
-void ff_flv2_decode_ac_esc(GetBitContext *gb, int *level, int *run, int *last);
-
-#endif /* AVCODEC_FLV_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/flvdec.c b/src/thirdparty/ffmpeg/libavcodec/flvdec.c
deleted file mode 100644
index 87e2b5fb2..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/flvdec.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * FLV decoding.
- * 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 "mpegvideo.h"
-#include "h263.h"
-#include "flv.h"
-#include "libavutil/imgutils.h"
-
-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){
- *level = get_sbits(gb, 11);
- } else {
- *level = get_sbits(gb, 7);
- }
-}
-
-int ff_flv_decode_picture_header(MpegEncContext *s)
-{
- int format, width, height;
-
- /* picture header */
- if (get_bits_long(&s->gb, 17) != 1) {
- av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
- return AVERROR_INVALIDDATA;
- }
- format = get_bits(&s->gb, 5);
- if (format != 0 && format != 1) {
- av_log(s->avctx, AV_LOG_ERROR, "Bad picture format\n");
- return AVERROR_INVALIDDATA;
- }
- s->h263_flv = format+1;
- s->picture_number = get_bits(&s->gb, 8); /* picture timestamp */
- format = get_bits(&s->gb, 3);
- switch (format) {
- case 0:
- width = get_bits(&s->gb, 8);
- height = get_bits(&s->gb, 8);
- break;
- case 1:
- width = get_bits(&s->gb, 16);
- height = get_bits(&s->gb, 16);
- break;
- case 2:
- width = 352;
- height = 288;
- break;
- case 3:
- width = 176;
- height = 144;
- break;
- case 4:
- width = 128;
- height = 96;
- break;
- case 5:
- width = 320;
- height = 240;
- break;
- case 6:
- width = 160;
- height = 120;
- break;
- default:
- width = height = 0;
- break;
- }
- if(av_image_check_size(width, height, 0, s->avctx))
- return AVERROR(EINVAL);
- s->width = width;
- s->height = height;
-
- s->pict_type = AV_PICTURE_TYPE_I + get_bits(&s->gb, 2);
- s->droppable = s->pict_type > AV_PICTURE_TYPE_P;
- if (s->droppable)
- s->pict_type = AV_PICTURE_TYPE_P;
-
- skip_bits1(&s->gb); /* deblocking flag */
- s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
-
- s->h263_plus = 0;
-
- s->unrestricted_mv = 1;
- s->h263_long_vectors = 0;
-
- /* PEI */
- while (get_bits1(&s->gb) != 0) {
- skip_bits(&s->gb, 8);
- }
- s->f_code = 1;
-
- 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;
-
- return 0;
-}
-
-AVCodec ff_flv_decoder = {
- .name = "flv",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_FLV1,
- .priv_data_size = sizeof(MpegEncContext),
- .init = ff_h263_decode_init,
- .close = ff_h263_decode_end,
- .decode = ff_h263_decode_frame,
- .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
- .max_lowres = 3,
- .long_name = NULL_IF_CONFIG_SMALL("FLV / Sorenson Spark / Sorenson H.263 (Flash Video)"),
- .pix_fmts = ff_pixfmt_list_420,
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/fmtconvert.c b/src/thirdparty/ffmpeg/libavcodec/fmtconvert.c
deleted file mode 100644
index 9cf9f69b7..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/fmtconvert.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Format Conversion Utils
- * Copyright (c) 2000, 2001 Fabrice Bellard
- * Copyright (c) 2002-2004 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
- */
-
-#include "avcodec.h"
-#include "fmtconvert.h"
-#include "libavutil/common.h"
-
-static void int32_to_float_fmul_scalar_c(float *dst, const int *src, float mul, int len){
- int i;
- for(i=0; i<len; i++)
- dst[i] = src[i] * mul;
-}
-
-static av_always_inline int float_to_int16_one(const float *src){
- return av_clip_int16(lrintf(*src));
-}
-
-static void float_to_int16_c(int16_t *dst, const float *src, long len)
-{
- int i;
- for(i=0; i<len; i++)
- dst[i] = float_to_int16_one(src+i);
-}
-
-static void float_to_int16_interleave_c(int16_t *dst, const float **src,
- long len, int channels)
-{
- int i,j,c;
- if(channels==2){
- for(i=0; i<len; i++){
- dst[2*i] = float_to_int16_one(src[0]+i);
- dst[2*i+1] = float_to_int16_one(src[1]+i);
- }
- }else{
- for(c=0; c<channels; c++)
- for(i=0, j=c; i<len; i++, j+=channels)
- dst[j] = float_to_int16_one(src[c]+i);
- }
-}
-
-void ff_float_interleave_c(float *dst, const float **src, unsigned int len,
- int channels)
-{
- int j, c;
- unsigned int i;
- if (channels == 2) {
- for (i = 0; i < len; i++) {
- dst[2*i] = src[0][i];
- dst[2*i+1] = src[1][i];
- }
- } else if (channels == 1 && len < INT_MAX / sizeof(float)) {
- memcpy(dst, src[0], len * sizeof(float));
- } else {
- for (c = 0; c < channels; c++)
- for (i = 0, j = c; i < len; i++, j += channels)
- dst[j] = src[c][i];
- }
-}
-
-av_cold void ff_fmt_convert_init(FmtConvertContext *c, AVCodecContext *avctx)
-{
- c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_c;
- c->float_to_int16 = float_to_int16_c;
- c->float_to_int16_interleave = float_to_int16_interleave_c;
- c->float_interleave = ff_float_interleave_c;
-
- if (ARCH_ARM) ff_fmt_convert_init_arm(c, avctx);
- if (HAVE_ALTIVEC) ff_fmt_convert_init_altivec(c, avctx);
- if (ARCH_X86) ff_fmt_convert_init_x86(c, avctx);
- if (HAVE_MIPSFPU) ff_fmt_convert_init_mips(c);
-}
-
-/* ffdshow custom code */
-void float_interleave(float *dst, const float **src, long len, int channels)
-{
- int i,j,c;
- if(channels==2){
- for(i=0; i<len; i++){
- dst[2*i] = src[0][i] / 32768.0f;
- dst[2*i+1] = src[1][i] / 32768.0f;
- }
- }else{
- for(c=0; c<channels; c++)
- for(i=0, j=c; i<len; i++, j+=channels)
- dst[j] = src[c][i] / 32768.0f;
- }
-}
-
-void float_interleave_noscale(float *dst, const float **src, long len, int channels)
-{
- int i,j,c;
- if(channels==2){
- for(i=0; i<len; i++){
- dst[2*i] = src[0][i];
- dst[2*i+1] = src[1][i];
- }
- }else{
- for(c=0; c<channels; c++)
- for(i=0, j=c; i<len; i++, j+=channels)
- dst[j] = src[c][i];
- }
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/fmtconvert.h b/src/thirdparty/ffmpeg/libavcodec/fmtconvert.h
deleted file mode 100644
index 4a1612ba3..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/fmtconvert.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Format Conversion Utils
- * Copyright (c) 2000, 2001 Fabrice Bellard
- * Copyright (c) 2002-2004 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
- */
-
-#ifndef AVCODEC_FMTCONVERT_H
-#define AVCODEC_FMTCONVERT_H
-
-#include "avcodec.h"
-
-typedef struct FmtConvertContext {
- /**
- * Convert an array of int32_t to float and multiply by a float value.
- * @param dst destination array of float.
- * constraints: 16-byte aligned
- * @param src source array of int32_t.
- * constraints: 16-byte aligned
- * @param len number of elements to convert.
- * constraints: multiple of 8
- */
- void (*int32_to_float_fmul_scalar)(float *dst, const int *src, float mul, int len);
-
- /**
- * Convert an array of float to an array of int16_t.
- *
- * Convert floats from in the range [-32768.0,32767.0] to ints
- * without rescaling
- *
- * @param dst destination array of int16_t.
- * constraints: 16-byte aligned
- * @param src source array of float.
- * constraints: 16-byte aligned
- * @param len number of elements to convert.
- * constraints: multiple of 8
- */
- void (*float_to_int16)(int16_t *dst, const float *src, long len);
-
- /**
- * Convert multiple arrays of float to an interleaved array of int16_t.
- *
- * Convert floats from in the range [-32768.0,32767.0] to ints
- * without rescaling
- *
- * @param dst destination array of interleaved int16_t.
- * constraints: 16-byte aligned
- * @param src source array of float arrays, one for each channel.
- * constraints: 16-byte aligned
- * @param len number of elements to convert.
- * constraints: multiple of 8
- * @param channels number of channels
- */
- void (*float_to_int16_interleave)(int16_t *dst, const float **src,
- long len, int channels);
-
- /**
- * Convert multiple arrays of float to an array of interleaved float.
- *
- * @param dst destination array of interleaved float.
- * constraints: 16-byte aligned
- * @param src source array of float arrays, one for each channel.
- * constraints: 16-byte aligned
- * @param len number of elements to convert.
- * constraints: multiple of 8
- * @param channels number of channels
- */
- void (*float_interleave)(float *dst, const float **src, unsigned int len,
- int channels);
-} FmtConvertContext;
-
-void ff_float_interleave_c(float *dst, const float **src, unsigned int len,
- int channels);
-
-av_cold void ff_fmt_convert_init(FmtConvertContext *c, AVCodecContext *avctx);
-
-void ff_fmt_convert_init_arm(FmtConvertContext *c, AVCodecContext *avctx);
-void ff_fmt_convert_init_altivec(FmtConvertContext *c, AVCodecContext *avctx);
-void ff_fmt_convert_init_x86(FmtConvertContext *c, AVCodecContext *avctx);
-void ff_fmt_convert_init_mips(FmtConvertContext *c);
-
-/* ffdshow custom code */
-void float_interleave(float *dst, const float **src, long len, int channels);
-void float_interleave_noscale(float *dst, const float **src, long len, int channels);
-
-#endif /* AVCODEC_FMTCONVERT_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/frame_thread_encoder.c b/src/thirdparty/ffmpeg/libavcodec/frame_thread_encoder.c
deleted file mode 100644
index b5ad22dd7..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/frame_thread_encoder.c
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- * Copyright (c) 2012 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
- */
-
-#include "frame_thread_encoder.h"
-
-#include "libavutil/fifo.h"
-#include "libavutil/avassert.h"
-#include "libavutil/imgutils.h"
-#include "avcodec.h"
-#include "internal.h"
-#include "thread.h"
-
-#if HAVE_PTHREADS
-#include <pthread.h>
-#elif HAVE_W32THREADS
-#include "w32pthreads.h"
-#elif HAVE_OS2THREADS
-#include "os2threads.h"
-#endif
-
-#define MAX_THREADS 64
-#define BUFFER_SIZE (2*MAX_THREADS)
-
-typedef struct{
- void *indata;
- void *outdata;
- int64_t return_code;
- unsigned index;
-} Task;
-
-typedef struct{
- AVCodecContext *parent_avctx;
- pthread_mutex_t buffer_mutex;
-
- AVFifoBuffer *task_fifo;
- pthread_mutex_t task_fifo_mutex;
- pthread_cond_t task_fifo_cond;
-
- Task finished_tasks[BUFFER_SIZE];
- pthread_mutex_t finished_task_mutex;
- pthread_cond_t finished_task_cond;
-
- unsigned task_index;
- unsigned finished_task_index;
-
- pthread_t worker[MAX_THREADS];
- int exit;
-} ThreadContext;
-
-static void * attribute_align_arg worker(void *v){
- AVCodecContext *avctx = v;
- ThreadContext *c = avctx->internal->frame_thread_encoder;
- AVPacket *pkt = NULL;
-
- while(!c->exit){
- int got_packet, ret;
- AVFrame *frame;
- Task task;
-
- if(!pkt) pkt= av_mallocz(sizeof(*pkt));
- if(!pkt) continue;
- av_init_packet(pkt);
-
- pthread_mutex_lock(&c->task_fifo_mutex);
- while (av_fifo_size(c->task_fifo) <= 0 || c->exit) {
- if(c->exit){
- pthread_mutex_unlock(&c->task_fifo_mutex);
- goto end;
- }
- pthread_cond_wait(&c->task_fifo_cond, &c->task_fifo_mutex);
- }
- av_fifo_generic_read(c->task_fifo, &task, sizeof(task), NULL);
- pthread_mutex_unlock(&c->task_fifo_mutex);
- frame = task.indata;
-
- ret = avcodec_encode_video2(avctx, pkt, frame, &got_packet);
- pthread_mutex_lock(&c->buffer_mutex);
- c->parent_avctx->release_buffer(c->parent_avctx, frame);
- pthread_mutex_unlock(&c->buffer_mutex);
- av_freep(&frame);
- if(got_packet) {
- av_dup_packet(pkt);
- } else {
- pkt->data = NULL;
- pkt->size = 0;
- }
- pthread_mutex_lock(&c->finished_task_mutex);
- c->finished_tasks[task.index].outdata = pkt; pkt = NULL;
- c->finished_tasks[task.index].return_code = ret;
- pthread_cond_signal(&c->finished_task_cond);
- pthread_mutex_unlock(&c->finished_task_mutex);
- }
-end:
- av_free(pkt);
- pthread_mutex_lock(&c->buffer_mutex);
- avcodec_close(avctx);
- pthread_mutex_unlock(&c->buffer_mutex);
- av_freep(&avctx);
- return NULL;
-}
-
-int ff_frame_thread_encoder_init(AVCodecContext *avctx, AVDictionary *options){
- int i=0;
- ThreadContext *c;
-
-
- if( !(avctx->thread_type & FF_THREAD_FRAME)
- || !(avctx->codec->capabilities & CODEC_CAP_INTRA_ONLY))
- return 0;
-
- if(!avctx->thread_count) {
- avctx->thread_count = ff_get_logical_cpus(avctx);
- avctx->thread_count = FFMIN(avctx->thread_count, MAX_THREADS);
- }
-
- if(avctx->thread_count <= 1)
- return 0;
-
- if(avctx->thread_count > MAX_THREADS)
- return AVERROR(EINVAL);
-
- av_assert0(!avctx->internal->frame_thread_encoder);
- c = avctx->internal->frame_thread_encoder = av_mallocz(sizeof(ThreadContext));
- if(!c)
- return AVERROR(ENOMEM);
-
- c->parent_avctx = avctx;
-
- c->task_fifo = av_fifo_alloc(sizeof(Task) * BUFFER_SIZE);
- if(!c->task_fifo)
- goto fail;
-
- pthread_mutex_init(&c->task_fifo_mutex, NULL);
- pthread_mutex_init(&c->finished_task_mutex, NULL);
- pthread_mutex_init(&c->buffer_mutex, NULL);
- pthread_cond_init(&c->task_fifo_cond, NULL);
- pthread_cond_init(&c->finished_task_cond, NULL);
-
- for(i=0; i<avctx->thread_count ; i++){
- AVDictionary *tmp = NULL;
- void *tmpv;
- AVCodecContext *thread_avctx = avcodec_alloc_context3(avctx->codec);
- if(!thread_avctx)
- goto fail;
- tmpv = thread_avctx->priv_data;
- *thread_avctx = *avctx;
- thread_avctx->priv_data = tmpv;
- thread_avctx->internal = NULL;
- memcpy(thread_avctx->priv_data, avctx->priv_data, avctx->codec->priv_data_size);
- thread_avctx->thread_count = 1;
- thread_avctx->active_thread_type &= ~FF_THREAD_FRAME;
-
- av_dict_copy(&tmp, options, 0);
- av_dict_set(&tmp, "threads", "1", 0);
- if(avcodec_open2(thread_avctx, avctx->codec, &tmp) < 0) {
- av_dict_free(&tmp);
- goto fail;
- }
- av_dict_free(&tmp);
- av_assert0(!thread_avctx->internal->frame_thread_encoder);
- thread_avctx->internal->frame_thread_encoder = c;
- if(pthread_create(&c->worker[i], NULL, worker, thread_avctx)) {
- goto fail;
- }
- }
-
- avctx->active_thread_type = FF_THREAD_FRAME;
-
- return 0;
-fail:
- avctx->thread_count = i;
- av_log(avctx, AV_LOG_ERROR, "ff_frame_thread_encoder_init failed\n");
- ff_frame_thread_encoder_free(avctx);
- return -1;
-}
-
-void ff_frame_thread_encoder_free(AVCodecContext *avctx){
- int i;
- ThreadContext *c= avctx->internal->frame_thread_encoder;
-
- pthread_mutex_lock(&c->task_fifo_mutex);
- c->exit = 1;
- pthread_cond_broadcast(&c->task_fifo_cond);
- pthread_mutex_unlock(&c->task_fifo_mutex);
-
- for (i=0; i<avctx->thread_count; i++) {
- pthread_join(c->worker[i], NULL);
- }
-
- pthread_mutex_destroy(&c->task_fifo_mutex);
- pthread_mutex_destroy(&c->finished_task_mutex);
- 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_freep(&avctx->internal->frame_thread_encoder);
-}
-
-int ff_thread_video_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet_ptr){
- ThreadContext *c = avctx->internal->frame_thread_encoder;
- Task task;
- int ret;
-
- av_assert1(!*got_packet_ptr);
-
- if(frame){
- if(!(avctx->flags & CODEC_FLAG_INPUT_PRESERVED)){
- AVFrame *new = avcodec_alloc_frame();
- if(!new)
- return AVERROR(ENOMEM);
- pthread_mutex_lock(&c->buffer_mutex);
- ret = ff_get_buffer(c->parent_avctx, new);
- pthread_mutex_unlock(&c->buffer_mutex);
- if(ret<0)
- return ret;
- new->pts = frame->pts;
- new->quality = frame->quality;
- new->pict_type = frame->pict_type;
- av_image_copy(new->data, new->linesize, (const uint8_t **)frame->data, frame->linesize,
- avctx->pix_fmt, avctx->width, avctx->height);
- frame = new;
- }
-
- task.index = c->task_index;
- task.indata = (void*)frame;
- pthread_mutex_lock(&c->task_fifo_mutex);
- av_fifo_generic_write(c->task_fifo, &task, sizeof(task), NULL);
- pthread_cond_signal(&c->task_fifo_cond);
- pthread_mutex_unlock(&c->task_fifo_mutex);
-
- c->task_index = (c->task_index+1) % BUFFER_SIZE;
-
- if(!c->finished_tasks[c->finished_task_index].outdata && (c->task_index - c->finished_task_index) % BUFFER_SIZE <= avctx->thread_count)
- return 0;
- }
-
- if(c->task_index == c->finished_task_index)
- return 0;
-
- pthread_mutex_lock(&c->finished_task_mutex);
- while (!c->finished_tasks[c->finished_task_index].outdata) {
- pthread_cond_wait(&c->finished_task_cond, &c->finished_task_mutex);
- }
- task = c->finished_tasks[c->finished_task_index];
- *pkt = *(AVPacket*)(task.outdata);
- if(pkt->data)
- *got_packet_ptr = 1;
- av_freep(&c->finished_tasks[c->finished_task_index].outdata);
- c->finished_task_index = (c->finished_task_index+1) % BUFFER_SIZE;
- pthread_mutex_unlock(&c->finished_task_mutex);
-
- return task.return_code;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/frame_thread_encoder.h b/src/thirdparty/ffmpeg/libavcodec/frame_thread_encoder.h
deleted file mode 100644
index 9b131a2f5..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/frame_thread_encoder.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2012 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
- */
-
-#include "avcodec.h"
-
-int ff_frame_thread_encoder_init(AVCodecContext *avctx, AVDictionary *options);
-void ff_frame_thread_encoder_free(AVCodecContext *avctx);
-int ff_thread_video_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet_ptr);
-
diff --git a/src/thirdparty/ffmpeg/libavcodec/get_bits.h b/src/thirdparty/ffmpeg/libavcodec/get_bits.h
deleted file mode 100644
index fd872d9e7..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/get_bits.h
+++ /dev/null
@@ -1,631 +0,0 @@
-/*
- * copyright (c) 2004 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
- * bitstream reader API header.
- */
-
-#ifndef AVCODEC_GET_BITS_H
-#define AVCODEC_GET_BITS_H
-
-#include <stdint.h>
-
-#include "libavutil/common.h"
-#include "libavutil/intreadwrite.h"
-#include "libavutil/log.h"
-#include "libavutil/avassert.h"
-#include "mathops.h"
-
-/*
- * Safe bitstream reading:
- * optionally, the get_bits API can check to ensure that we
- * don't read past input buffer boundaries. This is protected
- * with CONFIG_SAFE_BITSTREAM_READER at the global level, and
- * then below that with UNCHECKED_BITSTREAM_READER at the per-
- * decoder level. This means that decoders that check internally
- * can "#define UNCHECKED_BITSTREAM_READER 1" to disable
- * overread checks.
- * Boundary checking causes a minor performance penalty so for
- * applications that won't want/need this, it can be disabled
- * globally using "#define CONFIG_SAFE_BITSTREAM_READER 0".
- */
-#ifndef UNCHECKED_BITSTREAM_READER
-#define UNCHECKED_BITSTREAM_READER !CONFIG_SAFE_BITSTREAM_READER
-#endif
-
-typedef struct GetBitContext {
- const uint8_t *buffer, *buffer_end;
- int index;
- int size_in_bits;
- int size_in_bits_plus8;
-} GetBitContext;
-
-#define VLC_TYPE int16_t
-
-typedef struct VLC {
- int bits;
- VLC_TYPE (*table)[2]; ///< code, bits
- int table_size, table_allocated;
-} VLC;
-
-typedef struct RL_VLC_ELEM {
- int16_t level;
- int8_t len;
- uint8_t run;
-} RL_VLC_ELEM;
-
-/* Bitstream reader API docs:
- * name
- * arbitrary name which is used as prefix for the internal variables
- *
- * gb
- * getbitcontext
- *
- * OPEN_READER(name, gb)
- * load gb into local variables
- *
- * CLOSE_READER(name, gb)
- * store local vars in gb
- *
- * UPDATE_CACHE(name, gb)
- * Refill the internal cache from the bitstream.
- * After this call at least MIN_CACHE_BITS will be available.
- *
- * GET_CACHE(name, gb)
- * Will output the contents of the internal cache,
- * next bit is MSB of 32 or 64 bit (FIXME 64bit).
- *
- * SHOW_UBITS(name, gb, num)
- * Will return the next num bits.
- *
- * SHOW_SBITS(name, gb, num)
- * Will return the next num bits and do sign extension.
- *
- * SKIP_BITS(name, gb, num)
- * Will skip over the next num bits.
- * Note, this is equivalent to SKIP_CACHE; SKIP_COUNTER.
- *
- * SKIP_CACHE(name, gb, num)
- * Will remove the next num bits from the cache (note SKIP_COUNTER
- * MUST be called before UPDATE_CACHE / CLOSE_READER).
- *
- * SKIP_COUNTER(name, gb, num)
- * Will increment the internal bit counter (see SKIP_CACHE & SKIP_BITS).
- *
- * LAST_SKIP_BITS(name, gb, num)
- * Like SKIP_BITS, to be used if next call is UPDATE_CACHE or CLOSE_READER.
- *
- * For examples see get_bits, show_bits, skip_bits, get_vlc.
- */
-
-#ifdef LONG_BITSTREAM_READER
-# define MIN_CACHE_BITS 32
-#else
-# define MIN_CACHE_BITS 25
-#endif
-
-#if UNCHECKED_BITSTREAM_READER
-#define OPEN_READER(name, gb) \
- unsigned int name ## _index = (gb)->index; \
- unsigned int av_unused name ## _cache
-
-#define HAVE_BITS_REMAINING(name, gb) 1
-#else
-#define OPEN_READER(name, gb) \
- unsigned int name ## _index = (gb)->index; \
- unsigned int av_unused name ## _cache = 0; \
- unsigned int av_unused name ## _size_plus8 = (gb)->size_in_bits_plus8
-
-#define HAVE_BITS_REMAINING(name, gb) name ## _index < name ## _size_plus8
-#endif
-
-#define CLOSE_READER(name, gb) (gb)->index = name ## _index
-
-#ifdef BITSTREAM_READER_LE
-
-# ifdef LONG_BITSTREAM_READER
-# define UPDATE_CACHE(name, gb) name ## _cache = \
- AV_RL64((gb)->buffer + (name ## _index >> 3)) >> (name ## _index & 7)
-# else
-# define UPDATE_CACHE(name, gb) name ## _cache = \
- AV_RL32((gb)->buffer + (name ## _index >> 3)) >> (name ## _index & 7)
-# endif
-
-# define SKIP_CACHE(name, gb, num) name ## _cache >>= (num)
-
-#else
-
-# ifdef LONG_BITSTREAM_READER
-# define UPDATE_CACHE(name, gb) name ## _cache = \
- AV_RB64((gb)->buffer + (name ## _index >> 3)) >> (32 - (name ## _index & 7))
-# else
-# define UPDATE_CACHE(name, gb) name ## _cache = \
- AV_RB32((gb)->buffer + (name ## _index >> 3)) << (name ## _index & 7)
-# endif
-
-# define SKIP_CACHE(name, gb, num) name ## _cache <<= (num)
-
-#endif
-
-#if UNCHECKED_BITSTREAM_READER
-# define SKIP_COUNTER(name, gb, num) name ## _index += (num)
-#else
-# define SKIP_COUNTER(name, gb, num) \
- name ## _index = FFMIN(name ## _size_plus8, name ## _index + (num))
-#endif
-
-#define SKIP_BITS(name, gb, num) \
- do { \
- SKIP_CACHE(name, gb, num); \
- SKIP_COUNTER(name, gb, num); \
- } while (0)
-
-#define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num)
-
-#ifdef BITSTREAM_READER_LE
-# define SHOW_UBITS(name, gb, num) zero_extend(name ## _cache, num)
-# define SHOW_SBITS(name, gb, num) sign_extend(name ## _cache, num)
-#else
-# define SHOW_UBITS(name, gb, num) NEG_USR32(name ## _cache, num)
-# define SHOW_SBITS(name, gb, num) NEG_SSR32(name ## _cache, num)
-#endif
-
-#define GET_CACHE(name, gb) ((uint32_t) name ## _cache)
-
-static inline int get_bits_count(const GetBitContext *s)
-{
- return s->index;
-}
-
-static inline void skip_bits_long(GetBitContext *s, int n)
-{
-#if UNCHECKED_BITSTREAM_READER
- s->index += n;
-#else
- s->index += av_clip(n, -s->index, s->size_in_bits_plus8 - s->index);
-#endif
-}
-
-/**
- * read mpeg1 dc style vlc (sign bit + mantisse with no MSB).
- * if MSB not set it is negative
- * @param n length in bits
- */
-static inline int get_xbits(GetBitContext *s, int n)
-{
- register int sign;
- register int32_t cache;
- OPEN_READER(re, s);
- UPDATE_CACHE(re, s);
- cache = GET_CACHE(re, s);
- sign = ~cache >> 31;
- LAST_SKIP_BITS(re, s, n);
- CLOSE_READER(re, s);
- return (NEG_USR32(sign ^ cache, n) ^ sign) - sign;
-}
-
-static inline int get_sbits(GetBitContext *s, int n)
-{
- register int tmp;
- OPEN_READER(re, s);
- av_assert2(n>0 && n<=25);
- UPDATE_CACHE(re, s);
- tmp = SHOW_SBITS(re, s, n);
- LAST_SKIP_BITS(re, s, n);
- CLOSE_READER(re, s);
- return tmp;
-}
-
-/**
- * Read 1-25 bits.
- */
-static inline unsigned int get_bits(GetBitContext *s, int n)
-{
- register int tmp;
- OPEN_READER(re, s);
- av_assert2(n>0 && n<=25);
- UPDATE_CACHE(re, s);
- tmp = SHOW_UBITS(re, s, n);
- LAST_SKIP_BITS(re, s, n);
- CLOSE_READER(re, s);
- return tmp;
-}
-
-/**
- * Show 1-25 bits.
- */
-static inline unsigned int show_bits(GetBitContext *s, int n)
-{
- register int tmp;
- OPEN_READER(re, s);
- av_assert2(n>0 && n<=25);
- UPDATE_CACHE(re, s);
- tmp = SHOW_UBITS(re, s, n);
- return tmp;
-}
-
-static inline void skip_bits(GetBitContext *s, int n)
-{
- OPEN_READER(re, s);
- UPDATE_CACHE(re, s);
- LAST_SKIP_BITS(re, s, n);
- CLOSE_READER(re, s);
-}
-
-static inline unsigned int get_bits1(GetBitContext *s)
-{
- unsigned int index = s->index;
- uint8_t result = s->buffer[index >> 3];
-#ifdef BITSTREAM_READER_LE
- result >>= index & 7;
- result &= 1;
-#else
- result <<= index & 7;
- result >>= 8 - 1;
-#endif
-#if !UNCHECKED_BITSTREAM_READER
- if (s->index < s->size_in_bits_plus8)
-#endif
- index++;
- s->index = index;
-
- return result;
-}
-
-static inline unsigned int show_bits1(GetBitContext *s)
-{
- return show_bits(s, 1);
-}
-
-static inline void skip_bits1(GetBitContext *s)
-{
- skip_bits(s, 1);
-}
-
-/**
- * Read 0-32 bits.
- */
-static inline unsigned int get_bits_long(GetBitContext *s, int n)
-{
- if (!n) {
- return 0;
- } else if (n <= MIN_CACHE_BITS) {
- return get_bits(s, n);
- } else {
-#ifdef BITSTREAM_READER_LE
- unsigned ret = get_bits(s, 16);
- return ret | (get_bits(s, n - 16) << 16);
-#else
- unsigned ret = get_bits(s, 16) << (n - 16);
- return ret | get_bits(s, n - 16);
-#endif
- }
-}
-
-/**
- * Read 0-64 bits.
- */
-static inline uint64_t get_bits64(GetBitContext *s, int n)
-{
- if (n <= 32) {
- return get_bits_long(s, n);
- } else {
-#ifdef BITSTREAM_READER_LE
- uint64_t ret = get_bits_long(s, 32);
- return ret | (uint64_t) get_bits_long(s, n - 32) << 32;
-#else
- uint64_t ret = (uint64_t) get_bits_long(s, n - 32) << 32;
- return ret | get_bits_long(s, 32);
-#endif
- }
-}
-
-/**
- * Read 0-32 bits as a signed integer.
- */
-static inline int get_sbits_long(GetBitContext *s, int n)
-{
- return sign_extend(get_bits_long(s, n), n);
-}
-
-/**
- * Show 0-32 bits.
- */
-static inline unsigned int show_bits_long(GetBitContext *s, int n)
-{
- if (n <= MIN_CACHE_BITS) {
- return show_bits(s, n);
- } else {
- GetBitContext gb = *s;
- return get_bits_long(&gb, n);
- }
-}
-
-static inline int check_marker(GetBitContext *s, const char *msg)
-{
- int bit = get_bits1(s);
- if (!bit)
- av_log(NULL, AV_LOG_INFO, "Marker bit missing %s\n", msg);
-
- return bit;
-}
-
-/**
- * Initialize GetBitContext.
- * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes
- * larger than the actual read bits because some optimized bitstream
- * readers read 32 or 64 bit at once and could read over the end
- * @param bit_size the size of the buffer in bits
- * @return 0 on success, AVERROR_INVALIDDATA if the buffer_size would overflow.
- */
-static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer,
- int bit_size)
-{
- int buffer_size;
- int ret = 0;
-
- if (bit_size >= INT_MAX - 7 || bit_size < 0 || !buffer) {
- buffer_size = bit_size = 0;
- buffer = NULL;
- ret = AVERROR_INVALIDDATA;
- }
-
- buffer_size = (bit_size + 7) >> 3;
-
- s->buffer = buffer;
- s->size_in_bits = bit_size;
- s->size_in_bits_plus8 = bit_size + 8;
- s->buffer_end = buffer + buffer_size;
- s->index = 0;
-
- return ret;
-}
-
-/**
- * Initialize GetBitContext.
- * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes
- * larger than the actual read bits because some optimized bitstream
- * readers read 32 or 64 bit at once and could read over the end
- * @param byte_size the size of the buffer in bytes
- * @return 0 on success, AVERROR_INVALIDDATA if the buffer_size would overflow.
- */
-static inline int init_get_bits8(GetBitContext *s, const uint8_t *buffer,
- int byte_size)
-{
- if (byte_size > INT_MAX / 8 || byte_size < 0)
- byte_size = -1;
- return init_get_bits(s, buffer, byte_size * 8);
-}
-
-static inline const uint8_t *align_get_bits(GetBitContext *s)
-{
- int n = -get_bits_count(s) & 7;
- if (n)
- skip_bits(s, n);
- return s->buffer + (s->index >> 3);
-}
-
-#define init_vlc(vlc, nb_bits, nb_codes, \
- bits, bits_wrap, bits_size, \
- codes, codes_wrap, codes_size, \
- flags) \
- ff_init_vlc_sparse(vlc, nb_bits, nb_codes, \
- bits, bits_wrap, bits_size, \
- codes, codes_wrap, codes_size, \
- NULL, 0, 0, flags)
-
-int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes,
- const void *bits, int bits_wrap, int bits_size,
- const void *codes, int codes_wrap, int codes_size,
- const void *symbols, int symbols_wrap, int symbols_size,
- int flags);
-void ff_free_vlc(VLC *vlc);
-
-#define INIT_VLC_LE 2
-#define INIT_VLC_USE_NEW_STATIC 4
-
-#define INIT_VLC_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size) \
- do { \
- static VLC_TYPE table[static_size][2]; \
- (vlc)->table = table; \
- (vlc)->table_allocated = static_size; \
- init_vlc(vlc, bits, a, b, c, d, e, f, g, INIT_VLC_USE_NEW_STATIC); \
- } while (0)
-
-/**
- * If the vlc code is invalid and max_depth=1, then no bits will be removed.
- * If the vlc code is invalid and max_depth>1, then the number of bits removed
- * is undefined.
- */
-#define GET_VLC(code, name, gb, table, bits, max_depth) \
- do { \
- int n, nb_bits; \
- unsigned int index; \
- \
- index = SHOW_UBITS(name, gb, bits); \
- code = table[index][0]; \
- n = table[index][1]; \
- \
- if (max_depth > 1 && n < 0) { \
- LAST_SKIP_BITS(name, gb, bits); \
- UPDATE_CACHE(name, gb); \
- \
- nb_bits = -n; \
- \
- index = SHOW_UBITS(name, gb, nb_bits) + code; \
- code = table[index][0]; \
- n = table[index][1]; \
- if (max_depth > 2 && n < 0) { \
- LAST_SKIP_BITS(name, gb, nb_bits); \
- UPDATE_CACHE(name, gb); \
- \
- nb_bits = -n; \
- \
- index = SHOW_UBITS(name, gb, nb_bits) + code; \
- code = table[index][0]; \
- n = table[index][1]; \
- } \
- } \
- SKIP_BITS(name, gb, n); \
- } while (0)
-
-#define GET_RL_VLC(level, run, name, gb, table, bits, \
- max_depth, need_update) \
- do { \
- int n, nb_bits; \
- unsigned int index; \
- \
- index = SHOW_UBITS(name, gb, bits); \
- level = table[index].level; \
- n = table[index].len; \
- \
- if (max_depth > 1 && n < 0) { \
- SKIP_BITS(name, gb, bits); \
- if (need_update) { \
- UPDATE_CACHE(name, gb); \
- } \
- \
- nb_bits = -n; \
- \
- index = SHOW_UBITS(name, gb, nb_bits) + level; \
- level = table[index].level; \
- n = table[index].len; \
- } \
- run = table[index].run; \
- SKIP_BITS(name, gb, n); \
- } while (0)
-
-/**
- * Parse a vlc code.
- * @param bits is the number of bits which will be read at once, must be
- * identical to nb_bits in init_vlc()
- * @param max_depth is the number of times bits bits must be read to completely
- * read the longest vlc code
- * = (max_vlc_length + bits - 1) / bits
- */
-static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2],
- int bits, int max_depth)
-{
- int code;
-
- OPEN_READER(re, s);
- UPDATE_CACHE(re, s);
-
- GET_VLC(code, re, s, table, bits, max_depth);
-
- CLOSE_READER(re, s);
-
- return code;
-}
-
-static inline int decode012(GetBitContext *gb)
-{
- int n;
- n = get_bits1(gb);
- if (n == 0)
- return 0;
- else
- return get_bits1(gb) + 1;
-}
-
-static inline int decode210(GetBitContext *gb)
-{
- if (get_bits1(gb))
- return 0;
- else
- return 2 - get_bits1(gb);
-}
-
-static inline int get_bits_left(GetBitContext *gb)
-{
- return gb->size_in_bits - get_bits_count(gb);
-}
-
-//#define TRACE
-
-#ifdef TRACE
-static inline void print_bin(int bits, int n)
-{
- int i;
-
- for (i = n - 1; i >= 0; i--)
- av_log(NULL, AV_LOG_DEBUG, "%d", (bits >> i) & 1);
- for (i = n; i < 24; i++)
- av_log(NULL, AV_LOG_DEBUG, " ");
-}
-
-static inline int get_bits_trace(GetBitContext *s, int n, const char *file,
- const char *func, int line)
-{
- int r = get_bits(s, n);
-
- print_bin(r, n);
- av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d bit @%5d in %s %s:%d\n",
- r, n, r, get_bits_count(s) - n, file, func, line);
-
- return r;
-}
-
-static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2],
- int bits, int max_depth, const char *file,
- const char *func, int line)
-{
- int show = show_bits(s, 24);
- int pos = get_bits_count(s);
- int r = get_vlc2(s, table, bits, max_depth);
- int len = get_bits_count(s) - pos;
- int bits2 = show >> (24 - len);
-
- print_bin(bits2, len);
-
- av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d vlc @%5d in %s %s:%d\n",
- bits2, len, r, pos, file, func, line);
-
- return r;
-}
-
-static inline int get_xbits_trace(GetBitContext *s, int n, const char *file,
- const char *func, int line)
-{
- int show = show_bits(s, n);
- int r = get_xbits(s, n);
-
- print_bin(show, n);
- av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d xbt @%5d in %s %s:%d\n",
- show, n, r, get_bits_count(s) - n, file, func, line);
-
- return r;
-}
-
-#define get_bits(s, n) get_bits_trace(s , n, __FILE__, __PRETTY_FUNCTION__, __LINE__)
-#define get_bits1(s) get_bits_trace(s, 1, __FILE__, __PRETTY_FUNCTION__, __LINE__)
-#define get_xbits(s, n) get_xbits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__)
-
-#define get_vlc(s, vlc) get_vlc_trace(s, (vlc)->table, (vlc)->bits, 3, __FILE__, __PRETTY_FUNCTION__, __LINE__)
-#define get_vlc2(s, tab, bits, max) get_vlc_trace(s, tab, bits, max, __FILE__, __PRETTY_FUNCTION__, __LINE__)
-
-#define tprintf(p, ...) av_log(p, AV_LOG_DEBUG, __VA_ARGS__)
-
-#else //TRACE
-#define tprintf(p, ...) { }
-#endif
-
-#endif /* AVCODEC_GET_BITS_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/golomb.c b/src/thirdparty/ffmpeg/libavcodec/golomb.c
deleted file mode 100644
index 6f09ef25d..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/golomb.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * exp golomb vlc stuff
- * 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
- * @brief
- * exp golomb vlc stuff
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#include "libavutil/common.h"
-
-const uint8_t ff_golomb_vlc_len[512]={
-19,17,15,15,13,13,13,13,11,11,11,11,11,11,11,11,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
-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,
-5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
-5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
-3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
-3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
-3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
-3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
-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,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
-};
-
-const uint8_t ff_ue_golomb_vlc_code[512]={
-32,32,32,32,32,32,32,32,31,32,32,32,32,32,32,32,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,
- 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9,10,10,10,10,11,11,11,11,12,12,12,12,13,13,13,13,14,14,14,14,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 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, 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
-};
-
-const int8_t ff_se_golomb_vlc_code[512]={
- 17, 17, 17, 17, 17, 17, 17, 17, 16, 17, 17, 17, 17, 17, 17, 17, 8, -8, 9, -9, 10,-10, 11,-11, 12,-12, 13,-13, 14,-14, 15,-15,
- 4, 4, 4, 4, -4, -4, -4, -4, 5, 5, 5, 5, -5, -5, -5, -5, 6, 6, 6, 6, -6, -6, -6, -6, 7, 7, 7, 7, -7, -7, -7, -7,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3,
- 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,
- 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, 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,
-};
-
-
-const uint8_t ff_ue_golomb_len[256]={
- 1, 3, 3, 5, 5, 5, 5, 7, 7, 7, 7, 7, 7, 7, 7, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,11,
-11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,13,
-13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,
-13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,15,
-15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
-15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
-15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
-15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,17,
-};
-
-const uint8_t ff_interleaved_golomb_vlc_len[256]={
-9,9,7,7,9,9,7,7,5,5,5,5,5,5,5,5,
-9,9,7,7,9,9,7,7,5,5,5,5,5,5,5,5,
-3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
-3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
-9,9,7,7,9,9,7,7,5,5,5,5,5,5,5,5,
-9,9,7,7,9,9,7,7,5,5,5,5,5,5,5,5,
-3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
-3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
-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,
-};
-
-const uint8_t ff_interleaved_ue_golomb_vlc_code[256]={
- 15,16,7, 7, 17,18,8, 8, 3, 3, 3, 3, 3, 3, 3, 3,
- 19,20,9, 9, 21,22,10,10,4, 4, 4, 4, 4, 4, 4, 4,
- 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,
- 23,24,11,11,25,26,12,12,5, 5, 5, 5, 5, 5, 5, 5,
- 27,28,13,13,29,30,14,14,6, 6, 6, 6, 6, 6, 6, 6,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 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,
-};
-
-const int8_t ff_interleaved_se_golomb_vlc_code[256]={
- 8, -8, 4, 4, 9, -9, -4, -4, 2, 2, 2, 2, 2, 2, 2, 2,
- 10,-10, 5, 5, 11,-11, -5, -5, -2, -2, -2, -2, -2, -2, -2, -2,
- 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,
- 12,-12, 6, 6, 13,-13, -6, -6, 3, 3, 3, 3, 3, 3, 3, 3,
- 14,-14, 7, 7, 15,-15, -7, -7, -3, -3, -3, -3, -3, -3, -3, -3,
- -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,
- 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,
-};
-
-const uint8_t ff_interleaved_dirac_golomb_vlc_code[256]={
-0, 1, 0, 0, 2, 3, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
-4, 5, 2, 2, 6, 7, 3, 3, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-8, 9, 4, 4, 10,11,5, 5, 2, 2, 2, 2, 2, 2, 2, 2,
-12,13,6, 6, 14,15,7, 7, 3, 3, 3, 3, 3, 3, 3, 3,
-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,
-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,};
diff --git a/src/thirdparty/ffmpeg/libavcodec/golomb.h b/src/thirdparty/ffmpeg/libavcodec/golomb.h
deleted file mode 100644
index 55ed8ff8e..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/golomb.h
+++ /dev/null
@@ -1,557 +0,0 @@
-/*
- * exp golomb vlc stuff
- * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
- * Copyright (c) 2004 Alex Beregszaszi
- *
- * 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
- * @brief
- * exp golomb vlc stuff
- * @author Michael Niedermayer <michaelni@gmx.at> and Alex Beregszaszi
- */
-
-#ifndef AVCODEC_GOLOMB_H
-#define AVCODEC_GOLOMB_H
-
-#include <stdint.h>
-#include "get_bits.h"
-#include "put_bits.h"
-
-#define INVALID_VLC 0x80000000
-
-extern const uint8_t ff_golomb_vlc_len[512];
-extern const uint8_t ff_ue_golomb_vlc_code[512];
-extern const int8_t ff_se_golomb_vlc_code[512];
-extern const uint8_t ff_ue_golomb_len[256];
-
-extern const uint8_t ff_interleaved_golomb_vlc_len[256];
-extern const uint8_t ff_interleaved_ue_golomb_vlc_code[256];
-extern const int8_t ff_interleaved_se_golomb_vlc_code[256];
-extern const uint8_t ff_interleaved_dirac_golomb_vlc_code[256];
-
-
- /**
- * read unsigned exp golomb code.
- */
-static inline int get_ue_golomb(GetBitContext *gb){
- unsigned int buf;
- int log;
-
- OPEN_READER(re, gb);
- UPDATE_CACHE(re, gb);
- buf=GET_CACHE(re, gb);
-
- if(buf >= (1<<27)){
- buf >>= 32 - 9;
- LAST_SKIP_BITS(re, gb, ff_golomb_vlc_len[buf]);
- CLOSE_READER(re, gb);
-
- return ff_ue_golomb_vlc_code[buf];
- }else{
- log= 2*av_log2(buf) - 31;
- LAST_SKIP_BITS(re, gb, 32 - log);
- CLOSE_READER(re, gb);
- if (CONFIG_FTRAPV && log < 0) {
- av_log(0, AV_LOG_ERROR, "Invalid UE golomb code\n");
- return AVERROR_INVALIDDATA;
- }
- buf>>= log;
- buf--;
-
- return buf;
- }
-}
-
-/**
- * Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1.
- */
-static inline unsigned get_ue_golomb_long(GetBitContext *gb)
-{
- unsigned buf, log;
-
- buf = show_bits_long(gb, 32);
- log = 31 - av_log2(buf);
- skip_bits_long(gb, log);
-
- return get_bits_long(gb, log + 1) - 1;
-}
-
- /**
- * read unsigned exp golomb code, constraint to a max of 31.
- * the return value is undefined if the stored value exceeds 31.
- */
-static inline int get_ue_golomb_31(GetBitContext *gb){
- unsigned int buf;
-
- OPEN_READER(re, gb);
- UPDATE_CACHE(re, gb);
- buf=GET_CACHE(re, gb);
-
- buf >>= 32 - 9;
- LAST_SKIP_BITS(re, gb, ff_golomb_vlc_len[buf]);
- CLOSE_READER(re, gb);
-
- return ff_ue_golomb_vlc_code[buf];
-}
-
-static inline unsigned svq3_get_ue_golomb(GetBitContext *gb)
-{
- uint32_t buf;
-
- OPEN_READER(re, gb);
- UPDATE_CACHE(re, gb);
- buf=GET_CACHE(re, gb);
-
- if(buf&0xAA800000){
- buf >>= 32 - 8;
- LAST_SKIP_BITS(re, gb, ff_interleaved_golomb_vlc_len[buf]);
- CLOSE_READER(re, gb);
-
- return ff_interleaved_ue_golomb_vlc_code[buf];
- }else{
- unsigned ret = 1;
-
- do {
- buf >>= 32 - 8;
- LAST_SKIP_BITS(re, gb, FFMIN(ff_interleaved_golomb_vlc_len[buf], 8));
-
- if (ff_interleaved_golomb_vlc_len[buf] != 9){
- ret <<= (ff_interleaved_golomb_vlc_len[buf] - 1) >> 1;
- ret |= ff_interleaved_dirac_golomb_vlc_code[buf];
- break;
- }
- ret = (ret << 4) | ff_interleaved_dirac_golomb_vlc_code[buf];
- UPDATE_CACHE(re, gb);
- buf = GET_CACHE(re, gb);
- } while (ret<0x8000000U && HAVE_BITS_REMAINING(re, gb));
-
- CLOSE_READER(re, gb);
- return ret - 1;
- }
-}
-
-/**
- * read unsigned truncated exp golomb code.
- */
-static inline int get_te0_golomb(GetBitContext *gb, int range){
- av_assert2(range >= 1);
-
- if(range==1) return 0;
- else if(range==2) return get_bits1(gb)^1;
- else return get_ue_golomb(gb);
-}
-
-/**
- * read unsigned truncated exp golomb code.
- */
-static inline int get_te_golomb(GetBitContext *gb, int range){
- av_assert2(range >= 1);
-
- if(range==2) return get_bits1(gb)^1;
- else return get_ue_golomb(gb);
-}
-
-
-/**
- * read signed exp golomb code.
- */
-static inline int get_se_golomb(GetBitContext *gb){
- unsigned int buf;
- int log;
-
- OPEN_READER(re, gb);
- UPDATE_CACHE(re, gb);
- buf=GET_CACHE(re, gb);
-
- if(buf >= (1<<27)){
- buf >>= 32 - 9;
- LAST_SKIP_BITS(re, gb, ff_golomb_vlc_len[buf]);
- CLOSE_READER(re, gb);
-
- return ff_se_golomb_vlc_code[buf];
- }else{
- log = av_log2(buf);
- LAST_SKIP_BITS(re, gb, 31 - log);
- UPDATE_CACHE(re, gb);
- buf = GET_CACHE(re, gb);
-
- buf>>= log;
-
- LAST_SKIP_BITS(re, gb, 32 - log);
- CLOSE_READER(re, gb);
-
- if(buf&1) buf= -(buf>>1);
- else buf= (buf>>1);
-
- return buf;
- }
-}
-
-static inline int svq3_get_se_golomb(GetBitContext *gb){
- unsigned int buf;
- int log;
-
- OPEN_READER(re, gb);
- UPDATE_CACHE(re, gb);
- buf=GET_CACHE(re, gb);
-
- if(buf&0xAA800000){
- buf >>= 32 - 8;
- LAST_SKIP_BITS(re, gb, ff_interleaved_golomb_vlc_len[buf]);
- CLOSE_READER(re, gb);
-
- return ff_interleaved_se_golomb_vlc_code[buf];
- }else{
- LAST_SKIP_BITS(re, gb, 8);
- UPDATE_CACHE(re, gb);
- buf |= 1 | (GET_CACHE(re, gb) >> 8);
-
- if((buf & 0xAAAAAAAA) == 0)
- return INVALID_VLC;
-
- for(log=31; (buf & 0x80000000) == 0; log--){
- buf = (buf << 2) - ((buf << log) >> (log - 1)) + (buf >> 30);
- }
-
- LAST_SKIP_BITS(re, gb, 63 - 2*log - 8);
- CLOSE_READER(re, gb);
-
- return (signed) (((((buf << log) >> log) - 1) ^ -(buf & 0x1)) + 1) >> 1;
- }
-}
-
-static inline int dirac_get_se_golomb(GetBitContext *gb){
- uint32_t buf;
- uint32_t ret;
-
- ret = svq3_get_ue_golomb(gb);
-
- if (ret) {
- OPEN_READER(re, gb);
- UPDATE_CACHE(re, gb);
- buf = SHOW_SBITS(re, gb, 1);
- LAST_SKIP_BITS(re, gb, 1);
- ret = (ret ^ buf) - buf;
- CLOSE_READER(re, gb);
- }
-
- return ret;
-}
-
-/**
- * read unsigned golomb rice code (ffv1).
- */
-static inline int get_ur_golomb(GetBitContext *gb, int k, int limit, int esc_len){
- unsigned int buf;
- int log;
-
- OPEN_READER(re, gb);
- UPDATE_CACHE(re, gb);
- buf=GET_CACHE(re, gb);
-
- log= av_log2(buf);
-
- if(log > 31-limit){
- buf >>= log - k;
- buf += (30-log)<<k;
- LAST_SKIP_BITS(re, gb, 32 + k - log);
- CLOSE_READER(re, gb);
-
- return buf;
- }else{
- LAST_SKIP_BITS(re, gb, limit);
- UPDATE_CACHE(re, gb);
-
- buf = SHOW_UBITS(re, gb, esc_len);
-
- LAST_SKIP_BITS(re, gb, esc_len);
- CLOSE_READER(re, gb);
-
- return buf + limit - 1;
- }
-}
-
-/**
- * read unsigned golomb rice code (jpegls).
- */
-static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, int esc_len){
- unsigned int buf;
- int log;
-
- OPEN_READER(re, gb);
- UPDATE_CACHE(re, gb);
- buf=GET_CACHE(re, gb);
-
- log= av_log2(buf);
-
- if(log - k >= 32-MIN_CACHE_BITS+(MIN_CACHE_BITS==32) && 32-log < limit){
- buf >>= log - k;
- buf += (30-log)<<k;
- LAST_SKIP_BITS(re, gb, 32 + k - log);
- CLOSE_READER(re, gb);
-
- return buf;
- }else{
- int i;
- for (i = 0; i < limit && SHOW_UBITS(re, gb, 1) == 0; i++) {
- if (gb->size_in_bits <= re_index)
- return -1;
- LAST_SKIP_BITS(re, gb, 1);
- UPDATE_CACHE(re, gb);
- }
- SKIP_BITS(re, gb, 1);
-
- if(i < limit - 1){
- if(k){
- buf = SHOW_UBITS(re, gb, k);
- LAST_SKIP_BITS(re, gb, k);
- }else{
- buf=0;
- }
-
- CLOSE_READER(re, gb);
- return buf + (i<<k);
- }else if(i == limit - 1){
- buf = SHOW_UBITS(re, gb, esc_len);
- LAST_SKIP_BITS(re, gb, esc_len);
- CLOSE_READER(re, gb);
-
- return buf + 1;
- }else
- return -1;
- }
-}
-
-/**
- * read signed golomb rice code (ffv1).
- */
-static inline int get_sr_golomb(GetBitContext *gb, int k, int limit, int esc_len){
- int v= get_ur_golomb(gb, k, limit, esc_len);
-
- v++;
- if (v&1) return v>>1;
- else return -(v>>1);
-
-// return (v>>1) ^ -(v&1);
-}
-
-/**
- * read signed golomb rice code (flac).
- */
-static inline int get_sr_golomb_flac(GetBitContext *gb, int k, int limit, int esc_len){
- int v= get_ur_golomb_jpegls(gb, k, limit, esc_len);
- return (v>>1) ^ -(v&1);
-}
-
-/**
- * read unsigned golomb rice code (shorten).
- */
-static inline unsigned int get_ur_golomb_shorten(GetBitContext *gb, int k){
- return get_ur_golomb_jpegls(gb, k, INT_MAX, 0);
-}
-
-/**
- * read signed golomb rice code (shorten).
- */
-static inline int get_sr_golomb_shorten(GetBitContext* gb, int k)
-{
- int uvar = get_ur_golomb_jpegls(gb, k + 1, INT_MAX, 0);
- if (uvar & 1)
- return ~(uvar >> 1);
- else
- return uvar >> 1;
-}
-
-
-
-#ifdef TRACE
-
-static inline int get_ue(GetBitContext *s, const char *file, const char *func,
- int line)
-{
- int show= show_bits(s, 24);
- int pos= get_bits_count(s);
- int i= get_ue_golomb(s);
- int len= get_bits_count(s) - pos;
- int bits= show>>(24-len);
-
- print_bin(bits, len);
-
- av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d ue @%5d in %s %s:%d\n", bits, len, i, pos, file, func, line);
-
- return i;
-}
-
-static inline int get_se(GetBitContext *s, const char *file, const char *func,
- int line)
-{
- int show= show_bits(s, 24);
- int pos= get_bits_count(s);
- int i= get_se_golomb(s);
- int len= get_bits_count(s) - pos;
- int bits= show>>(24-len);
-
- print_bin(bits, len);
-
- av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d se @%5d in %s %s:%d\n", bits, len, i, pos, file, func, line);
-
- return i;
-}
-
-static inline int get_te(GetBitContext *s, int r, char *file, const char *func, int line){
- int show= show_bits(s, 24);
- int pos= get_bits_count(s);
- int i= get_te0_golomb(s, r);
- int len= get_bits_count(s) - pos;
- int bits= show>>(24-len);
-
- print_bin(bits, len);
-
- av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d te @%5d in %s %s:%d\n", bits, len, i, pos, file, func, line);
-
- return i;
-}
-
-#define get_ue_golomb(a) get_ue(a, __FILE__, __PRETTY_FUNCTION__, __LINE__)
-#define get_se_golomb(a) get_se(a, __FILE__, __PRETTY_FUNCTION__, __LINE__)
-#define get_te_golomb(a, r) get_te(a, r, __FILE__, __PRETTY_FUNCTION__, __LINE__)
-#define get_te0_golomb(a, r) get_te(a, r, __FILE__, __PRETTY_FUNCTION__, __LINE__)
-
-#endif
-
-/**
- * write unsigned exp golomb code.
- */
-static inline void set_ue_golomb(PutBitContext *pb, int i){
- int e;
-
- av_assert2(i>=0);
-
-#if 0
- if(i=0){
- put_bits(pb, 1, 1);
- return;
- }
-#endif
- if(i<256)
- put_bits(pb, ff_ue_golomb_len[i], i+1);
- else{
- e= av_log2(i+1);
-
- put_bits(pb, 2*e+1, i+1);
- }
-}
-
-/**
- * write truncated unsigned exp golomb code.
- */
-static inline void set_te_golomb(PutBitContext *pb, int i, int range){
- av_assert2(range >= 1);
- av_assert2(i<=range);
-
- if(range==2) put_bits(pb, 1, i^1);
- else set_ue_golomb(pb, i);
-}
-
-/**
- * write signed exp golomb code. 16 bits at most.
- */
-static inline void set_se_golomb(PutBitContext *pb, int i){
-#if 0
- if(i<=0) i= -2*i;
- else i= 2*i-1;
-#elif 1
- i= 2*i-1;
- if(i<0) i^= -1; //FIXME check if gcc does the right thing
-#else
- i= 2*i-1;
- i^= (i>>31);
-#endif
- set_ue_golomb(pb, i);
-}
-
-/**
- * write unsigned golomb rice code (ffv1).
- */
-static inline void set_ur_golomb(PutBitContext *pb, int i, int k, int limit, int esc_len){
- int e;
-
- av_assert2(i>=0);
-
- e= i>>k;
- if(e<limit){
- put_bits(pb, e + k + 1, (1<<k) + (i&((1<<k)-1)));
- }else{
- put_bits(pb, limit + esc_len, i - limit + 1);
- }
-}
-
-/**
- * write unsigned golomb rice code (jpegls).
- */
-static inline void set_ur_golomb_jpegls(PutBitContext *pb, int i, int k, int limit, int esc_len){
- int e;
-
- av_assert2(i>=0);
-
- e= (i>>k) + 1;
- if(e<limit){
- while(e > 31) {
- put_bits(pb, 31, 0);
- e -= 31;
- }
- put_bits(pb, e, 1);
- if(k)
- put_sbits(pb, k, i);
- }else{
- while(limit > 31) {
- put_bits(pb, 31, 0);
- limit -= 31;
- }
- put_bits(pb, limit , 1);
- put_bits(pb, esc_len, i - 1);
- }
-}
-
-/**
- * write signed golomb rice code (ffv1).
- */
-static inline void set_sr_golomb(PutBitContext *pb, int i, int k, int limit, int esc_len){
- int v;
-
- v = -2*i-1;
- v ^= (v>>31);
-
- set_ur_golomb(pb, v, k, limit, esc_len);
-}
-
-/**
- * write signed golomb rice code (flac).
- */
-static inline void set_sr_golomb_flac(PutBitContext *pb, int i, int k, int limit, int esc_len){
- int v;
-
- v = -2*i-1;
- v ^= (v>>31);
-
- set_ur_golomb_jpegls(pb, v, k, limit, esc_len);
-}
-
-#endif /* AVCODEC_GOLOMB_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/h261.c b/src/thirdparty/ffmpeg/libavcodec/h261.c
deleted file mode 100644
index 5441a34ce..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h261.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * H261 common code
- * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
- * Copyright (c) 2004 Maarten Daniels
- *
- * 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
- * h261codec.
- */
-
-#include "dsputil.h"
-#include "avcodec.h"
-#include "h261.h"
-
-#define IS_FIL(a) ((a)&MB_TYPE_H261_FIL)
-
-uint8_t ff_h261_rl_table_store[2][2*MAX_RUN + MAX_LEVEL + 3];
-
-void ff_h261_loop_filter(MpegEncContext *s){
- H261Context * h= (H261Context*)s;
- const int linesize = s->linesize;
- const int uvlinesize= s->uvlinesize;
- uint8_t *dest_y = s->dest[0];
- uint8_t *dest_cb= s->dest[1];
- uint8_t *dest_cr= s->dest[2];
-
- if(!(IS_FIL (h->mtype)))
- return;
-
- s->dsp.h261_loop_filter(dest_y , linesize);
- s->dsp.h261_loop_filter(dest_y + 8, linesize);
- s->dsp.h261_loop_filter(dest_y + 8 * linesize , linesize);
- s->dsp.h261_loop_filter(dest_y + 8 * linesize + 8, linesize);
- s->dsp.h261_loop_filter(dest_cb, uvlinesize);
- s->dsp.h261_loop_filter(dest_cr, uvlinesize);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/h261.h b/src/thirdparty/ffmpeg/libavcodec/h261.h
deleted file mode 100644
index bd351af6a..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h261.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * H261 decoder
- * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
- * Copyright (c) 2004 Maarten Daniels
- *
- * 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
- * h261codec.
- */
-
-#ifndef AVCODEC_H261_H
-#define AVCODEC_H261_H
-
-#include "mpegvideo.h"
-
-/**
- * H261Context
- */
-typedef struct H261Context{
- MpegEncContext s;
-
- int current_mba;
- int previous_mba;
- int mba_diff;
- int mtype;
- int current_mv_x;
- int current_mv_y;
- int gob_number;
- int gob_start_code_skipped; // 1 if gob start code is already read before gob header is read
-}H261Context;
-
-#define MB_TYPE_H261_FIL 0x800000
-
-#endif /* AVCODEC_H261_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/h261data.h b/src/thirdparty/ffmpeg/libavcodec/h261data.h
deleted file mode 100644
index 325b4b773..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h261data.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
- * copyright (c) 2004 Maarten Daniels
- *
- * 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.261 tables.
- */
-
-#ifndef AVCODEC_H261DATA_H
-#define AVCODEC_H261DATA_H
-
-#include <stdint.h>
-#include "h261.h"
-
-extern const uint8_t ff_h261_mba_code[35];
-extern const uint8_t ff_h261_mba_bits[35];
-extern const uint8_t ff_h261_mtype_code[10];
-extern const uint8_t ff_h261_mtype_bits[10];
-extern const int ff_h261_mtype_map[10];
-extern const uint8_t ff_h261_mv_tab[17][2];
-extern const uint8_t ff_h261_cbp_tab[63][2];
-extern RLTable ff_h261_rl_tcoeff;
-
-#endif /* AVCODEC_H261DATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/h263.c b/src/thirdparty/ffmpeg/libavcodec/h263.c
deleted file mode 100644
index 24271f301..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h263.c
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
- * H263/MPEG4 backend for encoder and decoder
- * Copyright (c) 2000,2001 Fabrice Bellard
- * H263+ support.
- * Copyright (c) 2001 Juan J. Sierralta P
- * Copyright (c) 2002-2004 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
- * h263/mpeg4 codec.
- */
-
-//#define DEBUG
-#include <limits.h>
-
-#include "dsputil.h"
-#include "avcodec.h"
-#include "mpegvideo.h"
-#include "h263.h"
-#include "h263data.h"
-#include "mathops.h"
-#include "unary.h"
-#include "flv.h"
-#include "mpeg4video.h"
-
-//#undef NDEBUG
-//#include <assert.h>
-
-uint8_t ff_h263_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3];
-
-
-void ff_h263_update_motion_val(MpegEncContext * s){
- const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
- //FIXME a lot of that is only needed for !low_delay
- const int wrap = s->b8_stride;
- const int xy = s->block_index[0];
-
- s->current_picture.f.mbskip_table[mb_xy] = s->mb_skipped;
-
- if(s->mv_type != MV_TYPE_8X8){
- int motion_x, motion_y;
- if (s->mb_intra) {
- motion_x = 0;
- motion_y = 0;
- } else if (s->mv_type == MV_TYPE_16X16) {
- motion_x = s->mv[0][0][0];
- motion_y = s->mv[0][0][1];
- } else /*if (s->mv_type == MV_TYPE_FIELD)*/ {
- int i;
- motion_x = s->mv[0][0][0] + s->mv[0][1][0];
- motion_y = s->mv[0][0][1] + s->mv[0][1][1];
- motion_x = (motion_x>>1) | (motion_x&1);
- for(i=0; i<2; i++){
- s->p_field_mv_table[i][0][mb_xy][0]= s->mv[0][i][0];
- s->p_field_mv_table[i][0][mb_xy][1]= s->mv[0][i][1];
- }
- s->current_picture.f.ref_index[0][4*mb_xy ] =
- s->current_picture.f.ref_index[0][4*mb_xy + 1] = s->field_select[0][0];
- s->current_picture.f.ref_index[0][4*mb_xy + 2] =
- s->current_picture.f.ref_index[0][4*mb_xy + 3] = s->field_select[0][1];
- }
-
- /* no update if 8X8 because it has been done during parsing */
- s->current_picture.f.motion_val[0][xy][0] = motion_x;
- s->current_picture.f.motion_val[0][xy][1] = motion_y;
- s->current_picture.f.motion_val[0][xy + 1][0] = motion_x;
- s->current_picture.f.motion_val[0][xy + 1][1] = motion_y;
- s->current_picture.f.motion_val[0][xy + wrap][0] = motion_x;
- s->current_picture.f.motion_val[0][xy + wrap][1] = motion_y;
- s->current_picture.f.motion_val[0][xy + 1 + wrap][0] = motion_x;
- s->current_picture.f.motion_val[0][xy + 1 + wrap][1] = motion_y;
- }
-
- if(s->encoding){ //FIXME encoding MUST be cleaned up
- if (s->mv_type == MV_TYPE_8X8)
- s->current_picture.f.mb_type[mb_xy] = MB_TYPE_L0 | MB_TYPE_8x8;
- else if(s->mb_intra)
- s->current_picture.f.mb_type[mb_xy] = MB_TYPE_INTRA;
- else
- s->current_picture.f.mb_type[mb_xy] = MB_TYPE_L0 | MB_TYPE_16x16;
- }
-}
-
-int ff_h263_pred_dc(MpegEncContext * s, int n, int16_t **dc_val_ptr)
-{
- int x, y, wrap, a, c, pred_dc;
- int16_t *dc_val;
-
- /* find prediction */
- if (n < 4) {
- x = 2 * s->mb_x + (n & 1);
- y = 2 * s->mb_y + ((n & 2) >> 1);
- wrap = s->b8_stride;
- dc_val = s->dc_val[0];
- } else {
- x = s->mb_x;
- y = s->mb_y;
- wrap = s->mb_stride;
- dc_val = s->dc_val[n - 4 + 1];
- }
- /* B C
- * A X
- */
- a = dc_val[(x - 1) + (y) * wrap];
- c = dc_val[(x) + (y - 1) * wrap];
-
- /* No prediction outside GOB boundary */
- if(s->first_slice_line && n!=3){
- if(n!=2) c= 1024;
- if(n!=1 && s->mb_x == s->resync_mb_x) a= 1024;
- }
- /* just DC prediction */
- if (a != 1024 && c != 1024)
- pred_dc = (a + c) >> 1;
- else if (a != 1024)
- pred_dc = a;
- else
- pred_dc = c;
-
- /* we assume pred is positive */
- *dc_val_ptr = &dc_val[x + y * wrap];
- return pred_dc;
-}
-
-void ff_h263_loop_filter(MpegEncContext * s){
- int qp_c;
- const int linesize = s->linesize;
- const int uvlinesize= s->uvlinesize;
- const int xy = s->mb_y * s->mb_stride + s->mb_x;
- uint8_t *dest_y = s->dest[0];
- uint8_t *dest_cb= s->dest[1];
- uint8_t *dest_cr= s->dest[2];
-
-// if(s->pict_type==AV_PICTURE_TYPE_B && !s->readable) return;
-
- /*
- Diag Top
- Left Center
- */
- if (!IS_SKIP(s->current_picture.f.mb_type[xy])) {
- qp_c= s->qscale;
- s->dsp.h263_v_loop_filter(dest_y+8*linesize , linesize, qp_c);
- s->dsp.h263_v_loop_filter(dest_y+8*linesize+8, linesize, qp_c);
- }else
- qp_c= 0;
-
- if(s->mb_y){
- int qp_dt, qp_tt, qp_tc;
-
- if (IS_SKIP(s->current_picture.f.mb_type[xy - s->mb_stride]))
- qp_tt=0;
- else
- qp_tt = s->current_picture.f.qscale_table[xy - s->mb_stride];
-
- if(qp_c)
- qp_tc= qp_c;
- else
- qp_tc= qp_tt;
-
- if(qp_tc){
- const int chroma_qp= s->chroma_qscale_table[qp_tc];
- s->dsp.h263_v_loop_filter(dest_y , linesize, qp_tc);
- s->dsp.h263_v_loop_filter(dest_y+8, linesize, qp_tc);
-
- s->dsp.h263_v_loop_filter(dest_cb , uvlinesize, chroma_qp);
- s->dsp.h263_v_loop_filter(dest_cr , uvlinesize, chroma_qp);
- }
-
- if(qp_tt)
- s->dsp.h263_h_loop_filter(dest_y-8*linesize+8 , linesize, qp_tt);
-
- if(s->mb_x){
- if (qp_tt || IS_SKIP(s->current_picture.f.mb_type[xy - 1 - s->mb_stride]))
- qp_dt= qp_tt;
- else
- qp_dt = s->current_picture.f.qscale_table[xy - 1 - s->mb_stride];
-
- if(qp_dt){
- const int chroma_qp= s->chroma_qscale_table[qp_dt];
- s->dsp.h263_h_loop_filter(dest_y -8*linesize , linesize, qp_dt);
- s->dsp.h263_h_loop_filter(dest_cb-8*uvlinesize, uvlinesize, chroma_qp);
- s->dsp.h263_h_loop_filter(dest_cr-8*uvlinesize, uvlinesize, chroma_qp);
- }
- }
- }
-
- if(qp_c){
- s->dsp.h263_h_loop_filter(dest_y +8, linesize, qp_c);
- if(s->mb_y + 1 == s->mb_height)
- s->dsp.h263_h_loop_filter(dest_y+8*linesize+8, linesize, qp_c);
- }
-
- if(s->mb_x){
- int qp_lc;
- if (qp_c || IS_SKIP(s->current_picture.f.mb_type[xy - 1]))
- qp_lc= qp_c;
- else
- qp_lc = s->current_picture.f.qscale_table[xy - 1];
-
- if(qp_lc){
- s->dsp.h263_h_loop_filter(dest_y, linesize, qp_lc);
- if(s->mb_y + 1 == s->mb_height){
- const int chroma_qp= s->chroma_qscale_table[qp_lc];
- s->dsp.h263_h_loop_filter(dest_y +8* linesize, linesize, qp_lc);
- s->dsp.h263_h_loop_filter(dest_cb , uvlinesize, chroma_qp);
- s->dsp.h263_h_loop_filter(dest_cr , uvlinesize, chroma_qp);
- }
- }
- }
-}
-
-void ff_h263_pred_acdc(MpegEncContext * s, int16_t *block, int n)
-{
- int x, y, wrap, a, c, pred_dc, scale, i;
- int16_t *dc_val, *ac_val, *ac_val1;
-
- /* find prediction */
- if (n < 4) {
- x = 2 * s->mb_x + (n & 1);
- y = 2 * s->mb_y + (n>> 1);
- wrap = s->b8_stride;
- dc_val = s->dc_val[0];
- ac_val = s->ac_val[0][0];
- scale = s->y_dc_scale;
- } else {
- x = s->mb_x;
- y = s->mb_y;
- wrap = s->mb_stride;
- dc_val = s->dc_val[n - 4 + 1];
- ac_val = s->ac_val[n - 4 + 1][0];
- scale = s->c_dc_scale;
- }
-
- ac_val += ((y) * wrap + (x)) * 16;
- ac_val1 = ac_val;
-
- /* B C
- * A X
- */
- a = dc_val[(x - 1) + (y) * wrap];
- c = dc_val[(x) + (y - 1) * wrap];
-
- /* No prediction outside GOB boundary */
- if(s->first_slice_line && n!=3){
- if(n!=2) c= 1024;
- if(n!=1 && s->mb_x == s->resync_mb_x) a= 1024;
- }
-
- if (s->ac_pred) {
- pred_dc = 1024;
- if (s->h263_aic_dir) {
- /* left prediction */
- if (a != 1024) {
- ac_val -= 16;
- for(i=1;i<8;i++) {
- block[s->dsp.idct_permutation[i<<3]] += ac_val[i];
- }
- pred_dc = a;
- }
- } else {
- /* top prediction */
- if (c != 1024) {
- ac_val -= 16 * wrap;
- for(i=1;i<8;i++) {
- block[s->dsp.idct_permutation[i ]] += ac_val[i + 8];
- }
- pred_dc = c;
- }
- }
- } else {
- /* just DC prediction */
- if (a != 1024 && c != 1024)
- pred_dc = (a + c) >> 1;
- else if (a != 1024)
- pred_dc = a;
- else
- pred_dc = c;
- }
-
- /* we assume pred is positive */
- block[0]=block[0]*scale + pred_dc;
-
- if (block[0] < 0)
- block[0] = 0;
- else
- block[0] |= 1;
-
- /* Update AC/DC tables */
- dc_val[(x) + (y) * wrap] = block[0];
-
- /* left copy */
- for(i=1;i<8;i++)
- ac_val1[i ] = block[s->dsp.idct_permutation[i<<3]];
- /* top copy */
- for(i=1;i<8;i++)
- ac_val1[8 + i] = block[s->dsp.idct_permutation[i ]];
-}
-
-int16_t *ff_h263_pred_motion(MpegEncContext * s, int block, int dir,
- int *px, int *py)
-{
- int wrap;
- int16_t *A, *B, *C, (*mot_val)[2];
- static const int off[4]= {2, 1, 1, -1};
-
- wrap = s->b8_stride;
- mot_val = s->current_picture.f.motion_val[dir] + s->block_index[block];
-
- A = mot_val[ - 1];
- /* special case for first (slice) line */
- if (s->first_slice_line && block<3) {
- // we can't just change some MVs to simulate that as we need them for the B frames (and ME)
- // and if we ever support non rectangular objects than we need to do a few ifs here anyway :(
- if(block==0){ //most common case
- if(s->mb_x == s->resync_mb_x){ //rare
- *px= *py = 0;
- }else if(s->mb_x + 1 == s->resync_mb_x && s->h263_pred){ //rare
- C = mot_val[off[block] - wrap];
- if(s->mb_x==0){
- *px = C[0];
- *py = C[1];
- }else{
- *px = mid_pred(A[0], 0, C[0]);
- *py = mid_pred(A[1], 0, C[1]);
- }
- }else{
- *px = A[0];
- *py = A[1];
- }
- }else if(block==1){
- if(s->mb_x + 1 == s->resync_mb_x && s->h263_pred){ //rare
- C = mot_val[off[block] - wrap];
- *px = mid_pred(A[0], 0, C[0]);
- *py = mid_pred(A[1], 0, C[1]);
- }else{
- *px = A[0];
- *py = A[1];
- }
- }else{ /* block==2*/
- B = mot_val[ - wrap];
- C = mot_val[off[block] - wrap];
- if(s->mb_x == s->resync_mb_x) //rare
- A[0]=A[1]=0;
-
- *px = mid_pred(A[0], B[0], C[0]);
- *py = mid_pred(A[1], B[1], C[1]);
- }
- } else {
- B = mot_val[ - wrap];
- C = mot_val[off[block] - wrap];
- *px = mid_pred(A[0], B[0], C[0]);
- *py = mid_pred(A[1], B[1], C[1]);
- }
- return *mot_val;
-}
-
-
-/**
- * Get the GOB height based on picture height.
- */
-int ff_h263_get_gob_height(MpegEncContext *s){
- if (s->height <= 400)
- return 1;
- else if (s->height <= 800)
- return 2;
- else
- return 4;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/h263.h b/src/thirdparty/ffmpeg/libavcodec/h263.h
deleted file mode 100644
index 11f342976..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h263.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * H263 internal header
- *
- * 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_H263_H
-#define AVCODEC_H263_H
-
-#include <stdint.h>
-#include "libavutil/rational.h"
-#include "get_bits.h"
-#include "mpegvideo.h"
-#include "rl.h"
-
-// The defines below define the number of bits that are read at once for
-// reading vlc values. Changing these may improve speed and data cache needs
-// be aware though that decreasing them may need the number of stages that is
-// passed to get_vlc* to be increased.
-#define INTRA_MCBPC_VLC_BITS 6
-#define INTER_MCBPC_VLC_BITS 7
-#define CBPY_VLC_BITS 6
-#define TEX_VLC_BITS 9
-
-extern const AVRational ff_h263_pixel_aspect[16];
-extern const uint8_t ff_h263_cbpy_tab[16][2];
-
-extern const uint8_t ff_cbpc_b_tab[4][2];
-
-extern const uint8_t ff_mvtab[33][2];
-
-extern const uint8_t ff_h263_intra_MCBPC_code[9];
-extern const uint8_t ff_h263_intra_MCBPC_bits[9];
-
-extern const uint8_t ff_h263_inter_MCBPC_code[28];
-extern const uint8_t ff_h263_inter_MCBPC_bits[28];
-extern const uint8_t ff_h263_mbtype_b_tab[15][2];
-
-extern VLC ff_h263_intra_MCBPC_vlc;
-extern VLC ff_h263_inter_MCBPC_vlc;
-extern VLC ff_h263_cbpy_vlc;
-
-extern RLTable ff_h263_rl_inter;
-
-extern RLTable ff_rl_intra_aic;
-
-extern const uint16_t ff_h263_format[8][2];
-extern const uint8_t ff_modified_quant_tab[2][32];
-extern const uint16_t ff_mba_max[6];
-extern const uint8_t ff_mba_length[7];
-
-extern uint8_t ff_h263_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3];
-
-
-int ff_h263_decode_motion(MpegEncContext * s, int pred, int f_code);
-av_const int ff_h263_aspect_to_info(AVRational aspect);
-int ff_h263_decode_init(AVCodecContext *avctx);
-int ff_h263_decode_frame(AVCodecContext *avctx,
- void *data, int *got_frame,
- AVPacket *avpkt);
-int ff_h263_decode_end(AVCodecContext *avctx);
-void ff_h263_encode_mb(MpegEncContext *s,
- int16_t block[6][64],
- int motion_x, int motion_y);
-void ff_h263_encode_picture_header(MpegEncContext *s, int picture_number);
-void ff_h263_encode_gob_header(MpegEncContext * s, int mb_line);
-int16_t *ff_h263_pred_motion(MpegEncContext * s, int block, int dir,
- int *px, int *py);
-void ff_h263_encode_init(MpegEncContext *s);
-void ff_h263_decode_init_vlc(void);
-int ff_h263_decode_picture_header(MpegEncContext *s);
-int ff_h263_decode_gob_header(MpegEncContext *s);
-void ff_h263_update_motion_val(MpegEncContext * s);
-void ff_h263_loop_filter(MpegEncContext * s);
-int ff_h263_decode_mba(MpegEncContext *s);
-void ff_h263_encode_mba(MpegEncContext *s);
-void ff_init_qscale_tab(MpegEncContext *s);
-int ff_h263_pred_dc(MpegEncContext * s, int n, int16_t **dc_val_ptr);
-void ff_h263_pred_acdc(MpegEncContext * s, int16_t *block, int n);
-
-
-/**
- * Print picture info if FF_DEBUG_PICT_INFO is set.
- */
-void ff_h263_show_pict_info(MpegEncContext *s);
-
-int ff_intel_h263_decode_picture_header(MpegEncContext *s);
-int ff_h263_decode_mb(MpegEncContext *s,
- int16_t block[6][64]);
-
-/**
- * Return the value of the 3bit "source format" syntax element.
- * This represents some standard picture dimensions or indicates that
- * width&height are explicitly stored later.
- */
-int av_const h263_get_picture_format(int width, int height);
-
-void ff_clean_h263_qscales(MpegEncContext *s);
-int ff_h263_resync(MpegEncContext *s);
-const uint8_t *ff_h263_find_resync_marker(MpegEncContext *s, const uint8_t *p, const uint8_t *end);
-int ff_h263_get_gob_height(MpegEncContext *s);
-void ff_h263_encode_motion(MpegEncContext * s, int val, int f_code);
-
-
-static inline int h263_get_motion_length(MpegEncContext * s, int val, int f_code){
- int l, bit_size, code;
-
- if (val == 0) {
- return ff_mvtab[0][1];
- } else {
- bit_size = f_code - 1;
- /* modulo encoding */
- l= INT_BIT - 6 - bit_size;
- val = (val<<l)>>l;
- val--;
- code = (val >> bit_size) + 1;
-
- return ff_mvtab[code][1] + 1 + bit_size;
- }
-}
-
-static inline void ff_h263_encode_motion_vector(MpegEncContext * s, int x, int y, int f_code){
- if(s->flags2 & CODEC_FLAG2_NO_OUTPUT){
- skip_put_bits(&s->pb,
- h263_get_motion_length(s, x, f_code)
- +h263_get_motion_length(s, y, f_code));
- }else{
- ff_h263_encode_motion(s, x, f_code);
- ff_h263_encode_motion(s, y, f_code);
- }
-}
-
-static inline int get_p_cbp(MpegEncContext * s,
- int16_t block[6][64],
- int motion_x, int motion_y){
- int cbp, i;
-
- if (s->mpv_flags & FF_MPV_FLAG_CBP_RD) {
- int best_cbpy_score= INT_MAX;
- int best_cbpc_score= INT_MAX;
- int cbpc = (-1), cbpy= (-1);
- const int offset= (s->mv_type==MV_TYPE_16X16 ? 0 : 16) + (s->dquant ? 8 : 0);
- const int lambda= s->lambda2 >> (FF_LAMBDA_SHIFT - 6);
-
- for(i=0; i<4; i++){
- int score= ff_h263_inter_MCBPC_bits[i + offset] * lambda;
- if(i&1) score += s->coded_score[5];
- if(i&2) score += s->coded_score[4];
-
- if(score < best_cbpc_score){
- best_cbpc_score= score;
- cbpc= i;
- }
- }
-
- for(i=0; i<16; i++){
- int score= ff_h263_cbpy_tab[i ^ 0xF][1] * lambda;
- if(i&1) score += s->coded_score[3];
- if(i&2) score += s->coded_score[2];
- if(i&4) score += s->coded_score[1];
- if(i&8) score += s->coded_score[0];
-
- if(score < best_cbpy_score){
- best_cbpy_score= score;
- cbpy= i;
- }
- }
- cbp= cbpc + 4*cbpy;
- if ((motion_x | motion_y | s->dquant) == 0 && s->mv_type==MV_TYPE_16X16){
- if(best_cbpy_score + best_cbpc_score + 2*lambda >= 0)
- cbp= 0;
- }
-
- for (i = 0; i < 6; i++) {
- if (s->block_last_index[i] >= 0 && ((cbp >> (5 - i))&1)==0 ){
- s->block_last_index[i]= -1;
- s->dsp.clear_block(s->block[i]);
- }
- }
- }else{
- cbp= 0;
- for (i = 0; i < 6; i++) {
- if (s->block_last_index[i] >= 0)
- cbp |= 1 << (5 - i);
- }
- }
- return cbp;
-}
-
-static inline void memsetw(short *tab, int val, int n)
-{
- int i;
- for(i=0;i<n;i++)
- tab[i] = val;
-}
-
-#endif /* AVCODEC_H263_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/h263_parser.c b/src/thirdparty/ffmpeg/libavcodec/h263_parser.c
deleted file mode 100644
index fb6a7e103..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h263_parser.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * H.263 parser
- * Copyright (c) 2002-2004 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.263 parser
- */
-
-#include "parser.h"
-#include "h263_parser.h"
-
-int ff_h263_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size){
- int vop_found, i;
- uint32_t state;
-
- vop_found= pc->frame_start_found;
- state= pc->state;
-
- i=0;
- if(!vop_found){
- for(i=0; i<buf_size; i++){
- state= (state<<8) | buf[i];
- if(state>>(32-22) == 0x20){
- i++;
- vop_found=1;
- break;
- }
- }
- }
-
- if(vop_found){
- for(; i<buf_size; i++){
- state= (state<<8) | buf[i];
- if(state>>(32-22) == 0x20){
- pc->frame_start_found=0;
- pc->state=-1;
- return i-3;
- }
- }
- }
- pc->frame_start_found= vop_found;
- pc->state= state;
-
- return END_NOT_FOUND;
-}
-
-static int h263_parse(AVCodecParserContext *s,
- AVCodecContext *avctx,
- const uint8_t **poutbuf, int *poutbuf_size,
- const uint8_t *buf, int buf_size)
-{
- ParseContext *pc = s->priv_data;
- int next;
-
- if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) {
- next = buf_size;
- } else {
- next= ff_h263_find_frame_end(pc, buf, buf_size);
-
- if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
- *poutbuf = NULL;
- *poutbuf_size = 0;
- return buf_size;
- }
- }
-
- *poutbuf = buf;
- *poutbuf_size = buf_size;
- return next;
-}
-
-AVCodecParser ff_h263_parser = {
- .codec_ids = { AV_CODEC_ID_H263 },
- .priv_data_size = sizeof(ParseContext),
- .parser_parse = h263_parse,
- .parser_close = ff_parse_close,
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/h263_parser.h b/src/thirdparty/ffmpeg/libavcodec/h263_parser.h
deleted file mode 100644
index 2f2aec3f0..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h263_parser.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * H.263 parser
- * Copyright (c) 2002-2004 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
- */
-
-#ifndef AVCODEC_H263_PARSER_H
-#define AVCODEC_H263_PARSER_H
-
-#include "parser.h"
-
-int ff_h263_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size);
-
-#endif /* AVCODEC_H263_PARSER_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/h263data.h b/src/thirdparty/ffmpeg/libavcodec/h263data.h
deleted file mode 100644
index c3d98bcfb..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h263data.h
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- * copyright (c) 2000,2001 Fabrice Bellard
- * H263+ support
- * copyright (c) 2001 Juan J. Sierralta P
- * copyright (c) 2002-2004 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.263 tables.
- */
-
-#ifndef AVCODEC_H263DATA_H
-#define AVCODEC_H263DATA_H
-
-#include <stdint.h>
-#include "mpegvideo.h"
-
-/* intra MCBPC, mb_type = (intra), then (intraq) */
-const uint8_t ff_h263_intra_MCBPC_code[9] = { 1, 1, 2, 3, 1, 1, 2, 3, 1 };
-const uint8_t ff_h263_intra_MCBPC_bits[9] = { 1, 3, 3, 3, 4, 6, 6, 6, 9 };
-
-/* inter MCBPC, mb_type = (inter), (intra), (interq), (intraq), (inter4v) */
-/* Changed the tables for interq and inter4v+q, following the standard ** Juanjo ** */
-const uint8_t ff_h263_inter_MCBPC_code[28] = {
- 1, 3, 2, 5,
- 3, 4, 3, 3,
- 3, 7, 6, 5,
- 4, 4, 3, 2,
- 2, 5, 4, 5,
- 1, 0, 0, 0, /* Stuffing */
- 2, 12, 14, 15,
-};
-const uint8_t ff_h263_inter_MCBPC_bits[28] = {
- 1, 4, 4, 6, /* inter */
- 5, 8, 8, 7, /* intra */
- 3, 7, 7, 9, /* interQ */
- 6, 9, 9, 9, /* intraQ */
- 3, 7, 7, 8, /* inter4 */
- 9, 0, 0, 0, /* Stuffing */
- 11, 13, 13, 13,/* inter4Q*/
-};
-
-const uint8_t ff_h263_mbtype_b_tab[15][2] = {
- {1, 1},
- {3, 3},
- {1, 5},
- {4, 4},
- {5, 4},
- {6, 6},
- {2, 4},
- {3, 4},
- {7, 6},
- {4, 6},
- {5, 6},
- {1, 6},
- {1,10},
- {1, 7},
- {1, 8},
-};
-
-const uint8_t ff_cbpc_b_tab[4][2] = {
-{0, 1},
-{2, 2},
-{7, 3},
-{6, 3},
-};
-
-const uint8_t ff_h263_cbpy_tab[16][2] =
-{
- {3,4}, {5,5}, {4,5}, {9,4}, {3,5}, {7,4}, {2,6}, {11,4},
- {2,5}, {3,6}, {5,4}, {10,4}, {4,4}, {8,4}, {6,4}, {3,2}
-};
-
-const uint8_t ff_mvtab[33][2] =
-{
- {1,1}, {1,2}, {1,3}, {1,4}, {3,6}, {5,7}, {4,7}, {3,7},
- {11,9}, {10,9}, {9,9}, {17,10}, {16,10}, {15,10}, {14,10}, {13,10},
- {12,10}, {11,10}, {10,10}, {9,10}, {8,10}, {7,10}, {6,10}, {5,10},
- {4,10}, {7,11}, {6,11}, {5,11}, {4,11}, {3,11}, {2,11}, {3,12},
- {2,12}
-};
-
-/* third non intra table */
-const uint16_t ff_inter_vlc[103][2] = {
-{ 0x2, 2 },{ 0xf, 4 },{ 0x15, 6 },{ 0x17, 7 },
-{ 0x1f, 8 },{ 0x25, 9 },{ 0x24, 9 },{ 0x21, 10 },
-{ 0x20, 10 },{ 0x7, 11 },{ 0x6, 11 },{ 0x20, 11 },
-{ 0x6, 3 },{ 0x14, 6 },{ 0x1e, 8 },{ 0xf, 10 },
-{ 0x21, 11 },{ 0x50, 12 },{ 0xe, 4 },{ 0x1d, 8 },
-{ 0xe, 10 },{ 0x51, 12 },{ 0xd, 5 },{ 0x23, 9 },
-{ 0xd, 10 },{ 0xc, 5 },{ 0x22, 9 },{ 0x52, 12 },
-{ 0xb, 5 },{ 0xc, 10 },{ 0x53, 12 },{ 0x13, 6 },
-{ 0xb, 10 },{ 0x54, 12 },{ 0x12, 6 },{ 0xa, 10 },
-{ 0x11, 6 },{ 0x9, 10 },{ 0x10, 6 },{ 0x8, 10 },
-{ 0x16, 7 },{ 0x55, 12 },{ 0x15, 7 },{ 0x14, 7 },
-{ 0x1c, 8 },{ 0x1b, 8 },{ 0x21, 9 },{ 0x20, 9 },
-{ 0x1f, 9 },{ 0x1e, 9 },{ 0x1d, 9 },{ 0x1c, 9 },
-{ 0x1b, 9 },{ 0x1a, 9 },{ 0x22, 11 },{ 0x23, 11 },
-{ 0x56, 12 },{ 0x57, 12 },{ 0x7, 4 },{ 0x19, 9 },
-{ 0x5, 11 },{ 0xf, 6 },{ 0x4, 11 },{ 0xe, 6 },
-{ 0xd, 6 },{ 0xc, 6 },{ 0x13, 7 },{ 0x12, 7 },
-{ 0x11, 7 },{ 0x10, 7 },{ 0x1a, 8 },{ 0x19, 8 },
-{ 0x18, 8 },{ 0x17, 8 },{ 0x16, 8 },{ 0x15, 8 },
-{ 0x14, 8 },{ 0x13, 8 },{ 0x18, 9 },{ 0x17, 9 },
-{ 0x16, 9 },{ 0x15, 9 },{ 0x14, 9 },{ 0x13, 9 },
-{ 0x12, 9 },{ 0x11, 9 },{ 0x7, 10 },{ 0x6, 10 },
-{ 0x5, 10 },{ 0x4, 10 },{ 0x24, 11 },{ 0x25, 11 },
-{ 0x26, 11 },{ 0x27, 11 },{ 0x58, 12 },{ 0x59, 12 },
-{ 0x5a, 12 },{ 0x5b, 12 },{ 0x5c, 12 },{ 0x5d, 12 },
-{ 0x5e, 12 },{ 0x5f, 12 },{ 0x3, 7 },
-};
-
-const int8_t ff_inter_level[102] = {
- 1, 2, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 1, 2, 3, 4,
- 5, 6, 1, 2, 3, 4, 1, 2,
- 3, 1, 2, 3, 1, 2, 3, 1,
- 2, 3, 1, 2, 1, 2, 1, 2,
- 1, 2, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 2, 3, 1, 2, 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,
-};
-
-const int8_t ff_inter_run[102] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 1, 1, 1, 1,
- 1, 1, 2, 2, 2, 2, 3, 3,
- 3, 4, 4, 4, 5, 5, 5, 6,
- 6, 6, 7, 7, 8, 8, 9, 9,
- 10, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 0, 0, 0, 1, 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, 32, 33, 34,
- 35, 36, 37, 38, 39, 40,
-};
-
-RLTable ff_h263_rl_inter = {
- 102,
- 58,
- ff_inter_vlc,
- ff_inter_run,
- ff_inter_level,
-};
-
-static const uint16_t intra_vlc_aic[103][2] = {
-{ 0x2, 2 }, { 0x6, 3 }, { 0xe, 4 }, { 0xc, 5 },
-{ 0xd, 5 }, { 0x10, 6 }, { 0x11, 6 }, { 0x12, 6 },
-{ 0x16, 7 }, { 0x1b, 8 }, { 0x20, 9 }, { 0x21, 9 },
-{ 0x1a, 9 }, { 0x1b, 9 }, { 0x1c, 9 }, { 0x1d, 9 },
-{ 0x1e, 9 }, { 0x1f, 9 }, { 0x23, 11 }, { 0x22, 11 },
-{ 0x57, 12 }, { 0x56, 12 }, { 0x55, 12 }, { 0x54, 12 },
-{ 0x53, 12 }, { 0xf, 4 }, { 0x14, 6 }, { 0x14, 7 },
-{ 0x1e, 8 }, { 0xf, 10 }, { 0x21, 11 }, { 0x50, 12 },
-{ 0xb, 5 }, { 0x15, 7 }, { 0xe, 10 }, { 0x9, 10 },
-{ 0x15, 6 }, { 0x1d, 8 }, { 0xd, 10 }, { 0x51, 12 },
-{ 0x13, 6 }, { 0x23, 9 }, { 0x7, 11 }, { 0x17, 7 },
-{ 0x22, 9 }, { 0x52, 12 }, { 0x1c, 8 }, { 0xc, 10 },
-{ 0x1f, 8 }, { 0xb, 10 }, { 0x25, 9 }, { 0xa, 10 },
-{ 0x24, 9 }, { 0x6, 11 }, { 0x21, 10 }, { 0x20, 10 },
-{ 0x8, 10 }, { 0x20, 11 }, { 0x7, 4 }, { 0xc, 6 },
-{ 0x10, 7 }, { 0x13, 8 }, { 0x11, 9 }, { 0x12, 9 },
-{ 0x4, 10 }, { 0x27, 11 }, { 0x26, 11 }, { 0x5f, 12 },
-{ 0xf, 6 }, { 0x13, 9 }, { 0x5, 10 }, { 0x25, 11 },
-{ 0xe, 6 }, { 0x14, 9 }, { 0x24, 11 }, { 0xd, 6 },
-{ 0x6, 10 }, { 0x5e, 12 }, { 0x11, 7 }, { 0x7, 10 },
-{ 0x13, 7 }, { 0x5d, 12 }, { 0x12, 7 }, { 0x5c, 12 },
-{ 0x14, 8 }, { 0x5b, 12 }, { 0x15, 8 }, { 0x1a, 8 },
-{ 0x19, 8 }, { 0x18, 8 }, { 0x17, 8 }, { 0x16, 8 },
-{ 0x19, 9 }, { 0x15, 9 }, { 0x16, 9 }, { 0x18, 9 },
-{ 0x17, 9 }, { 0x4, 11 }, { 0x5, 11 }, { 0x58, 12 },
-{ 0x59, 12 }, { 0x5a, 12 }, { 0x3, 7 },
-};
-
-static const int8_t intra_run_aic[102] = {
- 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, 1, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 3, 3, 3, 3,
- 4, 4, 4, 5, 5, 5, 6, 6,
- 7, 7, 8, 8, 9, 9, 10, 11,
-12, 13, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 1, 1, 1, 1,
- 2, 2, 2, 3, 3, 3, 4, 4,
- 5, 5, 6, 6, 7, 7, 8, 9,
-10, 11, 12, 13, 14, 15, 16, 17,
-18, 19, 20, 21, 22, 23,
-};
-
-static const int8_t intra_level_aic[102] = {
- 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, 1, 2, 3, 4, 5, 6, 7,
- 1, 2, 3, 4, 1, 2, 3, 4,
- 1, 2, 3, 1, 2, 3, 1, 2,
- 1, 2, 1, 2, 1, 2, 1, 1,
- 1, 1, 1, 2, 3, 4, 5, 6,
- 7, 8, 9, 10, 1, 2, 3, 4,
- 1, 2, 3, 1, 2, 3, 1, 2,
- 1, 2, 1, 2, 1, 2, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1,
-};
-
-RLTable ff_rl_intra_aic = {
- 102,
- 58,
- intra_vlc_aic,
- intra_run_aic,
- intra_level_aic,
-};
-
-const uint16_t ff_h263_format[8][2] = {
- { 0, 0 },
- { 128, 96 },
- { 176, 144 },
- { 352, 288 },
- { 704, 576 },
- { 1408, 1152 },
-};
-
-const uint8_t ff_aic_dc_scale_table[32]={
-// 0 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
- 0, 2, 4, 6, 8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62
-};
-
-const uint8_t ff_modified_quant_tab[2][32]={
-// 0 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
-{
- 0, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9,10,11,12,13,14,15,16,17,18,18,19,20,21,22,23,24,25,26,27,28
-},{
- 0, 2, 3, 4, 5, 6, 7, 8, 9,10,11,13,14,15,16,17,18,19,20,21,22,24,25,26,27,28,29,30,31,31,31,26
-}
-};
-
-const uint8_t ff_h263_chroma_qscale_table[32]={
-// 0 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
- 0, 1, 2, 3, 4, 5, 6, 6, 7, 8, 9, 9,10,10,11,11,12,12,12,13,13,13,14,14,14,14,14,15,15,15,15,15
-};
-
-const uint16_t ff_mba_max[6]={
- 47, 98, 395,1583,6335,9215
-};
-
-const uint8_t ff_mba_length[7]={
- 6, 7, 9, 11, 13, 14, 14
-};
-
-const uint8_t ff_h263_loop_filter_strength[32]={
-// 0 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
- 0, 1, 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9,10,10,10,11,11,11,12,12,12
-};
-
-const AVRational ff_h263_pixel_aspect[16]={
- {0, 1},
- {1, 1},
- {12, 11},
- {10, 11},
- {16, 11},
- {40, 33},
- {0, 1},
- {0, 1},
- {0, 1},
- {0, 1},
- {0, 1},
- {0, 1},
- {0, 1},
- {0, 1},
- {0, 1},
- {0, 1},
-};
-
-#endif /* AVCODEC_H263DATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/h263dec.c b/src/thirdparty/ffmpeg/libavcodec/h263dec.c
deleted file mode 100644
index 3703c9149..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h263dec.c
+++ /dev/null
@@ -1,796 +0,0 @@
-/*
- * H.263 decoder
- * Copyright (c) 2001 Fabrice Bellard
- * Copyright (c) 2002-2004 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.263 decoder.
- */
-
-#define UNCHECKED_BITSTREAM_READER 1
-
-#include "libavutil/cpu.h"
-#include "internal.h"
-#include "avcodec.h"
-#include "dsputil.h"
-#include "mpegvideo.h"
-#include "h263.h"
-#include "h263_parser.h"
-#include "mpeg4video_parser.h"
-#include "msmpeg4.h"
-#include "vdpau_internal.h"
-#include "thread.h"
-#include "flv.h"
-#include "mpeg4video.h"
-
-//#define DEBUG
-//#define PRINT_FRAME_TIME
-
-av_cold int ff_h263_decode_init(AVCodecContext *avctx)
-{
- MpegEncContext *s = avctx->priv_data;
- int ret;
-
- s->avctx = avctx;
- s->out_format = FMT_H263;
-
- s->width = avctx->coded_width;
- s->height = avctx->coded_height;
- s->workaround_bugs= avctx->workaround_bugs;
-
- // set defaults
- ff_MPV_decode_defaults(s);
- s->quant_precision=5;
- s->decode_mb= ff_h263_decode_mb;
- s->low_delay= 1;
- 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);
- s->unrestricted_mv= 1;
-
- /* select sub codec */
- switch(avctx->codec->id) {
- case AV_CODEC_ID_H263:
- case AV_CODEC_ID_H263P:
- s->unrestricted_mv= 0;
- avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
- break;
- case AV_CODEC_ID_MPEG4:
- break;
- case AV_CODEC_ID_MSMPEG4V1:
- s->h263_pred = 1;
- s->msmpeg4_version=1;
- break;
- case AV_CODEC_ID_MSMPEG4V2:
- s->h263_pred = 1;
- s->msmpeg4_version=2;
- break;
- case AV_CODEC_ID_MSMPEG4V3:
- s->h263_pred = 1;
- s->msmpeg4_version=3;
- break;
- case AV_CODEC_ID_WMV1:
- s->h263_pred = 1;
- s->msmpeg4_version=4;
- break;
- case AV_CODEC_ID_WMV2:
- s->h263_pred = 1;
- s->msmpeg4_version=5;
- break;
- case AV_CODEC_ID_VC1:
- case AV_CODEC_ID_WMV3:
- case AV_CODEC_ID_VC1IMAGE:
- case AV_CODEC_ID_WMV3IMAGE:
- case AV_CODEC_ID_MSS2:
- s->h263_pred = 1;
- s->msmpeg4_version=6;
- avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
- break;
- case AV_CODEC_ID_H263I:
- break;
- case AV_CODEC_ID_FLV1:
- s->h263_flv = 1;
- break;
- default:
- return AVERROR(EINVAL);
- }
- s->codec_id= avctx->codec->id;
- avctx->hwaccel= ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt);
-
- /* for h263, we allocate the images after having read the header */
- if (avctx->codec->id != AV_CODEC_ID_H263 && avctx->codec->id != AV_CODEC_ID_H263P && avctx->codec->id != AV_CODEC_ID_MPEG4)
- if ((ret = ff_MPV_common_init(s)) < 0)
- return ret;
-
- ff_h263_decode_init_vlc();
-
- return 0;
-}
-
-av_cold int ff_h263_decode_end(AVCodecContext *avctx)
-{
- MpegEncContext *s = avctx->priv_data;
-
- ff_MPV_common_end(s);
- return 0;
-}
-
-/**
- * Return the number of bytes consumed for building the current frame.
- */
-static int get_consumed_bytes(MpegEncContext *s, int buf_size){
- int pos= (get_bits_count(&s->gb)+7)>>3;
-
- if(s->divx_packed || s->avctx->hwaccel){
- //we would have to scan through the whole buf to handle the weird reordering ...
- return buf_size;
- }else if(s->flags&CODEC_FLAG_TRUNCATED){
- pos -= s->parse_context.last_index;
- if(pos<0) pos=0; // padding is not really read so this might be -1
- return pos;
- }else{
- if(pos==0) pos=1; //avoid infinite loops (i doubt that is needed but ...)
- if(pos+10>buf_size) pos=buf_size; // oops ;)
-
- return pos;
- }
-}
-
-static int decode_slice(MpegEncContext *s){
- const int part_mask= s->partitioned_frame ? (ER_AC_END|ER_AC_ERROR) : 0x7F;
- const int mb_size= 16>>s->avctx->lowres;
- int ret;
-
- s->last_resync_gb= s->gb;
- s->first_slice_line= 1;
-
- s->resync_mb_x= s->mb_x;
- s->resync_mb_y= s->mb_y;
-
- ff_set_qscale(s, s->qscale);
-
- if (s->avctx->hwaccel) {
- const uint8_t *start= s->gb.buffer + get_bits_count(&s->gb)/8;
- const uint8_t *end = ff_h263_find_resync_marker(s, start + 1, s->gb.buffer_end);
- skip_bits_long(&s->gb, 8*(end - start));
- return s->avctx->hwaccel->decode_slice(s->avctx, start, end - start);
- }
-
- if(s->partitioned_frame){
- const int qscale= s->qscale;
-
- if(CONFIG_MPEG4_DECODER && s->codec_id==AV_CODEC_ID_MPEG4){
- if ((ret = ff_mpeg4_decode_partitions(s)) < 0)
- return ret;
- }
-
- /* restore variables which were modified */
- s->first_slice_line=1;
- s->mb_x= s->resync_mb_x;
- s->mb_y= s->resync_mb_y;
- ff_set_qscale(s, qscale);
- }
-
- for(; s->mb_y < s->mb_height; s->mb_y++) {
- /* per-row end of slice checks */
- if(s->msmpeg4_version){
- if(s->resync_mb_y + s->slice_height == s->mb_y){
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END);
-
- return 0;
- }
- }
-
- if(s->msmpeg4_version==1){
- s->last_dc[0]=
- s->last_dc[1]=
- s->last_dc[2]= 128;
- }
-
- ff_init_block_index(s);
- for(; s->mb_x < s->mb_width; s->mb_x++) {
- int ret;
-
- ff_update_block_index(s);
-
- if(s->resync_mb_x == s->mb_x && s->resync_mb_y+1 == s->mb_y){
- s->first_slice_line=0;
- }
-
- /* DCT & quantize */
-
- s->mv_dir = MV_DIR_FORWARD;
- s->mv_type = MV_TYPE_16X16;
-// s->mb_skipped = 0;
- av_dlog(s, "%d %d %06X\n",
- ret, get_bits_count(&s->gb), show_bits(&s->gb, 24));
- ret= s->decode_mb(s, s->block);
-
- if (s->pict_type!=AV_PICTURE_TYPE_B)
- ff_h263_update_motion_val(s);
-
- if(ret<0){
- const int xy= s->mb_x + s->mb_y*s->mb_stride;
- if(ret==SLICE_END){
- ff_MPV_decode_mb(s, s->block);
- if(s->loop_filter)
- ff_h263_loop_filter(s);
-
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_MB_END&part_mask);
-
- s->padding_bug_score--;
-
- if(++s->mb_x >= s->mb_width){
- s->mb_x=0;
- ff_draw_horiz_band(s, s->mb_y*mb_size, mb_size);
- ff_MPV_report_decode_progress(s);
- s->mb_y++;
- }
- return 0;
- }else if(ret==SLICE_NOEND){
- av_log(s->avctx, AV_LOG_ERROR, "Slice mismatch at MB: %d\n", xy);
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x+1, s->mb_y, ER_MB_END&part_mask);
- return AVERROR_INVALIDDATA;
- }
- av_log(s->avctx, AV_LOG_ERROR, "Error at MB: %d\n", xy);
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR&part_mask);
-
- return AVERROR_INVALIDDATA;
- }
-
- ff_MPV_decode_mb(s, s->block);
- if(s->loop_filter)
- ff_h263_loop_filter(s);
- }
-
- ff_draw_horiz_band(s, s->mb_y*mb_size, mb_size);
- ff_MPV_report_decode_progress(s);
-
- s->mb_x= 0;
- }
-
- av_assert1(s->mb_x==0 && s->mb_y==s->mb_height);
-
- if(s->codec_id==AV_CODEC_ID_MPEG4
- && (s->workaround_bugs&FF_BUG_AUTODETECT)
- && get_bits_left(&s->gb) >= 48
- && show_bits(&s->gb, 24)==0x4010
- && !s->data_partitioning)
- s->padding_bug_score+=32;
-
- /* try to detect the padding bug */
- if( s->codec_id==AV_CODEC_ID_MPEG4
- && (s->workaround_bugs&FF_BUG_AUTODETECT)
- && get_bits_left(&s->gb) >=0
- && get_bits_left(&s->gb) < 137
-// && !s->resync_marker
- && !s->data_partitioning){
-
- const int bits_count= get_bits_count(&s->gb);
- const int bits_left = s->gb.size_in_bits - bits_count;
-
- if(bits_left==0){
- s->padding_bug_score+=16;
- } else if(bits_left != 1){
- int v= show_bits(&s->gb, 8);
- v|= 0x7F >> (7-(bits_count&7));
-
- if(v==0x7F && bits_left<=8)
- s->padding_bug_score--;
- else if(v==0x7F && ((get_bits_count(&s->gb)+8)&8) && bits_left<=16)
- s->padding_bug_score+= 4;
- else
- s->padding_bug_score++;
- }
- }
-
- if(s->workaround_bugs&FF_BUG_AUTODETECT){
- if(s->padding_bug_score > -2 && !s->data_partitioning /*&& (s->divx_version>=0 || !s->resync_marker)*/)
- s->workaround_bugs |= FF_BUG_NO_PADDING;
- else
- s->workaround_bugs &= ~FF_BUG_NO_PADDING;
- }
-
- // handle formats which don't have unique end markers
- if(s->msmpeg4_version || (s->workaround_bugs&FF_BUG_NO_PADDING)){ //FIXME perhaps solve this more cleanly
- int left= get_bits_left(&s->gb);
- int max_extra=7;
-
- /* no markers in M$ crap */
- if(s->msmpeg4_version && s->pict_type==AV_PICTURE_TYPE_I)
- max_extra+= 17;
-
- /* buggy padding but the frame should still end approximately at the bitstream end */
- if((s->workaround_bugs&FF_BUG_NO_PADDING) && (s->err_recognition&(AV_EF_BUFFER|AV_EF_AGGRESSIVE)))
- max_extra+= 48;
- else if((s->workaround_bugs&FF_BUG_NO_PADDING))
- max_extra+= 256*256*256*64;
-
- if(left>max_extra){
- av_log(s->avctx, AV_LOG_ERROR, "discarding %d junk bits at end, next would be %X\n", left, show_bits(&s->gb, 24));
- }
- else if(left<0){
- av_log(s->avctx, AV_LOG_ERROR, "overreading %d bits\n", -left);
- }else
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END);
-
- return 0;
- }
-
- av_log(s->avctx, AV_LOG_ERROR, "slice end not reached but screenspace end (%d left %06X, score= %d)\n",
- get_bits_left(&s->gb),
- show_bits(&s->gb, 24), s->padding_bug_score);
-
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_MB_END&part_mask);
-
- return AVERROR_INVALIDDATA;
-}
-
-int ff_h263_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;
- int ret;
- AVFrame *pict = data;
-
-#ifdef PRINT_FRAME_TIME
-uint64_t time= rdtsc();
-#endif
- s->flags= avctx->flags;
- s->flags2= avctx->flags2;
-
- /* no supplementary picture */
- if (buf_size == 0) {
- /* special case for last picture */
- if (s->low_delay==0 && s->next_picture_ptr) {
- *pict = s->next_picture_ptr->f;
- s->next_picture_ptr= NULL;
-
- *got_frame = 1;
- }
-
- return 0;
- }
-
- if(s->flags&CODEC_FLAG_TRUNCATED){
- int next;
-
- if(CONFIG_MPEG4_DECODER && s->codec_id==AV_CODEC_ID_MPEG4){
- next= ff_mpeg4_find_frame_end(&s->parse_context, buf, buf_size);
- }else if(CONFIG_H263_DECODER && s->codec_id==AV_CODEC_ID_H263){
- next= ff_h263_find_frame_end(&s->parse_context, buf, buf_size);
- }else if(CONFIG_H263P_DECODER && s->codec_id==AV_CODEC_ID_H263P){
- next= ff_h263_find_frame_end(&s->parse_context, buf, buf_size);
- }else{
- av_log(s->avctx, AV_LOG_ERROR, "this codec does not support truncated bitstreams\n");
- return AVERROR(EINVAL);
- }
-
- if( ff_combine_frame(&s->parse_context, next, (const uint8_t **)&buf, &buf_size) < 0 )
- return buf_size;
- }
-
-
-retry:
- if(s->divx_packed && s->bitstream_buffer_size){
- int i;
- for(i=0; i<buf_size-3; i++){
- if(buf[i]==0 && buf[i+1]==0 && buf[i+2]==1){
- if(buf[i+3]==0xB0){
- av_log(s->avctx, AV_LOG_WARNING, "Discarding excessive bitstream in packed xvid\n");
- s->bitstream_buffer_size=0;
- }
- break;
- }
- }
- }
-
- if(s->bitstream_buffer_size && (s->divx_packed || buf_size<20)){ //divx 5.01+/xvid frame reorder
- init_get_bits(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size*8);
- }else
- init_get_bits(&s->gb, buf, buf_size*8);
- s->bitstream_buffer_size=0;
-
- if (!s->context_initialized) {
- if ((ret = ff_MPV_common_init(s)) < 0) //we need the idct permutaton for reading a custom matrix
- return ret;
- }
-
- /* 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]) {
- int i= ff_find_unused_picture(s, 0);
- if (i < 0)
- return i;
- s->current_picture_ptr= &s->picture[i];
- }
-
- /* let's go :-) */
- if (CONFIG_WMV2_DECODER && s->msmpeg4_version==5) {
- ret= ff_wmv2_decode_picture_header(s);
- } else if (CONFIG_MSMPEG4_DECODER && s->msmpeg4_version) {
- ret = ff_msmpeg4_decode_picture_header(s);
- } else if (CONFIG_MPEG4_DECODER && s->h263_pred) {
- if(s->avctx->extradata_size && s->picture_number==0){
- GetBitContext gb;
-
- init_get_bits(&gb, s->avctx->extradata, s->avctx->extradata_size*8);
- ret = ff_mpeg4_decode_picture_header(s, &gb);
- }
- ret = ff_mpeg4_decode_picture_header(s, &s->gb);
- } else if (CONFIG_H263I_DECODER && s->codec_id == AV_CODEC_ID_H263I) {
- ret = ff_intel_h263_decode_picture_header(s);
- } else if (CONFIG_FLV_DECODER && s->h263_flv) {
- ret = ff_flv_decode_picture_header(s);
- } else {
- ret = ff_h263_decode_picture_header(s);
- }
-
- if (ret < 0 || ret==FRAME_SKIPPED) {
- if ( s->width != avctx->coded_width
- || s->height != avctx->coded_height) {
- av_log(s->avctx, AV_LOG_WARNING, "Reverting picture dimensions change due to header decoding failure\n");
- s->width = avctx->coded_width;
- s->height= avctx->coded_height;
- }
- }
- if(ret==FRAME_SKIPPED) return get_consumed_bytes(s, buf_size);
-
- /* skip if the header was thrashed */
- if (ret < 0){
- av_log(s->avctx, AV_LOG_ERROR, "header damaged\n");
- return ret;
- }
-
- avctx->has_b_frames= !s->low_delay;
-
- if(s->xvid_build==-1 && s->divx_version==-1 && s->lavc_build==-1){
- if(s->stream_codec_tag == AV_RL32("XVID") ||
- s->codec_tag == AV_RL32("XVID") || s->codec_tag == AV_RL32("XVIX") ||
- s->codec_tag == AV_RL32("RMP4") || s->codec_tag == AV_RL32("ZMP4") ||
- s->codec_tag == AV_RL32("SIPP")
- )
- s->xvid_build= 0;
-#if 0
- if(s->codec_tag == AV_RL32("DIVX") && s->vo_type==0 && s->vol_control_parameters==1
- && s->padding_bug_score > 0 && s->low_delay) // XVID with modified fourcc
- s->xvid_build= 0;
-#endif
- }
-
- if(s->xvid_build==-1 && s->divx_version==-1 && s->lavc_build==-1){
- if(s->codec_tag == AV_RL32("DIVX") && s->vo_type==0 && s->vol_control_parameters==0)
- s->divx_version= 400; //divx 4
- }
-
- if(s->xvid_build>=0 && s->divx_version>=0){
- s->divx_version=
- s->divx_build= -1;
- }
-
- if(s->workaround_bugs&FF_BUG_AUTODETECT){
- if(s->codec_tag == AV_RL32("XVIX"))
- s->workaround_bugs|= FF_BUG_XVID_ILACE;
-
- if(s->codec_tag == AV_RL32("UMP4")){
- s->workaround_bugs|= FF_BUG_UMP4;
- }
-
- if(s->divx_version>=500 && s->divx_build<1814){
- s->workaround_bugs|= FF_BUG_QPEL_CHROMA;
- }
-
- if(s->divx_version>502 && s->divx_build<1814){
- s->workaround_bugs|= FF_BUG_QPEL_CHROMA2;
- }
-
- if(s->xvid_build<=3U)
- s->padding_bug_score= 256*256*256*64;
-
- if(s->xvid_build<=1U)
- s->workaround_bugs|= FF_BUG_QPEL_CHROMA;
-
- if(s->xvid_build<=12U)
- s->workaround_bugs|= FF_BUG_EDGE;
-
- if(s->xvid_build<=32U)
- s->workaround_bugs|= FF_BUG_DC_CLIP;
-
-#define SET_QPEL_FUNC(postfix1, postfix2) \
- s->dsp.put_ ## postfix1 = ff_put_ ## postfix2;\
- s->dsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2;\
- s->dsp.avg_ ## postfix1 = ff_avg_ ## postfix2;
-
- if(s->lavc_build<4653U)
- s->workaround_bugs|= FF_BUG_STD_QPEL;
-
- if(s->lavc_build<4655U)
- s->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE;
-
- if(s->lavc_build<4670U){
- s->workaround_bugs|= FF_BUG_EDGE;
- }
-
- if(s->lavc_build<=4712U)
- s->workaround_bugs|= FF_BUG_DC_CLIP;
-
- if(s->divx_version>=0)
- s->workaround_bugs|= FF_BUG_DIRECT_BLOCKSIZE;
- if(s->divx_version==501 && s->divx_build==20020416)
- s->padding_bug_score= 256*256*256*64;
-
- if(s->divx_version<500U){
- s->workaround_bugs|= FF_BUG_EDGE;
- }
-
- if(s->divx_version>=0)
- s->workaround_bugs|= FF_BUG_HPEL_CHROMA;
-#if 0
- if(s->divx_version==500)
- s->padding_bug_score= 256*256*256*64;
-
- /* very ugly XVID padding bug detection FIXME/XXX solve this differently
- * Let us hope this at least works.
- */
- if( s->resync_marker==0 && s->data_partitioning==0 && s->divx_version==-1
- && s->codec_id==AV_CODEC_ID_MPEG4 && s->vo_type==0)
- s->workaround_bugs|= FF_BUG_NO_PADDING;
-
- if(s->lavc_build<4609U) //FIXME not sure about the version num but a 4609 file seems ok
- s->workaround_bugs|= FF_BUG_NO_PADDING;
-#endif
- }
-
- if(s->workaround_bugs& FF_BUG_STD_QPEL){
- SET_QPEL_FUNC(qpel_pixels_tab[0][ 5], qpel16_mc11_old_c)
- SET_QPEL_FUNC(qpel_pixels_tab[0][ 7], qpel16_mc31_old_c)
- SET_QPEL_FUNC(qpel_pixels_tab[0][ 9], qpel16_mc12_old_c)
- SET_QPEL_FUNC(qpel_pixels_tab[0][11], qpel16_mc32_old_c)
- SET_QPEL_FUNC(qpel_pixels_tab[0][13], qpel16_mc13_old_c)
- SET_QPEL_FUNC(qpel_pixels_tab[0][15], qpel16_mc33_old_c)
-
- SET_QPEL_FUNC(qpel_pixels_tab[1][ 5], qpel8_mc11_old_c)
- SET_QPEL_FUNC(qpel_pixels_tab[1][ 7], qpel8_mc31_old_c)
- SET_QPEL_FUNC(qpel_pixels_tab[1][ 9], qpel8_mc12_old_c)
- SET_QPEL_FUNC(qpel_pixels_tab[1][11], qpel8_mc32_old_c)
- SET_QPEL_FUNC(qpel_pixels_tab[1][13], qpel8_mc13_old_c)
- SET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_old_c)
- }
-
- if(avctx->debug & FF_DEBUG_BUGS)
- av_log(s->avctx, AV_LOG_DEBUG, "bugs: %X lavc_build:%d xvid_build:%d divx_version:%d divx_build:%d %s\n",
- s->workaround_bugs, s->lavc_build, s->xvid_build, s->divx_version, s->divx_build,
- s->divx_packed ? "p" : "");
-
-#if HAVE_MMX
- if (s->codec_id == AV_CODEC_ID_MPEG4 && s->xvid_build>=0 && avctx->idct_algo == FF_IDCT_AUTO && (av_get_cpu_flags() & AV_CPU_FLAG_MMX)) {
- avctx->idct_algo= FF_IDCT_XVIDMMX;
- ff_dct_common_init(s);
- goto retry;
- }
-#endif
-
- /* After H263 & mpeg4 header decode we have the height, width,*/
- /* and other parameters. So then we could init the picture */
- /* FIXME: By the way H263 decoder is evolving it should have */
- /* an H263EncContext */
-
- if ((!avctx->coded_width || !avctx->coded_height) && 0) {
- ParseContext pc= s->parse_context; //FIXME move these demuxng hack to avformat
-
- s->parse_context.buffer=0;
- ff_MPV_common_end(s);
- s->parse_context= pc;
- avcodec_set_dimensions(avctx, s->width, s->height);
-
- goto retry;
- }
-
- if (s->width != avctx->coded_width ||
- s->height != avctx->coded_height ||
- s->context_reinit) {
- /* H.263 could change picture size any time */
- s->context_reinit = 0;
-
- avcodec_set_dimensions(avctx, s->width, s->height);
-
- if ((ret = ff_MPV_common_frame_size_change(s)))
- return ret;
- }
-
- if((s->codec_id==AV_CODEC_ID_H263 || s->codec_id==AV_CODEC_ID_H263P || s->codec_id == AV_CODEC_ID_H263I))
- 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;
-
- /* 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))
- return get_consumed_bytes(s, buf_size);
- 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)
- || avctx->skip_frame >= AVDISCARD_ALL)
- return get_consumed_bytes(s, buf_size);
-
- if(s->next_p_frame_damaged){
- if(s->pict_type==AV_PICTURE_TYPE_B)
- return get_consumed_bytes(s, buf_size);
- else
- s->next_p_frame_damaged=0;
- }
-
- if((!s->no_rounding) || s->pict_type==AV_PICTURE_TYPE_B){
- s->me.qpel_put= s->dsp.put_qpel_pixels_tab;
- s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab;
- }else{
- s->me.qpel_put= s->dsp.put_no_rnd_qpel_pixels_tab;
- s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab;
- }
-
- if ((ret = ff_MPV_frame_start(s, avctx)) < 0)
- return ret;
-
- if (!s->divx_packed) 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);
- goto frame_end;
- }
-
- if (avctx->hwaccel) {
- if ((ret = avctx->hwaccel->start_frame(avctx, s->gb.buffer, s->gb.buffer_end - s->gb.buffer)) < 0)
- return ret;
- }
-
- ff_er_frame_start(s);
-
- //the second part of the wmv2 header contains the MB skip bits which are stored in current_picture->mb_type
- //which is not available before ff_MPV_frame_start()
- if (CONFIG_WMV2_DECODER && s->msmpeg4_version==5){
- ret = ff_wmv2_decode_secondary_picture_header(s);
- if(ret<0) return ret;
- if(ret==1) goto intrax8_decoded;
- }
-
- /* decode each macroblock */
- s->mb_x=0;
- s->mb_y=0;
-
- ret = decode_slice(s);
- while(s->mb_y<s->mb_height){
- if(s->msmpeg4_version){
- if(s->slice_height==0 || s->mb_x!=0 || (s->mb_y%s->slice_height)!=0 || get_bits_left(&s->gb)<0)
- break;
- }else{
- int prev_x=s->mb_x, prev_y=s->mb_y;
- if(ff_h263_resync(s)<0)
- break;
- if (prev_y * s->mb_width + prev_x < s->mb_y * s->mb_width + s->mb_x)
- s->error_occurred = 1;
- }
-
- if(s->msmpeg4_version<4 && s->h263_pred)
- ff_mpeg4_clean_buffers(s);
-
- if (decode_slice(s) < 0) ret = AVERROR_INVALIDDATA;
- }
-
- if (s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type==AV_PICTURE_TYPE_I)
- if(!CONFIG_MSMPEG4_DECODER || ff_msmpeg4_decode_ext_header(s, buf_size) < 0){
- s->error_status_table[s->mb_num-1]= ER_MB_ERROR;
- }
-
- av_assert1(s->bitstream_buffer_size==0);
-frame_end:
- /* divx 5.01+ bitstream reorder stuff */
- if(s->codec_id==AV_CODEC_ID_MPEG4 && s->divx_packed){
- int current_pos= s->gb.buffer == s->bitstream_buffer ? 0 : (get_bits_count(&s->gb)>>3);
- int startcode_found=0;
-
- if(buf_size - current_pos > 7){
- int i;
- for(i=current_pos; i<buf_size-4; i++){
- if(buf[i]==0 && buf[i+1]==0 && buf[i+2]==1 && buf[i+3]==0xB6){
- startcode_found=!(buf[i+4]&0x40);
- break;
- }
- }
- }
-
- if(startcode_found){
- av_fast_malloc(
- &s->bitstream_buffer,
- &s->allocated_bitstream_buffer_size,
- buf_size - current_pos + FF_INPUT_BUFFER_PADDING_SIZE);
- if (!s->bitstream_buffer)
- return AVERROR(ENOMEM);
- memcpy(s->bitstream_buffer, buf + current_pos, buf_size - current_pos);
- s->bitstream_buffer_size= buf_size - current_pos;
- }
- }
-
-intrax8_decoded:
- ff_er_frame_end(s);
-
- if (avctx->hwaccel) {
- if ((ret = avctx->hwaccel->end_frame(avctx)) < 0)
- return ret;
- }
-
- ff_MPV_frame_end(s);
-
- assert(s->current_picture.f.pict_type == s->current_picture_ptr->f.pict_type);
- assert(s->current_picture.f.pict_type == s->pict_type);
- if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
- *pict = s->current_picture_ptr->f;
- } else if (s->last_picture_ptr != NULL) {
- *pict = s->last_picture_ptr->f;
- }
-
- if(s->last_picture_ptr || s->low_delay){
- *got_frame = 1;
- ff_print_debug_info(s, pict);
- }
-
-#ifdef PRINT_FRAME_TIME
-av_log(avctx, AV_LOG_DEBUG, "%"PRId64"\n", rdtsc()-time);
-#endif
-
- return (ret && (avctx->err_recognition & AV_EF_EXPLODE))?ret:get_consumed_bytes(s, buf_size);
-}
-
-AVCodec ff_h263_decoder = {
- .name = "h263",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_H263,
- .priv_data_size = sizeof(MpegEncContext),
- .init = ff_h263_decode_init,
- .close = ff_h263_decode_end,
- .decode = ff_h263_decode_frame,
- .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 |
- CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
- .flush = ff_mpeg_flush,
- .max_lowres = 3,
- .long_name = NULL_IF_CONFIG_SMALL("H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2"),
- .pix_fmts = ff_hwaccel_pixfmt_list_420,
-};
-
-AVCodec ff_h263p_decoder = {
- .name = "h263p",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_H263P,
- .priv_data_size = sizeof(MpegEncContext),
- .init = ff_h263_decode_init,
- .close = ff_h263_decode_end,
- .decode = ff_h263_decode_frame,
- .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 |
- CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
- .flush = ff_mpeg_flush,
- .max_lowres = 3,
- .long_name = NULL_IF_CONFIG_SMALL("H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2"),
- .pix_fmts = ff_hwaccel_pixfmt_list_420,
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264.c b/src/thirdparty/ffmpeg/libavcodec/h264.c
deleted file mode 100644
index 0046b96d7..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264.c
+++ /dev/null
@@ -1,4532 +0,0 @@
-/*
- * 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>
- */
-
-#define UNCHECKED_BITSTREAM_READER 1
-
-#include "libavutil/imgutils.h"
-#include "libavutil/opt.h"
-#include "internal.h"
-#include "cabac.h"
-#include "cabac_functions.h"
-#include "dsputil.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 "rectangle.h"
-#include "svq3.h"
-#include "thread.h"
-#include "vdpau_internal.h"
-#include "libavutil/avassert.h"
-
-// #undef NDEBUG
-#include <assert.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 enum AVPixelFormat hwaccel_pixfmt_list_h264_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;
- return h ? h->sps.num_reorder_frames : 0;
-}
-
-/**
- * Check if the top & left blocks are available if needed and
- * change the dc mode so it only uses the available blocks.
- */
-int ff_h264_check_intra4x4_pred_mode(H264Context *h)
-{
- MpegEncContext *const s = &h->s;
- static const int8_t top[12] = {
- -1, 0, LEFT_DC_PRED, -1, -1, -1, -1, -1, 0
- };
- static const int8_t left[12] = {
- 0, -1, TOP_DC_PRED, 0, -1, -1, -1, 0, -1, DC_128_PRED
- };
- int i;
-
- if (!(h->top_samples_available & 0x8000)) {
- for (i = 0; i < 4; i++) {
- int status = top[h->intra4x4_pred_mode_cache[scan8[0] + i]];
- if (status < 0) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "top block unavailable for requested intra4x4 mode %d at %d %d\n",
- status, s->mb_x, s->mb_y);
- return -1;
- } else if (status) {
- h->intra4x4_pred_mode_cache[scan8[0] + i] = status;
- }
- }
- }
-
- if ((h->left_samples_available & 0x8888) != 0x8888) {
- static const int mask[4] = { 0x8000, 0x2000, 0x80, 0x20 };
- for (i = 0; i < 4; i++)
- if (!(h->left_samples_available & mask[i])) {
- int status = left[h->intra4x4_pred_mode_cache[scan8[0] + 8 * i]];
- if (status < 0) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "left block unavailable for requested intra4x4 mode %d at %d %d\n",
- status, s->mb_x, s->mb_y);
- return -1;
- } else if (status) {
- h->intra4x4_pred_mode_cache[scan8[0] + 8 * i] = status;
- }
- }
- }
-
- return 0;
-} // FIXME cleanup like ff_h264_check_intra_pred_mode
-
-/**
- * Check if the top & left blocks are available if needed and
- * change the dc mode so it only uses the available blocks.
- */
-int ff_h264_check_intra_pred_mode(H264Context *h, int mode, int is_chroma)
-{
- MpegEncContext *const s = &h->s;
- static const int8_t top[7] = { LEFT_DC_PRED8x8, 1, -1, -1 };
- static const int8_t left[7] = { TOP_DC_PRED8x8, -1, 2, -1, DC_128_PRED8x8 };
-
- if (mode > 6U) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "out of range intra chroma pred mode at %d %d\n",
- s->mb_x, s->mb_y);
- return -1;
- }
-
- if (!(h->top_samples_available & 0x8000)) {
- mode = top[mode];
- if (mode < 0) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "top block unavailable for requested intra mode at %d %d\n",
- s->mb_x, s->mb_y);
- return -1;
- }
- }
-
- if ((h->left_samples_available & 0x8080) != 0x8080) {
- mode = left[mode];
- if (is_chroma && (h->left_samples_available & 0x8080)) {
- // mad cow disease mode, aka MBAFF + constrained_intra_pred
- mode = ALZHEIMER_DC_L0T_PRED8x8 +
- (!(h->left_samples_available & 0x8000)) +
- 2 * (mode == DC_128_PRED8x8);
- }
- if (mode < 0) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "left block unavailable for requested intra mode at %d %d\n",
- s->mb_x, s->mb_y);
- return -1;
- }
- }
-
- return mode;
-}
-
-const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src,
- int *dst_length, int *consumed, int length)
-{
- int i, si, di;
- uint8_t *dst;
- int bufidx;
-
- // src[0]&0x80; // forbidden bit
- h->nal_ref_idc = src[0] >> 5;
- h->nal_unit_type = src[0] & 0x1F;
-
- src++;
- length--;
-
-#define STARTCODE_TEST \
- if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \
- if (src[i + 2] != 3) { \
- /* startcode, so we must be past the end */ \
- length = i; \
- } \
- break; \
- }
-#if HAVE_FAST_UNALIGNED
-#define FIND_FIRST_ZERO \
- if (i > 0 && !src[i]) \
- i--; \
- while (src[i]) \
- i++
-#if HAVE_FAST_64BIT
- for (i = 0; i + 1 < length; i += 9) {
- if (!((~AV_RN64A(src + i) &
- (AV_RN64A(src + i) - 0x0100010001000101ULL)) &
- 0x8000800080008080ULL))
- continue;
- FIND_FIRST_ZERO;
- STARTCODE_TEST;
- i -= 7;
- }
-#else
- for (i = 0; i + 1 < length; i += 5) {
- if (!((~AV_RN32A(src + i) &
- (AV_RN32A(src + i) - 0x01000101U)) &
- 0x80008080U))
- continue;
- FIND_FIRST_ZERO;
- STARTCODE_TEST;
- i -= 3;
- }
-#endif
-#else
- for (i = 0; i + 1 < length; i += 2) {
- if (src[i])
- continue;
- if (i > 0 && src[i - 1] == 0)
- i--;
- STARTCODE_TEST;
- }
-#endif
-
- // use second escape buffer for inter data
- bufidx = h->nal_unit_type == NAL_DPC ? 1 : 0;
-
- si = h->rbsp_buffer_size[bufidx];
- av_fast_padded_malloc(&h->rbsp_buffer[bufidx], &h->rbsp_buffer_size[bufidx], length+MAX_MBPAIR_SIZE);
- dst = h->rbsp_buffer[bufidx];
-
- if (dst == NULL)
- return NULL;
-
- if(i>=length-1){ //no escaped 0
- *dst_length= length;
- *consumed= length+1; //+1 for the header
- if(h->s.avctx->flags2 & CODEC_FLAG2_FAST){
- return src;
- }else{
- memcpy(dst, src, length);
- return dst;
- }
- }
-
- memcpy(dst, src, i);
- si = di = i;
- while (si + 2 < length) {
- // remove escapes (very rare 1:2^22)
- if (src[si + 2] > 3) {
- dst[di++] = src[si++];
- dst[di++] = src[si++];
- } else if (src[si] == 0 && src[si + 1] == 0) {
- if (src[si + 2] == 3) { // escape
- dst[di++] = 0;
- dst[di++] = 0;
- si += 3;
- continue;
- } else // next start code
- goto nsc;
- }
-
- dst[di++] = src[si++];
- }
- while (si < length)
- dst[di++] = src[si++];
-nsc:
-
- memset(dst + di, 0, FF_INPUT_BUFFER_PADDING_SIZE);
-
- *dst_length = di;
- *consumed = si + 1; // +1 for the header
- /* FIXME store exact number of bits in the getbitcontext
- * (it is needed for decoding) */
- return dst;
-}
-
-/**
- * Identify the exact end of the bitstream
- * @return the length of the trailing, or 0 if damaged
- */
-static int decode_rbsp_trailing(H264Context *h, const uint8_t *src)
-{
- int v = *src;
- int r;
-
- tprintf(h->s.avctx, "rbsp trailing %X\n", v);
-
- for (r = 1; r < 9; r++) {
- if (v & 1)
- return r;
- v >>= 1;
- }
- 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)
-{
- MpegEncContext *const s = &h->s;
- int my;
-
- y_offset += 16 * (s->mb_y >> MB_FIELD);
-
- 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->f.thread_opaque != s->current_picture.f.thread_opaque ||
- (ref->f.reference & 3) != s->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->f.thread_opaque != s->current_picture.f.thread_opaque ||
- (ref->f.reference & 3) != s->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)
-{
- MpegEncContext *const s = &h->s;
- const int mb_xy = h->mb_xy;
- const int mb_type = s->current_picture.f.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->f.reference - 1;
- int ref_field_picture = ref_pic->field_picture;
- int pic_height = 16 * s->mb_height >> ref_field_picture;
-
- row <<= MB_MBAFF;
- nrefs[list]--;
-
- if (!FIELD_PICTURE && ref_field_picture) { // frame referencing two fields
- ff_thread_await_progress(&ref_pic->f,
- FFMIN((row >> 1) - !(row & 1),
- pic_height - 1),
- 1);
- ff_thread_await_progress(&ref_pic->f,
- FFMIN((row >> 1), pic_height - 1),
- 0);
- } else if (FIELD_PICTURE && !ref_field_picture) { // field referencing one field of a frame
- ff_thread_await_progress(&ref_pic->f,
- FFMIN(row * 2 + ref_field,
- pic_height - 1),
- 0);
- } else if (FIELD_PICTURE) {
- ff_thread_await_progress(&ref_pic->f,
- FFMIN(row, pic_height - 1),
- ref_field);
- } else {
- ff_thread_await_progress(&ref_pic->f,
- 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)
-{
- MpegEncContext *const s = &h->s;
- 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);
- int 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 = h->emu_edge_width;
- int extra_height = h->emu_edge_height;
- int emu = 0;
- const int full_mx = mx >> 2;
- const int full_my = my >> 2;
- const int pic_width = 16 * s->mb_width;
- const int pic_height = 16 * s->mb_height >> MB_FIELD;
- 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) {
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
- src_y - (2 << pixel_shift) - 2 * h->mb_linesize,
- h->mb_linesize,
- 16 + 5, 16 + 5 /*FIXME*/, full_mx - 2,
- full_my - 2, pic_width, pic_height);
- src_y = s->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 && s->flags & CODEC_FLAG_GRAY)
- return;
-
- if (chroma_idc == 3 /* yuv444 */) {
- src_cb = pic->f.data[1] + offset;
- if (emu) {
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
- src_cb - (2 << pixel_shift) - 2 * h->mb_linesize,
- h->mb_linesize,
- 16 + 5, 16 + 5 /*FIXME*/,
- full_mx - 2, full_my - 2,
- pic_width, pic_height);
- src_cb = s->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) {
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
- src_cr - (2 << pixel_shift) - 2 * h->mb_linesize,
- h->mb_linesize,
- 16 + 5, 16 + 5 /*FIXME*/,
- full_mx - 2, full_my - 2,
- pic_width, pic_height);
- src_cr = s->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) {
- // chroma offset when predicting from a field of opposite parity
- my += 2 * ((s->mb_y & 1) - (pic->f.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) {
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer, src_cb, h->mb_uvlinesize,
- 9, 8 * chroma_idc + 1, (mx >> 3), (my >> ysh),
- pic_width >> 1, pic_height >> (chroma_idc == 1 /* yuv420 */));
- src_cb = s->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) {
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer, src_cr, h->mb_uvlinesize,
- 9, 8 * chroma_idc + 1, (mx >> 3), (my >> ysh),
- pic_width >> 1, pic_height >> (chroma_idc == 1 /* yuv420 */));
- src_cr = s->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)
-{
- MpegEncContext *const s = &h->s;
- 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 * s->mb_x;
- y_offset += 8 * (s->mb_y >> MB_FIELD);
-
- 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)
-{
- MpegEncContext *const s = &h->s;
- 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 * s->mb_x;
- y_offset += 8 * (s->mb_y >> MB_FIELD);
-
- 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][s->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 */
- MpegEncContext *const s = &h->s;
- const int refn = h->ref_cache[list][scan8[0]];
- if (refn >= 0) {
- const int mx = (h->mv_cache[list][scan8[0]][0] >> 2) + 16 * s->mb_x + 8;
- const int my = (h->mv_cache[list][scan8[0]][1] >> 2) + 16 * s->mb_y;
- uint8_t **src = h->ref_list[list][refn].f.data;
- int off = (mx << pixel_shift) +
- (my + (s->mb_x & 3) * 4) * h->mb_linesize +
- (64 << pixel_shift);
- s->vdsp.prefetch(src[0] + off, s->linesize, 4);
- if (chroma_idc == 3 /* yuv444 */) {
- s->vdsp.prefetch(src[1] + off, s->linesize, 4);
- s->vdsp.prefetch(src[2] + off, s->linesize, 4);
- } else {
- off= (((mx>>1)+64)<<pixel_shift) + ((my>>1) + (s->mb_x&7))*s->uvlinesize;
- s->vdsp.prefetch(src[1] + off, src[2] - src[1], 2);
- }
- }
-}
-
-static void free_tables(H264Context *h, int free_rbsp)
-{
- int i;
- H264Context *hx;
-
- av_freep(&h->intra4x4_pred_mode);
- av_freep(&h->chroma_pred_mode_table);
- av_freep(&h->cbp_table);
- av_freep(&h->mvd_table[0]);
- av_freep(&h->mvd_table[1]);
- av_freep(&h->direct_table);
- av_freep(&h->non_zero_count);
- av_freep(&h->slice_table_base);
- h->slice_table = NULL;
- av_freep(&h->list_counts);
-
- av_freep(&h->mb2b_xy);
- av_freep(&h->mb2br_xy);
-
- for (i = 0; i < MAX_THREADS; i++) {
- hx = h->thread_context[i];
- if (!hx)
- continue;
- av_freep(&hx->top_borders[1]);
- av_freep(&hx->top_borders[0]);
- av_freep(&hx->bipred_scratchpad);
- if (free_rbsp) {
- av_freep(&hx->rbsp_buffer[1]);
- av_freep(&hx->rbsp_buffer[0]);
- hx->rbsp_buffer_size[0] = 0;
- hx->rbsp_buffer_size[1] = 0;
- }
- if (i)
- av_freep(&h->thread_context[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;
- }
- }
-}
-
-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)
-{
- MpegEncContext *const s = &h->s;
- const int big_mb_num = s->mb_stride * (s->mb_height + 1);
- const int row_mb_num = 2*s->mb_stride*FFMAX(s->avctx->thread_count, 1);
- int x, y;
-
- FF_ALLOCZ_OR_GOTO(h->s.avctx, h->intra4x4_pred_mode,
- row_mb_num * 8 * sizeof(uint8_t), fail)
- FF_ALLOCZ_OR_GOTO(h->s.avctx, h->non_zero_count,
- big_mb_num * 48 * sizeof(uint8_t), fail)
- FF_ALLOCZ_OR_GOTO(h->s.avctx, h->slice_table_base,
- (big_mb_num + s->mb_stride) * sizeof(*h->slice_table_base), fail)
- FF_ALLOCZ_OR_GOTO(h->s.avctx, h->cbp_table,
- big_mb_num * sizeof(uint16_t), fail)
- FF_ALLOCZ_OR_GOTO(h->s.avctx, h->chroma_pred_mode_table,
- big_mb_num * sizeof(uint8_t), fail)
- FF_ALLOCZ_OR_GOTO(h->s.avctx, h->mvd_table[0],
- 16 * row_mb_num * sizeof(uint8_t), fail);
- FF_ALLOCZ_OR_GOTO(h->s.avctx, h->mvd_table[1],
- 16 * row_mb_num * sizeof(uint8_t), fail);
- FF_ALLOCZ_OR_GOTO(h->s.avctx, h->direct_table,
- 4 * big_mb_num * sizeof(uint8_t), fail);
- FF_ALLOCZ_OR_GOTO(h->s.avctx, h->list_counts,
- big_mb_num * sizeof(uint8_t), fail)
-
- memset(h->slice_table_base, -1,
- (big_mb_num + s->mb_stride) * sizeof(*h->slice_table_base));
- h->slice_table = h->slice_table_base + s->mb_stride * 2 + 1;
-
- FF_ALLOCZ_OR_GOTO(h->s.avctx, h->mb2b_xy,
- big_mb_num * sizeof(uint32_t), fail);
- FF_ALLOCZ_OR_GOTO(h->s.avctx, h->mb2br_xy,
- big_mb_num * sizeof(uint32_t), fail);
- for (y = 0; y < s->mb_height; y++)
- for (x = 0; x < s->mb_width; x++) {
- const int mb_xy = x + y * s->mb_stride;
- const int b_xy = 4 * x + 4 * y * h->b_stride;
-
- h->mb2b_xy[mb_xy] = b_xy;
- h->mb2br_xy[mb_xy] = 8 * (FMO ? mb_xy : (mb_xy % (2 * s->mb_stride)));
- }
-
- if (!h->dequant4_coeff[0])
- init_dequant_tables(h);
-
- return 0;
-
-fail:
- free_tables(h, 1);
- return -1;
-}
-
-/**
- * Mimic alloc_tables(), but for every context thread.
- */
-static void clone_tables(H264Context *dst, H264Context *src, int i)
-{
- MpegEncContext *const s = &src->s;
- dst->intra4x4_pred_mode = src->intra4x4_pred_mode + i * 8 * 2 * s->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 * s->mb_stride;
- dst->mvd_table[1] = src->mvd_table[1] + i * 8 * 2 * s->mb_stride;
- dst->direct_table = src->direct_table;
- dst->list_counts = src->list_counts;
- dst->bipred_scratchpad = NULL;
- ff_h264_pred_init(&dst->hpc, src->s.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)
-{
- FF_ALLOCZ_OR_GOTO(h->s.avctx, h->top_borders[0],
- h->s.mb_width * 16 * 3 * sizeof(uint8_t) * 2, fail)
- FF_ALLOCZ_OR_GOTO(h->s.avctx, h->top_borders[1],
- h->s.mb_width * 16 * 3 * sizeof(uint8_t) * 2, fail)
-
- h->ref_cache[0][scan8[5] + 1] =
- h->ref_cache[0][scan8[7] + 1] =
- h->ref_cache[0][scan8[13] + 1] =
- h->ref_cache[1][scan8[5] + 1] =
- h->ref_cache[1][scan8[7] + 1] =
- h->ref_cache[1][scan8[13] + 1] = PART_NOT_AVAILABLE;
-
- return 0;
-
-fail:
- return -1; // free_tables will clean up for us
-}
-
-static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size,
- int parse_extradata);
-
-static av_cold void common_init(H264Context *h)
-{
- MpegEncContext *const s = &h->s;
-
- s->width = s->avctx->width;
- s->height = s->avctx->height;
- s->codec_id = s->avctx->codec->id;
-
- s->avctx->bits_per_raw_sample = 8;
- h->cur_chroma_format_idc = 1;
-
- ff_h264dsp_init(&h->h264dsp, 8, 1);
- av_assert0(h->sps.bit_depth_chroma == 0);
- ff_h264chroma_init(&h->h264chroma, h->sps.bit_depth_chroma);
- ff_h264qpel_init(&h->h264qpel, 8);
- ff_h264_pred_init(&h->hpc, s->codec_id, 8, 1);
-
- h->dequant_coeff_pps = -1;
- s->unrestricted_mv = 1;
-
- s->dsp.dct_bits = 16;
- /* needed so that IDCT permutation is known early */
- ff_dsputil_init(&s->dsp, s->avctx);
- ff_videodsp_init(&s->vdsp, 8);
-
- memset(h->pps.scaling_matrix4, 16, 6 * 16 * sizeof(uint8_t));
- memset(h->pps.scaling_matrix8, 16, 2 * 64 * sizeof(uint8_t));
-}
-
-int ff_h264_decode_extradata(H264Context *h, const uint8_t *buf, int size)
-{
- AVCodecContext *avctx = h->s.avctx;
-
- if (!buf || size <= 0)
- return -1;
-
- if (buf[0] == 1) {
- int i, cnt, nalsize;
- const unsigned char *p = buf;
-
- h->is_avc = 1;
-
- if (size < 7) {
- av_log(avctx, AV_LOG_ERROR, "avcC too short\n");
- return -1;
- }
- /* sps and pps in the avcC always have length coded with 2 bytes,
- * so put a fake nal_length_size = 2 while parsing them */
- h->nal_length_size = 2;
- // Decode sps from avcC
- cnt = *(p + 5) & 0x1f; // Number of sps
- p += 6;
- for (i = 0; i < cnt; i++) {
- nalsize = AV_RB16(p) + 2;
- if(nalsize > size - (p-buf))
- return -1;
- if (decode_nal_units(h, p, nalsize, 1) < 0) {
- av_log(avctx, AV_LOG_ERROR,
- "Decoding sps %d from avcC failed\n", i);
- return -1;
- }
- p += nalsize;
- }
- // Decode pps from avcC
- cnt = *(p++); // Number of pps
- for (i = 0; i < cnt; i++) {
- nalsize = AV_RB16(p) + 2;
- if(nalsize > size - (p-buf))
- return -1;
- if (decode_nal_units(h, p, nalsize, 1) < 0) {
- av_log(avctx, AV_LOG_ERROR,
- "Decoding pps %d from avcC failed\n", i);
- return -1;
- }
- p += nalsize;
- }
- // Now store right nal length size, that will be used to parse all other nals
- h->nal_length_size = (buf[4] & 0x03) + 1;
- } else {
- h->is_avc = 0;
- if (decode_nal_units(h, buf, size, 1) < 0)
- return -1;
- }
- return size;
-}
-
-av_cold int ff_h264_decode_init(AVCodecContext *avctx)
-{
- H264Context *h = avctx->priv_data;
- MpegEncContext *const s = &h->s;
- int i;
-
- ff_MPV_decode_defaults(s);
-
- s->avctx = avctx;
- common_init(h);
-
- s->out_format = FMT_H264;
- s->workaround_bugs = avctx->workaround_bugs;
-
- /* set defaults */
- // s->decode_mb = ff_h263_decode_mb;
- s->quarter_sample = 1;
- if (!avctx->has_b_frames)
- s->low_delay = 1;
-
- avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
-
- ff_h264_decode_init_vlc();
-
- h->pixel_shift = 0;
- h->sps.bit_depth_luma = avctx->bits_per_raw_sample = 8;
-
- h->thread_context[0] = h;
- h->outputed_poc = h->next_outputed_poc = INT_MIN;
- for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++)
- h->last_pocs[i] = INT_MIN;
- h->prev_poc_msb = 1 << 16;
- h->prev_frame_num = -1;
- h->x264_build = -1;
- ff_h264_reset_sei(h);
- if (avctx->codec_id == AV_CODEC_ID_H264) {
- if (avctx->ticks_per_frame == 1) {
- if(s->avctx->time_base.den < INT_MAX/2) {
- s->avctx->time_base.den *= 2;
- } else
- s->avctx->time_base.num /= 2;
- }
- avctx->ticks_per_frame = 2;
- }
-
- if (avctx->extradata_size > 0 && avctx->extradata &&
- ff_h264_decode_extradata(h, avctx->extradata, avctx->extradata_size) < 0) {
- ff_h264_free_context(h);
- return -1;
- }
-
- if (h->sps.bitstream_restriction_flag &&
- s->avctx->has_b_frames < h->sps.num_reorder_frames) {
- s->avctx->has_b_frames = h->sps.num_reorder_frames;
- s->low_delay = 0;
- }
-
- ff_init_cabac_states();
-
- return 0;
-}
-
-#define IN_RANGE(a, b, size) (((a) >= (b)) && ((a) < ((b) + (size))))
-
-static void copy_picture_range(Picture **to, Picture **from, int count,
- MpegEncContext *new_base,
- MpegEncContext *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->picture,
- sizeof(Picture) * old_base->picture_count) ||
- !from[i]));
- to[i] = REBASE_PICTURE(from[i], new_base, old_base);
- }
-}
-
-static void 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 (from[i])
- memcpy(to[i], from[i], size);
- }
-}
-
-static int decode_init_thread_copy(AVCodecContext *avctx)
-{
- H264Context *h = avctx->priv_data;
-
- if (!avctx->internal->is_copy)
- return 0;
- memset(h->sps_buffers, 0, sizeof(h->sps_buffers));
- memset(h->pps_buffers, 0, sizeof(h->pps_buffers));
-
- h->s.context_initialized = 0;
-
- 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;
- MpegEncContext *const s = &h->s, *const s1 = &h1->s;
- int inited = s->context_initialized, err;
- int i;
-
- if (dst == src)
- return 0;
-
- if (inited &&
- (s->width != s1->width ||
- s->height != s1->height ||
- s->mb_width != s1->mb_width ||
- s->mb_height != s1->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)) {
-
- av_freep(&h->bipred_scratchpad);
-
- s->width = s1->width;
- s->height = s1->height;
- s->mb_height = s1->mb_height;
- h->b_stride = h1->b_stride;
- // SPS/PPS
- copy_parameter_set((void **)h->sps_buffers, (void **)h1->sps_buffers,
- MAX_SPS_COUNT, sizeof(SPS));
- h->sps = h1->sps;
- copy_parameter_set((void **)h->pps_buffers, (void **)h1->pps_buffers,
- MAX_PPS_COUNT, sizeof(PPS));
- h->pps = h1->pps;
-
- if ((err = h264_slice_header_init(h, 1)) < 0) {
- av_log(h->s.avctx, AV_LOG_ERROR, "h264_slice_header_init() failed");
- return err;
- }
- h->context_reinitialized = 1;
-
- 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;
- }
- /* update linesize on resize for h264. The h264 decoder doesn't
- * necessarily call ff_MPV_frame_start in the new thread */
- s->linesize = s1->linesize;
- s->uvlinesize = s1->uvlinesize;
-
- /* copy block_offset since frame_start may not be called */
- memcpy(h->block_offset, h1->block_offset, sizeof(h->block_offset));
-
- err = ff_mpeg_update_thread_context(dst, src);
- if (err)
- return err;
-
- 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);
-
- // copy all fields after MpegEnc, except mb
- memcpy(&h->s + 1, &h1->s + 1,
- offsetof(H264Context, mb) - sizeof(MpegEncContext));
- av_assert0(&h->cabac == &h->mb_padding + 1);
- memcpy(&h->cabac, &h1->cabac,
- sizeof(H264Context) - offsetof(H264Context, cabac));
- memset(h->sps_buffers, 0, sizeof(h->sps_buffers));
- memset(h->pps_buffers, 0, sizeof(h->pps_buffers));
-
- if (s1->context_initialized) {
- if (ff_h264_alloc_tables(h) < 0) {
- av_log(dst, AV_LOG_ERROR, "Could not allocate memory for h264\n");
- return AVERROR(ENOMEM);
- }
- context_init(h);
-
- }
-
- for (i = 0; i < 2; i++) {
- h->rbsp_buffer[i] = NULL;
- h->rbsp_buffer_size[i] = 0;
- }
- h->bipred_scratchpad = NULL;
-
- h->thread_context[0] = h;
- }
-
- /* frame_start may not be called for the next thread (if it's decoding
- * a bottom field) so this has to be allocated here */
- if (!h->bipred_scratchpad && s->linesize)
- h->bipred_scratchpad = av_malloc(16 * 6 * s->linesize);
-
- // extradata/NAL handling
- h->is_avc = h1->is_avc;
-
- // SPS/PPS
- copy_parameter_set((void **)h->sps_buffers, (void **)h1->sps_buffers,
- MAX_SPS_COUNT, sizeof(SPS));
- h->sps = h1->sps;
- copy_parameter_set((void **)h->pps_buffers, (void **)h1->pps_buffers,
- MAX_PPS_COUNT, sizeof(PPS));
- 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, ref_count, list_count);
- copy_fields(h, h1, ref2frm, intra_gb);
- copy_fields(h, h1, short_ref, cabac_init_idc);
-
- copy_picture_range(h->short_ref, h1->short_ref, 32, s, s1);
- copy_picture_range(h->long_ref, h1->long_ref, 32, s, s1);
- copy_picture_range(h->delayed_pic, h1->delayed_pic,
- MAX_DELAYED_PIC_COUNT + 2, s, s1);
-
- h->last_slice_type = h1->last_slice_type;
- h->sync = h1->sync;
-
- if (!s->current_picture_ptr)
- return 0;
-
- if (!s->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;
-
- return err;
-}
-
-int ff_h264_frame_start(H264Context *h)
-{
- MpegEncContext *const s = &h->s;
- int i;
- 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_MPV_frame_start(s, s->avctx) < 0)
- return -1;
- if(!h->sync)
- avpriv_color_frame(&h->s.current_picture_ptr->f, c);
- ff_er_frame_start(s);
- /*
- * ff_MPV_frame_start uses pict_type to derive key_frame.
- * This is incorrect for H.264; IDR markings must be used.
- * Zero here; IDR markings per slice in frame or fields are ORed in later.
- * See decode_nal_units().
- */
- s->current_picture_ptr->f.key_frame = 0;
- s->current_picture_ptr->sync = 0;
- s->current_picture_ptr->mmco_reset = 0;
-
- assert(s->linesize && s->uvlinesize);
-
- for (i = 0; i < 16; i++) {
- h->block_offset[i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 4 * s->linesize * ((scan8[i] - scan8[0]) >> 3);
- h->block_offset[48 + i] = (4 * ((scan8[i] - scan8[0]) & 7) << pixel_shift) + 8 * s->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 * s->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 * s->uvlinesize * ((scan8[i] - scan8[0]) >> 3);
- }
-
- /* 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 < s->slice_context_count; i++)
- if (h->thread_context[i] && !h->thread_context[i]->bipred_scratchpad)
- h->thread_context[i]->bipred_scratchpad = av_malloc(16 * 6 * s->linesize);
-
- /* Some macroblocks can be accessed before they're available in case
- * of lost slices, MBAFF or threading. */
- memset(h->slice_table, -1,
- (s->mb_height * s->mb_stride - 1) * sizeof(*h->slice_table));
-
- // s->decode = (s->flags & CODEC_FLAG_PSNR) || !s->encoding ||
- // s->current_picture.f.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().
- * SVQ3 as well as most other codecs have only last/next/current and thus
- * get released even with set reference, besides SVQ3 and others do not
- * mark frames as reference later "naturally". */
- if (s->codec_id != AV_CODEC_ID_SVQ3)
- s->current_picture_ptr->f.reference = 0;
-
- s->current_picture_ptr->field_poc[0] =
- s->current_picture_ptr->field_poc[1] = INT_MAX;
-
- h->next_output_pic = NULL;
-
- assert(s->current_picture_ptr->long_ref == 0);
-
- return 0;
-}
-
-/**
- * Run setup operations that must be run after slice header decoding.
- * This includes finding the next displayed frame.
- *
- * @param h h264 master context
- * @param setup_finished enough NALs have been read that we can call
- * ff_thread_finish_setup()
- */
-static void decode_postinit(H264Context *h, int setup_finished)
-{
- MpegEncContext *const s = &h->s;
- Picture *out = s->current_picture_ptr;
- Picture *cur = s->current_picture_ptr;
- int i, pics, out_of_order, out_idx;
-
- s->current_picture_ptr->f.qscale_type = FF_QSCALE_TYPE_H264;
- s->current_picture_ptr->f.pict_type = s->pict_type;
-
- if (h->next_output_pic)
- return;
-
- if (cur->field_poc[0] == INT_MAX || cur->field_poc[1] == INT_MAX) {
- /* FIXME: if we have two PAFF fields in one packet, we can't start
- * the next thread here. If we have one field per packet, we can.
- * The check in decode_nal_units() is not good enough to find this
- * yet, so we assume the worst for now. */
- // if (setup_finished)
- // ff_thread_finish_setup(s->avctx);
- return;
- }
-
- cur->f.interlaced_frame = 0;
- cur->f.repeat_pict = 0;
-
- /* Signal interlacing information externally. */
- /* Prioritize picture timing SEI information over used
- * decoding process if it exists. */
-
- if (h->sps.pic_struct_present_flag) {
- switch (h->sei_pic_struct) {
- case SEI_PIC_STRUCT_FRAME:
- break;
- case SEI_PIC_STRUCT_TOP_FIELD:
- case SEI_PIC_STRUCT_BOTTOM_FIELD:
- cur->f.interlaced_frame = 1;
- break;
- case SEI_PIC_STRUCT_TOP_BOTTOM:
- case SEI_PIC_STRUCT_BOTTOM_TOP:
- if (FIELD_OR_MBAFF_PICTURE)
- cur->f.interlaced_frame = 1;
- else
- // try to flag soft telecine progressive
- cur->f.interlaced_frame = h->prev_interlaced_frame;
- break;
- case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
- case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:
- /* Signal the possibility of telecined film externally
- * (pic_struct 5,6). From these hints, let the applications
- * decide if they apply deinterlacing. */
- cur->f.repeat_pict = 1;
- break;
- case SEI_PIC_STRUCT_FRAME_DOUBLING:
- cur->f.repeat_pict = 2;
- break;
- case SEI_PIC_STRUCT_FRAME_TRIPLING:
- cur->f.repeat_pict = 4;
- break;
- }
-
- if ((h->sei_ct_type & 3) &&
- h->sei_pic_struct <= SEI_PIC_STRUCT_BOTTOM_TOP)
- cur->f.interlaced_frame = (h->sei_ct_type & (1 << 1)) != 0;
- } else {
- /* Derive interlacing flag from used decoding process. */
- cur->f.interlaced_frame = FIELD_OR_MBAFF_PICTURE;
- }
- h->prev_interlaced_frame = cur->f.interlaced_frame;
-
- if (cur->field_poc[0] != cur->field_poc[1]) {
- /* Derive top_field_first from field pocs. */
- cur->f.top_field_first = cur->field_poc[0] < cur->field_poc[1];
- } else {
- if (cur->f.interlaced_frame || h->sps.pic_struct_present_flag) {
- /* Use picture timing SEI information. Even if it is a
- * information of a past frame, better than nothing. */
- if (h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM ||
- h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP)
- cur->f.top_field_first = 1;
- else
- cur->f.top_field_first = 0;
- } else {
- /* Most likely progressive */
- cur->f.top_field_first = 0;
- }
- }
-
- cur->mmco_reset = h->mmco_reset;
- h->mmco_reset = 0;
- // FIXME do something with unavailable reference frames
-
- /* Sort B-frames into display order */
-
- if (h->sps.bitstream_restriction_flag &&
- s->avctx->has_b_frames < h->sps.num_reorder_frames) {
- s->avctx->has_b_frames = h->sps.num_reorder_frames;
- s->low_delay = 0;
- }
-
- if (s->avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT &&
- !h->sps.bitstream_restriction_flag) {
- s->avctx->has_b_frames = MAX_DELAYED_PIC_COUNT - 1;
- s->low_delay = 0;
- }
-
- for (i = 0; 1; i++) {
- if(i == MAX_DELAYED_PIC_COUNT || cur->poc < h->last_pocs[i]){
- if(i)
- h->last_pocs[i-1] = cur->poc;
- break;
- } else if(i) {
- h->last_pocs[i-1]= h->last_pocs[i];
- }
- }
- out_of_order = MAX_DELAYED_PIC_COUNT - i;
- if( cur->f.pict_type == AV_PICTURE_TYPE_B
- || (h->last_pocs[MAX_DELAYED_PIC_COUNT-2] > INT_MIN && h->last_pocs[MAX_DELAYED_PIC_COUNT-1] - h->last_pocs[MAX_DELAYED_PIC_COUNT-2] > 2))
- out_of_order = FFMAX(out_of_order, 1);
- if (out_of_order == MAX_DELAYED_PIC_COUNT) {
- av_log(s->avctx, AV_LOG_VERBOSE, "Invalid POC %d<%d\n", cur->poc, h->last_pocs[0]);
- for (i = 1; i < MAX_DELAYED_PIC_COUNT; i++)
- h->last_pocs[i] = INT_MIN;
- h->last_pocs[0] = cur->poc;
- cur->mmco_reset = 1;
- } else if(s->avctx->has_b_frames < out_of_order && !h->sps.bitstream_restriction_flag){
- av_log(s->avctx, AV_LOG_VERBOSE, "Increasing reorder buffer to %d\n", out_of_order);
- s->avctx->has_b_frames = out_of_order;
- s->low_delay = 0;
- }
-
- pics = 0;
- while (h->delayed_pic[pics])
- pics++;
-
- av_assert0(pics <= MAX_DELAYED_PIC_COUNT);
-
- h->delayed_pic[pics++] = cur;
- if (cur->f.reference == 0)
- cur->f.reference = DELAYED_PIC_REF;
-
- out = h->delayed_pic[0];
- out_idx = 0;
- for (i = 1; h->delayed_pic[i] &&
- !h->delayed_pic[i]->f.key_frame &&
- !h->delayed_pic[i]->mmco_reset;
- i++)
- if (h->delayed_pic[i]->poc < out->poc) {
- out = h->delayed_pic[i];
- out_idx = i;
- }
- if (s->avctx->has_b_frames == 0 &&
- (h->delayed_pic[0]->f.key_frame || h->delayed_pic[0]->mmco_reset))
- h->next_outputed_poc = INT_MIN;
- out_of_order = out->poc < h->next_outputed_poc;
-
- if (out_of_order || pics > s->avctx->has_b_frames) {
- out->f.reference &= ~DELAYED_PIC_REF;
- // for frame threading, the owner must be the second field's thread or
- // else the first thread can release the picture and reuse it unsafely
- out->owner2 = s;
- for (i = out_idx; h->delayed_pic[i]; i++)
- h->delayed_pic[i] = h->delayed_pic[i + 1];
- }
- if (!out_of_order && pics > s->avctx->has_b_frames) {
- h->next_output_pic = out;
- if (out_idx == 0 && h->delayed_pic[0] && (h->delayed_pic[0]->f.key_frame || h->delayed_pic[0]->mmco_reset)) {
- h->next_outputed_poc = INT_MIN;
- } else
- h->next_outputed_poc = out->poc;
- } else {
- av_log(s->avctx, AV_LOG_DEBUG, "no picture %s\n", out_of_order ? "ooo" : "");
- }
-
- if (h->next_output_pic && h->next_output_pic->sync) {
- h->sync |= 2;
- }
-
- if (setup_finished)
- ff_thread_finish_setup(s->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)
-{
- MpegEncContext *const s = &h->s;
- uint8_t *top_border;
- int top_idx = 1;
- const int pixel_shift = h->pixel_shift;
- int chroma444 = CHROMA444;
- int chroma422 = CHROMA422;
-
- src_y -= linesize;
- src_cb -= uvlinesize;
- src_cr -= uvlinesize;
-
- if (!simple && FRAME_MBAFF) {
- if (s->mb_y & 1) {
- if (!MB_MBAFF) {
- top_border = h->top_borders[0][s->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 || !(s->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) {
- top_idx = 0;
- } else
- return;
- }
-
- top_border = h->top_borders[top_idx][s->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 || !(s->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)
-{
- MpegEncContext *const s = &h->s;
- int deblock_topleft;
- int deblock_top;
- int top_idx = 1;
- uint8_t *top_border_m1;
- uint8_t *top_border;
-
- if (!simple && FRAME_MBAFF) {
- if (s->mb_y & 1) {
- if (!MB_MBAFF)
- return;
- } else {
- top_idx = MB_MBAFF ? 0 : 1;
- }
- }
-
- if (h->deblocking_filter == 2) {
- deblock_topleft = h->slice_table[h->mb_xy - 1 - s->mb_stride] == h->slice_num;
- deblock_top = h->top_type;
- } else {
- deblock_topleft = (s->mb_x > 0);
- deblock_top = (s->mb_y > !!MB_FIELD);
- }
-
- 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][s->mb_x - 1];
- top_border = h->top_borders[top_idx][s->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 (s->mb_x + 1 < s->mb_width) {
- XCHG(h->top_borders[top_idx][s->mb_x + 1],
- src_y + (17 << pixel_shift), 1);
- }
- }
- if (simple || !CONFIG_GRAY || !(s->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 (s->mb_x + 1 < s->mb_width) {
- XCHG(h->top_borders[top_idx][s->mb_x + 1] + (16 << pixel_shift), src_cb + (17 << pixel_shift), 1);
- XCHG(h->top_borders[top_idx][s->mb_x + 1] + (32 << pixel_shift), src_cr + (17 << pixel_shift), 1);
- }
- } else {
- if (deblock_top) {
- 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)
-{
- MpegEncContext *const s = &h->s;
- 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 ? s->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;
- } 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;
- } 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(s->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)
-{
- MpegEncContext *const s = &h->s;
- 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(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
- : h->h264dsp.h264_add_pixels4;
- 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,
- s->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)
-{
- MpegEncContext *const s = &h->s;
- const int mb_xy = h->mb_xy;
- const int mb_type = s->current_picture.f.mb_type[mb_xy];
- int is_complex = CONFIG_SMALL || h->is_complex || IS_INTRA_PCM(mb_type) || s->qscale == 0;
-
- if (CHROMA444) {
- 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);
-}
-
-static int pred_weight_table(H264Context *h)
-{
- MpegEncContext *const s = &h->s;
- int list, i;
- int luma_def, chroma_def;
-
- h->use_weight = 0;
- h->use_weight_chroma = 0;
- h->luma_log2_weight_denom = get_ue_golomb(&s->gb);
- if (h->sps.chroma_format_idc)
- h->chroma_log2_weight_denom = get_ue_golomb(&s->gb);
- luma_def = 1 << h->luma_log2_weight_denom;
- chroma_def = 1 << h->chroma_log2_weight_denom;
-
- for (list = 0; list < 2; list++) {
- h->luma_weight_flag[list] = 0;
- h->chroma_weight_flag[list] = 0;
- for (i = 0; i < h->ref_count[list]; i++) {
- int luma_weight_flag, chroma_weight_flag;
-
- luma_weight_flag = get_bits1(&s->gb);
- if (luma_weight_flag) {
- h->luma_weight[i][list][0] = get_se_golomb(&s->gb);
- h->luma_weight[i][list][1] = get_se_golomb(&s->gb);
- if (h->luma_weight[i][list][0] != luma_def ||
- h->luma_weight[i][list][1] != 0) {
- h->use_weight = 1;
- h->luma_weight_flag[list] = 1;
- }
- } else {
- h->luma_weight[i][list][0] = luma_def;
- h->luma_weight[i][list][1] = 0;
- }
-
- if (h->sps.chroma_format_idc) {
- chroma_weight_flag = get_bits1(&s->gb);
- if (chroma_weight_flag) {
- int j;
- for (j = 0; j < 2; j++) {
- h->chroma_weight[i][list][j][0] = get_se_golomb(&s->gb);
- h->chroma_weight[i][list][j][1] = get_se_golomb(&s->gb);
- if (h->chroma_weight[i][list][j][0] != chroma_def ||
- h->chroma_weight[i][list][j][1] != 0) {
- h->use_weight_chroma = 1;
- h->chroma_weight_flag[list] = 1;
- }
- }
- } else {
- int j;
- for (j = 0; j < 2; j++) {
- h->chroma_weight[i][list][j][0] = chroma_def;
- h->chroma_weight[i][list][j][1] = 0;
- }
- }
- }
- }
- if (h->slice_type_nos != AV_PICTURE_TYPE_B)
- break;
- }
- h->use_weight = h->use_weight || h->use_weight_chroma;
- return 0;
-}
-
-/**
- * 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)
-{
- MpegEncContext *const s = &h->s;
- 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 (s->picture_structure == PICT_FRAME) {
- cur_poc = s->current_picture_ptr->poc;
- } else {
- cur_poc = s->current_picture_ptr->field_poc[s->picture_structure - 1];
- }
- if (h->ref_count[0] == 1 && h->ref_count[1] == 1 && !FRAME_MBAFF &&
- 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 = s->current_picture_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)
-{
- int i;
- ff_h264_remove_all_refs(h);
- h->prev_frame_num = 0;
- h->prev_frame_num_offset = 0;
- h->prev_poc_msb = 1<<16;
- h->prev_poc_lsb = 0;
- for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++)
- h->last_pocs[i] = INT_MIN;
-}
-
-/* forget old pics after a seek */
-static void flush_change(H264Context *h)
-{
- int i, j;
-
- h->outputed_poc = h->next_outputed_poc = INT_MIN;
- h->prev_interlaced_frame = 1;
- idr(h);
- h->prev_frame_num = -1;
- if (h->s.current_picture_ptr) {
- h->s.current_picture_ptr->f.reference = 0;
- for (j=i=0; h->delayed_pic[i]; i++)
- if (h->delayed_pic[i] != h->s.current_picture_ptr)
- h->delayed_pic[j++] = h->delayed_pic[i];
- h->delayed_pic[j] = NULL;
- }
- h->s.first_field = 0;
- memset(h->ref_list[0], 0, sizeof(h->ref_list[0]));
- memset(h->ref_list[1], 0, sizeof(h->ref_list[1]));
- memset(h->default_ref_list[0], 0, sizeof(h->default_ref_list[0]));
- memset(h->default_ref_list[1], 0, sizeof(h->default_ref_list[1]));
- ff_h264_reset_sei(h);
- h->recovery_frame= -1;
- h->sync= 0;
- h->list_count = 0;
- h->current_slice = 0;
-}
-
-/* forget old pics after a seek */
-static void flush_dpb(AVCodecContext *avctx)
-{
- H264Context *h = avctx->priv_data;
- int i;
-
- for (i = 0; i <= MAX_DELAYED_PIC_COUNT; i++) {
- if (h->delayed_pic[i])
- h->delayed_pic[i]->f.reference = 0;
- h->delayed_pic[i] = NULL;
- }
-
- flush_change(h);
- ff_mpeg_flush(avctx);
-}
-
-static int init_poc(H264Context *h)
-{
- MpegEncContext *const s = &h->s;
- const int max_frame_num = 1 << h->sps.log2_max_frame_num;
- int field_poc[2];
- Picture *cur = s->current_picture_ptr;
-
- h->frame_num_offset = h->prev_frame_num_offset;
- if (h->frame_num < h->prev_frame_num)
- h->frame_num_offset += max_frame_num;
-
- if (h->sps.poc_type == 0) {
- const int max_poc_lsb = 1 << h->sps.log2_max_poc_lsb;
-
- if (h->poc_lsb < h->prev_poc_lsb && h->prev_poc_lsb - h->poc_lsb >= max_poc_lsb / 2)
- h->poc_msb = h->prev_poc_msb + max_poc_lsb;
- else if (h->poc_lsb > h->prev_poc_lsb && h->prev_poc_lsb - h->poc_lsb < -max_poc_lsb / 2)
- h->poc_msb = h->prev_poc_msb - max_poc_lsb;
- else
- h->poc_msb = h->prev_poc_msb;
- field_poc[0] =
- field_poc[1] = h->poc_msb + h->poc_lsb;
- if (s->picture_structure == PICT_FRAME)
- field_poc[1] += h->delta_poc_bottom;
- } else if (h->sps.poc_type == 1) {
- int abs_frame_num, expected_delta_per_poc_cycle, expectedpoc;
- int i;
-
- if (h->sps.poc_cycle_length != 0)
- abs_frame_num = h->frame_num_offset + h->frame_num;
- else
- abs_frame_num = 0;
-
- if (h->nal_ref_idc == 0 && abs_frame_num > 0)
- abs_frame_num--;
-
- expected_delta_per_poc_cycle = 0;
- for (i = 0; i < h->sps.poc_cycle_length; i++)
- // FIXME integrate during sps parse
- expected_delta_per_poc_cycle += h->sps.offset_for_ref_frame[i];
-
- if (abs_frame_num > 0) {
- int poc_cycle_cnt = (abs_frame_num - 1) / h->sps.poc_cycle_length;
- int frame_num_in_poc_cycle = (abs_frame_num - 1) % h->sps.poc_cycle_length;
-
- expectedpoc = poc_cycle_cnt * expected_delta_per_poc_cycle;
- for (i = 0; i <= frame_num_in_poc_cycle; i++)
- expectedpoc = expectedpoc + h->sps.offset_for_ref_frame[i];
- } else
- expectedpoc = 0;
-
- if (h->nal_ref_idc == 0)
- expectedpoc = expectedpoc + h->sps.offset_for_non_ref_pic;
-
- field_poc[0] = expectedpoc + h->delta_poc[0];
- field_poc[1] = field_poc[0] + h->sps.offset_for_top_to_bottom_field;
-
- if (s->picture_structure == PICT_FRAME)
- field_poc[1] += h->delta_poc[1];
- } else {
- int poc = 2 * (h->frame_num_offset + h->frame_num);
-
- if (!h->nal_ref_idc)
- poc--;
-
- field_poc[0] = poc;
- field_poc[1] = poc;
- }
-
- if (s->picture_structure != PICT_BOTTOM_FIELD)
- s->current_picture_ptr->field_poc[0] = field_poc[0];
- if (s->picture_structure != PICT_TOP_FIELD)
- s->current_picture_ptr->field_poc[1] = field_poc[1];
- cur->poc = FFMIN(cur->field_poc[0], cur->field_poc[1]);
-
- return 0;
-}
-
-/**
- * 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)
-{
- MpegEncContext *const s = &h->s;
- AVCodecContext *const avctx = s->avctx;
- int err = 0;
- s->mb_y = 0;
-
- if (!in_setup && !s->droppable)
- ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX,
- s->picture_structure == PICT_BOTTOM_FIELD);
-
- if (CONFIG_H264_VDPAU_DECODER &&
- s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
- ff_vdpau_h264_set_reference_frames(s);
-
- if (in_setup || !(avctx->active_thread_type & FF_THREAD_FRAME)) {
- if (!s->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 &&
- s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
- ff_vdpau_h264_picture_complete(s);
-
- /*
- * 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 (!FIELD_PICTURE && h->current_slice && !h->sps.new)
- ff_er_frame_end(s);
-
- ff_MPV_frame_end(s);
-
- h->current_slice = 0;
-
- return err;
-}
-
-/**
- * Replicate H264 "master" context to thread contexts.
- */
-static int clone_slice(H264Context *dst, H264Context *src)
-{
- int ret;
-
- memcpy(dst->block_offset, src->block_offset, sizeof(dst->block_offset));
- dst->s.current_picture_ptr = src->s.current_picture_ptr;
- dst->s.current_picture = src->s.current_picture;
- dst->s.linesize = src->s.linesize;
- dst->s.uvlinesize = src->s.uvlinesize;
- dst->s.first_field = src->s.first_field;
-
- if (!dst->s.edge_emu_buffer &&
- (ret = ff_mpv_frame_size_alloc(&dst->s, dst->s.linesize))) {
- av_log(dst->s.avctx, AV_LOG_ERROR,
- "Failed to allocate scratch buffers\n");
- return ret;
- }
-
- 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
- *
- * @return profile as defined by FF_PROFILE_H264_*
- */
-int ff_h264_get_profile(SPS *sps)
-{
- int profile = sps->profile_idc;
-
- switch (sps->profile_idc) {
- case FF_PROFILE_H264_BASELINE:
- // constraint_set1_flag set to 1
- profile |= (sps->constraint_set_flags & 1 << 1) ? FF_PROFILE_H264_CONSTRAINED : 0;
- break;
- case FF_PROFILE_H264_HIGH_10:
- case FF_PROFILE_H264_HIGH_422:
- case FF_PROFILE_H264_HIGH_444_PREDICTIVE:
- // constraint_set3_flag set to 1
- profile |= (sps->constraint_set_flags & 1 << 3) ? FF_PROFILE_H264_INTRA : 0;
- break;
- }
-
- return profile;
-}
-
-static int h264_set_parameter_from_sps(H264Context *h)
-{
- MpegEncContext *s = &h->s;
-
- if (s->flags & CODEC_FLAG_LOW_DELAY ||
- (h->sps.bitstream_restriction_flag &&
- !h->sps.num_reorder_frames)) {
- if (s->avctx->has_b_frames > 1 || h->delayed_pic[0])
- av_log(h->s.avctx, AV_LOG_WARNING, "Delayed frames seen. "
- "Reenabling low delay requires a codec flush.\n");
- else
- s->low_delay = 1;
- }
-
- if (s->avctx->has_b_frames < 2)
- s->avctx->has_b_frames = !s->low_delay;
-
- if (s->avctx->bits_per_raw_sample != h->sps.bit_depth_luma ||
- h->cur_chroma_format_idc != h->sps.chroma_format_idc) {
- if (s->avctx->codec &&
- s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU &&
- (h->sps.bit_depth_luma != 8 || h->sps.chroma_format_idc > 1)) {
- av_log(s->avctx, AV_LOG_ERROR,
- "VDPAU decoding does not support video colorspace.\n");
- return AVERROR_INVALIDDATA;
- }
- if (h->sps.bit_depth_luma >= 8 && h->sps.bit_depth_luma <= 14 &&
- h->sps.bit_depth_luma != 11 && h->sps.bit_depth_luma != 13 &&
- (h->sps.bit_depth_luma != 9 || !CHROMA422)) {
- s->avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
- h->cur_chroma_format_idc = h->sps.chroma_format_idc;
- h->pixel_shift = h->sps.bit_depth_luma > 8;
-
- ff_h264dsp_init(&h->h264dsp, h->sps.bit_depth_luma,
- h->sps.chroma_format_idc);
- ff_h264chroma_init(&h->h264chroma, h->sps.bit_depth_chroma);
- ff_h264qpel_init(&h->h264qpel, h->sps.bit_depth_luma);
- ff_h264_pred_init(&h->hpc, s->codec_id, h->sps.bit_depth_luma,
- h->sps.chroma_format_idc);
- s->dsp.dct_bits = h->sps.bit_depth_luma > 8 ? 32 : 16;
- ff_dsputil_init(&s->dsp, s->avctx);
- ff_videodsp_init(&s->vdsp, h->sps.bit_depth_luma);
- } else {
- av_log(s->avctx, AV_LOG_ERROR, "Unsupported bit depth: %d\n",
- h->sps.bit_depth_luma);
- return AVERROR_INVALIDDATA;
- }
- }
- return 0;
-}
-
-static enum PixelFormat get_pixel_format(H264Context *h)
-{
- MpegEncContext *const s = &h->s;
- switch (h->sps.bit_depth_luma) {
- case 9:
- if (CHROMA444) {
- if (s->avctx->colorspace == AVCOL_SPC_RGB) {
- return AV_PIX_FMT_GBRP9;
- } else
- return AV_PIX_FMT_YUV444P9;
- } else if (CHROMA422)
- return AV_PIX_FMT_YUV422P9;
- else
- return AV_PIX_FMT_YUV420P9;
- break;
- case 10:
- if (CHROMA444) {
- if (s->avctx->colorspace == AVCOL_SPC_RGB) {
- return AV_PIX_FMT_GBRP10;
- } else
- return AV_PIX_FMT_YUV444P10;
- } else if (CHROMA422)
- return AV_PIX_FMT_YUV422P10;
- else
- return AV_PIX_FMT_YUV420P10;
- break;
- case 12:
- if (CHROMA444) {
- if (s->avctx->colorspace == AVCOL_SPC_RGB) {
- return AV_PIX_FMT_GBRP12;
- } else
- return AV_PIX_FMT_YUV444P12;
- } else if (CHROMA422)
- return AV_PIX_FMT_YUV422P12;
- else
- return AV_PIX_FMT_YUV420P12;
- break;
- case 14:
- if (CHROMA444) {
- if (s->avctx->colorspace == AVCOL_SPC_RGB) {
- return AV_PIX_FMT_GBRP14;
- } else
- return AV_PIX_FMT_YUV444P14;
- } else if (CHROMA422)
- return AV_PIX_FMT_YUV422P14;
- else
- return AV_PIX_FMT_YUV420P14;
- break;
- case 8:
- if (CHROMA444) {
- if (s->avctx->colorspace == AVCOL_SPC_RGB) {
- av_log(h->s.avctx, AV_LOG_DEBUG, "Detected GBR colorspace.\n");
- return AV_PIX_FMT_GBR24P;
- } else if (s->avctx->colorspace == AVCOL_SPC_YCGCO) {
- av_log(h->s.avctx, AV_LOG_WARNING, "Detected unsupported YCgCo colorspace.\n");
- }
- return s->avctx->color_range == AVCOL_RANGE_JPEG ? AV_PIX_FMT_YUVJ444P
- : AV_PIX_FMT_YUV444P;
- } else if (CHROMA422) {
- return s->avctx->color_range == AVCOL_RANGE_JPEG ? AV_PIX_FMT_YUVJ422P
- : AV_PIX_FMT_YUV422P;
- } else {
- return s->avctx->get_format(s->avctx, s->avctx->codec->pix_fmts ?
- s->avctx->codec->pix_fmts :
- s->avctx->color_range == AVCOL_RANGE_JPEG ?
- hwaccel_pixfmt_list_h264_jpeg_420 :
- ff_hwaccel_pixfmt_list_420);
- }
- break;
- default:
- av_log(s->avctx, AV_LOG_ERROR,
- "Unsupported bit depth: %d\n", h->sps.bit_depth_luma);
- return AVERROR_INVALIDDATA;
- }
-}
-
-static int h264_slice_header_init(H264Context *h, int reinit)
-{
- MpegEncContext *const s = &h->s;
- int i, ret;
-
- if( FFALIGN(s->avctx->width , 16 ) == s->width
- && FFALIGN(s->avctx->height, 16*(2 - h->sps.frame_mbs_only_flag)) == s->height
- && !h->sps.crop_right && !h->sps.crop_bottom
- && (s->avctx->width != s->width || s->avctx->height && s->height)
- ) {
- av_log(h->s.avctx, AV_LOG_DEBUG, "Using externally provided dimensions\n");
- s->avctx->coded_width = s->width;
- s->avctx->coded_height = s->height;
- } else{
- avcodec_set_dimensions(s->avctx, s->width, s->height);
- s->avctx->width -= (2>>CHROMA444)*FFMIN(h->sps.crop_right, (8<<CHROMA444)-1);
- s->avctx->height -= (1<<s->chroma_y_shift)*FFMIN(h->sps.crop_bottom, (16>>s->chroma_y_shift)-1) * (2 - h->sps.frame_mbs_only_flag);
- }
-
- s->avctx->sample_aspect_ratio = h->sps.sar;
- av_assert0(s->avctx->sample_aspect_ratio.den);
-
- if (h->sps.timing_info_present_flag) {
- int64_t den = h->sps.time_scale;
- if (h->x264_build < 44U)
- den *= 2;
- av_reduce(&s->avctx->time_base.num, &s->avctx->time_base.den,
- h->sps.num_units_in_tick, den, 1 << 30);
- }
-
- s->avctx->hwaccel = ff_find_hwaccel(s->avctx->codec->id, s->avctx->pix_fmt);
-
- if (reinit) {
- free_tables(h, 0);
- if ((ret = ff_MPV_common_frame_size_change(s)) < 0) {
- av_log(h->s.avctx, AV_LOG_ERROR, "ff_MPV_common_frame_size_change() failed.\n");
- return ret;
- }
- } else {
- if ((ret = ff_MPV_common_init(s)) < 0) {
- av_log(h->s.avctx, AV_LOG_ERROR, "ff_MPV_common_init() failed.\n");
- return ret;
- }
- }
- s->first_field = 0;
- h->prev_interlaced_frame = 1;
-
- init_scan_tables(h);
- if (ff_h264_alloc_tables(h) < 0) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "Could not allocate memory for h264\n");
- return AVERROR(ENOMEM);
- }
-
- if (!HAVE_THREADS || !(s->avctx->active_thread_type & FF_THREAD_SLICE)) {
- if (context_init(h) < 0) {
- av_log(h->s.avctx, AV_LOG_ERROR, "context_init() failed.\n");
- return -1;
- }
- } else {
- for (i = 1; i < s->slice_context_count; i++) {
- H264Context *c;
- c = h->thread_context[i] = av_malloc(sizeof(H264Context));
- memcpy(c, h->s.thread_context[i], sizeof(MpegEncContext));
- memset(&c->s + 1, 0, sizeof(H264Context) - sizeof(MpegEncContext));
- 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;
- init_scan_tables(c);
- clone_tables(c, h, i);
- }
-
- for (i = 0; i < s->slice_context_count; i++)
- if (context_init(h->thread_context[i]) < 0) {
- av_log(h->s.avctx, AV_LOG_ERROR, "context_init() failed.\n");
- return -1;
- }
- }
-
- 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)
-{
- MpegEncContext *const s = &h->s;
- MpegEncContext *const s0 = &h0->s;
- unsigned int first_mb_in_slice;
- unsigned int pps_id;
- int num_ref_idx_active_override_flag, ret;
- unsigned int slice_type, tmp, i, j;
- int default_ref_list_done = 0;
- int last_pic_structure, last_pic_droppable;
- int must_reinit;
- int needs_reinit = 0;
-
- s->me.qpel_put = h->h264qpel.put_h264_qpel_pixels_tab;
- s->me.qpel_avg = h->h264qpel.avg_h264_qpel_pixels_tab;
-
- first_mb_in_slice = get_ue_golomb_long(&s->gb);
-
- if (first_mb_in_slice == 0) { // FIXME better field boundary detection
- if (h0->current_slice && FIELD_PICTURE) {
- field_end(h, 1);
- }
-
- h0->current_slice = 0;
- if (!s0->first_field) {
- if (s->current_picture_ptr && !s->droppable &&
- s->current_picture_ptr->owner2 == s) {
- ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX,
- s->picture_structure == PICT_BOTTOM_FIELD);
- }
- s->current_picture_ptr = NULL;
- }
- }
-
- slice_type = get_ue_golomb_31(&s->gb);
- if (slice_type > 9) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "slice type too large (%d) at %d %d\n",
- slice_type, s->mb_x, s->mb_y);
- return -1;
- }
- 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];
- if (slice_type == AV_PICTURE_TYPE_I ||
- (h0->current_slice != 0 && slice_type == h0->last_slice_type)) {
- default_ref_list_done = 1;
- }
- h->slice_type = slice_type;
- h->slice_type_nos = slice_type & 3;
-
- // to make a few old functions happy, it's wrong though
- s->pict_type = h->slice_type;
-
- pps_id = get_ue_golomb(&s->gb);
- if (pps_id >= MAX_PPS_COUNT) {
- av_log(h->s.avctx, AV_LOG_ERROR, "pps_id %d out of range\n", pps_id);
- return -1;
- }
- if (!h0->pps_buffers[pps_id]) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "non-existing PPS %u referenced\n",
- pps_id);
- return -1;
- }
- h->pps = *h0->pps_buffers[pps_id];
-
- if (!h0->sps_buffers[h->pps.sps_id]) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "non-existing SPS %u referenced\n",
- h->pps.sps_id);
- return -1;
- }
-
- if (h->pps.sps_id != h->current_sps_id ||
- h->context_reinitialized ||
- h0->sps_buffers[h->pps.sps_id]->new) {
- SPS *new_sps = h0->sps_buffers[h->pps.sps_id];
-
- h0->sps_buffers[h->pps.sps_id]->new = 0;
-
- if (h->sps.chroma_format_idc != new_sps->chroma_format_idc ||
- h->sps.bit_depth_luma != new_sps->bit_depth_luma)
- needs_reinit = 1;
-
- h->current_sps_id = h->pps.sps_id;
- h->sps = *h0->sps_buffers[h->pps.sps_id];
-
- if (s->mb_width != h->sps.mb_width ||
- s->mb_height != h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag) ||
- s->avctx->bits_per_raw_sample != h->sps.bit_depth_luma ||
- h->cur_chroma_format_idc != h->sps.chroma_format_idc
- )
- needs_reinit = 1;
-
- if ((ret = h264_set_parameter_from_sps(h)) < 0)
- return ret;
- }
-
- s->avctx->profile = ff_h264_get_profile(&h->sps);
- s->avctx->level = h->sps.level_idc;
- s->avctx->refs = h->sps.ref_frame_count;
-
- must_reinit = (s->context_initialized &&
- ( 16*h->sps.mb_width != s->avctx->coded_width
- || 16*h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag) != s->avctx->coded_height
- || s->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, s->avctx->sample_aspect_ratio)));
- if (h0->s.avctx->pix_fmt != get_pixel_format(h0))
- must_reinit = 1;
-
- s->mb_width = h->sps.mb_width;
- s->mb_height = h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag);
-
- h->b_stride = s->mb_width * 4;
-
- s->chroma_y_shift = h->sps.chroma_format_idc <= 1; // 400 uses yuv420p
-
- s->width = 16 * s->mb_width;
- s->height = 16 * s->mb_height;
-
- if (h->sps.video_signal_type_present_flag) {
- s->avctx->color_range = h->sps.full_range>0 ? AVCOL_RANGE_JPEG
- : AVCOL_RANGE_MPEG;
- if (h->sps.colour_description_present_flag) {
- if (s->avctx->colorspace != h->sps.colorspace)
- needs_reinit = 1;
- s->avctx->color_primaries = h->sps.color_primaries;
- s->avctx->color_trc = h->sps.color_trc;
- s->avctx->colorspace = h->sps.colorspace;
- }
- }
-
- if (s->context_initialized &&
- (
- needs_reinit ||
- must_reinit)) {
-
- if (h != h0) {
- av_log(s->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)) < 0)
- return ret;
- s->avctx->pix_fmt = ret;
-
- av_log(h->s.avctx, AV_LOG_INFO, "Reinit context to %dx%d, "
- "pix_fmt: %d\n", s->width, s->height, s->avctx->pix_fmt);
-
- if ((ret = h264_slice_header_init(h, 1)) < 0) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "h264_slice_header_init() failed\n");
- return ret;
- }
- h->context_reinitialized = 1;
- }
- if (!s->context_initialized) {
- if (h != h0) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "Cannot (re-)initialize context during parallel decoding.\n");
- return -1;
- }
-
- if ((ret = get_pixel_format(h)) < 0)
- return ret;
- s->avctx->pix_fmt = ret;
-
- if ((ret = h264_slice_header_init(h, 0)) < 0) {
- av_log(h->s.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(&s->gb, h->sps.log2_max_frame_num);
-
- h->mb_mbaff = 0;
- h->mb_aff_frame = 0;
- last_pic_structure = s0->picture_structure;
- last_pic_droppable = s0->droppable;
- s->droppable = h->nal_ref_idc == 0;
- if (h->sps.frame_mbs_only_flag) {
- s->picture_structure = PICT_FRAME;
- } else {
- if (!h->sps.direct_8x8_inference_flag && slice_type == AV_PICTURE_TYPE_B) {
- av_log(h->s.avctx, AV_LOG_ERROR, "This stream was generated by a broken encoder, invalid 8x8 inference\n");
- return -1;
- }
- if (get_bits1(&s->gb)) { // field_pic_flag
- s->picture_structure = PICT_TOP_FIELD + get_bits1(&s->gb); // bottom_field_flag
- } else {
- s->picture_structure = PICT_FRAME;
- h->mb_aff_frame = h->sps.mb_aff;
- }
- }
- h->mb_field_decoding_flag = s->picture_structure != PICT_FRAME;
-
- if (h0->current_slice != 0) {
- if (last_pic_structure != s->picture_structure ||
- last_pic_droppable != s->droppable) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "Changing field mode (%d -> %d) between slices is not allowed\n",
- last_pic_structure, s->picture_structure);
- s->picture_structure = last_pic_structure;
- s->droppable = last_pic_droppable;
- return AVERROR_INVALIDDATA;
- } else if (!s0->current_picture_ptr) {
- av_log(s->avctx, AV_LOG_ERROR,
- "unset current_picture_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 && h->prev_frame_num >= 0) {
- 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 s->current_picture_ptr. */
- if (s0->first_field) {
- assert(s0->current_picture_ptr);
- assert(s0->current_picture_ptr->f.data[0]);
- assert(s0->current_picture_ptr->f.reference != DELAYED_PIC_REF);
-
- /* Mark old field/frame as completed */
- if (!last_pic_droppable && s0->current_picture_ptr->owner2 == s0) {
- ff_thread_report_progress(&s0->current_picture_ptr->f, INT_MAX,
- last_pic_structure == PICT_BOTTOM_FIELD);
- }
-
- /* figure out if we have a complementary field pair */
- if (!FIELD_PICTURE || s->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_droppable && last_pic_structure != PICT_FRAME) {
- ff_thread_report_progress(&s0->current_picture_ptr->f, INT_MAX,
- last_pic_structure == PICT_TOP_FIELD);
- }
- } else {
- if (s0->current_picture_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_droppable && last_pic_structure != PICT_FRAME) {
- ff_thread_report_progress(&s0->current_picture_ptr->f, INT_MAX,
- last_pic_structure == PICT_TOP_FIELD);
- }
- } else {
- /* Second field in complementary pair */
- if (!((last_pic_structure == PICT_TOP_FIELD &&
- s->picture_structure == PICT_BOTTOM_FIELD) ||
- (last_pic_structure == PICT_BOTTOM_FIELD &&
- s->picture_structure == PICT_TOP_FIELD))) {
- av_log(s->avctx, AV_LOG_ERROR,
- "Invalid field mode combination %d/%d\n",
- last_pic_structure, s->picture_structure);
- s->picture_structure = last_pic_structure;
- s->droppable = last_pic_droppable;
- return AVERROR_INVALIDDATA;
- } else if (last_pic_droppable != s->droppable) {
- av_log(s->avctx, AV_LOG_ERROR,
- "Cannot combine reference and non-reference fields in the same frame\n");
- av_log_ask_for_sample(s->avctx, NULL);
- s->picture_structure = last_pic_structure;
- s->droppable = last_pic_droppable;
- return AVERROR_PATCHWELCOME;
- }
-
- /* Take ownership of this buffer. Note that if another thread owned
- * the first field of this buffer, we're not operating on that pointer,
- * so the original thread is still responsible for reporting progress
- * on that first field (or if that was us, we just did that above).
- * By taking ownership, we assign responsibility to ourselves to
- * report progress on the second field. */
- s0->current_picture_ptr->owner2 = s0;
- }
- }
- }
-
- while (h->frame_num != h->prev_frame_num && h->prev_frame_num >= 0 && !s0->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->s.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;
- if (ff_h264_frame_start(h) < 0)
- return -1;
- h->prev_frame_num++;
- h->prev_frame_num %= 1 << h->sps.log2_max_frame_num;
- s->current_picture_ptr->frame_num = h->prev_frame_num;
- ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, 0);
- ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, 1);
- if ((ret = ff_generate_sliding_window_mmcos(h, 1)) < 0 &&
- s->avctx->err_recognition & AV_EF_EXPLODE)
- return ret;
- if (ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index) < 0 &&
- (s->avctx->err_recognition & AV_EF_EXPLODE))
- return AVERROR_INVALIDDATA;
- /* 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 doesn't copy padding for out-of-frame motion vectors. Given we're
- * concealing a lost frame, this probably isn't 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,
- s->avctx->pix_fmt, s->mb_width * 16, s->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 (s0->first_field) {
- assert(s0->current_picture_ptr);
- assert(s0->current_picture_ptr->f.data[0]);
- assert(s0->current_picture_ptr->f.reference != DELAYED_PIC_REF);
-
- /* figure out if we have a complementary field pair */
- if (!FIELD_PICTURE || s->picture_structure == last_pic_structure) {
- /* Previous field is unmatched. Don't display it, but let it
- * remain for reference if marked as such. */
- s0->current_picture_ptr = NULL;
- s0->first_field = FIELD_PICTURE;
- } else {
- if (s0->current_picture_ptr->frame_num != h->frame_num) {
- ff_thread_report_progress((AVFrame*)s0->current_picture_ptr, INT_MAX,
- s0->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. */
- s0->first_field = 1;
- s0->current_picture_ptr = NULL;
- } else {
- /* Second field in complementary pair */
- s0->first_field = 0;
- }
- }
- } else {
- /* Frame or first field in a potentially complementary pair */
- s0->first_field = FIELD_PICTURE;
- }
-
- if (!FIELD_PICTURE || s0->first_field) {
- if (ff_h264_frame_start(h) < 0) {
- s0->first_field = 0;
- return -1;
- }
- } else {
- ff_release_unused_pictures(s, 0);
- }
- }
- if (h != h0 && (ret = clone_slice(h, h0)) < 0)
- return ret;
-
- s->current_picture_ptr->frame_num = h->frame_num; // FIXME frame_num cleanup
-
- av_assert1(s->mb_num == s->mb_width * s->mb_height);
- if (first_mb_in_slice << FIELD_OR_MBAFF_PICTURE >= s->mb_num ||
- first_mb_in_slice >= s->mb_num) {
- av_log(h->s.avctx, AV_LOG_ERROR, "first_mb_in_slice overflow\n");
- return -1;
- }
- s->resync_mb_x = s->mb_x = first_mb_in_slice % s->mb_width;
- s->resync_mb_y = s->mb_y = (first_mb_in_slice / s->mb_width) << FIELD_OR_MBAFF_PICTURE;
- if (s->picture_structure == PICT_BOTTOM_FIELD)
- s->resync_mb_y = s->mb_y = s->mb_y + 1;
- av_assert1(s->mb_y < s->mb_height);
-
- if (s->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(&s->gb); /* idr_pic_id */
-
- if (h->sps.poc_type == 0) {
- h->poc_lsb = get_bits(&s->gb, h->sps.log2_max_poc_lsb);
-
- if (h->pps.pic_order_present == 1 && s->picture_structure == PICT_FRAME)
- h->delta_poc_bottom = get_se_golomb(&s->gb);
- }
-
- if (h->sps.poc_type == 1 && !h->sps.delta_pic_order_always_zero_flag) {
- h->delta_poc[0] = get_se_golomb(&s->gb);
-
- if (h->pps.pic_order_present == 1 && s->picture_structure == PICT_FRAME)
- h->delta_poc[1] = get_se_golomb(&s->gb);
- }
-
- init_poc(h);
-
- if (h->pps.redundant_pic_cnt_present)
- h->redundant_pic_count = get_ue_golomb(&s->gb);
-
- // 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];
-
- if (h->slice_type_nos != AV_PICTURE_TYPE_I) {
- unsigned max[2];
- max[0] = max[1] = s->picture_structure == PICT_FRAME ? 15 : 31;
-
- if (h->slice_type_nos == AV_PICTURE_TYPE_B)
- h->direct_spatial_mv_pred = get_bits1(&s->gb);
- num_ref_idx_active_override_flag = get_bits1(&s->gb);
-
- if (num_ref_idx_active_override_flag) {
- h->ref_count[0] = get_ue_golomb(&s->gb) + 1;
- if (h->slice_type_nos == AV_PICTURE_TYPE_B) {
- h->ref_count[1] = get_ue_golomb(&s->gb) + 1;
- } else
- // full range is spec-ok in this case, even for frames
- h->ref_count[1] = 1;
- }
-
- if (h->ref_count[0]-1 > max[0] || h->ref_count[1]-1 > max[1]){
- av_log(h->s.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]);
- h->ref_count[0] = h->ref_count[1] = 1;
- return AVERROR_INVALIDDATA;
- }
-
- if (h->slice_type_nos == AV_PICTURE_TYPE_B)
- h->list_count = 2;
- else
- h->list_count = 1;
- } else
- h->ref_count[1]= h->ref_count[0]= h->list_count= 0;
-
- if (!default_ref_list_done)
- ff_h264_fill_default_ref_list(h);
-
- if (h->slice_type_nos != AV_PICTURE_TYPE_I &&
- ff_h264_decode_ref_pic_list_reordering(h) < 0) {
- h->ref_count[1] = h->ref_count[0] = 0;
- return -1;
- }
-
- if (h->slice_type_nos != AV_PICTURE_TYPE_I) {
- s->last_picture_ptr = &h->ref_list[0][0];
- s->last_picture_ptr->owner2 = s;
- ff_copy_picture(&s->last_picture, s->last_picture_ptr);
- }
- if (h->slice_type_nos == AV_PICTURE_TYPE_B) {
- s->next_picture_ptr = &h->ref_list[1][0];
- s->next_picture_ptr->owner2 = s;
- ff_copy_picture(&s->next_picture, s->next_picture_ptr);
- }
-
- 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))
- 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 &&
- ff_h264_decode_ref_pic_marking(h0, &s->gb,
- !(s->avctx->active_thread_type & FF_THREAD_FRAME) ||
- h0->current_slice == 0) < 0 &&
- (s->avctx->err_recognition & AV_EF_EXPLODE))
- return AVERROR_INVALIDDATA;
-
- if (FRAME_MBAFF) {
- 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(&s->gb);
- if (tmp > 2) {
- av_log(s->avctx, AV_LOG_ERROR, "cabac_init_idc overflow\n");
- return -1;
- }
- h->cabac_init_idc = tmp;
- }
-
- h->last_qscale_diff = 0;
- tmp = h->pps.init_qp + get_se_golomb(&s->gb);
- if (tmp > 51 + 6 * (h->sps.bit_depth_luma - 8)) {
- av_log(s->avctx, AV_LOG_ERROR, "QP %u out of range\n", tmp);
- return -1;
- }
- s->qscale = tmp;
- h->chroma_qp[0] = get_chroma_qp(h, 0, s->qscale);
- h->chroma_qp[1] = get_chroma_qp(h, 1, s->qscale);
- // FIXME qscale / qp ... stuff
- if (h->slice_type == AV_PICTURE_TYPE_SP)
- get_bits1(&s->gb); /* sp_for_switch_flag */
- if (h->slice_type == AV_PICTURE_TYPE_SP ||
- h->slice_type == AV_PICTURE_TYPE_SI)
- get_se_golomb(&s->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(&s->gb);
- if (tmp > 2) {
- av_log(s->avctx, AV_LOG_ERROR,
- "deblocking_filter_idc %u out of range\n", tmp);
- return -1;
- }
- 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(&s->gb) << 1;
- h->slice_beta_offset += get_se_golomb(&s->gb) << 1;
- if (h->slice_alpha_c0_offset > 104U ||
- h->slice_beta_offset > 104U) {
- av_log(s->avctx, AV_LOG_ERROR,
- "deblocking filter parameters %d %d out of range\n",
- h->slice_alpha_c0_offset, h->slice_beta_offset);
- return -1;
- }
- }
- }
-
- if (s->avctx->skip_loop_filter >= AVDISCARD_ALL ||
- (s->avctx->skip_loop_filter >= AVDISCARD_NONKEY &&
- h->slice_type_nos != AV_PICTURE_TYPE_I) ||
- (s->avctx->skip_loop_filter >= AVDISCARD_BIDIR &&
- h->slice_type_nos == AV_PICTURE_TYPE_B) ||
- (s->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 (s->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(s->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->s.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;
- h->slice_num = ++h0->current_slice;
-
- if (h->slice_num)
- h0->slice_row[(h->slice_num-1)&(MAX_SLICES-1)]= s->resync_mb_y;
- if ( h0->slice_row[h->slice_num&(MAX_SLICES-1)] + 3 >= s->resync_mb_y
- && h0->slice_row[h->slice_num&(MAX_SLICES-1)] <= s->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(s->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 (h->ref_list[j][i].f.data[0]) {
- int k;
- uint8_t *base = h->ref_list[j][i].f.base[0];
- for (k = 0; k < h->short_ref_count; k++)
- if (h->short_ref[k]->f.base[0] == base) {
- id_list[i] = k;
- break;
- }
- for (k = 0; k < h->long_ref_count; k++)
- if (h->long_ref[k] && h->long_ref[k]->f.base[0] == base) {
- 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].f.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].f.reference & 3);
- }
-
- // FIXME: fix draw_edges + PAFF + frame threads
- h->emu_edge_width = (s->flags & CODEC_FLAG_EMU_EDGE ||
- (!h->sps.frame_mbs_only_flag &&
- s->avctx->active_thread_type))
- ? 0 : 16;
- h->emu_edge_height = (FRAME_MBAFF || FIELD_PICTURE) ? 0 : h->emu_edge_width;
-
- if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
- av_log(h->s.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,
- (s->picture_structure == PICT_FRAME ? "F" : s->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,
- s->current_picture_ptr->field_poc[0],
- s->current_picture_ptr->field_poc[1],
- h->ref_count[0], h->ref_count[1],
- s->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") : "");
- }
-
- 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 -1;
- }
-}
-
-static av_always_inline void fill_filter_caches_inter(H264Context *h,
- MpegEncContext *const s,
- 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 ? 20 : 2));
- AV_COPY128(mv_dst - 1 * 8, s->current_picture.f.motion_val[list][b_xy + 0]);
- ref_cache[0 - 1 * 8] =
- ref_cache[1 - 1 * 8] = ref2frm[list][s->current_picture.f.ref_index[list][b8_xy + 0]];
- ref_cache[2 - 1 * 8] =
- ref_cache[3 - 1 * 8] = ref2frm[list][s->current_picture.f.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 ? 20 : 2));
- AV_COPY32(mv_dst - 1 + 0, s->current_picture.f.motion_val[list][b_xy + b_stride * 0]);
- AV_COPY32(mv_dst - 1 + 8, s->current_picture.f.motion_val[list][b_xy + b_stride * 1]);
- AV_COPY32(mv_dst - 1 + 16, s->current_picture.f.motion_val[list][b_xy + b_stride * 2]);
- AV_COPY32(mv_dst - 1 + 24, s->current_picture.f.motion_val[list][b_xy + b_stride * 3]);
- ref_cache[-1 + 0] =
- ref_cache[-1 + 8] = ref2frm[list][s->current_picture.f.ref_index[list][b8_xy + 2 * 0]];
- ref_cache[-1 + 16] =
- ref_cache[-1 + 24] = ref2frm[list][s->current_picture.f.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 = &s->current_picture.f.ref_index[list][4 * mb_xy];
- int (*ref2frm)[64] = (void*)(h->ref2frm[h->slice_num & (MAX_SLICES - 1)][0] + (MB_MBAFF ? 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] = &s->current_picture.f.motion_val[list][4 * s->mb_x + 4 * s->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)
-{
- MpegEncContext *const s = &h->s;
- 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 - (s->mb_stride << MB_FIELD);
-
- /* 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) {
- const int left_mb_field_flag = IS_INTERLACED(s->current_picture.f.mb_type[mb_xy - 1]);
- const int curr_mb_field_flag = IS_INTERLACED(mb_type);
- if (s->mb_y & 1) {
- if (left_mb_field_flag != curr_mb_field_flag)
- left_xy[LTOP] -= s->mb_stride;
- } else {
- if (curr_mb_field_flag)
- top_xy += s->mb_stride &
- (((s->current_picture.f.mb_type[top_xy] >> 7) & 1) - 1);
- if (left_mb_field_flag != curr_mb_field_flag)
- left_xy[LBOT] += s->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 = s->current_picture.f.qscale_table[mb_xy];
- if (qp <= qp_thresh &&
- (left_xy[LTOP] < 0 ||
- ((qp + s->current_picture.f.qscale_table[left_xy[LTOP]] + 1) >> 1) <= qp_thresh) &&
- (top_xy < 0 ||
- ((qp + s->current_picture.f.qscale_table[top_xy] + 1) >> 1) <= qp_thresh)) {
- if (!FRAME_MBAFF)
- return 1;
- if ((left_xy[LTOP] < 0 ||
- ((qp + s->current_picture.f.qscale_table[left_xy[LBOT]] + 1) >> 1) <= qp_thresh) &&
- (top_xy < s->mb_stride ||
- ((qp + s->current_picture.f.qscale_table[top_xy - s->mb_stride] + 1) >> 1) <= qp_thresh))
- return 1;
- }
- }
-
- top_type = s->current_picture.f.mb_type[top_xy];
- left_type[LTOP] = s->current_picture.f.mb_type[left_xy[LTOP]];
- left_type[LBOT] = s->current_picture.f.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, s, mb_type, top_xy, left_xy,
- top_type, left_type, mb_xy, 0);
- if (h->list_count == 2)
- fill_filter_caches_inter(h, s, 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->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)
-{
- MpegEncContext *const s = &h->s;
- uint8_t *dest_y, *dest_cb, *dest_cr;
- int linesize, uvlinesize, mb_x, mb_y;
- const int end_mb_y = s->mb_y + FRAME_MBAFF;
- const int old_slice_type = h->slice_type;
- const int pixel_shift = h->pixel_shift;
- const int block_h = 16 >> s->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; mb_y <= end_mb_y; mb_y++) {
- int mb_xy, mb_type;
- mb_xy = h->mb_xy = mb_x + mb_y * s->mb_stride;
- h->slice_num = h->slice_table[mb_xy];
- mb_type = s->current_picture.f.mb_type[mb_xy];
- h->list_count = h->list_counts[mb_xy];
-
- if (FRAME_MBAFF)
- h->mb_mbaff =
- h->mb_field_decoding_flag = !!IS_INTERLACED(mb_type);
-
- s->mb_x = mb_x;
- s->mb_y = mb_y;
- dest_y = s->current_picture.f.data[0] +
- ((mb_x << pixel_shift) + mb_y * s->linesize) * 16;
- dest_cb = s->current_picture.f.data[1] +
- (mb_x << pixel_shift) * (8 << CHROMA444) +
- mb_y * s->uvlinesize * block_h;
- dest_cr = s->current_picture.f.data[2] +
- (mb_x << pixel_shift) * (8 << CHROMA444) +
- mb_y * s->uvlinesize * block_h;
- // FIXME simplify above
-
- if (MB_FIELD) {
- linesize = h->mb_linesize = s->linesize * 2;
- uvlinesize = h->mb_uvlinesize = s->uvlinesize * 2;
- if (mb_y & 1) { // FIXME move out of this function?
- dest_y -= s->linesize * 15;
- dest_cb -= s->uvlinesize * (block_h - 1);
- dest_cr -= s->uvlinesize * (block_h - 1);
- }
- } else {
- linesize = h->mb_linesize = s->linesize;
- uvlinesize = h->mb_uvlinesize = s->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, s->current_picture.f.qscale_table[mb_xy]);
- h->chroma_qp[1] = get_chroma_qp(h, 1, s->current_picture.f.qscale_table[mb_xy]);
-
- if (FRAME_MBAFF) {
- 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;
- s->mb_x = end_x;
- s->mb_y = end_mb_y - FRAME_MBAFF;
- h->chroma_qp[0] = get_chroma_qp(h, 0, s->qscale);
- h->chroma_qp[1] = get_chroma_qp(h, 1, s->qscale);
-}
-
-static void predict_field_decoding_flag(H264Context *h)
-{
- MpegEncContext *const s = &h->s;
- const int mb_xy = s->mb_x + s->mb_y * s->mb_stride;
- int mb_type = (h->slice_table[mb_xy - 1] == h->slice_num) ?
- s->current_picture.f.mb_type[mb_xy - 1] :
- (h->slice_table[mb_xy - s->mb_stride] == h->slice_num) ?
- s->current_picture.f.mb_type[mb_xy - s->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)
-{
- MpegEncContext *const s = &h->s;
- int top = 16 * (s->mb_y >> FIELD_PICTURE);
- int pic_height = 16 * s->mb_height >> FIELD_PICTURE;
- int height = 16 << FRAME_MBAFF;
- int deblock_border = (16 + 4) << FRAME_MBAFF;
-
- if (h->deblocking_filter) {
- if ((top + height) >= pic_height)
- height += deblock_border;
- top -= deblock_border;
- }
-
- if (top >= pic_height || (top + height) < h->emu_edge_height)
- return;
-
- height = FFMIN(height, pic_height - top);
- if (top < h->emu_edge_height) {
- height = top + height;
- top = 0;
- }
-
- ff_draw_horiz_band(s, top, height);
-
- if (s->droppable)
- return;
-
- ff_thread_report_progress(&s->current_picture_ptr->f, top + height - 1,
- s->picture_structure == PICT_BOTTOM_FIELD);
-}
-
-static int decode_slice(struct AVCodecContext *avctx, void *arg)
-{
- H264Context *h = *(void **)arg;
- MpegEncContext *const s = &h->s;
- int lf_x_start = s->mb_x;
-
- s->mb_skip_run = -1;
-
- av_assert0(h->block_offset[15] == (4 * ((scan8[15] - scan8[0]) & 7) << h->pixel_shift) + 4 * s->linesize * ((scan8[15] - scan8[0]) >> 3));
-
- h->is_complex = FRAME_MBAFF || s->picture_structure != PICT_FRAME ||
- s->codec_id != AV_CODEC_ID_H264 ||
- (CONFIG_GRAY && (s->flags & CODEC_FLAG_GRAY));
-
- if (h->pps.cabac) {
- /* realign */
- align_get_bits(&s->gb);
-
- /* init cabac */
- ff_init_cabac_decoder(&h->cabac,
- s->gb.buffer + get_bits_count(&s->gb) / 8,
- (get_bits_left(&s->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) {
- s->mb_y++;
-
- ret = ff_h264_decode_mb_cabac(h);
-
- if (ret >= 0)
- ff_h264_hl_decode_mb(h);
- s->mb_y--;
- }
- eos = get_cabac_terminate(&h->cabac);
-
- if ((s->workaround_bugs & FF_BUG_TRUNCATED) &&
- h->cabac.bytestream > h->cabac.bytestream_end + 2) {
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x - 1,
- s->mb_y, ER_MB_END);
- if (s->mb_x >= lf_x_start)
- loop_filter(h, lf_x_start, s->mb_x + 1);
- return 0;
- }
- if (h->cabac.bytestream > h->cabac.bytestream_end + 2 )
- av_log(h->s.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->s.avctx, AV_LOG_ERROR,
- "error while decoding MB %d %d, bytestream (%td)\n",
- s->mb_x, s->mb_y,
- h->cabac.bytestream_end - h->cabac.bytestream);
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x,
- s->mb_y, ER_MB_ERROR);
- return -1;
- }
-
- if (++s->mb_x >= s->mb_width) {
- loop_filter(h, lf_x_start, s->mb_x);
- s->mb_x = lf_x_start = 0;
- decode_finish_row(h);
- ++s->mb_y;
- if (FIELD_OR_MBAFF_PICTURE) {
- ++s->mb_y;
- if (FRAME_MBAFF && s->mb_y < s->mb_height)
- predict_field_decoding_flag(h);
- }
- }
-
- if (eos || s->mb_y >= s->mb_height) {
- tprintf(s->avctx, "slice end %d %d\n",
- get_bits_count(&s->gb), s->gb.size_in_bits);
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x - 1,
- s->mb_y, ER_MB_END);
- if (s->mb_x > lf_x_start)
- loop_filter(h, lf_x_start, s->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) {
- s->mb_y++;
- ret = ff_h264_decode_mb_cavlc(h);
-
- if (ret >= 0)
- ff_h264_hl_decode_mb(h);
- s->mb_y--;
- }
-
- if (ret < 0) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "error while decoding MB %d %d\n", s->mb_x, s->mb_y);
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x,
- s->mb_y, ER_MB_ERROR);
- return -1;
- }
-
- if (++s->mb_x >= s->mb_width) {
- loop_filter(h, lf_x_start, s->mb_x);
- s->mb_x = lf_x_start = 0;
- decode_finish_row(h);
- ++s->mb_y;
- if (FIELD_OR_MBAFF_PICTURE) {
- ++s->mb_y;
- if (FRAME_MBAFF && s->mb_y < s->mb_height)
- predict_field_decoding_flag(h);
- }
- if (s->mb_y >= s->mb_height) {
- tprintf(s->avctx, "slice end %d %d\n",
- get_bits_count(&s->gb), s->gb.size_in_bits);
-
- if ( get_bits_left(&s->gb) == 0
- || get_bits_left(&s->gb) > 0 && !(s->avctx->err_recognition & AV_EF_AGGRESSIVE)) {
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y,
- s->mb_x - 1, s->mb_y,
- ER_MB_END);
-
- return 0;
- } else {
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y,
- s->mb_x, s->mb_y,
- ER_MB_END);
-
- return -1;
- }
- }
- }
-
- if (get_bits_left(&s->gb) <= 0 && s->mb_skip_run <= 0) {
- tprintf(s->avctx, "slice end %d %d\n",
- get_bits_count(&s->gb), s->gb.size_in_bits);
- if (get_bits_left(&s->gb) == 0) {
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y,
- s->mb_x - 1, s->mb_y,
- ER_MB_END);
- if (s->mb_x > lf_x_start)
- loop_filter(h, lf_x_start, s->mb_x);
-
- return 0;
- } else {
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x,
- s->mb_y, ER_MB_ERROR);
-
- return -1;
- }
- }
- }
- }
-}
-
-/**
- * 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)
-{
- MpegEncContext *const s = &h->s;
- AVCodecContext *const avctx = s->avctx;
- H264Context *hx;
- int i;
-
- if (s->avctx->hwaccel ||
- s->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];
- hx->s.err_recognition = avctx->err_recognition;
- hx->s.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];
- s->mb_x = hx->s.mb_x;
- s->mb_y = hx->s.mb_y;
- s->droppable = hx->s.droppable;
- s->picture_structure = hx->s.picture_structure;
- for (i = 1; i < context_count; i++)
- h->s.error_count += h->thread_context[i]->s.error_count;
- }
-
- return 0;
-}
-
-static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size,
- int parse_extradata)
-{
- MpegEncContext *const s = &h->s;
- AVCodecContext *const avctx = s->avctx;
- H264Context *hx; ///< thread context
- int buf_index;
- int 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;
-
- h->nal_unit_type= 0;
-
- if(!s->slice_context_count)
- s->slice_context_count= 1;
- h->max_contexts = s->slice_context_count;
- if (!(s->flags2 & CODEC_FLAG2_CHUNKS)) {
- h->current_slice = 0;
- if (!s->first_field)
- s->current_picture_ptr = NULL;
- ff_h264_reset_sei(h);
- }
-
- if (h->nal_length_size == 4) {
- if (buf_size > 8 && AV_RB32(buf) == 1 && AV_RB32(buf+5) > (unsigned)buf_size) {
- h->is_avc = 0;
- }else if(buf_size > 3 && AV_RB32(buf) > 1 && AV_RB32(buf) <= (unsigned)buf_size)
- h->is_avc = 1;
- }
-
- for (; pass <= 1; pass++) {
- buf_index = 0;
- context_count = 0;
- next_avc = h->is_avc ? 0 : buf_size;
- nal_index = 0;
- for (;;) {
- int consumed;
- int dst_length;
- int bit_length;
- const uint8_t *ptr;
- int i, nalsize = 0;
- int err;
-
- if (buf_index >= next_avc) {
- if (buf_index >= buf_size - h->nal_length_size)
- 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->s.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;
- break;
- }
-
- buf_index += 3;
- if (buf_index >= next_avc)
- continue;
- }
-
- hx = h->thread_context[context_count];
-
- ptr = ff_h264_decode_nal(hx, buf + buf_index, &dst_length,
- &consumed, next_avc - buf_index);
- if (ptr == NULL || dst_length < 0) {
- buf_index = -1;
- goto end;
- }
- i = buf_index + consumed;
- if ((s->workaround_bugs & FF_BUG_AUTODETECT) && i + 3 < next_avc &&
- buf[i] == 0x00 && buf[i + 1] == 0x00 &&
- buf[i + 2] == 0x01 && buf[i + 3] == 0xE0)
- s->workaround_bugs |= FF_BUG_TRUNCATED;
-
- if (!(s->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));
-
- if (s->avctx->debug & FF_DEBUG_STARTCODE)
- av_log(h->s.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);
-
- if (h->is_avc && (nalsize != consumed) && nalsize)
- av_log(h->s.avctx, AV_LOG_DEBUG,
- "AVC: Consumed only %d bytes instead of %d\n",
- consumed, nalsize);
-
- 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->s.gb, ptr, bit_length);
- if (!get_ue_golomb(&hx->s.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;
- }
-
- // FIXME do not discard SEI id
- if (avctx->skip_frame >= AVDISCARD_NONREF && h->nal_ref_idc == 0)
- continue;
-
-again:
- /* Ignore per frame NAL unit type during extradata
- * parsing. Decoding slices is not possible in codec init
- * with frame-mt */
- if (parse_extradata) {
- switch (hx->nal_unit_type) {
- case NAL_IDR_SLICE:
- case NAL_SLICE:
- case NAL_DPA:
- case NAL_DPB:
- case NAL_DPC:
- case NAL_AUXILIARY_SLICE:
- av_log(h->s.avctx, AV_LOG_WARNING, "Ignoring NAL %d in global header/extradata\n", hx->nal_unit_type);
- hx->nal_unit_type = NAL_FF_IGNORE;
- }
- }
-
- err = 0;
-
- switch (hx->nal_unit_type) {
- case NAL_IDR_SLICE:
- if (first_slice != NAL_IDR_SLICE) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "Invalid mix of idr and non-idr slices\n");
- buf_index = -1;
- goto end;
- }
- if(!idr_cleared)
- idr(h); // FIXME ensure we don't lose some frames if there is reordering
- idr_cleared = 1;
- case NAL_SLICE:
- init_get_bits(&hx->s.gb, ptr, bit_length);
- hx->intra_gb_ptr =
- hx->inter_gb_ptr = &hx->s.gb;
- hx->s.data_partitioning = 0;
-
- if ((err = decode_slice_header(hx, h)))
- break;
-
- if (h->sei_recovery_frame_cnt >= 0 && (h->frame_num != h->sei_recovery_frame_cnt || hx->slice_type_nos != AV_PICTURE_TYPE_I))
- h->valid_recovery_point = 1;
-
- if ( h->sei_recovery_frame_cnt >= 0
- && ( h->recovery_frame<0
- || ((h->recovery_frame - h->frame_num) & ((1 << h->sps.log2_max_frame_num)-1)) > h->sei_recovery_frame_cnt)) {
- h->recovery_frame = (h->frame_num + h->sei_recovery_frame_cnt) %
- (1 << h->sps.log2_max_frame_num);
-
- if (!h->valid_recovery_point)
- h->recovery_frame = h->frame_num;
- }
-
- s->current_picture_ptr->f.key_frame |=
- (hx->nal_unit_type == NAL_IDR_SLICE);
-
- if (h->recovery_frame == h->frame_num) {
- s->current_picture_ptr->sync |= 1;
- h->recovery_frame = -1;
- }
-
- h->sync |= !!s->current_picture_ptr->f.key_frame;
- h->sync |= 3*!!(s->flags2 & CODEC_FLAG2_SHOW_ALL);
- s->current_picture_ptr->sync |= h->sync;
-
- if (h->current_slice == 1) {
- if (!(s->flags2 & CODEC_FLAG2_CHUNKS))
- decode_postinit(h, nal_index >= nals_needed);
-
- if (s->avctx->hwaccel &&
- s->avctx->hwaccel->start_frame(s->avctx, NULL, 0) < 0)
- return -1;
- if (CONFIG_H264_VDPAU_DECODER &&
- s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
- ff_vdpau_h264_picture_start(s);
- }
-
- if (hx->redundant_pic_count == 0 &&
- (avctx->skip_frame < AVDISCARD_NONREF ||
- hx->nal_ref_idc) &&
- (avctx->skip_frame < AVDISCARD_BIDIR ||
- hx->slice_type_nos != AV_PICTURE_TYPE_B) &&
- (avctx->skip_frame < AVDISCARD_NONKEY ||
- hx->slice_type_nos == AV_PICTURE_TYPE_I) &&
- avctx->skip_frame < AVDISCARD_ALL) {
- if (avctx->hwaccel) {
- if (avctx->hwaccel->decode_slice(avctx,
- &buf[buf_index - consumed],
- consumed) < 0)
- return -1;
- } else if (CONFIG_H264_VDPAU_DECODER &&
- s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) {
- static const uint8_t start_code[] = {
- 0x00, 0x00, 0x01 };
- ff_vdpau_add_data_chunk(s, start_code,
- sizeof(start_code));
- ff_vdpau_add_data_chunk(s, &buf[buf_index - consumed],
- consumed);
- } else
- context_count++;
- }
- break;
- case NAL_DPA:
- init_get_bits(&hx->s.gb, ptr, bit_length);
- hx->intra_gb_ptr =
- hx->inter_gb_ptr = NULL;
-
- if ((err = decode_slice_header(hx, h)) < 0)
- break;
-
- hx->s.data_partitioning = 1;
- break;
- case NAL_DPB:
- init_get_bits(&hx->intra_gb, ptr, bit_length);
- hx->intra_gb_ptr = &hx->intra_gb;
- break;
- case NAL_DPC:
- init_get_bits(&hx->inter_gb, ptr, bit_length);
- hx->inter_gb_ptr = &hx->inter_gb;
-
- av_log(h->s.avctx, AV_LOG_ERROR, "Partitioned H.264 support is incomplete\n");
- break;
-
- if (hx->redundant_pic_count == 0 &&
- hx->intra_gb_ptr &&
- hx->s.data_partitioning &&
- s->current_picture_ptr &&
- s->context_initialized &&
- (avctx->skip_frame < AVDISCARD_NONREF || hx->nal_ref_idc) &&
- (avctx->skip_frame < AVDISCARD_BIDIR ||
- hx->slice_type_nos != AV_PICTURE_TYPE_B) &&
- (avctx->skip_frame < AVDISCARD_NONKEY ||
- hx->slice_type_nos == AV_PICTURE_TYPE_I) &&
- avctx->skip_frame < AVDISCARD_ALL)
- context_count++;
- break;
- case NAL_SEI:
- init_get_bits(&s->gb, ptr, bit_length);
- ff_h264_decode_sei(h);
- break;
- case NAL_SPS:
- init_get_bits(&s->gb, ptr, bit_length);
- if (ff_h264_decode_seq_parameter_set(h) < 0 && (h->is_avc ? (nalsize != consumed) && nalsize : 1)) {
- av_log(h->s.avctx, AV_LOG_DEBUG,
- "SPS decoding failure, trying again with the complete NAL\n");
- if (h->is_avc)
- av_assert0(next_avc - buf_index + consumed == nalsize);
- if ((next_avc - buf_index + consumed - 1) >= INT_MAX/8)
- break;
- init_get_bits(&s->gb, &buf[buf_index + 1 - consumed],
- 8*(next_avc - buf_index + consumed - 1));
- ff_h264_decode_seq_parameter_set(h);
- }
-
- break;
- case NAL_PPS:
- init_get_bits(&s->gb, ptr, bit_length);
- ff_h264_decode_picture_parameter_set(h, bit_length);
- break;
- case NAL_AUD:
- case NAL_END_SEQUENCE:
- case NAL_END_STREAM:
- case NAL_FILLER_DATA:
- case NAL_SPS_EXT:
- case NAL_AUXILIARY_SLICE:
- break;
- case NAL_FF_IGNORE:
- break;
- default:
- av_log(avctx, AV_LOG_DEBUG, "Unknown NAL code: %d (%d bits)\n",
- hx->nal_unit_type, bit_length);
- }
-
- if (context_count == h->max_contexts) {
- execute_decode_slices(h, context_count);
- context_count = 0;
- }
-
- if (err < 0)
- av_log(h->s.avctx, AV_LOG_ERROR, "decode_slice_header error\n");
- 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
- * run in parallel mode this should not be an issue. */
- h->nal_unit_type = hx->nal_unit_type;
- h->nal_ref_idc = hx->nal_ref_idc;
- hx = h;
- goto again;
- }
- }
- }
- if (context_count)
- execute_decode_slices(h, context_count);
-
-end:
- /* clean up */
- if (s->current_picture_ptr && s->current_picture_ptr->owner2 == s &&
- !s->droppable) {
- ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX,
- s->picture_structure == PICT_BOTTOM_FIELD);
- }
-
- return buf_index;
-}
-
-/**
- * Return the number of bytes consumed for building the current frame.
- */
-static int get_consumed_bytes(MpegEncContext *s, int pos, int buf_size)
-{
- if (pos == 0)
- pos = 1; // avoid infinite loops (i doubt that is needed but ...)
- if (pos + 10 > buf_size)
- pos = buf_size; // oops ;)
-
- return pos;
-}
-
-static int 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;
- MpegEncContext *s = &h->s;
- AVFrame *pict = data;
- int buf_index = 0;
- Picture *out;
- int i, out_idx;
-
- s->flags = avctx->flags;
- s->flags2 = avctx->flags2;
-
- /* end of stream, output what is still in the buffers */
- if (buf_size == 0) {
- out:
-
- s->current_picture_ptr = NULL;
- s->first_field = 0;
-
- // FIXME factorize this with the output code below
- out = h->delayed_pic[0];
- out_idx = 0;
- for (i = 1;
- h->delayed_pic[i] &&
- !h->delayed_pic[i]->f.key_frame &&
- !h->delayed_pic[i]->mmco_reset;
- i++)
- if (h->delayed_pic[i]->poc < out->poc) {
- out = h->delayed_pic[i];
- out_idx = i;
- }
-
- for (i = out_idx; h->delayed_pic[i]; i++)
- h->delayed_pic[i] = h->delayed_pic[i + 1];
-
- if (out) {
- out->f.reference &= ~DELAYED_PIC_REF;
- *got_frame = 1;
- *pict = out->f;
- }
-
- return buf_index;
- }
- if(h->is_avc && buf_size >= 9 && buf[0]==1 && buf[2]==0 && (buf[4]&0xFC)==0xFC && (buf[5]&0x1F) && buf[8]==0x67){
- int cnt= buf[5]&0x1f;
- const uint8_t *p= buf+6;
- while(cnt--){
- int nalsize= AV_RB16(p) + 2;
- if(nalsize > buf_size - (p-buf) || p[2]!=0x67)
- goto not_extra;
- p += nalsize;
- }
- cnt = *(p++);
- if(!cnt)
- goto not_extra;
- while(cnt--){
- int nalsize= AV_RB16(p) + 2;
- if(nalsize > buf_size - (p-buf) || p[2]!=0x68)
- goto not_extra;
- p += nalsize;
- }
-
- return ff_h264_decode_extradata(h, buf, buf_size);
- }
-not_extra:
-
- buf_index = decode_nal_units(h, buf, buf_size, 0);
- if (buf_index < 0)
- return -1;
-
- if (!s->current_picture_ptr && h->nal_unit_type == NAL_END_SEQUENCE) {
- av_assert0(buf_index <= buf_size);
- goto out;
- }
-
- if (!(s->flags2 & CODEC_FLAG2_CHUNKS) && !s->current_picture_ptr) {
- if (avctx->skip_frame >= AVDISCARD_NONREF ||
- buf_size >= 4 && !memcmp("Q264", buf, 4))
- return buf_size;
- av_log(avctx, AV_LOG_ERROR, "no frame!\n");
- return -1;
- }
-
- if (!(s->flags2 & CODEC_FLAG2_CHUNKS) ||
- (s->mb_y >= s->mb_height && s->mb_height)) {
- if (s->flags2 & CODEC_FLAG2_CHUNKS)
- decode_postinit(h, 1);
-
- field_end(h, 0);
- h->context_reinitialized = 0;
-
- /* Wait for second field. */
- *got_frame = 0;
- if (h->next_output_pic && (h->next_output_pic->sync || h->sync>1)) {
- *got_frame = 1;
- *pict = h->next_output_pic->f;
- }
- }
-
- assert(pict->data[0] || !*got_frame);
- ff_print_debug_info(s, pict);
-
- /* ffdshow custom code (begin) */
- pict->h264_poc_decoded = h->poc_lsb + h->poc_msb;
- if (h->next_output_pic)
- pict->h264_poc_outputed = h->next_output_pic->poc;
- else
- pict->h264_poc_outputed = INT_MIN;
- pict->h264_frame_num_decoded = h-> frame_num;
- pict->h264_max_frame_num = 1 << h->sps.log2_max_frame_num;
- /* ffdshow custom code (end) */
-
- return get_consumed_bytes(s, buf_index, buf_size);
-}
-
-av_cold void ff_h264_free_context(H264Context *h)
-{
- int i;
-
- free_tables(h, 1); // FIXME cleanup init stuff perhaps
-
- 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);
-}
-
-static av_cold int h264_decode_end(AVCodecContext *avctx)
-{
- H264Context *h = avctx->priv_data;
- MpegEncContext *s = &h->s;
-
- ff_h264_remove_all_refs(h);
- ff_h264_free_context(h);
-
- ff_MPV_common_end(s);
-
- // memset(h, 0, sizeof(H264Context));
-
- return 0;
-}
-
-static const AVProfile profiles[] = {
- { FF_PROFILE_H264_BASELINE, "Baseline" },
- { FF_PROFILE_H264_CONSTRAINED_BASELINE, "Constrained Baseline" },
- { FF_PROFILE_H264_MAIN, "Main" },
- { FF_PROFILE_H264_EXTENDED, "Extended" },
- { FF_PROFILE_H264_HIGH, "High" },
- { FF_PROFILE_H264_HIGH_10, "High 10" },
- { FF_PROFILE_H264_HIGH_10_INTRA, "High 10 Intra" },
- { FF_PROFILE_H264_HIGH_422, "High 4:2:2" },
- { FF_PROFILE_H264_HIGH_422_INTRA, "High 4:2:2 Intra" },
- { FF_PROFILE_H264_HIGH_444, "High 4:4:4" },
- { FF_PROFILE_H264_HIGH_444_PREDICTIVE, "High 4:4:4 Predictive" },
- { FF_PROFILE_H264_HIGH_444_INTRA, "High 4:4:4 Intra" },
- { FF_PROFILE_H264_CAVLC_444, "CAVLC 4:4:4" },
- { FF_PROFILE_UNKNOWN },
-};
-
-static const AVOption h264_options[] = {
- {"is_avc", "is avc", offsetof(H264Context, is_avc), FF_OPT_TYPE_INT, {.i64 = 0}, 0, 1, 0},
- {"nal_length_size", "nal_length_size", offsetof(H264Context, nal_length_size), FF_OPT_TYPE_INT, {.i64 = 0}, 0, 4, 0},
- {NULL}
-};
-
-static const AVClass h264_class = {
- .class_name = "H264 Decoder",
- .item_name = av_default_item_name,
- .option = h264_options,
- .version = LIBAVUTIL_VERSION_INT,
-};
-
-static const AVClass h264_vdpau_class = {
- .class_name = "H264 VDPAU Decoder",
- .item_name = av_default_item_name,
- .option = h264_options,
- .version = LIBAVUTIL_VERSION_INT,
-};
-
-AVCodec ff_h264_decoder = {
- .name = "h264",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_H264,
- .priv_data_size = sizeof(H264Context),
- .init = ff_h264_decode_init,
- .close = h264_decode_end,
- .decode = 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,
- .long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
- .init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
- .update_thread_context = ONLY_IF_THREADS_ENABLED(decode_update_thread_context),
- .profiles = NULL_IF_CONFIG_SMALL(profiles),
- .priv_class = &h264_class,
-};
-
-#if CONFIG_H264_VDPAU_DECODER
-AVCodec ff_h264_vdpau_decoder = {
- .name = "h264_vdpau",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_H264,
- .priv_data_size = sizeof(H264Context),
- .init = ff_h264_decode_init,
- .close = h264_decode_end,
- .decode = decode_frame,
- .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU,
- .flush = flush_dpb,
- .long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (VDPAU acceleration)"),
- .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_VDPAU_H264,
- AV_PIX_FMT_NONE},
- .profiles = NULL_IF_CONFIG_SMALL(profiles),
- .priv_class = &h264_vdpau_class,
-};
-#endif
-
-// ==> Start patch MPC
-#include "h264_recov.c"
-#include "h264_dxva.c"
-// ==> End patch MPC
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264.h b/src/thirdparty/ffmpeg/libavcodec/h264.h
deleted file mode 100644
index 255a39ac3..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264.h
+++ /dev/null
@@ -1,941 +0,0 @@
-/*
- * H.26L/H.264/AVC/JVT/14496-10/... encoder/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>
- */
-
-#ifndef AVCODEC_H264_H
-#define AVCODEC_H264_H
-
-#include "libavutil/intreadwrite.h"
-#include "cabac.h"
-#include "mpegvideo.h"
-#include "h264chroma.h"
-#include "h264dsp.h"
-#include "h264pred.h"
-#include "h264qpel.h"
-#include "rectangle.h"
-
-#define MAX_SPS_COUNT 32
-#define MAX_PPS_COUNT 256
-
-#define MAX_MMCO_COUNT 66
-
-#define MAX_DELAYED_PIC_COUNT 16
-
-#define MAX_MBPAIR_SIZE (256*1024) // a tighter bound could be calculated if someone cares about a few bytes
-
-/* Compiling in interlaced support reduces the speed
- * of progressive decoding by about 2%. */
-#define ALLOW_INTERLACE
-
-#define FMO 0
-
-/**
- * The maximum number of slices supported by the decoder.
- * must be a power of 2
- */
-#define MAX_SLICES 16
-
-#ifdef ALLOW_INTERLACE
-#define MB_MBAFF h->mb_mbaff
-#define MB_FIELD h->mb_field_decoding_flag
-#define FRAME_MBAFF h->mb_aff_frame
-#define FIELD_PICTURE (s->picture_structure != PICT_FRAME)
-#define LEFT_MBS 2
-#define LTOP 0
-#define LBOT 1
-#define LEFT(i) (i)
-#else
-#define MB_MBAFF 0
-#define MB_FIELD 0
-#define FRAME_MBAFF 0
-#define FIELD_PICTURE 0
-#undef IS_INTERLACED
-#define IS_INTERLACED(mb_type) 0
-#define LEFT_MBS 1
-#define LTOP 0
-#define LBOT 0
-#define LEFT(i) 0
-#endif
-#define FIELD_OR_MBAFF_PICTURE (FRAME_MBAFF || FIELD_PICTURE)
-
-#ifndef CABAC
-#define CABAC h->pps.cabac
-#endif
-
-#define CHROMA (h->sps.chroma_format_idc)
-#define CHROMA422 (h->sps.chroma_format_idc == 2)
-#define CHROMA444 (h->sps.chroma_format_idc == 3)
-
-#define EXTENDED_SAR 255
-
-#define MB_TYPE_REF0 MB_TYPE_ACPRED // dirty but it fits in 16 bit
-#define MB_TYPE_8x8DCT 0x01000000
-#define IS_REF0(a) ((a) & MB_TYPE_REF0)
-#define IS_8x8DCT(a) ((a) & MB_TYPE_8x8DCT)
-
-#define QP_MAX_NUM (51 + 6*6) // The maximum supported qp
-
-/* 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_AUXILIARY_SLICE = 19,
- NAL_FF_IGNORE = 0xff0f001,
-};
-
-/**
- * SEI message types
- */
-typedef enum {
- SEI_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
- SEI_TYPE_RECOVERY_POINT = 6 ///< recovery point (frame # to decoder sync)
-} SEI_Type;
-
-/**
- * pic_struct in picture timing SEI message
- */
-typedef enum {
- SEI_PIC_STRUCT_FRAME = 0, ///< 0: %frame
- SEI_PIC_STRUCT_TOP_FIELD = 1, ///< 1: top field
- SEI_PIC_STRUCT_BOTTOM_FIELD = 2, ///< 2: bottom field
- SEI_PIC_STRUCT_TOP_BOTTOM = 3, ///< 3: top field, bottom field, in that order
- SEI_PIC_STRUCT_BOTTOM_TOP = 4, ///< 4: bottom field, top field, in that order
- SEI_PIC_STRUCT_TOP_BOTTOM_TOP = 5, ///< 5: top field, bottom field, top field repeated, in that order
- SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM = 6, ///< 6: bottom field, top field, bottom field repeated, in that order
- SEI_PIC_STRUCT_FRAME_DOUBLING = 7, ///< 7: %frame doubling
- SEI_PIC_STRUCT_FRAME_TRIPLING = 8 ///< 8: %frame tripling
-} SEI_PicStructType;
-
-/**
- * Sequence parameter set
- */
-typedef struct SPS {
- int profile_idc;
- int level_idc;
- int chroma_format_idc;
- int transform_bypass; ///< qpprime_y_zero_transform_bypass_flag
- int log2_max_frame_num; ///< log2_max_frame_num_minus4 + 4
- int poc_type; ///< pic_order_cnt_type
- int log2_max_poc_lsb; ///< log2_max_pic_order_cnt_lsb_minus4
- int delta_pic_order_always_zero_flag;
- int offset_for_non_ref_pic;
- int offset_for_top_to_bottom_field;
- int poc_cycle_length; ///< num_ref_frames_in_pic_order_cnt_cycle
- int ref_frame_count; ///< num_ref_frames
- int gaps_in_frame_num_allowed_flag;
- int mb_width; ///< pic_width_in_mbs_minus1 + 1
- int mb_height; ///< pic_height_in_map_units_minus1 + 1
- int frame_mbs_only_flag;
- int mb_aff; ///< mb_adaptive_frame_field_flag
- int direct_8x8_inference_flag;
- int crop; ///< frame_cropping_flag
- unsigned int crop_left; ///< frame_cropping_rect_left_offset
- unsigned int crop_right; ///< frame_cropping_rect_right_offset
- unsigned int crop_top; ///< frame_cropping_rect_top_offset
- unsigned int crop_bottom; ///< frame_cropping_rect_bottom_offset
- int vui_parameters_present_flag;
- AVRational sar;
- int video_signal_type_present_flag;
- int full_range;
- int colour_description_present_flag;
- enum AVColorPrimaries color_primaries;
- enum AVColorTransferCharacteristic color_trc;
- enum AVColorSpace colorspace;
- int timing_info_present_flag;
- uint32_t num_units_in_tick;
- uint32_t time_scale;
- int fixed_frame_rate_flag;
- short offset_for_ref_frame[256]; // FIXME dyn aloc?
- int bitstream_restriction_flag;
- int num_reorder_frames;
- int scaling_matrix_present;
- uint8_t scaling_matrix4[6][16];
- uint8_t scaling_matrix8[6][64];
- int nal_hrd_parameters_present_flag;
- int vcl_hrd_parameters_present_flag;
- int pic_struct_present_flag;
- int time_offset_length;
- int cpb_cnt; ///< See H.264 E.1.2
- int initial_cpb_removal_delay_length; ///< initial_cpb_removal_delay_length_minus1 + 1
- int cpb_removal_delay_length; ///< cpb_removal_delay_length_minus1 + 1
- int dpb_output_delay_length; ///< dpb_output_delay_length_minus1 + 1
- int bit_depth_luma; ///< bit_depth_luma_minus8 + 8
- int bit_depth_chroma; ///< bit_depth_chroma_minus8 + 8
- int residual_color_transform_flag; ///< residual_colour_transform_flag
- int constraint_set_flags; ///< constraint_set[0-3]_flag
- int new; ///< flag to keep track if the decoder context needs re-init due to changed SPS
-} SPS;
-
-/**
- * Picture parameter set
- */
-typedef struct PPS {
- unsigned int sps_id;
- int cabac; ///< entropy_coding_mode_flag
- int pic_order_present; ///< pic_order_present_flag
- int slice_group_count; ///< num_slice_groups_minus1 + 1
- int mb_slice_group_map_type;
- unsigned int ref_count[2]; ///< num_ref_idx_l0/1_active_minus1 + 1
- int weighted_pred; ///< weighted_pred_flag
- int weighted_bipred_idc;
- int init_qp; ///< pic_init_qp_minus26 + 26
- int init_qs; ///< pic_init_qs_minus26 + 26
- int chroma_qp_index_offset[2];
- int deblocking_filter_parameters_present; ///< deblocking_filter_parameters_present_flag
- int constrained_intra_pred; ///< constrained_intra_pred_flag
- int redundant_pic_cnt_present; ///< redundant_pic_cnt_present_flag
- int transform_8x8_mode; ///< transform_8x8_mode_flag
- uint8_t scaling_matrix4[6][16];
- uint8_t scaling_matrix8[6][64];
- uint8_t chroma_qp_table[2][QP_MAX_NUM+1]; ///< pre-scaled (with chroma_qp_index_offset) version of qp_table
- int chroma_qp_diff;
-} PPS;
-
-/**
- * Memory management control operation opcode.
- */
-typedef enum MMCOOpcode {
- MMCO_END = 0,
- MMCO_SHORT2UNUSED,
- MMCO_LONG2UNUSED,
- MMCO_SHORT2LONG,
- MMCO_SET_MAX_LONG,
- MMCO_RESET,
- MMCO_LONG,
-} MMCOOpcode;
-
-/**
- * Memory management control operation.
- */
-typedef struct MMCO {
- MMCOOpcode opcode;
- int short_pic_num; ///< pic_num without wrapping (pic_num & max_pic_num)
- int long_arg; ///< index, pic_num, or num long refs depending on opcode
-} MMCO;
-
-/**
- * H264Context
- */
-typedef struct H264Context {
- MpegEncContext s;
- H264DSPContext h264dsp;
- H264ChromaContext h264chroma;
- H264QpelContext h264qpel;
- int pixel_shift; ///< 0 for 8-bit H264, 1 for high-bit-depth H264
- int chroma_qp[2]; // QPc
-
- int qp_thresh; ///< QP threshold to skip loopfilter
-
- int prev_mb_skipped;
- int next_mb_skipped;
-
- // prediction stuff
- int chroma_pred_mode;
- int intra16x16_pred_mode;
-
- int topleft_mb_xy;
- int top_mb_xy;
- int topright_mb_xy;
- int left_mb_xy[LEFT_MBS];
-
- int topleft_type;
- int top_type;
- int topright_type;
- int left_type[LEFT_MBS];
-
- const uint8_t *left_block;
- int topleft_partition;
-
- int8_t intra4x4_pred_mode_cache[5 * 8];
- int8_t(*intra4x4_pred_mode);
- H264PredContext hpc;
- unsigned int topleft_samples_available;
- unsigned int top_samples_available;
- unsigned int topright_samples_available;
- unsigned int left_samples_available;
- uint8_t (*top_borders[2])[(16 * 3) * 2];
-
- /**
- * non zero coeff count cache.
- * is 64 if not available.
- */
- DECLARE_ALIGNED(8, uint8_t, non_zero_count_cache)[15 * 8];
-
- uint8_t (*non_zero_count)[48];
-
- /**
- * Motion vector cache.
- */
- DECLARE_ALIGNED(16, int16_t, mv_cache)[2][5 * 8][2];
- DECLARE_ALIGNED(8, int8_t, ref_cache)[2][5 * 8];
-#define LIST_NOT_USED -1 // FIXME rename?
-#define PART_NOT_AVAILABLE -2
-
- /**
- * number of neighbors (top and/or left) that used 8x8 dct
- */
- int neighbor_transform_size;
-
- /**
- * block_offset[ 0..23] for frame macroblocks
- * block_offset[24..47] for field macroblocks
- */
- int block_offset[2 * (16 * 3)];
-
- uint32_t *mb2b_xy; // FIXME are these 4 a good idea?
- uint32_t *mb2br_xy;
- int b_stride; // FIXME use s->b4_stride
-
- int mb_linesize; ///< may be equal to s->linesize or s->linesize * 2, for mbaff
- int mb_uvlinesize;
-
- int emu_edge_width;
- int emu_edge_height;
-
- unsigned current_sps_id; ///< id of the current SPS
- SPS sps; ///< current sps
-
- /**
- * current pps
- */
- PPS pps; // FIXME move to Picture perhaps? (->no) do we need that?
-
- 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];
- uint32_t(*dequant4_coeff[6])[16];
- uint32_t(*dequant8_coeff[6])[64];
-
- int slice_num;
- uint16_t *slice_table; ///< slice_table_base + 2*mb_stride + 1
- int slice_type;
- int slice_type_nos; ///< S free slice type (SI/SP are remapped to I/P)
- int slice_type_fixed;
-
- // interlacing specific flags
- int mb_aff_frame;
- int mb_field_decoding_flag;
- int mb_mbaff; ///< mb_aff_frame && mb_field_decoding_flag
-
- DECLARE_ALIGNED(8, uint16_t, sub_mb_type)[4];
-
- // Weighted pred stuff
- int use_weight;
- int use_weight_chroma;
- int luma_log2_weight_denom;
- int chroma_log2_weight_denom;
- // The following 2 can be changed to int8_t but that causes 10cpu cycles speedloss
- int luma_weight[48][2][2];
- int chroma_weight[48][2][2][2];
- int implicit_weight[48][48][2];
-
- int direct_spatial_mv_pred;
- int col_parity;
- int col_fieldoff;
- int dist_scale_factor[32];
- int dist_scale_factor_field[2][32];
- int map_col_to_list0[2][16 + 32];
- int map_col_to_list0_field[2][2][16 + 32];
-
- /**
- * num_ref_idx_l0/1_active_minus1 + 1
- */
- 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.
- * 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
-
- // data partitioning
- GetBitContext intra_gb;
- GetBitContext inter_gb;
- GetBitContext *intra_gb_ptr;
- GetBitContext *inter_gb_ptr;
-
- DECLARE_ALIGNED(16, int16_t, mb)[16 * 48 * 2]; ///< as a dct coeffecient is int32_t in high depth, we need to reserve twice the space.
- DECLARE_ALIGNED(16, int16_t, mb_luma_dc)[3][16 * 2];
- int16_t mb_padding[256 * 2]; ///< as mb is addressed by scantable[i] and scantable is uint8_t we can either check that i is not too large or ensure that there is some unused stuff after mb
-
- /**
- * Cabac
- */
- CABACContext cabac;
- uint8_t cabac_state[1024];
-
- /* 0x100 -> non null luma_dc, 0x80/0x40 -> non null chroma_dc (cb/cr), 0x?0 -> chroma_cbp(0, 1, 2), 0x0? luma_cbp */
- uint16_t *cbp_table;
- int cbp;
- int top_cbp;
- int left_cbp;
- /* chroma_pred_mode for i4x4 or i16x16, else 0 */
- uint8_t *chroma_pred_mode_table;
- int last_qscale_diff;
- uint8_t (*mvd_table[2])[2];
- DECLARE_ALIGNED(16, uint8_t, mvd_cache)[2][5 * 8][2];
- uint8_t *direct_table;
- uint8_t direct_cache[5 * 8];
-
- uint8_t zigzag_scan[16];
- uint8_t zigzag_scan8x8[64];
- uint8_t zigzag_scan8x8_cavlc[64];
- uint8_t field_scan[16];
- uint8_t field_scan8x8[64];
- uint8_t field_scan8x8_cavlc[64];
- uint8_t zigzag_scan_q0[16];
- uint8_t zigzag_scan8x8_q0[64];
- uint8_t zigzag_scan8x8_cavlc_q0[64];
- uint8_t field_scan_q0[16];
- uint8_t field_scan8x8_q0[64];
- uint8_t field_scan8x8_cavlc_q0[64];
-
- int x264_build;
-
- int mb_xy;
-
- int is_complex;
-
- // deblock
- int deblocking_filter; ///< disable_deblocking_filter_idc with 1 <-> 0
- int slice_alpha_c0_offset;
- int slice_beta_offset;
-
- // =============================================================
- // Things below are not used in the MB or more inner code
-
- int nal_ref_idc;
- int nal_unit_type;
- uint8_t *rbsp_buffer[2];
- unsigned int rbsp_buffer_size[2];
-
- /**
- * Used to parse AVC variant of h264
- */
- int is_avc; ///< this flag is != 0 if codec is avc1
- int nal_length_size; ///< Number of bytes used for nal length (1, 2 or 4)
- int got_first; ///< this flag is != 0 if we've parsed a frame
-
- int context_reinitialized;
-
- SPS *sps_buffers[MAX_SPS_COUNT];
- PPS *pps_buffers[MAX_PPS_COUNT];
-
- int dequant_coeff_pps; ///< reinit tables when pps changes
-
- uint16_t *slice_table_base;
-
- // POC stuff
- int poc_lsb;
- int poc_msb;
- int delta_poc_bottom;
- int delta_poc[2];
- int frame_num;
- int prev_poc_msb; ///< poc_msb of the last reference pic for POC type 0
- int prev_poc_lsb; ///< poc_lsb of the last reference pic for POC type 0
- int frame_num_offset; ///< for POC type 2
- int prev_frame_num_offset; ///< for POC type 2
- int prev_frame_num; ///< frame_num of the last pic for POC type 1/2
-
- /**
- * frame_num for frames or 2 * frame_num + 1 for field pics.
- */
- int curr_pic_num;
-
- /**
- * max_frame_num or 2 * max_frame_num for field pics.
- */
- int max_pic_num;
-
- 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?
- int last_pocs[MAX_DELAYED_PIC_COUNT];
- Picture *next_output_pic;
- int outputed_poc;
- int next_outputed_poc;
-
- /**
- * memory management control operations buffer.
- */
- MMCO mmco[MAX_MMCO_COUNT];
- int mmco_index;
- int mmco_reset;
-
- int long_ref_count; ///< number of actual long term references
- int short_ref_count; ///< number of actual short term references
-
- int cabac_init_idc;
-
- /**
- * @name Members for slice based multithreading
- * @{
- */
- struct H264Context *thread_context[MAX_THREADS];
-
- /**
- * current slice number, used to initialize slice_num of each thread/context
- */
- int current_slice;
-
- /**
- * Max number of threads / contexts.
- * This is equal to AVCodecContext.thread_count unless
- * multithreaded decoding is impossible, in which case it is
- * reduced to 1.
- */
- int max_contexts;
-
- /**
- * 1 if the single thread fallback warning has already been
- * displayed, 0 otherwise.
- */
- int single_decode_warning;
-
- int last_slice_type;
- /** @} */
-
- /**
- * pic_struct in picture timing SEI message
- */
- SEI_PicStructType sei_pic_struct;
-
- /**
- * Complement sei_pic_struct
- * SEI_PIC_STRUCT_TOP_BOTTOM and SEI_PIC_STRUCT_BOTTOM_TOP indicate interlaced frames.
- * However, soft telecined frames may have these values.
- * This is used in an attempt to flag soft telecine progressive.
- */
- int prev_interlaced_frame;
-
- /**
- * 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).
- */
- int sei_ct_type;
-
- /**
- * dpb_output_delay in picture timing SEI message, see H.264 C.2.2
- */
- int sei_dpb_output_delay;
-
- /**
- * cpb_removal_delay in picture timing SEI message, see H.264 C.1.2
- */
- int sei_cpb_removal_delay;
-
- /**
- * recovery_frame_cnt from SEI message
- *
- * Set to -1 if no recovery point SEI message found or to number of frames
- * before playback synchronizes. Frames having recovery point are key
- * frames.
- */
- int sei_recovery_frame_cnt;
- /**
- * recovery_frame is the frame_num at which the next frame should
- * be fully constructed.
- *
- * Set to -1 when not expecting a recovery point.
- */
- int recovery_frame;
-
- /**
- * Are the SEI recovery points looking valid.
- */
- int valid_recovery_point;
-
- int luma_weight_flag[2]; ///< 7.4.3.2 luma_weight_lX_flag
- int chroma_weight_flag[2]; ///< 7.4.3.2 chroma_weight_lX_flag
-
- // Timestamp stuff
- int sei_buffering_period_present; ///< Buffering period SEI flag
- int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs
-
- int cur_chroma_format_idc;
- uint8_t *bipred_scratchpad;
-
- int16_t slice_row[MAX_SLICES]; ///< to detect when MAX_SLICES is too low
-
- int sync; ///< did we had a keyframe or recovery point
-
- uint8_t parse_history[4];
- int parse_history_count;
- int parse_last_mb;
-
- // ==> Start patch MPC
- int sp_for_switch_flag;
- int slice_qs_delta;
- int slice_qp_delta;
- unsigned int first_mb_in_slice;
- int bit_offset_to_slice_data;
- int raw_slice_type;
- int64_t outputed_rtstart;
- void* dxva_slice_long;
- int ref_pic_flag;
- // <== End patch MPC
-} 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).
-extern const uint16_t ff_h264_mb_sizes[4];
-
-/**
- * Decode SEI
- */
-int ff_h264_decode_sei(H264Context *h);
-
-/**
- * Decode SPS
- */
-int ff_h264_decode_seq_parameter_set(H264Context *h);
-
-/**
- * compute profile from sps
- */
-int ff_h264_get_profile(SPS *sps);
-
-/**
- * Decode PPS
- */
-int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length);
-
-/**
- * Decode a network abstraction layer unit.
- * @param consumed is the number of bytes used as input
- * @param length is the length of the array
- * @param dst_length is the number of decoded bytes FIXME here
- * or a decode rbsp tailing?
- * @return decoded bytes, might be src+1 if no escapes
- */
-const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src,
- int *dst_length, int *consumed, int length);
-
-/**
- * Free any data that may have been allocated in the H264 context
- * like SPS, PPS etc.
- */
-av_cold void ff_h264_free_context(H264Context *h);
-
-/**
- * Reconstruct bitstream slice_type.
- */
-int ff_h264_get_slice_type(const H264Context *h);
-
-/**
- * Allocate tables.
- * needs width/height
- */
-int ff_h264_alloc_tables(H264Context *h);
-
-/**
- * Fill the default_ref_list.
- */
-int ff_h264_fill_default_ref_list(H264Context *h);
-
-int ff_h264_decode_ref_pic_list_reordering(H264Context *h);
-void ff_h264_fill_mbaff_ref_list(H264Context *h);
-void ff_h264_remove_all_refs(H264Context *h);
-
-/**
- * Execute the reference picture marking (memory management control operations).
- */
-int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count);
-
-int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb,
- int first_slice);
-
-int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice);
-
-/**
- * Check if the top & left blocks are available if needed & change the
- * dc mode so it only uses the available blocks.
- */
-int ff_h264_check_intra4x4_pred_mode(H264Context *h);
-
-/**
- * Check if the top & left blocks are available if needed & change the
- * dc mode so it only uses the available blocks.
- */
-int ff_h264_check_intra_pred_mode(H264Context *h, int mode, int is_chroma);
-
-void ff_h264_hl_decode_mb(H264Context *h);
-int ff_h264_frame_start(H264Context *h);
-int ff_h264_decode_extradata(H264Context *h, const uint8_t *buf, int size);
-av_cold int ff_h264_decode_init(AVCodecContext *avctx);
-av_cold void ff_h264_decode_init_vlc(void);
-
-/**
- * Decode a macroblock
- * @return 0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR on error
- */
-int ff_h264_decode_mb_cavlc(H264Context *h);
-
-/**
- * Decode a CABAC coded macroblock
- * @return 0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR on error
- */
-int ff_h264_decode_mb_cabac(H264Context *h);
-
-void ff_h264_init_cabac_states(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);
-
-void ff_h264_filter_mb_fast(H264Context *h, int mb_x, int mb_y,
- uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr,
- unsigned int linesize, unsigned int uvlinesize);
-void ff_h264_filter_mb(H264Context *h, int mb_x, int mb_y,
- uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr,
- unsigned int linesize, unsigned int uvlinesize);
-
-/**
- * Reset SEI values at the beginning of the frame.
- *
- * @param h H.264 context.
- */
-void ff_h264_reset_sei(H264Context *h);
-
-/*
- * o-o o-o
- * / / /
- * o-o o-o
- * ,---'
- * o-o o-o
- * / / /
- * o-o o-o
- */
-
-/* Scan8 organization:
- * 0 1 2 3 4 5 6 7
- * 0 DY y y y y y
- * 1 y Y Y Y Y
- * 2 y Y Y Y Y
- * 3 y Y Y Y Y
- * 4 y Y Y Y Y
- * 5 DU u u u u u
- * 6 u U U U U
- * 7 u U U U U
- * 8 u U U U U
- * 9 u U U U U
- * 10 DV v v v v v
- * 11 v V V V V
- * 12 v V V V V
- * 13 v V V V V
- * 14 v V V V V
- * DY/DU/DV are for luma/chroma DC.
- */
-
-#define LUMA_DC_BLOCK_INDEX 48
-#define CHROMA_DC_BLOCK_INDEX 49
-
-// This table must be here because scan8[constant] must be known at compiletime
-static const uint8_t scan8[16 * 3 + 3] = {
- 4 + 1 * 8, 5 + 1 * 8, 4 + 2 * 8, 5 + 2 * 8,
- 6 + 1 * 8, 7 + 1 * 8, 6 + 2 * 8, 7 + 2 * 8,
- 4 + 3 * 8, 5 + 3 * 8, 4 + 4 * 8, 5 + 4 * 8,
- 6 + 3 * 8, 7 + 3 * 8, 6 + 4 * 8, 7 + 4 * 8,
- 4 + 6 * 8, 5 + 6 * 8, 4 + 7 * 8, 5 + 7 * 8,
- 6 + 6 * 8, 7 + 6 * 8, 6 + 7 * 8, 7 + 7 * 8,
- 4 + 8 * 8, 5 + 8 * 8, 4 + 9 * 8, 5 + 9 * 8,
- 6 + 8 * 8, 7 + 8 * 8, 6 + 9 * 8, 7 + 9 * 8,
- 4 + 11 * 8, 5 + 11 * 8, 4 + 12 * 8, 5 + 12 * 8,
- 6 + 11 * 8, 7 + 11 * 8, 6 + 12 * 8, 7 + 12 * 8,
- 4 + 13 * 8, 5 + 13 * 8, 4 + 14 * 8, 5 + 14 * 8,
- 6 + 13 * 8, 7 + 13 * 8, 6 + 14 * 8, 7 + 14 * 8,
- 0 + 0 * 8, 0 + 5 * 8, 0 + 10 * 8
-};
-
-static av_always_inline uint32_t pack16to32(int a, int b)
-{
-#if HAVE_BIGENDIAN
- return (b & 0xFFFF) + (a << 16);
-#else
- return (a & 0xFFFF) + (b << 16);
-#endif
-}
-
-static av_always_inline uint16_t pack8to16(int a, int b)
-{
-#if HAVE_BIGENDIAN
- return (b & 0xFF) + (a << 8);
-#else
- return (a & 0xFF) + (b << 8);
-#endif
-}
-
-/**
- * Get the chroma qp.
- */
-static av_always_inline int get_chroma_qp(H264Context *h, int t, int qscale)
-{
- return h->pps.chroma_qp_table[t][qscale];
-}
-
-/**
- * Get the predicted intra4x4 prediction mode.
- */
-static av_always_inline int pred_intra_mode(H264Context *h, int n)
-{
- const int index8 = scan8[n];
- const int left = h->intra4x4_pred_mode_cache[index8 - 1];
- const int top = h->intra4x4_pred_mode_cache[index8 - 8];
- const int min = FFMIN(left, top);
-
- tprintf(h->s.avctx, "mode:%d %d min:%d\n", left, top, min);
-
- if (min < 0)
- return DC_PRED;
- else
- return min;
-}
-
-static av_always_inline void write_back_intra_pred_mode(H264Context *h)
-{
- int8_t *i4x4 = h->intra4x4_pred_mode + h->mb2br_xy[h->mb_xy];
- int8_t *i4x4_cache = h->intra4x4_pred_mode_cache;
-
- AV_COPY32(i4x4, i4x4_cache + 4 + 8 * 4);
- i4x4[4] = i4x4_cache[7 + 8 * 3];
- i4x4[5] = i4x4_cache[7 + 8 * 2];
- i4x4[6] = i4x4_cache[7 + 8 * 1];
-}
-
-static av_always_inline void write_back_non_zero_count(H264Context *h)
-{
- const int mb_xy = h->mb_xy;
- uint8_t *nnz = h->non_zero_count[mb_xy];
- uint8_t *nnz_cache = h->non_zero_count_cache;
-
- AV_COPY32(&nnz[ 0], &nnz_cache[4 + 8 * 1]);
- AV_COPY32(&nnz[ 4], &nnz_cache[4 + 8 * 2]);
- AV_COPY32(&nnz[ 8], &nnz_cache[4 + 8 * 3]);
- AV_COPY32(&nnz[12], &nnz_cache[4 + 8 * 4]);
- AV_COPY32(&nnz[16], &nnz_cache[4 + 8 * 6]);
- AV_COPY32(&nnz[20], &nnz_cache[4 + 8 * 7]);
- AV_COPY32(&nnz[32], &nnz_cache[4 + 8 * 11]);
- AV_COPY32(&nnz[36], &nnz_cache[4 + 8 * 12]);
-
- if (!h->s.chroma_y_shift) {
- AV_COPY32(&nnz[24], &nnz_cache[4 + 8 * 8]);
- AV_COPY32(&nnz[28], &nnz_cache[4 + 8 * 9]);
- AV_COPY32(&nnz[40], &nnz_cache[4 + 8 * 13]);
- AV_COPY32(&nnz[44], &nnz_cache[4 + 8 * 14]);
- }
-}
-
-static av_always_inline void write_back_motion_list(H264Context *h,
- MpegEncContext *const s,
- int b_stride,
- int b_xy, int b8_xy,
- int mb_type, int list)
-{
- int16_t(*mv_dst)[2] = &s->current_picture.f.motion_val[list][b_xy];
- int16_t(*mv_src)[2] = &h->mv_cache[list][scan8[0]];
- AV_COPY128(mv_dst + 0 * b_stride, mv_src + 8 * 0);
- AV_COPY128(mv_dst + 1 * b_stride, mv_src + 8 * 1);
- AV_COPY128(mv_dst + 2 * b_stride, mv_src + 8 * 2);
- AV_COPY128(mv_dst + 3 * b_stride, mv_src + 8 * 3);
- if (CABAC) {
- uint8_t (*mvd_dst)[2] = &h->mvd_table[list][FMO ? 8 * h->mb_xy
- : h->mb2br_xy[h->mb_xy]];
- uint8_t(*mvd_src)[2] = &h->mvd_cache[list][scan8[0]];
- if (IS_SKIP(mb_type)) {
- AV_ZERO128(mvd_dst);
- } else {
- AV_COPY64(mvd_dst, mvd_src + 8 * 3);
- AV_COPY16(mvd_dst + 3 + 3, mvd_src + 3 + 8 * 0);
- AV_COPY16(mvd_dst + 3 + 2, mvd_src + 3 + 8 * 1);
- AV_COPY16(mvd_dst + 3 + 1, mvd_src + 3 + 8 * 2);
- }
- }
-
- {
- int8_t *ref_index = &s->current_picture.f.ref_index[list][b8_xy];
- int8_t *ref_cache = h->ref_cache[list];
- ref_index[0 + 0 * 2] = ref_cache[scan8[0]];
- ref_index[1 + 0 * 2] = ref_cache[scan8[4]];
- ref_index[0 + 1 * 2] = ref_cache[scan8[8]];
- ref_index[1 + 1 * 2] = ref_cache[scan8[12]];
- }
-}
-
-static av_always_inline void write_back_motion(H264Context *h, int mb_type)
-{
- MpegEncContext *const s = &h->s;
- const int b_stride = h->b_stride;
- const int b_xy = 4 * s->mb_x + 4 * s->mb_y * h->b_stride; // try mb2b(8)_xy
- const int b8_xy = 4 * h->mb_xy;
-
- if (USES_LIST(mb_type, 0)) {
- write_back_motion_list(h, s, b_stride, b_xy, b8_xy, mb_type, 0);
- } else {
- fill_rectangle(&s->current_picture.f.ref_index[0][b8_xy],
- 2, 2, 2, (uint8_t)LIST_NOT_USED, 1);
- }
- if (USES_LIST(mb_type, 1))
- write_back_motion_list(h, s, b_stride, b_xy, b8_xy, mb_type, 1);
-
- if (h->slice_type_nos == AV_PICTURE_TYPE_B && CABAC) {
- if (IS_8X8(mb_type)) {
- uint8_t *direct_table = &h->direct_table[4 * h->mb_xy];
- direct_table[1] = h->sub_mb_type[1] >> 1;
- direct_table[2] = h->sub_mb_type[2] >> 1;
- direct_table[3] = h->sub_mb_type[3] >> 1;
- }
- }
-}
-
-static av_always_inline int get_dct8x8_allowed(H264Context *h)
-{
- if (h->sps.direct_8x8_inference_flag)
- return !(AV_RN64A(h->sub_mb_type) &
- ((MB_TYPE_16x8 | MB_TYPE_8x16 | MB_TYPE_8x8) *
- 0x0001000100010001ULL));
- else
- return !(AV_RN64A(h->sub_mb_type) &
- ((MB_TYPE_16x8 | MB_TYPE_8x16 | MB_TYPE_8x8 | MB_TYPE_DIRECT2) *
- 0x0001000100010001ULL));
-}
-
-#endif /* AVCODEC_H264_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264_cabac.c b/src/thirdparty/ffmpeg/libavcodec/h264_cabac.c
deleted file mode 100644
index 8afb46493..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264_cabac.c
+++ /dev/null
@@ -1,2430 +0,0 @@
-/*
- * H.26L/H.264/AVC/JVT/14496-10/... cabac decoding
- * 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 cabac decoding.
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#define CABAC 1
-#define UNCHECKED_BITSTREAM_READER 1
-
-#include "config.h"
-#include "cabac.h"
-#include "cabac_functions.h"
-#include "internal.h"
-#include "dsputil.h"
-#include "avcodec.h"
-#include "h264.h"
-#include "h264data.h"
-#include "h264_mvpred.h"
-#include "golomb.h"
-#include "libavutil/avassert.h"
-
-#if ARCH_X86
-#include "x86/h264_i386.h"
-#endif
-
-/* Cabac pre state table */
-
-static const int8_t cabac_context_init_I[1024][2] =
-{
- /* 0 - 10 */
- { 20, -15 }, { 2, 54 }, { 3, 74 }, { 20, -15 },
- { 2, 54 }, { 3, 74 }, { -28,127 }, { -23, 104 },
- { -6, 53 }, { -1, 54 }, { 7, 51 },
-
- /* 11 - 23 unsused for I */
- { 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 },
-
- /* 24- 39 */
- { 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 },
-
- /* 40 - 53 */
- { 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 },
-
- /* 54 - 59 */
- { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
- { 0, 0 }, { 0, 0 },
-
- /* 60 - 69 */
- { 0, 41 }, { 0, 63 }, { 0, 63 }, { 0, 63 },
- { -9, 83 }, { 4, 86 }, { 0, 97 }, { -7, 72 },
- { 13, 41 }, { 3, 62 },
-
- /* 70 -> 87 */
- { 0, 11 }, { 1, 55 }, { 0, 69 }, { -17, 127 },
- { -13, 102 },{ 0, 82 }, { -7, 74 }, { -21, 107 },
- { -27, 127 },{ -31, 127 },{ -24, 127 }, { -18, 95 },
- { -27, 127 },{ -21, 114 },{ -30, 127 }, { -17, 123 },
- { -12, 115 },{ -16, 122 },
-
- /* 88 -> 104 */
- { -11, 115 },{ -12, 63 }, { -2, 68 }, { -15, 84 },
- { -13, 104 },{ -3, 70 }, { -8, 93 }, { -10, 90 },
- { -30, 127 },{ -1, 74 }, { -6, 97 }, { -7, 91 },
- { -20, 127 },{ -4, 56 }, { -5, 82 }, { -7, 76 },
- { -22, 125 },
-
- /* 105 -> 135 */
- { -7, 93 }, { -11, 87 }, { -3, 77 }, { -5, 71 },
- { -4, 63 }, { -4, 68 }, { -12, 84 }, { -7, 62 },
- { -7, 65 }, { 8, 61 }, { 5, 56 }, { -2, 66 },
- { 1, 64 }, { 0, 61 }, { -2, 78 }, { 1, 50 },
- { 7, 52 }, { 10, 35 }, { 0, 44 }, { 11, 38 },
- { 1, 45 }, { 0, 46 }, { 5, 44 }, { 31, 17 },
- { 1, 51 }, { 7, 50 }, { 28, 19 }, { 16, 33 },
- { 14, 62 }, { -13, 108 },{ -15, 100 },
-
- /* 136 -> 165 */
- { -13, 101 },{ -13, 91 }, { -12, 94 }, { -10, 88 },
- { -16, 84 }, { -10, 86 }, { -7, 83 }, { -13, 87 },
- { -19, 94 }, { 1, 70 }, { 0, 72 }, { -5, 74 },
- { 18, 59 }, { -8, 102 }, { -15, 100 }, { 0, 95 },
- { -4, 75 }, { 2, 72 }, { -11, 75 }, { -3, 71 },
- { 15, 46 }, { -13, 69 }, { 0, 62 }, { 0, 65 },
- { 21, 37 }, { -15, 72 }, { 9, 57 }, { 16, 54 },
- { 0, 62 }, { 12, 72 },
-
- /* 166 -> 196 */
- { 24, 0 }, { 15, 9 }, { 8, 25 }, { 13, 18 },
- { 15, 9 }, { 13, 19 }, { 10, 37 }, { 12, 18 },
- { 6, 29 }, { 20, 33 }, { 15, 30 }, { 4, 45 },
- { 1, 58 }, { 0, 62 }, { 7, 61 }, { 12, 38 },
- { 11, 45 }, { 15, 39 }, { 11, 42 }, { 13, 44 },
- { 16, 45 }, { 12, 41 }, { 10, 49 }, { 30, 34 },
- { 18, 42 }, { 10, 55 }, { 17, 51 }, { 17, 46 },
- { 0, 89 }, { 26, -19 }, { 22, -17 },
-
- /* 197 -> 226 */
- { 26, -17 }, { 30, -25 }, { 28, -20 }, { 33, -23 },
- { 37, -27 }, { 33, -23 }, { 40, -28 }, { 38, -17 },
- { 33, -11 }, { 40, -15 }, { 41, -6 }, { 38, 1 },
- { 41, 17 }, { 30, -6 }, { 27, 3 }, { 26, 22 },
- { 37, -16 }, { 35, -4 }, { 38, -8 }, { 38, -3 },
- { 37, 3 }, { 38, 5 }, { 42, 0 }, { 35, 16 },
- { 39, 22 }, { 14, 48 }, { 27, 37 }, { 21, 60 },
- { 12, 68 }, { 2, 97 },
-
- /* 227 -> 251 */
- { -3, 71 }, { -6, 42 }, { -5, 50 }, { -3, 54 },
- { -2, 62 }, { 0, 58 }, { 1, 63 }, { -2, 72 },
- { -1, 74 }, { -9, 91 }, { -5, 67 }, { -5, 27 },
- { -3, 39 }, { -2, 44 }, { 0, 46 }, { -16, 64 },
- { -8, 68 }, { -10, 78 }, { -6, 77 }, { -10, 86 },
- { -12, 92 }, { -15, 55 }, { -10, 60 }, { -6, 62 },
- { -4, 65 },
-
- /* 252 -> 275 */
- { -12, 73 }, { -8, 76 }, { -7, 80 }, { -9, 88 },
- { -17, 110 },{ -11, 97 }, { -20, 84 }, { -11, 79 },
- { -6, 73 }, { -4, 74 }, { -13, 86 }, { -13, 96 },
- { -11, 97 }, { -19, 117 },{ -8, 78 }, { -5, 33 },
- { -4, 48 }, { -2, 53 }, { -3, 62 }, { -13, 71 },
- { -10, 79 }, { -12, 86 }, { -13, 90 }, { -14, 97 },
-
- /* 276 a bit special (not used, bypass is used instead) */
- { 0, 0 },
-
- /* 277 -> 307 */
- { -6, 93 }, { -6, 84 }, { -8, 79 }, { 0, 66 },
- { -1, 71 }, { 0, 62 }, { -2, 60 }, { -2, 59 },
- { -5, 75 }, { -3, 62 }, { -4, 58 }, { -9, 66 },
- { -1, 79 }, { 0, 71 }, { 3, 68 }, { 10, 44 },
- { -7, 62 }, { 15, 36 }, { 14, 40 }, { 16, 27 },
- { 12, 29 }, { 1, 44 }, { 20, 36 }, { 18, 32 },
- { 5, 42 }, { 1, 48 }, { 10, 62 }, { 17, 46 },
- { 9, 64 }, { -12, 104 },{ -11, 97 },
-
- /* 308 -> 337 */
- { -16, 96 }, { -7, 88 }, { -8, 85 }, { -7, 85 },
- { -9, 85 }, { -13, 88 }, { 4, 66 }, { -3, 77 },
- { -3, 76 }, { -6, 76 }, { 10, 58 }, { -1, 76 },
- { -1, 83 }, { -7, 99 }, { -14, 95 }, { 2, 95 },
- { 0, 76 }, { -5, 74 }, { 0, 70 }, { -11, 75 },
- { 1, 68 }, { 0, 65 }, { -14, 73 }, { 3, 62 },
- { 4, 62 }, { -1, 68 }, { -13, 75 }, { 11, 55 },
- { 5, 64 }, { 12, 70 },
-
- /* 338 -> 368 */
- { 15, 6 }, { 6, 19 }, { 7, 16 }, { 12, 14 },
- { 18, 13 }, { 13, 11 }, { 13, 15 }, { 15, 16 },
- { 12, 23 }, { 13, 23 }, { 15, 20 }, { 14, 26 },
- { 14, 44 }, { 17, 40 }, { 17, 47 }, { 24, 17 },
- { 21, 21 }, { 25, 22 }, { 31, 27 }, { 22, 29 },
- { 19, 35 }, { 14, 50 }, { 10, 57 }, { 7, 63 },
- { -2, 77 }, { -4, 82 }, { -3, 94 }, { 9, 69 },
- { -12, 109 },{ 36, -35 }, { 36, -34 },
-
- /* 369 -> 398 */
- { 32, -26 }, { 37, -30 }, { 44, -32 }, { 34, -18 },
- { 34, -15 }, { 40, -15 }, { 33, -7 }, { 35, -5 },
- { 33, 0 }, { 38, 2 }, { 33, 13 }, { 23, 35 },
- { 13, 58 }, { 29, -3 }, { 26, 0 }, { 22, 30 },
- { 31, -7 }, { 35, -15 }, { 34, -3 }, { 34, 3 },
- { 36, -1 }, { 34, 5 }, { 32, 11 }, { 35, 5 },
- { 34, 12 }, { 39, 11 }, { 30, 29 }, { 34, 26 },
- { 29, 39 }, { 19, 66 },
-
- /* 399 -> 435 */
- { 31, 21 }, { 31, 31 }, { 25, 50 },
- { -17, 120 }, { -20, 112 }, { -18, 114 }, { -11, 85 },
- { -15, 92 }, { -14, 89 }, { -26, 71 }, { -15, 81 },
- { -14, 80 }, { 0, 68 }, { -14, 70 }, { -24, 56 },
- { -23, 68 }, { -24, 50 }, { -11, 74 }, { 23, -13 },
- { 26, -13 }, { 40, -15 }, { 49, -14 }, { 44, 3 },
- { 45, 6 }, { 44, 34 }, { 33, 54 }, { 19, 82 },
- { -3, 75 }, { -1, 23 }, { 1, 34 }, { 1, 43 },
- { 0, 54 }, { -2, 55 }, { 0, 61 }, { 1, 64 },
- { 0, 68 }, { -9, 92 },
-
- /* 436 -> 459 */
- { -14, 106 }, { -13, 97 }, { -15, 90 }, { -12, 90 },
- { -18, 88 }, { -10, 73 }, { -9, 79 }, { -14, 86 },
- { -10, 73 }, { -10, 70 }, { -10, 69 }, { -5, 66 },
- { -9, 64 }, { -5, 58 }, { 2, 59 }, { 21, -10 },
- { 24, -11 }, { 28, -8 }, { 28, -1 }, { 29, 3 },
- { 29, 9 }, { 35, 20 }, { 29, 36 }, { 14, 67 },
-
- /* 460 -> 1024 */
- { -17, 123 }, { -12, 115 }, { -16, 122 }, { -11, 115 },
- { -12, 63 }, { -2, 68 }, { -15, 84 }, { -13, 104 },
- { -3, 70 }, { -8, 93 }, { -10, 90 }, { -30, 127 },
- { -17, 123 }, { -12, 115 }, { -16, 122 }, { -11, 115 },
- { -12, 63 }, { -2, 68 }, { -15, 84 }, { -13, 104 },
- { -3, 70 }, { -8, 93 }, { -10, 90 }, { -30, 127 },
- { -7, 93 }, { -11, 87 }, { -3, 77 }, { -5, 71 },
- { -4, 63 }, { -4, 68 }, { -12, 84 }, { -7, 62 },
- { -7, 65 }, { 8, 61 }, { 5, 56 }, { -2, 66 },
- { 1, 64 }, { 0, 61 }, { -2, 78 }, { 1, 50 },
- { 7, 52 }, { 10, 35 }, { 0, 44 }, { 11, 38 },
- { 1, 45 }, { 0, 46 }, { 5, 44 }, { 31, 17 },
- { 1, 51 }, { 7, 50 }, { 28, 19 }, { 16, 33 },
- { 14, 62 }, { -13, 108 }, { -15, 100 }, { -13, 101 },
- { -13, 91 }, { -12, 94 }, { -10, 88 }, { -16, 84 },
- { -10, 86 }, { -7, 83 }, { -13, 87 }, { -19, 94 },
- { 1, 70 }, { 0, 72 }, { -5, 74 }, { 18, 59 },
- { -7, 93 }, { -11, 87 }, { -3, 77 }, { -5, 71 },
- { -4, 63 }, { -4, 68 }, { -12, 84 }, { -7, 62 },
- { -7, 65 }, { 8, 61 }, { 5, 56 }, { -2, 66 },
- { 1, 64 }, { 0, 61 }, { -2, 78 }, { 1, 50 },
- { 7, 52 }, { 10, 35 }, { 0, 44 }, { 11, 38 },
- { 1, 45 }, { 0, 46 }, { 5, 44 }, { 31, 17 },
- { 1, 51 }, { 7, 50 }, { 28, 19 }, { 16, 33 },
- { 14, 62 }, { -13, 108 }, { -15, 100 }, { -13, 101 },
- { -13, 91 }, { -12, 94 }, { -10, 88 }, { -16, 84 },
- { -10, 86 }, { -7, 83 }, { -13, 87 }, { -19, 94 },
- { 1, 70 }, { 0, 72 }, { -5, 74 }, { 18, 59 },
- { 24, 0 }, { 15, 9 }, { 8, 25 }, { 13, 18 },
- { 15, 9 }, { 13, 19 }, { 10, 37 }, { 12, 18 },
- { 6, 29 }, { 20, 33 }, { 15, 30 }, { 4, 45 },
- { 1, 58 }, { 0, 62 }, { 7, 61 }, { 12, 38 },
- { 11, 45 }, { 15, 39 }, { 11, 42 }, { 13, 44 },
- { 16, 45 }, { 12, 41 }, { 10, 49 }, { 30, 34 },
- { 18, 42 }, { 10, 55 }, { 17, 51 }, { 17, 46 },
- { 0, 89 }, { 26, -19 }, { 22, -17 }, { 26, -17 },
- { 30, -25 }, { 28, -20 }, { 33, -23 }, { 37, -27 },
- { 33, -23 }, { 40, -28 }, { 38, -17 }, { 33, -11 },
- { 40, -15 }, { 41, -6 }, { 38, 1 }, { 41, 17 },
- { 24, 0 }, { 15, 9 }, { 8, 25 }, { 13, 18 },
- { 15, 9 }, { 13, 19 }, { 10, 37 }, { 12, 18 },
- { 6, 29 }, { 20, 33 }, { 15, 30 }, { 4, 45 },
- { 1, 58 }, { 0, 62 }, { 7, 61 }, { 12, 38 },
- { 11, 45 }, { 15, 39 }, { 11, 42 }, { 13, 44 },
- { 16, 45 }, { 12, 41 }, { 10, 49 }, { 30, 34 },
- { 18, 42 }, { 10, 55 }, { 17, 51 }, { 17, 46 },
- { 0, 89 }, { 26, -19 }, { 22, -17 }, { 26, -17 },
- { 30, -25 }, { 28, -20 }, { 33, -23 }, { 37, -27 },
- { 33, -23 }, { 40, -28 }, { 38, -17 }, { 33, -11 },
- { 40, -15 }, { 41, -6 }, { 38, 1 }, { 41, 17 },
- { -17, 120 }, { -20, 112 }, { -18, 114 }, { -11, 85 },
- { -15, 92 }, { -14, 89 }, { -26, 71 }, { -15, 81 },
- { -14, 80 }, { 0, 68 }, { -14, 70 }, { -24, 56 },
- { -23, 68 }, { -24, 50 }, { -11, 74 }, { -14, 106 },
- { -13, 97 }, { -15, 90 }, { -12, 90 }, { -18, 88 },
- { -10, 73 }, { -9, 79 }, { -14, 86 }, { -10, 73 },
- { -10, 70 }, { -10, 69 }, { -5, 66 }, { -9, 64 },
- { -5, 58 }, { 2, 59 }, { 23, -13 }, { 26, -13 },
- { 40, -15 }, { 49, -14 }, { 44, 3 }, { 45, 6 },
- { 44, 34 }, { 33, 54 }, { 19, 82 }, { 21, -10 },
- { 24, -11 }, { 28, -8 }, { 28, -1 }, { 29, 3 },
- { 29, 9 }, { 35, 20 }, { 29, 36 }, { 14, 67 },
- { -3, 75 }, { -1, 23 }, { 1, 34 }, { 1, 43 },
- { 0, 54 }, { -2, 55 }, { 0, 61 }, { 1, 64 },
- { 0, 68 }, { -9, 92 }, { -17, 120 }, { -20, 112 },
- { -18, 114 }, { -11, 85 }, { -15, 92 }, { -14, 89 },
- { -26, 71 }, { -15, 81 }, { -14, 80 }, { 0, 68 },
- { -14, 70 }, { -24, 56 }, { -23, 68 }, { -24, 50 },
- { -11, 74 }, { -14, 106 }, { -13, 97 }, { -15, 90 },
- { -12, 90 }, { -18, 88 }, { -10, 73 }, { -9, 79 },
- { -14, 86 }, { -10, 73 }, { -10, 70 }, { -10, 69 },
- { -5, 66 }, { -9, 64 }, { -5, 58 }, { 2, 59 },
- { 23, -13 }, { 26, -13 }, { 40, -15 }, { 49, -14 },
- { 44, 3 }, { 45, 6 }, { 44, 34 }, { 33, 54 },
- { 19, 82 }, { 21, -10 }, { 24, -11 }, { 28, -8 },
- { 28, -1 }, { 29, 3 }, { 29, 9 }, { 35, 20 },
- { 29, 36 }, { 14, 67 }, { -3, 75 }, { -1, 23 },
- { 1, 34 }, { 1, 43 }, { 0, 54 }, { -2, 55 },
- { 0, 61 }, { 1, 64 }, { 0, 68 }, { -9, 92 },
- { -6, 93 }, { -6, 84 }, { -8, 79 }, { 0, 66 },
- { -1, 71 }, { 0, 62 }, { -2, 60 }, { -2, 59 },
- { -5, 75 }, { -3, 62 }, { -4, 58 }, { -9, 66 },
- { -1, 79 }, { 0, 71 }, { 3, 68 }, { 10, 44 },
- { -7, 62 }, { 15, 36 }, { 14, 40 }, { 16, 27 },
- { 12, 29 }, { 1, 44 }, { 20, 36 }, { 18, 32 },
- { 5, 42 }, { 1, 48 }, { 10, 62 }, { 17, 46 },
- { 9, 64 }, { -12, 104 }, { -11, 97 }, { -16, 96 },
- { -7, 88 }, { -8, 85 }, { -7, 85 }, { -9, 85 },
- { -13, 88 }, { 4, 66 }, { -3, 77 }, { -3, 76 },
- { -6, 76 }, { 10, 58 }, { -1, 76 }, { -1, 83 },
- { -6, 93 }, { -6, 84 }, { -8, 79 }, { 0, 66 },
- { -1, 71 }, { 0, 62 }, { -2, 60 }, { -2, 59 },
- { -5, 75 }, { -3, 62 }, { -4, 58 }, { -9, 66 },
- { -1, 79 }, { 0, 71 }, { 3, 68 }, { 10, 44 },
- { -7, 62 }, { 15, 36 }, { 14, 40 }, { 16, 27 },
- { 12, 29 }, { 1, 44 }, { 20, 36 }, { 18, 32 },
- { 5, 42 }, { 1, 48 }, { 10, 62 }, { 17, 46 },
- { 9, 64 }, { -12, 104 }, { -11, 97 }, { -16, 96 },
- { -7, 88 }, { -8, 85 }, { -7, 85 }, { -9, 85 },
- { -13, 88 }, { 4, 66 }, { -3, 77 }, { -3, 76 },
- { -6, 76 }, { 10, 58 }, { -1, 76 }, { -1, 83 },
- { 15, 6 }, { 6, 19 }, { 7, 16 }, { 12, 14 },
- { 18, 13 }, { 13, 11 }, { 13, 15 }, { 15, 16 },
- { 12, 23 }, { 13, 23 }, { 15, 20 }, { 14, 26 },
- { 14, 44 }, { 17, 40 }, { 17, 47 }, { 24, 17 },
- { 21, 21 }, { 25, 22 }, { 31, 27 }, { 22, 29 },
- { 19, 35 }, { 14, 50 }, { 10, 57 }, { 7, 63 },
- { -2, 77 }, { -4, 82 }, { -3, 94 }, { 9, 69 },
- { -12, 109 }, { 36, -35 }, { 36, -34 }, { 32, -26 },
- { 37, -30 }, { 44, -32 }, { 34, -18 }, { 34, -15 },
- { 40, -15 }, { 33, -7 }, { 35, -5 }, { 33, 0 },
- { 38, 2 }, { 33, 13 }, { 23, 35 }, { 13, 58 },
- { 15, 6 }, { 6, 19 }, { 7, 16 }, { 12, 14 },
- { 18, 13 }, { 13, 11 }, { 13, 15 }, { 15, 16 },
- { 12, 23 }, { 13, 23 }, { 15, 20 }, { 14, 26 },
- { 14, 44 }, { 17, 40 }, { 17, 47 }, { 24, 17 },
- { 21, 21 }, { 25, 22 }, { 31, 27 }, { 22, 29 },
- { 19, 35 }, { 14, 50 }, { 10, 57 }, { 7, 63 },
- { -2, 77 }, { -4, 82 }, { -3, 94 }, { 9, 69 },
- { -12, 109 }, { 36, -35 }, { 36, -34 }, { 32, -26 },
- { 37, -30 }, { 44, -32 }, { 34, -18 }, { 34, -15 },
- { 40, -15 }, { 33, -7 }, { 35, -5 }, { 33, 0 },
- { 38, 2 }, { 33, 13 }, { 23, 35 }, { 13, 58 },
- { -3, 71 }, { -6, 42 }, { -5, 50 }, { -3, 54 },
- { -2, 62 }, { 0, 58 }, { 1, 63 }, { -2, 72 },
- { -1, 74 }, { -9, 91 }, { -5, 67 }, { -5, 27 },
- { -3, 39 }, { -2, 44 }, { 0, 46 }, { -16, 64 },
- { -8, 68 }, { -10, 78 }, { -6, 77 }, { -10, 86 },
- { -12, 92 }, { -15, 55 }, { -10, 60 }, { -6, 62 },
- { -4, 65 }, { -12, 73 }, { -8, 76 }, { -7, 80 },
- { -9, 88 }, { -17, 110 }, { -3, 71 }, { -6, 42 },
- { -5, 50 }, { -3, 54 }, { -2, 62 }, { 0, 58 },
- { 1, 63 }, { -2, 72 }, { -1, 74 }, { -9, 91 },
- { -5, 67 }, { -5, 27 }, { -3, 39 }, { -2, 44 },
- { 0, 46 }, { -16, 64 }, { -8, 68 }, { -10, 78 },
- { -6, 77 }, { -10, 86 }, { -12, 92 }, { -15, 55 },
- { -10, 60 }, { -6, 62 }, { -4, 65 }, { -12, 73 },
- { -8, 76 }, { -7, 80 }, { -9, 88 }, { -17, 110 },
- { -3, 70 }, { -8, 93 }, { -10, 90 }, { -30, 127 },
- { -3, 70 }, { -8, 93 }, { -10, 90 }, { -30, 127 },
- { -3, 70 }, { -8, 93 }, { -10, 90 }, { -30, 127 }
-};
-
-static const int8_t cabac_context_init_PB[3][1024][2] =
-{
- /* i_cabac_init_idc == 0 */
- {
- /* 0 - 10 */
- { 20, -15 }, { 2, 54 }, { 3, 74 }, { 20, -15 },
- { 2, 54 }, { 3, 74 }, { -28, 127 }, { -23, 104 },
- { -6, 53 }, { -1, 54 }, { 7, 51 },
-
- /* 11 - 23 */
- { 23, 33 }, { 23, 2 }, { 21, 0 }, { 1, 9 },
- { 0, 49 }, { -37, 118 }, { 5, 57 }, { -13, 78 },
- { -11, 65 }, { 1, 62 }, { 12, 49 }, { -4, 73 },
- { 17, 50 },
-
- /* 24 - 39 */
- { 18, 64 }, { 9, 43 }, { 29, 0 }, { 26, 67 },
- { 16, 90 }, { 9, 104 }, { -46, 127 }, { -20, 104 },
- { 1, 67 }, { -13, 78 }, { -11, 65 }, { 1, 62 },
- { -6, 86 }, { -17, 95 }, { -6, 61 }, { 9, 45 },
-
- /* 40 - 53 */
- { -3, 69 }, { -6, 81 }, { -11, 96 }, { 6, 55 },
- { 7, 67 }, { -5, 86 }, { 2, 88 }, { 0, 58 },
- { -3, 76 }, { -10, 94 }, { 5, 54 }, { 4, 69 },
- { -3, 81 }, { 0, 88 },
-
- /* 54 - 59 */
- { -7, 67 }, { -5, 74 }, { -4, 74 }, { -5, 80 },
- { -7, 72 }, { 1, 58 },
-
- /* 60 - 69 */
- { 0, 41 }, { 0, 63 }, { 0, 63 }, { 0, 63 },
- { -9, 83 }, { 4, 86 }, { 0, 97 }, { -7, 72 },
- { 13, 41 }, { 3, 62 },
-
- /* 70 - 87 */
- { 0, 45 }, { -4, 78 }, { -3, 96 }, { -27, 126 },
- { -28, 98 }, { -25, 101 }, { -23, 67 }, { -28, 82 },
- { -20, 94 }, { -16, 83 }, { -22, 110 }, { -21, 91 },
- { -18, 102 }, { -13, 93 }, { -29, 127 }, { -7, 92 },
- { -5, 89 }, { -7, 96 }, { -13, 108 }, { -3, 46 },
- { -1, 65 }, { -1, 57 }, { -9, 93 }, { -3, 74 },
- { -9, 92 }, { -8, 87 }, { -23, 126 }, { 5, 54 },
- { 6, 60 }, { 6, 59 }, { 6, 69 }, { -1, 48 },
- { 0, 68 }, { -4, 69 }, { -8, 88 },
-
- /* 105 -> 165 */
- { -2, 85 }, { -6, 78 }, { -1, 75 }, { -7, 77 },
- { 2, 54 }, { 5, 50 }, { -3, 68 }, { 1, 50 },
- { 6, 42 }, { -4, 81 }, { 1, 63 }, { -4, 70 },
- { 0, 67 }, { 2, 57 }, { -2, 76 }, { 11, 35 },
- { 4, 64 }, { 1, 61 }, { 11, 35 }, { 18, 25 },
- { 12, 24 }, { 13, 29 }, { 13, 36 }, { -10, 93 },
- { -7, 73 }, { -2, 73 }, { 13, 46 }, { 9, 49 },
- { -7, 100 }, { 9, 53 }, { 2, 53 }, { 5, 53 },
- { -2, 61 }, { 0, 56 }, { 0, 56 }, { -13, 63 },
- { -5, 60 }, { -1, 62 }, { 4, 57 }, { -6, 69 },
- { 4, 57 }, { 14, 39 }, { 4, 51 }, { 13, 68 },
- { 3, 64 }, { 1, 61 }, { 9, 63 }, { 7, 50 },
- { 16, 39 }, { 5, 44 }, { 4, 52 }, { 11, 48 },
- { -5, 60 }, { -1, 59 }, { 0, 59 }, { 22, 33 },
- { 5, 44 }, { 14, 43 }, { -1, 78 }, { 0, 60 },
- { 9, 69 },
-
- /* 166 - 226 */
- { 11, 28 }, { 2, 40 }, { 3, 44 }, { 0, 49 },
- { 0, 46 }, { 2, 44 }, { 2, 51 }, { 0, 47 },
- { 4, 39 }, { 2, 62 }, { 6, 46 }, { 0, 54 },
- { 3, 54 }, { 2, 58 }, { 4, 63 }, { 6, 51 },
- { 6, 57 }, { 7, 53 }, { 6, 52 }, { 6, 55 },
- { 11, 45 }, { 14, 36 }, { 8, 53 }, { -1, 82 },
- { 7, 55 }, { -3, 78 }, { 15, 46 }, { 22, 31 },
- { -1, 84 }, { 25, 7 }, { 30, -7 }, { 28, 3 },
- { 28, 4 }, { 32, 0 }, { 34, -1 }, { 30, 6 },
- { 30, 6 }, { 32, 9 }, { 31, 19 }, { 26, 27 },
- { 26, 30 }, { 37, 20 }, { 28, 34 }, { 17, 70 },
- { 1, 67 }, { 5, 59 }, { 9, 67 }, { 16, 30 },
- { 18, 32 }, { 18, 35 }, { 22, 29 }, { 24, 31 },
- { 23, 38 }, { 18, 43 }, { 20, 41 }, { 11, 63 },
- { 9, 59 }, { 9, 64 }, { -1, 94 }, { -2, 89 },
- { -9, 108 },
-
- /* 227 - 275 */
- { -6, 76 }, { -2, 44 }, { 0, 45 }, { 0, 52 },
- { -3, 64 }, { -2, 59 }, { -4, 70 }, { -4, 75 },
- { -8, 82 }, { -17, 102 }, { -9, 77 }, { 3, 24 },
- { 0, 42 }, { 0, 48 }, { 0, 55 }, { -6, 59 },
- { -7, 71 }, { -12, 83 }, { -11, 87 }, { -30, 119 },
- { 1, 58 }, { -3, 29 }, { -1, 36 }, { 1, 38 },
- { 2, 43 }, { -6, 55 }, { 0, 58 }, { 0, 64 },
- { -3, 74 }, { -10, 90 }, { 0, 70 }, { -4, 29 },
- { 5, 31 }, { 7, 42 }, { 1, 59 }, { -2, 58 },
- { -3, 72 }, { -3, 81 }, { -11, 97 }, { 0, 58 },
- { 8, 5 }, { 10, 14 }, { 14, 18 }, { 13, 27 },
- { 2, 40 }, { 0, 58 }, { -3, 70 }, { -6, 79 },
- { -8, 85 },
-
- /* 276 a bit special (not used, bypass is used instead) */
- { 0, 0 },
-
- /* 277 - 337 */
- { -13, 106 }, { -16, 106 }, { -10, 87 }, { -21, 114 },
- { -18, 110 }, { -14, 98 }, { -22, 110 }, { -21, 106 },
- { -18, 103 }, { -21, 107 }, { -23, 108 }, { -26, 112 },
- { -10, 96 }, { -12, 95 }, { -5, 91 }, { -9, 93 },
- { -22, 94 }, { -5, 86 }, { 9, 67 }, { -4, 80 },
- { -10, 85 }, { -1, 70 }, { 7, 60 }, { 9, 58 },
- { 5, 61 }, { 12, 50 }, { 15, 50 }, { 18, 49 },
- { 17, 54 }, { 10, 41 }, { 7, 46 }, { -1, 51 },
- { 7, 49 }, { 8, 52 }, { 9, 41 }, { 6, 47 },
- { 2, 55 }, { 13, 41 }, { 10, 44 }, { 6, 50 },
- { 5, 53 }, { 13, 49 }, { 4, 63 }, { 6, 64 },
- { -2, 69 }, { -2, 59 }, { 6, 70 }, { 10, 44 },
- { 9, 31 }, { 12, 43 }, { 3, 53 }, { 14, 34 },
- { 10, 38 }, { -3, 52 }, { 13, 40 }, { 17, 32 },
- { 7, 44 }, { 7, 38 }, { 13, 50 }, { 10, 57 },
- { 26, 43 },
-
- /* 338 - 398 */
- { 14, 11 }, { 11, 14 }, { 9, 11 }, { 18, 11 },
- { 21, 9 }, { 23, -2 }, { 32, -15 }, { 32, -15 },
- { 34, -21 }, { 39, -23 }, { 42, -33 }, { 41, -31 },
- { 46, -28 }, { 38, -12 }, { 21, 29 }, { 45, -24 },
- { 53, -45 }, { 48, -26 }, { 65, -43 }, { 43, -19 },
- { 39, -10 }, { 30, 9 }, { 18, 26 }, { 20, 27 },
- { 0, 57 }, { -14, 82 }, { -5, 75 }, { -19, 97 },
- { -35, 125 }, { 27, 0 }, { 28, 0 }, { 31, -4 },
- { 27, 6 }, { 34, 8 }, { 30, 10 }, { 24, 22 },
- { 33, 19 }, { 22, 32 }, { 26, 31 }, { 21, 41 },
- { 26, 44 }, { 23, 47 }, { 16, 65 }, { 14, 71 },
- { 8, 60 }, { 6, 63 }, { 17, 65 }, { 21, 24 },
- { 23, 20 }, { 26, 23 }, { 27, 32 }, { 28, 23 },
- { 28, 24 }, { 23, 40 }, { 24, 32 }, { 28, 29 },
- { 23, 42 }, { 19, 57 }, { 22, 53 }, { 22, 61 },
- { 11, 86 },
-
- /* 399 - 435 */
- { 12, 40 }, { 11, 51 }, { 14, 59 },
- { -4, 79 }, { -7, 71 }, { -5, 69 }, { -9, 70 },
- { -8, 66 }, { -10, 68 }, { -19, 73 }, { -12, 69 },
- { -16, 70 }, { -15, 67 }, { -20, 62 }, { -19, 70 },
- { -16, 66 }, { -22, 65 }, { -20, 63 }, { 9, -2 },
- { 26, -9 }, { 33, -9 }, { 39, -7 }, { 41, -2 },
- { 45, 3 }, { 49, 9 }, { 45, 27 }, { 36, 59 },
- { -6, 66 }, { -7, 35 }, { -7, 42 }, { -8, 45 },
- { -5, 48 }, { -12, 56 }, { -6, 60 }, { -5, 62 },
- { -8, 66 }, { -8, 76 },
-
- /* 436 - 459 */
- { -5, 85 }, { -6, 81 }, { -10, 77 }, { -7, 81 },
- { -17, 80 }, { -18, 73 }, { -4, 74 }, { -10, 83 },
- { -9, 71 }, { -9, 67 }, { -1, 61 }, { -8, 66 },
- { -14, 66 }, { 0, 59 }, { 2, 59 }, { 21, -13 },
- { 33, -14 }, { 39, -7 }, { 46, -2 }, { 51, 2 },
- { 60, 6 }, { 61, 17 }, { 55, 34 }, { 42, 62 },
-
- /* 460 - 1024 */
- { -7, 92 }, { -5, 89 }, { -7, 96 }, { -13, 108 },
- { -3, 46 }, { -1, 65 }, { -1, 57 }, { -9, 93 },
- { -3, 74 }, { -9, 92 }, { -8, 87 }, { -23, 126 },
- { -7, 92 }, { -5, 89 }, { -7, 96 }, { -13, 108 },
- { -3, 46 }, { -1, 65 }, { -1, 57 }, { -9, 93 },
- { -3, 74 }, { -9, 92 }, { -8, 87 }, { -23, 126 },
- { -2, 85 }, { -6, 78 }, { -1, 75 }, { -7, 77 },
- { 2, 54 }, { 5, 50 }, { -3, 68 }, { 1, 50 },
- { 6, 42 }, { -4, 81 }, { 1, 63 }, { -4, 70 },
- { 0, 67 }, { 2, 57 }, { -2, 76 }, { 11, 35 },
- { 4, 64 }, { 1, 61 }, { 11, 35 }, { 18, 25 },
- { 12, 24 }, { 13, 29 }, { 13, 36 }, { -10, 93 },
- { -7, 73 }, { -2, 73 }, { 13, 46 }, { 9, 49 },
- { -7, 100 }, { 9, 53 }, { 2, 53 }, { 5, 53 },
- { -2, 61 }, { 0, 56 }, { 0, 56 }, { -13, 63 },
- { -5, 60 }, { -1, 62 }, { 4, 57 }, { -6, 69 },
- { 4, 57 }, { 14, 39 }, { 4, 51 }, { 13, 68 },
- { -2, 85 }, { -6, 78 }, { -1, 75 }, { -7, 77 },
- { 2, 54 }, { 5, 50 }, { -3, 68 }, { 1, 50 },
- { 6, 42 }, { -4, 81 }, { 1, 63 }, { -4, 70 },
- { 0, 67 }, { 2, 57 }, { -2, 76 }, { 11, 35 },
- { 4, 64 }, { 1, 61 }, { 11, 35 }, { 18, 25 },
- { 12, 24 }, { 13, 29 }, { 13, 36 }, { -10, 93 },
- { -7, 73 }, { -2, 73 }, { 13, 46 }, { 9, 49 },
- { -7, 100 }, { 9, 53 }, { 2, 53 }, { 5, 53 },
- { -2, 61 }, { 0, 56 }, { 0, 56 }, { -13, 63 },
- { -5, 60 }, { -1, 62 }, { 4, 57 }, { -6, 69 },
- { 4, 57 }, { 14, 39 }, { 4, 51 }, { 13, 68 },
- { 11, 28 }, { 2, 40 }, { 3, 44 }, { 0, 49 },
- { 0, 46 }, { 2, 44 }, { 2, 51 }, { 0, 47 },
- { 4, 39 }, { 2, 62 }, { 6, 46 }, { 0, 54 },
- { 3, 54 }, { 2, 58 }, { 4, 63 }, { 6, 51 },
- { 6, 57 }, { 7, 53 }, { 6, 52 }, { 6, 55 },
- { 11, 45 }, { 14, 36 }, { 8, 53 }, { -1, 82 },
- { 7, 55 }, { -3, 78 }, { 15, 46 }, { 22, 31 },
- { -1, 84 }, { 25, 7 }, { 30, -7 }, { 28, 3 },
- { 28, 4 }, { 32, 0 }, { 34, -1 }, { 30, 6 },
- { 30, 6 }, { 32, 9 }, { 31, 19 }, { 26, 27 },
- { 26, 30 }, { 37, 20 }, { 28, 34 }, { 17, 70 },
- { 11, 28 }, { 2, 40 }, { 3, 44 }, { 0, 49 },
- { 0, 46 }, { 2, 44 }, { 2, 51 }, { 0, 47 },
- { 4, 39 }, { 2, 62 }, { 6, 46 }, { 0, 54 },
- { 3, 54 }, { 2, 58 }, { 4, 63 }, { 6, 51 },
- { 6, 57 }, { 7, 53 }, { 6, 52 }, { 6, 55 },
- { 11, 45 }, { 14, 36 }, { 8, 53 }, { -1, 82 },
- { 7, 55 }, { -3, 78 }, { 15, 46 }, { 22, 31 },
- { -1, 84 }, { 25, 7 }, { 30, -7 }, { 28, 3 },
- { 28, 4 }, { 32, 0 }, { 34, -1 }, { 30, 6 },
- { 30, 6 }, { 32, 9 }, { 31, 19 }, { 26, 27 },
- { 26, 30 }, { 37, 20 }, { 28, 34 }, { 17, 70 },
- { -4, 79 }, { -7, 71 }, { -5, 69 }, { -9, 70 },
- { -8, 66 }, { -10, 68 }, { -19, 73 }, { -12, 69 },
- { -16, 70 }, { -15, 67 }, { -20, 62 }, { -19, 70 },
- { -16, 66 }, { -22, 65 }, { -20, 63 }, { -5, 85 },
- { -6, 81 }, { -10, 77 }, { -7, 81 }, { -17, 80 },
- { -18, 73 }, { -4, 74 }, { -10, 83 }, { -9, 71 },
- { -9, 67 }, { -1, 61 }, { -8, 66 }, { -14, 66 },
- { 0, 59 }, { 2, 59 }, { 9, -2 }, { 26, -9 },
- { 33, -9 }, { 39, -7 }, { 41, -2 }, { 45, 3 },
- { 49, 9 }, { 45, 27 }, { 36, 59 }, { 21, -13 },
- { 33, -14 }, { 39, -7 }, { 46, -2 }, { 51, 2 },
- { 60, 6 }, { 61, 17 }, { 55, 34 }, { 42, 62 },
- { -6, 66 }, { -7, 35 }, { -7, 42 }, { -8, 45 },
- { -5, 48 }, { -12, 56 }, { -6, 60 }, { -5, 62 },
- { -8, 66 }, { -8, 76 }, { -4, 79 }, { -7, 71 },
- { -5, 69 }, { -9, 70 }, { -8, 66 }, { -10, 68 },
- { -19, 73 }, { -12, 69 }, { -16, 70 }, { -15, 67 },
- { -20, 62 }, { -19, 70 }, { -16, 66 }, { -22, 65 },
- { -20, 63 }, { -5, 85 }, { -6, 81 }, { -10, 77 },
- { -7, 81 }, { -17, 80 }, { -18, 73 }, { -4, 74 },
- { -10, 83 }, { -9, 71 }, { -9, 67 }, { -1, 61 },
- { -8, 66 }, { -14, 66 }, { 0, 59 }, { 2, 59 },
- { 9, -2 }, { 26, -9 }, { 33, -9 }, { 39, -7 },
- { 41, -2 }, { 45, 3 }, { 49, 9 }, { 45, 27 },
- { 36, 59 }, { 21, -13 }, { 33, -14 }, { 39, -7 },
- { 46, -2 }, { 51, 2 }, { 60, 6 }, { 61, 17 },
- { 55, 34 }, { 42, 62 }, { -6, 66 }, { -7, 35 },
- { -7, 42 }, { -8, 45 }, { -5, 48 }, { -12, 56 },
- { -6, 60 }, { -5, 62 }, { -8, 66 }, { -8, 76 },
- { -13, 106 }, { -16, 106 }, { -10, 87 }, { -21, 114 },
- { -18, 110 }, { -14, 98 }, { -22, 110 }, { -21, 106 },
- { -18, 103 }, { -21, 107 }, { -23, 108 }, { -26, 112 },
- { -10, 96 }, { -12, 95 }, { -5, 91 }, { -9, 93 },
- { -22, 94 }, { -5, 86 }, { 9, 67 }, { -4, 80 },
- { -10, 85 }, { -1, 70 }, { 7, 60 }, { 9, 58 },
- { 5, 61 }, { 12, 50 }, { 15, 50 }, { 18, 49 },
- { 17, 54 }, { 10, 41 }, { 7, 46 }, { -1, 51 },
- { 7, 49 }, { 8, 52 }, { 9, 41 }, { 6, 47 },
- { 2, 55 }, { 13, 41 }, { 10, 44 }, { 6, 50 },
- { 5, 53 }, { 13, 49 }, { 4, 63 }, { 6, 64 },
- { -13, 106 }, { -16, 106 }, { -10, 87 }, { -21, 114 },
- { -18, 110 }, { -14, 98 }, { -22, 110 }, { -21, 106 },
- { -18, 103 }, { -21, 107 }, { -23, 108 }, { -26, 112 },
- { -10, 96 }, { -12, 95 }, { -5, 91 }, { -9, 93 },
- { -22, 94 }, { -5, 86 }, { 9, 67 }, { -4, 80 },
- { -10, 85 }, { -1, 70 }, { 7, 60 }, { 9, 58 },
- { 5, 61 }, { 12, 50 }, { 15, 50 }, { 18, 49 },
- { 17, 54 }, { 10, 41 }, { 7, 46 }, { -1, 51 },
- { 7, 49 }, { 8, 52 }, { 9, 41 }, { 6, 47 },
- { 2, 55 }, { 13, 41 }, { 10, 44 }, { 6, 50 },
- { 5, 53 }, { 13, 49 }, { 4, 63 }, { 6, 64 },
- { 14, 11 }, { 11, 14 }, { 9, 11 }, { 18, 11 },
- { 21, 9 }, { 23, -2 }, { 32, -15 }, { 32, -15 },
- { 34, -21 }, { 39, -23 }, { 42, -33 }, { 41, -31 },
- { 46, -28 }, { 38, -12 }, { 21, 29 }, { 45, -24 },
- { 53, -45 }, { 48, -26 }, { 65, -43 }, { 43, -19 },
- { 39, -10 }, { 30, 9 }, { 18, 26 }, { 20, 27 },
- { 0, 57 }, { -14, 82 }, { -5, 75 }, { -19, 97 },
- { -35, 125 }, { 27, 0 }, { 28, 0 }, { 31, -4 },
- { 27, 6 }, { 34, 8 }, { 30, 10 }, { 24, 22 },
- { 33, 19 }, { 22, 32 }, { 26, 31 }, { 21, 41 },
- { 26, 44 }, { 23, 47 }, { 16, 65 }, { 14, 71 },
- { 14, 11 }, { 11, 14 }, { 9, 11 }, { 18, 11 },
- { 21, 9 }, { 23, -2 }, { 32, -15 }, { 32, -15 },
- { 34, -21 }, { 39, -23 }, { 42, -33 }, { 41, -31 },
- { 46, -28 }, { 38, -12 }, { 21, 29 }, { 45, -24 },
- { 53, -45 }, { 48, -26 }, { 65, -43 }, { 43, -19 },
- { 39, -10 }, { 30, 9 }, { 18, 26 }, { 20, 27 },
- { 0, 57 }, { -14, 82 }, { -5, 75 }, { -19, 97 },
- { -35, 125 }, { 27, 0 }, { 28, 0 }, { 31, -4 },
- { 27, 6 }, { 34, 8 }, { 30, 10 }, { 24, 22 },
- { 33, 19 }, { 22, 32 }, { 26, 31 }, { 21, 41 },
- { 26, 44 }, { 23, 47 }, { 16, 65 }, { 14, 71 },
- { -6, 76 }, { -2, 44 }, { 0, 45 }, { 0, 52 },
- { -3, 64 }, { -2, 59 }, { -4, 70 }, { -4, 75 },
- { -8, 82 }, { -17, 102 }, { -9, 77 }, { 3, 24 },
- { 0, 42 }, { 0, 48 }, { 0, 55 }, { -6, 59 },
- { -7, 71 }, { -12, 83 }, { -11, 87 }, { -30, 119 },
- { 1, 58 }, { -3, 29 }, { -1, 36 }, { 1, 38 },
- { 2, 43 }, { -6, 55 }, { 0, 58 }, { 0, 64 },
- { -3, 74 }, { -10, 90 }, { -6, 76 }, { -2, 44 },
- { 0, 45 }, { 0, 52 }, { -3, 64 }, { -2, 59 },
- { -4, 70 }, { -4, 75 }, { -8, 82 }, { -17, 102 },
- { -9, 77 }, { 3, 24 }, { 0, 42 }, { 0, 48 },
- { 0, 55 }, { -6, 59 }, { -7, 71 }, { -12, 83 },
- { -11, 87 }, { -30, 119 }, { 1, 58 }, { -3, 29 },
- { -1, 36 }, { 1, 38 }, { 2, 43 }, { -6, 55 },
- { 0, 58 }, { 0, 64 }, { -3, 74 }, { -10, 90 },
- { -3, 74 }, { -9, 92 }, { -8, 87 }, { -23, 126 },
- { -3, 74 }, { -9, 92 }, { -8, 87 }, { -23, 126 },
- { -3, 74 }, { -9, 92 }, { -8, 87 }, { -23, 126 }
- },
-
- /* i_cabac_init_idc == 1 */
- {
- /* 0 - 10 */
- { 20, -15 }, { 2, 54 }, { 3, 74 }, { 20, -15 },
- { 2, 54 }, { 3, 74 }, { -28, 127 }, { -23, 104 },
- { -6, 53 }, { -1, 54 }, { 7, 51 },
-
- /* 11 - 23 */
- { 22, 25 }, { 34, 0 }, { 16, 0 }, { -2, 9 },
- { 4, 41 }, { -29, 118 }, { 2, 65 }, { -6, 71 },
- { -13, 79 }, { 5, 52 }, { 9, 50 }, { -3, 70 },
- { 10, 54 },
-
- /* 24 - 39 */
- { 26, 34 }, { 19, 22 }, { 40, 0 }, { 57, 2 },
- { 41, 36 }, { 26, 69 }, { -45, 127 }, { -15, 101 },
- { -4, 76 }, { -6, 71 }, { -13, 79 }, { 5, 52 },
- { 6, 69 }, { -13, 90 }, { 0, 52 }, { 8, 43 },
-
- /* 40 - 53 */
- { -2, 69 },{ -5, 82 },{ -10, 96 },{ 2, 59 },
- { 2, 75 },{ -3, 87 },{ -3, 100 },{ 1, 56 },
- { -3, 74 },{ -6, 85 },{ 0, 59 },{ -3, 81 },
- { -7, 86 },{ -5, 95 },
-
- /* 54 - 59 */
- { -1, 66 },{ -1, 77 },{ 1, 70 },{ -2, 86 },
- { -5, 72 },{ 0, 61 },
-
- /* 60 - 69 */
- { 0, 41 }, { 0, 63 }, { 0, 63 }, { 0, 63 },
- { -9, 83 }, { 4, 86 }, { 0, 97 }, { -7, 72 },
- { 13, 41 }, { 3, 62 },
-
- /* 70 - 104 */
- { 13, 15 }, { 7, 51 }, { 2, 80 }, { -39, 127 },
- { -18, 91 }, { -17, 96 }, { -26, 81 }, { -35, 98 },
- { -24, 102 }, { -23, 97 }, { -27, 119 }, { -24, 99 },
- { -21, 110 }, { -18, 102 }, { -36, 127 }, { 0, 80 },
- { -5, 89 }, { -7, 94 }, { -4, 92 }, { 0, 39 },
- { 0, 65 }, { -15, 84 }, { -35, 127 }, { -2, 73 },
- { -12, 104 }, { -9, 91 }, { -31, 127 }, { 3, 55 },
- { 7, 56 }, { 7, 55 }, { 8, 61 }, { -3, 53 },
- { 0, 68 }, { -7, 74 }, { -9, 88 },
-
- /* 105 -> 165 */
- { -13, 103 }, { -13, 91 }, { -9, 89 }, { -14, 92 },
- { -8, 76 }, { -12, 87 }, { -23, 110 }, { -24, 105 },
- { -10, 78 }, { -20, 112 }, { -17, 99 }, { -78, 127 },
- { -70, 127 }, { -50, 127 }, { -46, 127 }, { -4, 66 },
- { -5, 78 }, { -4, 71 }, { -8, 72 }, { 2, 59 },
- { -1, 55 }, { -7, 70 }, { -6, 75 }, { -8, 89 },
- { -34, 119 }, { -3, 75 }, { 32, 20 }, { 30, 22 },
- { -44, 127 }, { 0, 54 }, { -5, 61 }, { 0, 58 },
- { -1, 60 }, { -3, 61 }, { -8, 67 }, { -25, 84 },
- { -14, 74 }, { -5, 65 }, { 5, 52 }, { 2, 57 },
- { 0, 61 }, { -9, 69 }, { -11, 70 }, { 18, 55 },
- { -4, 71 }, { 0, 58 }, { 7, 61 }, { 9, 41 },
- { 18, 25 }, { 9, 32 }, { 5, 43 }, { 9, 47 },
- { 0, 44 }, { 0, 51 }, { 2, 46 }, { 19, 38 },
- { -4, 66 }, { 15, 38 }, { 12, 42 }, { 9, 34 },
- { 0, 89 },
-
- /* 166 - 226 */
- { 4, 45 }, { 10, 28 }, { 10, 31 }, { 33, -11 },
- { 52, -43 }, { 18, 15 }, { 28, 0 }, { 35, -22 },
- { 38, -25 }, { 34, 0 }, { 39, -18 }, { 32, -12 },
- { 102, -94 }, { 0, 0 }, { 56, -15 }, { 33, -4 },
- { 29, 10 }, { 37, -5 }, { 51, -29 }, { 39, -9 },
- { 52, -34 }, { 69, -58 }, { 67, -63 }, { 44, -5 },
- { 32, 7 }, { 55, -29 }, { 32, 1 }, { 0, 0 },
- { 27, 36 }, { 33, -25 }, { 34, -30 }, { 36, -28 },
- { 38, -28 }, { 38, -27 }, { 34, -18 }, { 35, -16 },
- { 34, -14 }, { 32, -8 }, { 37, -6 }, { 35, 0 },
- { 30, 10 }, { 28, 18 }, { 26, 25 }, { 29, 41 },
- { 0, 75 }, { 2, 72 }, { 8, 77 }, { 14, 35 },
- { 18, 31 }, { 17, 35 }, { 21, 30 }, { 17, 45 },
- { 20, 42 }, { 18, 45 }, { 27, 26 }, { 16, 54 },
- { 7, 66 }, { 16, 56 }, { 11, 73 }, { 10, 67 },
- { -10, 116 },
-
- /* 227 - 275 */
- { -23, 112 }, { -15, 71 }, { -7, 61 }, { 0, 53 },
- { -5, 66 }, { -11, 77 }, { -9, 80 }, { -9, 84 },
- { -10, 87 }, { -34, 127 }, { -21, 101 }, { -3, 39 },
- { -5, 53 }, { -7, 61 }, { -11, 75 }, { -15, 77 },
- { -17, 91 }, { -25, 107 }, { -25, 111 }, { -28, 122 },
- { -11, 76 }, { -10, 44 }, { -10, 52 }, { -10, 57 },
- { -9, 58 }, { -16, 72 }, { -7, 69 }, { -4, 69 },
- { -5, 74 }, { -9, 86 }, { 2, 66 }, { -9, 34 },
- { 1, 32 }, { 11, 31 }, { 5, 52 }, { -2, 55 },
- { -2, 67 }, { 0, 73 }, { -8, 89 }, { 3, 52 },
- { 7, 4 }, { 10, 8 }, { 17, 8 }, { 16, 19 },
- { 3, 37 }, { -1, 61 }, { -5, 73 }, { -1, 70 },
- { -4, 78 },
-
- /* 276 a bit special (not used, bypass is used instead) */
- { 0, 0 },
-
- /* 277 - 337 */
- { -21, 126 }, { -23, 124 }, { -20, 110 }, { -26, 126 },
- { -25, 124 }, { -17, 105 }, { -27, 121 }, { -27, 117 },
- { -17, 102 }, { -26, 117 }, { -27, 116 }, { -33, 122 },
- { -10, 95 }, { -14, 100 }, { -8, 95 }, { -17, 111 },
- { -28, 114 }, { -6, 89 }, { -2, 80 }, { -4, 82 },
- { -9, 85 }, { -8, 81 }, { -1, 72 }, { 5, 64 },
- { 1, 67 }, { 9, 56 }, { 0, 69 }, { 1, 69 },
- { 7, 69 }, { -7, 69 }, { -6, 67 }, { -16, 77 },
- { -2, 64 }, { 2, 61 }, { -6, 67 }, { -3, 64 },
- { 2, 57 }, { -3, 65 }, { -3, 66 }, { 0, 62 },
- { 9, 51 }, { -1, 66 }, { -2, 71 }, { -2, 75 },
- { -1, 70 }, { -9, 72 }, { 14, 60 }, { 16, 37 },
- { 0, 47 }, { 18, 35 }, { 11, 37 }, { 12, 41 },
- { 10, 41 }, { 2, 48 }, { 12, 41 }, { 13, 41 },
- { 0, 59 }, { 3, 50 }, { 19, 40 }, { 3, 66 },
- { 18, 50 },
-
- /* 338 - 398 */
- { 19, -6 }, { 18, -6 }, { 14, 0 }, { 26, -12 },
- { 31, -16 }, { 33, -25 }, { 33, -22 }, { 37, -28 },
- { 39, -30 }, { 42, -30 }, { 47, -42 }, { 45, -36 },
- { 49, -34 }, { 41, -17 }, { 32, 9 }, { 69, -71 },
- { 63, -63 }, { 66, -64 }, { 77, -74 }, { 54, -39 },
- { 52, -35 }, { 41, -10 }, { 36, 0 }, { 40, -1 },
- { 30, 14 }, { 28, 26 }, { 23, 37 }, { 12, 55 },
- { 11, 65 }, { 37, -33 }, { 39, -36 }, { 40, -37 },
- { 38, -30 }, { 46, -33 }, { 42, -30 }, { 40, -24 },
- { 49, -29 }, { 38, -12 }, { 40, -10 }, { 38, -3 },
- { 46, -5 }, { 31, 20 }, { 29, 30 }, { 25, 44 },
- { 12, 48 }, { 11, 49 }, { 26, 45 }, { 22, 22 },
- { 23, 22 }, { 27, 21 }, { 33, 20 }, { 26, 28 },
- { 30, 24 }, { 27, 34 }, { 18, 42 }, { 25, 39 },
- { 18, 50 }, { 12, 70 }, { 21, 54 }, { 14, 71 },
- { 11, 83 },
-
- /* 399 - 435 */
- { 25, 32 }, { 21, 49 }, { 21, 54 },
- { -5, 85 }, { -6, 81 }, { -10, 77 }, { -7, 81 },
- { -17, 80 }, { -18, 73 }, { -4, 74 }, { -10, 83 },
- { -9, 71 }, { -9, 67 }, { -1, 61 }, { -8, 66 },
- { -14, 66 }, { 0, 59 }, { 2, 59 }, { 17, -10 },
- { 32, -13 }, { 42, -9 }, { 49, -5 }, { 53, 0 },
- { 64, 3 }, { 68, 10 }, { 66, 27 }, { 47, 57 },
- { -5, 71 }, { 0, 24 }, { -1, 36 }, { -2, 42 },
- { -2, 52 }, { -9, 57 }, { -6, 63 }, { -4, 65 },
- { -4, 67 }, { -7, 82 },
-
- /* 436 - 459 */
- { -3, 81 }, { -3, 76 }, { -7, 72 }, { -6, 78 },
- { -12, 72 }, { -14, 68 }, { -3, 70 }, { -6, 76 },
- { -5, 66 }, { -5, 62 }, { 0, 57 }, { -4, 61 },
- { -9, 60 }, { 1, 54 }, { 2, 58 }, { 17, -10 },
- { 32, -13 }, { 42, -9 }, { 49, -5 }, { 53, 0 },
- { 64, 3 }, { 68, 10 }, { 66, 27 }, { 47, 57 },
-
- /* 460 - 1024 */
- { 0, 80 }, { -5, 89 }, { -7, 94 }, { -4, 92 },
- { 0, 39 }, { 0, 65 }, { -15, 84 }, { -35, 127 },
- { -2, 73 }, { -12, 104 }, { -9, 91 }, { -31, 127 },
- { 0, 80 }, { -5, 89 }, { -7, 94 }, { -4, 92 },
- { 0, 39 }, { 0, 65 }, { -15, 84 }, { -35, 127 },
- { -2, 73 }, { -12, 104 }, { -9, 91 }, { -31, 127 },
- { -13, 103 }, { -13, 91 }, { -9, 89 }, { -14, 92 },
- { -8, 76 }, { -12, 87 }, { -23, 110 }, { -24, 105 },
- { -10, 78 }, { -20, 112 }, { -17, 99 }, { -78, 127 },
- { -70, 127 }, { -50, 127 }, { -46, 127 }, { -4, 66 },
- { -5, 78 }, { -4, 71 }, { -8, 72 }, { 2, 59 },
- { -1, 55 }, { -7, 70 }, { -6, 75 }, { -8, 89 },
- { -34, 119 }, { -3, 75 }, { 32, 20 }, { 30, 22 },
- { -44, 127 }, { 0, 54 }, { -5, 61 }, { 0, 58 },
- { -1, 60 }, { -3, 61 }, { -8, 67 }, { -25, 84 },
- { -14, 74 }, { -5, 65 }, { 5, 52 }, { 2, 57 },
- { 0, 61 }, { -9, 69 }, { -11, 70 }, { 18, 55 },
- { -13, 103 }, { -13, 91 }, { -9, 89 }, { -14, 92 },
- { -8, 76 }, { -12, 87 }, { -23, 110 }, { -24, 105 },
- { -10, 78 }, { -20, 112 }, { -17, 99 }, { -78, 127 },
- { -70, 127 }, { -50, 127 }, { -46, 127 }, { -4, 66 },
- { -5, 78 }, { -4, 71 }, { -8, 72 }, { 2, 59 },
- { -1, 55 }, { -7, 70 }, { -6, 75 }, { -8, 89 },
- { -34, 119 }, { -3, 75 }, { 32, 20 }, { 30, 22 },
- { -44, 127 }, { 0, 54 }, { -5, 61 }, { 0, 58 },
- { -1, 60 }, { -3, 61 }, { -8, 67 }, { -25, 84 },
- { -14, 74 }, { -5, 65 }, { 5, 52 }, { 2, 57 },
- { 0, 61 }, { -9, 69 }, { -11, 70 }, { 18, 55 },
- { 4, 45 }, { 10, 28 }, { 10, 31 }, { 33, -11 },
- { 52, -43 }, { 18, 15 }, { 28, 0 }, { 35, -22 },
- { 38, -25 }, { 34, 0 }, { 39, -18 }, { 32, -12 },
- { 102, -94 }, { 0, 0 }, { 56, -15 }, { 33, -4 },
- { 29, 10 }, { 37, -5 }, { 51, -29 }, { 39, -9 },
- { 52, -34 }, { 69, -58 }, { 67, -63 }, { 44, -5 },
- { 32, 7 }, { 55, -29 }, { 32, 1 }, { 0, 0 },
- { 27, 36 }, { 33, -25 }, { 34, -30 }, { 36, -28 },
- { 38, -28 }, { 38, -27 }, { 34, -18 }, { 35, -16 },
- { 34, -14 }, { 32, -8 }, { 37, -6 }, { 35, 0 },
- { 30, 10 }, { 28, 18 }, { 26, 25 }, { 29, 41 },
- { 4, 45 }, { 10, 28 }, { 10, 31 }, { 33, -11 },
- { 52, -43 }, { 18, 15 }, { 28, 0 }, { 35, -22 },
- { 38, -25 }, { 34, 0 }, { 39, -18 }, { 32, -12 },
- { 102, -94 }, { 0, 0 }, { 56, -15 }, { 33, -4 },
- { 29, 10 }, { 37, -5 }, { 51, -29 }, { 39, -9 },
- { 52, -34 }, { 69, -58 }, { 67, -63 }, { 44, -5 },
- { 32, 7 }, { 55, -29 }, { 32, 1 }, { 0, 0 },
- { 27, 36 }, { 33, -25 }, { 34, -30 }, { 36, -28 },
- { 38, -28 }, { 38, -27 }, { 34, -18 }, { 35, -16 },
- { 34, -14 }, { 32, -8 }, { 37, -6 }, { 35, 0 },
- { 30, 10 }, { 28, 18 }, { 26, 25 }, { 29, 41 },
- { -5, 85 }, { -6, 81 }, { -10, 77 }, { -7, 81 },
- { -17, 80 }, { -18, 73 }, { -4, 74 }, { -10, 83 },
- { -9, 71 }, { -9, 67 }, { -1, 61 }, { -8, 66 },
- { -14, 66 }, { 0, 59 }, { 2, 59 }, { -3, 81 },
- { -3, 76 }, { -7, 72 }, { -6, 78 }, { -12, 72 },
- { -14, 68 }, { -3, 70 }, { -6, 76 }, { -5, 66 },
- { -5, 62 }, { 0, 57 }, { -4, 61 }, { -9, 60 },
- { 1, 54 }, { 2, 58 }, { 17, -10 }, { 32, -13 },
- { 42, -9 }, { 49, -5 }, { 53, 0 }, { 64, 3 },
- { 68, 10 }, { 66, 27 }, { 47, 57 }, { 17, -10 },
- { 32, -13 }, { 42, -9 }, { 49, -5 }, { 53, 0 },
- { 64, 3 }, { 68, 10 }, { 66, 27 }, { 47, 57 },
- { -5, 71 }, { 0, 24 }, { -1, 36 }, { -2, 42 },
- { -2, 52 }, { -9, 57 }, { -6, 63 }, { -4, 65 },
- { -4, 67 }, { -7, 82 }, { -5, 85 }, { -6, 81 },
- { -10, 77 }, { -7, 81 }, { -17, 80 }, { -18, 73 },
- { -4, 74 }, { -10, 83 }, { -9, 71 }, { -9, 67 },
- { -1, 61 }, { -8, 66 }, { -14, 66 }, { 0, 59 },
- { 2, 59 }, { -3, 81 }, { -3, 76 }, { -7, 72 },
- { -6, 78 }, { -12, 72 }, { -14, 68 }, { -3, 70 },
- { -6, 76 }, { -5, 66 }, { -5, 62 }, { 0, 57 },
- { -4, 61 }, { -9, 60 }, { 1, 54 }, { 2, 58 },
- { 17, -10 }, { 32, -13 }, { 42, -9 }, { 49, -5 },
- { 53, 0 }, { 64, 3 }, { 68, 10 }, { 66, 27 },
- { 47, 57 }, { 17, -10 }, { 32, -13 }, { 42, -9 },
- { 49, -5 }, { 53, 0 }, { 64, 3 }, { 68, 10 },
- { 66, 27 }, { 47, 57 }, { -5, 71 }, { 0, 24 },
- { -1, 36 }, { -2, 42 }, { -2, 52 }, { -9, 57 },
- { -6, 63 }, { -4, 65 }, { -4, 67 }, { -7, 82 },
- { -21, 126 }, { -23, 124 }, { -20, 110 }, { -26, 126 },
- { -25, 124 }, { -17, 105 }, { -27, 121 }, { -27, 117 },
- { -17, 102 }, { -26, 117 }, { -27, 116 }, { -33, 122 },
- { -10, 95 }, { -14, 100 }, { -8, 95 }, { -17, 111 },
- { -28, 114 }, { -6, 89 }, { -2, 80 }, { -4, 82 },
- { -9, 85 }, { -8, 81 }, { -1, 72 }, { 5, 64 },
- { 1, 67 }, { 9, 56 }, { 0, 69 }, { 1, 69 },
- { 7, 69 }, { -7, 69 }, { -6, 67 }, { -16, 77 },
- { -2, 64 }, { 2, 61 }, { -6, 67 }, { -3, 64 },
- { 2, 57 }, { -3, 65 }, { -3, 66 }, { 0, 62 },
- { 9, 51 }, { -1, 66 }, { -2, 71 }, { -2, 75 },
- { -21, 126 }, { -23, 124 }, { -20, 110 }, { -26, 126 },
- { -25, 124 }, { -17, 105 }, { -27, 121 }, { -27, 117 },
- { -17, 102 }, { -26, 117 }, { -27, 116 }, { -33, 122 },
- { -10, 95 }, { -14, 100 }, { -8, 95 }, { -17, 111 },
- { -28, 114 }, { -6, 89 }, { -2, 80 }, { -4, 82 },
- { -9, 85 }, { -8, 81 }, { -1, 72 }, { 5, 64 },
- { 1, 67 }, { 9, 56 }, { 0, 69 }, { 1, 69 },
- { 7, 69 }, { -7, 69 }, { -6, 67 }, { -16, 77 },
- { -2, 64 }, { 2, 61 }, { -6, 67 }, { -3, 64 },
- { 2, 57 }, { -3, 65 }, { -3, 66 }, { 0, 62 },
- { 9, 51 }, { -1, 66 }, { -2, 71 }, { -2, 75 },
- { 19, -6 }, { 18, -6 }, { 14, 0 }, { 26, -12 },
- { 31, -16 }, { 33, -25 }, { 33, -22 }, { 37, -28 },
- { 39, -30 }, { 42, -30 }, { 47, -42 }, { 45, -36 },
- { 49, -34 }, { 41, -17 }, { 32, 9 }, { 69, -71 },
- { 63, -63 }, { 66, -64 }, { 77, -74 }, { 54, -39 },
- { 52, -35 }, { 41, -10 }, { 36, 0 }, { 40, -1 },
- { 30, 14 }, { 28, 26 }, { 23, 37 }, { 12, 55 },
- { 11, 65 }, { 37, -33 }, { 39, -36 }, { 40, -37 },
- { 38, -30 }, { 46, -33 }, { 42, -30 }, { 40, -24 },
- { 49, -29 }, { 38, -12 }, { 40, -10 }, { 38, -3 },
- { 46, -5 }, { 31, 20 }, { 29, 30 }, { 25, 44 },
- { 19, -6 }, { 18, -6 }, { 14, 0 }, { 26, -12 },
- { 31, -16 }, { 33, -25 }, { 33, -22 }, { 37, -28 },
- { 39, -30 }, { 42, -30 }, { 47, -42 }, { 45, -36 },
- { 49, -34 }, { 41, -17 }, { 32, 9 }, { 69, -71 },
- { 63, -63 }, { 66, -64 }, { 77, -74 }, { 54, -39 },
- { 52, -35 }, { 41, -10 }, { 36, 0 }, { 40, -1 },
- { 30, 14 }, { 28, 26 }, { 23, 37 }, { 12, 55 },
- { 11, 65 }, { 37, -33 }, { 39, -36 }, { 40, -37 },
- { 38, -30 }, { 46, -33 }, { 42, -30 }, { 40, -24 },
- { 49, -29 }, { 38, -12 }, { 40, -10 }, { 38, -3 },
- { 46, -5 }, { 31, 20 }, { 29, 30 }, { 25, 44 },
- { -23, 112 }, { -15, 71 }, { -7, 61 }, { 0, 53 },
- { -5, 66 }, { -11, 77 }, { -9, 80 }, { -9, 84 },
- { -10, 87 }, { -34, 127 }, { -21, 101 }, { -3, 39 },
- { -5, 53 }, { -7, 61 }, { -11, 75 }, { -15, 77 },
- { -17, 91 }, { -25, 107 }, { -25, 111 }, { -28, 122 },
- { -11, 76 }, { -10, 44 }, { -10, 52 }, { -10, 57 },
- { -9, 58 }, { -16, 72 }, { -7, 69 }, { -4, 69 },
- { -5, 74 }, { -9, 86 }, { -23, 112 }, { -15, 71 },
- { -7, 61 }, { 0, 53 }, { -5, 66 }, { -11, 77 },
- { -9, 80 }, { -9, 84 }, { -10, 87 }, { -34, 127 },
- { -21, 101 }, { -3, 39 }, { -5, 53 }, { -7, 61 },
- { -11, 75 }, { -15, 77 }, { -17, 91 }, { -25, 107 },
- { -25, 111 }, { -28, 122 }, { -11, 76 }, { -10, 44 },
- { -10, 52 }, { -10, 57 }, { -9, 58 }, { -16, 72 },
- { -7, 69 }, { -4, 69 }, { -5, 74 }, { -9, 86 },
- { -2, 73 }, { -12, 104 }, { -9, 91 }, { -31, 127 },
- { -2, 73 }, { -12, 104 }, { -9, 91 }, { -31, 127 },
- { -2, 73 }, { -12, 104 }, { -9, 91 }, { -31, 127 }
- },
-
- /* i_cabac_init_idc == 2 */
- {
- /* 0 - 10 */
- { 20, -15 }, { 2, 54 }, { 3, 74 }, { 20, -15 },
- { 2, 54 }, { 3, 74 }, { -28, 127 }, { -23, 104 },
- { -6, 53 }, { -1, 54 }, { 7, 51 },
-
- /* 11 - 23 */
- { 29, 16 }, { 25, 0 }, { 14, 0 }, { -10, 51 },
- { -3, 62 }, { -27, 99 }, { 26, 16 }, { -4, 85 },
- { -24, 102 }, { 5, 57 }, { 6, 57 }, { -17, 73 },
- { 14, 57 },
-
- /* 24 - 39 */
- { 20, 40 }, { 20, 10 }, { 29, 0 }, { 54, 0 },
- { 37, 42 }, { 12, 97 }, { -32, 127 }, { -22, 117 },
- { -2, 74 }, { -4, 85 }, { -24, 102 }, { 5, 57 },
- { -6, 93 }, { -14, 88 }, { -6, 44 }, { 4, 55 },
-
- /* 40 - 53 */
- { -11, 89 },{ -15, 103 },{ -21, 116 },{ 19, 57 },
- { 20, 58 },{ 4, 84 },{ 6, 96 },{ 1, 63 },
- { -5, 85 },{ -13, 106 },{ 5, 63 },{ 6, 75 },
- { -3, 90 },{ -1, 101 },
-
- /* 54 - 59 */
- { 3, 55 },{ -4, 79 },{ -2, 75 },{ -12, 97 },
- { -7, 50 },{ 1, 60 },
-
- /* 60 - 69 */
- { 0, 41 }, { 0, 63 }, { 0, 63 }, { 0, 63 },
- { -9, 83 }, { 4, 86 }, { 0, 97 }, { -7, 72 },
- { 13, 41 }, { 3, 62 },
-
- /* 70 - 104 */
- { 7, 34 }, { -9, 88 }, { -20, 127 }, { -36, 127 },
- { -17, 91 }, { -14, 95 }, { -25, 84 }, { -25, 86 },
- { -12, 89 }, { -17, 91 }, { -31, 127 }, { -14, 76 },
- { -18, 103 }, { -13, 90 }, { -37, 127 }, { 11, 80 },
- { 5, 76 }, { 2, 84 }, { 5, 78 }, { -6, 55 },
- { 4, 61 }, { -14, 83 }, { -37, 127 }, { -5, 79 },
- { -11, 104 }, { -11, 91 }, { -30, 127 }, { 0, 65 },
- { -2, 79 }, { 0, 72 }, { -4, 92 }, { -6, 56 },
- { 3, 68 }, { -8, 71 }, { -13, 98 },
-
- /* 105 -> 165 */
- { -4, 86 }, { -12, 88 }, { -5, 82 }, { -3, 72 },
- { -4, 67 }, { -8, 72 }, { -16, 89 }, { -9, 69 },
- { -1, 59 }, { 5, 66 }, { 4, 57 }, { -4, 71 },
- { -2, 71 }, { 2, 58 }, { -1, 74 }, { -4, 44 },
- { -1, 69 }, { 0, 62 }, { -7, 51 }, { -4, 47 },
- { -6, 42 }, { -3, 41 }, { -6, 53 }, { 8, 76 },
- { -9, 78 }, { -11, 83 }, { 9, 52 }, { 0, 67 },
- { -5, 90 }, { 1, 67 }, { -15, 72 }, { -5, 75 },
- { -8, 80 }, { -21, 83 }, { -21, 64 }, { -13, 31 },
- { -25, 64 }, { -29, 94 }, { 9, 75 }, { 17, 63 },
- { -8, 74 }, { -5, 35 }, { -2, 27 }, { 13, 91 },
- { 3, 65 }, { -7, 69 }, { 8, 77 }, { -10, 66 },
- { 3, 62 }, { -3, 68 }, { -20, 81 }, { 0, 30 },
- { 1, 7 }, { -3, 23 }, { -21, 74 }, { 16, 66 },
- { -23, 124 }, { 17, 37 }, { 44, -18 }, { 50, -34 },
- { -22, 127 },
-
- /* 166 - 226 */
- { 4, 39 }, { 0, 42 }, { 7, 34 }, { 11, 29 },
- { 8, 31 }, { 6, 37 }, { 7, 42 }, { 3, 40 },
- { 8, 33 }, { 13, 43 }, { 13, 36 }, { 4, 47 },
- { 3, 55 }, { 2, 58 }, { 6, 60 }, { 8, 44 },
- { 11, 44 }, { 14, 42 }, { 7, 48 }, { 4, 56 },
- { 4, 52 }, { 13, 37 }, { 9, 49 }, { 19, 58 },
- { 10, 48 }, { 12, 45 }, { 0, 69 }, { 20, 33 },
- { 8, 63 }, { 35, -18 }, { 33, -25 }, { 28, -3 },
- { 24, 10 }, { 27, 0 }, { 34, -14 }, { 52, -44 },
- { 39, -24 }, { 19, 17 }, { 31, 25 }, { 36, 29 },
- { 24, 33 }, { 34, 15 }, { 30, 20 }, { 22, 73 },
- { 20, 34 }, { 19, 31 }, { 27, 44 }, { 19, 16 },
- { 15, 36 }, { 15, 36 }, { 21, 28 }, { 25, 21 },
- { 30, 20 }, { 31, 12 }, { 27, 16 }, { 24, 42 },
- { 0, 93 }, { 14, 56 }, { 15, 57 }, { 26, 38 },
- { -24, 127 },
-
- /* 227 - 275 */
- { -24, 115 }, { -22, 82 }, { -9, 62 }, { 0, 53 },
- { 0, 59 }, { -14, 85 }, { -13, 89 }, { -13, 94 },
- { -11, 92 }, { -29, 127 }, { -21, 100 }, { -14, 57 },
- { -12, 67 }, { -11, 71 }, { -10, 77 }, { -21, 85 },
- { -16, 88 }, { -23, 104 }, { -15, 98 }, { -37, 127 },
- { -10, 82 }, { -8, 48 }, { -8, 61 }, { -8, 66 },
- { -7, 70 }, { -14, 75 }, { -10, 79 }, { -9, 83 },
- { -12, 92 }, { -18, 108 }, { -4, 79 }, { -22, 69 },
- { -16, 75 }, { -2, 58 }, { 1, 58 }, { -13, 78 },
- { -9, 83 }, { -4, 81 }, { -13, 99 }, { -13, 81 },
- { -6, 38 }, { -13, 62 }, { -6, 58 }, { -2, 59 },
- { -16, 73 }, { -10, 76 }, { -13, 86 }, { -9, 83 },
- { -10, 87 },
-
- /* 276 a bit special (not used, bypass is used instead) */
- { 0, 0 },
-
- /* 277 - 337 */
- { -22, 127 }, { -25, 127 }, { -25, 120 }, { -27, 127 },
- { -19, 114 }, { -23, 117 }, { -25, 118 }, { -26, 117 },
- { -24, 113 }, { -28, 118 }, { -31, 120 }, { -37, 124 },
- { -10, 94 }, { -15, 102 }, { -10, 99 }, { -13, 106 },
- { -50, 127 }, { -5, 92 }, { 17, 57 }, { -5, 86 },
- { -13, 94 }, { -12, 91 }, { -2, 77 }, { 0, 71 },
- { -1, 73 }, { 4, 64 }, { -7, 81 }, { 5, 64 },
- { 15, 57 }, { 1, 67 }, { 0, 68 }, { -10, 67 },
- { 1, 68 }, { 0, 77 }, { 2, 64 }, { 0, 68 },
- { -5, 78 }, { 7, 55 }, { 5, 59 }, { 2, 65 },
- { 14, 54 }, { 15, 44 }, { 5, 60 }, { 2, 70 },
- { -2, 76 }, { -18, 86 }, { 12, 70 }, { 5, 64 },
- { -12, 70 }, { 11, 55 }, { 5, 56 }, { 0, 69 },
- { 2, 65 }, { -6, 74 }, { 5, 54 }, { 7, 54 },
- { -6, 76 }, { -11, 82 }, { -2, 77 }, { -2, 77 },
- { 25, 42 },
-
- /* 338 - 398 */
- { 17, -13 }, { 16, -9 }, { 17, -12 }, { 27, -21 },
- { 37, -30 }, { 41, -40 }, { 42, -41 }, { 48, -47 },
- { 39, -32 }, { 46, -40 }, { 52, -51 }, { 46, -41 },
- { 52, -39 }, { 43, -19 }, { 32, 11 }, { 61, -55 },
- { 56, -46 }, { 62, -50 }, { 81, -67 }, { 45, -20 },
- { 35, -2 }, { 28, 15 }, { 34, 1 }, { 39, 1 },
- { 30, 17 }, { 20, 38 }, { 18, 45 }, { 15, 54 },
- { 0, 79 }, { 36, -16 }, { 37, -14 }, { 37, -17 },
- { 32, 1 }, { 34, 15 }, { 29, 15 }, { 24, 25 },
- { 34, 22 }, { 31, 16 }, { 35, 18 }, { 31, 28 },
- { 33, 41 }, { 36, 28 }, { 27, 47 }, { 21, 62 },
- { 18, 31 }, { 19, 26 }, { 36, 24 }, { 24, 23 },
- { 27, 16 }, { 24, 30 }, { 31, 29 }, { 22, 41 },
- { 22, 42 }, { 16, 60 }, { 15, 52 }, { 14, 60 },
- { 3, 78 }, { -16, 123 }, { 21, 53 }, { 22, 56 },
- { 25, 61 },
-
- /* 399 - 435 */
- { 21, 33 }, { 19, 50 }, { 17, 61 },
- { -3, 78 }, { -8, 74 }, { -9, 72 }, { -10, 72 },
- { -18, 75 }, { -12, 71 }, { -11, 63 }, { -5, 70 },
- { -17, 75 }, { -14, 72 }, { -16, 67 }, { -8, 53 },
- { -14, 59 }, { -9, 52 }, { -11, 68 }, { 9, -2 },
- { 30, -10 }, { 31, -4 }, { 33, -1 }, { 33, 7 },
- { 31, 12 }, { 37, 23 }, { 31, 38 }, { 20, 64 },
- { -9, 71 }, { -7, 37 }, { -8, 44 }, { -11, 49 },
- { -10, 56 }, { -12, 59 }, { -8, 63 }, { -9, 67 },
- { -6, 68 }, { -10, 79 },
-
- /* 436 - 459 */
- { -3, 78 }, { -8, 74 }, { -9, 72 }, { -10, 72 },
- { -18, 75 }, { -12, 71 }, { -11, 63 }, { -5, 70 },
- { -17, 75 }, { -14, 72 }, { -16, 67 }, { -8, 53 },
- { -14, 59 }, { -9, 52 }, { -11, 68 }, { 9, -2 },
- { 30, -10 }, { 31, -4 }, { 33, -1 }, { 33, 7 },
- { 31, 12 }, { 37, 23 }, { 31, 38 }, { 20, 64 },
-
- /* 460 - 1024 */
- { 11, 80 }, { 5, 76 }, { 2, 84 }, { 5, 78 },
- { -6, 55 }, { 4, 61 }, { -14, 83 }, { -37, 127 },
- { -5, 79 }, { -11, 104 }, { -11, 91 }, { -30, 127 },
- { 11, 80 }, { 5, 76 }, { 2, 84 }, { 5, 78 },
- { -6, 55 }, { 4, 61 }, { -14, 83 }, { -37, 127 },
- { -5, 79 }, { -11, 104 }, { -11, 91 }, { -30, 127 },
- { -4, 86 }, { -12, 88 }, { -5, 82 }, { -3, 72 },
- { -4, 67 }, { -8, 72 }, { -16, 89 }, { -9, 69 },
- { -1, 59 }, { 5, 66 }, { 4, 57 }, { -4, 71 },
- { -2, 71 }, { 2, 58 }, { -1, 74 }, { -4, 44 },
- { -1, 69 }, { 0, 62 }, { -7, 51 }, { -4, 47 },
- { -6, 42 }, { -3, 41 }, { -6, 53 }, { 8, 76 },
- { -9, 78 }, { -11, 83 }, { 9, 52 }, { 0, 67 },
- { -5, 90 }, { 1, 67 }, { -15, 72 }, { -5, 75 },
- { -8, 80 }, { -21, 83 }, { -21, 64 }, { -13, 31 },
- { -25, 64 }, { -29, 94 }, { 9, 75 }, { 17, 63 },
- { -8, 74 }, { -5, 35 }, { -2, 27 }, { 13, 91 },
- { -4, 86 }, { -12, 88 }, { -5, 82 }, { -3, 72 },
- { -4, 67 }, { -8, 72 }, { -16, 89 }, { -9, 69 },
- { -1, 59 }, { 5, 66 }, { 4, 57 }, { -4, 71 },
- { -2, 71 }, { 2, 58 }, { -1, 74 }, { -4, 44 },
- { -1, 69 }, { 0, 62 }, { -7, 51 }, { -4, 47 },
- { -6, 42 }, { -3, 41 }, { -6, 53 }, { 8, 76 },
- { -9, 78 }, { -11, 83 }, { 9, 52 }, { 0, 67 },
- { -5, 90 }, { 1, 67 }, { -15, 72 }, { -5, 75 },
- { -8, 80 }, { -21, 83 }, { -21, 64 }, { -13, 31 },
- { -25, 64 }, { -29, 94 }, { 9, 75 }, { 17, 63 },
- { -8, 74 }, { -5, 35 }, { -2, 27 }, { 13, 91 },
- { 4, 39 }, { 0, 42 }, { 7, 34 }, { 11, 29 },
- { 8, 31 }, { 6, 37 }, { 7, 42 }, { 3, 40 },
- { 8, 33 }, { 13, 43 }, { 13, 36 }, { 4, 47 },
- { 3, 55 }, { 2, 58 }, { 6, 60 }, { 8, 44 },
- { 11, 44 }, { 14, 42 }, { 7, 48 }, { 4, 56 },
- { 4, 52 }, { 13, 37 }, { 9, 49 }, { 19, 58 },
- { 10, 48 }, { 12, 45 }, { 0, 69 }, { 20, 33 },
- { 8, 63 }, { 35, -18 }, { 33, -25 }, { 28, -3 },
- { 24, 10 }, { 27, 0 }, { 34, -14 }, { 52, -44 },
- { 39, -24 }, { 19, 17 }, { 31, 25 }, { 36, 29 },
- { 24, 33 }, { 34, 15 }, { 30, 20 }, { 22, 73 },
- { 4, 39 }, { 0, 42 }, { 7, 34 }, { 11, 29 },
- { 8, 31 }, { 6, 37 }, { 7, 42 }, { 3, 40 },
- { 8, 33 }, { 13, 43 }, { 13, 36 }, { 4, 47 },
- { 3, 55 }, { 2, 58 }, { 6, 60 }, { 8, 44 },
- { 11, 44 }, { 14, 42 }, { 7, 48 }, { 4, 56 },
- { 4, 52 }, { 13, 37 }, { 9, 49 }, { 19, 58 },
- { 10, 48 }, { 12, 45 }, { 0, 69 }, { 20, 33 },
- { 8, 63 }, { 35, -18 }, { 33, -25 }, { 28, -3 },
- { 24, 10 }, { 27, 0 }, { 34, -14 }, { 52, -44 },
- { 39, -24 }, { 19, 17 }, { 31, 25 }, { 36, 29 },
- { 24, 33 }, { 34, 15 }, { 30, 20 }, { 22, 73 },
- { -3, 78 }, { -8, 74 }, { -9, 72 }, { -10, 72 },
- { -18, 75 }, { -12, 71 }, { -11, 63 }, { -5, 70 },
- { -17, 75 }, { -14, 72 }, { -16, 67 }, { -8, 53 },
- { -14, 59 }, { -9, 52 }, { -11, 68 }, { -3, 78 },
- { -8, 74 }, { -9, 72 }, { -10, 72 }, { -18, 75 },
- { -12, 71 }, { -11, 63 }, { -5, 70 }, { -17, 75 },
- { -14, 72 }, { -16, 67 }, { -8, 53 }, { -14, 59 },
- { -9, 52 }, { -11, 68 }, { 9, -2 }, { 30, -10 },
- { 31, -4 }, { 33, -1 }, { 33, 7 }, { 31, 12 },
- { 37, 23 }, { 31, 38 }, { 20, 64 }, { 9, -2 },
- { 30, -10 }, { 31, -4 }, { 33, -1 }, { 33, 7 },
- { 31, 12 }, { 37, 23 }, { 31, 38 }, { 20, 64 },
- { -9, 71 }, { -7, 37 }, { -8, 44 }, { -11, 49 },
- { -10, 56 }, { -12, 59 }, { -8, 63 }, { -9, 67 },
- { -6, 68 }, { -10, 79 }, { -3, 78 }, { -8, 74 },
- { -9, 72 }, { -10, 72 }, { -18, 75 }, { -12, 71 },
- { -11, 63 }, { -5, 70 }, { -17, 75 }, { -14, 72 },
- { -16, 67 }, { -8, 53 }, { -14, 59 }, { -9, 52 },
- { -11, 68 }, { -3, 78 }, { -8, 74 }, { -9, 72 },
- { -10, 72 }, { -18, 75 }, { -12, 71 }, { -11, 63 },
- { -5, 70 }, { -17, 75 }, { -14, 72 }, { -16, 67 },
- { -8, 53 }, { -14, 59 }, { -9, 52 }, { -11, 68 },
- { 9, -2 }, { 30, -10 }, { 31, -4 }, { 33, -1 },
- { 33, 7 }, { 31, 12 }, { 37, 23 }, { 31, 38 },
- { 20, 64 }, { 9, -2 }, { 30, -10 }, { 31, -4 },
- { 33, -1 }, { 33, 7 }, { 31, 12 }, { 37, 23 },
- { 31, 38 }, { 20, 64 }, { -9, 71 }, { -7, 37 },
- { -8, 44 }, { -11, 49 }, { -10, 56 }, { -12, 59 },
- { -8, 63 }, { -9, 67 }, { -6, 68 }, { -10, 79 },
- { -22, 127 }, { -25, 127 }, { -25, 120 }, { -27, 127 },
- { -19, 114 }, { -23, 117 }, { -25, 118 }, { -26, 117 },
- { -24, 113 }, { -28, 118 }, { -31, 120 }, { -37, 124 },
- { -10, 94 }, { -15, 102 }, { -10, 99 }, { -13, 106 },
- { -50, 127 }, { -5, 92 }, { 17, 57 }, { -5, 86 },
- { -13, 94 }, { -12, 91 }, { -2, 77 }, { 0, 71 },
- { -1, 73 }, { 4, 64 }, { -7, 81 }, { 5, 64 },
- { 15, 57 }, { 1, 67 }, { 0, 68 }, { -10, 67 },
- { 1, 68 }, { 0, 77 }, { 2, 64 }, { 0, 68 },
- { -5, 78 }, { 7, 55 }, { 5, 59 }, { 2, 65 },
- { 14, 54 }, { 15, 44 }, { 5, 60 }, { 2, 70 },
- { -22, 127 }, { -25, 127 }, { -25, 120 }, { -27, 127 },
- { -19, 114 }, { -23, 117 }, { -25, 118 }, { -26, 117 },
- { -24, 113 }, { -28, 118 }, { -31, 120 }, { -37, 124 },
- { -10, 94 }, { -15, 102 }, { -10, 99 }, { -13, 106 },
- { -50, 127 }, { -5, 92 }, { 17, 57 }, { -5, 86 },
- { -13, 94 }, { -12, 91 }, { -2, 77 }, { 0, 71 },
- { -1, 73 }, { 4, 64 }, { -7, 81 }, { 5, 64 },
- { 15, 57 }, { 1, 67 }, { 0, 68 }, { -10, 67 },
- { 1, 68 }, { 0, 77 }, { 2, 64 }, { 0, 68 },
- { -5, 78 }, { 7, 55 }, { 5, 59 }, { 2, 65 },
- { 14, 54 }, { 15, 44 }, { 5, 60 }, { 2, 70 },
- { 17, -13 }, { 16, -9 }, { 17, -12 }, { 27, -21 },
- { 37, -30 }, { 41, -40 }, { 42, -41 }, { 48, -47 },
- { 39, -32 }, { 46, -40 }, { 52, -51 }, { 46, -41 },
- { 52, -39 }, { 43, -19 }, { 32, 11 }, { 61, -55 },
- { 56, -46 }, { 62, -50 }, { 81, -67 }, { 45, -20 },
- { 35, -2 }, { 28, 15 }, { 34, 1 }, { 39, 1 },
- { 30, 17 }, { 20, 38 }, { 18, 45 }, { 15, 54 },
- { 0, 79 }, { 36, -16 }, { 37, -14 }, { 37, -17 },
- { 32, 1 }, { 34, 15 }, { 29, 15 }, { 24, 25 },
- { 34, 22 }, { 31, 16 }, { 35, 18 }, { 31, 28 },
- { 33, 41 }, { 36, 28 }, { 27, 47 }, { 21, 62 },
- { 17, -13 }, { 16, -9 }, { 17, -12 }, { 27, -21 },
- { 37, -30 }, { 41, -40 }, { 42, -41 }, { 48, -47 },
- { 39, -32 }, { 46, -40 }, { 52, -51 }, { 46, -41 },
- { 52, -39 }, { 43, -19 }, { 32, 11 }, { 61, -55 },
- { 56, -46 }, { 62, -50 }, { 81, -67 }, { 45, -20 },
- { 35, -2 }, { 28, 15 }, { 34, 1 }, { 39, 1 },
- { 30, 17 }, { 20, 38 }, { 18, 45 }, { 15, 54 },
- { 0, 79 }, { 36, -16 }, { 37, -14 }, { 37, -17 },
- { 32, 1 }, { 34, 15 }, { 29, 15 }, { 24, 25 },
- { 34, 22 }, { 31, 16 }, { 35, 18 }, { 31, 28 },
- { 33, 41 }, { 36, 28 }, { 27, 47 }, { 21, 62 },
- { -24, 115 }, { -22, 82 }, { -9, 62 }, { 0, 53 },
- { 0, 59 }, { -14, 85 }, { -13, 89 }, { -13, 94 },
- { -11, 92 }, { -29, 127 }, { -21, 100 }, { -14, 57 },
- { -12, 67 }, { -11, 71 }, { -10, 77 }, { -21, 85 },
- { -16, 88 }, { -23, 104 }, { -15, 98 }, { -37, 127 },
- { -10, 82 }, { -8, 48 }, { -8, 61 }, { -8, 66 },
- { -7, 70 }, { -14, 75 }, { -10, 79 }, { -9, 83 },
- { -12, 92 }, { -18, 108 }, { -24, 115 }, { -22, 82 },
- { -9, 62 }, { 0, 53 }, { 0, 59 }, { -14, 85 },
- { -13, 89 }, { -13, 94 }, { -11, 92 }, { -29, 127 },
- { -21, 100 }, { -14, 57 }, { -12, 67 }, { -11, 71 },
- { -10, 77 }, { -21, 85 }, { -16, 88 }, { -23, 104 },
- { -15, 98 }, { -37, 127 }, { -10, 82 }, { -8, 48 },
- { -8, 61 }, { -8, 66 }, { -7, 70 }, { -14, 75 },
- { -10, 79 }, { -9, 83 }, { -12, 92 }, { -18, 108 },
- { -5, 79 }, { -11, 104 }, { -11, 91 }, { -30, 127 },
- { -5, 79 }, { -11, 104 }, { -11, 91 }, { -30, 127 },
- { -5, 79 }, { -11, 104 }, { -11, 91 }, { -30, 127 }
- }
-};
-
-void ff_h264_init_cabac_states(H264Context *h) {
- MpegEncContext * const s = &h->s;
- int i;
- const int8_t (*tab)[2];
- const int slice_qp = av_clip(s->qscale - 6*(h->sps.bit_depth_luma-8), 0, 51);
-
- if( h->slice_type_nos == AV_PICTURE_TYPE_I ) tab = cabac_context_init_I;
- else tab = cabac_context_init_PB[h->cabac_init_idc];
-
- /* calculate pre-state */
- for( i= 0; i < 1024; i++ ) {
- int pre = 2*(((tab[i][0] * slice_qp) >>4 ) + tab[i][1]) - 127;
-
- pre^= pre>>31;
- if(pre > 124)
- pre= 124 + (pre&1);
-
- h->cabac_state[i] = pre;
- }
-}
-
-static int decode_cabac_field_decoding_flag(H264Context *h) {
- MpegEncContext * const s = &h->s;
- const long mbb_xy = h->mb_xy - 2L*s->mb_stride;
-
- unsigned long ctx = 0;
-
- ctx += h->mb_field_decoding_flag & !!s->mb_x; //for FMO:(s->current_picture.f.mb_type[mba_xy] >> 7) & (h->slice_table[mba_xy] == h->slice_num);
- ctx += (s->current_picture.f.mb_type[mbb_xy] >> 7) & (h->slice_table[mbb_xy] == h->slice_num);
-
- return get_cabac_noinline( &h->cabac, &(h->cabac_state+70)[ctx] );
-}
-
-static int decode_cabac_intra_mb_type(H264Context *h, int ctx_base, int intra_slice) {
- uint8_t *state= &h->cabac_state[ctx_base];
- int mb_type;
-
- if(intra_slice){
- int ctx=0;
- if( h->left_type[LTOP] & (MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM))
- ctx++;
- if( h->top_type & (MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM))
- ctx++;
- if( get_cabac_noinline( &h->cabac, &state[ctx] ) == 0 )
- return 0; /* I4x4 */
- state += 2;
- }else{
- if( get_cabac_noinline( &h->cabac, state ) == 0 )
- return 0; /* I4x4 */
- }
-
- if( get_cabac_terminate( &h->cabac ) )
- return 25; /* PCM */
-
- mb_type = 1; /* I16x16 */
- mb_type += 12 * get_cabac_noinline( &h->cabac, &state[1] ); /* cbp_luma != 0 */
- if( get_cabac_noinline( &h->cabac, &state[2] ) ) /* cbp_chroma */
- mb_type += 4 + 4 * get_cabac_noinline( &h->cabac, &state[2+intra_slice] );
- mb_type += 2 * get_cabac_noinline( &h->cabac, &state[3+intra_slice] );
- mb_type += 1 * get_cabac_noinline( &h->cabac, &state[3+2*intra_slice] );
- return mb_type;
-}
-
-static int decode_cabac_mb_skip( H264Context *h, int mb_x, int mb_y ) {
- MpegEncContext * const s = &h->s;
- int mba_xy, mbb_xy;
- int ctx = 0;
-
- if(FRAME_MBAFF){ //FIXME merge with the stuff in fill_caches?
- int mb_xy = mb_x + (mb_y&~1)*s->mb_stride;
- mba_xy = mb_xy - 1;
- if( (mb_y&1)
- && h->slice_table[mba_xy] == h->slice_num
- && MB_FIELD == !!IS_INTERLACED( s->current_picture.f.mb_type[mba_xy] ) )
- mba_xy += s->mb_stride;
- if( MB_FIELD ){
- mbb_xy = mb_xy - s->mb_stride;
- if( !(mb_y&1)
- && h->slice_table[mbb_xy] == h->slice_num
- && IS_INTERLACED( s->current_picture.f.mb_type[mbb_xy] ) )
- mbb_xy -= s->mb_stride;
- }else
- mbb_xy = mb_x + (mb_y-1)*s->mb_stride;
- }else{
- int mb_xy = h->mb_xy;
- mba_xy = mb_xy - 1;
- mbb_xy = mb_xy - (s->mb_stride << FIELD_PICTURE);
- }
-
- if( h->slice_table[mba_xy] == h->slice_num && !IS_SKIP( s->current_picture.f.mb_type[mba_xy] ))
- ctx++;
- if( h->slice_table[mbb_xy] == h->slice_num && !IS_SKIP( s->current_picture.f.mb_type[mbb_xy] ))
- ctx++;
-
- if( h->slice_type_nos == AV_PICTURE_TYPE_B )
- ctx += 13;
- return get_cabac_noinline( &h->cabac, &h->cabac_state[11+ctx] );
-}
-
-static int decode_cabac_mb_intra4x4_pred_mode( H264Context *h, int pred_mode ) {
- int mode = 0;
-
- if( get_cabac( &h->cabac, &h->cabac_state[68] ) )
- return pred_mode;
-
- mode += 1 * get_cabac( &h->cabac, &h->cabac_state[69] );
- mode += 2 * get_cabac( &h->cabac, &h->cabac_state[69] );
- mode += 4 * get_cabac( &h->cabac, &h->cabac_state[69] );
-
- return mode + ( mode >= pred_mode );
-}
-
-static int decode_cabac_mb_chroma_pre_mode( H264Context *h) {
- const int mba_xy = h->left_mb_xy[0];
- const int mbb_xy = h->top_mb_xy;
-
- int ctx = 0;
-
- /* No need to test for IS_INTRA4x4 and IS_INTRA16x16, as we set chroma_pred_mode_table to 0 */
- if( h->left_type[LTOP] && h->chroma_pred_mode_table[mba_xy] != 0 )
- ctx++;
-
- if( h->top_type && h->chroma_pred_mode_table[mbb_xy] != 0 )
- ctx++;
-
- if( get_cabac_noinline( &h->cabac, &h->cabac_state[64+ctx] ) == 0 )
- return 0;
-
- if( get_cabac_noinline( &h->cabac, &h->cabac_state[64+3] ) == 0 )
- return 1;
- if( get_cabac_noinline( &h->cabac, &h->cabac_state[64+3] ) == 0 )
- return 2;
- else
- return 3;
-}
-
-static int decode_cabac_mb_cbp_luma( H264Context *h) {
- int cbp_b, cbp_a, ctx, cbp = 0;
-
- cbp_a = h->left_cbp;
- cbp_b = h->top_cbp;
-
- ctx = !(cbp_a & 0x02) + 2 * !(cbp_b & 0x04);
- cbp += get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]);
- ctx = !(cbp & 0x01) + 2 * !(cbp_b & 0x08);
- cbp += get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]) << 1;
- ctx = !(cbp_a & 0x08) + 2 * !(cbp & 0x01);
- cbp += get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]) << 2;
- ctx = !(cbp & 0x04) + 2 * !(cbp & 0x02);
- cbp += get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]) << 3;
- return cbp;
-}
-static int decode_cabac_mb_cbp_chroma( H264Context *h) {
- int ctx;
- int cbp_a, cbp_b;
-
- cbp_a = (h->left_cbp>>4)&0x03;
- cbp_b = (h-> top_cbp>>4)&0x03;
-
- ctx = 0;
- if( cbp_a > 0 ) ctx++;
- if( cbp_b > 0 ) ctx += 2;
- if( get_cabac_noinline( &h->cabac, &h->cabac_state[77 + ctx] ) == 0 )
- return 0;
-
- ctx = 4;
- if( cbp_a == 2 ) ctx++;
- if( cbp_b == 2 ) ctx += 2;
- return 1 + get_cabac_noinline( &h->cabac, &h->cabac_state[77 + ctx] );
-}
-
-static int decode_cabac_p_mb_sub_type( H264Context *h ) {
- if( get_cabac( &h->cabac, &h->cabac_state[21] ) )
- return 0; /* 8x8 */
- if( !get_cabac( &h->cabac, &h->cabac_state[22] ) )
- return 1; /* 8x4 */
- if( get_cabac( &h->cabac, &h->cabac_state[23] ) )
- return 2; /* 4x8 */
- return 3; /* 4x4 */
-}
-static int decode_cabac_b_mb_sub_type( H264Context *h ) {
- int type;
- if( !get_cabac( &h->cabac, &h->cabac_state[36] ) )
- return 0; /* B_Direct_8x8 */
- if( !get_cabac( &h->cabac, &h->cabac_state[37] ) )
- return 1 + get_cabac( &h->cabac, &h->cabac_state[39] ); /* B_L0_8x8, B_L1_8x8 */
- type = 3;
- if( get_cabac( &h->cabac, &h->cabac_state[38] ) ) {
- if( get_cabac( &h->cabac, &h->cabac_state[39] ) )
- return 11 + get_cabac( &h->cabac, &h->cabac_state[39] ); /* B_L1_4x4, B_Bi_4x4 */
- type += 4;
- }
- type += 2*get_cabac( &h->cabac, &h->cabac_state[39] );
- type += get_cabac( &h->cabac, &h->cabac_state[39] );
- return type;
-}
-
-static int decode_cabac_mb_ref( H264Context *h, int list, int n ) {
- int refa = h->ref_cache[list][scan8[n] - 1];
- int refb = h->ref_cache[list][scan8[n] - 8];
- int ref = 0;
- int ctx = 0;
-
- if( h->slice_type_nos == AV_PICTURE_TYPE_B) {
- if( refa > 0 && !(h->direct_cache[scan8[n] - 1]&(MB_TYPE_DIRECT2>>1)) )
- ctx++;
- if( refb > 0 && !(h->direct_cache[scan8[n] - 8]&(MB_TYPE_DIRECT2>>1)) )
- ctx += 2;
- } else {
- if( refa > 0 )
- ctx++;
- if( refb > 0 )
- ctx += 2;
- }
-
- while( get_cabac( &h->cabac, &h->cabac_state[54+ctx] ) ) {
- ref++;
- ctx = (ctx>>2)+4;
- if(ref >= 32 /*h->ref_list[list]*/){
- return -1;
- }
- }
- return ref;
-}
-
-static int decode_cabac_mb_mvd( H264Context *h, int ctxbase, int amvd, int *mvda) {
- int mvd;
-
- if(!get_cabac(&h->cabac, &h->cabac_state[ctxbase+((amvd-3)>>(INT_BIT-1))+((amvd-33)>>(INT_BIT-1))+2])){
-// if(!get_cabac(&h->cabac, &h->cabac_state[ctxbase+(amvd>2)+(amvd>32)])){
- *mvda= 0;
- return 0;
- }
-
- mvd= 1;
- ctxbase+= 3;
- while( mvd < 9 && get_cabac( &h->cabac, &h->cabac_state[ctxbase] ) ) {
- if( mvd < 4 )
- ctxbase++;
- mvd++;
- }
-
- if( mvd >= 9 ) {
- int k = 3;
- while( get_cabac_bypass( &h->cabac ) ) {
- mvd += 1 << k;
- k++;
- if(k>24){
- av_log(h->s.avctx, AV_LOG_ERROR, "overflow in decode_cabac_mb_mvd\n");
- return INT_MIN;
- }
- }
- while( k-- ) {
- mvd += get_cabac_bypass( &h->cabac )<<k;
- }
- *mvda=mvd < 70 ? mvd : 70;
- }else
- *mvda=mvd;
- return get_cabac_bypass_sign( &h->cabac, -mvd );
-}
-
-#define DECODE_CABAC_MB_MVD( h, list, n )\
-{\
- int amvd0 = h->mvd_cache[list][scan8[n] - 1][0] +\
- h->mvd_cache[list][scan8[n] - 8][0];\
- int amvd1 = h->mvd_cache[list][scan8[n] - 1][1] +\
- h->mvd_cache[list][scan8[n] - 8][1];\
-\
- mx += decode_cabac_mb_mvd( h, 40, amvd0, &mpx );\
- my += decode_cabac_mb_mvd( h, 47, amvd1, &mpy );\
-}
-
-static av_always_inline int get_cabac_cbf_ctx( H264Context *h, int cat, int idx, int max_coeff, int is_dc ) {
- int nza, nzb;
- int ctx = 0;
- static const uint16_t base_ctx[14] = {85,89,93,97,101,1012,460,464,468,1016,472,476,480,1020};
-
- if( is_dc ) {
- if( cat == 3 ) {
- idx -= CHROMA_DC_BLOCK_INDEX;
- nza = (h->left_cbp>>(6+idx))&0x01;
- nzb = (h-> top_cbp>>(6+idx))&0x01;
- } else {
- idx -= LUMA_DC_BLOCK_INDEX;
- nza = h->left_cbp&(0x100<<idx);
- nzb = h-> top_cbp&(0x100<<idx);
- }
- } else {
- nza = h->non_zero_count_cache[scan8[idx] - 1];
- nzb = h->non_zero_count_cache[scan8[idx] - 8];
- }
-
- if( nza > 0 )
- ctx++;
-
- if( nzb > 0 )
- ctx += 2;
-
- return base_ctx[cat] + ctx;
-}
-
-static av_always_inline void
-decode_cabac_residual_internal(H264Context *h, int16_t *block,
- int cat, int n, const uint8_t *scantable,
- const uint32_t *qmul, int max_coeff,
- int is_dc, int chroma422)
-{
- static const int significant_coeff_flag_offset[2][14] = {
- { 105+0, 105+15, 105+29, 105+44, 105+47, 402, 484+0, 484+15, 484+29, 660, 528+0, 528+15, 528+29, 718 },
- { 277+0, 277+15, 277+29, 277+44, 277+47, 436, 776+0, 776+15, 776+29, 675, 820+0, 820+15, 820+29, 733 }
- };
- static const int last_coeff_flag_offset[2][14] = {
- { 166+0, 166+15, 166+29, 166+44, 166+47, 417, 572+0, 572+15, 572+29, 690, 616+0, 616+15, 616+29, 748 },
- { 338+0, 338+15, 338+29, 338+44, 338+47, 451, 864+0, 864+15, 864+29, 699, 908+0, 908+15, 908+29, 757 }
- };
- static const int coeff_abs_level_m1_offset[14] = {
- 227+0, 227+10, 227+20, 227+30, 227+39, 426, 952+0, 952+10, 952+20, 708, 982+0, 982+10, 982+20, 766
- };
- static const uint8_t significant_coeff_flag_offset_8x8[2][63] = {
- { 0, 1, 2, 3, 4, 5, 5, 4, 4, 3, 3, 4, 4, 4, 5, 5,
- 4, 4, 4, 4, 3, 3, 6, 7, 7, 7, 8, 9,10, 9, 8, 7,
- 7, 6,11,12,13,11, 6, 7, 8, 9,14,10, 9, 8, 6,11,
- 12,13,11, 6, 9,14,10, 9,11,12,13,11,14,10,12 },
- { 0, 1, 1, 2, 2, 3, 3, 4, 5, 6, 7, 7, 7, 8, 4, 5,
- 6, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,11,12,11,
- 9, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,13,13, 9,
- 9,10,10, 8,13,13, 9, 9,10,10,14,14,14,14,14 }
- };
- static const uint8_t sig_coeff_offset_dc[7] = { 0, 0, 1, 1, 2, 2, 2 };
- /* node ctx: 0..3: abslevel1 (with abslevelgt1 == 0).
- * 4..7: abslevelgt1 + 3 (and abslevel1 doesn't matter).
- * map node ctx => cabac ctx for level=1 */
- static const uint8_t coeff_abs_level1_ctx[8] = { 1, 2, 3, 4, 0, 0, 0, 0 };
- /* map node ctx => cabac ctx for level>1 */
- static const uint8_t coeff_abs_levelgt1_ctx[2][8] = {
- { 5, 5, 5, 5, 6, 7, 8, 9 },
- { 5, 5, 5, 5, 6, 7, 8, 8 }, // 422/dc case
- };
- static const uint8_t coeff_abs_level_transition[2][8] = {
- /* update node ctx after decoding a level=1 */
- { 1, 2, 3, 3, 4, 5, 6, 7 },
- /* update node ctx after decoding a level>1 */
- { 4, 4, 4, 4, 5, 6, 7, 7 }
- };
-
- int index[64];
-
- int av_unused last;
- int coeff_count = 0;
- int node_ctx = 0;
-
- uint8_t *significant_coeff_ctx_base;
- uint8_t *last_coeff_ctx_base;
- uint8_t *abs_level_m1_ctx_base;
-
-#if !ARCH_X86
-#define CABAC_ON_STACK
-#endif
-#ifdef CABAC_ON_STACK
-#define CC &cc
- CABACContext cc;
- cc.range = h->cabac.range;
- cc.low = h->cabac.low;
- cc.bytestream= h->cabac.bytestream;
-#else
-#define CC &h->cabac
-#endif
-
- significant_coeff_ctx_base = h->cabac_state
- + significant_coeff_flag_offset[MB_FIELD][cat];
- last_coeff_ctx_base = h->cabac_state
- + last_coeff_flag_offset[MB_FIELD][cat];
- abs_level_m1_ctx_base = h->cabac_state
- + coeff_abs_level_m1_offset[cat];
-
- if( !is_dc && max_coeff == 64 ) {
-#define DECODE_SIGNIFICANCE( coefs, sig_off, last_off ) \
- for(last= 0; last < coefs; last++) { \
- uint8_t *sig_ctx = significant_coeff_ctx_base + sig_off; \
- if( get_cabac( CC, sig_ctx )) { \
- uint8_t *last_ctx = last_coeff_ctx_base + last_off; \
- index[coeff_count++] = last; \
- if( get_cabac( CC, last_ctx ) ) { \
- last= max_coeff; \
- break; \
- } \
- } \
- }\
- if( last == max_coeff -1 ) {\
- index[coeff_count++] = last;\
- }
- const uint8_t *sig_off = significant_coeff_flag_offset_8x8[MB_FIELD];
-#ifdef decode_significance
- coeff_count = decode_significance_8x8(CC, significant_coeff_ctx_base, index,
- last_coeff_ctx_base, sig_off);
- } else {
- if (is_dc && chroma422) { // dc 422
- DECODE_SIGNIFICANCE(7, sig_coeff_offset_dc[last], sig_coeff_offset_dc[last]);
- } else {
- coeff_count = decode_significance(CC, max_coeff, significant_coeff_ctx_base, index,
- last_coeff_ctx_base-significant_coeff_ctx_base);
- }
-#else
- DECODE_SIGNIFICANCE( 63, sig_off[last], ff_h264_last_coeff_flag_offset_8x8[last] );
- } else {
- if (is_dc && chroma422) { // dc 422
- DECODE_SIGNIFICANCE(7, sig_coeff_offset_dc[last], sig_coeff_offset_dc[last]);
- } else {
- DECODE_SIGNIFICANCE(max_coeff - 1, last, last);
- }
-#endif
- }
- av_assert2(coeff_count > 0);
-
- if( is_dc ) {
- if( cat == 3 )
- h->cbp_table[h->mb_xy] |= 0x40 << (n - CHROMA_DC_BLOCK_INDEX);
- else
- h->cbp_table[h->mb_xy] |= 0x100 << (n - LUMA_DC_BLOCK_INDEX);
- h->non_zero_count_cache[scan8[n]] = coeff_count;
- } else {
- if( max_coeff == 64 )
- fill_rectangle(&h->non_zero_count_cache[scan8[n]], 2, 2, 8, coeff_count, 1);
- else {
- av_assert2( cat == 1 || cat == 2 || cat == 4 || cat == 7 || cat == 8 || cat == 11 || cat == 12 );
- h->non_zero_count_cache[scan8[n]] = coeff_count;
- }
- }
-
-
-#define STORE_BLOCK(type) \
- do { \
- uint8_t *ctx = coeff_abs_level1_ctx[node_ctx] + abs_level_m1_ctx_base; \
- \
- int j= scantable[index[--coeff_count]]; \
- \
- if( get_cabac( CC, ctx ) == 0 ) { \
- node_ctx = coeff_abs_level_transition[0][node_ctx]; \
- if( is_dc ) { \
- ((type*)block)[j] = get_cabac_bypass_sign( CC, -1); \
- }else{ \
- ((type*)block)[j] = (get_cabac_bypass_sign( CC, -qmul[j]) + 32) >> 6; \
- } \
- } else { \
- int coeff_abs = 2; \
- ctx = coeff_abs_levelgt1_ctx[is_dc && chroma422][node_ctx] + abs_level_m1_ctx_base; \
- node_ctx = coeff_abs_level_transition[1][node_ctx]; \
-\
- while( coeff_abs < 15 && get_cabac( CC, ctx ) ) { \
- coeff_abs++; \
- } \
-\
- if( coeff_abs >= 15 ) { \
- int j = 0; \
- while(get_cabac_bypass( CC ) && j<30) { \
- j++; \
- } \
-\
- coeff_abs=1; \
- while( j-- ) { \
- coeff_abs += coeff_abs + get_cabac_bypass( CC ); \
- } \
- coeff_abs+= 14; \
- } \
-\
- if( is_dc ) { \
- ((type*)block)[j] = get_cabac_bypass_sign( CC, -coeff_abs ); \
- }else{ \
- ((type*)block)[j] = ((int)(get_cabac_bypass_sign( CC, -coeff_abs ) * qmul[j] + 32)) >> 6; \
- } \
- } \
- } while ( coeff_count );
-
- if (h->pixel_shift) {
- STORE_BLOCK(int32_t)
- } else {
- STORE_BLOCK(int16_t)
- }
-#ifdef CABAC_ON_STACK
- h->cabac.range = cc.range ;
- h->cabac.low = cc.low ;
- h->cabac.bytestream= cc.bytestream;
-#endif
-
-}
-
-static void decode_cabac_residual_dc_internal(H264Context *h, int16_t *block,
- int cat, int n,
- const uint8_t *scantable,
- int max_coeff)
-{
- decode_cabac_residual_internal(h, block, cat, n, scantable, NULL, max_coeff, 1, 0);
-}
-
-static void decode_cabac_residual_dc_internal_422(H264Context *h, int16_t *block,
- int cat, int n, const uint8_t *scantable,
- int max_coeff)
-{
- decode_cabac_residual_internal(h, block, cat, n, scantable, NULL, max_coeff, 1, 1);
-}
-
-static void decode_cabac_residual_nondc_internal(H264Context *h, int16_t *block,
- int cat, int n,
- const uint8_t *scantable,
- const uint32_t *qmul,
- int max_coeff)
-{
- decode_cabac_residual_internal(h, block, cat, n, scantable, qmul, max_coeff, 0, 0);
-}
-
-/* cat: 0-> DC 16x16 n = 0
- * 1-> AC 16x16 n = luma4x4idx
- * 2-> Luma4x4 n = luma4x4idx
- * 3-> DC Chroma n = iCbCr
- * 4-> AC Chroma n = 16 + 4 * iCbCr + chroma4x4idx
- * 5-> Luma8x8 n = 4 * luma8x8idx */
-
-/* Partially inline the CABAC residual decode: inline the coded block flag.
- * This has very little impact on binary size and improves performance
- * because it allows improved constant propagation into get_cabac_cbf_ctx,
- * as well as because most blocks have zero CBFs. */
-
-static av_always_inline void decode_cabac_residual_dc(H264Context *h,
- int16_t *block,
- int cat, int n,
- const uint8_t *scantable,
- int max_coeff)
-{
- /* read coded block flag */
- if( get_cabac( &h->cabac, &h->cabac_state[get_cabac_cbf_ctx( h, cat, n, max_coeff, 1 ) ] ) == 0 ) {
- h->non_zero_count_cache[scan8[n]] = 0;
- return;
- }
- decode_cabac_residual_dc_internal( h, block, cat, n, scantable, max_coeff );
-}
-
-static av_always_inline void
-decode_cabac_residual_dc_422(H264Context *h, int16_t *block,
- int cat, int n, const uint8_t *scantable,
- int max_coeff)
-{
- /* read coded block flag */
- if (get_cabac(&h->cabac, &h->cabac_state[get_cabac_cbf_ctx(h, cat, n, max_coeff, 1)]) == 0) {
- h->non_zero_count_cache[scan8[n]] = 0;
- return;
- }
- decode_cabac_residual_dc_internal_422(h, block, cat, n, scantable, max_coeff);
-}
-
-static av_always_inline void decode_cabac_residual_nondc(H264Context *h,
- int16_t *block,
- int cat, int n,
- const uint8_t *scantable,
- const uint32_t *qmul,
- int max_coeff)
-{
- /* read coded block flag */
- if( (cat != 5 || CHROMA444) && get_cabac( &h->cabac, &h->cabac_state[get_cabac_cbf_ctx( h, cat, n, max_coeff, 0 ) ] ) == 0 ) {
- if( max_coeff == 64 ) {
- fill_rectangle(&h->non_zero_count_cache[scan8[n]], 2, 2, 8, 0, 1);
- } else {
- h->non_zero_count_cache[scan8[n]] = 0;
- }
- return;
- }
- decode_cabac_residual_nondc_internal( h, block, cat, n, scantable, qmul, max_coeff );
-}
-
-static av_always_inline void decode_cabac_luma_residual( H264Context *h, const uint8_t *scan, const uint8_t *scan8x8, int pixel_shift, int mb_type, int cbp, int p )
-{
- static const uint8_t ctx_cat[4][3] = {{0,6,10},{1,7,11},{2,8,12},{5,9,13}};
- const uint32_t *qmul;
- int i8x8, i4x4;
- MpegEncContext * const s = &h->s;
- int qscale = p == 0 ? s->qscale : h->chroma_qp[p-1];
- if( IS_INTRA16x16( mb_type ) ) {
- AV_ZERO128(h->mb_luma_dc[p]+0);
- AV_ZERO128(h->mb_luma_dc[p]+8);
- AV_ZERO128(h->mb_luma_dc[p]+16);
- AV_ZERO128(h->mb_luma_dc[p]+24);
- decode_cabac_residual_dc(h, h->mb_luma_dc[p], ctx_cat[0][p], LUMA_DC_BLOCK_INDEX+p, scan, 16);
-
- if( cbp&15 ) {
- qmul = h->dequant4_coeff[p][qscale];
- for( i4x4 = 0; i4x4 < 16; i4x4++ ) {
- const int index = 16*p + i4x4;
- decode_cabac_residual_nondc(h, h->mb + (16*index << pixel_shift), ctx_cat[1][p], index, scan + 1, qmul, 15);
- }
- } else {
- fill_rectangle(&h->non_zero_count_cache[scan8[16*p]], 4, 4, 8, 0, 1);
- }
- } else {
- int cqm = (IS_INTRA( mb_type ) ? 0:3) + p;
- for( i8x8 = 0; i8x8 < 4; i8x8++ ) {
- if( cbp & (1<<i8x8) ) {
- if( IS_8x8DCT(mb_type) ) {
- const int index = 16*p + 4*i8x8;
- decode_cabac_residual_nondc(h, h->mb + (16*index << pixel_shift), ctx_cat[3][p], index,
- scan8x8, h->dequant8_coeff[cqm][qscale], 64);
- } else {
- qmul = h->dequant4_coeff[cqm][qscale];
- for( i4x4 = 0; i4x4 < 4; i4x4++ ) {
- const int index = 16*p + 4*i8x8 + i4x4;
-//START_TIMER
- decode_cabac_residual_nondc(h, h->mb + (16*index << pixel_shift), ctx_cat[2][p], index, scan, qmul, 16);
-//STOP_TIMER("decode_residual")
- }
- }
- } else {
- fill_rectangle(&h->non_zero_count_cache[scan8[4*i8x8+16*p]], 2, 2, 8, 0, 1);
- }
- }
- }
-}
-
-/**
- * Decode a macroblock.
- * @return 0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR if an error is noticed
- */
-int ff_h264_decode_mb_cabac(H264Context *h) {
- MpegEncContext * const s = &h->s;
- int mb_xy;
- int mb_type, partition_count, cbp = 0;
- int dct8x8_allowed= h->pps.transform_8x8_mode;
- int decode_chroma = h->sps.chroma_format_idc == 1 || h->sps.chroma_format_idc == 2;
- const int pixel_shift = h->pixel_shift;
- unsigned local_ref_count[2];
-
- mb_xy = h->mb_xy = s->mb_x + s->mb_y*s->mb_stride;
-
- tprintf(s->avctx, "pic:%d mb:%d/%d\n", h->frame_num, s->mb_x, s->mb_y);
- if( h->slice_type_nos != AV_PICTURE_TYPE_I ) {
- int skip;
- /* a skipped mb needs the aff flag from the following mb */
- if( FRAME_MBAFF && (s->mb_y&1)==1 && h->prev_mb_skipped )
- skip = h->next_mb_skipped;
- else
- skip = decode_cabac_mb_skip( h, s->mb_x, s->mb_y );
- /* read skip flags */
- if( skip ) {
- if( FRAME_MBAFF && (s->mb_y&1)==0 ){
- s->current_picture.f.mb_type[mb_xy] = MB_TYPE_SKIP;
- h->next_mb_skipped = decode_cabac_mb_skip( h, s->mb_x, s->mb_y+1 );
- if(!h->next_mb_skipped)
- h->mb_mbaff = h->mb_field_decoding_flag = decode_cabac_field_decoding_flag(h);
- }
-
- decode_mb_skip(h);
-
- h->cbp_table[mb_xy] = 0;
- h->chroma_pred_mode_table[mb_xy] = 0;
- h->last_qscale_diff = 0;
-
- return 0;
-
- }
- }
- if(FRAME_MBAFF){
- if( (s->mb_y&1) == 0 )
- h->mb_mbaff =
- h->mb_field_decoding_flag = decode_cabac_field_decoding_flag(h);
- }
-
- h->prev_mb_skipped = 0;
-
- fill_decode_neighbors(h, -(MB_FIELD));
-
- if( h->slice_type_nos == AV_PICTURE_TYPE_B ) {
- int ctx = 0;
- av_assert2(h->slice_type_nos == AV_PICTURE_TYPE_B);
-
- if( !IS_DIRECT( h->left_type[LTOP]-1 ) )
- ctx++;
- if( !IS_DIRECT( h->top_type-1 ) )
- ctx++;
-
- if( !get_cabac_noinline( &h->cabac, &h->cabac_state[27+ctx] ) ){
- mb_type= 0; /* B_Direct_16x16 */
- }else if( !get_cabac_noinline( &h->cabac, &h->cabac_state[27+3] ) ) {
- mb_type= 1 + get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ); /* B_L[01]_16x16 */
- }else{
- int bits;
- bits = get_cabac_noinline( &h->cabac, &h->cabac_state[27+4] ) << 3;
- bits+= get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ) << 2;
- bits+= get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ) << 1;
- bits+= get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] );
- if( bits < 8 ){
- mb_type= bits + 3; /* B_Bi_16x16 through B_L1_L0_16x8 */
- }else if( bits == 13 ){
- mb_type= decode_cabac_intra_mb_type(h, 32, 0);
- goto decode_intra_mb;
- }else if( bits == 14 ){
- mb_type= 11; /* B_L1_L0_8x16 */
- }else if( bits == 15 ){
- mb_type= 22; /* B_8x8 */
- }else{
- bits= ( bits<<1 ) + get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] );
- mb_type= bits - 4; /* B_L0_Bi_* through B_Bi_Bi_* */
- }
- }
- partition_count= b_mb_type_info[mb_type].partition_count;
- mb_type= b_mb_type_info[mb_type].type;
- } else if( h->slice_type_nos == AV_PICTURE_TYPE_P ) {
- if( get_cabac_noinline( &h->cabac, &h->cabac_state[14] ) == 0 ) {
- /* P-type */
- if( get_cabac_noinline( &h->cabac, &h->cabac_state[15] ) == 0 ) {
- /* P_L0_D16x16, P_8x8 */
- mb_type= 3 * get_cabac_noinline( &h->cabac, &h->cabac_state[16] );
- } else {
- /* P_L0_D8x16, P_L0_D16x8 */
- mb_type= 2 - get_cabac_noinline( &h->cabac, &h->cabac_state[17] );
- }
- partition_count= p_mb_type_info[mb_type].partition_count;
- mb_type= p_mb_type_info[mb_type].type;
- } else {
- mb_type= decode_cabac_intra_mb_type(h, 17, 0);
- goto decode_intra_mb;
- }
- } else {
- mb_type= decode_cabac_intra_mb_type(h, 3, 1);
- if(h->slice_type == AV_PICTURE_TYPE_SI && mb_type)
- mb_type--;
- av_assert2(h->slice_type_nos == AV_PICTURE_TYPE_I);
-decode_intra_mb:
- partition_count = 0;
- cbp= i_mb_type_info[mb_type].cbp;
- h->intra16x16_pred_mode= i_mb_type_info[mb_type].pred_mode;
- mb_type= i_mb_type_info[mb_type].type;
- }
- if(MB_FIELD)
- mb_type |= MB_TYPE_INTERLACED;
-
- h->slice_table[ mb_xy ]= h->slice_num;
-
- if(IS_INTRA_PCM(mb_type)) {
- const int mb_size = ff_h264_mb_sizes[h->sps.chroma_format_idc] *
- h->sps.bit_depth_luma >> 3;
- const uint8_t *ptr;
-
- // We assume these blocks are very rare so we do not optimize it.
- // FIXME The two following lines get the bitstream position in the cabac
- // decode, I think it should be done by a function in cabac.h (or cabac.c).
- ptr= h->cabac.bytestream;
- if(h->cabac.low&0x1) ptr--;
- if(CABAC_BITS==16){
- if(h->cabac.low&0x1FF) ptr--;
- }
-
- // The pixels are stored in the same order as levels in h->mb array.
- if ((int) (h->cabac.bytestream_end - ptr) < mb_size)
- return -1;
- memcpy(h->mb, ptr, mb_size); ptr+=mb_size;
-
- ff_init_cabac_decoder(&h->cabac, ptr, h->cabac.bytestream_end - ptr);
-
- // All blocks are present
- h->cbp_table[mb_xy] = 0xf7ef;
- h->chroma_pred_mode_table[mb_xy] = 0;
- // In deblocking, the quantizer is 0
- s->current_picture.f.qscale_table[mb_xy] = 0;
- // All coeffs are present
- memset(h->non_zero_count[mb_xy], 16, 48);
- s->current_picture.f.mb_type[mb_xy] = mb_type;
- h->last_qscale_diff = 0;
- return 0;
- }
-
- local_ref_count[0] = h->ref_count[0] << MB_MBAFF;
- local_ref_count[1] = h->ref_count[1] << MB_MBAFF;
-
- fill_decode_caches(h, mb_type);
-
- if( IS_INTRA( mb_type ) ) {
- int i, pred_mode;
- if( IS_INTRA4x4( mb_type ) ) {
- if( dct8x8_allowed && get_cabac_noinline( &h->cabac, &h->cabac_state[399 + h->neighbor_transform_size] ) ) {
- mb_type |= MB_TYPE_8x8DCT;
- for( i = 0; i < 16; i+=4 ) {
- int pred = pred_intra_mode( h, i );
- int mode = decode_cabac_mb_intra4x4_pred_mode( h, pred );
- fill_rectangle( &h->intra4x4_pred_mode_cache[ scan8[i] ], 2, 2, 8, mode, 1 );
- }
- } else {
- for( i = 0; i < 16; i++ ) {
- int pred = pred_intra_mode( h, i );
- h->intra4x4_pred_mode_cache[ scan8[i] ] = decode_cabac_mb_intra4x4_pred_mode( h, pred );
-
- av_dlog(s->avctx, "i4x4 pred=%d mode=%d\n", pred,
- h->intra4x4_pred_mode_cache[scan8[i]]);
- }
- }
- write_back_intra_pred_mode(h);
- if( ff_h264_check_intra4x4_pred_mode(h) < 0 ) return -1;
- } else {
- h->intra16x16_pred_mode= ff_h264_check_intra_pred_mode( h, h->intra16x16_pred_mode, 0 );
- if( h->intra16x16_pred_mode < 0 ) return -1;
- }
- if(decode_chroma){
- h->chroma_pred_mode_table[mb_xy] =
- pred_mode = decode_cabac_mb_chroma_pre_mode( h );
-
- pred_mode= ff_h264_check_intra_pred_mode( h, pred_mode, 1 );
- if( pred_mode < 0 ) return -1;
- h->chroma_pred_mode= pred_mode;
- } else {
- h->chroma_pred_mode= DC_128_PRED8x8;
- }
- } else if( partition_count == 4 ) {
- int i, j, sub_partition_count[4], list, ref[2][4];
-
- if( h->slice_type_nos == AV_PICTURE_TYPE_B ) {
- for( i = 0; i < 4; i++ ) {
- h->sub_mb_type[i] = decode_cabac_b_mb_sub_type( h );
- sub_partition_count[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
- h->sub_mb_type[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].type;
- }
- if( IS_DIRECT(h->sub_mb_type[0] | h->sub_mb_type[1] |
- h->sub_mb_type[2] | h->sub_mb_type[3]) ) {
- ff_h264_pred_direct_motion(h, &mb_type);
- h->ref_cache[0][scan8[4]] =
- h->ref_cache[1][scan8[4]] =
- h->ref_cache[0][scan8[12]] =
- h->ref_cache[1][scan8[12]] = PART_NOT_AVAILABLE;
- for( i = 0; i < 4; i++ )
- fill_rectangle( &h->direct_cache[scan8[4*i]], 2, 2, 8, (h->sub_mb_type[i]>>1)&0xFF, 1 );
- }
- } else {
- for( i = 0; i < 4; i++ ) {
- h->sub_mb_type[i] = decode_cabac_p_mb_sub_type( h );
- sub_partition_count[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
- h->sub_mb_type[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].type;
- }
- }
-
- for( list = 0; list < h->list_count; list++ ) {
- for( i = 0; i < 4; i++ ) {
- if(IS_DIRECT(h->sub_mb_type[i])) continue;
- if(IS_DIR(h->sub_mb_type[i], 0, list)){
- if (local_ref_count[list] > 1) {
- ref[list][i] = decode_cabac_mb_ref( h, list, 4*i );
- if (ref[list][i] >= (unsigned)local_ref_count[list]) {
- av_log(s->avctx, AV_LOG_ERROR, "Reference %d >= %d\n", ref[list][i], local_ref_count[list]);
- return -1;
- }
- }else
- ref[list][i] = 0;
- } else {
- ref[list][i] = -1;
- }
- h->ref_cache[list][ scan8[4*i]+1 ]=
- h->ref_cache[list][ scan8[4*i]+8 ]=h->ref_cache[list][ scan8[4*i]+9 ]= ref[list][i];
- }
- }
-
- if(dct8x8_allowed)
- dct8x8_allowed = get_dct8x8_allowed(h);
-
- for(list=0; list<h->list_count; list++){
- for(i=0; i<4; i++){
- h->ref_cache[list][ scan8[4*i] ]=h->ref_cache[list][ scan8[4*i]+1 ];
- if(IS_DIRECT(h->sub_mb_type[i])){
- fill_rectangle(h->mvd_cache[list][scan8[4*i]], 2, 2, 8, 0, 2);
- continue;
- }
-
- if(IS_DIR(h->sub_mb_type[i], 0, list) && !IS_DIRECT(h->sub_mb_type[i])){
- const int sub_mb_type= h->sub_mb_type[i];
- const int block_width= (sub_mb_type & (MB_TYPE_16x16|MB_TYPE_16x8)) ? 2 : 1;
- for(j=0; j<sub_partition_count[i]; j++){
- int mpx, mpy;
- int mx, my;
- const int index= 4*i + block_width*j;
- int16_t (* mv_cache)[2]= &h->mv_cache[list][ scan8[index] ];
- uint8_t (* mvd_cache)[2]= &h->mvd_cache[list][ scan8[index] ];
- pred_motion(h, index, block_width, list, h->ref_cache[list][ scan8[index] ], &mx, &my);
- DECODE_CABAC_MB_MVD( h, list, index)
- tprintf(s->avctx, "final mv:%d %d\n", mx, my);
-
- if(IS_SUB_8X8(sub_mb_type)){
- mv_cache[ 1 ][0]=
- mv_cache[ 8 ][0]= mv_cache[ 9 ][0]= mx;
- mv_cache[ 1 ][1]=
- mv_cache[ 8 ][1]= mv_cache[ 9 ][1]= my;
-
- mvd_cache[ 1 ][0]=
- mvd_cache[ 8 ][0]= mvd_cache[ 9 ][0]= mpx;
- mvd_cache[ 1 ][1]=
- mvd_cache[ 8 ][1]= mvd_cache[ 9 ][1]= mpy;
- }else if(IS_SUB_8X4(sub_mb_type)){
- mv_cache[ 1 ][0]= mx;
- mv_cache[ 1 ][1]= my;
-
- mvd_cache[ 1 ][0]= mpx;
- mvd_cache[ 1 ][1]= mpy;
- }else if(IS_SUB_4X8(sub_mb_type)){
- mv_cache[ 8 ][0]= mx;
- mv_cache[ 8 ][1]= my;
-
- mvd_cache[ 8 ][0]= mpx;
- mvd_cache[ 8 ][1]= mpy;
- }
- mv_cache[ 0 ][0]= mx;
- mv_cache[ 0 ][1]= my;
-
- mvd_cache[ 0 ][0]= mpx;
- mvd_cache[ 0 ][1]= mpy;
- }
- }else{
- fill_rectangle(h->mv_cache [list][ scan8[4*i] ], 2, 2, 8, 0, 4);
- fill_rectangle(h->mvd_cache[list][ scan8[4*i] ], 2, 2, 8, 0, 2);
- }
- }
- }
- } else if( IS_DIRECT(mb_type) ) {
- ff_h264_pred_direct_motion(h, &mb_type);
- fill_rectangle(h->mvd_cache[0][scan8[0]], 4, 4, 8, 0, 2);
- fill_rectangle(h->mvd_cache[1][scan8[0]], 4, 4, 8, 0, 2);
- dct8x8_allowed &= h->sps.direct_8x8_inference_flag;
- } else {
- int list, i;
- if(IS_16X16(mb_type)){
- for(list=0; list<h->list_count; list++){
- if(IS_DIR(mb_type, 0, list)){
- int ref;
- if (local_ref_count[list] > 1) {
- ref= decode_cabac_mb_ref(h, list, 0);
- if (ref >= (unsigned)local_ref_count[list]) {
- av_log(s->avctx, AV_LOG_ERROR, "Reference %d >= %d\n", ref, local_ref_count[list]);
- return -1;
- }
- }else
- ref=0;
- fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, ref, 1);
- }
- }
- for(list=0; list<h->list_count; list++){
- if(IS_DIR(mb_type, 0, list)){
- int mx,my,mpx,mpy;
- pred_motion(h, 0, 4, list, h->ref_cache[list][ scan8[0] ], &mx, &my);
- DECODE_CABAC_MB_MVD( h, list, 0)
- tprintf(s->avctx, "final mv:%d %d\n", mx, my);
-
- fill_rectangle(h->mvd_cache[list][ scan8[0] ], 4, 4, 8, pack8to16(mpx,mpy), 2);
- fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx,my), 4);
- }
- }
- }
- else if(IS_16X8(mb_type)){
- for(list=0; list<h->list_count; list++){
- for(i=0; i<2; i++){
- if(IS_DIR(mb_type, i, list)){
- int ref;
- if (local_ref_count[list] > 1) {
- ref= decode_cabac_mb_ref( h, list, 8*i );
- if (ref >= (unsigned)local_ref_count[list]) {
- av_log(s->avctx, AV_LOG_ERROR, "Reference %d >= %d\n", ref, local_ref_count[list]);
- return -1;
- }
- }else
- ref=0;
- fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, ref, 1);
- }else
- fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, (LIST_NOT_USED&0xFF), 1);
- }
- }
- for(list=0; list<h->list_count; list++){
- for(i=0; i<2; i++){
- if(IS_DIR(mb_type, i, list)){
- int mx,my,mpx,mpy;
- pred_16x8_motion(h, 8*i, list, h->ref_cache[list][scan8[0] + 16*i], &mx, &my);
- DECODE_CABAC_MB_MVD( h, list, 8*i)
- tprintf(s->avctx, "final mv:%d %d\n", mx, my);
-
- fill_rectangle(h->mvd_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack8to16(mpx,mpy), 2);
- fill_rectangle(h->mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack16to32(mx,my), 4);
- }else{
- fill_rectangle(h->mvd_cache[list][ scan8[0] + 16*i ], 4, 2, 8, 0, 2);
- fill_rectangle(h-> mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, 0, 4);
- }
- }
- }
- }else{
- av_assert2(IS_8X16(mb_type));
- for(list=0; list<h->list_count; list++){
- for(i=0; i<2; i++){
- if(IS_DIR(mb_type, i, list)){ //FIXME optimize
- int ref;
- if (local_ref_count[list] > 1) {
- ref= decode_cabac_mb_ref( h, list, 4*i );
- if (ref >= (unsigned)local_ref_count[list]) {
- av_log(s->avctx, AV_LOG_ERROR, "Reference %d >= %d\n", ref, local_ref_count[list]);
- return -1;
- }
- }else
- ref=0;
- fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, ref, 1);
- }else
- fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, (LIST_NOT_USED&0xFF), 1);
- }
- }
- for(list=0; list<h->list_count; list++){
- for(i=0; i<2; i++){
- if(IS_DIR(mb_type, i, list)){
- int mx,my,mpx,mpy;
- pred_8x16_motion(h, i*4, list, h->ref_cache[list][ scan8[0] + 2*i ], &mx, &my);
- DECODE_CABAC_MB_MVD( h, list, 4*i)
-
- tprintf(s->avctx, "final mv:%d %d\n", mx, my);
- fill_rectangle(h->mvd_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack8to16(mpx,mpy), 2);
- fill_rectangle(h->mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack16to32(mx,my), 4);
- }else{
- fill_rectangle(h->mvd_cache[list][ scan8[0] + 2*i ], 2, 4, 8, 0, 2);
- fill_rectangle(h-> mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, 0, 4);
- }
- }
- }
- }
- }
-
- if( IS_INTER( mb_type ) ) {
- h->chroma_pred_mode_table[mb_xy] = 0;
- write_back_motion( h, mb_type );
- }
-
- if( !IS_INTRA16x16( mb_type ) ) {
- cbp = decode_cabac_mb_cbp_luma( h );
- if(decode_chroma)
- cbp |= decode_cabac_mb_cbp_chroma( h ) << 4;
- } else {
- if (!decode_chroma && cbp>15) {
- av_log(s->avctx, AV_LOG_ERROR, "gray chroma\n");
- return AVERROR_INVALIDDATA;
- }
- }
-
- h->cbp_table[mb_xy] = h->cbp = cbp;
-
- if( dct8x8_allowed && (cbp&15) && !IS_INTRA( mb_type ) ) {
- mb_type |= MB_TYPE_8x8DCT * get_cabac_noinline( &h->cabac, &h->cabac_state[399 + h->neighbor_transform_size] );
- }
-
- /* It would be better to do this in fill_decode_caches, but we don't know
- * the transform mode of the current macroblock there. */
- if (CHROMA444 && IS_8x8DCT(mb_type)){
- int i;
- uint8_t *nnz_cache = h->non_zero_count_cache;
- for (i = 0; i < 2; i++){
- if (h->left_type[LEFT(i)] && !IS_8x8DCT(h->left_type[LEFT(i)])){
- nnz_cache[3+8* 1 + 2*8*i]=
- nnz_cache[3+8* 2 + 2*8*i]=
- nnz_cache[3+8* 6 + 2*8*i]=
- nnz_cache[3+8* 7 + 2*8*i]=
- nnz_cache[3+8*11 + 2*8*i]=
- nnz_cache[3+8*12 + 2*8*i]= IS_INTRA(mb_type) ? 64 : 0;
- }
- }
- if (h->top_type && !IS_8x8DCT(h->top_type)){
- uint32_t top_empty = CABAC && !IS_INTRA(mb_type) ? 0 : 0x40404040;
- AV_WN32A(&nnz_cache[4+8* 0], top_empty);
- AV_WN32A(&nnz_cache[4+8* 5], top_empty);
- AV_WN32A(&nnz_cache[4+8*10], top_empty);
- }
- }
- s->current_picture.f.mb_type[mb_xy] = mb_type;
-
- if( cbp || IS_INTRA16x16( mb_type ) ) {
- const uint8_t *scan, *scan8x8;
- const uint32_t *qmul;
-
- if(IS_INTERLACED(mb_type)){
- scan8x8= s->qscale ? h->field_scan8x8 : h->field_scan8x8_q0;
- scan= s->qscale ? h->field_scan : h->field_scan_q0;
- }else{
- scan8x8= s->qscale ? h->zigzag_scan8x8 : h->zigzag_scan8x8_q0;
- scan= s->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
- }
-
- // decode_cabac_mb_dqp
- if(get_cabac_noinline( &h->cabac, &h->cabac_state[60 + (h->last_qscale_diff != 0)])){
- int val = 1;
- int ctx= 2;
- const int max_qp = 51 + 6*(h->sps.bit_depth_luma-8);
-
- while( get_cabac_noinline( &h->cabac, &h->cabac_state[60 + ctx] ) ) {
- ctx= 3;
- val++;
- if(val > 2*max_qp){ //prevent infinite loop
- av_log(h->s.avctx, AV_LOG_ERROR, "cabac decode of qscale diff failed at %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
- }
-
- if( val&0x01 )
- val= (val + 1)>>1 ;
- else
- val= -((val + 1)>>1);
- h->last_qscale_diff = val;
- s->qscale += val;
- if(((unsigned)s->qscale) > max_qp){
- if(s->qscale<0) s->qscale+= max_qp+1;
- else s->qscale-= max_qp+1;
- }
- h->chroma_qp[0] = get_chroma_qp(h, 0, s->qscale);
- h->chroma_qp[1] = get_chroma_qp(h, 1, s->qscale);
- }else
- h->last_qscale_diff=0;
-
- decode_cabac_luma_residual(h, scan, scan8x8, pixel_shift, mb_type, cbp, 0);
- if(CHROMA444){
- decode_cabac_luma_residual(h, scan, scan8x8, pixel_shift, mb_type, cbp, 1);
- decode_cabac_luma_residual(h, scan, scan8x8, pixel_shift, mb_type, cbp, 2);
- } else if (CHROMA422) {
- if( cbp&0x30 ){
- int c;
- for (c = 0; c < 2; c++)
- decode_cabac_residual_dc_422(h, h->mb + ((256 + 16*16*c) << pixel_shift), 3,
- CHROMA_DC_BLOCK_INDEX + c,
- chroma422_dc_scan, 8);
- }
-
- if( cbp&0x20 ) {
- int c, i, i8x8;
- for( c = 0; c < 2; c++ ) {
- int16_t *mb = h->mb + (16*(16 + 16*c) << pixel_shift);
- qmul = h->dequant4_coeff[c+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[c]];
- for (i8x8 = 0; i8x8 < 2; i8x8++) {
- for (i = 0; i < 4; i++) {
- const int index = 16 + 16 * c + 8*i8x8 + i;
- decode_cabac_residual_nondc(h, mb, 4, index, scan + 1, qmul, 15);
- mb += 16<<pixel_shift;
- }
- }
- }
- } else {
- fill_rectangle(&h->non_zero_count_cache[scan8[16]], 4, 4, 8, 0, 1);
- fill_rectangle(&h->non_zero_count_cache[scan8[32]], 4, 4, 8, 0, 1);
- }
- } else /* yuv420 */ {
- if( cbp&0x30 ){
- int c;
- for (c = 0; c < 2; c++)
- decode_cabac_residual_dc(h, h->mb + ((256 + 16*16*c) << pixel_shift), 3, CHROMA_DC_BLOCK_INDEX+c, chroma_dc_scan, 4);
- }
-
- if( cbp&0x20 ) {
- int c, i;
- for( c = 0; c < 2; c++ ) {
- qmul = h->dequant4_coeff[c+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[c]];
- for( i = 0; i < 4; i++ ) {
- const int index = 16 + 16 * c + i;
- decode_cabac_residual_nondc(h, h->mb + (16*index << pixel_shift), 4, index, scan + 1, qmul, 15);
- }
- }
- } else {
- fill_rectangle(&h->non_zero_count_cache[scan8[16]], 4, 4, 8, 0, 1);
- fill_rectangle(&h->non_zero_count_cache[scan8[32]], 4, 4, 8, 0, 1);
- }
- }
- } else {
- fill_rectangle(&h->non_zero_count_cache[scan8[ 0]], 4, 4, 8, 0, 1);
- fill_rectangle(&h->non_zero_count_cache[scan8[16]], 4, 4, 8, 0, 1);
- fill_rectangle(&h->non_zero_count_cache[scan8[32]], 4, 4, 8, 0, 1);
- h->last_qscale_diff = 0;
- }
-
- s->current_picture.f.qscale_table[mb_xy] = s->qscale;
- write_back_non_zero_count(h);
-
- return 0;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264_cavlc.c b/src/thirdparty/ffmpeg/libavcodec/h264_cavlc.c
deleted file mode 100644
index d34d9fc53..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264_cavlc.c
+++ /dev/null
@@ -1,1170 +0,0 @@
-/*
- * H.26L/H.264/AVC/JVT/14496-10/... cavlc bitstream decoding
- * 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 cavlc bitstream decoding.
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#define CABAC 0
-#define UNCHECKED_BITSTREAM_READER 1
-
-#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 "libavutil/avassert.h"
-
-
-static const uint8_t golomb_to_inter_cbp_gray[16]={
- 0, 1, 2, 4, 8, 3, 5,10,12,15, 7,11,13,14, 6, 9,
-};
-
-static const uint8_t golomb_to_intra4x4_cbp_gray[16]={
-15, 0, 7,11,13,14, 3, 5,10,12, 1, 2, 4, 8, 6, 9,
-};
-
-static const uint8_t chroma_dc_coeff_token_len[4*5]={
- 2, 0, 0, 0,
- 6, 1, 0, 0,
- 6, 6, 3, 0,
- 6, 7, 7, 6,
- 6, 8, 8, 7,
-};
-
-static const uint8_t chroma_dc_coeff_token_bits[4*5]={
- 1, 0, 0, 0,
- 7, 1, 0, 0,
- 4, 6, 1, 0,
- 3, 3, 2, 5,
- 2, 3, 2, 0,
-};
-
-static const uint8_t chroma422_dc_coeff_token_len[4*9]={
- 1, 0, 0, 0,
- 7, 2, 0, 0,
- 7, 7, 3, 0,
- 9, 7, 7, 5,
- 9, 9, 7, 6,
- 10, 10, 9, 7,
- 11, 11, 10, 7,
- 12, 12, 11, 10,
- 13, 12, 12, 11,
-};
-
-static const uint8_t chroma422_dc_coeff_token_bits[4*9]={
- 1, 0, 0, 0,
- 15, 1, 0, 0,
- 14, 13, 1, 0,
- 7, 12, 11, 1,
- 6, 5, 10, 1,
- 7, 6, 4, 9,
- 7, 6, 5, 8,
- 7, 6, 5, 4,
- 7, 5, 4, 4,
-};
-
-static const uint8_t coeff_token_len[4][4*17]={
-{
- 1, 0, 0, 0,
- 6, 2, 0, 0, 8, 6, 3, 0, 9, 8, 7, 5, 10, 9, 8, 6,
- 11,10, 9, 7, 13,11,10, 8, 13,13,11, 9, 13,13,13,10,
- 14,14,13,11, 14,14,14,13, 15,15,14,14, 15,15,15,14,
- 16,15,15,15, 16,16,16,15, 16,16,16,16, 16,16,16,16,
-},
-{
- 2, 0, 0, 0,
- 6, 2, 0, 0, 6, 5, 3, 0, 7, 6, 6, 4, 8, 6, 6, 4,
- 8, 7, 7, 5, 9, 8, 8, 6, 11, 9, 9, 6, 11,11,11, 7,
- 12,11,11, 9, 12,12,12,11, 12,12,12,11, 13,13,13,12,
- 13,13,13,13, 13,14,13,13, 14,14,14,13, 14,14,14,14,
-},
-{
- 4, 0, 0, 0,
- 6, 4, 0, 0, 6, 5, 4, 0, 6, 5, 5, 4, 7, 5, 5, 4,
- 7, 5, 5, 4, 7, 6, 6, 4, 7, 6, 6, 4, 8, 7, 7, 5,
- 8, 8, 7, 6, 9, 8, 8, 7, 9, 9, 8, 8, 9, 9, 9, 8,
- 10, 9, 9, 9, 10,10,10,10, 10,10,10,10, 10,10,10,10,
-},
-{
- 6, 0, 0, 0,
- 6, 6, 0, 0, 6, 6, 6, 0, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
-}
-};
-
-static const uint8_t coeff_token_bits[4][4*17]={
-{
- 1, 0, 0, 0,
- 5, 1, 0, 0, 7, 4, 1, 0, 7, 6, 5, 3, 7, 6, 5, 3,
- 7, 6, 5, 4, 15, 6, 5, 4, 11,14, 5, 4, 8,10,13, 4,
- 15,14, 9, 4, 11,10,13,12, 15,14, 9,12, 11,10,13, 8,
- 15, 1, 9,12, 11,14,13, 8, 7,10, 9,12, 4, 6, 5, 8,
-},
-{
- 3, 0, 0, 0,
- 11, 2, 0, 0, 7, 7, 3, 0, 7,10, 9, 5, 7, 6, 5, 4,
- 4, 6, 5, 6, 7, 6, 5, 8, 15, 6, 5, 4, 11,14,13, 4,
- 15,10, 9, 4, 11,14,13,12, 8,10, 9, 8, 15,14,13,12,
- 11,10, 9,12, 7,11, 6, 8, 9, 8,10, 1, 7, 6, 5, 4,
-},
-{
- 15, 0, 0, 0,
- 15,14, 0, 0, 11,15,13, 0, 8,12,14,12, 15,10,11,11,
- 11, 8, 9,10, 9,14,13, 9, 8,10, 9, 8, 15,14,13,13,
- 11,14,10,12, 15,10,13,12, 11,14, 9,12, 8,10,13, 8,
- 13, 7, 9,12, 9,12,11,10, 5, 8, 7, 6, 1, 4, 3, 2,
-},
-{
- 3, 0, 0, 0,
- 0, 1, 0, 0, 4, 5, 6, 0, 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,57,58,59, 60,61,62,63,
-}
-};
-
-static const uint8_t total_zeros_len[16][16]= {
- {1,3,3,4,4,5,5,6,6,7,7,8,8,9,9,9},
- {3,3,3,3,3,4,4,4,4,5,5,6,6,6,6},
- {4,3,3,3,4,4,3,3,4,5,5,6,5,6},
- {5,3,4,4,3,3,3,4,3,4,5,5,5},
- {4,4,4,3,3,3,3,3,4,5,4,5},
- {6,5,3,3,3,3,3,3,4,3,6},
- {6,5,3,3,3,2,3,4,3,6},
- {6,4,5,3,2,2,3,3,6},
- {6,6,4,2,2,3,2,5},
- {5,5,3,2,2,2,4},
- {4,4,3,3,1,3},
- {4,4,2,1,3},
- {3,3,1,2},
- {2,2,1},
- {1,1},
-};
-
-static const uint8_t total_zeros_bits[16][16]= {
- {1,3,2,3,2,3,2,3,2,3,2,3,2,3,2,1},
- {7,6,5,4,3,5,4,3,2,3,2,3,2,1,0},
- {5,7,6,5,4,3,4,3,2,3,2,1,1,0},
- {3,7,5,4,6,5,4,3,3,2,2,1,0},
- {5,4,3,7,6,5,4,3,2,1,1,0},
- {1,1,7,6,5,4,3,2,1,1,0},
- {1,1,5,4,3,3,2,1,1,0},
- {1,1,1,3,3,2,2,1,0},
- {1,0,1,3,2,1,1,1},
- {1,0,1,3,2,1,1},
- {0,1,1,2,1,3},
- {0,1,1,1,1},
- {0,1,1,1},
- {0,1,1},
- {0,1},
-};
-
-static const uint8_t chroma_dc_total_zeros_len[3][4]= {
- { 1, 2, 3, 3,},
- { 1, 2, 2, 0,},
- { 1, 1, 0, 0,},
-};
-
-static const uint8_t chroma_dc_total_zeros_bits[3][4]= {
- { 1, 1, 1, 0,},
- { 1, 1, 0, 0,},
- { 1, 0, 0, 0,},
-};
-
-static const uint8_t chroma422_dc_total_zeros_len[7][8]= {
- { 1, 3, 3, 4, 4, 4, 5, 5 },
- { 3, 2, 3, 3, 3, 3, 3 },
- { 3, 3, 2, 2, 3, 3 },
- { 3, 2, 2, 2, 3 },
- { 2, 2, 2, 2 },
- { 2, 2, 1 },
- { 1, 1 },
-};
-
-static const uint8_t chroma422_dc_total_zeros_bits[7][8]= {
- { 1, 2, 3, 2, 3, 1, 1, 0 },
- { 0, 1, 1, 4, 5, 6, 7 },
- { 0, 1, 1, 2, 6, 7 },
- { 6, 0, 1, 2, 7 },
- { 0, 1, 2, 3 },
- { 0, 1, 1 },
- { 0, 1 },
-};
-
-static const uint8_t run_len[7][16]={
- {1,1},
- {1,2,2},
- {2,2,2,2},
- {2,2,2,3,3},
- {2,2,3,3,3,3},
- {2,3,3,3,3,3,3},
- {3,3,3,3,3,3,3,4,5,6,7,8,9,10,11},
-};
-
-static const uint8_t run_bits[7][16]={
- {1,0},
- {1,1,0},
- {3,2,1,0},
- {3,2,1,1,0},
- {3,2,3,2,1,0},
- {3,0,1,3,2,5,4},
- {7,6,5,4,3,2,1,1,1,1,1,1,1,1,1},
-};
-
-static VLC coeff_token_vlc[4];
-static VLC_TYPE coeff_token_vlc_tables[520+332+280+256][2];
-static const int coeff_token_vlc_tables_size[4]={520,332,280,256};
-
-static VLC chroma_dc_coeff_token_vlc;
-static VLC_TYPE chroma_dc_coeff_token_vlc_table[256][2];
-static const int chroma_dc_coeff_token_vlc_table_size = 256;
-
-static VLC chroma422_dc_coeff_token_vlc;
-static VLC_TYPE chroma422_dc_coeff_token_vlc_table[8192][2];
-static const int chroma422_dc_coeff_token_vlc_table_size = 8192;
-
-static VLC total_zeros_vlc[15];
-static VLC_TYPE total_zeros_vlc_tables[15][512][2];
-static const int total_zeros_vlc_tables_size = 512;
-
-static VLC chroma_dc_total_zeros_vlc[3];
-static VLC_TYPE chroma_dc_total_zeros_vlc_tables[3][8][2];
-static const int chroma_dc_total_zeros_vlc_tables_size = 8;
-
-static VLC chroma422_dc_total_zeros_vlc[7];
-static VLC_TYPE chroma422_dc_total_zeros_vlc_tables[7][32][2];
-static const int chroma422_dc_total_zeros_vlc_tables_size = 32;
-
-static VLC run_vlc[6];
-static VLC_TYPE run_vlc_tables[6][8][2];
-static const int run_vlc_tables_size = 8;
-
-static VLC run7_vlc;
-static VLC_TYPE run7_vlc_table[96][2];
-static const int run7_vlc_table_size = 96;
-
-#define LEVEL_TAB_BITS 8
-static int8_t cavlc_level_tab[7][1<<LEVEL_TAB_BITS][2];
-
-#define CHROMA_DC_COEFF_TOKEN_VLC_BITS 8
-#define CHROMA422_DC_COEFF_TOKEN_VLC_BITS 13
-#define COEFF_TOKEN_VLC_BITS 8
-#define TOTAL_ZEROS_VLC_BITS 9
-#define CHROMA_DC_TOTAL_ZEROS_VLC_BITS 3
-#define CHROMA422_DC_TOTAL_ZEROS_VLC_BITS 5
-#define RUN_VLC_BITS 3
-#define RUN7_VLC_BITS 6
-
-/**
- * Get the predicted number of non-zero coefficients.
- * @param n block index
- */
-static inline int pred_non_zero_count(H264Context *h, int n){
- const int index8= scan8[n];
- const int left= h->non_zero_count_cache[index8 - 1];
- const int top = h->non_zero_count_cache[index8 - 8];
- int i= left + top;
-
- if(i<64) i= (i+1)>>1;
-
- tprintf(h->s.avctx, "pred_nnz L%X T%X n%d s%d P%X\n", left, top, n, scan8[n], i&31);
-
- return i&31;
-}
-
-static av_cold void init_cavlc_level_tab(void){
- int suffix_length;
- unsigned int i;
-
- for(suffix_length=0; suffix_length<7; suffix_length++){
- for(i=0; i<(1<<LEVEL_TAB_BITS); i++){
- int prefix= LEVEL_TAB_BITS - av_log2(2*i);
-
- if(prefix + 1 + suffix_length <= LEVEL_TAB_BITS){
- int level_code = (prefix << suffix_length) +
- (i >> (av_log2(i) - suffix_length)) - (1 << suffix_length);
- int mask = -(level_code&1);
- level_code = (((2 + level_code) >> 1) ^ mask) - mask;
- cavlc_level_tab[suffix_length][i][0]= level_code;
- cavlc_level_tab[suffix_length][i][1]= prefix + 1 + suffix_length;
- }else if(prefix + 1 <= LEVEL_TAB_BITS){
- cavlc_level_tab[suffix_length][i][0]= prefix+100;
- cavlc_level_tab[suffix_length][i][1]= prefix + 1;
- }else{
- cavlc_level_tab[suffix_length][i][0]= LEVEL_TAB_BITS+100;
- cavlc_level_tab[suffix_length][i][1]= LEVEL_TAB_BITS;
- }
- }
- }
-}
-
-av_cold void ff_h264_decode_init_vlc(void){
- static int done = 0;
-
- if (!done) {
- int i;
- int offset;
- done = 1;
-
- chroma_dc_coeff_token_vlc.table = chroma_dc_coeff_token_vlc_table;
- chroma_dc_coeff_token_vlc.table_allocated = chroma_dc_coeff_token_vlc_table_size;
- init_vlc(&chroma_dc_coeff_token_vlc, CHROMA_DC_COEFF_TOKEN_VLC_BITS, 4*5,
- &chroma_dc_coeff_token_len [0], 1, 1,
- &chroma_dc_coeff_token_bits[0], 1, 1,
- INIT_VLC_USE_NEW_STATIC);
-
- chroma422_dc_coeff_token_vlc.table = chroma422_dc_coeff_token_vlc_table;
- chroma422_dc_coeff_token_vlc.table_allocated = chroma422_dc_coeff_token_vlc_table_size;
- init_vlc(&chroma422_dc_coeff_token_vlc, CHROMA422_DC_COEFF_TOKEN_VLC_BITS, 4*9,
- &chroma422_dc_coeff_token_len [0], 1, 1,
- &chroma422_dc_coeff_token_bits[0], 1, 1,
- INIT_VLC_USE_NEW_STATIC);
-
- offset = 0;
- for(i=0; i<4; i++){
- coeff_token_vlc[i].table = coeff_token_vlc_tables+offset;
- coeff_token_vlc[i].table_allocated = coeff_token_vlc_tables_size[i];
- init_vlc(&coeff_token_vlc[i], COEFF_TOKEN_VLC_BITS, 4*17,
- &coeff_token_len [i][0], 1, 1,
- &coeff_token_bits[i][0], 1, 1,
- INIT_VLC_USE_NEW_STATIC);
- offset += coeff_token_vlc_tables_size[i];
- }
- /*
- * This is a one time safety check to make sure that
- * the packed static coeff_token_vlc table sizes
- * were initialized correctly.
- */
- av_assert0(offset == FF_ARRAY_ELEMS(coeff_token_vlc_tables));
-
- for(i=0; i<3; i++){
- chroma_dc_total_zeros_vlc[i].table = chroma_dc_total_zeros_vlc_tables[i];
- chroma_dc_total_zeros_vlc[i].table_allocated = chroma_dc_total_zeros_vlc_tables_size;
- init_vlc(&chroma_dc_total_zeros_vlc[i],
- CHROMA_DC_TOTAL_ZEROS_VLC_BITS, 4,
- &chroma_dc_total_zeros_len [i][0], 1, 1,
- &chroma_dc_total_zeros_bits[i][0], 1, 1,
- INIT_VLC_USE_NEW_STATIC);
- }
-
- for(i=0; i<7; i++){
- chroma422_dc_total_zeros_vlc[i].table = chroma422_dc_total_zeros_vlc_tables[i];
- chroma422_dc_total_zeros_vlc[i].table_allocated = chroma422_dc_total_zeros_vlc_tables_size;
- init_vlc(&chroma422_dc_total_zeros_vlc[i],
- CHROMA422_DC_TOTAL_ZEROS_VLC_BITS, 8,
- &chroma422_dc_total_zeros_len [i][0], 1, 1,
- &chroma422_dc_total_zeros_bits[i][0], 1, 1,
- INIT_VLC_USE_NEW_STATIC);
- }
-
- for(i=0; i<15; i++){
- total_zeros_vlc[i].table = total_zeros_vlc_tables[i];
- total_zeros_vlc[i].table_allocated = total_zeros_vlc_tables_size;
- init_vlc(&total_zeros_vlc[i],
- TOTAL_ZEROS_VLC_BITS, 16,
- &total_zeros_len [i][0], 1, 1,
- &total_zeros_bits[i][0], 1, 1,
- INIT_VLC_USE_NEW_STATIC);
- }
-
- for(i=0; i<6; i++){
- run_vlc[i].table = run_vlc_tables[i];
- run_vlc[i].table_allocated = run_vlc_tables_size;
- init_vlc(&run_vlc[i],
- RUN_VLC_BITS, 7,
- &run_len [i][0], 1, 1,
- &run_bits[i][0], 1, 1,
- INIT_VLC_USE_NEW_STATIC);
- }
- run7_vlc.table = run7_vlc_table,
- run7_vlc.table_allocated = run7_vlc_table_size;
- init_vlc(&run7_vlc, RUN7_VLC_BITS, 16,
- &run_len [6][0], 1, 1,
- &run_bits[6][0], 1, 1,
- INIT_VLC_USE_NEW_STATIC);
-
- init_cavlc_level_tab();
- }
-}
-
-/**
- *
- */
-static inline int get_level_prefix(GetBitContext *gb){
- unsigned int buf;
- int log;
-
- OPEN_READER(re, gb);
- UPDATE_CACHE(re, gb);
- buf=GET_CACHE(re, gb);
-
- log= 32 - av_log2(buf);
-#ifdef TRACE
- print_bin(buf>>(32-log), log);
- av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d lpr @%5d in %s get_level_prefix\n", buf>>(32-log), log, log-1, get_bits_count(gb), __FILE__);
-#endif
-
- LAST_SKIP_BITS(re, gb, log);
- CLOSE_READER(re, gb);
-
- return log-1;
-}
-
-/**
- * Decode a residual block.
- * @param n block index
- * @param scantable scantable
- * @param max_coeff number of coefficients in the block
- * @return <0 if an error occurred
- */
-static int decode_residual(H264Context *h, GetBitContext *gb, int16_t *block, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff){
- MpegEncContext * const s = &h->s;
- static const int coeff_token_table_index[17]= {0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3};
- int level[16];
- int zeros_left, coeff_token, total_coeff, i, trailing_ones, run_before;
-
- //FIXME put trailing_onex into the context
-
- if(max_coeff <= 8){
- if (max_coeff == 4)
- coeff_token = get_vlc2(gb, chroma_dc_coeff_token_vlc.table, CHROMA_DC_COEFF_TOKEN_VLC_BITS, 1);
- else
- coeff_token = get_vlc2(gb, chroma422_dc_coeff_token_vlc.table, CHROMA422_DC_COEFF_TOKEN_VLC_BITS, 1);
- total_coeff= coeff_token>>2;
- }else{
- if(n >= LUMA_DC_BLOCK_INDEX){
- total_coeff= pred_non_zero_count(h, (n - LUMA_DC_BLOCK_INDEX)*16);
- coeff_token= get_vlc2(gb, coeff_token_vlc[ coeff_token_table_index[total_coeff] ].table, COEFF_TOKEN_VLC_BITS, 2);
- total_coeff= coeff_token>>2;
- }else{
- total_coeff= pred_non_zero_count(h, n);
- coeff_token= get_vlc2(gb, coeff_token_vlc[ coeff_token_table_index[total_coeff] ].table, COEFF_TOKEN_VLC_BITS, 2);
- total_coeff= coeff_token>>2;
- }
- }
- h->non_zero_count_cache[ scan8[n] ]= total_coeff;
-
- //FIXME set last_non_zero?
-
- if(total_coeff==0)
- return 0;
- if(total_coeff > (unsigned)max_coeff) {
- av_log(h->s.avctx, AV_LOG_ERROR, "corrupted macroblock %d %d (total_coeff=%d)\n", s->mb_x, s->mb_y, total_coeff);
- return -1;
- }
-
- trailing_ones= coeff_token&3;
- tprintf(h->s.avctx, "trailing:%d, total:%d\n", trailing_ones, total_coeff);
- av_assert2(total_coeff<=16);
-
- i = show_bits(gb, 3);
- skip_bits(gb, trailing_ones);
- level[0] = 1-((i&4)>>1);
- level[1] = 1-((i&2) );
- level[2] = 1-((i&1)<<1);
-
- if(trailing_ones<total_coeff) {
- int mask, prefix;
- int suffix_length = total_coeff > 10 & trailing_ones < 3;
- int bitsi= show_bits(gb, LEVEL_TAB_BITS);
- int level_code= cavlc_level_tab[suffix_length][bitsi][0];
-
- skip_bits(gb, cavlc_level_tab[suffix_length][bitsi][1]);
- if(level_code >= 100){
- prefix= level_code - 100;
- if(prefix == LEVEL_TAB_BITS)
- prefix += get_level_prefix(gb);
-
- //first coefficient has suffix_length equal to 0 or 1
- if(prefix<14){ //FIXME try to build a large unified VLC table for all this
- if(suffix_length)
- level_code= (prefix<<1) + get_bits1(gb); //part
- else
- level_code= prefix; //part
- }else if(prefix==14){
- if(suffix_length)
- level_code= (prefix<<1) + get_bits1(gb); //part
- else
- level_code= prefix + get_bits(gb, 4); //part
- }else{
- level_code= 30;
- if(prefix>=16){
- if(prefix > 25+3){
- av_log(h->s.avctx, AV_LOG_ERROR, "Invalid level prefix\n");
- return -1;
- }
- level_code += (1<<(prefix-3))-4096;
- }
- level_code += get_bits(gb, prefix-3); //part
- }
-
- if(trailing_ones < 3) level_code += 2;
-
- suffix_length = 2;
- mask= -(level_code&1);
- level[trailing_ones]= (((2+level_code)>>1) ^ mask) - mask;
- }else{
- level_code += ((level_code>>31)|1) & -(trailing_ones < 3);
-
- suffix_length = 1 + (level_code + 3U > 6U);
- level[trailing_ones]= level_code;
- }
-
- //remaining coefficients have suffix_length > 0
- for(i=trailing_ones+1;i<total_coeff;i++) {
- static const unsigned int suffix_limit[7] = {0,3,6,12,24,48,INT_MAX };
- int bitsi= show_bits(gb, LEVEL_TAB_BITS);
- level_code= cavlc_level_tab[suffix_length][bitsi][0];
-
- skip_bits(gb, cavlc_level_tab[suffix_length][bitsi][1]);
- if(level_code >= 100){
- prefix= level_code - 100;
- if(prefix == LEVEL_TAB_BITS){
- prefix += get_level_prefix(gb);
- }
- if(prefix<15){
- level_code = (prefix<<suffix_length) + get_bits(gb, suffix_length);
- }else{
- level_code = (15<<suffix_length) + get_bits(gb, prefix-3);
- if(prefix>=16)
- level_code += (1<<(prefix-3))-4096;
- }
- mask= -(level_code&1);
- level_code= (((2+level_code)>>1) ^ mask) - mask;
- }
- level[i]= level_code;
- suffix_length+= suffix_limit[suffix_length] + level_code > 2U*suffix_limit[suffix_length];
- }
- }
-
- if(total_coeff == max_coeff)
- zeros_left=0;
- else{
- if (max_coeff <= 8) {
- if (max_coeff == 4)
- zeros_left = get_vlc2(gb, (chroma_dc_total_zeros_vlc-1)[total_coeff].table,
- CHROMA_DC_TOTAL_ZEROS_VLC_BITS, 1);
- else
- zeros_left = get_vlc2(gb, (chroma422_dc_total_zeros_vlc-1)[total_coeff].table,
- CHROMA422_DC_TOTAL_ZEROS_VLC_BITS, 1);
- } else {
- zeros_left= get_vlc2(gb, (total_zeros_vlc-1)[ total_coeff ].table, TOTAL_ZEROS_VLC_BITS, 1);
- }
- }
-
-#define STORE_BLOCK(type) \
- scantable += zeros_left + total_coeff - 1; \
- if(n >= LUMA_DC_BLOCK_INDEX){ \
- ((type*)block)[*scantable] = level[0]; \
- for(i=1;i<total_coeff && zeros_left > 0;i++) { \
- if(zeros_left < 7) \
- run_before= get_vlc2(gb, (run_vlc-1)[zeros_left].table, RUN_VLC_BITS, 1); \
- else \
- run_before= get_vlc2(gb, run7_vlc.table, RUN7_VLC_BITS, 2); \
- zeros_left -= run_before; \
- scantable -= 1 + run_before; \
- ((type*)block)[*scantable]= level[i]; \
- } \
- for(;i<total_coeff;i++) { \
- scantable--; \
- ((type*)block)[*scantable]= level[i]; \
- } \
- }else{ \
- ((type*)block)[*scantable] = ((int)(level[0] * qmul[*scantable] + 32))>>6; \
- for(i=1;i<total_coeff && zeros_left > 0;i++) { \
- if(zeros_left < 7) \
- run_before= get_vlc2(gb, (run_vlc-1)[zeros_left].table, RUN_VLC_BITS, 1); \
- else \
- run_before= get_vlc2(gb, run7_vlc.table, RUN7_VLC_BITS, 2); \
- zeros_left -= run_before; \
- scantable -= 1 + run_before; \
- ((type*)block)[*scantable]= ((int)(level[i] * qmul[*scantable] + 32))>>6; \
- } \
- for(;i<total_coeff;i++) { \
- scantable--; \
- ((type*)block)[*scantable]= ((int)(level[i] * qmul[*scantable] + 32))>>6; \
- } \
- }
-
- if (h->pixel_shift) {
- STORE_BLOCK(int32_t)
- } else {
- STORE_BLOCK(int16_t)
- }
-
- if(zeros_left<0){
- av_log(h->s.avctx, AV_LOG_ERROR, "negative number of zero coeffs at %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
-
- return 0;
-}
-
-static av_always_inline int decode_luma_residual(H264Context *h, GetBitContext *gb, const uint8_t *scan, const uint8_t *scan8x8, int pixel_shift, int mb_type, int cbp, int p){
- int i4x4, i8x8;
- MpegEncContext * const s = &h->s;
- int qscale = p == 0 ? s->qscale : h->chroma_qp[p-1];
- if(IS_INTRA16x16(mb_type)){
- AV_ZERO128(h->mb_luma_dc[p]+0);
- AV_ZERO128(h->mb_luma_dc[p]+8);
- AV_ZERO128(h->mb_luma_dc[p]+16);
- AV_ZERO128(h->mb_luma_dc[p]+24);
- if( decode_residual(h, h->intra_gb_ptr, h->mb_luma_dc[p], LUMA_DC_BLOCK_INDEX+p, scan, NULL, 16) < 0){
- return -1; //FIXME continue if partitioned and other return -1 too
- }
-
- av_assert2((cbp&15) == 0 || (cbp&15) == 15);
-
- if(cbp&15){
- for(i8x8=0; i8x8<4; i8x8++){
- for(i4x4=0; i4x4<4; i4x4++){
- const int index= i4x4 + 4*i8x8 + p*16;
- if( decode_residual(h, h->intra_gb_ptr, h->mb + (16*index << pixel_shift),
- index, scan + 1, h->dequant4_coeff[p][qscale], 15) < 0 ){
- return -1;
- }
- }
- }
- return 0xf;
- }else{
- fill_rectangle(&h->non_zero_count_cache[scan8[p*16]], 4, 4, 8, 0, 1);
- return 0;
- }
- }else{
- int cqm = (IS_INTRA( mb_type ) ? 0:3)+p;
- /* For CAVLC 4:4:4, we need to keep track of the luma 8x8 CBP for deblocking nnz purposes. */
- int new_cbp = 0;
- for(i8x8=0; i8x8<4; i8x8++){
- if(cbp & (1<<i8x8)){
- if(IS_8x8DCT(mb_type)){
- int16_t *buf = &h->mb[64*i8x8+256*p << pixel_shift];
- uint8_t *nnz;
- for(i4x4=0; i4x4<4; i4x4++){
- const int index= i4x4 + 4*i8x8 + p*16;
- if( decode_residual(h, gb, buf, index, scan8x8+16*i4x4,
- h->dequant8_coeff[cqm][qscale], 16) < 0 )
- return -1;
- }
- nnz= &h->non_zero_count_cache[ scan8[4*i8x8+p*16] ];
- nnz[0] += nnz[1] + nnz[8] + nnz[9];
- new_cbp |= !!nnz[0] << i8x8;
- }else{
- for(i4x4=0; i4x4<4; i4x4++){
- const int index= i4x4 + 4*i8x8 + p*16;
- if( decode_residual(h, gb, h->mb + (16*index << pixel_shift), index,
- scan, h->dequant4_coeff[cqm][qscale], 16) < 0 ){
- return -1;
- }
- new_cbp |= h->non_zero_count_cache[ scan8[index] ] << i8x8;
- }
- }
- }else{
- uint8_t * const nnz= &h->non_zero_count_cache[ scan8[4*i8x8+p*16] ];
- nnz[0] = nnz[1] = nnz[8] = nnz[9] = 0;
- }
- }
- return new_cbp;
- }
-}
-
-int ff_h264_decode_mb_cavlc(H264Context *h){
- MpegEncContext * const s = &h->s;
- int mb_xy;
- int partition_count;
- unsigned int mb_type, cbp;
- int dct8x8_allowed= h->pps.transform_8x8_mode;
- int decode_chroma = h->sps.chroma_format_idc == 1 || h->sps.chroma_format_idc == 2;
- const int pixel_shift = h->pixel_shift;
- unsigned local_ref_count[2];
-
- mb_xy = h->mb_xy = s->mb_x + s->mb_y*s->mb_stride;
-
- tprintf(s->avctx, "pic:%d mb:%d/%d\n", h->frame_num, s->mb_x, s->mb_y);
- cbp = 0; /* avoid warning. FIXME: find a solution without slowing
- down the code */
- if(h->slice_type_nos != AV_PICTURE_TYPE_I){
- if(s->mb_skip_run==-1)
- s->mb_skip_run= get_ue_golomb(&s->gb);
-
- if (s->mb_skip_run--) {
- if(FRAME_MBAFF && (s->mb_y&1) == 0){
- if(s->mb_skip_run==0)
- h->mb_mbaff = h->mb_field_decoding_flag = get_bits1(&s->gb);
- }
- decode_mb_skip(h);
- return 0;
- }
- }
- if(FRAME_MBAFF){
- if( (s->mb_y&1) == 0 )
- h->mb_mbaff = h->mb_field_decoding_flag = get_bits1(&s->gb);
- }
-
- h->prev_mb_skipped= 0;
-
- mb_type= get_ue_golomb(&s->gb);
- if(h->slice_type_nos == AV_PICTURE_TYPE_B){
- if(mb_type < 23){
- partition_count= b_mb_type_info[mb_type].partition_count;
- mb_type= b_mb_type_info[mb_type].type;
- }else{
- mb_type -= 23;
- goto decode_intra_mb;
- }
- }else if(h->slice_type_nos == AV_PICTURE_TYPE_P){
- if(mb_type < 5){
- partition_count= p_mb_type_info[mb_type].partition_count;
- mb_type= p_mb_type_info[mb_type].type;
- }else{
- mb_type -= 5;
- goto decode_intra_mb;
- }
- }else{
- av_assert2(h->slice_type_nos == AV_PICTURE_TYPE_I);
- if(h->slice_type == AV_PICTURE_TYPE_SI && mb_type)
- mb_type--;
-decode_intra_mb:
- if(mb_type > 25){
- av_log(h->s.avctx, AV_LOG_ERROR, "mb_type %d in %c slice too large at %d %d\n", mb_type, av_get_picture_type_char(h->slice_type), s->mb_x, s->mb_y);
- return -1;
- }
- partition_count=0;
- cbp= i_mb_type_info[mb_type].cbp;
- h->intra16x16_pred_mode= i_mb_type_info[mb_type].pred_mode;
- mb_type= i_mb_type_info[mb_type].type;
- }
-
- if(MB_FIELD)
- mb_type |= MB_TYPE_INTERLACED;
-
- h->slice_table[ mb_xy ]= h->slice_num;
-
- if(IS_INTRA_PCM(mb_type)){
- unsigned int x;
- const int mb_size = ff_h264_mb_sizes[h->sps.chroma_format_idc] *
- h->sps.bit_depth_luma >> 3;
-
- // We assume these blocks are very rare so we do not optimize it.
- align_get_bits(&s->gb);
-
- // The pixels are stored in the same order as levels in h->mb array.
- for(x=0; x < mb_size; x++){
- ((uint8_t*)h->mb)[x]= get_bits(&s->gb, 8);
- }
-
- // In deblocking, the quantizer is 0
- s->current_picture.f.qscale_table[mb_xy] = 0;
- // All coeffs are present
- memset(h->non_zero_count[mb_xy], 16, 48);
-
- s->current_picture.f.mb_type[mb_xy] = mb_type;
- return 0;
- }
-
- local_ref_count[0] = h->ref_count[0] << MB_MBAFF;
- local_ref_count[1] = h->ref_count[1] << MB_MBAFF;
-
- fill_decode_neighbors(h, mb_type);
- fill_decode_caches(h, mb_type);
-
- //mb_pred
- if(IS_INTRA(mb_type)){
- int pred_mode;
-// init_top_left_availability(h);
- if(IS_INTRA4x4(mb_type)){
- int i;
- int di = 1;
- if(dct8x8_allowed && get_bits1(&s->gb)){
- mb_type |= MB_TYPE_8x8DCT;
- di = 4;
- }
-
-// fill_intra4x4_pred_table(h);
- for(i=0; i<16; i+=di){
- int mode= pred_intra_mode(h, i);
-
- if(!get_bits1(&s->gb)){
- const int rem_mode= get_bits(&s->gb, 3);
- mode = rem_mode + (rem_mode >= mode);
- }
-
- if(di==4)
- fill_rectangle( &h->intra4x4_pred_mode_cache[ scan8[i] ], 2, 2, 8, mode, 1 );
- else
- h->intra4x4_pred_mode_cache[ scan8[i] ] = mode;
- }
- write_back_intra_pred_mode(h);
- if( ff_h264_check_intra4x4_pred_mode(h) < 0)
- return -1;
- }else{
- h->intra16x16_pred_mode= ff_h264_check_intra_pred_mode(h, h->intra16x16_pred_mode, 0);
- if(h->intra16x16_pred_mode < 0)
- return -1;
- }
- if(decode_chroma){
- pred_mode= ff_h264_check_intra_pred_mode(h, get_ue_golomb_31(&s->gb), 1);
- if(pred_mode < 0)
- return -1;
- h->chroma_pred_mode= pred_mode;
- } else {
- h->chroma_pred_mode = DC_128_PRED8x8;
- }
- }else if(partition_count==4){
- int i, j, sub_partition_count[4], list, ref[2][4];
-
- if(h->slice_type_nos == AV_PICTURE_TYPE_B){
- for(i=0; i<4; i++){
- h->sub_mb_type[i]= get_ue_golomb_31(&s->gb);
- if(h->sub_mb_type[i] >=13){
- av_log(h->s.avctx, AV_LOG_ERROR, "B sub_mb_type %u out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y);
- return -1;
- }
- sub_partition_count[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
- h->sub_mb_type[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].type;
- }
- if( IS_DIRECT(h->sub_mb_type[0]|h->sub_mb_type[1]|h->sub_mb_type[2]|h->sub_mb_type[3])) {
- ff_h264_pred_direct_motion(h, &mb_type);
- h->ref_cache[0][scan8[4]] =
- h->ref_cache[1][scan8[4]] =
- h->ref_cache[0][scan8[12]] =
- h->ref_cache[1][scan8[12]] = PART_NOT_AVAILABLE;
- }
- }else{
- av_assert2(h->slice_type_nos == AV_PICTURE_TYPE_P); //FIXME SP correct ?
- for(i=0; i<4; i++){
- h->sub_mb_type[i]= get_ue_golomb_31(&s->gb);
- if(h->sub_mb_type[i] >=4){
- av_log(h->s.avctx, AV_LOG_ERROR, "P sub_mb_type %u out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y);
- return -1;
- }
- sub_partition_count[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
- h->sub_mb_type[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].type;
- }
- }
-
- for(list=0; list<h->list_count; list++){
- int ref_count= IS_REF0(mb_type) ? 1 : local_ref_count[list];
- for(i=0; i<4; i++){
- if(IS_DIRECT(h->sub_mb_type[i])) continue;
- if(IS_DIR(h->sub_mb_type[i], 0, list)){
- unsigned int tmp;
- if(ref_count == 1){
- tmp= 0;
- }else if(ref_count == 2){
- tmp= get_bits1(&s->gb)^1;
- }else{
- tmp= get_ue_golomb_31(&s->gb);
- if(tmp>=ref_count){
- av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", tmp);
- return -1;
- }
- }
- ref[list][i]= tmp;
- }else{
- //FIXME
- ref[list][i] = -1;
- }
- }
- }
-
- if(dct8x8_allowed)
- dct8x8_allowed = get_dct8x8_allowed(h);
-
- for(list=0; list<h->list_count; list++){
- for(i=0; i<4; i++){
- if(IS_DIRECT(h->sub_mb_type[i])) {
- h->ref_cache[list][ scan8[4*i] ] = h->ref_cache[list][ scan8[4*i]+1 ];
- continue;
- }
- h->ref_cache[list][ scan8[4*i] ]=h->ref_cache[list][ scan8[4*i]+1 ]=
- h->ref_cache[list][ scan8[4*i]+8 ]=h->ref_cache[list][ scan8[4*i]+9 ]= ref[list][i];
-
- if(IS_DIR(h->sub_mb_type[i], 0, list)){
- const int sub_mb_type= h->sub_mb_type[i];
- const int block_width= (sub_mb_type & (MB_TYPE_16x16|MB_TYPE_16x8)) ? 2 : 1;
- for(j=0; j<sub_partition_count[i]; j++){
- int mx, my;
- const int index= 4*i + block_width*j;
- int16_t (* mv_cache)[2]= &h->mv_cache[list][ scan8[index] ];
- pred_motion(h, index, block_width, list, h->ref_cache[list][ scan8[index] ], &mx, &my);
- mx += get_se_golomb(&s->gb);
- my += get_se_golomb(&s->gb);
- tprintf(s->avctx, "final mv:%d %d\n", mx, my);
-
- if(IS_SUB_8X8(sub_mb_type)){
- mv_cache[ 1 ][0]=
- mv_cache[ 8 ][0]= mv_cache[ 9 ][0]= mx;
- mv_cache[ 1 ][1]=
- mv_cache[ 8 ][1]= mv_cache[ 9 ][1]= my;
- }else if(IS_SUB_8X4(sub_mb_type)){
- mv_cache[ 1 ][0]= mx;
- mv_cache[ 1 ][1]= my;
- }else if(IS_SUB_4X8(sub_mb_type)){
- mv_cache[ 8 ][0]= mx;
- mv_cache[ 8 ][1]= my;
- }
- mv_cache[ 0 ][0]= mx;
- mv_cache[ 0 ][1]= my;
- }
- }else{
- uint32_t *p= (uint32_t *)&h->mv_cache[list][ scan8[4*i] ][0];
- p[0] = p[1]=
- p[8] = p[9]= 0;
- }
- }
- }
- }else if(IS_DIRECT(mb_type)){
- ff_h264_pred_direct_motion(h, &mb_type);
- dct8x8_allowed &= h->sps.direct_8x8_inference_flag;
- }else{
- int list, mx, my, i;
- //FIXME we should set ref_idx_l? to 0 if we use that later ...
- if(IS_16X16(mb_type)){
- for(list=0; list<h->list_count; list++){
- unsigned int val;
- if(IS_DIR(mb_type, 0, list)){
- if(local_ref_count[list]==1){
- val= 0;
- }else if(local_ref_count[list]==2){
- val= get_bits1(&s->gb)^1;
- }else{
- val= get_ue_golomb_31(&s->gb);
- if(val >= local_ref_count[list]){
- av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", val);
- return -1;
- }
- }
- fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, val, 1);
- }
- }
- for(list=0; list<h->list_count; list++){
- if(IS_DIR(mb_type, 0, list)){
- pred_motion(h, 0, 4, list, h->ref_cache[list][ scan8[0] ], &mx, &my);
- mx += get_se_golomb(&s->gb);
- my += get_se_golomb(&s->gb);
- tprintf(s->avctx, "final mv:%d %d\n", mx, my);
-
- fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx,my), 4);
- }
- }
- }
- else if(IS_16X8(mb_type)){
- for(list=0; list<h->list_count; list++){
- for(i=0; i<2; i++){
- unsigned int val;
- if(IS_DIR(mb_type, i, list)){
- if(local_ref_count[list] == 1){
- val= 0;
- }else if(local_ref_count[list] == 2){
- val= get_bits1(&s->gb)^1;
- }else{
- val= get_ue_golomb_31(&s->gb);
- if(val >= local_ref_count[list]){
- av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", val);
- return -1;
- }
- }
- }else
- val= LIST_NOT_USED&0xFF;
- fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, val, 1);
- }
- }
- for(list=0; list<h->list_count; list++){
- for(i=0; i<2; i++){
- unsigned int val;
- if(IS_DIR(mb_type, i, list)){
- pred_16x8_motion(h, 8*i, list, h->ref_cache[list][scan8[0] + 16*i], &mx, &my);
- mx += get_se_golomb(&s->gb);
- my += get_se_golomb(&s->gb);
- tprintf(s->avctx, "final mv:%d %d\n", mx, my);
-
- val= pack16to32(mx,my);
- }else
- val=0;
- fill_rectangle(h->mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, val, 4);
- }
- }
- }else{
- av_assert2(IS_8X16(mb_type));
- for(list=0; list<h->list_count; list++){
- for(i=0; i<2; i++){
- unsigned int val;
- if(IS_DIR(mb_type, i, list)){ //FIXME optimize
- if(local_ref_count[list]==1){
- val= 0;
- }else if(local_ref_count[list]==2){
- val= get_bits1(&s->gb)^1;
- }else{
- val= get_ue_golomb_31(&s->gb);
- if(val >= local_ref_count[list]){
- av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", val);
- return -1;
- }
- }
- }else
- val= LIST_NOT_USED&0xFF;
- fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, val, 1);
- }
- }
- for(list=0; list<h->list_count; list++){
- for(i=0; i<2; i++){
- unsigned int val;
- if(IS_DIR(mb_type, i, list)){
- pred_8x16_motion(h, i*4, list, h->ref_cache[list][ scan8[0] + 2*i ], &mx, &my);
- mx += get_se_golomb(&s->gb);
- my += get_se_golomb(&s->gb);
- tprintf(s->avctx, "final mv:%d %d\n", mx, my);
-
- val= pack16to32(mx,my);
- }else
- val=0;
- fill_rectangle(h->mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, val, 4);
- }
- }
- }
- }
-
- if(IS_INTER(mb_type))
- write_back_motion(h, mb_type);
-
- if(!IS_INTRA16x16(mb_type)){
- cbp= get_ue_golomb(&s->gb);
-
- if(decode_chroma){
- if(cbp > 47){
- av_log(h->s.avctx, AV_LOG_ERROR, "cbp too large (%u) at %d %d\n", cbp, s->mb_x, s->mb_y);
- return -1;
- }
- if(IS_INTRA4x4(mb_type)) cbp= golomb_to_intra4x4_cbp[cbp];
- else cbp= golomb_to_inter_cbp [cbp];
- }else{
- if(cbp > 15){
- av_log(h->s.avctx, AV_LOG_ERROR, "cbp too large (%u) at %d %d\n", cbp, s->mb_x, s->mb_y);
- return -1;
- }
- if(IS_INTRA4x4(mb_type)) cbp= golomb_to_intra4x4_cbp_gray[cbp];
- else cbp= golomb_to_inter_cbp_gray[cbp];
- }
- } else {
- if (!decode_chroma && cbp>15) {
- av_log(s->avctx, AV_LOG_ERROR, "gray chroma\n");
- return AVERROR_INVALIDDATA;
- }
- }
-
- if(dct8x8_allowed && (cbp&15) && !IS_INTRA(mb_type)){
- mb_type |= MB_TYPE_8x8DCT*get_bits1(&s->gb);
- }
- h->cbp=
- h->cbp_table[mb_xy]= cbp;
- s->current_picture.f.mb_type[mb_xy] = mb_type;
-
- if(cbp || IS_INTRA16x16(mb_type)){
- int i4x4, i8x8, chroma_idx;
- int dquant;
- int ret;
- GetBitContext *gb= IS_INTRA(mb_type) ? h->intra_gb_ptr : h->inter_gb_ptr;
- const uint8_t *scan, *scan8x8;
- const int max_qp = 51 + 6*(h->sps.bit_depth_luma-8);
-
- if(IS_INTERLACED(mb_type)){
- scan8x8= s->qscale ? h->field_scan8x8_cavlc : h->field_scan8x8_cavlc_q0;
- scan= s->qscale ? h->field_scan : h->field_scan_q0;
- }else{
- scan8x8= s->qscale ? h->zigzag_scan8x8_cavlc : h->zigzag_scan8x8_cavlc_q0;
- scan= s->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
- }
-
- dquant= get_se_golomb(&s->gb);
-
- s->qscale += dquant;
-
- if(((unsigned)s->qscale) > max_qp){
- if(s->qscale<0) s->qscale+= max_qp+1;
- else s->qscale-= max_qp+1;
- if(((unsigned)s->qscale) > max_qp){
- av_log(h->s.avctx, AV_LOG_ERROR, "dquant out of range (%d) at %d %d\n", dquant, s->mb_x, s->mb_y);
- return -1;
- }
- }
-
- h->chroma_qp[0]= get_chroma_qp(h, 0, s->qscale);
- h->chroma_qp[1]= get_chroma_qp(h, 1, s->qscale);
-
- if( (ret = decode_luma_residual(h, gb, scan, scan8x8, pixel_shift, mb_type, cbp, 0)) < 0 ){
- return -1;
- }
- h->cbp_table[mb_xy] |= ret << 12;
- if(CHROMA444){
- if( decode_luma_residual(h, gb, scan, scan8x8, pixel_shift, mb_type, cbp, 1) < 0 ){
- return -1;
- }
- if( decode_luma_residual(h, gb, scan, scan8x8, pixel_shift, mb_type, cbp, 2) < 0 ){
- return -1;
- }
- } else {
- const int num_c8x8 = h->sps.chroma_format_idc;
-
- if(cbp&0x30){
- for(chroma_idx=0; chroma_idx<2; chroma_idx++)
- if (decode_residual(h, gb, h->mb + ((256 + 16*16*chroma_idx) << pixel_shift),
- CHROMA_DC_BLOCK_INDEX+chroma_idx,
- CHROMA422 ? chroma422_dc_scan : chroma_dc_scan,
- NULL, 4*num_c8x8) < 0) {
- return -1;
- }
- }
-
- if(cbp&0x20){
- for(chroma_idx=0; chroma_idx<2; chroma_idx++){
- const uint32_t *qmul = h->dequant4_coeff[chroma_idx+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[chroma_idx]];
- int16_t *mb = h->mb + (16*(16 + 16*chroma_idx) << pixel_shift);
- for (i8x8=0; i8x8<num_c8x8; i8x8++) {
- for (i4x4=0; i4x4<4; i4x4++) {
- const int index= 16 + 16*chroma_idx + 8*i8x8 + i4x4;
- if (decode_residual(h, gb, mb, index, scan + 1, qmul, 15) < 0)
- return -1;
- mb += 16<<pixel_shift;
- }
- }
- }
- }else{
- fill_rectangle(&h->non_zero_count_cache[scan8[16]], 4, 4, 8, 0, 1);
- fill_rectangle(&h->non_zero_count_cache[scan8[32]], 4, 4, 8, 0, 1);
- }
- }
- }else{
- fill_rectangle(&h->non_zero_count_cache[scan8[ 0]], 4, 4, 8, 0, 1);
- fill_rectangle(&h->non_zero_count_cache[scan8[16]], 4, 4, 8, 0, 1);
- fill_rectangle(&h->non_zero_count_cache[scan8[32]], 4, 4, 8, 0, 1);
- }
- s->current_picture.f.qscale_table[mb_xy] = s->qscale;
- write_back_non_zero_count(h);
-
- return 0;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264_direct.c b/src/thirdparty/ffmpeg/libavcodec/h264_direct.c
deleted file mode 100644
index 9f2104008..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264_direct.c
+++ /dev/null
@@ -1,634 +0,0 @@
-/*
- * H.26L/H.264/AVC/JVT/14496-10/... direct mb/block decoding
- * 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 direct mb/block decoding.
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#include "internal.h"
-#include "dsputil.h"
-#include "avcodec.h"
-#include "mpegvideo.h"
-#include "h264.h"
-#include "rectangle.h"
-#include "thread.h"
-
-//#undef NDEBUG
-#include <assert.h>
-
-
-static int get_scale_factor(H264Context * const h, int poc, int poc1, int i){
- int poc0 = h->ref_list[0][i].poc;
- int td = av_clip(poc1 - poc0, -128, 127);
- if(td == 0 || h->ref_list[0][i].long_ref){
- return 256;
- }else{
- int tb = av_clip(poc - poc0, -128, 127);
- int tx = (16384 + (FFABS(td) >> 1)) / td;
- return av_clip((tb*tx + 32) >> 6, -1024, 1023);
- }
-}
-
-void ff_h264_direct_dist_scale_factor(H264Context * const h){
- MpegEncContext * const s = &h->s;
- const int poc = h->s.current_picture_ptr->field_poc[ s->picture_structure == PICT_BOTTOM_FIELD ];
- const int poc1 = h->ref_list[1][0].poc;
- int i, field;
-
- if (FRAME_MBAFF)
- for (field = 0; field < 2; field++){
- const int poc = h->s.current_picture_ptr->field_poc[field];
- const int poc1 = h->ref_list[1][0].field_poc[field];
- for (i = 0; i < 2 * h->ref_count[0]; i++)
- h->dist_scale_factor_field[field][i^field] =
- get_scale_factor(h, poc, poc1, i+16);
- }
-
- for (i = 0; i < h->ref_count[0]; i++){
- h->dist_scale_factor[i] = get_scale_factor(h, poc, poc1, i);
- }
-}
-
-static void fill_colmap(H264Context *h, int map[2][16+32], int list, int field, int colfield, int mbafi){
- MpegEncContext * const s = &h->s;
- Picture * 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];
- int interl= mbafi || s->picture_structure != PICT_FRAME;
-
- /* bogus; fills in for missing frames */
- memset(map[list], 0, sizeof(map[list]));
-
- for(rfield=0; rfield<2; rfield++){
- for(old_ref=0; old_ref<ref1->ref_count[colfield][list]; old_ref++){
- int poc = ref1->ref_poc[colfield][list][old_ref];
-
- if (!interl)
- poc |= 3;
- else if( interl && (poc&3) == 3) // FIXME: store all MBAFF references so this is not needed
- poc= (poc&~3) + rfield + 1;
-
- for(j=start; j<end; j++){
- if (4 * h->ref_list[0][j].frame_num + (h->ref_list[0][j].f.reference & 3) == poc) {
- int cur_ref= mbafi ? (j-16)^field : j;
- if (ref1->mbaff)
- map[list][2 * old_ref + (rfield^field) + 16] = cur_ref;
- if(rfield == field || !interl)
- map[list][old_ref] = cur_ref;
- break;
- }
- }
- }
- }
-}
-
-void ff_h264_direct_ref_list_init(H264Context * const h){
- MpegEncContext * const s = &h->s;
- Picture * const ref1 = &h->ref_list[1][0];
- Picture * const cur = s->current_picture_ptr;
- int list, j, field;
- int sidx= (s->picture_structure&1)^1;
- int ref1sidx = (ref1->f.reference&1)^1;
-
- for(list=0; list<2; list++){
- cur->ref_count[sidx][list] = h->ref_count[list];
- for(j=0; j<h->ref_count[list]; j++)
- cur->ref_poc[sidx][list][j] = 4 * h->ref_list[list][j].frame_num + (h->ref_list[list][j].f.reference & 3);
- }
-
- if(s->picture_structure == PICT_FRAME){
- memcpy(cur->ref_count[1], cur->ref_count[0], sizeof(cur->ref_count[0]));
- memcpy(cur->ref_poc [1], cur->ref_poc [0], sizeof(cur->ref_poc [0]));
- }
-
- cur->mbaff= FRAME_MBAFF;
-
- h->col_fieldoff= 0;
- if(s->picture_structure == PICT_FRAME){
- int cur_poc = s->current_picture_ptr->poc;
- int *col_poc = h->ref_list[1]->field_poc;
- h->col_parity= (FFABS(col_poc[0] - cur_poc) >= FFABS(col_poc[1] - cur_poc));
- ref1sidx=sidx= h->col_parity;
- } else if (!(s->picture_structure & h->ref_list[1][0].f.reference) && !h->ref_list[1][0].mbaff) { // FL -> FL & differ parity
- h->col_fieldoff = 2 * h->ref_list[1][0].f.reference - 3;
- }
-
- if (h->slice_type_nos != AV_PICTURE_TYPE_B || h->direct_spatial_mv_pred)
- return;
-
- for(list=0; list<2; list++){
- fill_colmap(h, h->map_col_to_list0, list, sidx, ref1sidx, 0);
- if(FRAME_MBAFF)
- for(field=0; field<2; field++)
- fill_colmap(h, h->map_col_to_list0_field[field], list, field, field, 1);
- }
-}
-
-static void await_reference_mb_row(H264Context * const h, Picture *ref, int mb_y)
-{
- int ref_field = ref->f.reference - 1;
- int ref_field_picture = ref->field_picture;
- int ref_height = 16*h->s.mb_height >> ref_field_picture;
-
- if(!HAVE_THREADS || !(h->s.avctx->active_thread_type&FF_THREAD_FRAME))
- return;
-
- //FIXME it can be safe to access mb stuff
- //even if pixels aren't deblocked yet
-
- ff_thread_await_progress(&ref->f,
- FFMIN(16 * mb_y >> ref_field_picture, ref_height - 1),
- ref_field_picture && ref_field);
-}
-
-static void pred_spatial_direct_motion(H264Context * const h, int *mb_type){
- MpegEncContext * const s = &h->s;
- int b8_stride = 2;
- int b4_stride = h->b_stride;
- int mb_xy = h->mb_xy, mb_y = s->mb_y;
- int mb_type_col[2];
- const int16_t (*l1mv0)[2], (*l1mv1)[2];
- const int8_t *l1ref0, *l1ref1;
- const int is_b8x8 = IS_8X8(*mb_type);
- unsigned int sub_mb_type= MB_TYPE_L0L1;
- int i8, i4;
- int ref[2];
- int mv[2];
- int list;
-
- assert(h->ref_list[1][0].f.reference & 3);
-
- await_reference_mb_row(h, &h->ref_list[1][0], s->mb_y + !!IS_INTERLACED(*mb_type));
-
-#define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16|MB_TYPE_INTRA4x4|MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM)
-
-
- /* ref = min(neighbors) */
- for(list=0; list<2; list++){
- int left_ref = h->ref_cache[list][scan8[0] - 1];
- int top_ref = h->ref_cache[list][scan8[0] - 8];
- int refc = h->ref_cache[list][scan8[0] - 8 + 4];
- const int16_t *C= h->mv_cache[list][ scan8[0] - 8 + 4];
- if(refc == PART_NOT_AVAILABLE){
- refc = h->ref_cache[list][scan8[0] - 8 - 1];
- C = h-> mv_cache[list][scan8[0] - 8 - 1];
- }
- ref[list] = FFMIN3((unsigned)left_ref, (unsigned)top_ref, (unsigned)refc);
- if(ref[list] >= 0){
- //this is just pred_motion() but with the cases removed that cannot happen for direct blocks
- const int16_t * const A= h->mv_cache[list][ scan8[0] - 1 ];
- const int16_t * const B= h->mv_cache[list][ scan8[0] - 8 ];
-
- int match_count= (left_ref==ref[list]) + (top_ref==ref[list]) + (refc==ref[list]);
- if(match_count > 1){ //most common
- mv[list]= pack16to32(mid_pred(A[0], B[0], C[0]),
- mid_pred(A[1], B[1], C[1]) );
- }else {
- assert(match_count==1);
- if(left_ref==ref[list]){
- mv[list]= AV_RN32A(A);
- }else if(top_ref==ref[list]){
- mv[list]= AV_RN32A(B);
- }else{
- mv[list]= AV_RN32A(C);
- }
- }
- }else{
- int mask= ~(MB_TYPE_L0 << (2*list));
- mv[list] = 0;
- ref[list] = -1;
- if(!is_b8x8)
- *mb_type &= mask;
- sub_mb_type &= mask;
- }
- }
- if(ref[0] < 0 && ref[1] < 0){
- ref[0] = ref[1] = 0;
- if(!is_b8x8)
- *mb_type |= MB_TYPE_L0L1;
- sub_mb_type |= MB_TYPE_L0L1;
- }
-
- if(!(is_b8x8|mv[0]|mv[1])){
- fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, (uint8_t)ref[0], 1);
- fill_rectangle(&h->ref_cache[1][scan8[0]], 4, 4, 8, (uint8_t)ref[1], 1);
- fill_rectangle(&h->mv_cache[0][scan8[0]], 4, 4, 8, 0, 4);
- fill_rectangle(&h->mv_cache[1][scan8[0]], 4, 4, 8, 0, 4);
- *mb_type= (*mb_type & ~(MB_TYPE_8x8|MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_P1L0|MB_TYPE_P1L1))|MB_TYPE_16x16|MB_TYPE_DIRECT2;
- return;
- }
-
- if (IS_INTERLACED(h->ref_list[1][0].f.mb_type[mb_xy])) { // AFL/AFR/FR/FL -> AFL/FL
- if (!IS_INTERLACED(*mb_type)) { // AFR/FR -> AFL/FL
- mb_y = (s->mb_y&~1) + h->col_parity;
- mb_xy= s->mb_x + ((s->mb_y&~1) + h->col_parity)*s->mb_stride;
- b8_stride = 0;
- }else{
- mb_y += h->col_fieldoff;
- mb_xy += s->mb_stride*h->col_fieldoff; // non zero for FL -> FL & differ parity
- }
- goto single_col;
- }else{ // AFL/AFR/FR/FL -> AFR/FR
- if(IS_INTERLACED(*mb_type)){ // AFL /FL -> AFR/FR
- mb_y = s->mb_y&~1;
- mb_xy= s->mb_x + (s->mb_y&~1)*s->mb_stride;
- mb_type_col[0] = h->ref_list[1][0].f.mb_type[mb_xy];
- mb_type_col[1] = h->ref_list[1][0].f.mb_type[mb_xy + s->mb_stride];
- b8_stride = 2+4*s->mb_stride;
- b4_stride *= 6;
- if (IS_INTERLACED(mb_type_col[0]) != IS_INTERLACED(mb_type_col[1])) {
- mb_type_col[0] &= ~MB_TYPE_INTERLACED;
- mb_type_col[1] &= ~MB_TYPE_INTERLACED;
- }
-
- sub_mb_type |= MB_TYPE_16x16|MB_TYPE_DIRECT2; /* B_SUB_8x8 */
- if( (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)
- && (mb_type_col[1] & MB_TYPE_16x16_OR_INTRA)
- && !is_b8x8){
- *mb_type |= MB_TYPE_16x8 |MB_TYPE_DIRECT2; /* B_16x8 */
- }else{
- *mb_type |= MB_TYPE_8x8;
- }
- }else{ // AFR/FR -> AFR/FR
-single_col:
- mb_type_col[0] =
- mb_type_col[1] = h->ref_list[1][0].f.mb_type[mb_xy];
-
- sub_mb_type |= MB_TYPE_16x16|MB_TYPE_DIRECT2; /* B_SUB_8x8 */
- if(!is_b8x8 && (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)){
- *mb_type |= MB_TYPE_16x16|MB_TYPE_DIRECT2; /* B_16x16 */
- }else if(!is_b8x8 && (mb_type_col[0] & (MB_TYPE_16x8|MB_TYPE_8x16))){
- *mb_type |= MB_TYPE_DIRECT2 | (mb_type_col[0] & (MB_TYPE_16x8|MB_TYPE_8x16));
- }else{
- if(!h->sps.direct_8x8_inference_flag){
- /* FIXME save sub mb types from previous frames (or derive from MVs)
- * so we know exactly what block size to use */
- sub_mb_type += (MB_TYPE_8x8-MB_TYPE_16x16); /* B_SUB_4x4 */
- }
- *mb_type |= MB_TYPE_8x8;
- }
- }
- }
-
- await_reference_mb_row(h, &h->ref_list[1][0], mb_y);
-
- l1mv0 = (void*)&h->ref_list[1][0].f.motion_val[0][h->mb2b_xy [mb_xy]];
- l1mv1 = (void*)&h->ref_list[1][0].f.motion_val[1][h->mb2b_xy [mb_xy]];
- l1ref0 = &h->ref_list[1][0].f.ref_index [0][4 * mb_xy];
- l1ref1 = &h->ref_list[1][0].f.ref_index [1][4 * mb_xy];
- if(!b8_stride){
- if(s->mb_y&1){
- l1ref0 += 2;
- l1ref1 += 2;
- l1mv0 += 2*b4_stride;
- l1mv1 += 2*b4_stride;
- }
- }
-
-
- if(IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col[0])){
- int n=0;
- for(i8=0; i8<4; i8++){
- int x8 = i8&1;
- int y8 = i8>>1;
- int xy8 = x8+y8*b8_stride;
- int xy4 = 3*x8+y8*b4_stride;
- int a,b;
-
- if(is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8]))
- continue;
- h->sub_mb_type[i8] = sub_mb_type;
-
- fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, (uint8_t)ref[0], 1);
- fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, (uint8_t)ref[1], 1);
- if(!IS_INTRA(mb_type_col[y8]) && !h->ref_list[1][0].long_ref
- && ( (l1ref0[xy8] == 0 && FFABS(l1mv0[xy4][0]) <= 1 && FFABS(l1mv0[xy4][1]) <= 1)
- || (l1ref0[xy8] < 0 && l1ref1[xy8] == 0 && FFABS(l1mv1[xy4][0]) <= 1 && FFABS(l1mv1[xy4][1]) <= 1))){
- a=b=0;
- if(ref[0] > 0)
- a= mv[0];
- if(ref[1] > 0)
- b= mv[1];
- n++;
- }else{
- a= mv[0];
- b= mv[1];
- }
- fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, a, 4);
- fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, b, 4);
- }
- if(!is_b8x8 && !(n&3))
- *mb_type= (*mb_type & ~(MB_TYPE_8x8|MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_P1L0|MB_TYPE_P1L1))|MB_TYPE_16x16|MB_TYPE_DIRECT2;
- }else if(IS_16X16(*mb_type)){
- int a,b;
-
- fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, (uint8_t)ref[0], 1);
- fill_rectangle(&h->ref_cache[1][scan8[0]], 4, 4, 8, (uint8_t)ref[1], 1);
- if(!IS_INTRA(mb_type_col[0]) && !h->ref_list[1][0].long_ref
- && ( (l1ref0[0] == 0 && FFABS(l1mv0[0][0]) <= 1 && FFABS(l1mv0[0][1]) <= 1)
- || (l1ref0[0] < 0 && l1ref1[0] == 0 && FFABS(l1mv1[0][0]) <= 1 && FFABS(l1mv1[0][1]) <= 1
- && h->x264_build>33U))){
- a=b=0;
- if(ref[0] > 0)
- a= mv[0];
- if(ref[1] > 0)
- b= mv[1];
- }else{
- a= mv[0];
- b= mv[1];
- }
- fill_rectangle(&h->mv_cache[0][scan8[0]], 4, 4, 8, a, 4);
- fill_rectangle(&h->mv_cache[1][scan8[0]], 4, 4, 8, b, 4);
- }else{
- int n=0;
- for(i8=0; i8<4; i8++){
- const int x8 = i8&1;
- const int y8 = i8>>1;
-
- if(is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8]))
- continue;
- h->sub_mb_type[i8] = sub_mb_type;
-
- fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, mv[0], 4);
- fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, mv[1], 4);
- fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, (uint8_t)ref[0], 1);
- fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, (uint8_t)ref[1], 1);
-
- assert(b8_stride==2);
- /* col_zero_flag */
- if(!IS_INTRA(mb_type_col[0]) && !h->ref_list[1][0].long_ref && ( l1ref0[i8] == 0
- || (l1ref0[i8] < 0 && l1ref1[i8] == 0
- && h->x264_build>33U))){
- const int16_t (*l1mv)[2]= l1ref0[i8] == 0 ? l1mv0 : l1mv1;
- if(IS_SUB_8X8(sub_mb_type)){
- const int16_t *mv_col = l1mv[x8*3 + y8*3*b4_stride];
- if(FFABS(mv_col[0]) <= 1 && FFABS(mv_col[1]) <= 1){
- if(ref[0] == 0)
- fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, 0, 4);
- if(ref[1] == 0)
- fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, 0, 4);
- n+=4;
- }
- }else{
- int m=0;
- for(i4=0; i4<4; i4++){
- const int16_t *mv_col = l1mv[x8*2 + (i4&1) + (y8*2 + (i4>>1))*b4_stride];
- if(FFABS(mv_col[0]) <= 1 && FFABS(mv_col[1]) <= 1){
- if(ref[0] == 0)
- AV_ZERO32(h->mv_cache[0][scan8[i8*4+i4]]);
- if(ref[1] == 0)
- AV_ZERO32(h->mv_cache[1][scan8[i8*4+i4]]);
- m++;
- }
- }
- if(!(m&3))
- h->sub_mb_type[i8]+= MB_TYPE_16x16 - MB_TYPE_8x8;
- n+=m;
- }
- }
- }
- if(!is_b8x8 && !(n&15))
- *mb_type= (*mb_type & ~(MB_TYPE_8x8|MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_P1L0|MB_TYPE_P1L1))|MB_TYPE_16x16|MB_TYPE_DIRECT2;
- }
-}
-
-static void pred_temp_direct_motion(H264Context * const h, int *mb_type){
- MpegEncContext * const s = &h->s;
- int b8_stride = 2;
- int b4_stride = h->b_stride;
- int mb_xy = h->mb_xy, mb_y = s->mb_y;
- int mb_type_col[2];
- const int16_t (*l1mv0)[2], (*l1mv1)[2];
- const int8_t *l1ref0, *l1ref1;
- const int is_b8x8 = IS_8X8(*mb_type);
- unsigned int sub_mb_type;
- int i8, i4;
-
- assert(h->ref_list[1][0].f.reference & 3);
-
- await_reference_mb_row(h, &h->ref_list[1][0], s->mb_y + !!IS_INTERLACED(*mb_type));
-
- if (IS_INTERLACED(h->ref_list[1][0].f.mb_type[mb_xy])) { // AFL/AFR/FR/FL -> AFL/FL
- if (!IS_INTERLACED(*mb_type)) { // AFR/FR -> AFL/FL
- mb_y = (s->mb_y&~1) + h->col_parity;
- mb_xy= s->mb_x + ((s->mb_y&~1) + h->col_parity)*s->mb_stride;
- b8_stride = 0;
- }else{
- mb_y += h->col_fieldoff;
- mb_xy += s->mb_stride*h->col_fieldoff; // non zero for FL -> FL & differ parity
- }
- goto single_col;
- }else{ // AFL/AFR/FR/FL -> AFR/FR
- if(IS_INTERLACED(*mb_type)){ // AFL /FL -> AFR/FR
- mb_y = s->mb_y&~1;
- mb_xy= s->mb_x + (s->mb_y&~1)*s->mb_stride;
- mb_type_col[0] = h->ref_list[1][0].f.mb_type[mb_xy];
- mb_type_col[1] = h->ref_list[1][0].f.mb_type[mb_xy + s->mb_stride];
- b8_stride = 2+4*s->mb_stride;
- b4_stride *= 6;
- if (IS_INTERLACED(mb_type_col[0]) != IS_INTERLACED(mb_type_col[1])) {
- mb_type_col[0] &= ~MB_TYPE_INTERLACED;
- mb_type_col[1] &= ~MB_TYPE_INTERLACED;
- }
-
- sub_mb_type = MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2; /* B_SUB_8x8 */
-
- if( (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)
- && (mb_type_col[1] & MB_TYPE_16x16_OR_INTRA)
- && !is_b8x8){
- *mb_type |= MB_TYPE_16x8 |MB_TYPE_L0L1|MB_TYPE_DIRECT2; /* B_16x8 */
- }else{
- *mb_type |= MB_TYPE_8x8|MB_TYPE_L0L1;
- }
- }else{ // AFR/FR -> AFR/FR
-single_col:
- mb_type_col[0] =
- mb_type_col[1] = h->ref_list[1][0].f.mb_type[mb_xy];
-
- sub_mb_type = MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2; /* B_SUB_8x8 */
- if(!is_b8x8 && (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)){
- *mb_type |= MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2; /* B_16x16 */
- }else if(!is_b8x8 && (mb_type_col[0] & (MB_TYPE_16x8|MB_TYPE_8x16))){
- *mb_type |= MB_TYPE_L0L1|MB_TYPE_DIRECT2 | (mb_type_col[0] & (MB_TYPE_16x8|MB_TYPE_8x16));
- }else{
- if(!h->sps.direct_8x8_inference_flag){
- /* FIXME save sub mb types from previous frames (or derive from MVs)
- * so we know exactly what block size to use */
- sub_mb_type = MB_TYPE_8x8|MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_DIRECT2; /* B_SUB_4x4 */
- }
- *mb_type |= MB_TYPE_8x8|MB_TYPE_L0L1;
- }
- }
- }
-
- await_reference_mb_row(h, &h->ref_list[1][0], mb_y);
-
- l1mv0 = (void*)&h->ref_list[1][0].f.motion_val[0][h->mb2b_xy [mb_xy]];
- l1mv1 = (void*)&h->ref_list[1][0].f.motion_val[1][h->mb2b_xy [mb_xy]];
- l1ref0 = &h->ref_list[1][0].f.ref_index [0][4 * mb_xy];
- l1ref1 = &h->ref_list[1][0].f.ref_index [1][4 * mb_xy];
- if(!b8_stride){
- if(s->mb_y&1){
- l1ref0 += 2;
- l1ref1 += 2;
- l1mv0 += 2*b4_stride;
- l1mv1 += 2*b4_stride;
- }
- }
-
- {
- const int *map_col_to_list0[2] = {h->map_col_to_list0[0], h->map_col_to_list0[1]};
- const int *dist_scale_factor = h->dist_scale_factor;
- int ref_offset;
-
- if(FRAME_MBAFF && IS_INTERLACED(*mb_type)){
- map_col_to_list0[0] = h->map_col_to_list0_field[s->mb_y&1][0];
- map_col_to_list0[1] = h->map_col_to_list0_field[s->mb_y&1][1];
- dist_scale_factor =h->dist_scale_factor_field[s->mb_y&1];
- }
- ref_offset = (h->ref_list[1][0].mbaff<<4) & (mb_type_col[0]>>3); //if(h->ref_list[1][0].mbaff && IS_INTERLACED(mb_type_col[0])) ref_offset=16 else 0
-
- if(IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col[0])){
- int y_shift = 2*!IS_INTERLACED(*mb_type);
- assert(h->sps.direct_8x8_inference_flag);
-
- for(i8=0; i8<4; i8++){
- const int x8 = i8&1;
- const int y8 = i8>>1;
- int ref0, scale;
- const int16_t (*l1mv)[2]= l1mv0;
-
- if(is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8]))
- continue;
- h->sub_mb_type[i8] = sub_mb_type;
-
- fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, 0, 1);
- if(IS_INTRA(mb_type_col[y8])){
- fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, 0, 1);
- fill_rectangle(&h-> mv_cache[0][scan8[i8*4]], 2, 2, 8, 0, 4);
- fill_rectangle(&h-> mv_cache[1][scan8[i8*4]], 2, 2, 8, 0, 4);
- continue;
- }
-
- ref0 = l1ref0[x8 + y8*b8_stride];
- if(ref0 >= 0)
- ref0 = map_col_to_list0[0][ref0 + ref_offset];
- else{
- ref0 = map_col_to_list0[1][l1ref1[x8 + y8*b8_stride] + ref_offset];
- l1mv= l1mv1;
- }
- scale = dist_scale_factor[ref0];
- fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, ref0, 1);
-
- {
- const int16_t *mv_col = l1mv[x8*3 + y8*b4_stride];
- int my_col = (mv_col[1]<<y_shift)/2;
- int mx = (scale * mv_col[0] + 128) >> 8;
- int my = (scale * my_col + 128) >> 8;
- fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, pack16to32(mx,my), 4);
- fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, pack16to32(mx-mv_col[0],my-my_col), 4);
- }
- }
- return;
- }
-
- /* one-to-one mv scaling */
-
- if(IS_16X16(*mb_type)){
- int ref, mv0, mv1;
-
- fill_rectangle(&h->ref_cache[1][scan8[0]], 4, 4, 8, 0, 1);
- if(IS_INTRA(mb_type_col[0])){
- ref=mv0=mv1=0;
- }else{
- const int ref0 = l1ref0[0] >= 0 ? map_col_to_list0[0][l1ref0[0] + ref_offset]
- : map_col_to_list0[1][l1ref1[0] + ref_offset];
- const int scale = dist_scale_factor[ref0];
- const int16_t *mv_col = l1ref0[0] >= 0 ? l1mv0[0] : l1mv1[0];
- int mv_l0[2];
- mv_l0[0] = (scale * mv_col[0] + 128) >> 8;
- mv_l0[1] = (scale * mv_col[1] + 128) >> 8;
- ref= ref0;
- mv0= pack16to32(mv_l0[0],mv_l0[1]);
- mv1= pack16to32(mv_l0[0]-mv_col[0],mv_l0[1]-mv_col[1]);
- }
- fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1);
- fill_rectangle(&h-> mv_cache[0][scan8[0]], 4, 4, 8, mv0, 4);
- fill_rectangle(&h-> mv_cache[1][scan8[0]], 4, 4, 8, mv1, 4);
- }else{
- for(i8=0; i8<4; i8++){
- const int x8 = i8&1;
- const int y8 = i8>>1;
- int ref0, scale;
- const int16_t (*l1mv)[2]= l1mv0;
-
- if(is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8]))
- continue;
- h->sub_mb_type[i8] = sub_mb_type;
- fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, 0, 1);
- if(IS_INTRA(mb_type_col[0])){
- fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, 0, 1);
- fill_rectangle(&h-> mv_cache[0][scan8[i8*4]], 2, 2, 8, 0, 4);
- fill_rectangle(&h-> mv_cache[1][scan8[i8*4]], 2, 2, 8, 0, 4);
- continue;
- }
-
- assert(b8_stride == 2);
- ref0 = l1ref0[i8];
- if(ref0 >= 0)
- ref0 = map_col_to_list0[0][ref0 + ref_offset];
- else{
- ref0 = map_col_to_list0[1][l1ref1[i8] + ref_offset];
- l1mv= l1mv1;
- }
- scale = dist_scale_factor[ref0];
-
- fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, ref0, 1);
- if(IS_SUB_8X8(sub_mb_type)){
- const int16_t *mv_col = l1mv[x8*3 + y8*3*b4_stride];
- int mx = (scale * mv_col[0] + 128) >> 8;
- int my = (scale * mv_col[1] + 128) >> 8;
- fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, pack16to32(mx,my), 4);
- fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, pack16to32(mx-mv_col[0],my-mv_col[1]), 4);
- }else
- for(i4=0; i4<4; i4++){
- const int16_t *mv_col = l1mv[x8*2 + (i4&1) + (y8*2 + (i4>>1))*b4_stride];
- int16_t *mv_l0 = h->mv_cache[0][scan8[i8*4+i4]];
- mv_l0[0] = (scale * mv_col[0] + 128) >> 8;
- mv_l0[1] = (scale * mv_col[1] + 128) >> 8;
- AV_WN32A(h->mv_cache[1][scan8[i8*4+i4]],
- pack16to32(mv_l0[0]-mv_col[0],mv_l0[1]-mv_col[1]));
- }
- }
- }
- }
-}
-
-void ff_h264_pred_direct_motion(H264Context * const h, int *mb_type){
- if(h->direct_spatial_mv_pred){
- pred_spatial_direct_motion(h, mb_type);
- }else{
- pred_temp_direct_motion(h, mb_type);
- }
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264_dxva.c b/src/thirdparty/ffmpeg/libavcodec/h264_dxva.c
deleted file mode 100644
index f04bba457..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264_dxva.c
+++ /dev/null
@@ -1,1288 +0,0 @@
-/*
- * (C) 2008-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <Windows.h>
-#include "libavcodec/dxva.h"
-
-
-static void fill_dxva_slice_long(H264Context *h)
-{
- MpegEncContext* const s = &h->s;
- DXVA_Slice_H264_Long* pSlice = &((DXVA_Slice_H264_Long*) h->dxva_slice_long)[h->current_slice - 1];
- unsigned i, list;
-
- memset(pSlice, 0, sizeof(DXVA_Slice_H264_Long));
-
- pSlice->slice_id = h->current_slice - 1;
- pSlice->first_mb_in_slice = h->first_mb_in_slice;
- pSlice->NumMbsForSlice = 0; // h->s.mb_num; // TODO : to be checked !
- pSlice->BitOffsetToSliceData = h->bit_offset_to_slice_data;
- pSlice->slice_type = h->raw_slice_type;
- pSlice->luma_log2_weight_denom = h->luma_log2_weight_denom;
- pSlice->chroma_log2_weight_denom = h->chroma_log2_weight_denom;
- pSlice->slice_alpha_c0_offset_div2 = h->slice_alpha_c0_offset / 2;
- pSlice->slice_beta_offset_div2 = h->slice_beta_offset / 2;
- pSlice->Reserved8Bits = 0;
-
- pSlice->num_ref_idx_l0_active_minus1 = 0;
- pSlice->num_ref_idx_l1_active_minus1 = 0;
- if (h->list_count > 0) {
- pSlice->num_ref_idx_l0_active_minus1 = h->ref_count[0] - 1;
- }
- if (h->list_count > 1) {
- pSlice->num_ref_idx_l1_active_minus1 = h->ref_count[1] - 1;
- }
-
- // Fill prediction weights
- memset (pSlice->Weights, 0, sizeof(pSlice->Weights));
- for (list = 0; list < 2; list++) {
- for (i = 0; i < 32; i++) {
- if (list < h->list_count && i < h->ref_count[list]) {
- const Picture *r = &h->ref_list[list][i];
- unsigned plane;
- for (plane = 0; plane < 3; plane++) {
- int w, o;
- if (plane == 0 && h->luma_weight_flag[list]) {
- w = h->luma_weight[i][list][0];
- o = h->luma_weight[i][list][1];
- } else if (plane >= 1 && h->chroma_weight_flag[list]) {
- w = h->chroma_weight[i][list][plane - 1][0];
- o = h->chroma_weight[i][list][plane - 1][1];
- } else {
- w = 1 << (plane == 0 ? h->luma_log2_weight_denom :
- h->chroma_log2_weight_denom);
- o = 0;
- }
- pSlice->Weights[list][i][plane][0] = w;
- pSlice->Weights[list][i][plane][1] = o;
- }
- } else {
- unsigned plane;
- for (plane = 0; plane < 3; plane++) {
- pSlice->Weights[list][i][plane][0] = 0;
- pSlice->Weights[list][i][plane][1] = 0;
- }
- }
- }
- }
-
- pSlice->slice_qs_delta = h->slice_qs_delta;
- pSlice->slice_qp_delta = h->slice_qp_delta;
- pSlice->redundant_pic_cnt = h->redundant_pic_count;
- pSlice->direct_spatial_mv_pred_flag = h->direct_spatial_mv_pred;
- pSlice->cabac_init_idc = h->cabac_init_idc;
- pSlice->disable_deblocking_filter_idc = h->deblocking_filter;
-
- for (i = 0; i < 32; i++) {
- pSlice->RefPicList[0][i].AssociatedFlag = 1;
- pSlice->RefPicList[0][i].bPicEntry = 255;
- pSlice->RefPicList[0][i].Index7Bits = 127;
- pSlice->RefPicList[1][i].AssociatedFlag = 1;
- pSlice->RefPicList[1][i].bPicEntry = 255;
- pSlice->RefPicList[1][i].Index7Bits = 127;
- }
-}
-
-static void decode_postinit_dxva(H264Context *h, int* nOutPOC, int64_t* rtStartTime)
-{
- MpegEncContext *const s = &h->s;
- Picture *out = s->current_picture_ptr;
- Picture *cur = s->current_picture_ptr;
- int i, pics, out_of_order, out_idx;
-
- s->current_picture_ptr->f.qscale_type = FF_QSCALE_TYPE_H264;
- s->current_picture_ptr->f.pict_type = s->pict_type;
-
- if (h->next_output_pic)
- return;
-
- if (cur->field_poc[0] == INT_MAX || cur->field_poc[1] == INT_MAX) {
- /* FIXME: if we have two PAFF fields in one packet, we can't start
- * the next thread here. If we have one field per packet, we can.
- * The check in decode_nal_units() is not good enough to find this
- * yet, so we assume the worst for now. */
- // if (setup_finished)
- // ff_thread_finish_setup(s->avctx);
- return;
- }
-
- cur->f.interlaced_frame = 0;
- cur->f.repeat_pict = 0;
-
- /* Signal interlacing information externally. */
- /* Prioritize picture timing SEI information over used
- * decoding process if it exists. */
-
- if (h->sps.pic_struct_present_flag) {
- switch (h->sei_pic_struct) {
- case SEI_PIC_STRUCT_FRAME:
- break;
- case SEI_PIC_STRUCT_TOP_FIELD:
- case SEI_PIC_STRUCT_BOTTOM_FIELD:
- cur->f.interlaced_frame = 1;
- break;
- case SEI_PIC_STRUCT_TOP_BOTTOM:
- case SEI_PIC_STRUCT_BOTTOM_TOP:
- if (FIELD_OR_MBAFF_PICTURE)
- cur->f.interlaced_frame = 1;
- else
- // try to flag soft telecine progressive
- cur->f.interlaced_frame = h->prev_interlaced_frame;
- break;
- case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
- case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:
- /* Signal the possibility of telecined film externally
- * (pic_struct 5,6). From these hints, let the applications
- * decide if they apply deinterlacing. */
- cur->f.repeat_pict = 1;
- break;
- case SEI_PIC_STRUCT_FRAME_DOUBLING:
- // Force progressive here, doubling interlaced frame is a bad idea.
- cur->f.repeat_pict = 2;
- break;
- case SEI_PIC_STRUCT_FRAME_TRIPLING:
- cur->f.repeat_pict = 4;
- break;
- }
-
- if ((h->sei_ct_type & 3) &&
- h->sei_pic_struct <= SEI_PIC_STRUCT_BOTTOM_TOP)
- cur->f.interlaced_frame = (h->sei_ct_type & (1 << 1)) != 0;
- } else {
- /* Derive interlacing flag from used decoding process. */
- cur->f.interlaced_frame = FIELD_OR_MBAFF_PICTURE;
- }
- h->prev_interlaced_frame = cur->f.interlaced_frame;
-
- if (cur->field_poc[0] != cur->field_poc[1]) {
- /* Derive top_field_first from field pocs. */
- cur->f.top_field_first = cur->field_poc[0] < cur->field_poc[1];
- } else {
- if (cur->f.interlaced_frame || h->sps.pic_struct_present_flag) {
- /* Use picture timing SEI information. Even if it is a
- * information of a past frame, better than nothing. */
- if (h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM ||
- h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP)
- cur->f.top_field_first = 1;
- else
- cur->f.top_field_first = 0;
- } else {
- /* Most likely progressive */
- cur->f.top_field_first = 0;
- }
- }
-
- cur->mmco_reset = h->mmco_reset;
- h->mmco_reset = 0;
- // FIXME do something with unavailable reference frames
-
- /* Sort B-frames into display order */
-
- if (h->sps.bitstream_restriction_flag &&
- s->avctx->has_b_frames < h->sps.num_reorder_frames) {
- s->avctx->has_b_frames = h->sps.num_reorder_frames;
- s->low_delay = 0;
- }
-
- if (s->avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT &&
- !h->sps.bitstream_restriction_flag) {
- s->avctx->has_b_frames = MAX_DELAYED_PIC_COUNT - 1;
- s->low_delay = 0;
- }
-
- for (i = 0; 1; i++) {
- if (i == MAX_DELAYED_PIC_COUNT || cur->poc < h->last_pocs[i]) {
- if (i)
- h->last_pocs[i - 1] = cur->poc;
- break;
- } else if (i) {
- h->last_pocs[i - 1] = h->last_pocs[i];
- }
- }
- out_of_order = MAX_DELAYED_PIC_COUNT - i;
- if ( cur->f.pict_type == AV_PICTURE_TYPE_B
- || (h->last_pocs[MAX_DELAYED_PIC_COUNT - 2] > INT_MIN && h->last_pocs[MAX_DELAYED_PIC_COUNT - 1] - h->last_pocs[MAX_DELAYED_PIC_COUNT - 2] > 2))
- out_of_order = FFMAX(out_of_order, 1);
- if (s->avctx->has_b_frames < out_of_order && !h->sps.bitstream_restriction_flag) {
- av_log(s->avctx, AV_LOG_WARNING, "Increasing reorder buffer to %d\n", out_of_order);
- s->avctx->has_b_frames = out_of_order;
- s->low_delay = 0;
- }
-
- pics = 0;
- while (h->delayed_pic[pics])
- pics++;
-
- av_assert0(pics <= MAX_DELAYED_PIC_COUNT);
-
- h->delayed_pic[pics++] = cur;
- if (cur->f.reference == 0)
- cur->f.reference = DELAYED_PIC_REF;
-
- out = h->delayed_pic[0];
- out_idx = 0;
- for (i = 1; h->delayed_pic[i] &&
- !h->delayed_pic[i]->f.key_frame &&
- !h->delayed_pic[i]->mmco_reset;
- i++)
- if (h->delayed_pic[i]->poc < out->poc) {
- out = h->delayed_pic[i];
- out_idx = i;
- }
- if (s->avctx->has_b_frames == 0 &&
- (h->delayed_pic[0]->f.key_frame || h->delayed_pic[0]->mmco_reset))
- h->next_outputed_poc = INT_MIN;
- out_of_order = out->poc < h->next_outputed_poc;
-
- if (out_of_order || pics > s->avctx->has_b_frames) {
- out->f.reference &= ~DELAYED_PIC_REF;
- // for frame threading, the owner must be the second field's thread or
- // else the first thread can release the picture and reuse it unsafely
- out->owner2 = s;
- for (i = out_idx; h->delayed_pic[i]; i++)
- h->delayed_pic[i] = h->delayed_pic[i + 1];
- }
- if (!out_of_order && pics > s->avctx->has_b_frames) {
- h->next_output_pic = out;
- if (out_idx == 0 && h->delayed_pic[0] && (h->delayed_pic[0]->f.key_frame || h->delayed_pic[0]->mmco_reset)) {
- h->next_outputed_poc = INT_MIN;
- } else
- h->next_outputed_poc = out->poc;
- // ==> Start patch MPC DXVA
- if (nOutPOC) *nOutPOC = h->next_outputed_poc;
- if (rtStartTime) *rtStartTime = out->f.reordered_opaque;
- // <== End patch MPC DXVA
- } else {
- av_log(s->avctx, AV_LOG_DEBUG, "no picture %s\n", out_of_order ? "ooo" : "");
- }
-
- if (h->next_output_pic && h->next_output_pic->sync) {
- h->sync |= 2;
- }
-}
-
-static int field_end_noexecute(H264Context *h)
-{
- MpegEncContext *const s = &h->s;
- int err = 0;
- s->mb_y = 0;
-
- if (!s->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;
-
- ff_MPV_frame_end(s);
-
- h->current_slice = 0;
-
- return err;
-}
-
-int decode_slice_header_noexecute(H264Context *h, H264Context *h0)
-{
- MpegEncContext * const s = &h->s;
- MpegEncContext * const s0 = &h0->s;
- unsigned int pps_id;
- int num_ref_idx_active_override_flag;
- unsigned int slice_type, tmp, i, j;
- int default_ref_list_done = 0;
- int last_pic_structure, last_pic_dropable;
-
- s->me.qpel_put = h->h264qpel.put_h264_qpel_pixels_tab;
- s->me.qpel_avg = h->h264qpel.avg_h264_qpel_pixels_tab;
-
- // ==> Start patch MPC DXVA
- h->first_mb_in_slice = get_ue_golomb_long(&s->gb);
- // <== End patch MPC DXVA
-
- if (h->first_mb_in_slice == 0) { //FIXME better field boundary detection
- if (h0->current_slice && FIELD_PICTURE) {
- // ==> Start patch MPC DXVA
- field_end_noexecute(h);
- // <== End patch MPC DXVA
- }
-
- h0->current_slice = 0;
- if (!s0->first_field) {
- if (s->current_picture_ptr && !s->droppable &&
- s->current_picture_ptr->owner2 == s) {
- ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX,
- s->picture_structure == PICT_BOTTOM_FIELD);
- }
- s->current_picture_ptr = NULL;
- }
- }
-
- slice_type = get_ue_golomb_31(&s->gb);
- if (slice_type > 9) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "slice type too large (%d) at %d %d\n",
- h->slice_type, s->mb_x, s->mb_y);
- return -1;
- }
- if (slice_type > 4) {
- slice_type -= 5;
- h->slice_type_fixed = 1;
- } else
- h->slice_type_fixed = 0;
-
- // ==> Start patch MPC DXVA
- h->raw_slice_type = slice_type;
- // <== End patch MPC DXVA
- slice_type = golomb_to_pict_type[slice_type];
- if (slice_type == AV_PICTURE_TYPE_I ||
- (h0->current_slice != 0 && slice_type == h0->last_slice_type)) {
- default_ref_list_done = 1;
- }
- h->slice_type = slice_type;
- h->slice_type_nos = slice_type & 3;
-
- // to make a few old functions happy, it's wrong though
- s->pict_type = h->slice_type;
-
- pps_id = get_ue_golomb(&s->gb);
- if (pps_id >= MAX_PPS_COUNT) {
- av_log(h->s.avctx, AV_LOG_ERROR, "pps_id %d out of range\n", pps_id);
- return -1;
- }
- if (!h0->pps_buffers[pps_id]) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "non-existing PPS %u referenced\n",
- pps_id);
- return -1;
- }
- h->pps = *h0->pps_buffers[pps_id];
-
- if (!h0->sps_buffers[h->pps.sps_id]) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "non-existing SPS %u referenced\n",
- h->pps.sps_id);
- return -1;
- }
- h->sps = *h0->sps_buffers[h->pps.sps_id];
-
- s->avctx->profile = ff_h264_get_profile(&h->sps);
- s->avctx->level = h->sps.level_idc;
- s->avctx->refs = h->sps.ref_frame_count;
-
- s->mb_width = h->sps.mb_width;
- s->mb_height = h->sps.mb_height * (2 - h->sps.frame_mbs_only_flag);
-
- h->b_stride = s->mb_width * 4;
-
- s->chroma_y_shift = h->sps.chroma_format_idc <= 1; // 400 uses yuv420p
-
- s->width = 16 * s->mb_width;
- s->height = 16 * s->mb_height;
-
-
- if (s->context_initialized &&
- ( s->width != s->avctx->coded_width || s->height != s->avctx->coded_height
- || av_cmp_q(h->sps.sar, s->avctx->sample_aspect_ratio))) {
- if (h != h0) {
- av_log_missing_feature(s->avctx, "Width/height changing with threads is", 0);
- return -1; // width / height changed during parallelized decoding
- }
- free_tables(h, 0);
- flush_dpb(s->avctx);
- ff_MPV_common_end(s);
- h->list_count = 0;
- }
- if (!s->context_initialized) {
- if (h != h0) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "Cannot (re-)initialize context during parallel decoding.\n");
- return -1;
- }
- avcodec_set_dimensions(s->avctx, s->width, s->height);
- s->avctx->width -= (2 >> CHROMA444) * FFMIN(h->sps.crop_right, (8 << CHROMA444) - 1);
- s->avctx->height -= (1 << s->chroma_y_shift) * FFMIN(h->sps.crop_bottom, (16 >> s->chroma_y_shift) - 1) * (2 - h->sps.frame_mbs_only_flag);
-
-
- if (h->sps.video_signal_type_present_flag) {
- s->avctx->color_range = h->sps.full_range > 0 ? AVCOL_RANGE_JPEG
- : AVCOL_RANGE_MPEG;
- if (h->sps.colour_description_present_flag) {
- s->avctx->color_primaries = h->sps.color_primaries;
- s->avctx->color_trc = h->sps.color_trc;
- s->avctx->colorspace = h->sps.colorspace;
- }
- }
-
- if (h->sps.timing_info_present_flag) {
- int64_t den = h->sps.time_scale;
- if (h->x264_build < 44U)
- den *= 2;
- av_reduce(&s->avctx->time_base.num, &s->avctx->time_base.den,
- h->sps.num_units_in_tick, den, 1 << 30);
- }
-
- s->avctx->pix_fmt = PIX_FMT_YUV420P;
-
- if (ff_MPV_common_init(s) < 0) {
- av_log(h->s.avctx, AV_LOG_ERROR, "ff_MPV_common_init() failed.\n");
- return -1;
- }
- s->first_field = 0;
- h->prev_interlaced_frame = 1;
-
- init_scan_tables(h);
- if (ff_h264_alloc_tables(h) < 0) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "Could not allocate memory for h264\n");
- return AVERROR(ENOMEM);
- }
-
- if (!HAVE_THREADS || !(s->avctx->active_thread_type & FF_THREAD_SLICE)) {
- if (context_init(h) < 0) {
- av_log(h->s.avctx, AV_LOG_ERROR, "context_init() failed.\n");
- return -1;
- }
- } else {
- for (i = 1; i < s->slice_context_count; i++) {
- H264Context *c;
- c = h->thread_context[i] = av_malloc(sizeof(H264Context));
- memcpy(c, h->s.thread_context[i], sizeof(MpegEncContext));
- memset(&c->s + 1, 0, sizeof(H264Context) - sizeof(MpegEncContext));
- c->h264dsp = h->h264dsp;
- c->sps = h->sps;
- c->pps = h->pps;
- c->pixel_shift = h->pixel_shift;
- c->cur_chroma_format_idc = h->cur_chroma_format_idc;
- init_scan_tables(c);
- clone_tables(c, h, i);
- }
-
- for (i = 0; i < s->slice_context_count; i++)
- if (context_init(h->thread_context[i]) < 0) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "context_init() failed.\n");
- return -1;
- }
- }
- }
-
- s->avctx->sample_aspect_ratio = h->sps.sar;
- av_assert0(s->avctx->sample_aspect_ratio.den);
-
- if (h == h0 && h->dequant_coeff_pps != pps_id) {
- h->dequant_coeff_pps = pps_id;
- init_dequant_tables(h);
- }
-
- h->frame_num = get_bits(&s->gb, h->sps.log2_max_frame_num);
-
- h->mb_mbaff = 0;
- h->mb_aff_frame = 0;
- last_pic_structure = s0->picture_structure;
- last_pic_dropable = s->droppable;
- s->droppable = h->nal_ref_idc == 0;
- if (h->sps.frame_mbs_only_flag) {
- s->picture_structure = PICT_FRAME;
- } else {
- if (!h->sps.direct_8x8_inference_flag && slice_type == AV_PICTURE_TYPE_B) {
- av_log(h->s.avctx, AV_LOG_ERROR, "This stream was generated by a broken encoder, invalid 8x8 inference\n");
- return -1;
- }
- if (get_bits1(&s->gb)) { // field_pic_flag
- s->picture_structure = PICT_TOP_FIELD + get_bits1(&s->gb); // bottom_field_flag
- } else {
- s->picture_structure = PICT_FRAME;
- h->mb_aff_frame = h->sps.mb_aff;
- }
- }
- h->mb_field_decoding_flag = s->picture_structure != PICT_FRAME;
-
- if (h0->current_slice != 0) {
- if (last_pic_structure != s->picture_structure ||
- last_pic_dropable != s->droppable) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "Changing field mode (%d -> %d) between slices is not allowed\n",
- last_pic_structure, s->picture_structure);
- s->picture_structure = last_pic_structure;
- s->droppable = last_pic_dropable;
- 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 && h->prev_frame_num >= 0) {
- 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 s->current_picture_ptr. */
- if (s0->first_field) {
- assert(s0->current_picture_ptr);
- assert(s0->current_picture_ptr->f.data[0]);
- assert(s0->current_picture_ptr->f.reference != DELAYED_PIC_REF);
-
- /* Mark old field/frame as completed */
- if (!last_pic_dropable && s0->current_picture_ptr->owner2 == s0) {
- ff_thread_report_progress(&s0->current_picture_ptr->f, INT_MAX,
- last_pic_structure == PICT_BOTTOM_FIELD);
- }
-
- /* figure out if we have a complementary field pair */
- if (!FIELD_PICTURE || s->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_dropable && last_pic_structure != PICT_FRAME) {
- ff_thread_report_progress(&s0->current_picture_ptr->f, INT_MAX,
- last_pic_structure == PICT_TOP_FIELD);
- }
- } else {
- if (s0->current_picture_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_dropable && last_pic_structure != PICT_FRAME) {
- ff_thread_report_progress(&s0->current_picture_ptr->f, INT_MAX,
- last_pic_structure == PICT_TOP_FIELD);
- }
- } else {
- /* Second field in complementary pair */
- if (!((last_pic_structure == PICT_TOP_FIELD &&
- s->picture_structure == PICT_BOTTOM_FIELD) ||
- (last_pic_structure == PICT_BOTTOM_FIELD &&
- s->picture_structure == PICT_TOP_FIELD))) {
- av_log(s->avctx, AV_LOG_ERROR,
- "Invalid field mode combination %d/%d\n",
- last_pic_structure, s->picture_structure);
- s->picture_structure = last_pic_structure;
- s->droppable = last_pic_dropable;
- return AVERROR_INVALIDDATA;
- } else if (last_pic_dropable != s->droppable) {
- av_log(s->avctx, AV_LOG_ERROR,
- "Cannot combine reference and non-reference fields in the same frame\n");
- av_log_ask_for_sample(s->avctx, NULL);
- s->picture_structure = last_pic_structure;
- s->droppable = last_pic_dropable;
- return AVERROR_INVALIDDATA;
- }
-
- /* Take ownership of this buffer. Note that if another thread owned
- * the first field of this buffer, we're not operating on that pointer,
- * so the original thread is still responsible for reporting progress
- * on that first field (or if that was us, we just did that above).
- * By taking ownership, we assign responsibility to ourselves to
- * report progress on the second field. */
- s0->current_picture_ptr->owner2 = s0;
- }
- }
- }
-
- while (h->frame_num != h->prev_frame_num && h->prev_frame_num >= 0 &&
- 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->s.avctx, AV_LOG_DEBUG, "Frame num gap %d %d\n",
- h->frame_num, h->prev_frame_num);
- if (ff_h264_frame_start(h) < 0)
- return -1;
- h->prev_frame_num++;
- h->prev_frame_num %= 1 << h->sps.log2_max_frame_num;
- s->current_picture_ptr->frame_num = h->prev_frame_num;
- ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, 0);
- ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, 1);
- ff_generate_sliding_window_mmcos(h, 1);
- if (ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index) < 0 &&
- (s->avctx->err_recognition & AV_EF_EXPLODE))
- return AVERROR_INVALIDDATA;
- /* 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 doesn't copy padding for out-of-frame motion vectors. Given we're
- * concealing a lost frame, this probably isn't 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,
- s->avctx->pix_fmt, s->mb_width * 16, s->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 (s0->first_field) {
- assert(s0->current_picture_ptr);
- assert(s0->current_picture_ptr->f.data[0]);
- assert(s0->current_picture_ptr->f.reference != DELAYED_PIC_REF);
-
- /* figure out if we have a complementary field pair */
- if (!FIELD_PICTURE || s->picture_structure == last_pic_structure) {
- /* Previous field is unmatched. Don't display it, but let it
- * remain for reference if marked as such. */
- s0->current_picture_ptr = NULL;
- s0->first_field = FIELD_PICTURE;
- } else {
- if (s0->current_picture_ptr->frame_num != h->frame_num) {
- ff_thread_report_progress((AVFrame*)s0->current_picture_ptr, INT_MAX,
- s0->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. */
- s0->first_field = 1;
- s0->current_picture_ptr = NULL;
- } else {
- /* Second field in complementary pair */
- s0->first_field = 0;
- }
- }
- } else {
- /* Frame or first field in a potentially complementary pair */
- // ==> Start patch MPC
- // assert(!s0->current_picture_ptr);
- // ==> End patch MPC
- s0->first_field = FIELD_PICTURE;
- }
-
- if (!FIELD_PICTURE || s0->first_field) {
- if (ff_h264_frame_start(h) < 0) {
- s0->first_field = 0;
- return -1;
- }
- } else {
- ff_release_unused_pictures(s, 0);
- }
- }
- if (h != h0)
- clone_slice(h, h0);
-
- s->current_picture_ptr->frame_num = h->frame_num; // FIXME frame_num cleanup
-
- assert(s->mb_num == s->mb_width * s->mb_height);
- if (h->first_mb_in_slice << FIELD_OR_MBAFF_PICTURE >= s->mb_num ||
- h->first_mb_in_slice >= s->mb_num){
- av_log(h->s.avctx, AV_LOG_ERROR, "first_mb_in_slice overflow\n");
- return -1;
- }
- s->resync_mb_x = s->mb_x = h->first_mb_in_slice % s->mb_width;
- s->resync_mb_y = s->mb_y = (h->first_mb_in_slice / s->mb_width) << FIELD_OR_MBAFF_PICTURE;
- if (s->picture_structure == PICT_BOTTOM_FIELD)
- s->resync_mb_y = s->mb_y = s->mb_y + 1;
- assert(s->mb_y < s->mb_height);
-
- if (s->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(&s->gb); /* idr_pic_id */
-
- if (h->sps.poc_type == 0) {
- h->poc_lsb = get_bits(&s->gb, h->sps.log2_max_poc_lsb);
-
- if (h->pps.pic_order_present == 1 && s->picture_structure == PICT_FRAME)
- h->delta_poc_bottom = get_se_golomb(&s->gb);
- }
-
- if (h->sps.poc_type == 1 && !h->sps.delta_pic_order_always_zero_flag) {
- h->delta_poc[0] = get_se_golomb(&s->gb);
-
- if (h->pps.pic_order_present == 1 && s->picture_structure == PICT_FRAME)
- h->delta_poc[1] = get_se_golomb(&s->gb);
- }
-
- init_poc(h);
-
- if (h->pps.redundant_pic_cnt_present)
- h->redundant_pic_count = get_ue_golomb(&s->gb);
-
- // 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];
-
- if (h->slice_type_nos != AV_PICTURE_TYPE_I) {
- unsigned max = s->picture_structure == PICT_FRAME ? 15 : 31;
-
- if (h->slice_type_nos == AV_PICTURE_TYPE_B)
- h->direct_spatial_mv_pred = get_bits1(&s->gb);
- num_ref_idx_active_override_flag = get_bits1(&s->gb);
-
- if (num_ref_idx_active_override_flag) {
- h->ref_count[0] = get_ue_golomb(&s->gb) + 1;
- if (h->slice_type_nos == AV_PICTURE_TYPE_B)
- h->ref_count[1] = get_ue_golomb(&s->gb) + 1;
- }
-
- if (h->ref_count[0] - 1 > max || h->ref_count[1] - 1 > max) {
- av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow\n");
- h->ref_count[0] = h->ref_count[1] = 1;
- return AVERROR_INVALIDDATA;
- }
-
- if (h->slice_type_nos == AV_PICTURE_TYPE_B)
- h->list_count = 2;
- else
- h->list_count = 1;
- } else
- h->ref_count[1] = h->ref_count[0] = h->list_count = 0;
-
- if (!default_ref_list_done)
- ff_h264_fill_default_ref_list(h);
-
- if (h->slice_type_nos != AV_PICTURE_TYPE_I &&
- ff_h264_decode_ref_pic_list_reordering(h) < 0) {
- h->ref_count[1] = h->ref_count[0] = 0;
- return -1;
- }
-
- if (h->slice_type_nos != AV_PICTURE_TYPE_I) {
- s->last_picture_ptr = &h->ref_list[0][0];
- ff_copy_picture(&s->last_picture, s->last_picture_ptr);
- }
- if (h->slice_type_nos == AV_PICTURE_TYPE_B) {
- s->next_picture_ptr = &h->ref_list[1][0];
- ff_copy_picture(&s->next_picture, s->next_picture_ptr);
- }
-
- 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))
- 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 (h->nal_ref_idc &&
- ff_h264_decode_ref_pic_marking(h0, &s->gb,
- !(s->avctx->active_thread_type & FF_THREAD_FRAME) ||
- h0->current_slice == 0) < 0 &&
- (s->avctx->err_recognition & AV_EF_EXPLODE))
- return AVERROR_INVALIDDATA;
-
- if (FRAME_MBAFF) {
- 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(&s->gb);
- if (tmp > 2) {
- av_log(s->avctx, AV_LOG_ERROR, "cabac_init_idc overflow\n");
- return -1;
- }
- h->cabac_init_idc = tmp;
- }
-
- h->last_qscale_diff = 0;
- // ==> Start patch MPC
- h->slice_qp_delta = get_se_golomb(&s->gb);
- tmp = h->pps.init_qp + h->slice_qp_delta;
- // <== End patch MPC
- if (tmp > 51 + 6 * (h->sps.bit_depth_luma - 8)) {
- av_log(s->avctx, AV_LOG_ERROR, "QP %u out of range\n", tmp);
- return -1;
- }
- s->qscale = tmp;
- h->chroma_qp[0] = get_chroma_qp(h, 0, s->qscale);
- h->chroma_qp[1] = get_chroma_qp(h, 1, s->qscale);
- // FIXME qscale / qp ... stuff
- if (h->slice_type == AV_PICTURE_TYPE_SP)
- get_bits1(&s->gb); /* sp_for_switch_flag */
- if (h->slice_type == AV_PICTURE_TYPE_SP ||
- h->slice_type == AV_PICTURE_TYPE_SI)
- // ==> Start patch MPC
- h->slice_qs_delta = get_se_golomb(&s->gb); /* slice_qs_delta */
- // <== End patch MPC
-
- 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(&s->gb);
- if (tmp > 2) {
- av_log(s->avctx, AV_LOG_ERROR,
- "deblocking_filter_idc %u out of range\n", tmp);
- return -1;
- }
- 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(&s->gb) << 1;
- h->slice_beta_offset += get_se_golomb(&s->gb) << 1;
- if (h->slice_alpha_c0_offset > 104U ||
- h->slice_beta_offset > 104U) {
- av_log(s->avctx, AV_LOG_ERROR,
- "deblocking filter parameters %d %d out of range\n",
- h->slice_alpha_c0_offset, h->slice_beta_offset);
- return -1;
- }
- }
- }
-
- if (s->avctx->skip_loop_filter >= AVDISCARD_ALL ||
- (s->avctx->skip_loop_filter >= AVDISCARD_NONKEY &&
- h->slice_type_nos != AV_PICTURE_TYPE_I) ||
- (s->avctx->skip_loop_filter >= AVDISCARD_BIDIR &&
- h->slice_type_nos == AV_PICTURE_TYPE_B) ||
- (s->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 (s->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(s->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->s.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);
-
- // ==> Start patch MPC
- // If entropy_coding_mode, align to 8 bits
- if (h->pps.cabac) align_get_bits(&s->gb);
- h->bit_offset_to_slice_data = s->gb.index;
- // <== End patch MPC
-
- h0->last_slice_type = slice_type;
- h->slice_num = ++h0->current_slice;
-
- if (h->slice_num)
- h0->slice_row[(h->slice_num - 1) & (MAX_SLICES - 1)] = s->resync_mb_y;
- if ( h0->slice_row[h->slice_num & (MAX_SLICES - 1)] + 3 >= s->resync_mb_y
- && h0->slice_row[h->slice_num & (MAX_SLICES - 1)] <= s->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(s->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 (h->ref_list[j][i].f.data[0]) {
- int k;
- uint8_t *base = h->ref_list[j][i].f.base[0];
- for (k = 0; k < h->short_ref_count; k++)
- if (h->short_ref[k]->f.base[0] == base) {
- id_list[i] = k;
- break;
- }
- for (k = 0; k < h->long_ref_count; k++)
- if (h->long_ref[k] && h->long_ref[k]->f.base[0] == base) {
- 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].f.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].f.reference & 3);
- }
-
- // FIXME: fix draw_edges + PAFF + frame threads
- h->emu_edge_width = (s->flags & CODEC_FLAG_EMU_EDGE ||
- (!h->sps.frame_mbs_only_flag &&
- s->avctx->active_thread_type))
- ? 0 : 16;
- h->emu_edge_height = (FRAME_MBAFF || FIELD_PICTURE) ? 0 : h->emu_edge_width;
-
- // ==> Start patch MPC
- fill_dxva_slice_long(h);
- // ==> End patch MPC
-
- if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
- av_log(h->s.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,
- (s->picture_structure == PICT_FRAME ? "F" : s->picture_structure == PICT_TOP_FIELD ? "T" : "B"),
- h->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,
- s->current_picture_ptr->field_poc[0],
- s->current_picture_ptr->field_poc[1],
- h->ref_count[0], h->ref_count[1],
- s->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") : "");
- }
-
- return 0;
-}
-
-
-static int decode_nal_units_noexecute(H264Context *h, const uint8_t *buf, int buf_size)
-{
- MpegEncContext *const s = &h->s;
- AVCodecContext *const avctx = s->avctx;
- int buf_index = 0;
- H264Context *hx; ///< thread context
- int context_count = 0;
- int next_avc = h->is_avc ? 0 : buf_size;
-
- h->max_contexts = 1;
- if (!(s->flags2 & CODEC_FLAG2_CHUNKS)) {
- h->current_slice = 0;
- if (!s->first_field)
- s->current_picture_ptr = NULL;
- ff_h264_reset_sei(h);
- }
-
- for (;;) {
- int consumed;
- int dst_length;
- int bit_length;
- const uint8_t *ptr;
- int i, nalsize = 0;
- int err;
-
- if (buf_index >= next_avc) {
- if (buf_index >= buf_size - h->nal_length_size) 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->s.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) break;
-
- buf_index += 3;
- if (buf_index >= next_avc) continue;
- }
-
- hx = h->thread_context[context_count];
-
- ptr = ff_h264_decode_nal(hx, buf + buf_index, &dst_length, &consumed, next_avc - buf_index);
- if (ptr == NULL || dst_length < 0) {
- return -1;
- }
- i = buf_index + consumed;
- if ((s->workaround_bugs & FF_BUG_AUTODETECT) && i + 3 < next_avc &&
- buf[i] == 0x00 && buf[i + 1] == 0x00 && buf[i + 2] == 0x01 && buf[i + 3] == 0xE0)
- s->workaround_bugs |= FF_BUG_TRUNCATED;
-
- if (!(s->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));
-
- if (s->avctx->debug & FF_DEBUG_STARTCODE) {
- av_log(h->s.avctx, AV_LOG_DEBUG, "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->s.avctx, AV_LOG_DEBUG, "AVC: Consumed only %d bytes instead of %d\n", consumed, nalsize);
- }
-
- buf_index += consumed;
-
- //FIXME do not discard SEI id
- if (avctx->skip_frame >= AVDISCARD_NONREF && h->nal_ref_idc == 0)
- continue;
-
-again:
- err = 0;
- switch (hx->nal_unit_type) {
- case NAL_IDR_SLICE:
- if (h->nal_unit_type != NAL_IDR_SLICE) {
- av_log(h->s.avctx, AV_LOG_ERROR, "Invalid mix of idr and non-idr slices");
- return -1;
- }
- idr(h); //FIXME ensure we don't loose some frames if there is reordering
- case NAL_SLICE:
- init_get_bits(&hx->s.gb, ptr, bit_length);
- hx->intra_gb_ptr =
- hx->inter_gb_ptr = &hx->s.gb;
- hx->s.data_partitioning = 0;
-
- // ==> Start patch MPC DXVA
- hx->ref_pic_flag = (h->nal_ref_idc != 0);
- if ((err = decode_slice_header_noexecute(hx, h)))
- break;
- // <== End patch MPC DXVA
-
- s->current_picture_ptr->f.key_frame |=
- (hx->nal_unit_type == NAL_IDR_SLICE) ||
- (h->sei_recovery_frame_cnt >= 0);
- if (hx->redundant_pic_count == 0
- && (avctx->skip_frame < AVDISCARD_NONREF || hx->nal_ref_idc)
- && (avctx->skip_frame < AVDISCARD_BIDIR || hx->slice_type_nos != AV_PICTURE_TYPE_B)
- && (avctx->skip_frame < AVDISCARD_NONKEY || hx->slice_type_nos == AV_PICTURE_TYPE_I)
- && avctx->skip_frame < AVDISCARD_ALL) {
- context_count++;
- }
- break;
- case NAL_DPA:
- init_get_bits(&hx->s.gb, ptr, bit_length);
- hx->intra_gb_ptr =
- hx->inter_gb_ptr = NULL;
- // ==> Start patch MPC DXVA
- if ((err = decode_slice_header_noexecute(hx, h)) < 0)
- break;
- // <== End patch MPC DXVA
-
- hx->s.data_partitioning = 1;
-
- break;
- case NAL_DPB:
- init_get_bits(&hx->intra_gb, ptr, bit_length);
- hx->intra_gb_ptr = &hx->intra_gb;
- break;
- case NAL_DPC:
- init_get_bits(&hx->inter_gb, ptr, bit_length);
- hx->inter_gb_ptr = &hx->inter_gb;
-
- if (hx->redundant_pic_count == 0 && hx->intra_gb_ptr && hx->s.data_partitioning
- && s->context_initialized
- && (avctx->skip_frame < AVDISCARD_NONREF || hx->nal_ref_idc)
- && (avctx->skip_frame < AVDISCARD_BIDIR || hx->slice_type_nos != AV_PICTURE_TYPE_B)
- && (avctx->skip_frame < AVDISCARD_NONKEY || hx->slice_type_nos == AV_PICTURE_TYPE_I)
- && avctx->skip_frame < AVDISCARD_ALL)
- context_count++;
- break;
- case NAL_SEI:
- init_get_bits(&s->gb, ptr, bit_length);
- ff_h264_decode_sei(h);
- break;
- case NAL_SPS:
- init_get_bits(&s->gb, ptr, bit_length);
- if (ff_h264_decode_seq_parameter_set(h) < 0 &&
- h->is_avc && (nalsize != consumed) && nalsize) {
- av_log(h->s.avctx, AV_LOG_DEBUG, "SPS decoding failure, "
- "try parsing the coomplete NAL\n");
- init_get_bits(&s->gb, buf + buf_index + 1 - consumed,
- 8 * (nalsize - 1));
- ff_h264_decode_seq_parameter_set(h);
- }
-
- if (s->flags & CODEC_FLAG_LOW_DELAY ||
- (h->sps.bitstream_restriction_flag && !h->sps.num_reorder_frames))
- s->low_delay = 1;
-
- if (avctx->has_b_frames < 2)
- avctx->has_b_frames = !s->low_delay;
- break;
- case NAL_PPS:
- init_get_bits(&s->gb, ptr, bit_length);
-
- ff_h264_decode_picture_parameter_set(h, bit_length);
-
- break;
- case NAL_AUD:
- case NAL_END_SEQUENCE:
- case NAL_END_STREAM:
- case NAL_FILLER_DATA:
- case NAL_SPS_EXT:
- case NAL_AUXILIARY_SLICE:
- break;
- default:
- av_log(avctx, AV_LOG_DEBUG, "Unknown NAL code: %d (%d bits)\n", hx->nal_unit_type, bit_length);
- }
-
- if (context_count == h->max_contexts) {
- // ==> Start patch MPC DXVA
- // execute_decode_slices(h, context_count);
- // <== End patch MPC DXVA
- context_count = 0;
- }
-
- if (err < 0)
- av_log(h->s.avctx, AV_LOG_ERROR, "decode_slice_header error\n");
- 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
- * run in parallel mode this should not be an issue. */
- h->nal_unit_type = hx->nal_unit_type;
- h->nal_ref_idc = hx->nal_ref_idc;
- hx = h;
- goto again;
- }
- }
- // ==> Start patch MPC DXVA
- //if(context_count)
- // execute_decode_slices(h, context_count);
- // <== End patch MPC DXVA
- return buf_index;
-}
-
-
-int av_h264_decode_frame(struct AVCodecContext* avctx, int* nOutPOC, int64_t* rtStartTime, const uint8_t *buf, int buf_size)
-{
- H264Context *h = avctx->priv_data;
- MpegEncContext *s = &h->s;
- int buf_index = 0;
- Picture *out;
- int i, out_idx;
-
- // ==> Start patch MPC DXVA
- if (nOutPOC) *nOutPOC = INT_MIN;
- // <== End patch MPC DXVA
-
- s->flags = avctx->flags;
- s->flags2 = avctx->flags2;
-
- /* end of stream, output what is still in the buffers */
- if (buf_size == 0) {
-out:
-
- s->current_picture_ptr = NULL;
-
- // FIXME factorize this with the output code below
- out = h->delayed_pic[0];
- out_idx = 0;
- for (i = 1;
- h->delayed_pic[i] &&
- !h->delayed_pic[i]->f.key_frame &&
- !h->delayed_pic[i]->mmco_reset;
- i++)
- if (h->delayed_pic[i]->poc < out->poc) {
- out = h->delayed_pic[i];
- out_idx = i;
- }
-
- for (i = out_idx; h->delayed_pic[i]; i++)
- h->delayed_pic[i] = h->delayed_pic[i + 1];
-
- if (out) {
- // ==> Start patch MPC DXVA
- //*data_size = sizeof(AVFrame);
- //*pict = out->f;
- if (nOutPOC) *nOutPOC = out->poc;
- if (rtStartTime) *rtStartTime = out->f.reordered_opaque;
- // <== End patch MPC DXVA
- }
-
- return buf_index;
- }
-
- // ==> Start patch MPC DXVA
- buf_index = decode_nal_units_noexecute(h, buf, buf_size);
- // <== End patch MPC DXVA
- if (buf_index < 0)
- return -1;
-
- if (!s->current_picture_ptr && h->nal_unit_type == NAL_END_SEQUENCE) {
- av_assert0(buf_index <= buf_size);
- goto out;
- }
-
- if (!(s->flags2 & CODEC_FLAG2_CHUNKS) && !s->current_picture_ptr) {
- if (avctx->skip_frame >= AVDISCARD_NONREF ||
- buf_size >= 4 && !memcmp("Q264", buf, 4))
- return buf_size;
- av_log(avctx, AV_LOG_ERROR, "no frame!\n");
- return -1;
- }
-
- if (!(s->flags2 & CODEC_FLAG2_CHUNKS) ||
- (s->mb_y >= s->mb_height && s->mb_height)) {
- // ==> Start patch MPC DXVA
- decode_postinit_dxva(h, nOutPOC, rtStartTime);
- field_end_noexecute(h);
- // <== End patch MPC DXVA
- }
-
- if ((nOutPOC) && *nOutPOC == INT_MIN && h->next_output_pic) {
- *nOutPOC = h->next_output_pic->poc;
- }
-
- return get_consumed_bytes(s, buf_index, buf_size);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264_loopfilter.c b/src/thirdparty/ffmpeg/libavcodec/h264_loopfilter.c
deleted file mode 100644
index 7bc7d2f39..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264_loopfilter.c
+++ /dev/null
@@ -1,829 +0,0 @@
-/*
- * H.26L/H.264/AVC/JVT/14496-10/... loop filter
- * 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 loop filter.
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#include "libavutil/internal.h"
-#include "libavutil/intreadwrite.h"
-#include "internal.h"
-#include "avcodec.h"
-#include "mpegvideo.h"
-#include "h264.h"
-#include "mathops.h"
-#include "rectangle.h"
-
-/* Deblocking filter (p153) */
-static const uint8_t alpha_table[52*3] = {
- 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, 4, 4, 5, 6,
- 7, 8, 9, 10, 12, 13, 15, 17, 20, 22,
- 25, 28, 32, 36, 40, 45, 50, 56, 63, 71,
- 80, 90,101,113,127,144,162,182,203,226,
- 255,255,
- 255,255,255,255,255,255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255,255,255,255,255,
-};
-static const uint8_t beta_table[52*3] = {
- 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, 2, 2, 2, 3,
- 3, 3, 3, 4, 4, 4, 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,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
-};
-static const uint8_t tc0_table[52*3][4] = {
- {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
- {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
- {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
- {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
- {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
- {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
- {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
- {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
- {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
- {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
- {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 },
- {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 0 }, {-1, 0, 0, 1 },
- {-1, 0, 0, 1 }, {-1, 0, 0, 1 }, {-1, 0, 0, 1 }, {-1, 0, 1, 1 }, {-1, 0, 1, 1 }, {-1, 1, 1, 1 },
- {-1, 1, 1, 1 }, {-1, 1, 1, 1 }, {-1, 1, 1, 1 }, {-1, 1, 1, 2 }, {-1, 1, 1, 2 }, {-1, 1, 1, 2 },
- {-1, 1, 1, 2 }, {-1, 1, 2, 3 }, {-1, 1, 2, 3 }, {-1, 2, 2, 3 }, {-1, 2, 2, 4 }, {-1, 2, 3, 4 },
- {-1, 2, 3, 4 }, {-1, 3, 3, 5 }, {-1, 3, 4, 6 }, {-1, 3, 4, 6 }, {-1, 4, 5, 7 }, {-1, 4, 5, 8 },
- {-1, 4, 6, 9 }, {-1, 5, 7,10 }, {-1, 6, 8,11 }, {-1, 6, 8,13 }, {-1, 7,10,14 }, {-1, 8,11,16 },
- {-1, 9,12,18 }, {-1,10,13,20 }, {-1,11,15,23 }, {-1,13,17,25 },
- {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 },
- {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 },
- {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 },
- {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 },
- {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 },
- {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 },
- {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 },
- {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 },
- {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 }, {-1,13,17,25 },
-};
-
-/* intra: 0 if this loopfilter call is guaranteed to be inter (bS < 4), 1 if it might be intra (bS == 4) */
-static av_always_inline void filter_mb_edgev(uint8_t *pix, int stride,
- const int16_t bS[4],
- unsigned int qp, int a, int b,
- H264Context *h, int intra)
-{
- const unsigned int index_a = qp + a;
- const int alpha = alpha_table[index_a];
- const int beta = beta_table[qp + b];
- if (alpha ==0 || beta == 0) return;
-
- if( bS[0] < 4 || !intra ) {
- int8_t tc[4];
- tc[0] = tc0_table[index_a][bS[0]];
- tc[1] = tc0_table[index_a][bS[1]];
- tc[2] = tc0_table[index_a][bS[2]];
- tc[3] = tc0_table[index_a][bS[3]];
- h->h264dsp.h264_h_loop_filter_luma(pix, stride, alpha, beta, tc);
- } else {
- h->h264dsp.h264_h_loop_filter_luma_intra(pix, stride, alpha, beta);
- }
-}
-
-static av_always_inline void filter_mb_edgecv(uint8_t *pix, int stride,
- const int16_t bS[4],
- unsigned int qp, int a, int b,
- H264Context *h, int intra)
-{
- const unsigned int index_a = qp + a;
- const int alpha = alpha_table[index_a];
- const int beta = beta_table[qp + b];
- if (alpha ==0 || beta == 0) return;
-
- if( bS[0] < 4 || !intra ) {
- int8_t tc[4];
- tc[0] = tc0_table[index_a][bS[0]]+1;
- tc[1] = tc0_table[index_a][bS[1]]+1;
- tc[2] = tc0_table[index_a][bS[2]]+1;
- tc[3] = tc0_table[index_a][bS[3]]+1;
- h->h264dsp.h264_h_loop_filter_chroma(pix, stride, alpha, beta, tc);
- } else {
- h->h264dsp.h264_h_loop_filter_chroma_intra(pix, stride, alpha, beta);
- }
-}
-
-static av_always_inline void filter_mb_mbaff_edgev(H264Context *h, uint8_t *pix,
- int stride,
- const int16_t bS[7], int bsi,
- int qp, int a, int b,
- int intra)
-{
- const unsigned int index_a = qp + a;
- const int alpha = alpha_table[index_a];
- const int beta = beta_table[qp + b];
- if (alpha ==0 || beta == 0) return;
-
- if( bS[0] < 4 || !intra ) {
- int8_t tc[4];
- tc[0] = tc0_table[index_a][bS[0*bsi]];
- tc[1] = tc0_table[index_a][bS[1*bsi]];
- tc[2] = tc0_table[index_a][bS[2*bsi]];
- tc[3] = tc0_table[index_a][bS[3*bsi]];
- h->h264dsp.h264_h_loop_filter_luma_mbaff(pix, stride, alpha, beta, tc);
- } else {
- h->h264dsp.h264_h_loop_filter_luma_mbaff_intra(pix, stride, alpha, beta);
- }
-}
-
-static av_always_inline void filter_mb_mbaff_edgecv(H264Context *h,
- uint8_t *pix, int stride,
- const int16_t bS[7],
- int bsi, int qp, int a,
- int b, int intra)
-{
- const unsigned int index_a = qp + a;
- const int alpha = alpha_table[index_a];
- const int beta = beta_table[qp + b];
- if (alpha ==0 || beta == 0) return;
-
- if( bS[0] < 4 || !intra ) {
- int8_t tc[4];
- tc[0] = tc0_table[index_a][bS[0*bsi]] + 1;
- tc[1] = tc0_table[index_a][bS[1*bsi]] + 1;
- tc[2] = tc0_table[index_a][bS[2*bsi]] + 1;
- tc[3] = tc0_table[index_a][bS[3*bsi]] + 1;
- h->h264dsp.h264_h_loop_filter_chroma_mbaff(pix, stride, alpha, beta, tc);
- } else {
- h->h264dsp.h264_h_loop_filter_chroma_mbaff_intra(pix, stride, alpha, beta);
- }
-}
-
-static av_always_inline void filter_mb_edgeh(uint8_t *pix, int stride,
- const int16_t bS[4],
- unsigned int qp, int a, int b,
- H264Context *h, int intra)
-{
- const unsigned int index_a = qp + a;
- const int alpha = alpha_table[index_a];
- const int beta = beta_table[qp + b];
- if (alpha ==0 || beta == 0) return;
-
- if( bS[0] < 4 || !intra ) {
- int8_t tc[4];
- tc[0] = tc0_table[index_a][bS[0]];
- tc[1] = tc0_table[index_a][bS[1]];
- tc[2] = tc0_table[index_a][bS[2]];
- tc[3] = tc0_table[index_a][bS[3]];
- h->h264dsp.h264_v_loop_filter_luma(pix, stride, alpha, beta, tc);
- } else {
- h->h264dsp.h264_v_loop_filter_luma_intra(pix, stride, alpha, beta);
- }
-}
-
-static av_always_inline void filter_mb_edgech(uint8_t *pix, int stride,
- const int16_t bS[4],
- unsigned int qp, int a, int b,
- H264Context *h, int intra)
-{
- const unsigned int index_a = qp + a;
- const int alpha = alpha_table[index_a];
- const int beta = beta_table[qp + b];
- if (alpha ==0 || beta == 0) return;
-
- if( bS[0] < 4 || !intra ) {
- int8_t tc[4];
- tc[0] = tc0_table[index_a][bS[0]]+1;
- tc[1] = tc0_table[index_a][bS[1]]+1;
- tc[2] = tc0_table[index_a][bS[2]]+1;
- tc[3] = tc0_table[index_a][bS[3]]+1;
- h->h264dsp.h264_v_loop_filter_chroma(pix, stride, alpha, beta, tc);
- } else {
- h->h264dsp.h264_v_loop_filter_chroma_intra(pix, stride, alpha, beta);
- }
-}
-
-static av_always_inline void h264_filter_mb_fast_internal(H264Context *h,
- int mb_x, int mb_y,
- uint8_t *img_y,
- uint8_t *img_cb,
- uint8_t *img_cr,
- unsigned int linesize,
- unsigned int uvlinesize,
- int pixel_shift)
-{
- MpegEncContext * const s = &h->s;
- int chroma = CHROMA && !(CONFIG_GRAY && (s->flags&CODEC_FLAG_GRAY));
- int chroma444 = CHROMA444;
- int chroma422 = CHROMA422;
-
- int mb_xy = h->mb_xy;
- int left_type= h->left_type[LTOP];
- 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 mb_type = s->current_picture.f.mb_type[mb_xy];
- int qp = s->current_picture.f.qscale_table[mb_xy];
- int qp0 = s->current_picture.f.qscale_table[mb_xy - 1];
- int qp1 = s->current_picture.f.qscale_table[h->top_mb_xy];
- int qpc = get_chroma_qp( h, 0, qp );
- int qpc0 = get_chroma_qp( h, 0, qp0 );
- int qpc1 = get_chroma_qp( h, 0, qp1 );
- qp0 = (qp + qp0 + 1) >> 1;
- qp1 = (qp + qp1 + 1) >> 1;
- qpc0 = (qpc + qpc0 + 1) >> 1;
- qpc1 = (qpc + qpc1 + 1) >> 1;
-
- if( IS_INTRA(mb_type) ) {
- static const int16_t bS4[4] = {4,4,4,4};
- static const int16_t bS3[4] = {3,3,3,3};
- const int16_t *bSH = FIELD_PICTURE ? bS3 : bS4;
- if(left_type)
- filter_mb_edgev( &img_y[4*0<<pixel_shift], linesize, bS4, qp0, a, b, h, 1);
- if( IS_8x8DCT(mb_type) ) {
- filter_mb_edgev( &img_y[4*2<<pixel_shift], linesize, bS3, qp, a, b, h, 0);
- if(top_type){
- filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, a, b, h, 1);
- }
- filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, a, b, h, 0);
- } else {
- filter_mb_edgev( &img_y[4*1<<pixel_shift], linesize, bS3, qp, a, b, h, 0);
- filter_mb_edgev( &img_y[4*2<<pixel_shift], linesize, bS3, qp, a, b, h, 0);
- filter_mb_edgev( &img_y[4*3<<pixel_shift], linesize, bS3, qp, a, b, h, 0);
- if(top_type){
- filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, a, b, h, 1);
- }
- filter_mb_edgeh( &img_y[4*1*linesize], linesize, bS3, qp, a, b, h, 0);
- filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, a, b, h, 0);
- filter_mb_edgeh( &img_y[4*3*linesize], linesize, bS3, qp, a, b, h, 0);
- }
- if(chroma){
- if(chroma444){
- if(left_type){
- filter_mb_edgev( &img_cb[4*0<<pixel_shift], linesize, bS4, qpc0, a, b, h, 1);
- filter_mb_edgev( &img_cr[4*0<<pixel_shift], linesize, bS4, qpc0, a, b, h, 1);
- }
- if( IS_8x8DCT(mb_type) ) {
- filter_mb_edgev( &img_cb[4*2<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
- filter_mb_edgev( &img_cr[4*2<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
- if(top_type){
- filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, a, b, h, 1 );
- filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, a, b, h, 1 );
- }
- filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, a, b, h, 0);
- filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, a, b, h, 0);
- } else {
- filter_mb_edgev( &img_cb[4*1<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
- filter_mb_edgev( &img_cr[4*1<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
- filter_mb_edgev( &img_cb[4*2<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
- filter_mb_edgev( &img_cr[4*2<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
- filter_mb_edgev( &img_cb[4*3<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
- filter_mb_edgev( &img_cr[4*3<<pixel_shift], linesize, bS3, qpc, a, b, h, 0);
- if(top_type){
- filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, a, b, h, 1);
- filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, a, b, h, 1);
- }
- filter_mb_edgeh( &img_cb[4*1*linesize], linesize, bS3, qpc, a, b, h, 0);
- filter_mb_edgeh( &img_cr[4*1*linesize], linesize, bS3, qpc, a, b, h, 0);
- filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, a, b, h, 0);
- filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, a, b, h, 0);
- filter_mb_edgeh( &img_cb[4*3*linesize], linesize, bS3, qpc, a, b, h, 0);
- filter_mb_edgeh( &img_cr[4*3*linesize], linesize, bS3, qpc, a, b, h, 0);
- }
- }else if(chroma422){
- if(left_type){
- filter_mb_edgecv(&img_cb[2*0<<pixel_shift], uvlinesize, bS4, qpc0, a, b, h, 1);
- filter_mb_edgecv(&img_cr[2*0<<pixel_shift], uvlinesize, bS4, qpc0, a, b, h, 1);
- }
- filter_mb_edgecv(&img_cb[2*2<<pixel_shift], uvlinesize, bS3, qpc, a, b, h, 0);
- filter_mb_edgecv(&img_cr[2*2<<pixel_shift], uvlinesize, bS3, qpc, a, b, h, 0);
- if(top_type){
- filter_mb_edgech(&img_cb[4*0*uvlinesize], uvlinesize, bSH, qpc1, a, b, h, 1);
- filter_mb_edgech(&img_cr[4*0*uvlinesize], uvlinesize, bSH, qpc1, a, b, h, 1);
- }
- filter_mb_edgech(&img_cb[4*1*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0);
- filter_mb_edgech(&img_cr[4*1*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0);
- filter_mb_edgech(&img_cb[4*2*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0);
- filter_mb_edgech(&img_cr[4*2*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0);
- filter_mb_edgech(&img_cb[4*3*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0);
- filter_mb_edgech(&img_cr[4*3*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0);
- }else{
- if(left_type){
- filter_mb_edgecv( &img_cb[2*0<<pixel_shift], uvlinesize, bS4, qpc0, a, b, h, 1);
- filter_mb_edgecv( &img_cr[2*0<<pixel_shift], uvlinesize, bS4, qpc0, a, b, h, 1);
- }
- filter_mb_edgecv( &img_cb[2*2<<pixel_shift], uvlinesize, bS3, qpc, a, b, h, 0);
- filter_mb_edgecv( &img_cr[2*2<<pixel_shift], uvlinesize, bS3, qpc, a, b, h, 0);
- if(top_type){
- filter_mb_edgech( &img_cb[2*0*uvlinesize], uvlinesize, bSH, qpc1, a, b, h, 1);
- filter_mb_edgech( &img_cr[2*0*uvlinesize], uvlinesize, bSH, qpc1, a, b, h, 1);
- }
- filter_mb_edgech( &img_cb[2*2*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0);
- filter_mb_edgech( &img_cr[2*2*uvlinesize], uvlinesize, bS3, qpc, a, b, h, 0);
- }
- }
- return;
- } else {
- LOCAL_ALIGNED_8(int16_t, bS, [2], [4][4]);
- int edges;
- if( IS_8x8DCT(mb_type) && (h->cbp&7) == 7 && !chroma444 ) {
- edges = 4;
- AV_WN64A(bS[0][0], 0x0002000200020002ULL);
- AV_WN64A(bS[0][2], 0x0002000200020002ULL);
- AV_WN64A(bS[1][0], 0x0002000200020002ULL);
- AV_WN64A(bS[1][2], 0x0002000200020002ULL);
- } else {
- int mask_edge1 = (3*(((5*mb_type)>>5)&1)) | (mb_type>>4); //(mb_type & (MB_TYPE_16x16 | MB_TYPE_8x16)) ? 3 : (mb_type & MB_TYPE_16x8) ? 1 : 0;
- int mask_edge0 = 3*((mask_edge1>>1) & ((5*left_type)>>5)&1); // (mb_type & (MB_TYPE_16x16 | MB_TYPE_8x16)) && (h->left_type[LTOP] & (MB_TYPE_16x16 | MB_TYPE_8x16)) ? 3 : 0;
- int step = 1+(mb_type>>24); //IS_8x8DCT(mb_type) ? 2 : 1;
- edges = 4 - 3*((mb_type>>3) & !(h->cbp & 15)); //(mb_type & MB_TYPE_16x16) && !(h->cbp & 15) ? 1 : 4;
- h->h264dsp.h264_loop_filter_strength( bS, h->non_zero_count_cache, h->ref_cache, h->mv_cache,
- h->list_count==2, edges, step, mask_edge0, mask_edge1, FIELD_PICTURE);
- }
- if( IS_INTRA(left_type) )
- AV_WN64A(bS[0][0], 0x0004000400040004ULL);
- if( IS_INTRA(top_type) )
- AV_WN64A(bS[1][0], FIELD_PICTURE ? 0x0003000300030003ULL : 0x0004000400040004ULL);
-
-#define FILTER(hv,dir,edge,intra)\
- if(AV_RN64A(bS[dir][edge])) { \
- filter_mb_edge##hv( &img_y[4*edge*(dir?linesize:1<<pixel_shift)], linesize, bS[dir][edge], edge ? qp : qp##dir, a, b, h, intra );\
- if(chroma){\
- if(chroma444){\
- filter_mb_edge##hv( &img_cb[4*edge*(dir?linesize:1<<pixel_shift)], linesize, bS[dir][edge], edge ? qpc : qpc##dir, a, b, h, intra );\
- filter_mb_edge##hv( &img_cr[4*edge*(dir?linesize:1<<pixel_shift)], linesize, bS[dir][edge], edge ? qpc : qpc##dir, a, b, h, intra );\
- } else if(!(edge&1)) {\
- filter_mb_edgec##hv( &img_cb[2*edge*(dir?uvlinesize:1<<pixel_shift)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir, a, b, h, intra );\
- filter_mb_edgec##hv( &img_cr[2*edge*(dir?uvlinesize:1<<pixel_shift)], uvlinesize, bS[dir][edge], edge ? qpc : qpc##dir, a, b, h, intra );\
- }\
- }\
- }
- if(left_type)
- FILTER(v,0,0,1);
- if( edges == 1 ) {
- if(top_type)
- FILTER(h,1,0,1);
- } else if( IS_8x8DCT(mb_type) ) {
- FILTER(v,0,2,0);
- if(top_type)
- FILTER(h,1,0,1);
- FILTER(h,1,2,0);
- } else {
- FILTER(v,0,1,0);
- FILTER(v,0,2,0);
- FILTER(v,0,3,0);
- if(top_type)
- FILTER(h,1,0,1);
- FILTER(h,1,1,0);
- FILTER(h,1,2,0);
- FILTER(h,1,3,0);
- }
-#undef FILTER
- }
-}
-
-void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) {
- av_assert2(!FRAME_MBAFF);
- if(!h->h264dsp.h264_loop_filter_strength || h->pps.chroma_qp_diff) {
- ff_h264_filter_mb(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize);
- return;
- }
-
-#if CONFIG_SMALL
- h264_filter_mb_fast_internal(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, h->pixel_shift);
-#else
- if(h->pixel_shift){
- h264_filter_mb_fast_internal(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, 1);
- }else{
- h264_filter_mb_fast_internal(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, 0);
- }
-#endif
-}
-
-static int check_mv(H264Context *h, long b_idx, long bn_idx, int mvy_limit){
- int v;
-
- v= h->ref_cache[0][b_idx] != h->ref_cache[0][bn_idx];
- if(!v && h->ref_cache[0][b_idx]!=-1)
- v= h->mv_cache[0][b_idx][0] - h->mv_cache[0][bn_idx][0] + 3 >= 7U |
- FFABS( h->mv_cache[0][b_idx][1] - h->mv_cache[0][bn_idx][1] ) >= mvy_limit;
-
- if(h->list_count==2){
- if(!v)
- v = h->ref_cache[1][b_idx] != h->ref_cache[1][bn_idx] |
- h->mv_cache[1][b_idx][0] - h->mv_cache[1][bn_idx][0] + 3 >= 7U |
- FFABS( h->mv_cache[1][b_idx][1] - h->mv_cache[1][bn_idx][1] ) >= mvy_limit;
-
- if(v){
- if(h->ref_cache[0][b_idx] != h->ref_cache[1][bn_idx] |
- h->ref_cache[1][b_idx] != h->ref_cache[0][bn_idx])
- return 1;
- return
- h->mv_cache[0][b_idx][0] - h->mv_cache[1][bn_idx][0] + 3 >= 7U |
- FFABS( h->mv_cache[0][b_idx][1] - h->mv_cache[1][bn_idx][1] ) >= mvy_limit |
- h->mv_cache[1][b_idx][0] - h->mv_cache[0][bn_idx][0] + 3 >= 7U |
- FFABS( h->mv_cache[1][b_idx][1] - h->mv_cache[0][bn_idx][1] ) >= mvy_limit;
- }
- }
-
- return v;
-}
-
-static av_always_inline void filter_mb_dir(H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize, int mb_xy, int mb_type, int mvy_limit, int first_vertical_edge_done, int a, int b, int chroma, int dir) {
- MpegEncContext * const s = &h->s;
- int edge;
- int chroma_qp_avg[2];
- int chroma444 = CHROMA444;
- int chroma422 = CHROMA422;
- const int mbm_xy = dir == 0 ? mb_xy -1 : h->top_mb_xy;
- const int mbm_type = dir == 0 ? h->left_type[LTOP] : h->top_type;
-
- // how often to recheck mv-based bS when iterating between edges
- static const uint8_t mask_edge_tab[2][8]={{0,3,3,3,1,1,1,1},
- {0,3,1,1,3,3,3,3}};
- const int mask_edge = mask_edge_tab[dir][(mb_type>>3)&7];
- const int edges = mask_edge== 3 && !(h->cbp&15) ? 1 : 4;
-
- // how often to recheck mv-based bS when iterating along each edge
- const int mask_par0 = mb_type & (MB_TYPE_16x16 | (MB_TYPE_8x16 >> dir));
-
- if(mbm_type && !first_vertical_edge_done){
-
- if (FRAME_MBAFF && (dir == 1) && ((mb_y&1) == 0)
- && IS_INTERLACED(mbm_type&~mb_type)
- ) {
- // This is a special case in the norm where the filtering must
- // be done twice (one each of the field) even if we are in a
- // frame macroblock.
- //
- unsigned int tmp_linesize = 2 * linesize;
- unsigned int tmp_uvlinesize = 2 * uvlinesize;
- int mbn_xy = mb_xy - 2 * s->mb_stride;
- int j;
-
- for(j=0; j<2; j++, mbn_xy += s->mb_stride){
- DECLARE_ALIGNED(8, int16_t, bS)[4];
- int qp;
- if (IS_INTRA(mb_type | s->current_picture.f.mb_type[mbn_xy])) {
- AV_WN64A(bS, 0x0003000300030003ULL);
- } else {
- if (!CABAC && IS_8x8DCT(s->current_picture.f.mb_type[mbn_xy])) {
- bS[0]= 1+((h->cbp_table[mbn_xy] & 0x4000)||h->non_zero_count_cache[scan8[0]+0]);
- bS[1]= 1+((h->cbp_table[mbn_xy] & 0x4000)||h->non_zero_count_cache[scan8[0]+1]);
- bS[2]= 1+((h->cbp_table[mbn_xy] & 0x8000)||h->non_zero_count_cache[scan8[0]+2]);
- bS[3]= 1+((h->cbp_table[mbn_xy] & 0x8000)||h->non_zero_count_cache[scan8[0]+3]);
- }else{
- const uint8_t *mbn_nnz = h->non_zero_count[mbn_xy] + 3*4;
- int i;
- for( i = 0; i < 4; i++ ) {
- bS[i] = 1 + !!(h->non_zero_count_cache[scan8[0]+i] | mbn_nnz[i]);
- }
- }
- }
- // Do not use s->qscale as luma quantizer because it has not the same
- // value in IPCM macroblocks.
- qp = (s->current_picture.f.qscale_table[mb_xy] + s->current_picture.f.qscale_table[mbn_xy] + 1) >> 1;
- tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, tmp_linesize, tmp_uvlinesize);
- { int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); }
- filter_mb_edgeh( &img_y[j*linesize], tmp_linesize, bS, qp, a, b, h, 0 );
- chroma_qp_avg[0] = (h->chroma_qp[0] + get_chroma_qp(h, 0, s->current_picture.f.qscale_table[mbn_xy]) + 1) >> 1;
- chroma_qp_avg[1] = (h->chroma_qp[1] + get_chroma_qp(h, 1, s->current_picture.f.qscale_table[mbn_xy]) + 1) >> 1;
- if (chroma) {
- if (chroma444) {
- filter_mb_edgeh (&img_cb[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[0], a, b, h, 0);
- filter_mb_edgeh (&img_cr[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[1], a, b, h, 0);
- } else {
- filter_mb_edgech(&img_cb[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[0], a, b, h, 0);
- filter_mb_edgech(&img_cr[j*uvlinesize], tmp_uvlinesize, bS, chroma_qp_avg[1], a, b, h, 0);
- }
- }
- }
- }else{
- DECLARE_ALIGNED(8, int16_t, bS)[4];
- int qp;
-
- if( IS_INTRA(mb_type|mbm_type)) {
- AV_WN64A(bS, 0x0003000300030003ULL);
- if ( (!IS_INTERLACED(mb_type|mbm_type))
- || ((FRAME_MBAFF || (s->picture_structure != PICT_FRAME)) && (dir == 0))
- )
- AV_WN64A(bS, 0x0004000400040004ULL);
- } else {
- int i;
- int mv_done;
-
- if( dir && FRAME_MBAFF && IS_INTERLACED(mb_type ^ mbm_type)) {
- AV_WN64A(bS, 0x0001000100010001ULL);
- mv_done = 1;
- }
- else if( mask_par0 && ((mbm_type & (MB_TYPE_16x16 | (MB_TYPE_8x16 >> dir)))) ) {
- int b_idx= 8 + 4;
- int bn_idx= b_idx - (dir ? 8:1);
-
- bS[0] = bS[1] = bS[2] = bS[3] = check_mv(h, 8 + 4, bn_idx, mvy_limit);
- mv_done = 1;
- }
- else
- mv_done = 0;
-
- for( i = 0; i < 4; i++ ) {
- int x = dir == 0 ? 0 : i;
- int y = dir == 0 ? i : 0;
- int b_idx= 8 + 4 + x + 8*y;
- int bn_idx= b_idx - (dir ? 8:1);
-
- if( h->non_zero_count_cache[b_idx] |
- h->non_zero_count_cache[bn_idx] ) {
- bS[i] = 2;
- }
- else if(!mv_done)
- {
- bS[i] = check_mv(h, b_idx, bn_idx, mvy_limit);
- }
- }
- }
-
- /* Filter edge */
- // Do not use s->qscale as luma quantizer because it has not the same
- // value in IPCM macroblocks.
- if(bS[0]+bS[1]+bS[2]+bS[3]){
- qp = (s->current_picture.f.qscale_table[mb_xy] + s->current_picture.f.qscale_table[mbm_xy] + 1) >> 1;
- //tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d, QPc:%d, QPcn:%d\n", mb_x, mb_y, dir, edge, qp, h->chroma_qp[0], s->current_picture.qscale_table[mbn_xy]);
- tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, linesize, uvlinesize);
- //{ int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); }
- chroma_qp_avg[0] = (h->chroma_qp[0] + get_chroma_qp(h, 0, s->current_picture.f.qscale_table[mbm_xy]) + 1) >> 1;
- chroma_qp_avg[1] = (h->chroma_qp[1] + get_chroma_qp(h, 1, s->current_picture.f.qscale_table[mbm_xy]) + 1) >> 1;
- if( dir == 0 ) {
- filter_mb_edgev( &img_y[0], linesize, bS, qp, a, b, h, 1 );
- if (chroma) {
- if (chroma444) {
- filter_mb_edgev ( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], a, b, h, 1);
- filter_mb_edgev ( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], a, b, h, 1);
- } else {
- filter_mb_edgecv( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], a, b, h, 1);
- filter_mb_edgecv( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], a, b, h, 1);
- }
- }
- } else {
- filter_mb_edgeh( &img_y[0], linesize, bS, qp, a, b, h, 1 );
- if (chroma) {
- if (chroma444) {
- filter_mb_edgeh ( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], a, b, h, 1);
- filter_mb_edgeh ( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], a, b, h, 1);
- } else {
- filter_mb_edgech( &img_cb[0], uvlinesize, bS, chroma_qp_avg[0], a, b, h, 1);
- filter_mb_edgech( &img_cr[0], uvlinesize, bS, chroma_qp_avg[1], a, b, h, 1);
- }
- }
- }
- }
- }
- }
-
- /* Calculate bS */
- for( edge = 1; edge < edges; edge++ ) {
- DECLARE_ALIGNED(8, int16_t, bS)[4];
- int qp;
- const int deblock_edge = !IS_8x8DCT(mb_type & (edge<<24)); // (edge&1) && IS_8x8DCT(mb_type)
-
- if (!deblock_edge && (!chroma422 || dir == 0))
- continue;
-
- if( IS_INTRA(mb_type)) {
- AV_WN64A(bS, 0x0003000300030003ULL);
- } else {
- int i;
- int mv_done;
-
- if( edge & mask_edge ) {
- AV_ZERO64(bS);
- mv_done = 1;
- }
- else if( mask_par0 ) {
- int b_idx= 8 + 4 + edge * (dir ? 8:1);
- int bn_idx= b_idx - (dir ? 8:1);
-
- bS[0] = bS[1] = bS[2] = bS[3] = check_mv(h, b_idx, bn_idx, mvy_limit);
- mv_done = 1;
- }
- else
- mv_done = 0;
-
- for( i = 0; i < 4; i++ ) {
- int x = dir == 0 ? edge : i;
- int y = dir == 0 ? i : edge;
- int b_idx= 8 + 4 + x + 8*y;
- int bn_idx= b_idx - (dir ? 8:1);
-
- if( h->non_zero_count_cache[b_idx] |
- h->non_zero_count_cache[bn_idx] ) {
- bS[i] = 2;
- }
- else if(!mv_done)
- {
- bS[i] = check_mv(h, b_idx, bn_idx, mvy_limit);
- }
- }
-
- if(bS[0]+bS[1]+bS[2]+bS[3] == 0)
- continue;
- }
-
- /* Filter edge */
- // Do not use s->qscale as luma quantizer because it has not the same
- // value in IPCM macroblocks.
- qp = s->current_picture.f.qscale_table[mb_xy];
- //tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d, QPc:%d, QPcn:%d\n", mb_x, mb_y, dir, edge, qp, h->chroma_qp[0], s->current_picture.qscale_table[mbn_xy]);
- tprintf(s->avctx, "filter mb:%d/%d dir:%d edge:%d, QPy:%d ls:%d uvls:%d", mb_x, mb_y, dir, edge, qp, linesize, uvlinesize);
- //{ int i; for (i = 0; i < 4; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); }
- if( dir == 0 ) {
- filter_mb_edgev( &img_y[4*edge << h->pixel_shift], linesize, bS, qp, a, b, h, 0 );
- if (chroma) {
- if (chroma444) {
- filter_mb_edgev ( &img_cb[4*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0);
- filter_mb_edgev ( &img_cr[4*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0);
- } else if( (edge&1) == 0 ) {
- filter_mb_edgecv( &img_cb[2*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0);
- filter_mb_edgecv( &img_cr[2*edge << h->pixel_shift], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0);
- }
- }
- } else {
- if (chroma422) {
- if (deblock_edge)
- filter_mb_edgeh(&img_y[4*edge*linesize], linesize, bS, qp, a, b, h, 0);
- if (chroma) {
- filter_mb_edgech(&img_cb[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0);
- filter_mb_edgech(&img_cr[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0);
- }
- } else {
- filter_mb_edgeh(&img_y[4*edge*linesize], linesize, bS, qp, a, b, h, 0);
- if (chroma) {
- if (chroma444) {
- filter_mb_edgeh (&img_cb[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0);
- filter_mb_edgeh (&img_cr[4*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0);
- } else if ((edge&1) == 0) {
- filter_mb_edgech(&img_cb[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[0], a, b, h, 0);
- filter_mb_edgech(&img_cr[2*edge*uvlinesize], uvlinesize, bS, h->chroma_qp[1], a, b, h, 0);
- }
- }
- }
- }
- }
-}
-
-void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) {
- MpegEncContext * const s = &h->s;
- const int mb_xy= mb_x + mb_y*s->mb_stride;
- const int mb_type = s->current_picture.f.mb_type[mb_xy];
- const int mvy_limit = IS_INTERLACED(mb_type) ? 2 : 4;
- int first_vertical_edge_done = 0;
- av_unused int dir;
- int chroma = CHROMA && !(CONFIG_GRAY && (s->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;
-
- if (FRAME_MBAFF
- // and current and left pair do not have the same interlaced type
- && IS_INTERLACED(mb_type^h->left_type[LTOP])
- // and left mb is in available to us
- && h->left_type[LTOP]) {
- /* First vertical edge is different in MBAFF frames
- * There are 8 different bS to compute and 2 different Qp
- */
- DECLARE_ALIGNED(8, int16_t, bS)[8];
- int qp[2];
- int bqp[2];
- int rqp[2];
- int mb_qp, mbn0_qp, mbn1_qp;
- int i;
- first_vertical_edge_done = 1;
-
- if( IS_INTRA(mb_type) ) {
- AV_WN64A(&bS[0], 0x0004000400040004ULL);
- AV_WN64A(&bS[4], 0x0004000400040004ULL);
- } else {
- static const uint8_t offset[2][2][8]={
- {
- {3+4*0, 3+4*0, 3+4*0, 3+4*0, 3+4*1, 3+4*1, 3+4*1, 3+4*1},
- {3+4*2, 3+4*2, 3+4*2, 3+4*2, 3+4*3, 3+4*3, 3+4*3, 3+4*3},
- },{
- {3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},
- {3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},
- }
- };
- const uint8_t *off= offset[MB_FIELD][mb_y&1];
- for( i = 0; i < 8; i++ ) {
- int j= MB_FIELD ? i>>2 : i&1;
- int mbn_xy = h->left_mb_xy[LEFT(j)];
- int mbn_type= h->left_type[LEFT(j)];
-
- if( IS_INTRA( mbn_type ) )
- bS[i] = 4;
- else{
- bS[i] = 1 + !!(h->non_zero_count_cache[12+8*(i>>1)] |
- ((!h->pps.cabac && IS_8x8DCT(mbn_type)) ?
- (h->cbp_table[mbn_xy] & (((MB_FIELD ? (i&2) : (mb_y&1)) ? 8 : 2) << 12))
- :
- h->non_zero_count[mbn_xy][ off[i] ]));
- }
- }
- }
-
- mb_qp = s->current_picture.f.qscale_table[mb_xy];
- mbn0_qp = s->current_picture.f.qscale_table[h->left_mb_xy[0]];
- mbn1_qp = s->current_picture.f.qscale_table[h->left_mb_xy[1]];
- qp[0] = ( mb_qp + mbn0_qp + 1 ) >> 1;
- bqp[0] = ( get_chroma_qp( h, 0, mb_qp ) +
- get_chroma_qp( h, 0, mbn0_qp ) + 1 ) >> 1;
- rqp[0] = ( get_chroma_qp( h, 1, mb_qp ) +
- get_chroma_qp( h, 1, mbn0_qp ) + 1 ) >> 1;
- qp[1] = ( mb_qp + mbn1_qp + 1 ) >> 1;
- bqp[1] = ( get_chroma_qp( h, 0, mb_qp ) +
- get_chroma_qp( h, 0, mbn1_qp ) + 1 ) >> 1;
- rqp[1] = ( get_chroma_qp( h, 1, mb_qp ) +
- get_chroma_qp( h, 1, mbn1_qp ) + 1 ) >> 1;
-
- /* Filter edge */
- tprintf(s->avctx, "filter mb:%d/%d MBAFF, QPy:%d/%d, QPb:%d/%d QPr:%d/%d ls:%d uvls:%d", mb_x, mb_y, qp[0], qp[1], bqp[0], bqp[1], rqp[0], rqp[1], linesize, uvlinesize);
- { int i; for (i = 0; i < 8; i++) tprintf(s->avctx, " bS[%d]:%d", i, bS[i]); tprintf(s->avctx, "\n"); }
- if(MB_FIELD){
- filter_mb_mbaff_edgev ( h, img_y , linesize, bS , 1, qp [0], a, b, 1 );
- filter_mb_mbaff_edgev ( h, img_y + 8* linesize, linesize, bS+4, 1, qp [1], a, b, 1 );
- if (chroma){
- if (CHROMA444) {
- filter_mb_mbaff_edgev ( h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1 );
- filter_mb_mbaff_edgev ( h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 );
- filter_mb_mbaff_edgev ( h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1 );
- filter_mb_mbaff_edgev ( h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1 );
- } else if (CHROMA422) {
- filter_mb_mbaff_edgecv(h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1);
- filter_mb_mbaff_edgecv(h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1);
- filter_mb_mbaff_edgecv(h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1);
- filter_mb_mbaff_edgecv(h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1);
- }else{
- filter_mb_mbaff_edgecv( h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1 );
- filter_mb_mbaff_edgecv( h, img_cb + 4*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 );
- filter_mb_mbaff_edgecv( h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1 );
- filter_mb_mbaff_edgecv( h, img_cr + 4*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1 );
- }
- }
- }else{
- filter_mb_mbaff_edgev ( h, img_y , 2* linesize, bS , 2, qp [0], a, b, 1 );
- filter_mb_mbaff_edgev ( h, img_y + linesize, 2* linesize, bS+1, 2, qp [1], a, b, 1 );
- if (chroma){
- if (CHROMA444) {
- filter_mb_mbaff_edgev ( h, img_cb, 2*uvlinesize, bS , 2, bqp[0], a, b, 1 );
- filter_mb_mbaff_edgev ( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], a, b, 1 );
- filter_mb_mbaff_edgev ( h, img_cr, 2*uvlinesize, bS , 2, rqp[0], a, b, 1 );
- filter_mb_mbaff_edgev ( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], a, b, 1 );
- }else{
- filter_mb_mbaff_edgecv( h, img_cb, 2*uvlinesize, bS , 2, bqp[0], a, b, 1 );
- filter_mb_mbaff_edgecv( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], a, b, 1 );
- filter_mb_mbaff_edgecv( h, img_cr, 2*uvlinesize, bS , 2, rqp[0], a, b, 1 );
- filter_mb_mbaff_edgecv( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], a, b, 1 );
- }
- }
- }
- }
-
-#if CONFIG_SMALL
- for( dir = 0; dir < 2; dir++ )
- filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, dir ? 0 : first_vertical_edge_done, a, b, chroma, dir);
-#else
- filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, first_vertical_edge_done, a, b, chroma, 0);
- filter_mb_dir(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, 0, a, b, chroma, 1);
-#endif
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264_mb_template.c b/src/thirdparty/ffmpeg/libavcodec/h264_mb_template.c
deleted file mode 100644
index c60e51cf0..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264_mb_template.c
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- * 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
- */
-
-#undef FUNC
-#undef PIXEL_SHIFT
-
-#if SIMPLE
-# define FUNC(n) AV_JOIN(n ## _simple_, BITS)
-# define PIXEL_SHIFT (BITS >> 4)
-#else
-# define FUNC(n) n ## _complex
-# define PIXEL_SHIFT h->pixel_shift
-#endif
-
-#undef CHROMA_IDC
-#define CHROMA_IDC 1
-#include "h264_mc_template.c"
-
-#undef CHROMA_IDC
-#define CHROMA_IDC 2
-#include "h264_mc_template.c"
-
-static av_noinline void FUNC(hl_decode_mb)(H264Context *h)
-{
- MpegEncContext *const s = &h->s;
- const int mb_x = s->mb_x;
- const int mb_y = s->mb_y;
- const int mb_xy = h->mb_xy;
- const int mb_type = s->current_picture.f.mb_type[mb_xy];
- uint8_t *dest_y, *dest_cb, *dest_cr;
- int linesize, uvlinesize /*dct_offset*/;
- int i, j;
- int *block_offset = &h->block_offset[0];
- const int transform_bypass = !SIMPLE && (s->qscale == 0 && h->sps.transform_bypass);
- /* is_h264 should always be true if SVQ3 is disabled. */
- const int is_h264 = !CONFIG_SVQ3_DECODER || SIMPLE || s->codec_id == AV_CODEC_ID_H264;
- void (*idct_add)(uint8_t *dst, int16_t *block, int stride);
- const int block_h = 16 >> s->chroma_y_shift;
- const int chroma422 = CHROMA422;
-
- dest_y = s->current_picture.f.data[0] + ((mb_x << PIXEL_SHIFT) + mb_y * s->linesize) * 16;
- dest_cb = s->current_picture.f.data[1] + (mb_x << PIXEL_SHIFT) * 8 + mb_y * s->uvlinesize * block_h;
- dest_cr = s->current_picture.f.data[2] + (mb_x << PIXEL_SHIFT) * 8 + mb_y * s->uvlinesize * block_h;
-
- s->vdsp.prefetch(dest_y + (s->mb_x & 3) * 4 * s->linesize + (64 << PIXEL_SHIFT), s->linesize, 4);
- s->vdsp.prefetch(dest_cb + (s->mb_x & 7) * s->uvlinesize + (64 << PIXEL_SHIFT), dest_cr - dest_cb, 2);
-
- h->list_counts[mb_xy] = h->list_count;
-
- if (!SIMPLE && MB_FIELD) {
- linesize = h->mb_linesize = s->linesize * 2;
- uvlinesize = h->mb_uvlinesize = s->uvlinesize * 2;
- block_offset = &h->block_offset[48];
- if (mb_y & 1) { // FIXME move out of this function?
- dest_y -= s->linesize * 15;
- dest_cb -= s->uvlinesize * (block_h - 1);
- dest_cr -= s->uvlinesize * (block_h - 1);
- }
- if (FRAME_MBAFF) {
- int list;
- for (list = 0; list < h->list_count; list++) {
- if (!USES_LIST(mb_type, list))
- continue;
- if (IS_16X16(mb_type)) {
- int8_t *ref = &h->ref_cache[list][scan8[0]];
- fill_rectangle(ref, 4, 4, 8, (16 + *ref) ^ (s->mb_y & 1), 1);
- } else {
- for (i = 0; i < 16; i += 4) {
- int ref = h->ref_cache[list][scan8[i]];
- if (ref >= 0)
- fill_rectangle(&h->ref_cache[list][scan8[i]], 2, 2,
- 8, (16 + ref) ^ (s->mb_y & 1), 1);
- }
- }
- }
- }
- } else {
- linesize = h->mb_linesize = s->linesize;
- uvlinesize = h->mb_uvlinesize = s->uvlinesize;
- // dct_offset = s->linesize * 16;
- }
-
- if (!SIMPLE && IS_INTRA_PCM(mb_type)) {
- const int bit_depth = h->sps.bit_depth_luma;
- if (PIXEL_SHIFT) {
- int j;
- GetBitContext gb;
- init_get_bits(&gb, (uint8_t *)h->mb,
- ff_h264_mb_sizes[h->sps.chroma_format_idc] * bit_depth);
-
- for (i = 0; i < 16; i++) {
- uint16_t *tmp_y = (uint16_t *)(dest_y + i * linesize);
- for (j = 0; j < 16; j++)
- tmp_y[j] = get_bits(&gb, bit_depth);
- }
- if (SIMPLE || !CONFIG_GRAY || !(s->flags & CODEC_FLAG_GRAY)) {
- if (!h->sps.chroma_format_idc) {
- for (i = 0; i < block_h; i++) {
- uint16_t *tmp_cb = (uint16_t *)(dest_cb + i * uvlinesize);
- uint16_t *tmp_cr = (uint16_t *)(dest_cr + i * uvlinesize);
- for (j = 0; j < 8; j++) {
- tmp_cb[j] = tmp_cr[j] = 1 << (bit_depth - 1);
- }
- }
- } else {
- for (i = 0; i < block_h; i++) {
- uint16_t *tmp_cb = (uint16_t *)(dest_cb + i * uvlinesize);
- for (j = 0; j < 8; j++)
- tmp_cb[j] = get_bits(&gb, bit_depth);
- }
- for (i = 0; i < block_h; i++) {
- uint16_t *tmp_cr = (uint16_t *)(dest_cr + i * uvlinesize);
- for (j = 0; j < 8; j++)
- tmp_cr[j] = get_bits(&gb, bit_depth);
- }
- }
- }
- } else {
- for (i = 0; i < 16; i++)
- memcpy(dest_y + i * linesize, (uint8_t *)h->mb + i * 16, 16);
- if (SIMPLE || !CONFIG_GRAY || !(s->flags & CODEC_FLAG_GRAY)) {
- if (!h->sps.chroma_format_idc) {
- for (i = 0; i < 8; i++) {
- memset(dest_cb + i*uvlinesize, 1 << (bit_depth - 1), 8);
- memset(dest_cr + i*uvlinesize, 1 << (bit_depth - 1), 8);
- }
- } else {
- uint8_t *src_cb = (uint8_t *)h->mb + 256;
- uint8_t *src_cr = (uint8_t *)h->mb + 256 + block_h * 8;
- for (i = 0; i < block_h; i++) {
- memcpy(dest_cb + i * uvlinesize, src_cb + i * 8, 8);
- memcpy(dest_cr + i * uvlinesize, src_cr + i * 8, 8);
- }
- }
- }
- }
- } else {
- if (IS_INTRA(mb_type)) {
- if (h->deblocking_filter)
- xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize,
- uvlinesize, 1, 0, SIMPLE, PIXEL_SHIFT);
-
- if (SIMPLE || !CONFIG_GRAY || !(s->flags & CODEC_FLAG_GRAY)) {
- h->hpc.pred8x8[h->chroma_pred_mode](dest_cb, uvlinesize);
- h->hpc.pred8x8[h->chroma_pred_mode](dest_cr, uvlinesize);
- }
-
- hl_decode_mb_predict_luma(h, mb_type, is_h264, SIMPLE,
- transform_bypass, PIXEL_SHIFT,
- block_offset, linesize, dest_y, 0);
-
- if (h->deblocking_filter)
- xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize,
- uvlinesize, 0, 0, SIMPLE, PIXEL_SHIFT);
- } else if (is_h264) {
- if (chroma422) {
- FUNC(hl_motion_422)(h, dest_y, dest_cb, dest_cr,
- s->me.qpel_put, h->h264chroma.put_h264_chroma_pixels_tab,
- s->me.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,
- s->me.qpel_put, h->h264chroma.put_h264_chroma_pixels_tab,
- s->me.qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab,
- h->h264dsp.weight_h264_pixels_tab,
- h->h264dsp.biweight_h264_pixels_tab);
- }
- }
-
- hl_decode_mb_idct_luma(h, mb_type, is_h264, SIMPLE, transform_bypass,
- PIXEL_SHIFT, block_offset, linesize, dest_y, 0);
-
- if ((SIMPLE || !CONFIG_GRAY || !(s->flags & CODEC_FLAG_GRAY)) &&
- (h->cbp & 0x30)) {
- uint8_t *dest[2] = { dest_cb, dest_cr };
- if (transform_bypass) {
- if (IS_INTRA(mb_type) && h->sps.profile_idc == 244 &&
- (h->chroma_pred_mode == VERT_PRED8x8 ||
- h->chroma_pred_mode == HOR_PRED8x8)) {
- h->hpc.pred8x8_add[h->chroma_pred_mode](dest[0],
- block_offset + 16,
- h->mb + (16 * 16 * 1 << PIXEL_SHIFT),
- uvlinesize);
- h->hpc.pred8x8_add[h->chroma_pred_mode](dest[1],
- block_offset + 32,
- h->mb + (16 * 16 * 2 << PIXEL_SHIFT),
- uvlinesize);
- } else {
- idct_add = h->h264dsp.h264_add_pixels4;
- for (j = 1; j < 3; j++) {
- for (i = j * 16; i < j * 16 + 4; i++)
- if (h->non_zero_count_cache[scan8[i]] ||
- dctcoef_get(h->mb, PIXEL_SHIFT, i * 16))
- idct_add(dest[j - 1] + block_offset[i],
- h->mb + (i * 16 << PIXEL_SHIFT),
- uvlinesize);
- if (chroma422) {
- for (i = j * 16 + 4; i < j * 16 + 8; i++)
- if (h->non_zero_count_cache[scan8[i + 4]] ||
- dctcoef_get(h->mb, PIXEL_SHIFT, i * 16))
- idct_add(dest[j - 1] + block_offset[i + 4],
- h->mb + (i * 16 << PIXEL_SHIFT),
- uvlinesize);
- }
- }
- }
- } else {
- if (is_h264) {
- int qp[2];
- if (chroma422) {
- qp[0] = h->chroma_qp[0] + 3;
- qp[1] = h->chroma_qp[1] + 3;
- } else {
- qp[0] = h->chroma_qp[0];
- qp[1] = h->chroma_qp[1];
- }
- if (h->non_zero_count_cache[scan8[CHROMA_DC_BLOCK_INDEX + 0]])
- h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + (16 * 16 * 1 << PIXEL_SHIFT),
- h->dequant4_coeff[IS_INTRA(mb_type) ? 1 : 4][qp[0]][0]);
- if (h->non_zero_count_cache[scan8[CHROMA_DC_BLOCK_INDEX + 1]])
- h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + (16 * 16 * 2 << PIXEL_SHIFT),
- h->dequant4_coeff[IS_INTRA(mb_type) ? 2 : 5][qp[1]][0]);
- h->h264dsp.h264_idct_add8(dest, block_offset,
- h->mb, uvlinesize,
- h->non_zero_count_cache);
- } else if (CONFIG_SVQ3_DECODER) {
- h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + 16 * 16 * 1,
- h->dequant4_coeff[IS_INTRA(mb_type) ? 1 : 4][h->chroma_qp[0]][0]);
- h->h264dsp.h264_chroma_dc_dequant_idct(h->mb + 16 * 16 * 2,
- h->dequant4_coeff[IS_INTRA(mb_type) ? 2 : 5][h->chroma_qp[1]][0]);
- for (j = 1; j < 3; j++) {
- for (i = j * 16; i < j * 16 + 4; i++)
- if (h->non_zero_count_cache[scan8[i]] || h->mb[i * 16]) {
- uint8_t *const ptr = dest[j - 1] + block_offset[i];
- ff_svq3_add_idct_c(ptr, h->mb + i * 16,
- uvlinesize,
- ff_h264_chroma_qp[0][s->qscale + 12] - 12, 2);
- }
- }
- }
- }
- }
- }
- if (h->cbp || IS_INTRA(mb_type)) {
- s->dsp.clear_blocks(h->mb);
- s->dsp.clear_blocks(h->mb + (24 * 16 << PIXEL_SHIFT));
- }
-}
-
-#if !SIMPLE || BITS == 8
-
-#undef CHROMA_IDC
-#define CHROMA_IDC 3
-#include "h264_mc_template.c"
-
-static av_noinline void FUNC(hl_decode_mb_444)(H264Context *h)
-{
- MpegEncContext *const s = &h->s;
- const int mb_x = s->mb_x;
- const int mb_y = s->mb_y;
- const int mb_xy = h->mb_xy;
- const int mb_type = s->current_picture.f.mb_type[mb_xy];
- uint8_t *dest[3];
- int linesize;
- int i, j, p;
- int *block_offset = &h->block_offset[0];
- const int transform_bypass = !SIMPLE && (s->qscale == 0 && h->sps.transform_bypass);
- const int plane_count = (SIMPLE || !CONFIG_GRAY || !(s->flags & CODEC_FLAG_GRAY)) ? 3 : 1;
-
- for (p = 0; p < plane_count; p++) {
- dest[p] = s->current_picture.f.data[p] +
- ((mb_x << PIXEL_SHIFT) + mb_y * s->linesize) * 16;
- s->vdsp.prefetch(dest[p] + (s->mb_x & 3) * 4 * s->linesize + (64 << PIXEL_SHIFT),
- s->linesize, 4);
- }
-
- h->list_counts[mb_xy] = h->list_count;
-
- if (!SIMPLE && MB_FIELD) {
- linesize = h->mb_linesize = h->mb_uvlinesize = s->linesize * 2;
- block_offset = &h->block_offset[48];
- if (mb_y & 1) // FIXME move out of this function?
- for (p = 0; p < 3; p++)
- dest[p] -= s->linesize * 15;
- if (FRAME_MBAFF) {
- int list;
- for (list = 0; list < h->list_count; list++) {
- if (!USES_LIST(mb_type, list))
- continue;
- if (IS_16X16(mb_type)) {
- int8_t *ref = &h->ref_cache[list][scan8[0]];
- fill_rectangle(ref, 4, 4, 8, (16 + *ref) ^ (s->mb_y & 1), 1);
- } else {
- for (i = 0; i < 16; i += 4) {
- int ref = h->ref_cache[list][scan8[i]];
- if (ref >= 0)
- fill_rectangle(&h->ref_cache[list][scan8[i]], 2, 2,
- 8, (16 + ref) ^ (s->mb_y & 1), 1);
- }
- }
- }
- }
- } else {
- linesize = h->mb_linesize = h->mb_uvlinesize = s->linesize;
- }
-
- if (!SIMPLE && IS_INTRA_PCM(mb_type)) {
- if (PIXEL_SHIFT) {
- const int bit_depth = h->sps.bit_depth_luma;
- GetBitContext gb;
- init_get_bits(&gb, (uint8_t *)h->mb, 768 * bit_depth);
-
- for (p = 0; p < plane_count; p++)
- for (i = 0; i < 16; i++) {
- uint16_t *tmp = (uint16_t *)(dest[p] + i * linesize);
- for (j = 0; j < 16; j++)
- tmp[j] = get_bits(&gb, bit_depth);
- }
- } else {
- for (p = 0; p < plane_count; p++)
- for (i = 0; i < 16; i++)
- memcpy(dest[p] + i * linesize,
- (uint8_t *)h->mb + p * 256 + i * 16, 16);
- }
- } else {
- if (IS_INTRA(mb_type)) {
- if (h->deblocking_filter)
- xchg_mb_border(h, dest[0], dest[1], dest[2], linesize,
- linesize, 1, 1, SIMPLE, PIXEL_SHIFT);
-
- for (p = 0; p < plane_count; p++)
- hl_decode_mb_predict_luma(h, mb_type, 1, SIMPLE,
- transform_bypass, PIXEL_SHIFT,
- block_offset, linesize, dest[p], p);
-
- if (h->deblocking_filter)
- xchg_mb_border(h, dest[0], dest[1], dest[2], linesize,
- linesize, 0, 1, SIMPLE, PIXEL_SHIFT);
- } else {
- FUNC(hl_motion_444)(h, dest[0], dest[1], dest[2],
- s->me.qpel_put, h->h264chroma.put_h264_chroma_pixels_tab,
- s->me.qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab,
- h->h264dsp.weight_h264_pixels_tab,
- h->h264dsp.biweight_h264_pixels_tab);
- }
-
- for (p = 0; p < plane_count; p++)
- hl_decode_mb_idct_luma(h, mb_type, 1, SIMPLE, transform_bypass,
- PIXEL_SHIFT, block_offset, linesize,
- dest[p], p);
- }
- if (h->cbp || IS_INTRA(mb_type)) {
- s->dsp.clear_blocks(h->mb);
- s->dsp.clear_blocks(h->mb + (24 * 16 << PIXEL_SHIFT));
- }
-}
-
-#endif
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264_mc_template.c b/src/thirdparty/ffmpeg/libavcodec/h264_mc_template.c
deleted file mode 100644
index 31c7519f3..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264_mc_template.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * 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
- */
-
-#undef MCFUNC
-
-#if CHROMA_IDC == 1
-# define MCFUNC(n) FUNC(n ## _420)
-#elif CHROMA_IDC == 2
-# define MCFUNC(n) FUNC(n ## _422)
-#elif CHROMA_IDC == 3
-# define MCFUNC(n) FUNC(n ## _444)
-#endif
-
-#undef mc_part
-#define mc_part MCFUNC(mc_part)
-
-static void mc_part(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,
- h264_weight_func *weight_op,
- h264_biweight_func *weight_avg,
- int list0, int list1)
-{
- if ((h->use_weight == 2 && list0 && list1 &&
- (h->implicit_weight[h->ref_cache[0][scan8[n]]][h->ref_cache[1][scan8[n]]][h->s.mb_y & 1] != 32)) ||
- h->use_weight == 1)
- mc_part_weighted(h, n, square, height, delta, dest_y, dest_cb, dest_cr,
- x_offset, y_offset, qpix_put, chroma_put,
- weight_op[0], weight_op[1], weight_avg[0],
- weight_avg[1], list0, list1, PIXEL_SHIFT, CHROMA_IDC);
- else
- mc_part_std(h, n, square, height, delta, dest_y, dest_cb, dest_cr,
- x_offset, y_offset, qpix_put, chroma_put, qpix_avg,
- chroma_avg, list0, list1, PIXEL_SHIFT, CHROMA_IDC);
-}
-
-static void MCFUNC(hl_motion)(H264Context *h, uint8_t *dest_y,
- uint8_t *dest_cb, uint8_t *dest_cr,
- qpel_mc_func(*qpix_put)[16],
- h264_chroma_mc_func(*chroma_put),
- qpel_mc_func(*qpix_avg)[16],
- h264_chroma_mc_func(*chroma_avg),
- h264_weight_func *weight_op,
- h264_biweight_func *weight_avg)
-{
- MpegEncContext *const s = &h->s;
- const int mb_xy = h->mb_xy;
- const int mb_type = s->current_picture.f.mb_type[mb_xy];
-
- av_assert2(IS_INTER(mb_type));
-
- if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME))
- await_references(h);
- prefetch_motion(h, 0, PIXEL_SHIFT, CHROMA_IDC);
-
- if (IS_16X16(mb_type)) {
- mc_part(h, 0, 1, 16, 0, dest_y, dest_cb, dest_cr, 0, 0,
- qpix_put[0], chroma_put[0], qpix_avg[0], chroma_avg[0],
- weight_op, weight_avg,
- IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1));
- } else if (IS_16X8(mb_type)) {
- mc_part(h, 0, 0, 8, 8 << PIXEL_SHIFT, dest_y, dest_cb, dest_cr, 0, 0,
- qpix_put[1], chroma_put[0], qpix_avg[1], chroma_avg[0],
- weight_op, weight_avg,
- IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1));
- mc_part(h, 8, 0, 8, 8 << PIXEL_SHIFT, dest_y, dest_cb, dest_cr, 0, 4,
- qpix_put[1], chroma_put[0], qpix_avg[1], chroma_avg[0],
- weight_op, weight_avg,
- IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1));
- } else if (IS_8X16(mb_type)) {
- mc_part(h, 0, 0, 16, 8 * h->mb_linesize, dest_y, dest_cb, dest_cr, 0, 0,
- qpix_put[1], chroma_put[1], qpix_avg[1], chroma_avg[1],
- &weight_op[1], &weight_avg[1],
- IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1));
- mc_part(h, 4, 0, 16, 8 * h->mb_linesize, dest_y, dest_cb, dest_cr, 4, 0,
- qpix_put[1], chroma_put[1], qpix_avg[1], chroma_avg[1],
- &weight_op[1], &weight_avg[1],
- IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1));
- } 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 x_offset = (i & 1) << 2;
- int y_offset = (i & 2) << 1;
-
- if (IS_SUB_8X8(sub_mb_type)) {
- mc_part(h, n, 1, 8, 0, dest_y, dest_cb, dest_cr,
- x_offset, y_offset,
- qpix_put[1], chroma_put[1], qpix_avg[1], chroma_avg[1],
- &weight_op[1], &weight_avg[1],
- IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1));
- } else if (IS_SUB_8X4(sub_mb_type)) {
- mc_part(h, n, 0, 4, 4 << PIXEL_SHIFT, dest_y, dest_cb, dest_cr,
- x_offset, y_offset,
- qpix_put[2], chroma_put[1], qpix_avg[2], chroma_avg[1],
- &weight_op[1], &weight_avg[1],
- IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1));
- mc_part(h, n + 2, 0, 4, 4 << PIXEL_SHIFT,
- dest_y, dest_cb, dest_cr, x_offset, y_offset + 2,
- qpix_put[2], chroma_put[1], qpix_avg[2], chroma_avg[1],
- &weight_op[1], &weight_avg[1],
- IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1));
- } else if (IS_SUB_4X8(sub_mb_type)) {
- mc_part(h, n, 0, 8, 4 * h->mb_linesize,
- dest_y, dest_cb, dest_cr, x_offset, y_offset,
- qpix_put[2], chroma_put[2], qpix_avg[2], chroma_avg[2],
- &weight_op[2], &weight_avg[2],
- IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1));
- mc_part(h, n + 1, 0, 8, 4 * h->mb_linesize,
- dest_y, dest_cb, dest_cr, x_offset + 2, y_offset,
- qpix_put[2], chroma_put[2], qpix_avg[2], chroma_avg[2],
- &weight_op[2], &weight_avg[2],
- IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1));
- } else {
- int j;
- av_assert2(IS_SUB_4X4(sub_mb_type));
- for (j = 0; j < 4; j++) {
- int sub_x_offset = x_offset + 2 * (j & 1);
- int sub_y_offset = y_offset + (j & 2);
- mc_part(h, n + j, 1, 4, 0,
- dest_y, dest_cb, dest_cr, sub_x_offset, sub_y_offset,
- qpix_put[2], chroma_put[2], qpix_avg[2], chroma_avg[2],
- &weight_op[2], &weight_avg[2],
- IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1));
- }
- }
- }
- }
-
- prefetch_motion(h, 1, PIXEL_SHIFT, CHROMA_IDC);
-}
-
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264_mvpred.h b/src/thirdparty/ffmpeg/libavcodec/h264_mvpred.h
deleted file mode 100644
index 1e400f46c..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264_mvpred.h
+++ /dev/null
@@ -1,834 +0,0 @@
-/*
- * H.26L/H.264/AVC/JVT/14496-10/... motion vector predicion
- * 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 motion vector predicion.
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#ifndef AVCODEC_H264_MVPRED_H
-#define AVCODEC_H264_MVPRED_H
-
-#include "internal.h"
-#include "avcodec.h"
-#include "h264.h"
-#include "libavutil/avassert.h"
-
-
-static av_always_inline int fetch_diagonal_mv(H264Context *h, const int16_t **C,
- int i, int list, int part_width)
-{
- const int topright_ref = h->ref_cache[list][i - 8 + part_width];
- MpegEncContext *s = &h->s;
-
- /* there is no consistent mapping of mvs to neighboring locations that will
- * make mbaff happy, so we can't move all this logic to fill_caches */
- if (FRAME_MBAFF) {
-#define SET_DIAG_MV(MV_OP, REF_OP, XY, Y4) \
- const int xy = XY, y4 = Y4; \
- const int mb_type = mb_types[xy + (y4 >> 2) * s->mb_stride]; \
- if (!USES_LIST(mb_type, list)) \
- return LIST_NOT_USED; \
- mv = s->current_picture_ptr->f.motion_val[list][h->mb2b_xy[xy] + 3 + y4 * h->b_stride]; \
- h->mv_cache[list][scan8[0] - 2][0] = mv[0]; \
- h->mv_cache[list][scan8[0] - 2][1] = mv[1] MV_OP; \
- return s->current_picture_ptr->f.ref_index[list][4 * xy + 1 + (y4 & ~1)] REF_OP;
-
- if (topright_ref == PART_NOT_AVAILABLE
- && i >= scan8[0] + 8 && (i & 7) == 4
- && h->ref_cache[list][scan8[0] - 1] != PART_NOT_AVAILABLE) {
- const uint32_t *mb_types = s->current_picture_ptr->f.mb_type;
- const int16_t *mv;
- AV_ZERO32(h->mv_cache[list][scan8[0] - 2]);
- *C = h->mv_cache[list][scan8[0] - 2];
-
- if (!MB_FIELD && IS_INTERLACED(h->left_type[0])) {
- SET_DIAG_MV(* 2, >> 1, h->left_mb_xy[0] + s->mb_stride,
- (s->mb_y & 1) * 2 + (i >> 5));
- }
- if (MB_FIELD && !IS_INTERLACED(h->left_type[0])) {
- // left shift will turn LIST_NOT_USED into PART_NOT_AVAILABLE, but that's OK.
- SET_DIAG_MV(/ 2, << 1, h->left_mb_xy[i >= 36], ((i >> 2)) & 3);
- }
- }
-#undef SET_DIAG_MV
- }
-
- if (topright_ref != PART_NOT_AVAILABLE) {
- *C = h->mv_cache[list][i - 8 + part_width];
- return topright_ref;
- } else {
- tprintf(s->avctx, "topright MV not available\n");
-
- *C = h->mv_cache[list][i - 8 - 1];
- return h->ref_cache[list][i - 8 - 1];
- }
-}
-
-/**
- * Get the predicted MV.
- * @param n the block index
- * @param part_width the width of the partition (4, 8,16) -> (1, 2, 4)
- * @param mx the x component of the predicted motion vector
- * @param my the y component of the predicted motion vector
- */
-static av_always_inline void pred_motion(H264Context *const h, int n,
- int part_width, int list, int ref,
- int *const mx, int *const my)
-{
- const int index8 = scan8[n];
- const int top_ref = h->ref_cache[list][index8 - 8];
- const int left_ref = h->ref_cache[list][index8 - 1];
- const int16_t *const A = h->mv_cache[list][index8 - 1];
- const int16_t *const B = h->mv_cache[list][index8 - 8];
- const int16_t *C;
- int diagonal_ref, match_count;
-
- av_assert2(part_width == 1 || part_width == 2 || part_width == 4);
-
-/* mv_cache
- * B . . A T T T T
- * U . . L . . , .
- * U . . L . . . .
- * U . . L . . , .
- * . . . L . . . .
- */
-
- diagonal_ref = fetch_diagonal_mv(h, &C, index8, list, part_width);
- match_count = (diagonal_ref == ref) + (top_ref == ref) + (left_ref == ref);
- tprintf(h->s.avctx, "pred_motion match_count=%d\n", match_count);
- if (match_count > 1) { //most common
- *mx = mid_pred(A[0], B[0], C[0]);
- *my = mid_pred(A[1], B[1], C[1]);
- } else if (match_count == 1) {
- if (left_ref == ref) {
- *mx = A[0];
- *my = A[1];
- } else if (top_ref == ref) {
- *mx = B[0];
- *my = B[1];
- } else {
- *mx = C[0];
- *my = C[1];
- }
- } else {
- if (top_ref == PART_NOT_AVAILABLE &&
- diagonal_ref == PART_NOT_AVAILABLE &&
- left_ref != PART_NOT_AVAILABLE) {
- *mx = A[0];
- *my = A[1];
- } else {
- *mx = mid_pred(A[0], B[0], C[0]);
- *my = mid_pred(A[1], B[1], C[1]);
- }
- }
-
- tprintf(h->s.avctx,
- "pred_motion (%2d %2d %2d) (%2d %2d %2d) (%2d %2d %2d) -> (%2d %2d %2d) at %2d %2d %d list %d\n",
- top_ref, B[0], B[1], diagonal_ref, C[0], C[1], left_ref,
- A[0], A[1], ref, *mx, *my, h->s.mb_x, h->s.mb_y, n, list);
-}
-
-/**
- * Get the directionally predicted 16x8 MV.
- * @param n the block index
- * @param mx the x component of the predicted motion vector
- * @param my the y component of the predicted motion vector
- */
-static av_always_inline void pred_16x8_motion(H264Context *const h,
- int n, int list, int ref,
- int *const mx, int *const my)
-{
- if (n == 0) {
- const int top_ref = h->ref_cache[list][scan8[0] - 8];
- const int16_t *const B = h->mv_cache[list][scan8[0] - 8];
-
- tprintf(h->s.avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n",
- top_ref, B[0], B[1], h->s.mb_x, h->s.mb_y, n, list);
-
- if (top_ref == ref) {
- *mx = B[0];
- *my = B[1];
- return;
- }
- } else {
- const int left_ref = h->ref_cache[list][scan8[8] - 1];
- const int16_t *const A = h->mv_cache[list][scan8[8] - 1];
-
- tprintf(h->s.avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n",
- left_ref, A[0], A[1], h->s.mb_x, h->s.mb_y, n, list);
-
- if (left_ref == ref) {
- *mx = A[0];
- *my = A[1];
- return;
- }
- }
-
- //RARE
- pred_motion(h, n, 4, list, ref, mx, my);
-}
-
-/**
- * Get the directionally predicted 8x16 MV.
- * @param n the block index
- * @param mx the x component of the predicted motion vector
- * @param my the y component of the predicted motion vector
- */
-static av_always_inline void pred_8x16_motion(H264Context *const h,
- int n, int list, int ref,
- int *const mx, int *const my)
-{
- if (n == 0) {
- const int left_ref = h->ref_cache[list][scan8[0] - 1];
- const int16_t *const A = h->mv_cache[list][scan8[0] - 1];
-
- tprintf(h->s.avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n",
- left_ref, A[0], A[1], h->s.mb_x, h->s.mb_y, n, list);
-
- if (left_ref == ref) {
- *mx = A[0];
- *my = A[1];
- return;
- }
- } else {
- const int16_t *C;
- int diagonal_ref;
-
- diagonal_ref = fetch_diagonal_mv(h, &C, scan8[4], list, 2);
-
- tprintf(h->s.avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n",
- diagonal_ref, C[0], C[1], h->s.mb_x, h->s.mb_y, n, list);
-
- if (diagonal_ref == ref) {
- *mx = C[0];
- *my = C[1];
- return;
- }
- }
-
- //RARE
- pred_motion(h, n, 2, list, ref, mx, my);
-}
-
-#define FIX_MV_MBAFF(type, refn, mvn, idx) \
- if (FRAME_MBAFF) { \
- if (MB_FIELD) { \
- if (!IS_INTERLACED(type)) { \
- refn <<= 1; \
- AV_COPY32(mvbuf[idx], mvn); \
- mvbuf[idx][1] /= 2; \
- mvn = mvbuf[idx]; \
- } \
- } else { \
- if (IS_INTERLACED(type)) { \
- refn >>= 1; \
- AV_COPY32(mvbuf[idx], mvn); \
- mvbuf[idx][1] <<= 1; \
- mvn = mvbuf[idx]; \
- } \
- } \
- }
-
-static av_always_inline void pred_pskip_motion(H264Context *const h)
-{
- DECLARE_ALIGNED(4, static const int16_t, zeromv)[2] = { 0 };
- DECLARE_ALIGNED(4, int16_t, mvbuf)[3][2];
- MpegEncContext *const s = &h->s;
- int8_t *ref = s->current_picture.f.ref_index[0];
- int16_t(*mv)[2] = s->current_picture.f.motion_val[0];
- int top_ref, left_ref, diagonal_ref, match_count, mx, my;
- const int16_t *A, *B, *C;
- int b_stride = h->b_stride;
-
- fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, 0, 1);
-
- /* To avoid doing an entire fill_decode_caches, we inline the relevant
- * parts here.
- * FIXME: this is a partial duplicate of the logic in fill_decode_caches,
- * but it's faster this way. Is there a way to avoid this duplication?
- */
- if (USES_LIST(h->left_type[LTOP], 0)) {
- left_ref = ref[4 * h->left_mb_xy[LTOP] + 1 + (h->left_block[0] & ~1)];
- A = mv[h->mb2b_xy[h->left_mb_xy[LTOP]] + 3 + b_stride * h->left_block[0]];
- FIX_MV_MBAFF(h->left_type[LTOP], left_ref, A, 0);
- if (!(left_ref | AV_RN32A(A)))
- goto zeromv;
- } else if (h->left_type[LTOP]) {
- left_ref = LIST_NOT_USED;
- A = zeromv;
- } else {
- goto zeromv;
- }
-
- if (USES_LIST(h->top_type, 0)) {
- top_ref = ref[4 * h->top_mb_xy + 2];
- B = mv[h->mb2b_xy[h->top_mb_xy] + 3 * b_stride];
- FIX_MV_MBAFF(h->top_type, top_ref, B, 1);
- if (!(top_ref | AV_RN32A(B)))
- goto zeromv;
- } else if (h->top_type) {
- top_ref = LIST_NOT_USED;
- B = zeromv;
- } else {
- goto zeromv;
- }
-
- tprintf(h->s.avctx, "pred_pskip: (%d) (%d) at %2d %2d\n",
- top_ref, left_ref, h->s.mb_x, h->s.mb_y);
-
- if (USES_LIST(h->topright_type, 0)) {
- diagonal_ref = ref[4 * h->topright_mb_xy + 2];
- C = mv[h->mb2b_xy[h->topright_mb_xy] + 3 * b_stride];
- FIX_MV_MBAFF(h->topright_type, diagonal_ref, C, 2);
- } else if (h->topright_type) {
- diagonal_ref = LIST_NOT_USED;
- C = zeromv;
- } else {
- if (USES_LIST(h->topleft_type, 0)) {
- diagonal_ref = ref[4 * h->topleft_mb_xy + 1 +
- (h->topleft_partition & 2)];
- C = mv[h->mb2b_xy[h->topleft_mb_xy] + 3 + b_stride +
- (h->topleft_partition & 2 * b_stride)];
- FIX_MV_MBAFF(h->topleft_type, diagonal_ref, C, 2);
- } else if (h->topleft_type) {
- diagonal_ref = LIST_NOT_USED;
- C = zeromv;
- } else {
- diagonal_ref = PART_NOT_AVAILABLE;
- C = zeromv;
- }
- }
-
- match_count = !diagonal_ref + !top_ref + !left_ref;
- tprintf(h->s.avctx, "pred_pskip_motion match_count=%d\n", match_count);
- if (match_count > 1) {
- mx = mid_pred(A[0], B[0], C[0]);
- my = mid_pred(A[1], B[1], C[1]);
- } else if (match_count == 1) {
- if (!left_ref) {
- mx = A[0];
- my = A[1];
- } else if (!top_ref) {
- mx = B[0];
- my = B[1];
- } else {
- mx = C[0];
- my = C[1];
- }
- } else {
- mx = mid_pred(A[0], B[0], C[0]);
- my = mid_pred(A[1], B[1], C[1]);
- }
-
- fill_rectangle(h->mv_cache[0][scan8[0]], 4, 4, 8, pack16to32(mx, my), 4);
- return;
-
-zeromv:
- fill_rectangle(h->mv_cache[0][scan8[0]], 4, 4, 8, 0, 4);
- return;
-}
-
-static void fill_decode_neighbors(H264Context *h, int mb_type)
-{
- MpegEncContext *const s = &h->s;
- const int mb_xy = h->mb_xy;
- int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS];
- static const uint8_t left_block_options[4][32] = {
- { 0, 1, 2, 3, 7, 10, 8, 11, 3 + 0 * 4, 3 + 1 * 4, 3 + 2 * 4, 3 + 3 * 4, 1 + 4 * 4, 1 + 8 * 4, 1 + 5 * 4, 1 + 9 * 4 },
- { 2, 2, 3, 3, 8, 11, 8, 11, 3 + 2 * 4, 3 + 2 * 4, 3 + 3 * 4, 3 + 3 * 4, 1 + 5 * 4, 1 + 9 * 4, 1 + 5 * 4, 1 + 9 * 4 },
- { 0, 0, 1, 1, 7, 10, 7, 10, 3 + 0 * 4, 3 + 0 * 4, 3 + 1 * 4, 3 + 1 * 4, 1 + 4 * 4, 1 + 8 * 4, 1 + 4 * 4, 1 + 8 * 4 },
- { 0, 2, 0, 2, 7, 10, 7, 10, 3 + 0 * 4, 3 + 2 * 4, 3 + 0 * 4, 3 + 2 * 4, 1 + 4 * 4, 1 + 8 * 4, 1 + 4 * 4, 1 + 8 * 4 }
- };
-
- h->topleft_partition = -1;
-
- top_xy = mb_xy - (s->mb_stride << MB_FIELD);
-
- /* Wow, what a mess, why didn't they simplify the interlacing & intra
- * stuff, I can't imagine that these complex rules are worth it. */
-
- topleft_xy = top_xy - 1;
- topright_xy = top_xy + 1;
- left_xy[LBOT] = left_xy[LTOP] = mb_xy - 1;
- h->left_block = left_block_options[0];
- if (FRAME_MBAFF) {
- const int left_mb_field_flag = IS_INTERLACED(s->current_picture.f.mb_type[mb_xy - 1]);
- const int curr_mb_field_flag = IS_INTERLACED(mb_type);
- if (s->mb_y & 1) {
- if (left_mb_field_flag != curr_mb_field_flag) {
- left_xy[LBOT] = left_xy[LTOP] = mb_xy - s->mb_stride - 1;
- if (curr_mb_field_flag) {
- left_xy[LBOT] += s->mb_stride;
- h->left_block = left_block_options[3];
- } else {
- topleft_xy += s->mb_stride;
- /* take top left mv from the middle of the mb, as opposed
- * to all other modes which use the bottom right partition */
- h->topleft_partition = 0;
- h->left_block = left_block_options[1];
- }
- }
- } else {
- if (curr_mb_field_flag) {
- topleft_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy - 1] >> 7) & 1) - 1);
- topright_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy + 1] >> 7) & 1) - 1);
- top_xy += s->mb_stride & (((s->current_picture.f.mb_type[top_xy] >> 7) & 1) - 1);
- }
- if (left_mb_field_flag != curr_mb_field_flag) {
- if (curr_mb_field_flag) {
- left_xy[LBOT] += s->mb_stride;
- h->left_block = left_block_options[3];
- } else {
- h->left_block = left_block_options[2];
- }
- }
- }
- }
-
- h->topleft_mb_xy = topleft_xy;
- h->top_mb_xy = top_xy;
- h->topright_mb_xy = topright_xy;
- h->left_mb_xy[LTOP] = left_xy[LTOP];
- h->left_mb_xy[LBOT] = left_xy[LBOT];
- //FIXME do we need all in the context?
-
- h->topleft_type = s->current_picture.f.mb_type[topleft_xy];
- h->top_type = s->current_picture.f.mb_type[top_xy];
- h->topright_type = s->current_picture.f.mb_type[topright_xy];
- h->left_type[LTOP] = s->current_picture.f.mb_type[left_xy[LTOP]];
- h->left_type[LBOT] = s->current_picture.f.mb_type[left_xy[LBOT]];
-
- if (FMO) {
- if (h->slice_table[topleft_xy] != h->slice_num)
- h->topleft_type = 0;
- if (h->slice_table[top_xy] != h->slice_num)
- h->top_type = 0;
- if (h->slice_table[left_xy[LTOP]] != h->slice_num)
- h->left_type[LTOP] = h->left_type[LBOT] = 0;
- } else {
- if (h->slice_table[topleft_xy] != h->slice_num) {
- h->topleft_type = 0;
- if (h->slice_table[top_xy] != h->slice_num)
- h->top_type = 0;
- if (h->slice_table[left_xy[LTOP]] != h->slice_num)
- h->left_type[LTOP] = h->left_type[LBOT] = 0;
- }
- }
- if (h->slice_table[topright_xy] != h->slice_num)
- h->topright_type = 0;
-}
-
-static void fill_decode_caches(H264Context *h, int mb_type)
-{
- MpegEncContext *const s = &h->s;
- int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS];
- int topleft_type, top_type, topright_type, left_type[LEFT_MBS];
- const uint8_t *left_block = h->left_block;
- int i;
- uint8_t *nnz;
- uint8_t *nnz_cache;
-
- topleft_xy = h->topleft_mb_xy;
- top_xy = h->top_mb_xy;
- topright_xy = h->topright_mb_xy;
- left_xy[LTOP] = h->left_mb_xy[LTOP];
- left_xy[LBOT] = h->left_mb_xy[LBOT];
- topleft_type = h->topleft_type;
- top_type = h->top_type;
- topright_type = h->topright_type;
- left_type[LTOP] = h->left_type[LTOP];
- left_type[LBOT] = h->left_type[LBOT];
-
- if (!IS_SKIP(mb_type)) {
- if (IS_INTRA(mb_type)) {
- int type_mask = h->pps.constrained_intra_pred ? IS_INTRA(-1) : -1;
- h->topleft_samples_available =
- h->top_samples_available =
- h->left_samples_available = 0xFFFF;
- h->topright_samples_available = 0xEEEA;
-
- if (!(top_type & type_mask)) {
- h->topleft_samples_available = 0xB3FF;
- h->top_samples_available = 0x33FF;
- h->topright_samples_available = 0x26EA;
- }
- if (IS_INTERLACED(mb_type) != IS_INTERLACED(left_type[LTOP])) {
- if (IS_INTERLACED(mb_type)) {
- if (!(left_type[LTOP] & type_mask)) {
- h->topleft_samples_available &= 0xDFFF;
- h->left_samples_available &= 0x5FFF;
- }
- if (!(left_type[LBOT] & type_mask)) {
- h->topleft_samples_available &= 0xFF5F;
- h->left_samples_available &= 0xFF5F;
- }
- } else {
- int left_typei = s->current_picture.f.mb_type[left_xy[LTOP] + s->mb_stride];
-
- av_assert2(left_xy[LTOP] == left_xy[LBOT]);
- if (!((left_typei & type_mask) && (left_type[LTOP] & type_mask))) {
- h->topleft_samples_available &= 0xDF5F;
- h->left_samples_available &= 0x5F5F;
- }
- }
- } else {
- if (!(left_type[LTOP] & type_mask)) {
- h->topleft_samples_available &= 0xDF5F;
- h->left_samples_available &= 0x5F5F;
- }
- }
-
- if (!(topleft_type & type_mask))
- h->topleft_samples_available &= 0x7FFF;
-
- if (!(topright_type & type_mask))
- h->topright_samples_available &= 0xFBFF;
-
- if (IS_INTRA4x4(mb_type)) {
- if (IS_INTRA4x4(top_type)) {
- AV_COPY32(h->intra4x4_pred_mode_cache + 4 + 8 * 0, h->intra4x4_pred_mode + h->mb2br_xy[top_xy]);
- } else {
- h->intra4x4_pred_mode_cache[4 + 8 * 0] =
- h->intra4x4_pred_mode_cache[5 + 8 * 0] =
- h->intra4x4_pred_mode_cache[6 + 8 * 0] =
- h->intra4x4_pred_mode_cache[7 + 8 * 0] = 2 - 3 * !(top_type & type_mask);
- }
- for (i = 0; i < 2; i++) {
- if (IS_INTRA4x4(left_type[LEFT(i)])) {
- int8_t *mode = h->intra4x4_pred_mode + h->mb2br_xy[left_xy[LEFT(i)]];
- h->intra4x4_pred_mode_cache[3 + 8 * 1 + 2 * 8 * i] = mode[6 - left_block[0 + 2 * i]];
- h->intra4x4_pred_mode_cache[3 + 8 * 2 + 2 * 8 * i] = mode[6 - left_block[1 + 2 * i]];
- } else {
- h->intra4x4_pred_mode_cache[3 + 8 * 1 + 2 * 8 * i] =
- h->intra4x4_pred_mode_cache[3 + 8 * 2 + 2 * 8 * i] = 2 - 3 * !(left_type[LEFT(i)] & type_mask);
- }
- }
- }
- }
-
- /*
- * 0 . T T. T T T T
- * 1 L . .L . . . .
- * 2 L . .L . . . .
- * 3 . T TL . . . .
- * 4 L . .L . . . .
- * 5 L . .. . . . .
- */
- /* FIXME: constraint_intra_pred & partitioning & nnz
- * (let us hope this is just a typo in the spec) */
- nnz_cache = h->non_zero_count_cache;
- if (top_type) {
- nnz = h->non_zero_count[top_xy];
- AV_COPY32(&nnz_cache[4 + 8 * 0], &nnz[4 * 3]);
- if (!s->chroma_y_shift) {
- AV_COPY32(&nnz_cache[4 + 8 * 5], &nnz[4 * 7]);
- AV_COPY32(&nnz_cache[4 + 8 * 10], &nnz[4 * 11]);
- } else {
- AV_COPY32(&nnz_cache[4 + 8 * 5], &nnz[4 * 5]);
- AV_COPY32(&nnz_cache[4 + 8 * 10], &nnz[4 * 9]);
- }
- } else {
- uint32_t top_empty = CABAC && !IS_INTRA(mb_type) ? 0 : 0x40404040;
- AV_WN32A(&nnz_cache[4 + 8 * 0], top_empty);
- AV_WN32A(&nnz_cache[4 + 8 * 5], top_empty);
- AV_WN32A(&nnz_cache[4 + 8 * 10], top_empty);
- }
-
- for (i = 0; i < 2; i++) {
- if (left_type[LEFT(i)]) {
- nnz = h->non_zero_count[left_xy[LEFT(i)]];
- nnz_cache[3 + 8 * 1 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i]];
- nnz_cache[3 + 8 * 2 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i]];
- if (CHROMA444) {
- nnz_cache[3 + 8 * 6 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] + 4 * 4];
- nnz_cache[3 + 8 * 7 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] + 4 * 4];
- nnz_cache[3 + 8 * 11 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] + 8 * 4];
- nnz_cache[3 + 8 * 12 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] + 8 * 4];
- } else if (CHROMA422) {
- nnz_cache[3 + 8 * 6 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] - 2 + 4 * 4];
- nnz_cache[3 + 8 * 7 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] - 2 + 4 * 4];
- nnz_cache[3 + 8 * 11 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] - 2 + 8 * 4];
- nnz_cache[3 + 8 * 12 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] - 2 + 8 * 4];
- } else {
- nnz_cache[3 + 8 * 6 + 8 * i] = nnz[left_block[8 + 4 + 2 * i]];
- nnz_cache[3 + 8 * 11 + 8 * i] = nnz[left_block[8 + 5 + 2 * i]];
- }
- } else {
- nnz_cache[3 + 8 * 1 + 2 * 8 * i] =
- nnz_cache[3 + 8 * 2 + 2 * 8 * i] =
- nnz_cache[3 + 8 * 6 + 2 * 8 * i] =
- nnz_cache[3 + 8 * 7 + 2 * 8 * i] =
- nnz_cache[3 + 8 * 11 + 2 * 8 * i] =
- nnz_cache[3 + 8 * 12 + 2 * 8 * i] = CABAC && !IS_INTRA(mb_type) ? 0 : 64;
- }
- }
-
- if (CABAC) {
- // top_cbp
- if (top_type)
- h->top_cbp = h->cbp_table[top_xy];
- else
- h->top_cbp = IS_INTRA(mb_type) ? 0x7CF : 0x00F;
- // left_cbp
- if (left_type[LTOP]) {
- h->left_cbp = (h->cbp_table[left_xy[LTOP]] & 0x7F0) |
- ((h->cbp_table[left_xy[LTOP]] >> (left_block[0] & (~1))) & 2) |
- (((h->cbp_table[left_xy[LBOT]] >> (left_block[2] & (~1))) & 2) << 2);
- } else {
- h->left_cbp = IS_INTRA(mb_type) ? 0x7CF : 0x00F;
- }
- }
- }
-
- if (IS_INTER(mb_type) || (IS_DIRECT(mb_type) && h->direct_spatial_mv_pred)) {
- int list;
- int b_stride = h->b_stride;
- for (list = 0; list < h->list_count; list++) {
- int8_t *ref_cache = &h->ref_cache[list][scan8[0]];
- int8_t *ref = s->current_picture.f.ref_index[list];
- int16_t(*mv_cache)[2] = &h->mv_cache[list][scan8[0]];
- int16_t(*mv)[2] = s->current_picture.f.motion_val[list];
- if (!USES_LIST(mb_type, list))
- continue;
- av_assert2(!(IS_DIRECT(mb_type) && !h->direct_spatial_mv_pred));
-
- if (USES_LIST(top_type, list)) {
- const int b_xy = h->mb2b_xy[top_xy] + 3 * b_stride;
- AV_COPY128(mv_cache[0 - 1 * 8], mv[b_xy + 0]);
- ref_cache[0 - 1 * 8] =
- ref_cache[1 - 1 * 8] = ref[4 * top_xy + 2];
- ref_cache[2 - 1 * 8] =
- ref_cache[3 - 1 * 8] = ref[4 * top_xy + 3];
- } else {
- AV_ZERO128(mv_cache[0 - 1 * 8]);
- AV_WN32A(&ref_cache[0 - 1 * 8],
- ((top_type ? LIST_NOT_USED : PART_NOT_AVAILABLE) & 0xFF) * 0x01010101u);
- }
-
- if (mb_type & (MB_TYPE_16x8 | MB_TYPE_8x8)) {
- for (i = 0; i < 2; i++) {
- int cache_idx = -1 + i * 2 * 8;
- if (USES_LIST(left_type[LEFT(i)], list)) {
- const int b_xy = h->mb2b_xy[left_xy[LEFT(i)]] + 3;
- const int b8_xy = 4 * left_xy[LEFT(i)] + 1;
- AV_COPY32(mv_cache[cache_idx],
- mv[b_xy + b_stride * left_block[0 + i * 2]]);
- AV_COPY32(mv_cache[cache_idx + 8],
- mv[b_xy + b_stride * left_block[1 + i * 2]]);
- ref_cache[cache_idx] = ref[b8_xy + (left_block[0 + i * 2] & ~1)];
- ref_cache[cache_idx + 8] = ref[b8_xy + (left_block[1 + i * 2] & ~1)];
- } else {
- AV_ZERO32(mv_cache[cache_idx]);
- AV_ZERO32(mv_cache[cache_idx + 8]);
- ref_cache[cache_idx] =
- ref_cache[cache_idx + 8] = (left_type[LEFT(i)]) ? LIST_NOT_USED
- : PART_NOT_AVAILABLE;
- }
- }
- } else {
- 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;
- AV_COPY32(mv_cache[-1], mv[b_xy + b_stride * left_block[0]]);
- ref_cache[-1] = ref[b8_xy + (left_block[0] & ~1)];
- } else {
- AV_ZERO32(mv_cache[-1]);
- ref_cache[-1] = left_type[LTOP] ? LIST_NOT_USED
- : PART_NOT_AVAILABLE;
- }
- }
-
- if (USES_LIST(topright_type, list)) {
- const int b_xy = h->mb2b_xy[topright_xy] + 3 * b_stride;
- AV_COPY32(mv_cache[4 - 1 * 8], mv[b_xy]);
- ref_cache[4 - 1 * 8] = ref[4 * topright_xy + 2];
- } else {
- AV_ZERO32(mv_cache[4 - 1 * 8]);
- ref_cache[4 - 1 * 8] = topright_type ? LIST_NOT_USED
- : PART_NOT_AVAILABLE;
- }
- if(ref_cache[2 - 1*8] < 0 || ref_cache[4 - 1*8] < 0){
- if (USES_LIST(topleft_type, list)) {
- const int b_xy = h->mb2b_xy[topleft_xy] + 3 + b_stride +
- (h->topleft_partition & 2 * b_stride);
- const int b8_xy = 4 * topleft_xy + 1 + (h->topleft_partition & 2);
- AV_COPY32(mv_cache[-1 - 1 * 8], mv[b_xy]);
- ref_cache[-1 - 1 * 8] = ref[b8_xy];
- } else {
- AV_ZERO32(mv_cache[-1 - 1 * 8]);
- ref_cache[-1 - 1 * 8] = topleft_type ? LIST_NOT_USED
- : PART_NOT_AVAILABLE;
- }
- }
-
- if ((mb_type & (MB_TYPE_SKIP | MB_TYPE_DIRECT2)) && !FRAME_MBAFF)
- continue;
-
- if (!(mb_type & (MB_TYPE_SKIP | MB_TYPE_DIRECT2))) {
- uint8_t(*mvd_cache)[2] = &h->mvd_cache[list][scan8[0]];
- uint8_t(*mvd)[2] = h->mvd_table[list];
- ref_cache[2 + 8 * 0] =
- ref_cache[2 + 8 * 2] = PART_NOT_AVAILABLE;
- AV_ZERO32(mv_cache[2 + 8 * 0]);
- AV_ZERO32(mv_cache[2 + 8 * 2]);
-
- if (CABAC) {
- if (USES_LIST(top_type, list)) {
- const int b_xy = h->mb2br_xy[top_xy];
- AV_COPY64(mvd_cache[0 - 1 * 8], mvd[b_xy + 0]);
- } else {
- AV_ZERO64(mvd_cache[0 - 1 * 8]);
- }
- if (USES_LIST(left_type[LTOP], list)) {
- const int b_xy = h->mb2br_xy[left_xy[LTOP]] + 6;
- AV_COPY16(mvd_cache[-1 + 0 * 8], mvd[b_xy - left_block[0]]);
- AV_COPY16(mvd_cache[-1 + 1 * 8], mvd[b_xy - left_block[1]]);
- } else {
- AV_ZERO16(mvd_cache[-1 + 0 * 8]);
- AV_ZERO16(mvd_cache[-1 + 1 * 8]);
- }
- if (USES_LIST(left_type[LBOT], list)) {
- const int b_xy = h->mb2br_xy[left_xy[LBOT]] + 6;
- AV_COPY16(mvd_cache[-1 + 2 * 8], mvd[b_xy - left_block[2]]);
- AV_COPY16(mvd_cache[-1 + 3 * 8], mvd[b_xy - left_block[3]]);
- } else {
- AV_ZERO16(mvd_cache[-1 + 2 * 8]);
- AV_ZERO16(mvd_cache[-1 + 3 * 8]);
- }
- AV_ZERO16(mvd_cache[2 + 8 * 0]);
- AV_ZERO16(mvd_cache[2 + 8 * 2]);
- if (h->slice_type_nos == AV_PICTURE_TYPE_B) {
- uint8_t *direct_cache = &h->direct_cache[scan8[0]];
- uint8_t *direct_table = h->direct_table;
- fill_rectangle(direct_cache, 4, 4, 8, MB_TYPE_16x16 >> 1, 1);
-
- if (IS_DIRECT(top_type)) {
- AV_WN32A(&direct_cache[-1 * 8],
- 0x01010101u * (MB_TYPE_DIRECT2 >> 1));
- } else if (IS_8X8(top_type)) {
- int b8_xy = 4 * top_xy;
- direct_cache[0 - 1 * 8] = direct_table[b8_xy + 2];
- direct_cache[2 - 1 * 8] = direct_table[b8_xy + 3];
- } else {
- AV_WN32A(&direct_cache[-1 * 8],
- 0x01010101 * (MB_TYPE_16x16 >> 1));
- }
-
- if (IS_DIRECT(left_type[LTOP]))
- direct_cache[-1 + 0 * 8] = MB_TYPE_DIRECT2 >> 1;
- else if (IS_8X8(left_type[LTOP]))
- direct_cache[-1 + 0 * 8] = direct_table[4 * left_xy[LTOP] + 1 + (left_block[0] & ~1)];
- else
- direct_cache[-1 + 0 * 8] = MB_TYPE_16x16 >> 1;
-
- if (IS_DIRECT(left_type[LBOT]))
- direct_cache[-1 + 2 * 8] = MB_TYPE_DIRECT2 >> 1;
- else if (IS_8X8(left_type[LBOT]))
- direct_cache[-1 + 2 * 8] = direct_table[4 * left_xy[LBOT] + 1 + (left_block[2] & ~1)];
- else
- direct_cache[-1 + 2 * 8] = MB_TYPE_16x16 >> 1;
- }
- }
- }
-
-#define MAP_MVS \
- MAP_F2F(scan8[0] - 1 - 1 * 8, topleft_type) \
- MAP_F2F(scan8[0] + 0 - 1 * 8, top_type) \
- MAP_F2F(scan8[0] + 1 - 1 * 8, top_type) \
- MAP_F2F(scan8[0] + 2 - 1 * 8, top_type) \
- MAP_F2F(scan8[0] + 3 - 1 * 8, top_type) \
- MAP_F2F(scan8[0] + 4 - 1 * 8, topright_type) \
- MAP_F2F(scan8[0] - 1 + 0 * 8, left_type[LTOP]) \
- MAP_F2F(scan8[0] - 1 + 1 * 8, left_type[LTOP]) \
- MAP_F2F(scan8[0] - 1 + 2 * 8, left_type[LBOT]) \
- MAP_F2F(scan8[0] - 1 + 3 * 8, left_type[LBOT])
-
- if (FRAME_MBAFF) {
- if (MB_FIELD) {
-
-#define MAP_F2F(idx, mb_type) \
- if (!IS_INTERLACED(mb_type) && h->ref_cache[list][idx] >= 0) { \
- h->ref_cache[list][idx] <<= 1; \
- h->mv_cache[list][idx][1] /= 2; \
- h->mvd_cache[list][idx][1] >>= 1; \
- }
-
- MAP_MVS
- } else {
-
-#undef MAP_F2F
-#define MAP_F2F(idx, mb_type) \
- if (IS_INTERLACED(mb_type) && h->ref_cache[list][idx] >= 0) { \
- h->ref_cache[list][idx] >>= 1; \
- h->mv_cache[list][idx][1] <<= 1; \
- h->mvd_cache[list][idx][1] <<= 1; \
- }
-
- MAP_MVS
-#undef MAP_F2F
- }
- }
- }
- }
-
- h->neighbor_transform_size = !!IS_8x8DCT(top_type) + !!IS_8x8DCT(left_type[LTOP]);
-}
-
-/**
- * decodes a P_SKIP or B_SKIP macroblock
- */
-static void av_unused decode_mb_skip(H264Context *h)
-{
- MpegEncContext *const s = &h->s;
- const int mb_xy = h->mb_xy;
- int mb_type = 0;
-
- memset(h->non_zero_count[mb_xy], 0, 48);
-
- if (MB_FIELD)
- mb_type |= MB_TYPE_INTERLACED;
-
- if (h->slice_type_nos == AV_PICTURE_TYPE_B) {
- // just for fill_caches. pred_direct_motion will set the real mb_type
- mb_type |= MB_TYPE_L0L1 | MB_TYPE_DIRECT2 | MB_TYPE_SKIP;
- if (h->direct_spatial_mv_pred) {
- fill_decode_neighbors(h, mb_type);
- fill_decode_caches(h, mb_type); //FIXME check what is needed and what not ...
- }
- ff_h264_pred_direct_motion(h, &mb_type);
- mb_type |= MB_TYPE_SKIP;
- } else {
- mb_type |= MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_SKIP;
-
- fill_decode_neighbors(h, mb_type);
- pred_pskip_motion(h);
- }
-
- write_back_motion(h, mb_type);
- s->current_picture.f.mb_type[mb_xy] = mb_type;
- s->current_picture.f.qscale_table[mb_xy] = s->qscale;
- h->slice_table[mb_xy] = h->slice_num;
- h->prev_mb_skipped = 1;
-}
-
-#endif /* AVCODEC_H264_MVPRED_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264_parser.c b/src/thirdparty/ffmpeg/libavcodec/h264_parser.c
deleted file mode 100644
index 599c0944b..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264_parser.c
+++ /dev/null
@@ -1,398 +0,0 @@
-/*
- * H.26L/H.264/AVC/JVT/14496-10/... parser
- * 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 parser.
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#define UNCHECKED_BITSTREAM_READER 1
-
-#include "parser.h"
-#include "h264data.h"
-#include "golomb.h"
-
-
-static int ff_h264_find_frame_end(H264Context *h, const uint8_t *buf, int buf_size)
-{
- int i, j;
- uint32_t state;
- ParseContext *pc = &(h->s.parse_context);
- int next_avc= h->is_avc ? 0 : buf_size;
-
-// mb_addr= pc->mb_addr - 1;
- state= pc->state;
- if(state>13)
- state= 7;
-
- if(h->is_avc && !h->nal_length_size)
- av_log(h->s.avctx, AV_LOG_ERROR, "AVC-parser: nal length size invalid\n");
-
- for(i=0; i<buf_size; i++){
- if(i >= next_avc) {
- int nalsize = 0;
- i = next_avc;
- for(j = 0; j < h->nal_length_size; j++)
- nalsize = (nalsize << 8) | buf[i++];
- if(nalsize <= 0 || nalsize > buf_size - i){
- av_log(h->s.avctx, AV_LOG_ERROR, "AVC-parser: nal size %d remaining %d\n", nalsize, buf_size - i);
- return buf_size;
- }
- next_avc= i + nalsize;
- state= 5;
- }
-
- if(state==7){
-#if HAVE_FAST_UNALIGNED
- /* we check i<buf_size instead of i+3/7 because its simpler
- * and there should be FF_INPUT_BUFFER_PADDING_SIZE bytes at the end
- */
-# if HAVE_FAST_64BIT
- while(i<next_avc && !((~*(const uint64_t*)(buf+i) & (*(const uint64_t*)(buf+i) - 0x0101010101010101ULL)) & 0x8080808080808080ULL))
- i+=8;
-# else
- while(i<next_avc && !((~*(const uint32_t*)(buf+i) & (*(const uint32_t*)(buf+i) - 0x01010101U)) & 0x80808080U))
- i+=4;
-# endif
-#endif
- for(; i<next_avc; i++){
- if(!buf[i]){
- state=2;
- break;
- }
- }
- }else if(state<=2){
- if(buf[i]==1) state^= 5; //2->7, 1->4, 0->5
- else if(buf[i]) state = 7;
- 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){
- if(pc->frame_start_found){
- i++;
- goto found;
- }
- }else if(v==1 || v==2 || v==5){
- state+=8;
- continue;
- }
- state= 7;
- }else{
- h->parse_history[h->parse_history_count++]= buf[i];
- if(h->parse_history_count>3){
- unsigned int mb, last_mb= h->parse_last_mb;
- GetBitContext gb;
-
- init_get_bits(&gb, h->parse_history, 8*h->parse_history_count);
- h->parse_history_count=0;
- mb= get_ue_golomb_long(&gb);
- last_mb= h->parse_last_mb;
- h->parse_last_mb= mb;
- if(pc->frame_start_found){
- if(mb <= last_mb)
- goto found;
- }else
- pc->frame_start_found = 1;
- state= 7;
- }
- }
- }
- pc->state= state;
- if(h->is_avc)
- return next_avc;
- return END_NOT_FOUND;
-
-found:
- pc->state=7;
- pc->frame_start_found= 0;
- if(h->is_avc)
- return next_avc;
- return i-(state&5) - 3*(state>7);
-}
-
-/**
- * Parse NAL units of found picture and decode some basic information.
- *
- * @param s parser context.
- * @param avctx codec context.
- * @param buf buffer with field/frame data.
- * @param buf_size size of the buffer.
- */
-static inline int parse_nal_units(AVCodecParserContext *s,
- AVCodecContext *avctx,
- const uint8_t *buf, int buf_size)
-{
- H264Context *h = s->priv_data;
- const uint8_t *buf_end = buf + buf_size;
- unsigned int pps_id;
- unsigned int slice_type;
- int state = -1;
- const uint8_t *ptr;
- int q264 = buf_size >=4 && !memcmp("Q264", buf, 4);
-
- /* set some sane default values */
- s->pict_type = AV_PICTURE_TYPE_I;
- s->key_frame = 0;
-
- h->s.avctx= avctx;
- h->sei_recovery_frame_cnt = -1;
- h->sei_dpb_output_delay = 0;
- h->sei_cpb_removal_delay = -1;
- h->sei_buffering_period_present = 0;
-
- if (!buf_size)
- return 0;
-
- for(;;) {
- int src_length, dst_length, consumed, nalsize = 0;
- if (h->is_avc) {
- int i;
- if (h->nal_length_size >= buf_end - buf) break;
- nalsize = 0;
- for (i = 0; i < h->nal_length_size; i++)
- nalsize = (nalsize << 8) | *buf++;
- if (nalsize <= 0 || nalsize > buf_end - buf) {
- av_log(h->s.avctx, AV_LOG_ERROR, "AVC: nal size %d\n", nalsize);
- break;
- }
- src_length = nalsize;
- } else {
- buf = avpriv_mpv_find_start_code(buf, buf_end, &state);
- if(buf >= buf_end)
- break;
- --buf;
- src_length = buf_end - buf;
- }
- switch (state & 0x1f) {
- case NAL_SLICE:
- case NAL_IDR_SLICE:
- // Do not walk the whole buffer just to decode slice header
- if (src_length > 20)
- src_length = 20;
- break;
- }
- ptr= ff_h264_decode_nal(h, buf, &dst_length, &consumed, src_length);
- if (ptr==NULL || dst_length < 0)
- break;
-
- init_get_bits(&h->s.gb, ptr, 8*dst_length);
- switch(h->nal_unit_type) {
- case NAL_SPS:
- ff_h264_decode_seq_parameter_set(h);
- break;
- case NAL_PPS:
- ff_h264_decode_picture_parameter_set(h, h->s.gb.size_in_bits);
- break;
- case NAL_SEI:
- ff_h264_decode_sei(h);
- break;
- case NAL_IDR_SLICE:
- s->key_frame = 1;
- /* fall through */
- case NAL_SLICE:
- get_ue_golomb_long(&h->s.gb); // skip first_mb_in_slice
- slice_type = get_ue_golomb_31(&h->s.gb);
- s->pict_type = golomb_to_pict_type[slice_type % 5];
- if (h->sei_recovery_frame_cnt >= 0) {
- /* key frame, since recovery_frame_cnt is set */
- s->key_frame = 1;
- }
- pps_id= get_ue_golomb(&h->s.gb);
- if(pps_id>=MAX_PPS_COUNT) {
- av_log(h->s.avctx, AV_LOG_ERROR, "pps_id out of range\n");
- return -1;
- }
- if(!h->pps_buffers[pps_id]) {
- av_log(h->s.avctx, AV_LOG_ERROR, "non-existing PPS referenced\n");
- return -1;
- }
- h->pps= *h->pps_buffers[pps_id];
- if(!h->sps_buffers[h->pps.sps_id]) {
- av_log(h->s.avctx, AV_LOG_ERROR, "non-existing SPS referenced\n");
- return -1;
- }
- h->sps = *h->sps_buffers[h->pps.sps_id];
- h->frame_num = get_bits(&h->s.gb, h->sps.log2_max_frame_num);
-
- avctx->profile = ff_h264_get_profile(&h->sps);
- avctx->level = h->sps.level_idc;
-
- if(h->sps.frame_mbs_only_flag){
- h->s.picture_structure= PICT_FRAME;
- }else{
- if(get_bits1(&h->s.gb)) { //field_pic_flag
- h->s.picture_structure= PICT_TOP_FIELD + get_bits1(&h->s.gb); //bottom_field_flag
- } else {
- h->s.picture_structure= PICT_FRAME;
- }
- }
-
- if(h->sps.pic_struct_present_flag) {
- switch (h->sei_pic_struct) {
- case SEI_PIC_STRUCT_TOP_FIELD:
- case SEI_PIC_STRUCT_BOTTOM_FIELD:
- s->repeat_pict = 0;
- break;
- case SEI_PIC_STRUCT_FRAME:
- case SEI_PIC_STRUCT_TOP_BOTTOM:
- case SEI_PIC_STRUCT_BOTTOM_TOP:
- s->repeat_pict = 1;
- break;
- case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
- case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:
- s->repeat_pict = 2;
- break;
- case SEI_PIC_STRUCT_FRAME_DOUBLING:
- s->repeat_pict = 3;
- break;
- case SEI_PIC_STRUCT_FRAME_TRIPLING:
- s->repeat_pict = 5;
- break;
- default:
- s->repeat_pict = h->s.picture_structure == PICT_FRAME ? 1 : 0;
- break;
- }
- } else {
- s->repeat_pict = h->s.picture_structure == PICT_FRAME ? 1 : 0;
- }
-
- return 0; /* no need to evaluate the rest */
- }
- buf += h->is_avc ? nalsize : consumed;
- }
- if (q264)
- return 0;
- /* didn't find a picture! */
- av_log(h->s.avctx, AV_LOG_ERROR, "missing picture in access unit with size %d\n", buf_size);
- return -1;
-}
-
-static int h264_parse(AVCodecParserContext *s,
- AVCodecContext *avctx,
- const uint8_t **poutbuf, int *poutbuf_size,
- const uint8_t *buf, int buf_size)
-{
- H264Context *h = s->priv_data;
- ParseContext *pc = &h->s.parse_context;
- int next;
-
- if (!h->got_first) {
- h->got_first = 1;
- if (avctx->extradata_size) {
- h->s.avctx = avctx;
- // must be done like in decoder, otherwise opening the parser,
- // letting it create extradata and then closing and opening again
- // will cause has_b_frames to be always set.
- // Note that estimate_timings_from_pts does exactly this.
- if (!avctx->has_b_frames)
- h->s.low_delay = 1;
- ff_h264_decode_extradata(h, avctx->extradata, avctx->extradata_size);
- }
- }
-
- if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){
- next= buf_size;
- }else{
- next= ff_h264_find_frame_end(h, buf, buf_size);
-
- if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
- *poutbuf = NULL;
- *poutbuf_size = 0;
- return buf_size;
- }
-
- if(next<0 && next != END_NOT_FOUND){
- av_assert1(pc->last_index + next >= 0 );
- ff_h264_find_frame_end(h, &pc->buffer[pc->last_index + next], -next); //update state
- }
- }
-
- parse_nal_units(s, avctx, buf, buf_size);
-
- if (h->sei_cpb_removal_delay >= 0) {
- s->dts_sync_point = h->sei_buffering_period_present;
- s->dts_ref_dts_delta = h->sei_cpb_removal_delay;
- s->pts_dts_delta = h->sei_dpb_output_delay;
- } else {
- s->dts_sync_point = INT_MIN;
- s->dts_ref_dts_delta = INT_MIN;
- s->pts_dts_delta = INT_MIN;
- }
-
- if (s->flags & PARSER_FLAG_ONCE) {
- s->flags &= PARSER_FLAG_COMPLETE_FRAMES;
- }
-
- *poutbuf = buf;
- *poutbuf_size = buf_size;
- return next;
-}
-
-static int h264_split(AVCodecContext *avctx,
- const uint8_t *buf, int buf_size)
-{
- int i;
- uint32_t state = -1;
- int has_sps= 0;
-
- for(i=0; i<=buf_size; i++){
- if((state&0xFFFFFF1F) == 0x107)
- has_sps=1;
-/* if((state&0xFFFFFF1F) == 0x101 || (state&0xFFFFFF1F) == 0x102 || (state&0xFFFFFF1F) == 0x105){
- }*/
- if((state&0xFFFFFF00) == 0x100 && (state&0xFFFFFF1F) != 0x107 && (state&0xFFFFFF1F) != 0x108 && (state&0xFFFFFF1F) != 0x109){
- if(has_sps){
- while(i>4 && buf[i-5]==0) i--;
- return i-4;
- }
- }
- if (i<buf_size)
- state= (state<<8) | buf[i];
- }
- return 0;
-}
-
-static void close(AVCodecParserContext *s)
-{
- H264Context *h = s->priv_data;
- ParseContext *pc = &h->s.parse_context;
-
- av_free(pc->buffer);
- ff_h264_free_context(h);
-}
-
-static int init(AVCodecParserContext *s)
-{
- H264Context *h = s->priv_data;
- h->thread_context[0] = h;
- h->s.slice_context_count = 1;
- return 0;
-}
-
-AVCodecParser ff_h264_parser = {
- .codec_ids = { AV_CODEC_ID_H264 },
- .priv_data_size = sizeof(H264Context),
- .parser_init = init,
- .parser_parse = h264_parse,
- .parser_close = close,
- .split = h264_split,
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264_ps.c b/src/thirdparty/ffmpeg/libavcodec/h264_ps.c
deleted file mode 100644
index 226aabf2e..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264_ps.c
+++ /dev/null
@@ -1,695 +0,0 @@
-/*
- * H.26L/H.264/AVC/JVT/14496-10/... parameter set decoding
- * 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 parameter set decoding.
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#include "libavutil/imgutils.h"
-#include "internal.h"
-#include "dsputil.h"
-#include "avcodec.h"
-#include "h264.h"
-#include "h264data.h" //FIXME FIXME FIXME (just for zigzag_scan)
-#include "golomb.h"
-
-
-//#undef NDEBUG
-#include <assert.h>
-
-#define MAX_LOG2_MAX_FRAME_NUM (12 + 4)
-#define MIN_LOG2_MAX_FRAME_NUM 4
-
-static const AVRational pixel_aspect[17]={
- {0, 1},
- {1, 1},
- {12, 11},
- {10, 11},
- {16, 11},
- {40, 33},
- {24, 11},
- {20, 11},
- {32, 11},
- {80, 33},
- {18, 11},
- {15, 11},
- {64, 33},
- {160,99},
- {4, 3},
- {3, 2},
- {2, 1},
-};
-
-#define QP(qP,depth) ( (qP)+6*((depth)-8) )
-
-#define CHROMA_QP_TABLE_END(d) \
- QP(0,d), QP(1,d), QP(2,d), QP(3,d), QP(4,d), QP(5,d),\
- QP(6,d), QP(7,d), QP(8,d), QP(9,d), QP(10,d), QP(11,d),\
- QP(12,d), QP(13,d), QP(14,d), QP(15,d), QP(16,d), QP(17,d),\
- QP(18,d), QP(19,d), QP(20,d), QP(21,d), QP(22,d), QP(23,d),\
- QP(24,d), QP(25,d), QP(26,d), QP(27,d), QP(28,d), QP(29,d),\
- QP(29,d), QP(30,d), QP(31,d), QP(32,d), QP(32,d), QP(33,d),\
- QP(34,d), QP(34,d), QP(35,d), QP(35,d), QP(36,d), QP(36,d),\
- QP(37,d), QP(37,d), QP(37,d), QP(38,d), QP(38,d), QP(38,d),\
- QP(39,d), QP(39,d), QP(39,d), QP(39,d)
-
-const uint8_t ff_h264_chroma_qp[7][QP_MAX_NUM+1] = {
- {
- CHROMA_QP_TABLE_END(8)
- },
- {
- 0, 1, 2, 3, 4, 5,
- CHROMA_QP_TABLE_END(9)
- },
- {
- 0, 1, 2, 3, 4, 5,
- 6, 7, 8, 9, 10, 11,
- CHROMA_QP_TABLE_END(10)
- },
- {
- 0, 1, 2, 3, 4, 5,
- 6, 7, 8, 9, 10, 11,
- 12,13,14,15, 16, 17,
- CHROMA_QP_TABLE_END(11)
- },
- {
- 0, 1, 2, 3, 4, 5,
- 6, 7, 8, 9, 10, 11,
- 12,13,14,15, 16, 17,
- 18,19,20,21, 22, 23,
- CHROMA_QP_TABLE_END(12)
- },
- {
- 0, 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,
- CHROMA_QP_TABLE_END(13)
- },
- {
- 0, 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,32,33, 34, 35,
- CHROMA_QP_TABLE_END(14)
- },
-};
-
-static const uint8_t default_scaling4[2][16]={
-{ 6,13,20,28,
- 13,20,28,32,
- 20,28,32,37,
- 28,32,37,42
-},{
- 10,14,20,24,
- 14,20,24,27,
- 20,24,27,30,
- 24,27,30,34
-}};
-
-static const uint8_t default_scaling8[2][64]={
-{ 6,10,13,16,18,23,25,27,
- 10,11,16,18,23,25,27,29,
- 13,16,18,23,25,27,29,31,
- 16,18,23,25,27,29,31,33,
- 18,23,25,27,29,31,33,36,
- 23,25,27,29,31,33,36,38,
- 25,27,29,31,33,36,38,40,
- 27,29,31,33,36,38,40,42
-},{
- 9,13,15,17,19,21,22,24,
- 13,13,17,19,21,22,24,25,
- 15,17,19,21,22,24,25,27,
- 17,19,21,22,24,25,27,28,
- 19,21,22,24,25,27,28,30,
- 21,22,24,25,27,28,30,32,
- 22,24,25,27,28,30,32,33,
- 24,25,27,28,30,32,33,35
-}};
-
-static inline int decode_hrd_parameters(H264Context *h, SPS *sps){
- MpegEncContext * const s = &h->s;
- int cpb_count, i;
- cpb_count = get_ue_golomb_31(&s->gb) + 1;
-
- if(cpb_count > 32U){
- av_log(h->s.avctx, AV_LOG_ERROR, "cpb_count %d invalid\n", cpb_count);
- return -1;
- }
-
- get_bits(&s->gb, 4); /* bit_rate_scale */
- get_bits(&s->gb, 4); /* cpb_size_scale */
- for(i=0; i<cpb_count; i++){
- get_ue_golomb_long(&s->gb); /* bit_rate_value_minus1 */
- get_ue_golomb_long(&s->gb); /* cpb_size_value_minus1 */
- get_bits1(&s->gb); /* cbr_flag */
- }
- sps->initial_cpb_removal_delay_length = get_bits(&s->gb, 5) + 1;
- sps->cpb_removal_delay_length = get_bits(&s->gb, 5) + 1;
- sps->dpb_output_delay_length = get_bits(&s->gb, 5) + 1;
- sps->time_offset_length = get_bits(&s->gb, 5);
- sps->cpb_cnt = cpb_count;
- return 0;
-}
-
-static inline int decode_vui_parameters(H264Context *h, SPS *sps){
- MpegEncContext * const s = &h->s;
- int aspect_ratio_info_present_flag;
- unsigned int aspect_ratio_idc;
-
- aspect_ratio_info_present_flag= get_bits1(&s->gb);
-
- if( aspect_ratio_info_present_flag ) {
- aspect_ratio_idc= get_bits(&s->gb, 8);
- if( aspect_ratio_idc == EXTENDED_SAR ) {
- sps->sar.num= get_bits(&s->gb, 16);
- sps->sar.den= get_bits(&s->gb, 16);
- }else if(aspect_ratio_idc < FF_ARRAY_ELEMS(pixel_aspect)){
- sps->sar= pixel_aspect[aspect_ratio_idc];
- }else{
- av_log(h->s.avctx, AV_LOG_ERROR, "illegal aspect ratio\n");
- return -1;
- }
- }else{
- sps->sar.num=
- sps->sar.den= 0;
- }
-// s->avctx->aspect_ratio= sar_width*s->width / (float)(s->height*sar_height);
-
- if(get_bits1(&s->gb)){ /* overscan_info_present_flag */
- get_bits1(&s->gb); /* overscan_appropriate_flag */
- }
-
- sps->video_signal_type_present_flag = get_bits1(&s->gb);
- if(sps->video_signal_type_present_flag){
- get_bits(&s->gb, 3); /* video_format */
- sps->full_range = get_bits1(&s->gb); /* video_full_range_flag */
-
- sps->colour_description_present_flag = get_bits1(&s->gb);
- if(sps->colour_description_present_flag){
- sps->color_primaries = get_bits(&s->gb, 8); /* colour_primaries */
- sps->color_trc = get_bits(&s->gb, 8); /* transfer_characteristics */
- sps->colorspace = get_bits(&s->gb, 8); /* matrix_coefficients */
- if (sps->color_primaries >= AVCOL_PRI_NB)
- sps->color_primaries = AVCOL_PRI_UNSPECIFIED;
- if (sps->color_trc >= AVCOL_TRC_NB)
- sps->color_trc = AVCOL_TRC_UNSPECIFIED;
- if (sps->colorspace >= AVCOL_SPC_NB)
- sps->colorspace = AVCOL_SPC_UNSPECIFIED;
- }
- }
-
- if(get_bits1(&s->gb)){ /* chroma_location_info_present_flag */
- s->avctx->chroma_sample_location = get_ue_golomb(&s->gb)+1; /* chroma_sample_location_type_top_field */
- get_ue_golomb(&s->gb); /* chroma_sample_location_type_bottom_field */
- }
-
- sps->timing_info_present_flag = get_bits1(&s->gb);
- if(sps->timing_info_present_flag){
- sps->num_units_in_tick = get_bits_long(&s->gb, 32);
- sps->time_scale = get_bits_long(&s->gb, 32);
- if(!sps->num_units_in_tick || !sps->time_scale){
- av_log(h->s.avctx, AV_LOG_ERROR, "time_scale/num_units_in_tick invalid or unsupported (%d/%d)\n", sps->time_scale, sps->num_units_in_tick);
- return -1;
- }
- sps->fixed_frame_rate_flag = get_bits1(&s->gb);
- }
-
- sps->nal_hrd_parameters_present_flag = get_bits1(&s->gb);
- if(sps->nal_hrd_parameters_present_flag)
- if(decode_hrd_parameters(h, sps) < 0)
- return -1;
- sps->vcl_hrd_parameters_present_flag = get_bits1(&s->gb);
- if(sps->vcl_hrd_parameters_present_flag)
- if(decode_hrd_parameters(h, sps) < 0)
- return -1;
- if(sps->nal_hrd_parameters_present_flag || sps->vcl_hrd_parameters_present_flag)
- get_bits1(&s->gb); /* low_delay_hrd_flag */
- sps->pic_struct_present_flag = get_bits1(&s->gb);
- if(!get_bits_left(&s->gb))
- return 0;
- sps->bitstream_restriction_flag = get_bits1(&s->gb);
- if(sps->bitstream_restriction_flag){
- get_bits1(&s->gb); /* motion_vectors_over_pic_boundaries_flag */
- get_ue_golomb(&s->gb); /* max_bytes_per_pic_denom */
- get_ue_golomb(&s->gb); /* max_bits_per_mb_denom */
- get_ue_golomb(&s->gb); /* log2_max_mv_length_horizontal */
- get_ue_golomb(&s->gb); /* log2_max_mv_length_vertical */
- sps->num_reorder_frames= get_ue_golomb(&s->gb);
- get_ue_golomb(&s->gb); /*max_dec_frame_buffering*/
-
- if (get_bits_left(&s->gb) < 0) {
- sps->num_reorder_frames=0;
- sps->bitstream_restriction_flag= 0;
- }
-
- if(sps->num_reorder_frames > 16U /*max_dec_frame_buffering || max_dec_frame_buffering > 16*/){
- av_log(h->s.avctx, AV_LOG_ERROR, "illegal num_reorder_frames %d\n", sps->num_reorder_frames);
- return -1;
- }
- }
-
- if (get_bits_left(&s->gb) < 0) {
- av_log(h->s.avctx, AV_LOG_ERROR, "Overread VUI by %d bits\n", -get_bits_left(&s->gb));
- return AVERROR_INVALIDDATA;
- }
-
- return 0;
-}
-
-static void decode_scaling_list(H264Context *h, uint8_t *factors, int size,
- const uint8_t *jvt_list, const uint8_t *fallback_list){
- MpegEncContext * const s = &h->s;
- int i, last = 8, next = 8;
- const uint8_t *scan = size == 16 ? zigzag_scan : ff_zigzag_direct;
- if(!get_bits1(&s->gb)) /* matrix not written, we use the predicted one */
- memcpy(factors, fallback_list, size*sizeof(uint8_t));
- else
- for(i=0;i<size;i++){
- if(next)
- next = (last + get_se_golomb(&s->gb)) & 0xff;
- if(!i && !next){ /* matrix not written, we use the preset one */
- memcpy(factors, jvt_list, size*sizeof(uint8_t));
- break;
- }
- last = factors[scan[i]] = next ? next : last;
- }
-}
-
-static void decode_scaling_matrices(H264Context *h, SPS *sps, PPS *pps, int is_sps,
- uint8_t (*scaling_matrix4)[16], uint8_t (*scaling_matrix8)[64]){
- MpegEncContext * const s = &h->s;
- int fallback_sps = !is_sps && sps->scaling_matrix_present;
- const uint8_t *fallback[4] = {
- fallback_sps ? sps->scaling_matrix4[0] : default_scaling4[0],
- fallback_sps ? sps->scaling_matrix4[3] : default_scaling4[1],
- fallback_sps ? sps->scaling_matrix8[0] : default_scaling8[0],
- fallback_sps ? sps->scaling_matrix8[3] : default_scaling8[1]
- };
- if(get_bits1(&s->gb)){
- sps->scaling_matrix_present |= is_sps;
- decode_scaling_list(h,scaling_matrix4[0],16,default_scaling4[0],fallback[0]); // Intra, Y
- decode_scaling_list(h,scaling_matrix4[1],16,default_scaling4[0],scaling_matrix4[0]); // Intra, Cr
- decode_scaling_list(h,scaling_matrix4[2],16,default_scaling4[0],scaling_matrix4[1]); // Intra, Cb
- decode_scaling_list(h,scaling_matrix4[3],16,default_scaling4[1],fallback[1]); // Inter, Y
- decode_scaling_list(h,scaling_matrix4[4],16,default_scaling4[1],scaling_matrix4[3]); // Inter, Cr
- decode_scaling_list(h,scaling_matrix4[5],16,default_scaling4[1],scaling_matrix4[4]); // Inter, Cb
- if(is_sps || pps->transform_8x8_mode){
- decode_scaling_list(h,scaling_matrix8[0],64,default_scaling8[0],fallback[2]); // Intra, Y
- decode_scaling_list(h,scaling_matrix8[3],64,default_scaling8[1],fallback[3]); // Inter, Y
- if(sps->chroma_format_idc == 3){
- decode_scaling_list(h,scaling_matrix8[1],64,default_scaling8[0],scaling_matrix8[0]); // Intra, Cr
- decode_scaling_list(h,scaling_matrix8[4],64,default_scaling8[1],scaling_matrix8[3]); // Inter, Cr
- decode_scaling_list(h,scaling_matrix8[2],64,default_scaling8[0],scaling_matrix8[1]); // Intra, Cb
- decode_scaling_list(h,scaling_matrix8[5],64,default_scaling8[1],scaling_matrix8[4]); // Inter, Cb
- }
- }
- }
-}
-
-int ff_h264_decode_seq_parameter_set(H264Context *h){
- MpegEncContext * const s = &h->s;
- int profile_idc, level_idc, constraint_set_flags = 0;
- unsigned int sps_id;
- int i, log2_max_frame_num_minus4;
- SPS *sps;
-
- profile_idc= get_bits(&s->gb, 8);
- constraint_set_flags |= get_bits1(&s->gb) << 0; //constraint_set0_flag
- constraint_set_flags |= get_bits1(&s->gb) << 1; //constraint_set1_flag
- constraint_set_flags |= get_bits1(&s->gb) << 2; //constraint_set2_flag
- constraint_set_flags |= get_bits1(&s->gb) << 3; //constraint_set3_flag
- constraint_set_flags |= get_bits1(&s->gb) << 4; //constraint_set4_flag
- constraint_set_flags |= get_bits1(&s->gb) << 5; //constraint_set5_flag
- get_bits(&s->gb, 2); // reserved
- level_idc= get_bits(&s->gb, 8);
- sps_id= get_ue_golomb_31(&s->gb);
-
- if(sps_id >= MAX_SPS_COUNT) {
- av_log(h->s.avctx, AV_LOG_ERROR, "sps_id (%d) out of range\n", sps_id);
- return -1;
- }
- sps= av_mallocz(sizeof(SPS));
- if(sps == NULL)
- return -1;
-
- sps->time_offset_length = 24;
- sps->profile_idc= profile_idc;
- sps->constraint_set_flags = constraint_set_flags;
- sps->level_idc= level_idc;
- sps->full_range = -1;
-
- memset(sps->scaling_matrix4, 16, sizeof(sps->scaling_matrix4));
- memset(sps->scaling_matrix8, 16, sizeof(sps->scaling_matrix8));
- 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) {
- sps->chroma_format_idc= get_ue_golomb_31(&s->gb);
- if (sps->chroma_format_idc > 3U) {
- av_log(h->s.avctx, AV_LOG_ERROR, "chroma_format_idc %d is illegal\n", sps->chroma_format_idc);
- goto fail;
- } else if(sps->chroma_format_idc == 3) {
- sps->residual_color_transform_flag = get_bits1(&s->gb);
- if(sps->residual_color_transform_flag) {
- av_log(h->s.avctx, AV_LOG_ERROR, "separate color planes are not supported\n");
- goto fail;
- }
- }
- sps->bit_depth_luma = get_ue_golomb(&s->gb) + 8;
- sps->bit_depth_chroma = get_ue_golomb(&s->gb) + 8;
- if (sps->bit_depth_luma > 14U || sps->bit_depth_chroma > 14U) {
- av_log(h->s.avctx, AV_LOG_ERROR, "illegal bit depth value (%d, %d)\n",
- sps->bit_depth_luma, sps->bit_depth_chroma);
- goto fail;
- }
- sps->transform_bypass = get_bits1(&s->gb);
- decode_scaling_matrices(h, sps, NULL, 1, sps->scaling_matrix4, sps->scaling_matrix8);
- }else{
- sps->chroma_format_idc= 1;
- sps->bit_depth_luma = 8;
- sps->bit_depth_chroma = 8;
- }
-
- log2_max_frame_num_minus4 = get_ue_golomb(&s->gb);
- if (log2_max_frame_num_minus4 < MIN_LOG2_MAX_FRAME_NUM - 4 ||
- log2_max_frame_num_minus4 > MAX_LOG2_MAX_FRAME_NUM - 4) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "log2_max_frame_num_minus4 out of range (0-12): %d\n",
- log2_max_frame_num_minus4);
- goto fail;
- }
- sps->log2_max_frame_num = log2_max_frame_num_minus4 + 4;
-
- sps->poc_type= get_ue_golomb_31(&s->gb);
-
- if(sps->poc_type == 0){ //FIXME #define
- unsigned t = get_ue_golomb(&s->gb);
- if(t>12){
- av_log(h->s.avctx, AV_LOG_ERROR, "log2_max_poc_lsb (%d) is out of range\n", t);
- goto fail;
- }
- sps->log2_max_poc_lsb= t + 4;
- } else if(sps->poc_type == 1){//FIXME #define
- sps->delta_pic_order_always_zero_flag= get_bits1(&s->gb);
- sps->offset_for_non_ref_pic= get_se_golomb(&s->gb);
- sps->offset_for_top_to_bottom_field= get_se_golomb(&s->gb);
- sps->poc_cycle_length = get_ue_golomb(&s->gb);
-
- if((unsigned)sps->poc_cycle_length >= FF_ARRAY_ELEMS(sps->offset_for_ref_frame)){
- av_log(h->s.avctx, AV_LOG_ERROR, "poc_cycle_length overflow %u\n", sps->poc_cycle_length);
- goto fail;
- }
-
- for(i=0; i<sps->poc_cycle_length; i++)
- sps->offset_for_ref_frame[i]= get_se_golomb(&s->gb);
- }else if(sps->poc_type != 2){
- av_log(h->s.avctx, AV_LOG_ERROR, "illegal POC type %d\n", sps->poc_type);
- goto fail;
- }
-
- sps->ref_frame_count= get_ue_golomb_31(&s->gb);
- if (h->s.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 || sps->ref_frame_count > 16U){
- av_log(h->s.avctx, AV_LOG_ERROR, "too many reference frames\n");
- goto fail;
- }
- sps->gaps_in_frame_num_allowed_flag= get_bits1(&s->gb);
- sps->mb_width = get_ue_golomb(&s->gb) + 1;
- sps->mb_height= get_ue_golomb(&s->gb) + 1;
- if((unsigned)sps->mb_width >= INT_MAX/16 || (unsigned)sps->mb_height >= INT_MAX/16 ||
- av_image_check_size(16*sps->mb_width, 16*sps->mb_height, 0, h->s.avctx)){
- av_log(h->s.avctx, AV_LOG_ERROR, "mb_width/height overflow\n");
- goto fail;
- }
-
- sps->frame_mbs_only_flag= get_bits1(&s->gb);
- if(!sps->frame_mbs_only_flag)
- sps->mb_aff= get_bits1(&s->gb);
- else
- sps->mb_aff= 0;
-
- sps->direct_8x8_inference_flag= get_bits1(&s->gb);
-
-#ifndef ALLOW_INTERLACE
- if(sps->mb_aff)
- av_log(h->s.avctx, AV_LOG_ERROR, "MBAFF support not included; enable it at compile-time.\n");
-#endif
- sps->crop= get_bits1(&s->gb);
- if(sps->crop){
- int crop_vertical_limit = sps->chroma_format_idc & 2 ? 16 : 8;
- int crop_horizontal_limit = sps->chroma_format_idc == 3 ? 16 : 8;
- sps->crop_left = get_ue_golomb(&s->gb);
- sps->crop_right = get_ue_golomb(&s->gb);
- sps->crop_top = get_ue_golomb(&s->gb);
- sps->crop_bottom= get_ue_golomb(&s->gb);
- if (h->s.avctx->flags2 & CODEC_FLAG2_IGNORE_CROP) {
- av_log(h->s.avctx, AV_LOG_DEBUG,
- "discarding sps cropping, "
- "original values are l:%u r:%u t:%u b:%u\n",
- sps->crop_left,
- sps->crop_right,
- sps->crop_top,
- sps->crop_bottom);
-
- sps->crop_left =
- sps->crop_right =
- sps->crop_top =
- sps->crop_bottom = 0;
- }
- if(sps->crop_left || sps->crop_top){
- av_log(h->s.avctx, AV_LOG_ERROR, "insane cropping not completely supported, this could look slightly wrong ... (left: %d, top: %d)\n", sps->crop_left, sps->crop_top);
- }
- if(sps->crop_right >= crop_horizontal_limit || sps->crop_bottom >= crop_vertical_limit){
- av_log(h->s.avctx, AV_LOG_ERROR, "brainfart cropping not supported, cropping disabled (right: %d, bottom: %d)\n", sps->crop_right, sps->crop_bottom);
- /* It is very unlikely that partial cropping will make anybody happy.
- * Not cropping at all fixes for example playback of Sisvel 3D streams
- * in applications supporting Sisvel 3D. */
- sps->crop_left =
- sps->crop_right =
- sps->crop_top =
- sps->crop_bottom= 0;
- }
- }else{
- sps->crop_left =
- sps->crop_right =
- sps->crop_top =
- sps->crop_bottom= 0;
- }
-
- sps->vui_parameters_present_flag= get_bits1(&s->gb);
- if( sps->vui_parameters_present_flag )
- if (decode_vui_parameters(h, sps) < 0)
- goto fail;
-
- if(!sps->sar.den)
- sps->sar.den= 1;
-
- if(s->avctx->debug&FF_DEBUG_PICT_INFO){
- static const char csp[4][5] = { "Gray", "420", "422", "444" };
- av_log(h->s.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_id, sps->profile_idc, sps->level_idc,
- sps->poc_type,
- sps->ref_frame_count,
- sps->mb_width, sps->mb_height,
- sps->frame_mbs_only_flag ? "FRM" : (sps->mb_aff ? "MB-AFF" : "PIC-AFF"),
- sps->direct_8x8_inference_flag ? "8B8" : "",
- sps->crop_left, sps->crop_right,
- sps->crop_top, sps->crop_bottom,
- sps->vui_parameters_present_flag ? "VUI" : "",
- csp[sps->chroma_format_idc],
- 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->new = 1;
-
- av_free(h->sps_buffers[sps_id]);
- h->sps_buffers[sps_id] = sps;
- h->sps = *sps;
- h->current_sps_id = sps_id;
-
- return 0;
-fail:
- av_free(sps);
- return -1;
-}
-
-static void
-build_qp_table(PPS *pps, int t, int index, const int depth)
-{
- int i;
- const int max_qp = 51 + 6*(depth-8);
- for(i = 0; i < max_qp+1; i++)
- pps->chroma_qp_table[t][i] = ff_h264_chroma_qp[depth-8][av_clip(i + index, 0, max_qp)];
-}
-
-static int more_rbsp_data_in_pps(H264Context *h, PPS *pps)
-{
- const SPS *sps = h->sps_buffers[pps->sps_id];
- int profile_idc = sps->profile_idc;
-
- if ((profile_idc == 66 || profile_idc == 77 ||
- profile_idc == 88) && (sps->constraint_set_flags & 7)) {
- av_log(h->s.avctx, AV_LOG_VERBOSE,
- "Current profile doesn't provide more RBSP data in PPS, skipping\n");
- return 0;
- }
-
- return 1;
-}
-
-int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length){
- MpegEncContext * const s = &h->s;
- unsigned int pps_id= get_ue_golomb(&s->gb);
- PPS *pps;
- const int qp_bd_offset = 6*(h->sps.bit_depth_luma-8);
- int bits_left;
-
- if(pps_id >= MAX_PPS_COUNT) {
- av_log(h->s.avctx, AV_LOG_ERROR, "pps_id (%d) out of range\n", pps_id);
- return -1;
- } else if (h->sps.bit_depth_luma > 14) {
- av_log(h->s.avctx, AV_LOG_ERROR, "Invalid luma bit depth=%d\n", h->sps.bit_depth_luma);
- return AVERROR_INVALIDDATA;
- } else if (h->sps.bit_depth_luma == 11 || h->sps.bit_depth_luma == 13) {
- av_log(h->s.avctx, AV_LOG_ERROR, "Unimplemented luma bit depth=%d\n", h->sps.bit_depth_luma);
- return AVERROR_PATCHWELCOME;
- }
-
- pps= av_mallocz(sizeof(PPS));
- if(pps == NULL)
- return -1;
- pps->sps_id= get_ue_golomb_31(&s->gb);
- if((unsigned)pps->sps_id>=MAX_SPS_COUNT || h->sps_buffers[pps->sps_id] == NULL){
- av_log(h->s.avctx, AV_LOG_ERROR, "sps_id out of range\n");
- goto fail;
- }
-
- pps->cabac= get_bits1(&s->gb);
- pps->pic_order_present= get_bits1(&s->gb);
- pps->slice_group_count= get_ue_golomb(&s->gb) + 1;
- if(pps->slice_group_count > 1 ){
- pps->mb_slice_group_map_type= get_ue_golomb(&s->gb);
- av_log(h->s.avctx, AV_LOG_ERROR, "FMO not supported\n");
- switch(pps->mb_slice_group_map_type){
- case 0:
-#if 0
-| for( i = 0; i <= num_slice_groups_minus1; i++ ) | | |
-| run_length[ i ] |1 |ue(v) |
-#endif
- break;
- case 2:
-#if 0
-| for( i = 0; i < num_slice_groups_minus1; i++ ) | | |
-|{ | | |
-| top_left_mb[ i ] |1 |ue(v) |
-| bottom_right_mb[ i ] |1 |ue(v) |
-| } | | |
-#endif
- break;
- case 3:
- case 4:
- case 5:
-#if 0
-| slice_group_change_direction_flag |1 |u(1) |
-| slice_group_change_rate_minus1 |1 |ue(v) |
-#endif
- break;
- case 6:
-#if 0
-| slice_group_id_cnt_minus1 |1 |ue(v) |
-| for( i = 0; i <= slice_group_id_cnt_minus1; i++ | | |
-|) | | |
-| slice_group_id[ i ] |1 |u(v) |
-#endif
- break;
- }
- }
- pps->ref_count[0]= get_ue_golomb(&s->gb) + 1;
- pps->ref_count[1]= get_ue_golomb(&s->gb) + 1;
- if(pps->ref_count[0]-1 > 32-1 || pps->ref_count[1]-1 > 32-1){
- av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow (pps)\n");
- goto fail;
- }
-
- pps->weighted_pred= get_bits1(&s->gb);
- pps->weighted_bipred_idc= get_bits(&s->gb, 2);
- pps->init_qp= get_se_golomb(&s->gb) + 26 + qp_bd_offset;
- pps->init_qs= get_se_golomb(&s->gb) + 26 + qp_bd_offset;
- pps->chroma_qp_index_offset[0]= get_se_golomb(&s->gb);
- pps->deblocking_filter_parameters_present= get_bits1(&s->gb);
- pps->constrained_intra_pred= get_bits1(&s->gb);
- pps->redundant_pic_cnt_present = get_bits1(&s->gb);
-
- pps->transform_8x8_mode= 0;
- h->dequant_coeff_pps= -1; //contents of sps/pps can change even if id doesn't, so reinit
- memcpy(pps->scaling_matrix4, h->sps_buffers[pps->sps_id]->scaling_matrix4, sizeof(pps->scaling_matrix4));
- memcpy(pps->scaling_matrix8, h->sps_buffers[pps->sps_id]->scaling_matrix8, sizeof(pps->scaling_matrix8));
-
- bits_left = bit_length - get_bits_count(&s->gb);
- if(bits_left > 0 && more_rbsp_data_in_pps(h, pps)){
- pps->transform_8x8_mode= get_bits1(&s->gb);
- decode_scaling_matrices(h, h->sps_buffers[pps->sps_id], pps, 0, pps->scaling_matrix4, pps->scaling_matrix8);
- pps->chroma_qp_index_offset[1]= get_se_golomb(&s->gb); //second_chroma_qp_index_offset
- } else {
- pps->chroma_qp_index_offset[1]= pps->chroma_qp_index_offset[0];
- }
-
- build_qp_table(pps, 0, pps->chroma_qp_index_offset[0], h->sps.bit_depth_luma);
- build_qp_table(pps, 1, pps->chroma_qp_index_offset[1], h->sps.bit_depth_luma);
- if(pps->chroma_qp_index_offset[0] != pps->chroma_qp_index_offset[1])
- pps->chroma_qp_diff= 1;
-
- if(s->avctx->debug&FF_DEBUG_PICT_INFO){
- av_log(h->s.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_id, pps->sps_id,
- pps->cabac ? "CABAC" : "CAVLC",
- pps->slice_group_count,
- pps->ref_count[0], pps->ref_count[1],
- pps->weighted_pred ? "weighted" : "",
- pps->init_qp, pps->init_qs, pps->chroma_qp_index_offset[0], pps->chroma_qp_index_offset[1],
- pps->deblocking_filter_parameters_present ? "LPAR" : "",
- pps->constrained_intra_pred ? "CONSTR" : "",
- pps->redundant_pic_cnt_present ? "REDU" : "",
- pps->transform_8x8_mode ? "8x8DCT" : ""
- );
- }
-
- av_free(h->pps_buffers[pps_id]);
- h->pps_buffers[pps_id]= pps;
- return 0;
-fail:
- av_free(pps);
- return -1;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264_recov.c b/src/thirdparty/ffmpeg/libavcodec/h264_recov.c
deleted file mode 100644
index 12b143853..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264_recov.c
+++ /dev/null
@@ -1,170 +0,0 @@
-// #included by h264.c
-av_cold int avcodec_h264_decode_init_is_avc(AVCodecContext *avctx)
-{
- if (avctx->extradata_size > 0 && avctx->extradata &&
- (*(char *)avctx->extradata == 1 || (avctx->codec_tag == 0x31637661 || avctx->codec_tag == 0x31435641))) {
- return 1;
- } else {
- return 0;
- }
-}
-
-static int is_I_slice(int slice_type)
-{
- return slice_type == 2 || slice_type == 4 || slice_type == 7 || slice_type == 9;
-}
-
-/**
- * ffdshow custom stuff (based on decode_nal_units)
- * Copyright (c) 2008-2012 Haruhiko Yamagata (except the parts copied from decode_nal_units)
- *
- * @param[out] recovery_frame_cnt. Valid only if GDR.
- * @return 0: no recovery point, 1:I-frame 2:Recovery Point SEI (GDR), 3:IDR, -1:error
- */
-int avcodec_h264_search_recovery_point(AVCodecContext *avctx,
- const uint8_t *buf, int buf_size, int *recovery_frame_cnt)
-{
- H264Context *h;
- MpegEncContext *s;
- int buf_index = 0;
- int found = 0; // 0: no recovery point, 1:Recovery Point SEI (GDR), 2:IDR
- AVCodecContext *users_MpegEncContext_avctx;
-
- avctx = get_thread0_avctx(avctx); // Next frame will start on thread 0, and we want to store SPS and PPS in the context of thread 0.
- h = avctx->priv_data;
- h->is_avc = avcodec_h264_decode_init_is_avc(avctx);
- s = &h->s;
- users_MpegEncContext_avctx = s->avctx; // save it and write back before return.
-
- if (s->avctx == NULL)
- s->avctx = avctx; // Hack, this function can be used before decoding, so we can't expect everything initialized.
-
- h->nal_length_size = avctx->nal_length_size ? avctx->nal_length_size : 4;
-
- for (;;) {
- int consumed;
- int dst_length;
- int bit_length;
- const uint8_t *ptr;
- int i, nalsize = 0;
-
- if (h->is_avc) {
- if (buf_index >= buf_size) break;
- nalsize = 0;
- for (i = 0; i < h->nal_length_size; i++)
- nalsize = (nalsize << 8) | buf[buf_index++];
- if (nalsize <= 1 || (nalsize + buf_index > buf_size)) {
- if (nalsize == 1) {
- buf_index++;
- continue;
- } else {
- av_log(h->s.avctx, AV_LOG_ERROR, "AVC: nal size %d\n", nalsize);
- break;
- }
- }
- } else {
- // start code prefix search
- for (; buf_index + 3 < buf_size; 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) break;
-
- buf_index += 3;
- }
-
- ptr = ff_h264_decode_nal(h, buf + buf_index, &dst_length, &consumed, h->is_avc ? nalsize : buf_size - buf_index);
- if (ptr == NULL || dst_length < 0) {
- found = -1;
- goto end;
- }
- while (ptr[dst_length - 1] == 0 && dst_length > 0)
- dst_length--;
- bit_length = !dst_length ? 0 : (8 * dst_length - decode_rbsp_trailing(h, ptr + dst_length - 1));
-
- if (h->is_avc && (nalsize != consumed)) {
- av_log(h->s.avctx, AV_LOG_ERROR, "AVC: Consumed only %d bytes instead of %d\n", consumed, nalsize);
- consumed = nalsize;
- }
-
- buf_index += consumed;
-
-
- switch (h->nal_unit_type) {
- case NAL_SEI:
- if (ptr[0] == 6/* Recovery Point SEI */) {
- init_get_bits(&s->gb, ptr, bit_length);
- ff_h264_decode_sei(h);
- if (found < 2)
- found = 2;
- break;
- }
- break;
- case NAL_SPS:
- init_get_bits(&s->gb, ptr, bit_length);
- ff_h264_decode_seq_parameter_set(h);
-
- if (s->flags & CODEC_FLAG_LOW_DELAY)
- s->low_delay = 1;
-
- if (avctx->has_b_frames < 2)
- avctx->has_b_frames = !s->low_delay;
- break;
- case NAL_PPS:
- init_get_bits(&s->gb, ptr, bit_length);
-
- ff_h264_decode_picture_parameter_set(h, bit_length);
-
- break;
- case NAL_AUD: {
- int primary_pic_type;
- init_get_bits(&s->gb, ptr, bit_length);
- primary_pic_type = get_bits(&s->gb, 3);
- if (found == 0 && (primary_pic_type == 0 || primary_pic_type == 3)) // I-frame (all I/SI slices)
- found = 1;
- break;
- }
- case NAL_IDR_SLICE:
- case NAL_SLICE:
- case NAL_DPA:
- // decode part of slice header and find I frame
- init_get_bits(&s->gb, ptr, bit_length);
- int first_mb_in_slice = get_ue_golomb(&s->gb);
- unsigned int slice_type = get_ue_golomb(&s->gb);
- if (!is_I_slice(slice_type))
- goto end;
-
- // at least one slice must start at the left top corner.
- // ASO should work, while FMO may not. FMO is not supported by current Libav anyway.
- if (first_mb_in_slice == 0) {
- if (h->nal_unit_type == NAL_IDR_SLICE) {
- found = 3;
- goto end;
- } else {
- if (found == 0) {
- found = 1;
- goto end;
- }
- }
- }
- break;
- case NAL_DPB:
- case NAL_DPC:
- case NAL_END_SEQUENCE:
- case NAL_END_STREAM:
- case NAL_FILLER_DATA:
- case NAL_SPS_EXT:
- case NAL_AUXILIARY_SLICE:
- break;
- default:
- av_log(avctx, AV_LOG_DEBUG, "Unknown NAL code: %d (%d bits)\n", h->nal_unit_type, bit_length);
- }
-
- }
- *recovery_frame_cnt = h->sei_recovery_frame_cnt;
-end:
- s->avctx = users_MpegEncContext_avctx;
- return found;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264_refs.c b/src/thirdparty/ffmpeg/libavcodec/h264_refs.c
deleted file mode 100644
index bc97ba5c8..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264_refs.c
+++ /dev/null
@@ -1,784 +0,0 @@
-/*
- * H.26L/H.264/AVC/JVT/14496-10/... reference picture handling
- * 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 reference picture handling.
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#include "libavutil/avassert.h"
-#include "internal.h"
-#include "dsputil.h"
-#include "avcodec.h"
-#include "h264.h"
-#include "golomb.h"
-
-//#undef NDEBUG
-#include <assert.h>
-
-
-static void pic_as_field(Picture *pic, const int parity){
- int i;
- for (i = 0; i < 4; ++i) {
- if (parity == PICT_BOTTOM_FIELD)
- pic->f.data[i] += pic->f.linesize[i];
- pic->f.reference = parity;
- pic->f.linesize[i] *= 2;
- }
- pic->poc= pic->field_poc[parity == PICT_BOTTOM_FIELD];
-}
-
-static int split_field_copy(Picture *dest, Picture *src,
- int parity, int id_add){
- int match = !!(src->f.reference & parity);
-
- if (match) {
- *dest = *src;
- if(parity != PICT_FRAME){
- pic_as_field(dest, parity);
- dest->pic_id *= 2;
- dest->pic_id += id_add;
- }
- }
-
- return match;
-}
-
-static int build_def_list(Picture *def, Picture **in, int len, int is_long, int sel){
- int i[2]={0};
- int index=0;
-
- while(i[0]<len || i[1]<len){
- while (i[0] < len && !(in[ i[0] ] && (in[ i[0] ]->f.reference & sel)))
- i[0]++;
- while (i[1] < len && !(in[ i[1] ] && (in[ i[1] ]->f.reference & (sel^3))))
- i[1]++;
- if(i[0] < len){
- in[ i[0] ]->pic_id= is_long ? i[0] : in[ i[0] ]->frame_num;
- split_field_copy(&def[index++], in[ i[0]++ ], sel , 1);
- }
- if(i[1] < len){
- in[ i[1] ]->pic_id= is_long ? i[1] : in[ i[1] ]->frame_num;
- split_field_copy(&def[index++], in[ i[1]++ ], sel^3, 0);
- }
- }
-
- return index;
-}
-
-static int add_sorted(Picture **sorted, Picture **src, int len, int limit, int dir){
- int i, best_poc;
- int out_i= 0;
-
- for(;;){
- best_poc= dir ? INT_MIN : INT_MAX;
-
- for(i=0; i<len; i++){
- const int poc= src[i]->poc;
- if(((poc > limit) ^ dir) && ((poc < best_poc) ^ dir)){
- best_poc= poc;
- sorted[out_i]= src[i];
- }
- }
- if(best_poc == (dir ? INT_MIN : INT_MAX))
- break;
- limit= sorted[out_i++]->poc - dir;
- }
- return out_i;
-}
-
-int ff_h264_fill_default_ref_list(H264Context *h){
- MpegEncContext * const s = &h->s;
- int i, len;
-
- if(h->slice_type_nos==AV_PICTURE_TYPE_B){
- Picture *sorted[32];
- int cur_poc, list;
- int lens[2];
-
- if(FIELD_PICTURE)
- cur_poc= s->current_picture_ptr->field_poc[ s->picture_structure == PICT_BOTTOM_FIELD ];
- else
- cur_poc= s->current_picture_ptr->poc;
-
- for(list= 0; list<2; list++){
- len= add_sorted(sorted , h->short_ref, h->short_ref_count, cur_poc, 1^list);
- len+=add_sorted(sorted+len, h->short_ref, h->short_ref_count, cur_poc, 0^list);
- av_assert0(len<=32);
- len= build_def_list(h->default_ref_list[list] , sorted , len, 0, s->picture_structure);
- len+=build_def_list(h->default_ref_list[list]+len, h->long_ref, 16 , 1, s->picture_structure);
- 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));
- lens[list]= len;
- }
-
- if(lens[0] == lens[1] && lens[1] > 1){
- for (i = 0; h->default_ref_list[0][i].f.data[0] == h->default_ref_list[1][i].f.data[0] && i < lens[0]; i++);
- if(i == lens[0])
- FFSWAP(Picture, h->default_ref_list[1][0], h->default_ref_list[1][1]);
- }
- }else{
- len = build_def_list(h->default_ref_list[0] , h->short_ref, h->short_ref_count, 0, s->picture_structure);
- len+= build_def_list(h->default_ref_list[0]+len, h-> long_ref, 16 , 1, s->picture_structure);
- 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));
- }
-#ifdef TRACE
- for (i=0; i<h->ref_count[0]; i++) {
- tprintf(h->s.avctx, "List0: %s fn:%d 0x%p\n", (h->default_ref_list[0][i].long_ref ? "LT" : "ST"), h->default_ref_list[0][i].pic_id, h->default_ref_list[0][i].f.data[0]);
- }
- if(h->slice_type_nos==AV_PICTURE_TYPE_B){
- for (i=0; i<h->ref_count[1]; i++) {
- tprintf(h->s.avctx, "List1: %s fn:%d 0x%p\n", (h->default_ref_list[1][i].long_ref ? "LT" : "ST"), h->default_ref_list[1][i].pic_id, h->default_ref_list[1][i].f.data[0]);
- }
- }
-#endif
- return 0;
-}
-
-static void print_short_term(H264Context *h);
-static void print_long_term(H264Context *h);
-
-/**
- * Extract structure information about the picture described by pic_num in
- * the current decoding context (frame or field). Note that pic_num is
- * picture number without wrapping (so, 0<=pic_num<max_pic_num).
- * @param pic_num picture number for which to extract structure information
- * @param structure one of PICT_XXX describing structure of picture
- * with pic_num
- * @return frame number (short term) or long term index of picture
- * described by pic_num
- */
-static int pic_num_extract(H264Context *h, int pic_num, int *structure){
- MpegEncContext * const s = &h->s;
-
- *structure = s->picture_structure;
- if(FIELD_PICTURE){
- if (!(pic_num & 1))
- /* opposite field */
- *structure ^= PICT_FRAME;
- pic_num >>= 1;
- }
-
- return pic_num;
-}
-
-int ff_h264_decode_ref_pic_list_reordering(H264Context *h){
- MpegEncContext * const s = &h->s;
- int list, index, pic_structure;
-
- print_short_term(h);
- print_long_term(h);
-
- for(list=0; list<h->list_count; list++){
- memcpy(h->ref_list[list], h->default_ref_list[list], sizeof(Picture)*h->ref_count[list]);
-
- if(get_bits1(&s->gb)){
- int pred= h->curr_pic_num;
-
- for(index=0; ; index++){
- unsigned int reordering_of_pic_nums_idc= get_ue_golomb_31(&s->gb);
- unsigned int pic_id;
- int i;
- Picture *ref = NULL;
-
- if(reordering_of_pic_nums_idc==3)
- break;
-
- if(index >= h->ref_count[list]){
- av_log(h->s.avctx, AV_LOG_ERROR, "reference count overflow\n");
- 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(&s->gb) + 1;
- int frame_num;
-
- if(abs_diff_pic_num > h->max_pic_num){
- av_log(h->s.avctx, AV_LOG_ERROR, "abs_diff_pic_num overflow\n");
- return -1;
- }
-
- 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->f.reference);
- assert(!ref->long_ref);
- if(
- ref->frame_num == frame_num &&
- (ref->f.reference & pic_structure)
- )
- break;
- }
- if(i>=0)
- ref->pic_id= pred;
- }else{
- int long_idx;
- pic_id= get_ue_golomb(&s->gb); //long_term_pic_idx
-
- long_idx= pic_num_extract(h, pic_id, &pic_structure);
-
- if(long_idx>31){
- av_log(h->s.avctx, AV_LOG_ERROR, "long_term_pic_idx overflow\n");
- return -1;
- }
- ref = h->long_ref[long_idx];
- assert(!(ref && !ref->f.reference));
- if (ref && (ref->f.reference & pic_structure)) {
- ref->pic_id= pic_id;
- assert(ref->long_ref);
- i=0;
- }else{
- i=-1;
- }
- }
-
- if (i < 0) {
- av_log(h->s.avctx, AV_LOG_ERROR, "reference picture missing during reorder\n");
- memset(&h->ref_list[list][index], 0, sizeof(Picture)); //FIXME
- } 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--){
- h->ref_list[list][i]= h->ref_list[list][i-1];
- }
- h->ref_list[list][index]= *ref;
- if (FIELD_PICTURE){
- pic_as_field(&h->ref_list[list][index], pic_structure);
- }
- }
- }else{
- av_log(h->s.avctx, AV_LOG_ERROR, "illegal reordering_of_pic_nums_idc\n");
- return -1;
- }
- }
- }
- }
- for(list=0; list<h->list_count; list++){
- for(index= 0; index < h->ref_count[list]; index++){
- if (!h->ref_list[list][index].f.data[0]) {
- int i;
- av_log(h->s.avctx, AV_LOG_ERROR, "Missing reference picture, default is %d\n", h->default_ref_list[list][0].poc);
- for (i=0; i<FF_ARRAY_ELEMS(h->last_pocs); i++)
- h->last_pocs[i] = INT_MIN;
- if (h->default_ref_list[list][0].f.data[0])
- h->ref_list[list][index]= h->default_ref_list[list][0];
- else
- return -1;
- }
- }
- }
-
- return 0;
-}
-
-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];
- field[0] = *frame;
- for(j=0; j<3; j++)
- field[0].f.linesize[j] <<= 1;
- field[0].f.reference = PICT_TOP_FIELD;
- field[0].poc= field[0].field_poc[0];
- field[1] = field[0];
- for(j=0; j<3; j++)
- field[1].f.data[j] += frame->f.linesize[j];
- field[1].f.reference = PICT_BOTTOM_FIELD;
- field[1].poc= field[1].field_poc[1];
-
- h->luma_weight[16+2*i][list][0] = h->luma_weight[16+2*i+1][list][0] = h->luma_weight[i][list][0];
- h->luma_weight[16+2*i][list][1] = h->luma_weight[16+2*i+1][list][1] = h->luma_weight[i][list][1];
- for(j=0; j<2; j++){
- h->chroma_weight[16+2*i][list][j][0] = h->chroma_weight[16+2*i+1][list][j][0] = h->chroma_weight[i][list][j][0];
- h->chroma_weight[16+2*i][list][j][1] = h->chroma_weight[16+2*i+1][list][j][1] = h->chroma_weight[i][list][j][1];
- }
- }
- }
-}
-
-/**
- * Mark a picture as no longer needed for reference. The refmask
- * argument allows unreferencing of individual fields or the whole frame.
- * If the picture becomes entirely unreferenced, but is being held for
- * display purposes, it is marked as such.
- * @param refmask mask of fields to unreference; the mask is bitwise
- * anded with the reference marking of pic
- * @return non-zero if pic becomes entirely unreferenced (except possibly
- * for display purposes) zero if one of the fields remains in
- * reference
- */
-static inline int unreference_pic(H264Context *h, Picture *pic, int refmask){
- int i;
- if (pic->f.reference &= refmask) {
- return 0;
- } else {
- for(i = 0; h->delayed_pic[i]; i++)
- if(pic == h->delayed_pic[i]){
- pic->f.reference = DELAYED_PIC_REF;
- break;
- }
- return 1;
- }
-}
-
-/**
- * Find a Picture 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){
- MpegEncContext * const s = &h->s;
- int i;
-
- for(i=0; i<h->short_ref_count; i++){
- Picture *pic= h->short_ref[i];
- if(s->avctx->debug&FF_DEBUG_MMCO)
- av_log(h->s.avctx, AV_LOG_DEBUG, "%d %d %p\n", i, pic->frame_num, pic);
- if(pic->frame_num == frame_num) {
- *idx = i;
- return pic;
- }
- }
- return NULL;
-}
-
-/**
- * Remove a picture from the short term reference list by its index in
- * that list. This does no checking on the provided index; it is assumed
- * to be valid. Other list entries are shifted down.
- * @param i index into h->short_ref of picture to remove.
- */
-static void remove_short_at_index(H264Context *h, int i){
- assert(i >= 0 && i < h->short_ref_count);
- 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*));
-}
-
-/**
- *
- * @return the removed picture or NULL if an error occurs
- */
-static Picture * remove_short(H264Context *h, int frame_num, int ref_mask){
- MpegEncContext * const s = &h->s;
- Picture *pic;
- int i;
-
- if(s->avctx->debug&FF_DEBUG_MMCO)
- av_log(h->s.avctx, AV_LOG_DEBUG, "remove short %d count %d\n", frame_num, h->short_ref_count);
-
- pic = find_short(h, frame_num, &i);
- if (pic){
- if(unreference_pic(h, pic, ref_mask))
- remove_short_at_index(h, i);
- }
-
- return pic;
-}
-
-/**
- * Remove a picture from the long term reference list by its index in
- * that list.
- * @return the removed picture or NULL if an error occurs
- */
-static Picture * remove_long(H264Context *h, int i, int ref_mask){
- Picture *pic;
-
- pic= h->long_ref[i];
- if (pic){
- if(unreference_pic(h, pic, ref_mask)){
- assert(h->long_ref[i]->long_ref == 1);
- h->long_ref[i]->long_ref= 0;
- h->long_ref[i]= NULL;
- h->long_ref_count--;
- }
- }
-
- return pic;
-}
-
-void ff_h264_remove_all_refs(H264Context *h){
- int i;
-
- for(i=0; i<16; i++){
- remove_long(h, i, 0);
- }
- assert(h->long_ref_count==0);
-
- for(i=0; i<h->short_ref_count; i++){
- unreference_pic(h, h->short_ref[i], 0);
- h->short_ref[i]= NULL;
- }
- h->short_ref_count=0;
-
- memset(h->default_ref_list, 0, sizeof(h->default_ref_list));
- memset(h->ref_list, 0, sizeof(h->ref_list));
-}
-
-/**
- * print short term list
- */
-static void print_short_term(H264Context *h) {
- uint32_t i;
- if(h->s.avctx->debug&FF_DEBUG_MMCO) {
- av_log(h->s.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->s.avctx, AV_LOG_DEBUG, "%d fn:%d poc:%d %p\n",
- i, pic->frame_num, pic->poc, pic->f.data[0]);
- }
- }
-}
-
-/**
- * print long term list
- */
-static void print_long_term(H264Context *h) {
- uint32_t i;
- if(h->s.avctx->debug&FF_DEBUG_MMCO) {
- av_log(h->s.avctx, AV_LOG_DEBUG, "long term list:\n");
- for(i = 0; i < 16; i++){
- Picture *pic= h->long_ref[i];
- if (pic) {
- av_log(h->s.avctx, AV_LOG_DEBUG, "%d fn:%d poc:%d %p\n",
- i, pic->frame_num, pic->poc, pic->f.data[0]);
- }
- }
- }
-}
-
-static int check_opcodes(MMCO *mmco1, MMCO *mmco2, int n_mmcos)
-{
- int i;
-
- for (i = 0; i < n_mmcos; i++) {
- if (mmco1[i].opcode != mmco2[i].opcode) {
- av_log(NULL, AV_LOG_ERROR, "MMCO opcode [%d, %d] at %d mismatches between slices\n",
- mmco1[i].opcode, mmco2[i].opcode, i);
- return -1;
- }
- }
-
- return 0;
-}
-
-int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice)
-{
- MpegEncContext * const s = &h->s;
- MMCO mmco_temp[MAX_MMCO_COUNT], *mmco = first_slice ? h->mmco : mmco_temp;
- int mmco_index = 0, i;
-
- if (h->short_ref_count &&
- h->long_ref_count + h->short_ref_count >= h->sps.ref_frame_count &&
- !(FIELD_PICTURE && !s->first_field &&
- s->current_picture_ptr->f.reference)) {
- mmco[0].opcode = MMCO_SHORT2UNUSED;
- mmco[0].short_pic_num = h->short_ref[h->short_ref_count - 1]->frame_num;
- mmco_index = 1;
- if (FIELD_PICTURE) {
- mmco[0].short_pic_num *= 2;
- mmco[1].opcode = MMCO_SHORT2UNUSED;
- mmco[1].short_pic_num = mmco[0].short_pic_num + 1;
- mmco_index = 2;
- }
- }
-
- if (first_slice) {
- h->mmco_index = mmco_index;
- } else if (!first_slice && mmco_index >= 0 &&
- (mmco_index != h->mmco_index ||
- (i = check_opcodes(h->mmco, mmco_temp, mmco_index)))) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "Inconsistent MMCO state between slices [%d, %d]\n",
- mmco_index, h->mmco_index);
- return AVERROR_INVALIDDATA;
- }
- return 0;
-}
-
-int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
- MpegEncContext * const s = &h->s;
- int i, av_uninit(j);
- int current_ref_assigned=0, err=0;
- Picture *av_uninit(pic);
-
- if((s->avctx->debug&FF_DEBUG_MMCO) && mmco_count==0)
- av_log(h->s.avctx, AV_LOG_DEBUG, "no mmco here\n");
-
- for(i=0; i<mmco_count; i++){
- int av_uninit(structure), av_uninit(frame_num);
- if(s->avctx->debug&FF_DEBUG_MMCO)
- av_log(h->s.avctx, AV_LOG_DEBUG, "mmco:%d %d %d\n", h->mmco[i].opcode, h->mmco[i].short_pic_num, h->mmco[i].long_arg);
-
- if( mmco[i].opcode == MMCO_SHORT2UNUSED
- || mmco[i].opcode == MMCO_SHORT2LONG){
- frame_num = pic_num_extract(h, mmco[i].short_pic_num, &structure);
- pic = find_short(h, frame_num, &j);
- if(!pic){
- if(mmco[i].opcode != MMCO_SHORT2LONG || !h->long_ref[mmco[i].long_arg]
- || h->long_ref[mmco[i].long_arg]->frame_num != frame_num) {
- av_log(h->s.avctx, AV_LOG_ERROR, "mmco: unref short failure\n");
- err = AVERROR_INVALIDDATA;
- }
- continue;
- }
- }
-
- switch(mmco[i].opcode){
- case MMCO_SHORT2UNUSED:
- if(s->avctx->debug&FF_DEBUG_MMCO)
- av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: unref short %d count %d\n", h->mmco[i].short_pic_num, h->short_ref_count);
- remove_short(h, frame_num, structure ^ PICT_FRAME);
- break;
- case MMCO_SHORT2LONG:
- if (h->long_ref[mmco[i].long_arg] != pic)
- remove_long(h, mmco[i].long_arg, 0);
-
- remove_short_at_index(h, j);
- h->long_ref[ mmco[i].long_arg ]= pic;
- if (h->long_ref[ mmco[i].long_arg ]){
- h->long_ref[ mmco[i].long_arg ]->long_ref=1;
- h->long_ref_count++;
- }
- break;
- case MMCO_LONG2UNUSED:
- j = pic_num_extract(h, mmco[i].long_arg, &structure);
- pic = h->long_ref[j];
- if (pic) {
- remove_long(h, j, structure ^ PICT_FRAME);
- } else if(s->avctx->debug&FF_DEBUG_MMCO)
- av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: unref long failure\n");
- break;
- case MMCO_LONG:
- // Comment below left from previous code as it is an interresting note.
- /* First field in pair is in short term list or
- * at a different long term index.
- * This is not allowed; see 7.4.3.3, notes 2 and 3.
- * Report the problem and keep the pair where it is,
- * and mark this field valid.
- */
-
- if (h->long_ref[mmco[i].long_arg] != s->current_picture_ptr) {
- remove_long(h, mmco[i].long_arg, 0);
-
- h->long_ref[ mmco[i].long_arg ]= s->current_picture_ptr;
- h->long_ref[ mmco[i].long_arg ]->long_ref=1;
- h->long_ref_count++;
- }
-
- s->current_picture_ptr->f.reference |= s->picture_structure;
- current_ref_assigned=1;
- break;
- case MMCO_SET_MAX_LONG:
- assert(mmco[i].long_arg <= 16);
- // just remove the long term which index is greater than new max
- for(j = mmco[i].long_arg; j<16; j++){
- remove_long(h, j, 0);
- }
- break;
- case MMCO_RESET:
- while(h->short_ref_count){
- remove_short(h, h->short_ref[0]->frame_num, 0);
- }
- for(j = 0; j < 16; j++) {
- remove_long(h, j, 0);
- }
- h->frame_num=
- s->current_picture_ptr->frame_num= 0;
- h->mmco_reset = 1;
- s->current_picture_ptr->mmco_reset=1;
- for (j = 0; j < MAX_DELAYED_PIC_COUNT; j++)
- h->last_pocs[j] = INT_MIN;
- break;
- default: assert(0);
- }
- }
-
- if (!current_ref_assigned) {
- /* Second field of complementary field pair; the first field of
- * which is already referenced. If short referenced, it
- * should be first entry in short_ref. If not, it must exist
- * in long_ref; trying to put it on the short list here is an
- * error in the encoded bit stream (ref: 7.4.3.3, NOTE 2 and 3).
- */
- if (h->short_ref_count && h->short_ref[0] == s->current_picture_ptr) {
- /* Just mark the second field valid */
- s->current_picture_ptr->f.reference = PICT_FRAME;
- } else if (s->current_picture_ptr->long_ref) {
- av_log(h->s.avctx, AV_LOG_ERROR, "illegal short term reference "
- "assignment for second field "
- "in complementary field pair "
- "(first field is long term)\n");
- err = AVERROR_INVALIDDATA;
- } else {
- pic= remove_short(h, s->current_picture_ptr->frame_num, 0);
- if(pic){
- av_log(h->s.avctx, AV_LOG_ERROR, "illegal short term buffer state detected\n");
- err = AVERROR_INVALIDDATA;
- }
-
- if(h->short_ref_count)
- memmove(&h->short_ref[1], &h->short_ref[0], h->short_ref_count*sizeof(Picture*));
-
- h->short_ref[0]= s->current_picture_ptr;
- h->short_ref_count++;
- s->current_picture_ptr->f.reference |= s->picture_structure;
- }
- }
-
- if (h->long_ref_count + h->short_ref_count > FFMAX(h->sps.ref_frame_count, 1)){
-
- /* We have too many reference frames, probably due to corrupted
- * stream. Need to discard one frame. Prevents overrun of the
- * short_ref and long_ref buffers.
- */
- av_log(h->s.avctx, AV_LOG_ERROR,
- "number of reference frames (%d+%d) exceeds max (%d; probably "
- "corrupt input), discarding one\n",
- h->long_ref_count, h->short_ref_count, h->sps.ref_frame_count);
- err = AVERROR_INVALIDDATA;
-
- if (h->long_ref_count && !h->short_ref_count) {
- for (i = 0; i < 16; ++i)
- if (h->long_ref[i])
- break;
-
- assert(i < 16);
- remove_long(h, i, 0);
- } else {
- pic = h->short_ref[h->short_ref_count - 1];
- remove_short(h, pic->frame_num, 0);
- }
- }
-
- print_short_term(h);
- print_long_term(h);
-
- if(err >= 0 && h->long_ref_count==0 && h->short_ref_count<=2 && h->pps.ref_count[0]<=1 + (s->picture_structure != PICT_FRAME) && s->current_picture_ptr->f.pict_type == AV_PICTURE_TYPE_I){
- s->current_picture_ptr->sync |= 1;
- if(!h->s.avctx->has_b_frames)
- h->sync = 2;
- }
-
- return (h->s.avctx->err_recognition & AV_EF_EXPLODE) ? err : 0;
-}
-
-int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb,
- int first_slice)
-{
- MpegEncContext * const s = &h->s;
- int i, ret;
- MMCO mmco_temp[MAX_MMCO_COUNT], *mmco = first_slice ? h->mmco : mmco_temp;
- int mmco_index = 0;
-
- if (h->nal_unit_type == NAL_IDR_SLICE){ // FIXME fields
- s->broken_link = get_bits1(gb) - 1;
- if (get_bits1(gb)){
- mmco[0].opcode = MMCO_LONG;
- mmco[0].long_arg = 0;
- mmco_index = 1;
- }
- } else {
- if (get_bits1(gb)) { // adaptive_ref_pic_marking_mode_flag
- for (i = 0; i < MAX_MMCO_COUNT; i++) {
- MMCOOpcode opcode = get_ue_golomb_31(gb);
-
- mmco[i].opcode = opcode;
- if (opcode == MMCO_SHORT2UNUSED || opcode == MMCO_SHORT2LONG){
- mmco[i].short_pic_num =
- (h->curr_pic_num - get_ue_golomb(gb) - 1) &
- (h->max_pic_num - 1);
-#if 0
- if (mmco[i].short_pic_num >= h->short_ref_count ||
- h->short_ref[ mmco[i].short_pic_num ] == NULL){
- av_log(s->avctx, AV_LOG_ERROR,
- "illegal short ref in memory management control "
- "operation %d\n", mmco);
- return -1;
- }
-#endif
- }
- if (opcode == MMCO_SHORT2LONG || opcode == MMCO_LONG2UNUSED ||
- opcode == MMCO_LONG || opcode == MMCO_SET_MAX_LONG) {
- unsigned int long_arg = get_ue_golomb_31(gb);
- if (long_arg >= 32 ||
- (long_arg >= 16 && !(opcode == MMCO_SET_MAX_LONG &&
- long_arg == 16) &&
- !(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE))){
- av_log(h->s.avctx, AV_LOG_ERROR,
- "illegal long ref in memory management control "
- "operation %d\n", opcode);
- return -1;
- }
- mmco[i].long_arg = long_arg;
- }
-
- if (opcode > (unsigned) MMCO_LONG){
- av_log(h->s.avctx, AV_LOG_ERROR,
- "illegal memory management control operation %d\n",
- opcode);
- return -1;
- }
- if (opcode == MMCO_END)
- break;
- }
- mmco_index = i;
- } else {
- if (first_slice) {
- ret = ff_generate_sliding_window_mmcos(h, first_slice);
- if (ret < 0 && s->avctx->err_recognition & AV_EF_EXPLODE)
- return ret;
- }
- mmco_index = -1;
- }
- }
-
- if (first_slice && mmco_index != -1) {
- h->mmco_index = mmco_index;
- } else if (!first_slice && mmco_index >= 0 &&
- (mmco_index != h->mmco_index ||
- (i = check_opcodes(h->mmco, mmco_temp, mmco_index)))) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "Inconsistent MMCO state between slices [%d, %d]\n",
- mmco_index, h->mmco_index);
- return AVERROR_INVALIDDATA;
- }
-
- return 0;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264_sei.c b/src/thirdparty/ffmpeg/libavcodec/h264_sei.c
deleted file mode 100644
index 9104612a5..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264_sei.c
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * H.26L/H.264/AVC/JVT/14496-10/... sei decoding
- * 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 sei decoding.
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#include "internal.h"
-#include "avcodec.h"
-#include "h264.h"
-#include "golomb.h"
-
-//#undef NDEBUG
-#include <assert.h>
-
-static const uint8_t sei_num_clock_ts_table[9]={
- 1, 1, 1, 2, 2, 3, 3, 2, 3
-};
-
-void ff_h264_reset_sei(H264Context *h) {
- h->sei_recovery_frame_cnt = -1;
- h->sei_dpb_output_delay = 0;
- h->sei_cpb_removal_delay = -1;
- h->sei_buffering_period_present = 0;
-}
-
-static int decode_picture_timing(H264Context *h){
- MpegEncContext * const s = &h->s;
- if(h->sps.nal_hrd_parameters_present_flag || h->sps.vcl_hrd_parameters_present_flag){
- h->sei_cpb_removal_delay = get_bits_long(&s->gb, h->sps.cpb_removal_delay_length);
- h->sei_dpb_output_delay = get_bits_long(&s->gb, h->sps.dpb_output_delay_length);
- }
- if(h->sps.pic_struct_present_flag){
- unsigned int i, num_clock_ts;
- h->sei_pic_struct = get_bits(&s->gb, 4);
- h->sei_ct_type = 0;
-
- if (h->sei_pic_struct > SEI_PIC_STRUCT_FRAME_TRIPLING)
- return -1;
-
- num_clock_ts = sei_num_clock_ts_table[h->sei_pic_struct];
-
- for (i = 0 ; i < num_clock_ts ; i++){
- if(get_bits(&s->gb, 1)){ /* clock_timestamp_flag */
- unsigned int full_timestamp_flag;
- h->sei_ct_type |= 1<<get_bits(&s->gb, 2);
- skip_bits(&s->gb, 1); /* nuit_field_based_flag */
- skip_bits(&s->gb, 5); /* counting_type */
- full_timestamp_flag = get_bits(&s->gb, 1);
- skip_bits(&s->gb, 1); /* discontinuity_flag */
- skip_bits(&s->gb, 1); /* cnt_dropped_flag */
- skip_bits(&s->gb, 8); /* n_frames */
- if(full_timestamp_flag){
- skip_bits(&s->gb, 6); /* seconds_value 0..59 */
- skip_bits(&s->gb, 6); /* minutes_value 0..59 */
- skip_bits(&s->gb, 5); /* hours_value 0..23 */
- }else{
- if(get_bits(&s->gb, 1)){ /* seconds_flag */
- skip_bits(&s->gb, 6); /* seconds_value range 0..59 */
- if(get_bits(&s->gb, 1)){ /* minutes_flag */
- skip_bits(&s->gb, 6); /* minutes_value 0..59 */
- if(get_bits(&s->gb, 1)) /* hours_flag */
- skip_bits(&s->gb, 5); /* hours_value 0..23 */
- }
- }
- }
- if(h->sps.time_offset_length > 0)
- skip_bits(&s->gb, h->sps.time_offset_length); /* time_offset */
- }
- }
-
- if(s->avctx->debug & FF_DEBUG_PICT_INFO)
- av_log(s->avctx, AV_LOG_DEBUG, "ct_type:%X pic_struct:%d\n", h->sei_ct_type, h->sei_pic_struct);
- }
- return 0;
-}
-
-static int decode_user_data_itu_t_t35(H264Context *h, int size) {
- MpegEncContext * const s = &h->s;
- uint32_t user_identifier;
- int dtg_active_format;
-
- if (size < 7)
- return -1;
- size -= 7;
-
- skip_bits(&s->gb, 8); // country_code
- skip_bits(&s->gb, 16); // provider_code
- user_identifier = get_bits_long(&s->gb, 32);
-
- switch (user_identifier) {
- case 0x44544731: // "DTG1" - AFD_data
- if (size < 1)
- return -1;
- skip_bits(&s->gb, 1);
- if (get_bits(&s->gb, 1)) {
- skip_bits(&s->gb, 6);
- if (size < 2)
- return -1;
- skip_bits(&s->gb, 4);
- dtg_active_format = get_bits(&s->gb, 4);
- s->avctx->dtg_active_format = dtg_active_format;
- } else {
- skip_bits(&s->gb, 6);
- }
- break;
- default:
- skip_bits(&s->gb, size * 8);
- break;
- }
-
- return 0;
-}
-
-static int decode_unregistered_user_data(H264Context *h, int size){
- MpegEncContext * const s = &h->s;
- uint8_t user_data[16+256];
- int e, build, i;
-
- if(size<16)
- return -1;
-
- for(i=0; i<sizeof(user_data)-1 && i<size; i++){
- user_data[i]= get_bits(&s->gb, 8);
- }
-
- user_data[i]= 0;
- e= sscanf(user_data+16, "x264 - core %d"/*%s - H.264/MPEG-4 AVC codec - Copyleft 2005 - http://www.videolan.org/x264.html*/, &build);
- if(e==1 && build>0)
- h->x264_build= build;
- if(e==1 && build==1 && !strncmp(user_data+16, "x264 - core 0000", 16))
- h->x264_build = 67;
-
- if(s->avctx->debug & FF_DEBUG_BUGS)
- av_log(s->avctx, AV_LOG_DEBUG, "user data:\"%s\"\n", user_data+16);
-
- for(; i<size; i++)
- skip_bits(&s->gb, 8);
-
- return 0;
-}
-
-static int decode_recovery_point(H264Context *h){
- MpegEncContext * const s = &h->s;
-
- h->sei_recovery_frame_cnt = get_ue_golomb(&s->gb);
- skip_bits(&s->gb, 4); /* 1b exact_match_flag, 1b broken_link_flag, 2b changing_slice_group_idc */
-
- return 0;
-}
-
-static int decode_buffering_period(H264Context *h){
- MpegEncContext * const s = &h->s;
- unsigned int sps_id;
- int sched_sel_idx;
- SPS *sps;
-
- sps_id = get_ue_golomb_31(&s->gb);
- if(sps_id > 31 || !h->sps_buffers[sps_id]) {
- av_log(h->s.avctx, AV_LOG_ERROR, "non-existing SPS %d referenced in buffering period\n", sps_id);
- return -1;
- }
- sps = h->sps_buffers[sps_id];
-
- // NOTE: This is really so duplicated in the standard... See H.264, D.1.1
- if (sps->nal_hrd_parameters_present_flag) {
- for (sched_sel_idx = 0; sched_sel_idx < sps->cpb_cnt; sched_sel_idx++) {
- h->initial_cpb_removal_delay[sched_sel_idx] = get_bits_long(&s->gb, sps->initial_cpb_removal_delay_length);
- skip_bits(&s->gb, sps->initial_cpb_removal_delay_length); // initial_cpb_removal_delay_offset
- }
- }
- if (sps->vcl_hrd_parameters_present_flag) {
- for (sched_sel_idx = 0; sched_sel_idx < sps->cpb_cnt; sched_sel_idx++) {
- h->initial_cpb_removal_delay[sched_sel_idx] = get_bits_long(&s->gb, sps->initial_cpb_removal_delay_length);
- skip_bits(&s->gb, sps->initial_cpb_removal_delay_length); // initial_cpb_removal_delay_offset
- }
- }
-
- h->sei_buffering_period_present = 1;
- return 0;
-}
-
-int ff_h264_decode_sei(H264Context *h){
- MpegEncContext * const s = &h->s;
-
- while (get_bits_left(&s->gb) > 16) {
- int size, type;
-
- type=0;
- do{
- if (get_bits_left(&s->gb) < 8)
- return -1;
- type+= show_bits(&s->gb, 8);
- }while(get_bits(&s->gb, 8) == 255);
-
- size=0;
- do{
- if (get_bits_left(&s->gb) < 8)
- return -1;
- size+= show_bits(&s->gb, 8);
- }while(get_bits(&s->gb, 8) == 255);
-
- if(s->avctx->debug&FF_DEBUG_STARTCODE)
- av_log(h->s.avctx, AV_LOG_DEBUG, "SEI %d len:%d\n", type, size);
-
- switch(type){
- case SEI_TYPE_PIC_TIMING: // Picture timing SEI
- if(decode_picture_timing(h) < 0)
- return -1;
- break;
- case SEI_TYPE_USER_DATA_ITU_T_T35:
- if(decode_user_data_itu_t_t35(h, size) < 0)
- return -1;
- break;
- case SEI_TYPE_USER_DATA_UNREGISTERED:
- if(decode_unregistered_user_data(h, size) < 0)
- return -1;
- break;
- case SEI_TYPE_RECOVERY_POINT:
- if(decode_recovery_point(h) < 0)
- return -1;
- break;
- case SEI_BUFFERING_PERIOD:
- if(decode_buffering_period(h) < 0)
- return -1;
- break;
- default:
- skip_bits(&s->gb, 8*size);
- }
-
- //FIXME check bits here
- align_get_bits(&s->gb);
- }
-
- return 0;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264addpx_template.c b/src/thirdparty/ffmpeg/libavcodec/h264addpx_template.c
deleted file mode 100644
index 117376680..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264addpx_template.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
- * Copyright (c) 2003-2011 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 DSP functions.
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#include "bit_depth_template.c"
-
-static void FUNCC(ff_h264_add_pixels4)(uint8_t *_dst, int16_t *_src, int stride)
-{
- int i;
- pixel *dst = (pixel *) _dst;
- dctcoef *src = (dctcoef *) _src;
- stride /= sizeof(pixel);
-
- for (i = 0; i < 4; i++) {
- dst[0] += src[0];
- dst[1] += src[1];
- dst[2] += src[2];
- dst[3] += src[3];
-
- dst += stride;
- src += 4;
- }
-}
-
-static void FUNCC(ff_h264_add_pixels8)(uint8_t *_dst, int16_t *_src, int stride)
-{
- int i;
- pixel *dst = (pixel *) _dst;
- dctcoef *src = (dctcoef *) _src;
- stride /= sizeof(pixel);
-
- for (i = 0; i < 8; i++) {
- dst[0] += src[0];
- dst[1] += src[1];
- dst[2] += src[2];
- dst[3] += src[3];
- dst[4] += src[4];
- dst[5] += src[5];
- dst[6] += src[6];
- dst[7] += src[7];
-
- dst += stride;
- src += 8;
- }
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264chroma.c b/src/thirdparty/ffmpeg/libavcodec/h264chroma.c
deleted file mode 100644
index 3b780a04e..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264chroma.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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 "h264chroma.h"
-
-#define BIT_DEPTH 8
-#include "h264chroma_template.c"
-#undef BIT_DEPTH
-
-#define BIT_DEPTH 16
-#include "h264chroma_template.c"
-#undef BIT_DEPTH
-
-#define SET_CHROMA(depth) \
- c->put_h264_chroma_pixels_tab[0] = put_h264_chroma_mc8_ ## depth ## _c; \
- c->put_h264_chroma_pixels_tab[1] = put_h264_chroma_mc4_ ## depth ## _c; \
- c->put_h264_chroma_pixels_tab[2] = put_h264_chroma_mc2_ ## depth ## _c; \
- c->avg_h264_chroma_pixels_tab[0] = avg_h264_chroma_mc8_ ## depth ## _c; \
- c->avg_h264_chroma_pixels_tab[1] = avg_h264_chroma_mc4_ ## depth ## _c; \
- c->avg_h264_chroma_pixels_tab[2] = avg_h264_chroma_mc2_ ## depth ## _c; \
-
-void ff_h264chroma_init(H264ChromaContext *c, int bit_depth)
-{
- if (bit_depth > 8 && bit_depth <= 16) {
- SET_CHROMA(16);
- } else {
- SET_CHROMA(8);
- }
-
- if (ARCH_ARM)
- ff_h264chroma_init_arm(c, bit_depth);
- if (ARCH_PPC)
- ff_h264chroma_init_ppc(c, bit_depth);
- if (ARCH_SH4)
- ff_h264chroma_init_sh4(c, bit_depth);
- if (ARCH_X86)
- ff_h264chroma_init_x86(c, bit_depth);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264chroma.h b/src/thirdparty/ffmpeg/libavcodec/h264chroma.h
deleted file mode 100644
index 4e035b0c3..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264chroma.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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_H264CHROMA_H
-#define AVCODEC_H264CHROMA_H
-
-#include <stdint.h>
-
-typedef void (*h264_chroma_mc_func)(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int srcStride, int h, int x, int y);
-
-typedef struct H264ChromaContext {
- h264_chroma_mc_func put_h264_chroma_pixels_tab[3];
- h264_chroma_mc_func avg_h264_chroma_pixels_tab[3];
-} H264ChromaContext;
-
-void ff_h264chroma_init(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_sh4(H264ChromaContext *c, int bit_depth);
-void ff_h264chroma_init_x86(H264ChromaContext *c, int bit_depth);
-
-#endif /* AVCODEC_H264CHROMA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264chroma_template.c b/src/thirdparty/ffmpeg/libavcodec/h264chroma_template.c
deleted file mode 100644
index 93559d7c6..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264chroma_template.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (c) 2000, 2001 Fabrice Bellard
- * Copyright (c) 2002-2004 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
- */
-
-#include "libavutil/avassert.h"
-
-#include "bit_depth_template.c"
-
-#define H264_CHROMA_MC(OPNAME, OP)\
-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){\
- pixel *dst = (pixel*)_dst;\
- pixel *src = (pixel*)_src;\
- 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;\
- stride >>= sizeof(pixel)-1;\
- \
- av_assert2(x<8 && y<8 && x>=0 && y>=0);\
-\
- if(D){\
- for(i=0; i<h; i++){\
- OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
- OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
- dst+= stride;\
- src+= stride;\
- }\
- }else{\
- const int E= B+C;\
- const int step= C ? stride : 1;\
- for(i=0; i<h; i++){\
- OP(dst[0], (A*src[0] + E*src[step+0]));\
- OP(dst[1], (A*src[1] + E*src[step+1]));\
- dst+= stride;\
- src+= stride;\
- }\
- }\
-}\
-\
-static void FUNCC(OPNAME ## h264_chroma_mc4)(uint8_t *_dst/*align 8*/, uint8_t *_src/*align 1*/, int stride, int h, int x, int y){\
- pixel *dst = (pixel*)_dst;\
- pixel *src = (pixel*)_src;\
- 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;\
- stride >>= sizeof(pixel)-1;\
- \
- av_assert2(x<8 && y<8 && x>=0 && y>=0);\
-\
- if(D){\
- for(i=0; i<h; i++){\
- OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
- OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
- OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
- OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
- dst+= stride;\
- src+= stride;\
- }\
- }else{\
- const int E= B+C;\
- const int step= C ? stride : 1;\
- for(i=0; i<h; i++){\
- OP(dst[0], (A*src[0] + E*src[step+0]));\
- OP(dst[1], (A*src[1] + E*src[step+1]));\
- OP(dst[2], (A*src[2] + E*src[step+2]));\
- OP(dst[3], (A*src[3] + E*src[step+3]));\
- dst+= stride;\
- src+= stride;\
- }\
- }\
-}\
-\
-static void FUNCC(OPNAME ## h264_chroma_mc8)(uint8_t *_dst/*align 8*/, uint8_t *_src/*align 1*/, int stride, int h, int x, int y){\
- pixel *dst = (pixel*)_dst;\
- pixel *src = (pixel*)_src;\
- 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;\
- stride >>= sizeof(pixel)-1;\
- \
- av_assert2(x<8 && y<8 && x>=0 && y>=0);\
-\
- if(D){\
- for(i=0; i<h; i++){\
- OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
- OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
- OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
- OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
- OP(dst[4], (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5]));\
- OP(dst[5], (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6]));\
- OP(dst[6], (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7]));\
- OP(dst[7], (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8]));\
- dst+= stride;\
- src+= stride;\
- }\
- }else{\
- const int E= B+C;\
- const int step= C ? stride : 1;\
- for(i=0; i<h; i++){\
- OP(dst[0], (A*src[0] + E*src[step+0]));\
- OP(dst[1], (A*src[1] + E*src[step+1]));\
- OP(dst[2], (A*src[2] + E*src[step+2]));\
- OP(dst[3], (A*src[3] + E*src[step+3]));\
- OP(dst[4], (A*src[4] + E*src[step+4]));\
- OP(dst[5], (A*src[5] + E*src[step+5]));\
- OP(dst[6], (A*src[6] + E*src[step+6]));\
- OP(dst[7], (A*src[7] + E*src[step+7]));\
- dst+= stride;\
- src+= stride;\
- }\
- }\
-}
-
-#define op_avg(a, b) a = (((a)+(((b) + 32)>>6)+1)>>1)
-#define op_put(a, b) a = (((b) + 32)>>6)
-
-H264_CHROMA_MC(put_ , op_put)
-H264_CHROMA_MC(avg_ , op_avg)
-#undef op_avg
-#undef op_put
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264data.h b/src/thirdparty/ffmpeg/libavcodec/h264data.h
deleted file mode 100644
index c529a29a9..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264data.h
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * H26L/H264/AVC/JVT/14496-10/... encoder/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
- * @brief
- * H264 / AVC / MPEG4 part10 codec data table
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#ifndef AVCODEC_H264DATA_H
-#define AVCODEC_H264DATA_H
-
-#include <stdint.h>
-
-#include "libavutil/rational.h"
-#include "mpegvideo.h"
-#include "h264.h"
-
-static const uint8_t golomb_to_pict_type[5] = {
- AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, AV_PICTURE_TYPE_I,
- AV_PICTURE_TYPE_SP, AV_PICTURE_TYPE_SI
-};
-
-static const uint8_t golomb_to_intra4x4_cbp[48] = {
- 47, 31, 15, 0, 23, 27, 29, 30, 7, 11, 13, 14, 39, 43, 45, 46,
- 16, 3, 5, 10, 12, 19, 21, 26, 28, 35, 37, 42, 44, 1, 2, 4,
- 8, 17, 18, 20, 24, 6, 9, 22, 25, 32, 33, 34, 36, 40, 38, 41
-};
-
-static const uint8_t golomb_to_inter_cbp[48] = {
- 0, 16, 1, 2, 4, 8, 32, 3, 5, 10, 12, 15, 47, 7, 11, 13,
- 14, 6, 9, 31, 35, 37, 42, 44, 33, 34, 36, 40, 39, 43, 45, 46,
- 17, 18, 20, 24, 19, 21, 26, 28, 23, 27, 29, 30, 22, 25, 38, 41
-};
-
-static const uint8_t zigzag_scan[16+1] = {
- 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 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 luma_dc_zigzag_scan[16] = {
- 0 * 16 + 0 * 64, 1 * 16 + 0 * 64, 2 * 16 + 0 * 64, 0 * 16 + 2 * 64,
- 3 * 16 + 0 * 64, 0 * 16 + 1 * 64, 1 * 16 + 1 * 64, 2 * 16 + 1 * 64,
- 1 * 16 + 2 * 64, 2 * 16 + 2 * 64, 3 * 16 + 2 * 64, 0 * 16 + 3 * 64,
- 3 * 16 + 1 * 64, 1 * 16 + 3 * 64, 2 * 16 + 3 * 64, 3 * 16 + 3 * 64,
-};
-
-static const uint8_t luma_dc_field_scan[16] = {
- 0 * 16 + 0 * 64, 2 * 16 + 0 * 64, 1 * 16 + 0 * 64, 0 * 16 + 2 * 64,
- 2 * 16 + 2 * 64, 3 * 16 + 0 * 64, 1 * 16 + 2 * 64, 3 * 16 + 2 * 64,
- 0 * 16 + 1 * 64, 2 * 16 + 1 * 64, 0 * 16 + 3 * 64, 2 * 16 + 3 * 64,
- 1 * 16 + 1 * 64, 3 * 16 + 1 * 64, 1 * 16 + 3 * 64, 3 * 16 + 3 * 64,
-};
-
-static const uint8_t chroma_dc_scan[4] = {
- (0 + 0 * 2) * 16, (1 + 0 * 2) * 16,
- (0 + 1 * 2) * 16, (1 + 1 * 2) * 16,
-};
-
-static const uint8_t chroma422_dc_scan[8] = {
- (0 + 0 * 2) * 16, (0 + 1 * 2) * 16,
- (1 + 0 * 2) * 16, (0 + 2 * 2) * 16,
- (0 + 3 * 2) * 16, (1 + 1 * 2) * 16,
- (1 + 2 * 2) * 16, (1 + 3 * 2) * 16,
-};
-
-// 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 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,
-};
-
-typedef struct IMbInfo {
- uint16_t type;
- uint8_t pred_mode;
- uint8_t cbp;
-} IMbInfo;
-
-static const IMbInfo i_mb_type_info[26] = {
- { MB_TYPE_INTRA4x4, -1, -1 },
- { MB_TYPE_INTRA16x16, 2, 0 },
- { MB_TYPE_INTRA16x16, 1, 0 },
- { MB_TYPE_INTRA16x16, 0, 0 },
- { MB_TYPE_INTRA16x16, 3, 0 },
- { MB_TYPE_INTRA16x16, 2, 16 },
- { MB_TYPE_INTRA16x16, 1, 16 },
- { MB_TYPE_INTRA16x16, 0, 16 },
- { MB_TYPE_INTRA16x16, 3, 16 },
- { MB_TYPE_INTRA16x16, 2, 32 },
- { MB_TYPE_INTRA16x16, 1, 32 },
- { MB_TYPE_INTRA16x16, 0, 32 },
- { MB_TYPE_INTRA16x16, 3, 32 },
- { MB_TYPE_INTRA16x16, 2, 15 + 0 },
- { MB_TYPE_INTRA16x16, 1, 15 + 0 },
- { MB_TYPE_INTRA16x16, 0, 15 + 0 },
- { MB_TYPE_INTRA16x16, 3, 15 + 0 },
- { MB_TYPE_INTRA16x16, 2, 15 + 16 },
- { MB_TYPE_INTRA16x16, 1, 15 + 16 },
- { MB_TYPE_INTRA16x16, 0, 15 + 16 },
- { MB_TYPE_INTRA16x16, 3, 15 + 16 },
- { MB_TYPE_INTRA16x16, 2, 15 + 32 },
- { MB_TYPE_INTRA16x16, 1, 15 + 32 },
- { MB_TYPE_INTRA16x16, 0, 15 + 32 },
- { MB_TYPE_INTRA16x16, 3, 15 + 32 },
- { MB_TYPE_INTRA_PCM, -1, -1 },
-};
-
-typedef struct PMbInfo {
- uint16_t type;
- uint8_t partition_count;
-} PMbInfo;
-
-static const PMbInfo p_mb_type_info[5] = {
- { MB_TYPE_16x16 | MB_TYPE_P0L0, 1 },
- { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2 },
- { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2 },
- { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 4 },
- { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_REF0, 4 },
-};
-
-static const PMbInfo p_sub_mb_type_info[4] = {
- { MB_TYPE_16x16 | MB_TYPE_P0L0, 1 },
- { MB_TYPE_16x8 | MB_TYPE_P0L0, 2 },
- { MB_TYPE_8x16 | MB_TYPE_P0L0, 2 },
- { MB_TYPE_8x8 | MB_TYPE_P0L0, 4 },
-};
-
-static const PMbInfo b_mb_type_info[23] = {
- { MB_TYPE_DIRECT2 | MB_TYPE_L0L1, 1, },
- { MB_TYPE_16x16 | MB_TYPE_P0L0, 1, },
- { MB_TYPE_16x16 | MB_TYPE_P0L1, 1, },
- { MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1, 1, },
- { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, },
- { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, },
- { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, },
- { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, },
- { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, },
- { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, },
- { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 4, },
-};
-
-static const PMbInfo b_sub_mb_type_info[13] = {
- { MB_TYPE_DIRECT2, 1, },
- { MB_TYPE_16x16 | MB_TYPE_P0L0, 1, },
- { MB_TYPE_16x16 | MB_TYPE_P0L1, 1, },
- { MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1, 1, },
- { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, },
- { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, },
- { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, },
- { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 4, },
- { MB_TYPE_8x8 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 4, },
- { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 4, },
-};
-
-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 },
-};
-
-#endif /* AVCODEC_H264DATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264dsp.c b/src/thirdparty/ffmpeg/libavcodec/h264dsp.c
deleted file mode 100644
index 79a6bdb60..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264dsp.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
- * 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
- * H.264 / AVC / MPEG4 part10 DSP functions.
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#include <stdint.h>
-#include "libavutil/avassert.h"
-#include "avcodec.h"
-#include "h264dsp.h"
-#include "h264idct.h"
-#include "libavutil/common.h"
-
-#define BIT_DEPTH 8
-#include "h264dsp_template.c"
-#undef BIT_DEPTH
-
-#define BIT_DEPTH 9
-#include "h264dsp_template.c"
-#undef BIT_DEPTH
-
-#define BIT_DEPTH 10
-#include "h264dsp_template.c"
-#undef BIT_DEPTH
-
-#define BIT_DEPTH 12
-#include "h264dsp_template.c"
-#undef BIT_DEPTH
-
-#define BIT_DEPTH 14
-#include "h264dsp_template.c"
-#undef BIT_DEPTH
-
-#define BIT_DEPTH 8
-#include "h264addpx_template.c"
-#undef BIT_DEPTH
-
-#define BIT_DEPTH 16
-#include "h264addpx_template.c"
-#undef BIT_DEPTH
-
-void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, const int chroma_format_idc)
-{
-#undef FUNC
-#define FUNC(a, depth) a ## _ ## depth ## _c
-
-#define ADDPX_DSP(depth) \
- c->h264_add_pixels4 = FUNC(ff_h264_add_pixels4, depth);\
- c->h264_add_pixels8 = FUNC(ff_h264_add_pixels8, depth)
-
- if (bit_depth > 8 && bit_depth <= 16) {
- ADDPX_DSP(16);
- } else {
- ADDPX_DSP(8);
- }
-
-#define H264_DSP(depth) \
- c->h264_idct_add= FUNC(ff_h264_idct_add, depth);\
- c->h264_idct8_add= FUNC(ff_h264_idct8_add, depth);\
- c->h264_idct_dc_add= FUNC(ff_h264_idct_dc_add, 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)\
- 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)\
- 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);\
-\
- c->weight_h264_pixels_tab[0]= FUNC(weight_h264_pixels16, depth);\
- c->weight_h264_pixels_tab[1]= FUNC(weight_h264_pixels8, depth);\
- c->weight_h264_pixels_tab[2]= FUNC(weight_h264_pixels4, depth);\
- c->weight_h264_pixels_tab[3]= FUNC(weight_h264_pixels2, depth);\
- c->biweight_h264_pixels_tab[0]= FUNC(biweight_h264_pixels16, depth);\
- c->biweight_h264_pixels_tab[1]= FUNC(biweight_h264_pixels8, depth);\
- c->biweight_h264_pixels_tab[2]= FUNC(biweight_h264_pixels4, depth);\
- c->biweight_h264_pixels_tab[3]= FUNC(biweight_h264_pixels2, depth);\
-\
- c->h264_v_loop_filter_luma= FUNC(h264_v_loop_filter_luma, depth);\
- c->h264_h_loop_filter_luma= FUNC(h264_h_loop_filter_luma, depth);\
- c->h264_h_loop_filter_luma_mbaff= FUNC(h264_h_loop_filter_luma_mbaff, depth);\
- c->h264_v_loop_filter_luma_intra= FUNC(h264_v_loop_filter_luma_intra, 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)\
- 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)\
- 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)\
- 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)\
- 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);\
- c->h264_loop_filter_strength= NULL;
-
- switch (bit_depth) {
- case 9:
- H264_DSP(9);
- break;
- case 10:
- H264_DSP(10);
- break;
- case 12:
- H264_DSP(12);
- break;
- case 14:
- H264_DSP(14);
- break;
- default:
- av_assert0(bit_depth<=8);
- H264_DSP(8);
- break;
- }
-
- if (ARCH_ARM) ff_h264dsp_init_arm(c, bit_depth, chroma_format_idc);
- if (HAVE_ALTIVEC) 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/src/thirdparty/ffmpeg/libavcodec/h264dsp.h b/src/thirdparty/ffmpeg/libavcodec/h264dsp.h
deleted file mode 100644
index dde914d82..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264dsp.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * 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
- * H.264 DSP functions.
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#ifndef AVCODEC_H264DSP_H
-#define AVCODEC_H264DSP_H
-
-#include <stdint.h>
-
-typedef void (*h264_weight_func)(uint8_t *block, int stride, int height,
- int log2_denom, int weight, int offset);
-typedef void (*h264_biweight_func)(uint8_t *dst, uint8_t *src,
- int stride, int height, int log2_denom,
- int weightd, int weights, int offset);
-
-/**
- * Context for storing H.264 DSP functions
- */
-typedef struct H264DSPContext {
- /* weighted MC */
- h264_weight_func weight_h264_pixels_tab[4];
- h264_biweight_func biweight_h264_pixels_tab[4];
-
- /* loop filter */
- void (*h264_v_loop_filter_luma)(uint8_t *pix /*align 16*/, int stride,
- int alpha, int beta, int8_t *tc0);
- void (*h264_h_loop_filter_luma)(uint8_t *pix /*align 4 */, int stride,
- int alpha, int beta, int8_t *tc0);
- void (*h264_h_loop_filter_luma_mbaff)(uint8_t *pix /*align 16*/, int stride,
- int alpha, int beta, int8_t *tc0);
- /* v/h_loop_filter_luma_intra: align 16 */
- void (*h264_v_loop_filter_luma_intra)(uint8_t *pix, int stride,
- int alpha, int beta);
- void (*h264_h_loop_filter_luma_intra)(uint8_t *pix, int stride,
- int alpha, int beta);
- void (*h264_h_loop_filter_luma_mbaff_intra)(uint8_t *pix /*align 16*/,
- int stride, int alpha, int beta);
- void (*h264_v_loop_filter_chroma)(uint8_t *pix /*align 8*/, int stride,
- int alpha, int beta, int8_t *tc0);
- void (*h264_h_loop_filter_chroma)(uint8_t *pix /*align 4*/, int stride,
- int alpha, int beta, int8_t *tc0);
- void (*h264_h_loop_filter_chroma_mbaff)(uint8_t *pix /*align 8*/,
- int stride, int alpha, int beta,
- int8_t *tc0);
- void (*h264_v_loop_filter_chroma_intra)(uint8_t *pix /*align 8*/,
- int stride, int alpha, int beta);
- void (*h264_h_loop_filter_chroma_intra)(uint8_t *pix /*align 8*/,
- int stride, int alpha, int beta);
- void (*h264_h_loop_filter_chroma_mbaff_intra)(uint8_t *pix /*align 8*/,
- int stride, int alpha, int beta);
- // h264_loop_filter_strength: simd only. the C version is inlined in h264.c
- 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);
-
- /* IDCT */
- void (*h264_idct_add)(uint8_t *dst /*align 4*/,
- int16_t *block /*align 16*/, int stride);
- void (*h264_idct8_add)(uint8_t *dst /*align 8*/,
- int16_t *block /*align 16*/, int stride);
- void (*h264_idct_dc_add)(uint8_t *dst /*align 4*/,
- int16_t *block /*align 16*/, int stride);
- void (*h264_idct8_dc_add)(uint8_t *dst /*align 8*/,
- int16_t *block /*align 16*/, int stride);
-
- void (*h264_idct_add16)(uint8_t *dst /*align 16*/, const int *blockoffset,
- int16_t *block /*align 16*/, int stride,
- const uint8_t nnzc[15 * 8]);
- void (*h264_idct8_add4)(uint8_t *dst /*align 16*/, const int *blockoffset,
- int16_t *block /*align 16*/, int stride,
- const uint8_t nnzc[15 * 8]);
- void (*h264_idct_add8)(uint8_t **dst /*align 16*/, const int *blockoffset,
- int16_t *block /*align 16*/, int stride,
- const uint8_t nnzc[15 * 8]);
- void (*h264_idct_add16intra)(uint8_t *dst /*align 16*/, const int *blockoffset,
- int16_t *block /*align 16*/,
- int stride, const uint8_t nnzc[15 * 8]);
- void (*h264_luma_dc_dequant_idct)(int16_t *output,
- int16_t *input /*align 16*/, int qmul);
- void (*h264_chroma_dc_dequant_idct)(int16_t *block, int qmul);
-
- /* bypass-transform */
- void (*h264_add_pixels8)(uint8_t *dst, int16_t *block, int stride);
- void (*h264_add_pixels4)(uint8_t *dst, int16_t *block, int stride);
-} H264DSPContext;
-
-void ff_h264dsp_init(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,
- const int chroma_format_idc);
-void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth,
- const int chroma_format_idc);
-
-#endif /* AVCODEC_H264DSP_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264dsp_template.c b/src/thirdparty/ffmpeg/libavcodec/h264dsp_template.c
deleted file mode 100644
index ad9933ddc..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264dsp_template.c
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
- * Copyright (c) 2003-2011 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 DSP functions.
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#include "bit_depth_template.c"
-
-#define op_scale1(x) block[x] = av_clip_pixel( (block[x]*weight + offset) >> log2_denom )
-#define op_scale2(x) dst[x] = av_clip_pixel( (src[x]*weights + dst[x]*weightd + offset) >> (log2_denom+1))
-#define H264_WEIGHT(W) \
-static void FUNCC(weight_h264_pixels ## W)(uint8_t *_block, int stride, int height, \
- int log2_denom, int weight, int offset) \
-{ \
- int y; \
- pixel *block = (pixel*)_block; \
- stride >>= sizeof(pixel)-1; \
- offset <<= (log2_denom + (BIT_DEPTH-8)); \
- if(log2_denom) offset += 1<<(log2_denom-1); \
- for (y = 0; y < height; y++, block += stride) { \
- op_scale1(0); \
- op_scale1(1); \
- if(W==2) continue; \
- op_scale1(2); \
- op_scale1(3); \
- if(W==4) continue; \
- op_scale1(4); \
- op_scale1(5); \
- op_scale1(6); \
- op_scale1(7); \
- if(W==8) continue; \
- op_scale1(8); \
- op_scale1(9); \
- op_scale1(10); \
- op_scale1(11); \
- op_scale1(12); \
- op_scale1(13); \
- op_scale1(14); \
- op_scale1(15); \
- } \
-} \
-static void FUNCC(biweight_h264_pixels ## W)(uint8_t *_dst, uint8_t *_src, int stride, int height, \
- int log2_denom, int weightd, int weights, int offset) \
-{ \
- int y; \
- pixel *dst = (pixel*)_dst; \
- pixel *src = (pixel*)_src; \
- stride >>= sizeof(pixel)-1; \
- offset <<= (BIT_DEPTH-8); \
- offset = ((offset + 1) | 1) << log2_denom; \
- for (y = 0; y < height; y++, dst += stride, src += stride) { \
- op_scale2(0); \
- op_scale2(1); \
- if(W==2) continue; \
- op_scale2(2); \
- op_scale2(3); \
- if(W==4) continue; \
- op_scale2(4); \
- op_scale2(5); \
- op_scale2(6); \
- op_scale2(7); \
- if(W==8) continue; \
- op_scale2(8); \
- op_scale2(9); \
- op_scale2(10); \
- op_scale2(11); \
- op_scale2(12); \
- op_scale2(13); \
- op_scale2(14); \
- op_scale2(15); \
- } \
-}
-
-H264_WEIGHT(16)
-H264_WEIGHT(8)
-H264_WEIGHT(4)
-H264_WEIGHT(2)
-
-#undef op_scale1
-#undef op_scale2
-#undef H264_WEIGHT
-
-static av_always_inline av_flatten void FUNCC(h264_loop_filter_luma)(uint8_t *p_pix, int xstride, int ystride, int inner_iters, int alpha, int beta, int8_t *tc0)
-{
- pixel *pix = (pixel*)p_pix;
- int i, d;
- xstride >>= sizeof(pixel)-1;
- ystride >>= sizeof(pixel)-1;
- alpha <<= BIT_DEPTH - 8;
- beta <<= BIT_DEPTH - 8;
- for( i = 0; i < 4; i++ ) {
- const int tc_orig = tc0[i] << (BIT_DEPTH - 8);
- if( tc_orig < 0 ) {
- pix += inner_iters*ystride;
- continue;
- }
- for( d = 0; d < inner_iters; d++ ) {
- const int p0 = pix[-1*xstride];
- const int p1 = pix[-2*xstride];
- const int p2 = pix[-3*xstride];
- const int q0 = pix[0];
- const int q1 = pix[1*xstride];
- const int q2 = pix[2*xstride];
-
- if( FFABS( p0 - q0 ) < alpha &&
- FFABS( p1 - p0 ) < beta &&
- FFABS( q1 - q0 ) < beta ) {
-
- int tc = tc_orig;
- int i_delta;
-
- if( FFABS( p2 - p0 ) < beta ) {
- if(tc_orig)
- pix[-2*xstride] = p1 + av_clip( (( p2 + ( ( p0 + q0 + 1 ) >> 1 ) ) >> 1) - p1, -tc_orig, tc_orig );
- tc++;
- }
- if( FFABS( q2 - q0 ) < beta ) {
- if(tc_orig)
- pix[ xstride] = q1 + av_clip( (( q2 + ( ( p0 + q0 + 1 ) >> 1 ) ) >> 1) - q1, -tc_orig, tc_orig );
- tc++;
- }
-
- i_delta = av_clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
- pix[-xstride] = av_clip_pixel( p0 + i_delta ); /* p0' */
- pix[0] = av_clip_pixel( q0 - i_delta ); /* q0' */
- }
- pix += ystride;
- }
- }
-}
-static void FUNCC(h264_v_loop_filter_luma)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
-{
- FUNCC(h264_loop_filter_luma)(pix, stride, sizeof(pixel), 4, alpha, beta, tc0);
-}
-static void FUNCC(h264_h_loop_filter_luma)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
-{
- FUNCC(h264_loop_filter_luma)(pix, sizeof(pixel), stride, 4, alpha, beta, tc0);
-}
-static void FUNCC(h264_h_loop_filter_luma_mbaff)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
-{
- FUNCC(h264_loop_filter_luma)(pix, sizeof(pixel), stride, 2, alpha, beta, tc0);
-}
-
-static av_always_inline av_flatten void FUNCC(h264_loop_filter_luma_intra)(uint8_t *p_pix, int xstride, int ystride, int inner_iters, int alpha, int beta)
-{
- pixel *pix = (pixel*)p_pix;
- int d;
- xstride >>= sizeof(pixel)-1;
- ystride >>= sizeof(pixel)-1;
- alpha <<= BIT_DEPTH - 8;
- beta <<= BIT_DEPTH - 8;
- for( d = 0; d < 4 * inner_iters; d++ ) {
- const int p2 = pix[-3*xstride];
- const int p1 = pix[-2*xstride];
- const int p0 = pix[-1*xstride];
-
- const int q0 = pix[ 0*xstride];
- const int q1 = pix[ 1*xstride];
- const int q2 = pix[ 2*xstride];
-
- if( FFABS( p0 - q0 ) < alpha &&
- FFABS( p1 - p0 ) < beta &&
- FFABS( q1 - q0 ) < beta ) {
-
- if(FFABS( p0 - q0 ) < (( alpha >> 2 ) + 2 )){
- if( FFABS( p2 - p0 ) < beta)
- {
- const int p3 = pix[-4*xstride];
- /* p0', p1', p2' */
- pix[-1*xstride] = ( p2 + 2*p1 + 2*p0 + 2*q0 + q1 + 4 ) >> 3;
- pix[-2*xstride] = ( p2 + p1 + p0 + q0 + 2 ) >> 2;
- pix[-3*xstride] = ( 2*p3 + 3*p2 + p1 + p0 + q0 + 4 ) >> 3;
- } else {
- /* p0' */
- pix[-1*xstride] = ( 2*p1 + p0 + q1 + 2 ) >> 2;
- }
- if( FFABS( q2 - q0 ) < beta)
- {
- const int q3 = pix[3*xstride];
- /* q0', q1', q2' */
- pix[0*xstride] = ( p1 + 2*p0 + 2*q0 + 2*q1 + q2 + 4 ) >> 3;
- pix[1*xstride] = ( p0 + q0 + q1 + q2 + 2 ) >> 2;
- pix[2*xstride] = ( 2*q3 + 3*q2 + q1 + q0 + p0 + 4 ) >> 3;
- } else {
- /* q0' */
- pix[0*xstride] = ( 2*q1 + q0 + p1 + 2 ) >> 2;
- }
- }else{
- /* p0', q0' */
- pix[-1*xstride] = ( 2*p1 + p0 + q1 + 2 ) >> 2;
- pix[ 0*xstride] = ( 2*q1 + q0 + p1 + 2 ) >> 2;
- }
- }
- pix += ystride;
- }
-}
-static void FUNCC(h264_v_loop_filter_luma_intra)(uint8_t *pix, int stride, int alpha, int beta)
-{
- FUNCC(h264_loop_filter_luma_intra)(pix, stride, sizeof(pixel), 4, alpha, beta);
-}
-static void FUNCC(h264_h_loop_filter_luma_intra)(uint8_t *pix, int stride, int alpha, int beta)
-{
- FUNCC(h264_loop_filter_luma_intra)(pix, sizeof(pixel), stride, 4, alpha, beta);
-}
-static void FUNCC(h264_h_loop_filter_luma_mbaff_intra)(uint8_t *pix, int stride, int alpha, int beta)
-{
- FUNCC(h264_loop_filter_luma_intra)(pix, sizeof(pixel), stride, 2, alpha, beta);
-}
-
-static av_always_inline av_flatten void FUNCC(h264_loop_filter_chroma)(uint8_t *p_pix, int xstride, int ystride, int inner_iters, int alpha, int beta, int8_t *tc0)
-{
- pixel *pix = (pixel*)p_pix;
- int i, d;
- alpha <<= BIT_DEPTH - 8;
- beta <<= BIT_DEPTH - 8;
- xstride >>= sizeof(pixel)-1;
- ystride >>= sizeof(pixel)-1;
- for( i = 0; i < 4; i++ ) {
- const int tc = ((tc0[i] - 1) << (BIT_DEPTH - 8)) + 1;
- if( tc <= 0 ) {
- pix += inner_iters*ystride;
- continue;
- }
- for( d = 0; d < inner_iters; d++ ) {
- const int p0 = pix[-1*xstride];
- const int p1 = pix[-2*xstride];
- const int q0 = pix[0];
- const int q1 = pix[1*xstride];
-
- if( FFABS( p0 - q0 ) < alpha &&
- FFABS( p1 - p0 ) < beta &&
- FFABS( q1 - q0 ) < beta ) {
-
- int delta = av_clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc );
-
- pix[-xstride] = av_clip_pixel( p0 + delta ); /* p0' */
- pix[0] = av_clip_pixel( q0 - delta ); /* q0' */
- }
- pix += ystride;
- }
- }
-}
-static void FUNCC(h264_v_loop_filter_chroma)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
-{
- FUNCC(h264_loop_filter_chroma)(pix, stride, sizeof(pixel), 2, alpha, beta, tc0);
-}
-static void FUNCC(h264_h_loop_filter_chroma)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
-{
- FUNCC(h264_loop_filter_chroma)(pix, sizeof(pixel), stride, 2, alpha, beta, tc0);
-}
-static void FUNCC(h264_h_loop_filter_chroma_mbaff)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
-{
- FUNCC(h264_loop_filter_chroma)(pix, sizeof(pixel), stride, 1, alpha, beta, tc0);
-}
-static void FUNCC(h264_h_loop_filter_chroma422)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
-{
- FUNCC(h264_loop_filter_chroma)(pix, sizeof(pixel), stride, 4, alpha, beta, tc0);
-}
-static void FUNCC(h264_h_loop_filter_chroma422_mbaff)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0)
-{
- FUNCC(h264_loop_filter_chroma)(pix, sizeof(pixel), stride, 2, alpha, beta, tc0);
-}
-
-static av_always_inline av_flatten void FUNCC(h264_loop_filter_chroma_intra)(uint8_t *p_pix, int xstride, int ystride, int inner_iters, int alpha, int beta)
-{
- pixel *pix = (pixel*)p_pix;
- int d;
- xstride >>= sizeof(pixel)-1;
- ystride >>= sizeof(pixel)-1;
- alpha <<= BIT_DEPTH - 8;
- beta <<= BIT_DEPTH - 8;
- for( d = 0; d < 4 * inner_iters; d++ ) {
- const int p0 = pix[-1*xstride];
- const int p1 = pix[-2*xstride];
- const int q0 = pix[0];
- const int q1 = pix[1*xstride];
-
- if( FFABS( p0 - q0 ) < alpha &&
- FFABS( p1 - p0 ) < beta &&
- FFABS( q1 - q0 ) < beta ) {
-
- pix[-xstride] = ( 2*p1 + p0 + q1 + 2 ) >> 2; /* p0' */
- pix[0] = ( 2*q1 + q0 + p1 + 2 ) >> 2; /* q0' */
- }
- pix += ystride;
- }
-}
-static void FUNCC(h264_v_loop_filter_chroma_intra)(uint8_t *pix, int stride, int alpha, int beta)
-{
- FUNCC(h264_loop_filter_chroma_intra)(pix, stride, sizeof(pixel), 2, alpha, beta);
-}
-static void FUNCC(h264_h_loop_filter_chroma_intra)(uint8_t *pix, int stride, int alpha, int beta)
-{
- FUNCC(h264_loop_filter_chroma_intra)(pix, sizeof(pixel), stride, 2, alpha, beta);
-}
-static void FUNCC(h264_h_loop_filter_chroma_mbaff_intra)(uint8_t *pix, int stride, int alpha, int beta)
-{
- FUNCC(h264_loop_filter_chroma_intra)(pix, sizeof(pixel), stride, 1, alpha, beta);
-}
-static void FUNCC(h264_h_loop_filter_chroma422_intra)(uint8_t *pix, int stride, int alpha, int beta)
-{
- FUNCC(h264_loop_filter_chroma_intra)(pix, sizeof(pixel), stride, 4, alpha, beta);
-}
-static void FUNCC(h264_h_loop_filter_chroma422_mbaff_intra)(uint8_t *pix, int stride, int alpha, int beta)
-{
- FUNCC(h264_loop_filter_chroma_intra)(pix, sizeof(pixel), stride, 2, alpha, beta);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264idct.c b/src/thirdparty/ffmpeg/libavcodec/h264idct.c
deleted file mode 100644
index 7ced929d7..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264idct.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * H.264 IDCT
- * Copyright (c) 2004 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 IDCT.
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#include "h264idct.h"
-
-#define BIT_DEPTH 8
-#include "h264idct_template.c"
-#undef BIT_DEPTH
-
-#define BIT_DEPTH 9
-#include "h264idct_template.c"
-#undef BIT_DEPTH
-
-#define BIT_DEPTH 10
-#include "h264idct_template.c"
-#undef BIT_DEPTH
-
-#define BIT_DEPTH 12
-#include "h264idct_template.c"
-#undef BIT_DEPTH
-
-#define BIT_DEPTH 14
-#include "h264idct_template.c"
-#undef BIT_DEPTH
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264idct.h b/src/thirdparty/ffmpeg/libavcodec/h264idct.h
deleted file mode 100644
index 17e005149..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264idct.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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_H264IDCT_H
-#define AVCODEC_H264IDCT_H
-
-#include <stdint.h>
-
-#define H264_IDCT(depth) \
-void ff_h264_idct8_add_ ## depth ## _c(uint8_t *dst, int16_t *block, int stride);\
-void ff_h264_idct_add_ ## depth ## _c(uint8_t *dst, int16_t *block, int stride);\
-void ff_h264_idct8_dc_add_ ## depth ## _c(uint8_t *dst, int16_t *block, int stride);\
-void ff_h264_idct_dc_add_ ## depth ## _c(uint8_t *dst, int16_t *block, int stride);\
-void ff_h264_idct_add16_ ## depth ## _c(uint8_t *dst, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[6*8]);\
-void ff_h264_idct_add16intra_ ## depth ## _c(uint8_t *dst, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[6*8]);\
-void ff_h264_idct8_add4_ ## depth ## _c(uint8_t *dst, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[6*8]);\
-void ff_h264_idct_add8_422_ ## depth ## _c(uint8_t **dest, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[6*8]);\
-void ff_h264_idct_add8_ ## depth ## _c(uint8_t **dest, const int *blockoffset, int16_t *block, int stride, const uint8_t nnzc[6*8]);\
-void ff_h264_luma_dc_dequant_idct_ ## depth ## _c(int16_t *output, int16_t *input, int qmul);\
-void ff_h264_chroma422_dc_dequant_idct_ ## depth ## _c(int16_t *block, int qmul);\
-void ff_h264_chroma_dc_dequant_idct_ ## depth ## _c(int16_t *block, int qmul);
-
-H264_IDCT( 8)
-H264_IDCT( 9)
-H264_IDCT(10)
-H264_IDCT(12)
-H264_IDCT(14)
-
-#endif /* AVCODEC_H264IDCT_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264idct_template.c b/src/thirdparty/ffmpeg/libavcodec/h264idct_template.c
deleted file mode 100644
index e665913fe..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264idct_template.c
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- * H.264 IDCT
- * Copyright (c) 2004-2011 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 IDCT.
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#include "bit_depth_template.c"
-#include "libavutil/common.h"
-#include "h264.h"
-
-void FUNCC(ff_h264_idct_add)(uint8_t *_dst, int16_t *_block, int stride)
-{
- int i;
- pixel *dst = (pixel*)_dst;
- dctcoef *block = (dctcoef*)_block;
- stride >>= sizeof(pixel)-1;
-
- block[0] += 1 << 5;
-
- for(i=0; i<4; i++){
- const int z0= block[i + 4*0] + block[i + 4*2];
- const int z1= block[i + 4*0] - block[i + 4*2];
- const int z2= (block[i + 4*1]>>1) - block[i + 4*3];
- const int z3= block[i + 4*1] + (block[i + 4*3]>>1);
-
- block[i + 4*0]= z0 + z3;
- block[i + 4*1]= z1 + z2;
- block[i + 4*2]= z1 - z2;
- block[i + 4*3]= z0 - z3;
- }
-
- for(i=0; i<4; i++){
- const int z0= block[0 + 4*i] + block[2 + 4*i];
- const int z1= block[0 + 4*i] - block[2 + 4*i];
- const int z2= (block[1 + 4*i]>>1) - block[3 + 4*i];
- const int z3= block[1 + 4*i] + (block[3 + 4*i]>>1);
-
- dst[i + 0*stride]= av_clip_pixel(dst[i + 0*stride] + ((z0 + z3) >> 6));
- dst[i + 1*stride]= av_clip_pixel(dst[i + 1*stride] + ((z1 + z2) >> 6));
- dst[i + 2*stride]= av_clip_pixel(dst[i + 2*stride] + ((z1 - z2) >> 6));
- dst[i + 3*stride]= av_clip_pixel(dst[i + 3*stride] + ((z0 - z3) >> 6));
- }
-}
-
-void FUNCC(ff_h264_idct8_add)(uint8_t *_dst, int16_t *_block, int stride){
- int i;
- pixel *dst = (pixel*)_dst;
- dctcoef *block = (dctcoef*)_block;
- stride >>= sizeof(pixel)-1;
-
- block[0] += 32;
-
- for( i = 0; i < 8; i++ )
- {
- const int a0 = block[i+0*8] + block[i+4*8];
- const int a2 = block[i+0*8] - block[i+4*8];
- const int a4 = (block[i+2*8]>>1) - block[i+6*8];
- const int a6 = (block[i+6*8]>>1) + block[i+2*8];
-
- const int b0 = a0 + a6;
- const int b2 = a2 + a4;
- const int b4 = a2 - a4;
- const int b6 = a0 - a6;
-
- const int a1 = -block[i+3*8] + block[i+5*8] - block[i+7*8] - (block[i+7*8]>>1);
- const int a3 = block[i+1*8] + block[i+7*8] - block[i+3*8] - (block[i+3*8]>>1);
- const int a5 = -block[i+1*8] + block[i+7*8] + block[i+5*8] + (block[i+5*8]>>1);
- const int a7 = block[i+3*8] + block[i+5*8] + block[i+1*8] + (block[i+1*8]>>1);
-
- const int b1 = (a7>>2) + a1;
- const int b3 = a3 + (a5>>2);
- const int b5 = (a3>>2) - a5;
- const int b7 = a7 - (a1>>2);
-
- block[i+0*8] = b0 + b7;
- block[i+7*8] = b0 - b7;
- block[i+1*8] = b2 + b5;
- block[i+6*8] = b2 - b5;
- block[i+2*8] = b4 + b3;
- block[i+5*8] = b4 - b3;
- block[i+3*8] = b6 + b1;
- block[i+4*8] = b6 - b1;
- }
- for( i = 0; i < 8; i++ )
- {
- const int a0 = block[0+i*8] + block[4+i*8];
- const int a2 = block[0+i*8] - block[4+i*8];
- const int a4 = (block[2+i*8]>>1) - block[6+i*8];
- const int a6 = (block[6+i*8]>>1) + block[2+i*8];
-
- const int b0 = a0 + a6;
- const int b2 = a2 + a4;
- const int b4 = a2 - a4;
- const int b6 = a0 - a6;
-
- const int a1 = -block[3+i*8] + block[5+i*8] - block[7+i*8] - (block[7+i*8]>>1);
- const int a3 = block[1+i*8] + block[7+i*8] - block[3+i*8] - (block[3+i*8]>>1);
- const int a5 = -block[1+i*8] + block[7+i*8] + block[5+i*8] + (block[5+i*8]>>1);
- const int a7 = block[3+i*8] + block[5+i*8] + block[1+i*8] + (block[1+i*8]>>1);
-
- const int b1 = (a7>>2) + a1;
- const int b3 = a3 + (a5>>2);
- const int b5 = (a3>>2) - a5;
- const int b7 = a7 - (a1>>2);
-
- dst[i + 0*stride] = av_clip_pixel( dst[i + 0*stride] + ((b0 + b7) >> 6) );
- dst[i + 1*stride] = av_clip_pixel( dst[i + 1*stride] + ((b2 + b5) >> 6) );
- dst[i + 2*stride] = av_clip_pixel( dst[i + 2*stride] + ((b4 + b3) >> 6) );
- dst[i + 3*stride] = av_clip_pixel( dst[i + 3*stride] + ((b6 + b1) >> 6) );
- dst[i + 4*stride] = av_clip_pixel( dst[i + 4*stride] + ((b6 - b1) >> 6) );
- dst[i + 5*stride] = av_clip_pixel( dst[i + 5*stride] + ((b4 - b3) >> 6) );
- dst[i + 6*stride] = av_clip_pixel( dst[i + 6*stride] + ((b2 - b5) >> 6) );
- dst[i + 7*stride] = av_clip_pixel( dst[i + 7*stride] + ((b0 - b7) >> 6) );
- }
-}
-
-// assumes all AC coefs are 0
-void FUNCC(ff_h264_idct_dc_add)(uint8_t *_dst, int16_t *block, int stride){
- int i, j;
- int dc = (((dctcoef*)block)[0] + 32) >> 6;
- pixel *dst = (pixel*)_dst;
- stride >>= sizeof(pixel)-1;
- for( j = 0; j < 4; j++ )
- {
- for( i = 0; i < 4; i++ )
- dst[i] = av_clip_pixel( dst[i] + dc );
- dst += stride;
- }
-}
-
-void FUNCC(ff_h264_idct8_dc_add)(uint8_t *_dst, int16_t *block, int stride){
- int i, j;
- int dc = (((dctcoef*)block)[0] + 32) >> 6;
- pixel *dst = (pixel*)_dst;
- stride >>= sizeof(pixel)-1;
- for( j = 0; j < 8; j++ )
- {
- for( i = 0; i < 8; i++ )
- dst[i] = av_clip_pixel( dst[i] + dc );
- dst += stride;
- }
-}
-
-void FUNCC(ff_h264_idct_add16)(uint8_t *dst, const int *block_offset, int16_t *block, int stride, const uint8_t nnzc[15*8]){
- int i;
- for(i=0; i<16; i++){
- int nnz = nnzc[ scan8[i] ];
- if(nnz){
- if(nnz==1 && ((dctcoef*)block)[i*16]) FUNCC(ff_h264_idct_dc_add)(dst + block_offset[i], block + i*16*sizeof(pixel), stride);
- else FUNCC(ff_h264_idct_add )(dst + block_offset[i], block + i*16*sizeof(pixel), stride);
- }
- }
-}
-
-void FUNCC(ff_h264_idct_add16intra)(uint8_t *dst, const int *block_offset, int16_t *block, int stride, const uint8_t nnzc[15*8]){
- int i;
- for(i=0; i<16; i++){
- if(nnzc[ scan8[i] ]) FUNCC(ff_h264_idct_add )(dst + block_offset[i], block + i*16*sizeof(pixel), stride);
- else if(((dctcoef*)block)[i*16]) FUNCC(ff_h264_idct_dc_add)(dst + block_offset[i], block + i*16*sizeof(pixel), stride);
- }
-}
-
-void FUNCC(ff_h264_idct8_add4)(uint8_t *dst, const int *block_offset, int16_t *block, int stride, const uint8_t nnzc[15*8]){
- int i;
- for(i=0; i<16; i+=4){
- int nnz = nnzc[ scan8[i] ];
- if(nnz){
- if(nnz==1 && ((dctcoef*)block)[i*16]) FUNCC(ff_h264_idct8_dc_add)(dst + block_offset[i], block + i*16*sizeof(pixel), stride);
- else FUNCC(ff_h264_idct8_add )(dst + block_offset[i], block + i*16*sizeof(pixel), stride);
- }
- }
-}
-
-void FUNCC(ff_h264_idct_add8)(uint8_t **dest, const int *block_offset, int16_t *block, int stride, const uint8_t nnzc[15*8]){
- int i, j;
- for(j=1; j<3; j++){
- for(i=j*16; i<j*16+4; i++){
- if(nnzc[ scan8[i] ])
- FUNCC(ff_h264_idct_add )(dest[j-1] + block_offset[i], block + i*16*sizeof(pixel), stride);
- else if(((dctcoef*)block)[i*16])
- FUNCC(ff_h264_idct_dc_add)(dest[j-1] + block_offset[i], block + i*16*sizeof(pixel), stride);
- }
- }
-}
-
-void FUNCC(ff_h264_idct_add8_422)(uint8_t **dest, const int *block_offset, int16_t *block, int stride, const uint8_t nnzc[15*8]){
- int i, j;
-
- for(j=1; j<3; j++){
- for(i=j*16; i<j*16+4; i++){
- if(nnzc[ scan8[i] ])
- FUNCC(ff_h264_idct_add )(dest[j-1] + block_offset[i], block + i*16*sizeof(pixel), stride);
- else if(((dctcoef*)block)[i*16])
- FUNCC(ff_h264_idct_dc_add)(dest[j-1] + block_offset[i], block + i*16*sizeof(pixel), stride);
- }
- }
-
- for(j=1; j<3; j++){
- for(i=j*16+4; i<j*16+8; i++){
- if(nnzc[ scan8[i+4] ])
- FUNCC(ff_h264_idct_add )(dest[j-1] + block_offset[i+4], block + i*16*sizeof(pixel), stride);
- else if(((dctcoef*)block)[i*16])
- FUNCC(ff_h264_idct_dc_add)(dest[j-1] + block_offset[i+4], block + i*16*sizeof(pixel), stride);
- }
- }
-}
-
-/**
- * IDCT transforms the 16 dc values and dequantizes them.
- * @param qmul quantization parameter
- */
-void FUNCC(ff_h264_luma_dc_dequant_idct)(int16_t *_output, int16_t *_input, int qmul){
-#define stride 16
- int i;
- int temp[16];
- static const uint8_t x_offset[4]={0, 2*stride, 8*stride, 10*stride};
- dctcoef *input = (dctcoef*)_input;
- dctcoef *output = (dctcoef*)_output;
-
- for(i=0; i<4; i++){
- const int z0= input[4*i+0] + input[4*i+1];
- const int z1= input[4*i+0] - input[4*i+1];
- const int z2= input[4*i+2] - input[4*i+3];
- const int z3= input[4*i+2] + input[4*i+3];
-
- temp[4*i+0]= z0+z3;
- temp[4*i+1]= z0-z3;
- temp[4*i+2]= z1-z2;
- temp[4*i+3]= z1+z2;
- }
-
- for(i=0; i<4; i++){
- const int offset= x_offset[i];
- const int z0= temp[4*0+i] + temp[4*2+i];
- const int z1= temp[4*0+i] - temp[4*2+i];
- const int z2= temp[4*1+i] - temp[4*3+i];
- const int z3= temp[4*1+i] + temp[4*3+i];
-
- output[stride* 0+offset]= ((((z0 + z3)*qmul + 128 ) >> 8));
- output[stride* 1+offset]= ((((z1 + z2)*qmul + 128 ) >> 8));
- output[stride* 4+offset]= ((((z1 - z2)*qmul + 128 ) >> 8));
- output[stride* 5+offset]= ((((z0 - z3)*qmul + 128 ) >> 8));
- }
-#undef stride
-}
-
-void FUNCC(ff_h264_chroma422_dc_dequant_idct)(int16_t *_block, int qmul){
- const int stride= 16*2;
- const int xStride= 16;
- int i;
- int temp[8];
- static const uint8_t x_offset[2]={0, 16};
- dctcoef *block = (dctcoef*)_block;
-
- for(i=0; i<4; i++){
- temp[2*i+0] = block[stride*i + xStride*0] + block[stride*i + xStride*1];
- temp[2*i+1] = block[stride*i + xStride*0] - block[stride*i + xStride*1];
- }
-
- for(i=0; i<2; i++){
- const int offset= x_offset[i];
- const int z0= temp[2*0+i] + temp[2*2+i];
- const int z1= temp[2*0+i] - temp[2*2+i];
- const int z2= temp[2*1+i] - temp[2*3+i];
- const int z3= temp[2*1+i] + temp[2*3+i];
-
- block[stride*0+offset]= ((z0 + z3)*qmul + 128) >> 8;
- block[stride*1+offset]= ((z1 + z2)*qmul + 128) >> 8;
- block[stride*2+offset]= ((z1 - z2)*qmul + 128) >> 8;
- block[stride*3+offset]= ((z0 - z3)*qmul + 128) >> 8;
- }
-}
-
-void FUNCC(ff_h264_chroma_dc_dequant_idct)(int16_t *_block, int qmul){
- const int stride= 16*2;
- const int xStride= 16;
- int a,b,c,d,e;
- dctcoef *block = (dctcoef*)_block;
-
- a= block[stride*0 + xStride*0];
- b= block[stride*0 + xStride*1];
- c= block[stride*1 + xStride*0];
- d= block[stride*1 + xStride*1];
-
- e= a-b;
- a= a+b;
- b= c-d;
- c= c+d;
-
- block[stride*0 + xStride*0]= ((a+c)*qmul) >> 7;
- block[stride*0 + xStride*1]= ((e+b)*qmul) >> 7;
- block[stride*1 + xStride*0]= ((a-c)*qmul) >> 7;
- block[stride*1 + xStride*1]= ((e-b)*qmul) >> 7;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264pred.c b/src/thirdparty/ffmpeg/libavcodec/h264pred.c
deleted file mode 100644
index 47343b3d6..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264pred.c
+++ /dev/null
@@ -1,595 +0,0 @@
-/*
- * H.26L/H.264/AVC/JVT/14496-10/... encoder/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 prediction functions.
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#include "libavutil/avassert.h"
-#include "h264pred.h"
-#include "dsputil.h" // for ff_cropTbl
-#include "avcodec.h" // for AV_CODEC_ID_*
-
-#define BIT_DEPTH 8
-#include "h264pred_template.c"
-#undef BIT_DEPTH
-
-#define BIT_DEPTH 9
-#include "h264pred_template.c"
-#undef BIT_DEPTH
-
-#define BIT_DEPTH 10
-#include "h264pred_template.c"
-#undef BIT_DEPTH
-
-#define BIT_DEPTH 12
-#include "h264pred_template.c"
-#undef BIT_DEPTH
-
-#define BIT_DEPTH 14
-#include "h264pred_template.c"
-#undef BIT_DEPTH
-
-static void pred4x4_vertical_vp8_c(uint8_t *src, const uint8_t *topright,
- ptrdiff_t stride)
-{
- const unsigned lt = src[-1-1*stride];
- LOAD_TOP_EDGE
- LOAD_TOP_RIGHT_EDGE
- uint32_t v = PACK_4U8((lt + 2*t0 + t1 + 2) >> 2,
- (t0 + 2*t1 + t2 + 2) >> 2,
- (t1 + 2*t2 + t3 + 2) >> 2,
- (t2 + 2*t3 + t4 + 2) >> 2);
-
- AV_WN32A(src+0*stride, v);
- AV_WN32A(src+1*stride, v);
- AV_WN32A(src+2*stride, v);
- AV_WN32A(src+3*stride, v);
-}
-
-static void pred4x4_horizontal_vp8_c(uint8_t *src, const uint8_t *topright,
- ptrdiff_t stride)
-{
- const unsigned lt = src[-1-1*stride];
- LOAD_LEFT_EDGE
-
- AV_WN32A(src+0*stride, ((lt + 2*l0 + l1 + 2) >> 2)*0x01010101);
- AV_WN32A(src+1*stride, ((l0 + 2*l1 + l2 + 2) >> 2)*0x01010101);
- AV_WN32A(src+2*stride, ((l1 + 2*l2 + l3 + 2) >> 2)*0x01010101);
- AV_WN32A(src+3*stride, ((l2 + 2*l3 + l3 + 2) >> 2)*0x01010101);
-}
-
-static void pred4x4_down_left_svq3_c(uint8_t *src, const uint8_t *topright,
- ptrdiff_t stride)
-{
- LOAD_TOP_EDGE
- LOAD_LEFT_EDGE
-
- src[0+0*stride]=(l1 + t1)>>1;
- src[1+0*stride]=
- src[0+1*stride]=(l2 + t2)>>1;
- src[2+0*stride]=
- src[1+1*stride]=
- src[0+2*stride]=
- src[3+0*stride]=
- src[2+1*stride]=
- src[1+2*stride]=
- src[0+3*stride]=
- src[3+1*stride]=
- src[2+2*stride]=
- src[1+3*stride]=
- src[3+2*stride]=
- src[2+3*stride]=
- src[3+3*stride]=(l3 + t3)>>1;
-}
-
-static void pred4x4_down_left_rv40_c(uint8_t *src, const uint8_t *topright,
- ptrdiff_t stride)
-{
- LOAD_TOP_EDGE
- LOAD_TOP_RIGHT_EDGE
- LOAD_LEFT_EDGE
- LOAD_DOWN_LEFT_EDGE
-
- src[0+0*stride]=(t0 + t2 + 2*t1 + 2 + l0 + l2 + 2*l1 + 2)>>3;
- src[1+0*stride]=
- src[0+1*stride]=(t1 + t3 + 2*t2 + 2 + l1 + l3 + 2*l2 + 2)>>3;
- src[2+0*stride]=
- src[1+1*stride]=
- src[0+2*stride]=(t2 + t4 + 2*t3 + 2 + l2 + l4 + 2*l3 + 2)>>3;
- src[3+0*stride]=
- src[2+1*stride]=
- src[1+2*stride]=
- src[0+3*stride]=(t3 + t5 + 2*t4 + 2 + l3 + l5 + 2*l4 + 2)>>3;
- src[3+1*stride]=
- src[2+2*stride]=
- src[1+3*stride]=(t4 + t6 + 2*t5 + 2 + l4 + l6 + 2*l5 + 2)>>3;
- src[3+2*stride]=
- src[2+3*stride]=(t5 + t7 + 2*t6 + 2 + l5 + l7 + 2*l6 + 2)>>3;
- src[3+3*stride]=(t6 + t7 + 1 + l6 + l7 + 1)>>2;
-}
-
-static void pred4x4_down_left_rv40_nodown_c(uint8_t *src,
- const uint8_t *topright,
- ptrdiff_t stride)
-{
- LOAD_TOP_EDGE
- LOAD_TOP_RIGHT_EDGE
- LOAD_LEFT_EDGE
-
- src[0+0*stride]=(t0 + t2 + 2*t1 + 2 + l0 + l2 + 2*l1 + 2)>>3;
- src[1+0*stride]=
- src[0+1*stride]=(t1 + t3 + 2*t2 + 2 + l1 + l3 + 2*l2 + 2)>>3;
- src[2+0*stride]=
- src[1+1*stride]=
- src[0+2*stride]=(t2 + t4 + 2*t3 + 2 + l2 + 3*l3 + 2)>>3;
- src[3+0*stride]=
- src[2+1*stride]=
- src[1+2*stride]=
- src[0+3*stride]=(t3 + t5 + 2*t4 + 2 + l3*4 + 2)>>3;
- src[3+1*stride]=
- src[2+2*stride]=
- src[1+3*stride]=(t4 + t6 + 2*t5 + 2 + l3*4 + 2)>>3;
- src[3+2*stride]=
- src[2+3*stride]=(t5 + t7 + 2*t6 + 2 + l3*4 + 2)>>3;
- src[3+3*stride]=(t6 + t7 + 1 + 2*l3 + 1)>>2;
-}
-
-static void pred4x4_vertical_left_rv40(uint8_t *src, const uint8_t *topright,
- ptrdiff_t stride,
- const int l0, const int l1, const int l2,
- const int l3, const int l4)
-{
- LOAD_TOP_EDGE
- LOAD_TOP_RIGHT_EDGE
-
- src[0+0*stride]=(2*t0 + 2*t1 + l1 + 2*l2 + l3 + 4)>>3;
- src[1+0*stride]=
- src[0+2*stride]=(t1 + t2 + 1)>>1;
- src[2+0*stride]=
- src[1+2*stride]=(t2 + t3 + 1)>>1;
- src[3+0*stride]=
- src[2+2*stride]=(t3 + t4+ 1)>>1;
- src[3+2*stride]=(t4 + t5+ 1)>>1;
- src[0+1*stride]=(t0 + 2*t1 + t2 + l2 + 2*l3 + l4 + 4)>>3;
- src[1+1*stride]=
- src[0+3*stride]=(t1 + 2*t2 + t3 + 2)>>2;
- src[2+1*stride]=
- src[1+3*stride]=(t2 + 2*t3 + t4 + 2)>>2;
- src[3+1*stride]=
- src[2+3*stride]=(t3 + 2*t4 + t5 + 2)>>2;
- src[3+3*stride]=(t4 + 2*t5 + t6 + 2)>>2;
-}
-
-static void pred4x4_vertical_left_rv40_c(uint8_t *src, const uint8_t *topright,
- ptrdiff_t stride)
-{
- LOAD_LEFT_EDGE
- LOAD_DOWN_LEFT_EDGE
-
- pred4x4_vertical_left_rv40(src, topright, stride, l0, l1, l2, l3, l4);
-}
-
-static void pred4x4_vertical_left_rv40_nodown_c(uint8_t *src,
- const uint8_t *topright,
- ptrdiff_t stride)
-{
- LOAD_LEFT_EDGE
-
- pred4x4_vertical_left_rv40(src, topright, stride, l0, l1, l2, l3, l3);
-}
-
-static void pred4x4_vertical_left_vp8_c(uint8_t *src, const uint8_t *topright,
- ptrdiff_t stride)
-{
- LOAD_TOP_EDGE
- LOAD_TOP_RIGHT_EDGE
-
- src[0+0*stride]=(t0 + t1 + 1)>>1;
- src[1+0*stride]=
- src[0+2*stride]=(t1 + t2 + 1)>>1;
- src[2+0*stride]=
- src[1+2*stride]=(t2 + t3 + 1)>>1;
- src[3+0*stride]=
- src[2+2*stride]=(t3 + t4 + 1)>>1;
- src[0+1*stride]=(t0 + 2*t1 + t2 + 2)>>2;
- src[1+1*stride]=
- src[0+3*stride]=(t1 + 2*t2 + t3 + 2)>>2;
- src[2+1*stride]=
- src[1+3*stride]=(t2 + 2*t3 + t4 + 2)>>2;
- src[3+1*stride]=
- src[2+3*stride]=(t3 + 2*t4 + t5 + 2)>>2;
- src[3+2*stride]=(t4 + 2*t5 + t6 + 2)>>2;
- src[3+3*stride]=(t5 + 2*t6 + t7 + 2)>>2;
-}
-
-static void pred4x4_horizontal_up_rv40_c(uint8_t *src, const uint8_t *topright,
- ptrdiff_t stride)
-{
- LOAD_LEFT_EDGE
- LOAD_DOWN_LEFT_EDGE
- LOAD_TOP_EDGE
- LOAD_TOP_RIGHT_EDGE
-
- src[0+0*stride]=(t1 + 2*t2 + t3 + 2*l0 + 2*l1 + 4)>>3;
- src[1+0*stride]=(t2 + 2*t3 + t4 + l0 + 2*l1 + l2 + 4)>>3;
- src[2+0*stride]=
- src[0+1*stride]=(t3 + 2*t4 + t5 + 2*l1 + 2*l2 + 4)>>3;
- src[3+0*stride]=
- src[1+1*stride]=(t4 + 2*t5 + t6 + l1 + 2*l2 + l3 + 4)>>3;
- src[2+1*stride]=
- src[0+2*stride]=(t5 + 2*t6 + t7 + 2*l2 + 2*l3 + 4)>>3;
- src[3+1*stride]=
- src[1+2*stride]=(t6 + 3*t7 + l2 + 3*l3 + 4)>>3;
- src[3+2*stride]=
- src[1+3*stride]=(l3 + 2*l4 + l5 + 2)>>2;
- src[0+3*stride]=
- src[2+2*stride]=(t6 + t7 + l3 + l4 + 2)>>2;
- src[2+3*stride]=(l4 + l5 + 1)>>1;
- src[3+3*stride]=(l4 + 2*l5 + l6 + 2)>>2;
-}
-
-static void pred4x4_horizontal_up_rv40_nodown_c(uint8_t *src,
- const uint8_t *topright,
- ptrdiff_t stride)
-{
- LOAD_LEFT_EDGE
- LOAD_TOP_EDGE
- LOAD_TOP_RIGHT_EDGE
-
- src[0+0*stride]=(t1 + 2*t2 + t3 + 2*l0 + 2*l1 + 4)>>3;
- src[1+0*stride]=(t2 + 2*t3 + t4 + l0 + 2*l1 + l2 + 4)>>3;
- src[2+0*stride]=
- src[0+1*stride]=(t3 + 2*t4 + t5 + 2*l1 + 2*l2 + 4)>>3;
- src[3+0*stride]=
- src[1+1*stride]=(t4 + 2*t5 + t6 + l1 + 2*l2 + l3 + 4)>>3;
- src[2+1*stride]=
- src[0+2*stride]=(t5 + 2*t6 + t7 + 2*l2 + 2*l3 + 4)>>3;
- src[3+1*stride]=
- src[1+2*stride]=(t6 + 3*t7 + l2 + 3*l3 + 4)>>3;
- src[3+2*stride]=
- src[1+3*stride]=l3;
- src[0+3*stride]=
- src[2+2*stride]=(t6 + t7 + 2*l3 + 2)>>2;
- src[2+3*stride]=
- src[3+3*stride]=l3;
-}
-
-static void pred4x4_tm_vp8_c(uint8_t *src, const uint8_t *topright,
- ptrdiff_t stride)
-{
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP - src[-1-stride];
- uint8_t *top = src-stride;
- int y;
-
- for (y = 0; y < 4; y++) {
- uint8_t *cm_in = cm + src[-1];
- src[0] = cm_in[top[0]];
- src[1] = cm_in[top[1]];
- src[2] = cm_in[top[2]];
- src[3] = cm_in[top[3]];
- src += stride;
- }
-}
-
-static void pred16x16_plane_svq3_c(uint8_t *src, ptrdiff_t stride)
-{
- pred16x16_plane_compat_8_c(src, stride, 1, 0);
-}
-
-static void pred16x16_plane_rv40_c(uint8_t *src, ptrdiff_t stride)
-{
- pred16x16_plane_compat_8_c(src, stride, 0, 1);
-}
-
-static void pred16x16_tm_vp8_c(uint8_t *src, ptrdiff_t stride)
-{
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP - src[-1-stride];
- uint8_t *top = src-stride;
- int y;
-
- for (y = 0; y < 16; y++) {
- uint8_t *cm_in = cm + src[-1];
- src[0] = cm_in[top[0]];
- src[1] = cm_in[top[1]];
- src[2] = cm_in[top[2]];
- src[3] = cm_in[top[3]];
- src[4] = cm_in[top[4]];
- src[5] = cm_in[top[5]];
- src[6] = cm_in[top[6]];
- src[7] = cm_in[top[7]];
- src[8] = cm_in[top[8]];
- src[9] = cm_in[top[9]];
- src[10] = cm_in[top[10]];
- src[11] = cm_in[top[11]];
- src[12] = cm_in[top[12]];
- src[13] = cm_in[top[13]];
- src[14] = cm_in[top[14]];
- src[15] = cm_in[top[15]];
- src += stride;
- }
-}
-
-static void pred8x8_left_dc_rv40_c(uint8_t *src, ptrdiff_t stride)
-{
- int i;
- unsigned dc0;
-
- dc0=0;
- for(i=0;i<8; i++)
- dc0+= src[-1+i*stride];
- dc0= 0x01010101*((dc0 + 4)>>3);
-
- for(i=0; i<8; i++){
- ((uint32_t*)(src+i*stride))[0]=
- ((uint32_t*)(src+i*stride))[1]= dc0;
- }
-}
-
-static void pred8x8_top_dc_rv40_c(uint8_t *src, ptrdiff_t stride)
-{
- int i;
- unsigned dc0;
-
- dc0=0;
- for(i=0;i<8; i++)
- dc0+= src[i-stride];
- dc0= 0x01010101*((dc0 + 4)>>3);
-
- for(i=0; i<8; i++){
- ((uint32_t*)(src+i*stride))[0]=
- ((uint32_t*)(src+i*stride))[1]= dc0;
- }
-}
-
-static void pred8x8_dc_rv40_c(uint8_t *src, ptrdiff_t stride)
-{
- int i;
- unsigned dc0 = 0;
-
- for(i=0;i<4; i++){
- dc0+= src[-1+i*stride] + src[i-stride];
- dc0+= src[4+i-stride];
- dc0+= src[-1+(i+4)*stride];
- }
- dc0= 0x01010101*((dc0 + 8)>>4);
-
- for(i=0; i<4; i++){
- ((uint32_t*)(src+i*stride))[0]= dc0;
- ((uint32_t*)(src+i*stride))[1]= dc0;
- }
- for(i=4; i<8; i++){
- ((uint32_t*)(src+i*stride))[0]= dc0;
- ((uint32_t*)(src+i*stride))[1]= dc0;
- }
-}
-
-static void pred8x8_tm_vp8_c(uint8_t *src, ptrdiff_t stride)
-{
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP - src[-1-stride];
- uint8_t *top = src-stride;
- int y;
-
- for (y = 0; y < 8; y++) {
- uint8_t *cm_in = cm + src[-1];
- src[0] = cm_in[top[0]];
- src[1] = cm_in[top[1]];
- src[2] = cm_in[top[2]];
- src[3] = cm_in[top[3]];
- src[4] = cm_in[top[4]];
- src[5] = cm_in[top[5]];
- src[6] = cm_in[top[6]];
- src[7] = cm_in[top[7]];
- src += stride;
- }
-}
-
-/**
- * Set the intra prediction function pointers.
- */
-void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth,
- int chroma_format_idc)
-{
-// MpegEncContext * const s = &h->s;
-
-#undef FUNC
-#undef FUNCC
-#define FUNC(a, depth) a ## _ ## depth
-#define FUNCC(a, depth) a ## _ ## depth ## _c
-#define FUNCD(a) a ## _c
-
-#define H264_PRED(depth) \
- if(codec_id != AV_CODEC_ID_RV40){\
- if(codec_id == AV_CODEC_ID_VP8) {\
- h->pred4x4[VERT_PRED ]= FUNCD(pred4x4_vertical_vp8);\
- h->pred4x4[HOR_PRED ]= FUNCD(pred4x4_horizontal_vp8);\
- } else {\
- h->pred4x4[VERT_PRED ]= FUNCC(pred4x4_vertical , depth);\
- h->pred4x4[HOR_PRED ]= FUNCC(pred4x4_horizontal , depth);\
- }\
- h->pred4x4[DC_PRED ]= FUNCC(pred4x4_dc , depth);\
- if(codec_id == AV_CODEC_ID_SVQ3)\
- h->pred4x4[DIAG_DOWN_LEFT_PRED ]= FUNCD(pred4x4_down_left_svq3);\
- else\
- h->pred4x4[DIAG_DOWN_LEFT_PRED ]= FUNCC(pred4x4_down_left , depth);\
- 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) {\
- 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) {\
- 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);\
- h->pred4x4[DC_129_PRED ]= FUNCC(pred4x4_129_dc , depth);\
- h->pred4x4[VERT_VP8_PRED ]= FUNCC(pred4x4_vertical , depth);\
- h->pred4x4[HOR_VP8_PRED ]= FUNCC(pred4x4_horizontal , depth);\
- }\
- }else{\
- h->pred4x4[VERT_PRED ]= FUNCC(pred4x4_vertical , depth);\
- h->pred4x4[HOR_PRED ]= FUNCC(pred4x4_horizontal , depth);\
- h->pred4x4[DC_PRED ]= FUNCC(pred4x4_dc , depth);\
- h->pred4x4[DIAG_DOWN_LEFT_PRED ]= FUNCD(pred4x4_down_left_rv40);\
- 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);\
- h->pred4x4[VERT_LEFT_PRED ]= FUNCD(pred4x4_vertical_left_rv40);\
- h->pred4x4[HOR_UP_PRED ]= FUNCD(pred4x4_horizontal_up_rv40);\
- 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);\
- h->pred4x4[DIAG_DOWN_LEFT_PRED_RV40_NODOWN]= FUNCD(pred4x4_down_left_rv40_nodown);\
- h->pred4x4[HOR_UP_PRED_RV40_NODOWN]= FUNCD(pred4x4_horizontal_up_rv40_nodown);\
- h->pred4x4[VERT_LEFT_PRED_RV40_NODOWN]= FUNCD(pred4x4_vertical_left_rv40_nodown);\
- }\
-\
- h->pred8x8l[VERT_PRED ]= FUNCC(pred8x8l_vertical , depth);\
- h->pred8x8l[HOR_PRED ]= FUNCC(pred8x8l_horizontal , depth);\
- h->pred8x8l[DC_PRED ]= FUNCC(pred8x8l_dc , depth);\
- h->pred8x8l[DIAG_DOWN_LEFT_PRED ]= FUNCC(pred8x8l_down_left , depth);\
- h->pred8x8l[DIAG_DOWN_RIGHT_PRED]= FUNCC(pred8x8l_down_right , depth);\
- h->pred8x8l[VERT_RIGHT_PRED ]= FUNCC(pred8x8l_vertical_right , depth);\
- h->pred8x8l[HOR_DOWN_PRED ]= FUNCC(pred8x8l_horizontal_down , depth);\
- h->pred8x8l[VERT_LEFT_PRED ]= FUNCC(pred8x8l_vertical_left , depth);\
- h->pred8x8l[HOR_UP_PRED ]= FUNCC(pred8x8l_horizontal_up , depth);\
- h->pred8x8l[LEFT_DC_PRED ]= FUNCC(pred8x8l_left_dc , depth);\
- 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) {\
- 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) {\
- 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) {\
- 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);\
- h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l0t, depth);\
- h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0lt, depth);\
- h->pred8x8[ALZHEIMER_DC_L00_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l00, depth);\
- h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0l0, depth);\
- } else {\
- h->pred8x8[DC_PRED8x8 ]= FUNCC(pred8x16_dc , depth);\
- h->pred8x8[LEFT_DC_PRED8x8]= FUNCC(pred8x16_left_dc , depth);\
- h->pred8x8[TOP_DC_PRED8x8 ]= FUNCC(pred8x16_top_dc , depth);\
- h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8 ]= FUNC(pred8x16_mad_cow_dc_l0t, depth);\
- h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8 ]= FUNC(pred8x16_mad_cow_dc_0lt, depth);\
- h->pred8x8[ALZHEIMER_DC_L00_PRED8x8 ]= FUNC(pred8x16_mad_cow_dc_l00, depth);\
- h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8 ]= FUNC(pred8x16_mad_cow_dc_0l0, depth);\
- }\
- }else{\
- 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) {\
- 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) {\
- h->pred8x8[DC_128_PRED8x8 ]= FUNCC(pred8x8_128_dc , depth);\
- } else {\
- h->pred8x8[DC_128_PRED8x8 ]= FUNCC(pred8x16_128_dc , depth);\
- }\
-\
- h->pred16x16[DC_PRED8x8 ]= FUNCC(pred16x16_dc , depth);\
- h->pred16x16[VERT_PRED8x8 ]= FUNCC(pred16x16_vertical , depth);\
- h->pred16x16[HOR_PRED8x8 ]= FUNCC(pred16x16_horizontal , depth);\
- switch(codec_id){\
- case AV_CODEC_ID_SVQ3:\
- h->pred16x16[PLANE_PRED8x8 ]= FUNCD(pred16x16_plane_svq3);\
- break;\
- case AV_CODEC_ID_RV40:\
- h->pred16x16[PLANE_PRED8x8 ]= FUNCD(pred16x16_plane_rv40);\
- break;\
- case AV_CODEC_ID_VP8:\
- h->pred16x16[PLANE_PRED8x8 ]= FUNCD(pred16x16_tm_vp8);\
- h->pred16x16[DC_127_PRED8x8]= FUNCC(pred16x16_127_dc , depth);\
- h->pred16x16[DC_129_PRED8x8]= FUNCC(pred16x16_129_dc , depth);\
- break;\
- default:\
- h->pred16x16[PLANE_PRED8x8 ]= FUNCC(pred16x16_plane , depth);\
- break;\
- }\
- h->pred16x16[LEFT_DC_PRED8x8]= FUNCC(pred16x16_left_dc , depth);\
- h->pred16x16[TOP_DC_PRED8x8 ]= FUNCC(pred16x16_top_dc , depth);\
- h->pred16x16[DC_128_PRED8x8 ]= FUNCC(pred16x16_128_dc , depth);\
-\
- /* special lossless h/v prediction for h264 */ \
- h->pred4x4_add [VERT_PRED ]= FUNCC(pred4x4_vertical_add , depth);\
- 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->pred8x8_add [VERT_PRED8x8]= FUNCC(pred8x8_vertical_add , depth);\
- h->pred8x8_add [ HOR_PRED8x8]= FUNCC(pred8x8_horizontal_add , depth);\
- } else {\
- h->pred8x8_add [VERT_PRED8x8]= FUNCC(pred8x16_vertical_add , depth);\
- h->pred8x8_add [ HOR_PRED8x8]= FUNCC(pred8x16_horizontal_add , depth);\
- }\
- 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)
- break;
- case 10:
- H264_PRED(10)
- break;
- case 12:
- H264_PRED(12)
- break;
- case 14:
- H264_PRED(14)
- break;
- default:
- av_assert0(bit_depth<=8);
- H264_PRED(8)
- break;
- }
-
- if (ARCH_ARM) ff_h264_pred_init_arm(h, codec_id, bit_depth, chroma_format_idc);
- if (ARCH_X86) ff_h264_pred_init_x86(h, codec_id, bit_depth, chroma_format_idc);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264pred.h b/src/thirdparty/ffmpeg/libavcodec/h264pred.h
deleted file mode 100644
index 7782949da..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264pred.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * H.26L/H.264/AVC/JVT/14496-10/... encoder/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 prediction functions.
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#ifndef AVCODEC_H264PRED_H
-#define AVCODEC_H264PRED_H
-
-#include <stddef.h>
-#include <stdint.h>
-
-/**
- * Prediction types
- */
-//@{
-#define VERT_PRED 0
-#define HOR_PRED 1
-#define DC_PRED 2
-#define DIAG_DOWN_LEFT_PRED 3
-#define DIAG_DOWN_RIGHT_PRED 4
-#define VERT_RIGHT_PRED 5
-#define HOR_DOWN_PRED 6
-#define VERT_LEFT_PRED 7
-#define HOR_UP_PRED 8
-
-// DC edge (not for VP8)
-#define LEFT_DC_PRED 9
-#define TOP_DC_PRED 10
-#define DC_128_PRED 11
-
-// RV40 specific
-#define DIAG_DOWN_LEFT_PRED_RV40_NODOWN 12
-#define HOR_UP_PRED_RV40_NODOWN 13
-#define VERT_LEFT_PRED_RV40_NODOWN 14
-
-// VP8 specific
-#define TM_VP8_PRED 9 ///< "True Motion", used instead of plane
-#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
- ///< #VERT_VP8_PRED for details
-#define DC_127_PRED 12
-#define DC_129_PRED 13
-
-#define DC_PRED8x8 0
-#define HOR_PRED8x8 1
-#define VERT_PRED8x8 2
-#define PLANE_PRED8x8 3
-
-// DC edge
-#define LEFT_DC_PRED8x8 4
-#define TOP_DC_PRED8x8 5
-#define DC_128_PRED8x8 6
-
-// H264/SVQ3 (8x8) specific
-#define ALZHEIMER_DC_L0T_PRED8x8 7
-#define ALZHEIMER_DC_0LT_PRED8x8 8
-#define ALZHEIMER_DC_L00_PRED8x8 9
-#define ALZHEIMER_DC_0L0_PRED8x8 10
-
-// VP8 specific
-#define DC_127_PRED8x8 7
-#define DC_129_PRED8x8 8
-//@}
-
-/**
- * Context for storing H.264 prediction functions
- */
-typedef struct H264PredContext {
- void(*pred4x4[9 + 3 + 3])(uint8_t *src, const uint8_t *topright,
- ptrdiff_t stride);
- void(*pred8x8l[9 + 3])(uint8_t *src, int topleft, int topright,
- ptrdiff_t stride);
- void(*pred8x8[4 + 3 + 4])(uint8_t *src, ptrdiff_t stride);
- void(*pred16x16[4 + 3 + 2])(uint8_t *src, ptrdiff_t stride);
-
- void(*pred4x4_add[2])(uint8_t *pix /*align 4*/,
- const int16_t *block /*align 16*/, ptrdiff_t stride);
- void(*pred8x8l_add[2])(uint8_t *pix /*align 8*/,
- const int16_t *block /*align 16*/, ptrdiff_t stride);
- void(*pred8x8_add[3])(uint8_t *pix /*align 8*/,
- const int *block_offset,
- const int16_t *block /*align 16*/, ptrdiff_t stride);
- void(*pred16x16_add[3])(uint8_t *pix /*align 16*/,
- const int *block_offset,
- const int16_t *block /*align 16*/, ptrdiff_t stride);
-} H264PredContext;
-
-void ff_h264_pred_init(H264PredContext *h, int codec_id,
- const int bit_depth, const int chroma_format_idc);
-void ff_h264_pred_init_arm(H264PredContext *h, int codec_id,
- const int bit_depth, const int chroma_format_idc);
-void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
- const int bit_depth, const int chroma_format_idc);
-
-#endif /* AVCODEC_H264PRED_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264pred_template.c b/src/thirdparty/ffmpeg/libavcodec/h264pred_template.c
deleted file mode 100644
index 5525eed8d..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264pred_template.c
+++ /dev/null
@@ -1,1272 +0,0 @@
-/*
- * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
- * Copyright (c) 2003-2011 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 prediction functions.
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#include "mathops.h"
-
-#include "bit_depth_template.c"
-
-static void FUNCC(pred4x4_vertical)(uint8_t *_src, const uint8_t *topright,
- ptrdiff_t _stride)
-{
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
- const pixel4 a= AV_RN4PA(src-stride);
-
- AV_WN4PA(src+0*stride, a);
- AV_WN4PA(src+1*stride, a);
- AV_WN4PA(src+2*stride, a);
- AV_WN4PA(src+3*stride, a);
-}
-
-static void FUNCC(pred4x4_horizontal)(uint8_t *_src, const uint8_t *topright,
- ptrdiff_t _stride)
-{
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
- AV_WN4PA(src+0*stride, PIXEL_SPLAT_X4(src[-1+0*stride]));
- AV_WN4PA(src+1*stride, PIXEL_SPLAT_X4(src[-1+1*stride]));
- AV_WN4PA(src+2*stride, PIXEL_SPLAT_X4(src[-1+2*stride]));
- AV_WN4PA(src+3*stride, PIXEL_SPLAT_X4(src[-1+3*stride]));
-}
-
-static void FUNCC(pred4x4_dc)(uint8_t *_src, const uint8_t *topright,
- ptrdiff_t _stride)
-{
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
- const int dc= ( src[-stride] + src[1-stride] + src[2-stride] + src[3-stride]
- + src[-1+0*stride] + src[-1+1*stride] + src[-1+2*stride] + src[-1+3*stride] + 4) >>3;
- const pixel4 a = PIXEL_SPLAT_X4(dc);
-
- AV_WN4PA(src+0*stride, a);
- AV_WN4PA(src+1*stride, a);
- AV_WN4PA(src+2*stride, a);
- AV_WN4PA(src+3*stride, a);
-}
-
-static void FUNCC(pred4x4_left_dc)(uint8_t *_src, const uint8_t *topright,
- ptrdiff_t _stride)
-{
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
- const int dc= ( src[-1+0*stride] + src[-1+1*stride] + src[-1+2*stride] + src[-1+3*stride] + 2) >>2;
- const pixel4 a = PIXEL_SPLAT_X4(dc);
-
- AV_WN4PA(src+0*stride, a);
- AV_WN4PA(src+1*stride, a);
- AV_WN4PA(src+2*stride, a);
- AV_WN4PA(src+3*stride, a);
-}
-
-static void FUNCC(pred4x4_top_dc)(uint8_t *_src, const uint8_t *topright,
- ptrdiff_t _stride)
-{
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
- const int dc= ( src[-stride] + src[1-stride] + src[2-stride] + src[3-stride] + 2) >>2;
- const pixel4 a = PIXEL_SPLAT_X4(dc);
-
- AV_WN4PA(src+0*stride, a);
- AV_WN4PA(src+1*stride, a);
- AV_WN4PA(src+2*stride, a);
- AV_WN4PA(src+3*stride, a);
-}
-
-static void FUNCC(pred4x4_128_dc)(uint8_t *_src, const uint8_t *topright,
- ptrdiff_t _stride)
-{
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
- const pixel4 a = PIXEL_SPLAT_X4(1<<(BIT_DEPTH-1));
-
- AV_WN4PA(src+0*stride, a);
- AV_WN4PA(src+1*stride, a);
- AV_WN4PA(src+2*stride, a);
- AV_WN4PA(src+3*stride, a);
-}
-
-static void FUNCC(pred4x4_127_dc)(uint8_t *_src, const uint8_t *topright,
- ptrdiff_t _stride)
-{
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
- const pixel4 a = PIXEL_SPLAT_X4((1<<(BIT_DEPTH-1))-1);
-
- AV_WN4PA(src+0*stride, a);
- AV_WN4PA(src+1*stride, a);
- AV_WN4PA(src+2*stride, a);
- AV_WN4PA(src+3*stride, a);
-}
-
-static void FUNCC(pred4x4_129_dc)(uint8_t *_src, const uint8_t *topright,
- ptrdiff_t _stride)
-{
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
- const pixel4 a = PIXEL_SPLAT_X4((1<<(BIT_DEPTH-1))+1);
-
- AV_WN4PA(src+0*stride, a);
- AV_WN4PA(src+1*stride, a);
- AV_WN4PA(src+2*stride, a);
- AV_WN4PA(src+3*stride, a);
-}
-
-
-#define LOAD_TOP_RIGHT_EDGE\
- const unsigned av_unused t4 = topright[0];\
- const unsigned av_unused t5 = topright[1];\
- const unsigned av_unused t6 = topright[2];\
- const unsigned av_unused t7 = topright[3];\
-
-#define LOAD_DOWN_LEFT_EDGE\
- const unsigned av_unused l4 = src[-1+4*stride];\
- const unsigned av_unused l5 = src[-1+5*stride];\
- const unsigned av_unused l6 = src[-1+6*stride];\
- const unsigned av_unused l7 = src[-1+7*stride];\
-
-#define LOAD_LEFT_EDGE\
- const unsigned av_unused l0 = src[-1+0*stride];\
- const unsigned av_unused l1 = src[-1+1*stride];\
- const unsigned av_unused l2 = src[-1+2*stride];\
- const unsigned av_unused l3 = src[-1+3*stride];\
-
-#define LOAD_TOP_EDGE\
- const unsigned av_unused t0 = src[ 0-1*stride];\
- const unsigned av_unused t1 = src[ 1-1*stride];\
- const unsigned av_unused t2 = src[ 2-1*stride];\
- const unsigned av_unused t3 = src[ 3-1*stride];\
-
-static void FUNCC(pred4x4_down_right)(uint8_t *_src, const uint8_t *topright,
- ptrdiff_t _stride)
-{
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
- const int lt= src[-1-1*stride];
- LOAD_TOP_EDGE
- LOAD_LEFT_EDGE
-
- src[0+3*stride]=(l3 + 2*l2 + l1 + 2)>>2;
- src[0+2*stride]=
- src[1+3*stride]=(l2 + 2*l1 + l0 + 2)>>2;
- src[0+1*stride]=
- src[1+2*stride]=
- src[2+3*stride]=(l1 + 2*l0 + lt + 2)>>2;
- src[0+0*stride]=
- src[1+1*stride]=
- src[2+2*stride]=
- src[3+3*stride]=(l0 + 2*lt + t0 + 2)>>2;
- src[1+0*stride]=
- src[2+1*stride]=
- src[3+2*stride]=(lt + 2*t0 + t1 + 2)>>2;
- src[2+0*stride]=
- src[3+1*stride]=(t0 + 2*t1 + t2 + 2)>>2;
- src[3+0*stride]=(t1 + 2*t2 + t3 + 2)>>2;
-}
-
-static void FUNCC(pred4x4_down_left)(uint8_t *_src, const uint8_t *_topright,
- ptrdiff_t _stride)
-{
- pixel *src = (pixel*)_src;
- const pixel *topright = (const pixel*)_topright;
- int stride = _stride>>(sizeof(pixel)-1);
- LOAD_TOP_EDGE
- LOAD_TOP_RIGHT_EDGE
-// LOAD_LEFT_EDGE
-
- src[0+0*stride]=(t0 + t2 + 2*t1 + 2)>>2;
- src[1+0*stride]=
- src[0+1*stride]=(t1 + t3 + 2*t2 + 2)>>2;
- src[2+0*stride]=
- src[1+1*stride]=
- src[0+2*stride]=(t2 + t4 + 2*t3 + 2)>>2;
- src[3+0*stride]=
- src[2+1*stride]=
- src[1+2*stride]=
- src[0+3*stride]=(t3 + t5 + 2*t4 + 2)>>2;
- src[3+1*stride]=
- src[2+2*stride]=
- src[1+3*stride]=(t4 + t6 + 2*t5 + 2)>>2;
- src[3+2*stride]=
- src[2+3*stride]=(t5 + t7 + 2*t6 + 2)>>2;
- src[3+3*stride]=(t6 + 3*t7 + 2)>>2;
-}
-
-static void FUNCC(pred4x4_vertical_right)(uint8_t *_src,
- const uint8_t *topright,
- ptrdiff_t _stride)
-{
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
- const int lt= src[-1-1*stride];
- LOAD_TOP_EDGE
- LOAD_LEFT_EDGE
-
- src[0+0*stride]=
- src[1+2*stride]=(lt + t0 + 1)>>1;
- src[1+0*stride]=
- src[2+2*stride]=(t0 + t1 + 1)>>1;
- src[2+0*stride]=
- src[3+2*stride]=(t1 + t2 + 1)>>1;
- src[3+0*stride]=(t2 + t3 + 1)>>1;
- src[0+1*stride]=
- src[1+3*stride]=(l0 + 2*lt + t0 + 2)>>2;
- src[1+1*stride]=
- src[2+3*stride]=(lt + 2*t0 + t1 + 2)>>2;
- src[2+1*stride]=
- src[3+3*stride]=(t0 + 2*t1 + t2 + 2)>>2;
- src[3+1*stride]=(t1 + 2*t2 + t3 + 2)>>2;
- src[0+2*stride]=(lt + 2*l0 + l1 + 2)>>2;
- src[0+3*stride]=(l0 + 2*l1 + l2 + 2)>>2;
-}
-
-static void FUNCC(pred4x4_vertical_left)(uint8_t *_src,
- const uint8_t *_topright,
- ptrdiff_t _stride)
-{
- pixel *src = (pixel*)_src;
- const pixel *topright = (const pixel*)_topright;
- int stride = _stride>>(sizeof(pixel)-1);
- LOAD_TOP_EDGE
- LOAD_TOP_RIGHT_EDGE
-
- src[0+0*stride]=(t0 + t1 + 1)>>1;
- src[1+0*stride]=
- src[0+2*stride]=(t1 + t2 + 1)>>1;
- src[2+0*stride]=
- src[1+2*stride]=(t2 + t3 + 1)>>1;
- src[3+0*stride]=
- src[2+2*stride]=(t3 + t4+ 1)>>1;
- src[3+2*stride]=(t4 + t5+ 1)>>1;
- src[0+1*stride]=(t0 + 2*t1 + t2 + 2)>>2;
- src[1+1*stride]=
- src[0+3*stride]=(t1 + 2*t2 + t3 + 2)>>2;
- src[2+1*stride]=
- src[1+3*stride]=(t2 + 2*t3 + t4 + 2)>>2;
- src[3+1*stride]=
- src[2+3*stride]=(t3 + 2*t4 + t5 + 2)>>2;
- src[3+3*stride]=(t4 + 2*t5 + t6 + 2)>>2;
-}
-
-static void FUNCC(pred4x4_horizontal_up)(uint8_t *_src, const uint8_t *topright,
- ptrdiff_t _stride)
-{
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
- LOAD_LEFT_EDGE
-
- src[0+0*stride]=(l0 + l1 + 1)>>1;
- src[1+0*stride]=(l0 + 2*l1 + l2 + 2)>>2;
- src[2+0*stride]=
- src[0+1*stride]=(l1 + l2 + 1)>>1;
- src[3+0*stride]=
- src[1+1*stride]=(l1 + 2*l2 + l3 + 2)>>2;
- src[2+1*stride]=
- src[0+2*stride]=(l2 + l3 + 1)>>1;
- src[3+1*stride]=
- src[1+2*stride]=(l2 + 2*l3 + l3 + 2)>>2;
- src[3+2*stride]=
- src[1+3*stride]=
- src[0+3*stride]=
- src[2+2*stride]=
- src[2+3*stride]=
- src[3+3*stride]=l3;
-}
-
-static void FUNCC(pred4x4_horizontal_down)(uint8_t *_src,
- const uint8_t *topright,
- ptrdiff_t _stride)
-{
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
- const int lt= src[-1-1*stride];
- LOAD_TOP_EDGE
- LOAD_LEFT_EDGE
-
- src[0+0*stride]=
- src[2+1*stride]=(lt + l0 + 1)>>1;
- src[1+0*stride]=
- src[3+1*stride]=(l0 + 2*lt + t0 + 2)>>2;
- src[2+0*stride]=(lt + 2*t0 + t1 + 2)>>2;
- src[3+0*stride]=(t0 + 2*t1 + t2 + 2)>>2;
- src[0+1*stride]=
- src[2+2*stride]=(l0 + l1 + 1)>>1;
- src[1+1*stride]=
- src[3+2*stride]=(lt + 2*l0 + l1 + 2)>>2;
- src[0+2*stride]=
- src[2+3*stride]=(l1 + l2+ 1)>>1;
- src[1+2*stride]=
- src[3+3*stride]=(l0 + 2*l1 + l2 + 2)>>2;
- src[0+3*stride]=(l2 + l3 + 1)>>1;
- src[1+3*stride]=(l1 + 2*l2 + l3 + 2)>>2;
-}
-
-static void FUNCC(pred16x16_vertical)(uint8_t *_src, ptrdiff_t _stride)
-{
- int i;
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
- const pixel4 a = AV_RN4PA(((pixel4*)(src-stride))+0);
- const pixel4 b = AV_RN4PA(((pixel4*)(src-stride))+1);
- const pixel4 c = AV_RN4PA(((pixel4*)(src-stride))+2);
- const pixel4 d = AV_RN4PA(((pixel4*)(src-stride))+3);
-
- for(i=0; i<16; i++){
- AV_WN4PA(((pixel4*)(src+i*stride))+0, a);
- AV_WN4PA(((pixel4*)(src+i*stride))+1, b);
- AV_WN4PA(((pixel4*)(src+i*stride))+2, c);
- AV_WN4PA(((pixel4*)(src+i*stride))+3, d);
- }
-}
-
-static void FUNCC(pred16x16_horizontal)(uint8_t *_src, ptrdiff_t stride)
-{
- int i;
- pixel *src = (pixel*)_src;
- stride >>= sizeof(pixel)-1;
-
- for(i=0; i<16; i++){
- const pixel4 a = PIXEL_SPLAT_X4(src[-1+i*stride]);
-
- AV_WN4PA(((pixel4*)(src+i*stride))+0, a);
- AV_WN4PA(((pixel4*)(src+i*stride))+1, a);
- AV_WN4PA(((pixel4*)(src+i*stride))+2, a);
- AV_WN4PA(((pixel4*)(src+i*stride))+3, a);
- }
-}
-
-#define PREDICT_16x16_DC(v)\
- for(i=0; i<16; i++){\
- AV_WN4PA(src+ 0, v);\
- AV_WN4PA(src+ 4, v);\
- AV_WN4PA(src+ 8, v);\
- AV_WN4PA(src+12, v);\
- src += stride;\
- }
-
-static void FUNCC(pred16x16_dc)(uint8_t *_src, ptrdiff_t stride)
-{
- int i, dc=0;
- pixel *src = (pixel*)_src;
- pixel4 dcsplat;
- stride >>= sizeof(pixel)-1;
-
- for(i=0;i<16; i++){
- dc+= src[-1+i*stride];
- }
-
- for(i=0;i<16; i++){
- dc+= src[i-stride];
- }
-
- dcsplat = PIXEL_SPLAT_X4((dc+16)>>5);
- PREDICT_16x16_DC(dcsplat);
-}
-
-static void FUNCC(pred16x16_left_dc)(uint8_t *_src, ptrdiff_t stride)
-{
- int i, dc=0;
- pixel *src = (pixel*)_src;
- pixel4 dcsplat;
- stride >>= sizeof(pixel)-1;
-
- for(i=0;i<16; i++){
- dc+= src[-1+i*stride];
- }
-
- dcsplat = PIXEL_SPLAT_X4((dc+8)>>4);
- PREDICT_16x16_DC(dcsplat);
-}
-
-static void FUNCC(pred16x16_top_dc)(uint8_t *_src, ptrdiff_t stride)
-{
- int i, dc=0;
- pixel *src = (pixel*)_src;
- pixel4 dcsplat;
- stride >>= sizeof(pixel)-1;
-
- for(i=0;i<16; i++){
- dc+= src[i-stride];
- }
-
- dcsplat = PIXEL_SPLAT_X4((dc+8)>>4);
- PREDICT_16x16_DC(dcsplat);
-}
-
-#define PRED16x16_X(n, v) \
-static void FUNCC(pred16x16_##n##_dc)(uint8_t *_src, ptrdiff_t stride)\
-{\
- int i;\
- pixel *src = (pixel*)_src;\
- stride >>= sizeof(pixel)-1;\
- PREDICT_16x16_DC(PIXEL_SPLAT_X4(v));\
-}
-
-PRED16x16_X(127, (1<<(BIT_DEPTH-1))-1)
-PRED16x16_X(128, (1<<(BIT_DEPTH-1))+0)
-PRED16x16_X(129, (1<<(BIT_DEPTH-1))+1)
-
-static inline void FUNCC(pred16x16_plane_compat)(uint8_t *_src,
- ptrdiff_t _stride,
- const int svq3,
- const int rv40)
-{
- int i, j, k;
- int a;
- INIT_CLIP
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
- const pixel * const src0 = src +7-stride;
- const pixel * src1 = src +8*stride-1;
- const pixel * src2 = src1-2*stride; // == src+6*stride-1;
- int H = src0[1] - src0[-1];
- int V = src1[0] - src2[ 0];
- for(k=2; k<=8; ++k) {
- src1 += stride; src2 -= stride;
- H += k*(src0[k] - src0[-k]);
- V += k*(src1[0] - src2[ 0]);
- }
- if(svq3){
- H = ( 5*(H/4) ) / 16;
- V = ( 5*(V/4) ) / 16;
-
- /* required for 100% accuracy */
- i = H; H = V; V = i;
- }else if(rv40){
- H = ( H + (H>>2) ) >> 4;
- V = ( V + (V>>2) ) >> 4;
- }else{
- H = ( 5*H+32 ) >> 6;
- V = ( 5*V+32 ) >> 6;
- }
-
- a = 16*(src1[0] + src2[16] + 1) - 7*(V+H);
- for(j=16; j>0; --j) {
- int b = a;
- a += V;
- for(i=-16; i<0; i+=4) {
- src[16+i] = CLIP((b ) >> 5);
- src[17+i] = CLIP((b+ H) >> 5);
- src[18+i] = CLIP((b+2*H) >> 5);
- src[19+i] = CLIP((b+3*H) >> 5);
- b += 4*H;
- }
- src += stride;
- }
-}
-
-static void FUNCC(pred16x16_plane)(uint8_t *src, ptrdiff_t stride)
-{
- FUNCC(pred16x16_plane_compat)(src, stride, 0, 0);
-}
-
-static void FUNCC(pred8x8_vertical)(uint8_t *_src, ptrdiff_t _stride)
-{
- int i;
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
- const pixel4 a= AV_RN4PA(((pixel4*)(src-stride))+0);
- const pixel4 b= AV_RN4PA(((pixel4*)(src-stride))+1);
-
- for(i=0; i<8; i++){
- AV_WN4PA(((pixel4*)(src+i*stride))+0, a);
- AV_WN4PA(((pixel4*)(src+i*stride))+1, b);
- }
-}
-
-static void FUNCC(pred8x16_vertical)(uint8_t *_src, ptrdiff_t _stride)
-{
- int i;
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
- const pixel4 a= AV_RN4PA(((pixel4*)(src-stride))+0);
- const pixel4 b= AV_RN4PA(((pixel4*)(src-stride))+1);
-
- for(i=0; i<16; i++){
- AV_WN4PA(((pixel4*)(src+i*stride))+0, a);
- AV_WN4PA(((pixel4*)(src+i*stride))+1, b);
- }
-}
-
-static void FUNCC(pred8x8_horizontal)(uint8_t *_src, ptrdiff_t stride)
-{
- int i;
- pixel *src = (pixel*)_src;
- stride >>= sizeof(pixel)-1;
-
- for(i=0; i<8; i++){
- const pixel4 a = PIXEL_SPLAT_X4(src[-1+i*stride]);
- AV_WN4PA(((pixel4*)(src+i*stride))+0, a);
- AV_WN4PA(((pixel4*)(src+i*stride))+1, a);
- }
-}
-
-static void FUNCC(pred8x16_horizontal)(uint8_t *_src, ptrdiff_t stride)
-{
- int i;
- pixel *src = (pixel*)_src;
- stride >>= sizeof(pixel)-1;
- for(i=0; i<16; i++){
- const pixel4 a = PIXEL_SPLAT_X4(src[-1+i*stride]);
- AV_WN4PA(((pixel4*)(src+i*stride))+0, a);
- AV_WN4PA(((pixel4*)(src+i*stride))+1, a);
- }
-}
-
-#define PRED8x8_X(n, v)\
-static void FUNCC(pred8x8_##n##_dc)(uint8_t *_src, ptrdiff_t stride)\
-{\
- int i;\
- const pixel4 a = PIXEL_SPLAT_X4(v);\
- pixel *src = (pixel*)_src;\
- stride >>= sizeof(pixel)-1;\
- for(i=0; i<8; i++){\
- AV_WN4PA(((pixel4*)(src+i*stride))+0, a);\
- AV_WN4PA(((pixel4*)(src+i*stride))+1, a);\
- }\
-}
-
-PRED8x8_X(127, (1<<(BIT_DEPTH-1))-1)
-PRED8x8_X(128, (1<<(BIT_DEPTH-1))+0)
-PRED8x8_X(129, (1<<(BIT_DEPTH-1))+1)
-
-static void FUNCC(pred8x16_128_dc)(uint8_t *_src, ptrdiff_t stride)
-{
- FUNCC(pred8x8_128_dc)(_src, stride);
- FUNCC(pred8x8_128_dc)(_src+8*stride, stride);
-}
-
-static void FUNCC(pred8x8_left_dc)(uint8_t *_src, ptrdiff_t stride)
-{
- int i;
- int dc0, dc2;
- pixel4 dc0splat, dc2splat;
- pixel *src = (pixel*)_src;
- stride >>= sizeof(pixel)-1;
-
- dc0=dc2=0;
- for(i=0;i<4; i++){
- dc0+= src[-1+i*stride];
- dc2+= src[-1+(i+4)*stride];
- }
- dc0splat = PIXEL_SPLAT_X4((dc0 + 2)>>2);
- dc2splat = PIXEL_SPLAT_X4((dc2 + 2)>>2);
-
- for(i=0; i<4; i++){
- AV_WN4PA(((pixel4*)(src+i*stride))+0, dc0splat);
- AV_WN4PA(((pixel4*)(src+i*stride))+1, dc0splat);
- }
- for(i=4; i<8; i++){
- AV_WN4PA(((pixel4*)(src+i*stride))+0, dc2splat);
- AV_WN4PA(((pixel4*)(src+i*stride))+1, dc2splat);
- }
-}
-
-static void FUNCC(pred8x16_left_dc)(uint8_t *_src, ptrdiff_t stride)
-{
- FUNCC(pred8x8_left_dc)(_src, stride);
- FUNCC(pred8x8_left_dc)(_src+8*stride, stride);
-}
-
-static void FUNCC(pred8x8_top_dc)(uint8_t *_src, ptrdiff_t stride)
-{
- int i;
- int dc0, dc1;
- pixel4 dc0splat, dc1splat;
- pixel *src = (pixel*)_src;
- stride >>= sizeof(pixel)-1;
-
- dc0=dc1=0;
- for(i=0;i<4; i++){
- dc0+= src[i-stride];
- dc1+= src[4+i-stride];
- }
- dc0splat = PIXEL_SPLAT_X4((dc0 + 2)>>2);
- dc1splat = PIXEL_SPLAT_X4((dc1 + 2)>>2);
-
- for(i=0; i<4; i++){
- AV_WN4PA(((pixel4*)(src+i*stride))+0, dc0splat);
- AV_WN4PA(((pixel4*)(src+i*stride))+1, dc1splat);
- }
- for(i=4; i<8; i++){
- AV_WN4PA(((pixel4*)(src+i*stride))+0, dc0splat);
- AV_WN4PA(((pixel4*)(src+i*stride))+1, dc1splat);
- }
-}
-
-static void FUNCC(pred8x16_top_dc)(uint8_t *_src, ptrdiff_t stride)
-{
- int i;
- int dc0, dc1;
- pixel4 dc0splat, dc1splat;
- pixel *src = (pixel*)_src;
- stride >>= sizeof(pixel)-1;
-
- dc0=dc1=0;
- for(i=0;i<4; i++){
- dc0+= src[i-stride];
- dc1+= src[4+i-stride];
- }
- dc0splat = PIXEL_SPLAT_X4((dc0 + 2)>>2);
- dc1splat = PIXEL_SPLAT_X4((dc1 + 2)>>2);
-
- for(i=0; i<16; i++){
- AV_WN4PA(((pixel4*)(src+i*stride))+0, dc0splat);
- AV_WN4PA(((pixel4*)(src+i*stride))+1, dc1splat);
- }
-}
-
-static void FUNCC(pred8x8_dc)(uint8_t *_src, ptrdiff_t stride)
-{
- int i;
- int dc0, dc1, dc2;
- pixel4 dc0splat, dc1splat, dc2splat, dc3splat;
- pixel *src = (pixel*)_src;
- stride >>= sizeof(pixel)-1;
-
- dc0=dc1=dc2=0;
- for(i=0;i<4; i++){
- dc0+= src[-1+i*stride] + src[i-stride];
- dc1+= src[4+i-stride];
- dc2+= src[-1+(i+4)*stride];
- }
- dc0splat = PIXEL_SPLAT_X4((dc0 + 4)>>3);
- dc1splat = PIXEL_SPLAT_X4((dc1 + 2)>>2);
- dc2splat = PIXEL_SPLAT_X4((dc2 + 2)>>2);
- dc3splat = PIXEL_SPLAT_X4((dc1 + dc2 + 4)>>3);
-
- for(i=0; i<4; i++){
- AV_WN4PA(((pixel4*)(src+i*stride))+0, dc0splat);
- AV_WN4PA(((pixel4*)(src+i*stride))+1, dc1splat);
- }
- for(i=4; i<8; i++){
- AV_WN4PA(((pixel4*)(src+i*stride))+0, dc2splat);
- AV_WN4PA(((pixel4*)(src+i*stride))+1, dc3splat);
- }
-}
-
-static void FUNCC(pred8x16_dc)(uint8_t *_src, ptrdiff_t stride)
-{
- int i;
- int dc0, dc1, dc2, dc3, dc4;
- pixel4 dc0splat, dc1splat, dc2splat, dc3splat, dc4splat, dc5splat, dc6splat, dc7splat;
- pixel *src = (pixel*)_src;
- stride >>= sizeof(pixel)-1;
-
- dc0=dc1=dc2=dc3=dc4=0;
- for(i=0;i<4; i++){
- dc0+= src[-1+i*stride] + src[i-stride];
- dc1+= src[4+i-stride];
- dc2+= src[-1+(i+4)*stride];
- dc3+= src[-1+(i+8)*stride];
- dc4+= src[-1+(i+12)*stride];
- }
- dc0splat = PIXEL_SPLAT_X4((dc0 + 4)>>3);
- dc1splat = PIXEL_SPLAT_X4((dc1 + 2)>>2);
- dc2splat = PIXEL_SPLAT_X4((dc2 + 2)>>2);
- dc3splat = PIXEL_SPLAT_X4((dc1 + dc2 + 4)>>3);
- dc4splat = PIXEL_SPLAT_X4((dc3 + 2)>>2);
- dc5splat = PIXEL_SPLAT_X4((dc1 + dc3 + 4)>>3);
- dc6splat = PIXEL_SPLAT_X4((dc4 + 2)>>2);
- dc7splat = PIXEL_SPLAT_X4((dc1 + dc4 + 4)>>3);
-
- for(i=0; i<4; i++){
- AV_WN4PA(((pixel4*)(src+i*stride))+0, dc0splat);
- AV_WN4PA(((pixel4*)(src+i*stride))+1, dc1splat);
- }
- for(i=4; i<8; i++){
- AV_WN4PA(((pixel4*)(src+i*stride))+0, dc2splat);
- AV_WN4PA(((pixel4*)(src+i*stride))+1, dc3splat);
- }
- for(i=8; i<12; i++){
- AV_WN4PA(((pixel4*)(src+i*stride))+0, dc4splat);
- AV_WN4PA(((pixel4*)(src+i*stride))+1, dc5splat);
- }
- for(i=12; i<16; i++){
- AV_WN4PA(((pixel4*)(src+i*stride))+0, dc6splat);
- AV_WN4PA(((pixel4*)(src+i*stride))+1, dc7splat);
- }
-}
-
-//the following 4 function should not be optimized!
-static void FUNC(pred8x8_mad_cow_dc_l0t)(uint8_t *src, ptrdiff_t stride)
-{
- FUNCC(pred8x8_top_dc)(src, stride);
- FUNCC(pred4x4_dc)(src, NULL, stride);
-}
-
-static void FUNC(pred8x16_mad_cow_dc_l0t)(uint8_t *src, ptrdiff_t stride)
-{
- FUNCC(pred8x16_top_dc)(src, stride);
- FUNCC(pred4x4_dc)(src, NULL, stride);
-}
-
-static void FUNC(pred8x8_mad_cow_dc_0lt)(uint8_t *src, ptrdiff_t stride)
-{
- FUNCC(pred8x8_dc)(src, stride);
- FUNCC(pred4x4_top_dc)(src, NULL, stride);
-}
-
-static void FUNC(pred8x16_mad_cow_dc_0lt)(uint8_t *src, ptrdiff_t stride)
-{
- FUNCC(pred8x16_dc)(src, stride);
- FUNCC(pred4x4_top_dc)(src, NULL, stride);
-}
-
-static void FUNC(pred8x8_mad_cow_dc_l00)(uint8_t *src, ptrdiff_t stride)
-{
- FUNCC(pred8x8_left_dc)(src, stride);
- FUNCC(pred4x4_128_dc)(src + 4*stride , NULL, stride);
- FUNCC(pred4x4_128_dc)(src + 4*stride + 4*sizeof(pixel), NULL, stride);
-}
-
-static void FUNC(pred8x16_mad_cow_dc_l00)(uint8_t *src, ptrdiff_t stride)
-{
- FUNCC(pred8x16_left_dc)(src, stride);
- FUNCC(pred4x4_128_dc)(src + 4*stride , NULL, stride);
- FUNCC(pred4x4_128_dc)(src + 4*stride + 4*sizeof(pixel), NULL, stride);
-}
-
-static void FUNC(pred8x8_mad_cow_dc_0l0)(uint8_t *src, ptrdiff_t stride)
-{
- FUNCC(pred8x8_left_dc)(src, stride);
- FUNCC(pred4x4_128_dc)(src , NULL, stride);
- FUNCC(pred4x4_128_dc)(src + 4*sizeof(pixel), NULL, stride);
-}
-
-static void FUNC(pred8x16_mad_cow_dc_0l0)(uint8_t *src, ptrdiff_t stride)
-{
- FUNCC(pred8x16_left_dc)(src, stride);
- FUNCC(pred4x4_128_dc)(src , NULL, stride);
- FUNCC(pred4x4_128_dc)(src + 4*sizeof(pixel), NULL, stride);
-}
-
-static void FUNCC(pred8x8_plane)(uint8_t *_src, ptrdiff_t _stride)
-{
- int j, k;
- int a;
- INIT_CLIP
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
- const pixel * const src0 = src +3-stride;
- const pixel * src1 = src +4*stride-1;
- const pixel * src2 = src1-2*stride; // == src+2*stride-1;
- int H = src0[1] - src0[-1];
- int V = src1[0] - src2[ 0];
- for(k=2; k<=4; ++k) {
- src1 += stride; src2 -= stride;
- H += k*(src0[k] - src0[-k]);
- V += k*(src1[0] - src2[ 0]);
- }
- H = ( 17*H+16 ) >> 5;
- V = ( 17*V+16 ) >> 5;
-
- a = 16*(src1[0] + src2[8]+1) - 3*(V+H);
- for(j=8; j>0; --j) {
- int b = a;
- a += V;
- src[0] = CLIP((b ) >> 5);
- src[1] = CLIP((b+ H) >> 5);
- src[2] = CLIP((b+2*H) >> 5);
- src[3] = CLIP((b+3*H) >> 5);
- src[4] = CLIP((b+4*H) >> 5);
- src[5] = CLIP((b+5*H) >> 5);
- src[6] = CLIP((b+6*H) >> 5);
- src[7] = CLIP((b+7*H) >> 5);
- src += stride;
- }
-}
-
-static void FUNCC(pred8x16_plane)(uint8_t *_src, ptrdiff_t _stride)
-{
- int j, k;
- int a;
- INIT_CLIP
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
- const pixel * const src0 = src +3-stride;
- const pixel * src1 = src +8*stride-1;
- const pixel * src2 = src1-2*stride; // == src+6*stride-1;
- int H = src0[1] - src0[-1];
- int V = src1[0] - src2[ 0];
-
- for (k = 2; k <= 4; ++k) {
- src1 += stride; src2 -= stride;
- H += k*(src0[k] - src0[-k]);
- V += k*(src1[0] - src2[ 0]);
- }
- for (; k <= 8; ++k) {
- src1 += stride; src2 -= stride;
- V += k*(src1[0] - src2[0]);
- }
-
- H = (17*H+16) >> 5;
- V = (5*V+32) >> 6;
-
- a = 16*(src1[0] + src2[8] + 1) - 7*V - 3*H;
- for(j=16; j>0; --j) {
- int b = a;
- a += V;
- src[0] = CLIP((b ) >> 5);
- src[1] = CLIP((b+ H) >> 5);
- src[2] = CLIP((b+2*H) >> 5);
- src[3] = CLIP((b+3*H) >> 5);
- src[4] = CLIP((b+4*H) >> 5);
- src[5] = CLIP((b+5*H) >> 5);
- src[6] = CLIP((b+6*H) >> 5);
- src[7] = CLIP((b+7*H) >> 5);
- src += stride;
- }
-}
-
-#define SRC(x,y) src[(x)+(y)*stride]
-#define PL(y) \
- const int l##y = (SRC(-1,y-1) + 2*SRC(-1,y) + SRC(-1,y+1) + 2) >> 2;
-#define PREDICT_8x8_LOAD_LEFT \
- const int l0 = ((has_topleft ? SRC(-1,-1) : SRC(-1,0)) \
- + 2*SRC(-1,0) + SRC(-1,1) + 2) >> 2; \
- PL(1) PL(2) PL(3) PL(4) PL(5) PL(6) \
- const int l7 av_unused = (SRC(-1,6) + 3*SRC(-1,7) + 2) >> 2
-
-#define PT(x) \
- const int t##x = (SRC(x-1,-1) + 2*SRC(x,-1) + SRC(x+1,-1) + 2) >> 2;
-#define PREDICT_8x8_LOAD_TOP \
- const int t0 = ((has_topleft ? SRC(-1,-1) : SRC(0,-1)) \
- + 2*SRC(0,-1) + SRC(1,-1) + 2) >> 2; \
- PT(1) PT(2) PT(3) PT(4) PT(5) PT(6) \
- const int t7 av_unused = ((has_topright ? SRC(8,-1) : SRC(7,-1)) \
- + 2*SRC(7,-1) + SRC(6,-1) + 2) >> 2
-
-#define PTR(x) \
- t##x = (SRC(x-1,-1) + 2*SRC(x,-1) + SRC(x+1,-1) + 2) >> 2;
-#define PREDICT_8x8_LOAD_TOPRIGHT \
- int t8, t9, t10, t11, t12, t13, t14, t15; \
- if(has_topright) { \
- PTR(8) PTR(9) PTR(10) PTR(11) PTR(12) PTR(13) PTR(14) \
- t15 = (SRC(14,-1) + 3*SRC(15,-1) + 2) >> 2; \
- } else t8=t9=t10=t11=t12=t13=t14=t15= SRC(7,-1);
-
-#define PREDICT_8x8_LOAD_TOPLEFT \
- const int lt = (SRC(-1,0) + 2*SRC(-1,-1) + SRC(0,-1) + 2) >> 2
-
-#define PREDICT_8x8_DC(v) \
- int y; \
- for( y = 0; y < 8; y++ ) { \
- AV_WN4PA(((pixel4*)src)+0, v); \
- AV_WN4PA(((pixel4*)src)+1, v); \
- src += stride; \
- }
-
-static void FUNCC(pred8x8l_128_dc)(uint8_t *_src, int has_topleft,
- int has_topright, ptrdiff_t _stride)
-{
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
-
- PREDICT_8x8_DC(PIXEL_SPLAT_X4(1<<(BIT_DEPTH-1)));
-}
-static void FUNCC(pred8x8l_left_dc)(uint8_t *_src, int has_topleft,
- int has_topright, ptrdiff_t _stride)
-{
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
-
- PREDICT_8x8_LOAD_LEFT;
- const pixel4 dc = PIXEL_SPLAT_X4((l0+l1+l2+l3+l4+l5+l6+l7+4) >> 3);
- PREDICT_8x8_DC(dc);
-}
-static void FUNCC(pred8x8l_top_dc)(uint8_t *_src, int has_topleft,
- int has_topright, ptrdiff_t _stride)
-{
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
-
- PREDICT_8x8_LOAD_TOP;
- const pixel4 dc = PIXEL_SPLAT_X4((t0+t1+t2+t3+t4+t5+t6+t7+4) >> 3);
- PREDICT_8x8_DC(dc);
-}
-static void FUNCC(pred8x8l_dc)(uint8_t *_src, int has_topleft,
- int has_topright, ptrdiff_t _stride)
-{
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
-
- PREDICT_8x8_LOAD_LEFT;
- PREDICT_8x8_LOAD_TOP;
- const pixel4 dc = PIXEL_SPLAT_X4((l0+l1+l2+l3+l4+l5+l6+l7
- +t0+t1+t2+t3+t4+t5+t6+t7+8) >> 4);
- PREDICT_8x8_DC(dc);
-}
-static void FUNCC(pred8x8l_horizontal)(uint8_t *_src, int has_topleft,
- int has_topright, ptrdiff_t _stride)
-{
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
- pixel4 a;
-
- PREDICT_8x8_LOAD_LEFT;
-#define ROW(y) a = PIXEL_SPLAT_X4(l##y); \
- AV_WN4PA(src+y*stride, a); \
- AV_WN4PA(src+y*stride+4, a);
- ROW(0); ROW(1); ROW(2); ROW(3); ROW(4); ROW(5); ROW(6); ROW(7);
-#undef ROW
-}
-static void FUNCC(pred8x8l_vertical)(uint8_t *_src, int has_topleft,
- int has_topright, ptrdiff_t _stride)
-{
- int y;
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
- pixel4 a, b;
-
- PREDICT_8x8_LOAD_TOP;
- src[0] = t0;
- src[1] = t1;
- src[2] = t2;
- src[3] = t3;
- src[4] = t4;
- src[5] = t5;
- src[6] = t6;
- src[7] = t7;
- a = AV_RN4PA(((pixel4*)src)+0);
- b = AV_RN4PA(((pixel4*)src)+1);
- for( y = 1; y < 8; y++ ) {
- AV_WN4PA(((pixel4*)(src+y*stride))+0, a);
- AV_WN4PA(((pixel4*)(src+y*stride))+1, b);
- }
-}
-static void FUNCC(pred8x8l_down_left)(uint8_t *_src, int has_topleft,
- int has_topright, ptrdiff_t _stride)
-{
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
- PREDICT_8x8_LOAD_TOP;
- PREDICT_8x8_LOAD_TOPRIGHT;
- SRC(0,0)= (t0 + 2*t1 + t2 + 2) >> 2;
- SRC(0,1)=SRC(1,0)= (t1 + 2*t2 + t3 + 2) >> 2;
- SRC(0,2)=SRC(1,1)=SRC(2,0)= (t2 + 2*t3 + t4 + 2) >> 2;
- SRC(0,3)=SRC(1,2)=SRC(2,1)=SRC(3,0)= (t3 + 2*t4 + t5 + 2) >> 2;
- SRC(0,4)=SRC(1,3)=SRC(2,2)=SRC(3,1)=SRC(4,0)= (t4 + 2*t5 + t6 + 2) >> 2;
- SRC(0,5)=SRC(1,4)=SRC(2,3)=SRC(3,2)=SRC(4,1)=SRC(5,0)= (t5 + 2*t6 + t7 + 2) >> 2;
- SRC(0,6)=SRC(1,5)=SRC(2,4)=SRC(3,3)=SRC(4,2)=SRC(5,1)=SRC(6,0)= (t6 + 2*t7 + t8 + 2) >> 2;
- SRC(0,7)=SRC(1,6)=SRC(2,5)=SRC(3,4)=SRC(4,3)=SRC(5,2)=SRC(6,1)=SRC(7,0)= (t7 + 2*t8 + t9 + 2) >> 2;
- SRC(1,7)=SRC(2,6)=SRC(3,5)=SRC(4,4)=SRC(5,3)=SRC(6,2)=SRC(7,1)= (t8 + 2*t9 + t10 + 2) >> 2;
- SRC(2,7)=SRC(3,6)=SRC(4,5)=SRC(5,4)=SRC(6,3)=SRC(7,2)= (t9 + 2*t10 + t11 + 2) >> 2;
- SRC(3,7)=SRC(4,6)=SRC(5,5)=SRC(6,4)=SRC(7,3)= (t10 + 2*t11 + t12 + 2) >> 2;
- SRC(4,7)=SRC(5,6)=SRC(6,5)=SRC(7,4)= (t11 + 2*t12 + t13 + 2) >> 2;
- SRC(5,7)=SRC(6,6)=SRC(7,5)= (t12 + 2*t13 + t14 + 2) >> 2;
- SRC(6,7)=SRC(7,6)= (t13 + 2*t14 + t15 + 2) >> 2;
- SRC(7,7)= (t14 + 3*t15 + 2) >> 2;
-}
-static void FUNCC(pred8x8l_down_right)(uint8_t *_src, int has_topleft,
- int has_topright, ptrdiff_t _stride)
-{
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
- PREDICT_8x8_LOAD_TOP;
- PREDICT_8x8_LOAD_LEFT;
- PREDICT_8x8_LOAD_TOPLEFT;
- SRC(0,7)= (l7 + 2*l6 + l5 + 2) >> 2;
- SRC(0,6)=SRC(1,7)= (l6 + 2*l5 + l4 + 2) >> 2;
- SRC(0,5)=SRC(1,6)=SRC(2,7)= (l5 + 2*l4 + l3 + 2) >> 2;
- SRC(0,4)=SRC(1,5)=SRC(2,6)=SRC(3,7)= (l4 + 2*l3 + l2 + 2) >> 2;
- SRC(0,3)=SRC(1,4)=SRC(2,5)=SRC(3,6)=SRC(4,7)= (l3 + 2*l2 + l1 + 2) >> 2;
- SRC(0,2)=SRC(1,3)=SRC(2,4)=SRC(3,5)=SRC(4,6)=SRC(5,7)= (l2 + 2*l1 + l0 + 2) >> 2;
- SRC(0,1)=SRC(1,2)=SRC(2,3)=SRC(3,4)=SRC(4,5)=SRC(5,6)=SRC(6,7)= (l1 + 2*l0 + lt + 2) >> 2;
- SRC(0,0)=SRC(1,1)=SRC(2,2)=SRC(3,3)=SRC(4,4)=SRC(5,5)=SRC(6,6)=SRC(7,7)= (l0 + 2*lt + t0 + 2) >> 2;
- SRC(1,0)=SRC(2,1)=SRC(3,2)=SRC(4,3)=SRC(5,4)=SRC(6,5)=SRC(7,6)= (lt + 2*t0 + t1 + 2) >> 2;
- SRC(2,0)=SRC(3,1)=SRC(4,2)=SRC(5,3)=SRC(6,4)=SRC(7,5)= (t0 + 2*t1 + t2 + 2) >> 2;
- SRC(3,0)=SRC(4,1)=SRC(5,2)=SRC(6,3)=SRC(7,4)= (t1 + 2*t2 + t3 + 2) >> 2;
- SRC(4,0)=SRC(5,1)=SRC(6,2)=SRC(7,3)= (t2 + 2*t3 + t4 + 2) >> 2;
- SRC(5,0)=SRC(6,1)=SRC(7,2)= (t3 + 2*t4 + t5 + 2) >> 2;
- SRC(6,0)=SRC(7,1)= (t4 + 2*t5 + t6 + 2) >> 2;
- SRC(7,0)= (t5 + 2*t6 + t7 + 2) >> 2;
-}
-static void FUNCC(pred8x8l_vertical_right)(uint8_t *_src, int has_topleft,
- int has_topright, ptrdiff_t _stride)
-{
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
- PREDICT_8x8_LOAD_TOP;
- PREDICT_8x8_LOAD_LEFT;
- PREDICT_8x8_LOAD_TOPLEFT;
- SRC(0,6)= (l5 + 2*l4 + l3 + 2) >> 2;
- SRC(0,7)= (l6 + 2*l5 + l4 + 2) >> 2;
- SRC(0,4)=SRC(1,6)= (l3 + 2*l2 + l1 + 2) >> 2;
- SRC(0,5)=SRC(1,7)= (l4 + 2*l3 + l2 + 2) >> 2;
- SRC(0,2)=SRC(1,4)=SRC(2,6)= (l1 + 2*l0 + lt + 2) >> 2;
- SRC(0,3)=SRC(1,5)=SRC(2,7)= (l2 + 2*l1 + l0 + 2) >> 2;
- SRC(0,1)=SRC(1,3)=SRC(2,5)=SRC(3,7)= (l0 + 2*lt + t0 + 2) >> 2;
- SRC(0,0)=SRC(1,2)=SRC(2,4)=SRC(3,6)= (lt + t0 + 1) >> 1;
- SRC(1,1)=SRC(2,3)=SRC(3,5)=SRC(4,7)= (lt + 2*t0 + t1 + 2) >> 2;
- SRC(1,0)=SRC(2,2)=SRC(3,4)=SRC(4,6)= (t0 + t1 + 1) >> 1;
- SRC(2,1)=SRC(3,3)=SRC(4,5)=SRC(5,7)= (t0 + 2*t1 + t2 + 2) >> 2;
- SRC(2,0)=SRC(3,2)=SRC(4,4)=SRC(5,6)= (t1 + t2 + 1) >> 1;
- SRC(3,1)=SRC(4,3)=SRC(5,5)=SRC(6,7)= (t1 + 2*t2 + t3 + 2) >> 2;
- SRC(3,0)=SRC(4,2)=SRC(5,4)=SRC(6,6)= (t2 + t3 + 1) >> 1;
- SRC(4,1)=SRC(5,3)=SRC(6,5)=SRC(7,7)= (t2 + 2*t3 + t4 + 2) >> 2;
- SRC(4,0)=SRC(5,2)=SRC(6,4)=SRC(7,6)= (t3 + t4 + 1) >> 1;
- SRC(5,1)=SRC(6,3)=SRC(7,5)= (t3 + 2*t4 + t5 + 2) >> 2;
- SRC(5,0)=SRC(6,2)=SRC(7,4)= (t4 + t5 + 1) >> 1;
- SRC(6,1)=SRC(7,3)= (t4 + 2*t5 + t6 + 2) >> 2;
- SRC(6,0)=SRC(7,2)= (t5 + t6 + 1) >> 1;
- SRC(7,1)= (t5 + 2*t6 + t7 + 2) >> 2;
- SRC(7,0)= (t6 + t7 + 1) >> 1;
-}
-static void FUNCC(pred8x8l_horizontal_down)(uint8_t *_src, int has_topleft,
- int has_topright, ptrdiff_t _stride)
-{
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
- PREDICT_8x8_LOAD_TOP;
- PREDICT_8x8_LOAD_LEFT;
- PREDICT_8x8_LOAD_TOPLEFT;
- SRC(0,7)= (l6 + l7 + 1) >> 1;
- SRC(1,7)= (l5 + 2*l6 + l7 + 2) >> 2;
- SRC(0,6)=SRC(2,7)= (l5 + l6 + 1) >> 1;
- SRC(1,6)=SRC(3,7)= (l4 + 2*l5 + l6 + 2) >> 2;
- SRC(0,5)=SRC(2,6)=SRC(4,7)= (l4 + l5 + 1) >> 1;
- SRC(1,5)=SRC(3,6)=SRC(5,7)= (l3 + 2*l4 + l5 + 2) >> 2;
- SRC(0,4)=SRC(2,5)=SRC(4,6)=SRC(6,7)= (l3 + l4 + 1) >> 1;
- SRC(1,4)=SRC(3,5)=SRC(5,6)=SRC(7,7)= (l2 + 2*l3 + l4 + 2) >> 2;
- SRC(0,3)=SRC(2,4)=SRC(4,5)=SRC(6,6)= (l2 + l3 + 1) >> 1;
- SRC(1,3)=SRC(3,4)=SRC(5,5)=SRC(7,6)= (l1 + 2*l2 + l3 + 2) >> 2;
- SRC(0,2)=SRC(2,3)=SRC(4,4)=SRC(6,5)= (l1 + l2 + 1) >> 1;
- SRC(1,2)=SRC(3,3)=SRC(5,4)=SRC(7,5)= (l0 + 2*l1 + l2 + 2) >> 2;
- SRC(0,1)=SRC(2,2)=SRC(4,3)=SRC(6,4)= (l0 + l1 + 1) >> 1;
- SRC(1,1)=SRC(3,2)=SRC(5,3)=SRC(7,4)= (lt + 2*l0 + l1 + 2) >> 2;
- SRC(0,0)=SRC(2,1)=SRC(4,2)=SRC(6,3)= (lt + l0 + 1) >> 1;
- SRC(1,0)=SRC(3,1)=SRC(5,2)=SRC(7,3)= (l0 + 2*lt + t0 + 2) >> 2;
- SRC(2,0)=SRC(4,1)=SRC(6,2)= (t1 + 2*t0 + lt + 2) >> 2;
- SRC(3,0)=SRC(5,1)=SRC(7,2)= (t2 + 2*t1 + t0 + 2) >> 2;
- SRC(4,0)=SRC(6,1)= (t3 + 2*t2 + t1 + 2) >> 2;
- SRC(5,0)=SRC(7,1)= (t4 + 2*t3 + t2 + 2) >> 2;
- SRC(6,0)= (t5 + 2*t4 + t3 + 2) >> 2;
- SRC(7,0)= (t6 + 2*t5 + t4 + 2) >> 2;
-}
-static void FUNCC(pred8x8l_vertical_left)(uint8_t *_src, int has_topleft,
- int has_topright, ptrdiff_t _stride)
-{
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
- PREDICT_8x8_LOAD_TOP;
- PREDICT_8x8_LOAD_TOPRIGHT;
- SRC(0,0)= (t0 + t1 + 1) >> 1;
- SRC(0,1)= (t0 + 2*t1 + t2 + 2) >> 2;
- SRC(0,2)=SRC(1,0)= (t1 + t2 + 1) >> 1;
- SRC(0,3)=SRC(1,1)= (t1 + 2*t2 + t3 + 2) >> 2;
- SRC(0,4)=SRC(1,2)=SRC(2,0)= (t2 + t3 + 1) >> 1;
- SRC(0,5)=SRC(1,3)=SRC(2,1)= (t2 + 2*t3 + t4 + 2) >> 2;
- SRC(0,6)=SRC(1,4)=SRC(2,2)=SRC(3,0)= (t3 + t4 + 1) >> 1;
- SRC(0,7)=SRC(1,5)=SRC(2,3)=SRC(3,1)= (t3 + 2*t4 + t5 + 2) >> 2;
- SRC(1,6)=SRC(2,4)=SRC(3,2)=SRC(4,0)= (t4 + t5 + 1) >> 1;
- SRC(1,7)=SRC(2,5)=SRC(3,3)=SRC(4,1)= (t4 + 2*t5 + t6 + 2) >> 2;
- SRC(2,6)=SRC(3,4)=SRC(4,2)=SRC(5,0)= (t5 + t6 + 1) >> 1;
- SRC(2,7)=SRC(3,5)=SRC(4,3)=SRC(5,1)= (t5 + 2*t6 + t7 + 2) >> 2;
- SRC(3,6)=SRC(4,4)=SRC(5,2)=SRC(6,0)= (t6 + t7 + 1) >> 1;
- SRC(3,7)=SRC(4,5)=SRC(5,3)=SRC(6,1)= (t6 + 2*t7 + t8 + 2) >> 2;
- SRC(4,6)=SRC(5,4)=SRC(6,2)=SRC(7,0)= (t7 + t8 + 1) >> 1;
- SRC(4,7)=SRC(5,5)=SRC(6,3)=SRC(7,1)= (t7 + 2*t8 + t9 + 2) >> 2;
- SRC(5,6)=SRC(6,4)=SRC(7,2)= (t8 + t9 + 1) >> 1;
- SRC(5,7)=SRC(6,5)=SRC(7,3)= (t8 + 2*t9 + t10 + 2) >> 2;
- SRC(6,6)=SRC(7,4)= (t9 + t10 + 1) >> 1;
- SRC(6,7)=SRC(7,5)= (t9 + 2*t10 + t11 + 2) >> 2;
- SRC(7,6)= (t10 + t11 + 1) >> 1;
- SRC(7,7)= (t10 + 2*t11 + t12 + 2) >> 2;
-}
-static void FUNCC(pred8x8l_horizontal_up)(uint8_t *_src, int has_topleft,
- int has_topright, ptrdiff_t _stride)
-{
- pixel *src = (pixel*)_src;
- int stride = _stride>>(sizeof(pixel)-1);
- PREDICT_8x8_LOAD_LEFT;
- SRC(0,0)= (l0 + l1 + 1) >> 1;
- SRC(1,0)= (l0 + 2*l1 + l2 + 2) >> 2;
- SRC(0,1)=SRC(2,0)= (l1 + l2 + 1) >> 1;
- SRC(1,1)=SRC(3,0)= (l1 + 2*l2 + l3 + 2) >> 2;
- SRC(0,2)=SRC(2,1)=SRC(4,0)= (l2 + l3 + 1) >> 1;
- SRC(1,2)=SRC(3,1)=SRC(5,0)= (l2 + 2*l3 + l4 + 2) >> 2;
- SRC(0,3)=SRC(2,2)=SRC(4,1)=SRC(6,0)= (l3 + l4 + 1) >> 1;
- SRC(1,3)=SRC(3,2)=SRC(5,1)=SRC(7,0)= (l3 + 2*l4 + l5 + 2) >> 2;
- SRC(0,4)=SRC(2,3)=SRC(4,2)=SRC(6,1)= (l4 + l5 + 1) >> 1;
- SRC(1,4)=SRC(3,3)=SRC(5,2)=SRC(7,1)= (l4 + 2*l5 + l6 + 2) >> 2;
- SRC(0,5)=SRC(2,4)=SRC(4,3)=SRC(6,2)= (l5 + l6 + 1) >> 1;
- SRC(1,5)=SRC(3,4)=SRC(5,3)=SRC(7,2)= (l5 + 2*l6 + l7 + 2) >> 2;
- SRC(0,6)=SRC(2,5)=SRC(4,4)=SRC(6,3)= (l6 + l7 + 1) >> 1;
- SRC(1,6)=SRC(3,5)=SRC(5,4)=SRC(7,3)= (l6 + 3*l7 + 2) >> 2;
- SRC(0,7)=SRC(1,7)=SRC(2,6)=SRC(2,7)=SRC(3,6)=
- SRC(3,7)=SRC(4,5)=SRC(4,6)=SRC(4,7)=SRC(5,5)=
- 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;
-}
-#undef PREDICT_8x8_LOAD_LEFT
-#undef PREDICT_8x8_LOAD_TOP
-#undef PREDICT_8x8_LOAD_TOPLEFT
-#undef PREDICT_8x8_LOAD_TOPRIGHT
-#undef PREDICT_8x8_DC
-#undef PTR
-#undef PT
-#undef PL
-#undef SRC
-
-static void FUNCC(pred4x4_vertical_add)(uint8_t *_pix, const int16_t *_block,
- ptrdiff_t stride)
-{
- int i;
- pixel *pix = (pixel*)_pix;
- const dctcoef *block = (const dctcoef*)_block;
- stride >>= sizeof(pixel)-1;
- pix -= stride;
- for(i=0; i<4; i++){
- pixel v = pix[0];
- pix[1*stride]= v += block[0];
- pix[2*stride]= v += block[4];
- pix[3*stride]= v += block[8];
- pix[4*stride]= v + block[12];
- pix++;
- block++;
- }
-}
-
-static void FUNCC(pred4x4_horizontal_add)(uint8_t *_pix, const int16_t *_block,
- ptrdiff_t stride)
-{
- int i;
- pixel *pix = (pixel*)_pix;
- const dctcoef *block = (const dctcoef*)_block;
- stride >>= sizeof(pixel)-1;
- for(i=0; i<4; i++){
- pixel v = pix[-1];
- pix[0]= v += block[0];
- pix[1]= v += block[1];
- pix[2]= v += block[2];
- pix[3]= v + block[3];
- pix+= stride;
- block+= 4;
- }
-}
-
-static void FUNCC(pred8x8l_vertical_add)(uint8_t *_pix, const int16_t *_block,
- ptrdiff_t stride)
-{
- int i;
- pixel *pix = (pixel*)_pix;
- const dctcoef *block = (const dctcoef*)_block;
- stride >>= sizeof(pixel)-1;
- pix -= stride;
- for(i=0; i<8; i++){
- pixel v = pix[0];
- pix[1*stride]= v += block[0];
- pix[2*stride]= v += block[8];
- pix[3*stride]= v += block[16];
- pix[4*stride]= v += block[24];
- pix[5*stride]= v += block[32];
- pix[6*stride]= v += block[40];
- pix[7*stride]= v += block[48];
- pix[8*stride]= v + block[56];
- pix++;
- block++;
- }
-}
-
-static void FUNCC(pred8x8l_horizontal_add)(uint8_t *_pix, const int16_t *_block,
- ptrdiff_t stride)
-{
- int i;
- pixel *pix = (pixel*)_pix;
- const dctcoef *block = (const dctcoef*)_block;
- stride >>= sizeof(pixel)-1;
- for(i=0; i<8; i++){
- pixel v = pix[-1];
- pix[0]= v += block[0];
- pix[1]= v += block[1];
- pix[2]= v += block[2];
- pix[3]= v += block[3];
- pix[4]= v += block[4];
- pix[5]= v += block[5];
- pix[6]= v += block[6];
- pix[7]= v + block[7];
- pix+= stride;
- block+= 8;
- }
-}
-
-static void FUNCC(pred16x16_vertical_add)(uint8_t *pix, const int *block_offset,
- const int16_t *block,
- ptrdiff_t stride)
-{
- int i;
- for(i=0; i<16; i++)
- FUNCC(pred4x4_vertical_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride);
-}
-
-static void FUNCC(pred16x16_horizontal_add)(uint8_t *pix,
- const int *block_offset,
- const int16_t *block,
- ptrdiff_t stride)
-{
- int i;
- for(i=0; i<16; i++)
- FUNCC(pred4x4_horizontal_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride);
-}
-
-static void FUNCC(pred8x8_vertical_add)(uint8_t *pix, const int *block_offset,
- const int16_t *block, ptrdiff_t stride)
-{
- int i;
- for(i=0; i<4; i++)
- FUNCC(pred4x4_vertical_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride);
-}
-
-static void FUNCC(pred8x16_vertical_add)(uint8_t *pix, const int *block_offset,
- const int16_t *block, ptrdiff_t stride)
-{
- int i;
- for(i=0; i<4; i++)
- FUNCC(pred4x4_vertical_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride);
- for(i=4; i<8; i++)
- FUNCC(pred4x4_vertical_add)(pix + block_offset[i+4], block + i*16*sizeof(pixel), stride);
-}
-
-static void FUNCC(pred8x8_horizontal_add)(uint8_t *pix, const int *block_offset,
- const int16_t *block,
- ptrdiff_t stride)
-{
- int i;
- for(i=0; i<4; i++)
- FUNCC(pred4x4_horizontal_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride);
-}
-
-static void FUNCC(pred8x16_horizontal_add)(uint8_t *pix,
- const int *block_offset,
- const int16_t *block, ptrdiff_t stride)
-{
- int i;
- for(i=0; i<4; i++)
- FUNCC(pred4x4_horizontal_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride);
- for(i=4; i<8; i++)
- FUNCC(pred4x4_horizontal_add)(pix + block_offset[i+4], block + i*16*sizeof(pixel), stride);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264qpel.c b/src/thirdparty/ffmpeg/libavcodec/h264qpel.c
deleted file mode 100644
index f46da8f6c..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264qpel.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
- * 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
- */
-
-#include "h264qpel.h"
-
-#define pixeltmp int16_t
-#define BIT_DEPTH 8
-#include "h264qpel_template.c"
-#undef BIT_DEPTH
-
-#define BIT_DEPTH 9
-#include "h264qpel_template.c"
-#undef BIT_DEPTH
-
-#define BIT_DEPTH 10
-#include "h264qpel_template.c"
-#undef BIT_DEPTH
-#undef pixeltmp
-
-#define pixeltmp int32_t
-#define BIT_DEPTH 12
-#include "h264qpel_template.c"
-#undef BIT_DEPTH
-
-#define BIT_DEPTH 14
-#include "h264qpel_template.c"
-#undef BIT_DEPTH
-
-
-void ff_h264qpel_init(H264QpelContext *c, int bit_depth)
-{
-#undef FUNCC
-#define FUNCC(f, depth) f ## _ ## depth ## _c
-
-#define dspfunc2(PFX, IDX, NUM, depth) \
- c->PFX ## _pixels_tab[IDX][ 0] = FUNCC(PFX ## NUM ## _mc00, depth); \
- c->PFX ## _pixels_tab[IDX][ 1] = FUNCC(PFX ## NUM ## _mc10, depth); \
- c->PFX ## _pixels_tab[IDX][ 2] = FUNCC(PFX ## NUM ## _mc20, depth); \
- c->PFX ## _pixels_tab[IDX][ 3] = FUNCC(PFX ## NUM ## _mc30, depth); \
- c->PFX ## _pixels_tab[IDX][ 4] = FUNCC(PFX ## NUM ## _mc01, depth); \
- c->PFX ## _pixels_tab[IDX][ 5] = FUNCC(PFX ## NUM ## _mc11, depth); \
- c->PFX ## _pixels_tab[IDX][ 6] = FUNCC(PFX ## NUM ## _mc21, depth); \
- c->PFX ## _pixels_tab[IDX][ 7] = FUNCC(PFX ## NUM ## _mc31, depth); \
- c->PFX ## _pixels_tab[IDX][ 8] = FUNCC(PFX ## NUM ## _mc02, depth); \
- c->PFX ## _pixels_tab[IDX][ 9] = FUNCC(PFX ## NUM ## _mc12, depth); \
- c->PFX ## _pixels_tab[IDX][10] = FUNCC(PFX ## NUM ## _mc22, depth); \
- c->PFX ## _pixels_tab[IDX][11] = FUNCC(PFX ## NUM ## _mc32, depth); \
- c->PFX ## _pixels_tab[IDX][12] = FUNCC(PFX ## NUM ## _mc03, depth); \
- c->PFX ## _pixels_tab[IDX][13] = FUNCC(PFX ## NUM ## _mc13, depth); \
- c->PFX ## _pixels_tab[IDX][14] = FUNCC(PFX ## NUM ## _mc23, depth); \
- c->PFX ## _pixels_tab[IDX][15] = FUNCC(PFX ## NUM ## _mc33, depth)
-
-#define SET_QPEL(depth) \
- dspfunc2(put_h264_qpel, 0, 16, depth); \
- dspfunc2(put_h264_qpel, 1, 8, depth); \
- dspfunc2(put_h264_qpel, 2, 4, depth); \
- dspfunc2(put_h264_qpel, 3, 2, depth); \
- dspfunc2(avg_h264_qpel, 0, 16, depth); \
- dspfunc2(avg_h264_qpel, 1, 8, depth); \
- dspfunc2(avg_h264_qpel, 2, 4, depth)
-
- switch (bit_depth) {
- default:
- SET_QPEL(8);
- break;
- case 9:
- SET_QPEL(9);
- break;
- case 10:
- SET_QPEL(10);
- break;
- case 12:
- SET_QPEL(12);
- break;
- case 14:
- SET_QPEL(14);
- break;
- }
-
- if (ARCH_ARM)
- ff_h264qpel_init_arm(c, bit_depth);
- if (ARCH_PPC)
- ff_h264qpel_init_ppc(c, bit_depth);
- if (ARCH_X86)
- ff_h264qpel_init_x86(c, bit_depth);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264qpel.h b/src/thirdparty/ffmpeg/libavcodec/h264qpel.h
deleted file mode 100644
index 6abfac042..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264qpel.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
- * 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
- */
-
-#ifndef AVCODEC_H264QPEL_H
-#define AVCODEC_H264QPEL_H
-
-#include "dsputil.h"
-
-typedef struct H264QpelContext {
- qpel_mc_func put_h264_qpel_pixels_tab[4][16];
- qpel_mc_func avg_h264_qpel_pixels_tab[4][16];
-} H264QpelContext;
-
-void ff_h264qpel_init(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);
-
-#endif /* AVCODEC_H264QPEL_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/h264qpel_template.c b/src/thirdparty/ffmpeg/libavcodec/h264qpel_template.c
deleted file mode 100644
index 95950f44d..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/h264qpel_template.c
+++ /dev/null
@@ -1,560 +0,0 @@
-/*
- * H.26L/H.264/AVC/JVT/14496-10/... encoder/decoder
- * 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
- */
-
-#include "libavutil/common.h"
-#include "bit_depth_template.c"
-#include "hpel_template.c"
-
-static inline void FUNC(copy_block2)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
-{
- int i;
- for(i=0; i<h; i++)
- {
- AV_WN2P(dst , AV_RN2P(src ));
- dst+=dstStride;
- src+=srcStride;
- }
-}
-
-static inline void FUNC(copy_block4)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
-{
- int i;
- for(i=0; i<h; i++)
- {
- AV_WN4P(dst , AV_RN4P(src ));
- dst+=dstStride;
- src+=srcStride;
- }
-}
-
-static inline void FUNC(copy_block8)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
-{
- int i;
- for(i=0; i<h; i++)
- {
- AV_WN4P(dst , AV_RN4P(src ));
- AV_WN4P(dst+4*sizeof(pixel), AV_RN4P(src+4*sizeof(pixel)));
- dst+=dstStride;
- src+=srcStride;
- }
-}
-
-static inline void FUNC(copy_block16)(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
-{
- int i;
- for(i=0; i<h; i++)
- {
- AV_WN4P(dst , AV_RN4P(src ));
- AV_WN4P(dst+ 4*sizeof(pixel), AV_RN4P(src+ 4*sizeof(pixel)));
- AV_WN4P(dst+ 8*sizeof(pixel), AV_RN4P(src+ 8*sizeof(pixel)));
- AV_WN4P(dst+12*sizeof(pixel), AV_RN4P(src+12*sizeof(pixel)));
- dst+=dstStride;
- src+=srcStride;
- }
-}
-
-#define H264_LOWPASS(OPNAME, OP, OP2) \
-static av_unused void FUNC(OPNAME ## h264_qpel2_h_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
- const int h=2;\
- INIT_CLIP\
- int i;\
- pixel *dst = (pixel*)p_dst;\
- pixel *src = (pixel*)p_src;\
- dstStride >>= sizeof(pixel)-1;\
- srcStride >>= sizeof(pixel)-1;\
- for(i=0; i<h; i++)\
- {\
- OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]));\
- OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]));\
- dst+=dstStride;\
- src+=srcStride;\
- }\
-}\
-\
-static av_unused void FUNC(OPNAME ## h264_qpel2_v_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
- const int w=2;\
- INIT_CLIP\
- int i;\
- pixel *dst = (pixel*)p_dst;\
- pixel *src = (pixel*)p_src;\
- dstStride >>= sizeof(pixel)-1;\
- srcStride >>= sizeof(pixel)-1;\
- for(i=0; i<w; i++)\
- {\
- const int srcB= src[-2*srcStride];\
- const int srcA= src[-1*srcStride];\
- 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];\
- OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
- OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
- dst++;\
- src++;\
- }\
-}\
-\
-static av_unused void FUNC(OPNAME ## h264_qpel2_hv_lowpass)(uint8_t *p_dst, pixeltmp *tmp, uint8_t *p_src, int dstStride, int tmpStride, int srcStride){\
- const int h=2;\
- const int w=2;\
- const int pad = (BIT_DEPTH == 10) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\
- INIT_CLIP\
- int i;\
- pixel *dst = (pixel*)p_dst;\
- pixel *src = (pixel*)p_src;\
- dstStride >>= sizeof(pixel)-1;\
- srcStride >>= sizeof(pixel)-1;\
- src -= 2*srcStride;\
- for(i=0; i<h+5; i++)\
- {\
- tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]) + pad;\
- tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]) + pad;\
- tmp+=tmpStride;\
- src+=srcStride;\
- }\
- tmp -= tmpStride*(h+5-2);\
- for(i=0; i<w; i++)\
- {\
- const int tmpB= tmp[-2*tmpStride] - pad;\
- const int tmpA= tmp[-1*tmpStride] - pad;\
- const int tmp0= tmp[0 *tmpStride] - pad;\
- const int tmp1= tmp[1 *tmpStride] - pad;\
- const int tmp2= tmp[2 *tmpStride] - pad;\
- const int tmp3= tmp[3 *tmpStride] - pad;\
- const int tmp4= tmp[4 *tmpStride] - pad;\
- OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
- OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
- dst++;\
- tmp++;\
- }\
-}\
-static void FUNC(OPNAME ## h264_qpel4_h_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
- const int h=4;\
- INIT_CLIP\
- int i;\
- pixel *dst = (pixel*)p_dst;\
- pixel *src = (pixel*)p_src;\
- dstStride >>= sizeof(pixel)-1;\
- srcStride >>= sizeof(pixel)-1;\
- for(i=0; i<h; i++)\
- {\
- OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]));\
- OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]));\
- OP(dst[2], (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5]));\
- OP(dst[3], (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6]));\
- dst+=dstStride;\
- src+=srcStride;\
- }\
-}\
-\
-static void FUNC(OPNAME ## h264_qpel4_v_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
- const int w=4;\
- INIT_CLIP\
- int i;\
- pixel *dst = (pixel*)p_dst;\
- pixel *src = (pixel*)p_src;\
- dstStride >>= sizeof(pixel)-1;\
- srcStride >>= sizeof(pixel)-1;\
- for(i=0; i<w; i++)\
- {\
- const int srcB= src[-2*srcStride];\
- const int srcA= src[-1*srcStride];\
- 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];\
- OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
- OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
- OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\
- OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\
- dst++;\
- src++;\
- }\
-}\
-\
-static void FUNC(OPNAME ## h264_qpel4_hv_lowpass)(uint8_t *p_dst, pixeltmp *tmp, uint8_t *p_src, int dstStride, int tmpStride, int srcStride){\
- const int h=4;\
- const int w=4;\
- const int pad = (BIT_DEPTH == 10) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\
- INIT_CLIP\
- int i;\
- pixel *dst = (pixel*)p_dst;\
- pixel *src = (pixel*)p_src;\
- dstStride >>= sizeof(pixel)-1;\
- srcStride >>= sizeof(pixel)-1;\
- src -= 2*srcStride;\
- for(i=0; i<h+5; i++)\
- {\
- tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]) + pad;\
- tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]) + pad;\
- tmp[2]= (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5]) + pad;\
- tmp[3]= (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6]) + pad;\
- tmp+=tmpStride;\
- src+=srcStride;\
- }\
- tmp -= tmpStride*(h+5-2);\
- for(i=0; i<w; i++)\
- {\
- const int tmpB= tmp[-2*tmpStride] - pad;\
- const int tmpA= tmp[-1*tmpStride] - pad;\
- const int tmp0= tmp[0 *tmpStride] - pad;\
- const int tmp1= tmp[1 *tmpStride] - pad;\
- const int tmp2= tmp[2 *tmpStride] - pad;\
- const int tmp3= tmp[3 *tmpStride] - pad;\
- const int tmp4= tmp[4 *tmpStride] - pad;\
- const int tmp5= tmp[5 *tmpStride] - pad;\
- const int tmp6= tmp[6 *tmpStride] - pad;\
- OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
- OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
- OP2(dst[2*dstStride], (tmp2+tmp3)*20 - (tmp1+tmp4)*5 + (tmp0+tmp5));\
- OP2(dst[3*dstStride], (tmp3+tmp4)*20 - (tmp2+tmp5)*5 + (tmp1+tmp6));\
- dst++;\
- tmp++;\
- }\
-}\
-\
-static void FUNC(OPNAME ## h264_qpel8_h_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
- const int h=8;\
- INIT_CLIP\
- int i;\
- pixel *dst = (pixel*)p_dst;\
- pixel *src = (pixel*)p_src;\
- dstStride >>= sizeof(pixel)-1;\
- srcStride >>= sizeof(pixel)-1;\
- for(i=0; i<h; i++)\
- {\
- OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3 ]));\
- OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4 ]));\
- OP(dst[2], (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5 ]));\
- OP(dst[3], (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6 ]));\
- OP(dst[4], (src[4]+src[5])*20 - (src[3 ]+src[6])*5 + (src[2 ]+src[7 ]));\
- OP(dst[5], (src[5]+src[6])*20 - (src[4 ]+src[7])*5 + (src[3 ]+src[8 ]));\
- OP(dst[6], (src[6]+src[7])*20 - (src[5 ]+src[8])*5 + (src[4 ]+src[9 ]));\
- OP(dst[7], (src[7]+src[8])*20 - (src[6 ]+src[9])*5 + (src[5 ]+src[10]));\
- dst+=dstStride;\
- src+=srcStride;\
- }\
-}\
-\
-static void FUNC(OPNAME ## h264_qpel8_v_lowpass)(uint8_t *p_dst, uint8_t *p_src, int dstStride, int srcStride){\
- const int w=8;\
- INIT_CLIP\
- int i;\
- pixel *dst = (pixel*)p_dst;\
- pixel *src = (pixel*)p_src;\
- dstStride >>= sizeof(pixel)-1;\
- srcStride >>= sizeof(pixel)-1;\
- for(i=0; i<w; i++)\
- {\
- const int srcB= src[-2*srcStride];\
- const int srcA= src[-1*srcStride];\
- 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];\
- OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
- OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
- OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\
- OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\
- OP(dst[4*dstStride], (src4+src5)*20 - (src3+src6)*5 + (src2+src7));\
- OP(dst[5*dstStride], (src5+src6)*20 - (src4+src7)*5 + (src3+src8));\
- OP(dst[6*dstStride], (src6+src7)*20 - (src5+src8)*5 + (src4+src9));\
- OP(dst[7*dstStride], (src7+src8)*20 - (src6+src9)*5 + (src5+src10));\
- dst++;\
- src++;\
- }\
-}\
-\
-static void FUNC(OPNAME ## h264_qpel8_hv_lowpass)(uint8_t *p_dst, pixeltmp *tmp, uint8_t *p_src, int dstStride, int tmpStride, int srcStride){\
- const int h=8;\
- const int w=8;\
- const int pad = (BIT_DEPTH == 10) ? (-10 * ((1<<BIT_DEPTH)-1)) : 0;\
- INIT_CLIP\
- int i;\
- pixel *dst = (pixel*)p_dst;\
- pixel *src = (pixel*)p_src;\
- dstStride >>= sizeof(pixel)-1;\
- srcStride >>= sizeof(pixel)-1;\
- src -= 2*srcStride;\
- for(i=0; i<h+5; i++)\
- {\
- tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3 ]) + pad;\
- tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4 ]) + pad;\
- tmp[2]= (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5 ]) + pad;\
- tmp[3]= (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6 ]) + pad;\
- tmp[4]= (src[4]+src[5])*20 - (src[3 ]+src[6])*5 + (src[2 ]+src[7 ]) + pad;\
- tmp[5]= (src[5]+src[6])*20 - (src[4 ]+src[7])*5 + (src[3 ]+src[8 ]) + pad;\
- tmp[6]= (src[6]+src[7])*20 - (src[5 ]+src[8])*5 + (src[4 ]+src[9 ]) + pad;\
- tmp[7]= (src[7]+src[8])*20 - (src[6 ]+src[9])*5 + (src[5 ]+src[10]) + pad;\
- tmp+=tmpStride;\
- src+=srcStride;\
- }\
- tmp -= tmpStride*(h+5-2);\
- for(i=0; i<w; i++)\
- {\
- const int tmpB= tmp[-2*tmpStride] - pad;\
- const int tmpA= tmp[-1*tmpStride] - pad;\
- const int tmp0= tmp[0 *tmpStride] - pad;\
- const int tmp1= tmp[1 *tmpStride] - pad;\
- const int tmp2= tmp[2 *tmpStride] - pad;\
- const int tmp3= tmp[3 *tmpStride] - pad;\
- const int tmp4= tmp[4 *tmpStride] - pad;\
- const int tmp5= tmp[5 *tmpStride] - pad;\
- const int tmp6= tmp[6 *tmpStride] - pad;\
- const int tmp7= tmp[7 *tmpStride] - pad;\
- const int tmp8= tmp[8 *tmpStride] - pad;\
- const int tmp9= tmp[9 *tmpStride] - pad;\
- const int tmp10=tmp[10*tmpStride] - pad;\
- OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
- OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
- OP2(dst[2*dstStride], (tmp2+tmp3)*20 - (tmp1+tmp4)*5 + (tmp0+tmp5));\
- OP2(dst[3*dstStride], (tmp3+tmp4)*20 - (tmp2+tmp5)*5 + (tmp1+tmp6));\
- OP2(dst[4*dstStride], (tmp4+tmp5)*20 - (tmp3+tmp6)*5 + (tmp2+tmp7));\
- OP2(dst[5*dstStride], (tmp5+tmp6)*20 - (tmp4+tmp7)*5 + (tmp3+tmp8));\
- OP2(dst[6*dstStride], (tmp6+tmp7)*20 - (tmp5+tmp8)*5 + (tmp4+tmp9));\
- OP2(dst[7*dstStride], (tmp7+tmp8)*20 - (tmp6+tmp9)*5 + (tmp5+tmp10));\
- dst++;\
- tmp++;\
- }\
-}\
-\
-static void FUNC(OPNAME ## h264_qpel16_v_lowpass)(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
- FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst , src , dstStride, srcStride);\
- FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
- src += 8*srcStride;\
- dst += 8*dstStride;\
- FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst , src , dstStride, srcStride);\
- FUNC(OPNAME ## h264_qpel8_v_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
-}\
-\
-static void FUNC(OPNAME ## h264_qpel16_h_lowpass)(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
- FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst , src , dstStride, srcStride);\
- FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
- src += 8*srcStride;\
- dst += 8*dstStride;\
- FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst , src , dstStride, srcStride);\
- FUNC(OPNAME ## h264_qpel8_h_lowpass)(dst+8*sizeof(pixel), src+8*sizeof(pixel), dstStride, srcStride);\
-}\
-\
-static void FUNC(OPNAME ## h264_qpel16_hv_lowpass)(uint8_t *dst, pixeltmp *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
- FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst , tmp , src , dstStride, tmpStride, srcStride);\
- FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst+8*sizeof(pixel), tmp+8, src+8*sizeof(pixel), dstStride, tmpStride, srcStride);\
- src += 8*srcStride;\
- dst += 8*dstStride;\
- FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst , tmp , src , dstStride, tmpStride, srcStride);\
- FUNC(OPNAME ## h264_qpel8_hv_lowpass)(dst+8*sizeof(pixel), tmp+8, src+8*sizeof(pixel), dstStride, tmpStride, srcStride);\
-}\
-
-#define H264_MC(OPNAME, SIZE) \
-static av_unused void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc00)(uint8_t *dst, uint8_t *src, int stride){\
- FUNCC(OPNAME ## pixels ## SIZE)(dst, src, stride, SIZE);\
-}\
-\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc10)(uint8_t *dst, uint8_t *src, int stride){\
- uint8_t half[SIZE*SIZE*sizeof(pixel)];\
- FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(half, src, SIZE*sizeof(pixel), stride);\
- FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, src, half, stride, stride, SIZE*sizeof(pixel), SIZE);\
-}\
-\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc20)(uint8_t *dst, uint8_t *src, int stride){\
- FUNC(OPNAME ## h264_qpel ## SIZE ## _h_lowpass)(dst, src, stride, stride);\
-}\
-\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc30)(uint8_t *dst, uint8_t *src, int stride){\
- uint8_t half[SIZE*SIZE*sizeof(pixel)];\
- FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(half, src, SIZE*sizeof(pixel), stride);\
- FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, src+sizeof(pixel), half, stride, stride, SIZE*sizeof(pixel), SIZE);\
-}\
-\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc01)(uint8_t *dst, uint8_t *src, int stride){\
- uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
- uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
- uint8_t half[SIZE*SIZE*sizeof(pixel)];\
- FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
- FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(half, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
- FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, full_mid, half, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
-}\
-\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc02)(uint8_t *dst, uint8_t *src, int stride){\
- uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
- uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
- FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
- FUNC(OPNAME ## h264_qpel ## SIZE ## _v_lowpass)(dst, full_mid, stride, SIZE*sizeof(pixel));\
-}\
-\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc03)(uint8_t *dst, uint8_t *src, int stride){\
- uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
- uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
- uint8_t half[SIZE*SIZE*sizeof(pixel)];\
- FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
- FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(half, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
- FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, full_mid+SIZE*sizeof(pixel), half, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
-}\
-\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc11)(uint8_t *dst, uint8_t *src, int stride){\
- uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
- uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
- uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
- uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
- FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
- FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
- FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
- FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
-}\
-\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc31)(uint8_t *dst, uint8_t *src, int stride){\
- uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
- uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
- uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
- uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
- FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
- FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel), stride, SIZE + 5);\
- FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
- FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
-}\
-\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc13)(uint8_t *dst, uint8_t *src, int stride){\
- uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
- uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
- uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
- uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
- FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
- FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
- FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
- FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
-}\
-\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc33)(uint8_t *dst, uint8_t *src, int stride){\
- uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
- uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
- uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
- uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
- FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
- FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel), stride, SIZE + 5);\
- FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
- FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
-}\
-\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc22)(uint8_t *dst, uint8_t *src, int stride){\
- pixeltmp tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
- FUNC(OPNAME ## h264_qpel ## SIZE ## _hv_lowpass)(dst, tmp, src, stride, SIZE*sizeof(pixel), stride);\
-}\
-\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc21)(uint8_t *dst, uint8_t *src, int stride){\
- pixeltmp tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
- uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
- uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
- FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src, SIZE*sizeof(pixel), stride);\
- FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
- FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
-}\
-\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc23)(uint8_t *dst, uint8_t *src, int stride){\
- pixeltmp tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
- uint8_t halfH[SIZE*SIZE*sizeof(pixel)];\
- uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
- FUNC(put_h264_qpel ## SIZE ## _h_lowpass)(halfH, src + stride, SIZE*sizeof(pixel), stride);\
- FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
- FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfH, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
-}\
-\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc12)(uint8_t *dst, uint8_t *src, int stride){\
- uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
- uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
- pixeltmp tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
- uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
- uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
- FUNC(copy_block ## SIZE )(full, src - stride*2, SIZE*sizeof(pixel), stride, SIZE + 5);\
- FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
- FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
- FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfV, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
-}\
-\
-static void FUNCC(OPNAME ## h264_qpel ## SIZE ## _mc32)(uint8_t *dst, uint8_t *src, int stride){\
- uint8_t full[SIZE*(SIZE+5)*sizeof(pixel)];\
- uint8_t * const full_mid= full + SIZE*2*sizeof(pixel);\
- pixeltmp tmp[SIZE*(SIZE+5)*sizeof(pixel)];\
- uint8_t halfV[SIZE*SIZE*sizeof(pixel)];\
- uint8_t halfHV[SIZE*SIZE*sizeof(pixel)];\
- FUNC(copy_block ## SIZE )(full, src - stride*2 + sizeof(pixel), SIZE*sizeof(pixel), stride, SIZE + 5);\
- FUNC(put_h264_qpel ## SIZE ## _v_lowpass)(halfV, full_mid, SIZE*sizeof(pixel), SIZE*sizeof(pixel));\
- FUNC(put_h264_qpel ## SIZE ## _hv_lowpass)(halfHV, tmp, src, SIZE*sizeof(pixel), SIZE*sizeof(pixel), stride);\
- FUNC(OPNAME ## pixels ## SIZE ## _l2)(dst, halfV, halfHV, stride, SIZE*sizeof(pixel), SIZE*sizeof(pixel), SIZE);\
-}\
-
-#define op_avg(a, b) a = (((a)+CLIP(((b) + 16)>>5)+1)>>1)
-//#define op_avg2(a, b) a = (((a)*w1+cm[((b) + 16)>>5]*w2 + o + 64)>>7)
-#define op_put(a, b) a = CLIP(((b) + 16)>>5)
-#define op2_avg(a, b) a = (((a)+CLIP(((b) + 512)>>10)+1)>>1)
-#define op2_put(a, b) a = CLIP(((b) + 512)>>10)
-
-H264_LOWPASS(put_ , op_put, op2_put)
-H264_LOWPASS(avg_ , op_avg, op2_avg)
-H264_MC(put_, 2)
-H264_MC(put_, 4)
-H264_MC(put_, 8)
-H264_MC(put_, 16)
-H264_MC(avg_, 4)
-H264_MC(avg_, 8)
-H264_MC(avg_, 16)
-
-#undef op_avg
-#undef op_put
-#undef op2_avg
-#undef op2_put
-
-#if BIT_DEPTH == 8
-# define put_h264_qpel8_mc00_8_c ff_put_pixels8x8_8_c
-# define avg_h264_qpel8_mc00_8_c ff_avg_pixels8x8_8_c
-# define put_h264_qpel16_mc00_8_c ff_put_pixels16x16_8_c
-# define avg_h264_qpel16_mc00_8_c ff_avg_pixels16x16_8_c
-#elif BIT_DEPTH == 9
-# define put_h264_qpel8_mc00_9_c ff_put_pixels8x8_9_c
-# define avg_h264_qpel8_mc00_9_c ff_avg_pixels8x8_9_c
-# define put_h264_qpel16_mc00_9_c ff_put_pixels16x16_9_c
-# define avg_h264_qpel16_mc00_9_c ff_avg_pixels16x16_9_c
-#elif BIT_DEPTH == 10
-# define put_h264_qpel8_mc00_10_c ff_put_pixels8x8_10_c
-# define avg_h264_qpel8_mc00_10_c ff_avg_pixels8x8_10_c
-# define put_h264_qpel16_mc00_10_c ff_put_pixels16x16_10_c
-# define avg_h264_qpel16_mc00_10_c ff_avg_pixels16x16_10_c
-#elif BIT_DEPTH == 12
-# define put_h264_qpel8_mc00_12_c ff_put_pixels8x8_12_c
-# define avg_h264_qpel8_mc00_12_c ff_avg_pixels8x8_12_c
-# define put_h264_qpel16_mc00_12_c ff_put_pixels16x16_12_c
-# define avg_h264_qpel16_mc00_12_c ff_avg_pixels16x16_12_c
-#elif BIT_DEPTH == 14
-# define put_h264_qpel8_mc00_14_c ff_put_pixels8x8_14_c
-# define avg_h264_qpel8_mc00_14_c ff_avg_pixels8x8_14_c
-# define put_h264_qpel16_mc00_14_c ff_put_pixels16x16_14_c
-# define avg_h264_qpel16_mc00_14_c ff_avg_pixels16x16_14_c
-#endif
diff --git a/src/thirdparty/ffmpeg/libavcodec/hpel_template.c b/src/thirdparty/ffmpeg/libavcodec/hpel_template.c
deleted file mode 100644
index 3b4699927..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/hpel_template.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2000, 2001 Fabrice Bellard
- * Copyright (c) 2002-2004 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
- */
-
-#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))
-
-
-#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
-#undef op_put
diff --git a/src/thirdparty/ffmpeg/libavcodec/huffman.c b/src/thirdparty/ffmpeg/libavcodec/huffman.c
deleted file mode 100644
index 9420124d5..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/huffman.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (c) 2006 Konstantin Shishkov
- * Copyright (c) 2007 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
- */
-
-/**
- * @file
- * huffman tree builder and VLC generator
- */
-
-#include "avcodec.h"
-#include "get_bits.h"
-#include "huffman.h"
-
-/* symbol for Huffman tree node */
-#define HNODE -1
-
-typedef struct {
- uint64_t val;
- int name;
-} HeapElem;
-
-static void heap_sift(HeapElem *h, int root, int size)
-{
- while (root * 2 + 1 < size) {
- int child = root * 2 + 1;
- if (child < size - 1 && h[child].val > h[child+1].val)
- child++;
- if (h[root].val > h[child].val) {
- FFSWAP(HeapElem, h[root], h[child]);
- root = child;
- } else
- break;
- }
-}
-
-void ff_huff_gen_len_table(uint8_t *dst, const uint64_t *stats)
-{
- HeapElem h[256];
- int up[2*256];
- int len[2*256];
- int offset, i, next;
- int size = 256;
-
- for (offset = 1; ; offset <<= 1) {
- for (i=0; i < size; i++) {
- h[i].name = i;
- h[i].val = (stats[i] << 8) + offset;
- }
- for (i = size / 2 - 1; i >= 0; i--)
- heap_sift(h, i, size);
-
- for (next = size; next < size * 2 - 1; next++) {
- // merge the two smallest entries, and put it back in the heap
- uint64_t min1v = h[0].val;
- up[h[0].name] = next;
- h[0].val = INT64_MAX;
- heap_sift(h, 0, size);
- up[h[0].name] = next;
- h[0].name = next;
- h[0].val += min1v;
- heap_sift(h, 0, size);
- }
-
- len[2 * size - 2] = 0;
- for (i = 2 * size - 3; i >= size; i--)
- len[i] = len[up[i]] + 1;
- for (i = 0; i < size; i++) {
- dst[i] = len[up[i]] + 1;
- if (dst[i] >= 32) break;
- }
- if (i==size) break;
- }
-}
-
-static void get_tree_codes(uint32_t *bits, int16_t *lens, uint8_t *xlat,
- Node *nodes, int node,
- uint32_t pfx, int pl, int *pos, int no_zero_count)
-{
- int s;
-
- s = nodes[node].sym;
- if (s != HNODE || (no_zero_count && !nodes[node].count)) {
- bits[*pos] = pfx;
- lens[*pos] = pl;
- xlat[*pos] = s;
- (*pos)++;
- } else {
- pfx <<= 1;
- pl++;
- get_tree_codes(bits, lens, xlat, nodes, nodes[node].n0, pfx, pl,
- pos, no_zero_count);
- pfx |= 1;
- get_tree_codes(bits, lens, xlat, nodes, nodes[node].n0 + 1, pfx, pl,
- pos, no_zero_count);
- }
-}
-
-static int build_huff_tree(VLC *vlc, Node *nodes, int head, int flags)
-{
- int no_zero_count = !(flags & FF_HUFFMAN_FLAG_ZERO_COUNT);
- uint32_t bits[256];
- int16_t lens[256];
- uint8_t xlat[256];
- int pos = 0;
-
- get_tree_codes(bits, lens, xlat, nodes, head, 0, 0,
- &pos, no_zero_count);
- return ff_init_vlc_sparse(vlc, 9, pos, lens, 2, 2, bits, 4, 4, xlat, 1, 1, 0);
-}
-
-
-/**
- * nodes size must be 2*nb_codes
- * first nb_codes nodes.count must be set
- */
-int ff_huff_build_tree(AVCodecContext *avctx, VLC *vlc, int nb_codes,
- Node *nodes, HuffCmp cmp, int flags)
-{
- int i, j;
- int cur_node;
- int64_t sum = 0;
-
- for (i = 0; i < nb_codes; i++) {
- nodes[i].sym = i;
- nodes[i].n0 = -2;
- sum += nodes[i].count;
- }
-
- if (sum >> 31) {
- av_log(avctx, AV_LOG_ERROR,
- "Too high symbol frequencies. "
- "Tree construction is not possible\n");
- return -1;
- }
- qsort(nodes, nb_codes, sizeof(Node), cmp);
- cur_node = nb_codes;
- nodes[nb_codes*2-1].count = 0;
- for (i = 0; i < nb_codes * 2 - 1; i += 2) {
- uint32_t cur_count = nodes[i].count + nodes[i+1].count;
- // find correct place to insert new node, and
- // make space for the new node while at it
- for(j = cur_node; j > i + 2; j--){
- if(cur_count > nodes[j-1].count ||
- (cur_count == nodes[j-1].count &&
- !(flags & FF_HUFFMAN_FLAG_HNODE_FIRST)))
- break;
- nodes[j] = nodes[j - 1];
- }
- nodes[j].sym = HNODE;
- nodes[j].count = cur_count;
- nodes[j].n0 = i;
- cur_node++;
- }
- if (build_huff_tree(vlc, nodes, nb_codes * 2 - 2, flags) < 0) {
- av_log(avctx, AV_LOG_ERROR, "Error building tree\n");
- return -1;
- }
- return 0;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/huffman.h b/src/thirdparty/ffmpeg/libavcodec/huffman.h
deleted file mode 100644
index d82d7b667..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/huffman.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2007 Aurelien Jacobs <aurel@gnuage.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
- */
-
-/**
- * @file
- * huffman tree builder and VLC generator
- */
-
-#ifndef AVCODEC_HUFFMAN_H
-#define AVCODEC_HUFFMAN_H
-
-#include "avcodec.h"
-#include "get_bits.h"
-
-typedef struct Node {
- int16_t sym;
- int16_t n0;
- uint32_t count;
-} Node;
-
-#define FF_HUFFMAN_FLAG_HNODE_FIRST 0x01
-#define FF_HUFFMAN_FLAG_ZERO_COUNT 0x02
-
-typedef int (*HuffCmp)(const void *va, const void *vb);
-int ff_huff_build_tree(AVCodecContext *avctx, VLC *vlc, int nb_codes,
- Node *nodes, HuffCmp cmp, int flags);
-
-void ff_huff_gen_len_table(uint8_t *dst, const uint64_t *stats);
-
-#endif /* AVCODEC_HUFFMAN_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/imgconvert.c b/src/thirdparty/ffmpeg/libavcodec/imgconvert.c
deleted file mode 100644
index b24d3725f..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/imgconvert.c
+++ /dev/null
@@ -1,680 +0,0 @@
-/*
- * Misc image conversion routines
- * Copyright (c) 2001, 2002, 2003 Fabrice Bellard
- *
- * 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
- * misc image conversion routines
- */
-
-/* TODO:
- * - write 'ffimg' program to test all the image related stuff
- * - move all api to slice based system
- * - integrate deinterlacing, postprocessing and scaling in the conversion process
- */
-
-#include "avcodec.h"
-#include "dsputil.h"
-#include "imgconvert.h"
-#include "internal.h"
-#include "libavutil/avassert.h"
-#include "libavutil/colorspace.h"
-#include "libavutil/common.h"
-#include "libavutil/pixdesc.h"
-#include "libavutil/imgutils.h"
-
-#if HAVE_MMX_EXTERNAL
-#include "x86/dsputil_mmx.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
-#define deinterlace_line_inplace deinterlace_line_inplace_c
-#define deinterlace_line deinterlace_line_c
-#endif
-
-#define pixdesc_has_alpha(pixdesc) \
- ((pixdesc)->nb_components == 2 || (pixdesc)->nb_components == 4 || (pixdesc)->flags & PIX_FMT_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);
- av_assert0(desc);
- *h_shift = desc->log2_chroma_w;
- *v_shift = desc->log2_chroma_h;
-}
-
-static int get_color_type(const AVPixFmtDescriptor *desc) {
- 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 & PIX_FMT_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;
-
- 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;
- }
- // dont 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;
-}
-
-#if FF_API_FIND_BEST_PIX_FMT
-enum AVPixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum AVPixelFormat src_pix_fmt,
- int has_alpha, int *loss_ptr)
-{
- enum AVPixelFormat dst_pix_fmt;
- int i;
-
- if (loss_ptr) /* all losses count (for backward compatibility) */
- *loss_ptr = 0;
-
- dst_pix_fmt = AV_PIX_FMT_NONE; /* so first iteration doesn't have to be treated special */
- for(i = 0; i< FFMIN(AV_PIX_FMT_NB, 64); i++){
- if (pix_fmt_mask & (1ULL << i))
- dst_pix_fmt = avcodec_find_best_pix_fmt_of_2(dst_pix_fmt, i, src_pix_fmt, has_alpha, loss_ptr);
- }
- return dst_pix_fmt;
-}
-#endif /* FF_API_FIND_BEST_PIX_FMT */
-
-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;
-}
-
-#if AV_HAVE_INCOMPATIBLE_FORK_ABI
-enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat *pix_fmt_list,
- enum AVPixelFormat src_pix_fmt,
- int has_alpha, int *loss_ptr){
- return avcodec_find_best_pix_fmt_of_list(pix_fmt_list, src_pix_fmt, has_alpha, loss_ptr);
-}
-#else
-enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
- enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr)
-{
- return avcodec_find_best_pix_fmt_of_2(dst_pix_fmt1, dst_pix_fmt2, src_pix_fmt, has_alpha, loss_ptr);
-}
-#endif
-
-enum AVPixelFormat avcodec_find_best_pix_fmt_of_list(enum AVPixelFormat *pix_fmt_list,
- enum AVPixelFormat src_pix_fmt,
- int has_alpha, int *loss_ptr){
- int i;
-
- enum AVPixelFormat best = AV_PIX_FMT_NONE;
-
- for(i=0; pix_fmt_list[i] != AV_PIX_FMT_NONE; i++)
- best = avcodec_find_best_pix_fmt_of_2(best, pix_fmt_list[i], src_pix_fmt, has_alpha, loss_ptr);
-
- return best;
-}
-
-/* 2x2 -> 1x1 */
-void ff_shrink22(uint8_t *dst, int dst_wrap,
- const uint8_t *src, int src_wrap,
- int width, int height)
-{
- int w;
- const uint8_t *s1, *s2;
- uint8_t *d;
-
- for(;height > 0; height--) {
- s1 = src;
- s2 = s1 + src_wrap;
- d = dst;
- for(w = width;w >= 4; w-=4) {
- d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 2;
- d[1] = (s1[2] + s1[3] + s2[2] + s2[3] + 2) >> 2;
- d[2] = (s1[4] + s1[5] + s2[4] + s2[5] + 2) >> 2;
- d[3] = (s1[6] + s1[7] + s2[6] + s2[7] + 2) >> 2;
- s1 += 8;
- s2 += 8;
- d += 4;
- }
- for(;w > 0; w--) {
- d[0] = (s1[0] + s1[1] + s2[0] + s2[1] + 2) >> 2;
- s1 += 2;
- s2 += 2;
- d++;
- }
- src += 2 * src_wrap;
- dst += dst_wrap;
- }
-}
-
-/* 4x4 -> 1x1 */
-void ff_shrink44(uint8_t *dst, int dst_wrap,
- const uint8_t *src, int src_wrap,
- int width, int height)
-{
- int w;
- const uint8_t *s1, *s2, *s3, *s4;
- uint8_t *d;
-
- for(;height > 0; height--) {
- s1 = src;
- s2 = s1 + src_wrap;
- s3 = s2 + src_wrap;
- s4 = s3 + src_wrap;
- d = dst;
- for(w = width;w > 0; w--) {
- d[0] = (s1[0] + s1[1] + s1[2] + s1[3] +
- s2[0] + s2[1] + s2[2] + s2[3] +
- s3[0] + s3[1] + s3[2] + s3[3] +
- s4[0] + s4[1] + s4[2] + s4[3] + 8) >> 4;
- s1 += 4;
- s2 += 4;
- s3 += 4;
- s4 += 4;
- d++;
- }
- src += 4 * src_wrap;
- dst += dst_wrap;
- }
-}
-
-/* 8x8 -> 1x1 */
-void ff_shrink88(uint8_t *dst, int dst_wrap,
- const uint8_t *src, int src_wrap,
- int width, int height)
-{
- int w, i;
-
- for(;height > 0; height--) {
- for(w = width;w > 0; w--) {
- int tmp=0;
- for(i=0; i<8; i++){
- tmp += src[0] + src[1] + src[2] + src[3] + src[4] + src[5] + src[6] + src[7];
- src += src_wrap;
- }
- *(dst++) = (tmp + 32)>>6;
- src += 8 - 8*src_wrap;
- }
- src += 8*src_wrap - 8*width;
- dst += dst_wrap - width;
- }
-}
-
-/* return true if yuv planar */
-static inline int is_yuv_planar(const AVPixFmtDescriptor *desc)
-{
- int i;
- int planes[4] = { 0 };
-
- if ( desc->flags & PIX_FMT_RGB
- || !(desc->flags & PIX_FMT_PLANAR))
- return 0;
-
- /* set the used planes */
- for (i = 0; i < desc->nb_components; i++)
- planes[desc->comp[i].plane] = 1;
-
- /* if there is an unused plane, the format is not planar */
- for (i = 0; i < desc->nb_components; i++)
- if (!planes[i])
- return 0;
- return 1;
-}
-
-int av_picture_crop(AVPicture *dst, const AVPicture *src,
- enum AVPixelFormat pix_fmt, int top_band, int left_band)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- int y_shift;
- int x_shift;
-
- if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
- return -1;
-
- y_shift = desc->log2_chroma_h;
- x_shift = desc->log2_chroma_w;
-
- if (is_yuv_planar(desc)) {
- dst->data[0] = src->data[0] + (top_band * src->linesize[0]) + left_band;
- dst->data[1] = src->data[1] + ((top_band >> y_shift) * src->linesize[1]) + (left_band >> x_shift);
- dst->data[2] = src->data[2] + ((top_band >> y_shift) * src->linesize[2]) + (left_band >> x_shift);
- } else{
- if(top_band % (1<<y_shift) || left_band % (1<<x_shift))
- return -1;
- if(left_band) //FIXME add support for this too
- return -1;
- dst->data[0] = src->data[0] + (top_band * src->linesize[0]) + left_band;
- }
-
- dst->linesize[0] = src->linesize[0];
- dst->linesize[1] = src->linesize[1];
- dst->linesize[2] = src->linesize[2];
- return 0;
-}
-
-int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width,
- enum AVPixelFormat pix_fmt, int padtop, int padbottom, int padleft, int padright,
- int *color)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- uint8_t *optr;
- int y_shift;
- int x_shift;
- int yheight;
- int i, y;
-
- if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB ||
- !is_yuv_planar(desc)) return -1;
-
- for (i = 0; i < 3; i++) {
- x_shift = i ? desc->log2_chroma_w : 0;
- y_shift = i ? desc->log2_chroma_h : 0;
-
- if (padtop || padleft) {
- memset(dst->data[i], color[i],
- dst->linesize[i] * (padtop >> y_shift) + (padleft >> x_shift));
- }
-
- if (padleft || padright) {
- optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) +
- (dst->linesize[i] - (padright >> x_shift));
- yheight = (height - 1 - (padtop + padbottom)) >> y_shift;
- for (y = 0; y < yheight; y++) {
- memset(optr, color[i], (padleft + padright) >> x_shift);
- optr += dst->linesize[i];
- }
- }
-
- if (src) { /* first line */
- uint8_t *iptr = src->data[i];
- optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) +
- (padleft >> x_shift);
- memcpy(optr, iptr, (width - padleft - padright) >> x_shift);
- iptr += src->linesize[i];
- optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) +
- (dst->linesize[i] - (padright >> x_shift));
- yheight = (height - 1 - (padtop + padbottom)) >> y_shift;
- for (y = 0; y < yheight; y++) {
- memset(optr, color[i], (padleft + padright) >> x_shift);
- memcpy(optr + ((padleft + padright) >> x_shift), iptr,
- (width - padleft - padright) >> x_shift);
- iptr += src->linesize[i];
- optr += dst->linesize[i];
- }
- }
-
- if (padbottom || padright) {
- optr = dst->data[i] + dst->linesize[i] *
- ((height - padbottom) >> y_shift) - (padright >> x_shift);
- memset(optr, color[i],dst->linesize[i] *
- (padbottom >> y_shift) + (padright >> x_shift));
- }
- }
- return 0;
-}
-
-#if !HAVE_MMX_EXTERNAL
-/* filter parameters: [-1 4 2 4 -1] // 8 */
-static void deinterlace_line_c(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)
-{
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
- int sum;
-
- for(;size > 0;size--) {
- sum = -lum_m4[0];
- sum += lum_m3[0] << 2;
- sum += lum_m2[0] << 1;
- sum += lum_m1[0] << 2;
- sum += -lum[0];
- dst[0] = cm[(sum + 4) >> 3];
- lum_m4++;
- lum_m3++;
- lum_m2++;
- lum_m1++;
- lum++;
- dst++;
- }
-}
-
-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)
-{
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
- int sum;
-
- for(;size > 0;size--) {
- sum = -lum_m4[0];
- sum += lum_m3[0] << 2;
- sum += lum_m2[0] << 1;
- lum_m4[0]=lum_m2[0];
- sum += lum_m1[0] << 2;
- sum += -lum[0];
- lum_m2[0] = cm[(sum + 4) >> 3];
- lum_m4++;
- lum_m3++;
- lum_m2++;
- lum_m1++;
- lum++;
- }
-}
-#endif /* !HAVE_MMX_EXTERNAL */
-
-/* deinterlacing : 2 temporal taps, 3 spatial taps linear filter. The
- top field is copied as is, but the bottom field is deinterlaced
- against the top field. */
-static void deinterlace_bottom_field(uint8_t *dst, int dst_wrap,
- const uint8_t *src1, int src_wrap,
- int width, int height)
-{
- const uint8_t *src_m2, *src_m1, *src_0, *src_p1, *src_p2;
- int y;
-
- src_m2 = src1;
- src_m1 = src1;
- src_0=&src_m1[src_wrap];
- src_p1=&src_0[src_wrap];
- src_p2=&src_p1[src_wrap];
- for(y=0;y<(height-2);y+=2) {
- memcpy(dst,src_m1,width);
- dst += dst_wrap;
- deinterlace_line(dst,src_m2,src_m1,src_0,src_p1,src_p2,width);
- src_m2 = src_0;
- src_m1 = src_p1;
- src_0 = src_p2;
- src_p1 += 2*src_wrap;
- src_p2 += 2*src_wrap;
- dst += dst_wrap;
- }
- memcpy(dst,src_m1,width);
- dst += dst_wrap;
- /* do last line */
- deinterlace_line(dst,src_m2,src_m1,src_0,src_0,src_0,width);
-}
-
-static void deinterlace_bottom_field_inplace(uint8_t *src1, int src_wrap,
- int width, int height)
-{
- uint8_t *src_m1, *src_0, *src_p1, *src_p2;
- int y;
- uint8_t *buf;
- buf = av_malloc(width);
-
- src_m1 = src1;
- memcpy(buf,src_m1,width);
- src_0=&src_m1[src_wrap];
- src_p1=&src_0[src_wrap];
- src_p2=&src_p1[src_wrap];
- for(y=0;y<(height-2);y+=2) {
- deinterlace_line_inplace(buf,src_m1,src_0,src_p1,src_p2,width);
- src_m1 = src_p1;
- src_0 = src_p2;
- src_p1 += 2*src_wrap;
- src_p2 += 2*src_wrap;
- }
- /* do last line */
- deinterlace_line_inplace(buf,src_m1,src_0,src_0,src_0,width);
- av_free(buf);
-}
-
-int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
- enum AVPixelFormat pix_fmt, int width, int height)
-{
- int i;
-
- if (pix_fmt != AV_PIX_FMT_YUV420P &&
- pix_fmt != AV_PIX_FMT_YUVJ420P &&
- pix_fmt != AV_PIX_FMT_YUV422P &&
- pix_fmt != AV_PIX_FMT_YUVJ422P &&
- pix_fmt != AV_PIX_FMT_YUV444P &&
- pix_fmt != AV_PIX_FMT_YUV411P &&
- pix_fmt != AV_PIX_FMT_GRAY8)
- return -1;
- if ((width & 3) != 0 || (height & 3) != 0)
- return -1;
-
- for(i=0;i<3;i++) {
- if (i == 1) {
- switch(pix_fmt) {
- case AV_PIX_FMT_YUVJ420P:
- case AV_PIX_FMT_YUV420P:
- width >>= 1;
- height >>= 1;
- break;
- case AV_PIX_FMT_YUV422P:
- case AV_PIX_FMT_YUVJ422P:
- width >>= 1;
- break;
- case AV_PIX_FMT_YUV411P:
- width >>= 2;
- break;
- default:
- break;
- }
- if (pix_fmt == AV_PIX_FMT_GRAY8) {
- break;
- }
- }
- if (src == dst) {
- deinterlace_bottom_field_inplace(dst->data[i], dst->linesize[i],
- width, height);
- } else {
- deinterlace_bottom_field(dst->data[i],dst->linesize[i],
- src->data[i], src->linesize[i],
- width, height);
- }
- }
- emms_c();
- return 0;
-}
-
-#ifdef TEST
-
-int main(void){
- int i;
- int err=0;
- int skip = 0;
-
- for (i=0; i<AV_PIX_FMT_NB*2; i++) {
- AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(i);
- if(!desc || !desc->name) {
- skip ++;
- continue;
- }
- if (skip) {
- 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));
- if ((!(desc->flags & PIX_FMT_ALPHA)) != (desc->nb_components != 2 && desc->nb_components != 4)) {
- av_log(NULL, AV_LOG_ERROR, "Alpha flag mismatch\n");
- err = 1;
- }
- }
- return err;
-}
-
-#endif
diff --git a/src/thirdparty/ffmpeg/libavcodec/imgconvert.h b/src/thirdparty/ffmpeg/libavcodec/imgconvert.h
deleted file mode 100644
index df8cee794..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/imgconvert.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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_IMGCONVERT_H
-#define AVCODEC_IMGCONVERT_H
-
-#include <stdint.h>
-
-/* 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);
-void ff_shrink88(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
-
-#endif /* AVCODEC_IMGCONVERT_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/indeo3.c b/src/thirdparty/ffmpeg/libavcodec/indeo3.c
deleted file mode 100644
index 36822cce9..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/indeo3.c
+++ /dev/null
@@ -1,1151 +0,0 @@
-/*
- * Indeo Video v3 compatible decoder
- * Copyright (c) 2009 - 2011 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
- * This is a decoder for Intel Indeo Video v3.
- * It is based on vector quantization, run-length coding and motion compensation.
- * Known container formats: .avi and .mov
- * Known FOURCCs: 'IV31', 'IV32'
- *
- * @see http://wiki.multimedia.cx/index.php?title=Indeo_3
- */
-
-#include "libavutil/imgutils.h"
-#include "libavutil/intreadwrite.h"
-#include "avcodec.h"
-#include "copy_block.h"
-#include "dsputil.h"
-#include "bytestream.h"
-#include "get_bits.h"
-#include "internal.h"
-
-#include "indeo3data.h"
-
-/* RLE opcodes. */
-enum {
- RLE_ESC_F9 = 249, ///< same as RLE_ESC_FA + do the same with next block
- RLE_ESC_FA = 250, ///< INTRA: skip block, INTER: copy data from reference
- RLE_ESC_FB = 251, ///< apply null delta to N blocks / skip N blocks
- RLE_ESC_FC = 252, ///< same as RLE_ESC_FD + do the same with next block
- RLE_ESC_FD = 253, ///< apply null delta to all remaining lines of this block
- RLE_ESC_FE = 254, ///< apply null delta to all lines up to the 3rd line
- RLE_ESC_FF = 255 ///< apply null delta to all lines up to the 2nd line
-};
-
-
-/* Some constants for parsing frame bitstream flags. */
-#define BS_8BIT_PEL (1 << 1) ///< 8bit pixel bitdepth indicator
-#define BS_KEYFRAME (1 << 2) ///< intra frame indicator
-#define BS_MV_Y_HALF (1 << 4) ///< vertical mv halfpel resolution indicator
-#define BS_MV_X_HALF (1 << 5) ///< horizontal mv halfpel resolution indicator
-#define BS_NONREF (1 << 8) ///< nonref (discardable) frame indicator
-#define BS_BUFFER 9 ///< indicates which of two frame buffers should be used
-
-
-typedef struct Plane {
- uint8_t *buffers[2];
- uint8_t *pixels[2]; ///< pointer to the actual pixel data of the buffers above
- uint32_t width;
- uint32_t height;
- uint32_t pitch;
-} Plane;
-
-#define CELL_STACK_MAX 20
-
-typedef struct Cell {
- int16_t xpos; ///< cell coordinates in 4x4 blocks
- int16_t ypos;
- int16_t width; ///< cell width in 4x4 blocks
- int16_t height; ///< cell height in 4x4 blocks
- uint8_t tree; ///< tree id: 0- MC tree, 1 - VQ tree
- const int8_t *mv_ptr; ///< ptr to the motion vector if any
-} Cell;
-
-typedef struct Indeo3DecodeContext {
- AVCodecContext *avctx;
- AVFrame frame;
- DSPContext dsp;
-
- GetBitContext gb;
- int need_resync;
- int skip_bits;
- const uint8_t *next_cell_data;
- const uint8_t *last_byte;
- const int8_t *mc_vectors;
- unsigned num_vectors; ///< number of motion vectors in mc_vectors
-
- int16_t width, height;
- uint32_t frame_num; ///< current frame number (zero-based)
- uint32_t data_size; ///< size of the frame data in bytes
- uint16_t frame_flags; ///< frame properties
- uint8_t cb_offset; ///< needed for selecting VQ tables
- uint8_t buf_sel; ///< active frame buffer: 0 - primary, 1 -secondary
- const uint8_t *y_data_ptr;
- const uint8_t *v_data_ptr;
- const uint8_t *u_data_ptr;
- int32_t y_data_size;
- int32_t v_data_size;
- int32_t u_data_size;
- const uint8_t *alt_quant; ///< secondary VQ table set for the modes 1 and 4
- Plane planes[3];
-} Indeo3DecodeContext;
-
-
-static uint8_t requant_tab[8][128];
-
-/*
- * Build the static requantization table.
- * This table is used to remap pixel values according to a specific
- * quant index and thus avoid overflows while adding deltas.
- */
-static av_cold void build_requant_tab(void)
-{
- static int8_t offsets[8] = { 1, 1, 2, -3, -3, 3, 4, 4 };
- static int8_t deltas [8] = { 0, 1, 0, 4, 4, 1, 0, 1 };
-
- int i, j, step;
-
- for (i = 0; i < 8; i++) {
- step = i + 2;
- for (j = 0; j < 128; j++)
- requant_tab[i][j] = (j + offsets[i]) / step * step + deltas[i];
- }
-
- /* some last elements calculated above will have values >= 128 */
- /* pixel values shall never exceed 127 so set them to non-overflowing values */
- /* according with the quantization step of the respective section */
- requant_tab[0][127] = 126;
- requant_tab[1][119] = 118;
- requant_tab[1][120] = 118;
- requant_tab[2][126] = 124;
- requant_tab[2][127] = 124;
- requant_tab[6][124] = 120;
- requant_tab[6][125] = 120;
- requant_tab[6][126] = 120;
- requant_tab[6][127] = 120;
-
- /* Patch for compatibility with the Intel's binary decoders */
- requant_tab[1][7] = 10;
- requant_tab[4][8] = 10;
-}
-
-
-static av_cold int allocate_frame_buffers(Indeo3DecodeContext *ctx,
- AVCodecContext *avctx, int luma_width, int luma_height)
-{
- int p, chroma_width, chroma_height;
- int luma_pitch, chroma_pitch, luma_size, chroma_size;
-
- if (luma_width < 16 || luma_width > 640 ||
- luma_height < 16 || luma_height > 480 ||
- luma_width & 3 || luma_height & 3) {
- av_log(avctx, AV_LOG_ERROR, "Invalid picture dimensions: %d x %d!\n",
- luma_width, luma_height);
- return AVERROR_INVALIDDATA;
- }
-
- ctx->width = luma_width ;
- ctx->height = luma_height;
-
- chroma_width = FFALIGN(luma_width >> 2, 4);
- chroma_height = FFALIGN(luma_height >> 2, 4);
-
- luma_pitch = FFALIGN(luma_width, 16);
- chroma_pitch = FFALIGN(chroma_width, 16);
-
- /* Calculate size of the luminance plane. */
- /* Add one line more for INTRA prediction. */
- luma_size = luma_pitch * (luma_height + 1);
-
- /* Calculate size of a chrominance planes. */
- /* Add one line more for INTRA prediction. */
- chroma_size = chroma_pitch * (chroma_height + 1);
-
- /* allocate frame buffers */
- for (p = 0; p < 3; p++) {
- ctx->planes[p].pitch = !p ? luma_pitch : chroma_pitch;
- ctx->planes[p].width = !p ? luma_width : chroma_width;
- ctx->planes[p].height = !p ? luma_height : chroma_height;
-
- ctx->planes[p].buffers[0] = av_malloc(!p ? luma_size : chroma_size);
- ctx->planes[p].buffers[1] = av_malloc(!p ? luma_size : chroma_size);
-
- /* fill the INTRA prediction lines with the middle pixel value = 64 */
- memset(ctx->planes[p].buffers[0], 0x40, ctx->planes[p].pitch);
- memset(ctx->planes[p].buffers[1], 0x40, ctx->planes[p].pitch);
-
- /* set buffer pointers = buf_ptr + pitch and thus skip the INTRA prediction line */
- ctx->planes[p].pixels[0] = ctx->planes[p].buffers[0] + ctx->planes[p].pitch;
- ctx->planes[p].pixels[1] = ctx->planes[p].buffers[1] + ctx->planes[p].pitch;
- memset(ctx->planes[p].pixels[0], 0, ctx->planes[p].pitch * ctx->planes[p].height);
- memset(ctx->planes[p].pixels[1], 0, ctx->planes[p].pitch * ctx->planes[p].height);
- }
-
- return 0;
-}
-
-
-static av_cold void free_frame_buffers(Indeo3DecodeContext *ctx)
-{
- int p;
-
- ctx->width=
- ctx->height= 0;
-
- for (p = 0; p < 3; p++) {
- av_freep(&ctx->planes[p].buffers[0]);
- av_freep(&ctx->planes[p].buffers[1]);
- ctx->planes[p].pixels[0] = ctx->planes[p].pixels[1] = 0;
- }
-}
-
-
-/**
- * Copy pixels of the cell(x + mv_x, y + mv_y) from the previous frame into
- * the cell(x, y) in the current frame.
- *
- * @param ctx pointer to the decoder context
- * @param plane pointer to the plane descriptor
- * @param cell pointer to the cell descriptor
- */
-static void copy_cell(Indeo3DecodeContext *ctx, Plane *plane, Cell *cell)
-{
- int h, w, mv_x, mv_y, offset, offset_dst;
- uint8_t *src, *dst;
-
- /* setup output and reference pointers */
- offset_dst = (cell->ypos << 2) * plane->pitch + (cell->xpos << 2);
- dst = plane->pixels[ctx->buf_sel] + offset_dst;
- if(cell->mv_ptr){
- mv_y = cell->mv_ptr[0];
- mv_x = cell->mv_ptr[1];
- }else
- mv_x= mv_y= 0;
- offset = offset_dst + mv_y * plane->pitch + mv_x;
- src = plane->pixels[ctx->buf_sel ^ 1] + offset;
-
- h = cell->height << 2;
-
- for (w = cell->width; w > 0;) {
- /* copy using 16xH blocks */
- if (!((cell->xpos << 2) & 15) && w >= 4) {
- for (; w >= 4; src += 16, dst += 16, w -= 4)
- ctx->dsp.put_no_rnd_pixels_tab[0][0](dst, src, plane->pitch, h);
- }
-
- /* copy using 8xH blocks */
- if (!((cell->xpos << 2) & 7) && w >= 2) {
- ctx->dsp.put_no_rnd_pixels_tab[1][0](dst, src, plane->pitch, h);
- w -= 2;
- src += 8;
- dst += 8;
- }
-
- if (w >= 1) {
- copy_block4(dst, src, plane->pitch, plane->pitch, h);
- w--;
- src += 4;
- dst += 4;
- }
- }
-}
-
-
-/* Average 4/8 pixels at once without rounding using SWAR */
-#define AVG_32(dst, src, ref) \
- AV_WN32A(dst, ((AV_RN32A(src) + AV_RN32A(ref)) >> 1) & 0x7F7F7F7FUL)
-
-#define AVG_64(dst, src, ref) \
- AV_WN64A(dst, ((AV_RN64A(src) + AV_RN64A(ref)) >> 1) & 0x7F7F7F7F7F7F7F7FULL)
-
-
-/*
- * Replicate each even pixel as follows:
- * ABCDEFGH -> AACCEEGG
- */
-static inline uint64_t replicate64(uint64_t a) {
-#if HAVE_BIGENDIAN
- a &= 0xFF00FF00FF00FF00ULL;
- a |= a >> 8;
-#else
- a &= 0x00FF00FF00FF00FFULL;
- a |= a << 8;
-#endif
- return a;
-}
-
-static inline uint32_t replicate32(uint32_t a) {
-#if HAVE_BIGENDIAN
- a &= 0xFF00FF00UL;
- a |= a >> 8;
-#else
- a &= 0x00FF00FFUL;
- a |= a << 8;
-#endif
- return a;
-}
-
-
-/* Fill n lines with 64bit pixel value pix */
-static inline void fill_64(uint8_t *dst, const uint64_t pix, int32_t n,
- int32_t row_offset)
-{
- for (; n > 0; dst += row_offset, n--)
- AV_WN64A(dst, pix);
-}
-
-
-/* Error codes for cell decoding. */
-enum {
- IV3_NOERR = 0,
- IV3_BAD_RLE = 1,
- IV3_BAD_DATA = 2,
- IV3_BAD_COUNTER = 3,
- IV3_UNSUPPORTED = 4,
- IV3_OUT_OF_DATA = 5
-};
-
-
-#define BUFFER_PRECHECK \
-if (*data_ptr >= last_ptr) \
- return IV3_OUT_OF_DATA; \
-
-#define RLE_BLOCK_COPY \
- if (cell->mv_ptr || !skip_flag) \
- copy_block4(dst, ref, row_offset, row_offset, 4 << v_zoom)
-
-#define RLE_BLOCK_COPY_8 \
- pix64 = AV_RN64A(ref);\
- if (is_first_row) {/* special prediction case: top line of a cell */\
- pix64 = replicate64(pix64);\
- fill_64(dst + row_offset, pix64, 7, row_offset);\
- AVG_64(dst, ref, dst + row_offset);\
- } else \
- fill_64(dst, pix64, 8, row_offset)
-
-#define RLE_LINES_COPY \
- copy_block4(dst, ref, row_offset, row_offset, num_lines << v_zoom)
-
-#define RLE_LINES_COPY_M10 \
- pix64 = AV_RN64A(ref);\
- if (is_top_of_cell) {\
- pix64 = replicate64(pix64);\
- fill_64(dst + row_offset, pix64, (num_lines << 1) - 1, row_offset);\
- AVG_64(dst, ref, dst + row_offset);\
- } else \
- fill_64(dst, pix64, num_lines << 1, row_offset)
-
-#define APPLY_DELTA_4 \
- AV_WN16A(dst + line_offset ,\
- (AV_RN16A(ref ) + delta_tab->deltas[dyad1]) & 0x7F7F);\
- AV_WN16A(dst + line_offset + 2,\
- (AV_RN16A(ref + 2) + delta_tab->deltas[dyad2]) & 0x7F7F);\
- if (mode >= 3) {\
- if (is_top_of_cell && !cell->ypos) {\
- AV_COPY32(dst, dst + row_offset);\
- } else {\
- AVG_32(dst, ref, dst + row_offset);\
- }\
- }
-
-#define APPLY_DELTA_8 \
- /* apply two 32-bit VQ deltas to next even line */\
- if (is_top_of_cell) { \
- AV_WN32A(dst + row_offset , \
- (replicate32(AV_RN32A(ref )) + delta_tab->deltas_m10[dyad1]) & 0x7F7F7F7F);\
- AV_WN32A(dst + row_offset + 4, \
- (replicate32(AV_RN32A(ref + 4)) + delta_tab->deltas_m10[dyad2]) & 0x7F7F7F7F);\
- } else { \
- AV_WN32A(dst + row_offset , \
- (AV_RN32A(ref ) + delta_tab->deltas_m10[dyad1]) & 0x7F7F7F7F);\
- AV_WN32A(dst + row_offset + 4, \
- (AV_RN32A(ref + 4) + delta_tab->deltas_m10[dyad2]) & 0x7F7F7F7F);\
- } \
- /* odd lines are not coded but rather interpolated/replicated */\
- /* first line of the cell on the top of image? - replicate */\
- /* otherwise - interpolate */\
- if (is_top_of_cell && !cell->ypos) {\
- AV_COPY64(dst, dst + row_offset);\
- } else \
- AVG_64(dst, ref, dst + row_offset);
-
-
-#define APPLY_DELTA_1011_INTER \
- if (mode == 10) { \
- AV_WN32A(dst , \
- (AV_RN32A(dst ) + delta_tab->deltas_m10[dyad1]) & 0x7F7F7F7F);\
- AV_WN32A(dst + 4 , \
- (AV_RN32A(dst + 4 ) + delta_tab->deltas_m10[dyad2]) & 0x7F7F7F7F);\
- AV_WN32A(dst + row_offset , \
- (AV_RN32A(dst + row_offset ) + delta_tab->deltas_m10[dyad1]) & 0x7F7F7F7F);\
- AV_WN32A(dst + row_offset + 4, \
- (AV_RN32A(dst + row_offset + 4) + delta_tab->deltas_m10[dyad2]) & 0x7F7F7F7F);\
- } else { \
- AV_WN16A(dst , \
- (AV_RN16A(dst ) + delta_tab->deltas[dyad1]) & 0x7F7F);\
- AV_WN16A(dst + 2 , \
- (AV_RN16A(dst + 2 ) + delta_tab->deltas[dyad2]) & 0x7F7F);\
- AV_WN16A(dst + row_offset , \
- (AV_RN16A(dst + row_offset ) + delta_tab->deltas[dyad1]) & 0x7F7F);\
- AV_WN16A(dst + row_offset + 2, \
- (AV_RN16A(dst + row_offset + 2) + delta_tab->deltas[dyad2]) & 0x7F7F);\
- }
-
-
-static int decode_cell_data(Indeo3DecodeContext *ctx, Cell *cell,
- uint8_t *block, uint8_t *ref_block,
- int pitch, int h_zoom, int v_zoom, int mode,
- const vqEntry *delta[2], int swap_quads[2],
- const uint8_t **data_ptr, const uint8_t *last_ptr)
-{
- int x, y, line, num_lines;
- int rle_blocks = 0;
- uint8_t code, *dst, *ref;
- const vqEntry *delta_tab;
- unsigned int dyad1, dyad2;
- uint64_t pix64;
- int skip_flag = 0, is_top_of_cell, is_first_row = 1;
- int row_offset, blk_row_offset, line_offset;
-
- row_offset = pitch;
- blk_row_offset = (row_offset << (2 + v_zoom)) - (cell->width << 2);
- line_offset = v_zoom ? row_offset : 0;
-
- if (cell->height & v_zoom || cell->width & h_zoom)
- return IV3_BAD_DATA;
-
- for (y = 0; y < cell->height; is_first_row = 0, y += 1 + v_zoom) {
- for (x = 0; x < cell->width; x += 1 + h_zoom) {
- ref = ref_block;
- dst = block;
-
- if (rle_blocks > 0) {
- if (mode <= 4) {
- RLE_BLOCK_COPY;
- } else if (mode == 10 && !cell->mv_ptr) {
- RLE_BLOCK_COPY_8;
- }
- rle_blocks--;
- } else {
- for (line = 0; line < 4;) {
- num_lines = 1;
- is_top_of_cell = is_first_row && !line;
-
- /* select primary VQ table for odd, secondary for even lines */
- if (mode <= 4)
- delta_tab = delta[line & 1];
- else
- delta_tab = delta[1];
- BUFFER_PRECHECK;
- code = bytestream_get_byte(data_ptr);
- if (code < 248) {
- if (code < delta_tab->num_dyads) {
- BUFFER_PRECHECK;
- dyad1 = bytestream_get_byte(data_ptr);
- dyad2 = code;
- if (dyad1 >= delta_tab->num_dyads || dyad1 >= 248)
- return IV3_BAD_DATA;
- } else {
- /* process QUADS */
- code -= delta_tab->num_dyads;
- dyad1 = code / delta_tab->quad_exp;
- dyad2 = code % delta_tab->quad_exp;
- if (swap_quads[line & 1])
- FFSWAP(unsigned int, dyad1, dyad2);
- }
- if (mode <= 4) {
- APPLY_DELTA_4;
- } else if (mode == 10 && !cell->mv_ptr) {
- APPLY_DELTA_8;
- } else {
- APPLY_DELTA_1011_INTER;
- }
- } else {
- /* process RLE codes */
- switch (code) {
- case RLE_ESC_FC:
- skip_flag = 0;
- rle_blocks = 1;
- code = 253;
- /* FALLTHROUGH */
- case RLE_ESC_FF:
- case RLE_ESC_FE:
- case RLE_ESC_FD:
- num_lines = 257 - code - line;
- if (num_lines <= 0)
- return IV3_BAD_RLE;
- if (mode <= 4) {
- RLE_LINES_COPY;
- } else if (mode == 10 && !cell->mv_ptr) {
- RLE_LINES_COPY_M10;
- }
- break;
- case RLE_ESC_FB:
- BUFFER_PRECHECK;
- code = bytestream_get_byte(data_ptr);
- rle_blocks = (code & 0x1F) - 1; /* set block counter */
- if (code >= 64 || rle_blocks < 0)
- return IV3_BAD_COUNTER;
- skip_flag = code & 0x20;
- num_lines = 4 - line; /* enforce next block processing */
- if (mode >= 10 || (cell->mv_ptr || !skip_flag)) {
- if (mode <= 4) {
- RLE_LINES_COPY;
- } else if (mode == 10 && !cell->mv_ptr) {
- RLE_LINES_COPY_M10;
- }
- }
- break;
- case RLE_ESC_F9:
- skip_flag = 1;
- rle_blocks = 1;
- /* FALLTHROUGH */
- case RLE_ESC_FA:
- if (line)
- return IV3_BAD_RLE;
- num_lines = 4; /* enforce next block processing */
- if (cell->mv_ptr) {
- if (mode <= 4) {
- RLE_LINES_COPY;
- } else if (mode == 10 && !cell->mv_ptr) {
- RLE_LINES_COPY_M10;
- }
- }
- break;
- default:
- return IV3_UNSUPPORTED;
- }
- }
-
- line += num_lines;
- ref += row_offset * (num_lines << v_zoom);
- dst += row_offset * (num_lines << v_zoom);
- }
- }
-
- /* move to next horizontal block */
- block += 4 << h_zoom;
- ref_block += 4 << h_zoom;
- }
-
- /* move to next line of blocks */
- ref_block += blk_row_offset;
- block += blk_row_offset;
- }
- return IV3_NOERR;
-}
-
-
-/**
- * Decode a vector-quantized cell.
- * It consists of several routines, each of which handles one or more "modes"
- * with which a cell can be encoded.
- *
- * @param ctx pointer to the decoder context
- * @param avctx ptr to the AVCodecContext
- * @param plane pointer to the plane descriptor
- * @param cell pointer to the cell descriptor
- * @param data_ptr pointer to the compressed data
- * @param last_ptr pointer to the last byte to catch reads past end of buffer
- * @return number of consumed bytes or negative number in case of error
- */
-static int decode_cell(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
- Plane *plane, Cell *cell, const uint8_t *data_ptr,
- const uint8_t *last_ptr)
-{
- int x, mv_x, mv_y, mode, vq_index, prim_indx, second_indx;
- int zoom_fac;
- int offset, error = 0, swap_quads[2];
- uint8_t code, *block, *ref_block = 0;
- const vqEntry *delta[2];
- const uint8_t *data_start = data_ptr;
-
- /* get coding mode and VQ table index from the VQ descriptor byte */
- code = *data_ptr++;
- mode = code >> 4;
- vq_index = code & 0xF;
-
- /* setup output and reference pointers */
- offset = (cell->ypos << 2) * plane->pitch + (cell->xpos << 2);
- block = plane->pixels[ctx->buf_sel] + offset;
-
- if (cell->mv_ptr) {
- mv_y = cell->mv_ptr[0];
- mv_x = cell->mv_ptr[1];
- if ( mv_x + 4*cell->xpos < 0
- || mv_y + 4*cell->ypos < 0
- || mv_x + 4*cell->xpos + 4*cell->width > plane->width
- || mv_y + 4*cell->ypos + 4*cell->height > plane->height) {
- av_log(avctx, AV_LOG_ERROR, "motion vector %d %d outside reference\n", mv_x + 4*cell->xpos, mv_y + 4*cell->ypos);
- return AVERROR_INVALIDDATA;
- }
- }
-
- if (!cell->mv_ptr) {
- /* use previous line as reference for INTRA cells */
- ref_block = block - plane->pitch;
- } else if (mode >= 10) {
- /* for mode 10 and 11 INTER first copy the predicted cell into the current one */
- /* so we don't need to do data copying for each RLE code later */
- copy_cell(ctx, plane, cell);
- } else {
- /* set the pointer to the reference pixels for modes 0-4 INTER */
- mv_y = cell->mv_ptr[0];
- mv_x = cell->mv_ptr[1];
- offset += mv_y * plane->pitch + mv_x;
- ref_block = plane->pixels[ctx->buf_sel ^ 1] + offset;
- }
-
- /* select VQ tables as follows: */
- /* modes 0 and 3 use only the primary table for all lines in a block */
- /* while modes 1 and 4 switch between primary and secondary tables on alternate lines */
- if (mode == 1 || mode == 4) {
- code = ctx->alt_quant[vq_index];
- prim_indx = (code >> 4) + ctx->cb_offset;
- second_indx = (code & 0xF) + ctx->cb_offset;
- } else {
- vq_index += ctx->cb_offset;
- prim_indx = second_indx = vq_index;
- }
-
- if (prim_indx >= 24 || second_indx >= 24) {
- av_log(avctx, AV_LOG_ERROR, "Invalid VQ table indexes! Primary: %d, secondary: %d!\n",
- prim_indx, second_indx);
- return AVERROR_INVALIDDATA;
- }
-
- delta[0] = &vq_tab[second_indx];
- delta[1] = &vq_tab[prim_indx];
- swap_quads[0] = second_indx >= 16;
- swap_quads[1] = prim_indx >= 16;
-
- /* requantize the prediction if VQ index of this cell differs from VQ index */
- /* of the predicted cell in order to avoid overflows. */
- if (vq_index >= 8 && ref_block) {
- for (x = 0; x < cell->width << 2; x++)
- ref_block[x] = requant_tab[vq_index & 7][ref_block[x] & 127];
- }
-
- error = IV3_NOERR;
-
- switch (mode) {
- case 0: /*------------------ MODES 0 & 1 (4x4 block processing) --------------------*/
- case 1:
- case 3: /*------------------ MODES 3 & 4 (4x8 block processing) --------------------*/
- case 4:
- if (mode >= 3 && cell->mv_ptr) {
- av_log(avctx, AV_LOG_ERROR, "Attempt to apply Mode 3/4 to an INTER cell!\n");
- return AVERROR_INVALIDDATA;
- }
-
- zoom_fac = mode >= 3;
- error = decode_cell_data(ctx, cell, block, ref_block, plane->pitch,
- 0, zoom_fac, mode, delta, swap_quads,
- &data_ptr, last_ptr);
- break;
- case 10: /*-------------------- MODE 10 (8x8 block processing) ---------------------*/
- case 11: /*----------------- MODE 11 (4x8 INTER block processing) ------------------*/
- if (mode == 10 && !cell->mv_ptr) { /* MODE 10 INTRA processing */
- error = decode_cell_data(ctx, cell, block, ref_block, plane->pitch,
- 1, 1, mode, delta, swap_quads,
- &data_ptr, last_ptr);
- } else { /* mode 10 and 11 INTER processing */
- if (mode == 11 && !cell->mv_ptr) {
- av_log(avctx, AV_LOG_ERROR, "Attempt to use Mode 11 for an INTRA cell!\n");
- return AVERROR_INVALIDDATA;
- }
-
- zoom_fac = mode == 10;
- error = decode_cell_data(ctx, cell, block, ref_block, plane->pitch,
- zoom_fac, 1, mode, delta, swap_quads,
- &data_ptr, last_ptr);
- }
- break;
- default:
- av_log(avctx, AV_LOG_ERROR, "Unsupported coding mode: %d\n", mode);
- return AVERROR_INVALIDDATA;
- }//switch mode
-
- switch (error) {
- case IV3_BAD_RLE:
- av_log(avctx, AV_LOG_ERROR, "Mode %d: RLE code %X is not allowed at the current line\n",
- mode, data_ptr[-1]);
- return AVERROR_INVALIDDATA;
- case IV3_BAD_DATA:
- av_log(avctx, AV_LOG_ERROR, "Mode %d: invalid VQ data\n", mode);
- return AVERROR_INVALIDDATA;
- case IV3_BAD_COUNTER:
- av_log(avctx, AV_LOG_ERROR, "Mode %d: RLE-FB invalid counter: %d\n", mode, code);
- return AVERROR_INVALIDDATA;
- case IV3_UNSUPPORTED:
- av_log(avctx, AV_LOG_ERROR, "Mode %d: unsupported RLE code: %X\n", mode, data_ptr[-1]);
- return AVERROR_INVALIDDATA;
- case IV3_OUT_OF_DATA:
- av_log(avctx, AV_LOG_ERROR, "Mode %d: attempt to read past end of buffer\n", mode);
- return AVERROR_INVALIDDATA;
- }
-
- return data_ptr - data_start; /* report number of bytes consumed from the input buffer */
-}
-
-
-/* Binary tree codes. */
-enum {
- H_SPLIT = 0,
- V_SPLIT = 1,
- INTRA_NULL = 2,
- INTER_DATA = 3
-};
-
-
-#define SPLIT_CELL(size, new_size) (new_size) = ((size) > 2) ? ((((size) + 2) >> 2) << 1) : 1
-
-#define UPDATE_BITPOS(n) \
- ctx->skip_bits += (n); \
- ctx->need_resync = 1
-
-#define RESYNC_BITSTREAM \
- if (ctx->need_resync && !(get_bits_count(&ctx->gb) & 7)) { \
- skip_bits_long(&ctx->gb, ctx->skip_bits); \
- ctx->skip_bits = 0; \
- ctx->need_resync = 0; \
- }
-
-#define CHECK_CELL \
- if (curr_cell.xpos + curr_cell.width > (plane->width >> 2) || \
- curr_cell.ypos + curr_cell.height > (plane->height >> 2)) { \
- av_log(avctx, AV_LOG_ERROR, "Invalid cell: x=%d, y=%d, w=%d, h=%d\n", \
- curr_cell.xpos, curr_cell.ypos, curr_cell.width, curr_cell.height); \
- return AVERROR_INVALIDDATA; \
- }
-
-
-static int parse_bintree(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
- Plane *plane, int code, Cell *ref_cell,
- const int depth, const int strip_width)
-{
- Cell curr_cell;
- int bytes_used;
- int mv_x, mv_y;
-
- if (depth <= 0) {
- av_log(avctx, AV_LOG_ERROR, "Stack overflow (corrupted binary tree)!\n");
- return AVERROR_INVALIDDATA; // unwind recursion
- }
-
- curr_cell = *ref_cell; // clone parent cell
- if (code == H_SPLIT) {
- SPLIT_CELL(ref_cell->height, curr_cell.height);
- ref_cell->ypos += curr_cell.height;
- ref_cell->height -= curr_cell.height;
- if (ref_cell->height <= 0 || curr_cell.height <= 0)
- return AVERROR_INVALIDDATA;
- } else if (code == V_SPLIT) {
- if (curr_cell.width > strip_width) {
- /* split strip */
- curr_cell.width = (curr_cell.width <= (strip_width << 1) ? 1 : 2) * strip_width;
- } else
- SPLIT_CELL(ref_cell->width, curr_cell.width);
- ref_cell->xpos += curr_cell.width;
- ref_cell->width -= curr_cell.width;
- if (ref_cell->width <= 0 || curr_cell.width <= 0)
- return AVERROR_INVALIDDATA;
- }
-
- while (get_bits_left(&ctx->gb) >= 2) { /* loop until return */
- RESYNC_BITSTREAM;
- switch (code = get_bits(&ctx->gb, 2)) {
- case H_SPLIT:
- case V_SPLIT:
- if (parse_bintree(ctx, avctx, plane, code, &curr_cell, depth - 1, strip_width))
- return AVERROR_INVALIDDATA;
- break;
- case INTRA_NULL:
- if (!curr_cell.tree) { /* MC tree INTRA code */
- curr_cell.mv_ptr = 0; /* mark the current strip as INTRA */
- curr_cell.tree = 1; /* enter the VQ tree */
- } else { /* VQ tree NULL code */
- RESYNC_BITSTREAM;
- code = get_bits(&ctx->gb, 2);
- if (code >= 2) {
- av_log(avctx, AV_LOG_ERROR, "Invalid VQ_NULL code: %d\n", code);
- return AVERROR_INVALIDDATA;
- }
- if (code == 1)
- av_log(avctx, AV_LOG_ERROR, "SkipCell procedure not implemented yet!\n");
-
- CHECK_CELL
- if (!curr_cell.mv_ptr)
- return AVERROR_INVALIDDATA;
-
- mv_y = curr_cell.mv_ptr[0];
- mv_x = curr_cell.mv_ptr[1];
- if ( mv_x + 4*curr_cell.xpos < 0
- || mv_y + 4*curr_cell.ypos < 0
- || mv_x + 4*curr_cell.xpos + 4*curr_cell.width > plane->width
- || mv_y + 4*curr_cell.ypos + 4*curr_cell.height > plane->height) {
- av_log(avctx, AV_LOG_ERROR, "motion vector %d %d outside reference\n", mv_x + 4*curr_cell.xpos, mv_y + 4*curr_cell.ypos);
- return AVERROR_INVALIDDATA;
- }
-
- copy_cell(ctx, plane, &curr_cell);
- return 0;
- }
- break;
- case INTER_DATA:
- if (!curr_cell.tree) { /* MC tree INTER code */
- unsigned mv_idx;
- /* get motion vector index and setup the pointer to the mv set */
- if (!ctx->need_resync)
- ctx->next_cell_data = &ctx->gb.buffer[(get_bits_count(&ctx->gb) + 7) >> 3];
- if (ctx->next_cell_data >= ctx->last_byte) {
- av_log(avctx, AV_LOG_ERROR, "motion vector out of array\n");
- return AVERROR_INVALIDDATA;
- }
- mv_idx = *(ctx->next_cell_data++);
- if (mv_idx >= ctx->num_vectors) {
- av_log(avctx, AV_LOG_ERROR, "motion vector index out of range\n");
- return AVERROR_INVALIDDATA;
- }
- curr_cell.mv_ptr = &ctx->mc_vectors[mv_idx << 1];
- curr_cell.tree = 1; /* enter the VQ tree */
- UPDATE_BITPOS(8);
- } else { /* VQ tree DATA code */
- if (!ctx->need_resync)
- ctx->next_cell_data = &ctx->gb.buffer[(get_bits_count(&ctx->gb) + 7) >> 3];
-
- CHECK_CELL
- bytes_used = decode_cell(ctx, avctx, plane, &curr_cell,
- ctx->next_cell_data, ctx->last_byte);
- if (bytes_used < 0)
- return AVERROR_INVALIDDATA;
-
- UPDATE_BITPOS(bytes_used << 3);
- ctx->next_cell_data += bytes_used;
- return 0;
- }
- break;
- }
- }//while
-
- return AVERROR_INVALIDDATA;
-}
-
-
-static int decode_plane(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
- Plane *plane, const uint8_t *data, int32_t data_size,
- int32_t strip_width)
-{
- Cell curr_cell;
- unsigned num_vectors;
-
- /* each plane data starts with mc_vector_count field, */
- /* an optional array of motion vectors followed by the vq data */
- num_vectors = bytestream_get_le32(&data); data_size -= 4;
- if (num_vectors > 256) {
- av_log(ctx->avctx, AV_LOG_ERROR,
- "Read invalid number of motion vectors %d\n", num_vectors);
- return AVERROR_INVALIDDATA;
- }
- if (num_vectors * 2 > data_size)
- return AVERROR_INVALIDDATA;
-
- ctx->num_vectors = num_vectors;
- ctx->mc_vectors = num_vectors ? data : 0;
-
- /* init the bitreader */
- init_get_bits(&ctx->gb, &data[num_vectors * 2], (data_size - num_vectors * 2) << 3);
- ctx->skip_bits = 0;
- ctx->need_resync = 0;
-
- ctx->last_byte = data + data_size;
-
- /* initialize the 1st cell and set its dimensions to whole plane */
- curr_cell.xpos = curr_cell.ypos = 0;
- curr_cell.width = plane->width >> 2;
- curr_cell.height = plane->height >> 2;
- curr_cell.tree = 0; // we are in the MC tree now
- curr_cell.mv_ptr = 0; // no motion vector = INTRA cell
-
- return parse_bintree(ctx, avctx, plane, INTRA_NULL, &curr_cell, CELL_STACK_MAX, strip_width);
-}
-
-
-#define OS_HDR_ID MKBETAG('F', 'R', 'M', 'H')
-
-static int decode_frame_headers(Indeo3DecodeContext *ctx, AVCodecContext *avctx,
- const uint8_t *buf, int buf_size)
-{
- const uint8_t *buf_ptr = buf, *bs_hdr;
- uint32_t frame_num, word2, check_sum, data_size;
- uint32_t y_offset, u_offset, v_offset, starts[3], ends[3];
- uint16_t height, width;
- int i, j;
-
- /* parse and check the OS header */
- frame_num = bytestream_get_le32(&buf_ptr);
- word2 = bytestream_get_le32(&buf_ptr);
- check_sum = bytestream_get_le32(&buf_ptr);
- data_size = bytestream_get_le32(&buf_ptr);
-
- if ((frame_num ^ word2 ^ data_size ^ OS_HDR_ID) != check_sum) {
- av_log(avctx, AV_LOG_ERROR, "OS header checksum mismatch!\n");
- return AVERROR_INVALIDDATA;
- }
-
- /* parse the bitstream header */
- bs_hdr = buf_ptr;
- buf_size -= 16;
-
- if (bytestream_get_le16(&buf_ptr) != 32) {
- av_log(avctx, AV_LOG_ERROR, "Unsupported codec version!\n");
- return AVERROR_INVALIDDATA;
- }
-
- ctx->frame_num = frame_num;
- ctx->frame_flags = bytestream_get_le16(&buf_ptr);
- ctx->data_size = (bytestream_get_le32(&buf_ptr) + 7) >> 3;
- ctx->cb_offset = *buf_ptr++;
-
- if (ctx->data_size == 16)
- return 4;
- if (ctx->data_size > buf_size)
- ctx->data_size = buf_size;
-
- buf_ptr += 3; // skip reserved byte and checksum
-
- /* check frame dimensions */
- height = bytestream_get_le16(&buf_ptr);
- width = bytestream_get_le16(&buf_ptr);
- if (av_image_check_size(width, height, 0, avctx))
- return AVERROR_INVALIDDATA;
-
- if (width != ctx->width || height != ctx->height) {
- int res;
-
- av_dlog(avctx, "Frame dimensions changed!\n");
-
- if (width < 16 || width > 640 ||
- height < 16 || height > 480 ||
- width & 3 || height & 3) {
- av_log(avctx, AV_LOG_ERROR,
- "Invalid picture dimensions: %d x %d!\n", width, height);
- return AVERROR_INVALIDDATA;
- }
- free_frame_buffers(ctx);
- if ((res = allocate_frame_buffers(ctx, avctx, width, height)) < 0)
- return res;
- avcodec_set_dimensions(avctx, width, height);
- }
-
- y_offset = bytestream_get_le32(&buf_ptr);
- v_offset = bytestream_get_le32(&buf_ptr);
- u_offset = bytestream_get_le32(&buf_ptr);
-
- /* unfortunately there is no common order of planes in the buffer */
- /* so we use that sorting algo for determining planes data sizes */
- starts[0] = y_offset;
- starts[1] = v_offset;
- starts[2] = u_offset;
-
- for (j = 0; j < 3; j++) {
- ends[j] = ctx->data_size;
- for (i = 2; i >= 0; i--)
- if (starts[i] < ends[j] && starts[i] > starts[j])
- ends[j] = starts[i];
- }
-
- ctx->y_data_size = ends[0] - starts[0];
- ctx->v_data_size = ends[1] - starts[1];
- ctx->u_data_size = ends[2] - starts[2];
- if (FFMAX3(y_offset, v_offset, u_offset) >= ctx->data_size - 16 ||
- FFMIN3(ctx->y_data_size, ctx->v_data_size, ctx->u_data_size) <= 0) {
- av_log(avctx, AV_LOG_ERROR, "One of the y/u/v offsets is invalid\n");
- return AVERROR_INVALIDDATA;
- }
-
- ctx->y_data_ptr = bs_hdr + y_offset;
- ctx->v_data_ptr = bs_hdr + v_offset;
- ctx->u_data_ptr = bs_hdr + u_offset;
- ctx->alt_quant = buf_ptr + sizeof(uint32_t);
-
- if (ctx->data_size == 16) {
- av_log(avctx, AV_LOG_DEBUG, "Sync frame encountered!\n");
- return 16;
- }
-
- if (ctx->frame_flags & BS_8BIT_PEL) {
- av_log_ask_for_sample(avctx, "8-bit pixel format\n");
- return AVERROR_PATCHWELCOME;
- }
-
- if (ctx->frame_flags & BS_MV_X_HALF || ctx->frame_flags & BS_MV_Y_HALF) {
- av_log_ask_for_sample(avctx, "halfpel motion vectors\n");
- return AVERROR_PATCHWELCOME;
- }
-
- return 0;
-}
-
-
-/**
- * Convert and output the current plane.
- * All pixel values will be upsampled by shifting right by one bit.
- *
- * @param[in] plane pointer to the descriptor of the plane being processed
- * @param[in] buf_sel indicates which frame buffer the input data stored in
- * @param[out] dst pointer to the buffer receiving converted pixels
- * @param[in] dst_pitch pitch for moving to the next y line
- * @param[in] dst_height output plane height
- */
-static void output_plane(const Plane *plane, int buf_sel, uint8_t *dst,
- int dst_pitch, int dst_height)
-{
- int x,y;
- const uint8_t *src = plane->pixels[buf_sel];
- uint32_t pitch = plane->pitch;
-
- dst_height = FFMIN(dst_height, plane->height);
- for (y = 0; y < dst_height; y++) {
- /* convert four pixels at once using SWAR */
- for (x = 0; x < plane->width >> 2; x++) {
- AV_WN32A(dst, (AV_RN32A(src) & 0x7F7F7F7F) << 1);
- src += 4;
- dst += 4;
- }
-
- for (x <<= 2; x < plane->width; x++)
- *dst++ = *src++ << 1;
-
- src += pitch - plane->width;
- dst += dst_pitch - plane->width;
- }
-}
-
-
-static av_cold int decode_init(AVCodecContext *avctx)
-{
- Indeo3DecodeContext *ctx = avctx->priv_data;
-
- ctx->avctx = avctx;
- avctx->pix_fmt = AV_PIX_FMT_YUV410P;
- avcodec_get_frame_defaults(&ctx->frame);
-
- build_requant_tab();
-
- ff_dsputil_init(&ctx->dsp, avctx);
-
- return allocate_frame_buffers(ctx, avctx, avctx->width, avctx->height);
-}
-
-
-static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
- AVPacket *avpkt)
-{
- Indeo3DecodeContext *ctx = avctx->priv_data;
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
- int res;
-
- res = decode_frame_headers(ctx, avctx, buf, buf_size);
- if (res < 0)
- return res;
-
- /* skip sync(null) frames */
- if (res) {
- // we have processed 16 bytes but no data was decoded
- *got_frame = 0;
- return buf_size;
- }
-
- /* skip droppable INTER frames if requested */
- if (ctx->frame_flags & BS_NONREF &&
- (avctx->skip_frame >= AVDISCARD_NONREF))
- return 0;
-
- /* skip INTER frames if requested */
- if (!(ctx->frame_flags & BS_KEYFRAME) && avctx->skip_frame >= AVDISCARD_NONKEY)
- return 0;
-
- /* use BS_BUFFER flag for buffer switching */
- ctx->buf_sel = (ctx->frame_flags >> BS_BUFFER) & 1;
-
- if (ctx->frame.data[0])
- avctx->release_buffer(avctx, &ctx->frame);
-
- ctx->frame.reference = 0;
- if ((res = ff_get_buffer(avctx, &ctx->frame)) < 0) {
- av_log(ctx->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return res;
- }
-
- /* decode luma plane */
- if ((res = decode_plane(ctx, avctx, ctx->planes, ctx->y_data_ptr, ctx->y_data_size, 40)))
- return res;
-
- /* decode chroma planes */
- if ((res = decode_plane(ctx, avctx, &ctx->planes[1], ctx->u_data_ptr, ctx->u_data_size, 10)))
- return res;
-
- if ((res = decode_plane(ctx, avctx, &ctx->planes[2], ctx->v_data_ptr, ctx->v_data_size, 10)))
- return res;
-
- output_plane(&ctx->planes[0], ctx->buf_sel,
- ctx->frame.data[0], ctx->frame.linesize[0],
- avctx->height);
- output_plane(&ctx->planes[1], ctx->buf_sel,
- ctx->frame.data[1], ctx->frame.linesize[1],
- (avctx->height + 3) >> 2);
- output_plane(&ctx->planes[2], ctx->buf_sel,
- ctx->frame.data[2], ctx->frame.linesize[2],
- (avctx->height + 3) >> 2);
-
- *got_frame = 1;
- *(AVFrame*)data = ctx->frame;
-
- return buf_size;
-}
-
-
-static av_cold int decode_close(AVCodecContext *avctx)
-{
- Indeo3DecodeContext *ctx = avctx->priv_data;
-
- free_frame_buffers(avctx->priv_data);
-
- if (ctx->frame.data[0])
- avctx->release_buffer(avctx, &ctx->frame);
-
- return 0;
-}
-
-AVCodec ff_indeo3_decoder = {
- .name = "indeo3",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_INDEO3,
- .priv_data_size = sizeof(Indeo3DecodeContext),
- .init = decode_init,
- .close = decode_close,
- .decode = decode_frame,
- .long_name = NULL_IF_CONFIG_SMALL("Intel Indeo 3"),
- .capabilities = CODEC_CAP_DR1,
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/indeo3data.h b/src/thirdparty/ffmpeg/libavcodec/indeo3data.h
deleted file mode 100644
index 22a8a80a1..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/indeo3data.h
+++ /dev/null
@@ -1,362 +0,0 @@
-/*
- * Indeo Video v3 compatible decoder
- * Copyright (c) 2009 - 2011 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_INDEO3DATA_H
-#define AVCODEC_INDEO3DATA_H
-
-#include <stdint.h>
-
-#include "config.h"
-
-/*
- * Define compressed VQ tables.
- */
-
-#define TAB_1_1 \
- PD( 0, 0), E2( 2, 2), E4( -1, 3), E2( 4, 4), E4( 1, 5),\
- E2( -4, 4), E4( -2, 6), E4( 4, 9), E2( 9, 9), E4( 1, 10),\
- E4( -5, 8), E4( 9, 15), E4( -3, 12), E4( 4, 16), E2( 16, 16),\
- E4( 0, 18), E2( -12, 12), E4( -9, 16), E4( 11, 27), E4( 19, 28),\
- E4( -6, 22), E4( 4, 29), E2( 30, 30), E4( -2, 33), E4( -18, 23),\
- E4( -15, 30), E4( 22, 46), E4( 13, 47), E4( 35, 49), E4( -11, 41),\
- E4( 4, 51), E2( 54, 54), E2( -34, 34), E4( -29, 42), E4( -6, 60),\
- E4( 27, 76), E4( 43, 77), E4( -24, 55), E4( 14, 79), E4( 63, 83),\
- E4( -20, 74), E4( 2, 88), E2( 93, 93), E4( -52, 61), E4( 52, 120),\
- E4( -45, 75), E4( 75, 125), E4( 33, 122), E4( -13, 103), E4( -40, 96),\
- E4( -34, 127), E2( -89, 89), E4( -78, 105), E2( 12, 12), E2( 23, 23),\
- E2( 42, 42), E2( 73, 73)
-
-#define TAB_1_2 \
- PD( 0, 0), E2( 3, 3), E4( -1, 4), E2( 7, 7), E4( 2, 8),\
- E4( -2, 9), E2( -6, 6), E4( 6, 13), E2( 13, 13), E4( 1, 14),\
- E4( -8, 12), E4( 14, 23), E4( -5, 18), E4( 6, 24), E2( 24, 24),\
- E4( -1, 27), E2( -17, 17), E4( -13, 23), E4( 16, 40), E4( 28, 41),\
- E4( -9, 33), E4( 6, 43), E2( 46, 46), E4( -4, 50), E4( -27, 34),\
- E4( -22, 45), E4( 34, 69), E4( 19, 70), E4( 53, 73), E4( -17, 62),\
- E4( 5, 77), E2( 82, 82), E2( -51, 51), E4( -43, 64), E4( -10, 90),\
- E4( 41, 114), E4( 64, 116), E4( -37, 82), E4( 22, 119), E4( 95, 124),\
- E4( -30, 111), E4( -78, 92), E4( -68, 113), E2( 18, 18), E2( 34, 34),\
- E2( 63, 63), E2( 109, 109)
-
-#define TAB_1_3 \
- PD( 0, 0), E2( 4, 4), E4( -1, 5), E4( 3, 10), E2( 9, 9),\
- E2( -7, 7), E4( -3, 12), E4( 8, 17), E2( 17, 17), E4( 1, 19),\
- E4( -11, 16), E4( -6, 23), E4( 18, 31), E4( 8, 32), E2( 33, 33),\
- E4( -1, 36), E2( -23, 23), E4( -17, 31), E4( 21, 54), E4( 37, 55),\
- E4( -12, 44), E4( 8, 57), E2( 61, 61), E4( -5, 66), E4( -36, 45),\
- E4( -29, 60), E4( 45, 92), E4( 25, 93), E4( 71, 97), E4( -22, 83),\
- E4( 7, 102), E2( 109, 109), E2( -68, 68), E4( -57, 85), E4( -13, 120),\
- E4( -49, 110), E4(-104, 123), E2( 24, 24), E2( 46, 46), E2( 84, 84)
-
-#define TAB_1_4 \
- PD( 0, 0), E2( 5, 5), E4( -2, 7), E2( 11, 11), E4( 3, 13),\
- E2( -9, 9), E4( -4, 15), E4( 11, 22), E2( 21, 21), E4( 2, 24),\
- E4( -14, 20), E4( 23, 38), E4( -8, 29), E4( 11, 39), E2( 41, 41),\
- E4( -1, 45), E2( -29, 29), E4( -22, 39), E4( 27, 67), E4( 47, 69),\
- E4( -15, 56), E4( 11, 71), E2( 76, 76), E4( -6, 83), E4( -45, 57),\
- E4( -36, 75), E4( 56, 115), E4( 31, 117), E4( 88, 122), E4( -28, 104),\
- E2( -85, 85), E4( -72, 106), E2( 30, 30), E2( 58, 58), E2( 105, 105)
-
-#define TAB_1_5 \
- PD( 0, 0), E2( 6, 6), E4( -2, 8), E2( 13, 13), E4( 4, 15),\
- E2( -11, 11), E4( -5, 18), E4( 13, 26), E2( 26, 26), E4( 2, 29),\
- E4( -16, 24), E4( 28, 46), E4( -9, 35), E4( 13, 47), E2( 49, 49),\
- E4( -1, 54), E2( -35, 35), E4( -26, 47), E4( 32, 81), E4( 56, 83),\
- E4( -18, 67), E4( 13, 86), E2( 91, 91), E4( -7, 99), E4( -54, 68),\
- E4( -44, 90), E4( -33, 124), E2(-103, 103), E4( -86, 127), E2( 37, 37),\
- E2( 69, 69)
-
-#define TAB_1_6 \
- PD( 0, 0), E2( 7, 7), E4( -3, 10), E2( 16, 16), E4( 5, 18),\
- E2( -13, 13), E4( -6, 21), E4( 15, 30), E2( 30, 30), E4( 2, 34),\
- E4( -19, 28), E4( 32, 54), E4( -11, 41), E4( 15, 55), E2( 57, 57),\
- E4( -1, 63), E2( -40, 40), E4( -30, 55), E4( 37, 94), E4( 65, 96),\
- E4( -21, 78), E4( 15, 100), E2( 106, 106), E4( -8, 116), E4( -63, 79),\
- E4( -51, 105), E2(-120, 120), E2( 43, 43), E2( 80, 80)
-
-#define TAB_1_7 \
- PD( 0, 0), E2( 8, 8), E4( -3, 11), E2( 18, 18), E4( 5, 20),\
- E2( -15, 15), E4( -7, 24), E4( 17, 35), E2( 34, 34), E4( 3, 38),\
- E4( -22, 32), E4( 37, 61), E4( -13, 47), E4( 17, 63), E2( 65, 65),\
- E4( -1, 72), E2( -46, 46), E4( -35, 63), E4( 43, 107), E4( 75, 110),\
- E4( -24, 89), E4( 17, 114), E2( 121, 121), E4( -72, 91), E4( -58, 120),\
- E2( 49, 49), E2( 92, 92)
-
-#define TAB_1_8 \
- PD( 0, 0), E2( 9, 9), E4( -3, 12), E2( 20, 20), E4( 6, 23),\
- E2( -17, 17), E4( -7, 27), E4( 19, 39), E2( 39, 39), E4( 3, 43),\
- E4( -24, 36), E4( 42, 69), E4( -14, 53), E4( 19, 71), E2( 73, 73),\
- E4( -2, 80), E2( -52, 52), E4( -39, 70), E4( 48, 121), E4( 84, 124),\
- E4( -27, 100), E4( -81, 102), E2( 55, 55), E2( 104, 104)
-
-#define TAB_2_1 \
- PD( 0, 0), E2( 2, 2), E4( 0, 2), E2( 4, 4), E4( 0, 4),\
- E2( -4, 4), E4( -2, 6), E4( 4, 8), E2( 8, 8), E4( 0, 10),\
- E4( -4, 8), E4( 8, 14), E4( -2, 12), E4( 4, 16), E2( 16, 16),\
- E4( 0, 18), E2( -12, 12), E4( -8, 16), E4( 10, 26), E4( 18, 28),\
- E4( -6, 22), E4( 4, 28), E2( 30, 30), E4( -2, 32), E4( -18, 22),\
- E4( -14, 30), E4( 22, 46), E4( 12, 46), E4( 34, 48), E4( -10, 40),\
- E4( 4, 50), E2( 54, 54), E2( -34, 34), E4( -28, 42), E4( -6, 60),\
- E4( 26, 76), E4( 42, 76), E4( -24, 54), E4( 14, 78), E4( 62, 82),\
- E4( -20, 74), E4( 2, 88), E2( 92, 92), E4( -52, 60), E4( 52, 118),\
- E4( -44, 74), E4( 74, 118), E4( 32, 118), E4( -12, 102), E4( -40, 96),\
- E4( -34, 118), E2( -88, 88), E4( -78, 104), E2( 12, 12), E2( 22, 22),\
- E2( 42, 42), E2( 72, 72)
-
-#define TAB_2_2 \
- PD( 0, 0), E2( 3, 3), E4( 0, 3), E2( 6, 6), E4( 3, 9),\
- E4( -3, 9), E2( -6, 6), E4( 6, 12), E2( 12, 12), E4( 0, 15),\
- E4( -9, 12), E4( 15, 24), E4( -6, 18), E4( 6, 24), E2( 24, 24),\
- E4( 0, 27), E2( -18, 18), E4( -12, 24), E4( 15, 39), E4( 27, 42),\
- E4( -9, 33), E4( 6, 42), E2( 45, 45), E4( -3, 51), E4( -27, 33),\
- E4( -21, 45), E4( 33, 69), E4( 18, 69), E4( 54, 72), E4( -18, 63),\
- E4( 6, 78), E2( 81, 81), E2( -51, 51), E4( -42, 63), E4( -9, 90),\
- E4( 42, 114), E4( 63, 117), E4( -36, 81), E4( 21, 120), E4( 96, 123),\
- E4( -30, 111), E4( -78, 93), E4( -69, 114), E2( 18, 18), E2( 33, 33),\
- E2( 63, 63), E2( 108, 108)
-
-#define TAB_2_3 \
- PD( 0, 0), E2( 4, 4), E4( 0, 4), E4( 4, 8), E2( 8, 8),\
- E2( -8, 8), E4( -4, 12), E4( 8, 16), E2( 16, 16), E4( 0, 20),\
- E4( -12, 16), E4( -4, 24), E4( 16, 32), E4( 8, 32), E2( 32, 32),\
- E4( 0, 36), E2( -24, 24), E4( -16, 32), E4( 20, 52), E4( 36, 56),\
- E4( -12, 44), E4( 8, 56), E2( 60, 60), E4( -4, 64), E4( -36, 44),\
- E4( -28, 60), E4( 44, 92), E4( 24, 92), E4( 72, 96), E4( -20, 84),\
- E4( 8, 100), E2( 108, 108), E2( -68, 68), E4( -56, 84), E4( -12, 120),\
- E4( -48, 108), E4(-104, 124), E2( 24, 24), E2( 44, 44), E2( 84, 84)
-
-#define TAB_2_4 \
- PD( 0, 0), E2( 5, 5), E4( 0, 5), E2( 10, 10), E4( 5, 15),\
- E2( -10, 10), E4( -5, 15), E4( 10, 20), E2( 20, 20), E4( 0, 25),\
- E4( -15, 20), E4( 25, 40), E4( -10, 30), E4( 10, 40), E2( 40, 40),\
- E4( 0, 45), E2( -30, 30), E4( -20, 40), E4( 25, 65), E4( 45, 70),\
- E4( -15, 55), E4( 10, 70), E2( 75, 75), E4( -5, 85), E4( -45, 55),\
- E4( -35, 75), E4( 55, 115), E4( 30, 115), E4( 90, 120), E4( -30, 105),\
- E2( -85, 85), E4( -70, 105), E2( 30, 30), E2( 60, 60), E2( 105, 105)
-
-#define TAB_2_5 \
- PD( 0, 0), E2( 6, 6), E4( 0, 6), E2( 12, 12), E4( 6, 12),\
- E2( -12, 12), E4( -6, 18), E4( 12, 24), E2( 24, 24), E4( 0, 30),\
- E4( -18, 24), E4( 30, 48), E4( -6, 36), E4( 12, 48), E2( 48, 48),\
- E4( 0, 54), E2( -36, 36), E4( -24, 48), E4( 30, 78), E4( 54, 84),\
- E4( -18, 66), E4( 12, 84), E2( 90, 90), E4( -6, 96), E4( -54, 66),\
- E4( -42, 90), E4( -30, 126), E2(-102, 102), E4( -84, 126), E2( 36, 36),\
- E2( 66, 66)
-
-#define TAB_2_6 \
- PD( 0, 0), E2( 7, 7), E4( 0, 7), E2( 14, 14), E4( 7, 21),\
- E2( -14, 14), E4( -7, 21), E4( 14, 28), E2( 28, 28), E4( 0, 35),\
- E4( -21, 28), E4( 35, 56), E4( -14, 42), E4( 14, 56), E2( 56, 56),\
- E4( 0, 63), E2( -42, 42), E4( -28, 56), E4( 35, 91), E4( 63, 98),\
- E4( -21, 77), E4( 14, 98), E2( 105, 105), E4( -7, 119), E4( -63, 77),\
- E4( -49, 105), E2(-119, 119), E2( 42, 42), E2( 77, 77)
-
-#define TAB_2_7 \
- PD( 0, 0), E2( 8, 8), E4( 0, 8), E2( 16, 16), E4( 8, 16),\
- E2( -16, 16), E4( -8, 24), E4( 16, 32), E2( 32, 32), E4( 0, 40),\
- E4( -24, 32), E4( 40, 64), E4( -16, 48), E4( 16, 64), E2( 64, 64),\
- E4( 0, 72), E2( -48, 48), E4( -32, 64), E4( 40, 104), E4( 72, 112),\
- E4( -24, 88), E4( 16, 112), E2( 120, 120), E4( -72, 88), E4( -56, 120),\
- E2( 48, 48), E2( 88, 88)
-
-#define TAB_2_8 \
- PD( 0, 0), E2( 9, 9), E4( 0, 9), E2( 18, 18), E4( 9, 27),\
- E2( -18, 18), E4( -9, 27), E4( 18, 36), E2( 36, 36), E4( 0, 45),\
- E4( -27, 36), E4( 45, 72), E4( -18, 54), E4( 18, 72), E2( 72, 72),\
- E4( 0, 81), E2( -54, 54), E4( -36, 72), E4( 45, 117), E4( 81, 126),\
- E4( -27, 99), E4( -81, 99), E2( 54, 54), E2( 108, 108)
-
-#define TAB_3_1 \
- PD( 0, 0), E2( 2, 2), E4( 0, 3), E2( 6, 6), E4( 0, 7),\
- E2( -5, 5), E2( 5, -5), E4( 6, 11), E4( 0, 8), E2( 11, 11),\
- E4( 0, 12), E4( 12, 17), E2( 17, 17), E4( 6, 18), E4( -8, 11),\
- E4( 0, 15), E4( 0, 20), E4( 18, 25), E4( 11, 25), E2( 25, 25),\
- E2( -14, 14), E2( 14, -14), E4( 0, 26), E4( -11, 18), E4( -7, 22),\
- E4( 26, 34), E4( 18, 34), E2( 34, 34), E4( 11, 35), E4( 0, 29),\
- E4( -19, 22), E4( -15, 26), E4( 0, 37), E4( 27, 44), E4( 36, 44),\
- E4( 18, 44), E4( -10, 33), E2( 45, 45)
-
-#define TAB_3_2 \
- PD( 0, 0), E4( 0, 2), E2( 2, 2), E2( 6, 6), E4( 0, 6),\
- E2( -4, 4), E2( 10, -6), E2( 0, -12), PD( -6, -12), E2( 6, -12),\
- PD( 6, 12), E2( -14, 0), E2( 12, 12), E2( 0, -18), E2( 14, -12),\
- PD( -18, -6), E2( 18, -6), PD( 18, 6), PD( -10, -18), E2( 10, -18),\
- PD( 10, 18), E2( -22, 0), E2( 0, -24), PD( -22, -12), E2( 22, -12),\
- PD( 22, 12), PD( -8, -24), E2( 8, -24), PD( 8, 24), PD( -26, -6),\
- E2( 26, -6), PD( 26, 6), E2( -28, 0), E2( 20, 20), E2( -14, -26),\
- E2( -30, -12), E2( -10, -32), E2( -18, -32), E2( -26, -26), E2( -34, -20),\
- E2( -38, -12), E2( -32, -32), PD( 32, 32), PD( -22, -40), E2( -34, -34)
-
-#define TAB_3_3 \
- PD( 0, 0), E4( 0, 2), E2( 4, 4), E2( 10, 10), E4( 0, 10),\
- E2( -6, 6), E2( 14, -8), E2( -18, 0), E2( 10, -16), E2( 0, -24),\
- PD( -24, -8), E2( 24, -8), PD( 24, 8), E2( 18, 18), E2( 20, -16),\
- PD( -14, -26), E2( 14, -26), PD( 14, 26), E2( -30, 0), E2( 0, -34),\
- PD( -34, -8), E2( 34, -8), PD( 34, 8), PD( -30, -18), E2( 30, -18),\
- PD( 30, 18), PD( -10, -34), E2( 10, -34), PD( 10, 34), E2( -20, -34),\
- E2( -40, 0), E2( 30, 30), E2( -40, -18), E2( 0, -44), E2( -16, -44),\
- PD( -36, -36), E2( -36, -36), E2( -26, -44), E2( -46, -26), E2( -52, -18),\
- PD( -20, -54), E2( -44, -44), PD( -32, -54), PD( -46, -46), E2( -46, -46)
-
-#define TAB_3_4 \
- PD( 0, 0), E4( 0, 4), E2( 4, 4), E2( 12, 12), E4( 0, 12),\
- E2( -8, 8), E2( 8, -16), E2( 0, -24), PD( -24, -8), E2( 24, -8),\
- PD( 24, 8), E2( 20, -16), E2( -28, 0), PD( -16, -24), E2( 16, -24),\
- PD( 16, 24), E2( 0, -32), PD( -28, -16), E2( 28, -16), PD( 28, 16),\
- PD( -8, -32), PD( 8, -32), PD( -32, -8), E2( 32, -8), PD( 32, 8),\
- PD( -8, 32), PD( 8, 32), E2( 24, 24), E2( 24, -24), E2( -20, -32),\
- E2( -40, 0), E2( -40, -16), PD( 0, -44), PD( 0, -44), E2( -44, 0),\
- PD( 0, 44), PD( 0, 44), E2( -32, -32), E2( -16, -44), PD( -24, -44),\
- E2( -44, -24), PD( 24, 44), E2( -48, -16), PD( -36, -36), E2( -36, -36),\
- PD( 36, 36), PD( -20, -52), E2( 40, 40), PD( -32, -52)
-
-#define TAB_3_5 \
- PD( 0, 0), E2( 2, 2), E2( 6, 6), E2( 12, 12), E2( 20, 20),\
- E2( 32, 32), E2( 46, 46)
-
-
-/**
- * Pack two delta values (a,b) into one 16bit word
- * according with endianness of the host machine.
- */
-#if HAVE_BIGENDIAN
-#define PD(a,b) (((a) << 8) + (b))
-#else
-#define PD(a,b) (((b) << 8) + (a))
-#endif
-
-/**
- * Expand a pair of delta values (a,b)
- * into two/four delta entries.
- */
-#define E2(a, b) PD(a, b), PD(-(a), -(b))
-#define E4(a, b) PD(a, b), PD(-(a), -(b)), PD(b, a), PD(-(b), -(a))
-
-/*
- * VQ tables for 4x4 block modes.
- * Let the compiler decompress and build the tables for us.
- */
-static const int16_t delta_tab_1_1[195] = { TAB_1_1 };
-static const int16_t delta_tab_1_2[159] = { TAB_1_2 };
-static const int16_t delta_tab_1_3[133] = { TAB_1_3 };
-static const int16_t delta_tab_1_4[115] = { TAB_1_4 };
-static const int16_t delta_tab_1_5[101] = { TAB_1_5 };
-static const int16_t delta_tab_1_6[93] = { TAB_1_6 };
-static const int16_t delta_tab_1_7[87] = { TAB_1_7 };
-static const int16_t delta_tab_1_8[77] = { TAB_1_8 };
-
-static const int16_t delta_tab_2_1[195] = { TAB_2_1 };
-static const int16_t delta_tab_2_2[159] = { TAB_2_2 };
-static const int16_t delta_tab_2_3[133] = { TAB_2_3 };
-static const int16_t delta_tab_2_4[115] = { TAB_2_4 };
-static const int16_t delta_tab_2_5[101] = { TAB_2_5 };
-static const int16_t delta_tab_2_6[93] = { TAB_2_6 };
-static const int16_t delta_tab_2_7[87] = { TAB_2_7 };
-static const int16_t delta_tab_2_8[77] = { TAB_2_8 };
-
-static const int16_t delta_tab_3_1[128] = { TAB_3_1 };
-static const int16_t delta_tab_3_2[79] = { TAB_3_2 };
-static const int16_t delta_tab_3_3[79] = { TAB_3_3 };
-static const int16_t delta_tab_3_4[79] = { TAB_3_4 };
-static const int16_t delta_tab_3_5[79] = { TAB_3_5 };
-
-#undef PD
-
-/**
- * Pack four delta values (a,a,b,b) into one 32bit word
- * according with endianness of the host machine.
- */
-#if HAVE_BIGENDIAN
-#define PD(a,b) (((a) << 24) + ((a) << 16) + ((b) << 8) + (b))
-#else
-#define PD(a,b) (((b) << 24) + ((b) << 16) + ((a) << 8) + (a))
-#endif
-
-/*
- * VQ tables for 8x8 block modes.
- * Those are based on the same delta tables by using
- * each value twice: ABCD --> AABBCCDD.
- */
-static const int32_t delta_tab_1_1_m10[195] = { TAB_1_1 };
-static const int32_t delta_tab_1_2_m10[159] = { TAB_1_2 };
-static const int32_t delta_tab_1_3_m10[133] = { TAB_1_3 };
-static const int32_t delta_tab_1_4_m10[115] = { TAB_1_4 };
-static const int32_t delta_tab_1_5_m10[101] = { TAB_1_5 };
-static const int32_t delta_tab_1_6_m10[93] = { TAB_1_6 };
-static const int32_t delta_tab_1_7_m10[87] = { TAB_1_7 };
-static const int32_t delta_tab_1_8_m10[77] = { TAB_1_8 };
-
-static const int32_t delta_tab_2_1_m10[195] = { TAB_2_1 };
-static const int32_t delta_tab_2_2_m10[159] = { TAB_2_2 };
-static const int32_t delta_tab_2_3_m10[133] = { TAB_2_3 };
-static const int32_t delta_tab_2_4_m10[115] = { TAB_2_4 };
-static const int32_t delta_tab_2_5_m10[101] = { TAB_2_5 };
-static const int32_t delta_tab_2_6_m10[93] = { TAB_2_6 };
-static const int32_t delta_tab_2_7_m10[87] = { TAB_2_7 };
-static const int32_t delta_tab_2_8_m10[77] = { TAB_2_8 };
-
-static const int32_t delta_tab_3_1_m10[128] = { TAB_3_1 };
-static const int32_t delta_tab_3_2_m10[79] = { TAB_3_2 };
-static const int32_t delta_tab_3_3_m10[79] = { TAB_3_3 };
-static const int32_t delta_tab_3_4_m10[79] = { TAB_3_4 };
-static const int32_t delta_tab_3_5_m10[79] = { TAB_3_5 };
-
-
-typedef struct vqEntry {
- const int16_t *deltas; ///< delta tables for 4x4 block modes
- const int32_t *deltas_m10; ///< delta tables for 8x8 block modes
- uint8_t num_dyads; ///< number of two-pixel deltas
- uint8_t quad_exp; ///< log2 of four-pixel deltas
-} vqEntry;
-
-static const vqEntry vq_tab[24] = {
- /* set 1 */
- { delta_tab_1_1, delta_tab_1_1_m10, 195, 7 },
- { delta_tab_1_2, delta_tab_1_2_m10, 159, 9 },
- { delta_tab_1_3, delta_tab_1_3_m10, 133, 10 },
- { delta_tab_1_4, delta_tab_1_4_m10, 115, 11 },
- { delta_tab_1_5, delta_tab_1_5_m10, 101, 12 },
- { delta_tab_1_6, delta_tab_1_6_m10, 93, 12 },
- { delta_tab_1_7, delta_tab_1_7_m10, 87, 12 },
- { delta_tab_1_8, delta_tab_1_8_m10, 77, 13 },
-
- /* set 2 */
- { delta_tab_2_1, delta_tab_2_1_m10, 195, 7 },
- { delta_tab_2_2, delta_tab_2_2_m10, 159, 9 },
- { delta_tab_2_3, delta_tab_2_3_m10, 133, 10 },
- { delta_tab_2_4, delta_tab_2_4_m10, 115, 11 },
- { delta_tab_2_5, delta_tab_2_5_m10, 101, 12 },
- { delta_tab_2_6, delta_tab_2_6_m10, 93, 12 },
- { delta_tab_2_7, delta_tab_2_7_m10, 87, 12 },
- { delta_tab_2_8, delta_tab_2_8_m10, 77, 13 },
-
- /* set 3 */
- { delta_tab_3_1, delta_tab_3_1_m10, 128, 11 },
- { delta_tab_3_2, delta_tab_3_2_m10, 79, 13 },
- { delta_tab_3_3, delta_tab_3_3_m10, 79, 13 },
- { delta_tab_3_4, delta_tab_3_4_m10, 79, 13 },
- { delta_tab_3_5, delta_tab_3_5_m10, 79, 13 },
- { delta_tab_3_5, delta_tab_3_5_m10, 79, 13 },
- { delta_tab_3_5, delta_tab_3_5_m10, 79, 13 },
- { delta_tab_3_5, delta_tab_3_5_m10, 79, 13 }
-};
-
-#endif /* AVCODEC_INDEO3DATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/indeo4.c b/src/thirdparty/ffmpeg/libavcodec/indeo4.c
deleted file mode 100644
index ee12691d8..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/indeo4.c
+++ /dev/null
@@ -1,660 +0,0 @@
-/*
- * Indeo Video Interactive v4 compatible decoder
- * Copyright (c) 2009-2011 Maxim Poliakovski
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * Indeo Video Interactive version 4 decoder
- *
- * Indeo 4 data is usually transported within .avi or .mov files.
- * Known FOURCCs: 'IV41'
- */
-
-#define BITSTREAM_READER_LE
-#include "avcodec.h"
-#include "get_bits.h"
-#include "dsputil.h"
-#include "ivi_dsp.h"
-#include "ivi_common.h"
-#include "indeo4data.h"
-
-/**
- * Indeo 4 frame types.
- */
-enum {
- FRAMETYPE_INTRA = 0,
- FRAMETYPE_INTRA1 = 1, ///< intra frame with slightly different bitstream coding
- FRAMETYPE_INTER = 2, ///< non-droppable P-frame
- FRAMETYPE_BIDIR = 3, ///< bidirectional frame
- FRAMETYPE_INTER_NOREF = 4, ///< droppable P-frame
- FRAMETYPE_NULL_FIRST = 5, ///< empty frame with no data
- FRAMETYPE_NULL_LAST = 6 ///< empty frame with no data
-};
-
-#define IVI4_PIC_SIZE_ESC 7
-
-
-static const struct {
- InvTransformPtr *inv_trans;
- DCTransformPtr *dc_trans;
- int is_2d_trans;
-} transforms[18] = {
- { ff_ivi_inverse_haar_8x8, ff_ivi_dc_haar_2d, 1 },
- { NULL, NULL, 0 }, /* inverse Haar 8x1 */
- { NULL, NULL, 0 }, /* inverse Haar 1x8 */
- { ff_ivi_put_pixels_8x8, ff_ivi_put_dc_pixel_8x8, 1 },
- { ff_ivi_inverse_slant_8x8, ff_ivi_dc_slant_2d, 1 },
- { ff_ivi_row_slant8, ff_ivi_dc_row_slant, 1 },
- { ff_ivi_col_slant8, ff_ivi_dc_col_slant, 1 },
- { NULL, NULL, 0 }, /* inverse DCT 8x8 */
- { NULL, NULL, 0 }, /* inverse DCT 8x1 */
- { NULL, NULL, 0 }, /* inverse DCT 1x8 */
- { NULL, NULL, 0 }, /* inverse Haar 4x4 */
- { ff_ivi_inverse_slant_4x4, ff_ivi_dc_slant_2d, 1 },
- { NULL, NULL, 0 }, /* no transform 4x4 */
- { NULL, NULL, 0 }, /* inverse Haar 1x4 */
- { NULL, NULL, 0 }, /* inverse Haar 4x1 */
- { NULL, NULL, 0 }, /* inverse slant 1x4 */
- { NULL, NULL, 0 }, /* inverse slant 4x1 */
- { NULL, NULL, 0 }, /* inverse DCT 4x4 */
-};
-
-/**
- * Decode subdivision of a plane.
- * This is a simplified version that checks for two supported subdivisions:
- * - 1 wavelet band per plane, size factor 1:1, code pattern: 3
- * - 4 wavelet bands per plane, size factor 1:4, code pattern: 2,3,3,3,3
- * Anything else is either unsupported or corrupt.
- *
- * @param[in,out] gb the GetBit context
- * @return number of wavelet bands or 0 on error
- */
-static int decode_plane_subdivision(GetBitContext *gb)
-{
- int i;
-
- switch (get_bits(gb, 2)) {
- case 3:
- return 1;
- case 2:
- for (i = 0; i < 4; i++)
- if (get_bits(gb, 2) != 3)
- return 0;
- return 4;
- default:
- return 0;
- }
-}
-
-static inline int scale_tile_size(int def_size, int size_factor)
-{
- return size_factor == 15 ? def_size : (size_factor + 1) << 5;
-}
-
-/**
- * Decode Indeo 4 picture header.
- *
- * @param[in,out] ctx pointer to the decoder context
- * @param[in] avctx pointer to the AVCodecContext
- * @return result code: 0 = OK, negative number = error
- */
-static int decode_pic_hdr(IVI45DecContext *ctx, AVCodecContext *avctx)
-{
- int pic_size_indx, i, p;
- IVIPicConfig pic_conf;
-
- if (get_bits(&ctx->gb, 18) != 0x3FFF8) {
- av_log(avctx, AV_LOG_ERROR, "Invalid picture start code!\n");
- return AVERROR_INVALIDDATA;
- }
-
- ctx->prev_frame_type = ctx->frame_type;
- ctx->frame_type = get_bits(&ctx->gb, 3);
- if (ctx->frame_type == 7) {
- av_log(avctx, AV_LOG_ERROR, "Invalid frame type: %d\n", ctx->frame_type);
- return AVERROR_INVALIDDATA;
- }
-
-#if IVI4_STREAM_ANALYSER
- if (ctx->frame_type == FRAMETYPE_BIDIR)
- ctx->has_b_frames = 1;
-#endif
-
- ctx->transp_status = get_bits1(&ctx->gb);
-#if IVI4_STREAM_ANALYSER
- if (ctx->transp_status) {
- ctx->has_transp = 1;
- }
-#endif
-
- /* unknown bit: Mac decoder ignores this bit, XANIM returns error */
- if (get_bits1(&ctx->gb)) {
- av_log(avctx, AV_LOG_ERROR, "Sync bit is set!\n");
- return AVERROR_INVALIDDATA;
- }
-
- ctx->data_size = get_bits1(&ctx->gb) ? get_bits(&ctx->gb, 24) : 0;
-
- /* null frames don't contain anything else so we just return */
- if (ctx->frame_type >= FRAMETYPE_NULL_FIRST) {
- av_dlog(avctx, "Null frame encountered!\n");
- return 0;
- }
-
- /* Check key lock status. If enabled - ignore lock word. */
- /* Usually we have to prompt the user for the password, but */
- /* we don't do that because Indeo 4 videos can be decoded anyway */
- if (get_bits1(&ctx->gb)) {
- skip_bits_long(&ctx->gb, 32);
- av_dlog(avctx, "Password-protected clip!\n");
- }
-
- pic_size_indx = get_bits(&ctx->gb, 3);
- if (pic_size_indx == IVI4_PIC_SIZE_ESC) {
- pic_conf.pic_height = get_bits(&ctx->gb, 16);
- pic_conf.pic_width = get_bits(&ctx->gb, 16);
- } else {
- pic_conf.pic_height = ivi4_common_pic_sizes[pic_size_indx * 2 + 1];
- pic_conf.pic_width = ivi4_common_pic_sizes[pic_size_indx * 2 ];
- }
-
- /* Decode tile dimensions. */
- if (get_bits1(&ctx->gb)) {
- pic_conf.tile_height = scale_tile_size(pic_conf.pic_height, get_bits(&ctx->gb, 4));
- pic_conf.tile_width = scale_tile_size(pic_conf.pic_width, get_bits(&ctx->gb, 4));
-#if IVI4_STREAM_ANALYSER
- ctx->uses_tiling = 1;
-#endif
- } else {
- pic_conf.tile_height = pic_conf.pic_height;
- pic_conf.tile_width = pic_conf.pic_width;
- }
-
- /* Decode chroma subsampling. We support only 4:4 aka YVU9. */
- if (get_bits(&ctx->gb, 2)) {
- av_log(avctx, AV_LOG_ERROR, "Only YVU9 picture format is supported!\n");
- return AVERROR_INVALIDDATA;
- }
- pic_conf.chroma_height = (pic_conf.pic_height + 3) >> 2;
- pic_conf.chroma_width = (pic_conf.pic_width + 3) >> 2;
-
- /* decode subdivision of the planes */
- pic_conf.luma_bands = decode_plane_subdivision(&ctx->gb);
- pic_conf.chroma_bands = 0;
- if (pic_conf.luma_bands)
- pic_conf.chroma_bands = decode_plane_subdivision(&ctx->gb);
- ctx->is_scalable = pic_conf.luma_bands != 1 || pic_conf.chroma_bands != 1;
- if (ctx->is_scalable && (pic_conf.luma_bands != 4 || pic_conf.chroma_bands != 1)) {
- av_log(avctx, AV_LOG_ERROR, "Scalability: unsupported subdivision! Luma bands: %d, chroma bands: %d\n",
- pic_conf.luma_bands, pic_conf.chroma_bands);
- return AVERROR_INVALIDDATA;
- }
-
- /* check if picture layout was changed and reallocate buffers */
- if (ivi_pic_config_cmp(&pic_conf, &ctx->pic_conf)) {
- if (ff_ivi_init_planes(ctx->planes, &pic_conf)) {
- av_log(avctx, AV_LOG_ERROR, "Couldn't reallocate color planes!\n");
- return AVERROR(ENOMEM);
- }
-
- ctx->pic_conf = pic_conf;
-
- /* set default macroblock/block dimensions */
- for (p = 0; p <= 2; p++) {
- for (i = 0; i < (!p ? pic_conf.luma_bands : pic_conf.chroma_bands); i++) {
- ctx->planes[p].bands[i].mb_size = !p ? (!ctx->is_scalable ? 16 : 8) : 4;
- ctx->planes[p].bands[i].blk_size = !p ? 8 : 4;
- }
- }
-
- if (ff_ivi_init_tiles(ctx->planes, ctx->pic_conf.tile_width,
- ctx->pic_conf.tile_height)) {
- av_log(avctx, AV_LOG_ERROR,
- "Couldn't reallocate internal structures!\n");
- return AVERROR(ENOMEM);
- }
- }
-
- ctx->frame_num = get_bits1(&ctx->gb) ? get_bits(&ctx->gb, 20) : 0;
-
- /* skip decTimeEst field if present */
- if (get_bits1(&ctx->gb))
- skip_bits(&ctx->gb, 8);
-
- /* decode macroblock and block huffman codebooks */
- if (ff_ivi_dec_huff_desc(&ctx->gb, get_bits1(&ctx->gb), IVI_MB_HUFF, &ctx->mb_vlc, avctx) ||
- ff_ivi_dec_huff_desc(&ctx->gb, get_bits1(&ctx->gb), IVI_BLK_HUFF, &ctx->blk_vlc, avctx))
- return AVERROR_INVALIDDATA;
-
- ctx->rvmap_sel = get_bits1(&ctx->gb) ? get_bits(&ctx->gb, 3) : 8;
-
- ctx->in_imf = get_bits1(&ctx->gb);
- ctx->in_q = get_bits1(&ctx->gb);
-
- ctx->pic_glob_quant = get_bits(&ctx->gb, 5);
-
- /* TODO: ignore this parameter if unused */
- ctx->unknown1 = get_bits1(&ctx->gb) ? get_bits(&ctx->gb, 3) : 0;
-
- ctx->checksum = get_bits1(&ctx->gb) ? get_bits(&ctx->gb, 16) : 0;
-
- /* skip picture header extension if any */
- while (get_bits1(&ctx->gb)) {
- av_dlog(avctx, "Pic hdr extension encountered!\n");
- skip_bits(&ctx->gb, 8);
- }
-
- if (get_bits1(&ctx->gb)) {
- av_log(avctx, AV_LOG_ERROR, "Bad blocks bits encountered!\n");
- }
-
- align_get_bits(&ctx->gb);
-
- return 0;
-}
-
-
-/**
- * Decode Indeo 4 band header.
- *
- * @param[in,out] ctx pointer to the decoder context
- * @param[in,out] band pointer to the band descriptor
- * @param[in] avctx pointer to the AVCodecContext
- * @return result code: 0 = OK, negative number = error
- */
-static int decode_band_hdr(IVI45DecContext *ctx, IVIBandDesc *band,
- AVCodecContext *avctx)
-{
- int plane, band_num, indx, transform_id, scan_indx;
- int i;
- int quant_mat;
-
- plane = get_bits(&ctx->gb, 2);
- band_num = get_bits(&ctx->gb, 4);
- if (band->plane != plane || band->band_num != band_num) {
- av_log(avctx, AV_LOG_ERROR, "Invalid band header sequence!\n");
- return AVERROR_INVALIDDATA;
- }
-
- band->is_empty = get_bits1(&ctx->gb);
- if (!band->is_empty) {
- /* skip header size
- * If header size is not given, header size is 4 bytes. */
- if (get_bits1(&ctx->gb))
- skip_bits(&ctx->gb, 16);
-
- band->is_halfpel = get_bits(&ctx->gb, 2);
- if (band->is_halfpel >= 2) {
- av_log(avctx, AV_LOG_ERROR, "Invalid/unsupported mv resolution: %d!\n",
- band->is_halfpel);
- return AVERROR_INVALIDDATA;
- }
-#if IVI4_STREAM_ANALYSER
- if (!band->is_halfpel)
- ctx->uses_fullpel = 1;
-#endif
-
- band->checksum_present = get_bits1(&ctx->gb);
- if (band->checksum_present)
- band->checksum = get_bits(&ctx->gb, 16);
-
- indx = get_bits(&ctx->gb, 2);
- if (indx == 3) {
- av_log(avctx, AV_LOG_ERROR, "Invalid block size!\n");
- return AVERROR_INVALIDDATA;
- }
- band->mb_size = 16 >> indx;
- band->blk_size = 8 >> (indx >> 1);
-
- band->inherit_mv = get_bits1(&ctx->gb);
- band->inherit_qdelta = get_bits1(&ctx->gb);
-
- band->glob_quant = get_bits(&ctx->gb, 5);
-
- if (!get_bits1(&ctx->gb) || ctx->frame_type == FRAMETYPE_INTRA) {
- transform_id = get_bits(&ctx->gb, 5);
- if (transform_id >= FF_ARRAY_ELEMS(transforms) ||
- !transforms[transform_id].inv_trans) {
- av_log_ask_for_sample(avctx, "Unimplemented transform: %d!\n", transform_id);
- return AVERROR_PATCHWELCOME;
- }
- if ((transform_id >= 7 && transform_id <= 9) ||
- transform_id == 17) {
- av_log_ask_for_sample(avctx, "DCT transform not supported yet!\n");
- return AVERROR_PATCHWELCOME;
- }
-
- if (transform_id < 10 && band->blk_size < 8) {
- av_log(avctx, AV_LOG_ERROR, "wrong transform size!\n");
- return AVERROR_INVALIDDATA;
- }
-#if IVI4_STREAM_ANALYSER
- if ((transform_id >= 0 && transform_id <= 2) || transform_id == 10)
- ctx->uses_haar = 1;
-#endif
-
- band->inv_transform = transforms[transform_id].inv_trans;
- band->dc_transform = transforms[transform_id].dc_trans;
- band->is_2d_trans = transforms[transform_id].is_2d_trans;
- band->transform_size= (transform_id < 10) ? 8 : 4;
-
- scan_indx = get_bits(&ctx->gb, 4);
- if ((scan_indx>4 && scan_indx<10) != (band->blk_size==4)) {
- av_log(avctx, AV_LOG_ERROR, "mismatching scan table!\n");
- return AVERROR_INVALIDDATA;
- }
- if (scan_indx == 15) {
- av_log(avctx, AV_LOG_ERROR, "Custom scan pattern encountered!\n");
- return AVERROR_INVALIDDATA;
- }
- band->scan = scan_index_to_tab[scan_indx];
- band->scan_size = band->blk_size;
-
- quant_mat = get_bits(&ctx->gb, 5);
- if (quant_mat == 31) {
- av_log(avctx, AV_LOG_ERROR, "Custom quant matrix encountered!\n");
- return AVERROR_INVALIDDATA;
- }
- if (quant_mat > 21) {
- av_log(avctx, AV_LOG_ERROR, "Invalid quant matrix encountered!\n");
- return AVERROR_INVALIDDATA;
- }
- band->quant_mat = quant_mat;
- }
- if (quant_index_to_tab[band->quant_mat] > 4 && band->blk_size == 4) {
- av_log(avctx, AV_LOG_ERROR, "Invalid quant matrix for 4x4 block encountered!\n");
- band->quant_mat = 0;
- return AVERROR_INVALIDDATA;
- }
- if (band->scan_size != band->blk_size) {
- av_log(avctx, AV_LOG_ERROR, "mismatching scan table!\n");
- return AVERROR_INVALIDDATA;
- }
- if (band->transform_size == 8 && band->blk_size < 8) {
- av_log(avctx, AV_LOG_ERROR, "mismatching transform_size!\n");
- return AVERROR_INVALIDDATA;
- }
-
- /* decode block huffman codebook */
- if (ff_ivi_dec_huff_desc(&ctx->gb, get_bits1(&ctx->gb), IVI_BLK_HUFF,
- &band->blk_vlc, avctx))
- return AVERROR_INVALIDDATA;
-
- /* select appropriate rvmap table for this band */
- band->rvmap_sel = get_bits1(&ctx->gb) ? get_bits(&ctx->gb, 3) : 8;
-
- /* decode rvmap probability corrections if any */
- band->num_corr = 0; /* there is no corrections */
- if (get_bits1(&ctx->gb)) {
- band->num_corr = get_bits(&ctx->gb, 8); /* get number of correction pairs */
- if (band->num_corr > 61) {
- av_log(avctx, AV_LOG_ERROR, "Too many corrections: %d\n",
- band->num_corr);
- return AVERROR_INVALIDDATA;
- }
-
- /* read correction pairs */
- for (i = 0; i < band->num_corr * 2; i++)
- band->corr[i] = get_bits(&ctx->gb, 8);
- }
- }
-
- if (band->blk_size == 8) {
- band->intra_base = &ivi4_quant_8x8_intra[quant_index_to_tab[band->quant_mat]][0];
- band->inter_base = &ivi4_quant_8x8_inter[quant_index_to_tab[band->quant_mat]][0];
- } else {
- band->intra_base = &ivi4_quant_4x4_intra[quant_index_to_tab[band->quant_mat]][0];
- band->inter_base = &ivi4_quant_4x4_inter[quant_index_to_tab[band->quant_mat]][0];
- }
-
- /* Indeo 4 doesn't use scale tables */
- band->intra_scale = NULL;
- band->inter_scale = NULL;
-
- align_get_bits(&ctx->gb);
-
- if (!band->scan) {
- av_log(avctx, AV_LOG_ERROR, "band->scan not set\n");
- return AVERROR_INVALIDDATA;
- }
-
- return 0;
-}
-
-
-/**
- * Decode information (block type, cbp, quant delta, motion vector)
- * for all macroblocks in the current tile.
- *
- * @param[in,out] ctx pointer to the decoder context
- * @param[in,out] band pointer to the band descriptor
- * @param[in,out] tile pointer to the tile descriptor
- * @param[in] avctx pointer to the AVCodecContext
- * @return result code: 0 = OK, negative number = error
- */
-static int decode_mb_info(IVI45DecContext *ctx, IVIBandDesc *band,
- IVITile *tile, AVCodecContext *avctx)
-{
- int x, y, mv_x, mv_y, mv_delta, offs, mb_offset, blks_per_mb,
- mv_scale, mb_type_bits, s;
- IVIMbInfo *mb, *ref_mb;
- int row_offset = band->mb_size * band->pitch;
-
- mb = tile->mbs;
- ref_mb = tile->ref_mbs;
- offs = tile->ypos * band->pitch + tile->xpos;
-
- blks_per_mb = band->mb_size != band->blk_size ? 4 : 1;
- mb_type_bits = ctx->frame_type == FRAMETYPE_BIDIR ? 2 : 1;
-
- /* scale factor for motion vectors */
- mv_scale = (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3);
- mv_x = mv_y = 0;
-
- if (((tile->width + band->mb_size-1)/band->mb_size) * ((tile->height + band->mb_size-1)/band->mb_size) != tile->num_MBs) {
- av_log(avctx, AV_LOG_ERROR, "num_MBs mismatch %d %d %d %d\n", tile->width, tile->height, band->mb_size, tile->num_MBs);
- return -1;
- }
-
- for (y = tile->ypos; y < tile->ypos + tile->height; y += band->mb_size) {
- mb_offset = offs;
-
- for (x = tile->xpos; x < tile->xpos + tile->width; x += band->mb_size) {
- mb->xpos = x;
- mb->ypos = y;
- mb->buf_offs = mb_offset;
-
- if (get_bits1(&ctx->gb)) {
- if (ctx->frame_type == FRAMETYPE_INTRA) {
- av_log(avctx, AV_LOG_ERROR, "Empty macroblock in an INTRA picture!\n");
- return AVERROR_INVALIDDATA;
- }
- mb->type = 1; /* empty macroblocks are always INTER */
- mb->cbp = 0; /* all blocks are empty */
-
- mb->q_delta = 0;
- if (!band->plane && !band->band_num && ctx->in_q) {
- mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
- IVI_VLC_BITS, 1);
- mb->q_delta = IVI_TOSIGNED(mb->q_delta);
- }
-
- mb->mv_x = mb->mv_y = 0; /* no motion vector coded */
- if (band->inherit_mv && ref_mb) {
- /* motion vector inheritance */
- if (mv_scale) {
- mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
- mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
- } else {
- mb->mv_x = ref_mb->mv_x;
- mb->mv_y = ref_mb->mv_y;
- }
- }
- } else {
- if (band->inherit_mv && ref_mb) {
- mb->type = ref_mb->type; /* copy mb_type from corresponding reference mb */
- } else if (ctx->frame_type == FRAMETYPE_INTRA ||
- ctx->frame_type == FRAMETYPE_INTRA1) {
- mb->type = 0; /* mb_type is always INTRA for intra-frames */
- } else {
- mb->type = get_bits(&ctx->gb, mb_type_bits);
- }
-
- mb->cbp = get_bits(&ctx->gb, blks_per_mb);
-
- mb->q_delta = 0;
- if (band->inherit_qdelta) {
- if (ref_mb) mb->q_delta = ref_mb->q_delta;
- } else if (mb->cbp || (!band->plane && !band->band_num &&
- ctx->in_q)) {
- mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
- IVI_VLC_BITS, 1);
- mb->q_delta = IVI_TOSIGNED(mb->q_delta);
- }
-
- if (!mb->type) {
- mb->mv_x = mb->mv_y = 0; /* there is no motion vector in intra-macroblocks */
- } else {
- if (band->inherit_mv && ref_mb) {
- /* motion vector inheritance */
- if (mv_scale) {
- mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
- mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
- } else {
- mb->mv_x = ref_mb->mv_x;
- mb->mv_y = ref_mb->mv_y;
- }
- } else {
- /* decode motion vector deltas */
- mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
- IVI_VLC_BITS, 1);
- mv_y += IVI_TOSIGNED(mv_delta);
- mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
- IVI_VLC_BITS, 1);
- mv_x += IVI_TOSIGNED(mv_delta);
- mb->mv_x = mv_x;
- mb->mv_y = mv_y;
- }
- }
- }
-
- s= band->is_halfpel;
- if (mb->type)
- if ( x + (mb->mv_x >>s) + (y+ (mb->mv_y >>s))*band->pitch < 0 ||
- x + ((mb->mv_x+s)>>s) + band->mb_size - 1
- + (y+band->mb_size - 1 +((mb->mv_y+s)>>s))*band->pitch > band->bufsize -1) {
- av_log(avctx, AV_LOG_ERROR, "motion vector %d %d outside reference\n", x*s + mb->mv_x, y*s + mb->mv_y);
- return AVERROR_INVALIDDATA;
- }
-
- mb++;
- if (ref_mb)
- ref_mb++;
- mb_offset += band->mb_size;
- }
-
- offs += row_offset;
- }
-
- align_get_bits(&ctx->gb);
-
- return 0;
-}
-
-
-/**
- * Rearrange decoding and reference buffers.
- *
- * @param[in,out] ctx pointer to the decoder context
- */
-static void switch_buffers(IVI45DecContext *ctx)
-{
- switch (ctx->prev_frame_type) {
- case FRAMETYPE_INTRA:
- case FRAMETYPE_INTRA1:
- case FRAMETYPE_INTER:
- ctx->buf_switch ^= 1;
- ctx->dst_buf = ctx->buf_switch;
- ctx->ref_buf = ctx->buf_switch ^ 1;
- break;
- case FRAMETYPE_INTER_NOREF:
- break;
- }
-
- switch (ctx->frame_type) {
- case FRAMETYPE_INTRA:
- case FRAMETYPE_INTRA1:
- ctx->buf_switch = 0;
- /* FALLTHROUGH */
- case FRAMETYPE_INTER:
- ctx->dst_buf = ctx->buf_switch;
- ctx->ref_buf = ctx->buf_switch ^ 1;
- break;
- case FRAMETYPE_INTER_NOREF:
- case FRAMETYPE_NULL_FIRST:
- case FRAMETYPE_NULL_LAST:
- break;
- }
-}
-
-
-static int is_nonnull_frame(IVI45DecContext *ctx)
-{
- return ctx->frame_type < FRAMETYPE_NULL_FIRST;
-}
-
-
-static av_cold int decode_init(AVCodecContext *avctx)
-{
- IVI45DecContext *ctx = avctx->priv_data;
-
- ff_ivi_init_static_vlc();
-
- /* copy rvmap tables in our context so we can apply changes to them */
- memcpy(ctx->rvmap_tabs, ff_ivi_rvmap_tabs, sizeof(ff_ivi_rvmap_tabs));
-
- /* Force allocation of the internal buffers */
- /* during picture header decoding. */
- ctx->pic_conf.pic_width = 0;
- ctx->pic_conf.pic_height = 0;
-
- avctx->pix_fmt = AV_PIX_FMT_YUV410P;
-
- ctx->decode_pic_hdr = decode_pic_hdr;
- ctx->decode_band_hdr = decode_band_hdr;
- ctx->decode_mb_info = decode_mb_info;
- ctx->switch_buffers = switch_buffers;
- ctx->is_nonnull_frame = is_nonnull_frame;
-
- return 0;
-}
-
-
-AVCodec ff_indeo4_decoder = {
- .name = "indeo4",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_INDEO4,
- .priv_data_size = sizeof(IVI45DecContext),
- .init = decode_init,
- .close = ff_ivi_decode_close,
- .decode = ff_ivi_decode_frame,
- .long_name = NULL_IF_CONFIG_SMALL("Intel Indeo Video Interactive 4"),
- .capabilities = CODEC_CAP_DR1,
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/indeo4data.h b/src/thirdparty/ffmpeg/libavcodec/indeo4data.h
deleted file mode 100644
index 02332e8d9..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/indeo4data.h
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
- * Indeo Video Interactive 4 compatible decoder
- * Copyright (c) 2009-2010 Maxim Poliakovski
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * This file contains data needed for the Indeo 4 decoder.
- */
-
-#ifndef AVCODEC_INDEO4DATA_H
-#define AVCODEC_INDEO4DATA_H
-
-#include <stdint.h>
-#include "dsputil.h"
-#include "ivi_common.h"
-
-/**
- * standard picture dimensions
- */
-static const uint16_t ivi4_common_pic_sizes[14] = {
- 640, 480, 320, 240, 160, 120, 704, 480, 352, 240, 352, 288, 176, 144
-};
-
-/**
- * Indeo 4 8x8 scan (zigzag) patterns
- */
-static const uint8_t ivi4_alternate_scan_8x8[64] = {
- 0, 8, 1, 9, 16, 24, 2, 3, 17, 25, 10, 11, 32, 40, 48, 56,
- 4, 5, 6, 7, 33, 41, 49, 57, 18, 19, 26, 27, 12, 13, 14, 15,
- 34, 35, 43, 42, 50, 51, 59, 58, 20, 21, 22, 23, 31, 30, 29, 28,
- 36, 37, 38, 39, 47, 46, 45, 44, 52, 53, 54, 55, 63, 62, 61, 60
-};
-
-static const uint8_t ivi4_alternate_scan_4x4[16] = {
- 0, 1, 4, 5, 8, 12, 2, 3, 9, 13, 6, 7, 10, 11, 14, 15
-};
-
-static const uint8_t ivi4_vertical_scan_4x4[16] = {
- 0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15
-};
-
-static const uint8_t ivi4_horizontal_scan_4x4[16] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
-};
-
-static const uint8_t *scan_index_to_tab[15] = {
- // for 8x8 transforms
- ff_zigzag_direct,
- ivi4_alternate_scan_8x8,
- ff_ivi_horizontal_scan_8x8,
- ff_ivi_vertical_scan_8x8,
- ff_zigzag_direct,
-
- // for 4x4 transforms
- ff_ivi_direct_scan_4x4,
- ivi4_alternate_scan_4x4,
- ivi4_vertical_scan_4x4,
- ivi4_horizontal_scan_4x4,
- ff_ivi_direct_scan_4x4,
-
- // TODO: check if those are needed
- ff_ivi_horizontal_scan_8x8,
- ff_ivi_horizontal_scan_8x8,
- ff_ivi_horizontal_scan_8x8,
- ff_ivi_horizontal_scan_8x8,
- ff_ivi_horizontal_scan_8x8
-};
-
-/**
- * Indeo 4 dequant tables
- */
-static const uint16_t ivi4_quant_8x8_intra[9][64] = {
- {
- 43, 342, 385, 470, 555, 555, 598, 726,
- 342, 342, 470, 513, 555, 598, 726, 769,
- 385, 470, 555, 555, 598, 726, 726, 811,
- 470, 470, 555, 555, 598, 726, 769, 854,
- 470, 555, 555, 598, 683, 726, 854, 1025,
- 555, 555, 598, 683, 726, 854, 1025, 1153,
- 555, 555, 598, 726, 811, 982, 1195, 1451,
- 555, 598, 726, 811, 982, 1195, 1451, 1793
- },
- {
- 86, 1195, 2390, 2390, 4865, 4865, 4865, 4865,
- 1195, 1195, 2390, 2390, 4865, 4865, 4865, 4865,
- 2390, 2390, 4865, 4865, 6827, 6827, 6827, 6827,
- 2390, 2390, 4865, 4865, 6827, 6827, 6827, 6827,
- 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
- 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
- 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
- 4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827
- },
- {
- 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
- 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
- 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
- 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
- 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
- 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
- 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
- 235, 1067, 1195, 1323, 1451, 1579, 1707, 1835
- },
- {
- 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
- 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
- 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
- 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
- 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
- 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
- 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
- 1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414
- },
- {
- 897, 897, 897, 897, 897, 897, 897, 897,
- 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067,
- 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238,
- 1409, 1409, 1409, 1409, 1409, 1409, 1409, 1409,
- 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579,
- 1750, 1750, 1750, 1750, 1750, 1750, 1750, 1750,
- 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921,
- 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091
- },
- {
- 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
- 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
- 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
- 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
- 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
- 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
- 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
- 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414
- },
- {
- 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
- 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
- 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
- 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
- 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
- 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
- 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
- 2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390
- },
- {
- 22, 171, 214, 257, 257, 299, 299, 342,
- 171, 171, 257, 257, 299, 299, 342, 385,
- 214, 257, 257, 299, 299, 342, 342, 385,
- 257, 257, 257, 299, 299, 342, 385, 427,
- 257, 257, 299, 299, 342, 385, 427, 513,
- 257, 299, 299, 342, 385, 427, 513, 598,
- 299, 299, 299, 385, 385, 470, 598, 726,
- 299, 299, 385, 385, 470, 598, 726, 897
- },
- {
- 86, 598, 1195, 1195, 2390, 2390, 2390, 2390,
- 598, 598, 1195, 1195, 2390, 2390, 2390, 2390,
- 1195, 1195, 2390, 2390, 3414, 3414, 3414, 3414,
- 1195, 1195, 2390, 2390, 3414, 3414, 3414, 3414,
- 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
- 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
- 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
- 2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414
- }
-};
-
-static const uint16_t ivi4_quant_8x8_inter[9][64] = {
- {
- 427, 427, 470, 427, 427, 427, 470, 470,
- 427, 427, 470, 427, 427, 427, 470, 470,
- 470, 470, 470, 470, 470, 470, 470, 470,
- 427, 427, 470, 470, 427, 427, 470, 470,
- 427, 427, 470, 427, 427, 427, 470, 470,
- 427, 427, 470, 427, 427, 427, 470, 470,
- 470, 470, 470, 470, 470, 470, 470, 470,
- 470, 470, 470, 470, 470, 470, 470, 470
- },
- {
- 1707, 1707, 2433, 2433, 3414, 3414, 3414, 3414,
- 1707, 1707, 2433, 2433, 3414, 3414, 3414, 3414,
- 2433, 2433, 3414, 3414, 4822, 4822, 4822, 4822,
- 2433, 2433, 3414, 3414, 4822, 4822, 4822, 4822,
- 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
- 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
- 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
- 3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414
- },
- {
- 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
- 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
- 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
- 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
- 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
- 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
- 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
- 1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281
- },
- {
- 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
- 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
- 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
- 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
- 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
- 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
- 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
- 2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433
- },
- {
- 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
- 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
- 1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281,
- 1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238,
- 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
- 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
- 1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281,
- 1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281
- },
- {
- 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
- 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
- 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
- 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
- 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
- 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
- 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
- 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433
- },
- {
- 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
- 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
- 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
- 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
- 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
- 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
- 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
- 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707
- },
- {
- 86, 171, 171, 214, 214, 214, 214, 257,
- 171, 171, 214, 214, 214, 214, 257, 257,
- 171, 214, 214, 214, 214, 257, 257, 257,
- 214, 214, 214, 214, 257, 257, 257, 299,
- 214, 214, 214, 257, 257, 257, 299, 299,
- 214, 214, 257, 257, 257, 299, 299, 299,
- 214, 257, 257, 257, 299, 299, 299, 342,
- 257, 257, 257, 299, 299, 299, 342, 342
- },
- {
- 854, 854, 1195, 1195, 1707, 1707, 1707, 1707,
- 854, 854, 1195, 1195, 1707, 1707, 1707, 1707,
- 1195, 1195, 1707, 1707, 2390, 2390, 2390, 2390,
- 1195, 1195, 1707, 1707, 2390, 2390, 2390, 2390,
- 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
- 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
- 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
- 1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707
- }
-};
-
-static const uint16_t ivi4_quant_4x4_intra[5][16] = {
- {
- 22, 214, 257, 299,
- 214, 257, 299, 342,
- 257, 299, 342, 427,
- 299, 342, 427, 513
- },
- {
- 129, 1025, 1451, 1451,
- 1025, 1025, 1451, 1451,
- 1451, 1451, 2049, 2049,
- 1451, 1451, 2049, 2049
- },
- {
- 43, 171, 171, 171,
- 43, 171, 171, 171,
- 43, 171, 171, 171,
- 43, 171, 171, 171
- },
- {
- 43, 43, 43, 43,
- 171, 171, 171, 171,
- 171, 171, 171, 171,
- 171, 171, 171, 171
- },
- {
- 43, 43, 43, 43,
- 43, 43, 43, 43,
- 43, 43, 43, 43,
- 43, 43, 43, 43
- }
-};
-
-static const uint16_t ivi4_quant_4x4_inter[5][16] = {
- {
- 107, 214, 257, 299,
- 214, 257, 299, 299,
- 257, 299, 299, 342,
- 299, 299, 342, 342
- },
- {
- 513, 1025, 1238, 1238,
- 1025, 1025, 1238, 1238,
- 1238, 1238, 1451, 1451,
- 1238, 1238, 1451, 1451
- },
- {
- 43, 171, 171, 171,
- 43, 171, 171, 171,
- 43, 171, 171, 171,
- 43, 171, 171, 171
- },
- {
- 43, 43, 43, 43,
- 171, 171, 171, 171,
- 171, 171, 171, 171,
- 171, 171, 171, 171
- },
- {
- 43, 43, 43, 43,
- 43, 43, 43, 43,
- 43, 43, 43, 43,
- 43, 43, 43, 43
- }
-};
-
-/**
- * Table for mapping quant matrix index from the bitstream
- * into internal quant table number.
- */
-static const uint8_t quant_index_to_tab[22] = {
- 0, 1, 0, 2, 1, 3, 0, 4, 1, 5, 0, 1, 6, 7, 8, // for 8x8 quant matrixes
- 0, 1, 2, 2, 3, 3, 4 // for 4x4 quant matrixes
-};
-
-#endif /* AVCODEC_INDEO4DATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/indeo5.c b/src/thirdparty/ffmpeg/libavcodec/indeo5.c
deleted file mode 100644
index 5345036bb..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/indeo5.c
+++ /dev/null
@@ -1,678 +0,0 @@
-/*
- * Indeo Video Interactive v5 compatible decoder
- * Copyright (c) 2009 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
- * Indeo Video Interactive version 5 decoder
- *
- * Indeo5 data is usually transported within .avi or .mov files.
- * Known FOURCCs: 'IV50'
- */
-
-#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"
-
-/**
- * Indeo5 frame types.
- */
-enum {
- FRAMETYPE_INTRA = 0,
- FRAMETYPE_INTER = 1, ///< non-droppable P-frame
- FRAMETYPE_INTER_SCAL = 2, ///< droppable P-frame used in the scalability mode
- FRAMETYPE_INTER_NOREF = 3, ///< droppable P-frame
- FRAMETYPE_NULL = 4 ///< empty frame with no data
-};
-
-#define IVI5_PIC_SIZE_ESC 15
-
-/**
- * Decode Indeo5 GOP (Group of pictures) header.
- * This header is present in key frames only.
- * It defines parameters for all frames in a GOP.
- *
- * @param[in,out] ctx ptr to the decoder context
- * @param[in] avctx ptr to the AVCodecContext
- * @return result code: 0 = OK, -1 = error
- */
-static int decode_gop_header(IVI45DecContext *ctx, AVCodecContext *avctx)
-{
- int result, i, p, tile_size, pic_size_indx, mb_size, blk_size, is_scalable;
- int quant_mat, blk_size_changed = 0;
- IVIBandDesc *band, *band1, *band2;
- IVIPicConfig pic_conf;
-
- ctx->gop_flags = get_bits(&ctx->gb, 8);
-
- ctx->gop_hdr_size = (ctx->gop_flags & 1) ? get_bits(&ctx->gb, 16) : 0;
-
- if (ctx->gop_flags & IVI5_IS_PROTECTED)
- ctx->lock_word = get_bits_long(&ctx->gb, 32);
-
- tile_size = (ctx->gop_flags & 0x40) ? 64 << get_bits(&ctx->gb, 2) : 0;
- if (tile_size > 256) {
- av_log(avctx, AV_LOG_ERROR, "Invalid tile size: %d\n", tile_size);
- return -1;
- }
-
- /* decode number of wavelet bands */
- /* num_levels * 3 + 1 */
- pic_conf.luma_bands = get_bits(&ctx->gb, 2) * 3 + 1;
- pic_conf.chroma_bands = get_bits1(&ctx->gb) * 3 + 1;
- is_scalable = pic_conf.luma_bands != 1 || pic_conf.chroma_bands != 1;
- if (is_scalable && (pic_conf.luma_bands != 4 || pic_conf.chroma_bands != 1)) {
- av_log(avctx, AV_LOG_ERROR, "Scalability: unsupported subdivision! Luma bands: %d, chroma bands: %d\n",
- pic_conf.luma_bands, pic_conf.chroma_bands);
- return -1;
- }
-
- pic_size_indx = get_bits(&ctx->gb, 4);
- if (pic_size_indx == IVI5_PIC_SIZE_ESC) {
- pic_conf.pic_height = get_bits(&ctx->gb, 13);
- pic_conf.pic_width = get_bits(&ctx->gb, 13);
- } else {
- pic_conf.pic_height = ivi5_common_pic_sizes[pic_size_indx * 2 + 1] << 2;
- pic_conf.pic_width = ivi5_common_pic_sizes[pic_size_indx * 2 ] << 2;
- }
-
- if (ctx->gop_flags & 2) {
- av_log(avctx, AV_LOG_ERROR, "YV12 picture format not supported!\n");
- return -1;
- }
-
- pic_conf.chroma_height = (pic_conf.pic_height + 3) >> 2;
- pic_conf.chroma_width = (pic_conf.pic_width + 3) >> 2;
-
- if (!tile_size) {
- pic_conf.tile_height = pic_conf.pic_height;
- pic_conf.tile_width = pic_conf.pic_width;
- } else {
- pic_conf.tile_height = pic_conf.tile_width = tile_size;
- }
-
- /* check if picture layout was changed and reallocate buffers */
- if (ivi_pic_config_cmp(&pic_conf, &ctx->pic_conf)) {
- result = ff_ivi_init_planes(ctx->planes, &pic_conf);
- if (result) {
- av_log(avctx, AV_LOG_ERROR, "Couldn't reallocate color planes!\n");
- return -1;
- }
- ctx->pic_conf = pic_conf;
- ctx->is_scalable = is_scalable;
- blk_size_changed = 1; /* force reallocation of the internal structures */
- }
-
- for (p = 0; p <= 1; p++) {
- for (i = 0; i < (!p ? pic_conf.luma_bands : pic_conf.chroma_bands); i++) {
- band = &ctx->planes[p].bands[i];
-
- band->is_halfpel = get_bits1(&ctx->gb);
-
- mb_size = get_bits1(&ctx->gb);
- blk_size = 8 >> get_bits1(&ctx->gb);
- mb_size = blk_size << !mb_size;
-
- if (p==0 && blk_size==4) {
- av_log(avctx, AV_LOG_ERROR, "4x4 luma blocks are unsupported!\n");
- return AVERROR_PATCHWELCOME;
- }
-
- blk_size_changed = mb_size != band->mb_size || blk_size != band->blk_size;
- if (blk_size_changed) {
- band->mb_size = mb_size;
- band->blk_size = blk_size;
- }
-
- if (get_bits1(&ctx->gb)) {
- av_log(avctx, AV_LOG_ERROR, "Extended transform info encountered!\n");
- return -1;
- }
-
- /* select transform function and scan pattern according to plane and band number */
- switch ((p << 2) + i) {
- case 0:
- band->inv_transform = ff_ivi_inverse_slant_8x8;
- band->dc_transform = ff_ivi_dc_slant_2d;
- band->scan = ff_zigzag_direct;
- band->transform_size= 8;
- break;
-
- case 1:
- band->inv_transform = ff_ivi_row_slant8;
- band->dc_transform = ff_ivi_dc_row_slant;
- band->scan = ff_ivi_vertical_scan_8x8;
- band->transform_size= 8;
- break;
-
- case 2:
- band->inv_transform = ff_ivi_col_slant8;
- band->dc_transform = ff_ivi_dc_col_slant;
- band->scan = ff_ivi_horizontal_scan_8x8;
- band->transform_size= 8;
- break;
-
- case 3:
- band->inv_transform = ff_ivi_put_pixels_8x8;
- band->dc_transform = ff_ivi_put_dc_pixel_8x8;
- band->scan = ff_ivi_horizontal_scan_8x8;
- band->transform_size= 8;
- break;
-
- case 4:
- band->inv_transform = ff_ivi_inverse_slant_4x4;
- band->dc_transform = ff_ivi_dc_slant_2d;
- band->scan = ff_ivi_direct_scan_4x4;
- band->transform_size= 4;
- break;
- }
-
- band->is_2d_trans = band->inv_transform == ff_ivi_inverse_slant_8x8 ||
- band->inv_transform == ff_ivi_inverse_slant_4x4;
-
- /* select dequant matrix according to plane and band number */
- if (!p) {
- quant_mat = (pic_conf.luma_bands > 1) ? i+1 : 0;
- } else {
- quant_mat = 5;
- }
-
- if (band->blk_size == 8) {
- if(quant_mat >= 5){
- av_log(avctx, AV_LOG_ERROR, "quant_mat %d too large!\n", quant_mat);
- return -1;
- }
- band->intra_base = &ivi5_base_quant_8x8_intra[quant_mat][0];
- band->inter_base = &ivi5_base_quant_8x8_inter[quant_mat][0];
- band->intra_scale = &ivi5_scale_quant_8x8_intra[quant_mat][0];
- band->inter_scale = &ivi5_scale_quant_8x8_inter[quant_mat][0];
- } else {
- band->intra_base = ivi5_base_quant_4x4_intra;
- band->inter_base = ivi5_base_quant_4x4_inter;
- band->intra_scale = ivi5_scale_quant_4x4_intra;
- band->inter_scale = ivi5_scale_quant_4x4_inter;
- }
-
- if (get_bits(&ctx->gb, 2)) {
- av_log(avctx, AV_LOG_ERROR, "End marker missing!\n");
- return -1;
- }
- }
- }
-
- /* copy chroma parameters into the 2nd chroma plane */
- for (i = 0; i < pic_conf.chroma_bands; i++) {
- band1 = &ctx->planes[1].bands[i];
- band2 = &ctx->planes[2].bands[i];
-
- band2->width = band1->width;
- band2->height = band1->height;
- band2->mb_size = band1->mb_size;
- band2->blk_size = band1->blk_size;
- band2->is_halfpel = band1->is_halfpel;
- band2->intra_base = band1->intra_base;
- band2->inter_base = band1->inter_base;
- band2->intra_scale = band1->intra_scale;
- band2->inter_scale = band1->inter_scale;
- band2->scan = band1->scan;
- band2->inv_transform = band1->inv_transform;
- band2->dc_transform = band1->dc_transform;
- band2->is_2d_trans = band1->is_2d_trans;
- band2->transform_size= band1->transform_size;
- }
-
- /* reallocate internal structures if needed */
- if (blk_size_changed) {
- result = ff_ivi_init_tiles(ctx->planes, pic_conf.tile_width,
- pic_conf.tile_height);
- if (result) {
- av_log(avctx, AV_LOG_ERROR,
- "Couldn't reallocate internal structures!\n");
- return -1;
- }
- }
-
- if (ctx->gop_flags & 8) {
- if (get_bits(&ctx->gb, 3)) {
- av_log(avctx, AV_LOG_ERROR, "Alignment bits are not zero!\n");
- return -1;
- }
-
- if (get_bits1(&ctx->gb))
- skip_bits_long(&ctx->gb, 24); /* skip transparency fill color */
- }
-
- align_get_bits(&ctx->gb);
-
- skip_bits(&ctx->gb, 23); /* FIXME: unknown meaning */
-
- /* skip GOP extension if any */
- if (get_bits1(&ctx->gb)) {
- do {
- i = get_bits(&ctx->gb, 16);
- } while (i & 0x8000);
- }
-
- align_get_bits(&ctx->gb);
-
- return 0;
-}
-
-
-/**
- * Skip a header extension.
- *
- * @param[in,out] gb the GetBit context
- */
-static inline void skip_hdr_extension(GetBitContext *gb)
-{
- int i, len;
-
- do {
- len = get_bits(gb, 8);
- for (i = 0; i < len; i++) skip_bits(gb, 8);
- } while(len);
-}
-
-
-/**
- * Decode Indeo5 picture header.
- *
- * @param[in,out] ctx ptr to the decoder context
- * @param[in] avctx ptr to the AVCodecContext
- * @return result code: 0 = OK, -1 = error
- */
-static int decode_pic_hdr(IVI45DecContext *ctx, AVCodecContext *avctx)
-{
- if (get_bits(&ctx->gb, 5) != 0x1F) {
- av_log(avctx, AV_LOG_ERROR, "Invalid picture start code!\n");
- return -1;
- }
-
- ctx->prev_frame_type = ctx->frame_type;
- ctx->frame_type = get_bits(&ctx->gb, 3);
- if (ctx->frame_type >= 5) {
- av_log(avctx, AV_LOG_ERROR, "Invalid frame type: %d \n", ctx->frame_type);
- return -1;
- }
-
- ctx->frame_num = get_bits(&ctx->gb, 8);
-
- if (ctx->frame_type == FRAMETYPE_INTRA) {
- ctx->gop_invalid = 1;
- if (decode_gop_header(ctx, avctx)) {
- av_log(avctx, AV_LOG_ERROR, "Invalid GOP header, skipping frames.\n");
- return AVERROR_INVALIDDATA;
- }
- ctx->gop_invalid = 0;
- }
-
- if (ctx->frame_type == FRAMETYPE_INTER_SCAL && !ctx->is_scalable) {
- av_log(avctx, AV_LOG_ERROR, "Scalable inter frame in non scaleable stream\n");
- ctx->frame_type = FRAMETYPE_INTER;
- return AVERROR_INVALIDDATA;
- }
-
- if (ctx->frame_type != FRAMETYPE_NULL) {
- ctx->frame_flags = get_bits(&ctx->gb, 8);
-
- ctx->pic_hdr_size = (ctx->frame_flags & 1) ? get_bits_long(&ctx->gb, 24) : 0;
-
- ctx->checksum = (ctx->frame_flags & 0x10) ? get_bits(&ctx->gb, 16) : 0;
-
- /* skip unknown extension if any */
- if (ctx->frame_flags & 0x20)
- skip_hdr_extension(&ctx->gb); /* XXX: untested */
-
- /* decode macroblock huffman codebook */
- if (ff_ivi_dec_huff_desc(&ctx->gb, ctx->frame_flags & 0x40, IVI_MB_HUFF, &ctx->mb_vlc, avctx))
- return -1;
-
- skip_bits(&ctx->gb, 3); /* FIXME: unknown meaning! */
- }
-
- align_get_bits(&ctx->gb);
-
- return 0;
-}
-
-
-/**
- * Decode Indeo5 band header.
- *
- * @param[in,out] ctx ptr to the decoder context
- * @param[in,out] band ptr to the band descriptor
- * @param[in] avctx ptr to the AVCodecContext
- * @return result code: 0 = OK, -1 = error
- */
-static int decode_band_hdr(IVI45DecContext *ctx, IVIBandDesc *band,
- AVCodecContext *avctx)
-{
- int i;
- uint8_t band_flags;
-
- band_flags = get_bits(&ctx->gb, 8);
-
- if (band_flags & 1) {
- band->is_empty = 1;
- return 0;
- }
-
- band->data_size = (ctx->frame_flags & 0x80) ? get_bits_long(&ctx->gb, 24) : 0;
-
- band->inherit_mv = band_flags & 2;
- band->inherit_qdelta = band_flags & 8;
- band->qdelta_present = band_flags & 4;
- if (!band->qdelta_present) band->inherit_qdelta = 1;
-
- /* decode rvmap probability corrections if any */
- band->num_corr = 0; /* there are no corrections */
- if (band_flags & 0x10) {
- band->num_corr = get_bits(&ctx->gb, 8); /* get number of correction pairs */
- if (band->num_corr > 61) {
- av_log(avctx, AV_LOG_ERROR, "Too many corrections: %d\n",
- band->num_corr);
- return -1;
- }
-
- /* read correction pairs */
- for (i = 0; i < band->num_corr * 2; i++)
- band->corr[i] = get_bits(&ctx->gb, 8);
- }
-
- /* select appropriate rvmap table for this band */
- band->rvmap_sel = (band_flags & 0x40) ? get_bits(&ctx->gb, 3) : 8;
-
- /* decode block huffman codebook */
- if (ff_ivi_dec_huff_desc(&ctx->gb, band_flags & 0x80, IVI_BLK_HUFF, &band->blk_vlc, avctx))
- return -1;
-
- band->checksum_present = get_bits1(&ctx->gb);
- if (band->checksum_present)
- band->checksum = get_bits(&ctx->gb, 16);
-
- band->glob_quant = get_bits(&ctx->gb, 5);
-
- /* skip unknown extension if any */
- if (band_flags & 0x20) { /* XXX: untested */
- align_get_bits(&ctx->gb);
- skip_hdr_extension(&ctx->gb);
- }
-
- align_get_bits(&ctx->gb);
-
- return 0;
-}
-
-
-/**
- * Decode info (block type, cbp, quant delta, motion vector)
- * for all macroblocks in the current tile.
- *
- * @param[in,out] ctx ptr to the decoder context
- * @param[in,out] band ptr to the band descriptor
- * @param[in,out] tile ptr to the tile descriptor
- * @param[in] avctx ptr to the AVCodecContext
- * @return result code: 0 = OK, -1 = error
- */
-static int decode_mb_info(IVI45DecContext *ctx, IVIBandDesc *band,
- IVITile *tile, AVCodecContext *avctx)
-{
- int x, y, mv_x, mv_y, mv_delta, offs, mb_offset,
- mv_scale, blks_per_mb, s;
- IVIMbInfo *mb, *ref_mb;
- int row_offset = band->mb_size * band->pitch;
-
- mb = tile->mbs;
- ref_mb = tile->ref_mbs;
- offs = tile->ypos * band->pitch + tile->xpos;
-
- if (!ref_mb &&
- ((band->qdelta_present && band->inherit_qdelta) || band->inherit_mv))
- return AVERROR_INVALIDDATA;
-
- if (tile->num_MBs != IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size)) {
- av_log(avctx, AV_LOG_ERROR, "Allocated tile size %d mismatches parameters %d\n",
- tile->num_MBs, IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size));
- return AVERROR_INVALIDDATA;
- }
-
- /* scale factor for motion vectors */
- mv_scale = (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3);
- mv_x = mv_y = 0;
-
- for (y = tile->ypos; y < (tile->ypos + tile->height); y += band->mb_size) {
- mb_offset = offs;
-
- for (x = tile->xpos; x < (tile->xpos + tile->width); x += band->mb_size) {
- mb->xpos = x;
- mb->ypos = y;
- mb->buf_offs = mb_offset;
-
- if (get_bits1(&ctx->gb)) {
- if (ctx->frame_type == FRAMETYPE_INTRA) {
- av_log(avctx, AV_LOG_ERROR, "Empty macroblock in an INTRA picture!\n");
- return -1;
- }
- mb->type = 1; /* empty macroblocks are always INTER */
- mb->cbp = 0; /* all blocks are empty */
-
- mb->q_delta = 0;
- if (!band->plane && !band->band_num && (ctx->frame_flags & 8)) {
- mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
- IVI_VLC_BITS, 1);
- mb->q_delta = IVI_TOSIGNED(mb->q_delta);
- }
-
- mb->mv_x = mb->mv_y = 0; /* no motion vector coded */
- if (band->inherit_mv && ref_mb){
- /* motion vector inheritance */
- if (mv_scale) {
- mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
- mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
- } else {
- mb->mv_x = ref_mb->mv_x;
- mb->mv_y = ref_mb->mv_y;
- }
- }
- } else {
- if (band->inherit_mv && ref_mb) {
- mb->type = ref_mb->type; /* copy mb_type from corresponding reference mb */
- } else if (ctx->frame_type == FRAMETYPE_INTRA) {
- mb->type = 0; /* mb_type is always INTRA for intra-frames */
- } else {
- mb->type = get_bits1(&ctx->gb);
- }
-
- blks_per_mb = band->mb_size != band->blk_size ? 4 : 1;
- mb->cbp = get_bits(&ctx->gb, blks_per_mb);
-
- mb->q_delta = 0;
- if (band->qdelta_present) {
- if (band->inherit_qdelta) {
- if (ref_mb) mb->q_delta = ref_mb->q_delta;
- } else if (mb->cbp || (!band->plane && !band->band_num &&
- (ctx->frame_flags & 8))) {
- mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
- IVI_VLC_BITS, 1);
- mb->q_delta = IVI_TOSIGNED(mb->q_delta);
- }
- }
-
- if (!mb->type) {
- mb->mv_x = mb->mv_y = 0; /* there is no motion vector in intra-macroblocks */
- } else {
- if (band->inherit_mv && ref_mb){
- /* motion vector inheritance */
- if (mv_scale) {
- mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
- mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
- } else {
- mb->mv_x = ref_mb->mv_x;
- mb->mv_y = ref_mb->mv_y;
- }
- } else {
- /* decode motion vector deltas */
- mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
- IVI_VLC_BITS, 1);
- mv_y += IVI_TOSIGNED(mv_delta);
- mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
- IVI_VLC_BITS, 1);
- mv_x += IVI_TOSIGNED(mv_delta);
- mb->mv_x = mv_x;
- mb->mv_y = mv_y;
- }
- }
- }
-
- s= band->is_halfpel;
- if (mb->type)
- if ( x + (mb->mv_x >>s) + (y+ (mb->mv_y >>s))*band->pitch < 0 ||
- x + ((mb->mv_x+s)>>s) + band->mb_size - 1
- + (y+band->mb_size - 1 +((mb->mv_y+s)>>s))*band->pitch > band->bufsize - 1) {
- av_log(avctx, AV_LOG_ERROR, "motion vector %d %d outside reference\n", x*s + mb->mv_x, y*s + mb->mv_y);
- return AVERROR_INVALIDDATA;
- }
-
- mb++;
- if (ref_mb)
- ref_mb++;
- mb_offset += band->mb_size;
- }
-
- offs += row_offset;
- }
-
- align_get_bits(&ctx->gb);
-
- return 0;
-}
-
-
-/**
- * Switch buffers.
- *
- * @param[in,out] ctx ptr to the decoder context
- */
-static void switch_buffers(IVI45DecContext *ctx)
-{
- switch (ctx->prev_frame_type) {
- case FRAMETYPE_INTRA:
- case FRAMETYPE_INTER:
- ctx->buf_switch ^= 1;
- ctx->dst_buf = ctx->buf_switch;
- ctx->ref_buf = ctx->buf_switch ^ 1;
- break;
- case FRAMETYPE_INTER_SCAL:
- if (!ctx->inter_scal) {
- ctx->ref2_buf = 2;
- ctx->inter_scal = 1;
- }
- FFSWAP(int, ctx->dst_buf, ctx->ref2_buf);
- ctx->ref_buf = ctx->ref2_buf;
- break;
- case FRAMETYPE_INTER_NOREF:
- break;
- }
-
- switch (ctx->frame_type) {
- case FRAMETYPE_INTRA:
- ctx->buf_switch = 0;
- /* FALLTHROUGH */
- case FRAMETYPE_INTER:
- ctx->inter_scal = 0;
- ctx->dst_buf = ctx->buf_switch;
- ctx->ref_buf = ctx->buf_switch ^ 1;
- break;
- case FRAMETYPE_INTER_SCAL:
- case FRAMETYPE_INTER_NOREF:
- case FRAMETYPE_NULL:
- break;
- }
-}
-
-
-static int is_nonnull_frame(IVI45DecContext *ctx)
-{
- return ctx->frame_type != FRAMETYPE_NULL;
-}
-
-
-/**
- * Initialize Indeo5 decoder.
- */
-static av_cold int decode_init(AVCodecContext *avctx)
-{
- IVI45DecContext *ctx = avctx->priv_data;
- int result;
-
- ff_ivi_init_static_vlc();
-
- /* copy rvmap tables in our context so we can apply changes to them */
- memcpy(ctx->rvmap_tabs, ff_ivi_rvmap_tabs, sizeof(ff_ivi_rvmap_tabs));
-
- /* set the initial picture layout according to the basic profile:
- there is only one band per plane (no scalability), only one tile (no local decoding)
- and picture format = YVU9 */
- ctx->pic_conf.pic_width = avctx->width;
- ctx->pic_conf.pic_height = avctx->height;
- ctx->pic_conf.chroma_width = (avctx->width + 3) >> 2;
- ctx->pic_conf.chroma_height = (avctx->height + 3) >> 2;
- ctx->pic_conf.tile_width = avctx->width;
- ctx->pic_conf.tile_height = avctx->height;
- ctx->pic_conf.luma_bands = ctx->pic_conf.chroma_bands = 1;
-
- avcodec_get_frame_defaults(&ctx->frame);
-
- result = ff_ivi_init_planes(ctx->planes, &ctx->pic_conf);
- if (result) {
- av_log(avctx, AV_LOG_ERROR, "Couldn't allocate color planes!\n");
- return -1;
- }
-
- ctx->buf_switch = 0;
- ctx->inter_scal = 0;
-
- ctx->decode_pic_hdr = decode_pic_hdr;
- ctx->decode_band_hdr = decode_band_hdr;
- ctx->decode_mb_info = decode_mb_info;
- ctx->switch_buffers = switch_buffers;
- ctx->is_nonnull_frame = is_nonnull_frame;
-
- avctx->pix_fmt = AV_PIX_FMT_YUV410P;
-
- return 0;
-}
-
-AVCodec ff_indeo5_decoder = {
- .name = "indeo5",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_INDEO5,
- .priv_data_size = sizeof(IVI45DecContext),
- .init = decode_init,
- .close = ff_ivi_decode_close,
- .decode = ff_ivi_decode_frame,
- .long_name = NULL_IF_CONFIG_SMALL("Intel Indeo Video Interactive 5"),
- .capabilities = CODEC_CAP_DR1,
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/indeo5data.h b/src/thirdparty/ffmpeg/libavcodec/indeo5data.h
deleted file mode 100644
index 08c34f026..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/indeo5data.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Indeo Video Interactive 5 compatible decoder
- * Copyright (c) 2009 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
- * This file contains data needed for the Indeo5 decoder.
- */
-
-#ifndef AVCODEC_INDEO5DATA_H
-#define AVCODEC_INDEO5DATA_H
-
-#include <stdint.h>
-
-/**
- * standard picture dimensions (width, height divided by 4)
- */
-static const uint8_t ivi5_common_pic_sizes[30] = {
- 160, 120, 80, 60, 40, 30, 176, 120, 88, 60, 88, 72, 44, 36, 60, 45, 160, 60,
- 176, 60, 20, 15, 22, 18, 0, 0, 0, 0, 0, 0
-};
-
-
-/**
- * Indeo5 dequantization matrixes consist of two tables: base table
- * and scale table. The base table defines the dequantization matrix
- * itself and the scale table tells how this matrix should be scaled
- * for a particular quant level (0...24).
- *
- * ivi5_base_quant_bbb_ttt - base tables for block size 'bbb' of type 'ttt'
- * ivi5_scale_quant_bbb_ttt - scale tables for block size 'bbb' of type 'ttt'
- */
-static const uint16_t ivi5_base_quant_8x8_inter[5][64] = {
- {0x26, 0x3a, 0x3e, 0x46, 0x4a, 0x4e, 0x52, 0x5a, 0x3a, 0x3e, 0x42, 0x46, 0x4a, 0x4e, 0x56, 0x5e,
- 0x3e, 0x42, 0x46, 0x48, 0x4c, 0x52, 0x5a, 0x62, 0x46, 0x46, 0x48, 0x4a, 0x4e, 0x56, 0x5e, 0x66,
- 0x4a, 0x4a, 0x4c, 0x4e, 0x52, 0x5a, 0x62, 0x6a, 0x4e, 0x4e, 0x52, 0x56, 0x5a, 0x5e, 0x66, 0x6e,
- 0x52, 0x56, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x72, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x6e, 0x72, 0x76,
- },
- {0x26, 0x3a, 0x3e, 0x46, 0x4a, 0x4e, 0x52, 0x5a, 0x3a, 0x3e, 0x42, 0x46, 0x4a, 0x4e, 0x56, 0x5e,
- 0x3e, 0x42, 0x46, 0x48, 0x4c, 0x52, 0x5a, 0x62, 0x46, 0x46, 0x48, 0x4a, 0x4e, 0x56, 0x5e, 0x66,
- 0x4a, 0x4a, 0x4c, 0x4e, 0x52, 0x5a, 0x62, 0x6a, 0x4e, 0x4e, 0x52, 0x56, 0x5a, 0x5e, 0x66, 0x6e,
- 0x52, 0x56, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x72, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x6e, 0x72, 0x76,
- },
- {0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
- 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
- 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
- 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
- },
- {0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
- 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4,
- 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2,
- 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2,
- },
- {0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
- 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
- 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
- 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
- }
-};
-
-static const uint16_t ivi5_base_quant_8x8_intra[5][64] = {
- {0x1a, 0x2e, 0x36, 0x42, 0x46, 0x4a, 0x4e, 0x5a, 0x2e, 0x32, 0x3e, 0x42, 0x46, 0x4e, 0x56, 0x6a,
- 0x36, 0x3e, 0x3e, 0x44, 0x4a, 0x54, 0x66, 0x72, 0x42, 0x42, 0x44, 0x4a, 0x52, 0x62, 0x6c, 0x7a,
- 0x46, 0x46, 0x4a, 0x52, 0x5e, 0x66, 0x72, 0x8e, 0x4a, 0x4e, 0x54, 0x62, 0x66, 0x6e, 0x86, 0xa6,
- 0x4e, 0x56, 0x66, 0x6c, 0x72, 0x86, 0x9a, 0xca, 0x5a, 0x6a, 0x72, 0x7a, 0x8e, 0xa6, 0xca, 0xfe,
- },
- {0x26, 0x3a, 0x3e, 0x46, 0x4a, 0x4e, 0x52, 0x5a, 0x3a, 0x3e, 0x42, 0x46, 0x4a, 0x4e, 0x56, 0x5e,
- 0x3e, 0x42, 0x46, 0x48, 0x4c, 0x52, 0x5a, 0x62, 0x46, 0x46, 0x48, 0x4a, 0x4e, 0x56, 0x5e, 0x66,
- 0x4a, 0x4a, 0x4c, 0x4e, 0x52, 0x5a, 0x62, 0x6a, 0x4e, 0x4e, 0x52, 0x56, 0x5a, 0x5e, 0x66, 0x6e,
- 0x52, 0x56, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x72, 0x5a, 0x5e, 0x62, 0x66, 0x6a, 0x6e, 0x72, 0x76,
- },
- {0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
- 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
- 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
- 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2, 0x4e, 0xaa, 0xf2, 0xd4, 0xde, 0xc2, 0xd6, 0xc2,
- },
- {0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0x4e, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
- 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4, 0xd4,
- 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xde, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2,
- 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2, 0xc2,
- },
- {0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
- 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
- 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
- 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e, 0x5e,
- }
-};
-
-static const uint16_t ivi5_base_quant_4x4_inter[16] = {
- 0x1e, 0x3e, 0x4a, 0x52, 0x3e, 0x4a, 0x52, 0x56, 0x4a, 0x52, 0x56, 0x5e, 0x52, 0x56, 0x5e, 0x66
-};
-
-static const uint16_t ivi5_base_quant_4x4_intra[16] = {
- 0x1e, 0x3e, 0x4a, 0x52, 0x3e, 0x4a, 0x52, 0x5e, 0x4a, 0x52, 0x5e, 0x7a, 0x52, 0x5e, 0x7a, 0x92
-};
-
-
-static const uint8_t ivi5_scale_quant_8x8_inter[5][24] = {
- {0x0b, 0x11, 0x13, 0x14, 0x15, 0x16, 0x18, 0x1a, 0x1b, 0x1d, 0x20, 0x22,
- 0x23, 0x25, 0x28, 0x2a, 0x2e, 0x32, 0x35, 0x39, 0x3d, 0x41, 0x44, 0x4a,
- },
- {0x07, 0x14, 0x16, 0x18, 0x1b, 0x1e, 0x22, 0x25, 0x29, 0x2d, 0x31, 0x35,
- 0x3a, 0x3f, 0x44, 0x4a, 0x50, 0x56, 0x5c, 0x63, 0x6a, 0x71, 0x78, 0x7e,
- },
- {0x15, 0x25, 0x28, 0x2d, 0x30, 0x34, 0x3a, 0x3d, 0x42, 0x48, 0x4c, 0x51,
- 0x56, 0x5b, 0x60, 0x65, 0x6b, 0x70, 0x76, 0x7c, 0x82, 0x88, 0x8f, 0x97,
- },
- {0x13, 0x1f, 0x20, 0x22, 0x25, 0x28, 0x2b, 0x2d, 0x30, 0x33, 0x36, 0x39,
- 0x3c, 0x3f, 0x42, 0x45, 0x48, 0x4b, 0x4e, 0x52, 0x56, 0x5a, 0x5e, 0x62,
- },
- {0x3c, 0x52, 0x58, 0x5d, 0x63, 0x68, 0x68, 0x6d, 0x73, 0x78, 0x7c, 0x80,
- 0x84, 0x89, 0x8e, 0x93, 0x98, 0x9d, 0xa3, 0xa9, 0xad, 0xb1, 0xb5, 0xba,
- },
-};
-
-static const uint8_t ivi5_scale_quant_8x8_intra[5][24] = {
- {0x0b, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x17, 0x18, 0x1a, 0x1c, 0x1e, 0x20,
- 0x22, 0x24, 0x27, 0x28, 0x2a, 0x2d, 0x2f, 0x31, 0x34, 0x37, 0x39, 0x3c,
- },
- {0x01, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1b, 0x1e, 0x22, 0x25, 0x28, 0x2c,
- 0x30, 0x34, 0x38, 0x3d, 0x42, 0x47, 0x4c, 0x52, 0x58, 0x5e, 0x65, 0x6c,
- },
- {0x13, 0x22, 0x27, 0x2a, 0x2d, 0x33, 0x36, 0x3c, 0x41, 0x45, 0x49, 0x4e,
- 0x53, 0x58, 0x5d, 0x63, 0x69, 0x6f, 0x75, 0x7c, 0x82, 0x88, 0x8e, 0x95,
- },
- {0x13, 0x1f, 0x21, 0x24, 0x27, 0x29, 0x2d, 0x2f, 0x34, 0x37, 0x3a, 0x3d,
- 0x40, 0x44, 0x48, 0x4c, 0x4f, 0x52, 0x56, 0x5a, 0x5e, 0x62, 0x66, 0x6b,
- },
- {0x31, 0x42, 0x47, 0x47, 0x4d, 0x52, 0x58, 0x58, 0x5d, 0x63, 0x67, 0x6b,
- 0x6f, 0x73, 0x78, 0x7c, 0x80, 0x84, 0x89, 0x8e, 0x93, 0x98, 0x9d, 0xa4,
- }
-};
-
-static const uint8_t ivi5_scale_quant_4x4_inter[24] = {
- 0x0b, 0x0d, 0x0d, 0x0e, 0x11, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
-};
-
-static const uint8_t ivi5_scale_quant_4x4_intra[24] = {
- 0x01, 0x0b, 0x0b, 0x0d, 0x0d, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x13, 0x14,
- 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20
-};
-
-
-#endif /* AVCODEC_INDEO5DATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/intelh263dec.c b/src/thirdparty/ffmpeg/libavcodec/intelh263dec.c
deleted file mode 100644
index 8d1bc281e..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/intelh263dec.c
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * H.263i decoder
- *
- * 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 "mpegvideo.h"
-#include "h263.h"
-
-/* don't understand why they choose a different header ! */
-int ff_intel_h263_decode_picture_header(MpegEncContext *s)
-{
- int format;
-
- /* picture header */
- if (get_bits_long(&s->gb, 22) != 0x20) {
- av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
- return -1;
- }
- s->picture_number = get_bits(&s->gb, 8); /* picture timestamp */
-
- if (get_bits1(&s->gb) != 1) {
- av_log(s->avctx, AV_LOG_ERROR, "Bad marker\n");
- return -1; /* marker */
- }
- if (get_bits1(&s->gb) != 0) {
- av_log(s->avctx, AV_LOG_ERROR, "Bad H263 id\n");
- return -1; /* h263 id */
- }
- skip_bits1(&s->gb); /* split screen off */
- skip_bits1(&s->gb); /* camera off */
- skip_bits1(&s->gb); /* freeze picture release off */
-
- format = get_bits(&s->gb, 3);
- if (format == 0 || format == 6) {
- av_log(s->avctx, AV_LOG_ERROR, "Intel H263 free format not supported\n");
- return -1;
- }
- s->h263_plus = 0;
-
- s->pict_type = AV_PICTURE_TYPE_I + get_bits1(&s->gb);
-
- s->h263_long_vectors = get_bits1(&s->gb);
-
- if (get_bits1(&s->gb) != 0) {
- av_log(s->avctx, AV_LOG_ERROR, "SAC not supported\n");
- return -1; /* SAC: off */
- }
- s->obmc= get_bits1(&s->gb);
- s->unrestricted_mv = s->obmc || s->h263_long_vectors;
- s->pb_frame = get_bits1(&s->gb);
-
- if (format < 6) {
- s->width = ff_h263_format[format][0];
- s->height = ff_h263_format[format][1];
- s->avctx->sample_aspect_ratio.num = 12;
- s->avctx->sample_aspect_ratio.den = 11;
- } else {
- format = get_bits(&s->gb, 3);
- if(format == 0 || format == 7){
- av_log(s->avctx, AV_LOG_ERROR, "Wrong Intel H263 format\n");
- return -1;
- }
- if(get_bits(&s->gb, 2))
- av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
- s->loop_filter = get_bits1(&s->gb) * !s->avctx->lowres;
- if(get_bits1(&s->gb))
- av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
- if(get_bits1(&s->gb))
- s->pb_frame = 2;
- if(get_bits(&s->gb, 5))
- av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
- if(get_bits(&s->gb, 5) != 1)
- av_log(s->avctx, AV_LOG_ERROR, "Invalid marker\n");
- }
- if(format == 6){
- int ar = get_bits(&s->gb, 4);
- skip_bits(&s->gb, 9); // display width
- skip_bits1(&s->gb);
- skip_bits(&s->gb, 9); // display height
- if(ar == 15){
- s->avctx->sample_aspect_ratio.num = get_bits(&s->gb, 8); // aspect ratio - width
- s->avctx->sample_aspect_ratio.den = get_bits(&s->gb, 8); // aspect ratio - height
- } else {
- s->avctx->sample_aspect_ratio = ff_h263_pixel_aspect[ar];
- }
- if (s->avctx->sample_aspect_ratio.num == 0)
- av_log(s->avctx, AV_LOG_ERROR, "Invalid aspect ratio.\n");
- }
-
- s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
- skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */
-
- if(s->pb_frame){
- skip_bits(&s->gb, 3); //temporal reference for B-frame
- skip_bits(&s->gb, 2); //dbquant
- }
-
- /* PEI */
- while (get_bits1(&s->gb) != 0) {
- skip_bits(&s->gb, 8);
- }
- s->f_code = 1;
-
- s->y_dc_scale_table=
- s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
-
- ff_h263_show_pict_info(s);
-
- return 0;
-}
-
-AVCodec ff_h263i_decoder = {
- .name = "h263i",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_H263I,
- .priv_data_size = sizeof(MpegEncContext),
- .init = ff_h263_decode_init,
- .close = ff_h263_decode_end,
- .decode = ff_h263_decode_frame,
- .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("Intel H.263"),
- .pix_fmts = ff_pixfmt_list_420,
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/internal.h b/src/thirdparty/ffmpeg/libavcodec/internal.h
deleted file mode 100644
index dd512b4bc..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/internal.h
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * 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
- * common internal api header.
- */
-
-#ifndef AVCODEC_INTERNAL_H
-#define AVCODEC_INTERNAL_H
-
-#include <stdint.h>
-
-#include "libavutil/mathematics.h"
-#include "libavutil/pixfmt.h"
-#include "avcodec.h"
-
-#define FF_SANE_NB_CHANNELS 128U
-
-typedef struct InternalBuffer {
- uint8_t *base[AV_NUM_DATA_POINTERS];
- uint8_t *data[AV_NUM_DATA_POINTERS];
- int linesize[AV_NUM_DATA_POINTERS];
- int width;
- int height;
- enum AVPixelFormat pix_fmt;
-} InternalBuffer;
-
-typedef struct AVCodecInternal {
- /**
- * internal buffer count
- * used by default get/release/reget_buffer().
- */
- int buffer_count;
-
- /**
- * internal buffers
- * used by default get/release/reget_buffer().
- */
- InternalBuffer *buffer;
-
- /**
- * Whether the parent AVCodecContext is a copy of the context which had
- * init() called on it.
- * This is used by multithreading - shared tables and picture pointers
- * should be freed from the original context only.
- */
- int is_copy;
-
-#if FF_API_OLD_DECODE_AUDIO
- /**
- * Internal sample count used by avcodec_encode_audio() to fabricate pts.
- * Can be removed along with avcodec_encode_audio().
- */
- int sample_count;
-#endif
-
- /**
- * An audio frame with less than required samples has been submitted and
- * padded with silence. Reject all subsequent frames.
- */
- int last_audio_frame;
-
- /**
- * The data for the last allocated audio frame.
- * Stored here so we can free it.
- */
- uint8_t *audio_data;
-
- /**
- * temporary buffer used for encoders to store their bitstream
- */
- uint8_t *byte_buffer;
- unsigned int byte_buffer_size;
-
- void *frame_thread_encoder;
-
- /**
- * Number of audio samples to skip at the start of the next decoded frame
- */
- int skip_samples;
-} AVCodecInternal;
-
-struct AVCodecDefault {
- const uint8_t *key;
- const uint8_t *value;
-};
-
-/**
- * Return the hardware accelerated codec for codec codec_id and
- * pixel format pix_fmt.
- *
- * @param codec_id the codec to match
- * @param pix_fmt the pixel format to match
- * @return the hardware accelerated codec, or NULL if none was found.
- */
-AVHWAccel *ff_find_hwaccel(enum AVCodecID codec_id, enum AVPixelFormat pix_fmt);
-
-/**
- * Return the index into tab at which {a,b} match elements {[0],[1]} of tab.
- * If there is no such matching pair then size is returned.
- */
-int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b);
-
-unsigned int avpriv_toupper4(unsigned int x);
-
-/**
- * does needed setup of pkt_pts/pos and such for (re)get_buffer();
- */
-void ff_init_buffer_info(AVCodecContext *s, AVFrame *frame);
-
-
-void avpriv_color_frame(AVFrame *frame, const int color[4]);
-
-/**
- * Remove and free all side data from packet.
- */
-void ff_packet_free_side_data(AVPacket *pkt);
-
-extern volatile int ff_avcodec_locked;
-int ff_lock_avcodec(AVCodecContext *log_ctx);
-int ff_unlock_avcodec(void);
-
-int avpriv_lock_avformat(void);
-int avpriv_unlock_avformat(void);
-
-/**
- * Maximum size in bytes of extradata.
- * This value was chosen such that every bit of the buffer is
- * addressable by a 32-bit signed integer as used by get_bits.
- */
-#define FF_MAX_EXTRADATA_SIZE ((1 << 28) - FF_INPUT_BUFFER_PADDING_SIZE)
-
-/**
- * Check AVPacket size and/or allocate data.
- *
- * Encoders supporting AVCodec.encode2() can use this as a convenience to
- * ensure the output packet data is large enough, whether provided by the user
- * or allocated in this function.
- *
- * @param avctx the AVCodecContext of the encoder
- * @param avpkt the AVPacket
- * If avpkt->data is already set, avpkt->size is checked
- * to ensure it is large enough.
- * If avpkt->data is NULL, a new buffer is allocated.
- * avpkt->size is set to the specified size.
- * All other AVPacket fields will be reset with av_init_packet().
- * @param size the minimum required packet size
- * @return 0 on success, negative error code on failure
- */
-int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int size);
-
-int ff_alloc_packet(AVPacket *avpkt, int size);
-
-/**
- * Rescale from sample rate to AVCodecContext.time_base.
- */
-static av_always_inline int64_t ff_samples_to_time_base(AVCodecContext *avctx,
- int64_t samples)
-{
- if(samples == AV_NOPTS_VALUE)
- return AV_NOPTS_VALUE;
- return av_rescale_q(samples, (AVRational){ 1, avctx->sample_rate },
- avctx->time_base);
-}
-
-/**
- * Get a buffer for a frame. This is a wrapper around
- * AVCodecContext.get_buffer() and should be used instead calling get_buffer()
- * directly.
- */
-int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame);
-
-int ff_thread_can_start_frame(AVCodecContext *avctx);
-
-int ff_get_logical_cpus(AVCodecContext *avctx);
-
-int avpriv_h264_has_num_reorder_frames(AVCodecContext *avctx);
-
-/**
- * Call avcodec_open2 recursively by decrementing counter, unlocking mutex,
- * calling the function and then restoring again. Assumes the mutex is
- * already locked
- */
-int ff_codec_open2_recursive(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options);
-
-/**
- * Call avcodec_close recursively, counterpart to avcodec_open2_recursive.
- */
-int ff_codec_close_recursive(AVCodecContext *avctx);
-
-/**
- * Finalize buf into extradata and set its size appropriately.
- */
-int avpriv_bprint_to_extradata(AVCodecContext *avctx, struct AVBPrint *buf);
-
-#endif /* AVCODEC_INTERNAL_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/intrax8.c b/src/thirdparty/ffmpeg/libavcodec/intrax8.c
deleted file mode 100644
index cb657fe9d..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/intrax8.c
+++ /dev/null
@@ -1,788 +0,0 @@
-/*
- * 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
- * @brief IntraX8 (J-Frame) subdecoder, used by WMV2 and VC-1
- */
-
-#include "libavutil/avassert.h"
-#include "avcodec.h"
-#include "get_bits.h"
-#include "mpegvideo.h"
-#include "msmpeg4data.h"
-#include "intrax8huf.h"
-#include "intrax8.h"
-#include "intrax8dsp.h"
-
-#define MAX_TABLE_DEPTH(table_bits, max_bits) ((max_bits+table_bits-1)/table_bits)
-
-#define DC_VLC_BITS 9
-#define AC_VLC_BITS 9
-#define OR_VLC_BITS 7
-
-#define DC_VLC_MTD MAX_TABLE_DEPTH(DC_VLC_BITS, MAX_DC_VLC_BITS)
-#define AC_VLC_MTD MAX_TABLE_DEPTH(AC_VLC_BITS, MAX_AC_VLC_BITS)
-#define OR_VLC_MTD MAX_TABLE_DEPTH(OR_VLC_BITS, MAX_OR_VLC_BITS)
-
-static VLC j_ac_vlc[2][2][8]; //[quant<13],[intra/inter],[select]
-static VLC j_dc_vlc[2][8]; //[quant], [select]
-static VLC j_orient_vlc[2][4]; //[quant], [select]
-
-static av_cold void x8_vlc_init(void){
- int i;
- int offset = 0;
- int sizeidx = 0;
- static const uint16_t sizes[8*4 + 8*2 + 2 + 4] = {
- 576, 548, 582, 618, 546, 616, 560, 642,
- 584, 582, 704, 664, 512, 544, 656, 640,
- 512, 648, 582, 566, 532, 614, 596, 648,
- 586, 552, 584, 590, 544, 578, 584, 624,
-
- 528, 528, 526, 528, 536, 528, 526, 544,
- 544, 512, 512, 528, 528, 544, 512, 544,
-
- 128, 128, 128, 128, 128, 128};
-
- static VLC_TYPE table[28150][2];
-
-#define init_ac_vlc(dst,src) \
- dst.table = &table[offset]; \
- dst.table_allocated = sizes[sizeidx]; \
- offset += sizes[sizeidx++]; \
- init_vlc(&dst, \
- AC_VLC_BITS,77, \
- &src[1],4,2, \
- &src[0],4,2, \
- INIT_VLC_USE_NEW_STATIC)
-//set ac tables
- for(i=0;i<8;i++){
- init_ac_vlc( j_ac_vlc[0][0][i], x8_ac0_highquant_table[i][0] );
- init_ac_vlc( j_ac_vlc[0][1][i], x8_ac1_highquant_table[i][0] );
- init_ac_vlc( j_ac_vlc[1][0][i], x8_ac0_lowquant_table [i][0] );
- init_ac_vlc( j_ac_vlc[1][1][i], x8_ac1_lowquant_table [i][0] );
- }
-#undef init_ac_vlc
-
-//set dc tables
-#define init_dc_vlc(dst,src) \
- dst.table = &table[offset]; \
- dst.table_allocated = sizes[sizeidx]; \
- offset += sizes[sizeidx++]; \
- init_vlc(&dst, \
- DC_VLC_BITS,34, \
- &src[1],4,2, \
- &src[0],4,2, \
- INIT_VLC_USE_NEW_STATIC);
- for(i=0;i<8;i++){
- init_dc_vlc( j_dc_vlc[0][i], x8_dc_highquant_table[i][0]);
- init_dc_vlc( j_dc_vlc[1][i], x8_dc_lowquant_table [i][0]);
- }
-#undef init_dc_vlc
-
-//set orient tables
-#define init_or_vlc(dst,src) \
- dst.table = &table[offset]; \
- dst.table_allocated = sizes[sizeidx]; \
- offset += sizes[sizeidx++]; \
- init_vlc(&dst, \
- OR_VLC_BITS,12, \
- &src[1],4,2, \
- &src[0],4,2, \
- INIT_VLC_USE_NEW_STATIC);
- for(i=0;i<2;i++){
- init_or_vlc( j_orient_vlc[0][i], x8_orient_highquant_table[i][0]);
- }
- for(i=0;i<4;i++){
- init_or_vlc( j_orient_vlc[1][i], x8_orient_lowquant_table [i][0])
- }
- if (offset != sizeof(table)/sizeof(VLC_TYPE)/2)
- av_log(NULL, AV_LOG_ERROR, "table size %i does not match needed %i\n", (int)(sizeof(table)/sizeof(VLC_TYPE)/2), offset);
-}
-#undef init_or_vlc
-
-static void x8_reset_vlc_tables(IntraX8Context * w){
- memset(w->j_dc_vlc,0,sizeof(w->j_dc_vlc));
- memset(w->j_ac_vlc,0,sizeof(w->j_ac_vlc));
- w->j_orient_vlc=NULL;
-}
-
-static inline void x8_select_ac_table(IntraX8Context * const w , int mode){
- MpegEncContext * const s= w->s;
- int table_index;
-
- av_assert2(mode<4);
-
- if( w->j_ac_vlc[mode] ) return;
-
- table_index = get_bits(&s->gb, 3);
- w->j_ac_vlc[mode] = &j_ac_vlc[w->quant<13][mode>>1][table_index];//2 modes use same tables
- av_assert2(w->j_ac_vlc[mode]);
-}
-
-static inline int x8_get_orient_vlc(IntraX8Context * w){
- MpegEncContext * const s= w->s;
- int table_index;
-
- if(!w->j_orient_vlc ){
- table_index = get_bits(&s->gb, 1+(w->quant<13) );
- w->j_orient_vlc = &j_orient_vlc[w->quant<13][table_index];
- }
-
- return get_vlc2(&s->gb, w->j_orient_vlc->table, OR_VLC_BITS, OR_VLC_MTD);
-}
-
-#define extra_bits(eb) (eb)
-#define extra_run (0xFF<<8)
-#define extra_level (0x00<<8)
-#define run_offset(r) ((r)<<16)
-#define level_offset(l) ((l)<<24)
-static const uint32_t ac_decode_table[]={
- /*46*/ extra_bits(3) | extra_run | run_offset(16) | level_offset( 0),
- /*47*/ extra_bits(3) | extra_run | run_offset(24) | level_offset( 0),
- /*48*/ extra_bits(2) | extra_run | run_offset( 4) | level_offset( 1),
- /*49*/ extra_bits(3) | extra_run | run_offset( 8) | level_offset( 1),
-
- /*50*/ extra_bits(5) | extra_run | run_offset(32) | level_offset( 0),
- /*51*/ extra_bits(4) | extra_run | run_offset(16) | level_offset( 1),
-
- /*52*/ extra_bits(2) | extra_level | run_offset( 0) | level_offset( 4),
- /*53*/ extra_bits(2) | extra_level | run_offset( 0) | level_offset( 8),
- /*54*/ extra_bits(2) | extra_level | run_offset( 0) | level_offset(12),
- /*55*/ extra_bits(3) | extra_level | run_offset( 0) | level_offset(16),
- /*56*/ extra_bits(3) | extra_level | run_offset( 0) | level_offset(24),
-
- /*57*/ extra_bits(2) | extra_level | run_offset( 1) | level_offset( 3),
- /*58*/ extra_bits(3) | extra_level | run_offset( 1) | level_offset( 7),
-
- /*59*/ extra_bits(2) | extra_run | run_offset(16) | level_offset( 0),
- /*60*/ extra_bits(2) | extra_run | run_offset(20) | level_offset( 0),
- /*61*/ extra_bits(2) | extra_run | run_offset(24) | level_offset( 0),
- /*62*/ extra_bits(2) | extra_run | run_offset(28) | level_offset( 0),
- /*63*/ extra_bits(4) | extra_run | run_offset(32) | level_offset( 0),
- /*64*/ extra_bits(4) | extra_run | run_offset(48) | level_offset( 0),
-
- /*65*/ extra_bits(2) | extra_run | run_offset( 4) | level_offset( 1),
- /*66*/ extra_bits(3) | extra_run | run_offset( 8) | level_offset( 1),
- /*67*/ extra_bits(4) | extra_run | run_offset(16) | level_offset( 1),
-
- /*68*/ extra_bits(2) | extra_level | run_offset( 0) | level_offset( 4),
- /*69*/ extra_bits(3) | extra_level | run_offset( 0) | level_offset( 8),
- /*70*/ extra_bits(4) | extra_level | run_offset( 0) | level_offset(16),
-
- /*71*/ extra_bits(2) | extra_level | run_offset( 1) | level_offset( 3),
- /*72*/ extra_bits(3) | extra_level | run_offset( 1) | level_offset( 7),
-};
-//extra_bits = 3bits; extra_run/level = 1 bit; run_offset = 6bits; level_offset = 5 bits;
-#undef extra_bits
-#undef extra_run
-#undef extra_level
-#undef run_offset
-#undef level_offset
-
-static void x8_get_ac_rlf(IntraX8Context * const w, const int mode,
- int * const run, int * const level, int * const final){
- MpegEncContext * const s= w->s;
- int i,e;
-
-// x8_select_ac_table(w,mode);
- i = get_vlc2(&s->gb, w->j_ac_vlc[mode]->table, AC_VLC_BITS, AC_VLC_MTD);
-
- if(i<46){ //[0-45]
- int t,l;
- if(i<0){
- (*level)=(*final)=//prevent 'may be used unilitialized'
- (*run)=64;//this would cause error exit in the ac loop
- return;
- }
-
- (*final) = t = (i>22);
- i-=23*t;
-/*
- i== 0-15 r=0-15 l=0 ;r=i& %01111
- i==16-19 r=0-3 l=1 ;r=i& %00011
- i==20-21 r=0-1 l=2 ;r=i& %00001
- i==22 r=0 l=3 ;r=i& %00000
-l=lut_l[i/2]={0,0,0,0,0,0,0,0,1,1,2,3}[i>>1];// 11 10'01 01'00 00'00 00'00 00'00 00 => 0xE50000
-t=lut_mask[l]={0x0f,0x03,0x01,0x00}[l]; as i<256 the higher bits do not matter */
- l=(0xE50000>>(i&(0x1E)))&3;/*0x1E or (~1) or ((i>>1)<<1)*/
- t=(0x01030F>>(l<<3));
-
- (*run) = i&t;
- (*level) = l;
- }else if(i<73){//[46-72]
- uint32_t sm;
- uint32_t mask;
-
- i-=46;
- sm=ac_decode_table[i];
-
- e=get_bits(&s->gb,sm&0xF);sm>>=8;//3bits
- mask=sm&0xff;sm>>=8; //1bit
-
- (*run) =(sm&0xff) + (e&( mask));//6bits
- (*level)=(sm>>8) + (e&(~mask));//5bits
- (*final)=i>(58-46);
- }else if(i<75){//[73-74]
- static const uint8_t crazy_mix_runlevel[32]={
- 0x22,0x32,0x33,0x53,0x23,0x42,0x43,0x63,
- 0x24,0x52,0x34,0x73,0x25,0x62,0x44,0x83,
- 0x26,0x72,0x35,0x54,0x27,0x82,0x45,0x64,
- 0x28,0x92,0x36,0x74,0x29,0xa2,0x46,0x84};
-
- (*final)=!(i&1);
- e=get_bits(&s->gb,5);//get the extra bits
- (*run) =crazy_mix_runlevel[e]>>4;
- (*level)=crazy_mix_runlevel[e]&0x0F;
- }else{
- (*level)=get_bits( &s->gb, 7-3*(i&1));
- (*run) =get_bits( &s->gb, 6);
- (*final)=get_bits1(&s->gb);
- }
- return;
-}
-
-//static const uint8_t dc_extra_sbits[] ={0, 1,1, 1,1, 2,2, 3,3, 4,4, 5,5, 6,6, 7,7 };
-static const uint8_t dc_index_offset[] ={ 0, 1,2, 3,4, 5,7, 9,13, 17,25, 33,49, 65,97, 129,193};
-
-static int x8_get_dc_rlf(IntraX8Context * const w,int const mode, int * const level, int * const final){
- MpegEncContext * const s= w->s;
- int i,e,c;
-
- av_assert2(mode<3);
- if( !w->j_dc_vlc[mode] ) {
- int table_index;
- table_index = get_bits(&s->gb, 3);
- //4 modes, same table
- w->j_dc_vlc[mode]= &j_dc_vlc[w->quant<13][table_index];
- }
-
- i=get_vlc2(&s->gb, w->j_dc_vlc[mode]->table, DC_VLC_BITS, DC_VLC_MTD);
-
- /*(i>=17) {i-=17;final=1;}*/
- c= i>16;
- (*final)=c;
- i-=17*c;
-
- if(i<=0){
- (*level)=0;
- return -i;
- }
- c=(i+1)>>1;//hackish way to calculate dc_extra_sbits[]
- c-=c>1;
-
- e=get_bits(&s->gb,c);//get the extra bits
- i=dc_index_offset[i]+(e>>1);
-
- e= -(e & 1);//0,0xffffff
- (*level)= (i ^ e) - e;// (i^0)-0 , (i^0xff)-(-1)
- return 0;
-}
-//end of huffman
-
-static int x8_setup_spatial_predictor(IntraX8Context * const w, const int chroma){
- MpegEncContext * const s= w->s;
- int range;
- int sum;
- int quant;
-
- w->dsp.setup_spatial_compensation(s->dest[chroma], s->edge_emu_buffer,
- s->current_picture.f.linesize[chroma>0],
- &range, &sum, w->edges);
- if(chroma){
- w->orient=w->chroma_orient;
- quant=w->quant_dc_chroma;
- }else{
- quant=w->quant;
- }
-
- w->flat_dc=0;
- if(range < quant || range < 3){
- w->orient=0;
- if(range < 3){//yep you read right, a +-1 idct error may break decoding!
- w->flat_dc=1;
- sum+=9;
- w->predicted_dc = (sum*6899)>>17;//((1<<17)+9)/(8+8+1+2)=6899
- }
- }
- if(chroma)
- return 0;
-
- av_assert2(w->orient < 3);
- if(range < 2*w->quant){
- if( (w->edges&3) == 0){
- if(w->orient==1) w->orient=11;
- if(w->orient==2) w->orient=10;
- }else{
- w->orient=0;
- }
- w->raw_orient=0;
- }else{
- static const uint8_t prediction_table[3][12]={
- {0,8,4, 10,11, 2,6,9,1,3,5,7},
- {4,0,8, 11,10, 3,5,2,6,9,1,7},
- {8,0,4, 10,11, 1,7,2,6,9,3,5}
- };
- w->raw_orient=x8_get_orient_vlc(w);
- if(w->raw_orient<0) return -1;
- av_assert2(w->raw_orient < 12 );
- av_assert2(w->orient<3);
- w->orient=prediction_table[w->orient][w->raw_orient];
- }
- return 0;
-}
-
-static void x8_update_predictions(IntraX8Context * const w, const int orient, const int est_run ){
- MpegEncContext * const s= w->s;
-
- w->prediction_table[s->mb_x*2+(s->mb_y&1)] = (est_run<<2) + 1*(orient==4) + 2*(orient==8);
-/*
- y=2n+0 ->//0 2 4
- y=2n+1 ->//1 3 5
-*/
-}
-static void x8_get_prediction_chroma(IntraX8Context * const w){
- MpegEncContext * const s= w->s;
-
- w->edges = 1*( !(s->mb_x>>1) );
- w->edges|= 2*( !(s->mb_y>>1) );
- w->edges|= 4*( s->mb_x >= (2*s->mb_width-1) );//mb_x for chroma would always be odd
-
- w->raw_orient=0;
- if(w->edges&3){//lut_co[8]={inv,4,8,8, inv,4,8,8}<- =>{1,1,0,0;1,1,0,0} => 0xCC
- w->chroma_orient=4<<((0xCC>>w->edges)&1);
- return;
- }
- w->chroma_orient = (w->prediction_table[2*s->mb_x-2] & 0x03)<<2;//block[x-1][y|1-1)]
-}
-
-static void x8_get_prediction(IntraX8Context * const w){
- MpegEncContext * const s= w->s;
- int a,b,c,i;
-
- w->edges = 1*( !s->mb_x );
- w->edges|= 2*( !s->mb_y );
- w->edges|= 4*( s->mb_x >= (2*s->mb_width-1) );
-
- switch(w->edges&3){
- case 0:
- break;
- case 1:
- //take the one from the above block[0][y-1]
- w->est_run = w->prediction_table[!(s->mb_y&1)]>>2;
- w->orient = 1;
- return;
- case 2:
- //take the one from the previous block[x-1][0]
- w->est_run = w->prediction_table[2*s->mb_x-2]>>2;
- w->orient = 2;
- return;
- case 3:
- w->est_run = 16;
- w->orient = 0;
- return;
- }
- //no edge cases
- b= w->prediction_table[2*s->mb_x + !(s->mb_y&1) ];//block[x ][y-1]
- a= w->prediction_table[2*s->mb_x-2 + (s->mb_y&1) ];//block[x-1][y ]
- c= w->prediction_table[2*s->mb_x-2 + !(s->mb_y&1) ];//block[x-1][y-1]
-
- w->est_run = FFMIN(b,a);
- /* This condition has nothing to do with w->edges, even if it looks
- similar it would trigger if e.g. x=3;y=2;
- I guess somebody wrote something wrong and it became standard. */
- if( (s->mb_x & s->mb_y) != 0 ) w->est_run=FFMIN(c,w->est_run);
- w->est_run>>=2;
-
- a&=3;
- b&=3;
- c&=3;
-
- i=( 0xFFEAF4C4>>(2*b+8*a) )&3;
- if(i!=3) w->orient=i;
- else w->orient=( 0xFFEAD8>>(2*c+8*(w->quant>12)) )&3;
-/*
-lut1[b][a]={
-->{0, 1, 0, pad},
- {0, 1, X, pad},
- {2, 2, 2, pad}}
- pad 2 2 2; pad X 1 0; pad 0 1 0 <-
--> 11 10 '10 10 '11 11'01 00 '11 00'01 00=>0xEAF4C4
-
-lut2[q>12][c]={
- ->{0,2,1,pad},
- {2,2,2,pad}}
- pad 2 2 2; pad 1 2 0 <-
--> 11 10'10 10 '11 01'10 00=>0xEAD8
-*/
-}
-
-
-static void x8_ac_compensation(IntraX8Context * const w, int const direction, int const dc_level){
- MpegEncContext * const s= w->s;
- int t;
-#define B(x,y) s->block[0][s->dsp.idct_permutation[(x)+(y)*8]]
-#define T(x) ((x) * dc_level + 0x8000) >> 16;
- switch(direction){
- case 0:
- t = T(3811);//h
- B(1,0) -= t;
- B(0,1) -= t;
-
- t = T(487);//e
- B(2,0) -= t;
- B(0,2) -= t;
-
- t = T(506);//f
- B(3,0) -= t;
- B(0,3) -= t;
-
- t = T(135);//c
- B(4,0) -= t;
- B(0,4) -= t;
- B(2,1) += t;
- B(1,2) += t;
- B(3,1) += t;
- B(1,3) += t;
-
- t = T(173);//d
- B(5,0) -= t;
- B(0,5) -= t;
-
- t = T(61);//b
- B(6,0) -= t;
- B(0,6) -= t;
- B(5,1) += t;
- B(1,5) += t;
-
- t = T(42); //a
- B(7,0) -= t;
- B(0,7) -= t;
- B(4,1) += t;
- B(1,4) += t;
- B(4,4) += t;
-
- t = T(1084);//g
- B(1,1) += t;
-
- s->block_last_index[0] = FFMAX(s->block_last_index[0], 7*8);
- break;
- case 1:
- B(0,1) -= T(6269);
- B(0,3) -= T( 708);
- B(0,5) -= T( 172);
- B(0,7) -= T( 73);
-
- s->block_last_index[0] = FFMAX(s->block_last_index[0], 7*8);
- break;
- case 2:
- B(1,0) -= T(6269);
- B(3,0) -= T( 708);
- B(5,0) -= T( 172);
- B(7,0) -= T( 73);
-
- s->block_last_index[0] = FFMAX(s->block_last_index[0], 7);
- break;
- }
-#undef B
-#undef T
-}
-
-static void dsp_x8_put_solidcolor(uint8_t const pix, uint8_t * dst, int const linesize){
- int k;
- for(k=0;k<8;k++){
- memset(dst,pix,8);
- dst+=linesize;
- }
-}
-
-static const int16_t quant_table[64] = {
- 256, 256, 256, 256, 256, 256, 259, 262,
- 265, 269, 272, 275, 278, 282, 285, 288,
- 292, 295, 299, 303, 306, 310, 314, 317,
- 321, 325, 329, 333, 337, 341, 345, 349,
- 353, 358, 362, 366, 371, 375, 379, 384,
- 389, 393, 398, 403, 408, 413, 417, 422,
- 428, 433, 438, 443, 448, 454, 459, 465,
- 470, 476, 482, 488, 493, 499, 505, 511
-};
-
-static int x8_decode_intra_mb(IntraX8Context* const w, const int chroma){
- MpegEncContext * const s= w->s;
-
- uint8_t * scantable;
- int final,run,level;
- int ac_mode,dc_mode,est_run,dc_level;
- int pos,n;
- int zeros_only;
- int use_quant_matrix;
- int sign;
-
- av_assert2(w->orient<12);
- s->dsp.clear_block(s->block[0]);
-
- if(chroma){
- dc_mode=2;
- }else{
- dc_mode=!!w->est_run;//0,1
- }
-
- if(x8_get_dc_rlf(w, dc_mode, &dc_level, &final)) return -1;
- n=0;
- zeros_only=0;
- if(!final){//decode ac
- use_quant_matrix=w->use_quant_matrix;
- if(chroma){
- ac_mode = 1;
- est_run = 64;//not used
- }else{
- if (w->raw_orient < 3){
- use_quant_matrix = 0;
- }
- if(w->raw_orient > 4){
- ac_mode = 0;
- est_run = 64;
- }else{
- if(w->est_run > 1){
- ac_mode = 2;
- est_run=w->est_run;
- }else{
- ac_mode = 3;
- est_run = 64;
- }
- }
- }
- x8_select_ac_table(w,ac_mode);
- /*scantable_selector[12]={0,2,0,1,1,1,0,2,2,0,1,2};<-
- -> 10'01' 00'10' 10'00' 01'01' 01'00' 10'00 =>0x928548 */
- scantable = w->scantable[ (0x928548>>(2*w->orient))&3 ].permutated;
- pos=0;
- do {
- n++;
- if( n >= est_run ){
- ac_mode=3;
- x8_select_ac_table(w,3);
- }
-
- x8_get_ac_rlf(w,ac_mode,&run,&level,&final);
-
- pos+=run+1;
- if(pos>63){
- //this also handles vlc error in x8_get_ac_rlf
- return -1;
- }
- level= (level+1) * w->dquant;
- level+= w->qsum;
-
- sign = - get_bits1(&s->gb);
- level = (level ^ sign) - sign;
-
- if(use_quant_matrix){
- level = (level*quant_table[pos])>>8;
- }
- s->block[0][ scantable[pos] ]=level;
- }while(!final);
-
- s->block_last_index[0]=pos;
- }else{//DC only
- s->block_last_index[0]=0;
- if(w->flat_dc && ((unsigned)(dc_level+1)) < 3){//[-1;1]
- int32_t divide_quant= !chroma ? w->divide_quant_dc_luma:
- w->divide_quant_dc_chroma;
- int32_t dc_quant = !chroma ? w->quant:
- w->quant_dc_chroma;
-
- //original intent dc_level+=predicted_dc/quant; but it got lost somewhere in the rounding
- 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]);
-
- goto block_placed;
- }
- zeros_only = (dc_level == 0);
- }
- if(!chroma){
- s->block[0][0] = dc_level*w->quant;
- }else{
- s->block[0][0] = dc_level*w->quant_dc_chroma;
- }
-
- //there is !zero_only check in the original, but dc_level check is enough
- if( (unsigned int)(dc_level+1) >= 3 && (w->edges&3) != 3 ){
- int direction;
- /*ac_comp_direction[orient] = { 0, 3, 3, 1, 1, 0, 0, 0, 2, 2, 2, 1 };<-
- -> 01'10' 10'10' 00'00' 00'01' 01'11' 11'00 =>0x6A017C */
- direction= (0x6A017C>>(w->orient*2))&3;
- if (direction != 3){
- x8_ac_compensation(w, direction, s->block[0][0]);//modify block_last[]
- }
- }
-
- if(w->flat_dc){
- 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] );
- }
- if(!zeros_only)
- s->dsp.idct_add ( s->dest[chroma],
- s->current_picture.f.linesize[!!chroma],
- s->block[0] );
-
-block_placed:
-
- if(!chroma){
- x8_update_predictions(w,w->orient,n);
- }
-
- if(s->loop_filter){
- uint8_t* ptr = s->dest[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);
- }
- if(!( (w->edges&1) || ( zeros_only && (w->orient|8)==8 ) )){
- w->dsp.v_loop_filter(ptr, linesize, w->quant);
- }
- }
- return 0;
-}
-
-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];
-
- 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
- s->dest[2] += ( s->mb_y&(~1) ) * uvlinesize << 2;
-}
-
-/**
- * Initialize IntraX8 frame decoder.
- * Requires valid MpegEncContext with valid s->mb_width before calling.
- * @param w pointer to IntraX8Context
- * @param s pointer to MpegEncContext of the parent codec
- */
-av_cold void ff_intrax8_common_init(IntraX8Context * w, MpegEncContext * const s){
-
- w->s=s;
- x8_vlc_init();
- av_assert0(s->mb_width>0);
- w->prediction_table=av_mallocz(s->mb_width*2*2);//two rows, 2 blocks per cannon mb
-
- ff_init_scantable(s->dsp.idct_permutation, &w->scantable[0], ff_wmv1_scantable[0]);
- ff_init_scantable(s->dsp.idct_permutation, &w->scantable[1], ff_wmv1_scantable[2]);
- ff_init_scantable(s->dsp.idct_permutation, &w->scantable[2], ff_wmv1_scantable[3]);
-
- ff_intrax8dsp_init(&w->dsp);
-}
-
-/**
- * Destroy IntraX8 frame structure.
- * @param w pointer to IntraX8Context
- */
-av_cold void ff_intrax8_common_end(IntraX8Context * w)
-{
- av_freep(&w->prediction_table);
-}
-
-/**
- * Decode single IntraX8 frame.
- * The parent codec must fill s->loopfilter and s->gb (bitstream).
- * The parent codec must call MPV_frame_start(), ff_er_frame_start() before calling this function.
- * The parent codec must call ff_er_frame_end(), MPV_frame_end() after calling this function.
- * This function does not use MPV_decode_mb().
- * lowres decoding is theoretically impossible.
- * @param w pointer to IntraX8Context
- * @param dquant doubled quantizer, it would be odd in case of VC-1 halfpq==1.
- * @param quant_offset offset away from zero
- */
-//FIXME extern uint8_t ff_wmv3_dc_scale_table[32];
-int ff_intrax8_decode_picture(IntraX8Context * const w, int dquant, int quant_offset){
- MpegEncContext * const s= w->s;
- int mb_xy;
- w->use_quant_matrix = get_bits1(&s->gb);
-
- w->dquant = dquant;
- w->quant = dquant >> 1;
- w->qsum = quant_offset;
-
- w->divide_quant_dc_luma = ((1<<16) + (w->quant>>1)) / w->quant;
- if(w->quant < 5){
- w->quant_dc_chroma = w->quant;
- w->divide_quant_dc_chroma = w->divide_quant_dc_luma;
- }else{
- w->quant_dc_chroma = w->quant+((w->quant+3)>>3);
- w->divide_quant_dc_chroma = ((1<<16) + (w->quant_dc_chroma>>1)) / w->quant_dc_chroma;
- }
- x8_reset_vlc_tables(w);
-
- s->resync_mb_x=0;
- s->resync_mb_y=0;
-
- for(s->mb_y=0; s->mb_y < s->mb_height*2; s->mb_y++){
- x8_init_block_index(s);
- mb_xy=(s->mb_y>>1)*s->mb_stride;
-
- for(s->mb_x=0; s->mb_x < s->mb_width*2; s->mb_x++){
- x8_get_prediction(w);
- if(x8_setup_spatial_predictor(w,0)) goto error;
- if(x8_decode_intra_mb(w,0)) goto error;
-
- if( s->mb_x & s->mb_y & 1 ){
- x8_get_prediction_chroma(w);
-
- /*when setting up chroma, no vlc is read,
- so no error condition can be reached*/
- x8_setup_spatial_predictor(w,1);
- if(x8_decode_intra_mb(w,1)) goto error;
-
- x8_setup_spatial_predictor(w,2);
- if(x8_decode_intra_mb(w,2)) goto error;
-
- s->dest[1]+= 8;
- s->dest[2]+= 8;
-
- /*emulate MB info in the relevant tables*/
- s->mbskip_table [mb_xy]=0;
- s->mbintra_table[mb_xy]=1;
- s->current_picture.f.qscale_table[mb_xy] = w->quant;
- mb_xy++;
- }
- s->dest[0]+= 8;
- }
- if(s->mb_y&1){
- ff_draw_horiz_band(s, (s->mb_y-1)*8, 16);
- }
- }
-
-error:
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y,
- (s->mb_x>>1)-1, (s->mb_y>>1)-1,
- ER_MB_END );
- return 0;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/intrax8.h b/src/thirdparty/ffmpeg/libavcodec/intrax8.h
deleted file mode 100644
index 086bcd07a..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/intrax8.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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_INTRAX8_H
-#define AVCODEC_INTRAX8_H
-
-#include "get_bits.h"
-#include "mpegvideo.h"
-#include "intrax8dsp.h"
-
-typedef struct IntraX8Context {
- VLC * j_ac_vlc[4];//they point to the static j_mb_vlc
- VLC * j_orient_vlc;
- VLC * j_dc_vlc[3];
-
- int use_quant_matrix;
-//set by ff_intrax8_common_init
- uint8_t * prediction_table;//2*(mb_w*2)
- ScanTable scantable[3];
-//set by the caller codec
- MpegEncContext * s;
- IntraX8DSPContext dsp;
- int quant;
- int dquant;
- int qsum;
-//calculated per frame
- int quant_dc_chroma;
- int divide_quant_dc_luma;
- int divide_quant_dc_chroma;
-//changed per block
- int edges;
- int flat_dc;
- int predicted_dc;
- int raw_orient;
- int chroma_orient;
- int orient;
- int est_run;
-} IntraX8Context;
-
-void ff_intrax8_common_init(IntraX8Context * w, MpegEncContext * const s);
-void ff_intrax8_common_end(IntraX8Context * w);
-int ff_intrax8_decode_picture(IntraX8Context * w, int quant, int halfpq);
-
-#endif /* AVCODEC_INTRAX8_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/intrax8dsp.c b/src/thirdparty/ffmpeg/libavcodec/intrax8dsp.c
deleted file mode 100644
index 52a5a70fb..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/intrax8dsp.c
+++ /dev/null
@@ -1,433 +0,0 @@
-/*
- * 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
- *@brief IntraX8 frame subdecoder image manipulation routines
- */
-
-#include "dsputil.h"
-#include "intrax8dsp.h"
-#include "libavutil/common.h"
-
-/*
-area positions, #3 is 1 pixel only, other are 8 pixels
- |66666666|
- 3|44444444|55555555|
-- -+--------+--------+
-1 2|XXXXXXXX|
-1 2|XXXXXXXX|
-1 2|XXXXXXXX|
-1 2|XXXXXXXX|
-1 2|XXXXXXXX|
-1 2|XXXXXXXX|
-1 2|XXXXXXXX|
-1 2|XXXXXXXX|
-^-start
-*/
-
-#define area1 (0)
-#define area2 (8)
-#define area3 (8+8)
-#define area4 (8+8+1)
-#define area5 (8+8+1+8)
-#define area6 (8+8+1+16)
-
-/**
- Collect statistics and prepare the edge pixels required by the other spatial compensation functions.
-
- * @param src pointer to the beginning of the processed block
- * @param dst pointer to emu_edge, edge pixels are stored the way other compensation routines do.
- * @param linesize byte offset between 2 vertical pixels in the source image
- * @param range pointer to the variable where the edge pixel range is to be stored (max-min values)
- * @param psum pointer to the variable where the edge pixel sum is to be stored
- * @param edges Informs this routine that the block is on an image border, so it has to interpolate the missing edge pixels.
- and some of the edge pixels should be interpolated, the flag has the following meaning:
- 1 - mb_x==0 - first block in the row, interpolate area #1,#2,#3;
- 2 - mb_y==0 - first row, interpolate area #3,#4,#5,#6;
- note: 1|2 - mb_x==mb_y==0 - first block, use 0x80 value for all areas;
- 4 - mb_x>= (mb_width-1) last block in the row, interpolate area #5;
-*/
-static void x8_setup_spatial_compensation(uint8_t *src, uint8_t *dst, int linesize,
- int * range, int * psum, int edges){
- uint8_t * ptr;
- int sum;
- int i;
- int min_pix,max_pix;
- uint8_t c;
-
- if((edges&3)==3){
- *psum=0x80*(8+1+8+2);
- *range=0;
- memset(dst,0x80,16+1+16+8);
- //this triggers flat_dc for sure.
- //flat_dc avoids all (other) prediction modes, but requires dc_level decoding.
- return;
- }
-
- min_pix=256;
- max_pix=-1;
-
- sum=0;
-
- if(!(edges&1)){//(mb_x!=0)//there is previous block on this row
- ptr=src-1;//left column, area 2
- for(i=7;i>=0;i--){
- c=*(ptr-1);//area1, same mb as area2, no need to check
- dst[area1+i]=c;
- c=*(ptr);
-
- sum+=c;
- min_pix=FFMIN(min_pix,c);
- max_pix=FFMAX(max_pix,c);
- dst[area2+i]=c;
-
- ptr+=linesize;
- }
- }
-
- if(!(edges&2)){ //(mb_y!=0)//there is row above
- ptr=src-linesize;//top line
- for(i=0;i<8;i++){
- c=*(ptr+i);
- sum+=c;
- min_pix=FFMIN(min_pix, c);
- max_pix=FFMAX(max_pix, c);
- }
- if(edges&4){//last block on the row?
- memset(dst+area5,c,8);//set with last pixel fr
- memcpy(dst+area4, ptr, 8);
- }else{
- memcpy(dst+area4, ptr, 16);//both area4 and 5
- }
- memcpy(dst+area6, ptr-linesize, 8);//area6 always present in the above block
- }
- //now calculate the stuff we need
- if(edges&3){//mb_x==0 || mb_y==0){
- int avg=(sum+4)>>3;
- if(edges&1){ //(mb_x==0) {//implies mb_y!=0
- memset(dst+area1,avg,8+8+1);//areas 1,2 and 3 are averaged
- }else{//implies y==0 x!=0
- memset(dst+area3,avg, 1+16+8);//areas 3, 4,5,6
- }
- sum+=avg*9;
- }else{
- uint8_t c=*(src-1-linesize);//the edge pixel, in the top line and left column
- dst[area3]=c;
- sum+=c;
- //edge pixel is not part of min/max
- }
- (*range) = max_pix - min_pix;
- sum += *(dst+area5) + *(dst+area5+1);
- *psum = sum;
-}
-
-
-static const uint16_t zero_prediction_weights[64*2] = {
- 640, 640, 669, 480, 708, 354, 748, 257, 792, 198, 760, 143, 808, 101, 772, 72,
- 480, 669, 537, 537, 598, 416, 661, 316, 719, 250, 707, 185, 768, 134, 745, 97,
- 354, 708, 416, 598, 488, 488, 564, 388, 634, 317, 642, 241, 716, 179, 706, 132,
- 257, 748, 316, 661, 388, 564, 469, 469, 543, 395, 571, 311, 655, 238, 660, 180,
- 198, 792, 250, 719, 317, 634, 395, 543, 469, 469, 507, 380, 597, 299, 616, 231,
- 161, 855, 206, 788, 266, 710, 340, 623, 411, 548, 455, 455, 548, 366, 576, 288,
- 122, 972, 159, 914, 211, 842, 276, 758, 341, 682, 389, 584, 483, 483, 520, 390,
- 110, 1172, 144, 1107, 193, 1028, 254, 932, 317, 846, 366, 731, 458, 611, 499, 499
-};
-
-static void spatial_compensation_0(uint8_t *src , uint8_t *dst, int linesize){
- int i,j;
- int x,y;
- unsigned int p;//power divided by 2
- int a;
- uint16_t left_sum[2][8] = { { 0 } };
- uint16_t top_sum[2][8] = { { 0 } };
-
- for(i=0;i<8;i++){
- a=src[area2+7-i]<<4;
- for(j=0;j<8;j++){
- p=abs(i-j);
- left_sum[p&1][j]+= a>>(p>>1);
- }
- }
-
- for(i=0;i<8;i++){
- a=src[area4+i]<<4;
- for(j=0;j<8;j++){
- p=abs(i-j);
- top_sum[p&1][j]+= a>>(p>>1);
- }
- }
- for(;i<10;i++){
- a=src[area4+i]<<4;
- for(j=5;j<8;j++){
- p=abs(i-j);
- top_sum[p&1][j]+= a>>(p>>1);
- }
- }
- for(;i<12;i++){
- a=src[area4+i]<<4;
- for(j=7;j<8;j++){
- p=abs(i-j);
- top_sum[p&1][j]+= a>>(p>>1);
- }
- }
-
- for(i=0;i<8;i++){
- top_sum [0][i]+=(top_sum [1][i]*181 + 128 )>>8;//181 is sqrt(2)/2
- left_sum[0][i]+=(left_sum[1][i]*181 + 128 )>>8;
- }
- for(y=0;y<8;y++){
- for(x=0;x<8;x++){
- dst[x] = (
- (uint32_t)top_sum [0][x]*zero_prediction_weights[y*16+x*2+0] +
- (uint32_t)left_sum[0][y]*zero_prediction_weights[y*16+x*2+1] +
- 0x8000
- )>>16;
- }
- dst+=linesize;
- }
-}
-static void spatial_compensation_1(uint8_t *src , uint8_t *dst, int linesize){
- int x,y;
-
- for(y=0;y<8;y++){
- for(x=0;x<8;x++){
- dst[x]=src[area4 + FFMIN(2*y+x+2, 15) ];
- }
- dst+=linesize;
- }
-}
-static void spatial_compensation_2(uint8_t *src , uint8_t *dst, int linesize){
- int x,y;
-
- for(y=0;y<8;y++){
- for(x=0;x<8;x++){
- dst[x]=src[area4 +1+y+x];
- }
- dst+=linesize;
- }
-}
-static void spatial_compensation_3(uint8_t *src , uint8_t *dst, int linesize){
- int x,y;
-
- for(y=0;y<8;y++){
- for(x=0;x<8;x++){
- dst[x]=src[area4 +((y+1)>>1)+x];
- }
- dst+=linesize;
- }
-}
-static void spatial_compensation_4(uint8_t *src , uint8_t *dst, int linesize){
- int x,y;
-
- for(y=0;y<8;y++){
- for(x=0;x<8;x++){
- dst[x]=( src[area4+x] + src[area6+x] + 1 )>>1;
- }
- dst+=linesize;
- }
-}
-static void spatial_compensation_5(uint8_t *src , uint8_t *dst, int linesize){
- int x,y;
-
- for(y=0;y<8;y++){
- for(x=0;x<8;x++){
- if(2*x-y<0){
- dst[x]=src[area2+9+2*x-y];
- }else{
- dst[x]=src[area4 +x-((y+1)>>1)];
- }
- }
- dst+=linesize;
- }
-}
-static void spatial_compensation_6(uint8_t *src , uint8_t *dst, int linesize){
- int x,y;
-
- for(y=0;y<8;y++){
- for(x=0;x<8;x++){
- dst[x]=src[area3+x-y];
- }
- dst+=linesize;
- }
-}
-static void spatial_compensation_7(uint8_t *src , uint8_t *dst, int linesize){
- int x,y;
-
- for(y=0;y<8;y++){
- for(x=0;x<8;x++){
- if(x-2*y>0){
- dst[x]=( src[area3-1+x-2*y] + src[area3+x-2*y] + 1)>>1;
- }else{
- dst[x]=src[area2+8-y +(x>>1)];
- }
- }
- dst+=linesize;
- }
-}
-static void spatial_compensation_8(uint8_t *src , uint8_t *dst, int linesize){
- int x,y;
-
- for(y=0;y<8;y++){
- for(x=0;x<8;x++){
- dst[x]=( src[area1+7-y] + src[area2+7-y] + 1 )>>1;
- }
- dst+=linesize;
- }
-}
-static void spatial_compensation_9(uint8_t *src , uint8_t *dst, int linesize){
- int x,y;
-
- for(y=0;y<8;y++){
- for(x=0;x<8;x++){
- dst[x]=src[area2+6-FFMIN(x+y,6)];
- }
- dst+=linesize;
- }
-}
-static void spatial_compensation_10(uint8_t *src , uint8_t *dst, int linesize){
- int x,y;
-
- for(y=0;y<8;y++){
- for(x=0;x<8;x++){
- dst[x]=(src[area2+7-y]*(8-x)+src[area4+x]*x+4)>>3;
- }
- dst+=linesize;
- }
-}
-static void spatial_compensation_11(uint8_t *src , uint8_t *dst, int linesize){
- int x,y;
-
- for(y=0;y<8;y++){
- for(x=0;x<8;x++){
- dst[x]=(src[area2+7-y]*y+src[area4+x]*(8-y)+4)>>3;
- }
- dst+=linesize;
- }
-}
-
-static void x8_loop_filter(uint8_t * ptr, const int a_stride, const int b_stride, int quant){
- int i,t;
- int p0,p1,p2,p3,p4,p5,p6,p7,p8,p9;
- int ql=(quant+10)>>3;
-
- for(i=0; i<8; i++,ptr+=b_stride){
- p0=ptr[-5*a_stride];
- p1=ptr[-4*a_stride];
- p2=ptr[-3*a_stride];
- p3=ptr[-2*a_stride];
- p4=ptr[-1*a_stride];
- p5=ptr[ 0 ];
- p6=ptr[ 1*a_stride];
- p7=ptr[ 2*a_stride];
- p8=ptr[ 3*a_stride];
- p9=ptr[ 4*a_stride];
-
- t=
- (FFABS(p1-p2) <= ql) +
- (FFABS(p2-p3) <= ql) +
- (FFABS(p3-p4) <= ql) +
- (FFABS(p4-p5) <= ql);
- if(t>0){//You need at least 1 to be able to reach a total score of 6.
- t+=
- (FFABS(p5-p6) <= ql) +
- (FFABS(p6-p7) <= ql) +
- (FFABS(p7-p8) <= ql) +
- (FFABS(p8-p9) <= ql) +
- (FFABS(p0-p1) <= ql);
- if(t>=6){
- int min,max;
-
- min=max=p1;
- min=FFMIN(min,p3); max=FFMAX(max,p3);
- min=FFMIN(min,p5); max=FFMAX(max,p5);
- min=FFMIN(min,p8); max=FFMAX(max,p8);
- if(max-min<2*quant){//early stop
- min=FFMIN(min,p2); max=FFMAX(max,p2);
- min=FFMIN(min,p4); max=FFMAX(max,p4);
- min=FFMIN(min,p6); max=FFMAX(max,p6);
- min=FFMIN(min,p7); max=FFMAX(max,p7);
- if(max-min<2*quant){
- ptr[-2*a_stride]=(4*p2 + 3*p3 + 1*p7 + 4)>>3;
- ptr[-1*a_stride]=(3*p2 + 3*p4 + 2*p7 + 4)>>3;
- ptr[ 0 ]=(2*p2 + 3*p5 + 3*p7 + 4)>>3;
- ptr[ 1*a_stride]=(1*p2 + 3*p6 + 4*p7 + 4)>>3;
- continue;
- };
- }
- }
- }
- {
- int x,x0,x1,x2;
- int m;
-
- x0 = (2*p3 - 5*p4 + 5*p5 - 2*p6 + 4)>>3;
- if(FFABS(x0) < quant){
- x1=(2*p1 - 5*p2 + 5*p3 - 2*p4 + 4)>>3;
- x2=(2*p5 - 5*p6 + 5*p7 - 2*p8 + 4)>>3;
-
- x=FFABS(x0) - FFMIN( FFABS(x1), FFABS(x2) );
- m=p4-p5;
-
- if( x > 0 && (m^x0) <0){
- int32_t sign;
-
- sign=m>>31;
- m=(m^sign)-sign;//abs(m)
- m>>=1;
-
- x=(5*x)>>3;
-
- if(x>m) x=m;
-
- x=(x^sign)-sign;
-
- ptr[-1*a_stride] -= x;
- ptr[ 0] += x;
- }
- }
- }
- }
-}
-
-static void x8_h_loop_filter(uint8_t *src, int stride, int qscale){
- x8_loop_filter(src, stride, 1, qscale);
-}
-
-static void x8_v_loop_filter(uint8_t *src, int stride, int qscale){
- x8_loop_filter(src, 1, stride, qscale);
-}
-
-av_cold void ff_intrax8dsp_init(IntraX8DSPContext *dsp)
-{
- dsp->h_loop_filter=x8_h_loop_filter;
- dsp->v_loop_filter=x8_v_loop_filter;
- dsp->setup_spatial_compensation=x8_setup_spatial_compensation;
- dsp->spatial_compensation[0]=spatial_compensation_0;
- dsp->spatial_compensation[1]=spatial_compensation_1;
- dsp->spatial_compensation[2]=spatial_compensation_2;
- dsp->spatial_compensation[3]=spatial_compensation_3;
- dsp->spatial_compensation[4]=spatial_compensation_4;
- dsp->spatial_compensation[5]=spatial_compensation_5;
- dsp->spatial_compensation[6]=spatial_compensation_6;
- dsp->spatial_compensation[7]=spatial_compensation_7;
- dsp->spatial_compensation[8]=spatial_compensation_8;
- dsp->spatial_compensation[9]=spatial_compensation_9;
- dsp->spatial_compensation[10]=spatial_compensation_10;
- dsp->spatial_compensation[11]=spatial_compensation_11;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/intrax8dsp.h b/src/thirdparty/ffmpeg/libavcodec/intrax8dsp.h
deleted file mode 100644
index 1e4a3af88..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/intrax8dsp.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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_INTRAX8DSP_H
-#define AVCODEC_INTRAX8DSP_H
-
-#include <stdint.h>
-
-typedef struct IntraX8DSPContext {
- void (*v_loop_filter)(uint8_t *src, int stride, int qscale);
- void (*h_loop_filter)(uint8_t *src, int stride, int qscale);
-
- void (*spatial_compensation[12])(uint8_t *src , uint8_t *dst, int linesize);
- void (*setup_spatial_compensation)(uint8_t *src, uint8_t *dst, int linesize,
- int *range, int *sum, int edges);
-} IntraX8DSPContext;
-
-void ff_intrax8dsp_init(IntraX8DSPContext *dsp);
-
-#endif /* AVCODEC_INTRAX8DSP_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/intrax8huf.h b/src/thirdparty/ffmpeg/libavcodec/intrax8huf.h
deleted file mode 100644
index ffa2e1c58..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/intrax8huf.h
+++ /dev/null
@@ -1,918 +0,0 @@
-/*
- * 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_INTRAX8HUF_H
-#define AVCODEC_INTRAX8HUF_H
-
-#include <inttypes.h>
-
-
-static const uint16_t x8_orient_lowquant_table[4][12][2]={
- {//0
- {0x0000, 1}, {0x0004, 3}, {0x0005, 3}, {0x000C, 4},
- {0x000D, 4}, {0x0038, 6}, {0x001D, 5}, {0x0039, 6},
- {0x003C, 6}, {0x003D, 6}, {0x003E, 6}, {0x003F, 6},
- },{//1
- {0x0000, 5}, {0x0001, 5}, {0x0002, 5}, {0x0001, 2},
- {0x0002, 2}, {0x0002, 4}, {0x0003, 5}, {0x0006, 3},
- {0x0003, 4}, {0x000E, 4}, {0x001E, 5}, {0x001F, 5},
- },{//2
- {0x0000, 2}, {0x0001, 2}, {0x0004, 3}, {0x0005, 3},
- {0x0006, 3}, {0x0038, 6}, {0x0039, 6}, {0x001D, 5},
- {0x003C, 6}, {0x003D, 6}, {0x003E, 6}, {0x003F, 6},
- },{//3
- {0x0000, 3}, {0x0002, 4}, {0x0003, 4}, {0x0001, 2},
- {0x0002, 2}, {0x0018, 5}, {0x0019, 5}, {0x000D, 4},
- {0x001C, 5}, {0x001D, 5}, {0x001E, 5}, {0x001F, 5},
- }
-};
-
-static const uint16_t x8_orient_highquant_table[2][12][2]={
- {//0
- {0x0000, 2}, {0x0001, 2}, {0x0004, 3}, {0x0005, 3},
- {0x0006, 3}, {0x0038, 6}, {0x001D, 5}, {0x0039, 6},
- {0x003C, 6}, {0x003D, 6}, {0x003E, 6}, {0x003F, 6},
- },{//1
- {0x0000, 1}, {0x0002, 2}, {0x0006, 3}, {0x001C, 5},
- {0x001D, 5}, {0x0078, 7}, {0x003D, 6}, {0x0079, 7},
- {0x007C, 7}, {0x007D, 7}, {0x007E, 7}, {0x007F, 7},
- }
-};
-#define MAX_OR_VLC_BITS 7
-
-
-static const uint16_t x8_dc_lowquant_table[8][34][2]={
- {//0
- {0x0000, 5}, {0x0001, 4}, {0x0001, 5}, {0x0004, 5},
- {0x0005, 5}, {0x0006, 5}, {0x000E, 6}, {0x000F, 6},
- {0x0040, 8}, {0x0041, 8}, {0x0840, 13}, {0x0841, 13},
- {0x0842, 13}, {0x0843, 13}, {0x0844, 13}, {0x0845, 13},
- {0x0846, 13}, {0x0002, 2}, {0x0003, 2}, {0x0003, 3},
- {0x0005, 4}, {0x0009, 5}, {0x0011, 6}, {0x0043, 8},
- {0x0085, 9}, {0x0847, 13}, {0x0848, 13}, {0x0849, 13},
- {0x084A, 13}, {0x084B, 13}, {0x084C, 13}, {0x084D, 13},
- {0x084E, 13}, {0x084F, 13},
- },{//1
- {0x0000, 4}, {0x0001, 3}, {0x0002, 3}, {0x0001, 4},
- {0x0006, 4}, {0x0004, 3}, {0x0007, 4}, {0x0005, 3},
- {0x000C, 4}, {0x000D, 4}, {0x001C, 5}, {0x003A, 6},
- {0x01D8, 9}, {0x01D9, 9}, {0x1DA0, 13}, {0x1DA1, 13},
- {0x1DA2, 13}, {0x003C, 6}, {0x003D, 6}, {0x003E, 6},
- {0x0077, 7}, {0x01DB, 9}, {0x007E, 7}, {0x00FE, 8},
- {0x01FE, 9}, {0x1DA3, 13}, {0x1DA4, 13}, {0x1DA5, 13},
- {0x0ED3, 12}, {0x0ED4, 12}, {0x01FF, 9}, {0x0ED5, 12},
- {0x0ED6, 12}, {0x0ED7, 12},
- },{//2
- {0x0000, 4}, {0x0001, 3}, {0x0002, 3}, {0x0001, 4},
- {0x0006, 4}, {0x0007, 4}, {0x0008, 4}, {0x0009, 4},
- {0x0028, 6}, {0x0029, 6}, {0x0054, 7}, {0x0055, 7},
- {0x0AC0, 12}, {0x0AC1, 12}, {0x0AC2, 12}, {0x0AC3, 12},
- {0x0AC4, 12}, {0x000B, 4}, {0x0006, 3}, {0x000E, 4},
- {0x001E, 5}, {0x003E, 6}, {0x003F, 6}, {0x0057, 7},
- {0x00AD, 8}, {0x0AC5, 12}, {0x0AC6, 12}, {0x0AC7, 12},
- {0x0AC8, 12}, {0x0AC9, 12}, {0x0ACA, 12}, {0x0ACB, 12},
- {0x0566, 11}, {0x0567, 11},
- },{//3
- {0x0000, 4}, {0x0001, 2}, {0x0001, 3}, {0x0004, 3},
- {0x0005, 3}, {0x0006, 3}, {0x0001, 4}, {0x000E, 4},
- {0x003C, 6}, {0x003D, 6}, {0x007C, 7}, {0x00FA, 8},
- {0x3EC0, 14}, {0x3EC1, 14}, {0x3EC2, 14}, {0x3EC3, 14},
- {0x1F62, 13}, {0x01F7, 9}, {0x007E, 7}, {0x00FE, 8},
- {0x00FF, 8}, {0x1F63, 13}, {0x1F64, 13}, {0x1F65, 13},
- {0x1F66, 13}, {0x1F67, 13}, {0x1F68, 13}, {0x1F69, 13},
- {0x1F6A, 13}, {0x1F6B, 13}, {0x1F6C, 13}, {0x1F6D, 13},
- {0x1F6E, 13}, {0x1F6F, 13},
- },{//4
- {0x0000, 7}, {0x0001, 7}, {0x0002, 7}, {0x0003, 7},
- {0x0004, 7}, {0x0005, 7}, {0x0006, 7}, {0x0007, 7},
- {0x0008, 7}, {0x0009, 7}, {0x000A, 7}, {0x000B, 7},
- {0x000C, 7}, {0x000D, 7}, {0x000E, 7}, {0x000F, 7},
- {0x0010, 7}, {0x0001, 1}, {0x0001, 2}, {0x0011, 7},
- {0x0012, 7}, {0x0013, 7}, {0x0014, 7}, {0x0015, 7},
- {0x0016, 7}, {0x0017, 7}, {0x0018, 7}, {0x0019, 7},
- {0x001A, 7}, {0x001B, 7}, {0x001C, 7}, {0x001D, 7},
- {0x001E, 7}, {0x001F, 7},
- },{//5
- {0x0000, 5}, {0x0001, 4}, {0x0001, 5}, {0x0008, 6},
- {0x0009, 6}, {0x000A, 6}, {0x0016, 7}, {0x000C, 6},
- {0x0017, 7}, {0x000D, 6}, {0x0038, 8}, {0x001D, 7},
- {0x0039, 8}, {0x0780, 13}, {0x0781, 13}, {0x0782, 13},
- {0x0783, 13}, {0x0002, 3}, {0x0001, 1}, {0x0003, 3},
- {0x001F, 7}, {0x003D, 8}, {0x0079, 9}, {0x0784, 13},
- {0x0785, 13}, {0x0786, 13}, {0x0787, 13}, {0x0788, 13},
- {0x0789, 13}, {0x078A, 13}, {0x078B, 13}, {0x078C, 13},
- {0x078D, 13}, {0x03C7, 12},
- },{//6
- {0x0000, 4}, {0x0001, 2}, {0x0001, 3}, {0x0004, 3},
- {0x0001, 4}, {0x000A, 4}, {0x0016, 5}, {0x002E, 6},
- {0x005E, 7}, {0x005F, 7}, {0x00C0, 8}, {0x3040, 14},
- {0x3041, 14}, {0x0305, 10}, {0x0183, 9}, {0x3042, 14},
- {0x3043, 14}, {0x000D, 4}, {0x0007, 3}, {0x0019, 5},
- {0x0031, 6}, {0x00C2, 8}, {0x00C3, 8}, {0x3044, 14},
- {0x3045, 14}, {0x3046, 14}, {0x3047, 14}, {0x3048, 14},
- {0x3049, 14}, {0x304A, 14}, {0x304B, 14}, {0x304C, 14},
- {0x304D, 14}, {0x1827, 13},
- },{//7
- {0x0000, 6}, {0x0001, 6}, {0x0002, 6}, {0x0006, 7},
- {0x0007, 7}, {0x0004, 6}, {0x0005, 6}, {0x0006, 6},
- {0x000E, 7}, {0x001E, 8}, {0x001F, 8}, {0x0040, 9},
- {0x0082, 10}, {0x0830, 14}, {0x0831, 14}, {0x0832, 14},
- {0x0833, 14}, {0x0001, 1}, {0x0001, 2}, {0x0003, 4},
- {0x0005, 5}, {0x0009, 6}, {0x0011, 7}, {0x0021, 8},
- {0x0834, 14}, {0x0835, 14}, {0x0836, 14}, {0x0837, 14},
- {0x0838, 14}, {0x0839, 14}, {0x083A, 14}, {0x083B, 14},
- {0x041E, 13}, {0x041F, 13},
- }
-};
-
-static const uint16_t x8_dc_highquant_table[8][34][2]={
- {//0
- {0x0000, 5}, {0x0001, 4}, {0x0002, 4}, {0x0001, 5},
- {0x0006, 5}, {0x0004, 4}, {0x0007, 5}, {0x000A, 5},
- {0x002C, 7}, {0x002D, 7}, {0x05C0, 12}, {0x05C1, 12},
- {0x05C2, 12}, {0x05C3, 12}, {0x05C4, 12}, {0x05C5, 12},
- {0x05C6, 12}, {0x0003, 3}, {0x0002, 2}, {0x0006, 3},
- {0x000E, 4}, {0x001E, 5}, {0x001F, 5}, {0x002F, 7},
- {0x005D, 8}, {0x05C7, 12}, {0x05C8, 12}, {0x05C9, 12},
- {0x05CA, 12}, {0x05CB, 12}, {0x05CC, 12}, {0x05CD, 12},
- {0x05CE, 12}, {0x05CF, 12},
- },{//1
- {0x0000, 3}, {0x0001, 3}, {0x0002, 3}, {0x0006, 4},
- {0x0007, 4}, {0x0004, 3}, {0x000A, 4}, {0x000B, 4},
- {0x0030, 6}, {0x0062, 7}, {0x0063, 7}, {0x0640, 11},
- {0x0641, 11}, {0x0642, 11}, {0x0643, 11}, {0x0644, 11},
- {0x0645, 11}, {0x0033, 6}, {0x000D, 4}, {0x001C, 5},
- {0x001D, 5}, {0x003C, 6}, {0x001F, 5}, {0x0065, 7},
- {0x007A, 7}, {0x0646, 11}, {0x007B, 7}, {0x0647, 11},
- {0x0648, 11}, {0x0649, 11}, {0x064A, 11}, {0x064B, 11},
- {0x0326, 10}, {0x0327, 10},
- },{//2
- {0x0000, 7}, {0x0001, 7}, {0x0001, 6}, {0x0004, 7},
- {0x0003, 6}, {0x0005, 7}, {0x0010, 8}, {0x0011, 8},
- {0x0240, 13}, {0x0241, 13}, {0x0242, 13}, {0x0243, 13},
- {0x0244, 13}, {0x0245, 13}, {0x0246, 13}, {0x0247, 13},
- {0x0124, 12}, {0x0001, 1}, {0x0001, 2}, {0x0001, 3},
- {0x0003, 5}, {0x0005, 6}, {0x0013, 8}, {0x0125, 12},
- {0x0126, 12}, {0x0127, 12}, {0x0128, 12}, {0x0129, 12},
- {0x012A, 12}, {0x012B, 12}, {0x012C, 12}, {0x012D, 12},
- {0x012E, 12}, {0x012F, 12},
- },{//3
- {0x0000, 4}, {0x0001, 3}, {0x0002, 3}, {0x0001, 4},
- {0x0006, 4}, {0x0004, 3}, {0x0005, 3}, {0x0006, 3},
- {0x000E, 5}, {0x000F, 5}, {0x0070, 7}, {0x0710, 11},
- {0x0711, 11}, {0x0712, 11}, {0x0713, 11}, {0x0714, 11},
- {0x0715, 11}, {0x001D, 5}, {0x0072, 7}, {0x003C, 6},
- {0x003D, 6}, {0x0073, 7}, {0x007C, 7}, {0x007D, 7},
- {0x007E, 7}, {0x0716, 11}, {0x0717, 11}, {0x0718, 11},
- {0x007F, 7}, {0x0719, 11}, {0x071A, 11}, {0x071B, 11},
- {0x038E, 10}, {0x038F, 10},
- },{//4
- {0x0000, 8}, {0x0001, 7}, {0x0002, 7}, {0x0003, 7},
- {0x0002, 9}, {0x0008, 8}, {0x0003, 9}, {0x0240, 14},
- {0x0241, 14}, {0x0242, 14}, {0x0243, 14}, {0x0244, 14},
- {0x0245, 14}, {0x0246, 14}, {0x0247, 14}, {0x0124, 13},
- {0x0125, 13}, {0x0001, 2}, {0x0001, 1}, {0x0001, 3},
- {0x0001, 4}, {0x0003, 6}, {0x0005, 7}, {0x0013, 9},
- {0x0126, 13}, {0x0127, 13}, {0x0128, 13}, {0x0129, 13},
- {0x012A, 13}, {0x012B, 13}, {0x012C, 13}, {0x012D, 13},
- {0x012E, 13}, {0x012F, 13},
- },{//5
- {0x0000, 7}, {0x0001, 7}, {0x0001, 6}, {0x0002, 6},
- {0x0003, 6}, {0x0004, 6}, {0x0005, 6}, {0x0006, 6},
- {0x0007, 6}, {0x0008, 6}, {0x0009, 6}, {0x000A, 6},
- {0x000B, 6}, {0x000C, 6}, {0x000D, 6}, {0x000E, 6},
- {0x000F, 6}, {0x0010, 6}, {0x0011, 6}, {0x0012, 6},
- {0x0013, 6}, {0x0014, 6}, {0x0015, 6}, {0x0016, 6},
- {0x0017, 6}, {0x0018, 6}, {0x0019, 6}, {0x0001, 1},
- {0x001A, 6}, {0x001B, 6}, {0x001C, 6}, {0x001D, 6},
- {0x001E, 6}, {0x001F, 6},
- },{//6
- {0x0000, 5}, {0x0001, 4}, {0x0001, 5}, {0x0004, 5},
- {0x000A, 6}, {0x0006, 5}, {0x000B, 6}, {0x000E, 6},
- {0x003C, 8}, {0x003D, 8}, {0x07C0, 13}, {0x07C1, 13},
- {0x07C2, 13}, {0x07C3, 13}, {0x07C4, 13}, {0x07C5, 13},
- {0x07C6, 13}, {0x0001, 2}, {0x0002, 2}, {0x0006, 3},
- {0x000E, 4}, {0x001E, 5}, {0x001F, 5}, {0x003F, 8},
- {0x007D, 9}, {0x07C7, 13}, {0x07C8, 13}, {0x07C9, 13},
- {0x07CA, 13}, {0x07CB, 13}, {0x07CC, 13}, {0x07CD, 13},
- {0x07CE, 13}, {0x07CF, 13},
- },{//7
- {0x0000, 7}, {0x0001, 7}, {0x0002, 7}, {0x0003, 7},
- {0x0004, 7}, {0x0005, 7}, {0x0006, 7}, {0x0007, 7},
- {0x0008, 7}, {0x0009, 7}, {0x000A, 7}, {0x000B, 7},
- {0x000C, 7}, {0x000D, 7}, {0x000E, 7}, {0x000F, 7},
- {0x0010, 7}, {0x0001, 1}, {0x0001, 2}, {0x0011, 7},
- {0x0012, 7}, {0x0013, 7}, {0x0014, 7}, {0x0015, 7},
- {0x0016, 7}, {0x0017, 7}, {0x0018, 7}, {0x0019, 7},
- {0x001A, 7}, {0x001B, 7}, {0x001C, 7}, {0x001D, 7},
- {0x001E, 7}, {0x001F, 7},
- }
-};
-#define MAX_DC_VLC_BITS 14
-
-
-static const uint16_t x8_ac0_lowquant_table[8][77][2]={
- {//0
- {0x0000, 2}, {0x0002, 3}, {0x0006, 4}, {0x000E, 5},
- {0x001E, 6}, {0x003E, 7}, {0x003F, 7}, {0x0040, 7},
- {0x0104, 9}, {0x0083, 8}, {0x0084, 8}, {0x0085, 8},
- {0x020A, 10}, {0x020B, 10}, {0x0218, 10}, {0x0219, 10},
- {0x0009, 4}, {0x0044, 7}, {0x010D, 9}, {0x021C, 10},
- {0x0023, 6}, {0x0045, 7}, {0x0050, 7}, {0x000B, 4},
- {0x000C, 4}, {0x0015, 5}, {0x001A, 5}, {0x001B, 5},
- {0x0029, 6}, {0x0038, 6}, {0x0039, 6}, {0x003A, 6},
- {0x0051, 7}, {0x0076, 7}, {0x0077, 7}, {0x0078, 7},
- {0x0079, 7}, {0x007A, 7}, {0x007B, 7}, {0x00F8, 8},
- {0x010F, 9}, {0x021D, 10}, {0x3E40, 14}, {0x3E41, 14},
- {0x3E42, 14}, {0x3E43, 14}, {0x03E5, 10}, {0x3E44, 14},
- {0x01F3, 9}, {0x3E45, 14}, {0x3E46, 14}, {0x3E47, 14},
- {0x00FA, 8}, {0x3E48, 14}, {0x3E49, 14}, {0x3E4A, 14},
- {0x3E4B, 14}, {0x03EC, 10}, {0x3E4C, 14}, {0x007E, 7},
- {0x00FE, 8}, {0x00FF, 8}, {0x01F7, 9}, {0x3E4D, 14},
- {0x3E4E, 14}, {0x3E4F, 14}, {0x3ED0, 14}, {0x3ED1, 14},
- {0x3ED2, 14}, {0x3ED3, 14}, {0x3ED4, 14}, {0x3ED5, 14},
- {0x1F6B, 13}, {0x1F6C, 13}, {0x1F6D, 13}, {0x1F6E, 13},
- {0x1F6F, 13},
- },{//1
- {0x0000, 3}, {0x0004, 5}, {0x0014, 7}, {0x000B, 6},
- {0x000C, 6}, {0x002A, 8}, {0x002B, 8}, {0x0034, 8},
- {0x0D40, 14}, {0x0D41, 14}, {0x001B, 7}, {0x0D42, 14},
- {0x0D43, 14}, {0x0D44, 14}, {0x0D45, 14}, {0x0D46, 14},
- {0x000E, 6}, {0x003C, 8}, {0x0D47, 14}, {0x003D, 8},
- {0x0D48, 14}, {0x0D49, 14}, {0x0D4A, 14}, {0x0001, 2},
- {0x0004, 3}, {0x0014, 5}, {0x000B, 4}, {0x000C, 4},
- {0x000D, 4}, {0x002A, 6}, {0x001F, 7}, {0x0056, 7},
- {0x0057, 7}, {0x0070, 7}, {0x00E2, 8}, {0x0072, 7},
- {0x003A, 6}, {0x003B, 6}, {0x003C, 6}, {0x003D, 6},
- {0x00E3, 8}, {0x0D4B, 14}, {0x00E6, 8}, {0x00E7, 8},
- {0x00F8, 8}, {0x0D4C, 14}, {0x0D4D, 14}, {0x0D4E, 14},
- {0x00F9, 8}, {0x0D4F, 14}, {0x0D50, 14}, {0x0D51, 14},
- {0x06A9, 13}, {0x06AA, 13}, {0x06AB, 13}, {0x06AC, 13},
- {0x06AD, 13}, {0x06AE, 13}, {0x06AF, 13}, {0x003F, 6},
- {0x06B0, 13}, {0x06B1, 13}, {0x06B2, 13}, {0x06B3, 13},
- {0x06B4, 13}, {0x007D, 7}, {0x06B5, 13}, {0x06B6, 13},
- {0x06B7, 13}, {0x06B8, 13}, {0x06B9, 13}, {0x06BA, 13},
- {0x06BB, 13}, {0x06BC, 13}, {0x06BD, 13}, {0x06BE, 13},
- {0x06BF, 13},
- },{//2
- {0x0000, 2}, {0x0002, 3}, {0x0003, 3}, {0x0008, 4},
- {0x0012, 5}, {0x0013, 5}, {0x0028, 6}, {0x0029, 6},
- {0x0054, 7}, {0x0055, 7}, {0x0056, 7}, {0x00AE, 8},
- {0x00AF, 8}, {0x00B0, 8}, {0x0162, 9}, {0x02C6, 10},
- {0x000C, 4}, {0x002D, 6}, {0x00B2, 8}, {0x0166, 9},
- {0x002E, 6}, {0x0167, 9}, {0x00BC, 8}, {0x001A, 5},
- {0x0036, 6}, {0x0037, 6}, {0x0038, 6}, {0x005F, 7},
- {0x0072, 7}, {0x0073, 7}, {0x0074, 7}, {0x0075, 7},
- {0x0076, 7}, {0x0077, 7}, {0x0078, 7}, {0x0079, 7},
- {0x007A, 7}, {0x007B, 7}, {0x00BD, 8}, {0xB1C0, 16},
- {0xB1C1, 16}, {0x58E1, 15}, {0x0B1D, 12}, {0x58E2, 15},
- {0x58E3, 15}, {0x58E4, 15}, {0x00F8, 8}, {0x03E4, 10},
- {0x01F3, 9}, {0x0B1E, 12}, {0x58E5, 15}, {0x58E6, 15},
- {0x00FA, 8}, {0x58E7, 15}, {0x58F8, 15}, {0x58F9, 15},
- {0x58FA, 15}, {0x01F6, 9}, {0x58FB, 15}, {0x007E, 7},
- {0x00FE, 8}, {0x00FF, 8}, {0x07CA, 11}, {0x0F96, 12},
- {0x58FC, 15}, {0x58FD, 15}, {0x58FE, 15}, {0x58FF, 15},
- {0x7CB8, 15}, {0x7CB9, 15}, {0x7CBA, 15}, {0x7CBB, 15},
- {0x7CBC, 15}, {0x01F7, 9}, {0x7CBD, 15}, {0x7CBE, 15},
- {0x7CBF, 15},
- },{//3
- {0x0000, 2}, {0x0002, 3}, {0x0006, 4}, {0x000E, 5},
- {0x000F, 5}, {0x0020, 6}, {0x0021, 6}, {0x0044, 7},
- {0x0045, 7}, {0x008C, 8}, {0x008D, 8}, {0x011C, 9},
- {0x011D, 9}, {0x011E, 9}, {0x023E, 10}, {0x023F, 10},
- {0x0005, 3}, {0x0012, 5}, {0x004C, 7}, {0x004D, 7},
- {0x000C, 4}, {0x004E, 7}, {0x001A, 5}, {0x0036, 6},
- {0x004F, 7}, {0x006E, 7}, {0x006F, 7}, {0x00E0, 8},
- {0x00E1, 8}, {0x00E2, 8}, {0x00E3, 8}, {0x00E4, 8},
- {0x00E5, 8}, {0x01CC, 9}, {0x00E7, 8}, {0x00E8, 8},
- {0x00E9, 8}, {0x01CD, 9}, {0x0750, 11}, {0x03A9, 10},
- {0x0751, 11}, {0x7540, 15}, {0x03AB, 10}, {0x7541, 15},
- {0x7542, 15}, {0x7543, 15}, {0x01D6, 9}, {0x0755, 11},
- {0x0076, 7}, {0x0EA9, 12}, {0x7544, 15}, {0x7545, 15},
- {0x001E, 5}, {0x0077, 7}, {0x00F8, 8}, {0x03AE, 10},
- {0x075E, 11}, {0x007D, 7}, {0x03E4, 10}, {0x00FC, 8},
- {0x00FD, 8}, {0x03E5, 10}, {0x03E6, 10}, {0x0EBE, 12},
- {0x7546, 15}, {0x07CE, 11}, {0x7547, 15}, {0x75F8, 15},
- {0x75F9, 15}, {0x75FA, 15}, {0x75FB, 15}, {0x75FC, 15},
- {0x75FD, 15}, {0x007F, 7}, {0x3AFF, 14}, {0x0F9E, 12},
- {0x0F9F, 12},
- },{//4
- {0x0000, 3}, {0x0002, 4}, {0x0003, 4}, {0x0008, 5},
- {0x0012, 6}, {0x0013, 6}, {0x0014, 6}, {0x002A, 7},
- {0x0016, 6}, {0x002B, 7}, {0x005C, 8}, {0x005D, 8},
- {0x005E, 8}, {0x00BE, 9}, {0x00BF, 9}, {0x0060, 8},
- {0x0007, 4}, {0x000D, 5}, {0x0019, 6}, {0x0020, 6},
- {0x0009, 4}, {0x0021, 6}, {0x0011, 5}, {0x0014, 5},
- {0x002A, 6}, {0x002B, 6}, {0x002C, 6}, {0x002D, 6},
- {0x002E, 6}, {0x002F, 6}, {0x0030, 6}, {0x0031, 7},
- {0x0062, 7}, {0x0063, 7}, {0x0064, 7}, {0x0065, 7},
- {0x0066, 7}, {0x0061, 8}, {0x0670, 11}, {0x0068, 7},
- {0x0069, 7}, {0x00CF, 8}, {0x019D, 9}, {0x01A8, 9},
- {0x01A9, 9}, {0x0339, 10}, {0x01AA, 9}, {0x0356, 10},
- {0x0036, 6}, {0x00D6, 8}, {0x6710, 15}, {0x6711, 15},
- {0x000E, 4}, {0x006E, 7}, {0x01AE, 9}, {0x6712, 15},
- {0x6713, 15}, {0x003C, 6}, {0x0357, 10}, {0x006F, 7},
- {0x00F4, 8}, {0x00F5, 8}, {0x035E, 10}, {0x01EC, 9},
- {0x6714, 15}, {0x01ED, 9}, {0x035F, 10}, {0x03DC, 10},
- {0x03DD, 10}, {0x6715, 15}, {0x338B, 14}, {0x338C, 14},
- {0x338D, 14}, {0x001F, 5}, {0x01EF, 9}, {0x338E, 14},
- {0x338F, 14},
- },{//5
- {0x0000, 2}, {0x0004, 4}, {0x000A, 5}, {0x000B, 5},
- {0x0018, 6}, {0x0019, 6}, {0x0034, 7}, {0x006A, 8},
- {0x006B, 8}, {0x006C, 8}, {0x00DA, 9}, {0x036C, 11},
- {0x006E, 8}, {0x01B7, 10}, {0x036D, 11}, {0x3780, 15},
- {0x0004, 3}, {0x000E, 5}, {0x001E, 6}, {0x003E, 7},
- {0x000A, 4}, {0x002C, 6}, {0x0017, 5}, {0x002D, 6},
- {0x003F, 7}, {0x00C0, 8}, {0x0061, 7}, {0x00C1, 8},
- {0x0062, 7}, {0x00C6, 8}, {0x0064, 7}, {0x00C7, 8},
- {0x00CA, 8}, {0x00DF, 9}, {0x0196, 9}, {0x0197, 9},
- {0x0198, 9}, {0x0199, 9}, {0x0379, 11}, {0x019A, 9},
- {0x01BD, 10}, {0x066C, 11}, {0x3781, 15}, {0x0337, 10},
- {0x066D, 11}, {0x0670, 11}, {0x0339, 10}, {0x0671, 11},
- {0x0034, 6}, {0x00CF, 8}, {0x3782, 15}, {0x3783, 15},
- {0x000E, 4}, {0x001B, 5}, {0x006A, 7}, {0x006B, 7},
- {0x019D, 9}, {0x003C, 6}, {0x00F4, 8}, {0x00F5, 8},
- {0x03D8, 10}, {0x07B2, 11}, {0x3784, 15}, {0x03DA, 10},
- {0x3785, 15}, {0x03DB, 10}, {0x03DC, 10}, {0x3786, 15},
- {0x3787, 15}, {0x1BC4, 14}, {0x1BC5, 14}, {0x1BC6, 14},
- {0x1BC7, 14}, {0x001F, 5}, {0x03DD, 10}, {0x07B3, 11},
- {0x01EF, 9},
- },{//6
- {0x0000, 2}, {0x0004, 4}, {0x000A, 5}, {0x0016, 6},
- {0x0017, 6}, {0x0060, 8}, {0x00C2, 9}, {0x0186, 10},
- {0x0187, 10}, {0x00C4, 9}, {0x3140, 15}, {0x3141, 15},
- {0x018B, 10}, {0x3142, 15}, {0x018C, 10}, {0x3143, 15},
- {0x0007, 4}, {0x000D, 5}, {0x0064, 8}, {0x0065, 8},
- {0x0010, 5}, {0x00C7, 9}, {0x0066, 8}, {0x0005, 3},
- {0x0006, 3}, {0x0009, 4}, {0x0011, 5}, {0x0038, 6},
- {0x0039, 6}, {0x0074, 7}, {0x0075, 7}, {0x0076, 7},
- {0x0067, 8}, {0x00EE, 8}, {0x01DE, 9}, {0x00F0, 8},
- {0x018D, 10}, {0x3144, 15}, {0x01DF, 9}, {0x003D, 6},
- {0x003E, 6}, {0x01E2, 9}, {0x03C6, 10}, {0x00F2, 8},
- {0x00F3, 8}, {0x03C7, 10}, {0x3145, 15}, {0x3146, 15},
- {0x01F8, 9}, {0x3147, 15}, {0x3148, 15}, {0x3149, 15},
- {0x00FD, 8}, {0x314A, 15}, {0x314B, 15}, {0x314C, 15},
- {0x314D, 15}, {0x01F9, 9}, {0x314E, 15}, {0x01FC, 9},
- {0x314F, 15}, {0x3150, 15}, {0x3151, 15}, {0x3152, 15},
- {0x3153, 15}, {0x03FA, 10}, {0x03FB, 10}, {0x3154, 15},
- {0x3155, 15}, {0x3156, 15}, {0x3157, 15}, {0x3158, 15},
- {0x3159, 15}, {0x00FF, 8}, {0x18AD, 14}, {0x18AE, 14},
- {0x18AF, 14},
- },{//7
- {0x0000, 4}, {0x0080, 11}, {0x0081, 11}, {0x0082, 11},
- {0x0083, 11}, {0x0084, 11}, {0x0085, 11}, {0x0086, 11},
- {0x0087, 11}, {0x0088, 11}, {0x0089, 11}, {0x008A, 11},
- {0x008B, 11}, {0x008C, 11}, {0x008D, 11}, {0x008E, 11},
- {0x008F, 11}, {0x0048, 10}, {0x0049, 10}, {0x004A, 10},
- {0x004B, 10}, {0x004C, 10}, {0x004D, 10}, {0x0001, 1},
- {0x0001, 2}, {0x004E, 10}, {0x0002, 4}, {0x0003, 4},
- {0x004F, 10}, {0x0050, 10}, {0x0051, 10}, {0x0052, 10},
- {0x0053, 10}, {0x0054, 10}, {0x0055, 10}, {0x0056, 10},
- {0x0057, 10}, {0x0058, 10}, {0x0059, 10}, {0x005A, 10},
- {0x005B, 10}, {0x005C, 10}, {0x005D, 10}, {0x005E, 10},
- {0x005F, 10}, {0x0060, 10}, {0x0061, 10}, {0x0062, 10},
- {0x0063, 10}, {0x0064, 10}, {0x0065, 10}, {0x0066, 10},
- {0x0067, 10}, {0x0068, 10}, {0x0069, 10}, {0x006A, 10},
- {0x006B, 10}, {0x006C, 10}, {0x006D, 10}, {0x006E, 10},
- {0x006F, 10}, {0x0070, 10}, {0x0071, 10}, {0x0072, 10},
- {0x0073, 10}, {0x0074, 10}, {0x0075, 10}, {0x0076, 10},
- {0x0077, 10}, {0x0078, 10}, {0x0079, 10}, {0x007A, 10},
- {0x007B, 10}, {0x007C, 10}, {0x007D, 10}, {0x007E, 10},
- {0x007F, 10},
- }
-};
-
-static const uint16_t x8_ac0_highquant_table[8][77][2]={
- {//0
- {0x0000, 3}, {0x0002, 4}, {0x000C, 6}, {0x000D, 6},
- {0x001C, 7}, {0x000F, 6}, {0x1D00, 15}, {0x003B, 8},
- {0x1D01, 15}, {0x0075, 9}, {0x1D02, 15}, {0x0080, 9},
- {0x1D03, 15}, {0x1D04, 15}, {0x1D05, 15}, {0x0E83, 14},
- {0x0009, 5}, {0x0011, 6}, {0x0081, 9}, {0x0082, 9},
- {0x0021, 7}, {0x0028, 7}, {0x0083, 9}, {0x0002, 2},
- {0x0003, 3}, {0x000C, 4}, {0x000D, 4}, {0x000B, 5},
- {0x0015, 6}, {0x0052, 8}, {0x0070, 7}, {0x0039, 6},
- {0x0071, 7}, {0x0053, 8}, {0x0E84, 14}, {0x0074, 7},
- {0x0075, 7}, {0x0076, 7}, {0x01DC, 9}, {0x001E, 5},
- {0x003E, 6}, {0x01DD, 9}, {0x00EF, 8}, {0x01F8, 9},
- {0x01F9, 9}, {0x0E85, 14}, {0x0E86, 14}, {0x0E87, 14},
- {0x00FD, 8}, {0x0E88, 14}, {0x0E89, 14}, {0x0E8A, 14},
- {0x0E8B, 14}, {0x0E8C, 14}, {0x0E8D, 14}, {0x0E8E, 14},
- {0x0E8F, 14}, {0x0E90, 14}, {0x0E91, 14}, {0x01FC, 9},
- {0x0E92, 14}, {0x0E93, 14}, {0x0E94, 14}, {0x0E95, 14},
- {0x0E96, 14}, {0x0E97, 14}, {0x01FD, 9}, {0x0E98, 14},
- {0x01FE, 9}, {0x0E99, 14}, {0x0E9A, 14}, {0x0E9B, 14},
- {0x0E9C, 14}, {0x01FF, 9}, {0x0E9D, 14}, {0x0E9E, 14},
- {0x0E9F, 14},
- },{//1
- {0x0000, 3}, {0x0002, 4}, {0x0003, 4}, {0x0008, 5},
- {0x0012, 6}, {0x0013, 6}, {0x0014, 6}, {0x0015, 6},
- {0x002C, 7}, {0x005A, 8}, {0x005B, 8}, {0x005C, 8},
- {0x005D, 8}, {0x1780, 14}, {0x0179, 10}, {0x017A, 10},
- {0x0006, 4}, {0x000E, 5}, {0x001E, 6}, {0x003E, 7},
- {0x0010, 5}, {0x0022, 6}, {0x0012, 5}, {0x000A, 4},
- {0x0013, 5}, {0x0016, 5}, {0x0023, 6}, {0x002E, 6},
- {0x002F, 6}, {0x0030, 6}, {0x0031, 6}, {0x003F, 7},
- {0x005F, 8}, {0x00C8, 8}, {0x0065, 7}, {0x0066, 7},
- {0x0067, 7}, {0x0068, 7}, {0x00C9, 8}, {0x0069, 7},
- {0x006A, 7}, {0x00D6, 8}, {0x00D7, 8}, {0x00D8, 8},
- {0x1781, 14}, {0x017B, 10}, {0x01B2, 9}, {0x1782, 14},
- {0x001C, 5}, {0x01B3, 9}, {0x1783, 14}, {0x1784, 14},
- {0x001D, 5}, {0x00DA, 8}, {0x1785, 14}, {0x1786, 14},
- {0x1787, 14}, {0x0037, 6}, {0x00DB, 8}, {0x0078, 7},
- {0x00F2, 8}, {0x01E6, 9}, {0x00F4, 8}, {0x1788, 14},
- {0x1789, 14}, {0x00F5, 8}, {0x01E7, 9}, {0x178A, 14},
- {0x178B, 14}, {0x178C, 14}, {0x178D, 14}, {0x01EC, 9},
- {0x178E, 14}, {0x001F, 5}, {0x00F7, 8}, {0x01ED, 9},
- {0x178F, 14},
- },{//2
- {0x0000, 4}, {0x0002, 5}, {0x0180, 12}, {0x0181, 12},
- {0x0182, 12}, {0x0183, 12}, {0x0184, 12}, {0x0185, 12},
- {0x0186, 12}, {0x0187, 12}, {0x0188, 12}, {0x0189, 12},
- {0x00C5, 11}, {0x00C6, 11}, {0x00C7, 11}, {0x00C8, 11},
- {0x00C9, 11}, {0x00CA, 11}, {0x00CB, 11}, {0x00CC, 11},
- {0x00CD, 11}, {0x00CE, 11}, {0x00CF, 11}, {0x0001, 1},
- {0x0001, 2}, {0x0004, 5}, {0x0005, 5}, {0x0006, 5},
- {0x00D0, 11}, {0x00D1, 11}, {0x00D2, 11}, {0x00D3, 11},
- {0x00D4, 11}, {0x00D5, 11}, {0x00D6, 11}, {0x00D7, 11},
- {0x00D8, 11}, {0x00D9, 11}, {0x00DA, 11}, {0x0007, 5},
- {0x00DB, 11}, {0x00DC, 11}, {0x00DD, 11}, {0x00DE, 11},
- {0x00DF, 11}, {0x00E0, 11}, {0x00E1, 11}, {0x00E2, 11},
- {0x00E3, 11}, {0x00E4, 11}, {0x00E5, 11}, {0x00E6, 11},
- {0x00E7, 11}, {0x00E8, 11}, {0x00E9, 11}, {0x00EA, 11},
- {0x00EB, 11}, {0x00EC, 11}, {0x00ED, 11}, {0x00EE, 11},
- {0x00EF, 11}, {0x00F0, 11}, {0x00F1, 11}, {0x00F2, 11},
- {0x00F3, 11}, {0x00F4, 11}, {0x00F5, 11}, {0x00F6, 11},
- {0x00F7, 11}, {0x00F8, 11}, {0x00F9, 11}, {0x00FA, 11},
- {0x00FB, 11}, {0x00FC, 11}, {0x00FD, 11}, {0x00FE, 11},
- {0x00FF, 11},
- },{//3
- {0x0000, 8}, {0x0001, 8}, {0x0002, 8}, {0x0003, 8},
- {0x0004, 8}, {0x0005, 8}, {0x0006, 8}, {0x0007, 8},
- {0x0008, 8}, {0x0009, 8}, {0x000A, 8}, {0x000B, 8},
- {0x000C, 8}, {0x000D, 8}, {0x000E, 8}, {0x000F, 8},
- {0x0010, 8}, {0x0011, 8}, {0x0012, 8}, {0x0013, 8},
- {0x0014, 8}, {0x0015, 8}, {0x0016, 8}, {0x0001, 1},
- {0x0017, 8}, {0x000C, 7}, {0x000D, 7}, {0x000E, 7},
- {0x000F, 7}, {0x0010, 7}, {0x0011, 7}, {0x0012, 7},
- {0x0013, 7}, {0x0014, 7}, {0x0015, 7}, {0x0016, 7},
- {0x0017, 7}, {0x0018, 7}, {0x0019, 7}, {0x001A, 7},
- {0x001B, 7}, {0x001C, 7}, {0x001D, 7}, {0x001E, 7},
- {0x001F, 7}, {0x0020, 7}, {0x0021, 7}, {0x0022, 7},
- {0x0023, 7}, {0x0024, 7}, {0x0025, 7}, {0x0026, 7},
- {0x0027, 7}, {0x0028, 7}, {0x0029, 7}, {0x002A, 7},
- {0x002B, 7}, {0x002C, 7}, {0x002D, 7}, {0x002E, 7},
- {0x002F, 7}, {0x0030, 7}, {0x0031, 7}, {0x0032, 7},
- {0x0033, 7}, {0x0034, 7}, {0x0035, 7}, {0x0036, 7},
- {0x0037, 7}, {0x0038, 7}, {0x0039, 7}, {0x003A, 7},
- {0x003B, 7}, {0x003C, 7}, {0x003D, 7}, {0x003E, 7},
- {0x003F, 7},
- },{//4
- {0x0000, 9}, {0x0001, 9}, {0x0002, 9}, {0x0003, 9},
- {0x0004, 9}, {0x0005, 9}, {0x0006, 9}, {0x0007, 9},
- {0x0008, 9}, {0x0009, 9}, {0x000A, 9}, {0x000B, 9},
- {0x000C, 9}, {0x000D, 9}, {0x000E, 9}, {0x000F, 9},
- {0x0010, 9}, {0x0011, 9}, {0x0012, 9}, {0x0013, 9},
- {0x0014, 9}, {0x0015, 9}, {0x000B, 8}, {0x0001, 2},
- {0x0001, 1}, {0x000C, 8}, {0x000D, 8}, {0x000E, 8},
- {0x000F, 8}, {0x0010, 8}, {0x0011, 8}, {0x0012, 8},
- {0x0013, 8}, {0x0014, 8}, {0x0015, 8}, {0x0016, 8},
- {0x0017, 8}, {0x0018, 8}, {0x0019, 8}, {0x001A, 8},
- {0x001B, 8}, {0x001C, 8}, {0x001D, 8}, {0x001E, 8},
- {0x001F, 8}, {0x0020, 8}, {0x0021, 8}, {0x0022, 8},
- {0x0023, 8}, {0x0024, 8}, {0x0025, 8}, {0x0026, 8},
- {0x0027, 8}, {0x0028, 8}, {0x0029, 8}, {0x002A, 8},
- {0x002B, 8}, {0x002C, 8}, {0x002D, 8}, {0x002E, 8},
- {0x002F, 8}, {0x0030, 8}, {0x0031, 8}, {0x0032, 8},
- {0x0033, 8}, {0x0034, 8}, {0x0035, 8}, {0x0036, 8},
- {0x0037, 8}, {0x0038, 8}, {0x0039, 8}, {0x003A, 8},
- {0x003B, 8}, {0x003C, 8}, {0x003D, 8}, {0x003E, 8},
- {0x003F, 8},
- },{//5
- {0x0000, 10}, {0x0001, 10}, {0x0002, 10}, {0x0003, 10},
- {0x0004, 10}, {0x0005, 10}, {0x0006, 10}, {0x0007, 10},
- {0x0008, 10}, {0x0009, 10}, {0x000A, 10}, {0x000B, 10},
- {0x000C, 10}, {0x000D, 10}, {0x000E, 10}, {0x000F, 10},
- {0x0010, 10}, {0x0011, 10}, {0x0012, 10}, {0x0013, 10},
- {0x000A, 9}, {0x000B, 9}, {0x000C, 9}, {0x0001, 1},
- {0x0001, 3}, {0x000D, 9}, {0x000E, 9}, {0x0001, 2},
- {0x000F, 9}, {0x0010, 9}, {0x0011, 9}, {0x0012, 9},
- {0x0013, 9}, {0x0014, 9}, {0x0015, 9}, {0x0016, 9},
- {0x0017, 9}, {0x0018, 9}, {0x0019, 9}, {0x001A, 9},
- {0x001B, 9}, {0x001C, 9}, {0x001D, 9}, {0x001E, 9},
- {0x001F, 9}, {0x0020, 9}, {0x0021, 9}, {0x0022, 9},
- {0x0023, 9}, {0x0024, 9}, {0x0025, 9}, {0x0026, 9},
- {0x0027, 9}, {0x0028, 9}, {0x0029, 9}, {0x002A, 9},
- {0x002B, 9}, {0x002C, 9}, {0x002D, 9}, {0x002E, 9},
- {0x002F, 9}, {0x0030, 9}, {0x0031, 9}, {0x0032, 9},
- {0x0033, 9}, {0x0034, 9}, {0x0035, 9}, {0x0036, 9},
- {0x0037, 9}, {0x0038, 9}, {0x0039, 9}, {0x003A, 9},
- {0x003B, 9}, {0x003C, 9}, {0x003D, 9}, {0x003E, 9},
- {0x003F, 9},
- },{//6
- {0x0000, 2}, {0x0004, 4}, {0x000A, 5}, {0x000B, 5},
- {0x0018, 6}, {0x0019, 6}, {0x0034, 7}, {0x006A, 8},
- {0x006B, 8}, {0x006C, 8}, {0x00DA, 9}, {0x00DB, 9},
- {0x01B8, 10}, {0x00DD, 9}, {0x01B9, 10}, {0x3780, 15},
- {0x0004, 3}, {0x000E, 5}, {0x001E, 6}, {0x001F, 6},
- {0x000A, 4}, {0x0058, 7}, {0x0017, 5}, {0x0018, 5},
- {0x0059, 7}, {0x005A, 7}, {0x005B, 7}, {0x00C8, 8},
- {0x0065, 7}, {0x0066, 7}, {0x00C9, 8}, {0x00CE, 8},
- {0x00CF, 8}, {0x00D0, 8}, {0x00D1, 8}, {0x00D2, 8},
- {0x00D3, 8}, {0x00DF, 9}, {0x00D4, 8}, {0x00D5, 8},
- {0x00D6, 8}, {0x01AE, 9}, {0x3781, 15}, {0x01BD, 10},
- {0x035E, 10}, {0x035F, 10}, {0x3782, 15}, {0x0360, 10},
- {0x0037, 6}, {0x01B1, 9}, {0x3783, 15}, {0x3784, 15},
- {0x000E, 4}, {0x003C, 6}, {0x0361, 10}, {0x3785, 15},
- {0x1BC3, 14}, {0x003D, 6}, {0x00D9, 8}, {0x1BC4, 14},
- {0x0368, 10}, {0x1BC5, 14}, {0x1BC6, 14}, {0x1BC7, 14},
- {0x1BC8, 14}, {0x00DB, 8}, {0x0369, 10}, {0x036A, 10},
- {0x1BC9, 14}, {0x1BCA, 14}, {0x1BCB, 14}, {0x1BCC, 14},
- {0x1BCD, 14}, {0x001F, 5}, {0x036B, 10}, {0x1BCE, 14},
- {0x1BCF, 14},
- },{//7
- {0x0000, 3}, {0x0002, 4}, {0x0006, 5}, {0x0007, 5},
- {0x0010, 6}, {0x0044, 8}, {0x0023, 7}, {0x0012, 6},
- {0x0026, 7}, {0x08A0, 13}, {0x004E, 8}, {0x004F, 8},
- {0x08A1, 13}, {0x08A2, 13}, {0x08A3, 13}, {0x0050, 8},
- {0x0006, 4}, {0x000B, 5}, {0x0029, 7}, {0x0015, 6},
- {0x001C, 6}, {0x003A, 7}, {0x001E, 6}, {0x0004, 3},
- {0x0014, 5}, {0x0015, 5}, {0x000B, 4}, {0x001F, 6},
- {0x0030, 6}, {0x0031, 6}, {0x0019, 5}, {0x0051, 8},
- {0x0034, 6}, {0x0035, 6}, {0x0036, 6}, {0x0037, 6},
- {0x0076, 8}, {0x0077, 8}, {0x0070, 7}, {0x001D, 5},
- {0x0071, 7}, {0x0072, 7}, {0x08A4, 13}, {0x0073, 7},
- {0x00F0, 8}, {0x08A5, 13}, {0x08A6, 13}, {0x08A7, 13},
- {0x0079, 7}, {0x007A, 7}, {0x08A8, 13}, {0x08A9, 13},
- {0x00F1, 8}, {0x08AA, 13}, {0x08AB, 13}, {0x08AC, 13},
- {0x08AD, 13}, {0x00F6, 8}, {0x08AE, 13}, {0x007C, 7},
- {0x00F7, 8}, {0x08AF, 13}, {0x08B0, 13}, {0x08B1, 13},
- {0x08B2, 13}, {0x00FA, 8}, {0x08B3, 13}, {0x08B4, 13},
- {0x08B5, 13}, {0x08B6, 13}, {0x08B7, 13}, {0x00FB, 8},
- {0x045C, 12}, {0x003F, 6}, {0x045D, 12}, {0x045E, 12},
- {0x045F, 12},
- }
-};
-
-static const uint16_t x8_ac1_lowquant_table[8][77][2]={
- {//0
- {0x0000, 3}, {0x0002, 4}, {0x0003, 4}, {0x0008, 5},
- {0x0012, 6}, {0x0026, 7}, {0x0014, 6}, {0x004E, 8},
- {0x004F, 8}, {0x00A8, 9}, {0x0152, 10}, {0x00AA, 9},
- {0x00AB, 9}, {0x00AC, 9}, {0x2A60, 15}, {0x02A7, 11},
- {0x0006, 4}, {0x000B, 5}, {0x001C, 6}, {0x003A, 7},
- {0x000F, 5}, {0x003B, 7}, {0x0010, 5}, {0x0005, 3},
- {0x0009, 4}, {0x0011, 5}, {0x0018, 5}, {0x0019, 5},
- {0x001A, 5}, {0x0036, 6}, {0x0037, 6}, {0x0070, 7},
- {0x0057, 8}, {0x00E2, 8}, {0x00E3, 8}, {0x00E4, 8},
- {0x00E5, 8}, {0x00AD, 9}, {0x0398, 10}, {0x003A, 6},
- {0x0076, 7}, {0x00E7, 8}, {0x00EE, 8}, {0x00EF, 8},
- {0x0732, 11}, {0x039A, 10}, {0x0733, 11}, {0x2A61, 15},
- {0x0078, 7}, {0x1531, 14}, {0x1532, 14}, {0x1533, 14},
- {0x003D, 6}, {0x039B, 10}, {0x1534, 14}, {0x1535, 14},
- {0x1536, 14}, {0x0079, 7}, {0x1537, 14}, {0x00F8, 8},
- {0x01F2, 9}, {0x07CC, 11}, {0x03E7, 10}, {0x07CD, 11},
- {0x3E80, 14}, {0x00FB, 8}, {0x03E9, 10}, {0x3E81, 14},
- {0x3E82, 14}, {0x3E83, 14}, {0x3E84, 14}, {0x3E85, 14},
- {0x3E86, 14}, {0x003F, 6}, {0x01F5, 9}, {0x07D1, 11},
- {0x3E87, 14},
- },{//1
- {0x0000, 2}, {0x0002, 3}, {0x0006, 4}, {0x000E, 5},
- {0x001E, 6}, {0x001F, 6}, {0x0040, 7}, {0x0082, 8},
- {0x0083, 8}, {0x0084, 8}, {0x010A, 9}, {0x010B, 9},
- {0x0430, 11}, {0x0431, 11}, {0x0432, 11}, {0x0433, 11},
- {0x0005, 3}, {0x0011, 5}, {0x0024, 6}, {0x004A, 7},
- {0x000C, 4}, {0x0026, 6}, {0x000D, 4}, {0x0087, 8},
- {0x010D, 9}, {0x0258, 10}, {0x012D, 9}, {0x0259, 10},
- {0x025C, 10}, {0x0974, 12}, {0x025E, 10}, {0x025F, 10},
- {0x0270, 10}, {0x0271, 10}, {0x04BB, 11}, {0x0975, 12},
- {0x0272, 10}, {0x09CC, 12}, {0x09CD, 12}, {0x4E70, 15},
- {0x4E71, 15}, {0x4E72, 15}, {0x4E73, 15}, {0x273A, 14},
- {0x273B, 14}, {0x273C, 14}, {0x04E8, 11}, {0x04E9, 11},
- {0x009E, 8}, {0x0275, 10}, {0x09D8, 12}, {0x273D, 14},
- {0x000E, 4}, {0x003C, 6}, {0x007A, 7}, {0x009F, 8},
- {0x0277, 10}, {0x003E, 6}, {0x00F6, 8}, {0x04ED, 11},
- {0x03DC, 10}, {0x273E, 14}, {0x07BA, 11}, {0x09D9, 12},
- {0x273F, 14}, {0x3DD8, 14}, {0x3DD9, 14}, {0x3DDA, 14},
- {0x3DDB, 14}, {0x3DDC, 14}, {0x3DDD, 14}, {0x3DDE, 14},
- {0x3DDF, 14}, {0x003F, 6}, {0x07BC, 11}, {0x07BD, 11},
- {0x03DF, 10},
- },{//2
- {0x0000, 3}, {0x0002, 4}, {0x0006, 5}, {0x000E, 6},
- {0x001E, 7}, {0x003E, 8}, {0x003F, 8}, {0x0040, 8},
- {0x0104, 10}, {0x0083, 9}, {0x0105, 10}, {0x0108, 10},
- {0x4240, 16}, {0x010A, 10}, {0x010B, 10}, {0x4241, 16},
- {0x0003, 3}, {0x0009, 5}, {0x0011, 6}, {0x0043, 8},
- {0x0004, 3}, {0x000A, 5}, {0x000A, 4}, {0x002C, 7},
- {0x00B4, 9}, {0x00B5, 9}, {0x00B6, 9}, {0x00B7, 9},
- {0x00B8, 9}, {0x0172, 10}, {0x0173, 10}, {0x0174, 10},
- {0x0175, 10}, {0x0176, 10}, {0x0177, 10}, {0x00BC, 9},
- {0x017A, 10}, {0x0213, 11}, {0x4242, 16}, {0x017B, 10},
- {0x02F8, 11}, {0x017D, 10}, {0x02F9, 11}, {0x017E, 10},
- {0x4243, 16}, {0x02FE, 11}, {0x2122, 15}, {0x2123, 15},
- {0x0058, 7}, {0x0164, 9}, {0x2124, 15}, {0x2125, 15},
- {0x0006, 3}, {0x000E, 4}, {0x002D, 6}, {0x002E, 6},
- {0x00B3, 8}, {0x001E, 5}, {0x005E, 7}, {0x2126, 15},
- {0x2127, 15}, {0x2128, 15}, {0x2129, 15}, {0x02FF, 11},
- {0x212A, 15}, {0x0594, 11}, {0x0595, 11}, {0x0596, 11},
- {0x212B, 15}, {0x212C, 15}, {0x212D, 15}, {0x212E, 15},
- {0x212F, 15}, {0x001F, 5}, {0x0597, 11}, {0x00BE, 8},
- {0x00BF, 8},
- },{//3
- {0x0000, 2}, {0x0002, 3}, {0x0006, 4}, {0x0007, 4},
- {0x0010, 5}, {0x0011, 5}, {0x0024, 6}, {0x0025, 6},
- {0x0026, 6}, {0x0027, 6}, {0x0050, 7}, {0x0051, 7},
- {0x00A4, 8}, {0x00A5, 8}, {0x00A6, 8}, {0x014E, 9},
- {0x000B, 4}, {0x002A, 6}, {0x0056, 7}, {0x014F, 9},
- {0x0030, 6}, {0x00AE, 8}, {0x0062, 7}, {0x0032, 6},
- {0x0033, 6}, {0x0034, 6}, {0x0035, 6}, {0x0036, 6},
- {0x0063, 7}, {0x006E, 7}, {0x006F, 7}, {0x0070, 7},
- {0x0071, 7}, {0x0072, 7}, {0x0073, 7}, {0x0074, 7},
- {0x00AF, 8}, {0x00EA, 8}, {0x01D6, 9}, {0x075C, 11},
- {0x03AF, 10}, {0x75D0, 15}, {0x75D1, 15}, {0x75D2, 15},
- {0x75D3, 15}, {0x75D4, 15}, {0x0076, 7}, {0x00EE, 8},
- {0x00EF, 8}, {0x0EBB, 12}, {0x01E0, 9}, {0x75D5, 15},
- {0x0079, 7}, {0x01E1, 9}, {0x75D6, 15}, {0x75D7, 15},
- {0x7880, 15}, {0x00F4, 8}, {0x0789, 11}, {0x003E, 6},
- {0x007B, 7}, {0x00F5, 8}, {0x00FC, 8}, {0x007F, 7},
- {0x01E3, 9}, {0x078A, 11}, {0x078B, 11}, {0x7881, 15},
- {0x7882, 15}, {0x7883, 15}, {0x3C42, 14}, {0x3C43, 14},
- {0x3C44, 14}, {0x00FD, 8}, {0x3C45, 14}, {0x3C46, 14},
- {0x3C47, 14},
- },{//4
- {0x0000, 2}, {0x0004, 4}, {0x000A, 5}, {0x0016, 6},
- {0x0017, 6}, {0x0030, 7}, {0x0031, 7}, {0x0064, 8},
- {0x0065, 8}, {0x0066, 8}, {0x00CE, 9}, {0x00CF, 9},
- {0x01A0, 10}, {0x01A1, 10}, {0x1A20, 14}, {0x0689, 12},
- {0x0004, 3}, {0x000E, 5}, {0x001B, 6}, {0x0035, 7},
- {0x000A, 4}, {0x001E, 6}, {0x0016, 5}, {0x0017, 5},
- {0x001F, 6}, {0x0030, 6}, {0x0031, 6}, {0x0064, 7},
- {0x0065, 7}, {0x0069, 8}, {0x0066, 7}, {0x00CE, 8},
- {0x00CF, 8}, {0x00D0, 8}, {0x00D1, 8}, {0x00D2, 8},
- {0x01A6, 9}, {0x01A3, 10}, {0x034E, 10}, {0x006A, 7},
- {0x00D6, 8}, {0x01AE, 9}, {0x01AF, 9}, {0x034F, 10},
- {0x0345, 11}, {0x01B0, 9}, {0x01B1, 9}, {0x0364, 10},
- {0x006D, 7}, {0x00DC, 8}, {0x0D94, 12}, {0x0D95, 12},
- {0x000E, 4}, {0x003C, 6}, {0x00DD, 8}, {0x00DE, 8},
- {0x01B3, 9}, {0x003D, 6}, {0x00DF, 8}, {0x01F0, 9},
- {0x03E2, 10}, {0x03E3, 10}, {0x06CB, 11}, {0x03E4, 10},
- {0x07CA, 11}, {0x01F3, 9}, {0x01F4, 9}, {0x07CB, 11},
- {0x07D4, 11}, {0x1A21, 14}, {0x1A22, 14}, {0x07D5, 11},
- {0x1A23, 14}, {0x003F, 6}, {0x01F6, 9}, {0x01F7, 9},
- {0x03EB, 10},
- },{//5
- {0x0000, 2}, {0x0002, 3}, {0x0006, 4}, {0x000E, 5},
- {0x000F, 5}, {0x0020, 6}, {0x0021, 6}, {0x0044, 7},
- {0x0045, 7}, {0x0046, 7}, {0x008E, 8}, {0x008F, 8},
- {0x0090, 8}, {0x0122, 9}, {0x0246, 10}, {0x0124, 9},
- {0x0005, 3}, {0x0013, 5}, {0x004A, 7}, {0x0093, 8},
- {0x0018, 5}, {0x004B, 7}, {0x0032, 6}, {0x001A, 5},
- {0x0033, 6}, {0x006C, 7}, {0x006D, 7}, {0x006E, 7},
- {0x00DE, 8}, {0x00DF, 8}, {0x0070, 7}, {0x00E2, 8},
- {0x00E3, 8}, {0x00E4, 8}, {0x00E5, 8}, {0x00E6, 8},
- {0x00E7, 8}, {0x0125, 9}, {0x01D0, 9}, {0x048E, 11},
- {0x091E, 12}, {0x091F, 12}, {0x7440, 15}, {0x1D11, 13},
- {0x7441, 15}, {0x7442, 15}, {0x00E9, 8}, {0x01D4, 9},
- {0x00EB, 8}, {0x03A3, 10}, {0x01D5, 9}, {0x1D12, 13},
- {0x001E, 5}, {0x0076, 7}, {0x01DC, 9}, {0x01DD, 9},
- {0x7443, 15}, {0x007C, 7}, {0x0745, 11}, {0x00EF, 8},
- {0x00FA, 8}, {0x00FB, 8}, {0x01F8, 9}, {0x00FD, 8},
- {0x07E4, 11}, {0x0FCA, 12}, {0x1D13, 13}, {0x7E58, 15},
- {0x7E59, 15}, {0x7E5A, 15}, {0x7E5B, 15}, {0x7E5C, 15},
- {0x7E5D, 15}, {0x007F, 7}, {0x3F2F, 14}, {0x07E6, 11},
- {0x07E7, 11},
- },{//6
- {0x0000, 3}, {0x0002, 4}, {0x0003, 4}, {0x0008, 5},
- {0x0009, 5}, {0x0014, 6}, {0x0015, 6}, {0x002C, 7},
- {0x005A, 8}, {0x005B, 8}, {0x005C, 8}, {0x00BA, 9},
- {0x00BB, 9}, {0x00BC, 9}, {0x02F4, 11}, {0x05EA, 12},
- {0x0003, 3}, {0x0010, 5}, {0x0022, 6}, {0x0046, 7},
- {0x0009, 4}, {0x0028, 6}, {0x0015, 5}, {0x000B, 4},
- {0x0018, 5}, {0x0029, 6}, {0x0032, 6}, {0x0047, 7},
- {0x0066, 7}, {0x0067, 7}, {0x0068, 7}, {0x0069, 7},
- {0x006A, 7}, {0x005F, 8}, {0x00D6, 8}, {0x00D7, 8},
- {0x01B0, 9}, {0x00D9, 8}, {0x017B, 10}, {0x006D, 7},
- {0x00DC, 8}, {0x01B1, 9}, {0x06E8, 11}, {0x01BB, 9},
- {0x0375, 10}, {0x05EB, 12}, {0x01BC, 9}, {0x6E90, 15},
- {0x0038, 6}, {0x0072, 7}, {0x6E91, 15}, {0x6E92, 15},
- {0x001D, 5}, {0x0073, 7}, {0x01BD, 9}, {0x06F8, 11},
- {0x6E93, 15}, {0x003C, 6}, {0x01BF, 9}, {0x00F4, 8},
- {0x01EA, 9}, {0x037D, 10}, {0x03D6, 10}, {0x06F9, 11},
- {0x6E94, 15}, {0x00F6, 8}, {0x01EE, 9}, {0x6E95, 15},
- {0x6E96, 15}, {0x6E97, 15}, {0x374C, 14}, {0x374D, 14},
- {0x374E, 14}, {0x001F, 5}, {0x03D7, 10}, {0x01EF, 9},
- {0x374F, 14},
- },{//7
- {0x0000, 2}, {0x0004, 4}, {0x000A, 5}, {0x0016, 6},
- {0x002E, 7}, {0x002F, 7}, {0x0060, 8}, {0x0061, 8},
- {0x00C4, 9}, {0x00C5, 9}, {0x00C6, 9}, {0x018E, 10},
- {0x31E0, 15}, {0x31E1, 15}, {0x31E2, 15}, {0x31E3, 15},
- {0x0004, 3}, {0x000D, 5}, {0x0019, 6}, {0x0038, 7},
- {0x000A, 4}, {0x001D, 6}, {0x000B, 4}, {0x0072, 8},
- {0x0073, 8}, {0x00F0, 9}, {0x01E2, 10}, {0x00F2, 9},
- {0x01E3, 10}, {0x00F3, 9}, {0x01E8, 10}, {0x01E9, 10},
- {0x31E4, 15}, {0x01EA, 10}, {0x031F, 11}, {0x03D6, 11},
- {0x31E5, 15}, {0x01EC, 10}, {0x31E6, 15}, {0x00F7, 9},
- {0x03D7, 11}, {0x31E7, 15}, {0x31E8, 15}, {0x03DA, 11},
- {0x03DB, 11}, {0x31E9, 15}, {0x03E0, 11}, {0x31EA, 15},
- {0x003F, 7}, {0x01F1, 10}, {0x31EB, 15}, {0x31EC, 15},
- {0x0006, 3}, {0x001C, 5}, {0x0074, 7}, {0x0075, 7},
- {0x00F9, 9}, {0x001E, 5}, {0x0076, 7}, {0x00FA, 9},
- {0x03E1, 11}, {0x31ED, 15}, {0x18F7, 14}, {0x1F60, 14},
- {0x1F61, 14}, {0x01DC, 9}, {0x01DD, 9}, {0x1F62, 14},
- {0x1F63, 14}, {0x1F64, 14}, {0x1F65, 14}, {0x1F66, 14},
- {0x1F67, 14}, {0x001F, 5}, {0x03ED, 11}, {0x00EF, 8},
- {0x01F7, 10},
- }
-};
-
-static const uint16_t x8_ac1_highquant_table[8][77][2]={
- {//0
- {0x0000, 3}, {0x0002, 4}, {0x0006, 5}, {0x0007, 5},
- {0x0008, 5}, {0x0009, 5}, {0x0014, 6}, {0x002A, 7},
- {0x0016, 6}, {0x002B, 7}, {0x005C, 8}, {0x002F, 7},
- {0x0030, 7}, {0x005D, 8}, {0x0062, 8}, {0x00C6, 9},
- {0x0007, 4}, {0x0019, 6}, {0x001A, 6}, {0x0036, 7},
- {0x0010, 5}, {0x006E, 8}, {0x0022, 6}, {0x0009, 4},
- {0x000A, 4}, {0x0016, 5}, {0x0023, 6}, {0x002E, 6},
- {0x002F, 6}, {0x0030, 6}, {0x0062, 7}, {0x0063, 7},
- {0x0064, 7}, {0x0065, 7}, {0x0066, 7}, {0x0067, 7},
- {0x0068, 7}, {0x0069, 7}, {0x006A, 7}, {0x006B, 7},
- {0x006C, 7}, {0x00C7, 9}, {0x00DE, 9}, {0x00DF, 9},
- {0x06D0, 11}, {0x01B5, 9}, {0x0037, 6}, {0x00DB, 8},
- {0x001C, 5}, {0x0074, 7}, {0x01D4, 9}, {0x01D5, 9},
- {0x0076, 7}, {0x0369, 10}, {0x3688, 14}, {0x3689, 14},
- {0x368A, 14}, {0x0077, 7}, {0x03AC, 10}, {0x0078, 7},
- {0x00F2, 8}, {0x01D7, 9}, {0x00F3, 8}, {0x007A, 7},
- {0x368B, 14}, {0x007B, 7}, {0x007C, 7}, {0x03AD, 10},
- {0x03E8, 10}, {0x368C, 14}, {0x368D, 14}, {0x03E9, 10},
- {0x368E, 14}, {0x003F, 6}, {0x01F5, 9}, {0x00FB, 8},
- {0x368F, 14},
- },{//1
- {0x0000, 2}, {0x0004, 4}, {0x000A, 5}, {0x000B, 5},
- {0x0018, 6}, {0x0032, 7}, {0x0033, 7}, {0x0034, 7},
- {0x006A, 8}, {0x00D6, 9}, {0x00D7, 9}, {0x00D8, 9},
- {0x00D9, 9}, {0x3680, 15}, {0x01B5, 10}, {0x0369, 11},
- {0x0004, 3}, {0x000E, 5}, {0x001E, 6}, {0x0037, 7},
- {0x000A, 4}, {0x0016, 5}, {0x000C, 4}, {0x001F, 6},
- {0x005C, 7}, {0x005D, 7}, {0x00BC, 8}, {0x00BD, 8},
- {0x005F, 7}, {0x00D0, 8}, {0x00DB, 9}, {0x00D1, 8},
- {0x01A4, 9}, {0x01A5, 9}, {0x01A6, 9}, {0x01A7, 9},
- {0x0350, 10}, {0x06A2, 11}, {0x06A3, 11}, {0x01A9, 9},
- {0x01AA, 9}, {0x06AC, 11}, {0x3681, 15}, {0x0357, 10},
- {0x3682, 15}, {0x3683, 15}, {0x3684, 15}, {0x3685, 15},
- {0x0036, 6}, {0x00D6, 8}, {0x3686, 15}, {0x3687, 15},
- {0x000E, 4}, {0x006E, 7}, {0x00D7, 8}, {0x06AD, 11},
- {0x3688, 15}, {0x001E, 5}, {0x00DE, 8}, {0x06F8, 11},
- {0x037D, 10}, {0x3689, 15}, {0x368A, 15}, {0x368B, 15},
- {0x368C, 15}, {0x01BF, 9}, {0x368D, 15}, {0x1B47, 14},
- {0x37C8, 14}, {0x37C9, 14}, {0x37CA, 14}, {0x37CB, 14},
- {0x37CC, 14}, {0x001F, 5}, {0x37CD, 14}, {0x37CE, 14},
- {0x37CF, 14},
- },{//2
- {0x0000, 3}, {0x0002, 4}, {0x0003, 4}, {0x0008, 5},
- {0x0012, 6}, {0x0026, 7}, {0x0014, 6}, {0x0027, 7},
- {0x00A8, 9}, {0x00A9, 9}, {0x0055, 8}, {0x2B00, 15},
- {0x00AD, 9}, {0x2B01, 15}, {0x2B02, 15}, {0x2B03, 15},
- {0x0003, 3}, {0x000B, 5}, {0x0040, 7}, {0x0041, 7},
- {0x0009, 4}, {0x0021, 6}, {0x0011, 5}, {0x000A, 4},
- {0x000B, 4}, {0x0018, 5}, {0x0032, 6}, {0x0033, 6},
- {0x0034, 6}, {0x0035, 6}, {0x006C, 7}, {0x0057, 8},
- {0x006D, 7}, {0x00DC, 8}, {0x0159, 10}, {0x00DD, 8},
- {0x01BC, 9}, {0x037A, 10}, {0x037B, 10}, {0x0038, 6},
- {0x0072, 7}, {0x01BE, 9}, {0x01BF, 9}, {0x00E6, 8},
- {0x039C, 10}, {0x01CF, 9}, {0x2B04, 15}, {0x2B05, 15},
- {0x0074, 7}, {0x01D4, 9}, {0x2B06, 15}, {0x2B07, 15},
- {0x001E, 5}, {0x00EB, 8}, {0x1584, 14}, {0x1585, 14},
- {0x1586, 14}, {0x003B, 6}, {0x01D5, 9}, {0x01F0, 9},
- {0x039D, 10}, {0x03E2, 10}, {0x1587, 14}, {0x1588, 14},
- {0x1589, 14}, {0x00F9, 8}, {0x158A, 14}, {0x158B, 14},
- {0x03E3, 10}, {0x158C, 14}, {0x158D, 14}, {0x01F4, 9},
- {0x158E, 14}, {0x003F, 6}, {0x00FB, 8}, {0x01F5, 9},
- {0x158F, 14},
- },{//3
- {0x0000, 3}, {0x0002, 4}, {0x0006, 5}, {0x0007, 5},
- {0x0010, 6}, {0x0011, 6}, {0x0024, 7}, {0x0025, 7},
- {0x0013, 6}, {0x0014, 6}, {0x002A, 7}, {0x002B, 7},
- {0x00B0, 9}, {0x00B1, 9}, {0x002D, 7}, {0x0059, 8},
- {0x000C, 5}, {0x0017, 6}, {0x00D0, 9}, {0x0035, 7},
- {0x001B, 6}, {0x0038, 7}, {0x0039, 7}, {0x0004, 3},
- {0x0005, 3}, {0x000F, 5}, {0x0018, 5}, {0x001D, 6},
- {0x0032, 6}, {0x0033, 6}, {0x0068, 7}, {0x0069, 7},
- {0x0069, 8}, {0x00D4, 8}, {0x00D5, 8}, {0x00D6, 8},
- {0x006C, 7}, {0x0037, 6}, {0x006D, 7}, {0x0070, 7},
- {0x0039, 6}, {0x00D7, 8}, {0x00D1, 9}, {0x3880, 14},
- {0x3881, 14}, {0x3882, 14}, {0x0074, 7}, {0x01C5, 9},
- {0x0075, 7}, {0x00E3, 8}, {0x3883, 14}, {0x3884, 14},
- {0x00EC, 8}, {0x3885, 14}, {0x1C43, 13}, {0x1C44, 13},
- {0x1C45, 13}, {0x00ED, 8}, {0x1C46, 13}, {0x003C, 6},
- {0x0077, 7}, {0x01E8, 9}, {0x003E, 6}, {0x007B, 7},
- {0x1C47, 13}, {0x007E, 7}, {0x007F, 7}, {0x1C48, 13},
- {0x1C49, 13}, {0x1C4A, 13}, {0x1C4B, 13}, {0x1C4C, 13},
- {0x1C4D, 13}, {0x00F5, 8}, {0x1C4E, 13}, {0x01E9, 9},
- {0x1C4F, 13},
- },{//4
- {0x0000, 2}, {0x0004, 4}, {0x000A, 5}, {0x000B, 5},
- {0x0018, 6}, {0x0019, 6}, {0x0034, 7}, {0x0035, 7},
- {0x0036, 7}, {0x006E, 8}, {0x00DE, 9}, {0x00DF, 9},
- {0x01C0, 10}, {0x01C1, 10}, {0x01C2, 10}, {0x3860, 15},
- {0x0004, 3}, {0x000F, 5}, {0x001D, 6}, {0x0039, 7},
- {0x000A, 4}, {0x002C, 6}, {0x002D, 6}, {0x000C, 4},
- {0x0017, 5}, {0x0034, 6}, {0x0035, 6}, {0x0036, 6},
- {0x006E, 7}, {0x006F, 7}, {0x0070, 7}, {0x0071, 7},
- {0x0071, 8}, {0x00E4, 8}, {0x00E5, 8}, {0x00E6, 8},
- {0x00E7, 8}, {0x00E8, 8}, {0x03A4, 10}, {0x0075, 7},
- {0x00EC, 8}, {0x01D3, 9}, {0x01DA, 9}, {0x03A5, 10},
- {0x03B6, 10}, {0x070D, 12}, {0x03B7, 10}, {0x070E, 12},
- {0x003C, 6}, {0x00EE, 8}, {0x3861, 15}, {0x3862, 15},
- {0x003D, 6}, {0x01DE, 9}, {0x3863, 15}, {0x3864, 15},
- {0x3865, 15}, {0x007C, 7}, {0x070F, 12}, {0x03BE, 10},
- {0x03BF, 10}, {0x3866, 15}, {0x0FA0, 12}, {0x07D1, 11},
- {0x3867, 15}, {0x00FB, 8}, {0x01F5, 9}, {0x7D08, 15},
- {0x0FA4, 12}, {0x7D09, 15}, {0x7D0A, 15}, {0x7D0B, 15},
- {0x3E86, 14}, {0x003F, 6}, {0x0FA5, 12}, {0x07D3, 11},
- {0x3E87, 14},
- },{//5
- {0x0000, 3}, {0x0002, 4}, {0x0003, 4}, {0x0008, 5},
- {0x0009, 5}, {0x0014, 6}, {0x002A, 7}, {0x0056, 8},
- {0x02B8, 11}, {0x00AF, 9}, {0x02B9, 11}, {0x015D, 10},
- {0x02C0, 11}, {0x2C10, 15}, {0x2C11, 15}, {0x2C12, 15},
- {0x0006, 4}, {0x000E, 5}, {0x0017, 6}, {0x002D, 7},
- {0x000F, 5}, {0x0040, 7}, {0x0021, 6}, {0x0005, 3},
- {0x0009, 4}, {0x0011, 5}, {0x0018, 5}, {0x0019, 5},
- {0x001A, 5}, {0x0036, 6}, {0x0037, 6}, {0x0041, 7},
- {0x0059, 8}, {0x00E0, 8}, {0x00E1, 8}, {0x0071, 7},
- {0x00E4, 8}, {0x00B1, 9}, {0x02C2, 11}, {0x001D, 5},
- {0x0073, 7}, {0x00E5, 8}, {0x00F0, 8}, {0x0079, 7},
- {0x03C4, 10}, {0x01E3, 9}, {0x01E8, 9}, {0x2C13, 15},
- {0x007B, 7}, {0x2C14, 15}, {0x2C15, 15}, {0x2C16, 15},
- {0x007C, 7}, {0x02C3, 11}, {0x2C17, 15}, {0x160C, 14},
- {0x160D, 14}, {0x007D, 7}, {0x160E, 14}, {0x01E9, 9},
- {0x03C5, 10}, {0x03D4, 10}, {0x01EB, 9}, {0x160F, 14},
- {0x3D50, 14}, {0x00FC, 8}, {0x07AB, 11}, {0x3D51, 14},
- {0x3D52, 14}, {0x3D53, 14}, {0x3D54, 14}, {0x01FA, 9},
- {0x3D55, 14}, {0x007F, 7}, {0x01FB, 9}, {0x3D56, 14},
- {0x3D57, 14},
- },{//6
- {0x0000, 3}, {0x0002, 4}, {0x0003, 4}, {0x0008, 5},
- {0x0009, 5}, {0x000A, 5}, {0x000B, 5}, {0x0018, 6},
- {0x0032, 7}, {0x000D, 5}, {0x0033, 7}, {0x0E00, 13},
- {0x0039, 7}, {0x0E01, 13}, {0x003A, 7}, {0x0E02, 13},
- {0x0008, 4}, {0x001E, 6}, {0x003B, 7}, {0x003E, 7},
- {0x0012, 5}, {0x003F, 7}, {0x0013, 5}, {0x0028, 6},
- {0x0029, 6}, {0x0054, 7}, {0x002B, 6}, {0x0055, 7},
- {0x0058, 7}, {0x0E03, 13}, {0x0059, 7}, {0x005A, 7},
- {0x0E04, 13}, {0x0E05, 13}, {0x0703, 12}, {0x005B, 7},
- {0x005C, 7}, {0x0704, 12}, {0x0705, 12}, {0x005D, 7},
- {0x0706, 12}, {0x0707, 12}, {0x0708, 12}, {0x0709, 12},
- {0x070A, 12}, {0x070B, 12}, {0x0018, 5}, {0x002F, 6},
- {0x000D, 4}, {0x0019, 5}, {0x070C, 12}, {0x0070, 7},
- {0x001D, 5}, {0x070D, 12}, {0x070E, 12}, {0x070F, 12},
- {0x0710, 12}, {0x0039, 6}, {0x0711, 12}, {0x003C, 6},
- {0x0712, 12}, {0x0713, 12}, {0x0714, 12}, {0x0715, 12},
- {0x0716, 12}, {0x003D, 6}, {0x0717, 12}, {0x0718, 12},
- {0x0719, 12}, {0x071A, 12}, {0x071B, 12}, {0x071C, 12},
- {0x071D, 12}, {0x001F, 5}, {0x071E, 12}, {0x0071, 7},
- {0x071F, 12},
- },{//7
- {0x0000, 3}, {0x0002, 4}, {0x0006, 5}, {0x000E, 6},
- {0x000F, 6}, {0x0040, 8}, {0x0041, 8}, {0x0042, 8},
- {0x0218, 11}, {0x2190, 15}, {0x2191, 15}, {0x2192, 15},
- {0x2193, 15}, {0x2194, 15}, {0x2195, 15}, {0x2196, 15},
- {0x0005, 4}, {0x0011, 6}, {0x0024, 7}, {0x0087, 9},
- {0x000C, 5}, {0x004A, 8}, {0x004B, 8}, {0x0002, 2},
- {0x0006, 3}, {0x000D, 5}, {0x000E, 5}, {0x000F, 5},
- {0x0013, 6}, {0x0038, 6}, {0x00E4, 8}, {0x00E5, 8},
- {0x01CC, 9}, {0x00E7, 8}, {0x0074, 7}, {0x00EA, 8},
- {0x01CD, 9}, {0x021A, 11}, {0x2197, 15}, {0x001E, 5},
- {0x0076, 7}, {0x00EB, 8}, {0x01DC, 9}, {0x00EF, 8},
- {0x01DD, 9}, {0x01F0, 9}, {0x2198, 15}, {0x2199, 15},
- {0x00F9, 8}, {0x03E2, 10}, {0x219A, 15}, {0x219B, 15},
- {0x00FA, 8}, {0x219C, 15}, {0x219D, 15}, {0x219E, 15},
- {0x219F, 15}, {0x01F6, 9}, {0x21B0, 15}, {0x00FC, 8},
- {0x01F7, 9}, {0x21B1, 15}, {0x21B2, 15}, {0x21B3, 15},
- {0x21B4, 15}, {0x01FA, 9}, {0x21B5, 15}, {0x21B6, 15},
- {0x21B7, 15}, {0x21B8, 15}, {0x21B9, 15}, {0x03E3, 10},
- {0x10DD, 14}, {0x007F, 7}, {0x01FB, 9}, {0x10DE, 14},
- {0x10DF, 14},
- }
-};
-#define MAX_AC_VLC_BITS 16
-
-#endif /* AVCODEC_INTRAX8HUF_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/ituh263dec.c b/src/thirdparty/ffmpeg/libavcodec/ituh263dec.c
deleted file mode 100644
index 920781b5b..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/ituh263dec.c
+++ /dev/null
@@ -1,1158 +0,0 @@
-/*
- * ITU H263 bitstream decoder
- * Copyright (c) 2000,2001 Fabrice Bellard
- * H263+ support.
- * Copyright (c) 2001 Juan J. Sierralta P
- * Copyright (c) 2002-2004 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
- * h263 decoder.
- */
-
-#define UNCHECKED_BITSTREAM_READER 1
-
-//#define DEBUG
-#include <limits.h>
-
-#include "libavutil/internal.h"
-#include "libavutil/mathematics.h"
-#include "dsputil.h"
-#include "avcodec.h"
-#include "mpegvideo.h"
-#include "h263.h"
-#include "mathops.h"
-#include "unary.h"
-#include "flv.h"
-#include "mpeg4video.h"
-
-// The defines below define the number of bits that are read at once for
-// reading vlc values. Changing these may improve speed and data cache needs
-// be aware though that decreasing them may need the number of stages that is
-// passed to get_vlc* to be increased.
-#define MV_VLC_BITS 9
-#define H263_MBTYPE_B_VLC_BITS 6
-#define CBPC_B_VLC_BITS 3
-
-static const int h263_mb_type_b_map[15]= {
- MB_TYPE_DIRECT2 | MB_TYPE_L0L1,
- MB_TYPE_DIRECT2 | MB_TYPE_L0L1 | MB_TYPE_CBP,
- MB_TYPE_DIRECT2 | MB_TYPE_L0L1 | MB_TYPE_CBP | MB_TYPE_QUANT,
- MB_TYPE_L0 | MB_TYPE_16x16,
- MB_TYPE_L0 | MB_TYPE_CBP | MB_TYPE_16x16,
- MB_TYPE_L0 | MB_TYPE_CBP | MB_TYPE_QUANT | MB_TYPE_16x16,
- MB_TYPE_L1 | MB_TYPE_16x16,
- MB_TYPE_L1 | MB_TYPE_CBP | MB_TYPE_16x16,
- MB_TYPE_L1 | MB_TYPE_CBP | MB_TYPE_QUANT | MB_TYPE_16x16,
- MB_TYPE_L0L1 | MB_TYPE_16x16,
- MB_TYPE_L0L1 | MB_TYPE_CBP | MB_TYPE_16x16,
- MB_TYPE_L0L1 | MB_TYPE_CBP | MB_TYPE_QUANT | MB_TYPE_16x16,
- 0, //stuffing
- MB_TYPE_INTRA4x4 | MB_TYPE_CBP,
- MB_TYPE_INTRA4x4 | MB_TYPE_CBP | MB_TYPE_QUANT,
-};
-
-void ff_h263_show_pict_info(MpegEncContext *s){
- if(s->avctx->debug&FF_DEBUG_PICT_INFO){
- av_log(s->avctx, AV_LOG_DEBUG, "qp:%d %c size:%d rnd:%d%s%s%s%s%s%s%s%s%s %d/%d\n",
- s->qscale, av_get_picture_type_char(s->pict_type),
- s->gb.size_in_bits, 1-s->no_rounding,
- s->obmc ? " AP" : "",
- s->umvplus ? " UMV" : "",
- s->h263_long_vectors ? " LONG" : "",
- s->h263_plus ? " +" : "",
- s->h263_aic ? " AIC" : "",
- s->alt_inter_vlc ? " AIV" : "",
- s->modified_quant ? " MQ" : "",
- s->loop_filter ? " LOOP" : "",
- s->h263_slice_structured ? " SS" : "",
- s->avctx->time_base.den, s->avctx->time_base.num
- );
- }
-}
-
-/***********************************************/
-/* decoding */
-
-VLC ff_h263_intra_MCBPC_vlc;
-VLC ff_h263_inter_MCBPC_vlc;
-VLC ff_h263_cbpy_vlc;
-static VLC mv_vlc;
-static VLC h263_mbtype_b_vlc;
-static VLC cbpc_b_vlc;
-
-/* init vlcs */
-
-/* XXX: find a better solution to handle static init */
-void ff_h263_decode_init_vlc(void)
-{
- static volatile int done = 0;
-
- if (!done) {
- INIT_VLC_STATIC(&ff_h263_intra_MCBPC_vlc, INTRA_MCBPC_VLC_BITS, 9,
- ff_h263_intra_MCBPC_bits, 1, 1,
- ff_h263_intra_MCBPC_code, 1, 1, 72);
- INIT_VLC_STATIC(&ff_h263_inter_MCBPC_vlc, INTER_MCBPC_VLC_BITS, 28,
- ff_h263_inter_MCBPC_bits, 1, 1,
- ff_h263_inter_MCBPC_code, 1, 1, 198);
- INIT_VLC_STATIC(&ff_h263_cbpy_vlc, CBPY_VLC_BITS, 16,
- &ff_h263_cbpy_tab[0][1], 2, 1,
- &ff_h263_cbpy_tab[0][0], 2, 1, 64);
- INIT_VLC_STATIC(&mv_vlc, MV_VLC_BITS, 33,
- &ff_mvtab[0][1], 2, 1,
- &ff_mvtab[0][0], 2, 1, 538);
- ff_init_rl(&ff_h263_rl_inter, ff_h263_static_rl_table_store[0]);
- ff_init_rl(&ff_rl_intra_aic, ff_h263_static_rl_table_store[1]);
- INIT_VLC_RL(ff_h263_rl_inter, 554);
- INIT_VLC_RL(ff_rl_intra_aic, 554);
- INIT_VLC_STATIC(&h263_mbtype_b_vlc, H263_MBTYPE_B_VLC_BITS, 15,
- &ff_h263_mbtype_b_tab[0][1], 2, 1,
- &ff_h263_mbtype_b_tab[0][0], 2, 1, 80);
- INIT_VLC_STATIC(&cbpc_b_vlc, CBPC_B_VLC_BITS, 4,
- &ff_cbpc_b_tab[0][1], 2, 1,
- &ff_cbpc_b_tab[0][0], 2, 1, 8);
- done = 1;
- }
-}
-
-int ff_h263_decode_mba(MpegEncContext *s)
-{
- int i, mb_pos;
-
- for(i=0; i<6; i++){
- if(s->mb_num-1 <= ff_mba_max[i]) break;
- }
- mb_pos= get_bits(&s->gb, ff_mba_length[i]);
- s->mb_x= mb_pos % s->mb_width;
- s->mb_y= mb_pos / s->mb_width;
-
- return mb_pos;
-}
-
-/**
- * Decode the group of blocks header or slice header.
- * @return <0 if an error occurred
- */
-static int h263_decode_gob_header(MpegEncContext *s)
-{
- unsigned int val, gob_number;
- int left;
-
- /* Check for GOB Start Code */
- val = show_bits(&s->gb, 16);
- if(val)
- return -1;
-
- /* We have a GBSC probably with GSTUFF */
- skip_bits(&s->gb, 16); /* Drop the zeros */
- left= get_bits_left(&s->gb);
- //MN: we must check the bits left or we might end in a infinite loop (or segfault)
- for(;left>13; left--){
- if(get_bits1(&s->gb)) break; /* Seek the '1' bit */
- }
- if(left<=13)
- return -1;
-
- if(s->h263_slice_structured){
- if(get_bits1(&s->gb)==0)
- return -1;
-
- ff_h263_decode_mba(s);
-
- if(s->mb_num > 1583)
- if(get_bits1(&s->gb)==0)
- return -1;
-
- s->qscale = get_bits(&s->gb, 5); /* SQUANT */
- if(get_bits1(&s->gb)==0)
- return -1;
- skip_bits(&s->gb, 2); /* GFID */
- }else{
- gob_number = get_bits(&s->gb, 5); /* GN */
- s->mb_x= 0;
- s->mb_y= s->gob_index* gob_number;
- skip_bits(&s->gb, 2); /* GFID */
- s->qscale = get_bits(&s->gb, 5); /* GQUANT */
- }
-
- if(s->mb_y >= s->mb_height)
- return -1;
-
- if(s->qscale==0)
- return -1;
-
- return 0;
-}
-
-/**
- * Find the next resync_marker.
- * @param p pointer to buffer to scan
- * @param end pointer to the end of the buffer
- * @return pointer to the next resync_marker, or end if none was found
- */
-const uint8_t *ff_h263_find_resync_marker(MpegEncContext *s, const uint8_t *av_restrict p, const uint8_t *av_restrict end)
-{
- av_assert2(p < end);
-
- end-=2;
- p++;
- if(s->resync_marker){
- int prefix_len = ff_mpeg4_get_video_packet_prefix_length(s);
- for(;p<end; p+=2){
- if(!*p){
- if (!p[-1] && ((p[1] >> (23-prefix_len)) == 1)) return p - 1;
- else if (!p[ 1] && ((p[2] >> (23-prefix_len)) == 1)) return p;
- }
- }
- }
- return end+2;
-}
-
-/**
- * Decode the group of blocks / video packet header.
- * @return bit position of the resync_marker, or <0 if none was found
- */
-int ff_h263_resync(MpegEncContext *s){
- int left, pos, ret;
-
- if(s->codec_id==AV_CODEC_ID_MPEG4){
- skip_bits1(&s->gb);
- align_get_bits(&s->gb);
- }
-
- if(show_bits(&s->gb, 16)==0){
- pos= get_bits_count(&s->gb);
- if(CONFIG_MPEG4_DECODER && s->codec_id==AV_CODEC_ID_MPEG4)
- ret= ff_mpeg4_decode_video_packet_header(s);
- else
- ret= h263_decode_gob_header(s);
- if(ret>=0)
- return pos;
- }
- //OK, it's not where it is supposed to be ...
- s->gb= s->last_resync_gb;
- align_get_bits(&s->gb);
- left= get_bits_left(&s->gb);
-
- for(;left>16+1+5+5; left-=8){
- if(show_bits(&s->gb, 16)==0){
- GetBitContext bak= s->gb;
-
- pos= get_bits_count(&s->gb);
- if(CONFIG_MPEG4_DECODER && s->codec_id==AV_CODEC_ID_MPEG4)
- ret= ff_mpeg4_decode_video_packet_header(s);
- else
- ret= h263_decode_gob_header(s);
- if(ret>=0)
- return pos;
-
- s->gb= bak;
- }
- skip_bits(&s->gb, 8);
- }
-
- return -1;
-}
-
-int ff_h263_decode_motion(MpegEncContext * s, int pred, int f_code)
-{
- int code, val, sign, shift;
- code = get_vlc2(&s->gb, mv_vlc.table, MV_VLC_BITS, 2);
-
- if (code == 0)
- return pred;
- if (code < 0)
- return 0xffff;
-
- sign = get_bits1(&s->gb);
- shift = f_code - 1;
- val = code;
- if (shift) {
- val = (val - 1) << shift;
- val |= get_bits(&s->gb, shift);
- val++;
- }
- if (sign)
- val = -val;
- val += pred;
-
- /* modulo decoding */
- if (!s->h263_long_vectors) {
- val = sign_extend(val, 5 + f_code);
- } else {
- /* horrible h263 long vector mode */
- if (pred < -31 && val < -63)
- val += 64;
- if (pred > 32 && val > 63)
- val -= 64;
-
- }
- return val;
-}
-
-
-/* Decode RVLC of H.263+ UMV */
-static int h263p_decode_umotion(MpegEncContext * s, int pred)
-{
- int code = 0, sign;
-
- if (get_bits1(&s->gb)) /* Motion difference = 0 */
- return pred;
-
- code = 2 + get_bits1(&s->gb);
-
- while (get_bits1(&s->gb))
- {
- code <<= 1;
- code += get_bits1(&s->gb);
- }
- sign = code & 1;
- code >>= 1;
-
- code = (sign) ? (pred - code) : (pred + code);
- av_dlog(s->avctx,"H.263+ UMV Motion = %d\n", code);
- return code;
-
-}
-
-/**
- * read the next MVs for OBMC. yes this is a ugly hack, feel free to send a patch :)
- */
-static void preview_obmc(MpegEncContext *s){
- GetBitContext gb= s->gb;
-
- int cbpc, i, pred_x, pred_y, mx, my;
- int16_t *mot_val;
- const int xy= s->mb_x + 1 + s->mb_y * s->mb_stride;
- const int stride= s->b8_stride*2;
-
- for(i=0; i<4; i++)
- s->block_index[i]+= 2;
- for(i=4; i<6; i++)
- s->block_index[i]+= 1;
- s->mb_x++;
-
- av_assert2(s->pict_type == AV_PICTURE_TYPE_P);
-
- do{
- if (get_bits1(&s->gb)) {
- /* skip mb */
- mot_val = s->current_picture.f.motion_val[0][s->block_index[0]];
- mot_val[0 ]= mot_val[2 ]=
- mot_val[0+stride]= mot_val[2+stride]= 0;
- mot_val[1 ]= mot_val[3 ]=
- mot_val[1+stride]= mot_val[3+stride]= 0;
-
- s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
- goto end;
- }
- cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
- }while(cbpc == 20);
-
- if(cbpc & 4){
- s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA;
- }else{
- get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
- if (cbpc & 8) {
- if(s->modified_quant){
- if(get_bits1(&s->gb)) skip_bits(&s->gb, 1);
- else skip_bits(&s->gb, 5);
- }else
- skip_bits(&s->gb, 2);
- }
-
- if ((cbpc & 16) == 0) {
- s->current_picture.f.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0;
- /* 16x16 motion prediction */
- mot_val= ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
- if (s->umvplus)
- mx = h263p_decode_umotion(s, pred_x);
- else
- mx = ff_h263_decode_motion(s, pred_x, 1);
-
- if (s->umvplus)
- my = h263p_decode_umotion(s, pred_y);
- else
- my = ff_h263_decode_motion(s, pred_y, 1);
-
- mot_val[0 ]= mot_val[2 ]=
- mot_val[0+stride]= mot_val[2+stride]= mx;
- mot_val[1 ]= mot_val[3 ]=
- mot_val[1+stride]= mot_val[3+stride]= my;
- } else {
- s->current_picture.f.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_L0;
- for(i=0;i<4;i++) {
- mot_val = ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);
- if (s->umvplus)
- mx = h263p_decode_umotion(s, pred_x);
- else
- mx = ff_h263_decode_motion(s, pred_x, 1);
-
- if (s->umvplus)
- my = h263p_decode_umotion(s, pred_y);
- else
- my = ff_h263_decode_motion(s, pred_y, 1);
- if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
- skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */
- mot_val[0] = mx;
- mot_val[1] = my;
- }
- }
- }
-end:
-
- for(i=0; i<4; i++)
- s->block_index[i]-= 2;
- for(i=4; i<6; i++)
- s->block_index[i]-= 1;
- s->mb_x--;
-
- s->gb= gb;
-}
-
-static void h263_decode_dquant(MpegEncContext *s){
- static const int8_t quant_tab[4] = { -1, -2, 1, 2 };
-
- if(s->modified_quant){
- if(get_bits1(&s->gb))
- s->qscale= ff_modified_quant_tab[get_bits1(&s->gb)][ s->qscale ];
- else
- s->qscale= get_bits(&s->gb, 5);
- }else
- s->qscale += quant_tab[get_bits(&s->gb, 2)];
- ff_set_qscale(s, s->qscale);
-}
-
-static int h263_decode_block(MpegEncContext * s, int16_t * block,
- int n, int coded)
-{
- int code, level, i, j, last, run;
- RLTable *rl = &ff_h263_rl_inter;
- const uint8_t *scan_table;
- GetBitContext gb= s->gb;
-
- scan_table = s->intra_scantable.permutated;
- if (s->h263_aic && s->mb_intra) {
- rl = &ff_rl_intra_aic;
- i = 0;
- if (s->ac_pred) {
- if (s->h263_aic_dir)
- scan_table = s->intra_v_scantable.permutated; /* left */
- else
- scan_table = s->intra_h_scantable.permutated; /* top */
- }
- } else if (s->mb_intra) {
- /* DC coef */
- if(s->codec_id == AV_CODEC_ID_RV10){
-#if CONFIG_RV10_DECODER
- if (s->rv10_version == 3 && s->pict_type == AV_PICTURE_TYPE_I) {
- int component, diff;
- component = (n <= 3 ? 0 : n - 4 + 1);
- level = s->last_dc[component];
- if (s->rv10_first_dc_coded[component]) {
- diff = ff_rv_decode_dc(s, n);
- if (diff == 0xffff)
- return -1;
- level += diff;
- level = level & 0xff; /* handle wrap round */
- s->last_dc[component] = level;
- } else {
- s->rv10_first_dc_coded[component] = 1;
- }
- } else {
- level = get_bits(&s->gb, 8);
- if (level == 255)
- level = 128;
- }
-#endif
- }else{
- level = get_bits(&s->gb, 8);
- if((level&0x7F) == 0){
- av_log(s->avctx, AV_LOG_ERROR, "illegal dc %d at %d %d\n", level, s->mb_x, s->mb_y);
- if(s->err_recognition & (AV_EF_BITSTREAM|AV_EF_COMPLIANT))
- return -1;
- }
- if (level == 255)
- level = 128;
- }
- block[0] = level;
- i = 1;
- } else {
- i = 0;
- }
- if (!coded) {
- if (s->mb_intra && s->h263_aic)
- goto not_coded;
- s->block_last_index[n] = i - 1;
- return 0;
- }
-retry:
- for(;;) {
- code = get_vlc2(&s->gb, rl->vlc.table, TEX_VLC_BITS, 2);
- if (code < 0){
- av_log(s->avctx, AV_LOG_ERROR, "illegal ac vlc code at %dx%d\n", s->mb_x, s->mb_y);
- return -1;
- }
- if (code == rl->n) {
- /* escape */
- if (CONFIG_FLV_DECODER && s->h263_flv > 1) {
- ff_flv2_decode_ac_esc(&s->gb, &level, &run, &last);
- } else {
- last = get_bits1(&s->gb);
- run = get_bits(&s->gb, 6);
- level = (int8_t)get_bits(&s->gb, 8);
- if(level == -128){
- if (s->codec_id == AV_CODEC_ID_RV10) {
- /* XXX: should patch encoder too */
- level = get_sbits(&s->gb, 12);
- }else{
- level = get_bits(&s->gb, 5);
- level |= get_sbits(&s->gb, 6)<<5;
- }
- }
- }
- } else {
- run = rl->table_run[code];
- level = rl->table_level[code];
- last = code >= rl->last;
- if (get_bits1(&s->gb))
- level = -level;
- }
- i += run;
- if (i >= 64){
- if(s->alt_inter_vlc && rl == &ff_h263_rl_inter && !s->mb_intra){
- //Looks like a hack but no, it's the way it is supposed to work ...
- rl = &ff_rl_intra_aic;
- i = 0;
- s->gb= gb;
- s->dsp.clear_block(block);
- goto retry;
- }
- av_log(s->avctx, AV_LOG_ERROR, "run overflow at %dx%d i:%d\n", s->mb_x, s->mb_y, s->mb_intra);
- return -1;
- }
- j = scan_table[i];
- block[j] = level;
- if (last)
- break;
- i++;
- }
-not_coded:
- if (s->mb_intra && s->h263_aic) {
- ff_h263_pred_acdc(s, block, n);
- i = 63;
- }
- s->block_last_index[n] = i;
- return 0;
-}
-
-static int h263_skip_b_part(MpegEncContext *s, int cbp)
-{
- LOCAL_ALIGNED_16(int16_t, dblock, [64]);
- int i, mbi;
- int bli[6];
-
- /* we have to set s->mb_intra to zero to decode B-part of PB-frame correctly
- * but real value should be restored in order to be used later (in OBMC condition)
- */
- mbi = s->mb_intra;
- memcpy(bli, s->block_last_index, sizeof(bli));
- s->mb_intra = 0;
- for (i = 0; i < 6; i++) {
- if (h263_decode_block(s, dblock, i, cbp&32) < 0)
- return -1;
- cbp+=cbp;
- }
- s->mb_intra = mbi;
- memcpy(s->block_last_index, bli, sizeof(bli));
- return 0;
-}
-
-static int h263_get_modb(GetBitContext *gb, int pb_frame, int *cbpb)
-{
- int c, mv = 1;
-
- if (pb_frame < 3) { // h.263 Annex G and i263 PB-frame
- c = get_bits1(gb);
- if (pb_frame == 2 && c)
- mv = !get_bits1(gb);
- } else { // h.263 Annex M improved PB-frame
- mv = get_unary(gb, 0, 4) + 1;
- c = mv & 1;
- mv = !!(mv & 2);
- }
- if(c)
- *cbpb = get_bits(gb, 6);
- return mv;
-}
-
-int ff_h263_decode_mb(MpegEncContext *s,
- int16_t block[6][64])
-{
- int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant;
- int16_t *mot_val;
- const int xy= s->mb_x + s->mb_y * s->mb_stride;
- int cbpb = 0, pb_mv_count = 0;
-
- av_assert2(!s->h263_pred);
-
- if (s->pict_type == AV_PICTURE_TYPE_P) {
- do{
- if (get_bits1(&s->gb)) {
- /* skip mb */
- s->mb_intra = 0;
- for(i=0;i<6;i++)
- s->block_last_index[i] = -1;
- s->mv_dir = MV_DIR_FORWARD;
- s->mv_type = MV_TYPE_16X16;
- s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
- s->mv[0][0][0] = 0;
- s->mv[0][0][1] = 0;
- s->mb_skipped = !(s->obmc | s->loop_filter);
- goto end;
- }
- 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);
- return -1;
- }
- }while(cbpc == 20);
-
- s->dsp.clear_blocks(s->block[0]);
-
- dquant = cbpc & 8;
- s->mb_intra = ((cbpc & 4) != 0);
- if (s->mb_intra) goto intra;
-
- if(s->pb_frame && get_bits1(&s->gb))
- pb_mv_count = h263_get_modb(&s->gb, s->pb_frame, &cbpb);
- cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
-
- if(s->alt_inter_vlc==0 || (cbpc & 3)!=3)
- cbpy ^= 0xF;
-
- cbp = (cbpc & 3) | (cbpy << 2);
- if (dquant) {
- h263_decode_dquant(s);
- }
-
- s->mv_dir = MV_DIR_FORWARD;
- if ((cbpc & 16) == 0) {
- s->current_picture.f.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0;
- /* 16x16 motion prediction */
- s->mv_type = MV_TYPE_16X16;
- ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
- if (s->umvplus)
- mx = h263p_decode_umotion(s, pred_x);
- else
- mx = ff_h263_decode_motion(s, pred_x, 1);
-
- if (mx >= 0xffff)
- return -1;
-
- if (s->umvplus)
- my = h263p_decode_umotion(s, pred_y);
- else
- my = ff_h263_decode_motion(s, pred_y, 1);
-
- if (my >= 0xffff)
- return -1;
- s->mv[0][0][0] = mx;
- s->mv[0][0][1] = my;
-
- if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
- skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */
- } else {
- s->current_picture.f.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_L0;
- s->mv_type = MV_TYPE_8X8;
- for(i=0;i<4;i++) {
- mot_val = ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);
- if (s->umvplus)
- mx = h263p_decode_umotion(s, pred_x);
- else
- mx = ff_h263_decode_motion(s, pred_x, 1);
- if (mx >= 0xffff)
- return -1;
-
- if (s->umvplus)
- my = h263p_decode_umotion(s, pred_y);
- else
- my = ff_h263_decode_motion(s, pred_y, 1);
- if (my >= 0xffff)
- return -1;
- s->mv[0][i][0] = mx;
- s->mv[0][i][1] = my;
- if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
- skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */
- mot_val[0] = mx;
- mot_val[1] = my;
- }
- }
- } else if(s->pict_type==AV_PICTURE_TYPE_B) {
- int mb_type;
- const int stride= s->b8_stride;
- int16_t *mot_val0 = s->current_picture.f.motion_val[0][2 * (s->mb_x + s->mb_y * stride)];
- int16_t *mot_val1 = s->current_picture.f.motion_val[1][2 * (s->mb_x + s->mb_y * stride)];
-// const int mv_xy= s->mb_x + 1 + s->mb_y * s->mb_stride;
-
- //FIXME ugly
- mot_val0[0 ]= mot_val0[2 ]= mot_val0[0+2*stride]= mot_val0[2+2*stride]=
- mot_val0[1 ]= mot_val0[3 ]= mot_val0[1+2*stride]= mot_val0[3+2*stride]=
- mot_val1[0 ]= mot_val1[2 ]= mot_val1[0+2*stride]= mot_val1[2+2*stride]=
- mot_val1[1 ]= mot_val1[3 ]= mot_val1[1+2*stride]= mot_val1[3+2*stride]= 0;
-
- do{
- mb_type= get_vlc2(&s->gb, h263_mbtype_b_vlc.table, H263_MBTYPE_B_VLC_BITS, 2);
- if (mb_type < 0){
- av_log(s->avctx, AV_LOG_ERROR, "b mb_type damaged at %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
-
- mb_type= h263_mb_type_b_map[ mb_type ];
- }while(!mb_type);
-
- s->mb_intra = IS_INTRA(mb_type);
- if(HAS_CBP(mb_type)){
- s->dsp.clear_blocks(s->block[0]);
- cbpc = get_vlc2(&s->gb, cbpc_b_vlc.table, CBPC_B_VLC_BITS, 1);
- if(s->mb_intra){
- dquant = IS_QUANT(mb_type);
- goto intra;
- }
-
- cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
-
- if (cbpy < 0){
- av_log(s->avctx, AV_LOG_ERROR, "b cbpy damaged at %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
-
- if(s->alt_inter_vlc==0 || (cbpc & 3)!=3)
- cbpy ^= 0xF;
-
- cbp = (cbpc & 3) | (cbpy << 2);
- }else
- cbp=0;
-
- av_assert2(!s->mb_intra);
-
- if(IS_QUANT(mb_type)){
- h263_decode_dquant(s);
- }
-
- if(IS_DIRECT(mb_type)){
- s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
- mb_type |= ff_mpeg4_set_direct_mv(s, 0, 0);
- }else{
- s->mv_dir = 0;
- s->mv_type= MV_TYPE_16X16;
-//FIXME UMV
-
- if(USES_LIST(mb_type, 0)){
- int16_t *mot_val= ff_h263_pred_motion(s, 0, 0, &mx, &my);
- s->mv_dir = MV_DIR_FORWARD;
-
- mx = ff_h263_decode_motion(s, mx, 1);
- my = ff_h263_decode_motion(s, my, 1);
-
- s->mv[0][0][0] = mx;
- s->mv[0][0][1] = my;
- mot_val[0 ]= mot_val[2 ]= mot_val[0+2*stride]= mot_val[2+2*stride]= mx;
- mot_val[1 ]= mot_val[3 ]= mot_val[1+2*stride]= mot_val[3+2*stride]= my;
- }
-
- if(USES_LIST(mb_type, 1)){
- int16_t *mot_val= ff_h263_pred_motion(s, 0, 1, &mx, &my);
- s->mv_dir |= MV_DIR_BACKWARD;
-
- mx = ff_h263_decode_motion(s, mx, 1);
- my = ff_h263_decode_motion(s, my, 1);
-
- s->mv[1][0][0] = mx;
- s->mv[1][0][1] = my;
- mot_val[0 ]= mot_val[2 ]= mot_val[0+2*stride]= mot_val[2+2*stride]= mx;
- mot_val[1 ]= mot_val[3 ]= mot_val[1+2*stride]= mot_val[3+2*stride]= my;
- }
- }
-
- s->current_picture.f.mb_type[xy] = mb_type;
- } else { /* I-Frame */
- do{
- 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, "I cbpc damaged at %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
- }while(cbpc == 8);
-
- s->dsp.clear_blocks(s->block[0]);
-
- dquant = cbpc & 4;
- s->mb_intra = 1;
-intra:
- s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA;
- if (s->h263_aic) {
- s->ac_pred = get_bits1(&s->gb);
- if(s->ac_pred){
- s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA | MB_TYPE_ACPRED;
-
- s->h263_aic_dir = get_bits1(&s->gb);
- }
- }else
- s->ac_pred = 0;
-
- if(s->pb_frame && get_bits1(&s->gb))
- pb_mv_count = h263_get_modb(&s->gb, s->pb_frame, &cbpb);
- cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
- if(cbpy<0){
- av_log(s->avctx, AV_LOG_ERROR, "I cbpy damaged at %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
- cbp = (cbpc & 3) | (cbpy << 2);
- if (dquant) {
- h263_decode_dquant(s);
- }
-
- pb_mv_count += !!s->pb_frame;
- }
-
- while(pb_mv_count--){
- ff_h263_decode_motion(s, 0, 1);
- ff_h263_decode_motion(s, 0, 1);
- }
-
- /* decode each block */
- for (i = 0; i < 6; i++) {
- if (h263_decode_block(s, block[i], i, cbp&32) < 0)
- return -1;
- cbp+=cbp;
- }
-
- if(s->pb_frame && h263_skip_b_part(s, cbpb) < 0)
- return -1;
- if(s->obmc && !s->mb_intra){
- if(s->pict_type == AV_PICTURE_TYPE_P && s->mb_x+1<s->mb_width && s->mb_num_left != 1)
- preview_obmc(s);
- }
-end:
-
- /* per-MB end of slice check */
- {
- int v= show_bits(&s->gb, 16);
-
- if (get_bits_left(&s->gb) < 16) {
- v >>= 16 - get_bits_left(&s->gb);
- }
-
- if(v==0)
- return SLICE_END;
- }
-
- return SLICE_OK;
-}
-
-/* most is hardcoded. should extend to handle all h263 streams */
-int ff_h263_decode_picture_header(MpegEncContext *s)
-{
- int format, width, height, i;
- uint32_t startcode;
-
- align_get_bits(&s->gb);
-
- startcode= get_bits(&s->gb, 22-8);
-
- for(i= get_bits_left(&s->gb); i>24; i-=8) {
- startcode = ((startcode << 8) | get_bits(&s->gb, 8)) & 0x003FFFFF;
-
- if(startcode == 0x20)
- break;
- }
-
- if (startcode != 0x20) {
- av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
- return -1;
- }
- /* temporal reference */
- i = get_bits(&s->gb, 8); /* picture timestamp */
- if( (s->picture_number&~0xFF)+i < s->picture_number)
- i+= 256;
- s->current_picture_ptr->f.pts =
- s->picture_number= (s->picture_number&~0xFF) + i;
-
- /* PTYPE starts here */
- if (get_bits1(&s->gb) != 1) {
- /* marker */
- av_log(s->avctx, AV_LOG_ERROR, "Bad marker\n");
- return -1;
- }
- if (get_bits1(&s->gb) != 0) {
- av_log(s->avctx, AV_LOG_ERROR, "Bad H263 id\n");
- return -1; /* h263 id */
- }
- skip_bits1(&s->gb); /* split screen off */
- skip_bits1(&s->gb); /* camera off */
- skip_bits1(&s->gb); /* freeze picture release off */
-
- format = get_bits(&s->gb, 3);
- /*
- 0 forbidden
- 1 sub-QCIF
- 10 QCIF
- 7 extended PTYPE (PLUSPTYPE)
- */
-
- if (format != 7 && format != 6) {
- s->h263_plus = 0;
- /* H.263v1 */
- width = ff_h263_format[format][0];
- height = ff_h263_format[format][1];
- if (!width)
- return -1;
-
- s->pict_type = AV_PICTURE_TYPE_I + get_bits1(&s->gb);
-
- s->h263_long_vectors = get_bits1(&s->gb);
-
- if (get_bits1(&s->gb) != 0) {
- av_log(s->avctx, AV_LOG_ERROR, "H263 SAC not supported\n");
- return -1; /* SAC: off */
- }
- s->obmc= get_bits1(&s->gb); /* Advanced prediction mode */
- s->unrestricted_mv = s->h263_long_vectors || s->obmc;
-
- s->pb_frame = get_bits1(&s->gb);
- s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
- skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */
-
- s->width = width;
- s->height = height;
- s->avctx->sample_aspect_ratio= (AVRational){12,11};
- s->avctx->time_base= (AVRational){1001, 30000};
- } else {
- int ufep;
-
- /* H.263v2 */
- s->h263_plus = 1;
- ufep = get_bits(&s->gb, 3); /* Update Full Extended PTYPE */
-
- /* ufep other than 0 and 1 are reserved */
- if (ufep == 1) {
- /* OPPTYPE */
- format = get_bits(&s->gb, 3);
- av_dlog(s->avctx, "ufep=1, format: %d\n", format);
- s->custom_pcf= get_bits1(&s->gb);
- s->umvplus = get_bits1(&s->gb); /* Unrestricted Motion Vector */
- if (get_bits1(&s->gb) != 0) {
- av_log(s->avctx, AV_LOG_ERROR, "Syntax-based Arithmetic Coding (SAC) not supported\n");
- }
- s->obmc= get_bits1(&s->gb); /* Advanced prediction mode */
- s->h263_aic = get_bits1(&s->gb); /* Advanced Intra Coding (AIC) */
- s->loop_filter= get_bits1(&s->gb);
- s->unrestricted_mv = s->umvplus || s->obmc || s->loop_filter;
- if(s->avctx->lowres)
- s->loop_filter = 0;
-
- s->h263_slice_structured= get_bits1(&s->gb);
- if (get_bits1(&s->gb) != 0) {
- av_log(s->avctx, AV_LOG_ERROR, "Reference Picture Selection not supported\n");
- }
- if (get_bits1(&s->gb) != 0) {
- av_log(s->avctx, AV_LOG_ERROR, "Independent Segment Decoding not supported\n");
- }
- s->alt_inter_vlc= get_bits1(&s->gb);
- s->modified_quant= get_bits1(&s->gb);
- if(s->modified_quant)
- s->chroma_qscale_table= ff_h263_chroma_qscale_table;
-
- skip_bits(&s->gb, 1); /* Prevent start code emulation */
-
- skip_bits(&s->gb, 3); /* Reserved */
- } else if (ufep != 0) {
- av_log(s->avctx, AV_LOG_ERROR, "Bad UFEP type (%d)\n", ufep);
- return -1;
- }
-
- /* MPPTYPE */
- s->pict_type = get_bits(&s->gb, 3);
- switch(s->pict_type){
- case 0: s->pict_type= AV_PICTURE_TYPE_I;break;
- case 1: s->pict_type= AV_PICTURE_TYPE_P;break;
- case 2: s->pict_type= AV_PICTURE_TYPE_P;s->pb_frame = 3;break;
- case 3: s->pict_type= AV_PICTURE_TYPE_B;break;
- case 7: s->pict_type= AV_PICTURE_TYPE_I;break; //ZYGO
- default:
- return -1;
- }
- skip_bits(&s->gb, 2);
- s->no_rounding = get_bits1(&s->gb);
- skip_bits(&s->gb, 4);
-
- /* Get the picture dimensions */
- if (ufep) {
- if (format == 6) {
- /* Custom Picture Format (CPFMT) */
- s->aspect_ratio_info = get_bits(&s->gb, 4);
- av_dlog(s->avctx, "aspect: %d\n", s->aspect_ratio_info);
- /* aspect ratios:
- 0 - forbidden
- 1 - 1:1
- 2 - 12:11 (CIF 4:3)
- 3 - 10:11 (525-type 4:3)
- 4 - 16:11 (CIF 16:9)
- 5 - 40:33 (525-type 16:9)
- 6-14 - reserved
- */
- width = (get_bits(&s->gb, 9) + 1) * 4;
- skip_bits1(&s->gb);
- height = get_bits(&s->gb, 9) * 4;
- av_dlog(s->avctx, "\nH.263+ Custom picture: %dx%d\n",width,height);
- if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) {
- /* aspected dimensions */
- s->avctx->sample_aspect_ratio.num= get_bits(&s->gb, 8);
- s->avctx->sample_aspect_ratio.den= get_bits(&s->gb, 8);
- }else{
- s->avctx->sample_aspect_ratio= ff_h263_pixel_aspect[s->aspect_ratio_info];
- }
- } else {
- width = ff_h263_format[format][0];
- height = ff_h263_format[format][1];
- s->avctx->sample_aspect_ratio= (AVRational){12,11};
- }
- if ((width == 0) || (height == 0))
- return -1;
- s->width = width;
- s->height = height;
-
- if(s->custom_pcf){
- int gcd;
- s->avctx->time_base.den= 1800000;
- s->avctx->time_base.num= 1000 + get_bits1(&s->gb);
- s->avctx->time_base.num*= get_bits(&s->gb, 7);
- if(s->avctx->time_base.num == 0){
- av_log(s, AV_LOG_ERROR, "zero framerate\n");
- return -1;
- }
- gcd= av_gcd(s->avctx->time_base.den, s->avctx->time_base.num);
- s->avctx->time_base.den /= gcd;
- s->avctx->time_base.num /= gcd;
- }else{
- s->avctx->time_base= (AVRational){1001, 30000};
- }
- }
-
- if(s->custom_pcf){
- skip_bits(&s->gb, 2); //extended Temporal reference
- }
-
- if (ufep) {
- if (s->umvplus) {
- if(get_bits1(&s->gb)==0) /* Unlimited Unrestricted Motion Vectors Indicator (UUI) */
- skip_bits1(&s->gb);
- }
- if(s->h263_slice_structured){
- if (get_bits1(&s->gb) != 0) {
- av_log(s->avctx, AV_LOG_ERROR, "rectangular slices not supported\n");
- }
- if (get_bits1(&s->gb) != 0) {
- av_log(s->avctx, AV_LOG_ERROR, "unordered slices not supported\n");
- }
- }
- }
-
- s->qscale = get_bits(&s->gb, 5);
- }
-
- if (s->width == 0 || s->height == 0) {
- av_log(s->avctx, AV_LOG_ERROR, "dimensions 0\n");
- return -1;
- }
- s->mb_width = (s->width + 15) / 16;
- s->mb_height = (s->height + 15) / 16;
- s->mb_num = s->mb_width * s->mb_height;
-
- if (s->pb_frame) {
- skip_bits(&s->gb, 3); /* Temporal reference for B-pictures */
- if (s->custom_pcf)
- skip_bits(&s->gb, 2); //extended Temporal reference
- skip_bits(&s->gb, 2); /* Quantization information for B-pictures */
- }
-
- if (s->pict_type!=AV_PICTURE_TYPE_B) {
- s->time = s->picture_number;
- s->pp_time = s->time - s->last_non_b_time;
- s->last_non_b_time = s->time;
- }else{
- s->time = s->picture_number;
- s->pb_time = s->pp_time - (s->last_non_b_time - s->time);
- if (s->pp_time <=s->pb_time ||
- s->pp_time <= s->pp_time - s->pb_time ||
- s->pp_time <= 0){
- s->pp_time = 2;
- s->pb_time = 1;
- }
- ff_mpeg4_init_direct_mv(s);
- }
-
- /* PEI */
- while (get_bits1(&s->gb) != 0) {
- skip_bits(&s->gb, 8);
- }
-
- if(s->h263_slice_structured){
- if (get_bits1(&s->gb) != 1) {
- av_log(s->avctx, AV_LOG_ERROR, "SEPB1 marker missing\n");
- return -1;
- }
-
- ff_h263_decode_mba(s);
-
- if (get_bits1(&s->gb) != 1) {
- av_log(s->avctx, AV_LOG_ERROR, "SEPB2 marker missing\n");
- return -1;
- }
- }
- s->f_code = 1;
-
- if(s->h263_aic){
- 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;
- }
-
- ff_h263_show_pict_info(s);
- if (s->pict_type == AV_PICTURE_TYPE_I && s->codec_tag == AV_RL32("ZYGO") && get_bits_left(&s->gb) >= 85 + 13*3*16 + 50){
- int i,j;
- for(i=0; i<85; i++) av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&s->gb));
- av_log(s->avctx, AV_LOG_DEBUG, "\n");
- for(i=0; i<13; i++){
- for(j=0; j<3; j++){
- int v= get_bits(&s->gb, 8);
- v |= get_sbits(&s->gb, 8)<<8;
- av_log(s->avctx, AV_LOG_DEBUG, " %5d", v);
- }
- av_log(s->avctx, AV_LOG_DEBUG, "\n");
- }
- for(i=0; i<50; i++) av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&s->gb));
- }
-
- return 0;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/ivi_common.c b/src/thirdparty/ffmpeg/libavcodec/ivi_common.c
deleted file mode 100644
index db09329f2..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/ivi_common.c
+++ /dev/null
@@ -1,1384 +0,0 @@
-/*
- * common functions for Indeo Video Interactive codecs (Indeo4 and Indeo5)
- *
- * Copyright (c) 2009 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
- * This file contains functions and data shared by both Indeo4 and
- * Indeo5 decoders.
- */
-
-#define BITSTREAM_READER_LE
-#include "libavutil/attributes.h"
-#include "avcodec.h"
-#include "get_bits.h"
-#include "internal.h"
-#include "mathops.h"
-#include "ivi_common.h"
-#include "ivi_dsp.h"
-
-extern const IVIHuffDesc ff_ivi_mb_huff_desc[8]; ///< static macroblock huffman tables
-extern const IVIHuffDesc ff_ivi_blk_huff_desc[8]; ///< static block huffman tables
-
-static VLC ivi_mb_vlc_tabs [8]; ///< static macroblock Huffman tables
-static VLC ivi_blk_vlc_tabs[8]; ///< static block Huffman tables
-
-/**
- * Reverse "nbits" bits of the value "val" and return the result
- * in the least significant bits.
- */
-static uint16_t inv_bits(uint16_t val, int nbits)
-{
- uint16_t res;
-
- if (nbits <= 8) {
- res = ff_reverse[val] >> (8-nbits);
- } else
- res = ((ff_reverse[val & 0xFF] << 8) + (ff_reverse[val >> 8])) >> (16-nbits);
-
- return res;
-}
-
-/*
- * Generate a huffman codebook from the given descriptor
- * and convert it into the FFmpeg VLC table.
- *
- * @param[in] cb pointer to codebook descriptor
- * @param[out] vlc where to place the generated VLC table
- * @param[in] flag flag: 1 - for static or 0 for dynamic tables
- * @return result code: 0 - OK, -1 = error (invalid codebook descriptor)
- */
-static int ivi_create_huff_from_desc(const IVIHuffDesc *cb, VLC *vlc, int flag)
-{
- int pos, i, j, codes_per_row, prefix, not_last_row;
- uint16_t codewords[256]; /* FIXME: move this temporal storage out? */
- uint8_t bits[256];
-
- pos = 0; /* current position = 0 */
-
- for (i = 0; i < cb->num_rows; i++) {
- codes_per_row = 1 << cb->xbits[i];
- not_last_row = (i != cb->num_rows - 1);
- prefix = ((1 << i) - 1) << (cb->xbits[i] + not_last_row);
-
- for (j = 0; j < codes_per_row; j++) {
- if (pos >= 256) /* Some Indeo5 codebooks can have more than 256 */
- break; /* elements, but only 256 codes are allowed! */
-
- bits[pos] = i + cb->xbits[i] + not_last_row;
- if (bits[pos] > IVI_VLC_BITS)
- return -1; /* invalid descriptor */
-
- codewords[pos] = inv_bits((prefix | j), bits[pos]);
- if (!bits[pos])
- bits[pos] = 1;
-
- pos++;
- }//for j
- }//for i
-
- /* number of codewords = pos */
- return init_vlc(vlc, IVI_VLC_BITS, pos, bits, 1, 1, codewords, 2, 2,
- (flag ? INIT_VLC_USE_NEW_STATIC : 0) | INIT_VLC_LE);
-}
-
-void ff_ivi_init_static_vlc(void)
-{
- int i;
- static VLC_TYPE table_data[8192 * 16][2];
- static int initialized_vlcs = 0;
-
- if (initialized_vlcs)
- return;
- for (i = 0; i < 8; i++) {
- ivi_mb_vlc_tabs[i].table = table_data + i * 2 * 8192;
- ivi_mb_vlc_tabs[i].table_allocated = 8192;
- ivi_create_huff_from_desc(&ff_ivi_mb_huff_desc[i], &ivi_mb_vlc_tabs[i], 1);
- ivi_blk_vlc_tabs[i].table = table_data + (i * 2 + 1) * 8192;
- ivi_blk_vlc_tabs[i].table_allocated = 8192;
- ivi_create_huff_from_desc(&ff_ivi_blk_huff_desc[i], &ivi_blk_vlc_tabs[i], 1);
- }
- initialized_vlcs = 1;
-}
-
-/*
- * Copy huffman codebook descriptors.
- *
- * @param[out] dst ptr to the destination descriptor
- * @param[in] src ptr to the source descriptor
- */
-static void ivi_huff_desc_copy(IVIHuffDesc *dst, const IVIHuffDesc *src)
-{
- dst->num_rows = src->num_rows;
- memcpy(dst->xbits, src->xbits, src->num_rows);
-}
-
-/*
- * Compare two huffman codebook descriptors.
- *
- * @param[in] desc1 ptr to the 1st descriptor to compare
- * @param[in] desc2 ptr to the 2nd descriptor to compare
- * @return comparison result: 0 - equal, 1 - not equal
- */
-static int ivi_huff_desc_cmp(const IVIHuffDesc *desc1, const IVIHuffDesc *desc2)
-{
- return desc1->num_rows != desc2->num_rows
- || memcmp(desc1->xbits, desc2->xbits, desc1->num_rows);
-}
-
-int ff_ivi_dec_huff_desc(GetBitContext *gb, int desc_coded, int which_tab,
- IVIHuffTab *huff_tab, AVCodecContext *avctx)
-{
- int i, result;
- IVIHuffDesc new_huff;
-
- if (!desc_coded) {
- /* select default table */
- huff_tab->tab = (which_tab) ? &ivi_blk_vlc_tabs[7]
- : &ivi_mb_vlc_tabs [7];
- } else {
- huff_tab->tab_sel = get_bits(gb, 3);
- if (huff_tab->tab_sel == 7) {
- /* custom huffman table (explicitly encoded) */
- new_huff.num_rows = get_bits(gb, 4);
- if (!new_huff.num_rows) {
- av_log(avctx, AV_LOG_ERROR, "Empty custom Huffman table!\n");
- return AVERROR_INVALIDDATA;
- }
-
- for (i = 0; i < new_huff.num_rows; i++)
- new_huff.xbits[i] = get_bits(gb, 4);
-
- /* Have we got the same custom table? Rebuild if not. */
- if (ivi_huff_desc_cmp(&new_huff, &huff_tab->cust_desc) || !huff_tab->cust_tab.table) {
- ivi_huff_desc_copy(&huff_tab->cust_desc, &new_huff);
-
- if (huff_tab->cust_tab.table)
- ff_free_vlc(&huff_tab->cust_tab);
- result = ivi_create_huff_from_desc(&huff_tab->cust_desc,
- &huff_tab->cust_tab, 0);
- if (result) {
- huff_tab->cust_desc.num_rows = 0; // reset faulty description
- av_log(avctx, AV_LOG_ERROR,
- "Error while initializing custom vlc table!\n");
- return result;
- }
- }
- huff_tab->tab = &huff_tab->cust_tab;
- } else {
- /* select one of predefined tables */
- huff_tab->tab = (which_tab) ? &ivi_blk_vlc_tabs[huff_tab->tab_sel]
- : &ivi_mb_vlc_tabs [huff_tab->tab_sel];
- }
- }
-
- return 0;
-}
-
-/*
- * Free planes, bands and macroblocks buffers.
- *
- * @param[in] planes pointer to the array of the plane descriptors
- */
-static av_cold void ivi_free_buffers(IVIPlaneDesc *planes)
-{
- int p, b, t;
-
- for (p = 0; p < 3; p++) {
- if (planes[p].bands)
- for (b = 0; b < planes[p].num_bands; b++) {
- av_freep(&planes[p].bands[b].bufs[0]);
- av_freep(&planes[p].bands[b].bufs[1]);
- av_freep(&planes[p].bands[b].bufs[2]);
-
- if (planes[p].bands[b].blk_vlc.cust_tab.table)
- ff_free_vlc(&planes[p].bands[b].blk_vlc.cust_tab);
- for (t = 0; t < planes[p].bands[b].num_tiles; t++)
- av_freep(&planes[p].bands[b].tiles[t].mbs);
- av_freep(&planes[p].bands[b].tiles);
- }
- av_freep(&planes[p].bands);
- }
-}
-
-av_cold int ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg)
-{
- int p, b;
- uint32_t b_width, b_height, align_fac, width_aligned, height_aligned, buf_size;
- IVIBandDesc *band;
-
- ivi_free_buffers(planes);
-
- /* fill in the descriptor of the luminance plane */
- planes[0].width = cfg->pic_width;
- planes[0].height = cfg->pic_height;
- planes[0].num_bands = cfg->luma_bands;
-
- /* fill in the descriptors of the chrominance planes */
- planes[1].width = planes[2].width = (cfg->pic_width + 3) >> 2;
- planes[1].height = planes[2].height = (cfg->pic_height + 3) >> 2;
- 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));
- if (!planes[p].bands)
- return AVERROR(ENOMEM);
-
- /* select band dimensions: if there is only one band then it
- * has the full size, if there are several bands each of them
- * has only half size */
- b_width = planes[p].num_bands == 1 ? planes[p].width : (planes[p].width + 1) >> 1;
- b_height = planes[p].num_bands == 1 ? planes[p].height : (planes[p].height + 1) >> 1;
-
- /* luma band buffers will be aligned on 16x16 (max macroblock size) */
- /* chroma band buffers will be aligned on 8x8 (max macroblock size) */
- align_fac = p ? 8 : 16;
- width_aligned = FFALIGN(b_width , align_fac);
- height_aligned = FFALIGN(b_height, align_fac);
- buf_size = width_aligned * height_aligned * sizeof(int16_t);
-
- for (b = 0; b < planes[p].num_bands; b++) {
- band = &planes[p].bands[b]; /* select appropriate plane/band */
- band->plane = p;
- band->band_num = b;
- band->width = b_width;
- band->height = b_height;
- band->pitch = width_aligned;
- band->aheight = height_aligned;
- band->bufs[0] = av_mallocz(buf_size);
- band->bufs[1] = av_mallocz(buf_size);
- band->bufsize = buf_size/2;
- if (!band->bufs[0] || !band->bufs[1])
- return AVERROR(ENOMEM);
-
- /* allocate the 3rd band buffer for scalability mode */
- if (cfg->luma_bands > 1) {
- band->bufs[2] = av_mallocz(buf_size);
- if (!band->bufs[2])
- return AVERROR(ENOMEM);
- }
-
- planes[p].bands[0].blk_vlc.cust_desc.num_rows = 0; /* reset custom vlc */
- }
- }
-
- return 0;
-}
-
-av_cold int ff_ivi_init_tiles(IVIPlaneDesc *planes, int tile_width, int tile_height)
-{
- int p, b, x, y, x_tiles, y_tiles, t_width, t_height;
- IVIBandDesc *band;
- IVITile *tile, *ref_tile;
-
- for (p = 0; p < 3; p++) {
- t_width = !p ? tile_width : (tile_width + 3) >> 2;
- t_height = !p ? tile_height : (tile_height + 3) >> 2;
-
- if (!p && planes[0].num_bands == 4) {
- t_width >>= 1;
- t_height >>= 1;
- }
- if(t_width<=0 || t_height<=0)
- return AVERROR(EINVAL);
-
- for (b = 0; b < planes[p].num_bands; b++) {
- band = &planes[p].bands[b];
- x_tiles = IVI_NUM_TILES(band->width, t_width);
- y_tiles = IVI_NUM_TILES(band->height, t_height);
- band->num_tiles = x_tiles * y_tiles;
-
- av_freep(&band->tiles);
- band->tiles = av_mallocz(band->num_tiles * sizeof(IVITile));
- if (!band->tiles)
- return AVERROR(ENOMEM);
-
- tile = band->tiles;
-
- /* use the first luma band as reference for motion vectors
- * and quant */
- ref_tile = planes[0].bands[0].tiles;
-
- for (y = 0; y < band->height; y += t_height) {
- for (x = 0; x < band->width; x += t_width) {
- tile->xpos = x;
- tile->ypos = y;
- tile->mb_size = band->mb_size;
- tile->width = FFMIN(band->width - x, t_width);
- tile->height = FFMIN(band->height - y, t_height);
- tile->is_empty = tile->data_size = 0;
- /* calculate number of macroblocks */
- tile->num_MBs = IVI_MBs_PER_TILE(tile->width, tile->height,
- band->mb_size);
-
- av_freep(&tile->mbs);
- tile->mbs = av_malloc(tile->num_MBs * sizeof(IVIMbInfo));
- if (!tile->mbs)
- return AVERROR(ENOMEM);
-
- tile->ref_mbs = 0;
- if (p || b) {
- if (tile->num_MBs <= ref_tile->num_MBs) {
- tile->ref_mbs = ref_tile->mbs;
- }else
- av_log(NULL, AV_LOG_DEBUG, "Cannot use ref_tile, too few mbs\n");
- ref_tile++;
- }
-
- tile++;
- }
- }
-
- }// for b
- }// for p
-
- return 0;
-}
-
-/*
- * Decode size of the tile data.
- * The size is stored as a variable-length field having the following format:
- * if (tile_data_size < 255) than this field is only one byte long
- * if (tile_data_size >= 255) than this field four is byte long: 0xFF X1 X2 X3
- * where X1-X3 is size of the tile data
- *
- * @param[in,out] gb the GetBit context
- * @return size of the tile data in bytes
- */
-static int ivi_dec_tile_data_size(GetBitContext *gb)
-{
- int len;
-
- len = 0;
- if (get_bits1(gb)) {
- len = get_bits(gb, 8);
- if (len == 255)
- len = get_bits_long(gb, 24);
- }
-
- /* align the bitstream reader on the byte boundary */
- align_get_bits(gb);
-
- return len;
-}
-
-/*
- * Decode block data:
- * extract huffman-coded transform coefficients from the bitstream,
- * dequantize them, apply inverse transform and motion compensation
- * in order to reconstruct the picture.
- *
- * @param[in,out] gb the GetBit context
- * @param[in] band pointer to the band descriptor
- * @param[in] tile pointer to the tile descriptor
- * @return result code: 0 - OK, -1 = error (corrupted blocks data)
- */
-static int ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile,
- AVCodecContext *avctx)
-{
- int mbn, blk, num_blocks, num_coeffs, blk_size, scan_pos, run, val,
- pos, is_intra, mc_type = 0, av_uninit(mv_x), av_uninit(mv_y), col_mask;
- uint8_t col_flags[8];
- int32_t prev_dc, trvec[64];
- uint32_t cbp, av_uninit(sym), lo, hi, quant, buf_offs, q;
- IVIMbInfo *mb;
- RVMapDesc *rvmap = band->rv_map;
- void (*mc_with_delta_func)(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type);
- void (*mc_no_delta_func) (int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type);
- const uint16_t *base_tab;
- const uint8_t *scale_tab;
-
- prev_dc = 0; /* init intra prediction for the DC coefficient */
-
- blk_size = band->blk_size;
- col_mask = blk_size - 1; /* column mask for tracking non-zero coeffs */
- num_blocks = (band->mb_size != blk_size) ? 4 : 1; /* number of blocks per mb */
- num_coeffs = blk_size * blk_size;
- if (blk_size == 8) {
- mc_with_delta_func = ff_ivi_mc_8x8_delta;
- mc_no_delta_func = ff_ivi_mc_8x8_no_delta;
- } else {
- mc_with_delta_func = ff_ivi_mc_4x4_delta;
- mc_no_delta_func = ff_ivi_mc_4x4_no_delta;
- }
-
- for (mbn = 0, mb = tile->mbs; mbn < tile->num_MBs; mb++, mbn++) {
- is_intra = !mb->type;
- cbp = mb->cbp;
- buf_offs = mb->buf_offs;
-
- quant = av_clip(band->glob_quant + mb->q_delta, 0, 23);
-
- base_tab = is_intra ? band->intra_base : band->inter_base;
- scale_tab = is_intra ? band->intra_scale : band->inter_scale;
- if (scale_tab)
- quant = scale_tab[quant];
-
- if (!is_intra) {
- mv_x = mb->mv_x;
- mv_y = mb->mv_y;
- if (band->is_halfpel) {
- mc_type = ((mv_y & 1) << 1) | (mv_x & 1);
- mv_x >>= 1;
- mv_y >>= 1; /* convert halfpel vectors into fullpel ones */
- }
- if (mb->type) {
- int dmv_x, dmv_y, cx, cy;
-
- dmv_x = mb->mv_x >> band->is_halfpel;
- dmv_y = mb->mv_y >> band->is_halfpel;
- cx = mb->mv_x & band->is_halfpel;
- cy = mb->mv_y & band->is_halfpel;
-
- if ( mb->xpos + dmv_x < 0
- || mb->xpos + dmv_x + band->mb_size + cx > band->pitch
- || mb->ypos + dmv_y < 0
- || mb->ypos + dmv_y + band->mb_size + cy > band->aheight) {
- return AVERROR_INVALIDDATA;
- }
- }
- }
-
- for (blk = 0; blk < num_blocks; blk++) {
- /* adjust block position in the buffer according to its number */
- if (blk & 1) {
- buf_offs += blk_size;
- } else if (blk == 2) {
- buf_offs -= blk_size;
- buf_offs += blk_size * band->pitch;
- }
-
- if (cbp & 1) { /* block coded ? */
- if (!band->scan) {
- av_log(avctx, AV_LOG_ERROR, "Scan pattern is not set.\n");
- return AVERROR_INVALIDDATA;
- }
-
- scan_pos = -1;
- memset(trvec, 0, num_coeffs*sizeof(trvec[0])); /* zero transform vector */
- memset(col_flags, 0, sizeof(col_flags)); /* zero column flags */
-
- while (scan_pos <= num_coeffs) {
- sym = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1);
- if (sym == rvmap->eob_sym)
- break; /* End of block */
-
- if (sym == rvmap->esc_sym) { /* Escape - run/val explicitly coded using 3 vlc codes */
- run = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1) + 1;
- lo = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1);
- hi = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1);
- val = IVI_TOSIGNED((hi << 6) | lo); /* merge them and convert into signed val */
- } else {
- if (sym >= 256U) {
- av_log(avctx, AV_LOG_ERROR, "Invalid sym encountered: %d.\n", sym);
- return -1;
- }
- run = rvmap->runtab[sym];
- val = rvmap->valtab[sym];
- }
-
- /* de-zigzag and dequantize */
- scan_pos += run;
- if (scan_pos >= (unsigned)num_coeffs)
- break;
- pos = band->scan[scan_pos];
-
- if (!val)
- av_dlog(avctx, "Val = 0 encountered!\n");
-
- q = (base_tab[pos] * quant) >> 9;
- if (q > 1)
- val = val * q + FFSIGN(val) * (((q ^ 1) - 1) >> 1);
- trvec[pos] = val;
- col_flags[pos & col_mask] |= !!val; /* track columns containing non-zero coeffs */
- }// while
-
- if (scan_pos >= num_coeffs && sym != rvmap->eob_sym)
- return -1; /* corrupt block data */
-
- /* undoing DC coeff prediction for intra-blocks */
- if (is_intra && band->is_2d_trans) {
- prev_dc += trvec[0];
- trvec[0] = prev_dc;
- col_flags[0] |= !!prev_dc;
- }
- if(band->transform_size > band->blk_size){
- av_log(NULL, AV_LOG_ERROR, "Too large transform\n");
- return AVERROR_INVALIDDATA;
- }
- /* apply inverse transform */
- band->inv_transform(trvec, band->buf + buf_offs,
- band->pitch, col_flags);
-
- /* apply motion compensation */
- if (!is_intra)
- mc_with_delta_func(band->buf + buf_offs,
- band->ref_buf + buf_offs + mv_y * band->pitch + mv_x,
- band->pitch, mc_type);
- } else {
- /* block not coded */
- /* for intra blocks apply the dc slant transform */
- /* for inter - perform the motion compensation without delta */
- if (is_intra) {
- band->dc_transform(&prev_dc, band->buf + buf_offs,
- band->pitch, blk_size);
- } else
- mc_no_delta_func(band->buf + buf_offs,
- band->ref_buf + buf_offs + mv_y * band->pitch + mv_x,
- band->pitch, mc_type);
- }
-
- cbp >>= 1;
- }// for blk
- }// for mbn
-
- align_get_bits(gb);
-
- return 0;
-}
-
-/**
- * Handle empty tiles by performing data copying and motion
- * compensation respectively.
- *
- * @param[in] avctx ptr to the AVCodecContext
- * @param[in] band pointer to the band descriptor
- * @param[in] tile pointer to the tile descriptor
- * @param[in] mv_scale scaling factor for motion vectors
- */
-static int ivi_process_empty_tile(AVCodecContext *avctx, IVIBandDesc *band,
- IVITile *tile, int32_t mv_scale)
-{
- int x, y, need_mc, mbn, blk, num_blocks, mv_x, mv_y, mc_type;
- int offs, mb_offset, row_offset;
- IVIMbInfo *mb, *ref_mb;
- const int16_t *src;
- int16_t *dst;
- void (*mc_no_delta_func)(int16_t *buf, const int16_t *ref_buf, uint32_t pitch,
- int mc_type);
-
- if (tile->num_MBs != IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size)) {
- av_log(avctx, AV_LOG_ERROR, "Allocated tile size %d mismatches "
- "parameters %d in ivi_process_empty_tile()\n",
- tile->num_MBs, IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size));
- return AVERROR_INVALIDDATA;
- }
-
- offs = tile->ypos * band->pitch + tile->xpos;
- mb = tile->mbs;
- ref_mb = tile->ref_mbs;
- row_offset = band->mb_size * band->pitch;
- need_mc = 0; /* reset the mc tracking flag */
-
- for (y = tile->ypos; y < (tile->ypos + tile->height); y += band->mb_size) {
- mb_offset = offs;
-
- for (x = tile->xpos; x < (tile->xpos + tile->width); x += band->mb_size) {
- mb->xpos = x;
- mb->ypos = y;
- mb->buf_offs = mb_offset;
-
- mb->type = 1; /* set the macroblocks type = INTER */
- mb->cbp = 0; /* all blocks are empty */
-
- if (!band->qdelta_present && !band->plane && !band->band_num) {
- mb->q_delta = band->glob_quant;
- mb->mv_x = 0;
- mb->mv_y = 0;
- }
-
- if (band->inherit_qdelta && ref_mb)
- mb->q_delta = ref_mb->q_delta;
-
- if (band->inherit_mv && ref_mb) {
- /* motion vector inheritance */
- if (mv_scale) {
- mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
- mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
- } else {
- mb->mv_x = ref_mb->mv_x;
- mb->mv_y = ref_mb->mv_y;
- }
- need_mc |= mb->mv_x || mb->mv_y; /* tracking non-zero motion vectors */
- {
- int dmv_x, dmv_y, cx, cy;
-
- dmv_x = mb->mv_x >> band->is_halfpel;
- dmv_y = mb->mv_y >> band->is_halfpel;
- cx = mb->mv_x & band->is_halfpel;
- cy = mb->mv_y & band->is_halfpel;
-
- if ( mb->xpos + dmv_x < 0
- || mb->xpos + dmv_x + band->mb_size + cx > band->pitch
- || mb->ypos + dmv_y < 0
- || mb->ypos + dmv_y + band->mb_size + cy > band->aheight) {
- av_log(avctx, AV_LOG_ERROR, "MV out of bounds\n");
- return AVERROR_INVALIDDATA;
- }
- }
- }
-
- mb++;
- if (ref_mb)
- ref_mb++;
- mb_offset += band->mb_size;
- } // for x
- offs += row_offset;
- } // for y
-
- if (band->inherit_mv && need_mc) { /* apply motion compensation if there is at least one non-zero motion vector */
- num_blocks = (band->mb_size != band->blk_size) ? 4 : 1; /* number of blocks per mb */
- mc_no_delta_func = (band->blk_size == 8) ? ff_ivi_mc_8x8_no_delta
- : ff_ivi_mc_4x4_no_delta;
-
- for (mbn = 0, mb = tile->mbs; mbn < tile->num_MBs; mb++, mbn++) {
- mv_x = mb->mv_x;
- mv_y = mb->mv_y;
- if (!band->is_halfpel) {
- mc_type = 0; /* we have only fullpel vectors */
- } else {
- mc_type = ((mv_y & 1) << 1) | (mv_x & 1);
- mv_x >>= 1;
- mv_y >>= 1; /* convert halfpel vectors into fullpel ones */
- }
-
- for (blk = 0; blk < num_blocks; blk++) {
- /* adjust block position in the buffer according with its number */
- offs = mb->buf_offs + band->blk_size * ((blk & 1) + !!(blk & 2) * band->pitch);
- mc_no_delta_func(band->buf + offs,
- band->ref_buf + offs + mv_y * band->pitch + mv_x,
- band->pitch, mc_type);
- }
- }
- } else {
- /* copy data from the reference tile into the current one */
- src = band->ref_buf + tile->ypos * band->pitch + tile->xpos;
- dst = band->buf + tile->ypos * band->pitch + tile->xpos;
- for (y = 0; y < tile->height; y++) {
- memcpy(dst, src, tile->width*sizeof(band->buf[0]));
- src += band->pitch;
- dst += band->pitch;
- }
- }
-
- return 0;
-}
-
-
-#ifdef DEBUG
-static uint16_t ivi_calc_band_checksum(IVIBandDesc *band)
-{
- int x, y;
- int16_t *src, checksum;
-
- src = band->buf;
- checksum = 0;
-
- for (y = 0; y < band->height; src += band->pitch, y++)
- for (x = 0; x < band->width; x++)
- checksum += src[x];
-
- return checksum;
-}
-#endif
-
-/*
- * Convert and output the current plane.
- * This conversion is done by adding back the bias value of 128
- * (subtracted in the encoder) and clipping the result.
- *
- * @param[in] plane pointer to the descriptor of the plane being processed
- * @param[out] dst pointer to the buffer receiving converted pixels
- * @param[in] dst_pitch pitch for moving to the next y line
- */
-static void ivi_output_plane(IVIPlaneDesc *plane, uint8_t *dst, int dst_pitch)
-{
- int x, y;
- const int16_t *src = plane->bands[0].buf;
- uint32_t pitch = plane->bands[0].pitch;
-
- if (!src)
- return;
-
- for (y = 0; y < plane->height; y++) {
- for (x = 0; x < plane->width; x++)
- dst[x] = av_clip_uint8(src[x] + 128);
- src += pitch;
- dst += dst_pitch;
- }
-}
-
-/**
- * Decode an Indeo 4 or 5 band.
- *
- * @param[in,out] ctx ptr to the decoder context
- * @param[in,out] band ptr to the band descriptor
- * @param[in] avctx ptr to the AVCodecContext
- * @return result code: 0 = OK, -1 = error
- */
-static int decode_band(IVI45DecContext *ctx,
- IVIBandDesc *band, AVCodecContext *avctx)
-{
- int result, i, t, idx1, idx2, pos;
- IVITile *tile;
-
- band->buf = band->bufs[ctx->dst_buf];
- if (!band->buf) {
- av_log(avctx, AV_LOG_ERROR, "Band buffer points to no data!\n");
- return AVERROR_INVALIDDATA;
- }
- band->ref_buf = band->bufs[ctx->ref_buf];
- band->data_ptr = ctx->frame_data + (get_bits_count(&ctx->gb) >> 3);
-
- result = ctx->decode_band_hdr(ctx, band, avctx);
- if (result) {
- av_log(avctx, AV_LOG_ERROR, "Error while decoding band header: %d\n",
- result);
- return result;
- }
-
- if (band->is_empty) {
- av_log(avctx, AV_LOG_ERROR, "Empty band encountered!\n");
- return AVERROR_INVALIDDATA;
- }
-
- band->rv_map = &ctx->rvmap_tabs[band->rvmap_sel];
-
- /* apply corrections to the selected rvmap table if present */
- for (i = 0; i < band->num_corr; i++) {
- idx1 = band->corr[i * 2];
- idx2 = band->corr[i * 2 + 1];
- FFSWAP(uint8_t, band->rv_map->runtab[idx1], band->rv_map->runtab[idx2]);
- FFSWAP(int16_t, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]);
- if (idx1 == band->rv_map->eob_sym || idx2 == band->rv_map->eob_sym)
- band->rv_map->eob_sym ^= idx1 ^ idx2;
- if (idx1 == band->rv_map->esc_sym || idx2 == band->rv_map->esc_sym)
- band->rv_map->esc_sym ^= idx1 ^ idx2;
- }
-
- pos = get_bits_count(&ctx->gb);
-
- for (t = 0; t < band->num_tiles; t++) {
- tile = &band->tiles[t];
-
- if (tile->mb_size != band->mb_size) {
- av_log(avctx, AV_LOG_ERROR, "MB sizes mismatch: %d vs. %d\n",
- band->mb_size, tile->mb_size);
- return AVERROR_INVALIDDATA;
- }
- tile->is_empty = get_bits1(&ctx->gb);
- if (tile->is_empty) {
- result = ivi_process_empty_tile(avctx, band, tile,
- (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3));
- if (result < 0)
- break;
- av_dlog(avctx, "Empty tile encountered!\n");
- } else {
- tile->data_size = ivi_dec_tile_data_size(&ctx->gb);
- if (!tile->data_size) {
- av_log(avctx, AV_LOG_ERROR, "Tile data size is zero!\n");
- result = AVERROR_INVALIDDATA;
- break;
- }
-
- result = ctx->decode_mb_info(ctx, band, tile, avctx);
- if (result < 0)
- break;
-
- result = ivi_decode_blocks(&ctx->gb, band, tile, avctx);
- if (result < 0 || ((get_bits_count(&ctx->gb) - pos) >> 3) != tile->data_size) {
- av_log(avctx, AV_LOG_ERROR, "Corrupted tile data encountered!\n");
- break;
- }
-
- pos += tile->data_size << 3; // skip to next tile
- }
- }
-
- /* restore the selected rvmap table by applying its corrections in reverse order */
- for (i = band->num_corr-1; i >= 0; i--) {
- idx1 = band->corr[i*2];
- idx2 = band->corr[i*2+1];
- FFSWAP(uint8_t, band->rv_map->runtab[idx1], band->rv_map->runtab[idx2]);
- FFSWAP(int16_t, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]);
- if (idx1 == band->rv_map->eob_sym || idx2 == band->rv_map->eob_sym)
- band->rv_map->eob_sym ^= idx1 ^ idx2;
- if (idx1 == band->rv_map->esc_sym || idx2 == band->rv_map->esc_sym)
- band->rv_map->esc_sym ^= idx1 ^ idx2;
- }
-
-#ifdef DEBUG
- if (band->checksum_present) {
- uint16_t chksum = ivi_calc_band_checksum(band);
- if (chksum != band->checksum) {
- av_log(avctx, AV_LOG_ERROR,
- "Band checksum mismatch! Plane %d, band %d, received: %x, calculated: %x\n",
- band->plane, band->band_num, band->checksum, chksum);
- }
- }
-#endif
-
- align_get_bits(&ctx->gb);
-
- return result;
-}
-
-int ff_ivi_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
- AVPacket *avpkt)
-{
- IVI45DecContext *ctx = avctx->priv_data;
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
- int result, p, b;
-
- init_get_bits(&ctx->gb, buf, buf_size * 8);
- ctx->frame_data = buf;
- ctx->frame_size = buf_size;
-
- result = ctx->decode_pic_hdr(ctx, avctx);
- if (result) {
- av_log(avctx, AV_LOG_ERROR,
- "Error while decoding picture header: %d\n", result);
- return -1;
- }
- if (ctx->gop_invalid)
- return AVERROR_INVALIDDATA;
-
- if (ctx->gop_flags & IVI5_IS_PROTECTED) {
- av_log(avctx, AV_LOG_ERROR, "Password-protected clip!\n");
- return -1;
- }
-
- ctx->switch_buffers(ctx);
-
- //{ START_TIMER;
-
- if (ctx->is_nonnull_frame(ctx)) {
- ctx->buf_invalid[ctx->dst_buf] = 1;
- for (p = 0; p < 3; p++) {
- for (b = 0; b < ctx->planes[p].num_bands; b++) {
- result = decode_band(ctx, &ctx->planes[p].bands[b], avctx);
- if (result) {
- av_log(avctx, AV_LOG_ERROR,
- "Error while decoding band: %d, plane: %d\n", b, p);
- return -1;
- }
- }
- }
- ctx->buf_invalid[ctx->dst_buf] = 0;
- }
- if (ctx->buf_invalid[ctx->dst_buf])
- return -1;
-
- //STOP_TIMER("decode_planes"); }
-
- /* If the bidirectional mode is enabled, next I and the following P frame will */
- /* be sent together. Unfortunately the approach below seems to be the only way */
- /* to handle the B-frames mode. That's exactly the same Intel decoders do. */
- if (avctx->codec_id == AV_CODEC_ID_INDEO4 && ctx->frame_type == 0/*FRAMETYPE_INTRA*/) {
- while (get_bits(&ctx->gb, 8)); // skip version string
- skip_bits_long(&ctx->gb, 64); // skip padding, TODO: implement correct 8-bytes alignment
- if (get_bits_left(&ctx->gb) > 18 && show_bits(&ctx->gb, 18) == 0x3FFF8)
- av_log(avctx, AV_LOG_ERROR, "Buffer contains IP frames!\n");
- }
-
- if (!ctx->is_nonnull_frame(ctx))
- return buf_size;
-
- if (ctx->frame.data[0])
- avctx->release_buffer(avctx, &ctx->frame);
-
- ctx->frame.reference = 0;
- avcodec_set_dimensions(avctx, ctx->planes[0].width, ctx->planes[0].height);
- if ((result = ff_get_buffer(avctx, &ctx->frame)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return result;
- }
-
- if (ctx->is_scalable) {
- if (avctx->codec_id == AV_CODEC_ID_INDEO4)
- ff_ivi_recompose_haar(&ctx->planes[0], ctx->frame.data[0], ctx->frame.linesize[0]);
- else
- ff_ivi_recompose53 (&ctx->planes[0], ctx->frame.data[0], ctx->frame.linesize[0]);
- } else {
- ivi_output_plane(&ctx->planes[0], ctx->frame.data[0], ctx->frame.linesize[0]);
- }
-
- ivi_output_plane(&ctx->planes[2], ctx->frame.data[1], ctx->frame.linesize[1]);
- ivi_output_plane(&ctx->planes[1], ctx->frame.data[2], ctx->frame.linesize[2]);
-
- *got_frame = 1;
- *(AVFrame*)data = ctx->frame;
-
- return buf_size;
-}
-
-/**
- * Close Indeo5 decoder and clean up its context.
- */
-av_cold int ff_ivi_decode_close(AVCodecContext *avctx)
-{
- IVI45DecContext *ctx = avctx->priv_data;
-
- ivi_free_buffers(&ctx->planes[0]);
-
- if (ctx->mb_vlc.cust_tab.table)
- ff_free_vlc(&ctx->mb_vlc.cust_tab);
-
- if (ctx->frame.data[0])
- avctx->release_buffer(avctx, &ctx->frame);
-
-#if IVI4_STREAM_ANALYSER
- if (avctx->codec_id == AV_CODEC_ID_INDEO4) {
- if (ctx->is_scalable)
- av_log(avctx, AV_LOG_ERROR, "This video uses scalability mode!\n");
- if (ctx->uses_tiling)
- av_log(avctx, AV_LOG_ERROR, "This video uses local decoding!\n");
- if (ctx->has_b_frames)
- av_log(avctx, AV_LOG_ERROR, "This video contains B-frames!\n");
- if (ctx->has_transp)
- av_log(avctx, AV_LOG_ERROR, "Transparency mode is enabled!\n");
- if (ctx->uses_haar)
- av_log(avctx, AV_LOG_ERROR, "This video uses Haar transform!\n");
- if (ctx->uses_fullpel)
- av_log(avctx, AV_LOG_ERROR, "This video uses fullpel motion vectors!\n");
- }
-#endif
-
- return 0;
-}
-
-
-/**
- * These are 2x8 predefined Huffman codebooks for coding macroblock/block
- * signals. They are specified using "huffman descriptors" in order to
- * avoid huge static tables. The decoding tables will be generated at
- * startup from these descriptors.
- */
-const IVIHuffDesc ff_ivi_mb_huff_desc[8] = {
- {8, {0, 4, 5, 4, 4, 4, 6, 6}},
- {12, {0, 2, 2, 3, 3, 3, 3, 5, 3, 2, 2, 2}},
- {12, {0, 2, 3, 4, 3, 3, 3, 3, 4, 3, 2, 2}},
- {12, {0, 3, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2}},
- {13, {0, 4, 4, 3, 3, 3, 3, 2, 3, 3, 2, 1, 1}},
- {9, {0, 4, 4, 4, 4, 3, 3, 3, 2}},
- {10, {0, 4, 4, 4, 4, 3, 3, 2, 2, 2}},
- {12, {0, 4, 4, 4, 3, 3, 2, 3, 2, 2, 2, 2}}
-};
-
-const IVIHuffDesc ff_ivi_blk_huff_desc[8] = {
- {10, {1, 2, 3, 4, 4, 7, 5, 5, 4, 1}},
- {11, {2, 3, 4, 4, 4, 7, 5, 4, 3, 3, 2}},
- {12, {2, 4, 5, 5, 5, 5, 6, 4, 4, 3, 1, 1}},
- {13, {3, 3, 4, 4, 5, 6, 6, 4, 4, 3, 2, 1, 1}},
- {11, {3, 4, 4, 5, 5, 5, 6, 5, 4, 2, 2}},
- {13, {3, 4, 5, 5, 5, 5, 6, 4, 3, 3, 2, 1, 1}},
- {13, {3, 4, 5, 5, 5, 6, 5, 4, 3, 3, 2, 1, 1}},
- {9, {3, 4, 4, 5, 5, 5, 6, 5, 5}}
-};
-
-
-/**
- * Scan patterns shared between indeo4 and indeo5
- */
-const uint8_t ff_ivi_vertical_scan_8x8[64] = {
- 0, 8, 16, 24, 32, 40, 48, 56,
- 1, 9, 17, 25, 33, 41, 49, 57,
- 2, 10, 18, 26, 34, 42, 50, 58,
- 3, 11, 19, 27, 35, 43, 51, 59,
- 4, 12, 20, 28, 36, 44, 52, 60,
- 5, 13, 21, 29, 37, 45, 53, 61,
- 6, 14, 22, 30, 38, 46, 54, 62,
- 7, 15, 23, 31, 39, 47, 55, 63
-};
-
-const uint8_t ff_ivi_horizontal_scan_8x8[64] = {
- 0, 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,
- 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, 57, 58, 59, 60, 61, 62, 63
-};
-
-const uint8_t ff_ivi_direct_scan_4x4[16] = {
- 0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15
-};
-
-
-/**
- * Run-value (RLE) tables.
- */
-const RVMapDesc ff_ivi_rvmap_tabs[9] = {
-{ /* MapTab0 */
- 5, /* eob_sym */
- 2, /* esc_sym */
- /* run table */
- {1, 1, 0, 1, 1, 0, 1, 1, 2, 2, 1, 1, 1, 1, 3, 3,
- 1, 1, 2, 2, 1, 1, 4, 4, 1, 1, 1, 1, 2, 2, 5, 5,
- 1, 1, 3, 3, 1, 1, 6, 6, 1, 2, 1, 2, 7, 7, 1, 1,
- 8, 8, 1, 1, 4, 2, 1, 4, 2, 1, 3, 3, 1, 1, 1, 9,
- 9, 1, 2, 1, 2, 1, 5, 5, 1, 1, 10, 10, 1, 1, 3, 3,
- 2, 2, 1, 1, 11, 11, 6, 4, 4, 1, 6, 1, 2, 1, 2, 12,
- 8, 1, 12, 7, 8, 7, 1, 16, 1, 16, 1, 3, 3, 13, 1, 13,
- 2, 2, 1, 15, 1, 5, 14, 15, 1, 5, 14, 1, 17, 8, 17, 8,
- 1, 4, 4, 2, 2, 1, 25, 25, 24, 24, 1, 3, 1, 3, 1, 8,
- 6, 7, 6, 1, 18, 8, 18, 1, 7, 23, 2, 2, 23, 1, 1, 21,
- 22, 9, 9, 22, 19, 1, 21, 5, 19, 5, 1, 33, 20, 33, 20, 8,
- 4, 4, 1, 32, 2, 2, 8, 3, 32, 26, 3, 1, 7, 7, 26, 6,
- 1, 6, 1, 1, 16, 1, 10, 1, 10, 2, 16, 29, 28, 2, 29, 28,
- 1, 27, 5, 8, 5, 27, 1, 8, 3, 7, 3, 31, 41, 31, 1, 41,
- 6, 1, 6, 7, 4, 4, 1, 1, 2, 1, 2, 11, 34, 30, 11, 1,
- 30, 15, 15, 34, 36, 40, 36, 40, 35, 35, 37, 37, 39, 39, 38, 38},
-
- /* value table */
- { 1, -1, 0, 2, -2, 0, 3, -3, 1, -1, 4, -4, 5, -5, 1, -1,
- 6, -6, 2, -2, 7, -7, 1, -1, 8, -8, 9, -9, 3, -3, 1, -1,
- 10, -10, 2, -2, 11, -11, 1, -1, 12, 4, -12, -4, 1, -1, 13, -13,
- 1, -1, 14, -14, 2, 5, 15, -2, -5, -15, -3, 3, 16, -16, 17, 1,
- -1, -17, 6, 18, -6, -18, 2, -2, 19, -19, 1, -1, 20, -20, 4, -4,
- 7, -7, 21, -21, 1, -1, 2, 3, -3, 22, -2, -22, 8, 23, -8, 1,
- 2, -23, -1, 2, -2, -2, 24, 1, -24, -1, 25, 5, -5, 1, -25, -1,
- 9, -9, 26, 1, -26, 3, 1, -1, 27, -3, -1, -27, 1, 3, -1, -3,
- 28, -4, 4, 10, -10, -28, 1, -1, 1, -1, 29, 6, -29, -6, 30, -4,
- 3, 3, -3, -30, 1, 4, -1, 31, -3, 1, 11, -11, -1, -31, 32, -1,
- -1, 2, -2, 1, 1, -32, 1, 4, -1, -4, 33, -1, 1, 1, -1, 5,
- 5, -5, -33, -1, -12, 12, -5, -7, 1, 1, 7, 34, 4, -4, -1, 4,
- -34, -4, 35, 36, -2, -35, -2, -36, 2, 13, 2, -1, 1, -13, 1, -1,
- 37, 1, -5, 6, 5, -1, 38, -6, -8, 5, 8, -1, 1, 1, -37, -1,
- 5, 39, -5, -5, 6, -6, -38, -39, -14, 40, 14, 2, 1, 1, -2, -40,
- -1, -2, 2, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1}
-},{
- /* MapTab1 */
- 0, /* eob_sym */
- 38, /* esc_sym */
- /* run table */
- {0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 8, 6, 8, 7,
- 7, 9, 9, 10, 10, 11, 11, 1, 12, 1, 12, 13, 13, 16, 14, 16,
- 14, 15, 15, 17, 17, 18, 0, 18, 19, 20, 21, 19, 22, 21, 20, 22,
- 25, 24, 2, 25, 24, 23, 23, 2, 26, 28, 26, 28, 29, 27, 29, 27,
- 33, 33, 1, 32, 1, 3, 32, 30, 36, 3, 36, 30, 31, 31, 35, 34,
- 37, 41, 34, 35, 37, 4, 41, 4, 49, 8, 8, 49, 40, 38, 5, 38,
- 40, 39, 5, 39, 42, 43, 42, 7, 57, 6, 43, 44, 6, 50, 7, 44,
- 57, 48, 50, 48, 45, 45, 46, 47, 51, 46, 47, 58, 1, 51, 58, 1,
- 52, 59, 53, 9, 52, 55, 55, 59, 53, 56, 54, 56, 54, 9, 64, 64,
- 60, 63, 60, 63, 61, 62, 61, 62, 2, 10, 2, 10, 11, 1, 11, 13,
- 12, 1, 12, 13, 16, 16, 8, 8, 14, 3, 3, 15, 14, 15, 4, 4,
- 1, 17, 17, 5, 1, 7, 7, 5, 6, 1, 2, 2, 6, 22, 1, 25,
- 21, 22, 8, 24, 1, 21, 25, 24, 8, 18, 18, 23, 9, 20, 23, 33,
- 29, 33, 20, 1, 19, 1, 29, 36, 9, 36, 19, 41, 28, 57, 32, 3,
- 28, 3, 1, 27, 49, 49, 1, 32, 26, 26, 2, 4, 4, 7, 57, 41,
- 2, 7, 10, 5, 37, 16, 10, 27, 8, 8, 13, 16, 37, 13, 1, 5},
-
- /* value table */
- {0, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1,
- -1, 1, -1, 1, -1, 1, -1, 2, 1, -2, -1, 1, -1, 1, 1, -1,
- -1, 1, -1, 1, -1, 1, 0, -1, 1, 1, 1, -1, 1, -1, -1, -1,
- 1, 1, 2, -1, -1, 1, -1, -2, 1, 1, -1, -1, 1, 1, -1, -1,
- 1, -1, 3, 1, -3, 2, -1, 1, 1, -2, -1, -1, -1, 1, 1, 1,
- 1, 1, -1, -1, -1, 2, -1, -2, 1, 2, -2, -1, 1, 1, 2, -1,
- -1, 1, -2, -1, 1, 1, -1, 2, 1, 2, -1, 1, -2, -1, -2, -1,
- -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 4, -1, -1, -4,
- 1, 1, 1, 2, -1, -1, 1, -1, -1, 1, -1, -1, 1, -2, 1, -1,
- 1, 1, -1, -1, 1, 1, -1, -1, 3, 2, -3, -2, 2, 5, -2, 2,
- 2, -5, -2, -2, -2, 2, -3, 3, 2, 3, -3, 2, -2, -2, 3, -3,
- 6, 2, -2, 3, -6, 3, -3, -3, 3, 7, -4, 4, -3, 2, -7, 2,
- 2, -2, -4, 2, 8, -2, -2, -2, 4, 2, -2, 2, 3, 2, -2, -2,
- 2, 2, -2, -8, -2, 9, -2, 2, -3, -2, 2, -2, 2, 2, 2, 4,
- -2, -4, 10, 2, 2, -2, -9, -2, 2, -2, 5, 4, -4, 4, -2, 2,
- -5, -4, -3, 4, 2, -3, 3, -2, -5, 5, 3, 3, -2, -3, -10, -4}
-},{
- /* MapTab2 */
- 2, /* eob_sym */
- 11, /* esc_sym */
- /* run table */
- {1, 1, 0, 2, 2, 1, 1, 3, 3, 4, 4, 0, 1, 1, 5, 5,
- 2, 2, 6, 6, 7, 7, 1, 8, 1, 8, 3, 3, 9, 9, 1, 2,
- 2, 1, 4, 10, 4, 10, 11, 11, 1, 5, 12, 12, 1, 5, 13, 13,
- 3, 3, 6, 6, 2, 2, 14, 14, 16, 16, 15, 7, 15, 8, 8, 7,
- 1, 1, 17, 17, 4, 4, 1, 1, 18, 18, 2, 2, 5, 5, 25, 3,
- 9, 3, 25, 9, 19, 24, 19, 24, 1, 21, 20, 1, 21, 22, 20, 22,
- 23, 23, 8, 6, 33, 6, 8, 33, 7, 7, 26, 26, 1, 32, 1, 32,
- 28, 4, 28, 10, 29, 27, 27, 10, 41, 4, 29, 2, 2, 41, 36, 31,
- 49, 31, 34, 30, 34, 36, 30, 35, 1, 49, 11, 5, 35, 11, 1, 3,
- 3, 5, 37, 37, 8, 40, 8, 40, 12, 12, 42, 42, 1, 38, 16, 57,
- 1, 6, 16, 39, 38, 6, 7, 7, 13, 13, 39, 43, 2, 43, 57, 2,
- 50, 9, 44, 9, 50, 4, 15, 48, 44, 4, 1, 15, 48, 14, 14, 1,
- 45, 45, 8, 3, 5, 8, 51, 47, 3, 46, 46, 47, 5, 51, 1, 17,
- 17, 58, 1, 58, 2, 52, 52, 2, 53, 7, 59, 6, 6, 56, 53, 55,
- 7, 55, 1, 54, 59, 56, 54, 10, 1, 10, 4, 60, 1, 60, 8, 4,
- 8, 64, 64, 61, 1, 63, 3, 63, 62, 61, 5, 11, 5, 3, 11, 62},
-
- /* value table */
- { 1, -1, 0, 1, -1, 2, -2, 1, -1, 1, -1, 0, 3, -3, 1, -1,
- 2, -2, 1, -1, 1, -1, 4, 1, -4, -1, 2, -2, 1, -1, 5, 3,
- -3, -5, 2, 1, -2, -1, 1, -1, 6, 2, 1, -1, -6, -2, 1, -1,
- 3, -3, 2, -2, 4, -4, 1, -1, 1, -1, 1, 2, -1, 2, -2, -2,
- 7, -7, 1, -1, 3, -3, 8, -8, 1, -1, 5, -5, 3, -3, 1, 4,
- 2, -4, -1, -2, 1, 1, -1, -1, 9, 1, 1, -9, -1, 1, -1, -1,
- 1, -1, 3, -3, 1, 3, -3, -1, 3, -3, 1, -1, 10, 1, -10, -1,
- 1, 4, -1, 2, 1, -1, 1, -2, 1, -4, -1, 6, -6, -1, 1, 1,
- 1, -1, 1, 1, -1, -1, -1, 1, 11, -1, -2, 4, -1, 2, -11, 5,
- -5, -4, -1, 1, 4, 1, -4, -1, -2, 2, 1, -1, 12, 1, -2, 1,
- -12, 4, 2, 1, -1, -4, 4, -4, 2, -2, -1, 1, 7, -1, -1, -7,
- -1, -3, 1, 3, 1, 5, 2, 1, -1, -5, 13, -2, -1, 2, -2, -13,
- 1, -1, 5, 6, 5, -5, 1, 1, -6, 1, -1, -1, -5, -1, 14, 2,
- -2, 1, -14, -1, 8, 1, -1, -8, 1, 5, 1, 5, -5, 1, -1, 1,
- -5, -1, 15, 1, -1, -1, -1, 3, -15, -3, 6, 1, 16, -1, 6, -6,
- -6, 1, -1, 1, -16, 1, 7, -1, 1, -1, -6, -3, 6, -7, 3, -1}
-},{
- /* MapTab3 */
- 0, /* eob_sym */
- 35, /* esc_sym */
- /* run table */
- {0, 1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 5, 5, 6, 6, 7,
- 7, 8, 8, 9, 9, 2, 2, 10, 10, 1, 1, 11, 11, 12, 12, 3,
- 3, 13, 13, 0, 14, 14, 16, 15, 16, 15, 4, 4, 17, 1, 17, 1,
- 5, 5, 18, 18, 2, 2, 6, 6, 8, 19, 7, 8, 7, 19, 20, 20,
- 21, 21, 22, 24, 22, 24, 23, 23, 1, 1, 25, 25, 3, 3, 26, 26,
- 9, 9, 27, 27, 28, 28, 33, 29, 4, 33, 29, 1, 4, 1, 32, 32,
- 2, 2, 31, 10, 30, 10, 30, 31, 34, 34, 5, 5, 36, 36, 35, 41,
- 35, 11, 41, 11, 37, 1, 8, 8, 37, 6, 1, 6, 40, 7, 7, 40,
- 12, 38, 12, 39, 39, 38, 49, 13, 49, 13, 3, 42, 3, 42, 16, 16,
- 43, 43, 14, 14, 1, 1, 44, 15, 44, 15, 2, 2, 57, 48, 50, 48,
- 57, 50, 4, 45, 45, 4, 46, 47, 47, 46, 1, 51, 1, 17, 17, 51,
- 8, 9, 9, 5, 58, 8, 58, 5, 52, 52, 55, 56, 53, 56, 55, 59,
- 59, 53, 54, 1, 6, 54, 7, 7, 6, 1, 2, 3, 2, 3, 64, 60,
- 60, 10, 10, 64, 61, 62, 61, 63, 1, 63, 62, 1, 18, 24, 18, 4,
- 25, 4, 8, 21, 21, 1, 24, 22, 25, 22, 8, 11, 19, 11, 23, 1,
- 20, 23, 19, 20, 5, 12, 5, 1, 16, 2, 12, 13, 2, 13, 1, 16},
-
- /* value table */
- { 0, 1, -1, 1, -1, 1, -1, 1, -1, 2, -2, 1, -1, 1, -1, 1,
- -1, 1, -1, 1, -1, 2, -2, 1, -1, 3, -3, 1, -1, 1, -1, 2,
- -2, 1, -1, 0, 1, -1, 1, 1, -1, -1, 2, -2, 1, 4, -1, -4,
- 2, -2, 1, -1, -3, 3, 2, -2, 2, 1, 2, -2, -2, -1, 1, -1,
- 1, -1, 1, 1, -1, -1, 1, -1, 5, -5, 1, -1, 3, -3, 1, -1,
- 2, -2, 1, -1, 1, -1, 1, 1, 3, -1, -1, 6, -3, -6, -1, 1,
- 4, -4, 1, 2, 1, -2, -1, -1, 1, -1, 3, -3, 1, -1, 1, 1,
- -1, 2, -1, -2, 1, 7, -3, 3, -1, 3, -7, -3, 1, -3, 3, -1,
- 2, 1, -2, 1, -1, -1, 1, 2, -1, -2, -4, -1, 4, 1, 2, -2,
- 1, -1, -2, 2, 8, -8, -1, 2, 1, -2, -5, 5, 1, -1, -1, 1,
- -1, 1, 4, -1, 1, -4, -1, -1, 1, 1, 9, 1, -9, 2, -2, -1,
- -4, 3, -3, -4, -1, 4, 1, 4, 1, -1, 1, -1, 1, 1, -1, 1,
- -1, -1, -1, 10, 4, 1, 4, -4, -4, -10, 6, 5, -6, -5, 1, -1,
- 1, 3, -3, -1, 1, -1, -1, -1, 11, 1, 1, -11, -2, -2, 2, 5,
- -2, -5, -5, 2, -2, 12, 2, -2, 2, 2, 5, -3, -2, 3, -2, -12,
- -2, 2, 2, 2, -5, 3, 5, 13, -3, 7, -3, -3, -7, 3, -13, 3}
-},{
- /* MapTab4 */
- 0, /* eob_sym */
- 34, /* esc_sym */
- /* run table */
- {0, 1, 1, 1, 2, 2, 1, 3, 3, 1, 1, 1, 4, 4, 1, 5,
- 2, 1, 5, 2, 1, 1, 6, 6, 1, 1, 1, 1, 1, 7, 3, 1,
- 2, 3, 0, 1, 2, 7, 1, 1, 1, 8, 1, 1, 8, 1, 1, 1,
- 9, 1, 9, 1, 2, 1, 1, 2, 1, 1, 10, 4, 1, 10, 1, 4,
- 1, 1, 1, 1, 1, 3, 1, 1, 1, 3, 2, 1, 5, 1, 1, 1,
- 2, 5, 1, 11, 1, 11, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 1, 6, 1, 6, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 12,
- 3, 1, 12, 1, 1, 1, 2, 1, 1, 3, 1, 1, 1, 1, 1, 1,
- 4, 1, 1, 1, 2, 1, 1, 4, 1, 1, 1, 1, 1, 1, 2, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 2, 1, 1, 5,
- 1, 1, 1, 1, 1, 7, 1, 7, 1, 1, 2, 3, 1, 1, 1, 1,
- 5, 1, 1, 1, 1, 1, 1, 2, 13, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 13, 2, 1, 1, 4, 1, 1, 1,
- 3, 1, 6, 1, 1, 1, 14, 1, 1, 1, 1, 1, 14, 6, 1, 1,
- 1, 1, 15, 2, 4, 1, 2, 3, 15, 1, 1, 1, 8, 1, 1, 8,
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1},
-
- /* value table */
- { 0, 1, -1, 2, 1, -1, -2, 1, -1, 3, -3, 4, 1, -1, -4, 1,
- 2, 5, -1, -2, -5, 6, 1, -1, -6, 7, -7, 8, -8, 1, 2, 9,
- 3, -2, 0, -9, -3, -1, 10, -10, 11, 1, -11, 12, -1, -12, 13, -13,
- 1, 14, -1, -14, 4, 15, -15, -4, 16, -16, 1, 2, 17, -1, -17, -2,
- 18, -18, 19, -19, 20, 3, -20, 21, -21, -3, 5, 22, 2, -22, -23, 23,
- -5, -2, 24, 1, -24, -1, 25, -25, 26, -26, -27, 27, 28, 29, -28, -29,
- 6, 30, 2, -31, -2, -30, 31, -6, -32, 32, 33, -33, 34, -35, -34, 1,
- 4, -36, -1, 35, 37, 36, 7, -37, 38, -4, -38, 39, 41, 40, -40, -39,
- 3, 42, -43, -41, -7, -42, 43, -3, 44, -44, 45, -45, 46, 47, 8, -47,
- -48, -46, 50, -50, 48, 49, 51, -49, 52, -52, 5, -51, -8, -53, 53, 3,
- -56, 56, 55, 54, -54, 2, 60, -2, -55, 58, 9, -5, 59, 57, -57, -63,
- -3, -58, -60, -61, 61, -59, -62, -9, 1, 64, 62, 69, -64, 63, 65, -67,
- -68, 66, -65, 68, -66, -69, 67, -70, -1, 10, 71, -71, 4, 73, 72, 70,
- 6, -76, -3, 74, -78, -74, 1, 78, 80, -72, -75, 76, -1, 3, -73, 79,
- 75, 77, 1, 11, -4, -79, -10, -6, -1, -77, -83, -80, 2, 81, -84, -2,
- 83, -81, 82, -82, 84, -87, -86, 85, -11, -85, 86, -89, 87, -88, 88, 89}
-},{
- /* MapTab5 */
- 2, /* eob_sym */
- 33, /* esc_sym */
- /* run table */
- {1, 1, 0, 2, 1, 2, 1, 3, 3, 1, 1, 4, 4, 2, 2, 1,
- 1, 5, 5, 6, 1, 6, 1, 7, 7, 3, 3, 2, 8, 2, 8, 1,
- 1, 0, 9, 9, 1, 1, 10, 4, 10, 4, 11, 11, 2, 1, 2, 1,
- 12, 12, 3, 3, 1, 1, 13, 5, 5, 13, 14, 1, 1, 14, 2, 2,
- 6, 6, 15, 1, 1, 15, 16, 4, 7, 16, 4, 7, 1, 1, 3, 3,
- 8, 8, 2, 2, 1, 1, 17, 17, 1, 1, 18, 18, 5, 5, 2, 2,
- 1, 1, 9, 19, 9, 19, 20, 3, 3, 20, 1, 10, 21, 1, 10, 4,
- 4, 21, 22, 6, 6, 22, 1, 1, 23, 24, 2, 2, 23, 24, 11, 1,
- 1, 11, 7, 25, 7, 1, 1, 25, 8, 8, 3, 26, 3, 1, 12, 2,
- 2, 26, 1, 12, 5, 5, 27, 4, 1, 4, 1, 27, 28, 1, 28, 13,
- 1, 13, 2, 29, 2, 1, 32, 6, 1, 30, 14, 29, 14, 6, 3, 31,
- 3, 1, 30, 1, 32, 31, 33, 9, 33, 1, 1, 7, 9, 7, 2, 2,
- 1, 1, 4, 36, 34, 4, 5, 10, 10, 5, 34, 1, 1, 35, 8, 8,
- 36, 3, 35, 1, 15, 3, 2, 1, 16, 15, 16, 2, 37, 1, 37, 1,
- 1, 1, 6, 6, 38, 1, 38, 11, 1, 39, 39, 40, 11, 2, 41, 4,
- 40, 1, 2, 4, 1, 1, 1, 41, 3, 1, 3, 1, 5, 7, 5, 7},
-
- /* value table */
- { 1, -1, 0, 1, 2, -1, -2, 1, -1, 3, -3, 1, -1, 2, -2, 4,
- -4, 1, -1, 1, 5, -1, -5, 1, -1, 2, -2, 3, 1, -3, -1, 6,
- -6, 0, 1, -1, 7, -7, 1, 2, -1, -2, 1, -1, 4, 8, -4, -8,
- 1, -1, 3, -3, 9, -9, 1, 2, -2, -1, 1, 10, -10, -1, 5, -5,
- 2, -2, 1, 11, -11, -1, 1, 3, 2, -1, -3, -2, 12, -12, 4, -4,
- 2, -2, -6, 6, 13, -13, 1, -1, 14, -14, 1, -1, 3, -3, 7, -7,
- 15, -15, 2, 1, -2, -1, 1, 5, -5, -1, -16, 2, 1, 16, -2, 4,
- -4, -1, 1, 3, -3, -1, 17, -17, 1, 1, -8, 8, -1, -1, 2, 18,
- -18, -2, 3, 1, -3, 19, -19, -1, 3, -3, 6, 1, -6, 20, 2, 9,
- -9, -1, -20, -2, 4, -4, 1, -5, 21, 5, -21, -1, 1, -22, -1, 2,
- 22, -2, 10, 1, -10, 23, 1, 4, -23, 1, 2, -1, -2, -4, -7, 1,
- 7, -24, -1, 24, -1, -1, 1, 3, -1, -25, 25, 4, -3, -4, 11, -11,
- 26, -26, 6, 1, 1, -6, -5, -3, 3, 5, -1, -27, 27, 1, 4, -4,
- -1, -8, -1, 28, 2, 8, -12, -28, -2, -2, 2, 12, -1, 29, 1, -29,
- 30, -30, 5, -5, 1, -31, -1, 3, 31, -1, 1, 1, -3, -13, 1, -7,
- -1, -32, 13, 7, 32, 33, -33, -1, -9, -34, 9, 34, -6, 5, 6, -5}
-},{
- /* MapTab6 */
- 2, /* eob_sym */
- 13, /* esc_sym */
- /* run table */
- {1, 1, 0, 1, 1, 2, 2, 1, 1, 3, 3, 1, 1, 0, 2, 2,
- 4, 1, 4, 1, 1, 1, 5, 5, 1, 1, 6, 6, 2, 2, 1, 1,
- 3, 3, 7, 7, 1, 1, 8, 8, 1, 1, 2, 2, 1, 9, 1, 9,
- 4, 4, 10, 1, 1, 10, 1, 1, 11, 11, 3, 3, 1, 2, 1, 2,
- 1, 1, 12, 12, 5, 5, 1, 1, 13, 1, 1, 13, 2, 2, 1, 1,
- 6, 6, 1, 1, 4, 14, 4, 14, 3, 1, 3, 1, 1, 1, 15, 7,
- 15, 2, 2, 7, 1, 1, 1, 8, 1, 8, 16, 16, 1, 1, 1, 1,
- 2, 1, 1, 2, 1, 1, 3, 5, 5, 3, 4, 1, 1, 4, 1, 1,
- 17, 17, 9, 1, 1, 9, 2, 2, 1, 1, 10, 10, 1, 6, 1, 1,
- 6, 18, 1, 1, 18, 1, 1, 1, 2, 2, 3, 1, 3, 1, 1, 1,
- 4, 1, 19, 1, 19, 7, 1, 1, 20, 1, 4, 20, 1, 7, 11, 2,
- 1, 11, 21, 2, 8, 5, 1, 8, 1, 5, 21, 1, 1, 1, 22, 1,
- 1, 22, 1, 1, 3, 3, 1, 23, 2, 12, 24, 1, 1, 2, 1, 1,
- 12, 23, 1, 1, 24, 1, 1, 1, 4, 1, 1, 1, 2, 1, 6, 6,
- 4, 2, 1, 1, 1, 1, 1, 1, 1, 14, 13, 3, 1, 25, 9, 25,
- 14, 1, 9, 3, 13, 1, 1, 1, 1, 1, 10, 1, 1, 2, 10, 2},
-
- /* value table */
- {-20, -1, 0, 2, -2, 1, -1, 3, -3, 1, -1, 4, -4, 0, 2, -2,
- 1, 5, -1, -5, 6, -6, 1, -1, 7, -7, 1, -1, 3, -3, 8, -8,
- 2, -2, 1, -1, 9, -9, 1, -1, 10, -10, 4, -4, 11, 1, -11, -1,
- 2, -2, 1, 12, -12, -1, 13, -13, 1, -1, 3, -3, 14, 5, -14, -5,
- -15, 15, -1, 1, 2, -2, 16, -16, 1, 17, -17, -1, 6, -6, 18, -18,
- 2, -2, -19, 19, -3, 1, 3, -1, 4, 20, -4, 1, -21, 21, 1, 2,
- -1, -7, 7, -2, 22, -22, 23, 2, -23, -2, 1, -1, -24, 24, -25, 25,
- -8, -26, 26, 8, -27, 27, 5, 3, -3, -5, -4, 28, -28, 4, 29, -29,
- 1, -1, -2, -30, 30, 2, 9, -9, -31, 31, 2, -2, -32, 3, 32, -33,
- -3, 1, 33, -34, -1, 34, -35, 35, -10, 10, -6, 36, 6, -36, 37, -37,
- -5, 38, 1, -38, -1, 3, 39, -39, -1, 40, 5, 1, -40, -3, 2, -11,
- -41, -2, 1, 11, -3, -4, 41, 3, 42, 4, -1, -43, -42, 43, 1, -44,
- 45, -1, 44, -45, -7, 7, -46, 1, -12, 2, 1, -47, 46, 12, 47, 48,
- -2, -1, -48, 49, -1, -50, -49, 50, -6, -51, 51, 52, -13, 53, -4, 4,
- 6, 13, -53, -52, -54, 55, 54, -55, -56, -2, 2, -8, 56, 1, -3, -1,
- 2, 58, 3, 8, -2, 57, -58, -60, -59, -57, -3, 60, 59, -14, 3, 14}
-},{
- /* MapTab7 */
- 2, /* eob_sym */
- 38, /* esc_sym */
- /* run table */
- {1, 1, 0, 2, 2, 1, 1, 3, 3, 4, 4, 5, 5, 1, 1, 6,
- 6, 2, 2, 7, 7, 8, 8, 1, 1, 3, 3, 9, 9, 10, 10, 1,
- 1, 2, 2, 4, 4, 11, 0, 11, 12, 12, 13, 13, 1, 1, 5, 5,
- 14, 14, 15, 16, 15, 16, 3, 3, 1, 6, 1, 6, 2, 2, 7, 7,
- 8, 8, 17, 17, 1, 1, 4, 4, 18, 18, 2, 2, 1, 19, 1, 20,
- 19, 20, 21, 21, 3, 3, 22, 22, 5, 5, 24, 1, 1, 23, 9, 23,
- 24, 9, 2, 2, 10, 1, 1, 10, 6, 6, 25, 4, 4, 25, 7, 7,
- 26, 8, 1, 8, 3, 1, 26, 3, 11, 11, 27, 27, 2, 28, 1, 2,
- 28, 1, 12, 12, 5, 5, 29, 13, 13, 29, 32, 1, 1, 33, 31, 30,
- 32, 4, 30, 33, 4, 31, 3, 14, 1, 1, 3, 34, 34, 2, 2, 14,
- 6, 6, 35, 36, 35, 36, 1, 15, 1, 16, 16, 15, 7, 9, 7, 9,
- 37, 8, 8, 37, 1, 1, 39, 2, 38, 39, 2, 40, 5, 38, 40, 5,
- 3, 3, 4, 4, 10, 10, 1, 1, 1, 1, 41, 2, 41, 2, 6, 6,
- 1, 1, 11, 42, 11, 43, 3, 42, 3, 17, 4, 43, 1, 17, 7, 1,
- 8, 44, 4, 7, 44, 5, 8, 2, 5, 1, 2, 48, 45, 1, 12, 45,
- 12, 48, 13, 13, 1, 9, 9, 46, 1, 46, 47, 47, 49, 18, 18, 49},
-
- /* value table */
- { 1, -1, 0, 1, -1, 2, -2, 1, -1, 1, -1, 1, -1, 3, -3, 1,
- -1, -2, 2, 1, -1, 1, -1, 4, -4, -2, 2, 1, -1, 1, -1, 5,
- -5, -3, 3, 2, -2, 1, 0, -1, 1, -1, 1, -1, 6, -6, 2, -2,
- 1, -1, 1, 1, -1, -1, -3, 3, 7, 2, -7, -2, -4, 4, 2, -2,
- 2, -2, 1, -1, 8, -8, 3, -3, 1, -1, -5, 5, 9, 1, -9, 1,
- -1, -1, 1, -1, -4, 4, 1, -1, 3, -3, 1, -10, 10, 1, 2, -1,
- -1, -2, 6, -6, 2, 11, -11, -2, 3, -3, 1, -4, 4, -1, 3, -3,
- 1, 3, 12, -3, -5, -12, -1, 5, 2, -2, 1, -1, -7, 1, 13, 7,
- -1, -13, 2, -2, 4, -4, 1, 2, -2, -1, 1, 14, -14, 1, 1, 1,
- -1, -5, -1, -1, 5, -1, -6, 2, -15, 15, 6, 1, -1, -8, 8, -2,
- -4, 4, 1, 1, -1, -1, 16, 2, -16, -2, 2, -2, 4, 3, -4, -3,
- -1, -4, 4, 1, -17, 17, -1, -9, 1, 1, 9, 1, -5, -1, -1, 5,
- -7, 7, 6, -6, 3, -3, 18, -18, 19, -19, 1, -10, -1, 10, -5, 5,
- 20, -20, -3, 1, 3, 1, 8, -1, -8, 2, 7, -1, -21, -2, 5, 21,
- 5, -1, -7, -5, 1, -6, -5, -11, 6, 22, 11, 1, 1, -22, -3, -1,
- 3, -1, 3, -3, -23, 4, -4, 1, 23, -1, 1, -1, 1, -2, 2, -1}
-},{
- /* MapTab8 */
- 4, /* eob_sym */
- 11, /* esc_sym */
- /* run table */
- {1, 1, 1, 1, 0, 2, 2, 1, 1, 3, 3, 0, 1, 1, 2, 2,
- 4, 4, 1, 1, 5, 5, 1, 1, 2, 2, 3, 3, 6, 6, 1, 1,
- 7, 7, 8, 1, 8, 2, 2, 1, 4, 4, 1, 3, 1, 3, 9, 9,
- 2, 2, 1, 5, 1, 5, 10, 10, 1, 1, 11, 11, 3, 6, 3, 4,
- 4, 6, 2, 2, 1, 12, 1, 12, 7, 13, 7, 13, 1, 1, 8, 8,
- 2, 2, 14, 14, 16, 15, 16, 5, 5, 1, 3, 15, 1, 3, 4, 4,
- 1, 1, 17, 17, 2, 2, 6, 6, 1, 18, 1, 18, 22, 21, 22, 21,
- 25, 24, 25, 19, 9, 20, 9, 23, 19, 24, 20, 3, 23, 7, 3, 1,
- 1, 7, 28, 26, 29, 5, 28, 26, 5, 8, 29, 4, 8, 27, 2, 2,
- 4, 27, 1, 1, 10, 36, 10, 33, 33, 36, 30, 1, 32, 32, 1, 30,
- 6, 31, 31, 35, 3, 6, 11, 11, 3, 2, 35, 2, 34, 1, 34, 1,
- 37, 37, 12, 7, 12, 5, 41, 5, 4, 7, 1, 8, 13, 4, 1, 41,
- 13, 38, 8, 38, 9, 1, 40, 40, 9, 1, 39, 2, 2, 49, 39, 42,
- 3, 3, 14, 16, 49, 14, 16, 42, 43, 43, 6, 6, 15, 1, 1, 15,
- 44, 44, 1, 1, 50, 48, 4, 5, 4, 7, 5, 2, 10, 10, 48, 7,
- 50, 45, 2, 1, 45, 8, 8, 1, 46, 46, 3, 47, 47, 3, 1, 1},
-
- /* value table */
- { 1, -1, 2, -2, 0, 1, -1, 3, -3, 1, -1, 0, 4, -4, 2, -2,
- 1, -1, 5, -5, 1, -1, 6, -6, 3, -3, 2, -2, 1, -1, 7, -7,
- 1, -1, 1, 8, -1, 4, -4, -8, 2, -2, 9, 3, -9, -3, 1, -1,
- 5, -5, 10, 2, -10, -2, 1, -1, 11, -11, 1, -1, -4, 2, 4, 3,
- -3, -2, 6, -6, 12, 1, -12, -1, 2, 1, -2, -1, 13, -13, 2, -2,
- 7, -7, 1, -1, 1, 1, -1, 3, -3, 14, 5, -1, -14, -5, 4, -4,
- 15, -15, 1, -1, 8, -8, -3, 3, 16, 1, -16, -1, 1, 1, -1, -1,
- 1, 1, -1, 1, 2, 1, -2, 1, -1, -1, -1, 6, -1, 3, -6, 17,
- -17, -3, 1, 1, 1, 4, -1, -1, -4, 3, -1, 5, -3, -1, -9, 9,
- -5, 1, 18, -18, 2, 1, -2, 1, -1, -1, 1, 19, -1, 1, -19, -1,
- 4, 1, -1, 1, 7, -4, -2, 2, -7, 10, -1, -10, 1, 20, -1, -20,
- 1, -1, 2, 4, -2, 5, 1, -5, 6, -4, 21, 4, 2, -6, -21, -1,
- -2, 1, -4, -1, -3, 22, -1, 1, 3, -22, -1, 11, -11, 1, 1, 1,
- 8, -8, 2, 2, -1, -2, -2, -1, 1, -1, -5, 5, 2, 23, -23, -2,
- 1, -1, 24, -24, -1, -1, 7, 6, -7, 5, -6, 12, -3, 3, 1, -5,
- 1, 1, -12, 25, -1, -5, 5, -25, -1, 1, 9, 1, -1, -9, 26, -26}
-}
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/ivi_common.h b/src/thirdparty/ffmpeg/libavcodec/ivi_common.h
deleted file mode 100644
index 106e3664c..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/ivi_common.h
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- * common functions for Indeo Video Interactive codecs (Indeo4 and Indeo5)
- *
- * Copyright (c) 2009 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
- * This file contains structures and macros shared by both Indeo4 and
- * Indeo5 decoders.
- */
-
-#ifndef AVCODEC_IVI_COMMON_H
-#define AVCODEC_IVI_COMMON_H
-
-#include "avcodec.h"
-#include "get_bits.h"
-#include <stdint.h>
-
-#define IVI_VLC_BITS 13 ///< max number of bits of the ivi's huffman codes
-#define IVI4_STREAM_ANALYSER 0
-#define IVI5_IS_PROTECTED 0x20
-
-/**
- * huffman codebook descriptor
- */
-typedef struct IVIHuffDesc {
- int32_t num_rows;
- uint8_t xbits[16];
-} IVIHuffDesc;
-
-/**
- * macroblock/block huffman table descriptor
- */
-typedef struct IVIHuffTab {
- int32_t tab_sel; /// index of one of the predefined tables
- /// or "7" for custom one
- VLC *tab; /// pointer to the table associated with tab_sel
-
- /// the following are used only when tab_sel == 7
- IVIHuffDesc cust_desc; /// custom Huffman codebook descriptor
- VLC cust_tab; /// vlc table for custom codebook
-} IVIHuffTab;
-
-enum {
- IVI_MB_HUFF = 0, /// Huffman table is used for coding macroblocks
- IVI_BLK_HUFF = 1 /// Huffman table is used for coding blocks
-};
-
-
-/**
- * Common scan patterns (defined in ivi_common.c)
- */
-extern const uint8_t ff_ivi_vertical_scan_8x8[64];
-extern const uint8_t ff_ivi_horizontal_scan_8x8[64];
-extern const uint8_t ff_ivi_direct_scan_4x4[16];
-
-
-/**
- * Declare inverse transform function types
- */
-typedef void (InvTransformPtr)(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags);
-typedef void (DCTransformPtr) (const int32_t *in, int16_t *out, uint32_t pitch, int blk_size);
-
-
-/**
- * run-value (RLE) table descriptor
- */
-typedef struct RVMapDesc {
- uint8_t eob_sym; ///< end of block symbol
- uint8_t esc_sym; ///< escape symbol
- uint8_t runtab[256];
- int8_t valtab[256];
-} RVMapDesc;
-
-extern const RVMapDesc ff_ivi_rvmap_tabs[9];
-
-
-/**
- * information for Indeo macroblock (16x16, 8x8 or 4x4)
- */
-typedef struct IVIMbInfo {
- int16_t xpos;
- int16_t ypos;
- uint32_t buf_offs; ///< address in the output buffer for this mb
- uint8_t type; ///< macroblock type: 0 - INTRA, 1 - INTER
- uint8_t cbp; ///< coded block pattern
- int8_t q_delta; ///< quant delta
- int8_t mv_x; ///< motion vector (x component)
- int8_t mv_y; ///< motion vector (y component)
-} IVIMbInfo;
-
-
-/**
- * information for Indeo tile
- */
-typedef struct IVITile {
- int xpos;
- int ypos;
- int width;
- int height;
- int mb_size;
- int is_empty; ///< = 1 if this tile doesn't contain any data
- int data_size; ///< size of the data in bytes
- int num_MBs; ///< number of macroblocks in this tile
- IVIMbInfo *mbs; ///< array of macroblock descriptors
- IVIMbInfo *ref_mbs; ///< ptr to the macroblock descriptors of the reference tile
-} IVITile;
-
-
-/**
- * information for Indeo wavelet band
- */
-typedef struct IVIBandDesc {
- int plane; ///< plane number this band belongs to
- int band_num; ///< band number
- int width;
- int height;
- int aheight; ///< aligned band height
- const uint8_t *data_ptr; ///< ptr to the first byte of the band data
- int data_size; ///< size of the band data
- int16_t *buf; ///< pointer to the output buffer for this band
- int16_t *ref_buf; ///< pointer to the reference frame buffer (for motion compensation)
- int16_t *bufs[3]; ///< array of pointers to the band buffers
- int pitch; ///< pitch associated with the buffers above
- int is_empty; ///< = 1 if this band doesn't contain any data
- int mb_size; ///< macroblock size
- int blk_size; ///< block size
- int is_halfpel; ///< precision of the motion compensation: 0 - fullpel, 1 - halfpel
- int inherit_mv; ///< tells if motion vector is inherited from reference macroblock
- int inherit_qdelta; ///< tells if quantiser delta is inherited from reference macroblock
- int qdelta_present; ///< tells if Qdelta signal is present in the bitstream (Indeo5 only)
- int quant_mat; ///< dequant matrix index
- int glob_quant; ///< quant base for this band
- const uint8_t *scan; ///< ptr to the scan pattern
- int scan_size; ///< size of the scantable
-
- IVIHuffTab blk_vlc; ///< vlc table for decoding block data
-
- int num_corr; ///< number of correction entries
- uint8_t corr[61*2]; ///< rvmap correction pairs
- int rvmap_sel; ///< rvmap table selector
- RVMapDesc *rv_map; ///< ptr to the RLE table for this band
- int num_tiles; ///< number of tiles in this band
- IVITile *tiles; ///< array of tile descriptors
- InvTransformPtr *inv_transform;
- DCTransformPtr *dc_transform;
- int is_2d_trans; ///< 1 indicates that the two-dimensional inverse transform is used
- int transform_size; ///< block size of the transform
- int32_t checksum; ///< for debug purposes
- int checksum_present;
- int bufsize; ///< band buffer size in bytes
- const uint16_t *intra_base; ///< quantization matrix for intra blocks
- const uint16_t *inter_base; ///< quantization matrix for inter blocks
- const uint8_t *intra_scale; ///< quantization coefficient for intra blocks
- const uint8_t *inter_scale; ///< quantization coefficient for inter blocks
-} IVIBandDesc;
-
-
-/**
- * color plane (luma or chroma) information
- */
-typedef struct IVIPlaneDesc {
- uint16_t width;
- uint16_t height;
- uint8_t num_bands; ///< number of bands this plane subdivided into
- IVIBandDesc *bands; ///< array of band descriptors
-} IVIPlaneDesc;
-
-
-typedef struct IVIPicConfig {
- uint16_t pic_width;
- uint16_t pic_height;
- uint16_t chroma_width;
- uint16_t chroma_height;
- uint16_t tile_width;
- uint16_t tile_height;
- uint8_t luma_bands;
- uint8_t chroma_bands;
-} IVIPicConfig;
-
-typedef struct IVI45DecContext {
- GetBitContext gb;
- AVFrame frame;
- RVMapDesc rvmap_tabs[9]; ///< local corrected copy of the static rvmap tables
-
- uint32_t frame_num;
- int frame_type;
- int prev_frame_type; ///< frame type of the previous frame
- uint32_t data_size; ///< size of the frame data in bytes from picture header
- int is_scalable;
- int transp_status; ///< transparency mode status: 1 - enabled
- const uint8_t *frame_data; ///< input frame data pointer
- int inter_scal; ///< signals a sequence of scalable inter frames
- uint32_t frame_size; ///< frame size in bytes
- uint32_t pic_hdr_size; ///< picture header size in bytes
- uint8_t frame_flags;
- uint16_t checksum; ///< frame checksum
-
- IVIPicConfig pic_conf;
- IVIPlaneDesc planes[3]; ///< color planes
-
- int buf_switch; ///< used to switch between three buffers
- int dst_buf; ///< buffer index for the currently decoded frame
- int ref_buf; ///< inter frame reference buffer index
- int ref2_buf; ///< temporal storage for switching buffers
-
- IVIHuffTab mb_vlc; ///< current macroblock table descriptor
- IVIHuffTab blk_vlc; ///< current block table descriptor
-
- uint8_t rvmap_sel;
- uint8_t in_imf;
- uint8_t in_q; ///< flag for explicitly stored quantiser delta
- uint8_t pic_glob_quant;
- uint8_t unknown1;
-
- uint16_t gop_hdr_size;
- uint8_t gop_flags;
- uint32_t lock_word;
-
-#if IVI4_STREAM_ANALYSER
- uint8_t has_b_frames;
- uint8_t has_transp;
- uint8_t uses_tiling;
- uint8_t uses_haar;
- uint8_t uses_fullpel;
-#endif
-
- int (*decode_pic_hdr) (struct IVI45DecContext *ctx, AVCodecContext *avctx);
- int (*decode_band_hdr) (struct IVI45DecContext *ctx, IVIBandDesc *band, AVCodecContext *avctx);
- int (*decode_mb_info) (struct IVI45DecContext *ctx, IVIBandDesc *band, IVITile *tile, AVCodecContext *avctx);
- void (*switch_buffers) (struct IVI45DecContext *ctx);
- int (*is_nonnull_frame)(struct IVI45DecContext *ctx);
-
- int gop_invalid;
- int buf_invalid[3];
-} IVI45DecContext;
-
-/** compare some properties of two pictures */
-static inline int ivi_pic_config_cmp(IVIPicConfig *str1, IVIPicConfig *str2)
-{
- return str1->pic_width != str2->pic_width || str1->pic_height != str2->pic_height ||
- str1->chroma_width != str2->chroma_width || str1->chroma_height != str2->chroma_height ||
- str1->tile_width != str2->tile_width || str1->tile_height != str2->tile_height ||
- str1->luma_bands != str2->luma_bands || str1->chroma_bands != str2->chroma_bands;
-}
-
-/** calculate number of tiles in a stride */
-#define IVI_NUM_TILES(stride, tile_size) (((stride) + (tile_size) - 1) / (tile_size))
-
-/** calculate number of macroblocks in a tile */
-#define IVI_MBs_PER_TILE(tile_width, tile_height, mb_size) \
- ((((tile_width) + (mb_size) - 1) / (mb_size)) * (((tile_height) + (mb_size) - 1) / (mb_size)))
-
-/** convert unsigned values into signed ones (the sign is in the LSB) */
-#define IVI_TOSIGNED(val) (-(((val) >> 1) ^ -((val) & 1)))
-
-/** scale motion vector */
-static inline int ivi_scale_mv(int mv, int mv_scale)
-{
- return (mv + (mv > 0) + (mv_scale - 1)) >> mv_scale;
-}
-
-/**
- * Initialize static codes used for macroblock and block decoding.
- */
-void ff_ivi_init_static_vlc(void);
-
-/**
- * Decode a huffman codebook descriptor from the bitstream
- * and select specified huffman table.
- *
- * @param[in,out] gb the GetBit context
- * @param[in] desc_coded flag signalling if table descriptor was coded
- * @param[in] which_tab codebook purpose (IVI_MB_HUFF or IVI_BLK_HUFF)
- * @param[out] huff_tab pointer to the descriptor of the selected table
- * @param[in] avctx AVCodecContext pointer
- * @return zero on success, negative value otherwise
- */
-int ff_ivi_dec_huff_desc(GetBitContext *gb, int desc_coded, int which_tab,
- IVIHuffTab *huff_tab, AVCodecContext *avctx);
-
-/**
- * Initialize planes (prepares descriptors, allocates buffers etc).
- *
- * @param[in,out] planes pointer to the array of the plane descriptors
- * @param[in] cfg pointer to the ivi_pic_config structure describing picture layout
- * @return result code: 0 - OK
- */
-int ff_ivi_init_planes(IVIPlaneDesc *planes, const IVIPicConfig *cfg);
-
-/**
- * Initialize tile and macroblock descriptors.
- *
- * @param[in,out] planes pointer to the array of the plane descriptors
- * @param[in] tile_width tile width
- * @param[in] tile_height tile height
- * @return result code: 0 - OK
- */
-int ff_ivi_init_tiles(IVIPlaneDesc *planes, int tile_width, int tile_height);
-
-int ff_ivi_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
- AVPacket *avpkt);
-av_cold int ff_ivi_decode_close(AVCodecContext *avctx);
-
-#endif /* AVCODEC_IVI_COMMON_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/ivi_dsp.c b/src/thirdparty/ffmpeg/libavcodec/ivi_dsp.c
deleted file mode 100644
index c1dda99ed..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/ivi_dsp.c
+++ /dev/null
@@ -1,624 +0,0 @@
-/*
- * DSP functions for Indeo Video Interactive codecs (Indeo4 and Indeo5)
- *
- * Copyright (c) 2009-2011 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 (inverse transforms, motion compensation, wavelet recompostions)
- * for Indeo Video Interactive codecs.
- */
-
-#include "avcodec.h"
-#include "dsputil.h"
-#include "ivi_common.h"
-#include "ivi_dsp.h"
-
-void ff_ivi_recompose53(const IVIPlaneDesc *plane, uint8_t *dst,
- const int dst_pitch)
-{
- int x, y, indx;
- int32_t p0, p1, p2, p3, tmp0, tmp1, tmp2;
- int32_t b0_1, b0_2, b1_1, b1_2, b1_3, b2_1, b2_2, b2_3, b2_4, b2_5, b2_6;
- int32_t b3_1, b3_2, b3_3, b3_4, b3_5, b3_6, b3_7, b3_8, b3_9;
- int32_t pitch, back_pitch;
- const short *b0_ptr, *b1_ptr, *b2_ptr, *b3_ptr;
- const int num_bands = 4;
-
- /* all bands should have the same pitch */
- pitch = plane->bands[0].pitch;
-
- /* pixels at the position "y-1" will be set to pixels at the "y" for the 1st iteration */
- back_pitch = 0;
-
- /* get pointers to the wavelet bands */
- b0_ptr = plane->bands[0].buf;
- b1_ptr = plane->bands[1].buf;
- b2_ptr = plane->bands[2].buf;
- b3_ptr = plane->bands[3].buf;
-
- for (y = 0; y < plane->height; y += 2) {
-
- if (y+2 >= plane->height)
- pitch= 0;
- /* load storage variables with values */
- if (num_bands > 0) {
- b0_1 = b0_ptr[0];
- b0_2 = b0_ptr[pitch];
- }
-
- if (num_bands > 1) {
- b1_1 = b1_ptr[back_pitch];
- b1_2 = b1_ptr[0];
- b1_3 = b1_1 - b1_2*6 + b1_ptr[pitch];
- }
-
- if (num_bands > 2) {
- b2_2 = b2_ptr[0]; // b2[x, y ]
- b2_3 = b2_2; // b2[x+1,y ] = b2[x,y]
- b2_5 = b2_ptr[pitch]; // b2[x ,y+1]
- b2_6 = b2_5; // b2[x+1,y+1] = b2[x,y+1]
- }
-
- if (num_bands > 3) {
- b3_2 = b3_ptr[back_pitch]; // b3[x ,y-1]
- b3_3 = b3_2; // b3[x+1,y-1] = b3[x ,y-1]
- b3_5 = b3_ptr[0]; // b3[x ,y ]
- b3_6 = b3_5; // b3[x+1,y ] = b3[x ,y ]
- b3_8 = b3_2 - b3_5*6 + b3_ptr[pitch];
- b3_9 = b3_8;
- }
-
- for (x = 0, indx = 0; x < plane->width; x+=2, indx++) {
- if (x+2 >= plane->width) {
- b0_ptr --;
- b1_ptr --;
- b2_ptr --;
- b3_ptr --;
- }
-
- /* some values calculated in the previous iterations can */
- /* be reused in the next ones, so do appropriate copying */
- b2_1 = b2_2; // b2[x-1,y ] = b2[x, y ]
- b2_2 = b2_3; // b2[x ,y ] = b2[x+1,y ]
- b2_4 = b2_5; // b2[x-1,y+1] = b2[x ,y+1]
- b2_5 = b2_6; // b2[x ,y+1] = b2[x+1,y+1]
- b3_1 = b3_2; // b3[x-1,y-1] = b3[x ,y-1]
- b3_2 = b3_3; // b3[x ,y-1] = b3[x+1,y-1]
- b3_4 = b3_5; // b3[x-1,y ] = b3[x ,y ]
- b3_5 = b3_6; // b3[x ,y ] = b3[x+1,y ]
- b3_7 = b3_8; // vert_HPF(x-1)
- b3_8 = b3_9; // vert_HPF(x )
-
- p0 = p1 = p2 = p3 = 0;
-
- /* process the LL-band by applying LPF both vertically and horizontally */
- if (num_bands > 0) {
- tmp0 = b0_1;
- tmp2 = b0_2;
- b0_1 = b0_ptr[indx+1];
- b0_2 = b0_ptr[pitch+indx+1];
- tmp1 = tmp0 + b0_1;
-
- p0 = tmp0 << 4;
- p1 = tmp1 << 3;
- p2 = (tmp0 + tmp2) << 3;
- p3 = (tmp1 + tmp2 + b0_2) << 2;
- }
-
- /* process the HL-band by applying HPF vertically and LPF horizontally */
- if (num_bands > 1) {
- tmp0 = b1_2;
- tmp1 = b1_1;
- b1_2 = b1_ptr[indx+1];
- b1_1 = b1_ptr[back_pitch+indx+1];
-
- tmp2 = tmp1 - tmp0*6 + b1_3;
- b1_3 = b1_1 - b1_2*6 + b1_ptr[pitch+indx+1];
-
- p0 += (tmp0 + tmp1) << 3;
- p1 += (tmp0 + tmp1 + b1_1 + b1_2) << 2;
- p2 += tmp2 << 2;
- p3 += (tmp2 + b1_3) << 1;
- }
-
- /* process the LH-band by applying LPF vertically and HPF horizontally */
- if (num_bands > 2) {
- b2_3 = b2_ptr[indx+1];
- b2_6 = b2_ptr[pitch+indx+1];
-
- tmp0 = b2_1 + b2_2;
- tmp1 = b2_1 - b2_2*6 + b2_3;
-
- p0 += tmp0 << 3;
- p1 += tmp1 << 2;
- p2 += (tmp0 + b2_4 + b2_5) << 2;
- p3 += (tmp1 + b2_4 - b2_5*6 + b2_6) << 1;
- }
-
- /* process the HH-band by applying HPF both vertically and horizontally */
- if (num_bands > 3) {
- b3_6 = b3_ptr[indx+1]; // b3[x+1,y ]
- b3_3 = b3_ptr[back_pitch+indx+1]; // b3[x+1,y-1]
-
- tmp0 = b3_1 + b3_4;
- tmp1 = b3_2 + b3_5;
- tmp2 = b3_3 + b3_6;
-
- b3_9 = b3_3 - b3_6*6 + b3_ptr[pitch+indx+1];
-
- p0 += (tmp0 + tmp1) << 2;
- p1 += (tmp0 - tmp1*6 + tmp2) << 1;
- p2 += (b3_7 + b3_8) << 1;
- p3 += b3_7 - b3_8*6 + b3_9;
- }
-
- /* output four pixels */
- dst[x] = av_clip_uint8((p0 >> 6) + 128);
- dst[x+1] = av_clip_uint8((p1 >> 6) + 128);
- dst[dst_pitch+x] = av_clip_uint8((p2 >> 6) + 128);
- dst[dst_pitch+x+1] = av_clip_uint8((p3 >> 6) + 128);
- }// for x
-
- dst += dst_pitch << 1;
-
- back_pitch = -pitch;
-
- b0_ptr += pitch + 1;
- b1_ptr += pitch + 1;
- b2_ptr += pitch + 1;
- b3_ptr += pitch + 1;
- }
-}
-
-void ff_ivi_recompose_haar(const IVIPlaneDesc *plane, uint8_t *dst,
- const int dst_pitch)
-{
- int x, y, indx, b0, b1, b2, b3, p0, p1, p2, p3;
- const short *b0_ptr, *b1_ptr, *b2_ptr, *b3_ptr;
- int32_t pitch;
-
- /* all bands should have the same pitch */
- pitch = plane->bands[0].pitch;
-
- /* get pointers to the wavelet bands */
- b0_ptr = plane->bands[0].buf;
- b1_ptr = plane->bands[1].buf;
- b2_ptr = plane->bands[2].buf;
- b3_ptr = plane->bands[3].buf;
-
- for (y = 0; y < plane->height; y += 2) {
- for (x = 0, indx = 0; x < plane->width; x += 2, indx++) {
- /* load coefficients */
- b0 = b0_ptr[indx]; //should be: b0 = (num_bands > 0) ? b0_ptr[indx] : 0;
- b1 = b1_ptr[indx]; //should be: b1 = (num_bands > 1) ? b1_ptr[indx] : 0;
- b2 = b2_ptr[indx]; //should be: b2 = (num_bands > 2) ? b2_ptr[indx] : 0;
- b3 = b3_ptr[indx]; //should be: b3 = (num_bands > 3) ? b3_ptr[indx] : 0;
-
- /* haar wavelet recomposition */
- p0 = (b0 + b1 + b2 + b3 + 2) >> 2;
- p1 = (b0 + b1 - b2 - b3 + 2) >> 2;
- p2 = (b0 - b1 + b2 - b3 + 2) >> 2;
- p3 = (b0 - b1 - b2 + b3 + 2) >> 2;
-
- /* bias, convert and output four pixels */
- dst[x] = av_clip_uint8(p0 + 128);
- dst[x + 1] = av_clip_uint8(p1 + 128);
- dst[dst_pitch + x] = av_clip_uint8(p2 + 128);
- dst[dst_pitch + x + 1] = av_clip_uint8(p3 + 128);
- }// for x
-
- dst += dst_pitch << 1;
-
- b0_ptr += pitch;
- b1_ptr += pitch;
- b2_ptr += pitch;
- b3_ptr += pitch;
- }// for y
-}
-
-/** butterfly operation for the inverse Haar transform */
-#define IVI_HAAR_BFLY(s1, s2, o1, o2, t) \
- t = (s1 - s2) >> 1;\
- o1 = (s1 + s2) >> 1;\
- o2 = t;\
-
-/** inverse 8-point Haar transform */
-#define INV_HAAR8(s1, s5, s3, s7, s2, s4, s6, s8,\
- d1, d2, d3, d4, d5, d6, d7, d8,\
- t0, t1, t2, t3, t4, t5, t6, t7, t8) {\
- t1 = s1 << 1; t5 = s5 << 1;\
- IVI_HAAR_BFLY(t1, t5, t1, t5, t0); IVI_HAAR_BFLY(t1, s3, t1, t3, t0);\
- IVI_HAAR_BFLY(t5, s7, t5, t7, t0); IVI_HAAR_BFLY(t1, s2, t1, t2, t0);\
- IVI_HAAR_BFLY(t3, s4, t3, t4, t0); IVI_HAAR_BFLY(t5, s6, t5, t6, t0);\
- IVI_HAAR_BFLY(t7, s8, t7, t8, t0);\
- d1 = COMPENSATE(t1);\
- d2 = COMPENSATE(t2);\
- d3 = COMPENSATE(t3);\
- d4 = COMPENSATE(t4);\
- d5 = COMPENSATE(t5);\
- d6 = COMPENSATE(t6);\
- d7 = COMPENSATE(t7);\
- d8 = COMPENSATE(t8); }
-
-/** inverse 4-point Haar transform */
-#define INV_HAAR4(s1, s3, s5, s7) {\
- HAAR_BFLY(s1, s5); HAAR_BFLY(s1, s3); HAAR_BFLY(s5, s7);\
- s1 = COMPENSATE(s1);\
- s3 = COMPENSATE(s3);\
- s5 = COMPENSATE(s5);\
- s7 = COMPENSATE(s7); }
-
-void ff_ivi_inverse_haar_8x8(const int32_t *in, int16_t *out, uint32_t pitch,
- const uint8_t *flags)
-{
- int i, shift, sp1, sp2, sp3, sp4;
- const int32_t *src;
- int32_t *dst;
- int tmp[64];
- int t0, t1, t2, t3, t4, t5, t6, t7, t8;
-
- /* apply the InvHaar8 to all columns */
-#define COMPENSATE(x) (x)
- src = in;
- dst = tmp;
- for (i = 0; i < 8; i++) {
- if (flags[i]) {
- /* pre-scaling */
- shift = !(i & 4);
- sp1 = src[ 0] << shift;
- sp2 = src[ 8] << shift;
- sp3 = src[16] << shift;
- sp4 = src[24] << shift;
- INV_HAAR8( sp1, sp2, sp3, sp4,
- src[32], src[40], src[48], src[56],
- dst[ 0], dst[ 8], dst[16], dst[24],
- dst[32], dst[40], dst[48], dst[56],
- t0, t1, t2, t3, t4, t5, t6, t7, t8);
- } else
- dst[ 0] = dst[ 8] = dst[16] = dst[24] =
- dst[32] = dst[40] = dst[48] = dst[56] = 0;
-
- src++;
- dst++;
- }
-#undef COMPENSATE
-
- /* apply the InvHaar8 to all rows */
-#define COMPENSATE(x) (x)
- src = tmp;
- for (i = 0; i < 8; i++) {
- if ( !src[0] && !src[1] && !src[2] && !src[3]
- && !src[4] && !src[5] && !src[6] && !src[7]) {
- memset(out, 0, 8 * sizeof(out[0]));
- } else {
- INV_HAAR8(src[0], src[1], src[2], src[3],
- src[4], src[5], src[6], src[7],
- out[0], out[1], out[2], out[3],
- out[4], out[5], out[6], out[7],
- t0, t1, t2, t3, t4, t5, t6, t7, t8);
- }
- src += 8;
- out += pitch;
- }
-#undef COMPENSATE
-}
-
-void ff_ivi_dc_haar_2d(const int32_t *in, int16_t *out, uint32_t pitch,
- int blk_size)
-{
- int x, y;
- int16_t dc_coeff;
-
- dc_coeff = (*in + 0) >> 3;
-
- for (y = 0; y < blk_size; out += pitch, y++) {
- for (x = 0; x < blk_size; x++)
- out[x] = dc_coeff;
- }
-}
-
-/** butterfly operation for the inverse slant transform */
-#define IVI_SLANT_BFLY(s1, s2, o1, o2, t) \
- t = s1 - s2;\
- o1 = s1 + s2;\
- o2 = t;\
-
-/** This is a reflection a,b = 1/2, 5/4 for the inverse slant transform */
-#define IVI_IREFLECT(s1, s2, o1, o2, t) \
- t = ((s1 + s2*2 + 2) >> 2) + s1;\
- o2 = ((s1*2 - s2 + 2) >> 2) - s2;\
- o1 = t;\
-
-/** This is a reflection a,b = 1/2, 7/8 for the inverse slant transform */
-#define IVI_SLANT_PART4(s1, s2, o1, o2, t) \
- t = s2 + ((s1*4 - s2 + 4) >> 3);\
- o2 = s1 + ((-s1 - s2*4 + 4) >> 3);\
- o1 = t;\
-
-/** inverse slant8 transform */
-#define IVI_INV_SLANT8(s1, s4, s8, s5, s2, s6, s3, s7,\
- d1, d2, d3, d4, d5, d6, d7, d8,\
- t0, t1, t2, t3, t4, t5, t6, t7, t8) {\
- IVI_SLANT_PART4(s4, s5, t4, t5, t0);\
-\
- IVI_SLANT_BFLY(s1, t5, t1, t5, t0); IVI_SLANT_BFLY(s2, s6, t2, t6, t0);\
- IVI_SLANT_BFLY(s7, s3, t7, t3, t0); IVI_SLANT_BFLY(t4, s8, t4, t8, t0);\
-\
- IVI_SLANT_BFLY(t1, t2, t1, t2, t0); IVI_IREFLECT (t4, t3, t4, t3, t0);\
- IVI_SLANT_BFLY(t5, t6, t5, t6, t0); IVI_IREFLECT (t8, t7, t8, t7, t0);\
- IVI_SLANT_BFLY(t1, t4, t1, t4, t0); IVI_SLANT_BFLY(t2, t3, t2, t3, t0);\
- IVI_SLANT_BFLY(t5, t8, t5, t8, t0); IVI_SLANT_BFLY(t6, t7, t6, t7, t0);\
- d1 = COMPENSATE(t1);\
- d2 = COMPENSATE(t2);\
- d3 = COMPENSATE(t3);\
- d4 = COMPENSATE(t4);\
- d5 = COMPENSATE(t5);\
- d6 = COMPENSATE(t6);\
- d7 = COMPENSATE(t7);\
- d8 = COMPENSATE(t8);}
-
-/** inverse slant4 transform */
-#define IVI_INV_SLANT4(s1, s4, s2, s3, d1, d2, d3, d4, t0, t1, t2, t3, t4) {\
- IVI_SLANT_BFLY(s1, s2, t1, t2, t0); IVI_IREFLECT (s4, s3, t4, t3, t0);\
-\
- IVI_SLANT_BFLY(t1, t4, t1, t4, t0); IVI_SLANT_BFLY(t2, t3, t2, t3, t0);\
- d1 = COMPENSATE(t1);\
- d2 = COMPENSATE(t2);\
- d3 = COMPENSATE(t3);\
- d4 = COMPENSATE(t4);}
-
-void ff_ivi_inverse_slant_8x8(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags)
-{
- int i;
- const int32_t *src;
- int32_t *dst;
- int tmp[64];
- int t0, t1, t2, t3, t4, t5, t6, t7, t8;
-
-#define COMPENSATE(x) (x)
- src = in;
- dst = tmp;
- for (i = 0; i < 8; i++) {
- if (flags[i]) {
- IVI_INV_SLANT8(src[0], src[8], src[16], src[24], src[32], src[40], src[48], src[56],
- dst[0], dst[8], dst[16], dst[24], dst[32], dst[40], dst[48], dst[56],
- t0, t1, t2, t3, t4, t5, t6, t7, t8);
- } else
- dst[0] = dst[8] = dst[16] = dst[24] = dst[32] = dst[40] = dst[48] = dst[56] = 0;
-
- src++;
- dst++;
- }
-#undef COMPENSATE
-
-#define COMPENSATE(x) ((x + 1)>>1)
- src = tmp;
- for (i = 0; i < 8; i++) {
- if (!src[0] && !src[1] && !src[2] && !src[3] && !src[4] && !src[5] && !src[6] && !src[7]) {
- memset(out, 0, 8*sizeof(out[0]));
- } else {
- IVI_INV_SLANT8(src[0], src[1], src[2], src[3], src[4], src[5], src[6], src[7],
- out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7],
- t0, t1, t2, t3, t4, t5, t6, t7, t8);
- }
- src += 8;
- out += pitch;
- }
-#undef COMPENSATE
-}
-
-void ff_ivi_inverse_slant_4x4(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags)
-{
- int i;
- const int32_t *src;
- int32_t *dst;
- int tmp[16];
- int t0, t1, t2, t3, t4;
-
-#define COMPENSATE(x) (x)
- src = in;
- dst = tmp;
- for (i = 0; i < 4; i++) {
- if (flags[i]) {
- IVI_INV_SLANT4(src[0], src[4], src[8], src[12],
- dst[0], dst[4], dst[8], dst[12],
- t0, t1, t2, t3, t4);
- } else
- dst[0] = dst[4] = dst[8] = dst[12] = 0;
-
- src++;
- dst++;
- }
-#undef COMPENSATE
-
-#define COMPENSATE(x) ((x + 1)>>1)
- src = tmp;
- for (i = 0; i < 4; i++) {
- if (!src[0] && !src[1] && !src[2] && !src[3]) {
- out[0] = out[1] = out[2] = out[3] = 0;
- } else {
- IVI_INV_SLANT4(src[0], src[1], src[2], src[3],
- out[0], out[1], out[2], out[3],
- t0, t1, t2, t3, t4);
- }
- src += 4;
- out += pitch;
- }
-#undef COMPENSATE
-}
-
-void ff_ivi_dc_slant_2d(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size)
-{
- int x, y;
- int16_t dc_coeff;
-
- dc_coeff = (*in + 1) >> 1;
-
- for (y = 0; y < blk_size; out += pitch, y++) {
- for (x = 0; x < blk_size; x++)
- out[x] = dc_coeff;
- }
-}
-
-void ff_ivi_row_slant8(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags)
-{
- int i;
- int t0, t1, t2, t3, t4, t5, t6, t7, t8;
-
-#define COMPENSATE(x) ((x + 1)>>1)
- for (i = 0; i < 8; i++) {
- if (!in[0] && !in[1] && !in[2] && !in[3] && !in[4] && !in[5] && !in[6] && !in[7]) {
- memset(out, 0, 8*sizeof(out[0]));
- } else {
- IVI_INV_SLANT8( in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7],
- out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7],
- t0, t1, t2, t3, t4, t5, t6, t7, t8);
- }
- in += 8;
- out += pitch;
- }
-#undef COMPENSATE
-}
-
-void ff_ivi_dc_row_slant(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size)
-{
- int x, y;
- int16_t dc_coeff;
-
- dc_coeff = (*in + 1) >> 1;
-
- for (x = 0; x < blk_size; x++)
- out[x] = dc_coeff;
-
- out += pitch;
-
- for (y = 1; y < blk_size; out += pitch, y++) {
- for (x = 0; x < blk_size; x++)
- out[x] = 0;
- }
-}
-
-void ff_ivi_col_slant8(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags)
-{
- int i, row2, row4, row8;
- int t0, t1, t2, t3, t4, t5, t6, t7, t8;
-
- row2 = pitch << 1;
- row4 = pitch << 2;
- row8 = pitch << 3;
-
-#define COMPENSATE(x) ((x + 1)>>1)
- for (i = 0; i < 8; i++) {
- if (flags[i]) {
- IVI_INV_SLANT8(in[0], in[8], in[16], in[24], in[32], in[40], in[48], in[56],
- out[0], out[pitch], out[row2], out[row2 + pitch], out[row4],
- out[row4 + pitch], out[row4 + row2], out[row8 - pitch],
- t0, t1, t2, t3, t4, t5, t6, t7, t8);
- } else {
- out[0] = out[pitch] = out[row2] = out[row2 + pitch] = out[row4] =
- out[row4 + pitch] = out[row4 + row2] = out[row8 - pitch] = 0;
- }
-
- in++;
- out++;
- }
-#undef COMPENSATE
-}
-
-void ff_ivi_dc_col_slant(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size)
-{
- int x, y;
- int16_t dc_coeff;
-
- dc_coeff = (*in + 1) >> 1;
-
- for (y = 0; y < blk_size; out += pitch, y++) {
- out[0] = dc_coeff;
- for (x = 1; x < blk_size; x++)
- out[x] = 0;
- }
-}
-
-void ff_ivi_put_pixels_8x8(const int32_t *in, int16_t *out, uint32_t pitch,
- const uint8_t *flags)
-{
- int x, y;
-
- for (y = 0; y < 8; out += pitch, in += 8, y++)
- for (x = 0; x < 8; x++)
- out[x] = in[x];
-}
-
-void ff_ivi_put_dc_pixel_8x8(const int32_t *in, int16_t *out, uint32_t pitch,
- int blk_size)
-{
- int y;
-
- out[0] = in[0];
- memset(out + 1, 0, 7*sizeof(out[0]));
- out += pitch;
-
- for (y = 1; y < 8; out += pitch, y++)
- memset(out, 0, 8*sizeof(out[0]));
-}
-
-#define IVI_MC_TEMPLATE(size, suffix, OP) \
-void ff_ivi_mc_ ## size ##x## size ## suffix (int16_t *buf, const int16_t *ref_buf, \
- uint32_t pitch, int mc_type) \
-{ \
- int i, j; \
- const int16_t *wptr; \
-\
- switch (mc_type) { \
- case 0: /* fullpel (no interpolation) */ \
- for (i = 0; i < size; i++, buf += pitch, ref_buf += pitch) { \
- for (j = 0; j < size; j++) {\
- OP(buf[j], ref_buf[j]); \
- } \
- } \
- break; \
- case 1: /* horizontal halfpel interpolation */ \
- for (i = 0; i < size; i++, buf += pitch, ref_buf += pitch) \
- for (j = 0; j < size; j++) \
- OP(buf[j], (ref_buf[j] + ref_buf[j+1]) >> 1); \
- break; \
- case 2: /* vertical halfpel interpolation */ \
- wptr = ref_buf + pitch; \
- for (i = 0; i < size; i++, buf += pitch, wptr += pitch, ref_buf += pitch) \
- for (j = 0; j < size; j++) \
- OP(buf[j], (ref_buf[j] + wptr[j]) >> 1); \
- break; \
- case 3: /* vertical and horizontal halfpel interpolation */ \
- wptr = ref_buf + pitch; \
- for (i = 0; i < size; i++, buf += pitch, wptr += pitch, ref_buf += pitch) \
- for (j = 0; j < size; j++) \
- OP(buf[j], (ref_buf[j] + ref_buf[j+1] + wptr[j] + wptr[j+1]) >> 2); \
- break; \
- } \
-} \
-
-#define OP_PUT(a, b) (a) = (b)
-#define OP_ADD(a, b) (a) += (b)
-
-IVI_MC_TEMPLATE(8, _no_delta, OP_PUT)
-IVI_MC_TEMPLATE(8, _delta, OP_ADD)
-IVI_MC_TEMPLATE(4, _no_delta, OP_PUT)
-IVI_MC_TEMPLATE(4, _delta, OP_ADD)
diff --git a/src/thirdparty/ffmpeg/libavcodec/ivi_dsp.h b/src/thirdparty/ffmpeg/libavcodec/ivi_dsp.h
deleted file mode 100644
index 5b778698c..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/ivi_dsp.h
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * DSP functions for Indeo Video Interactive codecs (Indeo4 and Indeo5)
- *
- * Copyright (c) 2009-2011 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 (inverse transforms, motion compensations, wavelet recompostion)
- * for Indeo Video Interactive codecs.
- */
-
-#ifndef AVCODEC_IVI_DSP_H
-#define AVCODEC_IVI_DSP_H
-
-#include "avcodec.h"
-#include "ivi_common.h"
-
-/**
- * 5/3 wavelet recomposition filter for Indeo5
- *
- * @param[in] plane pointer to the descriptor of the plane being processed
- * @param[out] dst pointer to the destination buffer
- * @param[in] dst_pitch pitch of the destination buffer
- */
-void ff_ivi_recompose53(const IVIPlaneDesc *plane, uint8_t *dst,
- const int dst_pitch);
-
-/**
- * Haar wavelet recomposition filter for Indeo 4
- *
- * @param[in] plane pointer to the descriptor of the plane being processed
- * @param[out] dst pointer to the destination buffer
- * @param[in] dst_pitch pitch of the destination buffer
- */
-void ff_ivi_recompose_haar(const IVIPlaneDesc *plane, uint8_t *dst,
- const int dst_pitch);
-
-/**
- * two-dimensional inverse Haar 8x8 transform for Indeo 4
- *
- * @param[in] in pointer to the vector of transform coefficients
- * @param[out] out pointer to the output buffer (frame)
- * @param[in] pitch pitch to move to the next y line
- * @param[in] flags pointer to the array of column flags:
- * != 0 - non_empty column, 0 - empty one
- * (this array must be filled by caller)
- */
-void ff_ivi_inverse_haar_8x8(const int32_t *in, int16_t *out, uint32_t pitch,
- const uint8_t *flags);
-
-/**
- * DC-only two-dimensional inverse Haar transform for Indeo 4.
- * Performing the inverse transform in this case is equivalent to
- * spreading DC_coeff >> 3 over the whole block.
- *
- * @param[in] in pointer to the dc coefficient
- * @param[out] out pointer to the output buffer (frame)
- * @param[in] pitch pitch to move to the next y line
- * @param[in] blk_size transform block size
- */
-void ff_ivi_dc_haar_2d(const int32_t *in, int16_t *out, uint32_t pitch,
- int blk_size);
-
-/**
- * two-dimensional inverse slant 8x8 transform
- *
- * @param[in] in pointer to the vector of transform coefficients
- * @param[out] out pointer to the output buffer (frame)
- * @param[in] pitch pitch to move to the next y line
- * @param[in] flags pointer to the array of column flags:
- * != 0 - non_empty column, 0 - empty one
- * (this array must be filled by caller)
- */
-void ff_ivi_inverse_slant_8x8(const int32_t *in, int16_t *out, uint32_t pitch,
- const uint8_t *flags);
-
-/**
- * two-dimensional inverse slant 4x4 transform
- *
- * @param[in] in pointer to the vector of transform coefficients
- * @param[out] out pointer to the output buffer (frame)
- * @param[in] pitch pitch to move to the next y line
- * @param[in] flags pointer to the array of column flags:
- * != 0 - non_empty column, 0 - empty one
- * (this array must be filled by caller)
- */
-void ff_ivi_inverse_slant_4x4(const int32_t *in, int16_t *out, uint32_t pitch,
- const uint8_t *flags);
-
-/**
- * DC-only two-dimensional inverse slant transform.
- * Performing the inverse slant transform in this case is equivalent to
- * spreading (DC_coeff + 1)/2 over the whole block.
- * It works much faster than performing the slant transform on a vector of zeroes.
- *
- * @param[in] in pointer to the dc coefficient
- * @param[out] out pointer to the output buffer (frame)
- * @param[in] pitch pitch to move to the next y line
- * @param[in] blk_size transform block size
- */
-void ff_ivi_dc_slant_2d(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size);
-
-/**
- * inverse 1D row slant transform
- *
- * @param[in] in pointer to the vector of transform coefficients
- * @param[out] out pointer to the output buffer (frame)
- * @param[in] pitch pitch to move to the next y line
- * @param[in] flags pointer to the array of column flags (unused here)
- */
-void ff_ivi_row_slant8(const int32_t *in, int16_t *out, uint32_t pitch,
- const uint8_t *flags);
-
-/**
- * inverse 1D column slant transform
- *
- * @param[in] in pointer to the vector of transform coefficients
- * @param[out] out pointer to the output buffer (frame)
- * @param[in] pitch pitch to move to the next y line
- * @param[in] flags pointer to the array of column flags:
- * != 0 - non_empty column, 0 - empty one
- * (this array must be filled by caller)
- */
-void ff_ivi_col_slant8(const int32_t *in, int16_t *out, uint32_t pitch,
- const uint8_t *flags);
-
-/**
- * DC-only inverse row slant transform
- */
-void ff_ivi_dc_row_slant(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size);
-
-/**
- * DC-only inverse column slant transform
- */
-void ff_ivi_dc_col_slant(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size);
-
-/**
- * Copy the pixels into the frame buffer.
- */
-void ff_ivi_put_pixels_8x8(const int32_t *in, int16_t *out, uint32_t pitch, const uint8_t *flags);
-
-/**
- * Copy the DC coefficient into the first pixel of the block and
- * zero all others.
- */
-void ff_ivi_put_dc_pixel_8x8(const int32_t *in, int16_t *out, uint32_t pitch, int blk_size);
-
-/**
- * 8x8 block motion compensation with adding delta
- *
- * @param[in,out] buf pointer to the block in the current frame buffer containing delta
- * @param[in] ref_buf pointer to the corresponding block in the reference frame
- * @param[in] pitch pitch for moving to the next y line
- * @param[in] mc_type interpolation type
- */
-void ff_ivi_mc_8x8_delta(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type);
-
-/**
- * 4x4 block motion compensation with adding delta
- *
- * @param[in,out] buf pointer to the block in the current frame buffer containing delta
- * @param[in] ref_buf pointer to the corresponding block in the reference frame
- * @param[in] pitch pitch for moving to the next y line
- * @param[in] mc_type interpolation type
- */
-void ff_ivi_mc_4x4_delta(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type);
-
-/**
- * motion compensation without adding delta
- *
- * @param[in,out] buf pointer to the block in the current frame receiving the result
- * @param[in] ref_buf pointer to the corresponding block in the reference frame
- * @param[in] pitch pitch for moving to the next y line
- * @param[in] mc_type interpolation type
- */
-void ff_ivi_mc_8x8_no_delta(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type);
-
-/**
- * 4x4 block motion compensation without adding delta
- *
- * @param[in,out] buf pointer to the block in the current frame receiving the result
- * @param[in] ref_buf pointer to the corresponding block in the reference frame
- * @param[in] pitch pitch for moving to the next y line
- * @param[in] mc_type interpolation type
- */
-void ff_ivi_mc_4x4_no_delta(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type);
-
-#endif /* AVCODEC_IVI_DSP_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/jpegls.c b/src/thirdparty/ffmpeg/libavcodec/jpegls.c
deleted file mode 100644
index be275fff2..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/jpegls.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * JPEG-LS common code
- * Copyright (c) 2003 Michael Niedermayer
- * Copyright (c) 2006 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
- */
-
-/**
- * @file
- * JPEG-LS common code.
- */
-
-#include "jpegls.h"
-
-void ff_jpegls_init_state(JLSState *state){
- int i;
-
- state->twonear = state->near * 2 + 1;
- state->range = ((state->maxval + state->twonear - 1) / state->twonear) + 1;
-
- // QBPP = ceil(log2(RANGE))
- for(state->qbpp = 0; (1 << state->qbpp) < state->range; state->qbpp++);
-
- state->bpp = FFMAX(av_log2(state->maxval)+1, 2);
- state->limit = 2*(state->bpp + FFMAX(state->bpp, 8)) - state->qbpp;
-
- for(i = 0; i < 367; i++) {
- state->A[i] = FFMAX((state->range + 32) >> 6, 2);
- state->N[i] = 1;
- }
-
-}
-
-/**
- * Custom value clipping function used in T1, T2, T3 calculation
- */
-static inline int iso_clip(int v, int vmin, int vmax){
- if(v > vmax || v < vmin) return vmin;
- else return v;
-}
-
-void ff_jpegls_reset_coding_parameters(JLSState *s, int reset_all){
- const int basic_t1= 3;
- const int basic_t2= 7;
- const int basic_t3= 21;
- int factor;
-
- if(s->maxval==0 || reset_all) s->maxval= (1 << s->bpp) - 1;
-
- if(s->maxval >=128){
- factor= (FFMIN(s->maxval, 4095) + 128)>>8;
-
- if(s->T1==0 || reset_all)
- s->T1= iso_clip(factor*(basic_t1-2) + 2 + 3*s->near, s->near+1, s->maxval);
- if(s->T2==0 || reset_all)
- s->T2= iso_clip(factor*(basic_t2-3) + 3 + 5*s->near, s->T1, s->maxval);
- if(s->T3==0 || reset_all)
- s->T3= iso_clip(factor*(basic_t3-4) + 4 + 7*s->near, s->T2, s->maxval);
- }else{
- factor= 256 / (s->maxval + 1);
-
- if(s->T1==0 || reset_all)
- s->T1= iso_clip(FFMAX(2, basic_t1/factor + 3*s->near), s->near+1, s->maxval);
- if(s->T2==0 || reset_all)
- s->T2= iso_clip(FFMAX(3, basic_t2/factor + 5*s->near), s->T1, s->maxval);
- if(s->T3==0 || reset_all)
- s->T3= iso_clip(FFMAX(4, basic_t3/factor + 7*s->near), s->T2, s->maxval);
- }
-
- if(s->reset==0 || reset_all) s->reset= 64;
- av_dlog(NULL, "[JPEG-LS RESET] T=%i,%i,%i\n", s->T1, s->T2, s->T3);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/jpegls.h b/src/thirdparty/ffmpeg/libavcodec/jpegls.h
deleted file mode 100644
index 997320d69..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/jpegls.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * JPEG-LS common code
- * Copyright (c) 2003 Michael Niedermayer
- * Copyright (c) 2006 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
- */
-
-/**
- * @file
- * JPEG-LS common code.
- */
-
-#ifndef AVCODEC_JPEGLS_H
-#define AVCODEC_JPEGLS_H
-
-#include "avcodec.h"
-#include "libavutil/common.h"
-
-typedef struct JpeglsContext{
- AVCodecContext *avctx;
- AVFrame picture;
-}JpeglsContext;
-
-typedef struct JLSState{
- int T1, T2, T3;
- int A[367], B[367], C[365], N[367];
- int limit, reset, bpp, qbpp, maxval, range;
- int near, twonear;
- int run_index[4];
-}JLSState;
-
-extern const uint8_t ff_log2_run[32];
-
-/**
- * Calculate initial JPEG-LS parameters
- */
-void ff_jpegls_init_state(JLSState *state);
-
-/**
- * Calculate quantized gradient value, used for context determination
- */
-static inline int ff_jpegls_quantize(JLSState *s, int v){ //FIXME optimize
- if(v==0) return 0;
- if(v < 0){
- if(v <= -s->T3) return -4;
- if(v <= -s->T2) return -3;
- if(v <= -s->T1) return -2;
- if(v < -s->near) return -1;
- return 0;
- }else{
- if(v <= s->near) return 0;
- if(v < s->T1) return 1;
- if(v < s->T2) return 2;
- if(v < s->T3) return 3;
- return 4;
- }
-}
-
-/**
- * Calculate JPEG-LS codec values
- */
-void ff_jpegls_reset_coding_parameters(JLSState *s, int reset_all);
-
-
-static inline void ff_jpegls_downscale_state(JLSState *state, int Q){
- if(state->N[Q] == state->reset){
- state->A[Q] >>=1;
- state->B[Q] >>=1;
- state->N[Q] >>=1;
- }
- state->N[Q]++;
-}
-
-static inline int ff_jpegls_update_state_regular(JLSState *state, int Q, int err){
- if(FFABS(err) > 0xFFFF)
- return -0x10000;
- state->A[Q] += FFABS(err);
- err *= state->twonear;
- state->B[Q] += err;
-
- ff_jpegls_downscale_state(state, Q);
-
- if(state->B[Q] <= -state->N[Q]) {
- state->B[Q]= FFMAX(state->B[Q] + state->N[Q], 1-state->N[Q]);
- if(state->C[Q] > -128)
- state->C[Q]--;
- }else if(state->B[Q] > 0){
- state->B[Q]= FFMIN(state->B[Q] - state->N[Q], 0);
- if(state->C[Q] < 127)
- state->C[Q]++;
- }
-
- return err;
-}
-
-#define R(a, i ) (bits == 8 ? ((uint8_t*)(a))[i] : ((uint16_t*)(a))[i] )
-#define W(a, i, v) (bits == 8 ? (((uint8_t*)(a))[i]=v) : (((uint16_t*)(a))[i]=v))
-
-#endif /* AVCODEC_JPEGLS_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/jpeglsdec.c b/src/thirdparty/ffmpeg/libavcodec/jpeglsdec.c
deleted file mode 100644
index fddca390f..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/jpeglsdec.c
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
- * JPEG-LS decoder
- * Copyright (c) 2003 Michael Niedermayer
- * Copyright (c) 2006 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
- */
-
-/**
- * @file
- * JPEG-LS decoder.
- */
-
-#include "avcodec.h"
-#include "get_bits.h"
-#include "golomb.h"
-#include "mathops.h"
-#include "mjpeg.h"
-#include "mjpegdec.h"
-#include "jpegls.h"
-#include "jpeglsdec.h"
-
-
-/*
-* Uncomment this to significantly speed up decoding of broken JPEG-LS
-* (or test broken JPEG-LS decoder) and slow down ordinary decoding a bit.
-*
-* There is no Golomb code with length >= 32 bits possible, so check and
-* avoid situation of 32 zeros, FFmpeg Golomb decoder is painfully slow
-* on this errors.
-*/
-//#define JLS_BROKEN
-
-
-/**
- * Decode LSE block with initialization parameters
- */
-int ff_jpegls_decode_lse(MJpegDecodeContext *s)
-{
- int id;
-
- skip_bits(&s->gb, 16); /* length: FIXME: verify field validity */
- id = get_bits(&s->gb, 8);
-
- switch(id){
- case 1:
- 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);
-
-// ff_jpegls_reset_coding_parameters(s, 0);
- //FIXME quant table?
- break;
- case 2:
- case 3:
- av_log(s->avctx, AV_LOG_ERROR, "palette not supported\n");
- return -1;
- case 4:
- av_log(s->avctx, AV_LOG_ERROR, "oversize image not supported\n");
- return -1;
- default:
- av_log(s->avctx, AV_LOG_ERROR, "invalid id %d\n", id);
- return -1;
- }
- av_dlog(s->avctx, "ID=%i, T=%i,%i,%i\n", id, s->t1, s->t2, s->t3);
-
- return 0;
-}
-
-/**
- * Get context-dependent Golomb code, decode it and update context
- */
-static inline int ls_get_code_regular(GetBitContext *gb, JLSState *state, int Q){
- int k, ret;
-
- for(k = 0; (state->N[Q] << k) < state->A[Q]; k++);
-
-#ifdef JLS_BROKEN
- if(!show_bits_long(gb, 32))return -1;
-#endif
- ret = get_ur_golomb_jpegls(gb, k, state->limit, state->qbpp);
-
- /* decode mapped error */
- if(ret & 1)
- ret = -((ret + 1) >> 1);
- else
- ret >>= 1;
-
- /* for NEAR=0, k=0 and 2*B[Q] <= - N[Q] mapping is reversed */
- if(!state->near && !k && (2 * state->B[Q] <= -state->N[Q]))
- ret = -(ret + 1);
-
- ret= ff_jpegls_update_state_regular(state, Q, ret);
-
- return ret;
-}
-
-/**
- * Get Golomb code, decode it and update state for run termination
- */
-static inline int ls_get_code_runterm(GetBitContext *gb, JLSState *state, int RItype, int limit_add){
- int k, ret, temp, map;
- int Q = 365 + RItype;
-
- temp= state->A[Q];
- if(RItype)
- temp += state->N[Q] >> 1;
-
- for(k = 0; (state->N[Q] << k) < temp; k++);
-
-#ifdef JLS_BROKEN
- if(!show_bits_long(gb, 32))return -1;
-#endif
- ret = get_ur_golomb_jpegls(gb, k, state->limit - limit_add - 1, state->qbpp);
-
- /* decode mapped error */
- map = 0;
- if(!k && (RItype || ret) && (2 * state->B[Q] < state->N[Q]))
- map = 1;
- ret += RItype + map;
-
- if(ret & 1){
- ret = map - ((ret + 1) >> 1);
- state->B[Q]++;
- } else {
- ret = ret >> 1;
- }
-
- /* update state */
- state->A[Q] += FFABS(ret) - RItype;
- ret *= state->twonear;
- ff_jpegls_downscale_state(state, Q);
-
- return ret;
-}
-
-/**
- * Decode one line of image
- */
-static inline void ls_decode_line(JLSState *state, MJpegDecodeContext *s, void *last, void *dst, int last2, int w, int stride, int comp, int bits){
- int i, x = 0;
- int Ra, Rb, Rc, Rd;
- int D0, D1, D2;
-
- while(x < w) {
- int err, pred;
-
- /* compute gradients */
- Ra = x ? R(dst, x - stride) : R(last, x);
- Rb = R(last, x);
- Rc = x ? R(last, x - stride) : last2;
- Rd = (x >= w - stride) ? R(last, x) : R(last, x + stride);
- D0 = Rd - Rb;
- D1 = Rb - Rc;
- D2 = Rc - Ra;
- /* run mode */
- if((FFABS(D0) <= state->near) && (FFABS(D1) <= state->near) && (FFABS(D2) <= state->near)) {
- int r;
- int RItype;
-
- /* decode full runs while available */
- while(get_bits1(&s->gb)) {
- int r;
- r = 1 << ff_log2_run[state->run_index[comp]];
- if(x + r * stride > w) {
- r = (w - x) / stride;
- }
- for(i = 0; i < r; i++) {
- W(dst, x, Ra);
- x += stride;
- }
- /* if EOL reached, we stop decoding */
- if(r != (1 << ff_log2_run[state->run_index[comp]]))
- return;
- if(state->run_index[comp] < 31)
- state->run_index[comp]++;
- if(x + stride > w)
- return;
- }
- /* decode aborted run */
- r = ff_log2_run[state->run_index[comp]];
- if(r)
- r = get_bits_long(&s->gb, r);
- if(x + r * stride > w) {
- r = (w - x) / stride;
- }
- for(i = 0; i < r; i++) {
- W(dst, x, Ra);
- x += stride;
- }
-
- /* decode run termination value */
- Rb = R(last, x);
- RItype = (FFABS(Ra - Rb) <= state->near) ? 1 : 0;
- err = ls_get_code_runterm(&s->gb, state, RItype, ff_log2_run[state->run_index[comp]]);
- if(state->run_index[comp])
- state->run_index[comp]--;
-
- if(state->near && RItype){
- pred = Ra + err;
- } else {
- if(Rb < Ra)
- pred = Rb - err;
- else
- pred = Rb + err;
- }
- } else { /* regular mode */
- int context, sign;
-
- context = ff_jpegls_quantize(state, D0) * 81 + ff_jpegls_quantize(state, D1) * 9 + ff_jpegls_quantize(state, D2);
- pred = mid_pred(Ra, Ra + Rb - Rc, Rb);
-
- if(context < 0){
- context = -context;
- sign = 1;
- }else{
- sign = 0;
- }
-
- if(sign){
- pred = av_clip(pred - state->C[context], 0, state->maxval);
- err = -ls_get_code_regular(&s->gb, state, context);
- } else {
- pred = av_clip(pred + state->C[context], 0, state->maxval);
- err = ls_get_code_regular(&s->gb, state, context);
- }
-
- /* we have to do something more for near-lossless coding */
- pred += err;
- }
- if(state->near){
- if(pred < -state->near)
- pred += state->range * state->twonear;
- else if(pred > state->maxval + state->near)
- pred -= state->range * state->twonear;
- pred = av_clip(pred, 0, state->maxval);
- }
-
- pred &= state->maxval;
- W(dst, x, pred);
- x += stride;
- }
-}
-
-int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transform, int ilv){
- int i, t = 0;
- uint8_t *zero, *last, *cur;
- JLSState *state;
- int off = 0, stride = 1, width, shift;
-
- zero = av_mallocz(s->picture.linesize[0]);
- last = zero;
- cur = s->picture.data[0];
-
- state = av_mallocz(sizeof(JLSState));
- /* initialize JPEG-LS state from JPEG parameters */
- state->near = near;
- state->bpp = (s->bits < 2) ? 2 : s->bits;
- state->maxval = s->maxval;
- state->T1 = s->t1;
- state->T2 = s->t2;
- state->T3 = s->t3;
- state->reset = s->reset;
- ff_jpegls_reset_coding_parameters(state, 0);
- ff_jpegls_init_state(state);
-
- if(s->bits <= 8)
- shift = point_transform + (8 - s->bits);
- else
- shift = point_transform + (16 - s->bits);
-
- if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
- av_log(s->avctx, AV_LOG_DEBUG, "JPEG-LS params: %ix%i NEAR=%i MV=%i T(%i,%i,%i) RESET=%i, LIMIT=%i, qbpp=%i, RANGE=%i\n",
- s->width, s->height, state->near, state->maxval,
- state->T1, state->T2, state->T3,
- state->reset, state->limit, state->qbpp, state->range);
- av_log(s->avctx, AV_LOG_DEBUG, "JPEG params: ILV=%i Pt=%i BPP=%i, scan = %i\n",
- ilv, point_transform, s->bits, s->cur_scan);
- }
- if(ilv == 0) { /* separate planes */
- stride = (s->nb_components > 1) ? 3 : 1;
- off = av_clip(s->cur_scan - 1, 0, stride - 1);
- width = s->width * stride;
- cur += off;
- for(i = 0; i < s->height; i++) {
- if(s->bits <= 8){
- ls_decode_line(state, s, last, cur, t, width, stride, off, 8);
- t = last[0];
- }else{
- ls_decode_line(state, s, last, cur, t, width, stride, off, 16);
- t = *((uint16_t*)last);
- }
- last = cur;
- cur += s->picture.linesize[0];
-
- if (s->restart_interval && !--s->restart_count) {
- align_get_bits(&s->gb);
- skip_bits(&s->gb, 16); /* skip RSTn */
- }
- }
- } else if(ilv == 1) { /* line interleaving */
- int j;
- int Rc[3] = {0, 0, 0};
- stride = (s->nb_components > 1) ? 3 : 1;
- memset(cur, 0, s->picture.linesize[0]);
- width = s->width * stride;
- for(i = 0; i < s->height; i++) {
- for(j = 0; j < stride; j++) {
- ls_decode_line(state, s, last + j, cur + j, Rc[j], width, stride, j, 8);
- Rc[j] = last[j];
-
- if (s->restart_interval && !--s->restart_count) {
- align_get_bits(&s->gb);
- skip_bits(&s->gb, 16); /* skip RSTn */
- }
- }
- last = cur;
- cur += s->picture.linesize[0];
- }
- } else if(ilv == 2) { /* sample interleaving */
- av_log(s->avctx, AV_LOG_ERROR, "Sample interleaved images are not supported.\n");
- av_free(state);
- av_free(zero);
- return -1;
- }
-
- if(shift){ /* we need to do point transform or normalize samples */
- int x, w;
-
- w = s->width * s->nb_components;
-
- if(s->bits <= 8){
- uint8_t *src = s->picture.data[0];
-
- for(i = 0; i < s->height; i++){
- for(x = off; x < w; x+= stride){
- src[x] <<= shift;
- }
- src += s->picture.linesize[0];
- }
- }else{
- uint16_t *src = (uint16_t*) s->picture.data[0];
-
- for(i = 0; i < s->height; i++){
- for(x = 0; x < w; x++){
- src[x] <<= shift;
- }
- src += s->picture.linesize[0]/2;
- }
- }
- }
- av_free(state);
- av_free(zero);
-
- return 0;
-}
-
-
-AVCodec ff_jpegls_decoder = {
- .name = "jpegls",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_JPEGLS,
- .priv_data_size = sizeof(MJpegDecodeContext),
- .init = ff_mjpeg_decode_init,
- .close = ff_mjpeg_decode_end,
- .decode = ff_mjpeg_decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("JPEG-LS"),
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/jpeglsdec.h b/src/thirdparty/ffmpeg/libavcodec/jpeglsdec.h
deleted file mode 100644
index 941288028..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/jpeglsdec.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * JPEG-LS decoder
- * Copyright (c) 2003 Michael Niedermayer
- * Copyright (c) 2006 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
- */
-
-/**
- * @file
- * JPEG-LS decoder.
- */
-
-#ifndef AVCODEC_JPEGLSDEC_H
-#define AVCODEC_JPEGLSDEC_H
-
-#include "mjpeg.h"
-#include "mjpegdec.h"
-
-/**
- * Decode LSE block with initialization parameters
- */
-int ff_jpegls_decode_lse(MJpegDecodeContext *s);
-
-int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transform, int ilv);
-
-#endif /* AVCODEC_JPEGLSDEC_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/jrevdct.c b/src/thirdparty/ffmpeg/libavcodec/jrevdct.c
deleted file mode 100644
index ddb4ebcbf..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/jrevdct.c
+++ /dev/null
@@ -1,1155 +0,0 @@
-/*
- * This file is part of the Independent JPEG Group's software.
- *
- * The authors make NO WARRANTY or representation, either express or implied,
- * with respect to this software, its quality, accuracy, merchantability, or
- * fitness for a particular purpose. This software is provided "AS IS", and
- * you, its user, assume the entire risk as to its quality and accuracy.
- *
- * This software is copyright (C) 1991, 1992, Thomas G. Lane.
- * All Rights Reserved except as specified below.
- *
- * Permission is hereby granted to use, copy, modify, and distribute this
- * software (or portions thereof) for any purpose, without fee, subject to
- * these conditions:
- * (1) If any part of the source code for this software is distributed, then
- * this README file must be included, with this copyright and no-warranty
- * notice unaltered; and any additions, deletions, or changes to the original
- * files must be clearly indicated in accompanying documentation.
- * (2) If only executable code is distributed, then the accompanying
- * documentation must state that "this software is based in part on the work
- * of the Independent JPEG Group".
- * (3) Permission for use of this software is granted only if the user accepts
- * full responsibility for any undesirable consequences; the authors accept
- * NO LIABILITY for damages of any kind.
- *
- * These conditions apply to any software derived from or based on the IJG
- * code, not just to the unmodified library. If you use our work, you ought
- * to acknowledge us.
- *
- * Permission is NOT granted for the use of any IJG author's name or company
- * name in advertising or publicity relating to this software or products
- * derived from it. This software may be referred to only as "the Independent
- * JPEG Group's software".
- *
- * We specifically permit and encourage the use of this software as the basis
- * of commercial products, provided that all warranty or liability claims are
- * assumed by the product vendor.
- *
- * This file contains the basic inverse-DCT transformation subroutine.
- *
- * This implementation is based on an algorithm described in
- * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT
- * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics,
- * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991.
- * The primary algorithm described there uses 11 multiplies and 29 adds.
- * We use their alternate method with 12 multiplies and 32 adds.
- * The advantage of this method is that no data path contains more than one
- * multiplication; this allows a very simple and accurate implementation in
- * scaled fixed-point arithmetic, with a minimal number of shifts.
- *
- * I've made lots of modifications to attempt to take advantage of the
- * sparse nature of the DCT matrices we're getting. Although the logic
- * is cumbersome, it's straightforward and the resulting code is much
- * faster.
- *
- * A better way to do this would be to pass in the DCT block as a sparse
- * matrix, perhaps with the difference cases encoded.
- */
-
-/**
- * @file
- * Independent JPEG Group's LLM idct.
- */
-
-#include "libavutil/common.h"
-#include "dct.h"
-
-#define EIGHT_BIT_SAMPLES
-
-#define DCTSIZE 8
-#define DCTSIZE2 64
-
-#define GLOBAL
-
-#define RIGHT_SHIFT(x, n) ((x) >> (n))
-
-typedef int16_t DCTBLOCK[DCTSIZE2];
-
-#define CONST_BITS 13
-
-/*
- * This routine is specialized to the case DCTSIZE = 8.
- */
-
-#if DCTSIZE != 8
- Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */
-#endif
-
-
-/*
- * A 2-D IDCT can be done by 1-D IDCT on each row followed by 1-D IDCT
- * on each column. Direct algorithms are also available, but they are
- * much more complex and seem not to be any faster when reduced to code.
- *
- * The poop on this scaling stuff is as follows:
- *
- * Each 1-D IDCT step produces outputs which are a factor of sqrt(N)
- * larger than the true IDCT outputs. The final outputs are therefore
- * a factor of N larger than desired; since N=8 this can be cured by
- * a simple right shift at the end of the algorithm. The advantage of
- * this arrangement is that we save two multiplications per 1-D IDCT,
- * because the y0 and y4 inputs need not be divided by sqrt(N).
- *
- * We have to do addition and subtraction of the integer inputs, which
- * is no problem, and multiplication by fractional constants, which is
- * a problem to do in integer arithmetic. We multiply all the constants
- * by CONST_SCALE and convert them to integer constants (thus retaining
- * CONST_BITS bits of precision in the constants). After doing a
- * multiplication we have to divide the product by CONST_SCALE, with proper
- * rounding, to produce the correct output. This division can be done
- * cheaply as a right shift of CONST_BITS bits. We postpone shifting
- * as long as possible so that partial sums can be added together with
- * full fractional precision.
- *
- * The outputs of the first pass are scaled up by PASS1_BITS bits so that
- * they are represented to better-than-integral precision. These outputs
- * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word
- * with the recommended scaling. (To scale up 12-bit sample data further, an
- * intermediate int32 array would be needed.)
- *
- * To avoid overflow of the 32-bit intermediate results in pass 2, we must
- * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis
- * shows that the values given below are the most effective.
- */
-
-#ifdef EIGHT_BIT_SAMPLES
-#define PASS1_BITS 2
-#else
-#define PASS1_BITS 1 /* lose a little precision to avoid overflow */
-#endif
-
-#define ONE ((int32_t) 1)
-
-#define CONST_SCALE (ONE << CONST_BITS)
-
-/* Convert a positive real constant to an integer scaled by CONST_SCALE.
- * IMPORTANT: if your compiler doesn't do this arithmetic at compile time,
- * you will pay a significant penalty in run time. In that case, figure
- * the correct integer constant values and insert them by hand.
- */
-
-/* Actually FIX is no longer used, we precomputed them all */
-#define FIX(x) ((int32_t) ((x) * CONST_SCALE + 0.5))
-
-/* Descale and correctly round an int32_t value that's scaled by N bits.
- * We assume RIGHT_SHIFT rounds towards minus infinity, so adding
- * the fudge factor is correct for either sign of X.
- */
-
-#define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)
-
-/* Multiply an int32_t variable by an int32_t constant to yield an int32_t result.
- * For 8-bit samples with the recommended scaling, all the variable
- * and constant values involved are no more than 16 bits wide, so a
- * 16x16->32 bit multiply can be used instead of a full 32x32 multiply;
- * this provides a useful speedup on many machines.
- * There is no way to specify a 16x16->32 multiply in portable C, but
- * some C compilers will do the right thing if you provide the correct
- * combination of casts.
- * NB: for 12-bit samples, a full 32-bit multiplication will be needed.
- */
-
-#ifdef EIGHT_BIT_SAMPLES
-#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */
-#define MULTIPLY(var,const) (((int16_t) (var)) * ((int16_t) (const)))
-#endif
-#ifdef SHORTxLCONST_32 /* known to work with Microsoft C 6.0 */
-#define MULTIPLY(var,const) (((int16_t) (var)) * ((int32_t) (const)))
-#endif
-#endif
-
-#ifndef MULTIPLY /* default definition */
-#define MULTIPLY(var,const) ((var) * (const))
-#endif
-
-
-/*
- Unlike our decoder where we approximate the FIXes, we need to use exact
-ones here or successive P-frames will drift too much with Reference frame coding
-*/
-#define FIX_0_211164243 1730
-#define FIX_0_275899380 2260
-#define FIX_0_298631336 2446
-#define FIX_0_390180644 3196
-#define FIX_0_509795579 4176
-#define FIX_0_541196100 4433
-#define FIX_0_601344887 4926
-#define FIX_0_765366865 6270
-#define FIX_0_785694958 6436
-#define FIX_0_899976223 7373
-#define FIX_1_061594337 8697
-#define FIX_1_111140466 9102
-#define FIX_1_175875602 9633
-#define FIX_1_306562965 10703
-#define FIX_1_387039845 11363
-#define FIX_1_451774981 11893
-#define FIX_1_501321110 12299
-#define FIX_1_662939225 13623
-#define FIX_1_847759065 15137
-#define FIX_1_961570560 16069
-#define FIX_2_053119869 16819
-#define FIX_2_172734803 17799
-#define FIX_2_562915447 20995
-#define FIX_3_072711026 25172
-
-/*
- * Perform the inverse DCT on one block of coefficients.
- */
-
-void ff_j_rev_dct(DCTBLOCK data)
-{
- int32_t tmp0, tmp1, tmp2, tmp3;
- int32_t tmp10, tmp11, tmp12, tmp13;
- int32_t z1, z2, z3, z4, z5;
- int32_t d0, d1, d2, d3, d4, d5, d6, d7;
- register int16_t *dataptr;
- int rowctr;
-
- /* Pass 1: process rows. */
- /* Note results are scaled up by sqrt(8) compared to a true IDCT; */
- /* furthermore, we scale the results by 2**PASS1_BITS. */
-
- dataptr = data;
-
- for (rowctr = DCTSIZE-1; rowctr >= 0; rowctr--) {
- /* Due to quantization, we will usually find that many of the input
- * coefficients are zero, especially the AC terms. We can exploit this
- * by short-circuiting the IDCT calculation for any row in which all
- * the AC terms are zero. In that case each output is equal to the
- * DC coefficient (with scale factor as needed).
- * With typical images and quantization tables, half or more of the
- * row DCT calculations can be simplified this way.
- */
-
- register int *idataptr = (int*)dataptr;
-
- /* WARNING: we do the same permutation as MMX idct to simplify the
- video core */
- d0 = dataptr[0];
- d2 = dataptr[1];
- d4 = dataptr[2];
- d6 = dataptr[3];
- d1 = dataptr[4];
- d3 = dataptr[5];
- d5 = dataptr[6];
- d7 = dataptr[7];
-
- if ((d1 | d2 | d3 | d4 | d5 | d6 | d7) == 0) {
- /* AC terms all zero */
- if (d0) {
- /* Compute a 32 bit value to assign. */
- int16_t dcval = (int16_t) (d0 << PASS1_BITS);
- register int v = (dcval & 0xffff) | ((dcval << 16) & 0xffff0000);
-
- idataptr[0] = v;
- idataptr[1] = v;
- idataptr[2] = v;
- idataptr[3] = v;
- }
-
- dataptr += DCTSIZE; /* advance pointer to next row */
- continue;
- }
-
- /* Even part: reverse the even part of the forward DCT. */
- /* The rotator is sqrt(2)*c(-6). */
-{
- if (d6) {
- if (d2) {
- /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */
- z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
- tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
- tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
-
- tmp0 = (d0 + d4) << CONST_BITS;
- tmp1 = (d0 - d4) << CONST_BITS;
-
- tmp10 = tmp0 + tmp3;
- tmp13 = tmp0 - tmp3;
- tmp11 = tmp1 + tmp2;
- tmp12 = tmp1 - tmp2;
- } else {
- /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */
- tmp2 = MULTIPLY(-d6, FIX_1_306562965);
- tmp3 = MULTIPLY(d6, FIX_0_541196100);
-
- tmp0 = (d0 + d4) << CONST_BITS;
- tmp1 = (d0 - d4) << CONST_BITS;
-
- tmp10 = tmp0 + tmp3;
- tmp13 = tmp0 - tmp3;
- tmp11 = tmp1 + tmp2;
- tmp12 = tmp1 - tmp2;
- }
- } else {
- if (d2) {
- /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */
- tmp2 = MULTIPLY(d2, FIX_0_541196100);
- tmp3 = MULTIPLY(d2, FIX_1_306562965);
-
- tmp0 = (d0 + d4) << CONST_BITS;
- tmp1 = (d0 - d4) << CONST_BITS;
-
- tmp10 = tmp0 + tmp3;
- tmp13 = tmp0 - tmp3;
- tmp11 = tmp1 + tmp2;
- tmp12 = tmp1 - tmp2;
- } else {
- /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */
- tmp10 = tmp13 = (d0 + d4) << CONST_BITS;
- tmp11 = tmp12 = (d0 - d4) << CONST_BITS;
- }
- }
-
- /* Odd part per figure 8; the matrix is unitary and hence its
- * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
- */
-
- if (d7) {
- if (d5) {
- if (d3) {
- if (d1) {
- /* d1 != 0, d3 != 0, d5 != 0, d7 != 0 */
- z1 = d7 + d1;
- z2 = d5 + d3;
- z3 = d7 + d3;
- z4 = d5 + d1;
- z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
-
- tmp0 = MULTIPLY(d7, FIX_0_298631336);
- tmp1 = MULTIPLY(d5, FIX_2_053119869);
- tmp2 = MULTIPLY(d3, FIX_3_072711026);
- tmp3 = MULTIPLY(d1, FIX_1_501321110);
- z1 = MULTIPLY(-z1, FIX_0_899976223);
- z2 = MULTIPLY(-z2, FIX_2_562915447);
- z3 = MULTIPLY(-z3, FIX_1_961570560);
- z4 = MULTIPLY(-z4, FIX_0_390180644);
-
- z3 += z5;
- z4 += z5;
-
- tmp0 += z1 + z3;
- tmp1 += z2 + z4;
- tmp2 += z2 + z3;
- tmp3 += z1 + z4;
- } else {
- /* d1 == 0, d3 != 0, d5 != 0, d7 != 0 */
- z2 = d5 + d3;
- z3 = d7 + d3;
- z5 = MULTIPLY(z3 + d5, FIX_1_175875602);
-
- tmp0 = MULTIPLY(d7, FIX_0_298631336);
- tmp1 = MULTIPLY(d5, FIX_2_053119869);
- tmp2 = MULTIPLY(d3, FIX_3_072711026);
- z1 = MULTIPLY(-d7, FIX_0_899976223);
- z2 = MULTIPLY(-z2, FIX_2_562915447);
- z3 = MULTIPLY(-z3, FIX_1_961570560);
- z4 = MULTIPLY(-d5, FIX_0_390180644);
-
- z3 += z5;
- z4 += z5;
-
- tmp0 += z1 + z3;
- tmp1 += z2 + z4;
- tmp2 += z2 + z3;
- tmp3 = z1 + z4;
- }
- } else {
- if (d1) {
- /* d1 != 0, d3 == 0, d5 != 0, d7 != 0 */
- z1 = d7 + d1;
- z4 = d5 + d1;
- z5 = MULTIPLY(d7 + z4, FIX_1_175875602);
-
- tmp0 = MULTIPLY(d7, FIX_0_298631336);
- tmp1 = MULTIPLY(d5, FIX_2_053119869);
- tmp3 = MULTIPLY(d1, FIX_1_501321110);
- z1 = MULTIPLY(-z1, FIX_0_899976223);
- z2 = MULTIPLY(-d5, FIX_2_562915447);
- z3 = MULTIPLY(-d7, FIX_1_961570560);
- z4 = MULTIPLY(-z4, FIX_0_390180644);
-
- z3 += z5;
- z4 += z5;
-
- tmp0 += z1 + z3;
- tmp1 += z2 + z4;
- tmp2 = z2 + z3;
- tmp3 += z1 + z4;
- } else {
- /* d1 == 0, d3 == 0, d5 != 0, d7 != 0 */
- tmp0 = MULTIPLY(-d7, FIX_0_601344887);
- z1 = MULTIPLY(-d7, FIX_0_899976223);
- z3 = MULTIPLY(-d7, FIX_1_961570560);
- tmp1 = MULTIPLY(-d5, FIX_0_509795579);
- z2 = MULTIPLY(-d5, FIX_2_562915447);
- z4 = MULTIPLY(-d5, FIX_0_390180644);
- z5 = MULTIPLY(d5 + d7, FIX_1_175875602);
-
- z3 += z5;
- z4 += z5;
-
- tmp0 += z3;
- tmp1 += z4;
- tmp2 = z2 + z3;
- tmp3 = z1 + z4;
- }
- }
- } else {
- if (d3) {
- if (d1) {
- /* d1 != 0, d3 != 0, d5 == 0, d7 != 0 */
- z1 = d7 + d1;
- z3 = d7 + d3;
- z5 = MULTIPLY(z3 + d1, FIX_1_175875602);
-
- tmp0 = MULTIPLY(d7, FIX_0_298631336);
- tmp2 = MULTIPLY(d3, FIX_3_072711026);
- tmp3 = MULTIPLY(d1, FIX_1_501321110);
- z1 = MULTIPLY(-z1, FIX_0_899976223);
- z2 = MULTIPLY(-d3, FIX_2_562915447);
- z3 = MULTIPLY(-z3, FIX_1_961570560);
- z4 = MULTIPLY(-d1, FIX_0_390180644);
-
- z3 += z5;
- z4 += z5;
-
- tmp0 += z1 + z3;
- tmp1 = z2 + z4;
- tmp2 += z2 + z3;
- tmp3 += z1 + z4;
- } else {
- /* d1 == 0, d3 != 0, d5 == 0, d7 != 0 */
- z3 = d7 + d3;
-
- tmp0 = MULTIPLY(-d7, FIX_0_601344887);
- z1 = MULTIPLY(-d7, FIX_0_899976223);
- tmp2 = MULTIPLY(d3, FIX_0_509795579);
- z2 = MULTIPLY(-d3, FIX_2_562915447);
- z5 = MULTIPLY(z3, FIX_1_175875602);
- z3 = MULTIPLY(-z3, FIX_0_785694958);
-
- tmp0 += z3;
- tmp1 = z2 + z5;
- tmp2 += z3;
- tmp3 = z1 + z5;
- }
- } else {
- if (d1) {
- /* d1 != 0, d3 == 0, d5 == 0, d7 != 0 */
- z1 = d7 + d1;
- z5 = MULTIPLY(z1, FIX_1_175875602);
-
- z1 = MULTIPLY(z1, FIX_0_275899380);
- z3 = MULTIPLY(-d7, FIX_1_961570560);
- tmp0 = MULTIPLY(-d7, FIX_1_662939225);
- z4 = MULTIPLY(-d1, FIX_0_390180644);
- tmp3 = MULTIPLY(d1, FIX_1_111140466);
-
- tmp0 += z1;
- tmp1 = z4 + z5;
- tmp2 = z3 + z5;
- tmp3 += z1;
- } else {
- /* d1 == 0, d3 == 0, d5 == 0, d7 != 0 */
- tmp0 = MULTIPLY(-d7, FIX_1_387039845);
- tmp1 = MULTIPLY(d7, FIX_1_175875602);
- tmp2 = MULTIPLY(-d7, FIX_0_785694958);
- tmp3 = MULTIPLY(d7, FIX_0_275899380);
- }
- }
- }
- } else {
- if (d5) {
- if (d3) {
- if (d1) {
- /* d1 != 0, d3 != 0, d5 != 0, d7 == 0 */
- z2 = d5 + d3;
- z4 = d5 + d1;
- z5 = MULTIPLY(d3 + z4, FIX_1_175875602);
-
- tmp1 = MULTIPLY(d5, FIX_2_053119869);
- tmp2 = MULTIPLY(d3, FIX_3_072711026);
- tmp3 = MULTIPLY(d1, FIX_1_501321110);
- z1 = MULTIPLY(-d1, FIX_0_899976223);
- z2 = MULTIPLY(-z2, FIX_2_562915447);
- z3 = MULTIPLY(-d3, FIX_1_961570560);
- z4 = MULTIPLY(-z4, FIX_0_390180644);
-
- z3 += z5;
- z4 += z5;
-
- tmp0 = z1 + z3;
- tmp1 += z2 + z4;
- tmp2 += z2 + z3;
- tmp3 += z1 + z4;
- } else {
- /* d1 == 0, d3 != 0, d5 != 0, d7 == 0 */
- z2 = d5 + d3;
-
- z5 = MULTIPLY(z2, FIX_1_175875602);
- tmp1 = MULTIPLY(d5, FIX_1_662939225);
- z4 = MULTIPLY(-d5, FIX_0_390180644);
- z2 = MULTIPLY(-z2, FIX_1_387039845);
- tmp2 = MULTIPLY(d3, FIX_1_111140466);
- z3 = MULTIPLY(-d3, FIX_1_961570560);
-
- tmp0 = z3 + z5;
- tmp1 += z2;
- tmp2 += z2;
- tmp3 = z4 + z5;
- }
- } else {
- if (d1) {
- /* d1 != 0, d3 == 0, d5 != 0, d7 == 0 */
- z4 = d5 + d1;
-
- z5 = MULTIPLY(z4, FIX_1_175875602);
- z1 = MULTIPLY(-d1, FIX_0_899976223);
- tmp3 = MULTIPLY(d1, FIX_0_601344887);
- tmp1 = MULTIPLY(-d5, FIX_0_509795579);
- z2 = MULTIPLY(-d5, FIX_2_562915447);
- z4 = MULTIPLY(z4, FIX_0_785694958);
-
- tmp0 = z1 + z5;
- tmp1 += z4;
- tmp2 = z2 + z5;
- tmp3 += z4;
- } else {
- /* d1 == 0, d3 == 0, d5 != 0, d7 == 0 */
- tmp0 = MULTIPLY(d5, FIX_1_175875602);
- tmp1 = MULTIPLY(d5, FIX_0_275899380);
- tmp2 = MULTIPLY(-d5, FIX_1_387039845);
- tmp3 = MULTIPLY(d5, FIX_0_785694958);
- }
- }
- } else {
- if (d3) {
- if (d1) {
- /* d1 != 0, d3 != 0, d5 == 0, d7 == 0 */
- z5 = d1 + d3;
- tmp3 = MULTIPLY(d1, FIX_0_211164243);
- tmp2 = MULTIPLY(-d3, FIX_1_451774981);
- z1 = MULTIPLY(d1, FIX_1_061594337);
- z2 = MULTIPLY(-d3, FIX_2_172734803);
- z4 = MULTIPLY(z5, FIX_0_785694958);
- z5 = MULTIPLY(z5, FIX_1_175875602);
-
- tmp0 = z1 - z4;
- tmp1 = z2 + z4;
- tmp2 += z5;
- tmp3 += z5;
- } else {
- /* d1 == 0, d3 != 0, d5 == 0, d7 == 0 */
- tmp0 = MULTIPLY(-d3, FIX_0_785694958);
- tmp1 = MULTIPLY(-d3, FIX_1_387039845);
- tmp2 = MULTIPLY(-d3, FIX_0_275899380);
- tmp3 = MULTIPLY(d3, FIX_1_175875602);
- }
- } else {
- if (d1) {
- /* d1 != 0, d3 == 0, d5 == 0, d7 == 0 */
- tmp0 = MULTIPLY(d1, FIX_0_275899380);
- tmp1 = MULTIPLY(d1, FIX_0_785694958);
- tmp2 = MULTIPLY(d1, FIX_1_175875602);
- tmp3 = MULTIPLY(d1, FIX_1_387039845);
- } else {
- /* d1 == 0, d3 == 0, d5 == 0, d7 == 0 */
- tmp0 = tmp1 = tmp2 = tmp3 = 0;
- }
- }
- }
- }
-}
- /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
-
- dataptr[0] = (int16_t) DESCALE(tmp10 + tmp3, CONST_BITS-PASS1_BITS);
- dataptr[7] = (int16_t) DESCALE(tmp10 - tmp3, CONST_BITS-PASS1_BITS);
- dataptr[1] = (int16_t) DESCALE(tmp11 + tmp2, CONST_BITS-PASS1_BITS);
- dataptr[6] = (int16_t) DESCALE(tmp11 - tmp2, CONST_BITS-PASS1_BITS);
- dataptr[2] = (int16_t) DESCALE(tmp12 + tmp1, CONST_BITS-PASS1_BITS);
- dataptr[5] = (int16_t) DESCALE(tmp12 - tmp1, CONST_BITS-PASS1_BITS);
- dataptr[3] = (int16_t) DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS);
- dataptr[4] = (int16_t) DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS);
-
- dataptr += DCTSIZE; /* advance pointer to next row */
- }
-
- /* Pass 2: process columns. */
- /* Note that we must descale the results by a factor of 8 == 2**3, */
- /* and also undo the PASS1_BITS scaling. */
-
- dataptr = data;
- for (rowctr = DCTSIZE-1; rowctr >= 0; rowctr--) {
- /* Columns of zeroes can be exploited in the same way as we did with rows.
- * However, the row calculation has created many nonzero AC terms, so the
- * simplification applies less often (typically 5% to 10% of the time).
- * On machines with very fast multiplication, it's possible that the
- * test takes more time than it's worth. In that case this section
- * may be commented out.
- */
-
- d0 = dataptr[DCTSIZE*0];
- d1 = dataptr[DCTSIZE*1];
- d2 = dataptr[DCTSIZE*2];
- d3 = dataptr[DCTSIZE*3];
- d4 = dataptr[DCTSIZE*4];
- d5 = dataptr[DCTSIZE*5];
- d6 = dataptr[DCTSIZE*6];
- d7 = dataptr[DCTSIZE*7];
-
- /* Even part: reverse the even part of the forward DCT. */
- /* The rotator is sqrt(2)*c(-6). */
- if (d6) {
- if (d2) {
- /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */
- z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
- tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
- tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
-
- tmp0 = (d0 + d4) << CONST_BITS;
- tmp1 = (d0 - d4) << CONST_BITS;
-
- tmp10 = tmp0 + tmp3;
- tmp13 = tmp0 - tmp3;
- tmp11 = tmp1 + tmp2;
- tmp12 = tmp1 - tmp2;
- } else {
- /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */
- tmp2 = MULTIPLY(-d6, FIX_1_306562965);
- tmp3 = MULTIPLY(d6, FIX_0_541196100);
-
- tmp0 = (d0 + d4) << CONST_BITS;
- tmp1 = (d0 - d4) << CONST_BITS;
-
- tmp10 = tmp0 + tmp3;
- tmp13 = tmp0 - tmp3;
- tmp11 = tmp1 + tmp2;
- tmp12 = tmp1 - tmp2;
- }
- } else {
- if (d2) {
- /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */
- tmp2 = MULTIPLY(d2, FIX_0_541196100);
- tmp3 = MULTIPLY(d2, FIX_1_306562965);
-
- tmp0 = (d0 + d4) << CONST_BITS;
- tmp1 = (d0 - d4) << CONST_BITS;
-
- tmp10 = tmp0 + tmp3;
- tmp13 = tmp0 - tmp3;
- tmp11 = tmp1 + tmp2;
- tmp12 = tmp1 - tmp2;
- } else {
- /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */
- tmp10 = tmp13 = (d0 + d4) << CONST_BITS;
- tmp11 = tmp12 = (d0 - d4) << CONST_BITS;
- }
- }
-
- /* Odd part per figure 8; the matrix is unitary and hence its
- * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
- */
- if (d7) {
- if (d5) {
- if (d3) {
- if (d1) {
- /* d1 != 0, d3 != 0, d5 != 0, d7 != 0 */
- z1 = d7 + d1;
- z2 = d5 + d3;
- z3 = d7 + d3;
- z4 = d5 + d1;
- z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
-
- tmp0 = MULTIPLY(d7, FIX_0_298631336);
- tmp1 = MULTIPLY(d5, FIX_2_053119869);
- tmp2 = MULTIPLY(d3, FIX_3_072711026);
- tmp3 = MULTIPLY(d1, FIX_1_501321110);
- z1 = MULTIPLY(-z1, FIX_0_899976223);
- z2 = MULTIPLY(-z2, FIX_2_562915447);
- z3 = MULTIPLY(-z3, FIX_1_961570560);
- z4 = MULTIPLY(-z4, FIX_0_390180644);
-
- z3 += z5;
- z4 += z5;
-
- tmp0 += z1 + z3;
- tmp1 += z2 + z4;
- tmp2 += z2 + z3;
- tmp3 += z1 + z4;
- } else {
- /* d1 == 0, d3 != 0, d5 != 0, d7 != 0 */
- z2 = d5 + d3;
- z3 = d7 + d3;
- z5 = MULTIPLY(z3 + d5, FIX_1_175875602);
-
- tmp0 = MULTIPLY(d7, FIX_0_298631336);
- tmp1 = MULTIPLY(d5, FIX_2_053119869);
- tmp2 = MULTIPLY(d3, FIX_3_072711026);
- z1 = MULTIPLY(-d7, FIX_0_899976223);
- z2 = MULTIPLY(-z2, FIX_2_562915447);
- z3 = MULTIPLY(-z3, FIX_1_961570560);
- z4 = MULTIPLY(-d5, FIX_0_390180644);
-
- z3 += z5;
- z4 += z5;
-
- tmp0 += z1 + z3;
- tmp1 += z2 + z4;
- tmp2 += z2 + z3;
- tmp3 = z1 + z4;
- }
- } else {
- if (d1) {
- /* d1 != 0, d3 == 0, d5 != 0, d7 != 0 */
- z1 = d7 + d1;
- z3 = d7;
- z4 = d5 + d1;
- z5 = MULTIPLY(z3 + z4, FIX_1_175875602);
-
- tmp0 = MULTIPLY(d7, FIX_0_298631336);
- tmp1 = MULTIPLY(d5, FIX_2_053119869);
- tmp3 = MULTIPLY(d1, FIX_1_501321110);
- z1 = MULTIPLY(-z1, FIX_0_899976223);
- z2 = MULTIPLY(-d5, FIX_2_562915447);
- z3 = MULTIPLY(-d7, FIX_1_961570560);
- z4 = MULTIPLY(-z4, FIX_0_390180644);
-
- z3 += z5;
- z4 += z5;
-
- tmp0 += z1 + z3;
- tmp1 += z2 + z4;
- tmp2 = z2 + z3;
- tmp3 += z1 + z4;
- } else {
- /* d1 == 0, d3 == 0, d5 != 0, d7 != 0 */
- tmp0 = MULTIPLY(-d7, FIX_0_601344887);
- z1 = MULTIPLY(-d7, FIX_0_899976223);
- z3 = MULTIPLY(-d7, FIX_1_961570560);
- tmp1 = MULTIPLY(-d5, FIX_0_509795579);
- z2 = MULTIPLY(-d5, FIX_2_562915447);
- z4 = MULTIPLY(-d5, FIX_0_390180644);
- z5 = MULTIPLY(d5 + d7, FIX_1_175875602);
-
- z3 += z5;
- z4 += z5;
-
- tmp0 += z3;
- tmp1 += z4;
- tmp2 = z2 + z3;
- tmp3 = z1 + z4;
- }
- }
- } else {
- if (d3) {
- if (d1) {
- /* d1 != 0, d3 != 0, d5 == 0, d7 != 0 */
- z1 = d7 + d1;
- z3 = d7 + d3;
- z5 = MULTIPLY(z3 + d1, FIX_1_175875602);
-
- tmp0 = MULTIPLY(d7, FIX_0_298631336);
- tmp2 = MULTIPLY(d3, FIX_3_072711026);
- tmp3 = MULTIPLY(d1, FIX_1_501321110);
- z1 = MULTIPLY(-z1, FIX_0_899976223);
- z2 = MULTIPLY(-d3, FIX_2_562915447);
- z3 = MULTIPLY(-z3, FIX_1_961570560);
- z4 = MULTIPLY(-d1, FIX_0_390180644);
-
- z3 += z5;
- z4 += z5;
-
- tmp0 += z1 + z3;
- tmp1 = z2 + z4;
- tmp2 += z2 + z3;
- tmp3 += z1 + z4;
- } else {
- /* d1 == 0, d3 != 0, d5 == 0, d7 != 0 */
- z3 = d7 + d3;
-
- tmp0 = MULTIPLY(-d7, FIX_0_601344887);
- z1 = MULTIPLY(-d7, FIX_0_899976223);
- tmp2 = MULTIPLY(d3, FIX_0_509795579);
- z2 = MULTIPLY(-d3, FIX_2_562915447);
- z5 = MULTIPLY(z3, FIX_1_175875602);
- z3 = MULTIPLY(-z3, FIX_0_785694958);
-
- tmp0 += z3;
- tmp1 = z2 + z5;
- tmp2 += z3;
- tmp3 = z1 + z5;
- }
- } else {
- if (d1) {
- /* d1 != 0, d3 == 0, d5 == 0, d7 != 0 */
- z1 = d7 + d1;
- z5 = MULTIPLY(z1, FIX_1_175875602);
-
- z1 = MULTIPLY(z1, FIX_0_275899380);
- z3 = MULTIPLY(-d7, FIX_1_961570560);
- tmp0 = MULTIPLY(-d7, FIX_1_662939225);
- z4 = MULTIPLY(-d1, FIX_0_390180644);
- tmp3 = MULTIPLY(d1, FIX_1_111140466);
-
- tmp0 += z1;
- tmp1 = z4 + z5;
- tmp2 = z3 + z5;
- tmp3 += z1;
- } else {
- /* d1 == 0, d3 == 0, d5 == 0, d7 != 0 */
- tmp0 = MULTIPLY(-d7, FIX_1_387039845);
- tmp1 = MULTIPLY(d7, FIX_1_175875602);
- tmp2 = MULTIPLY(-d7, FIX_0_785694958);
- tmp3 = MULTIPLY(d7, FIX_0_275899380);
- }
- }
- }
- } else {
- if (d5) {
- if (d3) {
- if (d1) {
- /* d1 != 0, d3 != 0, d5 != 0, d7 == 0 */
- z2 = d5 + d3;
- z4 = d5 + d1;
- z5 = MULTIPLY(d3 + z4, FIX_1_175875602);
-
- tmp1 = MULTIPLY(d5, FIX_2_053119869);
- tmp2 = MULTIPLY(d3, FIX_3_072711026);
- tmp3 = MULTIPLY(d1, FIX_1_501321110);
- z1 = MULTIPLY(-d1, FIX_0_899976223);
- z2 = MULTIPLY(-z2, FIX_2_562915447);
- z3 = MULTIPLY(-d3, FIX_1_961570560);
- z4 = MULTIPLY(-z4, FIX_0_390180644);
-
- z3 += z5;
- z4 += z5;
-
- tmp0 = z1 + z3;
- tmp1 += z2 + z4;
- tmp2 += z2 + z3;
- tmp3 += z1 + z4;
- } else {
- /* d1 == 0, d3 != 0, d5 != 0, d7 == 0 */
- z2 = d5 + d3;
-
- z5 = MULTIPLY(z2, FIX_1_175875602);
- tmp1 = MULTIPLY(d5, FIX_1_662939225);
- z4 = MULTIPLY(-d5, FIX_0_390180644);
- z2 = MULTIPLY(-z2, FIX_1_387039845);
- tmp2 = MULTIPLY(d3, FIX_1_111140466);
- z3 = MULTIPLY(-d3, FIX_1_961570560);
-
- tmp0 = z3 + z5;
- tmp1 += z2;
- tmp2 += z2;
- tmp3 = z4 + z5;
- }
- } else {
- if (d1) {
- /* d1 != 0, d3 == 0, d5 != 0, d7 == 0 */
- z4 = d5 + d1;
-
- z5 = MULTIPLY(z4, FIX_1_175875602);
- z1 = MULTIPLY(-d1, FIX_0_899976223);
- tmp3 = MULTIPLY(d1, FIX_0_601344887);
- tmp1 = MULTIPLY(-d5, FIX_0_509795579);
- z2 = MULTIPLY(-d5, FIX_2_562915447);
- z4 = MULTIPLY(z4, FIX_0_785694958);
-
- tmp0 = z1 + z5;
- tmp1 += z4;
- tmp2 = z2 + z5;
- tmp3 += z4;
- } else {
- /* d1 == 0, d3 == 0, d5 != 0, d7 == 0 */
- tmp0 = MULTIPLY(d5, FIX_1_175875602);
- tmp1 = MULTIPLY(d5, FIX_0_275899380);
- tmp2 = MULTIPLY(-d5, FIX_1_387039845);
- tmp3 = MULTIPLY(d5, FIX_0_785694958);
- }
- }
- } else {
- if (d3) {
- if (d1) {
- /* d1 != 0, d3 != 0, d5 == 0, d7 == 0 */
- z5 = d1 + d3;
- tmp3 = MULTIPLY(d1, FIX_0_211164243);
- tmp2 = MULTIPLY(-d3, FIX_1_451774981);
- z1 = MULTIPLY(d1, FIX_1_061594337);
- z2 = MULTIPLY(-d3, FIX_2_172734803);
- z4 = MULTIPLY(z5, FIX_0_785694958);
- z5 = MULTIPLY(z5, FIX_1_175875602);
-
- tmp0 = z1 - z4;
- tmp1 = z2 + z4;
- tmp2 += z5;
- tmp3 += z5;
- } else {
- /* d1 == 0, d3 != 0, d5 == 0, d7 == 0 */
- tmp0 = MULTIPLY(-d3, FIX_0_785694958);
- tmp1 = MULTIPLY(-d3, FIX_1_387039845);
- tmp2 = MULTIPLY(-d3, FIX_0_275899380);
- tmp3 = MULTIPLY(d3, FIX_1_175875602);
- }
- } else {
- if (d1) {
- /* d1 != 0, d3 == 0, d5 == 0, d7 == 0 */
- tmp0 = MULTIPLY(d1, FIX_0_275899380);
- tmp1 = MULTIPLY(d1, FIX_0_785694958);
- tmp2 = MULTIPLY(d1, FIX_1_175875602);
- tmp3 = MULTIPLY(d1, FIX_1_387039845);
- } else {
- /* d1 == 0, d3 == 0, d5 == 0, d7 == 0 */
- tmp0 = tmp1 = tmp2 = tmp3 = 0;
- }
- }
- }
- }
-
- /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
-
- dataptr[DCTSIZE*0] = (int16_t) DESCALE(tmp10 + tmp3,
- CONST_BITS+PASS1_BITS+3);
- dataptr[DCTSIZE*7] = (int16_t) DESCALE(tmp10 - tmp3,
- CONST_BITS+PASS1_BITS+3);
- dataptr[DCTSIZE*1] = (int16_t) DESCALE(tmp11 + tmp2,
- CONST_BITS+PASS1_BITS+3);
- dataptr[DCTSIZE*6] = (int16_t) DESCALE(tmp11 - tmp2,
- CONST_BITS+PASS1_BITS+3);
- dataptr[DCTSIZE*2] = (int16_t) DESCALE(tmp12 + tmp1,
- CONST_BITS+PASS1_BITS+3);
- dataptr[DCTSIZE*5] = (int16_t) DESCALE(tmp12 - tmp1,
- CONST_BITS+PASS1_BITS+3);
- dataptr[DCTSIZE*3] = (int16_t) DESCALE(tmp13 + tmp0,
- CONST_BITS+PASS1_BITS+3);
- dataptr[DCTSIZE*4] = (int16_t) DESCALE(tmp13 - tmp0,
- CONST_BITS+PASS1_BITS+3);
-
- dataptr++; /* advance pointer to next column */
- }
-}
-
-#undef DCTSIZE
-#define DCTSIZE 4
-#define DCTSTRIDE 8
-
-void ff_j_rev_dct4(DCTBLOCK data)
-{
- int32_t tmp0, tmp1, tmp2, tmp3;
- int32_t tmp10, tmp11, tmp12, tmp13;
- int32_t z1;
- int32_t d0, d2, d4, d6;
- register int16_t *dataptr;
- int rowctr;
-
- /* Pass 1: process rows. */
- /* Note results are scaled up by sqrt(8) compared to a true IDCT; */
- /* furthermore, we scale the results by 2**PASS1_BITS. */
-
- data[0] += 4;
-
- dataptr = data;
-
- for (rowctr = DCTSIZE-1; rowctr >= 0; rowctr--) {
- /* Due to quantization, we will usually find that many of the input
- * coefficients are zero, especially the AC terms. We can exploit this
- * by short-circuiting the IDCT calculation for any row in which all
- * the AC terms are zero. In that case each output is equal to the
- * DC coefficient (with scale factor as needed).
- * With typical images and quantization tables, half or more of the
- * row DCT calculations can be simplified this way.
- */
-
- register int *idataptr = (int*)dataptr;
-
- d0 = dataptr[0];
- d2 = dataptr[1];
- d4 = dataptr[2];
- d6 = dataptr[3];
-
- if ((d2 | d4 | d6) == 0) {
- /* AC terms all zero */
- if (d0) {
- /* Compute a 32 bit value to assign. */
- int16_t dcval = (int16_t) (d0 << PASS1_BITS);
- register int v = (dcval & 0xffff) | ((dcval << 16) & 0xffff0000);
-
- idataptr[0] = v;
- idataptr[1] = v;
- }
-
- dataptr += DCTSTRIDE; /* advance pointer to next row */
- continue;
- }
-
- /* Even part: reverse the even part of the forward DCT. */
- /* The rotator is sqrt(2)*c(-6). */
- if (d6) {
- if (d2) {
- /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */
- z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
- tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
- tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
-
- tmp0 = (d0 + d4) << CONST_BITS;
- tmp1 = (d0 - d4) << CONST_BITS;
-
- tmp10 = tmp0 + tmp3;
- tmp13 = tmp0 - tmp3;
- tmp11 = tmp1 + tmp2;
- tmp12 = tmp1 - tmp2;
- } else {
- /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */
- tmp2 = MULTIPLY(-d6, FIX_1_306562965);
- tmp3 = MULTIPLY(d6, FIX_0_541196100);
-
- tmp0 = (d0 + d4) << CONST_BITS;
- tmp1 = (d0 - d4) << CONST_BITS;
-
- tmp10 = tmp0 + tmp3;
- tmp13 = tmp0 - tmp3;
- tmp11 = tmp1 + tmp2;
- tmp12 = tmp1 - tmp2;
- }
- } else {
- if (d2) {
- /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */
- tmp2 = MULTIPLY(d2, FIX_0_541196100);
- tmp3 = MULTIPLY(d2, FIX_1_306562965);
-
- tmp0 = (d0 + d4) << CONST_BITS;
- tmp1 = (d0 - d4) << CONST_BITS;
-
- tmp10 = tmp0 + tmp3;
- tmp13 = tmp0 - tmp3;
- tmp11 = tmp1 + tmp2;
- tmp12 = tmp1 - tmp2;
- } else {
- /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */
- tmp10 = tmp13 = (d0 + d4) << CONST_BITS;
- tmp11 = tmp12 = (d0 - d4) << CONST_BITS;
- }
- }
-
- /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
-
- dataptr[0] = (int16_t) DESCALE(tmp10, CONST_BITS-PASS1_BITS);
- dataptr[1] = (int16_t) DESCALE(tmp11, CONST_BITS-PASS1_BITS);
- dataptr[2] = (int16_t) DESCALE(tmp12, CONST_BITS-PASS1_BITS);
- dataptr[3] = (int16_t) DESCALE(tmp13, CONST_BITS-PASS1_BITS);
-
- dataptr += DCTSTRIDE; /* advance pointer to next row */
- }
-
- /* Pass 2: process columns. */
- /* Note that we must descale the results by a factor of 8 == 2**3, */
- /* and also undo the PASS1_BITS scaling. */
-
- dataptr = data;
- for (rowctr = DCTSIZE-1; rowctr >= 0; rowctr--) {
- /* Columns of zeroes can be exploited in the same way as we did with rows.
- * However, the row calculation has created many nonzero AC terms, so the
- * simplification applies less often (typically 5% to 10% of the time).
- * On machines with very fast multiplication, it's possible that the
- * test takes more time than it's worth. In that case this section
- * may be commented out.
- */
-
- d0 = dataptr[DCTSTRIDE*0];
- d2 = dataptr[DCTSTRIDE*1];
- d4 = dataptr[DCTSTRIDE*2];
- d6 = dataptr[DCTSTRIDE*3];
-
- /* Even part: reverse the even part of the forward DCT. */
- /* The rotator is sqrt(2)*c(-6). */
- if (d6) {
- if (d2) {
- /* d0 != 0, d2 != 0, d4 != 0, d6 != 0 */
- z1 = MULTIPLY(d2 + d6, FIX_0_541196100);
- tmp2 = z1 + MULTIPLY(-d6, FIX_1_847759065);
- tmp3 = z1 + MULTIPLY(d2, FIX_0_765366865);
-
- tmp0 = (d0 + d4) << CONST_BITS;
- tmp1 = (d0 - d4) << CONST_BITS;
-
- tmp10 = tmp0 + tmp3;
- tmp13 = tmp0 - tmp3;
- tmp11 = tmp1 + tmp2;
- tmp12 = tmp1 - tmp2;
- } else {
- /* d0 != 0, d2 == 0, d4 != 0, d6 != 0 */
- tmp2 = MULTIPLY(-d6, FIX_1_306562965);
- tmp3 = MULTIPLY(d6, FIX_0_541196100);
-
- tmp0 = (d0 + d4) << CONST_BITS;
- tmp1 = (d0 - d4) << CONST_BITS;
-
- tmp10 = tmp0 + tmp3;
- tmp13 = tmp0 - tmp3;
- tmp11 = tmp1 + tmp2;
- tmp12 = tmp1 - tmp2;
- }
- } else {
- if (d2) {
- /* d0 != 0, d2 != 0, d4 != 0, d6 == 0 */
- tmp2 = MULTIPLY(d2, FIX_0_541196100);
- tmp3 = MULTIPLY(d2, FIX_1_306562965);
-
- tmp0 = (d0 + d4) << CONST_BITS;
- tmp1 = (d0 - d4) << CONST_BITS;
-
- tmp10 = tmp0 + tmp3;
- tmp13 = tmp0 - tmp3;
- tmp11 = tmp1 + tmp2;
- tmp12 = tmp1 - tmp2;
- } else {
- /* d0 != 0, d2 == 0, d4 != 0, d6 == 0 */
- tmp10 = tmp13 = (d0 + d4) << CONST_BITS;
- tmp11 = tmp12 = (d0 - d4) << CONST_BITS;
- }
- }
-
- /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
-
- dataptr[DCTSTRIDE*0] = tmp10 >> (CONST_BITS+PASS1_BITS+3);
- dataptr[DCTSTRIDE*1] = tmp11 >> (CONST_BITS+PASS1_BITS+3);
- dataptr[DCTSTRIDE*2] = tmp12 >> (CONST_BITS+PASS1_BITS+3);
- dataptr[DCTSTRIDE*3] = tmp13 >> (CONST_BITS+PASS1_BITS+3);
-
- dataptr++; /* advance pointer to next column */
- }
-}
-
-void ff_j_rev_dct2(DCTBLOCK data){
- int d00, d01, d10, d11;
-
- data[0] += 4;
- d00 = data[0+0*DCTSTRIDE] + data[1+0*DCTSTRIDE];
- d01 = data[0+0*DCTSTRIDE] - data[1+0*DCTSTRIDE];
- d10 = data[0+1*DCTSTRIDE] + data[1+1*DCTSTRIDE];
- d11 = data[0+1*DCTSTRIDE] - data[1+1*DCTSTRIDE];
-
- data[0+0*DCTSTRIDE]= (d00 + d10)>>3;
- data[1+0*DCTSTRIDE]= (d01 + d11)>>3;
- data[0+1*DCTSTRIDE]= (d00 - d10)>>3;
- data[1+1*DCTSTRIDE]= (d01 - d11)>>3;
-}
-
-void ff_j_rev_dct1(DCTBLOCK data){
- data[0] = (data[0] + 4)>>3;
-}
-
-#undef FIX
-#undef CONST_BITS
diff --git a/src/thirdparty/ffmpeg/libavcodec/kbdwin.c b/src/thirdparty/ffmpeg/libavcodec/kbdwin.c
deleted file mode 100644
index 43e5f4fe6..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/kbdwin.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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/avassert.h"
-#include "libavutil/mathematics.h"
-#include "libavutil/attributes.h"
-#include "kbdwin.h"
-
-#define BESSEL_I0_ITER 50 // default: 50 iterations of Bessel I0 approximation
-
-av_cold void ff_kbd_window_init(float *window, float alpha, int n)
-{
- int i, j;
- double sum = 0.0, bessel, tmp;
- double local_window[FF_KBD_WINDOW_MAX];
- double alpha2 = (alpha * M_PI / n) * (alpha * M_PI / n);
-
- av_assert0(n <= FF_KBD_WINDOW_MAX);
-
- for (i = 0; i < n; i++) {
- tmp = i * (n - i) * alpha2;
- bessel = 1.0;
- for (j = BESSEL_I0_ITER; j > 0; j--)
- bessel = bessel * tmp / (j * j) + 1;
- sum += bessel;
- local_window[i] = sum;
- }
-
- sum++;
- for (i = 0; i < n; i++)
- window[i] = sqrt(local_window[i] / sum);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/kbdwin.h b/src/thirdparty/ffmpeg/libavcodec/kbdwin.h
deleted file mode 100644
index c2dc6944f..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/kbdwin.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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_KBDWIN_H
-#define AVCODEC_KBDWIN_H
-
-/**
- * Maximum window size for ff_kbd_window_init.
- */
-#define FF_KBD_WINDOW_MAX 1024
-
-/**
- * Generate a Kaiser-Bessel Derived Window.
- * @param window pointer to half window
- * @param alpha determines window shape
- * @param n size of half window, max FF_KBD_WINDOW_MAX
- */
-void ff_kbd_window_init(float *window, float alpha, int n);
-
-#endif /* AVCODEC_KBDWIN_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/latm_parser.c b/src/thirdparty/ffmpeg/libavcodec/latm_parser.c
deleted file mode 100644
index 3820f58d6..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/latm_parser.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * copyright (c) 2008 Paul Kendall <paul@kcbbs.gen.nz>
- *
- * 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
- * AAC LATM parser
- */
-
-#include <stdint.h>
-#include "parser.h"
-
-#define LATM_HEADER 0x56e000 // 0x2b7 (11 bits)
-#define LATM_MASK 0xFFE000 // top 11 bits
-#define LATM_SIZE_MASK 0x001FFF // bottom 13 bits
-
-typedef struct LATMParseContext{
- ParseContext pc;
- int count;
-} LATMParseContext;
-
-/**
- * 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 latm_find_frame_end(AVCodecParserContext *s1, const uint8_t *buf,
- int buf_size)
-{
- LATMParseContext *s = s1->priv_data;
- ParseContext *pc = &s->pc;
- int pic_found, i;
- uint32_t state;
-
- pic_found = pc->frame_start_found;
- state = pc->state;
-
- if (!pic_found) {
- for (i = 0; i < buf_size; i++) {
- state = (state<<8) | buf[i];
- if ((state & LATM_MASK) == LATM_HEADER) {
- i++;
- s->count = -i;
- pic_found = 1;
- break;
- }
- }
- }
-
- if (pic_found) {
- /* EOF considered as end of frame */
- if (buf_size == 0)
- return 0;
- if ((state & LATM_SIZE_MASK) - s->count <= buf_size) {
- pc->frame_start_found = 0;
- pc->state = -1;
- return (state & LATM_SIZE_MASK) - s->count;
- }
- }
-
- s->count += buf_size;
- pc->frame_start_found = pic_found;
- pc->state = state;
-
- return END_NOT_FOUND;
-}
-
-static int latm_parse(AVCodecParserContext *s1, AVCodecContext *avctx,
- const uint8_t **poutbuf, int *poutbuf_size,
- const uint8_t *buf, int buf_size)
-{
- LATMParseContext *s = s1->priv_data;
- ParseContext *pc = &s->pc;
- int next;
-
- if (s1->flags & PARSER_FLAG_COMPLETE_FRAMES) {
- next = buf_size;
- } else {
- next = latm_find_frame_end(s1, buf, buf_size);
-
- if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
- *poutbuf = NULL;
- *poutbuf_size = 0;
- return buf_size;
- }
- }
- *poutbuf = buf;
- *poutbuf_size = buf_size;
- return next;
-}
-
-AVCodecParser ff_aac_latm_parser = {
- .codec_ids = { AV_CODEC_ID_AAC_LATM },
- .priv_data_size = sizeof(LATMParseContext),
- .parser_parse = latm_parse,
- .parser_close = ff_parse_close
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/log2_tab.c b/src/thirdparty/ffmpeg/libavcodec/log2_tab.c
deleted file mode 100644
index 47a1df03b..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/log2_tab.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "libavutil/log2_tab.c"
diff --git a/src/thirdparty/ffmpeg/libavcodec/lpc.h b/src/thirdparty/ffmpeg/libavcodec/lpc.h
deleted file mode 100644
index dd401af4d..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/lpc.h
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * LPC utility code
- * Copyright (c) 2006 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
- */
-
-#ifndef AVCODEC_LPC_H
-#define AVCODEC_LPC_H
-
-#include <stdint.h>
-#include "libavutil/avassert.h"
-#include "dsputil.h"
-
-#define ORDER_METHOD_EST 0
-#define ORDER_METHOD_2LEVEL 1
-#define ORDER_METHOD_4LEVEL 2
-#define ORDER_METHOD_8LEVEL 3
-#define ORDER_METHOD_SEARCH 4
-#define ORDER_METHOD_LOG 5
-
-#define MIN_LPC_ORDER 1
-#define MAX_LPC_ORDER 32
-
-/**
- * LPC analysis type
- */
-enum FFLPCType {
- FF_LPC_TYPE_DEFAULT = -1, ///< use the codec default LPC type
- FF_LPC_TYPE_NONE = 0, ///< do not use LPC prediction or use all zero coefficients
- FF_LPC_TYPE_FIXED = 1, ///< fixed LPC coefficients
- FF_LPC_TYPE_LEVINSON = 2, ///< Levinson-Durbin recursion
- FF_LPC_TYPE_CHOLESKY = 3, ///< Cholesky factorization
- FF_LPC_TYPE_NB , ///< Not part of ABI
-};
-
-typedef struct LPCContext {
- int blocksize;
- int max_order;
- enum FFLPCType lpc_type;
- double *windowed_buffer;
- double *windowed_samples;
-
- /**
- * Apply a Welch window to an array of input samples.
- * The output samples have the same scale as the input, but are in double
- * sample format.
- * @param data input samples
- * @param len number of input samples
- * @param w_data output samples
- */
- void (*lpc_apply_welch_window)(const int32_t *data, int len,
- double *w_data);
- /**
- * Perform autocorrelation on input samples with delay of 0 to lag.
- * @param data input samples.
- * constraints: no alignment needed, but must have have at
- * least lag*sizeof(double) valid bytes preceding it, and
- * size must be at least (len+1)*sizeof(double) if data is
- * 16-byte aligned or (len+2)*sizeof(double) if data is
- * unaligned.
- * @param len number of input samples to process
- * @param lag maximum delay to calculate
- * @param autoc output autocorrelation coefficients.
- * constraints: array size must be at least lag+1.
- */
- void (*lpc_compute_autocorr)(const double *data, int len, int lag,
- double *autoc);
-} LPCContext;
-
-
-/**
- * Calculate LPC coefficients for multiple orders
- */
-int ff_lpc_calc_coefs(LPCContext *s,
- const int32_t *samples, int blocksize, int min_order,
- int max_order, int precision,
- int32_t coefs[][MAX_LPC_ORDER], int *shift,
- enum FFLPCType lpc_type, int lpc_passes,
- int omethod, int max_shift, int zero_shift);
-
-int ff_lpc_calc_ref_coefs(LPCContext *s,
- const int32_t *samples, int order, double *ref);
-
-/**
- * Initialize LPCContext.
- */
-int ff_lpc_init(LPCContext *s, int blocksize, int max_order,
- enum FFLPCType lpc_type);
-void ff_lpc_init_x86(LPCContext *s);
-
-/**
- * Uninitialize LPCContext.
- */
-void ff_lpc_end(LPCContext *s);
-
-#ifdef LPC_USE_DOUBLE
-#define LPC_TYPE double
-#else
-#define LPC_TYPE float
-#endif
-
-/**
- * Schur recursion.
- * Produces reflection coefficients from autocorrelation data.
- */
-static inline void compute_ref_coefs(const LPC_TYPE *autoc, int max_order,
- LPC_TYPE *ref, LPC_TYPE *error)
-{
- int i, j;
- LPC_TYPE err;
- LPC_TYPE gen0[MAX_LPC_ORDER], gen1[MAX_LPC_ORDER];
-
- for (i = 0; i < max_order; i++)
- gen0[i] = gen1[i] = autoc[i + 1];
-
- err = autoc[0];
- ref[0] = -gen1[0] / err;
- err += gen1[0] * ref[0];
- if (error)
- error[0] = err;
- for (i = 1; i < max_order; i++) {
- for (j = 0; j < max_order - i; j++) {
- gen1[j] = gen1[j + 1] + ref[i - 1] * gen0[j];
- gen0[j] = gen1[j + 1] * ref[i - 1] + gen0[j];
- }
- ref[i] = -gen1[0] / err;
- err += gen1[0] * ref[i];
- if (error)
- error[i] = err;
- }
-}
-
-/**
- * Levinson-Durbin recursion.
- * Produce LPC coefficients from autocorrelation data.
- */
-static inline int compute_lpc_coefs(const LPC_TYPE *autoc, int max_order,
- LPC_TYPE *lpc, int lpc_stride, int fail,
- int normalize)
-{
- int i, j;
- LPC_TYPE err;
- LPC_TYPE *lpc_last = lpc;
-
- av_assert2(normalize || !fail);
-
- if (normalize)
- err = *autoc++;
-
- if (fail && (autoc[max_order - 1] == 0 || err <= 0))
- return -1;
-
- for(i=0; i<max_order; i++) {
- LPC_TYPE r = -autoc[i];
-
- if (normalize) {
- for(j=0; j<i; j++)
- r -= lpc_last[j] * autoc[i-j-1];
-
- r /= err;
- err *= 1.0 - (r * r);
- }
-
- lpc[i] = r;
-
- for(j=0; j < (i+1)>>1; j++) {
- LPC_TYPE f = lpc_last[ j];
- LPC_TYPE b = lpc_last[i-1-j];
- lpc[ j] = f + r * b;
- lpc[i-1-j] = b + r * f;
- }
-
- if (fail && err < 0)
- return -1;
-
- lpc_last = lpc;
- lpc += lpc_stride;
- }
-
- return 0;
-}
-
-#endif /* AVCODEC_LPC_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/lsp.c b/src/thirdparty/ffmpeg/libavcodec/lsp.c
deleted file mode 100644
index 527805e56..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/lsp.c
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * LSP routines for ACELP-based codecs
- *
- * Copyright (c) 2007 Reynaldo H. Verdejo Pinochet (QCELP decoder)
- * Copyright (c) 2008 Vladimir Voroshilov
- *
- * 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 <inttypes.h>
-
-#include "avcodec.h"
-#define FRAC_BITS 14
-#include "mathops.h"
-#include "lsp.h"
-#include "libavcodec/mips/lsp_mips.h"
-#include "libavutil/avassert.h"
-
-void ff_acelp_reorder_lsf(int16_t* lsfq, int lsfq_min_distance, int lsfq_min, int lsfq_max, int lp_order)
-{
- int i, j;
-
- /* sort lsfq in ascending order. float bubble agorithm,
- O(n) if data already sorted, O(n^2) - otherwise */
- for(i=0; i<lp_order-1; i++)
- for(j=i; j>=0 && lsfq[j] > lsfq[j+1]; j--)
- FFSWAP(int16_t, lsfq[j], lsfq[j+1]);
-
- for(i=0; i<lp_order; i++)
- {
- lsfq[i] = FFMAX(lsfq[i], lsfq_min);
- lsfq_min = lsfq[i] + lsfq_min_distance;
- }
- lsfq[lp_order-1] = FFMIN(lsfq[lp_order-1], lsfq_max);//Is warning required ?
-}
-
-void ff_set_min_dist_lsf(float *lsf, double min_spacing, int size)
-{
- int i;
- float prev = 0.0;
- for (i = 0; i < size; i++)
- prev = lsf[i] = FFMAX(lsf[i], prev + min_spacing);
-}
-
-
-/* Cosine table: base_cos[i] = (1 << 15) * cos(i * PI / 64) */
-static const int16_t tab_cos[65] =
-{
- 32767, 32738, 32617, 32421, 32145, 31793, 31364, 30860,
- 30280, 29629, 28905, 28113, 27252, 26326, 25336, 24285,
- 23176, 22011, 20793, 19525, 18210, 16851, 15451, 14014,
- 12543, 11043, 9515, 7965, 6395, 4810, 3214, 1609,
- 1, -1607, -3211, -4808, -6393, -7962, -9513, -11040,
- -12541, -14012, -15449, -16848, -18207, -19523, -20791, -22009,
- -23174, -24283, -25334, -26324, -27250, -28111, -28904, -29627,
- -30279, -30858, -31363, -31792, -32144, -32419, -32616, -32736, -32768,
-};
-
-static int16_t ff_cos(uint16_t arg)
-{
- uint8_t offset= arg;
- uint8_t ind = arg >> 8;
-
- av_assert2(arg <= 0x3fff);
-
- return tab_cos[ind] + (offset * (tab_cos[ind+1] - tab_cos[ind]) >> 8);
-}
-
-void ff_acelp_lsf2lsp(int16_t *lsp, const int16_t *lsf, int lp_order)
-{
- int i;
-
- /* Convert LSF to LSP, lsp=cos(lsf) */
- for(i=0; i<lp_order; i++)
- // 20861 = 2.0 / PI in (0.15)
- lsp[i] = ff_cos(lsf[i] * 20861 >> 15); // divide by PI and (0,13) -> (0,14)
-}
-
-void ff_acelp_lsf2lspd(double *lsp, const float *lsf, int lp_order)
-{
- int i;
-
- for(i = 0; i < lp_order; i++)
- lsp[i] = cos(2.0 * M_PI * lsf[i]);
-}
-
-/**
- * @brief decodes polynomial coefficients from LSP
- * @param[out] f decoded polynomial coefficients (-0x20000000 <= (3.22) <= 0x1fffffff)
- * @param lsp LSP coefficients (-0x8000 <= (0.15) <= 0x7fff)
- */
-static void lsp2poly(int* f, const int16_t* lsp, int lp_half_order)
-{
- int i, j;
-
- f[0] = 0x400000; // 1.0 in (3.22)
- f[1] = -lsp[0] << 8; // *2 and (0.15) -> (3.22)
-
- for(i=2; i<=lp_half_order; i++)
- {
- f[i] = f[i-2];
- for(j=i; j>1; j--)
- f[j] -= MULL(f[j-1], lsp[2*i-2], FRAC_BITS) - f[j-2];
-
- f[1] -= lsp[2*i-2] << 8;
- }
-}
-
-void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order)
-{
- int i;
- int f1[MAX_LP_HALF_ORDER+1]; // (3.22)
- int f2[MAX_LP_HALF_ORDER+1]; // (3.22)
-
- lsp2poly(f1, lsp , lp_half_order);
- lsp2poly(f2, lsp+1, lp_half_order);
-
- /* 3.2.6 of G.729, Equations 25 and 26*/
- lp[0] = 4096;
- for(i=1; i<lp_half_order+1; i++)
- {
- int ff1 = f1[i] + f1[i-1]; // (3.22)
- int ff2 = f2[i] - f2[i-1]; // (3.22)
-
- ff1 += 1 << 10; // for rounding
- lp[i] = (ff1 + ff2) >> 11; // divide by 2 and (3.22) -> (3.12)
- lp[(lp_half_order << 1) + 1 - i] = (ff1 - ff2) >> 11; // divide by 2 and (3.22) -> (3.12)
- }
-}
-
-void ff_amrwb_lsp2lpc(const double *lsp, float *lp, int lp_order)
-{
- int lp_half_order = lp_order >> 1;
- double buf[MAX_LP_HALF_ORDER + 1];
- double pa[MAX_LP_HALF_ORDER + 1];
- double *qa = buf + 1;
- int i,j;
-
- qa[-1] = 0.0;
-
- ff_lsp2polyf(lsp , pa, lp_half_order );
- ff_lsp2polyf(lsp + 1, qa, lp_half_order - 1);
-
- for (i = 1, j = lp_order - 1; i < lp_half_order; i++, j--) {
- double paf = pa[i] * (1 + lsp[lp_order - 1]);
- double qaf = (qa[i] - qa[i-2]) * (1 - lsp[lp_order - 1]);
- lp[i-1] = (paf + qaf) * 0.5;
- lp[j-1] = (paf - qaf) * 0.5;
- }
-
- lp[lp_half_order - 1] = (1.0 + lsp[lp_order - 1]) *
- pa[lp_half_order] * 0.5;
-
- lp[lp_order - 1] = lsp[lp_order - 1];
-}
-
-void ff_acelp_lp_decode(int16_t* lp_1st, int16_t* lp_2nd, const int16_t* lsp_2nd, const int16_t* lsp_prev, int lp_order)
-{
- int16_t lsp_1st[MAX_LP_ORDER]; // (0.15)
- int i;
-
- /* LSP values for first subframe (3.2.5 of G.729, Equation 24)*/
- for(i=0; i<lp_order; i++)
-#ifdef G729_BITEXACT
- lsp_1st[i] = (lsp_2nd[i] >> 1) + (lsp_prev[i] >> 1);
-#else
- lsp_1st[i] = (lsp_2nd[i] + lsp_prev[i]) >> 1;
-#endif
-
- ff_acelp_lsp2lpc(lp_1st, lsp_1st, lp_order >> 1);
-
- /* LSP values for second subframe (3.2.5 of G.729)*/
- ff_acelp_lsp2lpc(lp_2nd, lsp_2nd, lp_order >> 1);
-}
-
-#ifndef ff_lsp2polyf
-void ff_lsp2polyf(const double *lsp, double *f, int lp_half_order)
-{
- int i, j;
-
- f[0] = 1.0;
- f[1] = -2 * lsp[0];
- lsp -= 2;
- for(i=2; i<=lp_half_order; i++)
- {
- double val = -2 * lsp[2*i];
- f[i] = val * f[i-1] + 2*f[i-2];
- for(j=i-1; j>1; j--)
- f[j] += f[j-1] * val + f[j-2];
- f[1] += val;
- }
-}
-#endif /* ff_lsp2polyf */
-
-void ff_acelp_lspd2lpc(const double *lsp, float *lpc, int lp_half_order)
-{
- double pa[MAX_LP_HALF_ORDER+1], qa[MAX_LP_HALF_ORDER+1];
- float *lpc2 = lpc + (lp_half_order << 1) - 1;
-
- av_assert2(lp_half_order <= MAX_LP_HALF_ORDER);
-
- ff_lsp2polyf(lsp, pa, lp_half_order);
- ff_lsp2polyf(lsp + 1, qa, lp_half_order);
-
- while (lp_half_order--) {
- double paf = pa[lp_half_order+1] + pa[lp_half_order];
- double qaf = qa[lp_half_order+1] - qa[lp_half_order];
-
- lpc [ lp_half_order] = 0.5*(paf+qaf);
- lpc2[-lp_half_order] = 0.5*(paf-qaf);
- }
-}
-
-void ff_sort_nearly_sorted_floats(float *vals, int len)
-{
- int i,j;
-
- for (i = 0; i < len - 1; i++)
- for (j = i; j >= 0 && vals[j] > vals[j+1]; j--)
- FFSWAP(float, vals[j], vals[j+1]);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/lsp.h b/src/thirdparty/ffmpeg/libavcodec/lsp.h
deleted file mode 100644
index 1f1c18655..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/lsp.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * LSP computing for ACELP-based codecs
- *
- * Copyright (c) 2008 Vladimir Voroshilov
- *
- * 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_LSP_H
-#define AVCODEC_LSP_H
-
-#include <stdint.h>
-
-/**
- (I.F) means fixed-point value with F fractional and I integer bits
-*/
-
-/**
- * @brief ensure a minimum distance between LSFs
- * @param[in,out] lsfq LSF to check and adjust
- * @param lsfq_min_distance minimum distance between LSFs
- * @param lsfq_min minimum allowed LSF value
- * @param lsfq_max maximum allowed LSF value
- * @param lp_order LP filter order
- */
-void ff_acelp_reorder_lsf(int16_t* lsfq, int lsfq_min_distance, int lsfq_min, int lsfq_max, int lp_order);
-
-/**
- * Adjust the quantized LSFs so they are increasing and not too close.
- *
- * This step is not mentioned in the AMR spec but is in the reference C decoder.
- * Omitting this step creates audible distortion on the sinusoidal sweep
- * test vectors in 3GPP TS 26.074.
- *
- * @param[in,out] lsf LSFs in Hertz
- * @param min_spacing minimum distance between two consecutive lsf values
- * @param size size of the lsf vector
- */
-void ff_set_min_dist_lsf(float *lsf, double min_spacing, int size);
-
-/**
- * @brief Convert LSF to LSP
- * @param[out] lsp LSP coefficients (-0x8000 <= (0.15) < 0x8000)
- * @param lsf normalized LSF coefficients (0 <= (2.13) < 0x2000 * PI)
- * @param lp_order LP filter order
- *
- * @remark It is safe to pass the same array into the lsf and lsp parameters.
- */
-void ff_acelp_lsf2lsp(int16_t *lsp, const int16_t *lsf, int lp_order);
-
-/**
- * Floating point version of ff_acelp_lsf2lsp()
- */
-void ff_acelp_lsf2lspd(double *lsp, const float *lsf, int lp_order);
-
-/**
- * @brief LSP to LP conversion (3.2.6 of G.729)
- * @param[out] lp decoded LP coefficients (-0x8000 <= (3.12) < 0x8000)
- * @param lsp LSP coefficients (-0x8000 <= (0.15) < 0x8000)
- * @param lp_half_order LP filter order, divided by 2
- */
-void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order);
-
-/**
- * LSP to LP conversion (5.2.4 of AMR-WB)
- */
-void ff_amrwb_lsp2lpc(const double *lsp, float *lp, int lp_order);
-
-/**
- * @brief Interpolate LSP for the first subframe and convert LSP -> LP for both subframes (3.2.5 and 3.2.6 of G.729)
- * @param[out] lp_1st decoded LP coefficients for first subframe (-0x8000 <= (3.12) < 0x8000)
- * @param[out] lp_2nd decoded LP coefficients for second subframe (-0x8000 <= (3.12) < 0x8000)
- * @param lsp_2nd LSP coefficients of the second subframe (-0x8000 <= (0.15) < 0x8000)
- * @param lsp_prev LSP coefficients from the second subframe of the previous frame (-0x8000 <= (0.15) < 0x8000)
- * @param lp_order LP filter order
- */
-void ff_acelp_lp_decode(int16_t* lp_1st, int16_t* lp_2nd, const int16_t* lsp_2nd, const int16_t* lsp_prev, int lp_order);
-
-
-#define MAX_LP_HALF_ORDER 10
-#define MAX_LP_ORDER (2*MAX_LP_HALF_ORDER)
-
-/**
- * Reconstruct LPC coefficients from the line spectral pair frequencies.
- *
- * @param lsp line spectral pairs in cosine domain
- * @param lpc linear predictive coding coefficients
- * @param lp_half_order half the number of the amount of LPCs to be
- * reconstructed, need to be smaller or equal to MAX_LP_HALF_ORDER
- *
- * @note buffers should have a minimux size of 2*lp_half_order elements.
- *
- * TIA/EIA/IS-733 2.4.3.3.5
- */
-void ff_acelp_lspd2lpc(const double *lsp, float *lpc, int lp_half_order);
-
-/**
- * Sort values in ascending order.
- *
- * @note O(n) if data already sorted, O(n^2) - otherwise
- */
-void ff_sort_nearly_sorted_floats(float *vals, int len);
-
-/**
- * Compute the Pa / (1 + z(-1)) or Qa / (1 - z(-1)) coefficients
- * needed for LSP to LPC conversion.
- * We only need to calculate the 6 first elements of the polynomial.
- *
- * @param lsp line spectral pairs in cosine domain
- * @param[out] f polynomial input/output as a vector
- *
- * TIA/EIA/IS-733 2.4.3.3.5-1/2
- */
-void ff_lsp2polyf(const double *lsp, double *f, int lp_half_order);
-
-#endif /* AVCODEC_LSP_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/mathops.h b/src/thirdparty/ffmpeg/libavcodec/mathops.h
deleted file mode 100644
index 66834e83b..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mathops.h
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * simple math operations
- * Copyright (c) 2001, 2002 Fabrice Bellard
- * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> et al
- *
- * 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_MATHOPS_H
-#define AVCODEC_MATHOPS_H
-
-#include <stdint.h>
-
-#include "libavutil/common.h"
-#include "config.h"
-
-extern const uint32_t ff_inverse[257];
-extern const uint8_t ff_reverse[256];
-extern const uint8_t ff_sqrt_tab[256];
-
-#if ARCH_ARM
-# include "arm/mathops.h"
-#elif ARCH_AVR32
-# include "avr32/mathops.h"
-#elif ARCH_BFIN
-# include "bfin/mathops.h"
-#elif ARCH_MIPS
-# include "mips/mathops.h"
-#elif ARCH_PPC
-# include "ppc/mathops.h"
-#elif ARCH_X86
-# include "x86/mathops.h"
-#endif
-
-/* generic implementation */
-
-#ifndef MUL64
-# define MUL64(a,b) ((int64_t)(a) * (int64_t)(b))
-#endif
-
-#ifndef MULL
-# define MULL(a,b,s) (MUL64(a, b) >> (s))
-#endif
-
-#ifndef MULH
-static av_always_inline int MULH(int a, int b){
- return MUL64(a, b) >> 32;
-}
-#endif
-
-#ifndef UMULH
-static av_always_inline unsigned UMULH(unsigned a, unsigned b){
- return ((uint64_t)(a) * (uint64_t)(b))>>32;
-}
-#endif
-
-#ifndef MAC64
-# define MAC64(d, a, b) ((d) += MUL64(a, b))
-#endif
-
-#ifndef MLS64
-# define MLS64(d, a, b) ((d) -= MUL64(a, b))
-#endif
-
-/* signed 16x16 -> 32 multiply add accumulate */
-#ifndef MAC16
-# define MAC16(rt, ra, rb) rt += (ra) * (rb)
-#endif
-
-/* signed 16x16 -> 32 multiply */
-#ifndef MUL16
-# define MUL16(ra, rb) ((ra) * (rb))
-#endif
-
-#ifndef MLS16
-# define MLS16(rt, ra, rb) ((rt) -= (ra) * (rb))
-#endif
-
-/* median of 3 */
-#ifndef mid_pred
-#define mid_pred mid_pred
-static inline av_const int mid_pred(int a, int b, int c)
-{
-#if 0
- int t= (a-b)&((a-b)>>31);
- a-=t;
- b+=t;
- b-= (b-c)&((b-c)>>31);
- b+= (a-b)&((a-b)>>31);
-
- return b;
-#else
- if(a>b){
- if(c>b){
- if(c>a) b=a;
- else b=c;
- }
- }else{
- if(b>c){
- if(c>a) b=c;
- else b=a;
- }
- }
- return b;
-#endif
-}
-#endif
-
-#ifndef sign_extend
-static inline av_const int sign_extend(int val, unsigned bits)
-{
- unsigned shift = 8 * sizeof(int) - bits;
- union { unsigned u; int s; } v = { (unsigned) val << shift };
- return v.s >> shift;
-}
-#endif
-
-#ifndef zero_extend
-static inline av_const unsigned zero_extend(unsigned val, unsigned bits)
-{
- return (val << ((8 * sizeof(int)) - bits)) >> ((8 * sizeof(int)) - bits);
-}
-#endif
-
-#ifndef COPY3_IF_LT
-#define COPY3_IF_LT(x, y, a, b, c, d)\
-if ((y) < (x)) {\
- (x) = (y);\
- (a) = (b);\
- (c) = (d);\
-}
-#endif
-
-#ifndef MASK_ABS
-#define MASK_ABS(mask, level) do { \
- mask = level >> 31; \
- level = (level ^ mask) - mask; \
- } while (0)
-#endif
-
-#ifndef NEG_SSR32
-# define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s)))
-#endif
-
-#ifndef NEG_USR32
-# define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s)))
-#endif
-
-#if HAVE_BIGENDIAN
-# ifndef PACK_2U8
-# define PACK_2U8(a,b) (((a) << 8) | (b))
-# endif
-# ifndef PACK_4U8
-# define PACK_4U8(a,b,c,d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
-# endif
-# ifndef PACK_2U16
-# define PACK_2U16(a,b) (((a) << 16) | (b))
-# endif
-#else
-# ifndef PACK_2U8
-# define PACK_2U8(a,b) (((b) << 8) | (a))
-# endif
-# ifndef PACK_4U2
-# define PACK_4U8(a,b,c,d) (((d) << 24) | ((c) << 16) | ((b) << 8) | (a))
-# endif
-# ifndef PACK_2U16
-# define PACK_2U16(a,b) (((b) << 16) | (a))
-# endif
-#endif
-
-#ifndef PACK_2S8
-# define PACK_2S8(a,b) PACK_2U8((a)&255, (b)&255)
-#endif
-#ifndef PACK_4S8
-# define PACK_4S8(a,b,c,d) PACK_4U8((a)&255, (b)&255, (c)&255, (d)&255)
-#endif
-#ifndef PACK_2S16
-# define PACK_2S16(a,b) PACK_2U16((a)&0xffff, (b)&0xffff)
-#endif
-
-#ifndef FASTDIV
-# define FASTDIV(a,b) ((uint32_t)((((uint64_t)a) * ff_inverse[b]) >> 32))
-#endif /* FASTDIV */
-
-static inline av_const unsigned int ff_sqrt(unsigned int a)
-{
- unsigned int b;
-
- if (a < 255) return (ff_sqrt_tab[a + 1] - 1) >> 4;
- else if (a < (1 << 12)) b = ff_sqrt_tab[a >> 4] >> 2;
-#if !CONFIG_SMALL
- else if (a < (1 << 14)) b = ff_sqrt_tab[a >> 6] >> 1;
- else if (a < (1 << 16)) b = ff_sqrt_tab[a >> 8] ;
-#endif
- else {
- int s = av_log2_16bit(a >> 16) >> 1;
- unsigned int c = a >> (s + 2);
- b = ff_sqrt_tab[c >> (s + 8)];
- b = FASTDIV(c,b) + (b << s);
- }
-
- return b - (a < b * b);
-}
-
-#endif /* AVCODEC_MATHOPS_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/mathtables.c b/src/thirdparty/ffmpeg/libavcodec/mathtables.c
deleted file mode 100644
index 037b135a1..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mathtables.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2002-2004 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
- */
-
-#include <stdint.h>
-
-/* a*inverse[b]>>32 == a/b for all 0<=a<=16909558 && 2<=b<=256
- * for a>16909558, is an overestimate by less than 1 part in 1<<24 */
-const uint32_t ff_inverse[257]={
- 0, 4294967295U,2147483648U,1431655766, 1073741824, 858993460, 715827883, 613566757,
- 536870912, 477218589, 429496730, 390451573, 357913942, 330382100, 306783379, 286331154,
- 268435456, 252645136, 238609295, 226050911, 214748365, 204522253, 195225787, 186737709,
- 178956971, 171798692, 165191050, 159072863, 153391690, 148102321, 143165577, 138547333,
- 134217728, 130150525, 126322568, 122713352, 119304648, 116080198, 113025456, 110127367,
- 107374183, 104755300, 102261127, 99882961, 97612894, 95443718, 93368855, 91382283,
- 89478486, 87652394, 85899346, 84215046, 82595525, 81037119, 79536432, 78090315,
- 76695845, 75350304, 74051161, 72796056, 71582789, 70409300, 69273667, 68174085,
- 67108864, 66076420, 65075263, 64103990, 63161284, 62245903, 61356676, 60492498,
- 59652324, 58835169, 58040099, 57266231, 56512728, 55778797, 55063684, 54366675,
- 53687092, 53024288, 52377650, 51746594, 51130564, 50529028, 49941481, 49367441,
- 48806447, 48258060, 47721859, 47197443, 46684428, 46182445, 45691142, 45210183,
- 44739243, 44278014, 43826197, 43383509, 42949673, 42524429, 42107523, 41698712,
- 41297763, 40904451, 40518560, 40139882, 39768216, 39403370, 39045158, 38693400,
- 38347923, 38008561, 37675152, 37347542, 37025581, 36709123, 36398028, 36092163,
- 35791395, 35495598, 35204650, 34918434, 34636834, 34359739, 34087043, 33818641,
- 33554432, 33294321, 33038210, 32786010, 32537632, 32292988, 32051995, 31814573,
- 31580642, 31350127, 31122952, 30899046, 30678338, 30460761, 30246249, 30034737,
- 29826162, 29620465, 29417585, 29217465, 29020050, 28825284, 28633116, 28443493,
- 28256364, 28071682, 27889399, 27709467, 27531842, 27356480, 27183338, 27012373,
- 26843546, 26676816, 26512144, 26349493, 26188825, 26030105, 25873297, 25718368,
- 25565282, 25414008, 25264514, 25116768, 24970741, 24826401, 24683721, 24542671,
- 24403224, 24265352, 24129030, 23994231, 23860930, 23729102, 23598722, 23469767,
- 23342214, 23216040, 23091223, 22967740, 22845571, 22724695, 22605092, 22486740,
- 22369622, 22253717, 22139007, 22025474, 21913099, 21801865, 21691755, 21582751,
- 21474837, 21367997, 21262215, 21157475, 21053762, 20951060, 20849356, 20748635,
- 20648882, 20550083, 20452226, 20355296, 20259280, 20164166, 20069941, 19976593,
- 19884108, 19792477, 19701685, 19611723, 19522579, 19434242, 19346700, 19259944,
- 19173962, 19088744, 19004281, 18920561, 18837576, 18755316, 18673771, 18592933,
- 18512791, 18433337, 18354562, 18276457, 18199014, 18122225, 18046082, 17970575,
- 17895698, 17821442, 17747799, 17674763, 17602325, 17530479, 17459217, 17388532,
- 17318417, 17248865, 17179870, 17111424, 17043522, 16976156, 16909321, 16843010,
- 16777216
-};
-
-const uint8_t ff_sqrt_tab[256]={
- 0, 16, 23, 28, 32, 36, 40, 43, 46, 48, 51, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 77, 79, 80, 82, 84, 85, 87, 88, 90,
- 91, 92, 94, 95, 96, 98, 99,100,102,103,104,105,107,108,109,110,111,112,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,144,145,146,147,148,149,150,151,151,152,153,154,155,156,156,
-157,158,159,160,160,161,162,163,164,164,165,166,167,168,168,169,170,171,171,172,173,174,174,175,176,176,177,178,179,179,180,181,
-182,182,183,184,184,185,186,186,187,188,188,189,190,190,191,192,192,193,194,194,195,196,196,197,198,198,199,200,200,201,202,202,
-203,204,204,205,205,206,207,207,208,208,209,210,210,211,212,212,213,213,214,215,215,216,216,217,218,218,219,219,220,220,221,222,
-222,223,223,224,224,225,226,226,227,227,228,228,229,230,230,231,231,232,232,233,233,234,235,235,236,236,237,237,238,238,239,239,
-240,240,241,242,242,243,243,244,244,245,245,246,246,247,247,248,248,249,249,250,250,251,251,252,252,253,253,254,254,255,255,255
-};
-
-const uint8_t ff_reverse[256] = {
-0x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50,0xD0,0x30,0xB0,0x70,0xF0,
-0x08,0x88,0x48,0xC8,0x28,0xA8,0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8,
-0x04,0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,0x34,0xB4,0x74,0xF4,
-0x0C,0x8C,0x4C,0xCC,0x2C,0xAC,0x6C,0xEC,0x1C,0x9C,0x5C,0xDC,0x3C,0xBC,0x7C,0xFC,
-0x02,0x82,0x42,0xC2,0x22,0xA2,0x62,0xE2,0x12,0x92,0x52,0xD2,0x32,0xB2,0x72,0xF2,
-0x0A,0x8A,0x4A,0xCA,0x2A,0xAA,0x6A,0xEA,0x1A,0x9A,0x5A,0xDA,0x3A,0xBA,0x7A,0xFA,
-0x06,0x86,0x46,0xC6,0x26,0xA6,0x66,0xE6,0x16,0x96,0x56,0xD6,0x36,0xB6,0x76,0xF6,
-0x0E,0x8E,0x4E,0xCE,0x2E,0xAE,0x6E,0xEE,0x1E,0x9E,0x5E,0xDE,0x3E,0xBE,0x7E,0xFE,
-0x01,0x81,0x41,0xC1,0x21,0xA1,0x61,0xE1,0x11,0x91,0x51,0xD1,0x31,0xB1,0x71,0xF1,
-0x09,0x89,0x49,0xC9,0x29,0xA9,0x69,0xE9,0x19,0x99,0x59,0xD9,0x39,0xB9,0x79,0xF9,
-0x05,0x85,0x45,0xC5,0x25,0xA5,0x65,0xE5,0x15,0x95,0x55,0xD5,0x35,0xB5,0x75,0xF5,
-0x0D,0x8D,0x4D,0xCD,0x2D,0xAD,0x6D,0xED,0x1D,0x9D,0x5D,0xDD,0x3D,0xBD,0x7D,0xFD,
-0x03,0x83,0x43,0xC3,0x23,0xA3,0x63,0xE3,0x13,0x93,0x53,0xD3,0x33,0xB3,0x73,0xF3,
-0x0B,0x8B,0x4B,0xCB,0x2B,0xAB,0x6B,0xEB,0x1B,0x9B,0x5B,0xDB,0x3B,0xBB,0x7B,0xFB,
-0x07,0x87,0x47,0xC7,0x27,0xA7,0x67,0xE7,0x17,0x97,0x57,0xD7,0x37,0xB7,0x77,0xF7,
-0x0F,0x8F,0x4F,0xCF,0x2F,0xAF,0x6F,0xEF,0x1F,0x9F,0x5F,0xDF,0x3F,0xBF,0x7F,0xFF,
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/mdct.c b/src/thirdparty/ffmpeg/libavcodec/mdct.c
deleted file mode 100644
index db986c5d2..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mdct.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * MDCT/IMDCT transforms
- * Copyright (c) 2002 Fabrice Bellard
- *
- * 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 <stdlib.h>
-#include <string.h>
-#include "libavutil/common.h"
-#include "libavutil/mathematics.h"
-#include "fft.h"
-#include "fft-internal.h"
-
-/**
- * @file
- * MDCT/IMDCT transforms.
- */
-
-#if CONFIG_FFT_FLOAT
-# define RSCALE(x) (x)
-#else
-# define RSCALE(x) ((x) >> 1)
-#endif
-
-/**
- * init MDCT or IMDCT computation.
- */
-av_cold int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale)
-{
- int n, n4, i;
- double alpha, theta;
- int tstep;
-
- memset(s, 0, sizeof(*s));
- n = 1 << nbits;
- s->mdct_bits = nbits;
- s->mdct_size = n;
- n4 = n >> 2;
- s->mdct_permutation = FF_MDCT_PERM_NONE;
-
- if (ff_fft_init(s, s->mdct_bits - 2, inverse) < 0)
- goto fail;
-
- s->tcos = av_malloc(n/2 * sizeof(FFTSample));
- if (!s->tcos)
- goto fail;
-
- switch (s->mdct_permutation) {
- case FF_MDCT_PERM_NONE:
- s->tsin = s->tcos + n4;
- tstep = 1;
- break;
- case FF_MDCT_PERM_INTERLEAVE:
- s->tsin = s->tcos + 1;
- tstep = 2;
- break;
- default:
- goto fail;
- }
-
- theta = 1.0 / 8.0 + (scale < 0 ? n4 : 0);
- scale = sqrt(fabs(scale));
- for(i=0;i<n4;i++) {
- alpha = 2 * M_PI * (i + theta) / n;
- s->tcos[i*tstep] = FIX15(-cos(alpha) * scale);
- s->tsin[i*tstep] = FIX15(-sin(alpha) * scale);
- }
- return 0;
- fail:
- ff_mdct_end(s);
- return -1;
-}
-
-/**
- * Compute the middle half of the inverse MDCT of size N = 2^nbits,
- * thus excluding the parts that can be derived by symmetry
- * @param output N/2 samples
- * @param input N/2 samples
- */
-void ff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input)
-{
- int k, n8, n4, n2, n, j;
- const uint16_t *revtab = s->revtab;
- const FFTSample *tcos = s->tcos;
- const FFTSample *tsin = s->tsin;
- const FFTSample *in1, *in2;
- FFTComplex *z = (FFTComplex *)output;
-
- n = 1 << s->mdct_bits;
- n2 = n >> 1;
- n4 = n >> 2;
- n8 = n >> 3;
-
- /* pre rotation */
- in1 = input;
- in2 = input + n2 - 1;
- for(k = 0; k < n4; k++) {
- j=revtab[k];
- CMUL(z[j].re, z[j].im, *in2, *in1, tcos[k], tsin[k]);
- in1 += 2;
- in2 -= 2;
- }
- s->fft_calc(s, z);
-
- /* post rotation + reordering */
- for(k = 0; k < n8; k++) {
- FFTSample r0, i0, r1, i1;
- CMUL(r0, i1, z[n8-k-1].im, z[n8-k-1].re, tsin[n8-k-1], tcos[n8-k-1]);
- CMUL(r1, i0, z[n8+k ].im, z[n8+k ].re, tsin[n8+k ], tcos[n8+k ]);
- z[n8-k-1].re = r0;
- z[n8-k-1].im = i0;
- z[n8+k ].re = r1;
- z[n8+k ].im = i1;
- }
-}
-
-/**
- * Compute inverse MDCT of size N = 2^nbits
- * @param output N samples
- * @param input N/2 samples
- */
-void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input)
-{
- int k;
- int n = 1 << s->mdct_bits;
- int n2 = n >> 1;
- int n4 = n >> 2;
-
- ff_imdct_half_c(s, output+n4, input);
-
- for(k = 0; k < n4; k++) {
- output[k] = -output[n2-k-1];
- output[n-k-1] = output[n2+k];
- }
-}
-
-/**
- * Compute MDCT of size N = 2^nbits
- * @param input N samples
- * @param out N/2 samples
- */
-void ff_mdct_calc_c(FFTContext *s, FFTSample *out, const FFTSample *input)
-{
- int i, j, n, n8, n4, n2, n3;
- FFTDouble re, im;
- const uint16_t *revtab = s->revtab;
- const FFTSample *tcos = s->tcos;
- const FFTSample *tsin = s->tsin;
- FFTComplex *x = (FFTComplex *)out;
-
- n = 1 << s->mdct_bits;
- n2 = n >> 1;
- n4 = n >> 2;
- n8 = n >> 3;
- n3 = 3 * n4;
-
- /* pre rotation */
- for(i=0;i<n8;i++) {
- re = RSCALE(-input[2*i+n3] - input[n3-1-2*i]);
- im = RSCALE(-input[n4+2*i] + input[n4-1-2*i]);
- j = revtab[i];
- CMUL(x[j].re, x[j].im, re, im, -tcos[i], tsin[i]);
-
- re = RSCALE( input[2*i] - input[n2-1-2*i]);
- im = RSCALE(-input[n2+2*i] - input[ n-1-2*i]);
- j = revtab[n8 + i];
- CMUL(x[j].re, x[j].im, re, im, -tcos[n8 + i], tsin[n8 + i]);
- }
-
- s->fft_calc(s, x);
-
- /* post rotation */
- for(i=0;i<n8;i++) {
- FFTSample r0, i0, r1, i1;
- CMUL(i1, r0, x[n8-i-1].re, x[n8-i-1].im, -tsin[n8-i-1], -tcos[n8-i-1]);
- CMUL(i0, r1, x[n8+i ].re, x[n8+i ].im, -tsin[n8+i ], -tcos[n8+i ]);
- x[n8-i-1].re = r0;
- x[n8-i-1].im = i0;
- x[n8+i ].re = r1;
- x[n8+i ].im = i1;
- }
-}
-
-av_cold void ff_mdct_end(FFTContext *s)
-{
- av_freep(&s->tcos);
- ff_fft_end(s);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/mips/amrwbdec_mips.h b/src/thirdparty/ffmpeg/libavcodec/mips/amrwbdec_mips.h
deleted file mode 100644
index a469918d2..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mips/amrwbdec_mips.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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: Nedeljko Babic (nbabic@mips.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
- * Reference: libavcodec/amrwbdec.c
- */
-#ifndef AVCODEC_AMRWBDEC_MIPS_H
-#define AVCODEC_AMRWBDEC_MIPS_H
-#include "config.h"
-
-#if HAVE_MIPSFPU && HAVE_INLINE_ASM
-void hb_fir_filter_mips(float *out, const float fir_coef[],
- float mem[], const float *in);
-#define hb_fir_filter hb_fir_filter_mips
-#endif
-
-#endif /* AVCODEC_AMRWBDEC_MIPS_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/mips/lsp_mips.h b/src/thirdparty/ffmpeg/libavcodec/mips/lsp_mips.h
deleted file mode 100644
index 749770625..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mips/lsp_mips.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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: Nedeljko Babic (nbabic@mips.com)
- *
- * LSP routines for ACELP-based codecs optimized for MIPS
- *
- * 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
- * Reference: libavcodec/lsp.c
- */
-#ifndef AVCODEC_LSP_MIPS_H
-#define AVCODEC_LSP_MIPS_H
-
-#if HAVE_MIPSFPU && HAVE_INLINE_ASM
-static av_always_inline void ff_lsp2polyf_mips(const double *lsp, double *f, int lp_half_order)
-{
- int i, j = 0;
- double * p_fi = f;
- double * p_f = 0;
-
- f[0] = 1.0;
- f[1] = -2 * lsp[0];
- lsp -= 2;
-
- for(i=2; i<=lp_half_order; i++)
- {
- double tmp, f_j_2, f_j_1, f_j;
- double val = lsp[2*i];
-
- __asm__ volatile(
- "move %[p_f], %[p_fi] \n\t"
- "add.d %[val], %[val], %[val] \n\t"
- "addiu %[p_fi], 8 \n\t"
- "ldc1 %[f_j_1], 0(%[p_f]) \n\t"
- "ldc1 %[f_j], 8(%[p_f]) \n\t"
- "neg.d %[val], %[val] \n\t"
- "add.d %[tmp], %[f_j_1], %[f_j_1] \n\t"
- "madd.d %[tmp], %[tmp], %[f_j], %[val] \n\t"
- "addiu %[j], %[i], -2 \n\t"
- "ldc1 %[f_j_2], -8(%[p_f]) \n\t"
- "sdc1 %[tmp], 16(%[p_f]) \n\t"
- "beqz %[j], ff_lsp2polyf_lp_j_end%= \n\t"
- "ff_lsp2polyf_lp_j%=: \n\t"
- "add.d %[tmp], %[f_j], %[f_j_2] \n\t"
- "madd.d %[tmp], %[tmp], %[f_j_1], %[val] \n\t"
- "mov.d %[f_j], %[f_j_1] \n\t"
- "addiu %[j], -1 \n\t"
- "mov.d %[f_j_1], %[f_j_2] \n\t"
- "ldc1 %[f_j_2], -16(%[p_f]) \n\t"
- "sdc1 %[tmp], 8(%[p_f]) \n\t"
- "addiu %[p_f], -8 \n\t"
- "bgtz %[j], ff_lsp2polyf_lp_j%= \n\t"
- "ff_lsp2polyf_lp_j_end%=: \n\t"
-
- : [f_j_2]"=&f"(f_j_2), [f_j_1]"=&f"(f_j_1), [val]"+f"(val),
- [tmp]"=&f"(tmp), [f_j]"=&f"(f_j), [p_f]"+r"(p_f),
- [j]"+r"(j), [p_fi]"+r"(p_fi)
- : [i]"r"(i)
- );
- f[1] += val;
- }
-}
-#define ff_lsp2polyf ff_lsp2polyf_mips
-#endif /* HAVE_MIPSFPU && HAVE_INLINE_ASM */
-#endif /* AVCODEC_LSP_MIPS_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/mjpeg.c b/src/thirdparty/ffmpeg/libavcodec/mjpeg.c
deleted file mode 100644
index d9293d73b..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mjpeg.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * MJPEG encoder and decoder
- * Copyright (c) 2000, 2001 Fabrice Bellard
- * Copyright (c) 2003 Alex Beregszaszi
- * Copyright (c) 2003-2004 Michael Niedermayer
- *
- * Support for external huffman table, various fixes (AVID workaround),
- * aspecting, new decode_frame mechanism and apple mjpeg-b support
- * by Alex Beregszaszi
- *
- * 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
- * MJPEG encoder and decoder.
- */
-
-#include "mjpeg.h"
-
-
-#if 0
-/* These are the sample quantization tables given in JPEG spec section K.1.
- * The spec says that the values given produce "good" quality, and
- * when divided by 2, "very good" quality.
- */
-const unsigned char std_luminance_quant_tbl[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, 56, 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
-};
-const unsigned char std_chrominance_quant_tbl[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
-};
-#endif
-
-/* Set up the standard Huffman tables (cf. JPEG standard section K.3) */
-/* IMPORTANT: these are only valid for 8-bit data precision! */
-const uint8_t avpriv_mjpeg_bits_dc_luminance[17] =
-{ /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 };
-const uint8_t avpriv_mjpeg_val_dc[12] =
-{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
-
-const uint8_t avpriv_mjpeg_bits_dc_chrominance[17] =
-{ /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 };
-
-const uint8_t avpriv_mjpeg_bits_ac_luminance[17] =
-{ /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d };
-const uint8_t avpriv_mjpeg_val_ac_luminance[] =
-{ 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
- 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
- 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
- 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0,
- 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16,
- 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28,
- 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
- 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
- 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
- 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
- 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
- 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
- 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
- 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
- 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
- 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5,
- 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4,
- 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2,
- 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
- 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
- 0xf9, 0xfa
-};
-
-const uint8_t avpriv_mjpeg_bits_ac_chrominance[17] =
-{ /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 };
-
-const uint8_t avpriv_mjpeg_val_ac_chrominance[] =
-{ 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
- 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
- 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
- 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0,
- 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34,
- 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26,
- 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38,
- 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
- 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
- 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
- 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
- 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
- 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96,
- 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5,
- 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
- 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3,
- 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2,
- 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda,
- 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
- 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
- 0xf9, 0xfa
-};
-
-/* isn't this function nicer than the one in the libjpeg ? */
-void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code,
- const uint8_t *bits_table,
- const uint8_t *val_table)
-{
- int i, j, k,nb, code, sym;
-
- code = 0;
- k = 0;
- for(i=1;i<=16;i++) {
- nb = bits_table[i];
- for(j=0;j<nb;j++) {
- sym = val_table[k++];
- huff_size[sym] = i;
- huff_code[sym] = code;
- code++;
- }
- code <<= 1;
- }
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/mjpeg.h b/src/thirdparty/ffmpeg/libavcodec/mjpeg.h
deleted file mode 100644
index 0bbfd967e..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mjpeg.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * MJPEG encoder and decoder
- * Copyright (c) 2000, 2001 Fabrice Bellard
- * Copyright (c) 2003 Alex Beregszaszi
- * Copyright (c) 2003-2004 Michael Niedermayer
- *
- * Support for external huffman table, various fixes (AVID workaround),
- * aspecting, new decode_frame mechanism and apple mjpeg-b support
- * by Alex Beregszaszi
- *
- * 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
- * MJPEG encoder and decoder.
- */
-
-#ifndef AVCODEC_MJPEG_H
-#define AVCODEC_MJPEG_H
-
-#include "avcodec.h"
-#include "put_bits.h"
-
-
-/* JPEG marker codes */
-typedef enum {
- /* start of frame */
- SOF0 = 0xc0, /* baseline */
- SOF1 = 0xc1, /* extended sequential, huffman */
- SOF2 = 0xc2, /* progressive, huffman */
- SOF3 = 0xc3, /* lossless, huffman */
-
- SOF5 = 0xc5, /* differential sequential, huffman */
- SOF6 = 0xc6, /* differential progressive, huffman */
- SOF7 = 0xc7, /* differential lossless, huffman */
- JPG = 0xc8, /* reserved for JPEG extension */
- SOF9 = 0xc9, /* extended sequential, arithmetic */
- SOF10 = 0xca, /* progressive, arithmetic */
- SOF11 = 0xcb, /* lossless, arithmetic */
-
- SOF13 = 0xcd, /* differential sequential, arithmetic */
- SOF14 = 0xce, /* differential progressive, arithmetic */
- SOF15 = 0xcf, /* differential lossless, arithmetic */
-
- DHT = 0xc4, /* define huffman tables */
-
- DAC = 0xcc, /* define arithmetic-coding conditioning */
-
- /* restart with modulo 8 count "m" */
- RST0 = 0xd0,
- RST1 = 0xd1,
- RST2 = 0xd2,
- RST3 = 0xd3,
- RST4 = 0xd4,
- RST5 = 0xd5,
- RST6 = 0xd6,
- RST7 = 0xd7,
-
- SOI = 0xd8, /* start of image */
- EOI = 0xd9, /* end of image */
- SOS = 0xda, /* start of scan */
- DQT = 0xdb, /* define quantization tables */
- DNL = 0xdc, /* define number of lines */
- DRI = 0xdd, /* define restart interval */
- DHP = 0xde, /* define hierarchical progression */
- EXP = 0xdf, /* expand reference components */
-
- APP0 = 0xe0,
- APP1 = 0xe1,
- APP2 = 0xe2,
- APP3 = 0xe3,
- APP4 = 0xe4,
- APP5 = 0xe5,
- APP6 = 0xe6,
- APP7 = 0xe7,
- APP8 = 0xe8,
- APP9 = 0xe9,
- APP10 = 0xea,
- APP11 = 0xeb,
- APP12 = 0xec,
- APP13 = 0xed,
- APP14 = 0xee,
- APP15 = 0xef,
-
- JPG0 = 0xf0,
- JPG1 = 0xf1,
- JPG2 = 0xf2,
- JPG3 = 0xf3,
- JPG4 = 0xf4,
- JPG5 = 0xf5,
- JPG6 = 0xf6,
- SOF48 = 0xf7, ///< JPEG-LS
- LSE = 0xf8, ///< JPEG-LS extension parameters
- JPG9 = 0xf9,
- JPG10 = 0xfa,
- JPG11 = 0xfb,
- JPG12 = 0xfc,
- JPG13 = 0xfd,
-
- COM = 0xfe, /* comment */
-
- TEM = 0x01, /* temporary private use for arithmetic coding */
-
- /* 0x02 -> 0xbf reserved */
-} JPEG_MARKER;
-
-static inline void put_marker(PutBitContext *p, int code)
-{
- put_bits(p, 8, 0xff);
- put_bits(p, 8, code);
-}
-
-#define PREDICT(ret, topleft, top, left, predictor)\
- switch(predictor){\
- case 0: ret= 0; break;\
- case 1: ret= left; break;\
- case 2: ret= top; break;\
- case 3: ret= topleft; break;\
- case 4: ret= left + top - topleft; break;\
- case 5: ret= left + ((top - topleft)>>1); break;\
- case 6: ret= top + ((left - topleft)>>1); break;\
- default:\
- case 7: ret= (left + top)>>1; break;\
- }
-
-extern av_export const uint8_t avpriv_mjpeg_bits_dc_luminance[];
-extern av_export const uint8_t avpriv_mjpeg_val_dc[];
-
-extern av_export const uint8_t avpriv_mjpeg_bits_dc_chrominance[];
-
-extern av_export const uint8_t avpriv_mjpeg_bits_ac_luminance[];
-extern av_export const uint8_t avpriv_mjpeg_val_ac_luminance[];
-
-extern av_export const uint8_t avpriv_mjpeg_bits_ac_chrominance[];
-extern av_export const uint8_t avpriv_mjpeg_val_ac_chrominance[];
-
-void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code,
- const uint8_t *bits_table,
- const uint8_t *val_table);
-
-#endif /* AVCODEC_MJPEG_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/mjpegbdec.c b/src/thirdparty/ffmpeg/libavcodec/mjpegbdec.c
deleted file mode 100644
index 837d19d71..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mjpegbdec.c
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Apple MJPEG-B decoder
- * Copyright (c) 2002 Alex Beregszaszi
- *
- * 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
- * Apple MJPEG-B decoder.
- */
-
-#include "avcodec.h"
-#include "mjpeg.h"
-#include "mjpegdec.h"
-
-static uint32_t read_offs(AVCodecContext *avctx, GetBitContext *gb, uint32_t size, const char *err_msg){
- uint32_t offs= get_bits_long(gb, 32);
- if(offs >= size){
- av_log(avctx, AV_LOG_WARNING, err_msg, offs, size);
- return 0;
- }
- return offs;
-}
-
-static int mjpegb_decode_frame(AVCodecContext *avctx,
- void *data, int *got_frame,
- AVPacket *avpkt)
-{
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
- MJpegDecodeContext *s = avctx->priv_data;
- const uint8_t *buf_end, *buf_ptr;
- AVFrame *picture = data;
- GetBitContext hgb; /* for the header */
- uint32_t dqt_offs, dht_offs, sof_offs, sos_offs, second_field_offs;
- uint32_t field_size, sod_offs;
-
- buf_ptr = buf;
- buf_end = buf + buf_size;
- s->got_picture = 0;
-
-read_header:
- /* reset on every SOI */
- s->restart_interval = 0;
- s->restart_count = 0;
- s->mjpb_skiptosod = 0;
-
- if (buf_end - buf_ptr >= 1 << 28)
- return AVERROR_INVALIDDATA;
-
- init_get_bits(&hgb, buf_ptr, /*buf_size*/(buf_end - buf_ptr)*8);
-
- skip_bits(&hgb, 32); /* reserved zeros */
-
- if (get_bits_long(&hgb, 32) != MKBETAG('m','j','p','g'))
- {
- av_log(avctx, AV_LOG_WARNING, "not mjpeg-b (bad fourcc)\n");
- return AVERROR_INVALIDDATA;
- }
-
- field_size = get_bits_long(&hgb, 32); /* field size */
- av_log(avctx, AV_LOG_DEBUG, "field size: 0x%x\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);
-
- 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);
- if (dqt_offs)
- {
- init_get_bits(&s->gb, buf_ptr+dqt_offs, (buf_end - (buf_ptr+dqt_offs))*8);
- s->start_code = DQT;
- if (ff_mjpeg_decode_dqt(s) < 0 &&
- (avctx->err_recognition & AV_EF_EXPLODE))
- return AVERROR_INVALIDDATA;
- }
-
- 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);
- if (dht_offs)
- {
- init_get_bits(&s->gb, buf_ptr+dht_offs, (buf_end - (buf_ptr+dht_offs))*8);
- s->start_code = DHT;
- ff_mjpeg_decode_dht(s);
- }
-
- 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);
- if (sof_offs)
- {
- init_get_bits(&s->gb, buf_ptr+sof_offs, (buf_end - (buf_ptr+sof_offs))*8);
- s->start_code = SOF0;
- if (ff_mjpeg_decode_sof(s) < 0)
- return -1;
- }
-
- 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);
- 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);
- 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 &&
- (avctx->err_recognition & AV_EF_EXPLODE))
- return AVERROR_INVALIDDATA;
- }
-
- if (s->interlaced) {
- s->bottom_field ^= 1;
- /* if not bottom field, do not output image yet */
- if (s->bottom_field != s->interlace_polarity && second_field_offs)
- {
- buf_ptr = buf + second_field_offs;
- goto read_header;
- }
- }
-
- //XXX FIXME factorize, this looks very similar to the EOI code
-
- if(!s->got_picture) {
- av_log(avctx, AV_LOG_WARNING, "no picture\n");
- return buf_size;
- }
-
- *picture= *s->picture_ptr;
- *got_frame = 1;
-
- if(!s->lossless){
- picture->quality= FFMAX3(s->qscale[0], s->qscale[1], s->qscale[2]);
- picture->qstride= 0;
- picture->qscale_table= s->qscale_table;
- memset(picture->qscale_table, picture->quality, (s->width+15)/16);
- if(avctx->debug & FF_DEBUG_QP)
- av_log(avctx, AV_LOG_DEBUG, "QP: %d\n", picture->quality);
- picture->quality*= FF_QP2LAMBDA;
- }
-
- return buf_size;
-}
-
-AVCodec ff_mjpegb_decoder = {
- .name = "mjpegb",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_MJPEGB,
- .priv_data_size = sizeof(MJpegDecodeContext),
- .init = ff_mjpeg_decode_init,
- .close = ff_mjpeg_decode_end,
- .decode = mjpegb_decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .max_lowres = 3,
- .long_name = NULL_IF_CONFIG_SMALL("Apple MJPEG-B"),
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/mjpegdec.c b/src/thirdparty/ffmpeg/libavcodec/mjpegdec.c
deleted file mode 100644
index 2cb33bf8a..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mjpegdec.c
+++ /dev/null
@@ -1,1935 +0,0 @@
-/*
- * MJPEG decoder
- * Copyright (c) 2000, 2001 Fabrice Bellard
- * Copyright (c) 2003 Alex Beregszaszi
- * Copyright (c) 2003-2004 Michael Niedermayer
- *
- * Support for external huffman table, various fixes (AVID workaround),
- * aspecting, new decode_frame mechanism and apple mjpeg-b support
- * by Alex Beregszaszi
- *
- * 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
- * MJPEG decoder.
- */
-
-#include "libavutil/imgutils.h"
-#include "libavutil/avassert.h"
-#include "libavutil/opt.h"
-#include "avcodec.h"
-#include "copy_block.h"
-#include "dsputil.h"
-#include "internal.h"
-#include "mjpeg.h"
-#include "mjpegdec.h"
-#include "jpeglsdec.h"
-
-
-static int build_vlc(VLC *vlc, const uint8_t *bits_table,
- const uint8_t *val_table, int nb_codes,
- int use_static, int is_ac)
-{
- uint8_t huff_size[256] = { 0 };
- uint16_t huff_code[256];
- uint16_t huff_sym[256];
- int i;
-
- av_assert0(nb_codes <= 256);
-
- ff_mjpeg_build_huffman_codes(huff_size, huff_code, bits_table, val_table);
-
- for (i = 0; i < 256; i++)
- huff_sym[i] = i + 16 * is_ac;
-
- if (is_ac)
- huff_sym[0] = 16 * 256;
-
- return ff_init_vlc_sparse(vlc, 9, nb_codes, huff_size, 1, 1,
- huff_code, 2, 2, huff_sym, 2, 2, use_static);
-}
-
-static void build_basic_mjpeg_vlc(MJpegDecodeContext *s)
-{
- build_vlc(&s->vlcs[0][0], avpriv_mjpeg_bits_dc_luminance,
- avpriv_mjpeg_val_dc, 12, 0, 0);
- build_vlc(&s->vlcs[0][1], avpriv_mjpeg_bits_dc_chrominance,
- avpriv_mjpeg_val_dc, 12, 0, 0);
- build_vlc(&s->vlcs[1][0], avpriv_mjpeg_bits_ac_luminance,
- avpriv_mjpeg_val_ac_luminance, 251, 0, 1);
- build_vlc(&s->vlcs[1][1], avpriv_mjpeg_bits_ac_chrominance,
- avpriv_mjpeg_val_ac_chrominance, 251, 0, 1);
- build_vlc(&s->vlcs[2][0], avpriv_mjpeg_bits_ac_luminance,
- avpriv_mjpeg_val_ac_luminance, 251, 0, 0);
- build_vlc(&s->vlcs[2][1], avpriv_mjpeg_bits_ac_chrominance,
- avpriv_mjpeg_val_ac_chrominance, 251, 0, 0);
-}
-
-av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
-{
- MJpegDecodeContext *s = avctx->priv_data;
-
- if (!s->picture_ptr)
- s->picture_ptr = &s->picture;
- avcodec_get_frame_defaults(&s->picture);
-
- s->avctx = avctx;
- ff_dsputil_init(&s->dsp, avctx);
- ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct);
- s->buffer_size = 0;
- s->buffer = NULL;
- s->start_code = -1;
- s->first_picture = 1;
- s->got_picture = 0;
- s->org_height = avctx->coded_height;
- avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
-
- build_basic_mjpeg_vlc(s);
-
- if (s->extern_huff) {
- av_log(avctx, AV_LOG_INFO, "using external huffman table\n");
- init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size * 8);
- if (ff_mjpeg_decode_dht(s)) {
- av_log(avctx, AV_LOG_ERROR,
- "error using external huffman table, switching back to internal\n");
- build_basic_mjpeg_vlc(s);
- }
- }
- 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");
- }
- if (avctx->codec->id == AV_CODEC_ID_AMV)
- s->flipped = 1;
-
- return 0;
-}
-
-
-/* quantize tables */
-int ff_mjpeg_decode_dqt(MJpegDecodeContext *s)
-{
- int len, index, i, j;
-
- len = get_bits(&s->gb, 16) - 2;
-
- while (len >= 65) {
- int pr = get_bits(&s->gb, 4);
- if (pr > 1) {
- av_log(s->avctx, AV_LOG_ERROR, "dqt: invalid precision\n");
- return AVERROR_INVALIDDATA;
- }
- index = get_bits(&s->gb, 4);
- if (index >= 4)
- return -1;
- av_log(s->avctx, AV_LOG_DEBUG, "index=%d\n", index);
- /* read quant table */
- for (i = 0; i < 64; i++) {
- j = s->scantable.permutated[i];
- s->quant_matrixes[index][j] = get_bits(&s->gb, pr ? 16 : 8);
- }
-
- // XXX FIXME finetune, and perhaps add dc too
- s->qscale[index] = FFMAX(s->quant_matrixes[index][s->scantable.permutated[1]],
- s->quant_matrixes[index][s->scantable.permutated[8]]) >> 1;
- av_log(s->avctx, AV_LOG_DEBUG, "qscale[%d]: %d\n",
- index, s->qscale[index]);
- len -= 65;
- }
- return 0;
-}
-
-/* decode huffman tables and build VLC decoders */
-int ff_mjpeg_decode_dht(MJpegDecodeContext *s)
-{
- int len, index, i, class, n, v, code_max;
- uint8_t bits_table[17];
- uint8_t val_table[256];
- int ret = 0;
-
- len = get_bits(&s->gb, 16) - 2;
-
- while (len > 0) {
- if (len < 17)
- return AVERROR_INVALIDDATA;
- class = get_bits(&s->gb, 4);
- if (class >= 2)
- return AVERROR_INVALIDDATA;
- index = get_bits(&s->gb, 4);
- if (index >= 4)
- return AVERROR_INVALIDDATA;
- n = 0;
- for (i = 1; i <= 16; i++) {
- bits_table[i] = get_bits(&s->gb, 8);
- n += bits_table[i];
- }
- len -= 17;
- if (len < n || n > 256)
- return AVERROR_INVALIDDATA;
-
- code_max = 0;
- for (i = 0; i < n; i++) {
- v = get_bits(&s->gb, 8);
- if (v > code_max)
- code_max = v;
- val_table[i] = v;
- }
- len -= n;
-
- /* build VLC and flush previous vlc if present */
- ff_free_vlc(&s->vlcs[class][index]);
- av_log(s->avctx, AV_LOG_DEBUG, "class=%d index=%d nb_codes=%d\n",
- class, index, code_max + 1);
- if ((ret = build_vlc(&s->vlcs[class][index], bits_table, val_table,
- code_max + 1, 0, class > 0)) < 0)
- return ret;
-
- if (class > 0) {
- ff_free_vlc(&s->vlcs[2][index]);
- if ((ret = build_vlc(&s->vlcs[2][index], bits_table, val_table,
- code_max + 1, 0, 0)) < 0)
- return ret;
- }
- }
- return 0;
-}
-
-int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
-{
- int len, nb_components, i, width, height, pix_fmt_id;
- int h_count[MAX_COMPONENTS];
- int v_count[MAX_COMPONENTS];
-
- s->cur_scan = 0;
- s->upscale_h = s->upscale_v = 0;
-
- /* XXX: verify len field validity */
- len = get_bits(&s->gb, 16);
- s->bits = get_bits(&s->gb, 8);
-
- if (s->pegasus_rct)
- s->bits = 9;
- if (s->bits == 9 && !s->pegasus_rct)
- s->rct = 1; // FIXME ugly
-
- if (s->bits != 8 && !s->lossless) {
- av_log(s->avctx, AV_LOG_ERROR, "only 8 bits/component accepted\n");
- return -1;
- }
-
- if(s->lossless && s->avctx->lowres){
- av_log(s->avctx, AV_LOG_ERROR, "lowres is not possible with lossless jpeg\n");
- return -1;
- }
-
- height = get_bits(&s->gb, 16);
- width = get_bits(&s->gb, 16);
-
- // HACK for odd_height.mov
- if (s->interlaced && s->width == width && s->height == height + 1)
- height= s->height;
-
- av_log(s->avctx, AV_LOG_DEBUG, "sof0: picture: %dx%d\n", width, height);
- if (av_image_check_size(width, height, 0, s->avctx))
- return AVERROR_INVALIDDATA;
-
- nb_components = get_bits(&s->gb, 8);
- if (nb_components <= 0 ||
- nb_components > MAX_COMPONENTS)
- return -1;
- if (s->interlaced && (s->bottom_field == !s->interlace_polarity)) {
- if (nb_components != s->nb_components) {
- av_log(s->avctx, AV_LOG_ERROR, "nb_components changing in interlaced picture\n");
- return AVERROR_INVALIDDATA;
- }
- }
- if (s->ls && !(s->bits <= 8 || nb_components == 1)) {
- av_log_missing_feature(s->avctx,
- "For JPEG-LS anything except <= 8 bits/component"
- " or 16-bit gray", 0);
- return AVERROR_PATCHWELCOME;
- }
- s->nb_components = nb_components;
- s->h_max = 1;
- s->v_max = 1;
- memset(h_count, 0, sizeof(h_count));
- memset(v_count, 0, sizeof(v_count));
- for (i = 0; i < nb_components; i++) {
- /* component id */
- s->component_id[i] = get_bits(&s->gb, 8) - 1;
- h_count[i] = get_bits(&s->gb, 4);
- v_count[i] = get_bits(&s->gb, 4);
- /* compute hmax and vmax (only used in interleaved case) */
- if (h_count[i] > s->h_max)
- s->h_max = h_count[i];
- if (v_count[i] > s->v_max)
- s->v_max = v_count[i];
- if (!h_count[i] || !v_count[i]) {
- av_log(s->avctx, AV_LOG_ERROR, "h/v_count is 0\n");
- return -1;
- }
- s->quant_index[i] = get_bits(&s->gb, 8);
- if (s->quant_index[i] >= 4) {
- av_log(s->avctx, AV_LOG_ERROR, "quant_index is invalid\n");
- return AVERROR_INVALIDDATA;
- }
- av_log(s->avctx, AV_LOG_DEBUG, "component %d %d:%d id: %d quant:%d\n",
- i, h_count[i], v_count[i],
- s->component_id[i], s->quant_index[i]);
- }
-
- if (s->ls && (s->h_max > 1 || s->v_max > 1)) {
- av_log_missing_feature(s->avctx, "Subsampling in JPEG-LS", 0);
- return AVERROR_PATCHWELCOME;
- }
-
- if (s->v_max == 1 && s->h_max == 1 && s->lossless==1 && nb_components==3)
- s->rgb = 1;
- else if (!s->lossless)
- s->rgb = 0;
-
- /* if different size, realloc/alloc picture */
- if ( width != s->width || height != s->height
- || memcmp(s->h_count, h_count, sizeof(h_count))
- || memcmp(s->v_count, v_count, sizeof(v_count))) {
- av_freep(&s->qscale_table);
-
- s->width = width;
- s->height = height;
- memcpy(s->h_count, h_count, sizeof(h_count));
- memcpy(s->v_count, v_count, sizeof(v_count));
- s->interlaced = 0;
- s->got_picture = 0;
-
- /* test interlaced mode */
- if (s->first_picture &&
- s->org_height != 0 &&
- s->height < ((s->org_height * 3) / 4)) {
- s->interlaced = 1;
- s->bottom_field = s->interlace_polarity;
- s->picture_ptr->interlaced_frame = 1;
- s->picture_ptr->top_field_first = !s->interlace_polarity;
- height *= 2;
- }
-
- avcodec_set_dimensions(s->avctx, width, height);
-
- s->qscale_table = av_mallocz((s->width + 15) / 16);
- s->first_picture = 0;
- }
-
- if (s->interlaced && (s->bottom_field == !s->interlace_polarity)) {
- if (s->progressive) {
- av_log_ask_for_sample(s->avctx, "progressively coded interlaced pictures not supported\n");
- return AVERROR_INVALIDDATA;
- }
- } else{
- /* XXX: not complete test ! */
- pix_fmt_id = (s->h_count[0] << 28) | (s->v_count[0] << 24) |
- (s->h_count[1] << 20) | (s->v_count[1] << 16) |
- (s->h_count[2] << 12) | (s->v_count[2] << 8) |
- (s->h_count[3] << 4) | s->v_count[3];
- av_log(s->avctx, AV_LOG_DEBUG, "pix fmt id %x\n", pix_fmt_id);
- /* NOTE we do not allocate pictures large enough for the possible
- * padding of h/v_count being 4 */
- if (!(pix_fmt_id & 0xD0D0D0D0))
- pix_fmt_id -= (pix_fmt_id & 0xF0F0F0F0) >> 1;
- if (!(pix_fmt_id & 0x0D0D0D0D))
- pix_fmt_id -= (pix_fmt_id & 0x0F0F0F0F) >> 1;
-
- switch (pix_fmt_id) {
- case 0x11111100:
- if (s->rgb)
- s->avctx->pix_fmt = AV_PIX_FMT_BGR24;
- else {
- if (s->component_id[0] == 'Q' && s->component_id[1] == 'F' && s->component_id[2] == 'A') {
- s->avctx->pix_fmt = AV_PIX_FMT_GBR24P;
- } else {
- s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
- s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
- }
- }
- av_assert0(s->nb_components == 3);
- break;
- case 0x12121100:
- case 0x22122100:
- s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
- 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->chroma_height = s->height;
- break;
- case 0x21211100:
- case 0x22211200:
- s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
- 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->chroma_height = s->height;
- break;
- case 0x22221100:
- s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
- s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
- s->upscale_v = 2;
- s->upscale_h = 2;
- s->chroma_height = s->height / 2;
- break;
- case 0x11000000:
- case 0x13000000:
- case 0x14000000:
- case 0x31000000:
- case 0x33000000:
- case 0x34000000:
- case 0x41000000:
- case 0x43000000:
- case 0x44000000:
- if(s->bits <= 8)
- s->avctx->pix_fmt = AV_PIX_FMT_GRAY8;
- else
- s->avctx->pix_fmt = AV_PIX_FMT_GRAY16;
- break;
- case 0x12111100:
- case 0x22211100:
- case 0x22112100:
- s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV440P : AV_PIX_FMT_YUVJ440P;
- 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->chroma_height = s->height / 2;
- break;
- case 0x21111100:
- s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV422P : AV_PIX_FMT_YUVJ422P;
- s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
- break;
- case 0x22121100:
- case 0x22111200:
- s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV422P : AV_PIX_FMT_YUVJ422P;
- s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
- s->upscale_v = (pix_fmt_id == 0x22121100) + 1;
- break;
- case 0x22111100:
- s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV420P : AV_PIX_FMT_YUVJ420P;
- s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
- break;
- default:
- av_log(s->avctx, AV_LOG_ERROR, "Unhandled pixel format 0x%x\n", pix_fmt_id);
- return AVERROR_PATCHWELCOME;
- }
- if ((s->upscale_h || s->upscale_v) && s->avctx->lowres) {
- av_log(s->avctx, AV_LOG_ERROR, "lowres not supported for weird subsampling\n");
- return AVERROR_PATCHWELCOME;
- }
- if (s->ls) {
- s->upscale_h = s->upscale_v = 0;
- if (s->nb_components > 1)
- s->avctx->pix_fmt = AV_PIX_FMT_RGB24;
- else if (s->bits <= 8)
- s->avctx->pix_fmt = AV_PIX_FMT_GRAY8;
- else
- s->avctx->pix_fmt = AV_PIX_FMT_GRAY16;
- }
-
- if (s->picture_ptr->data[0])
- s->avctx->release_buffer(s->avctx, s->picture_ptr);
-
- if (ff_get_buffer(s->avctx, s->picture_ptr) < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return -1;
- }
- s->picture_ptr->pict_type = AV_PICTURE_TYPE_I;
- s->picture_ptr->key_frame = 1;
- s->got_picture = 1;
-
- for (i = 0; i < 3; i++)
- s->linesize[i] = s->picture_ptr->linesize[i] << s->interlaced;
-
- av_dlog(s->avctx, "%d %d %d %d %d %d\n",
- s->width, s->height, s->linesize[0], s->linesize[1],
- s->interlaced, s->avctx->height);
-
- if (len != (8 + (3 * nb_components)))
- av_log(s->avctx, AV_LOG_DEBUG, "decode_sof0: error, len(%d) mismatch\n", len);
- }
-
- /* totally blank picture as progressive JPEG will only add details to it */
- if (s->progressive) {
- int bw = (width + s->h_max * 8 - 1) / (s->h_max * 8);
- int bh = (height + s->v_max * 8 - 1) / (s->v_max * 8);
- for (i = 0; i < s->nb_components; i++) {
- 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->block_stride[i] = bw * s->h_count[i];
- }
- memset(s->coefs_finished, 0, sizeof(s->coefs_finished));
- }
- return 0;
-}
-
-static inline int mjpeg_decode_dc(MJpegDecodeContext *s, int dc_index)
-{
- int code;
- code = get_vlc2(&s->gb, s->vlcs[0][dc_index].table, 9, 2);
- if (code < 0) {
- av_log(s->avctx, AV_LOG_WARNING,
- "mjpeg_decode_dc: bad vlc: %d:%d (%p)\n",
- 0, dc_index, &s->vlcs[0][dc_index]);
- return 0xffff;
- }
-
- if (code)
- return get_xbits(&s->gb, code);
- else
- return 0;
-}
-
-/* decode block and dequantize */
-static int decode_block(MJpegDecodeContext *s, int16_t *block, int component,
- int dc_index, int ac_index, int16_t *quant_matrix)
-{
- int code, i, j, level, val;
-
- /* DC coef */
- val = mjpeg_decode_dc(s, dc_index);
- if (val == 0xffff) {
- av_log(s->avctx, AV_LOG_ERROR, "error dc\n");
- return AVERROR_INVALIDDATA;
- }
- val = val * quant_matrix[0] + s->last_dc[component];
- s->last_dc[component] = val;
- block[0] = val;
- /* AC coefs */
- i = 0;
- {OPEN_READER(re, &s->gb);
- do {
- UPDATE_CACHE(re, &s->gb);
- GET_VLC(code, re, &s->gb, s->vlcs[1][ac_index].table, 9, 2);
-
- i += ((unsigned)code) >> 4;
- code &= 0xf;
- if (code) {
- if (code > MIN_CACHE_BITS - 16)
- UPDATE_CACHE(re, &s->gb);
-
- {
- int cache = GET_CACHE(re, &s->gb);
- int sign = (~cache) >> 31;
- level = (NEG_USR32(sign ^ cache,code) ^ sign) - sign;
- }
-
- LAST_SKIP_BITS(re, &s->gb, code);
-
- if (i > 63) {
- av_log(s->avctx, AV_LOG_ERROR, "error count: %d\n", i);
- return AVERROR_INVALIDDATA;
- }
- j = s->scantable.permutated[i];
- block[j] = level * quant_matrix[j];
- }
- } while (i < 63);
- CLOSE_READER(re, &s->gb);}
-
- return 0;
-}
-
-static int decode_dc_progressive(MJpegDecodeContext *s, int16_t *block,
- int component, int dc_index,
- int16_t *quant_matrix, int Al)
-{
- int val;
- s->dsp.clear_block(block);
- val = mjpeg_decode_dc(s, dc_index);
- if (val == 0xffff) {
- av_log(s->avctx, AV_LOG_ERROR, "error dc\n");
- return AVERROR_INVALIDDATA;
- }
- val = (val * quant_matrix[0] << Al) + s->last_dc[component];
- s->last_dc[component] = val;
- block[0] = val;
- return 0;
-}
-
-/* decode block and dequantize - progressive JPEG version */
-static int decode_block_progressive(MJpegDecodeContext *s, int16_t *block,
- uint8_t *last_nnz, int ac_index,
- int16_t *quant_matrix,
- int ss, int se, int Al, int *EOBRUN)
-{
- int code, i, j, level, val, run;
-
- if (*EOBRUN) {
- (*EOBRUN)--;
- return 0;
- }
-
- {
- OPEN_READER(re, &s->gb);
- for (i = ss; ; i++) {
- UPDATE_CACHE(re, &s->gb);
- GET_VLC(code, re, &s->gb, s->vlcs[2][ac_index].table, 9, 2);
-
- run = ((unsigned) code) >> 4;
- code &= 0xF;
- if (code) {
- i += run;
- if (code > MIN_CACHE_BITS - 16)
- UPDATE_CACHE(re, &s->gb);
-
- {
- int cache = GET_CACHE(re, &s->gb);
- int sign = (~cache) >> 31;
- level = (NEG_USR32(sign ^ cache,code) ^ sign) - sign;
- }
-
- LAST_SKIP_BITS(re, &s->gb, code);
-
- if (i >= se) {
- if (i == se) {
- j = s->scantable.permutated[se];
- block[j] = level * quant_matrix[j] << Al;
- break;
- }
- av_log(s->avctx, AV_LOG_ERROR, "error count: %d\n", i);
- return AVERROR_INVALIDDATA;
- }
- j = s->scantable.permutated[i];
- block[j] = level * quant_matrix[j] << Al;
- } else {
- if (run == 0xF) {// ZRL - skip 15 coefficients
- i += 15;
- if (i >= se) {
- av_log(s->avctx, AV_LOG_ERROR, "ZRL overflow: %d\n", i);
- return AVERROR_INVALIDDATA;
- }
- } else {
- val = (1 << run);
- if (run) {
- UPDATE_CACHE(re, &s->gb);
- val += NEG_USR32(GET_CACHE(re, &s->gb), run);
- LAST_SKIP_BITS(re, &s->gb, run);
- }
- *EOBRUN = val - 1;
- break;
- }
- }
- }
- CLOSE_READER(re, &s->gb);
- }
-
- if (i > *last_nnz)
- *last_nnz = i;
-
- return 0;
-}
-
-#define REFINE_BIT(j) { \
- UPDATE_CACHE(re, &s->gb); \
- sign = block[j] >> 15; \
- block[j] += SHOW_UBITS(re, &s->gb, 1) * \
- ((quant_matrix[j] ^ sign) - sign) << Al; \
- LAST_SKIP_BITS(re, &s->gb, 1); \
-}
-
-#define ZERO_RUN \
-for (; ; i++) { \
- if (i > last) { \
- i += run; \
- if (i > se) { \
- av_log(s->avctx, AV_LOG_ERROR, "error count: %d\n", i); \
- return -1; \
- } \
- break; \
- } \
- j = s->scantable.permutated[i]; \
- if (block[j]) \
- REFINE_BIT(j) \
- else if (run-- == 0) \
- break; \
-}
-
-/* decode block and dequantize - progressive JPEG refinement pass */
-static int decode_block_refinement(MJpegDecodeContext *s, int16_t *block,
- uint8_t *last_nnz,
- int ac_index, int16_t *quant_matrix,
- int ss, int se, int Al, int *EOBRUN)
-{
- int code, i = ss, j, sign, val, run;
- int last = FFMIN(se, *last_nnz);
-
- OPEN_READER(re, &s->gb);
- if (*EOBRUN) {
- (*EOBRUN)--;
- } else {
- for (; ; i++) {
- UPDATE_CACHE(re, &s->gb);
- GET_VLC(code, re, &s->gb, s->vlcs[2][ac_index].table, 9, 2);
-
- if (code & 0xF) {
- run = ((unsigned) code) >> 4;
- UPDATE_CACHE(re, &s->gb);
- val = SHOW_UBITS(re, &s->gb, 1);
- LAST_SKIP_BITS(re, &s->gb, 1);
- ZERO_RUN;
- j = s->scantable.permutated[i];
- val--;
- block[j] = ((quant_matrix[j]^val) - val) << Al;
- if (i == se) {
- if (i > *last_nnz)
- *last_nnz = i;
- CLOSE_READER(re, &s->gb);
- return 0;
- }
- } else {
- run = ((unsigned) code) >> 4;
- if (run == 0xF) {
- ZERO_RUN;
- } else {
- val = run;
- run = (1 << run);
- if (val) {
- UPDATE_CACHE(re, &s->gb);
- run += SHOW_UBITS(re, &s->gb, val);
- LAST_SKIP_BITS(re, &s->gb, val);
- }
- *EOBRUN = run - 1;
- break;
- }
- }
- }
-
- if (i > *last_nnz)
- *last_nnz = i;
- }
-
- for (; i <= last; i++) {
- j = s->scantable.permutated[i];
- if (block[j])
- REFINE_BIT(j)
- }
- CLOSE_READER(re, &s->gb);
-
- return 0;
-}
-#undef REFINE_BIT
-#undef ZERO_RUN
-
-static void handle_rstn(MJpegDecodeContext *s, int nb_components)
-{
- int i;
- if (s->restart_interval) {
- s->restart_count--;
- if(s->restart_count == 0 && s->avctx->codec_id == AV_CODEC_ID_THP){
- align_get_bits(&s->gb);
- for (i = 0; i < nb_components; i++) /* reset dc */
- s->last_dc[i] = 1024;
- }
-
- i = 8 + ((-get_bits_count(&s->gb)) & 7);
- /* skip RSTn */
- if (s->restart_count == 0 && show_bits(&s->gb, i) == (1 << i) - 1) {
- int pos = get_bits_count(&s->gb);
- align_get_bits(&s->gb);
- while (get_bits_left(&s->gb) >= 8 && show_bits(&s->gb, 8) == 0xFF)
- skip_bits(&s->gb, 8);
- if (get_bits_left(&s->gb) >= 8 && (get_bits(&s->gb, 8) & 0xF8) == 0xD0) {
- for (i = 0; i < nb_components; i++) /* reset dc */
- s->last_dc[i] = 1024;
- } else
- skip_bits_long(&s->gb, pos - get_bits_count(&s->gb));
- }
- }
-}
-
-static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int predictor, int point_transform)
-{
- int i, mb_x, mb_y;
- uint16_t (*buffer)[4];
- int left[3], top[3], topleft[3];
- const int linesize = s->linesize[0];
- const int mask = (1 << s->bits) - 1;
- int resync_mb_y = 0;
- int resync_mb_x = 0;
-
- s->restart_count = s->restart_interval;
-
- av_fast_malloc(&s->ljpeg_buffer, &s->ljpeg_buffer_size,
- (unsigned)s->mb_width * 4 * sizeof(s->ljpeg_buffer[0][0]));
- buffer = s->ljpeg_buffer;
-
- for (i = 0; i < 3; i++)
- buffer[0][i] = 1 << (s->bits - 1);
-
- for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
- uint8_t *ptr = s->picture.data[0] + (linesize * mb_y);
-
- if (s->interlaced && s->bottom_field)
- ptr += linesize >> 1;
-
- for (i = 0; i < 3; i++)
- top[i] = left[i] = topleft[i] = buffer[0][i];
-
- for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
- int modified_predictor = predictor;
-
- if (s->restart_interval && !s->restart_count){
- s->restart_count = s->restart_interval;
- resync_mb_x = mb_x;
- resync_mb_y = mb_y;
- for(i=0; i<3; i++)
- top[i] = left[i]= topleft[i]= 1 << (s->bits - 1);
- }
- if (mb_y == resync_mb_y || mb_y == resync_mb_y+1 && mb_x < resync_mb_x || !mb_x)
- modified_predictor = 1;
-
- for (i=0;i<nb_components;i++) {
- int pred, dc;
-
- topleft[i] = top[i];
- top[i] = buffer[mb_x][i];
-
- PREDICT(pred, topleft[i], top[i], left[i], modified_predictor);
-
- dc = mjpeg_decode_dc(s, s->dc_index[i]);
- if(dc == 0xFFFF)
- return -1;
-
- left[i] = buffer[mb_x][i] =
- mask & (pred + (dc << point_transform));
- }
-
- if (s->restart_interval && !--s->restart_count) {
- align_get_bits(&s->gb);
- skip_bits(&s->gb, 16); /* skip RSTn */
- }
- }
-
- if (s->rct) {
- for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
- ptr[3*mb_x + 1] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2] - 0x200) >> 2);
- ptr[3*mb_x + 0] = buffer[mb_x][1] + ptr[3*mb_x + 1];
- ptr[3*mb_x + 2] = buffer[mb_x][2] + ptr[3*mb_x + 1];
- }
- } else if (s->pegasus_rct) {
- for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
- ptr[3*mb_x + 1] = buffer[mb_x][0] - ((buffer[mb_x][1] + buffer[mb_x][2]) >> 2);
- ptr[3*mb_x + 0] = buffer[mb_x][1] + ptr[3*mb_x + 1];
- ptr[3*mb_x + 2] = buffer[mb_x][2] + ptr[3*mb_x + 1];
- }
- } else {
- for(i=0; i<nb_components; i++) {
- int c= s->comp_index[i];
- for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
- ptr[3*mb_x+2-c] = buffer[mb_x][i];
- }
- }
- }
- }
- return 0;
-}
-
-static int ljpeg_decode_yuv_scan(MJpegDecodeContext *s, int nb_components, int predictor,
- int point_transform)
-{
- int i, mb_x, mb_y;
- int bits= (s->bits+7)&~7;
- int resync_mb_y = 0;
- int resync_mb_x = 0;
-
- point_transform += bits - s->bits;
-
- av_assert0(nb_components>=1 && nb_components<=3);
-
- for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
- for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
- if (s->restart_interval && !s->restart_count){
- s->restart_count = s->restart_interval;
- resync_mb_x = mb_x;
- resync_mb_y = mb_y;
- }
-
- if(!mb_x || mb_y == resync_mb_y || mb_y == resync_mb_y+1 && mb_x < resync_mb_x || s->interlaced){
- int toprow = mb_y == resync_mb_y || mb_y == resync_mb_y+1 && mb_x < resync_mb_x;
- int leftcol = !mb_x || mb_y == resync_mb_y && mb_x == resync_mb_x;
- for (i = 0; i < nb_components; i++) {
- uint8_t *ptr;
- uint16_t *ptr16;
- int n, h, v, x, y, c, j, linesize;
- n = s->nb_blocks[i];
- c = s->comp_index[i];
- h = s->h_scount[i];
- v = s->v_scount[i];
- x = 0;
- y = 0;
- linesize= s->linesize[c];
-
- if(bits>8) linesize /= 2;
-
- for(j=0; j<n; j++) {
- int pred, dc;
-
- dc = mjpeg_decode_dc(s, s->dc_index[i]);
- if(dc == 0xFFFF)
- return -1;
- if(bits<=8){
- ptr = s->picture.data[c] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap
- if(y==0 && toprow){
- if(x==0 && leftcol){
- pred= 1 << (bits - 1);
- }else{
- pred= ptr[-1];
- }
- }else{
- if(x==0 && leftcol){
- pred= ptr[-linesize];
- }else{
- PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);
- }
- }
-
- if (s->interlaced && s->bottom_field)
- ptr += linesize >> 1;
- pred &= (-1)<<(8-s->bits);
- *ptr= pred + (dc << point_transform);
- }else{
- ptr16 = (uint16_t*)(s->picture.data[c] + 2*(linesize * (v * mb_y + y)) + 2*(h * mb_x + x)); //FIXME optimize this crap
- if(y==0 && toprow){
- if(x==0 && leftcol){
- pred= 1 << (bits - 1);
- }else{
- pred= ptr16[-1];
- }
- }else{
- if(x==0 && leftcol){
- pred= ptr16[-linesize];
- }else{
- PREDICT(pred, ptr16[-linesize-1], ptr16[-linesize], ptr16[-1], predictor);
- }
- }
-
- if (s->interlaced && s->bottom_field)
- ptr16 += linesize >> 1;
- pred &= (-1)<<(16-s->bits);
- *ptr16= pred + (dc << point_transform);
- }
- if (++x == h) {
- x = 0;
- y++;
- }
- }
- }
- } else {
- for (i = 0; i < nb_components; i++) {
- uint8_t *ptr;
- uint16_t *ptr16;
- int n, h, v, x, y, c, j, linesize, dc;
- n = s->nb_blocks[i];
- c = s->comp_index[i];
- h = s->h_scount[i];
- v = s->v_scount[i];
- x = 0;
- y = 0;
- linesize = s->linesize[c];
-
- if(bits>8) linesize /= 2;
-
- for (j = 0; j < n; j++) {
- int pred;
-
- dc = mjpeg_decode_dc(s, s->dc_index[i]);
- if(dc == 0xFFFF)
- return -1;
- if(bits<=8){
- ptr = s->picture.data[c] +
- (linesize * (v * mb_y + y)) +
- (h * mb_x + x); //FIXME optimize this crap
- PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);
-
- pred &= (-1)<<(8-s->bits);
- *ptr = pred + (dc << point_transform);
- }else{
- ptr16 = (uint16_t*)(s->picture.data[c] + 2*(linesize * (v * mb_y + y)) + 2*(h * mb_x + x)); //FIXME optimize this crap
- PREDICT(pred, ptr16[-linesize-1], ptr16[-linesize], ptr16[-1], predictor);
-
- pred &= (-1)<<(16-s->bits);
- *ptr16= pred + (dc << point_transform);
- }
-
- if (++x == h) {
- x = 0;
- y++;
- }
- }
- }
- }
- if (s->restart_interval && !--s->restart_count) {
- align_get_bits(&s->gb);
- skip_bits(&s->gb, 16); /* skip RSTn */
- }
- }
- }
- return 0;
-}
-
-static av_always_inline void mjpeg_copy_block(MJpegDecodeContext *s,
- uint8_t *dst, const uint8_t *src,
- int linesize, int lowres)
-{
- switch (lowres) {
- case 0: s->dsp.put_pixels_tab[1][0](dst, src, linesize, 8);
- break;
- case 1: copy_block4(dst, src, linesize, linesize, 4);
- break;
- case 2: copy_block2(dst, src, linesize, linesize, 2);
- break;
- case 3: *dst = *src;
- break;
- }
-}
-
-static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah,
- int Al, const uint8_t *mb_bitmask,
- 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;
-
- if (mb_bitmask)
- 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;
- }
-
- 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++) {
- for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
- const int copy_mb = mb_bitmask && !get_bits1(&mb_bitmask_gb);
-
- if (s->restart_interval && !s->restart_count)
- s->restart_count = s->restart_interval;
-
- if (get_bits_left(&s->gb) < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "overread %d\n",
- -get_bits_left(&s->gb));
- return AVERROR_INVALIDDATA;
- }
- for (i = 0; i < nb_components; i++) {
- uint8_t *ptr;
- int n, h, v, x, y, c, j;
- int block_offset;
- n = s->nb_blocks[i];
- c = s->comp_index[i];
- h = s->h_scount[i];
- v = s->v_scount[i];
- x = 0;
- y = 0;
- for (j = 0; j < n; j++) {
- block_offset = (((linesize[c] * (v * mb_y + y) * 8) +
- (h * mb_x + x) * 8) >> s->avctx->lowres);
-
- if (s->interlaced && s->bottom_field)
- block_offset += linesize[c] >> 1;
- ptr = data[c] + block_offset;
- if (!s->progressive) {
- if (copy_mb)
- mjpeg_copy_block(s, ptr, reference_data[c] + block_offset,
- linesize[c], s->avctx->lowres);
-
- else {
- s->dsp.clear_block(s->block);
- if (decode_block(s, s->block, i,
- s->dc_index[i], s->ac_index[i],
- s->quant_matrixes[s->quant_index[c]]) < 0) {
- av_log(s->avctx, AV_LOG_ERROR,
- "error y=%d x=%d\n", mb_y, mb_x);
- return AVERROR_INVALIDDATA;
- }
- s->dsp.idct_put(ptr, linesize[c], s->block);
- }
- } else {
- int block_idx = s->block_stride[c] * (v * mb_y + y) +
- (h * mb_x + x);
- int16_t *block = s->blocks[c][block_idx];
- if (Ah)
- block[0] += get_bits1(&s->gb) *
- s->quant_matrixes[s->quant_index[c]][0] << Al;
- else if (decode_dc_progressive(s, block, i, s->dc_index[i],
- s->quant_matrixes[s->quant_index[c]],
- Al) < 0) {
- av_log(s->avctx, AV_LOG_ERROR,
- "error y=%d x=%d\n", mb_y, mb_x);
- return AVERROR_INVALIDDATA;
- }
- }
- av_dlog(s->avctx, "mb: %d %d processed\n", mb_y, mb_x);
- av_dlog(s->avctx, "%d %d %d %d %d %d %d %d \n",
- mb_x, mb_y, x, y, c, s->bottom_field,
- (v * mb_y + y) * 8, (h * mb_x + x) * 8);
- if (++x == h) {
- x = 0;
- y++;
- }
- }
- }
-
- handle_rstn(s, nb_components);
- }
- }
- return 0;
-}
-
-static int mjpeg_decode_scan_progressive_ac(MJpegDecodeContext *s, int ss,
- int se, int Ah, int Al)
-{
- int mb_x, mb_y;
- int EOBRUN = 0;
- int c = s->comp_index[0];
- uint8_t *data = s->picture.data[c];
- int linesize = s->linesize[c];
- int last_scan = 0;
- int16_t *quant_matrix = s->quant_matrixes[s->quant_index[c]];
-
- if (se > 63) {
- av_log(s->avctx, AV_LOG_ERROR, "SE %d is too large\n", se);
- return AVERROR_INVALIDDATA;
- }
-
- if (!Al) {
- s->coefs_finished[c] |= (1LL << (se + 1)) - (1LL << ss);
- last_scan = !~s->coefs_finished[c];
- }
-
- if (s->interlaced && s->bottom_field)
- data += linesize >> 1;
-
- s->restart_count = 0;
-
- for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
- uint8_t *ptr = data + (mb_y * linesize * 8 >> s->avctx->lowres);
- int block_idx = mb_y * s->block_stride[c];
- int16_t (*block)[64] = &s->blocks[c][block_idx];
- uint8_t *last_nnz = &s->last_nnz[c][block_idx];
- for (mb_x = 0; mb_x < s->mb_width; mb_x++, block++, last_nnz++) {
- int ret;
- if (s->restart_interval && !s->restart_count)
- s->restart_count = s->restart_interval;
-
- if (Ah)
- ret = decode_block_refinement(s, *block, last_nnz, s->ac_index[0],
- quant_matrix, ss, se, Al, &EOBRUN);
- else
- ret = decode_block_progressive(s, *block, last_nnz, s->ac_index[0],
- quant_matrix, ss, se, Al, &EOBRUN);
- if (ret < 0) {
- av_log(s->avctx, AV_LOG_ERROR,
- "error y=%d x=%d\n", mb_y, mb_x);
- return AVERROR_INVALIDDATA;
- }
-
- if (last_scan) {
- s->dsp.idct_put(ptr, linesize, *block);
- ptr += 8 >> s->avctx->lowres;
- }
- handle_rstn(s, 0);
- }
- }
- return 0;
-}
-
-int ff_mjpeg_decode_sos(MJpegDecodeContext *s, const uint8_t *mb_bitmask,
- const AVFrame *reference)
-{
- int len, nb_components, i, h, v, predictor, point_transform;
- int index, id, ret;
- const int block_size = s->lossless ? 1 : 8;
- int ilv, prev_shift;
-
- if (!s->got_picture) {
- av_log(s->avctx, AV_LOG_WARNING,
- "Can not process SOS before SOF, skipping\n");
- return -1;
- }
-
- av_assert0(s->picture_ptr->data[0]);
- /* XXX: verify len field validity */
- len = get_bits(&s->gb, 16);
- nb_components = get_bits(&s->gb, 8);
- if (nb_components == 0 || nb_components > MAX_COMPONENTS) {
- av_log(s->avctx, AV_LOG_ERROR,
- "decode_sos: nb_components (%d) unsupported\n", nb_components);
- return AVERROR_PATCHWELCOME;
- }
- if (len != 6 + 2 * nb_components) {
- av_log(s->avctx, AV_LOG_ERROR, "decode_sos: invalid len (%d)\n", len);
- return AVERROR_INVALIDDATA;
- }
- for (i = 0; i < nb_components; i++) {
- id = get_bits(&s->gb, 8) - 1;
- av_log(s->avctx, AV_LOG_DEBUG, "component: %d\n", id);
- /* find component index */
- for (index = 0; index < s->nb_components; index++)
- if (id == s->component_id[index])
- break;
- if (index == s->nb_components) {
- av_log(s->avctx, AV_LOG_ERROR,
- "decode_sos: index(%d) out of components\n", index);
- return AVERROR_INVALIDDATA;
- }
- /* Metasoft MJPEG codec has Cb and Cr swapped */
- if (s->avctx->codec_tag == MKTAG('M', 'T', 'S', 'J')
- && nb_components == 3 && s->nb_components == 3 && i)
- index = 3 - i;
-
- if(nb_components == 3 && s->nb_components == 3 && s->avctx->pix_fmt == AV_PIX_FMT_GBR24P)
- index = (i+2)%3;
- if(nb_components == 1 && s->nb_components == 3 && s->avctx->pix_fmt == AV_PIX_FMT_GBR24P)
- index = (index+2)%3;
-
- s->comp_index[i] = index;
-
- s->nb_blocks[i] = s->h_count[index] * s->v_count[index];
- s->h_scount[i] = s->h_count[index];
- s->v_scount[i] = s->v_count[index];
-
- s->dc_index[i] = get_bits(&s->gb, 4);
- s->ac_index[i] = get_bits(&s->gb, 4);
-
- if (s->dc_index[i] < 0 || s->ac_index[i] < 0 ||
- s->dc_index[i] >= 4 || s->ac_index[i] >= 4)
- goto out_of_range;
- if (!s->vlcs[0][s->dc_index[i]].table || !(s->progressive ? s->vlcs[2][s->ac_index[0]].table : s->vlcs[1][s->ac_index[i]].table))
- goto out_of_range;
- }
-
- predictor = get_bits(&s->gb, 8); /* JPEG Ss / lossless JPEG predictor /JPEG-LS NEAR */
- ilv = get_bits(&s->gb, 8); /* JPEG Se / JPEG-LS ILV */
- if(s->avctx->codec_tag != AV_RL32("CJPG")){
- prev_shift = get_bits(&s->gb, 4); /* Ah */
- point_transform = get_bits(&s->gb, 4); /* Al */
- }else
- prev_shift = point_transform = 0;
-
- if (nb_components > 1) {
- /* interleaved stream */
- s->mb_width = (s->width + s->h_max * block_size - 1) / (s->h_max * block_size);
- s->mb_height = (s->height + s->v_max * block_size - 1) / (s->v_max * block_size);
- } else if (!s->ls) { /* skip this for JPEG-LS */
- h = s->h_max / s->h_scount[0];
- v = s->v_max / s->v_scount[0];
- s->mb_width = (s->width + h * block_size - 1) / (h * block_size);
- s->mb_height = (s->height + v * block_size - 1) / (v * block_size);
- s->nb_blocks[0] = 1;
- s->h_scount[0] = 1;
- s->v_scount[0] = 1;
- }
-
- if (s->avctx->debug & FF_DEBUG_PICT_INFO)
- av_log(s->avctx, AV_LOG_DEBUG, "%s %s p:%d >>:%d ilv:%d bits:%d skip:%d %s comp:%d\n",
- s->lossless ? "lossless" : "sequential DCT", s->rgb ? "RGB" : "",
- predictor, point_transform, ilv, s->bits, s->mjpb_skiptosod,
- s->pegasus_rct ? "PRCT" : (s->rct ? "RCT" : ""), nb_components);
-
-
- /* mjpeg-b can have padding bytes between sos and image data, skip them */
- for (i = s->mjpb_skiptosod; i > 0; i--)
- skip_bits(&s->gb, 8);
-
-next_field:
- for (i = 0; i < nb_components; i++)
- s->last_dc[i] = 1024;
-
- if (s->lossless) {
- av_assert0(s->picture_ptr == &s->picture);
- if (CONFIG_JPEGLS_DECODER && s->ls) {
-// for () {
-// reset_ls_coding_parameters(s, 0);
-
- if ((ret = ff_jpegls_decode_picture(s, predictor,
- point_transform, ilv)) < 0)
- return ret;
- } else {
- if (s->rgb) {
- if ((ret = ljpeg_decode_rgb_scan(s, nb_components, predictor, point_transform)) < 0)
- return ret;
- } else {
- if ((ret = ljpeg_decode_yuv_scan(s, nb_components, predictor, point_transform)) < 0)
- return ret;
- }
- }
- } else {
- if (s->progressive && predictor) {
- av_assert0(s->picture_ptr == &s->picture);
- if ((ret = mjpeg_decode_scan_progressive_ac(s, predictor,
- ilv, prev_shift,
- point_transform)) < 0)
- return ret;
- } else {
- if ((ret = mjpeg_decode_scan(s, nb_components,
- prev_shift, point_transform,
- mb_bitmask, reference)) < 0)
- return ret;
- }
- }
-
- if (s->interlaced &&
- get_bits_left(&s->gb) > 32 &&
- show_bits(&s->gb, 8) == 0xFF) {
- GetBitContext bak = s->gb;
- align_get_bits(&bak);
- if (show_bits(&bak, 16) == 0xFFD1) {
- av_log(s->avctx, AV_LOG_DEBUG, "AVRn interlaced picture marker found\n");
- s->gb = bak;
- skip_bits(&s->gb, 16);
- s->bottom_field ^= 1;
-
- goto next_field;
- }
- }
-
- emms_c();
- return 0;
- out_of_range:
- av_log(s->avctx, AV_LOG_ERROR, "decode_sos: ac/dc index out of range\n");
- return AVERROR_INVALIDDATA;
-}
-
-static int mjpeg_decode_dri(MJpegDecodeContext *s)
-{
- if (get_bits(&s->gb, 16) != 4)
- return AVERROR_INVALIDDATA;
- s->restart_interval = get_bits(&s->gb, 16);
- s->restart_count = 0;
- av_log(s->avctx, AV_LOG_DEBUG, "restart interval: %d\n",
- s->restart_interval);
-
- return 0;
-}
-
-static int mjpeg_decode_app(MJpegDecodeContext *s)
-{
- int len, id, i;
-
- len = get_bits(&s->gb, 16);
- if (len < 5)
- return AVERROR_INVALIDDATA;
- if (8 * len > get_bits_left(&s->gb))
- return AVERROR_INVALIDDATA;
-
- id = get_bits_long(&s->gb, 32);
- id = av_be2ne32(id);
- len -= 6;
-
- if (s->avctx->debug & FF_DEBUG_STARTCODE)
- av_log(s->avctx, AV_LOG_DEBUG, "APPx %8X\n", id);
-
- /* Buggy AVID, it puts EOI only at every 10th frame. */
- /* Also, this fourcc is used by non-avid files too, it holds some
- information, but it's always present in AVID-created files. */
- if (id == AV_RL32("AVI1")) {
- /* structure:
- 4bytes AVI1
- 1bytes polarity
- 1bytes always zero
- 4bytes field_size
- 4bytes field_size_less_padding
- */
- s->buggy_avid = 1;
- i = get_bits(&s->gb, 8); len--;
- av_log(s->avctx, AV_LOG_DEBUG, "polarity %d\n", i);
-#if 0
- skip_bits(&s->gb, 8);
- skip_bits(&s->gb, 32);
- skip_bits(&s->gb, 32);
- len -= 10;
-#endif
- goto out;
- }
-
-// len -= 2;
-
- if (id == AV_RL32("JFIF")) {
- int t_w, t_h, v1, v2;
- skip_bits(&s->gb, 8); /* the trailing zero-byte */
- v1 = get_bits(&s->gb, 8);
- v2 = get_bits(&s->gb, 8);
- skip_bits(&s->gb, 8);
-
- s->avctx->sample_aspect_ratio.num = get_bits(&s->gb, 16);
- s->avctx->sample_aspect_ratio.den = get_bits(&s->gb, 16);
-
- if (s->avctx->debug & FF_DEBUG_PICT_INFO)
- av_log(s->avctx, AV_LOG_INFO,
- "mjpeg: JFIF header found (version: %x.%x) SAR=%d/%d\n",
- v1, v2,
- s->avctx->sample_aspect_ratio.num,
- s->avctx->sample_aspect_ratio.den);
-
- t_w = get_bits(&s->gb, 8);
- t_h = get_bits(&s->gb, 8);
- if (t_w && t_h) {
- /* skip thumbnail */
- if (len -10 - (t_w * t_h * 3) > 0)
- len -= t_w * t_h * 3;
- }
- len -= 10;
- goto out;
- }
-
- if (id == AV_RL32("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 */
- len -= 7;
- goto out;
- }
-
- if (id == AV_RL32("LJIF")) {
- if (s->avctx->debug & FF_DEBUG_PICT_INFO)
- av_log(s->avctx, AV_LOG_INFO,
- "Pegasus lossless jpeg header found\n");
- skip_bits(&s->gb, 16); /* version ? */
- skip_bits(&s->gb, 16); /* unknown always 0? */
- skip_bits(&s->gb, 16); /* unknown always 0? */
- skip_bits(&s->gb, 16); /* unknown always 0? */
- switch (get_bits(&s->gb, 8)) {
- case 1:
- s->rgb = 1;
- s->pegasus_rct = 0;
- break;
- case 2:
- s->rgb = 1;
- s->pegasus_rct = 1;
- break;
- default:
- av_log(s->avctx, AV_LOG_ERROR, "unknown colorspace\n");
- }
- len -= 9;
- goto out;
- }
-
- /* Apple MJPEG-A */
- if ((s->start_code == APP1) && (len > (0x28 - 8))) {
- id = get_bits_long(&s->gb, 32);
- id = av_be2ne32(id);
- len -= 4;
- /* Apple MJPEG-A */
- if (id == AV_RL32("mjpg")) {
-#if 0
- skip_bits(&s->gb, 32); /* field size */
- skip_bits(&s->gb, 32); /* pad field size */
- skip_bits(&s->gb, 32); /* next off */
- skip_bits(&s->gb, 32); /* quant off */
- skip_bits(&s->gb, 32); /* huff off */
- skip_bits(&s->gb, 32); /* image off */
- skip_bits(&s->gb, 32); /* scan off */
- skip_bits(&s->gb, 32); /* data off */
-#endif
- if (s->avctx->debug & FF_DEBUG_PICT_INFO)
- av_log(s->avctx, AV_LOG_INFO, "mjpeg: Apple MJPEG-A header found\n");
- }
- }
-
-out:
- /* slow but needed for extreme adobe jpegs */
- if (len < 0)
- av_log(s->avctx, AV_LOG_ERROR,
- "mjpeg: error, decode_app parser read over the end\n");
- while (--len > 0)
- skip_bits(&s->gb, 8);
-
- return 0;
-}
-
-static int mjpeg_decode_com(MJpegDecodeContext *s)
-{
- int len = get_bits(&s->gb, 16);
- if (len >= 2 && 8 * len - 16 <= get_bits_left(&s->gb)) {
- char *cbuf = av_malloc(len - 1);
- if (cbuf) {
- int i;
- for (i = 0; i < len - 2; i++)
- cbuf[i] = get_bits(&s->gb, 8);
- if (i > 0 && cbuf[i - 1] == '\n')
- cbuf[i - 1] = 0;
- else
- cbuf[i] = 0;
-
- if (s->avctx->debug & FF_DEBUG_PICT_INFO)
- av_log(s->avctx, AV_LOG_INFO, "comment: '%s'\n", cbuf);
-
- /* buggy avid, it puts EOI only at every 10th frame */
- if (!strcmp(cbuf, "AVID")) {
- s->buggy_avid = 1;
- } else if (!strcmp(cbuf, "CS=ITU601"))
- s->cs_itu601 = 1;
- else if ((len > 31 && !strncmp(cbuf, "Intel(R) JPEG Library, version 1", 32)) ||
- (len > 19 && !strncmp(cbuf, "Metasoft MJPEG Codec", 20)))
- s->flipped = 1;
-
- av_free(cbuf);
- }
- }
-
- return 0;
-}
-
-/* return the 8 bit start code value and update the search
- state. Return -1 if no start code found */
-static int find_marker(const uint8_t **pbuf_ptr, const uint8_t *buf_end)
-{
- const uint8_t *buf_ptr;
- unsigned int v, v2;
- int val;
- int skipped = 0;
-
- buf_ptr = *pbuf_ptr;
- while (buf_ptr < buf_end) {
- v = *buf_ptr++;
- v2 = *buf_ptr;
- if ((v == 0xff) && (v2 >= 0xc0) && (v2 <= 0xfe) && buf_ptr < buf_end) {
- val = *buf_ptr++;
- goto found;
- }
- skipped++;
- }
- val = -1;
-found:
- av_dlog(NULL, "find_marker skipped %d bytes\n", skipped);
- *pbuf_ptr = buf_ptr;
- return val;
-}
-
-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)
-{
- int start_code;
- start_code = find_marker(buf_ptr, buf_end);
-
- av_fast_padded_malloc(&s->buffer, &s->buffer_size, buf_end - *buf_ptr);
- if (!s->buffer)
- return AVERROR(ENOMEM);
-
- /* unescape buffer of SOS, use special treatment for JPEG-LS */
- if (start_code == SOS && !s->ls) {
- const uint8_t *src = *buf_ptr;
- uint8_t *dst = s->buffer;
-
- while (src < buf_end) {
- uint8_t x = *(src++);
-
- *(dst++) = x;
- if (s->avctx->codec_id != AV_CODEC_ID_THP) {
- if (x == 0xff) {
- while (src < buf_end && x == 0xff)
- x = *(src++);
-
- if (x >= 0xd0 && x <= 0xd7)
- *(dst++) = x;
- else if (x)
- break;
- }
- }
- }
- *unescaped_buf_ptr = s->buffer;
- *unescaped_buf_size = dst - s->buffer;
- memset(s->buffer + *unescaped_buf_size, 0,
- FF_INPUT_BUFFER_PADDING_SIZE);
-
- av_log(s->avctx, AV_LOG_DEBUG, "escaping removed %td bytes\n",
- (buf_end - *buf_ptr) - (dst - s->buffer));
- } else if (start_code == SOS && s->ls) {
- const uint8_t *src = *buf_ptr;
- uint8_t *dst = s->buffer;
- int bit_count = 0;
- int t = 0, b = 0;
- PutBitContext pb;
-
- s->cur_scan++;
-
- /* find marker */
- while (src + t < buf_end) {
- uint8_t x = src[t++];
- if (x == 0xff) {
- while ((src + t < buf_end) && x == 0xff)
- x = src[t++];
- if (x & 0x80) {
- t -= FFMIN(2, t);
- break;
- }
- }
- }
- bit_count = t * 8;
- init_put_bits(&pb, dst, t);
-
- /* unescape bitstream */
- while (b < t) {
- uint8_t x = src[b++];
- put_bits(&pb, 8, x);
- if (x == 0xFF) {
- x = src[b++];
- put_bits(&pb, 7, x);
- bit_count--;
- }
- }
- flush_put_bits(&pb);
-
- *unescaped_buf_ptr = dst;
- *unescaped_buf_size = (bit_count + 7) >> 3;
- memset(s->buffer + *unescaped_buf_size, 0,
- FF_INPUT_BUFFER_PADDING_SIZE);
- } else {
- *unescaped_buf_ptr = *buf_ptr;
- *unescaped_buf_size = buf_end - *buf_ptr;
- }
-
- return start_code;
-}
-
-int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
- AVPacket *avpkt)
-{
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
- MJpegDecodeContext *s = avctx->priv_data;
- const uint8_t *buf_end, *buf_ptr;
- const uint8_t *unescaped_buf_ptr;
- int unescaped_buf_size;
- int start_code;
- int i, index;
- int ret = 0;
- AVFrame *picture = data;
-
- buf_ptr = buf;
- buf_end = buf + buf_size;
- while (buf_ptr < buf_end) {
- /* find start next marker */
- start_code = ff_mjpeg_find_marker(s, &buf_ptr, buf_end,
- &unescaped_buf_ptr,
- &unescaped_buf_size);
- /* EOF */
- if (start_code < 0) {
- goto the_end;
- } else if (unescaped_buf_size > (1U<<28)) {
- av_log(avctx, AV_LOG_ERROR, "MJPEG packet 0x%x too big (0x%x/0x%x), corrupt data?\n",
- start_code, unescaped_buf_size, buf_size);
- return AVERROR_INVALIDDATA;
- } else {
- av_log(avctx, AV_LOG_DEBUG, "marker=%x avail_size_in_buf=%td\n",
- start_code, buf_end - buf_ptr);
-
- init_get_bits(&s->gb, unescaped_buf_ptr, unescaped_buf_size * 8);
-
- s->start_code = start_code;
- if (s->avctx->debug & FF_DEBUG_STARTCODE)
- av_log(avctx, AV_LOG_DEBUG, "startcode: %X\n", start_code);
-
- /* process markers */
- if (start_code >= 0xd0 && start_code <= 0xd7)
- av_log(avctx, AV_LOG_DEBUG,
- "restart marker: %d\n", start_code & 0x0f);
- /* APP fields */
- else if (start_code >= APP0 && start_code <= APP15)
- mjpeg_decode_app(s);
- /* Comment */
- else if (start_code == COM)
- mjpeg_decode_com(s);
-
- ret = -1;
- switch (start_code) {
- case SOI:
- s->restart_interval = 0;
- s->restart_count = 0;
- /* nothing to do on SOI */
- break;
- case DQT:
- ff_mjpeg_decode_dqt(s);
- break;
- case DHT:
- if ((ret = ff_mjpeg_decode_dht(s)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "huffman table decode error\n");
- goto fail;
- }
- break;
- case SOF0:
- case SOF1:
- s->lossless = 0;
- s->ls = 0;
- s->progressive = 0;
- if ((ret = ff_mjpeg_decode_sof(s)) < 0)
- goto fail;
- break;
- case SOF2:
- s->lossless = 0;
- s->ls = 0;
- s->progressive = 1;
- if ((ret = ff_mjpeg_decode_sof(s)) < 0)
- goto fail;
- break;
- case SOF3:
- s->lossless = 1;
- s->ls = 0;
- s->progressive = 0;
- if ((ret = ff_mjpeg_decode_sof(s)) < 0)
- goto fail;
- break;
- case SOF48:
- s->lossless = 1;
- s->ls = 1;
- s->progressive = 0;
- if ((ret = ff_mjpeg_decode_sof(s)) < 0)
- goto fail;
- break;
- case LSE:
- if (!CONFIG_JPEGLS_DECODER ||
- (ret = ff_jpegls_decode_lse(s)) < 0)
- goto fail;
- break;
- case EOI:
-eoi_parser:
- s->cur_scan = 0;
- if (!s->got_picture) {
- av_log(avctx, AV_LOG_WARNING,
- "Found EOI before any SOF, ignoring\n");
- break;
- }
- if (s->interlaced) {
- s->bottom_field ^= 1;
- /* if not bottom field, do not output image yet */
- if (s->bottom_field == !s->interlace_polarity)
- break;
- }
- *picture = *s->picture_ptr;
- *got_frame = 1;
- s->got_picture = 0;
-
- if (!s->lossless) {
- picture->quality = FFMAX3(s->qscale[0],
- s->qscale[1],
- s->qscale[2]);
- picture->qstride = 0;
- picture->qscale_table = s->qscale_table;
- memset(picture->qscale_table, picture->quality,
- (s->width + 15) / 16);
- if (avctx->debug & FF_DEBUG_QP)
- av_log(avctx, AV_LOG_DEBUG,
- "QP: %d\n", picture->quality);
- picture->quality *= FF_QP2LAMBDA;
- }
-
- goto the_end;
- case SOS:
- if ((ret = ff_mjpeg_decode_sos(s, NULL, NULL)) < 0 &&
- (avctx->err_recognition & AV_EF_EXPLODE))
- goto fail;
- break;
- case DRI:
- mjpeg_decode_dri(s);
- break;
- case SOF5:
- case SOF6:
- case SOF7:
- case SOF9:
- case SOF10:
- case SOF11:
- case SOF13:
- case SOF14:
- case SOF15:
- case JPG:
- av_log(avctx, AV_LOG_ERROR,
- "mjpeg: unsupported coding type (%x)\n", start_code);
- break;
- }
-
- /* eof process start code */
- buf_ptr += (get_bits_count(&s->gb) + 7) / 8;
- av_log(avctx, AV_LOG_DEBUG,
- "marker parser used %d bytes (%d bits)\n",
- (get_bits_count(&s->gb) + 7) / 8, get_bits_count(&s->gb));
- }
- }
- if (s->got_picture) {
- av_log(avctx, AV_LOG_WARNING, "EOI missing, emulating\n");
- goto eoi_parser;
- }
- av_log(avctx, AV_LOG_FATAL, "No JPEG data found in image\n");
- return AVERROR_INVALIDDATA;
-fail:
- s->got_picture = 0;
- return ret;
-the_end:
- if (s->upscale_h) {
- uint8_t *line = s->picture_ptr->data[s->upscale_h];
- 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];
- }
- }
- if (s->upscale_v) {
- uint8_t *dst = &((uint8_t *)s->picture_ptr->data[s->upscale_v])[(s->height - 1) * s->linesize[s->upscale_v]];
- 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, s->width);
- } else {
- for (index = 0; index < s->width; index++)
- dst[index] = (src1[index] + src2[index]) >> 1;
- }
- dst -= s->linesize[s->upscale_v];
- }
- }
- if (s->flipped && (s->avctx->flags & CODEC_FLAG_EMU_EDGE)) {
- int hshift, vshift, 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;
- if(index && index<3){
- w = -((-w) >> hshift);
- h = -((-h) >> vshift);
- }
- if(dst){
- uint8_t *dst2 = dst + s->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];
- }
- }
- }
- }
-
- av_log(avctx, AV_LOG_DEBUG, "decode frame unused %td bytes\n",
- buf_end - buf_ptr);
-// return buf_end - buf_ptr;
- return buf_ptr - buf;
-}
-
-av_cold int ff_mjpeg_decode_end(AVCodecContext *avctx)
-{
- MJpegDecodeContext *s = avctx->priv_data;
- int i, j;
-
- if (s->picture_ptr && s->picture_ptr->data[0])
- avctx->release_buffer(avctx, s->picture_ptr);
-
- av_free(s->buffer);
- av_free(s->qscale_table);
- av_freep(&s->ljpeg_buffer);
- s->ljpeg_buffer_size = 0;
-
- for (i = 0; i < 3; i++) {
- for (j = 0; j < 4; j++)
- ff_free_vlc(&s->vlcs[i][j]);
- }
- for (i = 0; i < MAX_COMPONENTS; i++) {
- av_freep(&s->blocks[i]);
- av_freep(&s->last_nnz[i]);
- }
- return 0;
-}
-
-static void decode_flush(AVCodecContext *avctx)
-{
- MJpegDecodeContext *s = avctx->priv_data;
- s->got_picture = 0;
-}
-
-#if CONFIG_MJPEG_DECODER
-#define OFFSET(x) offsetof(MJpegDecodeContext, x)
-#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
-static const AVOption options[] = {
- { "extern_huff", "Use external huffman table.",
- OFFSET(extern_huff), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VD },
- { NULL },
-};
-
-static const AVClass mjpegdec_class = {
- .class_name = "MJPEG decoder",
- .item_name = av_default_item_name,
- .option = options,
- .version = LIBAVUTIL_VERSION_INT,
-};
-
-AVCodec ff_mjpeg_decoder = {
- .name = "mjpeg",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_MJPEG,
- .priv_data_size = sizeof(MJpegDecodeContext),
- .init = ff_mjpeg_decode_init,
- .close = ff_mjpeg_decode_end,
- .decode = ff_mjpeg_decode_frame,
- .flush = decode_flush,
- .capabilities = CODEC_CAP_DR1,
- .max_lowres = 3,
- .long_name = NULL_IF_CONFIG_SMALL("MJPEG (Motion JPEG)"),
- .priv_class = &mjpegdec_class,
-};
-#endif
-#if CONFIG_THP_DECODER
-AVCodec ff_thp_decoder = {
- .name = "thp",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_THP,
- .priv_data_size = sizeof(MJpegDecodeContext),
- .init = ff_mjpeg_decode_init,
- .close = ff_mjpeg_decode_end,
- .decode = ff_mjpeg_decode_frame,
- .flush = decode_flush,
- .capabilities = CODEC_CAP_DR1,
- .max_lowres = 3,
- .long_name = NULL_IF_CONFIG_SMALL("Nintendo Gamecube THP video"),
-};
-#endif
diff --git a/src/thirdparty/ffmpeg/libavcodec/mjpegdec.h b/src/thirdparty/ffmpeg/libavcodec/mjpegdec.h
deleted file mode 100644
index 3c56b4c61..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mjpegdec.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * MJPEG decoder
- * Copyright (c) 2000, 2001 Fabrice Bellard
- * Copyright (c) 2003 Alex Beregszaszi
- * Copyright (c) 2003-2004 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
- */
-
-/**
- * @file
- * MJPEG decoder.
- */
-
-#ifndef AVCODEC_MJPEGDEC_H
-#define AVCODEC_MJPEGDEC_H
-
-#include "libavutil/log.h"
-
-#include "avcodec.h"
-#include "get_bits.h"
-#include "dsputil.h"
-
-#define MAX_COMPONENTS 4
-
-typedef struct MJpegDecodeContext {
- AVClass *class;
- AVCodecContext *avctx;
- GetBitContext gb;
-
- int start_code; /* current start code */
- int buffer_size;
- uint8_t *buffer;
-
- int16_t quant_matrixes[4][64];
- VLC vlcs[3][4];
- int qscale[4]; ///< quantizer scale calculated from quant_matrixes
-
- int org_height; /* size given at codec init */
- int first_picture; /* true if decoding first picture */
- int interlaced; /* true if interlaced */
- int bottom_field; /* true if bottom field */
- int lossless;
- int ls;
- int progressive;
- int rgb;
- int upscale_h;
- int chroma_height;
- int upscale_v;
- int rct; /* standard rct */
- int pegasus_rct; /* pegasus reversible colorspace transform */
- int bits; /* bits per component */
-
- int maxval;
- int near; ///< near lossless bound (si 0 for lossless)
- int t1,t2,t3;
- int reset; ///< context halfing interval ?rename
-
- int width, height;
- int mb_width, mb_height;
- int nb_components;
- int block_stride[MAX_COMPONENTS];
- int component_id[MAX_COMPONENTS];
- int h_count[MAX_COMPONENTS]; /* horizontal and vertical count for each component */
- int v_count[MAX_COMPONENTS];
- int comp_index[MAX_COMPONENTS];
- int dc_index[MAX_COMPONENTS];
- int ac_index[MAX_COMPONENTS];
- int nb_blocks[MAX_COMPONENTS];
- int h_scount[MAX_COMPONENTS];
- int v_scount[MAX_COMPONENTS];
- int h_max, v_max; /* maximum h and v counts */
- int quant_index[4]; /* quant table index for each component */
- int last_dc[MAX_COMPONENTS]; /* last DEQUANTIZED dc (XXX: am I right to do that ?) */
- AVFrame picture; /* picture structure */
- AVFrame *picture_ptr; /* pointer to picture structure */
- int got_picture; ///< we found a SOF and picture is valid, too.
- int linesize[MAX_COMPONENTS]; ///< linesize << interlaced
- int8_t *qscale_table;
- DECLARE_ALIGNED(16, int16_t, block)[64];
- 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)
- ScanTable scantable;
- DSPContext dsp;
-
- int restart_interval;
- int restart_count;
-
- int buggy_avid;
- int cs_itu601;
- int interlace_polarity;
-
- int mjpb_skiptosod;
-
- int cur_scan; /* current scan, used by JPEG-LS */
- int flipped; /* true if picture is flipped */
-
- uint16_t (*ljpeg_buffer)[4];
- unsigned int ljpeg_buffer_size;
-
- int extern_huff;
-} MJpegDecodeContext;
-
-int ff_mjpeg_decode_init(AVCodecContext *avctx);
-int ff_mjpeg_decode_end(AVCodecContext *avctx);
-int ff_mjpeg_decode_frame(AVCodecContext *avctx,
- void *data, int *got_frame,
- AVPacket *avpkt);
-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);
-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);
-
-#endif /* AVCODEC_MJPEGDEC_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/mjpegenc.h b/src/thirdparty/ffmpeg/libavcodec/mjpegenc.h
deleted file mode 100644
index aa0096a2e..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mjpegenc.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * MJPEG encoder
- * Copyright (c) 2000, 2001 Fabrice Bellard
- * Copyright (c) 2003 Alex Beregszaszi
- * Copyright (c) 2003-2004 Michael Niedermayer
- *
- * Support for external huffman table, various fixes (AVID workaround),
- * aspecting, new decode_frame mechanism and apple mjpeg-b support
- * by Alex Beregszaszi
- *
- * 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
- * MJPEG encoder.
- */
-
-#ifndef AVCODEC_MJPEGENC_H
-#define AVCODEC_MJPEGENC_H
-
-#include <stdint.h>
-
-#include "mpegvideo.h"
-
-typedef struct MJpegContext {
- uint8_t huff_size_dc_luminance[12]; //FIXME use array [3] instead of lumi / chrom, for easier addressing
- uint16_t huff_code_dc_luminance[12];
- uint8_t huff_size_dc_chrominance[12];
- uint16_t huff_code_dc_chrominance[12];
-
- uint8_t huff_size_ac_luminance[256];
- uint16_t huff_code_ac_luminance[256];
- uint8_t huff_size_ac_chrominance[256];
- uint16_t huff_code_ac_chrominance[256];
-} MJpegContext;
-
-int ff_mjpeg_encode_init(MpegEncContext *s);
-void ff_mjpeg_encode_close(MpegEncContext *s);
-void ff_mjpeg_encode_picture_header(MpegEncContext *s);
-void ff_mjpeg_encode_picture_trailer(MpegEncContext *s);
-void ff_mjpeg_encode_stuffing(MpegEncContext *s);
-void ff_mjpeg_encode_dc(MpegEncContext *s, int val,
- uint8_t *huff_size, uint16_t *huff_code);
-void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[6][64]);
-
-#endif /* AVCODEC_MJPEGENC_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/mlp.c b/src/thirdparty/ffmpeg/libavcodec/mlp.c
deleted file mode 100644
index 6851b78ca..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mlp.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * MLP codec common code
- * Copyright (c) 2007-2008 Ian Caulfield
- *
- * 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/crc.h"
-#include "libavutil/intreadwrite.h"
-#include "mlp.h"
-
-const uint8_t ff_mlp_huffman_tables[3][18][2] = {
- { /* Huffman table 0, -7 - +10 */
- {0x01, 9}, {0x01, 8}, {0x01, 7}, {0x01, 6}, {0x01, 5}, {0x01, 4}, {0x01, 3},
- {0x04, 3}, {0x05, 3}, {0x06, 3}, {0x07, 3},
- {0x03, 3}, {0x05, 4}, {0x09, 5}, {0x11, 6}, {0x21, 7}, {0x41, 8}, {0x81, 9},
- }, { /* Huffman table 1, -7 - +8 */
- {0x01, 9}, {0x01, 8}, {0x01, 7}, {0x01, 6}, {0x01, 5}, {0x01, 4}, {0x01, 3},
- {0x02, 2}, {0x03, 2},
- {0x03, 3}, {0x05, 4}, {0x09, 5}, {0x11, 6}, {0x21, 7}, {0x41, 8}, {0x81, 9},
- }, { /* Huffman table 2, -7 - +7 */
- {0x01, 9}, {0x01, 8}, {0x01, 7}, {0x01, 6}, {0x01, 5}, {0x01, 4}, {0x01, 3},
- {0x01, 1},
- {0x03, 3}, {0x05, 4}, {0x09, 5}, {0x11, 6}, {0x21, 7}, {0x41, 8}, {0x81, 9},
- }
-};
-
-static int crc_init = 0;
-#if CONFIG_SMALL
-#define CRC_TABLE_SIZE 257
-#else
-#define CRC_TABLE_SIZE 1024
-#endif
-static AVCRC crc_63[CRC_TABLE_SIZE];
-static AVCRC crc_1D[CRC_TABLE_SIZE];
-static AVCRC crc_2D[CRC_TABLE_SIZE];
-
-av_cold void ff_mlp_init_crc(void)
-{
- if (!crc_init) {
- av_crc_init(crc_63, 0, 8, 0x63, sizeof(crc_63));
- av_crc_init(crc_1D, 0, 8, 0x1D, sizeof(crc_1D));
- av_crc_init(crc_2D, 0, 16, 0x002D, sizeof(crc_2D));
- crc_init = 1;
- }
-}
-
-uint16_t ff_mlp_checksum16(const uint8_t *buf, unsigned int buf_size)
-{
- uint16_t crc;
-
- crc = av_crc(crc_2D, 0, buf, buf_size - 2);
- crc ^= AV_RL16(buf + buf_size - 2);
- return crc;
-}
-
-uint8_t ff_mlp_checksum8(const uint8_t *buf, unsigned int buf_size)
-{
- uint8_t checksum = av_crc(crc_63, 0x3c, buf, buf_size - 1); // crc_63[0xa2] == 0x3c
- checksum ^= buf[buf_size-1];
- return checksum;
-}
-
-uint8_t ff_mlp_restart_checksum(const uint8_t *buf, unsigned int bit_size)
-{
- int i;
- int num_bytes = (bit_size + 2) / 8;
-
- int crc = crc_1D[buf[0] & 0x3f];
- crc = av_crc(crc_1D, crc, buf + 1, num_bytes - 2);
- crc ^= buf[num_bytes - 1];
-
- for (i = 0; i < ((bit_size + 2) & 7); i++) {
- crc <<= 1;
- if (crc & 0x100)
- crc ^= 0x11D;
- crc ^= (buf[num_bytes] >> (7 - i)) & 1;
- }
-
- return crc;
-}
-
-uint8_t ff_mlp_calculate_parity(const uint8_t *buf, unsigned int buf_size)
-{
- uint32_t scratch = 0;
- const uint8_t *buf_end = buf + buf_size;
-
- for (; ((intptr_t) buf & 3) && buf < buf_end; buf++)
- scratch ^= *buf;
- for (; buf < buf_end - 3; buf += 4)
- scratch ^= *((const uint32_t*)buf);
-
- scratch = xor_32_to_8(scratch);
-
- for (; buf < buf_end; buf++)
- scratch ^= *buf;
-
- return scratch;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/mlp.h b/src/thirdparty/ffmpeg/libavcodec/mlp.h
deleted file mode 100644
index 7f9b6833d..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mlp.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * MLP codec common header file
- * Copyright (c) 2007-2008 Ian Caulfield
- *
- * 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_MLP_H
-#define AVCODEC_MLP_H
-
-#include <stdint.h>
-
-#include "avcodec.h"
-
-/** Last possible matrix channel for each codec */
-#define MAX_MATRIX_CHANNEL_MLP 5
-#define MAX_MATRIX_CHANNEL_TRUEHD 7
-/** Maximum number of channels in a valid stream.
- * MLP : 5.1 + 2 noise channels -> 8 channels
- * TrueHD: 7.1 -> 8 channels
- */
-#define MAX_CHANNELS 8
-
-/** Maximum number of matrices used in decoding; most streams have one matrix
- * per output channel, but some rematrix a channel (usually 0) more than once.
- */
-#define MAX_MATRICES_MLP 6
-#define MAX_MATRICES_TRUEHD 8
-#define MAX_MATRICES 8
-
-/** Maximum number of substreams that can be decoded.
- * MLP's limit is 2. TrueHD supports at least up to 3.
- */
-#define MAX_SUBSTREAMS 3
-
-/** which multiple of 48000 the maximum sample rate is */
-#define MAX_RATEFACTOR 4
-/** maximum sample frequency seen in files */
-#define MAX_SAMPLERATE (MAX_RATEFACTOR * 48000)
-
-/** maximum number of audio samples within one access unit */
-#define MAX_BLOCKSIZE (40 * MAX_RATEFACTOR)
-/** next power of two greater than MAX_BLOCKSIZE */
-#define MAX_BLOCKSIZE_POW2 (64 * MAX_RATEFACTOR)
-
-/** number of allowed filters */
-#define NUM_FILTERS 2
-
-/** The maximum number of taps in IIR and FIR filters. */
-#define MAX_FIR_ORDER 8
-#define MAX_IIR_ORDER 4
-
-/** Code that signals end of a stream. */
-#define END_OF_STREAM 0xd234d234
-
-#define FIR 0
-#define IIR 1
-
-/** filter data */
-typedef struct FilterParams {
- uint8_t order; ///< number of taps in filter
- uint8_t shift; ///< Right shift to apply to output of filter.
-
- int32_t state[MAX_FIR_ORDER];
-} FilterParams;
-
-/** sample data coding information */
-typedef struct ChannelParams {
- FilterParams filter_params[NUM_FILTERS];
- int32_t coeff[NUM_FILTERS][MAX_FIR_ORDER];
-
- int16_t huff_offset; ///< Offset to apply to residual values.
- int32_t sign_huff_offset; ///< sign/rounding-corrected version of huff_offset
- uint8_t codebook; ///< Which VLC codebook to use to read residuals.
- uint8_t huff_lsbs; ///< Size of residual suffix not encoded using VLC.
-} ChannelParams;
-
-/** Tables defining the Huffman codes.
- * There are three entropy coding methods used in MLP (four if you count
- * "none" as a method). These use the same sequences for codes starting with
- * 00 or 01, but have different codes starting with 1.
- */
-extern const uint8_t ff_mlp_huffman_tables[3][18][2];
-
-/** MLP uses checksums that seem to be based on the standard CRC algorithm, but
- * are not (in implementation terms, the table lookup and XOR are reversed).
- * We can implement this behavior using a standard av_crc on all but the
- * last element, then XOR that with the last element.
- */
-uint8_t ff_mlp_checksum8 (const uint8_t *buf, unsigned int buf_size);
-uint16_t ff_mlp_checksum16(const uint8_t *buf, unsigned int buf_size);
-
-/** Calculate an 8-bit checksum over a restart header -- a non-multiple-of-8
- * number of bits, starting two bits into the first byte of buf.
- */
-uint8_t ff_mlp_restart_checksum(const uint8_t *buf, unsigned int bit_size);
-
-/** XOR together all the bytes of a buffer.
- * Does this belong in dspcontext?
- */
-uint8_t ff_mlp_calculate_parity(const uint8_t *buf, unsigned int buf_size);
-
-void ff_mlp_init_crc(void);
-
-/** XOR four bytes into one. */
-static inline uint8_t xor_32_to_8(uint32_t value)
-{
- value ^= value >> 16;
- value ^= value >> 8;
- return value;
-}
-
-#endif /* AVCODEC_MLP_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/mlp_parser.c b/src/thirdparty/ffmpeg/libavcodec/mlp_parser.c
deleted file mode 100644
index c4f7135be..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mlp_parser.c
+++ /dev/null
@@ -1,398 +0,0 @@
-/*
- * MLP parser
- * Copyright (c) 2007 Ian Caulfield
- *
- * 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
- * MLP parser
- */
-
-#include <stdint.h>
-
-#include "libavutil/channel_layout.h"
-#include "libavutil/crc.h"
-#include "get_bits.h"
-#include "parser.h"
-#include "mlp_parser.h"
-#include "mlp.h"
-
-static const uint8_t mlp_quants[16] = {
- 16, 20, 24, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-
-static const uint8_t mlp_channels[32] = {
- 1, 2, 3, 4, 3, 4, 5, 3, 4, 5, 4, 5, 6, 4, 5, 4,
- 5, 6, 5, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-};
-
-const uint64_t ff_mlp_layout[32] = {
- AV_CH_LAYOUT_MONO,
- AV_CH_LAYOUT_STEREO,
- AV_CH_LAYOUT_2_1,
- AV_CH_LAYOUT_QUAD,
- AV_CH_LAYOUT_STEREO|AV_CH_LOW_FREQUENCY,
- AV_CH_LAYOUT_2_1|AV_CH_LOW_FREQUENCY,
- AV_CH_LAYOUT_QUAD|AV_CH_LOW_FREQUENCY,
- AV_CH_LAYOUT_SURROUND,
- AV_CH_LAYOUT_4POINT0,
- AV_CH_LAYOUT_5POINT0_BACK,
- AV_CH_LAYOUT_SURROUND|AV_CH_LOW_FREQUENCY,
- AV_CH_LAYOUT_4POINT0|AV_CH_LOW_FREQUENCY,
- AV_CH_LAYOUT_5POINT1_BACK,
- AV_CH_LAYOUT_4POINT0,
- AV_CH_LAYOUT_5POINT0_BACK,
- AV_CH_LAYOUT_SURROUND|AV_CH_LOW_FREQUENCY,
- AV_CH_LAYOUT_4POINT0|AV_CH_LOW_FREQUENCY,
- AV_CH_LAYOUT_5POINT1_BACK,
- AV_CH_LAYOUT_QUAD|AV_CH_LOW_FREQUENCY,
- AV_CH_LAYOUT_5POINT0_BACK,
- AV_CH_LAYOUT_5POINT1_BACK,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-static const uint8_t thd_chancount[13] = {
-// LR C LFE LRs LRvh LRc LRrs Cs Ts LRsd LRw Cvh LFE2
- 2, 1, 1, 2, 2, 2, 2, 1, 1, 2, 2, 1, 1
-};
-
-static const uint64_t thd_layout[13] = {
- AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT, // LR
- AV_CH_FRONT_CENTER, // C
- AV_CH_LOW_FREQUENCY, // LFE
- AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, // LRs
- AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT, // LRvh
- AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER, // LRc
- AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT, // LRrs
- AV_CH_BACK_CENTER, // Cs
- AV_CH_TOP_CENTER, // Ts
- AV_CH_SURROUND_DIRECT_LEFT|AV_CH_SURROUND_DIRECT_RIGHT, // LRsd
- AV_CH_WIDE_LEFT|AV_CH_WIDE_RIGHT, // LRw
- AV_CH_TOP_FRONT_CENTER, // Cvh
- AV_CH_LOW_FREQUENCY_2, // LFE2
-};
-
-static int mlp_samplerate(int in)
-{
- if (in == 0xF)
- return 0;
-
- return (in & 8 ? 44100 : 48000) << (in & 7) ;
-}
-
-static int truehd_channels(int chanmap)
-{
- int channels = 0, i;
-
- for (i = 0; i < 13; i++)
- channels += thd_chancount[i] * ((chanmap >> i) & 1);
-
- return channels;
-}
-
-uint64_t ff_truehd_layout(int chanmap)
-{
- int i;
- uint64_t layout = 0;
-
- for (i = 0; i < 13; i++)
- layout |= thd_layout[i] * ((chanmap >> i) & 1);
-
- return layout;
-}
-
-/** Read a major sync info header - contains high level information about
- * the stream - sample rate, channel arrangement etc. Most of this
- * information is not actually necessary for decoding, only for playback.
- * gb must be a freshly initialized GetBitContext with no bits read.
- */
-
-int ff_mlp_read_major_sync(void *log, MLPHeaderInfo *mh, GetBitContext *gb)
-{
- int ratebits, channel_arrangement;
- uint16_t checksum;
-
- av_assert1(get_bits_count(gb) == 0);
-
- if (gb->size_in_bits < 28 << 3) {
- av_log(log, AV_LOG_ERROR, "packet too short, unable to read major sync\n");
- return -1;
- }
-
- checksum = ff_mlp_checksum16(gb->buffer, 26);
- if (checksum != AV_RL16(gb->buffer+26)) {
- av_log(log, AV_LOG_ERROR, "major sync info header checksum error\n");
- return AVERROR_INVALIDDATA;
- }
-
- if (get_bits_long(gb, 24) != 0xf8726f) /* Sync words */
- return AVERROR_INVALIDDATA;
-
- mh->stream_type = get_bits(gb, 8);
-
- if (mh->stream_type == 0xbb) {
- mh->group1_bits = mlp_quants[get_bits(gb, 4)];
- mh->group2_bits = mlp_quants[get_bits(gb, 4)];
-
- ratebits = get_bits(gb, 4);
- mh->group1_samplerate = mlp_samplerate(ratebits);
- mh->group2_samplerate = mlp_samplerate(get_bits(gb, 4));
-
- skip_bits(gb, 11);
-
- mh->channel_arrangement=
- channel_arrangement = get_bits(gb, 5);
- mh->channels_mlp = mlp_channels[channel_arrangement];
- mh->channel_layout_mlp = ff_mlp_layout[channel_arrangement];
- } else if (mh->stream_type == 0xba) {
- mh->group1_bits = 24; // TODO: Is this information actually conveyed anywhere?
- mh->group2_bits = 0;
-
- ratebits = get_bits(gb, 4);
- mh->group1_samplerate = mlp_samplerate(ratebits);
- mh->group2_samplerate = 0;
-
- skip_bits(gb, 8);
-
- 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);
-
- channel_arrangement = get_bits(gb, 13);
- mh->channels_thd_stream2 = truehd_channels(channel_arrangement);
- mh->channel_layout_thd_stream2 = ff_truehd_layout(channel_arrangement);
- } else
- return AVERROR_INVALIDDATA;
-
- mh->access_unit_size = 40 << (ratebits & 7);
- mh->access_unit_size_pow2 = 64 << (ratebits & 7);
-
- skip_bits_long(gb, 48);
-
- mh->is_vbr = get_bits1(gb);
-
- mh->peak_bitrate = (get_bits(gb, 15) * mh->group1_samplerate + 8) >> 4;
-
- mh->num_substreams = get_bits(gb, 4);
-
- skip_bits_long(gb, 4 + 11 * 8);
-
- return 0;
-}
-
-typedef struct MLPParseContext
-{
- ParseContext pc;
-
- int bytes_left;
-
- int in_sync;
-
- int num_substreams;
-} MLPParseContext;
-
-static av_cold int mlp_init(AVCodecParserContext *s)
-{
- ff_mlp_init_crc();
- return 0;
-}
-
-static int mlp_parse(AVCodecParserContext *s,
- AVCodecContext *avctx,
- const uint8_t **poutbuf, int *poutbuf_size,
- const uint8_t *buf, int buf_size)
-{
- MLPParseContext *mp = s->priv_data;
- int sync_present;
- uint8_t parity_bits;
- int next;
- int i, p = 0;
-
- *poutbuf_size = 0;
- if (buf_size == 0)
- return 0;
-
- if (!mp->in_sync) {
- // Not in sync - find a major sync header
-
- for (i = 0; i < buf_size; i++) {
- mp->pc.state = (mp->pc.state << 8) | buf[i];
- if ((mp->pc.state & 0xfffffffe) == 0xf8726fba &&
- // ignore if we do not have the data for the start of header
- mp->pc.index + i >= 7) {
- mp->in_sync = 1;
- mp->bytes_left = 0;
- break;
- }
- }
-
- if (!mp->in_sync) {
- if (ff_combine_frame(&mp->pc, END_NOT_FOUND, &buf, &buf_size) != -1)
- av_log(avctx, AV_LOG_WARNING, "ff_combine_frame failed\n");
- return buf_size;
- }
-
- ff_combine_frame(&mp->pc, i - 7, &buf, &buf_size);
-
- return i - 7;
- }
-
- if (mp->bytes_left == 0) {
- // Find length of this packet
-
- /* Copy overread bytes from last frame into buffer. */
- for(; mp->pc.overread>0; mp->pc.overread--) {
- mp->pc.buffer[mp->pc.index++]= mp->pc.buffer[mp->pc.overread_index++];
- }
-
- if (mp->pc.index + buf_size < 2) {
- if (ff_combine_frame(&mp->pc, END_NOT_FOUND, &buf, &buf_size) != -1)
- av_log(avctx, AV_LOG_WARNING, "ff_combine_frame failed\n");
- return buf_size;
- }
-
- mp->bytes_left = ((mp->pc.index > 0 ? mp->pc.buffer[0] : buf[0]) << 8)
- | (mp->pc.index > 1 ? mp->pc.buffer[1] : buf[1-mp->pc.index]);
- mp->bytes_left = (mp->bytes_left & 0xfff) * 2;
- if (mp->bytes_left <= 0) { // prevent infinite loop
- goto lost_sync;
- }
- mp->bytes_left -= mp->pc.index;
- }
-
- next = (mp->bytes_left > buf_size) ? END_NOT_FOUND : mp->bytes_left;
-
- if (ff_combine_frame(&mp->pc, next, &buf, &buf_size) < 0) {
- mp->bytes_left -= buf_size;
- return buf_size;
- }
-
- mp->bytes_left = 0;
-
- sync_present = (AV_RB32(buf + 4) & 0xfffffffe) == 0xf8726fba;
-
- if (!sync_present) {
- /* The first nibble of a frame is a parity check of the 4-byte
- * access unit header and all the 2- or 4-byte substream headers. */
- // Only check when this isn't a sync frame - syncs have a checksum.
-
- parity_bits = 0;
- for (i = -1; i < mp->num_substreams; i++) {
- parity_bits ^= buf[p++];
- parity_bits ^= buf[p++];
-
- if (i < 0 || buf[p-2] & 0x80) {
- parity_bits ^= buf[p++];
- parity_bits ^= buf[p++];
- }
- }
-
- if ((((parity_bits >> 4) ^ parity_bits) & 0xF) != 0xF) {
- av_log(avctx, AV_LOG_INFO, "mlpparse: Parity check failed.\n");
- goto lost_sync;
- }
- } else {
- GetBitContext gb;
- MLPHeaderInfo mh;
-
- init_get_bits(&gb, buf + 4, (buf_size - 4) << 3);
- if (ff_mlp_read_major_sync(avctx, &mh, &gb) < 0)
- goto lost_sync;
-
- avctx->bits_per_raw_sample = mh.group1_bits;
- if (avctx->bits_per_raw_sample > 16)
- avctx->sample_fmt = AV_SAMPLE_FMT_S32;
- else
- avctx->sample_fmt = AV_SAMPLE_FMT_S16;
- avctx->sample_rate = mh.group1_samplerate;
- s->duration = mh.access_unit_size;
-
- if(!avctx->channels || !avctx->channel_layout) {
- if (mh.stream_type == 0xbb) {
- /* MLP stream */
-#if FF_API_REQUEST_CHANNELS
- if (avctx->request_channels > 0 && avctx->request_channels <= 2 &&
- mh.num_substreams > 1) {
- avctx->channels = 2;
- avctx->channel_layout = AV_CH_LAYOUT_STEREO;
- } else
-#endif
- if (avctx->request_channel_layout == AV_CH_LAYOUT_STEREO &&
- mh.num_substreams > 1) {
- avctx->channels = 2;
- avctx->channel_layout = AV_CH_LAYOUT_STEREO;
- } else {
- avctx->channels = mh.channels_mlp;
- avctx->channel_layout = mh.channel_layout_mlp;
- }
- } else { /* mh.stream_type == 0xba */
- /* TrueHD stream */
-#if FF_API_REQUEST_CHANNELS
- if (avctx->request_channels > 0 && avctx->request_channels <= 2 &&
- mh.num_substreams > 1) {
- avctx->channels = 2;
- avctx->channel_layout = AV_CH_LAYOUT_STEREO;
- } else if (avctx->request_channels > 0 &&
- avctx->request_channels <= mh.channels_thd_stream1) {
- avctx->channels = mh.channels_thd_stream1;
- avctx->channel_layout = mh.channel_layout_thd_stream1;
- } else
-#endif
- if (avctx->request_channel_layout == AV_CH_LAYOUT_STEREO &&
- 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) {
- avctx->channels = mh.channels_thd_stream1;
- avctx->channel_layout = mh.channel_layout_thd_stream1;
- } else {
- avctx->channels = mh.channels_thd_stream2;
- avctx->channel_layout = mh.channel_layout_thd_stream2;
- }
- }
- }
-
- if (!mh.is_vbr) /* Stream is CBR */
- avctx->bit_rate = mh.peak_bitrate;
-
- mp->num_substreams = mh.num_substreams;
- }
-
- *poutbuf = buf;
- *poutbuf_size = buf_size;
-
- return next;
-
-lost_sync:
- mp->in_sync = 0;
- return 1;
-}
-
-AVCodecParser ff_mlp_parser = {
- .codec_ids = { AV_CODEC_ID_MLP, AV_CODEC_ID_TRUEHD },
- .priv_data_size = sizeof(MLPParseContext),
- .parser_init = mlp_init,
- .parser_parse = mlp_parse,
- .parser_close = ff_parse_close,
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/mlp_parser.h b/src/thirdparty/ffmpeg/libavcodec/mlp_parser.h
deleted file mode 100644
index 4cff2dbef..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mlp_parser.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * MLP parser prototypes
- * Copyright (c) 2007 Ian Caulfield
- *
- * 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
- * MLP parser prototypes
- */
-
-#ifndef AVCODEC_MLP_PARSER_H
-#define AVCODEC_MLP_PARSER_H
-
-#include "get_bits.h"
-
-typedef struct MLPHeaderInfo
-{
- int stream_type; ///< 0xBB for MLP, 0xBA for TrueHD
-
- int group1_bits; ///< The bit depth of the first substream
- int group2_bits; ///< Bit depth of the second substream (MLP only)
-
- int group1_samplerate; ///< Sample rate of first substream
- int group2_samplerate; ///< Sample rate of second substream (MLP only)
-
- int channel_arrangement;
- 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")
- uint64_t channel_layout_mlp; ///< Channel layout for MLP streams
- uint64_t channel_layout_thd_stream1; ///< Channel layout for substream 1 of TrueHD streams ("6-channel presentation")
- uint64_t channel_layout_thd_stream2; ///< Channel layout for substream 2 of TrueHD streams ("8-channel presentation")
-
- int access_unit_size; ///< Number of samples per coded frame
- int access_unit_size_pow2; ///< Next power of two above number of samples per frame
-
- int is_vbr; ///< Stream is VBR instead of CBR
- int peak_bitrate; ///< Peak bitrate for VBR, actual bitrate (==peak) for CBR
-
- int num_substreams; ///< Number of substreams within stream
-} MLPHeaderInfo;
-
-
-int ff_mlp_read_major_sync(void *log, MLPHeaderInfo *mh, GetBitContext *gb);
-uint64_t ff_truehd_layout(int chanmap);
-
-extern const uint64_t ff_mlp_layout[32];
-
-#endif /* AVCODEC_MLP_PARSER_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/mlpdec.c b/src/thirdparty/ffmpeg/libavcodec/mlpdec.c
deleted file mode 100644
index b2ef6061f..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mlpdec.c
+++ /dev/null
@@ -1,1267 +0,0 @@
-/*
- * MLP decoder
- * Copyright (c) 2007-2008 Ian Caulfield
- *
- * 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
- * MLP decoder
- */
-
-#include <stdint.h>
-
-#include "avcodec.h"
-#include "libavutil/intreadwrite.h"
-#include "libavutil/channel_layout.h"
-#include "get_bits.h"
-#include "internal.h"
-#include "libavutil/crc.h"
-#include "parser.h"
-#include "mlp_parser.h"
-#include "mlpdsp.h"
-#include "mlp.h"
-
-/** number of bits used for VLC lookup - longest Huffman code is 9 */
-#define VLC_BITS 9
-
-typedef struct SubStream {
- /// Set if a valid restart header has been read. Otherwise the substream cannot be decoded.
- uint8_t restart_seen;
-
- //@{
- /** restart header data */
- /// The type of noise to be used in the rematrix stage.
- uint16_t noise_type;
-
- /// The index of the first channel coded in this substream.
- uint8_t min_channel;
- /// The index of the last channel coded in this substream.
- uint8_t max_channel;
- /// The number of channels input into the rematrix stage.
- uint8_t max_matrix_channel;
- /// For each channel output by the matrix, the output channel to map it to
- uint8_t ch_assign[MAX_CHANNELS];
- /// The channel layout for this substream
- uint64_t ch_layout;
-
- /// Channel coding parameters for channels in the substream
- ChannelParams channel_params[MAX_CHANNELS];
-
- /// The left shift applied to random noise in 0x31ea substreams.
- uint8_t noise_shift;
- /// The current seed value for the pseudorandom noise generator(s).
- uint32_t noisegen_seed;
-
- /// Set if the substream contains extra info to check the size of VLC blocks.
- uint8_t data_check_present;
-
- /// Bitmask of which parameter sets are conveyed in a decoding parameter block.
- uint8_t param_presence_flags;
-#define PARAM_BLOCKSIZE (1 << 7)
-#define PARAM_MATRIX (1 << 6)
-#define PARAM_OUTSHIFT (1 << 5)
-#define PARAM_QUANTSTEP (1 << 4)
-#define PARAM_FIR (1 << 3)
-#define PARAM_IIR (1 << 2)
-#define PARAM_HUFFOFFSET (1 << 1)
-#define PARAM_PRESENCE (1 << 0)
- //@}
-
- //@{
- /** matrix data */
-
- /// Number of matrices to be applied.
- uint8_t num_primitive_matrices;
-
- /// matrix output channel
- uint8_t matrix_out_ch[MAX_MATRICES];
-
- /// Whether the LSBs of the matrix output are encoded in the bitstream.
- uint8_t lsb_bypass[MAX_MATRICES];
- /// Matrix coefficients, stored as 2.14 fixed point.
- int32_t matrix_coeff[MAX_MATRICES][MAX_CHANNELS];
- /// Left shift to apply to noise values in 0x31eb substreams.
- uint8_t matrix_noise_shift[MAX_MATRICES];
- //@}
-
- /// Left shift to apply to Huffman-decoded residuals.
- uint8_t quant_step_size[MAX_CHANNELS];
-
- /// number of PCM samples in current audio block
- uint16_t blocksize;
- /// Number of PCM samples decoded so far in this frame.
- uint16_t blockpos;
-
- /// Left shift to apply to decoded PCM values to get final 24-bit output.
- int8_t output_shift[MAX_CHANNELS];
-
- /// Running XOR of all output samples.
- int32_t lossless_check_data;
-
-} SubStream;
-
-typedef struct MLPDecodeContext {
- AVCodecContext *avctx;
-
- /// Current access unit being read has a major sync.
- int is_major_sync_unit;
-
- /// Set if a valid major sync block has been read. Otherwise no decoding is possible.
- uint8_t params_valid;
-
- /// Number of substreams contained within this stream.
- uint8_t num_substreams;
-
- /// Index of the last substream to decode - further substreams are skipped.
- uint8_t max_decoded_substream;
-
- /// Stream needs channel reordering to comply with FFmpeg's channel order
- uint8_t needs_reordering;
-
- /// number of PCM samples contained in each frame
- int access_unit_size;
- /// next power of two above the number of samples in each frame
- int access_unit_size_pow2;
-
- SubStream substream[MAX_SUBSTREAMS];
-
- int matrix_changed;
- int filter_changed[MAX_CHANNELS][NUM_FILTERS];
-
- int8_t noise_buffer[MAX_BLOCKSIZE_POW2];
- int8_t bypassed_lsbs[MAX_BLOCKSIZE][MAX_CHANNELS];
- int32_t sample_buffer[MAX_BLOCKSIZE][MAX_CHANNELS];
-
- MLPDSPContext dsp;
-} MLPDecodeContext;
-
-static const uint64_t thd_channel_order[] = {
- AV_CH_FRONT_LEFT, AV_CH_FRONT_RIGHT, // LR
- AV_CH_FRONT_CENTER, // C
- AV_CH_LOW_FREQUENCY, // LFE
- AV_CH_SIDE_LEFT, AV_CH_SIDE_RIGHT, // LRs
- AV_CH_TOP_FRONT_LEFT, AV_CH_TOP_FRONT_RIGHT, // LRvh
- AV_CH_FRONT_LEFT_OF_CENTER, AV_CH_FRONT_RIGHT_OF_CENTER, // LRc
- AV_CH_BACK_LEFT, AV_CH_BACK_RIGHT, // LRrs
- AV_CH_BACK_CENTER, // Cs
- AV_CH_TOP_CENTER, // Ts
- AV_CH_SURROUND_DIRECT_LEFT, AV_CH_SURROUND_DIRECT_RIGHT, // LRsd
- AV_CH_WIDE_LEFT, AV_CH_WIDE_RIGHT, // LRw
- AV_CH_TOP_FRONT_CENTER, // Cvh
- AV_CH_LOW_FREQUENCY_2, // LFE2
-};
-
-static uint64_t thd_channel_layout_extract_channel(uint64_t channel_layout,
- int index)
-{
- int i;
-
- if (av_get_channel_layout_nb_channels(channel_layout) <= index)
- return 0;
-
- for (i = 0; i < FF_ARRAY_ELEMS(thd_channel_order); i++)
- if (channel_layout & thd_channel_order[i] && !index--)
- return thd_channel_order[i];
- return 0;
-}
-
-static VLC huff_vlc[3];
-
-/** Initialize static data, constant between all invocations of the codec. */
-
-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);
- 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);
- 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_init_crc();
-}
-
-static inline int32_t calculate_sign_huff(MLPDecodeContext *m,
- unsigned int substr, unsigned int ch)
-{
- SubStream *s = &m->substream[substr];
- ChannelParams *cp = &s->channel_params[ch];
- int lsb_bits = cp->huff_lsbs - s->quant_step_size[ch];
- int sign_shift = lsb_bits + (cp->codebook ? 2 - cp->codebook : -1);
- int32_t sign_huff_offset = cp->huff_offset;
-
- if (cp->codebook > 0)
- sign_huff_offset -= 7 << lsb_bits;
-
- if (sign_shift >= 0)
- sign_huff_offset -= 1 << sign_shift;
-
- return sign_huff_offset;
-}
-
-/** Read a sample, consisting of either, both or neither of entropy-coded MSBs
- * and plain LSBs. */
-
-static inline int read_huff_channels(MLPDecodeContext *m, GetBitContext *gbp,
- unsigned int substr, unsigned int pos)
-{
- SubStream *s = &m->substream[substr];
- unsigned int mat, channel;
-
- for (mat = 0; mat < s->num_primitive_matrices; mat++)
- if (s->lsb_bypass[mat])
- m->bypassed_lsbs[pos + s->blockpos][mat] = get_bits1(gbp);
-
- for (channel = s->min_channel; channel <= s->max_channel; channel++) {
- ChannelParams *cp = &s->channel_params[channel];
- int codebook = cp->codebook;
- int quant_step_size = s->quant_step_size[channel];
- int lsb_bits = cp->huff_lsbs - quant_step_size;
- int result = 0;
-
- if (codebook > 0)
- result = get_vlc2(gbp, huff_vlc[codebook-1].table,
- VLC_BITS, (9 + VLC_BITS - 1) / VLC_BITS);
-
- if (result < 0)
- return AVERROR_INVALIDDATA;
-
- if (lsb_bits > 0)
- result = (result << lsb_bits) + get_bits(gbp, lsb_bits);
-
- result += cp->sign_huff_offset;
- result <<= quant_step_size;
-
- m->sample_buffer[pos + s->blockpos][channel] = result;
- }
-
- return 0;
-}
-
-static av_cold int mlp_decode_init(AVCodecContext *avctx)
-{
- MLPDecodeContext *m = avctx->priv_data;
- int substr;
-
- init_static();
- m->avctx = avctx;
- for (substr = 0; substr < MAX_SUBSTREAMS; substr++)
- m->substream[substr].lossless_check_data = 0xffffffff;
- ff_mlpdsp_init(&m->dsp);
-
- return 0;
-}
-
-/** Read a major sync info header - contains high level information about
- * the stream - sample rate, channel arrangement etc. Most of this
- * information is not actually necessary for decoding, only for playback.
- */
-
-static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb)
-{
- MLPHeaderInfo mh;
- int substr, ret;
-
- if ((ret = ff_mlp_read_major_sync(m->avctx, &mh, gb)) != 0)
- return ret;
-
- if (mh.group1_bits == 0) {
- av_log(m->avctx, AV_LOG_ERROR, "invalid/unknown bits per sample\n");
- return AVERROR_INVALIDDATA;
- }
- if (mh.group2_bits > mh.group1_bits) {
- av_log(m->avctx, AV_LOG_ERROR,
- "Channel group 2 cannot have more bits per sample than group 1.\n");
- return AVERROR_INVALIDDATA;
- }
-
- if (mh.group2_samplerate && mh.group2_samplerate != mh.group1_samplerate) {
- av_log(m->avctx, AV_LOG_ERROR,
- "Channel groups with differing sample rates are not currently supported.\n");
- return AVERROR_INVALIDDATA;
- }
-
- if (mh.group1_samplerate == 0) {
- av_log(m->avctx, AV_LOG_ERROR, "invalid/unknown sampling rate\n");
- return AVERROR_INVALIDDATA;
- }
- if (mh.group1_samplerate > MAX_SAMPLERATE) {
- av_log(m->avctx, AV_LOG_ERROR,
- "Sampling rate %d is greater than the supported maximum (%d).\n",
- mh.group1_samplerate, MAX_SAMPLERATE);
- return AVERROR_INVALIDDATA;
- }
- if (mh.access_unit_size > MAX_BLOCKSIZE) {
- av_log(m->avctx, AV_LOG_ERROR,
- "Block size %d is greater than the supported maximum (%d).\n",
- mh.access_unit_size, MAX_BLOCKSIZE);
- return AVERROR_INVALIDDATA;
- }
- if (mh.access_unit_size_pow2 > MAX_BLOCKSIZE_POW2) {
- av_log(m->avctx, AV_LOG_ERROR,
- "Block size pow2 %d is greater than the supported maximum (%d).\n",
- mh.access_unit_size_pow2, MAX_BLOCKSIZE_POW2);
- return AVERROR_INVALIDDATA;
- }
-
- if (mh.num_substreams == 0)
- return AVERROR_INVALIDDATA;
- if (m->avctx->codec_id == AV_CODEC_ID_MLP && mh.num_substreams > 2) {
- av_log(m->avctx, AV_LOG_ERROR, "MLP only supports up to 2 substreams.\n");
- return AVERROR_INVALIDDATA;
- }
- if (mh.num_substreams > MAX_SUBSTREAMS) {
- av_log_ask_for_sample(m->avctx,
- "Number of substreams %d is larger than the maximum supported "
- "by the decoder.\n", mh.num_substreams);
- return AVERROR_PATCHWELCOME;
- }
-
- m->access_unit_size = mh.access_unit_size;
- m->access_unit_size_pow2 = mh.access_unit_size_pow2;
-
- m->num_substreams = mh.num_substreams;
- m->max_decoded_substream = m->num_substreams - 1;
-
- m->avctx->sample_rate = mh.group1_samplerate;
- m->avctx->frame_size = mh.access_unit_size;
-
- m->avctx->bits_per_raw_sample = mh.group1_bits;
- if (mh.group1_bits > 16)
- m->avctx->sample_fmt = AV_SAMPLE_FMT_S32;
- else
- m->avctx->sample_fmt = AV_SAMPLE_FMT_S16;
-
- m->params_valid = 1;
- for (substr = 0; substr < MAX_SUBSTREAMS; substr++)
- m->substream[substr].restart_seen = 0;
-
- /* Set the layout for each substream. When there's more than one, the first
- * substream is Stereo. Subsequent substreams' layouts are indicated in the
- * major sync. */
- if (m->avctx->codec_id == AV_CODEC_ID_MLP) {
- 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 ((substr = (mh.num_substreams > 1)))
- m->substream[0].ch_layout = AV_CH_LAYOUT_STEREO;
- if (mh.num_substreams > 2)
- if (mh.channel_layout_thd_stream2)
- m->substream[2].ch_layout = mh.channel_layout_thd_stream2;
- else
- m->substream[2].ch_layout = mh.channel_layout_thd_stream1;
- m->substream[substr].ch_layout = mh.channel_layout_thd_stream1;
-
- if (m->avctx->channels<=2 && m->substream[substr].ch_layout == AV_CH_LAYOUT_MONO && m->max_decoded_substream == 1) {
- av_log(m->avctx, AV_LOG_DEBUG, "Mono stream with 2 substreams, ignoring 2nd\n");
- m->max_decoded_substream = 0;
- if (m->avctx->channels==2)
- m->avctx->channel_layout = AV_CH_LAYOUT_STEREO;
- }
- }
-
- m->needs_reordering = mh.channel_arrangement >= 18 && mh.channel_arrangement <= 20;
-
- return 0;
-}
-
-/** Read a restart header from a block in a substream. This contains parameters
- * required to decode the audio that do not change very often. Generally
- * (always) present only in blocks following a major sync. */
-
-static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp,
- const uint8_t *buf, unsigned int substr)
-{
- SubStream *s = &m->substream[substr];
- unsigned int ch;
- int sync_word, tmp;
- uint8_t checksum;
- uint8_t lossless_check;
- int start_count = get_bits_count(gbp);
- const int max_matrix_channel = m->avctx->codec_id == AV_CODEC_ID_MLP
- ? MAX_MATRIX_CHANNEL_MLP
- : MAX_MATRIX_CHANNEL_TRUEHD;
- int max_channel, min_channel, matrix_channel;
-
- sync_word = get_bits(gbp, 13);
-
- if (sync_word != 0x31ea >> 1) {
- av_log(m->avctx, AV_LOG_ERROR,
- "restart header sync incorrect (got 0x%04x)\n", sync_word);
- return AVERROR_INVALIDDATA;
- }
-
- s->noise_type = get_bits1(gbp);
-
- if (m->avctx->codec_id == AV_CODEC_ID_MLP && s->noise_type) {
- av_log(m->avctx, AV_LOG_ERROR, "MLP must have 0x31ea sync word.\n");
- return AVERROR_INVALIDDATA;
- }
-
- skip_bits(gbp, 16); /* Output timestamp */
-
- min_channel = get_bits(gbp, 4);
- max_channel = get_bits(gbp, 4);
- matrix_channel = get_bits(gbp, 4);
-
- if (matrix_channel > max_matrix_channel) {
- av_log(m->avctx, AV_LOG_ERROR,
- "Max matrix channel cannot be greater than %d.\n",
- max_matrix_channel);
- return AVERROR_INVALIDDATA;
- }
-
- if (max_channel != matrix_channel) {
- av_log(m->avctx, AV_LOG_ERROR,
- "Max channel must be equal max matrix channel.\n");
- return AVERROR_INVALIDDATA;
- }
-
- /* This should happen for TrueHD streams with >6 channels and MLP's noise
- * type. It is not yet known if this is allowed. */
- if (max_channel > MAX_MATRIX_CHANNEL_MLP && !s->noise_type) {
- av_log_ask_for_sample(m->avctx,
- "Number of channels %d is larger than the maximum supported "
- "by the decoder.\n", max_channel + 2);
- return AVERROR_PATCHWELCOME;
- }
-
- if (min_channel > max_channel) {
- av_log(m->avctx, AV_LOG_ERROR,
- "Substream min channel cannot be greater than max channel.\n");
- return AVERROR_INVALIDDATA;
- }
-
- s->min_channel = min_channel;
- s->max_channel = max_channel;
- s->max_matrix_channel = matrix_channel;
-
-#if FF_API_REQUEST_CHANNELS
- if (m->avctx->request_channels > 0 &&
- m->avctx->request_channels <= s->max_channel + 1 &&
- m->max_decoded_substream > substr) {
- av_log(m->avctx, AV_LOG_DEBUG,
- "Extracting %d-channel downmix from substream %d. "
- "Further substreams will be skipped.\n",
- s->max_channel + 1, substr);
- m->max_decoded_substream = substr;
- } else
-#endif
- if (m->avctx->request_channel_layout == s->ch_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",
- s->max_channel + 1, s->ch_layout, substr);
- m->max_decoded_substream = substr;
- }
-
- s->noise_shift = get_bits(gbp, 4);
- s->noisegen_seed = get_bits(gbp, 23);
-
- skip_bits(gbp, 19);
-
- s->data_check_present = get_bits1(gbp);
- lossless_check = get_bits(gbp, 8);
- if (substr == m->max_decoded_substream
- && s->lossless_check_data != 0xffffffff) {
- tmp = xor_32_to_8(s->lossless_check_data);
- if (tmp != lossless_check)
- av_log(m->avctx, AV_LOG_WARNING,
- "Lossless check failed - expected %02x, calculated %02x.\n",
- lossless_check, tmp);
- }
-
- skip_bits(gbp, 16);
-
- memset(s->ch_assign, 0, sizeof(s->ch_assign));
-
- for (ch = 0; ch <= s->max_matrix_channel; ch++) {
- int ch_assign = get_bits(gbp, 6);
- if (m->avctx->codec_id == AV_CODEC_ID_TRUEHD) {
- uint64_t channel = thd_channel_layout_extract_channel(s->ch_layout,
- ch_assign);
- ch_assign = av_get_channel_layout_channel_index(s->ch_layout,
- channel);
- }
- if ((unsigned)ch_assign > s->max_matrix_channel) {
- av_log_ask_for_sample(m->avctx,
- "Assignment of matrix channel %d to invalid output channel %d.\n",
- ch, ch_assign);
- return AVERROR_PATCHWELCOME;
- }
- s->ch_assign[ch_assign] = ch;
- }
-
- checksum = ff_mlp_restart_checksum(buf, get_bits_count(gbp) - start_count);
-
- if (checksum != get_bits(gbp, 8))
- av_log(m->avctx, AV_LOG_ERROR, "restart header checksum error\n");
-
- /* Set default decoding parameters. */
- s->param_presence_flags = 0xff;
- s->num_primitive_matrices = 0;
- s->blocksize = 8;
- s->lossless_check_data = 0;
-
- memset(s->output_shift , 0, sizeof(s->output_shift ));
- memset(s->quant_step_size, 0, sizeof(s->quant_step_size));
-
- for (ch = s->min_channel; ch <= s->max_channel; ch++) {
- ChannelParams *cp = &s->channel_params[ch];
- cp->filter_params[FIR].order = 0;
- cp->filter_params[IIR].order = 0;
- cp->filter_params[FIR].shift = 0;
- cp->filter_params[IIR].shift = 0;
-
- /* Default audio coding is 24-bit raw PCM. */
- cp->huff_offset = 0;
- cp->sign_huff_offset = (-1) << 23;
- cp->codebook = 0;
- cp->huff_lsbs = 24;
- }
-
- if (substr == m->max_decoded_substream) {
- m->avctx->channels = s->max_matrix_channel + 1;
- m->avctx->channel_layout = s->ch_layout;
-
- 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) ||
- m->avctx->channel_layout == AV_CH_LAYOUT_5POINT0_BACK) {
- int i = s->ch_assign[4];
- s->ch_assign[4] = s->ch_assign[3];
- s->ch_assign[3] = s->ch_assign[2];
- s->ch_assign[2] = i;
- } else if (m->avctx->channel_layout == AV_CH_LAYOUT_5POINT1_BACK) {
- FFSWAP(int, s->ch_assign[2], s->ch_assign[4]);
- FFSWAP(int, s->ch_assign[3], s->ch_assign[5]);
- }
- }
-
- }
-
- return 0;
-}
-
-/** Read parameters for one of the prediction filters. */
-
-static int read_filter_params(MLPDecodeContext *m, GetBitContext *gbp,
- unsigned int substr, unsigned int channel,
- unsigned int filter)
-{
- SubStream *s = &m->substream[substr];
- FilterParams *fp = &s->channel_params[channel].filter_params[filter];
- const int max_order = filter ? MAX_IIR_ORDER : MAX_FIR_ORDER;
- const char fchar = filter ? 'I' : 'F';
- int i, order;
-
- // Filter is 0 for FIR, 1 for IIR.
- av_assert0(filter < 2);
-
- if (m->filter_changed[channel][filter]++ > 1) {
- av_log(m->avctx, AV_LOG_ERROR, "Filters may change only once per access unit.\n");
- return AVERROR_INVALIDDATA;
- }
-
- order = get_bits(gbp, 4);
- if (order > max_order) {
- av_log(m->avctx, AV_LOG_ERROR,
- "%cIR filter order %d is greater than maximum %d.\n",
- fchar, order, max_order);
- return AVERROR_INVALIDDATA;
- }
- fp->order = order;
-
- if (order > 0) {
- int32_t *fcoeff = s->channel_params[channel].coeff[filter];
- int coeff_bits, coeff_shift;
-
- fp->shift = get_bits(gbp, 4);
-
- coeff_bits = get_bits(gbp, 5);
- coeff_shift = get_bits(gbp, 3);
- if (coeff_bits < 1 || coeff_bits > 16) {
- av_log(m->avctx, AV_LOG_ERROR,
- "%cIR filter coeff_bits must be between 1 and 16.\n",
- fchar);
- return AVERROR_INVALIDDATA;
- }
- if (coeff_bits + coeff_shift > 16) {
- av_log(m->avctx, AV_LOG_ERROR,
- "Sum of coeff_bits and coeff_shift for %cIR filter must be 16 or less.\n",
- fchar);
- return AVERROR_INVALIDDATA;
- }
-
- for (i = 0; i < order; i++)
- fcoeff[i] = get_sbits(gbp, coeff_bits) << coeff_shift;
-
- if (get_bits1(gbp)) {
- int state_bits, state_shift;
-
- if (filter == FIR) {
- av_log(m->avctx, AV_LOG_ERROR,
- "FIR filter has state data specified.\n");
- return AVERROR_INVALIDDATA;
- }
-
- state_bits = get_bits(gbp, 4);
- state_shift = get_bits(gbp, 4);
-
- /* TODO: Check validity of state data. */
-
- for (i = 0; i < order; i++)
- fp->state[i] = get_sbits(gbp, state_bits) << state_shift;
- }
- }
-
- return 0;
-}
-
-/** Read parameters for primitive matrices. */
-
-static int read_matrix_params(MLPDecodeContext *m, unsigned int substr, GetBitContext *gbp)
-{
- SubStream *s = &m->substream[substr];
- unsigned int mat, ch;
- const int max_primitive_matrices = m->avctx->codec_id == AV_CODEC_ID_MLP
- ? MAX_MATRICES_MLP
- : MAX_MATRICES_TRUEHD;
-
- if (m->matrix_changed++ > 1) {
- av_log(m->avctx, AV_LOG_ERROR, "Matrices may change only once per access unit.\n");
- return AVERROR_INVALIDDATA;
- }
-
- s->num_primitive_matrices = get_bits(gbp, 4);
-
- if (s->num_primitive_matrices > max_primitive_matrices) {
- av_log(m->avctx, AV_LOG_ERROR,
- "Number of primitive matrices cannot be greater than %d.\n",
- max_primitive_matrices);
- return AVERROR_INVALIDDATA;
- }
-
- for (mat = 0; mat < s->num_primitive_matrices; mat++) {
- int frac_bits, max_chan;
- s->matrix_out_ch[mat] = get_bits(gbp, 4);
- frac_bits = get_bits(gbp, 4);
- s->lsb_bypass [mat] = get_bits1(gbp);
-
- if (s->matrix_out_ch[mat] > s->max_matrix_channel) {
- av_log(m->avctx, AV_LOG_ERROR,
- "Invalid channel %d specified as output from matrix.\n",
- s->matrix_out_ch[mat]);
- return AVERROR_INVALIDDATA;
- }
- if (frac_bits > 14) {
- av_log(m->avctx, AV_LOG_ERROR,
- "Too many fractional bits specified.\n");
- return AVERROR_INVALIDDATA;
- }
-
- max_chan = s->max_matrix_channel;
- if (!s->noise_type)
- max_chan+=2;
-
- for (ch = 0; ch <= max_chan; ch++) {
- int coeff_val = 0;
- if (get_bits1(gbp))
- coeff_val = get_sbits(gbp, frac_bits + 2);
-
- s->matrix_coeff[mat][ch] = coeff_val << (14 - frac_bits);
- }
-
- if (s->noise_type)
- s->matrix_noise_shift[mat] = get_bits(gbp, 4);
- else
- s->matrix_noise_shift[mat] = 0;
- }
-
- return 0;
-}
-
-/** Read channel parameters. */
-
-static int read_channel_params(MLPDecodeContext *m, unsigned int substr,
- GetBitContext *gbp, unsigned int ch)
-{
- SubStream *s = &m->substream[substr];
- ChannelParams *cp = &s->channel_params[ch];
- FilterParams *fir = &cp->filter_params[FIR];
- FilterParams *iir = &cp->filter_params[IIR];
- int ret;
-
- if (s->param_presence_flags & PARAM_FIR)
- if (get_bits1(gbp))
- if ((ret = read_filter_params(m, gbp, substr, ch, FIR)) < 0)
- return ret;
-
- if (s->param_presence_flags & PARAM_IIR)
- if (get_bits1(gbp))
- if ((ret = read_filter_params(m, gbp, substr, ch, IIR)) < 0)
- return ret;
-
- if (fir->order + iir->order > 8) {
- av_log(m->avctx, AV_LOG_ERROR, "Total filter orders too high.\n");
- return AVERROR_INVALIDDATA;
- }
-
- if (fir->order && iir->order &&
- fir->shift != iir->shift) {
- av_log(m->avctx, AV_LOG_ERROR,
- "FIR and IIR filters must use the same precision.\n");
- return AVERROR_INVALIDDATA;
- }
- /* The FIR and IIR filters must have the same precision.
- * To simplify the filtering code, only the precision of the
- * FIR filter is considered. If only the IIR filter is employed,
- * the FIR filter precision is set to that of the IIR filter, so
- * that the filtering code can use it. */
- if (!fir->order && iir->order)
- fir->shift = iir->shift;
-
- if (s->param_presence_flags & PARAM_HUFFOFFSET)
- if (get_bits1(gbp))
- cp->huff_offset = get_sbits(gbp, 15);
-
- cp->codebook = get_bits(gbp, 2);
- cp->huff_lsbs = get_bits(gbp, 5);
-
- if (cp->huff_lsbs > 24) {
- av_log(m->avctx, AV_LOG_ERROR, "Invalid huff_lsbs.\n");
- cp->huff_lsbs = 0;
- return AVERROR_INVALIDDATA;
- }
-
- cp->sign_huff_offset = calculate_sign_huff(m, substr, ch);
-
- return 0;
-}
-
-/** Read decoding parameters that change more often than those in the restart
- * header. */
-
-static int read_decoding_params(MLPDecodeContext *m, GetBitContext *gbp,
- unsigned int substr)
-{
- SubStream *s = &m->substream[substr];
- unsigned int ch;
- int ret;
-
- if (s->param_presence_flags & PARAM_PRESENCE)
- if (get_bits1(gbp))
- s->param_presence_flags = get_bits(gbp, 8);
-
- if (s->param_presence_flags & PARAM_BLOCKSIZE)
- if (get_bits1(gbp)) {
- s->blocksize = get_bits(gbp, 9);
- if (s->blocksize < 8 || s->blocksize > m->access_unit_size) {
- av_log(m->avctx, AV_LOG_ERROR, "Invalid blocksize.\n");
- s->blocksize = 0;
- return AVERROR_INVALIDDATA;
- }
- }
-
- if (s->param_presence_flags & PARAM_MATRIX)
- if (get_bits1(gbp))
- if ((ret = read_matrix_params(m, substr, gbp)) < 0)
- return ret;
-
- if (s->param_presence_flags & PARAM_OUTSHIFT)
- if (get_bits1(gbp))
- for (ch = 0; ch <= s->max_matrix_channel; ch++)
- s->output_shift[ch] = get_sbits(gbp, 4);
-
- if (s->param_presence_flags & PARAM_QUANTSTEP)
- if (get_bits1(gbp))
- for (ch = 0; ch <= s->max_channel; ch++) {
- ChannelParams *cp = &s->channel_params[ch];
-
- s->quant_step_size[ch] = get_bits(gbp, 4);
-
- cp->sign_huff_offset = calculate_sign_huff(m, substr, ch);
- }
-
- for (ch = s->min_channel; ch <= s->max_channel; ch++)
- if (get_bits1(gbp))
- if ((ret = read_channel_params(m, substr, gbp, ch)) < 0)
- return ret;
-
- return 0;
-}
-
-#define MSB_MASK(bits) (-1u << bits)
-
-/** Generate PCM samples using the prediction filters and residual values
- * read from the data stream, and update the filter state. */
-
-static void filter_channel(MLPDecodeContext *m, unsigned int substr,
- unsigned int channel)
-{
- SubStream *s = &m->substream[substr];
- const int32_t *fircoeff = s->channel_params[channel].coeff[FIR];
- int32_t state_buffer[NUM_FILTERS][MAX_BLOCKSIZE + MAX_FIR_ORDER];
- int32_t *firbuf = state_buffer[FIR] + MAX_BLOCKSIZE;
- int32_t *iirbuf = state_buffer[IIR] + MAX_BLOCKSIZE;
- FilterParams *fir = &s->channel_params[channel].filter_params[FIR];
- FilterParams *iir = &s->channel_params[channel].filter_params[IIR];
- unsigned int filter_shift = fir->shift;
- int32_t mask = MSB_MASK(s->quant_step_size[channel]);
-
- memcpy(firbuf, fir->state, MAX_FIR_ORDER * sizeof(int32_t));
- memcpy(iirbuf, iir->state, MAX_IIR_ORDER * sizeof(int32_t));
-
- m->dsp.mlp_filter_channel(firbuf, fircoeff,
- fir->order, iir->order,
- filter_shift, mask, s->blocksize,
- &m->sample_buffer[s->blockpos][channel]);
-
- memcpy(fir->state, firbuf - s->blocksize, MAX_FIR_ORDER * sizeof(int32_t));
- memcpy(iir->state, iirbuf - s->blocksize, MAX_IIR_ORDER * sizeof(int32_t));
-}
-
-/** Read a block of PCM residual data (or actual if no filtering active). */
-
-static int read_block_data(MLPDecodeContext *m, GetBitContext *gbp,
- unsigned int substr)
-{
- SubStream *s = &m->substream[substr];
- unsigned int i, ch, expected_stream_pos = 0;
- int ret;
-
- if (s->data_check_present) {
- expected_stream_pos = get_bits_count(gbp);
- expected_stream_pos += get_bits(gbp, 16);
- av_log_ask_for_sample(m->avctx, "This file contains some features "
- "we have not tested yet.\n");
- }
-
- if (s->blockpos + s->blocksize > m->access_unit_size) {
- av_log(m->avctx, AV_LOG_ERROR, "too many audio samples in frame\n");
- return AVERROR_INVALIDDATA;
- }
-
- memset(&m->bypassed_lsbs[s->blockpos][0], 0,
- s->blocksize * sizeof(m->bypassed_lsbs[0]));
-
- for (i = 0; i < s->blocksize; i++)
- if ((ret = read_huff_channels(m, gbp, substr, i)) < 0)
- return ret;
-
- for (ch = s->min_channel; ch <= s->max_channel; ch++)
- filter_channel(m, substr, ch);
-
- s->blockpos += s->blocksize;
-
- if (s->data_check_present) {
- if (get_bits_count(gbp) != expected_stream_pos)
- av_log(m->avctx, AV_LOG_ERROR, "block data length mismatch\n");
- skip_bits(gbp, 8);
- }
-
- return 0;
-}
-
-/** Data table used for TrueHD noise generation function. */
-
-static const int8_t noise_table[256] = {
- 30, 51, 22, 54, 3, 7, -4, 38, 14, 55, 46, 81, 22, 58, -3, 2,
- 52, 31, -7, 51, 15, 44, 74, 30, 85, -17, 10, 33, 18, 80, 28, 62,
- 10, 32, 23, 69, 72, 26, 35, 17, 73, 60, 8, 56, 2, 6, -2, -5,
- 51, 4, 11, 50, 66, 76, 21, 44, 33, 47, 1, 26, 64, 48, 57, 40,
- 38, 16, -10, -28, 92, 22, -18, 29, -10, 5, -13, 49, 19, 24, 70, 34,
- 61, 48, 30, 14, -6, 25, 58, 33, 42, 60, 67, 17, 54, 17, 22, 30,
- 67, 44, -9, 50, -11, 43, 40, 32, 59, 82, 13, 49, -14, 55, 60, 36,
- 48, 49, 31, 47, 15, 12, 4, 65, 1, 23, 29, 39, 45, -2, 84, 69,
- 0, 72, 37, 57, 27, 41, -15, -16, 35, 31, 14, 61, 24, 0, 27, 24,
- 16, 41, 55, 34, 53, 9, 56, 12, 25, 29, 53, 5, 20, -20, -8, 20,
- 13, 28, -3, 78, 38, 16, 11, 62, 46, 29, 21, 24, 46, 65, 43, -23,
- 89, 18, 74, 21, 38, -12, 19, 12, -19, 8, 15, 33, 4, 57, 9, -8,
- 36, 35, 26, 28, 7, 83, 63, 79, 75, 11, 3, 87, 37, 47, 34, 40,
- 39, 19, 20, 42, 27, 34, 39, 77, 13, 42, 59, 64, 45, -1, 32, 37,
- 45, -5, 53, -6, 7, 36, 50, 23, 6, 32, 9, -21, 18, 71, 27, 52,
- -25, 31, 35, 42, -1, 68, 63, 52, 26, 43, 66, 37, 41, 25, 40, 70,
-};
-
-/** Noise generation functions.
- * I'm not sure what these are for - they seem to be some kind of pseudorandom
- * sequence generators, used to generate noise data which is used when the
- * channels are rematrixed. I'm not sure if they provide a practical benefit
- * to compression, or just obfuscate the decoder. Are they for some kind of
- * dithering? */
-
-/** Generate two channels of noise, used in the matrix when
- * restart sync word == 0x31ea. */
-
-static void generate_2_noise_channels(MLPDecodeContext *m, unsigned int substr)
-{
- SubStream *s = &m->substream[substr];
- unsigned int i;
- uint32_t seed = s->noisegen_seed;
- unsigned int maxchan = s->max_matrix_channel;
-
- for (i = 0; i < s->blockpos; i++) {
- uint16_t seed_shr7 = seed >> 7;
- m->sample_buffer[i][maxchan+1] = ((int8_t)(seed >> 15)) << s->noise_shift;
- m->sample_buffer[i][maxchan+2] = ((int8_t) seed_shr7) << s->noise_shift;
-
- seed = (seed << 16) ^ seed_shr7 ^ (seed_shr7 << 5);
- }
-
- s->noisegen_seed = seed;
-}
-
-/** Generate a block of noise, used when restart sync word == 0x31eb. */
-
-static void fill_noise_buffer(MLPDecodeContext *m, unsigned int substr)
-{
- SubStream *s = &m->substream[substr];
- unsigned int i;
- uint32_t seed = s->noisegen_seed;
-
- for (i = 0; i < m->access_unit_size_pow2; i++) {
- uint8_t seed_shr15 = seed >> 15;
- m->noise_buffer[i] = noise_table[seed_shr15];
- seed = (seed << 8) ^ seed_shr15 ^ (seed_shr15 << 5);
- }
-
- s->noisegen_seed = seed;
-}
-
-
-/** Apply the channel matrices in turn to reconstruct the original audio
- * samples. */
-
-static void rematrix_channels(MLPDecodeContext *m, unsigned int substr)
-{
- SubStream *s = &m->substream[substr];
- unsigned int mat, src_ch, i;
- unsigned int maxchan;
-
- maxchan = s->max_matrix_channel;
- if (!s->noise_type) {
- generate_2_noise_channels(m, substr);
- maxchan += 2;
- } else {
- fill_noise_buffer(m, 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;
- }
- }
-}
-
-/** Write the audio data into the output buffer. */
-
-static int output_data(MLPDecodeContext *m, unsigned int substr,
- AVFrame *frame, int *got_frame_ptr)
-{
- 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);
-
- if (m->avctx->channels != s->max_matrix_channel + 1) {
- av_log(m->avctx, AV_LOG_ERROR, "channel count mismatch\n");
- return AVERROR_INVALIDDATA;
- }
-
- /* get output buffer */
- frame->nb_samples = s->blockpos;
- if ((ret = ff_get_buffer(avctx, frame)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- 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;
- }
- }
-
- *got_frame_ptr = 1;
-
- return 0;
-}
-
-/** Read an access unit from the stream.
- * @return negative on error, 0 if not enough data is present in the input stream,
- * otherwise the number of bytes consumed. */
-
-static int read_access_unit(AVCodecContext *avctx, void* data,
- int *got_frame_ptr, AVPacket *avpkt)
-{
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
- MLPDecodeContext *m = avctx->priv_data;
- GetBitContext gb;
- unsigned int length, substr;
- unsigned int substream_start;
- unsigned int header_size = 4;
- unsigned int substr_header_size = 0;
- uint8_t substream_parity_present[MAX_SUBSTREAMS];
- uint16_t substream_data_len[MAX_SUBSTREAMS];
- uint8_t parity_bits;
- int ret;
-
- if (buf_size < 4)
- return 0;
-
- length = (AV_RB16(buf) & 0xfff) * 2;
-
- if (length < 4 || length > buf_size)
- return AVERROR_INVALIDDATA;
-
- init_get_bits(&gb, (buf + 4), (length - 4) * 8);
-
- m->is_major_sync_unit = 0;
- if (show_bits_long(&gb, 31) == (0xf8726fba >> 1)) {
- if (read_major_sync(m, &gb) < 0)
- goto error;
- m->is_major_sync_unit = 1;
- header_size += 28;
- }
-
- if (!m->params_valid) {
- av_log(m->avctx, AV_LOG_WARNING,
- "Stream parameters not seen; skipping frame.\n");
- *got_frame_ptr = 0;
- return length;
- }
-
- substream_start = 0;
-
- for (substr = 0; substr < m->num_substreams; substr++) {
- int extraword_present, checkdata_present, end, nonrestart_substr;
-
- extraword_present = get_bits1(&gb);
- nonrestart_substr = get_bits1(&gb);
- checkdata_present = get_bits1(&gb);
- skip_bits1(&gb);
-
- end = get_bits(&gb, 12) * 2;
-
- substr_header_size += 2;
-
- if (extraword_present) {
- if (m->avctx->codec_id == AV_CODEC_ID_MLP) {
- av_log(m->avctx, AV_LOG_ERROR, "There must be no extraword for MLP.\n");
- goto error;
- }
- skip_bits(&gb, 16);
- substr_header_size += 2;
- }
-
- if (!(nonrestart_substr ^ m->is_major_sync_unit)) {
- av_log(m->avctx, AV_LOG_ERROR, "Invalid nonrestart_substr.\n");
- goto error;
- }
-
- if (end + header_size + substr_header_size > length) {
- av_log(m->avctx, AV_LOG_ERROR,
- "Indicated length of substream %d data goes off end of "
- "packet.\n", substr);
- end = length - header_size - substr_header_size;
- }
-
- if (end < substream_start) {
- av_log(avctx, AV_LOG_ERROR,
- "Indicated end offset of substream %d data "
- "is smaller than calculated start offset.\n",
- substr);
- goto error;
- }
-
- if (substr > m->max_decoded_substream)
- continue;
-
- substream_parity_present[substr] = checkdata_present;
- substream_data_len[substr] = end - substream_start;
- substream_start = end;
- }
-
- parity_bits = ff_mlp_calculate_parity(buf, 4);
- parity_bits ^= ff_mlp_calculate_parity(buf + header_size, substr_header_size);
-
- if ((((parity_bits >> 4) ^ parity_bits) & 0xF) != 0xF) {
- av_log(avctx, AV_LOG_ERROR, "Parity check failed.\n");
- goto error;
- }
-
- buf += header_size + substr_header_size;
-
- for (substr = 0; substr <= m->max_decoded_substream; substr++) {
- SubStream *s = &m->substream[substr];
- init_get_bits(&gb, buf, substream_data_len[substr] * 8);
-
- m->matrix_changed = 0;
- memset(m->filter_changed, 0, sizeof(m->filter_changed));
-
- s->blockpos = 0;
- do {
- if (get_bits1(&gb)) {
- if (get_bits1(&gb)) {
- /* A restart header should be present. */
- if (read_restart_header(m, &gb, buf, substr) < 0)
- goto next_substr;
- s->restart_seen = 1;
- }
-
- if (!s->restart_seen)
- goto next_substr;
- if (read_decoding_params(m, &gb, substr) < 0)
- goto next_substr;
- }
-
- if (!s->restart_seen)
- goto next_substr;
-
- if ((ret = read_block_data(m, &gb, substr)) < 0)
- return ret;
-
- if (get_bits_count(&gb) >= substream_data_len[substr] * 8)
- goto substream_length_mismatch;
-
- } while (!get_bits1(&gb));
-
- skip_bits(&gb, (-get_bits_count(&gb)) & 15);
-
- if (substream_data_len[substr] * 8 - get_bits_count(&gb) >= 32) {
- int shorten_by;
-
- if (get_bits(&gb, 16) != 0xD234)
- return AVERROR_INVALIDDATA;
-
- shorten_by = get_bits(&gb, 16);
- if (m->avctx->codec_id == AV_CODEC_ID_TRUEHD && shorten_by & 0x2000)
- s->blockpos -= FFMIN(shorten_by & 0x1FFF, s->blockpos);
- else if (m->avctx->codec_id == AV_CODEC_ID_MLP && shorten_by != 0xD234)
- return AVERROR_INVALIDDATA;
-
- if (substr == m->max_decoded_substream)
- av_log(m->avctx, AV_LOG_INFO, "End of stream indicated.\n");
- }
-
- if (substream_parity_present[substr]) {
- uint8_t parity, checksum;
-
- if (substream_data_len[substr] * 8 - get_bits_count(&gb) != 16)
- goto substream_length_mismatch;
-
- parity = ff_mlp_calculate_parity(buf, substream_data_len[substr] - 2);
- checksum = ff_mlp_checksum8 (buf, substream_data_len[substr] - 2);
-
- if ((get_bits(&gb, 8) ^ parity) != 0xa9 )
- av_log(m->avctx, AV_LOG_ERROR, "Substream %d parity check failed.\n", substr);
- if ( get_bits(&gb, 8) != checksum)
- av_log(m->avctx, AV_LOG_ERROR, "Substream %d checksum failed.\n" , substr);
- }
-
- if (substream_data_len[substr] * 8 != get_bits_count(&gb))
- goto substream_length_mismatch;
-
-next_substr:
- if (!s->restart_seen)
- av_log(m->avctx, AV_LOG_ERROR,
- "No restart header present in substream %d.\n", substr);
-
- buf += substream_data_len[substr];
- }
-
- rematrix_channels(m, m->max_decoded_substream);
-
- if ((ret = output_data(m, m->max_decoded_substream, data, got_frame_ptr)) < 0)
- return ret;
-
- return length;
-
-substream_length_mismatch:
- av_log(m->avctx, AV_LOG_ERROR, "substream %d length mismatch\n", substr);
- return AVERROR_INVALIDDATA;
-
-error:
- m->params_valid = 0;
- return AVERROR_INVALIDDATA;
-}
-
-#if CONFIG_MLP_DECODER
-AVCodec ff_mlp_decoder = {
- .name = "mlp",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_MLP,
- .priv_data_size = sizeof(MLPDecodeContext),
- .init = mlp_decode_init,
- .decode = read_access_unit,
- .capabilities = CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("MLP (Meridian Lossless Packing)"),
-};
-#endif
-#if CONFIG_TRUEHD_DECODER
-AVCodec ff_truehd_decoder = {
- .name = "truehd",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_TRUEHD,
- .priv_data_size = sizeof(MLPDecodeContext),
- .init = mlp_decode_init,
- .decode = read_access_unit,
- .capabilities = CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("TrueHD"),
-};
-#endif /* CONFIG_TRUEHD_DECODER */
diff --git a/src/thirdparty/ffmpeg/libavcodec/mlpdsp.c b/src/thirdparty/ffmpeg/libavcodec/mlpdsp.c
deleted file mode 100644
index a0870a619..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mlpdsp.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2007-2008 Ian Caulfield
- * 2009 Ramiro Polla
- *
- * 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 "mlpdsp.h"
-#include "mlp.h"
-
-static void ff_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)
-{
- int32_t *firbuf = state;
- int32_t *iirbuf = state + MAX_BLOCKSIZE + MAX_FIR_ORDER;
- const int32_t *fircoeff = coeff;
- const int32_t *iircoeff = coeff + MAX_FIR_ORDER;
- int i;
-
- for (i = 0; i < blocksize; i++) {
- int32_t residual = *sample_buffer;
- unsigned int order;
- int64_t accum = 0;
- int32_t result;
-
- for (order = 0; order < firorder; order++)
- accum += (int64_t) firbuf[order] * fircoeff[order];
- for (order = 0; order < iirorder; order++)
- accum += (int64_t) iirbuf[order] * iircoeff[order];
-
- accum = accum >> filter_shift;
- result = (accum + residual) & mask;
-
- *--firbuf = result;
- *--iirbuf = result - accum;
-
- *sample_buffer = result;
- sample_buffer += MAX_CHANNELS;
- }
-}
-
-void ff_mlpdsp_init(MLPDSPContext *c)
-{
- c->mlp_filter_channel = ff_mlp_filter_channel;
- if (ARCH_X86)
- ff_mlpdsp_init_x86(c);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/mlpdsp.h b/src/thirdparty/ffmpeg/libavcodec/mlpdsp.h
deleted file mode 100644
index 84a8aa3a3..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mlpdsp.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * MLP codec common header file
- * Copyright (c) 2007-2008 Ian Caulfield
- *
- * 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_MLPDSP_H
-#define AVCODEC_MLPDSP_H
-
-#include <stdint.h>
-
-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);
-} MLPDSPContext;
-
-void ff_mlpdsp_init(MLPDSPContext *c);
-void ff_mlpdsp_init_x86(MLPDSPContext *c);
-
-#endif /* AVCODEC_MLPDSP_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpeg12.c b/src/thirdparty/ffmpeg/libavcodec/mpeg12.c
deleted file mode 100644
index df0ab4efc..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpeg12.c
+++ /dev/null
@@ -1,2748 +0,0 @@
-/*
- * MPEG-1/2 decoder
- * Copyright (c) 2000, 2001 Fabrice Bellard
- * Copyright (c) 2002-2004 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
- * MPEG-1/2 decoder
- */
-
-#define UNCHECKED_BITSTREAM_READER 1
-
-//#define DEBUG
-#include "internal.h"
-#include "avcodec.h"
-#include "dsputil.h"
-#include "mpegvideo.h"
-#include "libavutil/avassert.h"
-#include "libavutil/timecode.h"
-
-#include "mpeg12.h"
-#include "mpeg12data.h"
-#include "mpeg12decdata.h"
-#include "bytestream.h"
-#include "vdpau_internal.h"
-#include "xvmc_internal.h"
-#include "thread.h"
-
-
-#define MV_VLC_BITS 9
-#define MBINCR_VLC_BITS 9
-#define MB_PAT_VLC_BITS 9
-#define MB_PTYPE_VLC_BITS 6
-#define MB_BTYPE_VLC_BITS 6
-
-static VLC mv_vlc;
-
-/* as H.263, but only 17 codes */
-static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred)
-{
- int code, sign, val, shift;
-
- code = get_vlc2(&s->gb, mv_vlc.table, MV_VLC_BITS, 2);
- if (code == 0) {
- return pred;
- }
- if (code < 0) {
- return 0xffff;
- }
-
- sign = get_bits1(&s->gb);
- shift = fcode - 1;
- val = code;
- if (shift) {
- val = (val - 1) << shift;
- val |= get_bits(&s->gb, shift);
- val++;
- }
- if (sign)
- val = -val;
- val += pred;
-
- /* modulo decoding */
- return sign_extend(val, 5 + shift);
-}
-
-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;
- const uint16_t *quant_matrix = s->intra_matrix;
- const int qscale = s->qscale;
-
- /* DC coefficient */
- component = (n <= 3 ? 0 : n - 4 + 1);
- diff = decode_dc(&s->gb, component);
- if (diff >= 0xffff)
- return -1;
- dc = s->last_dc[component];
- dc += diff;
- s->last_dc[component] = dc;
- block[0] = dc * quant_matrix[0];
- av_dlog(s->avctx, "dc=%d diff=%d\n", dc, diff);
- i = 0;
- {
- OPEN_READER(re, &s->gb);
- /* 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);
-
- if (level == 127) {
- break;
- } else if (level != 0) {
- i += run;
- 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);
- } else {
- /* escape */
- 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);
- if (level == -128) {
- level = SHOW_UBITS(re, &s->gb, 8) - 256; LAST_SKIP_BITS(re, &s->gb, 8);
- } else if (level == 0) {
- level = SHOW_UBITS(re, &s->gb, 8) ; LAST_SKIP_BITS(re, &s->gb, 8);
- }
- i += run;
- j = scantable[i];
- if (level < 0) {
- level = -level;
- level = (level * qscale * quant_matrix[j]) >> 4;
- level = (level - 1) | 1;
- level = -level;
- } else {
- level = (level * qscale * quant_matrix[j]) >> 4;
- 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;
- }
- CLOSE_READER(re, &s->gb);
- }
- s->block_last_index[n] = i;
- return 0;
-}
-
-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)
-{
- int level, i, j, run;
- 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;
-
- {
- 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) {
- level = (3 * qscale * quant_matrix[0]) >> 5;
- level = (level - 1) | 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)
- 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);
-
- if (level != 0) {
- i += run;
- 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);
- SKIP_BITS(re, &s->gb, 1);
- } else {
- /* escape */
- 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);
- if (level == -128) {
- 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);
- }
- i += run;
- j = scantable[i];
- if (level < 0) {
- level = -level;
- level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
- level = (level - 1) | 1;
- level = -level;
- } else {
- level = ((level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
- 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;
-}
-
-/**
- * Note: this function can read out of range and crash for corrupt streams.
- * 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)
-{
- int level, i, j, run;
- 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) {
- level = (3 * qscale) >> 1;
- level = (level - 1) | 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)
- 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);
-
- if (level != 0) {
- i += run;
- 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);
- SKIP_BITS(re, &s->gb, 1);
- } else {
- /* escape */
- 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);
- if (level == -128) {
- 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);
- }
- i += run;
- j = scantable[i];
- if (level < 0) {
- level = -level;
- level = ((level * 2 + 1) * qscale) >> 1;
- level = (level - 1) | 1;
- level = -level;
- } else {
- level = ((level * 2 + 1) * qscale) >> 1;
- level = (level - 1) | 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;
-}
-
-
-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;
- const uint16_t *quant_matrix;
- const int qscale = s->qscale;
- int mismatch;
-
- mismatch = 1;
-
- {
- OPEN_READER(re, &s->gb);
- i = -1;
- if (n < 4)
- quant_matrix = s->inter_matrix;
- else
- quant_matrix = s->chroma_inter_matrix;
-
- // 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 (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)
- 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);
-
- if (level != 0) {
- i += run;
- 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);
- SKIP_BITS(re, &s->gb, 1);
- } else {
- /* escape */
- 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);
-
- i += run;
- j = scantable[i];
- if (level < 0) {
- level = ((-level * 2 + 1) * qscale * quant_matrix[j]) >> 5;
- level = -level;
- } else {
- 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)
- break;
- UPDATE_CACHE(re, &s->gb);
- }
-end:
- LAST_SKIP_BITS(re, &s->gb, 2);
- CLOSE_READER(re, &s->gb);
- }
- block[63] ^= (mismatch & 1);
-
- s->block_last_index[n] = i;
- return 0;
-}
-
-/**
- * Note: this function can read out of range and crash for corrupt streams.
- * 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_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;
- 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) {
- 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)
- 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);
-
- if (level != 0) {
- i += run;
- j = scantable[i];
- level = ((level * 2 + 1) * qscale) >> 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);
- UPDATE_CACHE(re, &s->gb);
- level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
-
- i += run;
- j = scantable[i];
- if (level < 0) {
- level = ((-level * 2 + 1) * qscale) >> 1;
- level = -level;
- } else {
- level = ((level * 2 + 1) * qscale) >> 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;
-}
-
-
-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;
- const uint16_t *quant_matrix;
- const int qscale = s->qscale;
- int mismatch;
-
- /* DC coefficient */
- if (n < 4) {
- quant_matrix = s->intra_matrix;
- component = 0;
- } else {
- quant_matrix = s->chroma_intra_matrix;
- component = (n & 1) + 1;
- }
- diff = decode_dc(&s->gb, component);
- if (diff >= 0xffff)
- return -1;
- dc = s->last_dc[component];
- dc += diff;
- s->last_dc[component] = dc;
- block[0] = dc << (3 - s->intra_dc_precision);
- av_dlog(s->avctx, "dc=%d\n", block[0]);
- mismatch = block[0] ^ 1;
- i = 0;
- if (s->intra_vlc_format)
- rl = &ff_rl_mpeg2;
- else
- rl = &ff_rl_mpeg1;
-
- {
- OPEN_READER(re, &s->gb);
- /* 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);
-
- if (level == 127) {
- break;
- } else if (level != 0) {
- 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);
- LAST_SKIP_BITS(re, &s->gb, 1);
- } else {
- /* escape */
- 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);
- i += run;
- j = scantable[i];
- if (level < 0) {
- level = (-level * qscale * quant_matrix[j]) >> 4;
- level = -level;
- } else {
- 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;
- }
- CLOSE_READER(re, &s->gb);
- }
- block[63] ^= mismatch & 1;
-
- s->block_last_index[n] = i;
- return 0;
-}
-
-/**
- * Note: this function can read out of range and crash for corrupt streams.
- * 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)
-{
- int level, dc, diff, j, run;
- int component;
- RLTable *rl;
- uint8_t * 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;
- } else {
- quant_matrix = s->chroma_intra_matrix;
- component = (n & 1) + 1;
- }
- diff = decode_dc(&s->gb, component);
- if (diff >= 0xffff)
- return -1;
- dc = s->last_dc[component];
- dc += diff;
- s->last_dc[component] = dc;
- block[0] = dc << (3 - s->intra_dc_precision);
- if (s->intra_vlc_format)
- rl = &ff_rl_mpeg2;
- else
- rl = &ff_rl_mpeg1;
-
- {
- OPEN_READER(re, &s->gb);
- /* 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);
-
- if (level == 127) {
- break;
- } else if (level != 0) {
- scantable += run;
- j = *scantable;
- level = (level * qscale * quant_matrix[j]) >> 4;
- 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);
- UPDATE_CACHE(re, &s->gb);
- level = SHOW_SBITS(re, &s->gb, 12); SKIP_BITS(re, &s->gb, 12);
- scantable += run;
- j = *scantable;
- if (level < 0) {
- level = (-level * qscale * quant_matrix[j]) >> 4;
- level = -level;
- } else {
- level = (level * qscale * quant_matrix[j]) >> 4;
- }
- }
-
- block[j] = level;
- }
- CLOSE_READER(re, &s->gb);
- }
-
- s->block_last_index[n] = scantable - s->intra_scantable.permutated;
- return 0;
-}
-
-uint8_t ff_mpeg12_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3];
-
-#define INIT_2D_VLC_RL(rl, static_size)\
-{\
- static RL_VLC_ELEM rl_vlc_table[static_size];\
- INIT_VLC_STATIC(&rl.vlc, TEX_VLC_BITS, rl.n + 2,\
- &rl.table_vlc[0][1], 4, 2,\
- &rl.table_vlc[0][0], 4, 2, static_size);\
-\
- rl.rl_vlc[0] = rl_vlc_table;\
- init_2d_vlc_rl(&rl);\
-}
-
-static void init_2d_vlc_rl(RLTable *rl)
-{
- int i;
-
- for (i = 0; i < rl->vlc.table_size; i++) {
- int code = rl->vlc.table[i][0];
- int len = rl->vlc.table[i][1];
- int level, run;
-
- if (len == 0) { // illegal code
- run = 65;
- level = MAX_LEVEL;
- } else if (len<0) { //more bits needed
- run = 0;
- level = code;
- } else {
- if (code == rl->n) { //esc
- run = 65;
- level = 0;
- } else if (code == rl->n+1) { //eob
- run = 0;
- level = 127;
- } else {
- run = rl->table_run [code] + 1;
- level = rl->table_level[code];
- }
- }
- rl->rl_vlc[0][i].len = len;
- rl->rl_vlc[0][i].level = level;
- rl->rl_vlc[0][i].run = run;
- }
-}
-
-void ff_mpeg12_common_init(MpegEncContext *s)
-{
-
- s->y_dc_scale_table =
- s->c_dc_scale_table = ff_mpeg2_dc_scale_table[s->intra_dc_precision];
-
-}
-
-void ff_mpeg1_clean_buffers(MpegEncContext *s)
-{
- s->last_dc[0] = 1 << (7 + s->intra_dc_precision);
- s->last_dc[1] = s->last_dc[0];
- s->last_dc[2] = s->last_dc[0];
- memset(s->last_mv, 0, sizeof(s->last_mv));
-}
-
-
-/******************************************/
-/* decoding */
-
-VLC ff_dc_lum_vlc;
-VLC ff_dc_chroma_vlc;
-
-static VLC mbincr_vlc;
-static VLC mb_ptype_vlc;
-static VLC mb_btype_vlc;
-static VLC mb_pat_vlc;
-
-av_cold void ff_mpeg12_init_vlcs(void)
-{
- static int done = 0;
-
- if (!done) {
- done = 1;
-
- INIT_VLC_STATIC(&ff_dc_lum_vlc, DC_VLC_BITS, 12,
- ff_mpeg12_vlc_dc_lum_bits, 1, 1,
- ff_mpeg12_vlc_dc_lum_code, 2, 2, 512);
- INIT_VLC_STATIC(&ff_dc_chroma_vlc, DC_VLC_BITS, 12,
- ff_mpeg12_vlc_dc_chroma_bits, 1, 1,
- ff_mpeg12_vlc_dc_chroma_code, 2, 2, 514);
- INIT_VLC_STATIC(&mv_vlc, MV_VLC_BITS, 17,
- &ff_mpeg12_mbMotionVectorTable[0][1], 2, 1,
- &ff_mpeg12_mbMotionVectorTable[0][0], 2, 1, 518);
- INIT_VLC_STATIC(&mbincr_vlc, MBINCR_VLC_BITS, 36,
- &ff_mpeg12_mbAddrIncrTable[0][1], 2, 1,
- &ff_mpeg12_mbAddrIncrTable[0][0], 2, 1, 538);
- INIT_VLC_STATIC(&mb_pat_vlc, MB_PAT_VLC_BITS, 64,
- &ff_mpeg12_mbPatTable[0][1], 2, 1,
- &ff_mpeg12_mbPatTable[0][0], 2, 1, 512);
-
- INIT_VLC_STATIC(&mb_ptype_vlc, MB_PTYPE_VLC_BITS, 7,
- &table_mb_ptype[0][1], 2, 1,
- &table_mb_ptype[0][0], 2, 1, 64);
- INIT_VLC_STATIC(&mb_btype_vlc, MB_BTYPE_VLC_BITS, 11,
- &table_mb_btype[0][1], 2, 1,
- &table_mb_btype[0][0], 2, 1, 64);
- ff_init_rl(&ff_rl_mpeg1, ff_mpeg12_static_rl_table_store[0]);
- ff_init_rl(&ff_rl_mpeg2, ff_mpeg12_static_rl_table_store[1]);
-
- INIT_2D_VLC_RL(ff_rl_mpeg1, 680);
- INIT_2D_VLC_RL(ff_rl_mpeg2, 674);
- }
-}
-
-static inline int get_dmv(MpegEncContext *s)
-{
- if (get_bits1(&s->gb))
- return 1 - (get_bits1(&s->gb) << 1);
- else
- return 0;
-}
-
-static inline int get_qscale(MpegEncContext *s)
-{
- int qscale = get_bits(&s->gb, 5);
- if (s->q_scale_type) {
- return non_linear_qscale[qscale];
- } 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
-#define MT_FRAME 2
-#define MT_16X8 2
-#define MT_DMV 3
-
-static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
-{
- int i, j, k, cbp, val, mb_type, motion_type;
- const int mb_block_count = 4 + (1 << s->chroma_format);
-
- av_dlog(s->avctx, "decode_mb: x=%d y=%d\n", s->mb_x, s->mb_y);
-
- av_assert2(s->mb_skipped == 0);
-
- if (s->mb_skip_run-- != 0) {
- if (s->pict_type == AV_PICTURE_TYPE_P) {
- s->mb_skipped = 1;
- s->current_picture.f.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.f.mb_type[s->mb_x + s->mb_y * s->mb_stride - 1];
- else
- mb_type = s->current_picture.f.mb_type[s->mb_width + (s->mb_y - 1) * s->mb_stride - 1]; // FIXME not sure if this is allowed in MPEG at all
- if (IS_INTRA(mb_type)) {
- av_log(s->avctx, AV_LOG_ERROR, "skip with previntra\n");
- return -1;
- }
- s->current_picture.f.mb_type[s->mb_x + s->mb_y*s->mb_stride] =
- mb_type | MB_TYPE_SKIP;
-// av_assert2(s->current_picture.f.mb_type[s->mb_x + s->mb_y * s->mb_stride - 1] & (MB_TYPE_16x16 | MB_TYPE_16x8));
-
- if ((s->mv[0][0][0] | s->mv[0][0][1] | s->mv[1][0][0] | s->mv[1][0][1]) == 0)
- s->mb_skipped = 1;
- }
-
- return 0;
- }
-
- switch (s->pict_type) {
- default:
- 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);
- return -1;
- }
- mb_type = MB_TYPE_QUANT | MB_TYPE_INTRA;
- } else {
- mb_type = MB_TYPE_INTRA;
- }
- break;
- case AV_PICTURE_TYPE_P:
- mb_type = get_vlc2(&s->gb, 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);
- return -1;
- }
- mb_type = ptype2mb_type[mb_type];
- break;
- case AV_PICTURE_TYPE_B:
- mb_type = get_vlc2(&s->gb, 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);
- return -1;
- }
- mb_type = btype2mb_type[mb_type];
- break;
- }
- av_dlog(s->avctx, "mb_type=%x\n", mb_type);
-// motion_type = 0; /* avoid warning */
- if (IS_INTRA(mb_type)) {
- s->dsp.clear_blocks(s->block[0]);
-
- 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) {
- s->interlaced_dct = get_bits1(&s->gb);
- }
-
- if (IS_QUANT(mb_type))
- s->qscale = get_qscale(s);
-
- if (s->concealment_motion_vectors) {
- /* just parse them */
- if (s->picture_structure != PICT_FRAME)
- 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]);
-
- skip_bits1(&s->gb); /* marker */
- } else
- memset(s->last_mv, 0, sizeof(s->last_mv)); /* reset mv prediction */
- s->mb_intra = 1;
- // if 1, we memcpy blocks in xvmcvideo
- if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration > 1) {
- ff_xvmc_pack_pblocks(s, -1); // inter are always full blocks
- if (s->swap_uv) {
- exchange_uv(s);
- }
- }
-
- if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
- if (s->flags2 & CODEC_FLAG2_FAST) {
- 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++) {
- if (mpeg2_decode_block_intra(s, *s->pblocks[i], i) < 0)
- return -1;
- }
- }
- } else {
- 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) {
- av_assert2(mb_type & MB_TYPE_CBP);
-
- s->mv_dir = MV_DIR_FORWARD;
- if (s->picture_structure == PICT_FRAME) {
- if (s->picture_structure == PICT_FRAME
- && !s->frame_pred_frame_dct)
- 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->field_select[0][0] = s->picture_structure - 1;
- }
-
- if (IS_QUANT(mb_type))
- s->qscale = get_qscale(s);
-
- s->last_mv[0][0][0] = 0;
- 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;
- } 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)
- motion_type = MT_FRAME;
- 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);
- }
-
- if (IS_QUANT(mb_type))
- s->qscale = get_qscale(s);
-
- /* motion vectors */
- s->mv_dir = (mb_type >> 13) & 3;
- av_dlog(s->avctx, "motion_type=%d\n", motion_type);
- switch (motion_type) {
- case MT_FRAME: /* or MT_16X8 */
- if (s->picture_structure == PICT_FRAME) {
- 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]);
- /* full_pel: only for MPEG-1 */
- if (s->full_pel[i]) {
- s->mv[i][0][0] <<= 1;
- s->mv[i][0][1] <<= 1;
- }
- }
- }
- } else {
- 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)) {
- /* MT_16X8 */
- for (j = 0; j < 2; j++) {
- s->field_select[i][j] = get_bits1(&s->gb);
- for (k = 0; k < 2; k++) {
- val = mpeg_decode_motion(s, s->mpeg_f_code[i][k],
- s->last_mv[i][j][k]);
- s->last_mv[i][j][k] = val;
- s->mv[i][j][k] = val;
- }
- }
- }
- }
- }
- break;
- case MT_FIELD:
- s->mv_type = MV_TYPE_FIELD;
- if (s->picture_structure == PICT_FRAME) {
- mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
- for (i = 0; i < 2; i++) {
- if (USES_LIST(mb_type, i)) {
- for (j = 0; j < 2; j++) {
- s->field_select[i][j] = get_bits1(&s->gb);
- val = mpeg_decode_motion(s, s->mpeg_f_code[i][0],
- s->last_mv[i][j][0]);
- s->last_mv[i][j][0] = val;
- s->mv[i][j][0] = val;
- av_dlog(s->avctx, "fmx=%d\n", val);
- val = mpeg_decode_motion(s, s->mpeg_f_code[i][1],
- s->last_mv[i][j][1] >> 1);
- s->last_mv[i][j][1] = val << 1;
- s->mv[i][j][1] = val;
- av_dlog(s->avctx, "fmy=%d\n", val);
- }
- }
- }
- } else {
- av_assert0(!s->progressive_sequence);
- mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;
- for (i = 0; i < 2; i++) {
- if (USES_LIST(mb_type, i)) {
- s->field_select[i][0] = get_bits1(&s->gb);
- for (k = 0; k < 2; k++) {
- val = mpeg_decode_motion(s, s->mpeg_f_code[i][k],
- s->last_mv[i][0][k]);
- s->last_mv[i][0][k] = val;
- s->last_mv[i][1][k] = val;
- s->mv[i][0][k] = val;
- }
- }
- }
- }
- break;
- case MT_DMV:
- if(s->progressive_sequence){
- av_log(s->avctx, AV_LOG_ERROR, "MT_DMV in progressive_sequence\n");
- return -1;
- }
- s->mv_type = MV_TYPE_DMV;
- for (i = 0; i < 2; i++) {
- if (USES_LIST(mb_type, i)) {
- int dmx, dmy, mx, my, m;
- const int my_shift = s->picture_structure == PICT_FRAME;
-
- mx = mpeg_decode_motion(s, s->mpeg_f_code[i][0],
- s->last_mv[i][0][0]);
- s->last_mv[i][0][0] = mx;
- s->last_mv[i][1][0] = mx;
- dmx = get_dmv(s);
- my = mpeg_decode_motion(s, s->mpeg_f_code[i][1],
- s->last_mv[i][0][1] >> my_shift);
- dmy = get_dmv(s);
-
-
- s->last_mv[i][0][1] = my << my_shift;
- s->last_mv[i][1][1] = my << my_shift;
-
- s->mv[i][0][0] = mx;
- s->mv[i][0][1] = my;
- s->mv[i][1][0] = mx; // not used
- s->mv[i][1][1] = my; // not used
-
- if (s->picture_structure == PICT_FRAME) {
- mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED;
-
- // m = 1 + 2 * s->top_field_first;
- m = s->top_field_first ? 1 : 3;
-
- /* top -> top pred */
- s->mv[i][2][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
- s->mv[i][2][1] = ((my * m + (my > 0)) >> 1) + dmy - 1;
- m = 4 - m;
- s->mv[i][3][0] = ((mx * m + (mx > 0)) >> 1) + dmx;
- s->mv[i][3][1] = ((my * m + (my > 0)) >> 1) + dmy + 1;
- } else {
- mb_type |= MB_TYPE_16x16;
-
- s->mv[i][2][0] = ((mx + (mx > 0)) >> 1) + dmx;
- s->mv[i][2][1] = ((my + (my > 0)) >> 1) + dmy;
- if (s->picture_structure == PICT_TOP_FIELD)
- s->mv[i][2][1]--;
- else
- s->mv[i][2][1]++;
- }
- }
- }
- break;
- default:
- av_log(s->avctx, AV_LOG_ERROR, "00 motion_type at %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
- }
-
- s->mb_intra = 0;
- if (HAS_CBP(mb_type)) {
- s->dsp.clear_blocks(s->block[0]);
-
- cbp = get_vlc2(&s->gb, 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]);
- }
- if (cbp <= 0) {
- av_log(s->avctx, AV_LOG_ERROR, "invalid cbp %d at %d %d\n", cbp, s->mb_x, s->mb_y);
- return -1;
- }
-
- //if 1, we memcpy blocks in xvmcvideo
- if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration > 1) {
- ff_xvmc_pack_pblocks(s, cbp);
- if (s->swap_uv) {
- exchange_uv(s);
- }
- }
-
- if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
- if (s->flags2 & CODEC_FLAG2_FAST) {
- for (i = 0; i < 6; i++) {
- if (cbp & 32) {
- mpeg2_fast_decode_block_non_intra(s, *s->pblocks[i], i);
- } else {
- s->block_last_index[i] = -1;
- }
- cbp += cbp;
- }
- } else {
- cbp <<= 12-mb_block_count;
-
- for (i = 0; i < mb_block_count; i++) {
- if (cbp & (1 << 11)) {
- if (mpeg2_decode_block_non_intra(s, *s->pblocks[i], i) < 0)
- return -1;
- } else {
- s->block_last_index[i] = -1;
- }
- cbp += cbp;
- }
- }
- } else {
- if (s->flags2 & CODEC_FLAG2_FAST) {
- for (i = 0; i < 6; i++) {
- if (cbp & 32) {
- mpeg1_fast_decode_block_inter(s, *s->pblocks[i], i);
- } else {
- s->block_last_index[i] = -1;
- }
- cbp += cbp;
- }
- } else {
- for (i = 0; i < 6; i++) {
- if (cbp & 32) {
- if (mpeg1_decode_block_inter(s, *s->pblocks[i], i) < 0)
- return -1;
- } else {
- s->block_last_index[i] = -1;
- }
- cbp += cbp;
- }
- }
- }
- } else {
- for (i = 0; i < 12; i++)
- s->block_last_index[i] = -1;
- }
- }
-
- s->current_picture.f.mb_type[s->mb_x + s->mb_y * s->mb_stride] = mb_type;
-
- return 0;
-}
-
-static av_cold int mpeg_decode_init(AVCodecContext *avctx)
-{
- 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;
-
- ff_MPV_decode_defaults(s2);
-
- s->mpeg_enc_ctx.avctx = avctx;
- s->mpeg_enc_ctx.flags = avctx->flags;
- s->mpeg_enc_ctx.flags2 = avctx->flags2;
- ff_mpeg12_common_init(&s->mpeg_enc_ctx);
- ff_mpeg12_init_vlcs();
-
- s->mpeg_enc_ctx_allocated = 0;
- 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;
- if (avctx->codec->id == AV_CODEC_ID_MPEG1VIDEO)
- avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
- else
- avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
- return 0;
-}
-
-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)
- return 0;
-
- err = ff_mpeg_update_thread_context(avctx, avctx_from);
- if (err) return err;
-
- if (!ctx->mpeg_enc_ctx_allocated)
- memcpy(s + 1, s1 + 1, sizeof(Mpeg1Context) - sizeof(MpegEncContext));
-
- if (!(s->pict_type == AV_PICTURE_TYPE_B || s->low_delay))
- s->picture_number++;
-
- return 0;
-}
-
-static void quant_matrix_rebuild(uint16_t *matrix, const uint8_t *old_perm,
- const uint8_t *new_perm)
-{
- uint16_t temp_matrix[64];
- int i;
-
- memcpy(temp_matrix, matrix, 64 * sizeof(uint16_t));
-
- for (i = 0; i < 64; i++) {
- matrix[new_perm[i]] = temp_matrix[old_perm[i]];
- }
-}
-
-static enum AVPixelFormat mpeg_get_pixelformat(AVCodecContext *avctx)
-{
- Mpeg1Context *s1 = avctx->priv_data;
- MpegEncContext *s = &s1->mpeg_enc_ctx;
-
- if(s->chroma_format < 2) {
- // ==> Start patch MPC
- return AV_PIX_FMT_YUV420P;
- // ==> End patch MPC
- } else if(s->chroma_format == 2)
- return AV_PIX_FMT_YUV422P;
- else
- return AV_PIX_FMT_YUV444P;
-}
-
-/* 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;
- MpegEncContext *s = &s1->mpeg_enc_ctx;
- uint8_t old_permutation[64];
-
- 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 ||
- 0)
- {
-
- if (s1->mpeg_enc_ctx_allocated) {
- ParseContext pc = s->parse_context;
- s->parse_context.buffer = 0;
- ff_MPV_common_end(s);
- s->parse_context = pc;
- }
-
- if ((s->width == 0) || (s->height == 0))
- return -2;
-
- avcodec_set_dimensions(avctx, s->width, s->height);
- if (avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO && s->bit_rate) {
- avctx->rc_max_rate = s->bit_rate;
- } else if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO && s->bit_rate &&
- (s->bit_rate != 0x3FFFF*400 || s->vbv_delay != 0xFFFF)) {
- avctx->bit_rate = s->bit_rate;
- }
- s1->save_aspect_info = s->aspect_ratio_info;
- s1->save_width = s->width;
- s1->save_height = s->height;
- s1->save_progressive_seq = s->progressive_sequence;
-
- /* low_delay may be forced, in this case we will have B-frames
- * that behave like P-frames. */
- avctx->has_b_frames = !s->low_delay;
-
- if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
- //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
- 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].den * s1->frame_rate_ext.den,
- 1 << 30);
- avctx->ticks_per_frame = 2;
- //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
- 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}))) {
- s->avctx->sample_aspect_ratio =
- av_div_q(ff_mpeg2_aspect[s->aspect_ratio_info],
- (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
-// 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);
- av_dlog(avctx, "B %d/%d\n", s->avctx->sample_aspect_ratio.num,
- s->avctx->sample_aspect_ratio.den);
- }
- } else {
- s->avctx->sample_aspect_ratio =
- ff_mpeg2_aspect[s->aspect_ratio_info];
- }
- } // MPEG-2
-
- avctx->pix_fmt = mpeg_get_pixelformat(avctx);
- avctx->hwaccel = ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt);
- // until then pix_fmt may be changed right after codec init
- if (avctx->pix_fmt == AV_PIX_FMT_XVMC_MPEG2_IDCT ||
- avctx->hwaccel )
- if (avctx->idct_algo == FF_IDCT_AUTO)
- avctx->idct_algo = FF_IDCT_SIMPLE;
-
- /* Quantization matrices may need reordering
- * if DCT permutation is changed. */
- memcpy(old_permutation, s->dsp.idct_permutation, 64 * sizeof(uint8_t));
-
- if (ff_MPV_common_init(s) < 0)
- return -2;
-
- quant_matrix_rebuild(s->intra_matrix, old_permutation, s->dsp.idct_permutation);
- quant_matrix_rebuild(s->inter_matrix, old_permutation, s->dsp.idct_permutation);
- quant_matrix_rebuild(s->chroma_intra_matrix, old_permutation, s->dsp.idct_permutation);
- quant_matrix_rebuild(s->chroma_inter_matrix, old_permutation, s->dsp.idct_permutation);
-
- s1->mpeg_enc_ctx_allocated = 1;
- }
- return 0;
-}
-
-static int mpeg1_decode_picture(AVCodecContext *avctx,
- const uint8_t *buf, int buf_size)
-{
- 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);
-
- ref = get_bits(&s->gb, 10); /* temporal ref */
- s->pict_type = get_bits(&s->gb, 3);
- if (s->pict_type == 0 || s->pict_type > 3)
- return -1;
-
- 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) {
- 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)))
- return -1;
- f_code += !f_code;
- s->mpeg_f_code[0][0] = f_code;
- s->mpeg_f_code[0][1] = f_code;
- }
- if (s->pict_type == AV_PICTURE_TYPE_B) {
- s->full_pel[1] = get_bits1(&s->gb);
- f_code = get_bits(&s->gb, 3);
- if (f_code == 0 && (avctx->err_recognition & (AV_EF_BITSTREAM|AV_EF_COMPLIANT)))
- return -1;
- f_code += !f_code;
- 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;
-
- 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);
-
- s->y_dc_scale = 8;
- s->c_dc_scale = 8;
- return 0;
-}
-
-static void mpeg_decode_sequence_extension(Mpeg1Context *s1)
-{
- 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->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);
- s->width |= (horiz_size_ext << 12);
- s->height |= (vert_size_ext << 12);
- bit_rate_ext = get_bits(&s->gb, 12); /* XXX: handle it */
- s->bit_rate += (bit_rate_ext << 18) * 400;
- skip_bits1(&s->gb); /* marker */
- s->avctx->rc_buffer_size += get_bits(&s->gb, 8) * 1024 * 16 << 10;
-
- s->low_delay = get_bits1(&s->gb);
- if (s->flags & CODEC_FLAG_LOW_DELAY)
- s->low_delay = 1;
-
- s1->frame_rate_ext.num = get_bits(&s->gb, 2) + 1;
- 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;
-
- if (s->avctx->debug & FF_DEBUG_PICT_INFO)
- av_log(s->avctx, AV_LOG_DEBUG, "profile: %d, level: %d vbv buffer: %d, bitrate:%d\n",
- s->avctx->profile, s->avctx->level, s->avctx->rc_buffer_size, s->bit_rate);
-
-}
-
-static void mpeg_decode_sequence_display_extension(Mpeg1Context *s1)
-{
- MpegEncContext *s = &s1->mpeg_enc_ctx;
- int color_description, w, h;
-
- skip_bits(&s->gb, 3); /* video format */
- color_description = get_bits1(&s->gb);
- if (color_description) {
- s->avctx->color_primaries = get_bits(&s->gb, 8);
- s->avctx->color_trc = get_bits(&s->gb, 8);
- s->avctx->colorspace = get_bits(&s->gb, 8);
- }
- w = get_bits(&s->gb, 14);
- skip_bits(&s->gb, 1); //marker
- h = get_bits(&s->gb, 14);
- // remaining 3 bits are zero padding
-
- s1->pan_scan.width = 16 * w;
- s1->pan_scan.height = 16 * h;
-
- if (s->avctx->debug & FF_DEBUG_PICT_INFO)
- av_log(s->avctx, AV_LOG_DEBUG, "sde w:%d, h:%d\n", w, h);
-}
-
-static void mpeg_decode_picture_display_extension(Mpeg1Context *s1)
-{
- MpegEncContext *s = &s1->mpeg_enc_ctx;
- int i, nofco;
-
- nofco = 1;
- if (s->progressive_sequence) {
- if (s->repeat_first_field) {
- nofco++;
- if (s->top_field_first)
- nofco++;
- }
- } else {
- if (s->picture_structure == PICT_FRAME) {
- nofco++;
- if (s->repeat_first_field)
- nofco++;
- }
- }
- for (i = 0; i < nofco; i++) {
- s1->pan_scan.position[i][0] = get_sbits(&s->gb, 16);
- skip_bits(&s->gb, 1); // marker
- s1->pan_scan.position[i][1] = get_sbits(&s->gb, 16);
- skip_bits(&s->gb, 1); // marker
- }
-
- if (s->avctx->debug & FF_DEBUG_PICT_INFO)
- av_log(s->avctx, AV_LOG_DEBUG, "pde (%d,%d) (%d,%d) (%d,%d)\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)
-{
- int i;
-
- for (i = 0; i < 64; i++) {
- int j = s->dsp.idct_permutation[ff_zigzag_direct[i]];
- int v = get_bits(&s->gb, 8);
- if (v == 0) {
- av_log(s->avctx, AV_LOG_ERROR, "matrix damaged\n");
- return -1;
- }
- if (intra && i == 0 && v != 8) {
- av_log(s->avctx, AV_LOG_DEBUG, "intra matrix specifies invalid DC quantizer %d, ignoring\n", v);
- v = 8; // needed by pink.mpg / issue1046
- }
- matrix0[j] = v;
- if (matrix1)
- matrix1[j] = v;
- }
- return 0;
-}
-
-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);
-}
-
-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->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");
- 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;
- else
- 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->mpeg_f_code[0][0] += !s->mpeg_f_code[0][0];
- s->mpeg_f_code[0][1] += !s->mpeg_f_code[0][1];
- s->mpeg_f_code[1][0] += !s->mpeg_f_code[1][0];
- s->mpeg_f_code[1][1] += !s->mpeg_f_code[1][1];
-
- s->intra_dc_precision = get_bits(&s->gb, 2);
- s->picture_structure = get_bits(&s->gb, 2);
- s->top_field_first = get_bits1(&s->gb);
- s->frame_pred_frame_dct = get_bits1(&s->gb);
- s->concealment_motion_vectors = get_bits1(&s->gb);
- s->q_scale_type = get_bits1(&s->gb);
- s->intra_vlc_format = get_bits1(&s->gb);
- s->alternate_scan = get_bits1(&s->gb);
- s->repeat_first_field = get_bits1(&s->gb);
- 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);
- } else {
- ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable, ff_zigzag_direct);
- ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable, ff_zigzag_direct);
- }
-
- /* composite display not parsed */
- av_dlog(s->avctx, "intra_dc_precision=%d\n", s->intra_dc_precision);
- av_dlog(s->avctx, "picture_structure=%d\n", s->picture_structure);
- av_dlog(s->avctx, "top field first=%d\n", s->top_field_first);
- av_dlog(s->avctx, "repeat first field=%d\n", s->repeat_first_field);
- av_dlog(s->avctx, "conceal=%d\n", s->concealment_motion_vectors);
- av_dlog(s->avctx, "intra_vlc_format=%d\n", s->intra_vlc_format);
- av_dlog(s->avctx, "alternate_scan=%d\n", s->alternate_scan);
- av_dlog(s->avctx, "frame_pred_frame_dct=%d\n", s->frame_pred_frame_dct);
- av_dlog(s->avctx, "progressive_frame=%d\n", s->progressive_frame);
-}
-
-static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
-{
- AVCodecContext *avctx = s->avctx;
- Mpeg1Context *s1 = (Mpeg1Context*)s;
-
- /* start frame decoding */
- if (s->first_field || s->picture_structure == PICT_FRAME) {
- if (ff_MPV_frame_start(s, avctx) < 0)
- return -1;
-
- ff_er_frame_start(s);
-
- /* first check if we must repeat the frame */
- 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;
- else
- 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.pan_scan = s1->pan_scan;
-
- if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_FRAME))
- ff_thread_finish_setup(avctx);
- } else { // second field
- int i;
-
- if (!s->current_picture_ptr) {
- av_log(s->avctx, AV_LOG_ERROR, "first field missing\n");
- return -1;
- }
-
- 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");
- }
-
- 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];
- }
- }
- }
-
- if (avctx->hwaccel) {
- if (avctx->hwaccel->start_frame(avctx, buf, buf_size) < 0)
- return -1;
- }
-
-// 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;
-
- return 0;
-}
-
-#define DECODE_SLICE_ERROR -1
-#define DECODE_SLICE_OK 0
-
-/**
- * Decode a slice.
- * MpegEncContext.mb_y must be set to the MB row from the startcode.
- * @return DECODE_SLICE_ERROR if the slice is damaged,
- * DECODE_SLICE_OK if this slice is OK
- */
-static int mpeg_decode_slice(MpegEncContext *s, int mb_y,
- const uint8_t **buf, int buf_size)
-{
- AVCodecContext *avctx = s->avctx;
- const int lowres = s->avctx->lowres;
- const int field_pic = s->picture_structure != PICT_FRAME;
-
- s->resync_mb_x =
- s->resync_mb_y = -1;
-
- 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)
- skip_bits(&s->gb, 3);
-
- ff_mpeg1_clean_buffers(s);
- s->interlaced_dct = 0;
-
- s->qscale = get_qscale(s);
-
- if (s->qscale == 0) {
- av_log(s->avctx, AV_LOG_ERROR, "qscale == 0\n");
- return -1;
- }
-
- /* extra slice info */
- while (get_bits1(&s->gb) != 0) {
- skip_bits(&s->gb, 8);
- }
-
- s->mb_x = 0;
-
- if (mb_y == 0 && s->codec_tag == AV_RL32("SLIF")) {
- skip_bits1(&s->gb);
- } else {
- while (get_bits_left(&s->gb) > 0) {
- int code = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2);
- if (code < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "first mb_incr damaged\n");
- return -1;
- }
- if (code >= 33) {
- if (code == 33) {
- s->mb_x += 33;
- }
- /* otherwise, stuffing, nothing to do */
- } else {
- s->mb_x += code;
- break;
- }
- }
- }
-
- if (s->mb_x >= (unsigned)s->mb_width) {
- av_log(s->avctx, AV_LOG_ERROR, "initial skip overflow\n");
- return -1;
- }
-
- if (avctx->hwaccel) {
- const uint8_t *buf_end, *buf_start = *buf - 4; /* include start_code */
- int start_code = -1;
- buf_end = avpriv_mpv_find_start_code(buf_start + 2, *buf + buf_size, &start_code);
- if (buf_end < *buf + buf_size)
- buf_end -= 4;
- s->mb_y = mb_y;
- if (avctx->hwaccel->decode_slice(avctx, buf_start, buf_end - buf_start) < 0)
- return DECODE_SLICE_ERROR;
- *buf = buf_end;
- return DECODE_SLICE_OK;
- }
-
- // ==> Start patch MPC
- if (s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) {
- Mpeg1Context *s1 = (Mpeg1Context*)s;
- const uint8_t *buf_end, *buf_start = *buf - 4; /* include start_code */
- const uint8_t *buffer;
- uint32_t size;
- int start_code = -1;
- int is_field = s->picture_structure != PICT_FRAME;
- GetBitContext gb;
-
- buf_end = avpriv_mpv_find_start_code(buf_start + 2, *buf + buf_size, &start_code);
- if (buf_end < *buf + buf_size)
- buf_end -= 4;
- s->mb_y = mb_y;
-
- buffer = buf_start;
- size = buf_end - buf_start;
-
- s1->pSliceInfo[s1->slice_count].wHorizontalPosition = s->mb_x;
- s1->pSliceInfo[s1->slice_count].wVerticalPosition = s->mb_y >> is_field;
- s1->pSliceInfo[s1->slice_count].dwSliceBitsInBuffer = 8 * size;
- s1->pSliceInfo[s1->slice_count].bStartCodeBitOffset = 0;
- s1->pSliceInfo[s1->slice_count].bReservedBits = 0;
- s1->pSliceInfo[s1->slice_count].wNumberMBsInSlice = (s->mb_y >> is_field) * s->mb_width + s->mb_x;//s->mb_width;
- s1->pSliceInfo[s1->slice_count].wBadSliceChopping = 0;
-
- init_get_bits(&gb, &buffer[4], 8 * (size - 4));
- s1->pSliceInfo[s1->slice_count].wQuantizerScaleCode = get_bits(&gb, 5);
- while (get_bits1(&gb))
- skip_bits(&gb, 8);
-
- s1->pSliceInfo[s1->slice_count].wMBbitOffset = 4 * 8 + get_bits_count(&gb);
- if (s1->slice_count>0) {
- s1->pSliceInfo[s1->slice_count-1].dwSliceBitsInBuffer = (buffer - s1->prev_slice)*8;
- s1->pSliceInfo[s1->slice_count].dwSliceDataLocation = s1->pSliceInfo[s1->slice_count-1].dwSliceDataLocation +
- s1->pSliceInfo[s1->slice_count-1].dwSliceBitsInBuffer/8;
- }
-
- s1->prev_slice = (uint8_t*)buffer;
- s1->slice_count++;
-
- *buf = buf_end;
- return 0;
- }
- // <== End patch MPC
-
- s->resync_mb_x = s->mb_x;
- s->resync_mb_y = s->mb_y = mb_y;
- s->mb_skip_run = 0;
- ff_init_block_index(s);
-
- 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" :"");
- }
- }
-
- for (;;) {
- // If 1, we memcpy blocks in xvmcvideo.
- if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration > 1)
- ff_xvmc_init_block(s); // set s->block
-
- if (mpeg_decode_mb(s, s->block) < 0)
- return -1;
-
- if (s->current_picture.f.motion_val[0] && !s->encoding) { // note motion_val is normally NULL unless we want to extract the MVs
- 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);
- int motion_x, motion_y, dir, i;
-
- 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)) {
- motion_x = motion_y = 0;
- } 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))*/ {
- motion_x = s->mv[dir][i][0];
- motion_y = s->mv[dir][i][1];
- }
-
- s->current_picture.f.motion_val[dir][xy ][0] = motion_x;
- s->current_picture.f.motion_val[dir][xy ][1] = motion_y;
- s->current_picture.f.motion_val[dir][xy + 1][0] = motion_x;
- s->current_picture.f.motion_val[dir][xy + 1][1] = motion_y;
- s->current_picture.f.ref_index [dir][b8_xy ] =
- s->current_picture.f.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);
- }
- xy += wrap;
- b8_xy +=2;
- }
- }
-
- s->dest[0] += 16 >> lowres;
- s->dest[1] +=(16 >> lowres) >> s->chroma_x_shift;
- s->dest[2] +=(16 >> lowres) >> s->chroma_x_shift;
-
- ff_MPV_decode_mb(s, s->block);
-
- if (++s->mb_x >= s->mb_width) {
- const int mb_size = 16 >> s->avctx->lowres;
-
- ff_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_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*/;
-
- 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;
- }
-
- ff_init_block_index(s);
- }
-
- /* skip mb handling */
- if (s->mb_skip_run == -1) {
- /* read increment again */
- s->mb_skip_run = 0;
- for (;;) {
- int code = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2);
- if (code < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "mb incr damaged\n");
- return -1;
- }
- if (code >= 33) {
- if (code == 33) {
- s->mb_skip_run += 33;
- } else if (code == 35) {
- if (s->mb_skip_run != 0 || show_bits(&s->gb, 15) != 0) {
- av_log(s->avctx, AV_LOG_ERROR, "slice mismatch\n");
- return -1;
- }
- goto eos; /* end of slice */
- }
- /* otherwise, stuffing, nothing to do */
- } else {
- s->mb_skip_run += code;
- break;
- }
- }
- 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);
- return -1;
- }
-
- /* skip mb */
- s->mb_intra = 0;
- for (i = 0; i < 12; i++)
- s->block_last_index[i] = -1;
- if (s->picture_structure == PICT_FRAME)
- s->mv_type = MV_TYPE_16X16;
- else
- s->mv_type = MV_TYPE_FIELD;
- if (s->pict_type == AV_PICTURE_TYPE_P) {
- /* if P type, zero motion vector is implied */
- s->mv_dir = MV_DIR_FORWARD;
- s->mv[0][0][0] = s->mv[0][0][1] = 0;
- s->last_mv[0][0][0] = s->last_mv[0][0][1] = 0;
- s->last_mv[0][1][0] = s->last_mv[0][1][1] = 0;
- s->field_select[0][0] = (s->picture_structure - 1) & 1;
- } else {
- /* if B type, reuse previous vectors and directions */
- s->mv[0][0][0] = s->last_mv[0][0][0];
- s->mv[0][0][1] = s->last_mv[0][0][1];
- s->mv[1][0][0] = s->last_mv[1][0][0];
- s->mv[1][0][1] = s->last_mv[1][0][1];
- }
- }
- }
- }
-eos: // end of slice
- *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;
- const uint8_t *buf = s->gb.buffer;
- int mb_y = s->start_mb_y;
- const int field_pic = s->picture_structure != PICT_FRAME;
-
- s->error_count = (3 * (s->end_mb_y - s->start_mb_y) * s->mb_width) >> field_pic;
-
- for (;;) {
- uint32_t start_code;
- int ret;
-
- ret = mpeg_decode_slice(s, mb_y, &buf, s->gb.buffer_end - buf);
- emms_c();
- av_dlog(c, "ret:%d resync:%d/%d mb:%d/%d ts:%d/%d ec:%d\n",
- ret, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y,
- s->start_mb_y, s->end_mb_y, s->error_count);
- if (ret < 0) {
- 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, 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, 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_mpv_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)
- mb_y++;
- if (mb_y < 0 || mb_y >= s->end_mb_y)
- return -1;
- }
-}
-
-/**
- * Handle slice ends.
- * @return 1 if it seems to be the last slice
- */
-static int slice_end(AVCodecContext *avctx, AVFrame *pict)
-{
- Mpeg1Context *s1 = avctx->priv_data;
- MpegEncContext *s = &s1->mpeg_enc_ctx;
-
- if (!s1->mpeg_enc_ctx_allocated || !s->current_picture_ptr)
- return 0;
-
- 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");
- }
-
- if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)
- ff_xvmc_field_end(s);
-
- /* end of slice reached */
- if (/*s->mb_y << field_pic == s->mb_height &&*/ !s->first_field && !s->first_slice) {
- /* end of image */
-
- s->current_picture_ptr->f.qscale_type = FF_QSCALE_TYPE_MPEG2;
-
- // ==> Start patch MPC
- if (!s->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
- // ==> End patch MPC
- ff_er_frame_end(s);
-
- ff_MPV_frame_end(s);
-
- if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
- *pict = s->current_picture_ptr->f;
- ff_print_debug_info(s, pict);
- } else {
- if (avctx->active_thread_type & FF_THREAD_FRAME)
- s->picture_number++;
- /* latency of 1 frame for I- and P-frames */
- /* XXX: use another variable than picture_number */
- if (s->last_picture_ptr != NULL) {
- *pict = s->last_picture_ptr->f;
- ff_print_debug_info(s, pict);
- }
- }
-
- return 1;
- } else {
- return 0;
- }
-}
-
-static int mpeg1_decode_sequence(AVCodecContext *avctx,
- const uint8_t *buf, int buf_size)
-{
- 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);
-
- width = get_bits(&s->gb, 12);
- height = get_bits(&s->gb, 12);
- s->aspect_ratio_info = get_bits(&s->gb, 4);
- if (s->aspect_ratio_info == 0) {
- av_log(avctx, AV_LOG_ERROR, "aspect ratio has forbidden 0 value\n");
- if (avctx->err_recognition & (AV_EF_BITSTREAM | AV_EF_COMPLIANT))
- return -1;
- }
- s->frame_rate_index = get_bits(&s->gb, 4);
- if (s->frame_rate_index == 0 || s->frame_rate_index > 13)
- return -1;
- s->bit_rate = get_bits(&s->gb, 18) * 400;
- if (get_bits1(&s->gb) == 0) /* marker */
- return -1;
- s->width = width;
- s->height = height;
-
- s->avctx->rc_buffer_size = get_bits(&s->gb, 10) * 1024 * 16;
- skip_bits(&s->gb, 1);
-
- /* get matrix */
- if (get_bits1(&s->gb)) {
- load_matrix(s, s->chroma_intra_matrix, s->intra_matrix, 1);
- } else {
- for (i = 0; i < 64; i++) {
- j = s->dsp.idct_permutation[i];
- v = ff_mpeg1_default_intra_matrix[i];
- s->intra_matrix[j] = v;
- s->chroma_intra_matrix[j] = v;
- }
- }
- if (get_bits1(&s->gb)) {
- load_matrix(s, s->chroma_inter_matrix, s->inter_matrix, 0);
- } else {
- for (i = 0; i < 64; i++) {
- int j = s->dsp.idct_permutation[i];
- v = ff_mpeg1_default_non_intra_matrix[i];
- s->inter_matrix[j] = v;
- s->chroma_inter_matrix[j] = v;
- }
- }
-
- if (show_bits(&s->gb, 23) != 0) {
- av_log(s->avctx, AV_LOG_ERROR, "sequence header damaged\n");
- return -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->out_format = FMT_MPEG1;
- s->swap_uv = 0; // AFAIK VCR2 does not have SEQ_HEADER
- if (s->flags & CODEC_FLAG_LOW_DELAY)
- s->low_delay = 1;
-
- if (s->avctx->debug & FF_DEBUG_PICT_INFO)
- av_log(s->avctx, AV_LOG_DEBUG, "vbv buffer: %d, bitrate:%d\n",
- s->avctx->rc_buffer_size, s->bit_rate);
-
- return 0;
-}
-
-static int vcr2_init_sequence(AVCodecContext *avctx)
-{
- Mpeg1Context *s1 = avctx->priv_data;
- MpegEncContext *s = &s1->mpeg_enc_ctx;
- int i, v;
-
- /* start new MPEG-1 context decoding */
- s->out_format = FMT_MPEG1;
- if (s1->mpeg_enc_ctx_allocated) {
- ff_MPV_common_end(s);
- }
- s->width = avctx->coded_width;
- s->height = avctx->coded_height;
- avctx->has_b_frames = 0; // true?
- s->low_delay = 1;
-
- avctx->pix_fmt = mpeg_get_pixelformat(avctx);
- avctx->hwaccel = ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt);
-
- if( avctx->pix_fmt == AV_PIX_FMT_XVMC_MPEG2_IDCT || avctx->hwaccel )
- if (avctx->idct_algo == FF_IDCT_AUTO)
- avctx->idct_algo = FF_IDCT_SIMPLE;
-
- if (ff_MPV_common_init(s) < 0)
- return -1;
- s1->mpeg_enc_ctx_allocated = 1;
-
- for (i = 0; i < 64; i++) {
- int j = s->dsp.idct_permutation[i];
- v = ff_mpeg1_default_intra_matrix[i];
- s->intra_matrix[j] = v;
- s->chroma_intra_matrix[j] = v;
-
- v = ff_mpeg1_default_non_intra_matrix[i];
- s->inter_matrix[j] = v;
- s->chroma_inter_matrix[j] = v;
- }
-
- 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;
- if (s->codec_tag == AV_RL32("BW10")) {
- s->codec_id = s->avctx->codec_id = AV_CODEC_ID_MPEG1VIDEO;
- } else {
- exchange_uv(s); // common init reset pblocks, so we swap them here
- s->swap_uv = 1; // in case of xvmc we need to swap uv for each MB
- s->codec_id = s->avctx->codec_id = AV_CODEC_ID_MPEG2VIDEO;
- }
- s1->save_width = s->width;
- s1->save_height = s->height;
- s1->save_progressive_seq = s->progressive_sequence;
- return 0;
-}
-
-
-static void mpeg_decode_user_data(AVCodecContext *avctx,
- const uint8_t *p, int buf_size)
-{
- Mpeg1Context *s = avctx->priv_data;
- const uint8_t *buf_end = p + buf_size;
-
- if(buf_size > 29){
- int i;
- for(i=0; i<20; i++)
- if(!memcmp(p+i, "\0TMPGEXS\0", 9)){
- s->tmpgexs= 1;
- }
-
-/* for(i=0; !(!p[i-2] && !p[i-1] && p[i]==1) && i<buf_size; i++){
- av_log(avctx, AV_LOG_ERROR, "%c", p[i]);
- }
- av_log(avctx, AV_LOG_ERROR, "\n");*/
- }
-
- /* we parse the DTG active format information */
- if (buf_end - p >= 5 &&
- p[0] == 'D' && p[1] == 'T' && p[2] == 'G' && p[3] == '1') {
- int flags = p[4];
- p += 5;
- if (flags & 0x80) {
- /* skip event id */
- p += 2;
- }
- if (flags & 0x40) {
- if (buf_end - p < 1)
- return;
- avctx->dtg_active_format = p[0] & 0x0f;
- }
- }
-}
-
-static void mpeg_decode_gop(AVCodecContext *avctx,
- const uint8_t *buf, int buf_size)
-{
- Mpeg1Context *s1 = avctx->priv_data;
- MpegEncContext *s = &s1->mpeg_enc_ctx;
- int broken_link;
- int64_t tc;
-
- 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 = get_bits1(&s->gb);
-
- if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
- char tcbuf[AV_TIMECODE_STR_SIZE];
- av_timecode_make_mpeg_tc_string(tcbuf, tc);
- av_log(s->avctx, AV_LOG_DEBUG,
- "GOP (%s) closed_gop=%d broken_link=%d\n",
- tcbuf, s->closed_gop, broken_link);
- }
-}
-/**
- * Find the end of the current frame in the bitstream.
- * @return the position of the first byte of the next frame, or -1
- */
-int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size, AVCodecParserContext *s)
-{
- int i;
- uint32_t state = pc->state;
-
- /* EOF considered as end of frame */
- if (buf_size == 0)
- return 0;
-
-/*
- 0 frame start -> 1/4
- 1 first_SEQEXT -> 0/2
- 2 first field start -> 3/0
- 3 second_SEQEXT -> 2/0
- 4 searching end
-*/
-
- for (i = 0; i < buf_size; i++) {
- av_assert1(pc->frame_start_found >= 0 && pc->frame_start_found <= 4);
- if (pc->frame_start_found & 1) {
- if (state == EXT_START_CODE && (buf[i] & 0xF0) != 0x80)
- pc->frame_start_found--;
- else if (state == EXT_START_CODE + 2) {
- if ((buf[i] & 3) == 3)
- pc->frame_start_found = 0;
- else
- pc->frame_start_found = (pc->frame_start_found + 1) & 3;
- }
- state++;
- } else {
- i = avpriv_mpv_find_start_code(buf + i, buf + buf_size, &state) - buf - 1;
- if (pc->frame_start_found == 0 && state >= SLICE_MIN_START_CODE && state <= SLICE_MAX_START_CODE) {
- i++;
- pc->frame_start_found = 4;
- }
- if (state == SEQ_END_CODE) {
- pc->frame_start_found = 0;
- pc->state=-1;
- return i+1;
- }
- if (pc->frame_start_found == 2 && state == SEQ_START_CODE)
- pc->frame_start_found = 0;
- if (pc->frame_start_found < 4 && state == EXT_START_CODE)
- pc->frame_start_found++;
- if (pc->frame_start_found == 4 && (state & 0xFFFFFF00) == 0x100) {
- if (state < SLICE_MIN_START_CODE || state > SLICE_MAX_START_CODE) {
- pc->frame_start_found = 0;
- pc->state = -1;
- return i - 3;
- }
- }
- if (pc->frame_start_found == 0 && s && state == PICTURE_START_CODE) {
- ff_fetch_timestamp(s, i - 3, 1);
- }
- }
- }
- pc->state = state;
- return END_NOT_FOUND;
-}
-
-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;
- const uint8_t *buf_ptr = buf;
- const uint8_t *buf_end = buf + buf_size;
- int ret, input_size;
- int last_code = 0;
-
- for (;;) {
- /* find next start code */
- uint32_t start_code = -1;
- buf_ptr = avpriv_mpv_find_start_code(buf_ptr, buf_end, &start_code);
- if (start_code > 0x1ff) {
- if (s2->pict_type != AV_PICTURE_TYPE_B || avctx->skip_frame <= AVDISCARD_DEFAULT) {
- if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE)) {
- int i;
- av_assert0(avctx->thread_count > 1);
-
- 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->error_count += s2->thread_context[i]->error_count;
- }
-
- if (CONFIG_VDPAU /*&& uses_vdpau(avctx)*/) // MPC patch
- ff_vdpau_mpeg_picture_complete(s2, buf, buf_size, s->slice_count);
-
-
- if (slice_end(avctx, picture)) {
- if (s2->last_picture_ptr || s2->low_delay) //FIXME merge with the stuff in mpeg_decode_slice
- *got_output = 1;
- }
- }
- s2->pict_type = 0;
- return FFMAX(0, buf_ptr - buf - s2->parse_context.last_index);
- }
-
- 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);
- }
-
- /* 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;
- } else {
- 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;
- }
- break;
-
- case PICTURE_START_CODE:
- if (s2->width <= 0 || s2->height <= 0) {
- av_log(avctx, AV_LOG_ERROR, "%dx%d is invalid\n", s2->width, s2->height);
- return AVERROR_INVALIDDATA;
- }
-
- if(s->tmpgexs){
- s2->intra_dc_precision= 3;
- s2->intra_matrix[0]= 1;
- }
- if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE) && s->slice_count) {
- int i;
-
- avctx->execute(avctx, slice_decode_thread,
- s2->thread_context, NULL,
- s->slice_count, sizeof(void*));
- for (i = 0; i < s->slice_count; i++)
- s2->error_count += s2->thread_context[i]->error_count;
- s->slice_count = 0;
- }
- 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");
- return ret;
- }
-
- /* we have a complete image: we try to decompress it */
- if (mpeg1_decode_picture(avctx, buf_ptr, input_size) < 0)
- s2->pict_type = 0;
- s2->first_slice = 1;
- last_code = PICTURE_START_CODE;
- } else {
- 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);
-
- switch (get_bits(&s2->gb, 4)) {
- case 0x1:
- if (last_code == 0) {
- mpeg_decode_sequence_extension(s);
- } else {
- av_log(avctx, AV_LOG_ERROR, "ignoring seq ext after %X\n", last_code);
- if (avctx->err_recognition & AV_EF_EXPLODE)
- return AVERROR_INVALIDDATA;
- }
- break;
- case 0x2:
- mpeg_decode_sequence_display_extension(s);
- break;
- case 0x3:
- mpeg_decode_quant_matrix_extension(s2);
- break;
- case 0x7:
- mpeg_decode_picture_display_extension(s);
- break;
- case 0x8:
- 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);
- if (avctx->err_recognition & AV_EF_EXPLODE)
- return AVERROR_INVALIDDATA;
- }
- break;
- }
- break;
- case USER_START_CODE:
- mpeg_decode_user_data(avctx, buf_ptr, input_size);
- break;
- case GOP_START_CODE:
- if (last_code == 0) {
- s2->first_field=0;
- mpeg_decode_gop(avctx, buf_ptr, input_size);
- s->sync=1;
- } else {
- 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;
- }
- break;
- 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");
- }
-
- 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) {
- av_log(s2->avctx, AV_LOG_WARNING, "invalid frame_pred_frame_dct\n");
- }
-
- if (s2->picture_structure == PICT_FRAME) {
- s2->first_field = 0;
- s2->v_edge_pos = 16 * s2->mb_height;
- } else {
- s2->first_field ^= 1;
- s2->v_edge_pos = 8 * s2->mb_height;
- memset(s2->mbskip_table, 0, s2->mb_stride * s2->mb_height);
- }
- }
- if (start_code >= SLICE_MIN_START_CODE &&
- start_code <= SLICE_MAX_START_CODE && last_code != 0) {
- 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)
- mb_y += (*buf_ptr&0xE0)<<2;
-
- mb_y <<= field_pic;
- if (s2->picture_structure == PICT_BOTTOM_FIELD)
- mb_y++;
-
- if (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 */
- if (s2->pict_type == AV_PICTURE_TYPE_B) {
- if (!s2->closed_gop)
- break;
- }
- }
- if (s2->pict_type == AV_PICTURE_TYPE_I || (s2->flags2 & CODEC_FLAG2_SHOW_ALL))
- 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. */
- if (s2->pict_type == AV_PICTURE_TYPE_P && !s->sync) 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)
- break;
-
- if (!s->mpeg_enc_ctx_allocated)
- break;
-
- if (s2->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
- if (mb_y < avctx->skip_top || mb_y >= s2->mb_height - avctx->skip_bottom)
- break;
- }
-
- if (!s2->pict_type) {
- av_log(avctx, AV_LOG_ERROR, "Missing picture start code\n");
- if (avctx->err_recognition & AV_EF_EXPLODE)
- return AVERROR_INVALIDDATA;
- break;
- }
-
- if (s2->first_slice) {
- s2->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");
- return AVERROR_INVALIDDATA;
- }
-
- // ==> Start patch MPC
- /*
- if (uses_vdpau(avctx)) {
- s->slice_count++;
- break;
- }
- */
- // <== End patch MPC
-
- if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE)) {
- int threshold = (s2->mb_height * s->slice_count +
- s2->slice_context_count / 2) /
- s2->slice_context_count;
- av_assert0(avctx->thread_count > 1);
- if (threshold <= mb_y) {
- MpegEncContext *thread_context = s2->thread_context[s->slice_count];
-
- 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);
- if (ret < 0)
- return ret;
- }
- 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
- } else {
- ret = mpeg_decode_slice(s2, mb_y, &buf_ptr, input_size);
- emms_c();
-
- if (ret < 0) {
- 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, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x, s2->mb_y, ER_AC_ERROR | ER_DC_ERROR | ER_MV_ERROR);
- // ==> Start patch MPC
- else if (!s2->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
- //} else {
- // <== End patch MPC
- ff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x-1, s2->mb_y, ER_AC_END | ER_DC_END | ER_MV_END);
- }
- }
- }
- break;
- }
- }
-}
-
-static int mpeg_decode_frame(AVCodecContext *avctx,
- void *data, int *got_output,
- AVPacket *avpkt)
-{
- const uint8_t *buf = avpkt->data;
- int ret;
- int buf_size = avpkt->size;
- 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) {
- *picture = s2->next_picture_ptr->f;
- s2->next_picture_ptr = NULL;
-
- *got_output = 1;
- }
- return buf_size;
- }
-
- if (s2->flags & CODEC_FLAG_TRUNCATED) {
- 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)
- return buf_size;
- }
-
- s2->codec_tag = avpriv_toupper4(avctx->codec_tag);
- if (s->mpeg_enc_ctx_allocated == 0 && ( s2->codec_tag == AV_RL32("VCR2")
- || s2->codec_tag == AV_RL32("BW10")
- ))
- vcr2_init_sequence(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) {
- av_log(avctx, AV_LOG_ERROR, "picture in extradata\n");
- *got_output = 0;
- }
- s->extradata_decoded = 1;
- if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE)) {
- s2->current_picture_ptr = NULL;
- return ret;
- }
- }
-
- ret = decode_chunks(avctx, picture, got_output, buf, buf_size);
- if (ret<0 || *got_output)
- s2->current_picture_ptr = NULL;
-
- return ret;
-}
-
-
-static void flush(AVCodecContext *avctx)
-{
- Mpeg1Context *s = avctx->priv_data;
-
- s->sync=0;
-
- ff_mpeg_flush(avctx);
-}
-
-static int mpeg_decode_end(AVCodecContext *avctx)
-{
- Mpeg1Context *s = avctx->priv_data;
-
- if (s->mpeg_enc_ctx_allocated)
- ff_MPV_common_end(&s->mpeg_enc_ctx);
- return 0;
-}
-
-static const AVProfile mpeg2_video_profiles[] = {
- { FF_PROFILE_MPEG2_422, "4:2:2" },
- { FF_PROFILE_MPEG2_HIGH, "High" },
- { FF_PROFILE_MPEG2_SS, "Spatially Scalable" },
- { FF_PROFILE_MPEG2_SNR_SCALABLE, "SNR Scalable" },
- { FF_PROFILE_MPEG2_MAIN, "Main" },
- { FF_PROFILE_MPEG2_SIMPLE, "Simple" },
- { FF_PROFILE_RESERVED, "Reserved" },
- { FF_PROFILE_RESERVED, "Reserved" },
- { FF_PROFILE_UNKNOWN },
-};
-
-
-AVCodec ff_mpeg1video_decoder = {
- .name = "mpeg1video",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_MPEG1VIDEO,
- .priv_data_size = sizeof(Mpeg1Context),
- .init = mpeg_decode_init,
- .close = mpeg_decode_end,
- .decode = mpeg_decode_frame,
- .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 |
- CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY |
- CODEC_CAP_SLICE_THREADS,
- .flush = flush,
- .max_lowres = 3,
- .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 video"),
- .update_thread_context = ONLY_IF_THREADS_ENABLED(mpeg_decode_update_thread_context)
-};
-
-AVCodec ff_mpeg2video_decoder = {
- .name = "mpeg2video",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_MPEG2VIDEO,
- .priv_data_size = sizeof(Mpeg1Context),
- .init = mpeg_decode_init,
- .close = mpeg_decode_end,
- .decode = mpeg_decode_frame,
- // ==> Start patch MPC
- .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 |
- CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY |
- CODEC_CAP_HWACCEL_VDPAU,
- // ==> End patch MPC
- .flush = flush,
- .max_lowres = 3,
- .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 video"),
- .profiles = NULL_IF_CONFIG_SMALL(mpeg2_video_profiles),
-};
-
-//legacy decoder
-AVCodec ff_mpegvideo_decoder = {
- .name = "mpegvideo",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_MPEG2VIDEO,
- .priv_data_size = sizeof(Mpeg1Context),
- .init = mpeg_decode_init,
- .close = mpeg_decode_end,
- .decode = mpeg_decode_frame,
- .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS,
- .flush = flush,
- .max_lowres = 3,
- .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 video"),
-};
-
-#if CONFIG_MPEG_XVMC_DECODER
-static av_cold int mpeg_mc_decode_init(AVCodecContext *avctx)
-{
- if (avctx->active_thread_type & FF_THREAD_SLICE)
- return -1;
- if (!(avctx->slice_flags & SLICE_FLAG_CODED_ORDER))
- return -1;
- if (!(avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD)) {
- av_dlog(avctx, "mpeg12.c: XvMC decoder will work better if SLICE_FLAG_ALLOW_FIELD is set\n");
- }
- mpeg_decode_init(avctx);
-
- avctx->pix_fmt = AV_PIX_FMT_XVMC_MPEG2_IDCT;
- avctx->xvmc_acceleration = 2; // 2 - the blocks are packed!
-
- return 0;
-}
-
-AVCodec ff_mpeg_xvmc_decoder = {
- .name = "mpegvideo_xvmc",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_MPEG2VIDEO_XVMC,
- .priv_data_size = sizeof(Mpeg1Context),
- .init = mpeg_mc_decode_init,
- .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,
- .flush = flush,
- .long_name = NULL_IF_CONFIG_SMALL("MPEG-1/2 video XvMC (X-Video Motion Compensation)"),
-};
-
-#endif
-
-#if CONFIG_MPEG_VDPAU_DECODER
-AVCodec ff_mpeg_vdpau_decoder = {
- .name = "mpegvideo_vdpau",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_MPEG2VIDEO,
- .priv_data_size = sizeof(Mpeg1Context),
- .init = mpeg_decode_init,
- .close = mpeg_decode_end,
- .decode = mpeg_decode_frame,
- .capabilities = CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED |
- CODEC_CAP_HWACCEL_VDPAU | CODEC_CAP_DELAY,
- .flush = flush,
- .long_name = NULL_IF_CONFIG_SMALL("MPEG-1/2 video (VDPAU acceleration)"),
-};
-#endif
-
-#if CONFIG_MPEG1_VDPAU_DECODER
-AVCodec ff_mpeg1_vdpau_decoder = {
- .name = "mpeg1video_vdpau",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_MPEG1VIDEO,
- .priv_data_size = sizeof(Mpeg1Context),
- .init = mpeg_decode_init,
- .close = mpeg_decode_end,
- .decode = mpeg_decode_frame,
- .capabilities = CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED |
- CODEC_CAP_HWACCEL_VDPAU | CODEC_CAP_DELAY,
- .flush = flush,
- .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 video (VDPAU acceleration)"),
-};
-#endif
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpeg12.h b/src/thirdparty/ffmpeg/libavcodec/mpeg12.h
deleted file mode 100644
index 1e2c432a4..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpeg12.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * MPEG1/2 common code
- * Copyright (c) 2007 Aurelien Jacobs <aurel@gnuage.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_MPEG12_H
-#define AVCODEC_MPEG12_H
-
-#include "mpegvideo.h"
-
-// ==> Start patch MPC
-#include <windows.h>
-#include "libavcodec/dxva.h"
-// <== End patch MPC
-
-#define DC_VLC_BITS 9
-#define TEX_VLC_BITS 9
-
-extern VLC ff_dc_lum_vlc;
-extern VLC ff_dc_chroma_vlc;
-
-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 slice_count;
- int swap_uv;//indicate VCR2
- 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?
- int tmpgexs;
- int extradata_decoded;
- // ==> Start patch MPC
- DXVA_SliceInfo* pSliceInfo;
- uint8_t* prev_slice;
- // <== End patch MPC
-} Mpeg1Context;
-
-extern uint8_t ff_mpeg12_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3];
-
-void ff_mpeg12_common_init(MpegEncContext *s);
-void ff_mpeg12_init_vlcs(void);
-
-static inline int decode_dc(GetBitContext *gb, int component)
-{
- int code, diff;
-
- if (component == 0) {
- code = get_vlc2(gb, ff_dc_lum_vlc.table, DC_VLC_BITS, 2);
- } else {
- code = get_vlc2(gb, ff_dc_chroma_vlc.table, DC_VLC_BITS, 2);
- }
- if (code < 0){
- av_log(NULL, AV_LOG_ERROR, "invalid dc code at\n");
- return 0xffff;
- }
- if (code == 0) {
- diff = 0;
- } else {
- diff = get_xbits(gb, code);
- }
- return diff;
-}
-
-extern int ff_mpeg1_decode_block_intra(MpegEncContext *s, int16_t *block, int n);
-
-#endif /* AVCODEC_MPEG12_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpeg12data.c b/src/thirdparty/ffmpeg/libavcodec/mpeg12data.c
deleted file mode 100644
index e7a0ec81a..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpeg12data.c
+++ /dev/null
@@ -1,432 +0,0 @@
-/*
- * MPEG1/2 tables
- * copyright (c) 2000,2001 Fabrice Bellard
- * copyright (c) 2002-2004 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
- * MPEG1/2 tables.
- */
-
-#include "mpeg12data.h"
-
-const uint16_t ff_mpeg1_default_intra_matrix[256] = {
- 8, 16, 19, 22, 26, 27, 29, 34,
- 16, 16, 22, 24, 27, 29, 34, 37,
- 19, 22, 26, 27, 29, 34, 34, 38,
- 22, 22, 26, 27, 29, 34, 37, 40,
- 22, 26, 27, 29, 32, 35, 40, 48,
- 26, 27, 29, 32, 35, 40, 48, 58,
- 26, 27, 29, 34, 38, 46, 56, 69,
- 27, 29, 35, 38, 46, 56, 69, 83
-};
-
-const uint16_t ff_mpeg1_default_non_intra_matrix[64] = {
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
-};
-
-const uint16_t ff_mpeg12_vlc_dc_lum_code[12] = {
- 0x4, 0x0, 0x1, 0x5, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe, 0x1ff,
-};
-const unsigned char ff_mpeg12_vlc_dc_lum_bits[12] = {
- 3, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 9,
-};
-
-const uint16_t ff_mpeg12_vlc_dc_chroma_code[12] = {
- 0x0, 0x1, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe, 0x3fe, 0x3ff,
-};
-const unsigned char ff_mpeg12_vlc_dc_chroma_bits[12] = {
- 2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10,
-};
-
-static const uint16_t mpeg1_vlc[113][2] = {
- { 0x3, 2 }, { 0x4, 4 }, { 0x5, 5 }, { 0x6, 7 },
- { 0x26, 8 }, { 0x21, 8 }, { 0xa, 10 }, { 0x1d, 12 },
- { 0x18, 12 }, { 0x13, 12 }, { 0x10, 12 }, { 0x1a, 13 },
- { 0x19, 13 }, { 0x18, 13 }, { 0x17, 13 }, { 0x1f, 14 },
- { 0x1e, 14 }, { 0x1d, 14 }, { 0x1c, 14 }, { 0x1b, 14 },
- { 0x1a, 14 }, { 0x19, 14 }, { 0x18, 14 }, { 0x17, 14 },
- { 0x16, 14 }, { 0x15, 14 }, { 0x14, 14 }, { 0x13, 14 },
- { 0x12, 14 }, { 0x11, 14 }, { 0x10, 14 }, { 0x18, 15 },
- { 0x17, 15 }, { 0x16, 15 }, { 0x15, 15 }, { 0x14, 15 },
- { 0x13, 15 }, { 0x12, 15 }, { 0x11, 15 }, { 0x10, 15 },
- { 0x3, 3 }, { 0x6, 6 }, { 0x25, 8 }, { 0xc, 10 },
- { 0x1b, 12 }, { 0x16, 13 }, { 0x15, 13 }, { 0x1f, 15 },
- { 0x1e, 15 }, { 0x1d, 15 }, { 0x1c, 15 }, { 0x1b, 15 },
- { 0x1a, 15 }, { 0x19, 15 }, { 0x13, 16 }, { 0x12, 16 },
- { 0x11, 16 }, { 0x10, 16 }, { 0x5, 4 }, { 0x4, 7 },
- { 0xb, 10 }, { 0x14, 12 }, { 0x14, 13 }, { 0x7, 5 },
- { 0x24, 8 }, { 0x1c, 12 }, { 0x13, 13 }, { 0x6, 5 },
- { 0xf, 10 }, { 0x12, 12 }, { 0x7, 6 }, { 0x9, 10 },
- { 0x12, 13 }, { 0x5, 6 }, { 0x1e, 12 }, { 0x14, 16 },
- { 0x4, 6 }, { 0x15, 12 }, { 0x7, 7 }, { 0x11, 12 },
- { 0x5, 7 }, { 0x11, 13 }, { 0x27, 8 }, { 0x10, 13 },
- { 0x23, 8 }, { 0x1a, 16 }, { 0x22, 8 }, { 0x19, 16 },
- { 0x20, 8 }, { 0x18, 16 }, { 0xe, 10 }, { 0x17, 16 },
- { 0xd, 10 }, { 0x16, 16 }, { 0x8, 10 }, { 0x15, 16 },
- { 0x1f, 12 }, { 0x1a, 12 }, { 0x19, 12 }, { 0x17, 12 },
- { 0x16, 12 }, { 0x1f, 13 }, { 0x1e, 13 }, { 0x1d, 13 },
- { 0x1c, 13 }, { 0x1b, 13 }, { 0x1f, 16 }, { 0x1e, 16 },
- { 0x1d, 16 }, { 0x1c, 16 }, { 0x1b, 16 },
- { 0x1, 6 }, /* escape */
- { 0x2, 2 }, /* EOB */
-};
-
-static const uint16_t mpeg2_vlc[113][2] = {
- {0x02, 2}, {0x06, 3}, {0x07, 4}, {0x1c, 5},
- {0x1d, 5}, {0x05, 6}, {0x04, 6}, {0x7b, 7},
- {0x7c, 7}, {0x23, 8}, {0x22, 8}, {0xfa, 8},
- {0xfb, 8}, {0xfe, 8}, {0xff, 8}, {0x1f,14},
- {0x1e,14}, {0x1d,14}, {0x1c,14}, {0x1b,14},
- {0x1a,14}, {0x19,14}, {0x18,14}, {0x17,14},
- {0x16,14}, {0x15,14}, {0x14,14}, {0x13,14},
- {0x12,14}, {0x11,14}, {0x10,14}, {0x18,15},
- {0x17,15}, {0x16,15}, {0x15,15}, {0x14,15},
- {0x13,15}, {0x12,15}, {0x11,15}, {0x10,15},
- {0x02, 3}, {0x06, 5}, {0x79, 7}, {0x27, 8},
- {0x20, 8}, {0x16,13}, {0x15,13}, {0x1f,15},
- {0x1e,15}, {0x1d,15}, {0x1c,15}, {0x1b,15},
- {0x1a,15}, {0x19,15}, {0x13,16}, {0x12,16},
- {0x11,16}, {0x10,16}, {0x05, 5}, {0x07, 7},
- {0xfc, 8}, {0x0c,10}, {0x14,13}, {0x07, 5},
- {0x26, 8}, {0x1c,12}, {0x13,13}, {0x06, 6},
- {0xfd, 8}, {0x12,12}, {0x07, 6}, {0x04, 9},
- {0x12,13}, {0x06, 7}, {0x1e,12}, {0x14,16},
- {0x04, 7}, {0x15,12}, {0x05, 7}, {0x11,12},
- {0x78, 7}, {0x11,13}, {0x7a, 7}, {0x10,13},
- {0x21, 8}, {0x1a,16}, {0x25, 8}, {0x19,16},
- {0x24, 8}, {0x18,16}, {0x05, 9}, {0x17,16},
- {0x07, 9}, {0x16,16}, {0x0d,10}, {0x15,16},
- {0x1f,12}, {0x1a,12}, {0x19,12}, {0x17,12},
- {0x16,12}, {0x1f,13}, {0x1e,13}, {0x1d,13},
- {0x1c,13}, {0x1b,13}, {0x1f,16}, {0x1e,16},
- {0x1d,16}, {0x1c,16}, {0x1b,16},
- {0x01,6}, /* escape */
- {0x06,4}, /* EOB */
-};
-
-static const int8_t mpeg1_level[111] = {
- 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, 32,
- 33, 34, 35, 36, 37, 38, 39, 40,
- 1, 2, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 1, 2, 3, 4, 5, 1,
- 2, 3, 4, 1, 2, 3, 1, 2,
- 3, 1, 2, 3, 1, 2, 1, 2,
- 1, 2, 1, 2, 1, 2, 1, 2,
- 1, 2, 1, 2, 1, 2, 1, 2,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1,
-};
-
-static const int8_t mpeg1_run[111] = {
- 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,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 2, 2, 2, 2, 2, 3,
- 3, 3, 3, 4, 4, 4, 5, 5,
- 5, 6, 6, 6, 7, 7, 8, 8,
- 9, 9, 10, 10, 11, 11, 12, 12,
- 13, 13, 14, 14, 15, 15, 16, 16,
- 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31,
-};
-
-RLTable ff_rl_mpeg1 = {
- 111,
- 111,
- mpeg1_vlc,
- mpeg1_run,
- mpeg1_level,
-};
-
-RLTable ff_rl_mpeg2 = {
- 111,
- 111,
- mpeg2_vlc,
- mpeg1_run,
- mpeg1_level,
-};
-
-const uint8_t ff_mpeg12_mbAddrIncrTable[36][2] = {
- {0x1, 1},
- {0x3, 3},
- {0x2, 3},
- {0x3, 4},
- {0x2, 4},
- {0x3, 5},
- {0x2, 5},
- {0x7, 7},
- {0x6, 7},
- {0xb, 8},
- {0xa, 8},
- {0x9, 8},
- {0x8, 8},
- {0x7, 8},
- {0x6, 8},
- {0x17, 10},
- {0x16, 10},
- {0x15, 10},
- {0x14, 10},
- {0x13, 10},
- {0x12, 10},
- {0x23, 11},
- {0x22, 11},
- {0x21, 11},
- {0x20, 11},
- {0x1f, 11},
- {0x1e, 11},
- {0x1d, 11},
- {0x1c, 11},
- {0x1b, 11},
- {0x1a, 11},
- {0x19, 11},
- {0x18, 11},
- {0x8, 11}, /* escape */
- {0xf, 11}, /* stuffing */
- {0x0, 8}, /* end (and 15 more 0 bits should follow) */
-};
-
-const uint8_t ff_mpeg12_mbPatTable[64][2] = {
- {0x1, 9},
- {0xb, 5},
- {0x9, 5},
- {0xd, 6},
- {0xd, 4},
- {0x17, 7},
- {0x13, 7},
- {0x1f, 8},
- {0xc, 4},
- {0x16, 7},
- {0x12, 7},
- {0x1e, 8},
- {0x13, 5},
- {0x1b, 8},
- {0x17, 8},
- {0x13, 8},
- {0xb, 4},
- {0x15, 7},
- {0x11, 7},
- {0x1d, 8},
- {0x11, 5},
- {0x19, 8},
- {0x15, 8},
- {0x11, 8},
- {0xf, 6},
- {0xf, 8},
- {0xd, 8},
- {0x3, 9},
- {0xf, 5},
- {0xb, 8},
- {0x7, 8},
- {0x7, 9},
- {0xa, 4},
- {0x14, 7},
- {0x10, 7},
- {0x1c, 8},
- {0xe, 6},
- {0xe, 8},
- {0xc, 8},
- {0x2, 9},
- {0x10, 5},
- {0x18, 8},
- {0x14, 8},
- {0x10, 8},
- {0xe, 5},
- {0xa, 8},
- {0x6, 8},
- {0x6, 9},
- {0x12, 5},
- {0x1a, 8},
- {0x16, 8},
- {0x12, 8},
- {0xd, 5},
- {0x9, 8},
- {0x5, 8},
- {0x5, 9},
- {0xc, 5},
- {0x8, 8},
- {0x4, 8},
- {0x4, 9},
- {0x7, 3},
- {0xa, 5},
- {0x8, 5},
- {0xc, 6}
-};
-
-const uint8_t ff_mpeg12_mbMotionVectorTable[17][2] = {
-{ 0x1, 1 },
-{ 0x1, 2 },
-{ 0x1, 3 },
-{ 0x1, 4 },
-{ 0x3, 6 },
-{ 0x5, 7 },
-{ 0x4, 7 },
-{ 0x3, 7 },
-{ 0xb, 9 },
-{ 0xa, 9 },
-{ 0x9, 9 },
-{ 0x11, 10 },
-{ 0x10, 10 },
-{ 0xf, 10 },
-{ 0xe, 10 },
-{ 0xd, 10 },
-{ 0xc, 10 },
-};
-
-const AVRational ff_mpeg12_frame_rate_tab[16] = {
- { 0, 0},
- {24000, 1001},
- { 24, 1},
- { 25, 1},
- {30000, 1001},
- { 30, 1},
- { 50, 1},
- {60000, 1001},
- { 60, 1},
- // Xing's 15fps: (9)
- { 15, 1},
- // libmpeg3's "Unofficial economy rates": (10-13)
- { 5, 1},
- { 10, 1},
- { 12, 1},
- { 15, 1},
- { 0, 0},
-};
-
-const AVRational ff_mpeg2_frame_rate_tab[] = {
- { 1, 1},
- { 2, 1},
- { 3, 1},
- { 4, 1},
- { 5, 1},
- { 6, 1},
- { 8, 1},
- { 9, 1},
- { 10, 1},
- { 12, 1},
- { 15, 1},
- { 16, 1},
- { 18, 1},
- { 20, 1},
- { 24, 1},
- { 25, 1},
- { 30, 1},
- { 32, 1},
- { 36, 1},
- { 40, 1},
- { 45, 1},
- { 48, 1},
- { 50, 1},
- { 60, 1},
- { 72, 1},
- { 75, 1},
- { 80, 1},
- { 90, 1},
- { 96, 1},
- { 100, 1},
- { 120, 1},
- { 150, 1},
- { 180, 1},
- { 200, 1},
- { 240, 1},
- { 750, 1001},
- { 800, 1001},
- { 960, 1001},
- { 1000, 1001},
- { 1200, 1001},
- { 1250, 1001},
- { 1500, 1001},
- { 1600, 1001},
- { 1875, 1001},
- { 2000, 1001},
- { 2400, 1001},
- { 2500, 1001},
- { 3000, 1001},
- { 3750, 1001},
- { 4000, 1001},
- { 4800, 1001},
- { 5000, 1001},
- { 6000, 1001},
- { 7500, 1001},
- { 8000, 1001},
- { 10000, 1001},
- { 12000, 1001},
- { 15000, 1001},
- { 20000, 1001},
- { 24000, 1001},
- { 30000, 1001},
- { 60000, 1001},
- { 0, 0},
-};
-
-const float ff_mpeg1_aspect[16]={
- 0.0000,
- 1.0000,
- 0.6735,
- 0.7031,
-
- 0.7615,
- 0.8055,
- 0.8437,
- 0.8935,
-
- 0.9157,
- 0.9815,
- 1.0255,
- 1.0695,
-
- 1.0950,
- 1.1575,
- 1.2015,
-};
-
-const AVRational ff_mpeg2_aspect[16]={
- {0,1},
- {1,1},
- {4,3},
- {16,9},
- {221,100},
- {0,1},
- {0,1},
- {0,1},
- {0,1},
- {0,1},
- {0,1},
- {0,1},
- {0,1},
- {0,1},
- {0,1},
- {0,1},
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpeg12data.h b/src/thirdparty/ffmpeg/libavcodec/mpeg12data.h
deleted file mode 100644
index ca21fcdbb..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpeg12data.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * MPEG1/2 tables
- * copyright (c) 2000,2001 Fabrice Bellard
- * copyright (c) 2002-2004 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
- * MPEG1/2 tables.
- */
-
-#ifndef AVCODEC_MPEG12DATA_H
-#define AVCODEC_MPEG12DATA_H
-
-#include <stdint.h>
-#include "libavutil/rational.h"
-#include "rl.h"
-
-extern const uint16_t ff_mpeg1_default_intra_matrix[];
-extern const uint16_t ff_mpeg1_default_non_intra_matrix[64];
-
-extern const uint16_t ff_mpeg12_vlc_dc_lum_code[12];
-extern const unsigned char ff_mpeg12_vlc_dc_lum_bits[12];
-extern const uint16_t ff_mpeg12_vlc_dc_chroma_code[12];
-extern const unsigned char ff_mpeg12_vlc_dc_chroma_bits[12];
-
-extern RLTable ff_rl_mpeg1;
-extern RLTable ff_rl_mpeg2;
-
-extern const uint8_t ff_mpeg12_mbAddrIncrTable[36][2];
-extern const uint8_t ff_mpeg12_mbPatTable[64][2];
-
-extern const uint8_t ff_mpeg12_mbMotionVectorTable[17][2];
-
-extern const AVRational ff_mpeg12_frame_rate_tab[];
-extern const AVRational ff_mpeg2_frame_rate_tab[];
-
-extern const float ff_mpeg1_aspect[16];
-extern const AVRational ff_mpeg2_aspect[16];
-
-#endif /* AVCODEC_MPEG12DATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpeg12decdata.h b/src/thirdparty/ffmpeg/libavcodec/mpeg12decdata.h
deleted file mode 100644
index fac906bdc..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpeg12decdata.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * MPEG1/2 decoder tables
- * copyright (c) 2000,2001 Fabrice Bellard
- * copyright (c) 2002-2004 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
- * MPEG1/2 decoder tables.
- */
-
-#ifndef AVCODEC_MPEG12DECDATA_H
-#define AVCODEC_MPEG12DECDATA_H
-
-#include <stdint.h>
-#include "mpegvideo.h"
-
-
-#define MB_TYPE_ZERO_MV 0x20000000
-#define IS_ZERO_MV(a) ((a)&MB_TYPE_ZERO_MV)
-
-static const uint8_t table_mb_ptype[7][2] = {
- { 3, 5 }, // 0x01 MB_INTRA
- { 1, 2 }, // 0x02 MB_PAT
- { 1, 3 }, // 0x08 MB_FOR
- { 1, 1 }, // 0x0A MB_FOR|MB_PAT
- { 1, 6 }, // 0x11 MB_QUANT|MB_INTRA
- { 1, 5 }, // 0x12 MB_QUANT|MB_PAT
- { 2, 5 }, // 0x1A MB_QUANT|MB_FOR|MB_PAT
-};
-
-static const uint32_t ptype2mb_type[7] = {
- MB_TYPE_INTRA,
- MB_TYPE_L0 | MB_TYPE_CBP | MB_TYPE_ZERO_MV | MB_TYPE_16x16,
- MB_TYPE_L0,
- MB_TYPE_L0 | MB_TYPE_CBP,
- MB_TYPE_QUANT | MB_TYPE_INTRA,
- MB_TYPE_QUANT | MB_TYPE_L0 | MB_TYPE_CBP | MB_TYPE_ZERO_MV | MB_TYPE_16x16,
- MB_TYPE_QUANT | MB_TYPE_L0 | MB_TYPE_CBP,
-};
-
-static const uint8_t table_mb_btype[11][2] = {
- { 3, 5 }, // 0x01 MB_INTRA
- { 2, 3 }, // 0x04 MB_BACK
- { 3, 3 }, // 0x06 MB_BACK|MB_PAT
- { 2, 4 }, // 0x08 MB_FOR
- { 3, 4 }, // 0x0A MB_FOR|MB_PAT
- { 2, 2 }, // 0x0C MB_FOR|MB_BACK
- { 3, 2 }, // 0x0E MB_FOR|MB_BACK|MB_PAT
- { 1, 6 }, // 0x11 MB_QUANT|MB_INTRA
- { 2, 6 }, // 0x16 MB_QUANT|MB_BACK|MB_PAT
- { 3, 6 }, // 0x1A MB_QUANT|MB_FOR|MB_PAT
- { 2, 5 }, // 0x1E MB_QUANT|MB_FOR|MB_BACK|MB_PAT
-};
-
-static const uint32_t btype2mb_type[11] = {
- MB_TYPE_INTRA,
- MB_TYPE_L1,
- MB_TYPE_L1 | MB_TYPE_CBP,
- MB_TYPE_L0,
- MB_TYPE_L0 | MB_TYPE_CBP,
- MB_TYPE_L0L1,
- MB_TYPE_L0L1 | MB_TYPE_CBP,
- MB_TYPE_QUANT | MB_TYPE_INTRA,
- MB_TYPE_QUANT | MB_TYPE_L1 | MB_TYPE_CBP,
- MB_TYPE_QUANT | MB_TYPE_L0 | MB_TYPE_CBP,
- MB_TYPE_QUANT | MB_TYPE_L0L1 | MB_TYPE_CBP,
-};
-
-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,
-};
-
-#endif /* AVCODEC_MPEG12DECDATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpeg4audio.c b/src/thirdparty/ffmpeg/libavcodec/mpeg4audio.c
deleted file mode 100644
index 34755cb77..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpeg4audio.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * MPEG-4 Audio common code
- * Copyright (c) 2008 Baptiste Coudurier <baptiste.coudurier@free.fr>
- * Copyright (c) 2009 Alex Converse <alex.converse@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 "get_bits.h"
-#include "put_bits.h"
-#include "mpeg4audio.h"
-
-/**
- * Parse MPEG-4 audio configuration for ALS object type.
- * @param[in] gb bit reader context
- * @param[in] c MPEG4AudioConfig structure to fill
- * @return on success 0 is returned, otherwise a value < 0
- */
-static int parse_config_ALS(GetBitContext *gb, MPEG4AudioConfig *c)
-{
- if (get_bits_left(gb) < 112)
- return -1;
-
- if (get_bits_long(gb, 32) != MKBETAG('A','L','S','\0'))
- return -1;
-
- // override AudioSpecificConfig channel configuration and sample rate
- // which are buggy in old ALS conformance files
- c->sample_rate = get_bits_long(gb, 32);
-
- // skip number of samples
- skip_bits_long(gb, 32);
-
- // read number of channels
- c->chan_config = 0;
- c->channels = get_bits(gb, 16) + 1;
-
- return 0;
-}
-
-/* XXX: make sure to update the copies in the different encoders if you change
- * this table */
-const int avpriv_mpeg4audio_sample_rates[16] = {
- 96000, 88200, 64000, 48000, 44100, 32000,
- 24000, 22050, 16000, 12000, 11025, 8000, 7350
-};
-
-const uint8_t ff_mpeg4audio_channels[8] = {
- 0, 1, 2, 3, 4, 5, 6, 8
-};
-
-static inline int get_object_type(GetBitContext *gb)
-{
- int object_type = get_bits(gb, 5);
- if (object_type == AOT_ESCAPE)
- object_type = 32 + get_bits(gb, 6);
- return object_type;
-}
-
-static inline int get_sample_rate(GetBitContext *gb, int *index)
-{
- *index = get_bits(gb, 4);
- return *index == 0x0f ? get_bits(gb, 24) :
- avpriv_mpeg4audio_sample_rates[*index];
-}
-
-int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf,
- int bit_size, int sync_extension)
-{
- GetBitContext gb;
- int specific_config_bitindex;
-
- if (bit_size <= 0 || init_get_bits(&gb, buf, bit_size) < 0)
- return AVERROR_INVALIDDATA;
- c->object_type = get_object_type(&gb);
- c->sample_rate = get_sample_rate(&gb, &c->sampling_index);
- c->chan_config = get_bits(&gb, 4);
- if (c->chan_config < FF_ARRAY_ELEMS(ff_mpeg4audio_channels))
- c->channels = ff_mpeg4audio_channels[c->chan_config];
- c->sbr = -1;
- c->ps = -1;
- if (c->object_type == AOT_SBR || (c->object_type == AOT_PS &&
- // check for W6132 Annex YYYY draft MP3onMP4
- !(show_bits(&gb, 3) & 0x03 && !(show_bits(&gb, 9) & 0x3F)))) {
- if (c->object_type == AOT_PS)
- c->ps = 1;
- c->ext_object_type = AOT_SBR;
- c->sbr = 1;
- c->ext_sample_rate = get_sample_rate(&gb, &c->ext_sampling_index);
- c->object_type = get_object_type(&gb);
- if (c->object_type == AOT_ER_BSAC)
- c->ext_chan_config = get_bits(&gb, 4);
- } else {
- c->ext_object_type = AOT_NULL;
- c->ext_sample_rate = 0;
- }
- specific_config_bitindex = get_bits_count(&gb);
-
- if (c->object_type == AOT_ALS) {
- skip_bits(&gb, 5);
- if (show_bits_long(&gb, 24) != MKBETAG('\0','A','L','S'))
- skip_bits_long(&gb, 24);
-
- specific_config_bitindex = get_bits_count(&gb);
-
- if (parse_config_ALS(&gb, c))
- return -1;
- }
-
- if (c->ext_object_type != AOT_SBR && sync_extension) {
- while (get_bits_left(&gb) > 15) {
- if (show_bits(&gb, 11) == 0x2b7) { // sync extension
- get_bits(&gb, 11);
- c->ext_object_type = get_object_type(&gb);
- if (c->ext_object_type == AOT_SBR && (c->sbr = get_bits1(&gb)) == 1) {
- c->ext_sample_rate = get_sample_rate(&gb, &c->ext_sampling_index);
- if (c->ext_sample_rate == c->sample_rate)
- c->sbr = -1;
- }
- if (get_bits_left(&gb) > 11 && get_bits(&gb, 11) == 0x548)
- c->ps = get_bits1(&gb);
- break;
- } else
- get_bits1(&gb); // skip 1 bit
- }
- }
-
- //PS requires SBR
- if (!c->sbr)
- c->ps = 0;
- //Limit implicit PS to the HE-AACv2 Profile
- if ((c->ps == -1 && c->object_type != AOT_AAC_LC) || c->channels & ~0x01)
- c->ps = 0;
-
- return specific_config_bitindex;
-}
-
-static av_always_inline unsigned int copy_bits(PutBitContext *pb,
- GetBitContext *gb,
- int bits)
-{
- unsigned int el = get_bits(gb, bits);
- put_bits(pb, bits, el);
- return el;
-}
-
-int avpriv_copy_pce_data(PutBitContext *pb, GetBitContext *gb)
-{
- int five_bit_ch, four_bit_ch, comment_size, bits;
- int offset = put_bits_count(pb);
-
- copy_bits(pb, gb, 10); //Tag, Object Type, Frequency
- five_bit_ch = copy_bits(pb, gb, 4); //Front
- five_bit_ch += copy_bits(pb, gb, 4); //Side
- five_bit_ch += copy_bits(pb, gb, 4); //Back
- four_bit_ch = copy_bits(pb, gb, 2); //LFE
- four_bit_ch += copy_bits(pb, gb, 3); //Data
- five_bit_ch += copy_bits(pb, gb, 4); //Coupling
- if (copy_bits(pb, gb, 1)) //Mono Mixdown
- copy_bits(pb, gb, 4);
- if (copy_bits(pb, gb, 1)) //Stereo Mixdown
- copy_bits(pb, gb, 4);
- if (copy_bits(pb, gb, 1)) //Matrix Mixdown
- copy_bits(pb, gb, 3);
- for (bits = five_bit_ch*5+four_bit_ch*4; bits > 16; bits -= 16)
- copy_bits(pb, gb, 16);
- if (bits)
- copy_bits(pb, gb, bits);
- avpriv_align_put_bits(pb);
- align_get_bits(gb);
- comment_size = copy_bits(pb, gb, 8);
- for (; comment_size > 0; comment_size--)
- copy_bits(pb, gb, 8);
-
- return put_bits_count(pb) - offset;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpeg4audio.h b/src/thirdparty/ffmpeg/libavcodec/mpeg4audio.h
deleted file mode 100644
index ccd480d7a..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpeg4audio.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * MPEG-4 Audio common header
- * Copyright (c) 2008 Baptiste Coudurier <baptiste.coudurier@free.fr>
- *
- * 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_MPEG4AUDIO_H
-#define AVCODEC_MPEG4AUDIO_H
-
-#include <stdint.h>
-#include "get_bits.h"
-#include "put_bits.h"
-
-typedef struct MPEG4AudioConfig {
- int object_type;
- int sampling_index;
- int sample_rate;
- int chan_config;
- int sbr; ///< -1 implicit, 1 presence
- int ext_object_type;
- int ext_sampling_index;
- int ext_sample_rate;
- int ext_chan_config;
- int channels;
- int ps; ///< -1 implicit, 1 presence
-} MPEG4AudioConfig;
-
-extern av_export const int avpriv_mpeg4audio_sample_rates[16];
-extern const uint8_t ff_mpeg4audio_channels[8];
-
-/**
- * Parse MPEG-4 systems extradata to retrieve audio configuration.
- * @param[in] c MPEG4AudioConfig structure to fill.
- * @param[in] buf Extradata from container.
- * @param[in] bit_size Extradata size in bits.
- * @param[in] sync_extension look for a sync extension after config if true.
- * @return On error -1 is returned, on success AudioSpecificConfig bit index in extradata.
- */
-int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf,
- int bit_size, int sync_extension);
-
-enum AudioObjectType {
- AOT_NULL,
- // Support? Name
- AOT_AAC_MAIN, ///< Y Main
- AOT_AAC_LC, ///< Y Low Complexity
- AOT_AAC_SSR, ///< N (code in SoC repo) Scalable Sample Rate
- AOT_AAC_LTP, ///< Y Long Term Prediction
- AOT_SBR, ///< Y Spectral Band Replication
- AOT_AAC_SCALABLE, ///< N Scalable
- AOT_TWINVQ, ///< N Twin Vector Quantizer
- AOT_CELP, ///< N Code Excited Linear Prediction
- AOT_HVXC, ///< N Harmonic Vector eXcitation Coding
- AOT_TTSI = 12, ///< N Text-To-Speech Interface
- AOT_MAINSYNTH, ///< N Main Synthesis
- AOT_WAVESYNTH, ///< N Wavetable Synthesis
- AOT_MIDI, ///< N General MIDI
- AOT_SAFX, ///< N Algorithmic Synthesis and Audio Effects
- AOT_ER_AAC_LC, ///< N Error Resilient Low Complexity
- AOT_ER_AAC_LTP = 19, ///< N Error Resilient Long Term Prediction
- AOT_ER_AAC_SCALABLE, ///< N Error Resilient Scalable
- AOT_ER_TWINVQ, ///< N Error Resilient Twin Vector Quantizer
- AOT_ER_BSAC, ///< N Error Resilient Bit-Sliced Arithmetic Coding
- AOT_ER_AAC_LD, ///< N Error Resilient Low Delay
- AOT_ER_CELP, ///< N Error Resilient Code Excited Linear Prediction
- AOT_ER_HVXC, ///< N Error Resilient Harmonic Vector eXcitation Coding
- AOT_ER_HILN, ///< N Error Resilient Harmonic and Individual Lines plus Noise
- AOT_ER_PARAM, ///< N Error Resilient Parametric
- AOT_SSC, ///< N SinuSoidal Coding
- AOT_PS, ///< N Parametric Stereo
- AOT_SURROUND, ///< N MPEG Surround
- AOT_ESCAPE, ///< Y Escape Value
- AOT_L1, ///< Y Layer 1
- AOT_L2, ///< Y Layer 2
- AOT_L3, ///< Y Layer 3
- AOT_DST, ///< N Direct Stream Transfer
- AOT_ALS, ///< Y Audio LosslesS
- AOT_SLS, ///< N Scalable LosslesS
- AOT_SLS_NON_CORE, ///< N Scalable LosslesS (non core)
- AOT_ER_AAC_ELD, ///< N Error Resilient Enhanced Low Delay
- AOT_SMR_SIMPLE, ///< N Symbolic Music Representation Simple
- AOT_SMR_MAIN, ///< N Symbolic Music Representation Main
- AOT_USAC_NOSBR, ///< N Unified Speech and Audio Coding (no SBR)
- AOT_SAOC, ///< N Spatial Audio Object Coding
- AOT_LD_SURROUND, ///< N Low Delay MPEG Surround
- AOT_USAC, ///< N Unified Speech and Audio Coding
-};
-
-#define MAX_PCE_SIZE 304 ///<Maximum size of a PCE including the 3-bit ID_PCE
- ///<marker and the comment
-
-int avpriv_copy_pce_data(PutBitContext *pb, GetBitContext *gb);
-
-#endif /* AVCODEC_MPEG4AUDIO_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpeg4data.h b/src/thirdparty/ffmpeg/libavcodec/mpeg4data.h
deleted file mode 100644
index b645bbb2b..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpeg4data.h
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- * copyright (c) 2000,2001 Fabrice Bellard
- * H263+ support
- * copyright (c) 2002-2004 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
- * mpeg4 tables.
- */
-
-#ifndef AVCODEC_MPEG4DATA_H
-#define AVCODEC_MPEG4DATA_H
-
-#include <stdint.h>
-#include "mpegvideo.h"
-
-/* dc encoding for mpeg4 */
-const uint8_t ff_mpeg4_DCtab_lum[13][2] =
-{
- {3,3}, {3,2}, {2,2}, {2,3}, {1,3}, {1,4}, {1,5}, {1,6}, {1,7},
- {1,8}, {1,9}, {1,10}, {1,11},
-};
-
-const uint8_t ff_mpeg4_DCtab_chrom[13][2] =
-{
- {3,2}, {2,2}, {1,2}, {1,3}, {1,4}, {1,5}, {1,6}, {1,7}, {1,8},
- {1,9}, {1,10}, {1,11}, {1,12},
-};
-
-const uint16_t ff_mpeg4_intra_vlc[103][2] = {
-{ 0x2, 2 },
-{ 0x6, 3 },{ 0xf, 4 },{ 0xd, 5 },{ 0xc, 5 },
-{ 0x15, 6 },{ 0x13, 6 },{ 0x12, 6 },{ 0x17, 7 },
-{ 0x1f, 8 },{ 0x1e, 8 },{ 0x1d, 8 },{ 0x25, 9 },
-{ 0x24, 9 },{ 0x23, 9 },{ 0x21, 9 },{ 0x21, 10 },
-{ 0x20, 10 },{ 0xf, 10 },{ 0xe, 10 },{ 0x7, 11 },
-{ 0x6, 11 },{ 0x20, 11 },{ 0x21, 11 },{ 0x50, 12 },
-{ 0x51, 12 },{ 0x52, 12 },{ 0xe, 4 },{ 0x14, 6 },
-{ 0x16, 7 },{ 0x1c, 8 },{ 0x20, 9 },{ 0x1f, 9 },
-{ 0xd, 10 },{ 0x22, 11 },{ 0x53, 12 },{ 0x55, 12 },
-{ 0xb, 5 },{ 0x15, 7 },{ 0x1e, 9 },{ 0xc, 10 },
-{ 0x56, 12 },{ 0x11, 6 },{ 0x1b, 8 },{ 0x1d, 9 },
-{ 0xb, 10 },{ 0x10, 6 },{ 0x22, 9 },{ 0xa, 10 },
-{ 0xd, 6 },{ 0x1c, 9 },{ 0x8, 10 },{ 0x12, 7 },
-{ 0x1b, 9 },{ 0x54, 12 },{ 0x14, 7 },{ 0x1a, 9 },
-{ 0x57, 12 },{ 0x19, 8 },{ 0x9, 10 },{ 0x18, 8 },
-{ 0x23, 11 },{ 0x17, 8 },{ 0x19, 9 },{ 0x18, 9 },
-{ 0x7, 10 },{ 0x58, 12 },{ 0x7, 4 },{ 0xc, 6 },
-{ 0x16, 8 },{ 0x17, 9 },{ 0x6, 10 },{ 0x5, 11 },
-{ 0x4, 11 },{ 0x59, 12 },{ 0xf, 6 },{ 0x16, 9 },
-{ 0x5, 10 },{ 0xe, 6 },{ 0x4, 10 },{ 0x11, 7 },
-{ 0x24, 11 },{ 0x10, 7 },{ 0x25, 11 },{ 0x13, 7 },
-{ 0x5a, 12 },{ 0x15, 8 },{ 0x5b, 12 },{ 0x14, 8 },
-{ 0x13, 8 },{ 0x1a, 8 },{ 0x15, 9 },{ 0x14, 9 },
-{ 0x13, 9 },{ 0x12, 9 },{ 0x11, 9 },{ 0x26, 11 },
-{ 0x27, 11 },{ 0x5c, 12 },{ 0x5d, 12 },{ 0x5e, 12 },
-{ 0x5f, 12 },{ 0x3, 7 },
-};
-
-const int8_t ff_mpeg4_intra_level[102] = {
- 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, 1, 2, 3, 4, 5,
- 6, 7, 8, 9, 10, 1, 2, 3,
- 4, 5, 1, 2, 3, 4, 1, 2,
- 3, 1, 2, 3, 1, 2, 3, 1,
- 2, 3, 1, 2, 1, 2, 1, 1,
- 1, 1, 1, 1, 2, 3, 4, 5,
- 6, 7, 8, 1, 2, 3, 1, 2,
- 1, 2, 1, 2, 1, 2, 1, 2,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1,
-};
-
-const int8_t ff_mpeg4_intra_run[102] = {
- 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, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 2, 2, 2,
- 2, 2, 3, 3, 3, 3, 4, 4,
- 4, 5, 5, 5, 6, 6, 6, 7,
- 7, 7, 8, 8, 9, 9, 10, 11,
- 12, 13, 14, 0, 0, 0, 0, 0,
- 0, 0, 0, 1, 1, 1, 2, 2,
- 3, 3, 4, 4, 5, 5, 6, 6,
- 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20,
-};
-
-RLTable ff_mpeg4_rl_intra = {
- 102,
- 67,
- ff_mpeg4_intra_vlc,
- ff_mpeg4_intra_run,
- ff_mpeg4_intra_level,
-};
-
-/* Note this is identical to the intra rvlc except that it is reordered. */
-static const uint16_t inter_rvlc[170][2]={
-{0x0006, 3},{0x0001, 4},{0x0004, 5},{0x001C, 7},
-{0x003C, 8},{0x003D, 8},{0x007C, 9},{0x00FC, 10},
-{0x00FD, 10},{0x01FC, 11},{0x01FD, 11},{0x03FC, 12},
-{0x07FC, 13},{0x07FD, 13},{0x0BFC, 13},{0x0BFD, 13},
-{0x0FFC, 14},{0x0FFD, 14},{0x1FFC, 15},{0x0007, 3},
-{0x000C, 6},{0x005C, 8},{0x007D, 9},{0x017C, 10},
-{0x02FC, 11},{0x03FD, 12},{0x0DFC, 13},{0x17FC, 14},
-{0x17FD, 14},{0x000A, 4},{0x001D, 7},{0x00BC, 9},
-{0x02FD, 11},{0x05FC, 12},{0x1BFC, 14},{0x1BFD, 14},
-{0x0005, 5},{0x005D, 8},{0x017D, 10},{0x05FD, 12},
-{0x0DFD, 13},{0x1DFC, 14},{0x1FFD, 15},{0x0008, 5},
-{0x006C, 8},{0x037C, 11},{0x0EFC, 13},{0x2FFC, 15},
-{0x0009, 5},{0x00BD, 9},{0x037D, 11},{0x0EFD, 13},
-{0x000D, 6},{0x01BC, 10},{0x06FC, 12},{0x1DFD, 14},
-{0x0014, 6},{0x01BD, 10},{0x06FD, 12},{0x2FFD, 15},
-{0x0015, 6},{0x01DC, 10},{0x0F7C, 13},{0x002C, 7},
-{0x01DD, 10},{0x1EFC, 14},{0x002D, 7},{0x03BC, 11},
-{0x0034, 7},{0x077C, 12},{0x006D, 8},{0x0F7D, 13},
-{0x0074, 8},{0x1EFD, 14},{0x0075, 8},{0x1F7C, 14},
-{0x00DC, 9},{0x1F7D, 14},{0x00DD, 9},{0x1FBC, 14},
-{0x00EC, 9},{0x37FC, 15},{0x01EC, 10},{0x01ED, 10},
-{0x01F4, 10},{0x03BD, 11},{0x03DC, 11},{0x03DD, 11},
-{0x03EC, 11},{0x03ED, 11},{0x03F4, 11},{0x077D, 12},
-{0x07BC, 12},{0x07BD, 12},{0x0FBC, 13},{0x0FBD, 13},
-{0x0FDC, 13},{0x0FDD, 13},{0x1FBD, 14},{0x1FDC, 14},
-{0x1FDD, 14},{0x37FD, 15},{0x3BFC, 15},
-{0x000B, 4},{0x0078, 8},{0x03F5, 11},{0x0FEC, 13},
-{0x1FEC, 14},{0x0012, 5},{0x00ED, 9},{0x07DC, 12},
-{0x1FED, 14},{0x3BFD, 15},{0x0013, 5},{0x03F8, 11},
-{0x3DFC, 15},{0x0018, 6},{0x07DD, 12},{0x0019, 6},
-{0x07EC, 12},{0x0022, 6},{0x0FED, 13},{0x0023, 6},
-{0x0FF4, 13},{0x0035, 7},{0x0FF5, 13},{0x0038, 7},
-{0x0FF8, 13},{0x0039, 7},{0x0FF9, 13},{0x0042, 7},
-{0x1FF4, 14},{0x0043, 7},{0x1FF5, 14},{0x0079, 8},
-{0x1FF8, 14},{0x0082, 8},{0x3DFD, 15},{0x0083, 8},
-{0x00F4, 9},{0x00F5, 9},{0x00F8, 9},{0x00F9, 9},
-{0x0102, 9},{0x0103, 9},{0x01F5, 10},{0x01F8, 10},
-{0x01F9, 10},{0x0202, 10},{0x0203, 10},{0x03F9, 11},
-{0x0402, 11},{0x0403, 11},{0x07ED, 12},{0x07F4, 12},
-{0x07F5, 12},{0x07F8, 12},{0x07F9, 12},{0x0802, 12},
-{0x0803, 12},{0x1002, 13},{0x1003, 13},{0x1FF9, 14},
-{0x2002, 14},{0x2003, 14},{0x3EFC, 15},{0x3EFD, 15},
-{0x3F7C, 15},{0x3F7D, 15},{0x0000, 4}
-};
-
-static const int8_t inter_rvlc_run[169]={
- 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, 1, 1, 2, 2, 2,
- 2, 2, 2, 2, 3, 3, 3, 3,
- 3, 3, 3, 4, 4, 4, 4, 4,
- 5, 5, 5, 5, 6, 6, 6, 6,
- 7, 7, 7, 7, 8, 8, 8, 9,
- 9, 9, 10, 10, 11, 11, 12, 12,
-13, 13, 14, 14, 15, 15, 16, 16,
-17, 17, 18, 19, 20, 21, 22, 23,
-24, 25, 26, 27, 28, 29, 30, 31,
-32, 33, 34, 35, 36, 37, 38,
- 0, 0, 0, 0, 0, 1, 1, 1,
- 1, 1, 2, 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, 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,
-};
-
-static const int8_t inter_rvlc_level[169]={
- 1, 2, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16,
-17, 18, 19, 1, 2, 3, 4, 5,
- 6, 7, 8, 9, 10, 1, 2, 3,
- 4, 5, 6, 7, 1, 2, 3, 4,
- 5, 6, 7, 1, 2, 3, 4, 5,
- 1, 2, 3, 4, 1, 2, 3, 4,
- 1, 2, 3, 4, 1, 2, 3, 1,
- 2, 3, 1, 2, 1, 2, 1, 2,
- 1, 2, 1, 2, 1, 2, 1, 2,
- 1, 2, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 3, 4, 5, 1, 2, 3,
- 4, 5, 1, 2, 3, 1, 2, 1,
- 2, 1, 2, 1, 2, 1, 2, 1,
- 2, 1, 2, 1, 2, 1, 2, 1,
- 2, 1, 2, 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,
-};
-
-RLTable ff_rvlc_rl_inter = {
- 169,
- 103,
- inter_rvlc,
- inter_rvlc_run,
- inter_rvlc_level,
-};
-
-static const uint16_t intra_rvlc[170][2]={
-{0x0006, 3},{0x0007, 3},{0x000A, 4},{0x0009, 5},
-{0x0014, 6},{0x0015, 6},{0x0034, 7},{0x0074, 8},
-{0x0075, 8},{0x00DD, 9},{0x00EC, 9},{0x01EC, 10},
-{0x01ED, 10},{0x01F4, 10},{0x03EC, 11},{0x03ED, 11},
-{0x03F4, 11},{0x077D, 12},{0x07BC, 12},{0x0FBD, 13},
-{0x0FDC, 13},{0x07BD, 12},{0x0FDD, 13},{0x1FBD, 14},
-{0x1FDC, 14},{0x1FDD, 14},{0x1FFC, 15},{0x0001, 4},
-{0x0008, 5},{0x002D, 7},{0x006C, 8},{0x006D, 8},
-{0x00DC, 9},{0x01DD, 10},{0x03DC, 11},{0x03DD, 11},
-{0x077C, 12},{0x0FBC, 13},{0x1F7D, 14},{0x1FBC, 14},
-{0x0004, 5},{0x002C, 7},{0x00BC, 9},{0x01DC, 10},
-{0x03BC, 11},{0x03BD, 11},{0x0EFD, 13},{0x0F7C, 13},
-{0x0F7D, 13},{0x1EFD, 14},{0x1F7C, 14},{0x0005, 5},
-{0x005C, 8},{0x00BD, 9},{0x037D, 11},{0x06FC, 12},
-{0x0EFC, 13},{0x1DFD, 14},{0x1EFC, 14},{0x1FFD, 15},
-{0x000C, 6},{0x005D, 8},{0x01BD, 10},{0x03FD, 12},
-{0x06FD, 12},{0x1BFD, 14},{0x000D, 6},{0x007D, 9},
-{0x02FC, 11},{0x05FC, 12},{0x1BFC, 14},{0x1DFC, 14},
-{0x001C, 7},{0x017C, 10},{0x02FD, 11},{0x05FD, 12},
-{0x2FFC, 15},{0x001D, 7},{0x017D, 10},{0x037C, 11},
-{0x0DFD, 13},{0x2FFD, 15},{0x003C, 8},{0x01BC, 10},
-{0x0BFD, 13},{0x17FD, 14},{0x003D, 8},{0x01FD, 11},
-{0x0DFC, 13},{0x37FC, 15},{0x007C, 9},{0x03FC, 12},
-{0x00FC, 10},{0x0BFC, 13},{0x00FD, 10},{0x37FD, 15},
-{0x01FC, 11},{0x07FC, 13},{0x07FD, 13},{0x0FFC, 14},
-{0x0FFD, 14},{0x17FC, 14},{0x3BFC, 15},
-{0x000B, 4},{0x0078, 8},{0x03F5, 11},{0x0FEC, 13},
-{0x1FEC, 14},{0x0012, 5},{0x00ED, 9},{0x07DC, 12},
-{0x1FED, 14},{0x3BFD, 15},{0x0013, 5},{0x03F8, 11},
-{0x3DFC, 15},{0x0018, 6},{0x07DD, 12},{0x0019, 6},
-{0x07EC, 12},{0x0022, 6},{0x0FED, 13},{0x0023, 6},
-{0x0FF4, 13},{0x0035, 7},{0x0FF5, 13},{0x0038, 7},
-{0x0FF8, 13},{0x0039, 7},{0x0FF9, 13},{0x0042, 7},
-{0x1FF4, 14},{0x0043, 7},{0x1FF5, 14},{0x0079, 8},
-{0x1FF8, 14},{0x0082, 8},{0x3DFD, 15},{0x0083, 8},
-{0x00F4, 9},{0x00F5, 9},{0x00F8, 9},{0x00F9, 9},
-{0x0102, 9},{0x0103, 9},{0x01F5, 10},{0x01F8, 10},
-{0x01F9, 10},{0x0202, 10},{0x0203, 10},{0x03F9, 11},
-{0x0402, 11},{0x0403, 11},{0x07ED, 12},{0x07F4, 12},
-{0x07F5, 12},{0x07F8, 12},{0x07F9, 12},{0x0802, 12},
-{0x0803, 12},{0x1002, 13},{0x1003, 13},{0x1FF9, 14},
-{0x2002, 14},{0x2003, 14},{0x3EFC, 15},{0x3EFD, 15},
-{0x3F7C, 15},{0x3F7D, 15},{0x0000, 4}
-};
-
-static const int8_t intra_rvlc_run[169]={
- 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, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 4, 4, 4, 4,
- 4, 4, 5, 5, 5, 5, 5, 5,
- 6, 6, 6, 6, 6, 7, 7, 7,
- 7, 7, 8, 8, 8, 8, 9, 9,
- 9, 9, 10, 10, 11, 11, 12, 12,
-13, 14, 15, 16, 17, 18, 19,
- 0, 0, 0, 0, 0, 1, 1, 1,
- 1, 1, 2, 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, 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,
-};
-
-static const int8_t intra_rvlc_level[169]={
- 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, 1, 2, 3, 4, 5,
- 6, 7, 8, 9, 10, 11, 12, 13,
- 1, 2, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 1, 2, 3, 4, 5,
- 6, 7, 8, 9, 1, 2, 3, 4,
- 5, 6, 1, 2, 3, 4, 5, 6,
- 1, 2, 3, 4, 5, 1, 2, 3,
- 4, 5, 1, 2, 3, 4, 1, 2,
- 3, 4, 1, 2, 1, 2, 1, 2,
- 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 3, 4, 5, 1, 2, 3,
- 4, 5, 1, 2, 3, 1, 2, 1,
- 2, 1, 2, 1, 2, 1, 2, 1,
- 2, 1, 2, 1, 2, 1, 2, 1,
- 2, 1, 2, 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,
-};
-
-RLTable ff_rvlc_rl_intra = {
- 169,
- 103,
- intra_rvlc,
- intra_rvlc_run,
- intra_rvlc_level,
-};
-
-const uint16_t ff_sprite_trajectory_tab[15][2] = {
- {0x00, 2}, {0x02, 3}, {0x03, 3}, {0x04, 3}, {0x05, 3}, {0x06, 3},
- {0x0E, 4}, {0x1E, 5}, {0x3E, 6}, {0x7E, 7}, {0xFE, 8},
- {0x1FE, 9},{0x3FE, 10},{0x7FE, 11},{0xFFE, 12},
-};
-
-const uint8_t ff_mb_type_b_tab[4][2] = {
- {1, 1}, {1, 2}, {1, 3}, {1, 4},
-};
-
-/* these matrixes will be permuted for the idct */
-const int16_t ff_mpeg4_default_intra_matrix[64] = {
- 8, 17, 18, 19, 21, 23, 25, 27,
- 17, 18, 19, 21, 23, 25, 27, 28,
- 20, 21, 22, 23, 24, 26, 28, 30,
- 21, 22, 23, 24, 26, 28, 30, 32,
- 22, 23, 24, 26, 28, 30, 32, 35,
- 23, 24, 26, 28, 30, 32, 35, 38,
- 25, 26, 28, 30, 32, 35, 38, 41,
- 27, 28, 30, 32, 35, 38, 41, 45,
-};
-
-const int16_t ff_mpeg4_default_non_intra_matrix[64] = {
- 16, 17, 18, 19, 20, 21, 22, 23,
- 17, 18, 19, 20, 21, 22, 23, 24,
- 18, 19, 20, 21, 22, 23, 24, 25,
- 19, 20, 21, 22, 23, 24, 26, 27,
- 20, 21, 22, 23, 25, 26, 27, 28,
- 21, 22, 23, 24, 26, 27, 28, 30,
- 22, 23, 24, 26, 27, 28, 30, 31,
- 23, 24, 25, 27, 28, 30, 31, 33,
-};
-
-const uint8_t ff_mpeg4_y_dc_scale_table[32]={
-// 0 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
- 0, 8, 8, 8, 8,10,12,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,34,36,38,40,42,44,46
-};
-const uint8_t ff_mpeg4_c_dc_scale_table[32]={
-// 0 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
- 0, 8, 8, 8, 8, 9, 9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,20,21,22,23,24,25
-};
-
-const uint16_t ff_mpeg4_resync_prefix[8]={
- 0x7F00, 0x7E00, 0x7C00, 0x7800, 0x7000, 0x6000, 0x4000, 0x0000
-};
-
-const uint8_t ff_mpeg4_dc_threshold[8]={
- 99, 13, 15, 17, 19, 21, 23, 0
-};
-
-#endif /* AVCODEC_MPEG4DATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpeg4video.c b/src/thirdparty/ffmpeg/libavcodec/mpeg4video.c
deleted file mode 100644
index 5c2f11e69..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpeg4video.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * MPEG4 decoder / encoder common code.
- * Copyright (c) 2000,2001 Fabrice Bellard
- * Copyright (c) 2002-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
- */
-
-#include "mpegvideo.h"
-#include "mpeg4video.h"
-#include "mpeg4data.h"
-
-uint8_t ff_mpeg4_static_rl_table_store[3][2][2*MAX_RUN + MAX_LEVEL + 3];
-
-int ff_mpeg4_get_video_packet_prefix_length(MpegEncContext *s){
- switch(s->pict_type){
- case AV_PICTURE_TYPE_I:
- return 16;
- case AV_PICTURE_TYPE_P:
- case AV_PICTURE_TYPE_S:
- return s->f_code+15;
- case AV_PICTURE_TYPE_B:
- return FFMAX3(s->f_code, s->b_code, 2) + 15;
- default:
- return -1;
- }
-}
-
-void ff_mpeg4_clean_buffers(MpegEncContext *s)
-{
- int c_wrap, c_xy, l_wrap, l_xy;
-
- l_wrap= s->b8_stride;
- l_xy= (2*s->mb_y-1)*l_wrap + s->mb_x*2 - 1;
- c_wrap= s->mb_stride;
- c_xy= (s->mb_y-1)*c_wrap + s->mb_x - 1;
-
-#if 0
- /* clean DC */
- memsetw(s->dc_val[0] + l_xy, 1024, l_wrap*2+1);
- memsetw(s->dc_val[1] + c_xy, 1024, c_wrap+1);
- memsetw(s->dc_val[2] + c_xy, 1024, c_wrap+1);
-#endif
-
- /* clean AC */
- memset(s->ac_val[0] + l_xy, 0, (l_wrap*2+1)*16*sizeof(int16_t));
- memset(s->ac_val[1] + c_xy, 0, (c_wrap +1)*16*sizeof(int16_t));
- memset(s->ac_val[2] + c_xy, 0, (c_wrap +1)*16*sizeof(int16_t));
-
- /* clean MV */
- // we can't clear the MVs as they might be needed by a b frame
-// memset(s->motion_val + l_xy, 0, (l_wrap*2+1)*2*sizeof(int16_t));
-// memset(s->motion_val, 0, 2*sizeof(int16_t)*(2 + s->mb_width*2)*(2 + s->mb_height*2));
- s->last_mv[0][0][0]=
- s->last_mv[0][0][1]=
- s->last_mv[1][0][0]=
- s->last_mv[1][0][1]= 0;
-}
-
-#define tab_size ((signed)FF_ARRAY_ELEMS(s->direct_scale_mv[0]))
-#define tab_bias (tab_size/2)
-
-//used by mpeg4 and rv10 decoder
-void ff_mpeg4_init_direct_mv(MpegEncContext *s){
- int i;
- for(i=0; i<tab_size; i++){
- s->direct_scale_mv[0][i] = (i-tab_bias)*s->pb_time/s->pp_time;
- s->direct_scale_mv[1][i] = (i-tab_bias)*(s->pb_time-s->pp_time)/s->pp_time;
- }
-}
-
-static inline void ff_mpeg4_set_one_direct_mv(MpegEncContext *s, int mx, int my, int i){
- int xy= s->block_index[i];
- uint16_t time_pp= s->pp_time;
- uint16_t time_pb= s->pb_time;
- int p_mx, p_my;
-
- p_mx = s->next_picture.f.motion_val[0][xy][0];
- if((unsigned)(p_mx + tab_bias) < tab_size){
- s->mv[0][i][0] = s->direct_scale_mv[0][p_mx + tab_bias] + mx;
- s->mv[1][i][0] = mx ? s->mv[0][i][0] - p_mx
- : s->direct_scale_mv[1][p_mx + tab_bias];
- }else{
- s->mv[0][i][0] = p_mx*time_pb/time_pp + mx;
- s->mv[1][i][0] = mx ? s->mv[0][i][0] - p_mx
- : p_mx*(time_pb - time_pp)/time_pp;
- }
- p_my = s->next_picture.f.motion_val[0][xy][1];
- if((unsigned)(p_my + tab_bias) < tab_size){
- s->mv[0][i][1] = s->direct_scale_mv[0][p_my + tab_bias] + my;
- s->mv[1][i][1] = my ? s->mv[0][i][1] - p_my
- : s->direct_scale_mv[1][p_my + tab_bias];
- }else{
- s->mv[0][i][1] = p_my*time_pb/time_pp + my;
- s->mv[1][i][1] = my ? s->mv[0][i][1] - p_my
- : p_my*(time_pb - time_pp)/time_pp;
- }
-}
-
-#undef tab_size
-#undef tab_bias
-
-/**
- *
- * @return the mb_type
- */
-int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my){
- const int mb_index= s->mb_x + s->mb_y*s->mb_stride;
- const int colocated_mb_type = s->next_picture.f.mb_type[mb_index];
- uint16_t time_pp;
- uint16_t time_pb;
- int i;
-
- //FIXME avoid divides
- // try special case with shifts for 1 and 3 B-frames?
-
- if(IS_8X8(colocated_mb_type)){
- s->mv_type = MV_TYPE_8X8;
- for(i=0; i<4; i++){
- ff_mpeg4_set_one_direct_mv(s, mx, my, i);
- }
- return MB_TYPE_DIRECT2 | MB_TYPE_8x8 | MB_TYPE_L0L1;
- } else if(IS_INTERLACED(colocated_mb_type)){
- s->mv_type = MV_TYPE_FIELD;
- for(i=0; i<2; i++){
- int field_select = s->next_picture.f.ref_index[0][4 * mb_index + 2 * i];
- s->field_select[0][i]= field_select;
- s->field_select[1][i]= i;
- if(s->top_field_first){
- time_pp= s->pp_field_time - field_select + i;
- time_pb= s->pb_field_time - field_select + i;
- }else{
- time_pp= s->pp_field_time + field_select - i;
- time_pb= s->pb_field_time + field_select - i;
- }
- s->mv[0][i][0] = s->p_field_mv_table[i][0][mb_index][0]*time_pb/time_pp + mx;
- s->mv[0][i][1] = s->p_field_mv_table[i][0][mb_index][1]*time_pb/time_pp + my;
- s->mv[1][i][0] = mx ? s->mv[0][i][0] - s->p_field_mv_table[i][0][mb_index][0]
- : s->p_field_mv_table[i][0][mb_index][0]*(time_pb - time_pp)/time_pp;
- s->mv[1][i][1] = my ? s->mv[0][i][1] - s->p_field_mv_table[i][0][mb_index][1]
- : s->p_field_mv_table[i][0][mb_index][1]*(time_pb - time_pp)/time_pp;
- }
- return MB_TYPE_DIRECT2 | MB_TYPE_16x8 | MB_TYPE_L0L1 | MB_TYPE_INTERLACED;
- }else{
- ff_mpeg4_set_one_direct_mv(s, mx, my, 0);
- s->mv[0][1][0] = s->mv[0][2][0] = s->mv[0][3][0] = s->mv[0][0][0];
- s->mv[0][1][1] = s->mv[0][2][1] = s->mv[0][3][1] = s->mv[0][0][1];
- s->mv[1][1][0] = s->mv[1][2][0] = s->mv[1][3][0] = s->mv[1][0][0];
- s->mv[1][1][1] = s->mv[1][2][1] = s->mv[1][3][1] = s->mv[1][0][1];
- if((s->avctx->workaround_bugs & FF_BUG_DIRECT_BLOCKSIZE) || !s->quarter_sample)
- s->mv_type= MV_TYPE_16X16;
- else
- s->mv_type= MV_TYPE_8X8;
- return MB_TYPE_DIRECT2 | MB_TYPE_16x16 | MB_TYPE_L0L1; //Note see prev line
- }
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpeg4video.h b/src/thirdparty/ffmpeg/libavcodec/mpeg4video.h
deleted file mode 100644
index 646f8fc33..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpeg4video.h
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * MPEG4 encoder/decoder internal header.
- * Copyright (c) 2000,2001 Fabrice Bellard
- * Copyright (c) 2002-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
- */
-
-#ifndef AVCODEC_MPEG4VIDEO_H
-#define AVCODEC_MPEG4VIDEO_H
-
-#include <stdint.h>
-#include "get_bits.h"
-#include "mpegvideo.h"
-#include "rl.h"
-
-// shapes
-#define RECT_SHAPE 0
-#define BIN_SHAPE 1
-#define BIN_ONLY_SHAPE 2
-#define GRAY_SHAPE 3
-
-#define SIMPLE_VO_TYPE 1
-#define CORE_VO_TYPE 3
-#define MAIN_VO_TYPE 4
-#define NBIT_VO_TYPE 5
-#define ARTS_VO_TYPE 10
-#define ACE_VO_TYPE 12
-#define ADV_SIMPLE_VO_TYPE 17
-
-// aspect_ratio_info
-#define EXTENDED_PAR 15
-
-//vol_sprite_usage / sprite_enable
-#define STATIC_SPRITE 1
-#define GMC_SPRITE 2
-
-#define MOTION_MARKER 0x1F001
-#define DC_MARKER 0x6B001
-
-#define VOS_STARTCODE 0x1B0
-#define USER_DATA_STARTCODE 0x1B2
-#define GOP_STARTCODE 0x1B3
-#define VISUAL_OBJ_STARTCODE 0x1B5
-#define VOP_STARTCODE 0x1B6
-
-/* dc encoding for mpeg4 */
-extern const uint8_t ff_mpeg4_DCtab_lum[13][2];
-extern const uint8_t ff_mpeg4_DCtab_chrom[13][2];
-
-extern const uint16_t ff_mpeg4_intra_vlc[103][2];
-extern RLTable ff_mpeg4_rl_intra;
-
-/* Note this is identical to the intra rvlc except that it is reordered. */
-extern RLTable ff_rvlc_rl_inter;
-extern RLTable ff_rvlc_rl_intra;
-
-extern const uint16_t ff_sprite_trajectory_tab[15][2];
-extern const uint8_t ff_mb_type_b_tab[4][2];
-
-/* these matrixes will be permuted for the idct */
-extern const int16_t ff_mpeg4_default_intra_matrix[64];
-extern const int16_t ff_mpeg4_default_non_intra_matrix[64];
-
-extern const uint8_t ff_mpeg4_y_dc_scale_table[32];
-extern const uint8_t ff_mpeg4_c_dc_scale_table[32];
-extern const uint16_t ff_mpeg4_resync_prefix[8];
-
-extern const uint8_t ff_mpeg4_dc_threshold[8];
-
-void ff_mpeg4_encode_mb(MpegEncContext *s,
- int16_t block[6][64],
- int motion_x, int motion_y);
-void ff_mpeg4_pred_ac(MpegEncContext * s, int16_t *block, int n,
- int dir);
-void ff_set_mpeg4_time(MpegEncContext * s);
-void ff_mpeg4_encode_picture_header(MpegEncContext *s, int picture_number);
-
-int ff_mpeg4_decode_picture_header(MpegEncContext * s, GetBitContext *gb);
-void ff_mpeg4_encode_video_packet_header(MpegEncContext *s);
-void ff_mpeg4_clean_buffers(MpegEncContext *s);
-void ff_mpeg4_stuffing(PutBitContext * pbc);
-void ff_mpeg4_init_partitions(MpegEncContext *s);
-void ff_mpeg4_merge_partitions(MpegEncContext *s);
-void ff_clean_mpeg4_qscales(MpegEncContext *s);
-int ff_mpeg4_decode_partitions(MpegEncContext *s);
-int ff_mpeg4_get_video_packet_prefix_length(MpegEncContext *s);
-int ff_mpeg4_decode_video_packet_header(MpegEncContext *s);
-void ff_mpeg4_init_direct_mv(MpegEncContext *s);
-void ff_mpeg4videodec_static_init(void);
-
-/**
- *
- * @return the mb_type
- */
-int ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my);
-
-extern uint8_t ff_mpeg4_static_rl_table_store[3][2][2*MAX_RUN + MAX_LEVEL + 3];
-
-
-#if 0 //3IV1 is quite rare and it slows things down a tiny bit
-#define IS_3IV1 s->codec_tag == AV_RL32("3IV1")
-#else
-#define IS_3IV1 0
-#endif
-
-
-/**
- * Predict the dc.
- * encoding quantized level -> quantized diff
- * decoding quantized diff -> quantized level
- * @param n block index (0-3 are luma, 4-5 are chroma)
- * @param dir_ptr pointer to an integer where the prediction direction will be stored
- */
-static inline int ff_mpeg4_pred_dc(MpegEncContext * s, int n, int level, int *dir_ptr, int encoding)
-{
- int a, b, c, wrap, pred, scale, ret;
- int16_t *dc_val;
-
- /* find prediction */
- if (n < 4) {
- scale = s->y_dc_scale;
- } else {
- scale = s->c_dc_scale;
- }
- if(IS_3IV1)
- scale= 8;
-
- wrap= s->block_wrap[n];
- dc_val = s->dc_val[0] + s->block_index[n];
-
- /* B C
- * A X
- */
- a = dc_val[ - 1];
- b = dc_val[ - 1 - wrap];
- c = dc_val[ - wrap];
-
- /* outside slice handling (we can't do that by memset as we need the dc for error resilience) */
- if(s->first_slice_line && n!=3){
- if(n!=2) b=c= 1024;
- if(n!=1 && s->mb_x == s->resync_mb_x) b=a= 1024;
- }
- if(s->mb_x == s->resync_mb_x && s->mb_y == s->resync_mb_y+1){
- if(n==0 || n==4 || n==5)
- b=1024;
- }
-
- if (abs(a - b) < abs(b - c)) {
- pred = c;
- *dir_ptr = 1; /* top */
- } else {
- pred = a;
- *dir_ptr = 0; /* left */
- }
- /* we assume pred is positive */
- pred = FASTDIV((pred + (scale >> 1)), scale);
-
- if(encoding){
- ret = level - pred;
- }else{
- level += pred;
- ret= level;
- if(s->err_recognition&(AV_EF_BITSTREAM|AV_EF_AGGRESSIVE)){
- if(level<0){
- av_log(s->avctx, AV_LOG_ERROR, "dc<0 at %dx%d\n", s->mb_x, s->mb_y);
- return -1;
- }
- if(level*scale > 2048 + scale){
- av_log(s->avctx, AV_LOG_ERROR, "dc overflow at %dx%d\n", s->mb_x, s->mb_y);
- return -1;
- }
- }
- }
- level *=scale;
- if(level&(~2047)){
- if(level<0)
- level=0;
- else if(!(s->workaround_bugs&FF_BUG_DC_CLIP))
- level=2047;
- }
- dc_val[0]= level;
-
- return ret;
-}
-#endif /* AVCODEC_MPEG4VIDEO_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpeg4video_parser.c b/src/thirdparty/ffmpeg/libavcodec/mpeg4video_parser.c
deleted file mode 100644
index 214062896..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpeg4video_parser.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * MPEG4 Video frame extraction
- * Copyright (c) 2003 Fabrice Bellard
- * Copyright (c) 2003 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
- */
-
-#define UNCHECKED_BITSTREAM_READER 1
-
-#include "parser.h"
-#include "mpegvideo.h"
-#include "mpeg4video.h"
-#include "mpeg4video_parser.h"
-
-struct Mp4vParseContext {
- ParseContext pc;
- struct MpegEncContext enc;
- int first_picture;
-};
-
-int ff_mpeg4_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size){
- int vop_found, i;
- uint32_t state;
-
- vop_found= pc->frame_start_found;
- state= pc->state;
-
- i=0;
- if(!vop_found){
- for(i=0; i<buf_size; i++){
- state= (state<<8) | buf[i];
- if(state == 0x1B6){
- i++;
- vop_found=1;
- break;
- }
- }
- }
-
- if(vop_found){
- /* EOF considered as end of frame */
- if (buf_size == 0)
- return 0;
- for(; i<buf_size; i++){
- state= (state<<8) | buf[i];
- if((state&0xFFFFFF00) == 0x100){
- pc->frame_start_found=0;
- pc->state=-1;
- return i-3;
- }
- }
- }
- pc->frame_start_found= vop_found;
- pc->state= state;
- return END_NOT_FOUND;
-}
-
-/* XXX: make it use less memory */
-static int av_mpeg4_decode_header(AVCodecParserContext *s1,
- AVCodecContext *avctx,
- const uint8_t *buf, int buf_size)
-{
- struct Mp4vParseContext *pc = s1->priv_data;
- MpegEncContext *s = &pc->enc;
- GetBitContext gb1, *gb = &gb1;
- int ret;
-
- s->avctx = avctx;
- s->current_picture_ptr = &s->current_picture;
-
- if (avctx->extradata_size && pc->first_picture){
- init_get_bits(gb, avctx->extradata, avctx->extradata_size*8);
- ret = ff_mpeg4_decode_picture_header(s, gb);
- }
-
- init_get_bits(gb, buf, 8 * buf_size);
- ret = ff_mpeg4_decode_picture_header(s, gb);
- if (s->width && (!avctx->width || !avctx->height || !avctx->coded_width || !avctx->coded_height)) {
- avcodec_set_dimensions(avctx, s->width, s->height);
- }
- if((s1->flags & PARSER_FLAG_USE_CODEC_TS) && s->avctx->time_base.den>0 && ret>=0){
- av_assert1(s1->pts == AV_NOPTS_VALUE);
- av_assert1(s1->dts == AV_NOPTS_VALUE);
-
- s1->pts = av_rescale_q(s->time, (AVRational){1, s->avctx->time_base.den}, (AVRational){1, 1200000});
- }
-
- s1->pict_type= s->pict_type;
- pc->first_picture = 0;
- return ret;
-}
-
-static av_cold int mpeg4video_parse_init(AVCodecParserContext *s)
-{
- struct Mp4vParseContext *pc = s->priv_data;
-
- ff_mpeg4videodec_static_init();
-
- pc->first_picture = 1;
- pc->enc.quant_precision=5;
- pc->enc.slice_context_count = 1;
- return 0;
-}
-
-static int mpeg4video_parse(AVCodecParserContext *s,
- AVCodecContext *avctx,
- const uint8_t **poutbuf, int *poutbuf_size,
- const uint8_t *buf, int buf_size)
-{
- ParseContext *pc = s->priv_data;
- int next;
-
- if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){
- next= buf_size;
- }else{
- next= ff_mpeg4_find_frame_end(pc, buf, buf_size);
-
- if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
- *poutbuf = NULL;
- *poutbuf_size = 0;
- return buf_size;
- }
- }
- av_mpeg4_decode_header(s, avctx, buf, buf_size);
-
- *poutbuf = buf;
- *poutbuf_size = buf_size;
- return next;
-}
-
-
-AVCodecParser ff_mpeg4video_parser = {
- .codec_ids = { AV_CODEC_ID_MPEG4 },
- .priv_data_size = sizeof(struct Mp4vParseContext),
- .parser_init = mpeg4video_parse_init,
- .parser_parse = mpeg4video_parse,
- .parser_close = ff_parse_close,
- .split = ff_mpeg4video_split,
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpeg4video_parser.h b/src/thirdparty/ffmpeg/libavcodec/mpeg4video_parser.h
deleted file mode 100644
index cad109995..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpeg4video_parser.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * MPEG4 video parser prototypes
- * Copyright (c) 2003 Fabrice Bellard
- * Copyright (c) 2003 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
- */
-
-#ifndef AVCODEC_MPEG4VIDEO_PARSER_H
-#define AVCODEC_MPEG4VIDEO_PARSER_H
-
-#include "parser.h"
-
-/**
- * Find the end of the current frame in the bitstream.
- * @return the position of the first byte of the next frame, or -1
- */
-int ff_mpeg4_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size);
-
-#endif /* AVCODEC_MPEG4VIDEO_PARSER_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpeg4videodec.c b/src/thirdparty/ffmpeg/libavcodec/mpeg4videodec.c
deleted file mode 100644
index fb4e28aca..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpeg4videodec.c
+++ /dev/null
@@ -1,2385 +0,0 @@
-/*
- * MPEG4 decoder.
- * Copyright (c) 2000,2001 Fabrice Bellard
- * Copyright (c) 2002-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
- */
-
-#define UNCHECKED_BITSTREAM_READER 1
-
-#include "libavutil/opt.h"
-#include "mpegvideo.h"
-#include "mpeg4video.h"
-#include "h263.h"
-#include "thread.h"
-
-// The defines below define the number of bits that are read at once for
-// reading vlc values. Changing these may improve speed and data cache needs
-// be aware though that decreasing them may need the number of stages that is
-// passed to get_vlc* to be increased.
-#define SPRITE_TRAJ_VLC_BITS 6
-#define DC_VLC_BITS 9
-#define MB_TYPE_B_VLC_BITS 4
-
-
-static VLC dc_lum, dc_chrom;
-static VLC sprite_trajectory;
-static VLC mb_type_b_vlc;
-
-static const int mb_type_b_map[4]= {
- MB_TYPE_DIRECT2 | MB_TYPE_L0L1,
- MB_TYPE_L0L1 | MB_TYPE_16x16,
- MB_TYPE_L1 | MB_TYPE_16x16,
- MB_TYPE_L0 | MB_TYPE_16x16,
-};
-
-/**
- * Predict the ac.
- * @param n block index (0-3 are luma, 4-5 are chroma)
- * @param dir the ac prediction direction
- */
-void ff_mpeg4_pred_ac(MpegEncContext * s, int16_t *block, int n,
- int dir)
-{
- int i;
- int16_t *ac_val, *ac_val1;
- int8_t * const qscale_table = s->current_picture.f.qscale_table;
-
- /* find prediction */
- ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
- ac_val1 = ac_val;
- if (s->ac_pred) {
- if (dir == 0) {
- const int xy= s->mb_x-1 + s->mb_y*s->mb_stride;
- /* left prediction */
- ac_val -= 16;
-
- if(s->mb_x==0 || s->qscale == qscale_table[xy] || n==1 || n==3){
- /* same qscale */
- for(i=1;i<8;i++) {
- block[s->dsp.idct_permutation[i<<3]] += ac_val[i];
- }
- }else{
- /* different qscale, we must rescale */
- for(i=1;i<8;i++) {
- block[s->dsp.idct_permutation[i<<3]] += ROUNDED_DIV(ac_val[i]*qscale_table[xy], s->qscale);
- }
- }
- } else {
- const int xy= s->mb_x + s->mb_y*s->mb_stride - s->mb_stride;
- /* top prediction */
- ac_val -= 16 * s->block_wrap[n];
-
- if(s->mb_y==0 || s->qscale == qscale_table[xy] || n==2 || n==3){
- /* same qscale */
- for(i=1;i<8;i++) {
- block[s->dsp.idct_permutation[i]] += ac_val[i + 8];
- }
- }else{
- /* different qscale, we must rescale */
- for(i=1;i<8;i++) {
- block[s->dsp.idct_permutation[i]] += ROUNDED_DIV(ac_val[i + 8]*qscale_table[xy], s->qscale);
- }
- }
- }
- }
- /* left copy */
- for(i=1;i<8;i++)
- ac_val1[i ] = block[s->dsp.idct_permutation[i<<3]];
-
- /* top copy */
- for(i=1;i<8;i++)
- ac_val1[8 + i] = block[s->dsp.idct_permutation[i ]];
-
-}
-
-/**
- * check if the next stuff is a resync marker or the end.
- * @return 0 if not
- */
-static inline int mpeg4_is_resync(MpegEncContext *s){
- int bits_count= get_bits_count(&s->gb);
- int v= show_bits(&s->gb, 16);
-
- if(s->workaround_bugs&FF_BUG_NO_PADDING && !s->resync_marker){
- return 0;
- }
-
- while(v<=0xFF){
- if(s->pict_type==AV_PICTURE_TYPE_B || (v>>(8-s->pict_type)!=1) || s->partitioned_frame)
- break;
- skip_bits(&s->gb, 8+s->pict_type);
- bits_count+= 8+s->pict_type;
- v= show_bits(&s->gb, 16);
- }
-
- if(bits_count + 8 >= s->gb.size_in_bits){
- v>>=8;
- v|= 0x7F >> (7-(bits_count&7));
-
- if(v==0x7F)
- return s->mb_num;
- }else{
- if(v == ff_mpeg4_resync_prefix[bits_count&7]){
- int len, mb_num;
- int mb_num_bits= av_log2(s->mb_num - 1) + 1;
- GetBitContext gb= s->gb;
-
- skip_bits(&s->gb, 1);
- align_get_bits(&s->gb);
-
- for(len=0; len<32; len++){
- if(get_bits1(&s->gb)) break;
- }
-
- mb_num= get_bits(&s->gb, mb_num_bits);
- if(!mb_num || mb_num > s->mb_num || get_bits_count(&s->gb)+6 > s->gb.size_in_bits)
- mb_num= -1;
-
- s->gb= gb;
-
- if(len>=ff_mpeg4_get_video_packet_prefix_length(s))
- return mb_num;
- }
- }
- return 0;
-}
-
-static int mpeg4_decode_sprite_trajectory(MpegEncContext * s, GetBitContext *gb)
-{
- int i;
- int a= 2<<s->sprite_warping_accuracy;
- int rho= 3-s->sprite_warping_accuracy;
- int r=16/a;
- const int vop_ref[4][2]= {{0,0}, {s->width,0}, {0, s->height}, {s->width, s->height}}; // only true for rectangle shapes
- int d[4][2]={{0,0}, {0,0}, {0,0}, {0,0}};
- int sprite_ref[4][2];
- int virtual_ref[2][2];
- int w2, h2, w3, h3;
- int alpha=0, beta=0;
- int w= s->width;
- int h= s->height;
- int min_ab;
-
- if(w<=0 || h<=0)
- return -1;
-
- for(i=0; i<s->num_sprite_warping_points; i++){
- int length;
- int x=0, y=0;
-
- length= get_vlc2(gb, sprite_trajectory.table, SPRITE_TRAJ_VLC_BITS, 3);
- if(length){
- x= get_xbits(gb, length);
- }
- if(!(s->divx_version==500 && s->divx_build==413)) skip_bits1(gb); /* marker bit */
-
- length= get_vlc2(gb, sprite_trajectory.table, SPRITE_TRAJ_VLC_BITS, 3);
- if(length){
- y=get_xbits(gb, length);
- }
- skip_bits1(gb); /* marker bit */
- s->sprite_traj[i][0]= d[i][0]= x;
- s->sprite_traj[i][1]= d[i][1]= y;
- }
- for(; i<4; i++)
- s->sprite_traj[i][0]= s->sprite_traj[i][1]= 0;
-
- while((1<<alpha)<w) alpha++;
- while((1<<beta )<h) beta++; // there seems to be a typo in the mpeg4 std for the definition of w' and h'
- w2= 1<<alpha;
- h2= 1<<beta;
-
-// Note, the 4th point isn't used for GMC
- if(s->divx_version==500 && s->divx_build==413){
- sprite_ref[0][0]= a*vop_ref[0][0] + d[0][0];
- sprite_ref[0][1]= a*vop_ref[0][1] + d[0][1];
- sprite_ref[1][0]= a*vop_ref[1][0] + d[0][0] + d[1][0];
- sprite_ref[1][1]= a*vop_ref[1][1] + d[0][1] + d[1][1];
- sprite_ref[2][0]= a*vop_ref[2][0] + d[0][0] + d[2][0];
- sprite_ref[2][1]= a*vop_ref[2][1] + d[0][1] + d[2][1];
- } else {
- sprite_ref[0][0]= (a>>1)*(2*vop_ref[0][0] + d[0][0]);
- sprite_ref[0][1]= (a>>1)*(2*vop_ref[0][1] + d[0][1]);
- sprite_ref[1][0]= (a>>1)*(2*vop_ref[1][0] + d[0][0] + d[1][0]);
- sprite_ref[1][1]= (a>>1)*(2*vop_ref[1][1] + d[0][1] + d[1][1]);
- sprite_ref[2][0]= (a>>1)*(2*vop_ref[2][0] + d[0][0] + d[2][0]);
- sprite_ref[2][1]= (a>>1)*(2*vop_ref[2][1] + d[0][1] + d[2][1]);
- }
-/* sprite_ref[3][0]= (a>>1)*(2*vop_ref[3][0] + d[0][0] + d[1][0] + d[2][0] + d[3][0]);
- sprite_ref[3][1]= (a>>1)*(2*vop_ref[3][1] + d[0][1] + d[1][1] + d[2][1] + d[3][1]); */
-
-// this is mostly identical to the mpeg4 std (and is totally unreadable because of that ...)
-// perhaps it should be reordered to be more readable ...
-// the idea behind this virtual_ref mess is to be able to use shifts later per pixel instead of divides
-// so the distance between points is converted from w&h based to w2&h2 based which are of the 2^x form
- virtual_ref[0][0]= 16*(vop_ref[0][0] + w2)
- + ROUNDED_DIV(((w - w2)*(r*sprite_ref[0][0] - 16*vop_ref[0][0]) + w2*(r*sprite_ref[1][0] - 16*vop_ref[1][0])),w);
- virtual_ref[0][1]= 16*vop_ref[0][1]
- + ROUNDED_DIV(((w - w2)*(r*sprite_ref[0][1] - 16*vop_ref[0][1]) + w2*(r*sprite_ref[1][1] - 16*vop_ref[1][1])),w);
- virtual_ref[1][0]= 16*vop_ref[0][0]
- + ROUNDED_DIV(((h - h2)*(r*sprite_ref[0][0] - 16*vop_ref[0][0]) + h2*(r*sprite_ref[2][0] - 16*vop_ref[2][0])),h);
- virtual_ref[1][1]= 16*(vop_ref[0][1] + h2)
- + ROUNDED_DIV(((h - h2)*(r*sprite_ref[0][1] - 16*vop_ref[0][1]) + h2*(r*sprite_ref[2][1] - 16*vop_ref[2][1])),h);
-
- switch(s->num_sprite_warping_points)
- {
- case 0:
- s->sprite_offset[0][0]= 0;
- s->sprite_offset[0][1]= 0;
- s->sprite_offset[1][0]= 0;
- s->sprite_offset[1][1]= 0;
- s->sprite_delta[0][0]= a;
- s->sprite_delta[0][1]= 0;
- s->sprite_delta[1][0]= 0;
- s->sprite_delta[1][1]= a;
- s->sprite_shift[0]= 0;
- s->sprite_shift[1]= 0;
- break;
- case 1: //GMC only
- s->sprite_offset[0][0]= sprite_ref[0][0] - a*vop_ref[0][0];
- s->sprite_offset[0][1]= sprite_ref[0][1] - a*vop_ref[0][1];
- s->sprite_offset[1][0]= ((sprite_ref[0][0]>>1)|(sprite_ref[0][0]&1)) - a*(vop_ref[0][0]/2);
- s->sprite_offset[1][1]= ((sprite_ref[0][1]>>1)|(sprite_ref[0][1]&1)) - a*(vop_ref[0][1]/2);
- s->sprite_delta[0][0]= a;
- s->sprite_delta[0][1]= 0;
- s->sprite_delta[1][0]= 0;
- s->sprite_delta[1][1]= a;
- s->sprite_shift[0]= 0;
- s->sprite_shift[1]= 0;
- break;
- case 2:
- s->sprite_offset[0][0]= (sprite_ref[0][0]<<(alpha+rho))
- + (-r*sprite_ref[0][0] + virtual_ref[0][0])*(-vop_ref[0][0])
- + ( r*sprite_ref[0][1] - virtual_ref[0][1])*(-vop_ref[0][1])
- + (1<<(alpha+rho-1));
- s->sprite_offset[0][1]= (sprite_ref[0][1]<<(alpha+rho))
- + (-r*sprite_ref[0][1] + virtual_ref[0][1])*(-vop_ref[0][0])
- + (-r*sprite_ref[0][0] + virtual_ref[0][0])*(-vop_ref[0][1])
- + (1<<(alpha+rho-1));
- s->sprite_offset[1][0]= ( (-r*sprite_ref[0][0] + virtual_ref[0][0])*(-2*vop_ref[0][0] + 1)
- +( r*sprite_ref[0][1] - virtual_ref[0][1])*(-2*vop_ref[0][1] + 1)
- +2*w2*r*sprite_ref[0][0]
- - 16*w2
- + (1<<(alpha+rho+1)));
- s->sprite_offset[1][1]= ( (-r*sprite_ref[0][1] + virtual_ref[0][1])*(-2*vop_ref[0][0] + 1)
- +(-r*sprite_ref[0][0] + virtual_ref[0][0])*(-2*vop_ref[0][1] + 1)
- +2*w2*r*sprite_ref[0][1]
- - 16*w2
- + (1<<(alpha+rho+1)));
- s->sprite_delta[0][0]= (-r*sprite_ref[0][0] + virtual_ref[0][0]);
- s->sprite_delta[0][1]= (+r*sprite_ref[0][1] - virtual_ref[0][1]);
- s->sprite_delta[1][0]= (-r*sprite_ref[0][1] + virtual_ref[0][1]);
- s->sprite_delta[1][1]= (-r*sprite_ref[0][0] + virtual_ref[0][0]);
-
- s->sprite_shift[0]= alpha+rho;
- s->sprite_shift[1]= alpha+rho+2;
- break;
- case 3:
- min_ab= FFMIN(alpha, beta);
- w3= w2>>min_ab;
- h3= h2>>min_ab;
- s->sprite_offset[0][0]= (sprite_ref[0][0]<<(alpha+beta+rho-min_ab))
- + (-r*sprite_ref[0][0] + virtual_ref[0][0])*h3*(-vop_ref[0][0])
- + (-r*sprite_ref[0][0] + virtual_ref[1][0])*w3*(-vop_ref[0][1])
- + (1<<(alpha+beta+rho-min_ab-1));
- s->sprite_offset[0][1]= (sprite_ref[0][1]<<(alpha+beta+rho-min_ab))
- + (-r*sprite_ref[0][1] + virtual_ref[0][1])*h3*(-vop_ref[0][0])
- + (-r*sprite_ref[0][1] + virtual_ref[1][1])*w3*(-vop_ref[0][1])
- + (1<<(alpha+beta+rho-min_ab-1));
- s->sprite_offset[1][0]= (-r*sprite_ref[0][0] + virtual_ref[0][0])*h3*(-2*vop_ref[0][0] + 1)
- + (-r*sprite_ref[0][0] + virtual_ref[1][0])*w3*(-2*vop_ref[0][1] + 1)
- + 2*w2*h3*r*sprite_ref[0][0]
- - 16*w2*h3
- + (1<<(alpha+beta+rho-min_ab+1));
- s->sprite_offset[1][1]= (-r*sprite_ref[0][1] + virtual_ref[0][1])*h3*(-2*vop_ref[0][0] + 1)
- + (-r*sprite_ref[0][1] + virtual_ref[1][1])*w3*(-2*vop_ref[0][1] + 1)
- + 2*w2*h3*r*sprite_ref[0][1]
- - 16*w2*h3
- + (1<<(alpha+beta+rho-min_ab+1));
- s->sprite_delta[0][0]= (-r*sprite_ref[0][0] + virtual_ref[0][0])*h3;
- s->sprite_delta[0][1]= (-r*sprite_ref[0][0] + virtual_ref[1][0])*w3;
- s->sprite_delta[1][0]= (-r*sprite_ref[0][1] + virtual_ref[0][1])*h3;
- s->sprite_delta[1][1]= (-r*sprite_ref[0][1] + virtual_ref[1][1])*w3;
-
- s->sprite_shift[0]= alpha + beta + rho - min_ab;
- s->sprite_shift[1]= alpha + beta + rho - min_ab + 2;
- break;
- }
- /* try to simplify the situation */
- if( s->sprite_delta[0][0] == a<<s->sprite_shift[0]
- && s->sprite_delta[0][1] == 0
- && s->sprite_delta[1][0] == 0
- && s->sprite_delta[1][1] == a<<s->sprite_shift[0])
- {
- s->sprite_offset[0][0]>>=s->sprite_shift[0];
- s->sprite_offset[0][1]>>=s->sprite_shift[0];
- s->sprite_offset[1][0]>>=s->sprite_shift[1];
- s->sprite_offset[1][1]>>=s->sprite_shift[1];
- s->sprite_delta[0][0]= a;
- s->sprite_delta[0][1]= 0;
- s->sprite_delta[1][0]= 0;
- s->sprite_delta[1][1]= a;
- s->sprite_shift[0]= 0;
- s->sprite_shift[1]= 0;
- s->real_sprite_warping_points=1;
- }
- else{
- int shift_y= 16 - s->sprite_shift[0];
- int shift_c= 16 - s->sprite_shift[1];
- for(i=0; i<2; i++){
- s->sprite_offset[0][i]<<= shift_y;
- s->sprite_offset[1][i]<<= shift_c;
- s->sprite_delta[0][i]<<= shift_y;
- s->sprite_delta[1][i]<<= shift_y;
- s->sprite_shift[i]= 16;
- }
- s->real_sprite_warping_points= s->num_sprite_warping_points;
- }
- return 0;
-}
-
-/**
- * Decode the next video packet.
- * @return <0 if something went wrong
- */
-int ff_mpeg4_decode_video_packet_header(MpegEncContext *s)
-{
- int mb_num_bits= av_log2(s->mb_num - 1) + 1;
- int header_extension=0, mb_num, len;
-
- /* is there enough space left for a video packet + header */
- if( get_bits_count(&s->gb) > s->gb.size_in_bits-20) return -1;
-
- for(len=0; len<32; len++){
- if(get_bits1(&s->gb)) break;
- }
-
- if(len!=ff_mpeg4_get_video_packet_prefix_length(s)){
- av_log(s->avctx, AV_LOG_ERROR, "marker does not match f_code\n");
- return -1;
- }
-
- if(s->shape != RECT_SHAPE){
- header_extension= get_bits1(&s->gb);
- //FIXME more stuff here
- }
-
- mb_num= get_bits(&s->gb, mb_num_bits);
- if(mb_num>=s->mb_num){
- av_log(s->avctx, AV_LOG_ERROR, "illegal mb_num in video packet (%d %d) \n", mb_num, s->mb_num);
- return -1;
- }
-
- s->mb_x= mb_num % s->mb_width;
- s->mb_y= mb_num / s->mb_width;
-
- if(s->shape != BIN_ONLY_SHAPE){
- int qscale= get_bits(&s->gb, s->quant_precision);
- if(qscale)
- s->chroma_qscale=s->qscale= qscale;
- }
-
- if(s->shape == RECT_SHAPE){
- header_extension= get_bits1(&s->gb);
- }
- if(header_extension){
- int time_incr=0;
-
- while (get_bits1(&s->gb) != 0)
- time_incr++;
-
- check_marker(&s->gb, "before time_increment in video packed header");
- skip_bits(&s->gb, s->time_increment_bits); /* time_increment */
- check_marker(&s->gb, "before vop_coding_type in video packed header");
-
- skip_bits(&s->gb, 2); /* vop coding type */
- //FIXME not rect stuff here
-
- if(s->shape != BIN_ONLY_SHAPE){
- skip_bits(&s->gb, 3); /* intra dc vlc threshold */
-//FIXME don't just ignore everything
- if(s->pict_type == AV_PICTURE_TYPE_S && s->vol_sprite_usage==GMC_SPRITE){
- if(mpeg4_decode_sprite_trajectory(s, &s->gb) < 0)
- return -1;
- av_log(s->avctx, AV_LOG_ERROR, "untested\n");
- }
-
- //FIXME reduced res stuff here
-
- if (s->pict_type != AV_PICTURE_TYPE_I) {
- int f_code = get_bits(&s->gb, 3); /* fcode_for */
- if(f_code==0){
- av_log(s->avctx, AV_LOG_ERROR, "Error, video packet header damaged (f_code=0)\n");
- }
- }
- if (s->pict_type == AV_PICTURE_TYPE_B) {
- int b_code = get_bits(&s->gb, 3);
- if(b_code==0){
- av_log(s->avctx, AV_LOG_ERROR, "Error, video packet header damaged (b_code=0)\n");
- }
- }
- }
- }
- //FIXME new-pred stuff
-
- return 0;
-}
-
-/**
- * Get the average motion vector for a GMC MB.
- * @param n either 0 for the x component or 1 for y
- * @return the average MV for a GMC MB
- */
-static inline int get_amv(MpegEncContext *s, int n){
- int x, y, mb_v, sum, dx, dy, shift;
- int len = 1 << (s->f_code + 4);
- const int a= s->sprite_warping_accuracy;
-
- if(s->workaround_bugs & FF_BUG_AMV)
- len >>= s->quarter_sample;
-
- if(s->real_sprite_warping_points==1){
- if(s->divx_version==500 && s->divx_build==413)
- sum= s->sprite_offset[0][n] / (1<<(a - s->quarter_sample));
- else
- sum= RSHIFT(s->sprite_offset[0][n]<<s->quarter_sample, a);
- }else{
- dx= s->sprite_delta[n][0];
- dy= s->sprite_delta[n][1];
- shift= s->sprite_shift[0];
- if(n) dy -= 1<<(shift + a + 1);
- else dx -= 1<<(shift + a + 1);
- mb_v= s->sprite_offset[0][n] + dx*s->mb_x*16 + dy*s->mb_y*16;
-
- sum=0;
- for(y=0; y<16; y++){
- int v;
-
- v= mb_v + dy*y;
- //XXX FIXME optimize
- for(x=0; x<16; x++){
- sum+= v>>shift;
- v+= dx;
- }
- }
- sum= RSHIFT(sum, a+8-s->quarter_sample);
- }
-
- if (sum < -len) sum= -len;
- else if (sum >= len) sum= len-1;
-
- return sum;
-}
-
-/**
- * Decode the dc value.
- * @param n block index (0-3 are luma, 4-5 are chroma)
- * @param dir_ptr the prediction direction will be stored here
- * @return the quantized dc
- */
-static inline int mpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr)
-{
- int level, code;
-
- if (n < 4)
- code = get_vlc2(&s->gb, dc_lum.table, DC_VLC_BITS, 1);
- else
- code = get_vlc2(&s->gb, dc_chrom.table, DC_VLC_BITS, 1);
- if (code < 0 || code > 9 /* && s->nbit<9 */){
- av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");
- return -1;
- }
- if (code == 0) {
- level = 0;
- } else {
- if(IS_3IV1){
- if(code==1)
- level= 2*get_bits1(&s->gb)-1;
- else{
- if(get_bits1(&s->gb))
- level = get_bits(&s->gb, code-1) + (1<<(code-1));
- else
- level = -get_bits(&s->gb, code-1) - (1<<(code-1));
- }
- }else{
- level = get_xbits(&s->gb, code);
- }
-
- if (code > 8){
- if(get_bits1(&s->gb)==0){ /* marker */
- if(s->err_recognition&(AV_EF_BITSTREAM|AV_EF_COMPLIANT)){
- av_log(s->avctx, AV_LOG_ERROR, "dc marker bit missing\n");
- return -1;
- }
- }
- }
- }
-
- return ff_mpeg4_pred_dc(s, n, level, dir_ptr, 0);
-}
-
-/**
- * Decode first partition.
- * @return number of MBs decoded or <0 if an error occurred
- */
-static int mpeg4_decode_partition_a(MpegEncContext *s){
- int mb_num;
- static const int8_t quant_tab[4] = { -1, -2, 1, 2 };
-
- /* decode first partition */
- mb_num=0;
- s->first_slice_line=1;
- for(; s->mb_y<s->mb_height; s->mb_y++){
- ff_init_block_index(s);
- for(; s->mb_x<s->mb_width; s->mb_x++){
- const int xy= s->mb_x + s->mb_y*s->mb_stride;
- int cbpc;
- int dir=0;
-
- mb_num++;
- ff_update_block_index(s);
- if(s->mb_x == s->resync_mb_x && s->mb_y == s->resync_mb_y+1)
- s->first_slice_line=0;
-
- if(s->pict_type==AV_PICTURE_TYPE_I){
- int i;
-
- do{
- if(show_bits_long(&s->gb, 19)==DC_MARKER){
- return mb_num-1;
- }
-
- 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);
- return -1;
- }
- }while(cbpc == 8);
-
- s->cbp_table[xy]= cbpc & 3;
- s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA;
- s->mb_intra = 1;
-
- if(cbpc & 4) {
- ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]);
- }
- s->current_picture.f.qscale_table[xy]= s->qscale;
-
- s->mbintra_table[xy]= 1;
- for(i=0; i<6; i++){
- int dc_pred_dir;
- int dc= mpeg4_decode_dc(s, i, &dc_pred_dir);
- if(dc < 0){
- av_log(s->avctx, AV_LOG_ERROR, "DC corrupted at %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
- dir<<=1;
- if(dc_pred_dir) dir|=1;
- }
- s->pred_dir_table[xy]= dir;
- }else{ /* P/S_TYPE */
- int mx, my, pred_x, pred_y, bits;
- int16_t * const mot_val = s->current_picture.f.motion_val[0][s->block_index[0]];
- const int stride= s->b8_stride*2;
-
-try_again:
- bits= show_bits(&s->gb, 17);
- if(bits==MOTION_MARKER){
- return mb_num-1;
- }
- skip_bits1(&s->gb);
- if(bits&0x10000){
- /* skip mb */
- if(s->pict_type==AV_PICTURE_TYPE_S && s->vol_sprite_usage==GMC_SPRITE){
- s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_GMC | MB_TYPE_L0;
- mx= get_amv(s, 0);
- my= get_amv(s, 1);
- }else{
- s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
- mx=my=0;
- }
- mot_val[0 ]= mot_val[2 ]=
- mot_val[0+stride]= mot_val[2+stride]= mx;
- mot_val[1 ]= mot_val[3 ]=
- mot_val[1+stride]= mot_val[3+stride]= my;
-
- if(s->mbintra_table[xy])
- ff_clean_intra_table_entries(s);
- continue;
- }
-
- 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);
- return -1;
- }
- if(cbpc == 20)
- goto try_again;
-
- s->cbp_table[xy]= cbpc&(8+3); //8 is dquant
-
- s->mb_intra = ((cbpc & 4) != 0);
-
- if(s->mb_intra){
- s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA;
- s->mbintra_table[xy]= 1;
- mot_val[0 ]= mot_val[2 ]=
- mot_val[0+stride]= mot_val[2+stride]= 0;
- mot_val[1 ]= mot_val[3 ]=
- mot_val[1+stride]= mot_val[3+stride]= 0;
- }else{
- if(s->mbintra_table[xy])
- ff_clean_intra_table_entries(s);
-
- if(s->pict_type==AV_PICTURE_TYPE_S && s->vol_sprite_usage==GMC_SPRITE && (cbpc & 16) == 0)
- s->mcsel= get_bits1(&s->gb);
- else s->mcsel= 0;
-
- if ((cbpc & 16) == 0) {
- /* 16x16 motion prediction */
-
- ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
- if(!s->mcsel){
- mx = ff_h263_decode_motion(s, pred_x, s->f_code);
- if (mx >= 0xffff)
- return -1;
-
- my = ff_h263_decode_motion(s, pred_y, s->f_code);
- if (my >= 0xffff)
- return -1;
- s->current_picture.f.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0;
- } else {
- mx = get_amv(s, 0);
- my = get_amv(s, 1);
- s->current_picture.f.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_GMC | MB_TYPE_L0;
- }
-
- mot_val[0 ]= mot_val[2 ] =
- mot_val[0+stride]= mot_val[2+stride]= mx;
- mot_val[1 ]= mot_val[3 ]=
- mot_val[1+stride]= mot_val[3+stride]= my;
- } else {
- int i;
- s->current_picture.f.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_L0;
- for(i=0;i<4;i++) {
- int16_t *mot_val= ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);
- mx = ff_h263_decode_motion(s, pred_x, s->f_code);
- if (mx >= 0xffff)
- return -1;
-
- my = ff_h263_decode_motion(s, pred_y, s->f_code);
- if (my >= 0xffff)
- return -1;
- mot_val[0] = mx;
- mot_val[1] = my;
- }
- }
- }
- }
- }
- s->mb_x= 0;
- }
-
- return mb_num;
-}
-
-/**
- * decode second partition.
- * @return <0 if an error occurred
- */
-static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count){
- int mb_num=0;
- static const int8_t quant_tab[4] = { -1, -2, 1, 2 };
-
- s->mb_x= s->resync_mb_x;
- s->first_slice_line=1;
- for(s->mb_y= s->resync_mb_y; mb_num < mb_count; s->mb_y++){
- ff_init_block_index(s);
- for(; mb_num < mb_count && s->mb_x<s->mb_width; s->mb_x++){
- const int xy= s->mb_x + s->mb_y*s->mb_stride;
-
- mb_num++;
- ff_update_block_index(s);
- if(s->mb_x == s->resync_mb_x && s->mb_y == s->resync_mb_y+1)
- s->first_slice_line=0;
-
- if(s->pict_type==AV_PICTURE_TYPE_I){
- int ac_pred= get_bits1(&s->gb);
- int cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
- if(cbpy<0){
- av_log(s->avctx, AV_LOG_ERROR, "cbpy corrupted at %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
-
- s->cbp_table[xy]|= cbpy<<2;
- s->current_picture.f.mb_type[xy] |= ac_pred*MB_TYPE_ACPRED;
- }else{ /* P || S_TYPE */
- if (IS_INTRA(s->current_picture.f.mb_type[xy])) {
- int dir=0,i;
- int ac_pred = get_bits1(&s->gb);
- int cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
-
- if(cbpy<0){
- av_log(s->avctx, AV_LOG_ERROR, "I cbpy corrupted at %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
-
- if(s->cbp_table[xy] & 8) {
- ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]);
- }
- s->current_picture.f.qscale_table[xy] = s->qscale;
-
- for(i=0; i<6; i++){
- int dc_pred_dir;
- int dc= mpeg4_decode_dc(s, i, &dc_pred_dir);
- if(dc < 0){
- av_log(s->avctx, AV_LOG_ERROR, "DC corrupted at %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
- dir<<=1;
- if(dc_pred_dir) dir|=1;
- }
- s->cbp_table[xy]&= 3; //remove dquant
- s->cbp_table[xy]|= cbpy<<2;
- s->current_picture.f.mb_type[xy] |= ac_pred*MB_TYPE_ACPRED;
- s->pred_dir_table[xy]= dir;
- } else if (IS_SKIP(s->current_picture.f.mb_type[xy])) {
- s->current_picture.f.qscale_table[xy] = s->qscale;
- s->cbp_table[xy]= 0;
- }else{
- int cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
-
- if(cbpy<0){
- av_log(s->avctx, AV_LOG_ERROR, "P cbpy corrupted at %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
-
- if(s->cbp_table[xy] & 8) {
- ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]);
- }
- s->current_picture.f.qscale_table[xy] = s->qscale;
-
- s->cbp_table[xy]&= 3; //remove dquant
- s->cbp_table[xy]|= (cbpy^0xf)<<2;
- }
- }
- }
- if(mb_num >= mb_count) return 0;
- s->mb_x= 0;
- }
- return 0;
-}
-
-/**
- * Decode the first and second partition.
- * @return <0 if error (and sets error type in the error_status_table)
- */
-int ff_mpeg4_decode_partitions(MpegEncContext *s)
-{
- int mb_num;
- const int part_a_error= s->pict_type==AV_PICTURE_TYPE_I ? (ER_DC_ERROR|ER_MV_ERROR) : ER_MV_ERROR;
- const int part_a_end = s->pict_type==AV_PICTURE_TYPE_I ? (ER_DC_END |ER_MV_END) : ER_MV_END;
-
- mb_num= mpeg4_decode_partition_a(s);
- if(mb_num<0){
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, part_a_error);
- return -1;
- }
-
- if(s->resync_mb_x + s->resync_mb_y*s->mb_width + mb_num > s->mb_num){
- av_log(s->avctx, AV_LOG_ERROR, "slice below monitor ...\n");
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, part_a_error);
- return -1;
- }
-
- s->mb_num_left= mb_num;
-
- if(s->pict_type==AV_PICTURE_TYPE_I){
- while(show_bits(&s->gb, 9) == 1)
- skip_bits(&s->gb, 9);
- if(get_bits_long(&s->gb, 19)!=DC_MARKER){
- av_log(s->avctx, AV_LOG_ERROR, "marker missing after first I partition at %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
- }else{
- while(show_bits(&s->gb, 10) == 1)
- skip_bits(&s->gb, 10);
- if(get_bits(&s->gb, 17)!=MOTION_MARKER){
- av_log(s->avctx, AV_LOG_ERROR, "marker missing after first P partition at %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
- }
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, part_a_end);
-
- if( mpeg4_decode_partition_b(s, mb_num) < 0){
- if(s->pict_type==AV_PICTURE_TYPE_P)
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_DC_ERROR);
- return -1;
- }else{
- if(s->pict_type==AV_PICTURE_TYPE_P)
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_DC_END);
- }
-
- return 0;
-}
-
-/**
- * Decode a block.
- * @return <0 if an error occurred
- */
-static inline int mpeg4_decode_block(MpegEncContext * s, int16_t * block,
- int n, int coded, int intra, int rvlc)
-{
- int level, i, last, run;
- int av_uninit(dc_pred_dir);
- RLTable * rl;
- RL_VLC_ELEM * rl_vlc;
- const uint8_t * scan_table;
- int qmul, qadd;
-
- //Note intra & rvlc should be optimized away if this is inlined
-
- if(intra) {
- if(s->use_intra_dc_vlc){
- /* DC coef */
- if(s->partitioned_frame){
- level = s->dc_val[0][ s->block_index[n] ];
- if(n<4) level= FASTDIV((level + (s->y_dc_scale>>1)), s->y_dc_scale);
- else level= FASTDIV((level + (s->c_dc_scale>>1)), s->c_dc_scale);
- dc_pred_dir= (s->pred_dir_table[s->mb_x + s->mb_y*s->mb_stride]<<n)&32;
- }else{
- level = mpeg4_decode_dc(s, n, &dc_pred_dir);
- if (level < 0)
- return -1;
- }
- block[0] = level;
- i = 0;
- }else{
- i = -1;
- ff_mpeg4_pred_dc(s, n, 0, &dc_pred_dir, 0);
- }
- if (!coded)
- goto not_coded;
-
- if(rvlc){
- rl = &ff_rvlc_rl_intra;
- rl_vlc = ff_rvlc_rl_intra.rl_vlc[0];
- }else{
- rl = &ff_mpeg4_rl_intra;
- rl_vlc = ff_mpeg4_rl_intra.rl_vlc[0];
- }
- if (s->ac_pred) {
- if (dc_pred_dir == 0)
- scan_table = s->intra_v_scantable.permutated; /* left */
- else
- scan_table = s->intra_h_scantable.permutated; /* top */
- } else {
- scan_table = s->intra_scantable.permutated;
- }
- qmul=1;
- qadd=0;
- } else {
- i = -1;
- if (!coded) {
- s->block_last_index[n] = i;
- return 0;
- }
- if(rvlc) rl = &ff_rvlc_rl_inter;
- else rl = &ff_h263_rl_inter;
-
- scan_table = s->intra_scantable.permutated;
-
- if(s->mpeg_quant){
- qmul=1;
- qadd=0;
- if(rvlc){
- rl_vlc = ff_rvlc_rl_inter.rl_vlc[0];
- }else{
- rl_vlc = ff_h263_rl_inter.rl_vlc[0];
- }
- }else{
- qmul = s->qscale << 1;
- qadd = (s->qscale - 1) | 1;
- if(rvlc){
- rl_vlc = ff_rvlc_rl_inter.rl_vlc[s->qscale];
- }else{
- rl_vlc = ff_h263_rl_inter.rl_vlc[s->qscale];
- }
- }
- }
- {
- OPEN_READER(re, &s->gb);
- for(;;) {
- UPDATE_CACHE(re, &s->gb);
- GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 0);
- if (level==0) {
- /* escape */
- if(rvlc){
- if(SHOW_UBITS(re, &s->gb, 1)==0){
- av_log(s->avctx, AV_LOG_ERROR, "1. marker bit missing in rvlc esc\n");
- return -1;
- }; SKIP_CACHE(re, &s->gb, 1);
-
- last= SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
- run= SHOW_UBITS(re, &s->gb, 6);
- SKIP_COUNTER(re, &s->gb, 1+1+6);
- UPDATE_CACHE(re, &s->gb);
-
- if(SHOW_UBITS(re, &s->gb, 1)==0){
- av_log(s->avctx, AV_LOG_ERROR, "2. marker bit missing in rvlc esc\n");
- return -1;
- }; SKIP_CACHE(re, &s->gb, 1);
-
- level= SHOW_UBITS(re, &s->gb, 11); SKIP_CACHE(re, &s->gb, 11);
-
- if(SHOW_UBITS(re, &s->gb, 5)!=0x10){
- av_log(s->avctx, AV_LOG_ERROR, "reverse esc missing\n");
- return -1;
- }; SKIP_CACHE(re, &s->gb, 5);
-
- level= level * qmul + qadd;
- level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
- SKIP_COUNTER(re, &s->gb, 1+11+5+1);
-
- i+= run + 1;
- if(last) i+=192;
- }else{
- int cache;
- cache= GET_CACHE(re, &s->gb);
-
- if(IS_3IV1)
- cache ^= 0xC0000000;
-
- if (cache&0x80000000) {
- if (cache&0x40000000) {
- /* third escape */
- SKIP_CACHE(re, &s->gb, 2);
- last= SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
- run= SHOW_UBITS(re, &s->gb, 6);
- SKIP_COUNTER(re, &s->gb, 2+1+6);
- UPDATE_CACHE(re, &s->gb);
-
- if(IS_3IV1){
- level= SHOW_SBITS(re, &s->gb, 12); LAST_SKIP_BITS(re, &s->gb, 12);
- }else{
- 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;
- }; SKIP_CACHE(re, &s->gb, 1);
-
- level= SHOW_SBITS(re, &s->gb, 12); SKIP_CACHE(re, &s->gb, 12);
-
- 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;
- }
-
- SKIP_COUNTER(re, &s->gb, 1+12+1);
- }
-
-#if 0
- if(s->error_recognition >= FF_ER_COMPLIANT){
- const int abs_level= FFABS(level);
- if(abs_level<=MAX_LEVEL && run<=MAX_RUN){
- const int run1= run - rl->max_run[last][abs_level] - 1;
- if(abs_level <= rl->max_level[last][run]){
- av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, vlc encoding possible\n");
- return -1;
- }
- if(s->error_recognition > FF_ER_COMPLIANT){
- if(abs_level <= rl->max_level[last][run]*2){
- av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, esc 1 encoding possible\n");
- return -1;
- }
- if(run1 >= 0 && abs_level <= rl->max_level[last][run1]){
- av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, esc 2 encoding possible\n");
- return -1;
- }
- }
- }
- }
-#endif
- if (level>0) level= level * qmul + qadd;
- else level= level * qmul - qadd;
-
- if((unsigned)(level + 2048) > 4095){
- if(s->err_recognition & (AV_EF_BITSTREAM|AV_EF_AGGRESSIVE)){
- if(level > 2560 || level<-2560){
- av_log(s->avctx, AV_LOG_ERROR, "|level| overflow in 3. esc, qp=%d\n", s->qscale);
- return -1;
- }
- }
- level= level<0 ? -2048 : 2047;
- }
-
- i+= run + 1;
- if(last) i+=192;
- } else {
- /* second escape */
- SKIP_BITS(re, &s->gb, 2);
- GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
- i+= run + rl->max_run[run>>7][level/qmul] +1; //FIXME opt indexing
- level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
- LAST_SKIP_BITS(re, &s->gb, 1);
- }
- } else {
- /* first escape */
- SKIP_BITS(re, &s->gb, 1);
- GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
- i+= run;
- level = level + rl->max_level[run>>7][(run-1)&63] * qmul;//FIXME opt indexing
- level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
- LAST_SKIP_BITS(re, &s->gb, 1);
- }
- }
- } else {
- i+= run;
- level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
- LAST_SKIP_BITS(re, &s->gb, 1);
- }
- if (i > 62){
- i-= 192;
- 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[scan_table[i]] = level;
- break;
- }
-
- block[scan_table[i]] = level;
- }
- CLOSE_READER(re, &s->gb);
- }
- not_coded:
- if (intra) {
- if(!s->use_intra_dc_vlc){
- block[0] = ff_mpeg4_pred_dc(s, n, block[0], &dc_pred_dir, 0);
-
- i -= i>>31; //if(i == -1) i=0;
- }
-
- ff_mpeg4_pred_ac(s, block, n, dc_pred_dir);
- if (s->ac_pred) {
- i = 63; /* XXX: not optimal */
- }
- }
- s->block_last_index[n] = i;
- return 0;
-}
-
-/**
- * decode partition C of one MB.
- * @return <0 if an error occurred
- */
-static int mpeg4_decode_partitioned_mb(MpegEncContext *s, int16_t block[6][64])
-{
- int cbp, mb_type;
- const int xy= s->mb_x + s->mb_y*s->mb_stride;
-
- mb_type = s->current_picture.f.mb_type[xy];
- cbp = s->cbp_table[xy];
-
- s->use_intra_dc_vlc= s->qscale < s->intra_dc_threshold;
-
- if (s->current_picture.f.qscale_table[xy] != s->qscale) {
- ff_set_qscale(s, s->current_picture.f.qscale_table[xy]);
- }
-
- if (s->pict_type == AV_PICTURE_TYPE_P || s->pict_type==AV_PICTURE_TYPE_S) {
- int i;
- for(i=0; i<4; i++){
- s->mv[0][i][0] = s->current_picture.f.motion_val[0][s->block_index[i]][0];
- s->mv[0][i][1] = s->current_picture.f.motion_val[0][s->block_index[i]][1];
- }
- s->mb_intra = IS_INTRA(mb_type);
-
- if (IS_SKIP(mb_type)) {
- /* skip mb */
- for(i=0;i<6;i++)
- s->block_last_index[i] = -1;
- s->mv_dir = MV_DIR_FORWARD;
- s->mv_type = MV_TYPE_16X16;
- if(s->pict_type==AV_PICTURE_TYPE_S && s->vol_sprite_usage==GMC_SPRITE){
- s->mcsel=1;
- s->mb_skipped = 0;
- }else{
- s->mcsel=0;
- s->mb_skipped = 1;
- }
- }else if(s->mb_intra){
- s->ac_pred = IS_ACPRED(s->current_picture.f.mb_type[xy]);
- }else if(!s->mb_intra){
-// s->mcsel= 0; //FIXME do we need to init that
-
- s->mv_dir = MV_DIR_FORWARD;
- if (IS_8X8(mb_type)) {
- s->mv_type = MV_TYPE_8X8;
- } else {
- s->mv_type = MV_TYPE_16X16;
- }
- }
- } else { /* I-Frame */
- s->mb_intra = 1;
- s->ac_pred = IS_ACPRED(s->current_picture.f.mb_type[xy]);
- }
-
- if (!IS_SKIP(mb_type)) {
- int i;
- s->dsp.clear_blocks(s->block[0]);
- /* decode each block */
- for (i = 0; i < 6; i++) {
- if(mpeg4_decode_block(s, block[i], i, cbp&32, s->mb_intra, s->rvlc) < 0){
- av_log(s->avctx, AV_LOG_ERROR, "texture corrupted at %d %d %d\n", s->mb_x, s->mb_y, s->mb_intra);
- return -1;
- }
- cbp+=cbp;
- }
- }
-
- /* per-MB end of slice check */
-
- if(--s->mb_num_left <= 0){
- if(mpeg4_is_resync(s))
- return SLICE_END;
- else
- return SLICE_NOEND;
- }else{
- if(mpeg4_is_resync(s)){
- const int delta= s->mb_x + 1 == s->mb_width ? 2 : 1;
- if(s->cbp_table[xy+delta])
- return SLICE_END;
- }
- return SLICE_OK;
- }
-}
-
-static int mpeg4_decode_mb(MpegEncContext *s,
- int16_t block[6][64])
-{
- int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant;
- int16_t *mot_val;
- static int8_t quant_tab[4] = { -1, -2, 1, 2 };
- const int xy= s->mb_x + s->mb_y * s->mb_stride;
-
- av_assert2(s->h263_pred);
-
- if (s->pict_type == AV_PICTURE_TYPE_P || s->pict_type==AV_PICTURE_TYPE_S) {
- do{
- if (get_bits1(&s->gb)) {
- /* skip mb */
- s->mb_intra = 0;
- for(i=0;i<6;i++)
- s->block_last_index[i] = -1;
- s->mv_dir = MV_DIR_FORWARD;
- s->mv_type = MV_TYPE_16X16;
- if(s->pict_type==AV_PICTURE_TYPE_S && s->vol_sprite_usage==GMC_SPRITE){
- s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_GMC | MB_TYPE_16x16 | MB_TYPE_L0;
- s->mcsel=1;
- s->mv[0][0][0]= get_amv(s, 0);
- s->mv[0][0][1]= get_amv(s, 1);
-
- s->mb_skipped = 0;
- }else{
- s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
- s->mcsel=0;
- s->mv[0][0][0] = 0;
- s->mv[0][0][1] = 0;
- s->mb_skipped = 1;
- }
- goto end;
- }
- 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);
- return -1;
- }
- }while(cbpc == 20);
-
- s->dsp.clear_blocks(s->block[0]);
- dquant = cbpc & 8;
- s->mb_intra = ((cbpc & 4) != 0);
- if (s->mb_intra) goto intra;
-
- if(s->pict_type==AV_PICTURE_TYPE_S && s->vol_sprite_usage==GMC_SPRITE && (cbpc & 16) == 0)
- s->mcsel= get_bits1(&s->gb);
- else s->mcsel= 0;
- cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1) ^ 0x0F;
-
- cbp = (cbpc & 3) | (cbpy << 2);
- if (dquant) {
- ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]);
- }
- if((!s->progressive_sequence) && (cbp || (s->workaround_bugs&FF_BUG_XVID_ILACE)))
- s->interlaced_dct= get_bits1(&s->gb);
-
- s->mv_dir = MV_DIR_FORWARD;
- if ((cbpc & 16) == 0) {
- if(s->mcsel){
- s->current_picture.f.mb_type[xy] = MB_TYPE_GMC | MB_TYPE_16x16 | MB_TYPE_L0;
- /* 16x16 global motion prediction */
- s->mv_type = MV_TYPE_16X16;
- mx= get_amv(s, 0);
- my= get_amv(s, 1);
- s->mv[0][0][0] = mx;
- s->mv[0][0][1] = my;
- }else if((!s->progressive_sequence) && get_bits1(&s->gb)){
- s->current_picture.f.mb_type[xy] = MB_TYPE_16x8 | MB_TYPE_L0 | MB_TYPE_INTERLACED;
- /* 16x8 field motion prediction */
- s->mv_type= MV_TYPE_FIELD;
-
- s->field_select[0][0]= get_bits1(&s->gb);
- s->field_select[0][1]= get_bits1(&s->gb);
-
- ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
-
- for(i=0; i<2; i++){
- mx = ff_h263_decode_motion(s, pred_x, s->f_code);
- if (mx >= 0xffff)
- return -1;
-
- my = ff_h263_decode_motion(s, pred_y/2, s->f_code);
- if (my >= 0xffff)
- return -1;
-
- s->mv[0][i][0] = mx;
- s->mv[0][i][1] = my;
- }
- }else{
- s->current_picture.f.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0;
- /* 16x16 motion prediction */
- s->mv_type = MV_TYPE_16X16;
- ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
- mx = ff_h263_decode_motion(s, pred_x, s->f_code);
-
- if (mx >= 0xffff)
- return -1;
-
- my = ff_h263_decode_motion(s, pred_y, s->f_code);
-
- if (my >= 0xffff)
- return -1;
- s->mv[0][0][0] = mx;
- s->mv[0][0][1] = my;
- }
- } else {
- s->current_picture.f.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_L0;
- s->mv_type = MV_TYPE_8X8;
- for(i=0;i<4;i++) {
- mot_val = ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);
- mx = ff_h263_decode_motion(s, pred_x, s->f_code);
- if (mx >= 0xffff)
- return -1;
-
- my = ff_h263_decode_motion(s, pred_y, s->f_code);
- if (my >= 0xffff)
- return -1;
- s->mv[0][i][0] = mx;
- s->mv[0][i][1] = my;
- mot_val[0] = mx;
- mot_val[1] = my;
- }
- }
- } else if(s->pict_type==AV_PICTURE_TYPE_B) {
- int modb1; // first bit of modb
- int modb2; // second bit of modb
- int mb_type;
-
- s->mb_intra = 0; //B-frames never contain intra blocks
- s->mcsel=0; // ... true gmc blocks
-
- if(s->mb_x==0){
- for(i=0; i<2; i++){
- s->last_mv[i][0][0]=
- s->last_mv[i][0][1]=
- s->last_mv[i][1][0]=
- s->last_mv[i][1][1]= 0;
- }
-
- ff_thread_await_progress(&s->next_picture_ptr->f, s->mb_y, 0);
- }
-
- /* if we skipped it in the future P Frame than skip it now too */
- s->mb_skipped = s->next_picture.f.mbskip_table[s->mb_y * s->mb_stride + s->mb_x]; // Note, skiptab=0 if last was GMC
-
- if(s->mb_skipped){
- /* skip mb */
- for(i=0;i<6;i++)
- s->block_last_index[i] = -1;
-
- s->mv_dir = MV_DIR_FORWARD;
- s->mv_type = MV_TYPE_16X16;
- s->mv[0][0][0] = 0;
- s->mv[0][0][1] = 0;
- s->mv[1][0][0] = 0;
- s->mv[1][0][1] = 0;
- s->current_picture.f.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
- goto end;
- }
-
- modb1= get_bits1(&s->gb);
- if(modb1){
- mb_type= MB_TYPE_DIRECT2 | MB_TYPE_SKIP | MB_TYPE_L0L1; //like MB_TYPE_B_DIRECT but no vectors coded
- cbp=0;
- }else{
- modb2= get_bits1(&s->gb);
- mb_type= get_vlc2(&s->gb, mb_type_b_vlc.table, MB_TYPE_B_VLC_BITS, 1);
- if(mb_type<0){
- av_log(s->avctx, AV_LOG_ERROR, "illegal MB_type\n");
- return -1;
- }
- mb_type= mb_type_b_map[ mb_type ];
- if(modb2) cbp= 0;
- else{
- s->dsp.clear_blocks(s->block[0]);
- cbp= get_bits(&s->gb, 6);
- }
-
- if ((!IS_DIRECT(mb_type)) && cbp) {
- if(get_bits1(&s->gb)){
- ff_set_qscale(s, s->qscale + get_bits1(&s->gb)*4 - 2);
- }
- }
-
- if(!s->progressive_sequence){
- if(cbp)
- s->interlaced_dct= get_bits1(&s->gb);
-
- if(!IS_DIRECT(mb_type) && get_bits1(&s->gb)){
- mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED;
- mb_type &= ~MB_TYPE_16x16;
-
- if(USES_LIST(mb_type, 0)){
- s->field_select[0][0]= get_bits1(&s->gb);
- s->field_select[0][1]= get_bits1(&s->gb);
- }
- if(USES_LIST(mb_type, 1)){
- s->field_select[1][0]= get_bits1(&s->gb);
- s->field_select[1][1]= get_bits1(&s->gb);
- }
- }
- }
-
- s->mv_dir = 0;
- if((mb_type & (MB_TYPE_DIRECT2|MB_TYPE_INTERLACED)) == 0){
- s->mv_type= MV_TYPE_16X16;
-
- if(USES_LIST(mb_type, 0)){
- s->mv_dir = MV_DIR_FORWARD;
-
- mx = ff_h263_decode_motion(s, s->last_mv[0][0][0], s->f_code);
- my = ff_h263_decode_motion(s, s->last_mv[0][0][1], s->f_code);
- s->last_mv[0][1][0]= s->last_mv[0][0][0]= s->mv[0][0][0] = mx;
- s->last_mv[0][1][1]= s->last_mv[0][0][1]= s->mv[0][0][1] = my;
- }
-
- if(USES_LIST(mb_type, 1)){
- s->mv_dir |= MV_DIR_BACKWARD;
-
- mx = ff_h263_decode_motion(s, s->last_mv[1][0][0], s->b_code);
- my = ff_h263_decode_motion(s, s->last_mv[1][0][1], s->b_code);
- s->last_mv[1][1][0]= s->last_mv[1][0][0]= s->mv[1][0][0] = mx;
- s->last_mv[1][1][1]= s->last_mv[1][0][1]= s->mv[1][0][1] = my;
- }
- }else if(!IS_DIRECT(mb_type)){
- s->mv_type= MV_TYPE_FIELD;
-
- if(USES_LIST(mb_type, 0)){
- s->mv_dir = MV_DIR_FORWARD;
-
- for(i=0; i<2; i++){
- mx = ff_h263_decode_motion(s, s->last_mv[0][i][0] , s->f_code);
- my = ff_h263_decode_motion(s, s->last_mv[0][i][1]/2, s->f_code);
- s->last_mv[0][i][0]= s->mv[0][i][0] = mx;
- s->last_mv[0][i][1]= (s->mv[0][i][1] = my)*2;
- }
- }
-
- if(USES_LIST(mb_type, 1)){
- s->mv_dir |= MV_DIR_BACKWARD;
-
- for(i=0; i<2; i++){
- mx = ff_h263_decode_motion(s, s->last_mv[1][i][0] , s->b_code);
- my = ff_h263_decode_motion(s, s->last_mv[1][i][1]/2, s->b_code);
- s->last_mv[1][i][0]= s->mv[1][i][0] = mx;
- s->last_mv[1][i][1]= (s->mv[1][i][1] = my)*2;
- }
- }
- }
- }
-
- if(IS_DIRECT(mb_type)){
- if(IS_SKIP(mb_type))
- mx=my=0;
- else{
- mx = ff_h263_decode_motion(s, 0, 1);
- my = ff_h263_decode_motion(s, 0, 1);
- }
-
- s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
- mb_type |= ff_mpeg4_set_direct_mv(s, mx, my);
- }
- s->current_picture.f.mb_type[xy] = mb_type;
- } else { /* I-Frame */
- do{
- 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, "I cbpc damaged at %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
- }while(cbpc == 8);
-
- dquant = cbpc & 4;
- s->mb_intra = 1;
-intra:
- s->ac_pred = get_bits1(&s->gb);
- if(s->ac_pred)
- s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA | MB_TYPE_ACPRED;
- else
- s->current_picture.f.mb_type[xy] = MB_TYPE_INTRA;
-
- cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
- if(cbpy<0){
- av_log(s->avctx, AV_LOG_ERROR, "I cbpy damaged at %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
- cbp = (cbpc & 3) | (cbpy << 2);
-
- s->use_intra_dc_vlc= s->qscale < s->intra_dc_threshold;
-
- if (dquant) {
- ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]);
- }
-
- if(!s->progressive_sequence)
- s->interlaced_dct= get_bits1(&s->gb);
-
- s->dsp.clear_blocks(s->block[0]);
- /* decode each block */
- for (i = 0; i < 6; i++) {
- if (mpeg4_decode_block(s, block[i], i, cbp&32, 1, 0) < 0)
- return -1;
- cbp+=cbp;
- }
- goto end;
- }
-
- /* decode each block */
- for (i = 0; i < 6; i++) {
- if (mpeg4_decode_block(s, block[i], i, cbp&32, 0, 0) < 0)
- return -1;
- cbp+=cbp;
- }
-end:
-
- /* per-MB end of slice check */
- if(s->codec_id==AV_CODEC_ID_MPEG4){
- int next= mpeg4_is_resync(s);
- if(next) {
- if (s->mb_x + s->mb_y*s->mb_width + 1 > next && (s->avctx->err_recognition & AV_EF_AGGRESSIVE)) {
- return -1;
- } else if (s->mb_x + s->mb_y*s->mb_width + 1 >= next)
- return SLICE_END;
-
- if(s->pict_type==AV_PICTURE_TYPE_B){
- const int delta= s->mb_x + 1 == s->mb_width ? 2 : 1;
- ff_thread_await_progress(&s->next_picture_ptr->f,
- (s->mb_x + delta >= s->mb_width) ? FFMIN(s->mb_y+1, s->mb_height-1) : s->mb_y, 0);
- if (s->next_picture.f.mbskip_table[xy + delta])
- return SLICE_OK;
- }
-
- return SLICE_END;
- }
- }
-
- return SLICE_OK;
-}
-
-
-static int mpeg4_decode_gop_header(MpegEncContext * s, GetBitContext *gb){
- int hours, minutes, seconds;
-
- if(!show_bits(gb, 23)){
- av_log(s->avctx, AV_LOG_WARNING, "GOP header invalid\n");
- return -1;
- }
-
- hours= get_bits(gb, 5);
- minutes= get_bits(gb, 6);
- skip_bits1(gb);
- seconds= get_bits(gb, 6);
-
- s->time_base= seconds + 60*(minutes + 60*hours);
-
- skip_bits1(gb);
- skip_bits1(gb);
-
- return 0;
-}
-
-static int mpeg4_decode_profile_level(MpegEncContext * s, GetBitContext *gb){
-
- s->avctx->profile = get_bits(gb, 4);
- s->avctx->level = get_bits(gb, 4);
-
- // for Simple profile, level 0
- if (s->avctx->profile == 0 && s->avctx->level == 8) {
- s->avctx->level = 0;
- }
-
- return 0;
-}
-
-static int decode_vol_header(MpegEncContext *s, GetBitContext *gb){
- int width, height, vo_ver_id;
-
- /* vol header */
- skip_bits(gb, 1); /* random access */
- s->vo_type= get_bits(gb, 8);
- if (get_bits1(gb) != 0) { /* is_ol_id */
- vo_ver_id = get_bits(gb, 4); /* vo_ver_id */
- skip_bits(gb, 3); /* vo_priority */
- } else {
- vo_ver_id = 1;
- }
- s->aspect_ratio_info= get_bits(gb, 4);
- if(s->aspect_ratio_info == FF_ASPECT_EXTENDED){
- s->avctx->sample_aspect_ratio.num= get_bits(gb, 8); // par_width
- s->avctx->sample_aspect_ratio.den= get_bits(gb, 8); // par_height
- }else{
- s->avctx->sample_aspect_ratio= ff_h263_pixel_aspect[s->aspect_ratio_info];
- }
-
- if ((s->vol_control_parameters=get_bits1(gb))) { /* vol control parameter */
- int chroma_format= get_bits(gb, 2);
- if(chroma_format!=CHROMA_420){
- av_log(s->avctx, AV_LOG_ERROR, "illegal chroma format\n");
- }
- s->low_delay= get_bits1(gb);
- if(get_bits1(gb)){ /* vbv parameters */
- get_bits(gb, 15); /* first_half_bitrate */
- skip_bits1(gb); /* marker */
- get_bits(gb, 15); /* latter_half_bitrate */
- skip_bits1(gb); /* marker */
- get_bits(gb, 15); /* first_half_vbv_buffer_size */
- skip_bits1(gb); /* marker */
- get_bits(gb, 3); /* latter_half_vbv_buffer_size */
- get_bits(gb, 11); /* first_half_vbv_occupancy */
- skip_bits1(gb); /* marker */
- get_bits(gb, 15); /* latter_half_vbv_occupancy */
- skip_bits1(gb); /* marker */
- }
- }else{
- // set low delay flag only once the smartest? low delay detection won't be overridden
- if(s->picture_number==0)
- s->low_delay=0;
- }
-
- s->shape = get_bits(gb, 2); /* vol shape */
- if(s->shape != RECT_SHAPE) av_log(s->avctx, AV_LOG_ERROR, "only rectangular vol supported\n");
- if(s->shape == GRAY_SHAPE && vo_ver_id != 1){
- av_log(s->avctx, AV_LOG_ERROR, "Gray shape not supported\n");
- skip_bits(gb, 4); //video_object_layer_shape_extension
- }
-
- check_marker(gb, "before time_increment_resolution");
-
- s->avctx->time_base.den = get_bits(gb, 16);
- if(!s->avctx->time_base.den){
- av_log(s->avctx, AV_LOG_ERROR, "time_base.den==0\n");
- s->avctx->time_base.num = 0;
- return -1;
- }
-
- s->time_increment_bits = av_log2(s->avctx->time_base.den - 1) + 1;
- if (s->time_increment_bits < 1)
- s->time_increment_bits = 1;
-
- check_marker(gb, "before fixed_vop_rate");
-
- if (get_bits1(gb) != 0) { /* fixed_vop_rate */
- s->avctx->time_base.num = get_bits(gb, s->time_increment_bits);
- }else
- s->avctx->time_base.num = 1;
-
- s->t_frame=0;
-
- if (s->shape != BIN_ONLY_SHAPE) {
- if (s->shape == RECT_SHAPE) {
- skip_bits1(gb); /* marker */
- width = get_bits(gb, 13);
- skip_bits1(gb); /* marker */
- height = get_bits(gb, 13);
- skip_bits1(gb); /* marker */
- if(width && height && !(s->width && s->codec_tag == AV_RL32("MP4S"))){ /* they should be non zero but who knows ... */
- if (s->width && s->height &&
- (s->width != width || s->height != height))
- s->context_reinit = 1;
- s->width = width;
- s->height = height;
- }
- }
-
- s->progressive_sequence=
- s->progressive_frame= get_bits1(gb)^1;
- s->interlaced_dct=0;
- if(!get_bits1(gb) && (s->avctx->debug & FF_DEBUG_PICT_INFO))
- av_log(s->avctx, AV_LOG_INFO, "MPEG4 OBMC not supported (very likely buggy encoder)\n"); /* OBMC Disable */
- if (vo_ver_id == 1) {
- s->vol_sprite_usage = get_bits1(gb); /* vol_sprite_usage */
- } else {
- s->vol_sprite_usage = get_bits(gb, 2); /* vol_sprite_usage */
- }
- if(s->vol_sprite_usage==STATIC_SPRITE) av_log(s->avctx, AV_LOG_ERROR, "Static Sprites not supported\n");
- if(s->vol_sprite_usage==STATIC_SPRITE || s->vol_sprite_usage==GMC_SPRITE){
- if(s->vol_sprite_usage==STATIC_SPRITE){
- s->sprite_width = get_bits(gb, 13);
- skip_bits1(gb); /* marker */
- s->sprite_height= get_bits(gb, 13);
- skip_bits1(gb); /* marker */
- s->sprite_left = get_bits(gb, 13);
- skip_bits1(gb); /* marker */
- s->sprite_top = get_bits(gb, 13);
- skip_bits1(gb); /* marker */
- }
- s->num_sprite_warping_points= get_bits(gb, 6);
- if(s->num_sprite_warping_points > 3){
- av_log(s->avctx, AV_LOG_ERROR, "%d sprite_warping_points\n", s->num_sprite_warping_points);
- s->num_sprite_warping_points= 0;
- return -1;
- }
- s->sprite_warping_accuracy = get_bits(gb, 2);
- s->sprite_brightness_change= get_bits1(gb);
- if(s->vol_sprite_usage==STATIC_SPRITE)
- s->low_latency_sprite= get_bits1(gb);
- }
- // FIXME sadct disable bit if verid!=1 && shape not rect
-
- if (get_bits1(gb) == 1) { /* not_8_bit */
- s->quant_precision = get_bits(gb, 4); /* quant_precision */
- if(get_bits(gb, 4)!=8) av_log(s->avctx, AV_LOG_ERROR, "N-bit not supported\n"); /* bits_per_pixel */
- if(s->quant_precision!=5) av_log(s->avctx, AV_LOG_ERROR, "quant precision %d\n", s->quant_precision);
- if(s->quant_precision<3 || s->quant_precision>9) {
- s->quant_precision = 5;
- }
- } else {
- s->quant_precision = 5;
- }
-
- // FIXME a bunch of grayscale shape things
-
- if((s->mpeg_quant=get_bits1(gb))){ /* vol_quant_type */
- int i, v;
-
- /* load default matrixes */
- for(i=0; i<64; i++){
- int j= s->dsp.idct_permutation[i];
- v= ff_mpeg4_default_intra_matrix[i];
- s->intra_matrix[j]= v;
- s->chroma_intra_matrix[j]= v;
-
- v= ff_mpeg4_default_non_intra_matrix[i];
- s->inter_matrix[j]= v;
- s->chroma_inter_matrix[j]= v;
- }
-
- /* load custom intra matrix */
- if(get_bits1(gb)){
- int last=0;
- for(i=0; i<64; i++){
- int j;
- v= get_bits(gb, 8);
- if(v==0) break;
-
- last= v;
- j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
- s->intra_matrix[j]= v;
- s->chroma_intra_matrix[j]= v;
- }
-
- /* replicate last value */
- for(; i<64; i++){
- int j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
- s->intra_matrix[j]= last;
- s->chroma_intra_matrix[j]= last;
- }
- }
-
- /* load custom non intra matrix */
- if(get_bits1(gb)){
- int last=0;
- for(i=0; i<64; i++){
- int j;
- v= get_bits(gb, 8);
- if(v==0) break;
-
- last= v;
- j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
- s->inter_matrix[j]= v;
- s->chroma_inter_matrix[j]= v;
- }
-
- /* replicate last value */
- for(; i<64; i++){
- int j= s->dsp.idct_permutation[ ff_zigzag_direct[i] ];
- s->inter_matrix[j]= last;
- s->chroma_inter_matrix[j]= last;
- }
- }
-
- // FIXME a bunch of grayscale shape things
- }
-
- if(vo_ver_id != 1)
- s->quarter_sample= get_bits1(gb);
- else s->quarter_sample=0;
-
- if(!get_bits1(gb)){
- int pos= get_bits_count(gb);
- int estimation_method= get_bits(gb, 2);
- if(estimation_method<2){
- if(!get_bits1(gb)){
- s->cplx_estimation_trash_i += 8*get_bits1(gb); //opaque
- s->cplx_estimation_trash_i += 8*get_bits1(gb); //transparent
- s->cplx_estimation_trash_i += 8*get_bits1(gb); //intra_cae
- s->cplx_estimation_trash_i += 8*get_bits1(gb); //inter_cae
- s->cplx_estimation_trash_i += 8*get_bits1(gb); //no_update
- s->cplx_estimation_trash_i += 8*get_bits1(gb); //upampling
- }
- if(!get_bits1(gb)){
- s->cplx_estimation_trash_i += 8*get_bits1(gb); //intra_blocks
- s->cplx_estimation_trash_p += 8*get_bits1(gb); //inter_blocks
- s->cplx_estimation_trash_p += 8*get_bits1(gb); //inter4v_blocks
- s->cplx_estimation_trash_i += 8*get_bits1(gb); //not coded blocks
- }
- if(!check_marker(gb, "in complexity estimation part 1")){
- skip_bits_long(gb, pos - get_bits_count(gb));
- goto no_cplx_est;
- }
- if(!get_bits1(gb)){
- s->cplx_estimation_trash_i += 8*get_bits1(gb); //dct_coeffs
- s->cplx_estimation_trash_i += 8*get_bits1(gb); //dct_lines
- s->cplx_estimation_trash_i += 8*get_bits1(gb); //vlc_syms
- s->cplx_estimation_trash_i += 4*get_bits1(gb); //vlc_bits
- }
- if(!get_bits1(gb)){
- s->cplx_estimation_trash_p += 8*get_bits1(gb); //apm
- s->cplx_estimation_trash_p += 8*get_bits1(gb); //npm
- s->cplx_estimation_trash_b += 8*get_bits1(gb); //interpolate_mc_q
- s->cplx_estimation_trash_p += 8*get_bits1(gb); //forwback_mc_q
- s->cplx_estimation_trash_p += 8*get_bits1(gb); //halfpel2
- s->cplx_estimation_trash_p += 8*get_bits1(gb); //halfpel4
- }
- if(!check_marker(gb, "in complexity estimation part 2")){
- skip_bits_long(gb, pos - get_bits_count(gb));
- goto no_cplx_est;
- }
- if(estimation_method==1){
- s->cplx_estimation_trash_i += 8*get_bits1(gb); //sadct
- s->cplx_estimation_trash_p += 8*get_bits1(gb); //qpel
- }
- }else
- av_log(s->avctx, AV_LOG_ERROR, "Invalid Complexity estimation method %d\n", estimation_method);
- }else{
-no_cplx_est:
- s->cplx_estimation_trash_i=
- s->cplx_estimation_trash_p=
- s->cplx_estimation_trash_b= 0;
- }
-
- s->resync_marker= !get_bits1(gb); /* resync_marker_disabled */
-
- s->data_partitioning= get_bits1(gb);
- if(s->data_partitioning){
- s->rvlc= get_bits1(gb);
- }
-
- if(vo_ver_id != 1) {
- s->new_pred= get_bits1(gb);
- if(s->new_pred){
- av_log(s->avctx, AV_LOG_ERROR, "new pred not supported\n");
- skip_bits(gb, 2); /* requested upstream message type */
- skip_bits1(gb); /* newpred segment type */
- }
- s->reduced_res_vop= get_bits1(gb);
- if(s->reduced_res_vop) av_log(s->avctx, AV_LOG_ERROR, "reduced resolution VOP not supported\n");
- }
- else{
- s->new_pred=0;
- s->reduced_res_vop= 0;
- }
-
- s->scalability= get_bits1(gb);
-
- if (s->scalability) {
- GetBitContext bak= *gb;
- int h_sampling_factor_n;
- int h_sampling_factor_m;
- int v_sampling_factor_n;
- int v_sampling_factor_m;
-
- s->hierachy_type= get_bits1(gb);
- skip_bits(gb, 4); /* ref_layer_id */
- skip_bits1(gb); /* ref_layer_sampling_dir */
- h_sampling_factor_n= get_bits(gb, 5);
- h_sampling_factor_m= get_bits(gb, 5);
- v_sampling_factor_n= get_bits(gb, 5);
- v_sampling_factor_m= get_bits(gb, 5);
- s->enhancement_type= get_bits1(gb);
-
- if( h_sampling_factor_n==0 || h_sampling_factor_m==0
- || v_sampling_factor_n==0 || v_sampling_factor_m==0){
- /* illegal scalability header (VERY broken encoder),
- * trying to workaround */
- s->scalability=0;
- *gb= bak;
- }else
- av_log(s->avctx, AV_LOG_ERROR, "scalability not supported\n");
-
- // bin shape stuff FIXME
- }
- }
-
- if(s->avctx->debug&FF_DEBUG_PICT_INFO) {
- av_log(s->avctx, AV_LOG_DEBUG, "tb %d/%d, tincrbits:%d, qp_prec:%d, ps:%d, %s%s%s%s\n",
- s->avctx->time_base.num, s->avctx->time_base.den,
- s->time_increment_bits,
- s->quant_precision,
- s->progressive_sequence,
- s->scalability ? "scalability " :"" , s->quarter_sample ? "qpel " : "",
- s->data_partitioning ? "partition " : "", s->rvlc ? "rvlc " : ""
- );
- }
-
- return 0;
-}
-
-/**
- * Decode the user data stuff in the header.
- * Also initializes divx/xvid/lavc_version/build.
- */
-static int decode_user_data(MpegEncContext *s, GetBitContext *gb){
- char buf[256];
- int i;
- int e;
- int ver = 0, build = 0, ver2 = 0, ver3 = 0;
- char last;
-
- for(i=0; i<255 && get_bits_count(gb) < gb->size_in_bits; i++){
- if(show_bits(gb, 23) == 0) break;
- buf[i]= get_bits(gb, 8);
- }
- buf[i]=0;
-
- /* divx detection */
- e=sscanf(buf, "DivX%dBuild%d%c", &ver, &build, &last);
- if(e<2)
- e=sscanf(buf, "DivX%db%d%c", &ver, &build, &last);
- if(e>=2){
- s->divx_version= ver;
- s->divx_build= build;
- s->divx_packed= e==3 && last=='p';
- if(s->divx_packed && !s->showed_packed_warning) {
- av_log(s->avctx, AV_LOG_WARNING, "Invalid and inefficient vfw-avi packed B frames detected\n");
- s->showed_packed_warning=1;
- }
- }
-
- /* libavcodec detection */
- e=sscanf(buf, "FFmpe%*[^b]b%d", &build)+3;
- if(e!=4)
- e=sscanf(buf, "FFmpeg v%d.%d.%d / libavcodec build: %d", &ver, &ver2, &ver3, &build);
- if(e!=4){
- e=sscanf(buf, "Lavc%d.%d.%d", &ver, &ver2, &ver3)+1;
- if (e>1)
- build= (ver<<16) + (ver2<<8) + ver3;
- }
- if(e!=4){
- if(strcmp(buf, "ffmpeg")==0){
- s->lavc_build= 4600;
- }
- }
- if(e==4){
- s->lavc_build= build;
- }
-
- /* Xvid detection */
- e=sscanf(buf, "XviD%d", &build);
- if(e==1){
- s->xvid_build= build;
- }
-
- return 0;
-}
-
-static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
- int time_incr, time_increment;
-
- s->pict_type = get_bits(gb, 2) + AV_PICTURE_TYPE_I; /* pict type: I = 0 , P = 1 */
- if(s->pict_type==AV_PICTURE_TYPE_B && s->low_delay && s->vol_control_parameters==0 && !(s->flags & CODEC_FLAG_LOW_DELAY)){
- av_log(s->avctx, AV_LOG_ERROR, "low_delay flag incorrectly, clearing it\n");
- s->low_delay=0;
- }
-
- s->partitioned_frame= s->data_partitioning && s->pict_type!=AV_PICTURE_TYPE_B;
- if(s->partitioned_frame)
- s->decode_mb= mpeg4_decode_partitioned_mb;
- else
- s->decode_mb= mpeg4_decode_mb;
-
- time_incr=0;
- while (get_bits1(gb) != 0)
- time_incr++;
-
- check_marker(gb, "before time_increment");
-
- if(s->time_increment_bits==0 || !(show_bits(gb, s->time_increment_bits+1)&1)){
- av_log(s->avctx, AV_LOG_ERROR, "hmm, seems the headers are not complete, trying to guess time_increment_bits\n");
-
- for(s->time_increment_bits=1 ;s->time_increment_bits<16; s->time_increment_bits++){
- if ( s->pict_type == AV_PICTURE_TYPE_P
- || (s->pict_type == AV_PICTURE_TYPE_S && s->vol_sprite_usage==GMC_SPRITE)) {
- if((show_bits(gb, s->time_increment_bits+6)&0x37) == 0x30) break;
- }else
- if((show_bits(gb, s->time_increment_bits+5)&0x1F) == 0x18) break;
- }
-
- av_log(s->avctx, AV_LOG_ERROR, "my guess is %d bits ;)\n",s->time_increment_bits);
- if (s->avctx->time_base.den && 4*s->avctx->time_base.den < 1<<s->time_increment_bits) {
- s->avctx->time_base.den = 1<<s->time_increment_bits;
- }
- }
-
- if(IS_3IV1) time_increment= get_bits1(gb); //FIXME investigate further
- else time_increment= get_bits(gb, s->time_increment_bits);
-
- if(s->pict_type!=AV_PICTURE_TYPE_B){
- s->last_time_base= s->time_base;
- s->time_base+= time_incr;
- s->time= s->time_base*s->avctx->time_base.den + time_increment;
- if(s->workaround_bugs&FF_BUG_UMP4){
- if(s->time < s->last_non_b_time){
- /* header is not mpeg-4-compatible, broken encoder,
- * trying to workaround */
- s->time_base++;
- s->time+= s->avctx->time_base.den;
- }
- }
- s->pp_time= s->time - s->last_non_b_time;
- s->last_non_b_time= s->time;
- }else{
- s->time= (s->last_time_base + time_incr)*s->avctx->time_base.den + time_increment;
- s->pb_time= s->pp_time - (s->last_non_b_time - s->time);
- if(s->pp_time <=s->pb_time || s->pp_time <= s->pp_time - s->pb_time || s->pp_time<=0){
- /* messed up order, maybe after seeking? skipping current b-frame */
- return FRAME_SKIPPED;
- }
- ff_mpeg4_init_direct_mv(s);
-
- if(s->t_frame==0) s->t_frame= s->pb_time;
- if(s->t_frame==0) s->t_frame=1; // 1/0 protection
- s->pp_field_time= ( ROUNDED_DIV(s->last_non_b_time, s->t_frame)
- - ROUNDED_DIV(s->last_non_b_time - s->pp_time, s->t_frame))*2;
- s->pb_field_time= ( ROUNDED_DIV(s->time, s->t_frame)
- - ROUNDED_DIV(s->last_non_b_time - s->pp_time, s->t_frame))*2;
- if(!s->progressive_sequence){
- if(s->pp_field_time <= s->pb_field_time || s->pb_field_time <= 1)
- return FRAME_SKIPPED;
- }
- }
-
- if(s->avctx->time_base.num)
- s->current_picture_ptr->f.pts = ROUNDED_DIV(s->time, s->avctx->time_base.num);
- else
- s->current_picture_ptr->f.pts = AV_NOPTS_VALUE;
- if(s->avctx->debug&FF_DEBUG_PTS)
- av_log(s->avctx, AV_LOG_DEBUG, "MPEG4 PTS: %"PRId64"\n",
- s->current_picture_ptr->f.pts);
-
- check_marker(gb, "before vop_coded");
-
- /* vop coded */
- if (get_bits1(gb) != 1){
- if(s->avctx->debug&FF_DEBUG_PICT_INFO)
- av_log(s->avctx, AV_LOG_ERROR, "vop not coded\n");
- return FRAME_SKIPPED;
- }
- if (s->shape != BIN_ONLY_SHAPE && ( s->pict_type == AV_PICTURE_TYPE_P
- || (s->pict_type == AV_PICTURE_TYPE_S && s->vol_sprite_usage==GMC_SPRITE))) {
- /* rounding type for motion estimation */
- s->no_rounding = get_bits1(gb);
- } else {
- s->no_rounding = 0;
- }
-//FIXME reduced res stuff
-
- if (s->shape != RECT_SHAPE) {
- if (s->vol_sprite_usage != 1 || s->pict_type != AV_PICTURE_TYPE_I) {
- skip_bits(gb, 13); /* width */
- skip_bits1(gb); /* marker */
- skip_bits(gb, 13); /* height */
- skip_bits1(gb); /* marker */
- skip_bits(gb, 13); /* hor_spat_ref */
- skip_bits1(gb); /* marker */
- skip_bits(gb, 13); /* ver_spat_ref */
- }
- skip_bits1(gb); /* change_CR_disable */
-
- if (get_bits1(gb) != 0) {
- skip_bits(gb, 8); /* constant_alpha_value */
- }
- }
-//FIXME complexity estimation stuff
-
- if (s->shape != BIN_ONLY_SHAPE) {
- skip_bits_long(gb, s->cplx_estimation_trash_i);
- if(s->pict_type != AV_PICTURE_TYPE_I)
- skip_bits_long(gb, s->cplx_estimation_trash_p);
- if(s->pict_type == AV_PICTURE_TYPE_B)
- skip_bits_long(gb, s->cplx_estimation_trash_b);
-
- if(get_bits_left(gb) < 3) {
- av_log(s->avctx, AV_LOG_ERROR, "Header truncated\n");
- return -1;
- }
- s->intra_dc_threshold= ff_mpeg4_dc_threshold[ get_bits(gb, 3) ];
- if(!s->progressive_sequence){
- s->top_field_first= get_bits1(gb);
- s->alternate_scan= get_bits1(gb);
- }else
- s->alternate_scan= 0;
- }
-
- 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);
- ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_alternate_vertical_scan);
- ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
- } else{
- ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_zigzag_direct);
- ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_zigzag_direct);
- ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_alternate_horizontal_scan);
- ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
- }
-
- if(s->pict_type == AV_PICTURE_TYPE_S && (s->vol_sprite_usage==STATIC_SPRITE || s->vol_sprite_usage==GMC_SPRITE)){
- if(mpeg4_decode_sprite_trajectory(s, gb) < 0)
- return -1;
- if(s->sprite_brightness_change) av_log(s->avctx, AV_LOG_ERROR, "sprite_brightness_change not supported\n");
- if(s->vol_sprite_usage==STATIC_SPRITE) av_log(s->avctx, AV_LOG_ERROR, "static sprite not supported\n");
- }
-
- if (s->shape != BIN_ONLY_SHAPE) {
- s->chroma_qscale= s->qscale = get_bits(gb, s->quant_precision);
- if(s->qscale==0){
- av_log(s->avctx, AV_LOG_ERROR, "Error, header damaged or not MPEG4 header (qscale=0)\n");
- return -1; // makes no sense to continue, as there is nothing left from the image then
- }
-
- if (s->pict_type != AV_PICTURE_TYPE_I) {
- s->f_code = get_bits(gb, 3); /* fcode_for */
- if(s->f_code==0){
- av_log(s->avctx, AV_LOG_ERROR, "Error, header damaged or not MPEG4 header (f_code=0)\n");
- s->f_code=1;
- return -1; // makes no sense to continue, as the MV decoding will break very quickly
- }
- }else
- s->f_code=1;
-
- if (s->pict_type == AV_PICTURE_TYPE_B) {
- s->b_code = get_bits(gb, 3);
- if(s->b_code==0){
- av_log(s->avctx, AV_LOG_ERROR, "Error, header damaged or not MPEG4 header (b_code=0)\n");
- s->b_code=1;
- return -1; // makes no sense to continue, as the MV decoding will break very quickly
- }
- }else
- s->b_code=1;
-
- if(s->avctx->debug&FF_DEBUG_PICT_INFO){
- av_log(s->avctx, AV_LOG_DEBUG, "qp:%d fc:%d,%d %s size:%d pro:%d alt:%d top:%d %spel part:%d resync:%d w:%d a:%d rnd:%d vot:%d%s dc:%d ce:%d/%d/%d time:%"PRId64" tincr:%d\n",
- s->qscale, s->f_code, s->b_code,
- 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")),
- gb->size_in_bits,s->progressive_sequence, s->alternate_scan, s->top_field_first,
- s->quarter_sample ? "q" : "h", s->data_partitioning, s->resync_marker, s->num_sprite_warping_points,
- s->sprite_warping_accuracy, 1-s->no_rounding, s->vo_type, s->vol_control_parameters ? " VOLC" : " ", s->intra_dc_threshold,
- s->cplx_estimation_trash_i, s->cplx_estimation_trash_p, s->cplx_estimation_trash_b,
- s->time,
- time_increment
- );
- }
-
- if(!s->scalability){
- if (s->shape!=RECT_SHAPE && s->pict_type!=AV_PICTURE_TYPE_I) {
- skip_bits1(gb); // vop shape coding type
- }
- }else{
- if(s->enhancement_type){
- int load_backward_shape= get_bits1(gb);
- if(load_backward_shape){
- av_log(s->avctx, AV_LOG_ERROR, "load backward shape isn't supported\n");
- }
- }
- skip_bits(gb, 2); //ref_select_code
- }
- }
- /* detect buggy encoders which don't set the low_delay flag (divx4/xvid/opendivx)*/
- // note we cannot detect divx5 without b-frames easily (although it's buggy too)
- if(s->vo_type==0 && s->vol_control_parameters==0 && s->divx_version==-1 && s->picture_number==0){
- av_log(s->avctx, AV_LOG_WARNING, "looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag\n");
- s->low_delay=1;
- }
-
- s->picture_number++; // better than pic number==0 always ;)
-
- s->y_dc_scale_table= ff_mpeg4_y_dc_scale_table; //FIXME add short header support
- s->c_dc_scale_table= ff_mpeg4_c_dc_scale_table;
-
- if(s->workaround_bugs&FF_BUG_EDGE){
- s->h_edge_pos= s->width;
- s->v_edge_pos= s->height;
- }
- return 0;
-}
-
-/**
- * Decode mpeg4 headers.
- * @return <0 if no VOP found (or a damaged one)
- * FRAME_SKIPPED if a not coded VOP is found
- * 0 if a VOP is found
- */
-int ff_mpeg4_decode_picture_header(MpegEncContext * s, GetBitContext *gb)
-{
- unsigned startcode, v;
-
- /* search next start code */
- align_get_bits(gb);
-
- if(s->codec_tag == AV_RL32("WV1F") && show_bits(gb, 24) == 0x575630){
- skip_bits(gb, 24);
- if(get_bits(gb, 8) == 0xF0)
- goto end;
- }
-
- startcode = 0xff;
- for(;;) {
- if(get_bits_count(gb) >= gb->size_in_bits){
- if(gb->size_in_bits==8 && (s->divx_version>=0 || s->xvid_build>=0) || s->codec_tag == AV_RL32("QMP4")){
- av_log(s->avctx, AV_LOG_VERBOSE, "frame skip %d\n", gb->size_in_bits);
- return FRAME_SKIPPED; //divx bug
- }else
- return -1; //end of stream
- }
-
- /* use the bits after the test */
- v = get_bits(gb, 8);
- startcode = ((startcode << 8) | v) & 0xffffffff;
-
- if((startcode&0xFFFFFF00) != 0x100)
- continue; //no startcode
-
- if(s->avctx->debug&FF_DEBUG_STARTCODE){
- av_log(s->avctx, AV_LOG_DEBUG, "startcode: %3X ", startcode);
- if (startcode<=0x11F) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Start");
- else if(startcode<=0x12F) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Layer Start");
- else if(startcode<=0x13F) av_log(s->avctx, AV_LOG_DEBUG, "Reserved");
- else if(startcode<=0x15F) av_log(s->avctx, AV_LOG_DEBUG, "FGS bp start");
- else if(startcode<=0x1AF) av_log(s->avctx, AV_LOG_DEBUG, "Reserved");
- else if(startcode==0x1B0) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Seq Start");
- else if(startcode==0x1B1) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Seq End");
- else if(startcode==0x1B2) av_log(s->avctx, AV_LOG_DEBUG, "User Data");
- else if(startcode==0x1B3) av_log(s->avctx, AV_LOG_DEBUG, "Group of VOP start");
- else if(startcode==0x1B4) av_log(s->avctx, AV_LOG_DEBUG, "Video Session Error");
- else if(startcode==0x1B5) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Start");
- else if(startcode==0x1B6) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Plane start");
- else if(startcode==0x1B7) av_log(s->avctx, AV_LOG_DEBUG, "slice start");
- else if(startcode==0x1B8) av_log(s->avctx, AV_LOG_DEBUG, "extension start");
- else if(startcode==0x1B9) av_log(s->avctx, AV_LOG_DEBUG, "fgs start");
- else if(startcode==0x1BA) av_log(s->avctx, AV_LOG_DEBUG, "FBA Object start");
- else if(startcode==0x1BB) av_log(s->avctx, AV_LOG_DEBUG, "FBA Object Plane start");
- else if(startcode==0x1BC) av_log(s->avctx, AV_LOG_DEBUG, "Mesh Object start");
- else if(startcode==0x1BD) av_log(s->avctx, AV_LOG_DEBUG, "Mesh Object Plane start");
- else if(startcode==0x1BE) av_log(s->avctx, AV_LOG_DEBUG, "Still Texture Object start");
- else if(startcode==0x1BF) av_log(s->avctx, AV_LOG_DEBUG, "Texture Spatial Layer start");
- else if(startcode==0x1C0) av_log(s->avctx, AV_LOG_DEBUG, "Texture SNR Layer start");
- else if(startcode==0x1C1) av_log(s->avctx, AV_LOG_DEBUG, "Texture Tile start");
- else if(startcode==0x1C2) av_log(s->avctx, AV_LOG_DEBUG, "Texture Shape Layer start");
- else if(startcode==0x1C3) av_log(s->avctx, AV_LOG_DEBUG, "stuffing start");
- else if(startcode<=0x1C5) av_log(s->avctx, AV_LOG_DEBUG, "reserved");
- else if(startcode<=0x1FF) av_log(s->avctx, AV_LOG_DEBUG, "System start");
- av_log(s->avctx, AV_LOG_DEBUG, " at %d\n", get_bits_count(gb));
- }
-
- if(startcode >= 0x120 && startcode <= 0x12F){
- if(decode_vol_header(s, gb) < 0)
- return -1;
- }
- else if(startcode == USER_DATA_STARTCODE){
- decode_user_data(s, gb);
- }
- else if(startcode == GOP_STARTCODE){
- mpeg4_decode_gop_header(s, gb);
- }
- else if(startcode == VOS_STARTCODE){
- mpeg4_decode_profile_level(s, gb);
- }
- else if(startcode == VOP_STARTCODE){
- break;
- }
-
- align_get_bits(gb);
- startcode = 0xff;
- }
-end:
- if(s->flags& CODEC_FLAG_LOW_DELAY)
- s->low_delay=1;
- s->avctx->has_b_frames= !s->low_delay;
- return decode_vop_header(s, gb);
-}
-
-av_cold void ff_mpeg4videodec_static_init(void) {
- static int done = 0;
-
- if (!done) {
- ff_init_rl(&ff_mpeg4_rl_intra, ff_mpeg4_static_rl_table_store[0]);
- ff_init_rl(&ff_rvlc_rl_inter, ff_mpeg4_static_rl_table_store[1]);
- ff_init_rl(&ff_rvlc_rl_intra, ff_mpeg4_static_rl_table_store[2]);
- INIT_VLC_RL(ff_mpeg4_rl_intra, 554);
- INIT_VLC_RL(ff_rvlc_rl_inter, 1072);
- INIT_VLC_RL(ff_rvlc_rl_intra, 1072);
- INIT_VLC_STATIC(&dc_lum, DC_VLC_BITS, 10 /* 13 */,
- &ff_mpeg4_DCtab_lum[0][1], 2, 1,
- &ff_mpeg4_DCtab_lum[0][0], 2, 1, 512);
- INIT_VLC_STATIC(&dc_chrom, DC_VLC_BITS, 10 /* 13 */,
- &ff_mpeg4_DCtab_chrom[0][1], 2, 1,
- &ff_mpeg4_DCtab_chrom[0][0], 2, 1, 512);
- INIT_VLC_STATIC(&sprite_trajectory, SPRITE_TRAJ_VLC_BITS, 15,
- &ff_sprite_trajectory_tab[0][1], 4, 2,
- &ff_sprite_trajectory_tab[0][0], 4, 2, 128);
- INIT_VLC_STATIC(&mb_type_b_vlc, MB_TYPE_B_VLC_BITS, 4,
- &ff_mb_type_b_tab[0][1], 2, 1,
- &ff_mb_type_b_tab[0][0], 2, 1, 16);
- done = 1;
- }
-}
-
-static av_cold int decode_init(AVCodecContext *avctx)
-{
- MpegEncContext *s = avctx->priv_data;
- int ret;
-
- s->divx_version=
- s->divx_build=
- s->xvid_build=
- s->lavc_build= -1;
-
- if((ret=ff_h263_decode_init(avctx)) < 0)
- return ret;
-
- ff_mpeg4videodec_static_init();
-
- s->h263_pred = 1;
- s->low_delay = 0; //default, might be overridden in the vol header during header parsing
- s->decode_mb= mpeg4_decode_mb;
- s->time_increment_bits = 4; /* default value for broken headers */
- avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
-
- return 0;
-}
-
-static const AVProfile mpeg4_video_profiles[] = {
- { FF_PROFILE_MPEG4_SIMPLE, "Simple Profile" },
- { FF_PROFILE_MPEG4_SIMPLE_SCALABLE, "Simple Scalable Profile" },
- { FF_PROFILE_MPEG4_CORE, "Core Profile" },
- { FF_PROFILE_MPEG4_MAIN, "Main Profile" },
- { FF_PROFILE_MPEG4_N_BIT, "N-bit Profile" },
- { FF_PROFILE_MPEG4_SCALABLE_TEXTURE, "Scalable Texture Profile" },
- { FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION, "Simple Face Animation Profile" },
- { FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE, "Basic Animated Texture Profile" },
- { FF_PROFILE_MPEG4_HYBRID, "Hybrid Profile" },
- { FF_PROFILE_MPEG4_ADVANCED_REAL_TIME, "Advanced Real Time Simple Profile" },
- { FF_PROFILE_MPEG4_CORE_SCALABLE, "Code Scalable Profile" },
- { FF_PROFILE_MPEG4_ADVANCED_CODING, "Advanced Coding Profile" },
- { FF_PROFILE_MPEG4_ADVANCED_CORE, "Advanced Core Profile" },
- { FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE, "Advanced Scalable Texture Profile" },
- { FF_PROFILE_MPEG4_SIMPLE_STUDIO, "Simple Studio Profile" },
- { FF_PROFILE_MPEG4_ADVANCED_SIMPLE, "Advanced Simple Profile" },
- { FF_PROFILE_UNKNOWN },
-};
-
-static const AVOption mpeg4_options[] = {
- {"quarter_sample", "1/4 subpel MC", offsetof(MpegEncContext, quarter_sample), FF_OPT_TYPE_INT, {.i64 = 0}, 0, 1, 0},
- {"divx_packed", "divx style packed b frames", offsetof(MpegEncContext, divx_packed), FF_OPT_TYPE_INT, {.i64 = 0}, 0, 1, 0},
- {NULL}
-};
-
-static const AVClass mpeg4_class = {
- "MPEG4 Video Decoder",
- av_default_item_name,
- mpeg4_options,
- LIBAVUTIL_VERSION_INT,
-};
-
-static const AVClass mpeg4_vdpau_class = {
- "MPEG4 Video VDPAU Decoder",
- av_default_item_name,
- mpeg4_options,
- LIBAVUTIL_VERSION_INT,
-};
-
-AVCodec ff_mpeg4_decoder = {
- .name = "mpeg4",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_MPEG4,
- .priv_data_size = sizeof(MpegEncContext),
- .init = decode_init,
- .close = ff_h263_decode_end,
- .decode = ff_h263_decode_frame,
- .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 |
- CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY |
- CODEC_CAP_FRAME_THREADS,
- .flush = ff_mpeg_flush,
- .max_lowres = 3,
- .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2"),
- .pix_fmts = ff_hwaccel_pixfmt_list_420,
- .profiles = NULL_IF_CONFIG_SMALL(mpeg4_video_profiles),
- .update_thread_context = ONLY_IF_THREADS_ENABLED(ff_mpeg_update_thread_context),
- .priv_class = &mpeg4_class,
-};
-
-
-#if CONFIG_MPEG4_VDPAU_DECODER
-AVCodec ff_mpeg4_vdpau_decoder = {
- .name = "mpeg4_vdpau",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_MPEG4,
- .priv_data_size = sizeof(MpegEncContext),
- .init = decode_init,
- .close = ff_h263_decode_end,
- .decode = ff_h263_decode_frame,
- .capabilities = CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY |
- CODEC_CAP_HWACCEL_VDPAU,
- .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 (VDPAU)"),
- .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_VDPAU_MPEG4,
- AV_PIX_FMT_NONE },
- .priv_class = &mpeg4_vdpau_class,
-};
-#endif
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpegaudio.c b/src/thirdparty/ffmpeg/libavcodec/mpegaudio.c
deleted file mode 100644
index cd82c5517..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpegaudio.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * MPEG Audio common code
- * Copyright (c) 2001, 2002 Fabrice Bellard
- *
- * 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
- * MPEG Audio common code.
- */
-
-#include "mpegaudio.h"
-
-
-/* bitrate is in kb/s */
-int ff_mpa_l2_select_table(int bitrate, int nb_channels, int freq, int lsf)
-{
- int ch_bitrate, table;
-
- ch_bitrate = bitrate / nb_channels;
- if (!lsf) {
- if ((freq == 48000 && ch_bitrate >= 56) ||
- (ch_bitrate >= 56 && ch_bitrate <= 80))
- table = 0;
- else if (freq != 48000 && ch_bitrate >= 96)
- table = 1;
- else if (freq != 32000 && ch_bitrate <= 48)
- table = 2;
- else
- table = 3;
- } else {
- table = 4;
- }
- return table;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpegaudio.h b/src/thirdparty/ffmpeg/libavcodec/mpegaudio.h
deleted file mode 100644
index 8929852ad..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpegaudio.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * copyright (c) 2001 Fabrice Bellard
- *
- * 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
- * mpeg audio declarations for both encoder and decoder.
- */
-
-#ifndef AVCODEC_MPEGAUDIO_H
-#define AVCODEC_MPEGAUDIO_H
-
-#ifndef CONFIG_FLOAT
-# define CONFIG_FLOAT 0
-#endif
-
-#include <stdint.h>
-
-/* max frame size, in samples */
-#define MPA_FRAME_SIZE 1152
-
-/* max compressed frame size */
-#define MPA_MAX_CODED_FRAME_SIZE 1792
-
-#define MPA_MAX_CHANNELS 2
-
-#define SBLIMIT 32 /* number of subbands */
-
-#define MPA_STEREO 0
-#define MPA_JSTEREO 1
-#define MPA_DUAL 2
-#define MPA_MONO 3
-
-#ifndef FRAC_BITS
-#define FRAC_BITS 23 /* fractional bits for sb_samples and dct */
-#define WFRAC_BITS 16 /* fractional bits for window */
-#endif
-
-#define IMDCT_SCALAR 1.759
-
-#define FRAC_ONE (1 << FRAC_BITS)
-
-#define FIX(a) ((int)((a) * FRAC_ONE))
-
-#if CONFIG_FLOAT
-# define INTFLOAT float
-typedef float MPA_INT;
-typedef float OUT_INT;
-#elif FRAC_BITS <= 15
-# define INTFLOAT int
-typedef int16_t MPA_INT;
-typedef int16_t OUT_INT;
-#else
-# define INTFLOAT int
-typedef int32_t MPA_INT;
-typedef int16_t OUT_INT;
-#endif
-
-int ff_mpa_l2_select_table(int bitrate, int nb_channels, int freq, int lsf);
-
-#endif /* AVCODEC_MPEGAUDIO_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpegaudio_parser.c b/src/thirdparty/ffmpeg/libavcodec/mpegaudio_parser.c
deleted file mode 100644
index 4a9c12322..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpegaudio_parser.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * MPEG Audio parser
- * Copyright (c) 2003 Fabrice Bellard
- * Copyright (c) 2003 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 "parser.h"
-#include "mpegaudiodecheader.h"
-#include "libavutil/common.h"
-
-
-typedef struct MpegAudioParseContext {
- ParseContext pc;
- int frame_size;
- uint32_t header;
- int header_count;
-} MpegAudioParseContext;
-
-#define MPA_HEADER_SIZE 4
-
-/* header + layer + bitrate + freq + lsf/mpeg25 */
-#define SAME_HEADER_MASK \
- (0xffe00000 | (3 << 17) | (3 << 10) | (3 << 19))
-
-static int mpegaudio_parse(AVCodecParserContext *s1,
- AVCodecContext *avctx,
- const uint8_t **poutbuf, int *poutbuf_size,
- const uint8_t *buf, int buf_size)
-{
- MpegAudioParseContext *s = s1->priv_data;
- ParseContext *pc = &s->pc;
- uint32_t state= pc->state;
- int i;
- int next= END_NOT_FOUND;
-
- for(i=0; i<buf_size; ){
- if(s->frame_size){
- int inc= FFMIN(buf_size - i, s->frame_size);
- i += inc;
- s->frame_size -= inc;
- state = 0;
-
- if(!s->frame_size){
- next= i;
- break;
- }
- }else{
- while(i<buf_size){
- int ret, sr, channels, bit_rate, frame_size;
-
- state= (state<<8) + buf[i++];
-
- ret = avpriv_mpa_decode_header(avctx, state, &sr, &channels, &frame_size, &bit_rate);
- if (ret < 4) {
- if (i > 4)
- s->header_count = -2;
- } else {
- if((state&SAME_HEADER_MASK) != (s->header&SAME_HEADER_MASK) && s->header)
- s->header_count= -3;
- s->header= state;
- s->header_count++;
- s->frame_size = ret-4;
-
- if (s->header_count > 1) {
- avctx->sample_rate= sr;
- avctx->channels = channels;
- s1->duration = frame_size;
- avctx->bit_rate = bit_rate;
- }
- break;
- }
- }
- }
- }
-
- pc->state= state;
- if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
- *poutbuf = NULL;
- *poutbuf_size = 0;
- return buf_size;
- }
-
- *poutbuf = buf;
- *poutbuf_size = buf_size;
- return next;
-}
-
-
-AVCodecParser ff_mpegaudio_parser = {
- .codec_ids = { AV_CODEC_ID_MP1, AV_CODEC_ID_MP2, AV_CODEC_ID_MP3 },
- .priv_data_size = sizeof(MpegAudioParseContext),
- .parser_parse = mpegaudio_parse,
- .parser_close = ff_parse_close,
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpegaudio_tablegen.h b/src/thirdparty/ffmpeg/libavcodec/mpegaudio_tablegen.h
deleted file mode 100644
index 43907db81..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpegaudio_tablegen.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Header file for hardcoded mpegaudiodec tables
- *
- * Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
- *
- * 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_MPEGAUDIO_TABLEGEN_H
-#define AVCODEC_MPEGAUDIO_TABLEGEN_H
-
-#include <stdint.h>
-#include <math.h>
-
-#define TABLE_4_3_SIZE (8191 + 16)*4
-#if CONFIG_HARDCODED_TABLES
-#define mpegaudio_tableinit()
-#include "libavcodec/mpegaudio_tables.h"
-#else
-static int8_t table_4_3_exp[TABLE_4_3_SIZE];
-static uint32_t table_4_3_value[TABLE_4_3_SIZE];
-static uint32_t exp_table_fixed[512];
-static uint32_t expval_table_fixed[512][16];
-static float exp_table_float[512];
-static float expval_table_float[512][16];
-
-#define FRAC_BITS 23
-#define IMDCT_SCALAR 1.759
-
-static void mpegaudio_tableinit(void)
-{
- int i, value, exponent;
- for (i = 1; i < TABLE_4_3_SIZE; i++) {
- double value = i / 4;
- double f, fm;
- int e, m;
- f = value / IMDCT_SCALAR * cbrtf(value) * pow(2, (i & 3) * 0.25);
- fm = frexp(f, &e);
- m = (uint32_t)(fm * (1LL << 31) + 0.5);
- e += FRAC_BITS - 31 + 5 - 100;
-
- /* normalized to FRAC_BITS */
- table_4_3_value[i] = m;
- table_4_3_exp[i] = -e;
- }
- for (exponent = 0; exponent < 512; exponent++) {
- for (value = 0; value < 16; value++) {
- double f = (double)value * cbrtf(value) * pow(2, (exponent - 400) * 0.25 + FRAC_BITS + 5) / IMDCT_SCALAR;
- expval_table_fixed[exponent][value] = llrint(f);
- expval_table_float[exponent][value] = f;
- }
- exp_table_fixed[exponent] = expval_table_fixed[exponent][1];
- exp_table_float[exponent] = expval_table_float[exponent][1];
- }
-}
-#endif /* CONFIG_HARDCODED_TABLES */
-
-#endif /* AVCODEC_MPEGAUDIO_TABLEGEN_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpegaudiodata.c b/src/thirdparty/ffmpeg/libavcodec/mpegaudiodata.c
deleted file mode 100644
index 9d29a7d55..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpegaudiodata.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * MPEG Audio common tables
- * copyright (c) 2002 Fabrice Bellard
- *
- * 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
- * mpeg audio layer common tables.
- */
-
-#include "mpegaudiodata.h"
-
-
-const uint16_t avpriv_mpa_bitrate_tab[2][3][15] = {
- { {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448 },
- {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384 },
- {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 } },
- { {0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256},
- {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160},
- {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160}
- }
-};
-
-const uint16_t avpriv_mpa_freq_tab[3] = { 44100, 48000, 32000 };
-
-/*******************************************************/
-/* layer 2 tables */
-
-const int ff_mpa_sblimit_table[5] = { 27 , 30 , 8, 12 , 30 };
-
-const int ff_mpa_quant_steps[17] = {
- 3, 5, 7, 9, 15,
- 31, 63, 127, 255, 511,
- 1023, 2047, 4095, 8191, 16383,
- 32767, 65535
-};
-
-/* we use a negative value if grouped */
-const int ff_mpa_quant_bits[17] = {
- -5, -7, 3, -10, 4,
- 5, 6, 7, 8, 9,
- 10, 11, 12, 13, 14,
- 15, 16
-};
-
-/* encoding tables which give the quantization index. Note how it is
- possible to store them efficiently ! */
-static const unsigned char alloc_table_1[] = {
- 4, 0, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
- 4, 0, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
- 4, 0, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
- 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16,
- 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16,
- 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16,
- 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16,
- 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16,
- 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16,
- 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16,
- 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16,
- 3, 0, 1, 2, 3, 4, 5, 16,
- 3, 0, 1, 2, 3, 4, 5, 16,
- 3, 0, 1, 2, 3, 4, 5, 16,
- 3, 0, 1, 2, 3, 4, 5, 16,
- 3, 0, 1, 2, 3, 4, 5, 16,
- 3, 0, 1, 2, 3, 4, 5, 16,
- 3, 0, 1, 2, 3, 4, 5, 16,
- 3, 0, 1, 2, 3, 4, 5, 16,
- 3, 0, 1, 2, 3, 4, 5, 16,
- 3, 0, 1, 2, 3, 4, 5, 16,
- 3, 0, 1, 2, 3, 4, 5, 16,
- 3, 0, 1, 2, 3, 4, 5, 16,
- 2, 0, 1, 16,
- 2, 0, 1, 16,
- 2, 0, 1, 16,
- 2, 0, 1, 16,
- 2, 0, 1, 16,
- 2, 0, 1, 16,
- 2, 0, 1, 16,
-};
-
-static const unsigned char alloc_table_3[] = {
- 4, 0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 4, 0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 3, 0, 1, 3, 4, 5, 6, 7,
- 3, 0, 1, 3, 4, 5, 6, 7,
- 3, 0, 1, 3, 4, 5, 6, 7,
- 3, 0, 1, 3, 4, 5, 6, 7,
- 3, 0, 1, 3, 4, 5, 6, 7,
- 3, 0, 1, 3, 4, 5, 6, 7,
- 3, 0, 1, 3, 4, 5, 6, 7,
- 3, 0, 1, 3, 4, 5, 6, 7,
- 3, 0, 1, 3, 4, 5, 6, 7,
- 3, 0, 1, 3, 4, 5, 6, 7,
-};
-
-static const unsigned char alloc_table_4[] = {
- 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 3, 0, 1, 3, 4, 5, 6, 7,
- 3, 0, 1, 3, 4, 5, 6, 7,
- 3, 0, 1, 3, 4, 5, 6, 7,
- 3, 0, 1, 3, 4, 5, 6, 7,
- 3, 0, 1, 3, 4, 5, 6, 7,
- 3, 0, 1, 3, 4, 5, 6, 7,
- 3, 0, 1, 3, 4, 5, 6, 7,
- 2, 0, 1, 3,
- 2, 0, 1, 3,
- 2, 0, 1, 3,
- 2, 0, 1, 3,
- 2, 0, 1, 3,
- 2, 0, 1, 3,
- 2, 0, 1, 3,
- 2, 0, 1, 3,
- 2, 0, 1, 3,
- 2, 0, 1, 3,
- 2, 0, 1, 3,
- 2, 0, 1, 3,
- 2, 0, 1, 3,
- 2, 0, 1, 3,
- 2, 0, 1, 3,
- 2, 0, 1, 3,
- 2, 0, 1, 3,
- 2, 0, 1, 3,
- 2, 0, 1, 3,
-};
-
-const unsigned char * const ff_mpa_alloc_tables[5] =
-{ alloc_table_1, alloc_table_1, alloc_table_3, alloc_table_3, alloc_table_4, };
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpegaudiodata.h b/src/thirdparty/ffmpeg/libavcodec/mpegaudiodata.h
deleted file mode 100644
index ae6e671ad..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpegaudiodata.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * MPEG Audio common tables
- * copyright (c) 2002 Fabrice Bellard
- *
- * 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
- * mpeg audio layer common tables.
- */
-
-#ifndef AVCODEC_MPEGAUDIODATA_H
-#define AVCODEC_MPEGAUDIODATA_H
-
-#include <stdint.h>
-
-#include "libavutil/internal.h"
-
-#define MODE_EXT_MS_STEREO 2
-#define MODE_EXT_I_STEREO 1
-
-extern av_export const uint16_t avpriv_mpa_bitrate_tab[2][3][15];
-extern av_export const uint16_t avpriv_mpa_freq_tab[3];
-extern const int ff_mpa_sblimit_table[5];
-extern const int ff_mpa_quant_steps[17];
-extern const int ff_mpa_quant_bits[17];
-extern const unsigned char * const ff_mpa_alloc_tables[5];
-
-#endif /* AVCODEC_MPEGAUDIODATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpegaudiodec.c b/src/thirdparty/ffmpeg/libavcodec/mpegaudiodec.c
deleted file mode 100644
index 3aad06888..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpegaudiodec.c
+++ /dev/null
@@ -1,2081 +0,0 @@
-/*
- * MPEG Audio decoder
- * Copyright (c) 2001, 2002 Fabrice Bellard
- *
- * 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
- * MPEG Audio decoder
- */
-
-#include "libavutil/avassert.h"
-#include "libavutil/channel_layout.h"
-#include "libavutil/float_dsp.h"
-#include "libavutil/libm.h"
-#include "avcodec.h"
-#include "get_bits.h"
-#include "internal.h"
-#include "mathops.h"
-#include "mpegaudiodsp.h"
-#include "dsputil.h"
-
-/*
- * TODO:
- * - test lsf / mpeg25 extensively.
- */
-
-#include "mpegaudio.h"
-#include "mpegaudiodecheader.h"
-
-#define BACKSTEP_SIZE 512
-#define EXTRABYTES 24
-#define LAST_BUF_SIZE 2 * BACKSTEP_SIZE + EXTRABYTES
-
-/* layer 3 "granule" */
-typedef struct GranuleDef {
- uint8_t scfsi;
- int part2_3_length;
- int big_values;
- int global_gain;
- int scalefac_compress;
- uint8_t block_type;
- uint8_t switch_point;
- int table_select[3];
- int subblock_gain[3];
- uint8_t scalefac_scale;
- uint8_t count1table_select;
- int region_size[3]; /* number of huffman codes in each region */
- int preflag;
- int short_start, long_end; /* long/short band indexes */
- uint8_t scale_factors[40];
- DECLARE_ALIGNED(16, INTFLOAT, sb_hybrid)[SBLIMIT * 18]; /* 576 samples */
-} GranuleDef;
-
-typedef struct MPADecodeContext {
- MPA_DECODE_HEADER
- uint8_t last_buf[LAST_BUF_SIZE];
- int last_buf_size;
- /* next header (used in free format parsing) */
- uint32_t free_format_next_header;
- GetBitContext gb;
- GetBitContext in_gb;
- DECLARE_ALIGNED(32, MPA_INT, synth_buf)[MPA_MAX_CHANNELS][512 * 2];
- int synth_buf_offset[MPA_MAX_CHANNELS];
- DECLARE_ALIGNED(32, INTFLOAT, sb_samples)[MPA_MAX_CHANNELS][36][SBLIMIT];
- INTFLOAT mdct_buf[MPA_MAX_CHANNELS][SBLIMIT * 18]; /* previous samples, for layer 3 MDCT */
- GranuleDef granules[2][2]; /* Used in Layer 3 */
- int adu_mode; ///< 0 for standard mp3, 1 for adu formatted mp3
- int dither_state;
- int err_recognition;
- AVCodecContext* avctx;
- MPADSPContext mpadsp;
- AVFloatDSPContext fdsp;
- AVFrame *frame;
-} MPADecodeContext;
-
-#if CONFIG_FLOAT
-# define SHR(a,b) ((a)*(1.0f/(1<<(b))))
-# define FIXR_OLD(a) ((int)((a) * FRAC_ONE + 0.5))
-# define FIXR(x) ((float)(x))
-# define FIXHR(x) ((float)(x))
-# define MULH3(x, y, s) ((s)*(y)*(x))
-# define MULLx(x, y, s) ((y)*(x))
-# define RENAME(a) a ## _float
-# define OUT_FMT AV_SAMPLE_FMT_FLT
-# define OUT_FMT_P AV_SAMPLE_FMT_FLTP
-#else
-# define SHR(a,b) ((a)>>(b))
-/* WARNING: only correct for positive numbers */
-# define FIXR_OLD(a) ((int)((a) * FRAC_ONE + 0.5))
-# define FIXR(a) ((int)((a) * FRAC_ONE + 0.5))
-# define FIXHR(a) ((int)((a) * (1LL<<32) + 0.5))
-# define MULH3(x, y, s) MULH((s)*(x), y)
-# define MULLx(x, y, s) MULL(x,y,s)
-# define RENAME(a) a ## _fixed
-# define OUT_FMT AV_SAMPLE_FMT_S16
-# define OUT_FMT_P AV_SAMPLE_FMT_S16P
-#endif
-
-/****************/
-
-#define HEADER_SIZE 4
-
-#include "mpegaudiodata.h"
-#include "mpegaudiodectab.h"
-
-/* vlc structure for decoding layer 3 huffman tables */
-static VLC huff_vlc[16];
-static VLC_TYPE huff_vlc_tables[
- 0 + 128 + 128 + 128 + 130 + 128 + 154 + 166 +
- 142 + 204 + 190 + 170 + 542 + 460 + 662 + 414
- ][2];
-static const int huff_vlc_tables_sizes[16] = {
- 0, 128, 128, 128, 130, 128, 154, 166,
- 142, 204, 190, 170, 542, 460, 662, 414
-};
-static VLC huff_quad_vlc[2];
-static VLC_TYPE huff_quad_vlc_tables[128+16][2];
-static const int huff_quad_vlc_tables_sizes[2] = { 128, 16 };
-/* computed from band_size_long */
-static uint16_t band_index_long[9][23];
-#include "mpegaudio_tablegen.h"
-/* intensity stereo coef table */
-static INTFLOAT is_table[2][16];
-static INTFLOAT is_table_lsf[2][2][16];
-static INTFLOAT csa_table[8][4];
-
-static int16_t division_tab3[1<<6 ];
-static int16_t division_tab5[1<<8 ];
-static int16_t division_tab9[1<<11];
-
-static int16_t * const division_tabs[4] = {
- division_tab3, division_tab5, NULL, division_tab9
-};
-
-/* lower 2 bits: modulo 3, higher bits: shift */
-static uint16_t scale_factor_modshift[64];
-/* [i][j]: 2^(-j/3) * FRAC_ONE * 2^(i+2) / (2^(i+2) - 1) */
-static int32_t scale_factor_mult[15][3];
-/* mult table for layer 2 group quantization */
-
-#define SCALE_GEN(v) \
-{ FIXR_OLD(1.0 * (v)), FIXR_OLD(0.7937005259 * (v)), FIXR_OLD(0.6299605249 * (v)) }
-
-static const int32_t scale_factor_mult2[3][3] = {
- SCALE_GEN(4.0 / 3.0), /* 3 steps */
- SCALE_GEN(4.0 / 5.0), /* 5 steps */
- SCALE_GEN(4.0 / 9.0), /* 9 steps */
-};
-
-/**
- * Convert region offsets to region sizes and truncate
- * size to big_values.
- */
-static void ff_region_offset2size(GranuleDef *g)
-{
- int i, k, j = 0;
- g->region_size[2] = 576 / 2;
- for (i = 0; i < 3; i++) {
- k = FFMIN(g->region_size[i], g->big_values);
- g->region_size[i] = k - j;
- j = k;
- }
-}
-
-static void ff_init_short_region(MPADecodeContext *s, GranuleDef *g)
-{
- if (g->block_type == 2) {
- if (s->sample_rate_index != 8)
- g->region_size[0] = (36 / 2);
- else
- g->region_size[0] = (72 / 2);
- } else {
- if (s->sample_rate_index <= 2)
- g->region_size[0] = (36 / 2);
- else if (s->sample_rate_index != 8)
- g->region_size[0] = (54 / 2);
- else
- g->region_size[0] = (108 / 2);
- }
- g->region_size[1] = (576 / 2);
-}
-
-static void ff_init_long_region(MPADecodeContext *s, GranuleDef *g, int ra1, int ra2)
-{
- int l;
- g->region_size[0] = band_index_long[s->sample_rate_index][ra1 + 1] >> 1;
- /* should not overflow */
- l = FFMIN(ra1 + ra2 + 2, 22);
- g->region_size[1] = band_index_long[s->sample_rate_index][ l] >> 1;
-}
-
-static void ff_compute_band_indexes(MPADecodeContext *s, GranuleDef *g)
-{
- if (g->block_type == 2) {
- if (g->switch_point) {
- if(s->sample_rate_index == 8)
- av_log_ask_for_sample(s->avctx, "switch point in 8khz\n");
- /* if switched mode, we handle the 36 first samples as
- long blocks. For 8000Hz, we handle the 72 first
- exponents as long blocks */
- if (s->sample_rate_index <= 2)
- g->long_end = 8;
- else
- g->long_end = 6;
-
- g->short_start = 3;
- } else {
- g->long_end = 0;
- g->short_start = 0;
- }
- } else {
- g->short_start = 13;
- g->long_end = 22;
- }
-}
-
-/* layer 1 unscaling */
-/* n = number of bits of the mantissa minus 1 */
-static inline int l1_unscale(int n, int mant, int scale_factor)
-{
- int shift, mod;
- int64_t val;
-
- shift = scale_factor_modshift[scale_factor];
- mod = shift & 3;
- shift >>= 2;
- val = MUL64(mant + (-1 << 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);
-}
-
-static inline int l2_unscale_group(int steps, int mant, int scale_factor)
-{
- int shift, mod, val;
-
- shift = scale_factor_modshift[scale_factor];
- mod = shift & 3;
- shift >>= 2;
-
- val = (mant - (steps >> 1)) * scale_factor_mult2[steps >> 2][mod];
- /* NOTE: at this point, 0 <= shift <= 21 */
- if (shift > 0)
- val = (val + (1 << (shift - 1))) >> shift;
- return val;
-}
-
-/* compute value^(4/3) * 2^(exponent/4). It normalized to FRAC_BITS */
-static inline int l3_unscale(int value, int exponent)
-{
- unsigned int m;
- int e;
-
- e = table_4_3_exp [4 * value + (exponent & 3)];
- m = table_4_3_value[4 * value + (exponent & 3)];
- e -= exponent >> 2;
-#ifdef DEBUG
- if(e < 1)
- av_log(NULL, AV_LOG_WARNING, "l3_unscale: e is %d\n", e);
-#endif
- if (e > 31)
- return 0;
- m = (m + (1 << (e - 1))) >> e;
-
- return m;
-}
-
-static av_cold void decode_init_static(void)
-{
- int i, j, k;
- int offset;
-
- /* scale factors table for layer 1/2 */
- for (i = 0; i < 64; i++) {
- int shift, mod;
- /* 1.0 (i = 3) is normalized to 2 ^ FRAC_BITS */
- shift = i / 3;
- mod = i % 3;
- scale_factor_modshift[i] = mod | (shift << 2);
- }
-
- /* scale factor multiply for layer 1 */
- for (i = 0; i < 15; i++) {
- int n, norm;
- n = i + 2;
- norm = ((INT64_C(1) << n) * FRAC_ONE) / ((1 << n) - 1);
- scale_factor_mult[i][0] = MULLx(norm, FIXR(1.0 * 2.0), FRAC_BITS);
- scale_factor_mult[i][1] = MULLx(norm, FIXR(0.7937005259 * 2.0), FRAC_BITS);
- scale_factor_mult[i][2] = MULLx(norm, FIXR(0.6299605249 * 2.0), FRAC_BITS);
- av_dlog(NULL, "%d: norm=%x s=%x %x %x\n", i, norm,
- scale_factor_mult[i][0],
- scale_factor_mult[i][1],
- scale_factor_mult[i][2]);
- }
-
- RENAME(ff_mpa_synth_init)(RENAME(ff_mpa_synth_window));
-
- /* huffman decode tables */
- offset = 0;
- for (i = 1; i < 16; i++) {
- const HuffTable *h = &mpa_huff_tables[i];
- int xsize, x, y;
- uint8_t tmp_bits [512] = { 0 };
- uint16_t tmp_codes[512] = { 0 };
-
- xsize = h->xsize;
-
- j = 0;
- for (x = 0; x < xsize; x++) {
- for (y = 0; y < xsize; y++) {
- tmp_bits [(x << 5) | y | ((x&&y)<<4)]= h->bits [j ];
- tmp_codes[(x << 5) | y | ((x&&y)<<4)]= h->codes[j++];
- }
- }
-
- /* XXX: fail test */
- huff_vlc[i].table = huff_vlc_tables+offset;
- huff_vlc[i].table_allocated = huff_vlc_tables_sizes[i];
- init_vlc(&huff_vlc[i], 7, 512,
- tmp_bits, 1, 1, tmp_codes, 2, 2,
- INIT_VLC_USE_NEW_STATIC);
- offset += huff_vlc_tables_sizes[i];
- }
- av_assert0(offset == FF_ARRAY_ELEMS(huff_vlc_tables));
-
- offset = 0;
- for (i = 0; i < 2; i++) {
- huff_quad_vlc[i].table = huff_quad_vlc_tables+offset;
- huff_quad_vlc[i].table_allocated = huff_quad_vlc_tables_sizes[i];
- init_vlc(&huff_quad_vlc[i], i == 0 ? 7 : 4, 16,
- mpa_quad_bits[i], 1, 1, mpa_quad_codes[i], 1, 1,
- INIT_VLC_USE_NEW_STATIC);
- offset += huff_quad_vlc_tables_sizes[i];
- }
- av_assert0(offset == FF_ARRAY_ELEMS(huff_quad_vlc_tables));
-
- for (i = 0; i < 9; i++) {
- k = 0;
- for (j = 0; j < 22; j++) {
- band_index_long[i][j] = k;
- k += band_size_long[i][j];
- }
- band_index_long[i][22] = k;
- }
-
- /* compute n ^ (4/3) and store it in mantissa/exp format */
-
- mpegaudio_tableinit();
-
- for (i = 0; i < 4; i++) {
- if (ff_mpa_quant_bits[i] < 0) {
- for (j = 0; j < (1 << (-ff_mpa_quant_bits[i]+1)); j++) {
- int val1, val2, val3, steps;
- int val = j;
- steps = ff_mpa_quant_steps[i];
- val1 = val % steps;
- val /= steps;
- val2 = val % steps;
- val3 = val / steps;
- division_tabs[i][j] = val1 + (val2 << 4) + (val3 << 8);
- }
- }
- }
-
-
- for (i = 0; i < 7; i++) {
- float f;
- INTFLOAT v;
- if (i != 6) {
- f = tan((double)i * M_PI / 12.0);
- v = FIXR(f / (1.0 + f));
- } else {
- v = FIXR(1.0);
- }
- is_table[0][ i] = v;
- is_table[1][6 - i] = v;
- }
- /* invalid values */
- for (i = 7; i < 16; i++)
- is_table[0][i] = is_table[1][i] = 0.0;
-
- for (i = 0; i < 16; i++) {
- double f;
- int e, k;
-
- for (j = 0; j < 2; j++) {
- e = -(j + 1) * ((i + 1) >> 1);
- f = exp2(e / 4.0);
- k = i & 1;
- is_table_lsf[j][k ^ 1][i] = FIXR(f);
- is_table_lsf[j][k ][i] = FIXR(1.0);
- av_dlog(NULL, "is_table_lsf %d %d: %f %f\n",
- i, j, (float) is_table_lsf[j][0][i],
- (float) is_table_lsf[j][1][i]);
- }
- }
-
- for (i = 0; i < 8; i++) {
- float ci, cs, ca;
- ci = ci_table[i];
- cs = 1.0 / sqrt(1.0 + ci * ci);
- ca = cs * ci;
-#if !CONFIG_FLOAT
- csa_table[i][0] = FIXHR(cs/4);
- csa_table[i][1] = FIXHR(ca/4);
- csa_table[i][2] = FIXHR(ca/4) + FIXHR(cs/4);
- csa_table[i][3] = FIXHR(ca/4) - FIXHR(cs/4);
-#else
- csa_table[i][0] = cs;
- csa_table[i][1] = ca;
- csa_table[i][2] = ca + cs;
- csa_table[i][3] = ca - cs;
-#endif
- }
-}
-
-static av_cold int decode_init(AVCodecContext * avctx)
-{
- static int initialized_tables = 0;
- MPADecodeContext *s = avctx->priv_data;
-
- if (!initialized_tables) {
- decode_init_static();
- initialized_tables = 1;
- }
-
- s->avctx = avctx;
-
- avpriv_float_dsp_init(&s->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
- ff_mpadsp_init(&s->mpadsp);
-
- if (avctx->request_sample_fmt == OUT_FMT &&
- avctx->codec_id != AV_CODEC_ID_MP3ON4)
- avctx->sample_fmt = OUT_FMT;
- else
- avctx->sample_fmt = OUT_FMT_P;
- s->err_recognition = avctx->err_recognition;
-
- if (avctx->codec_id == AV_CODEC_ID_MP3ADU)
- s->adu_mode = 1;
-
- return 0;
-}
-
-#define C3 FIXHR(0.86602540378443864676/2)
-#define C4 FIXHR(0.70710678118654752439/2) //0.5 / cos(pi*(9)/36)
-#define C5 FIXHR(0.51763809020504152469/2) //0.5 / cos(pi*(5)/36)
-#define C6 FIXHR(1.93185165257813657349/4) //0.5 / cos(pi*(15)/36)
-
-/* 12 points IMDCT. We compute it "by hand" by factorizing obvious
- cases. */
-static void imdct12(INTFLOAT *out, INTFLOAT *in)
-{
- INTFLOAT in0, in1, in2, in3, in4, in5, t1, t2;
-
- in0 = in[0*3];
- in1 = in[1*3] + in[0*3];
- in2 = in[2*3] + in[1*3];
- in3 = in[3*3] + in[2*3];
- in4 = in[4*3] + in[3*3];
- in5 = in[5*3] + in[4*3];
- in5 += in3;
- in3 += in1;
-
- in2 = MULH3(in2, C3, 2);
- in3 = MULH3(in3, C3, 4);
-
- t1 = in0 - in4;
- t2 = MULH3(in1 - in5, C4, 2);
-
- out[ 7] =
- out[10] = t1 + t2;
- out[ 1] =
- out[ 4] = t1 - t2;
-
- in0 += SHR(in4, 1);
- in4 = in0 + in2;
- in5 += 2*in1;
- in1 = MULH3(in5 + in3, C5, 1);
- out[ 8] =
- out[ 9] = in4 + in1;
- out[ 2] =
- out[ 3] = in4 - in1;
-
- in0 -= in2;
- in5 = MULH3(in5 - in3, C6, 2);
- out[ 0] =
- out[ 5] = in0 - in5;
- out[ 6] =
- out[11] = in0 + in5;
-}
-
-/* return the number of decoded frames */
-static int mp_decode_layer1(MPADecodeContext *s)
-{
- int bound, i, v, n, ch, j, mant;
- uint8_t allocation[MPA_MAX_CHANNELS][SBLIMIT];
- uint8_t scale_factors[MPA_MAX_CHANNELS][SBLIMIT];
-
- if (s->mode == MPA_JSTEREO)
- bound = (s->mode_ext + 1) * 4;
- else
- bound = SBLIMIT;
-
- /* allocation bits */
- for (i = 0; i < bound; i++) {
- for (ch = 0; ch < s->nb_channels; ch++) {
- allocation[ch][i] = get_bits(&s->gb, 4);
- }
- }
- for (i = bound; i < SBLIMIT; i++)
- allocation[0][i] = get_bits(&s->gb, 4);
-
- /* scale factors */
- for (i = 0; i < bound; i++) {
- for (ch = 0; ch < s->nb_channels; ch++) {
- if (allocation[ch][i])
- scale_factors[ch][i] = get_bits(&s->gb, 6);
- }
- }
- for (i = bound; i < SBLIMIT; i++) {
- if (allocation[0][i]) {
- scale_factors[0][i] = get_bits(&s->gb, 6);
- scale_factors[1][i] = get_bits(&s->gb, 6);
- }
- }
-
- /* compute samples */
- for (j = 0; j < 12; j++) {
- for (i = 0; i < bound; i++) {
- for (ch = 0; ch < s->nb_channels; ch++) {
- n = allocation[ch][i];
- if (n) {
- mant = get_bits(&s->gb, n + 1);
- v = l1_unscale(n, mant, scale_factors[ch][i]);
- } else {
- v = 0;
- }
- s->sb_samples[ch][j][i] = v;
- }
- }
- for (i = bound; i < SBLIMIT; i++) {
- n = allocation[0][i];
- if (n) {
- mant = get_bits(&s->gb, n + 1);
- v = l1_unscale(n, mant, scale_factors[0][i]);
- s->sb_samples[0][j][i] = v;
- v = l1_unscale(n, mant, scale_factors[1][i]);
- s->sb_samples[1][j][i] = v;
- } else {
- s->sb_samples[0][j][i] = 0;
- s->sb_samples[1][j][i] = 0;
- }
- }
- }
- return 12;
-}
-
-static int mp_decode_layer2(MPADecodeContext *s)
-{
- int sblimit; /* number of used subbands */
- const unsigned char *alloc_table;
- int table, bit_alloc_bits, i, j, ch, bound, v;
- unsigned char bit_alloc[MPA_MAX_CHANNELS][SBLIMIT];
- unsigned char scale_code[MPA_MAX_CHANNELS][SBLIMIT];
- unsigned char scale_factors[MPA_MAX_CHANNELS][SBLIMIT][3], *sf;
- int scale, qindex, bits, steps, k, l, m, b;
-
- /* select decoding table */
- table = ff_mpa_l2_select_table(s->bit_rate / 1000, s->nb_channels,
- s->sample_rate, s->lsf);
- sblimit = ff_mpa_sblimit_table[table];
- alloc_table = ff_mpa_alloc_tables[table];
-
- if (s->mode == MPA_JSTEREO)
- bound = (s->mode_ext + 1) * 4;
- else
- bound = sblimit;
-
- av_dlog(s->avctx, "bound=%d sblimit=%d\n", bound, sblimit);
-
- /* sanity check */
- if (bound > sblimit)
- bound = sblimit;
-
- /* parse bit allocation */
- j = 0;
- for (i = 0; i < bound; i++) {
- bit_alloc_bits = alloc_table[j];
- for (ch = 0; ch < s->nb_channels; ch++)
- bit_alloc[ch][i] = get_bits(&s->gb, bit_alloc_bits);
- j += 1 << bit_alloc_bits;
- }
- for (i = bound; i < sblimit; i++) {
- bit_alloc_bits = alloc_table[j];
- v = get_bits(&s->gb, bit_alloc_bits);
- bit_alloc[0][i] = v;
- bit_alloc[1][i] = v;
- j += 1 << bit_alloc_bits;
- }
-
- /* scale codes */
- for (i = 0; i < sblimit; i++) {
- for (ch = 0; ch < s->nb_channels; ch++) {
- if (bit_alloc[ch][i])
- scale_code[ch][i] = get_bits(&s->gb, 2);
- }
- }
-
- /* scale factors */
- for (i = 0; i < sblimit; i++) {
- for (ch = 0; ch < s->nb_channels; ch++) {
- if (bit_alloc[ch][i]) {
- sf = scale_factors[ch][i];
- switch (scale_code[ch][i]) {
- default:
- case 0:
- sf[0] = get_bits(&s->gb, 6);
- sf[1] = get_bits(&s->gb, 6);
- sf[2] = get_bits(&s->gb, 6);
- break;
- case 2:
- sf[0] = get_bits(&s->gb, 6);
- sf[1] = sf[0];
- sf[2] = sf[0];
- break;
- case 1:
- sf[0] = get_bits(&s->gb, 6);
- sf[2] = get_bits(&s->gb, 6);
- sf[1] = sf[0];
- break;
- case 3:
- sf[0] = get_bits(&s->gb, 6);
- sf[2] = get_bits(&s->gb, 6);
- sf[1] = sf[2];
- break;
- }
- }
- }
- }
-
- /* samples */
- for (k = 0; k < 3; k++) {
- for (l = 0; l < 12; l += 3) {
- j = 0;
- for (i = 0; i < bound; i++) {
- bit_alloc_bits = alloc_table[j];
- for (ch = 0; ch < s->nb_channels; ch++) {
- b = bit_alloc[ch][i];
- if (b) {
- scale = scale_factors[ch][i][k];
- qindex = alloc_table[j+b];
- bits = ff_mpa_quant_bits[qindex];
- if (bits < 0) {
- int v2;
- /* 3 values at the same time */
- v = get_bits(&s->gb, -bits);
- v2 = division_tabs[qindex][v];
- steps = ff_mpa_quant_steps[qindex];
-
- s->sb_samples[ch][k * 12 + l + 0][i] =
- l2_unscale_group(steps, v2 & 15, scale);
- s->sb_samples[ch][k * 12 + l + 1][i] =
- l2_unscale_group(steps, (v2 >> 4) & 15, scale);
- s->sb_samples[ch][k * 12 + l + 2][i] =
- l2_unscale_group(steps, v2 >> 8 , scale);
- } else {
- for (m = 0; m < 3; m++) {
- v = get_bits(&s->gb, bits);
- v = l1_unscale(bits - 1, v, scale);
- s->sb_samples[ch][k * 12 + l + m][i] = v;
- }
- }
- } else {
- s->sb_samples[ch][k * 12 + l + 0][i] = 0;
- s->sb_samples[ch][k * 12 + l + 1][i] = 0;
- s->sb_samples[ch][k * 12 + l + 2][i] = 0;
- }
- }
- /* next subband in alloc table */
- j += 1 << bit_alloc_bits;
- }
- /* XXX: find a way to avoid this duplication of code */
- for (i = bound; i < sblimit; i++) {
- bit_alloc_bits = alloc_table[j];
- b = bit_alloc[0][i];
- if (b) {
- int mant, scale0, scale1;
- scale0 = scale_factors[0][i][k];
- scale1 = scale_factors[1][i][k];
- qindex = alloc_table[j+b];
- bits = ff_mpa_quant_bits[qindex];
- if (bits < 0) {
- /* 3 values at the same time */
- v = get_bits(&s->gb, -bits);
- steps = ff_mpa_quant_steps[qindex];
- mant = v % steps;
- v = v / steps;
- s->sb_samples[0][k * 12 + l + 0][i] =
- l2_unscale_group(steps, mant, scale0);
- s->sb_samples[1][k * 12 + l + 0][i] =
- l2_unscale_group(steps, mant, scale1);
- mant = v % steps;
- v = v / steps;
- s->sb_samples[0][k * 12 + l + 1][i] =
- l2_unscale_group(steps, mant, scale0);
- s->sb_samples[1][k * 12 + l + 1][i] =
- l2_unscale_group(steps, mant, scale1);
- s->sb_samples[0][k * 12 + l + 2][i] =
- l2_unscale_group(steps, v, scale0);
- s->sb_samples[1][k * 12 + l + 2][i] =
- l2_unscale_group(steps, v, scale1);
- } else {
- for (m = 0; m < 3; m++) {
- mant = get_bits(&s->gb, bits);
- s->sb_samples[0][k * 12 + l + m][i] =
- l1_unscale(bits - 1, mant, scale0);
- s->sb_samples[1][k * 12 + l + m][i] =
- l1_unscale(bits - 1, mant, scale1);
- }
- }
- } else {
- s->sb_samples[0][k * 12 + l + 0][i] = 0;
- s->sb_samples[0][k * 12 + l + 1][i] = 0;
- s->sb_samples[0][k * 12 + l + 2][i] = 0;
- s->sb_samples[1][k * 12 + l + 0][i] = 0;
- s->sb_samples[1][k * 12 + l + 1][i] = 0;
- s->sb_samples[1][k * 12 + l + 2][i] = 0;
- }
- /* next subband in alloc table */
- j += 1 << bit_alloc_bits;
- }
- /* fill remaining samples to zero */
- for (i = sblimit; i < SBLIMIT; i++) {
- for (ch = 0; ch < s->nb_channels; ch++) {
- s->sb_samples[ch][k * 12 + l + 0][i] = 0;
- s->sb_samples[ch][k * 12 + l + 1][i] = 0;
- s->sb_samples[ch][k * 12 + l + 2][i] = 0;
- }
- }
- }
- }
- return 3 * 12;
-}
-
-#define SPLIT(dst,sf,n) \
- if (n == 3) { \
- int m = (sf * 171) >> 9; \
- dst = sf - 3 * m; \
- sf = m; \
- } else if (n == 4) { \
- dst = sf & 3; \
- sf >>= 2; \
- } else if (n == 5) { \
- int m = (sf * 205) >> 10; \
- dst = sf - 5 * m; \
- sf = m; \
- } else if (n == 6) { \
- int m = (sf * 171) >> 10; \
- dst = sf - 6 * m; \
- sf = m; \
- } else { \
- dst = 0; \
- }
-
-static av_always_inline void lsf_sf_expand(int *slen, int sf, int n1, int n2,
- int n3)
-{
- SPLIT(slen[3], sf, n3)
- SPLIT(slen[2], sf, n2)
- SPLIT(slen[1], sf, n1)
- slen[0] = sf;
-}
-
-static void exponents_from_scale_factors(MPADecodeContext *s, GranuleDef *g,
- int16_t *exponents)
-{
- const uint8_t *bstab, *pretab;
- int len, i, j, k, l, v0, shift, gain, gains[3];
- int16_t *exp_ptr;
-
- exp_ptr = exponents;
- gain = g->global_gain - 210;
- shift = g->scalefac_scale + 1;
-
- bstab = band_size_long[s->sample_rate_index];
- pretab = mpa_pretab[g->preflag];
- for (i = 0; i < g->long_end; i++) {
- v0 = gain - ((g->scale_factors[i] + pretab[i]) << shift) + 400;
- len = bstab[i];
- for (j = len; j > 0; j--)
- *exp_ptr++ = v0;
- }
-
- if (g->short_start < 13) {
- bstab = band_size_short[s->sample_rate_index];
- gains[0] = gain - (g->subblock_gain[0] << 3);
- gains[1] = gain - (g->subblock_gain[1] << 3);
- gains[2] = gain - (g->subblock_gain[2] << 3);
- k = g->long_end;
- for (i = g->short_start; i < 13; i++) {
- len = bstab[i];
- for (l = 0; l < 3; l++) {
- v0 = gains[l] - (g->scale_factors[k++] << shift) + 400;
- for (j = len; j > 0; j--)
- *exp_ptr++ = v0;
- }
- }
- }
-}
-
-/* handle n = 0 too */
-static inline int get_bitsz(GetBitContext *s, int n)
-{
- return n ? get_bits(s, n) : 0;
-}
-
-
-static void switch_buffer(MPADecodeContext *s, int *pos, int *end_pos,
- int *end_pos2)
-{
- if (s->in_gb.buffer && *pos >= s->gb.size_in_bits) {
- s->gb = s->in_gb;
- s->in_gb.buffer = NULL;
- av_assert2((get_bits_count(&s->gb) & 7) == 0);
- skip_bits_long(&s->gb, *pos - *end_pos);
- *end_pos2 =
- *end_pos = *end_pos2 + get_bits_count(&s->gb) - *pos;
- *pos = get_bits_count(&s->gb);
- }
-}
-
-/* Following is a optimized code for
- INTFLOAT v = *src
- if(get_bits1(&s->gb))
- v = -v;
- *dst = v;
-*/
-#if CONFIG_FLOAT
-#define READ_FLIP_SIGN(dst,src) \
- v = AV_RN32A(src) ^ (get_bits1(&s->gb) << 31); \
- AV_WN32A(dst, v);
-#else
-#define READ_FLIP_SIGN(dst,src) \
- v = -get_bits1(&s->gb); \
- *(dst) = (*(src) ^ v) - v;
-#endif
-
-static int huffman_decode(MPADecodeContext *s, GranuleDef *g,
- int16_t *exponents, int end_pos2)
-{
- int s_index;
- int i;
- int last_pos, bits_left;
- VLC *vlc;
- int end_pos = FFMIN(end_pos2, s->gb.size_in_bits);
-
- /* low frequencies (called big values) */
- s_index = 0;
- for (i = 0; i < 3; i++) {
- int j, k, l, linbits;
- j = g->region_size[i];
- if (j == 0)
- continue;
- /* select vlc table */
- k = g->table_select[i];
- l = mpa_huff_data[k][0];
- linbits = mpa_huff_data[k][1];
- vlc = &huff_vlc[l];
-
- if (!l) {
- memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid) * 2 * j);
- s_index += 2 * j;
- continue;
- }
-
- /* read huffcode and compute each couple */
- for (; j > 0; j--) {
- int exponent, x, y;
- int v;
- int pos = get_bits_count(&s->gb);
-
- if (pos >= end_pos){
- switch_buffer(s, &pos, &end_pos, &end_pos2);
- if (pos >= end_pos)
- break;
- }
- y = get_vlc2(&s->gb, vlc->table, 7, 3);
-
- if (!y) {
- g->sb_hybrid[s_index ] =
- g->sb_hybrid[s_index+1] = 0;
- s_index += 2;
- continue;
- }
-
- exponent= exponents[s_index];
-
- av_dlog(s->avctx, "region=%d n=%d x=%d y=%d exp=%d\n",
- i, g->region_size[i] - j, x, y, exponent);
- if (y & 16) {
- x = y >> 5;
- y = y & 0x0f;
- if (x < 15) {
- READ_FLIP_SIGN(g->sb_hybrid + s_index, RENAME(expval_table)[exponent] + x)
- } else {
- x += get_bitsz(&s->gb, linbits);
- v = l3_unscale(x, exponent);
- if (get_bits1(&s->gb))
- v = -v;
- g->sb_hybrid[s_index] = v;
- }
- if (y < 15) {
- READ_FLIP_SIGN(g->sb_hybrid + s_index + 1, RENAME(expval_table)[exponent] + y)
- } else {
- y += get_bitsz(&s->gb, linbits);
- v = l3_unscale(y, exponent);
- if (get_bits1(&s->gb))
- v = -v;
- g->sb_hybrid[s_index+1] = v;
- }
- } else {
- x = y >> 5;
- y = y & 0x0f;
- x += y;
- if (x < 15) {
- READ_FLIP_SIGN(g->sb_hybrid + s_index + !!y, RENAME(expval_table)[exponent] + x)
- } else {
- x += get_bitsz(&s->gb, linbits);
- v = l3_unscale(x, exponent);
- if (get_bits1(&s->gb))
- v = -v;
- g->sb_hybrid[s_index+!!y] = v;
- }
- g->sb_hybrid[s_index + !y] = 0;
- }
- s_index += 2;
- }
- }
-
- /* high frequencies */
- vlc = &huff_quad_vlc[g->count1table_select];
- last_pos = 0;
- while (s_index <= 572) {
- int pos, code;
- pos = get_bits_count(&s->gb);
- if (pos >= end_pos) {
- if (pos > end_pos2 && last_pos) {
- /* some encoders generate an incorrect size for this
- part. We must go back into the data */
- s_index -= 4;
- skip_bits_long(&s->gb, last_pos - pos);
- av_log(s->avctx, AV_LOG_INFO, "overread, skip %d enddists: %d %d\n", last_pos - pos, end_pos-pos, end_pos2-pos);
- if(s->err_recognition & (AV_EF_BITSTREAM|AV_EF_COMPLIANT))
- s_index=0;
- break;
- }
- switch_buffer(s, &pos, &end_pos, &end_pos2);
- if (pos >= end_pos)
- break;
- }
- last_pos = pos;
-
- code = get_vlc2(&s->gb, vlc->table, vlc->bits, 1);
- av_dlog(s->avctx, "t=%d code=%d\n", g->count1table_select, code);
- g->sb_hybrid[s_index+0] =
- g->sb_hybrid[s_index+1] =
- g->sb_hybrid[s_index+2] =
- g->sb_hybrid[s_index+3] = 0;
- while (code) {
- static const int idxtab[16] = { 3,3,2,2,1,1,1,1,0,0,0,0,0,0,0,0 };
- int v;
- int pos = s_index + idxtab[code];
- code ^= 8 >> idxtab[code];
- READ_FLIP_SIGN(g->sb_hybrid + pos, RENAME(exp_table)+exponents[pos])
- }
- s_index += 4;
- }
- /* skip extension bits */
- bits_left = end_pos2 - get_bits_count(&s->gb);
- if (bits_left < 0 && (s->err_recognition & (AV_EF_BUFFER|AV_EF_COMPLIANT))) {
- av_log(s->avctx, AV_LOG_ERROR, "bits_left=%d\n", bits_left);
- s_index=0;
- } else if (bits_left > 0 && (s->err_recognition & (AV_EF_BUFFER|AV_EF_AGGRESSIVE))) {
- av_log(s->avctx, AV_LOG_ERROR, "bits_left=%d\n", bits_left);
- s_index = 0;
- }
- memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid) * (576 - s_index));
- skip_bits_long(&s->gb, bits_left);
-
- i = get_bits_count(&s->gb);
- switch_buffer(s, &i, &end_pos, &end_pos2);
-
- return 0;
-}
-
-/* Reorder short blocks from bitstream order to interleaved order. It
- would be faster to do it in parsing, but the code would be far more
- complicated */
-static void reorder_block(MPADecodeContext *s, GranuleDef *g)
-{
- int i, j, len;
- INTFLOAT *ptr, *dst, *ptr1;
- INTFLOAT tmp[576];
-
- if (g->block_type != 2)
- return;
-
- if (g->switch_point) {
- if (s->sample_rate_index != 8)
- ptr = g->sb_hybrid + 36;
- else
- ptr = g->sb_hybrid + 72;
- } else {
- ptr = g->sb_hybrid;
- }
-
- for (i = g->short_start; i < 13; i++) {
- len = band_size_short[s->sample_rate_index][i];
- ptr1 = ptr;
- dst = tmp;
- for (j = len; j > 0; j--) {
- *dst++ = ptr[0*len];
- *dst++ = ptr[1*len];
- *dst++ = ptr[2*len];
- ptr++;
- }
- ptr += 2 * len;
- memcpy(ptr1, tmp, len * 3 * sizeof(*ptr1));
- }
-}
-
-#define ISQRT2 FIXR(0.70710678118654752440)
-
-static void compute_stereo(MPADecodeContext *s, GranuleDef *g0, GranuleDef *g1)
-{
- int i, j, k, l;
- int sf_max, sf, len, non_zero_found;
- INTFLOAT (*is_tab)[16], *tab0, *tab1, tmp0, tmp1, v1, v2;
- int non_zero_found_short[3];
-
- /* intensity stereo */
- if (s->mode_ext & MODE_EXT_I_STEREO) {
- if (!s->lsf) {
- is_tab = is_table;
- sf_max = 7;
- } else {
- is_tab = is_table_lsf[g1->scalefac_compress & 1];
- sf_max = 16;
- }
-
- tab0 = g0->sb_hybrid + 576;
- tab1 = g1->sb_hybrid + 576;
-
- non_zero_found_short[0] = 0;
- non_zero_found_short[1] = 0;
- non_zero_found_short[2] = 0;
- k = (13 - g1->short_start) * 3 + g1->long_end - 3;
- for (i = 12; i >= g1->short_start; i--) {
- /* for last band, use previous scale factor */
- if (i != 11)
- k -= 3;
- len = band_size_short[s->sample_rate_index][i];
- for (l = 2; l >= 0; l--) {
- tab0 -= len;
- tab1 -= len;
- if (!non_zero_found_short[l]) {
- /* test if non zero band. if so, stop doing i-stereo */
- for (j = 0; j < len; j++) {
- if (tab1[j] != 0) {
- non_zero_found_short[l] = 1;
- goto found1;
- }
- }
- sf = g1->scale_factors[k + l];
- if (sf >= sf_max)
- goto found1;
-
- v1 = is_tab[0][sf];
- v2 = is_tab[1][sf];
- for (j = 0; j < len; j++) {
- tmp0 = tab0[j];
- tab0[j] = MULLx(tmp0, v1, FRAC_BITS);
- tab1[j] = MULLx(tmp0, v2, FRAC_BITS);
- }
- } else {
-found1:
- if (s->mode_ext & MODE_EXT_MS_STEREO) {
- /* lower part of the spectrum : do ms stereo
- if enabled */
- for (j = 0; j < len; j++) {
- tmp0 = tab0[j];
- tmp1 = tab1[j];
- tab0[j] = MULLx(tmp0 + tmp1, ISQRT2, FRAC_BITS);
- tab1[j] = MULLx(tmp0 - tmp1, ISQRT2, FRAC_BITS);
- }
- }
- }
- }
- }
-
- non_zero_found = non_zero_found_short[0] |
- non_zero_found_short[1] |
- non_zero_found_short[2];
-
- for (i = g1->long_end - 1;i >= 0;i--) {
- len = band_size_long[s->sample_rate_index][i];
- tab0 -= len;
- tab1 -= len;
- /* test if non zero band. if so, stop doing i-stereo */
- if (!non_zero_found) {
- for (j = 0; j < len; j++) {
- if (tab1[j] != 0) {
- non_zero_found = 1;
- goto found2;
- }
- }
- /* for last band, use previous scale factor */
- k = (i == 21) ? 20 : i;
- sf = g1->scale_factors[k];
- if (sf >= sf_max)
- goto found2;
- v1 = is_tab[0][sf];
- v2 = is_tab[1][sf];
- for (j = 0; j < len; j++) {
- tmp0 = tab0[j];
- tab0[j] = MULLx(tmp0, v1, FRAC_BITS);
- tab1[j] = MULLx(tmp0, v2, FRAC_BITS);
- }
- } else {
-found2:
- if (s->mode_ext & MODE_EXT_MS_STEREO) {
- /* lower part of the spectrum : do ms stereo
- if enabled */
- for (j = 0; j < len; j++) {
- tmp0 = tab0[j];
- tmp1 = tab1[j];
- tab0[j] = MULLx(tmp0 + tmp1, ISQRT2, FRAC_BITS);
- tab1[j] = MULLx(tmp0 - tmp1, ISQRT2, FRAC_BITS);
- }
- }
- }
- }
- } else if (s->mode_ext & MODE_EXT_MS_STEREO) {
- /* ms stereo ONLY */
- /* NOTE: the 1/sqrt(2) normalization factor is included in the
- global gain */
-#if CONFIG_FLOAT
- s->fdsp.butterflies_float(g0->sb_hybrid, g1->sb_hybrid, 576);
-#else
- tab0 = g0->sb_hybrid;
- tab1 = g1->sb_hybrid;
- for (i = 0; i < 576; i++) {
- tmp0 = tab0[i];
- tmp1 = tab1[i];
- tab0[i] = tmp0 + tmp1;
- tab1[i] = tmp0 - tmp1;
- }
-#endif
- }
-}
-
-#if CONFIG_FLOAT
-#if HAVE_MIPSFPU
-# include "mips/compute_antialias_float.h"
-#endif /* HAVE_MIPSFPU */
-#else
-#if HAVE_MIPSDSPR1
-# include "mips/compute_antialias_fixed.h"
-#endif /* HAVE_MIPSDSPR1 */
-#endif /* CONFIG_FLOAT */
-
-#ifndef compute_antialias
-#if CONFIG_FLOAT
-#define AA(j) do { \
- float tmp0 = ptr[-1-j]; \
- float tmp1 = ptr[ j]; \
- ptr[-1-j] = tmp0 * csa_table[j][0] - tmp1 * csa_table[j][1]; \
- ptr[ j] = tmp0 * csa_table[j][1] + tmp1 * csa_table[j][0]; \
- } while (0)
-#else
-#define AA(j) do { \
- int tmp0 = ptr[-1-j]; \
- int tmp1 = ptr[ j]; \
- int tmp2 = MULH(tmp0 + tmp1, csa_table[j][0]); \
- ptr[-1-j] = 4 * (tmp2 - MULH(tmp1, csa_table[j][2])); \
- ptr[ j] = 4 * (tmp2 + MULH(tmp0, csa_table[j][3])); \
- } while (0)
-#endif
-
-static void compute_antialias(MPADecodeContext *s, GranuleDef *g)
-{
- INTFLOAT *ptr;
- int n, i;
-
- /* we antialias only "long" bands */
- if (g->block_type == 2) {
- if (!g->switch_point)
- return;
- /* XXX: check this for 8000Hz case */
- n = 1;
- } else {
- n = SBLIMIT - 1;
- }
-
- ptr = g->sb_hybrid + 18;
- for (i = n; i > 0; i--) {
- AA(0);
- AA(1);
- AA(2);
- AA(3);
- AA(4);
- AA(5);
- AA(6);
- AA(7);
-
- ptr += 18;
- }
-}
-#endif /* compute_antialias */
-
-static void compute_imdct(MPADecodeContext *s, GranuleDef *g,
- INTFLOAT *sb_samples, INTFLOAT *mdct_buf)
-{
- INTFLOAT *win, *out_ptr, *ptr, *buf, *ptr1;
- INTFLOAT out2[12];
- int i, j, mdct_long_end, sblimit;
-
- /* find last non zero block */
- ptr = g->sb_hybrid + 576;
- ptr1 = g->sb_hybrid + 2 * 18;
- while (ptr >= ptr1) {
- int32_t *p;
- ptr -= 6;
- p = (int32_t*)ptr;
- if (p[0] | p[1] | p[2] | p[3] | p[4] | p[5])
- break;
- }
- sblimit = ((ptr - g->sb_hybrid) / 18) + 1;
-
- if (g->block_type == 2) {
- /* XXX: check for 8000 Hz */
- if (g->switch_point)
- mdct_long_end = 2;
- else
- mdct_long_end = 0;
- } else {
- mdct_long_end = sblimit;
- }
-
- s->mpadsp.RENAME(imdct36_blocks)(sb_samples, mdct_buf, g->sb_hybrid,
- mdct_long_end, g->switch_point,
- g->block_type);
-
- buf = mdct_buf + 4*18*(mdct_long_end >> 2) + (mdct_long_end & 3);
- ptr = g->sb_hybrid + 18 * mdct_long_end;
-
- for (j = mdct_long_end; j < sblimit; j++) {
- /* select frequency inversion */
- win = RENAME(ff_mdct_win)[2 + (4 & -(j & 1))];
- out_ptr = sb_samples + j;
-
- for (i = 0; i < 6; i++) {
- *out_ptr = buf[4*i];
- out_ptr += SBLIMIT;
- }
- imdct12(out2, ptr + 0);
- for (i = 0; i < 6; i++) {
- *out_ptr = MULH3(out2[i ], win[i ], 1) + buf[4*(i + 6*1)];
- buf[4*(i + 6*2)] = MULH3(out2[i + 6], win[i + 6], 1);
- out_ptr += SBLIMIT;
- }
- imdct12(out2, ptr + 1);
- for (i = 0; i < 6; i++) {
- *out_ptr = MULH3(out2[i ], win[i ], 1) + buf[4*(i + 6*2)];
- buf[4*(i + 6*0)] = MULH3(out2[i + 6], win[i + 6], 1);
- out_ptr += SBLIMIT;
- }
- imdct12(out2, ptr + 2);
- for (i = 0; i < 6; i++) {
- buf[4*(i + 6*0)] = MULH3(out2[i ], win[i ], 1) + buf[4*(i + 6*0)];
- buf[4*(i + 6*1)] = MULH3(out2[i + 6], win[i + 6], 1);
- buf[4*(i + 6*2)] = 0;
- }
- ptr += 18;
- buf += (j&3) != 3 ? 1 : (4*18-3);
- }
- /* zero bands */
- for (j = sblimit; j < SBLIMIT; j++) {
- /* overlap */
- out_ptr = sb_samples + j;
- for (i = 0; i < 18; i++) {
- *out_ptr = buf[4*i];
- buf[4*i] = 0;
- out_ptr += SBLIMIT;
- }
- buf += (j&3) != 3 ? 1 : (4*18-3);
- }
-}
-
-/* main layer3 decoding function */
-static int mp_decode_layer3(MPADecodeContext *s)
-{
- int nb_granules, main_data_begin;
- int gr, ch, blocksplit_flag, i, j, k, n, bits_pos;
- GranuleDef *g;
- int16_t exponents[576]; //FIXME try INTFLOAT
-
- /* read side info */
- if (s->lsf) {
- main_data_begin = get_bits(&s->gb, 8);
- skip_bits(&s->gb, s->nb_channels);
- nb_granules = 1;
- } else {
- main_data_begin = get_bits(&s->gb, 9);
- if (s->nb_channels == 2)
- skip_bits(&s->gb, 3);
- else
- skip_bits(&s->gb, 5);
- nb_granules = 2;
- for (ch = 0; ch < s->nb_channels; ch++) {
- s->granules[ch][0].scfsi = 0;/* all scale factors are transmitted */
- s->granules[ch][1].scfsi = get_bits(&s->gb, 4);
- }
- }
-
- for (gr = 0; gr < nb_granules; gr++) {
- for (ch = 0; ch < s->nb_channels; ch++) {
- av_dlog(s->avctx, "gr=%d ch=%d: side_info\n", gr, ch);
- g = &s->granules[ch][gr];
- g->part2_3_length = get_bits(&s->gb, 12);
- g->big_values = get_bits(&s->gb, 9);
- if (g->big_values > 288) {
- av_log(s->avctx, AV_LOG_ERROR, "big_values too big\n");
- return AVERROR_INVALIDDATA;
- }
-
- g->global_gain = get_bits(&s->gb, 8);
- /* if MS stereo only is selected, we precompute the
- 1/sqrt(2) renormalization factor */
- if ((s->mode_ext & (MODE_EXT_MS_STEREO | MODE_EXT_I_STEREO)) ==
- MODE_EXT_MS_STEREO)
- g->global_gain -= 2;
- if (s->lsf)
- g->scalefac_compress = get_bits(&s->gb, 9);
- else
- g->scalefac_compress = get_bits(&s->gb, 4);
- blocksplit_flag = get_bits1(&s->gb);
- if (blocksplit_flag) {
- g->block_type = get_bits(&s->gb, 2);
- if (g->block_type == 0) {
- av_log(s->avctx, AV_LOG_ERROR, "invalid block type\n");
- return AVERROR_INVALIDDATA;
- }
- g->switch_point = get_bits1(&s->gb);
- for (i = 0; i < 2; i++)
- g->table_select[i] = get_bits(&s->gb, 5);
- for (i = 0; i < 3; i++)
- g->subblock_gain[i] = get_bits(&s->gb, 3);
- ff_init_short_region(s, g);
- } else {
- int region_address1, region_address2;
- g->block_type = 0;
- g->switch_point = 0;
- for (i = 0; i < 3; i++)
- g->table_select[i] = get_bits(&s->gb, 5);
- /* compute huffman coded region sizes */
- region_address1 = get_bits(&s->gb, 4);
- region_address2 = get_bits(&s->gb, 3);
- av_dlog(s->avctx, "region1=%d region2=%d\n",
- region_address1, region_address2);
- ff_init_long_region(s, g, region_address1, region_address2);
- }
- ff_region_offset2size(g);
- ff_compute_band_indexes(s, g);
-
- g->preflag = 0;
- if (!s->lsf)
- g->preflag = get_bits1(&s->gb);
- g->scalefac_scale = get_bits1(&s->gb);
- g->count1table_select = get_bits1(&s->gb);
- av_dlog(s->avctx, "block_type=%d switch_point=%d\n",
- g->block_type, g->switch_point);
- }
- }
-
- if (!s->adu_mode) {
- int skip;
- const uint8_t *ptr = s->gb.buffer + (get_bits_count(&s->gb)>>3);
- int extrasize = av_clip(get_bits_left(&s->gb) >> 3, 0, EXTRABYTES);
- av_assert1((get_bits_count(&s->gb) & 7) == 0);
- /* now we get bits from the main_data_begin offset */
- av_dlog(s->avctx, "seekback:%d, lastbuf:%d\n",
- main_data_begin, s->last_buf_size);
-
- memcpy(s->last_buf + s->last_buf_size, ptr, extrasize);
- s->in_gb = s->gb;
- init_get_bits(&s->gb, s->last_buf, s->last_buf_size*8);
-#if !UNCHECKED_BITSTREAM_READER
- s->gb.size_in_bits_plus8 += FFMAX(extrasize, LAST_BUF_SIZE - s->last_buf_size) * 8;
-#endif
- s->last_buf_size <<= 3;
- for (gr = 0; gr < nb_granules && (s->last_buf_size >> 3) < main_data_begin; gr++) {
- for (ch = 0; ch < s->nb_channels; ch++) {
- g = &s->granules[ch][gr];
- s->last_buf_size += g->part2_3_length;
- memset(g->sb_hybrid, 0, sizeof(g->sb_hybrid));
- compute_imdct(s, g, &s->sb_samples[ch][18 * gr][0], s->mdct_buf[ch]);
- }
- }
- skip = s->last_buf_size - 8 * main_data_begin;
- if (skip >= s->gb.size_in_bits && s->in_gb.buffer) {
- skip_bits_long(&s->in_gb, skip - s->gb.size_in_bits);
- s->gb = s->in_gb;
- s->in_gb.buffer = NULL;
- } else {
- skip_bits_long(&s->gb, skip);
- }
- } else {
- gr = 0;
- }
-
- for (; gr < nb_granules; gr++) {
- for (ch = 0; ch < s->nb_channels; ch++) {
- g = &s->granules[ch][gr];
- bits_pos = get_bits_count(&s->gb);
-
- if (!s->lsf) {
- uint8_t *sc;
- int slen, slen1, slen2;
-
- /* MPEG1 scale factors */
- slen1 = slen_table[0][g->scalefac_compress];
- slen2 = slen_table[1][g->scalefac_compress];
- av_dlog(s->avctx, "slen1=%d slen2=%d\n", slen1, slen2);
- if (g->block_type == 2) {
- n = g->switch_point ? 17 : 18;
- j = 0;
- if (slen1) {
- for (i = 0; i < n; i++)
- g->scale_factors[j++] = get_bits(&s->gb, slen1);
- } else {
- for (i = 0; i < n; i++)
- g->scale_factors[j++] = 0;
- }
- if (slen2) {
- for (i = 0; i < 18; i++)
- g->scale_factors[j++] = get_bits(&s->gb, slen2);
- for (i = 0; i < 3; i++)
- g->scale_factors[j++] = 0;
- } else {
- for (i = 0; i < 21; i++)
- g->scale_factors[j++] = 0;
- }
- } else {
- sc = s->granules[ch][0].scale_factors;
- j = 0;
- for (k = 0; k < 4; k++) {
- n = k == 0 ? 6 : 5;
- if ((g->scfsi & (0x8 >> k)) == 0) {
- slen = (k < 2) ? slen1 : slen2;
- if (slen) {
- for (i = 0; i < n; i++)
- g->scale_factors[j++] = get_bits(&s->gb, slen);
- } else {
- for (i = 0; i < n; i++)
- g->scale_factors[j++] = 0;
- }
- } else {
- /* simply copy from last granule */
- for (i = 0; i < n; i++) {
- g->scale_factors[j] = sc[j];
- j++;
- }
- }
- }
- g->scale_factors[j++] = 0;
- }
- } else {
- int tindex, tindex2, slen[4], sl, sf;
-
- /* LSF scale factors */
- if (g->block_type == 2)
- tindex = g->switch_point ? 2 : 1;
- else
- tindex = 0;
-
- sf = g->scalefac_compress;
- if ((s->mode_ext & MODE_EXT_I_STEREO) && ch == 1) {
- /* intensity stereo case */
- sf >>= 1;
- if (sf < 180) {
- lsf_sf_expand(slen, sf, 6, 6, 0);
- tindex2 = 3;
- } else if (sf < 244) {
- lsf_sf_expand(slen, sf - 180, 4, 4, 0);
- tindex2 = 4;
- } else {
- lsf_sf_expand(slen, sf - 244, 3, 0, 0);
- tindex2 = 5;
- }
- } else {
- /* normal case */
- if (sf < 400) {
- lsf_sf_expand(slen, sf, 5, 4, 4);
- tindex2 = 0;
- } else if (sf < 500) {
- lsf_sf_expand(slen, sf - 400, 5, 4, 0);
- tindex2 = 1;
- } else {
- lsf_sf_expand(slen, sf - 500, 3, 0, 0);
- tindex2 = 2;
- g->preflag = 1;
- }
- }
-
- j = 0;
- for (k = 0; k < 4; k++) {
- n = lsf_nsf_table[tindex2][tindex][k];
- sl = slen[k];
- if (sl) {
- for (i = 0; i < n; i++)
- g->scale_factors[j++] = get_bits(&s->gb, sl);
- } else {
- for (i = 0; i < n; i++)
- g->scale_factors[j++] = 0;
- }
- }
- /* XXX: should compute exact size */
- for (; j < 40; j++)
- g->scale_factors[j] = 0;
- }
-
- exponents_from_scale_factors(s, g, exponents);
-
- /* read Huffman coded residue */
- huffman_decode(s, g, exponents, bits_pos + g->part2_3_length);
- } /* ch */
-
- if (s->mode == MPA_JSTEREO)
- compute_stereo(s, &s->granules[0][gr], &s->granules[1][gr]);
-
- for (ch = 0; ch < s->nb_channels; ch++) {
- g = &s->granules[ch][gr];
-
- reorder_block(s, g);
- compute_antialias(s, g);
- compute_imdct(s, g, &s->sb_samples[ch][18 * gr][0], s->mdct_buf[ch]);
- }
- } /* gr */
- if (get_bits_count(&s->gb) < 0)
- skip_bits_long(&s->gb, -get_bits_count(&s->gb));
- return nb_granules * 18;
-}
-
-static int mp_decode_frame(MPADecodeContext *s, OUT_INT **samples,
- const uint8_t *buf, int buf_size)
-{
- int i, nb_frames, ch, ret;
- OUT_INT *samples_ptr;
-
- init_get_bits(&s->gb, buf + HEADER_SIZE, (buf_size - HEADER_SIZE) * 8);
-
- /* skip error protection field */
- if (s->error_protection)
- skip_bits(&s->gb, 16);
-
- switch(s->layer) {
- case 1:
- s->avctx->frame_size = 384;
- nb_frames = mp_decode_layer1(s);
- break;
- case 2:
- s->avctx->frame_size = 1152;
- nb_frames = mp_decode_layer2(s);
- break;
- case 3:
- s->avctx->frame_size = s->lsf ? 576 : 1152;
- default:
- nb_frames = mp_decode_layer3(s);
-
- s->last_buf_size=0;
- if (s->in_gb.buffer) {
- align_get_bits(&s->gb);
- i = get_bits_left(&s->gb)>>3;
- if (i >= 0 && i <= BACKSTEP_SIZE) {
- memmove(s->last_buf, s->gb.buffer + (get_bits_count(&s->gb)>>3), i);
- s->last_buf_size=i;
- } else
- av_log(s->avctx, AV_LOG_ERROR, "invalid old backstep %d\n", i);
- s->gb = s->in_gb;
- s->in_gb.buffer = NULL;
- }
-
- align_get_bits(&s->gb);
- av_assert1((get_bits_count(&s->gb) & 7) == 0);
- i = get_bits_left(&s->gb) >> 3;
-
- if (i < 0 || i > BACKSTEP_SIZE || nb_frames < 0) {
- if (i < 0)
- av_log(s->avctx, AV_LOG_ERROR, "invalid new backstep %d\n", i);
- i = FFMIN(BACKSTEP_SIZE, buf_size - HEADER_SIZE);
- }
- av_assert1(i <= buf_size - HEADER_SIZE && i >= 0);
- memcpy(s->last_buf + s->last_buf_size, s->gb.buffer + buf_size - HEADER_SIZE - i, i);
- s->last_buf_size += i;
- }
-
- if(nb_frames < 0)
- return nb_frames;
-
- /* get output buffer */
- if (!samples) {
- av_assert0(s->frame != NULL);
- s->frame->nb_samples = s->avctx->frame_size;
- if ((ret = ff_get_buffer(s->avctx, s->frame)) < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return ret;
- }
- samples = (OUT_INT **)s->frame->extended_data;
- }
-
- /* apply the synthesis filter */
- for (ch = 0; ch < s->nb_channels; ch++) {
- int sample_stride;
- if (s->avctx->sample_fmt == OUT_FMT_P) {
- samples_ptr = samples[ch];
- sample_stride = 1;
- } else {
- samples_ptr = samples[0] + ch;
- sample_stride = s->nb_channels;
- }
- for (i = 0; i < nb_frames; i++) {
- RENAME(ff_mpa_synth_filter)(&s->mpadsp, s->synth_buf[ch],
- &(s->synth_buf_offset[ch]),
- RENAME(ff_mpa_synth_window),
- &s->dither_state, samples_ptr,
- sample_stride, s->sb_samples[ch][i]);
- samples_ptr += 32 * sample_stride;
- }
- }
-
- return nb_frames * 32 * sizeof(OUT_INT) * s->nb_channels;
-}
-
-static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame_ptr,
- AVPacket *avpkt)
-{
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
- MPADecodeContext *s = avctx->priv_data;
- uint32_t header;
- int ret;
-
- while(buf_size && !*buf){
- buf++;
- buf_size--;
- }
-
- if (buf_size < HEADER_SIZE)
- return AVERROR_INVALIDDATA;
-
- header = AV_RB32(buf);
- if (header>>8 == AV_RB32("TAG")>>8) {
- av_log(avctx, AV_LOG_DEBUG, "discarding ID3 tag\n");
- return buf_size;
- }
- if (ff_mpa_check_header(header) < 0) {
- av_log(avctx, AV_LOG_ERROR, "Header missing\n");
- return AVERROR_INVALIDDATA;
- }
-
- if (avpriv_mpegaudio_decode_header((MPADecodeHeader *)s, header) == 1) {
- /* free format: prepare to compute frame size */
- s->frame_size = -1;
- return AVERROR_INVALIDDATA;
- }
- /* update codec info */
- 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;
-
- if (s->frame_size <= 0 || s->frame_size > buf_size) {
- av_log(avctx, AV_LOG_ERROR, "incomplete frame\n");
- return AVERROR_INVALIDDATA;
- } else if (s->frame_size < buf_size) {
- av_log(avctx, AV_LOG_DEBUG, "incorrect frame size - multiple frames in buffer?\n");
- buf_size= s->frame_size;
- }
-
- s->frame = data;
-
- ret = mp_decode_frame(s, NULL, buf, buf_size);
- if (ret >= 0) {
- s->frame->nb_samples = avctx->frame_size;
- *got_frame_ptr = 1;
- avctx->sample_rate = s->sample_rate;
- //FIXME maybe move the other codec info stuff from above here too
- } else {
- av_log(avctx, AV_LOG_ERROR, "Error while decoding MPEG audio frame.\n");
- /* Only return an error if the bad frame makes up the whole packet or
- * the error is related to buffer management.
- * If there is more data in the packet, just consume the bad frame
- * instead of returning an error, which would discard the whole
- * packet. */
- *got_frame_ptr = 0;
- if (buf_size == avpkt->size || ret != AVERROR_INVALIDDATA)
- return ret;
- }
- s->frame_size = 0;
- return buf_size;
-}
-
-static void mp_flush(MPADecodeContext *ctx)
-{
- memset(ctx->synth_buf, 0, sizeof(ctx->synth_buf));
- ctx->last_buf_size = 0;
-}
-
-static void flush(AVCodecContext *avctx)
-{
- mp_flush(avctx->priv_data);
-}
-
-#if CONFIG_MP3ADU_DECODER || CONFIG_MP3ADUFLOAT_DECODER
-static int decode_frame_adu(AVCodecContext *avctx, void *data,
- int *got_frame_ptr, AVPacket *avpkt)
-{
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
- MPADecodeContext *s = avctx->priv_data;
- uint32_t header;
- int len, ret;
- int av_unused out_size;
-
- len = buf_size;
-
- // Discard too short frames
- if (buf_size < HEADER_SIZE) {
- av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
- return AVERROR_INVALIDDATA;
- }
-
-
- if (len > MPA_MAX_CODED_FRAME_SIZE)
- len = MPA_MAX_CODED_FRAME_SIZE;
-
- // Get header and restore sync word
- header = AV_RB32(buf) | 0xffe00000;
-
- if (ff_mpa_check_header(header) < 0) { // Bad header, discard frame
- av_log(avctx, AV_LOG_ERROR, "Invalid frame header\n");
- return AVERROR_INVALIDDATA;
- }
-
- avpriv_mpegaudio_decode_header((MPADecodeHeader *)s, header);
- /* update codec info */
- avctx->sample_rate = s->sample_rate;
- avctx->channels = s->nb_channels;
- if (!avctx->bit_rate)
- avctx->bit_rate = s->bit_rate;
-
- s->frame_size = len;
-
- s->frame = data;
-
- ret = mp_decode_frame(s, NULL, buf, buf_size);
- if (ret < 0) {
- av_log(avctx, AV_LOG_ERROR, "Error while decoding MPEG audio frame.\n");
- return ret;
- }
-
- *got_frame_ptr = 1;
-
- return buf_size;
-}
-#endif /* CONFIG_MP3ADU_DECODER || CONFIG_MP3ADUFLOAT_DECODER */
-
-#if CONFIG_MP3ON4_DECODER || CONFIG_MP3ON4FLOAT_DECODER
-
-/**
- * Context for MP3On4 decoder
- */
-typedef struct MP3On4DecodeContext {
- int frames; ///< number of mp3 frames per block (number of mp3 decoder instances)
- int syncword; ///< syncword patch
- const uint8_t *coff; ///< channel offsets in output buffer
- MPADecodeContext *mp3decctx[5]; ///< MPADecodeContext for every decoder instance
-} MP3On4DecodeContext;
-
-#include "mpeg4audio.h"
-
-/* Next 3 arrays are indexed by channel config number (passed via codecdata) */
-
-/* number of mp3 decoder instances */
-static const uint8_t mp3Frames[8] = { 0, 1, 1, 2, 3, 3, 4, 5 };
-
-/* offsets into output buffer, assume output order is FL FR C LFE BL BR SL SR */
-static const uint8_t chan_offset[8][5] = {
- { 0 },
- { 0 }, // C
- { 0 }, // FLR
- { 2, 0 }, // C FLR
- { 2, 0, 3 }, // C FLR BS
- { 2, 0, 3 }, // C FLR BLRS
- { 2, 0, 4, 3 }, // C FLR BLRS LFE
- { 2, 0, 6, 4, 3 }, // C FLR BLRS BLR LFE
-};
-
-/* mp3on4 channel layouts */
-static const int16_t chan_layout[8] = {
- 0,
- AV_CH_LAYOUT_MONO,
- AV_CH_LAYOUT_STEREO,
- AV_CH_LAYOUT_SURROUND,
- AV_CH_LAYOUT_4POINT0,
- AV_CH_LAYOUT_5POINT0,
- AV_CH_LAYOUT_5POINT1,
- AV_CH_LAYOUT_7POINT1
-};
-
-static av_cold int decode_close_mp3on4(AVCodecContext * avctx)
-{
- MP3On4DecodeContext *s = avctx->priv_data;
- int i;
-
- for (i = 0; i < s->frames; i++)
- av_free(s->mp3decctx[i]);
-
- return 0;
-}
-
-
-static int decode_init_mp3on4(AVCodecContext * avctx)
-{
- MP3On4DecodeContext *s = avctx->priv_data;
- MPEG4AudioConfig cfg;
- int i;
-
- if ((avctx->extradata_size < 2) || (avctx->extradata == NULL)) {
- av_log(avctx, AV_LOG_ERROR, "Codec extradata missing or too short.\n");
- return AVERROR_INVALIDDATA;
- }
-
- avpriv_mpeg4audio_get_config(&cfg, avctx->extradata,
- avctx->extradata_size * 8, 1);
- if (!cfg.chan_config || cfg.chan_config > 7) {
- av_log(avctx, AV_LOG_ERROR, "Invalid channel config number.\n");
- return AVERROR_INVALIDDATA;
- }
- s->frames = mp3Frames[cfg.chan_config];
- s->coff = chan_offset[cfg.chan_config];
- avctx->channels = ff_mpeg4audio_channels[cfg.chan_config];
- avctx->channel_layout = chan_layout[cfg.chan_config];
-
- if (cfg.sample_rate < 16000)
- s->syncword = 0xffe00000;
- else
- s->syncword = 0xfff00000;
-
- /* Init the first mp3 decoder in standard way, so that all tables get builded
- * We replace avctx->priv_data with the context of the first decoder so that
- * decode_init() does not have to be changed.
- * Other decoders will be initialized here copying data from the first context
- */
- // Allocate zeroed memory for the first decoder context
- s->mp3decctx[0] = av_mallocz(sizeof(MPADecodeContext));
- if (!s->mp3decctx[0])
- goto alloc_fail;
- // Put decoder context in place to make init_decode() happy
- avctx->priv_data = s->mp3decctx[0];
- decode_init(avctx);
- // Restore mp3on4 context pointer
- avctx->priv_data = s;
- s->mp3decctx[0]->adu_mode = 1; // Set adu mode
-
- /* Create a separate codec/context for each frame (first is already ok).
- * Each frame is 1 or 2 channels - up to 5 frames allowed
- */
- for (i = 1; i < s->frames; i++) {
- s->mp3decctx[i] = av_mallocz(sizeof(MPADecodeContext));
- if (!s->mp3decctx[i])
- goto alloc_fail;
- s->mp3decctx[i]->adu_mode = 1;
- s->mp3decctx[i]->avctx = avctx;
- s->mp3decctx[i]->mpadsp = s->mp3decctx[0]->mpadsp;
- }
-
- return 0;
-alloc_fail:
- decode_close_mp3on4(avctx);
- return AVERROR(ENOMEM);
-}
-
-
-static void flush_mp3on4(AVCodecContext *avctx)
-{
- int i;
- MP3On4DecodeContext *s = avctx->priv_data;
-
- for (i = 0; i < s->frames; i++)
- mp_flush(s->mp3decctx[i]);
-}
-
-
-static int decode_frame_mp3on4(AVCodecContext *avctx, void *data,
- int *got_frame_ptr, AVPacket *avpkt)
-{
- AVFrame *frame = data;
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
- MP3On4DecodeContext *s = avctx->priv_data;
- MPADecodeContext *m;
- int fsize, len = buf_size, out_size = 0;
- uint32_t header;
- OUT_INT **out_samples;
- OUT_INT *outptr[2];
- int fr, ch, ret;
-
- /* get output buffer */
- frame->nb_samples = MPA_FRAME_SIZE;
- if ((ret = ff_get_buffer(avctx, frame)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return ret;
- }
- out_samples = (OUT_INT **)frame->extended_data;
-
- // Discard too short frames
- if (buf_size < HEADER_SIZE)
- return AVERROR_INVALIDDATA;
-
- avctx->bit_rate = 0;
-
- ch = 0;
- for (fr = 0; fr < s->frames; fr++) {
- fsize = AV_RB16(buf) >> 4;
- fsize = FFMIN3(fsize, len, MPA_MAX_CODED_FRAME_SIZE);
- m = s->mp3decctx[fr];
- av_assert1(m);
-
- if (fsize < HEADER_SIZE) {
- av_log(avctx, AV_LOG_ERROR, "Frame size smaller than header size\n");
- return AVERROR_INVALIDDATA;
- }
- header = (AV_RB32(buf) & 0x000fffff) | s->syncword; // patch header
-
- if (ff_mpa_check_header(header) < 0) // Bad header, discard block
- break;
-
- avpriv_mpegaudio_decode_header((MPADecodeHeader *)m, header);
-
- if (ch + m->nb_channels > avctx->channels || s->coff[fr] + m->nb_channels > avctx->channels) {
- av_log(avctx, AV_LOG_ERROR, "frame channel count exceeds codec "
- "channel count\n");
- return AVERROR_INVALIDDATA;
- }
- ch += m->nb_channels;
-
- outptr[0] = out_samples[s->coff[fr]];
- 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;
-
- out_size += ret;
- buf += fsize;
- len -= fsize;
-
- avctx->bit_rate += m->bit_rate;
- }
-
- /* update codec info */
- avctx->sample_rate = s->mp3decctx[0]->sample_rate;
-
- frame->nb_samples = out_size / (avctx->channels * sizeof(OUT_INT));
- *got_frame_ptr = 1;
-
- return buf_size;
-}
-#endif /* CONFIG_MP3ON4_DECODER || CONFIG_MP3ON4FLOAT_DECODER */
-
-#if !CONFIG_FLOAT
-#if CONFIG_MP1_DECODER
-AVCodec ff_mp1_decoder = {
- .name = "mp1",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_MP1,
- .priv_data_size = sizeof(MPADecodeContext),
- .init = decode_init,
- .decode = decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .flush = flush,
- .long_name = NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"),
- .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
- AV_SAMPLE_FMT_S16,
- AV_SAMPLE_FMT_NONE },
-};
-#endif
-#if CONFIG_MP2_DECODER
-AVCodec ff_mp2_decoder = {
- .name = "mp2",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_MP2,
- .priv_data_size = sizeof(MPADecodeContext),
- .init = decode_init,
- .decode = decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .flush = flush,
- .long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"),
- .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
- AV_SAMPLE_FMT_S16,
- AV_SAMPLE_FMT_NONE },
-};
-#endif
-#if CONFIG_MP3_DECODER
-AVCodec ff_mp3_decoder = {
- .name = "mp3",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_MP3,
- .priv_data_size = sizeof(MPADecodeContext),
- .init = decode_init,
- .decode = decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .flush = flush,
- .long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"),
- .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
- AV_SAMPLE_FMT_S16,
- AV_SAMPLE_FMT_NONE },
-};
-#endif
-#if CONFIG_MP3ADU_DECODER
-AVCodec ff_mp3adu_decoder = {
- .name = "mp3adu",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_MP3ADU,
- .priv_data_size = sizeof(MPADecodeContext),
- .init = decode_init,
- .decode = decode_frame_adu,
- .capabilities = CODEC_CAP_DR1,
- .flush = flush,
- .long_name = NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"),
- .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
- AV_SAMPLE_FMT_S16,
- AV_SAMPLE_FMT_NONE },
-};
-#endif
-#if CONFIG_MP3ON4_DECODER
-AVCodec ff_mp3on4_decoder = {
- .name = "mp3on4",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_MP3ON4,
- .priv_data_size = sizeof(MP3On4DecodeContext),
- .init = decode_init_mp3on4,
- .close = decode_close_mp3on4,
- .decode = decode_frame_mp3on4,
- .capabilities = CODEC_CAP_DR1,
- .flush = flush_mp3on4,
- .long_name = NULL_IF_CONFIG_SMALL("MP3onMP4"),
- .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
- AV_SAMPLE_FMT_NONE },
-};
-#endif
-#endif
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpegaudiodec_float.c b/src/thirdparty/ffmpeg/libavcodec/mpegaudiodec_float.c
deleted file mode 100644
index f60ab1c99..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpegaudiodec_float.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Float MPEG Audio decoder
- * Copyright (c) 2010 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
- */
-
-#define CONFIG_FLOAT 1
-#include "mpegaudiodec.c"
-
-#if CONFIG_MP1FLOAT_DECODER
-AVCodec ff_mp1float_decoder = {
- .name = "mp1float",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_MP1,
- .priv_data_size = sizeof(MPADecodeContext),
- .init = decode_init,
- .decode = decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .flush = flush,
- .long_name = NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"),
- .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
- AV_SAMPLE_FMT_FLT,
- AV_SAMPLE_FMT_NONE },
-};
-#endif
-#if CONFIG_MP2FLOAT_DECODER
-AVCodec ff_mp2float_decoder = {
- .name = "mp2float",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_MP2,
- .priv_data_size = sizeof(MPADecodeContext),
- .init = decode_init,
- .decode = decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .flush = flush,
- .long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"),
- .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
- AV_SAMPLE_FMT_FLT,
- AV_SAMPLE_FMT_NONE },
-};
-#endif
-#if CONFIG_MP3FLOAT_DECODER
-AVCodec ff_mp3float_decoder = {
- .name = "mp3float",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_MP3,
- .priv_data_size = sizeof(MPADecodeContext),
- .init = decode_init,
- .decode = decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .flush = flush,
- .long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"),
- .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
- AV_SAMPLE_FMT_FLT,
- AV_SAMPLE_FMT_NONE },
-};
-#endif
-#if CONFIG_MP3ADUFLOAT_DECODER
-AVCodec ff_mp3adufloat_decoder = {
- .name = "mp3adufloat",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_MP3ADU,
- .priv_data_size = sizeof(MPADecodeContext),
- .init = decode_init,
- .decode = decode_frame_adu,
- .capabilities = CODEC_CAP_DR1,
- .flush = flush,
- .long_name = NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"),
- .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
- AV_SAMPLE_FMT_FLT,
- AV_SAMPLE_FMT_NONE },
-};
-#endif
-#if CONFIG_MP3ON4FLOAT_DECODER
-AVCodec ff_mp3on4float_decoder = {
- .name = "mp3on4float",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_MP3ON4,
- .priv_data_size = sizeof(MP3On4DecodeContext),
- .init = decode_init_mp3on4,
- .close = decode_close_mp3on4,
- .decode = decode_frame_mp3on4,
- .capabilities = CODEC_CAP_DR1,
- .flush = flush_mp3on4,
- .long_name = NULL_IF_CONFIG_SMALL("MP3onMP4"),
- .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
- AV_SAMPLE_FMT_NONE },
-};
-#endif
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpegaudiodecheader.c b/src/thirdparty/ffmpeg/libavcodec/mpegaudiodecheader.c
deleted file mode 100644
index 0def5d4b8..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpegaudiodecheader.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * MPEG Audio header decoder
- * Copyright (c) 2001, 2002 Fabrice Bellard
- *
- * 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
- * MPEG Audio header decoder.
- */
-
-//#define DEBUG
-#include "avcodec.h"
-#include "mpegaudio.h"
-#include "mpegaudiodata.h"
-#include "mpegaudiodecheader.h"
-
-
-int avpriv_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header)
-{
- int sample_rate, frame_size, mpeg25, padding;
- int sample_rate_index, bitrate_index;
- if (header & (1<<20)) {
- s->lsf = (header & (1<<19)) ? 0 : 1;
- mpeg25 = 0;
- } else {
- s->lsf = 1;
- mpeg25 = 1;
- }
-
- s->layer = 4 - ((header >> 17) & 3);
- /* extract frequency */
- sample_rate_index = (header >> 10) & 3;
- sample_rate = avpriv_mpa_freq_tab[sample_rate_index] >> (s->lsf + mpeg25);
- sample_rate_index += 3 * (s->lsf + mpeg25);
- s->sample_rate_index = sample_rate_index;
- s->error_protection = ((header >> 16) & 1) ^ 1;
- s->sample_rate = sample_rate;
-
- bitrate_index = (header >> 12) & 0xf;
- padding = (header >> 9) & 1;
- //extension = (header >> 8) & 1;
- s->mode = (header >> 6) & 3;
- s->mode_ext = (header >> 4) & 3;
- //copyright = (header >> 3) & 1;
- //original = (header >> 2) & 1;
- //emphasis = header & 3;
-
- if (s->mode == MPA_MONO)
- s->nb_channels = 1;
- else
- s->nb_channels = 2;
-
- if (bitrate_index != 0) {
- frame_size = avpriv_mpa_bitrate_tab[s->lsf][s->layer - 1][bitrate_index];
- s->bit_rate = frame_size * 1000;
- switch(s->layer) {
- case 1:
- frame_size = (frame_size * 12000) / sample_rate;
- frame_size = (frame_size + padding) * 4;
- break;
- case 2:
- frame_size = (frame_size * 144000) / sample_rate;
- frame_size += padding;
- break;
- default:
- case 3:
- frame_size = (frame_size * 144000) / (sample_rate << s->lsf);
- frame_size += padding;
- break;
- }
- s->frame_size = frame_size;
- } else {
- /* if no frame size computed, signal it */
- return 1;
- }
-
-#if defined(DEBUG)
- av_dlog(NULL, "layer%d, %d Hz, %d kbits/s, ",
- s->layer, s->sample_rate, s->bit_rate);
- if (s->nb_channels == 2) {
- if (s->layer == 3) {
- if (s->mode_ext & MODE_EXT_MS_STEREO)
- av_dlog(NULL, "ms-");
- if (s->mode_ext & MODE_EXT_I_STEREO)
- av_dlog(NULL, "i-");
- }
- av_dlog(NULL, "stereo");
- } else {
- av_dlog(NULL, "mono");
- }
- av_dlog(NULL, "\n");
-#endif
- return 0;
-}
-
-int avpriv_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bit_rate)
-{
- MPADecodeHeader s1, *s = &s1;
-
- if (ff_mpa_check_header(head) != 0)
- return -1;
-
- if (avpriv_mpegaudio_decode_header(s, head) != 0) {
- return -1;
- }
-
- switch(s->layer) {
- case 1:
- avctx->codec_id = AV_CODEC_ID_MP1;
- *frame_size = 384;
- break;
- case 2:
- avctx->codec_id = AV_CODEC_ID_MP2;
- *frame_size = 1152;
- break;
- default:
- case 3:
- avctx->codec_id = AV_CODEC_ID_MP3;
- if (s->lsf)
- *frame_size = 576;
- else
- *frame_size = 1152;
- break;
- }
-
- *sample_rate = s->sample_rate;
- *channels = s->nb_channels;
- *bit_rate = s->bit_rate;
- return s->frame_size;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpegaudiodecheader.h b/src/thirdparty/ffmpeg/libavcodec/mpegaudiodecheader.h
deleted file mode 100644
index 0f8ed5372..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpegaudiodecheader.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * MPEG Audio header decoder
- * Copyright (c) 2001, 2002 Fabrice Bellard
- *
- * 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
- * MPEG Audio header decoder.
- */
-
-#ifndef AVCODEC_MPEGAUDIODECHEADER_H
-#define AVCODEC_MPEGAUDIODECHEADER_H
-
-#include "avcodec.h"
-
-#define MP3_MASK 0xFFFE0CCF
-
-#define MPA_DECODE_HEADER \
- int frame_size; \
- int error_protection; \
- int layer; \
- int sample_rate; \
- int sample_rate_index; /* between 0 and 8 */ \
- int bit_rate; \
- int nb_channels; \
- int mode; \
- int mode_ext; \
- int lsf;
-
-typedef struct MPADecodeHeader {
- MPA_DECODE_HEADER
-} MPADecodeHeader;
-
-/* header decoding. MUST check the header before because no
- consistency check is done there. Return 1 if free format found and
- that the frame size must be computed externally */
-int avpriv_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header);
-
-/* useful helper to get mpeg audio stream infos. Return -1 if error in
- 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);
-
-/* fast header check for resync */
-static inline int ff_mpa_check_header(uint32_t header){
- /* header */
- if ((header & 0xffe00000) != 0xffe00000)
- return -1;
- /* layer check */
- if ((header & (3<<17)) == 0)
- return -1;
- /* bit rate */
- if ((header & (0xf<<12)) == 0xf<<12)
- return -1;
- /* frequency */
- if ((header & (3<<10)) == 3<<10)
- return -1;
- return 0;
-}
-
-#endif /* AVCODEC_MPEGAUDIODECHEADER_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpegaudiodectab.h b/src/thirdparty/ffmpeg/libavcodec/mpegaudiodectab.h
deleted file mode 100644
index 668edf94a..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpegaudiodectab.h
+++ /dev/null
@@ -1,615 +0,0 @@
-/*
- * MPEG Audio decoder
- * copyright (c) 2002 Fabrice Bellard
- *
- * 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
- * mpeg audio layer decoder tables.
- */
-
-#ifndef AVCODEC_MPEGAUDIODECTAB_H
-#define AVCODEC_MPEGAUDIODECTAB_H
-
-#include <stddef.h>
-#include <stdint.h>
-
-#include "mpegaudio.h"
-
-/*******************************************************/
-/* layer 3 tables */
-
-/* layer 3 huffman tables */
-typedef struct HuffTable {
- int xsize;
- const uint8_t *bits;
- const uint16_t *codes;
-} HuffTable;
-
-/* layer3 scale factor size */
-static const uint8_t slen_table[2][16] = {
- { 0, 0, 0, 0, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4 },
- { 0, 1, 2, 3, 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 3 },
-};
-
-/* number of lsf scale factors for a given size */
-static const uint8_t lsf_nsf_table[6][3][4] = {
- { { 6, 5, 5, 5 }, { 9, 9, 9, 9 }, { 6, 9, 9, 9 } },
- { { 6, 5, 7, 3 }, { 9, 9, 12, 6 }, { 6, 9, 12, 6 } },
- { { 11, 10, 0, 0 }, { 18, 18, 0, 0 }, { 15, 18, 0, 0 } },
- { { 7, 7, 7, 0 }, { 12, 12, 12, 0 }, { 6, 15, 12, 0 } },
- { { 6, 6, 6, 3 }, { 12, 9, 9, 6 }, { 6, 12, 9, 6 } },
- { { 8, 8, 5, 0 }, { 15, 12, 9, 0 }, { 6, 18, 9, 0 } },
-};
-
-/* mpegaudio layer 3 huffman tables */
-
-static const uint16_t mpa_huffcodes_1[4] = {
- 0x0001, 0x0001, 0x0001, 0x0000,
-};
-
-static const uint8_t mpa_huffbits_1[4] = {
- 1, 3, 2, 3,
-};
-
-static const uint16_t mpa_huffcodes_2[9] = {
- 0x0001, 0x0002, 0x0001, 0x0003, 0x0001, 0x0001, 0x0003, 0x0002,
- 0x0000,
-};
-
-static const uint8_t mpa_huffbits_2[9] = {
- 1, 3, 6, 3, 3, 5, 5, 5,
- 6,
-};
-
-static const uint16_t mpa_huffcodes_3[9] = {
- 0x0003, 0x0002, 0x0001, 0x0001, 0x0001, 0x0001, 0x0003, 0x0002,
- 0x0000,
-};
-
-static const uint8_t mpa_huffbits_3[9] = {
- 2, 2, 6, 3, 2, 5, 5, 5,
- 6,
-};
-
-static const uint16_t mpa_huffcodes_5[16] = {
- 0x0001, 0x0002, 0x0006, 0x0005, 0x0003, 0x0001, 0x0004, 0x0004,
- 0x0007, 0x0005, 0x0007, 0x0001, 0x0006, 0x0001, 0x0001, 0x0000,
-};
-
-static const uint8_t mpa_huffbits_5[16] = {
- 1, 3, 6, 7, 3, 3, 6, 7,
- 6, 6, 7, 8, 7, 6, 7, 8,
-};
-
-static const uint16_t mpa_huffcodes_6[16] = {
- 0x0007, 0x0003, 0x0005, 0x0001, 0x0006, 0x0002, 0x0003, 0x0002,
- 0x0005, 0x0004, 0x0004, 0x0001, 0x0003, 0x0003, 0x0002, 0x0000,
-};
-
-static const uint8_t mpa_huffbits_6[16] = {
- 3, 3, 5, 7, 3, 2, 4, 5,
- 4, 4, 5, 6, 6, 5, 6, 7,
-};
-
-static const uint16_t mpa_huffcodes_7[36] = {
- 0x0001, 0x0002, 0x000a, 0x0013, 0x0010, 0x000a, 0x0003, 0x0003,
- 0x0007, 0x000a, 0x0005, 0x0003, 0x000b, 0x0004, 0x000d, 0x0011,
- 0x0008, 0x0004, 0x000c, 0x000b, 0x0012, 0x000f, 0x000b, 0x0002,
- 0x0007, 0x0006, 0x0009, 0x000e, 0x0003, 0x0001, 0x0006, 0x0004,
- 0x0005, 0x0003, 0x0002, 0x0000,
-};
-
-static const uint8_t mpa_huffbits_7[36] = {
- 1, 3, 6, 8, 8, 9, 3, 4,
- 6, 7, 7, 8, 6, 5, 7, 8,
- 8, 9, 7, 7, 8, 9, 9, 9,
- 7, 7, 8, 9, 9, 10, 8, 8,
- 9, 10, 10, 10,
-};
-
-static const uint16_t mpa_huffcodes_8[36] = {
- 0x0003, 0x0004, 0x0006, 0x0012, 0x000c, 0x0005, 0x0005, 0x0001,
- 0x0002, 0x0010, 0x0009, 0x0003, 0x0007, 0x0003, 0x0005, 0x000e,
- 0x0007, 0x0003, 0x0013, 0x0011, 0x000f, 0x000d, 0x000a, 0x0004,
- 0x000d, 0x0005, 0x0008, 0x000b, 0x0005, 0x0001, 0x000c, 0x0004,
- 0x0004, 0x0001, 0x0001, 0x0000,
-};
-
-static const uint8_t mpa_huffbits_8[36] = {
- 2, 3, 6, 8, 8, 9, 3, 2,
- 4, 8, 8, 8, 6, 4, 6, 8,
- 8, 9, 8, 8, 8, 9, 9, 10,
- 8, 7, 8, 9, 10, 10, 9, 8,
- 9, 9, 11, 11,
-};
-
-static const uint16_t mpa_huffcodes_9[36] = {
- 0x0007, 0x0005, 0x0009, 0x000e, 0x000f, 0x0007, 0x0006, 0x0004,
- 0x0005, 0x0005, 0x0006, 0x0007, 0x0007, 0x0006, 0x0008, 0x0008,
- 0x0008, 0x0005, 0x000f, 0x0006, 0x0009, 0x000a, 0x0005, 0x0001,
- 0x000b, 0x0007, 0x0009, 0x0006, 0x0004, 0x0001, 0x000e, 0x0004,
- 0x0006, 0x0002, 0x0006, 0x0000,
-};
-
-static const uint8_t mpa_huffbits_9[36] = {
- 3, 3, 5, 6, 8, 9, 3, 3,
- 4, 5, 6, 8, 4, 4, 5, 6,
- 7, 8, 6, 5, 6, 7, 7, 8,
- 7, 6, 7, 7, 8, 9, 8, 7,
- 8, 8, 9, 9,
-};
-
-static const uint16_t mpa_huffcodes_10[64] = {
- 0x0001, 0x0002, 0x000a, 0x0017, 0x0023, 0x001e, 0x000c, 0x0011,
- 0x0003, 0x0003, 0x0008, 0x000c, 0x0012, 0x0015, 0x000c, 0x0007,
- 0x000b, 0x0009, 0x000f, 0x0015, 0x0020, 0x0028, 0x0013, 0x0006,
- 0x000e, 0x000d, 0x0016, 0x0022, 0x002e, 0x0017, 0x0012, 0x0007,
- 0x0014, 0x0013, 0x0021, 0x002f, 0x001b, 0x0016, 0x0009, 0x0003,
- 0x001f, 0x0016, 0x0029, 0x001a, 0x0015, 0x0014, 0x0005, 0x0003,
- 0x000e, 0x000d, 0x000a, 0x000b, 0x0010, 0x0006, 0x0005, 0x0001,
- 0x0009, 0x0008, 0x0007, 0x0008, 0x0004, 0x0004, 0x0002, 0x0000,
-};
-
-static const uint8_t mpa_huffbits_10[64] = {
- 1, 3, 6, 8, 9, 9, 9, 10,
- 3, 4, 6, 7, 8, 9, 8, 8,
- 6, 6, 7, 8, 9, 10, 9, 9,
- 7, 7, 8, 9, 10, 10, 9, 10,
- 8, 8, 9, 10, 10, 10, 10, 10,
- 9, 9, 10, 10, 11, 11, 10, 11,
- 8, 8, 9, 10, 10, 10, 11, 11,
- 9, 8, 9, 10, 10, 11, 11, 11,
-};
-
-static const uint16_t mpa_huffcodes_11[64] = {
- 0x0003, 0x0004, 0x000a, 0x0018, 0x0022, 0x0021, 0x0015, 0x000f,
- 0x0005, 0x0003, 0x0004, 0x000a, 0x0020, 0x0011, 0x000b, 0x000a,
- 0x000b, 0x0007, 0x000d, 0x0012, 0x001e, 0x001f, 0x0014, 0x0005,
- 0x0019, 0x000b, 0x0013, 0x003b, 0x001b, 0x0012, 0x000c, 0x0005,
- 0x0023, 0x0021, 0x001f, 0x003a, 0x001e, 0x0010, 0x0007, 0x0005,
- 0x001c, 0x001a, 0x0020, 0x0013, 0x0011, 0x000f, 0x0008, 0x000e,
- 0x000e, 0x000c, 0x0009, 0x000d, 0x000e, 0x0009, 0x0004, 0x0001,
- 0x000b, 0x0004, 0x0006, 0x0006, 0x0006, 0x0003, 0x0002, 0x0000,
-};
-
-static const uint8_t mpa_huffbits_11[64] = {
- 2, 3, 5, 7, 8, 9, 8, 9,
- 3, 3, 4, 6, 8, 8, 7, 8,
- 5, 5, 6, 7, 8, 9, 8, 8,
- 7, 6, 7, 9, 8, 10, 8, 9,
- 8, 8, 8, 9, 9, 10, 9, 10,
- 8, 8, 9, 10, 10, 11, 10, 11,
- 8, 7, 7, 8, 9, 10, 10, 10,
- 8, 7, 8, 9, 10, 10, 10, 10,
-};
-
-static const uint16_t mpa_huffcodes_12[64] = {
- 0x0009, 0x0006, 0x0010, 0x0021, 0x0029, 0x0027, 0x0026, 0x001a,
- 0x0007, 0x0005, 0x0006, 0x0009, 0x0017, 0x0010, 0x001a, 0x000b,
- 0x0011, 0x0007, 0x000b, 0x000e, 0x0015, 0x001e, 0x000a, 0x0007,
- 0x0011, 0x000a, 0x000f, 0x000c, 0x0012, 0x001c, 0x000e, 0x0005,
- 0x0020, 0x000d, 0x0016, 0x0013, 0x0012, 0x0010, 0x0009, 0x0005,
- 0x0028, 0x0011, 0x001f, 0x001d, 0x0011, 0x000d, 0x0004, 0x0002,
- 0x001b, 0x000c, 0x000b, 0x000f, 0x000a, 0x0007, 0x0004, 0x0001,
- 0x001b, 0x000c, 0x0008, 0x000c, 0x0006, 0x0003, 0x0001, 0x0000,
-};
-
-static const uint8_t mpa_huffbits_12[64] = {
- 4, 3, 5, 7, 8, 9, 9, 9,
- 3, 3, 4, 5, 7, 7, 8, 8,
- 5, 4, 5, 6, 7, 8, 7, 8,
- 6, 5, 6, 6, 7, 8, 8, 8,
- 7, 6, 7, 7, 8, 8, 8, 9,
- 8, 7, 8, 8, 8, 9, 8, 9,
- 8, 7, 7, 8, 8, 9, 9, 10,
- 9, 8, 8, 9, 9, 9, 9, 10,
-};
-
-static const uint16_t mpa_huffcodes_13[256] = {
- 0x0001, 0x0005, 0x000e, 0x0015, 0x0022, 0x0033, 0x002e, 0x0047,
- 0x002a, 0x0034, 0x0044, 0x0034, 0x0043, 0x002c, 0x002b, 0x0013,
- 0x0003, 0x0004, 0x000c, 0x0013, 0x001f, 0x001a, 0x002c, 0x0021,
- 0x001f, 0x0018, 0x0020, 0x0018, 0x001f, 0x0023, 0x0016, 0x000e,
- 0x000f, 0x000d, 0x0017, 0x0024, 0x003b, 0x0031, 0x004d, 0x0041,
- 0x001d, 0x0028, 0x001e, 0x0028, 0x001b, 0x0021, 0x002a, 0x0010,
- 0x0016, 0x0014, 0x0025, 0x003d, 0x0038, 0x004f, 0x0049, 0x0040,
- 0x002b, 0x004c, 0x0038, 0x0025, 0x001a, 0x001f, 0x0019, 0x000e,
- 0x0023, 0x0010, 0x003c, 0x0039, 0x0061, 0x004b, 0x0072, 0x005b,
- 0x0036, 0x0049, 0x0037, 0x0029, 0x0030, 0x0035, 0x0017, 0x0018,
- 0x003a, 0x001b, 0x0032, 0x0060, 0x004c, 0x0046, 0x005d, 0x0054,
- 0x004d, 0x003a, 0x004f, 0x001d, 0x004a, 0x0031, 0x0029, 0x0011,
- 0x002f, 0x002d, 0x004e, 0x004a, 0x0073, 0x005e, 0x005a, 0x004f,
- 0x0045, 0x0053, 0x0047, 0x0032, 0x003b, 0x0026, 0x0024, 0x000f,
- 0x0048, 0x0022, 0x0038, 0x005f, 0x005c, 0x0055, 0x005b, 0x005a,
- 0x0056, 0x0049, 0x004d, 0x0041, 0x0033, 0x002c, 0x002b, 0x002a,
- 0x002b, 0x0014, 0x001e, 0x002c, 0x0037, 0x004e, 0x0048, 0x0057,
- 0x004e, 0x003d, 0x002e, 0x0036, 0x0025, 0x001e, 0x0014, 0x0010,
- 0x0035, 0x0019, 0x0029, 0x0025, 0x002c, 0x003b, 0x0036, 0x0051,
- 0x0042, 0x004c, 0x0039, 0x0036, 0x0025, 0x0012, 0x0027, 0x000b,
- 0x0023, 0x0021, 0x001f, 0x0039, 0x002a, 0x0052, 0x0048, 0x0050,
- 0x002f, 0x003a, 0x0037, 0x0015, 0x0016, 0x001a, 0x0026, 0x0016,
- 0x0035, 0x0019, 0x0017, 0x0026, 0x0046, 0x003c, 0x0033, 0x0024,
- 0x0037, 0x001a, 0x0022, 0x0017, 0x001b, 0x000e, 0x0009, 0x0007,
- 0x0022, 0x0020, 0x001c, 0x0027, 0x0031, 0x004b, 0x001e, 0x0034,
- 0x0030, 0x0028, 0x0034, 0x001c, 0x0012, 0x0011, 0x0009, 0x0005,
- 0x002d, 0x0015, 0x0022, 0x0040, 0x0038, 0x0032, 0x0031, 0x002d,
- 0x001f, 0x0013, 0x000c, 0x000f, 0x000a, 0x0007, 0x0006, 0x0003,
- 0x0030, 0x0017, 0x0014, 0x0027, 0x0024, 0x0023, 0x0035, 0x0015,
- 0x0010, 0x0017, 0x000d, 0x000a, 0x0006, 0x0001, 0x0004, 0x0002,
- 0x0010, 0x000f, 0x0011, 0x001b, 0x0019, 0x0014, 0x001d, 0x000b,
- 0x0011, 0x000c, 0x0010, 0x0008, 0x0001, 0x0001, 0x0000, 0x0001,
-};
-
-static const uint8_t mpa_huffbits_13[256] = {
- 1, 4, 6, 7, 8, 9, 9, 10,
- 9, 10, 11, 11, 12, 12, 13, 13,
- 3, 4, 6, 7, 8, 8, 9, 9,
- 9, 9, 10, 10, 11, 12, 12, 12,
- 6, 6, 7, 8, 9, 9, 10, 10,
- 9, 10, 10, 11, 11, 12, 13, 13,
- 7, 7, 8, 9, 9, 10, 10, 10,
- 10, 11, 11, 11, 11, 12, 13, 13,
- 8, 7, 9, 9, 10, 10, 11, 11,
- 10, 11, 11, 12, 12, 13, 13, 14,
- 9, 8, 9, 10, 10, 10, 11, 11,
- 11, 11, 12, 11, 13, 13, 14, 14,
- 9, 9, 10, 10, 11, 11, 11, 11,
- 11, 12, 12, 12, 13, 13, 14, 14,
- 10, 9, 10, 11, 11, 11, 12, 12,
- 12, 12, 13, 13, 13, 14, 16, 16,
- 9, 8, 9, 10, 10, 11, 11, 12,
- 12, 12, 12, 13, 13, 14, 15, 15,
- 10, 9, 10, 10, 11, 11, 11, 13,
- 12, 13, 13, 14, 14, 14, 16, 15,
- 10, 10, 10, 11, 11, 12, 12, 13,
- 12, 13, 14, 13, 14, 15, 16, 17,
- 11, 10, 10, 11, 12, 12, 12, 12,
- 13, 13, 13, 14, 15, 15, 15, 16,
- 11, 11, 11, 12, 12, 13, 12, 13,
- 14, 14, 15, 15, 15, 16, 16, 16,
- 12, 11, 12, 13, 13, 13, 14, 14,
- 14, 14, 14, 15, 16, 15, 16, 16,
- 13, 12, 12, 13, 13, 13, 15, 14,
- 14, 17, 15, 15, 15, 17, 16, 16,
- 12, 12, 13, 14, 14, 14, 15, 14,
- 15, 15, 16, 16, 19, 18, 19, 16,
-};
-
-static const uint16_t mpa_huffcodes_15[256] = {
- 0x0007, 0x000c, 0x0012, 0x0035, 0x002f, 0x004c, 0x007c, 0x006c,
- 0x0059, 0x007b, 0x006c, 0x0077, 0x006b, 0x0051, 0x007a, 0x003f,
- 0x000d, 0x0005, 0x0010, 0x001b, 0x002e, 0x0024, 0x003d, 0x0033,
- 0x002a, 0x0046, 0x0034, 0x0053, 0x0041, 0x0029, 0x003b, 0x0024,
- 0x0013, 0x0011, 0x000f, 0x0018, 0x0029, 0x0022, 0x003b, 0x0030,
- 0x0028, 0x0040, 0x0032, 0x004e, 0x003e, 0x0050, 0x0038, 0x0021,
- 0x001d, 0x001c, 0x0019, 0x002b, 0x0027, 0x003f, 0x0037, 0x005d,
- 0x004c, 0x003b, 0x005d, 0x0048, 0x0036, 0x004b, 0x0032, 0x001d,
- 0x0034, 0x0016, 0x002a, 0x0028, 0x0043, 0x0039, 0x005f, 0x004f,
- 0x0048, 0x0039, 0x0059, 0x0045, 0x0031, 0x0042, 0x002e, 0x001b,
- 0x004d, 0x0025, 0x0023, 0x0042, 0x003a, 0x0034, 0x005b, 0x004a,
- 0x003e, 0x0030, 0x004f, 0x003f, 0x005a, 0x003e, 0x0028, 0x0026,
- 0x007d, 0x0020, 0x003c, 0x0038, 0x0032, 0x005c, 0x004e, 0x0041,
- 0x0037, 0x0057, 0x0047, 0x0033, 0x0049, 0x0033, 0x0046, 0x001e,
- 0x006d, 0x0035, 0x0031, 0x005e, 0x0058, 0x004b, 0x0042, 0x007a,
- 0x005b, 0x0049, 0x0038, 0x002a, 0x0040, 0x002c, 0x0015, 0x0019,
- 0x005a, 0x002b, 0x0029, 0x004d, 0x0049, 0x003f, 0x0038, 0x005c,
- 0x004d, 0x0042, 0x002f, 0x0043, 0x0030, 0x0035, 0x0024, 0x0014,
- 0x0047, 0x0022, 0x0043, 0x003c, 0x003a, 0x0031, 0x0058, 0x004c,
- 0x0043, 0x006a, 0x0047, 0x0036, 0x0026, 0x0027, 0x0017, 0x000f,
- 0x006d, 0x0035, 0x0033, 0x002f, 0x005a, 0x0052, 0x003a, 0x0039,
- 0x0030, 0x0048, 0x0039, 0x0029, 0x0017, 0x001b, 0x003e, 0x0009,
- 0x0056, 0x002a, 0x0028, 0x0025, 0x0046, 0x0040, 0x0034, 0x002b,
- 0x0046, 0x0037, 0x002a, 0x0019, 0x001d, 0x0012, 0x000b, 0x000b,
- 0x0076, 0x0044, 0x001e, 0x0037, 0x0032, 0x002e, 0x004a, 0x0041,
- 0x0031, 0x0027, 0x0018, 0x0010, 0x0016, 0x000d, 0x000e, 0x0007,
- 0x005b, 0x002c, 0x0027, 0x0026, 0x0022, 0x003f, 0x0034, 0x002d,
- 0x001f, 0x0034, 0x001c, 0x0013, 0x000e, 0x0008, 0x0009, 0x0003,
- 0x007b, 0x003c, 0x003a, 0x0035, 0x002f, 0x002b, 0x0020, 0x0016,
- 0x0025, 0x0018, 0x0011, 0x000c, 0x000f, 0x000a, 0x0002, 0x0001,
- 0x0047, 0x0025, 0x0022, 0x001e, 0x001c, 0x0014, 0x0011, 0x001a,
- 0x0015, 0x0010, 0x000a, 0x0006, 0x0008, 0x0006, 0x0002, 0x0000,
-};
-
-static const uint8_t mpa_huffbits_15[256] = {
- 3, 4, 5, 7, 7, 8, 9, 9,
- 9, 10, 10, 11, 11, 11, 12, 13,
- 4, 3, 5, 6, 7, 7, 8, 8,
- 8, 9, 9, 10, 10, 10, 11, 11,
- 5, 5, 5, 6, 7, 7, 8, 8,
- 8, 9, 9, 10, 10, 11, 11, 11,
- 6, 6, 6, 7, 7, 8, 8, 9,
- 9, 9, 10, 10, 10, 11, 11, 11,
- 7, 6, 7, 7, 8, 8, 9, 9,
- 9, 9, 10, 10, 10, 11, 11, 11,
- 8, 7, 7, 8, 8, 8, 9, 9,
- 9, 9, 10, 10, 11, 11, 11, 12,
- 9, 7, 8, 8, 8, 9, 9, 9,
- 9, 10, 10, 10, 11, 11, 12, 12,
- 9, 8, 8, 9, 9, 9, 9, 10,
- 10, 10, 10, 10, 11, 11, 11, 12,
- 9, 8, 8, 9, 9, 9, 9, 10,
- 10, 10, 10, 11, 11, 12, 12, 12,
- 9, 8, 9, 9, 9, 9, 10, 10,
- 10, 11, 11, 11, 11, 12, 12, 12,
- 10, 9, 9, 9, 10, 10, 10, 10,
- 10, 11, 11, 11, 11, 12, 13, 12,
- 10, 9, 9, 9, 10, 10, 10, 10,
- 11, 11, 11, 11, 12, 12, 12, 13,
- 11, 10, 9, 10, 10, 10, 11, 11,
- 11, 11, 11, 11, 12, 12, 13, 13,
- 11, 10, 10, 10, 10, 11, 11, 11,
- 11, 12, 12, 12, 12, 12, 13, 13,
- 12, 11, 11, 11, 11, 11, 11, 11,
- 12, 12, 12, 12, 13, 13, 12, 13,
- 12, 11, 11, 11, 11, 11, 11, 12,
- 12, 12, 12, 12, 13, 13, 13, 13,
-};
-
-static const uint16_t mpa_huffcodes_16[256] = {
- 0x0001, 0x0005, 0x000e, 0x002c, 0x004a, 0x003f, 0x006e, 0x005d,
- 0x00ac, 0x0095, 0x008a, 0x00f2, 0x00e1, 0x00c3, 0x0178, 0x0011,
- 0x0003, 0x0004, 0x000c, 0x0014, 0x0023, 0x003e, 0x0035, 0x002f,
- 0x0053, 0x004b, 0x0044, 0x0077, 0x00c9, 0x006b, 0x00cf, 0x0009,
- 0x000f, 0x000d, 0x0017, 0x0026, 0x0043, 0x003a, 0x0067, 0x005a,
- 0x00a1, 0x0048, 0x007f, 0x0075, 0x006e, 0x00d1, 0x00ce, 0x0010,
- 0x002d, 0x0015, 0x0027, 0x0045, 0x0040, 0x0072, 0x0063, 0x0057,
- 0x009e, 0x008c, 0x00fc, 0x00d4, 0x00c7, 0x0183, 0x016d, 0x001a,
- 0x004b, 0x0024, 0x0044, 0x0041, 0x0073, 0x0065, 0x00b3, 0x00a4,
- 0x009b, 0x0108, 0x00f6, 0x00e2, 0x018b, 0x017e, 0x016a, 0x0009,
- 0x0042, 0x001e, 0x003b, 0x0038, 0x0066, 0x00b9, 0x00ad, 0x0109,
- 0x008e, 0x00fd, 0x00e8, 0x0190, 0x0184, 0x017a, 0x01bd, 0x0010,
- 0x006f, 0x0036, 0x0034, 0x0064, 0x00b8, 0x00b2, 0x00a0, 0x0085,
- 0x0101, 0x00f4, 0x00e4, 0x00d9, 0x0181, 0x016e, 0x02cb, 0x000a,
- 0x0062, 0x0030, 0x005b, 0x0058, 0x00a5, 0x009d, 0x0094, 0x0105,
- 0x00f8, 0x0197, 0x018d, 0x0174, 0x017c, 0x0379, 0x0374, 0x0008,
- 0x0055, 0x0054, 0x0051, 0x009f, 0x009c, 0x008f, 0x0104, 0x00f9,
- 0x01ab, 0x0191, 0x0188, 0x017f, 0x02d7, 0x02c9, 0x02c4, 0x0007,
- 0x009a, 0x004c, 0x0049, 0x008d, 0x0083, 0x0100, 0x00f5, 0x01aa,
- 0x0196, 0x018a, 0x0180, 0x02df, 0x0167, 0x02c6, 0x0160, 0x000b,
- 0x008b, 0x0081, 0x0043, 0x007d, 0x00f7, 0x00e9, 0x00e5, 0x00db,
- 0x0189, 0x02e7, 0x02e1, 0x02d0, 0x0375, 0x0372, 0x01b7, 0x0004,
- 0x00f3, 0x0078, 0x0076, 0x0073, 0x00e3, 0x00df, 0x018c, 0x02ea,
- 0x02e6, 0x02e0, 0x02d1, 0x02c8, 0x02c2, 0x00df, 0x01b4, 0x0006,
- 0x00ca, 0x00e0, 0x00de, 0x00da, 0x00d8, 0x0185, 0x0182, 0x017d,
- 0x016c, 0x0378, 0x01bb, 0x02c3, 0x01b8, 0x01b5, 0x06c0, 0x0004,
- 0x02eb, 0x00d3, 0x00d2, 0x00d0, 0x0172, 0x017b, 0x02de, 0x02d3,
- 0x02ca, 0x06c7, 0x0373, 0x036d, 0x036c, 0x0d83, 0x0361, 0x0002,
- 0x0179, 0x0171, 0x0066, 0x00bb, 0x02d6, 0x02d2, 0x0166, 0x02c7,
- 0x02c5, 0x0362, 0x06c6, 0x0367, 0x0d82, 0x0366, 0x01b2, 0x0000,
- 0x000c, 0x000a, 0x0007, 0x000b, 0x000a, 0x0011, 0x000b, 0x0009,
- 0x000d, 0x000c, 0x000a, 0x0007, 0x0005, 0x0003, 0x0001, 0x0003,
-};
-
-static const uint8_t mpa_huffbits_16[256] = {
- 1, 4, 6, 8, 9, 9, 10, 10,
- 11, 11, 11, 12, 12, 12, 13, 9,
- 3, 4, 6, 7, 8, 9, 9, 9,
- 10, 10, 10, 11, 12, 11, 12, 8,
- 6, 6, 7, 8, 9, 9, 10, 10,
- 11, 10, 11, 11, 11, 12, 12, 9,
- 8, 7, 8, 9, 9, 10, 10, 10,
- 11, 11, 12, 12, 12, 13, 13, 10,
- 9, 8, 9, 9, 10, 10, 11, 11,
- 11, 12, 12, 12, 13, 13, 13, 9,
- 9, 8, 9, 9, 10, 11, 11, 12,
- 11, 12, 12, 13, 13, 13, 14, 10,
- 10, 9, 9, 10, 11, 11, 11, 11,
- 12, 12, 12, 12, 13, 13, 14, 10,
- 10, 9, 10, 10, 11, 11, 11, 12,
- 12, 13, 13, 13, 13, 15, 15, 10,
- 10, 10, 10, 11, 11, 11, 12, 12,
- 13, 13, 13, 13, 14, 14, 14, 10,
- 11, 10, 10, 11, 11, 12, 12, 13,
- 13, 13, 13, 14, 13, 14, 13, 11,
- 11, 11, 10, 11, 12, 12, 12, 12,
- 13, 14, 14, 14, 15, 15, 14, 10,
- 12, 11, 11, 11, 12, 12, 13, 14,
- 14, 14, 14, 14, 14, 13, 14, 11,
- 12, 12, 12, 12, 12, 13, 13, 13,
- 13, 15, 14, 14, 14, 14, 16, 11,
- 14, 12, 12, 12, 13, 13, 14, 14,
- 14, 16, 15, 15, 15, 17, 15, 11,
- 13, 13, 11, 12, 14, 14, 13, 14,
- 14, 15, 16, 15, 17, 15, 14, 11,
- 9, 8, 8, 9, 9, 10, 10, 10,
- 11, 11, 11, 11, 11, 11, 11, 8,
-};
-
-static const uint16_t mpa_huffcodes_24[256] = {
- 0x000f, 0x000d, 0x002e, 0x0050, 0x0092, 0x0106, 0x00f8, 0x01b2,
- 0x01aa, 0x029d, 0x028d, 0x0289, 0x026d, 0x0205, 0x0408, 0x0058,
- 0x000e, 0x000c, 0x0015, 0x0026, 0x0047, 0x0082, 0x007a, 0x00d8,
- 0x00d1, 0x00c6, 0x0147, 0x0159, 0x013f, 0x0129, 0x0117, 0x002a,
- 0x002f, 0x0016, 0x0029, 0x004a, 0x0044, 0x0080, 0x0078, 0x00dd,
- 0x00cf, 0x00c2, 0x00b6, 0x0154, 0x013b, 0x0127, 0x021d, 0x0012,
- 0x0051, 0x0027, 0x004b, 0x0046, 0x0086, 0x007d, 0x0074, 0x00dc,
- 0x00cc, 0x00be, 0x00b2, 0x0145, 0x0137, 0x0125, 0x010f, 0x0010,
- 0x0093, 0x0048, 0x0045, 0x0087, 0x007f, 0x0076, 0x0070, 0x00d2,
- 0x00c8, 0x00bc, 0x0160, 0x0143, 0x0132, 0x011d, 0x021c, 0x000e,
- 0x0107, 0x0042, 0x0081, 0x007e, 0x0077, 0x0072, 0x00d6, 0x00ca,
- 0x00c0, 0x00b4, 0x0155, 0x013d, 0x012d, 0x0119, 0x0106, 0x000c,
- 0x00f9, 0x007b, 0x0079, 0x0075, 0x0071, 0x00d7, 0x00ce, 0x00c3,
- 0x00b9, 0x015b, 0x014a, 0x0134, 0x0123, 0x0110, 0x0208, 0x000a,
- 0x01b3, 0x0073, 0x006f, 0x006d, 0x00d3, 0x00cb, 0x00c4, 0x00bb,
- 0x0161, 0x014c, 0x0139, 0x012a, 0x011b, 0x0213, 0x017d, 0x0011,
- 0x01ab, 0x00d4, 0x00d0, 0x00cd, 0x00c9, 0x00c1, 0x00ba, 0x00b1,
- 0x00a9, 0x0140, 0x012f, 0x011e, 0x010c, 0x0202, 0x0179, 0x0010,
- 0x014f, 0x00c7, 0x00c5, 0x00bf, 0x00bd, 0x00b5, 0x00ae, 0x014d,
- 0x0141, 0x0131, 0x0121, 0x0113, 0x0209, 0x017b, 0x0173, 0x000b,
- 0x029c, 0x00b8, 0x00b7, 0x00b3, 0x00af, 0x0158, 0x014b, 0x013a,
- 0x0130, 0x0122, 0x0115, 0x0212, 0x017f, 0x0175, 0x016e, 0x000a,
- 0x028c, 0x015a, 0x00ab, 0x00a8, 0x00a4, 0x013e, 0x0135, 0x012b,
- 0x011f, 0x0114, 0x0107, 0x0201, 0x0177, 0x0170, 0x016a, 0x0006,
- 0x0288, 0x0142, 0x013c, 0x0138, 0x0133, 0x012e, 0x0124, 0x011c,
- 0x010d, 0x0105, 0x0200, 0x0178, 0x0172, 0x016c, 0x0167, 0x0004,
- 0x026c, 0x012c, 0x0128, 0x0126, 0x0120, 0x011a, 0x0111, 0x010a,
- 0x0203, 0x017c, 0x0176, 0x0171, 0x016d, 0x0169, 0x0165, 0x0002,
- 0x0409, 0x0118, 0x0116, 0x0112, 0x010b, 0x0108, 0x0103, 0x017e,
- 0x017a, 0x0174, 0x016f, 0x016b, 0x0168, 0x0166, 0x0164, 0x0000,
- 0x002b, 0x0014, 0x0013, 0x0011, 0x000f, 0x000d, 0x000b, 0x0009,
- 0x0007, 0x0006, 0x0004, 0x0007, 0x0005, 0x0003, 0x0001, 0x0003,
-};
-
-static const uint8_t mpa_huffbits_24[256] = {
- 4, 4, 6, 7, 8, 9, 9, 10,
- 10, 11, 11, 11, 11, 11, 12, 9,
- 4, 4, 5, 6, 7, 8, 8, 9,
- 9, 9, 10, 10, 10, 10, 10, 8,
- 6, 5, 6, 7, 7, 8, 8, 9,
- 9, 9, 9, 10, 10, 10, 11, 7,
- 7, 6, 7, 7, 8, 8, 8, 9,
- 9, 9, 9, 10, 10, 10, 10, 7,
- 8, 7, 7, 8, 8, 8, 8, 9,
- 9, 9, 10, 10, 10, 10, 11, 7,
- 9, 7, 8, 8, 8, 8, 9, 9,
- 9, 9, 10, 10, 10, 10, 10, 7,
- 9, 8, 8, 8, 8, 9, 9, 9,
- 9, 10, 10, 10, 10, 10, 11, 7,
- 10, 8, 8, 8, 9, 9, 9, 9,
- 10, 10, 10, 10, 10, 11, 11, 8,
- 10, 9, 9, 9, 9, 9, 9, 9,
- 9, 10, 10, 10, 10, 11, 11, 8,
- 10, 9, 9, 9, 9, 9, 9, 10,
- 10, 10, 10, 10, 11, 11, 11, 8,
- 11, 9, 9, 9, 9, 10, 10, 10,
- 10, 10, 10, 11, 11, 11, 11, 8,
- 11, 10, 9, 9, 9, 10, 10, 10,
- 10, 10, 10, 11, 11, 11, 11, 8,
- 11, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 11, 11, 11, 11, 11, 8,
- 11, 10, 10, 10, 10, 10, 10, 10,
- 11, 11, 11, 11, 11, 11, 11, 8,
- 12, 10, 10, 10, 10, 10, 10, 11,
- 11, 11, 11, 11, 11, 11, 11, 8,
- 8, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 8, 8, 8, 8, 4,
-};
-
-static const HuffTable mpa_huff_tables[16] = {
-{ 1, NULL, NULL },
-{ 2, mpa_huffbits_1, mpa_huffcodes_1 },
-{ 3, mpa_huffbits_2, mpa_huffcodes_2 },
-{ 3, mpa_huffbits_3, mpa_huffcodes_3 },
-{ 4, mpa_huffbits_5, mpa_huffcodes_5 },
-{ 4, mpa_huffbits_6, mpa_huffcodes_6 },
-{ 6, mpa_huffbits_7, mpa_huffcodes_7 },
-{ 6, mpa_huffbits_8, mpa_huffcodes_8 },
-{ 6, mpa_huffbits_9, mpa_huffcodes_9 },
-{ 8, mpa_huffbits_10, mpa_huffcodes_10 },
-{ 8, mpa_huffbits_11, mpa_huffcodes_11 },
-{ 8, mpa_huffbits_12, mpa_huffcodes_12 },
-{ 16, mpa_huffbits_13, mpa_huffcodes_13 },
-{ 16, mpa_huffbits_15, mpa_huffcodes_15 },
-{ 16, mpa_huffbits_16, mpa_huffcodes_16 },
-{ 16, mpa_huffbits_24, mpa_huffcodes_24 },
-};
-
-static const uint8_t mpa_huff_data[32][2] = {
-{ 0, 0 },
-{ 1, 0 },
-{ 2, 0 },
-{ 3, 0 },
-{ 0, 0 },
-{ 4, 0 },
-{ 5, 0 },
-{ 6, 0 },
-{ 7, 0 },
-{ 8, 0 },
-{ 9, 0 },
-{ 10, 0 },
-{ 11, 0 },
-{ 12, 0 },
-{ 0, 0 },
-{ 13, 0 },
-{ 14, 1 },
-{ 14, 2 },
-{ 14, 3 },
-{ 14, 4 },
-{ 14, 6 },
-{ 14, 8 },
-{ 14, 10 },
-{ 14, 13 },
-{ 15, 4 },
-{ 15, 5 },
-{ 15, 6 },
-{ 15, 7 },
-{ 15, 8 },
-{ 15, 9 },
-{ 15, 11 },
-{ 15, 13 },
-};
-
-
-/* huffman tables for quadrules */
-static const uint8_t mpa_quad_codes[2][16] = {
- { 1, 5, 4, 5, 6, 5, 4, 4, 7, 3, 6, 0, 7, 2, 3, 1, },
- { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, },
-};
-
-static const uint8_t mpa_quad_bits[2][16] = {
- { 1, 4, 4, 5, 4, 6, 5, 6, 4, 5, 5, 6, 5, 6, 6, 6, },
- { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, },
-};
-
-/* band size tables */
-static const uint8_t band_size_long[9][22] = {
-{ 4, 4, 4, 4, 4, 4, 6, 6, 8, 8, 10,
- 12, 16, 20, 24, 28, 34, 42, 50, 54, 76, 158, }, /* 44100 */
-{ 4, 4, 4, 4, 4, 4, 6, 6, 6, 8, 10,
- 12, 16, 18, 22, 28, 34, 40, 46, 54, 54, 192, }, /* 48000 */
-{ 4, 4, 4, 4, 4, 4, 6, 6, 8, 10, 12,
- 16, 20, 24, 30, 38, 46, 56, 68, 84, 102, 26, }, /* 32000 */
-{ 6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16,
- 20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54, }, /* 22050 */
-{ 6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16,
- 18, 22, 26, 32, 38, 46, 52, 64, 70, 76, 36, }, /* 24000 */
-{ 6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16,
- 20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54, }, /* 16000 */
-{ 6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16,
- 20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54, }, /* 11025 */
-{ 6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16,
- 20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54, }, /* 12000 */
-{ 12, 12, 12, 12, 12, 12, 16, 20, 24, 28, 32,
- 40, 48, 56, 64, 76, 90, 2, 2, 2, 2, 2, }, /* 8000 */
-};
-
-static const uint8_t band_size_short[9][13] = {
-{ 4, 4, 4, 4, 6, 8, 10, 12, 14, 18, 22, 30, 56, }, /* 44100 */
-{ 4, 4, 4, 4, 6, 6, 10, 12, 14, 16, 20, 26, 66, }, /* 48000 */
-{ 4, 4, 4, 4, 6, 8, 12, 16, 20, 26, 34, 42, 12, }, /* 32000 */
-{ 4, 4, 4, 6, 6, 8, 10, 14, 18, 26, 32, 42, 18, }, /* 22050 */
-{ 4, 4, 4, 6, 8, 10, 12, 14, 18, 24, 32, 44, 12, }, /* 24000 */
-{ 4, 4, 4, 6, 8, 10, 12, 14, 18, 24, 30, 40, 18, }, /* 16000 */
-{ 4, 4, 4, 6, 8, 10, 12, 14, 18, 24, 30, 40, 18, }, /* 11025 */
-{ 4, 4, 4, 6, 8, 10, 12, 14, 18, 24, 30, 40, 18, }, /* 12000 */
-{ 8, 8, 8, 12, 16, 20, 24, 28, 36, 2, 2, 2, 26, }, /* 8000 */
-};
-
-static const uint8_t mpa_pretab[2][22] = {
- { 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, 1, 1, 1, 1, 2, 2, 3, 3, 3, 2, 0 },
-};
-
-/* table for alias reduction (XXX: store it as integer !) */
-static const float ci_table[8] = {
- -0.6, -0.535, -0.33, -0.185, -0.095, -0.041, -0.0142, -0.0037,
-};
-
-#endif /* AVCODEC_MPEGAUDIODECTAB_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpegaudiodsp.c b/src/thirdparty/ffmpeg/libavcodec/mpegaudiodsp.c
deleted file mode 100644
index db6a63643..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpegaudiodsp.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2011 Mans Rullgard
- *
- * 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 "mpegaudiodsp.h"
-#include "dct.h"
-#include "dct32.h"
-
-void ff_mpadsp_init(MPADSPContext *s)
-{
- DCTContext dct;
-
- ff_dct_init(&dct, 5, DCT_II);
- ff_init_mpadsp_tabs_float();
- ff_init_mpadsp_tabs_fixed();
-
- s->apply_window_float = ff_mpadsp_apply_window_float;
- s->apply_window_fixed = ff_mpadsp_apply_window_fixed;
-
- s->dct32_float = dct.dct32;
- s->dct32_fixed = ff_dct32_fixed;
-
- s->imdct36_blocks_float = ff_imdct36_blocks_float;
- s->imdct36_blocks_fixed = ff_imdct36_blocks_fixed;
-
- if (ARCH_ARM) ff_mpadsp_init_arm(s);
- if (ARCH_X86) ff_mpadsp_init_x86(s);
- if (HAVE_ALTIVEC) ff_mpadsp_init_altivec(s);
- if (HAVE_MIPSFPU) ff_mpadsp_init_mipsfpu(s);
- if (HAVE_MIPSDSPR1) ff_mpadsp_init_mipsdspr1(s);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpegaudiodsp.h b/src/thirdparty/ffmpeg/libavcodec/mpegaudiodsp.h
deleted file mode 100644
index 2cd2fded3..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpegaudiodsp.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_MPEGAUDIODSP_H
-#define AVCODEC_MPEGAUDIODSP_H
-
-#include <stdint.h>
-#include "libavutil/common.h"
-
-typedef struct MPADSPContext {
- void (*apply_window_float)(float *synth_buf, float *window,
- int *dither_state, float *samples, int incr);
- void (*apply_window_fixed)(int32_t *synth_buf, int32_t *window,
- int *dither_state, int16_t *samples, int incr);
- void (*dct32_float)(float *dst, const float *src);
- void (*dct32_fixed)(int *dst, const int *src);
-
- void (*imdct36_blocks_float)(float *out, float *buf, float *in,
- int count, int switch_point, int block_type);
- void (*imdct36_blocks_fixed)(int *out, int *buf, int *in,
- int count, int switch_point, int block_type);
-} MPADSPContext;
-
-void ff_mpadsp_init(MPADSPContext *s);
-
-extern int32_t ff_mpa_synth_window_fixed[];
-extern float ff_mpa_synth_window_float[];
-
-extern const int32_t ff_mpa_enwindow[257];
-
-void ff_mpa_synth_filter_fixed(MPADSPContext *s,
- int32_t *synth_buf_ptr, int *synth_buf_offset,
- int32_t *window, int *dither_state,
- int16_t *samples, int incr,
- int32_t *sb_samples);
-
-void ff_mpa_synth_filter_float(MPADSPContext *s,
- float *synth_buf_ptr, int *synth_buf_offset,
- float *window, int *dither_state,
- float *samples, int incr,
- float *sb_samples);
-
-void ff_mpadsp_init_arm(MPADSPContext *s);
-void ff_mpadsp_init_x86(MPADSPContext *s);
-void ff_mpadsp_init_altivec(MPADSPContext *s);
-void ff_mpadsp_init_mipsfpu(MPADSPContext *s);
-void ff_mpadsp_init_mipsdspr1(MPADSPContext *s);
-
-void ff_mpa_synth_init_float(float *window);
-void ff_mpa_synth_init_fixed(int32_t *window);
-
-void ff_mpadsp_apply_window_float(float *synth_buf, float *window,
- int *dither_state, float *samples,
- int incr);
-void ff_mpadsp_apply_window_fixed(int32_t *synth_buf, int32_t *window,
- int *dither_state, int16_t *samples,
- int incr);
-
-void ff_imdct36_blocks_float(float *out, float *buf, float *in,
- int count, int switch_point, int block_type);
-
-void ff_imdct36_blocks_fixed(int *out, int *buf, int *in,
- int count, int switch_point, int block_type);
-
-void ff_init_mpadsp_tabs_float(void);
-void ff_init_mpadsp_tabs_fixed(void);
-
-/** For SSE implementation, MDCT_BUF_SIZE/2 should be 128-bit aligned */
-#define MDCT_BUF_SIZE FFALIGN(36, 2*4)
-
-extern int ff_mdct_win_fixed[8][MDCT_BUF_SIZE];
-extern float ff_mdct_win_float[8][MDCT_BUF_SIZE];
-
-#endif /* AVCODEC_MPEGAUDIODSP_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpegaudiodsp_data.c b/src/thirdparty/ffmpeg/libavcodec/mpegaudiodsp_data.c
deleted file mode 100644
index 4550de9b8..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpegaudiodsp_data.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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 "mpegaudiodsp.h"
-
-/* half mpeg encoding window (full precision) */
-const int32_t ff_mpa_enwindow[257] = {
- 0, -1, -1, -1, -1, -1, -1, -2,
- -2, -2, -2, -3, -3, -4, -4, -5,
- -5, -6, -7, -7, -8, -9, -10, -11,
- -13, -14, -16, -17, -19, -21, -24, -26,
- -29, -31, -35, -38, -41, -45, -49, -53,
- -58, -63, -68, -73, -79, -85, -91, -97,
- -104, -111, -117, -125, -132, -139, -147, -154,
- -161, -169, -176, -183, -190, -196, -202, -208,
- 213, 218, 222, 225, 227, 228, 228, 227,
- 224, 221, 215, 208, 200, 189, 177, 163,
- 146, 127, 106, 83, 57, 29, -2, -36,
- -72, -111, -153, -197, -244, -294, -347, -401,
- -459, -519, -581, -645, -711, -779, -848, -919,
- -991, -1064, -1137, -1210, -1283, -1356, -1428, -1498,
- -1567, -1634, -1698, -1759, -1817, -1870, -1919, -1962,
- -2001, -2032, -2057, -2075, -2085, -2087, -2080, -2063,
- 2037, 2000, 1952, 1893, 1822, 1739, 1644, 1535,
- 1414, 1280, 1131, 970, 794, 605, 402, 185,
- -45, -288, -545, -814, -1095, -1388, -1692, -2006,
- -2330, -2663, -3004, -3351, -3705, -4063, -4425, -4788,
- -5153, -5517, -5879, -6237, -6589, -6935, -7271, -7597,
- -7910, -8209, -8491, -8755, -8998, -9219, -9416, -9585,
- -9727, -9838, -9916, -9959, -9966, -9935, -9863, -9750,
- -9592, -9389, -9139, -8840, -8492, -8092, -7640, -7134,
- 6574, 5959, 5288, 4561, 3776, 2935, 2037, 1082,
- 70, -998, -2122, -3300, -4533, -5818, -7154, -8540,
- -9975,-11455,-12980,-14548,-16155,-17799,-19478,-21189,
--22929,-24694,-26482,-28289,-30112,-31947,-33791,-35640,
--37489,-39336,-41176,-43006,-44821,-46617,-48390,-50137,
--51853,-53534,-55178,-56778,-58333,-59838,-61289,-62684,
--64019,-65290,-66494,-67629,-68692,-69679,-70590,-71420,
--72169,-72835,-73415,-73908,-74313,-74630,-74856,-74992,
- 75038,
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpegaudiodsp_fixed.c b/src/thirdparty/ffmpeg/libavcodec/mpegaudiodsp_fixed.c
deleted file mode 100644
index a9f03815f..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpegaudiodsp_fixed.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#define CONFIG_FLOAT 0
-#include "mpegaudiodsp_template.c"
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpegaudiodsp_float.c b/src/thirdparty/ffmpeg/libavcodec/mpegaudiodsp_float.c
deleted file mode 100644
index 736882118..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpegaudiodsp_float.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#define CONFIG_FLOAT 1
-#include "mpegaudiodsp_template.c"
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpegaudiodsp_template.c b/src/thirdparty/ffmpeg/libavcodec/mpegaudiodsp_template.c
deleted file mode 100644
index 7cbb62c76..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpegaudiodsp_template.c
+++ /dev/null
@@ -1,400 +0,0 @@
-/*
- * Copyright (c) 2001, 2002 Fabrice Bellard
- *
- * 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/mem.h"
-#include "dct32.h"
-#include "mathops.h"
-#include "mpegaudiodsp.h"
-#include "mpegaudio.h"
-
-#if CONFIG_FLOAT
-#define RENAME(n) n##_float
-
-static inline float round_sample(float *sum)
-{
- float sum1=*sum;
- *sum = 0;
- return sum1;
-}
-
-#define MACS(rt, ra, rb) rt+=(ra)*(rb)
-#define MULS(ra, rb) ((ra)*(rb))
-#define MULH3(x, y, s) ((s)*(y)*(x))
-#define MLSS(rt, ra, rb) rt-=(ra)*(rb)
-#define MULLx(x, y, s) ((y)*(x))
-#define FIXHR(x) ((float)(x))
-#define FIXR(x) ((float)(x))
-#define SHR(a,b) ((a)*(1.0f/(1<<(b))))
-
-#else
-
-#define RENAME(n) n##_fixed
-#define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 15)
-
-static inline int round_sample(int64_t *sum)
-{
- int sum1;
- sum1 = (int)((*sum) >> OUT_SHIFT);
- *sum &= (1<<OUT_SHIFT)-1;
- return av_clip_int16(sum1);
-}
-
-# define MULS(ra, rb) MUL64(ra, rb)
-# define MACS(rt, ra, rb) MAC64(rt, ra, rb)
-# define MLSS(rt, ra, rb) MLS64(rt, ra, rb)
-# define MULH3(x, y, s) MULH((s)*(x), y)
-# define MULLx(x, y, s) MULL(x,y,s)
-# define SHR(a,b) ((a)>>(b))
-# define FIXR(a) ((int)((a) * FRAC_ONE + 0.5))
-# define FIXHR(a) ((int)((a) * (1LL<<32) + 0.5))
-#endif
-
-/** Window for MDCT. Actually only the elements in [0,17] and
- [MDCT_BUF_SIZE/2, MDCT_BUF_SIZE/2 + 17] are actually used. The rest
- is just to preserve alignment for SIMD implementations.
-*/
-DECLARE_ALIGNED(16, INTFLOAT, RENAME(ff_mdct_win))[8][MDCT_BUF_SIZE];
-
-DECLARE_ALIGNED(16, MPA_INT, RENAME(ff_mpa_synth_window))[512+256];
-
-#define SUM8(op, sum, w, p) \
-{ \
- op(sum, (w)[0 * 64], (p)[0 * 64]); \
- op(sum, (w)[1 * 64], (p)[1 * 64]); \
- op(sum, (w)[2 * 64], (p)[2 * 64]); \
- op(sum, (w)[3 * 64], (p)[3 * 64]); \
- op(sum, (w)[4 * 64], (p)[4 * 64]); \
- op(sum, (w)[5 * 64], (p)[5 * 64]); \
- op(sum, (w)[6 * 64], (p)[6 * 64]); \
- op(sum, (w)[7 * 64], (p)[7 * 64]); \
-}
-
-#define SUM8P2(sum1, op1, sum2, op2, w1, w2, p) \
-{ \
- INTFLOAT tmp;\
- tmp = p[0 * 64];\
- op1(sum1, (w1)[0 * 64], tmp);\
- op2(sum2, (w2)[0 * 64], tmp);\
- tmp = p[1 * 64];\
- op1(sum1, (w1)[1 * 64], tmp);\
- op2(sum2, (w2)[1 * 64], tmp);\
- tmp = p[2 * 64];\
- op1(sum1, (w1)[2 * 64], tmp);\
- op2(sum2, (w2)[2 * 64], tmp);\
- tmp = p[3 * 64];\
- op1(sum1, (w1)[3 * 64], tmp);\
- op2(sum2, (w2)[3 * 64], tmp);\
- tmp = p[4 * 64];\
- op1(sum1, (w1)[4 * 64], tmp);\
- op2(sum2, (w2)[4 * 64], tmp);\
- tmp = p[5 * 64];\
- op1(sum1, (w1)[5 * 64], tmp);\
- op2(sum2, (w2)[5 * 64], tmp);\
- tmp = p[6 * 64];\
- op1(sum1, (w1)[6 * 64], tmp);\
- op2(sum2, (w2)[6 * 64], tmp);\
- tmp = p[7 * 64];\
- op1(sum1, (w1)[7 * 64], tmp);\
- op2(sum2, (w2)[7 * 64], tmp);\
-}
-
-void RENAME(ff_mpadsp_apply_window)(MPA_INT *synth_buf, MPA_INT *window,
- int *dither_state, OUT_INT *samples,
- int incr)
-{
- register const MPA_INT *w, *w2, *p;
- int j;
- OUT_INT *samples2;
-#if CONFIG_FLOAT
- float sum, sum2;
-#else
- int64_t sum, sum2;
-#endif
-
- /* copy to avoid wrap */
- memcpy(synth_buf + 512, synth_buf, 32 * sizeof(*synth_buf));
-
- samples2 = samples + 31 * incr;
- w = window;
- w2 = window + 31;
-
- sum = *dither_state;
- p = synth_buf + 16;
- SUM8(MACS, sum, w, p);
- p = synth_buf + 48;
- SUM8(MLSS, sum, w + 32, p);
- *samples = round_sample(&sum);
- samples += incr;
- w++;
-
- /* we calculate two samples at the same time to avoid one memory
- access per two sample */
- for(j=1;j<16;j++) {
- sum2 = 0;
- p = synth_buf + 16 + j;
- SUM8P2(sum, MACS, sum2, MLSS, w, w2, p);
- p = synth_buf + 48 - j;
- SUM8P2(sum, MLSS, sum2, MLSS, w + 32, w2 + 32, p);
-
- *samples = round_sample(&sum);
- samples += incr;
- sum += sum2;
- *samples2 = round_sample(&sum);
- samples2 -= incr;
- w++;
- w2--;
- }
-
- p = synth_buf + 32;
- SUM8(MLSS, sum, w + 32, p);
- *samples = round_sample(&sum);
- *dither_state= sum;
-}
-
-/* 32 sub band synthesis filter. Input: 32 sub band samples, Output:
- 32 samples. */
-void RENAME(ff_mpa_synth_filter)(MPADSPContext *s, MPA_INT *synth_buf_ptr,
- int *synth_buf_offset,
- MPA_INT *window, int *dither_state,
- OUT_INT *samples, int incr,
- MPA_INT *sb_samples)
-{
- MPA_INT *synth_buf;
- int offset;
-
- offset = *synth_buf_offset;
- synth_buf = synth_buf_ptr + offset;
-
- s->RENAME(dct32)(synth_buf, sb_samples);
- s->RENAME(apply_window)(synth_buf, window, dither_state, samples, incr);
-
- offset = (offset - 32) & 511;
- *synth_buf_offset = offset;
-}
-
-av_cold void RENAME(ff_mpa_synth_init)(MPA_INT *window)
-{
- int i, j;
-
- /* max = 18760, max sum over all 16 coefs : 44736 */
- for(i=0;i<257;i++) {
- INTFLOAT v;
- v = ff_mpa_enwindow[i];
-#if CONFIG_FLOAT
- v *= 1.0 / (1LL<<(16 + FRAC_BITS));
-#endif
- window[i] = v;
- if ((i & 63) != 0)
- v = -v;
- if (i != 0)
- window[512 - i] = v;
- }
-
-
- // Needed for avoiding shuffles in ASM implementations
- for(i=0; i < 8; i++)
- for(j=0; j < 16; j++)
- window[512+16*i+j] = window[64*i+32-j];
-
- for(i=0; i < 8; i++)
- for(j=0; j < 16; j++)
- window[512+128+16*i+j] = window[64*i+48-j];
-}
-
-void RENAME(ff_init_mpadsp_tabs)(void)
-{
- int i, j;
- /* compute mdct windows */
- for (i = 0; i < 36; i++) {
- for (j = 0; j < 4; j++) {
- double d;
-
- if (j == 2 && i % 3 != 1)
- continue;
-
- d = sin(M_PI * (i + 0.5) / 36.0);
- if (j == 1) {
- if (i >= 30) d = 0;
- else if (i >= 24) d = sin(M_PI * (i - 18 + 0.5) / 12.0);
- else if (i >= 18) d = 1;
- } else if (j == 3) {
- if (i < 6) d = 0;
- else if (i < 12) d = sin(M_PI * (i - 6 + 0.5) / 12.0);
- else if (i < 18) d = 1;
- }
- //merge last stage of imdct into the window coefficients
- d *= 0.5 * IMDCT_SCALAR / cos(M_PI * (2 * i + 19) / 72);
-
- if (j == 2)
- RENAME(ff_mdct_win)[j][i/3] = FIXHR((d / (1<<5)));
- else {
- int idx = i < 18 ? i : i + (MDCT_BUF_SIZE/2 - 18);
- RENAME(ff_mdct_win)[j][idx] = FIXHR((d / (1<<5)));
- }
- }
- }
-
- /* NOTE: we do frequency inversion adter the MDCT by changing
- the sign of the right window coefs */
- for (j = 0; j < 4; j++) {
- for (i = 0; i < MDCT_BUF_SIZE; i += 2) {
- RENAME(ff_mdct_win)[j + 4][i ] = RENAME(ff_mdct_win)[j][i ];
- RENAME(ff_mdct_win)[j + 4][i + 1] = -RENAME(ff_mdct_win)[j][i + 1];
- }
- }
-}
-/* cos(pi*i/18) */
-#define C1 FIXHR(0.98480775301220805936/2)
-#define C2 FIXHR(0.93969262078590838405/2)
-#define C3 FIXHR(0.86602540378443864676/2)
-#define C4 FIXHR(0.76604444311897803520/2)
-#define C5 FIXHR(0.64278760968653932632/2)
-#define C6 FIXHR(0.5/2)
-#define C7 FIXHR(0.34202014332566873304/2)
-#define C8 FIXHR(0.17364817766693034885/2)
-
-/* 0.5 / cos(pi*(2*i+1)/36) */
-static const INTFLOAT icos36[9] = {
- FIXR(0.50190991877167369479),
- FIXR(0.51763809020504152469), //0
- FIXR(0.55168895948124587824),
- FIXR(0.61038729438072803416),
- FIXR(0.70710678118654752439), //1
- FIXR(0.87172339781054900991),
- FIXR(1.18310079157624925896),
- FIXR(1.93185165257813657349), //2
- FIXR(5.73685662283492756461),
-};
-
-/* 0.5 / cos(pi*(2*i+1)/36) */
-static const INTFLOAT icos36h[9] = {
- FIXHR(0.50190991877167369479/2),
- FIXHR(0.51763809020504152469/2), //0
- FIXHR(0.55168895948124587824/2),
- FIXHR(0.61038729438072803416/2),
- FIXHR(0.70710678118654752439/2), //1
- FIXHR(0.87172339781054900991/2),
- FIXHR(1.18310079157624925896/4),
- FIXHR(1.93185165257813657349/4), //2
-// FIXHR(5.73685662283492756461),
-};
-
-/* using Lee like decomposition followed by hand coded 9 points DCT */
-static void imdct36(INTFLOAT *out, INTFLOAT *buf, INTFLOAT *in, INTFLOAT *win)
-{
- int i, j;
- INTFLOAT t0, t1, t2, t3, s0, s1, s2, s3;
- INTFLOAT tmp[18], *tmp1, *in1;
-
- for (i = 17; i >= 1; i--)
- in[i] += in[i-1];
- for (i = 17; i >= 3; i -= 2)
- in[i] += in[i-2];
-
- for (j = 0; j < 2; j++) {
- tmp1 = tmp + j;
- in1 = in + j;
-
- t2 = in1[2*4] + in1[2*8] - in1[2*2];
-
- t3 = in1[2*0] + SHR(in1[2*6],1);
- t1 = in1[2*0] - in1[2*6];
- tmp1[ 6] = t1 - SHR(t2,1);
- tmp1[16] = t1 + t2;
-
- t0 = MULH3(in1[2*2] + in1[2*4] , C2, 2);
- t1 = MULH3(in1[2*4] - in1[2*8] , -2*C8, 1);
- t2 = MULH3(in1[2*2] + in1[2*8] , -C4, 2);
-
- tmp1[10] = t3 - t0 - t2;
- tmp1[ 2] = t3 + t0 + t1;
- tmp1[14] = t3 + t2 - t1;
-
- tmp1[ 4] = MULH3(in1[2*5] + in1[2*7] - in1[2*1], -C3, 2);
- t2 = MULH3(in1[2*1] + in1[2*5], C1, 2);
- t3 = MULH3(in1[2*5] - in1[2*7], -2*C7, 1);
- t0 = MULH3(in1[2*3], C3, 2);
-
- t1 = MULH3(in1[2*1] + in1[2*7], -C5, 2);
-
- tmp1[ 0] = t2 + t3 + t0;
- tmp1[12] = t2 + t1 - t0;
- tmp1[ 8] = t3 - t1 - t0;
- }
-
- i = 0;
- for (j = 0; j < 4; j++) {
- t0 = tmp[i];
- t1 = tmp[i + 2];
- s0 = t1 + t0;
- s2 = t1 - t0;
-
- t2 = tmp[i + 1];
- t3 = tmp[i + 3];
- s1 = MULH3(t3 + t2, icos36h[ j], 2);
- s3 = MULLx(t3 - t2, icos36 [8 - j], FRAC_BITS);
-
- t0 = s0 + s1;
- t1 = s0 - s1;
- out[(9 + j) * SBLIMIT] = MULH3(t1, win[ 9 + j], 1) + buf[4*(9 + j)];
- out[(8 - j) * SBLIMIT] = MULH3(t1, win[ 8 - j], 1) + buf[4*(8 - j)];
- buf[4 * ( 9 + j )] = MULH3(t0, win[MDCT_BUF_SIZE/2 + 9 + j], 1);
- buf[4 * ( 8 - j )] = MULH3(t0, win[MDCT_BUF_SIZE/2 + 8 - j], 1);
-
- t0 = s2 + s3;
- t1 = s2 - s3;
- out[(9 + 8 - j) * SBLIMIT] = MULH3(t1, win[ 9 + 8 - j], 1) + buf[4*(9 + 8 - j)];
- out[ j * SBLIMIT] = MULH3(t1, win[ j], 1) + buf[4*( j)];
- buf[4 * ( 9 + 8 - j )] = MULH3(t0, win[MDCT_BUF_SIZE/2 + 9 + 8 - j], 1);
- buf[4 * ( j )] = MULH3(t0, win[MDCT_BUF_SIZE/2 + j], 1);
- i += 4;
- }
-
- s0 = tmp[16];
- s1 = MULH3(tmp[17], icos36h[4], 2);
- t0 = s0 + s1;
- t1 = s0 - s1;
- out[(9 + 4) * SBLIMIT] = MULH3(t1, win[ 9 + 4], 1) + buf[4*(9 + 4)];
- out[(8 - 4) * SBLIMIT] = MULH3(t1, win[ 8 - 4], 1) + buf[4*(8 - 4)];
- buf[4 * ( 9 + 4 )] = MULH3(t0, win[MDCT_BUF_SIZE/2 + 9 + 4], 1);
- buf[4 * ( 8 - 4 )] = MULH3(t0, win[MDCT_BUF_SIZE/2 + 8 - 4], 1);
-}
-
-void RENAME(ff_imdct36_blocks)(INTFLOAT *out, INTFLOAT *buf, INTFLOAT *in,
- int count, int switch_point, int block_type)
-{
- int j;
- for (j=0 ; j < count; j++) {
- /* apply window & overlap with previous buffer */
-
- /* select window */
- int win_idx = (switch_point && j < 2) ? 0 : block_type;
- INTFLOAT *win = RENAME(ff_mdct_win)[win_idx + (4 & -(j & 1))];
-
- imdct36(out, buf, in, win);
-
- in += 18;
- buf += ((j&3) != 3 ? 1 : (72-3));
- out++;
- }
-}
-
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpegvideo.c b/src/thirdparty/ffmpeg/libavcodec/mpegvideo.c
deleted file mode 100644
index 6fbbd6d80..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpegvideo.c
+++ /dev/null
@@ -1,3171 +0,0 @@
-/*
- * The simplest mpeg encoder (well, it was the simplest!)
- * Copyright (c) 2000,2001 Fabrice Bellard
- * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
- *
- * 4MV & hq & B-frame encoding stuff 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
- * The simplest mpeg encoder (well, it was the simplest!).
- */
-
-#include "libavutil/imgutils.h"
-#include "avcodec.h"
-#include "dsputil.h"
-#include "h264chroma.h"
-#include "internal.h"
-#include "mathops.h"
-#include "mpegvideo.h"
-#include "mjpegenc.h"
-#include "msmpeg4.h"
-#include "xvmc_internal.h"
-#include "thread.h"
-#include <limits.h>
-
-//#undef NDEBUG
-//#include <assert.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);
-
-
-//#define DEBUG
-
-
-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,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
-};
-
-const uint8_t ff_mpeg1_dc_scale_table[128] = {
-// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-};
-
-static const uint8_t mpeg2_dc_scale_table1[128] = {
-// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
- 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, 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, 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,
-};
-
-static const uint8_t mpeg2_dc_scale_table2[128] = {
-// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-};
-
-static const uint8_t mpeg2_dc_scale_table3[128] = {
-// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
- 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,
-};
-
-const uint8_t *const ff_mpeg2_dc_scale_table[4] = {
- ff_mpeg1_dc_scale_table,
- mpeg2_dc_scale_table1,
- mpeg2_dc_scale_table2,
- mpeg2_dc_scale_table3,
-};
-
-const enum AVPixelFormat ff_pixfmt_list_420[] = {
- AV_PIX_FMT_YUV420P,
- AV_PIX_FMT_NONE
-};
-
-const enum AVPixelFormat ff_hwaccel_pixfmt_list_420[] = {
-#if CONFIG_DXVA2
- AV_PIX_FMT_DXVA2_VLD,
-#endif
-#if CONFIG_VAAPI
- AV_PIX_FMT_VAAPI_VLD,
-#endif
-#if CONFIG_VDA
- AV_PIX_FMT_VDA_VLD,
-#endif
-#if CONFIG_VDPAU
- AV_PIX_FMT_VDPAU,
-#endif
- AV_PIX_FMT_YUV420P,
- AV_PIX_FMT_NONE
-};
-
-const uint8_t *avpriv_mpv_find_start_code(const uint8_t *av_restrict p,
- const uint8_t *end,
- uint32_t *av_restrict state)
-{
- int i;
-
- assert(p <= end);
- if (p >= end)
- return end;
-
- for (i = 0; i < 3; i++) {
- uint32_t tmp = *state << 8;
- *state = tmp + *(p++);
- if (tmp == 0x100 || p == end)
- return p;
- }
-
- while (p < end) {
- if (p[-1] > 1 ) p += 3;
- else if (p[-2] ) p += 2;
- else if (p[-3]|(p[-1]-1)) p++;
- else {
- p++;
- break;
- }
- }
-
- p = FFMIN(p, end) - 4;
- *state = AV_RB32(p);
-
- return p + 4;
-}
-
-/* init common dct for both encoder and decoder */
-av_cold int ff_dct_common_init(MpegEncContext *s)
-{
- ff_dsputil_init(&s->dsp, s->avctx);
- ff_h264chroma_init(&s->h264chroma, 8); //for lowres
- ff_videodsp_init(&s->vdsp, s->avctx->bits_per_raw_sample);
-
- 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;
- s->dct_unquantize_mpeg1_inter = dct_unquantize_mpeg1_inter_c;
- s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_c;
- if (s->flags & CODEC_FLAG_BITEXACT)
- s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_bitexact;
- s->dct_unquantize_mpeg2_inter = dct_unquantize_mpeg2_inter_c;
-
-#if ARCH_X86
- ff_MPV_common_init_x86(s);
-#elif ARCH_ALPHA
- ff_MPV_common_init_axp(s);
-#elif ARCH_ARM
- ff_MPV_common_init_arm(s);
-#elif HAVE_ALTIVEC
- ff_MPV_common_init_altivec(s);
-#elif ARCH_BFIN
- ff_MPV_common_init_bfin(s);
-#endif
-
- /* load & permutate scantables
- * note: only wmv uses different ones
- */
- 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);
- } else {
- ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_zigzag_direct);
- ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_zigzag_direct);
- }
- ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_alternate_horizontal_scan);
- ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan);
-
- return 0;
-}
-
-void ff_copy_picture(Picture *dst, Picture *src)
-{
- *dst = *src;
- dst->f.type = FF_BUFFER_TYPE_COPY;
-}
-
-/**
- * Release a frame buffer
- */
-static void free_frame_buffer(MpegEncContext *s, Picture *pic)
-{
- pic->period_since_free = 0;
- /* 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->f);
- else
- avcodec_default_release_buffer(s->avctx, &pic->f);
- av_freep(&pic->f.hwaccel_picture_private);
-}
-
-int ff_mpv_frame_size_alloc(MpegEncContext *s, int linesize)
-{
- int alloc_size = FFALIGN(FFABS(linesize) + 64, 32);
-
- // edge emu needs blocksize + filter length - 1
- // (= 17x17 for halfpel / 21x21 for h264)
- // VC1 computes luma and chroma simultaneously and needs 19X19 + 9x9
- // at uvlinesize. It supports only YUV420 so 24x24 is enough
- // linesize * interlaced * MBsize
- FF_ALLOCZ_OR_GOTO(s->avctx, s->edge_emu_buffer, alloc_size * 4 * 24,
- fail);
-
- FF_ALLOCZ_OR_GOTO(s->avctx, s->me.scratchpad, alloc_size * 4 * 16 * 2,
- fail)
- s->me.temp = s->me.scratchpad;
- s->rd_scratchpad = s->me.scratchpad;
- s->b_scratchpad = s->me.scratchpad;
- s->obmc_scratchpad = s->me.scratchpad + 16;
-
- return 0;
-fail:
- av_freep(&s->edge_emu_buffer);
- return AVERROR(ENOMEM);
-}
-
-/**
- * Allocate a frame buffer
- */
-static int alloc_frame_buffer(MpegEncContext *s, Picture *pic)
-{
- int r, ret;
-
- if (s->avctx->hwaccel) {
- assert(!pic->f.hwaccel_picture_private);
- if (s->avctx->hwaccel->priv_data_size) {
- pic->f.hwaccel_picture_private = av_mallocz(s->avctx->hwaccel->priv_data_size);
- if (!pic->f.hwaccel_picture_private) {
- av_log(s->avctx, AV_LOG_ERROR, "alloc_frame_buffer() failed (hwaccel private data allocation)\n");
- return -1;
- }
- }
- }
-
- if (s->codec_id != AV_CODEC_ID_WMV3IMAGE &&
- s->codec_id != AV_CODEC_ID_VC1IMAGE &&
- s->codec_id != AV_CODEC_ID_MSS2)
- r = ff_thread_get_buffer(s->avctx, &pic->f);
- else
- r = avcodec_default_get_buffer(s->avctx, &pic->f);
-
- if (r < 0 || !pic->f.type || !pic->f.data[0]) {
- av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %p)\n",
- r, pic->f.type, pic->f.data[0]);
- av_freep(&pic->f.hwaccel_picture_private);
- return -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");
- free_frame_buffer(s, pic);
- return -1;
- }
-
- if (pic->f.linesize[1] != pic->f.linesize[2]) {
- av_log(s->avctx, AV_LOG_ERROR,
- "get_buffer() failed (uv stride mismatch)\n");
- free_frame_buffer(s, pic);
- return -1;
- }
-
- if (!s->edge_emu_buffer &&
- (ret = ff_mpv_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");
- free_frame_buffer(s, pic);
- return ret;
- }
-
- return 0;
-}
-
-/**
- * Allocate a Picture.
- * The pixels are allocated/set by calling get_buffer() if shared = 0
- */
-int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared)
-{
- const int big_mb_num = s->mb_stride * (s->mb_height + 1) + 1;
-
- // the + 1 is needed so memset(,,stride*height) does not sig11
-
- const int mb_array_size = s->mb_stride * s->mb_height;
- const int b8_array_size = s->b8_stride * s->mb_height * 2;
- const int b4_array_size = s->b4_stride * s->mb_height * 4;
- int i;
- int r = -1;
-
- if (shared) {
- assert(pic->f.data[0]);
- assert(pic->f.type == 0 || pic->f.type == FF_BUFFER_TYPE_SHARED);
- pic->f.type = FF_BUFFER_TYPE_SHARED;
- } else {
- assert(!pic->f.data[0]);
-
- if (alloc_frame_buffer(s, pic) < 0)
- return -1;
-
- s->linesize = pic->f.linesize[0];
- s->uvlinesize = pic->f.linesize[1];
- }
-
- if (pic->f.qscale_table == NULL) {
- if (s->encoding) {
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->mb_var,
- mb_array_size * sizeof(int16_t), fail)
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->mc_mb_var,
- mb_array_size * sizeof(int16_t), fail)
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->mb_mean,
- mb_array_size * sizeof(int8_t ), fail)
- }
-
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->f.mbskip_table,
- mb_array_size * sizeof(uint8_t) + 2, fail)// the + 2 is for the slice end check
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->qscale_table_base,
- (big_mb_num + s->mb_stride) * sizeof(uint8_t),
- fail)
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->mb_type_base,
- (big_mb_num + s->mb_stride) * sizeof(uint32_t),
- fail)
- pic->f.mb_type = pic->mb_type_base + 2 * s->mb_stride + 1;
- pic->f.qscale_table = pic->qscale_table_base + 2 * s->mb_stride + 1;
- if (s->out_format == FMT_H264) {
- for (i = 0; i < 2; i++) {
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->motion_val_base[i],
- 2 * (b4_array_size + 4) * sizeof(int16_t),
- fail)
- pic->f.motion_val[i] = pic->motion_val_base[i] + 4;
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->f.ref_index[i],
- 4 * mb_array_size * sizeof(uint8_t), fail)
- }
- pic->f.motion_subsample_log2 = 2;
- } else if (s->out_format == FMT_H263 || s->encoding ||
- (s->avctx->debug & FF_DEBUG_MV) || s->avctx->debug_mv) {
- for (i = 0; i < 2; i++) {
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->motion_val_base[i],
- 2 * (b8_array_size + 4) * sizeof(int16_t),
- fail)
- pic->f.motion_val[i] = pic->motion_val_base[i] + 4;
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->f.ref_index[i],
- 4 * mb_array_size * sizeof(uint8_t), fail)
- }
- pic->f.motion_subsample_log2 = 3;
- }
- if (s->avctx->debug&FF_DEBUG_DCT_COEFF) {
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->f.dct_coeff,
- 64 * mb_array_size * sizeof(int16_t) * 6, fail)
- }
- pic->f.qstride = s->mb_stride;
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->f.pan_scan,
- 1 * sizeof(AVPanScan), fail)
- }
-
- pic->owner2 = s;
-
- return 0;
-fail: // for the FF_ALLOCZ_OR_GOTO macro
- if (r >= 0)
- free_frame_buffer(s, pic);
- return -1;
-}
-
-/**
- * Deallocate a picture.
- */
-static void free_picture(MpegEncContext *s, Picture *pic)
-{
- int i;
-
- if (pic->f.data[0] && pic->f.type != FF_BUFFER_TYPE_SHARED) {
- free_frame_buffer(s, pic);
- }
-
- av_freep(&pic->mb_var);
- av_freep(&pic->mc_mb_var);
- av_freep(&pic->mb_mean);
- av_freep(&pic->f.mbskip_table);
- av_freep(&pic->qscale_table_base);
- pic->f.qscale_table = NULL;
- av_freep(&pic->mb_type_base);
- pic->f.mb_type = NULL;
- av_freep(&pic->f.dct_coeff);
- av_freep(&pic->f.pan_scan);
- pic->f.mb_type = NULL;
- for (i = 0; i < 2; i++) {
- av_freep(&pic->motion_val_base[i]);
- av_freep(&pic->f.ref_index[i]);
- pic->f.motion_val[i] = NULL;
- }
-
- if (pic->f.type == FF_BUFFER_TYPE_SHARED) {
- for (i = 0; i < 4; i++) {
- pic->f.base[i] =
- pic->f.data[i] = NULL;
- }
- pic->f.type = 0;
- }
-}
-
-static int init_duplicate_context(MpegEncContext *s)
-{
- int y_size = s->b8_stride * (2 * s->mb_height + 1);
- int c_size = s->mb_stride * (s->mb_height + 1);
- int yc_size = y_size + 2 * c_size;
- int i;
-
- s->edge_emu_buffer =
- s->me.scratchpad =
- s->me.temp =
- s->rd_scratchpad =
- s->b_scratchpad =
- s->obmc_scratchpad = NULL;
-
- if (s->encoding) {
- FF_ALLOCZ_OR_GOTO(s->avctx, s->me.map,
- ME_MAP_SIZE * sizeof(uint32_t), fail)
- FF_ALLOCZ_OR_GOTO(s->avctx, s->me.score_map,
- ME_MAP_SIZE * sizeof(uint32_t), fail)
- if (s->avctx->noise_reduction) {
- FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_error_sum,
- 2 * 64 * sizeof(int), fail)
- }
- }
- FF_ALLOCZ_OR_GOTO(s->avctx, s->blocks, 64 * 12 * 2 * sizeof(int16_t), fail)
- s->block = s->blocks[0];
-
- for (i = 0; i < 12; i++) {
- s->pblocks[i] = &s->block[i];
- }
-
- if (s->out_format == FMT_H263) {
- /* ac values */
- FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_val_base,
- yc_size * sizeof(int16_t) * 16, fail);
- s->ac_val[0] = s->ac_val_base + s->b8_stride + 1;
- s->ac_val[1] = s->ac_val_base + y_size + s->mb_stride + 1;
- s->ac_val[2] = s->ac_val[1] + c_size;
- }
-
- return 0;
-fail:
- return -1; // free() through ff_MPV_common_end()
-}
-
-static void free_duplicate_context(MpegEncContext *s)
-{
- if (s == NULL)
- return;
-
- av_freep(&s->edge_emu_buffer);
- av_freep(&s->me.scratchpad);
- s->me.temp =
- s->rd_scratchpad =
- s->b_scratchpad =
- s->obmc_scratchpad = NULL;
-
- av_freep(&s->dct_error_sum);
- av_freep(&s->me.map);
- av_freep(&s->me.score_map);
- av_freep(&s->blocks);
- av_freep(&s->ac_val_base);
- s->block = NULL;
-}
-
-static void backup_duplicate_context(MpegEncContext *bak, MpegEncContext *src)
-{
-#define COPY(a) bak->a = src->a
- COPY(edge_emu_buffer);
- COPY(me.scratchpad);
- COPY(me.temp);
- COPY(rd_scratchpad);
- COPY(b_scratchpad);
- COPY(obmc_scratchpad);
- COPY(me.map);
- COPY(me.score_map);
- COPY(blocks);
- COPY(block);
- COPY(start_mb_y);
- COPY(end_mb_y);
- COPY(me.map_generation);
- COPY(pb);
- COPY(dct_error_sum);
- COPY(dct_count[0]);
- COPY(dct_count[1]);
- COPY(ac_val_base);
- COPY(ac_val[0]);
- COPY(ac_val[1]);
- COPY(ac_val[2]);
-#undef COPY
-}
-
-int ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src)
-{
- MpegEncContext bak;
- int i, ret;
- // FIXME copy only needed parts
- // START_TIMER
- backup_duplicate_context(&bak, dst);
- memcpy(dst, src, sizeof(MpegEncContext));
- backup_duplicate_context(dst, &bak);
- for (i = 0; i < 12; i++) {
- dst->pblocks[i] = &dst->block[i];
- }
- if (!dst->edge_emu_buffer &&
- (ret = ff_mpv_frame_size_alloc(dst, dst->linesize)) < 0) {
- av_log(dst->avctx, AV_LOG_ERROR, "failed to allocate context "
- "scratch buffers.\n");
- return ret;
- }
- // STOP_TIMER("update_duplicate_context")
- // about 10k cycles / 0.01 sec for 1000frames on 1ghz with 2 threads
- return 0;
-}
-
-int ff_mpeg_update_thread_context(AVCodecContext *dst,
- const AVCodecContext *src)
-{
- int i;
- int err;
- MpegEncContext *s = dst->priv_data, *s1 = src->priv_data;
-
- if (dst == src)
- return 0;
-
- av_assert0(s != s1);
-
- // FIXME can parameters change on I-frames?
- // in that case dst may need a reinit
- if (!s->context_initialized) {
- memcpy(s, s1, sizeof(MpegEncContext));
-
- s->avctx = dst;
- s->bitstream_buffer = NULL;
- s->bitstream_buffer_size = s->allocated_bitstream_buffer_size = 0;
-
- if (s1->context_initialized){
- s->picture_range_start += MAX_PICTURE_COUNT;
- s->picture_range_end += MAX_PICTURE_COUNT;
- if((err = ff_MPV_common_init(s)) < 0){
- memset(s, 0, sizeof(MpegEncContext));
- s->avctx = dst;
- return err;
- }
- }
- }
-
- if (s->height != s1->height || s->width != s1->width || s->context_reinit) {
- s->context_reinit = 0;
- s->height = s1->height;
- s->width = s1->width;
- if ((err = ff_MPV_common_frame_size_change(s)) < 0)
- return err;
- }
-
- s->avctx->coded_height = s1->avctx->coded_height;
- s->avctx->coded_width = s1->avctx->coded_width;
- s->avctx->width = s1->avctx->width;
- s->avctx->height = s1->avctx->height;
-
- s->coded_picture_number = s1->coded_picture_number;
- s->picture_number = s1->picture_number;
- s->input_picture_number = s1->input_picture_number;
-
- av_assert0(!s->picture || s->picture != s1->picture);
- memcpy(s->picture, s1->picture, s1->picture_count * sizeof(Picture));
- memcpy(&s->last_picture, &s1->last_picture,
- (char *) &s1->last_picture_ptr - (char *) &s1->last_picture);
-
- // reset s->picture[].f.extended_data to s->picture[].f.data
- for (i = 0; i < s->picture_count; i++) {
- s->picture[i].f.extended_data = s->picture[i].f.data;
- s->picture[i].period_since_free ++;
- }
-
- s->last_picture_ptr = REBASE_PICTURE(s1->last_picture_ptr, s, s1);
- s->current_picture_ptr = REBASE_PICTURE(s1->current_picture_ptr, s, s1);
- s->next_picture_ptr = REBASE_PICTURE(s1->next_picture_ptr, s, s1);
-
- // Error/bug resilience
- s->next_p_frame_damaged = s1->next_p_frame_damaged;
- s->workaround_bugs = s1->workaround_bugs;
- s->padding_bug_score = s1->padding_bug_score;
-
- // MPEG4 timing info
- memcpy(&s->time_increment_bits, &s1->time_increment_bits,
- (char *) &s1->shape - (char *) &s1->time_increment_bits);
-
- // B-frame info
- s->max_b_frames = s1->max_b_frames;
- s->low_delay = s1->low_delay;
- s->droppable = s1->droppable;
-
- // DivX handling (doesn't work)
- s->divx_packed = s1->divx_packed;
-
- if (s1->bitstream_buffer) {
- if (s1->bitstream_buffer_size +
- FF_INPUT_BUFFER_PADDING_SIZE > s->allocated_bitstream_buffer_size)
- av_fast_malloc(&s->bitstream_buffer,
- &s->allocated_bitstream_buffer_size,
- s1->allocated_bitstream_buffer_size);
- s->bitstream_buffer_size = s1->bitstream_buffer_size;
- memcpy(s->bitstream_buffer, s1->bitstream_buffer,
- s1->bitstream_buffer_size);
- memset(s->bitstream_buffer + s->bitstream_buffer_size, 0,
- FF_INPUT_BUFFER_PADDING_SIZE);
- }
-
- // linesize dependend scratch buffer allocation
- if (!s->edge_emu_buffer)
- if (s1->linesize) {
- if (ff_mpv_frame_size_alloc(s, s1->linesize) < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "Failed to allocate context "
- "scratch buffers.\n");
- return AVERROR(ENOMEM);
- }
- } else {
- av_log(s->avctx, AV_LOG_ERROR, "Context scratch buffers could not "
- "be allocated due to unknown size.\n");
- }
-
- // MPEG2/interlacing info
- memcpy(&s->progressive_sequence, &s1->progressive_sequence,
- (char *) &s1->rtp_mode - (char *) &s1->progressive_sequence);
-
- 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;
-
- if (s1->pict_type != AV_PICTURE_TYPE_B) {
- s->last_non_b_pict_type = s1->pict_type;
- }
- }
-
- return 0;
-}
-
-/**
- * Set the given MpegEncContext to common defaults
- * (same for encoding and decoding).
- * The changed fields will not depend upon the
- * prior state of the MpegEncContext.
- */
-void ff_MPV_common_defaults(MpegEncContext *s)
-{
- s->y_dc_scale_table =
- s->c_dc_scale_table = ff_mpeg1_dc_scale_table;
- s->chroma_qscale_table = ff_default_chroma_qscale_table;
- s->progressive_frame = 1;
- s->progressive_sequence = 1;
- s->picture_structure = PICT_FRAME;
-
- s->coded_picture_number = 0;
- s->picture_number = 0;
- s->input_picture_number = 0;
-
- s->picture_in_gop_number = 0;
-
- s->f_code = 1;
- s->b_code = 1;
-
- s->picture_range_start = 0;
- s->picture_range_end = MAX_PICTURE_COUNT;
-
- s->slice_context_count = 1;
-}
-
-/**
- * Set the given MpegEncContext to defaults for decoding.
- * the changed fields will not depend upon
- * the prior state of the MpegEncContext.
- */
-void ff_MPV_decode_defaults(MpegEncContext *s)
-{
- ff_MPV_common_defaults(s);
-}
-
-/**
- * Initialize and allocates MpegEncContext fields dependent on the resolution.
- */
-static int init_context_frame(MpegEncContext *s)
-{
- int y_size, c_size, yc_size, i, mb_array_size, mv_table_size, x, y;
-
- 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
- * in decode_header if needed */
- s->h_edge_pos = s->mb_width * 16;
- s->v_edge_pos = s->mb_height * 16;
-
- s->mb_num = s->mb_width * s->mb_height;
-
- s->block_wrap[0] =
- s->block_wrap[1] =
- s->block_wrap[2] =
- s->block_wrap[3] = s->b8_stride;
- s->block_wrap[4] =
- s->block_wrap[5] = s->mb_stride;
-
- y_size = s->b8_stride * (2 * s->mb_height + 1);
- c_size = s->mb_stride * (s->mb_height + 1);
- yc_size = y_size + 2 * c_size;
-
- 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++)
- s->mb_index2xy[x + y * s->mb_width] = x + y * s->mb_stride;
-
- s->mb_index2xy[s->mb_height * s->mb_width] = (s->mb_height - 1) * s->mb_stride + s->mb_width; // FIXME really needed?
-
- if (s->encoding) {
- /* Allocate MV tables */
- FF_ALLOCZ_OR_GOTO(s->avctx, s->p_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail)
- FF_ALLOCZ_OR_GOTO(s->avctx, s->b_forw_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail)
- FF_ALLOCZ_OR_GOTO(s->avctx, s->b_back_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail)
- FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_forw_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail)
- FF_ALLOCZ_OR_GOTO(s->avctx, s->b_bidir_back_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail)
- FF_ALLOCZ_OR_GOTO(s->avctx, s->b_direct_mv_table_base, mv_table_size * 2 * sizeof(int16_t), fail)
- s->p_mv_table = s->p_mv_table_base + s->mb_stride + 1;
- s->b_forw_mv_table = s->b_forw_mv_table_base + s->mb_stride + 1;
- s->b_back_mv_table = s->b_back_mv_table_base + s->mb_stride + 1;
- s->b_bidir_forw_mv_table = s->b_bidir_forw_mv_table_base + s->mb_stride + 1;
- s->b_bidir_back_mv_table = s->b_bidir_back_mv_table_base + s->mb_stride + 1;
- s->b_direct_mv_table = s->b_direct_mv_table_base + s->mb_stride + 1;
-
- /* Allocate MB type table */
- FF_ALLOCZ_OR_GOTO(s->avctx, s->mb_type, mb_array_size * sizeof(uint16_t), fail) // needed for encoding
-
- FF_ALLOCZ_OR_GOTO(s->avctx, s->lambda_table, mb_array_size * sizeof(int), fail)
-
- FF_ALLOC_OR_GOTO(s->avctx, s->cplx_tab,
- mb_array_size * sizeof(float), fail);
- FF_ALLOC_OR_GOTO(s->avctx, s->bits_tab,
- mb_array_size * sizeof(float), fail);
-
- }
-
- FF_ALLOC_OR_GOTO(s->avctx, s->er_temp_buffer,
- mb_array_size * sizeof(uint8_t), fail);
- FF_ALLOCZ_OR_GOTO(s->avctx, s->error_status_table,
- mb_array_size * sizeof(uint8_t), fail);
-
- if (s->codec_id == AV_CODEC_ID_MPEG4 || (s->flags & CODEC_FLAG_INTERLACED_ME)) {
- /* interlaced direct mode decoding tables */
- for (i = 0; i < 2; i++) {
- int j, k;
- for (j = 0; j < 2; j++) {
- for (k = 0; k < 2; k++) {
- FF_ALLOCZ_OR_GOTO(s->avctx,
- s->b_field_mv_table_base[i][j][k],
- mv_table_size * 2 * sizeof(int16_t),
- fail);
- s->b_field_mv_table[i][j][k] = s->b_field_mv_table_base[i][j][k] +
- s->mb_stride + 1;
- }
- FF_ALLOCZ_OR_GOTO(s->avctx, s->b_field_select_table [i][j], mb_array_size * 2 * sizeof(uint8_t), fail)
- FF_ALLOCZ_OR_GOTO(s->avctx, s->p_field_mv_table_base[i][j], mv_table_size * 2 * sizeof(int16_t), fail)
- s->p_field_mv_table[i][j] = s->p_field_mv_table_base[i][j] + s->mb_stride + 1;
- }
- FF_ALLOCZ_OR_GOTO(s->avctx, s->p_field_select_table[i], mb_array_size * 2 * sizeof(uint8_t), fail)
- }
- }
- if (s->out_format == FMT_H263) {
- /* cbp values */
- FF_ALLOCZ_OR_GOTO(s->avctx, s->coded_block_base, y_size, fail);
- s->coded_block = s->coded_block_base + s->b8_stride + 1;
-
- /* cbp, ac_pred, pred_dir */
- FF_ALLOCZ_OR_GOTO(s->avctx, s->cbp_table , mb_array_size * sizeof(uint8_t), fail);
- FF_ALLOCZ_OR_GOTO(s->avctx, s->pred_dir_table, mb_array_size * sizeof(uint8_t), fail);
- }
-
- if (s->h263_pred || s->h263_plus || !s->encoding) {
- /* dc values */
- // MN: we need these for error resilience of intra-frames
- FF_ALLOCZ_OR_GOTO(s->avctx, s->dc_val_base, yc_size * sizeof(int16_t), fail);
- s->dc_val[0] = s->dc_val_base + s->b8_stride + 1;
- s->dc_val[1] = s->dc_val_base + y_size + s->mb_stride + 1;
- s->dc_val[2] = s->dc_val[1] + c_size;
- for (i = 0; i < yc_size; i++)
- s->dc_val_base[i] = 1024;
- }
-
- /* which mb is a intra block */
- FF_ALLOCZ_OR_GOTO(s->avctx, s->mbintra_table, mb_array_size, fail);
- memset(s->mbintra_table, 1, mb_array_size);
-
- /* init macroblock skip table */
- FF_ALLOCZ_OR_GOTO(s->avctx, s->mbskip_table, mb_array_size + 2, fail);
- // Note the + 1 is for a quicker mpeg4 slice_end detection
-
- return 0;
-fail:
- return AVERROR(ENOMEM);
-}
-
-/**
- * init common structure for both encoder and decoder.
- * this assumes that some variables like width/height are already set
- */
-av_cold int ff_MPV_common_init(MpegEncContext *s)
-{
- int i;
- int nb_slices = (HAVE_THREADS &&
- s->avctx->active_thread_type & FF_THREAD_SLICE) ?
- s->avctx->thread_count : 1;
-
- if (s->encoding && s->avctx->slices)
- nb_slices = s->avctx->slices;
-
- if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO && !s->progressive_sequence)
- s->mb_height = (s->height + 31) / 32 * 2;
- else if (s->codec_id != AV_CODEC_ID_H264)
- s->mb_height = (s->height + 15) / 16;
-
- if (s->avctx->pix_fmt == AV_PIX_FMT_NONE) {
- av_log(s->avctx, AV_LOG_ERROR,
- "decoding to AV_PIX_FMT_NONE is not supported.\n");
- return -1;
- }
-
- if (nb_slices > MAX_THREADS || (nb_slices > s->mb_height && s->mb_height)) {
- int max_slices;
- if (s->mb_height)
- max_slices = FFMIN(MAX_THREADS, s->mb_height);
- else
- max_slices = MAX_THREADS;
- av_log(s->avctx, AV_LOG_WARNING, "too many threads/slices (%d),"
- " reducing to %d\n", nb_slices, max_slices);
- nb_slices = max_slices;
- }
-
- if ((s->width || s->height) &&
- av_image_check_size(s->width, s->height, 0, s->avctx))
- return -1;
-
- ff_dct_common_init(s);
-
- s->flags = s->avctx->flags;
- s->flags2 = s->avctx->flags2;
-
- /* set chroma shifts */
- avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &s->chroma_x_shift, &s->chroma_y_shift);
-
- /* convert fourcc to upper case */
- s->codec_tag = avpriv_toupper4(s->avctx->codec_tag);
- s->stream_codec_tag = avpriv_toupper4(s->avctx->stream_codec_tag);
-
- s->avctx->coded_frame = &s->current_picture.f;
-
- if (s->encoding) {
- if (s->msmpeg4_version) {
- FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_stats,
- 2 * 2 * (MAX_LEVEL + 1) *
- (MAX_RUN + 1) * 2 * sizeof(int), fail);
- }
- FF_ALLOCZ_OR_GOTO(s->avctx, s->avctx->stats_out, 256, fail);
-
- FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix, 64 * 32 * sizeof(int), fail)
- FF_ALLOCZ_OR_GOTO(s->avctx, s->q_chroma_intra_matrix, 64 * 32 * sizeof(int), fail)
- FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix, 64 * 32 * sizeof(int), fail)
- FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix16, 64 * 32 * 2 * sizeof(uint16_t), fail)
- FF_ALLOCZ_OR_GOTO(s->avctx, s->q_chroma_intra_matrix16, 64 * 32 * 2 * sizeof(uint16_t), fail)
- FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix16, 64 * 32 * 2 * sizeof(uint16_t), fail)
- FF_ALLOCZ_OR_GOTO(s->avctx, s->input_picture, MAX_PICTURE_COUNT * sizeof(Picture *), fail)
- FF_ALLOCZ_OR_GOTO(s->avctx, s->reordered_input_picture, MAX_PICTURE_COUNT * sizeof(Picture *), fail)
-
- if (s->avctx->noise_reduction) {
- FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_offset, 2 * 64 * sizeof(uint16_t), fail);
- }
- }
-
- s->picture_count = MAX_PICTURE_COUNT * FFMAX(1, s->avctx->thread_count);
- FF_ALLOCZ_OR_GOTO(s->avctx, s->picture,
- s->picture_count * sizeof(Picture), fail);
- for (i = 0; i < s->picture_count; i++) {
- avcodec_get_frame_defaults(&s->picture[i].f);
- }
-
- if (init_context_frame(s))
- goto fail;
-
- s->parse_context.state = -1;
-
- s->context_initialized = 1;
- s->thread_context[0] = s;
-
-// if (s->width && s->height) {
- if (nb_slices > 1) {
- for (i = 1; i < nb_slices; i++) {
- s->thread_context[i] = av_malloc(sizeof(MpegEncContext));
- memcpy(s->thread_context[i], s, sizeof(MpegEncContext));
- }
-
- for (i = 0; i < nb_slices; i++) {
- if (init_duplicate_context(s->thread_context[i]) < 0)
- goto fail;
- s->thread_context[i]->start_mb_y =
- (s->mb_height * (i) + nb_slices / 2) / nb_slices;
- s->thread_context[i]->end_mb_y =
- (s->mb_height * (i + 1) + nb_slices / 2) / nb_slices;
- }
- } else {
- if (init_duplicate_context(s) < 0)
- goto fail;
- s->start_mb_y = 0;
- s->end_mb_y = s->mb_height;
- }
- s->slice_context_count = nb_slices;
-// }
-
- return 0;
- fail:
- ff_MPV_common_end(s);
- return -1;
-}
-
-/**
- * Frees and resets MpegEncContext fields depending on the resolution.
- * Is used during resolution changes to avoid a full reinitialization of the
- * codec.
- */
-static int free_context_frame(MpegEncContext *s)
-{
- int i, j, k;
-
- av_freep(&s->mb_type);
- av_freep(&s->p_mv_table_base);
- av_freep(&s->b_forw_mv_table_base);
- av_freep(&s->b_back_mv_table_base);
- av_freep(&s->b_bidir_forw_mv_table_base);
- av_freep(&s->b_bidir_back_mv_table_base);
- av_freep(&s->b_direct_mv_table_base);
- s->p_mv_table = NULL;
- s->b_forw_mv_table = NULL;
- s->b_back_mv_table = NULL;
- s->b_bidir_forw_mv_table = NULL;
- s->b_bidir_back_mv_table = NULL;
- s->b_direct_mv_table = NULL;
- for (i = 0; i < 2; i++) {
- for (j = 0; j < 2; j++) {
- for (k = 0; k < 2; k++) {
- av_freep(&s->b_field_mv_table_base[i][j][k]);
- s->b_field_mv_table[i][j][k] = NULL;
- }
- av_freep(&s->b_field_select_table[i][j]);
- av_freep(&s->p_field_mv_table_base[i][j]);
- s->p_field_mv_table[i][j] = NULL;
- }
- av_freep(&s->p_field_select_table[i]);
- }
-
- av_freep(&s->dc_val_base);
- av_freep(&s->coded_block_base);
- av_freep(&s->mbintra_table);
- av_freep(&s->cbp_table);
- av_freep(&s->pred_dir_table);
-
- av_freep(&s->mbskip_table);
-
- av_freep(&s->error_status_table);
- av_freep(&s->er_temp_buffer);
- av_freep(&s->mb_index2xy);
- av_freep(&s->lambda_table);
-
- av_freep(&s->cplx_tab);
- av_freep(&s->bits_tab);
-
- s->linesize = s->uvlinesize = 0;
-
- for (i = 0; i < 3; i++)
- av_freep(&s->visualization_buffer[i]);
-
- return 0;
-}
-
-int ff_MPV_common_frame_size_change(MpegEncContext *s)
-{
- int i, err = 0;
-
- if (s->slice_context_count > 1) {
- for (i = 0; i < s->slice_context_count; i++) {
- free_duplicate_context(s->thread_context[i]);
- }
- for (i = 1; i < s->slice_context_count; i++) {
- av_freep(&s->thread_context[i]);
- }
- } else
- free_duplicate_context(s);
-
- free_context_frame(s);
-
- if (s->picture)
- for (i = 0; i < s->picture_count; i++) {
- s->picture[i].needs_realloc = 1;
- }
-
- s->last_picture_ptr =
- s->next_picture_ptr =
- s->current_picture_ptr = NULL;
-
- // init
- if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO && !s->progressive_sequence)
- s->mb_height = (s->height + 31) / 32 * 2;
- else if (s->codec_id != AV_CODEC_ID_H264)
- s->mb_height = (s->height + 15) / 16;
-
- if ((s->width || s->height) &&
- av_image_check_size(s->width, s->height, 0, s->avctx))
- return AVERROR_INVALIDDATA;
-
- if ((err = init_context_frame(s)))
- goto fail;
-
- s->thread_context[0] = s;
-
- if (s->width && s->height) {
- int nb_slices = s->slice_context_count;
- if (nb_slices > 1) {
- for (i = 1; i < nb_slices; i++) {
- s->thread_context[i] = av_malloc(sizeof(MpegEncContext));
- memcpy(s->thread_context[i], s, sizeof(MpegEncContext));
- }
-
- for (i = 0; i < nb_slices; i++) {
- if (init_duplicate_context(s->thread_context[i]) < 0)
- goto fail;
- s->thread_context[i]->start_mb_y =
- (s->mb_height * (i) + nb_slices / 2) / nb_slices;
- s->thread_context[i]->end_mb_y =
- (s->mb_height * (i + 1) + nb_slices / 2) / nb_slices;
- }
- } else {
- if (init_duplicate_context(s) < 0)
- goto fail;
- s->start_mb_y = 0;
- s->end_mb_y = s->mb_height;
- }
- s->slice_context_count = nb_slices;
- }
-
- return 0;
- fail:
- ff_MPV_common_end(s);
- return err;
-}
-
-/* init common structure for both encoder and decoder */
-void ff_MPV_common_end(MpegEncContext *s)
-{
- int i;
-
- if (s->slice_context_count > 1) {
- for (i = 0; i < s->slice_context_count; i++) {
- free_duplicate_context(s->thread_context[i]);
- }
- for (i = 1; i < s->slice_context_count; i++) {
- av_freep(&s->thread_context[i]);
- }
- s->slice_context_count = 1;
- } else free_duplicate_context(s);
-
- av_freep(&s->parse_context.buffer);
- s->parse_context.buffer_size = 0;
-
- av_freep(&s->bitstream_buffer);
- s->allocated_bitstream_buffer_size = 0;
-
- av_freep(&s->avctx->stats_out);
- av_freep(&s->ac_stats);
-
- 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= NULL;
- s->q_chroma_intra_matrix16= NULL;
- av_freep(&s->q_intra_matrix);
- av_freep(&s->q_inter_matrix);
- av_freep(&s->q_intra_matrix16);
- av_freep(&s->q_inter_matrix16);
- av_freep(&s->input_picture);
- av_freep(&s->reordered_input_picture);
- av_freep(&s->dct_offset);
-
- if (s->picture && !s->avctx->internal->is_copy) {
- for (i = 0; i < s->picture_count; i++) {
- free_picture(s, &s->picture[i]);
- }
- }
- av_freep(&s->picture);
-
- free_context_frame(s);
-
- if (!(s->avctx->active_thread_type & FF_THREAD_FRAME))
- avcodec_default_free_buffers(s->avctx);
-
- s->context_initialized = 0;
- s->last_picture_ptr =
- s->next_picture_ptr =
- s->current_picture_ptr = NULL;
- s->linesize = s->uvlinesize = 0;
-}
-
-void ff_init_rl(RLTable *rl,
- uint8_t static_store[2][2 * MAX_RUN + MAX_LEVEL + 3])
-{
- int8_t max_level[MAX_RUN + 1], max_run[MAX_LEVEL + 1];
- uint8_t index_run[MAX_RUN + 1];
- int last, run, level, start, end, i;
-
- /* If table is static, we can quit if rl->max_level[0] is not NULL */
- if (static_store && rl->max_level[0])
- return;
-
- /* compute max_level[], max_run[] and index_run[] */
- for (last = 0; last < 2; last++) {
- if (last == 0) {
- start = 0;
- end = rl->last;
- } else {
- start = rl->last;
- end = rl->n;
- }
-
- memset(max_level, 0, MAX_RUN + 1);
- memset(max_run, 0, MAX_LEVEL + 1);
- memset(index_run, rl->n, MAX_RUN + 1);
- for (i = start; i < end; i++) {
- run = rl->table_run[i];
- level = rl->table_level[i];
- if (index_run[run] == rl->n)
- index_run[run] = i;
- if (level > max_level[run])
- max_level[run] = level;
- if (run > max_run[level])
- max_run[level] = run;
- }
- if (static_store)
- rl->max_level[last] = static_store[last];
- else
- rl->max_level[last] = av_malloc(MAX_RUN + 1);
- memcpy(rl->max_level[last], max_level, MAX_RUN + 1);
- if (static_store)
- rl->max_run[last] = static_store[last] + MAX_RUN + 1;
- else
- rl->max_run[last] = av_malloc(MAX_LEVEL + 1);
- memcpy(rl->max_run[last], max_run, MAX_LEVEL + 1);
- if (static_store)
- rl->index_run[last] = static_store[last] + MAX_RUN + MAX_LEVEL + 2;
- else
- rl->index_run[last] = av_malloc(MAX_RUN + 1);
- memcpy(rl->index_run[last], index_run, MAX_RUN + 1);
- }
-}
-
-void ff_init_vlc_rl(RLTable *rl)
-{
- int i, q;
-
- for (q = 0; q < 32; q++) {
- int qmul = q * 2;
- int qadd = (q - 1) | 1;
-
- if (q == 0) {
- qmul = 1;
- qadd = 0;
- }
- for (i = 0; i < rl->vlc.table_size; i++) {
- int code = rl->vlc.table[i][0];
- int len = rl->vlc.table[i][1];
- int level, run;
-
- if (len == 0) { // illegal code
- run = 66;
- level = MAX_LEVEL;
- } else if (len < 0) { // more bits needed
- run = 0;
- level = code;
- } else {
- if (code == rl->n) { // esc
- run = 66;
- level = 0;
- } else {
- run = rl->table_run[code] + 1;
- level = rl->table_level[code] * qmul + qadd;
- if (code >= rl->last) run += 192;
- }
- }
- rl->rl_vlc[q][i].len = len;
- rl->rl_vlc[q][i].level = level;
- rl->rl_vlc[q][i].run = run;
- }
- }
-}
-
-void ff_release_unused_pictures(MpegEncContext*s, int remove_current)
-{
- int i;
-
- /* release non reference frames */
- for (i = 0; i < s->picture_count; i++) {
- if (s->picture[i].f.data[0] && !s->picture[i].f.reference &&
- (!s->picture[i].owner2 || s->picture[i].owner2 == s) &&
- (remove_current || &s->picture[i] != s->current_picture_ptr)
- /* && s->picture[i].type!= FF_BUFFER_TYPE_SHARED */) {
- free_frame_buffer(s, &s->picture[i]);
- }
- }
-}
-
-static inline int pic_is_unused(MpegEncContext *s, Picture *pic)
-{
- if ( (s->avctx->active_thread_type & FF_THREAD_FRAME)
- && pic->f.qscale_table //check if the frame has anything allocated
- && pic->period_since_free < s->avctx->thread_count)
- return 0;
- if (pic->f.data[0] == NULL)
- return 1;
- if (pic->needs_realloc && !(pic->f.reference & DELAYED_PIC_REF))
- if (!pic->owner2 || pic->owner2 == s)
- return 1;
- return 0;
-}
-
-static int find_unused_picture(MpegEncContext *s, int shared)
-{
- int i;
-
- if (shared) {
- for (i = s->picture_range_start; i < s->picture_range_end; i++) {
- if (s->picture[i].f.data[0] == NULL && s->picture[i].f.type == 0)
- return i;
- }
- } else {
- for (i = s->picture_range_start; i < s->picture_range_end; i++) {
- if (pic_is_unused(s, &s->picture[i]) && s->picture[i].f.type != 0)
- return i; // FIXME
- }
- for (i = s->picture_range_start; i < s->picture_range_end; i++) {
- if (pic_is_unused(s, &s->picture[i]))
- return i;
- }
- }
-
- av_log(s->avctx, AV_LOG_FATAL,
- "Internal error, picture buffer overflow\n");
- /* We could return -1, but the codec would crash trying to draw into a
- * non-existing frame anyway. This is safer than waiting for a random crash.
- * Also the return of this is never useful, an encoder must only allocate
- * as much as allowed in the specification. This has no relationship to how
- * much libavcodec could allocate (and MAX_PICTURE_COUNT is always large
- * enough for such valid streams).
- * Plus, a decoder has to check stream validity and remove frames if too
- * many reference frames are around. Waiting for "OOM" is not correct at
- * all. Similarly, missing reference frames have to be replaced by
- * interpolated/MC frames, anything else is a bug in the codec ...
- */
- abort();
- return -1;
-}
-
-int ff_find_unused_picture(MpegEncContext *s, int shared)
-{
- int ret = find_unused_picture(s, shared);
-
- if (ret >= 0 && ret < s->picture_range_end) {
- if (s->picture[ret].needs_realloc) {
- s->picture[ret].needs_realloc = 0;
- free_picture(s, &s->picture[ret]);
- avcodec_get_frame_defaults(&s->picture[ret].f);
- }
- }
- return ret;
-}
-
-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);
- }
- }
-}
-
-/**
- * generic function for encode/decode called after coding/decoding
- * the header and before a frame is coded/decoded.
- */
-int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
-{
- int i;
- Picture *pic;
- s->mb_skipped = 0;
-
- if (!ff_thread_can_start_frame(avctx)) {
- av_log(avctx, AV_LOG_ERROR, "Attempt to start a frame outside SETUP state\n");
- return -1;
- }
-
- /* mark & release old frames */
- if (s->out_format != FMT_H264 || s->codec_id == AV_CODEC_ID_SVQ3) {
- 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.data[0]) {
- if (s->last_picture_ptr->owner2 == s)
- free_frame_buffer(s, s->last_picture_ptr);
- }
-
- /* release forgotten pictures */
- /* if (mpeg124/h263) */
- if (!s->encoding) {
- for (i = 0; i < s->picture_count; i++) {
- if (s->picture[i].owner2 == s && s->picture[i].f.data[0] &&
- &s->picture[i] != s->last_picture_ptr &&
- &s->picture[i] != s->next_picture_ptr &&
- s->picture[i].f.reference && !s->picture[i].needs_realloc) {
- if (!(avctx->active_thread_type & FF_THREAD_FRAME))
- av_log(avctx, AV_LOG_ERROR,
- "releasing zombie picture\n");
- free_frame_buffer(s, &s->picture[i]);
- }
- }
- }
- }
-
- if (!s->encoding) {
- ff_release_unused_pictures(s, 1);
-
- if (s->current_picture_ptr &&
- s->current_picture_ptr->f.data[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->f.reference = 0;
- if (!s->droppable) {
- if (s->codec_id == AV_CODEC_ID_H264)
- pic->f.reference = s->picture_structure;
- else if (s->pict_type != AV_PICTURE_TYPE_B)
- pic->f.reference = 3;
- }
-
- pic->f.coded_picture_number = s->coded_picture_number++;
-
- 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->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;
-
- ff_copy_picture(&s->current_picture, s->current_picture_ptr);
-
- 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;
- }
- 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->pict_type, s->droppable);
-
- if (s->codec_id != AV_CODEC_ID_H264) {
- if ((s->last_picture_ptr == NULL ||
- s->last_picture_ptr->f.data[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_I)
- av_log(avctx, AV_LOG_ERROR,
- "warning: first frame is no keyframe\n");
- else if (s->picture_structure != PICT_FRAME)
- av_log(avctx, AV_LOG_INFO,
- "allocate dummy last picture for field based first keyframe\n");
-
- /* Allocate a dummy frame */
- i = ff_find_unused_picture(s, 0);
- if (i < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n");
- return i;
- }
- s->last_picture_ptr = &s->picture[i];
- s->last_picture_ptr->f.key_frame = 0;
- 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){
- 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->f, INT_MAX, 0);
- ff_thread_report_progress(&s->last_picture_ptr->f, INT_MAX, 1);
- s->last_picture_ptr->f.reference = 3;
- }
- if ((s->next_picture_ptr == NULL ||
- s->next_picture_ptr->f.data[0] == NULL) &&
- s->pict_type == AV_PICTURE_TYPE_B) {
- /* Allocate a dummy frame */
- i = ff_find_unused_picture(s, 0);
- if (i < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "no frame buffer available\n");
- return i;
- }
- s->next_picture_ptr = &s->picture[i];
- s->next_picture_ptr->f.key_frame = 0;
- if (ff_alloc_picture(s, s->next_picture_ptr, 0) < 0) {
- s->next_picture_ptr = NULL;
- return -1;
- }
- ff_thread_report_progress(&s->next_picture_ptr->f, INT_MAX, 0);
- ff_thread_report_progress(&s->next_picture_ptr->f, INT_MAX, 1);
- s->next_picture_ptr->f.reference = 3;
- }
- }
-
- 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));
- if (s->last_picture_ptr)
- ff_copy_picture(&s->last_picture, s->last_picture_ptr);
- if (s->next_picture_ptr)
- ff_copy_picture(&s->next_picture, s->next_picture_ptr);
-
- if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_FRAME)) {
- if (s->next_picture_ptr)
- s->next_picture_ptr->owner2 = s;
- if (s->last_picture_ptr)
- s->last_picture_ptr->owner2 = s;
- }
- // ==> Start patch MPC
- /*
- assert(s->pict_type == AV_PICTURE_TYPE_I || (s->last_picture_ptr &&
- s->last_picture_ptr->f.data[0]));
- */
- // ==> End patch MPC
- if (s->picture_structure!= PICT_FRAME && s->out_format != FMT_H264) {
- 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;
- }
- }
-
- s->err_recognition = avctx->err_recognition;
-
- /* set dequantizer, we can't do it during init as
- * it might change for mpeg4 and we can't do it in the header
- * decode as init is not called for mpeg4 there yet */
- 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) {
- assert(s->avctx->noise_reduction && s->encoding);
- update_noise_reduction(s);
- }
-
- if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)
- return ff_xvmc_field_start(s, avctx);
-
- return 0;
-}
-
-/* generic function for encode/decode called after a
- * frame has been coded/decoded. */
-void ff_MPV_frame_end(MpegEncContext *s)
-{
- int i;
- /* 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 if((s->error_count || s->encoding || !(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.f.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();
-
- s->last_pict_type = s->pict_type;
- 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;
- }
-#if 0
- /* copy back current_picture variables */
- for (i = 0; i < MAX_PICTURE_COUNT; i++) {
- if (s->picture[i].f.data[0] == s->current_picture.f.data[0]) {
- s->picture[i] = s->current_picture;
- break;
- }
- }
- assert(i < MAX_PICTURE_COUNT);
-#endif
-
- if (s->encoding) {
- /* release non-reference frames */
- for (i = 0; i < s->picture_count; i++) {
- if (s->picture[i].f.data[0] && !s->picture[i].f.reference
- /* && s->picture[i].type != FF_BUFFER_TYPE_SHARED */) {
- free_frame_buffer(s, &s->picture[i]);
- }
- }
- }
- // clear copies, to avoid confusion
-#if 0
- memset(&s->last_picture, 0, sizeof(Picture));
- memset(&s->next_picture, 0, sizeof(Picture));
- memset(&s->current_picture, 0, sizeof(Picture));
-#endif
- s->avctx->coded_frame = &s->current_picture_ptr->f;
-
- if (s->codec_id != AV_CODEC_ID_H264 && s->current_picture.f.reference) {
- ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, 0);
- }
-}
-
-/**
- * Draw a line from (ex, ey) -> (sx, sy).
- * @param w width of the image
- * @param h height of the image
- * @param stride stride/linesize of the image
- * @param color color of the arrow
- */
-static void draw_line(uint8_t *buf, int sx, int sy, int ex, int ey,
- int w, int h, int stride, int color)
-{
- int x, y, fr, f;
-
- sx = av_clip(sx, 0, w - 1);
- sy = av_clip(sy, 0, h - 1);
- ex = av_clip(ex, 0, w - 1);
- ey = av_clip(ey, 0, h - 1);
-
- buf[sy * stride + sx] += color;
-
- if (FFABS(ex - sx) > FFABS(ey - sy)) {
- if (sx > ex) {
- FFSWAP(int, sx, ex);
- FFSWAP(int, sy, ey);
- }
- buf += sx + sy * stride;
- ex -= sx;
- f = ((ey - sy) << 16) / ex;
- for (x = 0; x <= ex; x++) {
- y = (x * f) >> 16;
- fr = (x * f) & 0xFFFF;
- buf[y * stride + x] += (color * (0x10000 - fr)) >> 16;
- if(fr) buf[(y + 1) * stride + x] += (color * fr ) >> 16;
- }
- } else {
- if (sy > ey) {
- FFSWAP(int, sx, ex);
- FFSWAP(int, sy, ey);
- }
- buf += sx + sy * stride;
- ey -= sy;
- if (ey)
- f = ((ex - sx) << 16) / ey;
- else
- f = 0;
- for(y= 0; y <= ey; y++){
- x = (y*f) >> 16;
- fr = (y*f) & 0xFFFF;
- buf[y * stride + x] += (color * (0x10000 - fr)) >> 16;
- if(fr) buf[y * stride + x + 1] += (color * fr ) >> 16;
- }
- }
-}
-
-/**
- * Draw an arrow from (ex, ey) -> (sx, sy).
- * @param w width of the image
- * @param h height of the image
- * @param stride stride/linesize of the image
- * @param color color of the arrow
- */
-static void draw_arrow(uint8_t *buf, int sx, int sy, int ex,
- int ey, int w, int h, int stride, int color)
-{
- int dx,dy;
-
- sx = av_clip(sx, -100, w + 100);
- sy = av_clip(sy, -100, h + 100);
- ex = av_clip(ex, -100, w + 100);
- ey = av_clip(ey, -100, h + 100);
-
- dx = ex - sx;
- dy = ey - sy;
-
- if (dx * dx + dy * dy > 3 * 3) {
- int rx = dx + dy;
- int ry = -dx + dy;
- int length = ff_sqrt((rx * rx + ry * ry) << 8);
-
- // FIXME subpixel accuracy
- rx = ROUNDED_DIV(rx * 3 << 4, length);
- ry = ROUNDED_DIV(ry * 3 << 4, length);
-
- draw_line(buf, sx, sy, sx + rx, sy + ry, w, h, stride, color);
- draw_line(buf, sx, sy, sx - ry, sy + rx, w, h, stride, color);
- }
- draw_line(buf, sx, sy, ex, ey, w, h, stride, color);
-}
-
-/**
- * Print debugging info for the given picture.
- */
-void ff_print_debug_info(MpegEncContext *s, AVFrame *pict)
-{
- if ( s->avctx->hwaccel || !pict || !pict->mb_type
- || (s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU))
- return;
-
-
- if (s->avctx->debug & (FF_DEBUG_SKIP | FF_DEBUG_QP | FF_DEBUG_MB_TYPE)) {
- int x,y;
-
- av_log(s->avctx, AV_LOG_DEBUG, "New frame, type: %c\n",
- av_get_picture_type_char(pict->pict_type));
- for (y = 0; y < s->mb_height; y++) {
- for (x = 0; x < s->mb_width; x++) {
- if (s->avctx->debug & FF_DEBUG_SKIP) {
- int count = s->mbskip_table[x + y * s->mb_stride];
- if (count > 9)
- count = 9;
- av_log(s->avctx, AV_LOG_DEBUG, "%1d", count);
- }
- if (s->avctx->debug & FF_DEBUG_QP) {
- av_log(s->avctx, AV_LOG_DEBUG, "%2d",
- pict->qscale_table[x + y * s->mb_stride]);
- }
- if (s->avctx->debug & FF_DEBUG_MB_TYPE) {
- int mb_type = pict->mb_type[x + y * s->mb_stride];
- // Type & MV direction
- if (IS_PCM(mb_type))
- av_log(s->avctx, AV_LOG_DEBUG, "P");
- else if (IS_INTRA(mb_type) && IS_ACPRED(mb_type))
- av_log(s->avctx, AV_LOG_DEBUG, "A");
- else if (IS_INTRA4x4(mb_type))
- av_log(s->avctx, AV_LOG_DEBUG, "i");
- else if (IS_INTRA16x16(mb_type))
- av_log(s->avctx, AV_LOG_DEBUG, "I");
- else if (IS_DIRECT(mb_type) && IS_SKIP(mb_type))
- av_log(s->avctx, AV_LOG_DEBUG, "d");
- else if (IS_DIRECT(mb_type))
- av_log(s->avctx, AV_LOG_DEBUG, "D");
- else if (IS_GMC(mb_type) && IS_SKIP(mb_type))
- av_log(s->avctx, AV_LOG_DEBUG, "g");
- else if (IS_GMC(mb_type))
- av_log(s->avctx, AV_LOG_DEBUG, "G");
- else if (IS_SKIP(mb_type))
- av_log(s->avctx, AV_LOG_DEBUG, "S");
- else if (!USES_LIST(mb_type, 1))
- av_log(s->avctx, AV_LOG_DEBUG, ">");
- else if (!USES_LIST(mb_type, 0))
- av_log(s->avctx, AV_LOG_DEBUG, "<");
- else {
- av_assert2(USES_LIST(mb_type, 0) && USES_LIST(mb_type, 1));
- av_log(s->avctx, AV_LOG_DEBUG, "X");
- }
-
- // segmentation
- if (IS_8X8(mb_type))
- av_log(s->avctx, AV_LOG_DEBUG, "+");
- else if (IS_16X8(mb_type))
- av_log(s->avctx, AV_LOG_DEBUG, "-");
- else if (IS_8X16(mb_type))
- av_log(s->avctx, AV_LOG_DEBUG, "|");
- else if (IS_INTRA(mb_type) || IS_16X16(mb_type))
- av_log(s->avctx, AV_LOG_DEBUG, " ");
- else
- av_log(s->avctx, AV_LOG_DEBUG, "?");
-
-
- if (IS_INTERLACED(mb_type))
- av_log(s->avctx, AV_LOG_DEBUG, "=");
- else
- av_log(s->avctx, AV_LOG_DEBUG, " ");
- }
- }
- av_log(s->avctx, AV_LOG_DEBUG, "\n");
- }
- }
-
- if ((s->avctx->debug & (FF_DEBUG_VIS_QP | FF_DEBUG_VIS_MB_TYPE)) ||
- (s->avctx->debug_mv)) {
- const int shift = 1 + s->quarter_sample;
- int mb_y;
- uint8_t *ptr;
- int i;
- int h_chroma_shift, v_chroma_shift, block_height;
- const int width = s->avctx->width;
- const int height = s->avctx->height;
- const int mv_sample_log2 = 4 - pict->motion_subsample_log2;
- const int mv_stride = (s->mb_width << mv_sample_log2) +
- (s->codec_id == AV_CODEC_ID_H264 ? 0 : 1);
- s->low_delay = 0; // needed to see the vectors without trashing the buffers
-
- avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &h_chroma_shift, &v_chroma_shift);
-
- for (i = 0; i < 3; i++) {
- size_t size= (i == 0) ? pict->linesize[i] * FFALIGN(height, 16):
- pict->linesize[i] * FFALIGN(height, 16) >> v_chroma_shift;
- s->visualization_buffer[i]= av_realloc(s->visualization_buffer[i], size);
- memcpy(s->visualization_buffer[i], pict->data[i], size);
- pict->data[i] = s->visualization_buffer[i];
- }
- pict->type = FF_BUFFER_TYPE_COPY;
- pict->opaque= NULL;
- ptr = pict->data[0];
- block_height = 16 >> v_chroma_shift;
-
- for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
- int mb_x;
- for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
- const int mb_index = mb_x + mb_y * s->mb_stride;
- if ((s->avctx->debug_mv) && pict->motion_val[0]) {
- int type;
- for (type = 0; type < 3; type++) {
- int direction = 0;
- switch (type) {
- case 0:
- if ((!(s->avctx->debug_mv & FF_DEBUG_VIS_MV_P_FOR)) ||
- (pict->pict_type!= AV_PICTURE_TYPE_P))
- continue;
- direction = 0;
- break;
- case 1:
- if ((!(s->avctx->debug_mv & FF_DEBUG_VIS_MV_B_FOR)) ||
- (pict->pict_type!= AV_PICTURE_TYPE_B))
- continue;
- direction = 0;
- break;
- case 2:
- if ((!(s->avctx->debug_mv & FF_DEBUG_VIS_MV_B_BACK)) ||
- (pict->pict_type!= AV_PICTURE_TYPE_B))
- continue;
- direction = 1;
- break;
- }
- if (!USES_LIST(pict->mb_type[mb_index], direction))
- continue;
-
- if (IS_8X8(pict->mb_type[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 = (pict->motion_val[direction][xy][0] >> shift) + sx;
- int my = (pict->motion_val[direction][xy][1] >> shift) + sy;
- draw_arrow(ptr, sx, sy, mx, my, width,
- height, s->linesize, 100);
- }
- } else if (IS_16X8(pict->mb_type[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 = (pict->motion_val[direction][xy][0] >> shift);
- int my = (pict->motion_val[direction][xy][1] >> shift);
-
- if (IS_INTERLACED(pict->mb_type[mb_index]))
- my *= 2;
-
- draw_arrow(ptr, sx, sy, mx + sx, my + sy, width,
- height, s->linesize, 100);
- }
- } else if (IS_8X16(pict->mb_type[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 = pict->motion_val[direction][xy][0] >> shift;
- int my = pict->motion_val[direction][xy][1] >> shift;
-
- if (IS_INTERLACED(pict->mb_type[mb_index]))
- my *= 2;
-
- draw_arrow(ptr, sx, sy, mx + sx, my + sy, width,
- height, s->linesize, 100);
- }
- } else {
- 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= (pict->motion_val[direction][xy][0]>>shift) + sx;
- int my= (pict->motion_val[direction][xy][1]>>shift) + sy;
- draw_arrow(ptr, sx, sy, mx, my, width, height, s->linesize, 100);
- }
- }
- }
- if ((s->avctx->debug & FF_DEBUG_VIS_QP)) {
- uint64_t c = (pict->qscale_table[mb_index] * 128 / 31) *
- 0x0101010101010101ULL;
- int y;
- for (y = 0; y < block_height; y++) {
- *(uint64_t *)(pict->data[1] + 8 * mb_x +
- (block_height * mb_y + y) *
- pict->linesize[1]) = c;
- *(uint64_t *)(pict->data[2] + 8 * mb_x +
- (block_height * mb_y + y) *
- pict->linesize[2]) = c;
- }
- }
- if ((s->avctx->debug & FF_DEBUG_VIS_MB_TYPE) &&
- pict->motion_val[0]) {
- int mb_type = pict->mb_type[mb_index];
- uint64_t u,v;
- int y;
-#define COLOR(theta, r) \
- u = (int)(128 + r * cos(theta * 3.141592 / 180)); \
- v = (int)(128 + r * sin(theta * 3.141592 / 180));
-
-
- u = v = 128;
- if (IS_PCM(mb_type)) {
- COLOR(120, 48)
- } else if ((IS_INTRA(mb_type) && IS_ACPRED(mb_type)) ||
- IS_INTRA16x16(mb_type)) {
- COLOR(30, 48)
- } else if (IS_INTRA4x4(mb_type)) {
- COLOR(90, 48)
- } else if (IS_DIRECT(mb_type) && IS_SKIP(mb_type)) {
- // COLOR(120, 48)
- } else if (IS_DIRECT(mb_type)) {
- COLOR(150, 48)
- } else if (IS_GMC(mb_type) && IS_SKIP(mb_type)) {
- COLOR(170, 48)
- } else if (IS_GMC(mb_type)) {
- COLOR(190, 48)
- } else if (IS_SKIP(mb_type)) {
- // COLOR(180, 48)
- } else if (!USES_LIST(mb_type, 1)) {
- COLOR(240, 48)
- } else if (!USES_LIST(mb_type, 0)) {
- COLOR(0, 48)
- } else {
- av_assert2(USES_LIST(mb_type, 0) && USES_LIST(mb_type, 1));
- COLOR(300,48)
- }
-
- u *= 0x0101010101010101ULL;
- v *= 0x0101010101010101ULL;
- for (y = 0; y < block_height; y++) {
- *(uint64_t *)(pict->data[1] + 8 * mb_x +
- (block_height * mb_y + y) * pict->linesize[1]) = u;
- *(uint64_t *)(pict->data[2] + 8 * mb_x +
- (block_height * mb_y + y) * pict->linesize[2]) = v;
- }
-
- // segmentation
- if (IS_8X8(mb_type) || IS_16X8(mb_type)) {
- *(uint64_t *)(pict->data[0] + 16 * mb_x + 0 +
- (16 * mb_y + 8) * pict->linesize[0]) ^= 0x8080808080808080ULL;
- *(uint64_t *)(pict->data[0] + 16 * mb_x + 8 +
- (16 * mb_y + 8) * pict->linesize[0]) ^= 0x8080808080808080ULL;
- }
- if (IS_8X8(mb_type) || IS_8X16(mb_type)) {
- for (y = 0; y < 16; y++)
- pict->data[0][16 * mb_x + 8 + (16 * mb_y + y) *
- pict->linesize[0]] ^= 0x80;
- }
- if (IS_8X8(mb_type) && mv_sample_log2 >= 2) {
- int dm = 1 << (mv_sample_log2 - 2);
- for (i = 0; i < 4; i++) {
- int sx = mb_x * 16 + 8 * (i & 1);
- int sy = mb_y * 16 + 8 * (i >> 1);
- 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 *) &pict->motion_val[0][xy];
- if (mv[0] != mv[dm] ||
- mv[dm * mv_stride] != mv[dm * (mv_stride + 1)])
- for (y = 0; y < 8; y++)
- pict->data[0][sx + 4 + (sy + y) * pict->linesize[0]] ^= 0x80;
- if (mv[0] != mv[dm * mv_stride] || mv[dm] != mv[dm * (mv_stride + 1)])
- *(uint64_t *)(pict->data[0] + sx + (sy + 4) *
- pict->linesize[0]) ^= 0x8080808080808080ULL;
- }
- }
-
- if (IS_INTERLACED(mb_type) &&
- s->codec_id == AV_CODEC_ID_H264) {
- // hmm
- }
- }
- s->mbskip_table[mb_index] = 0;
- }
- }
- }
-}
-
-static inline int hpel_motion_lowres(MpegEncContext *s,
- uint8_t *dest, uint8_t *src,
- int field_based, int field_select,
- int src_x, int src_y,
- int width, int height, int stride,
- int h_edge_pos, int v_edge_pos,
- int w, int h, h264_chroma_mc_func *pix_op,
- int motion_x, int motion_y)
-{
- const int lowres = s->avctx->lowres;
- const int op_index = FFMIN(lowres, 2);
- const int s_mask = (2 << lowres) - 1;
- int emu = 0;
- int sx, sy;
-
- if (s->quarter_sample) {
- motion_x /= 2;
- motion_y /= 2;
- }
-
- sx = motion_x & s_mask;
- sy = motion_y & s_mask;
- src_x += motion_x >> lowres + 1;
- src_y += motion_y >> lowres + 1;
-
- src += src_y * stride + src_x;
-
- if ((unsigned)src_x > FFMAX( h_edge_pos - (!!sx) - w, 0) ||
- (unsigned)src_y > FFMAX((v_edge_pos >> field_based) - (!!sy) - h, 0)) {
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer, src, s->linesize, w + 1,
- (h + 1) << field_based, src_x,
- src_y << field_based,
- h_edge_pos,
- v_edge_pos);
- src = s->edge_emu_buffer;
- emu = 1;
- }
-
- sx = (sx << 2) >> lowres;
- sy = (sy << 2) >> lowres;
- if (field_select)
- src += s->linesize;
- pix_op[op_index](dest, src, stride, h, sx, sy);
- return emu;
-}
-
-/* apply one mpeg motion vector to the three components */
-static av_always_inline void mpeg_motion_lowres(MpegEncContext *s,
- uint8_t *dest_y,
- uint8_t *dest_cb,
- uint8_t *dest_cr,
- int field_based,
- int bottom_field,
- int field_select,
- uint8_t **ref_picture,
- h264_chroma_mc_func *pix_op,
- int motion_x, int motion_y,
- int h, int mb_y)
-{
- uint8_t *ptr_y, *ptr_cb, *ptr_cr;
- int mx, my, src_x, src_y, uvsrc_x, uvsrc_y, uvlinesize, linesize, sx, sy,
- uvsx, uvsy;
- const int lowres = s->avctx->lowres;
- const int op_index = FFMIN(lowres-1+s->chroma_x_shift, 2);
- const int block_s = 8>>lowres;
- 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;
-
- // FIXME obviously not perfect but qpel will not work in lowres anyway
- if (s->quarter_sample) {
- motion_x /= 2;
- motion_y /= 2;
- }
-
- if(field_based){
- motion_y += (bottom_field - field_select)*((1 << lowres)-1);
- }
-
- sx = motion_x & s_mask;
- sy = motion_y & s_mask;
- src_x = s->mb_x * 2 * block_s + (motion_x >> lowres + 1);
- src_y = (mb_y * 2 * block_s >> field_based) + (motion_y >> lowres + 1);
-
- if (s->out_format == FMT_H263) {
- uvsx = ((motion_x >> 1) & s_mask) | (sx & 1);
- uvsy = ((motion_y >> 1) & s_mask) | (sy & 1);
- uvsrc_x = src_x >> 1;
- uvsrc_y = src_y >> 1;
- } else if (s->out_format == FMT_H261) {
- // even chroma mv's are full pel in H261
- mx = motion_x / 4;
- my = motion_y / 4;
- uvsx = (2 * mx) & s_mask;
- uvsy = (2 * my) & s_mask;
- uvsrc_x = s->mb_x * block_s + (mx >> lowres);
- uvsrc_y = mb_y * block_s + (my >> lowres);
- } else {
- if(s->chroma_y_shift){
- mx = motion_x / 2;
- my = motion_y / 2;
- uvsx = mx & s_mask;
- uvsy = my & s_mask;
- uvsrc_x = s->mb_x * block_s + (mx >> lowres + 1);
- uvsrc_y = (mb_y * block_s >> field_based) + (my >> lowres + 1);
- } else {
- if(s->chroma_x_shift){
- //Chroma422
- mx = motion_x / 2;
- uvsx = mx & s_mask;
- uvsy = motion_y & s_mask;
- uvsrc_y = src_y;
- uvsrc_x = s->mb_x*block_s + (mx >> (lowres+1));
- } else {
- //Chroma444
- uvsx = motion_x & s_mask;
- uvsy = motion_y & s_mask;
- uvsrc_x = src_x;
- uvsrc_y = src_y;
- }
- }
- }
-
- ptr_y = ref_picture[0] + src_y * linesize + src_x;
- ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
- ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
-
- if ((unsigned) src_x > FFMAX( h_edge_pos - (!!sx) - 2 * block_s, 0) ||
- (unsigned) src_y > FFMAX((v_edge_pos >> field_based) - (!!sy) - h, 0)) {
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr_y,
- linesize >> field_based, 17, 17 + field_based,
- src_x, src_y << field_based, h_edge_pos,
- v_edge_pos);
- ptr_y = s->edge_emu_buffer;
- if (!CONFIG_GRAY || !(s->flags & CODEC_FLAG_GRAY)) {
- uint8_t *uvbuf = s->edge_emu_buffer + 18 * s->linesize;
- s->vdsp.emulated_edge_mc(uvbuf , ptr_cb, uvlinesize >> field_based, 9,
- 9 + field_based,
- uvsrc_x, uvsrc_y << field_based,
- h_edge_pos >> 1, v_edge_pos >> 1);
- s->vdsp.emulated_edge_mc(uvbuf + 16, ptr_cr, uvlinesize >> field_based, 9,
- 9 + field_based,
- uvsrc_x, uvsrc_y << field_based,
- h_edge_pos >> 1, v_edge_pos >> 1);
- ptr_cb = uvbuf;
- ptr_cr = uvbuf + 16;
- }
- }
-
- // 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;
- dest_cr += s->uvlinesize;
- }
-
- if (field_select) {
- ptr_y += s->linesize;
- ptr_cb += s->uvlinesize;
- ptr_cr += s->uvlinesize;
- }
-
- sx = (sx << 2) >> lowres;
- sy = (sy << 2) >> lowres;
- pix_op[lowres - 1](dest_y, ptr_y, linesize, h, sx, sy);
-
- if (!CONFIG_GRAY || !(s->flags & CODEC_FLAG_GRAY)) {
- uvsx = (uvsx << 2) >> lowres;
- uvsy = (uvsy << 2) >> lowres;
- if (h >> s->chroma_y_shift) {
- pix_op[op_index](dest_cb, ptr_cb, uvlinesize, h >> s->chroma_y_shift, uvsx, uvsy);
- pix_op[op_index](dest_cr, ptr_cr, uvlinesize, h >> s->chroma_y_shift, uvsx, uvsy);
- }
- }
- // FIXME h261 lowres loop filter
-}
-
-static inline void chroma_4mv_motion_lowres(MpegEncContext *s,
- uint8_t *dest_cb, uint8_t *dest_cr,
- uint8_t **ref_picture,
- h264_chroma_mc_func * pix_op,
- int mx, int my)
-{
- const int lowres = s->avctx->lowres;
- const int op_index = FFMIN(lowres, 2);
- const int block_s = 8 >> lowres;
- const int s_mask = (2 << lowres) - 1;
- const int h_edge_pos = s->h_edge_pos >> lowres + 1;
- const int v_edge_pos = s->v_edge_pos >> lowres + 1;
- int emu = 0, src_x, src_y, offset, sx, sy;
- uint8_t *ptr;
-
- if (s->quarter_sample) {
- mx /= 2;
- my /= 2;
- }
-
- /* In case of 8X8, we construct a single chroma motion vector
- with a special rounding */
- mx = ff_h263_round_chroma(mx);
- my = ff_h263_round_chroma(my);
-
- sx = mx & s_mask;
- sy = my & s_mask;
- src_x = s->mb_x * block_s + (mx >> lowres + 1);
- src_y = s->mb_y * block_s + (my >> lowres + 1);
-
- offset = src_y * s->uvlinesize + src_x;
- ptr = ref_picture[1] + offset;
- if (s->flags & CODEC_FLAG_EMU_EDGE) {
- if ((unsigned) src_x > FFMAX(h_edge_pos - (!!sx) - block_s, 0) ||
- (unsigned) src_y > FFMAX(v_edge_pos - (!!sy) - block_s, 0)) {
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize,
- 9, 9, src_x, src_y, h_edge_pos, v_edge_pos);
- ptr = s->edge_emu_buffer;
- emu = 1;
- }
- }
- sx = (sx << 2) >> lowres;
- sy = (sy << 2) >> lowres;
- pix_op[op_index](dest_cb, ptr, s->uvlinesize, block_s, sx, sy);
-
- ptr = ref_picture[2] + offset;
- if (emu) {
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9,
- src_x, src_y, h_edge_pos, v_edge_pos);
- ptr = s->edge_emu_buffer;
- }
- pix_op[op_index](dest_cr, ptr, s->uvlinesize, block_s, sx, sy);
-}
-
-/**
- * motion compensation of a single macroblock
- * @param s context
- * @param dest_y luma destination pointer
- * @param dest_cb chroma cb/u destination pointer
- * @param dest_cr chroma cr/v destination pointer
- * @param dir direction (0->forward, 1->backward)
- * @param ref_picture array[3] of pointers to the 3 planes of the reference picture
- * @param pix_op halfpel motion compensation function (average or put normally)
- * the motion vectors are taken from s->mv and the MV type from s->mv_type
- */
-static inline void MPV_motion_lowres(MpegEncContext *s,
- uint8_t *dest_y, uint8_t *dest_cb,
- uint8_t *dest_cr,
- int dir, uint8_t **ref_picture,
- h264_chroma_mc_func *pix_op)
-{
- int mx, my;
- int mb_x, mb_y, i;
- const int lowres = s->avctx->lowres;
- const int block_s = 8 >>lowres;
-
- mb_x = s->mb_x;
- mb_y = s->mb_y;
-
- switch (s->mv_type) {
- case MV_TYPE_16X16:
- mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
- 0, 0, 0,
- ref_picture, pix_op,
- s->mv[dir][0][0], s->mv[dir][0][1],
- 2 * block_s, mb_y);
- break;
- case MV_TYPE_8X8:
- mx = 0;
- my = 0;
- for (i = 0; i < 4; i++) {
- hpel_motion_lowres(s, dest_y + ((i & 1) + (i >> 1) *
- s->linesize) * block_s,
- ref_picture[0], 0, 0,
- (2 * mb_x + (i & 1)) * block_s,
- (2 * mb_y + (i >> 1)) * block_s,
- s->width, s->height, s->linesize,
- s->h_edge_pos >> lowres, s->v_edge_pos >> lowres,
- block_s, block_s, pix_op,
- s->mv[dir][i][0], s->mv[dir][i][1]);
-
- mx += s->mv[dir][i][0];
- my += s->mv[dir][i][1];
- }
-
- if (!CONFIG_GRAY || !(s->flags & CODEC_FLAG_GRAY))
- chroma_4mv_motion_lowres(s, dest_cb, dest_cr, ref_picture,
- pix_op, mx, my);
- break;
- case MV_TYPE_FIELD:
- if (s->picture_structure == PICT_FRAME) {
- /* top field */
- mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
- 1, 0, s->field_select[dir][0],
- ref_picture, pix_op,
- s->mv[dir][0][0], s->mv[dir][0][1],
- block_s, mb_y);
- /* bottom field */
- mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
- 1, 1, s->field_select[dir][1],
- ref_picture, pix_op,
- s->mv[dir][1][0], s->mv[dir][1][1],
- block_s, mb_y);
- } 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;
-
- }
- mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
- 0, 0, s->field_select[dir][0],
- ref_picture, pix_op,
- s->mv[dir][0][0],
- s->mv[dir][0][1], 2 * block_s, mb_y >> 1);
- }
- break;
- case MV_TYPE_16X8:
- for (i = 0; i < 2; i++) {
- uint8_t **ref2picture;
-
- if (s->picture_structure == s->field_select[dir][i] + 1 ||
- s->pict_type == AV_PICTURE_TYPE_B || s->first_field) {
- ref2picture = ref_picture;
- } else {
- ref2picture = s->current_picture_ptr->f.data;
- }
-
- mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
- 0, 0, s->field_select[dir][i],
- ref2picture, pix_op,
- s->mv[dir][i][0], s->mv[dir][i][1] +
- 2 * block_s * i, block_s, mb_y >> 1);
-
- dest_y += 2 * block_s * s->linesize;
- dest_cb += (2 * block_s >> s->chroma_y_shift) * s->uvlinesize;
- dest_cr += (2 * block_s >> s->chroma_y_shift) * s->uvlinesize;
- }
- break;
- case MV_TYPE_DMV:
- if (s->picture_structure == PICT_FRAME) {
- for (i = 0; i < 2; i++) {
- int j;
- for (j = 0; j < 2; j++) {
- mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
- 1, j, j ^ i,
- ref_picture, pix_op,
- s->mv[dir][2 * i + j][0],
- s->mv[dir][2 * i + j][1],
- block_s, mb_y);
- }
- pix_op = s->h264chroma.avg_h264_chroma_pixels_tab;
- }
- } else {
- for (i = 0; i < 2; i++) {
- mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
- 0, 0, s->picture_structure != i + 1,
- ref_picture, pix_op,
- s->mv[dir][2 * i][0],s->mv[dir][2 * i][1],
- 2 * block_s, mb_y >> 1);
-
- // after put we make avg of the same block
- pix_op = s->h264chroma.avg_h264_chroma_pixels_tab;
-
- // 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;
- }
- }
- }
- break;
- default:
- av_assert2(0);
- }
-}
-
-/**
- * find the lowest MB row referenced in the MVs
- */
-int ff_MPV_lowest_referenced_row(MpegEncContext *s, int dir)
-{
- int my_max = INT_MIN, my_min = INT_MAX, qpel_shift = !s->quarter_sample;
- int my, off, i, mvs;
-
- if (s->picture_structure != PICT_FRAME || s->mcsel)
- goto unhandled;
-
- switch (s->mv_type) {
- case MV_TYPE_16X16:
- mvs = 1;
- break;
- case MV_TYPE_16X8:
- mvs = 2;
- break;
- case MV_TYPE_8X8:
- mvs = 4;
- break;
- default:
- goto unhandled;
- }
-
- for (i = 0; i < mvs; i++) {
- my = s->mv[dir][i][1]<<qpel_shift;
- my_max = FFMAX(my_max, my);
- my_min = FFMIN(my_min, my);
- }
-
- off = (FFMAX(-my_min, my_max) + 63) >> 6;
-
- return FFMIN(FFMAX(s->mb_y + off, 0), s->mb_height-1);
-unhandled:
- return s->mb_height-1;
-}
-
-/* put block[] to dest[] */
-static inline void put_dct(MpegEncContext *s,
- int16_t *block, int i, uint8_t *dest, int line_size, int qscale)
-{
- s->dct_unquantize_intra(s, block, i, qscale);
- s->dsp.idct_put (dest, line_size, block);
-}
-
-/* add block[] to dest[] */
-static inline void add_dct(MpegEncContext *s,
- int16_t *block, int i, uint8_t *dest, int line_size)
-{
- if (s->block_last_index[i] >= 0) {
- s->dsp.idct_add (dest, line_size, block);
- }
-}
-
-static inline void add_dequant_dct(MpegEncContext *s,
- int16_t *block, int i, uint8_t *dest, int line_size, int qscale)
-{
- if (s->block_last_index[i] >= 0) {
- s->dct_unquantize_inter(s, block, i, qscale);
-
- s->dsp.idct_add (dest, line_size, block);
- }
-}
-
-/**
- * Clean dc, ac, coded_block for the current non-intra MB.
- */
-void ff_clean_intra_table_entries(MpegEncContext *s)
-{
- int wrap = s->b8_stride;
- int xy = s->block_index[0];
-
- s->dc_val[0][xy ] =
- s->dc_val[0][xy + 1 ] =
- s->dc_val[0][xy + wrap] =
- s->dc_val[0][xy + 1 + wrap] = 1024;
- /* ac pred */
- memset(s->ac_val[0][xy ], 0, 32 * sizeof(int16_t));
- memset(s->ac_val[0][xy + wrap], 0, 32 * sizeof(int16_t));
- if (s->msmpeg4_version>=3) {
- s->coded_block[xy ] =
- s->coded_block[xy + 1 ] =
- s->coded_block[xy + wrap] =
- s->coded_block[xy + 1 + wrap] = 0;
- }
- /* chroma */
- wrap = s->mb_stride;
- xy = s->mb_x + s->mb_y * wrap;
- s->dc_val[1][xy] =
- s->dc_val[2][xy] = 1024;
- /* ac pred */
- memset(s->ac_val[1][xy], 0, 16 * sizeof(int16_t));
- memset(s->ac_val[2][xy], 0, 16 * sizeof(int16_t));
-
- s->mbintra_table[xy]= 0;
-}
-
-/* generic function called after a macroblock has been parsed by the
- decoder or after it has been encoded by the encoder.
-
- Important variables used:
- s->mb_intra : true if intra macroblock
- s->mv_dir : motion vector direction
- s->mv_type : motion vector type
- s->mv : motion vector
- s->interlaced_dct : true if interlaced dct used (mpeg2)
- */
-static av_always_inline
-void MPV_decode_mb_internal(MpegEncContext *s, int16_t block[12][64],
- int lowres_flag, int is_mpeg12)
-{
- const int mb_xy = s->mb_y * s->mb_stride + s->mb_x;
- if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration){
- ff_xvmc_decode_mb(s);//xvmc uses pblocks
- return;
- }
-
- if(s->avctx->debug&FF_DEBUG_DCT_COEFF) {
- /* save DCT coefficients */
- int i,j;
- int16_t *dct = &s->current_picture.f.dct_coeff[mb_xy * 64 * 6];
- av_log(s->avctx, AV_LOG_DEBUG, "DCT coeffs of MB at %dx%d:\n", s->mb_x, s->mb_y);
- for(i=0; i<6; i++){
- for(j=0; j<64; j++){
- *dct++ = block[i][s->dsp.idct_permutation[j]];
- av_log(s->avctx, AV_LOG_DEBUG, "%5d", dct[-1]);
- }
- av_log(s->avctx, AV_LOG_DEBUG, "\n");
- }
- }
-
- s->current_picture.f.qscale_table[mb_xy] = s->qscale;
-
- /* update DC predictors for P macroblocks */
- if (!s->mb_intra) {
- if (!is_mpeg12 && (s->h263_pred || s->h263_aic)) {
- if(s->mbintra_table[mb_xy])
- ff_clean_intra_table_entries(s);
- } else {
- s->last_dc[0] =
- s->last_dc[1] =
- s->last_dc[2] = 128 << s->intra_dc_precision;
- }
- }
- 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
- 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 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;
-
- /* avoid copy if macroblock skipped in last frame too */
- /* skip only during decoding as we might trash the buffers during encoding a bit */
- if(!s->encoding){
- uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy];
-
- if (s->mb_skipped) {
- s->mb_skipped= 0;
- av_assert2(s->pict_type!=AV_PICTURE_TYPE_I);
- *mbskip_ptr = 1;
- } else if(!s->current_picture.f.reference) {
- *mbskip_ptr = 1;
- } else{
- *mbskip_ptr = 0; /* not skipped */
- }
- }
-
- dct_linesize = linesize << s->interlaced_dct;
- dct_offset = s->interlaced_dct ? linesize : linesize * block_size;
-
- if(readable){
- dest_y= s->dest[0];
- dest_cb= s->dest[1];
- dest_cr= s->dest[2];
- }else{
- dest_y = s->b_scratchpad;
- dest_cb= s->b_scratchpad+16*linesize;
- dest_cr= s->b_scratchpad+32*linesize;
- }
-
- if (!s->mb_intra) {
- /* motion handling */
- /* decoding or more than one mb_type (MC was already done otherwise) */
- if(!s->encoding){
-
- if(HAVE_THREADS && s->avctx->active_thread_type&FF_THREAD_FRAME) {
- if (s->mv_dir & MV_DIR_FORWARD) {
- ff_thread_await_progress(&s->last_picture_ptr->f,
- ff_MPV_lowest_referenced_row(s, 0),
- 0);
- }
- if (s->mv_dir & MV_DIR_BACKWARD) {
- ff_thread_await_progress(&s->next_picture_ptr->f,
- ff_MPV_lowest_referenced_row(s, 1),
- 0);
- }
- }
-
- if(lowres_flag){
- 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);
- 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);
- }
- }else{
- op_qpix= s->me.qpel_put;
- if ((!s->no_rounding) || s->pict_type==AV_PICTURE_TYPE_B){
- op_pix = s->dsp.put_pixels_tab;
- }else{
- op_pix = s->dsp.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);
- op_pix = s->dsp.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);
- }
- }
- }
-
- /* skip dequant / idct if we are really late ;) */
- if(s->avctx->skip_idct){
- if( (s->avctx->skip_idct >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B)
- ||(s->avctx->skip_idct >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I)
- || s->avctx->skip_idct >= AVDISCARD_ALL)
- goto skip_idct;
- }
-
- /* add dct residue */
- if(s->encoding || !( s->msmpeg4_version || s->codec_id==AV_CODEC_ID_MPEG1VIDEO || s->codec_id==AV_CODEC_ID_MPEG2VIDEO
- || (s->codec_id==AV_CODEC_ID_MPEG4 && !s->mpeg_quant))){
- add_dequant_dct(s, block[0], 0, dest_y , dct_linesize, s->qscale);
- add_dequant_dct(s, block[1], 1, dest_y + block_size, dct_linesize, s->qscale);
- add_dequant_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize, s->qscale);
- add_dequant_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
-
- if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
- if (s->chroma_y_shift){
- add_dequant_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
- add_dequant_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
- }else{
- dct_linesize >>= 1;
- dct_offset >>=1;
- add_dequant_dct(s, block[4], 4, dest_cb, dct_linesize, s->chroma_qscale);
- add_dequant_dct(s, block[5], 5, dest_cr, dct_linesize, s->chroma_qscale);
- add_dequant_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize, s->chroma_qscale);
- add_dequant_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize, s->chroma_qscale);
- }
- }
- } else if(is_mpeg12 || (s->codec_id != AV_CODEC_ID_WMV2)){
- add_dct(s, block[0], 0, dest_y , dct_linesize);
- add_dct(s, block[1], 1, dest_y + block_size, dct_linesize);
- add_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize);
- add_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize);
-
- if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
- if(s->chroma_y_shift){//Chroma420
- add_dct(s, block[4], 4, dest_cb, uvlinesize);
- add_dct(s, block[5], 5, dest_cr, uvlinesize);
- }else{
- //chroma422
- dct_linesize = uvlinesize << s->interlaced_dct;
- dct_offset = s->interlaced_dct ? uvlinesize : uvlinesize*block_size;
-
- add_dct(s, block[4], 4, dest_cb, dct_linesize);
- add_dct(s, block[5], 5, dest_cr, dct_linesize);
- add_dct(s, block[6], 6, dest_cb+dct_offset, dct_linesize);
- add_dct(s, block[7], 7, dest_cr+dct_offset, dct_linesize);
- if(!s->chroma_x_shift){//Chroma444
- add_dct(s, block[8], 8, dest_cb+block_size, dct_linesize);
- add_dct(s, block[9], 9, dest_cr+block_size, dct_linesize);
- add_dct(s, block[10], 10, dest_cb+block_size+dct_offset, dct_linesize);
- add_dct(s, block[11], 11, dest_cr+block_size+dct_offset, dct_linesize);
- }
- }
- }//fi gray
- }
- else if (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) {
- ff_wmv2_add_mb(s, block, dest_y, dest_cb, dest_cr);
- }
- } else {
- /* dct only in intra block */
- if(s->encoding || !(s->codec_id==AV_CODEC_ID_MPEG1VIDEO || s->codec_id==AV_CODEC_ID_MPEG2VIDEO)){
- put_dct(s, block[0], 0, dest_y , dct_linesize, s->qscale);
- put_dct(s, block[1], 1, dest_y + block_size, dct_linesize, s->qscale);
- put_dct(s, block[2], 2, dest_y + dct_offset , dct_linesize, s->qscale);
- put_dct(s, block[3], 3, dest_y + dct_offset + block_size, dct_linesize, s->qscale);
-
- if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
- if(s->chroma_y_shift){
- put_dct(s, block[4], 4, dest_cb, uvlinesize, s->chroma_qscale);
- put_dct(s, block[5], 5, dest_cr, uvlinesize, s->chroma_qscale);
- }else{
- dct_offset >>=1;
- dct_linesize >>=1;
- put_dct(s, block[4], 4, dest_cb, dct_linesize, s->chroma_qscale);
- put_dct(s, block[5], 5, dest_cr, dct_linesize, s->chroma_qscale);
- put_dct(s, block[6], 6, dest_cb + dct_offset, dct_linesize, s->chroma_qscale);
- put_dct(s, block[7], 7, dest_cr + dct_offset, dct_linesize, s->chroma_qscale);
- }
- }
- }else{
- s->dsp.idct_put(dest_y , dct_linesize, block[0]);
- s->dsp.idct_put(dest_y + block_size, dct_linesize, block[1]);
- s->dsp.idct_put(dest_y + dct_offset , dct_linesize, block[2]);
- s->dsp.idct_put(dest_y + dct_offset + block_size, dct_linesize, block[3]);
-
- if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
- if(s->chroma_y_shift){
- s->dsp.idct_put(dest_cb, uvlinesize, block[4]);
- s->dsp.idct_put(dest_cr, uvlinesize, block[5]);
- }else{
-
- dct_linesize = uvlinesize << s->interlaced_dct;
- dct_offset = s->interlaced_dct? uvlinesize : uvlinesize*block_size;
-
- s->dsp.idct_put(dest_cb, dct_linesize, block[4]);
- s->dsp.idct_put(dest_cr, dct_linesize, block[5]);
- s->dsp.idct_put(dest_cb + dct_offset, dct_linesize, block[6]);
- s->dsp.idct_put(dest_cr + dct_offset, dct_linesize, block[7]);
- if(!s->chroma_x_shift){//Chroma444
- s->dsp.idct_put(dest_cb + block_size, dct_linesize, block[8]);
- s->dsp.idct_put(dest_cr + block_size, dct_linesize, block[9]);
- s->dsp.idct_put(dest_cb + block_size + dct_offset, dct_linesize, block[10]);
- s->dsp.idct_put(dest_cr + block_size + dct_offset, dct_linesize, block[11]);
- }
- }
- }//gray
- }
- }
-skip_idct:
- if(!readable){
- s->dsp.put_pixels_tab[0][0](s->dest[0], dest_y , linesize,16);
- s->dsp.put_pixels_tab[s->chroma_x_shift][0](s->dest[1], dest_cb, uvlinesize,16 >> s->chroma_y_shift);
- s->dsp.put_pixels_tab[s->chroma_x_shift][0](s->dest[2], dest_cr, uvlinesize,16 >> s->chroma_y_shift);
- }
- }
-}
-
-void ff_MPV_decode_mb(MpegEncContext *s, int16_t block[12][64]){
-#if !CONFIG_SMALL
- if(s->out_format == FMT_MPEG1) {
- if(s->avctx->lowres) MPV_decode_mb_internal(s, block, 1, 1);
- else MPV_decode_mb_internal(s, block, 0, 1);
- } else
-#endif
- if(s->avctx->lowres) MPV_decode_mb_internal(s, block, 1, 0);
- 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(MpegEncContext *s, int y, int h){
- const int field_pic= s->picture_structure != PICT_FRAME;
- if(field_pic){
- h <<= 1;
- y <<= 1;
- }
-
- if (!s->avctx->hwaccel
- && !(s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
- && s->unrestricted_mv
- && s->current_picture.f.reference
- && !s->intra_only
- && !(s->flags&CODEC_FLAG_EMU_EDGE)) {
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->avctx->pix_fmt);
- int sides = 0, edge_h;
- int hshift = desc->log2_chroma_w;
- int vshift = desc->log2_chroma_h;
- if (y==0) sides |= EDGE_TOP;
- if (y + h >= s->v_edge_pos) sides |= EDGE_BOTTOM;
-
- edge_h= FFMIN(h, s->v_edge_pos - y);
-
- s->dsp.draw_edges(s->current_picture_ptr->f.data[0] + y *s->linesize,
- s->linesize, s->h_edge_pos, edge_h,
- EDGE_WIDTH, EDGE_WIDTH, sides);
- s->dsp.draw_edges(s->current_picture_ptr->f.data[1] + (y>>vshift)*s->uvlinesize,
- s->uvlinesize, s->h_edge_pos>>hshift, edge_h>>vshift,
- EDGE_WIDTH>>hshift, EDGE_WIDTH>>vshift, sides);
- s->dsp.draw_edges(s->current_picture_ptr->f.data[2] + (y>>vshift)*s->uvlinesize,
- s->uvlinesize, s->h_edge_pos>>hshift, edge_h>>vshift,
- EDGE_WIDTH>>hshift, EDGE_WIDTH>>vshift, sides);
- }
-
- h= FFMIN(h, s->avctx->height - y);
-
- if(field_pic && s->first_field && !(s->avctx->slice_flags&SLICE_FLAG_ALLOW_FIELD)) return;
-
- if (s->avctx->draw_horiz_band) {
- AVFrame *src;
- int offset[AV_NUM_DATA_POINTERS];
- int i;
-
- if(s->pict_type==AV_PICTURE_TYPE_B || s->low_delay || (s->avctx->slice_flags&SLICE_FLAG_CODED_ORDER))
- src = &s->current_picture_ptr->f;
- else if(s->last_picture_ptr)
- src = &s->last_picture_ptr->f;
- else
- return;
-
- if(s->pict_type==AV_PICTURE_TYPE_B && s->picture_structure == PICT_FRAME && s->out_format != FMT_H264){
- for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
- offset[i] = 0;
- }else{
- offset[0]= y * s->linesize;
- offset[1]=
- offset[2]= (y >> s->chroma_y_shift) * s->uvlinesize;
- for (i = 3; i < AV_NUM_DATA_POINTERS; i++)
- offset[i] = 0;
- }
-
- emms_c();
-
- s->avctx->draw_horiz_band(s->avctx, src, offset,
- y, s->picture_structure, h);
- }
-}
-
-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 mb_size= 4 - s->avctx->lowres;
-
- s->block_index[0]= s->b8_stride*(s->mb_y*2 ) - 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) - 2 + 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 - 1;
- 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));
-
- if(!(s->pict_type==AV_PICTURE_TYPE_B && s->avctx->draw_horiz_band && s->picture_structure==PICT_FRAME))
- {
- if(s->picture_structure==PICT_FRAME){
- s->dest[0] += s->mb_y * linesize << mb_size;
- s->dest[1] += s->mb_y * uvlinesize << (mb_size - s->chroma_y_shift);
- s->dest[2] += s->mb_y * uvlinesize << (mb_size - s->chroma_y_shift);
- }else{
- s->dest[0] += (s->mb_y>>1) * linesize << mb_size;
- s->dest[1] += (s->mb_y>>1) * uvlinesize << (mb_size - s->chroma_y_shift);
- s->dest[2] += (s->mb_y>>1) * uvlinesize << (mb_size - s->chroma_y_shift);
- av_assert1((s->mb_y&1) == (s->picture_structure == PICT_BOTTOM_FIELD));
- }
- }
-}
-
-/**
- * Permute an 8x8 block.
- * @param block the block which will be permuted according to the given permutation vector
- * @param permutation the permutation vector
- * @param last the last non zero coefficient in scantable order, used to speed the permutation up
- * @param scantable the used scantable, this is only used to speed the permutation up, the block is not
- * (inverse) permutated to scantable order!
- */
-void ff_block_permute(int16_t *block, uint8_t *permutation, const uint8_t *scantable, int last)
-{
- int i;
- int16_t temp[64];
-
- if(last<=0) return;
- //if(permutation[1]==1) return; //FIXME it is ok but not clean and might fail for some permutations
-
- for(i=0; i<=last; i++){
- const int j= scantable[i];
- temp[j]= block[j];
- block[j]=0;
- }
-
- for(i=0; i<=last; i++){
- const int j= scantable[i];
- const int perm_j= permutation[j];
- block[perm_j]= temp[j];
- }
-}
-
-void ff_mpeg_flush(AVCodecContext *avctx){
- int i;
- MpegEncContext *s = avctx->priv_data;
-
- if(s==NULL || s->picture==NULL)
- return;
-
- for(i=0; i<s->picture_count; i++){
- if (s->picture[i].f.data[0] &&
- (s->picture[i].f.type == FF_BUFFER_TYPE_INTERNAL ||
- s->picture[i].f.type == FF_BUFFER_TYPE_USER))
- free_frame_buffer(s, &s->picture[i]);
- }
- s->current_picture_ptr = s->last_picture_ptr = s->next_picture_ptr = NULL;
-
- s->mb_x= s->mb_y= 0;
- s->closed_gop= 0;
-
- s->parse_context.state= -1;
- s->parse_context.frame_start_found= 0;
- s->parse_context.overread= 0;
- s->parse_context.overread_index= 0;
- s->parse_context.index= 0;
- s->parse_context.last_index= 0;
- s->bitstream_buffer_size=0;
- 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;
-
- assert(s->block_last_index[n]>=0);
-
- 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;
-
- assert(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.
- */
-void ff_set_qscale(MpegEncContext * s, int qscale)
-{
- if (qscale < 1)
- qscale = 1;
- else if (qscale > 31)
- qscale = 31;
-
- s->qscale = qscale;
- s->chroma_qscale= s->chroma_qscale_table[qscale];
-
- s->y_dc_scale= s->y_dc_scale_table[ qscale ];
- s->c_dc_scale= s->c_dc_scale_table[ s->chroma_qscale ];
-}
-
-void ff_MPV_report_decode_progress(MpegEncContext *s)
-{
- if (s->pict_type != AV_PICTURE_TYPE_B && !s->partitioned_frame && !s->error_occurred)
- ff_thread_report_progress(&s->current_picture_ptr->f, s->mb_y, 0);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpegvideo.h b/src/thirdparty/ffmpeg/libavcodec/mpegvideo.h
deleted file mode 100644
index 176f074ca..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpegvideo.h
+++ /dev/null
@@ -1,943 +0,0 @@
-/*
- * Generic DCT based hybrid video encoder
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
- * Copyright (c) 2002-2004 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
- */
-
-/**
- * @file
- * mpegvideo header.
- */
-
-#ifndef AVCODEC_MPEGVIDEO_H
-#define AVCODEC_MPEGVIDEO_H
-
-#include "avcodec.h"
-#include "dsputil.h"
-#include "get_bits.h"
-#include "h264chroma.h"
-#include "put_bits.h"
-#include "ratecontrol.h"
-#include "parser.h"
-#include "mpeg12data.h"
-#include "rl.h"
-#include "videodsp.h"
-
-#include "libavutil/opt.h"
-#include "libavutil/timecode.h"
-
-#define FRAME_SKIPPED 100 ///< return value for header parsers if frame is not coded
-
-enum OutputFormat {
- FMT_MPEG1,
- FMT_H261,
- FMT_H263,
- FMT_MJPEG,
- FMT_H264,
-};
-
-#define MPEG_BUF_SIZE (16 * 1024)
-
-#define QMAT_SHIFT_MMX 16
-#define QMAT_SHIFT 21
-
-#define MAX_FCODE 7
-#define MAX_MV 4096
-
-#define MAX_THREADS 32
-#define MAX_PICTURE_COUNT 36
-
-#define ME_MAP_SIZE 64
-#define ME_MAP_SHIFT 3
-#define ME_MAP_MV_BITS 11
-
-#define MAX_MB_BYTES (30*16*16*3/8 + 120)
-
-#define INPLACE_OFFSET 16
-
-/* Start codes. */
-#define SEQ_END_CODE 0x000001b7
-#define SEQ_START_CODE 0x000001b3
-#define GOP_START_CODE 0x000001b8
-#define PICTURE_START_CODE 0x00000100
-#define SLICE_MIN_START_CODE 0x00000101
-#define SLICE_MAX_START_CODE 0x000001af
-#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;
-
- int8_t *qscale_table_base;
- int16_t (*motion_val_base[2])[2];
- uint32_t *mb_type_base;
-#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 sync; ///< has been decoded after a keyframe
-
- int mb_var_sum; ///< sum of MB variance for current frame
- int mc_mb_var_sum; ///< motion compensated MB variance for current frame
- uint16_t *mb_var; ///< Table for MB variances
- uint16_t *mc_mb_var; ///< Table for motion compensated MB variances
- uint8_t *mb_mean; ///< Table for MB luminance
- int b_frame_score; /* */
- struct MpegEncContext *owner2; ///< pointer to the MpegEncContext that allocated this picture
- int needs_realloc; ///< Picture needs to be reallocated (eg due to a frame size change)
- int period_since_free; ///< "cycles" since this Picture has been freed
-} Picture;
-
-/**
- * Motion estimation context.
- */
-typedef struct MotionEstContext{
- AVCodecContext *avctx;
- int skip; ///< set if ME is skipped for the current MB
- int co_located_mv[4][2]; ///< mv from last P-frame for direct mode ME
- int direct_basis_mv[4][2];
- uint8_t *scratchpad; ///< data area for the ME algo, so that the ME does not need to malloc/free
- uint8_t *best_mb;
- uint8_t *temp_mb[2];
- uint8_t *temp;
- int best_bits;
- uint32_t *map; ///< map to avoid duplicate evaluations
- uint32_t *score_map; ///< map to store the scores
- unsigned map_generation;
- int pre_penalty_factor;
- int penalty_factor; /**< an estimate of the bits required to
- code a given mv value, e.g. (1,0) takes
- more bits than (0,0). We have to
- estimate whether any reduction in
- residual is worth the extra bits. */
- int sub_penalty_factor;
- int mb_penalty_factor;
- int flags;
- int sub_flags;
- int mb_flags;
- int pre_pass; ///< = 1 for the pre pass
- int dia_size;
- int xmin;
- int xmax;
- int ymin;
- int ymax;
- int pred_x;
- int pred_y;
- uint8_t *src[4][4];
- uint8_t *ref[4][4];
- int stride;
- int uvstride;
- /* temp variables for picture complexity calculation */
- int mc_mb_var_sum_temp;
- int mb_var_sum_temp;
- int scene_change_score;
-/* cmp, chroma_cmp;*/
- op_pixels_func (*hpel_put)[4];
- op_pixels_func (*hpel_avg)[4];
- qpel_mc_func (*qpel_put)[16];
- qpel_mc_func (*qpel_avg)[16];
- uint8_t (*mv_penalty)[MAX_MV*2+1]; ///< amount of bits needed to encode a MV
- uint8_t *current_mv_penalty;
- int (*sub_motion_search)(struct MpegEncContext * s,
- int *mx_ptr, int *my_ptr, int dmin,
- int src_index, int ref_index,
- int size, int h);
-}MotionEstContext;
-
-/**
- * MpegEncContext.
- */
-typedef struct MpegEncContext {
- AVClass *class;
- struct AVCodecContext *avctx;
- /* the following parameters must be initialized before encoding */
- int width, height;///< picture size. must be a multiple of 16
- int gop_size;
- int intra_only; ///< if true, only intra pictures are generated
- int bit_rate; ///< wanted bit rate
- enum OutputFormat out_format; ///< output format
- int h263_pred; ///< use mpeg4/h263 ac/dc predictions
- int pb_frame; ///< PB frame mode (0 = none, 1 = base, 2 = improved)
-
-/* the following codec id fields are deprecated in favor of codec_id */
- int h263_plus; ///< h263 plus headers
- int h263_flv; ///< use flv h263 header
-
- enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */
- int fixed_qscale; ///< fixed qscale if non zero
- int encoding; ///< true if we are encoding (vs decoding)
- int flags; ///< AVCodecContext.flags (HQ, MV4, ...)
- int flags2; ///< AVCodecContext.flags2
- int max_b_frames; ///< max number of b-frames for encoding
- int luma_elim_threshold;
- int chroma_elim_threshold;
- int strict_std_compliance; ///< strictly follow the std (MPEG4, ...)
- int workaround_bugs; ///< workaround bugs in encoders which cannot be detected automatically
- int codec_tag; ///< internal codec_tag upper case converted from avctx codec_tag
- int stream_codec_tag; ///< internal stream_codec_tag upper case converted from avctx stream_codec_tag
- /* the following fields are managed internally by the encoder */
-
- /* sequence parameters */
- int context_initialized;
- int input_picture_number; ///< used to set pic->display_picture_number, should not be used for/by anything else
- int coded_picture_number; ///< used to set pic->coded_picture_number, should not be used for/by anything else
- int picture_number; //FIXME remove, unclear definition
- int picture_in_gop_number; ///< 0-> first pic in gop, ...
- 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
- int linesize; ///< line size, in bytes, may be different from width
- int uvlinesize; ///< line size, for chroma in bytes, may be different from width
- Picture *picture; ///< main picture buffer
- 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_video()
- /**
- * pts difference between the first and second input frame, used for
- * calculating dts of the first frame when there's a delay */
- int64_t dts_delta;
- /**
- * reordered pts to be used as dts for the next output frame when there's
- * a delay */
- int64_t reordered_pts;
-
- /** bit output */
- PutBitContext pb;
-
- int start_mb_y; ///< start mb_y of this thread (so current thread should process start_mb_y <= row < end_mb_y)
- int end_mb_y; ///< end mb_y of this thread (so current thread should process start_mb_y <= row < end_mb_y)
- struct MpegEncContext *thread_context[MAX_THREADS];
- int slice_context_count; ///< number of used thread_contexts
-
- /**
- * copy of the previous picture structure.
- * note, linesize & data, might not match the previous picture (for field pictures)
- */
- Picture last_picture;
-
- /**
- * copy of the next picture structure.
- * note, linesize & data, might not match the next picture (for field pictures)
- */
- Picture next_picture;
-
- /**
- * copy of the source picture structure for encoding.
- * note, linesize & data, might not match the source picture (for field pictures)
- */
- Picture new_picture;
-
- /**
- * copy of the current picture structure.
- * note, linesize & data, might not match the current picture (for field pictures)
- */
- Picture current_picture; ///< buffer to store the decompressed current picture
-
- Picture *last_picture_ptr; ///< pointer to the previous picture.
- Picture *next_picture_ptr; ///< pointer to the next picture (for bidir pred)
- Picture *current_picture_ptr; ///< pointer to the current picture
- int picture_count; ///< number of allocated pictures (MAX_PICTURE_COUNT * avctx->thread_count)
- int picture_range_start, picture_range_end; ///< the part of picture that this context can allocate in
- uint8_t *visualization_buffer[3]; ///< temporary buffer vor MV visualization
- int last_dc[3]; ///< last DC values for MPEG1
- int16_t *dc_val_base;
- int16_t *dc_val[3]; ///< used for mpeg4 DC prediction, all 3 arrays must be continuous
- const uint8_t *y_dc_scale_table; ///< qscale -> y_dc_scale table
- const uint8_t *c_dc_scale_table; ///< qscale -> c_dc_scale table
- const uint8_t *chroma_qscale_table; ///< qscale -> chroma_qscale (h263)
- uint8_t *coded_block_base;
- uint8_t *coded_block; ///< used for coded block pattern prediction (msmpeg4v3, wmv1)
- int16_t (*ac_val_base)[16];
- int16_t (*ac_val[3])[16]; ///< used for for mpeg4 AC prediction, all 3 arrays must be continuous
- int mb_skipped; ///< MUST BE SET only during DECODING
- uint8_t *mbskip_table; /**< used to avoid copy if macroblock skipped (for black regions for example)
- and used for b-frame encoding & decoding (contains skip table of next P Frame) */
- uint8_t *mbintra_table; ///< used to avoid setting {ac, dc, cbp}-pred stuff to zero on inter MB decoding
- uint8_t *cbp_table; ///< used to store cbp, ac_pred for partitioned decoding
- uint8_t *pred_dir_table; ///< used to store pred_dir for partitioned decoding
- uint8_t *edge_emu_buffer; ///< temporary buffer for if MVs point to out-of-frame data
- uint8_t *rd_scratchpad; ///< scratchpad for rate distortion mb decision
- uint8_t *obmc_scratchpad;
- uint8_t *b_scratchpad; ///< scratchpad used for writing into write only buffers
-
- int qscale; ///< QP
- int chroma_qscale; ///< chroma QP
- unsigned int lambda; ///< lagrange multipler used in rate distortion
- unsigned int lambda2; ///< (lambda*lambda) >> FF_LAMBDA_SHIFT
- int *lambda_table;
- int adaptive_quant; ///< use adaptive quantization
- int dquant; ///< qscale difference to prev qscale
- int closed_gop; ///< MPEG1/2 GOP is closed
- int pict_type; ///< AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ...
- int vbv_delay;
- int last_pict_type; //FIXME removes
- int last_non_b_pict_type; ///< used for mpeg4 gmc b-frames & ratecontrol
- int droppable;
- int frame_rate_index;
- AVRational mpeg2_frame_rate_ext;
- int last_lambda_for[5]; ///< last lambda for a specific pict type
- int skipdct; ///< skip dct and code zero residual
-
- /* motion compensation */
- int unrestricted_mv; ///< mv can point outside of the coded picture
- int h263_long_vectors; ///< use horrible h263v1 long vector mode
-
- DSPContext dsp; ///< pointers for accelerated dsp functions
- H264ChromaContext h264chroma;
- VideoDSPContext vdsp;
- int f_code; ///< forward MV resolution
- int b_code; ///< backward MV resolution for B Frames (mpeg4)
- int16_t (*p_mv_table_base)[2];
- int16_t (*b_forw_mv_table_base)[2];
- int16_t (*b_back_mv_table_base)[2];
- int16_t (*b_bidir_forw_mv_table_base)[2];
- int16_t (*b_bidir_back_mv_table_base)[2];
- int16_t (*b_direct_mv_table_base)[2];
- int16_t (*p_field_mv_table_base[2][2])[2];
- int16_t (*b_field_mv_table_base[2][2][2])[2];
- int16_t (*p_mv_table)[2]; ///< MV table (1MV per MB) p-frame encoding
- int16_t (*b_forw_mv_table)[2]; ///< MV table (1MV per MB) forward mode b-frame encoding
- int16_t (*b_back_mv_table)[2]; ///< MV table (1MV per MB) backward mode b-frame encoding
- int16_t (*b_bidir_forw_mv_table)[2]; ///< MV table (1MV per MB) bidir mode b-frame encoding
- int16_t (*b_bidir_back_mv_table)[2]; ///< MV table (1MV per MB) bidir mode b-frame encoding
- int16_t (*b_direct_mv_table)[2]; ///< MV table (1MV per MB) direct mode b-frame encoding
- int16_t (*p_field_mv_table[2][2])[2]; ///< MV table (2MV per MB) interlaced p-frame encoding
- int16_t (*b_field_mv_table[2][2][2])[2];///< MV table (4MV per MB) interlaced b-frame encoding
- uint8_t (*p_field_select_table[2]);
- uint8_t (*b_field_select_table[2][2]);
- int me_method; ///< ME algorithm
- int mv_dir;
-#define MV_DIR_FORWARD 1
-#define MV_DIR_BACKWARD 2
-#define MV_DIRECT 4 ///< bidirectional mode where the difference equals the MV of the last P/S/I-Frame (mpeg4)
- int mv_type;
-#define MV_TYPE_16X16 0 ///< 1 vector for the whole mb
-#define MV_TYPE_8X8 1 ///< 4 vectors (h263, mpeg4 4MV)
-#define MV_TYPE_16X8 2 ///< 2 vectors, one per 16x8 block
-#define MV_TYPE_FIELD 3 ///< 2 vectors, one per field
-#define MV_TYPE_DMV 4 ///< 2 vectors, special mpeg2 Dual Prime Vectors
- /**motion vectors for a macroblock
- first coordinate : 0 = forward 1 = backward
- second " : depend on type
- third " : 0 = x, 1 = y
- */
- int mv[2][4][2];
- int field_select[2][2];
- int last_mv[2][2][2]; ///< last MV, used for MV prediction in MPEG1 & B-frame MPEG4
- uint8_t *fcode_tab; ///< smallest fcode needed for each MV
- int16_t direct_scale_mv[2][64]; ///< precomputed to avoid divisions in ff_mpeg4_set_direct_mv
-
- MotionEstContext me;
-
- int no_rounding; /**< apply no rounding to motion compensation (MPEG4, msmpeg4, ...)
- for b-frames rounding mode is always 0 */
-
- /* macroblock layer */
- 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
-
- int block_index[6]; ///< index to current MB in block based arrays with edges
- int block_wrap[6];
- uint8_t *dest[3];
-
- int *mb_index2xy; ///< mb_index -> mb_x + mb_y*mb_stride
-
- /** matrix transmitted in the bitstream */
- uint16_t intra_matrix[64];
- uint16_t chroma_intra_matrix[64];
- uint16_t inter_matrix[64];
- uint16_t chroma_inter_matrix[64];
-#define QUANT_BIAS_SHIFT 8
- int intra_quant_bias; ///< bias for the quantizer
- int inter_quant_bias; ///< bias for the quantizer
- int min_qcoeff; ///< minimum encodable coefficient
- int max_qcoeff; ///< maximum encodable coefficient
- int ac_esc_length; ///< num of bits needed to encode the longest esc
- uint8_t *intra_ac_vlc_length;
- uint8_t *intra_ac_vlc_last_length;
- uint8_t *inter_ac_vlc_length;
- uint8_t *inter_ac_vlc_last_length;
- uint8_t *luma_dc_vlc_length;
-#define UNI_AC_ENC_INDEX(run,level) ((run)*128 + (level))
-
- int coded_score[12];
-
- /** precomputed matrix (combine qscale and DCT renorm) */
- int (*q_intra_matrix)[64];
- int (*q_chroma_intra_matrix)[64];
- int (*q_inter_matrix)[64];
- /** identical to the above but for MMX & these are not permutated, second 64 entries are bias*/
- uint16_t (*q_intra_matrix16)[2][64];
- uint16_t (*q_chroma_intra_matrix16)[2][64];
- uint16_t (*q_inter_matrix16)[2][64];
-
- /* noise reduction */
- int (*dct_error_sum)[64];
- int dct_count[2];
- uint16_t (*dct_offset)[64];
-
- void *opaque; ///< private data for the user
-
- /* bit rate control */
- int64_t total_bits;
- int frame_bits; ///< bits used for the current frame
- int stuffing_bits; ///< bits used for stuffing
- int next_lambda; ///< next lambda used for retrying to encode a frame
- RateControlContext rc_context; ///< contains stuff only accessed in ratecontrol.c
-
- /* statistics, used for 2-pass encoding */
- int mv_bits;
- int header_bits;
- int i_tex_bits;
- int p_tex_bits;
- int i_count;
- int f_count;
- int b_count;
- int skip_count;
- int misc_bits; ///< cbp, mb_type
- int last_bits; ///< temp var used for calculating the above vars
-
- /* error concealment / resync */
- int error_count, error_occurred;
- uint8_t *error_status_table; ///< table of the error status of each MB
-#define VP_START 1 ///< current MB is the first after a resync marker
-#define ER_AC_ERROR 2
-#define ER_DC_ERROR 4
-#define ER_MV_ERROR 8
-#define ER_AC_END 16
-#define ER_DC_END 32
-#define ER_MV_END 64
-
-#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)
-
- int resync_mb_x; ///< x position of last resync marker
- int resync_mb_y; ///< y position of last resync marker
- GetBitContext last_resync_gb; ///< used to search for the next resync marker
- int mb_num_left; ///< number of MBs left in this video packet (for partitioned Slices only)
- int next_p_frame_damaged; ///< set if the next p frame is damaged, to avoid showing trashed b frames
- int err_recognition;
-
- ParseContext parse_context;
-
- /* H.263 specific */
- int gob_index;
- int obmc; ///< overlapped block motion compensation
- int showed_packed_warning; ///< flag for having shown the warning about divxs invalid b frames
- int mb_info; ///< interval for outputting info about mb offsets as side data
- int prev_mb_info, last_mb_info;
- uint8_t *mb_info_ptr;
- int mb_info_size;
-
- /* H.263+ specific */
- int umvplus; ///< == H263+ && unrestricted_mv
- int h263_aic_dir; ///< AIC direction: 0 = left, 1 = top
- int h263_slice_structured;
- int alt_inter_vlc; ///< alternative inter vlc
- int modified_quant;
- int loop_filter;
- int custom_pcf;
-
- /* mpeg4 specific */
- int time_increment_bits; ///< number of bits to represent the fractional part of time
- int last_time_base;
- int time_base; ///< time in seconds of last I,P,S Frame
- int64_t time; ///< time of current frame
- int64_t last_non_b_time;
- uint16_t pp_time; ///< time distance between the last 2 p,s,i frames
- uint16_t pb_time; ///< time distance between the last b and p,s,i frame
- uint16_t pp_field_time;
- uint16_t pb_field_time; ///< like above, just for interlaced
- int shape;
- int vol_sprite_usage;
- int sprite_width;
- int sprite_height;
- int sprite_left;
- int sprite_top;
- int sprite_brightness_change;
- int num_sprite_warping_points;
- int real_sprite_warping_points;
- uint16_t sprite_traj[4][2]; ///< sprite trajectory points
- int sprite_offset[2][2]; ///< sprite offset[isChroma][isMVY]
- int sprite_delta[2][2]; ///< sprite_delta [isY][isMVY]
- int sprite_shift[2]; ///< sprite shift [isChroma]
- int mcsel;
- int quant_precision;
- int quarter_sample; ///< 1->qpel, 0->half pel ME/MC
- int scalability;
- int hierachy_type;
- int enhancement_type;
- int new_pred;
- int reduced_res_vop;
- int aspect_ratio_info; //FIXME remove
- int sprite_warping_accuracy;
- int low_latency_sprite;
- int data_partitioning; ///< data partitioning flag from header
- int partitioned_frame; ///< is current frame partitioned
- int rvlc; ///< reversible vlc
- int resync_marker; ///< could this stream contain resync markers
- int low_delay; ///< no reordering needed / has no b-frames
- int vo_type;
- int vol_control_parameters; ///< does the stream contain the low_delay flag, used to workaround buggy encoders
- int intra_dc_threshold; ///< QP above whch the ac VLC should be used for intra dc
- int use_intra_dc_vlc;
- PutBitContext tex_pb; ///< used for data partitioned VOPs
- PutBitContext pb2; ///< used for data partitioned VOPs
- int mpeg_quant;
- int t_frame; ///< time distance of first I -> B, used for interlaced b frames
- int padding_bug_score; ///< used to detect the VERY common padding bug in MPEG4
- int cplx_estimation_trash_i;
- int cplx_estimation_trash_p;
- int cplx_estimation_trash_b;
-
- /* divx specific, used to workaround (many) bugs in divx5 */
- int divx_version;
- int divx_build;
- int divx_packed;
- uint8_t *bitstream_buffer; //Divx 5.01 puts several frames in a single one, this is used to reorder them
- int bitstream_buffer_size;
- unsigned int allocated_bitstream_buffer_size;
-
- int xvid_build;
-
- /* lavc specific stuff, used to workaround bugs in libavcodec */
- int lavc_build;
-
- /* RV10 specific */
- int rv10_version; ///< RV10 version: 0 or 3
- int rv10_first_dc_coded[3];
- int orig_width, orig_height;
-
- /* MJPEG specific */
- struct MJpegContext *mjpeg_ctx;
- int mjpeg_vsample[3]; ///< vertical sampling factors, default = {2, 1, 1}
- int mjpeg_hsample[3]; ///< horizontal sampling factors, default = {2, 1, 1}
- int esc_pos;
-
- /* MSMPEG4 specific */
- int mv_table_index;
- int rl_table_index;
- int rl_chroma_table_index;
- int dc_table_index;
- int use_skip_mb_code;
- int slice_height; ///< in macroblocks
- int first_slice_line; ///< used in mpeg4 too to handle resync markers
- int flipflop_rounding;
- int msmpeg4_version; ///< 0=not msmpeg4, 1=mp41, 2=mp42, 3=mp43/divx3 4=wmv1/7 5=wmv2/8
- int per_mb_rl_table;
- int esc3_level_length;
- int esc3_run_length;
- /** [mb_intra][isChroma][level][run][last] */
- int (*ac_stats)[2][MAX_LEVEL+1][MAX_RUN+1][2];
- int inter_intra_pred;
- int mspel;
-
- /* decompression specific */
- GetBitContext gb;
-
- /* Mpeg1 specific */
- int gop_picture_number; ///< index of the first picture of a GOP based on fake_pic_num & mpeg1 specific
- int last_mv_dir; ///< last mv_dir, used for b frame encoding
- int broken_link; ///< no_output_of_prior_pics_flag
- uint8_t *vbv_delay_ptr; ///< pointer to vbv_delay in the bitstream
-
- /* MPEG-2-specific - I wished not to have to support this mess. */
- int progressive_sequence;
- int mpeg_f_code[2][2];
- 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;
- int top_field_first;
- int concealment_motion_vectors;
- int q_scale_type;
- int intra_vlc_format;
- int alternate_scan;
- int repeat_first_field;
- int chroma_420_type;
- int chroma_format;
-#define CHROMA_420 1
-#define CHROMA_422 2
-#define CHROMA_444 3
- int chroma_x_shift;//depend on pix_format, that depend on chroma_format
- int chroma_y_shift;
-
- int progressive_frame;
- int full_pel[2];
- int interlaced_dct;
- int first_slice;
- int first_field; ///< is 1 for the first field of a field picture 0 otherwise
- int drop_frame_timecode; ///< timecode is in drop frame format.
- int scan_offset; ///< reserve space for SVCD scan offset user data.
-
- /* RTP specific */
- int rtp_mode;
-
- char *tc_opt_str; ///< timecode option string
- AVTimecode tc; ///< timecode context
-
- uint8_t *ptr_lastgob;
- int swap_uv; //vcr2 codec is an MPEG-2 variant with U and V swapped
- int16_t (*pblocks[12])[64];
-
- int16_t (*block)[64]; ///< points to one of the following blocks
- int16_t (*blocks)[12][64]; // for HQ mode we need to keep the best block
- int (*decode_mb)(struct MpegEncContext *s, int16_t block[6][64]); // used by some codecs to avoid a switch()
-#define SLICE_OK 0
-#define SLICE_ERROR -1
-#define SLICE_END -2 ///<end marker found
-#define SLICE_NOEND -3 ///<no end marker or error found but mb count exceeded
-
- void (*dct_unquantize_mpeg1_intra)(struct MpegEncContext *s,
- int16_t *block/*align 16*/, int n, int qscale);
- void (*dct_unquantize_mpeg1_inter)(struct MpegEncContext *s,
- int16_t *block/*align 16*/, int n, int qscale);
- void (*dct_unquantize_mpeg2_intra)(struct MpegEncContext *s,
- int16_t *block/*align 16*/, int n, int qscale);
- void (*dct_unquantize_mpeg2_inter)(struct MpegEncContext *s,
- int16_t *block/*align 16*/, int n, int qscale);
- void (*dct_unquantize_h263_intra)(struct MpegEncContext *s,
- int16_t *block/*align 16*/, int n, int qscale);
- void (*dct_unquantize_h263_inter)(struct MpegEncContext *s,
- int16_t *block/*align 16*/, int n, int qscale);
- void (*dct_unquantize_h261_intra)(struct MpegEncContext *s,
- int16_t *block/*align 16*/, int n, int qscale);
- void (*dct_unquantize_h261_inter)(struct MpegEncContext *s,
- int16_t *block/*align 16*/, int n, int qscale);
- void (*dct_unquantize_intra)(struct MpegEncContext *s, // unquantizer to use (mpeg4 can use both)
- int16_t *block/*align 16*/, int n, int qscale);
- void (*dct_unquantize_inter)(struct MpegEncContext *s, // unquantizer to use (mpeg4 can use both)
- int16_t *block/*align 16*/, int n, int qscale);
- int (*dct_quantize)(struct MpegEncContext *s, int16_t *block/*align 16*/, int n, int qscale, int *overflow);
- int (*fast_dct_quantize)(struct MpegEncContext *s, int16_t *block/*align 16*/, int n, int qscale, int *overflow);
- void (*denoise_dct)(struct MpegEncContext *s, int16_t *block);
-
- int mpv_flags; ///< flags set by private options
- int quantizer_noise_shaping;
-
- /* error resilience stuff */
- uint8_t *er_temp_buffer;
-
- /* temp buffers for rate control */
- float *cplx_tab, *bits_tab;
-
- /* flag to indicate a reinitialization is required, e.g. after
- * a frame size change */
- int context_reinit;
-} MpegEncContext;
-
-#define REBASE_PICTURE(pic, new_ctx, old_ctx) \
- ((pic && pic >= old_ctx->picture && \
- pic < old_ctx->picture + old_ctx->picture_count) ? \
- &new_ctx->picture[pic - old_ctx->picture] : NULL)
-
-/* mpegvideo_enc common options */
-#define FF_MPV_FLAG_SKIP_RD 0x0001
-#define FF_MPV_FLAG_STRICT_GOP 0x0002
-#define FF_MPV_FLAG_QP_RD 0x0004
-#define FF_MPV_FLAG_CBP_RD 0x0008
-
-#define FF_MPV_OFFSET(x) offsetof(MpegEncContext, x)
-#define FF_MPV_OPT_FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
-#define FF_MPV_COMMON_OPTS \
-{ "mpv_flags", "Flags common for all mpegvideo-based encoders.", FF_MPV_OFFSET(mpv_flags), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "mpv_flags" },\
-{ "skip_rd", "RD optimal MB level residual skipping", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_SKIP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\
-{ "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" },\
-{ "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)",\
- FF_MPV_OFFSET(chroma_elim_threshold), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },\
-{ "quantizer_noise_shaping", NULL, FF_MPV_OFFSET(quantizer_noise_shaping), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FF_MPV_OPT_FLAGS },
-
-extern const AVOption ff_mpv_generic_options[];
-
-#define FF_MPV_GENERIC_CLASS(name) \
-static const AVClass name ## _class = {\
- .class_name = #name " encoder",\
- .item_name = av_default_item_name,\
- .option = ff_mpv_generic_options,\
- .version = LIBAVUTIL_VERSION_INT,\
-};
-
-/**
- * Set the given MpegEncContext to common defaults (same for encoding
- * and decoding). The changed fields will not depend upon the prior
- * state of the MpegEncContext.
- */
-void ff_MPV_common_defaults(MpegEncContext *s);
-
-void ff_MPV_decode_defaults(MpegEncContext *s);
-int ff_MPV_common_init(MpegEncContext *s);
-int ff_mpv_frame_size_alloc(MpegEncContext *s, int linesize);
-int ff_MPV_common_frame_size_change(MpegEncContext *s);
-void ff_MPV_common_end(MpegEncContext *s);
-void ff_MPV_decode_mb(MpegEncContext *s, int16_t block[12][64]);
-int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx);
-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);
-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_altivec(MpegEncContext *s);
-void ff_MPV_common_init_bfin(MpegEncContext *s);
-void ff_clean_intra_table_entries(MpegEncContext *s);
-void ff_draw_horiz_band(MpegEncContext *s, int y, int h);
-void ff_mpeg_flush(AVCodecContext *avctx);
-void ff_print_debug_info(MpegEncContext *s, AVFrame *pict);
-void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix);
-void ff_release_unused_pictures(MpegEncContext *s, int remove_current);
-int ff_find_unused_picture(MpegEncContext *s, int shared);
-void ff_denoise_dct(MpegEncContext *s, int16_t *block);
-int ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src);
-int ff_MPV_lowest_referenced_row(MpegEncContext *s, int dir);
-void ff_MPV_report_decode_progress(MpegEncContext *s);
-int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src);
-const uint8_t *avpriv_mpv_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state);
-void ff_set_qscale(MpegEncContext * s, int qscale);
-
-void ff_er_frame_start(MpegEncContext *s);
-void ff_er_frame_end(MpegEncContext *s);
-void ff_er_add_slice(MpegEncContext *s, int startx, int starty, int endx, int endy, int status);
-
-int ff_dct_common_init(MpegEncContext *s);
-int ff_dct_encode_init(MpegEncContext *s);
-void ff_convert_matrix(DSPContext *dsp, int (*qmat)[64], uint16_t (*qmat16)[2][64],
- const uint16_t *quant_matrix, int bias, int qmin, int qmax, int intra);
-int ff_dct_quantize_c(MpegEncContext *s, int16_t *block, int n, int qscale, int *overflow);
-
-void ff_init_block_index(MpegEncContext *s);
-void ff_copy_picture(Picture *dst, Picture *src);
-
-void ff_MPV_motion(MpegEncContext *s,
- uint8_t *dest_y, uint8_t *dest_cb,
- uint8_t *dest_cr, int dir,
- uint8_t **ref_picture,
- op_pixels_func (*pix_op)[4],
- qpel_mc_func (*qpix_op)[16]);
-
-/**
- * Allocate a Picture.
- * The pixels are allocated/set by calling get_buffer() if shared = 0.
- */
-int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared);
-
-extern const enum AVPixelFormat ff_pixfmt_list_420[];
-extern const enum AVPixelFormat ff_hwaccel_pixfmt_list_420[];
-
-/**
- * permute block according to permuatation.
- * @param last last non zero element in scantable order
- */
-void ff_block_permute(int16_t *block, uint8_t *permutation, const uint8_t *scantable, int last);
-
-static inline void ff_update_block_index(MpegEncContext *s){
- const int block_size= 8 >> s->avctx->lowres;
-
- s->block_index[0]+=2;
- s->block_index[1]+=2;
- s->block_index[2]+=2;
- s->block_index[3]+=2;
- s->block_index[4]++;
- s->block_index[5]++;
- s->dest[0]+= 2*block_size;
- s->dest[1]+= block_size;
- s->dest[2]+= block_size;
-}
-
-static inline int get_bits_diff(MpegEncContext *s){
- const int bits= put_bits_count(&s->pb);
- const int last= s->last_bits;
-
- s->last_bits = bits;
-
- return bits - last;
-}
-
-static inline int ff_h263_round_chroma(int x){
- static const uint8_t h263_chroma_roundtab[16] = {
- // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
- 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1,
- };
- return h263_chroma_roundtab[x & 0xf] + (x >> 3);
-}
-
-/* motion_est.c */
-void ff_estimate_p_frame_motion(MpegEncContext * s,
- int mb_x, int mb_y);
-void ff_estimate_b_frame_motion(MpegEncContext * s,
- int mb_x, int mb_y);
-int ff_get_best_fcode(MpegEncContext * s, int16_t (*mv_table)[2], int type);
-void ff_fix_long_p_mvs(MpegEncContext * s);
-void ff_fix_long_mvs(MpegEncContext * s, uint8_t *field_select_table, int field_select,
- int16_t (*mv_table)[2], int f_code, int type, int truncate);
-int ff_init_me(MpegEncContext *s);
-int ff_pre_estimate_p_frame_motion(MpegEncContext * s, int mb_x, int mb_y);
-int ff_epzs_motion_search(MpegEncContext * s, int *mx_ptr, int *my_ptr,
- int P[10][2], int src_index, int ref_index, int16_t (*last_mv)[2],
- int ref_mv_scale, int size, int h);
-int ff_get_mb_score(MpegEncContext * s, int mx, int my, int src_index,
- int ref_index, int size, int h, int add_rate);
-
-/* mpeg12.c */
-extern const uint8_t ff_mpeg1_dc_scale_table[128];
-extern const uint8_t * const ff_mpeg2_dc_scale_table[4];
-
-void ff_mpeg1_encode_picture_header(MpegEncContext *s, int picture_number);
-void ff_mpeg1_encode_mb(MpegEncContext *s,
- int16_t block[6][64],
- int motion_x, int motion_y);
-void ff_mpeg1_encode_init(MpegEncContext *s);
-void ff_mpeg1_encode_slice_header(MpegEncContext *s);
-void ff_mpeg1_clean_buffers(MpegEncContext *s);
-int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size, AVCodecParserContext *s);
-
-extern const uint8_t ff_aic_dc_scale_table[32];
-extern const uint8_t ff_h263_chroma_qscale_table[32];
-extern const uint8_t ff_h263_loop_filter_strength[32];
-
-/* h261.c */
-void ff_h261_loop_filter(MpegEncContext *s);
-void ff_h261_reorder_mb_index(MpegEncContext* s);
-void ff_h261_encode_mb(MpegEncContext *s,
- int16_t block[6][64],
- int motion_x, int motion_y);
-void ff_h261_encode_picture_header(MpegEncContext * s, int picture_number);
-void ff_h261_encode_init(MpegEncContext *s);
-int ff_h261_get_picture_format(int width, int height);
-
-
-/* rv10.c */
-void ff_rv10_encode_picture_header(MpegEncContext *s, int picture_number);
-int ff_rv_decode_dc(MpegEncContext *s, int n);
-void ff_rv20_encode_picture_header(MpegEncContext *s, int picture_number);
-
-
-/* msmpeg4.c */
-void ff_msmpeg4_encode_picture_header(MpegEncContext * s, int picture_number);
-void ff_msmpeg4_encode_ext_header(MpegEncContext * s);
-void ff_msmpeg4_encode_mb(MpegEncContext * s,
- int16_t block[6][64],
- int motion_x, int motion_y);
-int ff_msmpeg4_decode_picture_header(MpegEncContext * s);
-int ff_msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size);
-int ff_msmpeg4_decode_init(AVCodecContext *avctx);
-void ff_msmpeg4_encode_init(MpegEncContext *s);
-int ff_wmv2_decode_picture_header(MpegEncContext * s);
-int ff_wmv2_decode_secondary_picture_header(MpegEncContext * s);
-void ff_wmv2_add_mb(MpegEncContext *s, int16_t block[6][64], uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr);
-void ff_mspel_motion(MpegEncContext *s,
- uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
- uint8_t **ref_picture, op_pixels_func (*pix_op)[4],
- int motion_x, int motion_y, int h);
-int ff_wmv2_encode_picture_header(MpegEncContext * s, int picture_number);
-void ff_wmv2_encode_mb(MpegEncContext * s,
- int16_t block[6][64],
- int motion_x, int motion_y);
-
-#endif /* AVCODEC_MPEGVIDEO_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpegvideo_motion.c b/src/thirdparty/ffmpeg/libavcodec/mpegvideo_motion.c
deleted file mode 100644
index 2380e569d..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpegvideo_motion.c
+++ /dev/null
@@ -1,894 +0,0 @@
-/*
- * Copyright (c) 2000,2001 Fabrice Bellard
- * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
- *
- * 4MV & hq & B-frame encoding stuff 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
- */
-
-#include <string.h>
-
-#include "libavutil/avassert.h"
-#include "libavutil/internal.h"
-#include "avcodec.h"
-#include "dsputil.h"
-#include "mpegvideo.h"
-#include "mjpegenc.h"
-#include "msmpeg4.h"
-#include <limits.h>
-
-static void gmc1_motion(MpegEncContext *s,
- uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
- uint8_t **ref_picture)
-{
- uint8_t *ptr;
- int offset, src_x, src_y, linesize, uvlinesize;
- int motion_x, motion_y;
- int emu=0;
-
- motion_x= s->sprite_offset[0][0];
- motion_y= s->sprite_offset[0][1];
- src_x = s->mb_x * 16 + (motion_x >> (s->sprite_warping_accuracy+1));
- src_y = s->mb_y * 16 + (motion_y >> (s->sprite_warping_accuracy+1));
- motion_x<<=(3-s->sprite_warping_accuracy);
- motion_y<<=(3-s->sprite_warping_accuracy);
- src_x = av_clip(src_x, -16, s->width);
- if (src_x == s->width)
- motion_x =0;
- src_y = av_clip(src_y, -16, s->height);
- if (src_y == s->height)
- motion_y =0;
-
- linesize = s->linesize;
- uvlinesize = s->uvlinesize;
-
- ptr = ref_picture[0] + (src_y * linesize) + src_x;
-
- if(s->flags&CODEC_FLAG_EMU_EDGE){
- 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, 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, motion_x&15, motion_y&15, 128 - s->no_rounding);
- s->dsp.gmc1(dest_y+8, ptr+8, linesize, 16, motion_x&15, motion_y&15, 128 - s->no_rounding);
- }else{
- int dxy;
-
- dxy= ((motion_x>>3)&1) | ((motion_y>>2)&2);
- if (s->no_rounding){
- s->dsp.put_no_rnd_pixels_tab[0][dxy](dest_y, ptr, linesize, 16);
- }else{
- s->dsp.put_pixels_tab [0][dxy](dest_y, ptr, linesize, 16);
- }
- }
-
- if(CONFIG_GRAY && s->flags&CODEC_FLAG_GRAY) return;
-
- motion_x= s->sprite_offset[1][0];
- motion_y= s->sprite_offset[1][1];
- src_x = s->mb_x * 8 + (motion_x >> (s->sprite_warping_accuracy+1));
- src_y = s->mb_y * 8 + (motion_y >> (s->sprite_warping_accuracy+1));
- motion_x<<=(3-s->sprite_warping_accuracy);
- motion_y<<=(3-s->sprite_warping_accuracy);
- src_x = av_clip(src_x, -8, s->width>>1);
- if (src_x == s->width>>1)
- motion_x =0;
- src_y = av_clip(src_y, -8, s->height>>1);
- if (src_y == s->height>>1)
- motion_y =0;
-
- offset = (src_y * 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) - 9, 0)
- || (unsigned)src_y >= FFMAX((s->v_edge_pos>>1) - 9, 0)){
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr, 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);
-
- ptr = ref_picture[2] + offset;
- if(emu){
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr, uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
- ptr= s->edge_emu_buffer;
- }
- s->dsp.gmc1(dest_cr, ptr, uvlinesize, 8, motion_x&15, motion_y&15, 128 - s->no_rounding);
-
- return;
-}
-
-static void gmc_motion(MpegEncContext *s,
- uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
- uint8_t **ref_picture)
-{
- uint8_t *ptr;
- int linesize, uvlinesize;
- const int a= s->sprite_warping_accuracy;
- int ox, oy;
-
- linesize = s->linesize;
- uvlinesize = s->uvlinesize;
-
- ptr = ref_picture[0];
-
- ox= s->sprite_offset[0][0] + s->sprite_delta[0][0]*s->mb_x*16 + s->sprite_delta[0][1]*s->mb_y*16;
- oy= s->sprite_offset[0][1] + s->sprite_delta[1][0]*s->mb_x*16 + s->sprite_delta[1][1]*s->mb_y*16;
-
- s->dsp.gmc(dest_y, ptr, linesize, 16,
- ox,
- oy,
- s->sprite_delta[0][0], s->sprite_delta[0][1],
- s->sprite_delta[1][0], s->sprite_delta[1][1],
- a+1, (1<<(2*a+1)) - s->no_rounding,
- s->h_edge_pos, s->v_edge_pos);
- s->dsp.gmc(dest_y+8, ptr, linesize, 16,
- ox + s->sprite_delta[0][0]*8,
- oy + s->sprite_delta[1][0]*8,
- s->sprite_delta[0][0], s->sprite_delta[0][1],
- s->sprite_delta[1][0], s->sprite_delta[1][1],
- a+1, (1<<(2*a+1)) - s->no_rounding,
- s->h_edge_pos, s->v_edge_pos);
-
- if(CONFIG_GRAY && s->flags&CODEC_FLAG_GRAY) return;
-
- ox= s->sprite_offset[1][0] + s->sprite_delta[0][0]*s->mb_x*8 + s->sprite_delta[0][1]*s->mb_y*8;
- oy= s->sprite_offset[1][1] + s->sprite_delta[1][0]*s->mb_x*8 + s->sprite_delta[1][1]*s->mb_y*8;
-
- ptr = ref_picture[1];
- s->dsp.gmc(dest_cb, ptr, uvlinesize, 8,
- ox,
- oy,
- s->sprite_delta[0][0], s->sprite_delta[0][1],
- s->sprite_delta[1][0], s->sprite_delta[1][1],
- a+1, (1<<(2*a+1)) - s->no_rounding,
- s->h_edge_pos>>1, s->v_edge_pos>>1);
-
- ptr = ref_picture[2];
- s->dsp.gmc(dest_cr, ptr, uvlinesize, 8,
- ox,
- oy,
- s->sprite_delta[0][0], s->sprite_delta[0][1],
- s->sprite_delta[1][0], s->sprite_delta[1][1],
- a+1, (1<<(2*a+1)) - s->no_rounding,
- s->h_edge_pos>>1, s->v_edge_pos>>1);
-}
-
-static inline int hpel_motion(MpegEncContext *s,
- uint8_t *dest, uint8_t *src,
- int src_x, int src_y,
- op_pixels_func *pix_op,
- int motion_x, int motion_y)
-{
- int dxy = 0;
- int emu=0;
-
- src_x += motion_x >> 1;
- src_y += motion_y >> 1;
-
- /* WARNING: do no forget half pels */
- src_x = av_clip(src_x, -16, s->width); //FIXME unneeded for emu?
- if (src_x != s->width)
- dxy |= motion_x & 1;
- src_y = av_clip(src_y, -16, s->height);
- if (src_y != s->height)
- dxy |= (motion_y & 1) << 1;
- src += src_y * s->linesize + src_x;
-
- if(s->unrestricted_mv && (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, s->linesize, 9, 9,
- src_x, src_y, s->h_edge_pos, s->v_edge_pos);
- src= s->edge_emu_buffer;
- emu=1;
- }
- }
- pix_op[dxy](dest, src, s->linesize, 8);
- return emu;
-}
-
-static av_always_inline
-void mpeg_motion_internal(MpegEncContext *s,
- uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
- int field_based, int bottom_field, int field_select,
- uint8_t **ref_picture, op_pixels_func (*pix_op)[4],
- int motion_x, int motion_y, int h, int is_mpeg12, int mb_y)
-{
- uint8_t *ptr_y, *ptr_cb, *ptr_cr;
- int dxy, uvdxy, mx, my, src_x, src_y,
- uvsrc_x, uvsrc_y, v_edge_pos, uvlinesize, linesize;
-
-#if 0
-if(s->quarter_sample)
-{
- motion_x>>=1;
- motion_y>>=1;
-}
-#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;
-
- dxy = ((motion_y & 1) << 1) | (motion_x & 1);
- src_x = s->mb_x* 16 + (motion_x >> 1);
- src_y =( mb_y<<(4-field_based)) + (motion_y >> 1);
-
- if (!is_mpeg12 && s->out_format == FMT_H263) {
- if((s->workaround_bugs & FF_BUG_HPEL_CHROMA) && field_based){
- mx = (motion_x>>1)|(motion_x&1);
- my = motion_y >>1;
- uvdxy = ((my & 1) << 1) | (mx & 1);
- uvsrc_x = s->mb_x* 8 + (mx >> 1);
- uvsrc_y =( mb_y<<(3-field_based))+ (my >> 1);
- }else{
- uvdxy = dxy | (motion_y & 2) | ((motion_x & 2) >> 1);
- uvsrc_x = src_x>>1;
- uvsrc_y = src_y>>1;
- }
- }else if(!is_mpeg12 && s->out_format == FMT_H261){//even chroma mv's are full pel in H261
- mx = motion_x / 4;
- my = motion_y / 4;
- uvdxy = 0;
- uvsrc_x = s->mb_x*8 + mx;
- uvsrc_y = mb_y*8 + my;
- } else {
- if(s->chroma_y_shift){
- mx = motion_x / 2;
- my = motion_y / 2;
- uvdxy = ((my & 1) << 1) | (mx & 1);
- uvsrc_x = s->mb_x* 8 + (mx >> 1);
- uvsrc_y =( mb_y<<(3-field_based))+ (my >> 1);
- } else {
- if(s->chroma_x_shift){
- //Chroma422
- mx = motion_x / 2;
- uvdxy = ((motion_y & 1) << 1) | (mx & 1);
- uvsrc_x = s->mb_x* 8 + (mx >> 1);
- uvsrc_y = src_y;
- } else {
- //Chroma444
- uvdxy = dxy;
- uvsrc_x = src_x;
- uvsrc_y = src_y;
- }
- }
- }
-
- ptr_y = ref_picture[0] + src_y * linesize + src_x;
- ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
- ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
-
- if( (unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x&1) - 16, 0)
- || (unsigned)src_y > FFMAX( v_edge_pos - (motion_y&1) - h , 0)){
- if(is_mpeg12 || s->codec_id == AV_CODEC_ID_MPEG2VIDEO ||
- s->codec_id == AV_CODEC_ID_MPEG1VIDEO){
- av_log(s->avctx,AV_LOG_DEBUG,
- "MPEG motion vector out of boundary (%d %d)\n", src_x, src_y);
- return;
- }
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr_y, s->linesize,
- 17, 17+field_based,
- src_x, src_y<<field_based,
- s->h_edge_pos, s->v_edge_pos);
- ptr_y = s->edge_emu_buffer;
- if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
- uint8_t *uvbuf= s->edge_emu_buffer+18*s->linesize;
- s->vdsp.emulated_edge_mc(uvbuf ,
- ptr_cb, s->uvlinesize,
- 9, 9+field_based,
- uvsrc_x, uvsrc_y<<field_based,
- s->h_edge_pos>>1, s->v_edge_pos>>1);
- s->vdsp.emulated_edge_mc(uvbuf+16,
- ptr_cr, s->uvlinesize,
- 9, 9+field_based,
- uvsrc_x, uvsrc_y<<field_based,
- s->h_edge_pos>>1, s->v_edge_pos>>1);
- ptr_cb= uvbuf;
- ptr_cr= uvbuf+16;
- }
- }
-
- if(bottom_field){ //FIXME use this for field pix too instead of the obnoxious hack which changes picture.data
- dest_y += s->linesize;
- dest_cb+= s->uvlinesize;
- dest_cr+= s->uvlinesize;
- }
-
- if(field_select){
- ptr_y += s->linesize;
- ptr_cb+= s->uvlinesize;
- ptr_cr+= s->uvlinesize;
- }
-
- pix_op[0][dxy](dest_y, ptr_y, linesize, h);
-
- if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
- pix_op[s->chroma_x_shift][uvdxy]
- (dest_cb, ptr_cb, uvlinesize, h >> s->chroma_y_shift);
- pix_op[s->chroma_x_shift][uvdxy]
- (dest_cr, ptr_cr, uvlinesize, h >> s->chroma_y_shift);
- }
- if(!is_mpeg12 && (CONFIG_H261_ENCODER || CONFIG_H261_DECODER) &&
- s->out_format == FMT_H261){
- ff_h261_loop_filter(s);
- }
-}
-/* apply one mpeg motion vector to the three components */
-static void mpeg_motion(MpegEncContext *s,
- uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
- int field_select, uint8_t **ref_picture,
- op_pixels_func (*pix_op)[4],
- int motion_x, int motion_y, int h, int mb_y)
-{
-#if !CONFIG_SMALL
- if(s->out_format == FMT_MPEG1)
- mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, 0, 0,
- field_select, ref_picture, pix_op,
- motion_x, motion_y, h, 1, mb_y);
- else
-#endif
- mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, 0, 0,
- field_select, ref_picture, pix_op,
- motion_x, motion_y, h, 0, mb_y);
-}
-
-static void mpeg_motion_field(MpegEncContext *s, uint8_t *dest_y,
- uint8_t *dest_cb, uint8_t *dest_cr,
- int bottom_field, int field_select,
- uint8_t **ref_picture,
- op_pixels_func (*pix_op)[4],
- int motion_x, int motion_y, int h, int mb_y)
-{
-#if !CONFIG_SMALL
- if(s->out_format == FMT_MPEG1)
- mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, 1,
- bottom_field, field_select, ref_picture, pix_op,
- motion_x, motion_y, h, 1, mb_y);
- else
-#endif
- mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, 1,
- bottom_field, field_select, ref_picture, pix_op,
- motion_x, motion_y, h, 0, mb_y);
-}
-
-//FIXME move to dsputil, avg variant, 16x16 version
-static inline void put_obmc(uint8_t *dst, uint8_t *src[5], int stride){
- int x;
- uint8_t * const top = src[1];
- uint8_t * const left = src[2];
- uint8_t * const mid = src[0];
- uint8_t * const right = src[3];
- uint8_t * const bottom= src[4];
-#define OBMC_FILTER(x, t, l, m, r, b)\
- dst[x]= (t*top[x] + l*left[x] + m*mid[x] + r*right[x] + b*bottom[x] + 4)>>3
-#define OBMC_FILTER4(x, t, l, m, r, b)\
- OBMC_FILTER(x , t, l, m, r, b);\
- OBMC_FILTER(x+1 , t, l, m, r, b);\
- OBMC_FILTER(x +stride, t, l, m, r, b);\
- OBMC_FILTER(x+1+stride, t, l, m, r, b);
-
- x=0;
- OBMC_FILTER (x , 2, 2, 4, 0, 0);
- OBMC_FILTER (x+1, 2, 1, 5, 0, 0);
- OBMC_FILTER4(x+2, 2, 1, 5, 0, 0);
- OBMC_FILTER4(x+4, 2, 0, 5, 1, 0);
- OBMC_FILTER (x+6, 2, 0, 5, 1, 0);
- OBMC_FILTER (x+7, 2, 0, 4, 2, 0);
- x+= stride;
- OBMC_FILTER (x , 1, 2, 5, 0, 0);
- OBMC_FILTER (x+1, 1, 2, 5, 0, 0);
- OBMC_FILTER (x+6, 1, 0, 5, 2, 0);
- OBMC_FILTER (x+7, 1, 0, 5, 2, 0);
- x+= stride;
- OBMC_FILTER4(x , 1, 2, 5, 0, 0);
- OBMC_FILTER4(x+2, 1, 1, 6, 0, 0);
- OBMC_FILTER4(x+4, 1, 0, 6, 1, 0);
- OBMC_FILTER4(x+6, 1, 0, 5, 2, 0);
- x+= 2*stride;
- OBMC_FILTER4(x , 0, 2, 5, 0, 1);
- OBMC_FILTER4(x+2, 0, 1, 6, 0, 1);
- OBMC_FILTER4(x+4, 0, 0, 6, 1, 1);
- OBMC_FILTER4(x+6, 0, 0, 5, 2, 1);
- x+= 2*stride;
- OBMC_FILTER (x , 0, 2, 5, 0, 1);
- OBMC_FILTER (x+1, 0, 2, 5, 0, 1);
- OBMC_FILTER4(x+2, 0, 1, 5, 0, 2);
- OBMC_FILTER4(x+4, 0, 0, 5, 1, 2);
- OBMC_FILTER (x+6, 0, 0, 5, 2, 1);
- OBMC_FILTER (x+7, 0, 0, 5, 2, 1);
- x+= stride;
- OBMC_FILTER (x , 0, 2, 4, 0, 2);
- OBMC_FILTER (x+1, 0, 1, 5, 0, 2);
- OBMC_FILTER (x+6, 0, 0, 5, 1, 2);
- OBMC_FILTER (x+7, 0, 0, 4, 2, 2);
-}
-
-/* obmc for 1 8x8 luma block */
-static inline void obmc_motion(MpegEncContext *s,
- uint8_t *dest, uint8_t *src,
- int src_x, int src_y,
- op_pixels_func *pix_op,
- int16_t mv[5][2]/* mid top left right bottom*/)
-#define MID 0
-{
- int i;
- uint8_t *ptr[5];
-
- av_assert2(s->quarter_sample==0);
-
- for(i=0; i<5; i++){
- if(i && mv[i][0]==mv[MID][0] && mv[i][1]==mv[MID][1]){
- ptr[i]= ptr[MID];
- }else{
- ptr[i]= s->obmc_scratchpad + 8*(i&1) + s->linesize*8*(i>>1);
- hpel_motion(s, ptr[i], src,
- src_x, src_y,
- pix_op,
- mv[i][0], mv[i][1]);
- }
- }
-
- put_obmc(dest, ptr, s->linesize);
-}
-
-static inline void qpel_motion(MpegEncContext *s,
- uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
- int field_based, int bottom_field, int field_select,
- uint8_t **ref_picture, op_pixels_func (*pix_op)[4],
- qpel_mc_func (*qpix_op)[16],
- int motion_x, int motion_y, int h)
-{
- uint8_t *ptr_y, *ptr_cb, *ptr_cr;
- int dxy, uvdxy, mx, my, src_x, src_y, uvsrc_x, uvsrc_y, v_edge_pos, linesize, uvlinesize;
-
- dxy = ((motion_y & 3) << 2) | (motion_x & 3);
- src_x = s->mb_x * 16 + (motion_x >> 2);
- src_y = s->mb_y * (16 >> field_based) + (motion_y >> 2);
-
- v_edge_pos = s->v_edge_pos >> field_based;
- linesize = s->linesize << field_based;
- uvlinesize = s->uvlinesize << field_based;
-
- if(field_based){
- mx= motion_x/2;
- my= motion_y>>1;
- }else if(s->workaround_bugs&FF_BUG_QPEL_CHROMA2){
- static const int rtab[8]= {0,0,1,1,0,0,0,1};
- mx= (motion_x>>1) + rtab[motion_x&7];
- my= (motion_y>>1) + rtab[motion_y&7];
- }else if(s->workaround_bugs&FF_BUG_QPEL_CHROMA){
- mx= (motion_x>>1)|(motion_x&1);
- my= (motion_y>>1)|(motion_y&1);
- }else{
- mx= motion_x/2;
- my= motion_y/2;
- }
- mx= (mx>>1)|(mx&1);
- my= (my>>1)|(my&1);
-
- uvdxy= (mx&1) | ((my&1)<<1);
- mx>>=1;
- my>>=1;
-
- uvsrc_x = s->mb_x * 8 + mx;
- uvsrc_y = s->mb_y * (8 >> field_based) + my;
-
- ptr_y = ref_picture[0] + src_y * linesize + src_x;
- ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
- ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
-
- if( (unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x&3) - 16, 0)
- || (unsigned)src_y > FFMAX( v_edge_pos - (motion_y&3) - h , 0)){
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr_y, s->linesize,
- 17, 17+field_based, src_x, src_y<<field_based,
- s->h_edge_pos, s->v_edge_pos);
- ptr_y= s->edge_emu_buffer;
- if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
- uint8_t *uvbuf= s->edge_emu_buffer + 18*s->linesize;
- s->vdsp.emulated_edge_mc(uvbuf, ptr_cb, s->uvlinesize,
- 9, 9 + field_based,
- uvsrc_x, uvsrc_y<<field_based,
- s->h_edge_pos>>1, s->v_edge_pos>>1);
- s->vdsp.emulated_edge_mc(uvbuf + 16, ptr_cr, s->uvlinesize,
- 9, 9 + field_based,
- uvsrc_x, uvsrc_y<<field_based,
- s->h_edge_pos>>1, s->v_edge_pos>>1);
- ptr_cb= uvbuf;
- ptr_cr= uvbuf + 16;
- }
- }
-
- if(!field_based)
- qpix_op[0][dxy](dest_y, ptr_y, linesize);
- else{
- if(bottom_field){
- dest_y += s->linesize;
- dest_cb+= s->uvlinesize;
- dest_cr+= s->uvlinesize;
- }
-
- if(field_select){
- ptr_y += s->linesize;
- ptr_cb += s->uvlinesize;
- ptr_cr += s->uvlinesize;
- }
- //damn interlaced mode
- //FIXME boundary mirroring is not exactly correct here
- qpix_op[1][dxy](dest_y , ptr_y , linesize);
- qpix_op[1][dxy](dest_y+8, ptr_y+8, linesize);
- }
- if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
- pix_op[1][uvdxy](dest_cr, ptr_cr, uvlinesize, h >> 1);
- pix_op[1][uvdxy](dest_cb, ptr_cb, uvlinesize, h >> 1);
- }
-}
-
-/**
- * h263 chroma 4mv motion compensation.
- */
-static void chroma_4mv_motion(MpegEncContext *s,
- uint8_t *dest_cb, uint8_t *dest_cr,
- uint8_t **ref_picture,
- op_pixels_func *pix_op,
- int mx, int my)
-{
- int dxy, emu=0, src_x, src_y, offset;
- uint8_t *ptr;
-
- /* In case of 8X8, we construct a single chroma motion vector
- with a special rounding */
- mx= ff_h263_round_chroma(mx);
- my= ff_h263_round_chroma(my);
-
- dxy = ((my & 1) << 1) | (mx & 1);
- mx >>= 1;
- my >>= 1;
-
- src_x = s->mb_x * 8 + mx;
- src_y = s->mb_y * 8 + my;
- src_x = av_clip(src_x, -8, (s->width >> 1));
- if (src_x == (s->width >> 1))
- dxy &= ~1;
- src_y = av_clip(src_y, -8, (s->height >> 1));
- if (src_y == (s->height >> 1))
- dxy &= ~2;
-
- 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,
- 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);
-
- ptr = ref_picture[2] + offset;
- if(emu){
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize,
- 9, 9, src_x, src_y,
- s->h_edge_pos>>1, s->v_edge_pos>>1);
- ptr= s->edge_emu_buffer;
- }
- pix_op[dxy](dest_cr, ptr, s->uvlinesize, 8);
-}
-
-static inline void prefetch_motion(MpegEncContext *s, uint8_t **pix, int dir){
- /* fetch pixels for estimated mv 4 macroblocks ahead
- * optimized for 64byte cache lines */
- const int shift = s->quarter_sample ? 2 : 1;
- const int mx= (s->mv[dir][0][0]>>shift) + 16*s->mb_x + 8;
- const int my= (s->mv[dir][0][1]>>shift) + 16*s->mb_y;
- int off= mx + (my + (s->mb_x&3)*4)*s->linesize + 64;
- s->vdsp.prefetch(pix[0]+off, s->linesize, 4);
- off= (mx>>1) + ((my>>1) + (s->mb_x&7))*s->uvlinesize + 64;
- s->vdsp.prefetch(pix[1]+off, pix[2]-pix[1], 2);
-}
-
-/**
- * motion compensation of a single macroblock
- * @param s context
- * @param dest_y luma destination pointer
- * @param dest_cb chroma cb/u destination pointer
- * @param dest_cr chroma cr/v destination pointer
- * @param dir direction (0->forward, 1->backward)
- * @param ref_picture array[3] of pointers to the 3 planes of the reference picture
- * @param pix_op halfpel motion compensation function (average or put normally)
- * @param qpix_op qpel motion compensation function (average or put normally)
- * the motion vectors are taken from s->mv and the MV type from s->mv_type
- */
-static av_always_inline void MPV_motion_internal(MpegEncContext *s,
- uint8_t *dest_y, uint8_t *dest_cb,
- uint8_t *dest_cr, int dir,
- uint8_t **ref_picture,
- op_pixels_func (*pix_op)[4],
- qpel_mc_func (*qpix_op)[16], int is_mpeg12)
-{
- int dxy, mx, my, src_x, src_y, motion_x, motion_y;
- int mb_x, mb_y, i;
- uint8_t *ptr, *dest;
-
- mb_x = s->mb_x;
- mb_y = s->mb_y;
-
- prefetch_motion(s, ref_picture, dir);
-
- if(!is_mpeg12 && s->obmc && s->pict_type != AV_PICTURE_TYPE_B){
- LOCAL_ALIGNED_8(int16_t, mv_cache, [4], [4][2]);
- AVFrame *cur_frame = &s->current_picture.f;
- const int xy= s->mb_x + s->mb_y*s->mb_stride;
- const int mot_stride= s->b8_stride;
- const int mot_xy= mb_x*2 + mb_y*2*mot_stride;
-
- av_assert2(!s->mb_skipped);
-
- AV_COPY32(mv_cache[1][1], cur_frame->motion_val[0][mot_xy ]);
- AV_COPY32(mv_cache[1][2], cur_frame->motion_val[0][mot_xy + 1]);
-
- AV_COPY32(mv_cache[2][1], cur_frame->motion_val[0][mot_xy + mot_stride ]);
- AV_COPY32(mv_cache[2][2], cur_frame->motion_val[0][mot_xy + mot_stride + 1]);
-
- AV_COPY32(mv_cache[3][1], cur_frame->motion_val[0][mot_xy + mot_stride ]);
- AV_COPY32(mv_cache[3][2], cur_frame->motion_val[0][mot_xy + mot_stride + 1]);
-
- if (mb_y == 0 || IS_INTRA(cur_frame->mb_type[xy - s->mb_stride])) {
- AV_COPY32(mv_cache[0][1], mv_cache[1][1]);
- AV_COPY32(mv_cache[0][2], mv_cache[1][2]);
- }else{
- AV_COPY32(mv_cache[0][1], cur_frame->motion_val[0][mot_xy - mot_stride ]);
- AV_COPY32(mv_cache[0][2], cur_frame->motion_val[0][mot_xy - mot_stride + 1]);
- }
-
- if (mb_x == 0 || IS_INTRA(cur_frame->mb_type[xy - 1])) {
- AV_COPY32(mv_cache[1][0], mv_cache[1][1]);
- AV_COPY32(mv_cache[2][0], mv_cache[2][1]);
- }else{
- AV_COPY32(mv_cache[1][0], cur_frame->motion_val[0][mot_xy - 1]);
- AV_COPY32(mv_cache[2][0], cur_frame->motion_val[0][mot_xy - 1 + mot_stride]);
- }
-
- if (mb_x + 1 >= s->mb_width || IS_INTRA(cur_frame->mb_type[xy + 1])) {
- AV_COPY32(mv_cache[1][3], mv_cache[1][2]);
- AV_COPY32(mv_cache[2][3], mv_cache[2][2]);
- }else{
- AV_COPY32(mv_cache[1][3], cur_frame->motion_val[0][mot_xy + 2]);
- AV_COPY32(mv_cache[2][3], cur_frame->motion_val[0][mot_xy + 2 + mot_stride]);
- }
-
- mx = 0;
- my = 0;
- for(i=0;i<4;i++) {
- const int x= (i&1)+1;
- const int y= (i>>1)+1;
- int16_t mv[5][2]= {
- {mv_cache[y][x ][0], mv_cache[y][x ][1]},
- {mv_cache[y-1][x][0], mv_cache[y-1][x][1]},
- {mv_cache[y][x-1][0], mv_cache[y][x-1][1]},
- {mv_cache[y][x+1][0], mv_cache[y][x+1][1]},
- {mv_cache[y+1][x][0], mv_cache[y+1][x][1]}};
- //FIXME cleanup
- obmc_motion(s, dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize,
- ref_picture[0],
- mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >>1) * 8,
- pix_op[1],
- mv);
-
- mx += mv[0][0];
- my += mv[0][1];
- }
- if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY))
- chroma_4mv_motion(s, dest_cb, dest_cr, ref_picture, pix_op[1], mx, my);
-
- return;
- }
-
- switch(s->mv_type) {
- case MV_TYPE_16X16:
- if(s->mcsel){
- if(s->real_sprite_warping_points==1){
- gmc1_motion(s, dest_y, dest_cb, dest_cr,
- ref_picture);
- }else{
- gmc_motion(s, dest_y, dest_cb, dest_cr,
- ref_picture);
- }
- }else if(!is_mpeg12 && s->quarter_sample){
- qpel_motion(s, dest_y, dest_cb, dest_cr,
- 0, 0, 0,
- ref_picture, pix_op, qpix_op,
- s->mv[dir][0][0], s->mv[dir][0][1], 16);
- } else if (!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) &&
- s->mspel && s->codec_id == AV_CODEC_ID_WMV2) {
- ff_mspel_motion(s, dest_y, dest_cb, dest_cr,
- ref_picture, pix_op,
- s->mv[dir][0][0], s->mv[dir][0][1], 16);
- }else
- {
- mpeg_motion(s, dest_y, dest_cb, dest_cr, 0,
- ref_picture, pix_op,
- s->mv[dir][0][0], s->mv[dir][0][1], 16, mb_y);
- }
- break;
- case MV_TYPE_8X8:
- if (!is_mpeg12) {
- mx = 0;
- my = 0;
- if(s->quarter_sample){
- for(i=0;i<4;i++) {
- motion_x = s->mv[dir][i][0];
- motion_y = s->mv[dir][i][1];
-
- dxy = ((motion_y & 3) << 2) | (motion_x & 3);
- src_x = mb_x * 16 + (motion_x >> 2) + (i & 1) * 8;
- src_y = mb_y * 16 + (motion_y >> 2) + (i >>1) * 8;
-
- /* WARNING: do no forget half pels */
- src_x = av_clip(src_x, -16, s->width);
- if (src_x == s->width)
- dxy &= ~3;
- src_y = av_clip(src_y, -16, s->height);
- if (src_y == s->height)
- 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, 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);
-
- mx += s->mv[dir][i][0]/2;
- my += s->mv[dir][i][1]/2;
- }
- }else{
- for(i=0;i<4;i++) {
- hpel_motion(s, dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize,
- ref_picture[0],
- mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >>1) * 8,
- pix_op[1],
- s->mv[dir][i][0], s->mv[dir][i][1]);
-
- mx += s->mv[dir][i][0];
- my += s->mv[dir][i][1];
- }
- }
-
- if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY))
- chroma_4mv_motion(s, dest_cb, dest_cr, ref_picture, pix_op[1], mx, my);
- }
- break;
- case MV_TYPE_FIELD:
- if (s->picture_structure == PICT_FRAME) {
- if(!is_mpeg12 && s->quarter_sample){
- for(i=0; i<2; i++){
- qpel_motion(s, dest_y, dest_cb, dest_cr,
- 1, i, s->field_select[dir][i],
- ref_picture, pix_op, qpix_op,
- s->mv[dir][i][0], s->mv[dir][i][1], 8);
- }
- }else{
- /* top field */
- mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
- 0, s->field_select[dir][0],
- ref_picture, pix_op,
- s->mv[dir][0][0], s->mv[dir][0][1], 8, mb_y);
- /* bottom field */
- mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
- 1, s->field_select[dir][1],
- ref_picture, pix_op,
- s->mv[dir][1][0], s->mv[dir][1][1], 8, mb_y);
- }
- } 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;
- }
-
- mpeg_motion(s, dest_y, dest_cb, dest_cr,
- s->field_select[dir][0],
- ref_picture, pix_op,
- s->mv[dir][0][0], s->mv[dir][0][1], 16, mb_y>>1);
- }
- break;
- case MV_TYPE_16X8:
- for(i=0; i<2; i++){
- uint8_t ** ref2picture;
-
- if(s->picture_structure == s->field_select[dir][i] + 1
- || s->pict_type == AV_PICTURE_TYPE_B || s->first_field){
- ref2picture= ref_picture;
- }else{
- ref2picture = s->current_picture_ptr->f.data;
- }
-
- mpeg_motion(s, dest_y, dest_cb, dest_cr,
- s->field_select[dir][i],
- ref2picture, pix_op,
- s->mv[dir][i][0], s->mv[dir][i][1] + 16*i, 8, mb_y>>1);
-
- dest_y += 16*s->linesize;
- dest_cb+= (16>>s->chroma_y_shift)*s->uvlinesize;
- dest_cr+= (16>>s->chroma_y_shift)*s->uvlinesize;
- }
- break;
- case MV_TYPE_DMV:
- if(s->picture_structure == PICT_FRAME){
- for(i=0; i<2; i++){
- int j;
- for(j=0; j<2; j++){
- mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
- j, j^i, ref_picture, pix_op,
- s->mv[dir][2*i + j][0],
- s->mv[dir][2*i + j][1], 8, mb_y);
- }
- pix_op = s->dsp.avg_pixels_tab;
- }
- }else{
- for(i=0; i<2; i++){
- mpeg_motion(s, dest_y, dest_cb, dest_cr,
- s->picture_structure != i+1,
- ref_picture, pix_op,
- s->mv[dir][2*i][0],s->mv[dir][2*i][1],16, mb_y>>1);
-
- // after put we make avg of the same block
- pix_op=s->dsp.avg_pixels_tab;
-
- //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;
- }
- }
- }
- break;
- default: av_assert2(0);
- }
-}
-
-void ff_MPV_motion(MpegEncContext *s,
- uint8_t *dest_y, uint8_t *dest_cb,
- uint8_t *dest_cr, int dir,
- uint8_t **ref_picture,
- op_pixels_func (*pix_op)[4],
- qpel_mc_func (*qpix_op)[16])
-{
-#if !CONFIG_SMALL
- if(s->out_format == FMT_MPEG1)
- MPV_motion_internal(s, dest_y, dest_cb, dest_cr, dir,
- ref_picture, pix_op, qpix_op, 1);
- else
-#endif
- MPV_motion_internal(s, dest_y, dest_cb, dest_cr, dir,
- ref_picture, pix_op, qpix_op, 0);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/mpegvideo_parser.c b/src/thirdparty/ffmpeg/libavcodec/mpegvideo_parser.c
deleted file mode 100644
index 1ba66dd51..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/mpegvideo_parser.c
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * MPEG1 / MPEG2 video parser
- * Copyright (c) 2000,2001 Fabrice Bellard
- * Copyright (c) 2002-2004 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
- */
-
-#include "parser.h"
-#include "mpegvideo.h"
-
-struct MpvParseContext {
- ParseContext pc;
- AVRational frame_rate;
- int progressive_sequence;
- int width, height;
-};
-
-
-static void mpegvideo_extract_headers(AVCodecParserContext *s,
- AVCodecContext *avctx,
- const uint8_t *buf, int buf_size)
-{
- struct MpvParseContext *pc = s->priv_data;
- const uint8_t *buf_end = buf + buf_size;
- uint32_t start_code;
- int frame_rate_index, ext_type, bytes_left;
- int frame_rate_ext_n, frame_rate_ext_d;
- int top_field_first, repeat_first_field, progressive_frame;
- int horiz_size_ext, vert_size_ext, bit_rate_ext;
- int did_set_size=0;
- int bit_rate = 0;
- int vbv_delay = 0;
-//FIXME replace the crap with get_bits()
- s->repeat_pict = 0;
-
- while (buf < buf_end) {
- start_code= -1;
- buf= avpriv_mpv_find_start_code(buf, buf_end, &start_code);
- bytes_left = buf_end - buf;
- switch(start_code) {
- case PICTURE_START_CODE:
- if (bytes_left >= 2) {
- s->pict_type = (buf[1] >> 3) & 7;
- if (bytes_left >= 4)
- vbv_delay = ((buf[1] & 0x07) << 13) | (buf[2] << 5) | (buf[3] >> 3);
- }
- break;
- case SEQ_START_CODE:
- if (bytes_left >= 7) {
- pc->width = (buf[0] << 4) | (buf[1] >> 4);
- pc->height = ((buf[1] & 0x0f) << 8) | buf[2];
- if(!avctx->width || !avctx->height || !avctx->coded_width || !avctx->coded_height){
- avcodec_set_dimensions(avctx, pc->width, pc->height);
- did_set_size=1;
- }
- frame_rate_index = buf[3] & 0xf;
- pc->frame_rate.den = avctx->time_base.den = ff_mpeg12_frame_rate_tab[frame_rate_index].num;
- pc->frame_rate.num = avctx->time_base.num = ff_mpeg12_frame_rate_tab[frame_rate_index].den;
- bit_rate = (buf[4]<<10) | (buf[5]<<2) | (buf[6]>>6);
- avctx->codec_id = AV_CODEC_ID_MPEG1VIDEO;
- }
- break;
- case EXT_START_CODE:
- if (bytes_left >= 1) {
- ext_type = (buf[0] >> 4);
- switch(ext_type) {
- case 0x1: /* sequence extension */
- if (bytes_left >= 6) {
- horiz_size_ext = ((buf[1] & 1) << 1) | (buf[2] >> 7);
- vert_size_ext = (buf[2] >> 5) & 3;
- bit_rate_ext = ((buf[2] & 0x1F)<<7) | (buf[3]>>1);
- frame_rate_ext_n = (buf[5] >> 5) & 3;
- frame_rate_ext_d = (buf[5] & 0x1f);
- pc->progressive_sequence = buf[1] & (1 << 3);
- avctx->has_b_frames= !(buf[5] >> 7);
-
- pc->width |=(horiz_size_ext << 12);
- pc->height |=( vert_size_ext << 12);
- bit_rate = (bit_rate&0x3FFFF) | (bit_rate_ext << 18);
- if(did_set_size)
- avcodec_set_dimensions(avctx, pc->width, pc->height);
- avctx->time_base.den = pc->frame_rate.den * (frame_rate_ext_n + 1) * 2;
- avctx->time_base.num = pc->frame_rate.num * (frame_rate_ext_d + 1);
- avctx->codec_id = AV_CODEC_ID_MPEG2VIDEO;
- }
- break;
- case 0x8: /* picture coding extension */
- if (bytes_left >= 5) {
- top_field_first = buf[3] & (1 << 7);
- repeat_first_field = buf[3] & (1 << 1);
- progressive_frame = buf[4] & (1 << 7);
-
- /* check if we must repeat the frame */
- s->repeat_pict = 1;
- if (repeat_first_field) {
- if (pc->progressive_sequence) {
- if (top_field_first)
- s->repeat_pict = 5;
- else
- s->repeat_pict = 3;
- } else if (progressive_frame) {
- s->repeat_pict = 2;
- }
- }
- }
- break;
- }
- }
- break;
- case -1:
- goto the_end;
- default:
- /* we stop parsing when we encounter a slice. It ensures
- that this function takes a negligible amount of time */
- if (start_code >= SLICE_MIN_START_CODE &&
- start_code <= SLICE_MAX_START_CODE)
- goto the_end;
- break;
- }
- }
- the_end: ;
- if (avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO && bit_rate) {
- avctx->rc_max_rate = 400*bit_rate;
- } else if (avctx->codec_id == AV_CODEC_ID_MPEG1VIDEO && bit_rate &&
- (bit_rate != 0x3FFFF || vbv_delay != 0xFFFF)) {
- avctx->bit_rate = 400*bit_rate;
- }
-}
-
-static int mpegvideo_parse(AVCodecParserContext *s,
- AVCodecContext *avctx,
- const uint8_t **poutbuf, int *poutbuf_size,
- const uint8_t *buf, int buf_size)
-{
- struct MpvParseContext *pc1 = s->priv_data;
- ParseContext *pc= &pc1->pc;
- int next;
-
- if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){
- next= buf_size;
- }else{
- next= ff_mpeg1_find_frame_end(pc, buf, buf_size, s);
-
- if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
- *poutbuf = NULL;
- *poutbuf_size = 0;
- return buf_size;
- }
-
- }
- /* we have a full frame : we just parse the first few MPEG headers
- to have the full timing information. The time take by this
- function should be negligible for uncorrupted streams */
- mpegvideo_extract_headers(s, avctx, buf, buf_size);
- av_dlog(NULL, "pict_type=%d frame_rate=%0.3f repeat_pict=%d\n",
- s->pict_type, (double)avctx->time_base.den / avctx->time_base.num, s->repeat_pict);
-
- *poutbuf = buf;
- *poutbuf_size = buf_size;
- return next;
-}
-
-static int mpegvideo_split(AVCodecContext *avctx,
- const uint8_t *buf, int buf_size)
-{
- int i;
- uint32_t state= -1;
- int found=0;
-
- for(i=0; i<buf_size; i++){
- state= (state<<8) | buf[i];
- if(state == 0x1B3){
- found=1;
- }else if(found && state != 0x1B5 && state < 0x200 && state >= 0x100)
- return i-3;
- }
- return 0;
-}
-
-static int mpegvideo_parse_init(AVCodecParserContext *s)
-{
- s->pict_type = AV_PICTURE_TYPE_NONE; // first frame might be partial
- return 0;
-}
-
-AVCodecParser ff_mpegvideo_parser = {
- .codec_ids = { AV_CODEC_ID_MPEG1VIDEO, AV_CODEC_ID_MPEG2VIDEO },
- .priv_data_size = sizeof(struct MpvParseContext),
- .parser_init = mpegvideo_parse_init,
- .parser_parse = mpegvideo_parse,
- .parser_close = ff_parse_close,
- .split = mpegvideo_split,
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/msmpeg4.c b/src/thirdparty/ffmpeg/libavcodec/msmpeg4.c
deleted file mode 100644
index 56f9a2987..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/msmpeg4.c
+++ /dev/null
@@ -1,1269 +0,0 @@
-/*
- * MSMPEG4 backend for encoder and decoder
- * Copyright (c) 2001 Fabrice Bellard
- * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
- *
- * msmpeg4v1 & v2 stuff 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
- * MSMPEG4 backend for encoder and decoder
- */
-
-#include "avcodec.h"
-#include "dsputil.h"
-#include "mpegvideo.h"
-#include "msmpeg4.h"
-#include "libavutil/x86/asm.h"
-#include "h263.h"
-#include "mpeg4video.h"
-#include "msmpeg4data.h"
-#include "vc1data.h"
-#include "libavutil/imgutils.h"
-
-/*
- * You can also call this codec : MPEG4 with a twist !
- *
- * TODO:
- * - (encoding) select best mv table (two choices)
- * - (encoding) select best vlc/dc table
- */
-//#define DEBUG
-
-#define DC_VLC_BITS 9
-#define V2_INTRA_CBPC_VLC_BITS 3
-#define V2_MB_TYPE_VLC_BITS 7
-#define MV_VLC_BITS 9
-#define V2_MV_VLC_BITS 9
-#define TEX_VLC_BITS 9
-
-#define DEFAULT_INTER_INDEX 3
-
-/* This table is practically identical to the one from h263
- * except that it is inverted. */
-static av_cold void init_h263_dc_for_msmpeg4(void)
-{
- int level, uni_code, uni_len;
-
- if(ff_v2_dc_chroma_table[255 + 256][1])
- return;
-
- for(level=-256; level<256; level++){
- int size, v, l;
- /* find number of bits */
- size = 0;
- v = abs(level);
- while (v) {
- v >>= 1;
- size++;
- }
-
- if (level < 0)
- l= (-level) ^ ((1 << size) - 1);
- else
- l= level;
-
- /* luminance h263 */
- uni_code= ff_mpeg4_DCtab_lum[size][0];
- uni_len = ff_mpeg4_DCtab_lum[size][1];
- uni_code ^= (1<<uni_len)-1; //M$ does not like compatibility
-
- if (size > 0) {
- uni_code<<=size; uni_code|=l;
- uni_len+=size;
- if (size > 8){
- uni_code<<=1; uni_code|=1;
- uni_len++;
- }
- }
- ff_v2_dc_lum_table[level + 256][0] = uni_code;
- ff_v2_dc_lum_table[level + 256][1] = uni_len;
-
- /* chrominance h263 */
- uni_code= ff_mpeg4_DCtab_chrom[size][0];
- uni_len = ff_mpeg4_DCtab_chrom[size][1];
- uni_code ^= (1<<uni_len)-1; //M$ does not like compatibility
-
- if (size > 0) {
- uni_code<<=size; uni_code|=l;
- uni_len+=size;
- if (size > 8){
- uni_code<<=1; uni_code|=1;
- uni_len++;
- }
- }
- ff_v2_dc_chroma_table[level + 256][0] = uni_code;
- ff_v2_dc_chroma_table[level + 256][1] = uni_len;
-
- }
-}
-
-av_cold void ff_msmpeg4_common_init(MpegEncContext *s)
-{
- switch(s->msmpeg4_version){
- case 1:
- case 2:
- s->y_dc_scale_table=
- s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
- break;
- case 3:
- if(s->workaround_bugs){
- s->y_dc_scale_table= ff_old_ff_y_dc_scale_table;
- s->c_dc_scale_table= ff_wmv1_c_dc_scale_table;
- } else{
- s->y_dc_scale_table= ff_mpeg4_y_dc_scale_table;
- s->c_dc_scale_table= ff_mpeg4_c_dc_scale_table;
- }
- break;
- case 4:
- case 5:
- s->y_dc_scale_table= ff_wmv1_y_dc_scale_table;
- s->c_dc_scale_table= ff_wmv1_c_dc_scale_table;
- break;
-#if CONFIG_VC1_DECODER
- case 6:
- s->y_dc_scale_table= ff_wmv3_dc_scale_table;
- s->c_dc_scale_table= ff_wmv3_dc_scale_table;
- break;
-#endif
-
- }
-
-
- if(s->msmpeg4_version>=4){
- ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_wmv1_scantable[1]);
- ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable, ff_wmv1_scantable[2]);
- ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable, ff_wmv1_scantable[3]);
- ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_wmv1_scantable[0]);
- }
- //Note the default tables are set in common_init in mpegvideo.c
-
- init_h263_dc_for_msmpeg4();
-}
-
-/* predict coded block */
-int ff_msmpeg4_coded_block_pred(MpegEncContext * s, int n, uint8_t **coded_block_ptr)
-{
- int xy, wrap, pred, a, b, c;
-
- xy = s->block_index[n];
- wrap = s->b8_stride;
-
- /* B C
- * A X
- */
- a = s->coded_block[xy - 1 ];
- b = s->coded_block[xy - 1 - wrap];
- c = s->coded_block[xy - wrap];
-
- if (b == c) {
- pred = a;
- } else {
- pred = c;
- }
-
- /* store value */
- *coded_block_ptr = &s->coded_block[xy];
-
- return pred;
-}
-
-static inline int msmpeg4v1_pred_dc(MpegEncContext * s, int n,
- int32_t **dc_val_ptr)
-{
- int i;
-
- if (n < 4) {
- i= 0;
- } else {
- i= n-3;
- }
-
- *dc_val_ptr= &s->last_dc[i];
- return s->last_dc[i];
-}
-
-static int get_dc(uint8_t *src, int stride, int scale)
-{
- int y;
- int sum=0;
- for(y=0; y<8; y++){
- int x;
- for(x=0; x<8; x++){
- sum+=src[x + y*stride];
- }
- }
- return FASTDIV((sum + (scale>>1)), scale);
-}
-
-/* dir = 0: left, dir = 1: top prediction */
-int ff_msmpeg4_pred_dc(MpegEncContext *s, int n,
- int16_t **dc_val_ptr, int *dir_ptr)
-{
- int a, b, c, wrap, pred, scale;
- int16_t *dc_val;
-
- /* find prediction */
- if (n < 4) {
- scale = s->y_dc_scale;
- } else {
- scale = s->c_dc_scale;
- }
-
- wrap = s->block_wrap[n];
- dc_val= s->dc_val[0] + s->block_index[n];
-
- /* B C
- * A X
- */
- a = dc_val[ - 1];
- b = dc_val[ - 1 - wrap];
- c = dc_val[ - wrap];
-
- if(s->first_slice_line && (n&2)==0 && s->msmpeg4_version<4){
- b=c=1024;
- }
-
- /* XXX: the following solution consumes divisions, but it does not
- necessitate to modify mpegvideo.c. The problem comes from the
- fact they decided to store the quantized DC (which would lead
- to problems if Q could vary !) */
-#if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE
- __asm__ volatile(
- "movl %3, %%eax \n\t"
- "shrl $1, %%eax \n\t"
- "addl %%eax, %2 \n\t"
- "addl %%eax, %1 \n\t"
- "addl %0, %%eax \n\t"
- "mull %4 \n\t"
- "movl %%edx, %0 \n\t"
- "movl %1, %%eax \n\t"
- "mull %4 \n\t"
- "movl %%edx, %1 \n\t"
- "movl %2, %%eax \n\t"
- "mull %4 \n\t"
- "movl %%edx, %2 \n\t"
- : "+b" (a), "+c" (b), "+D" (c)
- : "g" (scale), "S" (ff_inverse[scale])
- : "%eax", "%edx"
- );
-#else
- /* #elif ARCH_ALPHA */
- /* Divisions are extremely costly on Alpha; optimize the most
- common case. But they are costly everywhere...
- */
- if (scale == 8) {
- a = (a + (8 >> 1)) / 8;
- b = (b + (8 >> 1)) / 8;
- c = (c + (8 >> 1)) / 8;
- } else {
- a = FASTDIV((a + (scale >> 1)), scale);
- b = FASTDIV((b + (scale >> 1)), scale);
- c = FASTDIV((c + (scale >> 1)), scale);
- }
-#endif
- /* XXX: WARNING: they did not choose the same test as MPEG4. This
- is very important ! */
- if(s->msmpeg4_version>3){
- if(s->inter_intra_pred){
- uint8_t *dest;
- int wrap;
-
- if(n==1){
- pred=a;
- *dir_ptr = 0;
- }else if(n==2){
- pred=c;
- *dir_ptr = 1;
- }else if(n==3){
- if (abs(a - b) < abs(b - c)) {
- pred = c;
- *dir_ptr = 1;
- } else {
- pred = a;
- *dir_ptr = 0;
- }
- }else{
- if(n<4){
- wrap= s->linesize;
- dest= s->current_picture.f.data[0] + (((n >> 1) + 2*s->mb_y) * 8* wrap ) + ((n & 1) + 2*s->mb_x) * 8;
- }else{
- wrap= s->uvlinesize;
- dest= s->current_picture.f.data[n - 3] + (s->mb_y * 8 * wrap) + s->mb_x * 8;
- }
- if(s->mb_x==0) a= (1024 + (scale>>1))/scale;
- else a= get_dc(dest-8, wrap, scale*8);
- if(s->mb_y==0) c= (1024 + (scale>>1))/scale;
- else c= get_dc(dest-8*wrap, wrap, scale*8);
-
- if (s->h263_aic_dir==0) {
- pred= a;
- *dir_ptr = 0;
- }else if (s->h263_aic_dir==1) {
- if(n==0){
- pred= c;
- *dir_ptr = 1;
- }else{
- pred= a;
- *dir_ptr = 0;
- }
- }else if (s->h263_aic_dir==2) {
- if(n==0){
- pred= a;
- *dir_ptr = 0;
- }else{
- pred= c;
- *dir_ptr = 1;
- }
- } else {
- pred= c;
- *dir_ptr = 1;
- }
- }
- }else{
- if (abs(a - b) < abs(b - c)) {
- pred = c;
- *dir_ptr = 1;
- } else {
- pred = a;
- *dir_ptr = 0;
- }
- }
- }else{
- if (abs(a - b) <= abs(b - c)) {
- pred = c;
- *dir_ptr = 1;
- } else {
- pred = a;
- *dir_ptr = 0;
- }
- }
-
- /* update predictor */
- *dc_val_ptr = &dc_val[0];
- return pred;
-}
-
-/****************************************/
-/* decoding stuff */
-
-VLC ff_mb_non_intra_vlc[4];
-static VLC v2_dc_lum_vlc;
-static VLC v2_dc_chroma_vlc;
-static VLC v2_intra_cbpc_vlc;
-static VLC v2_mb_type_vlc;
-static VLC v2_mv_vlc;
-VLC ff_inter_intra_vlc;
-
-/* This is identical to h263 except that its range is multiplied by 2. */
-static int msmpeg4v2_decode_motion(MpegEncContext * s, int pred, int f_code)
-{
- int code, val, sign, shift;
-
- code = get_vlc2(&s->gb, v2_mv_vlc.table, V2_MV_VLC_BITS, 2);
- av_dlog(s, "MV code %d at %d %d pred: %d\n", code, s->mb_x,s->mb_y, pred);
- if (code < 0)
- return 0xffff;
-
- if (code == 0)
- return pred;
- sign = get_bits1(&s->gb);
- shift = f_code - 1;
- val = code;
- if (shift) {
- val = (val - 1) << shift;
- val |= get_bits(&s->gb, shift);
- val++;
- }
- if (sign)
- val = -val;
-
- val += pred;
- if (val <= -64)
- val += 64;
- else if (val >= 64)
- val -= 64;
-
- return val;
-}
-
-static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64])
-{
- int cbp, code, i;
- uint32_t * const mb_type_ptr = &s->current_picture.f.mb_type[s->mb_x + s->mb_y*s->mb_stride];
-
- if (s->pict_type == AV_PICTURE_TYPE_P) {
- if (s->use_skip_mb_code) {
- if (get_bits1(&s->gb)) {
- /* skip mb */
- s->mb_intra = 0;
- for(i=0;i<6;i++)
- s->block_last_index[i] = -1;
- s->mv_dir = MV_DIR_FORWARD;
- s->mv_type = MV_TYPE_16X16;
- s->mv[0][0][0] = 0;
- s->mv[0][0][1] = 0;
- s->mb_skipped = 1;
- *mb_type_ptr = MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
- return 0;
- }
- }
-
- if(s->msmpeg4_version==2)
- code = get_vlc2(&s->gb, v2_mb_type_vlc.table, V2_MB_TYPE_VLC_BITS, 1);
- else
- code = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
- if(code<0 || code>7){
- av_log(s->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", code, s->mb_x, s->mb_y);
- return -1;
- }
-
- s->mb_intra = code >>2;
-
- cbp = code & 0x3;
- } else {
- s->mb_intra = 1;
- if(s->msmpeg4_version==2)
- cbp= get_vlc2(&s->gb, v2_intra_cbpc_vlc.table, V2_INTRA_CBPC_VLC_BITS, 1);
- else
- cbp= get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 1);
- if(cbp<0 || cbp>3){
- av_log(s->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", cbp, s->mb_x, s->mb_y);
- return -1;
- }
- }
-
- if (!s->mb_intra) {
- int mx, my, cbpy;
-
- cbpy= get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
- if(cbpy<0){
- av_log(s->avctx, AV_LOG_ERROR, "cbpy %d invalid at %d %d\n", cbp, s->mb_x, s->mb_y);
- return -1;
- }
-
- cbp|= cbpy<<2;
- if(s->msmpeg4_version==1 || (cbp&3) != 3) cbp^= 0x3C;
-
- ff_h263_pred_motion(s, 0, 0, &mx, &my);
- mx= msmpeg4v2_decode_motion(s, mx, 1);
- my= msmpeg4v2_decode_motion(s, my, 1);
-
- s->mv_dir = MV_DIR_FORWARD;
- s->mv_type = MV_TYPE_16X16;
- s->mv[0][0][0] = mx;
- s->mv[0][0][1] = my;
- *mb_type_ptr = MB_TYPE_L0 | MB_TYPE_16x16;
- } else {
- if(s->msmpeg4_version==2){
- s->ac_pred = get_bits1(&s->gb);
- cbp|= get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1)<<2; //FIXME check errors
- } else{
- s->ac_pred = 0;
- cbp|= get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1)<<2; //FIXME check errors
- if(s->pict_type==AV_PICTURE_TYPE_P) cbp^=0x3C;
- }
- *mb_type_ptr = MB_TYPE_INTRA;
- }
-
- s->dsp.clear_blocks(s->block[0]);
- for (i = 0; i < 6; i++) {
- if (ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
- {
- av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
- return -1;
- }
- }
- return 0;
-}
-
-static int msmpeg4v34_decode_mb(MpegEncContext *s, int16_t block[6][64])
-{
- int cbp, code, i;
- uint8_t *coded_val;
- uint32_t * const mb_type_ptr = &s->current_picture.f.mb_type[s->mb_x + s->mb_y*s->mb_stride];
-
- if (s->pict_type == AV_PICTURE_TYPE_P) {
- if (s->use_skip_mb_code) {
- if (get_bits1(&s->gb)) {
- /* skip mb */
- s->mb_intra = 0;
- for(i=0;i<6;i++)
- s->block_last_index[i] = -1;
- s->mv_dir = MV_DIR_FORWARD;
- s->mv_type = MV_TYPE_16X16;
- s->mv[0][0][0] = 0;
- s->mv[0][0][1] = 0;
- s->mb_skipped = 1;
- *mb_type_ptr = MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
-
- return 0;
- }
- }
-
- code = get_vlc2(&s->gb, ff_mb_non_intra_vlc[DEFAULT_INTER_INDEX].table, MB_NON_INTRA_VLC_BITS, 3);
- if (code < 0)
- return -1;
- //s->mb_intra = (code & 0x40) ? 0 : 1;
- s->mb_intra = (~code & 0x40) >> 6;
-
- cbp = code & 0x3f;
- } else {
- s->mb_intra = 1;
- code = get_vlc2(&s->gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);
- if (code < 0)
- return -1;
- /* predict coded block pattern */
- cbp = 0;
- for(i=0;i<6;i++) {
- int val = ((code >> (5 - i)) & 1);
- if (i < 4) {
- int pred = ff_msmpeg4_coded_block_pred(s, i, &coded_val);
- val = val ^ pred;
- *coded_val = val;
- }
- cbp |= val << (5 - i);
- }
- }
-
- if (!s->mb_intra) {
- int mx, my;
- if(s->per_mb_rl_table && cbp){
- s->rl_table_index = decode012(&s->gb);
- s->rl_chroma_table_index = s->rl_table_index;
- }
- ff_h263_pred_motion(s, 0, 0, &mx, &my);
- if (ff_msmpeg4_decode_motion(s, &mx, &my) < 0)
- return -1;
- s->mv_dir = MV_DIR_FORWARD;
- s->mv_type = MV_TYPE_16X16;
- s->mv[0][0][0] = mx;
- s->mv[0][0][1] = my;
- *mb_type_ptr = MB_TYPE_L0 | MB_TYPE_16x16;
- } else {
- av_dlog(s, "I at %d %d %d %06X\n", s->mb_x, s->mb_y,
- ((cbp & 3) ? 1 : 0) +((cbp & 0x3C)? 2 : 0),
- show_bits(&s->gb, 24));
- s->ac_pred = get_bits1(&s->gb);
- *mb_type_ptr = MB_TYPE_INTRA;
- if(s->inter_intra_pred){
- s->h263_aic_dir= get_vlc2(&s->gb, ff_inter_intra_vlc.table, INTER_INTRA_VLC_BITS, 1);
- av_dlog(s, "%d%d %d %d/",
- s->ac_pred, s->h263_aic_dir, s->mb_x, s->mb_y);
- }
- if(s->per_mb_rl_table && cbp){
- s->rl_table_index = decode012(&s->gb);
- s->rl_chroma_table_index = s->rl_table_index;
- }
- }
-
- s->dsp.clear_blocks(s->block[0]);
- for (i = 0; i < 6; i++) {
- if (ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
- {
- av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
- return -1;
- }
- }
-
- return 0;
-}
-
-/* init all vlc decoding tables */
-av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
-{
- MpegEncContext *s = avctx->priv_data;
- static volatile int done = 0;
- int i, ret;
- MVTable *mv;
-
- if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0)
- return ret;
-
- if (ff_h263_decode_init(avctx) < 0)
- return -1;
-
- ff_msmpeg4_common_init(s);
-
- if (!done) {
- for(i=0;i<NB_RL_TABLES;i++) {
- ff_init_rl(&ff_rl_table[i], ff_static_rl_table_store[i]);
- }
- INIT_VLC_RL(ff_rl_table[0], 642);
- INIT_VLC_RL(ff_rl_table[1], 1104);
- INIT_VLC_RL(ff_rl_table[2], 554);
- INIT_VLC_RL(ff_rl_table[3], 940);
- INIT_VLC_RL(ff_rl_table[4], 962);
- INIT_VLC_RL(ff_rl_table[5], 554);
-
- mv = &ff_mv_tables[0];
- INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1,
- mv->table_mv_bits, 1, 1,
- mv->table_mv_code, 2, 2, 3714);
- mv = &ff_mv_tables[1];
- INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1,
- mv->table_mv_bits, 1, 1,
- mv->table_mv_code, 2, 2, 2694);
-
- INIT_VLC_STATIC(&ff_msmp4_dc_luma_vlc[0], DC_VLC_BITS, 120,
- &ff_table0_dc_lum[0][1], 8, 4,
- &ff_table0_dc_lum[0][0], 8, 4, 1158);
- INIT_VLC_STATIC(&ff_msmp4_dc_chroma_vlc[0], DC_VLC_BITS, 120,
- &ff_table0_dc_chroma[0][1], 8, 4,
- &ff_table0_dc_chroma[0][0], 8, 4, 1118);
- INIT_VLC_STATIC(&ff_msmp4_dc_luma_vlc[1], DC_VLC_BITS, 120,
- &ff_table1_dc_lum[0][1], 8, 4,
- &ff_table1_dc_lum[0][0], 8, 4, 1476);
- INIT_VLC_STATIC(&ff_msmp4_dc_chroma_vlc[1], DC_VLC_BITS, 120,
- &ff_table1_dc_chroma[0][1], 8, 4,
- &ff_table1_dc_chroma[0][0], 8, 4, 1216);
-
- INIT_VLC_STATIC(&v2_dc_lum_vlc, DC_VLC_BITS, 512,
- &ff_v2_dc_lum_table[0][1], 8, 4,
- &ff_v2_dc_lum_table[0][0], 8, 4, 1472);
- INIT_VLC_STATIC(&v2_dc_chroma_vlc, DC_VLC_BITS, 512,
- &ff_v2_dc_chroma_table[0][1], 8, 4,
- &ff_v2_dc_chroma_table[0][0], 8, 4, 1506);
-
- INIT_VLC_STATIC(&v2_intra_cbpc_vlc, V2_INTRA_CBPC_VLC_BITS, 4,
- &ff_v2_intra_cbpc[0][1], 2, 1,
- &ff_v2_intra_cbpc[0][0], 2, 1, 8);
- INIT_VLC_STATIC(&v2_mb_type_vlc, V2_MB_TYPE_VLC_BITS, 8,
- &ff_v2_mb_type[0][1], 2, 1,
- &ff_v2_mb_type[0][0], 2, 1, 128);
- INIT_VLC_STATIC(&v2_mv_vlc, V2_MV_VLC_BITS, 33,
- &ff_mvtab[0][1], 2, 1,
- &ff_mvtab[0][0], 2, 1, 538);
-
- INIT_VLC_STATIC(&ff_mb_non_intra_vlc[0], MB_NON_INTRA_VLC_BITS, 128,
- &ff_wmv2_inter_table[0][0][1], 8, 4,
- &ff_wmv2_inter_table[0][0][0], 8, 4, 1636);
- INIT_VLC_STATIC(&ff_mb_non_intra_vlc[1], MB_NON_INTRA_VLC_BITS, 128,
- &ff_wmv2_inter_table[1][0][1], 8, 4,
- &ff_wmv2_inter_table[1][0][0], 8, 4, 2648);
- INIT_VLC_STATIC(&ff_mb_non_intra_vlc[2], MB_NON_INTRA_VLC_BITS, 128,
- &ff_wmv2_inter_table[2][0][1], 8, 4,
- &ff_wmv2_inter_table[2][0][0], 8, 4, 1532);
- INIT_VLC_STATIC(&ff_mb_non_intra_vlc[3], MB_NON_INTRA_VLC_BITS, 128,
- &ff_wmv2_inter_table[3][0][1], 8, 4,
- &ff_wmv2_inter_table[3][0][0], 8, 4, 2488);
-
- INIT_VLC_STATIC(&ff_msmp4_mb_i_vlc, MB_INTRA_VLC_BITS, 64,
- &ff_msmp4_mb_i_table[0][1], 4, 2,
- &ff_msmp4_mb_i_table[0][0], 4, 2, 536);
-
- INIT_VLC_STATIC(&ff_inter_intra_vlc, INTER_INTRA_VLC_BITS, 4,
- &ff_table_inter_intra[0][1], 2, 1,
- &ff_table_inter_intra[0][0], 2, 1, 8);
- done = 1;
- }
-
- switch(s->msmpeg4_version){
- case 1:
- case 2:
- s->decode_mb= msmpeg4v12_decode_mb;
- break;
- case 3:
- case 4:
- s->decode_mb= msmpeg4v34_decode_mb;
- break;
- case 5:
- if (CONFIG_WMV2_DECODER)
- s->decode_mb= ff_wmv2_decode_mb;
- case 6:
- //FIXME + TODO VC1 decode mb
- break;
- }
-
- s->slice_height= s->mb_height; //to avoid 1/0 if the first frame is not a keyframe
-
- return 0;
-}
-
-int ff_msmpeg4_decode_picture_header(MpegEncContext * s)
-{
- int code;
-
- if(s->msmpeg4_version==1){
- int start_code = get_bits_long(&s->gb, 32);
- if(start_code!=0x00000100){
- av_log(s->avctx, AV_LOG_ERROR, "invalid startcode\n");
- return -1;
- }
-
- skip_bits(&s->gb, 5); // frame number */
- }
-
- s->pict_type = get_bits(&s->gb, 2) + 1;
- if (s->pict_type != AV_PICTURE_TYPE_I &&
- s->pict_type != AV_PICTURE_TYPE_P){
- av_log(s->avctx, AV_LOG_ERROR, "invalid picture type\n");
- return -1;
- }
-#if 0
-{
- static int had_i=0;
- if(s->pict_type == AV_PICTURE_TYPE_I) had_i=1;
- if(!had_i) return -1;
-}
-#endif
- s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
- if(s->qscale==0){
- av_log(s->avctx, AV_LOG_ERROR, "invalid qscale\n");
- return -1;
- }
-
- if (s->pict_type == AV_PICTURE_TYPE_I) {
- code = get_bits(&s->gb, 5);
- if(s->msmpeg4_version==1){
- if(code==0 || code>s->mb_height){
- av_log(s->avctx, AV_LOG_ERROR, "invalid slice height %d\n", code);
- return -1;
- }
-
- s->slice_height = code;
- }else{
- /* 0x17: one slice, 0x18: two slices, ... */
- if (code < 0x17){
- av_log(s->avctx, AV_LOG_ERROR, "error, slice code was %X\n", code);
- return -1;
- }
-
- s->slice_height = s->mb_height / (code - 0x16);
- }
-
- switch(s->msmpeg4_version){
- case 1:
- case 2:
- s->rl_chroma_table_index = 2;
- s->rl_table_index = 2;
-
- s->dc_table_index = 0; //not used
- break;
- case 3:
- s->rl_chroma_table_index = decode012(&s->gb);
- s->rl_table_index = decode012(&s->gb);
-
- s->dc_table_index = get_bits1(&s->gb);
- break;
- case 4:
- ff_msmpeg4_decode_ext_header(s, (2+5+5+17+7)/8);
-
- if(s->bit_rate > MBAC_BITRATE) s->per_mb_rl_table= get_bits1(&s->gb);
- else s->per_mb_rl_table= 0;
-
- if(!s->per_mb_rl_table){
- s->rl_chroma_table_index = decode012(&s->gb);
- s->rl_table_index = decode012(&s->gb);
- }
-
- s->dc_table_index = get_bits1(&s->gb);
- s->inter_intra_pred= 0;
- break;
- }
- s->no_rounding = 1;
- if(s->avctx->debug&FF_DEBUG_PICT_INFO)
- av_log(s->avctx, AV_LOG_DEBUG, "qscale:%d rlc:%d rl:%d dc:%d mbrl:%d slice:%d \n",
- s->qscale,
- s->rl_chroma_table_index,
- s->rl_table_index,
- s->dc_table_index,
- s->per_mb_rl_table,
- s->slice_height);
- } else {
- switch(s->msmpeg4_version){
- case 1:
- case 2:
- if(s->msmpeg4_version==1)
- s->use_skip_mb_code = 1;
- else
- s->use_skip_mb_code = get_bits1(&s->gb);
- s->rl_table_index = 2;
- s->rl_chroma_table_index = s->rl_table_index;
- s->dc_table_index = 0; //not used
- s->mv_table_index = 0;
- break;
- case 3:
- s->use_skip_mb_code = get_bits1(&s->gb);
- s->rl_table_index = decode012(&s->gb);
- s->rl_chroma_table_index = s->rl_table_index;
-
- s->dc_table_index = get_bits1(&s->gb);
-
- s->mv_table_index = get_bits1(&s->gb);
- break;
- case 4:
- s->use_skip_mb_code = get_bits1(&s->gb);
-
- if(s->bit_rate > MBAC_BITRATE) s->per_mb_rl_table= get_bits1(&s->gb);
- else s->per_mb_rl_table= 0;
-
- if(!s->per_mb_rl_table){
- s->rl_table_index = decode012(&s->gb);
- s->rl_chroma_table_index = s->rl_table_index;
- }
-
- s->dc_table_index = get_bits1(&s->gb);
-
- s->mv_table_index = get_bits1(&s->gb);
- s->inter_intra_pred= (s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE);
- break;
- }
-
- if(s->avctx->debug&FF_DEBUG_PICT_INFO)
- av_log(s->avctx, AV_LOG_DEBUG, "skip:%d rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d \n",
- s->use_skip_mb_code,
- s->rl_table_index,
- s->rl_chroma_table_index,
- s->dc_table_index,
- s->mv_table_index,
- s->per_mb_rl_table,
- s->qscale);
-
- if(s->flipflop_rounding){
- s->no_rounding ^= 1;
- }else{
- s->no_rounding = 0;
- }
- }
- av_dlog(s->avctx, "%d %d %d %d %d\n", s->pict_type, s->bit_rate,
- s->inter_intra_pred, s->width, s->height);
-
- s->esc3_level_length= 0;
- s->esc3_run_length= 0;
-
- return 0;
-}
-
-int ff_msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size)
-{
- int left= buf_size*8 - get_bits_count(&s->gb);
- int length= s->msmpeg4_version>=3 ? 17 : 16;
- /* the alt_bitstream reader could read over the end so we need to check it */
- if(left>=length && left<length+8)
- {
- skip_bits(&s->gb, 5); /* fps */
- s->bit_rate= get_bits(&s->gb, 11)*1024;
- if(s->msmpeg4_version>=3)
- s->flipflop_rounding= get_bits1(&s->gb);
- else
- s->flipflop_rounding= 0;
- }
- else if(left<length+8)
- {
- s->flipflop_rounding= 0;
- if(s->msmpeg4_version != 2)
- av_log(s->avctx, AV_LOG_ERROR, "ext header missing, %d left\n", left);
- }
- else
- {
- av_log(s->avctx, AV_LOG_ERROR, "I frame too long, ignoring ext header\n");
- }
-
- return 0;
-}
-
-static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr)
-{
- int level, pred;
-
- if(s->msmpeg4_version<=2){
- if (n < 4) {
- level = get_vlc2(&s->gb, v2_dc_lum_vlc.table, DC_VLC_BITS, 3);
- } else {
- level = get_vlc2(&s->gb, v2_dc_chroma_vlc.table, DC_VLC_BITS, 3);
- }
- if (level < 0)
- return -1;
- level-=256;
- }else{ //FIXME optimize use unified tables & index
- if (n < 4) {
- level = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
- } else {
- level = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
- }
- if (level < 0){
- av_log(s->avctx, AV_LOG_ERROR, "illegal dc vlc\n");
- return -1;
- }
-
- if (level == DC_MAX) {
- level = get_bits(&s->gb, 8);
- if (get_bits1(&s->gb))
- level = -level;
- } else if (level != 0) {
- if (get_bits1(&s->gb))
- level = -level;
- }
- }
-
- if(s->msmpeg4_version==1){
- int32_t *dc_val;
- pred = msmpeg4v1_pred_dc(s, n, &dc_val);
- level += pred;
-
- /* update predictor */
- *dc_val= level;
- }else{
- int16_t *dc_val;
- pred = ff_msmpeg4_pred_dc(s, n, &dc_val, dir_ptr);
- level += pred;
-
- /* update predictor */
- if (n < 4) {
- *dc_val = level * s->y_dc_scale;
- } else {
- *dc_val = level * s->c_dc_scale;
- }
- }
-
- return level;
-}
-
-//#define ERROR_DETAILS
-int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block,
- int n, int coded, const uint8_t *scan_table)
-{
- int level, i, last, run, run_diff;
- int av_uninit(dc_pred_dir);
- RLTable *rl;
- RL_VLC_ELEM *rl_vlc;
- int qmul, qadd;
-
- if (s->mb_intra) {
- qmul=1;
- qadd=0;
-
- /* DC coef */
- level = msmpeg4_decode_dc(s, n, &dc_pred_dir);
-
- if (level < 0){
- av_log(s->avctx, AV_LOG_ERROR, "dc overflow- block: %d qscale: %d//\n", n, s->qscale);
- if(s->inter_intra_pred) level=0;
- else return -1;
- }
- if (n < 4) {
- rl = &ff_rl_table[s->rl_table_index];
- if(level > 256*s->y_dc_scale){
- av_log(s->avctx, AV_LOG_ERROR, "dc overflow+ L qscale: %d//\n", s->qscale);
- if(!s->inter_intra_pred) return -1;
- }
- } else {
- rl = &ff_rl_table[3 + s->rl_chroma_table_index];
- if(level > 256*s->c_dc_scale){
- av_log(s->avctx, AV_LOG_ERROR, "dc overflow+ C qscale: %d//\n", s->qscale);
- if(!s->inter_intra_pred) return -1;
- }
- }
- block[0] = level;
-
- run_diff = s->msmpeg4_version >= 4;
- i = 0;
- if (!coded) {
- goto not_coded;
- }
- if (s->ac_pred) {
- if (dc_pred_dir == 0)
- scan_table = s->intra_v_scantable.permutated; /* left */
- else
- scan_table = s->intra_h_scantable.permutated; /* top */
- } else {
- scan_table = s->intra_scantable.permutated;
- }
- rl_vlc= rl->rl_vlc[0];
- } else {
- qmul = s->qscale << 1;
- qadd = (s->qscale - 1) | 1;
- i = -1;
- rl = &ff_rl_table[3 + s->rl_table_index];
-
- if(s->msmpeg4_version==2)
- run_diff = 0;
- else
- run_diff = 1;
-
- if (!coded) {
- s->block_last_index[n] = i;
- return 0;
- }
- if(!scan_table)
- scan_table = s->inter_scantable.permutated;
- rl_vlc= rl->rl_vlc[s->qscale];
- }
- {
- OPEN_READER(re, &s->gb);
- for(;;) {
- UPDATE_CACHE(re, &s->gb);
- GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 0);
- if (level==0) {
- int cache;
- cache= GET_CACHE(re, &s->gb);
- /* escape */
- if (s->msmpeg4_version==1 || (cache&0x80000000)==0) {
- if (s->msmpeg4_version==1 || (cache&0x40000000)==0) {
- /* third escape */
- if(s->msmpeg4_version!=1) LAST_SKIP_BITS(re, &s->gb, 2);
- UPDATE_CACHE(re, &s->gb);
- if(s->msmpeg4_version<=3){
- last= SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1);
- run= SHOW_UBITS(re, &s->gb, 6); SKIP_CACHE(re, &s->gb, 6);
- level= SHOW_SBITS(re, &s->gb, 8);
- SKIP_COUNTER(re, &s->gb, 1+6+8);
- }else{
- int sign;
- last= SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1);
- if(!s->esc3_level_length){
- int ll;
- av_dlog(s->avctx, "ESC-3 %X at %d %d\n",
- show_bits(&s->gb, 24), s->mb_x, s->mb_y);
- if(s->qscale<8){
- ll= SHOW_UBITS(re, &s->gb, 3); SKIP_BITS(re, &s->gb, 3);
- if(ll==0){
- ll= 8+SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1);
- }
- }else{
- ll=2;
- while(ll<8 && SHOW_UBITS(re, &s->gb, 1)==0){
- ll++;
- SKIP_BITS(re, &s->gb, 1);
- }
- if(ll<8) SKIP_BITS(re, &s->gb, 1);
- }
-
- s->esc3_level_length= ll;
- s->esc3_run_length= SHOW_UBITS(re, &s->gb, 2) + 3; SKIP_BITS(re, &s->gb, 2);
- UPDATE_CACHE(re, &s->gb);
- }
- run= SHOW_UBITS(re, &s->gb, s->esc3_run_length);
- SKIP_BITS(re, &s->gb, s->esc3_run_length);
-
- sign= SHOW_UBITS(re, &s->gb, 1);
- SKIP_BITS(re, &s->gb, 1);
-
- level= SHOW_UBITS(re, &s->gb, s->esc3_level_length);
- SKIP_BITS(re, &s->gb, s->esc3_level_length);
- if(sign) level= -level;
- }
-
-#if 0 // waste of time / this will detect very few errors
- {
- const int abs_level= FFABS(level);
- const int run1= run - rl->max_run[last][abs_level] - run_diff;
- if(abs_level<=MAX_LEVEL && run<=MAX_RUN){
- if(abs_level <= rl->max_level[last][run]){
- av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, vlc encoding possible\n");
- return DECODING_AC_LOST;
- }
- if(abs_level <= rl->max_level[last][run]*2){
- av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, esc 1 encoding possible\n");
- return DECODING_AC_LOST;
- }
- if(run1>=0 && abs_level <= rl->max_level[last][run1]){
- av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, esc 2 encoding possible\n");
- return DECODING_AC_LOST;
- }
- }
- }
-#endif
- //level = level * qmul + (level>0) * qadd - (level<=0) * qadd ;
- if (level>0) level= level * qmul + qadd;
- else level= level * qmul - qadd;
-#if 0 // waste of time too :(
- if(level>2048 || level<-2048){
- av_log(s->avctx, AV_LOG_ERROR, "|level| overflow in 3. esc\n");
- return DECODING_AC_LOST;
- }
-#endif
- i+= run + 1;
- if(last) i+=192;
-#ifdef ERROR_DETAILS
- if(run==66)
- av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code in ESC3 level=%d\n", level);
- else if((i>62 && i<192) || i>192+63)
- av_log(s->avctx, AV_LOG_ERROR, "run overflow in ESC3 i=%d run=%d level=%d\n", i, run, level);
-#endif
- } else {
- /* second escape */
- SKIP_BITS(re, &s->gb, 2);
- GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
- i+= run + rl->max_run[run>>7][level/qmul] + run_diff; //FIXME opt indexing
- level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
- LAST_SKIP_BITS(re, &s->gb, 1);
-#ifdef ERROR_DETAILS
- if(run==66)
- av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code in ESC2 level=%d\n", level);
- else if((i>62 && i<192) || i>192+63)
- av_log(s->avctx, AV_LOG_ERROR, "run overflow in ESC2 i=%d run=%d level=%d\n", i, run, level);
-#endif
- }
- } else {
- /* first escape */
- SKIP_BITS(re, &s->gb, 1);
- GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1);
- i+= run;
- level = level + rl->max_level[run>>7][(run-1)&63] * qmul;//FIXME opt indexing
- level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
- LAST_SKIP_BITS(re, &s->gb, 1);
-#ifdef ERROR_DETAILS
- if(run==66)
- av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code in ESC1 level=%d\n", level);
- else if((i>62 && i<192) || i>192+63)
- av_log(s->avctx, AV_LOG_ERROR, "run overflow in ESC1 i=%d run=%d level=%d\n", i, run, level);
-#endif
- }
- } else {
- i+= run;
- level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1);
- LAST_SKIP_BITS(re, &s->gb, 1);
-#ifdef ERROR_DETAILS
- if(run==66)
- av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code level=%d\n", level);
- else if((i>62 && i<192) || i>192+63)
- av_log(s->avctx, AV_LOG_ERROR, "run overflow i=%d run=%d level=%d\n", i, run, level);
-#endif
- }
- if (i > 62){
- i-= 192;
- if(i&(~63)){
- const int left= get_bits_left(&s->gb);
- if(((i+192 == 64 && level/qmul==-1) || !(s->err_recognition&(AV_EF_BITSTREAM|AV_EF_COMPLIANT))) && left>=0){
- av_log(s->avctx, AV_LOG_ERROR, "ignoring overflow at %d %d\n", s->mb_x, s->mb_y);
- i = 63;
- break;
- }else{
- av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
- }
-
- block[scan_table[i]] = level;
- break;
- }
-
- block[scan_table[i]] = level;
- }
- CLOSE_READER(re, &s->gb);
- }
- not_coded:
- if (s->mb_intra) {
- ff_mpeg4_pred_ac(s, block, n, dc_pred_dir);
- if (s->ac_pred) {
- i = 63; /* XXX: not optimal */
- }
- }
- if(s->msmpeg4_version>=4 && i>0) i=63; //FIXME/XXX optimize
- s->block_last_index[n] = i;
-
- return 0;
-}
-
-int ff_msmpeg4_decode_motion(MpegEncContext * s,
- int *mx_ptr, int *my_ptr)
-{
- MVTable *mv;
- int code, mx, my;
-
- mv = &ff_mv_tables[s->mv_table_index];
-
- code = get_vlc2(&s->gb, mv->vlc.table, MV_VLC_BITS, 2);
- if (code < 0){
- av_log(s->avctx, AV_LOG_ERROR, "illegal MV code at %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
- if (code == mv->n) {
- mx = get_bits(&s->gb, 6);
- my = get_bits(&s->gb, 6);
- } else {
- mx = mv->table_mvx[code];
- my = mv->table_mvy[code];
- }
-
- mx += *mx_ptr - 32;
- my += *my_ptr - 32;
- /* WARNING : they do not do exactly modulo encoding */
- if (mx <= -64)
- mx += 64;
- else if (mx >= 64)
- mx -= 64;
-
- if (my <= -64)
- my += 64;
- else if (my >= 64)
- my -= 64;
- *mx_ptr = mx;
- *my_ptr = my;
- return 0;
-}
-
-AVCodec ff_msmpeg4v1_decoder = {
- .name = "msmpeg4v1",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_MSMPEG4V1,
- .priv_data_size = sizeof(MpegEncContext),
- .init = ff_msmpeg4_decode_init,
- .close = ff_h263_decode_end,
- .decode = ff_h263_decode_frame,
- .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
- .max_lowres = 3,
- .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 1"),
- .pix_fmts = ff_pixfmt_list_420,
-};
-
-AVCodec ff_msmpeg4v2_decoder = {
- .name = "msmpeg4v2",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_MSMPEG4V2,
- .priv_data_size = sizeof(MpegEncContext),
- .init = ff_msmpeg4_decode_init,
- .close = ff_h263_decode_end,
- .decode = ff_h263_decode_frame,
- .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
- .max_lowres = 3,
- .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 2"),
- .pix_fmts = ff_pixfmt_list_420,
-};
-
-AVCodec ff_msmpeg4v3_decoder = {
- .name = "msmpeg4",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_MSMPEG4V3,
- .priv_data_size = sizeof(MpegEncContext),
- .init = ff_msmpeg4_decode_init,
- .close = ff_h263_decode_end,
- .decode = ff_h263_decode_frame,
- .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
- .max_lowres = 3,
- .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 part 2 Microsoft variant version 3"),
- .pix_fmts = ff_pixfmt_list_420,
-};
-
-AVCodec ff_wmv1_decoder = {
- .name = "wmv1",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_WMV1,
- .priv_data_size = sizeof(MpegEncContext),
- .init = ff_msmpeg4_decode_init,
- .close = ff_h263_decode_end,
- .decode = ff_h263_decode_frame,
- .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
- .max_lowres = 3,
- .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 7"),
- .pix_fmts = ff_pixfmt_list_420,
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/msmpeg4.h b/src/thirdparty/ffmpeg/libavcodec/msmpeg4.h
deleted file mode 100644
index b49354149..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/msmpeg4.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * MSMPEG4 backend for encoder and decoder
- * copyright (c) 2007 Aurelien Jacobs <aurel@gnuage.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_MSMPEG4_H
-#define AVCODEC_MSMPEG4_H
-
-#include <stdint.h>
-
-#include "config.h"
-#include "avcodec.h"
-#include "mpegvideo.h"
-#include "msmpeg4data.h"
-#include "put_bits.h"
-
-#define INTER_INTRA_VLC_BITS 3
-#define MB_NON_INTRA_VLC_BITS 9
-#define MB_INTRA_VLC_BITS 9
-
-#define II_BITRATE 128*1024
-#define MBAC_BITRATE 50*1024
-
-#define DC_MAX 119
-
-extern VLC ff_mb_non_intra_vlc[4];
-extern VLC ff_inter_intra_vlc;
-
-void ff_msmpeg4_code012(PutBitContext *pb, int n);
-void ff_msmpeg4_common_init(MpegEncContext *s);
-void ff_msmpeg4_encode_block(MpegEncContext * s, int16_t * block, int n);
-void ff_msmpeg4_handle_slices(MpegEncContext *s);
-void ff_msmpeg4_encode_motion(MpegEncContext * s, int mx, int my);
-int ff_msmpeg4_coded_block_pred(MpegEncContext * s, int n,
- uint8_t **coded_block_ptr);
-int ff_msmpeg4_decode_motion(MpegEncContext * s, int *mx_ptr, int *my_ptr);
-int ff_msmpeg4_decode_block(MpegEncContext * s, int16_t * block,
- int n, int coded, const uint8_t *scan_table);
-int ff_msmpeg4_pred_dc(MpegEncContext *s, int n,
- int16_t **dc_val_ptr, int *dir_ptr);
-int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64]);
-
-#define CONFIG_MSMPEG4_DECODER (CONFIG_MSMPEG4V1_DECODER || \
- CONFIG_MSMPEG4V2_DECODER || \
- CONFIG_MSMPEG4V3_DECODER || \
- CONFIG_WMV2_DECODER || \
- CONFIG_VC1_DECODER)
-#define CONFIG_MSMPEG4_ENCODER (CONFIG_MSMPEG4V2_ENCODER || \
- CONFIG_MSMPEG4V3_ENCODER || \
- CONFIG_WMV2_ENCODER)
-
-#endif /* AVCODEC_MSMPEG4_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/msmpeg4data.c b/src/thirdparty/ffmpeg/libavcodec/msmpeg4data.c
deleted file mode 100644
index 6584dfa6e..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/msmpeg4data.c
+++ /dev/null
@@ -1,2005 +0,0 @@
-/*
- * MSMPEG4 backend for encoder and decoder
- * copyright (c) 2001 Fabrice Bellard
- * copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
- *
- * msmpeg4v1 & v2 stuff 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
- * MSMPEG4 data tables.
- */
-
-#include "msmpeg4data.h"
-
-uint32_t ff_v2_dc_lum_table[512][2];
-uint32_t ff_v2_dc_chroma_table[512][2];
-uint8_t ff_static_rl_table_store[NB_RL_TABLES][2][2 * MAX_RUN + MAX_LEVEL + 3];
-
-VLC ff_msmp4_mb_i_vlc;
-VLC ff_msmp4_dc_luma_vlc[2];
-VLC ff_msmp4_dc_chroma_vlc[2];
-
-/* intra picture macroblock coded block pattern */
-const uint16_t ff_msmp4_mb_i_table[64][2] = {
-{ 0x1, 1 },{ 0x17, 6 },{ 0x9, 5 },{ 0x5, 5 },
-{ 0x6, 5 },{ 0x47, 9 },{ 0x20, 7 },{ 0x10, 7 },
-{ 0x2, 5 },{ 0x7c, 9 },{ 0x3a, 7 },{ 0x1d, 7 },
-{ 0x2, 6 },{ 0xec, 9 },{ 0x77, 8 },{ 0x0, 8 },
-{ 0x3, 5 },{ 0xb7, 9 },{ 0x2c, 7 },{ 0x13, 7 },
-{ 0x1, 6 },{ 0x168, 10 },{ 0x46, 8 },{ 0x3f, 8 },
-{ 0x1e, 6 },{ 0x712, 13 },{ 0xb5, 9 },{ 0x42, 8 },
-{ 0x22, 7 },{ 0x1c5, 11 },{ 0x11e, 10 },{ 0x87, 9 },
-{ 0x6, 4 },{ 0x3, 9 },{ 0x1e, 7 },{ 0x1c, 6 },
-{ 0x12, 7 },{ 0x388, 12 },{ 0x44, 9 },{ 0x70, 9 },
-{ 0x1f, 6 },{ 0x23e, 11 },{ 0x39, 8 },{ 0x8e, 9 },
-{ 0x1, 7 },{ 0x1c6, 11 },{ 0xb6, 9 },{ 0x45, 9 },
-{ 0x14, 6 },{ 0x23f, 11 },{ 0x7d, 9 },{ 0x18, 9 },
-{ 0x7, 7 },{ 0x1c7, 11 },{ 0x86, 9 },{ 0x19, 9 },
-{ 0x15, 6 },{ 0x1db, 10 },{ 0x2, 9 },{ 0x46, 9 },
-{ 0xd, 8 },{ 0x713, 13 },{ 0x1da, 10 },{ 0x169, 10 },
-};
-
-/* non intra picture macroblock coded block pattern + mb type */
-const uint32_t ff_table_mb_non_intra[128][2] = {
-{ 0x40, 7 },{ 0x13c9, 13 },{ 0x9fd, 12 },{ 0x1fc, 15 },
-{ 0x9fc, 12 },{ 0xa83, 18 },{ 0x12d34, 17 },{ 0x83bc, 16 },
-{ 0x83a, 12 },{ 0x7f8, 17 },{ 0x3fd, 16 },{ 0x3ff, 16 },
-{ 0x79, 13 },{ 0xa82, 18 },{ 0x969d, 16 },{ 0x2a4, 16 },
-{ 0x978, 12 },{ 0x543, 17 },{ 0x41df, 15 },{ 0x7f9, 17 },
-{ 0x12f3, 13 },{ 0x25a6b, 18 },{ 0x25ef9, 18 },{ 0x3fa, 16 },
-{ 0x20ee, 14 },{ 0x969ab, 20 },{ 0x969c, 16 },{ 0x25ef8, 18 },
-{ 0x12d2, 13 },{ 0xa85, 18 },{ 0x969e, 16 },{ 0x4bc8, 15 },
-{ 0x3d, 12 },{ 0x12f7f, 17 },{ 0x2a2, 16 },{ 0x969f, 16 },
-{ 0x25ee, 14 },{ 0x12d355, 21 },{ 0x12f7d, 17 },{ 0x12f7e, 17 },
-{ 0x9e5, 12 },{ 0xa81, 18 },{ 0x4b4d4, 19 },{ 0x83bd, 16 },
-{ 0x78, 13 },{ 0x969b, 16 },{ 0x3fe, 16 },{ 0x2a5, 16 },
-{ 0x7e, 13 },{ 0xa80, 18 },{ 0x2a3, 16 },{ 0x3fb, 16 },
-{ 0x1076, 13 },{ 0xa84, 18 },{ 0x153, 15 },{ 0x4bc9, 15 },
-{ 0x55, 13 },{ 0x12d354, 21 },{ 0x4bde, 15 },{ 0x25e5, 14 },
-{ 0x25b, 10 },{ 0x4b4c, 15 },{ 0x96b, 12 },{ 0x96a, 12 },
-{ 0x1, 2 },{ 0x0, 7 },{ 0x26, 6 },{ 0x12b, 9 },
-{ 0x7, 3 },{ 0x20f, 10 },{ 0x4, 9 },{ 0x28, 12 },
-{ 0x6, 3 },{ 0x20a, 10 },{ 0x128, 9 },{ 0x2b, 12 },
-{ 0x11, 5 },{ 0x1b, 11 },{ 0x13a, 9 },{ 0x4ff, 11 },
-{ 0x3, 4 },{ 0x277, 10 },{ 0x106, 9 },{ 0x839, 12 },
-{ 0xb, 4 },{ 0x27b, 10 },{ 0x12c, 9 },{ 0x4bf, 11 },
-{ 0x9, 6 },{ 0x35, 12 },{ 0x27e, 10 },{ 0x13c8, 13 },
-{ 0x1, 6 },{ 0x4aa, 11 },{ 0x208, 10 },{ 0x29, 12 },
-{ 0x1, 4 },{ 0x254, 10 },{ 0x12e, 9 },{ 0x838, 12 },
-{ 0x24, 6 },{ 0x4f3, 11 },{ 0x276, 10 },{ 0x12f6, 13 },
-{ 0x1, 5 },{ 0x27a, 10 },{ 0x13e, 9 },{ 0x3e, 12 },
-{ 0x8, 6 },{ 0x413, 11 },{ 0xc, 10 },{ 0x4be, 11 },
-{ 0x14, 5 },{ 0x412, 11 },{ 0x253, 10 },{ 0x97a, 12 },
-{ 0x21, 6 },{ 0x4ab, 11 },{ 0x20b, 10 },{ 0x34, 12 },
-{ 0x15, 5 },{ 0x278, 10 },{ 0x252, 10 },{ 0x968, 12 },
-{ 0x5, 5 },{ 0xb, 10 },{ 0x9c, 8 },{ 0xe, 10 },
-};
-
-/* dc table 0 */
-
-const uint32_t ff_table0_dc_lum[120][2] = {
-{ 0x1, 1 },{ 0x1, 2 },{ 0x1, 4 },{ 0x1, 5 },
-{ 0x5, 5 },{ 0x7, 5 },{ 0x8, 6 },{ 0xc, 6 },
-{ 0x0, 7 },{ 0x2, 7 },{ 0x12, 7 },{ 0x1a, 7 },
-{ 0x3, 8 },{ 0x7, 8 },{ 0x27, 8 },{ 0x37, 8 },
-{ 0x5, 9 },{ 0x4c, 9 },{ 0x6c, 9 },{ 0x6d, 9 },
-{ 0x8, 10 },{ 0x19, 10 },{ 0x9b, 10 },{ 0x1b, 10 },
-{ 0x9a, 10 },{ 0x13, 11 },{ 0x34, 11 },{ 0x35, 11 },
-{ 0x61, 12 },{ 0x48, 13 },{ 0xc4, 13 },{ 0x4a, 13 },
-{ 0xc6, 13 },{ 0xc7, 13 },{ 0x92, 14 },{ 0x18b, 14 },
-{ 0x93, 14 },{ 0x183, 14 },{ 0x182, 14 },{ 0x96, 14 },
-{ 0x97, 14 },{ 0x180, 14 },{ 0x314, 15 },{ 0x315, 15 },
-{ 0x605, 16 },{ 0x604, 16 },{ 0x606, 16 },{ 0xc0e, 17 },
-{ 0x303cd, 23 },{ 0x303c9, 23 },{ 0x303c8, 23 },{ 0x303ca, 23 },
-{ 0x303cb, 23 },{ 0x303cc, 23 },{ 0x303ce, 23 },{ 0x303cf, 23 },
-{ 0x303d0, 23 },{ 0x303d1, 23 },{ 0x303d2, 23 },{ 0x303d3, 23 },
-{ 0x303d4, 23 },{ 0x303d5, 23 },{ 0x303d6, 23 },{ 0x303d7, 23 },
-{ 0x303d8, 23 },{ 0x303d9, 23 },{ 0x303da, 23 },{ 0x303db, 23 },
-{ 0x303dc, 23 },{ 0x303dd, 23 },{ 0x303de, 23 },{ 0x303df, 23 },
-{ 0x303e0, 23 },{ 0x303e1, 23 },{ 0x303e2, 23 },{ 0x303e3, 23 },
-{ 0x303e4, 23 },{ 0x303e5, 23 },{ 0x303e6, 23 },{ 0x303e7, 23 },
-{ 0x303e8, 23 },{ 0x303e9, 23 },{ 0x303ea, 23 },{ 0x303eb, 23 },
-{ 0x303ec, 23 },{ 0x303ed, 23 },{ 0x303ee, 23 },{ 0x303ef, 23 },
-{ 0x303f0, 23 },{ 0x303f1, 23 },{ 0x303f2, 23 },{ 0x303f3, 23 },
-{ 0x303f4, 23 },{ 0x303f5, 23 },{ 0x303f6, 23 },{ 0x303f7, 23 },
-{ 0x303f8, 23 },{ 0x303f9, 23 },{ 0x303fa, 23 },{ 0x303fb, 23 },
-{ 0x303fc, 23 },{ 0x303fd, 23 },{ 0x303fe, 23 },{ 0x303ff, 23 },
-{ 0x60780, 24 },{ 0x60781, 24 },{ 0x60782, 24 },{ 0x60783, 24 },
-{ 0x60784, 24 },{ 0x60785, 24 },{ 0x60786, 24 },{ 0x60787, 24 },
-{ 0x60788, 24 },{ 0x60789, 24 },{ 0x6078a, 24 },{ 0x6078b, 24 },
-{ 0x6078c, 24 },{ 0x6078d, 24 },{ 0x6078e, 24 },{ 0x6078f, 24 },
-};
-
-const uint32_t ff_table0_dc_chroma[120][2] = {
-{ 0x0, 2 },{ 0x1, 2 },{ 0x5, 3 },{ 0x9, 4 },
-{ 0xd, 4 },{ 0x11, 5 },{ 0x1d, 5 },{ 0x1f, 5 },
-{ 0x21, 6 },{ 0x31, 6 },{ 0x38, 6 },{ 0x33, 6 },
-{ 0x39, 6 },{ 0x3d, 6 },{ 0x61, 7 },{ 0x79, 7 },
-{ 0x80, 8 },{ 0xc8, 8 },{ 0xca, 8 },{ 0xf0, 8 },
-{ 0x81, 8 },{ 0xc0, 8 },{ 0xc9, 8 },{ 0x107, 9 },
-{ 0x106, 9 },{ 0x196, 9 },{ 0x183, 9 },{ 0x1e3, 9 },
-{ 0x1e2, 9 },{ 0x20a, 10 },{ 0x20b, 10 },{ 0x609, 11 },
-{ 0x412, 11 },{ 0x413, 11 },{ 0x60b, 11 },{ 0x411, 11 },
-{ 0x60a, 11 },{ 0x65f, 11 },{ 0x410, 11 },{ 0x65d, 11 },
-{ 0x65e, 11 },{ 0xcb8, 12 },{ 0xc10, 12 },{ 0xcb9, 12 },
-{ 0x1823, 13 },{ 0x3045, 14 },{ 0x6089, 15 },{ 0xc110, 16 },
-{ 0x304448, 22 },{ 0x304449, 22 },{ 0x30444a, 22 },{ 0x30444b, 22 },
-{ 0x30444c, 22 },{ 0x30444d, 22 },{ 0x30444e, 22 },{ 0x30444f, 22 },
-{ 0x304450, 22 },{ 0x304451, 22 },{ 0x304452, 22 },{ 0x304453, 22 },
-{ 0x304454, 22 },{ 0x304455, 22 },{ 0x304456, 22 },{ 0x304457, 22 },
-{ 0x304458, 22 },{ 0x304459, 22 },{ 0x30445a, 22 },{ 0x30445b, 22 },
-{ 0x30445c, 22 },{ 0x30445d, 22 },{ 0x30445e, 22 },{ 0x30445f, 22 },
-{ 0x304460, 22 },{ 0x304461, 22 },{ 0x304462, 22 },{ 0x304463, 22 },
-{ 0x304464, 22 },{ 0x304465, 22 },{ 0x304466, 22 },{ 0x304467, 22 },
-{ 0x304468, 22 },{ 0x304469, 22 },{ 0x30446a, 22 },{ 0x30446b, 22 },
-{ 0x30446c, 22 },{ 0x30446d, 22 },{ 0x30446e, 22 },{ 0x30446f, 22 },
-{ 0x304470, 22 },{ 0x304471, 22 },{ 0x304472, 22 },{ 0x304473, 22 },
-{ 0x304474, 22 },{ 0x304475, 22 },{ 0x304476, 22 },{ 0x304477, 22 },
-{ 0x304478, 22 },{ 0x304479, 22 },{ 0x30447a, 22 },{ 0x30447b, 22 },
-{ 0x30447c, 22 },{ 0x30447d, 22 },{ 0x30447e, 22 },{ 0x30447f, 22 },
-{ 0x608880, 23 },{ 0x608881, 23 },{ 0x608882, 23 },{ 0x608883, 23 },
-{ 0x608884, 23 },{ 0x608885, 23 },{ 0x608886, 23 },{ 0x608887, 23 },
-{ 0x608888, 23 },{ 0x608889, 23 },{ 0x60888a, 23 },{ 0x60888b, 23 },
-{ 0x60888c, 23 },{ 0x60888d, 23 },{ 0x60888e, 23 },{ 0x60888f, 23 },
-};
-
-/* dc table 1 */
-
-const uint32_t ff_table1_dc_lum[120][2] = {
-{ 0x2, 2 },{ 0x3, 2 },{ 0x3, 3 },{ 0x2, 4 },
-{ 0x5, 4 },{ 0x1, 5 },{ 0x3, 5 },{ 0x8, 5 },
-{ 0x0, 6 },{ 0x5, 6 },{ 0xd, 6 },{ 0xf, 6 },
-{ 0x13, 6 },{ 0x8, 7 },{ 0x18, 7 },{ 0x1c, 7 },
-{ 0x24, 7 },{ 0x4, 8 },{ 0x6, 8 },{ 0x12, 8 },
-{ 0x32, 8 },{ 0x3b, 8 },{ 0x4a, 8 },{ 0x4b, 8 },
-{ 0xb, 9 },{ 0x26, 9 },{ 0x27, 9 },{ 0x66, 9 },
-{ 0x74, 9 },{ 0x75, 9 },{ 0x14, 10 },{ 0x1c, 10 },
-{ 0x1f, 10 },{ 0x1d, 10 },{ 0x2b, 11 },{ 0x3d, 11 },
-{ 0x19d, 11 },{ 0x19f, 11 },{ 0x54, 12 },{ 0x339, 12 },
-{ 0x338, 12 },{ 0x33d, 12 },{ 0xab, 13 },{ 0xf1, 13 },
-{ 0x678, 13 },{ 0xf2, 13 },{ 0x1e0, 14 },{ 0x1e1, 14 },
-{ 0x154, 14 },{ 0xcf2, 14 },{ 0x3cc, 15 },{ 0x2ab, 15 },
-{ 0x19e7, 15 },{ 0x3ce, 15 },{ 0x19e6, 15 },{ 0x554, 16 },
-{ 0x79f, 16 },{ 0x555, 16 },{ 0xf3d, 17 },{ 0xf37, 17 },
-{ 0xf3c, 17 },{ 0xf35, 17 },{ 0x1e6d, 18 },{ 0x1e68, 18 },
-{ 0x3cd8, 19 },{ 0x3cd3, 19 },{ 0x3cd9, 19 },{ 0x79a4, 20 },
-{ 0xf34ba, 25 },{ 0xf34b4, 25 },{ 0xf34b5, 25 },{ 0xf34b6, 25 },
-{ 0xf34b7, 25 },{ 0xf34b8, 25 },{ 0xf34b9, 25 },{ 0xf34bb, 25 },
-{ 0xf34bc, 25 },{ 0xf34bd, 25 },{ 0xf34be, 25 },{ 0xf34bf, 25 },
-{ 0x1e6940, 26 },{ 0x1e6941, 26 },{ 0x1e6942, 26 },{ 0x1e6943, 26 },
-{ 0x1e6944, 26 },{ 0x1e6945, 26 },{ 0x1e6946, 26 },{ 0x1e6947, 26 },
-{ 0x1e6948, 26 },{ 0x1e6949, 26 },{ 0x1e694a, 26 },{ 0x1e694b, 26 },
-{ 0x1e694c, 26 },{ 0x1e694d, 26 },{ 0x1e694e, 26 },{ 0x1e694f, 26 },
-{ 0x1e6950, 26 },{ 0x1e6951, 26 },{ 0x1e6952, 26 },{ 0x1e6953, 26 },
-{ 0x1e6954, 26 },{ 0x1e6955, 26 },{ 0x1e6956, 26 },{ 0x1e6957, 26 },
-{ 0x1e6958, 26 },{ 0x1e6959, 26 },{ 0x1e695a, 26 },{ 0x1e695b, 26 },
-{ 0x1e695c, 26 },{ 0x1e695d, 26 },{ 0x1e695e, 26 },{ 0x1e695f, 26 },
-{ 0x1e6960, 26 },{ 0x1e6961, 26 },{ 0x1e6962, 26 },{ 0x1e6963, 26 },
-{ 0x1e6964, 26 },{ 0x1e6965, 26 },{ 0x1e6966, 26 },{ 0x1e6967, 26 },
-};
-
-const uint32_t ff_table1_dc_chroma[120][2] = {
-{ 0x0, 2 },{ 0x1, 2 },{ 0x4, 3 },{ 0x7, 3 },
-{ 0xb, 4 },{ 0xd, 4 },{ 0x15, 5 },{ 0x28, 6 },
-{ 0x30, 6 },{ 0x32, 6 },{ 0x52, 7 },{ 0x62, 7 },
-{ 0x66, 7 },{ 0xa6, 8 },{ 0xc6, 8 },{ 0xcf, 8 },
-{ 0x14f, 9 },{ 0x18e, 9 },{ 0x19c, 9 },{ 0x29d, 10 },
-{ 0x33a, 10 },{ 0x538, 11 },{ 0x63c, 11 },{ 0x63e, 11 },
-{ 0x63f, 11 },{ 0x676, 11 },{ 0xa73, 12 },{ 0xc7a, 12 },
-{ 0xcef, 12 },{ 0x14e5, 13 },{ 0x19dd, 13 },{ 0x29c8, 14 },
-{ 0x29c9, 14 },{ 0x63dd, 15 },{ 0x33b8, 14 },{ 0x33b9, 14 },
-{ 0xc7b6, 16 },{ 0x63d8, 15 },{ 0x63df, 15 },{ 0xc7b3, 16 },
-{ 0xc7b4, 16 },{ 0xc7b5, 16 },{ 0x63de, 15 },{ 0xc7b7, 16 },
-{ 0xc7b8, 16 },{ 0xc7b9, 16 },{ 0x18f65, 17 },{ 0x31ec8, 18 },
-{ 0xc7b248, 24 },{ 0xc7b249, 24 },{ 0xc7b24a, 24 },{ 0xc7b24b, 24 },
-{ 0xc7b24c, 24 },{ 0xc7b24d, 24 },{ 0xc7b24e, 24 },{ 0xc7b24f, 24 },
-{ 0xc7b250, 24 },{ 0xc7b251, 24 },{ 0xc7b252, 24 },{ 0xc7b253, 24 },
-{ 0xc7b254, 24 },{ 0xc7b255, 24 },{ 0xc7b256, 24 },{ 0xc7b257, 24 },
-{ 0xc7b258, 24 },{ 0xc7b259, 24 },{ 0xc7b25a, 24 },{ 0xc7b25b, 24 },
-{ 0xc7b25c, 24 },{ 0xc7b25d, 24 },{ 0xc7b25e, 24 },{ 0xc7b25f, 24 },
-{ 0xc7b260, 24 },{ 0xc7b261, 24 },{ 0xc7b262, 24 },{ 0xc7b263, 24 },
-{ 0xc7b264, 24 },{ 0xc7b265, 24 },{ 0xc7b266, 24 },{ 0xc7b267, 24 },
-{ 0xc7b268, 24 },{ 0xc7b269, 24 },{ 0xc7b26a, 24 },{ 0xc7b26b, 24 },
-{ 0xc7b26c, 24 },{ 0xc7b26d, 24 },{ 0xc7b26e, 24 },{ 0xc7b26f, 24 },
-{ 0xc7b270, 24 },{ 0xc7b271, 24 },{ 0xc7b272, 24 },{ 0xc7b273, 24 },
-{ 0xc7b274, 24 },{ 0xc7b275, 24 },{ 0xc7b276, 24 },{ 0xc7b277, 24 },
-{ 0xc7b278, 24 },{ 0xc7b279, 24 },{ 0xc7b27a, 24 },{ 0xc7b27b, 24 },
-{ 0xc7b27c, 24 },{ 0xc7b27d, 24 },{ 0xc7b27e, 24 },{ 0xc7b27f, 24 },
-{ 0x18f6480, 25 },{ 0x18f6481, 25 },{ 0x18f6482, 25 },{ 0x18f6483, 25 },
-{ 0x18f6484, 25 },{ 0x18f6485, 25 },{ 0x18f6486, 25 },{ 0x18f6487, 25 },
-{ 0x18f6488, 25 },{ 0x18f6489, 25 },{ 0x18f648a, 25 },{ 0x18f648b, 25 },
-{ 0x18f648c, 25 },{ 0x18f648d, 25 },{ 0x18f648e, 25 },{ 0x18f648f, 25 },
-};
-
-/* vlc table 0, for intra luma */
-
-static const uint16_t table0_vlc[133][2] = {
-{ 0x1, 2 },{ 0x6, 3 },{ 0xf, 4 },{ 0x16, 5 },
-{ 0x20, 6 },{ 0x18, 7 },{ 0x8, 8 },{ 0x9a, 8 },
-{ 0x56, 9 },{ 0x13e, 9 },{ 0xf0, 10 },{ 0x3a5, 10 },
-{ 0x77, 11 },{ 0x1ef, 11 },{ 0x9a, 12 },{ 0x5d, 13 },
-{ 0x1, 4 },{ 0x11, 5 },{ 0x2, 7 },{ 0xb, 8 },
-{ 0x12, 9 },{ 0x1d6, 9 },{ 0x27e, 10 },{ 0x191, 11 },
-{ 0xea, 12 },{ 0x3dc, 12 },{ 0x13b, 13 },{ 0x4, 5 },
-{ 0x14, 7 },{ 0x9e, 8 },{ 0x9, 10 },{ 0x1ac, 11 },
-{ 0x1e2, 11 },{ 0x3ca, 12 },{ 0x5f, 13 },{ 0x17, 5 },
-{ 0x4e, 7 },{ 0x5e, 9 },{ 0xf3, 10 },{ 0x1ad, 11 },
-{ 0xec, 12 },{ 0x5f0, 13 },{ 0xe, 6 },{ 0xe1, 8 },
-{ 0x3a4, 10 },{ 0x9c, 12 },{ 0x13d, 13 },{ 0x3b, 6 },
-{ 0x1c, 9 },{ 0x14, 11 },{ 0x9be, 12 },{ 0x6, 7 },
-{ 0x7a, 9 },{ 0x190, 11 },{ 0x137, 13 },{ 0x1b, 7 },
-{ 0x8, 10 },{ 0x75c, 11 },{ 0x71, 7 },{ 0xd7, 10 },
-{ 0x9bf, 12 },{ 0x7, 8 },{ 0xaf, 10 },{ 0x4cc, 11 },
-{ 0x34, 8 },{ 0x265, 10 },{ 0x9f, 12 },{ 0xe0, 8 },
-{ 0x16, 11 },{ 0x327, 12 },{ 0x15, 9 },{ 0x17d, 11 },
-{ 0xebb, 12 },{ 0x14, 9 },{ 0xf6, 10 },{ 0x1e4, 11 },
-{ 0xcb, 10 },{ 0x99d, 12 },{ 0xca, 10 },{ 0x2fc, 12 },
-{ 0x17f, 11 },{ 0x4cd, 11 },{ 0x2fd, 12 },{ 0x4fe, 11 },
-{ 0x13a, 13 },{ 0xa, 4 },{ 0x42, 7 },{ 0x1d3, 9 },
-{ 0x4dd, 11 },{ 0x12, 5 },{ 0xe8, 8 },{ 0x4c, 11 },
-{ 0x136, 13 },{ 0x39, 6 },{ 0x264, 10 },{ 0xeba, 12 },
-{ 0x0, 7 },{ 0xae, 10 },{ 0x99c, 12 },{ 0x1f, 7 },
-{ 0x4de, 11 },{ 0x43, 7 },{ 0x4dc, 11 },{ 0x3, 8 },
-{ 0x3cb, 12 },{ 0x6, 8 },{ 0x99e, 12 },{ 0x2a, 8 },
-{ 0x5f1, 13 },{ 0xf, 8 },{ 0x9fe, 12 },{ 0x33, 8 },
-{ 0x9ff, 12 },{ 0x98, 8 },{ 0x99f, 12 },{ 0xea, 8 },
-{ 0x13c, 13 },{ 0x2e, 8 },{ 0x192, 11 },{ 0x136, 9 },
-{ 0x6a, 9 },{ 0x15, 11 },{ 0x3af, 10 },{ 0x1e3, 11 },
-{ 0x74, 11 },{ 0xeb, 12 },{ 0x2f9, 12 },{ 0x5c, 13 },
-{ 0xed, 12 },{ 0x3dd, 12 },{ 0x326, 12 },{ 0x5e, 13 },
-{ 0x16, 7 },
-};
-
-static const int8_t table0_level[132] = {
- 1, 2, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16,
- 1, 2, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 1, 2, 3, 4, 5,
- 6, 7, 8, 1, 2, 3, 4, 5,
- 6, 7, 1, 2, 3, 4, 5, 1,
- 2, 3, 4, 1, 2, 3, 4, 1,
- 2, 3, 1, 2, 3, 1, 2, 3,
- 1, 2, 3, 1, 2, 3, 1, 2,
- 3, 1, 2, 3, 1, 2, 1, 2,
- 1, 1, 1, 1, 1, 1, 2, 3,
- 4, 1, 2, 3, 4, 1, 2, 3,
- 1, 2, 3, 1, 2, 1, 2, 1,
- 2, 1, 2, 1, 2, 1, 2, 1,
- 2, 1, 2, 1, 2, 1, 2, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1,
-};
-
-static const int8_t table0_run[132] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 2, 2, 2, 2, 2,
- 2, 2, 2, 3, 3, 3, 3, 3,
- 3, 3, 4, 4, 4, 4, 4, 5,
- 5, 5, 5, 6, 6, 6, 6, 7,
- 7, 7, 8, 8, 8, 9, 9, 9,
- 10, 10, 10, 11, 11, 11, 12, 12,
- 12, 13, 13, 13, 14, 14, 15, 15,
- 16, 17, 18, 19, 20, 0, 0, 0,
- 0, 1, 1, 1, 1, 2, 2, 2,
- 3, 3, 3, 4, 4, 5, 5, 6,
- 6, 7, 7, 8, 8, 9, 9, 10,
- 10, 11, 11, 12, 12, 13, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22,
- 23, 24, 25, 26,
-};
-
-/* vlc table 1, for intra chroma and P macroblocks */
-
-static const uint16_t table1_vlc[149][2] = {
-{ 0x4, 3 },{ 0x14, 5 },{ 0x17, 7 },{ 0x7f, 8 },
-{ 0x154, 9 },{ 0x1f2, 10 },{ 0xbf, 11 },{ 0x65, 12 },
-{ 0xaaa, 12 },{ 0x630, 13 },{ 0x1597, 13 },{ 0x3b7, 14 },
-{ 0x2b22, 14 },{ 0xbe6, 15 },{ 0xb, 4 },{ 0x37, 7 },
-{ 0x62, 9 },{ 0x7, 11 },{ 0x166, 12 },{ 0xce, 13 },
-{ 0x1590, 13 },{ 0x5f6, 14 },{ 0xbe7, 15 },{ 0x7, 5 },
-{ 0x6d, 8 },{ 0x3, 11 },{ 0x31f, 12 },{ 0x5f2, 14 },
-{ 0x2, 6 },{ 0x61, 9 },{ 0x55, 12 },{ 0x1df, 14 },
-{ 0x1a, 6 },{ 0x1e, 10 },{ 0xac9, 12 },{ 0x2b23, 14 },
-{ 0x1e, 6 },{ 0x1f, 10 },{ 0xac3, 12 },{ 0x2b2b, 14 },
-{ 0x6, 7 },{ 0x4, 11 },{ 0x2f8, 13 },{ 0x19, 7 },
-{ 0x6, 11 },{ 0x63d, 13 },{ 0x57, 7 },{ 0x182, 11 },
-{ 0x2aa2, 14 },{ 0x4, 8 },{ 0x180, 11 },{ 0x59c, 14 },
-{ 0x7d, 8 },{ 0x164, 12 },{ 0x76d, 15 },{ 0x2, 9 },
-{ 0x18d, 11 },{ 0x1581, 13 },{ 0xad, 8 },{ 0x60, 12 },
-{ 0xc67, 14 },{ 0x1c, 9 },{ 0xee, 13 },{ 0x3, 9 },
-{ 0x2cf, 13 },{ 0xd9, 9 },{ 0x1580, 13 },{ 0x2, 11 },
-{ 0x183, 11 },{ 0x57, 12 },{ 0x61, 12 },{ 0x31, 11 },
-{ 0x66, 12 },{ 0x631, 13 },{ 0x632, 13 },{ 0xac, 13 },
-{ 0x31d, 12 },{ 0x76, 12 },{ 0x3a, 11 },{ 0x165, 12 },
-{ 0xc66, 14 },{ 0x3, 2 },{ 0x54, 7 },{ 0x2ab, 10 },
-{ 0x16, 13 },{ 0x5f7, 14 },{ 0x5, 4 },{ 0xf8, 9 },
-{ 0xaa9, 12 },{ 0x5f, 15 },{ 0x4, 4 },{ 0x1c, 10 },
-{ 0x1550, 13 },{ 0x4, 5 },{ 0x77, 11 },{ 0x76c, 15 },
-{ 0xe, 5 },{ 0xa, 12 },{ 0xc, 5 },{ 0x562, 11 },
-{ 0x4, 6 },{ 0x31c, 12 },{ 0x6, 6 },{ 0xc8, 13 },
-{ 0xd, 6 },{ 0x1da, 13 },{ 0x7, 6 },{ 0xc9, 13 },
-{ 0x1, 7 },{ 0x2e, 14 },{ 0x14, 7 },{ 0x1596, 13 },
-{ 0xa, 7 },{ 0xac2, 12 },{ 0x16, 7 },{ 0x15b, 14 },
-{ 0x15, 7 },{ 0x15a, 14 },{ 0xf, 8 },{ 0x5e, 15 },
-{ 0x7e, 8 },{ 0xab, 8 },{ 0x2d, 9 },{ 0xd8, 9 },
-{ 0xb, 9 },{ 0x14, 10 },{ 0x2b3, 10 },{ 0x1f3, 10 },
-{ 0x3a, 10 },{ 0x0, 10 },{ 0x58, 10 },{ 0x2e, 9 },
-{ 0x5e, 10 },{ 0x563, 11 },{ 0xec, 12 },{ 0x54, 12 },
-{ 0xac1, 12 },{ 0x1556, 13 },{ 0x2fa, 13 },{ 0x181, 11 },
-{ 0x1557, 13 },{ 0x59d, 14 },{ 0x2aa3, 14 },{ 0x2b2a, 14 },
-{ 0x1de, 14 },{ 0x63c, 13 },{ 0xcf, 13 },{ 0x1594, 13 },
-{ 0xd, 9 },
-};
-
-static const int8_t table1_level[148] = {
- 1, 2, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 1, 2,
- 3, 4, 5, 6, 7, 8, 9, 1,
- 2, 3, 4, 5, 1, 2, 3, 4,
- 1, 2, 3, 4, 1, 2, 3, 4,
- 1, 2, 3, 1, 2, 3, 1, 2,
- 3, 1, 2, 3, 1, 2, 3, 1,
- 2, 3, 1, 2, 3, 1, 2, 1,
- 2, 1, 2, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 2, 3, 4, 5, 1, 2,
- 3, 4, 1, 2, 3, 1, 2, 3,
- 1, 2, 1, 2, 1, 2, 1, 2,
- 1, 2, 1, 2, 1, 2, 1, 2,
- 1, 2, 1, 2, 1, 2, 1, 2,
- 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,
-};
-
-static const int8_t table1_run[148] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 2,
- 2, 2, 2, 2, 3, 3, 3, 3,
- 4, 4, 4, 4, 5, 5, 5, 5,
- 6, 6, 6, 7, 7, 7, 8, 8,
- 8, 9, 9, 9, 10, 10, 10, 11,
- 11, 11, 12, 12, 12, 13, 13, 14,
- 14, 15, 15, 16, 17, 18, 19, 20,
- 21, 22, 23, 24, 25, 26, 27, 28,
- 29, 0, 0, 0, 0, 0, 1, 1,
- 1, 1, 2, 2, 2, 3, 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, 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,
-};
-
-/* third vlc table */
-
-static const uint16_t table2_vlc[186][2] = {
-{ 0x1, 2 },{ 0x5, 3 },{ 0xd, 4 },{ 0x12, 5 },
-{ 0xe, 6 },{ 0x15, 7 },{ 0x13, 8 },{ 0x3f, 8 },
-{ 0x4b, 9 },{ 0x11f, 9 },{ 0xb8, 10 },{ 0x3e3, 10 },
-{ 0x172, 11 },{ 0x24d, 12 },{ 0x3da, 12 },{ 0x2dd, 13 },
-{ 0x1f55, 13 },{ 0x5b9, 14 },{ 0x3eae, 14 },{ 0x0, 4 },
-{ 0x10, 5 },{ 0x8, 7 },{ 0x20, 8 },{ 0x29, 9 },
-{ 0x1f4, 9 },{ 0x233, 10 },{ 0x1e0, 11 },{ 0x12a, 12 },
-{ 0x3dd, 12 },{ 0x50a, 13 },{ 0x1f29, 13 },{ 0xa42, 14 },
-{ 0x1272, 15 },{ 0x1737, 15 },{ 0x3, 5 },{ 0x11, 7 },
-{ 0xc4, 8 },{ 0x4b, 10 },{ 0xb4, 11 },{ 0x7d4, 11 },
-{ 0x345, 12 },{ 0x2d7, 13 },{ 0x7bf, 13 },{ 0x938, 14 },
-{ 0xbbb, 14 },{ 0x95e, 15 },{ 0x13, 5 },{ 0x78, 7 },
-{ 0x69, 9 },{ 0x232, 10 },{ 0x461, 11 },{ 0x3ec, 12 },
-{ 0x520, 13 },{ 0x1f2a, 13 },{ 0x3e50, 14 },{ 0x3e51, 14 },
-{ 0x1486, 15 },{ 0xc, 6 },{ 0x24, 9 },{ 0x94, 11 },
-{ 0x8c0, 12 },{ 0xf09, 14 },{ 0x1ef0, 15 },{ 0x3d, 6 },
-{ 0x53, 9 },{ 0x1a0, 11 },{ 0x2d6, 13 },{ 0xf08, 14 },
-{ 0x13, 7 },{ 0x7c, 9 },{ 0x7c1, 11 },{ 0x4ac, 14 },
-{ 0x1b, 7 },{ 0xa0, 10 },{ 0x344, 12 },{ 0xf79, 14 },
-{ 0x79, 7 },{ 0x3e1, 10 },{ 0x2d4, 13 },{ 0x2306, 14 },
-{ 0x21, 8 },{ 0x23c, 10 },{ 0xfae, 12 },{ 0x23de, 14 },
-{ 0x35, 8 },{ 0x175, 11 },{ 0x7b3, 13 },{ 0xc5, 8 },
-{ 0x174, 11 },{ 0x785, 13 },{ 0x48, 9 },{ 0x1a3, 11 },
-{ 0x49e, 13 },{ 0x2c, 9 },{ 0xfa, 10 },{ 0x7d6, 11 },
-{ 0x92, 10 },{ 0x5cc, 13 },{ 0x1ef1, 15 },{ 0xa3, 10 },
-{ 0x3ed, 12 },{ 0x93e, 14 },{ 0x1e2, 11 },{ 0x1273, 15 },
-{ 0x7c4, 11 },{ 0x1487, 15 },{ 0x291, 12 },{ 0x293, 12 },
-{ 0xf8a, 12 },{ 0x509, 13 },{ 0x508, 13 },{ 0x78d, 13 },
-{ 0x7be, 13 },{ 0x78c, 13 },{ 0x4ae, 14 },{ 0xbba, 14 },
-{ 0x2307, 14 },{ 0xb9a, 14 },{ 0x1736, 15 },{ 0xe, 4 },
-{ 0x45, 7 },{ 0x1f3, 9 },{ 0x47a, 11 },{ 0x5dc, 13 },
-{ 0x23df, 14 },{ 0x19, 5 },{ 0x28, 9 },{ 0x176, 11 },
-{ 0x49d, 13 },{ 0x23dd, 14 },{ 0x30, 6 },{ 0xa2, 10 },
-{ 0x2ef, 12 },{ 0x5b8, 14 },{ 0x3f, 6 },{ 0xa5, 10 },
-{ 0x3db, 12 },{ 0x93f, 14 },{ 0x44, 7 },{ 0x7cb, 11 },
-{ 0x95f, 15 },{ 0x63, 7 },{ 0x3c3, 12 },{ 0x15, 8 },
-{ 0x8f6, 12 },{ 0x17, 8 },{ 0x498, 13 },{ 0x2c, 8 },
-{ 0x7b2, 13 },{ 0x2f, 8 },{ 0x1f54, 13 },{ 0x8d, 8 },
-{ 0x7bd, 13 },{ 0x8e, 8 },{ 0x1182, 13 },{ 0xfb, 8 },
-{ 0x50b, 13 },{ 0x2d, 8 },{ 0x7c0, 11 },{ 0x79, 9 },
-{ 0x1f5f, 13 },{ 0x7a, 9 },{ 0x1f56, 13 },{ 0x231, 10 },
-{ 0x3e4, 10 },{ 0x1a1, 11 },{ 0x143, 11 },{ 0x1f7, 11 },
-{ 0x16f, 12 },{ 0x292, 12 },{ 0x2e7, 12 },{ 0x16c, 12 },
-{ 0x16d, 12 },{ 0x3dc, 12 },{ 0xf8b, 12 },{ 0x499, 13 },
-{ 0x3d8, 12 },{ 0x78e, 13 },{ 0x2d5, 13 },{ 0x1f5e, 13 },
-{ 0x1f2b, 13 },{ 0x78f, 13 },{ 0x4ad, 14 },{ 0x3eaf, 14 },
-{ 0x23dc, 14 },{ 0x4a, 9 },
-};
-
-static const int8_t table2_level[185] = {
- 1, 2, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 19, 1, 2, 3, 4, 5,
- 6, 7, 8, 9, 10, 11, 12, 13,
- 14, 15, 1, 2, 3, 4, 5, 6,
- 7, 8, 9, 10, 11, 12, 1, 2,
- 3, 4, 5, 6, 7, 8, 9, 10,
- 11, 1, 2, 3, 4, 5, 6, 1,
- 2, 3, 4, 5, 1, 2, 3, 4,
- 1, 2, 3, 4, 1, 2, 3, 4,
- 1, 2, 3, 4, 1, 2, 3, 1,
- 2, 3, 1, 2, 3, 1, 2, 3,
- 1, 2, 3, 1, 2, 3, 1, 2,
- 1, 2, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 3, 4, 5, 6, 1, 2, 3,
- 4, 5, 1, 2, 3, 4, 1, 2,
- 3, 4, 1, 2, 3, 1, 2, 1,
- 2, 1, 2, 1, 2, 1, 2, 1,
- 2, 1, 2, 1, 2, 1, 2, 1,
- 2, 1, 2, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1,
-};
-
-static const int8_t table2_run[185] = {
- 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, 1, 1, 1, 1, 1,
- 1, 1, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 4, 4, 4, 4, 4, 4, 5,
- 5, 5, 5, 5, 6, 6, 6, 6,
- 7, 7, 7, 7, 8, 8, 8, 8,
- 9, 9, 9, 9, 10, 10, 10, 11,
- 11, 11, 12, 12, 12, 13, 13, 13,
- 14, 14, 14, 15, 15, 15, 16, 16,
- 17, 17, 18, 19, 20, 21, 22, 23,
- 24, 25, 26, 27, 28, 29, 30, 0,
- 0, 0, 0, 0, 0, 1, 1, 1,
- 1, 1, 2, 2, 2, 2, 3, 3,
- 3, 3, 4, 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, 17, 18, 19, 20,
- 21, 22, 23, 24, 25, 26, 27, 28,
- 29, 30, 31, 32, 33, 34, 35, 36,
- 37,
-};
-
-/* second non intra vlc table */
-static const uint16_t table4_vlc[169][2] = {
-{ 0x0, 3 },{ 0x3, 4 },{ 0xb, 5 },{ 0x14, 6 },
-{ 0x3f, 6 },{ 0x5d, 7 },{ 0xa2, 8 },{ 0xac, 9 },
-{ 0x16e, 9 },{ 0x20a, 10 },{ 0x2e2, 10 },{ 0x432, 11 },
-{ 0x5c9, 11 },{ 0x827, 12 },{ 0xb54, 12 },{ 0x4e6, 13 },
-{ 0x105f, 13 },{ 0x172a, 13 },{ 0x20b2, 14 },{ 0x2d4e, 14 },
-{ 0x39f0, 14 },{ 0x4175, 15 },{ 0x5a9e, 15 },{ 0x4, 4 },
-{ 0x1e, 5 },{ 0x42, 7 },{ 0xb6, 8 },{ 0x173, 9 },
-{ 0x395, 10 },{ 0x72e, 11 },{ 0xb94, 12 },{ 0x16a4, 13 },
-{ 0x20b3, 14 },{ 0x2e45, 14 },{ 0x5, 5 },{ 0x40, 7 },
-{ 0x49, 9 },{ 0x28f, 10 },{ 0x5cb, 11 },{ 0x48a, 13 },
-{ 0x9dd, 14 },{ 0x73e2, 15 },{ 0x18, 5 },{ 0x25, 8 },
-{ 0x8a, 10 },{ 0x51b, 11 },{ 0xe5f, 12 },{ 0x9c9, 14 },
-{ 0x139c, 15 },{ 0x29, 6 },{ 0x4f, 9 },{ 0x412, 11 },
-{ 0x48d, 13 },{ 0x2e41, 14 },{ 0x38, 6 },{ 0x10e, 9 },
-{ 0x5a8, 11 },{ 0x105c, 13 },{ 0x39f2, 14 },{ 0x58, 7 },
-{ 0x21f, 10 },{ 0xe7e, 12 },{ 0x39ff, 14 },{ 0x23, 8 },
-{ 0x2e3, 10 },{ 0x4e5, 13 },{ 0x2e40, 14 },{ 0xa1, 8 },
-{ 0x5be, 11 },{ 0x9c8, 14 },{ 0x83, 8 },{ 0x13a, 11 },
-{ 0x1721, 13 },{ 0x44, 9 },{ 0x276, 12 },{ 0x39f6, 14 },
-{ 0x8b, 10 },{ 0x4ef, 13 },{ 0x5a9b, 15 },{ 0x208, 10 },
-{ 0x1cfe, 13 },{ 0x399, 10 },{ 0x1cb4, 13 },{ 0x39e, 10 },
-{ 0x39f3, 14 },{ 0x5ab, 11 },{ 0x73e3, 15 },{ 0x737, 11 },
-{ 0x5a9f, 15 },{ 0x82d, 12 },{ 0xe69, 12 },{ 0xe68, 12 },
-{ 0x433, 11 },{ 0xb7b, 12 },{ 0x2df8, 14 },{ 0x2e56, 14 },
-{ 0x2e57, 14 },{ 0x39f7, 14 },{ 0x51a5, 15 },{ 0x3, 3 },
-{ 0x2a, 6 },{ 0xe4, 8 },{ 0x28e, 10 },{ 0x735, 11 },
-{ 0x1058, 13 },{ 0x1cfa, 13 },{ 0x2df9, 14 },{ 0x4174, 15 },
-{ 0x9, 4 },{ 0x54, 8 },{ 0x398, 10 },{ 0x48b, 13 },
-{ 0x139d, 15 },{ 0xd, 4 },{ 0xad, 9 },{ 0x826, 12 },
-{ 0x2d4c, 14 },{ 0x11, 5 },{ 0x16b, 9 },{ 0xb7f, 12 },
-{ 0x51a4, 15 },{ 0x19, 5 },{ 0x21b, 10 },{ 0x16fd, 13 },
-{ 0x1d, 5 },{ 0x394, 10 },{ 0x28d3, 14 },{ 0x2b, 6 },
-{ 0x5bc, 11 },{ 0x5a9a, 15 },{ 0x2f, 6 },{ 0x247, 12 },
-{ 0x10, 7 },{ 0xa35, 12 },{ 0x3e, 6 },{ 0xb7a, 12 },
-{ 0x59, 7 },{ 0x105e, 13 },{ 0x26, 8 },{ 0x9cf, 14 },
-{ 0x55, 8 },{ 0x1cb5, 13 },{ 0x57, 8 },{ 0xe5b, 12 },
-{ 0xa0, 8 },{ 0x1468, 13 },{ 0x170, 9 },{ 0x90, 10 },
-{ 0x1ce, 9 },{ 0x21a, 10 },{ 0x218, 10 },{ 0x168, 9 },
-{ 0x21e, 10 },{ 0x244, 12 },{ 0x736, 11 },{ 0x138, 11 },
-{ 0x519, 11 },{ 0xe5e, 12 },{ 0x72c, 11 },{ 0xb55, 12 },
-{ 0x9dc, 14 },{ 0x20bb, 14 },{ 0x48c, 13 },{ 0x1723, 13 },
-{ 0x2e44, 14 },{ 0x16a5, 13 },{ 0x518, 11 },{ 0x39fe, 14 },
-{ 0x169, 9 },
-};
-
-static const int8_t table4_level[168] = {
- 1, 2, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 23, 1,
- 2, 3, 4, 5, 6, 7, 8, 9,
- 10, 11, 1, 2, 3, 4, 5, 6,
- 7, 8, 1, 2, 3, 4, 5, 6,
- 7, 1, 2, 3, 4, 5, 1, 2,
- 3, 4, 5, 1, 2, 3, 4, 1,
- 2, 3, 4, 1, 2, 3, 1, 2,
- 3, 1, 2, 3, 1, 2, 3, 1,
- 2, 1, 2, 1, 2, 1, 2, 1,
- 2, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 2, 3, 4, 5,
- 6, 7, 8, 9, 1, 2, 3, 4,
- 5, 1, 2, 3, 4, 1, 2, 3,
- 4, 1, 2, 3, 1, 2, 3, 1,
- 2, 3, 1, 2, 1, 2, 1, 2,
- 1, 2, 1, 2, 1, 2, 1, 2,
- 1, 2, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1,
-};
-
-static const int8_t table4_run[168] = {
- 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, 1,
- 1, 1, 2, 2, 2, 2, 2, 2,
- 2, 2, 3, 3, 3, 3, 3, 3,
- 3, 4, 4, 4, 4, 4, 5, 5,
- 5, 5, 5, 6, 6, 6, 6, 7,
- 7, 7, 7, 8, 8, 8, 9, 9,
- 9, 10, 10, 10, 11, 11, 11, 12,
- 12, 13, 13, 14, 14, 15, 15, 16,
- 16, 17, 18, 19, 20, 21, 22, 23,
- 24, 25, 26, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 1, 1, 1, 1,
- 1, 2, 2, 2, 2, 3, 3, 3,
- 3, 4, 4, 4, 5, 5, 5, 6,
- 6, 6, 7, 7, 8, 8, 9, 9,
- 10, 10, 11, 11, 12, 12, 13, 13,
- 14, 14, 15, 16, 17, 18, 19, 20,
- 21, 22, 23, 24, 25, 26, 27, 28,
- 29, 30, 31, 32, 33, 34, 35, 36,
-};
-
-extern const uint16_t ff_inter_vlc[103][2];
-extern const int8_t ff_inter_level[102];
-extern const int8_t ff_inter_run[102];
-
-extern const uint16_t ff_mpeg4_intra_vlc[103][2];
-extern const int8_t ff_mpeg4_intra_level[102];
-extern const int8_t ff_mpeg4_intra_run[102];
-
-RLTable ff_rl_table[NB_RL_TABLES] = {
- /* intra luminance tables */
- /* low motion */
- {
- 132,
- 85,
- table0_vlc,
- table0_run,
- table0_level,
- },
- /* high motion */
- {
- 185,
- 119,
- table2_vlc,
- table2_run,
- table2_level,
- },
- /* mid-rate */
- {
- 102,
- 67,
- ff_mpeg4_intra_vlc,
- ff_mpeg4_intra_run,
- ff_mpeg4_intra_level,
- },
- /* intra chrominance / non intra tables */
- /* low motion inter */
- {
- 148,
- 81,
- table1_vlc,
- table1_run,
- table1_level,
- },
- /* high motion inter */
- {
- 168,
- 99,
- table4_vlc,
- table4_run,
- table4_level,
- },
- /* mid rate inter */
- {
- 102,
- 58,
- ff_inter_vlc,
- ff_inter_run,
- ff_inter_level,
- },
-};
-
-/* motion vector table 0 */
-
-static const uint16_t table0_mv_code[1100] = {
- 0x0001, 0x0003, 0x0005, 0x0007, 0x0003, 0x0008, 0x000c, 0x0001,
- 0x0002, 0x001b, 0x0006, 0x000b, 0x0015, 0x0002, 0x000e, 0x000f,
- 0x0014, 0x0020, 0x0022, 0x0025, 0x0027, 0x0029, 0x002d, 0x004b,
- 0x004d, 0x0003, 0x0022, 0x0023, 0x0025, 0x0027, 0x0042, 0x0048,
- 0x0049, 0x0050, 0x005c, 0x0091, 0x009f, 0x000e, 0x0043, 0x004c,
- 0x0054, 0x0056, 0x008c, 0x0098, 0x009a, 0x009b, 0x00b1, 0x00b2,
- 0x0120, 0x0121, 0x0126, 0x0133, 0x0139, 0x01a1, 0x01a4, 0x01a5,
- 0x01a6, 0x01a7, 0x01ae, 0x01af, 0x000b, 0x0019, 0x0085, 0x0090,
- 0x009b, 0x00aa, 0x00af, 0x010c, 0x010e, 0x011c, 0x011e, 0x0133,
- 0x0144, 0x0160, 0x0174, 0x0175, 0x0177, 0x0178, 0x0249, 0x024b,
- 0x0252, 0x0261, 0x0265, 0x0270, 0x0352, 0x0353, 0x0355, 0x0359,
- 0x0010, 0x0011, 0x0013, 0x0034, 0x0035, 0x0036, 0x0037, 0x003d,
- 0x003e, 0x0109, 0x0126, 0x0156, 0x021a, 0x021e, 0x023a, 0x023e,
- 0x028e, 0x028f, 0x02cf, 0x0491, 0x0494, 0x049f, 0x04a0, 0x04a3,
- 0x04a6, 0x04a7, 0x04ad, 0x04ae, 0x04c0, 0x04c4, 0x04c6, 0x04c8,
- 0x04c9, 0x04f5, 0x04f6, 0x04f7, 0x0680, 0x0682, 0x0683, 0x0688,
- 0x0689, 0x068d, 0x068e, 0x068f, 0x06a2, 0x06a3, 0x06a9, 0x06b0,
- 0x06b1, 0x06b4, 0x06b5, 0x0024, 0x0060, 0x0063, 0x0078, 0x0079,
- 0x0211, 0x0244, 0x0245, 0x0247, 0x0248, 0x0249, 0x024a, 0x024b,
- 0x026b, 0x02af, 0x02b8, 0x02bb, 0x0436, 0x0476, 0x0477, 0x047e,
- 0x04c8, 0x04c9, 0x04ca, 0x0514, 0x0586, 0x0587, 0x0598, 0x059d,
- 0x05d9, 0x05da, 0x0920, 0x0921, 0x093b, 0x093c, 0x093d, 0x0942,
- 0x0943, 0x0944, 0x0945, 0x0959, 0x095e, 0x095f, 0x0982, 0x0983,
- 0x098e, 0x098f, 0x09c4, 0x09e7, 0x09e8, 0x09e9, 0x0d02, 0x0d17,
- 0x0d18, 0x0d19, 0x0d41, 0x0d42, 0x0d43, 0x0d50, 0x0d5f, 0x0d6d,
- 0x0d6e, 0x0d6f, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
- 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x041e, 0x041f, 0x0420, 0x0421,
- 0x048c, 0x048d, 0x04d3, 0x04d4, 0x04d5, 0x055c, 0x055d, 0x0572,
- 0x0573, 0x0574, 0x0575, 0x08de, 0x08df, 0x08fe, 0x08ff, 0x0996,
- 0x0a36, 0x0a37, 0x0b08, 0x0b09, 0x0b0a, 0x0b0b, 0x0b32, 0x0b33,
- 0x0b34, 0x0b35, 0x0b36, 0x0b37, 0x0b38, 0x0b39, 0x0bb0, 0x0bf7,
- 0x0bf8, 0x0bf9, 0x0bfa, 0x0bfb, 0x0bfc, 0x0bfd, 0x0bfe, 0x0bff,
- 0x1254, 0x1255, 0x1256, 0x1257, 0x1270, 0x1271, 0x1272, 0x1273,
- 0x1274, 0x1275, 0x12ab, 0x12ac, 0x12ad, 0x12ae, 0x12af, 0x12b0,
- 0x12b1, 0x1315, 0x1316, 0x1317, 0x13bf, 0x13c0, 0x13c1, 0x13c2,
- 0x13c3, 0x13c4, 0x13c5, 0x13c6, 0x13c7, 0x13c8, 0x13c9, 0x13ca,
- 0x13cb, 0x13cc, 0x13cd, 0x1a06, 0x1a07, 0x1a28, 0x1a29, 0x1a2a,
- 0x1a2b, 0x1a2c, 0x1a2d, 0x1a80, 0x1abb, 0x1abc, 0x1abd, 0x1ad8,
- 0x1ad9, 0x0094, 0x0095, 0x0096, 0x0097, 0x00a0, 0x00a1, 0x00a2,
- 0x00a3, 0x0831, 0x0832, 0x0833, 0x0834, 0x0835, 0x0836, 0x0837,
- 0x0838, 0x0839, 0x083a, 0x083b, 0x0939, 0x093a, 0x093b, 0x093c,
- 0x093d, 0x093e, 0x093f, 0x09a0, 0x09a1, 0x09a2, 0x09a3, 0x09a4,
- 0x09a5, 0x11ac, 0x11ad, 0x11ae, 0x11af, 0x11b0, 0x11b1, 0x11b2,
- 0x11b3, 0x11b4, 0x11b5, 0x11b6, 0x11b7, 0x11b8, 0x11b9, 0x11ba,
- 0x11bb, 0x132f, 0x1454, 0x1455, 0x1456, 0x1457, 0x1458, 0x1459,
- 0x145a, 0x145b, 0x145c, 0x145d, 0x145e, 0x145f, 0x1460, 0x1461,
- 0x1462, 0x1463, 0x1464, 0x1465, 0x1466, 0x1467, 0x1468, 0x1469,
- 0x146a, 0x146b, 0x17de, 0x17df, 0x17e0, 0x17e1, 0x17e2, 0x17e3,
- 0x17e4, 0x17e5, 0x17e6, 0x17e7, 0x17e8, 0x17e9, 0x17ea, 0x17eb,
- 0x17ec, 0x17ed, 0x2540, 0x2541, 0x2542, 0x2543, 0x2544, 0x2545,
- 0x2546, 0x2547, 0x2548, 0x2549, 0x254a, 0x254b, 0x254c, 0x254d,
- 0x254e, 0x254f, 0x2550, 0x2551, 0x2552, 0x2553, 0x2554, 0x2555,
- 0x2628, 0x2766, 0x2767, 0x2768, 0x2769, 0x276a, 0x276b, 0x276c,
- 0x276d, 0x276e, 0x276f, 0x2770, 0x2771, 0x2772, 0x2773, 0x2774,
- 0x2775, 0x2776, 0x2777, 0x2778, 0x2779, 0x277a, 0x277b, 0x277c,
- 0x277d, 0x3503, 0x3544, 0x3545, 0x3546, 0x3547, 0x3560, 0x3561,
- 0x3562, 0x3563, 0x3564, 0x3565, 0x3566, 0x3567, 0x3568, 0x3569,
- 0x356a, 0x356b, 0x356c, 0x356d, 0x356e, 0x356f, 0x3570, 0x3571,
- 0x3572, 0x3573, 0x3574, 0x3575, 0x03f0, 0x103d, 0x103e, 0x103f,
- 0x1040, 0x1041, 0x1042, 0x1043, 0x1044, 0x1045, 0x1046, 0x1047,
- 0x1048, 0x1049, 0x104a, 0x104b, 0x104c, 0x104d, 0x104e, 0x104f,
- 0x1050, 0x1051, 0x1052, 0x1053, 0x1054, 0x1055, 0x1056, 0x1057,
- 0x1058, 0x1059, 0x105a, 0x105b, 0x105c, 0x105d, 0x105e, 0x105f,
- 0x1060, 0x1061, 0x1270, 0x1271, 0x21b8, 0x21b9, 0x21ba, 0x21bb,
- 0x21bc, 0x21bd, 0x21be, 0x21bf, 0x21f0, 0x21f1, 0x21f2, 0x21f3,
- 0x21f4, 0x21f5, 0x21f6, 0x21f7, 0x21f8, 0x21f9, 0x21fa, 0x21fb,
- 0x21fc, 0x21fd, 0x21fe, 0x21ff, 0x2340, 0x2341, 0x2342, 0x2343,
- 0x2344, 0x2345, 0x2346, 0x2347, 0x2348, 0x2349, 0x234a, 0x234b,
- 0x234c, 0x234d, 0x234e, 0x234f, 0x2350, 0x2351, 0x2352, 0x2353,
- 0x2354, 0x2355, 0x2356, 0x2357, 0x265c, 0x2f88, 0x2f89, 0x2f8a,
- 0x2f8b, 0x2f8c, 0x2f8d, 0x2f8e, 0x2f8f, 0x2f90, 0x2f91, 0x2f92,
- 0x2f93, 0x2f94, 0x2f95, 0x2f96, 0x2f97, 0x2f98, 0x2f99, 0x2f9a,
- 0x2f9b, 0x2f9c, 0x2f9d, 0x2f9e, 0x2f9f, 0x2fa0, 0x2fa1, 0x2fa2,
- 0x2fa3, 0x2fa4, 0x2fa5, 0x2fa6, 0x2fa7, 0x2fa8, 0x2fa9, 0x2faa,
- 0x2fab, 0x2fac, 0x2fad, 0x2fae, 0x2faf, 0x2fb0, 0x2fb1, 0x2fb2,
- 0x2fb3, 0x2fb4, 0x2fb5, 0x2fb6, 0x2fb7, 0x2fb8, 0x2fb9, 0x2fba,
- 0x2fbb, 0x4c52, 0x4c53, 0x4e28, 0x4e29, 0x4e2a, 0x4e2b, 0x4e2c,
- 0x4e2d, 0x4e2e, 0x4e2f, 0x4e30, 0x4e31, 0x4e32, 0x4e33, 0x4e34,
- 0x4e35, 0x4e36, 0x4e37, 0x4e38, 0x4e39, 0x4e3a, 0x4e3b, 0x4e3c,
- 0x4e3d, 0x4e3e, 0x4e3f, 0x4e80, 0x4e81, 0x4e82, 0x4e83, 0x4e84,
- 0x4e85, 0x4e86, 0x4e87, 0x4e88, 0x4e89, 0x4e8a, 0x4e8b, 0x4e8c,
- 0x4e8d, 0x4e8e, 0x4e8f, 0x4e90, 0x4e91, 0x4e92, 0x4e93, 0x4e94,
- 0x4e95, 0x4e96, 0x4e97, 0x4e98, 0x4e99, 0x4e9a, 0x4e9b, 0x4e9c,
- 0x4e9d, 0x4e9e, 0x4e9f, 0x4ea0, 0x4ea1, 0x4ea2, 0x4ea3, 0x4ea4,
- 0x4ea5, 0x4ea6, 0x4ea7, 0x4ea8, 0x4ea9, 0x4eaa, 0x4eab, 0x4eac,
- 0x4ead, 0x4eae, 0x4eaf, 0x4eb0, 0x4eb1, 0x4eb2, 0x4eb3, 0x4eb4,
- 0x4eb5, 0x4eb6, 0x4eb7, 0x4eb8, 0x4eb9, 0x4eba, 0x4ebb, 0x4ebc,
- 0x4ebd, 0x4ebe, 0x4ebf, 0x4ec0, 0x4ec1, 0x4ec2, 0x4ec3, 0x4ec4,
- 0x4ec5, 0x4ec6, 0x4ec7, 0x4ec8, 0x4ec9, 0x4eca, 0x4ecb, 0x6a04,
- 0x6a05, 0x07e2, 0x07e3, 0x07e4, 0x07e5, 0x07e6, 0x07e7, 0x07e8,
- 0x07e9, 0x07ea, 0x07eb, 0x07ec, 0x07ed, 0x07ee, 0x07ef, 0x07f0,
- 0x07f1, 0x07f2, 0x07f3, 0x07f4, 0x07f5, 0x07f6, 0x07f7, 0x07f8,
- 0x07f9, 0x07fa, 0x07fb, 0x07fc, 0x07fd, 0x07fe, 0x07ff, 0x2000,
- 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008,
- 0x2009, 0x200a, 0x200b, 0x200c, 0x200d, 0x200e, 0x200f, 0x2010,
- 0x2011, 0x2012, 0x2013, 0x2014, 0x2015, 0x2016, 0x2017, 0x2018,
- 0x2019, 0x201a, 0x201b, 0x201c, 0x201d, 0x201e, 0x201f, 0x2020,
- 0x2021, 0x2022, 0x2023, 0x2024, 0x2025, 0x2026, 0x2027, 0x2028,
- 0x2029, 0x202a, 0x202b, 0x202c, 0x202d, 0x202e, 0x202f, 0x2030,
- 0x2031, 0x2032, 0x2033, 0x2034, 0x2035, 0x2036, 0x2037, 0x2038,
- 0x2039, 0x203a, 0x203b, 0x203c, 0x203d, 0x203e, 0x203f, 0x2040,
- 0x2041, 0x2042, 0x2043, 0x2044, 0x2045, 0x2046, 0x2047, 0x2048,
- 0x2049, 0x204a, 0x204b, 0x204c, 0x204d, 0x204e, 0x204f, 0x2050,
- 0x2051, 0x2052, 0x2053, 0x2054, 0x2055, 0x2056, 0x2057, 0x2058,
- 0x2059, 0x205a, 0x205b, 0x205c, 0x205d, 0x205e, 0x205f, 0x2060,
- 0x2061, 0x2062, 0x2063, 0x2064, 0x2065, 0x2066, 0x2067, 0x2068,
- 0x2069, 0x206a, 0x206b, 0x206c, 0x206d, 0x206e, 0x206f, 0x2070,
- 0x2071, 0x2072, 0x2073, 0x2074, 0x2075, 0x2076, 0x2077, 0x2078,
- 0x2079, 0x4cba, 0x4cbb, 0x5d88, 0x5d89, 0x5d8a, 0x5d8b, 0x5d8c,
- 0x5d8d, 0x5d8e, 0x5d8f, 0x5db0, 0x5db1, 0x5db2, 0x5db3, 0x5db4,
- 0x5db5, 0x5db6, 0x5db7, 0x5db8, 0x5db9, 0x5dba, 0x5dbb, 0x5dbc,
- 0x5dbd, 0x5dbe, 0x5dbf, 0x5e40, 0x5e41, 0x5e42, 0x5e43, 0x5e44,
- 0x5e45, 0x5e46, 0x5e47, 0x5e48, 0x5e49, 0x5e4a, 0x5e4b, 0x5e4c,
- 0x5e4d, 0x5e4e, 0x5e4f, 0x5e50, 0x5e51, 0x5e52, 0x5e53, 0x5e54,
- 0x5e55, 0x5e56, 0x5e57, 0x5e58, 0x5e59, 0x5e5a, 0x5e5b, 0x5e5c,
- 0x5e5d, 0x5e5e, 0x5e5f, 0x5e60, 0x5e61, 0x5e62, 0x5e63, 0x5e64,
- 0x5e65, 0x5e66, 0x5e67, 0x5e68, 0x5e69, 0x5e6a, 0x5e6b, 0x5e6c,
- 0x5e6d, 0x5e6e, 0x5e6f, 0x5e70, 0x5e71, 0x5e72, 0x5e73, 0x5e74,
- 0x5e75, 0x5e76, 0x5e77, 0x5e78, 0x5e79, 0x5e7a, 0x5e7b, 0x5e7c,
- 0x5e7d, 0x5e7e, 0x5e7f, 0x5e80, 0x5e81, 0x5e82, 0x5e83, 0x5e84,
- 0x5e85, 0x5e86, 0x5e87, 0x5e88, 0x5e89, 0x5e8a, 0x5e8b, 0x5e8c,
- 0x5e8d, 0x5e8e, 0x5e8f, 0x5e90, 0x5e91, 0x5e92, 0x5e93, 0x5e94,
- 0x5e95, 0x5e96, 0x5e97, 0x5e98, 0x5e99, 0x5e9a, 0x5e9b, 0x5e9c,
- 0x5e9d, 0x5e9e, 0x5e9f, 0x5ea0, 0x5ea1, 0x5ea2, 0x5ea3, 0x5ea4,
- 0x5ea5, 0x5ea6, 0x5ea7, 0x5ea8, 0x5ea9, 0x5eaa, 0x5eab, 0x5eac,
- 0x5ead, 0x5eae, 0x5eaf, 0x5eb0, 0x5eb1, 0x5eb2, 0x5eb3, 0x5eb4,
- 0x5eb5, 0x5eb6, 0x5eb7, 0x5eb8, 0x5eb9, 0x5eba, 0x5ebb, 0x5ebc,
- 0x5ebd, 0x5ebe, 0x5ebf, 0x5ec0, 0x5ec1, 0x5ec2, 0x5ec3, 0x5ec4,
- 0x5ec5, 0x5ec6, 0x5ec7, 0x5ec8, 0x5ec9, 0x5eca, 0x5ecb, 0x5ecc,
- 0x5ecd, 0x5ece, 0x5ecf, 0x5ed0, 0x5ed1, 0x5ed2, 0x5ed3, 0x5ed4,
- 0x5ed5, 0x5ed6, 0x5ed7, 0x5ed8, 0x5ed9, 0x5eda, 0x5edb, 0x5edc,
- 0x5edd, 0x5ede, 0x5edf, 0x5ee0, 0x5ee1, 0x5ee2, 0x5ee3, 0x5ee4,
- 0x5ee5, 0x5ee6, 0x5ee7, 0x5ee8, 0x5ee9, 0x5eea, 0x5eeb, 0x5eec,
- 0x5eed, 0x5eee, 0x5eef, 0x5ef0, 0x5ef1, 0x5ef2, 0x5ef3, 0x5ef4,
- 0x5ef5, 0x5ef6, 0x5ef7, 0x5ef8, 0x5ef9, 0x5efa, 0x5efb, 0x5efc,
- 0x5efd, 0x5efe, 0x5eff, 0x5f00, 0x5f01, 0x5f02, 0x5f03, 0x5f04,
- 0x5f05, 0x5f06, 0x5f07, 0x5f08, 0x5f09, 0x5f0a, 0x5f0b, 0x5f0c,
- 0x5f0d, 0x5f0e, 0x5f0f, 0x0000,
-};
-
-static const uint8_t table0_mv_bits[1100] = {
- 1, 4, 4, 4, 5, 5, 5, 6,
- 6, 6, 7, 7, 7, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 8,
-};
-
-static const uint8_t table0_mvx[1099] = {
- 32, 32, 31, 32, 33, 31, 33, 31,
- 33, 32, 34, 32, 30, 32, 31, 34,
- 35, 32, 34, 33, 29, 33, 30, 30,
- 31, 31, 35, 29, 33, 35, 33, 34,
- 31, 29, 30, 34, 30, 36, 28, 32,
- 34, 37, 30, 27, 32, 25, 39, 32,
- 34, 32, 35, 35, 35, 31, 35, 29,
- 32, 29, 30, 29, 37, 27, 36, 38,
- 37, 33, 32, 31, 29, 31, 28, 36,
- 33, 30, 34, 33, 33, 28, 27, 25,
- 31, 26, 39, 32, 32, 31, 33, 39,
- 31, 38, 28, 36, 21, 23, 43, 36,
- 34, 41, 30, 25, 28, 31, 30, 34,
- 38, 35, 61, 34, 28, 30, 37, 37,
- 35, 27, 36, 3, 59, 38, 37, 32,
- 31, 29, 26, 33, 37, 33, 27, 27,
- 35, 34, 34, 40, 42, 33, 32, 29,
- 4, 5, 28, 24, 25, 35, 39, 38,
- 32, 23, 27, 32, 30, 35, 26, 34,
- 60, 36, 29, 22, 26, 41, 7, 30,
- 38, 30, 36, 29, 30, 41, 26, 25,
- 32, 34, 24, 39, 1, 25, 39, 32,
- 28, 29, 32, 38, 26, 36, 28, 63,
- 28, 39, 23, 21, 26, 35, 31, 35,
- 57, 31, 29, 29, 28, 30, 27, 35,
- 2, 38, 40, 34, 37, 29, 38, 43,
- 26, 32, 33, 42, 24, 40, 28, 32,
- 32, 32, 36, 32, 43, 25, 21, 31,
- 30, 31, 41, 29, 33, 37, 26, 37,
- 27, 59, 23, 33, 35, 31, 31, 37,
- 38, 39, 32, 23, 32, 27, 37, 36,
- 31, 40, 25, 27, 38, 31, 36, 28,
- 31, 36, 25, 45, 3, 34, 38, 39,
- 40, 38, 30, 32, 19, 24, 25, 26,
- 45, 20, 24, 33, 33, 31, 41, 34,
- 39, 47, 40, 58, 59, 41, 33, 3,
- 17, 61, 42, 30, 26, 29, 36, 61,
- 33, 37, 62, 28, 25, 38, 25, 38,
- 17, 23, 34, 33, 21, 33, 49, 27,
- 32, 23, 27, 22, 24, 22, 39, 43,
- 27, 37, 6, 42, 47, 26, 30, 31,
- 41, 39, 33, 22, 45, 36, 32, 45,
- 19, 22, 30, 5, 5, 17, 29, 22,
- 31, 31, 43, 37, 27, 32, 32, 32,
- 33, 34, 43, 35, 29, 26, 22, 32,
- 19, 32, 25, 31, 41, 49, 28, 34,
- 28, 39, 34, 19, 37, 38, 29, 21,
- 36, 42, 24, 48, 16, 28, 49, 22,
- 34, 31, 38, 39, 44, 11, 35, 30,
- 33, 33, 23, 28, 33, 46, 15, 13,
- 24, 41, 24, 34, 34, 30, 26, 24,
- 14, 60, 21, 29, 39, 23, 35, 37,
- 63, 45, 33, 34, 47, 41, 22, 42,
- 35, 35, 23, 32, 35, 43, 32, 7,
- 31, 41, 20, 31, 16, 13, 63, 25,
- 30, 32, 35, 30, 30, 31, 42, 47,
- 39, 38, 40, 40, 51, 55, 56, 18,
- 21, 39, 39, 33, 17, 41, 23, 24,
- 43, 25, 31, 20, 19, 45, 1, 34,
- 31, 22, 35, 15, 46, 46, 35, 31,
- 28, 29, 29, 23, 41, 27, 14, 53,
- 53, 27, 24, 32, 57, 32, 17, 42,
- 37, 29, 33, 1, 25, 32, 32, 63,
- 26, 40, 44, 36, 31, 39, 20, 20,
- 44, 23, 33, 34, 35, 33, 33, 28,
- 41, 23, 41, 41, 29, 25, 26, 49,
- 29, 24, 37, 49, 50, 51, 51, 26,
- 39, 25, 26, 15, 39, 18, 42, 17,
- 4, 31, 32, 32, 60, 1, 42, 32,
- 0, 12, 19, 35, 21, 41, 17, 26,
- 20, 45, 46, 32, 37, 22, 47, 29,
- 31, 27, 29, 30, 21, 33, 35, 18,
- 25, 33, 50, 51, 42, 2, 15, 51,
- 53, 33, 25, 29, 55, 37, 38, 33,
- 38, 59, 38, 33, 39, 13, 32, 40,
- 61, 61, 32, 9, 44, 3, 31, 29,
- 25, 31, 27, 23, 9, 25, 9, 29,
- 20, 30, 30, 42, 18, 28, 25, 28,
- 28, 21, 29, 43, 29, 43, 26, 44,
- 44, 21, 38, 21, 24, 45, 45, 35,
- 39, 22, 35, 36, 34, 34, 45, 34,
- 29, 31, 46, 25, 46, 16, 17, 31,
- 20, 32, 47, 47, 47, 32, 49, 49,
- 49, 31, 1, 27, 28, 39, 39, 21,
- 36, 23, 51, 2, 40, 51, 32, 53,
- 24, 30, 24, 30, 21, 40, 57, 57,
- 31, 41, 58, 32, 12, 4, 32, 34,
- 59, 31, 32, 13, 9, 35, 26, 35,
- 37, 61, 37, 63, 26, 29, 41, 38,
- 23, 20, 41, 26, 41, 42, 42, 42,
- 26, 26, 26, 26, 1, 26, 37, 37,
- 37, 23, 34, 42, 27, 43, 34, 27,
- 31, 24, 33, 16, 3, 31, 24, 33,
- 24, 4, 44, 44, 11, 44, 31, 13,
- 13, 44, 45, 13, 25, 22, 38, 26,
- 38, 38, 39, 32, 30, 39, 30, 22,
- 32, 26, 30, 47, 47, 47, 19, 47,
- 30, 31, 35, 8, 23, 47, 47, 27,
- 35, 47, 31, 48, 35, 19, 36, 49,
- 49, 33, 31, 39, 27, 39, 49, 49,
- 50, 50, 50, 39, 31, 51, 51, 39,
- 28, 33, 33, 21, 40, 31, 52, 53,
- 40, 53, 9, 33, 31, 53, 54, 54,
- 54, 55, 55, 34, 15, 56, 25, 56,
- 21, 21, 40, 40, 25, 40, 58, 36,
- 5, 41, 41, 12, 60, 41, 41, 37,
- 22, 61, 18, 29, 29, 30, 61, 30,
- 61, 62, 62, 30, 30, 63, 18, 13,
- 30, 23, 19, 20, 20, 41, 13, 2,
- 5, 5, 1, 5, 32, 6, 32, 35,
- 20, 35, 27, 35, 35, 36, 36, 13,
- 36, 41, 41, 41, 3, 30, 42, 27,
- 20, 30, 27, 28, 30, 21, 33, 33,
- 14, 24, 30, 42, 24, 33, 25, 42,
- 43, 14, 43, 43, 14, 43, 7, 36,
- 37, 37, 37, 37, 7, 14, 25, 43,
- 43, 44, 15, 37, 7, 7, 3, 1,
- 8, 15, 15, 8, 44, 44, 44, 45,
- 45, 45, 45, 8, 8, 45, 21, 45,
- 28, 28, 28, 21, 28, 28, 22, 37,
- 46, 46, 37, 8, 29, 37, 29, 22,
- 46, 37, 22, 29, 47, 47, 38, 38,
- 16, 38, 38, 33, 38, 22, 47, 47,
- 29, 25, 16, 0, 48, 1, 34, 48,
- 48, 34, 25, 26, 26, 49, 49, 26,
- 1, 49, 4, 26, 4, 49, 1, 9,
- 49, 49, 49, 10, 49, 17, 38, 17,
- 17, 50, 38, 50, 50, 22, 38, 51,
- 38, 38, 51, 39, 39, 18, 22, 39,
- 51, 22, 52, 52, 52, 39, 53, 53,
- 10, 23, 18, 29, 10, 53, 29, 54,
- 11, 54, 11, 11, 55, 1, 18, 55,
- 55, 55, 55, 55, 55, 29, 34, 18,
- 29, 56, 56, 34, 57, 34, 34, 29,
- 29, 57, 57, 35, 35, 35, 35, 35,
- 39, 35, 59, 59, 18, 59, 39, 30,
- 18, 40, 60, 60, 61, 30, 18, 61,
- 61, 19, 19,
-};
-
-static const uint8_t table0_mvy[1099] = {
- 32, 31, 32, 33, 32, 31, 31, 33,
- 33, 34, 32, 30, 32, 35, 34, 31,
- 32, 29, 33, 30, 32, 34, 33, 31,
- 30, 35, 31, 31, 29, 33, 35, 30,
- 29, 33, 34, 34, 30, 32, 32, 36,
- 29, 32, 35, 32, 28, 32, 32, 27,
- 35, 37, 34, 29, 30, 36, 35, 34,
- 25, 30, 29, 35, 33, 31, 31, 32,
- 31, 28, 39, 28, 29, 37, 31, 33,
- 27, 36, 28, 36, 37, 33, 33, 31,
- 27, 32, 31, 38, 26, 25, 25, 33,
- 39, 31, 34, 30, 32, 32, 32, 34,
- 36, 32, 28, 33, 30, 38, 37, 27,
- 33, 28, 32, 37, 35, 38, 29, 34,
- 27, 29, 29, 32, 32, 34, 35, 3,
- 26, 36, 31, 38, 30, 26, 35, 34,
- 37, 26, 25, 32, 32, 39, 23, 37,
- 32, 32, 29, 32, 29, 36, 29, 30,
- 41, 31, 30, 21, 39, 25, 34, 38,
- 32, 35, 39, 32, 33, 33, 32, 27,
- 29, 25, 28, 27, 26, 31, 30, 35,
- 24, 24, 31, 34, 32, 30, 35, 40,
- 28, 38, 5, 35, 29, 36, 36, 32,
- 38, 30, 33, 31, 35, 26, 23, 38,
- 32, 41, 28, 25, 37, 40, 37, 39,
- 32, 36, 33, 39, 25, 26, 28, 31,
- 28, 42, 23, 31, 33, 31, 39, 1,
- 59, 22, 27, 4, 33, 34, 33, 24,
- 41, 3, 35, 41, 41, 28, 36, 36,
- 28, 33, 35, 21, 23, 21, 22, 37,
- 27, 27, 43, 29, 60, 39, 27, 25,
- 59, 34, 27, 27, 26, 40, 37, 27,
- 61, 26, 39, 33, 31, 22, 37, 25,
- 30, 25, 24, 61, 31, 34, 25, 38,
- 32, 32, 30, 3, 61, 43, 29, 23,
- 28, 32, 28, 32, 31, 34, 5, 33,
- 32, 33, 33, 42, 37, 23, 38, 31,
- 40, 26, 32, 26, 37, 38, 36, 24,
- 29, 30, 20, 22, 29, 24, 32, 41,
- 2, 34, 25, 33, 29, 31, 39, 35,
- 36, 24, 32, 30, 33, 27, 44, 60,
- 30, 36, 19, 34, 31, 24, 16, 35,
- 32, 38, 21, 33, 31, 31, 21, 35,
- 5, 17, 29, 38, 38, 18, 58, 19,
- 43, 41, 30, 41, 43, 39, 29, 7,
- 29, 17, 28, 19, 28, 31, 25, 19,
- 40, 26, 21, 33, 39, 23, 40, 30,
- 39, 34, 35, 32, 32, 24, 33, 30,
- 40, 47, 39, 37, 32, 33, 24, 23,
- 45, 47, 27, 23, 42, 32, 32, 33,
- 36, 37, 37, 17, 18, 22, 40, 38,
- 32, 31, 35, 24, 17, 25, 17, 23,
- 33, 34, 51, 42, 31, 36, 36, 29,
- 21, 22, 37, 44, 43, 25, 47, 33,
- 45, 27, 31, 58, 31, 32, 31, 38,
- 43, 20, 47, 45, 54, 1, 26, 34,
- 38, 14, 22, 24, 33, 34, 32, 32,
- 37, 21, 23, 49, 35, 23, 28, 39,
- 39, 23, 55, 33, 30, 30, 63, 16,
- 42, 28, 13, 33, 33, 35, 19, 46,
- 43, 17, 19, 36, 39, 24, 31, 32,
- 33, 26, 28, 62, 33, 63, 33, 39,
- 19, 49, 17, 31, 43, 13, 15, 29,
- 25, 35, 33, 23, 49, 41, 28, 29,
- 34, 38, 7, 61, 11, 50, 13, 41,
- 19, 47, 25, 26, 15, 42, 41, 29,
- 45, 27, 17, 35, 32, 29, 32, 24,
- 13, 26, 26, 31, 24, 33, 28, 30,
- 31, 11, 45, 46, 33, 33, 35, 57,
- 32, 32, 35, 45, 34, 11, 37, 42,
- 39, 37, 31, 49, 21, 27, 29, 47,
- 53, 40, 51, 16, 26, 1, 40, 30,
- 41, 44, 34, 25, 27, 31, 35, 35,
- 31, 15, 49, 1, 35, 40, 5, 58,
- 21, 29, 22, 59, 45, 31, 9, 26,
- 9, 29, 11, 32, 30, 3, 13, 20,
- 18, 20, 11, 3, 29, 40, 31, 53,
- 30, 17, 20, 37, 31, 42, 47, 47,
- 54, 38, 9, 34, 13, 37, 21, 25,
- 27, 43, 42, 45, 40, 25, 27, 46,
- 22, 25, 53, 20, 2, 14, 39, 15,
- 22, 44, 34, 21, 38, 33, 27, 48,
- 34, 52, 35, 47, 49, 54, 2, 13,
- 23, 52, 29, 45, 22, 49, 54, 21,
- 40, 42, 31, 30, 29, 34, 0, 25,
- 23, 51, 24, 59, 28, 38, 29, 31,
- 2, 13, 31, 8, 31, 33, 12, 45,
- 41, 7, 14, 30, 25, 18, 43, 20,
- 43, 35, 44, 1, 49, 42, 42, 18,
- 41, 38, 41, 44, 53, 11, 20, 25,
- 45, 46, 47, 48, 39, 52, 46, 49,
- 63, 55, 44, 38, 13, 13, 57, 22,
- 51, 16, 12, 28, 35, 57, 25, 20,
- 26, 28, 28, 29, 32, 31, 62, 34,
- 35, 35, 19, 49, 48, 39, 40, 18,
- 43, 46, 11, 6, 48, 19, 49, 41,
- 10, 23, 58, 17, 21, 23, 34, 30,
- 60, 0, 44, 34, 26, 37, 46, 43,
- 49, 59, 4, 34, 59, 37, 22, 25,
- 28, 46, 6, 40, 59, 42, 36, 61,
- 28, 30, 31, 43, 10, 22, 23, 47,
- 20, 52, 55, 36, 25, 16, 1, 11,
- 27, 29, 5, 63, 18, 41, 31, 34,
- 38, 1, 5, 13, 28, 31, 17, 38,
- 39, 41, 36, 37, 22, 39, 33, 43,
- 43, 15, 17, 49, 30, 21, 22, 20,
- 10, 17, 25, 54, 57, 3, 34, 8,
- 36, 25, 31, 14, 15, 19, 29, 25,
- 18, 39, 53, 22, 27, 20, 29, 33,
- 41, 42, 35, 62, 50, 29, 53, 50,
- 35, 55, 42, 61, 63, 4, 7, 42,
- 21, 46, 47, 49, 27, 46, 17, 55,
- 41, 50, 63, 4, 56, 18, 8, 10,
- 18, 51, 63, 36, 55, 18, 5, 55,
- 9, 29, 17, 21, 30, 27, 1, 59,
- 7, 11, 12, 15, 5, 42, 24, 41,
- 43, 7, 27, 22, 25, 31, 30, 37,
- 22, 39, 53, 29, 36, 37, 48, 0,
- 5, 13, 17, 31, 32, 26, 46, 28,
- 44, 45, 46, 53, 49, 51, 3, 41,
- 3, 22, 42, 33, 5, 45, 7, 22,
- 40, 53, 24, 14, 25, 27, 10, 12,
- 34, 16, 17, 53, 20, 26, 39, 45,
- 18, 45, 35, 33, 31, 49, 4, 39,
- 42, 11, 51, 5, 13, 26, 27, 17,
- 52, 30, 0, 22, 12, 34, 62, 36,
- 38, 41, 47, 30, 63, 38, 41, 43,
- 59, 33, 45, 37, 38, 40, 47, 24,
- 48, 49, 30, 1, 10, 22, 49, 15,
- 39, 59, 31, 32, 33, 18, 13, 15,
- 31, 21, 27, 44, 42, 39, 46, 17,
- 26, 32, 30, 31, 0, 30, 34, 9,
- 12, 13, 25, 31, 32, 55, 43, 35,
- 61, 33, 35, 46, 25, 47, 48, 62,
- 63, 38, 61, 1, 2, 5, 7, 9,
- 46, 10, 34, 35, 36, 55, 51, 7,
- 40, 23, 34, 37, 5, 13, 42, 18,
- 25, 27, 28,
-};
-
-/* motion vector table 1 */
-static const uint16_t table1_mv_code[1100] = {
- 0x0000, 0x0007, 0x0009, 0x000f, 0x000a, 0x0011, 0x001a, 0x001c,
- 0x0011, 0x0031, 0x0025, 0x002d, 0x002f, 0x006f, 0x0075, 0x0041,
- 0x004c, 0x004e, 0x005c, 0x0060, 0x0062, 0x0066, 0x0068, 0x0069,
- 0x006b, 0x00a6, 0x00c1, 0x00cb, 0x00cc, 0x00ce, 0x00da, 0x00e8,
- 0x00ee, 0x0087, 0x0090, 0x009e, 0x009f, 0x00ba, 0x00ca, 0x00d8,
- 0x00db, 0x00df, 0x0104, 0x0109, 0x010c, 0x0143, 0x0145, 0x014a,
- 0x0156, 0x015c, 0x01b3, 0x01d3, 0x01da, 0x0103, 0x0109, 0x010b,
- 0x0122, 0x0127, 0x0134, 0x0161, 0x0164, 0x0176, 0x0184, 0x018d,
- 0x018e, 0x018f, 0x0190, 0x0193, 0x0196, 0x019d, 0x019e, 0x019f,
- 0x01a9, 0x01b2, 0x01b4, 0x01ba, 0x01bb, 0x01bc, 0x0201, 0x0202,
- 0x0205, 0x0207, 0x020d, 0x0210, 0x0211, 0x0215, 0x021b, 0x021f,
- 0x0281, 0x0285, 0x0290, 0x029c, 0x029d, 0x02a2, 0x02a7, 0x02a8,
- 0x02aa, 0x02b0, 0x02b1, 0x02b4, 0x02bc, 0x02bf, 0x0320, 0x0326,
- 0x0327, 0x0329, 0x032a, 0x0336, 0x0360, 0x0362, 0x0363, 0x0372,
- 0x03b2, 0x03bc, 0x03bd, 0x0203, 0x0205, 0x021a, 0x0249, 0x024a,
- 0x024c, 0x02c7, 0x02ca, 0x02ce, 0x02ef, 0x030d, 0x0322, 0x0325,
- 0x0338, 0x0373, 0x037a, 0x0409, 0x0415, 0x0416, 0x0418, 0x0428,
- 0x042d, 0x042f, 0x0434, 0x0508, 0x0509, 0x0510, 0x0511, 0x051c,
- 0x051e, 0x0524, 0x0541, 0x0543, 0x0546, 0x0547, 0x054d, 0x0557,
- 0x055f, 0x056a, 0x056c, 0x056d, 0x056f, 0x0576, 0x0577, 0x057a,
- 0x057b, 0x057c, 0x057d, 0x0600, 0x0601, 0x0603, 0x0614, 0x0616,
- 0x0617, 0x061c, 0x061f, 0x0642, 0x0648, 0x0649, 0x064a, 0x064b,
- 0x0657, 0x0668, 0x0669, 0x066b, 0x066e, 0x067f, 0x06c2, 0x06c8,
- 0x06cb, 0x06de, 0x06df, 0x06e2, 0x06e3, 0x06ef, 0x0748, 0x074b,
- 0x076e, 0x076f, 0x077c, 0x0409, 0x0423, 0x0428, 0x0429, 0x042a,
- 0x042b, 0x0432, 0x0433, 0x0496, 0x049a, 0x04d5, 0x04db, 0x0581,
- 0x0582, 0x058b, 0x058c, 0x058d, 0x0598, 0x0599, 0x059a, 0x059e,
- 0x05dd, 0x0619, 0x0632, 0x0633, 0x0648, 0x0672, 0x06a1, 0x06a2,
- 0x06a3, 0x06af, 0x06e2, 0x06e3, 0x06e4, 0x0800, 0x0801, 0x0802,
- 0x0803, 0x081a, 0x081b, 0x0829, 0x082f, 0x0832, 0x083e, 0x083f,
- 0x0852, 0x0853, 0x0858, 0x086b, 0x0877, 0x0878, 0x0879, 0x087a,
- 0x087b, 0x0a00, 0x0a01, 0x0a0d, 0x0a0e, 0x0a0f, 0x0a24, 0x0a37,
- 0x0a3a, 0x0a3b, 0x0a3e, 0x0a46, 0x0a47, 0x0a4a, 0x0a4b, 0x0a5f,
- 0x0a79, 0x0a7a, 0x0a7b, 0x0a80, 0x0a81, 0x0a84, 0x0a85, 0x0a99,
- 0x0aa5, 0x0aa6, 0x0ab8, 0x0aba, 0x0abb, 0x0abc, 0x0abd, 0x0ac8,
- 0x0ace, 0x0acf, 0x0ad7, 0x0adc, 0x0aeb, 0x0c04, 0x0c25, 0x0c26,
- 0x0c27, 0x0c2a, 0x0c2b, 0x0c3a, 0x0c3b, 0x0c3c, 0x0c3d, 0x0ca0,
- 0x0cad, 0x0cd4, 0x0cd5, 0x0cfc, 0x0cfd, 0x0d86, 0x0d92, 0x0d93,
- 0x0d94, 0x0d95, 0x0db0, 0x0db8, 0x0db9, 0x0dba, 0x0dbb, 0x0dc0,
- 0x0dc2, 0x0dc3, 0x0dda, 0x0ddb, 0x0ddc, 0x0ddd, 0x0e92, 0x0e93,
- 0x0e94, 0x0e95, 0x0ec7, 0x0ecc, 0x0ece, 0x0ecf, 0x0ed8, 0x0ed9,
- 0x0eda, 0x0edb, 0x0808, 0x0809, 0x080a, 0x0810, 0x0811, 0x0844,
- 0x0845, 0x0861, 0x0862, 0x0863, 0x086c, 0x0922, 0x0923, 0x092e,
- 0x092f, 0x0936, 0x0937, 0x09b1, 0x09b2, 0x09b3, 0x09b4, 0x09b5,
- 0x09b8, 0x09b9, 0x09ba, 0x09bb, 0x09bc, 0x09bd, 0x09be, 0x09bf,
- 0x0b00, 0x0b15, 0x0b2c, 0x0b2d, 0x0b2e, 0x0b2f, 0x0b36, 0x0bb9,
- 0x0c28, 0x0c2a, 0x0c2b, 0x0c2c, 0x0c2d, 0x0c2e, 0x0c2f, 0x0c30,
- 0x0c31, 0x0c38, 0x0c60, 0x0c61, 0x0c62, 0x0c63, 0x0c8d, 0x0c8e,
- 0x0c8f, 0x0c92, 0x0cbe, 0x0cbf, 0x0ce6, 0x0ce7, 0x0d40, 0x0d41,
- 0x0d57, 0x0d58, 0x0d59, 0x0d5a, 0x0d5b, 0x0d5c, 0x0d5d, 0x0d98,
- 0x0d99, 0x0d9a, 0x0d9b, 0x0d9c, 0x0d9d, 0x0dad, 0x0dae, 0x0daf,
- 0x0dc0, 0x0dc1, 0x0dc2, 0x0dc3, 0x0dca, 0x0dcb, 0x0dec, 0x0ded,
- 0x0dee, 0x0def, 0x1018, 0x1022, 0x1023, 0x1030, 0x1031, 0x1032,
- 0x1033, 0x1050, 0x1051, 0x105c, 0x1074, 0x1075, 0x1076, 0x1077,
- 0x1078, 0x1079, 0x107a, 0x107b, 0x10b2, 0x10b3, 0x10b8, 0x10b9,
- 0x10ba, 0x10bb, 0x10d4, 0x10ea, 0x10eb, 0x10ec, 0x10ed, 0x1404,
- 0x1405, 0x1406, 0x1407, 0x1410, 0x1411, 0x1412, 0x1413, 0x1414,
- 0x1415, 0x1416, 0x1417, 0x1418, 0x1419, 0x1466, 0x1467, 0x1468,
- 0x1469, 0x146a, 0x146b, 0x146c, 0x146d, 0x147e, 0x147f, 0x1488,
- 0x1489, 0x148a, 0x148b, 0x14b6, 0x14b7, 0x14b8, 0x14b9, 0x14ba,
- 0x14bb, 0x14bc, 0x14bd, 0x14f0, 0x14f1, 0x14f8, 0x14f9, 0x14fa,
- 0x14fb, 0x14fc, 0x14fd, 0x14fe, 0x14ff, 0x152a, 0x152b, 0x152c,
- 0x152d, 0x152e, 0x152f, 0x1530, 0x1531, 0x1548, 0x1549, 0x154e,
- 0x154f, 0x1558, 0x1559, 0x155a, 0x155b, 0x1572, 0x159a, 0x159b,
- 0x15ac, 0x15ba, 0x15bb, 0x15d0, 0x15d1, 0x15d2, 0x15d3, 0x15d4,
- 0x15d5, 0x181d, 0x181e, 0x181f, 0x1840, 0x1841, 0x1842, 0x1843,
- 0x1844, 0x1845, 0x1846, 0x1847, 0x1848, 0x1849, 0x1861, 0x1862,
- 0x1863, 0x1864, 0x1865, 0x1866, 0x1867, 0x1868, 0x1869, 0x186a,
- 0x186b, 0x186c, 0x186d, 0x186e, 0x191b, 0x191c, 0x191d, 0x191e,
- 0x191f, 0x1942, 0x1943, 0x1944, 0x1945, 0x1946, 0x1947, 0x1958,
- 0x1959, 0x19ed, 0x19ee, 0x19ef, 0x19f0, 0x19f1, 0x19f2, 0x19f3,
- 0x19f4, 0x19f5, 0x19f6, 0x19f7, 0x1b0e, 0x1b0f, 0x1b62, 0x1b63,
- 0x1b64, 0x1b65, 0x1b66, 0x1b67, 0x1b68, 0x1b69, 0x1b6a, 0x1b6b,
- 0x1b6c, 0x1b6d, 0x1b6e, 0x1b6f, 0x1b82, 0x1ba8, 0x1ba9, 0x1baa,
- 0x1bab, 0x1bac, 0x1bad, 0x1bae, 0x1baf, 0x1bb0, 0x1bb1, 0x1bb2,
- 0x1bb3, 0x1d80, 0x1d81, 0x1d82, 0x1d83, 0x1d84, 0x1d85, 0x1d86,
- 0x1d87, 0x1d88, 0x1d89, 0x1d8a, 0x1d8b, 0x1d8c, 0x1d8d, 0x1007,
- 0x1008, 0x1009, 0x100a, 0x100b, 0x100c, 0x100d, 0x100e, 0x100f,
- 0x1016, 0x1080, 0x1081, 0x1082, 0x1083, 0x1084, 0x1085, 0x1086,
- 0x1087, 0x10c0, 0x123a, 0x123b, 0x123c, 0x123d, 0x123e, 0x123f,
- 0x1240, 0x1241, 0x1242, 0x1243, 0x1350, 0x1352, 0x1353, 0x1358,
- 0x1359, 0x135a, 0x135b, 0x135c, 0x135d, 0x135e, 0x135f, 0x1360,
- 0x1361, 0x1602, 0x1603, 0x160c, 0x160d, 0x160e, 0x160f, 0x1620,
- 0x1621, 0x1622, 0x1623, 0x1624, 0x1625, 0x1626, 0x1627, 0x1628,
- 0x1629, 0x166e, 0x166f, 0x167c, 0x167d, 0x167e, 0x167f, 0x1770,
- 0x1771, 0x1852, 0x1853, 0x1872, 0x1873, 0x1874, 0x1875, 0x1876,
- 0x1877, 0x1878, 0x1879, 0x187a, 0x187b, 0x187c, 0x187d, 0x187e,
- 0x187f, 0x1918, 0x1919, 0x1926, 0x1927, 0x1970, 0x1971, 0x1972,
- 0x1973, 0x1974, 0x1975, 0x1976, 0x1977, 0x1978, 0x1979, 0x197a,
- 0x197b, 0x1aa0, 0x1aa1, 0x1aa2, 0x1aa3, 0x1aa4, 0x1aa5, 0x1aa6,
- 0x1aa7, 0x1aa8, 0x1aa9, 0x1aaa, 0x1aab, 0x1aac, 0x1aad, 0x1b3c,
- 0x1b3d, 0x1b3e, 0x1b3f, 0x1b50, 0x1b51, 0x1b52, 0x1b53, 0x1b54,
- 0x1b55, 0x1b56, 0x1b57, 0x1b58, 0x1b59, 0x2032, 0x2033, 0x2034,
- 0x2035, 0x2036, 0x2037, 0x2038, 0x2039, 0x203a, 0x203b, 0x203c,
- 0x203d, 0x203e, 0x203f, 0x2040, 0x2041, 0x2042, 0x2043, 0x20ba,
- 0x20bb, 0x20cc, 0x20cd, 0x20ce, 0x20cf, 0x20e0, 0x20e1, 0x20e2,
- 0x20e3, 0x20e4, 0x20e5, 0x20e6, 0x20e7, 0x21aa, 0x21ab, 0x21c0,
- 0x21c1, 0x21c2, 0x21c3, 0x21c4, 0x21c5, 0x21c6, 0x21c7, 0x21c8,
- 0x21c9, 0x21ca, 0x21cb, 0x21cc, 0x21cd, 0x21ce, 0x21cf, 0x21d0,
- 0x21d1, 0x21d2, 0x21d3, 0x2894, 0x2895, 0x2896, 0x2897, 0x2898,
- 0x2899, 0x289a, 0x289b, 0x289c, 0x289d, 0x289e, 0x289f, 0x28c0,
- 0x28c1, 0x28c2, 0x28c3, 0x28c4, 0x28c5, 0x28c6, 0x28c7, 0x28c8,
- 0x28c9, 0x28ca, 0x28cb, 0x2930, 0x2931, 0x2932, 0x2933, 0x2934,
- 0x2935, 0x2936, 0x2937, 0x2938, 0x2939, 0x293a, 0x293b, 0x293c,
- 0x293d, 0x293e, 0x293f, 0x2960, 0x2961, 0x2962, 0x2963, 0x2964,
- 0x2965, 0x2966, 0x2967, 0x2968, 0x2969, 0x296a, 0x296b, 0x2a40,
- 0x2a41, 0x2a42, 0x2a43, 0x2a44, 0x2a45, 0x2a46, 0x2a47, 0x2a48,
- 0x2a49, 0x2a4a, 0x2a4b, 0x2a4c, 0x2a4d, 0x2a4e, 0x2a4f, 0x2a50,
- 0x2a51, 0x2a52, 0x2a53, 0x2ae6, 0x2ae7, 0x2b24, 0x2b25, 0x2b26,
- 0x2b27, 0x2b28, 0x2b29, 0x2b2a, 0x2b2b, 0x2b2c, 0x2b2d, 0x2b2e,
- 0x2b2f, 0x2b30, 0x2b31, 0x2b32, 0x2b33, 0x2b5a, 0x2b5b, 0x3014,
- 0x3015, 0x3016, 0x3017, 0x3020, 0x3021, 0x3022, 0x3023, 0x3024,
- 0x3025, 0x3026, 0x3027, 0x3028, 0x3029, 0x302a, 0x302b, 0x302c,
- 0x302d, 0x302e, 0x302f, 0x3030, 0x3031, 0x3032, 0x3033, 0x3034,
- 0x3035, 0x3036, 0x3037, 0x3038, 0x3039, 0x30c0, 0x30c1, 0x30de,
- 0x30df, 0x3218, 0x3219, 0x321a, 0x321b, 0x321c, 0x321d, 0x321e,
- 0x321f, 0x3220, 0x3221, 0x3222, 0x3223, 0x3224, 0x3225, 0x3226,
- 0x3227, 0x3228, 0x3229, 0x322a, 0x322b, 0x322c, 0x322d, 0x322e,
- 0x322f, 0x3230, 0x3231, 0x3232, 0x3233, 0x3234, 0x3235, 0x3378,
- 0x3379, 0x337a, 0x337b, 0x337c, 0x337d, 0x337e, 0x337f, 0x33c0,
- 0x33c1, 0x33c2, 0x33c3, 0x33c4, 0x33c5, 0x33c6, 0x33c7, 0x33c8,
- 0x33c9, 0x33ca, 0x33cb, 0x33cc, 0x33cd, 0x33ce, 0x33cf, 0x33d0,
- 0x33d1, 0x33d2, 0x33d3, 0x33d4, 0x33d5, 0x33d6, 0x33d7, 0x33d8,
- 0x33d9, 0x3706, 0x3707, 0x3730, 0x3731, 0x3732, 0x3733, 0x3734,
- 0x3735, 0x3736, 0x3737, 0x3738, 0x3739, 0x373a, 0x373b, 0x373c,
- 0x373d, 0x373e, 0x373f, 0x3740, 0x3741, 0x3742, 0x3743, 0x3744,
- 0x3745, 0x3746, 0x3747, 0x3748, 0x3749, 0x374a, 0x374b, 0x374c,
- 0x374d, 0x374e, 0x374f, 0x3b34, 0x3b35, 0x3b36, 0x3b37, 0x3be8,
- 0x3be9, 0x3bea, 0x3beb, 0x3bec, 0x3bed, 0x3bee, 0x3bef, 0x3bf0,
- 0x3bf1, 0x3bf2, 0x3bf3, 0x3bf4, 0x3bf5, 0x3bf6, 0x3bf7, 0x3bf8,
- 0x3bf9, 0x3bfa, 0x3bfb, 0x3bfc, 0x3bfd, 0x3bfe, 0x3bff, 0x2000,
- 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008,
- 0x2009, 0x200a, 0x200b, 0x200c, 0x200d, 0x202e, 0x202f, 0x2182,
- 0x2183, 0x21b4, 0x21b5, 0x21b6, 0x21b7, 0x21b8, 0x21b9, 0x21ba,
- 0x21bb, 0x21bc, 0x21bd, 0x21be, 0x21bf, 0x2460, 0x2461, 0x2462,
- 0x2463, 0x2464, 0x2465, 0x2466, 0x2467, 0x2468, 0x2469, 0x246a,
- 0x246b, 0x246c, 0x246d, 0x246e, 0x246f, 0x2470, 0x2471, 0x2472,
- 0x2473, 0x26a2, 0x26a3, 0x000b,
-};
-
-static const uint8_t table1_mv_bits[1100] = {
- 2, 4, 4, 4, 5, 5, 5, 5,
- 6, 6, 7, 7, 7, 7, 7, 8,
- 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 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, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 4,
-};
-
-static const uint8_t table1_mvx[1099] = {
- 32, 31, 32, 31, 33, 32, 33, 33,
- 31, 34, 30, 32, 32, 34, 35, 32,
- 34, 33, 29, 30, 30, 32, 31, 31,
- 33, 35, 35, 33, 31, 29, 29, 33,
- 34, 30, 31, 28, 36, 30, 34, 32,
- 32, 37, 32, 32, 25, 27, 39, 32,
- 32, 32, 38, 35, 36, 32, 37, 61,
- 26, 32, 34, 35, 3, 35, 27, 28,
- 29, 34, 28, 37, 31, 36, 32, 27,
- 31, 30, 29, 39, 33, 29, 33, 35,
- 25, 25, 29, 33, 31, 31, 31, 33,
- 32, 30, 32, 32, 41, 39, 33, 36,
- 32, 28, 34, 36, 38, 24, 60, 31,
- 23, 28, 32, 33, 59, 32, 40, 30,
- 5, 34, 32, 38, 32, 30, 43, 4,
- 32, 32, 42, 31, 31, 32, 26, 38,
- 26, 22, 21, 37, 61, 63, 37, 31,
- 32, 33, 2, 1, 23, 33, 41, 27,
- 35, 30, 38, 23, 33, 3, 28, 34,
- 34, 27, 41, 29, 39, 35, 36, 29,
- 32, 27, 30, 32, 24, 61, 37, 26,
- 59, 25, 35, 27, 36, 37, 30, 31,
- 34, 40, 3, 28, 34, 39, 32, 31,
- 32, 30, 24, 28, 35, 36, 26, 32,
- 31, 33, 29, 33, 39, 25, 30, 24,
- 35, 59, 29, 34, 25, 30, 21, 35,
- 43, 40, 32, 29, 5, 28, 31, 62,
- 33, 33, 25, 31, 21, 31, 43, 31,
- 34, 33, 20, 40, 39, 31, 31, 57,
- 38, 32, 42, 33, 32, 31, 32, 29,
- 30, 44, 5, 31, 22, 34, 36, 17,
- 38, 58, 38, 35, 32, 60, 35, 24,
- 32, 38, 16, 45, 42, 32, 31, 29,
- 4, 30, 17, 40, 46, 48, 63, 32,
- 42, 19, 41, 22, 28, 36, 45, 33,
- 33, 32, 29, 7, 41, 42, 18, 33,
- 33, 32, 22, 37, 1, 26, 22, 23,
- 49, 28, 26, 27, 32, 33, 27, 23,
- 28, 36, 15, 6, 34, 27, 31, 26,
- 23, 2, 33, 32, 34, 41, 28, 32,
- 41, 0, 36, 38, 34, 31, 47, 32,
- 17, 31, 39, 33, 37, 51, 30, 47,
- 32, 50, 32, 19, 63, 30, 25, 27,
- 33, 62, 24, 31, 27, 30, 37, 31,
- 45, 32, 39, 20, 46, 47, 35, 19,
- 34, 1, 49, 21, 21, 14, 51, 26,
- 23, 31, 36, 35, 58, 29, 29, 21,
- 20, 42, 13, 28, 12, 40, 31, 33,
- 39, 60, 32, 44, 33, 31, 28, 37,
- 29, 32, 30, 49, 43, 28, 39, 25,
- 32, 48, 2, 15, 20, 25, 31, 28,
- 21, 24, 25, 15, 31, 17, 37, 43,
- 18, 32, 33, 24, 33, 36, 13, 33,
- 31, 39, 11, 31, 33, 32, 39, 37,
- 32, 32, 29, 17, 44, 46, 36, 35,
- 26, 37, 58, 32, 34, 38, 8, 38,
- 38, 22, 29, 25, 16, 35, 32, 35,
- 33, 43, 18, 46, 38, 50, 33, 18,
- 53, 60, 13, 32, 36, 33, 51, 36,
- 43, 45, 27, 42, 29, 24, 30, 25,
- 31, 52, 31, 35, 38, 9, 22, 34,
- 4, 17, 28, 55, 42, 25, 17, 20,
- 47, 34, 33, 16, 40, 25, 16, 30,
- 53, 29, 10, 11, 14, 26, 33, 4,
- 35, 44, 26, 16, 31, 26, 34, 38,
- 29, 31, 30, 24, 22, 61, 32, 9,
- 45, 34, 31, 19, 9, 31, 46, 31,
- 35, 54, 29, 57, 30, 50, 3, 31,
- 63, 34, 47, 41, 51, 18, 31, 14,
- 37, 38, 31, 24, 32, 31, 50, 33,
- 31, 54, 27, 9, 33, 23, 19, 32,
- 29, 29, 33, 28, 47, 49, 30, 47,
- 33, 27, 25, 54, 44, 45, 50, 58,
- 51, 48, 33, 59, 33, 34, 57, 13,
- 26, 33, 13, 48, 30, 11, 7, 56,
- 34, 55, 26, 0, 26, 35, 1, 51,
- 33, 53, 31, 45, 12, 29, 29, 51,
- 31, 48, 2, 6, 34, 30, 28, 33,
- 60, 40, 27, 46, 31, 9, 35, 29,
- 31, 39, 55, 46, 19, 37, 62, 34,
- 30, 16, 19, 49, 41, 41, 39, 37,
- 14, 5, 13, 35, 55, 30, 40, 40,
- 42, 8, 20, 25, 45, 35, 33, 36,
- 54, 38, 27, 37, 62, 40, 15, 59,
- 49, 31, 29, 34, 34, 39, 24, 29,
- 25, 29, 21, 29, 10, 61, 33, 49,
- 35, 34, 3, 38, 39, 29, 7, 41,
- 1, 35, 4, 23, 15, 23, 11, 37,
- 28, 35, 30, 30, 24, 1, 43, 56,
- 8, 34, 42, 24, 45, 30, 20, 23,
- 8, 38, 22, 33, 17, 52, 34, 22,
- 53, 43, 44, 1, 27, 31, 41, 43,
- 41, 30, 31, 36, 30, 5, 55, 31,
- 33, 30, 40, 23, 15, 29, 34, 34,
- 59, 34, 30, 11, 13, 38, 5, 0,
- 30, 42, 5, 30, 29, 34, 10, 44,
- 30, 63, 35, 12, 3, 26, 15, 17,
- 25, 34, 43, 39, 34, 56, 29, 23,
- 30, 12, 30, 10, 35, 9, 24, 58,
- 10, 12, 54, 33, 37, 20, 41, 35,
- 29, 18, 61, 30, 40, 24, 39, 53,
- 62, 26, 29, 33, 34, 53, 49, 21,
- 27, 11, 63, 20, 26, 23, 7, 13,
- 6, 47, 29, 30, 9, 51, 22, 34,
- 21, 25, 33, 56, 57, 30, 38, 51,
- 51, 38, 63, 28, 40, 35, 33, 18,
- 33, 33, 24, 58, 58, 34, 49, 29,
- 43, 4, 1, 4, 42, 35, 35, 30,
- 17, 5, 56, 61, 25, 37, 36, 55,
- 28, 35, 29, 50, 48, 52, 2, 42,
- 34, 40, 46, 46, 43, 35, 29, 48,
- 20, 29, 31, 41, 7, 30, 35, 19,
- 14, 21, 8, 39, 39, 40, 46, 55,
- 34, 6, 30, 34, 37, 25, 37, 33,
- 22, 44, 52, 17, 35, 29, 36, 35,
- 40, 37, 28, 30, 50, 14, 28, 55,
- 6, 23, 19, 14, 30, 3, 30, 28,
- 28, 61, 61, 47, 45, 48, 40, 40,
- 34, 34, 25, 30, 29, 35, 4, 26,
- 53, 50, 26, 41, 27, 59, 27, 38,
- 39, 3, 50, 43, 47, 23, 33, 55,
- 35, 21, 23, 35, 61, 33, 46, 52,
- 35, 34, 24, 30, 43, 16, 37, 21,
- 2, 24, 45, 34, 30, 55, 55, 1,
- 29, 29, 26, 28, 25, 31, 36, 22,
- 17, 30, 52, 2, 44, 44, 57, 26,
- 62, 41, 39, 57, 26, 46, 49, 11,
- 16, 19, 5, 59, 38, 39, 58, 38,
- 25, 49, 50, 22, 28, 59, 9, 59,
- 7, 28, 55, 17, 4, 35, 50, 21,
- 29, 44, 47, 18, 24, 19, 25, 42,
- 35, 3, 51, 35, 16, 35, 30, 63,
- 57, 39, 39, 25, 35, 38, 9, 16,
- 36, 45, 31, 60, 14, 34, 42, 24,
- 0, 37, 18, 61, 57, 37, 28, 53,
- 20, 46, 14, 47, 38, 38, 38, 9,
- 34, 39, 43, 17, 39, 59, 5, 27,
- 0, 12, 27,
-};
-
-static const uint8_t table1_mvy[1099] = {
- 32, 32, 31, 31, 32, 33, 31, 33,
- 33, 32, 32, 30, 34, 31, 32, 29,
- 33, 30, 32, 33, 31, 35, 34, 30,
- 34, 31, 33, 29, 29, 31, 33, 35,
- 30, 30, 35, 32, 32, 34, 34, 28,
- 25, 32, 36, 27, 32, 32, 32, 37,
- 39, 3, 32, 30, 31, 26, 31, 32,
- 32, 38, 29, 29, 32, 34, 31, 31,
- 34, 35, 33, 33, 28, 33, 1, 33,
- 27, 29, 30, 31, 28, 29, 37, 35,
- 31, 33, 35, 27, 36, 37, 25, 25,
- 61, 35, 4, 5, 32, 33, 36, 30,
- 23, 30, 28, 34, 31, 32, 32, 39,
- 32, 34, 21, 39, 32, 59, 32, 28,
- 32, 36, 60, 33, 24, 36, 32, 32,
- 41, 2, 32, 38, 26, 22, 33, 30,
- 31, 32, 32, 30, 31, 32, 29, 3,
- 40, 38, 32, 32, 33, 26, 31, 34,
- 28, 38, 34, 31, 3, 31, 35, 38,
- 27, 35, 33, 28, 29, 27, 29, 27,
- 43, 29, 37, 63, 31, 33, 34, 30,
- 31, 30, 37, 30, 35, 35, 26, 41,
- 37, 31, 33, 28, 26, 30, 42, 24,
- 7, 27, 33, 29, 36, 28, 34, 57,
- 23, 41, 36, 23, 35, 34, 25, 30,
- 25, 33, 25, 25, 29, 24, 33, 39,
- 33, 33, 0, 37, 31, 36, 21, 32,
- 61, 24, 35, 61, 31, 5, 31, 59,
- 39, 21, 32, 30, 34, 22, 40, 32,
- 29, 16, 31, 5, 62, 2, 20, 39,
- 39, 32, 33, 1, 31, 24, 36, 32,
- 36, 32, 28, 26, 6, 31, 38, 34,
- 58, 35, 32, 33, 33, 17, 43, 26,
- 31, 40, 31, 34, 32, 32, 31, 19,
- 30, 32, 29, 33, 38, 38, 32, 59,
- 40, 18, 38, 32, 35, 34, 32, 17,
- 1, 15, 30, 28, 31, 28, 34, 29,
- 32, 27, 35, 27, 49, 22, 37, 34,
- 37, 26, 32, 32, 22, 28, 45, 29,
- 30, 31, 43, 46, 41, 30, 26, 13,
- 34, 32, 27, 38, 42, 42, 33, 47,
- 33, 60, 27, 42, 25, 32, 22, 32,
- 48, 32, 45, 33, 33, 41, 27, 25,
- 19, 31, 35, 19, 36, 42, 27, 17,
- 31, 44, 28, 33, 33, 31, 23, 31,
- 40, 33, 31, 34, 30, 32, 33, 36,
- 35, 47, 37, 41, 31, 23, 41, 29,
- 30, 35, 32, 25, 32, 28, 58, 2,
- 37, 33, 14, 33, 49, 20, 39, 36,
- 21, 9, 23, 33, 35, 24, 39, 37,
- 11, 33, 30, 31, 31, 28, 51, 40,
- 35, 29, 25, 33, 46, 35, 37, 30,
- 30, 8, 63, 28, 15, 40, 33, 45,
- 49, 25, 32, 4, 47, 51, 36, 39,
- 53, 10, 24, 29, 30, 31, 25, 40,
- 38, 38, 33, 56, 23, 27, 32, 37,
- 26, 29, 43, 36, 33, 24, 55, 43,
- 9, 29, 34, 34, 24, 33, 18, 33,
- 33, 30, 31, 50, 24, 60, 30, 39,
- 34, 30, 39, 28, 22, 38, 2, 26,
- 63, 32, 57, 21, 39, 33, 28, 18,
- 30, 34, 22, 33, 29, 41, 30, 34,
- 35, 21, 13, 34, 35, 39, 30, 46,
- 32, 42, 32, 31, 33, 26, 11, 33,
- 22, 31, 25, 31, 53, 27, 43, 25,
- 40, 50, 21, 36, 38, 30, 12, 31,
- 34, 20, 15, 29, 32, 62, 30, 13,
- 17, 32, 19, 31, 20, 31, 30, 7,
- 1, 17, 34, 37, 31, 31, 44, 34,
- 26, 40, 16, 37, 52, 48, 30, 20,
- 18, 33, 38, 29, 7, 25, 30, 54,
- 45, 47, 46, 41, 29, 29, 16, 30,
- 14, 26, 38, 34, 34, 29, 34, 30,
- 29, 30, 57, 30, 4, 46, 33, 29,
- 39, 44, 30, 31, 50, 33, 31, 32,
- 19, 32, 40, 31, 37, 47, 1, 35,
- 16, 31, 0, 35, 33, 1, 17, 34,
- 9, 34, 33, 31, 49, 43, 42, 51,
- 34, 29, 23, 29, 14, 30, 45, 49,
- 11, 24, 31, 28, 35, 41, 30, 44,
- 18, 29, 34, 35, 36, 25, 26, 21,
- 31, 30, 34, 19, 34, 44, 36, 38,
- 25, 31, 28, 23, 37, 3, 55, 41,
- 30, 22, 41, 24, 33, 26, 35, 35,
- 30, 55, 51, 47, 48, 38, 24, 15,
- 21, 50, 25, 46, 30, 29, 10, 34,
- 42, 45, 29, 42, 22, 3, 33, 27,
- 34, 1, 34, 28, 34, 36, 35, 23,
- 23, 13, 58, 3, 26, 63, 25, 31,
- 34, 61, 38, 39, 25, 61, 29, 37,
- 30, 41, 26, 48, 28, 33, 50, 35,
- 30, 37, 29, 29, 40, 6, 39, 28,
- 28, 19, 8, 22, 45, 34, 35, 10,
- 58, 17, 37, 39, 30, 18, 54, 14,
- 29, 16, 59, 30, 35, 23, 35, 30,
- 47, 36, 29, 55, 20, 12, 31, 35,
- 14, 29, 18, 34, 34, 24, 29, 26,
- 22, 2, 27, 23, 8, 30, 55, 38,
- 60, 31, 4, 34, 49, 34, 27, 34,
- 33, 30, 31, 54, 42, 35, 38, 46,
- 44, 26, 27, 9, 39, 25, 21, 29,
- 28, 42, 13, 0, 5, 34, 37, 28,
- 24, 29, 63, 26, 22, 27, 29, 25,
- 33, 25, 61, 0, 35, 25, 36, 15,
- 27, 40, 53, 33, 3, 10, 16, 37,
- 38, 18, 30, 46, 27, 9, 6, 29,
- 62, 8, 42, 28, 29, 3, 25, 16,
- 26, 29, 35, 28, 27, 51, 61, 48,
- 37, 9, 34, 7, 49, 45, 20, 29,
- 21, 5, 5, 29, 28, 34, 29, 24,
- 10, 24, 35, 36, 38, 55, 11, 36,
- 38, 53, 54, 26, 30, 49, 20, 27,
- 30, 39, 33, 41, 49, 22, 38, 38,
- 4, 30, 8, 9, 3, 24, 22, 50,
- 37, 36, 31, 27, 2, 9, 42, 63,
- 25, 19, 44, 1, 28, 28, 48, 30,
- 34, 41, 41, 38, 12, 27, 15, 0,
- 16, 34, 35, 38, 28, 29, 40, 42,
- 51, 52, 45, 54, 59, 59, 42, 44,
- 37, 26, 46, 24, 15, 39, 22, 46,
- 19, 35, 38, 17, 37, 23, 52, 55,
- 50, 37, 26, 11, 37, 12, 24, 30,
- 16, 13, 22, 13, 36, 35, 40, 41,
- 34, 41, 26, 53, 51, 5, 21, 30,
- 2, 63, 41, 20, 1, 56, 21, 24,
- 25, 5, 28, 35, 26, 28, 30, 18,
- 29, 23, 40, 34, 20, 42, 39, 34,
- 28, 61, 38, 27, 62, 9, 36, 17,
- 9, 49, 24, 25, 54, 34, 39, 37,
- 3, 1, 25, 38, 38, 44, 35, 36,
- 12, 60, 36, 38, 40, 25, 43, 39,
- 53, 28, 39, 57, 46, 10, 52, 27,
- 35, 42, 45, 59, 15, 60, 38, 24,
- 23, 39, 12, 29, 24, 0, 20, 16,
- 28, 43, 35, 28, 1, 49, 4, 21,
- 42, 39, 29, 3, 44, 21, 53, 55,
- 11, 5, 3, 39, 53, 28, 25, 19,
- 34, 28, 21,
-};
-
-MVTable ff_mv_tables[2] = {
- {
- 1099,
- table0_mv_code,
- table0_mv_bits,
- table0_mvx,
- table0_mvy,
- },
- {
- 1099,
- table1_mv_code,
- table1_mv_bits,
- table1_mvx,
- table1_mvy,
- }
-};
-
-const uint8_t ff_v2_mb_type[8][2] = {
- {1, 1}, {0 , 2}, {3 , 3}, {9 , 5},
- {5, 4}, {0x21, 7}, {0x20, 7}, {0x11, 6},
-};
-
-const uint8_t ff_v2_intra_cbpc[4][2] = {
- {1, 1}, {0, 3}, {1, 3}, {1, 2},
-};
-
-const uint8_t ff_wmv1_y_dc_scale_table[32]={
-// 0, 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
- 0, 8, 8, 8, 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
-};
-const uint8_t ff_wmv1_c_dc_scale_table[32]={
-// 0, 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
- 0, 8, 8, 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
-};
-
-const uint8_t ff_old_ff_y_dc_scale_table[32]={
-// 0 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
- 0, 8, 8, 8, 8,10,12,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39
-};
-
-const uint8_t ff_wmv1_scantable[WMV1_SCANTABLE_COUNT][64]={
- {
- 0x00, 0x08, 0x01, 0x02, 0x09, 0x10, 0x18, 0x11,
- 0x0A, 0x03, 0x04, 0x0B, 0x12, 0x19, 0x20, 0x28,
- 0x30, 0x38, 0x29, 0x21, 0x1A, 0x13, 0x0C, 0x05,
- 0x06, 0x0D, 0x14, 0x1B, 0x22, 0x31, 0x39, 0x3A,
- 0x32, 0x2A, 0x23, 0x1C, 0x15, 0x0E, 0x07, 0x0F,
- 0x16, 0x1D, 0x24, 0x2B, 0x33, 0x3B, 0x3C, 0x34,
- 0x2C, 0x25, 0x1E, 0x17, 0x1F, 0x26, 0x2D, 0x35,
- 0x3D, 0x3E, 0x36, 0x2E, 0x27, 0x2F, 0x37, 0x3F,
- },
- {
- 0x00, 0x08, 0x01, 0x02, 0x09, 0x10, 0x18, 0x11,
- 0x0A, 0x03, 0x04, 0x0B, 0x12, 0x19, 0x20, 0x28,
- 0x21, 0x30, 0x1A, 0x13, 0x0C, 0x05, 0x06, 0x0D,
- 0x14, 0x1B, 0x22, 0x29, 0x38, 0x31, 0x39, 0x2A,
- 0x23, 0x1C, 0x15, 0x0E, 0x07, 0x0F, 0x16, 0x1D,
- 0x24, 0x2B, 0x32, 0x3A, 0x33, 0x3B, 0x2C, 0x25,
- 0x1E, 0x17, 0x1F, 0x26, 0x2D, 0x34, 0x3C, 0x35,
- 0x3D, 0x2E, 0x27, 0x2F, 0x36, 0x3E, 0x37, 0x3F,
- },
- {
- 0x00, 0x01, 0x08, 0x02, 0x03, 0x09, 0x10, 0x18,
- 0x11, 0x0A, 0x04, 0x05, 0x0B, 0x12, 0x19, 0x20,
- 0x28, 0x30, 0x21, 0x1A, 0x13, 0x0C, 0x06, 0x07,
- 0x0D, 0x14, 0x1B, 0x22, 0x29, 0x38, 0x31, 0x39,
- 0x2A, 0x23, 0x1C, 0x15, 0x0E, 0x0F, 0x16, 0x1D,
- 0x24, 0x2B, 0x32, 0x3A, 0x33, 0x2C, 0x25, 0x1E,
- 0x17, 0x1F, 0x26, 0x2D, 0x34, 0x3B, 0x3C, 0x35,
- 0x2E, 0x27, 0x2F, 0x36, 0x3D, 0x3E, 0x37, 0x3F,
- },
- {
- 0x00, 0x08, 0x10, 0x01, 0x18, 0x20, 0x28, 0x09,
- 0x02, 0x03, 0x0A, 0x11, 0x19, 0x30, 0x38, 0x29,
- 0x21, 0x1A, 0x12, 0x0B, 0x04, 0x05, 0x0C, 0x13,
- 0x1B, 0x22, 0x31, 0x39, 0x32, 0x2A, 0x23, 0x1C,
- 0x14, 0x0D, 0x06, 0x07, 0x0E, 0x15, 0x1D, 0x24,
- 0x2B, 0x33, 0x3A, 0x3B, 0x34, 0x2C, 0x25, 0x1E,
- 0x16, 0x0F, 0x17, 0x1F, 0x26, 0x2D, 0x3C, 0x35,
- 0x2E, 0x27, 0x2F, 0x36, 0x3D, 0x3E, 0x37, 0x3F,
- }
-};
-
-const uint8_t ff_table_inter_intra[4][2]={
- {0,1} /*Luma-Left Chroma-Left*/,
- {2,2} /*Luma-Top Chroma-Left*/,
- {6,3} /*luma-Left Chroma-Top */,
- {7,3} /*luma-Top Chroma-Top */
-};
-
-static const uint32_t table_mb_non_intra2[128][2] = {
-{0x0000A7, 14}, {0x01B2B8, 18}, {0x01B28E, 18}, {0x036575, 19},
-{0x006CAC, 16}, {0x000A69, 18}, {0x002934, 20}, {0x00526B, 21},
-{0x006CA1, 16}, {0x01B2B9, 18}, {0x0029AD, 20}, {0x029353, 24},
-{0x006CA7, 16}, {0x006CAB, 16}, {0x01B2BB, 18}, {0x00029B, 16},
-{0x00D944, 17}, {0x000A6A, 18}, {0x0149A8, 23}, {0x03651F, 19},
-{0x006CAF, 16}, {0x000A4C, 18}, {0x03651E, 19}, {0x000A48, 18},
-{0x00299C, 20}, {0x00299F, 20}, {0x029352, 24}, {0x0029AC, 20},
-{0x000296, 16}, {0x00D946, 17}, {0x000A68, 18}, {0x000298, 16},
-{0x000527, 17}, {0x00D94D, 17}, {0x0014D7, 19}, {0x036574, 19},
-{0x000A5C, 18}, {0x01B299, 18}, {0x00299D, 20}, {0x00299E, 20},
-{0x000525, 17}, {0x000A66, 18}, {0x00A4D5, 22}, {0x00149B, 19},
-{0x000295, 16}, {0x006CAD, 16}, {0x000A49, 18}, {0x000521, 17},
-{0x006CAA, 16}, {0x00D945, 17}, {0x01B298, 18}, {0x00052F, 17},
-{0x003654, 15}, {0x006CA0, 16}, {0x000532, 17}, {0x000291, 16},
-{0x003652, 15}, {0x000520, 17}, {0x000A5D, 18}, {0x000294, 16},
-{0x00009B, 11}, {0x0006E2, 12}, {0x000028, 12}, {0x0001B0, 10},
-{0x000001, 3}, {0x000010, 8}, {0x00002F, 6}, {0x00004C, 10},
-{0x00000D, 4}, {0x000000, 10}, {0x000006, 9}, {0x000134, 12},
-{0x00000C, 4}, {0x000007, 10}, {0x000007, 9}, {0x0006E1, 12},
-{0x00000E, 5}, {0x0000DA, 9}, {0x000022, 9}, {0x000364, 11},
-{0x00000F, 4}, {0x000006, 10}, {0x00000F, 9}, {0x000135, 12},
-{0x000014, 5}, {0x0000DD, 9}, {0x000004, 9}, {0x000015, 11},
-{0x00001A, 6}, {0x0001B3, 10}, {0x000005, 10}, {0x0006E3, 12},
-{0x00000C, 5}, {0x0000B9, 8}, {0x000004, 8}, {0x0000DB, 9},
-{0x00000E, 4}, {0x00000B, 10}, {0x000023, 9}, {0x0006CB, 12},
-{0x000005, 6}, {0x0001B1, 10}, {0x000001, 10}, {0x0006E0, 12},
-{0x000011, 5}, {0x0000DF, 9}, {0x00000E, 9}, {0x000373, 11},
-{0x000003, 5}, {0x0000B8, 8}, {0x000006, 8}, {0x000175, 9},
-{0x000015, 5}, {0x000174, 9}, {0x000027, 9}, {0x000372, 11},
-{0x000010, 5}, {0x0000BB, 8}, {0x000005, 8}, {0x0000DE, 9},
-{0x00000F, 5}, {0x000001, 9}, {0x000012, 8}, {0x000004, 10},
-{0x000002, 3}, {0x000016, 5}, {0x000009, 4}, {0x000001, 5},
-};
-
-static const uint32_t table_mb_non_intra3[128][2] = {
-{0x0002A1, 10}, {0x005740, 15}, {0x01A0BF, 18}, {0x015D19, 17},
-{0x001514, 13}, {0x00461E, 15}, {0x015176, 17}, {0x015177, 17},
-{0x0011AD, 13}, {0x00682E, 16}, {0x0682F9, 20}, {0x03417D, 19},
-{0x001A36, 14}, {0x002A2D, 14}, {0x00D05E, 17}, {0x006824, 16},
-{0x001515, 13}, {0x00545C, 15}, {0x0230E9, 18}, {0x011AFA, 17},
-{0x0015D7, 13}, {0x005747, 15}, {0x008D79, 16}, {0x006825, 16},
-{0x002BA2, 14}, {0x00A8BA, 16}, {0x0235F6, 18}, {0x015D18, 17},
-{0x0011AE, 13}, {0x00346F, 15}, {0x008C3B, 16}, {0x00346E, 15},
-{0x000D1A, 13}, {0x00461F, 15}, {0x0682F8, 20}, {0x011875, 17},
-{0x002BA1, 14}, {0x008D61, 16}, {0x0235F7, 18}, {0x0230E8, 18},
-{0x001513, 13}, {0x008D7B, 16}, {0x011AF4, 17}, {0x011AF5, 17},
-{0x001185, 13}, {0x0046BF, 15}, {0x008D60, 16}, {0x008D7C, 16},
-{0x001512, 13}, {0x00461C, 15}, {0x00AE8D, 16}, {0x008D78, 16},
-{0x000D0E, 13}, {0x003413, 15}, {0x0046B1, 15}, {0x003416, 15},
-{0x000AEA, 12}, {0x002A2C, 14}, {0x005741, 15}, {0x002A2F, 14},
-{0x000158, 9}, {0x0008D2, 12}, {0x00054C, 11}, {0x000686, 12},
-{0x000000, 2}, {0x000069, 8}, {0x00006B, 8}, {0x00068C, 12},
-{0x000007, 3}, {0x00015E, 9}, {0x0002A3, 10}, {0x000AE9, 12},
-{0x000006, 3}, {0x000231, 10}, {0x0002B8, 10}, {0x001A08, 14},
-{0x000010, 5}, {0x0001A9, 10}, {0x000342, 11}, {0x000A88, 12},
-{0x000004, 4}, {0x0001A2, 10}, {0x0002A4, 10}, {0x001184, 13},
-{0x000012, 5}, {0x000232, 10}, {0x0002B2, 10}, {0x000680, 12},
-{0x00001B, 6}, {0x00046A, 11}, {0x00068E, 12}, {0x002359, 14},
-{0x000016, 5}, {0x00015F, 9}, {0x0002A0, 10}, {0x00054D, 11},
-{0x000005, 4}, {0x000233, 10}, {0x0002B9, 10}, {0x0015D6, 13},
-{0x000022, 6}, {0x000468, 11}, {0x000683, 12}, {0x001A0A, 14},
-{0x000013, 5}, {0x000236, 10}, {0x0002BB, 10}, {0x001186, 13},
-{0x000017, 5}, {0x0001AB, 10}, {0x0002A7, 10}, {0x0008D3, 12},
-{0x000014, 5}, {0x000237, 10}, {0x000460, 11}, {0x000D0F, 13},
-{0x000019, 6}, {0x0001AA, 10}, {0x0002B3, 10}, {0x000681, 12},
-{0x000018, 6}, {0x0001A8, 10}, {0x0002A5, 10}, {0x00068F, 12},
-{0x000007, 4}, {0x000055, 7}, {0x000047, 7}, {0x0000AD, 8},
-};
-
-static const uint32_t table_mb_non_intra4[128][2] = {
-{0x0000D4, 8}, {0x0021C5, 14}, {0x00F18A, 16}, {0x00D5BC, 16},
-{0x000879, 12}, {0x00354D, 14}, {0x010E3F, 17}, {0x010F54, 17},
-{0x000866, 12}, {0x00356E, 14}, {0x010F55, 17}, {0x010E3E, 17},
-{0x0010CE, 13}, {0x003C84, 14}, {0x00D5BD, 16}, {0x00F18B, 16},
-{0x000868, 12}, {0x00438C, 15}, {0x0087AB, 16}, {0x00790B, 15},
-{0x000F10, 12}, {0x00433D, 15}, {0x006AD3, 15}, {0x00790A, 15},
-{0x001AA7, 13}, {0x0043D4, 15}, {0x00871E, 16}, {0x006ADF, 15},
-{0x000D7C, 12}, {0x003C94, 14}, {0x00438D, 15}, {0x006AD2, 15},
-{0x0006BC, 11}, {0x0021E9, 14}, {0x006ADA, 15}, {0x006A99, 15},
-{0x0010F7, 13}, {0x004389, 15}, {0x006ADB, 15}, {0x0078C4, 15},
-{0x000D56, 12}, {0x0035F7, 14}, {0x00438E, 15}, {0x006A98, 15},
-{0x000D52, 12}, {0x003C95, 14}, {0x004388, 15}, {0x00433C, 15},
-{0x000D54, 12}, {0x001E4B, 13}, {0x003C63, 14}, {0x003C83, 14},
-{0x000861, 12}, {0x0021EB, 14}, {0x00356C, 14}, {0x0035F6, 14},
-{0x000863, 12}, {0x00219F, 14}, {0x003568, 14}, {0x003C82, 14},
-{0x0001AE, 9}, {0x0010C0, 13}, {0x000F11, 12}, {0x001AFA, 13},
-{0x000000, 1}, {0x0000F0, 8}, {0x0001AD, 9}, {0x0010C1, 13},
-{0x00000A, 4}, {0x0003C5, 10}, {0x000789, 11}, {0x001AB5, 13},
-{0x000009, 4}, {0x000435, 11}, {0x000793, 11}, {0x001E40, 13},
-{0x00001D, 5}, {0x0003CB, 10}, {0x000878, 12}, {0x001AAF, 13},
-{0x00000B, 4}, {0x0003C7, 10}, {0x000791, 11}, {0x001AAB, 13},
-{0x00001F, 5}, {0x000436, 11}, {0x0006BF, 11}, {0x000F19, 12},
-{0x00003D, 6}, {0x000D51, 12}, {0x0010C4, 13}, {0x0021E8, 14},
-{0x000036, 6}, {0x000437, 11}, {0x0006AF, 11}, {0x0010C5, 13},
-{0x00000C, 4}, {0x000432, 11}, {0x000794, 11}, {0x001E30, 13},
-{0x000042, 7}, {0x000870, 12}, {0x000F24, 12}, {0x001E43, 13},
-{0x000020, 6}, {0x00043E, 11}, {0x000795, 11}, {0x001AAA, 13},
-{0x000037, 6}, {0x0006AC, 11}, {0x0006AE, 11}, {0x0010F6, 13},
-{0x000034, 6}, {0x00043A, 11}, {0x000D50, 12}, {0x001AAE, 13},
-{0x000039, 6}, {0x00043F, 11}, {0x00078D, 11}, {0x0010D2, 13},
-{0x000038, 6}, {0x00043B, 11}, {0x0006BD, 11}, {0x0010D3, 13},
-{0x000011, 5}, {0x0001AC, 9}, {0x0000F3, 8}, {0x000439, 11},
-};
-
-const uint32_t (* const ff_wmv2_inter_table[WMV2_INTER_CBP_TABLE_COUNT])[2]={
- table_mb_non_intra2,
- table_mb_non_intra3,
- table_mb_non_intra4,
- ff_table_mb_non_intra,
-};
-
-const uint8_t ff_wmv2_scantableA[64]={
-0x00, 0x01, 0x02, 0x08, 0x03, 0x09, 0x0A, 0x10,
-0x04, 0x0B, 0x11, 0x18, 0x12, 0x0C, 0x05, 0x13,
-0x19, 0x0D, 0x14, 0x1A, 0x1B, 0x06, 0x15, 0x1C,
-0x0E, 0x16, 0x1D, 0x07, 0x1E, 0x0F, 0x17, 0x1F,
-};
-
-const uint8_t ff_wmv2_scantableB[64]={
-0x00, 0x08, 0x01, 0x10, 0x09, 0x18, 0x11, 0x02,
-0x20, 0x0A, 0x19, 0x28, 0x12, 0x30, 0x21, 0x1A,
-0x38, 0x29, 0x22, 0x03, 0x31, 0x39, 0x0B, 0x2A,
-0x13, 0x32, 0x1B, 0x3A, 0x23, 0x2B, 0x33, 0x3B,
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/msmpeg4data.h b/src/thirdparty/ffmpeg/libavcodec/msmpeg4data.h
deleted file mode 100644
index 2ffd9adb1..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/msmpeg4data.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * MSMPEG4 backend for encoder and decoder
- * copyright (c) 2001 Fabrice Bellard
- * copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
- *
- * msmpeg4v1 & v2 stuff 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
- * MSMPEG4 data tables.
- */
-
-#ifndef AVCODEC_MSMPEG4DATA_H
-#define AVCODEC_MSMPEG4DATA_H
-
-#include "libavutil/common.h"
-#include "get_bits.h"
-#include "rl.h"
-
-/* motion vector table */
-typedef struct MVTable {
- int n;
- const uint16_t *table_mv_code;
- const uint8_t *table_mv_bits;
- const uint8_t *table_mvx;
- const uint8_t *table_mvy;
- uint16_t *table_mv_index; /* encoding: convert mv to index in table_mv */
- VLC vlc; /* decoding: vlc */
-} MVTable;
-
-extern VLC ff_msmp4_mb_i_vlc;
-extern VLC ff_msmp4_dc_luma_vlc[2];
-extern VLC ff_msmp4_dc_chroma_vlc[2];
-
-/* intra picture macroblock coded block pattern */
-extern const uint16_t ff_msmp4_mb_i_table[64][2];
-
-#define WMV1_SCANTABLE_COUNT 4
-
-extern const uint8_t ff_wmv1_scantable[WMV1_SCANTABLE_COUNT][64];
-
-#define NB_RL_TABLES 6
-
-extern RLTable ff_rl_table[NB_RL_TABLES];
-extern uint8_t ff_static_rl_table_store[NB_RL_TABLES][2][2 * MAX_RUN + MAX_LEVEL + 3];
-
-extern uint32_t ff_v2_dc_lum_table[512][2];
-extern uint32_t ff_v2_dc_chroma_table[512][2];
-
-extern const uint8_t ff_wmv1_y_dc_scale_table[32];
-extern const uint8_t ff_wmv1_c_dc_scale_table[32];
-extern const uint8_t ff_old_ff_y_dc_scale_table[32];
-
-extern MVTable ff_mv_tables[2];
-
-extern const uint8_t ff_v2_mb_type[8][2];
-extern const uint8_t ff_v2_intra_cbpc[4][2];
-
-extern const uint32_t ff_table_mb_non_intra[128][2];
-extern const uint8_t ff_table_inter_intra[4][2];
-
-extern const uint32_t ff_table0_dc_lum[120][2];
-extern const uint32_t ff_table1_dc_lum[120][2];
-extern const uint32_t ff_table0_dc_chroma[120][2];
-extern const uint32_t ff_table1_dc_chroma[120][2];
-
-#define WMV2_INTER_CBP_TABLE_COUNT 4
-extern const uint32_t (* const ff_wmv2_inter_table[WMV2_INTER_CBP_TABLE_COUNT])[2];
-
-extern const uint8_t ff_wmv2_scantableA[64];
-extern const uint8_t ff_wmv2_scantableB[64];
-
-#endif /* AVCODEC_MSMPEG4DATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/msrle.c b/src/thirdparty/ffmpeg/libavcodec/msrle.c
deleted file mode 100644
index a4b9ad043..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/msrle.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Microsoft RLE video decoder
- * Copyright (C) 2003 the ffmpeg project
- *
- * 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
- * MS RLE video decoder by Mike Melanson (melanson@pcisys.net)
- * For more information about the MS RLE format, visit:
- * http://www.pcisys.net/~melanson/codecs/
- *
- * The MS RLE decoder outputs PAL8 colorspace data.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "avcodec.h"
-#include "dsputil.h"
-#include "msrledec.h"
-
-typedef struct MsrleContext {
- AVCodecContext *avctx;
- AVFrame frame;
-
- GetByteContext gb;
- const unsigned char *buf;
- int size;
-
- uint32_t pal[256];
-} MsrleContext;
-
-static av_cold int msrle_decode_init(AVCodecContext *avctx)
-{
- MsrleContext *s = avctx->priv_data;
- int i;
-
- s->avctx = avctx;
-
- switch (avctx->bits_per_coded_sample) {
- case 1:
- avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
- break;
- case 4:
- case 8:
- avctx->pix_fmt = AV_PIX_FMT_PAL8;
- break;
- case 24:
- avctx->pix_fmt = AV_PIX_FMT_BGR24;
- break;
- default:
- av_log(avctx, AV_LOG_ERROR, "unsupported bits per sample\n");
- return AVERROR_INVALIDDATA;
- }
-
- avcodec_get_frame_defaults(&s->frame);
- s->frame.data[0] = NULL;
-
- if (avctx->extradata_size >= 4)
- for (i = 0; i < FFMIN(avctx->extradata_size, AVPALETTE_SIZE)/4; i++)
- s->pal[i] = 0xFFU<<24 | AV_RL32(avctx->extradata+4*i);
-
- return 0;
-}
-
-static int msrle_decode_frame(AVCodecContext *avctx,
- void *data, int *got_frame,
- AVPacket *avpkt)
-{
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
- MsrleContext *s = avctx->priv_data;
- int istride = FFALIGN(avctx->width*avctx->bits_per_coded_sample, 32) / 8;
- int ret;
-
- s->buf = buf;
- s->size = buf_size;
-
- s->frame.reference = 3;
- s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
- if ((ret = avctx->reget_buffer(avctx, &s->frame)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
- return ret;
- }
-
- if (avctx->bits_per_coded_sample > 1 && avctx->bits_per_coded_sample <= 8) {
- const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
-
- if (pal) {
- s->frame.palette_has_changed = 1;
- memcpy(s->pal, pal, AVPALETTE_SIZE);
- }
- /* make the palette available */
- memcpy(s->frame.data[1], s->pal, AVPALETTE_SIZE);
- }
-
- /* 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;
- uint8_t *ptr = s->frame.data[0];
- uint8_t *buf = avpkt->data + (avctx->height-1)*istride;
- int i, j;
-
- for (i = 0; i < avctx->height; i++) {
- if (avctx->bits_per_coded_sample == 4) {
- for (j = 0; j < avctx->width - 1; j += 2) {
- ptr[j+0] = buf[j>>1] >> 4;
- ptr[j+1] = buf[j>>1] & 0xF;
- }
- if (avctx->width & 1)
- ptr[j+0] = buf[j>>1] >> 4;
- } else {
- memcpy(ptr, buf, linesize);
- }
- buf -= istride;
- ptr += s->frame.linesize[0];
- }
- } else {
- bytestream2_init(&s->gb, buf, buf_size);
- ff_msrle_decode(avctx, (AVPicture*)&s->frame, avctx->bits_per_coded_sample, &s->gb);
- }
-
- *got_frame = 1;
- *(AVFrame*)data = s->frame;
-
- /* report that the buffer was completely consumed */
- return buf_size;
-}
-
-static av_cold int msrle_decode_end(AVCodecContext *avctx)
-{
- MsrleContext *s = avctx->priv_data;
-
- /* release the last frame */
- if (s->frame.data[0])
- avctx->release_buffer(avctx, &s->frame);
-
- return 0;
-}
-
-AVCodec ff_msrle_decoder = {
- .name = "msrle",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_MSRLE,
- .priv_data_size = sizeof(MsrleContext),
- .init = msrle_decode_init,
- .close = msrle_decode_end,
- .decode = msrle_decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("Microsoft RLE"),
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/msrledec.c b/src/thirdparty/ffmpeg/libavcodec/msrledec.c
deleted file mode 100644
index 8f047c024..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/msrledec.c
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Microsoft RLE decoder
- * Copyright (C) 2008 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
- */
-
-/**
- * @file
- * MS RLE decoder based on decoder by Mike Melanson and my own for TSCC
- * For more information about the MS RLE format, visit:
- * http://www.multimedia.cx/msrle.txt
- */
-
-#include "libavutil/intreadwrite.h"
-#include "avcodec.h"
-#include "msrledec.h"
-
-static int msrle_decode_pal4(AVCodecContext *avctx, AVPicture *pic,
- GetByteContext *gb)
-{
- unsigned char rle_code;
- unsigned char extra_byte, odd_pixel;
- unsigned char stream_byte;
- unsigned int pixel_ptr = 0;
- int row_dec = pic->linesize[0];
- int row_ptr = (avctx->height - 1) * row_dec;
- int frame_size = row_dec * avctx->height;
- int i;
-
- while (row_ptr >= 0) {
- if (bytestream2_get_bytes_left(gb) <= 0) {
- av_log(avctx, AV_LOG_ERROR,
- "MS RLE: bytestream overrun, %d rows left\n",
- row_ptr);
- return AVERROR_INVALIDDATA;
- }
- rle_code = stream_byte = bytestream2_get_byteu(gb);
- if (rle_code == 0) {
- /* fetch the next byte to see how to handle escape code */
- stream_byte = bytestream2_get_byte(gb);
- if (stream_byte == 0) {
- /* line is done, goto the next one */
- row_ptr -= row_dec;
- pixel_ptr = 0;
- } else if (stream_byte == 1) {
- /* decode is done */
- return 0;
- } else if (stream_byte == 2) {
- /* reposition frame decode coordinates */
- stream_byte = bytestream2_get_byte(gb);
- pixel_ptr += stream_byte;
- stream_byte = bytestream2_get_byte(gb);
- row_ptr -= stream_byte * row_dec;
- } else {
- // copy pixels from encoded stream
- odd_pixel = stream_byte & 1;
- rle_code = (stream_byte + 1) / 2;
- extra_byte = rle_code & 0x01;
- if (row_ptr + pixel_ptr + stream_byte > frame_size ||
- bytestream2_get_bytes_left(gb) < rle_code) {
- av_log(avctx, AV_LOG_ERROR,
- "MS RLE: frame/stream ptr just went out of bounds (copy)\n");
- return AVERROR_INVALIDDATA;
- }
-
- for (i = 0; i < rle_code; i++) {
- if (pixel_ptr >= avctx->width)
- break;
- stream_byte = bytestream2_get_byteu(gb);
- pic->data[0][row_ptr + pixel_ptr] = stream_byte >> 4;
- pixel_ptr++;
- if (i + 1 == rle_code && odd_pixel)
- break;
- if (pixel_ptr >= avctx->width)
- break;
- pic->data[0][row_ptr + pixel_ptr] = stream_byte & 0x0F;
- pixel_ptr++;
- }
-
- // if the RLE code is odd, skip a byte in the stream
- if (extra_byte)
- bytestream2_skip(gb, 1);
- }
- } else {
- // decode a run of data
- if (row_ptr + pixel_ptr + stream_byte > frame_size) {
- av_log(avctx, AV_LOG_ERROR,
- "MS RLE: frame ptr just went out of bounds (run)\n");
- return AVERROR_INVALIDDATA;
- }
- stream_byte = bytestream2_get_byte(gb);
- for (i = 0; i < rle_code; i++) {
- if (pixel_ptr >= avctx->width)
- break;
- if ((i & 1) == 0)
- pic->data[0][row_ptr + pixel_ptr] = stream_byte >> 4;
- else
- pic->data[0][row_ptr + pixel_ptr] = stream_byte & 0x0F;
- pixel_ptr++;
- }
- }
- }
-
- /* one last sanity check on the way out */
- if (bytestream2_get_bytes_left(gb)) {
- av_log(avctx, AV_LOG_ERROR,
- "MS RLE: ended frame decode with %d bytes left over\n",
- bytestream2_get_bytes_left(gb));
- return AVERROR_INVALIDDATA;
- }
-
- return 0;
-}
-
-
-static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic,
- int depth, GetByteContext *gb)
-{
- uint8_t *output, *output_end;
- int p1, p2, line=avctx->height - 1, pos=0, i;
- uint16_t pix16;
- uint32_t pix32;
- unsigned int width= FFABS(pic->linesize[0]) / (depth >> 3);
-
- output = pic->data[0] + (avctx->height - 1) * pic->linesize[0];
- output_end = pic->data[0] + avctx->height * pic->linesize[0];
- while (bytestream2_get_bytes_left(gb) > 0) {
- p1 = bytestream2_get_byteu(gb);
- if(p1 == 0) { //Escape code
- p2 = bytestream2_get_byte(gb);
- if(p2 == 0) { //End-of-line
- if (--line < 0) {
- if (bytestream2_get_be16(gb) == 1) { // end-of-picture
- return 0;
- } else {
- av_log(avctx, AV_LOG_ERROR,
- "Next line is beyond picture bounds (%d bytes left)\n",
- bytestream2_get_bytes_left(gb));
- return AVERROR_INVALIDDATA;
- }
- }
- output = pic->data[0] + line * pic->linesize[0];
- pos = 0;
- continue;
- } else if(p2 == 1) { //End-of-picture
- return 0;
- } else if(p2 == 2) { //Skip
- p1 = bytestream2_get_byte(gb);
- p2 = bytestream2_get_byte(gb);
- line -= p2;
- pos += p1;
- if (line < 0 || pos >= width){
- av_log(avctx, AV_LOG_ERROR, "Skip beyond picture bounds\n");
- return -1;
- }
- output = pic->data[0] + line * pic->linesize[0] + pos * (depth >> 3);
- continue;
- }
- // Copy data
- if ((pic->linesize[0] > 0 && output + p2 * (depth >> 3) > output_end) ||
- (pic->linesize[0] < 0 && output + p2 * (depth >> 3) < output_end)) {
- bytestream2_skip(gb, 2 * (depth >> 3));
- continue;
- } else if (bytestream2_get_bytes_left(gb) < p2 * (depth >> 3)) {
- av_log(avctx, AV_LOG_ERROR, "bytestream overrun\n");
- return AVERROR_INVALIDDATA;
- }
-
- if ((depth == 8) || (depth == 24)) {
- for(i = 0; i < p2 * (depth >> 3); i++) {
- *output++ = bytestream2_get_byteu(gb);
- }
- // RLE8 copy is actually padded - and runs are not!
- if(depth == 8 && (p2 & 1)) {
- bytestream2_skip(gb, 1);
- }
- } else if (depth == 16) {
- for(i = 0; i < p2; i++) {
- *(uint16_t*)output = bytestream2_get_le16u(gb);
- output += 2;
- }
- } else if (depth == 32) {
- for(i = 0; i < p2; i++) {
- *(uint32_t*)output = bytestream2_get_le32u(gb);
- output += 4;
- }
- }
- pos += p2;
- } else { //run of pixels
- uint8_t pix[3]; //original pixel
- if ((pic->linesize[0] > 0 && output + p1 * (depth >> 3) > output_end) ||
- (pic->linesize[0] < 0 && output + p1 * (depth >> 3) < output_end))
- continue;
-
- switch(depth){
- case 8:
- pix[0] = bytestream2_get_byte(gb);
- for(i = 0; i < p1; i++)
- *output++ = pix[0];
- break;
- case 16:
- pix16 = bytestream2_get_le16(gb);
- for(i = 0; i < p1; i++) {
- *(uint16_t*)output = pix16;
- output += 2;
- }
- break;
- case 24:
- pix[0] = bytestream2_get_byte(gb);
- pix[1] = bytestream2_get_byte(gb);
- pix[2] = bytestream2_get_byte(gb);
- for(i = 0; i < p1; i++) {
- *output++ = pix[0];
- *output++ = pix[1];
- *output++ = pix[2];
- }
- break;
- case 32:
- pix32 = bytestream2_get_le32(gb);
- for(i = 0; i < p1; i++) {
- *(uint32_t*)output = pix32;
- output += 4;
- }
- break;
- }
- pos += p1;
- }
- }
-
- av_log(avctx, AV_LOG_WARNING, "MS RLE warning: no end-of-picture code\n");
- return 0;
-}
-
-
-int ff_msrle_decode(AVCodecContext *avctx, AVPicture *pic,
- int depth, GetByteContext *gb)
-{
- switch(depth){
- case 4:
- return msrle_decode_pal4(avctx, pic, gb);
- case 8:
- case 16:
- case 24:
- case 32:
- return msrle_decode_8_16_24_32(avctx, pic, depth, gb);
- default:
- av_log(avctx, AV_LOG_ERROR, "Unknown depth %d\n", depth);
- return -1;
- }
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/msrledec.h b/src/thirdparty/ffmpeg/libavcodec/msrledec.h
deleted file mode 100644
index 1586b5c40..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/msrledec.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Microsoft RLE decoder
- * Copyright (C) 2008 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_MSRLEDEC_H
-#define AVCODEC_MSRLEDEC_H
-
-#include "avcodec.h"
-#include "bytestream.h"
-
-/**
- * Decode stream in MS RLE format into frame.
- *
- * @param avctx codec context
- * @param pic destination frame
- * @param depth bit depth
- * @param gb input bytestream context
- */
-int ff_msrle_decode(AVCodecContext *avctx, AVPicture *pic,
- int depth, GetByteContext *gb);
-
-#endif /* AVCODEC_MSRLEDEC_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/nellymoser.c b/src/thirdparty/ffmpeg/libavcodec/nellymoser.c
deleted file mode 100644
index 359bcff6b..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/nellymoser.c
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Common code between Nellymoser encoder and decoder
- * Copyright (c) 2007 a840bda5870ba11f19698ff6eb9581dfb0f95fa5,
- * 539459aeb7d425140b62a3ec7dbf6dc8e408a306, and
- * 520e17cd55896441042b14df2566a6eb610ed444
- * Copyright (c) 2007 Loic Minier <lool at dooz.org>
- * Benjamin Larsson
- *
- * 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.
- */
-
-/**
- * @file
- * The 3 alphanumeric copyright notices are md5summed they are from the original
- * implementors. The original code is available from http://code.google.com/p/nelly2pcm/
- */
-
-#include "nellymoser.h"
-#include "avcodec.h"
-#include "dsputil.h"
-
-#define BITSTREAM_READER_LE
-#include "get_bits.h"
-
-const float ff_nelly_dequantization_table[127] = {
- 0.0000000000,
-
--0.8472560048, 0.7224709988,
-
--1.5247479677,-0.4531480074, 0.3753609955, 1.4717899561,
-
--1.9822579622,-1.1929379702,-0.5829370022,-0.0693780035, 0.3909569979, 0.9069200158, 1.4862740040, 2.2215409279,
-
--2.3887870312,-1.8067539930,-1.4105420113,-1.0773609877,-0.7995010018,-0.5558109879,-0.3334020078,-0.1324490011,
- 0.0568020009, 0.2548770010, 0.4773550034, 0.7386850119, 1.0443060398, 1.3954459429, 1.8098750114, 2.3918759823,
-
--2.3893830776,-1.9884680510,-1.7514040470,-1.5643119812,-1.3922129869,-1.2164649963,-1.0469499826,-0.8905100226,
--0.7645580173,-0.6454579830,-0.5259280205,-0.4059549868,-0.3029719889,-0.2096900046,-0.1239869967,-0.0479229987,
- 0.0257730000, 0.1001340002, 0.1737180054, 0.2585540116, 0.3522900045, 0.4569880068, 0.5767750144, 0.7003160119,
- 0.8425520062, 1.0093879700, 1.1821349859, 1.3534560204, 1.5320819616, 1.7332619429, 1.9722349644, 2.3978140354,
-
--2.5756309032,-2.0573320389,-1.8984919786,-1.7727810144,-1.6662600040,-1.5742180347,-1.4993319511,-1.4316639900,
--1.3652280569,-1.3000990152,-1.2280930281,-1.1588579416,-1.0921250582,-1.0135740042,-0.9202849865,-0.8287050128,
--0.7374889851,-0.6447759867,-0.5590940118,-0.4857139885,-0.4110319912,-0.3459700048,-0.2851159871,-0.2341620028,
--0.1870580018,-0.1442500055,-0.1107169986,-0.0739680007,-0.0365610011,-0.0073290002, 0.0203610007, 0.0479039997,
- 0.0751969963, 0.0980999991, 0.1220389977, 0.1458999962, 0.1694349945, 0.1970459968, 0.2252430022, 0.2556869984,
- 0.2870100141, 0.3197099864, 0.3525829911, 0.3889069855, 0.4334920049, 0.4769459963, 0.5204820037, 0.5644530058,
- 0.6122040153, 0.6685929894, 0.7341650128, 0.8032159805, 0.8784040213, 0.9566209912, 1.0397069454, 1.1293770075,
- 1.2211159468, 1.3080279827, 1.4024800062, 1.5056819916, 1.6227730513, 1.7724959850, 1.9430880547, 2.2903931141
-};
-
-const uint8_t ff_nelly_band_sizes_table[NELLY_BANDS] = {
-2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 7, 8, 9, 10, 12, 14, 15
-};
-
-const uint16_t ff_nelly_init_table[64] = {
-3134, 5342, 6870, 7792, 8569, 9185, 9744, 10191, 10631, 11061, 11434, 11770,
-12116, 12513, 12925, 13300, 13674, 14027, 14352, 14716, 15117, 15477, 15824,
-16157, 16513, 16804, 17090, 17401, 17679, 17948, 18238, 18520, 18764, 19078,
-19381, 19640, 19921, 20205, 20500, 20813, 21162, 21465, 21794, 22137, 22453,
-22756, 23067, 23350, 23636, 23926, 24227, 24521, 24819, 25107, 25414, 25730,
-26120, 26497, 26895, 27344, 27877, 28463, 29426, 31355
-};
-
-const int16_t ff_nelly_delta_table[32] = {
--11725, -9420, -7910, -6801, -5948, -5233, -4599, -4039, -3507, -3030, -2596,
--2170, -1774, -1383, -1016, -660, -329, -1, 337, 696, 1085, 1512, 1962, 2433,
-2968, 3569, 4314, 5279, 6622, 8154, 10076, 12975
-};
-
-static inline int signed_shift(int i, int shift) {
- if (shift > 0)
- return i << shift;
- return i >> -shift;
-}
-
-static int sum_bits(short *buf, short shift, short off)
-{
- int i, ret = 0;
-
- for (i = 0; i < NELLY_FILL_LEN; i++) {
- int b = buf[i]-off;
- b = ((b>>(shift-1))+1)>>1;
- ret += av_clip(b, 0, NELLY_BIT_CAP);
- }
-
- return ret;
-}
-
-static int headroom(int *la)
-{
- int l;
- if (*la == 0) {
- return 31;
- }
- l = 30 - av_log2(FFABS(*la));
- *la <<= l;
- return l;
-}
-
-
-void ff_nelly_get_sample_bits(const float *buf, int *bits)
-{
- int i, j;
- short sbuf[128];
- int bitsum = 0, last_bitsum, small_bitsum, big_bitsum;
- short shift, shift_saved;
- int max, sum, last_off, tmp;
- int big_off, small_off;
- int off;
-
- max = 0;
- for (i = 0; i < NELLY_FILL_LEN; i++) {
- max = FFMAX(max, buf[i]);
- }
- shift = -16;
- shift += headroom(&max);
-
- sum = 0;
- for (i = 0; i < NELLY_FILL_LEN; i++) {
- sbuf[i] = signed_shift(buf[i], shift);
- sbuf[i] = (3*sbuf[i])>>2;
- sum += sbuf[i];
- }
-
- shift += 11;
- shift_saved = shift;
- sum -= NELLY_DETAIL_BITS << shift;
- shift += headroom(&sum);
- small_off = (NELLY_BASE_OFF * (sum>>16)) >> 15;
- shift = shift_saved - (NELLY_BASE_SHIFT+shift-31);
-
- small_off = signed_shift(small_off, shift);
-
- bitsum = sum_bits(sbuf, shift_saved, small_off);
-
- if (bitsum != NELLY_DETAIL_BITS) {
- off = bitsum - NELLY_DETAIL_BITS;
-
- for(shift=0; FFABS(off) <= 16383; shift++)
- off *= 2;
-
- off = (off * NELLY_BASE_OFF) >> 15;
- shift = shift_saved-(NELLY_BASE_SHIFT+shift-15);
-
- off = signed_shift(off, shift);
-
- for (j = 1; j < 20; j++) {
- last_off = small_off;
- small_off += off;
- last_bitsum = bitsum;
-
- bitsum = sum_bits(sbuf, shift_saved, small_off);
-
- if ((bitsum-NELLY_DETAIL_BITS) * (last_bitsum-NELLY_DETAIL_BITS) <= 0)
- break;
- }
-
- if (bitsum > NELLY_DETAIL_BITS) {
- big_off = small_off;
- small_off = last_off;
- big_bitsum=bitsum;
- small_bitsum=last_bitsum;
- } else {
- big_off = last_off;
- big_bitsum=last_bitsum;
- small_bitsum=bitsum;
- }
-
- while (bitsum != NELLY_DETAIL_BITS && j <= 19) {
- off = (big_off+small_off)>>1;
- bitsum = sum_bits(sbuf, shift_saved, off);
- if (bitsum > NELLY_DETAIL_BITS) {
- big_off=off;
- big_bitsum=bitsum;
- } else {
- small_off = off;
- small_bitsum=bitsum;
- }
- j++;
- }
-
- if (abs(big_bitsum-NELLY_DETAIL_BITS) >=
- abs(small_bitsum-NELLY_DETAIL_BITS)) {
- bitsum = small_bitsum;
- } else {
- small_off = big_off;
- bitsum = big_bitsum;
- }
- }
-
- for (i = 0; i < NELLY_FILL_LEN; i++) {
- tmp = sbuf[i]-small_off;
- tmp = ((tmp>>(shift_saved-1))+1)>>1;
- bits[i] = av_clip(tmp, 0, NELLY_BIT_CAP);
- }
-
- if (bitsum > NELLY_DETAIL_BITS) {
- tmp = i = 0;
- while (tmp < NELLY_DETAIL_BITS) {
- tmp += bits[i];
- i++;
- }
-
- bits[i-1] -= tmp - NELLY_DETAIL_BITS;
- for(; i < NELLY_FILL_LEN; i++)
- bits[i] = 0;
- }
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/nellymoser.h b/src/thirdparty/ffmpeg/libavcodec/nellymoser.h
deleted file mode 100644
index 35e29ba4b..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/nellymoser.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Common code between Nellymoser encoder and decoder
- * Copyright (c) 2007 a840bda5870ba11f19698ff6eb9581dfb0f95fa5,
- * 539459aeb7d425140b62a3ec7dbf6dc8e408a306, and
- * 520e17cd55896441042b14df2566a6eb610ed444
- * Copyright (c) 2007 Loic Minier <lool at dooz.org>
- * Benjamin Larsson
- *
- * 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.
- */
-
-/**
- * @file
- * The 3 alphanumeric copyright notices are md5summed they are from the original
- * implementors. The original code is available from http://code.google.com/p/nelly2pcm/
- */
-
-#ifndef AVCODEC_NELLYMOSER_H
-#define AVCODEC_NELLYMOSER_H
-
-#include "avcodec.h"
-
-#define NELLY_BANDS 23
-#define NELLY_BLOCK_LEN 64
-#define NELLY_HEADER_BITS 116
-#define NELLY_DETAIL_BITS 198
-#define NELLY_BUF_LEN 128
-#define NELLY_FILL_LEN 124
-#define NELLY_BIT_CAP 6
-#define NELLY_BASE_OFF 4228
-#define NELLY_BASE_SHIFT 19
-#define NELLY_SAMPLES (2 * NELLY_BUF_LEN)
-
-extern const float ff_nelly_dequantization_table[127];
-extern const uint8_t ff_nelly_band_sizes_table[NELLY_BANDS];
-extern const uint16_t ff_nelly_init_table[64];
-extern const int16_t ff_nelly_delta_table[32];
-
-void ff_nelly_get_sample_bits(const float *buf, int *bits);
-
-#endif /* AVCODEC_NELLYMOSER_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/nellymoserdec.c b/src/thirdparty/ffmpeg/libavcodec/nellymoserdec.c
deleted file mode 100644
index d9372253a..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/nellymoserdec.c
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * NellyMoser audio decoder
- * Copyright (c) 2007 a840bda5870ba11f19698ff6eb9581dfb0f95fa5,
- * 539459aeb7d425140b62a3ec7dbf6dc8e408a306, and
- * 520e17cd55896441042b14df2566a6eb610ed444
- * Copyright (c) 2007 Loic Minier <lool at dooz.org>
- * Benjamin Larsson
- *
- * 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.
- */
-
-/**
- * @file
- * The 3 alphanumeric copyright notices are md5summed they are from the original
- * implementors. The original code is available from http://code.google.com/p/nelly2pcm/
- */
-
-#include "libavutil/channel_layout.h"
-#include "libavutil/float_dsp.h"
-#include "libavutil/lfg.h"
-#include "libavutil/random_seed.h"
-#include "avcodec.h"
-#include "dsputil.h"
-#include "fft.h"
-#include "fmtconvert.h"
-#include "internal.h"
-#include "nellymoser.h"
-#include "sinewin.h"
-
-#define BITSTREAM_READER_LE
-#include "get_bits.h"
-
-
-typedef struct NellyMoserDecodeContext {
- AVCodecContext* avctx;
- AVLFG random_state;
- GetBitContext gb;
- float scale_bias;
- AVFloatDSPContext fdsp;
- FFTContext imdct_ctx;
- DECLARE_ALIGNED(32, float, imdct_buf)[2][NELLY_BUF_LEN];
- float *imdct_out;
- float *imdct_prev;
-} NellyMoserDecodeContext;
-
-static void nelly_decode_block(NellyMoserDecodeContext *s,
- const unsigned char block[NELLY_BLOCK_LEN],
- float audio[NELLY_SAMPLES])
-{
- int i,j;
- float buf[NELLY_FILL_LEN], pows[NELLY_FILL_LEN];
- float *aptr, *bptr, *pptr, val, pval;
- int bits[NELLY_BUF_LEN];
- unsigned char v;
-
- init_get_bits(&s->gb, block, NELLY_BLOCK_LEN * 8);
-
- bptr = buf;
- pptr = pows;
- val = ff_nelly_init_table[get_bits(&s->gb, 6)];
- for (i=0 ; i<NELLY_BANDS ; i++) {
- if (i > 0)
- val += ff_nelly_delta_table[get_bits(&s->gb, 5)];
- pval = -pow(2, val/2048) * s->scale_bias;
- for (j = 0; j < ff_nelly_band_sizes_table[i]; j++) {
- *bptr++ = val;
- *pptr++ = pval;
- }
-
- }
-
- ff_nelly_get_sample_bits(buf, bits);
-
- for (i = 0; i < 2; i++) {
- aptr = audio + i * NELLY_BUF_LEN;
-
- init_get_bits(&s->gb, block, NELLY_BLOCK_LEN * 8);
- skip_bits_long(&s->gb, NELLY_HEADER_BITS + i*NELLY_DETAIL_BITS);
-
- for (j = 0; j < NELLY_FILL_LEN; j++) {
- if (bits[j] <= 0) {
- aptr[j] = M_SQRT1_2*pows[j];
- if (av_lfg_get(&s->random_state) & 1)
- aptr[j] *= -1.0;
- } else {
- v = get_bits(&s->gb, bits[j]);
- aptr[j] = ff_nelly_dequantization_table[(1<<bits[j])-1+v]*pows[j];
- }
- }
- memset(&aptr[NELLY_FILL_LEN], 0,
- (NELLY_BUF_LEN - NELLY_FILL_LEN) * sizeof(float));
-
- s->imdct_ctx.imdct_half(&s->imdct_ctx, s->imdct_out, aptr);
- s->fdsp.vector_fmul_window(aptr, s->imdct_prev + NELLY_BUF_LEN / 2,
- s->imdct_out, ff_sine_128,
- NELLY_BUF_LEN / 2);
- FFSWAP(float *, s->imdct_out, s->imdct_prev);
- }
-}
-
-static av_cold int decode_init(AVCodecContext * avctx) {
- NellyMoserDecodeContext *s = avctx->priv_data;
-
- s->avctx = avctx;
- s->imdct_out = s->imdct_buf[0];
- s->imdct_prev = s->imdct_buf[1];
- av_lfg_init(&s->random_state, 0);
- ff_mdct_init(&s->imdct_ctx, 8, 1, 1.0);
-
- avpriv_float_dsp_init(&s->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
-
- s->scale_bias = 1.0/(32768*8);
- avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
-
- /* Generate overlap window */
- if (!ff_sine_128[127])
- ff_init_ff_sine_windows(7);
-
- avctx->channels = 1;
- avctx->channel_layout = AV_CH_LAYOUT_MONO;
-
- return 0;
-}
-
-static int decode_tag(AVCodecContext *avctx, void *data,
- int *got_frame_ptr, AVPacket *avpkt)
-{
- AVFrame *frame = data;
- const uint8_t *buf = avpkt->data;
- const uint8_t *side=av_packet_get_side_data(avpkt, 'F', NULL);
- int buf_size = avpkt->size;
- NellyMoserDecodeContext *s = avctx->priv_data;
- int blocks, i, ret;
- float *samples_flt;
-
- blocks = buf_size / NELLY_BLOCK_LEN;
-
- if (blocks <= 0) {
- av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
- return AVERROR_INVALIDDATA;
- }
-
- if (buf_size % NELLY_BLOCK_LEN) {
- av_log(avctx, AV_LOG_WARNING, "Leftover bytes: %d.\n",
- buf_size % NELLY_BLOCK_LEN);
- }
- /* Normal numbers of blocks for sample rates:
- * 8000 Hz - 1
- * 11025 Hz - 2
- * 16000 Hz - 3
- * 22050 Hz - 4
- * 44100 Hz - 8
- */
- if(side && blocks>1 && avctx->sample_rate%11025==0 && (1<<((side[0]>>2)&3)) == blocks)
- avctx->sample_rate= 11025*(blocks/2);
-
- /* get output buffer */
- frame->nb_samples = NELLY_SAMPLES * blocks;
- if ((ret = ff_get_buffer(avctx, frame)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return ret;
- }
- samples_flt = (float *)frame->data[0];
-
- for (i=0 ; i<blocks ; i++) {
- nelly_decode_block(s, buf, samples_flt);
- samples_flt += NELLY_SAMPLES;
- buf += NELLY_BLOCK_LEN;
- }
-
- *got_frame_ptr = 1;
-
- return buf_size;
-}
-
-static av_cold int decode_end(AVCodecContext * avctx) {
- NellyMoserDecodeContext *s = avctx->priv_data;
-
- ff_mdct_end(&s->imdct_ctx);
-
- return 0;
-}
-
-AVCodec ff_nellymoser_decoder = {
- .name = "nellymoser",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_NELLYMOSER,
- .priv_data_size = sizeof(NellyMoserDecodeContext),
- .init = decode_init,
- .close = decode_end,
- .decode = decode_tag,
- .capabilities = CODEC_CAP_DR1 | CODEC_CAP_PARAM_CHANGE,
- .long_name = NULL_IF_CONFIG_SMALL("Nellymoser Asao"),
- .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT,
- AV_SAMPLE_FMT_NONE },
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/old_codec_ids.h b/src/thirdparty/ffmpeg/libavcodec/old_codec_ids.h
deleted file mode 100644
index ded4cc787..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/old_codec_ids.h
+++ /dev/null
@@ -1,398 +0,0 @@
-/*
- * 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_OLD_CODEC_IDS_H
-#define AVCODEC_OLD_CODEC_IDS_H
-
-#include "libavutil/common.h"
-
-/*
- * This header exists to prevent new codec IDs from being accidentally added to
- * the deprecated list.
- * Do not include it directly. It will be removed on next major bump
- *
- * Do not add new items to this list. Use the AVCodecID enum instead.
- */
-
- CODEC_ID_NONE = AV_CODEC_ID_NONE,
-
- /* video codecs */
- CODEC_ID_MPEG1VIDEO,
- CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding
- CODEC_ID_MPEG2VIDEO_XVMC,
- CODEC_ID_H261,
- CODEC_ID_H263,
- CODEC_ID_RV10,
- CODEC_ID_RV20,
- CODEC_ID_MJPEG,
- CODEC_ID_MJPEGB,
- CODEC_ID_LJPEG,
- CODEC_ID_SP5X,
- CODEC_ID_JPEGLS,
- CODEC_ID_MPEG4,
- CODEC_ID_RAWVIDEO,
- CODEC_ID_MSMPEG4V1,
- CODEC_ID_MSMPEG4V2,
- CODEC_ID_MSMPEG4V3,
- CODEC_ID_WMV1,
- CODEC_ID_WMV2,
- CODEC_ID_H263P,
- CODEC_ID_H263I,
- CODEC_ID_FLV1,
- CODEC_ID_SVQ1,
- CODEC_ID_SVQ3,
- CODEC_ID_DVVIDEO,
- CODEC_ID_HUFFYUV,
- CODEC_ID_CYUV,
- CODEC_ID_H264,
- CODEC_ID_INDEO3,
- CODEC_ID_VP3,
- CODEC_ID_THEORA,
- CODEC_ID_ASV1,
- CODEC_ID_ASV2,
- CODEC_ID_FFV1,
- CODEC_ID_4XM,
- CODEC_ID_VCR1,
- CODEC_ID_CLJR,
- CODEC_ID_MDEC,
- CODEC_ID_ROQ,
- CODEC_ID_INTERPLAY_VIDEO,
- CODEC_ID_XAN_WC3,
- CODEC_ID_XAN_WC4,
- CODEC_ID_RPZA,
- CODEC_ID_CINEPAK,
- CODEC_ID_WS_VQA,
- CODEC_ID_MSRLE,
- CODEC_ID_MSVIDEO1,
- CODEC_ID_IDCIN,
- CODEC_ID_8BPS,
- CODEC_ID_SMC,
- CODEC_ID_FLIC,
- CODEC_ID_TRUEMOTION1,
- CODEC_ID_VMDVIDEO,
- CODEC_ID_MSZH,
- CODEC_ID_ZLIB,
- CODEC_ID_QTRLE,
- CODEC_ID_SNOW,
- CODEC_ID_TSCC,
- CODEC_ID_ULTI,
- CODEC_ID_QDRAW,
- CODEC_ID_VIXL,
- CODEC_ID_QPEG,
- CODEC_ID_PNG,
- CODEC_ID_PPM,
- CODEC_ID_PBM,
- CODEC_ID_PGM,
- CODEC_ID_PGMYUV,
- CODEC_ID_PAM,
- CODEC_ID_FFVHUFF,
- CODEC_ID_RV30,
- CODEC_ID_RV40,
- CODEC_ID_VC1,
- CODEC_ID_WMV3,
- CODEC_ID_LOCO,
- CODEC_ID_WNV1,
- CODEC_ID_AASC,
- CODEC_ID_INDEO2,
- CODEC_ID_FRAPS,
- CODEC_ID_TRUEMOTION2,
- CODEC_ID_BMP,
- CODEC_ID_CSCD,
- CODEC_ID_MMVIDEO,
- CODEC_ID_ZMBV,
- CODEC_ID_AVS,
- CODEC_ID_SMACKVIDEO,
- CODEC_ID_NUV,
- CODEC_ID_KMVC,
- CODEC_ID_FLASHSV,
- CODEC_ID_CAVS,
- CODEC_ID_JPEG2000,
- CODEC_ID_VMNC,
- CODEC_ID_VP5,
- CODEC_ID_VP6,
- CODEC_ID_VP6F,
- CODEC_ID_TARGA,
- CODEC_ID_DSICINVIDEO,
- CODEC_ID_TIERTEXSEQVIDEO,
- CODEC_ID_TIFF,
- CODEC_ID_GIF,
- CODEC_ID_DXA,
- CODEC_ID_DNXHD,
- CODEC_ID_THP,
- CODEC_ID_SGI,
- CODEC_ID_C93,
- CODEC_ID_BETHSOFTVID,
- CODEC_ID_PTX,
- CODEC_ID_TXD,
- CODEC_ID_VP6A,
- CODEC_ID_AMV,
- CODEC_ID_VB,
- CODEC_ID_PCX,
- CODEC_ID_SUNRAST,
- CODEC_ID_INDEO4,
- CODEC_ID_INDEO5,
- CODEC_ID_MIMIC,
- CODEC_ID_RL2,
- CODEC_ID_ESCAPE124,
- CODEC_ID_DIRAC,
- CODEC_ID_BFI,
- CODEC_ID_CMV,
- CODEC_ID_MOTIONPIXELS,
- CODEC_ID_TGV,
- CODEC_ID_TGQ,
- CODEC_ID_TQI,
- CODEC_ID_AURA,
- CODEC_ID_AURA2,
- CODEC_ID_V210X,
- CODEC_ID_TMV,
- CODEC_ID_V210,
- CODEC_ID_DPX,
- CODEC_ID_MAD,
- CODEC_ID_FRWU,
- CODEC_ID_FLASHSV2,
- CODEC_ID_CDGRAPHICS,
- CODEC_ID_R210,
- CODEC_ID_ANM,
- CODEC_ID_BINKVIDEO,
- CODEC_ID_IFF_ILBM,
- CODEC_ID_IFF_BYTERUN1,
- CODEC_ID_KGV1,
- CODEC_ID_YOP,
- CODEC_ID_VP8,
- CODEC_ID_PICTOR,
- CODEC_ID_ANSI,
- CODEC_ID_A64_MULTI,
- CODEC_ID_A64_MULTI5,
- CODEC_ID_R10K,
- CODEC_ID_MXPEG,
- CODEC_ID_LAGARITH,
- CODEC_ID_PRORES,
- CODEC_ID_JV,
- CODEC_ID_DFA,
- CODEC_ID_WMV3IMAGE,
- CODEC_ID_VC1IMAGE,
- CODEC_ID_UTVIDEO,
- CODEC_ID_BMV_VIDEO,
- CODEC_ID_VBLE,
- CODEC_ID_DXTORY,
- CODEC_ID_V410,
- CODEC_ID_XWD,
- CODEC_ID_CDXL,
- CODEC_ID_XBM,
- CODEC_ID_ZEROCODEC,
- CODEC_ID_MSS1,
- CODEC_ID_MSA1,
- CODEC_ID_TSCC2,
- CODEC_ID_MTS2,
- CODEC_ID_CLLC,
- CODEC_ID_Y41P = MKBETAG('Y','4','1','P'),
- CODEC_ID_ESCAPE130 = MKBETAG('E','1','3','0'),
- CODEC_ID_EXR = MKBETAG('0','E','X','R'),
- CODEC_ID_AVRP = MKBETAG('A','V','R','P'),
-
- CODEC_ID_G2M = MKBETAG( 0 ,'G','2','M'),
- CODEC_ID_AVUI = MKBETAG('A','V','U','I'),
- CODEC_ID_AYUV = MKBETAG('A','Y','U','V'),
- CODEC_ID_V308 = MKBETAG('V','3','0','8'),
- CODEC_ID_V408 = MKBETAG('V','4','0','8'),
- CODEC_ID_YUV4 = MKBETAG('Y','U','V','4'),
- CODEC_ID_SANM = MKBETAG('S','A','N','M'),
- CODEC_ID_PAF_VIDEO = MKBETAG('P','A','F','V'),
-
- /* various PCM "codecs" */
- CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
- CODEC_ID_PCM_S16LE = 0x10000,
- CODEC_ID_PCM_S16BE,
- CODEC_ID_PCM_U16LE,
- CODEC_ID_PCM_U16BE,
- CODEC_ID_PCM_S8,
- CODEC_ID_PCM_U8,
- CODEC_ID_PCM_MULAW,
- CODEC_ID_PCM_ALAW,
- CODEC_ID_PCM_S32LE,
- CODEC_ID_PCM_S32BE,
- CODEC_ID_PCM_U32LE,
- CODEC_ID_PCM_U32BE,
- CODEC_ID_PCM_S24LE,
- CODEC_ID_PCM_S24BE,
- CODEC_ID_PCM_U24LE,
- CODEC_ID_PCM_U24BE,
- CODEC_ID_PCM_S24DAUD,
- CODEC_ID_PCM_ZORK,
- CODEC_ID_PCM_S16LE_PLANAR,
- CODEC_ID_PCM_DVD,
- CODEC_ID_PCM_F32BE,
- CODEC_ID_PCM_F32LE,
- CODEC_ID_PCM_F64BE,
- CODEC_ID_PCM_F64LE,
- CODEC_ID_PCM_BLURAY,
- CODEC_ID_PCM_LXF,
- CODEC_ID_S302M,
- CODEC_ID_PCM_S8_PLANAR,
-
- /* various ADPCM codecs */
- CODEC_ID_ADPCM_IMA_QT = 0x11000,
- CODEC_ID_ADPCM_IMA_WAV,
- CODEC_ID_ADPCM_IMA_DK3,
- CODEC_ID_ADPCM_IMA_DK4,
- CODEC_ID_ADPCM_IMA_WS,
- CODEC_ID_ADPCM_IMA_SMJPEG,
- CODEC_ID_ADPCM_MS,
- CODEC_ID_ADPCM_4XM,
- CODEC_ID_ADPCM_XA,
- CODEC_ID_ADPCM_ADX,
- CODEC_ID_ADPCM_EA,
- CODEC_ID_ADPCM_G726,
- CODEC_ID_ADPCM_CT,
- CODEC_ID_ADPCM_SWF,
- CODEC_ID_ADPCM_YAMAHA,
- CODEC_ID_ADPCM_SBPRO_4,
- CODEC_ID_ADPCM_SBPRO_3,
- CODEC_ID_ADPCM_SBPRO_2,
- CODEC_ID_ADPCM_THP,
- CODEC_ID_ADPCM_IMA_AMV,
- CODEC_ID_ADPCM_EA_R1,
- CODEC_ID_ADPCM_EA_R3,
- CODEC_ID_ADPCM_EA_R2,
- CODEC_ID_ADPCM_IMA_EA_SEAD,
- CODEC_ID_ADPCM_IMA_EA_EACS,
- CODEC_ID_ADPCM_EA_XAS,
- CODEC_ID_ADPCM_EA_MAXIS_XA,
- CODEC_ID_ADPCM_IMA_ISS,
- CODEC_ID_ADPCM_G722,
- CODEC_ID_ADPCM_IMA_APC,
- CODEC_ID_VIMA = MKBETAG('V','I','M','A'),
-
- /* AMR */
- CODEC_ID_AMR_NB = 0x12000,
- CODEC_ID_AMR_WB,
-
- /* RealAudio codecs*/
- CODEC_ID_RA_144 = 0x13000,
- CODEC_ID_RA_288,
-
- /* various DPCM codecs */
- CODEC_ID_ROQ_DPCM = 0x14000,
- CODEC_ID_INTERPLAY_DPCM,
- CODEC_ID_XAN_DPCM,
- CODEC_ID_SOL_DPCM,
-
- /* audio codecs */
- CODEC_ID_MP2 = 0x15000,
- CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
- CODEC_ID_AAC,
- CODEC_ID_AC3,
- CODEC_ID_DTS,
- CODEC_ID_VORBIS,
- CODEC_ID_DVAUDIO,
- CODEC_ID_WMAV1,
- CODEC_ID_WMAV2,
- CODEC_ID_MACE3,
- CODEC_ID_MACE6,
- CODEC_ID_VMDAUDIO,
- CODEC_ID_FLAC,
- CODEC_ID_MP3ADU,
- CODEC_ID_MP3ON4,
- CODEC_ID_SHORTEN,
- CODEC_ID_ALAC,
- CODEC_ID_WESTWOOD_SND1,
- CODEC_ID_GSM, ///< as in Berlin toast format
- CODEC_ID_QDM2,
- CODEC_ID_COOK,
- CODEC_ID_TRUESPEECH,
- CODEC_ID_TTA,
- CODEC_ID_SMACKAUDIO,
- CODEC_ID_QCELP,
- CODEC_ID_WAVPACK,
- CODEC_ID_DSICINAUDIO,
- CODEC_ID_IMC,
- CODEC_ID_MUSEPACK7,
- CODEC_ID_MLP,
- CODEC_ID_GSM_MS, /* as found in WAV */
- CODEC_ID_ATRAC3,
- CODEC_ID_VOXWARE,
- CODEC_ID_APE,
- CODEC_ID_NELLYMOSER,
- CODEC_ID_MUSEPACK8,
- CODEC_ID_SPEEX,
- CODEC_ID_WMAVOICE,
- CODEC_ID_WMAPRO,
- CODEC_ID_WMALOSSLESS,
- CODEC_ID_ATRAC3P,
- CODEC_ID_EAC3,
- CODEC_ID_SIPR,
- CODEC_ID_MP1,
- CODEC_ID_TWINVQ,
- CODEC_ID_TRUEHD,
- CODEC_ID_MP4ALS,
- CODEC_ID_ATRAC1,
- CODEC_ID_BINKAUDIO_RDFT,
- CODEC_ID_BINKAUDIO_DCT,
- CODEC_ID_AAC_LATM,
- CODEC_ID_QDMC,
- CODEC_ID_CELT,
- CODEC_ID_G723_1,
- CODEC_ID_G729,
- CODEC_ID_8SVX_EXP,
- CODEC_ID_8SVX_FIB,
- CODEC_ID_BMV_AUDIO,
- CODEC_ID_RALF,
- CODEC_ID_IAC,
- CODEC_ID_ILBC,
- CODEC_ID_FFWAVESYNTH = MKBETAG('F','F','W','S'),
- CODEC_ID_8SVX_RAW = MKBETAG('8','S','V','X'),
- CODEC_ID_SONIC = MKBETAG('S','O','N','C'),
- CODEC_ID_SONIC_LS = MKBETAG('S','O','N','L'),
- CODEC_ID_PAF_AUDIO = MKBETAG('P','A','F','A'),
- CODEC_ID_OPUS = MKBETAG('O','P','U','S'),
-
- /* subtitle codecs */
- CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs.
- CODEC_ID_DVD_SUBTITLE = 0x17000,
- CODEC_ID_DVB_SUBTITLE,
- CODEC_ID_TEXT, ///< raw UTF-8 text
- CODEC_ID_XSUB,
- CODEC_ID_SSA,
- CODEC_ID_MOV_TEXT,
- CODEC_ID_HDMV_PGS_SUBTITLE,
- CODEC_ID_DVB_TELETEXT,
- CODEC_ID_SRT,
- CODEC_ID_MICRODVD = MKBETAG('m','D','V','D'),
- CODEC_ID_EIA_608 = MKBETAG('c','6','0','8'),
- CODEC_ID_JACOSUB = MKBETAG('J','S','U','B'),
- CODEC_ID_SAMI = MKBETAG('S','A','M','I'),
- CODEC_ID_REALTEXT = MKBETAG('R','T','X','T'),
- CODEC_ID_SUBVIEWER = MKBETAG('S','u','b','V'),
-
- /* other specific kind of codecs (generally used for attachments) */
- CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs.
- CODEC_ID_TTF = 0x18000,
- CODEC_ID_BINTEXT = MKBETAG('B','T','X','T'),
- CODEC_ID_XBIN = MKBETAG('X','B','I','N'),
- CODEC_ID_IDF = MKBETAG( 0 ,'I','D','F'),
- CODEC_ID_OTF = MKBETAG( 0 ,'O','T','F'),
-
- CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it
-
- CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS
- * stream (only used by libavformat) */
- CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems
- * stream (only used by libavformat) */
- CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information.
-
-#endif /* AVCODEC_OLD_CODEC_IDS_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/options.c b/src/thirdparty/ffmpeg/libavcodec/options.c
deleted file mode 100644
index c9cb05d9f..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/options.c
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * Copyright (c) 2001 Fabrice Bellard
- * Copyright (c) 2002-2004 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
- * Options definition for AVCodecContext.
- */
-
-#include "avcodec.h"
-#include "internal.h"
-#include "libavutil/avassert.h"
-#include "libavutil/mem.h"
-#include "libavutil/opt.h"
-#include <float.h> /* FLT_MIN, FLT_MAX */
-#include <string.h>
-
-#include "options_table.h"
-
-static const char* context_to_name(void* ptr) {
- AVCodecContext *avc= ptr;
-
- if(avc && avc->codec && avc->codec->name)
- return avc->codec->name;
- else
- return "NULL";
-}
-
-static void *codec_child_next(void *obj, void *prev)
-{
- AVCodecContext *s = obj;
- if (!prev && s->codec && s->codec->priv_class && s->priv_data)
- return s->priv_data;
- return NULL;
-}
-
-static const AVClass *codec_child_class_next(const AVClass *prev)
-{
- AVCodec *c = NULL;
-
- /* find the codec that corresponds to prev */
- while (prev && (c = av_codec_next(c)))
- if (c->priv_class == prev)
- break;
-
- /* find next codec with priv options */
- while (c = av_codec_next(c))
- if (c->priv_class)
- return c->priv_class;
- return NULL;
-}
-
-static AVClassCategory get_category(void *ptr)
-{
- AVCodecContext* avctx = ptr;
- if(avctx->codec && avctx->codec->decode) return AV_CLASS_CATEGORY_DECODER;
- else return AV_CLASS_CATEGORY_ENCODER;
-}
-
-static const AVClass av_codec_context_class = {
- .class_name = "AVCodecContext",
- .item_name = context_to_name,
- .option = options,
- .version = LIBAVUTIL_VERSION_INT,
- .log_level_offset_offset = offsetof(AVCodecContext, log_level_offset),
- .child_next = codec_child_next,
- .child_class_next = codec_child_class_next,
- .category = AV_CLASS_CATEGORY_ENCODER,
- .get_category = get_category,
-};
-
-#if FF_API_ALLOC_CONTEXT
-void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType codec_type){
- AVCodec c= {0};
- c.type= codec_type;
- avcodec_get_context_defaults3(s, &c);
-}
-#endif
-
-int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec)
-{
- int flags=0;
- memset(s, 0, sizeof(AVCodecContext));
-
- s->av_class = &av_codec_context_class;
-
- s->codec_type = codec ? codec->type : AVMEDIA_TYPE_UNKNOWN;
- if(s->codec_type == AVMEDIA_TYPE_AUDIO)
- flags= AV_OPT_FLAG_AUDIO_PARAM;
- else if(s->codec_type == AVMEDIA_TYPE_VIDEO)
- flags= AV_OPT_FLAG_VIDEO_PARAM;
- else if(s->codec_type == AVMEDIA_TYPE_SUBTITLE)
- flags= AV_OPT_FLAG_SUBTITLE_PARAM;
- av_opt_set_defaults2(s, flags, flags);
-
- s->time_base = (AVRational){0,1};
- s->get_buffer = avcodec_default_get_buffer;
- s->release_buffer = avcodec_default_release_buffer;
- s->get_format = avcodec_default_get_format;
- s->execute = avcodec_default_execute;
- s->execute2 = avcodec_default_execute2;
- s->sample_aspect_ratio = (AVRational){0,1};
- s->pix_fmt = AV_PIX_FMT_NONE;
- s->sample_fmt = AV_SAMPLE_FMT_NONE;
- s->timecode_frame_start = -1;
-
- s->reget_buffer = avcodec_default_reget_buffer;
- s->reordered_opaque = AV_NOPTS_VALUE;
- if(codec && codec->priv_data_size){
- if(!s->priv_data){
- s->priv_data= av_mallocz(codec->priv_data_size);
- if (!s->priv_data) {
- return AVERROR(ENOMEM);
- }
- }
- if(codec->priv_class){
- *(const AVClass**)s->priv_data = codec->priv_class;
- av_opt_set_defaults(s->priv_data);
- }
- }
- if (codec && codec->defaults) {
- int ret;
- const AVCodecDefault *d = codec->defaults;
- while (d->key) {
- ret = av_opt_set(s, d->key, d->value, 0);
- av_assert0(ret >= 0);
- d++;
- }
- }
- return 0;
-}
-
-AVCodecContext *avcodec_alloc_context3(const AVCodec *codec)
-{
- AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
-
- if(avctx==NULL) return NULL;
-
- if(avcodec_get_context_defaults3(avctx, codec) < 0){
- av_free(avctx);
- return NULL;
- }
-
- return avctx;
-}
-
-#if FF_API_ALLOC_CONTEXT
-AVCodecContext *avcodec_alloc_context2(enum AVMediaType codec_type){
- AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
-
- if(avctx==NULL) return NULL;
-
- avcodec_get_context_defaults2(avctx, codec_type);
-
- return avctx;
-}
-
-void avcodec_get_context_defaults(AVCodecContext *s){
- avcodec_get_context_defaults2(s, AVMEDIA_TYPE_UNKNOWN);
-}
-
-AVCodecContext *avcodec_alloc_context(void){
- return avcodec_alloc_context2(AVMEDIA_TYPE_UNKNOWN);
-}
-#endif
-
-int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
-{
- 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",
- src, dest);
- return AVERROR(EINVAL);
- }
- memcpy(dest, src, sizeof(*dest));
-
- /* 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->thread_opaque = NULL;
- dest->internal = NULL;
-
- /* reallocate values that should be allocated separately */
- dest->rc_eq = NULL;
- dest->extradata = NULL;
- dest->intra_matrix = NULL;
- dest->inter_matrix = NULL;
- dest->rc_override = NULL;
- if (src->rc_eq) {
- dest->rc_eq = av_strdup(src->rc_eq);
- if (!dest->rc_eq)
- return AVERROR(ENOMEM);
- }
-
-#define alloc_and_copy_or_fail(obj, size, pad) \
- if (src->obj && size > 0) { \
- dest->obj = av_malloc(size + pad); \
- if (!dest->obj) \
- goto fail; \
- memcpy(dest->obj, src->obj, size); \
- if (pad) \
- memset(((uint8_t *) dest->obj) + size, 0, pad); \
- }
- alloc_and_copy_or_fail(extradata, src->extradata_size,
- FF_INPUT_BUFFER_PADDING_SIZE);
- alloc_and_copy_or_fail(intra_matrix, 64 * sizeof(int16_t), 0);
- 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);
-#undef alloc_and_copy_or_fail
-
- return 0;
-
-fail:
- av_freep(&dest->rc_override);
- av_freep(&dest->intra_matrix);
- av_freep(&dest->inter_matrix);
- av_freep(&dest->extradata);
- av_freep(&dest->rc_eq);
- return AVERROR(ENOMEM);
-}
-
-const AVClass *avcodec_get_class(void)
-{
- return &av_codec_context_class;
-}
-
-#define FOFFSET(x) offsetof(AVFrame,x)
-
-static const AVOption frame_options[]={
-{"best_effort_timestamp", "", FOFFSET(best_effort_timestamp), AV_OPT_TYPE_INT64, {.i64 = AV_NOPTS_VALUE }, INT64_MIN, INT64_MAX, 0},
-{"pkt_pos", "", FOFFSET(pkt_pos), AV_OPT_TYPE_INT64, {.i64 = -1 }, INT64_MIN, INT64_MAX, 0},
-{"pkt_size", "", FOFFSET(pkt_size), AV_OPT_TYPE_INT64, {.i64 = -1 }, INT64_MIN, INT64_MAX, 0},
-{"sample_aspect_ratio", "", FOFFSET(sample_aspect_ratio), AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, 0, INT_MAX, 0},
-{"width", "", FOFFSET(width), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0},
-{"height", "", FOFFSET(height), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0},
-{"format", "", FOFFSET(format), AV_OPT_TYPE_INT, {.i64 = -1 }, 0, INT_MAX, 0},
-{"channel_layout", "", FOFFSET(channel_layout), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT64_MAX, 0},
-{"sample_rate", "", FOFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0},
-{NULL},
-};
-
-static const AVClass av_frame_class = {
- .class_name = "AVFrame",
- .item_name = NULL,
- .option = frame_options,
- .version = LIBAVUTIL_VERSION_INT,
-};
-
-const AVClass *avcodec_get_frame_class(void)
-{
- return &av_frame_class;
-}
-
-#define SROFFSET(x) offsetof(AVSubtitleRect,x)
-
-static const AVOption subtitle_rect_options[]={
-{"x", "", SROFFSET(x), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0},
-{"y", "", SROFFSET(y), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0},
-{"w", "", SROFFSET(w), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0},
-{"h", "", SROFFSET(h), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0},
-{"type", "", SROFFSET(type), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0},
-{"flags", "", SROFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = 0}, 0, 1, 0, "flags"},
-{"forced", "", SROFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = 0}, 0, 1, 0},
-{NULL},
-};
-
-static const AVClass av_subtitle_rect_class = {
- .class_name = "AVSubtitleRect",
- .item_name = NULL,
- .option = subtitle_rect_options,
- .version = LIBAVUTIL_VERSION_INT,
-};
-
-const AVClass *avcodec_get_subtitle_rect_class(void)
-{
- return &av_subtitle_rect_class;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/options_table.h b/src/thirdparty/ffmpeg/libavcodec/options_table.h
deleted file mode 100644
index 35af2101e..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/options_table.h
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * Copyright (c) 2001 Fabrice Bellard
- * Copyright (c) 2002-2004 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
- */
-
-#ifndef AVCODEC_OPTIONS_TABLE_H
-#define AVCODEC_OPTIONS_TABLE_H
-
-#include <float.h>
-#include <limits.h>
-
-#include "libavutil/opt.h"
-#include "avcodec.h"
-#include "version.h"
-#include "config.h"
-
-#define OFFSET(x) offsetof(AVCodecContext,x)
-#define DEFAULT 0 //should be NAN but it does not work as it is not a constant in glibc as required by ANSI/ISO C
-//these names are too long to be readable
-#define V AV_OPT_FLAG_VIDEO_PARAM
-#define A AV_OPT_FLAG_AUDIO_PARAM
-#define S AV_OPT_FLAG_SUBTITLE_PARAM
-#define E AV_OPT_FLAG_ENCODING_PARAM
-#define D AV_OPT_FLAG_DECODING_PARAM
-
-#define AV_CODEC_DEFAULT_BITRATE 200*1000
-
-static const AVOption options[]={
-{"b", "set bitrate (in bits/s)", OFFSET(bit_rate), AV_OPT_TYPE_INT, {.i64 = AV_CODEC_DEFAULT_BITRATE }, 0, INT_MAX, A|V|E},
-{"ab", "set bitrate (in bits/s)", OFFSET(bit_rate), AV_OPT_TYPE_INT, {.i64 = 128*1000 }, 0, INT_MAX, A|E},
-{"bt", "Set video bitrate tolerance (in bits/s). In 1-pass mode, bitrate tolerance specifies how far "
- "ratecontrol is willing to deviate from the target average bitrate value. This is not related "
- "to minimum/maximum bitrate. Lowering tolerance too much has an adverse effect on quality.",
- OFFSET(bit_rate_tolerance), AV_OPT_TYPE_INT, {.i64 = AV_CODEC_DEFAULT_BITRATE*20 }, 1, INT_MAX, V|E},
-{"flags", NULL, OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT }, 0, UINT_MAX, V|A|S|E|D, "flags"},
-{"mv4", "use four motion vectors per macroblock (MPEG-4)", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_4MV }, INT_MIN, INT_MAX, V|E, "flags"},
-{"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"},
-{"gmc", "use gmc", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_GMC }, INT_MIN, INT_MAX, V|E, "flags"},
-{"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"},
-{"input_preserved", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_INPUT_PRESERVED }, INT_MIN, INT_MAX, 0, "flags"},
-{"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"},
-{"naq", "normalize adaptive quantization", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_NORMALIZE_AQP }, INT_MIN, INT_MAX, V|E, "flags"},
-{"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"},
-{"bitexact", "use only bitexact functions (except (I)DCT)", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_BITEXACT }, INT_MIN, INT_MAX, A|V|S|D|E, "flags"},
-{"aic", "H.263 advanced intra coding / MPEG-4 AC prediction", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_AC_PRED }, INT_MIN, INT_MAX, V|E, "flags"},
-#if FF_API_MPV_GLOBAL_OPTS
-{"cbp", "Deprecated, use mpegvideo private options instead", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_CBP_RD }, INT_MIN, INT_MAX, V|E, "flags"},
-{"qprd", "Deprecated, use mpegvideo private options instead", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_QP_RD }, INT_MIN, INT_MAX, V|E, "flags"},
-#endif
-{"ilme", "interlaced motion estimation", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_INTERLACED_ME }, INT_MIN, INT_MAX, V|E, "flags"},
-{"cgop", "closed GOP", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG_CLOSED_GOP }, INT_MIN, INT_MAX, V|E, "flags"},
-{"fast", "allow non-spec-compliant speedup tricks", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_FAST }, INT_MIN, INT_MAX, V|E, "flags2"},
-#if FF_API_MPV_GLOBAL_OPTS
-{"sgop", "Deprecated, use mpegvideo private options instead", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_STRICT_GOP }, INT_MIN, INT_MAX, V|E, "flags2"},
-#endif
-{"noout", "skip bitstream encoding", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_NO_OUTPUT }, INT_MIN, INT_MAX, V|E, "flags2"},
-{"ignorecrop", "ignore cropping information from sps", 1, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_IGNORE_CROP }, INT_MIN, INT_MAX, V|D, "flags2"},
-{"local_header", "place global headers at every keyframe instead of in extradata", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_LOCAL_HEADER }, INT_MIN, INT_MAX, V|E, "flags2"},
-{"chunks", "Frame data might be split into multiple chunks", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_CHUNKS }, INT_MIN, INT_MAX, V|D, "flags2"},
-{"showall", "Show all frames before the first keyframe", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_SHOW_ALL }, INT_MIN, INT_MAX, V|D, "flags2"},
-#if FF_API_SUB_ID
-{"sub_id", NULL, OFFSET(sub_id), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
-#endif
-{"me_method", "set motion estimation method", OFFSET(me_method), AV_OPT_TYPE_INT, {.i64 = ME_EPZS }, INT_MIN, INT_MAX, V|E, "me_method"},
-{"zero", "zero motion estimation (fastest)", 0, AV_OPT_TYPE_CONST, {.i64 = ME_ZERO }, INT_MIN, INT_MAX, V|E, "me_method" },
-{"full", "full motion estimation (slowest)", 0, AV_OPT_TYPE_CONST, {.i64 = ME_FULL }, INT_MIN, INT_MAX, V|E, "me_method" },
-{"epzs", "EPZS motion estimation (default)", 0, AV_OPT_TYPE_CONST, {.i64 = ME_EPZS }, INT_MIN, INT_MAX, V|E, "me_method" },
-{"esa", "esa motion estimation (alias for full)", 0, AV_OPT_TYPE_CONST, {.i64 = ME_FULL }, INT_MIN, INT_MAX, V|E, "me_method" },
-{"tesa", "tesa motion estimation", 0, AV_OPT_TYPE_CONST, {.i64 = ME_TESA }, INT_MIN, INT_MAX, V|E, "me_method" },
-{"dia", "diamond motion estimation (alias for EPZS)", 0, AV_OPT_TYPE_CONST, {.i64 = ME_EPZS }, INT_MIN, INT_MAX, V|E, "me_method" },
-{"log", "log motion estimation", 0, AV_OPT_TYPE_CONST, {.i64 = ME_LOG }, INT_MIN, INT_MAX, V|E, "me_method" },
-{"phods", "phods motion estimation", 0, AV_OPT_TYPE_CONST, {.i64 = ME_PHODS }, INT_MIN, INT_MAX, V|E, "me_method" },
-{"x1", "X1 motion estimation", 0, AV_OPT_TYPE_CONST, {.i64 = ME_X1 }, INT_MIN, INT_MAX, V|E, "me_method" },
-{"hex", "hex motion estimation", 0, AV_OPT_TYPE_CONST, {.i64 = ME_HEX }, INT_MIN, INT_MAX, V|E, "me_method" },
-{"umh", "umh motion estimation", 0, AV_OPT_TYPE_CONST, {.i64 = ME_UMH }, INT_MIN, INT_MAX, V|E, "me_method" },
-{"iter", "iter motion estimation", 0, AV_OPT_TYPE_CONST, {.i64 = ME_ITER }, INT_MIN, INT_MAX, V|E, "me_method" },
-{"extradata_size", NULL, OFFSET(extradata_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
-{"time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, INT_MIN, INT_MAX},
-{"g", "set the group of picture (GOP) size", OFFSET(gop_size), AV_OPT_TYPE_INT, {.i64 = 12 }, INT_MIN, INT_MAX, V|E},
-{"ar", "set audio sampling rate (in Hz)", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, A|D|E},
-{"ac", "set number of audio channels", OFFSET(channels), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, A|D|E},
-{"cutoff", "set cutoff bandwidth", OFFSET(cutoff), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, A|E},
-{"frame_size", NULL, OFFSET(frame_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, A|E},
-{"frame_number", NULL, OFFSET(frame_number), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
-{"delay", NULL, OFFSET(delay), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
-{"qcomp", "video quantizer scale compression (VBR). Constant of ratecontrol equation. "
- "Recommended range for default rc_eq: 0.0-1.0",
- OFFSET(qcompress), AV_OPT_TYPE_FLOAT, {.dbl = 0.5 }, -FLT_MAX, FLT_MAX, V|E},
-{"qblur", "video quantizer scale blur (VBR)", OFFSET(qblur), AV_OPT_TYPE_FLOAT, {.dbl = 0.5 }, -1, FLT_MAX, V|E},
-{"qmin", "minimum video quantizer scale (VBR)", OFFSET(qmin), AV_OPT_TYPE_INT, {.i64 = 2 }, -1, 69, V|E},
-{"qmax", "maximum video quantizer scale (VBR)", OFFSET(qmax), AV_OPT_TYPE_INT, {.i64 = 31 }, -1, 1024, V|E},
-{"qdiff", "maximum difference between the quantizer scales (VBR)", OFFSET(max_qdiff), AV_OPT_TYPE_INT, {.i64 = 3 }, INT_MIN, INT_MAX, V|E},
-{"bf", "use 'frames' B frames", OFFSET(max_b_frames), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, -1, FF_MAX_B_FRAMES, V|E},
-{"b_qfactor", "QP factor between P- and B-frames", OFFSET(b_quant_factor), AV_OPT_TYPE_FLOAT, {.dbl = 1.25 }, -FLT_MAX, FLT_MAX, V|E},
-{"rc_strategy", "ratecontrol method", OFFSET(rc_strategy), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
-{"b_strategy", "strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, V|E},
-{"ps", "RTP payload size in bytes", OFFSET(rtp_payload_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
-{"mv_bits", NULL, OFFSET(mv_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
-{"header_bits", NULL, OFFSET(header_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
-{"i_tex_bits", NULL, OFFSET(i_tex_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
-{"p_tex_bits", NULL, OFFSET(p_tex_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
-{"i_count", NULL, OFFSET(i_count), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
-{"p_count", NULL, OFFSET(p_count), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
-{"skip_count", NULL, OFFSET(skip_count), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
-{"misc_bits", NULL, OFFSET(misc_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
-{"frame_bits", NULL, OFFSET(frame_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
-{"codec_tag", NULL, OFFSET(codec_tag), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
-{"bug", "work around not autodetected encoder bugs", OFFSET(workaround_bugs), AV_OPT_TYPE_FLAGS, {.i64 = FF_BUG_AUTODETECT }, INT_MIN, INT_MAX, V|D, "bug"},
-{"autodetect", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_AUTODETECT }, INT_MIN, INT_MAX, V|D, "bug"},
-{"old_msmpeg4", "some old lavc-generated MSMPEG4v3 files (no autodetection)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_OLD_MSMPEG4 }, INT_MIN, INT_MAX, V|D, "bug"},
-{"xvid_ilace", "Xvid interlacing bug (autodetected if FOURCC == XVIX)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_XVID_ILACE }, INT_MIN, INT_MAX, V|D, "bug"},
-{"ump4", "(autodetected if FOURCC == UMP4)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_UMP4 }, INT_MIN, INT_MAX, V|D, "bug"},
-{"no_padding", "padding bug (autodetected)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_NO_PADDING }, INT_MIN, INT_MAX, V|D, "bug"},
-{"amv", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_AMV }, INT_MIN, INT_MAX, V|D, "bug"},
-{"ac_vlc", "illegal VLC bug (autodetected per FOURCC)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_AC_VLC }, INT_MIN, INT_MAX, V|D, "bug"},
-{"qpel_chroma", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_QPEL_CHROMA }, INT_MIN, INT_MAX, V|D, "bug"},
-{"std_qpel", "old standard qpel (autodetected per FOURCC/version)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_STD_QPEL }, INT_MIN, INT_MAX, V|D, "bug"},
-{"qpel_chroma2", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_QPEL_CHROMA2 }, INT_MIN, INT_MAX, V|D, "bug"},
-{"direct_blocksize", "direct-qpel-blocksize bug (autodetected per FOURCC/version)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_DIRECT_BLOCKSIZE }, INT_MIN, INT_MAX, V|D, "bug"},
-{"edge", "edge padding bug (autodetected per FOURCC/version)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_EDGE }, INT_MIN, INT_MAX, V|D, "bug"},
-{"hpel_chroma", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_HPEL_CHROMA }, INT_MIN, INT_MAX, V|D, "bug"},
-{"dc_clip", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_DC_CLIP }, INT_MIN, INT_MAX, V|D, "bug"},
-{"ms", "work around various bugs in Microsoft's broken decoders", 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_MS }, INT_MIN, INT_MAX, V|D, "bug"},
-{"trunc", "truncated frames", 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_TRUNCATED}, INT_MIN, INT_MAX, V|D, "bug"},
-#if FF_API_MPV_GLOBAL_OPTS
-{"lelim", "single coefficient elimination threshold for luminance (negative values also consider DC coefficient)", OFFSET(luma_elim_threshold), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
-{"celim", "single coefficient elimination threshold for chrominance (negative values also consider DC coefficient)", OFFSET(chroma_elim_threshold), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
-#endif
-{"strict", "how strictly to follow the standards", OFFSET(strict_std_compliance), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, A|V|D|E, "strict"},
-{"very", "strictly conform to a older more strict version of the spec or reference software", 0, AV_OPT_TYPE_CONST, {.i64 = FF_COMPLIANCE_VERY_STRICT }, INT_MIN, INT_MAX, V|D|E, "strict"},
-{"strict", "strictly conform to all the things in the spec no matter what the consequences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_COMPLIANCE_STRICT }, INT_MIN, INT_MAX, V|D|E, "strict"},
-{"normal", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_COMPLIANCE_NORMAL }, INT_MIN, INT_MAX, V|D|E, "strict"},
-{"unofficial", "allow unofficial extensions", 0, AV_OPT_TYPE_CONST, {.i64 = FF_COMPLIANCE_UNOFFICIAL }, INT_MIN, INT_MAX, V|D|E, "strict"},
-{"experimental", "allow non-standardized experimental things", 0, AV_OPT_TYPE_CONST, {.i64 = FF_COMPLIANCE_EXPERIMENTAL }, INT_MIN, INT_MAX, V|D|E, "strict"},
-{"b_qoffset", "QP offset between P- and B-frames", OFFSET(b_quant_offset), AV_OPT_TYPE_FLOAT, {.dbl = 1.25 }, -FLT_MAX, FLT_MAX, V|E},
-{"err_detect", "set error detection flags", OFFSET(err_recognition), AV_OPT_TYPE_FLAGS, {.i64 = AV_EF_CRCCHECK }, INT_MIN, INT_MAX, A|V|D, "err_detect"},
-{"crccheck", "verify embedded CRCs", 0, AV_OPT_TYPE_CONST, {.i64 = AV_EF_CRCCHECK }, INT_MIN, INT_MAX, A|V|D, "err_detect"},
-{"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"},
-{"careful", "consider things that violate the spec 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"},
-{"has_b_frames", NULL, OFFSET(has_b_frames), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
-{"block_align", NULL, OFFSET(block_align), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
-{"mpeg_quant", "use MPEG quantizers instead of H.263", OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
-{"qsquish", "how to keep quantizer between qmin and qmax (0 = clip, 1 = use differentiable function)", OFFSET(rc_qsquish), AV_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, 0, 99, V|E},
-{"rc_qmod_amp", "experimental quantizer modulation", OFFSET(rc_qmod_amp), AV_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, -FLT_MAX, FLT_MAX, V|E},
-{"rc_qmod_freq", "experimental quantizer modulation", OFFSET(rc_qmod_freq), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
-{"rc_override_count", NULL, OFFSET(rc_override_count), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
-{"rc_eq", "Set rate control equation. When computing the expression, besides the standard functions "
- "defined in the section 'Expression Evaluation', the following functions are available: "
- "bits2qp(bits), qp2bits(qp). Also the following constants are available: iTex pTex tex mv "
- "fCode iCount mcVar var isI isP isB avgQP qComp avgIITex avgPITex avgPPTex avgBPTex avgTex.",
- OFFSET(rc_eq), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, V|E},
-{"maxrate", "Set maximum bitrate tolerance (in bits/s). Requires bufsize to be set.", OFFSET(rc_max_rate), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|A|E},
-{"minrate", "Set minimum bitrate tolerance (in bits/s). Most useful in setting up a CBR encode. It is of little use otherwise.",
- OFFSET(rc_min_rate), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|A|E},
-{"bufsize", "set ratecontrol buffer size (in bits)", OFFSET(rc_buffer_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, A|V|E},
-{"rc_buf_aggressivity", "currently useless", OFFSET(rc_buffer_aggressivity), AV_OPT_TYPE_FLOAT, {.dbl = 1.0 }, -FLT_MAX, FLT_MAX, V|E},
-{"i_qfactor", "QP factor between P- and I-frames", OFFSET(i_quant_factor), AV_OPT_TYPE_FLOAT, {.dbl = -0.8 }, -FLT_MAX, FLT_MAX, V|E},
-{"i_qoffset", "QP offset between P- and I-frames", OFFSET(i_quant_offset), AV_OPT_TYPE_FLOAT, {.dbl = 0.0 }, -FLT_MAX, FLT_MAX, V|E},
-{"rc_init_cplx", "initial complexity for 1-pass encoding", OFFSET(rc_initial_cplx), AV_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, -FLT_MAX, FLT_MAX, V|E},
-{"dct", "DCT algorithm", OFFSET(dct_algo), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, V|E, "dct"},
-{"auto", "autoselect a good one (default)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DCT_AUTO }, INT_MIN, INT_MAX, V|E, "dct"},
-{"fastint", "fast integer", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DCT_FASTINT }, INT_MIN, INT_MAX, V|E, "dct"},
-{"int", "accurate integer", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DCT_INT }, INT_MIN, INT_MAX, V|E, "dct"},
-{"mmx", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DCT_MMX }, INT_MIN, INT_MAX, V|E, "dct"},
-{"altivec", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DCT_ALTIVEC }, INT_MIN, INT_MAX, V|E, "dct"},
-{"faan", "floating point AAN DCT", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DCT_FAAN }, INT_MIN, INT_MAX, V|E, "dct"},
-{"lumi_mask", "compresses bright areas stronger than medium ones", OFFSET(lumi_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, V|E},
-{"tcplx_mask", "temporal complexity masking", OFFSET(temporal_cplx_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, V|E},
-{"scplx_mask", "spatial complexity masking", OFFSET(spatial_cplx_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, V|E},
-{"p_mask", "inter masking", OFFSET(p_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, V|E},
-{"dark_mask", "compresses dark areas stronger than medium ones", OFFSET(dark_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, V|E},
-{"idct", "select IDCT implementation", OFFSET(idct_algo), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, V|E|D, "idct"},
-{"auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_AUTO }, INT_MIN, INT_MAX, V|E|D, "idct"},
-{"int", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_INT }, INT_MIN, INT_MAX, V|E|D, "idct"},
-{"simple", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SIMPLE }, INT_MIN, INT_MAX, V|E|D, "idct"},
-{"simplemmx", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SIMPLEMMX }, INT_MIN, INT_MAX, V|E|D, "idct"},
-{"libmpeg2mmx", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_LIBMPEG2MMX }, INT_MIN, INT_MAX, V|E|D, "idct"},
-#if FF_API_MMI
-{"mmi", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_MMI }, INT_MIN, INT_MAX, V|E|D, "idct"},
-#endif
-{"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"},
-{"sh4", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SH4 }, INT_MIN, INT_MAX, V|E|D, "idct"},
-{"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"},
-{"simpleneon", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SIMPLENEON }, INT_MIN, INT_MAX, V|E|D, "idct"},
-{"simplealpha", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SIMPLEALPHA }, INT_MIN, INT_MAX, V|E|D, "idct"},
-#if FF_API_IDCT
-{"h264", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_H264 }, INT_MIN, INT_MAX, V|E|D, "idct"},
-{"vp3", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_VP3 }, INT_MIN, INT_MAX, V|E|D, "idct"},
-#endif
-{"ipp", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_IPP }, INT_MIN, INT_MAX, V|E|D, "idct"},
-{"xvidmmx", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_XVIDMMX }, INT_MIN, INT_MAX, V|E|D, "idct"},
-{"faani", "floating point AAN IDCT", 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_FAAN }, INT_MIN, INT_MAX, V|D|E, "idct"},
-{"slice_count", NULL, OFFSET(slice_count), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
-{"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"},
-{"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"},
-{"plane", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PRED_PLANE }, INT_MIN, INT_MAX, V|E, "pred"},
-{"median", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PRED_MEDIAN }, INT_MIN, INT_MAX, V|E, "pred"},
-{"aspect", "sample aspect ratio", OFFSET(sample_aspect_ratio), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, 0, 10, V|E},
-{"debug", "print specific debug info", OFFSET(debug), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT }, 0, INT_MAX, V|A|S|E|D, "debug"},
-{"pict", "picture info", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_PICT_INFO }, INT_MIN, INT_MAX, V|D, "debug"},
-{"rc", "rate control", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_RC }, INT_MIN, INT_MAX, V|E, "debug"},
-{"bitstream", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_BITSTREAM }, INT_MIN, INT_MAX, V|D, "debug"},
-{"mb_type", "macroblock (MB) type", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_MB_TYPE }, INT_MIN, INT_MAX, V|D, "debug"},
-{"qp", "per-block quantization parameter (QP)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_QP }, INT_MIN, INT_MAX, V|D, "debug"},
-{"mv", "motion vector", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_MV }, INT_MIN, INT_MAX, V|D, "debug"},
-{"dct_coeff", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_DCT_COEFF }, INT_MIN, INT_MAX, V|D, "debug"},
-{"skip", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_SKIP }, INT_MIN, INT_MAX, V|D, "debug"},
-{"startcode", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_STARTCODE }, INT_MIN, INT_MAX, V|D, "debug"},
-{"pts", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_PTS }, INT_MIN, INT_MAX, V|D, "debug"},
-{"er", "error recognition", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_ER }, INT_MIN, INT_MAX, V|D, "debug"},
-{"mmco", "memory management control operations (H.264)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_MMCO }, INT_MIN, INT_MAX, V|D, "debug"},
-{"bugs", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_BUGS }, INT_MIN, INT_MAX, V|D, "debug"},
-{"vis_qp", "visualize quantization parameter (QP), lower QP are tinted greener", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_VIS_QP }, INT_MIN, INT_MAX, V|D, "debug"},
-{"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|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"},
-{"bb", "backward predicted MVs of B-frames", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_VIS_MV_B_BACK }, INT_MIN, INT_MAX, V|D, "debug_mv"},
-{"cmp", "full-pel ME compare function", OFFSET(me_cmp), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"subcmp", "sub-pel ME compare function", OFFSET(me_sub_cmp), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"mbcmp", "macroblock compare function", OFFSET(mb_cmp), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"ildctcmp", "interlaced DCT compare function", OFFSET(ildct_cmp), AV_OPT_TYPE_INT, {.i64 = FF_CMP_VSAD }, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"dia_size", "diamond type & size for motion estimation", OFFSET(dia_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
-{"last_pred", "amount of motion predictors from the previous frame", OFFSET(last_predictor_count), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
-{"preme", "pre motion estimation", OFFSET(pre_me), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
-{"precmp", "pre motion estimation compare function", OFFSET(me_pre_cmp), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"sad", "sum of absolute differences, fast (default)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SAD }, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"sse", "sum of squared errors", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SSE }, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"satd", "sum of absolute Hadamard transformed differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SATD }, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"dct", "sum of absolute DCT transformed differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_DCT }, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"psnr", "sum of squared quantization errors (avoid, low quality)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_PSNR }, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"bit", "number of bits needed for the block", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_BIT }, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"rd", "rate distortion optimal, slow", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_RD }, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"zero", "0", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_ZERO }, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"vsad", "sum of absolute vertical differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_VSAD }, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"vsse", "sum of squared vertical differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_VSSE }, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"nsse", "noise preserving sum of squared differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_NSSE }, INT_MIN, INT_MAX, V|E, "cmp_func"},
-#if CONFIG_SNOW_ENCODER
-{"w53", "5/3 wavelet, only used in snow", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_W53 }, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"w97", "9/7 wavelet, only used in snow", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_W97 }, INT_MIN, INT_MAX, V|E, "cmp_func"},
-#endif
-{"dctmax", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"chroma", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_CHROMA }, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"pre_dia_size", "diamond type & size for motion estimation pre-pass", OFFSET(pre_dia_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
-{"subq", "sub-pel motion estimation quality", OFFSET(me_subpel_quality), AV_OPT_TYPE_INT, {.i64 = 8 }, INT_MIN, INT_MAX, V|E},
-{"dtg_active_format", NULL, OFFSET(dtg_active_format), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
-{"me_range", "limit motion vectors range (1023 for DivX player)", OFFSET(me_range), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
-{"ibias", "intra quant bias", OFFSET(intra_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, V|E},
-{"pbias", "inter quant bias", OFFSET(inter_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, V|E},
-#if FF_API_COLOR_TABLE_ID
-{"color_table_id", NULL, OFFSET(color_table_id), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
-#endif
-{"global_quality", NULL, OFFSET(global_quality), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|A|E},
-{"coder", NULL, OFFSET(coder_type), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "coder"},
-{"vlc", "variable length coder / Huffman coder", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CODER_TYPE_VLC }, INT_MIN, INT_MAX, V|E, "coder"},
-{"ac", "arithmetic coder", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CODER_TYPE_AC }, INT_MIN, INT_MAX, V|E, "coder"},
-{"raw", "raw (no encoding)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CODER_TYPE_RAW }, INT_MIN, INT_MAX, V|E, "coder"},
-{"rle", "run-length coder", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CODER_TYPE_RLE }, INT_MIN, INT_MAX, V|E, "coder"},
-{"deflate", "deflate-based coder", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CODER_TYPE_DEFLATE }, INT_MIN, INT_MAX, V|E, "coder"},
-{"context", "context model", OFFSET(context_model), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
-{"slice_flags", NULL, OFFSET(slice_flags), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
-{"xvmc_acceleration", NULL, OFFSET(xvmc_acceleration), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
-{"mbd", "macroblock decision algorithm (high quality mode)", OFFSET(mb_decision), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E, "mbd"},
-{"simple", "use mbcmp (default)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MB_DECISION_SIMPLE }, INT_MIN, INT_MAX, V|E, "mbd"},
-{"bits", "use fewest bits", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MB_DECISION_BITS }, INT_MIN, INT_MAX, V|E, "mbd"},
-{"rd", "use best rate distortion", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MB_DECISION_RD }, INT_MIN, INT_MAX, V|E, "mbd"},
-{"stream_codec_tag", NULL, OFFSET(stream_codec_tag), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
-{"sc_threshold", "scene change threshold", OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
-{"lmin", "minimum Lagrange factor (VBR)", OFFSET(lmin), AV_OPT_TYPE_INT, {.i64 = 2*FF_QP2LAMBDA }, 0, INT_MAX, V|E},
-{"lmax", "maximum Lagrange factor (VBR)", OFFSET(lmax), AV_OPT_TYPE_INT, {.i64 = 31*FF_QP2LAMBDA }, 0, INT_MAX, V|E},
-{"nr", "noise reduction", OFFSET(noise_reduction), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
-{"rc_init_occupancy", "number of bits which should be loaded into the rc buffer before decoding starts", OFFSET(rc_initial_buffer_occupancy), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
-#if FF_API_INTER_THRESHOLD
-{"inter_threshold", NULL, OFFSET(inter_threshold), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
-#endif
-{"flags2", NULL, OFFSET(flags2), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT}, 0, UINT_MAX, V|A|E|D, "flags2"},
-{"error", NULL, OFFSET(error_rate), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
-#if FF_API_MPV_GLOBAL_OPTS
-{"qns", "deprecated, use mpegvideo private options instead", OFFSET(quantizer_noise_shaping), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
-#endif
-{"threads", NULL, OFFSET(thread_count), AV_OPT_TYPE_INT, {.i64 = 1 }, 0, INT_MAX, V|E|D, "threads"},
-{"auto", "autodetect a suitable number of threads to use", 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, INT_MIN, INT_MAX, V|E|D, "threads"},
-{"me_threshold", "motion estimation threshold", OFFSET(me_threshold), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
-{"mb_threshold", "macroblock threshold", OFFSET(mb_threshold), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
-{"dc", "intra_dc_precision", OFFSET(intra_dc_precision), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, V|E},
-{"nssew", "nsse weight", OFFSET(nsse_weight), AV_OPT_TYPE_INT, {.i64 = 8 }, INT_MIN, INT_MAX, V|E},
-{"skip_top", "number of macroblock rows at the top which are skipped", OFFSET(skip_top), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|D},
-{"skip_bottom", "number of macroblock rows at the bottom which are skipped", OFFSET(skip_bottom), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|D},
-{"profile", NULL, OFFSET(profile), AV_OPT_TYPE_INT, {.i64 = FF_PROFILE_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "profile"},
-{"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "profile"},
-{"aac_main", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_MAIN }, INT_MIN, INT_MAX, A|E, "profile"},
-{"aac_low", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_LOW }, INT_MIN, INT_MAX, A|E, "profile"},
-{"aac_ssr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_SSR }, INT_MIN, INT_MAX, A|E, "profile"},
-{"aac_ltp", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_LTP }, INT_MIN, INT_MAX, A|E, "profile"},
-{"aac_he", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_HE }, INT_MIN, INT_MAX, A|E, "profile"},
-{"aac_he_v2", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_HE_V2 }, INT_MIN, INT_MAX, A|E, "profile"},
-{"aac_ld", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_LD }, INT_MIN, INT_MAX, A|E, "profile"},
-{"aac_eld", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_AAC_ELD }, INT_MIN, INT_MAX, A|E, "profile"},
-{"dts", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS }, INT_MIN, INT_MAX, A|E, "profile"},
-{"dts_es", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_ES }, INT_MIN, INT_MAX, A|E, "profile"},
-{"dts_96_24", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_96_24 }, INT_MIN, INT_MAX, A|E, "profile"},
-{"dts_hd_hra", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_HD_HRA }, INT_MIN, INT_MAX, A|E, "profile"},
-{"dts_hd_ma", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_HD_MA }, INT_MIN, INT_MAX, A|E, "profile"},
-{"level", NULL, OFFSET(level), AV_OPT_TYPE_INT, {.i64 = FF_LEVEL_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "level"},
-{"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_LEVEL_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "level"},
-{"lowres", "decode at 1= 1/2, 2=1/4, 3=1/8 resolutions", OFFSET(lowres), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, V|A|D},
-{"skip_threshold", "frame skip threshold", OFFSET(frame_skip_threshold), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
-{"skip_factor", "frame skip factor", OFFSET(frame_skip_factor), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
-{"skip_exp", "frame skip exponent", OFFSET(frame_skip_exp), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
-{"skipcmp", "frame skip compare function", OFFSET(frame_skip_cmp), AV_OPT_TYPE_INT, {.i64 = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, V|E, "cmp_func"},
-{"border_mask", "increase the quantizer for macroblocks close to borders", OFFSET(border_masking), AV_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, -FLT_MAX, FLT_MAX, V|E},
-{"mblmin", "minimum macroblock Lagrange factor (VBR)", OFFSET(mb_lmin), AV_OPT_TYPE_INT, {.i64 = FF_QP2LAMBDA * 2 }, 1, FF_LAMBDA_MAX, V|E},
-{"mblmax", "maximum macroblock Lagrange factor (VBR)", OFFSET(mb_lmax), AV_OPT_TYPE_INT, {.i64 = FF_QP2LAMBDA * 31 }, 1, FF_LAMBDA_MAX, V|E},
-{"mepc", "motion estimation bitrate penalty compensation (1.0 = 256)", OFFSET(me_penalty_compensation), AV_OPT_TYPE_INT, {.i64 = 256 }, INT_MIN, INT_MAX, V|E},
-{"skip_loop_filter", NULL, OFFSET(skip_loop_filter), AV_OPT_TYPE_INT, {.i64 = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX, V|D, "avdiscard"},
-{"skip_idct" , NULL, OFFSET(skip_idct) , AV_OPT_TYPE_INT, {.i64 = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX, V|D, "avdiscard"},
-{"skip_frame" , NULL, OFFSET(skip_frame) , AV_OPT_TYPE_INT, {.i64 = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX, V|D, "avdiscard"},
-{"none" , NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONE }, INT_MIN, INT_MAX, V|D, "avdiscard"},
-{"default" , NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX, V|D, "avdiscard"},
-{"noref" , NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONREF }, INT_MIN, INT_MAX, V|D, "avdiscard"},
-{"bidir" , NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_BIDIR }, INT_MIN, INT_MAX, V|D, "avdiscard"},
-{"nokey" , NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONKEY }, INT_MIN, INT_MAX, V|D, "avdiscard"},
-{"all" , NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_ALL }, INT_MIN, INT_MAX, V|D, "avdiscard"},
-{"bidir_refine", "refine the two motion vectors used in bidirectional macroblocks", OFFSET(bidir_refine), AV_OPT_TYPE_INT, {.i64 = 1 }, 0, 4, V|E},
-{"brd_scale", "downscale frames for dynamic B-frame decision", OFFSET(brd_scale), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, 10, V|E},
-{"keyint_min", "minimum interval between IDR-frames", OFFSET(keyint_min), AV_OPT_TYPE_INT, {.i64 = 25 }, INT_MIN, INT_MAX, V|E},
-{"refs", "reference frames to consider for motion compensation", OFFSET(refs), AV_OPT_TYPE_INT, {.i64 = 1 }, INT_MIN, INT_MAX, V|E},
-{"chromaoffset", "chroma QP offset from luma", OFFSET(chromaoffset), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
-{"trellis", "rate-distortion optimal quantization", OFFSET(trellis), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|A|E},
-#if FF_API_MPV_GLOBAL_OPTS
-{"skiprd", "Deprecated, use mpegvideo private options instead", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_SKIP_RD }, INT_MIN, INT_MAX, V|E, "flags2"},
-#endif
-{"sc_factor", "multiplied by qscale for each frame and added to scene_change_score", OFFSET(scenechange_factor), AV_OPT_TYPE_INT, {.i64 = 6 }, 0, INT_MAX, V|E},
-{"mv0_threshold", NULL, OFFSET(mv0_threshold), AV_OPT_TYPE_INT, {.i64 = 256 }, 0, INT_MAX, V|E},
-{"b_sensitivity", "adjust sensitivity of b_frame_strategy 1", OFFSET(b_sensitivity), AV_OPT_TYPE_INT, {.i64 = 40 }, 1, INT_MAX, V|E},
-{"compression_level", NULL, OFFSET(compression_level), AV_OPT_TYPE_INT, {.i64 = FF_COMPRESSION_DEFAULT }, INT_MIN, INT_MAX, V|A|E},
-{"min_prediction_order", NULL, OFFSET(min_prediction_order), AV_OPT_TYPE_INT, {.i64 = -1 }, INT_MIN, INT_MAX, A|E},
-{"max_prediction_order", NULL, OFFSET(max_prediction_order), AV_OPT_TYPE_INT, {.i64 = -1 }, INT_MIN, INT_MAX, A|E},
-{"timecode_frame_start", "GOP timecode frame start number, in non-drop-frame format", OFFSET(timecode_frame_start), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT64_MAX, V|E},
-#if FF_API_REQUEST_CHANNELS
-{"request_channels", "set desired number of audio channels", OFFSET(request_channels), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, A|D},
-#endif
-{"bits_per_raw_sample", NULL, OFFSET(bits_per_raw_sample), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
-{"channel_layout", NULL, OFFSET(channel_layout), AV_OPT_TYPE_INT64, {.i64 = DEFAULT }, 0, INT64_MAX, A|E|D, "channel_layout"},
-{"request_channel_layout", NULL, OFFSET(request_channel_layout), AV_OPT_TYPE_INT64, {.i64 = DEFAULT }, 0, INT64_MAX, A|D, "request_channel_layout"},
-{"rc_max_vbv_use", NULL, OFFSET(rc_max_available_vbv_use), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, 0.0, FLT_MAX, V|E},
-{"rc_min_vbv_use", NULL, OFFSET(rc_min_vbv_overflow_use), AV_OPT_TYPE_FLOAT, {.dbl = 3 }, 0.0, FLT_MAX, V|E},
-{"ticks_per_frame", NULL, OFFSET(ticks_per_frame), AV_OPT_TYPE_INT, {.i64 = 1 }, 1, INT_MAX, A|V|E|D},
-{"color_primaries", NULL, OFFSET(color_primaries), AV_OPT_TYPE_INT, {.i64 = AVCOL_PRI_UNSPECIFIED }, 1, AVCOL_PRI_NB-1, V|E|D},
-{"color_trc", NULL, OFFSET(color_trc), AV_OPT_TYPE_INT, {.i64 = AVCOL_TRC_UNSPECIFIED }, 1, AVCOL_TRC_NB-1, V|E|D},
-{"colorspace", NULL, OFFSET(colorspace), AV_OPT_TYPE_INT, {.i64 = AVCOL_SPC_UNSPECIFIED }, 1, AVCOL_SPC_NB-1, V|E|D},
-{"color_range", NULL, OFFSET(color_range), AV_OPT_TYPE_INT, {.i64 = AVCOL_RANGE_UNSPECIFIED }, 0, AVCOL_RANGE_NB-1, V|E|D},
-{"chroma_sample_location", NULL, OFFSET(chroma_sample_location), AV_OPT_TYPE_INT, {.i64 = AVCHROMA_LOC_UNSPECIFIED }, 0, AVCHROMA_LOC_NB-1, V|E|D},
-{"log_level_offset", "set the log level offset", OFFSET(log_level_offset), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX },
-{"slices", "number of slices, used in parallelized encoding", OFFSET(slices), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, V|E},
-{"thread_type", "select multithreading type", OFFSET(thread_type), AV_OPT_TYPE_FLAGS, {.i64 = FF_THREAD_SLICE|FF_THREAD_FRAME }, 0, INT_MAX, V|E|D, "thread_type"},
-{"slice", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_THREAD_SLICE }, INT_MIN, INT_MAX, V|E|D, "thread_type"},
-{"frame", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_THREAD_FRAME }, INT_MIN, INT_MAX, V|E|D, "thread_type"},
-{"audio_service_type", "audio service type", OFFSET(audio_service_type), AV_OPT_TYPE_INT, {.i64 = AV_AUDIO_SERVICE_TYPE_MAIN }, 0, AV_AUDIO_SERVICE_TYPE_NB-1, A|E, "audio_service_type"},
-{"ma", "Main Audio Service", 0, AV_OPT_TYPE_CONST, {.i64 = AV_AUDIO_SERVICE_TYPE_MAIN }, INT_MIN, INT_MAX, A|E, "audio_service_type"},
-{"ef", "Effects", 0, AV_OPT_TYPE_CONST, {.i64 = AV_AUDIO_SERVICE_TYPE_EFFECTS }, INT_MIN, INT_MAX, A|E, "audio_service_type"},
-{"vi", "Visually Impaired", 0, AV_OPT_TYPE_CONST, {.i64 = AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED }, INT_MIN, INT_MAX, A|E, "audio_service_type"},
-{"hi", "Hearing Impaired", 0, AV_OPT_TYPE_CONST, {.i64 = AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED }, INT_MIN, INT_MAX, A|E, "audio_service_type"},
-{"di", "Dialogue", 0, AV_OPT_TYPE_CONST, {.i64 = AV_AUDIO_SERVICE_TYPE_DIALOGUE }, INT_MIN, INT_MAX, A|E, "audio_service_type"},
-{"co", "Commentary", 0, AV_OPT_TYPE_CONST, {.i64 = AV_AUDIO_SERVICE_TYPE_COMMENTARY }, INT_MIN, INT_MAX, A|E, "audio_service_type"},
-{"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"},
-{"pkt_timebase", NULL, OFFSET(pkt_timebase), AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, 0, INT_MAX, 0},
-{NULL},
-};
-
-#undef A
-#undef V
-#undef S
-#undef E
-#undef D
-#undef DEFAULT
-#undef OFFSET
-
-#endif /* AVCODEC_OPTIONS_TABLE_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/parser.c b/src/thirdparty/ffmpeg/libavcodec/parser.c
deleted file mode 100644
index 687943f34..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/parser.c
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Audio and Video frame extraction
- * Copyright (c) 2003 Fabrice Bellard
- * Copyright (c) 2003 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 <string.h>
-
-#include "parser.h"
-#include "libavutil/mem.h"
-
-static AVCodecParser *av_first_parser = NULL;
-
-AVCodecParser* av_parser_next(AVCodecParser *p){
- if(p) return p->next;
- else return av_first_parser;
-}
-
-void av_register_codec_parser(AVCodecParser *parser)
-{
- parser->next = av_first_parser;
- av_first_parser = parser;
-}
-
-AVCodecParserContext *av_parser_init(int codec_id)
-{
- AVCodecParserContext *s = NULL;
- AVCodecParser *parser;
- int ret;
-
- if(codec_id == AV_CODEC_ID_NONE)
- return NULL;
-
- 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 ||
- parser->codec_ids[3] == codec_id ||
- parser->codec_ids[4] == codec_id)
- goto found;
- }
- return NULL;
- found:
- s = av_mallocz(sizeof(AVCodecParserContext));
- if (!s)
- goto err_out;
- s->parser = parser;
- s->priv_data = av_mallocz(parser->priv_data_size);
- if (!s->priv_data)
- goto err_out;
- s->fetch_timestamp=1;
- s->pict_type = AV_PICTURE_TYPE_I;
- if (parser->parser_init) {
- ret = parser->parser_init(s);
- if (ret != 0)
- goto err_out;
- }
- s->key_frame = -1;
- s->convergence_duration = 0;
- s->dts_sync_point = INT_MIN;
- s->dts_ref_dts_delta = INT_MIN;
- s->pts_dts_delta = INT_MIN;
- return s;
-
-err_out:
- if (s)
- av_freep(&s->priv_data);
- av_free(s);
- return NULL;
-}
-
-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
- // 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->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])
- break;
- }
- }
-}
-
-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)
-{
- int index, i;
- uint8_t dummy_buf[FF_INPUT_BUFFER_PADDING_SIZE];
-
- if(!(s->flags & PARSER_FLAG_FETCHED_OFFSET)) {
- s->next_frame_offset =
- s->cur_offset = pos;
- 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 */
- /* 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;
- }
-
- 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);
- /* update the file pointer */
- if (*poutbuf_size) {
- /* fill the data for the current frame */
- s->frame_offset = s->next_frame_offset;
-
- /* offset of the next frame */
- s->next_frame_offset = s->cur_offset + index;
- s->fetch_timestamp=1;
- }
- if (index < 0)
- index = 0;
- s->cur_offset += index;
- return index;
-}
-
-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;
- 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);
-
- memcpy(*poutbuf, avctx->extradata, avctx->extradata_size);
- memcpy((*poutbuf) + avctx->extradata_size, buf, buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
- return 1;
- }
- }
-
- return 0;
-}
-
-void av_parser_close(AVCodecParserContext *s)
-{
- if(s){
- if (s->parser->parser_close)
- s->parser->parser_close(s);
- av_free(s->priv_data);
- av_free(s);
- }
-}
-
-/*****************************************************/
-
-int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size)
-{
- 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]);
- }
-
- /* Copy overread bytes from last frame into buffer. */
- 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;
- }
-
- 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(!new_buffer)
- return AVERROR(ENOMEM);
- pc->buffer = new_buffer;
- memcpy(&pc->buffer[pc->index], *buf, *buf_size);
- pc->index += *buf_size;
- return -1;
- }
-
- *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)
- return AVERROR(ENOMEM);
- pc->buffer = new_buffer;
- if (next > -FF_INPUT_BUFFER_PADDING_SIZE)
- memcpy(&pc->buffer[pc->index], *buf,
- next + FF_INPUT_BUFFER_PADDING_SIZE);
- pc->index = 0;
- *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];
- 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]);
- }
-
- return 0;
-}
-
-void ff_parse_close(AVCodecParserContext *s)
-{
- ParseContext *pc = s->priv_data;
-
- av_freep(&pc->buffer);
-}
-
-/*************************/
-
-int ff_mpeg4video_split(AVCodecContext *avctx,
- const uint8_t *buf, int buf_size)
-{
- int i;
- uint32_t state= -1;
-
- 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/src/thirdparty/ffmpeg/libavcodec/parser.h b/src/thirdparty/ffmpeg/libavcodec/parser.h
deleted file mode 100644
index eb2382712..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/parser.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * AVCodecParser prototypes and definitions
- * Copyright (c) 2003 Fabrice Bellard
- * Copyright (c) 2003 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
- */
-
-#ifndef AVCODEC_PARSER_H
-#define AVCODEC_PARSER_H
-
-#include "avcodec.h"
-
-typedef struct ParseContext{
- uint8_t *buffer;
- int index;
- int last_index;
- unsigned int buffer_size;
- uint32_t state; ///< contains the last few bytes in MSB order
- int frame_start_found;
- int overread; ///< the number of bytes which where irreversibly read from the next frame
- int overread_index; ///< the index into ParseContext.buffer of the overread bytes
- uint64_t state64; ///< contains the last 8 bytes in MSB order
-} ParseContext;
-
-#define END_NOT_FOUND (-100)
-
-/**
- * Combine the (truncated) bitstream to a complete frame.
- * @return -1 if no complete frame could be created,
- * AVERROR(ENOMEM) if there was a memory allocation error
- */
-int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size);
-int ff_mpeg4video_split(AVCodecContext *avctx, const uint8_t *buf,
- int buf_size);
-void ff_parse_close(AVCodecParserContext *s);
-
-/**
- * Fetch timestamps for a specific byte within the current access unit.
- * @param off byte position within the access unit
- * @param remove Found timestamps will be removed if set to 1, kept if set to 0.
- */
-void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove);
-
-#endif /* AVCODEC_PARSER_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/png.h b/src/thirdparty/ffmpeg/libavcodec/png.h
deleted file mode 100644
index c08218824..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/png.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * PNG image format
- * Copyright (c) 2003 Fabrice Bellard
- *
- * 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_PNG_H
-#define AVCODEC_PNG_H
-
-#include <stdint.h>
-
-#define PNG_COLOR_MASK_PALETTE 1
-#define PNG_COLOR_MASK_COLOR 2
-#define PNG_COLOR_MASK_ALPHA 4
-
-#define PNG_COLOR_TYPE_GRAY 0
-#define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
-#define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR)
-#define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
-#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)
-
-#define PNG_FILTER_TYPE_LOCO 64
-#define PNG_FILTER_VALUE_NONE 0
-#define PNG_FILTER_VALUE_SUB 1
-#define PNG_FILTER_VALUE_UP 2
-#define PNG_FILTER_VALUE_AVG 3
-#define PNG_FILTER_VALUE_PAETH 4
-#define PNG_FILTER_VALUE_MIXED 5
-
-#define PNG_IHDR 0x0001
-#define PNG_IDAT 0x0002
-#define PNG_ALLIMAGE 0x0004
-#define PNG_PLTE 0x0008
-
-#define NB_PASSES 7
-
-#define PNGSIG 0x89504e470d0a1a0a
-#define MNGSIG 0x8a4d4e470d0a1a0a
-
-/* Mask to determine which y pixels are valid in a pass */
-extern const uint8_t ff_png_pass_ymask[NB_PASSES];
-
-void *ff_png_zalloc(void *opaque, unsigned int items, unsigned int size);
-
-void ff_png_zfree(void *opaque, void *ptr);
-
-int ff_png_get_nb_channels(int color_type);
-
-/* compute the row size of an interleaved pass */
-int ff_png_pass_row_size(int pass, int bits_per_pixel, int width);
-
-void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp);
-
-#endif /* AVCODEC_PNG_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/pthread.c b/src/thirdparty/ffmpeg/libavcodec/pthread.c
deleted file mode 100644
index 66968dc1f..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/pthread.c
+++ /dev/null
@@ -1,1158 +0,0 @@
-/*
- * Copyright (c) 2004 Roman Shaposhnik
- * Copyright (c) 2008 Alexander Strange (astrange@ithinksw.com)
- *
- * Many thanks to Steven M. Schultz for providing clever ideas and
- * to Michael Niedermayer <michaelni@gmx.at> for writing initial
- * implementation.
- *
- * 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
- * Multithreading support functions
- * @see doc/multithreading.txt
- */
-
-#include "config.h"
-
-#if HAVE_SCHED_GETAFFINITY
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE
-#endif
-#include <sched.h>
-#endif
-#if HAVE_GETPROCESSAFFINITYMASK
-#include <windows.h>
-#endif
-#if HAVE_SYSCTL
-#if HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#endif
-#if HAVE_SYSCONF
-#include <unistd.h>
-#endif
-
-#include "avcodec.h"
-#include "internal.h"
-#include "thread.h"
-#include "libavutil/common.h"
-
-#if HAVE_PTHREADS
-#include <pthread.h>
-#elif HAVE_W32THREADS
-#include "w32pthreads.h"
-#elif HAVE_OS2THREADS
-#include "os2threads.h"
-#endif
-
-// ==> Start patch MPC
-int ff_pthread_lockmgr_cb(void **mutex, enum AVLockOp op)
-{
- int ret = 0;
- av_log(NULL, AV_LOG_DEBUG, "ff_pthread_lockmgr_cb called %d on mutex %p\n", op, *mutex);
- switch (op) {
- case AV_LOCK_CREATE:
- *mutex = av_malloc(sizeof(pthread_mutex_t));
- if (!mutex)
- return AVERROR(ENOMEM);
- ret = pthread_mutex_init(*mutex, NULL);
- break;
- case AV_LOCK_OBTAIN:
- ret = pthread_mutex_lock(*mutex);
- break;
- case AV_LOCK_RELEASE:
- ret = pthread_mutex_unlock(*mutex);
- break;
- case AV_LOCK_DESTROY:
- ret = pthread_mutex_destroy(*mutex);
- av_freep(mutex);
- break;
- default:
- return AVERROR_BUG;
- }
- return AVERROR(ret);
-}
-// ==> End patch MPC
-
-typedef int (action_func)(AVCodecContext *c, void *arg);
-typedef int (action_func2)(AVCodecContext *c, void *arg, int jobnr, int threadnr);
-
-typedef struct ThreadContext {
- pthread_t *workers;
- action_func *func;
- action_func2 *func2;
- void *args;
- int *rets;
- int rets_count;
- int job_count;
- int job_size;
-
- pthread_cond_t last_job_cond;
- pthread_cond_t current_job_cond;
- pthread_mutex_t current_job_lock;
- int current_job;
- unsigned int current_execute;
- int done;
-} ThreadContext;
-
-/// Max number of frame buffers that can be allocated when using frame threads.
-#define MAX_BUFFERS (34+1)
-
-/**
- * Context used by codec threads and stored in their AVCodecContext thread_opaque.
- */
-typedef struct PerThreadContext {
- struct FrameThreadContext *parent;
-
- pthread_t thread;
- int thread_init;
- pthread_cond_t input_cond; ///< Used to wait for a new packet from the main thread.
- pthread_cond_t progress_cond; ///< Used by child threads to wait for progress to change.
- pthread_cond_t output_cond; ///< Used by the main thread to wait for frames to finish.
-
- pthread_mutex_t mutex; ///< Mutex used to protect the contents of the PerThreadContext.
- pthread_mutex_t progress_mutex; ///< Mutex used to protect frame progress values and progress_cond.
-
- AVCodecContext *avctx; ///< Context used to decode packets passed to this thread.
-
- AVPacket avpkt; ///< Input packet (for decoding) or output (for encoding).
- int allocated_buf_size; ///< Size allocated for avpkt.data
-
- AVFrame frame; ///< Output frame (for decoding) or input (for encoding).
- int got_frame; ///< The output of got_picture_ptr from the last avcodec_decode_video() call.
- int result; ///< The result of the last codec decode/encode() call.
-
- enum {
- STATE_INPUT_READY, ///< Set when the thread is awaiting a packet.
- STATE_SETTING_UP, ///< Set before the codec has called ff_thread_finish_setup().
- STATE_GET_BUFFER, /**<
- * Set when the codec calls get_buffer().
- * State is returned to STATE_SETTING_UP afterwards.
- */
- STATE_SETUP_FINISHED ///< Set after the codec has called ff_thread_finish_setup().
- } state;
-
- /**
- * Array of frames passed to ff_thread_release_buffer().
- * Frames are released after all threads referencing them are finished.
- */
- AVFrame released_buffers[MAX_BUFFERS];
- int num_released_buffers;
-
- /**
- * Array of progress values used by ff_thread_get_buffer().
- */
- volatile int progress[MAX_BUFFERS][2];
- volatile uint8_t progress_used[MAX_BUFFERS];
-
- AVFrame *requested_frame; ///< AVFrame the codec passed to get_buffer()
-} PerThreadContext;
-
-/**
- * Context stored in the client AVCodecContext thread_opaque.
- */
-typedef struct FrameThreadContext {
- PerThreadContext *threads; ///< The contexts for each thread.
- PerThreadContext *prev_thread; ///< The last thread submit_packet() was called on.
-
- pthread_mutex_t buffer_mutex; ///< Mutex used to protect get/release_buffer().
-
- int next_decoding; ///< The next context to submit a packet to.
- int next_finished; ///< The next context to return output from.
-
- int delaying; /**<
- * Set for the first N packets, where N is the number of threads.
- * While it is set, ff_thread_en/decode_frame won't return any results.
- */
-
- int die; ///< Set when threads should exit.
-} FrameThreadContext;
-
-
-/* H264 slice threading seems to be buggy with more than 16 threads,
- * limit the number of threads to 16 for automatic detection */
-#define MAX_AUTO_THREADS 16
-
-int ff_get_logical_cpus(AVCodecContext *avctx)
-{
- int ret, nb_cpus = 1;
-#if HAVE_SCHED_GETAFFINITY && defined(CPU_COUNT)
- cpu_set_t cpuset;
-
- CPU_ZERO(&cpuset);
-
- ret = sched_getaffinity(0, sizeof(cpuset), &cpuset);
- if (!ret) {
- nb_cpus = CPU_COUNT(&cpuset);
- }
-#elif HAVE_GETPROCESSAFFINITYMASK
- DWORD_PTR proc_aff, sys_aff;
- ret = GetProcessAffinityMask(GetCurrentProcess(), &proc_aff, &sys_aff);
- if (ret)
- nb_cpus = av_popcount64(proc_aff);
-#elif HAVE_SYSCTL && defined(HW_NCPU)
- int mib[2] = { CTL_HW, HW_NCPU };
- size_t len = sizeof(nb_cpus);
-
- ret = sysctl(mib, 2, &nb_cpus, &len, NULL, 0);
- if (ret == -1)
- nb_cpus = 0;
-#elif HAVE_SYSCONF && defined(_SC_NPROC_ONLN)
- nb_cpus = sysconf(_SC_NPROC_ONLN);
-#elif HAVE_SYSCONF && defined(_SC_NPROCESSORS_ONLN)
- nb_cpus = sysconf(_SC_NPROCESSORS_ONLN);
-#endif
- av_log(avctx, AV_LOG_DEBUG, "detected %d logical cores\n", nb_cpus);
-
- if (avctx->height)
- nb_cpus = FFMIN(nb_cpus, (avctx->height+15)/16);
-
- return nb_cpus;
-}
-
-
-static void* attribute_align_arg worker(void *v)
-{
- AVCodecContext *avctx = v;
- ThreadContext *c = avctx->thread_opaque;
- int our_job = c->job_count;
- int last_execute = 0;
- int thread_count = avctx->thread_count;
- int self_id;
-
- pthread_mutex_lock(&c->current_job_lock);
- self_id = c->current_job++;
- for (;;){
- while (our_job >= c->job_count) {
- if (c->current_job == thread_count + c->job_count)
- pthread_cond_signal(&c->last_job_cond);
-
- while (last_execute == c->current_execute && !c->done)
- pthread_cond_wait(&c->current_job_cond, &c->current_job_lock);
- last_execute = c->current_execute;
- our_job = self_id;
-
- if (c->done) {
- pthread_mutex_unlock(&c->current_job_lock);
- return NULL;
- }
- }
- pthread_mutex_unlock(&c->current_job_lock);
-
- c->rets[our_job%c->rets_count] = c->func ? c->func(avctx, (char*)c->args + our_job*c->job_size):
- c->func2(avctx, c->args, our_job, self_id);
-
- pthread_mutex_lock(&c->current_job_lock);
- our_job = c->current_job++;
- }
-}
-
-static av_always_inline void avcodec_thread_park_workers(ThreadContext *c, int thread_count)
-{
- while (c->current_job != thread_count + c->job_count)
- pthread_cond_wait(&c->last_job_cond, &c->current_job_lock);
- pthread_mutex_unlock(&c->current_job_lock);
-}
-
-static void thread_free(AVCodecContext *avctx)
-{
- ThreadContext *c = avctx->thread_opaque;
- int i;
-
- pthread_mutex_lock(&c->current_job_lock);
- c->done = 1;
- pthread_cond_broadcast(&c->current_job_cond);
- pthread_mutex_unlock(&c->current_job_lock);
-
- for (i=0; i<avctx->thread_count; i++)
- pthread_join(c->workers[i], NULL);
-
- pthread_mutex_destroy(&c->current_job_lock);
- pthread_cond_destroy(&c->current_job_cond);
- pthread_cond_destroy(&c->last_job_cond);
- av_free(c->workers);
- av_freep(&avctx->thread_opaque);
-}
-
-static int avcodec_thread_execute(AVCodecContext *avctx, action_func* func, void *arg, int *ret, int job_count, int job_size)
-{
- ThreadContext *c= avctx->thread_opaque;
- int dummy_ret;
-
- if (!(avctx->active_thread_type&FF_THREAD_SLICE) || avctx->thread_count <= 1)
- return avcodec_default_execute(avctx, func, arg, ret, job_count, job_size);
-
- if (job_count <= 0)
- return 0;
-
- pthread_mutex_lock(&c->current_job_lock);
-
- c->current_job = avctx->thread_count;
- c->job_count = job_count;
- c->job_size = job_size;
- c->args = arg;
- c->func = func;
- if (ret) {
- c->rets = ret;
- c->rets_count = job_count;
- } else {
- c->rets = &dummy_ret;
- c->rets_count = 1;
- }
- c->current_execute++;
- pthread_cond_broadcast(&c->current_job_cond);
-
- avcodec_thread_park_workers(c, avctx->thread_count);
-
- return 0;
-}
-
-static int avcodec_thread_execute2(AVCodecContext *avctx, action_func2* func2, void *arg, int *ret, int job_count)
-{
- ThreadContext *c= avctx->thread_opaque;
- c->func2 = func2;
- return avcodec_thread_execute(avctx, NULL, arg, ret, job_count, 0);
-}
-
-static int thread_init(AVCodecContext *avctx)
-{
- int i;
- ThreadContext *c;
- int thread_count = avctx->thread_count;
-
- if (!thread_count) {
- int nb_cpus = ff_get_logical_cpus(avctx);
- // use number of cores + 1 as thread count if there is more than one
- if (nb_cpus > 1)
- thread_count = avctx->thread_count = FFMIN(nb_cpus + 1, MAX_AUTO_THREADS);
- else
- thread_count = avctx->thread_count = 1;
- }
-
- if (thread_count <= 1) {
- avctx->active_thread_type = 0;
- return 0;
- }
-
- c = av_mallocz(sizeof(ThreadContext));
- if (!c)
- return -1;
-
- c->workers = av_mallocz(sizeof(pthread_t)*thread_count);
- if (!c->workers) {
- av_free(c);
- return -1;
- }
-
- avctx->thread_opaque = c;
- c->current_job = 0;
- c->job_count = 0;
- c->job_size = 0;
- c->done = 0;
- pthread_cond_init(&c->current_job_cond, NULL);
- pthread_cond_init(&c->last_job_cond, NULL);
- pthread_mutex_init(&c->current_job_lock, NULL);
- pthread_mutex_lock(&c->current_job_lock);
- for (i=0; i<thread_count; i++) {
- if(pthread_create(&c->workers[i], NULL, worker, avctx)) {
- avctx->thread_count = i;
- pthread_mutex_unlock(&c->current_job_lock);
- ff_thread_free(avctx);
- return -1;
- }
- }
-
- avcodec_thread_park_workers(c, thread_count);
-
- avctx->execute = avcodec_thread_execute;
- avctx->execute2 = avcodec_thread_execute2;
- return 0;
-}
-
-/**
- * Codec worker thread.
- *
- * Automatically calls ff_thread_finish_setup() if the codec does
- * not provide an update_thread_context method, or if the codec returns
- * before calling it.
- */
-static attribute_align_arg void *frame_worker_thread(void *arg)
-{
- PerThreadContext *p = arg;
- FrameThreadContext *fctx = p->parent;
- AVCodecContext *avctx = p->avctx;
- const AVCodec *codec = avctx->codec;
-
- pthread_mutex_lock(&p->mutex);
- while (1) {
- int i;
- while (p->state == STATE_INPUT_READY && !fctx->die)
- pthread_cond_wait(&p->input_cond, &p->mutex);
-
- if (fctx->die) break;
-
- if (!codec->update_thread_context && (avctx->thread_safe_callbacks || avctx->get_buffer == avcodec_default_get_buffer))
- ff_thread_finish_setup(avctx);
-
- avcodec_get_frame_defaults(&p->frame);
- p->got_frame = 0;
- p->result = codec->decode(avctx, &p->frame, &p->got_frame, &p->avpkt);
-
- /* many decoders assign whole AVFrames, thus overwriting extended_data;
- * make sure it's set correctly */
- p->frame.extended_data = p->frame.data;
-
- if (p->state == STATE_SETTING_UP) ff_thread_finish_setup(avctx);
-
- pthread_mutex_lock(&p->progress_mutex);
- for (i = 0; i < MAX_BUFFERS; i++)
- if (p->progress_used[i] && (p->got_frame || p->result<0 || avctx->codec_id != AV_CODEC_ID_H264)) {
- p->progress[i][0] = INT_MAX;
- p->progress[i][1] = INT_MAX;
- }
- p->state = STATE_INPUT_READY;
-
- pthread_cond_broadcast(&p->progress_cond);
- pthread_cond_signal(&p->output_cond);
- pthread_mutex_unlock(&p->progress_mutex);
- }
- pthread_mutex_unlock(&p->mutex);
-
- return NULL;
-}
-
-/**
- * Update the next thread's AVCodecContext with values from the reference thread's context.
- *
- * @param dst The destination context.
- * @param src The source context.
- * @param for_user 0 if the destination is a codec thread, 1 if the destination is the user's thread
- */
-static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src, int for_user)
-{
- int err = 0;
-
- if (dst != src) {
- dst->time_base = src->time_base;
- dst->width = src->width;
- dst->height = src->height;
- dst->pix_fmt = src->pix_fmt;
-
- dst->coded_width = src->coded_width;
- dst->coded_height = src->coded_height;
-
- dst->has_b_frames = src->has_b_frames;
- dst->idct_algo = src->idct_algo;
-
- dst->bits_per_coded_sample = src->bits_per_coded_sample;
- dst->sample_aspect_ratio = src->sample_aspect_ratio;
- dst->dtg_active_format = src->dtg_active_format;
-
- dst->profile = src->profile;
- dst->level = src->level;
-
- dst->bits_per_raw_sample = src->bits_per_raw_sample;
- dst->ticks_per_frame = src->ticks_per_frame;
- dst->color_primaries = src->color_primaries;
-
- dst->color_trc = src->color_trc;
- dst->colorspace = src->colorspace;
- dst->color_range = src->color_range;
- dst->chroma_sample_location = src->chroma_sample_location;
- }
-
- if (for_user) {
- dst->delay = src->thread_count - 1;
- dst->coded_frame = src->coded_frame;
- } else {
- if (dst->codec->update_thread_context)
- err = dst->codec->update_thread_context(dst, src);
- }
-
- return err;
-}
-
-/**
- * Update the next thread's AVCodecContext with values set by the user.
- *
- * @param dst The destination context.
- * @param src The source context.
- * @return 0 on success, negative error code on failure
- */
-static int update_context_from_user(AVCodecContext *dst, AVCodecContext *src)
-{
-#define copy_fields(s, e) memcpy(&dst->s, &src->s, (char*)&dst->e - (char*)&dst->s);
- dst->flags = src->flags;
-
- dst->draw_horiz_band= src->draw_horiz_band;
- dst->get_buffer = src->get_buffer;
- dst->release_buffer = src->release_buffer;
-
- dst->opaque = src->opaque;
- dst->debug = src->debug;
- dst->debug_mv = src->debug_mv;
-
- dst->slice_flags = src->slice_flags;
- dst->flags2 = src->flags2;
-
- copy_fields(skip_loop_filter, subtitle_header);
-
- dst->frame_number = src->frame_number;
- dst->reordered_opaque = src->reordered_opaque;
- // ==> Start patch MPC
- dst->reordered_opaque2 = src->reordered_opaque2;
- // ==> End patch MPC
- dst->thread_safe_callbacks = src->thread_safe_callbacks;
-
- if (src->slice_count && src->slice_offset) {
- if (dst->slice_count < src->slice_count) {
- int *tmp = av_realloc(dst->slice_offset, src->slice_count *
- sizeof(*dst->slice_offset));
- if (!tmp) {
- av_free(dst->slice_offset);
- return AVERROR(ENOMEM);
- }
- dst->slice_offset = tmp;
- }
- memcpy(dst->slice_offset, src->slice_offset,
- src->slice_count * sizeof(*dst->slice_offset));
- }
- dst->slice_count = src->slice_count;
- return 0;
-#undef copy_fields
-}
-
-static void free_progress(AVFrame *f)
-{
- PerThreadContext *p = f->owner->thread_opaque;
- volatile int *progress = f->thread_opaque;
-
- p->progress_used[(progress - p->progress[0]) / 2] = 0;
-}
-
-/// Releases the buffers that this decoding thread was the last user of.
-static void release_delayed_buffers(PerThreadContext *p)
-{
- FrameThreadContext *fctx = p->parent;
-
- while (p->num_released_buffers > 0) {
- AVFrame *f;
-
- pthread_mutex_lock(&fctx->buffer_mutex);
- f = &p->released_buffers[--p->num_released_buffers];
- free_progress(f);
- f->thread_opaque = NULL;
-
- f->owner->release_buffer(f->owner, f);
- pthread_mutex_unlock(&fctx->buffer_mutex);
- }
-}
-
-static int submit_packet(PerThreadContext *p, AVPacket *avpkt)
-{
- FrameThreadContext *fctx = p->parent;
- PerThreadContext *prev_thread = fctx->prev_thread;
- const AVCodec *codec = p->avctx->codec;
- uint8_t *buf = p->avpkt.data;
-
- if (!avpkt->size && !(codec->capabilities & CODEC_CAP_DELAY)) return 0;
-
- pthread_mutex_lock(&p->mutex);
-
- release_delayed_buffers(p);
-
- if (prev_thread) {
- int err;
- if (prev_thread->state == STATE_SETTING_UP) {
- pthread_mutex_lock(&prev_thread->progress_mutex);
- while (prev_thread->state == STATE_SETTING_UP)
- pthread_cond_wait(&prev_thread->progress_cond, &prev_thread->progress_mutex);
- pthread_mutex_unlock(&prev_thread->progress_mutex);
- }
-
- err = update_context_from_thread(p->avctx, prev_thread->avctx, 0);
- if (err) {
- pthread_mutex_unlock(&p->mutex);
- return err;
- }
- }
-
- av_fast_malloc(&buf, &p->allocated_buf_size, avpkt->size + FF_INPUT_BUFFER_PADDING_SIZE);
- p->avpkt = *avpkt;
- p->avpkt.data = buf;
- memcpy(buf, avpkt->data, avpkt->size);
- memset(buf + avpkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
-
- p->state = STATE_SETTING_UP;
- pthread_cond_signal(&p->input_cond);
- pthread_mutex_unlock(&p->mutex);
-
- /*
- * If the client doesn't have a thread-safe get_buffer(),
- * then decoding threads call back to the main thread,
- * and it calls back to the client here.
- */
-
- if (!p->avctx->thread_safe_callbacks &&
- p->avctx->get_buffer != avcodec_default_get_buffer) {
- while (p->state != STATE_SETUP_FINISHED && p->state != STATE_INPUT_READY) {
- pthread_mutex_lock(&p->progress_mutex);
- while (p->state == STATE_SETTING_UP)
- pthread_cond_wait(&p->progress_cond, &p->progress_mutex);
-
- if (p->state == STATE_GET_BUFFER) {
- p->result = ff_get_buffer(p->avctx, p->requested_frame);
- p->state = STATE_SETTING_UP;
- pthread_cond_signal(&p->progress_cond);
- }
- pthread_mutex_unlock(&p->progress_mutex);
- }
- }
-
- fctx->prev_thread = p;
- fctx->next_decoding++;
-
- return 0;
-}
-
-int ff_thread_decode_frame(AVCodecContext *avctx,
- AVFrame *picture, int *got_picture_ptr,
- AVPacket *avpkt)
-{
- FrameThreadContext *fctx = avctx->thread_opaque;
- int finished = fctx->next_finished;
- PerThreadContext *p;
- int err;
-
- /*
- * Submit a packet to the next decoding thread.
- */
-
- p = &fctx->threads[fctx->next_decoding];
- err = update_context_from_user(p->avctx, avctx);
- if (err) return err;
- err = submit_packet(p, avpkt);
- if (err) return err;
-
- /*
- * If we're still receiving the initial packets, don't return a frame.
- */
-
- if (fctx->delaying) {
- if (fctx->next_decoding >= (avctx->thread_count-1)) fctx->delaying = 0;
-
- *got_picture_ptr=0;
- if (avpkt->size)
- return avpkt->size;
- }
-
- /*
- * Return the next available frame from the oldest thread.
- * If we're at the end of the stream, then we have to skip threads that
- * didn't output a frame, because we don't want to accidentally signal
- * EOF (avpkt->size == 0 && *got_picture_ptr == 0).
- */
-
- do {
- p = &fctx->threads[finished++];
-
- if (p->state != STATE_INPUT_READY) {
- pthread_mutex_lock(&p->progress_mutex);
- while (p->state != STATE_INPUT_READY)
- pthread_cond_wait(&p->output_cond, &p->progress_mutex);
- pthread_mutex_unlock(&p->progress_mutex);
- }
-
- *picture = p->frame;
- *got_picture_ptr = p->got_frame;
- picture->pkt_dts = p->avpkt.dts;
-
- /*
- * A later call with avkpt->size == 0 may loop over all threads,
- * including this one, searching for a frame to return before being
- * stopped by the "finished != fctx->next_finished" condition.
- * Make sure we don't mistakenly return the same frame again.
- */
- p->got_frame = 0;
-
- if (finished >= avctx->thread_count) finished = 0;
- } while (!avpkt->size && !*got_picture_ptr && finished != fctx->next_finished);
-
- update_context_from_thread(avctx, p->avctx, 1);
-
- if (fctx->next_decoding >= avctx->thread_count) fctx->next_decoding = 0;
-
- fctx->next_finished = finished;
-
- /* return the size of the consumed packet if no error occurred */
- return (p->result >= 0) ? avpkt->size : p->result;
-}
-
-void ff_thread_report_progress(AVFrame *f, int n, int field)
-{
- PerThreadContext *p;
- volatile int *progress = f->thread_opaque;
-
- if (!progress || progress[field] >= n) return;
-
- p = f->owner->thread_opaque;
-
- if (f->owner->debug&FF_DEBUG_THREADS)
- av_log(f->owner, AV_LOG_DEBUG, "%p finished %d field %d\n", progress, n, field);
-
- pthread_mutex_lock(&p->progress_mutex);
- progress[field] = n;
- pthread_cond_broadcast(&p->progress_cond);
- pthread_mutex_unlock(&p->progress_mutex);
-}
-
-void ff_thread_await_progress(AVFrame *f, int n, int field)
-{
- PerThreadContext *p;
- volatile int *progress = f->thread_opaque;
-
- if (!progress || progress[field] >= n) return;
-
- p = f->owner->thread_opaque;
-
- if (f->owner->debug&FF_DEBUG_THREADS)
- av_log(f->owner, AV_LOG_DEBUG, "thread awaiting %d field %d from %p\n", n, field, progress);
-
- pthread_mutex_lock(&p->progress_mutex);
- while (progress[field] < n)
- pthread_cond_wait(&p->progress_cond, &p->progress_mutex);
- pthread_mutex_unlock(&p->progress_mutex);
-}
-
-void ff_thread_finish_setup(AVCodecContext *avctx) {
- PerThreadContext *p = avctx->thread_opaque;
-
- if (!(avctx->active_thread_type&FF_THREAD_FRAME)) return;
-
- if(p->state == STATE_SETUP_FINISHED){
- av_log(avctx, AV_LOG_WARNING, "Multiple ff_thread_finish_setup() calls\n");
- }
-
- pthread_mutex_lock(&p->progress_mutex);
- p->state = STATE_SETUP_FINISHED;
- pthread_cond_broadcast(&p->progress_cond);
- pthread_mutex_unlock(&p->progress_mutex);
-}
-
-/// Waits for all threads to finish.
-static void park_frame_worker_threads(FrameThreadContext *fctx, int thread_count)
-{
- int i;
-
- for (i = 0; i < thread_count; i++) {
- PerThreadContext *p = &fctx->threads[i];
-
- if (p->state != STATE_INPUT_READY) {
- pthread_mutex_lock(&p->progress_mutex);
- while (p->state != STATE_INPUT_READY)
- pthread_cond_wait(&p->output_cond, &p->progress_mutex);
- pthread_mutex_unlock(&p->progress_mutex);
- }
- p->got_frame = 0;
- }
-}
-
-static void frame_thread_free(AVCodecContext *avctx, int thread_count)
-{
- FrameThreadContext *fctx = avctx->thread_opaque;
- const AVCodec *codec = avctx->codec;
- int i;
-
- park_frame_worker_threads(fctx, thread_count);
-
- if (fctx->prev_thread && fctx->prev_thread != fctx->threads)
- if (update_context_from_thread(fctx->threads->avctx, fctx->prev_thread->avctx, 0) < 0) {
- av_log(avctx, AV_LOG_ERROR, "Final thread update failed\n");
- fctx->prev_thread->avctx->internal->is_copy = fctx->threads->avctx->internal->is_copy;
- fctx->threads->avctx->internal->is_copy = 1;
- }
-
- fctx->die = 1;
-
- for (i = 0; i < thread_count; i++) {
- PerThreadContext *p = &fctx->threads[i];
-
- pthread_mutex_lock(&p->mutex);
- pthread_cond_signal(&p->input_cond);
- pthread_mutex_unlock(&p->mutex);
-
- if (p->thread_init)
- pthread_join(p->thread, NULL);
- p->thread_init=0;
-
- if (codec->close)
- codec->close(p->avctx);
-
- avctx->codec = NULL;
-
- release_delayed_buffers(p);
- }
-
- for (i = 0; i < thread_count; i++) {
- PerThreadContext *p = &fctx->threads[i];
-
- avcodec_default_free_buffers(p->avctx);
-
- pthread_mutex_destroy(&p->mutex);
- pthread_mutex_destroy(&p->progress_mutex);
- pthread_cond_destroy(&p->input_cond);
- pthread_cond_destroy(&p->progress_cond);
- pthread_cond_destroy(&p->output_cond);
- av_freep(&p->avpkt.data);
-
- if (i) {
- av_freep(&p->avctx->priv_data);
- av_freep(&p->avctx->internal);
- av_freep(&p->avctx->slice_offset);
- }
-
- av_freep(&p->avctx);
- }
-
- av_freep(&fctx->threads);
- pthread_mutex_destroy(&fctx->buffer_mutex);
- av_freep(&avctx->thread_opaque);
-}
-
-static int frame_thread_init(AVCodecContext *avctx)
-{
- int thread_count = avctx->thread_count;
- const AVCodec *codec = avctx->codec;
- AVCodecContext *src = avctx;
- FrameThreadContext *fctx;
- int i, err = 0;
-
- if (!thread_count) {
- int nb_cpus = ff_get_logical_cpus(avctx);
- if ((avctx->debug & (FF_DEBUG_VIS_QP | FF_DEBUG_VIS_MB_TYPE)) || avctx->debug_mv)
- nb_cpus = 1;
- // use number of cores + 1 as thread count if there is more than one
- if (nb_cpus > 1)
- thread_count = avctx->thread_count = FFMIN(nb_cpus + 1, MAX_AUTO_THREADS);
- else
- thread_count = avctx->thread_count = 1;
- }
-
- if (thread_count <= 1) {
- avctx->active_thread_type = 0;
- return 0;
- }
-
- avctx->thread_opaque = fctx = av_mallocz(sizeof(FrameThreadContext));
-
- fctx->threads = av_mallocz(sizeof(PerThreadContext) * thread_count);
- pthread_mutex_init(&fctx->buffer_mutex, NULL);
- fctx->delaying = 1;
-
- for (i = 0; i < thread_count; i++) {
- AVCodecContext *copy = av_malloc(sizeof(AVCodecContext));
- PerThreadContext *p = &fctx->threads[i];
-
- pthread_mutex_init(&p->mutex, NULL);
- pthread_mutex_init(&p->progress_mutex, NULL);
- pthread_cond_init(&p->input_cond, NULL);
- pthread_cond_init(&p->progress_cond, NULL);
- pthread_cond_init(&p->output_cond, NULL);
-
- p->parent = fctx;
- p->avctx = copy;
-
- if (!copy) {
- err = AVERROR(ENOMEM);
- goto error;
- }
-
- *copy = *src;
- copy->thread_opaque = p;
- copy->pkt = &p->avpkt;
-
- if (!i) {
- src = copy;
-
- if (codec->init)
- err = codec->init(copy);
-
- update_context_from_thread(avctx, copy, 1);
- } else {
- copy->priv_data = av_malloc(codec->priv_data_size);
- if (!copy->priv_data) {
- err = AVERROR(ENOMEM);
- goto error;
- }
- memcpy(copy->priv_data, src->priv_data, codec->priv_data_size);
- copy->internal = av_malloc(sizeof(AVCodecInternal));
- if (!copy->internal) {
- err = AVERROR(ENOMEM);
- goto error;
- }
- *copy->internal = *src->internal;
- copy->internal->is_copy = 1;
-
- if (codec->init_thread_copy)
- err = codec->init_thread_copy(copy);
- }
-
- if (err) goto error;
-
- err = AVERROR(pthread_create(&p->thread, NULL, frame_worker_thread, p));
- p->thread_init= !err;
- if(!p->thread_init)
- goto error;
- }
-
- return 0;
-
-error:
- frame_thread_free(avctx, i+1);
-
- return err;
-}
-
-void ff_thread_flush(AVCodecContext *avctx)
-{
- int i;
- FrameThreadContext *fctx = avctx->thread_opaque;
-
- if (!avctx->thread_opaque) return;
-
- park_frame_worker_threads(fctx, avctx->thread_count);
- 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;
- fctx->delaying = 1;
- fctx->prev_thread = NULL;
- for (i = 0; i < avctx->thread_count; i++) {
- PerThreadContext *p = &fctx->threads[i];
- // Make sure decode flush calls with size=0 won't return old frames
- p->got_frame = 0;
-
- release_delayed_buffers(p);
- }
-}
-
-static volatile int *allocate_progress(PerThreadContext *p)
-{
- int i;
-
- for (i = 0; i < MAX_BUFFERS; i++)
- if (!p->progress_used[i]) break;
-
- if (i == MAX_BUFFERS) {
- av_log(p->avctx, AV_LOG_ERROR, "allocate_progress() overflow\n");
- return NULL;
- }
-
- p->progress_used[i] = 1;
-
- return p->progress[i];
-}
-
-int ff_thread_can_start_frame(AVCodecContext *avctx)
-{
- PerThreadContext *p = avctx->thread_opaque;
- if ((avctx->active_thread_type&FF_THREAD_FRAME) && p->state != STATE_SETTING_UP &&
- (avctx->codec->update_thread_context || (!avctx->thread_safe_callbacks &&
- avctx->get_buffer != avcodec_default_get_buffer))) {
- return 0;
- }
- return 1;
-}
-
-int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f)
-{
- PerThreadContext *p = avctx->thread_opaque;
- int err;
- volatile int *progress;
-
- f->owner = avctx;
-
- ff_init_buffer_info(avctx, f);
-
- if (!(avctx->active_thread_type&FF_THREAD_FRAME)) {
- f->thread_opaque = NULL;
- return ff_get_buffer(avctx, f);
- }
-
- if (p->state != STATE_SETTING_UP &&
- (avctx->codec->update_thread_context || (!avctx->thread_safe_callbacks &&
- avctx->get_buffer != avcodec_default_get_buffer))) {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() cannot be called after ff_thread_finish_setup()\n");
- return -1;
- }
-
- pthread_mutex_lock(&p->parent->buffer_mutex);
- f->thread_opaque = (int*)(progress = allocate_progress(p));
-
- if (!progress) {
- pthread_mutex_unlock(&p->parent->buffer_mutex);
- return -1;
- }
-
- progress[0] =
- progress[1] = -1;
-
- if (avctx->thread_safe_callbacks ||
- avctx->get_buffer == avcodec_default_get_buffer) {
- err = ff_get_buffer(avctx, f);
- } else {
- pthread_mutex_lock(&p->progress_mutex);
- p->requested_frame = f;
- p->state = STATE_GET_BUFFER;
- pthread_cond_broadcast(&p->progress_cond);
-
- while (p->state != STATE_SETTING_UP)
- pthread_cond_wait(&p->progress_cond, &p->progress_mutex);
-
- err = p->result;
-
- pthread_mutex_unlock(&p->progress_mutex);
-
- if (!avctx->codec->update_thread_context)
- ff_thread_finish_setup(avctx);
- }
-
- if (err) {
- free_progress(f);
- f->thread_opaque = NULL;
- }
- pthread_mutex_unlock(&p->parent->buffer_mutex);
-
- return err;
-}
-
-void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f)
-{
- PerThreadContext *p = avctx->thread_opaque;
- FrameThreadContext *fctx;
-
- if (!f->data[0])
- return;
-
- if (!(avctx->active_thread_type&FF_THREAD_FRAME)) {
- avctx->release_buffer(avctx, f);
- return;
- }
-
- if (p->num_released_buffers >= MAX_BUFFERS) {
- av_log(p->avctx, AV_LOG_ERROR, "too many thread_release_buffer calls!\n");
- return;
- }
-
- if(avctx->debug & FF_DEBUG_BUFFERS)
- av_log(avctx, AV_LOG_DEBUG, "thread_release_buffer called on pic %p\n", f);
-
- fctx = p->parent;
- pthread_mutex_lock(&fctx->buffer_mutex);
- p->released_buffers[p->num_released_buffers++] = *f;
- pthread_mutex_unlock(&fctx->buffer_mutex);
- memset(f->data, 0, sizeof(f->data));
-}
-
-/**
- * Set the threading algorithms used.
- *
- * Threading requires more than one thread.
- * Frame threading requires entire frames to be passed to the codec,
- * and introduces extra decoding delay, so is incompatible with low_delay.
- *
- * @param avctx The context.
- */
-static void validate_thread_parameters(AVCodecContext *avctx)
-{
- int frame_threading_supported = (avctx->codec->capabilities & CODEC_CAP_FRAME_THREADS)
- && !(avctx->flags & CODEC_FLAG_TRUNCATED)
- && !(avctx->flags & CODEC_FLAG_LOW_DELAY)
- && !(avctx->flags2 & CODEC_FLAG2_CHUNKS);
- if (avctx->thread_count == 1) {
- avctx->active_thread_type = 0;
- } else if (frame_threading_supported && (avctx->thread_type & FF_THREAD_FRAME)) {
- avctx->active_thread_type = FF_THREAD_FRAME;
- } else if (avctx->codec->capabilities & CODEC_CAP_SLICE_THREADS &&
- avctx->thread_type & FF_THREAD_SLICE) {
- avctx->active_thread_type = FF_THREAD_SLICE;
- } else if (!(avctx->codec->capabilities & CODEC_CAP_AUTO_THREADS)) {
- avctx->thread_count = 1;
- avctx->active_thread_type = 0;
- }
-
- if (avctx->thread_count > MAX_AUTO_THREADS)
- av_log(avctx, AV_LOG_WARNING,
- "Application has requested %d threads. Using a thread count greater than %d is not recommended.\n",
- avctx->thread_count, MAX_AUTO_THREADS);
-}
-
-int ff_thread_init(AVCodecContext *avctx)
-{
- if (avctx->thread_opaque) {
- av_log(avctx, AV_LOG_ERROR, "avcodec_thread_init is ignored after avcodec_open\n");
- return -1;
- }
-
-#if HAVE_W32THREADS
- w32thread_init();
-#endif
-
- if (avctx->codec) {
- validate_thread_parameters(avctx);
-
- if (avctx->active_thread_type&FF_THREAD_SLICE)
- return thread_init(avctx);
- else if (avctx->active_thread_type&FF_THREAD_FRAME)
- return frame_thread_init(avctx);
- }
-
- return 0;
-}
-
-void ff_thread_free(AVCodecContext *avctx)
-{
- if (avctx->active_thread_type&FF_THREAD_FRAME)
- frame_thread_free(avctx, avctx->thread_count);
- else
- thread_free(avctx);
-}
-
-// ffdshow custom code
-AVCodecContext* get_thread0_avctx(AVCodecContext *avctx)
-{
- FrameThreadContext *fctx;
- PerThreadContext *p;
-
- if (avctx->active_thread_type&FF_THREAD_FRAME && avctx->thread_opaque){
- fctx = avctx->thread_opaque;
- p = &fctx->threads[0];
- return p->avctx;
- } else {
- return avctx;
- }
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/put_bits.h b/src/thirdparty/ffmpeg/libavcodec/put_bits.h
deleted file mode 100644
index 5de7dc3d1..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/put_bits.h
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * copyright (c) 2004 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
- * bitstream writer API
- */
-
-#ifndef AVCODEC_PUT_BITS_H
-#define AVCODEC_PUT_BITS_H
-
-#include <stdint.h>
-#include <stdlib.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;
- int bit_left;
- uint8_t *buf, *buf_ptr, *buf_end;
- int size_in_bits;
-} PutBitContext;
-
-/**
- * Initialize the PutBitContext s.
- *
- * @param buffer the buffer where to put bits
- * @param buffer_size the size in bytes of buffer
- */
-static inline void init_put_bits(PutBitContext *s, uint8_t *buffer,
- int buffer_size)
-{
- if (buffer_size < 0) {
- buffer_size = 0;
- buffer = NULL;
- }
-
- s->size_in_bits = 8 * buffer_size;
- s->buf = buffer;
- s->buf_end = s->buf + buffer_size;
- s->buf_ptr = s->buf;
- s->bit_left = 32;
- s->bit_buf = 0;
-}
-
-/**
- * @return the total number of bits written to the bitstream.
- */
-static inline int put_bits_count(PutBitContext *s)
-{
- return (s->buf_ptr - s->buf) * 8 + 32 - s->bit_left;
-}
-
-/**
- * Pad the end of the output stream with zeros.
- */
-static inline void flush_put_bits(PutBitContext *s)
-{
-#ifndef BITSTREAM_WRITER_LE
- if (s->bit_left < 32)
- s->bit_buf <<= s->bit_left;
-#endif
- while (s->bit_left < 32) {
- /* XXX: should test end of buffer */
-#ifdef BITSTREAM_WRITER_LE
- *s->buf_ptr++ = s->bit_buf;
- s->bit_buf >>= 8;
-#else
- *s->buf_ptr++ = s->bit_buf >> 24;
- s->bit_buf <<= 8;
-#endif
- s->bit_left += 8;
- }
- s->bit_left = 32;
- s->bit_buf = 0;
-}
-
-#ifdef BITSTREAM_WRITER_LE
-#define avpriv_align_put_bits align_put_bits_unsupported_here
-#define avpriv_put_string ff_put_string_unsupported_here
-#define avpriv_copy_bits avpriv_copy_bits_unsupported_here
-#else
-/**
- * Pad the bitstream with zeros up to the next byte boundary.
- */
-void avpriv_align_put_bits(PutBitContext *s);
-
-/**
- * Put the string string in the bitstream.
- *
- * @param terminate_string 0-terminates the written string if value is 1
- */
-void avpriv_put_string(PutBitContext *pb, const char *string,
- int terminate_string);
-
-/**
- * Copy the content of src to the bitstream.
- *
- * @param length the number of bits of src to copy
- */
-void avpriv_copy_bits(PutBitContext *pb, const uint8_t *src, int length);
-#endif
-
-/**
- * Write up to 31 bits into a bitstream.
- * Use put_bits32 to write 32 bits.
- */
-static inline void put_bits(PutBitContext *s, int n, unsigned int value)
-{
- unsigned int bit_buf;
- int bit_left;
-
- av_assert2(n <= 31 && value < (1U << n));
-
- bit_buf = s->bit_buf;
- bit_left = s->bit_left;
-
- /* XXX: optimize */
-#ifdef BITSTREAM_WRITER_LE
- bit_buf |= value << (32 - bit_left);
- if (n >= bit_left) {
- av_assert2(s->buf_ptr+3<s->buf_end);
- AV_WL32(s->buf_ptr, bit_buf);
- s->buf_ptr += 4;
- bit_buf = (bit_left == 32) ? 0 : value >> bit_left;
- bit_left += 32;
- }
- bit_left -= n;
-#else
- if (n < bit_left) {
- bit_buf = (bit_buf << n) | value;
- bit_left -= n;
- } else {
- bit_buf <<= bit_left;
- bit_buf |= value >> (n - bit_left);
- av_assert2(s->buf_ptr+3<s->buf_end);
- AV_WB32(s->buf_ptr, bit_buf);
- s->buf_ptr += 4;
- bit_left += 32 - n;
- bit_buf = value;
- }
-#endif
-
- s->bit_buf = bit_buf;
- s->bit_left = bit_left;
-}
-
-static inline void put_sbits(PutBitContext *pb, int n, int32_t value)
-{
- av_assert2(n >= 0 && n <= 31);
-
- put_bits(pb, n, value & ((1 << n) - 1));
-}
-
-/**
- * Write exactly 32 bits into a bitstream.
- */
-static void av_unused put_bits32(PutBitContext *s, uint32_t value)
-{
- int lo = value & 0xffff;
- int hi = value >> 16;
-#ifdef BITSTREAM_WRITER_LE
- put_bits(s, 16, lo);
- put_bits(s, 16, hi);
-#else
- put_bits(s, 16, hi);
- put_bits(s, 16, lo);
-#endif
-}
-
-/**
- * Return the pointer to the byte where the bitstream writer will put
- * the next bit.
- */
-static inline uint8_t *put_bits_ptr(PutBitContext *s)
-{
- return s->buf_ptr;
-}
-
-/**
- * Skip the given number of bytes.
- * PutBitContext must be flushed & aligned to a byte boundary before calling this.
- */
-static inline void skip_put_bytes(PutBitContext *s, int n)
-{
- av_assert2((put_bits_count(s) & 7) == 0);
- av_assert2(s->bit_left == 32);
- s->buf_ptr += n;
-}
-
-/**
- * Skip the given number of bits.
- * Must only be used if the actual values in the bitstream do not matter.
- * If n is 0 the behavior is undefined.
- */
-static inline void skip_put_bits(PutBitContext *s, int n)
-{
- s->bit_left -= n;
- s->buf_ptr -= 4 * (s->bit_left >> 5);
- s->bit_left &= 31;
-}
-
-/**
- * Change the end of the buffer.
- *
- * @param size the new size in bytes of the buffer where to put bits
- */
-static inline void set_put_bits_buffer_size(PutBitContext *s, int size)
-{
- s->buf_end = s->buf + size;
-}
-
-#endif /* AVCODEC_PUT_BITS_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/ra144.c b/src/thirdparty/ffmpeg/libavcodec/ra144.c
deleted file mode 100644
index aa1f0c91a..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/ra144.c
+++ /dev/null
@@ -1,1728 +0,0 @@
-/*
- * Real Audio 1.0 (14.4K)
- * Copyright (c) 2003 the ffmpeg project
- *
- * 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 "avcodec.h"
-#include "celp_filters.h"
-#include "mathops.h"
-#include "ra144.h"
-
-const int16_t ff_gain_val_tab[256][3] = {
- { 541, 956, 768}, { 877, 581, 568}, { 675,1574, 635}, {1248,1464, 668},
- {1246, 839, 1394}, {2560,1386, 991}, { 925, 687, 608}, {2208, 797, 1144},
- { 535, 832, 799}, { 762, 605, 1154}, { 832,1122, 1003}, {1180, 687, 1176},
- {1292, 901, 732}, {1656, 689, 896}, {1750,1248, 848}, {2284, 942, 1022},
- { 824,1472, 643}, { 517, 765, 512}, { 562,1816, 1522}, { 694,1826, 2700},
- { 704, 524, 672}, {1442, 757, 2232}, { 884, 551, 1266}, {2232,1007, 1692},
- { 932, 746, 777}, {1132, 822, 926}, {1226, 771, 611}, {2948,1342, 1008},
- {1302, 594, 1158}, {1602, 636, 1128}, {3408, 910, 1438}, {1996, 614, 575},
- { 665, 935, 628}, { 631,1192, 829}, { 644, 926, 1052}, { 879, 988, 1226},
- { 941,2768, 2772}, { 565,1344, 2304}, { 547, 628, 740}, { 639, 532, 1074},
- { 955,1208, 598}, {1124,1160, 900}, {1206, 899, 1242}, { 746, 533, 624},
- {1458,1028, 735}, {1706,1102, 692}, {1898,1018, 1004}, {2176, 988, 735},
- {1578, 782, 1642}, { 897, 516, 754}, {2068, 702, 1656}, {2344, 818, 1526},
- { 907, 652, 592}, {1056, 652, 642}, {2124,1416, 780}, {2664,1250, 727},
- {1894, 727, 1108}, {2196, 657, 981}, {4840, 920, 1704}, {4992,1238, 983},
- {2420, 909, 1094}, {2760, 935, 1032}, {2800, 612, 853}, {3068, 832, 574},
- { 523,1796, 923}, { 722,1916, 1382}, {1226,1542, 928}, { 758, 757, 584},
- { 512,1134, 577}, { 615,1276, 698}, { 574,2568, 2356}, { 993,2728, 3512},
- { 539, 890, 913}, { 694, 928, 1088}, { 805, 600, 1360}, {2160, 951, 3128},
- { 816, 950, 590}, { 955, 847, 811}, {1094, 883, 556}, {1304, 888, 604},
- { 863,1170, 855}, {1023, 997, 1032}, { 932,1228, 1280}, { 627, 564, 573},
- { 876, 900, 1448}, {1030, 857, 1792}, {1294, 953, 1758}, {1612, 854, 1714},
- {1090,1166, 631}, {1314,1202, 751}, {1480, 905, 795}, {1682,1016, 568},
- {1494,1178, 983}, { 878, 613, 526}, {1728,1446, 779}, {2136,1348, 774},
- { 950, 649, 939}, {1180, 703, 899}, {1236, 527, 1158}, {1450, 647, 972},
- {1282, 647, 707}, {1460, 663, 644}, {1614, 572, 578}, {3516,1222, 821},
- {2668, 729, 1682}, {3128, 585, 1502}, {3208, 733, 976}, {6800, 871, 1416},
- {3480, 743, 1408}, {3764, 899, 1170}, {3772, 632, 875}, {4092, 732, 638},
- {3112, 753, 2620}, {3372, 945, 1890}, {3768, 969, 2288}, {2016, 559, 854},
- {1736, 729, 787}, {1940, 686, 547}, {2140, 635, 674}, {4480,1272, 828},
- {3976, 592, 1666}, {4384, 621, 1388}, {4400, 801, 955}, {4656, 522, 646},
- {4848, 625, 1636}, {4984, 591, 874}, {5352, 535, 1001}, {11216,938, 1184},
- { 925,3280, 1476}, { 735,1580, 1088}, {1150,1576, 674}, { 655, 783, 528},
- { 527,2052, 1354}, { 782,1704, 1880}, { 578, 910, 1026}, { 692, 882, 1468},
- { 586, 683, 715}, { 739, 609, 717}, { 778, 773, 697}, { 922, 785, 813},
- { 766, 651, 984}, { 978, 596, 1030}, {1070, 757, 1080}, {1324, 687, 1178},
- {1108,2144, 979}, { 723, 982, 690}, { 936, 956, 527}, {1180,1002, 547},
- { 517,1306, 825}, { 832,1184, 974}, {1024, 957, 903}, {1262,1090, 906},
- {1028, 720, 649}, {1192, 679, 694}, {2468,1480, 979}, {2844,1370, 877},
- {1310, 835, 848}, {1508, 839, 698}, {1742,1030, 769}, {1910, 852, 573},
- {1280, 859, 1174}, {1584, 863, 1108}, {1686, 708, 1364}, {1942, 768, 1104},
- { 891, 536, 690}, {1016, 560, 663}, {2172, 870, 1348}, {2404, 999, 1170},
- {1890, 966, 889}, {2116, 912, 777}, {2296,1020, 714}, {4872,1844, 932},
- {2392, 778, 929}, {2604, 772, 744}, {2764, 957, 722}, {5832,1532, 984},
- {2188, 519, 1264}, {2332, 532, 922}, {5064, 995, 2412}, {2708, 571, 874},
- {2408, 545, 666}, {5016,1084, 875}, {5376, 983, 1196}, {5536, 979, 730},
- {5344, 634, 1744}, {5688, 706, 1348}, {5912, 977, 1190}, {6072, 905, 763},
- {6048, 582, 1526}, {11968,1013,1816}, {12864,937, 1900}, {12560,1086, 998},
- {1998, 684, 1884}, {2504, 633, 1992}, {1252, 567, 835}, {1478, 571, 973},
- {2620, 769, 1414}, {2808, 952, 1142}, {2908, 712, 1028}, {2976, 686, 741},
- {1462, 552, 714}, {3296, 991, 1452}, {1590, 615, 544}, {3480,1150, 824},
- {3212, 832, 923}, {3276, 839, 531}, {3548, 786, 852}, {3732, 764, 570},
- {5728, 906, 2616}, {6272, 804, 2252}, {3096, 535, 876}, {3228, 598, 649},
- {6536, 759, 1436}, {6648, 993, 846}, {6864, 567, 1210},{14016,1012, 1302},
- {3408, 548, 1098}, {7160,1008, 1742}, {7136,1000, 1182}, {7480,1032, 836},
- {7448, 612, 1552}, {7744, 614, 816}, {8384, 777, 1438}, {8784, 694, 786},
- { 882,1508, 1068}, { 597, 837, 766}, {1270, 954, 1408}, { 803, 550, 798},
- {1398,1308, 798}, {1848,1534, 738}, { 970, 675, 608}, {1264, 706, 684},
- {1716, 767, 1126}, {2108, 765, 1404}, {2236, 924, 1003}, {2472,1048, 611},
- { 999, 942, 963}, {1094, 857, 935}, {2936, 926, 1138}, {1934, 746, 551},
- {3336, 633, 1762}, {3764, 701, 1454}, {1890, 564, 636}, {4096,1126, 793},
- {3936, 556, 1140}, {3936, 540, 740}, {4216, 764, 874}, {8480,1328, 1014},
- {2184, 515, 1042}, {4432, 934, 1344}, {4784, 945, 1112}, {5016,1062, 733},
- {9216,1020, 2028}, {9968, 924, 1188}, {5424, 909, 1206}, {6512, 744, 1086}
-};
-
-const uint8_t ff_gain_exp_tab[256] = {
- 15, 15, 15, 15, 15, 16, 14, 15, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 13, 14, 14, 13, 14, 13, 14, 13, 13, 13, 14, 13, 13, 14, 13,
- 13, 13, 13, 13, 14, 13, 12, 12, 13, 13, 13, 12, 13, 13, 13, 13,
- 13, 12, 13, 13, 12, 12, 13, 13, 13, 13, 14, 14, 13, 13, 13, 13,
- 13, 13, 13, 12, 12, 12, 13, 13, 12, 12, 12, 13, 12, 12, 12, 12,
- 12, 12, 12, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 11, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 14, 13, 13, 13, 13,
- 13, 13, 13, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 14,
- 13, 12, 12, 11, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 11, 11, 11, 11,
- 12, 12, 12, 12, 11, 11, 12, 12, 12, 12, 12, 13, 12, 12, 12, 13,
- 12, 12, 13, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14,
- 12, 12, 11, 11, 12, 12, 12, 12, 11, 12, 11, 12, 12, 12, 12, 12,
- 13, 13, 12, 12, 13, 13, 13, 14, 12, 13, 13, 13, 13, 13, 13, 13,
- 11, 10, 11, 10, 11, 11, 10, 10, 11, 11, 11, 11, 10, 9, 11, 10,
- 12, 12, 11, 12, 12, 12, 12, 13, 11, 12, 12, 12, 13, 13, 12, 12
-};
-
-const int8_t ff_cb1_vects[128][40]={
- {
- 38, -4, 15, -4, 14, -13, 12, -11, -2, -6,
- -6, -11, -45, -16, -11, -13, -7, 6, -12, 4,
- -20, 3, -16, 12, -1, 12, 46, 24, 0, 33,
- -3, 9, -12, -12, -8, -7, 17, -6, 0, -2,
- }, {
- 60, -16, 3, -22, 10, -32, 0, -28, -17, -18,
- -3, -25, -37, -23, -10, 3, 2, 3, 0, 3,
- -14, 0, -14, -1, 0, 2, 32, 9, -1, 25,
- 7, 13, -5, 13, 8, 1, 2, 8, -10, 6,
- }, {
- 27, -12, 28, -2, 6, -7, 15, 9, -11, 1,
- -13, -11, -40, 4, -29, -14, -19, -5, -23, -8,
- -30, -13, -17, 0, -14, 12, 34, 20, -2, 25,
- 2, -16, -4, -12, 15, 16, 29, 7, 24, 10,
- }, {
- 49, -24, 16, -20, 2, -26, 2, -7, -25, -10,
- -11, -25, -32, -3, -27, 2, -8, -8, -11, -9,
- -24, -17, -16, -14, -13, 2, 20, 5, -4, 17,
- 14, -12, 3, 13, 33, 25, 14, 23, 15, 19,
- }, {
- 46, -6, 21, 8, -2, -16, -5, -8, -11, 4,
- 8, 15, -24, 4, -2, -26, -3, -16, -16, -14,
- -9, -2, -1, 4, 19, 7, 36, 17, 9, 13,
- 0, 31, -5, -12, 7, -8, 11, -15, -13, -4,
- }, {
- 68, -18, 9, -9, -6, -35, -18, -25, -26, -7,
- 10, 1, -16, -3, -1, -9, 6, -19, -4, -15,
- -4, -6, 0, -8, 20, -2, 23, 2, 7, 5,
- 12, 35, 1, 13, 24, 0, -3, 0, -22, 4,
- }, {
- 35, -14, 34, 10, -10, -10, -1, 12, -20, 12,
- 0, 15, -18, 24, -20, -27, -14, -28, -27, -27,
- -20, -19, -2, -8, 5, 7, 25, 13, 5, 5,
- 6, 5, 2, -12, 31, 15, 23, -1, 12, 8,
- }, {
- 57, -26, 22, -7, -14, -28, -14, -3, -35, 0,
- 3, 1, -11, 16, -18, -10, -4, -31, -15, -28,
- -14, -23, -1, -21, 7, -2, 11, -1, 3, -1,
- 18, 9, 10, 13, 49, 24, 8, 14, 2, 16,
- }, {
- 25, 15, 22, 11, 18, 4, 15, -22, 8, -2,
- -17, -9, -48, -20, -30, -17, -16, 11, -1, 16,
- 2, 10, -5, 26, -2, -4, 22, 0, 2, 10,
- -6, 13, -14, 10, -23, 0, 10, -2, 1, 0,
- }, {
- 47, 3, 11, -6, 15, -13, 2, -38, -6, -13,
- -15, -22, -40, -28, -28, 0, -5, 8, 10, 15,
- 7, 7, -4, 13, -1, -14, 9, -14, 0, 2,
- 4, 18, -7, 36, -6, 8, -3, 13, -7, 8,
- }, {
- 14, 7, 36, 13, 10, 10, 18, 0, 0, 5,
- -25, -8, -43, 0, -48, -18, -27, 0, -12, 3,
- -7, -6, -7, 13, -15, -5, 11, -3, 0, 2,
- 0, -12, -6, 10, 0, 23, 22, 11, 26, 12,
- }, {
- 36, -5, 24, -4, 7, -7, 6, -17, -14, -5,
- -22, -22, -35, -8, -46, -1, -17, -3, 0, 2,
- -2, -10, -5, 0, -14, -15, -2, -18, -2, -4,
- 11, -7, 1, 36, 18, 32, 7, 27, 17, 20,
- }, {
- 33, 13, 29, 24, 1, 1, -2, -18, 0, 9,
- -3, 17, -27, 0, -21, -30, -12, -11, -5, -2,
- 12, 4, 9, 19, 18, -9, 13, -6, 11, -8,
- -2, 35, -8, 10, -7, -1, 4, -11, -10, -2,
- }, {
- 55, 1, 17, 6, -1, -16, -15, -35, -15, -2,
- 0, 4, -19, -8, -20, -13, -1, -14, 7, -3,
- 18, 0, 10, 5, 19, -19, 0, -21, 8, -16,
- 9, 39, 0, 36, 10, 7, -9, 4, -20, 5,
- }, {
- 22, 5, 42, 26, -6, 8, 1, 2, -9, 17,
- -10, 18, -21, 19, -39, -31, -23, -23, -16, -15,
- 2, -12, 7, 6, 5, -9, 1, -10, 7, -16,
- 4, 9, 0, 10, 17, 22, 16, 2, 14, 9,
- }, {
- 44, -6, 30, 8, -9, -10, -11, -14, -23, 5,
- -8, 4, -14, 12, -37, -14, -12, -26, -4, -16,
- 8, -16, 9, -7, 6, -19, -12, -25, 5, -24,
- 15, 13, 8, 36, 34, 31, 1, 18, 4, 18,
- }, {
- -3, -5, -9, -7, 15, -1, 5, 13, 2, 12,
- 5, 2, -21, -23, -2, -16, 0, 5, -6, 13,
- -23, 3, -32, 10, -15, 8, 44, 28, 9, 37,
- -2, 13, -9, -15, -12, -27, -7, -12, 0, -11,
- }, {
- 18, -17, -21, -25, 11, -19, -6, -3, -11, 0,
- 7, -11, -13, -31, -1, 0, 9, 1, 5, 12,
- -18, 0, -31, -2, -13, -1, 30, 14, 7, 29,
- 9, 18, -1, 10, 4, -18, -22, 3, -10, -2,
- }, {
- -13, -13, 3, -5, 7, 4, 9, 34, -5, 20,
- -2, 3, -16, -3, -20, -17, -11, -7, -17, 0,
- -34, -13, -33, -2, -28, 8, 32, 24, 5, 29,
- 3, -12, 0, -15, 11, -3, 3, 2, 24, 1,
- }, {
- 8, -25, -8, -23, 3, -13, -3, 17, -20, 8,
- 0, -10, -8, -11, -18, 0, -1, -10, -5, 0,
- -28, -17, -32, -15, -26, -1, 19, 9, 3, 21,
- 15, -7, 6, 9, 29, 5, -10, 17, 15, 9,
- }, {
- 4, -6, -3, 5, -1, -4, -11, 16, -6, 23,
- 19, 29, 0, -3, 6, -30, 3, -17, -10, -5,
- -13, -2, -17, 3, 5, 3, 35, 21, 17, 17,
- 2, 35, -2, -15, 3, -28, -13, -21, -13, -13,
- }, {
- 26, -19, -15, -12, -5, -22, -24, 0, -21, 12,
- 21, 15, 8, -11, 7, -12, 14, -20, 2, -6,
- -7, -6, -16, -9, 6, -5, 21, 7, 15, 10,
- 13, 39, 5, 10, 20, -19, -28, -5, -22, -5,
- }, {
- -5, -15, 9, 7, -9, 2, -8, 37, -14, 31,
- 11, 29, 5, 16, -11, -30, -7, -29, -21, -18,
- -23, -19, -18, -9, -7, 3, 23, 17, 14, 9,
- 8, 9, 6, -15, 27, -4, -2, -6, 12, -1,
- }, {
- 16, -27, -2, -10, -13, -16, -20, 20, -29, 20,
- 14, 16, 13, 8, -9, -13, 2, -33, -9, -19,
- -17, -23, -17, -22, -6, -6, 9, 2, 12, 2,
- 20, 13, 13, 10, 45, 4, -16, 8, 2, 7,
- }, {
- -16, 14, -2, 8, 20, 17, 9, 2, 14, 16,
- -6, 5, -24, -28, -21, -20, -8, 9, 4, 25,
- -1, 11, -22, 24, -15, -8, 21, 5, 11, 14,
- -5, 18, -11, 7, -27, -20, -14, -7, 1, -9,
- }, {
- 6, 2, -14, -9, 16, -1, -3, -14, 0, 5,
- -3, -8, -16, -36, -19, -3, 1, 6, 17, 24,
- 4, 7, -21, 11, -14, -18, 7, -9, 9, 7,
- 6, 22, -3, 33, -10, -11, -28, 7, -7, 0,
- }, {
- -26, 6, 11, 10, 12, 23, 12, 23, 5, 24,
- -13, 5, -19, -8, -38, -21, -20, -2, -6, 12,
- -11, -5, -23, 11, -29, -9, 9, 0, 7, 6,
- 1, -7, -2, 7, -3, 3, -2, 6, 27, 3,
- }, {
- -4, -6, 0, -7, 8, 4, 0, 6, -9, 13,
- -11, -7, -11, -15, -37, -4, -9, -5, 5, 11,
- -5, -9, -22, -1, -27, -18, -4, -14, 5, 0,
- 12, -3, 4, 32, 14, 12, -17, 22, 17, 11,
- }, {
- -8, 12, 3, 21, 3, 14, -8, 5, 4, 28,
- 7, 32, -2, -8, -12, -34, -4, -12, 1, 6,
- 9, 4, -7, 17, 4, -13, 11, -1, 19, -4,
- 0, 39, -4, 7, -11, -21, -20, -16, -10, -11,
- }, {
- 13, 0, -8, 3, 0, -4, -21, -11, -9, 16,
- 10, 18, 5, -16, -10, -16, 5, -15, 13, 5,
- 15, 1, -6, 4, 6, -23, -2, -16, 17, -12,
- 10, 44, 3, 33, 6, -12, -34, -1, -20, -3,
- }, {
- -18, 4, 17, 23, -4, 20, -4, 26, -3, 36,
- 0, 32, 2, 12, -29, -34, -16, -24, -10, -6,
- 0, -12, -8, 4, -8, -13, 0, -6, 16, -12,
- 5, 13, 3, 7, 13, 3, -8, -2, 14, 0,
- }, {
- 3, -7, 5, 5, -8, 2, -17, 9, -18, 24,
- 2, 19, 10, 4, -28, -17, -5, -28, 2, -7,
- 4, -15, -7, -8, -6, -23, -13, -21, 14, -20,
- 17, 18, 11, 33, 30, 11, -23, 13, 5, 9,
- }, {
- 60, 10, 7, -1, 9, -8, 6, -13, 2, -15,
- -1, -10, -13, -11, 15, 0, 6, 9, -1, 0,
- -13, 1, -11, -3, -13, 21, 13, 26, -7, 31,
- -10, -7, -16, -33, -31, -10, 22, -8, 1, -2,
- }, {
- 82, -1, -4, -19, 6, -27, -6, -29, -12, -26,
- 1, -24, -5, -18, 17, 17, 17, 6, 10, 0,
- -7, -2, -9, -16, -12, 11, 0, 11, -9, 23,
- 0, -3, -8, -8, -13, -1, 8, 7, -7, 6,
- }, {
- 49, 2, 21, 0, 1, -2, 9, 8, -6, -6,
- -8, -10, -8, 9, -2, 0, -4, -2, -13, -12,
- -23, -15, -12, -16, -26, 21, 2, 21, -11, 23,
- -4, -33, -7, -33, -6, 13, 34, 5, 27, 10,
- }, {
- 71, -10, 9, -17, -1, -20, -3, -8, -21, -18,
- -6, -24, 0, 1, 0, 16, 6, -5, 0, -13,
- -17, -19, -11, -29, -25, 11, -11, 6, -13, 15,
- 7, -29, 0, -8, 11, 22, 20, 21, 17, 18,
- }, {
- 67, 8, 14, 11, -7, -11, -11, -9, -7, -3,
- 13, 16, 8, 9, 24, -12, 10, -13, -5, -17,
- -2, -4, 3, -10, 6, 17, 4, 19, 0, 11,
- -6, 13, -9, -33, -14, -10, 16, -17, -10, -4,
- }, {
- 90, -3, 2, -6, -10, -29, -24, -26, -21, -15,
- 15, 2, 16, 1, 25, 4, 21, -16, 6, -18,
- 3, -8, 5, -24, 8, 7, -9, 4, -1, 3,
- 5, 18, -1, -7, 2, -1, 2, -1, -19, 3,
- }, {
- 57, 0, 27, 13, -14, -5, -7, 11, -15, 4,
- 5, 16, 13, 29, 6, -13, 0, -25, -16, -31,
- -12, -22, 2, -23, -6, 16, -7, 14, -2, 3,
- 0, -12, 0, -33, 9, 13, 28, -3, 14, 7,
- }, {
- 79, -11, 15, -4, -18, -23, -20, -5, -30, -7,
- 7, 2, 21, 21, 8, 3, 10, -28, -4, -31,
- -6, -25, 3, -37, -4, 7, -20, 0, -4, -4,
- 11, -7, 6, -8, 27, 22, 14, 12, 5, 16,
- }, {
- 47, 30, 15, 14, 14, 9, 9, -23, 13, -10,
- -12, -7, -16, -15, -3, -3, -1, 14, 9, 12,
- 9, 8, 0, 10, -14, 4, -9, 2, -5, 8,
- -13, -3, -18, -10, -45, -3, 16, -4, 4, 0,
- }, {
- 69, 17, 3, -3, 10, -8, -3, -40, -1, -21,
- -10, -21, -8, -23, -1, 13, 8, 11, 21, 11,
- 15, 4, 0, -2, -13, -5, -23, -12, -7, 0,
- -1, 0, -10, 14, -28, 5, 1, 11, -5, 7,
- }, {
- 36, 21, 28, 16, 6, 16, 12, -2, 4, -2,
- -20, -7, -11, 4, -20, -4, -12, 2, -1, 0,
- 0, -8, -2, -2, -27, 4, -21, -2, -9, 0,
- -6, -29, -9, -10, -21, 21, 28, 10, 29, 11,
- }, {
- 58, 9, 16, -1, 2, -2, 0, -19, -10, -13,
- -17, -21, -3, -3, -19, 12, -2, 0, 10, -1,
- 5, -12, 0, -15, -26, -5, -34, -16, -11, -7,
- 4, -25, -2, 14, -3, 29, 13, 25, 20, 20,
- }, {
- 55, 28, 21, 27, -2, 7, -8, -20, 4, 1,
- 1, 18, 5, 4, 5, -16, 2, -8, 5, -5,
- 19, 2, 14, 3, 6, 0, -18, -4, 2, -11,
- -8, 18, -11, -10, -29, -3, 10, -13, -8, -3,
- }, {
- 77, 16, 9, 9, -6, -11, -21, -37, -10, -10,
- 4, 5, 13, -3, 7, 0, 13, -11, 17, -6,
- 25, -1, 15, -9, 7, -9, -32, -19, 0, -18,
- 2, 22, -3, 15, -12, 5, -4, 2, -17, 5,
- }, {
- 44, 20, 34, 29, -10, 13, -4, 0, -4, 9,
- -5, 19, 10, 24, -11, -17, -8, -20, -5, -19,
- 9, -14, 12, -9, -6, 0, -30, -9, 0, -19,
- -2, -7, -2, -10, -5, 20, 21, 1, 17, 9,
- }, {
- 66, 8, 23, 11, -14, -5, -17, -16, -19, -2,
- -3, 5, 18, 17, -10, 0, 1, -23, 6, -20,
- 15, -18, 14, -22, -5, -10, -44, -23, -2, -26,
- 9, -3, 4, 14, 12, 29, 7, 16, 7, 18,
- }, {
- 18, 9, -17, -4, 11, 3, 0, 11, 7, 4,
- 10, 3, 10, -18, 24, -3, 14, 7, 4, 10,
- -16, 1, -27, -4, -27, 17, 12, 30, 0, 35,
- -9, -3, -12, -36, -35, -30, -2, -13, 2, -11,
- }, {
- 40, -2, -29, -22, 7, -14, -12, -5, -7, -7,
- 12, -9, 18, -26, 26, 14, 24, 4, 16, 9,
- -10, -2, -26, -18, -26, 7, -1, 15, -1, 27,
- 2, 0, -4, -11, -17, -21, -16, 1, -7, -3,
- }, {
- 8, 1, -3, -2, 3, 10, 3, 32, -1, 12,
- 2, 4, 15, 1, 7, -3, 2, -4, -6, -3,
- -26, -15, -29, -17, -40, 17, 0, 26, -2, 27,
- -2, -29, -4, -36, -10, -6, 9, 0, 27, 0,
- }, {
- 30, -11, -15, -20, 0, -8, -9, 15, -15, 0,
- 5, -9, 23, -6, 8, 13, 13, -7, 5, -3,
- -20, -19, -27, -31, -39, 7, -13, 11, -4, 19,
- 8, -25, 3, -11, 7, 2, -4, 16, 18, 9,
- }, {
- 26, 7, -11, 8, -5, 1, -17, 14, -1, 15,
- 24, 30, 32, 1, 33, -16, 18, -14, 0, -8,
- -6, -4, -12, -12, -6, 13, 2, 23, 8, 15,
- -4, 17, -5, -36, -18, -30, -8, -22, -10, -14,
- }, {
- 48, -4, -23, -9, -9, -17, -30, -2, -16, 3,
- 26, 16, 40, -6, 35, 1, 28, -17, 12, -9,
- 0, -8, -11, -25, -5, 3, -10, 8, 6, 7,
- 6, 22, 1, -11, -1, -21, -22, -7, -19, -5,
- }, {
- 15, 0, 2, 10, -13, 7, -14, 35, -10, 23,
- 16, 31, 37, 21, 16, -17, 6, -26, -10, -21,
- -16, -21, -13, -25, -19, 13, -8, 19, 5, 7,
- 1, -8, 2, -36, 5, -6, 3, -8, 15, -1,
- }, {
- 37, -12, -9, -7, -17, -11, -26, 18, -25, 12,
- 19, 17, 45, 14, 17, 0, 17, -30, 1, -22,
- -10, -25, -12, -38, -18, 3, -22, 4, 3, 0,
- 13, -3, 10, -11, 23, 2, -10, 7, 5, 7,
- }, {
- 5, 29, -9, 11, 15, 22, 3, 0, 18, 8,
- -1, 6, 7, -23, 6, -6, 5, 12, 15, 21,
- 5, 8, -17, 9, -28, 0, -11, 6, 2, 12,
- -11, 0, -14, -13, -49, -22, -8, -9, 4, -9,
- }, {
- 27, 16, -21, -6, 12, 3, -9, -16, 3, -2,
- 1, -7, 15, -31, 7, 10, 16, 9, 27, 21,
- 11, 5, -16, -3, -26, -9, -24, -7, 0, 4,
- 0, 4, -6, 11, -32, -14, -23, 6, -5, -1,
- }, {
- -4, 20, 3, 13, 8, 28, 6, 21, 10, 16,
- -8, 7, 12, -3, -11, -7, -5, 0, 4, 8,
- -4, -8, -18, -3, -41, 0, -22, 2, 0, 4,
- -5, -25, -6, -14, -25, 1, 2, 4, 29, 2,
- }, {
- 17, 8, -8, -4, 4, 10, -6, 5, -4, 5,
- -6, -6, 20, -10, -9, 9, 4, -2, 16, 7,
- 1, -12, -17, -16, -39, -9, -36, -12, -2, -3,
- 6, -21, 1, 11, -7, 10, -11, 20, 20, 11,
- }, {
- 13, 27, -3, 24, -1, 19, -14, 3, 9, 20,
- 12, 33, 29, -3, 15, -20, 9, -9, 11, 3,
- 16, 2, -2, 2, -7, -3, -20, 0, 10, -7,
- -7, 22, -7, -13, -33, -23, -14, -18, -7, -12,
- }, {
- 35, 15, -15, 6, -4, 1, -27, -12, -5, 8,
- 15, 19, 37, -11, 16, -2, 20, -12, 23, 2,
- 22, -1, -1, -11, -5, -13, -34, -14, 8, -14,
- 4, 26, 0, 11, -16, -14, -29, -2, -17, -3,
- }, {
- 3, 19, 9, 26, -8, 26, -10, 24, 0, 28,
- 5, 33, 34, 17, -2, -20, -1, -22, 0, -10,
- 6, -14, -3, -10, -20, -4, -32, -4, 7, -15,
- 0, -3, 0, -13, -9, 0, -3, -4, 17, 0,
- }, {
- 25, 7, -2, 8, -12, 7, -23, 8, -13, 16,
- 7, 20, 42, 9, 0, -3, 9, -25, 12, -10,
- 12, -18, -2, -24, -19, -13, -46, -19, 5, -22,
- 10, 0, 8, 11, 8, 9, -17, 11, 7, 8,
- }, {
- -25, -7, 2, -8, 12, -7, 23, -8, 13, -16,
- -7, -20, -42, -9, 0, 3, -9, 25, -12, 10,
- -12, 18, 2, 24, 19, 13, 46, 19, -5, 22,
- -10, 0, -8, -11, -8, -9, 17, -11, -7, -8,
- }, {
- -3, -19, -9, -26, 8, -26, 10, -24, 0, -28,
- -5, -33, -34, -17, 2, 20, 1, 22, 0, 10,
- -6, 14, 3, 10, 20, 4, 32, 4, -7, 15,
- 0, 3, 0, 13, 9, 0, 3, 4, -17, 0,
- }, {
- -35, -15, 15, -6, 4, -1, 27, 12, 5, -8,
- -15, -19, -37, 11, -16, 2, -20, 12, -23, -2,
- -22, 1, 1, 11, 5, 13, 34, 14, -8, 14,
- -4, -26, 0, -11, 16, 14, 29, 2, 17, 3,
- }, {
- -13, -27, 3, -24, 1, -19, 14, -3, -9, -20,
- -12, -33, -29, 3, -15, 20, -9, 9, -11, -3,
- -16, -2, 2, -2, 7, 3, 20, 0, -10, 7,
- 7, -22, 7, 13, 33, 23, 14, 18, 7, 12,
- }, {
- -17, -8, 8, 4, -4, -10, 6, -5, 4, -5,
- 6, 6, -20, 10, 9, -9, -4, 2, -16, -7,
- -1, 12, 17, 16, 39, 9, 36, 12, 2, 3,
- -6, 21, -1, -11, 7, -10, 11, -20, -20, -11,
- }, {
- 4, -20, -3, -13, -8, -28, -6, -21, -10, -16,
- 8, -7, -12, 3, 11, 7, 5, 0, -4, -8,
- 4, 8, 18, 3, 41, 0, 22, -2, 0, -4,
- 5, 25, 6, 14, 25, -1, -2, -4, -29, -2,
- }, {
- -27, -16, 21, 6, -12, -3, 9, 16, -3, 2,
- -1, 7, -15, 31, -7, -10, -16, -9, -27, -21,
- -11, -5, 16, 3, 26, 9, 24, 7, 0, -4,
- 0, -4, 6, -11, 32, 14, 23, -6, 5, 1,
- }, {
- -5, -29, 9, -11, -15, -22, -3, 0, -18, -8,
- 1, -6, -7, 23, -6, 6, -5, -12, -15, -21,
- -5, -8, 17, -9, 28, 0, 11, -6, -2, -12,
- 11, 0, 14, 13, 49, 22, 8, 9, -4, 9,
- }, {
- -37, 12, 9, 7, 17, 11, 26, -18, 25, -12,
- -19, -17, -45, -14, -17, 0, -17, 30, -1, 22,
- 10, 25, 12, 38, 18, -3, 22, -4, -3, 0,
- -13, 3, -10, 11, -23, -2, 10, -7, -5, -7,
- }, {
- -15, 0, -2, -10, 13, -7, 14, -35, 10, -23,
- -16, -31, -37, -21, -16, 17, -6, 26, 10, 21,
- 16, 21, 13, 25, 19, -13, 8, -19, -5, -7,
- -1, 8, -2, 36, -5, 6, -3, 8, -15, 1,
- }, {
- -48, 4, 23, 9, 9, 17, 30, 2, 16, -3,
- -26, -16, -40, 6, -35, -1, -28, 17, -12, 9,
- 0, 8, 11, 25, 5, -3, 10, -8, -6, -7,
- -6, -22, -1, 11, 1, 21, 22, 7, 19, 5,
- }, {
- -26, -7, 11, -8, 5, -1, 17, -14, 1, -15,
- -24, -30, -32, -1, -33, 16, -18, 14, 0, 8,
- 6, 4, 12, 12, 6, -13, -2, -23, -8, -15,
- 4, -17, 5, 36, 18, 30, 8, 22, 10, 14,
- }, {
- -30, 11, 15, 20, 0, 8, 9, -15, 15, 0,
- -5, 9, -23, 6, -8, -13, -13, 7, -5, 3,
- 20, 19, 27, 31, 39, -7, 13, -11, 4, -19,
- -8, 25, -3, 11, -7, -2, 4, -16, -18, -9,
- }, {
- -8, -1, 3, 2, -3, -10, -3, -32, 1, -12,
- -2, -4, -15, -1, -7, 3, -2, 4, 6, 3,
- 26, 15, 29, 17, 40, -17, 0, -26, 2, -27,
- 2, 29, 4, 36, 10, 6, -9, 0, -27, 0,
- }, {
- -40, 2, 29, 22, -7, 14, 12, 5, 7, 7,
- -12, 9, -18, 26, -26, -14, -24, -4, -16, -9,
- 10, 2, 26, 18, 26, -7, 1, -15, 1, -27,
- -2, 0, 4, 11, 17, 21, 16, -1, 7, 3,
- }, {
- -18, -9, 17, 4, -11, -3, 0, -11, -7, -4,
- -10, -3, -10, 18, -24, 3, -14, -7, -4, -10,
- 16, -1, 27, 4, 27, -17, -12, -30, 0, -35,
- 9, 3, 12, 36, 35, 30, 2, 13, -2, 11,
- }, {
- -66, -8, -23, -11, 14, 5, 17, 16, 19, 2,
- 3, -5, -18, -17, 10, 0, -1, 23, -6, 20,
- -15, 18, -14, 22, 5, 10, 44, 23, 2, 26,
- -9, 3, -4, -14, -12, -29, -7, -16, -7, -18,
- }, {
- -44, -20, -34, -29, 10, -13, 4, 0, 4, -9,
- 5, -19, -10, -24, 11, 17, 8, 20, 5, 19,
- -9, 14, -12, 9, 6, 0, 30, 9, 0, 19,
- 2, 7, 2, 10, 5, -20, -21, -1, -17, -9,
- }, {
- -77, -16, -9, -9, 6, 11, 21, 37, 10, 10,
- -4, -5, -13, 3, -7, 0, -13, 11, -17, 6,
- -25, 1, -15, 9, -7, 9, 32, 19, 0, 18,
- -2, -22, 3, -15, 12, -5, 4, -2, 17, -5,
- }, {
- -55, -28, -21, -27, 2, -7, 8, 20, -4, -1,
- -1, -18, -5, -4, -5, 16, -2, 8, -5, 5,
- -19, -2, -14, -3, -6, 0, 18, 4, -2, 11,
- 8, -18, 11, 10, 29, 3, -10, 13, 8, 3,
- }, {
- -58, -9, -16, 1, -2, 2, 0, 19, 10, 13,
- 17, 21, 3, 3, 19, -12, 2, 0, -10, 1,
- -5, 12, 0, 15, 26, 5, 34, 16, 11, 7,
- -4, 25, 2, -14, 3, -29, -13, -25, -20, -20,
- }, {
- -36, -21, -28, -16, -6, -16, -12, 2, -4, 2,
- 20, 7, 11, -4, 20, 4, 12, -2, 1, 0,
- 0, 8, 2, 2, 27, -4, 21, 2, 9, 0,
- 6, 29, 9, 10, 21, -21, -28, -10, -29, -11,
- }, {
- -69, -17, -3, 3, -10, 8, 3, 40, 1, 21,
- 10, 21, 8, 23, 1, -13, -8, -11, -21, -11,
- -15, -4, 0, 2, 13, 5, 23, 12, 7, 0,
- 1, 0, 10, -14, 28, -5, -1, -11, 5, -7,
- }, {
- -47, -30, -15, -14, -14, -9, -9, 23, -13, 10,
- 12, 7, 16, 15, 3, 3, 1, -14, -9, -12,
- -9, -8, 0, -10, 14, -4, 9, -2, 5, -8,
- 13, 3, 18, 10, 45, 3, -16, 4, -4, 0,
- }, {
- -79, 11, -15, 4, 18, 23, 20, 5, 30, 7,
- -7, -2, -21, -21, -8, -3, -10, 28, 4, 31,
- 6, 25, -3, 37, 4, -7, 20, 0, 4, 4,
- -11, 7, -6, 8, -27, -22, -14, -12, -5, -16,
- }, {
- -57, 0, -27, -13, 14, 5, 7, -11, 15, -4,
- -5, -16, -13, -29, -6, 13, 0, 25, 16, 31,
- 12, 22, -2, 23, 6, -16, 7, -14, 2, -3,
- 0, 12, 0, 33, -9, -13, -28, 3, -14, -7,
- }, {
- -90, 3, -2, 6, 10, 29, 24, 26, 21, 15,
- -15, -2, -16, -1, -25, -4, -21, 16, -6, 18,
- -3, 8, -5, 24, -8, -7, 9, -4, 1, -3,
- -5, -18, 1, 7, -2, 1, -2, 1, 19, -3,
- }, {
- -67, -8, -14, -11, 7, 11, 11, 9, 7, 3,
- -13, -16, -8, -9, -24, 12, -10, 13, 5, 17,
- 2, 4, -3, 10, -6, -17, -4, -19, 0, -11,
- 6, -13, 9, 33, 14, 10, -16, 17, 10, 4,
- }, {
- -71, 10, -9, 17, 1, 20, 3, 8, 21, 18,
- 6, 24, 0, -1, 0, -16, -6, 5, 0, 13,
- 17, 19, 11, 29, 25, -11, 11, -6, 13, -15,
- -7, 29, 0, 8, -11, -22, -20, -21, -17, -18,
- }, {
- -49, -2, -21, 0, -1, 2, -9, -8, 6, 6,
- 8, 10, 8, -9, 2, 0, 4, 2, 13, 12,
- 23, 15, 12, 16, 26, -21, -2, -21, 11, -23,
- 4, 33, 7, 33, 6, -13, -34, -5, -27, -10,
- }, {
- -82, 1, 4, 19, -6, 27, 6, 29, 12, 26,
- -1, 24, 5, 18, -17, -17, -17, -6, -10, 0,
- 7, 2, 9, 16, 12, -11, 0, -11, 9, -23,
- 0, 3, 8, 8, 13, 1, -8, -7, 7, -6,
- }, {
- -60, -10, -7, 1, -9, 8, -6, 13, -2, 15,
- 1, 10, 13, 11, -15, 0, -6, -9, 1, 0,
- 13, -1, 11, 3, 13, -21, -13, -26, 7, -31,
- 10, 7, 16, 33, 31, 10, -22, 8, -1, 2,
- }, {
- -3, 7, -5, -5, 8, -2, 17, -9, 18, -24,
- -2, -19, -10, -4, 28, 17, 5, 28, -2, 7,
- -4, 15, 7, 8, 6, 23, 13, 21, -14, 20,
- -17, -18, -11, -33, -30, -11, 23, -13, -5, -9,
- }, {
- 18, -4, -17, -23, 4, -20, 4, -26, 3, -36,
- 0, -32, -2, -12, 29, 34, 16, 24, 10, 6,
- 0, 12, 8, -4, 8, 13, 0, 6, -16, 12,
- -5, -13, -3, -7, -13, -3, 8, 2, -14, 0,
- }, {
- -13, 0, 8, -3, 0, 4, 21, 11, 9, -16,
- -10, -18, -5, 16, 10, 16, -5, 15, -13, -5,
- -15, -1, 6, -4, -6, 23, 2, 16, -17, 12,
- -10, -44, -3, -33, -6, 12, 34, 1, 20, 3,
- }, {
- 8, -12, -3, -21, -3, -14, 8, -5, -4, -28,
- -7, -32, 2, 8, 12, 34, 4, 12, -1, -6,
- -9, -4, 7, -17, -4, 13, -11, 1, -19, 4,
- 0, -39, 4, -7, 11, 21, 20, 16, 10, 11,
- }, {
- 4, 6, 0, 7, -8, -4, 0, -6, 9, -13,
- 11, 7, 11, 15, 37, 4, 9, 5, -5, -11,
- 5, 9, 22, 1, 27, 18, 4, 14, -5, 0,
- -12, 3, -4, -32, -14, -12, 17, -22, -17, -11,
- }, {
- 26, -6, -11, -10, -12, -23, -12, -23, -5, -24,
- 13, -5, 19, 8, 38, 21, 20, 2, 6, -12,
- 11, 5, 23, -11, 29, 9, -9, 0, -7, -6,
- -1, 7, 2, -7, 3, -3, 2, -6, -27, -3,
- }, {
- -6, -2, 14, 9, -16, 1, 3, 14, 0, -5,
- 3, 8, 16, 36, 19, 3, -1, -6, -17, -24,
- -4, -7, 21, -11, 14, 18, -7, 9, -9, -7,
- -6, -22, 3, -33, 10, 11, 28, -7, 7, 0,
- }, {
- 16, -14, 2, -8, -20, -17, -9, -2, -14, -16,
- 6, -5, 24, 28, 21, 20, 8, -9, -4, -25,
- 1, -11, 22, -24, 15, 8, -21, -5, -11, -14,
- 5, -18, 11, -7, 27, 20, 14, 7, -1, 9,
- }, {
- -16, 27, 2, 10, 13, 16, 20, -20, 29, -20,
- -14, -16, -13, -8, 9, 13, -2, 33, 9, 19,
- 17, 23, 17, 22, 6, 6, -9, -2, -12, -2,
- -20, -13, -13, -10, -45, -4, 16, -8, -2, -7,
- }, {
- 5, 15, -9, -7, 9, -2, 8, -37, 14, -31,
- -11, -29, -5, -16, 11, 30, 7, 29, 21, 18,
- 23, 19, 18, 9, 7, -3, -23, -17, -14, -9,
- -8, -9, -6, 15, -27, 4, 2, 6, -12, 1,
- }, {
- -26, 19, 15, 12, 5, 22, 24, 0, 21, -12,
- -21, -15, -8, 11, -7, 12, -14, 20, -2, 6,
- 7, 6, 16, 9, -6, 5, -21, -7, -15, -10,
- -13, -39, -5, -10, -20, 19, 28, 5, 22, 5,
- }, {
- -4, 6, 3, -5, 1, 4, 11, -16, 6, -23,
- -19, -29, 0, 3, -6, 30, -3, 17, 10, 5,
- 13, 2, 17, -3, -5, -3, -35, -21, -17, -17,
- -2, -35, 2, 15, -3, 28, 13, 21, 13, 13,
- }, {
- -8, 25, 8, 23, -3, 13, 3, -17, 20, -8,
- 0, 10, 8, 11, 18, 0, 1, 10, 5, 0,
- 28, 17, 32, 15, 26, 1, -19, -9, -3, -21,
- -15, 7, -6, -9, -29, -5, 10, -17, -15, -9,
- }, {
- 13, 13, -3, 5, -7, -4, -9, -34, 5, -20,
- 2, -3, 16, 3, 20, 17, 11, 7, 17, 0,
- 34, 13, 33, 2, 28, -8, -32, -24, -5, -29,
- -3, 12, 0, 15, -11, 3, -3, -2, -24, -1,
- }, {
- -18, 17, 21, 25, -11, 19, 6, 3, 11, 0,
- -7, 11, 13, 31, 1, 0, -9, -1, -5, -12,
- 18, 0, 31, 2, 13, 1, -30, -14, -7, -29,
- -9, -18, 1, -10, -4, 18, 22, -3, 10, 2,
- }, {
- 3, 5, 9, 7, -15, 1, -5, -13, -2, -12,
- -5, -2, 21, 23, 2, 16, 0, -5, 6, -13,
- 23, -3, 32, -10, 15, -8, -44, -28, -9, -37,
- 2, -13, 9, 15, 12, 27, 7, 12, 0, 11,
- }, {
- -44, 6, -30, -8, 9, 10, 11, 14, 23, -5,
- 8, -4, 14, -12, 37, 14, 12, 26, 4, 16,
- -8, 16, -9, 7, -6, 19, 12, 25, -5, 24,
- -15, -13, -8, -36, -34, -31, -1, -18, -4, -18,
- }, {
- -22, -5, -42, -26, 6, -8, -1, -2, 9, -17,
- 10, -18, 21, -19, 39, 31, 23, 23, 16, 15,
- -2, 12, -7, -6, -5, 9, -1, 10, -7, 16,
- -4, -9, 0, -10, -17, -22, -16, -2, -14, -9,
- }, {
- -55, -1, -17, -6, 1, 16, 15, 35, 15, 2,
- 0, -4, 19, 8, 20, 13, 1, 14, -7, 3,
- -18, 0, -10, -5, -19, 19, 0, 21, -8, 16,
- -9, -39, 0, -36, -10, -7, 9, -4, 20, -5,
- }, {
- -33, -13, -29, -24, -1, -1, 2, 18, 0, -9,
- 3, -17, 27, 0, 21, 30, 12, 11, 5, 2,
- -12, -4, -9, -19, -18, 9, -13, 6, -11, 8,
- 2, -35, 8, -10, 7, 1, -4, 11, 10, 2,
- }, {
- -36, 5, -24, 4, -7, 7, -6, 17, 14, 5,
- 22, 22, 35, 8, 46, 1, 17, 3, 0, -2,
- 2, 10, 5, 0, 14, 15, 2, 18, 2, 4,
- -11, 7, -1, -36, -18, -32, -7, -27, -17, -20,
- }, {
- -14, -7, -36, -13, -10, -10, -18, 0, 0, -5,
- 25, 8, 43, 0, 48, 18, 27, 0, 12, -3,
- 7, 6, 7, -13, 15, 5, -11, 3, 0, -2,
- 0, 12, 6, -10, 0, -23, -22, -11, -26, -12,
- }, {
- -47, -3, -11, 6, -15, 13, -2, 38, 6, 13,
- 15, 22, 40, 28, 28, 0, 5, -8, -10, -15,
- -7, -7, 4, -13, 1, 14, -9, 14, 0, -2,
- -4, -18, 7, -36, 6, -8, 3, -13, 7, -8,
- }, {
- -25, -15, -22, -11, -18, -4, -15, 22, -8, 2,
- 17, 9, 48, 20, 30, 17, 16, -11, 1, -16,
- -2, -10, 5, -26, 2, 4, -22, 0, -2, -10,
- 6, -13, 14, -10, 23, 0, -10, 2, -1, 0,
- }, {
- -57, 26, -22, 7, 14, 28, 14, 3, 35, 0,
- -3, -1, 11, -16, 18, 10, 4, 31, 15, 28,
- 14, 23, 1, 21, -7, 2, -11, 1, -3, 1,
- -18, -9, -10, -13, -49, -24, -8, -14, -2, -16,
- }, {
- -35, 14, -34, -10, 10, 10, 1, -12, 20, -12,
- 0, -15, 18, -24, 20, 27, 14, 28, 27, 27,
- 20, 19, 2, 8, -5, -7, -25, -13, -5, -5,
- -6, -5, -2, 12, -31, -15, -23, 1, -12, -8,
- }, {
- -68, 18, -9, 9, 6, 35, 18, 25, 26, 7,
- -10, -1, 16, 3, 1, 9, -6, 19, 4, 15,
- 4, 6, 0, 8, -20, 2, -23, -2, -7, -5,
- -12, -35, -1, -13, -24, 0, 3, 0, 22, -4,
- }, {
- -46, 6, -21, -8, 2, 16, 5, 8, 11, -4,
- -8, -15, 24, -4, 2, 26, 3, 16, 16, 14,
- 9, 2, 1, -4, -19, -7, -36, -17, -9, -13,
- 0, -31, 5, 12, -7, 8, -11, 15, 13, 4,
- }, {
- -49, 24, -16, 20, -2, 26, -2, 7, 25, 10,
- 11, 25, 32, 3, 27, -2, 8, 8, 11, 9,
- 24, 17, 16, 14, 13, -2, -20, -5, 4, -17,
- -14, 12, -3, -13, -33, -25, -14, -23, -15, -19,
- }, {
- -27, 12, -28, 2, -6, 7, -15, -9, 11, -1,
- 13, 11, 40, -4, 29, 14, 19, 5, 23, 8,
- 30, 13, 17, 0, 14, -12, -34, -20, 2, -25,
- -2, 16, 4, 12, -15, -16, -29, -7, -24, -10,
- }, {
- -60, 16, -3, 22, -10, 32, 0, 28, 17, 18,
- 3, 25, 37, 23, 10, -3, -2, -3, 0, -3,
- 14, 0, 14, 1, 0, -2, -32, -9, 1, -25,
- -7, -13, 5, -13, -8, -1, -2, -8, 10, -6,
- }, {
- -38, 4, -15, 4, -14, 13, -12, 11, 2, 6,
- 6, 11, 45, 16, 11, 13, 7, -6, 12, -4,
- 20, -3, 16, -12, 1, -12, -46, -24, 0, -33,
- 3, -9, 12, 12, 8, 7, -17, 6, 0, 2
- }
-};
-
-const int8_t ff_cb2_vects[128][40]={
- {
- 73, -32, -60, -15, -26, 59, 2, -33, 30, -10,
- -3, -17, 8, 30, -1, -26, -4, -22, 10, 16,
- -36, -5, -11, 56, 37, 6, -10, -5, -13, -3,
- 6, -5, 11, 4, -19, -5, -16, 41, 24, 13,
- }, {
- 4, -11, -37, 23, -5, 46, -2, -29, -5, -39,
- -21, -9, 0, 49, 12, -9, -16, -26, 22, 15,
- -45, -20, -5, 40, 22, 17, -26, 31, -14, 2,
- -14, 10, 30, 20, -27, -9, -39, 39, 18, 5,
- }, {
- 34, -25, -48, -28, -11, 34, -2, -41, 9, -7,
- -17, 21, 20, 24, -17, -33, 0, -24, 10, 42,
- 3, -5, 10, 42, 11, 8, -3, 3, 16, 9,
- 22, -2, 0, -33, -10, 18, 7, 58, 10, 28,
- }, {
- -34, -4, -25, 10, 9, 21, -7, -36, -26, -36,
- -35, 28, 12, 42, -3, -16, -12, -28, 21, 42,
- -5, -21, 16, 26, -4, 19, -19, 39, 15, 15,
- 1, 13, 19, -17, -17, 14, -15, 55, 4, 19,
- }, {
- 28, -20, -51, -14, -6, 7, 0, -26, 27, -4,
- 18, -40, -6, 16, -1, -15, 0, -55, -5, -16,
- -19, 14, -3, 49, 14, 1, -22, -30, -12, 0,
- 24, 15, 9, -17, -45, -29, 4, 28, 51, 35,
- }, {
- -40, 0, -28, 24, 14, -5, -4, -21, -7, -33,
- 0, -32, -15, 35, 12, 1, -11, -58, 5, -16,
- -28, 0, 1, 33, 0, 11, -39, 5, -14, 6,
- 3, 31, 28, -1, -53, -33, -19, 25, 46, 26,
- }, {
- -11, -14, -39, -27, 9, -17, -4, -33, 6, 0,
- 4, -1, 5, 10, -17, -22, 5, -57, -5, 9,
- 20, 13, 18, 35, -11, 3, -16, -22, 17, 13,
- 40, 19, -1, -55, -35, -5, 27, 44, 37, 49,
- }, {
- -80, 6, -16, 11, 30, -30, -9, -28, -28, -29,
- -13, 6, -2, 28, -3, -5, -7, -60, 5, 9,
- 11, -1, 24, 19, -27, 13, -32, 13, 15, 19,
- 19, 35, 17, -39, -43, -9, 4, 42, 32, 41,
- }, {
- 78, -21, -43, 4, -38, 17, 17, -5, 55, 24,
- -15, -36, 14, 4, 24, -24, 12, 5, 17, 31,
- -54, -5, -2, 27, 43, -12, 2, 9, -9, -15,
- 22, -3, 28, 21, -20, 3, 20, 28, 9, -5,
- }, {
- 9, -1, -20, 43, -17, 3, 12, 0, 20, -4,
- -33, -29, 6, 22, 38, -7, 0, 1, 29, 30,
- -63, -21, 3, 11, 27, -1, -14, 45, -10, -9,
- 1, 12, 47, 37, -28, 0, -2, 26, 4, -13,
- }, {
- 39, -14, -30, -8, -22, -8, 12, -12, 34, 27,
- -29, 2, 26, -2, 8, -31, 16, 3, 17, 57,
- -14, -6, 19, 13, 16, -10, 8, 17, 20, -2,
- 38, 0, 17, -16, -11, 27, 44, 45, -4, 8,
- }, {
- -29, 5, -7, 30, -1, -21, 7, -7, 0, 0,
- -47, 9, 18, 15, 22, -14, 4, 0, 28, 57,
- -23, -21, 25, -2, 1, 0, -7, 53, 19, 3,
- 17, 15, 36, 0, -19, 24, 21, 43, -9, 0,
- }, {
- 33, -10, -34, 5, -17, -35, 15, 1, 53, 30,
- 6, -59, 0, -10, 24, -13, 17, -27, 1, -1,
- -37, 13, 4, 20, 20, -18, -10, -16, -8, -11,
- 39, 18, 26, 0, -46, -20, 41, 15, 37, 15,
- }, {
- -35, 10, -11, 44, 3, -48, 10, 6, 17, 2,
- -11, -51, -8, 8, 38, 3, 4, -31, 12, -2,
- -46, -1, 10, 4, 5, -7, -26, 19, -10, -5,
- 18, 34, 45, 15, -54, -24, 18, 13, 31, 7,
- }, {
- -5, -3, -21, -7, -2, -60, 10, -5, 32, 34,
- -7, -20, 11, -16, 8, -20, 21, -29, 1, 24,
- 2, 13, 27, 6, -5, -15, -3, -8, 21, 1,
- 55, 21, 15, -38, -37, 3, 65, 32, 23, 30,
- }, {
- -74, 17, 0, 31, 18, -73, 5, 0, -3, 5,
- -25, -12, 3, 1, 22, -3, 9, -33, 12, 24,
- -6, -2, 33, -9, -21, -5, -20, 27, 19, 7,
- 34, 37, 34, -22, -44, 0, 41, 29, 17, 21,
- }, {
- 76, -35, -31, -28, -49, 43, -40, 0, 29, -14,
- 8, 5, 10, 18, -26, -46, 0, 7, 6, 3,
- -25, -7, -2, 40, 28, 14, 18, -3, -27, -28,
- -8, -45, -13, 34, -13, -27, -15, 31, 12, 3,
- }, {
- 7, -15, -9, 9, -28, 29, -45, 5, -6, -43,
- -9, 12, 2, 36, -12, -30, -11, 3, 17, 3,
- -34, -22, 3, 24, 12, 24, 2, 32, -28, -22,
- -29, -29, 5, 50, -21, -31, -38, 29, 7, -5,
- }, {
- 36, -29, -19, -41, -34, 18, -45, -6, 8, -10,
- -5, 43, 23, 11, -42, -53, 5, 5, 6, 30,
- 14, -8, 20, 26, 1, 16, 25, 4, 3, -15,
- 7, -41, -23, -3, -4, -3, 8, 48, -1, 17,
- }, {
- -32, -8, 3, -2, -13, 4, -50, -1, -27, -39,
- -23, 51, 15, 30, -27, -37, -7, 1, 17, 29,
- 5, -23, 25, 10, -14, 26, 8, 41, 1, -9,
- -13, -26, -5, 12, -12, -7, -14, 45, -6, 9,
- }, {
- 31, -24, -23, -27, -29, -9, -43, 8, 26, -7,
- 30, -17, -4, 3, -26, -35, 5, -24, -10, -28,
- -9, 12, 5, 33, 5, 8, 5, -29, -26, -24,
- 9, -23, -14, 12, -39, -52, 5, 18, 39, 24,
- }, {
- -37, -3, 0, 10, -7, -22, -48, 12, -8, -36,
- 12, -9, -12, 22, -12, -19, -6, -28, 0, -29,
- -18, -3, 11, 17, -10, 18, -10, 7, -27, -18,
- -11, -7, 3, 28, -47, -55, -18, 15, 34, 16,
- }, {
- -8, -17, -10, -40, -13, -34, -47, 0, 5, -4,
- 16, 21, 8, -2, -42, -43, 10, -26, -10, -2,
- 31, 11, 27, 19, -21, 10, 12, -20, 3, -11,
- 25, -20, -25, -25, -29, -28, 28, 34, 25, 38,
- }, {
- -77, 2, 11, -1, 7, -47, -52, 5, -29, -33,
- -1, 28, 0, 15, -28, -26, -2, -30, 0, -2,
- 22, -4, 33, 3, -36, 21, -3, 15, 2, -5,
- 4, -4, -6, -9, -37, -31, 5, 32, 20, 30,
- }, {
- 81, -25, -14, -8, -61, 0, -25, 28, 54, 20,
- -3, -14, 17, -8, 0, -44, 16, 35, 13, 18,
- -43, -7, 6, 11, 33, -4, 30, 11, -22, -40,
- 6, -43, 3, 50, -14, -18, 22, 18, -1, -16,
- }, {
- 12, -4, 8, 29, -39, -12, -30, 33, 19, -8,
- -21, -6, 8, 9, 13, -28, 4, 31, 24, 18,
- -52, -23, 12, -4, 18, 5, 14, 47, -24, -34,
- -14, -27, 22, 66, -22, -22, -1, 16, -6, -24,
- }, {
- 41, -18, -2, -21, -45, -24, -30, 21, 33, 24,
- -17, 24, 29, -15, -16, -51, 21, 33, 13, 45,
- -3, -8, 28, -2, 7, -2, 37, 19, 7, -27,
- 22, -39, -7, 12, -5, 5, 45, 35, -15, -1,
- }, {
- -27, 1, 20, 17, -24, -38, -35, 26, -1, -4,
- -35, 32, 21, 3, -2, -35, 8, 29, 24, 44,
- -12, -24, 34, -18, -8, 7, 21, 55, 5, -21,
- 2, -23, 11, 28, -13, 1, 22, 33, -21, -10,
- }, {
- 36, -13, -5, -7, -40, -51, -28, 36, 52, 27,
- 18, -36, 2, -22, 0, -33, 21, 2, -3, -13,
- -26, 11, 14, 4, 10, -10, 18, -14, -22, -36,
- 24, -21, 1, 28, -40, -42, 42, 5, 25, 5,
- }, {
- -32, 6, 17, 31, -19, -65, -33, 41, 16, -1,
- 0, -29, -6, -4, 13, -17, 9, -1, 8, -14,
- -35, -3, 19, -11, -4, 0, 1, 21, -23, -30,
- 3, -5, 20, 44, -48, -46, 19, 3, 20, -3,
- }, {
- -3, -7, 6, -20, -25, -77, -32, 29, 31, 30,
- 4, 2, 14, -29, -16, -40, 26, 0, -3, 12,
- 13, 10, 36, -9, -15, -8, 24, -6, 7, -22,
- 40, -17, -8, -9, -31, -18, 66, 22, 11, 19,
- }, {
- -72, 13, 29, 18, -4, -90, -37, 34, -4, 1,
- -13, 9, 6, -11, -2, -24, 13, -3, 7, 11,
- 4, -4, 42, -25, -31, 1, 8, 29, 6, -17,
- 19, -2, 10, 6, -38, -22, 42, 19, 6, 11,
- }, {
- 116, -20, -68, -30, -28, 83, 28, -18, 32, -22,
- -13, -21, 5, 28, 5, -7, -24, -8, -22, 17,
- -23, 30, -25, 45, 15, -9, -11, -18, 22, -10,
- 4, -2, 19, -12, 23, 3, -43, 2, 12, -4,
- }, {
- 47, 0, -45, 7, -7, 69, 23, -13, -2, -51,
- -32, -14, -3, 47, 19, 8, -37, -11, -10, 16,
- -32, 15, -19, 29, 0, 1, -28, 18, 20, -4,
- -16, 13, 38, 3, 15, 0, -66, 0, 7, -13,
- }, {
- 77, -13, -56, -43, -13, 57, 23, -26, 11, -19,
- -27, 16, 17, 22, -10, -15, -19, -10, -22, 43,
- 16, 30, -2, 31, -11, -6, -5, -9, 52, 2,
- 20, 0, 8, -50, 33, 27, -19, 19, -1, 9,
- }, {
- 8, 6, -33, -4, 7, 44, 18, -21, -23, -48,
- -46, 24, 9, 40, 3, 1, -32, -13, -11, 43,
- 7, 14, 3, 15, -26, 3, -21, 26, 50, 8,
- 0, 16, 27, -34, 25, 23, -43, 17, -6, 1,
- }, {
- 71, -9, -59, -29, -8, 30, 26, -11, 30, -16,
- 8, -44, -9, 14, 5, 2, -19, -40, -38, -15,
- -7, 50, -17, 38, -7, -14, -24, -43, 22, -6,
- 22, 19, 17, -34, -2, -20, -23, -10, 39, 16,
- }, {
- 2, 11, -36, 9, 13, 17, 21, -6, -5, -45,
- -10, -36, -18, 33, 19, 19, -31, -44, -27, -15,
- -16, 34, -11, 22, -22, -4, -40, -7, 21, 0,
- 1, 35, 36, -18, -10, -24, -46, -12, 34, 8,
- }, {
- 32, -2, -47, -42, 7, 5, 21, -18, 9, -12,
- -5, -5, 2, 8, -10, -4, -14, -42, -38, 10,
- 33, 49, 5, 24, -33, -12, -17, -35, 52, 6,
- 38, 22, 7, -72, 7, 3, 0, 6, 25, 30,
- }, {
- -36, 18, -24, -3, 28, -7, 16, -13, -26, -41,
- -24, 1, -5, 26, 3, 12, -27, -46, -27, 10,
- 24, 34, 10, 8, -49, -2, -34, 0, 51, 12,
- 17, 38, 25, -56, 0, 0, -22, 3, 20, 22,
- }, {
- 121, -9, -50, -10, -40, 40, 43, 9, 58, 12,
- -25, -41, 11, 2, 31, -5, -8, 19, -15, 32,
- -41, 30, -16, 16, 20, -28, 0, -3, 26, -22,
- 19, 0, 36, 4, 22, 12, -6, -9, -1, -24,
- }, {
- 52, 10, -27, 27, -18, 26, 38, 14, 23, -16,
- -44, -33, 3, 20, 45, 10, -20, 15, -3, 31,
- -50, 14, -10, 0, 5, -17, -15, 32, 24, -16,
- -1, 15, 55, 20, 14, 8, -29, -12, -7, -32,
- }, {
- 82, -3, -38, -23, -24, 15, 38, 2, 37, 15,
- -39, -2, 23, -4, 15, -12, -3, 17, -15, 58,
- -1, 29, 6, 2, -5, -26, 7, 4, 56, -9,
- 35, 3, 25, -33, 32, 36, 17, 7, -15, -9,
- }, {
- 13, 17, -15, 15, -3, 1, 33, 7, 1, -12,
- -58, 5, 15, 13, 29, 3, -16, 13, -4, 57,
- -10, 13, 11, -13, -21, -15, -9, 40, 55, -3,
- 14, 19, 44, -17, 24, 32, -5, 4, -21, -18,
- }, {
- 76, 1, -41, -9, -19, -12, 41, 17, 55, 18,
- -3, -63, -3, -12, 30, 5, -3, -12, -31, 0,
- -24, 49, -8, 9, -1, -33, -12, -29, 27, -18,
- 37, 21, 34, -17, -3, -11, 14, -23, 25, -2,
- }, {
- 7, 22, -18, 29, 1, -25, 36, 21, 20, -9,
- -22, -56, -11, 6, 45, 21, -15, -16, -20, -1,
- -33, 34, -2, -6, -17, -23, -28, 6, 25, -12,
- 16, 37, 53, -1, -11, -15, -8, -25, 20, -11,
- }, {
- 37, 8, -29, -22, -4, -37, 36, 9, 34, 22,
- -17, -24, 8, -18, 15, -2, 1, -14, -31, 25,
- 15, 48, 13, -4, -28, -31, -5, -21, 57, -4,
- 53, 24, 23, -55, 6, 12, 37, -6, 11, 11,
- }, {
- -31, 28, -6, 16, 16, -50, 31, 14, 0, -6,
- -36, -17, 0, 0, 29, 14, -11, -18, -20, 25,
- 6, 33, 19, -20, -43, -21, -21, 14, 55, 0,
- 32, 40, 42, -39, -1, 8, 14, -8, 6, 3,
- }, {
- 119, -24, -39, -44, -51, 66, -14, 15, 31, -26,
- -1, 0, 7, 16, -19, -28, -19, 22, -26, 4,
- -13, 28, -16, 29, 5, -1, 16, -16, 8, -35,
- -10, -42, -4, 17, 29, -19, -42, -7, 0, -15,
- }, {
- 50, -3, -16, -5, -30, 53, -19, 20, -3, -55,
- -19, 8, 0, 34, -5, -11, -32, 18, -15, 4,
- -22, 13, -10, 13, -9, 8, 0, 19, 7, -29,
- -31, -26, 13, 33, 21, -22, -65, -9, -4, -23,
- }, {
- 79, -17, -27, -56, -36, 41, -19, 8, 10, -22,
- -15, 39, 20, 9, -35, -35, -15, 20, -26, 31,
- 26, 27, 6, 15, -20, 0, 23, -8, 38, -22,
- 5, -38, -15, -20, 39, 4, -18, 9, -13, -1,
- }, {
- 10, 3, -4, -18, -15, 27, -24, 13, -24, -51,
- -34, 47, 12, 28, -21, -19, -27, 16, -15, 30,
- 17, 12, 12, 0, -36, 10, 7, 27, 37, -16,
- -15, -22, 3, -4, 31, 1, -42, 7, -18, -9,
- }, {
- 74, -12, -30, -42, -30, 14, -16, 23, 29, -19,
- 20, -21, -7, 1, -19, -17, -14, -10, -43, -27,
- 3, 48, -8, 22, -16, -7, 4, -42, 9, -31,
- 6, -20, -6, -4, 3, -43, -22, -20, 28, 5,
- }, {
- 5, 7, -7, -4, -9, 0, -21, 28, -6, -48,
- 2, -14, -15, 20, -5, 0, -27, -14, -32, -28,
- -5, 32, -2, 6, -32, 3, -12, -5, 8, -25,
- -14, -4, 12, 11, -4, -47, -45, -22, 22, -2,
- }, {
- 34, -6, -18, -55, -15, -11, -21, 16, 8, -16,
- 6, 16, 5, -4, -35, -24, -10, -12, -43, -1,
- 43, 47, 14, 8, -43, -5, 10, -34, 39, -18,
- 22, -16, -17, -42, 13, -19, 1, -3, 14, 20,
- }, {
- -34, 14, 4, -17, 5, -24, -26, 20, -27, -45,
- -12, 24, -2, 13, -21, -8, -22, -16, -32, -2,
- 34, 31, 20, -7, -58, 5, -5, 2, 38, -12,
- 2, -1, 1, -26, 5, -23, -21, -6, 8, 11,
- }, {
- 124, -13, -21, -23, -62, 23, 0, 43, 57, 8,
- -13, -18, 14, -10, 6, -26, -3, 49, -19, 19,
- -31, 27, -7, 0, 11, -20, 29, -1, 12, -47,
- 4, -39, 11, 34, 28, -9, -5, -19, -13, -34,
- }, {
- 55, 6, 1, 14, -41, 10, -4, 48, 22, -20,
- -31, -10, 5, 7, 20, -9, -16, 45, -8, 19,
- -40, 12, -1, -15, -4, -10, 12, 34, 11, -41,
- -16, -24, 30, 49, 20, -13, -28, -22, -18, -43,
- }, {
- 84, -6, -9, -36, -47, -1, -4, 36, 36, 12,
- -27, 20, 26, -17, -9, -33, 1, 47, -19, 46,
- 9, 27, 15, -13, -15, -18, 35, 6, 42, -33,
- 20, -36, 1, -4, 38, 14, 18, -2, -27, -20,
- }, {
- 15, 13, 13, 1, -26, -14, -9, 41, 1, -16,
- -46, 27, 18, 1, 4, -16, -11, 43, -8, 45,
- 0, 11, 21, -29, -30, -8, 19, 42, 41, -28,
- 0, -20, 20, 11, 30, 10, -4, -5, -32, -28,
- }, {
- 79, -2, -12, -22, -42, -28, -1, 51, 54, 15,
- 8, -41, 0, -24, 6, -15, 1, 17, -36, -12,
- -14, 47, 0, -6, -11, -26, 16, -27, 13, -43,
- 22, -18, 10, 12, 2, -34, 15, -33, 13, -13,
- }, {
- 10, 18, 10, 15, -21, -41, -6, 56, 19, -13,
- -9, -33, -9, -6, 20, 1, -11, 13, -24, -13,
- -23, 32, 6, -22, -26, -15, 0, 8, 12, -37,
- 1, -2, 28, 27, -5, -37, -7, -35, 8, -21,
- }, {
- 39, 4, 0, -35, -27, -53, -6, 44, 33, 18,
- -5, -2, 11, -31, -9, -22, 6, 15, -36, 13,
- 25, 46, 23, -20, -37, -24, 23, -19, 43, -29,
- 38, -14, 0, -26, 12, -10, 38, -16, 0, 0,
- }, {
- -29, 25, 22, 2, -6, -67, -11, 49, -1, -10,
- -24, 5, 3, -13, 4, -5, -6, 11, -25, 12,
- 16, 31, 28, -36, -53, -13, 6, 16, 42, -24,
- 17, 1, 18, -10, 4, -13, 15, -18, -5, -7,
- }, {
- 29, -25, -22, -2, 6, 67, 11, -49, 1, 10,
- 24, -5, -3, 13, -4, 5, 6, -11, 25, -12,
- -16, -31, -28, 36, 53, 13, -6, -16, -42, 24,
- -17, -1, -18, 10, -4, 13, -15, 18, 5, 7,
- }, {
- -39, -4, 0, 35, 27, 53, 6, -44, -33, -18,
- 5, 2, -11, 31, 9, 22, -6, -15, 36, -13,
- -25, -46, -23, 20, 37, 24, -23, 19, -43, 29,
- -38, 14, 0, 26, -12, 10, -38, 16, 0, 0,
- }, {
- -10, -18, -10, -15, 21, 41, 6, -56, -19, 13,
- 9, 33, 9, 6, -20, -1, 11, -13, 24, 13,
- 23, -32, -6, 22, 26, 15, 0, -8, -12, 37,
- -1, 2, -28, -27, 5, 37, 7, 35, -8, 21,
- }, {
- -79, 2, 12, 22, 42, 28, 1, -51, -54, -15,
- -8, 41, 0, 24, -6, 15, -1, -17, 36, 12,
- 14, -47, 0, 6, 11, 26, -16, 27, -13, 43,
- -22, 18, -10, -12, -2, 34, -15, 33, -13, 13,
- }, {
- -15, -13, -13, -1, 26, 14, 9, -41, -1, 16,
- 46, -27, -18, -1, -4, 16, 11, -43, 8, -45,
- 0, -11, -21, 29, 30, 8, -19, -42, -41, 28,
- 0, 20, -20, -11, -30, -10, 4, 5, 32, 28,
- }, {
- -84, 6, 9, 36, 47, 1, 4, -36, -36, -12,
- 27, -20, -26, 17, 9, 33, -1, -47, 19, -46,
- -9, -27, -15, 13, 15, 18, -35, -6, -42, 33,
- -20, 36, -1, 4, -38, -14, -18, 2, 27, 20,
- }, {
- -55, -6, -1, -14, 41, -10, 4, -48, -22, 20,
- 31, 10, -5, -7, -20, 9, 16, -45, 8, -19,
- 40, -12, 1, 15, 4, 10, -12, -34, -11, 41,
- 16, 24, -30, -49, -20, 13, 28, 22, 18, 43,
- }, {
- -124, 13, 21, 23, 62, -23, 0, -43, -57, -8,
- 13, 18, -14, 10, -6, 26, 3, -49, 19, -19,
- 31, -27, 7, 0, -11, 20, -29, 1, -12, 47,
- -4, 39, -11, -34, -28, 9, 5, 19, 13, 34,
- }, {
- 34, -14, -4, 17, -5, 24, 26, -20, 27, 45,
- 12, -24, 2, -13, 21, 8, 22, 16, 32, 2,
- -34, -31, -20, 7, 58, -5, 5, -2, -38, 12,
- -2, 1, -1, 26, -5, 23, 21, 6, -8, -11,
- }, {
- -34, 6, 18, 55, 15, 11, 21, -16, -8, 16,
- -6, -16, -5, 4, 35, 24, 10, 12, 43, 1,
- -43, -47, -14, -8, 43, 5, -10, 34, -39, 18,
- -22, 16, 17, 42, -13, 19, -1, 3, -14, -20,
- }, {
- -5, -7, 7, 4, 9, 0, 21, -28, 6, 48,
- -2, 14, 15, -20, 5, 0, 27, 14, 32, 28,
- 5, -32, 2, -6, 32, -3, 12, 5, -8, 25,
- 14, 4, -12, -11, 4, 47, 45, 22, -22, 2,
- }, {
- -74, 12, 30, 42, 30, -14, 16, -23, -29, 19,
- -20, 21, 7, -1, 19, 17, 14, 10, 43, 27,
- -3, -48, 8, -22, 16, 7, -4, 42, -9, 31,
- -6, 20, 6, 4, -3, 43, 22, 20, -28, -5,
- }, {
- -10, -3, 4, 18, 15, -27, 24, -13, 24, 51,
- 34, -47, -12, -28, 21, 19, 27, -16, 15, -30,
- -17, -12, -12, 0, 36, -10, -7, -27, -37, 16,
- 15, 22, -3, 4, -31, -1, 42, -7, 18, 9,
- }, {
- -79, 17, 27, 56, 36, -41, 19, -8, -10, 22,
- 15, -39, -20, -9, 35, 35, 15, -20, 26, -31,
- -26, -27, -6, -15, 20, 0, -23, 8, -38, 22,
- -5, 38, 15, 20, -39, -4, 18, -9, 13, 1,
- }, {
- -50, 3, 16, 5, 30, -53, 19, -20, 3, 55,
- 19, -8, 0, -34, 5, 11, 32, -18, 15, -4,
- 22, -13, 10, -13, 9, -8, 0, -19, -7, 29,
- 31, 26, -13, -33, -21, 22, 65, 9, 4, 23,
- }, {
- -119, 24, 39, 44, 51, -66, 14, -15, -31, 26,
- 1, 0, -7, -16, 19, 28, 19, -22, 26, -4,
- 13, -28, 16, -29, -5, 1, -16, 16, -8, 35,
- 10, 42, 4, -17, -29, 19, 42, 7, 0, 15,
- }, {
- 31, -28, 6, -16, -16, 50, -31, -14, 0, 6,
- 36, 17, 0, 0, -29, -14, 11, 18, 20, -25,
- -6, -33, -19, 20, 43, 21, 21, -14, -55, 0,
- -32, -40, -42, 39, 1, -8, -14, 8, -6, -3,
- }, {
- -37, -8, 29, 22, 4, 37, -36, -9, -34, -22,
- 17, 24, -8, 18, -15, 2, -1, 14, 31, -25,
- -15, -48, -13, 4, 28, 31, 5, 21, -57, 4,
- -53, -24, -23, 55, -6, -12, -37, 6, -11, -11,
- }, {
- -7, -22, 18, -29, -1, 25, -36, -21, -20, 9,
- 22, 56, 11, -6, -45, -21, 15, 16, 20, 1,
- 33, -34, 2, 6, 17, 23, 28, -6, -25, 12,
- -16, -37, -53, 1, 11, 15, 8, 25, -20, 11,
- }, {
- -76, -1, 41, 9, 19, 12, -41, -17, -55, -18,
- 3, 63, 3, 12, -30, -5, 3, 12, 31, 0,
- 24, -49, 8, -9, 1, 33, 12, 29, -27, 18,
- -37, -21, -34, 17, 3, 11, -14, 23, -25, 2,
- }, {
- -13, -17, 15, -15, 3, -1, -33, -7, -1, 12,
- 58, -5, -15, -13, -29, -3, 16, -13, 4, -57,
- 10, -13, -11, 13, 21, 15, 9, -40, -55, 3,
- -14, -19, -44, 17, -24, -32, 5, -4, 21, 18,
- }, {
- -82, 3, 38, 23, 24, -15, -38, -2, -37, -15,
- 39, 2, -23, 4, -15, 12, 3, -17, 15, -58,
- 1, -29, -6, -2, 5, 26, -7, -4, -56, 9,
- -35, -3, -25, 33, -32, -36, -17, -7, 15, 9,
- }, {
- -52, -10, 27, -27, 18, -26, -38, -14, -23, 16,
- 44, 33, -3, -20, -45, -10, 20, -15, 3, -31,
- 50, -14, 10, 0, -5, 17, 15, -32, -24, 16,
- 1, -15, -55, -20, -14, -8, 29, 12, 7, 32,
- }, {
- -121, 9, 50, 10, 40, -40, -43, -9, -58, -12,
- 25, 41, -11, -2, -31, 5, 8, -19, 15, -32,
- 41, -30, 16, -16, -20, 28, 0, 3, -26, 22,
- -19, 0, -36, -4, -22, -12, 6, 9, 1, 24,
- }, {
- 36, -18, 24, 3, -28, 7, -16, 13, 26, 41,
- 24, -1, 5, -26, -3, -12, 27, 46, 27, -10,
- -24, -34, -10, -8, 49, 2, 34, 0, -51, -12,
- -17, -38, -25, 56, 0, 0, 22, -3, -20, -22,
- }, {
- -32, 2, 47, 42, -7, -5, -21, 18, -9, 12,
- 5, 5, -2, -8, 10, 4, 14, 42, 38, -10,
- -33, -49, -5, -24, 33, 12, 17, 35, -52, -6,
- -38, -22, -7, 72, -7, -3, 0, -6, -25, -30,
- }, {
- -2, -11, 36, -9, -13, -17, -21, 6, 5, 45,
- 10, 36, 18, -33, -19, -19, 31, 44, 27, 15,
- 16, -34, 11, -22, 22, 4, 40, 7, -21, 0,
- -1, -35, -36, 18, 10, 24, 46, 12, -34, -8,
- }, {
- -71, 9, 59, 29, 8, -30, -26, 11, -30, 16,
- -8, 44, 9, -14, -5, -2, 19, 40, 38, 15,
- 7, -50, 17, -38, 7, 14, 24, 43, -22, 6,
- -22, -19, -17, 34, 2, 20, 23, 10, -39, -16,
- }, {
- -8, -6, 33, 4, -7, -44, -18, 21, 23, 48,
- 46, -24, -9, -40, -3, -1, 32, 13, 11, -43,
- -7, -14, -3, -15, 26, -3, 21, -26, -50, -8,
- 0, -16, -27, 34, -25, -23, 43, -17, 6, -1,
- }, {
- -77, 13, 56, 43, 13, -57, -23, 26, -11, 19,
- 27, -16, -17, -22, 10, 15, 19, 10, 22, -43,
- -16, -30, 2, -31, 11, 6, 5, 9, -52, -2,
- -20, 0, -8, 50, -33, -27, 19, -19, 1, -9,
- }, {
- -47, 0, 45, -7, 7, -69, -23, 13, 2, 51,
- 32, 14, 3, -47, -19, -8, 37, 11, 10, -16,
- 32, -15, 19, -29, 0, -1, 28, -18, -20, 4,
- 16, -13, -38, -3, -15, 0, 66, 0, -7, 13,
- }, {
- -116, 20, 68, 30, 28, -83, -28, 18, -32, 22,
- 13, 21, -5, -28, -5, 7, 24, 8, 22, -17,
- 23, -30, 25, -45, -15, 9, 11, 18, -22, 10,
- -4, 2, -19, 12, -23, -3, 43, -2, -12, 4,
- }, {
- 72, -13, -29, -18, 4, 90, 37, -34, 4, -1,
- 13, -9, -6, 11, 2, 24, -13, 3, -7, -11,
- -4, 4, -42, 25, 31, -1, -8, -29, -6, 17,
- -19, 2, -10, -6, 38, 22, -42, -19, -6, -11,
- }, {
- 3, 7, -6, 20, 25, 77, 32, -29, -31, -30,
- -4, -2, -14, 29, 16, 40, -26, 0, 3, -12,
- -13, -10, -36, 9, 15, 8, -24, 6, -7, 22,
- -40, 17, 8, 9, 31, 18, -66, -22, -11, -19,
- }, {
- 32, -6, -17, -31, 19, 65, 33, -41, -16, 1,
- 0, 29, 6, 4, -13, 17, -9, 1, -8, 14,
- 35, 3, -19, 11, 4, 0, -1, -21, 23, 30,
- -3, 5, -20, -44, 48, 46, -19, -3, -20, 3,
- }, {
- -36, 13, 5, 7, 40, 51, 28, -36, -52, -27,
- -18, 36, -2, 22, 0, 33, -21, -2, 3, 13,
- 26, -11, -14, -4, -10, 10, -18, 14, 22, 36,
- -24, 21, -1, -28, 40, 42, -42, -5, -25, -5,
- }, {
- 27, -1, -20, -17, 24, 38, 35, -26, 1, 4,
- 35, -32, -21, -3, 2, 35, -8, -29, -24, -44,
- 12, 24, -34, 18, 8, -7, -21, -55, -5, 21,
- -2, 23, -11, -28, 13, -1, -22, -33, 21, 10,
- }, {
- -41, 18, 2, 21, 45, 24, 30, -21, -33, -24,
- 17, -24, -29, 15, 16, 51, -21, -33, -13, -45,
- 3, 8, -28, 2, -7, 2, -37, -19, -7, 27,
- -22, 39, 7, -12, 5, -5, -45, -35, 15, 1,
- }, {
- -12, 4, -8, -29, 39, 12, 30, -33, -19, 8,
- 21, 6, -8, -9, -13, 28, -4, -31, -24, -18,
- 52, 23, -12, 4, -18, -5, -14, -47, 24, 34,
- 14, 27, -22, -66, 22, 22, 1, -16, 6, 24,
- }, {
- -81, 25, 14, 8, 61, 0, 25, -28, -54, -20,
- 3, 14, -17, 8, 0, 44, -16, -35, -13, -18,
- 43, 7, -6, -11, -33, 4, -30, -11, 22, 40,
- -6, 43, -3, -50, 14, 18, -22, -18, 1, 16,
- }, {
- 77, -2, -11, 1, -7, 47, 52, -5, 29, 33,
- 1, -28, 0, -15, 28, 26, 2, 30, 0, 2,
- -22, 4, -33, -3, 36, -21, 3, -15, -2, 5,
- -4, 4, 6, 9, 37, 31, -5, -32, -20, -30,
- }, {
- 8, 17, 10, 40, 13, 34, 47, 0, -5, 4,
- -16, -21, -8, 2, 42, 43, -10, 26, 10, 2,
- -31, -11, -27, -19, 21, -10, -12, 20, -3, 11,
- -25, 20, 25, 25, 29, 28, -28, -34, -25, -38,
- }, {
- 37, 3, 0, -10, 7, 22, 48, -12, 8, 36,
- -12, 9, 12, -22, 12, 19, 6, 28, 0, 29,
- 18, 3, -11, -17, 10, -18, 10, -7, 27, 18,
- 11, 7, -3, -28, 47, 55, 18, -15, -34, -16,
- }, {
- -31, 24, 23, 27, 29, 9, 43, -8, -26, 7,
- -30, 17, 4, -3, 26, 35, -5, 24, 10, 28,
- 9, -12, -5, -33, -5, -8, -5, 29, 26, 24,
- -9, 23, 14, -12, 39, 52, -5, -18, -39, -24,
- }, {
- 32, 8, -3, 2, 13, -4, 50, 1, 27, 39,
- 23, -51, -15, -30, 27, 37, 7, -1, -17, -29,
- -5, 23, -25, -10, 14, -26, -8, -41, -1, 9,
- 13, 26, 5, -12, 12, 7, 14, -45, 6, -9,
- }, {
- -36, 29, 19, 41, 34, -18, 45, 6, -8, 10,
- 5, -43, -23, -11, 42, 53, -5, -5, -6, -30,
- -14, 8, -20, -26, -1, -16, -25, -4, -3, 15,
- -7, 41, 23, 3, 4, 3, -8, -48, 1, -17,
- }, {
- -7, 15, 9, -9, 28, -29, 45, -5, 6, 43,
- 9, -12, -2, -36, 12, 30, 11, -3, -17, -3,
- 34, 22, -3, -24, -12, -24, -2, -32, 28, 22,
- 29, 29, -5, -50, 21, 31, 38, -29, -7, 5,
- }, {
- -76, 35, 31, 28, 49, -43, 40, 0, -29, 14,
- -8, -5, -10, -18, 26, 46, 0, -7, -6, -3,
- 25, 7, 2, -40, -28, -14, -18, 3, 27, 28,
- 8, 45, 13, -34, 13, 27, 15, -31, -12, -3,
- }, {
- 74, -17, 0, -31, -18, 73, -5, 0, 3, -5,
- 25, 12, -3, -1, -22, 3, -9, 33, -12, -24,
- 6, 2, -33, 9, 21, 5, 20, -27, -19, -7,
- -34, -37, -34, 22, 44, 0, -41, -29, -17, -21,
- }, {
- 5, 3, 21, 7, 2, 60, -10, 5, -32, -34,
- 7, 20, -11, 16, -8, 20, -21, 29, -1, -24,
- -2, -13, -27, -6, 5, 15, 3, 8, -21, -1,
- -55, -21, -15, 38, 37, -3, -65, -32, -23, -30,
- }, {
- 35, -10, 11, -44, -3, 48, -10, -6, -17, -2,
- 11, 51, 8, -8, -38, -3, -4, 31, -12, 2,
- 46, 1, -10, -4, -5, 7, 26, -19, 10, 5,
- -18, -34, -45, -15, 54, 24, -18, -13, -31, -7,
- }, {
- -33, 10, 34, -5, 17, 35, -15, -1, -53, -30,
- -6, 59, 0, 10, -24, 13, -17, 27, -1, 1,
- 37, -13, -4, -20, -20, 18, 10, 16, 8, 11,
- -39, -18, -26, 0, 46, 20, -41, -15, -37, -15,
- }, {
- 29, -5, 7, -30, 1, 21, -7, 7, 0, 0,
- 47, -9, -18, -15, -22, 14, -4, 0, -28, -57,
- 23, 21, -25, 2, -1, 0, 7, -53, -19, -3,
- -17, -15, -36, 0, 19, -24, -21, -43, 9, 0,
- }, {
- -39, 14, 30, 8, 22, 8, -12, 12, -34, -27,
- 29, -2, -26, 2, -8, 31, -16, -3, -17, -57,
- 14, 6, -19, -13, -16, 10, -8, -17, -20, 2,
- -38, 0, -17, 16, 11, -27, -44, -45, 4, -8,
- }, {
- -9, 1, 20, -43, 17, -3, -12, 0, -20, 4,
- 33, 29, -6, -22, -38, 7, 0, -1, -29, -30,
- 63, 21, -3, -11, -27, 1, 14, -45, 10, 9,
- -1, -12, -47, -37, 28, 0, 2, -26, -4, 13,
- }, {
- -78, 21, 43, -4, 38, -17, -17, 5, -55, -24,
- 15, 36, -14, -4, -24, 24, -12, -5, -17, -31,
- 54, 5, 2, -27, -43, 12, -2, -9, 9, 15,
- -22, 3, -28, -21, 20, -3, -20, -28, -9, 5,
- }, {
- 80, -6, 16, -11, -30, 30, 9, 28, 28, 29,
- 13, -6, 2, -28, 3, 5, 7, 60, -5, -9,
- -11, 1, -24, -19, 27, -13, 32, -13, -15, -19,
- -19, -35, -17, 39, 43, 9, -4, -42, -32, -41,
- }, {
- 11, 14, 39, 27, -9, 17, 4, 33, -6, 0,
- -4, 1, -5, -10, 17, 22, -5, 57, 5, -9,
- -20, -13, -18, -35, 11, -3, 16, 22, -17, -13,
- -40, -19, 1, 55, 35, 5, -27, -44, -37, -49,
- }, {
- 40, 0, 28, -24, -14, 5, 4, 21, 7, 33,
- 0, 32, 15, -35, -12, -1, 11, 58, -5, 16,
- 28, 0, -1, -33, 0, -11, 39, -5, 14, -6,
- -3, -31, -28, 1, 53, 33, 19, -25, -46, -26,
- }, {
- -28, 20, 51, 14, 6, -7, 0, 26, -27, 4,
- -18, 40, 6, -16, 1, 15, 0, 55, 5, 16,
- 19, -14, 3, -49, -14, -1, 22, 30, 12, 0,
- -24, -15, -9, 17, 45, 29, -4, -28, -51, -35,
- }, {
- 34, 4, 25, -10, -9, -21, 7, 36, 26, 36,
- 35, -28, -12, -42, 3, 16, 12, 28, -21, -42,
- 5, 21, -16, -26, 4, -19, 19, -39, -15, -15,
- -1, -13, -19, 17, 17, -14, 15, -55, -4, -19,
- }, {
- -34, 25, 48, 28, 11, -34, 2, 41, -9, 7,
- 17, -21, -20, -24, 17, 33, 0, 24, -10, -42,
- -3, 5, -10, -42, -11, -8, 3, -3, -16, -9,
- -22, 2, 0, 33, 10, -18, -7, -58, -10, -28,
- }, {
- -4, 11, 37, -23, 5, -46, 2, 29, 5, 39,
- 21, 9, 0, -49, -12, 9, 16, 26, -22, -15,
- 45, 20, 5, -40, -22, -17, 26, -31, 14, -2,
- 14, -10, -30, -20, 27, 9, 39, -39, -18, -5,
- }, {
- -73, 32, 60, 15, 26, -59, -2, 33, -30, 10,
- 3, 17, -8, -30, 1, 26, 4, 22, -10, -16,
- 36, 5, 11, -56, -37, -6, 10, 5, 13, 3,
- -6, 5, -11, -4, 19, 5, 16, -41, -24, -13
- }
-};
-
-const uint16_t ff_cb1_base[128]={
- 19657, 18474, 18365, 17520, 21048, 18231, 18584, 16671,
- 20363, 19069, 19409, 18430, 21844, 18753, 19613, 17411,
- 20389, 21772, 20129, 21702, 20978, 20472, 19627, 19387,
- 21477, 23134, 21841, 23919, 22089, 21519, 21134, 20852,
- 19675, 17821, 19044, 17477, 19986, 16955, 18446, 16086,
- 21138, 18899, 20952, 18929, 21452, 17833, 20104, 17159,
- 19770, 20056, 20336, 20866, 19329, 18217, 18908, 18004,
- 21556, 21948, 23079, 23889, 20922, 19544, 20984, 19781,
- 19781, 20984, 19544, 20922, 23889, 23079, 21948, 21556,
- 18004, 18908, 18217, 19329, 20866, 20336, 20056, 19770,
- 17159, 20104, 17833, 21452, 18929, 20952, 18899, 21138,
- 16086, 18446, 16955, 19986, 17477, 19044, 17821, 19675,
- 20852, 21134, 21519, 22089, 23919, 21841, 23134, 21477,
- 19387, 19627, 20472, 20978, 21702, 20129, 21772, 20389,
- 17411, 19613, 18753, 21844, 18430, 19409, 19069, 20363,
- 16671, 18584, 18231, 21048, 17520, 18365, 18474, 19657,
-};
-
-const uint16_t ff_cb2_base[128]={
- 12174, 13380, 13879, 13832, 13170, 13227, 13204, 12053,
- 12410, 13988, 14348, 14631, 13100, 13415, 13224, 12268,
- 11982, 13825, 13499, 14210, 13877, 14788, 13811, 13109,
- 11449, 13275, 12833, 13717, 12728, 13696, 12759, 12405,
- 10230, 12185, 11628, 13161, 11762, 13458, 12312, 12818,
- 10443, 12773, 12011, 14020, 11818, 13825, 12453, 13226,
- 10446, 13162, 11881, 14300, 12859, 16288, 13490, 15053,
- 10155, 12820, 11519, 13973, 12041, 15081, 12635, 14198,
- 14198, 12635, 15081, 12041, 13973, 11519, 12820, 10155,
- 15053, 13490, 16288, 12859, 14300, 11881, 13162, 10446,
- 13226, 12453, 13825, 11818, 14020, 12011, 12773, 10443,
- 12818, 12312, 13458, 11762, 13161, 11628, 12185, 10230,
- 12405, 12759, 13696, 12728, 13717, 12833, 13275, 11449,
- 13109, 13811, 14788, 13877, 14210, 13499, 13825, 11982,
- 12268, 13224, 13415, 13100, 14631, 14348, 13988, 12410,
- 12053, 13204, 13227, 13170, 13832, 13879, 13380, 12174,
-};
-
-const int16_t ff_energy_tab[32]={
- 0, 16, 20, 25, 32, 41, 51, 65,
- 81, 103, 129, 163, 205, 259, 326, 410,
- 516, 650, 819, 1031, 1298, 1634, 2057, 2590,
- 3261, 4105, 5168, 6507, 8192, 10313, 12983, 16345
-};
-
-static const int16_t lpc_refl_cb1[64]={
- -4041, -4018, -3998, -3977, -3954, -3930, -3906, -3879,
- -3852, -3825, -3795, -3764, -3731, -3699, -3666, -3631,
- -3594, -3555, -3513, -3468, -3420, -3372, -3321, -3268,
- -3212, -3153, -3090, -3021, -2944, -2863, -2772, -2676,
- -2565, -2445, -2328, -2202, -2072, -1941, -1808, -1660,
- -1508, -1348, -1185, -994, -798, -600, -374, -110,
- 152, 447, 720, 982, 1229, 1456, 1682, 1916,
- 2130, 2353, 2595, 2853, 3118, 3363, 3588, 3814
-};
-
-static const int16_t lpc_refl_cb2[32]={
- -3091, -2386, -1871, -1425, -1021, -649, -316, -20,
- 267, 544, 810, 1065, 1305, 1534, 1756, 1970,
- 2171, 2359, 2536, 2700, 2854, 2996, 3133, 3263,
- 3386, 3499, 3603, 3701, 3789, 3870, 3947, 4020
-};
-
-static const int16_t lpc_refl_cb3[32]={
- -3525, -3295, -3081, -2890, -2696, -2511, -2328, -2149,
- -1979, -1817, -1658, -1498, -1341, -1188, -1032, -876,
- -721, -561, -394, -228, -54, 119, 296, 484,
- 683, 895, 1123, 1373, 1651, 1965, 2360, 2854
-};
-
-static const int16_t lpc_refl_cb4[16]={
- -1845, -1057, -522, -77, 301, 647, 975, 1285,
- 1582, 1873, 2163, 2452, 2735, 3017, 3299, 3569
-};
-
-static const int16_t lpc_refl_cb5[16]={
- -2691, -2187, -1788, -1435, -1118, -837, -571, -316,
- -59, 201, 470, 759, 1077, 1457, 1908, 2495
-};
-
-static const int16_t lpc_refl_cb6[8]={
- -1372, -474, 133, 632, 1100, 1571, 2075, 2672
-};
-
-static const int16_t lpc_refl_cb7[8]={
- -2389, -1787, -1231, -717, -239, 234, 770, 1474
-};
-
-static const int16_t lpc_refl_cb8[8]={
- -1569, -864, -296, 200, 670, 1151, 1709, 2385
-};
-
-static const int16_t lpc_refl_cb9[8]={
- -2200, -1608, -1062, -569, -120, 338, 863, 1621
-};
-
-static const int16_t lpc_refl_cb10[4]={
- -617, 190, 802, 1483
-};
-
-const int16_t * const ff_lpc_refl_cb[10]={
- lpc_refl_cb1, lpc_refl_cb2, lpc_refl_cb3, lpc_refl_cb4, lpc_refl_cb5,
- lpc_refl_cb6, lpc_refl_cb7, lpc_refl_cb8, lpc_refl_cb9, lpc_refl_cb10
-};
-
-static void ff_add_wav(int16_t *dest, int n, int skip_first, int *m, const int16_t *s1,
- const int8_t *s2, const int8_t *s3)
-{
- int i;
- int v[3];
-
- v[0] = 0;
- for (i=!skip_first; i<3; i++)
- v[i] = (ff_gain_val_tab[n][i] * m[i]) >> ff_gain_exp_tab[n];
-
- if (v[0]) {
- for (i=0; i < BLOCKSIZE; i++)
- dest[i] = (s1[i]*v[0] + s2[i]*v[1] + s3[i]*v[2]) >> 12;
- } else {
- for (i=0; i < BLOCKSIZE; i++)
- dest[i] = ( s2[i]*v[1] + s3[i]*v[2]) >> 12;
- }
-}
-
-/**
- * Copy the last offset values of *source to *target. If those values are not
- * enough to fill the target buffer, fill it with another copy of those values.
- */
-void ff_copy_and_dup(int16_t *target, const int16_t *source, int offset)
-{
- source += BUFFERSIZE - offset;
-
- memcpy(target, source, FFMIN(BLOCKSIZE, offset)*sizeof(*target));
- if (offset < BLOCKSIZE)
- memcpy(target + offset, source, (BLOCKSIZE - offset)*sizeof(*target));
-}
-
-/**
- * Evaluate the reflection coefficients from the filter coefficients.
- *
- * @return 1 if one of the reflection coefficients is greater than
- * 4095, 0 if not.
- */
-int ff_eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx)
-{
- int b, i, j;
- int buffer1[LPC_ORDER];
- int buffer2[LPC_ORDER];
- int *bp1 = buffer1;
- int *bp2 = buffer2;
-
- for (i=0; i < LPC_ORDER; i++)
- buffer2[i] = coefs[i];
-
- refl[LPC_ORDER-1] = bp2[LPC_ORDER-1];
-
- if ((unsigned) bp2[LPC_ORDER-1] + 0x1000 > 0x1fff) {
- av_log(avctx, AV_LOG_ERROR, "Overflow. Broken sample?\n");
- return 1;
- }
-
- for (i = LPC_ORDER-2; i >= 0; i--) {
- b = 0x1000-((bp2[i+1] * bp2[i+1]) >> 12);
-
- if (!b)
- b = -2;
-
- b = 0x1000000 / b;
- for (j=0; j <= i; j++) {
-#if CONFIG_FTRAPV
- int a = bp2[j] - ((refl[i+1] * bp2[i-j]) >> 12);
- if((int)(a*(unsigned)b) != a*(int64_t)b)
- return 1;
-#endif
- bp1[j] = ((bp2[j] - ((refl[i+1] * bp2[i-j]) >> 12)) * b) >> 12;
- }
-
- if ((unsigned) bp1[i] + 0x1000 > 0x1fff)
- return 1;
-
- refl[i] = bp1[i];
-
- FFSWAP(int *, bp1, bp2);
- }
- return 0;
-}
-
-/**
- * Evaluate the LPC filter coefficients from the reflection coefficients.
- * Does the inverse of the ff_eval_refl() function.
- */
-void ff_eval_coefs(int *coefs, const int *refl)
-{
- int buffer[LPC_ORDER];
- int *b1 = buffer;
- int *b2 = coefs;
- int i, j;
-
- for (i=0; i < LPC_ORDER; i++) {
- b1[i] = refl[i] << 4;
-
- for (j=0; j < i; j++)
- b1[j] = ((refl[i] * b2[i-j-1]) >> 12) + b2[j];
-
- FFSWAP(int *, b1, b2);
- }
-
- for (i=0; i < LPC_ORDER; i++)
- coefs[i] >>= 4;
-}
-
-void ff_int_to_int16(int16_t *out, const int *inp)
-{
- int i;
-
- for (i = 0; i < LPC_ORDER; i++)
- *out++ = *inp++;
-}
-
-/**
- * Evaluate sqrt(x << 24). x must fit in 20 bits. This value is evaluated in an
- * odd way to make the output identical to the binary decoder.
- */
-int ff_t_sqrt(unsigned int x)
-{
- int s = 2;
- while (x > 0xfff) {
- s++;
- x >>= 2;
- }
-
- return ff_sqrt(x << 20) << s;
-}
-
-unsigned int ff_rms(const int *data)
-{
- int i;
- unsigned int res = 0x10000;
- int b = LPC_ORDER;
-
- for (i = 0; i < LPC_ORDER; i++) {
- res = (((0x1000000 - data[i]*data[i]) >> 12) * res) >> 12;
-
- if (res == 0)
- return 0;
-
- while (res <= 0x3fff) {
- b++;
- res <<= 2;
- }
- }
-
- return ff_t_sqrt(res) >> b;
-}
-
-int ff_interp(RA144Context *ractx, int16_t *out, int a, int copyold, int energy)
-{
- int work[LPC_ORDER];
- int b = NBLOCKS - a;
- int i;
-
- // Interpolate block coefficients from the this frame's forth block and
- // last frame's forth block.
- for (i = 0; i < LPC_ORDER; i++)
- out[i] = (a * ractx->lpc_coef[0][i] + b * ractx->lpc_coef[1][i])>> 2;
-
- if (ff_eval_refl(work, out, ractx->avctx)) {
- // The interpolated coefficients are unstable, copy either new or old
- // coefficients.
- ff_int_to_int16(out, ractx->lpc_coef[copyold]);
- return ff_rescale_rms(ractx->lpc_refl_rms[copyold], energy);
- } else {
- return ff_rescale_rms(ff_rms(work), energy);
- }
-}
-
-unsigned int ff_rescale_rms(unsigned int rms, unsigned int energy)
-{
- return (rms * energy) >> 10;
-}
-
-/** inverse root mean square */
-int ff_irms(const int16_t *data)
-{
- unsigned int i, sum = 0;
-
- for (i=0; i < BLOCKSIZE; i++)
- sum += data[i] * data[i];
-
- if (sum == 0)
- return 0; /* OOPS - division by zero */
-
- return 0x20000000 / (ff_t_sqrt(sum) >> 8);
-}
-
-void ff_subblock_synthesis(RA144Context *ractx, const uint16_t *lpc_coefs,
- int cba_idx, int cb1_idx, int cb2_idx,
- int gval, int gain)
-{
- uint16_t buffer_a[BLOCKSIZE];
- uint16_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;
- } else {
- m[0] = 0;
- }
- m[1] = (ff_cb1_base[cb1_idx] * gval) >> 8;
- m[2] = (ff_cb2_base[cb2_idx] * gval) >> 8;
- memmove(ractx->adapt_cb, ractx->adapt_cb + BLOCKSIZE,
- (BUFFERSIZE - BLOCKSIZE) * sizeof(*ractx->adapt_cb));
-
- block = ractx->adapt_cb + BUFFERSIZE - BLOCKSIZE;
-
- ff_add_wav(block, gain, cba_idx, m, cba_idx? buffer_a: NULL,
- ff_cb1_vects[cb1_idx], ff_cb2_vects[cb2_idx]);
-
- memcpy(ractx->curr_sblock, ractx->curr_sblock + BLOCKSIZE,
- LPC_ORDER*sizeof(*ractx->curr_sblock));
-
- if (ff_celp_lp_synthesis_filter(ractx->curr_sblock + LPC_ORDER, lpc_coefs,
- block, BLOCKSIZE, LPC_ORDER, 1, 0, 0xfff))
- memset(ractx->curr_sblock, 0, (LPC_ORDER+BLOCKSIZE)*sizeof(*ractx->curr_sblock));
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/ra144.h b/src/thirdparty/ffmpeg/libavcodec/ra144.h
deleted file mode 100644
index 2fe1ce3a8..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/ra144.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Real Audio 1.0 (14.4K)
- * Copyright (c) 2003 the ffmpeg project
- *
- * 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_RA144_H
-#define AVCODEC_RA144_H
-
-#include <stdint.h>
-#include "lpc.h"
-#include "audio_frame_queue.h"
-
-#define NBLOCKS 4 ///< number of subblocks within a block
-#define BLOCKSIZE 40 ///< subblock size in 16-bit words
-#define BUFFERSIZE 146 ///< the size of the adaptive codebook
-#define FIXED_CB_SIZE 128 ///< size of fixed codebooks
-#define FRAMESIZE 20 ///< size of encoded frame
-#define LPC_ORDER 10 ///< order of LPC filter
-
-typedef struct RA144Context {
- AVCodecContext *avctx;
- LPCContext lpc_ctx;
- AudioFrameQueue afq;
- int last_frame;
-
- unsigned int old_energy; ///< previous frame energy
-
- unsigned int lpc_tables[2][10];
-
- /** LPC coefficients: lpc_coef[0] is the coefficients of the current frame
- * and lpc_coef[1] of the previous one. */
- unsigned int *lpc_coef[2];
-
- unsigned int lpc_refl_rms[2];
-
- int16_t curr_block[NBLOCKS * BLOCKSIZE];
-
- /** The current subblock padded by the last 10 values of the previous one. */
- int16_t curr_sblock[50];
-
- /** Adaptive codebook, its size is two units bigger to avoid a
- * buffer overflow. */
- uint16_t adapt_cb[146+2];
-} RA144Context;
-
-void ff_copy_and_dup(int16_t *target, const int16_t *source, int offset);
-int ff_eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx);
-void ff_eval_coefs(int *coefs, const int *refl);
-void ff_int_to_int16(int16_t *out, const int *inp);
-int ff_t_sqrt(unsigned int x);
-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);
-void ff_subblock_synthesis(RA144Context *ractx, const uint16_t *lpc_coefs,
- int cba_idx, int cb1_idx, int cb2_idx,
- int gval, int gain);
-
-extern const int16_t ff_gain_val_tab[256][3];
-extern const uint8_t ff_gain_exp_tab[256];
-extern const int8_t ff_cb1_vects[128][40];
-extern const int8_t ff_cb2_vects[128][40];
-extern const uint16_t ff_cb1_base[128];
-extern const uint16_t ff_cb2_base[128];
-extern const int16_t ff_energy_tab[32];
-extern const int16_t * const ff_lpc_refl_cb[10];
-
-#endif /* AVCODEC_RA144_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/ra144dec.c b/src/thirdparty/ffmpeg/libavcodec/ra144dec.c
deleted file mode 100644
index daeb9c4d2..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/ra144dec.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Real Audio 1.0 (14.4K)
- *
- * Copyright (c) 2008 Vitor Sessak
- * Copyright (c) 2003 Nick Kurshev
- * Based on public domain decoder at http://www.honeypot.net/audio
- *
- * 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/intmath.h"
-#include "avcodec.h"
-#include "get_bits.h"
-#include "internal.h"
-#include "ra144.h"
-
-
-static av_cold int ra144_decode_init(AVCodecContext * avctx)
-{
- RA144Context *ractx = avctx->priv_data;
-
- ractx->avctx = avctx;
-
- ractx->lpc_coef[0] = ractx->lpc_tables[0];
- ractx->lpc_coef[1] = ractx->lpc_tables[1];
-
- avctx->channels = 1;
- avctx->channel_layout = AV_CH_LAYOUT_MONO;
- avctx->sample_fmt = AV_SAMPLE_FMT_S16;
-
- return 0;
-}
-
-static void do_output_subblock(RA144Context *ractx, const uint16_t *lpc_coefs,
- int gval, GetBitContext *gb)
-{
- int cba_idx = get_bits(gb, 7); // index of the adaptive CB, 0 if none
- int gain = get_bits(gb, 8);
- int cb1_idx = get_bits(gb, 7);
- int cb2_idx = get_bits(gb, 7);
-
- ff_subblock_synthesis(ractx, lpc_coefs, cba_idx, cb1_idx, cb2_idx, gval,
- gain);
-}
-
-/** Uncompress one block (20 bytes -> 160*2 bytes). */
-static int ra144_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;
- static const uint8_t sizes[LPC_ORDER] = {6, 5, 5, 4, 4, 3, 3, 3, 3, 2};
- unsigned int refl_rms[NBLOCKS]; // RMS of the reflection coefficients
- uint16_t block_coefs[NBLOCKS][LPC_ORDER]; // LPC coefficients of each sub-block
- unsigned int lpc_refl[LPC_ORDER]; // LPC reflection coefficients of the frame
- int i, j;
- int ret;
- int16_t *samples;
- unsigned int energy;
-
- RA144Context *ractx = avctx->priv_data;
- GetBitContext gb;
-
- /* get output buffer */
- frame->nb_samples = NBLOCKS * BLOCKSIZE;
- if ((ret = ff_get_buffer(avctx, frame)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return ret;
- }
- samples = (int16_t *)frame->data[0];
-
- if(buf_size < FRAMESIZE) {
- av_log(avctx, AV_LOG_ERROR,
- "Frame too small (%d bytes). Truncated file?\n", buf_size);
- *got_frame_ptr = 0;
- return buf_size;
- }
- init_get_bits(&gb, buf, FRAMESIZE * 8);
-
- for (i = 0; i < LPC_ORDER; i++)
- lpc_refl[i] = ff_lpc_refl_cb[i][get_bits(&gb, sizes[i])];
-
- ff_eval_coefs(ractx->lpc_coef[0], lpc_refl);
- ractx->lpc_refl_rms[0] = ff_rms(lpc_refl);
-
- energy = ff_energy_tab[get_bits(&gb, 5)];
-
- refl_rms[0] = ff_interp(ractx, block_coefs[0], 1, 1, ractx->old_energy);
- refl_rms[1] = ff_interp(ractx, block_coefs[1], 2,
- energy <= ractx->old_energy,
- ff_t_sqrt(energy*ractx->old_energy) >> 12);
- refl_rms[2] = ff_interp(ractx, block_coefs[2], 3, 0, energy);
- refl_rms[3] = ff_rescale_rms(ractx->lpc_refl_rms[0], energy);
-
- ff_int_to_int16(block_coefs[3], ractx->lpc_coef[0]);
-
- for (i=0; i < NBLOCKS; i++) {
- do_output_subblock(ractx, block_coefs[i], refl_rms[i], &gb);
-
- for (j=0; j < BLOCKSIZE; j++)
- *samples++ = av_clip_int16(ractx->curr_sblock[j + 10] << 2);
- }
-
- ractx->old_energy = energy;
- ractx->lpc_refl_rms[1] = ractx->lpc_refl_rms[0];
-
- FFSWAP(unsigned int *, ractx->lpc_coef[0], ractx->lpc_coef[1]);
-
- *got_frame_ptr = 1;
-
- return FRAMESIZE;
-}
-
-AVCodec ff_ra_144_decoder = {
- .name = "real_144",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_RA_144,
- .priv_data_size = sizeof(RA144Context),
- .init = ra144_decode_init,
- .decode = ra144_decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K)"),
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/ra288.c b/src/thirdparty/ffmpeg/libavcodec/ra288.c
deleted file mode 100644
index ab28cc0d2..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/ra288.c
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * RealAudio 2.0 (28.8K)
- * Copyright (c) 2003 the ffmpeg project
- *
- * 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 "libavutil/internal.h"
-#include "avcodec.h"
-#include "internal.h"
-#define BITSTREAM_READER_LE
-#include "get_bits.h"
-#include "ra288.h"
-#include "lpc.h"
-#include "celp_filters.h"
-
-#define MAX_BACKWARD_FILTER_ORDER 36
-#define MAX_BACKWARD_FILTER_LEN 40
-#define MAX_BACKWARD_FILTER_NONREC 35
-
-#define RA288_BLOCK_SIZE 5
-#define RA288_BLOCKS_PER_FRAME 32
-
-typedef struct {
- AVFloatDSPContext fdsp;
- DECLARE_ALIGNED(32, float, sp_lpc)[FFALIGN(36, 16)]; ///< LPC coefficients for speech data (spec: A)
- DECLARE_ALIGNED(32, float, gain_lpc)[FFALIGN(10, 16)]; ///< LPC coefficients for gain (spec: GB)
-
- /** speech data history (spec: SB).
- * Its first 70 coefficients are updated only at backward filtering.
- */
- float sp_hist[111];
-
- /// speech part of the gain autocorrelation (spec: REXP)
- float sp_rec[37];
-
- /** log-gain history (spec: SBLG).
- * Its first 28 coefficients are updated only at backward filtering.
- */
- float gain_hist[38];
-
- /// recursive part of the gain autocorrelation (spec: REXPLG)
- float gain_rec[11];
-} RA288Context;
-
-static av_cold int ra288_decode_init(AVCodecContext *avctx)
-{
- RA288Context *ractx = avctx->priv_data;
-
- avctx->channels = 1;
- avctx->channel_layout = AV_CH_LAYOUT_MONO;
- avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
-
- if (avctx->block_align <= 0) {
- av_log_ask_for_sample(avctx, "unsupported block align\n");
- return AVERROR_PATCHWELCOME;
- }
-
- avpriv_float_dsp_init(&ractx->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
-
- return 0;
-}
-
-static void convolve(float *tgt, const float *src, int len, int n)
-{
- for (; n >= 0; n--)
- tgt[n] = avpriv_scalarproduct_float_c(src, src - n, len);
-
-}
-
-static void decode(RA288Context *ractx, float gain, int cb_coef)
-{
- int i;
- double sumsum;
- float sum, buffer[5];
- float *block = ractx->sp_hist + 70 + 36; // current block
- float *gain_block = ractx->gain_hist + 28;
-
- memmove(ractx->sp_hist + 70, ractx->sp_hist + 75, 36*sizeof(*block));
-
- /* block 46 of G.728 spec */
- sum = 32.;
- for (i=0; i < 10; i++)
- sum -= gain_block[9-i] * ractx->gain_lpc[i];
-
- /* block 47 of G.728 spec */
- sum = av_clipf(sum, 0, 60);
-
- /* block 48 of G.728 spec */
- /* exp(sum * 0.1151292546497) == pow(10.0,sum/20) */
- sumsum = exp(sum * 0.1151292546497) * gain * (1.0/(1<<23));
-
- for (i=0; i < 5; i++)
- buffer[i] = codetable[cb_coef][i] * sumsum;
-
- sum = avpriv_scalarproduct_float_c(buffer, buffer, 5);
-
- sum = FFMAX(sum, 5. / (1<<24));
-
- /* shift and store */
- memmove(gain_block, gain_block + 1, 9 * sizeof(*gain_block));
-
- gain_block[9] = 10 * log10(sum) + (10*log10(((1<<24)/5.)) - 32);
-
- ff_celp_lp_synthesis_filterf(block, ractx->sp_lpc, buffer, 5, 36);
-}
-
-/**
- * Hybrid window filtering, see blocks 36 and 49 of the G.728 specification.
- *
- * @param order filter order
- * @param n input length
- * @param non_rec number of non-recursive samples
- * @param out filter output
- * @param hist pointer to the input history of the filter
- * @param out pointer to the non-recursive part of the output
- * @param out2 pointer to the recursive part of the output
- * @param window pointer to the windowing function table
- */
-static void do_hybrid_window(RA288Context *ractx,
- int order, int n, int non_rec, float *out,
- float *hist, float *out2, const float *window)
-{
- int i;
- float buffer1[MAX_BACKWARD_FILTER_ORDER + 1];
- float buffer2[MAX_BACKWARD_FILTER_ORDER + 1];
- LOCAL_ALIGNED(32, float, work, [FFALIGN(MAX_BACKWARD_FILTER_ORDER +
- MAX_BACKWARD_FILTER_LEN +
- MAX_BACKWARD_FILTER_NONREC, 16)]);
-
- av_assert2(order>=0);
-
- ractx->fdsp.vector_fmul(work, window, hist, FFALIGN(order + n + non_rec, 16));
-
- convolve(buffer1, work + order , n , order);
- convolve(buffer2, work + order + n, non_rec, order);
-
- for (i=0; i <= order; i++) {
- out2[i] = out2[i] * 0.5625 + buffer1[i];
- out [i] = out2[i] + buffer2[i];
- }
-
- /* Multiply by the white noise correcting factor (WNCF). */
- *out *= 257./256.;
-}
-
-/**
- * Backward synthesis filter, find the LPC coefficients from past speech data.
- */
-static void backward_filter(RA288Context *ractx,
- float *hist, float *rec, const float *window,
- float *lpc, const float *tab,
- int order, int n, int non_rec, int move_size)
-{
- float temp[MAX_BACKWARD_FILTER_ORDER+1];
-
- do_hybrid_window(ractx, order, n, non_rec, temp, hist, rec, window);
-
- if (!compute_lpc_coefs(temp, order, lpc, 0, 1, 1))
- ractx->fdsp.vector_fmul(lpc, lpc, tab, FFALIGN(order, 16));
-
- memmove(hist, hist + n, move_size*sizeof(*hist));
-}
-
-static int ra288_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;
- float *out;
- int i, ret;
- RA288Context *ractx = avctx->priv_data;
- GetBitContext gb;
-
- if (buf_size < avctx->block_align) {
- av_log(avctx, AV_LOG_ERROR,
- "Error! Input buffer is too small [%d<%d]\n",
- buf_size, avctx->block_align);
- return AVERROR_INVALIDDATA;
- }
-
- /* get output buffer */
- frame->nb_samples = RA288_BLOCK_SIZE * RA288_BLOCKS_PER_FRAME;
- if ((ret = ff_get_buffer(avctx, frame)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return ret;
- }
- out = (float *)frame->data[0];
-
- init_get_bits(&gb, buf, avctx->block_align * 8);
-
- for (i=0; i < RA288_BLOCKS_PER_FRAME; i++) {
- float gain = amptable[get_bits(&gb, 3)];
- int cb_coef = get_bits(&gb, 6 + (i&1));
-
- decode(ractx, gain, cb_coef);
-
- memcpy(out, &ractx->sp_hist[70 + 36], RA288_BLOCK_SIZE * sizeof(*out));
- out += RA288_BLOCK_SIZE;
-
- if ((i & 7) == 3) {
- backward_filter(ractx, ractx->sp_hist, ractx->sp_rec, syn_window,
- ractx->sp_lpc, syn_bw_tab, 36, 40, 35, 70);
-
- backward_filter(ractx, ractx->gain_hist, ractx->gain_rec, gain_window,
- ractx->gain_lpc, gain_bw_tab, 10, 8, 20, 28);
- }
- }
-
- *got_frame_ptr = 1;
-
- return avctx->block_align;
-}
-
-AVCodec ff_ra_288_decoder = {
- .name = "real_288",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_RA_288,
- .priv_data_size = sizeof(RA288Context),
- .init = ra288_decode_init,
- .decode = ra288_decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("RealAudio 2.0 (28.8K)"),
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/ra288.h b/src/thirdparty/ffmpeg/libavcodec/ra288.h
deleted file mode 100644
index 0682686e0..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/ra288.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * RealAudio 2.0 (28.8K)
- * Copyright (c) 2003 the ffmpeg project
- *
- * 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_RA288_H
-#define AVCODEC_RA288_H
-
-#include <stdint.h>
-#include "dsputil.h"
-#include "libavutil/common.h"
-
-static const float amptable[8]={
- 0.515625, 0.90234375, 1.57910156, 2.76342773,
- -0.515625, -0.90234375, -1.57910156, -2.76342773
-};
-
-static const int16_t codetable[128][5]={
- { 668, -2950, -1254, -1790, -2553}, { -5032, -4577, -1045, 2908, 3318},
- { -2819, -2677, -948, -2825, -4450}, { -6679, -340, 1482, -1276, 1262},
- { -562, -6757, 1281, 179, -1274}, { -2512, -7130, -4925, 6913, 2411},
- { -2478, -156, 4683, -3873, 0}, { -8208, 2140, -478, -2785, 533},
- { 1889, 2759, 1381, -6955, -5913}, { 5082, -2460, -5778, 1797, 568},
- { -2208, -3309, -4523, -6236, -7505}, { -2719, 4358, -2988, -1149, 2664},
- { 1259, 995, 2711, -2464,-10390}, { 1722, -7569, -2742, 2171, -2329},
- { 1032, 747, -858, -7946,-12843}, { 3106, 4856, -4193, -2541, 1035},
- { 1862, -960, -6628, 410, 5882}, { -2493, -2628, -4000, -60, 7202},
- { -2672, 1446, 1536, -3831, 1233}, { -5302, 6912, 1589, -4187, 3665},
- { -3456, -8170, -7709, 1384, 4698}, { -4699, -6209,-11176, 8104, 16830},
- { 930, 7004, 1269, -8977, 2567}, { 4649, 11804, 3441, -5657, 1199},
- { 2542, -183, -8859, -7976, 3230}, { -2872, -2011, -9713, -8385, 12983},
- { 3086, 2140, -3680, -9643, -2896}, { -7609, 6515, -2283, -2522, 6332},
- { -3333, -5620, -9130,-11131, 5543}, { -407, -6721,-17466, -2889, 11568},
- { 3692, 6796, -262,-10846, -1856}, { 7275, 13404, -2989,-10595, 4936},
- { 244, -2219, 2656, 3776, -5412}, { -4043, -5934, 2131, 863, -2866},
- { -3302, 1743, -2006, -128, -2052}, { -6361, 3342, -1583, -21, 1142},
- { -3837, -1831, 6397, 2545, -2848}, { -9332, -6528, 5309, 1986, -2245},
- { -4490, 748, 1935, -3027, -493}, { -9255, 5366, 3193, -4493, 1784},
- { 4784, -370, 1866, 1057, -1889}, { 7342, -2690, -2577, 676, -611},
- { -502, 2235, -1850, -1777, -2049}, { 1011, 3880, -2465, 2209, -152},
- { 2592, 2829, 5588, 2839, -7306}, { -3049, -4918, 5955, 9201, -4447},
- { 697, 3908, 5798, -4451, -4644}, { -2121, 5444, -2570, 321, -1202},
- { 2846, -2086, 3532, 566, -708}, { -4279, 950, 4980, 3749, 452},
- { -2484, 3502, 1719, -170, 238}, { -3435, 263, 2114, -2005, 2361},
- { -7338, -1208, 9347, -1216, -4013}, {-13498, -439, 8028, -4232, 361},
- { -3729, 5433, 2004, -4727, -1259}, { -3986, 7743, 8429, -3691, -987},
- { 5198, -423, 1150, -1281, 816}, { 7409, 4109, -3949, 2690, 30},
- { 1246, 3055, -35, -1370, -246}, { -1489, 5635, -678, -2627, 3170},
- { 4830, -4585, 2008, -1062, 799}, { -129, 717, 4594, 14937, 10706},
- { 417, 2759, 1850, -5057, -1153}, { -3887, 7361, -5768, 4285, 666},
- { 1443, -938, 20, -2119, -1697}, { -3712, -3402, -2212, 110, 2136},
- { -2952, 12, -1568, -3500, -1855}, { -1315, -1731, 1160, -558, 1709},
- { 88, -4569, 194, -454, -2957}, { -2839, -1666, -273, 2084, -155},
- { -189, -2376, 1663, -1040, -2449}, { -2842, -1369, 636, -248, -2677},
- { 1517, 79, -3013, -3669, -973}, { 1913, -2493, -5312, -749, 1271},
- { -2903, -3324, -3756, -3690, -1829}, { -2913, -1547, -2760, -1406, 1124},
- { 1844, -1834, 456, 706, -4272}, { 467, -4256, -1909, 1521, 1134},
- { -127, -994, -637, -1491, -6494}, { 873, -2045, -3828, -2792, -578},
- { 2311, -1817, 2632, -3052, 1968}, { 641, 1194, 1893, 4107, 6342},
- { -45, 1198, 2160, -1449, 2203}, { -2004, 1713, 3518, 2652, 4251},
- { 2936, -3968, 1280, 131, -1476}, { 2827, 8, -1928, 2658, 3513},
- { 3199, -816, 2687, -1741, -1407}, { 2948, 4029, 394, -253, 1298},
- { 4286, 51, -4507, -32, -659}, { 3903, 5646, -5588, -2592, 5707},
- { -606, 1234, -1607, -5187, 664}, { -525, 3620, -2192, -2527, 1707},
- { 4297, -3251, -2283, 812, -2264}, { 5765, 528, -3287, 1352, 1672},
- { 2735, 1241, -1103, -3273, -3407}, { 4033, 1648, -2965, -1174, 1444},
- { 74, 918, 1999, 915, -1026}, { -2496, -1605, 2034, 2950, 229},
- { -2168, 2037, 15, -1264, -208}, { -3552, 1530, 581, 1491, 962},
- { -2613, -2338, 3621, -1488, -2185}, { -1747, 81, 5538, 1432, -2257},
- { -1019, 867, 214, -2284, -1510}, { -1684, 2816, -229, 2551, -1389},
- { 2707, 504, 479, 2783, -1009}, { 2517, -1487, -1596, 621, 1929},
- { -148, 2206, -4288, 1292, -1401}, { -527, 1243, -2731, 1909, 1280},
- { 2149, -1501, 3688, 610, -4591}, { 3306, -3369, 1875, 3636, -1217},
- { 2574, 2513, 1449, -3074, -4979}, { 814, 1826, -2497, 4234, -4077},
- { 1664, -220, 3418, 1002, 1115}, { 781, 1658, 3919, 6130, 3140},
- { 1148, 4065, 1516, 815, 199}, { 1191, 2489, 2561, 2421, 2443},
- { 770, -5915, 5515, -368, -3199}, { 1190, 1047, 3742, 6927, -2089},
- { 292, 3099, 4308, -758, -2455}, { 523, 3921, 4044, 1386, 85},
- { 4367, 1006, -1252, -1466, -1383}, { 3852, 1579, -77, 2064, 868},
- { 5109, 2919, -202, 359, -509}, { 3650, 3206, 2303, 1693, 1296},
- { 2905, -3907, 229, -1196, -2332}, { 5977, -3585, 805, 3825, -3138},
- { 3746, -606, 53, -269, -3301}, { 606, 2018, -1316, 4064, 398}
-};
-
-DECLARE_ALIGNED(32, static const float, syn_window)[FFALIGN(111, 16)]={
- 0.576690972, 0.580838025, 0.585013986, 0.589219987, 0.59345597, 0.597723007,
- 0.602020264, 0.606384277, 0.610748291, 0.615142822, 0.619598389, 0.624084473,
- 0.628570557, 0.633117676, 0.637695313, 0.642272949, 0.646911621, 0.651580811,
- 0.656280518, 0.66104126, 0.665802002, 0.670593262, 0.675445557, 0.680328369,
- 0.685241699, 0.690185547, 0.695159912, 0.700164795, 0.705230713, 0.710327148,
- 0.715454102, 0.720611572, 0.725830078, 0.731048584, 0.736328125, 0.741638184,
- 0.747009277, 0.752380371, 0.7578125, 0.763305664, 0.768798828, 0.774353027,
- 0.779937744, 0.785583496, 0.791229248, 0.796936035, 0.802703857, 0.808502197,
- 0.814331055, 0.820220947, 0.826141357, 0.832092285, 0.838104248, 0.844146729,
- 0.850250244, 0.856384277, 0.862548828, 0.868774414, 0.875061035, 0.881378174,
- 0.88772583, 0.894134521, 0.900604248, 0.907104492, 0.913635254, 0.920227051,
- 0.926879883, 0.933563232, 0.940307617, 0.94708252, 0.953918457, 0.96081543,
- 0.96774292, 0.974731445, 0.981781006, 0.988861084, 0.994842529, 0.998565674,
- 0.999969482, 0.99911499, 0.996002197, 0.990600586, 0.982910156, 0.973022461,
- 0.960876465, 0.946533203, 0.930053711, 0.911437988, 0.89074707, 0.868041992,
- 0.843322754, 0.816680908, 0.788208008, 0.757904053, 0.725891113, 0.692199707,
- 0.656921387, 0.620178223, 0.582000732, 0.542480469, 0.501739502, 0.459838867,
- 0.416900635, 0.373016357, 0.328277588, 0.282775879, 0.236663818, 0.189971924,
- 0.142852783, 0.0954284668,0.0477600098
-};
-
-DECLARE_ALIGNED(32, static const float, gain_window)[FFALIGN(38, 16)]={
- 0.505699992, 0.524200022, 0.54339999, 0.563300014, 0.583953857, 0.60534668,
- 0.627502441, 0.650482178, 0.674316406, 0.699005127, 0.724578857, 0.75112915,
- 0.778625488, 0.807128906, 0.836669922, 0.86730957, 0.899078369, 0.932006836,
- 0.961486816, 0.982757568, 0.995635986, 1, 0.995819092, 0.983154297,
- 0.96206665, 0.932769775, 0.895507813, 0.850585938, 0.798400879, 0.739379883,
- 0.674072266, 0.602996826, 0.526763916, 0.446014404, 0.361480713, 0.273834229,
- 0.183868408, 0.0923461914
-};
-
-/** synthesis bandwidth broadening table */
-DECLARE_ALIGNED(32, static const float, syn_bw_tab)[FFALIGN(36, 16)] = {
- 0.98828125, 0.976699829, 0.965254128, 0.953942537, 0.942763507, 0.931715488,
- 0.920796931, 0.910006344, 0.899342179, 0.888803005, 0.878387332, 0.868093729,
- 0.857920766, 0.847867012, 0.837931097, 0.828111589, 0.818407178, 0.808816493,
- 0.799338162, 0.789970934, 0.780713439, 0.771564424, 0.762522638, 0.753586829,
- 0.744755745, 0.736028135, 0.727402806, 0.718878567, 0.710454226, 0.702128589,
- 0.693900526, 0.685768902, 0.677732527, 0.669790328, 0.66194123, 0.654184103
-};
-
-/** gain bandwidth broadening table */
-DECLARE_ALIGNED(32, static const float, gain_bw_tab)[FFALIGN(10, 16)] = {
- 0.90625, 0.821289063, 0.74432373, 0.674499512, 0.61126709,
- 0.553955078, 0.50201416, 0.454956055, 0.41229248, 0.373657227
-};
-
-#endif /* AVCODEC_RA288_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/rangecoder.h b/src/thirdparty/ffmpeg/libavcodec/rangecoder.h
deleted file mode 100644
index fd4d3f702..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/rangecoder.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Range coder
- * Copyright (c) 2004 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
- * Range coder.
- */
-
-#ifndef AVCODEC_RANGECODER_H
-#define AVCODEC_RANGECODER_H
-
-#include <stdint.h>
-
-#include "libavutil/common.h"
-#include "libavutil/avassert.h"
-
-typedef struct RangeCoder {
- int low;
- int range;
- int outstanding_count;
- int outstanding_byte;
- uint8_t zero_state[256];
- uint8_t one_state[256];
- uint8_t *bytestream_start;
- uint8_t *bytestream;
- uint8_t *bytestream_end;
-} RangeCoder;
-
-void ff_init_range_encoder(RangeCoder *c, uint8_t *buf, int buf_size);
-void ff_init_range_decoder(RangeCoder *c, const uint8_t *buf, int buf_size);
-int ff_rac_terminate(RangeCoder *c);
-void ff_build_rac_states(RangeCoder *c, int factor, int max_p);
-
-static inline void renorm_encoder(RangeCoder *c)
-{
- // FIXME: optimize
- while (c->range < 0x100) {
- if (c->outstanding_byte < 0) {
- c->outstanding_byte = c->low >> 8;
- } else if (c->low <= 0xFF00) {
- *c->bytestream++ = c->outstanding_byte;
- for (; c->outstanding_count; c->outstanding_count--)
- *c->bytestream++ = 0xFF;
- c->outstanding_byte = c->low >> 8;
- } else if (c->low >= 0x10000) {
- *c->bytestream++ = c->outstanding_byte + 1;
- for (; c->outstanding_count; c->outstanding_count--)
- *c->bytestream++ = 0x00;
- c->outstanding_byte = (c->low >> 8) & 0xFF;
- } else {
- c->outstanding_count++;
- }
-
- c->low = (c->low & 0xFF) << 8;
- c->range <<= 8;
- }
-}
-
-static inline int get_rac_count(RangeCoder *c)
-{
- int x = c->bytestream - c->bytestream_start + c->outstanding_count;
- if (c->outstanding_byte >= 0)
- x++;
- return 8 * x - av_log2(c->range);
-}
-
-static inline void put_rac(RangeCoder *c, uint8_t *const state, int bit)
-{
- int range1 = (c->range * (*state)) >> 8;
-
- av_assert2(*state);
- av_assert2(range1 < c->range);
- av_assert2(range1 > 0);
- if (!bit) {
- c->range -= range1;
- *state = c->zero_state[*state];
- } else {
- c->low += c->range - range1;
- c->range = range1;
- *state = c->one_state[*state];
- }
-
- renorm_encoder(c);
-}
-
-static inline void refill(RangeCoder *c)
-{
- if (c->range < 0x100) {
- c->range <<= 8;
- c->low <<= 8;
- if (c->bytestream < c->bytestream_end)
- c->low += c->bytestream[0];
- c->bytestream++;
- }
-}
-
-static inline int get_rac(RangeCoder *c, uint8_t *const state)
-{
- int range1 = (c->range * (*state)) >> 8;
- int av_unused one_mask;
-
- c->range -= range1;
-#if 1
- if (c->low < c->range) {
- *state = c->zero_state[*state];
- refill(c);
- return 0;
- } else {
- c->low -= c->range;
- *state = c->one_state[*state];
- c->range = range1;
- refill(c);
- return 1;
- }
-#else
- one_mask = (c->range - c->low - 1) >> 31;
-
- c->low -= c->range & one_mask;
- c->range += (range1 - c->range) & one_mask;
-
- *state = c->zero_state[(*state) + (256 & one_mask)];
-
- refill(c);
-
- return one_mask & 1;
-#endif
-}
-
-#endif /* AVCODEC_RANGECODER_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/ratecontrol.h b/src/thirdparty/ffmpeg/libavcodec/ratecontrol.h
deleted file mode 100644
index 234790c73..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/ratecontrol.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Ratecontrol
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
- * Copyright (c) 2002-2004 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
- */
-
-#ifndef AVCODEC_RATECONTROL_H
-#define AVCODEC_RATECONTROL_H
-
-/**
- * @file
- * ratecontrol header.
- */
-
-#include <stdio.h>
-#include <stdint.h>
-#include "libavutil/eval.h"
-
-typedef struct Predictor{
- double coeff;
- double count;
- double decay;
-} Predictor;
-
-typedef struct RateControlEntry{
- int pict_type;
- float qscale;
- int mv_bits;
- int i_tex_bits;
- int p_tex_bits;
- int misc_bits;
- int header_bits;
- uint64_t expected_bits;
- int new_pict_type;
- float new_qscale;
- int mc_mb_var_sum;
- int mb_var_sum;
- int i_count;
- int skip_count;
- int f_code;
- int b_code;
-}RateControlEntry;
-
-/**
- * rate control context.
- */
-typedef struct RateControlContext{
- FILE *stats_file;
- int num_entries; ///< number of RateControlEntries
- RateControlEntry *entry;
- double buffer_index; ///< amount of bits in the video/audio buffer
- Predictor pred[5];
- double short_term_qsum; ///< sum of recent qscales
- double short_term_qcount; ///< count of recent qscales
- double pass1_rc_eq_output_sum;///< sum of the output of the rc equation, this is used for normalization
- 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;
- uint64_t i_cplx_sum[5];
- uint64_t p_cplx_sum[5];
- uint64_t mv_bits_sum[5];
- uint64_t qscale_sum[5];
- int frame_count[5];
- int last_non_b_pict_type;
-
- void *non_lavc_opaque; ///< context for non lavc rc code (for example xvid)
- float dry_run_qscale; ///< for xvid rc
- int last_picture_number; ///< for xvid rc
- AVExpr * rc_eq_eval;
-}RateControlContext;
-
-struct MpegEncContext;
-
-/* rate control */
-int ff_rate_control_init(struct MpegEncContext *s);
-float ff_rate_estimate_qscale(struct MpegEncContext *s, int dry_run);
-void ff_write_pass1_stats(struct MpegEncContext *s);
-void ff_rate_control_uninit(struct MpegEncContext *s);
-int ff_vbv_update(struct MpegEncContext *s, int frame_size);
-void ff_get_2pass_fcode(struct MpegEncContext *s);
-
-int ff_xvid_rate_control_init(struct MpegEncContext *s);
-void ff_xvid_rate_control_uninit(struct MpegEncContext *s);
-float ff_xvid_rate_estimate_qscale(struct MpegEncContext *s, int dry_run);
-
-#endif /* AVCODEC_RATECONTROL_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/rdft.c b/src/thirdparty/ffmpeg/libavcodec/rdft.c
deleted file mode 100644
index bd4b25bb6..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/rdft.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * (I)RDFT transforms
- * Copyright (c) 2009 Alex Converse <alex dot converse at gmail dot 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 <stdlib.h>
-#include <math.h>
-#include "libavutil/mathematics.h"
-#include "rdft.h"
-
-/**
- * @file
- * (Inverse) Real Discrete Fourier Transforms.
- */
-
-/* sin(2*pi*x/n) for 0<=x<n/4, followed by n/2<=x<3n/4 */
-#if !CONFIG_HARDCODED_TABLES
-SINTABLE(16);
-SINTABLE(32);
-SINTABLE(64);
-SINTABLE(128);
-SINTABLE(256);
-SINTABLE(512);
-SINTABLE(1024);
-SINTABLE(2048);
-SINTABLE(4096);
-SINTABLE(8192);
-SINTABLE(16384);
-SINTABLE(32768);
-SINTABLE(65536);
-#endif
-static SINTABLE_CONST FFTSample * const ff_sin_tabs[] = {
- NULL, NULL, NULL, NULL,
- ff_sin_16, ff_sin_32, ff_sin_64, ff_sin_128, ff_sin_256, ff_sin_512, ff_sin_1024,
- ff_sin_2048, ff_sin_4096, ff_sin_8192, ff_sin_16384, ff_sin_32768, ff_sin_65536,
-};
-
-/** Map one real FFT into two parallel real even and odd FFTs. Then interleave
- * the two real FFTs into one complex FFT. Unmangle the results.
- * ref: http://www.engineeringproductivitytools.com/stuff/T0001/PT10.HTM
- */
-static void ff_rdft_calc_c(RDFTContext* s, FFTSample* data)
-{
- int i, i1, i2;
- FFTComplex ev, od;
- const int n = 1 << s->nbits;
- const float k1 = 0.5;
- const float k2 = 0.5 - s->inverse;
- const FFTSample *tcos = s->tcos;
- const FFTSample *tsin = s->tsin;
-
- if (!s->inverse) {
- s->fft.fft_permute(&s->fft, (FFTComplex*)data);
- s->fft.fft_calc(&s->fft, (FFTComplex*)data);
- }
- /* i=0 is a special case because of packing, the DC term is real, so we
- are going to throw the N/2 term (also real) in with it. */
- ev.re = data[0];
- data[0] = ev.re+data[1];
- data[1] = ev.re-data[1];
- for (i = 1; i < (n>>2); i++) {
- i1 = 2*i;
- i2 = n-i1;
- /* Separate even and odd FFTs */
- ev.re = k1*(data[i1 ]+data[i2 ]);
- od.im = -k2*(data[i1 ]-data[i2 ]);
- ev.im = k1*(data[i1+1]-data[i2+1]);
- od.re = k2*(data[i1+1]+data[i2+1]);
- /* Apply twiddle factors to the odd FFT and add to the even FFT */
- data[i1 ] = ev.re + od.re*tcos[i] - od.im*tsin[i];
- data[i1+1] = ev.im + od.im*tcos[i] + od.re*tsin[i];
- data[i2 ] = ev.re - od.re*tcos[i] + od.im*tsin[i];
- data[i2+1] = -ev.im + od.im*tcos[i] + od.re*tsin[i];
- }
- data[2*i+1]=s->sign_convention*data[2*i+1];
- if (s->inverse) {
- data[0] *= k1;
- data[1] *= k1;
- s->fft.fft_permute(&s->fft, (FFTComplex*)data);
- s->fft.fft_calc(&s->fft, (FFTComplex*)data);
- }
-}
-
-av_cold int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans)
-{
- int n = 1 << nbits;
- int i;
- const double theta = (trans == DFT_R2C || trans == DFT_C2R ? -1 : 1)*2*M_PI/n;
-
- s->nbits = nbits;
- s->inverse = trans == IDFT_C2R || trans == DFT_C2R;
- s->sign_convention = trans == IDFT_R2C || trans == DFT_C2R ? 1 : -1;
-
- if (nbits < 4 || nbits > 16)
- return -1;
-
- if (ff_fft_init(&s->fft, nbits-1, trans == IDFT_C2R || trans == IDFT_R2C) < 0)
- return -1;
-
- ff_init_ff_cos_tabs(nbits);
- s->tcos = ff_cos_tabs[nbits];
- s->tsin = ff_sin_tabs[nbits]+(trans == DFT_R2C || trans == DFT_C2R)*(n>>2);
-#if !CONFIG_HARDCODED_TABLES
- for (i = 0; i < (n>>2); i++) {
- s->tsin[i] = sin(i*theta);
- }
-#endif
- s->rdft_calc = ff_rdft_calc_c;
-
- if (ARCH_ARM) ff_rdft_init_arm(s);
-
- return 0;
-}
-
-av_cold void ff_rdft_end(RDFTContext *s)
-{
- ff_fft_end(&s->fft);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/rdft.h b/src/thirdparty/ffmpeg/libavcodec/rdft.h
deleted file mode 100644
index 77c575e41..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/rdft.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * (I)RDFT transforms
- * Copyright (c) 2009 Alex Converse <alex dot converse at gmail dot 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_RDFT_H
-#define AVCODEC_RDFT_H
-
-#include "config.h"
-#include "fft.h"
-
-#if CONFIG_HARDCODED_TABLES
-# define SINTABLE_CONST const
-#else
-# define SINTABLE_CONST
-#endif
-
-#define SINTABLE(size) \
- SINTABLE_CONST DECLARE_ALIGNED(16, FFTSample, ff_sin_##size)[size/2]
-
-extern SINTABLE(16);
-extern SINTABLE(32);
-extern SINTABLE(64);
-extern SINTABLE(128);
-extern SINTABLE(256);
-extern SINTABLE(512);
-extern SINTABLE(1024);
-extern SINTABLE(2048);
-extern SINTABLE(4096);
-extern SINTABLE(8192);
-extern SINTABLE(16384);
-extern SINTABLE(32768);
-extern SINTABLE(65536);
-
-struct RDFTContext {
- int nbits;
- int inverse;
- int sign_convention;
-
- /* pre/post rotation tables */
- const FFTSample *tcos;
- SINTABLE_CONST FFTSample *tsin;
- FFTContext fft;
- void (*rdft_calc)(struct RDFTContext *s, FFTSample *z);
-};
-
-/**
- * Set up a real FFT.
- * @param nbits log2 of the length of the input array
- * @param trans the type of transform
- */
-int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans);
-void ff_rdft_end(RDFTContext *s);
-
-void ff_rdft_init_arm(RDFTContext *s);
-
-
-#endif /* AVCODEC_RDFT_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/rectangle.h b/src/thirdparty/ffmpeg/libavcodec/rectangle.h
deleted file mode 100644
index 0b1ccd845..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/rectangle.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * rectangle filling function
- * 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
- * useful rectangle filling function
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#ifndef AVCODEC_RECTANGLE_H
-#define AVCODEC_RECTANGLE_H
-
-#include "config.h"
-#include "libavutil/common.h"
-#include "libavutil/avassert.h"
-#include "dsputil.h"
-
-/**
- * fill a rectangle.
- * @param h height of the rectangle, should be a constant
- * @param w width of the rectangle, should be a constant
- * @param size the size of val (1, 2 or 4), should be a constant
- */
-static av_always_inline void fill_rectangle(void *vp, int w, int h, int stride, uint32_t val, int size){
- uint8_t *p= (uint8_t*)vp;
- av_assert2(size==1 || size==2 || size==4);
- av_assert2(w<=4);
-
- w *= size;
- stride *= size;
-
- av_assert2((((long)vp)&(FFMIN(w, 8<<(HAVE_NEON|ARCH_PPC|HAVE_MMX))-1)) == 0);
- av_assert2((stride&(w-1))==0);
- if(w==2){
- const uint16_t v= size==4 ? val : val*0x0101;
- *(uint16_t*)(p + 0*stride)= v;
- if(h==1) return;
- *(uint16_t*)(p + 1*stride)= v;
- if(h==2) return;
- *(uint16_t*)(p + 2*stride)= v;
- *(uint16_t*)(p + 3*stride)= v;
- }else if(w==4){
- const uint32_t v= size==4 ? val : size==2 ? val*0x00010001 : val*0x01010101;
- *(uint32_t*)(p + 0*stride)= v;
- if(h==1) return;
- *(uint32_t*)(p + 1*stride)= v;
- if(h==2) return;
- *(uint32_t*)(p + 2*stride)= v;
- *(uint32_t*)(p + 3*stride)= v;
- }else if(w==8){
- //gcc can't optimize 64bit math on x86_32
-#if HAVE_FAST_64BIT
- const uint64_t v= size==2 ? val*0x0001000100010001ULL : val*0x0100000001ULL;
- *(uint64_t*)(p + 0*stride)= v;
- if(h==1) return;
- *(uint64_t*)(p + 1*stride)= v;
- if(h==2) return;
- *(uint64_t*)(p + 2*stride)= v;
- *(uint64_t*)(p + 3*stride)= v;
- }else if(w==16){
- const uint64_t v= val*0x0100000001ULL;
- *(uint64_t*)(p + 0+0*stride)= v;
- *(uint64_t*)(p + 8+0*stride)= v;
- *(uint64_t*)(p + 0+1*stride)= v;
- *(uint64_t*)(p + 8+1*stride)= v;
- if(h==2) return;
- *(uint64_t*)(p + 0+2*stride)= v;
- *(uint64_t*)(p + 8+2*stride)= v;
- *(uint64_t*)(p + 0+3*stride)= v;
- *(uint64_t*)(p + 8+3*stride)= v;
-#else
- const uint32_t v= size==2 ? val*0x00010001 : val;
- *(uint32_t*)(p + 0+0*stride)= v;
- *(uint32_t*)(p + 4+0*stride)= v;
- if(h==1) return;
- *(uint32_t*)(p + 0+1*stride)= v;
- *(uint32_t*)(p + 4+1*stride)= v;
- if(h==2) return;
- *(uint32_t*)(p + 0+2*stride)= v;
- *(uint32_t*)(p + 4+2*stride)= v;
- *(uint32_t*)(p + 0+3*stride)= v;
- *(uint32_t*)(p + 4+3*stride)= v;
- }else if(w==16){
- *(uint32_t*)(p + 0+0*stride)= val;
- *(uint32_t*)(p + 4+0*stride)= val;
- *(uint32_t*)(p + 8+0*stride)= val;
- *(uint32_t*)(p +12+0*stride)= val;
- *(uint32_t*)(p + 0+1*stride)= val;
- *(uint32_t*)(p + 4+1*stride)= val;
- *(uint32_t*)(p + 8+1*stride)= val;
- *(uint32_t*)(p +12+1*stride)= val;
- if(h==2) return;
- *(uint32_t*)(p + 0+2*stride)= val;
- *(uint32_t*)(p + 4+2*stride)= val;
- *(uint32_t*)(p + 8+2*stride)= val;
- *(uint32_t*)(p +12+2*stride)= val;
- *(uint32_t*)(p + 0+3*stride)= val;
- *(uint32_t*)(p + 4+3*stride)= val;
- *(uint32_t*)(p + 8+3*stride)= val;
- *(uint32_t*)(p +12+3*stride)= val;
-#endif
- }else
- av_assert2(0);
- av_assert2(h==4);
-}
-
-#endif /* AVCODEC_RECTANGLE_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/rl.h b/src/thirdparty/ffmpeg/libavcodec/rl.h
deleted file mode 100644
index ed5dabbfc..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/rl.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2000-2002 Fabrice Bellard
- * Copyright (c) 2002-2004 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
- */
-
-/**
- * @file
- * rl header.
- */
-
-#ifndef AVCODEC_RL_H
-#define AVCODEC_RL_H
-
-#include <stdint.h>
-#include "get_bits.h"
-
-/* run length table */
-#define MAX_RUN 64
-#define MAX_LEVEL 64
-
-/** RLTable. */
-typedef struct RLTable {
- int n; ///< number of entries of table_vlc minus 1
- int last; ///< number of values for last = 0
- const uint16_t (*table_vlc)[2];
- const int8_t *table_run;
- const int8_t *table_level;
- uint8_t *index_run[2]; ///< encoding only
- int8_t *max_level[2]; ///< encoding & decoding
- int8_t *max_run[2]; ///< encoding & decoding
- VLC vlc; ///< decoding only deprecated FIXME remove
- RL_VLC_ELEM *rl_vlc[32]; ///< decoding only
-} RLTable;
-
-/**
- *
- * @param static_store static uint8_t array[2][2*MAX_RUN + MAX_LEVEL + 3] which will hold
- * the level and run tables, if this is NULL av_malloc() will be used
- */
-void ff_init_rl(RLTable *rl, uint8_t static_store[2][2*MAX_RUN + MAX_LEVEL + 3]);
-void ff_init_vlc_rl(RLTable *rl);
-
-#define INIT_VLC_RL(rl, static_size)\
-{\
- int q;\
- static RL_VLC_ELEM rl_vlc_table[32][static_size];\
- INIT_VLC_STATIC(&rl.vlc, 9, rl.n + 1,\
- &rl.table_vlc[0][1], 4, 2,\
- &rl.table_vlc[0][0], 4, 2, static_size);\
-\
- if(!rl.rl_vlc[0]){\
- for(q=0; q<32; q++)\
- rl.rl_vlc[q]= rl_vlc_table[q];\
-\
- ff_init_vlc_rl(&rl);\
- }\
-}
-
-static inline int get_rl_index(const RLTable *rl, int last, int run, int level)
-{
- int index;
- index = rl->index_run[last][run];
- if (index >= rl->n)
- return rl->n;
- if (level > rl->max_level[last][run])
- return rl->n;
- return index + level - 1;
-}
-
-#endif /* AVCODEC_RL_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/rnd_avg.h b/src/thirdparty/ffmpeg/libavcodec/rnd_avg.h
deleted file mode 100644
index bc663ef86..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/rnd_avg.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2001-2003 BERO <bero@geocities.co.jp>
- * Copyright (c) 2011 Oskar Arvidsson
- *
- * 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_RND_AVG_H
-#define AVCODEC_RND_AVG_H
-
-#include <stdint.h>
-
-#define BYTE_VEC32(c) ((c)*0x01010101UL)
-#define BYTE_VEC64(c) ((c)*0x0001000100010001UL)
-
-static inline uint32_t rnd_avg32(uint32_t a, uint32_t b)
-{
- return (a | b) - (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1);
-}
-
-static inline uint32_t no_rnd_avg32(uint32_t a, uint32_t b)
-{
- return (a & b) + (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1);
-}
-
-static inline uint64_t rnd_avg64(uint64_t a, uint64_t b)
-{
- return (a | b) - (((a ^ b) & ~BYTE_VEC64(0x01)) >> 1);
-}
-
-static inline uint64_t no_rnd_avg64(uint64_t a, uint64_t b)
-{
- return (a & b) + (((a ^ b) & ~BYTE_VEC64(0x01)) >> 1);
-}
-
-#endif /* AVCODEC_RND_AVG_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/rv10.c b/src/thirdparty/ffmpeg/libavcodec/rv10.c
deleted file mode 100644
index e9bb37c21..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/rv10.c
+++ /dev/null
@@ -1,782 +0,0 @@
-/*
- * RV10/RV20 decoder
- * Copyright (c) 2000,2001 Fabrice Bellard
- * Copyright (c) 2002-2004 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
- */
-
-/**
- * @file
- * RV10/RV20 decoder
- */
-
-#include "libavutil/imgutils.h"
-#include "avcodec.h"
-#include "dsputil.h"
-#include "mpegvideo.h"
-#include "mpeg4video.h"
-#include "h263.h"
-
-//#define DEBUG
-
-#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
-
-typedef struct RVDecContext {
- MpegEncContext m;
- int sub_id;
-} RVDecContext;
-
-static const uint16_t rv_lum_code[256] =
-{
- 0x3e7f, 0x0f00, 0x0f01, 0x0f02, 0x0f03, 0x0f04, 0x0f05, 0x0f06,
- 0x0f07, 0x0f08, 0x0f09, 0x0f0a, 0x0f0b, 0x0f0c, 0x0f0d, 0x0f0e,
- 0x0f0f, 0x0f10, 0x0f11, 0x0f12, 0x0f13, 0x0f14, 0x0f15, 0x0f16,
- 0x0f17, 0x0f18, 0x0f19, 0x0f1a, 0x0f1b, 0x0f1c, 0x0f1d, 0x0f1e,
- 0x0f1f, 0x0f20, 0x0f21, 0x0f22, 0x0f23, 0x0f24, 0x0f25, 0x0f26,
- 0x0f27, 0x0f28, 0x0f29, 0x0f2a, 0x0f2b, 0x0f2c, 0x0f2d, 0x0f2e,
- 0x0f2f, 0x0f30, 0x0f31, 0x0f32, 0x0f33, 0x0f34, 0x0f35, 0x0f36,
- 0x0f37, 0x0f38, 0x0f39, 0x0f3a, 0x0f3b, 0x0f3c, 0x0f3d, 0x0f3e,
- 0x0f3f, 0x0380, 0x0381, 0x0382, 0x0383, 0x0384, 0x0385, 0x0386,
- 0x0387, 0x0388, 0x0389, 0x038a, 0x038b, 0x038c, 0x038d, 0x038e,
- 0x038f, 0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396,
- 0x0397, 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e,
- 0x039f, 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6,
- 0x00c7, 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce,
- 0x00cf, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056,
- 0x0057, 0x0020, 0x0021, 0x0022, 0x0023, 0x000c, 0x000d, 0x0004,
- 0x0000, 0x0005, 0x000e, 0x000f, 0x0024, 0x0025, 0x0026, 0x0027,
- 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
- 0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
- 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df,
- 0x03a0, 0x03a1, 0x03a2, 0x03a3, 0x03a4, 0x03a5, 0x03a6, 0x03a7,
- 0x03a8, 0x03a9, 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03ae, 0x03af,
- 0x03b0, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7,
- 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf,
- 0x0f40, 0x0f41, 0x0f42, 0x0f43, 0x0f44, 0x0f45, 0x0f46, 0x0f47,
- 0x0f48, 0x0f49, 0x0f4a, 0x0f4b, 0x0f4c, 0x0f4d, 0x0f4e, 0x0f4f,
- 0x0f50, 0x0f51, 0x0f52, 0x0f53, 0x0f54, 0x0f55, 0x0f56, 0x0f57,
- 0x0f58, 0x0f59, 0x0f5a, 0x0f5b, 0x0f5c, 0x0f5d, 0x0f5e, 0x0f5f,
- 0x0f60, 0x0f61, 0x0f62, 0x0f63, 0x0f64, 0x0f65, 0x0f66, 0x0f67,
- 0x0f68, 0x0f69, 0x0f6a, 0x0f6b, 0x0f6c, 0x0f6d, 0x0f6e, 0x0f6f,
- 0x0f70, 0x0f71, 0x0f72, 0x0f73, 0x0f74, 0x0f75, 0x0f76, 0x0f77,
- 0x0f78, 0x0f79, 0x0f7a, 0x0f7b, 0x0f7c, 0x0f7d, 0x0f7e, 0x0f7f,
-};
-
-static const uint8_t rv_lum_bits[256] =
-{
- 14, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 7, 7, 7, 7, 7, 7, 7,
- 7, 6, 6, 6, 6, 5, 5, 4,
- 2, 4, 5, 5, 6, 6, 6, 6,
- 7, 7, 7, 7, 7, 7, 7, 7,
- 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
-};
-
-static const uint16_t rv_chrom_code[256] =
-{
- 0xfe7f, 0x3f00, 0x3f01, 0x3f02, 0x3f03, 0x3f04, 0x3f05, 0x3f06,
- 0x3f07, 0x3f08, 0x3f09, 0x3f0a, 0x3f0b, 0x3f0c, 0x3f0d, 0x3f0e,
- 0x3f0f, 0x3f10, 0x3f11, 0x3f12, 0x3f13, 0x3f14, 0x3f15, 0x3f16,
- 0x3f17, 0x3f18, 0x3f19, 0x3f1a, 0x3f1b, 0x3f1c, 0x3f1d, 0x3f1e,
- 0x3f1f, 0x3f20, 0x3f21, 0x3f22, 0x3f23, 0x3f24, 0x3f25, 0x3f26,
- 0x3f27, 0x3f28, 0x3f29, 0x3f2a, 0x3f2b, 0x3f2c, 0x3f2d, 0x3f2e,
- 0x3f2f, 0x3f30, 0x3f31, 0x3f32, 0x3f33, 0x3f34, 0x3f35, 0x3f36,
- 0x3f37, 0x3f38, 0x3f39, 0x3f3a, 0x3f3b, 0x3f3c, 0x3f3d, 0x3f3e,
- 0x3f3f, 0x0f80, 0x0f81, 0x0f82, 0x0f83, 0x0f84, 0x0f85, 0x0f86,
- 0x0f87, 0x0f88, 0x0f89, 0x0f8a, 0x0f8b, 0x0f8c, 0x0f8d, 0x0f8e,
- 0x0f8f, 0x0f90, 0x0f91, 0x0f92, 0x0f93, 0x0f94, 0x0f95, 0x0f96,
- 0x0f97, 0x0f98, 0x0f99, 0x0f9a, 0x0f9b, 0x0f9c, 0x0f9d, 0x0f9e,
- 0x0f9f, 0x03c0, 0x03c1, 0x03c2, 0x03c3, 0x03c4, 0x03c5, 0x03c6,
- 0x03c7, 0x03c8, 0x03c9, 0x03ca, 0x03cb, 0x03cc, 0x03cd, 0x03ce,
- 0x03cf, 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6,
- 0x00e7, 0x0030, 0x0031, 0x0032, 0x0033, 0x0008, 0x0009, 0x0002,
- 0x0000, 0x0003, 0x000a, 0x000b, 0x0034, 0x0035, 0x0036, 0x0037,
- 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
- 0x03d0, 0x03d1, 0x03d2, 0x03d3, 0x03d4, 0x03d5, 0x03d6, 0x03d7,
- 0x03d8, 0x03d9, 0x03da, 0x03db, 0x03dc, 0x03dd, 0x03de, 0x03df,
- 0x0fa0, 0x0fa1, 0x0fa2, 0x0fa3, 0x0fa4, 0x0fa5, 0x0fa6, 0x0fa7,
- 0x0fa8, 0x0fa9, 0x0faa, 0x0fab, 0x0fac, 0x0fad, 0x0fae, 0x0faf,
- 0x0fb0, 0x0fb1, 0x0fb2, 0x0fb3, 0x0fb4, 0x0fb5, 0x0fb6, 0x0fb7,
- 0x0fb8, 0x0fb9, 0x0fba, 0x0fbb, 0x0fbc, 0x0fbd, 0x0fbe, 0x0fbf,
- 0x3f40, 0x3f41, 0x3f42, 0x3f43, 0x3f44, 0x3f45, 0x3f46, 0x3f47,
- 0x3f48, 0x3f49, 0x3f4a, 0x3f4b, 0x3f4c, 0x3f4d, 0x3f4e, 0x3f4f,
- 0x3f50, 0x3f51, 0x3f52, 0x3f53, 0x3f54, 0x3f55, 0x3f56, 0x3f57,
- 0x3f58, 0x3f59, 0x3f5a, 0x3f5b, 0x3f5c, 0x3f5d, 0x3f5e, 0x3f5f,
- 0x3f60, 0x3f61, 0x3f62, 0x3f63, 0x3f64, 0x3f65, 0x3f66, 0x3f67,
- 0x3f68, 0x3f69, 0x3f6a, 0x3f6b, 0x3f6c, 0x3f6d, 0x3f6e, 0x3f6f,
- 0x3f70, 0x3f71, 0x3f72, 0x3f73, 0x3f74, 0x3f75, 0x3f76, 0x3f77,
- 0x3f78, 0x3f79, 0x3f7a, 0x3f7b, 0x3f7c, 0x3f7d, 0x3f7e, 0x3f7f,
-};
-
-static const uint8_t rv_chrom_bits[256] =
-{
- 16, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 8, 8, 8, 8, 8, 8, 8,
- 8, 6, 6, 6, 6, 4, 4, 3,
- 2, 3, 4, 4, 6, 6, 6, 6,
- 8, 8, 8, 8, 8, 8, 8, 8,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14,
-};
-
-static VLC rv_dc_lum, rv_dc_chrom;
-
-int ff_rv_decode_dc(MpegEncContext *s, int n)
-{
- int code;
-
- if (n < 4) {
- 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 !!! */
- code = get_bits(&s->gb, 7);
- if (code == 0x7c) {
- 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);
- else
- code = (int8_t)(get_bits(&s->gb, 8));
- } else if (code == 0x7f) {
- skip_bits(&s->gb, 11);
- code = 1;
- }
- } else {
- code -= 128;
- }
- } else {
- code = get_vlc2(&s->gb, rv_dc_chrom.table, DC_VLC_BITS, 2);
- /* same remark */
- if (code < 0) {
- code = get_bits(&s->gb, 9);
- if (code == 0x1fc) {
- code = (int8_t)(get_bits(&s->gb, 7) + 1);
- } else if (code == 0x1fd) {
- code = -128 + get_bits(&s->gb, 7);
- } else if (code == 0x1fe) {
- skip_bits(&s->gb, 9);
- code = 1;
- } else {
- av_log(s->avctx, AV_LOG_ERROR, "chroma dc error\n");
- return 0xffff;
- }
- } else {
- code -= 128;
- }
- }
- return -code;
-}
-
-/* read RV 1.0 compatible frame header */
-static int rv10_decode_picture_header(MpegEncContext *s)
-{
- int mb_count, pb_frame, marker, mb_xy;
-
- marker = get_bits1(&s->gb);
-
- if (get_bits1(&s->gb))
- s->pict_type = AV_PICTURE_TYPE_P;
- else
- s->pict_type = AV_PICTURE_TYPE_I;
- if(!marker) av_log(s->avctx, AV_LOG_ERROR, "marker missing\n");
- pb_frame = get_bits1(&s->gb);
-
- av_dlog(s->avctx, "pict_type=%d pb_frame=%d\n", s->pict_type, pb_frame);
-
- if (pb_frame){
- av_log(s->avctx, AV_LOG_ERROR, "pb frame not supported\n");
- return -1;
- }
-
- s->qscale = get_bits(&s->gb, 5);
- if(s->qscale==0){
- av_log(s->avctx, AV_LOG_ERROR, "error, qscale:0\n");
- return -1;
- }
-
- if (s->pict_type == AV_PICTURE_TYPE_I) {
- if (s->rv10_version == 3) {
- /* specific MPEG like DC coding not used */
- s->last_dc[0] = get_bits(&s->gb, 8);
- s->last_dc[1] = get_bits(&s->gb, 8);
- s->last_dc[2] = get_bits(&s->gb, 8);
- av_dlog(s->avctx, "DC:%d %d %d\n", s->last_dc[0],
- s->last_dc[1], s->last_dc[2]);
- }
- }
- /* if multiple packets per frame are sent, the position at which
- 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)){
- s->mb_x = get_bits(&s->gb, 6); /* mb_x */
- s->mb_y = get_bits(&s->gb, 6); /* mb_y */
- mb_count = get_bits(&s->gb, 12);
- } else {
- s->mb_x = 0;
- s->mb_y = 0;
- mb_count = s->mb_width * s->mb_height;
- }
- skip_bits(&s->gb, 3); /* ignored */
- s->f_code = 1;
- s->unrestricted_mv = 1;
-
- return mb_count;
-}
-
-static int rv20_decode_picture_header(RVDecContext *rv)
-{
- MpegEncContext *s = &rv->m;
- int seq, mb_pos, i;
- int rpr_bits;
-
-#if 0
- GetBitContext gb= s->gb;
- for(i=0; i<64; i++){
- av_log(s->avctx, AV_LOG_DEBUG, "%d", get_bits1(&gb));
- if(i%4==3) av_log(s->avctx, AV_LOG_DEBUG, " ");
- }
- av_log(s->avctx, AV_LOG_DEBUG, "\n");
-#endif
-#if 0
- av_log(s->avctx, AV_LOG_DEBUG, "%3dx%03d/%02Xx%02X ", s->width, s->height, s->width/4, s->height/4);
- for(i=0; i<s->avctx->extradata_size; i++){
- av_log(s->avctx, AV_LOG_DEBUG, "%02X ", ((uint8_t*)s->avctx->extradata)[i]);
- if(i%4==3) av_log(s->avctx, AV_LOG_DEBUG, " ");
- }
- av_log(s->avctx, AV_LOG_DEBUG, "\n");
-#endif
-
- 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;
- default:
- av_log(s->avctx, AV_LOG_ERROR, "unknown frame type\n");
- return -1;
- }
-
- if(s->low_delay && s->pict_type==AV_PICTURE_TYPE_B){
- av_log(s->avctx, AV_LOG_ERROR, "low delay B\n");
- return -1;
- }
- if(s->last_picture_ptr==NULL && s->pict_type==AV_PICTURE_TYPE_B){
- av_log(s->avctx, AV_LOG_ERROR, "early B pix\n");
- return -1;
- }
-
- if (get_bits1(&s->gb)){
- av_log(s->avctx, AV_LOG_ERROR, "reserved bit set\n");
- return -1;
- }
-
- s->qscale = get_bits(&s->gb, 5);
- if(s->qscale==0){
- av_log(s->avctx, AV_LOG_ERROR, "error, qscale:0\n");
- return -1;
- }
-
- if(RV_GET_MINOR_VER(rv->sub_id) >= 2)
- s->loop_filter = get_bits1(&s->gb) && !s->avctx->lowres;
-
- if(RV_GET_MINOR_VER(rv->sub_id) <= 1)
- seq = get_bits(&s->gb, 8) << 7;
- else
- seq = get_bits(&s->gb, 13) << 2;
-
- rpr_bits = s->avctx->extradata[1] & 7;
- if(rpr_bits){
- int f, new_w, new_h;
- rpr_bits = FFMIN((rpr_bits >> 1) + 1, 3);
-
- f = get_bits(&s->gb, rpr_bits);
-
- if(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_h= s->orig_height;
- }
- if(new_w != s->width || new_h != s->height){
- AVRational old_aspect = s->avctx->sample_aspect_ratio;
- av_log(s->avctx, AV_LOG_DEBUG, "attempting to change resolution to %dx%d\n", new_w, new_h);
- if (av_image_check_size(new_w, new_h, 0, s->avctx) < 0)
- return -1;
- ff_MPV_common_end(s);
-
- // attempt to keep aspect during typical resolution switches
- if (!old_aspect.num)
- old_aspect = (AVRational){1, 1};
- if (2 * new_w * s->height == new_h * s->width)
- s->avctx->sample_aspect_ratio = av_mul_q(old_aspect, (AVRational){2, 1});
- if (new_w * s->height == 2 * new_h * s->width)
- s->avctx->sample_aspect_ratio = av_mul_q(old_aspect, (AVRational){1, 2});
- avcodec_set_dimensions(s->avctx, new_w, new_h);
- s->width = new_w;
- s->height = new_h;
- if (ff_MPV_common_init(s) < 0)
- return -1;
- }
-
- if(s->avctx->debug & FF_DEBUG_PICT_INFO){
- av_log(s->avctx, AV_LOG_DEBUG, "F %d/%d\n", f, rpr_bits);
- }
- }
- if (av_image_check_size(s->width, s->height, 0, s->avctx) < 0)
- return AVERROR_INVALIDDATA;
-
- mb_pos = ff_h263_decode_mba(s);
-
- seq |= s->time &~0x7FFF;
- if(seq - s->time > 0x4000) seq -= 0x8000;
- if(seq - s->time < -0x4000) seq += 0x8000;
- if(seq != s->time){
- if(s->pict_type!=AV_PICTURE_TYPE_B){
- s->time= seq;
- s->pp_time= s->time - s->last_non_b_time;
- s->last_non_b_time= s->time;
- }else{
- s->time= seq;
- s->pb_time= s->pp_time - (s->last_non_b_time - s->time);
- }
- }
- if (s->pict_type==AV_PICTURE_TYPE_B) {
- if(s->pp_time <=s->pb_time || s->pp_time <= s->pp_time - s->pb_time || s->pp_time<=0){
- av_log(s->avctx, AV_LOG_DEBUG, "messed up order, possible from seeking? skipping current b frame\n");
- return FRAME_SKIPPED;
- }
- ff_mpeg4_init_direct_mv(s);
- }
-
- 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
-
- s->f_code = 1;
- s->unrestricted_mv = 1;
- s->h263_aic= s->pict_type == AV_PICTURE_TYPE_I;
-// s->alt_inter_vlc=1;
-// s->obmc=1;
-// s->umvplus=1;
- s->modified_quant=1;
- if(!s->avctx->lowres)
- 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_assert0(s->pict_type != AV_PICTURE_TYPE_B || !s->low_delay);
-
- return s->mb_width*s->mb_height - mb_pos;
-}
-
-static av_cold int rv10_decode_init(AVCodecContext *avctx)
-{
- RVDecContext *rv = avctx->priv_data;
- MpegEncContext *s = &rv->m;
- static int done=0;
- int major_ver, minor_ver, micro_ver;
-
- if (avctx->extradata_size < 8) {
- av_log(avctx, AV_LOG_ERROR, "Extradata is too small.\n");
- return -1;
- }
-
- ff_MPV_decode_defaults(s);
-
- 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->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);
- micro_ver = RV_GET_MICRO_VER(rv->sub_id);
-
- s->low_delay = 1;
- switch (major_ver) {
- case 1:
- s->rv10_version = micro_ver ? 3 : 1;
- s->obmc = micro_ver == 2;
- break;
- case 2:
- if (minor_ver >= 2) {
- s->low_delay = 0;
- s->avctx->has_b_frames = 1;
- }
- break;
- default:
- av_log(s->avctx, AV_LOG_ERROR, "unknown header %X\n", rv->sub_id);
- av_log_missing_feature(avctx, "RV1/2 version", 1);
- return AVERROR_PATCHWELCOME;
- }
-
- 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]);
- }
-
- avctx->pix_fmt = AV_PIX_FMT_YUV420P;
-
- if (ff_MPV_common_init(s) < 0)
- return -1;
-
- ff_h263_decode_init_vlc();
-
- /* init rv vlc */
- if (!done) {
- INIT_VLC_STATIC(&rv_dc_lum, DC_VLC_BITS, 256,
- rv_lum_bits, 1, 1,
- rv_lum_code, 2, 2, 16384);
- INIT_VLC_STATIC(&rv_dc_chrom, DC_VLC_BITS, 256,
- rv_chrom_bits, 1, 1,
- rv_chrom_code, 2, 2, 16388);
- done = 1;
- }
-
- return 0;
-}
-
-static av_cold int rv10_decode_end(AVCodecContext *avctx)
-{
- MpegEncContext *s = avctx->priv_data;
-
- ff_MPV_common_end(s);
- return 0;
-}
-
-static int rv10_decode_packet(AVCodecContext *avctx,
- const uint8_t *buf, int buf_size, int buf_size2)
-{
- RVDecContext *rv = avctx->priv_data;
- MpegEncContext *s = &rv->m;
- int mb_count, mb_pos, left, start_mb_x, active_bits_size;
-
- active_bits_size = buf_size * 8;
- init_get_bits(&s->gb, buf, FFMAX(buf_size, buf_size2) * 8);
- if(s->codec_id ==AV_CODEC_ID_RV10)
- mb_count = rv10_decode_picture_header(s);
- else
- mb_count = rv20_decode_picture_header(rv);
- if (mb_count < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "HEADER ERROR\n");
- return -1;
- }
-
- if (s->mb_x >= s->mb_width ||
- s->mb_y >= s->mb_height) {
- av_log(s->avctx, AV_LOG_ERROR, "POS ERROR %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
- mb_pos = s->mb_y * s->mb_width + s->mb_x;
- left = s->mb_width * s->mb_height - mb_pos;
- if (mb_count > left) {
- av_log(s->avctx, AV_LOG_ERROR, "COUNT ERROR\n");
- return -1;
- }
-
- 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?
- ff_er_frame_end(s);
- ff_MPV_frame_end(s);
- s->mb_x= s->mb_y = s->resync_mb_x = s->resync_mb_y= 0;
- }
- if(ff_MPV_frame_start(s, avctx) < 0)
- return -1;
- ff_er_frame_start(s);
- } else {
- if (s->current_picture_ptr->f.pict_type != s->pict_type) {
- av_log(s->avctx, AV_LOG_ERROR, "Slice type mismatch\n");
- return -1;
- }
- }
-
-
- av_dlog(avctx, "qscale=%d\n", s->qscale);
-
- /* default quantization values */
- if(s->codec_id== AV_CODEC_ID_RV10){
- if(s->mb_y==0) s->first_slice_line=1;
- }else{
- s->first_slice_line=1;
- s->resync_mb_x= s->mb_x;
- }
- 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;
- }else{
- s->y_dc_scale_table=
- s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
- }
-
- if(s->modified_quant)
- s->chroma_qscale_table= ff_h263_chroma_qscale_table;
-
- ff_set_qscale(s, s->qscale);
-
- s->rv10_first_dc_coded[0] = 0;
- s->rv10_first_dc_coded[1] = 0;
- s->rv10_first_dc_coded[2] = 0;
- s->block_wrap[0]=
- s->block_wrap[1]=
- s->block_wrap[2]=
- s->block_wrap[3]= s->b8_stride;
- s->block_wrap[4]=
- s->block_wrap[5]= s->mb_stride;
- ff_init_block_index(s);
- /* decode each macroblock */
-
- for(s->mb_num_left= mb_count; s->mb_num_left>0; s->mb_num_left--) {
- int ret;
- ff_update_block_index(s);
- av_dlog(avctx, "**mb x=%d y=%d\n", s->mb_x, s->mb_y);
-
- s->mv_dir = MV_DIR_FORWARD;
- s->mv_type = MV_TYPE_16X16;
- ret=ff_h263_decode_mb(s, s->block);
-
- // Repeat the slice end check from ff_h263_decode_mb with our active
- // bitstream size
- if (ret != SLICE_ERROR) {
- int v = show_bits(&s->gb, 16);
-
- if (get_bits_count(&s->gb) + 16 > active_bits_size)
- v >>= get_bits_count(&s->gb) + 16 - active_bits_size;
-
- if (!v)
- ret = SLICE_END;
- }
- if (ret != SLICE_ERROR && active_bits_size < get_bits_count(&s->gb) &&
- 8 * buf_size2 >= get_bits_count(&s->gb)) {
- active_bits_size = buf_size2 * 8;
- av_log(avctx, AV_LOG_DEBUG, "update size from %d to %d\n",
- 8 * buf_size, active_bits_size);
- ret= SLICE_OK;
- }
-
- 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);
- return -1;
- }
- if(s->pict_type != AV_PICTURE_TYPE_B)
- ff_h263_update_motion_val(s);
- ff_MPV_decode_mb(s, s->block);
- if(s->loop_filter)
- ff_h263_loop_filter(s);
-
- if (++s->mb_x == s->mb_width) {
- s->mb_x = 0;
- s->mb_y++;
- ff_init_block_index(s);
- }
- if(s->mb_x == s->resync_mb_x)
- s->first_slice_line=0;
- if(ret == SLICE_END) break;
- }
-
- ff_er_add_slice(s, start_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END);
-
- return active_bits_size;
-}
-
-static int get_slice_offset(AVCodecContext *avctx, const uint8_t *buf, int n)
-{
- if(avctx->slice_count) return avctx->slice_offset[n];
- else return AV_RL32(buf + n*8);
-}
-
-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;
- int i;
- AVFrame *pict = data;
- int slice_count;
- const uint8_t *slices_hdr = NULL;
-
- av_dlog(avctx, "*****frame %d size=%d\n", avctx->frame_number, buf_size);
- s->flags = avctx->flags;
- s->flags2 = avctx->flags2;
-
- /* no supplementary picture */
- if (buf_size == 0) {
- return 0;
- }
-
- if(!avctx->slice_count){
- slice_count = (*buf++) + 1;
- buf_size--;
-
- if (!slice_count || buf_size <= 8 * slice_count) {
- av_log(avctx, AV_LOG_ERROR, "Invalid slice count: %d.\n", slice_count);
- return AVERROR_INVALIDDATA;
- }
-
- slices_hdr = buf + 4;
- buf += 8 * slice_count;
- buf_size -= 8 * slice_count;
- }else
- slice_count = avctx->slice_count;
-
- for(i=0; i<slice_count; i++){
- unsigned offset = get_slice_offset(avctx, slices_hdr, i);
- int size, size2;
-
- if (offset >= buf_size)
- return AVERROR_INVALIDDATA;
-
- if(i+1 == slice_count)
- size= buf_size - offset;
- else
- size= get_slice_offset(avctx, slices_hdr, i+1) - offset;
-
- if(i+2 >= slice_count)
- size2= buf_size - offset;
- else
- size2= get_slice_offset(avctx, slices_hdr, i+2) - offset;
-
- if (size <= 0 || size2 <= 0 ||
- offset + FFMAX(size, size2) > buf_size)
- return AVERROR_INVALIDDATA;
-
- if(rv10_decode_packet(avctx, buf+offset, size, size2) > 8*size)
- i++;
- }
-
- if(s->current_picture_ptr != NULL && s->mb_y>=s->mb_height){
- ff_er_frame_end(s);
- ff_MPV_frame_end(s);
-
- if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
- *pict = s->current_picture_ptr->f;
- } else if (s->last_picture_ptr != NULL) {
- *pict = s->last_picture_ptr->f;
- }
-
- if(s->last_picture_ptr || s->low_delay){
- *got_frame = 1;
- ff_print_debug_info(s, pict);
- }
- s->current_picture_ptr= NULL; // so we can detect if frame_end was not called (find some nicer solution...)
- }
-
- return avpkt->size;
-}
-
-AVCodec ff_rv10_decoder = {
- .name = "rv10",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_RV10,
- .priv_data_size = sizeof(RVDecContext),
- .init = rv10_decode_init,
- .close = rv10_decode_end,
- .decode = rv10_decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .max_lowres = 3,
- .long_name = NULL_IF_CONFIG_SMALL("RealVideo 1.0"),
- .pix_fmts = ff_pixfmt_list_420,
-};
-
-AVCodec ff_rv20_decoder = {
- .name = "rv20",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_RV20,
- .priv_data_size = sizeof(RVDecContext),
- .init = rv10_decode_init,
- .close = rv10_decode_end,
- .decode = rv10_decode_frame,
- .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY,
- .flush = ff_mpeg_flush,
- .max_lowres = 3,
- .long_name = NULL_IF_CONFIG_SMALL("RealVideo 2.0"),
- .pix_fmts = ff_pixfmt_list_420,
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/rv30.c b/src/thirdparty/ffmpeg/libavcodec/rv30.c
deleted file mode 100644
index a2aa71831..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/rv30.c
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * RV30 decoder
- * Copyright (c) 2007 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
- */
-
-/**
- * @file
- * RV30 decoder
- */
-
-#include "avcodec.h"
-#include "dsputil.h"
-#include "mpegvideo.h"
-#include "golomb.h"
-
-#include "rv34.h"
-#include "rv30data.h"
-
-
-static int rv30_parse_slice_header(RV34DecContext *r, GetBitContext *gb, SliceInfo *si)
-{
- int mb_bits;
- int w = r->s.width, h = r->s.height;
- int mb_size;
- int rpr;
-
- memset(si, 0, sizeof(SliceInfo));
- if(get_bits(gb, 3))
- return -1;
- si->type = get_bits(gb, 2);
- if(si->type == 1) si->type = 0;
- if(get_bits1(gb))
- return -1;
- 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;
- }
- if(rpr){
- w = r->s.avctx->extradata[6 + rpr*2] << 2;
- h = r->s.avctx->extradata[7 + rpr*2] << 2;
- }
- si->width = w;
- si->height = h;
- mb_size = ((w + 15) >> 4) * ((h + 15) >> 4);
- mb_bits = ff_rv34_get_start_offset(gb, mb_size);
- si->start = get_bits(gb, mb_bits);
- skip_bits1(gb);
- return 0;
-}
-
-/**
- * Decode 4x4 intra types array.
- */
-static int rv30_decode_intra_types(RV34DecContext *r, GetBitContext *gb, int8_t *dst)
-{
- int i, j, k;
-
- for(i = 0; i < 4; i++, dst += r->intra_types_stride - 4){
- for(j = 0; j < 4; j+= 2){
- unsigned code = svq3_get_ue_golomb(gb) << 1;
- if (code > 80U*2U) {
- av_log(r->s.avctx, AV_LOG_ERROR, "Incorrect intra prediction code\n");
- return -1;
- }
- for(k = 0; k < 2; k++){
- int A = dst[-r->intra_types_stride] + 1;
- int B = dst[-1] + 1;
- *dst++ = rv30_itype_from_context[A * 90 + B * 9 + rv30_itype_code[code + k]];
- if(dst[-1] == 9){
- av_log(r->s.avctx, AV_LOG_ERROR, "Incorrect intra prediction mode\n");
- return -1;
- }
- }
- }
- }
- return 0;
-}
-
-/**
- * Decode macroblock information.
- */
-static int rv30_decode_mb_info(RV34DecContext *r)
-{
- static const int rv30_p_types[6] = { RV34_MB_SKIP, RV34_MB_P_16x16, RV34_MB_P_8x8, -1, RV34_MB_TYPE_INTRA, RV34_MB_TYPE_INTRA16x16 };
- static const int rv30_b_types[6] = { RV34_MB_SKIP, RV34_MB_B_DIRECT, RV34_MB_B_FORWARD, RV34_MB_B_BACKWARD, RV34_MB_TYPE_INTRA, RV34_MB_TYPE_INTRA16x16 };
- MpegEncContext *s = &r->s;
- GetBitContext *gb = &s->gb;
- unsigned code = svq3_get_ue_golomb(gb);
-
- if (code > 11) {
- av_log(s->avctx, AV_LOG_ERROR, "Incorrect MB type code\n");
- return -1;
- }
- if(code > 5){
- av_log(s->avctx, AV_LOG_ERROR, "dquant needed\n");
- code -= 6;
- }
- if(s->pict_type != AV_PICTURE_TYPE_B)
- return rv30_p_types[code];
- else
- return rv30_b_types[code];
-}
-
-static inline void rv30_weak_loop_filter(uint8_t *src, const int step,
- const int stride, const int lim)
-{
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
- int i, diff;
-
- for(i = 0; i < 4; i++){
- diff = ((src[-2*step] - src[1*step]) - (src[-1*step] - src[0*step])*4) >> 3;
- diff = av_clip(diff, -lim, lim);
- src[-1*step] = cm[src[-1*step] + diff];
- src[ 0*step] = cm[src[ 0*step] - diff];
- src += stride;
- }
-}
-
-static void rv30_loop_filter(RV34DecContext *r, int row)
-{
- MpegEncContext *s = &r->s;
- int mb_pos, mb_x;
- int i, j, k;
- uint8_t *Y, *C;
- int loc_lim, cur_lim, left_lim = 0, top_lim = 0;
-
- mb_pos = row * s->mb_stride;
- for(mb_x = 0; mb_x < s->mb_width; mb_x++, mb_pos++){
- int mbtype = s->current_picture_ptr->f.mb_type[mb_pos];
- if(IS_INTRA(mbtype) || IS_SEPARATE_DC(mbtype))
- r->deblock_coefs[mb_pos] = 0xFFFF;
- if(IS_INTRA(mbtype))
- r->cbp_chroma[mb_pos] = 0xFF;
- }
-
- /* all vertical edges are filtered first
- * and horizontal edges are filtered on the next iteration
- */
- mb_pos = row * s->mb_stride;
- for(mb_x = 0; mb_x < s->mb_width; mb_x++, mb_pos++){
- cur_lim = rv30_loop_filt_lim[s->current_picture_ptr->f.qscale_table[mb_pos]];
- if(mb_x)
- left_lim = rv30_loop_filt_lim[s->current_picture_ptr->f.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;
- for(i = !mb_x; i < 4; i++, Y += 4){
- int ij = i + j;
- loc_lim = 0;
- if(r->deblock_coefs[mb_pos] & (1 << ij))
- loc_lim = cur_lim;
- else if(!i && r->deblock_coefs[mb_pos - 1] & (1 << (ij + 3)))
- loc_lim = left_lim;
- else if( i && r->deblock_coefs[mb_pos] & (1 << (ij - 1)))
- loc_lim = cur_lim;
- if(loc_lim)
- rv30_weak_loop_filter(Y, 1, s->linesize, loc_lim);
- }
- }
- for(k = 0; k < 2; k++){
- int cur_cbp, left_cbp = 0;
- cur_cbp = (r->cbp_chroma[mb_pos] >> (k*4)) & 0xF;
- 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;
- for(i = !mb_x; i < 2; i++, C += 4){
- int ij = i + (j >> 1);
- loc_lim = 0;
- if (cur_cbp & (1 << ij))
- loc_lim = cur_lim;
- else if(!i && left_cbp & (1 << (ij + 1)))
- loc_lim = left_lim;
- else if( i && cur_cbp & (1 << (ij - 1)))
- loc_lim = cur_lim;
- if(loc_lim)
- rv30_weak_loop_filter(C, 1, s->uvlinesize, loc_lim);
- }
- }
- }
- }
- mb_pos = row * s->mb_stride;
- for(mb_x = 0; mb_x < s->mb_width; mb_x++, mb_pos++){
- cur_lim = rv30_loop_filt_lim[s->current_picture_ptr->f.qscale_table[mb_pos]];
- if(row)
- top_lim = rv30_loop_filt_lim[s->current_picture_ptr->f.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;
- for(i = 0; i < 4; i++, Y += 4){
- int ij = i + j;
- loc_lim = 0;
- if(r->deblock_coefs[mb_pos] & (1 << ij))
- loc_lim = cur_lim;
- else if(!j && r->deblock_coefs[mb_pos - s->mb_stride] & (1 << (ij + 12)))
- loc_lim = top_lim;
- else if( j && r->deblock_coefs[mb_pos] & (1 << (ij - 4)))
- loc_lim = cur_lim;
- if(loc_lim)
- rv30_weak_loop_filter(Y, s->linesize, 1, loc_lim);
- }
- }
- for(k = 0; k < 2; k++){
- int cur_cbp, top_cbp = 0;
- cur_cbp = (r->cbp_chroma[mb_pos] >> (k*4)) & 0xF;
- 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;
- for(i = 0; i < 2; i++, C += 4){
- int ij = i + (j >> 1);
- loc_lim = 0;
- if (r->cbp_chroma[mb_pos] & (1 << ij))
- loc_lim = cur_lim;
- else if(!j && top_cbp & (1 << (ij + 2)))
- loc_lim = top_lim;
- else if( j && cur_cbp & (1 << (ij - 2)))
- loc_lim = cur_lim;
- if(loc_lim)
- rv30_weak_loop_filter(C, s->uvlinesize, 1, loc_lim);
- }
- }
- }
- }
-}
-
-/**
- * Initialize decoder.
- */
-static av_cold int rv30_decode_init(AVCodecContext *avctx)
-{
- RV34DecContext *r = avctx->priv_data;
-
- r->rv30 = 1;
- ff_rv34_decode_init(avctx);
- if(avctx->extradata_size < 2){
- 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->parse_slice_header = rv30_parse_slice_header;
- r->decode_intra_types = rv30_decode_intra_types;
- r->decode_mb_info = rv30_decode_mb_info;
- r->loop_filter = rv30_loop_filter;
- r->luma_dc_quant_i = rv30_luma_dc_quant;
- r->luma_dc_quant_p = rv30_luma_dc_quant;
- return 0;
-}
-
-AVCodec ff_rv30_decoder = {
- .name = "rv30",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_RV30,
- .priv_data_size = sizeof(RV34DecContext),
- .init = rv30_decode_init,
- .close = ff_rv34_decode_end,
- .decode = ff_rv34_decode_frame,
- .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY |
- CODEC_CAP_FRAME_THREADS,
- .flush = ff_mpeg_flush,
- .long_name = NULL_IF_CONFIG_SMALL("RealVideo 3.0"),
- .pix_fmts = ff_pixfmt_list_420,
- .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/src/thirdparty/ffmpeg/libavcodec/rv30data.h b/src/thirdparty/ffmpeg/libavcodec/rv30data.h
deleted file mode 100644
index 23f194e77..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/rv30data.h
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * RealVideo 3 decoder
- * copyright (c) 2007 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
- */
-
-/**
- * @file
- * miscellaneous RV30 tables
- */
-
-#ifndef AVCODEC_RV30DATA_H
-#define AVCODEC_RV30DATA_H
-
-#include <stdint.h>
-
-/** DC quantizer mapping for RV30 */
-static const uint8_t rv30_luma_dc_quant[32] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 22, 22, 23, 23, 23, 24, 24, 25, 25
-};
-
-/**
- * This table is used for storing the differences
- * between the predicted and the real intra type.
- */
-static const uint8_t rv30_itype_code[9*9*2] = {
- 0, 0, 0, 1, 1, 0, 1, 1, 0, 2, 2, 0, 0, 3, 3, 0, 1, 2,
- 2, 1, 0, 4, 4, 0, 3, 1, 1, 3, 0, 5, 5, 0, 2, 2, 1, 4,
- 4, 1, 0, 6, 3, 2, 1, 5, 2, 3, 5, 1, 6, 0, 0, 7, 4, 2,
- 2, 4, 3, 3, 6, 1, 1, 6, 7, 0, 0, 8, 5, 2, 4, 3, 2, 5,
- 3, 4, 1, 7, 4, 4, 7, 1, 8, 0, 6, 2, 3, 5, 5, 3, 2, 6,
- 1, 8, 2, 7, 7, 2, 8, 1, 5, 4, 4, 5, 3, 6, 6, 3, 8, 2,
- 4, 6, 5, 5, 6, 4, 2, 8, 7, 3, 3, 7, 6, 5, 5, 6, 7, 4,
- 4, 7, 8, 3, 3, 8, 7, 5, 8, 4, 5, 7, 4, 8, 6, 6, 7, 6,
- 5, 8, 8, 5, 6, 7, 8, 6, 7, 7, 6, 8, 8, 7, 7, 8, 8, 8,
-};
-
-/**
- * This table is used for retrieving the current intra type
- * based on its neighbors and adjustment provided by
- * code read and decoded before.
- *
- * 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).
- */
-static const uint8_t rv30_itype_from_context[900] = {
- 0, 9, 9, 9, 9, 9, 9, 9, 9,
- 0, 2, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 2, 0, 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, 9, 9, 9, 9, 9, 9, 9,
-
- 0, 1, 9, 9, 9, 9, 9, 9, 9,
- 0, 2, 1, 6, 4, 8, 5, 7, 3,
- 1, 0, 2, 6, 5, 4, 3, 8, 7,
- 2, 8, 0, 1, 7, 4, 3, 6, 5,
- 2, 0, 1, 3, 8, 5, 4, 7, 6,
- 2, 0, 1, 4, 6, 7, 8, 3, 5,
- 0, 1, 5, 2, 6, 3, 8, 4, 7,
- 0, 1, 6, 2, 4, 7, 5, 8, 3,
- 2, 7, 0, 1, 4, 8, 6, 3, 5,
- 2, 8, 0, 1, 7, 3, 4, 5, 6,
-
- 1, 0, 9, 9, 9, 9, 9, 9, 9,
- 1, 2, 5, 6, 3, 0, 4, 8, 7,
- 1, 6, 2, 5, 3, 0, 4, 8, 7,
- 2, 1, 7, 6, 8, 3, 5, 0, 4,
- 1, 2, 5, 3, 6, 8, 4, 7, 0,
- 1, 6, 2, 0, 4, 5, 8, 7, 3,
- 1, 5, 2, 6, 3, 8, 4, 0, 7,
- 1, 6, 0, 2, 4, 5, 7, 3, 8,
- 2, 1, 7, 6, 0, 8, 5, 4, 3,
- 1, 2, 7, 8, 3, 4, 5, 6, 0,
-
- 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 0, 2, 1, 8, 7, 6, 5, 4, 3,
- 1, 2, 0, 6, 5, 7, 4, 8, 3,
- 2, 8, 7, 1, 0, 6, 4, 3, 5,
- 2, 0, 8, 1, 3, 7, 5, 4, 6,
- 2, 0, 4, 1, 7, 8, 6, 3, 5,
- 2, 0, 1, 5, 8, 4, 6, 7, 3,
- 2, 0, 6, 1, 4, 7, 8, 5, 3,
- 2, 7, 8, 1, 0, 5, 4, 6, 3,
- 2, 8, 7, 1, 0, 4, 3, 6, 5,
-
- 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 0, 2, 1, 3, 5, 8, 6, 4, 7,
- 1, 0, 2, 5, 3, 6, 4, 8, 7,
- 2, 8, 1, 0, 3, 5, 7, 6, 4,
- 3, 2, 5, 8, 1, 4, 6, 7, 0,
- 4, 2, 0, 6, 1, 5, 8, 3, 7,
- 5, 3, 1, 2, 8, 6, 4, 0, 7,
- 1, 6, 0, 2, 4, 5, 8, 3, 7,
- 2, 7, 0, 1, 5, 4, 8, 6, 3,
- 2, 8, 3, 5, 1, 0, 7, 6, 4,
-
- 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 2, 0, 6, 1, 4, 7, 5, 8, 3,
- 1, 6, 2, 0, 4, 5, 3, 7, 8,
- 2, 8, 7, 6, 4, 0, 1, 5, 3,
- 4, 2, 1, 0, 6, 8, 3, 5, 7,
- 4, 2, 6, 0, 1, 5, 7, 8, 3,
- 1, 2, 5, 0, 6, 3, 4, 7, 8,
- 6, 4, 0, 1, 2, 7, 5, 3, 8,
- 2, 7, 4, 6, 0, 1, 8, 5, 3,
- 2, 8, 7, 4, 6, 1, 3, 5, 0,
-
- 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 5, 1, 2, 3, 6, 8, 0, 4, 7,
- 1, 5, 6, 3, 2, 0, 4, 8, 7,
- 2, 1, 5, 3, 6, 8, 7, 4, 0,
- 5, 3, 1, 2, 6, 8, 4, 7, 0,
- 1, 6, 2, 4, 5, 8, 0, 3, 7,
- 5, 1, 3, 6, 2, 0, 8, 4, 7,
- 1, 6, 5, 2, 0, 4, 3, 7, 8,
- 2, 7, 1, 6, 5, 0, 8, 3, 4,
- 2, 5, 1, 3, 6, 8, 4, 0, 7,
-
- 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 1, 6, 2, 0, 5, 4, 3, 7, 8,
- 1, 6, 5, 4, 2, 3, 0, 7, 8,
- 2, 1, 6, 7, 4, 8, 5, 3, 0,
- 2, 1, 6, 5, 8, 4, 3, 0, 7,
- 6, 4, 1, 2, 0, 5, 7, 8, 3,
- 1, 6, 5, 2, 3, 0, 4, 8, 7,
- 6, 1, 4, 0, 2, 7, 5, 3, 8,
- 2, 7, 4, 6, 1, 5, 0, 8, 3,
- 2, 1, 6, 8, 4, 7, 3, 5, 0,
-
- 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 2, 0, 4, 7, 6, 1, 8, 5, 3,
- 6, 1, 2, 0, 4, 7, 5, 8, 3,
- 2, 7, 8, 0, 1, 6, 4, 3, 5,
- 2, 4, 0, 8, 3, 1, 7, 6, 5,
- 4, 2, 7, 0, 6, 1, 8, 5, 3,
- 2, 1, 0, 8, 5, 6, 7, 4, 3,
- 2, 6, 4, 1, 7, 0, 5, 8, 3,
- 2, 7, 4, 0, 8, 6, 1, 5, 3,
- 2, 8, 7, 4, 1, 0, 3, 6, 5,
-
- 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 2, 0, 8, 1, 3, 4, 6, 5, 7,
- 1, 2, 0, 6, 8, 5, 7, 3, 4,
- 2, 8, 7, 1, 0, 3, 6, 5, 4,
- 8, 3, 2, 5, 1, 0, 4, 7, 6,
- 2, 0, 4, 8, 5, 1, 7, 6, 3,
- 2, 1, 0, 8, 5, 3, 6, 4, 7,
- 2, 1, 6, 0, 8, 4, 5, 7, 3,
- 2, 7, 8, 4, 0, 6, 1, 5, 3,
- 2, 8, 3, 0, 7, 4, 1, 6, 5,
-};
-
-/**
- * Loop filter limits are taken from this table.
- */
-static const uint8_t rv30_loop_filt_lim[32] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5
-};
-#endif /* AVCODEC_RV30DATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/rv30dsp.c b/src/thirdparty/ffmpeg/libavcodec/rv30dsp.c
deleted file mode 100644
index 9ed56436f..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/rv30dsp.c
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
- * RV30 decoder motion compensation functions
- * Copyright (c) 2007 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
- */
-
-/**
- * @file
- * RV30 decoder motion compensation functions
- */
-
-#include "avcodec.h"
-#include "dsputil.h"
-#include "h264chroma.h"
-#include "h264qpel.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;\
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
- int i;\
- for(i = 0; i < h; i++)\
- {\
- OP(dst[0], (-(src[-1]+src[2]) + src[0]*C1 + src[1]*C2 + 8)>>4);\
- OP(dst[1], (-(src[ 0]+src[3]) + src[1]*C1 + src[2]*C2 + 8)>>4);\
- OP(dst[2], (-(src[ 1]+src[4]) + src[2]*C1 + src[3]*C2 + 8)>>4);\
- OP(dst[3], (-(src[ 2]+src[5]) + src[3]*C1 + src[4]*C2 + 8)>>4);\
- OP(dst[4], (-(src[ 3]+src[6]) + src[4]*C1 + src[5]*C2 + 8)>>4);\
- OP(dst[5], (-(src[ 4]+src[7]) + src[5]*C1 + src[6]*C2 + 8)>>4);\
- OP(dst[6], (-(src[ 5]+src[8]) + src[6]*C1 + src[7]*C2 + 8)>>4);\
- OP(dst[7], (-(src[ 6]+src[9]) + src[7]*C1 + src[8]*C2 + 8)>>4);\
- dst += dstStride;\
- src += srcStride;\
- }\
-}\
-\
-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;\
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
- int i;\
- for(i = 0; i < w; i++)\
- {\
- const int srcA = src[-1*srcStride];\
- 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];\
- OP(dst[0*dstStride], (-(srcA+src2) + src0*C1 + src1*C2 + 8)>>4);\
- OP(dst[1*dstStride], (-(src0+src3) + src1*C1 + src2*C2 + 8)>>4);\
- OP(dst[2*dstStride], (-(src1+src4) + src2*C1 + src3*C2 + 8)>>4);\
- OP(dst[3*dstStride], (-(src2+src5) + src3*C1 + src4*C2 + 8)>>4);\
- OP(dst[4*dstStride], (-(src3+src6) + src4*C1 + src5*C2 + 8)>>4);\
- OP(dst[5*dstStride], (-(src4+src7) + src5*C1 + src6*C2 + 8)>>4);\
- OP(dst[6*dstStride], (-(src5+src8) + src6*C1 + src7*C2 + 8)>>4);\
- OP(dst[7*dstStride], (-(src6+src9) + src7*C1 + src8*C2 + 8)>>4);\
- dst++;\
- src++;\
- }\
-}\
-\
-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;\
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
- int i, j;\
- for(j = 0; j < h; j++){\
- for(i = 0; i < w; i++){\
- OP(dst[i], (\
- src[srcStride*-1+i-1] -12*src[srcStride*-1+i] -6*src[srcStride*-1+i+1] +src[srcStride*-1+i+2]+\
- -12*src[srcStride* 0+i-1] +144*src[srcStride* 0+i] +72*src[srcStride* 0+i+1] -12*src[srcStride* 0+i+2] +\
- -6*src[srcStride* 1+i-1] +72*src[srcStride* 1+i] +36*src[srcStride* 1+i+1] -6*src[srcStride* 1+i+2] +\
- src[srcStride* 2+i-1] -12*src[srcStride* 2+i] -6*src[srcStride* 2+i+1] +src[srcStride* 2+i+2] +\
- 128)>>8);\
- }\
- src += srcStride;\
- dst += dstStride;\
- }\
-}\
-\
-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;\
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
- int i, j;\
- for(j = 0; j < h; j++){\
- for(i = 0; i < w; i++){\
- OP(dst[i], (\
- src[srcStride*-1+i-1] -12*src[srcStride*-1+i+1] -6*src[srcStride*-1+i] +src[srcStride*-1+i+2]+\
- -12*src[srcStride* 0+i-1] +144*src[srcStride* 0+i+1] +72*src[srcStride* 0+i] -12*src[srcStride* 0+i+2]+\
- -6*src[srcStride* 1+i-1] +72*src[srcStride* 1+i+1] +36*src[srcStride* 1+i] -6*src[srcStride* 1+i+2]+\
- src[srcStride* 2+i-1] -12*src[srcStride* 2+i+1] -6*src[srcStride* 2+i] +src[srcStride* 2+i+2]+\
- 128)>>8);\
- }\
- src += srcStride;\
- dst += dstStride;\
- }\
-}\
-\
-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;\
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
- int i, j;\
- for(j = 0; j < h; j++){\
- for(i = 0; i < w; i++){\
- OP(dst[i], (\
- src[srcStride*-1+i-1] -12*src[srcStride*-1+i] -6*src[srcStride*-1+i+1] +src[srcStride*-1+i+2]+\
- -6*src[srcStride* 0+i-1] +72*src[srcStride* 0+i] +36*src[srcStride* 0+i+1] -6*src[srcStride* 0+i+2]+\
- -12*src[srcStride* 1+i-1] +144*src[srcStride* 1+i] +72*src[srcStride* 1+i+1] -12*src[srcStride* 1+i+2]+\
- src[srcStride* 2+i-1] -12*src[srcStride* 2+i] -6*src[srcStride* 2+i+1] +src[srcStride* 2+i+2]+\
- 128)>>8);\
- }\
- src += srcStride;\
- dst += dstStride;\
- }\
-}\
-\
-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;\
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
- int i, j;\
- for(j = 0; j < h; j++){\
- for(i = 0; i < w; i++){\
- OP(dst[i], (\
- 36*src[i+srcStride*0] +54*src[i+1+srcStride*0] +6*src[i+2+srcStride*0]+\
- 54*src[i+srcStride*1] +81*src[i+1+srcStride*1] +9*src[i+2+srcStride*1]+\
- 6*src[i+srcStride*2] + 9*src[i+1+srcStride*2] + src[i+2+srcStride*2]+\
- 128)>>8);\
- }\
- src += srcStride;\
- dst += dstStride;\
- }\
-}\
-\
-static void OPNAME ## rv30_tpel16_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, const int C1, const int C2){\
- OPNAME ## rv30_tpel8_v_lowpass(dst , src , dstStride, srcStride, C1, C2);\
- OPNAME ## rv30_tpel8_v_lowpass(dst+8, src+8, dstStride, srcStride, C1, C2);\
- src += 8*srcStride;\
- dst += 8*dstStride;\
- OPNAME ## rv30_tpel8_v_lowpass(dst , src , dstStride, srcStride, C1, C2);\
- OPNAME ## rv30_tpel8_v_lowpass(dst+8, src+8, dstStride, srcStride, C1, C2);\
-}\
-\
-static void OPNAME ## rv30_tpel16_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, const int C1, const int C2){\
- OPNAME ## rv30_tpel8_h_lowpass(dst , src , dstStride, srcStride, C1, C2);\
- OPNAME ## rv30_tpel8_h_lowpass(dst+8, src+8, dstStride, srcStride, C1, C2);\
- src += 8*srcStride;\
- dst += 8*dstStride;\
- OPNAME ## rv30_tpel8_h_lowpass(dst , src , dstStride, srcStride, C1, C2);\
- OPNAME ## rv30_tpel8_h_lowpass(dst+8, src+8, dstStride, srcStride, C1, C2);\
-}\
-\
-static void OPNAME ## rv30_tpel16_hv_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
- OPNAME ## rv30_tpel8_hv_lowpass(dst , src , dstStride, srcStride);\
- OPNAME ## rv30_tpel8_hv_lowpass(dst+8, src+8, dstStride, srcStride);\
- src += 8*srcStride;\
- dst += 8*dstStride;\
- OPNAME ## rv30_tpel8_hv_lowpass(dst , src , dstStride, srcStride);\
- OPNAME ## rv30_tpel8_hv_lowpass(dst+8, src+8, dstStride, srcStride);\
-}\
-\
-static void OPNAME ## rv30_tpel16_hhv_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
- OPNAME ## rv30_tpel8_hhv_lowpass(dst , src , dstStride, srcStride);\
- OPNAME ## rv30_tpel8_hhv_lowpass(dst+8, src+8, dstStride, srcStride);\
- src += 8*srcStride;\
- dst += 8*dstStride;\
- OPNAME ## rv30_tpel8_hhv_lowpass(dst , src , dstStride, srcStride);\
- OPNAME ## rv30_tpel8_hhv_lowpass(dst+8, src+8, dstStride, srcStride);\
-}\
-\
-static void OPNAME ## rv30_tpel16_hvv_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
- OPNAME ## rv30_tpel8_hvv_lowpass(dst , src , dstStride, srcStride);\
- OPNAME ## rv30_tpel8_hvv_lowpass(dst+8, src+8, dstStride, srcStride);\
- src += 8*srcStride;\
- dst += 8*dstStride;\
- OPNAME ## rv30_tpel8_hvv_lowpass(dst , src , dstStride, srcStride);\
- OPNAME ## rv30_tpel8_hvv_lowpass(dst+8, src+8, dstStride, srcStride);\
-}\
-\
-static void OPNAME ## rv30_tpel16_hhvv_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
- OPNAME ## rv30_tpel8_hhvv_lowpass(dst , src , dstStride, srcStride);\
- OPNAME ## rv30_tpel8_hhvv_lowpass(dst+8, src+8, dstStride, srcStride);\
- src += 8*srcStride;\
- dst += 8*dstStride;\
- OPNAME ## rv30_tpel8_hhvv_lowpass(dst , src , dstStride, srcStride);\
- OPNAME ## rv30_tpel8_hhvv_lowpass(dst+8, src+8, dstStride, srcStride);\
-}\
-\
-
-#define RV30_MC(OPNAME, SIZE) \
-static void OPNAME ## rv30_tpel ## SIZE ## _mc10_c(uint8_t *dst, uint8_t *src, int stride){\
- OPNAME ## rv30_tpel ## SIZE ## _h_lowpass(dst, src, stride, stride, 12, 6);\
-}\
-\
-static void OPNAME ## rv30_tpel ## SIZE ## _mc20_c(uint8_t *dst, uint8_t *src, int stride){\
- OPNAME ## rv30_tpel ## SIZE ## _h_lowpass(dst, src, stride, stride, 6, 12);\
-}\
-\
-static void OPNAME ## rv30_tpel ## SIZE ## _mc01_c(uint8_t *dst, uint8_t *src, int stride){\
- OPNAME ## rv30_tpel ## SIZE ## _v_lowpass(dst, src, stride, stride, 12, 6);\
-}\
-\
-static void OPNAME ## rv30_tpel ## SIZE ## _mc02_c(uint8_t *dst, uint8_t *src, int stride){\
- OPNAME ## rv30_tpel ## SIZE ## _v_lowpass(dst, src, stride, stride, 6, 12);\
-}\
-\
-static void OPNAME ## rv30_tpel ## SIZE ## _mc11_c(uint8_t *dst, uint8_t *src, int stride){\
- OPNAME ## rv30_tpel ## SIZE ## _hv_lowpass(dst, src, stride, stride);\
-}\
-\
-static void OPNAME ## rv30_tpel ## SIZE ## _mc12_c(uint8_t *dst, uint8_t *src, int stride){\
- OPNAME ## rv30_tpel ## SIZE ## _hvv_lowpass(dst, src, stride, stride);\
-}\
-\
-static void OPNAME ## rv30_tpel ## SIZE ## _mc21_c(uint8_t *dst, uint8_t *src, int stride){\
- OPNAME ## rv30_tpel ## SIZE ## _hhv_lowpass(dst, src, stride, stride);\
-}\
-\
-static void OPNAME ## rv30_tpel ## SIZE ## _mc22_c(uint8_t *dst, uint8_t *src, int stride){\
- OPNAME ## rv30_tpel ## SIZE ## _hhvv_lowpass(dst, src, stride, stride);\
-}\
-\
-
-#define op_avg(a, b) a = (((a)+cm[b]+1)>>1)
-#define op_put(a, b) a = cm[b]
-
-RV30_LOWPASS(put_ , op_put)
-RV30_LOWPASS(avg_ , op_avg)
-RV30_MC(put_, 8)
-RV30_MC(put_, 16)
-RV30_MC(avg_, 8)
-RV30_MC(avg_, 16)
-
-av_cold void ff_rv30dsp_init(RV34DSPContext *c)
-{
- H264ChromaContext h264chroma;
- H264QpelContext qpel;
-
- ff_rv34dsp_init(c);
- ff_h264chroma_init(&h264chroma, 8);
- ff_h264qpel_init(&qpel, 8);
-
- c->put_pixels_tab[0][ 0] = qpel.put_h264_qpel_pixels_tab[0][0];
- c->put_pixels_tab[0][ 1] = put_rv30_tpel16_mc10_c;
- c->put_pixels_tab[0][ 2] = put_rv30_tpel16_mc20_c;
- c->put_pixels_tab[0][ 4] = put_rv30_tpel16_mc01_c;
- c->put_pixels_tab[0][ 5] = put_rv30_tpel16_mc11_c;
- c->put_pixels_tab[0][ 6] = put_rv30_tpel16_mc21_c;
- c->put_pixels_tab[0][ 8] = put_rv30_tpel16_mc02_c;
- c->put_pixels_tab[0][ 9] = put_rv30_tpel16_mc12_c;
- c->put_pixels_tab[0][10] = put_rv30_tpel16_mc22_c;
- c->avg_pixels_tab[0][ 0] = qpel.avg_h264_qpel_pixels_tab[0][0];
- c->avg_pixels_tab[0][ 1] = avg_rv30_tpel16_mc10_c;
- c->avg_pixels_tab[0][ 2] = avg_rv30_tpel16_mc20_c;
- c->avg_pixels_tab[0][ 4] = avg_rv30_tpel16_mc01_c;
- c->avg_pixels_tab[0][ 5] = avg_rv30_tpel16_mc11_c;
- c->avg_pixels_tab[0][ 6] = avg_rv30_tpel16_mc21_c;
- c->avg_pixels_tab[0][ 8] = avg_rv30_tpel16_mc02_c;
- c->avg_pixels_tab[0][ 9] = avg_rv30_tpel16_mc12_c;
- c->avg_pixels_tab[0][10] = avg_rv30_tpel16_mc22_c;
- c->put_pixels_tab[1][ 0] = qpel.put_h264_qpel_pixels_tab[1][0];
- c->put_pixels_tab[1][ 1] = put_rv30_tpel8_mc10_c;
- c->put_pixels_tab[1][ 2] = put_rv30_tpel8_mc20_c;
- c->put_pixels_tab[1][ 4] = put_rv30_tpel8_mc01_c;
- c->put_pixels_tab[1][ 5] = put_rv30_tpel8_mc11_c;
- c->put_pixels_tab[1][ 6] = put_rv30_tpel8_mc21_c;
- c->put_pixels_tab[1][ 8] = put_rv30_tpel8_mc02_c;
- c->put_pixels_tab[1][ 9] = put_rv30_tpel8_mc12_c;
- c->put_pixels_tab[1][10] = put_rv30_tpel8_mc22_c;
- c->avg_pixels_tab[1][ 0] = qpel.avg_h264_qpel_pixels_tab[1][0];
- c->avg_pixels_tab[1][ 1] = avg_rv30_tpel8_mc10_c;
- c->avg_pixels_tab[1][ 2] = avg_rv30_tpel8_mc20_c;
- c->avg_pixels_tab[1][ 4] = avg_rv30_tpel8_mc01_c;
- c->avg_pixels_tab[1][ 5] = avg_rv30_tpel8_mc11_c;
- c->avg_pixels_tab[1][ 6] = avg_rv30_tpel8_mc21_c;
- c->avg_pixels_tab[1][ 8] = avg_rv30_tpel8_mc02_c;
- c->avg_pixels_tab[1][ 9] = avg_rv30_tpel8_mc12_c;
- c->avg_pixels_tab[1][10] = avg_rv30_tpel8_mc22_c;
-
- c->put_chroma_pixels_tab[0] = h264chroma.put_h264_chroma_pixels_tab[0];
- c->put_chroma_pixels_tab[1] = h264chroma.put_h264_chroma_pixels_tab[1];
- c->avg_chroma_pixels_tab[0] = h264chroma.avg_h264_chroma_pixels_tab[0];
- c->avg_chroma_pixels_tab[1] = h264chroma.avg_h264_chroma_pixels_tab[1];
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/rv34.c b/src/thirdparty/ffmpeg/libavcodec/rv34.c
deleted file mode 100644
index c63ba75a3..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/rv34.c
+++ /dev/null
@@ -1,1796 +0,0 @@
-/*
- * RV30/40 decoder common data
- * Copyright (c) 2007 Mike Melanson, 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
- */
-
-/**
- * @file
- * RV30/40 decoder common data
- */
-
-#include "libavutil/imgutils.h"
-#include "libavutil/internal.h"
-
-#include "avcodec.h"
-#include "mpegvideo.h"
-#include "golomb.h"
-#include "internal.h"
-#include "mathops.h"
-#include "rectangle.h"
-#include "thread.h"
-
-#include "rv34vlc.h"
-#include "rv34data.h"
-#include "rv34.h"
-
-//#define DEBUG
-
-static inline void ZERO8x2(void* dst, int stride)
-{
- fill_rectangle(dst, 1, 2, stride, 0, 4);
- fill_rectangle(((uint8_t*)(dst))+4, 1, 2, stride, 0, 4);
-}
-
-/** translation of RV30/40 macroblock types to lavc ones */
-static const int rv34_mb_type_to_lavc[12] = {
- MB_TYPE_INTRA,
- MB_TYPE_INTRA16x16 | MB_TYPE_SEPARATE_DC,
- MB_TYPE_16x16 | MB_TYPE_L0,
- MB_TYPE_8x8 | MB_TYPE_L0,
- MB_TYPE_16x16 | MB_TYPE_L0,
- MB_TYPE_16x16 | MB_TYPE_L1,
- MB_TYPE_SKIP,
- MB_TYPE_DIRECT2 | MB_TYPE_16x16,
- MB_TYPE_16x8 | MB_TYPE_L0,
- MB_TYPE_8x16 | MB_TYPE_L0,
- MB_TYPE_16x16 | MB_TYPE_L0L1,
- MB_TYPE_16x16 | MB_TYPE_L0 | MB_TYPE_SEPARATE_DC
-};
-
-
-static RV34VLC intra_vlcs[NUM_INTRA_TABLES], inter_vlcs[NUM_INTER_TABLES];
-
-static int rv34_decode_mv(RV34DecContext *r, int block_type);
-
-/**
- * @name RV30/40 VLC generating functions
- * @{
- */
-
-static const int table_offs[] = {
- 0, 1818, 3622, 4144, 4698, 5234, 5804, 5868, 5900, 5932,
- 5996, 6252, 6316, 6348, 6380, 7674, 8944, 10274, 11668, 12250,
- 14060, 15846, 16372, 16962, 17512, 18148, 18180, 18212, 18244, 18308,
- 18564, 18628, 18660, 18692, 20036, 21314, 22648, 23968, 24614, 26384,
- 28190, 28736, 29366, 29938, 30608, 30640, 30672, 30704, 30768, 31024,
- 31088, 31120, 31184, 32570, 33898, 35236, 36644, 37286, 39020, 40802,
- 41368, 42052, 42692, 43348, 43380, 43412, 43444, 43476, 43604, 43668,
- 43700, 43732, 45100, 46430, 47778, 49160, 49802, 51550, 53340, 53972,
- 54648, 55348, 55994, 56122, 56154, 56186, 56218, 56346, 56410, 56442,
- 56474, 57878, 59290, 60636, 62036, 62682, 64460, 64524, 64588, 64716,
- 64844, 66076, 67466, 67978, 68542, 69064, 69648, 70296, 72010, 72074,
- 72138, 72202, 72330, 73572, 74936, 75454, 76030, 76566, 77176, 77822,
- 79582, 79646, 79678, 79742, 79870, 81180, 82536, 83064, 83672, 84242,
- 84934, 85576, 87384, 87448, 87480, 87544, 87672, 88982, 90340, 90902,
- 91598, 92182, 92846, 93488, 95246, 95278, 95310, 95374, 95502, 96878,
- 98266, 98848, 99542, 100234, 100884, 101524, 103320, 103352, 103384, 103416,
- 103480, 104874, 106222, 106910, 107584, 108258, 108902, 109544, 111366, 111398,
- 111430, 111462, 111494, 112878, 114320, 114988, 115660, 116310, 116950, 117592
-};
-
-static VLC_TYPE table_data[117592][2];
-
-/**
- * Generate VLC from codeword lengths.
- * @param bits codeword lengths (zeroes are accepted)
- * @param size length of input data
- * @param vlc output VLC
- * @param insyms symbols for input codes (NULL for default ones)
- * @param num VLC table number (for static initialization)
- */
-static void rv34_gen_vlc(const uint8_t *bits, int size, VLC *vlc, const uint8_t *insyms,
- const int num)
-{
- int i;
- int counts[17] = {0}, codes[17];
- uint16_t cw[MAX_VLC_SIZE], syms[MAX_VLC_SIZE];
- uint8_t bits2[MAX_VLC_SIZE];
- int maxbits = 0, realsize = 0;
-
- for(i = 0; i < size; i++){
- if(bits[i]){
- bits2[realsize] = bits[i];
- syms[realsize] = insyms ? insyms[i] : i;
- realsize++;
- maxbits = FFMAX(maxbits, bits[i]);
- counts[bits[i]]++;
- }
- }
-
- codes[0] = 0;
- for(i = 0; i < 16; i++)
- codes[i+1] = (codes[i] + counts[i]) << 1;
- for(i = 0; i < realsize; i++)
- cw[i] = codes[bits2[i]]++;
-
- vlc->table = &table_data[table_offs[num]];
- vlc->table_allocated = table_offs[num + 1] - table_offs[num];
- ff_init_vlc_sparse(vlc, FFMIN(maxbits, 9), realsize,
- bits2, 1, 1,
- cw, 2, 2,
- syms, 2, 2, INIT_VLC_USE_NEW_STATIC);
-}
-
-/**
- * Initialize all tables.
- */
-static av_cold void rv34_init_tables(void)
-{
- int i, j, k;
-
- for(i = 0; i < NUM_INTRA_TABLES; i++){
- for(j = 0; j < 2; j++){
- rv34_gen_vlc(rv34_table_intra_cbppat [i][j], CBPPAT_VLC_SIZE, &intra_vlcs[i].cbppattern[j], NULL, 19*i + 0 + j);
- rv34_gen_vlc(rv34_table_intra_secondpat[i][j], OTHERBLK_VLC_SIZE, &intra_vlcs[i].second_pattern[j], NULL, 19*i + 2 + j);
- rv34_gen_vlc(rv34_table_intra_thirdpat [i][j], OTHERBLK_VLC_SIZE, &intra_vlcs[i].third_pattern[j], NULL, 19*i + 4 + j);
- for(k = 0; k < 4; k++){
- rv34_gen_vlc(rv34_table_intra_cbp[i][j+k*2], CBP_VLC_SIZE, &intra_vlcs[i].cbp[j][k], rv34_cbp_code, 19*i + 6 + j*4 + k);
- }
- }
- for(j = 0; j < 4; j++){
- rv34_gen_vlc(rv34_table_intra_firstpat[i][j], FIRSTBLK_VLC_SIZE, &intra_vlcs[i].first_pattern[j], NULL, 19*i + 14 + j);
- }
- rv34_gen_vlc(rv34_intra_coeff[i], COEFF_VLC_SIZE, &intra_vlcs[i].coefficient, NULL, 19*i + 18);
- }
-
- for(i = 0; i < NUM_INTER_TABLES; i++){
- rv34_gen_vlc(rv34_inter_cbppat[i], CBPPAT_VLC_SIZE, &inter_vlcs[i].cbppattern[0], NULL, i*12 + 95);
- for(j = 0; j < 4; j++){
- rv34_gen_vlc(rv34_inter_cbp[i][j], CBP_VLC_SIZE, &inter_vlcs[i].cbp[0][j], rv34_cbp_code, i*12 + 96 + j);
- }
- for(j = 0; j < 2; j++){
- rv34_gen_vlc(rv34_table_inter_firstpat [i][j], FIRSTBLK_VLC_SIZE, &inter_vlcs[i].first_pattern[j], NULL, i*12 + 100 + j);
- rv34_gen_vlc(rv34_table_inter_secondpat[i][j], OTHERBLK_VLC_SIZE, &inter_vlcs[i].second_pattern[j], NULL, i*12 + 102 + j);
- rv34_gen_vlc(rv34_table_inter_thirdpat [i][j], OTHERBLK_VLC_SIZE, &inter_vlcs[i].third_pattern[j], NULL, i*12 + 104 + j);
- }
- rv34_gen_vlc(rv34_inter_coeff[i], COEFF_VLC_SIZE, &inter_vlcs[i].coefficient, NULL, i*12 + 106);
- }
-}
-
-/** @} */ // vlc group
-
-/**
- * @name RV30/40 4x4 block decoding functions
- * @{
- */
-
-/**
- * Decode coded block pattern.
- */
-static int rv34_decode_cbp(GetBitContext *gb, RV34VLC *vlc, int table)
-{
- int pattern, code, cbp=0;
- int ones;
- static const int cbp_masks[3] = {0x100000, 0x010000, 0x110000};
- static const int shifts[4] = { 0, 2, 8, 10 };
- const int *curshift = shifts;
- int i, t, mask;
-
- code = get_vlc2(gb, vlc->cbppattern[table].table, 9, 2);
- pattern = code & 0xF;
- code >>= 4;
-
- ones = rv34_count_ones[pattern];
-
- for(mask = 8; mask; mask >>= 1, curshift++){
- if(pattern & mask)
- cbp |= get_vlc2(gb, vlc->cbp[table][ones].table, vlc->cbp[table][ones].bits, 1) << curshift[0];
- }
-
- for(i = 0; i < 4; i++){
- t = (modulo_three_table[code] >> (6 - 2*i)) & 3;
- if(t == 1)
- cbp |= cbp_masks[get_bits1(gb)] << i;
- if(t == 2)
- cbp |= cbp_masks[2] << i;
- }
- return cbp;
-}
-
-/**
- * Get one coefficient value from the bitstream and store it.
- */
-static inline void decode_coeff(int16_t *dst, int coef, int esc, GetBitContext *gb, VLC* vlc, int q)
-{
- if(coef){
- if(coef == esc){
- coef = get_vlc2(gb, vlc->table, 9, 2);
- if(coef > 23){
- coef -= 23;
- coef = 22 + ((1 << coef) | get_bits(gb, coef));
- }
- coef += esc;
- }
- if(get_bits1(gb))
- coef = -coef;
- *dst = (coef*q + 8) >> 4;
- }
-}
-
-/**
- * Decode 2x2 subblock of coefficients.
- */
-static inline void decode_subblock(int16_t *dst, int code, const int is_block2, GetBitContext *gb, VLC *vlc, int q)
-{
- int flags = modulo_three_table[code];
-
- decode_coeff( dst+0*4+0, (flags >> 6) , 3, gb, vlc, q);
- if(is_block2){
- decode_coeff(dst+1*4+0, (flags >> 4) & 3, 2, gb, vlc, q);
- decode_coeff(dst+0*4+1, (flags >> 2) & 3, 2, gb, vlc, q);
- }else{
- decode_coeff(dst+0*4+1, (flags >> 4) & 3, 2, gb, vlc, q);
- decode_coeff(dst+1*4+0, (flags >> 2) & 3, 2, gb, vlc, q);
- }
- decode_coeff( dst+1*4+1, (flags >> 0) & 3, 2, gb, vlc, q);
-}
-
-/**
- * Decode a single coefficient.
- */
-static inline void decode_subblock1(int16_t *dst, int code, GetBitContext *gb, VLC *vlc, int q)
-{
- int coeff = modulo_three_table[code] >> 6;
- decode_coeff(dst, coeff, 3, gb, vlc, q);
-}
-
-static inline void decode_subblock3(int16_t *dst, int code, GetBitContext *gb, VLC *vlc,
- int q_dc, int q_ac1, int q_ac2)
-{
- int flags = modulo_three_table[code];
-
- decode_coeff(dst+0*4+0, (flags >> 6) , 3, gb, vlc, q_dc);
- decode_coeff(dst+0*4+1, (flags >> 4) & 3, 2, gb, vlc, q_ac1);
- decode_coeff(dst+1*4+0, (flags >> 2) & 3, 2, gb, vlc, q_ac1);
- decode_coeff(dst+1*4+1, (flags >> 0) & 3, 2, gb, vlc, q_ac2);
-}
-
-/**
- * Decode coefficients for 4x4 block.
- *
- * This is done by filling 2x2 subblocks with decoded coefficients
- * in this order (the same for subblocks and subblock coefficients):
- * o--o
- * /
- * /
- * o--o
- */
-
-static int rv34_decode_block(int16_t *dst, GetBitContext *gb, RV34VLC *rvlc, int fc, int sc, int q_dc, int q_ac1, int q_ac2)
-{
- int code, pattern, has_ac = 1;
-
- code = get_vlc2(gb, rvlc->first_pattern[fc].table, 9, 2);
-
- pattern = code & 0x7;
-
- code >>= 3;
-
- if (modulo_three_table[code] & 0x3F) {
- decode_subblock3(dst, code, gb, &rvlc->coefficient, q_dc, q_ac1, q_ac2);
- } else {
- decode_subblock1(dst, code, gb, &rvlc->coefficient, q_dc);
- if (!pattern)
- return 0;
- has_ac = 0;
- }
-
- if(pattern & 4){
- code = get_vlc2(gb, rvlc->second_pattern[sc].table, 9, 2);
- decode_subblock(dst + 4*0+2, code, 0, gb, &rvlc->coefficient, q_ac2);
- }
- if(pattern & 2){ // Looks like coefficients 1 and 2 are swapped for this block
- code = get_vlc2(gb, rvlc->second_pattern[sc].table, 9, 2);
- decode_subblock(dst + 4*2+0, code, 1, gb, &rvlc->coefficient, q_ac2);
- }
- if(pattern & 1){
- code = get_vlc2(gb, rvlc->third_pattern[sc].table, 9, 2);
- decode_subblock(dst + 4*2+2, code, 0, gb, &rvlc->coefficient, q_ac2);
- }
- return has_ac | pattern;
-}
-
-/**
- * @name RV30/40 bitstream parsing
- * @{
- */
-
-/**
- * Decode starting slice position.
- * @todo Maybe replace with ff_h263_decode_mba() ?
- */
-int ff_rv34_get_start_offset(GetBitContext *gb, int mb_size)
-{
- int i;
- for(i = 0; i < 5; i++)
- if(rv34_mb_max_sizes[i] >= mb_size - 1)
- break;
- return rv34_mb_bits_sizes[i];
-}
-
-/**
- * Select VLC set for decoding from current quantizer, modifier and frame type.
- */
-static inline RV34VLC* choose_vlc_set(int quant, int mod, int type)
-{
- if(mod == 2 && quant < 19) quant += 10;
- else if(mod && quant < 26) quant += 5;
- return type ? &inter_vlcs[rv34_quant_to_vlc_set[1][av_clip(quant, 0, 30)]]
- : &intra_vlcs[rv34_quant_to_vlc_set[0][av_clip(quant, 0, 30)]];
-}
-
-/**
- * Decode intra macroblock header and return CBP in case of success, -1 otherwise.
- */
-static int rv34_decode_intra_mb_header(RV34DecContext *r, int8_t *intra_types)
-{
- MpegEncContext *s = &r->s;
- GetBitContext *gb = &s->gb;
- int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
- int t;
-
- r->is16 = get_bits1(gb);
- if(r->is16){
- s->current_picture_ptr->f.mb_type[mb_pos] = MB_TYPE_INTRA16x16;
- r->block_type = RV34_MB_TYPE_INTRA16x16;
- t = get_bits(gb, 2);
- fill_rectangle(intra_types, 4, 4, r->intra_types_stride, t, sizeof(intra_types[0]));
- r->luma_vlc = 2;
- }else{
- if(!r->rv30){
- if(!get_bits1(gb))
- av_log(s->avctx, AV_LOG_ERROR, "Need DQUANT\n");
- }
- s->current_picture_ptr->f.mb_type[mb_pos] = MB_TYPE_INTRA;
- r->block_type = RV34_MB_TYPE_INTRA;
- if(r->decode_intra_types(r, gb, intra_types) < 0)
- return -1;
- r->luma_vlc = 1;
- }
-
- r->chroma_vlc = 0;
- r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 0);
-
- return rv34_decode_cbp(gb, r->cur_vlcs, r->is16);
-}
-
-/**
- * Decode inter macroblock header and return CBP in case of success, -1 otherwise.
- */
-static int rv34_decode_inter_mb_header(RV34DecContext *r, int8_t *intra_types)
-{
- MpegEncContext *s = &r->s;
- GetBitContext *gb = &s->gb;
- int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
- int i, t;
-
- r->block_type = r->decode_mb_info(r);
- if(r->block_type == -1)
- return -1;
- s->current_picture_ptr->f.mb_type[mb_pos] = rv34_mb_type_to_lavc[r->block_type];
- r->mb_type[mb_pos] = r->block_type;
- if(r->block_type == RV34_MB_SKIP){
- if(s->pict_type == AV_PICTURE_TYPE_P)
- r->mb_type[mb_pos] = RV34_MB_P_16x16;
- if(s->pict_type == AV_PICTURE_TYPE_B)
- r->mb_type[mb_pos] = RV34_MB_B_DIRECT;
- }
- r->is16 = !!IS_INTRA16x16(s->current_picture_ptr->f.mb_type[mb_pos]);
- rv34_decode_mv(r, r->block_type);
- if(r->block_type == RV34_MB_SKIP){
- fill_rectangle(intra_types, 4, 4, r->intra_types_stride, 0, sizeof(intra_types[0]));
- return 0;
- }
- r->chroma_vlc = 1;
- r->luma_vlc = 0;
-
- if(IS_INTRA(s->current_picture_ptr->f.mb_type[mb_pos])){
- if(r->is16){
- t = get_bits(gb, 2);
- fill_rectangle(intra_types, 4, 4, r->intra_types_stride, t, sizeof(intra_types[0]));
- r->luma_vlc = 2;
- }else{
- if(r->decode_intra_types(r, gb, intra_types) < 0)
- return -1;
- r->luma_vlc = 1;
- }
- r->chroma_vlc = 0;
- r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 0);
- }else{
- for(i = 0; i < 16; i++)
- intra_types[(i & 3) + (i>>2) * r->intra_types_stride] = 0;
- r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 1);
- if(r->mb_type[mb_pos] == RV34_MB_P_MIX16x16){
- r->is16 = 1;
- r->chroma_vlc = 1;
- r->luma_vlc = 2;
- r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 0);
- }
- }
-
- return rv34_decode_cbp(gb, r->cur_vlcs, r->is16);
-}
-
-/** @} */ //bitstream functions
-
-/**
- * @name motion vector related code (prediction, reconstruction, motion compensation)
- * @{
- */
-
-/** macroblock partition width in 8x8 blocks */
-static const uint8_t part_sizes_w[RV34_MB_TYPES] = { 2, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2 };
-
-/** macroblock partition height in 8x8 blocks */
-static const uint8_t part_sizes_h[RV34_MB_TYPES] = { 2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2 };
-
-/** availability index for subblocks */
-static const uint8_t avail_indexes[4] = { 6, 7, 10, 11 };
-
-/**
- * motion vector prediction
- *
- * Motion prediction performed for the block by using median prediction of
- * motion vectors from the left, top and right top blocks but in corner cases
- * some other vectors may be used instead.
- */
-static void rv34_pred_mv(RV34DecContext *r, int block_type, int subblock_no, int dmv_no)
-{
- MpegEncContext *s = &r->s;
- int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride;
- int A[2] = {0}, B[2], C[2];
- int i, j;
- int mx, my;
- int* avail = r->avail_cache + avail_indexes[subblock_no];
- int c_off = part_sizes_w[block_type];
-
- mv_pos += (subblock_no & 1) + (subblock_no >> 1)*s->b8_stride;
- if(subblock_no == 3)
- c_off = -1;
-
- if(avail[-1]){
- A[0] = s->current_picture_ptr->f.motion_val[0][mv_pos-1][0];
- A[1] = s->current_picture_ptr->f.motion_val[0][mv_pos-1][1];
- }
- if(avail[-4]){
- B[0] = s->current_picture_ptr->f.motion_val[0][mv_pos-s->b8_stride][0];
- B[1] = s->current_picture_ptr->f.motion_val[0][mv_pos-s->b8_stride][1];
- }else{
- B[0] = A[0];
- B[1] = A[1];
- }
- if(!avail[c_off-4]){
- if(avail[-4] && (avail[-1] || r->rv30)){
- C[0] = s->current_picture_ptr->f.motion_val[0][mv_pos-s->b8_stride-1][0];
- C[1] = s->current_picture_ptr->f.motion_val[0][mv_pos-s->b8_stride-1][1];
- }else{
- C[0] = A[0];
- C[1] = A[1];
- }
- }else{
- C[0] = s->current_picture_ptr->f.motion_val[0][mv_pos-s->b8_stride+c_off][0];
- C[1] = s->current_picture_ptr->f.motion_val[0][mv_pos-s->b8_stride+c_off][1];
- }
- mx = mid_pred(A[0], B[0], C[0]);
- my = mid_pred(A[1], B[1], C[1]);
- mx += r->dmv[dmv_no][0];
- my += r->dmv[dmv_no][1];
- for(j = 0; j < part_sizes_h[block_type]; j++){
- for(i = 0; i < part_sizes_w[block_type]; i++){
- s->current_picture_ptr->f.motion_val[0][mv_pos + i + j*s->b8_stride][0] = mx;
- s->current_picture_ptr->f.motion_val[0][mv_pos + i + j*s->b8_stride][1] = my;
- }
- }
-}
-
-#define GET_PTS_DIFF(a, b) ((a - b + 8192) & 0x1FFF)
-
-/**
- * Calculate motion vector component that should be added for direct blocks.
- */
-static int calc_add_mv(RV34DecContext *r, int dir, int val)
-{
- int mul = dir ? -r->mv_weight2 : r->mv_weight1;
-
- return (val * mul + 0x2000) >> 14;
-}
-
-/**
- * Predict motion vector for B-frame macroblock.
- */
-static inline void rv34_pred_b_vector(int A[2], int B[2], int C[2],
- int A_avail, int B_avail, int C_avail,
- int *mx, int *my)
-{
- if(A_avail + B_avail + C_avail != 3){
- *mx = A[0] + B[0] + C[0];
- *my = A[1] + B[1] + C[1];
- if(A_avail + B_avail + C_avail == 2){
- *mx /= 2;
- *my /= 2;
- }
- }else{
- *mx = mid_pred(A[0], B[0], C[0]);
- *my = mid_pred(A[1], B[1], C[1]);
- }
-}
-
-/**
- * motion vector prediction for B-frames
- */
-static void rv34_pred_mv_b(RV34DecContext *r, int block_type, int dir)
-{
- MpegEncContext *s = &r->s;
- int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
- int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride;
- int A[2] = { 0 }, B[2] = { 0 }, C[2] = { 0 };
- int has_A = 0, has_B = 0, has_C = 0;
- int mx, my;
- int i, j;
- Picture *cur_pic = s->current_picture_ptr;
- const int mask = dir ? MB_TYPE_L1 : MB_TYPE_L0;
- int type = cur_pic->f.mb_type[mb_pos];
-
- if((r->avail_cache[6-1] & type) & mask){
- A[0] = cur_pic->f.motion_val[dir][mv_pos - 1][0];
- A[1] = cur_pic->f.motion_val[dir][mv_pos - 1][1];
- has_A = 1;
- }
- if((r->avail_cache[6-4] & type) & mask){
- B[0] = cur_pic->f.motion_val[dir][mv_pos - s->b8_stride][0];
- B[1] = cur_pic->f.motion_val[dir][mv_pos - s->b8_stride][1];
- has_B = 1;
- }
- if(r->avail_cache[6-4] && (r->avail_cache[6-2] & type) & mask){
- C[0] = cur_pic->f.motion_val[dir][mv_pos - s->b8_stride + 2][0];
- C[1] = cur_pic->f.motion_val[dir][mv_pos - s->b8_stride + 2][1];
- has_C = 1;
- }else if((s->mb_x+1) == s->mb_width && (r->avail_cache[6-5] & type) & mask){
- C[0] = cur_pic->f.motion_val[dir][mv_pos - s->b8_stride - 1][0];
- C[1] = cur_pic->f.motion_val[dir][mv_pos - s->b8_stride - 1][1];
- has_C = 1;
- }
-
- rv34_pred_b_vector(A, B, C, has_A, has_B, has_C, &mx, &my);
-
- mx += r->dmv[dir][0];
- my += r->dmv[dir][1];
-
- for(j = 0; j < 2; j++){
- for(i = 0; i < 2; i++){
- cur_pic->f.motion_val[dir][mv_pos + i + j*s->b8_stride][0] = mx;
- cur_pic->f.motion_val[dir][mv_pos + i + j*s->b8_stride][1] = my;
- }
- }
- if(block_type == RV34_MB_B_BACKWARD || block_type == RV34_MB_B_FORWARD){
- ZERO8x2(cur_pic->f.motion_val[!dir][mv_pos], s->b8_stride);
- }
-}
-
-/**
- * motion vector prediction - RV3 version
- */
-static void rv34_pred_mv_rv3(RV34DecContext *r, int block_type, int dir)
-{
- MpegEncContext *s = &r->s;
- int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride;
- int A[2] = {0}, B[2], C[2];
- int i, j, k;
- int mx, my;
- int* avail = r->avail_cache + avail_indexes[0];
-
- if(avail[-1]){
- A[0] = s->current_picture_ptr->f.motion_val[0][mv_pos - 1][0];
- A[1] = s->current_picture_ptr->f.motion_val[0][mv_pos - 1][1];
- }
- if(avail[-4]){
- B[0] = s->current_picture_ptr->f.motion_val[0][mv_pos - s->b8_stride][0];
- B[1] = s->current_picture_ptr->f.motion_val[0][mv_pos - s->b8_stride][1];
- }else{
- B[0] = A[0];
- B[1] = A[1];
- }
- if(!avail[-4 + 2]){
- if(avail[-4] && (avail[-1])){
- C[0] = s->current_picture_ptr->f.motion_val[0][mv_pos - s->b8_stride - 1][0];
- C[1] = s->current_picture_ptr->f.motion_val[0][mv_pos - s->b8_stride - 1][1];
- }else{
- C[0] = A[0];
- C[1] = A[1];
- }
- }else{
- C[0] = s->current_picture_ptr->f.motion_val[0][mv_pos - s->b8_stride + 2][0];
- C[1] = s->current_picture_ptr->f.motion_val[0][mv_pos - s->b8_stride + 2][1];
- }
- mx = mid_pred(A[0], B[0], C[0]);
- my = mid_pred(A[1], B[1], C[1]);
- mx += r->dmv[0][0];
- my += r->dmv[0][1];
- for(j = 0; j < 2; j++){
- for(i = 0; i < 2; i++){
- for(k = 0; k < 2; k++){
- s->current_picture_ptr->f.motion_val[k][mv_pos + i + j*s->b8_stride][0] = mx;
- s->current_picture_ptr->f.motion_val[k][mv_pos + i + j*s->b8_stride][1] = my;
- }
- }
- }
-}
-
-static const int chroma_coeffs[3] = { 0, 3, 5 };
-
-/**
- * generic motion compensation function
- *
- * @param r decoder context
- * @param block_type type of the current block
- * @param xoff horizontal offset from the start of the current block
- * @param yoff vertical offset from the start of the current block
- * @param mv_off offset to the motion vector information
- * @param width width of the current partition in 8x8 blocks
- * @param height height of the current partition in 8x8 blocks
- * @param dir motion compensation direction (i.e. from the last or the next reference frame)
- * @param thirdpel motion vectors are specified in 1/3 of pixel
- * @param qpel_mc a set of functions used to perform luma motion compensation
- * @param chroma_mc a set of functions used to perform chroma motion compensation
- */
-static inline void rv34_mc(RV34DecContext *r, const int block_type,
- const int xoff, const int yoff, int mv_off,
- const int width, const int height, int dir,
- const int thirdpel, int weighted,
- qpel_mc_func (*qpel_mc)[16],
- h264_chroma_mc_func (*chroma_mc))
-{
- MpegEncContext *s = &r->s;
- uint8_t *Y, *U, *V, *srcY, *srcU, *srcV;
- int dxy, mx, my, umx, umy, lx, ly, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;
- int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride + mv_off;
- int is16x16 = 1;
-
- if(thirdpel){
- int chroma_mx, chroma_my;
- mx = (s->current_picture_ptr->f.motion_val[dir][mv_pos][0] + (3 << 24)) / 3 - (1 << 24);
- my = (s->current_picture_ptr->f.motion_val[dir][mv_pos][1] + (3 << 24)) / 3 - (1 << 24);
- lx = (s->current_picture_ptr->f.motion_val[dir][mv_pos][0] + (3 << 24)) % 3;
- ly = (s->current_picture_ptr->f.motion_val[dir][mv_pos][1] + (3 << 24)) % 3;
- chroma_mx = s->current_picture_ptr->f.motion_val[dir][mv_pos][0] / 2;
- chroma_my = s->current_picture_ptr->f.motion_val[dir][mv_pos][1] / 2;
- umx = (chroma_mx + (3 << 24)) / 3 - (1 << 24);
- umy = (chroma_my + (3 << 24)) / 3 - (1 << 24);
- uvmx = chroma_coeffs[(chroma_mx + (3 << 24)) % 3];
- uvmy = chroma_coeffs[(chroma_my + (3 << 24)) % 3];
- }else{
- int cx, cy;
- mx = s->current_picture_ptr->f.motion_val[dir][mv_pos][0] >> 2;
- my = s->current_picture_ptr->f.motion_val[dir][mv_pos][1] >> 2;
- lx = s->current_picture_ptr->f.motion_val[dir][mv_pos][0] & 3;
- ly = s->current_picture_ptr->f.motion_val[dir][mv_pos][1] & 3;
- cx = s->current_picture_ptr->f.motion_val[dir][mv_pos][0] / 2;
- cy = s->current_picture_ptr->f.motion_val[dir][mv_pos][1] / 2;
- umx = cx >> 2;
- umy = cy >> 2;
- uvmx = (cx & 3) << 1;
- uvmy = (cy & 3) << 1;
- //due to some flaw RV40 uses the same MC compensation routine for H2V2 and H3V3
- if(uvmx == 6 && uvmy == 6)
- uvmx = uvmy = 4;
- }
-
- if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) {
- /* wait for the referenced mb row to be finished */
- int mb_row = s->mb_y + ((yoff + my + 5 + 8 * height) >> 4);
- AVFrame *f = dir ? &s->next_picture_ptr->f : &s->last_picture_ptr->f;
- ff_thread_await_progress(f, mb_row, 0);
- }
-
- 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];
- 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;
- uvsrc_y = s->mb_y * 8 + (yoff >> 1) + umy;
- srcY += src_y * s->linesize + src_x;
- srcU += uvsrc_y * s->uvlinesize + uvsrc_x;
- srcV += uvsrc_y * s->uvlinesize + uvsrc_x;
- if(s->h_edge_pos - (width << 3) < 6 || s->v_edge_pos - (height << 3) < 6 ||
- (unsigned)(src_x - !!lx*2) > s->h_edge_pos - !!lx*2 - (width <<3) - 4 ||
- (unsigned)(src_y - !!ly*2) > s->v_edge_pos - !!ly*2 - (height<<3) - 4) {
- uint8_t *uvbuf = s->edge_emu_buffer + 22 * s->linesize;
-
- srcY -= 2 + 2*s->linesize;
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize, (width<<3)+6, (height<<3)+6,
- src_x - 2, src_y - 2, s->h_edge_pos, s->v_edge_pos);
- srcY = s->edge_emu_buffer + 2 + 2*s->linesize;
- s->vdsp.emulated_edge_mc(uvbuf , srcU, s->uvlinesize, (width<<2)+1, (height<<2)+1,
- uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1);
- s->vdsp.emulated_edge_mc(uvbuf + 16, srcV, s->uvlinesize, (width<<2)+1, (height<<2)+1,
- uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1);
- srcU = uvbuf;
- srcV = uvbuf + 16;
- }
- if(!weighted){
- Y = s->dest[0] + xoff + yoff *s->linesize;
- U = s->dest[1] + (xoff>>1) + (yoff>>1)*s->uvlinesize;
- V = s->dest[2] + (xoff>>1) + (yoff>>1)*s->uvlinesize;
- }else{
- Y = r->tmp_b_block_y [dir] + xoff + yoff *s->linesize;
- U = r->tmp_b_block_uv[dir*2] + (xoff>>1) + (yoff>>1)*s->uvlinesize;
- V = r->tmp_b_block_uv[dir*2+1] + (xoff>>1) + (yoff>>1)*s->uvlinesize;
- }
-
- if(block_type == RV34_MB_P_16x8){
- qpel_mc[1][dxy](Y, srcY, s->linesize);
- Y += 8;
- srcY += 8;
- }else if(block_type == RV34_MB_P_8x16){
- qpel_mc[1][dxy](Y, srcY, s->linesize);
- Y += 8 * s->linesize;
- srcY += 8 * s->linesize;
- }
- is16x16 = (block_type != RV34_MB_P_8x8) && (block_type != RV34_MB_P_16x8) && (block_type != RV34_MB_P_8x16);
- qpel_mc[!is16x16][dxy](Y, srcY, s->linesize);
- chroma_mc[2-width] (U, srcU, s->uvlinesize, height*4, uvmx, uvmy);
- chroma_mc[2-width] (V, srcV, s->uvlinesize, height*4, uvmx, uvmy);
-}
-
-static void rv34_mc_1mv(RV34DecContext *r, const int block_type,
- const int xoff, const int yoff, int mv_off,
- const int width, const int height, int dir)
-{
- rv34_mc(r, block_type, xoff, yoff, mv_off, width, height, dir, r->rv30, 0,
- r->rdsp.put_pixels_tab,
- r->rdsp.put_chroma_pixels_tab);
-}
-
-static void rv4_weight(RV34DecContext *r)
-{
- r->rdsp.rv40_weight_pixels_tab[r->scaled_weight][0](r->s.dest[0],
- r->tmp_b_block_y[0],
- r->tmp_b_block_y[1],
- r->weight1,
- r->weight2,
- r->s.linesize);
- r->rdsp.rv40_weight_pixels_tab[r->scaled_weight][1](r->s.dest[1],
- r->tmp_b_block_uv[0],
- r->tmp_b_block_uv[2],
- r->weight1,
- r->weight2,
- r->s.uvlinesize);
- r->rdsp.rv40_weight_pixels_tab[r->scaled_weight][1](r->s.dest[2],
- r->tmp_b_block_uv[1],
- r->tmp_b_block_uv[3],
- r->weight1,
- r->weight2,
- r->s.uvlinesize);
-}
-
-static void rv34_mc_2mv(RV34DecContext *r, const int block_type)
-{
- int weighted = !r->rv30 && block_type != RV34_MB_B_BIDIR && r->weight1 != 8192;
-
- rv34_mc(r, block_type, 0, 0, 0, 2, 2, 0, r->rv30, weighted,
- r->rdsp.put_pixels_tab,
- r->rdsp.put_chroma_pixels_tab);
- if(!weighted){
- rv34_mc(r, block_type, 0, 0, 0, 2, 2, 1, r->rv30, 0,
- r->rdsp.avg_pixels_tab,
- r->rdsp.avg_chroma_pixels_tab);
- }else{
- rv34_mc(r, block_type, 0, 0, 0, 2, 2, 1, r->rv30, 1,
- r->rdsp.put_pixels_tab,
- r->rdsp.put_chroma_pixels_tab);
- rv4_weight(r);
- }
-}
-
-static void rv34_mc_2mv_skip(RV34DecContext *r)
-{
- int i, j;
- int weighted = !r->rv30 && r->weight1 != 8192;
-
- for(j = 0; j < 2; j++)
- for(i = 0; i < 2; i++){
- rv34_mc(r, RV34_MB_P_8x8, i*8, j*8, i+j*r->s.b8_stride, 1, 1, 0, r->rv30,
- weighted,
- r->rdsp.put_pixels_tab,
- r->rdsp.put_chroma_pixels_tab);
- rv34_mc(r, RV34_MB_P_8x8, i*8, j*8, i+j*r->s.b8_stride, 1, 1, 1, r->rv30,
- weighted,
- weighted ? r->rdsp.put_pixels_tab : r->rdsp.avg_pixels_tab,
- weighted ? r->rdsp.put_chroma_pixels_tab : r->rdsp.avg_chroma_pixels_tab);
- }
- if(weighted)
- rv4_weight(r);
-}
-
-/** number of motion vectors in each macroblock type */
-static const int num_mvs[RV34_MB_TYPES] = { 0, 0, 1, 4, 1, 1, 0, 0, 2, 2, 2, 1 };
-
-/**
- * Decode motion vector differences
- * and perform motion vector reconstruction and motion compensation.
- */
-static int rv34_decode_mv(RV34DecContext *r, int block_type)
-{
- MpegEncContext *s = &r->s;
- GetBitContext *gb = &s->gb;
- int i, j, k, l;
- int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride;
- int next_bt;
-
- memset(r->dmv, 0, sizeof(r->dmv));
- for(i = 0; i < num_mvs[block_type]; i++){
- r->dmv[i][0] = svq3_get_se_golomb(gb);
- r->dmv[i][1] = svq3_get_se_golomb(gb);
- }
- switch(block_type){
- case RV34_MB_TYPE_INTRA:
- case RV34_MB_TYPE_INTRA16x16:
- ZERO8x2(s->current_picture_ptr->f.motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride);
- return 0;
- case RV34_MB_SKIP:
- if(s->pict_type == AV_PICTURE_TYPE_P){
- ZERO8x2(s->current_picture_ptr->f.motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride);
- rv34_mc_1mv (r, block_type, 0, 0, 0, 2, 2, 0);
- break;
- }
- case RV34_MB_B_DIRECT:
- //surprisingly, it uses motion scheme from next reference frame
- /* wait for the current mb row to be finished */
- if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME))
- ff_thread_await_progress(&s->next_picture_ptr->f, FFMAX(0, s->mb_y-1), 0);
-
- next_bt = s->next_picture_ptr->f.mb_type[s->mb_x + s->mb_y * s->mb_stride];
- if(IS_INTRA(next_bt) || IS_SKIP(next_bt)){
- ZERO8x2(s->current_picture_ptr->f.motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride);
- ZERO8x2(s->current_picture_ptr->f.motion_val[1][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride);
- }else
- for(j = 0; j < 2; j++)
- for(i = 0; i < 2; i++)
- for(k = 0; k < 2; k++)
- for(l = 0; l < 2; l++)
- s->current_picture_ptr->f.motion_val[l][mv_pos + i + j*s->b8_stride][k] = calc_add_mv(r, l, s->next_picture_ptr->f.motion_val[0][mv_pos + i + j*s->b8_stride][k]);
- if(!(IS_16X8(next_bt) || IS_8X16(next_bt) || IS_8X8(next_bt))) //we can use whole macroblock MC
- rv34_mc_2mv(r, block_type);
- else
- rv34_mc_2mv_skip(r);
- ZERO8x2(s->current_picture_ptr->f.motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], s->b8_stride);
- break;
- case RV34_MB_P_16x16:
- case RV34_MB_P_MIX16x16:
- rv34_pred_mv(r, block_type, 0, 0);
- rv34_mc_1mv (r, block_type, 0, 0, 0, 2, 2, 0);
- break;
- case RV34_MB_B_FORWARD:
- case RV34_MB_B_BACKWARD:
- r->dmv[1][0] = r->dmv[0][0];
- r->dmv[1][1] = r->dmv[0][1];
- if(r->rv30)
- rv34_pred_mv_rv3(r, block_type, block_type == RV34_MB_B_BACKWARD);
- else
- rv34_pred_mv_b (r, block_type, block_type == RV34_MB_B_BACKWARD);
- rv34_mc_1mv (r, block_type, 0, 0, 0, 2, 2, block_type == RV34_MB_B_BACKWARD);
- break;
- case RV34_MB_P_16x8:
- case RV34_MB_P_8x16:
- rv34_pred_mv(r, block_type, 0, 0);
- rv34_pred_mv(r, block_type, 1 + (block_type == RV34_MB_P_16x8), 1);
- if(block_type == RV34_MB_P_16x8){
- rv34_mc_1mv(r, block_type, 0, 0, 0, 2, 1, 0);
- rv34_mc_1mv(r, block_type, 0, 8, s->b8_stride, 2, 1, 0);
- }
- if(block_type == RV34_MB_P_8x16){
- rv34_mc_1mv(r, block_type, 0, 0, 0, 1, 2, 0);
- rv34_mc_1mv(r, block_type, 8, 0, 1, 1, 2, 0);
- }
- break;
- case RV34_MB_B_BIDIR:
- rv34_pred_mv_b (r, block_type, 0);
- rv34_pred_mv_b (r, block_type, 1);
- rv34_mc_2mv (r, block_type);
- break;
- case RV34_MB_P_8x8:
- for(i=0;i< 4;i++){
- rv34_pred_mv(r, block_type, i, i);
- rv34_mc_1mv (r, block_type, (i&1)<<3, (i&2)<<2, (i&1)+(i>>1)*s->b8_stride, 1, 1, 0);
- }
- break;
- }
-
- return 0;
-}
-/** @} */ // mv group
-
-/**
- * @name Macroblock reconstruction functions
- * @{
- */
-/** mapping of RV30/40 intra prediction types to standard H.264 types */
-static const int ittrans[9] = {
- DC_PRED, VERT_PRED, HOR_PRED, DIAG_DOWN_RIGHT_PRED, DIAG_DOWN_LEFT_PRED,
- VERT_RIGHT_PRED, VERT_LEFT_PRED, HOR_UP_PRED, HOR_DOWN_PRED,
-};
-
-/** mapping of RV30/40 intra 16x16 prediction types to standard H.264 types */
-static const int ittrans16[4] = {
- DC_PRED8x8, VERT_PRED8x8, HOR_PRED8x8, PLANE_PRED8x8,
-};
-
-/**
- * Perform 4x4 intra prediction.
- */
-static void rv34_pred_4x4_block(RV34DecContext *r, uint8_t *dst, int stride, int itype, int up, int left, int down, int right)
-{
- uint8_t *prev = dst - stride + 4;
- uint32_t topleft;
-
- if(!up && !left)
- itype = DC_128_PRED;
- else if(!up){
- if(itype == VERT_PRED) itype = HOR_PRED;
- if(itype == DC_PRED) itype = LEFT_DC_PRED;
- }else if(!left){
- if(itype == HOR_PRED) itype = VERT_PRED;
- if(itype == DC_PRED) itype = TOP_DC_PRED;
- if(itype == DIAG_DOWN_LEFT_PRED) itype = DIAG_DOWN_LEFT_PRED_RV40_NODOWN;
- }
- if(!down){
- if(itype == DIAG_DOWN_LEFT_PRED) itype = DIAG_DOWN_LEFT_PRED_RV40_NODOWN;
- if(itype == HOR_UP_PRED) itype = HOR_UP_PRED_RV40_NODOWN;
- if(itype == VERT_LEFT_PRED) itype = VERT_LEFT_PRED_RV40_NODOWN;
- }
- if(!right && up){
- topleft = dst[-stride + 3] * 0x01010101u;
- prev = (uint8_t*)&topleft;
- }
- r->h.pred4x4[itype](dst, prev, stride);
-}
-
-static inline int adjust_pred16(int itype, int up, int left)
-{
- if(!up && !left)
- itype = DC_128_PRED8x8;
- else if(!up){
- if(itype == PLANE_PRED8x8)itype = HOR_PRED8x8;
- if(itype == VERT_PRED8x8) itype = HOR_PRED8x8;
- if(itype == DC_PRED8x8) itype = LEFT_DC_PRED8x8;
- }else if(!left){
- if(itype == PLANE_PRED8x8)itype = VERT_PRED8x8;
- if(itype == HOR_PRED8x8) itype = VERT_PRED8x8;
- if(itype == DC_PRED8x8) itype = TOP_DC_PRED8x8;
- }
- return itype;
-}
-
-static inline void rv34_process_block(RV34DecContext *r,
- uint8_t *pdst, int stride,
- int fc, int sc, int q_dc, int q_ac)
-{
- MpegEncContext *s = &r->s;
- int16_t *ptr = s->block[0];
- int has_ac = rv34_decode_block(ptr, &s->gb, r->cur_vlcs,
- fc, sc, q_dc, q_ac, q_ac);
- if(has_ac){
- r->rdsp.rv34_idct_add(pdst, stride, ptr);
- }else{
- r->rdsp.rv34_idct_dc_add(pdst, stride, ptr[0]);
- ptr[0] = 0;
- }
-}
-
-static void rv34_output_i16x16(RV34DecContext *r, int8_t *intra_types, int cbp)
-{
- LOCAL_ALIGNED_16(int16_t, block16, [16]);
- MpegEncContext *s = &r->s;
- GetBitContext *gb = &s->gb;
- int q_dc = rv34_qscale_tab[ r->luma_dc_quant_i[s->qscale] ],
- q_ac = rv34_qscale_tab[s->qscale];
- uint8_t *dst = s->dest[0];
- int16_t *ptr = s->block[0];
- int i, j, itype, has_ac;
-
- memset(block16, 0, 16 * sizeof(*block16));
-
- has_ac = rv34_decode_block(block16, gb, r->cur_vlcs, 3, 0, q_dc, q_dc, q_ac);
- if(has_ac)
- r->rdsp.rv34_inv_transform(block16);
- else
- r->rdsp.rv34_inv_transform_dc(block16);
-
- itype = ittrans16[intra_types[0]];
- itype = adjust_pred16(itype, r->avail_cache[6-4], r->avail_cache[6-1]);
- r->h.pred16x16[itype](dst, s->linesize);
-
- for(j = 0; j < 4; j++){
- for(i = 0; i < 4; i++, cbp >>= 1){
- int dc = block16[i + j*4];
-
- if(cbp & 1){
- has_ac = rv34_decode_block(ptr, gb, r->cur_vlcs, r->luma_vlc, 0, q_ac, q_ac, q_ac);
- }else
- has_ac = 0;
-
- if(has_ac){
- ptr[0] = dc;
- r->rdsp.rv34_idct_add(dst+4*i, s->linesize, ptr);
- }else
- r->rdsp.rv34_idct_dc_add(dst+4*i, s->linesize, dc);
- }
-
- dst += 4*s->linesize;
- }
-
- itype = ittrans16[intra_types[0]];
- if(itype == PLANE_PRED8x8) itype = DC_PRED8x8;
- itype = adjust_pred16(itype, r->avail_cache[6-4], r->avail_cache[6-1]);
-
- q_dc = rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]];
- q_ac = rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]];
-
- for(j = 1; j < 3; j++){
- dst = s->dest[j];
- r->h.pred8x8[itype](dst, s->uvlinesize);
- for(i = 0; i < 4; i++, cbp >>= 1){
- uint8_t *pdst;
- if(!(cbp & 1)) continue;
- pdst = dst + (i&1)*4 + (i&2)*2*s->uvlinesize;
-
- rv34_process_block(r, pdst, s->uvlinesize,
- r->chroma_vlc, 1, q_dc, q_ac);
- }
- }
-}
-
-static void rv34_output_intra(RV34DecContext *r, int8_t *intra_types, int cbp)
-{
- MpegEncContext *s = &r->s;
- uint8_t *dst = s->dest[0];
- int avail[6*8] = {0};
- int i, j, k;
- int idx, q_ac, q_dc;
-
- // Set neighbour information.
- if(r->avail_cache[1])
- avail[0] = 1;
- if(r->avail_cache[2])
- avail[1] = avail[2] = 1;
- if(r->avail_cache[3])
- avail[3] = avail[4] = 1;
- if(r->avail_cache[4])
- avail[5] = 1;
- if(r->avail_cache[5])
- avail[8] = avail[16] = 1;
- if(r->avail_cache[9])
- avail[24] = avail[32] = 1;
-
- q_ac = rv34_qscale_tab[s->qscale];
- for(j = 0; j < 4; j++){
- idx = 9 + j*8;
- for(i = 0; i < 4; i++, cbp >>= 1, dst += 4, idx++){
- rv34_pred_4x4_block(r, dst, s->linesize, ittrans[intra_types[i]], avail[idx-8], avail[idx-1], avail[idx+7], avail[idx-7]);
- avail[idx] = 1;
- if(!(cbp & 1)) continue;
-
- rv34_process_block(r, dst, s->linesize,
- r->luma_vlc, 0, q_ac, q_ac);
- }
- dst += s->linesize * 4 - 4*4;
- intra_types += r->intra_types_stride;
- }
-
- intra_types -= r->intra_types_stride * 4;
-
- q_dc = rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]];
- q_ac = rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]];
-
- for(k = 0; k < 2; k++){
- dst = s->dest[1+k];
- fill_rectangle(r->avail_cache + 6, 2, 2, 4, 0, 4);
-
- for(j = 0; j < 2; j++){
- int* acache = r->avail_cache + 6 + j*4;
- for(i = 0; i < 2; i++, cbp >>= 1, acache++){
- int itype = ittrans[intra_types[i*2+j*2*r->intra_types_stride]];
- rv34_pred_4x4_block(r, dst+4*i, s->uvlinesize, itype, acache[-4], acache[-1], !i && !j, acache[-3]);
- acache[0] = 1;
-
- if(!(cbp&1)) continue;
-
- rv34_process_block(r, dst + 4*i, s->uvlinesize,
- r->chroma_vlc, 1, q_dc, q_ac);
- }
-
- dst += 4*s->uvlinesize;
- }
- }
-}
-
-static int is_mv_diff_gt_3(int16_t (*motion_val)[2], int step)
-{
- int d;
- d = motion_val[0][0] - motion_val[-step][0];
- if(d < -3 || d > 3)
- return 1;
- d = motion_val[0][1] - motion_val[-step][1];
- if(d < -3 || d > 3)
- return 1;
- return 0;
-}
-
-static int rv34_set_deblock_coef(RV34DecContext *r)
-{
- MpegEncContext *s = &r->s;
- int hmvmask = 0, vmvmask = 0, i, j;
- int midx = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride;
- int16_t (*motion_val)[2] = &s->current_picture_ptr->f.motion_val[0][midx];
- for(j = 0; j < 16; j += 8){
- for(i = 0; i < 2; i++){
- if(is_mv_diff_gt_3(motion_val + i, 1))
- vmvmask |= 0x11 << (j + i*2);
- if((j || s->mb_y) && is_mv_diff_gt_3(motion_val + i, s->b8_stride))
- hmvmask |= 0x03 << (j + i*2);
- }
- motion_val += s->b8_stride;
- }
- if(s->first_slice_line)
- hmvmask &= ~0x000F;
- if(!s->mb_x)
- vmvmask &= ~0x1111;
- if(r->rv30){ //RV30 marks both subblocks on the edge for filtering
- vmvmask |= (vmvmask & 0x4444) >> 1;
- hmvmask |= (hmvmask & 0x0F00) >> 4;
- if(s->mb_x)
- r->deblock_coefs[s->mb_x - 1 + s->mb_y*s->mb_stride] |= (vmvmask & 0x1111) << 3;
- if(!s->first_slice_line)
- r->deblock_coefs[s->mb_x + (s->mb_y - 1)*s->mb_stride] |= (hmvmask & 0xF) << 12;
- }
- return hmvmask | vmvmask;
-}
-
-static int rv34_decode_inter_macroblock(RV34DecContext *r, int8_t *intra_types)
-{
- MpegEncContext *s = &r->s;
- GetBitContext *gb = &s->gb;
- uint8_t *dst = s->dest[0];
- int16_t *ptr = s->block[0];
- int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
- int cbp, cbp2;
- int q_dc, q_ac, has_ac;
- int i, j;
- int dist;
-
- // Calculate which neighbours are available. Maybe it's worth optimizing too.
- memset(r->avail_cache, 0, sizeof(r->avail_cache));
- fill_rectangle(r->avail_cache + 6, 2, 2, 4, 1, 4);
- dist = (s->mb_x - s->resync_mb_x) + (s->mb_y - s->resync_mb_y) * s->mb_width;
- if(s->mb_x && dist)
- r->avail_cache[5] =
- r->avail_cache[9] = s->current_picture_ptr->f.mb_type[mb_pos - 1];
- if(dist >= s->mb_width)
- r->avail_cache[2] =
- r->avail_cache[3] = s->current_picture_ptr->f.mb_type[mb_pos - s->mb_stride];
- if(((s->mb_x+1) < s->mb_width) && dist >= s->mb_width - 1)
- r->avail_cache[4] = s->current_picture_ptr->f.mb_type[mb_pos - s->mb_stride + 1];
- if(s->mb_x && dist > s->mb_width)
- r->avail_cache[1] = s->current_picture_ptr->f.mb_type[mb_pos - s->mb_stride - 1];
-
- s->qscale = r->si.quant;
- cbp = cbp2 = rv34_decode_inter_mb_header(r, intra_types);
- r->cbp_luma [mb_pos] = cbp;
- r->cbp_chroma[mb_pos] = cbp >> 16;
- r->deblock_coefs[mb_pos] = rv34_set_deblock_coef(r) | r->cbp_luma[mb_pos];
- s->current_picture_ptr->f.qscale_table[mb_pos] = s->qscale;
-
- if(cbp == -1)
- return -1;
-
- if (IS_INTRA(s->current_picture_ptr->f.mb_type[mb_pos])){
- if(r->is16) rv34_output_i16x16(r, intra_types, cbp);
- else rv34_output_intra(r, intra_types, cbp);
- return 0;
- }
-
- if(r->is16){
- // Only for RV34_MB_P_MIX16x16
- LOCAL_ALIGNED_16(int16_t, block16, [16]);
- memset(block16, 0, 16 * sizeof(*block16));
- q_dc = rv34_qscale_tab[ r->luma_dc_quant_p[s->qscale] ];
- q_ac = rv34_qscale_tab[s->qscale];
- if (rv34_decode_block(block16, gb, r->cur_vlcs, 3, 0, q_dc, q_dc, q_ac))
- r->rdsp.rv34_inv_transform(block16);
- else
- r->rdsp.rv34_inv_transform_dc(block16);
-
- q_ac = rv34_qscale_tab[s->qscale];
-
- for(j = 0; j < 4; j++){
- for(i = 0; i < 4; i++, cbp >>= 1){
- int dc = block16[i + j*4];
-
- if(cbp & 1){
- has_ac = rv34_decode_block(ptr, gb, r->cur_vlcs, r->luma_vlc, 0, q_ac, q_ac, q_ac);
- }else
- has_ac = 0;
-
- if(has_ac){
- ptr[0] = dc;
- r->rdsp.rv34_idct_add(dst+4*i, s->linesize, ptr);
- }else
- r->rdsp.rv34_idct_dc_add(dst+4*i, s->linesize, dc);
- }
-
- dst += 4*s->linesize;
- }
-
- r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 1);
- }else{
- q_ac = rv34_qscale_tab[s->qscale];
-
- for(j = 0; j < 4; j++){
- for(i = 0; i < 4; i++, cbp >>= 1){
- if(!(cbp & 1)) continue;
-
- rv34_process_block(r, dst + 4*i, s->linesize,
- r->luma_vlc, 0, q_ac, q_ac);
- }
- dst += 4*s->linesize;
- }
- }
-
- q_dc = rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]];
- q_ac = rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]];
-
- for(j = 1; j < 3; j++){
- dst = s->dest[j];
- for(i = 0; i < 4; i++, cbp >>= 1){
- uint8_t *pdst;
- if(!(cbp & 1)) continue;
- pdst = dst + (i&1)*4 + (i&2)*2*s->uvlinesize;
-
- rv34_process_block(r, pdst, s->uvlinesize,
- r->chroma_vlc, 1, q_dc, q_ac);
- }
- }
-
- return 0;
-}
-
-static int rv34_decode_intra_macroblock(RV34DecContext *r, int8_t *intra_types)
-{
- MpegEncContext *s = &r->s;
- int cbp, dist;
- int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
-
- // Calculate which neighbours are available. Maybe it's worth optimizing too.
- memset(r->avail_cache, 0, sizeof(r->avail_cache));
- fill_rectangle(r->avail_cache + 6, 2, 2, 4, 1, 4);
- dist = (s->mb_x - s->resync_mb_x) + (s->mb_y - s->resync_mb_y) * s->mb_width;
- if(s->mb_x && dist)
- r->avail_cache[5] =
- r->avail_cache[9] = s->current_picture_ptr->f.mb_type[mb_pos - 1];
- if(dist >= s->mb_width)
- r->avail_cache[2] =
- r->avail_cache[3] = s->current_picture_ptr->f.mb_type[mb_pos - s->mb_stride];
- if(((s->mb_x+1) < s->mb_width) && dist >= s->mb_width - 1)
- r->avail_cache[4] = s->current_picture_ptr->f.mb_type[mb_pos - s->mb_stride + 1];
- if(s->mb_x && dist > s->mb_width)
- r->avail_cache[1] = s->current_picture_ptr->f.mb_type[mb_pos - s->mb_stride - 1];
-
- s->qscale = r->si.quant;
- cbp = rv34_decode_intra_mb_header(r, intra_types);
- r->cbp_luma [mb_pos] = cbp;
- r->cbp_chroma[mb_pos] = cbp >> 16;
- r->deblock_coefs[mb_pos] = 0xFFFF;
- s->current_picture_ptr->f.qscale_table[mb_pos] = s->qscale;
-
- if(cbp == -1)
- return -1;
-
- if(r->is16){
- rv34_output_i16x16(r, intra_types, cbp);
- return 0;
- }
-
- rv34_output_intra(r, intra_types, cbp);
- return 0;
-}
-
-static int check_slice_end(RV34DecContext *r, MpegEncContext *s)
-{
- int bits;
- if(s->mb_y >= s->mb_height)
- return 1;
- if(!s->mb_num_left)
- return 1;
- if(r->s.mb_skip_run > 1)
- return 0;
- bits = get_bits_left(&s->gb);
- if(bits <= 0 || (bits < 8 && !show_bits(&s->gb, bits)))
- return 1;
- return 0;
-}
-
-
-static void rv34_decoder_free(RV34DecContext *r)
-{
- av_freep(&r->intra_types_hist);
- r->intra_types = NULL;
- av_freep(&r->tmp_b_block_base);
- av_freep(&r->mb_type);
- av_freep(&r->cbp_luma);
- av_freep(&r->cbp_chroma);
- av_freep(&r->deblock_coefs);
-}
-
-
-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 *
- sizeof(*r->cbp_chroma));
- r->cbp_luma = av_malloc(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 *
- sizeof(*r->deblock_coefs));
- r->intra_types_hist = av_malloc(r->intra_types_stride * 4 * 2 *
- sizeof(*r->intra_types_hist));
- r->mb_type = av_mallocz(r->s.mb_stride * r->s.mb_height *
- sizeof(*r->mb_type));
-
- if (!(r->cbp_chroma && r->cbp_luma && r->deblock_coefs &&
- r->intra_types_hist && r->mb_type)) {
- rv34_decoder_free(r);
- return AVERROR(ENOMEM);
- }
-
- r->intra_types = r->intra_types_hist + r->intra_types_stride * 4;
-
- return 0;
-}
-
-
-static int rv34_decoder_realloc(RV34DecContext *r)
-{
- rv34_decoder_free(r);
- return rv34_decoder_alloc(r);
-}
-
-
-static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int buf_size)
-{
- MpegEncContext *s = &r->s;
- GetBitContext *gb = &s->gb;
- int mb_pos, slice_type;
- int res;
-
- init_get_bits(&r->s.gb, buf, buf_size*8);
- res = r->parse_slice_header(r, gb, &r->si);
- if(res < 0){
- av_log(s->avctx, AV_LOG_ERROR, "Incorrect or unknown slice header\n");
- return -1;
- }
-
- slice_type = r->si.type ? r->si.type : AV_PICTURE_TYPE_I;
- if (slice_type != s->pict_type) {
- av_log(s->avctx, AV_LOG_ERROR, "Slice type mismatch\n");
- return AVERROR_INVALIDDATA;
- }
- if (s->width != r->si.width || s->height != r->si.height) {
- av_log(s->avctx, AV_LOG_ERROR, "Size mismatch\n");
- return AVERROR_INVALIDDATA;
- }
-
- r->si.end = end;
- s->qscale = r->si.quant;
- s->mb_num_left = r->si.end - r->si.start;
- r->s.mb_skip_run = 0;
-
- mb_pos = s->mb_x + s->mb_y * s->mb_width;
- if(r->si.start != mb_pos){
- av_log(s->avctx, AV_LOG_ERROR, "Slice indicates MB offset %d, got %d\n", r->si.start, mb_pos);
- s->mb_x = r->si.start % s->mb_width;
- s->mb_y = r->si.start / s->mb_width;
- }
- memset(r->intra_types_hist, -1, r->intra_types_stride * 4 * 2 * sizeof(*r->intra_types_hist));
- s->first_slice_line = 1;
- s->resync_mb_x = s->mb_x;
- s->resync_mb_y = s->mb_y;
-
- ff_init_block_index(s);
- while(!check_slice_end(r, s)) {
- ff_update_block_index(s);
-
- if(r->si.type)
- res = rv34_decode_inter_macroblock(r, r->intra_types + s->mb_x * 4 + 4);
- else
- res = rv34_decode_intra_macroblock(r, r->intra_types + s->mb_x * 4 + 4);
- if(res < 0){
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_ERROR);
- return -1;
- }
- if (++s->mb_x == s->mb_width) {
- s->mb_x = 0;
- s->mb_y++;
- ff_init_block_index(s);
-
- memmove(r->intra_types_hist, r->intra_types, r->intra_types_stride * 4 * sizeof(*r->intra_types_hist));
- memset(r->intra_types, -1, r->intra_types_stride * 4 * sizeof(*r->intra_types_hist));
-
- if(r->loop_filter && s->mb_y >= 2)
- r->loop_filter(r, s->mb_y - 2);
-
- if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME))
- ff_thread_report_progress(&s->current_picture_ptr->f,
- s->mb_y - 2, 0);
-
- }
- if(s->mb_x == s->resync_mb_x)
- s->first_slice_line=0;
- s->mb_num_left--;
- }
- ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, ER_MB_END);
-
- return s->mb_y == s->mb_height;
-}
-
-/** @} */ // recons group end
-
-/**
- * Initialize decoder.
- */
-av_cold int ff_rv34_decode_init(AVCodecContext *avctx)
-{
- RV34DecContext *r = avctx->priv_data;
- MpegEncContext *s = &r->s;
- int ret;
-
- ff_MPV_decode_defaults(s);
- s->avctx = avctx;
- s->out_format = FMT_H263;
- s->codec_id = avctx->codec_id;
-
- s->width = avctx->width;
- 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;
-
- if ((ret = ff_MPV_common_init(s)) < 0)
- return ret;
-
- ff_h264_pred_init(&r->h, AV_CODEC_ID_RV40, 8, 1);
-
-#if CONFIG_RV30_DECODER
- if (avctx->codec_id == AV_CODEC_ID_RV30)
- ff_rv30dsp_init(&r->rdsp);
-#endif
-#if CONFIG_RV40_DECODER
- if (avctx->codec_id == AV_CODEC_ID_RV40)
- ff_rv40dsp_init(&r->rdsp);
-#endif
-
- if ((ret = rv34_decoder_alloc(r)) < 0)
- return ret;
-
- if(!intra_vlcs[0].cbppattern[0].bits)
- rv34_init_tables();
-
- return 0;
-}
-
-int ff_rv34_decode_init_thread_copy(AVCodecContext *avctx)
-{
- int err;
- RV34DecContext *r = avctx->priv_data;
-
- r->s.avctx = avctx;
-
- if (avctx->internal->is_copy) {
- r->tmp_b_block_base = NULL;
- if ((err = ff_MPV_common_init(&r->s)) < 0)
- return err;
- if ((err = rv34_decoder_alloc(r)) < 0)
- return err;
- }
- return 0;
-}
-
-int ff_rv34_decode_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
-{
- RV34DecContext *r = dst->priv_data, *r1 = src->priv_data;
- MpegEncContext * const s = &r->s, * const s1 = &r1->s;
- int err;
-
- if (dst == src || !s1->context_initialized)
- return 0;
-
- if (s->height != s1->height || s->width != s1->width) {
- s->height = s1->height;
- s->width = s1->width;
- if ((err = ff_MPV_common_frame_size_change(s)) < 0)
- return err;
- if ((err = rv34_decoder_realloc(r)) < 0)
- return err;
- }
-
- if ((err = ff_mpeg_update_thread_context(dst, src)))
- return err;
-
- r->cur_pts = r1->cur_pts;
- r->last_pts = r1->last_pts;
- r->next_pts = r1->next_pts;
-
- memset(&r->si, 0, sizeof(r->si));
-
- return 0;
-}
-
-static int get_slice_offset(AVCodecContext *avctx, const uint8_t *buf, int n)
-{
- if(avctx->slice_count) return avctx->slice_offset[n];
- else return AV_RL32(buf + n*8 - 4) == 1 ? AV_RL32(buf + n*8) : AV_RB32(buf + n*8);
-}
-
-static int finish_frame(AVCodecContext *avctx, AVFrame *pict)
-{
- RV34DecContext *r = avctx->priv_data;
- MpegEncContext *s = &r->s;
- int got_picture = 0;
-
- ff_er_frame_end(s);
- ff_MPV_frame_end(s);
- s->mb_num_left = 0;
-
- if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME))
- ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, 0);
-
- if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
- *pict = s->current_picture_ptr->f;
- got_picture = 1;
- } else if (s->last_picture_ptr != NULL) {
- *pict = s->last_picture_ptr->f;
- got_picture = 1;
- }
- if (got_picture)
- ff_print_debug_info(s, pict);
-
- return got_picture;
-}
-
-int ff_rv34_decode_frame(AVCodecContext *avctx,
- void *data, int *got_picture_ptr,
- AVPacket *avpkt)
-{
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
- RV34DecContext *r = avctx->priv_data;
- MpegEncContext *s = &r->s;
- AVFrame *pict = data;
- SliceInfo si;
- int i;
- int slice_count;
- const uint8_t *slices_hdr = NULL;
- int last = 0;
-
- /* no supplementary picture */
- if (buf_size == 0) {
- /* special case for last picture */
- if (s->low_delay==0 && s->next_picture_ptr) {
- *pict = s->next_picture_ptr->f;
- s->next_picture_ptr = NULL;
-
- *got_picture_ptr = 1;
- }
- return 0;
- }
-
- if(!avctx->slice_count){
- slice_count = (*buf++) + 1;
- slices_hdr = buf + 4;
- buf += 8 * slice_count;
- buf_size -= 1 + 8 * slice_count;
- }else
- slice_count = avctx->slice_count;
-
- //parse first slice header to check whether this frame can be decoded
- if(get_slice_offset(avctx, slices_hdr, 0) < 0 ||
- get_slice_offset(avctx, slices_hdr, 0) > buf_size){
- av_log(avctx, AV_LOG_ERROR, "Slice offset is invalid\n");
- return AVERROR_INVALIDDATA;
- }
- init_get_bits(&s->gb, buf+get_slice_offset(avctx, slices_hdr, 0), (buf_size-get_slice_offset(avctx, slices_hdr, 0))*8);
- if(r->parse_slice_header(r, &r->s.gb, &si) < 0 || si.start){
- 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]) &&
- si.type == AV_PICTURE_TYPE_B) {
- av_log(avctx, AV_LOG_ERROR, "Invalid decoder state: B-frame without "
- "reference data.\n");
- return AVERROR_INVALIDDATA;
- }
- if( (avctx->skip_frame >= AVDISCARD_NONREF && si.type==AV_PICTURE_TYPE_B)
- || (avctx->skip_frame >= AVDISCARD_NONKEY && si.type!=AV_PICTURE_TYPE_I)
- || avctx->skip_frame >= AVDISCARD_ALL)
- return avpkt->size;
-
- /* first slice */
- if (si.start == 0) {
- if (s->mb_num_left > 0) {
- av_log(avctx, AV_LOG_ERROR, "New frame but still %d MB left.\n",
- s->mb_num_left);
- ff_er_frame_end(s);
- ff_MPV_frame_end(s);
- }
-
- if (s->width != si.width || s->height != si.height) {
- int err;
-
- av_log(s->avctx, AV_LOG_WARNING, "Changing dimensions to %dx%d\n",
- si.width, si.height);
-
- if (av_image_check_size(si.width, si.height, 0, s->avctx))
- return AVERROR_INVALIDDATA;
-
- s->width = si.width;
- s->height = si.height;
- avcodec_set_dimensions(s->avctx, s->width, s->height);
- if ((err = ff_MPV_common_frame_size_change(s)) < 0)
- return err;
- if ((err = rv34_decoder_realloc(r)) < 0)
- return err;
- }
- s->pict_type = si.type ? si.type : AV_PICTURE_TYPE_I;
- if (ff_MPV_frame_start(s, s->avctx) < 0)
- return -1;
- ff_er_frame_start(s);
- if (!r->tmp_b_block_base) {
- int i;
-
- r->tmp_b_block_base = av_malloc(s->linesize * 48);
- for (i = 0; i < 2; i++)
- r->tmp_b_block_y[i] = r->tmp_b_block_base
- + i * 16 * s->linesize;
- for (i = 0; i < 4; i++)
- r->tmp_b_block_uv[i] = r->tmp_b_block_base + 32 * s->linesize
- + (i >> 1) * 8 * s->uvlinesize
- + (i & 1) * 16;
- }
- r->cur_pts = si.pts;
- if (s->pict_type != AV_PICTURE_TYPE_B) {
- r->last_pts = r->next_pts;
- r->next_pts = r->cur_pts;
- } else {
- int refdist = GET_PTS_DIFF(r->next_pts, r->last_pts);
- int dist0 = GET_PTS_DIFF(r->cur_pts, r->last_pts);
- int dist1 = GET_PTS_DIFF(r->next_pts, r->cur_pts);
-
- if(!refdist){
- r->mv_weight1 = r->mv_weight2 = r->weight1 = r->weight2 = 8192;
- r->scaled_weight = 0;
- }else{
- r->mv_weight1 = (dist0 << 14) / refdist;
- r->mv_weight2 = (dist1 << 14) / refdist;
- if((r->mv_weight1|r->mv_weight2) & 511){
- r->weight1 = r->mv_weight1;
- r->weight2 = r->mv_weight2;
- r->scaled_weight = 0;
- }else{
- r->weight1 = r->mv_weight1 >> 9;
- r->weight2 = r->mv_weight2 >> 9;
- r->scaled_weight = 1;
- }
- }
- }
- s->mb_x = s->mb_y = 0;
- ff_thread_finish_setup(s->avctx);
- } else if (HAVE_THREADS &&
- (s->avctx->active_thread_type & FF_THREAD_FRAME)) {
- av_log(s->avctx, AV_LOG_ERROR, "Decoder needs full frames in frame "
- "multithreading mode (start MB is %d).\n", si.start);
- return AVERROR_INVALIDDATA;
- }
-
- for(i = 0; i < slice_count; i++){
- int offset = get_slice_offset(avctx, slices_hdr, i);
- int size;
- if(i+1 == slice_count)
- size = buf_size - offset;
- else
- size = get_slice_offset(avctx, slices_hdr, i+1) - offset;
-
- if(offset < 0 || offset > buf_size){
- av_log(avctx, AV_LOG_ERROR, "Slice offset is invalid\n");
- break;
- }
-
- r->si.end = s->mb_width * s->mb_height;
- s->mb_num_left = r->s.mb_x + r->s.mb_y*r->s.mb_width - r->si.start;
-
- if(i+1 < slice_count){
- if (get_slice_offset(avctx, slices_hdr, i+1) < 0 ||
- get_slice_offset(avctx, slices_hdr, i+1) > buf_size) {
- av_log(avctx, AV_LOG_ERROR, "Slice offset is invalid\n");
- break;
- }
- init_get_bits(&s->gb, buf+get_slice_offset(avctx, slices_hdr, i+1), (buf_size-get_slice_offset(avctx, slices_hdr, i+1))*8);
- if(r->parse_slice_header(r, &r->s.gb, &si) < 0){
- if(i+2 < slice_count)
- size = get_slice_offset(avctx, slices_hdr, i+2) - offset;
- else
- size = buf_size - offset;
- }else
- r->si.end = si.start;
- }
- if (size < 0 || size > buf_size - offset) {
- av_log(avctx, AV_LOG_ERROR, "Slice size is invalid\n");
- break;
- }
- last = rv34_decode_slice(r, r->si.end, buf + offset, size);
- if(last)
- break;
- }
-
- if (s->current_picture_ptr) {
- if (last) {
- if(r->loop_filter)
- r->loop_filter(r, s->mb_height - 1);
-
- *got_picture_ptr = finish_frame(avctx, pict);
- } else if (HAVE_THREADS &&
- (s->avctx->active_thread_type & FF_THREAD_FRAME)) {
- av_log(avctx, AV_LOG_INFO, "marking unfished frame as finished\n");
- /* always mark the current frame as finished, frame-mt supports
- * only complete frames */
- ff_er_frame_end(s);
- ff_MPV_frame_end(s);
- s->mb_num_left = 0;
- ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, 0);
- return AVERROR_INVALIDDATA;
- }
- }
-
- return avpkt->size;
-}
-
-av_cold int ff_rv34_decode_end(AVCodecContext *avctx)
-{
- RV34DecContext *r = avctx->priv_data;
-
- ff_MPV_common_end(&r->s);
- rv34_decoder_free(r);
-
- return 0;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/rv34.h b/src/thirdparty/ffmpeg/libavcodec/rv34.h
deleted file mode 100644
index a7bf31f3e..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/rv34.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * RV30/40 decoder common data declarations
- * Copyright (c) 2007 Mike Melanson, 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
- */
-
-/**
- * @file
- * RV30 and RV40 decoder common data declarations
- */
-
-#ifndef AVCODEC_RV34_H
-#define AVCODEC_RV34_H
-
-#include "avcodec.h"
-#include "dsputil.h"
-#include "mpegvideo.h"
-
-#include "h264pred.h"
-#include "rv34dsp.h"
-
-#define MB_TYPE_SEPARATE_DC 0x01000000
-#define IS_SEPARATE_DC(a) ((a) & MB_TYPE_SEPARATE_DC)
-
-/**
- * RV30 and RV40 Macroblock types
- */
-enum RV40BlockTypes{
- RV34_MB_TYPE_INTRA, ///< Intra macroblock
- RV34_MB_TYPE_INTRA16x16, ///< Intra macroblock with DCs in a separate 4x4 block
- RV34_MB_P_16x16, ///< P-frame macroblock, one motion frame
- RV34_MB_P_8x8, ///< P-frame macroblock, 8x8 motion compensation partitions
- RV34_MB_B_FORWARD, ///< B-frame macroblock, forward prediction
- RV34_MB_B_BACKWARD, ///< B-frame macroblock, backward prediction
- RV34_MB_SKIP, ///< Skipped block
- RV34_MB_B_DIRECT, ///< Bidirectionally predicted B-frame macroblock, no motion vectors
- RV34_MB_P_16x8, ///< P-frame macroblock, 16x8 motion compensation partitions
- RV34_MB_P_8x16, ///< P-frame macroblock, 8x16 motion compensation partitions
- RV34_MB_B_BIDIR, ///< Bidirectionally predicted B-frame macroblock, two motion vectors
- RV34_MB_P_MIX16x16, ///< P-frame macroblock with DCs in a separate 4x4 block, one motion vector
- RV34_MB_TYPES
-};
-
-/**
- * VLC tables used by the decoder
- *
- * Intra frame VLC sets do not contain some of those tables.
- */
-typedef struct RV34VLC{
- VLC cbppattern[2]; ///< VLCs used for pattern of coded block patterns decoding
- VLC cbp[2][4]; ///< VLCs used for coded block patterns decoding
- VLC first_pattern[4]; ///< VLCs used for decoding coefficients in the first subblock
- VLC second_pattern[2]; ///< VLCs used for decoding coefficients in the subblocks 2 and 3
- VLC third_pattern[2]; ///< VLCs used for decoding coefficients in the last subblock
- VLC coefficient; ///< VLCs used for decoding big coefficients
-}RV34VLC;
-
-/** essential slice information */
-typedef struct SliceInfo{
- int type; ///< slice type (intra, inter)
- int quant; ///< quantizer used for this slice
- int vlc_set; ///< VLCs used for this slice
- int start, end; ///< start and end macroblocks of the slice
- int width; ///< coded width
- int height; ///< coded height
- int pts; ///< frame timestamp
-}SliceInfo;
-
-/** decoder context */
-typedef struct RV34DecContext{
- MpegEncContext s;
- RV34DSPContext rdsp;
- int8_t *intra_types_hist;///< old block types, used for prediction
- int8_t *intra_types; ///< block types
- int intra_types_stride;///< block types array stride
- const uint8_t *luma_dc_quant_i;///< luma subblock DC quantizer for intraframes
- const uint8_t *luma_dc_quant_p;///< luma subblock DC quantizer for interframes
-
- RV34VLC *cur_vlcs; ///< VLC set used for current frame decoding
- H264PredContext h; ///< functions for 4x4 and 16x16 intra block prediction
- SliceInfo si; ///< current slice information
-
- int *mb_type; ///< internal macroblock types
- int block_type; ///< current block type
- int luma_vlc; ///< which VLC set will be used for decoding of luma blocks
- int chroma_vlc; ///< which VLC set will be used for decoding of chroma blocks
- int is16; ///< current block has additional 16x16 specific features or not
- 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 cur_pts, last_pts, next_pts;
- int scaled_weight;
- int weight1, weight2; ///< B frame distance fractions (0.14) used in motion compensation
- int mv_weight1, mv_weight2;
-
- uint16_t *cbp_luma; ///< CBP values for luma subblocks
- uint8_t *cbp_chroma; ///< CBP values for chroma subblocks
- uint16_t *deblock_coefs; ///< deblock coefficients for each macroblock
-
- /** 8x8 block available flags (for MV prediction) */
- DECLARE_ALIGNED(8, uint32_t, avail_cache)[3*4];
-
- /** temporary blocks for RV4 weighted MC */
- uint8_t *tmp_b_block_y[2];
- uint8_t *tmp_b_block_uv[4];
- uint8_t *tmp_b_block_base;
-
- int (*parse_slice_header)(struct RV34DecContext *r, GetBitContext *gb, SliceInfo *si);
- int (*decode_mb_info)(struct RV34DecContext *r);
- int (*decode_intra_types)(struct RV34DecContext *r, GetBitContext *gb, int8_t *dst);
- void (*loop_filter)(struct RV34DecContext *r, int row);
-}RV34DecContext;
-
-/**
- * common decoding functions
- */
-int ff_rv34_get_start_offset(GetBitContext *gb, int blocks);
-int ff_rv34_decode_init(AVCodecContext *avctx);
-int ff_rv34_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt);
-int ff_rv34_decode_end(AVCodecContext *avctx);
-int ff_rv34_decode_init_thread_copy(AVCodecContext *avctx);
-int ff_rv34_decode_update_thread_context(AVCodecContext *dst, const AVCodecContext *src);
-
-#endif /* AVCODEC_RV34_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/rv34data.h b/src/thirdparty/ffmpeg/libavcodec/rv34data.h
deleted file mode 100644
index 24996d5a0..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/rv34data.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * RealVideo 4 decoder
- * copyright (c) 2007 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
- */
-
-/**
- * @file
- * miscellaneous RV30/40 tables
- */
-
-#ifndef AVCODEC_RV34DATA_H
-#define AVCODEC_RV34DATA_H
-
-#include <stdint.h>
-
-/**
- * number of ones in nibble minus one
- */
-static const uint8_t rv34_count_ones[16] = {
- 0, 0, 0, 1, 0, 1, 1, 2, 0, 1, 1, 2, 1, 2, 2, 3
-};
-
-/**
- * values used to reconstruct coded block pattern
- */
-static const uint8_t rv34_cbp_code[16] = {
- 0x00, 0x20, 0x10, 0x30, 0x02, 0x22, 0x12, 0x32,
- 0x01, 0x21, 0x11, 0x31, 0x03, 0x23, 0x13, 0x33
-};
-
-/**
- * precalculated results of division by three and modulo three for values 0-107
- *
- * A lot of four-tuples in RV40 are represented as c0*27+c1*9+c2*3+c3.
- * This table allows conversion from a value back to a vector.
- */
-static const uint8_t modulo_three_table[108] = {
- 0x00, 0x01, 0x02, 0x04, 0x05, 0x06, 0x08, 0x09, 0x0A,
- 0x10, 0x11, 0x12, 0x14, 0x15, 0x16, 0x18, 0x19, 0x1A,
- 0x20, 0x21, 0x22, 0x24, 0x25, 0x26, 0x28, 0x29, 0x2A,
-
- 0x40, 0x41, 0x42, 0x44, 0x45, 0x46, 0x48, 0x49, 0x4A,
- 0x50, 0x51, 0x52, 0x54, 0x55, 0x56, 0x58, 0x59, 0x5A,
- 0x60, 0x61, 0x62, 0x64, 0x65, 0x66, 0x68, 0x69, 0x6A,
-
- 0x80, 0x81, 0x82, 0x84, 0x85, 0x86, 0x88, 0x89, 0x8A,
- 0x90, 0x91, 0x92, 0x94, 0x95, 0x96, 0x98, 0x99, 0x9A,
- 0xA0, 0xA1, 0xA2, 0xA4, 0xA5, 0xA6, 0xA8, 0xA9, 0xAA,
-
- 0xC0, 0xC1, 0xC2, 0xC4, 0xC5, 0xC6, 0xC8, 0xC9, 0xCA,
- 0xD0, 0xD1, 0xD2, 0xD4, 0xD5, 0xD6, 0xD8, 0xD9, 0xDA,
- 0xE0, 0xE1, 0xE2, 0xE4, 0xE5, 0xE6, 0xE8, 0xE9, 0xEA,
-};
-
-/**
- * quantizer values used for AC and DC coefficients in chroma blocks
- */
-static const uint8_t rv34_chroma_quant[2][32] = {
- { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 17, 18, 19, 20, 20, 21, 22, 22, 23, 23, 24, 24, 25, 25 },
- { 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
- 14, 15, 15, 16, 17, 18, 18, 19, 20, 20, 21, 21, 22, 22, 23, 23 }
-};
-
-/**
- * This table is used for dequantizing.
- */
-static const uint16_t rv34_qscale_tab[32] = {
- 60, 67, 76, 85, 96, 108, 121, 136,
- 152, 171, 192, 216, 242, 272, 305, 341,
- 383, 432, 481, 544, 606, 683, 767, 854,
- 963, 1074, 1212, 1392, 1566, 1708, 1978, 2211
-};
-
-/**
- * tables used to translate a quantizer value into a VLC set for decoding
- * The first table is used for intraframes.
- */
-static const uint8_t rv34_quant_to_vlc_set[2][31] = {
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 0 },
- { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3,
- 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6 },
-};
-
-/**
- * table for obtaining the quantizer difference
- * @todo Use with ff_modified_quant_tab from h263data.h.
- */
-static const uint8_t rv34_dquant_tab[2][32]={
-// 0 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
-{
- 0, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9,10,11,12,13,14,15,16,17,18,18,19,20,21,22,23,24,25,26,27,28
-},{
- 0, 2, 3, 4, 5, 6, 7, 8, 9,10,11,13,14,15,16,17,18,19,20,21,22,24,25,26,27,28,29,30,31,31,31,26
-}
-};
-
-/**
- * maximum number of macroblocks for each of the possible slice offset sizes
- * @todo This is the same as ff_mba_max, maybe use it instead.
- */
-static const uint16_t rv34_mb_max_sizes[6] = { 0x2F, 0x62, 0x18B, 0x62F, 0x18BF, 0x23FF };
-/**
- * bits needed to code the slice offset for the given size
- * @todo This is the same as ff_mba_length, maybe use it instead.
- */
-static const uint8_t rv34_mb_bits_sizes[6] = { 6, 7, 9, 11, 13, 14 };
-
-#endif /* AVCODEC_RV34DATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/rv34dsp.c b/src/thirdparty/ffmpeg/libavcodec/rv34dsp.c
deleted file mode 100644
index 69cd2c8c9..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/rv34dsp.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * RV30/40 decoder common dsp functions
- * Copyright (c) 2007 Mike Melanson, Konstantin Shishkov
- * Copyright (c) 2011 Janne Grunau
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * RV30/40 decoder common dsp functions
- */
-
-#include "rv34dsp.h"
-#include "libavutil/common.h"
-
-/**
- * @name RV30/40 inverse transform functions
- * @{
- */
-
-static av_always_inline void rv34_row_transform(int temp[16], int16_t *block)
-{
- int i;
-
- for(i = 0; i < 4; i++){
- const int z0 = 13*(block[i+4*0] + block[i+4*2]);
- const int z1 = 13*(block[i+4*0] - block[i+4*2]);
- const int z2 = 7* block[i+4*1] - 17*block[i+4*3];
- const int z3 = 17* block[i+4*1] + 7*block[i+4*3];
-
- temp[4*i+0] = z0 + z3;
- temp[4*i+1] = z1 + z2;
- temp[4*i+2] = z1 - z2;
- temp[4*i+3] = z0 - z3;
- }
-}
-
-/**
- * Real Video 3.0/4.0 inverse transform + sample reconstruction
- * Code is almost the same as in SVQ3, only scaling is different.
- */
-static void rv34_idct_add_c(uint8_t *dst, ptrdiff_t stride, int16_t *block){
- int temp[16];
- int i;
-
- rv34_row_transform(temp, block);
- memset(block, 0, 16*sizeof(int16_t));
-
- for(i = 0; i < 4; i++){
- const int z0 = 13*(temp[4*0+i] + temp[4*2+i]) + 0x200;
- const int z1 = 13*(temp[4*0+i] - temp[4*2+i]) + 0x200;
- const int z2 = 7* temp[4*1+i] - 17*temp[4*3+i];
- const int z3 = 17* temp[4*1+i] + 7*temp[4*3+i];
-
- dst[0] = av_clip_uint8( dst[0] + ( (z0 + z3) >> 10 ) );
- dst[1] = av_clip_uint8( dst[1] + ( (z1 + z2) >> 10 ) );
- dst[2] = av_clip_uint8( dst[2] + ( (z1 - z2) >> 10 ) );
- dst[3] = av_clip_uint8( dst[3] + ( (z0 - z3) >> 10 ) );
-
- dst += stride;
- }
-}
-
-/**
- * RealVideo 3.0/4.0 inverse transform for DC block
- *
- * Code is almost the same as rv34_inv_transform()
- * but final coefficients are multiplied by 1.5 and have no rounding.
- */
-static void rv34_inv_transform_noround_c(int16_t *block){
- int temp[16];
- int i;
-
- rv34_row_transform(temp, block);
-
- for(i = 0; i < 4; i++){
- const int z0 = 39*(temp[4*0+i] + temp[4*2+i]);
- const int z1 = 39*(temp[4*0+i] - temp[4*2+i]);
- const int z2 = 21* temp[4*1+i] - 51*temp[4*3+i];
- const int z3 = 51* temp[4*1+i] + 21*temp[4*3+i];
-
- block[i*4+0] = (z0 + z3) >> 11;
- block[i*4+1] = (z1 + z2) >> 11;
- block[i*4+2] = (z1 - z2) >> 11;
- block[i*4+3] = (z0 - z3) >> 11;
- }
-}
-
-static void rv34_idct_dc_add_c(uint8_t *dst, ptrdiff_t stride, int dc)
-{
- int i, j;
-
- dc = (13*13*dc + 0x200) >> 10;
- for (i = 0; i < 4; i++)
- {
- for (j = 0; j < 4; j++)
- dst[j] = av_clip_uint8( dst[j] + dc );
-
- dst += stride;
- }
-}
-
-static void rv34_inv_transform_dc_noround_c(int16_t *block)
-{
- int16_t dc = (13 * 13 * 3 * block[0]) >> 11;
- int i, j;
-
- for (i = 0; i < 4; i++, block += 4)
- for (j = 0; j < 4; j++)
- block[j] = dc;
-}
-
-/** @} */ // transform
-
-
-av_cold void ff_rv34dsp_init(RV34DSPContext *c)
-{
- c->rv34_inv_transform = rv34_inv_transform_noround_c;
- c->rv34_inv_transform_dc = rv34_inv_transform_dc_noround_c;
-
- c->rv34_idct_add = rv34_idct_add_c;
- c->rv34_idct_dc_add = rv34_idct_dc_add_c;
-
- if (ARCH_ARM)
- ff_rv34dsp_init_arm(c);
- if (ARCH_X86)
- ff_rv34dsp_init_x86(c);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/rv34dsp.h b/src/thirdparty/ffmpeg/libavcodec/rv34dsp.h
deleted file mode 100644
index b94aba870..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/rv34dsp.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * RV30/40 decoder motion compensation functions
- * Copyright (c) 2008 Konstantin Shishkov
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * RV30/40 decoder motion compensation functions
- */
-
-#ifndef AVCODEC_RV34DSP_H
-#define AVCODEC_RV34DSP_H
-
-#include "dsputil.h"
-#include "h264chroma.h"
-
-typedef void (*rv40_weight_func)(uint8_t *dst/*align width (8 or 16)*/,
- uint8_t *src1/*align width (8 or 16)*/,
- uint8_t *src2/*align width (8 or 16)*/,
- int w1, int w2, ptrdiff_t stride);
-
-typedef void (*rv34_inv_transform_func)(int16_t *block);
-
-typedef void (*rv34_idct_add_func)(uint8_t *dst, ptrdiff_t stride, int16_t *block);
-typedef void (*rv34_idct_dc_add_func)(uint8_t *dst, ptrdiff_t stride,
- int dc);
-
-typedef void (*rv40_weak_loop_filter_func)(uint8_t *src, ptrdiff_t stride,
- int filter_p1, int filter_q1,
- int alpha, int beta,
- int lims, int lim_q1, int lim_p1);
-
-typedef void (*rv40_strong_loop_filter_func)(uint8_t *src, ptrdiff_t stride,
- int alpha, int lims,
- int dmode, int chroma);
-
-typedef int (*rv40_loop_filter_strength_func)(uint8_t *src, ptrdiff_t stride,
- int beta, int beta2, int edge,
- int *p1, int *q1);
-
-typedef struct RV34DSPContext {
- qpel_mc_func put_pixels_tab[4][16];
- qpel_mc_func avg_pixels_tab[4][16];
- h264_chroma_mc_func put_chroma_pixels_tab[3];
- h264_chroma_mc_func avg_chroma_pixels_tab[3];
- /**
- * Biweight functions, first dimension is transform size (16/8),
- * second is whether the weight is prescaled by 1/512 to skip
- * the intermediate shifting.
- */
- rv40_weight_func rv40_weight_pixels_tab[2][2];
- rv34_inv_transform_func rv34_inv_transform;
- rv34_inv_transform_func rv34_inv_transform_dc;
- rv34_idct_add_func rv34_idct_add;
- rv34_idct_dc_add_func rv34_idct_dc_add;
- rv40_weak_loop_filter_func rv40_weak_loop_filter[2];
- rv40_strong_loop_filter_func rv40_strong_loop_filter[2];
- rv40_loop_filter_strength_func rv40_loop_filter_strength[2];
-} RV34DSPContext;
-
-void ff_rv30dsp_init(RV34DSPContext *c);
-void ff_rv34dsp_init(RV34DSPContext *c);
-void ff_rv40dsp_init(RV34DSPContext *c);
-
-void ff_rv34dsp_init_arm(RV34DSPContext *c);
-void ff_rv34dsp_init_x86(RV34DSPContext *c);
-
-void ff_rv40dsp_init_x86(RV34DSPContext *c);
-void ff_rv40dsp_init_arm(RV34DSPContext *c);
-
-#endif /* AVCODEC_RV34DSP_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/rv34vlc.h b/src/thirdparty/ffmpeg/libavcodec/rv34vlc.h
deleted file mode 100644
index 10a99a8a3..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/rv34vlc.h
+++ /dev/null
@@ -1,4055 +0,0 @@
-/*
- * RealVideo 3/4 decoder
- * Copyright (c) 2007 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
- */
-
-/**
- * @file
- * RV30/40 VLC tables
- */
-
-#ifndef AVCODEC_RV34VLC_H
-#define AVCODEC_RV34VLC_H
-
-#include <stdint.h>
-
-#define NUM_INTRA_TABLES 5
-#define NUM_INTER_TABLES 7
-
-#define CBPPAT_VLC_SIZE 1296
-#define CBP_VLC_SIZE 16
-#define FIRSTBLK_VLC_SIZE 864
-#define OTHERBLK_VLC_SIZE 108
-#define COEFF_VLC_SIZE 32
-#define MAX_VLC_SIZE 1296
-
-static const uint8_t rv34_table_intra_cbppat[NUM_INTRA_TABLES][2][CBPPAT_VLC_SIZE] = {
- {
- {
- 8, 10, 10, 10, 10, 10, 11, 10, 10, 11, 10, 10, 10, 10, 10, 6,
- 12, 12, 13, 12, 13, 12, 13, 11, 13, 13, 13, 12, 13, 12, 12, 8,
- 14, 13, 16, 13, 15, 13, 16, 12, 16, 16, 16, 14, 16, 13, 14, 10,
- 12, 13, 12, 12, 13, 13, 13, 12, 13, 13, 12, 12, 13, 12, 12, 8,
- 13, 14, 14, 12, 14, 14, 14, 12, 14, 15, 14, 12, 14, 13, 13, 8,
- 16, 16, 16, 12, 16, 16, 16, 13, 16, 16, 16, 13, 16, 14, 14, 9,
- 14, 16, 13, 13, 16, 16, 16, 14, 15, 16, 14, 13, 15, 15, 14, 10,
- 16, 16, 14, 13, 16, 16, 16, 13, 16, 16, 16, 13, 16, 15, 14, 10,
- 16, 16, 16, 11, 16, 16, 16, 12, 16, 16, 16, 12, 16, 16, 15, 9,
- 12, 13, 13, 13, 12, 12, 14, 12, 12, 14, 13, 12, 12, 12, 12, 8,
- 14, 14, 16, 14, 13, 12, 14, 12, 14, 15, 14, 13, 13, 12, 13, 8,
- 16, 16, 16, 15, 16, 13, 16, 13, 16, 16, 16, 15, 16, 13, 15, 10,
- 14, 16, 14, 14, 14, 14, 15, 13, 14, 16, 14, 13, 13, 13, 13, 9,
- 16, 16, 16, 14, 16, 14, 16, 12, 16, 16, 14, 13, 14, 13, 13, 8,
- 16, 16, 16, 14, 16, 14, 16, 13, 16, 16, 16, 14, 16, 14, 14, 9,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 16, 16, 14, 10,
- 16, 16, 16, 14, 16, 16, 16, 13, 16, 16, 16, 14, 16, 15, 14, 9,
- 16, 16, 16, 13, 16, 16, 16, 12, 16, 16, 16, 13, 16, 15, 15, 8,
- 14, 16, 16, 16, 14, 14, 16, 14, 16, 16, 16, 15, 13, 13, 14, 10,
- 16, 16, 16, 16, 15, 13, 16, 13, 16, 16, 16, 16, 16, 13, 14, 10,
- 16, 16, 16, 16, 16, 11, 16, 12, 16, 16, 16, 16, 16, 12, 16, 9,
- 16, 16, 16, 16, 16, 16, 16, 15, 16, 16, 16, 16, 16, 14, 14, 10,
- 16, 16, 16, 16, 16, 15, 16, 13, 16, 16, 16, 15, 16, 13, 14, 9,
- 16, 16, 16, 16, 16, 13, 16, 12, 16, 16, 16, 16, 16, 13, 14, 8,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 11,
- 16, 16, 16, 16, 16, 16, 16, 14, 16, 16, 16, 16, 16, 16, 14, 9,
- 16, 16, 16, 14, 16, 15, 16, 11, 16, 16, 16, 14, 16, 14, 14, 8,
- 12, 13, 13, 13, 13, 13, 14, 12, 12, 13, 12, 12, 12, 12, 12, 8,
- 14, 14, 16, 14, 15, 14, 16, 13, 14, 15, 14, 13, 14, 13, 13, 9,
- 16, 16, 16, 15, 16, 16, 16, 14, 16, 16, 16, 14, 16, 14, 16, 10,
- 14, 15, 14, 14, 15, 14, 15, 13, 14, 14, 13, 12, 13, 13, 13, 9,
- 15, 16, 15, 14, 16, 16, 16, 13, 15, 16, 14, 12, 14, 13, 13, 8,
- 16, 16, 16, 14, 16, 16, 16, 13, 16, 16, 16, 13, 16, 14, 14, 9,
- 16, 16, 16, 16, 16, 16, 16, 15, 16, 16, 13, 13, 16, 16, 14, 10,
- 16, 16, 16, 14, 16, 16, 16, 14, 16, 16, 15, 13, 16, 14, 14, 9,
- 16, 16, 16, 12, 16, 16, 16, 13, 16, 16, 16, 12, 16, 16, 15, 8,
- 13, 14, 14, 14, 14, 14, 16, 13, 13, 14, 14, 13, 12, 12, 12, 8,
- 16, 16, 16, 14, 15, 14, 16, 13, 15, 16, 14, 13, 13, 12, 13, 8,
- 16, 16, 16, 16, 16, 14, 16, 14, 16, 16, 16, 14, 16, 13, 14, 9,
- 15, 16, 16, 15, 16, 15, 16, 13, 14, 16, 14, 13, 13, 13, 12, 8,
- 16, 16, 16, 14, 16, 14, 15, 12, 15, 15, 14, 12, 13, 12, 12, 7,
- 16, 16, 16, 14, 16, 14, 16, 12, 16, 16, 16, 13, 16, 13, 13, 7,
- 16, 16, 16, 16, 16, 16, 16, 14, 16, 16, 14, 14, 16, 14, 13, 9,
- 16, 16, 16, 14, 16, 16, 16, 13, 16, 16, 14, 12, 16, 13, 12, 7,
- 16, 16, 16, 12, 16, 16, 16, 11, 16, 16, 15, 12, 16, 13, 13, 6,
- 16, 16, 16, 16, 16, 16, 16, 15, 16, 16, 16, 15, 13, 13, 14, 10,
- 16, 16, 16, 16, 16, 14, 16, 14, 16, 16, 16, 16, 14, 13, 14, 9,
- 16, 16, 16, 16, 16, 13, 16, 13, 16, 16, 16, 16, 16, 12, 14, 8,
- 16, 16, 16, 16, 16, 16, 16, 14, 16, 16, 16, 14, 14, 13, 13, 9,
- 16, 16, 16, 16, 16, 14, 16, 13, 16, 16, 16, 13, 14, 12, 12, 7,
- 16, 16, 16, 16, 16, 13, 16, 12, 16, 16, 16, 13, 14, 12, 13, 6,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 14, 9,
- 16, 16, 16, 16, 16, 16, 16, 13, 16, 16, 16, 13, 15, 13, 12, 7,
- 16, 16, 16, 13, 16, 14, 16, 11, 16, 16, 16, 12, 16, 12, 12, 5,
- 14, 16, 15, 16, 16, 16, 16, 15, 14, 15, 14, 14, 13, 14, 13, 10,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 16, 14, 16, 10,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 11,
- 16, 16, 16, 16, 16, 16, 16, 16, 14, 16, 14, 14, 15, 14, 13, 10,
- 16, 16, 16, 16, 16, 16, 16, 15, 16, 16, 14, 13, 16, 14, 14, 9,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 16, 16, 15, 9,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 12, 13, 16, 16, 13, 10,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 13, 13, 16, 16, 13, 9,
- 16, 16, 16, 14, 16, 16, 16, 14, 16, 16, 15, 12, 16, 16, 14, 8,
- 16, 16, 16, 16, 16, 16, 16, 16, 14, 16, 15, 14, 13, 13, 13, 9,
- 16, 16, 16, 16, 16, 16, 16, 14, 16, 16, 16, 14, 14, 13, 13, 9,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 15, 9,
- 16, 16, 16, 16, 16, 16, 16, 15, 15, 16, 14, 14, 14, 13, 13, 9,
- 16, 16, 16, 16, 16, 16, 16, 13, 16, 16, 14, 12, 13, 12, 12, 7,
- 16, 16, 16, 16, 16, 16, 16, 13, 16, 16, 16, 13, 16, 13, 13, 7,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 13, 13, 16, 14, 13, 9,
- 16, 16, 16, 15, 16, 16, 16, 13, 16, 16, 13, 12, 14, 13, 12, 6,
- 16, 16, 16, 13, 16, 16, 16, 12, 16, 16, 14, 10, 15, 12, 12, 5,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 12, 13, 13, 9,
- 16, 16, 16, 16, 16, 16, 16, 14, 16, 16, 16, 15, 13, 12, 13, 8,
- 16, 16, 16, 16, 16, 14, 16, 14, 16, 16, 16, 16, 15, 12, 14, 8,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 13, 13, 13, 8,
- 16, 16, 16, 16, 16, 16, 16, 13, 16, 16, 15, 13, 12, 11, 12, 6,
- 16, 16, 16, 15, 16, 14, 16, 12, 16, 16, 16, 12, 13, 10, 12, 5,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 14, 13, 14, 12, 8,
- 16, 16, 16, 16, 16, 16, 16, 13, 16, 16, 13, 12, 13, 12, 10, 5,
- 16, 16, 16, 13, 16, 13, 16, 10, 16, 16, 13, 10, 13, 10, 10, 1,
- },
- {
- 2, 7, 7, 8, 7, 8, 9, 8, 7, 9, 8, 8, 8, 8, 9, 7,
- 6, 9, 10, 10, 10, 10, 11, 10, 10, 11, 11, 11, 10, 11, 11, 9,
- 9, 11, 12, 12, 12, 13, 14, 13, 13, 14, 14, 13, 13, 13, 14, 11,
- 6, 10, 9, 10, 10, 11, 11, 11, 10, 11, 10, 11, 11, 11, 11, 9,
- 6, 9, 10, 10, 10, 11, 12, 11, 10, 12, 11, 11, 11, 11, 11, 8,
- 9, 11, 12, 12, 12, 13, 13, 13, 12, 14, 14, 13, 13, 13, 13, 10,
- 9, 13, 11, 13, 13, 14, 14, 13, 13, 14, 13, 13, 14, 14, 14, 12,
- 9, 12, 12, 12, 12, 14, 14, 13, 13, 14, 13, 13, 13, 14, 13, 11,
- 8, 12, 12, 11, 12, 14, 14, 12, 13, 14, 14, 13, 13, 13, 14, 11,
- 6, 10, 10, 11, 9, 10, 12, 11, 10, 12, 11, 11, 10, 11, 11, 9,
- 7, 10, 10, 11, 10, 11, 12, 11, 11, 12, 11, 11, 11, 11, 11, 9,
- 9, 12, 13, 13, 12, 12, 14, 13, 13, 14, 14, 13, 14, 13, 14, 11,
- 8, 11, 11, 12, 11, 12, 12, 12, 11, 13, 12, 12, 12, 12, 12, 10,
- 7, 10, 10, 11, 10, 11, 12, 11, 10, 12, 11, 11, 11, 11, 11, 8,
- 9, 11, 12, 12, 12, 12, 13, 12, 12, 13, 13, 12, 13, 12, 13, 10,
- 10, 13, 13, 14, 14, 14, 15, 14, 14, 15, 14, 15, 14, 14, 14, 12,
- 9, 12, 12, 13, 12, 13, 14, 13, 12, 13, 13, 12, 13, 13, 13, 10,
- 9, 12, 12, 12, 12, 13, 14, 12, 12, 14, 13, 12, 13, 13, 13, 10,
- 9, 12, 13, 13, 11, 13, 14, 13, 13, 14, 14, 14, 12, 13, 13, 11,
- 10, 12, 13, 13, 12, 12, 14, 13, 13, 14, 14, 14, 13, 13, 14, 11,
- 10, 13, 14, 14, 13, 12, 15, 13, 14, 14, 14, 14, 15, 13, 14, 11,
- 11, 14, 14, 14, 13, 14, 15, 14, 14, 15, 15, 14, 13, 14, 14, 12,
- 10, 13, 12, 13, 12, 12, 14, 13, 13, 14, 13, 13, 13, 13, 13, 10,
- 10, 12, 13, 13, 13, 12, 14, 12, 13, 14, 14, 13, 13, 13, 13, 10,
- 13, 15, 16, 16, 15, 15, 16, 16, 15, 16, 15, 16, 16, 16, 16, 14,
- 11, 14, 14, 14, 14, 14, 15, 14, 14, 15, 15, 14, 14, 14, 15, 11,
- 10, 13, 13, 13, 13, 13, 14, 12, 13, 14, 14, 13, 13, 13, 13, 10,
- 6, 10, 10, 11, 10, 11, 12, 11, 10, 12, 10, 11, 10, 11, 11, 9,
- 8, 11, 11, 12, 11, 12, 13, 12, 11, 12, 12, 12, 12, 12, 12, 10,
- 11, 13, 14, 14, 13, 14, 15, 14, 13, 15, 15, 14, 14, 14, 15, 12,
- 7, 11, 10, 12, 11, 12, 12, 12, 11, 12, 11, 12, 11, 12, 12, 10,
- 7, 10, 10, 11, 10, 11, 12, 11, 11, 12, 11, 11, 11, 11, 11, 9,
- 10, 12, 13, 13, 12, 13, 14, 13, 13, 14, 13, 13, 13, 13, 13, 10,
- 10, 13, 12, 14, 13, 14, 14, 14, 13, 14, 12, 14, 15, 14, 14, 11,
- 10, 12, 12, 12, 12, 13, 14, 13, 13, 14, 13, 12, 13, 13, 13, 10,
- 9, 12, 13, 13, 13, 14, 14, 13, 13, 14, 14, 13, 13, 13, 13, 10,
- 7, 10, 10, 11, 10, 11, 12, 11, 10, 12, 12, 11, 9, 11, 11, 9,
- 7, 10, 11, 11, 10, 11, 12, 11, 10, 12, 12, 11, 11, 11, 11, 9,
- 10, 12, 13, 13, 13, 13, 15, 13, 13, 14, 13, 13, 13, 13, 13, 10,
- 8, 11, 11, 11, 11, 11, 12, 11, 11, 12, 12, 11, 11, 12, 11, 9,
- 6, 9, 9, 10, 9, 10, 10, 10, 9, 11, 10, 10, 9, 10, 10, 7,
- 8, 10, 11, 11, 11, 11, 12, 11, 11, 12, 12, 11, 11, 11, 11, 8,
- 10, 13, 13, 13, 13, 14, 14, 13, 13, 14, 13, 13, 13, 13, 13, 11,
- 8, 11, 11, 11, 11, 12, 12, 11, 11, 12, 11, 11, 11, 11, 11, 8,
- 8, 11, 11, 11, 11, 12, 12, 10, 11, 12, 12, 11, 11, 11, 11, 8,
- 10, 13, 13, 13, 12, 13, 14, 13, 12, 14, 14, 14, 10, 13, 13, 11,
- 10, 12, 12, 13, 12, 13, 14, 12, 12, 13, 13, 13, 12, 12, 13, 10,
- 11, 13, 14, 14, 13, 13, 14, 13, 13, 15, 14, 13, 13, 13, 13, 10,
- 10, 12, 13, 13, 12, 13, 14, 13, 13, 14, 14, 13, 12, 13, 13, 11,
- 8, 11, 11, 11, 11, 11, 12, 11, 11, 12, 12, 11, 11, 11, 11, 8,
- 9, 11, 12, 12, 11, 11, 12, 11, 12, 12, 12, 11, 12, 11, 11, 8,
- 12, 15, 14, 14, 14, 15, 15, 14, 14, 15, 15, 14, 14, 14, 15, 12,
- 10, 12, 12, 12, 12, 12, 13, 12, 12, 13, 13, 12, 12, 12, 12, 9,
- 9, 11, 11, 11, 11, 11, 12, 10, 11, 12, 12, 11, 11, 11, 11, 7,
- 10, 13, 13, 13, 13, 14, 15, 14, 13, 14, 14, 14, 12, 14, 15, 12,
- 11, 14, 14, 14, 14, 15, 15, 14, 14, 15, 15, 15, 14, 15, 15, 12,
- 13, 16, 16, 16, 15, 16, 16, 16, 15, 16, 16, 16, 16, 16, 16, 14,
- 10, 13, 13, 14, 13, 15, 14, 14, 13, 15, 13, 14, 14, 14, 14, 12,
- 10, 13, 13, 13, 13, 13, 14, 13, 13, 14, 13, 13, 13, 13, 14, 11,
- 12, 14, 14, 14, 14, 15, 15, 14, 14, 15, 15, 14, 15, 14, 14, 12,
- 11, 14, 14, 15, 14, 15, 15, 14, 14, 15, 12, 14, 15, 16, 15, 12,
- 11, 13, 13, 14, 13, 14, 14, 14, 14, 14, 13, 13, 14, 14, 14, 11,
- 11, 14, 14, 14, 14, 15, 15, 14, 14, 16, 14, 13, 14, 14, 14, 11,
- 10, 13, 13, 13, 12, 14, 14, 14, 12, 15, 14, 14, 11, 13, 13, 12,
- 10, 12, 13, 14, 12, 13, 14, 13, 13, 14, 14, 13, 12, 13, 13, 11,
- 12, 14, 14, 15, 14, 15, 16, 15, 15, 15, 15, 15, 14, 14, 15, 12,
- 10, 13, 13, 13, 12, 13, 14, 13, 13, 14, 13, 13, 12, 13, 13, 11,
- 9, 11, 11, 12, 11, 12, 12, 11, 11, 12, 12, 11, 11, 11, 11, 9,
- 10, 12, 12, 12, 12, 12, 13, 12, 12, 13, 13, 12, 13, 12, 12, 9,
- 11, 13, 13, 15, 14, 14, 15, 14, 14, 15, 14, 14, 14, 14, 14, 11,
- 10, 12, 12, 12, 12, 12, 13, 12, 12, 13, 11, 11, 12, 12, 12, 8,
- 9, 12, 12, 11, 12, 12, 13, 11, 12, 12, 12, 11, 12, 11, 11, 8,
- 10, 13, 13, 14, 12, 14, 15, 14, 13, 15, 15, 14, 10, 13, 13, 11,
- 11, 13, 14, 13, 13, 14, 14, 13, 13, 14, 14, 14, 11, 13, 13, 11,
- 12, 14, 14, 14, 14, 14, 15, 14, 15, 16, 15, 14, 13, 13, 14, 11,
- 11, 14, 13, 14, 13, 14, 15, 14, 13, 15, 14, 14, 11, 13, 13, 11,
- 9, 12, 12, 12, 11, 12, 13, 11, 12, 13, 12, 11, 10, 11, 11, 8,
- 10, 12, 12, 12, 12, 12, 13, 11, 12, 12, 12, 11, 11, 11, 11, 8,
- 12, 15, 14, 15, 14, 15, 16, 15, 15, 15, 15, 14, 14, 14, 14, 12,
- 10, 12, 12, 12, 12, 12, 13, 11, 12, 13, 12, 11, 11, 11, 11, 8,
- 8, 10, 10, 10, 10, 10, 11, 9, 10, 11, 10, 9, 10, 9, 9, 5,
- },
- },
- {
- {
- 12, 12, 11, 9, 11, 10, 11, 9, 11, 11, 10, 9, 9, 8, 9, 5,
- 14, 13, 14, 11, 14, 11, 13, 10, 14, 13, 12, 10, 12, 10, 11, 6,
- 16, 13, 16, 12, 16, 12, 16, 11, 16, 14, 16, 12, 15, 12, 13, 8,
- 14, 14, 12, 11, 14, 12, 13, 10, 13, 13, 11, 10, 12, 11, 10, 6,
- 16, 15, 14, 11, 16, 13, 14, 10, 15, 14, 13, 10, 13, 11, 11, 7,
- 16, 16, 16, 11, 16, 14, 16, 11, 16, 16, 15, 12, 15, 13, 13, 8,
- 16, 16, 13, 12, 16, 16, 15, 12, 16, 16, 12, 11, 15, 13, 12, 8,
- 16, 16, 14, 11, 16, 16, 16, 11, 16, 16, 14, 11, 15, 14, 13, 8,
- 16, 16, 15, 10, 16, 16, 16, 10, 16, 16, 15, 11, 16, 14, 14, 8,
- 14, 14, 14, 12, 13, 11, 13, 10, 13, 13, 12, 11, 11, 10, 10, 6,
- 16, 15, 16, 13, 13, 11, 14, 11, 15, 14, 13, 11, 12, 10, 11, 7,
- 16, 15, 16, 14, 16, 11, 16, 11, 16, 16, 16, 13, 16, 12, 13, 8,
- 16, 16, 14, 13, 15, 13, 14, 11, 14, 15, 13, 11, 13, 11, 11, 7,
- 16, 16, 15, 13, 15, 13, 14, 11, 16, 15, 14, 11, 13, 11, 11, 7,
- 16, 16, 16, 13, 16, 13, 16, 11, 16, 16, 16, 12, 16, 12, 13, 8,
- 16, 16, 16, 14, 16, 16, 16, 13, 16, 16, 14, 13, 15, 14, 13, 9,
- 16, 16, 16, 13, 16, 16, 16, 12, 16, 16, 14, 12, 15, 13, 13, 8,
- 16, 16, 16, 12, 16, 16, 16, 11, 16, 16, 15, 12, 16, 13, 13, 7,
- 16, 16, 16, 16, 13, 12, 16, 12, 16, 16, 14, 13, 12, 11, 12, 8,
- 16, 16, 16, 15, 14, 11, 16, 11, 16, 16, 16, 13, 14, 11, 13, 8,
- 16, 16, 16, 16, 15, 10, 16, 11, 16, 16, 16, 14, 15, 11, 13, 8,
- 16, 16, 16, 16, 16, 14, 16, 13, 16, 16, 14, 14, 14, 12, 13, 9,
- 16, 16, 16, 15, 16, 13, 16, 12, 16, 16, 16, 13, 14, 12, 13, 8,
- 16, 16, 16, 14, 16, 12, 16, 11, 16, 16, 16, 13, 15, 12, 13, 7,
- 16, 16, 16, 16, 16, 16, 16, 14, 16, 16, 16, 15, 16, 14, 13, 9,
- 16, 16, 16, 16, 16, 16, 16, 12, 16, 16, 16, 14, 16, 13, 13, 8,
- 16, 16, 16, 14, 16, 14, 16, 10, 16, 16, 16, 13, 16, 13, 13, 7,
- 14, 14, 13, 12, 13, 12, 13, 11, 12, 13, 11, 10, 11, 10, 10, 6,
- 16, 16, 15, 13, 16, 13, 15, 11, 14, 14, 13, 11, 13, 11, 11, 7,
- 16, 16, 16, 14, 16, 14, 16, 12, 16, 16, 16, 13, 16, 13, 14, 9,
- 16, 16, 13, 13, 15, 14, 14, 11, 13, 14, 11, 11, 12, 11, 11, 7,
- 16, 16, 15, 12, 16, 14, 15, 11, 14, 14, 12, 11, 13, 11, 11, 7,
- 16, 16, 16, 13, 16, 14, 16, 12, 16, 16, 14, 12, 16, 13, 13, 8,
- 16, 16, 14, 14, 16, 16, 16, 13, 16, 16, 12, 11, 15, 13, 12, 8,
- 16, 16, 15, 13, 16, 16, 16, 12, 16, 16, 13, 11, 16, 13, 12, 8,
- 16, 16, 16, 11, 16, 16, 16, 11, 16, 16, 14, 11, 16, 14, 13, 7,
- 16, 16, 15, 13, 14, 13, 14, 11, 14, 14, 12, 11, 11, 10, 11, 7,
- 16, 16, 16, 13, 14, 12, 15, 11, 15, 14, 13, 11, 12, 11, 11, 7,
- 16, 16, 16, 14, 16, 13, 16, 12, 16, 16, 16, 13, 14, 12, 13, 8,
- 16, 16, 15, 13, 15, 14, 14, 12, 14, 14, 12, 11, 12, 11, 11, 7,
- 16, 16, 14, 12, 15, 13, 14, 11, 15, 14, 13, 11, 12, 11, 11, 6,
- 16, 16, 16, 13, 16, 13, 16, 11, 16, 15, 14, 11, 14, 11, 12, 6,
- 16, 16, 16, 14, 16, 16, 16, 13, 16, 16, 13, 12, 14, 13, 12, 8,
- 16, 16, 15, 13, 16, 14, 15, 11, 16, 16, 13, 11, 14, 12, 11, 6,
- 16, 16, 16, 12, 16, 14, 15, 11, 16, 16, 13, 10, 14, 12, 12, 6,
- 16, 16, 16, 16, 16, 14, 16, 13, 16, 16, 14, 13, 12, 11, 12, 8,
- 16, 16, 16, 16, 16, 13, 16, 12, 16, 16, 15, 13, 13, 11, 12, 8,
- 16, 16, 16, 15, 16, 12, 16, 12, 16, 16, 16, 14, 14, 11, 13, 7,
- 16, 16, 16, 16, 16, 15, 16, 13, 16, 16, 14, 13, 13, 12, 12, 8,
- 16, 16, 16, 14, 15, 13, 15, 11, 16, 15, 14, 12, 13, 11, 11, 6,
- 16, 16, 16, 14, 16, 12, 15, 11, 16, 16, 15, 12, 14, 11, 12, 6,
- 16, 16, 16, 16, 16, 16, 16, 13, 16, 16, 15, 13, 14, 13, 12, 8,
- 16, 16, 16, 14, 16, 14, 16, 12, 16, 16, 14, 12, 13, 12, 11, 6,
- 16, 16, 16, 13, 16, 13, 15, 10, 16, 16, 14, 11, 14, 11, 11, 5,
- 16, 16, 15, 14, 16, 16, 16, 13, 14, 14, 12, 12, 12, 12, 12, 8,
- 16, 16, 16, 15, 16, 16, 16, 14, 16, 16, 14, 13, 14, 13, 13, 9,
- 16, 16, 16, 16, 16, 16, 16, 14, 16, 16, 16, 14, 16, 13, 15, 9,
- 16, 16, 14, 15, 16, 16, 16, 14, 14, 16, 12, 12, 13, 13, 12, 8,
- 16, 16, 16, 14, 16, 16, 16, 13, 16, 15, 13, 12, 14, 12, 12, 8,
- 16, 16, 16, 16, 16, 16, 16, 13, 16, 16, 14, 12, 16, 13, 13, 8,
- 16, 16, 16, 15, 16, 16, 16, 14, 16, 16, 11, 11, 15, 14, 12, 8,
- 16, 16, 16, 14, 16, 16, 16, 13, 16, 16, 12, 11, 15, 13, 12, 8,
- 16, 16, 16, 13, 16, 16, 16, 12, 16, 16, 13, 10, 16, 13, 12, 7,
- 16, 16, 16, 16, 16, 15, 16, 13, 14, 16, 13, 13, 12, 12, 12, 8,
- 16, 16, 16, 15, 16, 14, 16, 13, 16, 16, 14, 13, 13, 12, 12, 8,
- 16, 16, 16, 16, 16, 15, 16, 13, 16, 16, 16, 13, 15, 12, 14, 8,
- 16, 16, 16, 15, 16, 16, 16, 13, 14, 16, 13, 12, 12, 12, 11, 8,
- 16, 16, 16, 14, 16, 14, 16, 12, 14, 14, 13, 11, 13, 11, 11, 6,
- 16, 16, 16, 14, 16, 14, 16, 12, 16, 15, 14, 11, 14, 11, 12, 6,
- 16, 16, 16, 15, 16, 16, 16, 14, 16, 16, 12, 12, 14, 13, 11, 8,
- 16, 16, 15, 14, 16, 16, 16, 12, 16, 15, 12, 11, 13, 12, 11, 6,
- 16, 16, 16, 13, 16, 14, 16, 11, 16, 14, 13, 10, 14, 11, 11, 5,
- 16, 16, 16, 16, 16, 16, 16, 14, 14, 16, 15, 13, 11, 11, 11, 8,
- 16, 16, 16, 16, 16, 15, 16, 13, 16, 16, 16, 13, 12, 11, 12, 7,
- 16, 16, 16, 16, 16, 13, 16, 12, 16, 16, 16, 13, 13, 11, 13, 7,
- 16, 16, 16, 16, 16, 16, 16, 13, 16, 16, 14, 13, 12, 12, 11, 7,
- 16, 16, 16, 15, 16, 14, 15, 12, 16, 14, 13, 12, 12, 11, 11, 6,
- 16, 16, 16, 14, 16, 13, 15, 11, 16, 14, 14, 11, 13, 10, 11, 5,
- 16, 16, 16, 16, 16, 16, 16, 13, 16, 16, 13, 12, 12, 12, 11, 7,
- 16, 16, 16, 14, 16, 14, 15, 12, 16, 15, 12, 11, 12, 11, 10, 5,
- 16, 16, 16, 13, 16, 13, 14, 10, 16, 14, 12, 9, 12, 10, 9, 3,
- },
- {
- 2, 6, 6, 7, 6, 7, 8, 7, 7, 8, 7, 8, 7, 8, 8, 5,
- 5, 8, 9, 9, 9, 9, 12, 10, 10, 11, 10, 10, 10, 11, 11, 8,
- 9, 10, 13, 12, 13, 12, 15, 13, 13, 14, 13, 14, 13, 13, 14, 11,
- 5, 10, 9, 10, 10, 10, 12, 10, 10, 12, 10, 11, 11, 11, 11, 8,
- 6, 9, 10, 9, 10, 11, 12, 10, 10, 12, 11, 11, 10, 11, 11, 8,
- 9, 11, 12, 11, 12, 13, 14, 12, 13, 14, 14, 12, 13, 13, 13, 11,
- 10, 13, 11, 12, 14, 14, 15, 13, 13, 15, 12, 13, 14, 14, 14, 12,
- 9, 12, 12, 12, 13, 13, 15, 13, 13, 14, 13, 13, 14, 13, 15, 11,
- 8, 11, 12, 10, 12, 13, 14, 12, 13, 14, 14, 13, 13, 13, 14, 11,
- 5, 9, 10, 10, 9, 10, 12, 11, 10, 12, 11, 11, 9, 11, 11, 9,
- 6, 10, 10, 11, 10, 10, 12, 11, 11, 12, 11, 11, 11, 11, 11, 9,
- 9, 11, 13, 13, 12, 11, 14, 12, 13, 15, 13, 13, 14, 13, 14, 11,
- 8, 11, 11, 12, 11, 12, 13, 12, 12, 13, 12, 13, 12, 12, 12, 10,
- 7, 10, 10, 11, 10, 11, 12, 11, 11, 12, 11, 11, 11, 11, 12, 9,
- 9, 12, 12, 12, 12, 12, 14, 12, 13, 14, 13, 13, 13, 13, 13, 11,
- 11, 14, 13, 15, 15, 16, 16, 15, 15, 16, 15, 15, 16, 16, 15, 13,
- 10, 12, 13, 13, 13, 14, 15, 13, 13, 14, 13, 13, 14, 14, 14, 11,
- 9, 12, 12, 12, 13, 13, 14, 12, 13, 14, 14, 13, 13, 13, 14, 11,
- 9, 13, 13, 13, 11, 12, 15, 13, 13, 15, 14, 14, 11, 13, 14, 11,
- 10, 13, 13, 13, 12, 12, 15, 13, 13, 15, 14, 14, 13, 13, 14, 11,
- 10, 12, 13, 13, 12, 11, 14, 12, 13, 15, 13, 13, 13, 13, 14, 11,
- 11, 14, 15, 15, 13, 14, 16, 14, 14, 16, 16, 14, 14, 15, 15, 13,
- 10, 13, 13, 13, 12, 13, 14, 13, 13, 14, 14, 14, 13, 13, 14, 11,
- 10, 12, 13, 13, 13, 12, 14, 13, 13, 14, 14, 13, 13, 13, 13, 11,
- 13, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15,
- 12, 15, 15, 15, 14, 15, 16, 14, 15, 16, 16, 15, 16, 15, 15, 13,
- 10, 12, 12, 12, 13, 13, 14, 12, 13, 14, 13, 13, 13, 13, 13, 11,
- 6, 10, 10, 11, 10, 11, 12, 11, 10, 12, 11, 11, 10, 11, 11, 9,
- 8, 11, 12, 12, 12, 12, 13, 12, 12, 13, 12, 13, 12, 13, 13, 10,
- 11, 13, 15, 14, 15, 14, 16, 14, 15, 16, 16, 14, 15, 15, 15, 13,
- 7, 11, 10, 12, 11, 11, 13, 11, 11, 13, 10, 11, 12, 12, 12, 10,
- 7, 11, 11, 11, 11, 11, 13, 11, 11, 13, 11, 12, 12, 12, 12, 9,
- 10, 12, 13, 13, 13, 13, 15, 13, 14, 15, 14, 14, 14, 14, 15, 11,
- 10, 13, 12, 14, 14, 14, 15, 13, 13, 15, 12, 13, 15, 15, 14, 12,
- 10, 13, 12, 12, 13, 13, 15, 14, 13, 15, 13, 13, 14, 14, 14, 11,
- 10, 13, 13, 12, 13, 14, 15, 13, 13, 15, 13, 13, 14, 14, 14, 11,
- 7, 10, 11, 11, 10, 11, 12, 11, 10, 12, 12, 12, 9, 11, 12, 9,
- 7, 11, 11, 11, 11, 11, 13, 11, 11, 13, 12, 12, 11, 12, 12, 9,
- 10, 12, 14, 13, 13, 13, 16, 13, 14, 16, 14, 14, 13, 13, 14, 11,
- 8, 11, 11, 12, 11, 12, 13, 12, 12, 13, 12, 12, 12, 12, 12, 10,
- 6, 9, 9, 10, 9, 10, 11, 10, 10, 11, 10, 10, 10, 10, 10, 8,
- 8, 11, 11, 11, 12, 11, 13, 11, 12, 13, 12, 12, 12, 12, 12, 10,
- 11, 14, 13, 14, 14, 14, 16, 14, 14, 16, 14, 14, 15, 15, 14, 12,
- 9, 12, 11, 12, 12, 12, 13, 12, 12, 13, 12, 12, 12, 12, 12, 10,
- 8, 11, 11, 11, 11, 11, 13, 11, 12, 12, 12, 12, 12, 12, 12, 9,
- 10, 13, 14, 13, 11, 13, 14, 14, 13, 15, 15, 14, 10, 13, 14, 11,
- 10, 13, 13, 13, 12, 13, 14, 13, 13, 14, 14, 14, 13, 13, 13, 11,
- 10, 13, 14, 13, 13, 12, 15, 13, 14, 15, 14, 14, 14, 13, 14, 12,
- 11, 14, 14, 14, 13, 13, 15, 14, 14, 15, 14, 15, 13, 14, 14, 12,
- 9, 11, 12, 12, 11, 11, 13, 12, 12, 13, 12, 12, 12, 12, 12, 10,
- 9, 11, 12, 12, 12, 11, 13, 11, 12, 13, 12, 12, 12, 12, 12, 10,
- 13, 15, 15, 16, 15, 16, 16, 15, 16, 16, 16, 15, 15, 15, 16, 14,
- 10, 13, 13, 13, 13, 13, 14, 13, 13, 14, 13, 13, 13, 13, 13, 11,
- 8, 11, 11, 11, 11, 11, 12, 11, 11, 12, 12, 11, 12, 11, 12, 9,
- 11, 14, 14, 15, 14, 15, 15, 14, 13, 15, 14, 15, 12, 14, 15, 13,
- 12, 15, 15, 15, 15, 15, 16, 15, 15, 16, 16, 16, 15, 16, 15, 13,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15,
- 11, 14, 13, 15, 14, 14, 16, 14, 14, 16, 13, 14, 15, 14, 15, 12,
- 11, 14, 13, 14, 14, 14, 16, 15, 14, 16, 14, 14, 15, 15, 15, 12,
- 13, 15, 15, 15, 15, 16, 16, 15, 16, 16, 16, 15, 16, 16, 16, 13,
- 11, 14, 13, 14, 14, 14, 15, 14, 14, 16, 12, 14, 16, 16, 14, 12,
- 11, 14, 14, 14, 14, 15, 16, 15, 14, 16, 13, 14, 16, 15, 14, 12,
- 12, 14, 14, 14, 14, 14, 16, 14, 15, 16, 14, 14, 14, 15, 15, 12,
- 11, 14, 14, 14, 13, 14, 16, 15, 13, 16, 15, 15, 11, 14, 14, 12,
- 11, 14, 14, 15, 14, 14, 16, 14, 14, 15, 14, 14, 13, 15, 15, 12,
- 13, 15, 16, 15, 15, 15, 16, 15, 16, 16, 16, 16, 15, 15, 16, 13,
- 11, 14, 14, 14, 14, 14, 15, 14, 14, 16, 14, 14, 14, 15, 14, 12,
- 9, 12, 12, 12, 12, 12, 13, 12, 12, 13, 12, 13, 12, 12, 12, 10,
- 11, 13, 13, 13, 13, 13, 14, 13, 13, 14, 13, 14, 13, 13, 14, 11,
- 12, 15, 14, 15, 15, 15, 16, 15, 14, 16, 14, 14, 16, 16, 14, 13,
- 10, 12, 12, 12, 12, 12, 14, 12, 13, 13, 12, 12, 13, 13, 13, 10,
- 10, 12, 12, 12, 12, 12, 14, 12, 12, 13, 12, 12, 12, 12, 12, 10,
- 10, 14, 14, 14, 12, 14, 16, 14, 13, 16, 16, 16, 10, 13, 14, 12,
- 11, 14, 14, 14, 13, 14, 16, 14, 14, 16, 15, 14, 12, 13, 14, 12,
- 12, 14, 14, 14, 14, 14, 16, 14, 14, 16, 15, 15, 14, 14, 15, 12,
- 12, 14, 15, 15, 14, 15, 16, 14, 15, 15, 15, 15, 13, 15, 14, 12,
- 9, 12, 12, 12, 12, 13, 13, 12, 12, 13, 13, 12, 11, 12, 12, 10,
- 10, 12, 12, 12, 12, 12, 13, 12, 12, 13, 12, 12, 12, 12, 12, 10,
- 13, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 15, 16, 15, 13,
- 10, 12, 12, 13, 12, 13, 13, 12, 13, 14, 13, 13, 12, 13, 13, 10,
- 7, 10, 10, 10, 10, 10, 11, 10, 10, 11, 10, 10, 10, 10, 10, 7,
- },
- },
- {
- {
- 10, 10, 9, 8, 9, 8, 9, 7, 9, 9, 8, 7, 8, 7, 7, 4,
- 13, 11, 12, 9, 12, 9, 12, 9, 12, 11, 11, 9, 10, 9, 9, 6,
- 15, 12, 15, 11, 14, 10, 14, 10, 14, 13, 13, 11, 13, 11, 12, 7,
- 13, 12, 11, 9, 12, 11, 12, 9, 12, 12, 10, 9, 10, 10, 9, 6,
- 14, 13, 12, 10, 13, 12, 13, 9, 13, 12, 11, 10, 12, 11, 10, 6,
- 16, 14, 14, 10, 15, 13, 14, 10, 15, 15, 14, 11, 14, 12, 12, 8,
- 15, 14, 12, 11, 15, 14, 13, 11, 14, 14, 11, 10, 13, 12, 11, 8,
- 15, 16, 13, 11, 16, 14, 14, 11, 15, 15, 12, 10, 14, 13, 12, 8,
- 16, 15, 14, 10, 16, 14, 14, 10, 16, 15, 14, 10, 14, 13, 12, 7,
- 13, 12, 12, 11, 11, 9, 12, 9, 12, 12, 11, 10, 10, 9, 9, 6,
- 13, 13, 14, 12, 12, 10, 12, 10, 14, 13, 12, 11, 11, 10, 10, 7,
- 16, 14, 16, 13, 14, 11, 15, 10, 16, 15, 14, 12, 14, 11, 12, 8,
- 14, 14, 13, 12, 13, 12, 13, 10, 13, 13, 12, 11, 11, 10, 10, 7,
- 15, 14, 14, 12, 14, 12, 13, 10, 14, 13, 12, 11, 12, 11, 11, 7,
- 16, 15, 16, 13, 15, 13, 15, 10, 16, 15, 14, 12, 14, 12, 12, 7,
- 15, 16, 14, 13, 16, 14, 14, 12, 15, 15, 12, 12, 13, 12, 12, 8,
- 16, 16, 14, 13, 16, 14, 14, 11, 15, 15, 14, 11, 14, 12, 12, 8,
- 16, 16, 15, 12, 16, 14, 15, 10, 16, 16, 13, 12, 14, 13, 12, 7,
- 14, 14, 14, 13, 13, 11, 13, 11, 14, 14, 13, 12, 11, 10, 11, 8,
- 16, 15, 16, 13, 13, 11, 14, 11, 15, 14, 14, 13, 12, 11, 12, 8,
- 15, 15, 16, 14, 14, 10, 14, 10, 16, 15, 15, 13, 14, 10, 12, 8,
- 16, 16, 16, 14, 15, 13, 14, 12, 15, 15, 13, 13, 13, 12, 12, 8,
- 16, 16, 16, 14, 15, 13, 14, 11, 16, 16, 14, 13, 13, 12, 12, 8,
- 16, 16, 16, 14, 16, 12, 15, 11, 16, 15, 15, 13, 14, 12, 12, 8,
- 16, 16, 16, 16, 16, 15, 15, 13, 16, 16, 14, 13, 14, 13, 12, 9,
- 16, 16, 16, 14, 16, 15, 15, 11, 16, 16, 14, 13, 15, 13, 12, 8,
- 16, 16, 16, 14, 16, 14, 14, 10, 16, 16, 15, 13, 14, 12, 12, 7,
- 12, 12, 12, 11, 12, 11, 12, 10, 11, 11, 10, 9, 9, 9, 9, 6,
- 14, 13, 14, 12, 13, 12, 13, 10, 13, 13, 12, 10, 12, 10, 11, 7,
- 16, 14, 16, 13, 15, 13, 16, 12, 15, 14, 14, 12, 14, 12, 13, 8,
- 14, 14, 13, 11, 14, 12, 13, 11, 12, 12, 10, 10, 11, 10, 10, 7,
- 14, 14, 13, 12, 14, 12, 13, 11, 13, 13, 12, 10, 12, 11, 10, 7,
- 16, 15, 15, 12, 16, 14, 15, 11, 16, 14, 13, 11, 14, 12, 12, 8,
- 16, 16, 13, 13, 16, 15, 14, 12, 14, 14, 11, 11, 13, 12, 11, 8,
- 16, 16, 14, 12, 16, 14, 14, 12, 15, 14, 12, 11, 14, 12, 12, 8,
- 16, 15, 14, 11, 16, 15, 15, 11, 16, 15, 13, 11, 14, 13, 12, 8,
- 14, 13, 13, 12, 13, 11, 13, 10, 12, 13, 11, 10, 10, 10, 10, 7,
- 15, 14, 14, 13, 13, 12, 13, 11, 14, 13, 12, 11, 12, 10, 11, 7,
- 16, 15, 16, 14, 15, 12, 15, 11, 16, 14, 14, 12, 14, 11, 12, 8,
- 14, 15, 13, 12, 14, 13, 13, 11, 13, 13, 11, 11, 11, 10, 10, 7,
- 14, 14, 14, 12, 14, 13, 13, 10, 14, 13, 12, 10, 12, 10, 10, 6,
- 16, 15, 15, 13, 16, 13, 15, 11, 15, 14, 13, 11, 13, 11, 11, 7,
- 16, 16, 14, 13, 16, 15, 14, 12, 15, 15, 12, 11, 13, 12, 11, 8,
- 16, 16, 14, 13, 16, 14, 14, 11, 15, 14, 12, 11, 13, 12, 11, 7,
- 16, 16, 15, 12, 16, 14, 14, 11, 15, 15, 13, 11, 14, 12, 11, 6,
- 16, 15, 15, 14, 14, 12, 14, 12, 13, 14, 13, 12, 11, 11, 11, 8,
- 16, 16, 16, 14, 14, 12, 15, 12, 15, 14, 14, 12, 12, 11, 12, 8,
- 16, 16, 16, 15, 14, 12, 15, 12, 16, 15, 14, 13, 13, 11, 12, 8,
- 16, 16, 16, 15, 15, 14, 15, 12, 14, 14, 13, 12, 12, 11, 11, 8,
- 16, 16, 15, 14, 14, 12, 14, 11, 14, 14, 13, 12, 12, 11, 11, 7,
- 16, 16, 16, 14, 15, 12, 14, 11, 15, 15, 14, 12, 13, 11, 12, 7,
- 16, 16, 16, 16, 16, 15, 16, 13, 15, 15, 14, 12, 13, 12, 11, 8,
- 16, 16, 16, 14, 15, 14, 14, 12, 16, 15, 13, 12, 13, 12, 11, 7,
- 16, 16, 16, 13, 16, 13, 14, 10, 16, 15, 14, 11, 13, 11, 11, 6,
- 14, 15, 13, 13, 14, 13, 14, 12, 12, 13, 11, 11, 11, 11, 10, 8,
- 16, 16, 15, 13, 16, 14, 16, 13, 14, 14, 13, 12, 13, 12, 12, 8,
- 16, 16, 16, 14, 16, 14, 16, 13, 16, 14, 15, 13, 15, 13, 13, 9,
- 15, 15, 14, 14, 15, 14, 14, 12, 13, 14, 11, 11, 12, 12, 11, 8,
- 15, 16, 15, 13, 15, 14, 14, 12, 14, 14, 12, 11, 13, 12, 12, 8,
- 16, 16, 16, 13, 16, 15, 15, 13, 16, 15, 14, 11, 15, 12, 13, 8,
- 16, 16, 14, 13, 16, 15, 15, 13, 14, 14, 10, 11, 14, 12, 11, 8,
- 16, 16, 15, 13, 16, 16, 15, 13, 15, 14, 12, 11, 14, 13, 12, 8,
- 16, 16, 15, 13, 16, 15, 16, 12, 16, 14, 13, 10, 15, 13, 12, 7,
- 15, 15, 15, 14, 14, 14, 15, 12, 13, 14, 12, 12, 11, 11, 11, 8,
- 16, 15, 16, 14, 15, 13, 15, 12, 14, 14, 13, 12, 12, 11, 12, 8,
- 16, 16, 16, 15, 16, 14, 16, 13, 16, 15, 14, 12, 14, 11, 13, 8,
- 16, 16, 15, 14, 16, 14, 15, 13, 14, 14, 12, 11, 12, 11, 11, 8,
- 15, 16, 15, 14, 15, 14, 14, 12, 14, 13, 12, 11, 12, 11, 11, 7,
- 16, 16, 16, 14, 16, 13, 16, 12, 15, 14, 13, 11, 13, 11, 12, 7,
- 16, 16, 15, 14, 16, 15, 15, 13, 14, 15, 11, 11, 13, 12, 11, 8,
- 16, 16, 15, 13, 16, 14, 15, 12, 15, 14, 12, 11, 13, 11, 11, 7,
- 16, 16, 15, 13, 16, 14, 16, 12, 15, 14, 13, 10, 13, 11, 11, 6,
- 16, 16, 16, 14, 14, 14, 15, 13, 14, 14, 14, 12, 11, 11, 11, 8,
- 16, 16, 16, 14, 15, 14, 16, 13, 15, 14, 14, 13, 12, 11, 11, 7,
- 16, 16, 16, 16, 15, 13, 16, 12, 15, 15, 14, 12, 13, 10, 12, 7,
- 16, 16, 16, 14, 15, 15, 14, 13, 14, 14, 13, 12, 12, 11, 11, 8,
- 16, 15, 16, 14, 16, 13, 15, 12, 14, 14, 13, 12, 12, 10, 10, 6,
- 16, 15, 16, 14, 16, 13, 16, 11, 16, 14, 13, 11, 13, 10, 11, 6,
- 16, 16, 16, 15, 16, 16, 15, 13, 14, 16, 12, 12, 12, 12, 10, 7,
- 16, 16, 16, 14, 16, 14, 14, 12, 15, 15, 12, 11, 12, 11, 10, 6,
- 16, 16, 16, 13, 16, 13, 15, 10, 15, 14, 13, 10, 13, 10, 10, 4,
- },
- {
- 1, 6, 6, 7, 6, 7, 9, 8, 7, 9, 7, 8, 7, 8, 8, 6,
- 6, 9, 10, 10, 10, 10, 12, 11, 10, 12, 11, 11, 11, 11, 12, 9,
- 9, 10, 13, 11, 13, 12, 14, 13, 14, 14, 14, 14, 14, 14, 14, 12,
- 6, 10, 9, 10, 10, 11, 13, 11, 11, 13, 10, 12, 11, 12, 12, 9,
- 6, 10, 10, 10, 10, 11, 13, 11, 11, 13, 12, 12, 11, 12, 12, 9,
- 9, 11, 13, 12, 13, 14, 15, 13, 14, 16, 14, 14, 14, 14, 15, 12,
- 10, 13, 11, 13, 14, 14, 16, 14, 14, 15, 13, 14, 15, 15, 16, 12,
- 9, 13, 12, 12, 14, 14, 16, 14, 14, 15, 14, 14, 15, 15, 15, 12,
- 8, 11, 12, 11, 13, 14, 15, 13, 13, 15, 14, 14, 13, 15, 15, 11,
- 6, 10, 10, 11, 9, 10, 13, 11, 10, 13, 11, 12, 10, 12, 12, 9,
- 6, 10, 10, 11, 11, 10, 13, 11, 11, 13, 11, 12, 12, 12, 13, 10,
- 9, 12, 13, 13, 13, 12, 16, 13, 14, 15, 14, 14, 15, 14, 15, 12,
- 8, 12, 12, 13, 12, 13, 15, 14, 13, 15, 13, 14, 13, 13, 14, 11,
- 7, 11, 11, 12, 11, 12, 13, 12, 12, 13, 12, 13, 12, 13, 13, 10,
- 9, 12, 13, 13, 13, 13, 16, 13, 13, 15, 14, 14, 14, 15, 15, 12,
- 11, 15, 14, 15, 15, 16, 16, 16, 15, 16, 15, 16, 16, 16, 16, 14,
- 10, 13, 13, 14, 14, 14, 16, 15, 14, 16, 15, 15, 15, 15, 16, 13,
- 9, 12, 13, 13, 13, 14, 16, 14, 13, 15, 14, 14, 14, 16, 15, 12,
- 10, 13, 14, 14, 11, 13, 16, 14, 14, 16, 15, 15, 12, 14, 15, 12,
- 10, 13, 14, 14, 12, 12, 16, 15, 14, 16, 15, 15, 14, 14, 16, 12,
- 9, 12, 13, 14, 13, 11, 16, 13, 14, 15, 13, 14, 14, 14, 15, 12,
- 11, 15, 16, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 10, 13, 14, 14, 13, 14, 16, 15, 14, 16, 16, 16, 14, 15, 16, 13,
- 10, 13, 13, 14, 13, 13, 16, 13, 13, 14, 14, 15, 15, 14, 15, 13,
- 13, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15,
- 12, 16, 16, 16, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 10, 12, 13, 14, 13, 13, 14, 13, 13, 14, 13, 14, 14, 14, 15, 12,
- 6, 10, 11, 11, 10, 11, 13, 12, 11, 13, 11, 12, 11, 12, 12, 10,
- 8, 12, 13, 13, 12, 13, 14, 14, 13, 15, 14, 14, 14, 14, 15, 12,
- 12, 14, 16, 15, 15, 15, 16, 15, 16, 16, 16, 16, 16, 16, 16, 14,
- 7, 11, 11, 12, 12, 12, 14, 13, 12, 14, 11, 12, 13, 13, 13, 11,
- 8, 11, 12, 12, 12, 12, 14, 13, 12, 14, 12, 13, 13, 14, 14, 11,
- 11, 13, 14, 14, 14, 14, 16, 15, 15, 16, 15, 15, 16, 16, 16, 13,
- 10, 14, 12, 14, 14, 15, 16, 15, 13, 16, 12, 14, 16, 16, 15, 13,
- 10, 13, 13, 14, 14, 15, 16, 15, 14, 16, 14, 15, 15, 16, 16, 12,
- 10, 13, 14, 13, 14, 14, 16, 15, 14, 16, 15, 15, 14, 16, 16, 13,
- 7, 11, 11, 11, 10, 12, 14, 13, 11, 14, 13, 13, 10, 12, 13, 10,
- 8, 11, 12, 12, 11, 12, 14, 13, 12, 15, 13, 13, 12, 13, 14, 11,
- 11, 13, 14, 14, 14, 14, 16, 15, 14, 16, 15, 16, 16, 16, 16, 14,
- 8, 12, 12, 13, 12, 13, 15, 14, 12, 15, 13, 13, 13, 14, 14, 11,
- 6, 10, 10, 11, 10, 11, 13, 12, 11, 13, 11, 12, 11, 12, 12, 9,
- 9, 12, 13, 13, 13, 13, 14, 13, 13, 15, 14, 14, 14, 14, 14, 12,
- 11, 15, 14, 15, 14, 15, 16, 16, 16, 16, 15, 16, 16, 16, 16, 14,
- 9, 13, 12, 13, 13, 13, 15, 14, 13, 14, 13, 14, 14, 15, 14, 12,
- 9, 12, 12, 12, 12, 13, 14, 13, 13, 14, 13, 13, 13, 13, 14, 11,
- 10, 13, 15, 14, 12, 14, 16, 14, 14, 16, 15, 15, 12, 14, 16, 12,
- 10, 14, 14, 14, 13, 14, 16, 15, 14, 16, 16, 16, 13, 14, 16, 13,
- 11, 13, 14, 14, 14, 13, 16, 14, 14, 16, 15, 15, 15, 15, 16, 13,
- 11, 15, 15, 15, 14, 15, 16, 16, 15, 16, 16, 16, 14, 16, 16, 13,
- 9, 13, 13, 13, 12, 13, 15, 14, 13, 15, 14, 14, 13, 14, 15, 11,
- 9, 12, 12, 13, 12, 12, 14, 13, 13, 14, 13, 14, 14, 14, 14, 11,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15,
- 11, 14, 14, 15, 15, 14, 16, 16, 14, 16, 14, 15, 15, 16, 16, 12,
- 9, 12, 12, 13, 12, 12, 14, 12, 12, 14, 13, 13, 13, 13, 14, 11,
- 11, 14, 14, 16, 14, 16, 16, 16, 13, 16, 14, 16, 14, 16, 16, 13,
- 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 11, 15, 14, 16, 14, 15, 16, 16, 15, 16, 14, 15, 16, 16, 16, 13,
- 11, 15, 14, 16, 15, 16, 16, 16, 15, 16, 15, 16, 16, 16, 16, 14,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 11, 14, 13, 14, 15, 14, 16, 15, 14, 16, 12, 14, 16, 16, 15, 13,
- 11, 14, 14, 16, 14, 15, 16, 16, 15, 16, 14, 15, 16, 16, 16, 14,
- 12, 14, 14, 15, 14, 16, 16, 15, 14, 16, 15, 15, 15, 16, 16, 13,
- 11, 14, 15, 15, 13, 15, 16, 16, 14, 16, 16, 16, 12, 15, 15, 13,
- 11, 15, 16, 16, 15, 16, 16, 16, 15, 16, 16, 16, 14, 16, 16, 14,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15,
- 11, 15, 14, 16, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 13,
- 10, 13, 13, 14, 14, 14, 16, 15, 14, 16, 14, 15, 14, 14, 15, 12,
- 12, 15, 14, 16, 14, 15, 16, 15, 15, 16, 15, 15, 16, 15, 16, 13,
- 12, 16, 14, 16, 15, 16, 16, 16, 16, 16, 14, 15, 16, 16, 16, 14,
- 10, 13, 13, 14, 14, 13, 16, 14, 13, 16, 13, 14, 15, 15, 15, 12,
- 10, 13, 13, 14, 13, 13, 16, 14, 14, 15, 14, 14, 14, 14, 15, 12,
- 10, 14, 15, 14, 13, 15, 16, 15, 14, 16, 16, 16, 11, 14, 16, 12,
- 11, 14, 14, 16, 14, 15, 16, 15, 15, 16, 16, 16, 13, 15, 16, 13,
- 12, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 15, 16, 13,
- 12, 16, 16, 16, 15, 16, 16, 16, 16, 16, 16, 16, 14, 16, 16, 13,
- 10, 13, 14, 14, 13, 14, 16, 14, 13, 16, 15, 14, 12, 14, 16, 11,
- 10, 13, 13, 14, 13, 14, 16, 14, 14, 15, 14, 14, 13, 14, 14, 11,
- 13, 16, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 11, 13, 14, 15, 14, 14, 16, 15, 14, 16, 14, 15, 14, 15, 16, 12,
- 8, 11, 11, 11, 11, 12, 13, 12, 11, 13, 11, 12, 11, 12, 12, 9,
- },
- },
- {
- {
- 8, 8, 8, 7, 8, 7, 8, 6, 8, 8, 7, 6, 7, 6, 6, 4,
- 11, 10, 11, 9, 11, 9, 11, 8, 11, 10, 10, 9, 10, 8, 9, 6,
- 13, 11, 13, 10, 12, 10, 13, 9, 13, 12, 13, 10, 12, 10, 11, 7,
- 11, 11, 10, 9, 11, 10, 11, 9, 10, 11, 9, 8, 10, 9, 9, 6,
- 12, 12, 11, 9, 12, 11, 12, 9, 12, 12, 11, 9, 11, 10, 10, 7,
- 14, 13, 13, 10, 15, 12, 13, 10, 15, 13, 13, 10, 13, 12, 12, 8,
- 13, 13, 11, 10, 14, 13, 12, 10, 13, 13, 10, 10, 12, 11, 10, 8,
- 15, 14, 13, 10, 14, 13, 13, 10, 14, 13, 12, 10, 13, 12, 11, 8,
- 14, 14, 13, 10, 16, 13, 13, 10, 15, 14, 13, 10, 13, 12, 12, 8,
- 11, 11, 11, 10, 10, 9, 10, 9, 10, 10, 10, 9, 9, 8, 9, 6,
- 12, 12, 12, 11, 11, 9, 12, 9, 12, 12, 11, 10, 11, 9, 10, 7,
- 14, 13, 14, 12, 13, 10, 13, 10, 15, 13, 14, 12, 12, 10, 12, 8,
- 13, 13, 12, 11, 12, 11, 12, 10, 12, 12, 11, 10, 11, 10, 10, 7,
- 14, 13, 13, 11, 13, 12, 12, 10, 13, 13, 12, 11, 12, 10, 10, 7,
- 16, 15, 15, 12, 14, 12, 13, 10, 15, 14, 13, 12, 13, 12, 12, 8,
- 15, 15, 13, 13, 14, 14, 14, 12, 14, 14, 12, 11, 13, 12, 11, 8,
- 15, 16, 14, 12, 15, 14, 13, 11, 15, 15, 13, 12, 13, 12, 11, 8,
- 16, 15, 15, 12, 16, 14, 14, 10, 15, 15, 14, 12, 14, 12, 12, 8,
- 13, 13, 13, 13, 11, 10, 12, 10, 12, 13, 12, 11, 10, 10, 10, 8,
- 14, 13, 14, 13, 12, 10, 13, 10, 14, 14, 13, 12, 12, 10, 11, 8,
- 15, 14, 16, 14, 13, 10, 14, 10, 16, 14, 14, 13, 13, 10, 12, 8,
- 15, 15, 14, 14, 14, 13, 13, 12, 14, 14, 13, 12, 12, 11, 11, 9,
- 15, 15, 15, 14, 14, 12, 14, 11, 15, 14, 13, 13, 13, 11, 11, 8,
- 16, 15, 16, 14, 15, 12, 14, 11, 16, 16, 15, 13, 14, 12, 12, 8,
- 16, 16, 16, 14, 15, 14, 14, 12, 15, 15, 14, 13, 13, 12, 11, 9,
- 16, 16, 15, 15, 16, 14, 14, 11, 16, 16, 14, 13, 14, 12, 12, 8,
- 16, 16, 16, 13, 15, 13, 14, 10, 16, 16, 15, 13, 14, 12, 12, 8,
- 11, 11, 11, 10, 11, 10, 11, 9, 10, 10, 9, 8, 9, 9, 9, 6,
- 12, 12, 13, 11, 12, 11, 12, 10, 12, 12, 11, 10, 11, 10, 10, 7,
- 15, 13, 15, 12, 14, 13, 14, 11, 14, 13, 13, 11, 13, 11, 12, 8,
- 12, 13, 12, 11, 13, 11, 12, 10, 11, 12, 10, 9, 11, 10, 10, 7,
- 14, 13, 13, 11, 14, 12, 13, 11, 12, 12, 11, 10, 12, 11, 10, 7,
- 15, 14, 15, 12, 15, 13, 15, 11, 15, 14, 13, 11, 13, 12, 12, 8,
- 14, 14, 13, 12, 15, 14, 13, 12, 13, 13, 11, 10, 13, 12, 11, 8,
- 16, 15, 13, 12, 15, 14, 14, 12, 14, 14, 12, 11, 14, 12, 11, 8,
- 16, 15, 14, 12, 16, 15, 15, 11, 15, 14, 13, 11, 14, 13, 12, 8,
- 12, 12, 12, 11, 12, 11, 12, 10, 11, 11, 11, 10, 10, 9, 9, 7,
- 13, 13, 14, 12, 13, 11, 13, 11, 13, 12, 12, 11, 11, 10, 10, 7,
- 15, 14, 16, 13, 14, 12, 14, 11, 14, 14, 14, 12, 13, 11, 12, 8,
- 13, 13, 13, 12, 13, 12, 13, 11, 12, 12, 11, 10, 11, 10, 10, 7,
- 14, 14, 13, 12, 13, 12, 13, 10, 13, 13, 11, 10, 12, 10, 10, 7,
- 16, 15, 15, 13, 15, 12, 14, 11, 15, 14, 13, 11, 13, 11, 11, 7,
- 15, 16, 14, 13, 15, 14, 14, 12, 14, 14, 12, 11, 13, 12, 11, 8,
- 16, 15, 14, 13, 15, 14, 14, 11, 14, 14, 12, 11, 13, 12, 11, 7,
- 16, 15, 15, 12, 16, 14, 14, 11, 15, 14, 13, 11, 14, 12, 11, 7,
- 14, 15, 14, 14, 13, 12, 13, 12, 13, 13, 12, 12, 11, 10, 11, 8,
- 15, 15, 15, 14, 13, 12, 14, 12, 14, 14, 13, 12, 12, 11, 11, 8,
- 16, 15, 16, 14, 14, 12, 15, 12, 16, 14, 14, 13, 13, 11, 12, 8,
- 15, 15, 15, 14, 14, 13, 14, 12, 14, 14, 13, 12, 12, 11, 11, 8,
- 15, 15, 15, 14, 14, 13, 14, 12, 14, 14, 13, 12, 12, 11, 11, 7,
- 16, 15, 16, 14, 15, 12, 15, 11, 15, 14, 14, 12, 13, 11, 12, 7,
- 16, 16, 16, 15, 16, 15, 14, 13, 15, 15, 13, 12, 13, 12, 11, 9,
- 16, 16, 16, 14, 15, 14, 14, 12, 15, 15, 13, 12, 14, 12, 11, 8,
- 16, 16, 16, 14, 16, 14, 14, 11, 15, 15, 14, 12, 14, 12, 11, 7,
- 13, 13, 13, 12, 13, 12, 13, 11, 11, 12, 11, 10, 10, 10, 10, 8,
- 15, 14, 14, 13, 14, 13, 14, 12, 13, 13, 12, 11, 13, 11, 11, 8,
- 16, 15, 16, 14, 16, 14, 16, 13, 15, 14, 14, 12, 14, 12, 13, 9,
- 14, 15, 13, 13, 14, 13, 14, 12, 12, 13, 11, 11, 12, 11, 11, 8,
- 15, 15, 14, 13, 15, 14, 14, 12, 13, 13, 12, 11, 13, 12, 11, 8,
- 16, 16, 16, 13, 16, 15, 16, 13, 15, 14, 14, 12, 14, 13, 13, 9,
- 14, 15, 13, 13, 16, 15, 15, 13, 13, 14, 11, 11, 13, 12, 11, 9,
- 16, 16, 14, 13, 16, 15, 16, 13, 14, 14, 12, 11, 14, 13, 12, 8,
- 16, 16, 15, 12, 16, 15, 15, 12, 15, 14, 13, 11, 14, 13, 12, 8,
- 14, 14, 14, 13, 14, 13, 14, 12, 12, 13, 12, 11, 11, 11, 11, 8,
- 15, 15, 15, 14, 14, 13, 15, 12, 14, 13, 13, 12, 12, 11, 11, 8,
- 16, 16, 16, 15, 15, 14, 16, 13, 15, 14, 14, 12, 14, 12, 12, 9,
- 15, 15, 14, 14, 14, 14, 14, 13, 13, 14, 12, 11, 12, 11, 11, 8,
- 15, 15, 15, 13, 15, 14, 14, 12, 13, 13, 12, 11, 12, 11, 11, 7,
- 16, 15, 16, 14, 16, 14, 15, 12, 15, 14, 14, 12, 13, 12, 12, 8,
- 16, 16, 15, 14, 16, 15, 15, 13, 14, 14, 12, 11, 13, 12, 11, 8,
- 16, 16, 15, 13, 16, 14, 14, 12, 14, 15, 12, 11, 13, 12, 11, 7,
- 16, 16, 16, 13, 16, 15, 15, 12, 15, 14, 13, 11, 14, 12, 11, 7,
- 15, 15, 15, 14, 13, 13, 14, 13, 13, 14, 13, 12, 11, 11, 11, 8,
- 16, 16, 16, 14, 15, 13, 15, 12, 14, 14, 14, 13, 12, 11, 12, 8,
- 16, 16, 16, 14, 15, 13, 15, 12, 15, 14, 14, 12, 13, 11, 12, 8,
- 15, 16, 16, 14, 15, 14, 15, 13, 14, 14, 12, 12, 11, 11, 11, 8,
- 16, 15, 15, 14, 15, 14, 14, 12, 14, 14, 13, 12, 12, 11, 11, 7,
- 16, 16, 16, 13, 15, 13, 15, 12, 15, 14, 14, 12, 13, 11, 11, 7,
- 16, 16, 16, 15, 15, 16, 15, 13, 14, 14, 12, 12, 12, 12, 11, 8,
- 16, 16, 16, 14, 16, 14, 14, 12, 15, 15, 13, 11, 12, 11, 10, 7,
- 16, 16, 15, 13, 16, 14, 14, 11, 15, 14, 13, 10, 13, 11, 10, 5,
- },
- {
- 1, 6, 6, 7, 6, 7, 9, 7, 6, 9, 7, 8, 7, 8, 8, 5,
- 5, 8, 10, 10, 10, 10, 12, 11, 11, 12, 11, 11, 11, 12, 12, 9,
- 9, 10, 12, 11, 13, 12, 15, 13, 14, 15, 15, 14, 14, 15, 15, 12,
- 6, 10, 9, 10, 10, 11, 13, 12, 11, 13, 11, 12, 12, 12, 12, 10,
- 6, 10, 10, 10, 11, 11, 13, 11, 11, 13, 12, 12, 11, 12, 12, 10,
- 9, 12, 13, 12, 13, 13, 16, 13, 14, 16, 15, 14, 14, 15, 16, 12,
- 9, 13, 11, 13, 14, 14, 16, 15, 14, 16, 13, 15, 15, 15, 15, 12,
- 9, 13, 12, 13, 14, 15, 16, 15, 14, 16, 15, 15, 15, 15, 16, 12,
- 8, 12, 12, 11, 13, 14, 15, 13, 13, 15, 14, 14, 14, 14, 14, 12,
- 6, 10, 10, 11, 9, 10, 13, 11, 11, 13, 12, 12, 10, 12, 12, 9,
- 6, 10, 11, 11, 11, 10, 13, 12, 11, 13, 12, 12, 12, 12, 13, 10,
- 9, 12, 13, 13, 13, 12, 16, 13, 14, 16, 14, 15, 16, 14, 15, 12,
- 8, 12, 13, 13, 13, 13, 16, 14, 13, 16, 13, 14, 14, 14, 14, 12,
- 7, 11, 11, 12, 11, 12, 14, 13, 12, 14, 13, 13, 12, 13, 13, 11,
- 9, 12, 13, 13, 13, 13, 15, 14, 14, 16, 16, 15, 15, 15, 16, 12,
- 11, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 10, 14, 14, 15, 15, 16, 16, 16, 14, 16, 14, 16, 16, 16, 16, 13,
- 9, 13, 13, 13, 14, 14, 16, 14, 14, 16, 15, 14, 14, 16, 16, 13,
- 9, 13, 14, 14, 11, 13, 16, 14, 13, 16, 15, 16, 13, 14, 15, 12,
- 10, 13, 14, 15, 13, 12, 16, 14, 14, 16, 15, 15, 14, 14, 16, 13,
- 9, 12, 13, 14, 12, 11, 15, 13, 13, 15, 13, 14, 15, 14, 16, 12,
- 11, 15, 16, 16, 14, 16, 16, 16, 15, 16, 16, 16, 16, 16, 16, 13,
- 11, 14, 14, 15, 13, 14, 16, 15, 15, 16, 16, 16, 16, 16, 16, 13,
- 10, 12, 13, 14, 13, 13, 16, 14, 14, 14, 14, 16, 15, 14, 16, 13,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15,
- 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 9, 12, 13, 14, 13, 13, 16, 13, 13, 15, 15, 16, 15, 15, 16, 12,
- 6, 11, 11, 12, 10, 12, 13, 12, 11, 13, 11, 12, 11, 12, 13, 10,
- 9, 12, 13, 13, 13, 13, 16, 14, 14, 15, 14, 14, 14, 14, 14, 12,
- 12, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 7, 11, 11, 12, 12, 12, 14, 13, 12, 14, 11, 13, 13, 13, 13, 11,
- 8, 12, 12, 13, 12, 13, 14, 13, 13, 14, 13, 13, 13, 14, 14, 11,
- 11, 14, 14, 15, 16, 15, 16, 16, 15, 16, 16, 16, 16, 16, 16, 13,
- 10, 14, 12, 14, 15, 15, 16, 16, 14, 16, 12, 15, 16, 16, 16, 13,
- 11, 14, 13, 15, 15, 15, 16, 16, 14, 16, 14, 14, 16, 16, 16, 13,
- 11, 14, 14, 14, 15, 16, 16, 16, 16, 16, 16, 15, 16, 16, 16, 13,
- 7, 11, 12, 11, 10, 12, 14, 13, 12, 14, 13, 13, 10, 12, 13, 10,
- 8, 12, 12, 13, 12, 12, 15, 13, 13, 14, 13, 13, 13, 13, 14, 11,
- 11, 13, 15, 16, 14, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 13,
- 9, 12, 13, 13, 13, 13, 15, 14, 13, 15, 13, 14, 13, 14, 14, 12,
- 7, 11, 11, 11, 11, 11, 13, 12, 11, 13, 11, 12, 11, 12, 12, 10,
- 9, 12, 13, 13, 13, 13, 16, 13, 14, 16, 15, 14, 14, 14, 16, 12,
- 12, 14, 14, 16, 16, 16, 16, 16, 16, 16, 15, 16, 16, 16, 16, 14,
- 10, 13, 13, 14, 14, 14, 16, 15, 14, 16, 14, 14, 16, 15, 15, 12,
- 9, 12, 13, 13, 13, 15, 16, 14, 13, 16, 14, 13, 13, 14, 14, 11,
- 10, 14, 15, 14, 12, 14, 16, 15, 13, 16, 16, 16, 12, 14, 16, 12,
- 11, 14, 14, 14, 14, 14, 16, 15, 15, 16, 16, 16, 14, 15, 16, 13,
- 11, 14, 14, 16, 14, 13, 16, 15, 14, 16, 15, 16, 15, 15, 16, 13,
- 12, 16, 16, 16, 14, 16, 16, 16, 16, 16, 16, 16, 15, 16, 16, 14,
- 10, 13, 14, 14, 13, 14, 16, 14, 13, 16, 15, 15, 13, 14, 14, 12,
- 9, 12, 13, 14, 13, 12, 16, 14, 13, 16, 14, 14, 14, 14, 15, 12,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 13,
- 9, 12, 13, 13, 13, 13, 14, 13, 12, 15, 14, 14, 14, 14, 14, 11,
- 11, 14, 14, 16, 14, 16, 16, 16, 13, 16, 14, 16, 14, 16, 16, 13,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 11, 14, 14, 16, 16, 15, 16, 16, 15, 16, 14, 16, 16, 16, 16, 14,
- 12, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 10, 14, 12, 15, 15, 15, 16, 16, 14, 16, 12, 14, 16, 16, 15, 14,
- 12, 15, 14, 16, 16, 16, 16, 16, 15, 16, 14, 16, 16, 16, 16, 14,
- 12, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 15, 16, 16, 16, 14,
- 11, 15, 15, 16, 14, 16, 16, 16, 14, 16, 16, 16, 13, 16, 16, 13,
- 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 11, 15, 14, 16, 14, 14, 16, 15, 14, 16, 15, 16, 15, 16, 16, 12,
- 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 13,
- 12, 16, 15, 16, 16, 16, 16, 16, 16, 16, 15, 16, 16, 16, 16, 14,
- 10, 14, 13, 14, 15, 14, 16, 15, 14, 16, 13, 16, 16, 16, 15, 13,
- 10, 14, 14, 14, 13, 14, 16, 15, 15, 16, 14, 14, 14, 16, 16, 12,
- 10, 14, 15, 14, 13, 16, 16, 15, 13, 16, 16, 16, 12, 14, 16, 12,
- 11, 16, 16, 16, 14, 15, 16, 16, 16, 16, 16, 16, 14, 16, 16, 13,
- 12, 15, 14, 16, 15, 16, 16, 16, 16, 16, 16, 16, 16, 14, 16, 14,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 16, 16, 14,
- 11, 14, 14, 14, 14, 15, 16, 14, 14, 16, 16, 16, 13, 15, 15, 12,
- 10, 14, 13, 14, 14, 14, 16, 15, 14, 16, 15, 15, 14, 14, 16, 12,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 12, 14, 14, 16, 16, 16, 16, 16, 16, 16, 15, 16, 16, 16, 16, 13,
- 8, 11, 11, 12, 12, 12, 13, 12, 11, 13, 12, 12, 12, 13, 12, 10,
- },
- },
- {
- {
- 5, 6, 6, 6, 6, 6, 7, 6, 6, 7, 6, 6, 6, 6, 6, 4,
- 9, 9, 9, 8, 9, 8, 10, 8, 10, 10, 9, 9, 9, 8, 9, 6,
- 11, 10, 12, 10, 11, 10, 12, 9, 12, 11, 11, 10, 11, 10, 11, 8,
- 9, 10, 9, 8, 10, 10, 10, 9, 9, 10, 8, 8, 9, 9, 8, 7,
- 10, 11, 10, 9, 11, 11, 11, 9, 11, 11, 10, 9, 10, 10, 10, 7,
- 13, 12, 12, 10, 13, 12, 13, 10, 13, 12, 12, 11, 13, 12, 11, 9,
- 11, 12, 10, 10, 12, 12, 11, 10, 11, 12, 10, 10, 11, 11, 10, 8,
- 12, 12, 11, 10, 13, 13, 13, 10, 13, 13, 12, 11, 13, 12, 11, 9,
- 12, 12, 12, 10, 13, 13, 13, 10, 13, 13, 12, 10, 13, 12, 12, 9,
- 9, 9, 10, 10, 9, 8, 10, 9, 9, 10, 9, 9, 8, 8, 9, 6,
- 10, 11, 11, 11, 10, 9, 11, 9, 11, 11, 11, 10, 10, 9, 10, 7,
- 12, 12, 13, 12, 12, 10, 13, 10, 13, 13, 13, 12, 12, 11, 11, 9,
- 11, 12, 11, 11, 11, 11, 11, 10, 11, 12, 10, 10, 10, 10, 10, 8,
- 12, 12, 12, 11, 12, 11, 11, 10, 12, 12, 11, 11, 11, 11, 10, 8,
- 14, 13, 13, 12, 13, 12, 13, 10, 14, 14, 13, 12, 13, 12, 12, 9,
- 13, 14, 13, 12, 13, 13, 13, 12, 13, 13, 12, 12, 12, 12, 11, 9,
- 14, 14, 13, 12, 13, 13, 13, 11, 14, 14, 13, 12, 13, 12, 12, 9,
- 14, 15, 14, 12, 15, 13, 13, 11, 15, 14, 14, 12, 14, 13, 12, 9,
- 11, 11, 12, 12, 10, 10, 12, 11, 11, 12, 11, 11, 10, 10, 10, 8,
- 12, 12, 14, 13, 11, 10, 12, 11, 13, 13, 13, 12, 12, 10, 11, 9,
- 13, 13, 14, 14, 12, 10, 13, 11, 14, 14, 14, 13, 12, 11, 12, 9,
- 13, 13, 13, 13, 12, 13, 13, 12, 13, 14, 12, 12, 12, 12, 11, 9,
- 13, 14, 14, 13, 13, 12, 13, 11, 14, 14, 13, 12, 13, 12, 12, 9,
- 14, 14, 14, 14, 14, 12, 13, 11, 15, 15, 15, 13, 14, 12, 12, 9,
- 14, 15, 15, 13, 14, 14, 13, 12, 13, 14, 13, 13, 12, 12, 11, 10,
- 16, 16, 15, 14, 15, 14, 13, 11, 15, 15, 14, 13, 13, 13, 12, 9,
- 15, 15, 15, 13, 14, 13, 13, 11, 15, 15, 15, 13, 14, 13, 12, 9,
- 8, 9, 9, 9, 9, 9, 10, 9, 8, 10, 9, 9, 8, 8, 9, 7,
- 11, 11, 11, 11, 11, 11, 12, 10, 11, 11, 11, 10, 10, 10, 10, 8,
- 13, 13, 14, 12, 13, 12, 14, 11, 13, 13, 13, 12, 13, 11, 12, 9,
- 10, 11, 10, 11, 11, 11, 12, 10, 10, 11, 10, 10, 10, 10, 10, 8,
- 12, 12, 12, 11, 12, 12, 12, 11, 11, 12, 11, 10, 11, 11, 10, 8,
- 14, 13, 14, 12, 14, 13, 14, 12, 14, 13, 13, 11, 13, 12, 12, 9,
- 12, 13, 12, 12, 13, 13, 13, 12, 12, 13, 11, 11, 12, 12, 11, 9,
- 13, 14, 13, 12, 14, 14, 14, 12, 14, 13, 12, 11, 13, 12, 12, 9,
- 14, 14, 13, 12, 15, 14, 15, 12, 14, 14, 13, 11, 13, 13, 12, 9,
- 10, 11, 11, 11, 10, 10, 12, 10, 10, 11, 10, 10, 9, 9, 10, 7,
- 12, 12, 13, 12, 12, 11, 12, 11, 12, 12, 12, 11, 11, 10, 10, 8,
- 14, 13, 14, 13, 14, 12, 13, 12, 14, 13, 14, 12, 13, 11, 12, 9,
- 12, 13, 12, 12, 12, 12, 12, 11, 11, 12, 11, 10, 10, 10, 10, 8,
- 12, 12, 12, 12, 12, 12, 12, 11, 12, 12, 11, 10, 11, 10, 10, 7,
- 14, 14, 14, 12, 14, 12, 14, 11, 14, 13, 13, 11, 13, 11, 11, 8,
- 13, 15, 13, 13, 14, 14, 14, 12, 13, 14, 12, 12, 12, 12, 11, 9,
- 14, 15, 13, 12, 14, 13, 13, 11, 13, 13, 12, 11, 13, 12, 11, 8,
- 15, 15, 15, 12, 15, 14, 14, 11, 14, 14, 13, 11, 13, 12, 12, 8,
- 12, 13, 13, 13, 12, 12, 13, 12, 12, 13, 12, 12, 11, 11, 11, 9,
- 13, 14, 15, 14, 13, 12, 14, 12, 13, 13, 14, 12, 12, 11, 12, 9,
- 14, 14, 15, 14, 14, 12, 14, 12, 14, 14, 14, 13, 13, 11, 12, 9,
- 13, 14, 14, 14, 13, 13, 14, 13, 13, 13, 12, 12, 12, 12, 11, 9,
- 14, 14, 14, 13, 13, 13, 13, 12, 13, 14, 13, 12, 12, 11, 11, 8,
- 15, 14, 15, 14, 14, 13, 14, 11, 15, 14, 14, 12, 13, 11, 12, 8,
- 14, 15, 14, 14, 15, 14, 14, 13, 14, 15, 13, 13, 12, 12, 11, 10,
- 16, 15, 14, 14, 14, 14, 13, 12, 14, 14, 13, 12, 13, 12, 11, 9,
- 15, 15, 15, 14, 16, 14, 14, 11, 15, 15, 14, 12, 13, 12, 11, 8,
- 11, 12, 11, 12, 12, 12, 12, 11, 10, 11, 10, 10, 10, 10, 10, 8,
- 13, 13, 13, 13, 13, 13, 14, 12, 12, 12, 12, 12, 12, 11, 12, 9,
- 14, 14, 14, 13, 15, 13, 15, 13, 14, 14, 14, 12, 14, 12, 13, 10,
- 12, 13, 12, 13, 13, 13, 13, 12, 11, 12, 11, 11, 12, 11, 11, 9,
- 14, 14, 13, 13, 14, 14, 14, 12, 12, 13, 12, 11, 13, 12, 12, 9,
- 14, 14, 15, 13, 15, 15, 15, 13, 15, 13, 13, 12, 14, 12, 13, 10,
- 13, 15, 12, 13, 14, 14, 14, 13, 12, 13, 11, 11, 13, 12, 11, 10,
- 14, 15, 14, 13, 15, 14, 15, 13, 14, 14, 12, 11, 13, 13, 12, 9,
- 14, 15, 14, 13, 15, 14, 15, 13, 14, 14, 13, 11, 14, 13, 12, 9,
- 12, 13, 13, 13, 12, 13, 13, 12, 11, 12, 12, 11, 11, 11, 11, 9,
- 13, 14, 14, 13, 14, 13, 14, 12, 13, 13, 13, 12, 12, 11, 11, 9,
- 15, 15, 16, 14, 15, 14, 14, 13, 15, 14, 14, 13, 13, 12, 13, 10,
- 13, 14, 14, 13, 13, 14, 14, 13, 12, 13, 12, 12, 11, 11, 11, 9,
- 14, 14, 14, 13, 14, 13, 14, 12, 13, 13, 12, 11, 12, 11, 11, 8,
- 15, 15, 15, 13, 15, 14, 14, 12, 14, 13, 13, 12, 13, 12, 12, 9,
- 14, 15, 14, 14, 15, 15, 14, 13, 13, 14, 12, 12, 13, 12, 12, 9,
- 15, 15, 14, 13, 15, 14, 14, 13, 14, 14, 12, 11, 13, 12, 11, 8,
- 15, 16, 14, 13, 15, 15, 15, 12, 14, 14, 13, 11, 14, 12, 12, 8,
- 12, 14, 13, 13, 13, 13, 14, 12, 12, 13, 12, 12, 10, 11, 11, 9,
- 14, 15, 15, 14, 13, 13, 15, 13, 13, 14, 14, 12, 12, 11, 12, 9,
- 15, 15, 16, 14, 14, 13, 15, 13, 14, 14, 14, 13, 13, 11, 12, 9,
- 14, 15, 14, 14, 14, 14, 14, 13, 13, 14, 13, 12, 12, 12, 11, 9,
- 14, 15, 15, 14, 14, 14, 14, 12, 13, 14, 13, 12, 12, 11, 11, 8,
- 15, 15, 15, 14, 14, 13, 15, 12, 15, 14, 14, 12, 13, 11, 11, 8,
- 14, 16, 14, 14, 14, 15, 14, 13, 13, 14, 12, 12, 12, 12, 11, 9,
- 15, 15, 15, 14, 15, 14, 14, 12, 14, 14, 13, 12, 12, 11, 11, 8,
- 15, 15, 14, 13, 15, 13, 14, 12, 14, 14, 13, 11, 13, 11, 11, 7,
- },
- {
- 1, 5, 6, 7, 6, 7, 9, 8, 6, 9, 8, 8, 7, 8, 8, 6,
- 5, 8, 10, 10, 10, 11, 13, 12, 11, 13, 12, 12, 12, 12, 13, 10,
- 8, 10, 13, 12, 13, 13, 16, 14, 14, 16, 16, 14, 16, 16, 16, 12,
- 5, 10, 9, 11, 11, 12, 13, 12, 11, 13, 11, 12, 12, 12, 13, 10,
- 6, 10, 11, 11, 11, 12, 14, 12, 11, 13, 13, 13, 12, 13, 13, 11,
- 8, 12, 13, 12, 14, 14, 16, 14, 14, 16, 16, 16, 16, 16, 16, 13,
- 9, 13, 11, 14, 14, 16, 16, 16, 14, 16, 14, 16, 16, 16, 16, 13,
- 9, 13, 13, 13, 14, 16, 16, 16, 16, 14, 16, 16, 16, 16, 16, 14,
- 8, 12, 13, 12, 13, 14, 16, 14, 14, 16, 16, 16, 14, 16, 16, 13,
- 5, 10, 11, 12, 9, 11, 13, 12, 11, 13, 13, 13, 11, 12, 13, 10,
- 6, 10, 11, 12, 11, 11, 14, 13, 12, 14, 12, 13, 13, 13, 13, 11,
- 9, 12, 14, 15, 13, 13, 16, 16, 14, 16, 16, 16, 16, 16, 16, 13,
- 8, 13, 13, 14, 13, 14, 16, 16, 14, 16, 14, 16, 14, 16, 14, 13,
- 7, 11, 12, 13, 12, 12, 14, 13, 12, 14, 13, 14, 13, 14, 14, 12,
- 9, 13, 14, 14, 14, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 13,
- 11, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 15, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 9, 13, 14, 14, 14, 16, 16, 16, 14, 16, 16, 16, 16, 16, 16, 14,
- 9, 13, 14, 15, 11, 13, 16, 14, 14, 16, 16, 16, 13, 14, 16, 13,
- 9, 13, 14, 16, 13, 13, 16, 16, 14, 16, 16, 16, 16, 15, 16, 14,
- 8, 12, 13, 16, 13, 12, 16, 14, 13, 16, 14, 16, 16, 16, 16, 13,
- 11, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 14, 16, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 9, 13, 16, 16, 14, 14, 16, 16, 14, 16, 16, 16, 16, 16, 16, 14,
- 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 9, 13, 14, 15, 14, 14, 16, 14, 13, 16, 16, 16, 14, 16, 16, 14,
- 6, 11, 11, 12, 11, 12, 14, 13, 11, 14, 12, 13, 12, 13, 13, 11,
- 9, 13, 13, 14, 13, 14, 16, 16, 14, 16, 16, 16, 15, 16, 16, 13,
- 11, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 7, 11, 11, 13, 12, 13, 16, 14, 12, 16, 12, 14, 14, 14, 14, 12,
- 8, 12, 12, 13, 12, 14, 16, 14, 13, 16, 14, 14, 14, 14, 14, 12,
- 11, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 10, 14, 13, 16, 16, 16, 16, 16, 14, 16, 14, 16, 16, 16, 16, 16,
- 10, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 10, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 7, 11, 12, 12, 11, 13, 16, 14, 12, 15, 14, 14, 11, 13, 13, 12,
- 8, 12, 12, 13, 13, 13, 16, 14, 13, 16, 13, 15, 13, 14, 14, 12,
- 11, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 8, 12, 13, 14, 13, 14, 16, 16, 14, 16, 14, 16, 14, 16, 15, 13,
- 6, 11, 11, 12, 11, 12, 13, 13, 11, 13, 12, 13, 12, 13, 13, 11,
- 9, 13, 14, 14, 14, 14, 16, 14, 14, 16, 16, 16, 16, 16, 14, 13,
- 11, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 14, 13, 14, 14, 16, 16, 16, 14, 16, 14, 16, 16, 16, 16, 13,
- 9, 13, 14, 13, 13, 16, 16, 14, 13, 16, 16, 16, 13, 16, 14, 13,
- 10, 14, 14, 16, 13, 16, 16, 16, 16, 16, 16, 16, 13, 14, 16, 14,
- 11, 16, 16, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 10, 14, 16, 16, 14, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 14, 14, 14, 14, 16, 16, 16, 14, 16, 16, 16, 14, 16, 16, 13,
- 9, 13, 13, 16, 14, 14, 16, 16, 14, 16, 14, 16, 16, 16, 16, 13,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 9, 13, 14, 14, 13, 16, 16, 14, 13, 16, 14, 16, 14, 14, 16, 12,
- 10, 14, 14, 16, 16, 16, 16, 16, 13, 16, 16, 16, 14, 16, 16, 14,
- 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 11, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 14, 13, 16, 16, 16, 16, 16, 14, 16, 12, 16, 16, 16, 16, 14,
- 11, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 16, 16, 16, 16, 16,
- 11, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 11, 16, 16, 16, 16, 16, 16, 16, 14, 16, 16, 16, 14, 16, 16, 14,
- 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15,
- 11, 16, 16, 16, 16, 16, 16, 16, 14, 16, 16, 16, 16, 16, 16, 13,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 15, 14, 16, 16, 16, 16, 16, 16, 16, 14, 16, 16, 16, 16, 14,
- 10, 14, 14, 14, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 13,
- 10, 14, 16, 16, 13, 16, 16, 16, 14, 16, 16, 16, 12, 16, 16, 14,
- 11, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 16, 16, 16,
- 11, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 15, 14, 16, 14, 16, 16, 16, 16, 16, 16, 16, 14, 16, 16, 13,
- 10, 15, 14, 16, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 13,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 11, 14, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 8, 12, 12, 13, 12, 14, 14, 14, 12, 16, 13, 14, 12, 14, 14, 11,
- },
- },
-};
-
-
-static const uint8_t rv34_table_intra_cbp[NUM_INTRA_TABLES][8][CBP_VLC_SIZE] = {
- {
- { 0, 3, 3, 4, 3, 5, 5, 5, 2, 5, 4, 6, 4, 6, 6, 6, },
- { 0, 2, 3, 4, 2, 5, 6, 7, 3, 6, 5, 7, 4, 7, 8, 8, },
- { 0, 3, 4, 4, 3, 4, 5, 5, 3, 5, 4, 5, 4, 5, 5, 3, },
- { 0, 3, 3, 4, 3, 4, 5, 5, 3, 5, 4, 6, 3, 5, 6, 5, },
- { 0, 4, 4, 4, 4, 5, 5, 4, 4, 5, 4, 5, 4, 4, 4, 2, },
- { 0, 3, 3, 4, 3, 4, 5, 5, 3, 5, 4, 5, 4, 5, 5, 4, },
- { 0, 6, 6, 5, 6, 5, 6, 4, 6, 6, 5, 4, 4, 4, 4, 1, },
- { 0, 4, 4, 4, 4, 5, 5, 4, 4, 5, 5, 4, 4, 4, 4, 2, },
- },
- {
- { 0, 4, 3, 4, 3, 4, 5, 4, 3, 5, 4, 5, 3, 5, 5, 5, },
- { 0, 2, 3, 4, 2, 5, 6, 7, 3, 6, 5, 7, 4, 7, 8, 8, },
- { 0, 4, 4, 4, 4, 4, 5, 4, 4, 5, 4, 4, 3, 4, 4, 3, },
- { 0, 3, 3, 4, 3, 4, 5, 5, 3, 5, 4, 6, 3, 5, 6, 5, },
- { 0, 4, 4, 4, 4, 4, 5, 4, 4, 5, 5, 5, 4, 4, 4, 2, },
- { 0, 3, 3, 4, 3, 4, 5, 5, 3, 5, 4, 5, 4, 5, 5, 4, },
- { 0, 5, 6, 5, 5, 5, 6, 4, 6, 6, 5, 4, 5, 4, 4, 1, },
- { 0, 4, 4, 4, 4, 4, 5, 4, 4, 5, 5, 4, 4, 4, 5, 2, },
- },
- {
- { 0, 3, 3, 4, 3, 4, 4, 5, 3, 5, 4, 5, 4, 5, 5, 5, },
- { 0, 2, 3, 4, 2, 4, 6, 7, 3, 6, 5, 7, 5, 7, 8, 8, },
- { 0, 4, 4, 4, 4, 4, 5, 4, 3, 5, 4, 4, 4, 4, 4, 3, },
- { 0, 3, 3, 4, 3, 3, 6, 6, 3, 6, 4, 6, 3, 6, 6, 5, },
- { 0, 4, 4, 4, 3, 4, 5, 4, 4, 5, 4, 4, 4, 4, 4, 3, },
- { 0, 3, 3, 4, 3, 4, 5, 5, 3, 5, 4, 5, 4, 5, 5, 4, },
- { 0, 5, 5, 5, 5, 5, 6, 4, 5, 6, 5, 5, 5, 4, 4, 1, },
- { 0, 4, 4, 4, 4, 4, 6, 4, 4, 6, 5, 4, 4, 4, 4, 2, },
- },
- {
- { 0, 3, 3, 4, 3, 4, 4, 5, 3, 5, 4, 5, 4, 5, 5, 5, },
- { 0, 2, 3, 4, 2, 4, 7, 6, 3, 7, 5, 7, 5, 7, 7, 7, },
- { 0, 3, 3, 4, 3, 4, 5, 5, 3, 5, 4, 5, 4, 5, 5, 4, },
- { 0, 3, 3, 3, 3, 4, 6, 6, 3, 6, 4, 6, 3, 6, 6, 5, },
- { 0, 3, 4, 4, 3, 4, 5, 4, 4, 5, 4, 5, 4, 5, 4, 3, },
- { 0, 3, 3, 4, 3, 4, 5, 5, 3, 5, 4, 5, 4, 5, 5, 4, },
- { 0, 4, 5, 4, 4, 4, 5, 4, 4, 5, 5, 4, 4, 4, 4, 2, },
- { 0, 4, 4, 4, 4, 5, 5, 4, 4, 5, 5, 4, 4, 4, 4, 2, },
- },
- {
- { 0, 3, 3, 4, 3, 4, 5, 6, 2, 5, 4, 7, 4, 6, 6, 7, },
- { 0, 2, 3, 4, 2, 4, 6, 7, 3, 7, 5, 7, 5, 7, 7, 7, },
- { 0, 3, 3, 4, 3, 4, 5, 5, 3, 5, 4, 5, 4, 5, 5, 4, },
- { 0, 2, 3, 4, 3, 4, 6, 5, 3, 6, 4, 6, 4, 6, 6, 6, },
- { 0, 3, 3, 4, 3, 4, 5, 5, 3, 5, 4, 5, 4, 5, 5, 4, },
- { 0, 3, 3, 4, 3, 4, 5, 5, 3, 5, 4, 5, 4, 5, 5, 4, },
- { 0, 4, 4, 4, 4, 5, 5, 4, 4, 5, 5, 4, 4, 4, 4, 2, },
- { 0, 3, 4, 4, 4, 4, 5, 4, 4, 5, 4, 4, 4, 4, 4, 3, },
- },
-};
-
-
-static const uint8_t rv34_table_intra_firstpat[NUM_INTRA_TABLES][4][FIRSTBLK_VLC_SIZE] = {
- {
- {
- 0, 10, 5, 10, 7, 12, 9, 11, 8, 13, 9, 12, 10, 13, 11, 12,
- 16, 16, 14, 15, 15, 16, 13, 14, 5, 12, 6, 11, 9, 13, 10, 11,
- 9, 14, 9, 12, 11, 14, 11, 12, 16, 16, 14, 15, 15, 16, 13, 13,
- 10, 15, 9, 12, 12, 16, 11, 12, 12, 16, 10, 13, 13, 16, 11, 12,
- 16, 16, 13, 14, 15, 16, 13, 12, 6, 12, 8, 11, 8, 12, 10, 11,
- 9, 14, 10, 12, 10, 13, 11, 12, 15, 16, 14, 15, 14, 16, 13, 13,
- 8, 13, 9, 12, 10, 13, 10, 12, 10, 14, 9, 12, 11, 14, 10, 12,
- 15, 16, 13, 15, 14, 16, 13, 13, 11, 16, 10, 13, 13, 16, 11, 12,
- 12, 16, 11, 13, 13, 16, 11, 12, 16, 16, 13, 14, 15, 16, 12, 12,
- 10, 16, 12, 14, 10, 14, 11, 12, 12, 16, 13, 14, 11, 14, 12, 12,
- 16, 16, 15, 16, 14, 15, 13, 13, 11, 16, 12, 14, 11, 14, 11, 12,
- 12, 16, 12, 14, 11, 14, 11, 12, 16, 16, 14, 15, 13, 15, 13, 12,
- 14, 16, 13, 14, 13, 16, 12, 12, 14, 16, 13, 14, 13, 16, 12, 12,
- 16, 16, 14, 14, 14, 15, 12, 11, 2, 10, 6, 10, 7, 12, 9, 11,
- 8, 12, 9, 11, 10, 13, 10, 11, 15, 16, 14, 15, 14, 16, 13, 13,
- 5, 12, 6, 11, 9, 13, 10, 11, 9, 13, 9, 11, 10, 13, 10, 11,
- 15, 16, 13, 14, 14, 16, 13, 13, 9, 15, 8, 12, 12, 15, 11, 11,
- 11, 16, 10, 12, 13, 15, 11, 11, 15, 16, 13, 14, 15, 16, 12, 12,
- 6, 12, 8, 11, 8, 12, 9, 11, 9, 14, 9, 12, 10, 13, 10, 11,
- 15, 16, 14, 15, 14, 16, 13, 13, 7, 13, 8, 11, 9, 13, 10, 11,
- 9, 14, 9, 12, 10, 13, 10, 11, 14, 16, 13, 14, 13, 16, 12, 12,
- 11, 16, 10, 12, 12, 15, 11, 11, 11, 16, 10, 12, 12, 15, 11, 11,
- 15, 16, 12, 13, 14, 16, 12, 11, 9, 15, 11, 13, 9, 13, 11, 12,
- 11, 16, 12, 14, 10, 14, 11, 12, 16, 16, 14, 15, 13, 15, 12, 12,
- 11, 16, 11, 14, 10, 14, 11, 12, 11, 16, 12, 13, 11, 14, 11, 11,
- 15, 16, 14, 15, 13, 14, 12, 12, 13, 16, 12, 14, 13, 15, 11, 11,
- 13, 16, 12, 14, 13, 15, 11, 11, 16, 16, 13, 14, 13, 15, 11, 10,
- 5, 12, 7, 11, 8, 13, 10, 11, 9, 13, 9, 12, 10, 14, 11, 12,
- 16, 16, 14, 15, 14, 16, 13, 13, 7, 13, 7, 11, 9, 13, 10, 11,
- 9, 14, 9, 12, 11, 14, 11, 12, 16, 16, 14, 14, 14, 16, 13, 13,
- 9, 15, 8, 12, 12, 15, 11, 12, 11, 16, 10, 12, 13, 16, 11, 12,
- 16, 16, 13, 14, 15, 16, 12, 12, 7, 13, 8, 12, 9, 13, 10, 11,
- 10, 14, 10, 12, 10, 14, 11, 12, 16, 16, 14, 15, 14, 16, 13, 13,
- 8, 14, 9, 12, 10, 13, 10, 11, 9, 14, 9, 12, 10, 14, 10, 11,
- 15, 16, 13, 14, 14, 16, 12, 12, 11, 16, 10, 12, 12, 15, 11, 12,
- 11, 16, 10, 12, 12, 15, 11, 11, 15, 16, 12, 14, 14, 16, 12, 11,
- 10, 16, 11, 13, 9, 14, 11, 12, 12, 16, 12, 14, 11, 14, 11, 12,
- 16, 16, 14, 16, 14, 15, 13, 12, 11, 16, 11, 14, 10, 14, 11, 12,
- 11, 16, 12, 14, 11, 14, 11, 11, 15, 16, 14, 15, 13, 15, 12, 12,
- 13, 16, 12, 14, 13, 15, 11, 11, 13, 16, 12, 14, 12, 14, 11, 11,
- 15, 16, 12, 13, 13, 14, 11, 10, 6, 13, 8, 11, 9, 13, 10, 11,
- 10, 14, 10, 12, 10, 13, 10, 11, 15, 16, 13, 13, 13, 14, 12, 11,
- 7, 13, 8, 11, 9, 13, 9, 11, 10, 14, 9, 11, 10, 13, 10, 11,
- 15, 16, 13, 13, 13, 14, 11, 11, 9, 14, 8, 11, 10, 13, 9, 10,
- 11, 15, 9, 11, 11, 13, 9, 10, 15, 16, 12, 13, 13, 14, 10, 9,
- 7, 13, 8, 11, 9, 13, 9, 11, 10, 14, 10, 12, 10, 13, 10, 11,
- 15, 16, 13, 13, 13, 14, 11, 11, 8, 13, 8, 11, 9, 13, 9, 10,
- 9, 14, 9, 11, 10, 13, 9, 10, 14, 16, 12, 13, 13, 14, 11, 10,
- 9, 14, 8, 11, 10, 13, 9, 9, 10, 14, 8, 11, 10, 13, 9, 9,
- 14, 16, 11, 12, 12, 14, 10, 9, 9, 14, 9, 12, 8, 12, 9, 10,
- 11, 15, 10, 12, 10, 13, 9, 10, 15, 16, 13, 13, 12, 13, 11, 10,
- 9, 14, 9, 12, 9, 12, 9, 10, 10, 14, 10, 12, 9, 12, 9, 9,
- 14, 16, 12, 13, 11, 13, 10, 9, 10, 14, 9, 11, 10, 12, 8, 8,
- 10, 14, 9, 11, 10, 12, 8, 8, 12, 14, 9, 10, 10, 11, 8, 7,
- },
- {
- 0, 9, 6, 9, 6, 10, 8, 9, 7, 11, 8, 11, 9, 11, 9, 10,
- 14, 16, 13, 14, 13, 14, 12, 11, 5, 11, 7, 10, 8, 10, 8, 9,
- 8, 12, 8, 11, 9, 12, 9, 10, 14, 16, 12, 13, 13, 14, 11, 11,
- 10, 14, 9, 11, 11, 13, 10, 10, 11, 15, 9, 11, 12, 13, 10, 10,
- 15, 16, 12, 12, 13, 14, 11, 9, 6, 11, 7, 10, 7, 10, 8, 9,
- 8, 12, 9, 11, 9, 11, 9, 10, 14, 16, 13, 13, 13, 14, 11, 11,
- 7, 12, 8, 11, 8, 11, 9, 9, 9, 13, 9, 11, 9, 12, 9, 10,
- 14, 16, 12, 13, 12, 14, 11, 10, 11, 14, 10, 12, 11, 13, 10, 10,
- 12, 15, 10, 12, 12, 13, 10, 10, 15, 16, 12, 12, 13, 14, 10, 9,
- 10, 14, 11, 13, 9, 12, 10, 10, 11, 15, 12, 13, 10, 12, 10, 10,
- 14, 16, 13, 14, 12, 13, 11, 10, 11, 14, 11, 13, 10, 12, 10, 10,
- 12, 15, 11, 13, 10, 12, 10, 10, 15, 16, 13, 13, 12, 13, 11, 9,
- 13, 16, 12, 13, 12, 13, 10, 9, 14, 16, 12, 13, 12, 13, 10, 9,
- 16, 16, 12, 12, 13, 13, 10, 7, 4, 10, 6, 9, 7, 10, 8, 9,
- 8, 12, 9, 11, 9, 11, 9, 9, 14, 16, 13, 13, 13, 14, 11, 11,
- 6, 11, 7, 10, 8, 11, 8, 9, 9, 12, 9, 11, 9, 12, 9, 9,
- 14, 16, 12, 13, 13, 14, 11, 10, 10, 14, 9, 11, 11, 13, 9, 9,
- 11, 14, 9, 11, 11, 13, 10, 9, 14, 16, 11, 12, 13, 14, 10, 9,
- 6, 11, 8, 10, 7, 10, 8, 9, 9, 12, 9, 11, 9, 11, 9, 9,
- 14, 16, 13, 13, 12, 13, 11, 10, 8, 12, 8, 10, 8, 11, 9, 9,
- 9, 12, 9, 11, 9, 11, 9, 9, 14, 16, 12, 13, 12, 13, 11, 10,
- 11, 14, 10, 11, 11, 13, 9, 9, 11, 14, 10, 11, 11, 13, 9, 9,
- 14, 16, 11, 12, 13, 14, 10, 8, 10, 14, 11, 12, 9, 12, 10, 10,
- 11, 14, 11, 13, 10, 12, 10, 10, 14, 16, 13, 14, 12, 13, 11, 9,
- 11, 14, 11, 12, 10, 12, 10, 10, 11, 14, 11, 12, 10, 12, 10, 9,
- 14, 16, 13, 13, 11, 12, 10, 9, 13, 16, 12, 13, 12, 13, 10, 9,
- 13, 16, 11, 12, 11, 13, 10, 8, 15, 16, 12, 12, 12, 12, 9, 7,
- 8, 12, 8, 11, 9, 12, 9, 10, 10, 14, 10, 12, 11, 13, 10, 10,
- 16, 16, 14, 14, 14, 14, 12, 11, 8, 13, 8, 11, 9, 12, 10, 10,
- 11, 14, 10, 12, 11, 13, 10, 10, 16, 16, 13, 14, 14, 14, 12, 11,
- 11, 14, 9, 12, 11, 13, 10, 10, 12, 15, 10, 12, 12, 14, 10, 10,
- 15, 16, 12, 12, 14, 14, 11, 9, 9, 13, 9, 11, 9, 12, 10, 10,
- 11, 14, 10, 12, 10, 12, 10, 10, 15, 16, 14, 14, 13, 14, 12, 11,
- 9, 13, 9, 11, 10, 12, 10, 10, 10, 14, 10, 12, 10, 12, 10, 10,
- 15, 16, 13, 13, 13, 14, 11, 10, 11, 15, 10, 12, 11, 13, 10, 10,
- 11, 15, 10, 12, 12, 13, 10, 9, 15, 16, 11, 12, 13, 14, 10, 9,
- 11, 15, 11, 13, 10, 12, 10, 10, 12, 16, 12, 13, 11, 13, 10, 10,
- 16, 16, 14, 14, 12, 13, 11, 9, 11, 15, 11, 13, 10, 13, 10, 10,
- 12, 15, 12, 13, 10, 12, 10, 10, 14, 16, 13, 13, 12, 13, 10, 9,
- 13, 16, 12, 13, 12, 13, 10, 9, 13, 16, 11, 12, 11, 13, 10, 9,
- 14, 16, 11, 12, 12, 12, 9, 7, 10, 15, 10, 12, 11, 13, 10, 10,
- 12, 16, 12, 13, 12, 13, 11, 10, 16, 16, 14, 14, 14, 15, 12, 10,
- 10, 14, 10, 12, 10, 13, 10, 10, 12, 15, 11, 12, 11, 13, 10, 10,
- 16, 16, 14, 13, 14, 14, 11, 9, 11, 14, 10, 11, 11, 12, 9, 9,
- 12, 15, 10, 11, 11, 13, 9, 8, 16, 16, 12, 12, 13, 13, 10, 7,
- 10, 15, 10, 12, 10, 13, 10, 10, 12, 15, 11, 12, 11, 13, 10, 10,
- 16, 16, 14, 13, 14, 14, 11, 9, 10, 14, 10, 12, 10, 12, 10, 10,
- 12, 15, 11, 12, 11, 13, 10, 10, 16, 16, 13, 13, 13, 14, 11, 9,
- 11, 14, 10, 11, 10, 12, 9, 8, 11, 14, 9, 11, 11, 12, 9, 8,
- 14, 16, 10, 11, 12, 13, 9, 7, 11, 15, 11, 12, 10, 12, 10, 9,
- 13, 16, 11, 12, 11, 12, 10, 9, 16, 16, 13, 13, 12, 13, 10, 7,
- 11, 15, 10, 12, 10, 12, 9, 8, 12, 15, 11, 12, 10, 12, 9, 8,
- 14, 16, 12, 12, 11, 12, 9, 7, 11, 14, 10, 11, 10, 12, 8, 7,
- 11, 14, 9, 10, 10, 11, 8, 6, 12, 15, 9, 9, 9, 10, 7, 4,
- },
- {
- 0, 6, 3, 7, 3, 7, 6, 7, 5, 9, 6, 9, 7, 9, 8, 8,
- 16, 16, 16, 16, 16, 16, 16, 11, 3, 8, 5, 8, 6, 8, 7, 7,
- 7, 11, 7, 10, 8, 10, 8, 9, 16, 16, 16, 16, 16, 16, 14, 10,
- 8, 16, 7, 11, 10, 16, 9, 9, 11, 16, 9, 14, 16, 16, 10, 9,
- 16, 16, 16, 16, 16, 16, 16, 10, 3, 8, 5, 8, 5, 8, 7, 7,
- 7, 11, 8, 10, 8, 10, 8, 9, 16, 16, 16, 16, 16, 16, 16, 11,
- 6, 10, 7, 9, 7, 10, 8, 8, 8, 11, 8, 10, 8, 11, 8, 8,
- 16, 16, 16, 16, 16, 16, 11, 10, 10, 16, 9, 13, 11, 16, 10, 9,
- 11, 16, 9, 11, 16, 16, 10, 9, 16, 16, 11, 16, 16, 16, 11, 9,
- 9, 16, 10, 11, 8, 11, 9, 9, 11, 16, 12, 16, 10, 16, 10, 10,
- 16, 16, 16, 16, 16, 16, 16, 10, 10, 16, 11, 16, 10, 16, 10, 10,
- 11, 16, 11, 16, 10, 16, 10, 9, 16, 16, 16, 16, 16, 16, 11, 9,
- 16, 16, 16, 16, 16, 16, 11, 9, 16, 16, 16, 16, 16, 16, 11, 9,
- 16, 16, 11, 16, 16, 16, 9, 7, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- },
- {
- 2, 8, 5, 9, 6, 9, 8, 8, 8, 12, 9, 11, 9, 11, 10, 10,
- 16, 16, 14, 16, 14, 16, 14, 12, 5, 10, 6, 9, 8, 10, 8, 9,
- 9, 12, 9, 11, 10, 12, 10, 10, 16, 16, 14, 15, 15, 16, 13, 12,
- 10, 13, 9, 12, 11, 12, 10, 10, 12, 15, 11, 12, 12, 13, 11, 10,
- 16, 16, 15, 14, 15, 16, 13, 12, 6, 10, 8, 10, 7, 10, 8, 9,
- 9, 13, 10, 11, 10, 12, 10, 10, 16, 16, 14, 16, 14, 16, 13, 12,
- 7, 11, 8, 11, 9, 11, 9, 9, 10, 13, 10, 11, 10, 12, 10, 9,
- 16, 16, 14, 14, 14, 15, 12, 11, 11, 14, 11, 12, 11, 13, 10, 10,
- 12, 15, 11, 13, 12, 13, 11, 10, 16, 16, 14, 16, 15, 15, 13, 11,
- 10, 13, 11, 12, 10, 12, 10, 10, 12, 15, 12, 13, 11, 13, 11, 11,
- 16, 16, 15, 16, 14, 15, 13, 11, 11, 14, 11, 13, 11, 12, 11, 10,
- 12, 16, 12, 13, 12, 13, 11, 10, 16, 16, 15, 16, 13, 15, 12, 11,
- 13, 15, 12, 13, 13, 14, 11, 11, 14, 16, 13, 13, 13, 14, 11, 11,
- 16, 16, 15, 14, 15, 15, 12, 10, 3, 8, 6, 9, 7, 9, 8, 8,
- 8, 12, 9, 11, 9, 11, 9, 9, 16, 16, 15, 15, 15, 16, 13, 12,
- 6, 10, 7, 9, 8, 10, 8, 8, 9, 12, 9, 11, 10, 12, 10, 9,
- 16, 16, 14, 14, 14, 15, 13, 11, 10, 13, 9, 11, 11, 12, 10, 10,
- 12, 14, 11, 12, 12, 13, 11, 10, 16, 16, 14, 14, 15, 15, 13, 11,
- 6, 10, 8, 10, 7, 10, 8, 9, 10, 12, 10, 11, 10, 11, 10, 9,
- 16, 16, 14, 15, 14, 15, 13, 11, 8, 11, 8, 10, 9, 11, 9, 9,
- 9, 13, 9, 11, 10, 11, 9, 9, 16, 16, 13, 14, 14, 14, 12, 10,
- 11, 14, 10, 12, 11, 12, 10, 10, 12, 14, 11, 12, 12, 13, 10, 10,
- 16, 16, 13, 14, 15, 15, 12, 10, 10, 13, 11, 12, 10, 12, 10, 10,
- 12, 14, 12, 13, 11, 13, 11, 10, 16, 16, 15, 14, 14, 14, 12, 11,
- 11, 14, 11, 12, 10, 12, 10, 10, 12, 15, 12, 12, 11, 13, 10, 10,
- 16, 16, 14, 15, 13, 14, 12, 10, 13, 15, 12, 13, 12, 13, 11, 10,
- 13, 16, 12, 13, 12, 13, 11, 10, 16, 16, 13, 14, 13, 15, 11, 9,
- 6, 10, 8, 10, 8, 11, 9, 10, 11, 13, 11, 12, 11, 13, 11, 10,
- 16, 16, 16, 16, 16, 16, 13, 12, 8, 11, 9, 11, 9, 11, 10, 10,
- 11, 14, 11, 12, 11, 12, 11, 10, 16, 16, 15, 15, 16, 16, 13, 12,
- 11, 14, 10, 12, 12, 13, 11, 10, 13, 16, 12, 13, 13, 14, 11, 11,
- 16, 16, 15, 16, 16, 16, 13, 12, 8, 12, 9, 11, 9, 11, 10, 10,
- 11, 14, 11, 12, 11, 12, 11, 10, 16, 16, 16, 16, 16, 16, 13, 12,
- 9, 12, 10, 11, 10, 12, 10, 10, 11, 14, 11, 12, 11, 13, 10, 10,
- 16, 16, 15, 14, 15, 15, 13, 11, 12, 14, 11, 13, 12, 13, 11, 10,
- 12, 15, 11, 12, 13, 13, 11, 10, 16, 16, 14, 15, 16, 15, 13, 11,
- 11, 15, 12, 13, 11, 13, 11, 10, 13, 16, 13, 14, 12, 14, 11, 11,
- 16, 16, 16, 16, 15, 15, 13, 12, 12, 14, 12, 13, 11, 13, 11, 10,
- 13, 15, 12, 13, 11, 13, 11, 10, 16, 16, 15, 15, 13, 15, 13, 11,
- 13, 16, 13, 13, 13, 13, 12, 11, 13, 16, 13, 13, 13, 13, 11, 10,
- 16, 16, 13, 15, 14, 14, 12, 9, 9, 13, 10, 12, 11, 13, 11, 11,
- 13, 16, 13, 14, 13, 14, 12, 11, 16, 16, 16, 16, 16, 16, 14, 12,
- 10, 14, 11, 13, 11, 13, 11, 10, 13, 16, 13, 13, 13, 14, 12, 11,
- 16, 16, 16, 16, 16, 16, 14, 12, 11, 15, 11, 13, 12, 13, 11, 10,
- 14, 16, 12, 13, 13, 14, 12, 10, 16, 16, 15, 16, 16, 16, 13, 11,
- 10, 14, 11, 12, 11, 13, 11, 10, 13, 16, 12, 13, 12, 14, 12, 11,
- 16, 16, 16, 16, 16, 16, 14, 12, 11, 14, 11, 12, 11, 13, 11, 10,
- 13, 15, 12, 13, 12, 13, 11, 10, 16, 16, 15, 15, 16, 16, 13, 11,
- 12, 15, 12, 13, 12, 13, 11, 10, 13, 16, 12, 13, 13, 13, 11, 10,
- 16, 16, 14, 14, 16, 15, 13, 10, 12, 15, 12, 13, 12, 13, 11, 10,
- 14, 16, 13, 14, 13, 14, 12, 11, 16, 16, 16, 16, 15, 16, 13, 11,
- 12, 16, 12, 13, 12, 13, 11, 10, 13, 16, 13, 13, 12, 14, 11, 10,
- 16, 16, 15, 16, 14, 15, 13, 10, 12, 15, 12, 14, 12, 13, 11, 10,
- 13, 16, 12, 13, 12, 13, 11, 10, 16, 16, 13, 14, 13, 14, 11, 8,
- },
- },
- {
- {
- 0, 11, 5, 11, 7, 13, 10, 12, 7, 13, 9, 13, 10, 14, 12, 13,
- 16, 16, 15, 16, 16, 16, 15, 15, 4, 13, 6, 12, 10, 14, 11, 12,
- 8, 14, 9, 13, 11, 15, 12, 13, 16, 16, 15, 16, 15, 16, 15, 14,
- 9, 16, 9, 13, 13, 16, 12, 13, 12, 16, 10, 14, 14, 16, 13, 13,
- 16, 16, 14, 16, 16, 16, 14, 14, 5, 13, 8, 13, 8, 13, 11, 12,
- 9, 14, 10, 13, 10, 14, 12, 13, 16, 16, 15, 16, 15, 16, 14, 15,
- 7, 14, 9, 13, 10, 14, 11, 13, 9, 15, 10, 13, 11, 14, 12, 13,
- 16, 16, 14, 16, 15, 16, 14, 14, 11, 16, 11, 14, 13, 16, 12, 13,
- 12, 16, 11, 14, 14, 16, 12, 13, 16, 16, 14, 15, 16, 16, 14, 13,
- 10, 16, 12, 15, 10, 15, 12, 14, 12, 16, 13, 16, 11, 15, 13, 14,
- 16, 16, 16, 16, 14, 16, 14, 14, 11, 16, 12, 15, 11, 16, 12, 13,
- 12, 16, 13, 15, 12, 16, 12, 13, 16, 16, 16, 16, 14, 16, 14, 14,
- 14, 16, 13, 15, 14, 16, 13, 13, 14, 16, 14, 15, 14, 16, 13, 13,
- 16, 16, 15, 16, 15, 16, 13, 13, 2, 12, 6, 11, 7, 13, 10, 12,
- 7, 13, 9, 12, 10, 14, 11, 12, 16, 16, 15, 16, 15, 16, 14, 15,
- 5, 13, 6, 12, 9, 13, 10, 12, 8, 14, 9, 13, 11, 14, 11, 13,
- 16, 16, 14, 16, 15, 16, 14, 14, 9, 16, 8, 13, 12, 16, 11, 13,
- 11, 16, 10, 13, 13, 16, 12, 13, 16, 16, 13, 15, 16, 16, 13, 13,
- 5, 13, 8, 12, 7, 13, 10, 12, 8, 14, 10, 13, 10, 14, 11, 13,
- 16, 16, 14, 16, 15, 16, 14, 14, 7, 14, 8, 12, 9, 14, 11, 12,
- 8, 14, 9, 13, 10, 14, 11, 12, 15, 16, 14, 15, 14, 16, 13, 14,
- 11, 16, 10, 13, 13, 16, 12, 13, 11, 16, 10, 13, 13, 16, 12, 13,
- 16, 16, 13, 15, 15, 16, 13, 13, 9, 16, 12, 15, 9, 14, 11, 13,
- 11, 16, 13, 15, 11, 14, 12, 13, 16, 16, 15, 16, 14, 16, 14, 14,
- 11, 16, 12, 14, 11, 15, 12, 13, 11, 16, 12, 14, 11, 15, 12, 13,
- 16, 16, 15, 16, 14, 16, 13, 13, 13, 16, 13, 15, 13, 16, 12, 13,
- 14, 16, 13, 15, 13, 16, 12, 12, 16, 16, 14, 15, 14, 16, 12, 12,
- 4, 13, 7, 12, 8, 14, 11, 12, 9, 14, 10, 13, 11, 14, 12, 13,
- 16, 16, 15, 16, 16, 16, 15, 15, 6, 14, 7, 12, 10, 14, 11, 12,
- 9, 15, 10, 13, 11, 15, 12, 13, 16, 16, 15, 16, 16, 16, 14, 14,
- 9, 16, 8, 13, 12, 16, 11, 13, 12, 16, 10, 14, 13, 16, 12, 13,
- 16, 16, 14, 16, 16, 16, 14, 14, 6, 14, 8, 13, 8, 14, 11, 13,
- 9, 15, 10, 13, 11, 14, 12, 13, 16, 16, 15, 16, 16, 16, 14, 14,
- 7, 15, 9, 13, 10, 14, 11, 13, 9, 15, 10, 13, 11, 14, 11, 13,
- 16, 16, 14, 16, 15, 16, 14, 14, 10, 16, 10, 13, 12, 16, 12, 13,
- 11, 16, 10, 13, 13, 16, 12, 13, 16, 16, 13, 14, 15, 16, 13, 13,
- 9, 16, 12, 14, 9, 14, 11, 13, 12, 16, 12, 15, 11, 15, 12, 13,
- 16, 16, 16, 16, 15, 16, 14, 14, 10, 16, 12, 15, 11, 15, 12, 13,
- 11, 16, 12, 14, 11, 15, 12, 13, 16, 16, 14, 16, 13, 16, 13, 13,
- 13, 16, 13, 15, 13, 16, 12, 13, 13, 16, 12, 14, 13, 16, 12, 12,
- 15, 16, 13, 14, 13, 16, 12, 12, 6, 14, 8, 13, 9, 14, 10, 12,
- 10, 15, 10, 12, 11, 14, 11, 12, 16, 16, 14, 14, 14, 16, 13, 13,
- 7, 15, 8, 13, 9, 14, 10, 12, 10, 15, 10, 13, 11, 14, 11, 12,
- 16, 16, 14, 14, 14, 16, 13, 12, 9, 16, 8, 12, 11, 14, 10, 11,
- 11, 16, 10, 13, 11, 14, 10, 11, 16, 16, 13, 14, 14, 16, 12, 11,
- 7, 14, 9, 13, 9, 14, 10, 12, 10, 16, 10, 13, 11, 14, 11, 12,
- 16, 16, 14, 14, 14, 15, 13, 12, 7, 14, 9, 13, 9, 14, 10, 12,
- 9, 14, 10, 12, 10, 14, 11, 12, 15, 16, 13, 14, 14, 15, 12, 12,
- 9, 15, 9, 12, 11, 14, 10, 11, 10, 15, 9, 12, 11, 14, 10, 11,
- 14, 16, 11, 13, 13, 15, 11, 11, 9, 16, 10, 13, 9, 14, 10, 11,
- 11, 16, 11, 13, 10, 14, 10, 11, 16, 16, 14, 15, 13, 15, 12, 12,
- 9, 16, 10, 13, 9, 13, 10, 11, 10, 15, 10, 13, 10, 13, 10, 11,
- 14, 16, 13, 14, 12, 14, 11, 11, 11, 16, 10, 13, 11, 13, 9, 10,
- 11, 14, 10, 12, 10, 13, 9, 9, 13, 15, 10, 11, 11, 12, 9, 8,
- },
- {
- 0, 10, 5, 10, 6, 11, 8, 10, 7, 12, 8, 11, 9, 12, 9, 10,
- 14, 16, 13, 13, 13, 14, 12, 11, 5, 12, 6, 10, 8, 12, 9, 10,
- 8, 13, 8, 11, 9, 12, 9, 10, 14, 16, 12, 13, 13, 14, 11, 11,
- 9, 15, 8, 12, 11, 14, 10, 10, 11, 16, 9, 12, 12, 14, 10, 10,
- 14, 16, 11, 12, 13, 14, 11, 10, 5, 12, 8, 11, 7, 11, 9, 10,
- 8, 13, 9, 11, 9, 12, 9, 10, 14, 16, 12, 13, 13, 14, 11, 11,
- 7, 13, 8, 11, 9, 12, 9, 10, 9, 13, 9, 11, 9, 12, 9, 10,
- 14, 16, 12, 13, 12, 13, 11, 10, 11, 15, 10, 12, 12, 14, 10, 10,
- 12, 16, 10, 12, 12, 14, 10, 10, 14, 16, 11, 12, 13, 14, 10, 9,
- 10, 15, 11, 13, 9, 13, 10, 10, 11, 15, 12, 13, 10, 12, 10, 10,
- 14, 16, 13, 14, 12, 13, 11, 10, 11, 16, 11, 13, 10, 13, 10, 10,
- 11, 16, 11, 13, 10, 13, 10, 10, 14, 16, 13, 14, 12, 13, 11, 9,
- 13, 16, 12, 13, 12, 14, 11, 10, 14, 16, 12, 13, 12, 14, 10, 9,
- 16, 16, 12, 13, 13, 13, 10, 8, 3, 11, 6, 10, 7, 11, 9, 10,
- 8, 12, 8, 11, 9, 12, 9, 10, 14, 16, 13, 13, 13, 14, 11, 11,
- 5, 12, 6, 10, 8, 12, 9, 10, 8, 13, 8, 11, 9, 12, 9, 10,
- 14, 16, 12, 13, 13, 14, 11, 10, 9, 14, 8, 11, 11, 14, 10, 10,
- 11, 15, 9, 11, 12, 14, 10, 10, 14, 16, 11, 12, 13, 14, 11, 9,
- 6, 12, 8, 11, 7, 11, 9, 10, 8, 13, 9, 11, 9, 12, 9, 10,
- 14, 16, 12, 13, 13, 13, 11, 10, 7, 13, 8, 11, 8, 12, 9, 10,
- 9, 13, 9, 11, 9, 12, 9, 9, 14, 16, 12, 13, 12, 13, 11, 10,
- 10, 15, 9, 12, 11, 14, 10, 10, 11, 15, 9, 11, 11, 13, 10, 9,
- 14, 16, 11, 12, 13, 14, 10, 9, 9, 15, 11, 13, 9, 12, 10, 10,
- 11, 15, 11, 13, 9, 12, 10, 10, 14, 16, 13, 14, 12, 13, 11, 10,
- 10, 15, 11, 13, 10, 13, 10, 10, 11, 15, 11, 13, 10, 12, 10, 10,
- 14, 16, 12, 13, 11, 12, 10, 9, 13, 16, 12, 13, 12, 14, 10, 9,
- 13, 16, 11, 12, 12, 13, 10, 9, 14, 16, 11, 12, 12, 13, 9, 8,
- 7, 13, 8, 12, 9, 13, 10, 11, 10, 14, 10, 12, 11, 13, 11, 11,
- 16, 16, 13, 14, 14, 14, 12, 11, 8, 14, 8, 12, 9, 13, 10, 10,
- 10, 14, 10, 12, 11, 13, 10, 10, 16, 16, 13, 13, 14, 14, 12, 11,
- 10, 15, 9, 12, 11, 14, 10, 10, 12, 16, 10, 12, 12, 14, 10, 10,
- 16, 16, 12, 13, 14, 15, 11, 10, 8, 14, 9, 12, 9, 13, 10, 11,
- 10, 15, 10, 12, 10, 13, 10, 11, 16, 16, 13, 14, 14, 14, 12, 11,
- 8, 14, 9, 12, 9, 13, 10, 10, 10, 14, 10, 12, 10, 13, 10, 10,
- 15, 16, 13, 13, 13, 14, 11, 10, 10, 15, 10, 12, 12, 14, 10, 10,
- 11, 16, 9, 12, 12, 14, 10, 10, 14, 16, 11, 12, 13, 14, 10, 9,
- 11, 16, 11, 13, 10, 13, 10, 10, 12, 16, 12, 13, 10, 13, 11, 10,
- 15, 16, 14, 14, 12, 13, 11, 10, 11, 16, 11, 13, 10, 13, 10, 10,
- 11, 16, 12, 13, 10, 12, 10, 10, 14, 16, 13, 14, 11, 13, 11, 9,
- 13, 16, 12, 13, 12, 14, 10, 10, 12, 16, 11, 12, 12, 13, 10, 9,
- 14, 16, 11, 12, 11, 12, 9, 8, 10, 16, 10, 13, 11, 14, 11, 11,
- 12, 16, 11, 13, 12, 14, 11, 11, 16, 16, 14, 13, 14, 14, 12, 10,
- 10, 15, 10, 13, 10, 13, 10, 11, 12, 16, 11, 13, 11, 13, 11, 10,
- 16, 16, 14, 13, 14, 14, 12, 10, 11, 15, 9, 12, 11, 13, 10, 9,
- 12, 16, 10, 12, 12, 13, 10, 9, 16, 16, 12, 12, 13, 14, 10, 8,
- 10, 16, 10, 13, 10, 14, 11, 11, 12, 16, 11, 13, 12, 14, 11, 10,
- 16, 16, 14, 13, 14, 14, 12, 10, 9, 15, 9, 12, 10, 13, 10, 10,
- 11, 16, 10, 12, 11, 13, 10, 10, 16, 16, 13, 13, 13, 14, 11, 9,
- 10, 15, 9, 11, 11, 13, 9, 9, 11, 15, 9, 11, 11, 13, 9, 8,
- 14, 16, 10, 11, 13, 13, 10, 8, 11, 16, 11, 13, 10, 13, 10, 9,
- 13, 16, 11, 13, 11, 13, 10, 9, 16, 16, 13, 13, 13, 13, 10, 8,
- 11, 16, 10, 12, 10, 13, 10, 9, 11, 16, 11, 12, 10, 12, 9, 9,
- 15, 16, 12, 13, 11, 12, 10, 8, 11, 16, 10, 12, 11, 12, 9, 8,
- 11, 15, 9, 11, 10, 12, 9, 7, 13, 15, 9, 9, 10, 10, 7, 5,
- },
- {
- 0, 7, 3, 8, 4, 9, 7, 8, 5, 10, 7, 10, 8, 11, 8, 9,
- 16, 16, 16, 16, 16, 16, 11, 10, 2, 10, 4, 9, 7, 10, 7, 8,
- 7, 16, 7, 10, 9, 16, 8, 9, 16, 16, 16, 16, 16, 16, 11, 10,
- 8, 16, 7, 10, 10, 16, 9, 8, 10, 16, 9, 11, 16, 16, 9, 9,
- 16, 16, 16, 16, 16, 16, 11, 9, 3, 10, 6, 9, 6, 11, 8, 8,
- 7, 16, 8, 10, 9, 16, 9, 9, 16, 16, 16, 16, 16, 16, 11, 10,
- 5, 16, 7, 10, 8, 11, 8, 8, 8, 16, 8, 10, 9, 16, 8, 8,
- 16, 16, 11, 16, 16, 16, 10, 9, 9, 16, 9, 11, 11, 16, 9, 9,
- 11, 16, 9, 11, 11, 16, 9, 8, 16, 16, 10, 16, 16, 16, 10, 9,
- 8, 16, 10, 16, 8, 16, 10, 9, 12, 16, 11, 16, 10, 16, 10, 9,
- 16, 16, 16, 16, 16, 16, 12, 10, 10, 16, 11, 16, 10, 16, 10, 9,
- 11, 16, 11, 16, 10, 16, 10, 9, 16, 16, 16, 16, 16, 16, 11, 9,
- 16, 16, 16, 16, 16, 16, 10, 9, 16, 16, 11, 16, 16, 16, 10, 9,
- 16, 16, 10, 11, 11, 16, 9, 7, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- },
- {
- 2, 9, 6, 9, 6, 10, 8, 9, 8, 12, 9, 11, 9, 12, 10, 10,
- 16, 16, 14, 14, 15, 15, 13, 12, 5, 11, 7, 10, 8, 11, 9, 9,
- 9, 13, 9, 11, 10, 12, 10, 10, 15, 16, 14, 14, 14, 16, 12, 11,
- 10, 14, 9, 11, 11, 13, 10, 10, 12, 15, 10, 12, 12, 13, 11, 10,
- 16, 16, 14, 15, 14, 15, 12, 11, 5, 11, 8, 10, 7, 11, 9, 9,
- 9, 13, 9, 12, 9, 12, 10, 10, 15, 16, 13, 14, 13, 16, 12, 11,
- 7, 12, 8, 11, 9, 11, 9, 10, 9, 13, 9, 11, 10, 12, 9, 9,
- 16, 16, 13, 14, 13, 14, 11, 11, 10, 14, 10, 12, 11, 13, 10, 10,
- 11, 16, 11, 12, 12, 13, 10, 10, 16, 16, 13, 14, 13, 14, 12, 11,
- 10, 14, 11, 13, 10, 13, 10, 11, 12, 16, 12, 13, 10, 12, 11, 11,
- 16, 16, 14, 15, 13, 14, 12, 11, 11, 15, 11, 13, 11, 13, 10, 10,
- 12, 15, 12, 13, 11, 13, 11, 10, 15, 16, 14, 15, 13, 15, 12, 11,
- 12, 16, 12, 13, 12, 14, 11, 11, 13, 16, 12, 13, 12, 14, 11, 10,
- 16, 16, 13, 14, 13, 14, 11, 10, 3, 10, 6, 9, 7, 10, 8, 9,
- 9, 12, 9, 11, 10, 12, 9, 10, 15, 16, 14, 14, 14, 14, 12, 11,
- 6, 11, 7, 10, 8, 10, 9, 9, 9, 13, 9, 11, 10, 12, 9, 9,
- 15, 16, 13, 14, 14, 15, 12, 11, 10, 14, 9, 11, 11, 12, 10, 10,
- 12, 14, 10, 12, 11, 13, 10, 10, 15, 16, 13, 14, 14, 16, 12, 11,
- 6, 11, 8, 10, 7, 11, 9, 9, 9, 13, 9, 11, 9, 12, 9, 9,
- 15, 16, 14, 14, 13, 14, 12, 11, 7, 11, 8, 11, 8, 11, 9, 9,
- 9, 12, 9, 11, 9, 12, 9, 9, 15, 16, 13, 13, 13, 14, 11, 10,
- 10, 13, 10, 12, 11, 13, 10, 10, 11, 15, 10, 12, 11, 13, 10, 10,
- 14, 16, 12, 13, 13, 14, 11, 10, 10, 14, 11, 12, 9, 12, 10, 10,
- 11, 15, 11, 13, 10, 13, 10, 10, 15, 16, 14, 14, 13, 14, 12, 11,
- 10, 14, 10, 12, 10, 12, 10, 10, 11, 15, 11, 12, 10, 12, 10, 10,
- 15, 16, 13, 14, 12, 14, 11, 10, 12, 16, 11, 13, 12, 14, 11, 10,
- 12, 16, 12, 13, 11, 13, 10, 10, 15, 16, 12, 14, 12, 14, 11, 9,
- 7, 12, 9, 11, 9, 12, 10, 10, 11, 14, 11, 12, 11, 13, 11, 11,
- 16, 16, 15, 16, 15, 16, 13, 12, 8, 12, 9, 11, 9, 12, 10, 10,
- 11, 14, 11, 12, 11, 13, 10, 10, 16, 16, 14, 15, 15, 16, 13, 12,
- 11, 14, 10, 12, 11, 13, 10, 10, 12, 16, 11, 13, 12, 14, 11, 10,
- 16, 16, 14, 15, 14, 16, 12, 11, 8, 13, 9, 11, 9, 12, 10, 10,
- 11, 14, 11, 12, 11, 13, 10, 10, 16, 16, 15, 15, 14, 15, 13, 12,
- 9, 13, 9, 12, 9, 12, 10, 10, 11, 14, 10, 12, 10, 12, 10, 10,
- 16, 16, 14, 15, 14, 14, 12, 11, 11, 15, 11, 12, 11, 13, 11, 10,
- 12, 16, 11, 12, 12, 13, 11, 10, 16, 16, 13, 15, 14, 15, 11, 11,
- 11, 16, 11, 13, 10, 13, 11, 11, 12, 16, 12, 14, 11, 13, 11, 11,
- 16, 16, 14, 15, 14, 15, 13, 11, 11, 16, 11, 13, 11, 13, 11, 10,
- 12, 16, 12, 13, 10, 13, 11, 10, 16, 16, 14, 14, 12, 14, 12, 10,
- 12, 16, 12, 14, 12, 14, 11, 11, 13, 16, 12, 14, 12, 14, 11, 10,
- 15, 16, 12, 14, 12, 14, 11, 9, 9, 14, 11, 13, 11, 13, 11, 11,
- 13, 16, 12, 14, 13, 14, 12, 11, 16, 16, 16, 16, 16, 16, 14, 12,
- 9, 14, 10, 12, 10, 13, 11, 11, 12, 16, 12, 13, 13, 14, 11, 11,
- 16, 16, 16, 16, 16, 14, 13, 12, 10, 15, 11, 13, 11, 14, 11, 10,
- 13, 16, 12, 13, 12, 15, 11, 10, 16, 16, 14, 16, 15, 16, 13, 11,
- 10, 14, 10, 13, 11, 14, 11, 11, 13, 16, 12, 13, 12, 14, 11, 11,
- 16, 16, 16, 16, 15, 16, 13, 12, 10, 14, 10, 12, 10, 13, 10, 11,
- 12, 15, 12, 13, 12, 13, 11, 10, 16, 16, 14, 14, 15, 15, 13, 11,
- 11, 16, 11, 13, 11, 14, 11, 10, 12, 16, 11, 13, 12, 14, 11, 10,
- 16, 16, 13, 14, 14, 15, 12, 10, 11, 16, 12, 13, 11, 14, 11, 10,
- 13, 16, 13, 14, 12, 14, 11, 11, 16, 16, 15, 16, 15, 15, 12, 11,
- 11, 16, 12, 13, 11, 14, 11, 10, 13, 16, 12, 13, 11, 14, 11, 10,
- 16, 16, 14, 15, 13, 14, 12, 10, 12, 16, 12, 14, 12, 14, 10, 10,
- 12, 16, 11, 13, 11, 14, 10, 10, 14, 16, 11, 13, 12, 13, 10, 8,
- },
- },
- {
- {
- 0, 12, 6, 13, 7, 14, 11, 14, 8, 14, 10, 14, 11, 15, 13, 15,
- 16, 16, 16, 16, 16, 16, 16, 16, 5, 14, 7, 13, 10, 16, 12, 14,
- 9, 16, 10, 14, 12, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 9, 14, 14, 16, 13, 16, 12, 16, 11, 16, 16, 16, 14, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 5, 14, 9, 14, 8, 14, 12, 14,
- 9, 16, 11, 14, 11, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 8, 16, 10, 14, 11, 16, 12, 14, 10, 16, 11, 15, 12, 16, 13, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 12, 16, 12, 16, 14, 16, 14, 16,
- 13, 16, 12, 16, 15, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 13, 16, 11, 16, 14, 16, 13, 16, 14, 16, 13, 16, 14, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 12, 16, 14, 16, 13, 16, 14, 16,
- 13, 16, 14, 16, 13, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 14, 16, 16, 16, 15, 16, 16, 16, 14, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 1, 12, 6, 12, 8, 14, 11, 13,
- 8, 14, 10, 13, 11, 14, 13, 14, 16, 16, 16, 16, 16, 16, 16, 16,
- 5, 14, 7, 13, 10, 14, 11, 14, 9, 16, 10, 14, 12, 16, 13, 15,
- 16, 16, 16, 16, 16, 16, 16, 16, 9, 16, 9, 14, 13, 16, 13, 14,
- 12, 16, 11, 15, 14, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 5, 14, 9, 13, 8, 14, 12, 14, 9, 16, 11, 14, 11, 16, 13, 14,
- 16, 16, 16, 16, 16, 16, 16, 16, 7, 15, 9, 14, 10, 16, 12, 14,
- 9, 16, 10, 14, 11, 16, 12, 14, 16, 16, 16, 16, 16, 16, 15, 16,
- 11, 16, 11, 15, 14, 16, 13, 15, 12, 16, 11, 15, 14, 16, 13, 14,
- 16, 16, 14, 16, 16, 16, 14, 16, 10, 16, 13, 16, 10, 16, 13, 16,
- 12, 16, 14, 16, 12, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 11, 16, 13, 16, 12, 16, 13, 16, 12, 16, 13, 16, 12, 16, 13, 16,
- 16, 16, 16, 16, 16, 16, 15, 16, 14, 16, 14, 16, 16, 16, 14, 16,
- 15, 16, 14, 16, 14, 16, 14, 16, 16, 16, 16, 16, 16, 16, 14, 14,
- 4, 14, 8, 13, 9, 16, 12, 14, 9, 16, 11, 14, 11, 16, 13, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 6, 15, 8, 13, 10, 16, 12, 14,
- 10, 16, 11, 14, 12, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 9, 16, 9, 14, 13, 16, 13, 15, 12, 16, 11, 16, 14, 16, 13, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 6, 16, 9, 14, 9, 16, 12, 14,
- 10, 16, 11, 15, 12, 16, 13, 15, 16, 16, 16, 16, 16, 16, 16, 16,
- 8, 16, 10, 14, 11, 16, 12, 14, 10, 16, 11, 14, 12, 16, 13, 15,
- 16, 16, 16, 16, 16, 16, 16, 16, 11, 16, 11, 15, 14, 16, 13, 15,
- 12, 16, 11, 15, 14, 16, 13, 14, 16, 16, 14, 16, 16, 16, 14, 16,
- 10, 16, 13, 16, 10, 16, 13, 15, 13, 16, 14, 16, 12, 16, 14, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 11, 16, 13, 16, 12, 16, 13, 16,
- 12, 16, 13, 16, 11, 16, 13, 16, 16, 16, 16, 16, 15, 16, 15, 16,
- 14, 16, 14, 16, 15, 16, 14, 16, 14, 16, 14, 16, 14, 16, 14, 14,
- 16, 16, 14, 16, 15, 16, 14, 14, 6, 16, 9, 14, 10, 16, 12, 14,
- 10, 16, 11, 13, 12, 16, 13, 14, 16, 16, 16, 16, 16, 16, 14, 14,
- 7, 16, 9, 14, 10, 16, 12, 13, 11, 16, 11, 14, 12, 16, 12, 14,
- 16, 16, 16, 16, 16, 16, 14, 14, 9, 16, 9, 14, 12, 16, 11, 13,
- 12, 16, 11, 14, 12, 16, 12, 13, 16, 16, 14, 16, 16, 16, 13, 14,
- 7, 16, 10, 14, 10, 16, 12, 14, 11, 16, 11, 14, 11, 16, 12, 14,
- 16, 16, 16, 16, 16, 16, 14, 14, 8, 16, 10, 14, 10, 16, 11, 13,
- 10, 16, 11, 13, 11, 16, 12, 13, 16, 16, 14, 16, 16, 16, 14, 14,
- 10, 16, 9, 13, 12, 16, 11, 13, 11, 16, 10, 13, 12, 16, 11, 12,
- 16, 16, 13, 15, 15, 16, 13, 13, 9, 16, 11, 14, 9, 16, 11, 13,
- 12, 16, 12, 16, 12, 16, 12, 13, 16, 16, 16, 16, 15, 16, 14, 14,
- 10, 16, 11, 14, 10, 16, 11, 13, 11, 16, 12, 14, 10, 15, 11, 13,
- 16, 16, 15, 16, 13, 16, 13, 13, 12, 16, 11, 13, 12, 16, 11, 12,
- 12, 16, 11, 13, 11, 14, 11, 11, 13, 16, 12, 13, 12, 14, 11, 11,
- },
- {
- 0, 10, 5, 10, 6, 11, 8, 10, 7, 12, 8, 11, 8, 12, 9, 10,
- 14, 16, 13, 13, 13, 14, 12, 11, 4, 12, 6, 10, 8, 12, 9, 10,
- 8, 13, 8, 11, 9, 12, 9, 10, 14, 16, 12, 13, 13, 14, 11, 11,
- 9, 15, 8, 12, 12, 14, 10, 11, 11, 16, 9, 12, 12, 14, 10, 10,
- 14, 16, 11, 13, 13, 15, 11, 11, 4, 12, 8, 11, 6, 11, 9, 10,
- 8, 13, 9, 11, 8, 12, 9, 10, 14, 16, 12, 13, 13, 14, 11, 11,
- 7, 13, 8, 11, 9, 12, 9, 10, 8, 13, 9, 11, 9, 12, 9, 10,
- 14, 16, 12, 13, 12, 13, 11, 10, 11, 16, 10, 12, 12, 14, 10, 11,
- 11, 16, 10, 12, 12, 14, 10, 10, 15, 16, 11, 13, 13, 14, 11, 10,
- 10, 16, 11, 13, 9, 13, 10, 11, 11, 15, 12, 13, 10, 12, 10, 11,
- 15, 16, 13, 14, 12, 13, 11, 11, 11, 16, 11, 13, 10, 13, 10, 11,
- 12, 16, 11, 13, 10, 13, 10, 10, 15, 16, 13, 14, 12, 13, 11, 10,
- 13, 16, 12, 13, 13, 14, 11, 11, 14, 16, 12, 13, 12, 14, 11, 10,
- 16, 16, 13, 13, 13, 14, 11, 9, 3, 11, 6, 10, 6, 11, 9, 10,
- 8, 12, 8, 11, 9, 12, 9, 10, 14, 16, 13, 13, 13, 13, 12, 11,
- 5, 12, 6, 10, 8, 12, 9, 10, 8, 13, 8, 11, 9, 12, 9, 10,
- 14, 16, 12, 13, 13, 14, 11, 11, 9, 15, 8, 11, 11, 14, 10, 10,
- 11, 15, 9, 11, 12, 14, 10, 10, 14, 16, 11, 12, 13, 14, 11, 10,
- 5, 12, 8, 11, 7, 11, 9, 10, 8, 13, 9, 11, 9, 12, 9, 10,
- 14, 16, 12, 13, 13, 13, 11, 11, 7, 13, 8, 11, 8, 12, 9, 10,
- 8, 13, 8, 11, 9, 12, 9, 9, 13, 16, 11, 13, 12, 13, 11, 10,
- 10, 15, 9, 12, 11, 14, 10, 10, 11, 15, 9, 11, 11, 13, 10, 10,
- 14, 16, 11, 12, 13, 14, 10, 10, 9, 16, 11, 13, 9, 12, 10, 10,
- 11, 16, 11, 13, 9, 12, 10, 10, 15, 16, 13, 14, 12, 13, 11, 10,
- 11, 16, 11, 13, 10, 13, 10, 10, 11, 15, 11, 13, 9, 12, 10, 10,
- 14, 16, 12, 13, 11, 13, 10, 10, 13, 16, 12, 13, 12, 14, 11, 10,
- 13, 16, 11, 13, 12, 13, 10, 10, 14, 16, 11, 12, 12, 13, 10, 9,
- 7, 14, 8, 12, 9, 13, 10, 11, 10, 14, 10, 12, 11, 13, 11, 11,
- 16, 16, 14, 14, 14, 14, 12, 12, 7, 14, 8, 12, 9, 13, 10, 11,
- 10, 14, 10, 12, 11, 13, 10, 11, 16, 16, 13, 13, 14, 14, 12, 11,
- 10, 15, 9, 12, 12, 14, 10, 10, 12, 16, 9, 12, 12, 14, 10, 10,
- 16, 16, 12, 13, 14, 15, 12, 11, 8, 14, 9, 12, 9, 13, 10, 11,
- 10, 15, 10, 12, 10, 13, 10, 11, 16, 16, 14, 14, 14, 14, 12, 11,
- 8, 14, 9, 12, 9, 13, 10, 11, 10, 14, 10, 12, 10, 13, 10, 10,
- 15, 16, 13, 13, 13, 14, 12, 11, 10, 15, 10, 12, 12, 14, 10, 10,
- 11, 16, 9, 12, 12, 14, 10, 10, 14, 16, 11, 12, 13, 14, 11, 10,
- 11, 16, 11, 14, 9, 13, 10, 11, 12, 16, 12, 14, 10, 13, 11, 11,
- 16, 16, 14, 15, 13, 14, 12, 11, 11, 16, 12, 14, 10, 13, 11, 11,
- 11, 16, 11, 13, 10, 13, 10, 10, 15, 16, 13, 14, 12, 13, 11, 10,
- 13, 16, 12, 14, 13, 14, 11, 10, 12, 16, 11, 13, 12, 13, 10, 10,
- 14, 16, 11, 12, 11, 13, 10, 9, 10, 16, 10, 13, 11, 14, 11, 11,
- 12, 16, 11, 13, 12, 14, 11, 11, 16, 16, 14, 13, 14, 15, 12, 11,
- 10, 16, 10, 13, 10, 14, 11, 11, 12, 16, 11, 13, 11, 14, 11, 11,
- 16, 16, 14, 13, 14, 14, 12, 11, 11, 15, 9, 12, 11, 14, 10, 10,
- 13, 16, 10, 12, 12, 14, 10, 10, 16, 16, 13, 13, 14, 14, 11, 10,
- 10, 16, 10, 13, 11, 14, 11, 11, 12, 16, 11, 13, 12, 14, 11, 11,
- 16, 16, 14, 14, 14, 14, 12, 11, 9, 16, 10, 13, 10, 14, 11, 11,
- 11, 15, 11, 12, 11, 13, 11, 11, 16, 16, 13, 13, 14, 14, 12, 10,
- 10, 15, 9, 12, 11, 14, 10, 10, 11, 16, 9, 11, 11, 13, 10, 9,
- 15, 16, 11, 12, 13, 14, 10, 9, 11, 16, 11, 13, 10, 13, 10, 10,
- 13, 16, 12, 13, 11, 13, 10, 10, 16, 16, 14, 14, 13, 13, 11, 10,
- 11, 16, 11, 13, 10, 13, 10, 10, 12, 16, 11, 13, 10, 13, 10, 10,
- 15, 16, 13, 13, 12, 13, 11, 9, 11, 16, 11, 12, 11, 13, 10, 9,
- 11, 15, 10, 11, 11, 12, 9, 8, 13, 15, 10, 10, 10, 11, 8, 7,
- },
- {
- 0, 9, 3, 8, 5, 9, 7, 8, 5, 11, 6, 9, 8, 11, 8, 9,
- 16, 16, 16, 16, 16, 16, 11, 10, 2, 10, 4, 9, 7, 10, 7, 8,
- 7, 16, 7, 10, 9, 11, 8, 9, 16, 16, 11, 16, 16, 16, 11, 10,
- 7, 16, 7, 10, 10, 16, 8, 9, 10, 16, 8, 10, 11, 16, 9, 9,
- 16, 16, 16, 16, 16, 16, 11, 10, 3, 11, 6, 9, 6, 11, 8, 8,
- 7, 16, 8, 10, 8, 11, 8, 9, 16, 16, 15, 16, 16, 16, 11, 10,
- 5, 11, 7, 9, 8, 11, 8, 8, 7, 16, 7, 10, 8, 11, 8, 8,
- 16, 16, 11, 16, 16, 16, 10, 9, 9, 16, 8, 11, 11, 16, 9, 9,
- 10, 16, 8, 11, 11, 16, 9, 9, 16, 16, 10, 16, 16, 16, 10, 9,
- 8, 16, 10, 11, 8, 16, 9, 9, 11, 16, 11, 16, 10, 16, 10, 9,
- 16, 16, 16, 16, 16, 16, 11, 10, 9, 16, 10, 16, 10, 16, 9, 9,
- 10, 16, 10, 16, 9, 16, 9, 9, 16, 16, 16, 16, 15, 16, 10, 9,
- 16, 16, 11, 16, 16, 16, 10, 10, 13, 16, 11, 16, 11, 16, 10, 9,
- 16, 16, 10, 11, 11, 16, 9, 8, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- },
- {
- 1, 10, 6, 10, 7, 11, 9, 10, 8, 12, 9, 12, 9, 12, 10, 10,
- 16, 16, 14, 16, 14, 15, 13, 12, 5, 12, 7, 10, 9, 11, 9, 10,
- 9, 13, 9, 12, 10, 13, 10, 10, 16, 16, 14, 15, 14, 14, 13, 12,
- 10, 15, 10, 12, 12, 14, 11, 11, 12, 16, 11, 13, 12, 14, 11, 11,
- 16, 16, 14, 16, 15, 16, 13, 12, 6, 12, 8, 11, 8, 11, 10, 10,
- 9, 13, 10, 12, 10, 12, 10, 10, 15, 16, 13, 15, 13, 14, 12, 12,
- 7, 13, 9, 11, 9, 12, 10, 10, 9, 14, 10, 12, 10, 13, 10, 10,
- 15, 16, 13, 15, 13, 14, 12, 11, 11, 15, 11, 13, 12, 14, 11, 11,
- 12, 16, 11, 13, 12, 14, 11, 11, 16, 16, 13, 15, 14, 16, 12, 11,
- 10, 16, 12, 14, 10, 13, 11, 11, 12, 16, 12, 14, 11, 13, 11, 11,
- 16, 16, 15, 16, 14, 16, 13, 12, 11, 16, 12, 14, 11, 14, 11, 11,
- 12, 16, 12, 14, 11, 14, 11, 11, 16, 16, 14, 15, 13, 15, 12, 12,
- 13, 16, 13, 15, 13, 15, 12, 12, 13, 16, 12, 15, 12, 15, 11, 11,
- 16, 16, 13, 16, 13, 15, 12, 11, 4, 11, 7, 10, 7, 11, 9, 10,
- 9, 13, 9, 12, 10, 12, 10, 10, 15, 16, 14, 15, 14, 15, 13, 12,
- 6, 12, 7, 11, 9, 11, 9, 10, 9, 13, 9, 12, 10, 12, 10, 10,
- 15, 16, 14, 15, 14, 15, 12, 12, 10, 15, 9, 12, 12, 13, 11, 11,
- 12, 15, 11, 13, 12, 14, 11, 11, 16, 16, 13, 15, 14, 16, 12, 12,
- 6, 12, 8, 11, 8, 11, 9, 10, 9, 14, 10, 12, 10, 12, 10, 10,
- 14, 16, 13, 14, 13, 14, 12, 12, 8, 13, 9, 11, 9, 12, 10, 10,
- 9, 13, 9, 12, 9, 12, 9, 10, 14, 16, 13, 14, 13, 14, 12, 11,
- 11, 15, 11, 13, 11, 14, 11, 11, 12, 16, 10, 13, 12, 13, 11, 10,
- 15, 16, 12, 15, 13, 16, 12, 11, 10, 15, 11, 13, 10, 13, 11, 11,
- 12, 16, 12, 14, 11, 13, 11, 11, 16, 16, 14, 15, 13, 16, 13, 12,
- 11, 16, 11, 14, 11, 13, 11, 11, 12, 16, 12, 14, 10, 13, 11, 11,
- 15, 16, 13, 16, 12, 14, 12, 11, 12, 16, 12, 14, 12, 15, 11, 11,
- 13, 16, 12, 14, 12, 14, 11, 11, 15, 16, 13, 15, 13, 15, 11, 10,
- 7, 13, 9, 12, 10, 13, 11, 11, 11, 15, 12, 13, 12, 13, 11, 11,
- 16, 16, 15, 16, 16, 16, 14, 13, 8, 13, 9, 12, 10, 13, 11, 11,
- 12, 15, 11, 13, 12, 13, 11, 11, 16, 16, 14, 15, 15, 16, 13, 12,
- 11, 16, 11, 13, 12, 14, 11, 11, 13, 16, 12, 14, 13, 15, 12, 11,
- 16, 16, 14, 16, 15, 16, 13, 12, 9, 15, 10, 13, 10, 13, 11, 11,
- 12, 15, 11, 13, 11, 13, 11, 11, 16, 16, 14, 16, 16, 16, 13, 12,
- 9, 14, 10, 13, 10, 13, 11, 11, 11, 14, 11, 13, 11, 13, 11, 11,
- 16, 16, 14, 16, 14, 16, 12, 12, 11, 16, 11, 14, 12, 14, 12, 11,
- 12, 16, 11, 13, 13, 14, 11, 11, 16, 16, 13, 15, 14, 16, 12, 11,
- 12, 16, 12, 14, 11, 14, 11, 11, 13, 16, 13, 14, 12, 15, 12, 11,
- 16, 16, 16, 16, 14, 16, 13, 12, 12, 16, 12, 14, 11, 14, 12, 11,
- 12, 16, 12, 15, 11, 14, 11, 11, 16, 16, 14, 16, 13, 15, 12, 12,
- 13, 16, 13, 16, 13, 16, 12, 12, 13, 16, 12, 15, 12, 16, 11, 11,
- 14, 16, 12, 15, 12, 15, 11, 10, 9, 16, 11, 14, 12, 14, 12, 12,
- 13, 16, 13, 15, 14, 16, 12, 12, 16, 16, 16, 16, 16, 16, 14, 13,
- 10, 16, 11, 14, 12, 14, 12, 12, 13, 16, 13, 14, 13, 16, 12, 12,
- 16, 16, 15, 16, 16, 16, 13, 12, 11, 16, 11, 14, 12, 15, 12, 11,
- 13, 16, 12, 14, 13, 16, 12, 11, 16, 16, 14, 16, 16, 16, 13, 12,
- 11, 16, 11, 14, 12, 14, 12, 12, 13, 16, 12, 15, 13, 16, 12, 12,
- 16, 16, 16, 16, 16, 16, 14, 13, 10, 16, 11, 14, 11, 15, 11, 11,
- 13, 16, 12, 14, 12, 14, 12, 11, 16, 16, 14, 16, 16, 16, 13, 12,
- 11, 16, 11, 15, 12, 15, 12, 11, 13, 16, 11, 14, 13, 15, 12, 11,
- 16, 16, 13, 16, 14, 16, 12, 11, 12, 16, 12, 15, 11, 15, 12, 11,
- 14, 16, 13, 15, 12, 16, 12, 11, 16, 16, 15, 16, 14, 16, 13, 12,
- 11, 16, 12, 15, 11, 15, 11, 11, 13, 16, 13, 16, 11, 15, 11, 11,
- 16, 16, 14, 16, 13, 15, 12, 11, 12, 16, 12, 15, 12, 16, 11, 11,
- 12, 16, 11, 15, 12, 14, 11, 11, 13, 16, 12, 13, 11, 13, 10, 9,
- },
- },
- {
- {
- 0, 13, 6, 13, 8, 14, 12, 16, 8, 16, 11, 16, 12, 16, 14, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 4, 16, 7, 14, 11, 16, 13, 16,
- 9, 16, 11, 16, 12, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 10, 16, 16, 16, 16, 16, 13, 16, 12, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 5, 16, 10, 16, 8, 16, 13, 16,
- 10, 16, 12, 16, 12, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 8, 16, 10, 16, 11, 16, 13, 16, 10, 16, 12, 16, 12, 16, 14, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 12, 16, 12, 16, 16, 16, 16, 16,
- 14, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 11, 16, 16, 16, 11, 16, 16, 16, 13, 16, 16, 16, 13, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 13, 16, 16, 16, 13, 16, 16, 16,
- 14, 16, 16, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 1, 13, 7, 13, 8, 16, 12, 16,
- 8, 16, 10, 16, 11, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 4, 16, 7, 14, 10, 16, 12, 16, 9, 16, 10, 16, 12, 16, 14, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 10, 16, 9, 16, 14, 16, 14, 16,
- 13, 16, 11, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 5, 16, 9, 16, 8, 16, 12, 16, 9, 16, 11, 16, 11, 16, 13, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 7, 16, 10, 16, 11, 16, 13, 16,
- 9, 16, 11, 16, 11, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 12, 16, 16, 16, 14, 16, 13, 16, 12, 16, 16, 16, 14, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 10, 16, 13, 16, 11, 16, 14, 16,
- 13, 16, 16, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 14, 16, 13, 16, 14, 16, 13, 16, 14, 16, 13, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 4, 16, 8, 16, 9, 16, 13, 16, 10, 16, 11, 16, 12, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 6, 16, 8, 16, 11, 16, 13, 16,
- 10, 16, 11, 16, 13, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 9, 16, 9, 16, 13, 16, 13, 16, 13, 16, 12, 16, 16, 16, 14, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 6, 16, 10, 16, 10, 16, 13, 16,
- 10, 16, 12, 16, 12, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 8, 16, 10, 16, 11, 16, 13, 16, 10, 16, 11, 16, 12, 16, 14, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 11, 16, 11, 16, 16, 16, 14, 16,
- 12, 16, 11, 16, 16, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 13, 16, 10, 16, 13, 16, 13, 16, 16, 16, 13, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 12, 16, 13, 16, 12, 16, 14, 16,
- 12, 16, 15, 16, 12, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 14, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 6, 16, 10, 16, 10, 16, 13, 16,
- 11, 16, 11, 16, 12, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 8, 16, 9, 16, 11, 16, 12, 16, 11, 16, 11, 16, 12, 16, 13, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 9, 16, 9, 16, 12, 16, 12, 16,
- 13, 16, 11, 16, 13, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 8, 16, 10, 16, 10, 16, 12, 16, 11, 16, 12, 16, 12, 16, 13, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 8, 16, 10, 16, 11, 16, 12, 16,
- 10, 16, 11, 16, 12, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 10, 14, 12, 16, 12, 16, 11, 16, 10, 14, 13, 16, 12, 14,
- 16, 16, 14, 16, 16, 16, 14, 16, 9, 16, 12, 16, 10, 16, 12, 16,
- 13, 16, 13, 16, 12, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 12, 16, 11, 16, 12, 16, 11, 16, 12, 16, 11, 16, 12, 15,
- 16, 16, 16, 16, 16, 16, 16, 16, 13, 16, 12, 16, 13, 16, 12, 13,
- 12, 16, 12, 16, 12, 16, 12, 13, 16, 16, 13, 14, 13, 16, 13, 13,
- },
- {
- 0, 10, 5, 10, 5, 10, 8, 10, 6, 11, 8, 11, 8, 11, 9, 10,
- 14, 16, 13, 14, 13, 14, 12, 12, 4, 12, 5, 10, 8, 12, 9, 10,
- 7, 12, 8, 11, 9, 12, 9, 10, 14, 16, 12, 13, 13, 14, 12, 12,
- 9, 16, 8, 12, 12, 14, 10, 11, 11, 16, 9, 12, 12, 14, 11, 11,
- 14, 16, 12, 13, 14, 15, 12, 12, 4, 12, 7, 11, 6, 11, 9, 10,
- 8, 12, 9, 11, 8, 11, 9, 10, 14, 16, 12, 14, 13, 14, 12, 12,
- 7, 13, 8, 11, 8, 12, 9, 10, 8, 13, 8, 11, 9, 12, 9, 10,
- 14, 16, 12, 13, 12, 13, 11, 11, 11, 16, 10, 12, 12, 14, 11, 11,
- 12, 16, 10, 12, 12, 14, 11, 11, 16, 16, 12, 13, 14, 15, 12, 11,
- 10, 16, 11, 14, 9, 13, 10, 11, 11, 16, 12, 14, 10, 13, 11, 11,
- 15, 16, 13, 14, 13, 14, 12, 12, 11, 16, 12, 14, 10, 13, 11, 11,
- 12, 16, 12, 14, 11, 13, 11, 11, 15, 16, 13, 14, 13, 14, 12, 11,
- 14, 16, 13, 14, 13, 15, 12, 12, 14, 16, 12, 14, 13, 15, 11, 11,
- 16, 16, 13, 14, 14, 15, 12, 11, 3, 11, 5, 10, 6, 11, 9, 10,
- 7, 12, 8, 11, 9, 11, 9, 10, 14, 16, 13, 13, 13, 14, 12, 12,
- 5, 12, 6, 10, 8, 12, 9, 10, 8, 13, 8, 11, 9, 12, 9, 10,
- 14, 16, 12, 13, 13, 14, 12, 12, 9, 16, 8, 11, 11, 14, 10, 11,
- 11, 16, 9, 12, 12, 14, 10, 11, 15, 16, 12, 13, 14, 15, 12, 11,
- 5, 12, 7, 11, 6, 11, 9, 10, 8, 13, 9, 11, 8, 11, 9, 10,
- 14, 16, 12, 14, 13, 13, 12, 12, 7, 13, 8, 11, 8, 12, 9, 10,
- 8, 12, 8, 11, 9, 12, 9, 10, 13, 16, 12, 13, 12, 13, 11, 11,
- 10, 16, 9, 12, 12, 14, 10, 11, 11, 15, 9, 12, 12, 14, 10, 11,
- 14, 16, 11, 13, 13, 14, 11, 11, 9, 16, 11, 14, 8, 13, 10, 11,
- 11, 16, 12, 13, 10, 13, 10, 11, 16, 16, 13, 15, 13, 14, 12, 12,
- 11, 16, 11, 14, 10, 13, 10, 11, 11, 16, 11, 13, 10, 13, 10, 11,
- 14, 16, 13, 14, 12, 13, 11, 11, 14, 16, 12, 14, 13, 15, 11, 11,
- 13, 16, 12, 13, 12, 14, 11, 11, 14, 16, 12, 13, 12, 13, 11, 10,
- 6, 14, 8, 12, 9, 13, 10, 11, 10, 14, 10, 12, 11, 13, 11, 12,
- 16, 16, 14, 14, 14, 14, 13, 12, 7, 14, 8, 12, 9, 13, 10, 11,
- 10, 14, 10, 12, 11, 13, 11, 11, 16, 16, 13, 14, 14, 15, 13, 12,
- 10, 16, 8, 12, 12, 14, 10, 11, 12, 16, 10, 12, 13, 15, 11, 11,
- 16, 16, 13, 14, 15, 16, 12, 12, 8, 15, 9, 13, 9, 13, 10, 11,
- 10, 15, 10, 13, 10, 13, 11, 11, 16, 16, 14, 14, 14, 14, 13, 12,
- 8, 15, 9, 12, 10, 13, 10, 11, 10, 14, 10, 12, 10, 13, 10, 11,
- 16, 16, 13, 14, 13, 14, 12, 12, 10, 16, 10, 13, 12, 15, 11, 11,
- 11, 16, 9, 12, 12, 14, 11, 11, 14, 16, 11, 13, 14, 16, 12, 11,
- 10, 16, 12, 14, 9, 13, 11, 11, 12, 16, 12, 14, 11, 13, 11, 11,
- 16, 16, 15, 16, 14, 14, 13, 12, 11, 16, 12, 14, 11, 14, 11, 11,
- 11, 16, 12, 14, 10, 13, 11, 11, 15, 16, 13, 15, 12, 14, 12, 11,
- 14, 16, 13, 14, 13, 16, 12, 12, 12, 16, 12, 13, 12, 14, 11, 11,
- 14, 16, 11, 12, 12, 13, 10, 10, 9, 16, 10, 14, 11, 15, 12, 12,
- 12, 16, 11, 13, 12, 15, 12, 12, 16, 16, 14, 13, 15, 15, 13, 12,
- 10, 16, 10, 14, 11, 15, 11, 12, 12, 16, 11, 13, 12, 14, 12, 12,
- 16, 16, 14, 13, 15, 14, 13, 12, 11, 16, 9, 12, 12, 14, 11, 11,
- 13, 16, 11, 13, 13, 15, 11, 11, 16, 16, 14, 14, 16, 16, 12, 12,
- 10, 16, 10, 14, 11, 14, 11, 12, 12, 16, 11, 13, 12, 14, 12, 12,
- 16, 16, 14, 14, 15, 15, 13, 12, 10, 16, 10, 13, 11, 14, 11, 12,
- 11, 16, 11, 13, 11, 14, 11, 12, 16, 16, 14, 14, 14, 14, 13, 12,
- 11, 16, 10, 12, 12, 15, 11, 11, 12, 16, 9, 12, 12, 14, 10, 11,
- 16, 16, 12, 13, 14, 15, 11, 11, 11, 16, 12, 14, 10, 14, 11, 11,
- 13, 16, 12, 14, 12, 14, 11, 11, 16, 16, 15, 15, 14, 15, 12, 12,
- 11, 16, 12, 14, 11, 14, 11, 11, 12, 16, 12, 14, 11, 13, 11, 11,
- 16, 16, 14, 14, 13, 14, 12, 11, 12, 16, 11, 13, 12, 14, 10, 10,
- 12, 15, 11, 12, 12, 13, 10, 10, 14, 15, 11, 11, 12, 12, 10, 9,
- },
- {
- 0, 8, 3, 8, 5, 9, 7, 8, 5, 10, 6, 10, 8, 11, 8, 9,
- 16, 16, 15, 16, 16, 16, 11, 11, 2, 10, 4, 9, 7, 10, 7, 8,
- 7, 16, 7, 10, 9, 11, 8, 9, 16, 16, 15, 16, 16, 16, 11, 11,
- 7, 16, 6, 11, 10, 16, 9, 10, 10, 16, 9, 11, 11, 16, 9, 10,
- 16, 16, 16, 16, 16, 16, 16, 11, 3, 10, 6, 9, 5, 10, 7, 9,
- 7, 16, 8, 10, 8, 11, 8, 9, 16, 16, 16, 16, 16, 16, 11, 11,
- 5, 11, 7, 10, 8, 11, 8, 9, 7, 14, 7, 10, 8, 11, 8, 9,
- 16, 16, 11, 16, 16, 16, 10, 11, 9, 16, 9, 11, 11, 16, 9, 10,
- 10, 16, 8, 11, 11, 16, 9, 10, 16, 16, 11, 16, 16, 16, 11, 10,
- 8, 16, 9, 16, 7, 16, 9, 10, 11, 16, 11, 16, 10, 16, 10, 10,
- 16, 16, 16, 16, 16, 16, 16, 11, 9, 16, 10, 16, 9, 16, 9, 10,
- 10, 16, 10, 16, 9, 16, 9, 10, 16, 16, 16, 16, 11, 16, 11, 11,
- 16, 16, 16, 16, 16, 16, 10, 10, 11, 16, 11, 16, 11, 16, 10, 10,
- 16, 16, 11, 16, 11, 16, 10, 9, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- },
- {
- 1, 10, 6, 10, 7, 11, 9, 10, 8, 12, 9, 12, 9, 12, 10, 10,
- 15, 16, 14, 15, 14, 16, 13, 12, 5, 12, 7, 11, 8, 11, 9, 10,
- 9, 13, 9, 12, 10, 12, 10, 10, 16, 16, 14, 15, 13, 16, 13, 12,
- 10, 15, 10, 13, 12, 14, 11, 11, 12, 16, 11, 13, 12, 14, 11, 11,
- 16, 16, 14, 16, 14, 16, 13, 12, 5, 12, 8, 11, 7, 11, 9, 10,
- 9, 13, 10, 12, 9, 12, 10, 10, 14, 16, 14, 15, 13, 14, 13, 12,
- 7, 13, 9, 12, 9, 12, 10, 10, 9, 13, 9, 12, 9, 12, 10, 10,
- 14, 16, 13, 14, 13, 15, 12, 12, 11, 16, 11, 13, 12, 14, 11, 11,
- 12, 16, 11, 14, 12, 14, 11, 11, 16, 16, 14, 16, 14, 16, 13, 12,
- 10, 16, 11, 14, 10, 13, 11, 11, 12, 16, 12, 14, 11, 13, 11, 11,
- 15, 16, 15, 16, 14, 16, 13, 12, 11, 16, 12, 14, 11, 14, 11, 12,
- 12, 16, 12, 14, 11, 14, 11, 11, 15, 16, 14, 16, 13, 16, 13, 12,
- 13, 16, 13, 16, 13, 16, 12, 12, 13, 16, 13, 16, 13, 16, 12, 12,
- 16, 16, 14, 15, 14, 16, 13, 12, 4, 11, 7, 10, 7, 11, 9, 10,
- 9, 13, 9, 11, 9, 12, 10, 10, 15, 16, 14, 15, 14, 15, 13, 12,
- 6, 12, 7, 11, 8, 11, 9, 10, 9, 13, 9, 12, 10, 12, 10, 10,
- 15, 16, 13, 14, 14, 15, 12, 12, 10, 14, 10, 12, 12, 13, 11, 11,
- 12, 16, 11, 13, 12, 14, 11, 11, 16, 16, 14, 15, 15, 16, 13, 12,
- 6, 12, 8, 11, 8, 11, 9, 10, 9, 13, 10, 12, 9, 12, 10, 10,
- 16, 16, 14, 15, 13, 14, 12, 12, 8, 13, 9, 11, 9, 12, 9, 10,
- 9, 13, 9, 12, 9, 12, 9, 10, 14, 16, 13, 14, 13, 14, 12, 11,
- 11, 15, 11, 13, 12, 14, 11, 11, 11, 16, 10, 13, 12, 14, 11, 11,
- 15, 16, 13, 15, 14, 16, 12, 11, 10, 16, 12, 13, 10, 13, 11, 11,
- 11, 16, 12, 14, 10, 13, 11, 11, 16, 16, 14, 16, 13, 16, 13, 12,
- 11, 16, 12, 14, 10, 14, 11, 11, 11, 16, 12, 14, 10, 13, 11, 11,
- 16, 16, 14, 16, 12, 15, 12, 11, 13, 16, 13, 15, 13, 15, 12, 12,
- 13, 16, 12, 15, 12, 15, 12, 11, 15, 16, 13, 16, 13, 16, 12, 11,
- 8, 14, 9, 12, 10, 13, 11, 11, 11, 16, 11, 13, 11, 13, 11, 11,
- 16, 16, 16, 16, 16, 16, 14, 13, 9, 14, 10, 12, 10, 13, 11, 11,
- 11, 16, 11, 13, 12, 13, 11, 11, 16, 16, 15, 16, 15, 16, 14, 12,
- 11, 16, 11, 13, 12, 14, 12, 11, 13, 16, 12, 14, 13, 14, 12, 11,
- 16, 16, 15, 16, 16, 16, 14, 13, 9, 14, 10, 13, 10, 13, 11, 11,
- 11, 16, 11, 13, 11, 13, 11, 11, 16, 16, 15, 16, 14, 15, 14, 13,
- 9, 14, 10, 13, 10, 13, 11, 11, 11, 15, 11, 13, 11, 13, 11, 11,
- 16, 16, 14, 16, 14, 16, 13, 12, 12, 16, 12, 14, 13, 14, 12, 11,
- 12, 16, 11, 14, 12, 15, 12, 11, 16, 16, 13, 16, 15, 16, 13, 11,
- 11, 16, 12, 14, 11, 14, 12, 11, 13, 16, 13, 15, 12, 14, 12, 12,
- 16, 16, 16, 16, 14, 16, 14, 13, 12, 16, 13, 15, 11, 14, 12, 12,
- 12, 16, 13, 14, 11, 15, 12, 11, 16, 16, 15, 16, 13, 15, 13, 12,
- 13, 16, 13, 15, 13, 16, 12, 12, 13, 16, 13, 15, 13, 15, 12, 12,
- 15, 16, 13, 16, 13, 15, 11, 10, 10, 16, 12, 14, 12, 15, 12, 12,
- 14, 16, 13, 15, 13, 16, 13, 12, 16, 16, 16, 16, 16, 16, 15, 13,
- 10, 16, 12, 14, 12, 15, 12, 12, 13, 16, 13, 15, 13, 15, 13, 12,
- 16, 16, 16, 16, 16, 16, 14, 13, 11, 16, 12, 15, 13, 16, 12, 12,
- 14, 16, 13, 16, 13, 16, 12, 12, 16, 16, 15, 16, 15, 16, 14, 12,
- 11, 16, 12, 14, 12, 16, 12, 12, 14, 16, 13, 15, 13, 15, 13, 12,
- 16, 16, 16, 16, 16, 16, 15, 13, 11, 16, 12, 14, 12, 15, 12, 12,
- 13, 16, 12, 14, 12, 15, 12, 12, 16, 16, 16, 16, 16, 16, 14, 12,
- 12, 16, 12, 15, 13, 16, 12, 12, 13, 16, 12, 15, 13, 15, 12, 11,
- 16, 16, 14, 16, 15, 16, 13, 12, 12, 16, 13, 16, 12, 16, 12, 12,
- 15, 16, 14, 16, 13, 16, 12, 12, 16, 16, 16, 16, 16, 16, 14, 13,
- 12, 16, 13, 15, 12, 16, 12, 12, 13, 16, 13, 15, 12, 15, 12, 12,
- 16, 16, 15, 16, 14, 16, 13, 12, 13, 16, 13, 16, 12, 16, 12, 12,
- 13, 16, 12, 16, 12, 15, 12, 12, 14, 16, 12, 14, 12, 14, 11, 10,
- },
- },
- {
- {
- 0, 16, 6, 16, 8, 16, 16, 16, 9, 16, 11, 16, 12, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 4, 16, 7, 16, 11, 16, 16, 16,
- 10, 16, 11, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 10, 16, 16, 16, 16, 16, 16, 16, 13, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 5, 16, 10, 16, 9, 16, 16, 16,
- 10, 16, 13, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 8, 16, 11, 16, 12, 16, 16, 16, 10, 16, 12, 16, 13, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 13, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 11, 16, 16, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 13, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 1, 16, 7, 16, 8, 16, 13, 16,
- 9, 16, 11, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 4, 16, 7, 16, 11, 16, 13, 16, 9, 16, 11, 16, 13, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 9, 16, 9, 16, 16, 16, 16, 16,
- 13, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 4, 16, 10, 16, 8, 16, 16, 16, 10, 16, 12, 16, 12, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 7, 16, 10, 16, 11, 16, 16, 16,
- 9, 16, 11, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 12, 16, 16, 16, 16, 16, 13, 16, 12, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 10, 16, 16, 16, 11, 16, 16, 16,
- 16, 16, 16, 16, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 16, 16, 13, 16, 16, 16, 13, 16, 16, 16, 13, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 4, 16, 8, 16, 10, 16, 16, 16, 10, 16, 11, 16, 12, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 6, 16, 8, 16, 11, 16, 16, 16,
- 10, 16, 12, 16, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 9, 16, 9, 16, 16, 16, 16, 16, 16, 16, 13, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 6, 16, 10, 16, 10, 16, 16, 16,
- 11, 16, 12, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 8, 16, 11, 16, 11, 16, 16, 16, 10, 16, 12, 16, 12, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 11, 16, 12, 16, 16, 16, 16, 16,
- 12, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 16, 16, 10, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 11, 16, 16, 16, 12, 16, 16, 16,
- 12, 16, 16, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 6, 16, 10, 16, 11, 16, 16, 16,
- 11, 16, 12, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 8, 16, 9, 16, 11, 16, 13, 16, 11, 16, 12, 16, 13, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 9, 16, 9, 16, 13, 16, 12, 16,
- 13, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 8, 16, 10, 16, 10, 16, 14, 16, 12, 16, 12, 16, 12, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 9, 16, 11, 16, 11, 16, 13, 16,
- 10, 16, 12, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 11, 16, 10, 16, 13, 16, 12, 16, 12, 16, 11, 16, 16, 16, 13, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 9, 16, 12, 16, 10, 16, 13, 16,
- 16, 16, 16, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 13, 16, 11, 16, 13, 16, 12, 16, 13, 16, 12, 16, 13, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 13, 16, 13, 16, 16, 16, 12, 16,
- 13, 16, 12, 16, 16, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- },
- {
- 0, 10, 4, 10, 5, 11, 9, 11, 6, 11, 8, 11, 8, 12, 10, 12,
- 15, 16, 13, 15, 14, 15, 13, 14, 4, 12, 5, 11, 8, 12, 9, 11,
- 7, 13, 8, 12, 9, 13, 10, 12, 15, 16, 13, 15, 14, 16, 13, 14,
- 10, 16, 9, 13, 12, 16, 11, 13, 11, 16, 10, 14, 13, 16, 12, 13,
- 16, 16, 14, 16, 15, 16, 14, 15, 4, 12, 7, 12, 6, 12, 9, 11,
- 8, 13, 9, 12, 9, 12, 10, 12, 15, 16, 13, 15, 14, 15, 13, 14,
- 7, 13, 8, 12, 9, 13, 10, 12, 8, 13, 9, 12, 9, 13, 10, 12,
- 14, 16, 13, 15, 13, 15, 13, 14, 12, 16, 11, 14, 13, 16, 12, 13,
- 12, 16, 11, 14, 13, 16, 12, 13, 16, 16, 14, 16, 15, 16, 14, 15,
- 10, 16, 12, 16, 10, 14, 12, 13, 12, 16, 13, 16, 11, 14, 12, 13,
- 16, 16, 16, 16, 15, 16, 14, 15, 12, 16, 13, 16, 11, 15, 12, 13,
- 13, 16, 13, 16, 12, 15, 12, 14, 16, 16, 16, 16, 14, 16, 13, 14,
- 16, 16, 14, 16, 14, 16, 13, 15, 16, 16, 14, 16, 14, 16, 13, 15,
- 16, 16, 16, 16, 16, 16, 14, 16, 2, 11, 5, 11, 6, 11, 9, 11,
- 7, 12, 8, 11, 9, 12, 10, 12, 15, 16, 14, 14, 14, 14, 13, 14,
- 4, 13, 6, 11, 8, 12, 9, 11, 8, 13, 8, 12, 10, 13, 10, 12,
- 15, 16, 13, 15, 14, 15, 13, 14, 9, 16, 8, 13, 12, 15, 11, 12,
- 11, 16, 10, 14, 13, 16, 12, 13, 16, 16, 14, 16, 16, 16, 14, 15,
- 5, 13, 8, 12, 7, 12, 9, 11, 8, 13, 9, 12, 9, 12, 10, 12,
- 16, 16, 14, 15, 14, 15, 13, 13, 7, 13, 8, 12, 9, 13, 10, 12,
- 8, 13, 8, 12, 9, 13, 10, 12, 14, 16, 13, 14, 13, 15, 12, 13,
- 11, 16, 10, 14, 13, 16, 12, 13, 11, 16, 10, 13, 12, 15, 11, 13,
- 14, 16, 12, 14, 14, 16, 13, 14, 10, 16, 12, 15, 9, 14, 11, 13,
- 12, 16, 12, 16, 11, 14, 12, 13, 16, 16, 15, 16, 16, 16, 14, 15,
- 11, 16, 12, 15, 11, 15, 12, 13, 12, 16, 12, 15, 11, 14, 12, 13,
- 16, 16, 14, 16, 13, 15, 13, 14, 15, 16, 14, 16, 14, 16, 13, 14,
- 14, 16, 13, 16, 14, 16, 13, 14, 16, 16, 14, 16, 14, 16, 13, 14,
- 7, 15, 8, 13, 9, 14, 11, 13, 10, 14, 10, 13, 11, 14, 12, 13,
- 16, 16, 15, 16, 15, 16, 15, 14, 7, 16, 8, 13, 10, 14, 11, 13,
- 11, 15, 10, 13, 12, 14, 12, 13, 16, 16, 16, 16, 16, 16, 15, 15,
- 10, 16, 9, 13, 13, 16, 12, 13, 13, 16, 11, 14, 14, 16, 13, 14,
- 16, 16, 16, 16, 16, 16, 15, 16, 8, 16, 10, 14, 9, 14, 11, 13,
- 11, 16, 11, 14, 11, 14, 12, 13, 16, 16, 16, 16, 16, 16, 14, 15,
- 8, 16, 10, 14, 10, 14, 11, 13, 10, 15, 10, 14, 11, 14, 12, 13,
- 16, 16, 14, 16, 15, 16, 14, 14, 11, 16, 10, 14, 13, 16, 12, 13,
- 11, 16, 10, 13, 13, 16, 12, 13, 16, 16, 13, 16, 16, 16, 14, 14,
- 11, 16, 12, 16, 10, 15, 12, 13, 14, 16, 14, 16, 12, 16, 13, 14,
- 16, 16, 16, 16, 16, 16, 16, 16, 12, 16, 13, 16, 11, 16, 12, 14,
- 12, 16, 13, 16, 11, 14, 12, 13, 16, 16, 16, 16, 14, 16, 14, 14,
- 15, 16, 14, 16, 16, 16, 13, 14, 13, 16, 13, 15, 14, 16, 13, 14,
- 14, 16, 13, 14, 14, 15, 13, 14, 9, 16, 11, 16, 12, 16, 13, 14,
- 12, 16, 12, 15, 13, 16, 13, 14, 16, 16, 16, 15, 16, 16, 15, 15,
- 10, 16, 10, 16, 12, 16, 12, 14, 12, 16, 12, 14, 13, 16, 13, 14,
- 16, 16, 16, 16, 16, 16, 15, 15, 11, 16, 10, 14, 14, 16, 12, 13,
- 14, 16, 12, 16, 14, 16, 13, 14, 16, 16, 16, 16, 16, 16, 16, 15,
- 10, 16, 12, 16, 11, 16, 12, 14, 13, 16, 12, 15, 13, 16, 13, 14,
- 16, 16, 16, 16, 16, 16, 16, 15, 10, 16, 11, 16, 12, 16, 12, 14,
- 12, 16, 12, 15, 13, 16, 13, 14, 16, 16, 16, 16, 16, 16, 14, 14,
- 11, 16, 10, 14, 14, 16, 12, 13, 13, 16, 11, 14, 14, 16, 12, 13,
- 16, 16, 15, 16, 16, 16, 14, 14, 12, 16, 13, 16, 11, 16, 12, 14,
- 15, 16, 14, 16, 13, 16, 13, 14, 16, 16, 16, 16, 16, 16, 14, 16,
- 12, 16, 13, 16, 12, 16, 12, 14, 13, 16, 13, 16, 12, 16, 12, 13,
- 16, 16, 16, 16, 16, 16, 14, 15, 13, 16, 13, 16, 14, 16, 12, 13,
- 13, 16, 13, 14, 14, 16, 12, 13, 16, 16, 14, 14, 14, 15, 13, 13,
- },
- {
- 0, 9, 3, 9, 5, 9, 7, 9, 5, 10, 7, 11, 8, 11, 9, 10,
- 16, 16, 16, 16, 16, 16, 16, 16, 2, 11, 4, 10, 7, 11, 8, 10,
- 7, 16, 7, 11, 9, 16, 9, 11, 16, 16, 16, 16, 16, 16, 16, 16,
- 8, 16, 7, 16, 11, 16, 10, 11, 11, 16, 10, 16, 16, 16, 11, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 2, 11, 6, 10, 6, 10, 8, 10,
- 7, 16, 8, 16, 8, 11, 9, 11, 16, 16, 16, 16, 16, 16, 16, 16,
- 5, 13, 7, 11, 8, 11, 9, 11, 6, 12, 8, 12, 8, 12, 9, 11,
- 16, 16, 16, 16, 16, 16, 16, 16, 10, 16, 10, 16, 12, 16, 10, 13,
- 10, 16, 9, 16, 11, 16, 11, 12, 16, 16, 16, 16, 16, 16, 16, 16,
- 8, 16, 10, 16, 8, 16, 10, 12, 11, 16, 12, 16, 10, 16, 11, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 10, 16, 11, 16, 10, 16, 11, 16,
- 11, 16, 12, 16, 10, 16, 11, 12, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- },
- {
- 1, 10, 5, 10, 6, 10, 9, 10, 7, 12, 9, 12, 9, 12, 10, 10,
- 16, 16, 15, 16, 14, 16, 13, 13, 5, 12, 7, 11, 8, 11, 9, 10,
- 8, 13, 9, 12, 10, 12, 10, 11, 16, 16, 16, 16, 14, 16, 13, 12,
- 10, 16, 10, 13, 12, 14, 12, 12, 12, 16, 11, 14, 13, 15, 12, 12,
- 16, 16, 16, 15, 16, 16, 14, 13, 5, 12, 8, 11, 7, 11, 9, 10,
- 8, 13, 10, 12, 9, 12, 10, 10, 15, 16, 14, 15, 14, 14, 13, 13,
- 7, 13, 9, 12, 9, 12, 10, 10, 9, 13, 10, 13, 10, 13, 10, 10,
- 14, 16, 14, 15, 14, 16, 13, 12, 11, 16, 12, 14, 12, 15, 12, 12,
- 12, 16, 12, 15, 13, 16, 12, 12, 16, 16, 15, 16, 16, 16, 14, 13,
- 10, 16, 12, 14, 10, 14, 12, 12, 12, 16, 13, 14, 11, 14, 12, 12,
- 16, 16, 16, 16, 14, 16, 14, 13, 11, 16, 12, 14, 11, 14, 12, 12,
- 12, 16, 13, 16, 11, 15, 12, 12, 16, 16, 16, 16, 14, 16, 14, 13,
- 13, 16, 14, 16, 14, 16, 13, 13, 13, 16, 13, 16, 13, 16, 13, 12,
- 16, 16, 16, 16, 16, 16, 13, 13, 4, 11, 7, 10, 7, 11, 9, 10,
- 8, 12, 9, 12, 9, 12, 10, 11, 15, 16, 14, 15, 14, 16, 13, 13,
- 6, 12, 7, 11, 8, 11, 9, 10, 9, 13, 9, 12, 10, 12, 10, 10,
- 16, 16, 15, 16, 15, 16, 13, 12, 10, 16, 10, 13, 12, 14, 12, 11,
- 12, 16, 11, 14, 13, 14, 12, 12, 16, 16, 16, 14, 16, 16, 14, 13,
- 6, 12, 8, 11, 7, 11, 9, 10, 9, 14, 10, 12, 9, 12, 10, 10,
- 15, 16, 14, 16, 14, 16, 14, 13, 7, 13, 9, 12, 9, 12, 10, 10,
- 9, 13, 9, 12, 9, 12, 10, 10, 14, 16, 13, 14, 14, 16, 12, 11,
- 11, 16, 11, 14, 12, 14, 12, 12, 12, 16, 11, 14, 12, 14, 12, 11,
- 16, 16, 13, 16, 14, 16, 13, 12, 10, 16, 12, 14, 10, 14, 11, 11,
- 12, 16, 13, 14, 11, 14, 12, 12, 16, 16, 16, 16, 14, 16, 13, 13,
- 11, 16, 12, 16, 11, 14, 12, 12, 12, 16, 12, 14, 11, 14, 12, 11,
- 16, 16, 15, 16, 13, 15, 13, 12, 13, 16, 14, 16, 13, 16, 13, 12,
- 13, 16, 13, 16, 13, 16, 13, 12, 16, 16, 14, 16, 14, 16, 12, 11,
- 8, 13, 10, 12, 10, 13, 11, 11, 11, 14, 12, 14, 12, 14, 12, 12,
- 16, 16, 16, 16, 16, 16, 14, 13, 9, 14, 10, 13, 10, 13, 11, 11,
- 12, 16, 12, 13, 12, 13, 12, 11, 16, 16, 16, 16, 16, 16, 15, 14,
- 12, 16, 11, 14, 13, 15, 12, 12, 13, 16, 12, 15, 14, 15, 13, 12,
- 16, 16, 16, 16, 16, 16, 15, 13, 9, 14, 11, 13, 10, 13, 11, 11,
- 11, 16, 12, 14, 12, 14, 12, 12, 16, 16, 16, 16, 16, 16, 16, 13,
- 10, 15, 11, 13, 11, 14, 12, 11, 11, 16, 12, 14, 11, 14, 12, 11,
- 16, 16, 16, 16, 16, 16, 14, 12, 12, 16, 12, 14, 13, 15, 13, 12,
- 12, 16, 12, 14, 13, 15, 12, 12, 16, 16, 14, 16, 16, 16, 14, 12,
- 12, 16, 13, 16, 11, 14, 12, 12, 14, 16, 14, 16, 12, 16, 13, 12,
- 16, 16, 16, 16, 16, 16, 16, 13, 12, 16, 13, 16, 12, 16, 13, 12,
- 12, 16, 13, 16, 12, 16, 12, 12, 16, 16, 16, 16, 14, 16, 14, 12,
- 14, 16, 14, 16, 14, 16, 14, 13, 13, 16, 13, 16, 13, 16, 13, 12,
- 16, 16, 13, 16, 13, 16, 12, 11, 9, 16, 12, 15, 13, 16, 13, 12,
- 13, 16, 14, 16, 14, 16, 14, 13, 16, 16, 16, 16, 16, 16, 16, 14,
- 10, 16, 12, 15, 12, 15, 13, 12, 13, 16, 14, 16, 13, 16, 13, 12,
- 16, 16, 16, 16, 16, 16, 16, 13, 12, 16, 12, 16, 13, 16, 13, 12,
- 14, 16, 13, 16, 14, 16, 13, 12, 16, 16, 16, 16, 16, 16, 16, 13,
- 11, 16, 12, 15, 12, 16, 13, 12, 14, 16, 14, 16, 13, 16, 13, 13,
- 16, 16, 16, 16, 16, 16, 15, 13, 11, 16, 12, 16, 12, 16, 13, 12,
- 13, 16, 13, 15, 13, 16, 13, 12, 16, 16, 16, 16, 16, 16, 15, 13,
- 12, 16, 12, 16, 13, 16, 13, 12, 13, 16, 12, 16, 13, 16, 13, 12,
- 16, 16, 14, 16, 16, 16, 14, 12, 12, 16, 14, 16, 11, 16, 13, 12,
- 14, 16, 14, 16, 13, 16, 13, 12, 16, 16, 16, 16, 16, 16, 16, 13,
- 12, 16, 13, 16, 12, 16, 13, 12, 13, 16, 13, 16, 12, 16, 13, 12,
- 16, 16, 16, 16, 14, 16, 14, 12, 13, 16, 13, 16, 13, 16, 13, 13,
- 13, 16, 12, 16, 12, 16, 12, 12, 14, 16, 13, 15, 13, 16, 12, 11,
- },
- },
-};
-
-
-static const uint8_t rv34_table_intra_secondpat[NUM_INTRA_TABLES][2][OTHERBLK_VLC_SIZE] = {
- {
- {
- 0, 5, 10, 3, 6, 10, 7, 8, 9, 4, 6, 10, 6, 7, 9, 8,
- 8, 9, 8, 8, 9, 8, 9, 9, 9, 9, 8, 3, 6, 10, 4, 6,
- 10, 7, 7, 9, 5, 7, 10, 6, 7, 9, 7, 7, 8, 7, 8, 9,
- 8, 8, 9, 8, 8, 7, 6, 8, 10, 6, 8, 10, 7, 8, 9, 7,
- 8, 10, 7, 8, 10, 8, 8, 8, 8, 9, 9, 8, 8, 9, 9, 8,
- 7, 7, 8, 9, 7, 8, 9, 7, 7, 7, 8, 8, 9, 7, 8, 9,
- 7, 7, 7, 8, 8, 8, 7, 7, 7, 7, 6, 5,
- },
- {
- 0, 5, 11, 3, 6, 11, 8, 9, 11, 3, 6, 10, 6, 7, 11, 9,
- 9, 11, 7, 9, 11, 9, 9, 11, 10, 10, 11, 2, 6, 10, 4, 7,
- 10, 7, 9, 11, 4, 7, 11, 6, 7, 10, 9, 9, 11, 7, 9, 11,
- 8, 9, 10, 10, 10, 10, 5, 8, 11, 6, 8, 11, 8, 9, 11, 6,
- 8, 11, 7, 8, 11, 9, 9, 11, 8, 10, 11, 9, 9, 11, 10, 10,
- 10, 8, 9, 11, 8, 9, 11, 9, 9, 10, 8, 9, 11, 8, 9, 11,
- 9, 9, 10, 8, 9, 10, 9, 9, 10, 9, 9, 8,
- },
- },
- {
- {
- 0, 5, 10, 4, 6, 10, 7, 8, 10, 4, 6, 10, 6, 7, 9, 8,
- 8, 9, 8, 8, 9, 8, 9, 9, 9, 9, 9, 2, 6, 10, 4, 6,
- 10, 7, 7, 9, 5, 7, 10, 6, 7, 9, 7, 7, 9, 7, 8, 9,
- 8, 8, 9, 9, 8, 8, 6, 8, 10, 6, 8, 10, 7, 8, 9, 6,
- 8, 10, 7, 8, 10, 8, 8, 9, 8, 9, 10, 8, 8, 9, 9, 9,
- 8, 8, 8, 10, 7, 8, 9, 7, 8, 8, 7, 8, 10, 7, 8, 9,
- 7, 7, 8, 8, 8, 9, 8, 8, 8, 7, 7, 6,
- },
- {
- 0, 5, 12, 4, 7, 12, 8, 10, 13, 4, 7, 12, 6, 8, 12, 10,
- 10, 12, 8, 9, 12, 10, 10, 12, 12, 12, 12, 1, 6, 12, 4, 7,
- 12, 8, 9, 12, 4, 7, 12, 6, 8, 11, 9, 10, 12, 8, 9, 12,
- 9, 10, 11, 11, 11, 12, 6, 8, 12, 7, 9, 12, 9, 10, 13, 6,
- 9, 12, 8, 9, 12, 10, 10, 12, 9, 10, 12, 10, 10, 12, 12, 12,
- 12, 8, 10, 12, 9, 10, 12, 10, 10, 12, 8, 10, 12, 9, 10, 12,
- 10, 10, 11, 9, 10, 12, 10, 10, 11, 11, 10, 10,
- },
- },
- {
- {
- 0, 5, 10, 3, 6, 10, 7, 8, 11, 4, 6, 10, 6, 7, 10, 8,
- 9, 10, 8, 8, 10, 9, 9, 10, 10, 10, 10, 2, 6, 10, 4, 6,
- 10, 7, 8, 10, 4, 7, 10, 6, 7, 10, 8, 8, 10, 7, 8, 10,
- 8, 8, 9, 10, 9, 9, 5, 8, 11, 6, 8, 10, 7, 9, 10, 6,
- 8, 11, 7, 8, 10, 8, 8, 10, 8, 9, 11, 9, 9, 10, 10, 9,
- 9, 8, 9, 10, 8, 9, 10, 8, 9, 10, 8, 9, 10, 8, 8, 10,
- 8, 8, 9, 8, 9, 10, 8, 8, 9, 9, 8, 8,
- },
- {
- 0, 6, 13, 4, 7, 14, 9, 11, 14, 3, 7, 13, 7, 8, 13, 11,
- 11, 14, 8, 10, 13, 10, 11, 13, 13, 13, 14, 1, 6, 12, 4, 8,
- 13, 9, 10, 15, 4, 8, 13, 7, 8, 12, 11, 11, 14, 8, 10, 13,
- 10, 10, 13, 13, 13, 14, 5, 9, 13, 7, 9, 13, 10, 11, 14, 6,
- 10, 14, 8, 10, 14, 11, 11, 14, 9, 11, 14, 11, 11, 13, 13, 13,
- 14, 9, 10, 14, 9, 11, 13, 11, 12, 14, 9, 11, 13, 9, 11, 14,
- 11, 12, 13, 10, 12, 15, 11, 11, 13, 13, 12, 13,
- },
- },
- {
- {
- 0, 5, 11, 3, 6, 11, 7, 9, 12, 3, 6, 11, 6, 7, 11, 9,
- 9, 11, 8, 9, 11, 9, 9, 11, 11, 11, 12, 2, 6, 11, 4, 6,
- 11, 7, 9, 11, 4, 7, 11, 5, 7, 10, 9, 9, 11, 7, 8, 11,
- 9, 9, 10, 11, 11, 11, 5, 8, 11, 6, 8, 11, 8, 9, 12, 6,
- 8, 11, 7, 8, 11, 9, 9, 11, 8, 9, 12, 9, 9, 11, 11, 11,
- 11, 8, 10, 12, 8, 10, 11, 9, 10, 12, 8, 10, 12, 8, 9, 12,
- 10, 10, 12, 9, 10, 12, 9, 9, 11, 11, 10, 11,
- },
- {
- 0, 6, 13, 3, 8, 14, 10, 12, 16, 3, 8, 15, 7, 9, 15, 12,
- 13, 15, 9, 11, 15, 11, 12, 16, 14, 16, 16, 1, 7, 13, 4, 8,
- 14, 9, 11, 15, 4, 8, 14, 7, 9, 14, 12, 13, 15, 8, 10, 14,
- 11, 11, 14, 16, 14, 16, 6, 9, 14, 7, 10, 14, 11, 13, 15, 7,
- 10, 14, 9, 10, 13, 12, 12, 15, 10, 11, 14, 11, 11, 14, 14, 14,
- 16, 9, 11, 14, 10, 11, 14, 13, 14, 15, 9, 12, 14, 10, 12, 16,
- 13, 14, 16, 10, 13, 16, 12, 12, 14, 15, 14, 15,
- },
- },
- {
- {
- 0, 6, 12, 3, 7, 12, 9, 11, 13, 4, 7, 12, 6, 8, 12, 10,
- 11, 13, 8, 10, 13, 10, 11, 13, 13, 13, 14, 1, 6, 12, 4, 7,
- 12, 9, 10, 14, 4, 7, 12, 6, 7, 12, 10, 11, 13, 8, 9, 13,
- 10, 10, 12, 13, 13, 14, 6, 9, 13, 7, 9, 13, 10, 12, 14, 7,
- 9, 13, 8, 10, 13, 11, 11, 14, 9, 11, 13, 11, 11, 14, 13, 13,
- 14, 10, 12, 14, 10, 12, 14, 12, 13, 15, 10, 12, 14, 10, 12, 14,
- 12, 13, 15, 11, 13, 15, 12, 12, 15, 14, 14, 14,
- },
- {
- 0, 6, 16, 3, 8, 16, 10, 13, 16, 3, 8, 16, 7, 9, 16, 13,
- 16, 16, 8, 10, 16, 11, 13, 16, 16, 16, 16, 1, 7, 14, 4, 8,
- 16, 10, 12, 16, 4, 8, 13, 7, 9, 16, 13, 14, 16, 8, 10, 16,
- 11, 11, 14, 16, 16, 16, 6, 9, 14, 8, 10, 14, 12, 16, 16, 6,
- 10, 13, 9, 11, 16, 13, 14, 16, 9, 12, 16, 12, 11, 16, 16, 16,
- 16, 10, 12, 16, 11, 12, 16, 16, 14, 16, 9, 12, 16, 11, 12, 16,
- 16, 15, 16, 10, 13, 16, 12, 13, 16, 16, 16, 16,
- },
- },
-};
-
-static const uint8_t rv34_table_intra_thirdpat[NUM_INTRA_TABLES][2][OTHERBLK_VLC_SIZE] = {
- {
- {
- 0, 5, 10, 3, 6, 10, 7, 8, 10, 4, 7, 10, 6, 7, 10, 8,
- 8, 10, 8, 9, 10, 9, 9, 10, 9, 9, 9, 2, 6, 10, 4, 7,
- 10, 7, 8, 9, 5, 7, 10, 6, 7, 10, 8, 8, 9, 8, 9, 10,
- 8, 8, 9, 9, 9, 8, 6, 8, 11, 6, 8, 10, 7, 8, 10, 6,
- 8, 11, 7, 8, 10, 8, 8, 9, 8, 9, 10, 9, 9, 10, 9, 9,
- 9, 7, 8, 10, 7, 8, 10, 7, 8, 8, 7, 8, 10, 7, 8, 9,
- 7, 8, 8, 8, 8, 9, 8, 8, 8, 7, 7, 7,
- },
- {
- 0, 4, 10, 3, 6, 10, 7, 8, 11, 3, 6, 10, 5, 7, 10, 9,
- 9, 11, 9, 10, 11, 9, 10, 11, 11, 11, 11, 2, 6, 10, 4, 6,
- 10, 7, 8, 10, 4, 7, 10, 6, 7, 10, 8, 9, 10, 8, 9, 11,
- 9, 9, 11, 10, 10, 11, 6, 8, 11, 6, 8, 11, 8, 9, 11, 7,
- 9, 11, 7, 8, 11, 9, 9, 11, 9, 10, 12, 10, 10, 12, 11, 11,
- 11, 8, 9, 11, 8, 9, 11, 9, 9, 11, 9, 10, 11, 9, 10, 11,
- 9, 10, 11, 10, 11, 12, 10, 10, 12, 10, 10, 10,
- },
- },
- {
- {
- 0, 5, 10, 3, 6, 10, 7, 8, 10, 4, 7, 10, 6, 7, 10, 8,
- 9, 10, 8, 9, 11, 8, 9, 10, 10, 10, 10, 2, 6, 10, 4, 6,
- 10, 7, 8, 10, 4, 7, 10, 5, 7, 10, 8, 8, 10, 8, 9, 10,
- 8, 9, 10, 9, 9, 9, 5, 7, 11, 6, 8, 11, 7, 8, 11, 6,
- 8, 11, 7, 8, 10, 8, 9, 10, 8, 9, 11, 9, 9, 10, 10, 9,
- 10, 7, 8, 10, 7, 8, 10, 8, 9, 10, 8, 9, 10, 8, 9, 10,
- 8, 8, 10, 9, 9, 10, 9, 9, 10, 9, 9, 9,
- },
- {
- 0, 5, 11, 3, 6, 11, 8, 9, 12, 4, 7, 12, 6, 7, 12, 9,
- 10, 13, 10, 11, 13, 10, 11, 14, 12, 13, 14, 1, 6, 11, 4, 7,
- 11, 8, 9, 12, 5, 7, 11, 6, 8, 12, 9, 10, 13, 10, 11, 14,
- 10, 11, 13, 12, 12, 14, 6, 8, 12, 7, 9, 13, 9, 10, 14, 7,
- 10, 13, 8, 10, 12, 11, 11, 13, 11, 13, 14, 11, 12, 14, 13, 13,
- 15, 9, 10, 12, 9, 11, 14, 10, 11, 14, 11, 11, 13, 10, 11, 13,
- 11, 12, 14, 12, 14, 15, 13, 13, 14, 13, 13, 14,
- },
- },
- {
- {
- 0, 5, 11, 3, 6, 11, 7, 9, 11, 4, 6, 11, 5, 7, 10, 9,
- 9, 11, 8, 9, 11, 9, 10, 11, 11, 11, 11, 2, 6, 10, 3, 6,
- 10, 7, 9, 11, 4, 7, 10, 5, 7, 10, 8, 9, 11, 8, 9, 11,
- 9, 9, 11, 11, 11, 11, 5, 8, 11, 6, 8, 11, 8, 10, 12, 6,
- 8, 11, 7, 8, 11, 9, 10, 11, 9, 10, 12, 9, 10, 11, 11, 11,
- 11, 8, 9, 11, 8, 10, 12, 9, 11, 12, 8, 10, 12, 9, 10, 12,
- 10, 11, 12, 10, 11, 12, 10, 10, 11, 11, 11, 11,
- },
- {
- 0, 5, 13, 2, 7, 16, 9, 11, 16, 4, 8, 16, 7, 9, 16, 12,
- 12, 16, 12, 16, 16, 12, 16, 16, 16, 16, 16, 1, 6, 13, 4, 8,
- 16, 9, 11, 16, 6, 9, 16, 7, 10, 16, 13, 13, 16, 13, 15, 16,
- 12, 16, 16, 16, 16, 16, 7, 9, 16, 8, 11, 15, 11, 13, 16, 10,
- 12, 16, 10, 12, 16, 16, 13, 16, 16, 16, 16, 14, 16, 16, 16, 16,
- 16, 12, 12, 16, 12, 16, 16, 16, 16, 16, 13, 14, 16, 12, 13, 16,
- 16, 16, 16, 16, 16, 16, 14, 16, 16, 16, 16, 16,
- },
- },
- {
- {
- 0, 6, 11, 3, 7, 11, 8, 10, 12, 4, 7, 11, 6, 8, 11, 10,
- 11, 12, 9, 10, 12, 10, 10, 12, 12, 12, 13, 1, 6, 11, 4, 7,
- 11, 8, 10, 12, 4, 7, 11, 6, 8, 11, 10, 10, 12, 9, 10, 12,
- 10, 10, 12, 13, 13, 13, 6, 8, 12, 7, 10, 12, 10, 12, 13, 7,
- 9, 12, 8, 10, 12, 11, 11, 13, 11, 12, 14, 11, 11, 13, 13, 13,
- 13, 9, 11, 13, 10, 12, 14, 12, 13, 15, 10, 12, 14, 11, 12, 14,
- 13, 13, 14, 12, 13, 15, 13, 13, 14, 14, 14, 14,
- },
- {
- 0, 5, 16, 2, 6, 16, 10, 14, 16, 4, 8, 16, 7, 9, 16, 11,
- 16, 16, 11, 16, 16, 16, 16, 16, 16, 16, 16, 1, 6, 12, 4, 8,
- 12, 12, 12, 16, 6, 8, 16, 8, 10, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 12, 16, 16, 7, 10, 16, 8, 11, 14, 16, 16, 16, 10,
- 12, 16, 10, 16, 16, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 12, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- },
- },
- {
- {
- 0, 5, 11, 3, 6, 11, 10, 10, 12, 3, 7, 11, 6, 8, 11, 11,
- 11, 12, 10, 10, 12, 11, 11, 13, 14, 13, 14, 1, 6, 11, 4, 7,
- 11, 10, 11, 13, 5, 7, 11, 7, 8, 11, 11, 11, 13, 10, 11, 13,
- 11, 11, 12, 13, 13, 14, 7, 10, 12, 9, 11, 13, 12, 13, 14, 9,
- 10, 13, 9, 10, 13, 12, 11, 13, 12, 13, 16, 12, 13, 13, 14, 14,
- 14, 11, 14, 16, 12, 14, 15, 14, 13, 16, 13, 13, 15, 13, 14, 16,
- 14, 13, 16, 13, 13, 16, 13, 14, 15, 15, 14, 15,
- },
- {
- 0, 4, 16, 2, 7, 16, 10, 16, 16, 4, 10, 16, 7, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 1, 6, 13, 4, 11,
- 16, 16, 16, 16, 6, 10, 16, 8, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 8, 16, 16, 10, 16, 16, 16, 16, 16, 10,
- 16, 16, 10, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- },
- },
-};
-
-
-static const uint8_t rv34_intra_coeff[NUM_INTRA_TABLES][COEFF_VLC_SIZE] = {
-{
- 1, 3, 3, 4, 4, 5, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9,
- 9, 9, 10, 10, 10, 11, 11, 11, 10, 10, 10, 12, 13, 14, 15, 15,
-},
-{
- 1, 2, 3, 5, 5, 6, 6, 7, 7, 8, 8, 9, 10, 10, 10, 11,
- 11, 11, 12, 12, 13, 13, 13, 13, 13, 13, 13, 14, 16, 16, 16, 16,
-},
-{
- 1, 2, 3, 4, 5, 6, 8, 8, 9, 9, 10, 10, 11, 12, 12, 12,
- 13, 13, 14, 14, 14, 14, 16, 16, 14, 16, 16, 16, 14, 16, 16, 16,
-},
-{
- 1, 2, 3, 4, 5, 6, 8, 8, 9, 9, 10, 10, 11, 12, 12, 12,
- 13, 13, 16, 16, 16, 16, 16, 16, 16, 16, 14, 12, 16, 16, 16, 16,
-},
-{
- 1, 2, 3, 4, 5, 7, 7, 8, 8, 9, 10, 10, 12, 11, 13, 12,
- 15, 13, 14, 13, 12, 15, 14, 13, 12, 12, 10, 11, 16, 16, 16, 16,
-}
-};
-
-
-static const uint8_t rv34_inter_cbppat[NUM_INTER_TABLES][CBPPAT_VLC_SIZE] = {
-{
- 7, 9, 9, 8, 9, 8, 9, 8, 9, 9, 8, 8, 8, 8, 8, 4,
- 7, 10, 11, 10, 11, 10, 12, 10, 12, 11, 11, 10, 11, 10, 10, 7,
- 10, 11, 15, 12, 15, 12, 15, 12, 15, 14, 14, 12, 14, 12, 14, 9,
- 7, 11, 10, 10, 12, 11, 11, 10, 11, 12, 10, 10, 11, 10, 10, 7,
- 8, 12, 12, 11, 13, 12, 12, 10, 13, 13, 12, 10, 12, 11, 11, 7,
- 11, 13, 15, 11, 15, 13, 15, 12, 16, 14, 14, 12, 15, 13, 13, 9,
- 10, 15, 11, 12, 15, 14, 14, 12, 15, 15, 12, 12, 14, 14, 12, 9,
- 11, 15, 13, 12, 16, 15, 14, 12, 15, 15, 13, 12, 15, 14, 13, 9,
- 13, 15, 14, 10, 16, 15, 16, 11, 16, 16, 15, 12, 16, 15, 15, 9,
- 7, 11, 11, 11, 11, 10, 11, 10, 11, 12, 11, 10, 10, 10, 10, 7,
- 9, 12, 13, 12, 12, 11, 13, 10, 13, 13, 12, 11, 12, 10, 11, 7,
- 12, 13, 16, 14, 15, 12, 16, 12, 16, 15, 15, 13, 15, 12, 14, 9,
- 9, 13, 13, 12, 13, 12, 13, 11, 13, 13, 12, 11, 12, 11, 11, 7,
- 9, 13, 13, 12, 13, 12, 13, 11, 13, 13, 13, 11, 12, 11, 11, 7,
- 12, 14, 15, 13, 16, 13, 15, 11, 16, 14, 15, 12, 15, 12, 13, 8,
- 12, 16, 14, 14, 16, 15, 15, 13, 16, 15, 14, 13, 15, 14, 13, 9,
- 12, 15, 14, 13, 15, 14, 15, 12, 16, 15, 14, 12, 14, 13, 13, 8,
- 13, 16, 16, 12, 16, 14, 16, 11, 16, 16, 15, 12, 16, 14, 14, 8,
- 10, 15, 15, 15, 12, 12, 14, 12, 14, 15, 15, 14, 12, 12, 13, 9,
- 11, 15, 16, 14, 13, 12, 15, 12, 16, 15, 15, 14, 14, 12, 13, 9,
- 14, 15, 16, 16, 15, 11, 16, 12, 16, 16, 16, 15, 16, 12, 15, 9,
- 12, 16, 16, 15, 14, 14, 14, 13, 16, 16, 15, 14, 14, 13, 13, 9,
- 12, 15, 15, 14, 14, 13, 15, 12, 16, 15, 14, 13, 14, 13, 13, 8,
- 13, 16, 16, 15, 16, 12, 16, 11, 16, 16, 16, 14, 16, 13, 14, 8,
- 14, 16, 16, 16, 16, 16, 15, 14, 16, 16, 16, 15, 16, 15, 14, 11,
- 13, 16, 16, 15, 16, 15, 15, 12, 16, 16, 16, 14, 15, 14, 14, 9,
- 14, 16, 16, 13, 16, 14, 16, 10, 16, 16, 16, 13, 16, 14, 14, 8,
- 7, 12, 11, 11, 11, 11, 12, 10, 11, 11, 10, 10, 10, 10, 10, 7,
- 9, 13, 13, 12, 13, 12, 13, 11, 13, 13, 12, 11, 12, 11, 11, 8,
- 12, 14, 16, 14, 16, 14, 16, 13, 16, 14, 15, 13, 15, 13, 14, 9,
- 9, 13, 12, 12, 13, 12, 13, 11, 12, 13, 11, 10, 12, 11, 11, 7,
- 9, 13, 13, 12, 13, 12, 13, 11, 13, 13, 12, 11, 12, 11, 11, 7,
- 12, 14, 16, 13, 16, 14, 15, 12, 15, 15, 14, 12, 15, 13, 13, 8,
- 11, 15, 13, 14, 15, 15, 14, 13, 15, 15, 12, 12, 14, 14, 12, 9,
- 11, 15, 14, 13, 15, 14, 14, 12, 15, 14, 13, 11, 14, 13, 12, 8,
- 13, 16, 15, 12, 16, 15, 16, 12, 16, 16, 14, 11, 15, 14, 14, 8,
- 8, 13, 13, 12, 12, 12, 13, 11, 12, 13, 12, 11, 11, 10, 10, 7,
- 9, 13, 14, 12, 13, 12, 13, 11, 13, 13, 13, 11, 12, 11, 11, 7,
- 12, 14, 16, 14, 15, 13, 15, 12, 15, 15, 15, 13, 14, 12, 13, 8,
- 9, 13, 13, 12, 13, 12, 13, 11, 13, 13, 12, 11, 12, 11, 11, 7,
- 9, 13, 12, 12, 13, 12, 12, 10, 13, 13, 12, 10, 12, 10, 10, 6,
- 11, 14, 14, 12, 14, 12, 14, 11, 14, 14, 13, 11, 13, 11, 12, 7,
- 12, 16, 14, 14, 15, 15, 14, 13, 15, 15, 13, 12, 14, 13, 12, 8,
- 11, 14, 13, 12, 14, 13, 13, 11, 14, 14, 13, 11, 13, 12, 11, 7,
- 11, 14, 14, 12, 15, 13, 14, 11, 15, 14, 13, 11, 14, 12, 12, 6,
- 11, 16, 15, 15, 13, 14, 15, 13, 14, 15, 15, 13, 12, 12, 12, 9,
- 12, 15, 15, 14, 14, 13, 15, 12, 15, 15, 14, 13, 13, 11, 12, 8,
- 13, 16, 16, 15, 16, 13, 16, 13, 16, 16, 15, 14, 14, 12, 14, 8,
- 11, 16, 15, 14, 14, 14, 14, 13, 15, 15, 14, 13, 13, 12, 12, 8,
- 11, 14, 14, 13, 13, 12, 14, 11, 14, 14, 13, 12, 12, 11, 11, 7,
- 12, 14, 15, 13, 14, 12, 14, 11, 15, 14, 14, 12, 13, 11, 12, 7,
- 13, 16, 16, 16, 16, 15, 16, 14, 16, 16, 15, 14, 15, 14, 13, 9,
- 12, 15, 14, 13, 15, 13, 14, 12, 15, 15, 13, 12, 13, 12, 12, 7,
- 11, 15, 14, 12, 14, 13, 14, 10, 15, 14, 13, 11, 13, 11, 11, 5,
- 10, 15, 15, 15, 15, 14, 15, 13, 12, 14, 12, 12, 12, 13, 12, 9,
- 12, 16, 16, 15, 16, 15, 16, 14, 14, 15, 14, 13, 14, 13, 13, 9,
- 14, 16, 16, 16, 16, 16, 16, 15, 16, 16, 16, 14, 16, 14, 15, 11,
- 11, 15, 15, 14, 15, 15, 15, 14, 14, 15, 12, 12, 13, 13, 12, 9,
- 12, 15, 15, 14, 16, 14, 15, 13, 14, 14, 13, 12, 14, 13, 12, 8,
- 13, 16, 16, 15, 16, 16, 16, 14, 16, 16, 15, 12, 16, 14, 14, 9,
- 13, 16, 14, 16, 16, 16, 16, 15, 15, 16, 11, 12, 16, 15, 12, 9,
- 13, 16, 15, 14, 16, 15, 16, 14, 15, 16, 12, 11, 15, 14, 13, 8,
- 13, 16, 16, 13, 16, 16, 16, 13, 16, 16, 13, 11, 16, 14, 14, 8,
- 11, 15, 15, 15, 14, 14, 15, 13, 13, 15, 14, 13, 12, 12, 12, 9,
- 11, 15, 16, 14, 15, 14, 15, 13, 14, 14, 14, 13, 13, 12, 13, 8,
- 13, 16, 16, 16, 16, 15, 16, 14, 16, 16, 16, 13, 15, 12, 14, 9,
- 11, 16, 15, 14, 14, 14, 15, 13, 14, 14, 13, 12, 13, 12, 11, 8,
- 11, 14, 14, 13, 14, 13, 14, 12, 13, 13, 12, 11, 12, 11, 11, 7,
- 12, 15, 15, 13, 15, 14, 15, 12, 15, 14, 14, 11, 13, 12, 12, 7,
- 13, 16, 15, 15, 16, 16, 16, 14, 15, 16, 12, 12, 14, 14, 12, 8,
- 11, 15, 14, 13, 15, 13, 14, 12, 14, 14, 12, 11, 13, 12, 11, 6,
- 11, 14, 14, 12, 15, 13, 14, 11, 15, 14, 12, 10, 13, 11, 11, 5,
- 12, 16, 16, 16, 15, 15, 16, 15, 14, 16, 15, 15, 10, 12, 12, 9,
- 13, 16, 16, 16, 15, 14, 16, 13, 15, 15, 15, 14, 12, 11, 13, 8,
- 14, 16, 16, 16, 16, 14, 16, 13, 16, 16, 16, 14, 14, 11, 14, 8,
- 13, 16, 16, 15, 15, 15, 15, 14, 15, 16, 14, 13, 12, 12, 11, 8,
- 11, 15, 15, 13, 14, 13, 14, 12, 14, 14, 13, 12, 12, 11, 11, 6,
- 11, 15, 15, 13, 15, 12, 14, 11, 14, 14, 13, 11, 12, 10, 11, 5,
- 13, 16, 16, 15, 16, 16, 16, 14, 16, 16, 14, 14, 14, 13, 11, 8,
- 11, 14, 14, 13, 14, 13, 14, 11, 14, 14, 12, 11, 12, 11, 10, 5,
- 10, 13, 13, 11, 13, 12, 13, 9, 13, 13, 12, 9, 12, 10, 10, 3,
-},
-{
- 5, 7, 7, 7, 7, 7, 8, 7, 7, 8, 7, 7, 7, 7, 7, 4,
- 7, 9, 11, 9, 11, 9, 11, 9, 11, 10, 10, 9, 10, 9, 10, 6,
- 11, 11, 14, 11, 14, 11, 14, 11, 15, 13, 14, 12, 14, 12, 13, 9,
- 6, 11, 10, 9, 11, 10, 11, 9, 11, 11, 9, 9, 10, 10, 9, 6,
- 8, 11, 11, 10, 12, 11, 12, 10, 12, 12, 11, 10, 12, 11, 11, 7,
- 11, 13, 14, 11, 15, 13, 15, 11, 15, 14, 14, 12, 14, 13, 13, 9,
- 10, 14, 11, 11, 15, 14, 13, 12, 14, 14, 11, 11, 14, 13, 12, 9,
- 11, 14, 13, 11, 15, 14, 14, 11, 15, 15, 13, 11, 14, 14, 13, 9,
- 12, 14, 14, 10, 16, 15, 16, 11, 16, 16, 15, 11, 16, 15, 14, 9,
- 6, 10, 11, 10, 10, 9, 11, 9, 10, 11, 10, 10, 9, 9, 9, 6,
- 9, 12, 12, 11, 12, 10, 12, 10, 12, 12, 12, 11, 11, 10, 11, 7,
- 12, 13, 15, 13, 14, 11, 15, 11, 15, 15, 14, 13, 14, 12, 14, 9,
- 9, 12, 12, 11, 12, 11, 12, 11, 12, 13, 11, 11, 12, 11, 11, 7,
- 9, 12, 12, 11, 13, 11, 12, 10, 13, 13, 12, 11, 12, 11, 11, 7,
- 12, 14, 15, 12, 15, 12, 14, 11, 15, 15, 14, 12, 14, 13, 13, 8,
- 12, 15, 14, 13, 15, 14, 14, 13, 16, 16, 14, 13, 15, 14, 13, 9,
- 12, 15, 14, 13, 15, 14, 14, 12, 15, 15, 13, 12, 14, 13, 13, 9,
- 13, 15, 15, 12, 16, 14, 15, 11, 16, 16, 15, 12, 15, 14, 14, 9,
- 10, 14, 14, 14, 12, 11, 13, 12, 14, 15, 14, 13, 12, 11, 12, 9,
- 12, 14, 15, 14, 13, 11, 14, 12, 15, 15, 15, 14, 13, 11, 13, 9,
- 13, 15, 16, 15, 14, 11, 16, 11, 16, 16, 16, 14, 15, 12, 15, 9,
- 12, 15, 15, 14, 14, 14, 14, 13, 15, 15, 14, 14, 14, 13, 13, 9,
- 12, 15, 15, 14, 14, 13, 14, 12, 15, 15, 14, 13, 14, 13, 13, 9,
- 13, 15, 16, 14, 15, 13, 16, 11, 16, 16, 15, 14, 15, 13, 14, 9,
- 14, 16, 16, 16, 16, 16, 15, 14, 16, 16, 16, 16, 16, 16, 14, 11,
- 14, 16, 16, 14, 16, 15, 15, 12, 16, 16, 16, 14, 15, 14, 14, 9,
- 14, 16, 16, 14, 16, 14, 16, 11, 16, 16, 16, 14, 16, 14, 14, 9,
- 6, 11, 10, 10, 10, 10, 11, 10, 10, 11, 9, 9, 9, 9, 9, 6,
- 9, 12, 12, 11, 13, 11, 13, 11, 12, 12, 11, 11, 12, 11, 11, 7,
- 12, 14, 16, 13, 16, 14, 16, 13, 15, 14, 15, 12, 15, 13, 14, 9,
- 8, 12, 11, 11, 12, 12, 12, 11, 11, 12, 10, 10, 11, 11, 10, 7,
- 9, 12, 12, 11, 13, 12, 13, 11, 13, 12, 11, 10, 12, 11, 11, 7,
- 12, 14, 15, 12, 15, 14, 15, 12, 15, 14, 14, 12, 14, 13, 13, 9,
- 11, 15, 13, 13, 15, 14, 14, 13, 14, 15, 11, 11, 14, 14, 12, 9,
- 11, 14, 13, 12, 15, 14, 14, 12, 14, 14, 12, 11, 14, 13, 12, 8,
- 13, 15, 15, 12, 16, 15, 15, 12, 15, 15, 14, 11, 15, 14, 14, 8,
- 8, 12, 12, 11, 11, 11, 12, 11, 11, 12, 11, 11, 10, 10, 10, 7,
- 9, 13, 13, 12, 13, 11, 13, 11, 12, 13, 12, 11, 11, 10, 11, 7,
- 12, 14, 15, 14, 15, 13, 15, 12, 15, 14, 14, 13, 14, 12, 13, 9,
- 9, 13, 12, 12, 12, 12, 12, 11, 12, 13, 11, 11, 11, 11, 10, 7,
- 9, 12, 12, 11, 12, 11, 12, 10, 12, 12, 11, 10, 11, 10, 10, 7,
- 11, 13, 14, 12, 14, 12, 14, 11, 14, 13, 13, 11, 13, 11, 12, 7,
- 12, 15, 14, 13, 15, 14, 14, 13, 15, 15, 13, 12, 13, 13, 12, 9,
- 11, 14, 13, 12, 14, 13, 13, 11, 14, 14, 12, 11, 13, 12, 11, 7,
- 11, 14, 14, 12, 14, 13, 14, 11, 14, 14, 13, 11, 13, 12, 12, 7,
- 11, 15, 15, 14, 13, 13, 14, 13, 14, 15, 14, 13, 11, 11, 12, 9,
- 12, 15, 15, 14, 14, 12, 14, 12, 14, 14, 14, 13, 12, 11, 12, 8,
- 13, 16, 16, 15, 15, 12, 16, 13, 16, 15, 15, 14, 14, 12, 14, 9,
- 12, 15, 15, 14, 14, 14, 14, 13, 15, 15, 14, 13, 12, 12, 12, 9,
- 11, 14, 14, 13, 13, 12, 13, 11, 14, 13, 13, 12, 12, 11, 11, 7,
- 12, 14, 15, 13, 14, 12, 14, 11, 15, 14, 13, 12, 13, 11, 12, 7,
- 13, 16, 16, 15, 16, 15, 15, 14, 16, 16, 15, 14, 14, 14, 12, 9,
- 12, 15, 14, 13, 14, 13, 14, 12, 15, 14, 13, 12, 13, 12, 12, 8,
- 12, 14, 14, 13, 15, 13, 14, 11, 14, 14, 13, 12, 13, 12, 12, 6,
- 10, 14, 14, 13, 14, 14, 14, 13, 12, 13, 12, 12, 12, 12, 11, 9,
- 12, 15, 15, 14, 15, 14, 16, 14, 14, 14, 13, 12, 14, 13, 13, 9,
- 14, 16, 16, 16, 16, 16, 16, 15, 16, 16, 16, 14, 16, 14, 16, 11,
- 11, 15, 14, 14, 15, 14, 14, 14, 13, 14, 11, 12, 13, 13, 12, 9,
- 12, 15, 14, 14, 15, 14, 15, 13, 14, 14, 13, 12, 14, 13, 13, 9,
- 13, 16, 16, 14, 16, 15, 16, 14, 16, 15, 15, 12, 16, 14, 14, 9,
- 13, 16, 14, 15, 16, 16, 16, 14, 14, 16, 11, 12, 15, 14, 12, 9,
- 13, 16, 15, 14, 16, 15, 16, 14, 15, 15, 12, 11, 15, 14, 13, 9,
- 14, 16, 16, 13, 16, 16, 16, 14, 16, 15, 13, 11, 16, 14, 14, 9,
- 11, 15, 15, 14, 14, 14, 14, 13, 13, 14, 13, 13, 11, 11, 11, 9,
- 12, 15, 15, 14, 15, 14, 15, 13, 14, 14, 13, 13, 13, 12, 12, 9,
- 13, 16, 16, 16, 16, 14, 16, 14, 16, 15, 16, 14, 15, 12, 14, 9,
- 11, 15, 14, 14, 15, 14, 14, 13, 14, 14, 12, 12, 12, 12, 11, 8,
- 11, 14, 14, 13, 14, 13, 13, 12, 13, 13, 12, 11, 12, 11, 11, 7,
- 12, 14, 15, 13, 15, 13, 14, 13, 14, 14, 13, 12, 13, 12, 12, 8,
- 13, 16, 15, 15, 16, 15, 15, 14, 15, 16, 12, 12, 14, 14, 11, 9,
- 12, 15, 14, 13, 15, 13, 14, 12, 14, 14, 12, 11, 13, 12, 11, 7,
- 12, 14, 14, 13, 15, 13, 14, 12, 15, 14, 13, 10, 13, 12, 12, 6,
- 12, 16, 16, 15, 14, 14, 15, 14, 13, 15, 14, 14, 10, 11, 11, 9,
- 13, 16, 16, 15, 15, 14, 15, 14, 15, 15, 15, 14, 12, 11, 12, 8,
- 14, 16, 16, 16, 16, 14, 16, 14, 16, 15, 15, 14, 14, 11, 14, 8,
- 12, 16, 16, 15, 15, 14, 15, 14, 14, 16, 14, 14, 12, 12, 11, 8,
- 11, 14, 14, 13, 14, 13, 14, 12, 14, 14, 13, 12, 12, 11, 11, 7,
- 12, 14, 15, 13, 14, 13, 14, 12, 14, 14, 13, 12, 13, 11, 12, 6,
- 14, 16, 16, 16, 16, 16, 15, 14, 16, 16, 14, 13, 13, 13, 11, 8,
- 12, 15, 15, 13, 15, 13, 14, 12, 14, 14, 13, 12, 13, 12, 10, 6,
- 11, 14, 13, 12, 14, 12, 13, 10, 14, 13, 12, 10, 12, 10, 10, 4,
-},
-{
- 4, 6, 6, 6, 6, 6, 7, 6, 6, 7, 6, 6, 6, 6, 6, 3,
- 6, 9, 10, 9, 10, 9, 11, 9, 10, 10, 10, 9, 10, 9, 10, 6,
- 10, 11, 14, 11, 14, 11, 14, 11, 14, 13, 14, 11, 14, 11, 13, 9,
- 6, 10, 9, 9, 10, 10, 10, 9, 10, 11, 9, 9, 10, 10, 9, 6,
- 8, 11, 11, 9, 12, 11, 12, 10, 12, 12, 11, 10, 12, 11, 11, 7,
- 11, 13, 14, 11, 15, 13, 15, 11, 15, 14, 14, 11, 15, 13, 14, 9,
- 10, 13, 11, 11, 14, 14, 13, 11, 14, 14, 11, 11, 13, 13, 11, 9,
- 11, 14, 12, 11, 15, 14, 14, 11, 15, 15, 13, 11, 14, 14, 13, 9,
- 12, 14, 13, 10, 16, 15, 16, 11, 16, 16, 14, 11, 16, 14, 14, 9,
- 6, 10, 10, 10, 9, 9, 10, 9, 10, 11, 10, 10, 9, 9, 9, 6,
- 8, 11, 12, 11, 11, 10, 12, 10, 12, 12, 12, 11, 11, 10, 11, 7,
- 11, 13, 15, 13, 14, 11, 15, 11, 15, 14, 14, 13, 14, 12, 14, 9,
- 8, 12, 12, 12, 12, 12, 12, 11, 12, 13, 11, 11, 11, 11, 11, 8,
- 9, 12, 12, 11, 12, 12, 13, 11, 13, 13, 12, 11, 12, 11, 11, 8,
- 11, 14, 15, 13, 14, 13, 15, 11, 15, 15, 14, 13, 15, 13, 14, 9,
- 12, 16, 14, 14, 15, 15, 14, 12, 15, 16, 14, 13, 14, 14, 13, 10,
- 11, 15, 14, 13, 15, 14, 15, 12, 15, 16, 14, 13, 15, 14, 13, 9,
- 13, 15, 15, 12, 16, 15, 16, 12, 16, 16, 15, 13, 15, 14, 14, 9,
- 10, 14, 14, 14, 11, 11, 13, 11, 14, 14, 14, 13, 11, 11, 11, 9,
- 11, 14, 15, 14, 13, 11, 14, 12, 15, 15, 15, 14, 13, 11, 13, 9,
- 13, 14, 16, 15, 14, 11, 16, 12, 16, 16, 16, 14, 15, 12, 15, 10,
- 12, 16, 15, 15, 14, 14, 14, 12, 16, 16, 14, 14, 14, 13, 13, 10,
- 12, 15, 15, 14, 14, 13, 14, 12, 15, 16, 14, 14, 14, 13, 13, 9,
- 13, 16, 16, 14, 16, 13, 16, 12, 16, 16, 16, 14, 16, 13, 15, 10,
- 14, 16, 16, 16, 16, 16, 15, 14, 16, 16, 16, 16, 16, 16, 14, 11,
- 13, 16, 16, 15, 16, 16, 16, 13, 16, 16, 16, 15, 16, 15, 14, 10,
- 14, 16, 16, 14, 16, 14, 16, 12, 16, 16, 16, 15, 16, 15, 15, 10,
- 6, 10, 10, 10, 10, 10, 11, 10, 9, 10, 9, 9, 9, 9, 9, 6,
- 9, 12, 12, 11, 12, 11, 13, 11, 12, 12, 11, 10, 12, 11, 11, 8,
- 12, 14, 15, 14, 15, 14, 16, 13, 15, 14, 14, 12, 15, 13, 14, 10,
- 8, 12, 11, 11, 12, 12, 12, 11, 11, 12, 10, 10, 11, 11, 10, 7,
- 9, 12, 12, 11, 13, 12, 13, 11, 12, 13, 11, 10, 12, 12, 11, 8,
- 11, 14, 14, 13, 15, 14, 15, 13, 15, 14, 14, 12, 15, 13, 14, 9,
- 11, 15, 12, 13, 15, 15, 14, 13, 14, 15, 11, 11, 14, 14, 12, 9,
- 11, 14, 13, 13, 15, 14, 15, 13, 15, 15, 13, 11, 15, 14, 13, 9,
- 13, 15, 15, 12, 16, 15, 16, 13, 16, 15, 14, 11, 16, 15, 14, 9,
- 8, 12, 12, 11, 11, 11, 12, 11, 11, 12, 11, 11, 9, 10, 10, 7,
- 9, 12, 13, 12, 12, 11, 13, 11, 12, 13, 12, 12, 11, 11, 11, 8,
- 12, 14, 15, 14, 15, 13, 16, 13, 15, 14, 15, 13, 14, 12, 14, 9,
- 9, 13, 12, 12, 12, 12, 13, 12, 12, 13, 11, 11, 11, 11, 10, 8,
- 9, 12, 12, 12, 12, 12, 13, 11, 12, 13, 11, 11, 12, 11, 11, 7,
- 11, 13, 14, 13, 14, 13, 15, 12, 14, 14, 14, 12, 14, 12, 13, 8,
- 12, 15, 14, 14, 15, 15, 14, 13, 15, 16, 13, 13, 14, 14, 12, 9,
- 11, 14, 13, 13, 14, 14, 14, 12, 14, 15, 13, 12, 14, 13, 12, 8,
- 11, 14, 14, 13, 15, 14, 15, 12, 15, 15, 14, 12, 14, 13, 13, 8,
- 11, 14, 14, 14, 13, 13, 14, 13, 13, 14, 14, 13, 11, 11, 11, 9,
- 11, 15, 15, 14, 14, 13, 15, 13, 14, 15, 14, 14, 13, 11, 13, 9,
- 13, 16, 16, 16, 15, 13, 16, 13, 16, 16, 16, 15, 15, 12, 15, 10,
- 11, 15, 15, 15, 14, 14, 14, 13, 15, 15, 14, 14, 13, 13, 12, 9,
- 11, 14, 14, 13, 13, 13, 14, 12, 14, 14, 13, 13, 13, 12, 12, 8,
- 12, 15, 15, 14, 15, 13, 15, 12, 15, 15, 14, 13, 14, 12, 13, 8,
- 13, 16, 16, 16, 16, 16, 16, 14, 16, 16, 15, 15, 15, 15, 13, 10,
- 12, 15, 15, 14, 15, 14, 15, 13, 15, 16, 14, 13, 14, 14, 13, 9,
- 12, 15, 15, 14, 15, 14, 15, 12, 15, 15, 14, 13, 14, 13, 13, 8,
- 10, 14, 13, 13, 14, 13, 14, 13, 11, 13, 11, 11, 11, 11, 11, 9,
- 12, 15, 16, 14, 15, 14, 16, 14, 14, 14, 14, 13, 14, 13, 13, 10,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 15, 16, 13, 16, 14, 16, 11,
- 11, 15, 14, 14, 15, 14, 15, 14, 13, 14, 11, 12, 13, 13, 11, 9,
- 12, 15, 15, 14, 15, 15, 16, 14, 14, 14, 13, 12, 14, 13, 13, 9,
- 13, 16, 16, 15, 16, 16, 16, 15, 16, 15, 15, 12, 16, 14, 15, 10,
- 12, 16, 14, 15, 16, 16, 16, 14, 14, 16, 11, 12, 14, 15, 12, 9,
- 13, 16, 15, 14, 16, 16, 16, 14, 15, 16, 13, 12, 15, 15, 13, 9,
- 14, 16, 16, 14, 16, 16, 16, 15, 16, 16, 14, 12, 16, 15, 15, 10,
- 11, 14, 14, 14, 14, 14, 14, 13, 12, 14, 13, 13, 11, 11, 11, 9,
- 11, 15, 15, 14, 14, 14, 16, 14, 14, 14, 14, 13, 13, 12, 13, 9,
- 13, 16, 16, 16, 16, 15, 16, 15, 16, 15, 16, 14, 15, 13, 15, 10,
- 11, 15, 15, 14, 14, 14, 15, 14, 14, 15, 13, 13, 12, 13, 11, 9,
- 11, 14, 14, 13, 14, 14, 14, 13, 13, 14, 13, 12, 13, 12, 12, 8,
- 12, 15, 15, 14, 16, 14, 16, 14, 15, 15, 15, 13, 14, 13, 14, 9,
- 13, 16, 15, 16, 16, 16, 16, 15, 15, 16, 13, 13, 14, 14, 12, 9,
- 12, 15, 14, 14, 15, 15, 15, 13, 14, 15, 13, 12, 14, 13, 12, 8,
- 12, 15, 14, 14, 15, 15, 15, 13, 15, 15, 14, 12, 14, 13, 13, 8,
- 12, 16, 15, 15, 13, 14, 15, 14, 13, 15, 14, 14, 10, 11, 11, 9,
- 12, 16, 16, 15, 15, 14, 16, 14, 15, 15, 15, 14, 13, 12, 13, 9,
- 14, 16, 16, 16, 16, 14, 16, 15, 16, 15, 16, 15, 14, 12, 15, 10,
- 12, 16, 15, 15, 15, 15, 15, 14, 15, 16, 14, 14, 12, 13, 11, 9,
- 11, 15, 15, 14, 14, 14, 15, 13, 14, 15, 14, 13, 13, 12, 12, 8,
- 12, 15, 15, 14, 15, 14, 15, 13, 15, 15, 14, 13, 14, 12, 13, 8,
- 14, 16, 16, 16, 16, 16, 16, 15, 16, 16, 14, 14, 14, 14, 11, 9,
- 12, 15, 15, 14, 15, 15, 15, 13, 15, 15, 14, 13, 14, 13, 12, 8,
- 11, 14, 14, 13, 14, 13, 14, 12, 13, 14, 13, 12, 13, 12, 12, 7,
-},
-{
- 2, 6, 6, 5, 6, 6, 7, 6, 6, 7, 6, 6, 6, 6, 6, 3,
- 6, 9, 10, 9, 10, 9, 11, 9, 10, 10, 10, 9, 10, 9, 10, 7,
- 10, 11, 14, 11, 14, 11, 14, 11, 14, 13, 14, 12, 14, 12, 13, 9,
- 6, 10, 9, 9, 10, 10, 10, 9, 10, 11, 9, 9, 10, 10, 9, 7,
- 8, 11, 11, 9, 12, 11, 12, 10, 12, 12, 11, 10, 12, 11, 11, 8,
- 11, 13, 14, 11, 16, 13, 15, 12, 16, 14, 14, 12, 15, 13, 14, 10,
- 10, 13, 11, 11, 14, 14, 13, 11, 13, 14, 11, 11, 13, 13, 11, 9,
- 11, 13, 13, 11, 15, 14, 14, 12, 15, 15, 13, 12, 15, 14, 13, 10,
- 12, 14, 14, 11, 16, 15, 16, 12, 16, 16, 15, 12, 16, 15, 15, 10,
- 6, 10, 10, 10, 9, 9, 10, 9, 10, 11, 10, 10, 9, 9, 9, 7,
- 8, 11, 12, 11, 11, 10, 12, 10, 12, 12, 12, 11, 11, 10, 11, 8,
- 12, 13, 16, 13, 14, 11, 16, 12, 16, 15, 15, 13, 14, 12, 14, 10,
- 9, 13, 12, 12, 12, 12, 12, 11, 13, 13, 12, 12, 12, 12, 11, 8,
- 10, 13, 13, 12, 13, 12, 13, 11, 14, 14, 13, 12, 13, 12, 12, 9,
- 12, 14, 16, 13, 15, 13, 15, 12, 16, 16, 16, 13, 16, 14, 14, 10,
- 12, 16, 14, 14, 16, 15, 14, 13, 16, 16, 14, 14, 15, 15, 13, 11,
- 12, 16, 15, 14, 16, 15, 15, 12, 16, 16, 15, 14, 16, 15, 14, 10,
- 14, 16, 16, 14, 16, 15, 16, 13, 16, 16, 16, 14, 16, 16, 15, 11,
- 10, 14, 14, 13, 11, 11, 13, 12, 14, 14, 13, 13, 11, 11, 12, 9,
- 12, 14, 16, 14, 13, 11, 14, 12, 16, 15, 15, 14, 14, 12, 13, 10,
- 13, 14, 16, 15, 14, 11, 16, 12, 16, 16, 16, 15, 16, 13, 15, 11,
- 12, 16, 15, 15, 14, 14, 14, 13, 16, 16, 15, 15, 14, 14, 13, 11,
- 13, 16, 16, 15, 14, 14, 15, 13, 16, 16, 16, 15, 15, 14, 14, 11,
- 14, 16, 16, 15, 16, 14, 16, 13, 16, 16, 16, 15, 16, 14, 15, 11,
- 15, 16, 16, 16, 16, 16, 16, 14, 16, 16, 16, 16, 16, 16, 14, 12,
- 15, 16, 16, 16, 16, 16, 16, 13, 16, 16, 16, 16, 16, 16, 15, 12,
- 15, 16, 16, 15, 16, 15, 16, 13, 16, 16, 16, 16, 16, 16, 16, 11,
- 6, 10, 10, 10, 10, 10, 11, 10, 9, 10, 9, 9, 9, 9, 9, 7,
- 9, 12, 13, 12, 13, 12, 14, 12, 12, 12, 12, 11, 12, 11, 11, 8,
- 12, 14, 16, 14, 16, 14, 16, 14, 15, 14, 15, 13, 16, 13, 14, 11,
- 8, 12, 11, 11, 12, 12, 12, 11, 11, 12, 10, 10, 11, 11, 10, 8,
- 10, 13, 13, 12, 14, 13, 14, 12, 13, 13, 12, 11, 13, 12, 12, 9,
- 12, 15, 15, 13, 16, 15, 16, 14, 16, 15, 15, 12, 16, 14, 15, 10,
- 11, 15, 13, 13, 16, 15, 14, 13, 14, 15, 11, 12, 14, 14, 12, 10,
- 12, 16, 14, 13, 16, 16, 16, 14, 16, 15, 13, 12, 15, 15, 14, 10,
- 14, 16, 16, 14, 16, 16, 16, 14, 16, 16, 15, 13, 16, 16, 15, 11,
- 8, 12, 12, 12, 11, 11, 12, 11, 11, 12, 11, 11, 9, 10, 10, 8,
- 10, 13, 14, 13, 13, 12, 14, 12, 13, 13, 13, 12, 12, 11, 12, 9,
- 13, 15, 16, 15, 16, 14, 16, 14, 16, 15, 16, 14, 15, 13, 15, 11,
- 10, 13, 13, 13, 13, 13, 13, 12, 13, 14, 12, 12, 12, 12, 11, 9,
- 10, 13, 13, 13, 13, 13, 14, 12, 13, 14, 13, 12, 12, 12, 12, 9,
- 12, 15, 15, 14, 16, 14, 16, 13, 16, 15, 15, 13, 15, 13, 14, 10,
- 13, 16, 15, 15, 16, 16, 15, 14, 16, 16, 13, 14, 15, 15, 12, 10,
- 12, 16, 14, 14, 16, 16, 15, 13, 16, 16, 14, 13, 15, 14, 13, 10,
- 13, 16, 16, 14, 16, 15, 16, 13, 16, 16, 16, 13, 16, 15, 15, 10,
- 11, 15, 15, 14, 13, 13, 14, 13, 13, 15, 14, 14, 11, 12, 12, 10,
- 12, 15, 16, 15, 14, 13, 16, 14, 16, 15, 16, 14, 13, 12, 13, 10,
- 14, 16, 16, 16, 16, 14, 16, 14, 16, 16, 16, 16, 16, 13, 16, 11,
- 12, 16, 16, 16, 15, 15, 15, 14, 15, 16, 14, 14, 13, 14, 12, 10,
- 12, 16, 16, 15, 15, 14, 16, 13, 16, 16, 15, 14, 14, 13, 13, 10,
- 13, 16, 16, 15, 16, 14, 16, 13, 16, 16, 16, 15, 16, 14, 15, 10,
- 15, 16, 16, 16, 16, 16, 16, 15, 16, 16, 16, 16, 16, 16, 13, 12,
- 14, 16, 16, 16, 16, 16, 16, 14, 16, 16, 16, 15, 16, 15, 14, 11,
- 14, 16, 16, 15, 16, 16, 16, 13, 16, 16, 16, 15, 16, 15, 14, 10,
- 10, 14, 13, 13, 13, 13, 14, 13, 11, 13, 11, 11, 11, 11, 11, 9,
- 12, 15, 16, 15, 16, 15, 16, 14, 14, 14, 14, 13, 14, 13, 14, 11,
- 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 16, 14, 16, 12,
- 11, 15, 14, 14, 15, 15, 15, 14, 13, 14, 11, 12, 13, 13, 12, 10,
- 13, 16, 15, 15, 16, 16, 16, 15, 15, 15, 13, 12, 15, 14, 13, 10,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 13, 16, 16, 16, 12,
- 13, 16, 14, 15, 16, 16, 16, 15, 14, 16, 11, 12, 15, 15, 12, 10,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 13, 13, 16, 16, 14, 11,
- 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 13, 16, 16, 16, 11,
- 11, 15, 15, 14, 13, 14, 14, 14, 13, 14, 13, 13, 11, 12, 11, 10,
- 12, 16, 16, 16, 16, 15, 16, 15, 15, 15, 15, 14, 13, 12, 14, 10,
- 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 16, 14, 16, 12,
- 12, 16, 15, 15, 16, 16, 16, 14, 14, 15, 13, 13, 13, 13, 12, 10,
- 12, 16, 16, 15, 15, 15, 16, 14, 14, 15, 14, 13, 14, 13, 13, 10,
- 14, 16, 16, 16, 16, 16, 16, 15, 16, 16, 16, 14, 16, 14, 15, 11,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 14, 15, 15, 12, 11,
- 13, 16, 16, 15, 16, 16, 16, 14, 16, 16, 14, 13, 16, 14, 13, 10,
- 14, 16, 16, 16, 16, 16, 16, 15, 16, 16, 16, 14, 16, 14, 15, 10,
- 12, 16, 16, 15, 14, 15, 16, 14, 13, 15, 14, 14, 11, 12, 12, 10,
- 13, 16, 16, 16, 16, 15, 16, 16, 16, 16, 16, 15, 13, 12, 14, 11,
- 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 13, 16, 11,
- 14, 16, 16, 16, 16, 16, 16, 15, 16, 16, 15, 15, 13, 14, 12, 11,
- 13, 16, 16, 16, 16, 16, 16, 15, 16, 16, 16, 14, 14, 13, 13, 10,
- 14, 16, 16, 16, 16, 16, 16, 15, 16, 16, 16, 15, 15, 14, 14, 10,
- 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 16, 15, 16, 13, 11,
- 14, 16, 16, 16, 16, 16, 16, 14, 16, 16, 15, 14, 15, 14, 13, 10,
- 12, 15, 15, 14, 15, 14, 16, 14, 14, 16, 15, 13, 14, 13, 13, 9,
-},
-{
- 2, 5, 5, 5, 5, 5, 6, 6, 5, 6, 5, 6, 5, 6, 6, 4,
- 6, 8, 10, 8, 10, 9, 11, 9, 10, 10, 10, 9, 10, 9, 10, 8,
- 10, 11, 13, 11, 13, 11, 14, 11, 14, 13, 13, 12, 13, 12, 13, 10,
- 6, 10, 8, 9, 10, 10, 10, 9, 10, 11, 9, 9, 10, 10, 9, 7,
- 8, 11, 11, 10, 12, 11, 12, 10, 12, 12, 11, 10, 12, 12, 11, 9,
- 11, 13, 14, 11, 15, 14, 15, 12, 16, 14, 14, 12, 15, 14, 14, 11,
- 10, 13, 11, 11, 14, 13, 13, 12, 13, 14, 11, 11, 13, 13, 12, 10,
- 11, 14, 13, 11, 16, 14, 14, 12, 15, 15, 14, 12, 15, 14, 14, 11,
- 12, 14, 14, 11, 16, 16, 16, 13, 16, 16, 16, 13, 16, 16, 15, 12,
- 6, 10, 10, 10, 8, 9, 10, 9, 10, 11, 10, 10, 9, 9, 9, 8,
- 8, 11, 12, 12, 11, 10, 12, 11, 12, 12, 12, 12, 12, 11, 12, 9,
- 11, 13, 16, 14, 14, 12, 15, 12, 16, 15, 16, 14, 14, 13, 14, 11,
- 9, 13, 12, 12, 12, 12, 12, 11, 13, 13, 12, 12, 12, 12, 11, 10,
- 10, 13, 13, 12, 13, 12, 13, 11, 14, 14, 13, 13, 13, 13, 12, 10,
- 13, 14, 16, 14, 15, 14, 16, 13, 16, 16, 16, 14, 16, 14, 15, 12,
- 12, 16, 14, 14, 16, 15, 14, 13, 16, 16, 14, 14, 15, 15, 13, 12,
- 13, 16, 15, 14, 16, 16, 15, 13, 16, 16, 15, 14, 16, 16, 14, 12,
- 14, 16, 16, 14, 16, 16, 16, 14, 16, 16, 16, 16, 16, 16, 16, 12,
- 10, 13, 14, 13, 11, 11, 13, 12, 13, 14, 13, 13, 11, 12, 12, 10,
- 11, 14, 15, 15, 13, 12, 14, 13, 16, 16, 16, 15, 14, 13, 14, 11,
- 12, 14, 16, 16, 14, 12, 16, 13, 16, 16, 16, 16, 15, 13, 16, 12,
- 12, 16, 15, 16, 14, 15, 14, 14, 16, 16, 15, 16, 14, 14, 13, 12,
- 13, 16, 16, 16, 16, 14, 16, 13, 16, 16, 16, 16, 16, 14, 15, 12,
- 14, 16, 16, 16, 16, 14, 16, 14, 16, 16, 16, 16, 16, 15, 16, 13,
- 15, 16, 16, 16, 16, 16, 16, 15, 16, 16, 16, 16, 16, 16, 15, 13,
- 16, 16, 16, 16, 16, 16, 16, 15, 16, 16, 16, 16, 16, 16, 16, 13,
- 15, 16, 16, 16, 16, 16, 16, 14, 16, 16, 16, 16, 16, 16, 16, 13,
- 6, 10, 10, 10, 10, 10, 10, 10, 8, 10, 9, 9, 8, 9, 9, 7,
- 9, 12, 13, 12, 13, 12, 13, 12, 12, 12, 12, 11, 12, 11, 12, 10,
- 12, 14, 16, 14, 16, 14, 16, 14, 16, 15, 15, 14, 16, 14, 15, 12,
- 8, 12, 11, 11, 12, 12, 12, 11, 11, 12, 10, 10, 11, 12, 10, 9,
- 10, 13, 13, 12, 14, 13, 14, 12, 13, 13, 12, 11, 13, 13, 12, 10,
- 13, 15, 16, 14, 16, 16, 16, 14, 16, 15, 15, 13, 16, 15, 15, 12,
- 11, 15, 13, 13, 15, 15, 15, 14, 14, 14, 11, 12, 14, 14, 12, 11,
- 13, 16, 14, 14, 16, 16, 16, 14, 16, 15, 13, 13, 16, 14, 14, 11,
- 14, 16, 16, 14, 16, 16, 16, 15, 16, 16, 16, 14, 16, 16, 16, 12,
- 8, 12, 12, 12, 11, 11, 12, 12, 11, 12, 11, 11, 9, 10, 10, 9,
- 10, 13, 14, 13, 13, 12, 14, 13, 13, 13, 13, 13, 12, 11, 12, 10,
- 13, 15, 16, 15, 16, 14, 16, 14, 16, 16, 16, 15, 16, 13, 15, 12,
- 10, 14, 13, 13, 13, 13, 13, 13, 13, 14, 12, 12, 12, 12, 11, 10,
- 10, 13, 13, 13, 13, 13, 14, 12, 13, 14, 13, 12, 13, 12, 12, 10,
- 13, 16, 16, 14, 16, 15, 16, 14, 16, 16, 15, 14, 16, 14, 15, 11,
- 13, 16, 15, 16, 16, 16, 15, 14, 16, 16, 14, 14, 15, 15, 13, 12,
- 13, 16, 15, 14, 16, 16, 16, 14, 16, 16, 14, 14, 15, 15, 14, 11,
- 14, 16, 16, 15, 16, 16, 16, 14, 16, 16, 16, 15, 16, 16, 15, 12,
- 11, 14, 15, 14, 13, 13, 14, 14, 13, 15, 14, 14, 11, 12, 12, 11,
- 13, 16, 16, 16, 14, 14, 16, 14, 16, 16, 16, 15, 14, 13, 14, 12,
- 14, 16, 16, 16, 16, 14, 16, 16, 16, 16, 16, 16, 16, 14, 16, 13,
- 13, 16, 16, 16, 15, 16, 15, 15, 16, 16, 15, 16, 14, 14, 13, 12,
- 13, 16, 16, 15, 15, 14, 16, 14, 16, 16, 16, 15, 14, 14, 14, 11,
- 14, 16, 16, 16, 16, 16, 16, 15, 16, 16, 16, 16, 16, 15, 16, 12,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 13,
- 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 12,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 12,
- 9, 13, 13, 13, 13, 13, 14, 13, 10, 12, 11, 12, 11, 12, 11, 10,
- 12, 15, 16, 15, 16, 16, 16, 16, 14, 14, 14, 13, 14, 13, 14, 12,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 16, 16, 16, 14,
- 11, 15, 14, 14, 15, 14, 15, 14, 13, 14, 11, 12, 13, 13, 12, 11,
- 13, 16, 16, 15, 16, 16, 16, 15, 15, 15, 14, 13, 16, 15, 14, 12,
- 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 16, 16, 16, 13,
- 12, 16, 14, 15, 16, 16, 16, 16, 14, 16, 11, 13, 15, 16, 13, 12,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 14, 16, 16, 15, 12,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 16, 16, 16, 13,
- 11, 15, 14, 14, 13, 14, 15, 14, 12, 14, 13, 13, 11, 12, 12, 11,
- 13, 16, 16, 16, 16, 15, 16, 16, 15, 15, 15, 15, 14, 13, 14, 12,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 16, 13,
- 13, 16, 16, 16, 16, 16, 16, 15, 14, 16, 13, 14, 13, 14, 13, 11,
- 13, 16, 16, 16, 16, 16, 16, 15, 15, 16, 15, 14, 14, 14, 14, 11,
- 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 12,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 15, 16, 16, 13, 12,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 14, 16, 16, 15, 12,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 12,
- 11, 16, 16, 15, 13, 15, 16, 15, 13, 15, 15, 15, 11, 12, 12, 11,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 14, 15, 12,
- 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 16, 13,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 16, 14, 14, 13, 12,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 14, 14, 12,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 16, 12,
- 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 16, 14, 13,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 12,
- 12, 14, 14, 14, 14, 15, 16, 14, 14, 16, 15, 14, 14, 15, 14, 11,
-},
-{
- 1, 5, 5, 6, 5, 6, 7, 7, 5, 7, 6, 7, 5, 6, 6, 6,
- 6, 9, 10, 9, 10, 9, 11, 10, 11, 11, 11, 10, 11, 10, 11, 9,
- 10, 11, 14, 12, 14, 12, 16, 12, 16, 13, 16, 13, 14, 13, 16, 12,
- 6, 10, 9, 9, 10, 11, 11, 10, 10, 11, 9, 10, 10, 11, 10, 9,
- 8, 11, 11, 10, 13, 12, 13, 12, 13, 13, 12, 12, 13, 13, 13, 11,
- 11, 13, 16, 12, 16, 16, 16, 13, 16, 16, 16, 14, 16, 16, 16, 13,
- 10, 14, 11, 12, 14, 14, 13, 13, 13, 16, 12, 13, 14, 16, 13, 12,
- 11, 14, 13, 12, 16, 16, 16, 14, 16, 16, 14, 14, 16, 16, 16, 13,
- 12, 14, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 6, 10, 10, 11, 9, 9, 11, 10, 10, 11, 11, 11, 9, 10, 10, 9,
- 9, 12, 13, 12, 12, 11, 13, 12, 13, 13, 13, 13, 12, 12, 13, 11,
- 12, 13, 16, 16, 16, 13, 16, 14, 16, 16, 16, 16, 16, 14, 16, 13,
- 9, 13, 13, 13, 13, 13, 13, 13, 13, 14, 13, 13, 13, 13, 12, 11,
- 10, 14, 14, 13, 14, 13, 14, 13, 16, 16, 14, 15, 14, 14, 14, 12,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 13,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 14, 14, 16, 11, 12, 14, 13, 14, 16, 16, 16, 12, 13, 13, 12,
- 12, 16, 16, 16, 13, 13, 16, 14, 16, 16, 16, 16, 16, 14, 16, 13,
- 13, 16, 16, 16, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 6, 10, 10, 10, 10, 11, 11, 11, 9, 11, 9, 10, 9, 10, 10, 9,
- 9, 13, 13, 13, 13, 13, 14, 13, 12, 13, 13, 12, 13, 12, 13, 11,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 8, 13, 12, 12, 13, 13, 13, 13, 11, 13, 10, 12, 12, 13, 12, 11,
- 10, 14, 13, 13, 16, 16, 16, 14, 14, 14, 13, 13, 14, 14, 14, 12,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 11, 16, 13, 16, 16, 16, 16, 16, 14, 16, 12, 13, 16, 16, 14, 13,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 8, 13, 13, 13, 11, 12, 13, 13, 11, 13, 12, 13, 10, 12, 12, 11,
- 10, 14, 16, 16, 14, 13, 16, 14, 14, 16, 16, 14, 13, 13, 14, 12,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 10, 16, 14, 16, 14, 14, 14, 14, 13, 16, 13, 14, 13, 14, 12, 12,
- 10, 14, 14, 14, 14, 16, 16, 14, 14, 16, 14, 14, 14, 14, 14, 12,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 11, 16, 16, 16, 13, 16, 16, 16, 14, 16, 16, 16, 12, 14, 14, 13,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 9, 14, 13, 14, 13, 14, 16, 16, 11, 13, 12, 13, 11, 13, 12, 12,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 11, 16, 14, 16, 16, 16, 16, 16, 13, 16, 12, 13, 14, 16, 13, 13,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 16, 16, 16, 16, 16, 16, 14, 16, 12, 16, 16, 16, 14, 14,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 11, 16, 16, 16, 14, 16, 16, 16, 13, 16, 14, 16, 12, 13, 13, 13,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 16, 16, 16, 14, 14,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 11, 16, 16, 16, 14, 16, 16, 16, 14, 16, 16, 16, 12, 16, 14, 14,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 13,
-},
-{
- 1, 5, 5, 6, 5, 6, 7, 8, 5, 7, 6, 8, 6, 7, 7, 7,
- 5, 9, 10, 10, 10, 10, 12, 11, 10, 11, 11, 11, 10, 11, 12, 10,
- 9, 11, 13, 12, 13, 12, 16, 14, 16, 14, 16, 16, 16, 13, 16, 13,
- 5, 10, 9, 10, 10, 11, 11, 11, 10, 11, 9, 11, 10, 11, 11, 10,
- 8, 11, 11, 11, 12, 13, 13, 13, 12, 13, 12, 12, 13, 13, 13, 12,
- 11, 13, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 9, 14, 11, 12, 14, 16, 13, 14, 13, 16, 12, 14, 16, 16, 13, 13,
- 11, 16, 13, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 11, 14, 14, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 5, 10, 11, 11, 9, 10, 11, 11, 10, 12, 11, 12, 9, 11, 11, 11,
- 8, 12, 13, 13, 11, 11, 14, 13, 13, 14, 13, 16, 12, 12, 13, 12,
- 11, 13, 16, 16, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 9, 13, 12, 13, 12, 13, 13, 14, 13, 16, 13, 16, 13, 16, 13, 13,
- 10, 14, 13, 14, 13, 13, 16, 14, 16, 16, 16, 16, 16, 16, 16, 13,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 9, 14, 16, 16, 11, 12, 14, 16, 13, 16, 16, 16, 12, 14, 13, 13,
- 11, 16, 16, 16, 13, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 16, 16, 14, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 5, 10, 10, 11, 10, 11, 12, 12, 8, 11, 10, 11, 9, 11, 11, 11,
- 9, 12, 13, 13, 13, 13, 16, 16, 12, 13, 13, 13, 13, 13, 16, 13,
- 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 8, 13, 11, 13, 12, 13, 13, 14, 11, 13, 10, 13, 12, 14, 12, 12,
- 10, 14, 13, 14, 16, 16, 16, 16, 13, 16, 13, 14, 16, 16, 16, 14,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 11, 16, 13, 16, 16, 16, 16, 16, 13, 16, 12, 16, 16, 16, 16, 16,
- 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 8, 13, 13, 13, 11, 13, 14, 16, 11, 13, 13, 14, 10, 12, 12, 12,
- 10, 14, 16, 16, 13, 16, 16, 16, 13, 16, 16, 16, 13, 13, 16, 14,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 14, 16, 13, 16, 16, 16, 13, 16, 13, 16, 13, 16, 13, 14,
- 10, 16, 16, 16, 14, 16, 16, 16, 14, 16, 16, 16, 13, 16, 16, 13,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 16, 16, 13, 16, 16, 16, 14, 16, 16, 16, 12, 16, 16, 16,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 9, 14, 13, 16, 13, 16, 16, 16, 10, 14, 12, 14, 11, 13, 13, 13,
- 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 11, 16, 16, 16, 16, 16, 16, 16, 12, 16, 12, 16, 16, 16, 16, 16,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 11, 16, 16, 16, 16, 16, 16, 16, 13, 16, 13, 16, 16, 16, 16, 16,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 16, 16, 14, 16, 16, 16, 12, 16, 16, 16, 12, 16, 16, 16,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 11, 16, 16, 16, 14, 16, 16, 16, 14, 16, 16, 16, 12, 16, 16, 16,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 16, 16, 16, 16, 16, 16, 14, 16, 16, 16, 16, 16, 16, 14,
-}
-};
-
-
-static const uint8_t rv34_inter_cbp[NUM_INTER_TABLES][4][CBP_VLC_SIZE] = {
-{
- { 0, 6, 6, 3, 6, 4, 5, 3, 6, 5, 4, 3, 3, 4, 4, 3 },
- { 0, 6, 6, 4, 6, 4, 5, 3, 6, 5, 4, 3, 4, 4, 4, 2 },
- { 0, 7, 7, 4, 7, 5, 5, 4, 7, 5, 5, 4, 5, 4, 4, 1 },
- { 0, 7, 7, 5, 7, 5, 6, 4, 7, 6, 5, 3, 5, 4, 4, 1 }
-},
-{
- { 0, 6, 6, 3, 6, 3, 5, 4, 6, 5, 3, 4, 3, 4, 4, 3 },
- { 0, 6, 6, 4, 6, 4, 4, 4, 6, 4, 4, 3, 4, 4, 4, 2 },
- { 0, 6, 6, 4, 6, 4, 5, 4, 6, 5, 4, 3, 4, 4, 3, 2 },
- { 0, 7, 7, 5, 7, 5, 6, 4, 7, 6, 5, 3, 5, 4, 4, 1 }
-},
-{
- { 0, 6, 6, 3, 6, 3, 5, 4, 6, 5, 3, 4, 3, 4, 4, 3 },
- { 0, 5, 5, 3, 5, 4, 5, 4, 5, 5, 4, 4, 4, 4, 4, 2 },
- { 0, 6, 6, 4, 6, 4, 5, 3, 6, 5, 4, 3, 4, 4, 4, 2 },
- { 0, 7, 7, 5, 7, 5, 6, 4, 7, 6, 5, 3, 5, 4, 4, 1 }
-},
-{
- { 0, 6, 6, 3, 6, 3, 5, 4, 6, 5, 3, 4, 3, 4, 4, 3 },
- { 0, 5, 5, 3, 5, 4, 5, 4, 5, 5, 4, 4, 4, 4, 4, 2 },
- { 0, 6, 6, 4, 6, 4, 5, 3, 6, 5, 4, 3, 4, 4, 4, 2 },
- { 0, 7, 7, 4, 7, 5, 6, 4, 7, 6, 5, 4, 4, 4, 4, 1 }
-},
-{
- { 0, 5, 5, 3, 5, 3, 5, 4, 5, 5, 3, 4, 3, 4, 4, 4 },
- { 0, 5, 5, 3, 5, 4, 5, 4, 5, 5, 3, 4, 3, 4, 4, 3 },
- { 0, 6, 6, 4, 6, 4, 5, 4, 6, 5, 4, 3, 4, 4, 3, 2 },
- { 0, 7, 7, 4, 7, 5, 6, 4, 7, 6, 5, 4, 4, 4, 4, 1 }
-},
-{
- { 0, 5, 5, 3, 5, 3, 5, 4, 5, 5, 3, 4, 3, 4, 4, 4 },
- { 0, 5, 5, 3, 5, 4, 5, 4, 5, 5, 3, 4, 3, 4, 4, 3 },
- { 0, 5, 5, 3, 5, 4, 4, 4, 5, 4, 4, 4, 3, 4, 4, 3 },
- { 0, 6, 6, 4, 6, 4, 5, 4, 6, 5, 4, 3, 4, 4, 3, 2 }
-},
-{
- { 0, 4, 4, 3, 4, 3, 5, 5, 4, 5, 3, 5, 3, 5, 4, 5 },
- { 0, 4, 4, 3, 4, 4, 5, 4, 4, 5, 3, 5, 3, 5, 4, 4 },
- { 0, 4, 4, 3, 4, 4, 5, 4, 4, 5, 4, 4, 3, 4, 4, 4 },
- { 0, 4, 4, 3, 5, 4, 5, 4, 5, 5, 4, 4, 3, 4, 4, 3 }
-}
-};
-
-
-static const uint8_t rv34_table_inter_firstpat[NUM_INTER_TABLES][2][FIRSTBLK_VLC_SIZE] = {
- {
- {
- 0, 7, 5, 7, 5, 7, 6, 6, 7, 10, 7, 9, 8, 9, 8, 7,
- 12, 14, 11, 12, 12, 12, 11, 9, 6, 9, 6, 8, 7, 9, 7, 7,
- 8, 11, 8, 9, 9, 10, 9, 8, 13, 15, 12, 12, 12, 13, 11, 9,
- 10, 13, 9, 10, 11, 12, 9, 8, 12, 14, 10, 11, 12, 13, 10, 9,
- 16, 16, 12, 12, 14, 13, 11, 9, 6, 9, 7, 9, 7, 9, 8, 7,
- 9, 11, 9, 10, 9, 10, 9, 8, 14, 16, 12, 12, 13, 13, 11, 9,
- 8, 11, 8, 10, 9, 10, 9, 8, 10, 13, 10, 11, 10, 11, 9, 8,
- 14, 16, 12, 12, 13, 13, 11, 9, 12, 14, 10, 11, 12, 13, 10, 9,
- 13, 16, 11, 12, 13, 13, 10, 9, 16, 16, 13, 12, 14, 14, 11, 9,
- 11, 13, 11, 12, 10, 11, 10, 9, 13, 14, 12, 12, 11, 12, 10, 9,
- 16, 16, 13, 13, 13, 13, 11, 9, 12, 15, 12, 12, 11, 12, 10, 9,
- 13, 16, 13, 13, 12, 12, 11, 9, 16, 16, 14, 13, 13, 13, 11, 9,
- 14, 16, 13, 13, 13, 14, 11, 9, 16, 16, 13, 13, 14, 14, 11, 9,
- 16, 16, 13, 13, 14, 13, 11, 8, 4, 9, 6, 8, 6, 9, 7, 7,
- 8, 11, 8, 9, 9, 10, 8, 8, 13, 15, 12, 12, 13, 13, 11, 9,
- 7, 10, 7, 9, 8, 10, 8, 8, 9, 12, 9, 10, 10, 11, 9, 8,
- 14, 16, 12, 12, 13, 13, 11, 9, 11, 13, 9, 10, 11, 12, 9, 8,
- 12, 14, 10, 11, 12, 13, 10, 9, 16, 16, 13, 12, 14, 14, 11, 9,
- 7, 10, 8, 9, 8, 10, 8, 8, 10, 12, 10, 11, 10, 11, 9, 8,
- 14, 16, 13, 13, 13, 13, 11, 9, 9, 12, 9, 10, 9, 11, 9, 8,
- 11, 13, 10, 11, 10, 11, 10, 9, 15, 16, 13, 13, 13, 13, 11, 9,
- 12, 14, 11, 11, 12, 13, 10, 9, 13, 16, 11, 12, 13, 13, 10, 9,
- 16, 16, 12, 12, 14, 13, 11, 8, 11, 14, 11, 12, 10, 11, 10, 9,
- 13, 15, 12, 13, 11, 12, 10, 9, 16, 16, 14, 13, 13, 13, 11, 9,
- 12, 15, 12, 13, 11, 12, 10, 9, 13, 16, 13, 13, 12, 12, 11, 9,
- 16, 16, 14, 13, 13, 13, 11, 9, 15, 16, 13, 13, 13, 13, 11, 9,
- 16, 16, 13, 13, 13, 13, 11, 9, 16, 16, 13, 12, 13, 13, 10, 7,
- 8, 11, 8, 10, 9, 11, 9, 9, 10, 13, 10, 11, 11, 12, 10, 9,
- 15, 16, 13, 13, 14, 14, 12, 10, 9, 12, 9, 11, 10, 11, 9, 9,
- 12, 14, 11, 11, 11, 12, 10, 9, 16, 16, 13, 13, 14, 14, 12, 10,
- 12, 14, 10, 11, 12, 13, 10, 9, 14, 16, 11, 12, 13, 14, 10, 9,
- 16, 16, 13, 13, 15, 14, 11, 9, 9, 12, 10, 11, 9, 11, 10, 9,
- 12, 14, 11, 12, 11, 12, 10, 9, 16, 16, 14, 13, 14, 14, 12, 10,
- 11, 14, 10, 12, 11, 12, 10, 9, 12, 15, 11, 12, 12, 13, 11, 10,
- 16, 16, 14, 13, 14, 14, 12, 10, 13, 16, 11, 12, 13, 14, 11, 9,
- 14, 16, 12, 12, 13, 14, 11, 9, 16, 16, 13, 13, 14, 14, 11, 9,
- 12, 15, 12, 13, 10, 12, 10, 9, 14, 16, 13, 13, 11, 12, 11, 10,
- 16, 16, 14, 14, 14, 13, 12, 9, 13, 16, 13, 13, 12, 13, 11, 10,
- 14, 16, 13, 13, 12, 13, 11, 10, 16, 16, 14, 14, 13, 13, 12, 9,
- 15, 16, 13, 13, 13, 14, 11, 9, 16, 16, 13, 13, 13, 14, 11, 9,
- 16, 16, 13, 12, 13, 13, 10, 8, 10, 13, 10, 11, 10, 12, 10, 9,
- 12, 14, 11, 12, 12, 13, 11, 10, 16, 16, 13, 13, 14, 14, 12, 9,
- 11, 14, 10, 11, 11, 12, 10, 9, 13, 16, 11, 12, 12, 13, 11, 10,
- 16, 16, 14, 13, 14, 14, 12, 9, 12, 15, 10, 11, 12, 13, 9, 8,
- 14, 16, 11, 11, 13, 14, 10, 8, 16, 16, 12, 12, 14, 14, 10, 8,
- 11, 14, 11, 12, 11, 12, 10, 9, 13, 16, 12, 13, 12, 13, 11, 10,
- 16, 16, 14, 13, 14, 14, 12, 9, 12, 15, 11, 12, 11, 13, 10, 10,
- 13, 16, 12, 13, 12, 13, 11, 10, 16, 16, 14, 13, 14, 14, 12, 9,
- 13, 16, 11, 11, 13, 13, 10, 8, 14, 16, 11, 12, 13, 14, 10, 8,
- 16, 16, 12, 12, 14, 14, 10, 8, 12, 15, 12, 13, 10, 11, 10, 9,
- 14, 16, 13, 13, 11, 12, 10, 9, 16, 16, 14, 13, 13, 13, 11, 8,
- 13, 16, 12, 13, 11, 12, 10, 9, 14, 16, 13, 13, 12, 12, 10, 9,
- 16, 16, 14, 13, 13, 12, 10, 8, 14, 16, 12, 12, 12, 13, 10, 8,
- 14, 16, 12, 12, 12, 13, 10, 7, 16, 16, 11, 11, 12, 11, 8, 5,
- },
- {
- 0, 7, 4, 8, 5, 8, 7, 8, 6, 10, 7, 10, 8, 10, 9, 9,
- 13, 16, 12, 13, 13, 14, 12, 12, 4, 10, 6, 9, 8, 11, 8, 9,
- 8, 12, 8, 11, 10, 12, 10, 10, 14, 16, 12, 13, 14, 15, 12, 12,
- 9, 14, 9, 11, 12, 14, 11, 11, 11, 15, 10, 12, 13, 14, 11, 11,
- 15, 16, 13, 14, 15, 16, 13, 12, 5, 10, 7, 10, 7, 10, 9, 9,
- 8, 12, 9, 11, 10, 11, 10, 10, 14, 16, 13, 14, 14, 14, 12, 12,
- 8, 12, 8, 11, 10, 12, 10, 10, 10, 14, 10, 12, 11, 13, 10, 11,
- 15, 16, 13, 14, 14, 15, 13, 12, 11, 16, 10, 12, 13, 15, 11, 11,
- 13, 16, 11, 13, 14, 15, 12, 12, 16, 16, 14, 14, 16, 16, 13, 12,
- 11, 15, 11, 13, 11, 13, 11, 11, 13, 16, 12, 14, 12, 13, 12, 12,
- 16, 16, 14, 15, 15, 15, 13, 12, 12, 16, 12, 14, 12, 14, 12, 12,
- 14, 16, 13, 14, 13, 14, 12, 12, 16, 16, 14, 16, 16, 16, 13, 12,
- 14, 16, 13, 14, 15, 16, 13, 12, 16, 16, 14, 15, 16, 16, 13, 12,
- 16, 16, 15, 16, 16, 16, 13, 12, 2, 9, 5, 8, 6, 9, 8, 9,
- 7, 11, 8, 10, 9, 11, 9, 10, 13, 16, 12, 13, 14, 14, 12, 12,
- 5, 11, 6, 10, 9, 11, 9, 9, 9, 13, 9, 11, 10, 12, 10, 10,
- 14, 16, 12, 14, 14, 15, 12, 12, 9, 14, 9, 11, 12, 14, 10, 11,
- 11, 16, 10, 12, 13, 14, 11, 11, 16, 16, 13, 14, 15, 16, 13, 12,
- 6, 11, 7, 10, 8, 11, 9, 9, 9, 13, 9, 11, 10, 12, 10, 10,
- 14, 16, 13, 14, 14, 14, 12, 12, 8, 13, 8, 11, 10, 12, 10, 10,
- 10, 13, 10, 12, 11, 13, 10, 11, 14, 16, 13, 14, 14, 15, 12, 12,
- 11, 15, 10, 12, 13, 15, 11, 11, 12, 16, 11, 13, 13, 15, 12, 11,
- 16, 16, 13, 14, 15, 16, 13, 12, 11, 15, 11, 13, 10, 13, 11, 11,
- 13, 16, 12, 14, 12, 13, 12, 11, 16, 16, 14, 15, 15, 15, 13, 12,
- 12, 16, 12, 13, 12, 14, 12, 12, 13, 16, 12, 14, 13, 14, 12, 12,
- 16, 16, 14, 15, 15, 15, 13, 12, 14, 16, 13, 14, 15, 16, 12, 12,
- 16, 16, 13, 14, 15, 16, 12, 12, 16, 16, 14, 15, 16, 16, 13, 12,
- 6, 12, 7, 10, 9, 12, 9, 10, 9, 13, 9, 12, 11, 13, 11, 11,
- 14, 16, 13, 14, 15, 15, 13, 12, 8, 13, 8, 11, 10, 13, 10, 10,
- 10, 14, 10, 12, 12, 14, 11, 11, 15, 16, 13, 14, 16, 16, 13, 12,
- 10, 15, 9, 12, 12, 15, 11, 11, 12, 16, 11, 13, 14, 16, 12, 12,
- 16, 16, 14, 14, 16, 16, 13, 12, 8, 13, 9, 11, 10, 12, 10, 11,
- 11, 14, 11, 12, 11, 13, 11, 11, 16, 16, 14, 15, 15, 16, 13, 12,
- 10, 14, 10, 12, 11, 13, 11, 11, 11, 15, 11, 13, 12, 14, 11, 11,
- 15, 16, 13, 14, 15, 16, 13, 12, 12, 16, 11, 13, 13, 16, 12, 12,
- 13, 16, 11, 13, 14, 16, 12, 12, 16, 16, 13, 14, 16, 16, 13, 12,
- 12, 16, 12, 14, 11, 13, 11, 11, 13, 16, 13, 14, 12, 14, 12, 12,
- 16, 16, 15, 16, 16, 16, 14, 13, 13, 16, 12, 14, 12, 14, 12, 12,
- 14, 16, 13, 14, 13, 14, 12, 12, 16, 16, 14, 16, 14, 16, 13, 12,
- 15, 16, 13, 15, 15, 16, 13, 12, 15, 16, 13, 15, 14, 16, 13, 12,
- 16, 16, 14, 15, 15, 16, 13, 11, 8, 13, 8, 11, 10, 13, 10, 11,
- 11, 15, 10, 12, 12, 14, 11, 11, 15, 16, 13, 14, 15, 15, 13, 12,
- 9, 14, 9, 12, 11, 14, 10, 11, 11, 16, 10, 12, 13, 14, 11, 11,
- 16, 16, 13, 14, 15, 16, 13, 12, 11, 15, 9, 12, 12, 14, 10, 10,
- 12, 16, 11, 12, 14, 15, 11, 11, 16, 16, 13, 14, 16, 16, 12, 11,
- 9, 14, 10, 12, 11, 13, 11, 11, 12, 16, 11, 13, 12, 14, 11, 11,
- 16, 16, 14, 14, 15, 15, 13, 12, 10, 15, 10, 12, 12, 14, 11, 11,
- 12, 16, 11, 13, 13, 14, 11, 11, 16, 16, 14, 14, 15, 16, 13, 12,
- 12, 16, 10, 12, 13, 15, 11, 11, 13, 16, 11, 13, 14, 15, 11, 11,
- 16, 16, 13, 13, 15, 16, 12, 11, 12, 16, 11, 13, 10, 13, 11, 11,
- 14, 16, 13, 14, 12, 14, 11, 11, 16, 16, 15, 16, 14, 15, 13, 11,
- 13, 16, 12, 14, 12, 14, 11, 11, 13, 16, 12, 14, 12, 14, 11, 11,
- 16, 16, 14, 15, 14, 14, 12, 11, 14, 16, 12, 13, 13, 15, 11, 11,
- 14, 16, 12, 13, 13, 14, 11, 11, 15, 16, 12, 13, 13, 13, 10, 9,
- },
- },
- {
- {
- 0, 7, 4, 7, 5, 7, 6, 6, 6, 10, 7, 8, 8, 9, 8, 7,
- 13, 14, 11, 12, 12, 12, 11, 9, 5, 9, 6, 8, 7, 9, 7, 7,
- 8, 11, 8, 9, 9, 10, 9, 8, 13, 16, 12, 12, 12, 13, 11, 9,
- 10, 13, 8, 10, 11, 12, 9, 9, 12, 14, 10, 11, 12, 13, 10, 9,
- 15, 16, 12, 12, 14, 14, 11, 9, 6, 10, 7, 9, 7, 9, 8, 7,
- 8, 11, 9, 10, 9, 10, 9, 8, 14, 16, 12, 12, 13, 12, 11, 9,
- 8, 11, 8, 10, 9, 10, 9, 8, 10, 13, 10, 11, 10, 11, 9, 9,
- 14, 16, 12, 12, 13, 13, 11, 9, 12, 15, 10, 11, 12, 13, 10, 9,
- 13, 16, 11, 12, 13, 13, 10, 9, 16, 16, 12, 13, 14, 14, 11, 9,
- 10, 14, 11, 12, 9, 11, 10, 9, 12, 15, 12, 13, 11, 12, 11, 9,
- 16, 16, 13, 13, 13, 13, 11, 9, 12, 15, 12, 13, 11, 12, 11, 9,
- 13, 16, 12, 13, 12, 13, 11, 10, 16, 16, 13, 13, 13, 13, 11, 9,
- 14, 16, 13, 13, 13, 14, 11, 10, 16, 16, 13, 13, 13, 14, 11, 10,
- 16, 16, 13, 13, 14, 14, 11, 9, 4, 9, 6, 8, 6, 9, 7, 7,
- 8, 11, 8, 9, 9, 10, 9, 8, 13, 15, 12, 12, 13, 13, 11, 9,
- 6, 10, 7, 9, 8, 10, 8, 8, 9, 12, 9, 10, 10, 11, 9, 8,
- 14, 16, 12, 12, 13, 13, 11, 10, 10, 13, 8, 10, 11, 12, 9, 9,
- 12, 15, 10, 11, 12, 13, 10, 9, 16, 16, 12, 12, 14, 14, 11, 9,
- 7, 11, 8, 9, 7, 10, 8, 8, 9, 12, 10, 11, 9, 11, 9, 9,
- 14, 16, 12, 13, 13, 13, 11, 10, 9, 12, 9, 10, 9, 11, 9, 9,
- 10, 13, 10, 11, 10, 11, 10, 9, 14, 16, 12, 13, 13, 13, 11, 9,
- 12, 15, 10, 11, 12, 13, 10, 9, 13, 16, 11, 12, 13, 13, 10, 9,
- 16, 16, 12, 12, 14, 14, 11, 9, 10, 14, 11, 12, 9, 11, 10, 9,
- 12, 16, 12, 13, 11, 12, 11, 9, 16, 16, 14, 14, 13, 13, 11, 9,
- 12, 16, 12, 13, 11, 12, 10, 10, 13, 16, 12, 13, 11, 12, 11, 10,
- 16, 16, 13, 13, 13, 13, 11, 9, 14, 16, 13, 13, 13, 14, 11, 9,
- 15, 16, 13, 13, 13, 14, 11, 9, 16, 16, 13, 13, 13, 13, 10, 8,
- 7, 11, 8, 10, 9, 11, 9, 9, 10, 13, 10, 11, 11, 12, 10, 10,
- 15, 16, 13, 13, 14, 14, 12, 10, 9, 13, 9, 11, 10, 12, 10, 9,
- 11, 14, 10, 12, 12, 13, 10, 10, 16, 16, 13, 13, 14, 14, 12, 10,
- 11, 15, 9, 11, 12, 13, 10, 9, 13, 16, 11, 12, 13, 14, 11, 10,
- 16, 16, 13, 13, 15, 15, 11, 10, 9, 13, 10, 11, 9, 11, 10, 9,
- 11, 14, 11, 12, 11, 12, 11, 10, 16, 16, 14, 14, 14, 14, 12, 10,
- 10, 14, 10, 12, 11, 12, 10, 10, 12, 15, 11, 12, 12, 13, 11, 10,
- 16, 16, 13, 13, 14, 14, 12, 10, 13, 16, 11, 12, 13, 14, 11, 10,
- 13, 16, 11, 12, 13, 14, 11, 10, 16, 16, 12, 13, 14, 14, 11, 9,
- 11, 15, 12, 13, 10, 12, 10, 10, 13, 16, 13, 14, 11, 13, 11, 10,
- 16, 16, 14, 14, 14, 14, 12, 10, 13, 16, 13, 13, 11, 13, 11, 10,
- 14, 16, 13, 14, 12, 13, 11, 10, 16, 16, 14, 14, 13, 13, 12, 10,
- 15, 16, 13, 14, 14, 14, 11, 10, 15, 16, 13, 13, 13, 14, 11, 10,
- 16, 16, 12, 13, 13, 13, 10, 8, 9, 13, 10, 11, 10, 12, 10, 10,
- 12, 15, 11, 12, 12, 13, 11, 10, 16, 16, 14, 13, 14, 14, 12, 10,
- 10, 14, 10, 12, 11, 13, 10, 10, 13, 16, 11, 12, 12, 14, 11, 10,
- 16, 16, 13, 13, 14, 14, 12, 10, 12, 16, 9, 11, 12, 14, 10, 9,
- 13, 16, 10, 12, 13, 14, 10, 9, 16, 16, 12, 12, 14, 14, 11, 9,
- 10, 14, 11, 12, 10, 12, 10, 10, 13, 16, 12, 13, 12, 13, 11, 10,
- 16, 16, 14, 14, 14, 14, 12, 10, 11, 16, 11, 12, 11, 13, 11, 10,
- 13, 16, 12, 13, 12, 14, 11, 10, 16, 16, 14, 14, 14, 14, 12, 10,
- 13, 16, 11, 12, 13, 14, 10, 9, 14, 16, 11, 12, 13, 14, 10, 9,
- 16, 16, 12, 12, 14, 14, 10, 8, 12, 16, 12, 13, 10, 12, 10, 9,
- 14, 16, 13, 13, 11, 12, 11, 9, 16, 16, 14, 14, 13, 13, 11, 9,
- 13, 16, 12, 13, 11, 12, 10, 9, 14, 16, 13, 13, 11, 13, 11, 9,
- 16, 16, 14, 14, 13, 13, 11, 9, 14, 16, 12, 13, 12, 13, 10, 8,
- 14, 16, 12, 12, 12, 13, 10, 8, 15, 16, 11, 11, 11, 12, 9, 6,
- },
- {
- 0, 7, 4, 7, 5, 8, 7, 8, 5, 10, 7, 10, 8, 10, 9, 10,
- 13, 16, 12, 14, 14, 14, 13, 12, 4, 10, 6, 9, 8, 11, 9, 9,
- 8, 12, 8, 11, 10, 12, 10, 10, 14, 16, 13, 14, 14, 15, 13, 12,
- 9, 14, 9, 12, 12, 14, 11, 11, 12, 16, 11, 13, 13, 15, 12, 12,
- 15, 16, 14, 15, 15, 16, 13, 13, 5, 10, 7, 10, 7, 10, 9, 9,
- 8, 12, 9, 11, 9, 11, 10, 10, 14, 16, 13, 14, 14, 15, 13, 12,
- 7, 12, 8, 11, 10, 12, 10, 10, 10, 13, 10, 12, 11, 13, 11, 11,
- 15, 16, 13, 15, 14, 16, 13, 13, 11, 16, 11, 13, 13, 16, 12, 12,
- 13, 16, 12, 14, 14, 16, 12, 12, 16, 16, 14, 16, 16, 16, 14, 13,
- 11, 15, 12, 14, 11, 13, 11, 12, 13, 16, 12, 14, 12, 14, 12, 12,
- 16, 16, 14, 16, 14, 16, 13, 13, 13, 16, 12, 14, 12, 14, 12, 12,
- 14, 16, 13, 15, 13, 15, 13, 13, 16, 16, 15, 16, 16, 16, 14, 13,
- 15, 16, 13, 16, 15, 16, 13, 13, 16, 16, 14, 16, 16, 16, 14, 13,
- 16, 16, 16, 16, 16, 16, 14, 13, 2, 9, 5, 8, 6, 9, 8, 9,
- 7, 11, 8, 10, 9, 11, 9, 10, 14, 16, 13, 14, 14, 15, 13, 12,
- 5, 11, 6, 10, 9, 11, 9, 10, 8, 13, 9, 11, 11, 12, 10, 11,
- 14, 16, 13, 14, 14, 16, 13, 13, 9, 15, 9, 12, 12, 14, 11, 11,
- 12, 16, 11, 13, 13, 15, 12, 12, 16, 16, 14, 15, 16, 16, 14, 13,
- 6, 11, 7, 10, 8, 11, 9, 10, 9, 13, 9, 12, 10, 12, 10, 11,
- 14, 16, 13, 14, 14, 15, 13, 13, 8, 12, 8, 11, 10, 12, 10, 11,
- 9, 13, 10, 12, 11, 13, 11, 11, 14, 16, 13, 14, 14, 16, 13, 13,
- 12, 16, 11, 13, 13, 15, 12, 12, 13, 16, 11, 13, 14, 16, 12, 12,
- 16, 16, 14, 15, 16, 16, 13, 13, 11, 15, 11, 14, 10, 13, 11, 12,
- 13, 16, 13, 15, 12, 14, 12, 12, 16, 16, 15, 16, 15, 16, 14, 13,
- 12, 16, 12, 14, 12, 14, 12, 12, 13, 16, 13, 15, 13, 14, 12, 13,
- 16, 16, 15, 16, 15, 16, 13, 13, 15, 16, 13, 16, 15, 16, 13, 13,
- 16, 16, 14, 16, 16, 16, 13, 13, 16, 16, 15, 16, 16, 16, 14, 13,
- 5, 12, 7, 10, 9, 12, 10, 10, 9, 13, 9, 12, 11, 13, 11, 11,
- 15, 16, 13, 14, 15, 15, 13, 13, 7, 13, 8, 11, 10, 13, 10, 11,
- 10, 14, 10, 12, 12, 14, 11, 12, 16, 16, 14, 15, 16, 16, 14, 13,
- 10, 16, 9, 12, 13, 15, 11, 12, 13, 16, 11, 13, 14, 16, 12, 12,
- 16, 16, 14, 16, 16, 16, 14, 13, 8, 13, 9, 12, 9, 12, 10, 11,
- 11, 15, 11, 13, 11, 13, 11, 12, 16, 16, 14, 16, 16, 16, 14, 13,
- 9, 14, 10, 12, 11, 13, 11, 12, 11, 15, 11, 13, 12, 14, 12, 12,
- 16, 16, 14, 16, 15, 16, 14, 13, 12, 16, 11, 14, 14, 16, 12, 12,
- 13, 16, 12, 14, 14, 16, 13, 13, 16, 16, 13, 15, 16, 16, 14, 13,
- 11, 16, 12, 14, 10, 13, 12, 12, 13, 16, 13, 15, 12, 14, 12, 13,
- 16, 16, 16, 16, 16, 16, 14, 14, 13, 16, 13, 15, 12, 15, 12, 13,
- 13, 16, 13, 15, 12, 15, 13, 13, 16, 16, 15, 16, 14, 16, 14, 13,
- 16, 16, 14, 16, 16, 16, 14, 13, 15, 16, 14, 16, 15, 16, 14, 13,
- 16, 16, 14, 16, 15, 16, 13, 12, 8, 14, 9, 12, 10, 14, 11, 12,
- 11, 16, 10, 13, 12, 14, 12, 12, 16, 16, 14, 15, 15, 16, 14, 13,
- 9, 15, 9, 12, 12, 14, 11, 12, 12, 16, 11, 13, 13, 15, 12, 12,
- 16, 16, 14, 15, 16, 16, 14, 13, 11, 16, 9, 12, 13, 15, 11, 11,
- 13, 16, 11, 13, 14, 16, 12, 12, 16, 16, 14, 14, 16, 16, 13, 12,
- 9, 15, 10, 13, 11, 14, 11, 12, 12, 16, 11, 14, 12, 14, 12, 12,
- 16, 16, 14, 16, 16, 16, 14, 13, 10, 16, 10, 13, 12, 15, 12, 12,
- 12, 16, 12, 14, 13, 15, 12, 12, 16, 16, 14, 16, 16, 16, 14, 13,
- 12, 16, 11, 13, 13, 16, 12, 12, 13, 16, 11, 13, 14, 16, 12, 12,
- 16, 16, 13, 14, 16, 16, 13, 12, 11, 16, 12, 14, 10, 13, 11, 12,
- 13, 16, 13, 15, 12, 14, 12, 12, 16, 16, 16, 16, 15, 16, 13, 12,
- 12, 16, 12, 15, 12, 14, 12, 12, 13, 16, 13, 15, 12, 14, 12, 12,
- 16, 16, 15, 16, 14, 15, 13, 12, 14, 16, 13, 14, 13, 16, 12, 12,
- 13, 16, 12, 14, 13, 15, 12, 12, 14, 16, 12, 13, 13, 14, 11, 10,
- },
- },
- {
- {
- 0, 7, 4, 7, 5, 7, 6, 6, 6, 10, 7, 8, 8, 9, 8, 8,
- 13, 14, 11, 12, 12, 12, 11, 10, 5, 9, 6, 8, 7, 9, 7, 7,
- 8, 11, 8, 9, 9, 10, 9, 8, 13, 16, 12, 12, 13, 13, 11, 10,
- 10, 14, 8, 10, 11, 13, 9, 9, 12, 15, 10, 11, 12, 13, 10, 10,
- 16, 16, 12, 13, 14, 14, 11, 10, 5, 10, 7, 9, 6, 9, 8, 8,
- 8, 11, 9, 10, 9, 10, 9, 8, 14, 16, 12, 12, 13, 13, 11, 10,
- 8, 12, 8, 10, 9, 10, 9, 9, 10, 13, 9, 11, 10, 11, 9, 9,
- 14, 16, 12, 13, 13, 13, 11, 10, 12, 16, 10, 12, 12, 13, 10, 10,
- 13, 16, 11, 12, 13, 14, 11, 10, 16, 16, 12, 13, 14, 14, 11, 10,
- 10, 14, 11, 13, 9, 11, 10, 10, 12, 16, 12, 13, 11, 12, 11, 10,
- 16, 16, 13, 14, 13, 13, 12, 10, 12, 16, 12, 13, 11, 13, 11, 10,
- 13, 16, 12, 13, 12, 13, 11, 10, 16, 16, 13, 14, 13, 14, 12, 10,
- 14, 16, 13, 14, 13, 14, 12, 11, 16, 16, 13, 14, 14, 15, 12, 11,
- 16, 16, 13, 14, 14, 14, 11, 10, 3, 9, 5, 8, 6, 9, 7, 7,
- 8, 11, 8, 10, 9, 10, 9, 8, 14, 15, 12, 12, 13, 13, 11, 10,
- 6, 11, 6, 9, 8, 10, 8, 8, 9, 12, 9, 10, 10, 11, 9, 9,
- 14, 16, 12, 13, 13, 13, 11, 10, 10, 14, 8, 11, 12, 13, 9, 9,
- 12, 16, 10, 11, 12, 13, 10, 10, 16, 16, 12, 13, 14, 14, 11, 10,
- 6, 11, 8, 10, 7, 10, 8, 8, 9, 12, 10, 11, 9, 11, 9, 9,
- 14, 16, 12, 13, 13, 13, 12, 10, 9, 12, 9, 11, 9, 11, 9, 9,
- 10, 13, 10, 11, 10, 12, 10, 9, 14, 16, 12, 13, 13, 13, 11, 10,
- 12, 16, 10, 12, 12, 14, 10, 10, 13, 16, 10, 12, 13, 14, 11, 10,
- 16, 16, 12, 13, 14, 14, 11, 10, 10, 15, 11, 13, 9, 11, 10, 10,
- 12, 16, 12, 13, 11, 12, 11, 10, 16, 16, 14, 14, 13, 14, 12, 10,
- 12, 16, 12, 13, 11, 13, 11, 10, 13, 16, 12, 13, 11, 13, 11, 10,
- 16, 16, 13, 14, 13, 13, 12, 10, 14, 16, 13, 14, 14, 14, 11, 11,
- 15, 16, 13, 14, 13, 14, 11, 10, 16, 16, 13, 13, 13, 14, 11, 9,
- 7, 12, 8, 11, 9, 11, 9, 10, 10, 14, 10, 12, 11, 12, 11, 10,
- 16, 16, 13, 13, 14, 14, 12, 11, 9, 13, 9, 11, 10, 12, 10, 10,
- 11, 15, 10, 12, 12, 13, 11, 10, 16, 16, 13, 14, 14, 14, 12, 11,
- 11, 16, 9, 11, 12, 14, 10, 10, 13, 16, 10, 12, 13, 14, 11, 10,
- 16, 16, 13, 14, 16, 16, 12, 11, 9, 13, 10, 12, 9, 12, 10, 10,
- 11, 15, 11, 13, 11, 13, 11, 11, 16, 16, 14, 14, 14, 14, 13, 11,
- 10, 14, 10, 12, 11, 13, 11, 10, 12, 16, 11, 13, 12, 13, 11, 11,
- 16, 16, 13, 14, 14, 14, 12, 11, 13, 16, 11, 13, 13, 14, 11, 11,
- 13, 16, 11, 13, 13, 14, 11, 11, 16, 16, 12, 13, 14, 15, 12, 10,
- 11, 16, 12, 14, 10, 12, 11, 10, 13, 16, 13, 14, 11, 13, 11, 11,
- 16, 16, 15, 16, 14, 14, 13, 11, 13, 16, 13, 14, 12, 13, 11, 11,
- 13, 16, 13, 14, 12, 13, 11, 11, 16, 16, 14, 14, 13, 14, 12, 11,
- 15, 16, 13, 14, 14, 16, 12, 11, 14, 16, 13, 14, 13, 14, 12, 11,
- 16, 16, 12, 13, 13, 14, 11, 9, 9, 14, 10, 12, 10, 13, 11, 11,
- 12, 16, 12, 13, 12, 14, 12, 11, 16, 16, 14, 14, 14, 14, 13, 11,
- 10, 16, 10, 13, 12, 14, 11, 11, 13, 16, 12, 13, 13, 14, 12, 11,
- 16, 16, 14, 14, 15, 15, 13, 11, 12, 16, 9, 12, 13, 14, 10, 10,
- 14, 16, 11, 12, 13, 15, 11, 10, 16, 16, 13, 13, 15, 16, 11, 10,
- 10, 16, 11, 13, 11, 13, 11, 11, 13, 16, 12, 14, 12, 14, 12, 11,
- 16, 16, 14, 14, 14, 14, 13, 11, 11, 16, 11, 13, 12, 14, 11, 11,
- 13, 16, 12, 14, 13, 14, 12, 11, 16, 16, 14, 14, 14, 15, 13, 11,
- 13, 16, 11, 13, 13, 14, 11, 10, 14, 16, 11, 13, 13, 14, 11, 10,
- 16, 16, 12, 13, 14, 15, 11, 9, 12, 16, 12, 14, 10, 13, 11, 10,
- 14, 16, 13, 14, 11, 13, 11, 10, 16, 16, 14, 15, 13, 14, 12, 10,
- 13, 16, 13, 14, 11, 13, 11, 10, 14, 16, 13, 14, 12, 13, 11, 10,
- 16, 16, 14, 14, 13, 13, 11, 10, 14, 16, 12, 13, 13, 14, 11, 9,
- 14, 16, 12, 13, 12, 13, 10, 9, 14, 16, 11, 11, 12, 12, 9, 7,
- },
- {
- 0, 7, 3, 8, 5, 8, 7, 9, 5, 10, 7, 10, 8, 11, 10, 10,
- 14, 16, 14, 15, 14, 16, 14, 14, 4, 10, 6, 10, 8, 11, 9, 10,
- 8, 12, 9, 11, 10, 12, 11, 11, 15, 16, 14, 16, 15, 16, 14, 14,
- 10, 16, 10, 13, 13, 16, 12, 13, 13, 16, 12, 14, 14, 16, 13, 13,
- 16, 16, 16, 16, 16, 16, 14, 15, 4, 10, 7, 10, 7, 10, 9, 10,
- 8, 12, 9, 12, 10, 12, 11, 12, 14, 16, 14, 16, 15, 16, 14, 14,
- 8, 12, 9, 12, 10, 13, 11, 12, 10, 14, 11, 13, 11, 14, 12, 13,
- 16, 16, 14, 16, 16, 16, 14, 15, 12, 16, 12, 14, 14, 16, 13, 14,
- 14, 16, 13, 16, 16, 16, 14, 14, 16, 16, 16, 16, 16, 16, 16, 16,
- 11, 16, 12, 16, 11, 14, 13, 13, 13, 16, 13, 16, 13, 15, 13, 14,
- 16, 16, 16, 16, 16, 16, 15, 16, 13, 16, 13, 16, 13, 16, 13, 14,
- 14, 16, 14, 16, 14, 16, 14, 15, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 15, 16, 16, 16, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 2, 9, 5, 9, 6, 10, 8, 10,
- 7, 11, 8, 11, 9, 12, 10, 11, 14, 16, 14, 16, 15, 16, 14, 14,
- 5, 11, 6, 10, 9, 12, 10, 11, 9, 13, 9, 12, 11, 13, 11, 12,
- 16, 16, 14, 16, 16, 16, 14, 14, 10, 16, 9, 13, 13, 16, 12, 13,
- 13, 16, 12, 14, 14, 16, 13, 13, 16, 16, 16, 16, 16, 16, 16, 14,
- 5, 11, 8, 11, 7, 11, 10, 11, 9, 13, 10, 13, 10, 13, 11, 12,
- 16, 16, 14, 16, 16, 16, 14, 14, 8, 13, 9, 12, 10, 13, 11, 12,
- 10, 14, 10, 13, 11, 14, 12, 12, 16, 16, 14, 16, 15, 16, 14, 14,
- 12, 16, 12, 14, 14, 16, 13, 14, 14, 16, 12, 16, 15, 16, 13, 14,
- 16, 16, 15, 16, 16, 16, 15, 15, 11, 16, 12, 16, 10, 14, 12, 13,
- 13, 16, 14, 16, 13, 16, 13, 14, 16, 16, 16, 16, 16, 16, 15, 16,
- 13, 16, 13, 16, 13, 16, 13, 14, 14, 16, 14, 16, 13, 16, 13, 14,
- 16, 16, 16, 16, 16, 16, 15, 16, 16, 16, 15, 16, 16, 16, 15, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 16,
- 5, 13, 7, 12, 9, 13, 11, 12, 10, 14, 10, 13, 11, 13, 12, 13,
- 16, 16, 16, 16, 16, 16, 16, 15, 7, 14, 8, 12, 11, 14, 11, 12,
- 11, 16, 11, 13, 13, 16, 13, 13, 16, 16, 16, 16, 16, 16, 16, 16,
- 11, 16, 10, 14, 14, 16, 12, 13, 13, 16, 12, 15, 16, 16, 14, 14,
- 16, 16, 16, 16, 16, 16, 16, 16, 8, 14, 10, 13, 9, 13, 11, 12,
- 11, 16, 12, 14, 12, 14, 13, 13, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 11, 14, 12, 14, 12, 13, 11, 16, 12, 14, 12, 15, 13, 13,
- 16, 16, 15, 16, 16, 16, 15, 16, 13, 16, 12, 16, 15, 16, 14, 14,
- 13, 16, 12, 16, 16, 16, 14, 14, 16, 16, 14, 16, 16, 16, 14, 16,
- 11, 16, 13, 16, 10, 14, 12, 13, 14, 16, 14, 16, 13, 16, 14, 14,
- 16, 16, 16, 16, 16, 16, 16, 16, 13, 16, 14, 16, 13, 16, 14, 15,
- 13, 16, 14, 16, 13, 16, 14, 15, 16, 16, 16, 16, 15, 16, 15, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 16, 16, 16, 15, 16,
- 16, 16, 15, 16, 16, 16, 14, 14, 8, 16, 10, 14, 11, 16, 12, 13,
- 12, 16, 12, 14, 13, 16, 13, 14, 16, 16, 16, 16, 16, 16, 16, 14,
- 10, 16, 10, 14, 12, 16, 12, 13, 13, 16, 12, 15, 14, 16, 13, 14,
- 16, 16, 16, 16, 16, 16, 16, 15, 11, 16, 10, 13, 13, 16, 12, 13,
- 14, 16, 12, 14, 15, 16, 13, 13, 16, 16, 16, 16, 16, 16, 15, 14,
- 10, 16, 11, 14, 11, 16, 12, 13, 13, 16, 13, 16, 13, 16, 13, 14,
- 16, 16, 16, 16, 16, 16, 16, 15, 11, 16, 12, 14, 13, 16, 13, 14,
- 13, 16, 13, 16, 14, 16, 13, 14, 16, 16, 16, 16, 16, 16, 16, 15,
- 13, 16, 12, 14, 14, 16, 13, 13, 13, 16, 12, 15, 14, 16, 13, 13,
- 16, 16, 14, 16, 16, 16, 14, 13, 11, 16, 12, 16, 11, 15, 12, 13,
- 14, 16, 14, 16, 13, 16, 13, 14, 16, 16, 16, 16, 16, 16, 14, 14,
- 12, 16, 13, 16, 12, 16, 13, 14, 13, 16, 14, 16, 13, 16, 13, 14,
- 16, 16, 16, 16, 14, 16, 14, 14, 14, 16, 13, 16, 14, 16, 13, 13,
- 13, 16, 13, 16, 14, 16, 13, 13, 15, 16, 13, 14, 13, 15, 12, 12,
- },
- },
- {
- {
- 0, 7, 4, 6, 4, 7, 6, 7, 6, 9, 7, 8, 7, 9, 8, 8,
- 13, 14, 12, 12, 12, 13, 11, 11, 5, 9, 5, 8, 7, 9, 7, 8,
- 8, 11, 8, 10, 9, 10, 9, 9, 13, 15, 12, 13, 12, 13, 11, 11,
- 9, 14, 8, 11, 11, 13, 10, 10, 11, 15, 10, 12, 12, 13, 10, 11,
- 14, 16, 12, 13, 14, 14, 12, 11, 5, 9, 7, 9, 6, 9, 8, 8,
- 8, 11, 8, 10, 8, 10, 9, 9, 13, 16, 12, 13, 13, 13, 11, 11,
- 7, 11, 8, 10, 9, 11, 9, 9, 9, 13, 9, 11, 10, 11, 10, 10,
- 14, 16, 12, 13, 13, 13, 12, 11, 11, 16, 10, 12, 12, 14, 11, 11,
- 13, 16, 11, 13, 13, 14, 11, 11, 16, 16, 13, 14, 14, 15, 12, 11,
- 10, 15, 11, 13, 9, 12, 10, 10, 12, 16, 12, 13, 11, 12, 11, 11,
- 15, 16, 13, 14, 13, 14, 12, 11, 12, 16, 12, 14, 11, 13, 11, 11,
- 13, 16, 12, 14, 12, 13, 12, 11, 16, 16, 13, 14, 14, 14, 12, 11,
- 14, 16, 13, 14, 14, 15, 12, 12, 16, 16, 13, 14, 14, 16, 12, 12,
- 16, 16, 14, 14, 14, 15, 12, 11, 3, 9, 5, 8, 6, 9, 7, 8,
- 7, 11, 8, 10, 9, 10, 9, 9, 13, 14, 12, 13, 13, 13, 12, 11,
- 6, 11, 6, 9, 8, 10, 8, 9, 9, 12, 8, 10, 10, 11, 9, 10,
- 14, 16, 12, 13, 13, 14, 12, 11, 9, 14, 8, 11, 11, 13, 10, 10,
- 12, 16, 10, 12, 12, 14, 11, 11, 16, 16, 12, 13, 14, 15, 12, 11,
- 6, 11, 8, 10, 7, 10, 8, 9, 9, 12, 9, 11, 9, 11, 10, 10,
- 14, 16, 13, 13, 13, 14, 12, 11, 8, 12, 9, 11, 9, 11, 9, 10,
- 10, 13, 9, 11, 10, 12, 10, 10, 14, 16, 12, 13, 13, 14, 12, 11,
- 12, 16, 10, 12, 12, 14, 11, 11, 12, 16, 10, 12, 13, 14, 11, 11,
- 15, 16, 12, 13, 14, 14, 11, 11, 10, 15, 11, 13, 9, 12, 10, 10,
- 12, 16, 12, 14, 11, 13, 11, 11, 16, 16, 14, 14, 14, 14, 12, 11,
- 12, 16, 12, 14, 11, 13, 11, 11, 13, 16, 12, 14, 11, 13, 11, 11,
- 16, 16, 13, 14, 13, 14, 12, 11, 14, 16, 13, 14, 14, 15, 12, 11,
- 14, 16, 13, 14, 13, 15, 12, 11, 16, 16, 13, 14, 13, 14, 11, 10,
- 6, 13, 8, 11, 9, 12, 10, 10, 10, 14, 10, 12, 11, 13, 11, 11,
- 16, 16, 13, 14, 14, 14, 13, 12, 8, 14, 8, 12, 10, 13, 10, 11,
- 11, 15, 10, 12, 12, 13, 11, 11, 16, 16, 14, 14, 15, 16, 13, 12,
- 11, 16, 9, 12, 12, 14, 11, 11, 13, 16, 11, 13, 13, 16, 11, 11,
- 16, 16, 13, 14, 16, 16, 13, 12, 8, 14, 10, 12, 9, 12, 10, 11,
- 11, 15, 11, 13, 11, 13, 11, 11, 16, 16, 14, 15, 14, 15, 13, 12,
- 10, 15, 10, 13, 11, 13, 11, 11, 11, 15, 11, 13, 12, 13, 11, 11,
- 16, 16, 13, 15, 14, 15, 13, 12, 12, 16, 11, 13, 13, 15, 11, 11,
- 13, 16, 11, 13, 13, 15, 11, 11, 16, 16, 12, 14, 14, 16, 12, 11,
- 11, 16, 12, 14, 10, 13, 11, 11, 13, 16, 13, 15, 12, 14, 12, 12,
- 16, 16, 15, 16, 14, 15, 13, 12, 12, 16, 13, 14, 12, 14, 12, 12,
- 13, 16, 13, 14, 12, 14, 12, 12, 16, 16, 14, 15, 13, 14, 12, 12,
- 15, 16, 13, 15, 14, 16, 12, 12, 14, 16, 13, 14, 13, 15, 12, 12,
- 15, 16, 12, 13, 13, 14, 11, 10, 9, 15, 10, 13, 11, 14, 11, 12,
- 12, 16, 12, 14, 12, 14, 12, 12, 16, 16, 14, 14, 14, 15, 13, 12,
- 10, 16, 10, 13, 12, 14, 12, 12, 13, 16, 12, 14, 13, 15, 12, 12,
- 16, 16, 14, 14, 15, 16, 13, 12, 11, 16, 9, 12, 13, 15, 11, 11,
- 14, 16, 11, 13, 14, 16, 11, 11, 16, 16, 13, 14, 16, 16, 12, 11,
- 10, 16, 11, 14, 11, 14, 12, 12, 13, 16, 13, 14, 12, 14, 12, 12,
- 16, 16, 14, 15, 15, 15, 13, 12, 11, 16, 12, 14, 12, 15, 12, 12,
- 13, 16, 12, 14, 13, 15, 12, 12, 16, 16, 14, 15, 15, 16, 13, 12,
- 12, 16, 11, 13, 13, 15, 11, 11, 13, 16, 11, 13, 13, 15, 11, 11,
- 16, 16, 12, 13, 14, 16, 12, 10, 11, 16, 12, 14, 10, 13, 11, 11,
- 14, 16, 13, 14, 12, 14, 11, 11, 16, 16, 15, 16, 14, 14, 12, 11,
- 12, 16, 13, 14, 11, 14, 11, 11, 13, 16, 13, 14, 12, 14, 11, 11,
- 16, 16, 14, 15, 13, 14, 12, 11, 14, 16, 12, 14, 13, 14, 11, 10,
- 13, 16, 12, 13, 12, 14, 11, 10, 14, 16, 11, 12, 12, 12, 10, 8,
- },
- {
- 0, 8, 4, 9, 5, 9, 8, 10, 6, 11, 8, 11, 9, 12, 11, 12,
- 16, 16, 16, 16, 16, 16, 16, 16, 4, 11, 6, 11, 9, 12, 10, 12,
- 9, 13, 10, 13, 11, 16, 12, 13, 16, 16, 16, 16, 16, 16, 16, 16,
- 11, 16, 11, 16, 16, 16, 14, 16, 14, 16, 13, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 4, 11, 8, 12, 7, 12, 10, 12,
- 8, 13, 10, 13, 10, 13, 12, 14, 16, 16, 16, 16, 16, 16, 16, 16,
- 8, 13, 10, 14, 11, 16, 12, 14, 11, 16, 12, 16, 12, 16, 13, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 14, 16, 13, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 14, 16, 12, 16, 16, 16, 13, 16, 16, 16, 14, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 14, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 1, 10, 5, 10, 7, 11, 9, 11,
- 8, 12, 9, 12, 10, 13, 12, 13, 16, 16, 16, 16, 16, 16, 16, 16,
- 5, 12, 7, 12, 10, 13, 11, 12, 9, 16, 10, 13, 12, 16, 13, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 11, 16, 10, 16, 16, 16, 14, 16,
- 14, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 6, 12, 9, 13, 8, 12, 11, 13, 10, 16, 11, 16, 11, 16, 13, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 9, 16, 10, 14, 11, 16, 12, 16,
- 10, 16, 11, 16, 12, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 14, 16, 13, 16, 16, 16, 16, 16, 16, 16, 13, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 12, 16, 14, 16, 11, 16, 14, 16,
- 16, 16, 16, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 6, 16, 9, 13, 10, 16, 12, 14, 11, 16, 12, 16, 12, 16, 13, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 8, 16, 9, 14, 12, 16, 13, 16,
- 12, 16, 12, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 10, 16, 16, 16, 14, 16, 16, 16, 13, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 8, 16, 11, 16, 10, 16, 12, 16,
- 12, 16, 13, 16, 13, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 12, 16, 13, 16, 14, 16, 11, 16, 13, 16, 13, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 14, 16, 13, 16, 16, 16, 16, 16,
- 14, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 16, 16, 11, 16, 14, 16, 16, 16, 16, 16, 14, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 14, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 8, 16, 11, 16, 12, 16, 13, 16,
- 13, 16, 13, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 11, 16, 13, 16, 14, 16, 14, 16, 13, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 11, 16, 10, 16, 16, 16, 13, 16,
- 16, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 12, 16, 12, 16, 13, 16, 13, 16, 16, 16, 14, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 11, 16, 13, 16, 14, 16, 16, 16,
- 13, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 13, 16, 12, 16, 16, 16, 14, 16, 14, 16, 13, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 11, 16, 13, 16, 11, 16, 13, 16,
- 16, 16, 16, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 13, 16, 16, 16, 13, 16, 16, 16, 13, 16, 16, 16, 13, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 16, 16, 16, 14, 15,
- },
- },
- {
- {
- 0, 7, 3, 7, 4, 7, 6, 7, 6, 9, 7, 9, 7, 9, 8, 9,
- 13, 14, 12, 13, 13, 13, 12, 12, 4, 9, 5, 9, 7, 9, 8, 9,
- 7, 11, 8, 10, 9, 11, 9, 10, 13, 16, 12, 14, 13, 14, 12, 12,
- 9, 14, 8, 12, 12, 14, 10, 11, 11, 16, 10, 13, 13, 14, 11, 12,
- 15, 16, 13, 14, 14, 16, 12, 12, 5, 10, 7, 9, 6, 9, 8, 9,
- 8, 11, 8, 11, 8, 10, 9, 10, 14, 16, 12, 14, 13, 14, 12, 12,
- 7, 12, 8, 11, 9, 11, 9, 10, 9, 13, 9, 12, 10, 12, 10, 11,
- 14, 16, 12, 14, 13, 14, 12, 12, 12, 16, 11, 13, 13, 15, 11, 12,
- 13, 16, 11, 14, 13, 15, 12, 12, 15, 16, 13, 15, 14, 16, 13, 13,
- 10, 15, 12, 14, 9, 13, 11, 12, 12, 16, 12, 14, 11, 13, 12, 12,
- 15, 16, 13, 15, 14, 15, 13, 13, 12, 16, 12, 14, 12, 14, 12, 12,
- 13, 16, 13, 14, 12, 14, 12, 12, 16, 16, 14, 15, 14, 16, 13, 13,
- 15, 16, 13, 15, 14, 16, 12, 13, 16, 16, 14, 16, 14, 16, 13, 13,
- 16, 16, 14, 16, 15, 16, 13, 13, 3, 9, 5, 9, 6, 9, 8, 9,
- 7, 11, 8, 10, 9, 11, 9, 10, 14, 15, 13, 14, 13, 14, 12, 12,
- 5, 11, 6, 10, 8, 11, 9, 10, 9, 12, 9, 11, 10, 12, 10, 11,
- 14, 16, 13, 14, 14, 15, 13, 13, 9, 15, 8, 12, 12, 14, 10, 11,
- 12, 16, 10, 13, 13, 15, 11, 12, 15, 16, 13, 14, 14, 16, 13, 13,
- 6, 11, 8, 11, 7, 10, 9, 10, 9, 13, 10, 12, 9, 12, 10, 11,
- 14, 16, 13, 14, 14, 14, 13, 13, 8, 13, 9, 12, 9, 12, 10, 11,
- 9, 13, 9, 12, 10, 12, 10, 11, 14, 16, 12, 14, 13, 14, 12, 12,
- 12, 16, 11, 13, 13, 15, 11, 12, 12, 16, 11, 13, 13, 15, 11, 12,
- 14, 16, 12, 14, 14, 15, 12, 12, 10, 15, 11, 14, 9, 13, 11, 12,
- 12, 16, 12, 14, 11, 14, 12, 12, 16, 16, 14, 16, 14, 15, 13, 13,
- 12, 16, 12, 14, 11, 14, 12, 12, 12, 16, 13, 14, 11, 14, 12, 12,
- 15, 16, 14, 15, 13, 15, 12, 13, 14, 16, 13, 15, 14, 16, 13, 13,
- 14, 16, 13, 15, 14, 16, 12, 13, 15, 16, 13, 15, 13, 15, 12, 12,
- 6, 13, 8, 12, 9, 12, 10, 11, 10, 14, 11, 13, 11, 13, 12, 12,
- 15, 16, 14, 15, 15, 15, 14, 13, 8, 14, 9, 12, 11, 13, 11, 12,
- 11, 15, 11, 13, 12, 14, 12, 12, 16, 16, 14, 15, 15, 16, 14, 14,
- 10, 16, 9, 13, 12, 15, 11, 12, 13, 16, 11, 14, 13, 16, 12, 12,
- 16, 16, 14, 15, 16, 16, 13, 13, 8, 14, 10, 13, 9, 13, 11, 12,
- 11, 15, 12, 14, 11, 14, 12, 12, 16, 16, 15, 16, 15, 16, 14, 14,
- 10, 15, 10, 13, 11, 14, 11, 12, 11, 15, 11, 14, 12, 14, 12, 12,
- 15, 16, 14, 15, 14, 16, 13, 13, 12, 16, 11, 14, 13, 16, 12, 12,
- 12, 16, 11, 14, 13, 15, 12, 12, 15, 16, 12, 14, 15, 16, 13, 13,
- 11, 16, 12, 14, 10, 14, 11, 12, 13, 16, 13, 16, 12, 14, 12, 13,
- 16, 16, 16, 16, 15, 16, 14, 13, 12, 16, 13, 15, 12, 14, 12, 13,
- 13, 16, 13, 15, 12, 14, 12, 13, 16, 16, 14, 16, 13, 15, 13, 13,
- 15, 16, 14, 16, 14, 16, 13, 13, 14, 16, 13, 15, 13, 16, 13, 13,
- 14, 16, 12, 14, 13, 14, 12, 12, 9, 16, 11, 14, 11, 15, 12, 13,
- 13, 16, 12, 14, 12, 15, 13, 13, 16, 16, 14, 15, 15, 15, 14, 13,
- 11, 16, 11, 14, 12, 16, 12, 13, 13, 16, 12, 14, 13, 16, 13, 13,
- 16, 16, 14, 15, 16, 16, 14, 13, 11, 16, 10, 13, 13, 16, 11, 12,
- 14, 16, 11, 14, 14, 16, 12, 12, 16, 16, 14, 14, 16, 16, 13, 12,
- 11, 16, 12, 14, 11, 15, 12, 13, 13, 16, 13, 15, 13, 16, 13, 13,
- 16, 16, 15, 16, 15, 16, 14, 13, 11, 16, 12, 15, 12, 16, 12, 13,
- 13, 16, 13, 15, 13, 16, 13, 13, 16, 16, 15, 16, 15, 16, 14, 13,
- 12, 16, 11, 14, 13, 16, 12, 12, 13, 16, 11, 14, 13, 16, 12, 12,
- 16, 16, 13, 14, 15, 16, 12, 12, 11, 16, 12, 14, 10, 14, 11, 12,
- 14, 16, 13, 15, 12, 15, 12, 12, 16, 16, 16, 16, 14, 15, 13, 12,
- 12, 16, 13, 15, 12, 14, 12, 12, 13, 16, 13, 15, 12, 14, 12, 12,
- 16, 16, 14, 16, 14, 15, 12, 12, 14, 16, 13, 15, 13, 16, 11, 12,
- 13, 16, 12, 14, 13, 15, 11, 11, 14, 16, 12, 13, 12, 13, 11, 10,
- },
- {
- 0, 8, 4, 9, 5, 10, 9, 11, 5, 11, 9, 12, 9, 13, 12, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 4, 11, 6, 12, 9, 13, 11, 13,
- 9, 16, 10, 16, 12, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 11, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 4, 12, 8, 13, 7, 12, 11, 16,
- 8, 16, 11, 16, 11, 16, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 8, 16, 10, 16, 11, 16, 13, 16, 11, 16, 12, 16, 13, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 16, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 1, 10, 6, 11, 7, 12, 10, 13,
- 7, 12, 10, 13, 10, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 5, 13, 7, 12, 10, 16, 12, 16, 10, 16, 11, 16, 12, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 11, 16, 11, 16, 16, 16, 16, 16,
- 16, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 5, 13, 9, 16, 8, 16, 12, 16, 9, 16, 12, 16, 11, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 9, 16, 11, 16, 12, 16, 13, 16,
- 10, 16, 12, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 12, 16, 16, 16, 12, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 6, 16, 9, 16, 10, 16, 13, 16, 11, 16, 12, 16, 13, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 8, 16, 9, 16, 12, 16, 13, 16,
- 12, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 11, 16, 10, 16, 16, 16, 16, 16, 16, 16, 13, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 8, 16, 11, 16, 11, 16, 13, 16,
- 12, 16, 13, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 12, 16, 13, 16, 16, 16, 11, 16, 13, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 15, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 16, 16, 11, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 7, 16, 11, 16, 12, 16, 16, 16,
- 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 11, 16, 13, 16, 16, 16, 16, 16, 13, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 11, 16, 10, 16, 16, 16, 16, 16,
- 16, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 12, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 11, 16, 13, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 13, 16, 12, 16, 16, 16, 16, 16, 16, 16, 12, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 11, 16, 16, 16, 11, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 13, 16, 16, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- },
- },
- {
- {
- 0, 7, 4, 8, 4, 8, 7, 8, 6, 10, 7, 10, 8, 10, 9, 10,
- 13, 16, 13, 15, 13, 15, 13, 14, 4, 10, 5, 10, 7, 10, 9, 10,
- 7, 12, 8, 11, 9, 12, 10, 11, 13, 16, 13, 15, 13, 16, 13, 14,
- 9, 16, 9, 13, 12, 16, 11, 13, 11, 16, 11, 14, 13, 16, 12, 14,
- 15, 16, 14, 16, 15, 16, 14, 14, 4, 10, 7, 10, 6, 10, 9, 10,
- 8, 12, 9, 12, 9, 11, 10, 12, 13, 16, 13, 16, 14, 16, 13, 14,
- 7, 12, 8, 12, 9, 12, 10, 12, 9, 13, 10, 13, 10, 13, 11, 12,
- 14, 16, 13, 16, 14, 16, 13, 14, 12, 16, 11, 14, 13, 16, 12, 14,
- 13, 16, 12, 16, 14, 16, 13, 14, 16, 16, 14, 16, 15, 16, 14, 14,
- 10, 16, 12, 15, 10, 14, 12, 13, 12, 16, 13, 16, 12, 14, 13, 14,
- 15, 16, 14, 16, 14, 16, 14, 14, 12, 16, 13, 16, 12, 16, 13, 14,
- 13, 16, 13, 16, 13, 16, 13, 14, 16, 16, 14, 16, 15, 16, 14, 15,
- 15, 16, 14, 16, 15, 16, 13, 15, 16, 16, 14, 16, 15, 16, 14, 15,
- 16, 16, 16, 16, 16, 16, 15, 15, 2, 9, 5, 10, 6, 10, 8, 10,
- 7, 11, 8, 11, 9, 11, 10, 11, 14, 16, 13, 15, 14, 15, 14, 14,
- 5, 11, 6, 11, 8, 12, 9, 11, 8, 13, 9, 12, 10, 13, 11, 12,
- 14, 16, 13, 15, 14, 16, 14, 14, 9, 16, 8, 13, 12, 16, 11, 13,
- 12, 16, 11, 14, 13, 16, 12, 13, 16, 16, 14, 16, 15, 16, 14, 15,
- 5, 12, 8, 11, 7, 11, 9, 11, 9, 13, 10, 13, 10, 13, 11, 12,
- 14, 16, 14, 16, 14, 16, 14, 15, 8, 13, 9, 13, 10, 13, 11, 12,
- 9, 13, 10, 13, 10, 13, 11, 13, 13, 16, 13, 15, 13, 16, 13, 14,
- 12, 16, 11, 14, 13, 16, 12, 14, 12, 16, 11, 14, 13, 16, 12, 14,
- 14, 16, 13, 16, 14, 16, 13, 14, 10, 16, 12, 15, 9, 14, 11, 13,
- 12, 16, 13, 16, 12, 15, 12, 14, 16, 16, 15, 16, 15, 16, 14, 14,
- 12, 16, 13, 16, 12, 16, 12, 14, 12, 16, 13, 16, 12, 15, 13, 14,
- 15, 16, 14, 16, 14, 16, 14, 14, 15, 16, 14, 16, 14, 16, 14, 15,
- 14, 16, 13, 16, 14, 16, 13, 14, 16, 16, 14, 16, 14, 16, 13, 14,
- 6, 14, 9, 13, 9, 14, 11, 12, 10, 14, 11, 13, 11, 14, 12, 13,
- 16, 16, 15, 16, 15, 16, 14, 15, 8, 15, 9, 13, 11, 14, 11, 13,
- 11, 16, 11, 14, 12, 15, 12, 14, 16, 16, 15, 16, 16, 16, 15, 16,
- 10, 16, 9, 14, 12, 16, 12, 13, 13, 16, 11, 15, 14, 16, 13, 14,
- 16, 16, 15, 16, 16, 16, 15, 16, 8, 15, 10, 13, 10, 14, 11, 13,
- 11, 16, 12, 14, 12, 14, 12, 14, 16, 16, 16, 16, 16, 16, 15, 16,
- 10, 16, 11, 14, 11, 15, 12, 13, 11, 16, 11, 14, 12, 15, 12, 14,
- 16, 16, 14, 16, 15, 16, 14, 15, 12, 16, 11, 15, 13, 16, 13, 14,
- 12, 16, 11, 14, 13, 16, 13, 14, 15, 16, 13, 16, 16, 16, 14, 15,
- 10, 16, 12, 15, 10, 15, 12, 13, 13, 16, 13, 16, 12, 16, 13, 14,
- 16, 16, 16, 16, 16, 16, 15, 15, 12, 16, 13, 16, 12, 16, 13, 14,
- 12, 16, 13, 16, 12, 16, 13, 14, 16, 16, 15, 16, 14, 16, 14, 15,
- 15, 16, 14, 16, 15, 16, 14, 15, 14, 16, 13, 16, 14, 16, 13, 14,
- 14, 16, 13, 15, 14, 16, 13, 14, 9, 16, 11, 16, 11, 16, 12, 14,
- 13, 16, 12, 16, 13, 16, 13, 14, 16, 16, 15, 16, 16, 16, 15, 15,
- 11, 16, 11, 16, 12, 16, 13, 14, 13, 16, 12, 16, 13, 16, 13, 14,
- 16, 16, 15, 16, 16, 16, 15, 15, 11, 16, 10, 15, 13, 16, 12, 13,
- 14, 16, 12, 16, 14, 16, 13, 14, 16, 16, 15, 16, 16, 16, 14, 14,
- 11, 16, 12, 16, 11, 16, 13, 14, 13, 16, 13, 16, 13, 16, 13, 14,
- 16, 16, 16, 16, 16, 16, 15, 15, 11, 16, 12, 16, 12, 16, 13, 14,
- 13, 16, 13, 16, 13, 16, 13, 14, 16, 16, 15, 16, 16, 16, 15, 14,
- 12, 16, 12, 15, 13, 16, 12, 14, 13, 16, 12, 16, 14, 16, 13, 14,
- 16, 16, 14, 16, 16, 16, 14, 14, 11, 16, 12, 16, 11, 16, 12, 14,
- 14, 16, 14, 16, 12, 16, 13, 14, 16, 16, 16, 16, 16, 16, 15, 14,
- 12, 16, 13, 16, 12, 16, 12, 14, 13, 16, 13, 16, 12, 16, 13, 14,
- 16, 16, 16, 16, 15, 16, 14, 14, 14, 16, 13, 16, 14, 16, 12, 14,
- 13, 16, 13, 16, 13, 16, 12, 13, 15, 16, 13, 14, 14, 15, 13, 13,
- },
- {
- 0, 8, 4, 10, 5, 11, 10, 16, 5, 12, 9, 16, 10, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 4, 12, 7, 12, 9, 16, 12, 16,
- 9, 16, 11, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 4, 12, 9, 16, 8, 16, 12, 16,
- 8, 16, 11, 16, 11, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 8, 16, 11, 16, 12, 16, 16, 16, 11, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 1, 11, 6, 12, 7, 16, 11, 16,
- 7, 16, 10, 16, 11, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 5, 16, 7, 16, 10, 16, 12, 16, 9, 16, 11, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 11, 16, 11, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 5, 16, 10, 16, 8, 16, 12, 16, 9, 16, 12, 16, 12, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 9, 16, 11, 16, 12, 16, 16, 16,
- 10, 16, 12, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 12, 16, 16, 16, 12, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 5, 16, 9, 16, 10, 16, 16, 16, 11, 16, 12, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 8, 16, 9, 16, 12, 16, 16, 16,
- 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 11, 16, 10, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 8, 16, 11, 16, 11, 16, 16, 16,
- 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 12, 16, 16, 16, 16, 16, 11, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 11, 16, 16, 16, 11, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 6, 16, 10, 16, 12, 16, 16, 16,
- 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 9, 16, 10, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 11, 16, 9, 16, 16, 16, 16, 16,
- 16, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 9, 16, 16, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 11, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 13, 16, 12, 16, 16, 16, 16, 16, 16, 16, 12, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 11, 16, 16, 16, 11, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- },
- },
- {
- {
- 0, 8, 4, 10, 5, 9, 8, 10, 6, 11, 8, 12, 8, 11, 10, 13,
- 14, 16, 14, 16, 14, 16, 16, 16, 3, 11, 5, 11, 8, 12, 10, 12,
- 7, 12, 9, 13, 10, 13, 11, 13, 14, 16, 14, 16, 16, 16, 16, 16,
- 9, 16, 9, 16, 12, 16, 12, 16, 11, 16, 11, 16, 14, 16, 13, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 4, 11, 7, 12, 6, 11, 10, 12,
- 8, 13, 9, 13, 9, 13, 11, 14, 13, 16, 14, 16, 14, 16, 16, 16,
- 7, 13, 9, 13, 9, 13, 11, 13, 9, 14, 10, 16, 11, 16, 12, 16,
- 15, 16, 14, 16, 16, 16, 16, 16, 12, 16, 12, 16, 14, 16, 13, 16,
- 13, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 12, 16, 10, 16, 13, 16, 12, 16, 13, 16, 12, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 12, 16, 13, 16, 13, 16, 14, 16,
- 13, 16, 14, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 2, 10, 5, 11, 6, 11, 9, 11,
- 7, 12, 9, 13, 9, 13, 11, 13, 14, 16, 16, 16, 16, 16, 16, 16,
- 4, 12, 6, 12, 8, 13, 10, 13, 8, 13, 9, 13, 11, 16, 12, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 9, 16, 8, 16, 12, 16, 12, 16,
- 12, 16, 11, 16, 13, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 5, 12, 8, 13, 7, 13, 10, 13, 8, 14, 10, 14, 10, 14, 12, 14,
- 16, 16, 16, 16, 16, 16, 16, 16, 7, 14, 9, 16, 10, 16, 11, 14,
- 8, 14, 10, 16, 11, 16, 12, 16, 13, 16, 14, 16, 16, 16, 16, 16,
- 11, 16, 11, 16, 13, 16, 13, 16, 12, 16, 12, 16, 14, 16, 14, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 9, 16, 12, 16, 10, 16, 12, 16,
- 12, 16, 13, 16, 12, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 13, 16, 12, 16, 14, 16, 12, 16, 13, 16, 12, 16, 14, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 6, 16, 8, 16, 9, 16, 11, 13, 10, 16, 11, 16, 11, 16, 13, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 7, 16, 9, 16, 10, 16, 12, 16,
- 11, 16, 11, 16, 12, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 9, 16, 12, 16, 13, 16, 13, 16, 12, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 7, 16, 10, 16, 9, 16, 12, 16,
- 11, 16, 12, 16, 12, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 9, 16, 11, 16, 11, 16, 12, 16, 11, 16, 12, 16, 13, 16, 13, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 12, 16, 12, 16, 14, 16, 14, 16,
- 12, 16, 12, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 12, 16, 10, 16, 13, 16, 13, 16, 14, 16, 13, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 12, 16, 13, 16, 12, 16, 14, 16,
- 12, 16, 14, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 14, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 9, 16, 11, 16, 11, 16, 13, 16,
- 12, 16, 13, 16, 13, 16, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 11, 16, 13, 16, 13, 16, 13, 16, 13, 16, 14, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 11, 16, 11, 16, 14, 16, 13, 16,
- 14, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 12, 16, 12, 16, 13, 16, 13, 16, 13, 16, 13, 16, 14, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 11, 16, 12, 16, 13, 16, 14, 16,
- 13, 16, 13, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 12, 16, 14, 16, 14, 16, 14, 16, 14, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 11, 16, 13, 16, 11, 16, 14, 16,
- 16, 16, 16, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 14, 16, 13, 16, 14, 16, 16, 16, 16, 16, 14, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- },
- {
- 0, 10, 4, 12, 5, 16, 11, 16, 6, 16, 10, 16, 11, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 3, 16, 7, 16, 10, 16, 16, 16,
- 9, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 4, 16, 10, 16, 9, 16, 16, 16,
- 9, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 9, 16, 12, 16, 16, 16, 16, 16, 11, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 1, 16, 6, 16, 8, 16, 16, 16,
- 8, 16, 11, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 5, 16, 8, 16, 11, 16, 16, 16, 10, 16, 12, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 12, 16, 11, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 5, 16, 11, 16, 9, 16, 16, 16, 10, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 9, 16, 12, 16, 16, 16, 16, 16,
- 10, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 5, 16, 9, 16, 11, 16, 16, 16, 11, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 8, 16, 10, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 11, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 8, 16, 16, 16, 11, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 16, 16, 16, 16, 16, 16, 12, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 12, 16, 16, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 6, 16, 11, 16, 15, 16, 16, 16,
- 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 9, 16, 10, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 11, 16, 9, 16, 16, 16, 16, 16,
- 16, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 10, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 11, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 12, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- },
- },
-};
-
-static const uint8_t rv34_table_inter_secondpat[NUM_INTER_TABLES][2][OTHERBLK_VLC_SIZE] = {
- {
- {
- 0, 4, 8, 3, 6, 8, 6, 7, 8, 4, 6, 8, 6, 7, 8, 7,
- 8, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 3, 6, 8, 4, 6,
- 9, 7, 7, 8, 5, 7, 9, 6, 7, 9, 8, 8, 8, 7, 8, 8,
- 8, 8, 8, 8, 8, 7, 6, 8, 9, 7, 8, 9, 7, 8, 9, 7,
- 8, 9, 7, 8, 9, 8, 8, 9, 8, 8, 9, 8, 9, 9, 8, 8,
- 8, 8, 9, 9, 8, 9, 9, 7, 8, 8, 8, 9, 9, 8, 9, 9,
- 8, 8, 8, 7, 8, 8, 8, 8, 8, 7, 7, 6,
- },
- {
- 0, 4, 9, 3, 6, 9, 7, 8, 10, 3, 6, 9, 5, 7, 10, 9,
- 9, 10, 7, 8, 10, 8, 9, 10, 10, 10, 10, 2, 6, 9, 4, 7,
- 10, 8, 9, 10, 4, 7, 10, 6, 7, 10, 9, 9, 10, 7, 8, 10,
- 8, 9, 10, 10, 10, 10, 6, 8, 10, 7, 9, 11, 9, 10, 11, 7,
- 9, 11, 8, 9, 11, 10, 10, 11, 8, 9, 11, 9, 10, 11, 11, 11,
- 10, 8, 10, 11, 9, 10, 11, 9, 10, 11, 8, 10, 11, 9, 10, 11,
- 10, 10, 11, 8, 10, 11, 9, 10, 10, 10, 10, 9,
- },
- },
- {
- {
- 0, 4, 8, 3, 6, 8, 6, 7, 9, 4, 6, 8, 5, 7, 8, 8,
- 8, 9, 7, 7, 8, 8, 8, 8, 8, 9, 8, 3, 6, 8, 4, 6,
- 9, 7, 7, 9, 5, 6, 9, 6, 7, 9, 8, 8, 9, 7, 8, 8,
- 8, 8, 8, 8, 8, 8, 6, 8, 9, 7, 8, 10, 7, 8, 9, 7,
- 8, 10, 7, 8, 10, 8, 8, 9, 7, 8, 9, 8, 9, 9, 9, 9,
- 8, 7, 9, 10, 8, 9, 10, 8, 8, 8, 8, 9, 10, 8, 9, 9,
- 8, 8, 8, 7, 8, 8, 8, 8, 8, 8, 7, 6,
- },
- {
- 0, 4, 9, 3, 6, 10, 8, 9, 11, 3, 5, 9, 5, 7, 10, 9,
- 10, 11, 7, 8, 10, 9, 9, 11, 11, 11, 12, 2, 5, 10, 4, 7,
- 10, 8, 9, 11, 4, 6, 10, 6, 7, 10, 9, 10, 11, 7, 9, 10,
- 9, 9, 11, 11, 11, 11, 6, 8, 11, 7, 9, 11, 9, 10, 12, 7,
- 9, 11, 8, 9, 12, 10, 10, 12, 8, 10, 11, 10, 10, 11, 12, 11,
- 11, 8, 10, 12, 9, 11, 12, 10, 11, 12, 9, 10, 12, 10, 11, 12,
- 11, 11, 12, 9, 10, 12, 10, 10, 11, 11, 11, 10,
- },
- },
- {
- {
- 0, 4, 8, 3, 6, 9, 7, 8, 9, 4, 6, 8, 5, 7, 9, 8,
- 9, 9, 7, 8, 9, 8, 8, 9, 9, 9, 9, 2, 6, 9, 4, 6,
- 9, 7, 8, 10, 5, 7, 9, 6, 7, 9, 8, 8, 9, 7, 8, 9,
- 8, 8, 9, 9, 9, 9, 6, 8, 10, 7, 8, 10, 8, 9, 10, 6,
- 8, 10, 8, 8, 10, 9, 9, 10, 8, 9, 10, 9, 9, 10, 10, 10,
- 9, 8, 9, 10, 8, 9, 10, 8, 9, 10, 8, 9, 10, 9, 9, 10,
- 9, 9, 9, 8, 9, 9, 8, 9, 9, 9, 9, 8,
- },
- {
- 0, 4, 10, 3, 6, 10, 8, 10, 12, 2, 6, 10, 6, 8, 11, 10,
- 11, 12, 7, 9, 11, 9, 10, 12, 12, 13, 13, 2, 6, 10, 4, 7,
- 11, 9, 10, 13, 4, 7, 11, 7, 8, 11, 10, 11, 12, 8, 9, 12,
- 10, 10, 12, 12, 12, 13, 6, 9, 12, 8, 10, 13, 10, 12, 14, 7,
- 10, 13, 9, 10, 13, 11, 11, 13, 9, 11, 13, 11, 11, 13, 13, 13,
- 13, 9, 11, 13, 10, 12, 14, 11, 12, 14, 9, 11, 14, 11, 12, 14,
- 12, 12, 14, 9, 12, 13, 11, 12, 13, 13, 12, 12,
- },
- },
- {
- {
- 0, 4, 9, 3, 6, 9, 7, 8, 10, 3, 6, 9, 6, 7, 9, 9,
- 9, 10, 7, 8, 9, 8, 9, 10, 10, 10, 11, 2, 6, 9, 4, 7,
- 10, 7, 9, 10, 4, 7, 10, 6, 7, 10, 9, 9, 10, 7, 8, 10,
- 8, 9, 10, 10, 10, 10, 6, 8, 11, 7, 9, 11, 8, 10, 11, 6,
- 9, 11, 8, 9, 11, 9, 9, 11, 8, 9, 11, 9, 10, 11, 11, 10,
- 10, 8, 10, 11, 9, 10, 11, 9, 10, 11, 8, 10, 11, 9, 10, 11,
- 10, 10, 11, 8, 10, 11, 9, 10, 11, 10, 10, 10,
- },
- {
- 0, 4, 12, 3, 7, 12, 10, 11, 14, 3, 6, 12, 7, 9, 13, 12,
- 13, 14, 8, 11, 13, 11, 12, 14, 14, 14, 14, 1, 7, 12, 5, 8,
- 13, 10, 12, 14, 4, 8, 13, 8, 9, 13, 12, 13, 14, 9, 11, 14,
- 11, 12, 14, 14, 14, 14, 7, 10, 14, 9, 11, 14, 11, 13, 16, 8,
- 11, 14, 10, 12, 14, 13, 13, 16, 10, 12, 15, 12, 13, 15, 15, 15,
- 15, 10, 13, 15, 12, 13, 14, 13, 15, 15, 10, 13, 15, 12, 13, 15,
- 13, 14, 15, 10, 13, 14, 12, 13, 14, 14, 14, 14,
- },
- },
- {
- {
- 0, 4, 9, 3, 6, 10, 7, 9, 11, 3, 5, 9, 5, 7, 10, 9,
- 10, 12, 7, 8, 10, 9, 10, 11, 11, 12, 12, 2, 6, 10, 4, 7,
- 10, 7, 9, 12, 4, 7, 10, 6, 7, 11, 9, 10, 12, 7, 9, 11,
- 9, 9, 11, 11, 11, 12, 5, 8, 11, 7, 9, 12, 9, 10, 13, 6,
- 9, 12, 8, 9, 12, 10, 10, 12, 8, 10, 12, 10, 10, 12, 12, 12,
- 12, 8, 10, 12, 9, 11, 13, 10, 11, 13, 9, 11, 13, 10, 11, 13,
- 11, 11, 13, 9, 11, 12, 10, 11, 12, 11, 11, 12,
- },
- {
- 0, 4, 12, 3, 7, 13, 10, 12, 15, 3, 7, 13, 7, 9, 14, 12,
- 12, 13, 8, 11, 14, 11, 13, 15, 15, 14, 14, 1, 6, 13, 5, 8,
- 13, 10, 13, 15, 4, 8, 13, 8, 9, 14, 13, 13, 15, 8, 11, 14,
- 12, 12, 15, 15, 14, 14, 7, 10, 13, 9, 11, 13, 12, 14, 16, 8,
- 11, 14, 10, 12, 15, 13, 13, 16, 10, 12, 15, 12, 13, 15, 15, 14,
- 15, 11, 12, 14, 12, 14, 14, 13, 15, 15, 10, 12, 14, 12, 13, 15,
- 14, 15, 15, 10, 13, 13, 12, 13, 15, 14, 14, 15,
- },
- },
- {
- {
- 0, 5, 10, 3, 7, 11, 9, 11, 14, 3, 7, 11, 7, 8, 12, 11,
- 12, 14, 7, 9, 12, 10, 11, 14, 13, 14, 16, 1, 7, 11, 5, 8,
- 12, 9, 11, 15, 4, 8, 12, 7, 9, 13, 11, 12, 15, 8, 10, 13,
- 10, 11, 14, 14, 14, 16, 6, 9, 13, 8, 11, 14, 10, 13, 16, 7,
- 10, 14, 9, 11, 15, 12, 13, 16, 9, 11, 15, 12, 12, 15, 14, 14,
- 16, 10, 12, 14, 11, 13, 15, 12, 14, 16, 10, 12, 15, 11, 13, 16,
- 13, 14, 16, 10, 13, 16, 12, 13, 15, 14, 15, 16,
- },
- {
- 0, 5, 16, 3, 8, 14, 11, 13, 14, 2, 8, 14, 8, 10, 16, 13,
- 13, 14, 9, 13, 16, 12, 13, 16, 16, 14, 16, 1, 7, 14, 6, 10,
- 14, 12, 16, 16, 5, 9, 14, 9, 11, 16, 15, 16, 16, 10, 12, 16,
- 13, 13, 16, 16, 14, 16, 8, 11, 14, 11, 13, 14, 14, 14, 16, 8,
- 12, 14, 11, 13, 16, 16, 16, 16, 10, 12, 15, 13, 14, 16, 16, 16,
- 16, 11, 14, 14, 14, 15, 16, 16, 15, 16, 10, 13, 16, 13, 14, 14,
- 16, 16, 16, 10, 13, 16, 13, 14, 16, 16, 16, 16,
- },
- },
- {
- {
- 0, 5, 11, 3, 7, 13, 9, 12, 16, 3, 7, 12, 6, 9, 14, 11,
- 13, 16, 7, 10, 16, 11, 12, 16, 16, 16, 16, 1, 6, 12, 5, 9,
- 16, 9, 13, 16, 4, 8, 16, 7, 10, 16, 12, 15, 16, 7, 11, 16,
- 11, 12, 16, 16, 16, 16, 6, 10, 15, 8, 11, 16, 11, 14, 16, 7,
- 11, 16, 10, 12, 16, 13, 16, 16, 9, 13, 16, 13, 14, 16, 16, 16,
- 16, 10, 12, 16, 12, 16, 16, 16, 16, 16, 11, 13, 16, 13, 16, 16,
- 16, 16, 16, 12, 16, 16, 16, 16, 16, 16, 16, 16,
- },
- {
- 0, 5, 16, 3, 8, 16, 12, 12, 16, 2, 8, 16, 8, 10, 16, 13,
- 13, 16, 9, 13, 16, 12, 13, 16, 16, 16, 16, 1, 8, 16, 6, 10,
- 16, 12, 16, 16, 5, 9, 16, 9, 11, 16, 13, 16, 16, 9, 12, 14,
- 12, 12, 16, 16, 16, 16, 8, 11, 13, 11, 12, 16, 14, 16, 16, 8,
- 12, 16, 11, 13, 16, 16, 15, 16, 9, 13, 14, 12, 13, 16, 16, 16,
- 16, 10, 12, 13, 14, 13, 16, 16, 16, 16, 9, 13, 16, 13, 12, 16,
- 16, 16, 16, 10, 12, 16, 14, 15, 16, 16, 16, 16,
- },
- },
-};
-
-static const uint8_t rv34_table_inter_thirdpat[NUM_INTER_TABLES][2][OTHERBLK_VLC_SIZE] = {
- {
- {
- 0, 5, 8, 3, 6, 9, 6, 7, 9, 4, 6, 9, 6, 7, 9, 8,
- 8, 9, 7, 8, 9, 8, 9, 9, 9, 9, 9, 2, 6, 9, 4, 7,
- 9, 7, 8, 9, 5, 7, 9, 6, 7, 9, 8, 8, 9, 7, 8, 9,
- 8, 9, 9, 9, 9, 8, 5, 8, 10, 6, 8, 10, 8, 9, 9, 7,
- 8, 10, 7, 9, 10, 8, 9, 9, 8, 9, 10, 9, 9, 10, 9, 9,
- 9, 7, 9, 10, 8, 9, 10, 8, 8, 9, 8, 9, 10, 8, 9, 10,
- 8, 8, 9, 8, 9, 9, 8, 9, 9, 8, 8, 7,
- },
- {
- 0, 4, 9, 2, 6, 10, 7, 8, 10, 3, 6, 10, 6, 7, 10, 9,
- 9, 10, 8, 9, 11, 9, 10, 11, 10, 11, 11, 2, 6, 10, 4, 7,
- 10, 8, 9, 10, 5, 7, 10, 7, 8, 10, 9, 9, 10, 9, 10, 11,
- 10, 10, 11, 11, 11, 11, 6, 9, 11, 7, 9, 11, 9, 10, 12, 8,
- 9, 11, 8, 10, 11, 10, 10, 11, 10, 11, 12, 11, 11, 12, 11, 11,
- 11, 9, 11, 12, 10, 11, 12, 10, 11, 12, 10, 11, 12, 10, 11, 12,
- 11, 11, 12, 11, 12, 12, 11, 12, 12, 12, 11, 11,
- },
- },
- {
- {
- 0, 4, 9, 3, 6, 9, 6, 8, 9, 4, 6, 9, 5, 7, 9, 8,
- 8, 9, 7, 8, 10, 8, 9, 10, 9, 9, 9, 2, 6, 9, 4, 7,
- 9, 7, 8, 9, 5, 7, 9, 6, 7, 10, 8, 9, 9, 7, 9, 10,
- 8, 9, 10, 9, 9, 9, 5, 8, 10, 6, 8, 10, 8, 9, 10, 7,
- 8, 10, 7, 9, 11, 9, 9, 10, 8, 9, 10, 9, 10, 10, 10, 10,
- 9, 7, 9, 10, 8, 9, 11, 8, 9, 10, 8, 9, 11, 8, 9, 11,
- 9, 9, 10, 9, 9, 10, 9, 9, 10, 9, 9, 8,
- },
- {
- 0, 4, 9, 2, 5, 10, 7, 8, 11, 3, 6, 10, 6, 7, 10, 9,
- 10, 11, 8, 9, 11, 9, 10, 11, 11, 11, 12, 2, 6, 10, 4, 7,
- 10, 8, 9, 11, 5, 7, 10, 6, 8, 10, 9, 10, 11, 9, 10, 12,
- 10, 10, 12, 11, 12, 12, 6, 9, 11, 8, 9, 12, 9, 11, 13, 8,
- 10, 12, 9, 10, 12, 11, 11, 12, 10, 12, 13, 11, 12, 13, 13, 12,
- 13, 10, 11, 13, 10, 12, 13, 11, 12, 13, 11, 12, 13, 11, 12, 13,
- 12, 12, 13, 12, 13, 14, 13, 13, 14, 13, 13, 13,
- },
- },
- {
- {
- 0, 4, 9, 3, 6, 9, 7, 8, 10, 3, 6, 9, 5, 7, 10, 8,
- 9, 10, 7, 9, 10, 8, 9, 10, 10, 10, 10, 2, 6, 9, 4, 7,
- 10, 7, 9, 10, 4, 7, 10, 6, 8, 10, 8, 9, 10, 8, 9, 10,
- 9, 9, 10, 10, 10, 10, 5, 8, 11, 7, 9, 11, 8, 10, 11, 7,
- 9, 11, 8, 9, 11, 9, 10, 11, 9, 10, 11, 10, 10, 11, 11, 11,
- 11, 8, 10, 11, 9, 10, 11, 9, 10, 11, 9, 10, 12, 9, 10, 12,
- 10, 11, 11, 9, 10, 11, 10, 11, 11, 10, 10, 10,
- },
- {
- 0, 4, 10, 3, 6, 11, 8, 10, 12, 3, 6, 11, 6, 8, 11, 10,
- 11, 13, 9, 10, 13, 11, 12, 14, 13, 13, 14, 1, 6, 10, 5, 8,
- 12, 9, 10, 13, 5, 8, 11, 7, 9, 12, 11, 11, 13, 10, 12, 13,
- 11, 12, 14, 14, 13, 15, 7, 10, 12, 9, 11, 14, 11, 12, 15, 9,
- 11, 13, 10, 11, 14, 12, 12, 14, 12, 14, 16, 13, 13, 16, 14, 14,
- 16, 12, 13, 15, 12, 14, 15, 13, 14, 16, 13, 14, 16, 14, 14, 16,
- 14, 15, 16, 14, 16, 16, 15, 16, 16, 15, 15, 16,
- },
- },
- {
- {
- 0, 4, 9, 2, 6, 9, 7, 9, 11, 3, 6, 10, 6, 7, 10, 9,
- 10, 11, 7, 9, 10, 9, 10, 11, 11, 11, 12, 2, 6, 10, 4, 7,
- 10, 8, 9, 11, 5, 7, 10, 7, 8, 10, 9, 10, 11, 8, 9, 11,
- 9, 10, 11, 11, 12, 11, 6, 9, 11, 7, 10, 12, 9, 11, 12, 7,
- 10, 12, 9, 10, 12, 11, 11, 12, 9, 11, 12, 10, 11, 12, 12, 12,
- 12, 9, 11, 12, 9, 11, 13, 11, 12, 13, 9, 11, 13, 10, 12, 13,
- 11, 12, 13, 11, 12, 13, 11, 12, 13, 12, 13, 12,
- },
- {
- 0, 4, 11, 2, 6, 12, 9, 11, 16, 4, 7, 12, 7, 9, 15, 11,
- 12, 16, 10, 11, 16, 11, 13, 16, 16, 16, 16, 1, 6, 11, 5, 8,
- 16, 9, 12, 16, 6, 9, 15, 8, 10, 16, 12, 13, 16, 12, 14, 16,
- 12, 16, 16, 16, 16, 16, 8, 11, 14, 10, 12, 16, 12, 16, 16, 10,
- 13, 16, 12, 16, 16, 13, 14, 16, 14, 16, 16, 16, 16, 16, 16, 16,
- 16, 13, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- },
- },
- {
- {
- 0, 5, 9, 3, 6, 10, 8, 10, 12, 3, 6, 10, 6, 8, 10, 10,
- 11, 12, 8, 9, 11, 10, 10, 12, 13, 13, 13, 1, 6, 10, 5, 8,
- 11, 9, 11, 13, 5, 8, 11, 7, 9, 11, 11, 11, 13, 8, 9, 11,
- 10, 10, 12, 13, 13, 14, 6, 9, 12, 8, 11, 13, 11, 13, 15, 8,
- 10, 13, 10, 11, 13, 12, 13, 15, 10, 12, 13, 12, 12, 13, 14, 14,
- 14, 9, 12, 14, 11, 13, 15, 13, 15, 16, 11, 13, 15, 12, 14, 15,
- 14, 15, 16, 13, 14, 15, 14, 14, 15, 15, 16, 16,
- },
- {
- 0, 4, 16, 2, 7, 16, 10, 13, 16, 3, 8, 16, 7, 10, 16, 16,
- 16, 16, 12, 16, 16, 15, 16, 16, 16, 16, 16, 1, 7, 16, 6, 9,
- 16, 10, 16, 16, 7, 12, 16, 9, 13, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 9, 16, 16, 11, 13, 16, 16, 16, 16, 12,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- },
- },
- {
- {
- 0, 4, 9, 3, 6, 11, 9, 12, 16, 3, 6, 10, 6, 8, 11, 12,
- 13, 16, 8, 9, 12, 10, 11, 13, 16, 16, 16, 1, 6, 10, 5, 8,
- 12, 10, 13, 16, 5, 8, 11, 8, 9, 13, 13, 14, 16, 9, 10, 14,
- 11, 12, 15, 16, 16, 16, 6, 10, 13, 9, 12, 16, 14, 16, 16, 9,
- 12, 14, 11, 13, 16, 16, 16, 16, 12, 14, 16, 14, 16, 16, 16, 16,
- 16, 11, 16, 16, 13, 16, 16, 16, 16, 16, 12, 16, 16, 13, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- },
- {
- 0, 4, 16, 2, 8, 16, 10, 16, 16, 3, 9, 16, 8, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 1, 7, 16, 5, 10,
- 16, 16, 16, 16, 7, 16, 16, 11, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 10, 15, 16, 10, 16, 16, 16, 16, 16, 14,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- },
- },
- {
- {
- 0, 3, 9, 3, 7, 11, 11, 15, 16, 3, 6, 11, 7, 9, 12, 16,
- 16, 16, 8, 10, 16, 11, 16, 16, 16, 16, 16, 1, 6, 11, 6, 9,
- 15, 16, 16, 16, 5, 8, 16, 9, 11, 16, 16, 16, 16, 10, 16, 16,
- 16, 16, 16, 16, 16, 16, 7, 11, 16, 11, 16, 16, 16, 16, 16, 11,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- },
- {
- 0, 4, 16, 2, 8, 16, 16, 16, 16, 3, 12, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 1, 7, 16, 5, 12,
- 16, 16, 16, 16, 6, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 9, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- },
- },
-};
-
-
-static const uint8_t rv34_inter_coeff[NUM_INTER_TABLES][COEFF_VLC_SIZE] = {
-{
- 1, 2, 4, 4, 5, 5, 6, 7, 7, 7, 8, 8, 8, 9, 9, 10,
- 10, 10, 10, 11, 11, 11, 11, 12, 11, 11, 11, 13, 14, 15, 16, 16,
-},
-{
- 1, 2, 3, 5, 5, 6, 6, 7, 7, 8, 9, 9, 9, 10, 10, 10,
- 11, 11, 12, 12, 12, 12, 13, 13, 12, 12, 13, 14, 16, 16, 16, 16,
-},
-{
- 1, 2, 3, 4, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 12,
- 12, 12, 13, 13, 13, 14, 14, 15, 14, 14, 16, 16, 16, 16, 16, 16,
-},
-{
- 1, 2, 3, 4, 5, 6, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12,
- 13, 13, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
-},
-{
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
-},
-{
- 1, 2, 3, 4, 5, 6, 7, 8, 10, 10, 11, 11, 13, 12, 12, 13,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
-},
-{
- 1, 2, 3, 4, 5, 6, 7, 8, 10, 10, 10, 11, 14, 13, 15, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 16, 16, 16,
-}
-};
-
-#endif /* AVCODEC_RV34VLC_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/rv40.c b/src/thirdparty/ffmpeg/libavcodec/rv40.c
deleted file mode 100644
index 607485f9c..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/rv40.c
+++ /dev/null
@@ -1,580 +0,0 @@
-/*
- * RV40 decoder
- * Copyright (c) 2007 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
- */
-
-/**
- * @file
- * RV40 decoder
- */
-
-#include "libavutil/imgutils.h"
-
-#include "avcodec.h"
-#include "dsputil.h"
-#include "mpegvideo.h"
-#include "golomb.h"
-
-#include "rv34.h"
-#include "rv40vlc2.h"
-#include "rv40data.h"
-
-static VLC aic_top_vlc;
-static VLC aic_mode1_vlc[AIC_MODE1_NUM], aic_mode2_vlc[AIC_MODE2_NUM];
-static VLC ptype_vlc[NUM_PTYPE_VLCS], btype_vlc[NUM_BTYPE_VLCS];
-
-static const int16_t mode2_offs[] = {
- 0, 614, 1222, 1794, 2410, 3014, 3586, 4202, 4792, 5382, 5966, 6542,
- 7138, 7716, 8292, 8864, 9444, 10030, 10642, 11212, 11814
-};
-
-/**
- * Initialize all tables.
- */
-static av_cold void rv40_init_tables(void)
-{
- int i;
- static VLC_TYPE aic_table[1 << AIC_TOP_BITS][2];
- static VLC_TYPE aic_mode1_table[AIC_MODE1_NUM << AIC_MODE1_BITS][2];
- static VLC_TYPE aic_mode2_table[11814][2];
- static VLC_TYPE ptype_table[NUM_PTYPE_VLCS << PTYPE_VLC_BITS][2];
- static VLC_TYPE btype_table[NUM_BTYPE_VLCS << BTYPE_VLC_BITS][2];
-
- aic_top_vlc.table = aic_table;
- aic_top_vlc.table_allocated = 1 << AIC_TOP_BITS;
- init_vlc(&aic_top_vlc, AIC_TOP_BITS, AIC_TOP_SIZE,
- rv40_aic_top_vlc_bits, 1, 1,
- rv40_aic_top_vlc_codes, 1, 1, INIT_VLC_USE_NEW_STATIC);
- for(i = 0; i < AIC_MODE1_NUM; i++){
- // Every tenth VLC table is empty
- if((i % 10) == 9) continue;
- aic_mode1_vlc[i].table = &aic_mode1_table[i << AIC_MODE1_BITS];
- aic_mode1_vlc[i].table_allocated = 1 << AIC_MODE1_BITS;
- init_vlc(&aic_mode1_vlc[i], AIC_MODE1_BITS, AIC_MODE1_SIZE,
- aic_mode1_vlc_bits[i], 1, 1,
- aic_mode1_vlc_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC);
- }
- for(i = 0; i < AIC_MODE2_NUM; i++){
- aic_mode2_vlc[i].table = &aic_mode2_table[mode2_offs[i]];
- aic_mode2_vlc[i].table_allocated = mode2_offs[i + 1] - mode2_offs[i];
- init_vlc(&aic_mode2_vlc[i], AIC_MODE2_BITS, AIC_MODE2_SIZE,
- aic_mode2_vlc_bits[i], 1, 1,
- aic_mode2_vlc_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC);
- }
- for(i = 0; i < NUM_PTYPE_VLCS; i++){
- ptype_vlc[i].table = &ptype_table[i << PTYPE_VLC_BITS];
- ptype_vlc[i].table_allocated = 1 << PTYPE_VLC_BITS;
- ff_init_vlc_sparse(&ptype_vlc[i], PTYPE_VLC_BITS, PTYPE_VLC_SIZE,
- ptype_vlc_bits[i], 1, 1,
- ptype_vlc_codes[i], 1, 1,
- ptype_vlc_syms, 1, 1, INIT_VLC_USE_NEW_STATIC);
- }
- for(i = 0; i < NUM_BTYPE_VLCS; i++){
- btype_vlc[i].table = &btype_table[i << BTYPE_VLC_BITS];
- btype_vlc[i].table_allocated = 1 << BTYPE_VLC_BITS;
- ff_init_vlc_sparse(&btype_vlc[i], BTYPE_VLC_BITS, BTYPE_VLC_SIZE,
- btype_vlc_bits[i], 1, 1,
- btype_vlc_codes[i], 1, 1,
- btype_vlc_syms, 1, 1, INIT_VLC_USE_NEW_STATIC);
- }
-}
-
-/**
- * Get stored dimension from bitstream.
- *
- * If the width/height is the standard one then it's coded as a 3-bit index.
- * Otherwise it is coded as escaped 8-bit portions.
- */
-static int get_dimension(GetBitContext *gb, const int *dim)
-{
- int t = get_bits(gb, 3);
- int val = dim[t];
- if(val < 0)
- val = dim[get_bits1(gb) - val];
- if(!val){
- do{
- t = get_bits(gb, 8);
- val += t << 2;
- }while(t == 0xFF);
- }
- return val;
-}
-
-/**
- * Get encoded picture size - usually this is called from rv40_parse_slice_header.
- */
-static void rv40_parse_picture_size(GetBitContext *gb, int *w, int *h)
-{
- *w = get_dimension(gb, rv40_standard_widths);
- *h = get_dimension(gb, rv40_standard_heights);
-}
-
-static int rv40_parse_slice_header(RV34DecContext *r, GetBitContext *gb, SliceInfo *si)
-{
- int mb_bits;
- int w = r->s.width, h = r->s.height;
- int mb_size;
-
- memset(si, 0, sizeof(SliceInfo));
- if(get_bits1(gb))
- return -1;
- si->type = get_bits(gb, 2);
- if(si->type == 1) si->type = 0;
- si->quant = get_bits(gb, 5);
- if(get_bits(gb, 2))
- return -1;
- si->vlc_set = get_bits(gb, 2);
- skip_bits1(gb);
- si->pts = get_bits(gb, 13);
- if(!si->type || !get_bits1(gb))
- rv40_parse_picture_size(gb, &w, &h);
- if(av_image_check_size(w, h, 0, r->s.avctx) < 0)
- return -1;
- si->width = w;
- si->height = h;
- mb_size = ((w + 15) >> 4) * ((h + 15) >> 4);
- mb_bits = ff_rv34_get_start_offset(gb, mb_size);
- si->start = get_bits(gb, mb_bits);
-
- return 0;
-}
-
-/**
- * Decode 4x4 intra types array.
- */
-static int rv40_decode_intra_types(RV34DecContext *r, GetBitContext *gb, int8_t *dst)
-{
- MpegEncContext *s = &r->s;
- int i, j, k, v;
- int A, B, C;
- int pattern;
- int8_t *ptr;
-
- for(i = 0; i < 4; i++, dst += r->intra_types_stride){
- if(!i && s->first_slice_line){
- pattern = get_vlc2(gb, aic_top_vlc.table, AIC_TOP_BITS, 1);
- dst[0] = (pattern >> 2) & 2;
- dst[1] = (pattern >> 1) & 2;
- dst[2] = pattern & 2;
- dst[3] = (pattern << 1) & 2;
- continue;
- }
- ptr = dst;
- for(j = 0; j < 4; j++){
- /* Coefficients are read using VLC chosen by the prediction pattern
- * The first one (used for retrieving a pair of coefficients) is
- * constructed from the top, top right and left coefficients
- * The second one (used for retrieving only one coefficient) is
- * top + 10 * left.
- */
- A = ptr[-r->intra_types_stride + 1]; // it won't be used for the last coefficient in a row
- B = ptr[-r->intra_types_stride];
- C = ptr[-1];
- pattern = A + (B << 4) + (C << 8);
- for(k = 0; k < MODE2_PATTERNS_NUM; k++)
- if(pattern == rv40_aic_table_index[k])
- break;
- if(j < 3 && k < MODE2_PATTERNS_NUM){ //pattern is found, decoding 2 coefficients
- v = get_vlc2(gb, aic_mode2_vlc[k].table, AIC_MODE2_BITS, 2);
- *ptr++ = v/9;
- *ptr++ = v%9;
- j++;
- }else{
- if(B != -1 && C != -1)
- v = get_vlc2(gb, aic_mode1_vlc[B + C*10].table, AIC_MODE1_BITS, 1);
- else{ // tricky decoding
- v = 0;
- switch(C){
- case -1: // code 0 -> 1, 1 -> 0
- if(B < 2)
- v = get_bits1(gb) ^ 1;
- break;
- case 0:
- case 2: // code 0 -> 2, 1 -> 0
- v = (get_bits1(gb) ^ 1) << 1;
- break;
- }
- }
- *ptr++ = v;
- }
- }
- }
- return 0;
-}
-
-/**
- * Decode macroblock information.
- */
-static int rv40_decode_mb_info(RV34DecContext *r)
-{
- MpegEncContext *s = &r->s;
- GetBitContext *gb = &s->gb;
- int q, i;
- int prev_type = 0;
- int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
-
- if(!r->s.mb_skip_run) {
- r->s.mb_skip_run = svq3_get_ue_golomb(gb) + 1;
- if(r->s.mb_skip_run > (unsigned)s->mb_num)
- return -1;
- }
-
- if(--r->s.mb_skip_run)
- return RV34_MB_SKIP;
-
- if(r->avail_cache[6-4]){
- int blocks[RV34_MB_TYPES] = {0};
- int count = 0;
- if(r->avail_cache[6-1])
- blocks[r->mb_type[mb_pos - 1]]++;
- blocks[r->mb_type[mb_pos - s->mb_stride]]++;
- if(r->avail_cache[6-2])
- blocks[r->mb_type[mb_pos - s->mb_stride + 1]]++;
- if(r->avail_cache[6-5])
- blocks[r->mb_type[mb_pos - s->mb_stride - 1]]++;
- for(i = 0; i < RV34_MB_TYPES; i++){
- if(blocks[i] > count){
- count = blocks[i];
- prev_type = i;
- if(count>1)
- break;
- }
- }
- } else if (r->avail_cache[6-1])
- prev_type = r->mb_type[mb_pos - 1];
-
- if(s->pict_type == AV_PICTURE_TYPE_P){
- prev_type = block_num_to_ptype_vlc_num[prev_type];
- q = get_vlc2(gb, ptype_vlc[prev_type].table, PTYPE_VLC_BITS, 1);
- if(q < PBTYPE_ESCAPE)
- return q;
- q = get_vlc2(gb, ptype_vlc[prev_type].table, PTYPE_VLC_BITS, 1);
- av_log(s->avctx, AV_LOG_ERROR, "Dquant for P-frame\n");
- }else{
- prev_type = block_num_to_btype_vlc_num[prev_type];
- q = get_vlc2(gb, btype_vlc[prev_type].table, BTYPE_VLC_BITS, 1);
- if(q < PBTYPE_ESCAPE)
- return q;
- q = get_vlc2(gb, btype_vlc[prev_type].table, BTYPE_VLC_BITS, 1);
- av_log(s->avctx, AV_LOG_ERROR, "Dquant for B-frame\n");
- }
- return 0;
-}
-
-enum RV40BlockPos{
- POS_CUR,
- POS_TOP,
- POS_LEFT,
- POS_BOTTOM,
-};
-
-#define MASK_CUR 0x0001
-#define MASK_RIGHT 0x0008
-#define MASK_BOTTOM 0x0010
-#define MASK_TOP 0x1000
-#define MASK_Y_TOP_ROW 0x000F
-#define MASK_Y_LAST_ROW 0xF000
-#define MASK_Y_LEFT_COL 0x1111
-#define MASK_Y_RIGHT_COL 0x8888
-#define MASK_C_TOP_ROW 0x0003
-#define MASK_C_LAST_ROW 0x000C
-#define MASK_C_LEFT_COL 0x0005
-#define MASK_C_RIGHT_COL 0x000A
-
-static const int neighbour_offs_x[4] = { 0, 0, -1, 0 };
-static const int neighbour_offs_y[4] = { 0, -1, 0, 1 };
-
-static void rv40_adaptive_loop_filter(RV34DSPContext *rdsp,
- uint8_t *src, int stride, int dmode,
- int lim_q1, int lim_p1,
- int alpha, int beta, int beta2,
- int chroma, int edge, int dir)
-{
- int filter_p1, filter_q1;
- int strong;
- int lims;
-
- strong = rdsp->rv40_loop_filter_strength[dir](src, stride, beta, beta2,
- edge, &filter_p1, &filter_q1);
-
- lims = filter_p1 + filter_q1 + ((lim_q1 + lim_p1) >> 1) + 1;
-
- if (strong) {
- rdsp->rv40_strong_loop_filter[dir](src, stride, alpha,
- lims, dmode, chroma);
- } else if (filter_p1 & filter_q1) {
- rdsp->rv40_weak_loop_filter[dir](src, stride, 1, 1, alpha, beta,
- lims, lim_q1, lim_p1);
- } else if (filter_p1 | filter_q1) {
- rdsp->rv40_weak_loop_filter[dir](src, stride, filter_p1, filter_q1,
- alpha, beta, lims >> 1, lim_q1 >> 1,
- lim_p1 >> 1);
- }
-}
-
-/**
- * RV40 loop filtering function
- */
-static void rv40_loop_filter(RV34DecContext *r, int row)
-{
- MpegEncContext *s = &r->s;
- int mb_pos, mb_x;
- int i, j, k;
- uint8_t *Y, *C;
- int alpha, beta, betaY, betaC;
- int q;
- int mbtype[4]; ///< current macroblock and its neighbours types
- /**
- * flags indicating that macroblock can be filtered with strong filter
- * it is set only for intra coded MB and MB with DCs coded separately
- */
- int mb_strong[4];
- int clip[4]; ///< MB filter clipping value calculated from filtering strength
- /**
- * coded block patterns for luma part of current macroblock and its neighbours
- * Format:
- * LSB corresponds to the top left block,
- * each nibble represents one row of subblocks.
- */
- int cbp[4];
- /**
- * coded block patterns for chroma part of current macroblock and its neighbours
- * Format is the same as for luma with two subblocks in a row.
- */
- int uvcbp[4][2];
- /**
- * This mask represents the pattern of luma subblocks that should be filtered
- * in addition to the coded ones because because they lie at the edge of
- * 8x8 block with different enough motion vectors
- */
- unsigned mvmasks[4];
-
- mb_pos = row * s->mb_stride;
- for(mb_x = 0; mb_x < s->mb_width; mb_x++, mb_pos++){
- int mbtype = s->current_picture_ptr->f.mb_type[mb_pos];
- if(IS_INTRA(mbtype) || IS_SEPARATE_DC(mbtype))
- r->cbp_luma [mb_pos] = r->deblock_coefs[mb_pos] = 0xFFFF;
- if(IS_INTRA(mbtype))
- r->cbp_chroma[mb_pos] = 0xFF;
- }
- mb_pos = row * s->mb_stride;
- for(mb_x = 0; mb_x < s->mb_width; mb_x++, mb_pos++){
- int y_h_deblock, y_v_deblock;
- int c_v_deblock[2], c_h_deblock[2];
- int clip_left;
- int avail[4];
- unsigned y_to_deblock;
- int c_to_deblock[2];
-
- q = s->current_picture_ptr->f.qscale_table[mb_pos];
- alpha = rv40_alpha_tab[q];
- beta = rv40_beta_tab [q];
- betaY = betaC = beta * 3;
- if(s->width * s->height <= 176*144)
- betaY += beta;
-
- avail[0] = 1;
- avail[1] = row;
- avail[2] = mb_x;
- avail[3] = row < s->mb_height - 1;
- for(i = 0; i < 4; i++){
- if(avail[i]){
- int pos = mb_pos + neighbour_offs_x[i] + neighbour_offs_y[i]*s->mb_stride;
- mvmasks[i] = r->deblock_coefs[pos];
- mbtype [i] = s->current_picture_ptr->f.mb_type[pos];
- cbp [i] = r->cbp_luma[pos];
- uvcbp[i][0] = r->cbp_chroma[pos] & 0xF;
- uvcbp[i][1] = r->cbp_chroma[pos] >> 4;
- }else{
- mvmasks[i] = 0;
- mbtype [i] = mbtype[0];
- cbp [i] = 0;
- uvcbp[i][0] = uvcbp[i][1] = 0;
- }
- mb_strong[i] = IS_INTRA(mbtype[i]) || IS_SEPARATE_DC(mbtype[i]);
- clip[i] = rv40_filter_clip_tbl[mb_strong[i] + 1][q];
- }
- y_to_deblock = mvmasks[POS_CUR]
- | (mvmasks[POS_BOTTOM] << 16);
- /* This pattern contains bits signalling that horizontal edges of
- * the current block can be filtered.
- * That happens when either of adjacent subblocks is coded or lies on
- * the edge of 8x8 blocks with motion vectors differing by more than
- * 3/4 pel in any component (any edge orientation for some reason).
- */
- y_h_deblock = y_to_deblock
- | ((cbp[POS_CUR] << 4) & ~MASK_Y_TOP_ROW)
- | ((cbp[POS_TOP] & MASK_Y_LAST_ROW) >> 12);
- /* This pattern contains bits signalling that vertical edges of
- * the current block can be filtered.
- * That happens when either of adjacent subblocks is coded or lies on
- * the edge of 8x8 blocks with motion vectors differing by more than
- * 3/4 pel in any component (any edge orientation for some reason).
- */
- y_v_deblock = y_to_deblock
- | ((cbp[POS_CUR] << 1) & ~MASK_Y_LEFT_COL)
- | ((cbp[POS_LEFT] & MASK_Y_RIGHT_COL) >> 3);
- if(!mb_x)
- y_v_deblock &= ~MASK_Y_LEFT_COL;
- if(!row)
- y_h_deblock &= ~MASK_Y_TOP_ROW;
- if(row == s->mb_height - 1 || (mb_strong[POS_CUR] | mb_strong[POS_BOTTOM]))
- y_h_deblock &= ~(MASK_Y_TOP_ROW << 16);
- /* Calculating chroma patterns is similar and easier since there is
- * no motion vector pattern for them.
- */
- for(i = 0; i < 2; i++){
- c_to_deblock[i] = (uvcbp[POS_BOTTOM][i] << 4) | uvcbp[POS_CUR][i];
- c_v_deblock[i] = c_to_deblock[i]
- | ((uvcbp[POS_CUR] [i] << 1) & ~MASK_C_LEFT_COL)
- | ((uvcbp[POS_LEFT][i] & MASK_C_RIGHT_COL) >> 1);
- c_h_deblock[i] = c_to_deblock[i]
- | ((uvcbp[POS_TOP][i] & MASK_C_LAST_ROW) >> 2)
- | (uvcbp[POS_CUR][i] << 2);
- if(!mb_x)
- c_v_deblock[i] &= ~MASK_C_LEFT_COL;
- if(!row)
- c_h_deblock[i] &= ~MASK_C_TOP_ROW;
- if(row == s->mb_height - 1 || (mb_strong[POS_CUR] | mb_strong[POS_BOTTOM]))
- c_h_deblock[i] &= ~(MASK_C_TOP_ROW << 4);
- }
-
- for(j = 0; j < 16; j += 4){
- 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;
- int dither = j ? ij : i*4;
-
- // if bottom block is coded then we can filter its top edge
- // (or bottom edge of this block, which is the same)
- if(y_h_deblock & (MASK_BOTTOM << ij)){
- rv40_adaptive_loop_filter(&r->rdsp, Y+4*s->linesize,
- s->linesize, dither,
- y_to_deblock & (MASK_BOTTOM << ij) ? clip[POS_CUR] : 0,
- clip_cur, alpha, beta, betaY,
- 0, 0, 0);
- }
- // filter left block edge in ordinary mode (with low filtering strength)
- if(y_v_deblock & (MASK_CUR << ij) && (i || !(mb_strong[POS_CUR] | mb_strong[POS_LEFT]))){
- if(!i)
- clip_left = mvmasks[POS_LEFT] & (MASK_RIGHT << j) ? clip[POS_LEFT] : 0;
- else
- clip_left = y_to_deblock & (MASK_CUR << (ij-1)) ? clip[POS_CUR] : 0;
- rv40_adaptive_loop_filter(&r->rdsp, Y, s->linesize, dither,
- clip_cur,
- clip_left,
- alpha, beta, betaY, 0, 0, 1);
- }
- // filter top edge of the current macroblock when filtering strength is high
- if(!j && y_h_deblock & (MASK_CUR << i) && (mb_strong[POS_CUR] | mb_strong[POS_TOP])){
- rv40_adaptive_loop_filter(&r->rdsp, Y, s->linesize, dither,
- clip_cur,
- mvmasks[POS_TOP] & (MASK_TOP << i) ? clip[POS_TOP] : 0,
- alpha, beta, betaY, 0, 1, 0);
- }
- // filter left block edge in edge mode (with high filtering strength)
- if(y_v_deblock & (MASK_CUR << ij) && !i && (mb_strong[POS_CUR] | mb_strong[POS_LEFT])){
- clip_left = mvmasks[POS_LEFT] & (MASK_RIGHT << j) ? clip[POS_LEFT] : 0;
- rv40_adaptive_loop_filter(&r->rdsp, Y, s->linesize, dither,
- clip_cur,
- clip_left,
- alpha, beta, betaY, 0, 1, 1);
- }
- }
- }
- 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;
- 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;
- if(c_h_deblock[k] & (MASK_CUR << (ij+2))){
- int clip_bot = c_to_deblock[k] & (MASK_CUR << (ij+2)) ? clip[POS_CUR] : 0;
- rv40_adaptive_loop_filter(&r->rdsp, C+4*s->uvlinesize, s->uvlinesize, i*8,
- clip_bot,
- clip_cur,
- alpha, beta, betaC, 1, 0, 0);
- }
- if((c_v_deblock[k] & (MASK_CUR << ij)) && (i || !(mb_strong[POS_CUR] | mb_strong[POS_LEFT]))){
- if(!i)
- clip_left = uvcbp[POS_LEFT][k] & (MASK_CUR << (2*j+1)) ? clip[POS_LEFT] : 0;
- else
- clip_left = c_to_deblock[k] & (MASK_CUR << (ij-1)) ? clip[POS_CUR] : 0;
- rv40_adaptive_loop_filter(&r->rdsp, C, s->uvlinesize, j*8,
- clip_cur,
- clip_left,
- alpha, beta, betaC, 1, 0, 1);
- }
- if(!j && c_h_deblock[k] & (MASK_CUR << ij) && (mb_strong[POS_CUR] | mb_strong[POS_TOP])){
- int clip_top = uvcbp[POS_TOP][k] & (MASK_CUR << (ij+2)) ? clip[POS_TOP] : 0;
- rv40_adaptive_loop_filter(&r->rdsp, C, s->uvlinesize, i*8,
- clip_cur,
- clip_top,
- alpha, beta, betaC, 1, 1, 0);
- }
- if(c_v_deblock[k] & (MASK_CUR << ij) && !i && (mb_strong[POS_CUR] | mb_strong[POS_LEFT])){
- clip_left = uvcbp[POS_LEFT][k] & (MASK_CUR << (2*j+1)) ? clip[POS_LEFT] : 0;
- rv40_adaptive_loop_filter(&r->rdsp, C, s->uvlinesize, j*8,
- clip_cur,
- clip_left,
- alpha, beta, betaC, 1, 1, 1);
- }
- }
- }
- }
- }
-}
-
-/**
- * Initialize decoder.
- */
-static av_cold int rv40_decode_init(AVCodecContext *avctx)
-{
- RV34DecContext *r = avctx->priv_data;
-
- r->rv30 = 0;
- ff_rv34_decode_init(avctx);
- if(!aic_top_vlc.bits)
- rv40_init_tables();
- r->parse_slice_header = rv40_parse_slice_header;
- r->decode_intra_types = rv40_decode_intra_types;
- r->decode_mb_info = rv40_decode_mb_info;
- r->loop_filter = rv40_loop_filter;
- r->luma_dc_quant_i = rv40_luma_dc_quant[0];
- r->luma_dc_quant_p = rv40_luma_dc_quant[1];
- return 0;
-}
-
-AVCodec ff_rv40_decoder = {
- .name = "rv40",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_RV40,
- .priv_data_size = sizeof(RV34DecContext),
- .init = rv40_decode_init,
- .close = ff_rv34_decode_end,
- .decode = ff_rv34_decode_frame,
- .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY |
- CODEC_CAP_FRAME_THREADS,
- .flush = ff_mpeg_flush,
- .long_name = NULL_IF_CONFIG_SMALL("RealVideo 4.0"),
- .pix_fmts = ff_pixfmt_list_420,
- .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/src/thirdparty/ffmpeg/libavcodec/rv40data.h b/src/thirdparty/ffmpeg/libavcodec/rv40data.h
deleted file mode 100644
index 4343b2b66..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/rv40data.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * RealVideo 4 decoder
- * copyright (c) 2007 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
- */
-
-/**
- * @file
- * miscellaneous RV40 tables
- */
-
-#ifndef AVCODEC_RV40DATA_H
-#define AVCODEC_RV40DATA_H
-
-#include <stdint.h>
-
-/**
- * standard widths and heights coded in RV40
- */
-//@{
-static const int rv40_standard_widths[] = { 160, 172, 240, 320, 352, 640, 704, 0};
-static const int rv40_standard_heights[] = { 120, 132, 144, 240, 288, 480, -8, -10, 180, 360, 576, 0};
-//@}
-
-#define MODE2_PATTERNS_NUM 20
-/**
- * intra types table
- *
- * These values are actually coded 3-tuples
- * used for detecting standard block configurations.
- */
-static const uint16_t rv40_aic_table_index[MODE2_PATTERNS_NUM] = {
- 0x000, 0x100, 0x200,
- 0x011, 0x111, 0x211, 0x511, 0x611,
- 0x022, 0x122, 0x222, 0x722,
- 0x272, 0x227,
- 0x822, 0x282, 0x228,
- 0x112, 0x116, 0x221
-};
-
-/**
- * luma quantizer values
- * The second table is used for inter blocks.
- */
-static const uint8_t rv40_luma_dc_quant[2][32] = {
- { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 22, 22, 22, 22 },
- { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 20, 21, 21, 22, 23, 23, 23, 24, 24, 24, 24 }
-};
-
-/**
- * @name Coefficients used by the RV40 loop filter
- * @{
- */
-
-/** alpha parameter for RV40 loop filter - almost the same as in JVT-A003r1 */
-static const uint8_t rv40_alpha_tab[32] = {
- 128, 128, 128, 128, 128, 128, 128, 128,
- 128, 128, 122, 96, 75, 59, 47, 37,
- 29, 23, 18, 15, 13, 11, 10, 9,
- 8, 7, 6, 5, 4, 3, 2, 1
-};
-/** beta parameter for RV40 loop filter - almost the same as in JVT-A003r1 */
-static const uint8_t rv40_beta_tab[32] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 4, 4, 4, 6, 6,
- 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 13, 14, 15, 16, 17
-};
-/** clip table for RV40 loop filter - the same as in JVT-A003r1 */
-static const uint8_t rv40_filter_clip_tbl[3][32] = {
- {
- 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, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 5, 5
- },
- {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 7, 8, 9
- }
-};
-/** @} */ // end loopfilter group
-
-#endif /* AVCODEC_RV40DATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/rv40dsp.c b/src/thirdparty/ffmpeg/libavcodec/rv40dsp.c
deleted file mode 100644
index 1e582d8b8..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/rv40dsp.c
+++ /dev/null
@@ -1,614 +0,0 @@
-/*
- * RV40 decoder motion compensation functions
- * Copyright (c) 2008 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
- */
-
-/**
- * @file
- * RV40 decoder motion compensation functions
- */
-
-#include "avcodec.h"
-#include "h264qpel.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){\
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
- int i;\
- for(i = 0; i < h; i++)\
- {\
- OP(dst[0], (src[-2] + src[ 3] - 5*(src[-1]+src[2]) + src[0]*C1 + src[1]*C2 + (1<<(SHIFT-1))) >> SHIFT);\
- OP(dst[1], (src[-1] + src[ 4] - 5*(src[ 0]+src[3]) + src[1]*C1 + src[2]*C2 + (1<<(SHIFT-1))) >> SHIFT);\
- OP(dst[2], (src[ 0] + src[ 5] - 5*(src[ 1]+src[4]) + src[2]*C1 + src[3]*C2 + (1<<(SHIFT-1))) >> SHIFT);\
- OP(dst[3], (src[ 1] + src[ 6] - 5*(src[ 2]+src[5]) + src[3]*C1 + src[4]*C2 + (1<<(SHIFT-1))) >> SHIFT);\
- OP(dst[4], (src[ 2] + src[ 7] - 5*(src[ 3]+src[6]) + src[4]*C1 + src[5]*C2 + (1<<(SHIFT-1))) >> SHIFT);\
- OP(dst[5], (src[ 3] + src[ 8] - 5*(src[ 4]+src[7]) + src[5]*C1 + src[6]*C2 + (1<<(SHIFT-1))) >> SHIFT);\
- OP(dst[6], (src[ 4] + src[ 9] - 5*(src[ 5]+src[8]) + src[6]*C1 + src[7]*C2 + (1<<(SHIFT-1))) >> SHIFT);\
- OP(dst[7], (src[ 5] + src[10] - 5*(src[ 6]+src[9]) + src[7]*C1 + src[8]*C2 + (1<<(SHIFT-1))) >> SHIFT);\
- dst += dstStride;\
- src += srcStride;\
- }\
-}\
-\
-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){\
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
- int i;\
- for(i = 0; i < w; i++)\
- {\
- const int srcB = src[-2*srcStride];\
- const int srcA = src[-1*srcStride];\
- 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];\
- OP(dst[0*dstStride], (srcB + src3 - 5*(srcA+src2) + src0*C1 + src1*C2 + (1<<(SHIFT-1))) >> SHIFT);\
- OP(dst[1*dstStride], (srcA + src4 - 5*(src0+src3) + src1*C1 + src2*C2 + (1<<(SHIFT-1))) >> SHIFT);\
- OP(dst[2*dstStride], (src0 + src5 - 5*(src1+src4) + src2*C1 + src3*C2 + (1<<(SHIFT-1))) >> SHIFT);\
- OP(dst[3*dstStride], (src1 + src6 - 5*(src2+src5) + src3*C1 + src4*C2 + (1<<(SHIFT-1))) >> SHIFT);\
- OP(dst[4*dstStride], (src2 + src7 - 5*(src3+src6) + src4*C1 + src5*C2 + (1<<(SHIFT-1))) >> SHIFT);\
- OP(dst[5*dstStride], (src3 + src8 - 5*(src4+src7) + src5*C1 + src6*C2 + (1<<(SHIFT-1))) >> SHIFT);\
- OP(dst[6*dstStride], (src4 + src9 - 5*(src5+src8) + src6*C1 + src7*C2 + (1<<(SHIFT-1))) >> SHIFT);\
- OP(dst[7*dstStride], (src5 + src10 - 5*(src6+src9) + src7*C1 + src8*C2 + (1<<(SHIFT-1))) >> SHIFT);\
- dst++;\
- src++;\
- }\
-}\
-\
-static void OPNAME ## rv40_qpel16_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride,\
- const int w, const int C1, const int C2, const int SHIFT){\
- OPNAME ## rv40_qpel8_v_lowpass(dst , src , dstStride, srcStride, 8, C1, C2, SHIFT);\
- OPNAME ## rv40_qpel8_v_lowpass(dst+8, src+8, dstStride, srcStride, 8, C1, C2, SHIFT);\
- src += 8*srcStride;\
- dst += 8*dstStride;\
- OPNAME ## rv40_qpel8_v_lowpass(dst , src , dstStride, srcStride, w-8, C1, C2, SHIFT);\
- OPNAME ## rv40_qpel8_v_lowpass(dst+8, src+8, dstStride, srcStride, w-8, C1, C2, SHIFT);\
-}\
-\
-static void OPNAME ## rv40_qpel16_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride,\
- const int h, const int C1, const int C2, const int SHIFT){\
- OPNAME ## rv40_qpel8_h_lowpass(dst , src , dstStride, srcStride, 8, C1, C2, SHIFT);\
- OPNAME ## rv40_qpel8_h_lowpass(dst+8, src+8, dstStride, srcStride, 8, C1, C2, SHIFT);\
- src += 8*srcStride;\
- dst += 8*dstStride;\
- OPNAME ## rv40_qpel8_h_lowpass(dst , src , dstStride, srcStride, h-8, C1, C2, SHIFT);\
- OPNAME ## rv40_qpel8_h_lowpass(dst+8, src+8, dstStride, srcStride, h-8, C1, C2, SHIFT);\
-}\
-\
-
-#define RV40_MC(OPNAME, SIZE) \
-static void OPNAME ## rv40_qpel ## SIZE ## _mc10_c(uint8_t *dst, uint8_t *src, int stride){\
- OPNAME ## rv40_qpel ## SIZE ## _h_lowpass(dst, src, stride, stride, SIZE, 52, 20, 6);\
-}\
-\
-static void OPNAME ## rv40_qpel ## SIZE ## _mc30_c(uint8_t *dst, uint8_t *src, int stride){\
- OPNAME ## rv40_qpel ## SIZE ## _h_lowpass(dst, src, stride, stride, SIZE, 20, 52, 6);\
-}\
-\
-static void OPNAME ## rv40_qpel ## SIZE ## _mc01_c(uint8_t *dst, uint8_t *src, int stride){\
- OPNAME ## rv40_qpel ## SIZE ## _v_lowpass(dst, src, stride, stride, SIZE, 52, 20, 6);\
-}\
-\
-static void OPNAME ## rv40_qpel ## SIZE ## _mc11_c(uint8_t *dst, uint8_t *src, int stride){\
- uint8_t full[SIZE*(SIZE+5)];\
- uint8_t * const full_mid = full + SIZE*2;\
- put_rv40_qpel ## SIZE ## _h_lowpass(full, src - 2*stride, SIZE, stride, SIZE+5, 52, 20, 6);\
- OPNAME ## rv40_qpel ## SIZE ## _v_lowpass(dst, full_mid, stride, SIZE, SIZE, 52, 20, 6);\
-}\
-\
-static void OPNAME ## rv40_qpel ## SIZE ## _mc21_c(uint8_t *dst, uint8_t *src, int stride){\
- uint8_t full[SIZE*(SIZE+5)];\
- uint8_t * const full_mid = full + SIZE*2;\
- put_rv40_qpel ## SIZE ## _h_lowpass(full, src - 2*stride, SIZE, stride, SIZE+5, 20, 20, 5);\
- OPNAME ## rv40_qpel ## SIZE ## _v_lowpass(dst, full_mid, stride, SIZE, SIZE, 52, 20, 6);\
-}\
-\
-static void OPNAME ## rv40_qpel ## SIZE ## _mc31_c(uint8_t *dst, uint8_t *src, int stride){\
- uint8_t full[SIZE*(SIZE+5)];\
- uint8_t * const full_mid = full + SIZE*2;\
- put_rv40_qpel ## SIZE ## _h_lowpass(full, src - 2*stride, SIZE, stride, SIZE+5, 20, 52, 6);\
- OPNAME ## rv40_qpel ## SIZE ## _v_lowpass(dst, full_mid, stride, SIZE, SIZE, 52, 20, 6);\
-}\
-\
-static void OPNAME ## rv40_qpel ## SIZE ## _mc12_c(uint8_t *dst, uint8_t *src, int stride){\
- uint8_t full[SIZE*(SIZE+5)];\
- uint8_t * const full_mid = full + SIZE*2;\
- put_rv40_qpel ## SIZE ## _h_lowpass(full, src - 2*stride, SIZE, stride, SIZE+5, 52, 20, 6);\
- OPNAME ## rv40_qpel ## SIZE ## _v_lowpass(dst, full_mid, stride, SIZE, SIZE, 20, 20, 5);\
-}\
-\
-static void OPNAME ## rv40_qpel ## SIZE ## _mc22_c(uint8_t *dst, uint8_t *src, int stride){\
- uint8_t full[SIZE*(SIZE+5)];\
- uint8_t * const full_mid = full + SIZE*2;\
- put_rv40_qpel ## SIZE ## _h_lowpass(full, src - 2*stride, SIZE, stride, SIZE+5, 20, 20, 5);\
- OPNAME ## rv40_qpel ## SIZE ## _v_lowpass(dst, full_mid, stride, SIZE, SIZE, 20, 20, 5);\
-}\
-\
-static void OPNAME ## rv40_qpel ## SIZE ## _mc32_c(uint8_t *dst, uint8_t *src, int stride){\
- uint8_t full[SIZE*(SIZE+5)];\
- uint8_t * const full_mid = full + SIZE*2;\
- put_rv40_qpel ## SIZE ## _h_lowpass(full, src - 2*stride, SIZE, stride, SIZE+5, 20, 52, 6);\
- OPNAME ## rv40_qpel ## SIZE ## _v_lowpass(dst, full_mid, stride, SIZE, SIZE, 20, 20, 5);\
-}\
-\
-static void OPNAME ## rv40_qpel ## SIZE ## _mc03_c(uint8_t *dst, uint8_t *src, int stride){\
- OPNAME ## rv40_qpel ## SIZE ## _v_lowpass(dst, src, stride, stride, SIZE, 20, 52, 6);\
-}\
-\
-static void OPNAME ## rv40_qpel ## SIZE ## _mc13_c(uint8_t *dst, uint8_t *src, int stride){\
- uint8_t full[SIZE*(SIZE+5)];\
- uint8_t * const full_mid = full + SIZE*2;\
- put_rv40_qpel ## SIZE ## _h_lowpass(full, src - 2*stride, SIZE, stride, SIZE+5, 52, 20, 6);\
- OPNAME ## rv40_qpel ## SIZE ## _v_lowpass(dst, full_mid, stride, SIZE, SIZE, 20, 52, 6);\
-}\
-\
-static void OPNAME ## rv40_qpel ## SIZE ## _mc23_c(uint8_t *dst, uint8_t *src, int stride){\
- uint8_t full[SIZE*(SIZE+5)];\
- uint8_t * const full_mid = full + SIZE*2;\
- put_rv40_qpel ## SIZE ## _h_lowpass(full, src - 2*stride, SIZE, stride, SIZE+5, 20, 20, 5);\
- OPNAME ## rv40_qpel ## SIZE ## _v_lowpass(dst, full_mid, stride, SIZE, SIZE, 20, 52, 6);\
-}\
-\
-
-#define op_avg(a, b) a = (((a)+cm[b]+1)>>1)
-#define op_put(a, b) a = cm[b]
-
-RV40_LOWPASS(put_ , op_put)
-RV40_LOWPASS(avg_ , op_avg)
-
-#undef op_avg
-#undef op_put
-
-RV40_MC(put_, 8)
-RV40_MC(put_, 16)
-RV40_MC(avg_, 8)
-RV40_MC(avg_, 16)
-
-static const int rv40_bias[4][4] = {
- { 0, 16, 32, 16 },
- { 32, 28, 32, 28 },
- { 0, 32, 16, 32 },
- { 32, 28, 32, 28 }
-};
-
-#define RV40_CHROMA_MC(OPNAME, OP)\
-static void OPNAME ## rv40_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;\
- int bias = rv40_bias[y>>1][x>>1];\
- \
- av_assert2(x<8 && y<8 && x>=0 && y>=0);\
-\
- if(D){\
- for(i = 0; i < h; i++){\
- OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + bias));\
- OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + bias));\
- OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + bias));\
- OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + bias));\
- dst += stride;\
- src += stride;\
- }\
- }else{\
- const int E = B + C;\
- const int step = C ? stride : 1;\
- for(i = 0; i < h; i++){\
- OP(dst[0], (A*src[0] + E*src[step+0] + bias));\
- OP(dst[1], (A*src[1] + E*src[step+1] + bias));\
- OP(dst[2], (A*src[2] + E*src[step+2] + bias));\
- OP(dst[3], (A*src[3] + E*src[step+3] + bias));\
- dst += stride;\
- src += stride;\
- }\
- }\
-}\
-\
-static void OPNAME ## rv40_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;\
- int bias = rv40_bias[y>>1][x>>1];\
- \
- av_assert2(x<8 && y<8 && x>=0 && y>=0);\
-\
- if(D){\
- for(i = 0; i < h; i++){\
- OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + bias));\
- OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + bias));\
- OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + bias));\
- OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + bias));\
- OP(dst[4], (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + bias));\
- OP(dst[5], (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + bias));\
- OP(dst[6], (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + bias));\
- OP(dst[7], (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + bias));\
- dst += stride;\
- src += stride;\
- }\
- }else{\
- const int E = B + C;\
- const int step = C ? stride : 1;\
- for(i = 0; i < h; i++){\
- OP(dst[0], (A*src[0] + E*src[step+0] + bias));\
- OP(dst[1], (A*src[1] + E*src[step+1] + bias));\
- OP(dst[2], (A*src[2] + E*src[step+2] + bias));\
- OP(dst[3], (A*src[3] + E*src[step+3] + bias));\
- OP(dst[4], (A*src[4] + E*src[step+4] + bias));\
- OP(dst[5], (A*src[5] + E*src[step+5] + bias));\
- OP(dst[6], (A*src[6] + E*src[step+6] + bias));\
- OP(dst[7], (A*src[7] + E*src[step+7] + bias));\
- dst += stride;\
- src += stride;\
- }\
- }\
-}
-
-#define op_avg(a, b) a = (((a)+((b)>>6)+1)>>1)
-#define op_put(a, b) a = ((b)>>6)
-
-RV40_CHROMA_MC(put_, op_put)
-RV40_CHROMA_MC(avg_, op_avg)
-
-#define RV40_WEIGHT_FUNC(size) \
-static void rv40_weight_func_rnd_ ## size (uint8_t *dst, uint8_t *src1, uint8_t *src2, int w1, int w2, ptrdiff_t stride)\
-{\
- int i, j;\
-\
- for (j = 0; j < size; j++) {\
- for (i = 0; i < size; i++)\
- dst[i] = (((w2 * src1[i]) >> 9) + ((w1 * src2[i]) >> 9) + 0x10) >> 5;\
- src1 += stride;\
- src2 += stride;\
- dst += stride;\
- }\
-}\
-static void rv40_weight_func_nornd_ ## size (uint8_t *dst, uint8_t *src1, uint8_t *src2, int w1, int w2, ptrdiff_t stride)\
-{\
- int i, j;\
-\
- for (j = 0; j < size; j++) {\
- for (i = 0; i < size; i++)\
- dst[i] = (w2 * src1[i] + w1 * src2[i] + 0x10) >> 5;\
- src1 += stride;\
- src2 += stride;\
- dst += stride;\
- }\
-}
-
-RV40_WEIGHT_FUNC(16)
-RV40_WEIGHT_FUNC(8)
-
-/**
- * dither values for deblocking filter - left/top values
- */
-static const uint8_t rv40_dither_l[16] = {
- 0x40, 0x50, 0x20, 0x60, 0x30, 0x50, 0x40, 0x30,
- 0x50, 0x40, 0x50, 0x30, 0x60, 0x20, 0x50, 0x40
-};
-
-/**
- * dither values for deblocking filter - right/bottom values
- */
-static const uint8_t rv40_dither_r[16] = {
- 0x40, 0x30, 0x60, 0x20, 0x50, 0x30, 0x30, 0x40,
- 0x40, 0x40, 0x50, 0x30, 0x20, 0x60, 0x30, 0x40
-};
-
-#define CLIP_SYMM(a, b) av_clip(a, -(b), b)
-/**
- * weaker deblocking very similar to the one described in 4.4.2 of JVT-A003r1
- */
-static av_always_inline void rv40_weak_loop_filter(uint8_t *src,
- const int step,
- const ptrdiff_t stride,
- const int filter_p1,
- const int filter_q1,
- const int alpha,
- const int beta,
- const int lim_p0q0,
- const int lim_q1,
- const int lim_p1)
-{
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
- int i, t, u, diff;
-
- for (i = 0; i < 4; i++, src += stride) {
- int diff_p1p0 = src[-2*step] - src[-1*step];
- int diff_q1q0 = src[ 1*step] - src[ 0*step];
- int diff_p1p2 = src[-2*step] - src[-3*step];
- int diff_q1q2 = src[ 1*step] - src[ 2*step];
-
- t = src[0*step] - src[-1*step];
- if (!t)
- continue;
-
- u = (alpha * FFABS(t)) >> 7;
- if (u > 3 - (filter_p1 && filter_q1))
- continue;
-
- t <<= 2;
- if (filter_p1 && filter_q1)
- t += src[-2*step] - src[1*step];
-
- diff = CLIP_SYMM((t + 4) >> 3, lim_p0q0);
- src[-1*step] = cm[src[-1*step] + diff];
- src[ 0*step] = cm[src[ 0*step] - diff];
-
- if (filter_p1 && FFABS(diff_p1p2) <= beta) {
- t = (diff_p1p0 + diff_p1p2 - diff) >> 1;
- src[-2*step] = cm[src[-2*step] - CLIP_SYMM(t, lim_p1)];
- }
-
- if (filter_q1 && FFABS(diff_q1q2) <= beta) {
- t = (diff_q1q0 + diff_q1q2 + diff) >> 1;
- src[ 1*step] = cm[src[ 1*step] - CLIP_SYMM(t, lim_q1)];
- }
- }
-}
-
-static void rv40_h_weak_loop_filter(uint8_t *src, const ptrdiff_t stride,
- const int filter_p1, const int filter_q1,
- const int alpha, const int beta,
- const int lim_p0q0, const int lim_q1,
- const int lim_p1)
-{
- rv40_weak_loop_filter(src, stride, 1, filter_p1, filter_q1,
- alpha, beta, lim_p0q0, lim_q1, lim_p1);
-}
-
-static void rv40_v_weak_loop_filter(uint8_t *src, const ptrdiff_t stride,
- const int filter_p1, const int filter_q1,
- const int alpha, const int beta,
- const int lim_p0q0, const int lim_q1,
- const int lim_p1)
-{
- rv40_weak_loop_filter(src, 1, stride, filter_p1, filter_q1,
- alpha, beta, lim_p0q0, lim_q1, lim_p1);
-}
-
-static av_always_inline void rv40_strong_loop_filter(uint8_t *src,
- const int step,
- const ptrdiff_t stride,
- const int alpha,
- const int lims,
- const int dmode,
- const int chroma)
-{
- int i;
-
- for(i = 0; i < 4; i++, src += stride){
- int sflag, p0, q0, p1, q1;
- int t = src[0*step] - src[-1*step];
-
- if (!t)
- continue;
-
- sflag = (alpha * FFABS(t)) >> 7;
- if (sflag > 1)
- continue;
-
- p0 = (25*src[-3*step] + 26*src[-2*step] + 26*src[-1*step] +
- 26*src[ 0*step] + 25*src[ 1*step] +
- rv40_dither_l[dmode + i]) >> 7;
-
- q0 = (25*src[-2*step] + 26*src[-1*step] + 26*src[ 0*step] +
- 26*src[ 1*step] + 25*src[ 2*step] +
- rv40_dither_r[dmode + i]) >> 7;
-
- if (sflag) {
- p0 = av_clip(p0, src[-1*step] - lims, src[-1*step] + lims);
- q0 = av_clip(q0, src[ 0*step] - lims, src[ 0*step] + lims);
- }
-
- p1 = (25*src[-4*step] + 26*src[-3*step] + 26*src[-2*step] + 26*p0 +
- 25*src[ 0*step] + rv40_dither_l[dmode + i]) >> 7;
- q1 = (25*src[-1*step] + 26*q0 + 26*src[ 1*step] + 26*src[ 2*step] +
- 25*src[ 3*step] + rv40_dither_r[dmode + i]) >> 7;
-
- if (sflag) {
- p1 = av_clip(p1, src[-2*step] - lims, src[-2*step] + lims);
- q1 = av_clip(q1, src[ 1*step] - lims, src[ 1*step] + lims);
- }
-
- src[-2*step] = p1;
- src[-1*step] = p0;
- src[ 0*step] = q0;
- src[ 1*step] = q1;
-
- if(!chroma){
- src[-3*step] = (25*src[-1*step] + 26*src[-2*step] +
- 51*src[-3*step] + 26*src[-4*step] + 64) >> 7;
- src[ 2*step] = (25*src[ 0*step] + 26*src[ 1*step] +
- 51*src[ 2*step] + 26*src[ 3*step] + 64) >> 7;
- }
- }
-}
-
-static void rv40_h_strong_loop_filter(uint8_t *src, const ptrdiff_t stride,
- const int alpha, const int lims,
- const int dmode, const int chroma)
-{
- rv40_strong_loop_filter(src, stride, 1, alpha, lims, dmode, chroma);
-}
-
-static void rv40_v_strong_loop_filter(uint8_t *src, const ptrdiff_t stride,
- const int alpha, const int lims,
- const int dmode, const int chroma)
-{
- rv40_strong_loop_filter(src, 1, stride, alpha, lims, dmode, chroma);
-}
-
-static av_always_inline int rv40_loop_filter_strength(uint8_t *src,
- int step, ptrdiff_t stride,
- int beta, int beta2,
- int edge,
- int *p1, int *q1)
-{
- int sum_p1p0 = 0, sum_q1q0 = 0, sum_p1p2 = 0, sum_q1q2 = 0;
- int strong0 = 0, strong1 = 0;
- uint8_t *ptr;
- int i;
-
- for (i = 0, ptr = src; i < 4; i++, ptr += stride) {
- sum_p1p0 += ptr[-2*step] - ptr[-1*step];
- sum_q1q0 += ptr[ 1*step] - ptr[ 0*step];
- }
-
- *p1 = FFABS(sum_p1p0) < (beta << 2);
- *q1 = FFABS(sum_q1q0) < (beta << 2);
-
- if(!*p1 && !*q1)
- return 0;
-
- if (!edge)
- return 0;
-
- for (i = 0, ptr = src; i < 4; i++, ptr += stride) {
- sum_p1p2 += ptr[-2*step] - ptr[-3*step];
- sum_q1q2 += ptr[ 1*step] - ptr[ 2*step];
- }
-
- strong0 = *p1 && (FFABS(sum_p1p2) < beta2);
- strong1 = *q1 && (FFABS(sum_q1q2) < beta2);
-
- return strong0 && strong1;
-}
-
-static int rv40_h_loop_filter_strength(uint8_t *src, ptrdiff_t stride,
- int beta, int beta2, int edge,
- int *p1, int *q1)
-{
- return rv40_loop_filter_strength(src, stride, 1, beta, beta2, edge, p1, q1);
-}
-
-static int rv40_v_loop_filter_strength(uint8_t *src, ptrdiff_t stride,
- int beta, int beta2, int edge,
- int *p1, int *q1)
-{
- return rv40_loop_filter_strength(src, 1, stride, beta, beta2, edge, p1, q1);
-}
-
-av_cold void ff_rv40dsp_init(RV34DSPContext *c)
-{
- H264QpelContext qpel;
-
- ff_rv34dsp_init(c);
- ff_h264qpel_init(&qpel, 8);
-
- c->put_pixels_tab[0][ 0] = qpel.put_h264_qpel_pixels_tab[0][0];
- c->put_pixels_tab[0][ 1] = put_rv40_qpel16_mc10_c;
- c->put_pixels_tab[0][ 2] = qpel.put_h264_qpel_pixels_tab[0][2];
- c->put_pixels_tab[0][ 3] = put_rv40_qpel16_mc30_c;
- c->put_pixels_tab[0][ 4] = put_rv40_qpel16_mc01_c;
- c->put_pixels_tab[0][ 5] = put_rv40_qpel16_mc11_c;
- c->put_pixels_tab[0][ 6] = put_rv40_qpel16_mc21_c;
- c->put_pixels_tab[0][ 7] = put_rv40_qpel16_mc31_c;
- c->put_pixels_tab[0][ 8] = qpel.put_h264_qpel_pixels_tab[0][8];
- c->put_pixels_tab[0][ 9] = put_rv40_qpel16_mc12_c;
- c->put_pixels_tab[0][10] = put_rv40_qpel16_mc22_c;
- c->put_pixels_tab[0][11] = put_rv40_qpel16_mc32_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->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];
- c->avg_pixels_tab[0][ 3] = avg_rv40_qpel16_mc30_c;
- c->avg_pixels_tab[0][ 4] = avg_rv40_qpel16_mc01_c;
- c->avg_pixels_tab[0][ 5] = avg_rv40_qpel16_mc11_c;
- c->avg_pixels_tab[0][ 6] = avg_rv40_qpel16_mc21_c;
- c->avg_pixels_tab[0][ 7] = avg_rv40_qpel16_mc31_c;
- c->avg_pixels_tab[0][ 8] = qpel.avg_h264_qpel_pixels_tab[0][8];
- c->avg_pixels_tab[0][ 9] = avg_rv40_qpel16_mc12_c;
- c->avg_pixels_tab[0][10] = avg_rv40_qpel16_mc22_c;
- c->avg_pixels_tab[0][11] = avg_rv40_qpel16_mc32_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->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];
- c->put_pixels_tab[1][ 3] = put_rv40_qpel8_mc30_c;
- c->put_pixels_tab[1][ 4] = put_rv40_qpel8_mc01_c;
- c->put_pixels_tab[1][ 5] = put_rv40_qpel8_mc11_c;
- c->put_pixels_tab[1][ 6] = put_rv40_qpel8_mc21_c;
- c->put_pixels_tab[1][ 7] = put_rv40_qpel8_mc31_c;
- c->put_pixels_tab[1][ 8] = qpel.put_h264_qpel_pixels_tab[1][8];
- c->put_pixels_tab[1][ 9] = put_rv40_qpel8_mc12_c;
- c->put_pixels_tab[1][10] = put_rv40_qpel8_mc22_c;
- c->put_pixels_tab[1][11] = put_rv40_qpel8_mc32_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->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];
- c->avg_pixels_tab[1][ 3] = avg_rv40_qpel8_mc30_c;
- c->avg_pixels_tab[1][ 4] = avg_rv40_qpel8_mc01_c;
- c->avg_pixels_tab[1][ 5] = avg_rv40_qpel8_mc11_c;
- c->avg_pixels_tab[1][ 6] = avg_rv40_qpel8_mc21_c;
- c->avg_pixels_tab[1][ 7] = avg_rv40_qpel8_mc31_c;
- c->avg_pixels_tab[1][ 8] = qpel.avg_h264_qpel_pixels_tab[1][8];
- c->avg_pixels_tab[1][ 9] = avg_rv40_qpel8_mc12_c;
- c->avg_pixels_tab[1][10] = avg_rv40_qpel8_mc22_c;
- c->avg_pixels_tab[1][11] = avg_rv40_qpel8_mc32_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->put_chroma_pixels_tab[0] = put_rv40_chroma_mc8_c;
- c->put_chroma_pixels_tab[1] = put_rv40_chroma_mc4_c;
- c->avg_chroma_pixels_tab[0] = avg_rv40_chroma_mc8_c;
- c->avg_chroma_pixels_tab[1] = avg_rv40_chroma_mc4_c;
-
- c->rv40_weight_pixels_tab[0][0] = rv40_weight_func_rnd_16;
- c->rv40_weight_pixels_tab[0][1] = rv40_weight_func_rnd_8;
- c->rv40_weight_pixels_tab[1][0] = rv40_weight_func_nornd_16;
- c->rv40_weight_pixels_tab[1][1] = rv40_weight_func_nornd_8;
-
- c->rv40_weak_loop_filter[0] = rv40_h_weak_loop_filter;
- c->rv40_weak_loop_filter[1] = rv40_v_weak_loop_filter;
- c->rv40_strong_loop_filter[0] = rv40_h_strong_loop_filter;
- c->rv40_strong_loop_filter[1] = rv40_v_strong_loop_filter;
- c->rv40_loop_filter_strength[0] = rv40_h_loop_filter_strength;
- c->rv40_loop_filter_strength[1] = rv40_v_loop_filter_strength;
-
- if (ARCH_X86)
- ff_rv40dsp_init_x86(c);
- if (ARCH_ARM)
- ff_rv40dsp_init_arm(c);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/rv40vlc2.h b/src/thirdparty/ffmpeg/libavcodec/rv40vlc2.h
deleted file mode 100644
index 439441e64..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/rv40vlc2.h
+++ /dev/null
@@ -1,706 +0,0 @@
-/*
- * RealVideo 4 decoder
- * copyright (c) 2007 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
- */
-
-/**
- * @file
- * RV40 VLC tables used for macroblock information decoding
- */
-
-#ifndef AVCODEC_RV40VLC2_H
-#define AVCODEC_RV40VLC2_H
-
-#include <stdint.h>
-
-/**
- * codes used for the first four block types
- */
-//@{
-#define AIC_TOP_BITS 8
-#define AIC_TOP_SIZE 16
-static const uint8_t rv40_aic_top_vlc_codes[AIC_TOP_SIZE] = {
- 0x01, 0x05, 0x01, 0x00, 0x03, 0x3D, 0x1D, 0x02,
- 0x04, 0x3C, 0x3F, 0x1C, 0x0D, 0x3E, 0x0C, 0x01
-};
-
-static const uint8_t rv40_aic_top_vlc_bits[AIC_TOP_SIZE] = {
- 1, 4, 5, 5, 5, 7, 6, 5, 4, 7, 7, 6, 5, 7, 5, 3
-};
-//@}
-
-/**
- * codes used for determining a pair of block types
- */
-//@{
-#define AIC_MODE2_NUM 20
-#define AIC_MODE2_SIZE 81
-#define AIC_MODE2_BITS 9
-
-static const uint16_t aic_mode2_vlc_codes[AIC_MODE2_NUM][AIC_MODE2_SIZE] = {
-{ 0x0001, 0x0001, 0x0005, 0x01F5, 0x0011, 0x0049, 0x0000, 0x0048, 0x004B,
- 0x0035, 0x0003, 0x0034, 0x03C9, 0x01F4, 0x00C9, 0x004A, 0x0FD9, 0x03C8,
- 0x0010, 0x0037, 0x0001, 0x00C8, 0x0075, 0x01F7, 0x00CB, 0x0074, 0x0002,
- 0x01F6, 0x00CA, 0x01F1, 0x01F0, 0x1F81, 0x07F9, 0x1F80, 0x1F83, 0x07F8,
- 0x0077, 0x00F5, 0x0036, 0x07FB, 0x0076, 0x1F82, 0x00F4, 0x00F7, 0x07FA,
- 0x0071, 0x00F6, 0x03CB, 0x03CA, 0x0FD8, 0x00F1, 0x03F5, 0x1F8D, 0x07E5,
- 0x0013, 0x0031, 0x00F0, 0x0FDB, 0x00F3, 0x07E4, 0x0030, 0x01F3, 0x07E7,
- 0x03F4, 0x07E6, 0x0070, 0x3F19, 0x01F2, 0x3F18, 0x0FDA, 0x0033, 0x07E1,
- 0x01FD, 0x01FC, 0x0073, 0x01FF, 0x0FC5, 0x0FC4, 0x0FC7, 0x03F7, 0x0072, },
-{ 0x0005, 0x0005, 0x0005, 0x0079, 0x0005, 0x000D, 0x001D, 0x0078, 0x0069,
- 0x0004, 0x0001, 0x0007, 0x0068, 0x001C, 0x001F, 0x0004, 0x006B, 0x000C,
- 0x0004, 0x001E, 0x0006, 0x006A, 0x0015, 0x000F, 0x0014, 0x0017, 0x0007,
- 0x0016, 0x000E, 0x0011, 0x0009, 0x00D1, 0x00D0, 0x0181, 0x00D3, 0x007B,
- 0x0010, 0x0013, 0x0004, 0x00D2, 0x0007, 0x0319, 0x0008, 0x007A, 0x00DD,
- 0x0019, 0x0006, 0x000B, 0x0065, 0x00DC, 0x0012, 0x0064, 0x0180, 0x00DF,
- 0x0006, 0x0018, 0x0001, 0x00DE, 0x001D, 0x00D9, 0x001B, 0x0067, 0x000A,
- 0x00D8, 0x00DB, 0x001C, 0x0318, 0x00DA, 0x0635, 0x0183, 0x0000, 0x00C5,
- 0x0066, 0x0061, 0x0035, 0x00C4, 0x0182, 0x0634, 0x031B, 0x00C7, 0x001F, },
-{ 0x0005, 0x0001, 0x001D, 0x01C1, 0x0035, 0x00F1, 0x006D, 0x00F0, 0x0049,
- 0x0000, 0x0004, 0x0003, 0x00F3, 0x0048, 0x0034, 0x006C, 0x01C0, 0x01C3,
- 0x0007, 0x0006, 0x0001, 0x006F, 0x0002, 0x004B, 0x006E, 0x001C, 0x0005,
- 0x0069, 0x0068, 0x006B, 0x0037, 0x01C2, 0x00F2, 0x0395, 0x01CD, 0x00FD,
- 0x006A, 0x0036, 0x0015, 0x01CC, 0x0014, 0x0394, 0x004A, 0x00FC, 0x00FF,
- 0x0017, 0x0031, 0x00FE, 0x01CF, 0x0397, 0x00F9, 0x01CE, 0x0725, 0x0396,
- 0x0016, 0x0030, 0x0075, 0x0724, 0x00F8, 0x0727, 0x0033, 0x0391, 0x0390,
- 0x0011, 0x0032, 0x001F, 0x00FB, 0x0074, 0x0726, 0x00FA, 0x001E, 0x0077,
- 0x0019, 0x0018, 0x0004, 0x0010, 0x003D, 0x0076, 0x0071, 0x0013, 0x0001, },
-{ 0x000D, 0x0019, 0x0011, 0x0015, 0x0061, 0x0019, 0x0014, 0x01AD, 0x0060,
- 0x0018, 0x0001, 0x0005, 0x001B, 0x0010, 0x0019, 0x0005, 0x0017, 0x0018,
- 0x0016, 0x0004, 0x0004, 0x0013, 0x000C, 0x0012, 0x001A, 0x0018, 0x0005,
- 0x000F, 0x001B, 0x0004, 0x001D, 0x0011, 0x001C, 0x0010, 0x000E, 0x001B,
- 0x0013, 0x001F, 0x001A, 0x0029, 0x0005, 0x0063, 0x001E, 0x0009, 0x0062,
- 0x0008, 0x0007, 0x0007, 0x0019, 0x0004, 0x001A, 0x0018, 0x006D, 0x0007,
- 0x001B, 0x0007, 0x001A, 0x006C, 0x0006, 0x0012, 0x0005, 0x006F, 0x000B,
- 0x006E, 0x0069, 0x001D, 0x0359, 0x0028, 0x002B, 0x002A, 0x001C, 0x00D5,
- 0x0358, 0x001F, 0x0001, 0x001E, 0x0068, 0x00D4, 0x00D7, 0x0019, 0x0000, },
-{ 0x00B9, 0x0061, 0x0060, 0x00B8, 0x02B5, 0x01AD, 0x00BB, 0x0AF5, 0x0151,
- 0x0001, 0x0001, 0x0005, 0x0000, 0x0003, 0x0005, 0x0004, 0x0063, 0x0025,
- 0x00BA, 0x0004, 0x0007, 0x0062, 0x00A5, 0x0024, 0x006D, 0x0002, 0x006C,
- 0x02B4, 0x000D, 0x006F, 0x0027, 0x00A4, 0x0026, 0x01AC, 0x0150, 0x01AF,
- 0x01AE, 0x0021, 0x006E, 0x02B7, 0x0020, 0x0153, 0x0023, 0x00A7, 0x0152,
- 0x00A6, 0x0006, 0x000C, 0x0022, 0x01A9, 0x0019, 0x002D, 0x02B6, 0x01A8,
- 0x000F, 0x0007, 0x000E, 0x00A1, 0x0069, 0x002C, 0x0001, 0x01AB, 0x00A0,
- 0x02B1, 0x00A3, 0x002F, 0x0AF4, 0x02B0, 0x0AF7, 0x02B3, 0x0068, 0x015D,
- 0x0AF6, 0x01AA, 0x0055, 0x015C, 0x02B2, 0x0579, 0x0578, 0x015F, 0x00A2, },
-{ 0x0905, 0x013D, 0x013C, 0x0904, 0x121D, 0x049D, 0x049C, 0x243D, 0x0907,
- 0x00ED, 0x0001, 0x0015, 0x0041, 0x013F, 0x0031, 0x0014, 0x025D, 0x025C,
- 0x013E, 0x000D, 0x0000, 0x0040, 0x0139, 0x0043, 0x0030, 0x0017, 0x0033,
- 0x0906, 0x0032, 0x0042, 0x00EC, 0x025F, 0x00EF, 0x025E, 0x049F, 0x0138,
- 0x0901, 0x013B, 0x0259, 0x121C, 0x049E, 0x0900, 0x0258, 0x243C, 0x121F,
- 0x0903, 0x003D, 0x00EE, 0x025B, 0x025A, 0x004D, 0x013A, 0x0902, 0x0245,
- 0x00E9, 0x0016, 0x00E8, 0x0499, 0x0125, 0x0244, 0x004C, 0x0498, 0x090D,
- 0x00EB, 0x003C, 0x0011, 0x049B, 0x049A, 0x0485, 0x00EA, 0x003F, 0x0124,
- 0x090C, 0x003E, 0x0039, 0x0095, 0x0247, 0x0246, 0x0484, 0x0094, 0x0038, },
-{ 0x0F09, 0x00CD, 0x01FD, 0x0791, 0x1E6D, 0x0790, 0x03D9, 0x3CD1, 0x3CD0,
- 0x0075, 0x0001, 0x0001, 0x0035, 0x00CC, 0x0011, 0x0000, 0x03D8, 0x01FC,
- 0x03DB, 0x0010, 0x0003, 0x00CF, 0x03DA, 0x00CE, 0x0074, 0x0034, 0x0077,
- 0x0793, 0x0013, 0x0076, 0x0071, 0x03C5, 0x0070, 0x01FF, 0x0792, 0x01FE,
- 0x01F9, 0x0037, 0x00C9, 0x0F08, 0x01F8, 0x03C4, 0x00C8, 0x0F0B, 0x079D,
- 0x03C7, 0x0001, 0x0012, 0x0073, 0x00CB, 0x0005, 0x0036, 0x03C6, 0x0072,
- 0x007D, 0x0002, 0x00CA, 0x079C, 0x01FB, 0x00F5, 0x0031, 0x079F, 0x0F0A,
- 0x0F35, 0x079E, 0x01FA, 0x1E6C, 0x1E6F, 0x3CD3, 0x0799, 0x03C1, 0x1E6E,
- 0x3CD2, 0x0030, 0x00F4, 0x007C, 0x03C0, 0x03C3, 0x0798, 0x01E5, 0x00F7, },
-{ 0x01A5, 0x0001, 0x001D, 0x0021, 0x00A1, 0x000D, 0x0061, 0x06B9, 0x00A0,
- 0x0060, 0x0001, 0x0005, 0x000C, 0x0020, 0x001C, 0x0004, 0x01A4, 0x01A7,
- 0x00A3, 0x001F, 0x001E, 0x0023, 0x0022, 0x002D, 0x002C, 0x0063, 0x0062,
- 0x1A81, 0x01A6, 0x01A1, 0x06B8, 0x06BB, 0x00A2, 0x06BA, 0x0D59, 0x06A5,
- 0x01A0, 0x000F, 0x006D, 0x06A4, 0x002F, 0x00AD, 0x006C, 0x06A7, 0x00AC,
- 0x0D58, 0x000E, 0x01A3, 0x00AF, 0x00AE, 0x006F, 0x01A2, 0x0D5B, 0x00A9,
- 0x0019, 0x0001, 0x0009, 0x00A8, 0x006E, 0x002E, 0x0000, 0x01AD, 0x00AB,
- 0x00AA, 0x0355, 0x0029, 0x1A80, 0x1A83, 0x1A82, 0x0354, 0x01AC, 0x0D5A,
- 0x1A8D, 0x01AF, 0x0357, 0x0D45, 0x0D44, 0x0D47, 0x1A8C, 0x06A6, 0x06A1, },
-{ 0x0001, 0x0011, 0x0005, 0x0775, 0x00F9, 0x00F8, 0x0031, 0x0030, 0x0049,
- 0x00FB, 0x0010, 0x0033, 0x0EC9, 0x038D, 0x038C, 0x00FA, 0x038F, 0x0774,
- 0x0048, 0x0032, 0x0000, 0x01D5, 0x00E5, 0x038E, 0x00E4, 0x0013, 0x000D,
- 0x0389, 0x0777, 0x0388, 0x038B, 0x1DF9, 0x0EC8, 0x3BC9, 0x1DF8, 0x038A,
- 0x03B5, 0x0776, 0x00E7, 0x3BC8, 0x01D4, 0x3BCB, 0x0ECB, 0x0771, 0x0ECA,
- 0x01D7, 0x03B4, 0x01D6, 0x1DFB, 0x0EF5, 0x0770, 0x0EF4, 0x3BCA, 0x0773,
- 0x00E6, 0x03B7, 0x004B, 0x1DFA, 0x03B6, 0x0EF7, 0x00E1, 0x0EF6, 0x0EF1,
- 0x03B1, 0x01D1, 0x003D, 0x0EF0, 0x0772, 0x077D, 0x077C, 0x003C, 0x01D0,
- 0x03B0, 0x01D3, 0x003F, 0x03B3, 0x01D2, 0x0EF3, 0x077F, 0x00E0, 0x004A, },
-{ 0x0015, 0x0049, 0x0014, 0x07D1, 0x03FD, 0x03FC, 0x01C1, 0x01C0, 0x00F1,
- 0x0017, 0x0001, 0x0001, 0x01C3, 0x0048, 0x004B, 0x0016, 0x0031, 0x01C2,
- 0x004A, 0x0011, 0x0000, 0x01CD, 0x00F0, 0x01CC, 0x0075, 0x0010, 0x000D,
- 0x03FF, 0x01CF, 0x01CE, 0x07D0, 0x0F81, 0x07D3, 0x1F1D, 0x0F80, 0x07D2,
- 0x01C9, 0x03FE, 0x0074, 0x07DD, 0x00F3, 0x1F1C, 0x07DC, 0x03F9, 0x07DF,
- 0x00F2, 0x00FD, 0x0077, 0x07DE, 0x07D9, 0x01C8, 0x07D8, 0x0F83, 0x03F8,
- 0x0030, 0x0076, 0x0013, 0x0F82, 0x00FC, 0x03FB, 0x0033, 0x03FA, 0x03E5,
- 0x03E4, 0x01CB, 0x0032, 0x1F1F, 0x03E7, 0x07DB, 0x07DA, 0x003D, 0x01CA,
- 0x07C5, 0x03E6, 0x0071, 0x0F8D, 0x07C4, 0x1F1E, 0x0F8C, 0x03E1, 0x01F5, },
-{ 0x0019, 0x0065, 0x0018, 0x0351, 0x0350, 0x0353, 0x0021, 0x0020, 0x0064,
- 0x001D, 0x0005, 0x0005, 0x01A5, 0x0023, 0x0067, 0x0005, 0x0066, 0x0022,
- 0x001B, 0x0004, 0x0001, 0x0004, 0x001C, 0x0061, 0x001A, 0x0005, 0x0004,
- 0x0007, 0x002D, 0x0006, 0x002C, 0x01A4, 0x002F, 0x0352, 0x035D, 0x0060,
- 0x0001, 0x002E, 0x001F, 0x035C, 0x0000, 0x06B1, 0x01A7, 0x0029, 0x01A6,
- 0x0028, 0x0063, 0x0062, 0x035F, 0x01A1, 0x002B, 0x06B0, 0x06B3, 0x01A0,
- 0x0003, 0x006D, 0x001E, 0x035E, 0x006C, 0x06B2, 0x0002, 0x01A3, 0x01A2,
- 0x000D, 0x0005, 0x0007, 0x01AD, 0x006F, 0x002A, 0x006E, 0x0004, 0x0004,
- 0x000C, 0x0007, 0x0006, 0x000F, 0x000E, 0x00D5, 0x0009, 0x0006, 0x0007, },
-{ 0x0065, 0x0181, 0x0064, 0x36C9, 0x06D5, 0x0DB5, 0x0379, 0x0180, 0x0183,
- 0x00D5, 0x001D, 0x001C, 0x0DB4, 0x0182, 0x0378, 0x00D4, 0x00D7, 0x06D4,
- 0x0067, 0x001F, 0x0001, 0x00D6, 0x00D1, 0x018D, 0x0066, 0x0001, 0x0000,
- 0x037B, 0x06D7, 0x037A, 0x0DB7, 0x36C8, 0x06D6, 0x0DB6, 0x1B79, 0x0DB1,
- 0x018C, 0x0365, 0x00D0, 0x1B78, 0x00D3, 0x1B7B, 0x0364, 0x06D1, 0x06D0,
- 0x018F, 0x018E, 0x00D2, 0x36CB, 0x0367, 0x0366, 0x06D3, 0x0DB0, 0x06D2,
- 0x0361, 0x06DD, 0x0189, 0x36CA, 0x0360, 0x36F5, 0x0188, 0x0DB3, 0x36F4,
- 0x0009, 0x0008, 0x0005, 0x06DC, 0x00DD, 0x018B, 0x00DC, 0x0004, 0x000B,
- 0x018A, 0x0061, 0x0003, 0x0363, 0x00DF, 0x06DF, 0x0362, 0x000A, 0x001E, },
-{ 0x001D, 0x0061, 0x000D, 0x0D55, 0x06B9, 0x06B8, 0x01A5, 0x0021, 0x0020,
- 0x0023, 0x000C, 0x0060, 0x0D54, 0x00AD, 0x00AC, 0x0022, 0x00AF, 0x06BB,
- 0x000F, 0x001C, 0x0001, 0x002D, 0x0063, 0x01A4, 0x000E, 0x0001, 0x0005,
- 0x01A7, 0x06BA, 0x01A6, 0x06A5, 0x0D57, 0x0D56, 0x1ABD, 0x0D51, 0x00AE,
- 0x002C, 0x00A9, 0x002F, 0x0D50, 0x01A1, 0x1ABC, 0x06A4, 0x06A7, 0x06A6,
- 0x00A8, 0x06A1, 0x01A0, 0x1ABF, 0x0D53, 0x06A0, 0x0D52, 0x1ABE, 0x06A3,
- 0x0062, 0x002E, 0x0009, 0x0D5D, 0x01A3, 0x0D5C, 0x006D, 0x00AB, 0x06A2,
- 0x006C, 0x001F, 0x0001, 0x06AD, 0x0029, 0x01A2, 0x0028, 0x0004, 0x001E,
- 0x01AD, 0x006F, 0x0000, 0x01AC, 0x01AF, 0x06AC, 0x00AA, 0x006E, 0x0019, },
-{ 0x0019, 0x007D, 0x0018, 0x01B5, 0x000D, 0x01B4, 0x007C, 0x007F, 0x01B7,
- 0x000C, 0x001B, 0x001A, 0x01B6, 0x000F, 0x00D5, 0x0019, 0x007E, 0x00D4,
- 0x0018, 0x001B, 0x0001, 0x000E, 0x0011, 0x0009, 0x0005, 0x0005, 0x0005,
- 0x00D7, 0x01B1, 0x0008, 0x01B0, 0x0079, 0x06FD, 0x0371, 0x0370, 0x00D6,
- 0x0078, 0x01B3, 0x0010, 0x0373, 0x0013, 0x06FC, 0x007B, 0x007A, 0x00D1,
- 0x00D0, 0x00D3, 0x0065, 0x0372, 0x06FF, 0x0064, 0x06FE, 0x037D, 0x00D2,
- 0x00DD, 0x0067, 0x0004, 0x037C, 0x0012, 0x01B2, 0x0007, 0x0066, 0x01BD,
- 0x0006, 0x0061, 0x0004, 0x01BC, 0x001A, 0x0060, 0x001D, 0x0004, 0x001C,
- 0x0063, 0x0001, 0x0007, 0x000B, 0x0000, 0x0062, 0x000A, 0x0005, 0x0007, },
-{ 0x0069, 0x0045, 0x0068, 0x04BD, 0x0255, 0x04BC, 0x00E5, 0x00E4, 0x0031,
- 0x0030, 0x0019, 0x0001, 0x0121, 0x00E7, 0x00E6, 0x0033, 0x00E1, 0x00E0,
- 0x006B, 0x0018, 0x0001, 0x0044, 0x0032, 0x0047, 0x006A, 0x001B, 0x0005,
- 0x003D, 0x0046, 0x0015, 0x0041, 0x0120, 0x0123, 0x04BF, 0x0122, 0x0040,
- 0x003C, 0x00E3, 0x0014, 0x0254, 0x0043, 0x0975, 0x012D, 0x00E2, 0x00ED,
- 0x0042, 0x00EC, 0x004D, 0x0257, 0x0256, 0x0251, 0x04BE, 0x0974, 0x0250,
- 0x00EF, 0x00EE, 0x004C, 0x04B9, 0x012C, 0x04B8, 0x004F, 0x04BB, 0x0253,
- 0x003F, 0x0017, 0x0001, 0x0252, 0x00E9, 0x00E8, 0x00EB, 0x0000, 0x0003,
- 0x0016, 0x0002, 0x0004, 0x004E, 0x003E, 0x00EA, 0x0049, 0x000D, 0x0007, },
-{ 0x000D, 0x01BD, 0x000C, 0x0D31, 0x0D30, 0x0D33, 0x0359, 0x0358, 0x002D,
- 0x0065, 0x001D, 0x001C, 0x0D32, 0x035B, 0x035A, 0x002C, 0x01BC, 0x0345,
- 0x000F, 0x001F, 0x0001, 0x002F, 0x0064, 0x01BF, 0x0067, 0x0001, 0x0005,
- 0x0066, 0x002E, 0x0061, 0x0029, 0x0695, 0x0694, 0x0697, 0x0696, 0x0060,
- 0x01BE, 0x0D3D, 0x0028, 0x1A49, 0x0344, 0x1A48, 0x1A4B, 0x0D3C, 0x0691,
- 0x002B, 0x01B9, 0x002A, 0x0D3F, 0x0690, 0x0347, 0x0D3E, 0x1A4A, 0x0346,
- 0x00D5, 0x0341, 0x0063, 0x0D39, 0x0340, 0x0D38, 0x01B8, 0x0D3B, 0x0D3A,
- 0x00D4, 0x0062, 0x0000, 0x0693, 0x01BB, 0x0343, 0x0342, 0x001E, 0x000E,
- 0x006D, 0x0009, 0x0001, 0x006C, 0x00D7, 0x034D, 0x01BA, 0x0008, 0x0004, },
-{ 0x0075, 0x00CD, 0x0035, 0x03C1, 0x03C0, 0x07F9, 0x03C3, 0x1F8D, 0x00CC,
- 0x0074, 0x0011, 0x0010, 0x03C2, 0x0FD9, 0x01F1, 0x00CF, 0x03CD, 0x00CE,
- 0x0034, 0x0001, 0x0001, 0x0037, 0x00C9, 0x00C8, 0x0036, 0x0000, 0x0001,
- 0x0FD8, 0x03CC, 0x00CB, 0x01F0, 0x07F8, 0x03CF, 0x07FB, 0x07FA, 0x00CA,
- 0x01F3, 0x03CE, 0x00F5, 0x0FDB, 0x00F4, 0x07E5, 0x07E4, 0x07E7, 0x01F2,
- 0x07E6, 0x03C9, 0x01FD, 0x0FDA, 0x1F8C, 0x07E1, 0x1F8F, 0x1F8E, 0x03C8,
- 0x03CB, 0x0077, 0x0076, 0x0FC5, 0x03CA, 0x07E0, 0x00F7, 0x0FC4, 0x03F5,
- 0x00F6, 0x01FC, 0x0003, 0x03F4, 0x0071, 0x03F7, 0x00F1, 0x0013, 0x0031,
- 0x0030, 0x0070, 0x0005, 0x0012, 0x0073, 0x01FF, 0x0072, 0x007D, 0x0002, },
-{ 0x0061, 0x0055, 0x0060, 0x02C9, 0x02C8, 0x02CB, 0x0171, 0x00B5, 0x0054,
- 0x0001, 0x0001, 0x0001, 0x0057, 0x0001, 0x0063, 0x001D, 0x0062, 0x0039,
- 0x006D, 0x0000, 0x0005, 0x0038, 0x0056, 0x00B4, 0x006C, 0x0003, 0x001C,
- 0x006F, 0x003B, 0x0002, 0x003A, 0x0170, 0x00B7, 0x0173, 0x0051, 0x006E,
- 0x0025, 0x0050, 0x0069, 0x02CA, 0x0024, 0x0027, 0x0172, 0x00B6, 0x00B1,
- 0x000D, 0x000C, 0x001F, 0x017D, 0x0026, 0x0068, 0x0053, 0x017C, 0x006B,
- 0x001E, 0x000F, 0x0004, 0x017F, 0x006A, 0x02F5, 0x0019, 0x0021, 0x0052,
- 0x02F4, 0x02F7, 0x0020, 0x0BCD, 0x05E5, 0x05E4, 0x0BCC, 0x0023, 0x00B0,
- 0x02F6, 0x00B3, 0x0022, 0x02F1, 0x02F0, 0x0BCF, 0x0BCE, 0x017E, 0x005D, },
-{ 0x00BD, 0x0025, 0x01A1, 0x0159, 0x0299, 0x00BC, 0x0024, 0x0505, 0x0504,
- 0x01A0, 0x0001, 0x001D, 0x006D, 0x001C, 0x0001, 0x0005, 0x0027, 0x01A3,
- 0x0158, 0x001F, 0x001E, 0x01A2, 0x0026, 0x0021, 0x000D, 0x0020, 0x0023,
- 0x0298, 0x006C, 0x0022, 0x00BF, 0x00BE, 0x01AD, 0x002D, 0x029B, 0x00B9,
- 0x01AC, 0x00B8, 0x01AF, 0x029A, 0x006F, 0x015B, 0x006E, 0x0285, 0x0284,
- 0x01AE, 0x0019, 0x002C, 0x01A9, 0x01A8, 0x000C, 0x000F, 0x015A, 0x00BB,
- 0x000E, 0x0000, 0x0069, 0x01AB, 0x0018, 0x01AA, 0x0004, 0x0055, 0x00BA,
- 0x0507, 0x0145, 0x0054, 0x0506, 0x00A5, 0x0501, 0x00A4, 0x0057, 0x0500,
- 0x0A05, 0x0144, 0x00A7, 0x0287, 0x0286, 0x0503, 0x0147, 0x0A04, 0x0146, },
-{ 0x0759, 0x0041, 0x00E5, 0x03BD, 0x0E9D, 0x012D, 0x012C, 0x3A1D, 0x03BC,
- 0x012F, 0x000D, 0x0040, 0x00E4, 0x03BF, 0x0043, 0x0042, 0x0758, 0x03BE,
- 0x00E7, 0x0001, 0x0000, 0x003D, 0x00E6, 0x0015, 0x0014, 0x0017, 0x003C,
- 0x743D, 0x012E, 0x03B9, 0x03B8, 0x0E9C, 0x03BB, 0x075B, 0x3A1C, 0x0E9F,
- 0x0129, 0x00E1, 0x0128, 0x0E9E, 0x012B, 0x075A, 0x00E0, 0x0E99, 0x0745,
- 0x3A1F, 0x03BA, 0x0744, 0x0E98, 0x1D0D, 0x03A5, 0x0E9B, 0x743C, 0x0E9A,
- 0x012A, 0x004D, 0x00E3, 0x0E85, 0x01D5, 0x0E84, 0x004C, 0x0747, 0x1D0C,
- 0x01D4, 0x003F, 0x0016, 0x0746, 0x03A4, 0x0741, 0x004F, 0x003E, 0x01D7,
- 0x0740, 0x000C, 0x0011, 0x004E, 0x00E2, 0x00ED, 0x00EC, 0x0049, 0x0048, },
-};
-
-static const uint8_t aic_mode2_vlc_bits[AIC_MODE2_NUM][AIC_MODE2_SIZE] = {
-{ 1, 5, 4, 10, 6, 8, 5, 8, 8,
- 7, 5, 7, 11, 10, 9, 8, 13, 11,
- 6, 7, 3, 9, 8, 10, 9, 8, 5,
- 10, 9, 10, 10, 14, 12, 14, 14, 12,
- 8, 9, 7, 12, 8, 14, 9, 9, 12,
- 8, 9, 11, 11, 13, 9, 11, 14, 12,
- 6, 7, 9, 13, 9, 12, 7, 10, 12,
- 11, 12, 8, 15, 10, 15, 13, 7, 12,
- 10, 10, 8, 10, 13, 13, 13, 11, 8, },
-{ 4, 6, 5, 11, 8, 10, 7, 11, 9,
- 4, 1, 4, 9, 7, 7, 5, 9, 10,
- 6, 7, 4, 9, 9, 10, 9, 9, 6,
- 9, 10, 9, 10, 12, 12, 13, 12, 11,
- 9, 9, 8, 12, 8, 14, 10, 11, 12,
- 7, 8, 10, 11, 12, 9, 11, 13, 12,
- 6, 7, 8, 12, 9, 12, 7, 11, 10,
- 12, 12, 9, 14, 12, 15, 13, 8, 12,
- 11, 11, 10, 12, 13, 15, 14, 12, 9, },
-{ 5, 7, 6, 12, 9, 11, 8, 11, 10,
- 7, 5, 7, 11, 10, 9, 8, 12, 12,
- 5, 5, 1, 8, 7, 10, 8, 6, 4,
- 8, 8, 8, 9, 12, 11, 13, 12, 11,
- 8, 9, 8, 12, 8, 13, 10, 11, 11,
- 8, 9, 11, 12, 13, 11, 12, 14, 13,
- 8, 9, 10, 14, 11, 14, 9, 13, 13,
- 8, 9, 6, 11, 10, 14, 11, 6, 10,
- 6, 6, 4, 8, 9, 10, 10, 8, 5, },
-{ 11, 7, 8, 10, 12, 9, 10, 14, 12,
- 7, 1, 5, 7, 8, 6, 4, 10, 9,
- 10, 5, 4, 8, 11, 8, 7, 6, 7,
- 11, 6, 7, 8, 10, 8, 10, 11, 9,
- 10, 8, 9, 13, 9, 12, 8, 11, 12,
- 11, 4, 7, 8, 9, 6, 8, 12, 9,
- 8, 5, 8, 12, 9, 10, 6, 12, 11,
- 12, 12, 10, 15, 13, 13, 13, 10, 13,
- 15, 10, 9, 10, 12, 13, 13, 10, 9, },
-{ 11, 8, 8, 11, 13, 10, 11, 15, 12,
- 7, 1, 4, 7, 7, 5, 4, 8, 9,
- 11, 5, 5, 8, 11, 9, 8, 7, 8,
- 13, 7, 8, 9, 11, 9, 10, 12, 10,
- 10, 9, 8, 13, 9, 12, 9, 11, 12,
- 11, 5, 7, 9, 10, 6, 9, 13, 10,
- 7, 4, 7, 11, 8, 9, 5, 10, 11,
- 13, 11, 9, 15, 13, 15, 13, 8, 12,
- 15, 10, 10, 12, 13, 14, 14, 12, 11, },
-{ 12, 9, 9, 12, 13, 11, 11, 14, 12,
- 8, 2, 5, 7, 9, 6, 5, 10, 10,
- 9, 4, 2, 7, 9, 7, 6, 5, 6,
- 12, 6, 7, 8, 10, 8, 10, 11, 9,
- 12, 9, 10, 13, 11, 12, 10, 14, 13,
- 12, 6, 8, 10, 10, 7, 9, 12, 10,
- 8, 5, 8, 11, 9, 10, 7, 11, 12,
- 8, 6, 5, 11, 11, 11, 8, 6, 9,
- 12, 6, 6, 8, 10, 10, 11, 8, 6, },
-{ 13, 9, 10, 12, 14, 12, 11, 15, 15,
- 8, 1, 5, 7, 9, 6, 5, 11, 10,
- 11, 6, 5, 9, 11, 9, 8, 7, 8,
- 12, 6, 8, 8, 11, 8, 10, 12, 10,
- 10, 7, 9, 13, 10, 11, 9, 13, 12,
- 11, 3, 6, 8, 9, 4, 7, 11, 8,
- 8, 5, 9, 12, 10, 9, 7, 12, 13,
- 13, 12, 10, 14, 14, 15, 12, 11, 14,
- 15, 7, 9, 8, 11, 11, 12, 10, 9, },
-{ 10, 5, 6, 9, 11, 7, 8, 12, 11,
- 8, 1, 4, 7, 9, 6, 4, 10, 10,
- 11, 6, 6, 9, 9, 9, 9, 8, 8,
- 14, 10, 10, 12, 12, 11, 12, 13, 12,
- 10, 7, 8, 12, 9, 11, 8, 12, 11,
- 13, 7, 10, 11, 11, 8, 10, 13, 11,
- 6, 3, 7, 11, 8, 9, 5, 10, 11,
- 11, 11, 9, 14, 14, 14, 11, 10, 13,
- 14, 10, 11, 13, 13, 13, 14, 12, 12, },
-{ 2, 5, 3, 11, 8, 8, 6, 6, 7,
- 8, 5, 6, 12, 10, 10, 8, 10, 11,
- 7, 6, 2, 9, 8, 10, 8, 5, 4,
- 10, 11, 10, 10, 13, 12, 14, 13, 10,
- 10, 11, 8, 14, 9, 14, 12, 11, 12,
- 9, 10, 9, 13, 12, 11, 12, 14, 11,
- 8, 10, 7, 13, 10, 12, 8, 12, 12,
- 10, 9, 6, 12, 11, 11, 11, 6, 9,
- 10, 9, 6, 10, 9, 12, 11, 8, 7, },
-{ 6, 8, 6, 12, 11, 11, 10, 10, 9,
- 6, 1, 3, 10, 8, 8, 6, 7, 10,
- 8, 6, 3, 10, 9, 10, 8, 6, 5,
- 11, 10, 10, 12, 13, 12, 14, 13, 12,
- 10, 11, 8, 12, 9, 14, 12, 11, 12,
- 9, 9, 8, 12, 12, 10, 12, 13, 11,
- 7, 8, 6, 13, 9, 11, 7, 11, 11,
- 11, 10, 7, 14, 11, 12, 12, 7, 10,
- 12, 11, 8, 13, 12, 14, 13, 11, 10, },
-{ 7, 10, 7, 13, 13, 13, 11, 11, 10,
- 8, 5, 6, 12, 11, 10, 9, 10, 11,
- 7, 5, 1, 9, 8, 10, 7, 4, 4,
- 9, 11, 9, 11, 12, 11, 13, 13, 10,
- 9, 11, 8, 13, 9, 14, 12, 11, 12,
- 11, 10, 10, 13, 12, 11, 14, 14, 12,
- 9, 10, 8, 13, 10, 14, 9, 12, 12,
- 9, 7, 4, 12, 10, 11, 10, 6, 7,
- 9, 7, 4, 9, 9, 11, 9, 7, 5, },
-{ 7, 9, 7, 14, 11, 12, 10, 9, 9,
- 8, 5, 5, 12, 9, 10, 8, 8, 11,
- 7, 5, 2, 8, 8, 9, 7, 4, 4,
- 10, 11, 10, 12, 14, 11, 12, 13, 12,
- 9, 10, 8, 13, 8, 13, 10, 11, 11,
- 9, 9, 8, 14, 10, 10, 11, 12, 11,
- 10, 11, 9, 14, 10, 14, 9, 12, 14,
- 6, 6, 3, 11, 8, 9, 8, 3, 6,
- 9, 7, 4, 10, 8, 11, 10, 6, 5, },
-{ 6, 8, 7, 13, 12, 12, 10, 9, 9,
- 9, 7, 8, 13, 11, 11, 9, 11, 12,
- 7, 6, 1, 9, 8, 10, 7, 5, 4,
- 10, 12, 10, 12, 13, 13, 14, 13, 11,
- 9, 11, 9, 13, 10, 14, 12, 12, 12,
- 11, 12, 10, 14, 13, 12, 13, 14, 12,
- 8, 9, 7, 13, 10, 13, 8, 11, 12,
- 8, 6, 3, 12, 9, 10, 9, 4, 6,
- 10, 8, 5, 10, 10, 12, 11, 8, 6, },
-{ 7, 10, 7, 12, 9, 12, 10, 10, 12,
- 9, 7, 7, 12, 9, 11, 6, 10, 11,
- 6, 6, 1, 9, 8, 9, 7, 4, 5,
- 11, 12, 9, 12, 10, 14, 13, 13, 11,
- 10, 12, 8, 13, 8, 14, 10, 10, 11,
- 11, 11, 10, 13, 14, 10, 14, 13, 11,
- 11, 10, 7, 13, 8, 12, 7, 10, 12,
- 7, 10, 4, 12, 6, 10, 8, 5, 8,
- 10, 7, 4, 9, 7, 10, 9, 6, 5, },
-{ 7, 9, 7, 13, 12, 13, 10, 10, 8,
- 8, 5, 6, 11, 10, 10, 8, 10, 10,
- 7, 5, 2, 9, 8, 9, 7, 5, 3,
- 8, 9, 7, 9, 11, 11, 13, 11, 9,
- 8, 10, 7, 12, 9, 14, 11, 10, 10,
- 9, 10, 9, 12, 12, 12, 13, 14, 12,
- 10, 10, 9, 13, 11, 13, 9, 13, 12,
- 8, 7, 4, 12, 10, 10, 10, 6, 6,
- 7, 6, 3, 9, 8, 10, 9, 6, 3, },
-{ 7, 10, 7, 13, 13, 13, 11, 11, 9,
- 8, 6, 6, 13, 11, 11, 9, 10, 11,
- 7, 6, 1, 9, 8, 10, 8, 5, 4,
- 8, 9, 8, 9, 12, 12, 12, 12, 8,
- 10, 13, 9, 14, 11, 14, 14, 13, 12,
- 9, 10, 9, 13, 12, 11, 13, 14, 11,
- 9, 11, 8, 13, 11, 13, 10, 13, 13,
- 9, 8, 5, 12, 10, 11, 11, 6, 7,
- 8, 7, 3, 8, 9, 11, 10, 7, 4, },
-{ 8, 9, 7, 11, 11, 12, 11, 14, 9,
- 8, 6, 6, 11, 13, 10, 9, 11, 9,
- 7, 5, 1, 7, 9, 9, 7, 5, 3,
- 13, 11, 9, 10, 12, 11, 12, 12, 9,
- 10, 11, 9, 13, 9, 12, 12, 12, 10,
- 12, 11, 10, 13, 14, 12, 14, 14, 11,
- 11, 8, 8, 13, 11, 12, 9, 13, 11,
- 9, 10, 5, 11, 8, 11, 9, 6, 7,
- 7, 8, 4, 6, 8, 10, 8, 8, 5, },
-{ 8, 10, 8, 13, 13, 13, 12, 11, 10,
- 5, 1, 3, 10, 7, 8, 6, 8, 9,
- 8, 7, 4, 9, 10, 11, 8, 7, 6,
- 8, 9, 7, 9, 12, 11, 12, 10, 8,
- 9, 10, 8, 13, 9, 9, 12, 11, 11,
- 7, 7, 6, 12, 9, 8, 10, 12, 8,
- 6, 7, 4, 12, 8, 13, 6, 9, 10,
- 13, 13, 9, 15, 14, 14, 15, 9, 11,
- 13, 11, 9, 13, 13, 15, 15, 12, 10, },
-{ 10, 8, 9, 11, 12, 10, 8, 13, 13,
- 9, 2, 5, 7, 5, 4, 3, 8, 9,
- 11, 5, 5, 9, 8, 8, 6, 8, 8,
- 12, 7, 8, 10, 10, 9, 8, 12, 10,
- 9, 10, 9, 12, 7, 11, 7, 12, 12,
- 9, 5, 8, 9, 9, 6, 6, 11, 10,
- 6, 4, 7, 9, 5, 9, 3, 9, 10,
- 13, 11, 9, 13, 10, 13, 10, 9, 13,
- 14, 11, 10, 12, 12, 13, 11, 14, 11, },
-{ 11, 7, 8, 10, 12, 9, 9, 14, 10,
- 9, 4, 7, 8, 10, 7, 7, 11, 10,
- 8, 2, 2, 6, 8, 5, 5, 5, 6,
- 15, 9, 10, 10, 12, 10, 11, 14, 12,
- 9, 8, 9, 12, 9, 11, 8, 12, 11,
- 14, 10, 11, 12, 13, 10, 12, 15, 12,
- 9, 7, 8, 12, 9, 12, 7, 11, 13,
- 9, 6, 5, 11, 10, 11, 7, 6, 9,
- 11, 4, 5, 7, 8, 8, 8, 7, 7, },
-};
-//@}
-
-/**
- * Codes used for determining block type
- */
-//@{
-#define AIC_MODE1_NUM 90
-#define AIC_MODE1_SIZE 9
-#define AIC_MODE1_BITS 7
-
-static const uint8_t aic_mode1_vlc_codes[AIC_MODE1_NUM][AIC_MODE1_SIZE] = {
- { 0x01, 0x01, 0x01, 0x11, 0x00, 0x09, 0x03, 0x10, 0x05,},
- { 0x09, 0x01, 0x01, 0x05, 0x11, 0x00, 0x03, 0x21, 0x20,},
- { 0x01, 0x01, 0x01, 0x11, 0x09, 0x10, 0x05, 0x00, 0x03,},
- { 0x01, 0x01, 0x00, 0x03, 0x21, 0x05, 0x09, 0x20, 0x11,},
- { 0x01, 0x09, 0x00, 0x29, 0x08, 0x15, 0x03, 0x0B, 0x28,},
- { 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x03, 0x02,},
- { 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x01, 0x09, 0x08,},
- { 0x01, 0x01, 0x01, 0x09, 0x01, 0x08, 0x00, 0x03, 0x05,},
- { 0x01, 0x01, 0x01, 0x00, 0x05, 0x11, 0x09, 0x10, 0x03,},
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
-
- { 0x01, 0x01, 0x01, 0x05, 0x01, 0x00, 0x03, 0x09, 0x08,},
- { 0x09, 0x01, 0x01, 0x05, 0x11, 0x00, 0x03, 0x21, 0x20,},
- { 0x01, 0x01, 0x01, 0x0D, 0x05, 0x04, 0x00, 0x07, 0x0C,},
- { 0x01, 0x01, 0x00, 0x05, 0x11, 0x03, 0x09, 0x21, 0x20,},
- { 0x05, 0x01, 0x01, 0x11, 0x00, 0x09, 0x03, 0x21, 0x20,},
- { 0x09, 0x01, 0x01, 0x00, 0x05, 0x01, 0x03, 0x11, 0x10,},
- { 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x03, 0x02,},
- { 0x01, 0x01, 0x01, 0x09, 0x00, 0x05, 0x01, 0x03, 0x08,},
- { 0x01, 0x01, 0x01, 0x09, 0x11, 0x05, 0x00, 0x10, 0x03,},
- { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
-
- { 0x01, 0x00, 0x01, 0x09, 0x08, 0x15, 0x14, 0x0B, 0x03,},
- { 0x0D, 0x01, 0x01, 0x05, 0x0C, 0x04, 0x01, 0x00, 0x07,},
- { 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x03, 0x01, 0x01,},
- { 0x05, 0x01, 0x01, 0x04, 0x19, 0x07, 0x18, 0x0D, 0x00,},
- { 0x11, 0x09, 0x01, 0x21, 0x05, 0x20, 0x01, 0x00, 0x03,},
- { 0x41, 0x01, 0x00, 0x05, 0x40, 0x03, 0x09, 0x21, 0x11,},
- { 0x29, 0x01, 0x00, 0x28, 0x09, 0x15, 0x03, 0x08, 0x0B,},
- { 0x01, 0x00, 0x01, 0x11, 0x09, 0x10, 0x05, 0x01, 0x03,},
- { 0x05, 0x01, 0x01, 0x04, 0x0D, 0x0C, 0x07, 0x00, 0x01,},
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
-
- { 0x01, 0x00, 0x03, 0x05, 0x11, 0x10, 0x25, 0x24, 0x13,},
- { 0x21, 0x01, 0x01, 0x00, 0x11, 0x03, 0x05, 0x20, 0x09,},
- { 0x01, 0x01, 0x01, 0x00, 0x09, 0x11, 0x10, 0x05, 0x03,},
- { 0x21, 0x05, 0x01, 0x01, 0x09, 0x00, 0x11, 0x20, 0x03,},
- { 0x05, 0x01, 0x00, 0x04, 0x01, 0x19, 0x07, 0x18, 0x0D,},
- { 0x11, 0x01, 0x00, 0x01, 0x09, 0x01, 0x03, 0x10, 0x05,},
- { 0x1D, 0x01, 0x05, 0x0D, 0x0C, 0x04, 0x00, 0x1C, 0x0F,},
- { 0x05, 0x19, 0x01, 0x04, 0x00, 0x18, 0x1B, 0x1A, 0x07,},
- { 0x09, 0x01, 0x00, 0x01, 0x05, 0x03, 0x11, 0x10, 0x01,},
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
-
- { 0x01, 0x00, 0x03, 0x41, 0x05, 0x40, 0x09, 0x11, 0x21,},
- { 0x05, 0x01, 0x01, 0x19, 0x04, 0x07, 0x00, 0x18, 0x0D,},
- { 0x01, 0x01, 0x01, 0x05, 0x01, 0x04, 0x01, 0x00, 0x03,},
- { 0x01, 0x05, 0x00, 0x0D, 0x01, 0x04, 0x07, 0x19, 0x18,},
- { 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x03, 0x02,},
- { 0x31, 0x01, 0x05, 0x19, 0x04, 0x07, 0x00, 0x30, 0x0D,},
- { 0x01, 0x00, 0x03, 0x11, 0x01, 0x05, 0x01, 0x09, 0x10,},
- { 0x01, 0x05, 0x01, 0x11, 0x01, 0x10, 0x00, 0x03, 0x09,},
- { 0x01, 0x09, 0x00, 0x29, 0x03, 0x08, 0x28, 0x15, 0x0B,},
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
-
- { 0x01, 0x01, 0x00, 0x09, 0x15, 0x03, 0x08, 0x14, 0x0B,},
- { 0x11, 0x01, 0x01, 0x00, 0x09, 0x01, 0x03, 0x10, 0x05,},
- { 0x01, 0x00, 0x03, 0x25, 0x11, 0x05, 0x10, 0x24, 0x13,},
- { 0x11, 0x01, 0x00, 0x01, 0x09, 0x01, 0x05, 0x10, 0x03,},
- { 0x05, 0x01, 0x00, 0x0D, 0x0C, 0x04, 0x0F, 0x1D, 0x1C,},
- { 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x03, 0x02,},
- { 0x21, 0x01, 0x05, 0x09, 0x11, 0x00, 0x03, 0x41, 0x40,},
- { 0x05, 0x01, 0x00, 0x1D, 0x1C, 0x0D, 0x0C, 0x0F, 0x04,},
- { 0x05, 0x01, 0x00, 0x0D, 0x31, 0x04, 0x19, 0x30, 0x07,},
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
-
- { 0x01, 0x01, 0x00, 0x21, 0x05, 0x11, 0x03, 0x09, 0x20,},
- { 0x01, 0x01, 0x00, 0x11, 0x03, 0x05, 0x01, 0x09, 0x10,},
- { 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x03, 0x02,},
- { 0x05, 0x01, 0x04, 0x19, 0x07, 0x0D, 0x00, 0x31, 0x30,},
- { 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x03, 0x02,},
- { 0x05, 0x01, 0x01, 0x11, 0x09, 0x00, 0x03, 0x21, 0x20,},
- { 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x03, 0x02,},
- { 0x01, 0x01, 0x01, 0x00, 0x01, 0x03, 0x01, 0x01, 0x02,},
- { 0x09, 0x01, 0x00, 0x29, 0x08, 0x15, 0x03, 0x28, 0x0B,},
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
-
- { 0x01, 0x01, 0x01, 0x05, 0x01, 0x04, 0x00, 0x01, 0x03,},
- { 0x09, 0x01, 0x00, 0x29, 0x28, 0x15, 0x08, 0x03, 0x0B,},
- { 0x01, 0x00, 0x01, 0x11, 0x05, 0x10, 0x09, 0x01, 0x03,},
- { 0x05, 0x04, 0x01, 0x1D, 0x0D, 0x0C, 0x1C, 0x00, 0x0F,},
- { 0x09, 0x11, 0x01, 0x41, 0x00, 0x40, 0x05, 0x03, 0x21,},
- { 0x0D, 0x05, 0x01, 0x1D, 0x1C, 0x0C, 0x04, 0x00, 0x0F,},
- { 0x41, 0x09, 0x01, 0x40, 0x00, 0x11, 0x05, 0x03, 0x21,},
- { 0x01, 0x01, 0x01, 0x05, 0x01, 0x04, 0x00, 0x01, 0x03,},
- { 0x05, 0x04, 0x01, 0x0D, 0x01, 0x0C, 0x07, 0x01, 0x00,},
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
-
- { 0x05, 0x04, 0x01, 0x07, 0x19, 0x31, 0x30, 0x0D, 0x00,},
- { 0x21, 0x01, 0x01, 0x00, 0x11, 0x09, 0x20, 0x05, 0x03,},
- { 0x05, 0x01, 0x01, 0x04, 0x07, 0x0D, 0x0C, 0x00, 0x01,},
- { 0x21, 0x09, 0x01, 0x00, 0x20, 0x05, 0x23, 0x22, 0x03,},
- { 0x31, 0x0D, 0x01, 0x19, 0x05, 0x30, 0x04, 0x07, 0x00,},
- { 0x31, 0x05, 0x01, 0x04, 0x19, 0x00, 0x0D, 0x30, 0x07,},
- { 0x31, 0x01, 0x00, 0x0D, 0x05, 0x19, 0x04, 0x30, 0x07,},
- { 0x01, 0x01, 0x01, 0x00, 0x01, 0x03, 0x02, 0x01, 0x01,},
- { 0x01, 0x00, 0x01, 0x01, 0x05, 0x09, 0x08, 0x03, 0x01,},
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,},
-};
-
-static const uint8_t aic_mode1_vlc_bits[AIC_MODE1_NUM][AIC_MODE1_SIZE] = {
- { 1, 4, 2, 7, 4, 6, 4, 7, 5,},
- { 5, 1, 3, 4, 6, 3, 3, 7, 7,},
- { 1, 4, 2, 7, 6, 7, 5, 4, 4,},
- { 1, 3, 3, 3, 7, 4, 5, 7, 6,},
- { 2, 4, 2, 6, 4, 5, 2, 4, 6,},
- { 7, 2, 3, 4, 7, 1, 5, 7, 7,},
- { 5, 1, 3, 6, 5, 5, 2, 7, 7,},
- { 2, 5, 1, 7, 3, 7, 5, 5, 6,},
- { 2, 4, 1, 4, 5, 7, 6, 7, 4,},
- { 0, 0, 0, 0, 0, 0, 0, 0, 0,},
-
- { 2, 1, 3, 6, 5, 5, 5, 7, 7,},
- { 5, 1, 3, 4, 6, 3, 3, 7, 7,},
- { 4, 1, 2, 6, 5, 5, 4, 5, 6,},
- { 3, 1, 3, 4, 6, 3, 5, 7, 7,},
- { 4, 1, 3, 6, 3, 5, 3, 7, 7,},
- { 6, 1, 4, 4, 5, 2, 4, 7, 7,},
- { 7, 1, 5, 7, 4, 3, 2, 7, 7,},
- { 5, 3, 2, 7, 5, 6, 1, 5, 7,},
- { 4, 1, 2, 6, 7, 5, 4, 7, 4,},
- { 1, 0, 1, 0, 0, 0, 0, 0, 0,},
-
- { 3, 3, 1, 5, 5, 6, 6, 5, 3,},
- { 6, 2, 1, 5, 6, 5, 4, 4, 5,},
- { 6, 4, 1, 7, 6, 7, 6, 3, 2,},
- { 4, 3, 1, 4, 6, 4, 6, 5, 3,},
- { 6, 5, 1, 7, 4, 7, 3, 3, 3,},
- { 7, 2, 2, 3, 7, 2, 4, 6, 5,},
- { 6, 2, 2, 6, 4, 5, 2, 4, 4,},
- { 4, 4, 1, 7, 6, 7, 5, 2, 4,},
- { 5, 4, 1, 5, 6, 6, 5, 4, 2,},
- { 0, 0, 0, 0, 0, 0, 0, 0, 0,},
-
- { 2, 2, 2, 3, 5, 5, 6, 6, 5,},
- { 7, 1, 3, 3, 6, 3, 4, 7, 5,},
- { 2, 4, 1, 4, 6, 7, 7, 5, 4,},
- { 7, 4, 3, 1, 5, 3, 6, 7, 3,},
- { 4, 3, 3, 4, 1, 6, 4, 6, 5,},
- { 7, 4, 4, 2, 6, 1, 4, 7, 5,},
- { 5, 2, 3, 4, 4, 3, 2, 5, 4,},
- { 3, 5, 2, 3, 2, 5, 5, 5, 3,},
- { 6, 4, 4, 2, 5, 4, 7, 7, 1,},
- { 0, 0, 0, 0, 0, 0, 0, 0, 0,},
-
- { 2, 2, 2, 7, 3, 7, 4, 5, 6,},
- { 4, 1, 3, 6, 4, 4, 3, 6, 5,},
- { 2, 4, 1, 7, 3, 7, 6, 6, 6,},
- { 3, 4, 3, 5, 1, 4, 4, 6, 6,},
- { 4, 5, 2, 7, 1, 7, 3, 7, 7,},
- { 6, 2, 3, 5, 3, 3, 2, 6, 4,},
- { 4, 4, 4, 7, 2, 5, 1, 6, 7,},
- { 4, 5, 2, 7, 1, 7, 4, 4, 6,},
- { 2, 4, 2, 6, 2, 4, 6, 5, 4,},
- { 0, 0, 0, 0, 0, 0, 0, 0, 0,},
-
- { 1, 3, 3, 5, 6, 3, 5, 6, 5,},
- { 7, 1, 4, 4, 6, 2, 4, 7, 5,},
- { 2, 2, 2, 6, 5, 3, 5, 6, 5,},
- { 7, 4, 4, 2, 6, 1, 5, 7, 4,},
- { 3, 2, 2, 4, 4, 3, 4, 5, 5,},
- { 7, 2, 5, 3, 7, 1, 4, 7, 7,},
- { 6, 2, 3, 4, 5, 2, 2, 7, 7,},
- { 3, 2, 2, 5, 5, 4, 4, 4, 3,},
- { 3, 2, 2, 4, 6, 3, 5, 6, 3,},
- { 0, 0, 0, 0, 0, 0, 0, 0, 0,},
-
- { 1, 3, 3, 7, 4, 6, 3, 5, 7,},
- { 4, 1, 4, 7, 4, 5, 2, 6, 7,},
- { 2, 4, 1, 7, 5, 7, 3, 7, 7,},
- { 3, 2, 3, 5, 3, 4, 2, 6, 6,},
- { 3, 5, 4, 7, 2, 7, 1, 7, 7,},
- { 4, 1, 3, 6, 5, 3, 3, 7, 7,},
- { 4, 2, 5, 7, 3, 7, 1, 7, 7,},
- { 7, 4, 1, 7, 3, 7, 2, 5, 7,},
- { 4, 2, 2, 6, 4, 5, 2, 6, 4,},
- { 0, 0, 0, 0, 0, 0, 0, 0, 0,},
-
- { 3, 4, 1, 7, 6, 7, 6, 2, 6,},
- { 4, 2, 2, 6, 6, 5, 4, 2, 4,},
- { 4, 4, 1, 7, 5, 7, 6, 2, 4,},
- { 3, 3, 2, 5, 4, 4, 5, 2, 4,},
- { 4, 5, 2, 7, 2, 7, 3, 2, 6,},
- { 4, 3, 2, 5, 5, 4, 3, 2, 4,},
- { 7, 4, 2, 7, 2, 5, 3, 2, 6,},
- { 4, 6, 2, 7, 3, 7, 6, 1, 6,},
- { 5, 5, 1, 6, 4, 6, 5, 2, 4,},
- { 0, 0, 0, 0, 0, 0, 0, 0, 0,},
-
- { 3, 3, 2, 3, 5, 6, 6, 4, 2,},
- { 7, 1, 3, 3, 6, 5, 7, 4, 3,},
- { 5, 4, 1, 5, 5, 6, 6, 4, 2,},
- { 6, 4, 2, 2, 6, 3, 6, 6, 2,},
- { 6, 4, 2, 5, 3, 6, 3, 3, 2,},
- { 6, 3, 2, 3, 5, 2, 4, 6, 3,},
- { 6, 2, 2, 4, 3, 5, 3, 6, 3,},
- { 7, 5, 1, 7, 4, 7, 7, 3, 2,},
- { 5, 5, 2, 3, 6, 7, 7, 5, 1,},
- { 0, 0, 0, 0, 0, 0, 0, 0, 0,},
-};
-
-//@}
-
-#define PBTYPE_ESCAPE 0xFF
-
-/** tables used for P-frame macroblock type decoding */
-//@{
-#define NUM_PTYPE_VLCS 7
-#define PTYPE_VLC_SIZE 8
-#define PTYPE_VLC_BITS 7
-
-static const uint8_t ptype_vlc_codes[NUM_PTYPE_VLCS][PTYPE_VLC_SIZE] = {
- { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00 },
- { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00 },
- { 0x0D, 0x05, 0x01, 0x04, 0x01, 0x00, 0x07, 0x0C },
- { 0x09, 0x11, 0x01, 0x00, 0x05, 0x03, 0x21, 0x20 },
- { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00 },
- { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00 },
- { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00 }
-};
-
-static const uint8_t ptype_vlc_bits[NUM_PTYPE_VLCS][PTYPE_VLC_SIZE] = {
- { 1, 2, 3, 6, 5, 4, 7, 7 },
- { 3, 1, 2, 7, 6, 5, 4, 7 },
- { 5, 4, 1, 4, 3, 3, 4, 5 },
- { 4, 5, 2, 2, 3, 2, 6, 6 },
- { 5, 6, 1, 4, 2, 3, 7, 7 },
- { 5, 6, 1, 4, 3, 2, 7, 7 },
- { 6, 3, 2, 7, 5, 4, 1, 7 }
-};
-
-static const uint8_t ptype_vlc_syms[PTYPE_VLC_SIZE] = {
- 0, 1, 2, 3, 8, 9, 11, PBTYPE_ESCAPE
-};
-
-/** reverse of ptype_vlc_syms */
-static const uint8_t block_num_to_ptype_vlc_num[12] = {
- 0, 1, 2, 3, 0, 0, 2, 0, 4, 5, 0, 6
-};
-//@}
-
-/** tables used for P-frame macroblock type decoding */
-//@{
-#define NUM_BTYPE_VLCS 6
-#define BTYPE_VLC_SIZE 7
-#define BTYPE_VLC_BITS 6
-
-static const uint8_t btype_vlc_codes[NUM_BTYPE_VLCS][BTYPE_VLC_SIZE] = {
- { 0x01, 0x05, 0x00, 0x03, 0x11, 0x09, 0x10 },
- { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00 },
- { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00 },
- { 0x09, 0x01, 0x00, 0x01, 0x05, 0x03, 0x08 },
- { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00 },
- { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00 }
-};
-
-static const uint8_t btype_vlc_bits[NUM_BTYPE_VLCS][PTYPE_VLC_SIZE] = {
- { 2, 3, 2, 2, 5, 4, 5 },
- { 4, 1, 3, 2, 6, 5, 6 },
- { 6, 4, 1, 2, 5, 3, 6 },
- { 5, 3, 3, 1, 4, 3, 5 },
- { 6, 5, 3, 2, 4, 1, 6 },
- { 6, 5, 3, 1, 4, 2, 6 }
-};
-
-static const uint8_t btype_vlc_syms[BTYPE_VLC_SIZE] = {
- 0, 1, 4, 5, 10, 7, PBTYPE_ESCAPE
-};
-
-/** reverse of btype_vlc_syms */
-static const uint8_t block_num_to_btype_vlc_num[12] = {
- 0, 1, 0, 0, 2, 3, 0, 5, 0, 0, 4, 0
-};
-//@}
-#endif /* AVCODEC_RV40VLC2_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/sbr.h b/src/thirdparty/ffmpeg/libavcodec/sbr.h
deleted file mode 100644
index e5288f19f..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/sbr.h
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Spectral Band Replication definitions and structures
- * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl )
- * Copyright (c) 2010 Alex Converse <alex.converse@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
- * Spectral Band Replication definitions and structures
- * @author Robert Swain ( rob opendot cl )
- */
-
-#ifndef AVCODEC_SBR_H
-#define AVCODEC_SBR_H
-
-#include <stdint.h>
-#include "fft.h"
-#include "aacps.h"
-#include "sbrdsp.h"
-
-/**
- * Spectral Band Replication header - spectrum parameters that invoke a reset if they differ from the previous header.
- */
-typedef struct SpectrumParameters {
- uint8_t bs_start_freq;
- uint8_t bs_stop_freq;
- uint8_t bs_xover_band;
-
- /**
- * @name Variables associated with bs_header_extra_1
- * @{
- */
- uint8_t bs_freq_scale;
- uint8_t bs_alter_scale;
- uint8_t bs_noise_bands;
- /** @} */
-} SpectrumParameters;
-
-#define SBR_SYNTHESIS_BUF_SIZE ((1280-128)*2)
-
-/**
- * Spectral Band Replication per channel data
- */
-typedef struct SBRData {
- /**
- * @name Main bitstream data variables
- * @{
- */
- unsigned bs_frame_class;
- unsigned bs_add_harmonic_flag;
- unsigned bs_num_env;
- uint8_t bs_freq_res[7];
- unsigned bs_num_noise;
- uint8_t bs_df_env[5];
- uint8_t bs_df_noise[2];
- uint8_t bs_invf_mode[2][5];
- uint8_t bs_add_harmonic[48];
- unsigned bs_amp_res;
- /** @} */
-
- /**
- * @name State variables
- * @{
- */
- DECLARE_ALIGNED(32, float, synthesis_filterbank_samples)[SBR_SYNTHESIS_BUF_SIZE];
- DECLARE_ALIGNED(32, float, analysis_filterbank_samples) [1312];
- int synthesis_filterbank_samples_offset;
- ///l_APrev and l_A
- int e_a[2];
- ///Chirp factors
- float bw_array[5];
- ///QMF values of the original signal
- float W[2][32][32][2];
- ///QMF output of the HF adjustor
- int Ypos;
- DECLARE_ALIGNED(16, float, Y)[2][38][64][2];
- DECLARE_ALIGNED(16, float, g_temp)[42][48];
- float q_temp[42][48];
- uint8_t s_indexmapped[8][48];
- ///Envelope scalefactors
- float env_facs[6][48];
- ///Noise scalefactors
- float noise_facs[3][5];
- ///Envelope time borders
- uint8_t t_env[8];
- ///Envelope time border of the last envelope of the previous frame
- uint8_t t_env_num_env_old;
- ///Noise time borders
- uint8_t t_q[3];
- unsigned f_indexnoise;
- unsigned f_indexsine;
- /** @} */
-} SBRData;
-
-/**
- * Spectral Band Replication
- */
-typedef struct SpectralBandReplication {
- int sample_rate;
- int start;
- int reset;
- SpectrumParameters spectrum_params;
- int bs_amp_res_header;
- /**
- * @name Variables associated with bs_header_extra_2
- * @{
- */
- unsigned bs_limiter_bands;
- unsigned bs_limiter_gains;
- unsigned bs_interpol_freq;
- unsigned bs_smoothing_mode;
- /** @} */
- unsigned bs_coupling;
- unsigned k[5]; ///< k0, k1, k2
- ///kx', and kx respectively, kx is the first QMF subband where SBR is used.
- ///kx' is its value from the previous frame
- unsigned kx[2];
- ///M' and M respectively, M is the number of QMF subbands that use SBR.
- unsigned m[2];
- unsigned kx_and_m_pushed;
- ///The number of frequency bands in f_master
- unsigned n_master;
- SBRData data[2];
- PSContext ps;
- ///N_Low and N_High respectively, the number of frequency bands for low and high resolution
- unsigned n[2];
- ///Number of noise floor bands
- unsigned n_q;
- ///Number of limiter bands
- unsigned n_lim;
- ///The master QMF frequency grouping
- uint16_t f_master[49];
- ///Frequency borders for low resolution SBR
- uint16_t f_tablelow[25];
- ///Frequency borders for high resolution SBR
- uint16_t f_tablehigh[49];
- ///Frequency borders for noise floors
- uint16_t f_tablenoise[6];
- ///Frequency borders for the limiter
- uint16_t f_tablelim[30];
- unsigned num_patches;
- uint8_t patch_num_subbands[6];
- uint8_t patch_start_subband[6];
- ///QMF low frequency input to the HF generator
- DECLARE_ALIGNED(16, float, X_low)[32][40][2];
- ///QMF output of the HF generator
- DECLARE_ALIGNED(16, float, X_high)[64][40][2];
- ///QMF values of the reconstructed signal
- DECLARE_ALIGNED(16, float, X)[2][2][38][64];
- ///Zeroth coefficient used to filter the subband signals
- DECLARE_ALIGNED(16, float, alpha0)[64][2];
- ///First coefficient used to filter the subband signals
- DECLARE_ALIGNED(16, float, alpha1)[64][2];
- ///Dequantized envelope scalefactors, remapped
- float e_origmapped[7][48];
- ///Dequantized noise scalefactors, remapped
- float q_mapped[7][48];
- ///Sinusoidal presence, remapped
- uint8_t s_mapped[7][48];
- ///Estimated envelope
- float e_curr[7][48];
- ///Amplitude adjusted noise scalefactors
- float q_m[7][48];
- ///Sinusoidal levels
- float s_m[7][48];
- float gain[7][48];
- DECLARE_ALIGNED(32, float, qmf_filter_scratch)[5][64];
- FFTContext mdct_ana;
- FFTContext mdct;
- SBRDSPContext dsp;
-} SpectralBandReplication;
-
-#endif /* AVCODEC_SBR_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/sbrdsp.c b/src/thirdparty/ffmpeg/libavcodec/sbrdsp.c
deleted file mode 100644
index 937d48e88..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/sbrdsp.c
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * AAC Spectral Band Replication decoding functions
- * Copyright (c) 2008-2009 Robert Swain ( rob opendot cl )
- * Copyright (c) 2009-2010 Alex Converse <alex.converse@gmail.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "config.h"
-#include "libavutil/attributes.h"
-#include "sbrdsp.h"
-
-static void sbr_sum64x5_c(float *z)
-{
- int k;
- for (k = 0; k < 64; k++) {
- float f = z[k] + z[k + 64] + z[k + 128] + z[k + 192] + z[k + 256];
- z[k] = f;
- }
-}
-
-static float sbr_sum_square_c(float (*x)[2], int n)
-{
- float sum0 = 0.0f, sum1 = 0.0f;
- int i;
-
- for (i = 0; i < n; i += 2)
- {
- sum0 += x[i + 0][0] * x[i + 0][0];
- sum1 += x[i + 0][1] * x[i + 0][1];
- sum0 += x[i + 1][0] * x[i + 1][0];
- sum1 += x[i + 1][1] * x[i + 1][1];
- }
-
- return sum0 + sum1;
-}
-
-static void sbr_neg_odd_64_c(float *x)
-{
- int i;
- for (i = 1; i < 64; i += 2)
- x[i] = -x[i];
-}
-
-static void sbr_qmf_pre_shuffle_c(float *z)
-{
- int k;
- z[64] = z[0];
- z[65] = z[1];
- for (k = 1; k < 32; k++) {
- z[64+2*k ] = -z[64 - k];
- z[64+2*k+1] = z[ k + 1];
- }
-}
-
-static void sbr_qmf_post_shuffle_c(float W[32][2], const float *z)
-{
- int k;
- for (k = 0; k < 32; k++) {
- W[k][0] = -z[63-k];
- W[k][1] = z[k];
- }
-}
-
-static void sbr_qmf_deint_neg_c(float *v, const float *src)
-{
- int i;
- for (i = 0; i < 32; i++) {
- v[ i] = src[63 - 2*i ];
- v[63 - i] = -src[63 - 2*i - 1];
- }
-}
-
-static void sbr_qmf_deint_bfly_c(float *v, const float *src0, const float *src1)
-{
- int i;
- for (i = 0; i < 64; i++) {
- v[ i] = src0[i] - src1[63 - i];
- v[127 - i] = src0[i] + src1[63 - i];
- }
-}
-
-static av_always_inline void autocorrelate(const float x[40][2],
- float phi[3][2][2], int lag)
-{
- int i;
- float real_sum = 0.0f;
- float imag_sum = 0.0f;
- if (lag) {
- for (i = 1; i < 38; i++) {
- real_sum += x[i][0] * x[i+lag][0] + x[i][1] * x[i+lag][1];
- imag_sum += x[i][0] * x[i+lag][1] - x[i][1] * x[i+lag][0];
- }
- phi[2-lag][1][0] = real_sum + x[ 0][0] * x[lag][0] + x[ 0][1] * x[lag][1];
- phi[2-lag][1][1] = imag_sum + x[ 0][0] * x[lag][1] - x[ 0][1] * x[lag][0];
- if (lag == 1) {
- phi[0][0][0] = real_sum + x[38][0] * x[39][0] + x[38][1] * x[39][1];
- phi[0][0][1] = imag_sum + x[38][0] * x[39][1] - x[38][1] * x[39][0];
- }
- } else {
- for (i = 1; i < 38; i++) {
- real_sum += x[i][0] * x[i][0] + x[i][1] * x[i][1];
- }
- phi[2][1][0] = real_sum + x[ 0][0] * x[ 0][0] + x[ 0][1] * x[ 0][1];
- phi[1][0][0] = real_sum + x[38][0] * x[38][0] + x[38][1] * x[38][1];
- }
-}
-
-static void sbr_autocorrelate_c(const float x[40][2], float phi[3][2][2])
-{
- autocorrelate(x, phi, 0);
- autocorrelate(x, phi, 1);
- autocorrelate(x, phi, 2);
-}
-
-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)
-{
- float alpha[4];
- int i;
-
- alpha[0] = alpha1[0] * bw * bw;
- alpha[1] = alpha1[1] * bw * bw;
- alpha[2] = alpha0[0] * bw;
- alpha[3] = alpha0[1] * bw;
-
- for (i = start; i < end; i++) {
- X_high[i][0] =
- X_low[i - 2][0] * alpha[0] -
- X_low[i - 2][1] * alpha[1] +
- X_low[i - 1][0] * alpha[2] -
- X_low[i - 1][1] * alpha[3] +
- X_low[i][0];
- X_high[i][1] =
- X_low[i - 2][1] * alpha[0] +
- X_low[i - 2][0] * alpha[1] +
- X_low[i - 1][1] * alpha[2] +
- X_low[i - 1][0] * alpha[3] +
- X_low[i][1];
- }
-}
-
-static void sbr_hf_g_filt_c(float (*Y)[2], const float (*X_high)[40][2],
- const float *g_filt, int m_max, intptr_t ixh)
-{
- int m;
-
- for (m = 0; m < m_max; m++) {
- Y[m][0] = X_high[m][ixh][0] * g_filt[m];
- Y[m][1] = X_high[m][ixh][1] * g_filt[m];
- }
-}
-
-static av_always_inline void sbr_hf_apply_noise(float (*Y)[2],
- const float *s_m,
- const float *q_filt,
- int noise,
- float phi_sign0,
- float phi_sign1,
- int m_max)
-{
- int m;
-
- for (m = 0; m < m_max; m++) {
- float y0 = Y[m][0];
- float y1 = Y[m][1];
- noise = (noise + 1) & 0x1ff;
- if (s_m[m]) {
- y0 += s_m[m] * phi_sign0;
- y1 += s_m[m] * phi_sign1;
- } else {
- y0 += q_filt[m] * ff_sbr_noise_table[noise][0];
- y1 += q_filt[m] * ff_sbr_noise_table[noise][1];
- }
- Y[m][0] = y0;
- Y[m][1] = y1;
- phi_sign1 = -phi_sign1;
- }
-}
-
-static void sbr_hf_apply_noise_0(float (*Y)[2], const float *s_m,
- const float *q_filt, int noise,
- int kx, int m_max)
-{
- sbr_hf_apply_noise(Y, s_m, q_filt, noise, 1.0, 0.0, m_max);
-}
-
-static void sbr_hf_apply_noise_1(float (*Y)[2], const float *s_m,
- const float *q_filt, int noise,
- int kx, int m_max)
-{
- float phi_sign = 1 - 2 * (kx & 1);
- sbr_hf_apply_noise(Y, s_m, q_filt, noise, 0.0, phi_sign, m_max);
-}
-
-static void sbr_hf_apply_noise_2(float (*Y)[2], const float *s_m,
- const float *q_filt, int noise,
- int kx, int m_max)
-{
- sbr_hf_apply_noise(Y, s_m, q_filt, noise, -1.0, 0.0, m_max);
-}
-
-static void sbr_hf_apply_noise_3(float (*Y)[2], const float *s_m,
- const float *q_filt, int noise,
- int kx, int m_max)
-{
- float phi_sign = 1 - 2 * (kx & 1);
- sbr_hf_apply_noise(Y, s_m, q_filt, noise, 0.0, -phi_sign, m_max);
-}
-
-av_cold void ff_sbrdsp_init(SBRDSPContext *s)
-{
- s->sum64x5 = sbr_sum64x5_c;
- s->sum_square = sbr_sum_square_c;
- s->neg_odd_64 = sbr_neg_odd_64_c;
- s->qmf_pre_shuffle = sbr_qmf_pre_shuffle_c;
- s->qmf_post_shuffle = sbr_qmf_post_shuffle_c;
- s->qmf_deint_neg = sbr_qmf_deint_neg_c;
- s->qmf_deint_bfly = sbr_qmf_deint_bfly_c;
- s->autocorrelate = sbr_autocorrelate_c;
- s->hf_gen = sbr_hf_gen_c;
- s->hf_g_filt = sbr_hf_g_filt_c;
-
- s->hf_apply_noise[0] = sbr_hf_apply_noise_0;
- s->hf_apply_noise[1] = sbr_hf_apply_noise_1;
- s->hf_apply_noise[2] = sbr_hf_apply_noise_2;
- s->hf_apply_noise[3] = sbr_hf_apply_noise_3;
-
- if (ARCH_ARM)
- ff_sbrdsp_init_arm(s);
- if (ARCH_X86)
- ff_sbrdsp_init_x86(s);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/sbrdsp.h b/src/thirdparty/ffmpeg/libavcodec/sbrdsp.h
deleted file mode 100644
index 50a351934..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/sbrdsp.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2012 Mans Rullgard
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_SBRDSP_H
-#define AVCODEC_SBRDSP_H
-
-#include <stdint.h>
-
-typedef struct SBRDSPContext {
- void (*sum64x5)(float *z);
- float (*sum_square)(float (*x)[2], int n);
- void (*neg_odd_64)(float *x);
- void (*qmf_pre_shuffle)(float *z);
- void (*qmf_post_shuffle)(float W[32][2], const float *z);
- void (*qmf_deint_neg)(float *v, const float *src);
- void (*qmf_deint_bfly)(float *v, const float *src0, const float *src1);
- void (*autocorrelate)(const float x[40][2], float phi[3][2][2]);
- void (*hf_gen)(float (*X_high)[2], const float (*X_low)[2],
- const float alpha0[2], const float alpha1[2],
- float bw, int start, int end);
- void (*hf_g_filt)(float (*Y)[2], const float (*X_high)[40][2],
- const float *g_filt, int m_max, intptr_t ixh);
- void (*hf_apply_noise[4])(float (*Y)[2], const float *s_m,
- const float *q_filt, int noise,
- int kx, int m_max);
-} SBRDSPContext;
-
-extern const float ff_sbr_noise_table[][2];
-
-void ff_sbrdsp_init(SBRDSPContext *s);
-void ff_sbrdsp_init_arm(SBRDSPContext *s);
-void ff_sbrdsp_init_x86(SBRDSPContext *s);
-
-#endif /* AVCODEC_SBRDSP_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/simple_idct.c b/src/thirdparty/ffmpeg/libavcodec/simple_idct.c
deleted file mode 100644
index 02b308b9f..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/simple_idct.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Simple IDCT
- *
- * Copyright (c) 2001 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
- * simpleidct in C.
- */
-
-#include "libavutil/intreadwrite.h"
-#include "avcodec.h"
-#include "mathops.h"
-#include "simple_idct.h"
-
-#define BIT_DEPTH 8
-#include "simple_idct_template.c"
-#undef BIT_DEPTH
-
-#define BIT_DEPTH 10
-#include "simple_idct_template.c"
-#undef BIT_DEPTH
-
-/* 2x4x8 idct */
-
-#define CN_SHIFT 12
-#define C_FIX(x) ((int)((x) * (1 << CN_SHIFT) + 0.5))
-#define C1 C_FIX(0.6532814824)
-#define C2 C_FIX(0.2705980501)
-
-/* row idct is multiple by 16 * sqrt(2.0), col idct4 is normalized,
- and the butterfly must be multiplied by 0.5 * sqrt(2.0) */
-#define C_SHIFT (4+1+12)
-
-static inline void idct4col_put(uint8_t *dest, int line_size, const int16_t *col)
-{
- int c0, c1, c2, c3, a0, a1, a2, a3;
-
- a0 = col[8*0];
- a1 = col[8*2];
- a2 = col[8*4];
- a3 = col[8*6];
- c0 = ((a0 + a2) << (CN_SHIFT - 1)) + (1 << (C_SHIFT - 1));
- c2 = ((a0 - a2) << (CN_SHIFT - 1)) + (1 << (C_SHIFT - 1));
- c1 = a1 * C1 + a3 * C2;
- c3 = a1 * C2 - a3 * C1;
- dest[0] = av_clip_uint8((c0 + c1) >> C_SHIFT);
- dest += line_size;
- dest[0] = av_clip_uint8((c2 + c3) >> C_SHIFT);
- dest += line_size;
- dest[0] = av_clip_uint8((c2 - c3) >> C_SHIFT);
- dest += line_size;
- dest[0] = av_clip_uint8((c0 - c1) >> C_SHIFT);
-}
-
-#define BF(k) \
-{\
- int a0, a1;\
- a0 = ptr[k];\
- a1 = ptr[8 + k];\
- ptr[k] = a0 + a1;\
- ptr[8 + k] = a0 - a1;\
-}
-
-/* only used by DV codec. The input must be interlaced. 128 is added
- to the pixels before clamping to avoid systematic error
- (1024*sqrt(2)) offset would be needed otherwise. */
-/* XXX: I think a 1.0/sqrt(2) normalization should be needed to
- compensate the extra butterfly stage - I don't have the full DV
- specification */
-void ff_simple_idct248_put(uint8_t *dest, int line_size, int16_t *block)
-{
- int i;
- int16_t *ptr;
-
- /* butterfly */
- ptr = block;
- for(i=0;i<4;i++) {
- BF(0);
- BF(1);
- BF(2);
- BF(3);
- BF(4);
- BF(5);
- BF(6);
- BF(7);
- ptr += 2 * 8;
- }
-
- /* IDCT8 on each line */
- for(i=0; i<8; i++) {
- idctRowCondDC_8(block + i*8, 0);
- }
-
- /* IDCT4 and store */
- for(i=0;i<8;i++) {
- idct4col_put(dest + i, 2 * line_size, block + i);
- idct4col_put(dest + line_size + i, 2 * line_size, block + 8 + i);
- }
-}
-
-/* 8x4 & 4x8 WMV2 IDCT */
-#undef CN_SHIFT
-#undef C_SHIFT
-#undef C_FIX
-#undef C1
-#undef C2
-#define CN_SHIFT 12
-#define C_FIX(x) ((int)((x) * 1.414213562 * (1 << CN_SHIFT) + 0.5))
-#define C1 C_FIX(0.6532814824)
-#define C2 C_FIX(0.2705980501)
-#define C3 C_FIX(0.5)
-#define C_SHIFT (4+1+12)
-static inline void idct4col_add(uint8_t *dest, int line_size, const int16_t *col)
-{
- int c0, c1, c2, c3, a0, a1, a2, a3;
-
- a0 = col[8*0];
- a1 = col[8*1];
- a2 = col[8*2];
- a3 = col[8*3];
- c0 = (a0 + a2)*C3 + (1 << (C_SHIFT - 1));
- c2 = (a0 - a2)*C3 + (1 << (C_SHIFT - 1));
- c1 = a1 * C1 + a3 * C2;
- c3 = a1 * C2 - a3 * C1;
- dest[0] = av_clip_uint8(dest[0] + ((c0 + c1) >> C_SHIFT));
- dest += line_size;
- dest[0] = av_clip_uint8(dest[0] + ((c2 + c3) >> C_SHIFT));
- dest += line_size;
- dest[0] = av_clip_uint8(dest[0] + ((c2 - c3) >> C_SHIFT));
- dest += line_size;
- dest[0] = av_clip_uint8(dest[0] + ((c0 - c1) >> C_SHIFT));
-}
-
-#define RN_SHIFT 15
-#define R_FIX(x) ((int)((x) * 1.414213562 * (1 << RN_SHIFT) + 0.5))
-#define R1 R_FIX(0.6532814824)
-#define R2 R_FIX(0.2705980501)
-#define R3 R_FIX(0.5)
-#define R_SHIFT 11
-static inline void idct4row(int16_t *row)
-{
- int c0, c1, c2, c3, a0, a1, a2, a3;
-
- a0 = row[0];
- a1 = row[1];
- a2 = row[2];
- a3 = row[3];
- c0 = (a0 + a2)*R3 + (1 << (R_SHIFT - 1));
- c2 = (a0 - a2)*R3 + (1 << (R_SHIFT - 1));
- c1 = a1 * R1 + a3 * R2;
- c3 = a1 * R2 - a3 * R1;
- row[0]= (c0 + c1) >> R_SHIFT;
- row[1]= (c2 + c3) >> R_SHIFT;
- row[2]= (c2 - c3) >> R_SHIFT;
- row[3]= (c0 - c1) >> R_SHIFT;
-}
-
-void ff_simple_idct84_add(uint8_t *dest, int line_size, int16_t *block)
-{
- int i;
-
- /* IDCT8 on each line */
- for(i=0; i<4; i++) {
- idctRowCondDC_8(block + i*8, 0);
- }
-
- /* IDCT4 and store */
- for(i=0;i<8;i++) {
- idct4col_add(dest + i, line_size, block + i);
- }
-}
-
-void ff_simple_idct48_add(uint8_t *dest, int line_size, int16_t *block)
-{
- int i;
-
- /* IDCT4 on each line */
- for(i=0; i<8; i++) {
- idct4row(block + i*8);
- }
-
- /* IDCT8 and store */
- for(i=0; i<4; i++){
- idctSparseColAdd_8(dest + i, line_size, block + i);
- }
-}
-
-void ff_simple_idct44_add(uint8_t *dest, int line_size, int16_t *block)
-{
- int i;
-
- /* IDCT4 on each line */
- for(i=0; i<4; i++) {
- idct4row(block + i*8);
- }
-
- /* IDCT4 and store */
- for(i=0; i<4; i++){
- idct4col_add(dest + i, line_size, block + i);
- }
-}
-
-void ff_prores_idct(int16_t *block, const int16_t *qmat)
-{
- int i;
-
- for (i = 0; i < 64; i++)
- block[i] *= qmat[i];
-
- for (i = 0; i < 8; i++)
- idctRowCondDC_10(block + i*8, 2);
-
- for (i = 0; i < 8; i++)
- idctSparseCol_10(block + i);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/simple_idct.h b/src/thirdparty/ffmpeg/libavcodec/simple_idct.h
deleted file mode 100644
index 942d7c7a4..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/simple_idct.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Simple IDCT
- *
- * Copyright (c) 2001 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
- * simple idct header.
- */
-
-#ifndef AVCODEC_SIMPLE_IDCT_H
-#define AVCODEC_SIMPLE_IDCT_H
-
-#include <stdint.h>
-
-void ff_simple_idct_put_8(uint8_t *dest, int line_size, int16_t *block);
-void ff_simple_idct_add_8(uint8_t *dest, int line_size, int16_t *block);
-void ff_simple_idct_8(int16_t *block);
-
-void ff_simple_idct_put_10(uint8_t *dest, int line_size, int16_t *block);
-void ff_simple_idct_add_10(uint8_t *dest, int line_size, int16_t *block);
-void ff_simple_idct_10(int16_t *block);
-/**
- * Special version of ff_simple_idct_10() which does dequantization
- * and scales by a factor of 2 more between the two IDCTs to account
- * for larger scale of input coefficients.
- */
-void ff_prores_idct(int16_t *block, const int16_t *qmat);
-
-void ff_simple_idct_mmx(int16_t *block);
-void ff_simple_idct_add_mmx(uint8_t *dest, int line_size, int16_t *block);
-void ff_simple_idct_put_mmx(uint8_t *dest, int line_size, int16_t *block);
-
-void ff_simple_idct248_put(uint8_t *dest, int line_size, int16_t *block);
-
-void ff_simple_idct84_add(uint8_t *dest, int line_size, int16_t *block);
-void ff_simple_idct48_add(uint8_t *dest, int line_size, int16_t *block);
-void ff_simple_idct44_add(uint8_t *dest, int line_size, int16_t *block);
-
-#endif /* AVCODEC_SIMPLE_IDCT_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/simple_idct_template.c b/src/thirdparty/ffmpeg/libavcodec/simple_idct_template.c
deleted file mode 100644
index a0ecf53d4..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/simple_idct_template.c
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- * Simple IDCT
- *
- * Copyright (c) 2001 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
- * simpleidct in C.
- */
-
-/*
- based upon some outcommented c code from mpeg2dec (idct_mmx.c
- written by Aaron Holtzman <aholtzma@ess.engr.uvic.ca>)
- */
-
-#include "bit_depth_template.c"
-
-#undef W1
-#undef W2
-#undef W3
-#undef W4
-#undef W5
-#undef W6
-#undef W7
-#undef ROW_SHIFT
-#undef COL_SHIFT
-#undef DC_SHIFT
-#undef MUL
-#undef MAC
-
-#if BIT_DEPTH == 8
-
-#define W1 22725 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define W2 21407 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define W3 19266 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define W4 16383 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define W5 12873 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define W6 8867 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define W7 4520 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-
-#define ROW_SHIFT 11
-#define COL_SHIFT 20
-#define DC_SHIFT 3
-
-#define MUL(a, b) MUL16(a, b)
-#define MAC(a, b, c) MAC16(a, b, c)
-
-#elif 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 ROW_SHIFT 15
-#define COL_SHIFT 20
-#define DC_SHIFT 1
-
-#define MUL(a, b) ((a) * (b))
-#define MAC(a, b, c) ((a) += (b) * (c))
-
-#else
-
-#error "Unsupported bitdepth"
-
-#endif
-
-static inline void FUNC(idctRowCondDC)(int16_t *row, int extra_shift)
-{
- int a0, a1, a2, a3, b0, b1, b2, b3;
-
-#if HAVE_FAST_64BIT
-#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) {
- temp = (row[0] << (DC_SHIFT - extra_shift)) & 0xffff;
- } else {
- temp = (row[0] >> (extra_shift - DC_SHIFT)) & 0xffff;
- }
- temp += temp << 16;
- temp += temp << 32;
- ((uint64_t *)row)[0] = temp;
- ((uint64_t *)row)[1] = temp;
- return;
- }
-#else
- if (!(((uint32_t*)row)[1] |
- ((uint32_t*)row)[2] |
- ((uint32_t*)row)[3] |
- row[1])) {
- uint32_t temp;
- if (DC_SHIFT - extra_shift > 0) {
- temp = (row[0] << (DC_SHIFT - extra_shift)) & 0xffff;
- } else {
- temp = (row[0] >> (extra_shift - DC_SHIFT)) & 0xffff;
- }
- temp += temp << 16;
- ((uint32_t*)row)[0]=((uint32_t*)row)[1] =
- ((uint32_t*)row)[2]=((uint32_t*)row)[3] = temp;
- return;
- }
-#endif
-
- a0 = (W4 * row[0]) + (1 << (ROW_SHIFT - 1));
- a1 = a0;
- a2 = a0;
- a3 = a0;
-
- a0 += W2 * row[2];
- a1 += W6 * row[2];
- a2 -= W6 * row[2];
- a3 -= W2 * row[2];
-
- b0 = MUL(W1, row[1]);
- MAC(b0, W3, row[3]);
- b1 = MUL(W3, row[1]);
- MAC(b1, -W7, row[3]);
- b2 = MUL(W5, row[1]);
- MAC(b2, -W1, row[3]);
- b3 = MUL(W7, row[1]);
- MAC(b3, -W5, row[3]);
-
- if (AV_RN64A(row + 4)) {
- a0 += W4*row[4] + W6*row[6];
- a1 += - W4*row[4] - W2*row[6];
- a2 += - W4*row[4] + W2*row[6];
- a3 += W4*row[4] - W6*row[6];
-
- MAC(b0, W5, row[5]);
- MAC(b0, W7, row[7]);
-
- MAC(b1, -W1, row[5]);
- MAC(b1, -W5, row[7]);
-
- MAC(b2, W7, row[5]);
- MAC(b2, W3, row[7]);
-
- MAC(b3, W3, row[5]);
- MAC(b3, -W1, row[7]);
- }
-
- row[0] = (a0 + b0) >> (ROW_SHIFT + extra_shift);
- row[7] = (a0 - b0) >> (ROW_SHIFT + extra_shift);
- row[1] = (a1 + b1) >> (ROW_SHIFT + extra_shift);
- row[6] = (a1 - b1) >> (ROW_SHIFT + extra_shift);
- row[2] = (a2 + b2) >> (ROW_SHIFT + extra_shift);
- row[5] = (a2 - b2) >> (ROW_SHIFT + extra_shift);
- row[3] = (a3 + b3) >> (ROW_SHIFT + extra_shift);
- row[4] = (a3 - b3) >> (ROW_SHIFT + extra_shift);
-}
-
-#define IDCT_COLS do { \
- a0 = W4 * (col[8*0] + ((1<<(COL_SHIFT-1))/W4)); \
- a1 = a0; \
- a2 = a0; \
- a3 = a0; \
- \
- a0 += W2*col[8*2]; \
- a1 += W6*col[8*2]; \
- a2 += -W6*col[8*2]; \
- a3 += -W2*col[8*2]; \
- \
- b0 = MUL(W1, col[8*1]); \
- b1 = MUL(W3, col[8*1]); \
- b2 = MUL(W5, col[8*1]); \
- b3 = MUL(W7, col[8*1]); \
- \
- MAC(b0, W3, col[8*3]); \
- MAC(b1, -W7, col[8*3]); \
- MAC(b2, -W1, col[8*3]); \
- MAC(b3, -W5, col[8*3]); \
- \
- if (col[8*4]) { \
- a0 += W4*col[8*4]; \
- a1 += -W4*col[8*4]; \
- a2 += -W4*col[8*4]; \
- a3 += W4*col[8*4]; \
- } \
- \
- if (col[8*5]) { \
- MAC(b0, W5, col[8*5]); \
- MAC(b1, -W1, col[8*5]); \
- MAC(b2, W7, col[8*5]); \
- MAC(b3, W3, col[8*5]); \
- } \
- \
- if (col[8*6]) { \
- a0 += W6*col[8*6]; \
- a1 += -W2*col[8*6]; \
- a2 += W2*col[8*6]; \
- a3 += -W6*col[8*6]; \
- } \
- \
- if (col[8*7]) { \
- MAC(b0, W7, col[8*7]); \
- MAC(b1, -W5, col[8*7]); \
- MAC(b2, W3, col[8*7]); \
- MAC(b3, -W1, col[8*7]); \
- } \
- } while (0)
-
-static inline void FUNC(idctSparseColPut)(pixel *dest, int line_size,
- int16_t *col)
-{
- int a0, a1, a2, a3, b0, b1, b2, b3;
-
- IDCT_COLS;
-
- dest[0] = av_clip_pixel((a0 + b0) >> COL_SHIFT);
- dest += line_size;
- dest[0] = av_clip_pixel((a1 + b1) >> COL_SHIFT);
- dest += line_size;
- dest[0] = av_clip_pixel((a2 + b2) >> COL_SHIFT);
- dest += line_size;
- dest[0] = av_clip_pixel((a3 + b3) >> COL_SHIFT);
- dest += line_size;
- dest[0] = av_clip_pixel((a3 - b3) >> COL_SHIFT);
- dest += line_size;
- dest[0] = av_clip_pixel((a2 - b2) >> COL_SHIFT);
- dest += line_size;
- dest[0] = av_clip_pixel((a1 - b1) >> COL_SHIFT);
- dest += line_size;
- dest[0] = av_clip_pixel((a0 - b0) >> COL_SHIFT);
-}
-
-static inline void FUNC(idctSparseColAdd)(pixel *dest, int line_size,
- int16_t *col)
-{
- int a0, a1, a2, a3, b0, b1, b2, b3;
-
- IDCT_COLS;
-
- dest[0] = av_clip_pixel(dest[0] + ((a0 + b0) >> COL_SHIFT));
- dest += line_size;
- dest[0] = av_clip_pixel(dest[0] + ((a1 + b1) >> COL_SHIFT));
- dest += line_size;
- dest[0] = av_clip_pixel(dest[0] + ((a2 + b2) >> COL_SHIFT));
- dest += line_size;
- dest[0] = av_clip_pixel(dest[0] + ((a3 + b3) >> COL_SHIFT));
- dest += line_size;
- dest[0] = av_clip_pixel(dest[0] + ((a3 - b3) >> COL_SHIFT));
- dest += line_size;
- dest[0] = av_clip_pixel(dest[0] + ((a2 - b2) >> COL_SHIFT));
- dest += line_size;
- dest[0] = av_clip_pixel(dest[0] + ((a1 - b1) >> COL_SHIFT));
- dest += line_size;
- dest[0] = av_clip_pixel(dest[0] + ((a0 - b0) >> COL_SHIFT));
-}
-
-static inline void FUNC(idctSparseCol)(int16_t *col)
-{
- int a0, a1, a2, a3, b0, b1, b2, b3;
-
- IDCT_COLS;
-
- col[0 ] = ((a0 + b0) >> COL_SHIFT);
- col[8 ] = ((a1 + b1) >> COL_SHIFT);
- col[16] = ((a2 + b2) >> COL_SHIFT);
- col[24] = ((a3 + b3) >> COL_SHIFT);
- col[32] = ((a3 - b3) >> COL_SHIFT);
- col[40] = ((a2 - b2) >> COL_SHIFT);
- col[48] = ((a1 - b1) >> COL_SHIFT);
- col[56] = ((a0 - b0) >> COL_SHIFT);
-}
-
-void FUNC(ff_simple_idct_put)(uint8_t *dest_, int line_size, int16_t *block)
-{
- pixel *dest = (pixel *)dest_;
- int i;
-
- line_size /= sizeof(pixel);
-
- for (i = 0; i < 8; i++)
- FUNC(idctRowCondDC)(block + i*8, 0);
-
- for (i = 0; i < 8; i++)
- FUNC(idctSparseColPut)(dest + i, line_size, block + i);
-}
-
-void FUNC(ff_simple_idct_add)(uint8_t *dest_, int line_size, int16_t *block)
-{
- pixel *dest = (pixel *)dest_;
- int i;
-
- line_size /= sizeof(pixel);
-
- for (i = 0; i < 8; i++)
- FUNC(idctRowCondDC)(block + i*8, 0);
-
- for (i = 0; i < 8; i++)
- FUNC(idctSparseColAdd)(dest + i, line_size, block + i);
-}
-
-void FUNC(ff_simple_idct)(int16_t *block)
-{
- int i;
-
- for (i = 0; i < 8; i++)
- FUNC(idctRowCondDC)(block + i*8, 0);
-
- for (i = 0; i < 8; i++)
- FUNC(idctSparseCol)(block + i);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/sinewin.c b/src/thirdparty/ffmpeg/libavcodec/sinewin.c
deleted file mode 100644
index 377c78d57..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/sinewin.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * 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 "sinewin.h"
-#include "sinewin_tablegen.h"
diff --git a/src/thirdparty/ffmpeg/libavcodec/sinewin.h b/src/thirdparty/ffmpeg/libavcodec/sinewin.h
deleted file mode 100644
index 1ae7a4062..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/sinewin.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2008 Robert Swain
- *
- * 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_SINEWIN_H
-#define AVCODEC_SINEWIN_H
-
-#include "config.h"
-#include "libavutil/mem.h"
-
-#if CONFIG_HARDCODED_TABLES
-# define SINETABLE_CONST const
-#else
-# define SINETABLE_CONST
-#endif
-
-#define SINETABLE(size) \
- SINETABLE_CONST DECLARE_ALIGNED(32, float, ff_sine_##size)[size]
-
-/**
- * Generate a sine window.
- * @param window pointer to half window
- * @param n size of half window
- */
-void ff_sine_window_init(float *window, int n);
-
-/**
- * initialize the specified entry of ff_sine_windows
- */
-void ff_init_ff_sine_windows(int index);
-
-extern SINETABLE( 32);
-extern SINETABLE( 64);
-extern SINETABLE( 128);
-extern SINETABLE( 256);
-extern SINETABLE( 512);
-extern SINETABLE(1024);
-extern SINETABLE(2048);
-extern SINETABLE(4096);
-extern SINETABLE(8192);
-
-extern SINETABLE_CONST float * const ff_sine_windows[14];
-
-#endif /* AVCODEC_SINEWIN_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/sinewin_tablegen.h b/src/thirdparty/ffmpeg/libavcodec/sinewin_tablegen.h
deleted file mode 100644
index ee2c88cb6..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/sinewin_tablegen.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Header file for hardcoded sine windows
- *
- * Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
- *
- * 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_SINEWIN_TABLEGEN_H
-#define AVCODEC_SINEWIN_TABLEGEN_H
-
-#include <assert.h>
-// do not use libavutil/libm.h since this is compiled both
-// for the host and the target and config.h is only valid for the target
-#include <math.h>
-#include "libavutil/attributes.h"
-#include "libavutil/common.h"
-
-#if !CONFIG_HARDCODED_TABLES
-SINETABLE( 32);
-SINETABLE( 64);
-SINETABLE( 128);
-SINETABLE( 256);
-SINETABLE( 512);
-SINETABLE(1024);
-SINETABLE(2048);
-SINETABLE(4096);
-SINETABLE(8192);
-#else
-#include "libavcodec/sinewin_tables.h"
-#endif
-
-SINETABLE_CONST float * const ff_sine_windows[] = {
- NULL, NULL, NULL, NULL, NULL, // unused
- ff_sine_32 , ff_sine_64 ,
- ff_sine_128, ff_sine_256, ff_sine_512, ff_sine_1024, ff_sine_2048, ff_sine_4096, ff_sine_8192
-};
-
-// Generate a sine window.
-av_cold void ff_sine_window_init(float *window, int n) {
- int i;
- for(i = 0; i < n; i++)
- window[i] = sinf((i + 0.5) * (M_PI / (2.0 * n)));
-}
-
-av_cold void ff_init_ff_sine_windows(int index) {
- assert(index >= 0 && index < FF_ARRAY_ELEMS(ff_sine_windows));
-#if !CONFIG_HARDCODED_TABLES
- ff_sine_window_init(ff_sine_windows[index], 1 << index);
-#endif
-}
-
-#endif /* AVCODEC_SINEWIN_TABLEGEN_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/sipr.c b/src/thirdparty/ffmpeg/libavcodec/sipr.c
deleted file mode 100644
index c03f30680..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/sipr.c
+++ /dev/null
@@ -1,576 +0,0 @@
-/*
- * SIPR / ACELP.NET decoder
- *
- * Copyright (c) 2008 Vladimir Voroshilov
- * Copyright (c) 2009 Vitor Sessak
- *
- * 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 <math.h>
-#include <stdint.h>
-#include <string.h>
-
-#include "libavutil/channel_layout.h"
-#include "libavutil/float_dsp.h"
-#include "libavutil/mathematics.h"
-#include "avcodec.h"
-#define BITSTREAM_READER_LE
-#include "get_bits.h"
-#include "internal.h"
-
-#include "lsp.h"
-#include "acelp_vectors.h"
-#include "acelp_pitch_delay.h"
-#include "acelp_filters.h"
-#include "celp_filters.h"
-
-#define MAX_SUBFRAME_COUNT 5
-
-#include "sipr.h"
-#include "siprdata.h"
-
-typedef struct {
- const char *mode_name;
- uint16_t bits_per_frame;
- uint8_t subframe_count;
- uint8_t frames_per_packet;
- float pitch_sharp_factor;
-
- /* bitstream parameters */
- uint8_t number_of_fc_indexes;
- uint8_t ma_predictor_bits; ///< size in bits of the switched MA predictor
-
- /** size in bits of the i-th stage vector of quantizer */
- uint8_t vq_indexes_bits[5];
-
- /** size in bits of the adaptive-codebook index for every subframe */
- uint8_t pitch_delay_bits[5];
-
- uint8_t gp_index_bits;
- uint8_t fc_index_bits[10]; ///< size in bits of the fixed codebook indexes
- uint8_t gc_index_bits; ///< size in bits of the gain codebook indexes
-} SiprModeParam;
-
-static const SiprModeParam modes[MODE_COUNT] = {
- [MODE_16k] = {
- .mode_name = "16k",
- .bits_per_frame = 160,
- .subframe_count = SUBFRAME_COUNT_16k,
- .frames_per_packet = 1,
- .pitch_sharp_factor = 0.00,
-
- .number_of_fc_indexes = 10,
- .ma_predictor_bits = 1,
- .vq_indexes_bits = {7, 8, 7, 7, 7},
- .pitch_delay_bits = {9, 6},
- .gp_index_bits = 4,
- .fc_index_bits = {4, 5, 4, 5, 4, 5, 4, 5, 4, 5},
- .gc_index_bits = 5
- },
-
- [MODE_8k5] = {
- .mode_name = "8k5",
- .bits_per_frame = 152,
- .subframe_count = 3,
- .frames_per_packet = 1,
- .pitch_sharp_factor = 0.8,
-
- .number_of_fc_indexes = 3,
- .ma_predictor_bits = 0,
- .vq_indexes_bits = {6, 7, 7, 7, 5},
- .pitch_delay_bits = {8, 5, 5},
- .gp_index_bits = 0,
- .fc_index_bits = {9, 9, 9},
- .gc_index_bits = 7
- },
-
- [MODE_6k5] = {
- .mode_name = "6k5",
- .bits_per_frame = 232,
- .subframe_count = 3,
- .frames_per_packet = 2,
- .pitch_sharp_factor = 0.8,
-
- .number_of_fc_indexes = 3,
- .ma_predictor_bits = 0,
- .vq_indexes_bits = {6, 7, 7, 7, 5},
- .pitch_delay_bits = {8, 5, 5},
- .gp_index_bits = 0,
- .fc_index_bits = {5, 5, 5},
- .gc_index_bits = 7
- },
-
- [MODE_5k0] = {
- .mode_name = "5k0",
- .bits_per_frame = 296,
- .subframe_count = 5,
- .frames_per_packet = 2,
- .pitch_sharp_factor = 0.85,
-
- .number_of_fc_indexes = 1,
- .ma_predictor_bits = 0,
- .vq_indexes_bits = {6, 7, 7, 7, 5},
- .pitch_delay_bits = {8, 5, 8, 5, 5},
- .gp_index_bits = 0,
- .fc_index_bits = {10},
- .gc_index_bits = 7
- }
-};
-
-const float ff_pow_0_5[] = {
- 1.0/(1 << 1), 1.0/(1 << 2), 1.0/(1 << 3), 1.0/(1 << 4),
- 1.0/(1 << 5), 1.0/(1 << 6), 1.0/(1 << 7), 1.0/(1 << 8),
- 1.0/(1 << 9), 1.0/(1 << 10), 1.0/(1 << 11), 1.0/(1 << 12),
- 1.0/(1 << 13), 1.0/(1 << 14), 1.0/(1 << 15), 1.0/(1 << 16)
-};
-
-static void dequant(float *out, const int *idx, const float *cbs[])
-{
- int i;
- int stride = 2;
- int num_vec = 5;
-
- for (i = 0; i < num_vec; i++)
- memcpy(out + stride*i, cbs[i] + stride*idx[i], stride*sizeof(float));
-
-}
-
-static void lsf_decode_fp(float *lsfnew, float *lsf_history,
- const SiprParameters *parm)
-{
- int i;
- float lsf_tmp[LP_FILTER_ORDER];
-
- dequant(lsf_tmp, parm->vq_indexes, lsf_codebooks);
-
- for (i = 0; i < LP_FILTER_ORDER; i++)
- lsfnew[i] = lsf_history[i] * 0.33 + lsf_tmp[i] + mean_lsf[i];
-
- ff_sort_nearly_sorted_floats(lsfnew, LP_FILTER_ORDER - 1);
-
- /* Note that a minimum distance is not enforced between the last value and
- the previous one, contrary to what is done in ff_acelp_reorder_lsf() */
- ff_set_min_dist_lsf(lsfnew, LSFQ_DIFF_MIN, LP_FILTER_ORDER - 1);
- lsfnew[9] = FFMIN(lsfnew[LP_FILTER_ORDER - 1], 1.3 * M_PI);
-
- memcpy(lsf_history, lsf_tmp, LP_FILTER_ORDER * sizeof(*lsf_history));
-
- for (i = 0; i < LP_FILTER_ORDER - 1; i++)
- lsfnew[i] = cos(lsfnew[i]);
- lsfnew[LP_FILTER_ORDER - 1] *= 6.153848 / M_PI;
-}
-
-/** Apply pitch lag to the fixed vector (AMR section 6.1.2). */
-static void pitch_sharpening(int pitch_lag_int, float beta,
- float *fixed_vector)
-{
- int i;
-
- for (i = pitch_lag_int; i < SUBFR_SIZE; i++)
- fixed_vector[i] += beta * fixed_vector[i - pitch_lag_int];
-}
-
-/**
- * Extract decoding parameters from the input bitstream.
- * @param parms parameters structure
- * @param pgb pointer to initialized GetBitContext structure
- */
-static void decode_parameters(SiprParameters* parms, GetBitContext *pgb,
- const SiprModeParam *p)
-{
- int i, j;
-
- if (p->ma_predictor_bits)
- parms->ma_pred_switch = get_bits(pgb, p->ma_predictor_bits);
-
- for (i = 0; i < 5; i++)
- parms->vq_indexes[i] = get_bits(pgb, p->vq_indexes_bits[i]);
-
- for (i = 0; i < p->subframe_count; i++) {
- parms->pitch_delay[i] = get_bits(pgb, p->pitch_delay_bits[i]);
- if (p->gp_index_bits)
- parms->gp_index[i] = get_bits(pgb, p->gp_index_bits);
-
- for (j = 0; j < p->number_of_fc_indexes; j++)
- parms->fc_indexes[i][j] = get_bits(pgb, p->fc_index_bits[j]);
-
- parms->gc_index[i] = get_bits(pgb, p->gc_index_bits);
- }
-}
-
-static void sipr_decode_lp(float *lsfnew, const float *lsfold, float *Az,
- int num_subfr)
-{
- double lsfint[LP_FILTER_ORDER];
- int i,j;
- float t, t0 = 1.0 / num_subfr;
-
- t = t0 * 0.5;
- for (i = 0; i < num_subfr; i++) {
- for (j = 0; j < LP_FILTER_ORDER; j++)
- lsfint[j] = lsfold[j] * (1 - t) + t * lsfnew[j];
-
- ff_amrwb_lsp2lpc(lsfint, Az, LP_FILTER_ORDER);
- Az += LP_FILTER_ORDER;
- t += t0;
- }
-}
-
-/**
- * Evaluate the adaptive impulse response.
- */
-static void eval_ir(const float *Az, int pitch_lag, float *freq,
- float pitch_sharp_factor)
-{
- float tmp1[SUBFR_SIZE+1], tmp2[LP_FILTER_ORDER+1];
- int i;
-
- tmp1[0] = 1.;
- for (i = 0; i < LP_FILTER_ORDER; i++) {
- tmp1[i+1] = Az[i] * ff_pow_0_55[i];
- tmp2[i ] = Az[i] * ff_pow_0_7 [i];
- }
- memset(tmp1 + 11, 0, 37 * sizeof(float));
-
- ff_celp_lp_synthesis_filterf(freq, tmp2, tmp1, SUBFR_SIZE,
- LP_FILTER_ORDER);
-
- pitch_sharpening(pitch_lag, pitch_sharp_factor, freq);
-}
-
-/**
- * Evaluate the convolution of a vector with a sparse vector.
- */
-static void convolute_with_sparse(float *out, const AMRFixed *pulses,
- const float *shape, int length)
-{
- int i, j;
-
- memset(out, 0, length*sizeof(float));
- for (i = 0; i < pulses->n; i++)
- for (j = pulses->x[i]; j < length; j++)
- out[j] += pulses->y[i] * shape[j - pulses->x[i]];
-}
-
-/**
- * Apply postfilter, very similar to AMR one.
- */
-static void postfilter_5k0(SiprContext *ctx, const float *lpc, float *samples)
-{
- float buf[SUBFR_SIZE + LP_FILTER_ORDER];
- float *pole_out = buf + LP_FILTER_ORDER;
- float lpc_n[LP_FILTER_ORDER];
- float lpc_d[LP_FILTER_ORDER];
- int i;
-
- for (i = 0; i < LP_FILTER_ORDER; i++) {
- lpc_d[i] = lpc[i] * ff_pow_0_75[i];
- lpc_n[i] = lpc[i] * ff_pow_0_5 [i];
- };
-
- memcpy(pole_out - LP_FILTER_ORDER, ctx->postfilter_mem,
- LP_FILTER_ORDER*sizeof(float));
-
- ff_celp_lp_synthesis_filterf(pole_out, lpc_d, samples, SUBFR_SIZE,
- LP_FILTER_ORDER);
-
- memcpy(ctx->postfilter_mem, pole_out + SUBFR_SIZE - LP_FILTER_ORDER,
- LP_FILTER_ORDER*sizeof(float));
-
- ff_tilt_compensation(&ctx->tilt_mem, 0.4, pole_out, SUBFR_SIZE);
-
- memcpy(pole_out - LP_FILTER_ORDER, ctx->postfilter_mem5k0,
- LP_FILTER_ORDER*sizeof(*pole_out));
-
- memcpy(ctx->postfilter_mem5k0, pole_out + SUBFR_SIZE - LP_FILTER_ORDER,
- LP_FILTER_ORDER*sizeof(*pole_out));
-
- ff_celp_lp_zero_synthesis_filterf(samples, lpc_n, pole_out, SUBFR_SIZE,
- LP_FILTER_ORDER);
-
-}
-
-static void decode_fixed_sparse(AMRFixed *fixed_sparse, const int16_t *pulses,
- SiprMode mode, int low_gain)
-{
- int i;
-
- switch (mode) {
- case MODE_6k5:
- for (i = 0; i < 3; i++) {
- fixed_sparse->x[i] = 3 * (pulses[i] & 0xf) + i;
- fixed_sparse->y[i] = pulses[i] & 0x10 ? -1 : 1;
- }
- fixed_sparse->n = 3;
- break;
- case MODE_8k5:
- for (i = 0; i < 3; i++) {
- fixed_sparse->x[2*i ] = 3 * ((pulses[i] >> 4) & 0xf) + i;
- fixed_sparse->x[2*i + 1] = 3 * ( pulses[i] & 0xf) + i;
-
- fixed_sparse->y[2*i ] = (pulses[i] & 0x100) ? -1.0: 1.0;
-
- fixed_sparse->y[2*i + 1] =
- (fixed_sparse->x[2*i + 1] < fixed_sparse->x[2*i]) ?
- -fixed_sparse->y[2*i ] : fixed_sparse->y[2*i];
- }
-
- fixed_sparse->n = 6;
- break;
- case MODE_5k0:
- default:
- if (low_gain) {
- int offset = (pulses[0] & 0x200) ? 2 : 0;
- int val = pulses[0];
-
- for (i = 0; i < 3; i++) {
- int index = (val & 0x7) * 6 + 4 - i*2;
-
- fixed_sparse->y[i] = (offset + index) & 0x3 ? -1 : 1;
- fixed_sparse->x[i] = index;
-
- val >>= 3;
- }
- fixed_sparse->n = 3;
- } else {
- int pulse_subset = (pulses[0] >> 8) & 1;
-
- fixed_sparse->x[0] = ((pulses[0] >> 4) & 15) * 3 + pulse_subset;
- fixed_sparse->x[1] = ( pulses[0] & 15) * 3 + pulse_subset + 1;
-
- fixed_sparse->y[0] = pulses[0] & 0x200 ? -1 : 1;
- fixed_sparse->y[1] = -fixed_sparse->y[0];
- fixed_sparse->n = 2;
- }
- break;
- }
-}
-
-static void decode_frame(SiprContext *ctx, SiprParameters *params,
- float *out_data)
-{
- int i, j;
- int subframe_count = modes[ctx->mode].subframe_count;
- int frame_size = subframe_count * SUBFR_SIZE;
- float Az[LP_FILTER_ORDER * MAX_SUBFRAME_COUNT];
- float *excitation;
- float ir_buf[SUBFR_SIZE + LP_FILTER_ORDER];
- float lsf_new[LP_FILTER_ORDER];
- float *impulse_response = ir_buf + LP_FILTER_ORDER;
- float *synth = ctx->synth_buf + 16; // 16 instead of LP_FILTER_ORDER for
- // memory alignment
- int t0_first = 0;
- AMRFixed fixed_cb;
-
- memset(ir_buf, 0, LP_FILTER_ORDER * sizeof(float));
- lsf_decode_fp(lsf_new, ctx->lsf_history, params);
-
- sipr_decode_lp(lsf_new, ctx->lsp_history, Az, subframe_count);
-
- memcpy(ctx->lsp_history, lsf_new, LP_FILTER_ORDER * sizeof(float));
-
- excitation = ctx->excitation + PITCH_DELAY_MAX + L_INTERPOL;
-
- for (i = 0; i < subframe_count; i++) {
- float *pAz = Az + i*LP_FILTER_ORDER;
- float fixed_vector[SUBFR_SIZE];
- int T0,T0_frac;
- float pitch_gain, gain_code, avg_energy;
-
- ff_decode_pitch_lag(&T0, &T0_frac, params->pitch_delay[i], t0_first, i,
- ctx->mode == MODE_5k0, 6);
-
- if (i == 0 || (i == 2 && ctx->mode == MODE_5k0))
- t0_first = T0;
-
- ff_acelp_interpolatef(excitation, excitation - T0 + (T0_frac <= 0),
- ff_b60_sinc, 6,
- 2 * ((2 + T0_frac)%3 + 1), LP_FILTER_ORDER,
- SUBFR_SIZE);
-
- decode_fixed_sparse(&fixed_cb, params->fc_indexes[i], ctx->mode,
- ctx->past_pitch_gain < 0.8);
-
- eval_ir(pAz, T0, impulse_response, modes[ctx->mode].pitch_sharp_factor);
-
- convolute_with_sparse(fixed_vector, &fixed_cb, impulse_response,
- SUBFR_SIZE);
-
- avg_energy = (0.01 + avpriv_scalarproduct_float_c(fixed_vector,
- fixed_vector,
- SUBFR_SIZE)) /
- SUBFR_SIZE;
-
- ctx->past_pitch_gain = pitch_gain = gain_cb[params->gc_index[i]][0];
-
- gain_code = ff_amr_set_fixed_gain(gain_cb[params->gc_index[i]][1],
- avg_energy, ctx->energy_history,
- 34 - 15.0/(0.05*M_LN10/M_LN2),
- pred);
-
- ff_weighted_vector_sumf(excitation, excitation, fixed_vector,
- pitch_gain, gain_code, SUBFR_SIZE);
-
- pitch_gain *= 0.5 * pitch_gain;
- pitch_gain = FFMIN(pitch_gain, 0.4);
-
- ctx->gain_mem = 0.7 * ctx->gain_mem + 0.3 * pitch_gain;
- ctx->gain_mem = FFMIN(ctx->gain_mem, pitch_gain);
- gain_code *= ctx->gain_mem;
-
- for (j = 0; j < SUBFR_SIZE; j++)
- fixed_vector[j] = excitation[j] - gain_code * fixed_vector[j];
-
- if (ctx->mode == MODE_5k0) {
- postfilter_5k0(ctx, pAz, fixed_vector);
-
- ff_celp_lp_synthesis_filterf(ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i*SUBFR_SIZE,
- pAz, excitation, SUBFR_SIZE,
- LP_FILTER_ORDER);
- }
-
- ff_celp_lp_synthesis_filterf(synth + i*SUBFR_SIZE, pAz, fixed_vector,
- SUBFR_SIZE, LP_FILTER_ORDER);
-
- excitation += SUBFR_SIZE;
- }
-
- memcpy(synth - LP_FILTER_ORDER, synth + frame_size - LP_FILTER_ORDER,
- LP_FILTER_ORDER * sizeof(float));
-
- if (ctx->mode == MODE_5k0) {
- for (i = 0; i < subframe_count; i++) {
- float energy = avpriv_scalarproduct_float_c(ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i * SUBFR_SIZE,
- ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i * SUBFR_SIZE,
- SUBFR_SIZE);
- ff_adaptive_gain_control(&synth[i * SUBFR_SIZE],
- &synth[i * SUBFR_SIZE], energy,
- SUBFR_SIZE, 0.9, &ctx->postfilter_agc);
- }
-
- memcpy(ctx->postfilter_syn5k0, ctx->postfilter_syn5k0 + frame_size,
- LP_FILTER_ORDER*sizeof(float));
- }
- memmove(ctx->excitation, excitation - PITCH_DELAY_MAX - L_INTERPOL,
- (PITCH_DELAY_MAX + L_INTERPOL) * sizeof(float));
-
- ff_acelp_apply_order_2_transfer_function(out_data, synth,
- (const float[2]) {-1.99997 , 1.000000000},
- (const float[2]) {-1.93307352, 0.935891986},
- 0.939805806,
- ctx->highpass_filt_mem,
- frame_size);
-}
-
-static av_cold int sipr_decoder_init(AVCodecContext * avctx)
-{
- SiprContext *ctx = avctx->priv_data;
- int i;
-
- switch (avctx->block_align) {
- case 20: ctx->mode = MODE_16k; break;
- case 19: ctx->mode = MODE_8k5; break;
- case 29: ctx->mode = MODE_6k5; break;
- case 37: ctx->mode = MODE_5k0; break;
- default:
- if (avctx->bit_rate > 12200) ctx->mode = MODE_16k;
- else if (avctx->bit_rate > 7500 ) ctx->mode = MODE_8k5;
- else if (avctx->bit_rate > 5750 ) ctx->mode = MODE_6k5;
- else ctx->mode = MODE_5k0;
- av_log(avctx, AV_LOG_WARNING,
- "Invalid block_align: %d. Mode %s guessed based on bitrate: %d\n",
- avctx->block_align, modes[ctx->mode].mode_name, avctx->bit_rate);
- }
-
- av_log(avctx, AV_LOG_DEBUG, "Mode: %s\n", modes[ctx->mode].mode_name);
-
- if (ctx->mode == MODE_16k) {
- ff_sipr_init_16k(ctx);
- ctx->decode_frame = ff_sipr_decode_frame_16k;
- } else {
- ctx->decode_frame = decode_frame;
- }
-
- for (i = 0; i < LP_FILTER_ORDER; i++)
- ctx->lsp_history[i] = cos((i+1) * M_PI / (LP_FILTER_ORDER + 1));
-
- for (i = 0; i < 4; i++)
- ctx->energy_history[i] = -14;
-
- avctx->channels = 1;
- avctx->channel_layout = AV_CH_LAYOUT_MONO;
- avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
-
- return 0;
-}
-
-static int sipr_decode_frame(AVCodecContext *avctx, void *data,
- int *got_frame_ptr, AVPacket *avpkt)
-{
- SiprContext *ctx = avctx->priv_data;
- AVFrame *frame = data;
- const uint8_t *buf=avpkt->data;
- SiprParameters parm;
- const SiprModeParam *mode_par = &modes[ctx->mode];
- GetBitContext gb;
- float *samples;
- int subframe_size = ctx->mode == MODE_16k ? L_SUBFR_16k : SUBFR_SIZE;
- int i, ret;
-
- ctx->avctx = avctx;
- if (avpkt->size < (mode_par->bits_per_frame >> 3)) {
- av_log(avctx, AV_LOG_ERROR,
- "Error processing packet: packet size (%d) too small\n",
- avpkt->size);
- return -1;
- }
-
- /* get output buffer */
- frame->nb_samples = mode_par->frames_per_packet * subframe_size *
- mode_par->subframe_count;
- if ((ret = ff_get_buffer(avctx, frame)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return ret;
- }
- samples = (float *)frame->data[0];
-
- init_get_bits(&gb, buf, mode_par->bits_per_frame);
-
- for (i = 0; i < mode_par->frames_per_packet; i++) {
- decode_parameters(&parm, &gb, mode_par);
-
- ctx->decode_frame(ctx, &parm, samples);
-
- samples += subframe_size * mode_par->subframe_count;
- }
-
- *got_frame_ptr = 1;
-
- return mode_par->bits_per_frame >> 3;
-}
-
-AVCodec ff_sipr_decoder = {
- .name = "sipr",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_SIPR,
- .priv_data_size = sizeof(SiprContext),
- .init = sipr_decoder_init,
- .decode = sipr_decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("RealAudio SIPR / ACELP.NET"),
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/sipr.h b/src/thirdparty/ffmpeg/libavcodec/sipr.h
deleted file mode 100644
index f783d625c..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/sipr.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * SIPR / ACELP.NET decoder
- *
- * Copyright (c) 2008 Vladimir Voroshilov
- * Copyright (c) 2009 Vitor Sessak
- *
- * 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_SIPR_H
-#define AVCODEC_SIPR_H
-
-#include "avcodec.h"
-#include "dsputil.h"
-#include "acelp_pitch_delay.h"
-#include "libavutil/mem.h"
-
-#define LP_FILTER_ORDER_16k 16
-#define L_SUBFR_16k 80
-#define PITCH_MIN 30
-#define PITCH_MAX 281
-
-#define LSFQ_DIFF_MIN (0.0125 * M_PI)
-
-#define LP_FILTER_ORDER 10
-
-/** Number of past samples needed for excitation interpolation */
-#define L_INTERPOL (LP_FILTER_ORDER + 1)
-
-/** Subframe size for all modes except 16k */
-#define SUBFR_SIZE 48
-
-#define SUBFRAME_COUNT_16k 2
-
-typedef enum {
- MODE_16k,
- MODE_8k5,
- MODE_6k5,
- MODE_5k0,
- MODE_COUNT
-} SiprMode;
-
-typedef struct SiprParameters {
- int ma_pred_switch; ///< switched moving average predictor
- int vq_indexes[5];
- int pitch_delay[5]; ///< pitch delay
- int gp_index[5]; ///< adaptive-codebook gain indexes
- int16_t fc_indexes[5][10]; ///< fixed-codebook indexes
- int gc_index[5]; ///< fixed-codebook gain indexes
-} SiprParameters;
-
-typedef struct SiprContext {
- AVCodecContext *avctx;
-
- SiprMode mode;
-
- float past_pitch_gain;
- float lsf_history[LP_FILTER_ORDER_16k];
-
- float excitation[L_INTERPOL + PITCH_MAX + 2 * L_SUBFR_16k];
-
- DECLARE_ALIGNED(16, float, synth_buf)[LP_FILTER_ORDER + 5*SUBFR_SIZE + 6];
-
- float lsp_history[LP_FILTER_ORDER];
- float gain_mem;
- float energy_history[4];
- float highpass_filt_mem[2];
- float postfilter_mem[PITCH_DELAY_MAX + LP_FILTER_ORDER];
-
- /* 5k0 */
- float tilt_mem;
- float postfilter_agc;
- float postfilter_mem5k0[PITCH_DELAY_MAX + LP_FILTER_ORDER];
- float postfilter_syn5k0[LP_FILTER_ORDER + SUBFR_SIZE*5];
-
- /* 16k */
- int pitch_lag_prev;
- float iir_mem[LP_FILTER_ORDER_16k+1];
- float filt_buf[2][LP_FILTER_ORDER_16k+1];
- float *filt_mem[2];
- float mem_preemph[LP_FILTER_ORDER_16k];
- float synth[LP_FILTER_ORDER_16k];
- double lsp_history_16k[16];
-
- void (*decode_frame)(struct SiprContext *ctx, SiprParameters *params,
- float *out_data);
-} SiprContext;
-
-extern const float ff_pow_0_5[16];
-
-void ff_sipr_init_16k(SiprContext *ctx);
-
-void ff_sipr_decode_frame_16k(SiprContext *ctx, SiprParameters *params,
- float *out_data);
-
-#endif /* AVCODEC_SIPR_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/sipr16k.c b/src/thirdparty/ffmpeg/libavcodec/sipr16k.c
deleted file mode 100644
index 2237186e3..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/sipr16k.c
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * SIPR decoder for the 16k mode
- *
- * Copyright (c) 2008 Vladimir Voroshilov
- * Copyright (c) 2009 Vitor Sessak
- *
- * 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 <math.h>
-
-#include "sipr.h"
-#include "libavutil/common.h"
-#include "libavutil/float_dsp.h"
-#include "libavutil/mathematics.h"
-#include "lsp.h"
-#include "celp_filters.h"
-#include "acelp_vectors.h"
-#include "acelp_pitch_delay.h"
-#include "acelp_filters.h"
-#include "celp_filters.h"
-
-#include "sipr16kdata.h"
-
-/**
- * Convert an lsf vector into an lsp vector.
- *
- * @param lsf input lsf vector
- * @param lsp output lsp vector
- */
-static void lsf2lsp(const float *lsf, double *lsp)
-{
- int i;
-
- for (i = 0; i < LP_FILTER_ORDER_16k; i++)
- lsp[i] = cosf(lsf[i]);
-}
-
-static void dequant(float *out, const int *idx, const float *cbs[])
-{
- int i;
-
- for (i = 0; i < 4; i++)
- memcpy(out + 3*i, cbs[i] + 3*idx[i], 3*sizeof(float));
-
- memcpy(out + 12, cbs[4] + 4*idx[4], 4*sizeof(float));
-}
-
-static void lsf_decode_fp_16k(float* lsf_history, float* isp_new,
- const int* parm, int ma_pred)
-{
- int i;
- float isp_q[LP_FILTER_ORDER_16k];
-
- dequant(isp_q, parm, lsf_codebooks_16k);
-
- for (i = 0; i < LP_FILTER_ORDER_16k; i++) {
- isp_new[i] = (1 - qu[ma_pred]) * isp_q[i]
- + qu[ma_pred] * lsf_history[i]
- + mean_lsf_16k[i];
- }
-
- memcpy(lsf_history, isp_q, LP_FILTER_ORDER_16k * sizeof(float));
-}
-
-static int dec_delay3_1st(int index)
-{
- if (index < 390) {
- return index + 88;
- } else
- return 3 * index - 690;
-}
-
-static int dec_delay3_2nd(int index, int pit_min, int pit_max,
- int pitch_lag_prev)
-{
- if (index < 62) {
- int pitch_delay_min = av_clip(pitch_lag_prev - 10,
- pit_min, pit_max - 19);
- return 3 * pitch_delay_min + index - 2;
- } else
- return 3 * pitch_lag_prev;
-}
-
-static void postfilter(float *out_data, float* synth, float* iir_mem,
- float* filt_mem[2], float* mem_preemph)
-{
- float buf[30 + LP_FILTER_ORDER_16k];
- float *tmpbuf = buf + LP_FILTER_ORDER_16k;
- float s;
- int i;
-
- for (i = 0; i < LP_FILTER_ORDER_16k; i++)
- filt_mem[0][i] = iir_mem[i] * ff_pow_0_5[i];
-
- memcpy(tmpbuf - LP_FILTER_ORDER_16k, mem_preemph,
- LP_FILTER_ORDER_16k*sizeof(*buf));
-
- ff_celp_lp_synthesis_filterf(tmpbuf, filt_mem[1], synth, 30,
- LP_FILTER_ORDER_16k);
-
- memcpy(synth - LP_FILTER_ORDER_16k, mem_preemph,
- LP_FILTER_ORDER_16k * sizeof(*synth));
-
- ff_celp_lp_synthesis_filterf(synth, filt_mem[0], synth, 30,
- LP_FILTER_ORDER_16k);
-
- memcpy(out_data + 30 - LP_FILTER_ORDER_16k,
- synth + 30 - LP_FILTER_ORDER_16k,
- LP_FILTER_ORDER_16k * sizeof(*synth));
-
- ff_celp_lp_synthesis_filterf(out_data + 30, filt_mem[0],
- synth + 30, 2 * L_SUBFR_16k - 30,
- LP_FILTER_ORDER_16k);
-
-
- memcpy(mem_preemph, out_data + 2*L_SUBFR_16k - LP_FILTER_ORDER_16k,
- LP_FILTER_ORDER_16k * sizeof(*synth));
-
- FFSWAP(float *, filt_mem[0], filt_mem[1]);
- for (i = 0, s = 0; i < 30; i++, s += 1.0/30)
- out_data[i] = tmpbuf[i] + s * (synth[i] - tmpbuf[i]);
-}
-
-/**
- * Floating point version of ff_acelp_lp_decode().
- */
-static void acelp_lp_decodef(float *lp_1st, float *lp_2nd,
- const double *lsp_2nd, const double *lsp_prev)
-{
- double lsp_1st[LP_FILTER_ORDER_16k];
- int i;
-
- /* LSP values for first subframe (3.2.5 of G.729, Equation 24) */
- for (i = 0; i < LP_FILTER_ORDER_16k; i++)
- lsp_1st[i] = (lsp_2nd[i] + lsp_prev[i]) * 0.5;
-
- ff_acelp_lspd2lpc(lsp_1st, lp_1st, LP_FILTER_ORDER_16k >> 1);
-
- /* LSP values for second subframe (3.2.5 of G.729) */
- ff_acelp_lspd2lpc(lsp_2nd, lp_2nd, LP_FILTER_ORDER_16k >> 1);
-}
-
-/**
- * Floating point version of ff_acelp_decode_gain_code().
- */
-static float acelp_decode_gain_codef(float gain_corr_factor, const float *fc_v,
- float mr_energy, const float *quant_energy,
- const float *ma_prediction_coeff,
- int subframe_size, int ma_pred_order)
-{
- mr_energy += avpriv_scalarproduct_float_c(quant_energy, ma_prediction_coeff,
- ma_pred_order);
-
- mr_energy = gain_corr_factor * exp(M_LN10 / 20. * mr_energy) /
- sqrt((0.01 + avpriv_scalarproduct_float_c(fc_v, fc_v, subframe_size)));
- return mr_energy;
-}
-
-#define DIVIDE_BY_3(x) ((x) * 10923 >> 15)
-
-void ff_sipr_decode_frame_16k(SiprContext *ctx, SiprParameters *params,
- float *out_data)
-{
- int frame_size = SUBFRAME_COUNT_16k * L_SUBFR_16k;
- float *synth = ctx->synth_buf + LP_FILTER_ORDER_16k;
- float lsf_new[LP_FILTER_ORDER_16k];
- double lsp_new[LP_FILTER_ORDER_16k];
- float Az[2][LP_FILTER_ORDER_16k];
- float fixed_vector[L_SUBFR_16k];
- float pitch_fac, gain_code;
-
- int i;
- int pitch_delay_3x;
-
- float *excitation = ctx->excitation + 292;
-
- lsf_decode_fp_16k(ctx->lsf_history, lsf_new, params->vq_indexes,
- params->ma_pred_switch);
-
- ff_set_min_dist_lsf(lsf_new, LSFQ_DIFF_MIN / 2, LP_FILTER_ORDER_16k);
-
- lsf2lsp(lsf_new, lsp_new);
-
- acelp_lp_decodef(Az[0], Az[1], lsp_new, ctx->lsp_history_16k);
-
- memcpy(ctx->lsp_history_16k, lsp_new, LP_FILTER_ORDER_16k * sizeof(double));
-
- memcpy(synth - LP_FILTER_ORDER_16k, ctx->synth,
- LP_FILTER_ORDER_16k * sizeof(*synth));
-
- for (i = 0; i < SUBFRAME_COUNT_16k; i++) {
- int i_subfr = i * L_SUBFR_16k;
- AMRFixed f;
- float gain_corr_factor;
- int pitch_delay_int;
- int pitch_delay_frac;
-
- if (!i) {
- pitch_delay_3x = dec_delay3_1st(params->pitch_delay[i]);
- } else
- pitch_delay_3x = dec_delay3_2nd(params->pitch_delay[i],
- PITCH_MIN, PITCH_MAX,
- ctx->pitch_lag_prev);
-
- pitch_fac = gain_pitch_cb_16k[params->gp_index[i]];
- f.pitch_fac = FFMIN(pitch_fac, 1.0);
- f.pitch_lag = DIVIDE_BY_3(pitch_delay_3x+1);
- ctx->pitch_lag_prev = f.pitch_lag;
-
- pitch_delay_int = DIVIDE_BY_3(pitch_delay_3x + 2);
- pitch_delay_frac = pitch_delay_3x + 2 - 3*pitch_delay_int;
-
- ff_acelp_interpolatef(&excitation[i_subfr],
- &excitation[i_subfr] - pitch_delay_int + 1,
- sinc_win, 3, pitch_delay_frac + 1,
- LP_FILTER_ORDER, L_SUBFR_16k);
-
-
- memset(fixed_vector, 0, sizeof(fixed_vector));
-
- ff_decode_10_pulses_35bits(params->fc_indexes[i], &f,
- ff_fc_4pulses_8bits_tracks_13, 5, 4);
-
- ff_set_fixed_vector(fixed_vector, &f, 1.0, L_SUBFR_16k);
-
- gain_corr_factor = gain_cb_16k[params->gc_index[i]];
- gain_code = gain_corr_factor *
- acelp_decode_gain_codef(sqrt(L_SUBFR_16k), fixed_vector,
- 19.0 - 15.0/(0.05*M_LN10/M_LN2),
- pred_16k, ctx->energy_history,
- L_SUBFR_16k, 2);
-
- ctx->energy_history[1] = ctx->energy_history[0];
- ctx->energy_history[0] = 20.0 * log10f(gain_corr_factor);
-
- ff_weighted_vector_sumf(&excitation[i_subfr], &excitation[i_subfr],
- fixed_vector, pitch_fac,
- gain_code, L_SUBFR_16k);
-
- ff_celp_lp_synthesis_filterf(synth + i_subfr, Az[i],
- &excitation[i_subfr], L_SUBFR_16k,
- LP_FILTER_ORDER_16k);
-
- }
- memcpy(ctx->synth, synth + frame_size - LP_FILTER_ORDER_16k,
- LP_FILTER_ORDER_16k * sizeof(*synth));
-
- memmove(ctx->excitation, ctx->excitation + 2 * L_SUBFR_16k,
- (L_INTERPOL+PITCH_MAX) * sizeof(float));
-
- postfilter(out_data, synth, ctx->iir_mem, ctx->filt_mem, ctx->mem_preemph);
-
- memcpy(ctx->iir_mem, Az[1], LP_FILTER_ORDER_16k * sizeof(float));
-}
-
-void ff_sipr_init_16k(SiprContext *ctx)
-{
- int i;
-
- for (i = 0; i < LP_FILTER_ORDER_16k; i++)
- ctx->lsp_history_16k[i] = cos((i + 1) * M_PI/(LP_FILTER_ORDER_16k + 1));
-
- ctx->filt_mem[0] = ctx->filt_buf[0];
- ctx->filt_mem[1] = ctx->filt_buf[1];
-
- ctx->pitch_lag_prev = 180;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/sipr16kdata.h b/src/thirdparty/ffmpeg/libavcodec/sipr16kdata.h
deleted file mode 100644
index 566d46f68..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/sipr16kdata.h
+++ /dev/null
@@ -1,533 +0,0 @@
-/*
- * SIPR decoder for the 16k mode
- *
- * Copyright (c) 2008 Vladimir Voroshilov
- * Copyright (c) 2009 Vitor Sessak
- *
- * 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_SIPR16KDATA_H
-#define AVCODEC_SIPR16KDATA_H
-
-static const float pred_16k[2] = {0.8, 0.6};
-static const float qu[2] = { 0.12, 0.5};
-
-static const float gain_cb_16k[32] = {
- 0.07499, 0.10593, 0.14125, 0.18836,
- 0.23714, 0.28184, 0.32734, 0.37584,
- 0.42170, 0.47315, 0.53088, 0.59566,
- 0.66834, 0.74989, 0.84140, 0.94406,
- 1.05925, 1.18850, 1.33352, 1.49624,
- 1.67880, 1.88365, 2.11349, 2.37137,
- 2.66073, 3.05492, 3.54813, 4.21697,
- 5.30884, 7.07946, 9.44061, 13.33521,
-};
-
-static const float gain_pitch_cb_16k[16] = {
- 0.00, 0.2, 0.40, 0.5, 0.60, 0.7, 0.75, 0.8,
- 0.85, 0.9, 0.95, 1.0, 1.05, 1.1, 1.15, 1.2,
-};
-
-
-static const float mean_lsf_16k[16] = {
- 0.131554, 0.246615, 0.435896, 0.644419,
- 0.827810, 1.017876, 1.198910, 1.379159,
- 1.562157, 1.736908, 1.940719, 2.131963,
- 2.347162, 2.521521, 2.717870, 2.847068
-};
-
-/**
- * Hamming windowed sinc function, like in AMR
- */
-static const float sinc_win[40] = {
- 0.874475, 0.755101, 0.455962, 0.118807, -0.114223, -0.176778,
- -0.101923, 0.015553, 0.086555, 0.078193, 0.018660, -0.037513,
- -0.052733, -0.027459, 0.009967, 0.030278, 0.024050, 0.003055,
- -0.013862, -0.016162, -0.006725, 0.004212, 0.008634, 0.005721,
- -0.000000, -0.003710, -0.003690, -0.001228, 0.001409, 0.002610,
-};
-
-static const float lsf_cb1_16k[128][3] = {
- {-0.089990, -0.172485, -0.203391}, {-0.094710, -0.178687, -0.134483},
- {-0.056398, -0.131952, -0.154500}, {-0.051362, -0.128138, -0.198549},
- {-0.061700, -0.142830, -0.251623}, {-0.041512, -0.115637, -0.229420},
- {-0.036544, -0.107512, -0.173125}, {-0.024158, -0.088450, -0.204144},
- {-0.038690, -0.103368, -0.132674}, {-0.056954, -0.128472, -0.104669},
- {-0.020963, -0.076785, -0.163199}, {-0.012952, -0.077249, -0.128385},
- {-0.032787, -0.097044, -0.093967}, {-0.035214, -0.053838, -0.111940},
- {-0.013850, -0.036926, -0.139328}, {-0.004956, -0.065092, -0.087709},
- {-0.065354, -0.065595, -0.079064}, {-0.023627, -0.081457, -0.054195},
- {-0.027335, -0.035244, -0.068034}, { 0.016555, -0.047075, -0.128286},
- { 0.021066, -0.037252, -0.092041}, { 0.014681, -0.043044, -0.057739},
- {-0.008493, -0.008143, -0.102486}, {-0.002303, -0.061540, -0.022952},
- {-0.006061, -0.014278, -0.033652}, {-0.005276, 0.011246, -0.062762},
- { 0.043411, -0.006303, -0.063730}, { 0.035885, -0.010052, -0.115290},
- { 0.030628, -0.031538, -0.017807}, { 0.022345, 0.028210, -0.032335},
- { 0.026535, 0.027536, -0.091150}, {-0.003365, -0.008077, 0.015687},
- {-0.026013, 0.017493, -0.010355}, { 0.059069, 0.010634, -0.007530},
- { 0.044038, -0.019424, 0.030453}, {-0.036065, -0.034215, -0.007758},
- { 0.022486, 0.042543, 0.027870}, {-0.049985, -0.016085, 0.021768},
- {-0.021715, 0.021168, 0.052076}, {-0.004243, -0.061228, 0.027640},
- {-0.033950, -0.017287, 0.064656}, { 0.016151, 0.000727, 0.062757},
- {-0.063456, -0.043152, 0.056707}, {-0.067715, 0.006126, 0.058178},
- {-0.038931, 0.051673, 0.030636}, {-0.073017, -0.074716, 0.026387},
- {-0.039893, -0.104629, 0.039616}, {-0.073179, -0.074601, 0.082069},
- {-0.066154, -0.027180, 0.099439}, {-0.075167, -0.121149, 0.071938},
- {-0.030382, -0.092582, 0.091067}, {-0.084519, -0.137542, 0.023626},
- {-0.060956, -0.121259, -0.015264}, {-0.030069, -0.093823, -0.008692},
- {-0.063564, -0.065225, -0.025820}, {-0.052074, -0.117595, -0.059689},
- {-0.091652, -0.165173, -0.045573}, {-0.070167, -0.121342, 0.131707},
- {-0.061024, -0.005833, -0.051035}, { 0.007837, -0.051816, 0.074575},
- {-0.070643, -0.053927, 0.149498}, {-0.014358, -0.066681, 0.139708},
- {-0.058186, 0.029576, 0.092923}, {-0.023371, 0.007058, 0.112484},
- {-0.057969, 0.022786, 0.148420}, { 0.029439, -0.017673, 0.121423},
- {-0.015811, 0.056785, 0.091594}, { 0.004347, 0.056680, 0.137848},
- {-0.004464, 0.002342, 0.184013}, { 0.029660, 0.046870, 0.082654},
- { 0.059408, 0.001016, 0.086063}, { 0.055263, 0.027574, 0.155037},
- { 0.062166, 0.064323, 0.117371}, { 0.022967, 0.100050, 0.077227},
- { 0.041795, 0.096343, 0.170421}, { 0.053189, 0.122931, 0.118549},
- { 0.094247, 0.094448, 0.078395}, { 0.082407, 0.033408, 0.041085},
- { 0.096820, 0.115960, 0.149433}, { 0.067804, 0.121849, 0.025336},
- {-0.008421, 0.104316, 0.032314}, { 0.031013, 0.073218, -0.004899},
- { 0.085079, 0.060323, -0.009687}, { 0.028174, 0.092766, -0.055590},
- { 0.070133, 0.039160, -0.061035}, {-0.039211, 0.072517, -0.028756},
- { 0.129686, 0.100233, -0.046998}, { 0.154189, 0.107616, 0.022791},
- {-0.049331, 0.094184, 0.087984}, {-0.013179, 0.126552, 0.125099},
- {-0.058716, 0.098524, 0.150886}, {-0.022753, 0.080011, 0.191127},
- { 0.013451, 0.164593, 0.153768}, { 0.074818, 0.181214, 0.108211},
- { 0.091323, 0.169249, 0.168460}, { 0.033885, 0.155516, 0.213745},
- {-0.032128, 0.227238, 0.135815}, {-0.059176, 0.168980, 0.229110},
- { 0.033917, 0.229753, 0.222264}, { 0.082702, 0.116370, 0.224697},
- { 0.127737, 0.186658, 0.212783}, { 0.047528, 0.063920, 0.216856},
- {-0.002446, 0.114174, 0.263289}, {-0.077783, 0.082523, 0.249697},
- { 0.010023, 0.024267, 0.256874}, { 0.053190, 0.111422, 0.310407},
- {-0.078804, 0.004444, 0.224078}, {-0.055253, -0.059180, 0.217892},
- {-0.065371, 0.008124, 0.333405}, {-0.076188, -0.098767, 0.286983},
- {-0.071911, -0.115804, 0.198031}, {-0.062473, 0.183639, 0.370162},
- {-0.042666, 0.255210, 0.262720}, { 0.011999, 0.217530, 0.318291},
- {-0.042144, 0.322087, 0.326387}, { 0.090663, 0.205835, 0.294784},
- { 0.058218, 0.293649, 0.277927}, { 0.157506, 0.282870, 0.294610},
- { 0.118248, 0.261007, 0.148614}, { 0.065261, 0.332362, 0.411912},
- { 0.141269, 0.451850, 0.315726}, { 0.001706, 0.456301, 0.357590},
- {-0.052947, 0.356559, 0.456944}, { 0.247707, 0.263837, 0.152591},
- { 0.306847, 0.417373, 0.258553}, { 0.166347, 0.149222, 0.118973},
- { 0.379709, 0.292172, 0.139875}, { 0.010171, -0.055170, -0.174523}
-};
-
-static const float lsf_cb2_16k[256][3] = {
- {-0.213011, -0.293385, -0.330597}, {-0.212582, -0.240992, -0.338239},
- {-0.223373, -0.306214, -0.277192}, {-0.231138, -0.287729, -0.229412},
- {-0.238466, -0.228571, -0.260954}, {-0.140931, -0.247018, -0.258566},
- {-0.136239, -0.249669, -0.350143}, {-0.149738, -0.192970, -0.281475},
- {-0.167058, -0.261052, -0.196301}, {-0.177049, -0.201324, -0.207897},
- {-0.116915, -0.200629, -0.212526}, {-0.162247, -0.143805, -0.245093},
- {-0.082042, -0.191842, -0.266338}, {-0.098846, -0.208511, -0.320481},
- {-0.113510, -0.152470, -0.222474}, {-0.066197, -0.179112, -0.207813},
- {-0.129490, -0.169320, -0.155238}, {-0.078843, -0.190292, -0.155172},
- {-0.087790, -0.147729, -0.169351}, {-0.141037, -0.127207, -0.177910},
- {-0.126525, -0.223961, -0.153639}, {-0.101464, -0.189953, -0.114559},
- {-0.102450, -0.106303, -0.151171}, {-0.103208, -0.144457, -0.105378},
- {-0.170794, -0.140525, -0.136428}, {-0.168641, -0.203064, -0.135368},
- {-0.138193, -0.116042, -0.111905}, {-0.145085, -0.168581, -0.092613},
- {-0.126379, -0.220431, -0.091327}, {-0.212934, -0.184797, -0.101632},
- {-0.193711, -0.140556, -0.078304}, {-0.173674, -0.197276, -0.060140},
- {-0.197897, -0.241907, -0.091997}, {-0.156037, -0.258519, -0.111628},
- {-0.241964, -0.191124, -0.063140}, {-0.261340, -0.240847, -0.103132},
- {-0.221621, -0.242972, -0.041255}, {-0.224166, -0.232742, -0.161568},
- {-0.203591, -0.294470, -0.126035}, {-0.209540, -0.303149, -0.053170},
- {-0.253859, -0.295066, -0.156050}, {-0.278143, -0.331105, -0.085237},
- {-0.300273, -0.198750, -0.094834}, {-0.260477, -0.169713, -0.132476},
- {-0.211889, -0.172454, -0.164281}, {-0.228370, -0.122149, -0.124178},
- {-0.254629, -0.135668, -0.081692}, {-0.263813, -0.154928, -0.213596},
- {-0.308224, -0.106877, -0.084404}, {-0.242644, -0.082862, -0.085835},
- {-0.252084, -0.064888, -0.146498}, {-0.198162, -0.105721, -0.188887},
- {-0.189238, -0.088028, -0.109736}, {-0.197598, -0.099831, -0.044030},
- {-0.269017, -0.105991, -0.021513}, {-0.231349, -0.058825, -0.041407},
- {-0.225589, -0.027501, -0.087160}, {-0.160347, -0.058341, -0.079789},
- {-0.158729, -0.108951, -0.067262}, {-0.170483, -0.053023, -0.017561},
- {-0.175207, -0.013649, -0.049513}, {-0.156004, -0.108378, -0.004052},
- {-0.219958, -0.082362, 0.014950}, {-0.217785, -0.012981, -0.009410},
- {-0.123290, -0.040849, -0.040910}, {-0.119861, -0.095078, -0.060246},
- {-0.117537, -0.065479, 0.002968}, {-0.103231, -0.113298, -0.023282},
- {-0.136365, -0.149524, -0.051387}, {-0.119332, -0.164400, -0.009103},
- {-0.104522, -0.060948, -0.083056}, {-0.071461, -0.070787, -0.037347},
- {-0.081116, -0.149015, -0.056740}, {-0.069561, -0.108099, -0.069167},
- {-0.055624, -0.117369, -0.025091}, {-0.091941, -0.190091, -0.060020},
- {-0.072003, -0.168433, -0.006540}, {-0.033305, -0.154427, -0.054608},
- {-0.062988, -0.127093, -0.108307}, {-0.056690, -0.170813, -0.102834},
- {-0.018273, -0.127863, -0.094998}, {-0.056239, -0.123678, -0.146262},
- {-0.023442, -0.154617, -0.137417}, {-0.051903, -0.078379, -0.093395},
- {-0.014599, -0.104412, -0.135959}, {-0.051582, -0.081280, -0.140643},
- {-0.092727, -0.091930, -0.107816}, {-0.024814, -0.140993, -0.183243},
- {-0.064307, -0.113024, -0.194788}, {-0.000118, -0.098858, -0.195336},
- {-0.028090, -0.048258, -0.164101}, {-0.093414, -0.055969, -0.172743},
- {-0.114445, -0.104336, -0.215204}, {-0.048518, -0.132063, -0.242991},
- {-0.159620, -0.060240, -0.178592}, {-0.135728, -0.067473, -0.131876},
- {-0.078464, -0.038040, -0.125105}, {-0.011061, -0.064011, -0.102496},
- {-0.033887, -0.026485, -0.109493}, {-0.129128, -0.014216, -0.111329},
- {-0.190687, -0.030660, -0.135825}, {-0.082037, 0.010997, -0.100167},
- {-0.183403, 0.001651, -0.098962}, {-0.074775, -0.030335, -0.062217},
- {-0.031759, -0.050551, -0.059420}, {-0.051439, 0.010827, -0.052148},
- {-0.126744, 0.008689, -0.047785}, {-0.145916, 0.042019, -0.077431},
- {-0.093552, 0.054143, -0.060473}, {-0.090660, 0.012868, -0.018195},
- {-0.079783, -0.033071, 0.001482}, {-0.033010, -0.022331, -0.014506},
- {-0.004798, -0.017339, -0.060120}, {-0.025021, 0.026390, -0.003263},
- {-0.001437, 0.025994, -0.040892}, {-0.074821, 0.019005, 0.027549},
- {-0.030811, -0.012114, 0.034284}, { 0.006785, 0.004618, 0.018717},
- { 0.013392, -0.032597, -0.023731}, { 0.035994, 0.005963, -0.011757},
- { 0.008071, -0.045750, 0.024889}, { 0.013055, 0.017040, 0.054121},
- {-0.012989, 0.044864, 0.036327}, { 0.025054, 0.047137, 0.009974},
- { 0.053801, 0.024178, 0.031774}, { 0.056442, -0.030647, 0.021291},
- { 0.032247, 0.052680, 0.049886}, { 0.035369, 0.090207, 0.031394},
- { 0.064720, 0.070390, 0.040938}, { 0.022112, 0.054834, 0.091059},
- { 0.041765, 0.086248, 0.070196}, { 0.070645, 0.060852, 0.078825},
- { 0.058506, 0.016920, 0.081612}, { 0.000009, 0.086500, 0.059849},
- { 0.071253, 0.107392, 0.059046}, { 0.094702, 0.096160, 0.090982},
- { 0.047639, 0.110877, 0.111227}, { 0.122444, 0.090909, 0.057396},
- { 0.101916, 0.052299, 0.029909}, { 0.076560, 0.086094, -0.007252},
- { 0.123411, 0.030769, 0.082749}, { 0.135579, 0.103022, 0.009540},
- { 0.120576, 0.065284, -0.024095}, { 0.077483, 0.028526, -0.012369},
- { 0.128747, 0.017901, -0.003874}, { 0.158254, 0.046962, 0.029577},
- { 0.102287, -0.002211, 0.037329}, { 0.089654, -0.021372, -0.006857},
- { 0.137917, 0.027228, -0.053223}, { 0.098728, -0.012192, -0.048518},
- { 0.083974, 0.036153, -0.062266}, { 0.048230, -0.010241, -0.052293},
- { 0.110135, 0.007715, -0.095233}, { 0.068294, -0.014317, -0.104029},
- { 0.063909, -0.056416, -0.063023}, { 0.059133, -0.044675, -0.023780},
- { 0.030748, 0.021845, -0.086332}, { 0.023994, -0.045574, -0.076232},
- { 0.052147, -0.059825, -0.109667}, { 0.013087, -0.020420, -0.121945},
- { 0.018163, -0.096765, -0.088758}, { 0.020196, -0.076470, -0.048112},
- { 0.020282, -0.084204, -0.135535}, { 0.040076, -0.053464, -0.161949},
- {-0.017796, -0.103070, -0.059559}, {-0.016484, -0.070138, -0.016866},
- { 0.004849, -0.112481, -0.017731}, { 0.040160, -0.073873, -0.005327},
- { 0.002202, -0.094723, 0.045366}, {-0.056918, -0.081578, 0.017875},
- {-0.031099, -0.141708, 0.009186}, {-0.102802, -0.122675, 0.030060},
- {-0.061717, -0.145116, 0.076680}, {-0.073607, -0.050464, 0.072853},
- {-0.117403, -0.194921, 0.040101}, {-0.185236, -0.133620, 0.045939},
- {-0.160174, -0.057226, 0.056641}, {-0.178489, -0.173435, -0.007806},
- {-0.199916, -0.204866, 0.047342}, {-0.152337, -0.249651, 0.034656},
- {-0.185637, -0.230942, -0.002072}, {-0.122548, -0.215209, -0.024552},
- {-0.249578, -0.209714, 0.009470}, {-0.160108, -0.257702, -0.040992},
- {-0.216694, -0.289353, 0.027182}, {-0.226390, -0.147844, -0.022742},
- {-0.288737, -0.272150, -0.013948}, {-0.262554, -0.237035, 0.072473},
- {-0.306267, -0.188335, -0.032894}, {-0.259666, -0.345816, 0.024138},
- {-0.271093, -0.137143, 0.040404}, {-0.201317, -0.286782, 0.107615},
- {-0.235725, -0.163396, 0.113844}, {-0.159988, -0.209788, 0.112140},
- {-0.262985, -0.056741, 0.093506}, {-0.277226, -0.037306, 0.016008},
- {-0.293486, -0.040422, -0.062018}, {-0.214921, 0.022900, 0.055295},
- {-0.253889, 0.058575, -0.000151}, {-0.246689, 0.024242, -0.058488},
- {-0.143790, 0.006767, 0.014061}, {-0.187077, 0.048882, -0.035625},
- {-0.196369, 0.112085, 0.031546}, {-0.124264, 0.086197, -0.020800},
- {-0.126249, 0.016960, 0.095741}, {-0.079816, 0.080398, 0.051038},
- {-0.056269, 0.075380, -0.028262}, {-0.120493, 0.148495, 0.028430},
- {-0.161750, 0.101290, 0.117806}, {-0.003247, 0.083393, -0.017061},
- {-0.034007, 0.142542, 0.007402}, {-0.037618, 0.025871, 0.089496},
- {-0.082819, 0.184435, 0.073224}, { 0.006448, 0.167015, 0.080548},
- { 0.035315, 0.144022, 0.003218}, {-0.023459, 0.088147, 0.152604},
- { 0.006247, -0.024099, 0.077792}, { 0.039894, 0.057586, -0.042455},
- {-0.020417, 0.035400, -0.093971}, { 0.075465, 0.052063, 0.145582},
- { 0.078027, 0.184720, 0.092096}, { 0.107295, 0.148380, 0.022264},
- { 0.066928, -0.052831, 0.065108}, { 0.093295, 0.118157, 0.149815},
- { 0.119373, 0.137114, 0.099536}, { 0.138653, 0.075509, 0.121545},
- { 0.174025, 0.077531, 0.077169}, { 0.165839, 0.150080, 0.133423},
- { 0.173276, 0.155887, 0.048150}, { 0.162910, 0.095898, 0.171896},
- { 0.214577, 0.112888, 0.115579}, { 0.204755, 0.106392, 0.032337},
- { 0.178853, 0.205034, 0.114760}, { 0.177401, 0.070504, -0.013778},
- { 0.241624, 0.166921, 0.066087}, { 0.219595, 0.183553, 0.172332},
- { 0.123671, 0.170842, 0.167216}, { 0.177104, 0.240197, 0.186359},
- { 0.272003, 0.220214, 0.126073}, { 0.093748, 0.235843, 0.160998},
- { 0.141510, 0.190012, 0.240416}, { 0.046878, 0.168984, 0.190412},
- { 0.094898, 0.107038, 0.235003}, { 0.108592, 0.269536, 0.262528},
- {-0.027754, 0.234355, 0.134544}, { 0.265127, 0.267540, 0.199041},
- { 0.199523, 0.291507, 0.265171}, { 0.266177, 0.209339, 0.350369},
- { 0.322159, 0.344794, 0.270823}, { 0.399957, 0.264065, 0.110387},
- { 0.277817, 0.127407, -0.035625}, {-0.177038, 0.208155, 0.119077},
- { 0.049075, -0.076294, 0.145711}, { 0.187246, 0.042865, -0.127097},
- { 0.117885, -0.023489, -0.138658}, {-0.284256, 0.068153, 0.124259}
-};
-
-static const float lsf_cb3_16k[128][3] = {
- {-0.223412, -0.236300, -0.188067}, {-0.202286, -0.218711, -0.102947},
- {-0.251652, -0.161020, -0.125280}, {-0.169223, -0.138155, -0.140430},
- {-0.176427, -0.146628, -0.222632}, {-0.120584, -0.187276, -0.180164},
- {-0.195559, -0.074225, -0.169109}, {-0.144551, -0.142774, -0.073340},
- {-0.111001, -0.111310, -0.130696}, {-0.095221, -0.174684, -0.111841},
- {-0.112158, -0.103049, -0.195130}, {-0.059989, -0.142170, -0.157850},
- {-0.127598, -0.051759, -0.153109}, {-0.063753, -0.067898, -0.164117},
- {-0.141753, -0.068274, -0.091999}, {-0.060482, -0.101054, -0.099475},
- {-0.104699, -0.104456, -0.066496}, {-0.073649, -0.052614, -0.091612},
- {-0.088268, -0.019072, -0.129956}, {-0.018837, -0.104115, -0.127837},
- {-0.021630, -0.033055, -0.129868}, {-0.083768, -0.047549, -0.041407},
- {-0.055892, -0.108526, -0.043200}, {-0.027816, -0.062499, -0.048190},
- {-0.002248, -0.110428, -0.062868}, { 0.001270, -0.033245, -0.072404},
- {-0.042747, -0.013835, -0.033829}, {-0.037615, -0.147833, -0.083912},
- {-0.045023, 0.006011, -0.092182}, {-0.050411, -0.081832, 0.005787},
- { 0.000357, -0.104282, -0.009428}, {-0.003893, -0.047892, -0.001506},
- {-0.040077, -0.147110, -0.009065}, {-0.060858, -0.030972, 0.012999},
- {-0.014674, 0.001370, 0.005554}, {-0.101362, -0.126061, -0.001898},
- {-0.102519, -0.000390, -0.015721}, {-0.132687, -0.069608, -0.019928},
- {-0.102227, -0.076131, 0.043306}, {-0.055193, 0.027001, 0.011857},
- {-0.156427, -0.016629, 0.017480}, {-0.078736, 0.002809, 0.057979},
- {-0.157789, -0.016693, -0.055073}, {-0.179397, -0.095520, 0.022065},
- {-0.110219, 0.010408, -0.081927}, {-0.125392, 0.049111, 0.044595},
- {-0.112528, 0.063173, -0.024954}, {-0.185525, 0.053093, -0.032102},
- {-0.176887, -0.019379, -0.115125}, {-0.249706, -0.017664, -0.059188},
- {-0.200243, -0.103311, -0.066846}, {-0.055404, 0.045106, -0.046991},
- {-0.000544, 0.022690, -0.044831}, { 0.022298, -0.016367, -0.022509},
- { 0.028278, 0.017585, -0.100612}, { 0.061781, -0.020826, -0.068190},
- { 0.029157, -0.074477, -0.098898}, { 0.043073, -0.067234, -0.032293},
- { 0.060157, 0.034636, -0.034885}, { 0.071153, -0.013881, -0.009036},
- { 0.054196, -0.029989, -0.131139}, { 0.030193, 0.024976, 0.009861},
- { 0.055943, -0.045304, 0.031927}, { 0.033217, -0.002418, 0.038165},
- { 0.063814, 0.045625, 0.025309}, { 0.033689, 0.038819, 0.049700},
- { 0.073582, 0.028527, 0.060200}, {-0.007957, 0.022531, 0.043687},
- {-0.000984, 0.054518, 0.018742}, { 0.057004, 0.060916, 0.060573},
- { 0.009883, 0.015238, 0.080211}, { 0.022742, 0.070832, 0.068855},
- { 0.053001, 0.029790, 0.091446}, {-0.042447, 0.060379, 0.061462},
- { 0.076826, 0.062468, 0.089653}, { 0.039065, 0.069768, 0.119128},
- { 0.064145, 0.095353, 0.071621}, { 0.094411, 0.069527, 0.054197},
- { 0.042812, 0.093060, 0.027980}, { 0.094791, 0.099189, 0.101112},
- { 0.117611, 0.048601, 0.093111}, { 0.119951, 0.122758, 0.051546},
- { 0.103558, 0.085245, -0.010700}, { 0.150126, 0.059766, 0.020280},
- { 0.108066, 0.017170, 0.008606}, { 0.108422, 0.023253, -0.063942},
- { 0.019652, 0.072284, -0.030331}, { 0.192719, 0.075624, 0.071156},
- { 0.221140, 0.069191, -0.035085}, { 0.188367, 0.126200, 0.035225},
- { 0.185760, 0.043537, -0.101714}, {-0.042518, 0.099646, 0.003244},
- {-0.015308, -0.027521, 0.046006}, { 0.034086, -0.045777, 0.095989},
- { 0.007174, -0.093358, 0.046459}, {-0.051248, -0.062095, 0.083161},
- {-0.045626, -0.133301, 0.052997}, {-0.037840, 0.024042, 0.131097},
- {-0.020217, -0.115942, 0.126170}, {-0.134550, -0.036291, 0.111322},
- {-0.110576, -0.160024, 0.091841}, {-0.093308, -0.184958, 0.013939},
- {-0.082735, -0.167417, -0.051725}, {-0.169934, -0.173003, -0.007155},
- {-0.128244, -0.213123, -0.053337}, {-0.079852, -0.154116, -0.246546},
- {-0.032242, -0.108756, -0.204133}, {-0.140117, -0.199495, -0.284505},
- { 0.010842, -0.074979, -0.166333}, {-0.093313, 0.145006, 0.034110},
- {-0.039236, 0.113213, 0.111053}, { 0.040613, -0.031783, 0.174058},
- {-0.164232, 0.131421, 0.149842}, { 0.026893, 0.107281, 0.179297},
- { 0.047086, 0.158606, 0.103267}, {-0.070567, 0.210459, 0.134734},
- { 0.094392, 0.137050, 0.166892}, { 0.086039, 0.063657, 0.168825},
- { 0.159371, 0.120897, 0.154357}, { 0.147101, 0.160684, 0.114882},
- { 0.120158, 0.199650, 0.180948}, { 0.191417, 0.174500, 0.170734},
- { 0.159153, 0.142165, 0.233347}, { 0.232002, 0.150181, 0.102736},
- { 0.188299, 0.221738, 0.228748}, { 0.256786, 0.209685, 0.161534},
- { 0.257861, 0.247793, 0.250516}, {-0.164461, -0.000143, 0.232461}
-};
-
-static const float lsf_cb4_16k[128][3] = {
- {-0.193369, -0.304643, -0.253777}, {-0.164125, -0.277786, -0.153116},
- {-0.135681, -0.209120, -0.211724}, {-0.121822, -0.215734, -0.292207},
- {-0.198781, -0.161674, -0.242538}, {-0.164147, -0.180570, -0.138070},
- {-0.095915, -0.198695, -0.154309}, {-0.248386, -0.234462, -0.136984},
- {-0.164968, -0.108318, -0.175635}, {-0.124171, -0.111809, -0.224402},
- {-0.067398, -0.157017, -0.195759}, {-0.090132, -0.119174, -0.165253},
- {-0.099460, -0.146895, -0.106799}, {-0.141493, -0.108103, -0.108880},
- {-0.085088, -0.098340, -0.109953}, {-0.105526, -0.054463, -0.154315},
- {-0.040480, -0.144285, -0.124042}, {-0.040969, -0.084039, -0.142880},
- {-0.049082, -0.118553, -0.066686}, {-0.096336, -0.087515, -0.055741},
- {-0.058605, -0.059327, -0.089275}, {-0.121842, -0.058681, -0.086949},
- {-0.053792, -0.022025, -0.124451}, {-0.036744, -0.068891, -0.045865},
- { 0.003900, -0.098237, -0.091158}, {-0.001664, -0.045089, -0.081353},
- {-0.072829, -0.034087, -0.038416}, {-0.100822, -0.007330, -0.088715},
- {-0.035911, -0.005864, -0.062577}, {-0.020205, -0.026547, -0.019634},
- { 0.004291, -0.041290, -0.138181}, { 0.023404, -0.010932, -0.044904},
- { 0.013557, 0.014823, -0.092943}, { 0.059673, -0.031024, -0.095739},
- { 0.021130, -0.080607, -0.034594}, { 0.024655, -0.035564, 0.003243},
- { 0.017106, 0.006952, -0.000308}, { 0.075208, -0.030910, -0.031181},
- { 0.024965, 0.048632, -0.039448}, { 0.057028, 0.021547, -0.009418},
- {-0.018577, 0.023697, -0.009759}, { 0.024077, 0.033053, 0.024324},
- { 0.037052, -0.003436, 0.044530}, {-0.012871, -0.007179, 0.031795},
- { 0.077877, 0.021547, 0.023131}, { 0.053365, 0.052078, 0.029433},
- { 0.011429, 0.070426, 0.028734}, {-0.001827, 0.033115, 0.061505},
- {-0.044870, 0.038568, 0.026239}, { 0.061633, 0.034799, 0.059784},
- { 0.034261, 0.060342, 0.065185}, { 0.058981, 0.082481, 0.047252},
- { 0.090008, 0.065942, 0.044470}, { 0.066961, 0.073728, -0.000428},
- { 0.074763, 0.060293, 0.085632}, { 0.066366, 0.103375, 0.079642},
- { 0.122297, 0.036558, 0.058745}, { 0.111042, 0.092093, 0.085412},
- { 0.099243, 0.115476, 0.039254}, { 0.019973, 0.122844, 0.050255},
- { 0.159571, 0.098965, 0.051740}, { 0.137624, 0.072405, -0.006922},
- { 0.130240, 0.146091, 0.089698}, { 0.138335, 0.092968, 0.136193},
- { 0.066031, 0.149304, 0.125476}, { 0.202749, 0.145751, 0.077122},
- { 0.002224, 0.082811, 0.131200}, { 0.124476, 0.178073, 0.162336},
- { 0.174722, 0.190298, 0.127106}, { 0.202193, 0.153569, 0.163840},
- { 0.242604, 0.197796, 0.136929}, { 0.185809, 0.229348, 0.193353},
- {-0.058814, 0.195178, 0.141821}, { 0.253646, 0.247175, 0.205766},
- { 0.061433, -0.025542, 0.119311}, {-0.057816, 0.082445, 0.073243},
- {-0.069239, 0.148678, 0.031146}, {-0.030217, -0.008503, 0.106194},
- {-0.026708, 0.087469, -0.009589}, {-0.090418, 0.000265, 0.056807},
- {-0.050607, -0.019383, 0.010494}, {-0.079397, 0.008233, -0.011469},
- {-0.072634, -0.061165, 0.046917}, {-0.075741, -0.072343, -0.007557},
- {-0.025162, -0.073363, 0.005173}, {-0.123371, -0.041257, -0.008375},
- {-0.139904, 0.018285, 0.009920}, {-0.143421, -0.104238, 0.033457},
- {-0.100923, -0.134400, -0.023257}, {-0.157791, -0.095042, -0.036959},
- {-0.219890, -0.078637, 0.001815}, {-0.183607, -0.023053, -0.043678},
- {-0.145303, -0.158923, -0.059045}, {-0.197615, -0.165199, 0.028099},
- {-0.225131, -0.167756, -0.056401}, {-0.216572, -0.104751, -0.102964},
- {-0.171336, -0.241967, -0.063404}, {-0.134035, -0.205614, 0.011831},
- {-0.297116, -0.211173, -0.015352}, {-0.086464, -0.200592, -0.070454},
- {-0.217777, -0.278403, 0.030398}, {-0.236248, -0.323694, -0.087588},
- {-0.222074, -0.210785, 0.106210}, {-0.283400, -0.097077, 0.041303},
- {-0.078417, -0.154464, 0.062956}, {-0.214417, -0.100695, 0.121909},
- {-0.178576, -0.028847, 0.061042}, {-0.037999, -0.144233, -0.010546},
- {-0.086695, -0.070996, 0.125282}, { 0.010788, -0.085006, 0.058527},
- {-0.154015, 0.066560, 0.071038}, {-0.143503, 0.033260, 0.154393},
- {-0.134069, 0.032420, -0.056293}, {-0.110851, 0.086908, 0.003920},
- {-0.057254, 0.047674, -0.055571}, {-0.214206, 0.068784, -0.004735},
- {-0.257264, 0.050468, 0.081702}, {-0.291834, 0.004120, -0.022366},
- {-0.173309, -0.029081, -0.115901}, {-0.207622, 0.168664, 0.136030},
- { 0.090541, 0.032754, -0.057330}, { 0.140219, -0.000735, -0.015633},
- { 0.136697, -0.017163, -0.100909}, { 0.029838, -0.089515, -0.147130},
- {-0.055367, -0.072683, -0.214015}, { 0.048680, -0.057633, -0.212429},
- {-0.013134, -0.113898, -0.196403}, {-0.071702, -0.159408, -0.254895}
-};
-
-static const float lsf_cb5_16k[128][4] = {
- {-0.201277, -0.278679, -0.173262, -0.198580},
- {-0.214667, -0.151922, -0.117551, -0.192713},
- {-0.160962, -0.207728, -0.124750, -0.129749},
- {-0.131043, -0.137818, -0.155281, -0.166308},
- {-0.179134, -0.169602, -0.165223, -0.066293},
- {-0.136474, -0.177035, -0.250127, -0.134370},
- {-0.066970, -0.146274, -0.170638, -0.134436},
- {-0.083288, -0.165860, -0.103437, -0.140361},
- {-0.130474, -0.119317, -0.124393, -0.086408},
- {-0.127609, -0.134415, -0.073592, -0.116103},
- {-0.113027, -0.091756, -0.107786, -0.131935},
- {-0.125530, -0.182152, -0.093796, -0.045088},
- {-0.077122, -0.138052, -0.166271, -0.038886},
- {-0.073027, -0.106845, -0.067073, -0.113910},
- {-0.049146, -0.107019, -0.112531, -0.063388},
- {-0.101539, -0.119586, -0.050297, -0.040670},
- {-0.107784, -0.066913, -0.080993, -0.052352},
- {-0.152155, -0.103010, -0.090461, -0.015526},
- {-0.153087, -0.087656, -0.029889, -0.037367},
- {-0.215281, -0.138062, -0.089162, -0.050839},
- {-0.053350, -0.060169, -0.063459, -0.024499},
- {-0.051674, -0.076355, -0.033733, -0.077211},
- {-0.045047, -0.107006, -0.020880, -0.024525},
- {-0.083003, -0.063672, -0.013243, -0.028324},
- {-0.104104, -0.075450, -0.032746, 0.024480},
- {-0.085695, -0.019502, -0.045121, -0.025016},
- {-0.123120, -0.030844, -0.003533, -0.016224},
- {-0.025568, -0.049172, -0.003911, -0.027522},
- {-0.039029, -0.019857, -0.043211, -0.058087},
- {-0.040122, -0.023067, -0.001356, 0.008607},
- {-0.063351, -0.001776, 0.016015, -0.027088},
- {-0.068110, -0.038838, 0.042525, 0.001076},
- {-0.043623, -0.020736, -0.047862, 0.037710},
- {-0.041052, 0.021954, -0.025660, 0.000758},
- {-0.013035, 0.002583, -0.008233, -0.037300},
- {-0.005523, -0.014670, 0.019651, -0.012667},
- {-0.004409, -0.014437, -0.059412, -0.019701},
- { 0.024946, -0.011663, -0.014351, -0.028762},
- { 0.012660, 0.018489, -0.010205, 0.012695},
- {-0.004423, 0.017827, 0.040544, 0.003629},
- { 0.020684, 0.026743, 0.007752, -0.025595},
- { 0.032071, 0.000043, 0.026188, -0.006444},
- { 0.058793, 0.015820, -0.001119, -0.017415},
- { 0.020156, -0.047590, 0.004227, 0.008670},
- { 0.054770, 0.032135, 0.029770, -0.009767},
- { 0.030884, 0.047757, 0.033068, 0.006866},
- { 0.062039, 0.011646, 0.056037, 0.016859},
- { 0.013798, -0.028196, 0.060710, 0.014299},
- { 0.100043, 0.041445, 0.023379, -0.014889},
- { 0.062728, -0.042821, 0.002180, -0.055380},
- { 0.061663, 0.018767, -0.015571, -0.074095},
- { 0.062980, 0.080497, 0.011808, -0.031787},
- { 0.084964, 0.043100, -0.025877, 0.020309},
- { 0.014707, 0.035421, -0.041440, -0.053373},
- { 0.081268, 0.005791, -0.066290, -0.039825},
- { 0.017691, -0.020401, -0.040513, -0.083960},
- { 0.120874, 0.055753, -0.025988, -0.059552},
- { 0.079912, 0.007894, -0.085380, -0.114587},
- { 0.036856, -0.039331, -0.104237, -0.069116},
- { 0.008526, -0.064273, -0.048312, -0.038595},
- { 0.033461, -0.028956, -0.066505, 0.038722},
- {-0.042064, -0.043989, -0.100653, -0.071550},
- {-0.015342, -0.064850, -0.065675, -0.122769},
- {-0.006581, -0.004919, -0.113564, -0.145753},
- { 0.008273, -0.070702, -0.164998, -0.095541},
- {-0.001698, -0.063744, -0.129971, -0.011162},
- {-0.048471, -0.087500, -0.111006, -0.161823},
- {-0.032193, -0.091955, -0.080642, 0.012288},
- {-0.095873, -0.015986, -0.072722, -0.101745},
- {-0.079477, -0.082060, -0.203008, -0.100297},
- {-0.023883, -0.064022, -0.168341, -0.211739},
- {-0.070530, -0.103547, -0.123858, 0.055049},
- {-0.033503, -0.076812, -0.016287, 0.044159},
- {-0.088427, -0.161682, -0.058579, 0.013873},
- {-0.083068, -0.168222, -0.016773, -0.080209},
- {-0.080548, -0.139090, 0.030544, 0.007171},
- {-0.117482, -0.083718, 0.027074, -0.003674},
- {-0.163085, -0.156856, -0.012618, -0.022329},
- {-0.176540, -0.113042, -0.020148, 0.051770},
- {-0.153891, -0.199293, -0.043244, 0.028331},
- {-0.107822, -0.150615, 0.016430, 0.092919},
- {-0.137676, -0.183224, 0.066026, 0.029343},
- {-0.191106, -0.099250, 0.045370, 0.004084},
- {-0.237042, -0.130815, -0.022543, -0.029428},
- {-0.201014, -0.053591, -0.007305, -0.033547},
- {-0.249286, -0.228408, 0.005002, 0.007146},
- {-0.206509, -0.211998, -0.061352, -0.047233},
- {-0.255702, -0.135114, 0.076375, 0.036630},
- {-0.296271, -0.073946, -0.007273, -0.019601},
- {-0.302917, -0.175111, -0.070024, -0.043905},
- {-0.239275, -0.043962, -0.084982, -0.067446},
- {-0.254583, -0.294720, -0.088762, -0.070451},
- {-0.205583, -0.238996, -0.124753, 0.033076},
- {-0.205583, -0.215882, -0.028472, 0.118679},
- {-0.153640, -0.204464, -0.039654, -0.134441},
- {-0.145929, -0.191970, -0.175308, 0.021366},
- {-0.149348, -0.212569, -0.118324, 0.103812},
- {-0.166397, -0.220581, -0.265260, -0.029113},
- {-0.164171, -0.231262, -0.258828, 0.061427},
- {-0.200198, -0.263453, -0.212016, 0.115359},
- {-0.130088, -0.212168, -0.202368, 0.118563},
- {-0.206387, -0.078075, -0.227856, -0.111165},
- {-0.129605, -0.176848, -0.241584, -0.259900},
- {-0.176826, -0.045901, -0.141712, -0.209345},
- {-0.351173, -0.031097, -0.133935, -0.182412},
- {-0.164232, 0.027006, -0.014039, -0.053567},
- {-0.171037, -0.025924, 0.030972, 0.017329},
- {-0.080862, -0.021577, 0.007652, 0.063968},
- {-0.061788, 0.042024, -0.018783, -0.057979},
- {-0.110311, 0.054760, 0.031446, -0.006710},
- {-0.136637, 0.022171, 0.084991, 0.028039},
- {-0.254471, -0.004376, 0.078034, 0.033649},
- {-0.234464, 0.088157, 0.040999, 0.002639},
- {-0.037095, 0.059443, 0.072180, 0.015027},
- {-0.046841, -0.004813, 0.088266, 0.038786},
- {-0.086782, 0.120100, 0.082655, 0.020271},
- {-0.118361, -0.069242, 0.094867, 0.039200},
- {-0.023342, -0.084303, 0.052684, 0.017093},
- {-0.014194, 0.001012, 0.011946, 0.074125},
- {-0.015342, 0.076396, 0.022365, -0.028001},
- { 0.027706, 0.037047, 0.107573, 0.060815},
- { 0.030615, 0.040664, 0.010467, 0.074289},
- { 0.038646, 0.115584, 0.069627, 0.007642},
- { 0.096463, 0.069818, 0.062494, 0.015413},
- { 0.054834, 0.065232, 0.054286, 0.110088},
- { 0.152312, 0.092371, 0.026420, -0.013184},
- { 0.144264, 0.123438, 0.080131, 0.023233},
- { 0.124405, 0.009943, -0.148477, -0.205184}
-};
-
-static const float *lsf_codebooks_16k[] = {
- lsf_cb1_16k[0], lsf_cb2_16k[0], lsf_cb3_16k[0], lsf_cb4_16k[0],
- lsf_cb5_16k[0]
-};
-
-#endif /* AVCODEC_SIPR16KDATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/siprdata.h b/src/thirdparty/ffmpeg/libavcodec/siprdata.h
deleted file mode 100644
index b41b26baf..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/siprdata.h
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * SIPR / ACELP.NET decoder
- *
- * Copyright (c) 2008 Vladimir Voroshilov
- * Copyright (c) 2009 Vitor Sessak
- *
- * 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_SIPRDATA_H
-#define AVCODEC_SIPRDATA_H
-
-static const float mean_lsf[10] = {
- 0.297151, 0.452308, 0.765443, 1.134803, 1.421125,
- 1.773822, 2.049173, 2.375914, 2.585097, 0.075756
-};
-
-static const float lsf_cb1[64][2] = {
- { 0.007587, -0.005843}, { 0.042163, -0.028048}, {-0.017147, -0.060705},
- { 0.013773, -0.038108}, {-0.041563, -0.078571}, {-0.076928, -0.119343},
- { 0.012654, 0.176005}, { 0.059737, 0.156869}, { 0.171767, 0.231837},
- { 0.114030, 0.242047}, { 0.168977, 0.283101}, { 0.146210, 0.397961},
- { 0.249446, 0.268421}, { 0.137074, 0.186724}, {-0.057736, -0.135638},
- {-0.109664, -0.124611}, {-0.021234, -0.031174}, {-0.013990, -0.091819},
- {-0.040046, -0.111426}, {-0.016830, 0.055361}, { 0.057815, 0.071606},
- { 0.060670, 0.114436}, { 0.106695, 0.140838}, { 0.093601, 0.092793},
- { 0.039593, 0.006142}, {-0.066589, -0.092463}, {-0.102589, -0.171380},
- {-0.059621, -0.050671}, { 0.166131, 0.139773}, { 0.213069, 0.190761},
- { 0.061820, 0.037661}, { 0.136471, 0.090823}, {-0.019789, 0.013515},
- { 0.022280, 0.079473}, { 0.215281, 0.461959}, { 0.206497, 0.340077},
- { 0.012249, -0.065596}, { 0.091345, 0.190871}, { 0.019506, 0.037266},
- {-0.050702, -0.013223}, {-0.057334, 0.028943}, { 0.291512, 0.371415},
- {-0.053467, 0.084160}, { 0.025372, 0.375310}, { 0.269995, 0.566520},
- {-0.095259, -0.012353}, { 0.050479, 0.212893}, { 0.101219, 0.049320},
- { 0.072426, 0.283362}, {-0.084116, -0.150542}, {-0.031485, 0.144922},
- { 0.012714, 0.256910}, {-0.009528, 0.102768}, {-0.039572, 0.204967},
- {-0.098800, 0.055038}, { 0.020719, 0.128387}, {-0.045559, -0.178373},
- {-0.082338, 0.136933}, {-0.058270, 0.292806}, { 0.084242, 0.505112},
- { 0.121825, 0.326386}, {-0.102658, -0.069341}, { 0.071675, 0.004744},
- {-0.117763, -0.202608}
-};
-
-static const float lsf_cb2[128][2] = {
- { 0.025412, 0.006095}, {-0.069803, 0.010650}, {-0.175957, -0.185800},
- {-0.139298, -0.048013}, {-0.156150, -0.129688}, {-0.160523, 0.068022},
- { 0.199683, 0.259982}, { 0.258038, 0.236147}, { 0.367089, 0.304716},
- { 0.251764, 0.305853}, { 0.394314, 0.382153}, { 0.448579, 0.337438},
- { 0.323286, 0.425563}, { 0.015369, 0.123820}, {-0.026770, 0.083881},
- {-0.112161, -0.097993}, {-0.221847, -0.161311}, {-0.050014, -0.092862},
- {-0.214960, -0.398498}, {-0.114062, -0.241381}, { 0.137950, 0.138852},
- { 0.031529, 0.065719}, { 0.208734, 0.084760}, { 0.157862, 0.057535},
- { 0.124750, 0.011922}, {-0.035227, -0.154397}, {-0.105523, -0.291427},
- {-0.073488, -0.201948}, {-0.224184, -0.273290}, {-0.168019, -0.240297},
- {-0.271591, -0.384682}, {-0.124784, 0.014253}, { 0.004210, -0.110418},
- { 0.074270, -0.014272}, { 0.053058, -0.068672}, {-0.090098, -0.145019},
- { 0.303214, 0.210323}, { 0.413443, 0.272002}, { 0.356904, 0.230646},
- {-0.035186, -0.028579}, {-0.117558, 0.115105}, {-0.159225, 0.218385},
- {-0.230178, 0.172901}, {-0.216148, -0.110195}, { 0.309444, 0.101508},
- { 0.250489, 0.118338}, { 0.293324, 0.151205}, {-0.023634, 0.033084},
- { 0.076708, 0.114024}, { 0.123119, 0.087704}, {-0.060265, 0.126543},
- {-0.223766, -0.021903}, {-0.241987, -0.328089}, { 0.205598, 0.147925},
- {-0.087010, 0.064601}, {-0.287892, -0.286099}, {-0.179451, -0.350781},
- {-0.219572, 0.043816}, {-0.217263, 0.245550}, {-0.286743, -0.180981},
- { 0.172659, 0.112620}, {-0.105422, 0.176856}, { 0.006176, -0.051491},
- { 0.099802, 0.176322}, {-0.186620, -0.068980}, { 0.164689, 0.185018},
- { 0.519877, 0.376111}, { 0.521941, 0.533731}, { 0.473375, 0.439534},
- { 0.214235, 0.202476}, { 0.579215, 0.466969}, { 0.310414, 0.271057},
- { 0.257450, 0.058939}, { 0.023936, -0.169464}, {-0.268817, -0.064531},
- {-0.174182, -0.000198}, {-0.268405, -0.234529}, {-0.296522, 0.247140},
- { 0.115950, -0.072194}, {-0.303666, 0.149084}, {-0.347762, -0.011002},
- {-0.223829, -0.214137}, {-0.278958, -0.457975}, { 0.135500, 0.238466},
- { 0.312730, 0.342760}, { 0.071754, -0.125912}, { 0.485938, 0.260429},
- { 0.037536, 0.179771}, { 0.391493, 0.156938}, { 0.397320, 0.484446},
- {-0.308630, -0.342418}, {-0.269599, -0.128453}, {-0.086683, -0.043863},
- { 0.421115, 0.213521}, { 0.082417, 0.049006}, {-0.087873, 0.238126},
- { 0.338899, 0.166131}, {-0.166988, 0.147105}, {-0.167214, -0.294075},
- { 0.588706, 0.328303}, { 0.207270, 0.017671}, {-0.141658, 0.291147},
- {-0.140850, 0.374321}, { 0.028180, 0.322510}, {-0.229858, 0.328036},
- {-0.060743, -0.260916}, {-0.011131, 0.246442}, {-0.058151, 0.310760},
- {-0.127536, -0.186432}, {-0.128523, -0.334884}, {-0.283899, 0.077729},
- {-0.031595, 0.181015}, {-0.329330, -0.108630}, {-0.215739, 0.107458},
- { 0.175734, 0.327134}, { 0.255801, 0.176077}, { 0.228265, 0.396859},
- {-0.370909, -0.185081}, {-0.355138, -0.300405}, { 0.061669, 0.242616},
- { 0.104489, 0.307995}, {-0.320021, -0.234002}, { 0.077349, 0.416286},
- {-0.339471, -0.407609}, {-0.019384, -0.215111}, { 0.168229, -0.032453},
- {-0.040140, 0.399658}, {-0.275141, 0.008218}
-};
-
-static const float lsf_cb3[128][2] = {
- { 0.024608, 0.006198}, {-0.216616, -0.398169}, {-0.089601, -0.201370},
- {-0.121878, -0.305281}, { 0.037913, 0.059320}, { 0.245126, 0.244089},
- { 0.266853, 0.182476}, { 0.319362, 0.203481}, { 0.349945, 0.252644},
- { 0.393849, 0.279272}, { 0.445707, 0.258063}, { 0.387321, 0.200855},
- {-0.038818, 0.129603}, {-0.009510, 0.076441}, {-0.023892, -0.028199},
- {-0.117134, -0.145990}, {-0.186585, -0.052886}, {-0.034250, -0.084547},
- {-0.087443, -0.095426}, {-0.453322, -0.174493}, {-0.363975, -0.148186},
- {-0.334413, -0.202479}, {-0.221313, -0.181320}, {-0.131146, -0.050611},
- {-0.104706, 0.115139}, { 0.192765, 0.275417}, { 0.014184, 0.194251},
- { 0.154215, 0.226949}, { 0.084031, 0.221759}, { 0.189438, 0.164566},
- { 0.130737, 0.170962}, {-0.066815, 0.062954}, {-0.177176, -0.145167},
- {-0.247608, -0.129767}, {-0.187886, -0.293720}, {-0.244036, -0.344655},
- {-0.203063, -0.234947}, {-0.292715, -0.158421}, { 0.064990, -0.028164},
- { 0.147664, 0.085995}, { 0.107977, 0.002253}, { 0.071286, 0.027533},
- { 0.021017, -0.049807}, {-0.272056, -0.217857}, {-0.065596, 0.008375},
- {-0.150818, -0.195514}, {-0.012767, -0.150787}, { 0.238541, 0.136606},
- { 0.291741, 0.114024}, { 0.202677, 0.103701}, { 0.140985, 0.037759},
- {-0.257347, -0.442383}, {-0.320666, -0.319742}, {-0.488725, -0.603660},
- {-0.319170, -0.469806}, { 0.014970, -0.101074}, { 0.102209, 0.066790},
- {-0.076202, -0.044884}, { 0.073868, 0.152565}, { 0.070755, -0.091358},
- {-0.016751, 0.027216}, { 0.071201, 0.096981}, {-0.060975, -0.145638},
- { 0.114156, 0.117587}, {-0.284757, -0.029101}, {-0.253005, -0.073645},
- {-0.204028, -0.098492}, {-0.114508, 0.001219}, {-0.225284, -0.011998},
- {-0.235670, 0.084330}, { 0.161921, 0.128334}, { 0.025717, 0.119456},
- {-0.255292, -0.281471}, {-0.392803, -0.095809}, { 0.039229, -0.152110},
- {-0.310905, -0.099233}, {-0.268773, 0.032308}, {-0.340150, 0.013129},
- {-0.344890, -0.045157}, {-0.188423, 0.265603}, {-0.168235, -0.000936},
- { 0.000462, 0.297000}, { 0.263674, 0.371214}, {-0.146797, -0.098225},
- {-0.386557, -0.282426}, {-0.070940, -0.255550}, { 0.293258, 0.252785},
- { 0.408332, 0.387751}, {-0.381914, -0.358918}, {-0.463621, -0.315560},
- {-0.323681, -0.258465}, { 0.250055, 0.071195}, {-0.405256, -0.429754},
- {-0.135748, -0.251274}, { 0.186827, 0.060177}, { 0.116742, -0.053526},
- {-0.403321, -0.220339}, {-0.414144, -0.021108}, {-0.416877, 0.050184},
- {-0.470083, -0.079564}, {-0.315554, 0.219217}, {-0.273183, 0.138437},
- { 0.253231, 0.306374}, { 0.177802, 0.346298}, { 0.210358, 0.207697},
- {-0.323480, 0.077519}, {-0.193136, 0.048170}, { 0.114492, 0.292778},
- {-0.130766, 0.056677}, {-0.171572, -0.349267}, {-0.370076, -0.536392},
- {-0.311109, -0.389953}, { 0.334928, 0.367664}, { 0.351246, 0.438664},
- { 0.518803, 0.331253}, { 0.437061, 0.327257}, { 0.318906, 0.307389},
- {-0.025972, -0.206758}, { 0.373278, 0.325438}, { 0.473488, 0.389441},
- { 0.478553, 0.477990}, { 0.332783, 0.153825}, { 0.212098, 0.452336},
- { 0.161522, -0.011212}, { 0.209368, 0.020687}, {-0.086262, 0.204493},
- {-0.388643, 0.133640}, {-0.177016, 0.134404}
-};
-
-static const float lsf_cb4[128][2] = {
- {-0.003594, -0.022447}, { 0.070651, 0.028334}, {-0.290374, -0.018347},
- {-0.224495, -0.370312}, {-0.269555, -0.131227}, {-0.122714, -0.267733},
- { 0.173325, 0.138698}, { 0.161946, 0.020687}, { 0.111706, 0.022510},
- { 0.097638, 0.056049}, { 0.139754, 0.059920}, { 0.056549, -0.050586},
- { 0.036301, 0.021501}, {-0.066347, 0.012324}, {-0.066972, 0.096136},
- {-0.120062, -0.084201}, { 0.011225, 0.047425}, {-0.012846, -0.067390},
- {-0.116201, 0.122874}, {-0.027819, 0.035453}, {-0.024743, 0.072835},
- {-0.034061, -0.001310}, { 0.077469, 0.081609}, { 0.128347, 0.139584},
- { 0.183416, 0.086563}, {-0.155839, -0.053775}, {-0.190403, -0.018639},
- {-0.202548, -0.062841}, {-0.373733, -0.275094}, {-0.394260, -0.186513},
- {-0.465700, -0.220031}, { 0.064400, -0.095825}, {-0.262053, -0.199837},
- {-0.167233, -0.094402}, { 0.048600, 0.057567}, {-0.007122, 0.168506},
- { 0.050938, 0.156451}, {-0.060828, 0.147083}, {-0.171889, 0.195822},
- {-0.218934, 0.138431}, {-0.270532, 0.195775}, {-0.405818, 0.075643},
- {-0.440187, 0.193387}, {-0.484968, 0.157607}, {-0.480560, 0.067230},
- {-0.436757, -0.111847}, {-0.040731, -0.040363}, {-0.202319, -0.170457},
- {-0.158515, -0.134551}, {-0.356709, -0.378549}, {-0.268820, -0.289831},
- {-0.188486, -0.289306}, {-0.148139, -0.177616}, {-0.071591, -0.191128},
- {-0.052270, -0.150589}, {-0.020543, -0.116220}, { 0.039584, -0.012592},
- {-0.268226, 0.042704}, {-0.209755, 0.069423}, {-0.168964, 0.124504},
- {-0.363240, 0.188266}, {-0.524935, -0.025010}, {-0.105894, -0.002699},
- {-0.251830, -0.062018}, {-0.310480, -0.082325}, { 0.014652, 0.083127},
- {-0.136512, 0.033116}, {-0.073755, -0.025236}, { 0.110766, 0.095954},
- { 0.002878, 0.011838}, {-0.074977, -0.244586}, {-0.047023, -0.081339},
- {-0.183249, 0.029525}, { 0.263435, 0.206934}, {-0.156721, -0.229993},
- {-0.112224, -0.208941}, {-0.116534, -0.123191}, {-0.073988, -0.111668},
- { 0.029484, -0.137573}, {-0.009802, -0.161685}, {-0.023273, 0.114043},
- {-0.332651, 0.049072}, {-0.394009, 0.018608}, {-0.433543, -0.035318},
- {-0.368459, -0.108024}, {-0.350215, -0.037617}, {-0.321140, -0.178537},
- { 0.020307, -0.048487}, {-0.210512, -0.232274}, {-0.082140, -0.065443},
- { 0.081961, -0.009340}, { 0.146794, 0.101973}, { 0.213999, 0.124687},
- { 0.100217, -0.054095}, {-0.114411, -0.041403}, {-0.097631, 0.037061},
- {-0.099651, -0.157978}, {-0.215790, -0.116550}, {-0.107100, 0.076300},
- { 0.084653, 0.126088}, { 0.246439, 0.091442}, { 0.160077, 0.188536},
- { 0.273900, 0.279190}, { 0.320417, 0.232550}, { 0.132710, -0.018988},
- { 0.018950, -0.091681}, {-0.032073, -0.202906}, { 0.212789, 0.178188},
- { 0.208580, 0.239726}, { 0.049420, 0.099840}, {-0.145695, -0.010619},
- {-0.132525, -0.322660}, { 0.019666, 0.126603}, { 0.260809, 0.147727},
- {-0.232795, -0.001090}, {-0.049826, 0.225987}, {-0.154774, 0.076614},
- { 0.045032, 0.221397}, { 0.321014, 0.161632}, {-0.062379, 0.053586},
- { 0.132252, 0.246675}, { 0.392627, 0.271905}, {-0.264585, 0.102344},
- {-0.327200, 0.121624}, {-0.399642, 0.124445}, {-0.108335, 0.179171},
- { 0.100374, 0.182731}, { 0.203852, 0.049505}
-};
-
-static const float lsf_cb5[32][2] = {
- {-0.047705, 0.008002}, { 0.011332, 0.065028}, {-0.021796, -0.034777},
- {-0.147394, -0.001241}, {-0.001577, 0.020599}, {-0.083827, -0.028975},
- {-0.177707, 0.066046}, {-0.043241, -0.165144}, { 0.053322, 0.096519},
- {-0.097688, 0.106484}, {-0.023392, 0.111234}, {-0.146747, -0.159360},
- { 0.027241, -0.011806}, {-0.043156, 0.057667}, { 0.019516, -0.062116},
- { 0.025990, 0.162533}, { 0.091888, 0.009720}, {-0.098511, 0.036414},
- { 0.013722, -0.116512}, { 0.054833, -0.180975}, { 0.119497, 0.128774},
- { 0.118378, -0.125997}, { 0.065882, -0.030932}, { 0.120581, -0.039964},
- {-0.050561, -0.088577}, { 0.050134, 0.033194}, {-0.129654, -0.075112},
- {-0.225334, -0.040234}, { 0.070629, -0.084455}, { 0.095508, 0.063548},
- { 0.150514, 0.034366}, { 0.186092, -0.069272}
-};
-
-static const float *lsf_codebooks[] = {
- lsf_cb1[0], lsf_cb2[0], lsf_cb3[0], lsf_cb4[0], lsf_cb5[0]
-};
-
-static const float gain_cb[128][2] = {
- {0.035230, 0.161540}, {0.049223, 0.448359}, {0.057443, 0.809043},
- {0.072434, 1.760306}, {0.111491, 0.566418}, {0.112820, 1.098524},
- {0.143493, 0.726856}, {0.144840, 0.347800}, {0.180341, 1.050010},
- {0.188171, 2.197256}, {0.189771, 0.256947}, {0.198260, 0.484678},
- {0.210622, 0.755825}, {0.220694, 0.590788}, {0.237062, 1.322214},
- {0.255175, 0.338710}, {0.298980, 0.919051}, {0.314627, 0.520961},
- {0.337106, 1.469863}, {0.341422, 2.804546}, {0.363257, 0.736222},
- {0.363881, 0.367640}, {0.369850, 1.937934}, {0.370136, 1.075201},
- {0.397152, 0.549410}, {0.426557, 0.876015}, {0.450686, 0.215588},
- {0.468116, 0.671848}, {0.470495, 1.242034}, {0.474180, 1.739845},
- {0.484875, 0.490564}, {0.498917, 0.971238}, {0.530996, 0.785765},
- {0.539768, 2.130689}, {0.546021, 0.589544}, {0.546632, 3.050846},
- {0.552336, 0.389775}, {0.556302, 1.400103}, {0.559688, 1.105421},
- {0.574140, 0.667513}, {0.595547, 0.828943}, {0.597771, 0.496929},
- {0.617079, 1.863075}, {0.619657, 1.221713}, {0.621172, 0.950275},
- {0.628426, 0.630766}, {0.628689, 4.242164}, {0.640899, 1.529846},
- {0.645813, 0.331127}, {0.653056, 0.748168}, {0.662909, 1.077438},
- {0.669505, 2.631114}, {0.681570, 1.839298}, {0.687844, 0.903400},
- {0.688660, 1.270830}, {0.695070, 0.578227}, {0.697926, 0.428440},
- {0.715454, 0.812355}, {0.729981, 1.539357}, {0.737434, 1.106765},
- {0.740241, 2.033374}, {0.740871, 0.568460}, {0.752689, 0.698461},
- {0.756587, 0.893078}, {0.767797, 0.499246}, {0.768516, 3.712434},
- {0.773153, 1.332360}, {0.786125, 1.042996}, {0.788792, 0.238388},
- {0.790861, 2.273229}, {0.795338, 1.582767}, {0.809621, 0.595501},
- {0.821032, 0.756460}, {0.824590, 0.922925}, {0.826019, 1.186793},
- {0.827426, 1.885076}, {0.830080, 6.088666}, {0.837028, 2.819993},
- {0.845561, 1.490623}, {0.848323, 0.410436}, {0.856522, 0.729725},
- {0.862636, 0.966880}, {0.874561, 1.681660}, {0.874751, 1.177630},
- {0.879289, 2.301300}, {0.886671, 0.613068}, {0.896729, 0.781097},
- {0.904777, 3.484111}, {0.906098, 1.330892}, {0.919182, 1.877203},
- {0.919901, 0.569511}, {0.921772, 1.034126}, {0.922439, 0.376000},
- {0.934221, 1.485214}, {0.938842, 0.869135}, {0.939166, 2.378294},
- {0.958933, 1.122722}, {0.959042, 0.694098}, {0.960995, 1.743430},
- {0.970763, 2.884897}, {0.982881, 0.814506}, {0.990141, 1.330022},
- {0.996447, 1.823381}, {1.000013, 0.967498}, {1.000743, 0.480597},
- {1.008020, 5.095226}, {1.013883, 2.105435}, {1.026438, 0.691312},
- {1.027361, 1.558169}, {1.030123, 3.586526}, {1.033916, 1.118036},
- {1.039315, 2.543360}, {1.068596, 0.836380}, {1.081023, 1.318768},
- {1.093150, 2.267843}, {1.095607, 1.712383}, {1.102816, 1.037334},
- {1.103231, 3.536292}, {1.107320, 0.508615}, {1.150000, 7.999000},
- {1.156731, 1.236772}, {1.168428, 2.268084}, {1.184130, 0.775839},
- {1.210609, 1.511840}, {1.220663, 4.365683}, {1.224016, 0.983179},
- {1.252236, 2.778535}, {1.301176, 1.923126}
-};
-
-static const float pred[4] = {
- 0.200, 0.334, 0.504, 0.691
-};
-
-#endif /* AVCODEC_SIPRDATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/sp5x.h b/src/thirdparty/ffmpeg/libavcodec/sp5x.h
deleted file mode 100644
index 78f8fad5a..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/sp5x.h
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * Sunplus JPEG tables
- * Copyright (c) 2003 the ffmpeg project
- *
- * 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_SP5X_H
-#define AVCODEC_SP5X_H
-
-#include <stdint.h>
-
-static const uint8_t sp5x_data_sof[] =
-{
- 0xFF, 0xC0, /* SOF */
- 0x00, 0x11, /* len */
- 0x08, /* bits */
- 0x00, 0xf0, /* height (default: 240) */
- 0x01, 0x40, /* width (default: 240) */
- 0x03, /* nb components */
- 0x01, 0x22, 0x00, /* 21 vs 22 ? */
- 0x02, 0x11, 0x01,
- 0x03, 0x11, 0x01
-};
-
-static const uint8_t sp5x_data_sos[] =
-{
- 0xFF, 0xDA, /* SOS */
- 0x00, 0x0C, /* len */
- 0x03, /* nb components */
- 0x01, 0x00,
- 0x02, 0x11,
- 0x03, 0x11,
- 0x00, /* Ss */
- 0x3F, /* Se */
- 0x00 /* Ah/Al */
-};
-
-static const uint8_t sp5x_data_dqt[] =
-{
- 0xFF, 0xDB, /* DQT */
- 0x00, 0x84, /* len */
- 0x00,
- 0x05, 0x03, 0x04, 0x04, 0x04, 0x03, 0x05, 0x04,
- 0x04, 0x04, 0x06, 0x05, 0x05, 0x06, 0x08, 0x0D,
- 0x08, 0x08, 0x07, 0x07, 0x08, 0x10, 0x0C, 0x0C,
- 0x0A, 0x0D, 0x14, 0x11, 0x15, 0x14, 0x13, 0x11,
- 0x13, 0x13, 0x16, 0x18, 0x1F, 0x1A, 0x16, 0x17,
- 0x1E, 0x17, 0x13, 0x13, 0x1B, 0x25, 0x1C, 0x1E,
- 0x20, 0x21, 0x23, 0x23, 0x23, 0x15, 0x1A, 0x27,
- 0x29, 0x26, 0x22, 0x29, 0x1F, 0x22, 0x23, 0x22,
- 0x01,
- 0x05, 0x06, 0x06, 0x08, 0x07, 0x08, 0x10, 0x08,
- 0x08, 0x10, 0x22, 0x16, 0x13, 0x16, 0x22, 0x22,
- 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
- 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
- 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
- 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
- 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
- 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22
-};
-
-static const uint8_t sp5x_data_dht[] = {
- 0xFF, 0xC4, /* DHT */
- 0x01, 0xA2, /* len */
- 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
- 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x01, 0x00, 0x03,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
- 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
- 0x0A, 0x0B, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03,
- 0x02, 0x04, 0x03, 0x05, 0x05, 0x04, 0x04, 0x00,
- 0x00, 0x01, 0x7D, 0x01, 0x02, 0x03, 0x00, 0x04,
- 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06, 0x13,
- 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81,
- 0x91, 0xA1, 0x08, 0x23, 0x42, 0xB1, 0xC1, 0x15,
- 0x52, 0xD1, 0xF0, 0x24, 0x33, 0x62, 0x72, 0x82,
- 0x09, 0x0A, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x25,
- 0x26, 0x27, 0x28, 0x29, 0x2A, 0x34, 0x35, 0x36,
- 0x37, 0x38, 0x39, 0x3A, 0x43, 0x44, 0x45, 0x46,
- 0x47, 0x48, 0x49, 0x4A, 0x53, 0x54, 0x55, 0x56,
- 0x57, 0x58, 0x59, 0x5A, 0x63, 0x64, 0x65, 0x66,
- 0x67, 0x68, 0x69, 0x6A, 0x73, 0x74, 0x75, 0x76,
- 0x77, 0x78, 0x79, 0x7A, 0x83, 0x84, 0x85, 0x86,
- 0x87, 0x88, 0x89, 0x8A, 0x92, 0x93, 0x94, 0x95,
- 0x96, 0x97, 0x98, 0x99, 0x9A, 0xA2, 0xA3, 0xA4,
- 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xB2, 0xB3,
- 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xC2,
- 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA,
- 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9,
- 0xDA, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
- 0xE8, 0xE9, 0xEA, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5,
- 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0x11, 0x00, 0x02,
- 0x01, 0x02, 0x04, 0x04, 0x03, 0x04, 0x07, 0x05,
- 0x04, 0x04, 0x00, 0x01, 0x02, 0x77, 0x00, 0x01,
- 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06,
- 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, 0x13, 0x22,
- 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xA1, 0xB1,
- 0xC1, 0x09, 0x23, 0x33, 0x52, 0xF0, 0x15, 0x62,
- 0x72, 0xD1, 0x0A, 0x16, 0x24, 0x34, 0xE1, 0x25,
- 0xF1, 0x17, 0x18, 0x19, 0x1A, 0x26, 0x27, 0x28,
- 0x29, 0x2A, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A,
- 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A,
- 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A,
- 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A,
- 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A,
- 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
- 0x8A, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
- 0x99, 0x9A, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,
- 0xA8, 0xA9, 0xAA, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6,
- 0xB7, 0xB8, 0xB9, 0xBA, 0xC2, 0xC3, 0xC4, 0xC5,
- 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xD2, 0xD3, 0xD4,
- 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xE2, 0xE3,
- 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xF2,
- 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA
-};
-
-
-static const uint8_t sp5x_quant_table[20][64]=
-{
- /* index 0, Q50 */
- { 16, 11, 12, 14, 12, 10, 16, 14, 13, 14, 18, 17, 16, 19, 24, 40,
- 26, 24, 22, 22, 24, 49, 35, 37, 29, 40, 58, 51, 61, 60, 57, 51,
- 56, 55, 64, 72, 92, 78, 64, 68, 87, 69, 55, 56, 80,109, 81, 87,
- 95, 98,103,104,103, 62, 77,113,121,112,100,120, 92,101,103, 99 },
- { 17, 18, 18, 24, 21, 24, 47, 26, 26, 47, 99, 66, 56, 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, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99 },
-
- /* index 1, Q70 */
- { 10, 7, 7, 8, 7, 6, 10, 8, 8, 8, 11, 10, 10, 11, 14, 24,
- 16, 14, 13, 13, 14, 29, 21, 22, 17, 24, 35, 31, 37, 36, 34, 31,
- 34, 33, 38, 43, 55, 47, 38, 41, 52, 41, 33, 34, 48, 65, 49, 52,
- 57, 59, 62, 62, 62, 37, 46, 68, 73, 67, 60, 72, 55, 61, 62, 59 },
- { 10, 11, 11, 14, 13, 14, 28, 16, 16, 28, 59, 40, 34, 40, 59, 59,
- 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
- 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
- 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59 },
-
- /* index 2, Q80 */
- { 6, 4, 5, 6, 5, 4, 6, 6, 5, 6, 7, 7, 6, 8, 10, 16,
- 10, 10, 9, 9, 10, 20, 14, 15, 12, 16, 23, 20, 24, 24, 23, 20,
- 22, 22, 26, 29, 37, 31, 26, 27, 35, 28, 22, 22, 32, 44, 32, 35,
- 38, 39, 41, 42, 41, 25, 31, 45, 48, 45, 40, 48, 37, 40, 41, 40 },
- { 7, 7, 7, 10, 8, 10, 19, 10, 10, 19, 40, 26, 22, 26, 40, 40,
- 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
- 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
- 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 },
-
- /* index 3, Q85 */
- { 5, 3, 4, 4, 4, 3, 5, 4, 4, 4, 5, 5, 5, 6, 7, 12,
- 8, 7, 7, 7, 7, 15, 11, 11, 9, 12, 17, 15, 18, 18, 17, 15,
- 17, 17, 19, 22, 28, 23, 19, 20, 26, 21, 17, 17, 24, 33, 24, 26,
- 29, 29, 31, 31, 31, 19, 23, 34, 36, 34, 30, 36, 28, 30, 31, 30 },
- { 5, 5, 5, 7, 6, 7, 14, 8, 8, 14, 30, 20, 17, 20, 30, 30,
- 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
- 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
- 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30 },
-
- /* index 4, Q90 */
- { 3, 2, 2, 3, 2, 2, 3, 3, 3, 3, 4, 3, 3, 4, 5, 8,
- 5, 5, 4, 4, 5, 10, 7, 7, 6, 8, 12, 10, 12, 12, 11, 10,
- 11, 11, 13, 14, 18, 16, 13, 14, 17, 14, 11, 11, 16, 22, 16, 17,
- 19, 20, 21, 21, 21, 12, 15, 23, 24, 22, 20, 24, 18, 20, 21, 20 },
- { 3, 4, 4, 5, 4, 5, 9, 5, 5, 9, 20, 13, 11, 13, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20 },
-
- /* index 5, Q60 */
- { 13, 9, 10, 11, 10, 8, 13, 11, 10, 11, 14, 14, 13, 15, 19, 32,
- 21, 19, 18, 18, 19, 39, 28, 30, 23, 32, 46, 41, 49, 48, 46, 41,
- 45, 44, 51, 58, 74, 62, 51, 54, 70, 55, 44, 45, 64, 87, 65, 70,
- 76, 78, 82, 83, 82, 50, 62, 90, 97, 90, 80, 96, 74, 81, 82, 79 },
- { 14, 14, 14, 19, 17, 19, 38, 21, 21, 38, 79, 53, 45, 53, 79, 79,
- 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
- 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
- 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79 },
-
- /* index 6, Q25 */
- { 32, 22, 24, 28, 24, 20, 32, 28, 26, 28, 36, 34, 32, 38, 48, 80,
- 52, 48, 44, 44, 48, 98, 70, 74, 58, 80,116,102,122,120,114,102,
- 112,110,128,144,184,156,128,136,174,138,110,112,160,218,162,174,
- 190,196,206,208,206,124,154,226,242,224,200,240,184,202,206,198 },
- { 34, 36, 36, 48, 42, 48, 94, 52, 52, 94,198,132,112,132,198,198,
- 198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,
- 198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,
- 198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,198 },
-
- /* index 7, Q95 */
- { 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 2, 2, 2, 4,
- 3, 2, 2, 2, 2, 5, 4, 4, 3, 4, 6, 5, 6, 6, 6, 5,
- 6, 6, 6, 7, 9, 8, 6, 7, 9, 7, 6, 6, 8, 11, 8, 9,
- 10, 10, 10, 10, 10, 6, 8, 11, 12, 11, 10, 12, 9, 10, 10, 10 },
- { 2, 2, 2, 2, 2, 2, 5, 3, 3, 5, 10, 7, 6, 7, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 },
-
- /* index 8, Q93 */
- { 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 3, 2, 2, 3, 3, 6,
- 4, 3, 3, 3, 3, 7, 5, 5, 4, 6, 8, 7, 9, 8, 8, 7,
- 8, 8, 9, 10, 13, 11, 9, 10, 12, 10, 8, 8, 11, 15, 11, 12,
- 13, 14, 14, 15, 14, 9, 11, 16, 17, 16, 14, 17, 13, 14, 14, 14 },
- { 2, 3, 3, 3, 3, 3, 7, 4, 4, 7, 14, 9, 8, 9, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 },
-
- /* index 9, Q40 */
- { 20, 14, 15, 18, 15, 13, 20, 18, 16, 18, 23, 21, 20, 24, 30, 50,
- 33, 30, 28, 28, 30, 61, 44, 46, 36, 50, 73, 64, 76, 75, 71, 64,
- 70, 69, 80, 90,115, 98, 80, 85,109, 86, 69, 70,100,136,101,109,
- 119,123,129,130,129, 78, 96,141,151,140,125,150,115,126,129,124 },
- { 21, 23, 23, 30, 26, 30, 59, 33, 33, 59,124, 83, 70, 83,124,124,
- 124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,
- 124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,
- 124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,124 }
-};
-
-#endif /* AVCODEC_SP5X_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/sp5xdec.c b/src/thirdparty/ffmpeg/libavcodec/sp5xdec.c
deleted file mode 100644
index e51d5f3cb..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/sp5xdec.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Sunplus JPEG decoder (SP5X)
- * Copyright (c) 2003 Alex Beregszaszi
- *
- * 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
- * Sunplus JPEG decoder (SP5X).
- */
-
-#include "avcodec.h"
-#include "mjpeg.h"
-#include "mjpegdec.h"
-#include "sp5x.h"
-
-
-static int sp5x_decode_frame(AVCodecContext *avctx,
- void *data, int *got_frame,
- AVPacket *avpkt)
-{
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
- AVPacket avpkt_recoded;
- const int qscale = 5;
- uint8_t *recoded;
- int i = 0, j = 0;
-
- if (!avctx->width || !avctx->height)
- return -1;
-
- recoded = av_mallocz(buf_size + 1024);
- if (!recoded)
- return -1;
-
- /* SOI */
- recoded[j++] = 0xFF;
- recoded[j++] = 0xD8;
-
- memcpy(recoded+j, &sp5x_data_dqt[0], sizeof(sp5x_data_dqt));
- memcpy(recoded+j+5, &sp5x_quant_table[qscale * 2], 64);
- memcpy(recoded+j+70, &sp5x_quant_table[(qscale * 2) + 1], 64);
- j += sizeof(sp5x_data_dqt);
-
- memcpy(recoded+j, &sp5x_data_dht[0], sizeof(sp5x_data_dht));
- j += sizeof(sp5x_data_dht);
-
- memcpy(recoded+j, &sp5x_data_sof[0], sizeof(sp5x_data_sof));
- AV_WB16(recoded+j+5, avctx->coded_height);
- AV_WB16(recoded+j+7, avctx->coded_width);
- j += sizeof(sp5x_data_sof);
-
- memcpy(recoded+j, &sp5x_data_sos[0], sizeof(sp5x_data_sos));
- j += sizeof(sp5x_data_sos);
-
- if(avctx->codec_id==AV_CODEC_ID_AMV)
- for (i = 2; i < buf_size-2 && j < buf_size+1024-2; i++)
- recoded[j++] = buf[i];
- else
- for (i = 14; i < buf_size && j < buf_size+1024-3; i++)
- {
- recoded[j++] = buf[i];
- if (buf[i] == 0xff)
- recoded[j++] = 0;
- }
-
- /* EOI */
- recoded[j++] = 0xFF;
- recoded[j++] = 0xD9;
-
- av_init_packet(&avpkt_recoded);
- avpkt_recoded.data = recoded;
- avpkt_recoded.size = j;
- i = ff_mjpeg_decode_frame(avctx, data, got_frame, &avpkt_recoded);
-
- av_free(recoded);
-
- return i < 0 ? i : avpkt->size;
-}
-
-#if CONFIG_SP5X_DECODER
-AVCodec ff_sp5x_decoder = {
- .name = "sp5x",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_SP5X,
- .priv_data_size = sizeof(MJpegDecodeContext),
- .init = ff_mjpeg_decode_init,
- .close = ff_mjpeg_decode_end,
- .decode = sp5x_decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .max_lowres = 3,
- .long_name = NULL_IF_CONFIG_SMALL("Sunplus JPEG (SP5X)"),
-};
-#endif
-#if CONFIG_AMV_DECODER
-AVCodec ff_amv_decoder = {
- .name = "amv",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_AMV,
- .priv_data_size = sizeof(MJpegDecodeContext),
- .init = ff_mjpeg_decode_init,
- .close = ff_mjpeg_decode_end,
- .decode = sp5x_decode_frame,
- .long_name = NULL_IF_CONFIG_SMALL("AMV Video"),
-};
-#endif
diff --git a/src/thirdparty/ffmpeg/libavcodec/svq1.c b/src/thirdparty/ffmpeg/libavcodec/svq1.c
deleted file mode 100644
index 23c05c9ee..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/svq1.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * SVQ1 decoder
- * ported to MPlayer by Arpi <arpi@thot.banki.hu>
- * ported to libavcodec by Nick Kurshev <nickols_k@mail.ru>
- *
- * Copyright (C) 2002 the xine project
- * Copyright (C) 2002 the ffmpeg project
- *
- * SVQ1 Encoder (c) 2004 Mike Melanson <melanson@pcisys.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
- */
-
-/**
- * @file
- * Sorenson Vector Quantizer #1 (SVQ1) video codec.
- * For more information of the SVQ1 algorithm, visit:
- * http://www.pcisys.net/~melanson/codecs/
- */
-
-#include "svq1.h"
-#include "svq1_cb.h"
-#include "svq1_vlc.h"
-
-/* standard video sizes */
-const uint16_t ff_svq1_frame_size_table[7][2] = {
- { 160, 120 }, { 128, 96 }, { 176, 144 }, { 352, 288 },
- { 704, 576 }, { 240, 180 }, { 320, 240 }
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/svq1.h b/src/thirdparty/ffmpeg/libavcodec/svq1.h
deleted file mode 100644
index ebaab6f5b..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/svq1.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * SVQ1 decoder
- * ported to MPlayer by Arpi <arpi@thot.banki.hu>
- * ported to libavcodec by Nick Kurshev <nickols_k@mail.ru>
- *
- * Copyright (C) 2002 the xine project
- * Copyright (C) 2002 the ffmpeg project
- *
- * SVQ1 Encoder (c) 2004 Mike Melanson <melanson@pcisys.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
- */
-
-/**
- * @file
- * Sorenson Vector Quantizer #1 (SVQ1) video codec.
- * For more information of the SVQ1 algorithm, visit:
- * http://www.pcisys.net/~melanson/codecs/
- */
-
-#ifndef AVCODEC_SVQ1_H
-#define AVCODEC_SVQ1_H
-
-#include <stdint.h>
-
-#define SVQ1_BLOCK_SKIP 0
-#define SVQ1_BLOCK_INTER 1
-#define SVQ1_BLOCK_INTER_4V 2
-#define SVQ1_BLOCK_INTRA 3
-
-uint16_t ff_svq1_packet_checksum(const uint8_t *data,
- const int length, int value);
-
-extern const int8_t *const ff_svq1_inter_codebooks[6];
-extern const int8_t *const ff_svq1_intra_codebooks[6];
-
-extern const uint8_t ff_svq1_block_type_vlc[4][2];
-extern const uint8_t ff_svq1_intra_multistage_vlc[6][8][2];
-extern const uint8_t ff_svq1_inter_multistage_vlc[6][8][2];
-extern const uint16_t ff_svq1_intra_mean_vlc[256][2];
-extern const uint16_t ff_svq1_inter_mean_vlc[512][2];
-
-extern const uint16_t ff_svq1_frame_size_table[7][2];
-
-#endif /* AVCODEC_SVQ1_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/svq13.c b/src/thirdparty/ffmpeg/libavcodec/svq13.c
deleted file mode 100644
index b821a446d..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/svq13.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * SVQ1/SVQ3 decoder common code
- *
- * 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 "svq1.h"
-
-static const uint16_t checksum_table[256] = {
- 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
- 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
- 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6,
- 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE,
- 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485,
- 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D,
- 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4,
- 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC,
- 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823,
- 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B,
- 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12,
- 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A,
- 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41,
- 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49,
- 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70,
- 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78,
- 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F,
- 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067,
- 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E,
- 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256,
- 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D,
- 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
- 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C,
- 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634,
- 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB,
- 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3,
- 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A,
- 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92,
- 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9,
- 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1,
- 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8,
- 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
-};
-
-uint16_t ff_svq1_packet_checksum (const uint8_t *data,
- const int length, int value)
-{
- int i;
-
- for (i = 0; i < length; i++)
- value = checksum_table[data[i] ^ (value >> 8)] ^ ((value & 0xFF) << 8);
-
- return value;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/svq1_cb.h b/src/thirdparty/ffmpeg/libavcodec/svq1_cb.h
deleted file mode 100644
index da83d06f7..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/svq1_cb.h
+++ /dev/null
@@ -1,1525 +0,0 @@
-/*
- * SVQ1 decoder
- * ported to MPlayer by Arpi <arpi@thot.banki.hu>
- * ported to libavcodec by Nick Kurshev <nickols_k@mail.ru>
- *
- * Copyright (C) 2002 the xine project
- * Copyright (C) 2002 the ffmpeg project
- *
- * 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
- * svq1 code books.
- */
-
-#ifndef AVCODEC_SVQ1_CB_H
-#define AVCODEC_SVQ1_CB_H
-
-#include <stdint.h>
-#include <stdlib.h>
-
-#include "libavutil/mem.h"
-
-/* 6x16-entry codebook for inter-coded 4x2 vectors */
-DECLARE_ALIGNED(4, static const int8_t, svq1_inter_codebook_4x2)[768] = {
- 7, 2, -6, -7, 7, 3, -3, -4, -7, -2, 7, 8, -8, -4, 3, 4,
- 19, 17, 9, 3,-14,-16,-12, -8,-18,-16, -8, -3, 11, 14, 12, 8,
- 7,-16,-10, 20, 7,-17,-10, 20, -6, 18, 8,-21, -7, 18, 9,-20,
- 25, 3,-20,-14, 29, 7,-18,-13,-29, -4, 21, 14,-31, -6, 20, 14,
- -19,-26,-28,-24, 31, 32, 22, 10, 15, 24, 31, 28,-32,-32,-22,-13,
- 2, -8,-23,-26, -9, 3, 27, 35, 3, 11, 21, 21, 8, -4,-27,-34,
- -30,-31, 12, 47,-29,-30, 13, 47, 38, 30,-17,-46, 34, 26,-19,-46,
- -42,-50,-51,-43, 34, 48, 55, 48, 48, 54, 51, 42,-44,-52,-53,-47,
- 4, 5, 0, -6, -2, -2, 0, 1,-11, -6, -1, -2, 1, 8, 9, 1,
- 0, 1, -6, 5, 8, 1,-12, 2, 7,-14, -7, 8, 5, -8, 0, 8,
- 1, 4, 11, 8,-12, -8, 0, -5, -1, 1, 0, 4,-15, -8, 3, 16,
- 17, 8, -4, -6, 9, -4,-13, -8, 2, 6, 1,-18, -1, 11, 11,-12,
- 6, 0, 2, 0, 14, 6, -7,-21, 1, -1,-13,-20, 1, 1, 10, 21,
- -22, -5, 7, 13,-11, -1, 4, 12, -7, 0, 14, 19, -4, 3, -5,-19,
- -26,-14, 10, 15, 18, 4, -6, -2, 25, 19, -5,-18,-20, -7, 4, 2,
- -13, -6, -1, -4, 25, 37, -2,-35, 5, 4, 1, 1,-21,-36, 2, 43,
- 2, -2, -1, 3, 8, -2, -6, -1, -2, -3, 2, 12, -5, -2, -2, -1,
- -3, -1, -1, -5, -1, 7, 8, -2, 2, 7, 5, -3, 1, 1, -3, -8,
- -3, -1, -3, -2, -2, -3, 2, 13, 15, 0,-11, -6, 3, 0, 0, 0,
- -6, -9, -5, -4, 18, 4, 1, 3, 12, 3, 0, 4,-16, -3, 3, -3,
- -17, 3, 18, 2, -1, -3, -1, -1, -6, 16, -8, 0, -9, 14, -7, 0,
- 3,-13, 14, -5, 3,-13, 14, -4, -7, 20, 14,-23, 8, -7, -8, 4,
- 8,-15,-19, 16,-10, 13, 11, -3, 9, -1, 1, 26, 5,-15,-27, 2,
- -20, 7, 16, -4,-40, 9, 31, 1, 26,-12,-30, -7, 40, -2,-19, 4,
- 6, 0, 0, 0, -6, -2, 1, 2, 0, -1, 0, -6, 9, 0, -2, -1,
- -7, 8, 2, -3, -1, 2, -3, 2, 7, -4, -2, 4, 2, 0, 0, -6,
- -3, -2, 9, 2, -2, -1, 0, -4, -3, -3, 0, -3, -6, 2, 10, 4,
- 3, 0,-10, 8, 0, 0, -4, 4, -1, 1, 4, 2, 3, -7, -9, 7,
- 2, 1, -9, -4, -1, 12, 0, 0, 3, -1, 7, -4, 3,-14, 4, 2,
- -12, -9, 1, 11, 2, 5, 1, 0, 3, 1, 0, 2, 0, 8, 6,-19,
- -6,-10, -7, -4, 9, 7, 5, 7, 6, 21, 3, -3,-11, -9, -5, -2,
- -4, -9,-16, -1, -2, -5, 1, 36, 8, 11, 19, 0, 2, 5, -4,-41,
- -1, -1, -2, -1, -2, -2, 1, 6, 0, 4, 1, -8, 1, 1, 1, 0,
- -2, -3, 4, 0, 2, -1, 3, -3, 1, 3, -4, 1, -1, 3, 0, -5,
- 3, 4, 2, 3, -2, -3, -6, -1, -2, -3, -2, 2, -4, 8, 1, 0,
- -7, 4, 2, 6, -7, -1, 1, 0, -2, 2, -4, 1, 8, -6, 2, -1,
- -6, 2, 0, 2, 5, 4, -8, -1, -1,-11, 0, 9, 0, -2, 2, 2,
- 17, -5, -4, -1, -1, -4, -2, -2, 0,-13, 9, -3, -1, 12, -7, 2,
- 0, -2, -5, 2, -7, -5, 20, -3, 7, 7, -1,-30, 3, 5, 8, 1,
- -6, 3, -1, -4, 2, -2,-11, 18, 0, -7, 3, 14, 20, -3,-18, -9,
- 7, -2, 0, -1, -2, 0, 0, -1, -4, -1, 1, 0, -2, 2, 0, 4,
- 1, -3, 2, 1, 3, 1, -5, 1, -3, 0, -1, -2, 7, 1, 0, -3,
- 2, 5, 0, -2, 2, -5, -1, 1, -1, -2, 4, -1, 0, -3, 5, 0,
- 0, 3, -1, -2, -4, 1, 5, -1, -1, 0, -1, 9, -1, -2, -1, -1,
- -2, 5, 5, -1, -2, 2, -3, -2, 1, 2,-11, 1, 2, 1, 3, 2,
- 2,-10, -1, -2, 4, 2, 4, 1, 4, 5, -5, 1, 0, 6,-11, 1,
- 1, 0, 6, 6, 0, 2, 1,-15, 7, 3, 5, 9,-30, 2, 2, 2,
- -34, 1, 9, 2, 5, 8, 8, 2, 7, 2, 6, 6, 2,-27, 1, 4
-};
-
-/* 6x16-entry codebook for inter-coded 4x4 vectors */
-DECLARE_ALIGNED(4, static const int8_t, svq1_inter_codebook_4x4)[1536] = {
- 4, 0, -6, -7, -4, -8,-13, -9, -8, -8, -1, 6, -2, 5, 22, 27,
- -16, -7, 11, 10,-18, -7, 13, 10,-15, -4, 12, 8, -9, -1, 9, 5,
- -2, 2, 15,-16, -3, 2, 19,-19, -3, 2, 19,-19, -2, 3, 15,-14,
- 17, 22, 22, 16, -6, -7, -5, -2,-12,-16,-16,-12, 1, 1, -1, -3,
- 11,-17, 0, 8, 14,-21, -1, 9, 14,-21, -2, 8, 11,-16, -2, 6,
- 7, -2,-16, 11, 9, -2,-21, 14, 10, -1,-22, 14, 8, -1,-18, 10,
- -10, 16, 3, -9,-13, 20, 4,-11,-14, 21, 4,-10,-11, 16, 3, -8,
- 11, 4, -9, -9, 15, 6,-12,-14, 17, 8,-12,-14, 16, 10, -7,-11,
- 4, 10, 14, 13, -1, 7, 15, 16,-12, -7, 3, 8,-20,-23,-18,-10,
- -10,-18,-26,-25, 4, 1, -6,-11, 13, 15, 11, 3, 12, 15, 13, 8,
- -16,-19,-16,-11, 7, 12, 15, 11, 11, 16, 16, 11, -6, -9,-11,-10,
- 18, 19, 12, 5, 18, 16, 5, -4, 6, 0,-10,-15, -9,-17,-23,-22,
- -10,-14, -1, 21,-11,-17, 0, 29,-11,-16, 1, 30,-10,-14, 0, 23,
- -16,-17,-12, -6,-19,-19,-14, -7, -3, -1, 1, 2, 27, 35, 29, 19,
- -37, -8, 23, 23,-42, -9, 28, 29,-43,-10, 26, 28,-38,-11, 19, 22,
- 32, 16,-16,-33, 39, 20,-18,-37, 38, 19,-19,-38, 32, 15,-17,-34,
- 24, 9, -6, -4, -1,-10, -6, 3, -8, -9, -1, 3, 3, 7, 2, -6,
- -1, -3, -1, 0, -1, 4, 2, -7, -3, 11, 3,-16, 1, 20, 9,-18,
- -3, -8, 6, 12, -5,-10, 7, 13, -6, -9, 5, 7, -5, -5, 2, -1,
- -8, 12, -3, -1,-10, 15, -3, 1,-11, 13, -4, 1,-11, 8, -3, 2,
- 9, 6, -5,-12, 3, 0, -8,-13, -4, -4, -1, -1, -4, 1, 15, 18,
- 9, 13, 14, 12, 4, 3, -1, -2, -2, -5, -8, -5, -7,-11, -9, -4,
- 7, -5, -7, -4, 14, -2, -7, -4, 17, 0, -8, -5, 15, 1, -7, -5,
- -10, -1, 6, 4,-15, -9, 2, 4, 2, -1, -3, 0, 25, 13, -8,-10,
- 7, 11, -3,-16, 7, 11, -3,-15, 6, 7, -2, -9, 4, 2, -3, -5,
- -7, -1, -1, 0, -9, -2, 2, 6,-12, -4, 6, 14,-13, -6, 8, 19,
- -18,-18,-11, -5, -3, 0, 3, 4, 6, 8, 6, 6, 6, 6, 6, 6,
- -5, 3, 13,-10, -6, 1, 15, -9, -6, -3, 15, -6, -6, -6, 10, -3,
- 9, 1, -9, -9, 11, 9, 6, 5, 0, 3, 8, 7,-15,-14, -6, -5,
- -11, -6, 11, 19, -2, -5, -9, -8, 6, 2, -9,-10, 6, 5, 4, 5,
- -7, -3, 8, 15, -1, 3, 10, 15, 5, 5, -1, -2, 4, -2,-21,-25,
- 6, -6, -6, 5, 8, -9, -7, 9, 8,-12, -7, 13, 4,-14, -7, 14,
- -4, -3, 1, 1, -3, -5, -2, -3, 7, 0, -2, -4, 20, 7, -4, -4,
- -3,-20, -6, 10, 6, 0, 0, 1, 5, 8, 5, -1, -3, 0, 0, -2,
- 13, 6, -1, 2, 5, 3, 2, 3, -3, 0, 3, 0,-16, -8, -2, -5,
- -2, -7, -6, 0, -3, -6, -3, 1, -5, -1, 2, -1, -1, 12, 16, 5,
- -7, 1, 9, 8,-10, -2, 5, 3, -6, 2, 7, 3, -4, 0, -1, -7,
- 3, 4, -9,-24, 0, 2, 6, 3, -1, -1, 4, 7, 5, 3, -1, -2,
- 3, 6, -9, 2, 1, 6,-13, 1, 1, 8,-10, 2, 1, 8, -7, 1,
- -3, -3, 2, 22, -2, -3, -5, 12, -2, -3,-10, 2, -3, -1, -4, 2,
- 11, 12, 8, 2, -5, -5, -5, -8, -6, -4, 0, -3, -2, -1, 3, 3,
- 12, -6, -2, -1, 12, -8, -2, -2, 9, -7, 0, -3, 4, -6, 2, -2,
- -19, 1, 12, -3, -4, 4, 5, -4, 6, 1, -2, -1, 4, -4, -2, 7,
- -3, -4, -7, -8, -4, -4, -2, 0, -1, 2, 14, 16, -4, -2, 4, 4,
- -1, 7, 2, -5, -2, 0, -1, 1, 4, -3, -1, 13, 6,-12,-14, 8,
- -1, 5, 4, -5, -2, 5, 3, -9, -2, 7, 4,-12, -1, 7, 4, -9,
- -6, -3, 1, 1, 11, 11, 0, -6, 6, 4, -2, -7,-12,-10, 3, 10,
- -2, -3, -3, -2, 6, 11, 14, 10, -9,-11,-10,-10, 2, 2, 3, 2,
- -7, -5, -7, -1, -1, 2, 0, 7, -1, 1, 0, 9, 3, 4, -5, -1,
- 10, -1,-15, -1, 4, 1, -5, 2, -3, 1, -1, 1, -3, 1, 4, 4,
- 2, -1, 4, 10, 6, 2, -1, 0, 2, 2, -7,-12, -4, 2, 0, -3,
- -1, -4, -1, -8, 3, -1, 2, -9, 4, 0, 5, -5, 2, 0, 8, 3,
- 3, 2, 1, 1, 4, -2, 0, 3, 2, -1, 4, 1, 0, 6, -1,-25,
- -1, -2, -2, -4, -3, 0, -1, -4, -1, -1, -4, 2, 0, -6, 2, 25,
- -11, -1, 5, 0, 7, 0, -2, 2, 10, -1, -3, 4, -5, -5, -2, -1,
- 0, 6, 3, -1, -2, -1, -1, 1, -1, -7,-12, -5, 8, 6, 2, 4,
- 2, 6, -1, -6, 9, 10, -1, -4, 1, 0, -4, 0, 3, -2, -9, -5,
- -4, 3, 4, 0, -4, 3, 3, 0,-11, 0, 3, 2,-11, 3, 7, 2,
- 2, -4, 7, 3, 1, -8, 7, 1, -1,-12, 4, 1, 3, -9, 2, 2,
- 2, -2, -2, 9,-17, -3, 3, 1, -4, 7, 1, -6, 5, 4, -1, 3,
- -1, 2, 0, -4, -7, 8, 12, -1, -2, 5, 4, -5, 3, -5, -8, -2,
- 0, 0, -5, -2, -2, -8, 3, 27, -1, -4, -3, 6, -3, 1, -2, -7,
- 4, 4, 1, -1, -7,-10, -7, -3, 10, 10, 5, 3, -2, -2, -4, -3,
- 0, 1, 5, 7, 4, -2,-16,-20, 0, 4, 7, 8, 2, 0, -2, -1,
- -2, 1, 3, 17, -3, 1, -2, -1, -1, -2, -1, -2, -1, -5, -1, 0,
- 5, -3, 1, 0, 6, -2, 0, 0, -1, -2, 0, -3,-11, 1, 8, -1,
- 3, 0, 0, 0, 0, 2, 4, 1, 2, 0, 6, 1, -2,-18, -3, 2,
- -14, 0, 6, 1, -5, -2, -1, 1, -1, 1, 0, 1, 1, 7, 4, 0,
- -1, 0, 1, -4, 1, 8, 3, -4, -3, 4, 1, 3, -6, 1, -4, 1,
- 1,-12, 3, 3, -1,-10, 0, -1, 2, 0, 2, 1, 3, 2, 2, 4,
- 3, 0, 0, 3, 2, 0, -2, 1, 5, 2, -5, 0, 6, -1,-14, -1,
- -2, -6, -3, -3, 2, -1, 4, 5, 6, -1, -2, 0, 4, 4, -1, -5,
- -4, 1,-11, 0, -1, 2, -4, 1, 2, -3, 3, -1, 1, -2, 15, 0,
- 1, -1, 0, -2, 1, -4, -7, 1, -2, -6, -1, 21, -2, 2, -1, 1,
- 21, -1, -2, 0, -1, -3, 1, -2, -9, -2, 2, -1, 2, 1, -4, -1,
- 1, 8, 2, -6,-10, -1, 4, 0, -4, -3, 3, 3, 5, 0, -1, -1,
- 3, 2, 1, -2, -2, -2, 4, 3, 5, 2, -4,-17, 0, -2, 4, 3,
- -7, -4, 0, 3, 9, 9, 2, -1,-11, -6, 0, -1, 5, 1, 0, 1,
- 0, 17, 5,-11, 3, -2, -6, 0, 2, -2, -4, 1, -4, 1, 2, -1,
- -5, -1, -5, -3, -3, 5, -3, -2, 4, 16, 2, -5, -2, 5, -1, -1,
- 0, 0, -4, 1, -1, 2, 5, 11, -1, -1, -2, 1, -4, -2, -3, -1,
- -5, -1, 10, 0, 6, 1, 0, -3, 0, -4, 1, 0, -2, -4, 3, -1,
- 6, 9, 3, 0, -2, 1, -2, 0, -2, -3, -2, -2, 1, 0, 1, -6,
- 1, 0, 2, 1, -1, 3, -2, 1, 0, -1,-15, 0, -1, 5, 2, 6,
- 2, 0, 2, 2, 0,-12, -4, 6, 0, 1, 4, -1, 1, 2, 1, -4,
- 1, -2, -7, 0, 0, 0, 0, -1, -5, 2, 11, 3, 1, 3, 0, -6,
- 0, -3, -9, -4, 1, 3, -1, 0, 4, 1, -2, 0, 7, -3, -1, 6,
- 1, -2, 6, 2, 0, -1, 3, -2, -2, 4, 0, 2, -1, 2,-14, 2,
- 2, 2, 0, -1, -2, 3, -3,-14, 0, 2, 3, -3, 5, 1, 3, 2,
- 1, -3, 4,-14, 1, -2, 11, -1, 0, -1, 3, 0, -1, 1, 0, 2,
- -2, 3, -3, 2, -4, -1, -4, 3, -1, 2, 1, 3, -6, -2, 2, 7,
- -2, 1, 2, 0, -2, 0, 0, -1, 12, 5, -1, 2, -8, -1, 1, -7,
- 2, -2, -4, 2, 11, 0,-11, -2, 3, 1, -3, -1, 0, 3, 1, -1,
- 0, 3, 0, -2, 0, -6, -1, -3, 12, -7, -2, 0, 7, -2, 1, 1,
- 1, 2, 2, 2, -1, 2, 0, 2,-23, 0, 4, 0, 3, 2, 1, 3,
- -4, -5, -1, 5, -3, 5, 10, -1, 0, 0, 3, -4, 1, -1, 2, -5
-};
-
-/* 6x16-entry codebook for inter-coded 8x4 vectors */
-DECLARE_ALIGNED(4, static const int8_t, svq1_inter_codebook_8x4)[3072] = {
- 9, 8, 4, 0, -3, -4, -4, -3, 9, 8, 4, -1, -4, -5, -5, -3,
- 8, 7, 3, -2, -5, -5, -5, -4, 6, 4, 1, -2, -4, -5, -4, -3,
- -12,-14,-11, -4, 1, 5, 6, 6, -8,-10, -7, -5, -2, 1, 1, 1,
- 5, 4, 3, 1, 0, 0, -1, -1, 13, 13, 9, 6, 3, 0, -1, -2,
- -4, -4, -3, -1, 1, 4, 8, 11, -5, -6, -4, -2, 0, 3, 8, 12,
- -7, -7, -6, -4, -2, 2, 7, 10, -7, -7, -5, -4, -2, 1, 5, 8,
- -3, -2, -1, 1, 3, 6, 7, 6, 2, 3, 5, 7, 8, 8, 6, 4,
- 4, 5, 4, 3, 1, -2, -6, -7, 1, 0, -2, -7,-10,-14,-17,-16,
- -5, -4, 1, 8, 9, 3, -3, -7, -7, -6, 1, 11, 12, 5, -3, -8,
- -8, -7, 0, 9, 11, 5, -3, -7, -8, -6, -1, 5, 8, 4, -2, -6,
- -4, -5, -7, -8, -9, -9, -8, -6, -4, -5, -6, -7, -7, -6, -4, -2,
- 0, 1, 2, 3, 5, 8, 10, 9, 1, 2, 3, 6, 9, 12, 14, 13,
- 5, 6, 6, 5, 4, 3, 2, 1, 5, 6, 7, 7, 6, 6, 6, 4,
- -1, 0, 1, 1, 3, 5, 5, 5,-13,-16,-17,-17,-14,-10, -6, -4,
- 9, 11, 13, 16, 15, 13, 12, 10, -4, -5, -6, -7, -7, -7, -6, -5,
- -6, -6, -7, -7, -7, -7, -6, -5, -2, -1, 0, 0, 0, 0, 0, -1,
- -11,-13,-15,-16,-16,-14,-12,-10, 2, 3, 4, 5, 4, 3, 3, 3,
- 6, 7, 8, 8, 8, 7, 6, 5, 3, 4, 3, 3, 3, 3, 3, 3,
- 3, 4, 4, 1, -2, -7,-13,-17, 5, 7, 7, 5, 1, -5,-13,-19,
- 6, 8, 9, 8, 5, -1, -9,-16, 6, 8, 10, 10, 7, 2, -4,-11,
- 18, 9, -1,-10,-13, -9, -4, 0, 22, 12, -1,-12,-15,-10, -4, 2,
- 23, 13, 0,-10,-13, -9, -3, 2, 20, 12, 2, -6, -9, -6, -2, 2,
- -6, -6, -6, -7, -7, -7, -7, -6, -6, -7, -8, -8, -9, -9, -9, -8,
- -3, -3, -3, -3, -3, -3, -3, -3, 12, 15, 18, 21, 21, 19, 17, 14,
- 14, 16, 18, 18, 18, 16, 15, 13, 5, 6, 6, 5, 5, 4, 4, 3,
- -6, -7, -9,-10,-10,-10, -9, -7,-10,-11,-13,-14,-14,-13,-12,-10,
- -27,-17, -4, 5, 9, 10, 10, 7,-32,-19, -3, 7, 11, 12, 11, 8,
- -30,-16, -2, 8, 12, 12, 10, 7,-23,-12, 0, 7, 10, 11, 9, 6,
- 16, 17, 16, 12, 6, -1, -8,-12, 17, 18, 15, 10, 1, -8,-15,-18,
- 15, 14, 10, 4, -5,-14,-20,-23, 10, 8, 4, -1, -9,-16,-21,-22,
- -10,-12,-12,-11, -5, 4, 14, 20,-11,-13,-15,-12, -4, 7, 19, 27,
- -11,-13,-14,-11, -3, 8, 21, 28,-10,-11,-12, -9, -2, 8, 18, 25,
- -1, -1, -1, 1, 4, 6, 6, 5, 0, 0, 0, 2, 4, 3, 1, -2,
- 0, 0, 2, 4, 4, -1, -7,-10, 0, 0, 3, 5, 3, -3,-11,-15,
- -14,-13, -8, -1, 3, 3, -1, -4, -5, -4, -1, 4, 8, 8, 3, 0,
- 3, 2, 2, 3, 4, 5, 3, 1, 5, 3, 0, -2, -2, -1, -1, -1,
- 9, 1, -6, -6, -5, -3, -2, -1, 12, 1, -6, -6, -4, -2, -1, 0,
- 14, 4, -4, -4, -2, -2, -1, -1, 14, 6, -1, -1, -1, -1, -1, -1,
- 4, 6, 8, 10, 11, 9, 7, 5, -1, -1, -1, 0, 0, -1, -1, -2,
- -2, -4, -4, -5, -5, -5, -5, -4, -2, -3, -3, -4, -4, -3, -2, -1,
- 2, 3, 4, 4, 3, 1, 0, 0, -1, 1, 4, 5, 6, 5, 4, 3,
- -8, -6, -2, 2, 3, 4, 4, 3,-14,-13, -9, -5, -2, -1, 0, 0,
- -3, -4, -5, -4, 0, 7, 12, 13, -3, -4, -5, -5, -2, 4, 9, 10,
- -2, -3, -4, -5, -4, -1, 3, 4, -1, -1, -2, -3, -3, -2, 0, 1,
- 9, 5, -2, -8,-11,-10, -7, -4, 12, 10, 6, 2, 0, -1, 0, 0,
- 2, 2, 3, 4, 3, 1, 1, 1, -9, -8, -4, 0, 1, 2, 1, 0,
- 6, 8, 8, 5, 1, -5,-11,-13, 0, 1, 2, 2, -1, -4, -8,-11,
- -3, -2, 1, 3, 3, 1, -1, -4, -2, -1, 2, 5, 6, 6, 4, 1,
- 3, 4, 5, 5, 4, 1, -3, -6, 5, 6, 4, 2, 2, 2, 0, -3,
- 6, 5, 0, -5, -5, -2, -1, -2, 7, 4, -3,-11,-12, -7, -3, -2,
- 1, 0, -1, -1, -1, 0, 0, 0, 2, 3, 4, 4, 5, 5, 4, 3,
- -7, -9, -9,-10,-10, -9, -7, -6, 3, 4, 5, 6, 5, 5, 5, 5,
- -7, -7, -7, -7, -6, -6, -5, -4, -5, -4, -3, -1, -1, -1, 0, 0,
- -3, -2, 1, 4, 5, 5, 5, 5, -2, -1, 3, 6, 9, 10, 10, 9,
- -14, 1, 10, 3, -2, 0, 1, 1,-16, 2, 13, 3, -3, -1, 1, 0,
- -15, 2, 12, 3, -4, -2, 1, 1,-10, 3, 10, 2, -3, -1, 1, 1,
- 0, 1, 4, 2, -5,-10, -3, 11, -1, 1, 4, 2, -6,-13, -2, 15,
- -1, 0, 3, 1, -6,-12, -1, 15, -1, 1, 2, 1, -4, -8, 0, 11,
- 10, 5, -2, -2, 2, 5, 1, -4, 7, 0, -8, -6, 1, 5, 2, -4,
- 2, -5,-12, -7, 2, 7, 4, -1, -1, -7,-10, -4, 4, 9, 7, 2,
- -5, -5, -4, -6, -6, -5, -5, -3, -1, -2, -2, -4, -5, -6, -5, -4,
- 6, 7, 7, 4, 0, -2, -3, -3, 13, 14, 13, 10, 5, 1, -1, -2,
- 1, 1, 2, 2, 2, 2, 2, 2, -5, -6, -8, -9, -9, -8, -7, -6,
- 7, 9, 10, 11, 11, 9, 7, 5, -1, -2, -3, -3, -4, -4, -4, -3,
- -1, -1, 0, 0, 0, 0, -1, -1, -3, -3, -4, -5, -4, -3, -3, -2,
- 2, 1, -1, -3, -3, -2, -1, 0, 12, 12, 8, 3, 1, 0, 0, 1,
- -6, -8, -8, -6, -2, 2, 6, 8, 1, 1, -1, -2, 0, 3, 5, 7,
- 3, 3, 1, -1, -1, 0, 0, 2, 0, 1, 0, -1, -1, -1, -2, -1,
- 1, 0, 0, 0, 0, 0, 2, 4, 2, 1, 3, 4, 3, 1, 0, 2,
- 2, 1, 0, 0, -1, -1, 0, 3, 5, 1, -6,-12,-13, -8, -1, 4,
- -2, 0, -1, -2, -1, 0, 2, 3, -6, -3, -2, 0, 1, 1, 1, 1,
- -9, -5, 0, 4, 5, 3, 1, 0, -8, -3, 3, 7, 8, 4, 1, 0,
- 1, 2, 2, 3, 3, 1, -1, -3, 4, 5, 5, 6, 6, 5, 2, 0,
- 0, 0, 0, 0, 1, 0, -2, -4, -3, -3, -4, -3, -3, -4, -7, -8,
- 14, 12, 6, -1, -3, -3, 0, 0, 7, 5, 1, -3, -5, -4, -2, -1,
- -2, -2, -2, -2, -2, -2, -1, -1, -6, -4, -1, 1, 1, 1, 0, -1,
- 2, 2, 1, -3, -6, -7, -6, -3, 1, 0, -1, -3, -2, 1, 4, 6,
- 0, 0, 1, 2, 4, 7, 8, 7, 0, 0, 0, 0, -1, -4, -7, -8,
- 0, 2, 1, -2, -3, -3, -2, -1, -1, 1, 0, -3, -5, -2, 0, 2,
- -2, -1, -2, -5, -4, 1, 6, 9, -3, -2, -3, -4, -2, 5, 11, 13,
- -4, -2, 2, 6, 4, -3,-10,-14, -2, -1, 1, 4, 4, 1, -1, -2,
- 0, 0, -1, -2, -2, 0, 4, 6, 2, 2, 0, -3, -3, 0, 5, 9,
- -4, -4, -2, 1, 6, 9, 3, -7, -2, -2, -2, -1, 4, 8, 0,-11,
- 1, 1, 0, 0, 2, 6, -1,-10, 2, 2, 1, 0, 2, 4, 0, -7,
- -1, -2, -3, -6, -7, -8, -8, -8, 2, 3, 3, 1, -1, -2, -3, -4,
- 5, 5, 5, 4, 3, 2, 0, -1, 3, 3, 3, 3, 2, 2, 1, 1,
- 3, 3, 2, -2, -3, 0, 7, 10, 1, 2, 2, -2, -5, -4, 0, 3,
- 0, 3, 4, 2, -3, -5, -6, -4, 0, 2, 4, 4, 1, -4, -7, -7,
- 2, 4, 5, 5, 5, 5, 6, 6, -4, -4, -3, -5, -5, -3, -3, -2,
- -3, -4, -4, -5, -4, -2, -2, -2, 1, 1, 0, 0, 2, 4, 5, 4,
- -2, 0, 3, 4, 4, 3, 2, 2, -9, -7, -4, 0, 3, 6, 6, 6,
- -5, -5, -3, -2, 0, 1, 3, 4, 5, 5, 2, -2, -4, -6, -5, -3,
- 1, -6, -4, 7, 5, -2, -2, 1, 5, -5, -4, 6, 4, -5, -4, 1,
- 5, -5, -4, 6, 4, -5, -3, 1, 1, -7, -3, 8, 7, -1, -3, 1,
- -8, -7, -4, 0, 2, 4, 5, 5, 5, 6, 5, 2, -1, -5, -7, -7,
- 5, 6, 4, 1, -3, -5, -6, -5, -7, -7, -5, -2, 1, 6, 9, 10,
- 6, 3, 0, 1, 3, 0, -8,-14, 3, 0, -1, 1, 4, 3, 0, -4,
- 1, 0, 0, 1, 2, 1, 1, 1, -1, -1, 1, 2, 1, -1, -1, 0,
- 1, 1, 1, 1, 0, -2, -3, 0, 1, 2, 1, 0, -2, -8, -9, -4,
- 1, 3, 3, 2, 1, -3, -3, 1, 0, 1, 1, 1, 1, 1, 4, 8,
- 2, 5, 9, 7, 2, -1, -1, 1, -4, -1, 1, 0, -3, -4, -1, 2,
- -3, 0, 3, 3, 0, -1, 0, 2, -4, -1, 1, 1, -2, -4, -5, -4,
- 1, -1, -2, -2, -1, 2, 4, 5, 2, 1, 1, 0, -1, -1, 0, 0,
- 2, 3, 4, 5, 4, 2, 1, 0, -9, -9, -6, -3, -1, -1, -1, -1,
- -6, -6, 4, 7, 0, -2, -1, -2, -1, -2, 5, 6, -1, -2, 0, -1,
- 4, -1, 1, 0, -4, -2, 0, -2, 7, 1, -1, -2, -3, 1, 3, 1,
- 4, 2, 1, 3, 3, 1, 1, 2, 2, -2, -4, 0, 3, 1, 0, 0,
- 1, -4, -8, -4, 1, 2, 1, 0, 2, -3, -9, -6, 0, 3, 3, 2,
- -1, -1, 0, -1, -1, 0, 1, 2, 3, 1, -4, -8, -7, -3, 1, 2,
- 2, -1, -3, -2, -1, 0, 1, 0, -1, 0, 5, 11, 9, 3, -1, -3,
- -1, -2, -2, -1, 1, 1, 1, 1, 0, -1, 0, 3, 6, 6, 5, 5,
- 2, 1, -1, -1, -2, -5, -6, -4, 2, 2, 2, 1, -1, -4, -5, -5,
- -1, -3, -6, -7, -6, -4, -1, 1, 5, 5, 3, 4, 4, 3, 4, 5,
- -1, -2, -3, -2, -2, -2, 0, 1, 0, 0, 0, 0, 0, 1, 2, 3,
- -6, -6, -4, -1, 2, 2, 2, 2, -6, -7, -5, -2, 0, -1, -1, 0,
- 2, 2, 2, 4, 4, 3, 3, 4, 2, 1, 0, -1, 0, 0, 2, 4,
- 12, 5, -5, -8, -5, 0, 2, 2, 2, -3, -6, -3, 0, 0, -1, -2,
- -2, -3, -1, 3, 4, 1, -2, -3, 2, 2, 3, 4, 3, 1, -1, -1,
- 3, 2, 1, 0, 1, 4, 3, 0, 4, 3, 0, -5, -6, 0, 3, 3,
- 2, 3, 1, -7,-12, -6, 1, 3, 1, 3, 4, -1, -6, -4, 0, 1,
- -9, -4, 2, 6, 7, 4, 1, 0, -7, -1, 4, 6, 4, 0, -3, -3,
- -6, 0, 4, 4, 1, -2, -3, -2, -4, 1, 3, 2, 0, -2, -1, 0,
- 0, 5, 2, -5, -3, 3, 1, -4, -2, 4, 2, -6, -3, 6, 4, -3,
- -1, 5, 3, -5, -1, 7, 3, -4, -1, 2, 0, -6, -3, 5, 3, -3,
- -8, -3, 3, 5, 3, 1, -2, -2, 2, 4, 4, -2, -4, -3, 1, 3,
- 2, 1, -3, -5, -3, 3, 4, 3, -5, -6, -5, 3, 10, 8, -1, -5,
- 0, 3, 2, -4, -9, -7, 0, 6, -5, -1, 5, 7, 4, -1, -3, -3,
- -5, -5, -2, 3, 6, 5, -1, -4, 9, 6, 0, -4, -2, 1, 1, -1,
- -1, -1, -1, 1, 1, 0, -1, 0, -1, 0, 0, 0, 0, -1, -1, 0,
- 2, 1, -2, -1, 1, 1, 0, 0, 12, 8, 2, -1, -1, -4, -7, -7,
- 2, 1, 3, 6, 7, 4, 2, 0, 1, 0, -1, 0, -1, -4, -7, -8,
- 0, 0, -1, 0, 0, 0, -1, -3, 0, 0, 0, 0, 1, 1, 0, -2,
- -1, 0, 1, 1, 0, 0, -1, -2, 0, 0, -1, -3, -4, -3, -1, 1,
- -1, 0, 0, 0, 1, 4, 10, 12, -1, 0, -2, -2, -3, -3, -1, 1,
- -3, -1, -2, -4, 2, 9, 9, 7, -3, 0, -1, -3, 0, 2, -1, 1,
- -1, 1, -2, -3, 0, -1, -3, 0, 0, 0, -3, -2, 0, -1, -1, 1,
- -1, -2, -1, -1, -2, -1, -1, -2, 2, -1, -2, -1, 0, 1, 0, -2,
- 3, -1, -2, 2, 5, 3, -1, -3, 1, -5, -5, 1, 6, 6, 2, 0,
- 1, 2, 0, -1, 0, 1, 0, -2, -5, -3, -1, 0, 1, 2, 1, -2,
- -7, -5, -2, -2, -2, -2, 0, 1, -1, 0, 1, 1, 0, 3, 9, 12,
- 0, 6, 5, 1, -2, -3, 0, 3, 0, 6, 5, 1, 1, 1, 2, 3,
- -5, -2, -2, -3, 0, 0, 0, 0, -6, -3, -3, -2, 0, 0, -1, -2,
- 4, 4, 2, 1, 0, -1, -1, 0, -2, -2, 0, 1, 2, 1, 1, 0,
- 2, 2, 1, -1, -3, -5, -9,-10, 2, 1, -1, -1, 1, 4, 4, 1,
- 4, 0, -2, -2, -2, -2, -1, 0, 7, 1, -4, -3, -2, 0, 1, 1,
- 10, 5, -1, -2, 0, 1, 1, 0, 5, 1, -3, -4, -3, -1, -1, -2,
- 2, 1, -1, -3, -3, 1, 1, -1, -2, -1, 3, 0, -1, 1, 1, 0,
- -3, 1, 7, 2, -3, -2, -1, 0, -2, 4, 8, -1, -8, -5, 0, 2,
- -4, -1, 1, 2, 1, -3, -4, -2, -5, -3, -2, 1, 4, 4, 4, 6,
- -3, -2, -4, -3, 0, 1, 1, 2, 2, 2, 2, 1, 2, 1, -1, -1,
- -4, -1, 0, -1, -3, -3, -1, -1, 1, 4, 4, 2, 0, -1, -2, -3,
- 4, 6, 5, 3, 2, 1, -2, -4, 0, 1, 1, 1, 1, -1, -4, -6,
- 1, 2, 2, -1, -6, -5, -1, 2, -3, -2, 1, 1, -4, -3, 2, 5,
- -2, -1, 2, 2, -3, -4, 0, 3, -2, -2, 2, 6, 5, 2, 1, 2,
- 2, -3, -3, 0, 0, 2, 3, 1, 3, -1, 1, 3, 1, 2, -1, -5,
- -5, -7, -4, -2, 1, 8, 8, 1, -1, 0, 2, 0, -3, 0, 1, -3,
- -2, -5, -5, -2, -3, -1, 0, -2, -1, -4, 0, 4, 0, 2, 4, 0,
- 0, 0, 8, 10, 2, 1, 3, -1, -4, -3, 2, 3, -3, -3, 1, -1,
- 1, -2, -4, 2, 7, 3, -2, -1, 6, 4, -2, -1, 2, 0, -1, 3,
- 1, 1, -2, -2, -2, -5, -3, 4, -6, -2, 1, 1, -1, -4, -2, 4,
- -2, -1, -2, -2, 0, 1, 0, -2, -1, 1, 0, -1, 0, 0, -1, -3,
- 0, 1, -2, -4, -3, -1, 0, 0, 6, 8, 5, 0, 0, 1, 2, 3,
- -2, -2, 2, 5, 2, 0, 0, 1, 2, -2, -2, -1, -1, 1, 2, 4,
- 2, -1, 0, 1, 0, 0, 0, 1, -8, -7, -1, 1, -1, -1, 1, 3,
- 0, 3, 6, 2, -2, 1, 2, 0,-10, -7, -1, 0, -3, -1, 2, 1,
- 0, 0, 2, 2, 1, 1, 1, -1, 3, 0, -2, -2, 0, 2, 1, 0,
- 8, 1, 0, 0, -2, -3, -1, 0, 2, -2, 2, 5, 1, -2, -1, 1,
- -3, -6, -3, -1, -3, -3, -1, 2, 2, 0, 1, 2, 2, 1, 0, 0,
- 1, -1, -1, -2, -1, 0, 1, 0, 15, 9, 2, -1, -2, -3, -3, -3,
- 0, -3, -2, 0, 0, -1, -1, -1, 1, 0, 1, 0, 0, -1, -1, -1,
- 0, 2, 2, -2, -3, -3, -7, -8, 0, 2, 2, 0, 1, 2, 1, 1,
- 1, 2, 2, 2, 3, 1, 0, 3, 1, 0, -1, -2, -1, -2, 0, 5,
- -11, -6, -1, 1, 2, 3, 1, -3, 1, 4, 3, -1, -2, 1, 2, -1,
- 2, 2, 1, -1, -2, 0, 1, -1, 0, 0, -1, -1, 0, 2, 3, 2,
- 1, 1, 2, 1, -1, 1, 0, -4, 0, 0, 0, -2, -2, 2, 4, -2,
- -2, -3, 0, 0, -1, 2, 1, -6, 0, 2, 5, 5, 3, 2, -1, -7,
- 4, 2, 0, 0, 3, 3, 1, -1, 0, -1, -1, 3, 6, 4, 1, -1,
- -2, -2, 0, 2, 2, 0, -2, -2, -1, 0, -1, -5, -7, -5, -1, 1,
- 5, -1, -2, 0, 2, 4, 2, -5, 0, -5, -2, 2, 1, 2, 0, -6,
- 6, 1, 0, 1, -2, -1, 4, 2, 2, -3, -3, 0, -1, -2, 0, 0,
- 1, -1, 0, 2, 0, 0, 6, 11, 2, -1, -1, 0, -3, -2, 3, 5,
- 0, -2, -1, 0, -1, 0, 0, -3, 1, -1, -1, -1, -2, -1, -3, -7,
- 1, 1, -2, -2, 1, 3, 1, -2, -1, 2, 0, -1, -1, 1, 0, 0,
- -4, 2, 3, -1, -2, -2, 0, 1,-11, -2, 4, 5, 6, 2, -1, -2,
- -6, -2, 1, -1, -3, -4, 1, 9, -3, 0, 3, 3, 2, -3, -3, 3,
- 1, 1, 0, 0, 1, -1, -2, 3, 2, 0, -3, -3, 0, -1, -1, 3,
- 1, -1, -3, 1, 2, -6, -4, 6, 0, -2, -5, -2, 0, -3, -2, 3,
- 2, 2, 1, -2, -2, 1, 2, -1, -1, 1, 1, -2, -1, 6, 7, -1,
- 1, 0, -4, -2, 1, -2, -3, 1, -4, 0, -3, -2, 2, 0, -3, 0,
- -3, 4, 3, 1, 8, 7, 0, -1, -3, 4, 1, -4, 2, 3, -2, -3,
- -3, 6, 1, -4, 1, 1, -1, -1, -2, 4, -3, -3, 3, 0, -1, -1,
- 1, 2, -4, 2, 4, -3, -1, 2, 3, -1, -4, 5, 4, -6, -3, 2
-};
-
-/* 6x16-entry codebook for inter-coded 8x8 vectors */
-DECLARE_ALIGNED(4, static const int8_t, svq1_inter_codebook_8x8)[6144] = {
- -4, -3, 4, 5, 2, 1, 1, 0, -5, -3, 5, 5, 2, 1, 0, 0,
- -6, -4, 5, 5, 2, 1, 0, 0, -7, -4, 4, 5, 2, 1, 0, 0,
- -8, -5, 3, 4, 2, 1, 0, 0, -8, -6, 3, 4, 1, 1, 1, 0,
- -8, -6, 2, 4, 2, 1, 1, 0, -8, -6, 2, 4, 1, 1, 1, 1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2, -2, -2, -2, -2, -2,
- -2, -3, -3, -3, -3, -3, -3, -3, -2, -3, -3, -3, -3, -3, -4, -3,
- -2, -2, -2, -2, -2, -3, -3, -2, 1, 1, 1, 1, 1, 0, -1, -1,
- 4, 5, 5, 5, 4, 3, 3, 2, 7, 7, 8, 8, 8, 7, 6, 5,
- 2, 1, 2, 4, 4, 0, -4, -6, 1, 1, 2, 5, 5, 1, -5, -7,
- 1, 2, 1, 4, 5, 1, -5, -8, 1, 1, 1, 5, 5, 0, -6, -8,
- 0, 1, 1, 5, 6, 1, -6, -9, 0, 0, 1, 4, 5, 0, -5, -8,
- 0, 0, 1, 4, 5, 0, -5, -7, 0, 0, 1, 4, 4, 1, -4, -7,
- 1, 2, 3, 0, -3, -4, -3, -1, 1, 3, 4, 0, -3, -4, -3, -1,
- 2, 4, 5, 1, -3, -4, -3, -2, 2, 5, 6, 1, -3, -5, -4, -2,
- 3, 6, 6, 1, -3, -5, -4, -2, 3, 6, 6, 1, -3, -5, -4, -2,
- 3, 6, 6, 1, -3, -5, -4, -2, 3, 5, 5, 1, -3, -4, -4, -2,
- 2, 2, 2, 2, 1, 0, 0, -1, 4, 4, 4, 3, 2, 1, 1, 0,
- 4, 5, 4, 4, 3, 3, 2, 1, 4, 4, 4, 4, 4, 3, 2, 2,
- 2, 3, 3, 3, 3, 3, 2, 1, -1, -1, -1, -1, 0, 0, 0, 0,
- -5, -6, -6, -5, -5, -4, -3, -3, -7, -9, -9, -8, -7, -6, -6, -5,
- 6, 6, 6, 6, 6, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 2,
- 0, -1, -1, -1, -2, -2, -1, -1, -3, -5, -6, -6, -6, -6, -5, -4,
- -3, -5, -6, -7, -6, -6, -5, -4, -1, -2, -2, -2, -2, -2, -1, -1,
- 0, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3,
- 2, 1, -2, -5, -4, 0, 2, 5, 2, 1, -2, -6, -5, 0, 3, 5,
- 2, 1, -2, -6, -6, -1, 3, 6, 3, 2, -2, -7, -6, 0, 4, 7,
- 2, 1, -2, -7, -5, 0, 5, 7, 2, 1, -2, -6, -5, 0, 4, 7,
- 2, 1, -2, -6, -4, 0, 4, 6, 1, 1, -2, -5, -4, 0, 3, 6,
- -10, -9, -6, -4, -1, 2, 3, 2,-10, -9, -5, -3, 0, 4, 4, 3,
- -9, -7, -3, -1, 2, 5, 5, 3, -7, -5, -2, 0, 3, 5, 5, 3,
- -6, -3, 0, 1, 4, 6, 5, 3, -4, -2, 1, 2, 3, 5, 4, 2,
- -2, 0, 1, 2, 2, 4, 3, 1, -1, 1, 2, 2, 2, 3, 3, 1,
- -4, -5, -5, -6, -6, -6, -6, -5, -3, -3, -4, -4, -4, -4, -4, -4,
- 0, 0, 0, 0, -1, -1, -1, -1, 5, 5, 6, 5, 5, 4, 3, 2,
- 5, 6, 7, 7, 7, 6, 5, 4, 3, 3, 4, 4, 4, 4, 3, 2,
- 0, -1, 0, 0, -1, -1, 0, -1, -3, -3, -4, -4, -4, -4, -3, -3,
- 1, -2, -5, 1, 5, 4, 2, 0, 1, -3, -6, 1, 6, 5, 2, 0,
- 0, -4, -7, 0, 6, 6, 2, 1, -1, -5, -9, -1, 6, 6, 3, 1,
- -1, -6,-10, -2, 6, 6, 3, 1, -1, -6, -9, -2, 5, 6, 3, 1,
- -2, -6, -9, -2, 5, 5, 3, 1, -2, -6, -7, -2, 4, 4, 2, 1,
- -5, -7, -8, -9, -9, -8, -7, -6, -5, -6, -6, -7, -7, -6, -6, -5,
- -3, -3, -3, -4, -5, -5, -4, -4, -1, 0, 0, -1, -1, -1, -1, -1,
- 0, 1, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 5, 5, 5, 4,
- 3, 4, 5, 6, 8, 8, 8, 7, 3, 4, 5, 6, 7, 7, 7, 6,
- 5, 6, 7, 8, 9, 10, 10, 9, 3, 4, 6, 7, 8, 9, 9, 8,
- 0, 1, 2, 3, 4, 5, 5, 5, -1, -2, -1, -1, 0, 1, 2, 2,
- -2, -3, -3, -3, -3, -2, -1, 0, -3, -4, -5, -5, -5, -5, -5, -4,
- -4, -5, -5, -6, -7, -7, -6, -5, -3, -4, -5, -6, -7, -7, -6, -6,
- 13, 7, 0, -3, -3, -4, -4, -5, 14, 7, 0, -3, -3, -4, -4, -4,
- 15, 8, -1, -4, -4, -4, -5, -4, 15, 8, -1, -4, -4, -5, -4, -3,
- 15, 7, -1, -4, -5, -5, -5, -4, 14, 7, -1, -4, -4, -4, -4, -3,
- 12, 6, -1, -4, -4, -4, -4, -3, 11, 5, -1, -4, -4, -4, -4, -3,
- -17, -4, 5, 4, 4, 4, 3, 3,-18, -5, 5, 4, 4, 4, 3, 3,
- -19, -5, 6, 4, 4, 4, 3, 2,-20, -5, 6, 4, 4, 4, 3, 3,
- -20, -4, 6, 4, 4, 5, 3, 3,-19, -5, 6, 4, 4, 5, 3, 3,
- -18, -4, 5, 4, 4, 4, 3, 2,-17, -5, 4, 3, 4, 4, 3, 3,
- -6, -6, -6, -4, -2, 1, 6, 11, -6, -7, -7, -4, -2, 2, 8, 13,
- -8, -8, -7, -4, -2, 3, 9, 14, -8, -8, -7, -5, -1, 4, 10, 16,
- -8, -8, -7, -5, -1, 4, 10, 17, -8, -8, -7, -4, 0, 5, 10, 16,
- -8, -8, -6, -3, 0, 4, 9, 15, -7, -7, -5, -3, 0, 4, 8, 12,
- 8, 7, 7, 5, 2, -2, -8,-14, 8, 8, 7, 5, 2, -2, -8,-15,
- 8, 8, 7, 5, 1, -3, -9,-16, 8, 8, 7, 5, 1, -3,-10,-17,
- 8, 9, 8, 5, 1, -3,-10,-17, 8, 8, 7, 4, 1, -4,-10,-16,
- 7, 7, 7, 4, 1, -3, -9,-14, 6, 7, 6, 3, 0, -3, -9,-13,
- 5, 1, -4, -4, -3, -1, 0, 0, 7, 2, -3, -3, -2, -1, 1, 0,
- 7, 1, -3, -3, -1, 0, 1, 1, 6, 1, -3, -2, -1, 1, 1, 0,
- 6, 0, -4, -2, -1, 0, 1, 0, 5, 0, -4, -3, -1, 0, 0, -1,
- 5, 0, -3, -1, 0, 0, 0, -2, 4, 1, -2, -1, 0, 1, 0, -1,
- 2, 2, 1, 1, -2, -6, -8, -8, 1, 1, 1, 1, -2, -5, -8, -8,
- 1, 1, 1, 0, -1, -3, -5, -5, 0, 0, 0, 0, -1, -1, -1, -2,
- 0, -1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 2, 3, 2,
- 2, 1, 1, 1, 2, 3, 4, 3, 3, 3, 3, 3, 4, 4, 5, 4,
- -4, -4, -3, -2, 0, 0, 1, 1, -4, -4, -3, -2, -1, 0, 0, 1,
- -2, -2, -2, -1, -1, -1, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1,
- 2, 2, 2, 2, 2, 2, 1, 1, 3, 4, 4, 4, 4, 4, 4, 3,
- 1, 1, 1, 3, 3, 4, 3, 3, -5, -6, -5, -4, -3, -3, -2, -2,
- -4, -2, -1, -1, -1, -1, 0, 1, -4, -2, -1, -1, -1, -1, 0, 1,
- -3, -2, -1, -1, -1, 0, 1, 2, -4, -3, -2, -1, -1, 1, 3, 3,
- -4, -3, -3, -1, -1, 1, 4, 5, -4, -3, -2, -2, -1, 1, 4, 7,
- -2, -2, -1, -1, 0, 2, 6, 8, -1, 0, 0, 1, 1, 4, 7, 8,
- -3, -3, -3, -2, -2, -1, -1, 0, -1, -1, 0, 1, 2, 2, 3, 3,
- 0, 1, 2, 4, 5, 6, 6, 5, -1, 0, 2, 3, 5, 6, 5, 3,
- -1, -1, 0, 2, 3, 3, 2, 1, -2, -2, -1, 0, -1, -3, -4, -4,
- 0, 0, -1, -1, -2, -4, -8, -7, 1, 2, 1, 0, -1, -4, -6, -7,
- -2, 4, 1, -6, 0, 3, 0, 0, -2, 5, 1, -7, 0, 3, 0, 0,
- -3, 5, 1, -8, 0, 3, -1, -1, -2, 6, 1, -9, 0, 3, 0, -1,
- -2, 6, 2, -8, 0, 4, 0, -1, -3, 5, 1, -7, 1, 4, 0, 0,
- -2, 4, 1, -7, 0, 4, 1, 0, -1, 4, 1, -6, 0, 3, 1, 0,
- 0, 0, 0, 3, 4, 5, 4, 1, 1, 1, 1, 2, 3, 3, 2, 0,
- 2, 2, 1, 2, 2, 1, -1, -2, 4, 3, 1, 1, 0, -1, -3, -5,
- 5, 3, 1, -1, -2, -3, -4, -6, 5, 3, 0, -2, -3, -5, -6, -7,
- 4, 3, 0, -2, -3, -4, -5, -5, 4, 3, 0, -1, -2, -2, -3, -3,
- 0, 0, 0, 0, -1, -5, -2, 6, 0, 0, 0, 1, -1, -6, -2, 8,
- 0, 0, 0, 2, 0, -6, -3, 9, 0, -1, 0, 2, 0, -7, -2, 10,
- 0, -1, 0, 2, -1, -8, -3, 10, 0, -1, -1, 2, -1, -7, -3, 9,
- 0, -1, 0, 1, -1, -6, -3, 8, 0, 0, 0, 1, 0, -5, -2, 7,
- 2, 3, 3, 2, 1, 0, -1, -1, 3, 4, 3, 2, 1, 0, -1, -2,
- 3, 4, 4, 2, 1, -1, -2, -3, 2, 3, 3, 2, 0, -1, -2, -3,
- -1, 0, 1, 1, 0, -1, -2, -2, -5, -4, -3, -1, 0, 1, 1, 1,
- -8, -8, -5, -1, 1, 3, 4, 3,-10, -9, -5, 0, 3, 5, 6, 5,
- -5, -1, 4, 5, 3, 1, 0, 0, -6, -1, 4, 5, 2, 0, -1, -2,
- -6, -1, 5, 4, 2, -1, -2, -2, -7, -1, 4, 4, 1, -2, -3, -3,
- -6, -1, 5, 4, 1, -2, -3, -3, -5, 0, 4, 4, 1, -1, -2, -2,
- -4, 0, 5, 4, 1, -1, -1, -2, -3, 1, 4, 3, 1, -1, -1, -2,
- -2, -3, -2, 1, 4, 6, 5, 3, -3, -4, -4, 0, 3, 5, 4, 2,
- -3, -5, -5, -1, 2, 4, 3, 1, -4, -6, -4, -1, 2, 4, 2, -1,
- -2, -4, -3, 1, 2, 4, 2, -1, -2, -4, -2, 1, 3, 3, 1, -2,
- -2, -3, -2, 1, 3, 3, 1, -2, -2, -2, -1, 1, 3, 3, 0, -2,
- -4, -4, -3, -2, -1, 2, 5, 7, -4, -4, -3, -3, -2, 1, 5, 7,
- -2, -3, -2, -3, -3, -1, 3, 5, -1, -1, 0, -2, -3, -2, 2, 4,
- 1, 1, 1, -1, -4, -3, 1, 3, 4, 3, 2, -1, -4, -3, -1, 1,
- 6, 4, 3, 0, -3, -3, -2, 0, 6, 5, 3, 1, -2, -3, -2, -1,
- 12, 11, 8, 4, 0, -2, -2, -1, 10, 9, 6, 2, -1, -2, -1, 0,
- 4, 3, 2, 0, -1, -1, 0, 1, -1, -1, -1, -1, -2, 0, 1, 2,
- -3, -5, -4, -2, -2, 0, 2, 3, -5, -5, -4, -2, -1, 0, 1, 2,
- -5, -5, -4, -2, -1, 0, 1, 1, -4, -4, -3, -2, -2, -1, 0, 0,
- 3, 3, 2, -1, -3, -4, -3, -2, 3, 2, 0, -2, -4, -4, -3, -2,
- 2, 2, 1, -1, -3, -5, -4, -3, 3, 3, 3, 1, -2, -3, -3, -3,
- 4, 4, 4, 3, 0, -2, -2, -2, 5, 5, 5, 3, 0, -1, -2, -2,
- 5, 5, 4, 2, -1, -2, -3, -2, 3, 3, 3, 0, -2, -4, -4, -4,
- -1, -1, 4, -2, -2, 6, 2, -5, -1, 0, 4, -2, -3, 6, 2, -6,
- -1, 0, 4, -2, -3, 7, 3, -7, -1, -1, 4, -3, -4, 8, 3, -7,
- 0, -1, 4, -3, -4, 7, 3, -6, -1, -1, 4, -3, -4, 7, 3, -6,
- -1, -1, 3, -3, -4, 6, 3, -6, -1, 0, 3, -2, -3, 6, 3, -5,
- 1, -2, -7, 2, 5, -2, -1, 1, 1, -2, -8, 3, 6, -3, -1, 2,
- 2, -2, -9, 4, 7, -4, -2, 2, 3, -1, -9, 5, 7, -4, -1, 3,
- 3, -1, -9, 4, 7, -4, -2, 2, 3, -1, -7, 4, 6, -4, -2, 1,
- 2, 0, -6, 4, 6, -4, -1, 1, 2, 0, -5, 3, 4, -3, -1, 1,
- -2, 2, 2, 0, 0, -1, -3, -4, -2, 2, 2, 1, 1, 0, -2, -4,
- -2, 2, 2, 2, 2, 1, -1, -2, -3, 2, 3, 3, 4, 2, 0, -2,
- -3, 2, 3, 2, 4, 2, 0, -3, -4, 1, 2, 1, 2, 1, -1, -3,
- -5, 0, 1, 0, 1, 1, -2, -3, -4, 0, 0, 0, 1, 0, -2, -3,
- 0, 0, -1, -2, -2, 2, 7, 8, 0, 0, -1, -3, -2, 1, 6, 7,
- 0, 1, -1, -3, -3, 0, 4, 5, 0, 1, 0, -1, -1, 0, 1, 3,
- 0, 2, 1, 1, 0, -1, 0, 1, -2, 0, 1, 2, 1, 0, -1, -1,
- -5, -2, 0, 1, 1, 0, -3, -3, -6, -4, -1, 1, 1, -1, -3, -4,
- -4, -2, 2, 5, 6, 4, 3, 2, -5, -3, 1, 4, 4, 2, 0, 0,
- -4, -2, 0, 2, 1, -1, -2, -2, -2, -1, 0, 1, 0, -2, -3, -2,
- -2, 0, 0, 0, -1, -1, -2, -1, -2, -1, -1, 0, 0, 0, 1, 2,
- -2, -2, -1, -1, 0, 1, 3, 4, -2, -3, -2, -1, 0, 2, 4, 5,
- 2, 1, -2, -2, -1, 0, 1, 0, 1, 0, -3, -3, -1, 0, 1, 0,
- 0, -1, -3, -3, -1, 1, 1, 1, 0, 0, -3, -1, 1, 2, 3, 3,
- 0, -1, -3, -1, 1, 3, 3, 3, -2, -2, -4, -2, 1, 3, 4, 4,
- -3, -3, -4, -2, 1, 3, 3, 4, -2, -3, -5, -2, 1, 2, 3, 3,
- 4, 5, 3, 4, 4, 4, 4, 5, 3, 3, 1, 0, 0, 0, 0, 1,
- 1, 1, -1, -2, -3, -4, -3, -2, 2, 2, 0, -2, -2, -4, -3, -2,
- 2, 3, 1, -1, -1, -3, -3, -2, 1, 2, 0, 0, -1, -2, -2, -1,
- 0, 1, 0, -1, -1, -3, -2, -1, 1, 1, 0, -1, -1, -2, -2, -2,
- -2, -1, -1, 0, 1, 2, 1, 0, 1, 2, 3, 5, 6, 5, 5, 3,
- 1, 2, 3, 4, 5, 5, 4, 3, -2, -2, -3, -3, -2, -1, 0, 0,
- -3, -3, -4, -5, -4, -3, -2, -1, -1, -1, -2, -2, -2, -1, 0, 0,
- 0, 1, 0, -1, -1, 0, 0, 1, -1, 0, -1, -2, -3, -2, -2, -1,
- 7, 7, 6, 5, 4, 2, -1, -2, 3, 3, 2, 2, 1, 0, -2, -3,
- 0, -1, -1, -1, 0, -1, -2, -2, -1, -3, -2, -1, 0, 0, 0, 1,
- 0, -2, -2, -1, -1, 1, 2, 2, 3, 1, -1, -1, -1, 1, 2, 2,
- 3, 1, -2, -3, -2, -1, 1, 2, 1, -2, -5, -6, -5, -3, -2, 0,
- 0, -1, -2, -3, -1, 0, -2, -2, 0, 0, -1, -1, 0, 1, -1, -2,
- 0, 0, -2, -1, 0, 0, 0, -2, -1, -2, -3, -3, -2, -1, -3, -3,
- -1, -2, -3, -3, -2, -2, -3, -4, 2, 2, 0, 0, 0, 0, -1, -2,
- 5, 5, 3, 2, 2, 2, 0, -1, 8, 8, 6, 5, 4, 4, 2, 1,
- -7, -8, -6, -3, -1, -1, -2, -1, -5, -5, -3, 0, 2, 1, 0, 0,
- -1, -1, 0, 3, 4, 3, 1, 1, 2, 1, 1, 3, 4, 3, 2, 2,
- 3, 2, 0, 2, 3, 2, 1, 2, 4, 2, -1, -1, 0, 1, 1, 1,
- 3, 2, -2, -3, -2, -1, 0, 1, 3, 1, -3, -4, -3, -2, 0, 1,
- -4, -2, -1, 2, 3, 3, 1, 0, -7, -5, -4, -2, 0, 0, -1, -2,
- -6, -5, -5, -4, -2, -2, -2, -3, -1, 0, -1, -1, 0, 0, 0, -1,
- 2, 3, 2, 2, 2, 2, 1, 0, 3, 5, 4, 3, 1, 0, 1, 0,
- 3, 4, 3, 2, 0, -1, -1, -1, 5, 5, 3, 1, 0, -1, -1, -1,
- 1, 1, 0, -1, -3, -5, -6, -4, 1, 1, 0, 0, 0, -3, -3, -1,
- 0, -1, -1, 0, 1, 0, 1, 3, -2, -2, -3, -1, 2, 2, 4, 7,
- -2, -2, -2, 0, 2, 2, 3, 6, -1, 0, 0, 1, 1, 0, 0, 3,
- 0, 3, 3, 3, 1, -2, -3, -1, 1, 3, 4, 3, 0, -3, -5, -4,
- 0, 2, 0, -1, -3, -4, -2, -2, 1, 4, 2, 0, -2, -3, -2, -1,
- 3, 6, 3, 1, -2, -2, 0, -1, 4, 7, 4, 1, -2, -3, -1, 0,
- 3, 6, 3, 0, -3, -3, -1, 0, 1, 3, 0, -1, -3, -2, 1, 1,
- 0, 1, -1, -2, -3, -1, 2, 2, -2, -1, -3, -3, -3, -1, 1, 2,
- 3, 1, -1, 0, 1, 0, 0, 0, 2, -1, -2, -1, 1, 0, -1, -1,
- 1, -1, -2, 0, 1, 0, -2, -3, 0, -2, -1, 1, 3, 1, -3, -5,
- 0, -2, -1, 2, 5, 2, -3, -5, 0, -2, -1, 4, 6, 3, -2, -5,
- 0, -2, 0, 4, 7, 4, -2, -4, 0, -2, 0, 4, 6, 4, -2, -4,
- -2, -2, -3, -4, -3, -2, -1, 0, 1, 1, 0, -1, -1, -1, 0, 1,
- 3, 3, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 0, 0, 1,
- 0, 0, 0, 0, -1, -1, -1, -1, -4, -4, -4, -4, -4, -4, -4, -3,
- -3, -3, -2, -3, -2, -1, -1, 0, 3, 4, 4, 5, 5, 6, 6, 7,
- -1, -2, 7, -2, -4, -1, -1, 0, -1, -2, 9, -1, -4, -1, -1, 0,
- -1, -3, 10, -1, -4, -1, -1, 1, -1, -3, 10, -2, -3, -1, -1, 2,
- -1, -2, 10, -2, -4, -1, -1, 2, -1, -2, 9, -2, -4, -1, -1, 2,
- -1, -2, 8, -2, -4, 0, -1, 1, 0, -2, 7, -2, -3, -1, 0, 2,
- 3, -4, 1, 3, -3, -2, 1, 0, 3, -5, 1, 4, -3, -2, 1, 0,
- 3, -6, 2, 5, -3, -1, 3, 0, 3, -6, 2, 5, -3, -1, 2, 0,
- 3, -6, 1, 5, -4, -2, 3, 0, 3, -6, 1, 5, -3, -2, 2, 0,
- 2, -6, 1, 4, -3, -1, 1, 0, 2, -6, 1, 4, -2, -1, 1, 0,
- 0, 0, 1, 1, 1, 0, 0, 2, 0, -1, 1, 1, 1, 0, 0, 2,
- 0, -1, 0, 0, 0, 0, 0, 2, 0, -1, 0, 0, 0, 0, -1, 0,
- 1, 0, 1, 0, 0, -1, -2, -1, 3, 1, 1, 0, 0, -2, -4, -3,
- 5, 3, 2, 1, 0, -3, -5, -4, 5, 4, 2, 0, -1, -4, -5, -5,
- 1, 0, -1, -2, -2, -3, -6, -9, 2, 0, -1, -1, 0, 0, -3, -6,
- 1, 0, 0, -1, 0, 0, -2, -5, 2, 1, 1, 1, 1, 2, -1, -3,
- 1, 1, 2, 1, 2, 2, 1, -1, 1, 1, 2, 1, 1, 1, 1, 1,
- 0, 0, 2, 1, 0, 0, 2, 2, 0, 1, 2, 2, 0, 0, 2, 2,
- -4, -3, 0, 1, 4, 6, 4, 3, -3, -2, 0, 0, 2, 4, 1, 0,
- -1, -1, 0, 0, 1, 1, -2, -3, 1, 1, 1, 0, 1, 1, -3, -5,
- 1, 1, 1, 0, 1, 1, -3, -5, -1, 0, 0, -1, 1, 1, -2, -4,
- -1, 0, 0, -1, 1, 2, 0, -2, -1, 0, 0, 0, 2, 3, 1, 0,
- -1, 0, 3, 4, 0, -4, -5, -5, 0, 0, 4, 5, 2, -2, -3, -2,
- 0, -1, 2, 4, 2, -1, -1, 0, 0, -2, -1, 1, 0, -2, 0, 1,
- 1, -2, -2, 0, 0, -1, -1, 1, 1, -2, -3, 0, 1, 0, -1, 0,
- 1, -2, -2, 1, 3, 1, 0, 0, 1, -2, -1, 2, 4, 2, 0, 0,
- 1, 2, 3, 2, 0, 2, 2, 1, -1, 0, 1, 0, -3, 1, 1, 1,
- -1, 0, 0, -2, -4, 0, 2, 1, -1, 2, 2, -1, -5, 0, 2, 1,
- -1, 3, 4, -1, -5, 0, 2, 1, -2, 2, 4, 0, -4, -1, 0, 0,
- -4, 0, 2, 0, -4, -2, 0, 0, -5, -1, 2, 1, -2, 1, 3, 2,
- 1, 0, 1, 0, 1, 2, -1, -2, 2, 0, -1, -2, 1, 3, 0, -1,
- 3, 0, -2, -4, 0, 3, 1, 0, 5, 1, -3, -5, -2, 2, 1, 1,
- 6, 1, -2, -5, -2, 1, 0, 1, 5, 1, -1, -5, -2, 0, -1, 0,
- 3, 0, -2, -4, -2, 0, -1, 0, 1, -1, 0, -2, 0, 1, 0, 1,
- 1, 1, 2, 3, 2, 1, 1, 2, -1, -1, 0, 1, 1, 0, 1, 1,
- -4, -3, 0, 0, 1, 1, 1, 2, -4, -3, 0, 2, 2, 2, 3, 2,
- -5, -4, 0, 1, 1, 1, 1, 2, -5, -4, -1, -1, -2, -2, -1, 0,
- -3, -2, 0, 0, -2, -3, -2, -1, 2, 3, 4, 4, 2, 0, 0, 0,
- -4, -2, 0, 1, 0, 0, 0, 0, -3, -1, 1, 1, 0, 0, 0, 0,
- -2, 0, 2, 2, 0, 0, 0, 2, -1, 1, 2, 1, -1, 0, 3, 5,
- 0, 2, 1, -1, -2, 0, 5, 6, 0, 1, 0, -3, -3, 0, 4, 6,
- 1, 1, -2, -4, -4, -3, 1, 2, 1, 0, -2, -4, -5, -4, -2, 0,
- -1, -3, -3, -3, -3, -2, -1, -1, 3, 2, 1, 0, 0, 1, 1, 1,
- 5, 4, 3, 2, 1, 1, 2, 2, 2, 1, 0, -2, -2, -2, -1, -1,
- 0, 0, 0, -1, -2, -2, -2, -2, 0, 1, 3, 3, 2, 1, -1, -1,
- 0, 1, 3, 4, 3, 2, 1, -1, -4, -3, -1, 1, 0, -2, -3, -3,
- -3, -4, -7, -8, -7, -4, -1, 2, 0, -1, -3, -4, -4, -2, 0, 2,
- 1, 0, 0, -1, -3, -2, 0, 2, 2, 1, 1, 0, -1, -1, 0, 2,
- 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 0, 0, 1, 2, 3, 3, 2, 2, 0, 0, 1, 3, 4, 4, 3, 2,
- 3, 3, 3, 0, -1, 0, 1, 2, 1, 1, 1, -1, -2, -1, -1, 1,
- -2, -2, -1, -3, -3, -2, -2, 0, -4, -4, -2, -2, -2, -2, -3, 0,
- -4, -4, -1, 1, 1, 0, -1, 2, -3, -1, 2, 3, 4, 3, 3, 5,
- -2, 0, 2, 3, 3, 3, 3, 3, -2, -2, 0, 0, 0, 0, 0, 1,
- 0, 2, 1, -1, -3, -1, 3, -2, -1, 0, -1, -1, -3, 0, 4, -2,
- -2, -2, -2, -2, -2, 1, 5, -2, -3, -2, -3, -1, -2, 1, 4, -3,
- -2, 0, -1, 0, -1, 0, 3, -5, 1, 2, 1, 2, 0, 0, 2, -5,
- 2, 4, 2, 3, 1, 1, 3, -3, 1, 2, 1, 1, 0, 1, 4, -2,
- 4, -3, -4, -1, 3, 3, 1, 3, 4, -4, -4, -1, 3, 2, 0, 2,
- 4, -3, -4, 0, 2, 2, -1, 1, 4, -3, -2, 1, 2, 1, -2, 0,
- 2, -4, -2, 1, 2, 0, -3, 0, 2, -3, -2, 0, 1, 0, -2, 2,
- 3, -1, -1, 0, 0, 0, 0, 3, 2, -2, -2, -2, -1, -1, -1, 2,
- 2, 2, 3, 4, 3, 1, 0, -1, 1, 0, 1, 2, 1, -1, -2, -2,
- 2, 1, 2, 1, 1, 0, -1, -1, 4, 3, 4, 3, 2, 1, 1, 1,
- 3, 2, 2, 2, 1, 1, 1, 1, -1, -2, -1, 0, -1, -1, -1, -1,
- -3, -3, -2, -1, -2, -2, -2, -2, -4, -4, -3, -3, -4, -4, -3, -3,
- 2, 1, -1, -3, -4, -2, 3, 4, 2, 2, 1, -1, -3, -2, 1, 2,
- 1, 2, 3, 3, 0, -2, -1, -2, -1, 0, 2, 4, 2, 0, -1, -3,
- -2, -2, 0, 3, 3, 2, 0, -3, 0, -2, -3, -1, 1, 2, 2, -1,
- 3, -1, -4, -5, -3, 0, 2, 0, 6, 3, -2, -6, -5, 0, 3, 1,
- -2, 3, -2, 0, 3, -2, -2, 1, -3, 4, -3, 0, 3, -2, -1, 2,
- -3, 5, -3, 0, 4, -2, -1, 2, -2, 4, -4, -1, 3, -3, -2, 2,
- -3, 4, -3, 0, 3, -3, -1, 2, -2, 5, -2, 0, 3, -3, -1, 2,
- -2, 4, -3, 1, 3, -2, -1, 2, -2, 3, -2, 1, 3, -2, 0, 2,
- 1, 0, 0, -1, 1, 2, -4, -1, 2, 0, 0, -1, 1, 2, -4, -2,
- 1, 1, 1, -1, 2, 4, -2, 0, 0, -1, 1, -1, 2, 5, -1, 1,
- 0, -1, 0, -2, 1, 5, -1, 1, 0, -1, -1, -2, 0, 3, -3, -1,
- 1, 1, 0, -2, 0, 3, -3, -1, 1, 1, 0, -3, 0, 3, -2, 0,
- 1, 0, -1, 1, 1, 2, 4, 5, 1, 0, -1, 1, 1, 1, 5, 7,
- 0, 0, -2, -1, -1, 0, 3, 5, 0, -1, -2, -1, -1, -1, 2, 3,
- 0, -1, -3, -1, -1, -1, 1, 2, -1, -2, -4, -2, -2, -2, 0, 0,
- -1, -2, -2, -1, -2, -2, 0, 0, 0, -1, -1, 0, -1, -1, 0, 0,
- 3, 3, 0, -1, -1, 1, 4, 4, 2, 3, 0, -2, -2, 0, 1, 1,
- 2, 3, 1, -1, -1, 0, 1, 0, 1, 2, 0, -1, -1, -1, 0, -2,
- 0, 1, 0, -1, -2, -1, 0, -2, 0, 1, 0, -1, -2, -1, 1, 0,
- 1, 1, -1, -3, -4, -3, 1, 3, 1, 2, -1, -3, -5, -4, 1, 3,
- -3, -2, 0, 1, 1, 1, 0, -2, 0, 1, 1, 1, 0, 0, -1, -3,
- 1, 2, 1, 1, 0, -1, -1, -2, 0, -1, -3, -1, -1, -1, 0, -1,
- 0, -3, -6, -3, -2, -1, 1, 1, 2, -1, -4, -3, -2, 0, 2, 2,
- 5, 4, 1, 1, 0, 1, 3, 2, 5, 4, 2, 1, 0, -1, 0, 1,
- -2, 0, -2, -5, -6, -3, 0, 0, -2, 0, 1, 0, -1, 1, 2, 2,
- -2, 0, 1, 3, 2, 2, 2, 1, -2, 0, 2, 4, 3, 2, 1, 1,
- -2, 0, 2, 3, 2, 0, -1, 0, -3, -1, 1, 1, 0, -1, -1, 1,
- -4, -1, 1, 0, -1, -2, 0, 2, -4, -1, 0, -1, -1, -2, 1, 4,
- -3, 0, 0, -1, 1, 1, 1, 0, -3, 1, 0, -1, 0, 0, -1, -1,
- -1, 3, 3, 0, 1, 0, 0, 1, -3, 2, 2, -2, -1, 0, 0, 1,
- -5, 0, 0, -2, -1, 1, 0, 2, -7, -2, 1, 0, 1, 2, 2, 2,
- -5, 0, 3, 2, 3, 3, 2, 2, -3, 2, 4, 1, 0, 0, -2, -3,
- 5, 2, -2, -2, 0, -1, -1, -1, 2, -1, -4, -3, -1, -2, -1, -1,
- 0, -2, -2, 1, 2, -1, 0, 1, -1, -2, -1, 3, 3, -1, 0, 2,
- 1, 0, 0, 3, 3, -2, -1, 2, 2, 1, 1, 3, 2, -2, -2, 0,
- 1, 0, -1, 1, 1, -3, -3, -2, 1, 0, 1, 2, 3, 0, 0, 0,
- -4, -5, -3, 0, 1, -1, -2, -1, -2, -3, -1, 1, 2, 0, 0, 0,
- 1, 1, 2, 1, 2, 1, 1, 1, 3, 4, 3, 1, 0, -2, -1, -1,
- 3, 3, 2, 0, -2, -3, -3, -2, 1, 1, 0, -1, -2, -4, -2, -2,
- 2, 1, 0, 0, 0, -1, 0, 1, 2, 1, 1, 1, 1, 1, 1, 3,
- 0, 0, 0, -1, -2, -1, 1, 0, -2, -1, -1, -2, -3, -2, 0, 0,
- -1, 0, 0, -1, -2, 0, 1, 1, 1, 1, 0, -1, -1, 1, 3, 1,
- 2, 2, 0, -2, -1, 2, 3, 0, 3, 1, -1, -1, 1, 4, 2, -2,
- 2, 0, -3, -1, 3, 5, 0, -5, 1, -1, -2, 0, 3, 3, -1, -6,
- -1, 0, 3, 4, 2, 0, 1, 2, -2, -1, 0, 1, -1, -2, 0, 1,
- -2, -3, -2, -3, -6, -7, -6, -3, 2, 2, 3, 1, -1, -2, -3, -2,
- 2, 2, 3, 1, 0, 0, 0, 0, 2, 1, 1, 0, 1, 1, 0, 1,
- 1, 0, 0, 0, 0, 1, 1, 2, 1, 0, -1, 0, 0, 2, 2, 1,
- 1, 1, 3, 1, -1, -1, -1, 1, -2, -1, 0, 0, -2, -2, -1, 2,
- -2, -2, 1, 1, 1, 0, 1, 3, -2, -2, 0, -1, 0, -1, 0, 2,
- 0, 0, 1, 0, -1, -1, -2, 1, 3, 2, 2, 1, 0, -2, -2, 1,
- 5, 3, 3, 2, 1, 1, 1, 4, 0, -3, -4, -5, -4, -3, -1, 1,
- -6, -4, -1, 2, 2, 0, 0, -1, -4, -2, 1, 3, 3, 2, 2, 0,
- -3, -2, -1, 2, 3, 3, 2, 0, -3, -2, -2, 1, 2, 1, 1, -1,
- -2, -2, -2, 0, 2, 2, 1, -1, -1, -1, -1, 1, 2, 3, 2, 0,
- -1, -1, -2, 1, 2, 2, 2, -1, 0, -1, -2, 0, 2, 1, 0, -1,
- 6, 4, 2, 1, 0, 0, 0, 1, 4, 2, -1, -2, -2, -2, -1, -1,
- 2, 1, -1, -2, -2, -2, -2, -1, 2, 2, 0, -2, -2, -2, -1, 0,
- 0, 0, -1, -2, -2, -1, 0, 1, -3, -3, -2, -1, -1, -2, -1, 0,
- -3, -2, 2, 3, 2, 0, -1, -2, -2, 0, 4, 5, 5, 2, 0, -1,
- 5, 4, 2, 0, -1, -2, -1, -1, 4, 3, 2, 1, 0, -1, 0, -1,
- 1, 1, 0, 1, 1, 0, 1, -1, -2, -1, -1, 0, 0, -2, -2, -3,
- -1, 0, 0, 0, -1, -3, -3, -5, 0, 1, 1, -1, -1, -2, -2, -3,
- -1, -1, -1, -2, -1, 1, 3, 1, -1, -2, -2, -1, 2, 5, 6, 5,
- -3, -3, -2, 1, 1, -2, -1, -1, 1, 2, 3, 4, 1, -3, -1, -3,
- 3, 2, 0, 1, -1, -3, -1, -3, 1, 0, -1, 0, -1, -1, 1, 0,
- 1, 1, 0, 1, 2, 2, 5, 3, 1, 1, 1, 2, 2, 2, 3, 0,
- -3, -1, -2, -2, -3, -3, -1, -3, -1, 1, 1, 0, -1, -1, 0, -2,
- 2, 0, -2, -2, 2, 4, 1, -2, 1, 0, -2, -1, 3, 5, 2, -1,
- -1, -2, -3, -2, 1, 3, 1, -2, -1, -2, -1, -1, 0, 2, 1, -1,
- 0, 0, 1, 1, 1, 2, 2, 0, 0, 1, 4, 4, 2, 2, 3, 1,
- -2, -1, 2, 1, -2, -3, -2, -3, -1, 0, 1, 0, -3, -4, -4, -5,
- 4, 0, -3, -4, -4, -4, -2, -1, 5, 0, -1, 0, -1, -3, -2, -1,
- 4, 0, 0, 1, 1, 0, 0, 0, 0, -3, -2, -1, 0, 0, 1, 0,
- 0, -2, 0, 0, 1, 1, 2, 1, 2, 0, 0, 0, 1, 1, 1, 0,
- 2, 0, -1, -1, 1, 1, 1, 0, 1, -1, -2, -2, 0, 2, 2, 2,
- -3, -5, -2, 0, -1, -3, -3, 0, 0, -2, 0, 2, 2, 0, 0, 3,
- 2, -1, -2, 0, 0, -1, -1, 2, 5, 2, -1, -1, -1, -1, -1, 2,
- 5, 2, 0, -1, -1, 0, -1, 2, 2, 1, 0, 0, 0, 1, 0, 2,
- -1, -1, 1, 1, 2, 2, 1, 2, -3, -2, 0, 0, 0, 0, -2, -1,
- 0, 3, 2, 0, -2, -3, -3, -3, 0, 3, 3, 1, 0, 0, 1, 2,
- -1, 0, -1, -2, -1, -1, 1, 3, -1, 0, -1, -2, -1, -1, 0, 2,
- -1, 0, -1, -2, 0, 0, -1, 2, -1, 0, -1, -2, -1, -1, -2, 1,
- 0, 1, 0, -3, -1, -1, -1, 2, 5, 5, 2, -1, -1, -1, 1, 3,
- 0, 0, 1, -1, -3, -2, 0, 2, 1, 1, 3, 0, -2, -2, 0, 1,
- 1, 1, 3, 1, 0, 0, -1, -1, 0, -1, 2, 1, 1, 0, -1, -3,
- -1, -2, 1, 1, 1, 0, -2, -4, -1, 0, 2, 1, 1, 0, -1, -3,
- 1, 1, 3, 2, 1, 0, -2, -3, 2, 2, 4, 2, 1, -1, -2, -4,
- 1, 2, 2, 2, 0, -2, 0, 2, -1, -1, -2, -3, -4, -5, -3, 1,
- 0, 1, 1, 0, -1, -1, -1, 1, 0, 1, 1, 1, 0, 0, 0, 2,
- 0, 1, 1, 2, 1, 1, 1, 2, -1, -1, 0, 2, 2, 2, 2, 3,
- -2, -4, -4, -1, -2, -2, -2, 0, 1, 0, 0, 1, 0, 0, 0, 1,
- 0, -1, -3, -2, 0, 2, 2, 1, 0, -1, -2, -3, 0, 1, 1, 2,
- 1, 0, -2, -3, -1, 0, 0, 1, -1, 0, -1, -2, 0, 0, -1, 0,
- -1, 1, 1, 0, 2, 2, 0, 0, 0, 2, 3, 1, 3, 5, 3, 2,
- -1, 1, 1, -2, 0, 3, 1, 1, -1, 0, 0, -4, -4, -1, -1, -1,
- -1, 1, 1, 0, 1, 2, 1, 2, -3, 0, 1, 0, 1, 1, 0, 2,
- -5, -3, -1, -1, 0, 1, 0, 1, -4, -3, -2, -3, -2, -1, -1, 0,
- 0, 0, -1, -2, -2, -2, -2, 0, 3, 4, 2, 0, 0, 0, 0, 1,
- 2, 1, 0, 0, 0, 0, -1, 0, 0, 1, 2, 3, 4, 4, 3, 2,
- -1, 4, 7, 4, 0, 0, 0, 0, -1, 4, 6, 3, 0, 1, 1, 1,
- 0, 3, 4, 0, -1, 0, 0, 1, 0, 1, 1, -2, -1, 0, -1, -1,
- -1, 0, -1, -1, -1, 0, 0, 0, -1, -1, -1, 0, 0, 0, 0, 0,
- -1, -3, -3, 0, 1, -1, -2, -1, -3, -4, -4, -2, -1, -2, -2, -1,
- 2, 2, 1, 0, 1, 1, 0, -3, -2, -1, 0, 0, 1, 1, 0, -3,
- -2, -1, 0, 1, 2, 1, 1, -2, 1, 2, 2, 2, 3, 3, 2, -1,
- 1, 2, 1, 0, 1, 1, 2, -1, 0, 1, -2, -4, -2, 0, 1, -1,
- 1, 1, -1, -3, -2, 0, -1, -3, 1, 2, 0, -1, 0, 1, -1, -4,
- -1, -1, -2, -2, 0, 3, 4, 3, 1, 1, -1, -3, -2, 0, 0, 0,
- 2, 2, 2, 2, 2, 1, -1, -1, 1, 1, 1, 3, 3, 0, -2, -2,
- 0, -1, -1, -1, 0, -2, -1, -1, -1, -3, -4, -3, -2, -2, 0, 2,
- -1, -1, 0, 1, 2, 2, 3, 5, -2, -1, -1, 0, 0, 0, 0, 1,
- -2, -3, 2, 0, 0, 1, 1, -1, -1, -4, 1, -2, -1, 2, 2, 0,
- 1, -4, 0, -2, -2, 1, 1, -1, 2, -3, 1, -1, -1, 1, 1, -1,
- 3, -2, 3, 1, 0, 1, 1, -1, 1, -3, 2, 1, 0, 1, 0, -1,
- -1, -5, 1, 0, -1, 0, 1, 1, 0, -3, 3, 3, 1, 2, 3, 3,
- 0, -1, -2, 1, 5, 5, 2, -1, 1, -1, -2, -1, 1, 1, -2, -5,
- 1, 1, -1, -2, -1, -1, -1, -3, 1, 1, -1, -1, -1, 2, 4, 3,
- -1, -1, -1, -1, -1, 0, 4, 3, -1, -1, 0, 1, -1, -3, -1, -1,
- 0, 0, 0, 2, 2, 0, 0, -1, 0, -2, -3, 0, 1, 1, 3, 2,
- 2, 3, 2, 1, 0, 0, -2, -2, 2, 3, 0, 1, 1, 3, 3, 2,
- 0, 0, -3, -1, -1, 2, 2, 3, -2, -2, -3, 1, 1, 2, 1, 1,
- -2, -1, -2, 2, 1, 1, -1, -2, 0, 1, 0, 2, 0, 0, -2, -2,
- 0, 1, 0, 2, 0, 0, -2, -2, -3, -2, -2, 0, -1, -2, -2, -3,
- 0, 1, -1, 3, -1, 1, 3, -1, 0, 1, -1, 3, -1, -1, 2, -3,
- 1, 1, -2, 3, -1, -3, 0, -3, 2, 2, -2, 3, 0, -2, 1, -2,
- 1, 1, -3, 3, -1, -2, 1, -3, 1, 1, -3, 3, 0, -1, 1, -2,
- 1, 2, -1, 4, 0, -1, 1, -2, 0, 1, -1, 3, -1, -3, 0, -3,
- -3, -3, -1, 1, 2, 1, -1, -2, -2, -2, 0, 2, 1, 0, -2, -2,
- -3, -2, 1, 2, 1, -1, -2, -1, -3, -2, 2, 4, 0, -2, -2, 1,
- -3, -1, 2, 4, 0, -2, -2, 2, -1, 1, 4, 3, -1, -3, -2, 2,
- 0, 2, 4, 2, -1, -2, -1, 2, 0, 1, 2, 0, -1, 0, 1, 3,
- 3, 0, -5, 1, 4, 0, 0, 1, 1, -2, -5, 2, 5, -1, -2, 1,
- -1, 0, 0, 3, 3, 1, 0, -1, -2, 3, 4, -2, -3, -1, 0, -2,
- -3, 3, 5, -3, -3, 0, 0, -2, -1, 3, 2, -2, -2, 2, 2, -1,
- 2, 0, 0, -1, 0, 0, 0, 0, 0, -3, -2, 1, 3, 0, -2, -2
-};
-
-/* list of codebooks for inter-coded vectors */
-const int8_t* const ff_svq1_inter_codebooks[6] = {
- svq1_inter_codebook_4x2, svq1_inter_codebook_4x4,
- svq1_inter_codebook_8x4, svq1_inter_codebook_8x8,
- NULL, NULL,
-};
-
-/* 6x16-entry codebook for intra-coded 4x2 vectors */
-DECLARE_ALIGNED(4, static const int8_t, svq1_intra_codebook_4x2)[768] = {
- 12, 13, 13, 11, -7,-10,-15,-17,-16,-15,-12,-10, 11, 15, 15, 12,
- 2, 17, 20, 15,-45,-24, 2, 13, 21, 20, -6,-36, 12, 16, -1,-27,
- -18,-21, 10, 45,-11,-20, -7, 21, 43, -8,-28, 0, 33,-16,-28, 3,
- -12,-18,-18, -6,-20,-10, 28, 55, -5,-18,-21,-18, 56, 30, -6,-20,
- -34, 27, 29,-22,-30, 29, 26,-25, 30, 34, 33, 26,-25,-31,-35,-33,
- -31,-35,-36,-32, 29, 36, 37, 31,-71,-12, 38, 34,-63, -1, 42, 33,
- 58, 37,-31,-60, 55, 34,-33,-61,-57,-57, 22, 93,-57,-58, 21, 93,
- 59, 69, 70, 62,-63,-68,-68,-60,-64,-71,-71,-64, 63, 73, 72, 62,
- -2, 0, 7, 15,-11,-10, -3, 5, -5, -8,-10,-10, 1, 9, 14, 9,
- 15, 8, -4,-11, 12, 2,-11,-12, -8, 0, 19, 28, 4, -1,-15,-26,
- -15, 27, 2,-14,-14, 22, 1, -9, -4, -6,-13,-10, -6,-14, 6, 47,
- -35,-20, 6, 23, 6, 9, 6, 4, -6, 2, 23,-22, -7, 4, 28,-21,
- 20,-22, -2, 6, 22,-28, -5, 8,-10,-18,-16,-12, 36, 19, 2, -1,
- -3, 0, 4, 8,-45,-10, 23, 23, 40, 15,-20,-35, -4, -1, 4, 1,
- 9, -5,-33, 24, 8, 3,-26, 19, -1, 4, 6, -3, 32, 25,-13,-49,
- 24, 24, 15, 7,-17,-27,-19, -7,-47, 0, 39, 24,-21, -6, 7, 4,
- -1, 0,-10,-13, 1, 1, 5, 16, 20, 5, -3, -9, -1, -4, -2, -6,
- -17, -7, 1, 4, 12, 7, 0, 0, 3, 0, 12, 11, -3, 1, 0,-23,
- 4, 17, -6, 0, 6, 3,-25, 0,-17, 10, 8, 5,-14, 4, 1, 4,
- 13, 10, 4, 2,-23, -9, 1, 2, 3, -3, 1, 7, 1,-23, -7, 20,
- -7,-18, 2, 12, -5, -4, 10, 9, 4, 10, 7,-24, 6, 3, 4,-10,
- 22,-14,-22, 6, 0, 5, 5, -1, -4, 3,-11, -4, -7, 31, 7,-14,
- -5,-16, -1, 42, -4, -2, -9, -5, 5, -8, -6, -3, 42, -4,-21, -5,
- -18, 12, 20,-12, 13,-13,-10, 7, -8, -9, -2,-18,-16, 6, 40, 8,
- 10, -1, 0, 4, -3, 4, -1,-13, -2, 6, 1,-15, 5, 3, 1, 2,
- -4, -2, 1, 3, 15, 0, -9, -4, -3, -4, -4, -4, -3, 5, 16, -3,
- 2, 13, 3, 4, -3, -8,-10, 0, -6, -2, -4, -1, -2, -3, -6, 23,
- 6, -6, 7, 1, 4,-18, 5, 1, -1, 1,-15, 14, -5, 6, -4, 4,
- 2, 2, 2, 6,-24, 2, 7, 3,-26, 0, 3, 3, 5, 7, 1, 6,
- 14, -2,-18, -3, 7, 5, -4, 2, -6, 3, 32, 1, -6, -6, -6,-12,
- 5,-36, 7, 6, 9, -1, 11, 0, 4, 4, 5, 3, 4, 15, 3,-38,
- 10, 23, -5,-42, 0, 4, 4, 4, 23, 17, -6,-13,-13,-37, 1, 29,
- 5,-14, -1, 1, 5, 0, 3, 1, 0, 4, -5, 2, 8, 0, 0,-10,
- 4, 7, -2, -3,-10, 3, 1, 1,-12, -1, 13, 3, 0, -1, 1, -3,
- 0, -1, 3, 1, -6, -9, 3, 9, -6, 1, -4, -6, 8, -1, 0, 8,
- -3, -3, 0, 18, -5, -1, -4, -1, -8, -2, 3, -4, 0, 17, -1, -5,
- 5, -2, 9,-10, 1, -5, 6, -5, 4, 2, 2, 3, 10,-14, -8, 1,
- -1, -2,-18, -1, -1, 20, 1, 2, -1, 1, -9, 1, -1, -9, 22, -4,
- 6, -4, 8, -3, -1, 7,-19, 5, -7, 31, -4, -4, -6, 0, -5, -5,
- -7, -8,-19, -4, 1, 1, 4, 32, 38, -1, -8, 4, -7, -8, -6,-12,
- -1, 0, -7, 1, -1, 9, -1, 0, 9, -1, -1, 0, 2, -6, 1, -3,
- -12, 0, 2, 1, 1, 1, 8, 0, 9, 1, 0, 2, -2, 1,-11, 0,
- 0, 8, 2,-10, -1, 2, -1, 0, -2, -4, 0, -5, -2, -1, -1, 14,
- -3, 7, -1, 5, 0,-10, 1, 1, -1, -5, 14, -1, -2, 1, -3, -2,
- -6, 0, 0, 6, 2, 3, -9, 4, 4, -5, -1, -1, -7, 3, 8, -1,
- 2, -4, -1,-11, 11, 2, 1, 0, -1, 2, 3, 9, 0, 2, 0,-15,
- 3, 5,-20, 3, 3, -1, 3, 3, 1, -1, 16, 1, 2,-29, 9, 2,
- -13, -6, -1, -3, 36, -1, -8, -3, 2, 5, 4, 2,-37, 9, 11, 3
-};
-
-/* 6x16-entry codebook for intra-coded 4x4 vectors */
-DECLARE_ALIGNED(4, static const int8_t, svq1_intra_codebook_4x4)[1536] = {
- -11, -3, 3, 6,-10, -1, 5, 7, -9, -1, 6, 7, -9, -1, 4, 6,
- 5, 7, 0,-14, 6, 9, 2,-15, 6, 9, 2,-15, 4, 6, 0,-14,
- 16, 3, -5, -6, 16, 1, -8, -8, 14, -1, -9, -9, 12, 0, -8, -8,
- 8, 12, 16, 17, -2, 2, 6, 9,-10, -8, -4, 0,-15,-14,-11, -7,
- -7,-10, -2, 16, -7,-11, -3, 18, -7,-11, -1, 20, -6, -8, 1, 19,
- -9,-13,-16,-17, 2, -2, -7, -9, 11, 8, 4, -1, 16, 15, 11, 7,
- -22, -2, 13, 15,-24, -2, 14, 16,-25, -4, 13, 15,-25, -6, 10, 13,
- 26, 26, 22, 16, 17, 15, 9, 3, -2, -6,-11,-14,-20,-25,-28,-28,
- -27,-27,-25,-21,-16,-15,-11, -7, 3, 8, 12, 13, 23, 28, 31, 30,
- 20, 16, -7,-33, 22, 19, -6,-35, 22, 19, -6,-34, 20, 17, -6,-32,
- -20,-20, 2, 38,-21,-22, 2, 40,-21,-22, 2, 40,-20,-20, 3, 38,
- -47, -4, 24, 26,-50, -3, 26, 27,-50, -3, 26, 27,-47, -4, 24, 26,
- 45, 6,-23,-27, 48, 5,-25,-28, 48, 5,-26,-28, 44, 6,-24,-27,
- -30,-36,-10, 76,-31,-37,-11, 78,-31,-37,-11, 78,-31,-36,-10, 77,
- -53,-32, 35, 52,-54,-34, 36, 52,-54,-34, 36, 52,-53,-33, 34, 51,
- -93,-34, 62, 65,-93,-34, 62, 66,-93,-34, 62, 65,-93,-34, 60, 64,
- -7, 0, 2, 2, -8, -1, 3, 3, -8, 0, 4, 5, -6, 1, 5, 5,
- 3, 7, 11, 11, 2, 2, 3, 3, 1, -2, -6, -7, 1, -5,-11,-13,
- 3, -2, -4, -3, 7, 0, -5, -5, 12, 4, -5, -7, 14, 6, -4, -7,
- 18, 14, 3, -2, 6, 4, 0, -3, -8, -5, -2, 0,-16,-11, -2, 2,
- -8, -6, 7, 18, -7, -8, 2, 13, -4, -6, -2, 6, 0, -4, -3, 1,
- 1, -3,-13,-18, 0, -1, -5, -7, -1, 1, 6, 7, -2, 4, 15, 17,
- -15,-14, -7, -2, -6, -5, -1, 0, 6, 6, 3, 1, 15, 13, 6, 1,
- 2, -2,-11, 10, 2, -1,-12, 11, 3, -1,-12, 11, 2, -2,-11, 11,
- -9, 14, -1, -5, -9, 15, -2, -5, -8, 16, -2, -5, -7, 15, -1, -4,
- 2, 6, 8, 8, -2, 3, 9, 12,-11, -5, 4, 10,-19,-16, -8, 0,
- 14, 8, -7,-15, 12, 7, -7,-14, 8, 5, -4, -9, 5, 3, -1, -4,
- 12,-14, -2, 2, 13,-15, -1, 3, 14,-15, -1, 3, 13,-14, -1, 3,
- 0, 6, 10,-13, 0, 6, 10,-15, 0, 7, 9,-17, 1, 6, 8,-16,
- -8, -5, 15, -2, -8, -6, 17, -2, -8, -6, 16, -3, -8, -5, 15, -2,
- -9,-11,-11,-10, 9, 10, 9, 8, 8, 10, 10, 9, -8, -9, -8, -7,
- 9, 10, 9, 7, -8,-10,-10,-10, -7,-10,-11,-11, 11, 12, 11, 8,
- 0, 10, 7, 0, 0, 7, 0, -6, 0, 2, -5, -6, -2, -1, -4, -1,
- 5, 0, -6, -9, 2, 2, 2, 1, -2, 0, 5, 7, -6, -5, 1, 4,
- 3, -8, 2, -1, 4, -9, 3, 0, 5, -7, 3, 0, 7, -5, 3, 0,
- -5, -3, 2, 9, -6, -3, 1, 8, -6, -3, 1, 7, -5, -2, 0, 4,
- 13, 8, 3, 1, -3, -5, -4, -1, -8, -7, -3, 0, -1, 1, 3, 2,
- 3, 2, -5,-12, 4, 3, -2, -9, 3, 4, 1, -4, 3, 5, 4, -1,
- -9, -8, -4, 0, 8, 6, 2, 0, 10, 8, 3, 0, -6, -5, -3, -1,
- -3, -9,-12, -5, 0, -3, -5, 0, 2, 3, 2, 4, 5, 8, 7, 6,
- -1, -2, 5, 12, -1, -1, 5, 9, 2, 1, -1, -2, 2, -1,-11,-17,
- -7, 3, 3, -1, -9, 3, 4, -1,-10, 4, 6, -1, -9, 5, 7, 0,
- -18, -7, 2, 2, -8, 1, 5, 3, 3, 4, 1, 0, 9, 5, -2, -3,
- -2, 0, 6, 8, -4, -5, -5, -3, 1, -2, -6, -8, 10, 9, 3, -1,
- 0, -2, -2, 0, 0, -4, -5, 0, -2, -8, -4, 8, -5, -7, 6, 24,
- 9, 1, -7, 1, 9, 1, -8, 1, 8, 0,-10, 1, 8, -1,-11, -1,
- 8, 8, 6, 3, 5, 4, 3, 2, -2, -3, -1, 0,-10,-13, -8, -4,
- 0, 4, 2, -3, 0, 6, 3, -5, 3, 10, 2,-12, 5, 10, -4,-22,
- 0, -4, -1, 3, 1, -4, -1, 5, 1, -5, 0, 8, -1, -6, -2, 7,
- -1, -1, -2, -4, -1, -2, -4, -6, -1, -1, -1, -2, 1, 5, 10, 9,
- 10, 3, 0, -2, 6, -1, -2, -5, 3, -1, -2, -6, 2, 0, 0, -5,
- 6, 3, 0, 0, 6, 3, 1, 1, 4, -2, -2, 1, 0, -9, -9, -2,
- -11, -3, 1, 2, -6, 2, 4, 5, -3, 2, 3, 4, -2, 1, 1, 2,
- -6, -4, -1, -2, 2, -1, -1, -2, 10, 2, -2, -2, 11, 2, -4, -1,
- 6, 0, -2, 2, 3, 3, 0, 0, -6, 3, 3, 0,-17, -1, 5, 0,
- -1, 4, 10, 11, -3, -2, 0, 1, -3, -4, -5, -3, -1, -2, -2, -1,
- 2, -3, -9,-12, 3, 3, 3, 2, 2, 2, 4, 4, 2, 1, -1, -2,
- -2, 9, 5,-10, -3, 5, 5, -5, -2, 1, 2, 0, -1, -2, -2, 1,
- -2, -3, 7, -2, -1, -3, 7, -3, -1, -2, 8, -4, -2, -2, 7, -3,
- 1, -8, -3, 12, 2, -2, -2, 4, 1, 3, 0, -5, -1, 5, 2, -7,
- -1, 3, 1, -5, -7, -2, 3, 1, -2, -7, -2, 2, 20, 3, -5, -1,
- 5, 0, -3, -2, -7, -7, 0, 6, -6, 0, 7, 6, 2, 6, 0, -7,
- -2, 6, -7, 1, -2, 7, -8, 3, -2, 7, -7, 3, -1, 7, -6, 2,
- -5, -2, 5, 7, 4, 1, -4, -8, 6, 3, -2, -5, -7, -5, 3, 7,
- -1, -1, 6, 5, 0, -1, 1, -4, 2, 1, 0, -7, 1, 0, 0, -4,
- -8, 0, 3, 1, -2, 1, -1, -1, 1, -1, -3, 1, 1, -2, 1, 9,
- 5, 2, -3, -4, -1, 0, -1, -3, -3, 1, 3, 1, -4, 0, 4, 2,
- 2, -2, -2, 12, 0, -2, -5, 3, -1, 0, -3, 1, -3, -1, -2, 1,
- 1, 5, 3, 0, -6, -4, -2, 1, 0, -2, -2, 2, 6, 1, -4, -1,
- -3, -5, -5, -1, 3, 5, 5, 4, 0, 3, 1, -1, -2, 1, -2, -3,
- 2, -4, -5, -3, 4, -2, -3, -2, 6, 0, -1, -1, 7, 1, 0, 0,
- -3, -2, -2, 0, -2, -3, -5, -1, -2, 2, 0, -1, -1, 11, 9, -1,
- 0, 1, -1,-10, -1, 1, 0, -6, 1, 0, 1, 4, 2, -5, -1, 13,
- -2, 4, 5, 0, -5, 1, 6, 3, -6, -2, 3, 2, -5, -2, 0, -2,
- -1, 1, 1, -2, -1, -2, 0, 2, 5, 5, 5, 7, 0, -4, -8, -7,
- 0, 2, -1, -5, -1, 2, 2, -3, 0, 5, 3, -5, 3, 8, 2,-12,
- 8, 4, 0, -2, 10, -1, -4, -1, 3, -6, -3, 0, -4, -5, 0, 0,
- 0,-10, -4, 2, -1, -6, 3, 5, -1, -3, 6, 4, 0, -2, 4, 2,
- 0, 8, 1, -1, 0, 11, 1, -3, -1, 6, -2, -4, -3, -2, -7, -4,
- 0, -1, -1, -1, 4, 5, 6, 5, -5, -9, -8, -5, 2, 2, 3, 2,
- 0, 2, 6, 1, 2, 0, 3, 0, 1, -2, -1, -2, 0, -1, -3, -6,
- 0, 0, 2, 0, 4, 0, 2, 1, 5, -2, 0, 0, -2, -9, -1, 2,
- 0, 1, 0,-10, -1, 1, 8, 0, -1, -2, 4, 0, 1, -1, 2, -1,
- -3, -2, 2, -1, -3, -1, 2, -3, 0, -1, 1, 0, 8, 1, -1, 3,
- 0, 1, 1, 2, 0, -4, -2, 0, -1, -5, 1, -1, -2, -1, 11, 2,
- 1, 5, -2, -2, 0, 2, -4, 0, -2, 1, -5, 1, 0, 5, 0, 1,
- -5, -3, 0, 6, -4, 2, 0, 0, -3, 5, 1, 0, -3, 3, 0, 0,
- 3, -2, -3, 1, 1, -4, 0, 8, -2, -3, -2, 3, 1, 2, -1, -1,
- 1, 1, 0, 2, 2, 0, 1, 6, 1, -1, 2, 1, 0, 3, 0,-19,
- 1, -3, -2, 2, 6, 5, -2, -7, -3, 1, 3, 1, -1, -1, 0, 2,
- -8, -1, -1, -4, 1, 1, -1, 2, 4, 3, 2, 3, -5, 1, 3, 0,
- 0, 2, -1, 1, -3, 0, 0, 5, -5, -2, 0, 8, -4, -4, -4, 6,
- 1, 2, 1, 2, 2, 2, -3, 2, 4, 0, -9, 0, 7, 0,-11, 1,
- 0, 0, 0, -2, 3, 3, -1, -6, 4, 3, -3,-10, -1, 2, 6, 2,
- 7, -2, -3, 5, -4, 0, 3, -1, -4, 2, 1, -7, 2, -1, -1, 3,
- 3, 2, 2, 2, -5, -7, -7, -5, 5, 6, 4, 2, -2, -1, 0, 1
-};
-
-/* 6x16-entry codebook for intra-coded 8x4 vectors */
-DECLARE_ALIGNED(4, static const int8_t, svq1_intra_codebook_8x4)[3072] = {
- 5, 6, 6, 6, 7, 7, 8, 8, 0, 0, 0, 0, 0, 1, 2, 3,
- -3, -4, -4, -5, -5, -4, -3, -2, -4, -4, -4, -5, -4, -4, -3, -3,
- 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 3, 4, 4, 5, 5, 5,
- -1, 0, 1, 1, 2, 3, 4, 4, -9,-10, -9, -9, -8, -7, -6, -5,
- -4, -4, -5, -6, -6, -7, -7, -7, 0, -1, -2, -2, -3, -3, -4, -4,
- 4, 4, 3, 3, 2, 1, 1, 0, 7, 7, 7, 6, 6, 5, 4, 4,
- 2, 4, 5, 6, 4, 1, -3, -6, 3, 4, 5, 5, 4, 0, -5, -8,
- 2, 3, 4, 4, 2, -2, -7,-10, 2, 2, 2, 1, 0, -4, -9,-12,
- -9, -7, -3, 1, 4, 4, 3, 3,-10, -7, -2, 3, 5, 5, 3, 3,
- -9, -6, -2, 3, 6, 5, 4, 3, -8, -6, -1, 3, 4, 4, 3, 2,
- -5, -5, -5, -5, -3, 1, 4, 7, -5, -5, -5, -4, -2, 1, 6, 8,
- -4, -5, -4, -3, -1, 3, 8, 10, -3, -4, -3, -2, 1, 5, 9, 11,
- -2, -2, -2, -2, -2, -2, -2, -2, -4, -5, -5, -5, -5, -5, -5, -4,
- -3, -4, -4, -4, -4, -4, -4, -3, 9, 10, 10, 11, 11, 11, 10, 10,
- 7, 4, 1, -2, -4, -6, -9,-10, 9, 7, 3, 0, -2, -4, -8, -9,
- 11, 8, 4, 2, 0, -3, -6, -8, 11, 9, 5, 3, 1, -2, -5, -7,
- -13,-13,-13,-12,-11,-10, -8, -8, 0, 1, 2, 3, 4, 4, 4, 3,
- 3, 4, 5, 6, 6, 6, 5, 4, 3, 4, 4, 4, 3, 3, 3, 2,
- 10, 10, 11, 10, 9, 9, 8, 7, 6, 6, 6, 6, 5, 4, 3, 2,
- 0, 0, 0, -1, -2, -3, -4, -4,-10,-10,-11,-12,-13,-14,-14,-14,
- 16, 16, 17, 16, 15, 13, 12, 11, -1, -2, -3, -4, -4, -4, -4, -3,
- -4, -5, -6, -6, -6, -6, -6, -6, -5, -6, -6, -6, -6, -6, -5, -5,
- -13,-13,-13,-12,-11,-10, -8, -6, -9, -8, -7, -6, -4, -2, 0, 1,
- -2, -1, 1, 3, 5, 7, 8, 9, 5, 7, 9, 11, 13, 14, 15, 15,
- 16, 14, 11, 7, 2, -3, -7, -9, 14, 12, 8, 3, -1, -6, -9,-11,
- 11, 9, 4, 0, -4, -8,-11,-13, 8, 5, 1, -3, -6,-10,-12,-14,
- -18,-15, -9, -3, 1, 6, 9, 11,-17,-13, -7, -1, 3, 7, 11, 12,
- -15,-11, -5, 1, 5, 9, 12, 13,-13, -9, -3, 2, 5, 9, 11, 13,
- 22, 21, 19, 15, 10, 3, -4, -9, 20, 18, 15, 9, 2, -5,-12,-17,
- 16, 13, 8, 1, -7,-14,-20,-24, 10, 6, -1, -8,-15,-21,-25,-27,
- -25,-23,-20,-14, -7, 1, 9, 14,-23,-21,-16, -9, 0, 9, 16, 21,
- -20,-16,-10, -1, 8, 16, 22, 25,-15,-11, -3, 6, 14, 20, 25, 27,
- -4, -2, 0, 1, 2, 2, 2, 2, -5, -2, 0, 2, 3, 3, 3, 3,
- -6, -4, -1, 1, 2, 3, 3, 3, -7, -5, -2, 0, 1, 1, 2, 2,
- 2, 1, 1, 1, 1, 0, -2, -3, 3, 3, 2, 1, 0, -1, -3, -4,
- 4, 3, 2, 1, 0, -2, -4, -6, 5, 4, 3, 1, -1, -3, -5, -6,
- 5, 6, 6, 4, 2, 0, -2, -3, 3, 4, 4, 4, 3, 1, 0, -1,
- -2, -2, -1, -1, -1, -1, -2, -2, -5, -4, -3, -2, -2, -2, -3, -3,
- -1, -1, -1, -1, -1, -1, -1, -1, -3, -4, -4, -4, -3, -3, -3, -3,
- -1, -1, -1, -1, -1, -1, -1, -2, 5, 6, 6, 6, 6, 5, 4, 3,
- 4, 4, 4, 4, 4, 5, 6, 7, 0, -1, -1, -1, -1, 0, 1, 2,
- -2, -3, -3, -3, -3, -2, -1, 0, -3, -3, -4, -4, -4, -3, -2, -1,
- 0, -2, -4, -4, -2, 0, 2, 3, 0, -2, -3, -3, -1, 2, 4, 5,
- -1, -2, -4, -3, 0, 3, 5, 6, -2, -3, -4, -3, -1, 2, 4, 5,
- 9, 4, 0, -3, -3, -1, 0, 1, 8, 4, -1, -4, -3, -1, 1, 2,
- 6, 2, -3, -5, -4, -2, 0, 1, 5, 1, -3, -4, -4, -2, 0, 1,
- 5, 3, 1, -1, -4, -8,-10,-10, 3, 3, 2, 1, 0, -2, -3, -4,
- 1, 1, 1, 2, 3, 2, 1, 0, -1, 0, 1, 2, 3, 4, 3, 2,
- 0, 1, 2, 2, 1, -1, -3, -3, 0, 1, 1, 1, -1, -2, -4, -3,
- -3, -3, -3, -3, -3, -3, -1, 2, -4, -4, -3, 0, 3, 7, 12, 14,
- -5, -5, -6, -6, -6, -6, -6, -5, 2, 2, 2, 1, 0, 0, 0, 0,
- 4, 4, 3, 2, 1, 0, 0, 0, 6, 6, 5, 4, 2, 2, 1, 1,
- -7, -7, -6, -3, 0, 4, 7, 8, -1, -2, -3, -3, -2, -1, 1, 2,
- 3, 3, 1, -1, -2, -2, -2, -1, 6, 6, 4, 2, 0, -2, -2, -2,
- -6, -5, -2, 2, 5, 9, 11, 12, -4, -4, -2, 0, 2, 4, 5, 6,
- -3, -2, -2, -2, -2, -1, 0, 1, -2, -2, -2, -3, -3, -3, -3, -2,
- -7, -3, 1, 3, 3, 0, -3, -5, -6, -2, 3, 5, 4, 1, -3, -5,
- -5, -1, 4, 6, 5, 2, -3, -4, -4, 0, 5, 7, 6, 3, -1, -3,
- 0, 0, 0, 0, 0, 0, 0, 0, -2, -2, -3, -3, -3, -3, -2, -1,
- 6, 7, 8, 9, 9, 8, 7, 6, -4, -4, -5, -5, -6, -6, -5, -4,
- -9, -8, -6, -4, 0, 3, 6, 6, -5, -4, -1, 3, 5, 6, 5, 3,
- 1, 3, 6, 6, 4, 1, -2, -5, 6, 7, 5, 1, -3, -7,-10,-11,
- 10, 9, 5, 1, -3, -6, -6, -4, 5, 3, -1, -5, -6, -5, -2, 2,
- -2, -4, -6, -6, -4, 1, 6, 10, -6, -7, -7, -4, 1, 7, 11, 12,
- 6, 5, 3, 2, 0, 0, 0, 0, 2, 1, -1, -2, -3, -2, -1, -1,
- 0, -1, -2, -4, -4, -2, -1, 1, 0, 0, -1, -2, -1, 0, 2, 3,
- 0, -1, -2, -2, -2, -2, -1, -1, 5, 4, 2, 1, 0, 0, 0, 0,
- 6, 5, 3, 1, 0, 0, 0, 0, 2, 0, -2, -4, -4, -3, -2, -2,
- -7, -4, 0, 2, 2, 2, 2, 1, -7, -3, 0, 0, 0, 0, 0, 0,
- -4, -1, 1, 1, 0, 0, 0, 1, -1, 1, 2, 2, 2, 2, 3, 3,
- -2, 0, 2, 2, 1, 1, 1, 1, -1, 1, 2, 2, 1, 0, 0, -1,
- 0, 2, 4, 2, 0, -1, -2, -3, 1, 2, 3, 1, -2, -4, -6, -6,
- 1, 2, 2, 4, 5, 6, 4, 1, 0, -1, -1, -1, 0, 0, -2, -4,
- 0, 0, -1, -2, -2, -2, -4, -6, 2, 1, 0, 0, 1, 1, -1, -3,
- 1, 1, 1, 1, 1, 2, 3, 3, 0, 0, 1, 0, 1, 2, 4, 4,
- -1, -1, -1, -1, 0, 1, 2, 3, -4, -4, -5, -5, -5, -3, -1, 0,
- -6, -5, -5, -4, -3, -2, -1, -1, -1, 0, 0, 1, 1, 2, 3, 3,
- 0, 1, 1, 1, 2, 2, 3, 4, 0, 0, -1, -1, 0, 1, 2, 3,
- 0, 1, 1, 1, 0, 0, -1, -1, 1, 3, 3, 2, 1, -1, -2, -2,
- -2, 0, 2, 2, 2, 2, 1, 1, -9, -8, -4, -2, 1, 3, 3, 3,
- -1, -1, -1, -2, -3, -3, -3, -4, 0, 0, 0, -1, -2, -2, -3, -3,
- 2, 2, 2, 0, -1, -1, -1, -1, 5, 5, 4, 3, 2, 2, 2, 2,
- 6, 3, -1, -4, -3, -1, 1, 1, 2, -1, -3, -4, -1, 2, 2, 0,
- -1, -2, -2, 1, 4, 4, 1, -3, -2, -1, 1, 4, 6, 3, -3, -8,
- 3, 3, 2, 1, -1, -2, -2, -2, -4, -4, -2, -1, 1, 3, 4, 4,
- -4, -5, -5, -4, -2, 0, 2, 2, 7, 7, 4, 1, -1, -2, -3, -2,
- -1, 1, 3, 0, -4, -6, 0, 6, -2, 1, 4, 1, -4, -6, -1, 7,
- -3, 1, 4, 2, -3, -6, -1, 6, -2, 0, 3, 2, -2, -5, -1, 4,
- 1, -1, -2, 1, 4, 4, -1, -7, 1, -1, -4, -1, 5, 6, 0, -6,
- 3, 0, -4, -3, 3, 6, 2, -4, 3, 0, -5, -4, 1, 4, 1, -3,
- 2, 2, 3, 3, 3, 3, 2, 2, -4, -5, -6, -7, -7, -7, -7, -6,
- 1, 2, 3, 3, 3, 3, 2, 2, 0, 0, 1, 1, 1, 2, 2, 1,
- 3, -3, -3, 3, 4, -2, -2, 2, 3, -4, -4, 4, 4, -4, -4, 2,
- 4, -4, -4, 4, 4, -4, -3, 3, 3, -3, -4, 3, 3, -3, -3, 3,
- -2, -2, -2, -2, -2, -2, -1, -1, 6, 7, 8, 8, 8, 7, 6, 5,
- -5, -6, -7, -7, -8, -7, -6, -5, 1, 1, 2, 2, 2, 2, 1, 1,
- 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0,
- -2, -3, -2, -2, -2, -3, -3, -3, 2, 3, 5, 6, 4, 2, 1, 0,
- 8, 6, 2, 0, 0, 0, 0, 0, 4, 1, 0, 0, 0, -1, -1, -1,
- 1, -1, 0, 0, 0, -1, -2, -3, -2, -2, -1, 0, 0, -2, -4, -5,
- 3, 1, -1, -2, -3, -4, -5, -5, 2, 1, 0, 0, 1, 1, 0, 0,
- 0, -1, -1, 0, 2, 2, 2, 2, -1, -2, -1, 1, 2, 2, 2, 2,
- 0, -1, -2, -1, -1, -1, -1, 0, -1, -2, -2, -1, -1, 0, 0, 1,
- 2, 1, 1, 2, 2, 1, 1, 0, 6, 5, 3, 1, 0, -2, -4, -4,
- -3, -2, -1, 0, 1, 1, 0, -1, 0, 1, 3, 4, 5, 5, 3, 1,
- -1, -1, -1, 0, 1, 0, -1, -2, -2, -2, -2, -1, 0, -1, -2, -3,
- 0, -1, -2, -2, -1, -1, 0, 2, 1, -1, -2, -1, -1, -1, 0, 2,
- 1, 0, -2, -2, -2, -2, 1, 5, 1, -1, -2, -2, -2, 0, 5, 10,
- 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, 0, 0, 0, 1, 2,
- 1, 2, 2, 3, 4, 4, 6, 5, -3, -3, -3, -2, -2, -3, -3, -3,
- 1, -1, -2, -2, 0, 3, 5, 7, 2, 0, -2, -3, -2, 0, 2, 3,
- 3, 1, -2, -3, -3, -2, -1, -1, 3, 1, 0, -1, -1, -1, -1, -1,
- 1, 3, 5, 4, 2, -1, -3, -4, -3, -2, 1, 2, 1, 0, -1, -2,
- -5, -3, 0, 2, 2, 1, 0, 0, -3, -1, 1, 2, 2, 1, 0, 0,
- 0, -1, -1, -1, 1, 2, 3, 4, -3, -4, -4, -3, -1, 0, 0, 1,
- -2, -3, -2, -1, 1, 1, 1, 1, -2, -2, 0, 3, 4, 4, 3, 2,
- -4, -4, -3, -2, -1, 1, 2, 3, 0, 1, 1, 1, -1, -2, -3, -3,
- 3, 4, 5, 4, 2, -1, -3, -3, -2, -2, 0, 2, 2, 2, 1, 0,
- -4, 0, 5, 7, 4, -1, -4, -4, -1, 2, 4, 3, 0, -3, -3, -2,
- 2, 1, 0, -1, -2, -2, 0, 1, 0, 0, -1, -2, -2, -1, 1, 2,
- -4, -3, -2, -1, 0, 1, 2, 2, 10, 9, 5, 0, -3, -4, -3, -2,
- 1, -1, -2, -2, -1, 0, 0, 0, -2, -2, -1, 1, 1, 1, 0, -1,
- -5, -3, 0, 3, 4, 2, 0, -2, -2, -1, 0, 1, 1, 0, -1, -1,
- 3, 2, -1, -2, -2, -1, 1, 1, 7, 5, -1, -5, -6, -2, 2, 4,
- -2, 3, 3, -3, -4, 1, 2, -2, -3, 3, 4, -3, -4, 2, 3, -2,
- -3, 3, 4, -3, -4, 2, 3, -2, -4, 2, 4, -2, -3, 1, 2, -1,
- 4, 3, -1, -3, -3, -1, 1, 2, -4, -6, -4, 0, 4, 5, 4, 1,
- 0, 2, 5, 6, 2, -3, -5, -4, 1, 1, -1, -3, -5, -2, 2, 4,
- -1, 0, 1, 2, 2, 3, 3, 4, -1, 0, 1, 1, 0, -1, -1, -1,
- -1, 0, 1, 2, 2, 1, -1, -2, -3, -2, -1, 0, 0, -1, -2, -3,
- 1, 1, 1, 1, 0, 0, 1, 2, 1, 0, -1, 0, 0, 1, 1, 0,
- 1, -2, -4, -1, 1, 2, 1, 0, 1, -4, -7, -3, 1, 3, 2, 1,
- 1, 1, 1, 1, 1, 1, 0, -1, 1, 1, 1, 0, 1, 2, 2, 0,
- 1, 1, 0, 0, 0, 2, 0, -3, 3, 2, 0, -1, -1, -2, -6, -9,
- 0, 0, 0, 1, 0, 0, 1, 2, 1, 0, 0, 0, -1, -1, 0, 2,
- 0, 1, 1, 1, -1, -3, -2, 0, -7, -5, 1, 6, 6, 2, -1, -1,
- 3, 1, -1, -3, -4, -2, 1, 4, 2, 0, -2, -3, -4, -3, -1, 2,
- 2, 2, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1,
- -1, 1, 1, -2, -5, -6, -4, -1, -1, 1, 4, 3, 2, 0, 1, 2,
- -1, 0, 2, 3, 1, 0, 0, 1, -1, 0, 1, 0, 0, -1, -1, 0,
- 0, 1, 2, 2, 0, -2, -1, 1, -2, -1, -1, -2, -1, 2, 6, 8,
- -1, -1, -2, -3, -2, 0, 1, 2, -1, 0, 0, -1, -1, 0, -1, -1,
- 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, -1, -1, 1,
- -1, 0, 2, 2, -1, -3, -2, 3, 0, 2, 3, 0, -5, -7, -2, 4,
- -1, 0, 0, 0, -1, -2, -3, -3, -1, 0, -1, -2, -2, -2, -2, -2,
- 1, 1, 0, 0, 1, 2, 0, -1, 1, 2, 1, 2, 5, 6, 2, 0,
- -2, -4, -3, 0, 2, 2, 0, -3, 3, 1, 0, 1, 2, 1, -2, -3,
- 3, 1, 0, 0, 0, 0, 0, -1, 1, -1, -2, -2, -1, 1, 3, 3,
- 3, 2, 1, 2, 4, 3, 1, -2, -2, -4, -4, -3, -1, 0, -2, -3,
- 1, 0, -1, -1, 0, 1, 0, -1, 3, 2, 0, 0, 0, 1, 1, 0,
- 1, 1, 0, 0, 0, 0, 0, 0, 2, 3, 3, 2, 2, 2, 1, 1,
- 0, -1, -2, -3, -5, -5, -5, -4, 1, 1, 0, -1, 0, 1, 3, 3,
- -9, -6, -2, 0, 1, 1, 2, 2, -6, -2, 1, 2, 1, 1, 0, 1,
- -2, 1, 2, 2, 1, 1, 1, 1, 0, 2, 2, 1, 0, 1, 1, 1,
- 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, -3, -2, 0,
- -3, -3, -3, -2, -1, 3, 7, 9, 1, 2, 2, 2, 0, -2, -4, -3,
- 2, 0, -2, -1, 3, 4, -1, -6, 1, 0, -2, -3, -1, 3, 3, 0,
- 0, 3, 3, 0, -2, -1, 1, 1, -6, -1, 3, 2, -1, -2, 0, 1,
- 5, 3, 0, -2, -3, 0, 2, 1, 1, 1, 2, 2, 0, -2, -4, -7,
- -3, -2, 1, 2, 2, 1, -1, -4, 2, 2, 0, -2, -2, 0, 2, 2,
- 0, 0, -2, -3, -2, -1, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2,
- -2, -1, 0, 1, 0, 1, 2, 3, -4, -2, 0, 0, -1, 0, 2, 3,
- -2, -2, -2, -1, -1, 0, 2, 4, 0, 0, 0, 0, -1, -1, 0, 1,
- 0, -1, -1, -1, -1, -1, 0, 0, 6, 4, 2, 0, -1, -2, -1, -1,
- 0, 1, 1, 1, 1, -1, -5,-10, 1, 1, 1, 1, 1, 1, 0, -4,
- 1, 0, 1, 1, 1, 1, 1, -1, 2, 1, 1, 1, 0, 0, 0, 0,
- -3, 1, 4, 3, 3, 1, -1, 0, -4, 0, 1, 0, -1, 0, 0, 0,
- -5, 0, 2, 1, 1, 1, 0, -1, -1, 2, 1, -2, -2, -1, 0, -1,
- 2, 4, 5, 3, 0, -1, 1, 2, 0, 0, 1, 0, -2, -2, -1, -1,
- -2, -2, -2, -2, -3, -2, -1, 0, 0, 0, 1, 0, 0, 0, 1, 2,
- 0, -2, -2, -3, -1, 2, 2, -1, 1, 0, 0, 0, 1, 5, 3, -2,
- -1, -1, 0, -1, 0, 2, 0, -5, -1, 0, 1, 0, 0, 2, 2, -2,
- 3, 1, -1, -1, 0, 1, 1, 2, 1, 0, 0, 1, 1, 1, 1, 1,
- -10, -8, -2, 1, 2, 1, 1, 1, -1, 1, 2, 1, 0, 0, 0, 0,
- -1, -1, 0, 1, 2, 2, 2, 1, -1, -1, -1, 0, -1, -3, -5, -4,
- 1, 1, 2, 1, 1, 0, 0, 2, -1, -2, -1, -1, -1, 0, 2, 4,
- -3, -7, -5, 0, 2, 0, 0, 0, 3, -1, -2, 1, 2, 1, 1, 2,
- 1, -2, -1, 1, 2, 1, 0, 1, 0, -1, 0, 3, 2, -1, -1, -1,
- 2, 1, 1, 0, 0, 0, 0, 0, -9, -7, -2, 3, 3, 2, 1, 1,
- 3, 2, 0, -2, -2, -1, 1, 1, 0, -1, 0, 0, 1, 1, 0, 0,
- -2, -1, 1, 1, 1, 0, 0, 0, 1, 2, 1, -2, -4, -3, 1, 2,
- 1, 2, 1, -2, -3, 0, 3, 1, -1, -1, 0, 0, 1, 3, 0, -4,
- 2, 0, -1, 1, 2, -2, -2, 3, 2, 0, -1, 2, 3, -2, -4, 1,
- 0, 1, 1, 1, 2, -2, -6, -2, -1, 0, 0, 0, 2, 0, -2, -1,
- -1, -1, 1, 2, 1, -2, -3, -2, 3, -1, -2, -1, -1, 0, 1, 2,
- 10, 4, 0, 0, -1, -2, -2, -1, 3, -1, -2, -1, 0, -1, -1, 0,
- -5, 2, 7, 1, -4, -2, 1, 0, -2, 2, 3, -1, -3, 0, 2, 0,
- 2, 1, 0, 0, 1, 1, -1, -2, 1, -2, -2, -1, -1, -2, 0, 0,
- 0, 3, -2, -7, -1, 3, 0, 0, 1, 3, -3, -5, 2, 3, -1, 0,
- 0, 2, -2, -2, 4, 2, -2, 0, -1, 1, -1, 0, 2, -1, -2, 1,
- 4, 0, -3, -4, -2, 1, 2, 1, 0, 0, 3, 5, 3, 1, -1, -2,
- 1, 1, 1, -1, -3, -1, 1, 1, 1, -1, -2, -2, 0, 0, -1, -2
-};
-
-/* 6x16-entry codebook for intra-coded 8x8 vectors */
-DECLARE_ALIGNED(4, static const int8_t, svq1_intra_codebook_8x8)[6144] = {
- 4, 4, 3, 2, 2, 1, 0, -1, 4, 3, 3, 2, 1, 0, -1, -1,
- 3, 3, 2, 2, 1, 0, -1, -2, 3, 2, 2, 1, 0, -1, -2, -3,
- 2, 2, 1, 0, -1, -1, -2, -3, 2, 1, 0, 0, -1, -2, -3, -4,
- 1, 0, 0, -1, -2, -3, -4, -4, 0, 0, -1, -2, -2, -3, -4, -4,
- 2, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 3, 3,
- 1, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1,
- -1, 0, 0, 0, 0, 0, 1, 1, -2, -2, -1, -1, -1, -1, -1, -1,
- -3, -3, -3, -3, -3, -3, -2, -2, -5, -4, -4, -4, -4, -4, -4, -3,
- -4, -2, -1, 0, 1, 2, 2, 3, -4, -2, -1, 0, 1, 2, 3, 3,
- -4, -3, -1, 0, 1, 2, 3, 3, -4, -3, -1, 0, 1, 2, 3, 3,
- -5, -3, -1, 0, 1, 2, 3, 3, -5, -3, -1, 0, 1, 2, 3, 3,
- -5, -3, -1, 0, 1, 1, 2, 3, -5, -3, -2, -1, 0, 1, 2, 3,
- 4, 4, 5, 5, 6, 6, 7, 7, 2, 2, 2, 3, 3, 4, 4, 4,
- 0, 0, 0, 0, 1, 1, 1, 2, -2, -2, -2, -2, -1, -1, -1, 0,
- -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- -1, -2, -2, -2, -2, -2, -2, -2, -1, -1, -1, -1, -2, -2, -2, -2,
- 5, 3, 1, -1, -2, -3, -3, -3, 5, 3, 1, -1, -2, -3, -3, -3,
- 5, 3, 1, -1, -2, -3, -3, -3, 5, 3, 1, -1, -2, -3, -3, -3,
- 5, 4, 1, 0, -2, -3, -3, -3, 6, 4, 2, 0, -2, -2, -3, -3,
- 6, 4, 2, 0, -1, -2, -2, -3, 6, 4, 2, 1, -1, -2, -2, -2,
- -1, 1, 3, 3, 2, 0, -3, -6, -1, 1, 3, 4, 3, 0, -3, -6,
- -1, 1, 4, 4, 3, 1, -3, -6, -1, 1, 3, 4, 3, 1, -3, -6,
- -2, 1, 3, 4, 3, 1, -3, -6, -2, 1, 3, 4, 3, 1, -3, -7,
- -2, 1, 3, 3, 2, 0, -3, -7, -2, 0, 2, 3, 2, 0, -3, -6,
- 10, 9, 8, 6, 6, 5, 4, 4, 6, 5, 4, 3, 2, 2, 2, 1,
- 2, 1, 0, -1, -2, -2, -2, -1, -1, -2, -3, -4, -4, -4, -4, -3,
- -2, -3, -4, -4, -5, -4, -4, -3, -2, -2, -3, -3, -3, -3, -2, -2,
- -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 1, 1, 1, 1, 1, 2,
- -2, -1, 1, 2, 4, 5, 7, 8, -3, -2, 0, 1, 3, 5, 7, 8,
- -4, -3, -1, 0, 2, 4, 6, 7, -5, -4, -2, -1, 1, 3, 5, 7,
- -6, -5, -3, -2, 0, 2, 4, 6, -6, -5, -4, -2, -1, 1, 3, 5,
- -7, -6, -5, -3, -2, 0, 2, 3, -8, -7, -5, -4, -3, -1, 1, 2,
- 11, 9, 7, 5, 3, 1, -1, -1, 10, 8, 6, 3, 1, 0, -2, -2,
- 9, 7, 5, 2, 0, -2, -3, -4, 8, 6, 3, 1, -1, -3, -4, -4,
- 6, 4, 2, -1, -3, -4, -5, -5, 5, 3, 0, -2, -4, -5, -6, -6,
- 3, 1, -1, -3, -5, -6, -7, -7, 2, 0, -2, -4, -6, -6, -7, -7,
- 5, 6, 7, 7, 7, 8, 8, 8, 3, 4, 5, 5, 6, 6, 6, 6,
- 0, 2, 2, 3, 4, 4, 4, 5, -2, -1, 0, 1, 2, 2, 3, 3,
- -4, -3, -2, -1, 0, 1, 1, 2, -6, -5, -4, -3, -2, -2, -1, 0,
- -8, -7, -6, -6, -5, -4, -3, -3,-10, -9, -8, -8, -7, -6, -6, -5,
- 6, 5, 3, 1, -1, -3, -6, -8, 6, 5, 4, 2, -1, -3, -6, -8,
- 6, 5, 4, 2, 0, -3, -6, -8, 6, 5, 4, 2, 0, -3, -6, -8,
- 6, 6, 4, 2, 0, -3, -6, -8, 6, 5, 4, 2, 0, -3, -6, -8,
- 6, 5, 4, 2, 0, -3, -6, -8, 6, 5, 4, 2, -1, -3, -5, -8,
- 11, 10, 9, 8, 7, 6, 5, 4, 8, 8, 7, 6, 5, 4, 3, 2,
- 6, 5, 4, 4, 2, 2, 1, 0, 3, 3, 2, 1, 0, 0, -1, -2,
- 1, 1, 0, -1, -2, -2, -3, -3, -1, -1, -2, -3, -4, -4, -5, -5,
- -3, -4, -4, -5, -6, -6, -7, -7, -5, -5, -6, -7, -8, -8, -8, -8,
- -14,-13,-12,-11, -9, -7, -6, -4,-12,-11,-10, -9, -7, -5, -3, -1,
- -10, -9, -7, -6, -3, -2, 0, 2, -8, -6, -4, -2, 0, 2, 4, 5,
- -5, -3, 0, 2, 4, 5, 7, 8, -2, 0, 2, 4, 6, 8, 9, 10,
- 0, 3, 5, 7, 8, 10, 11, 12, 3, 5, 7, 8, 10, 11, 12, 12,
- -19,-19,-18,-18,-17,-16,-15,-14,-15,-15,-14,-13,-12,-11,-10, -9,
- -11,-10, -9, -8, -6, -5, -4, -3, -6, -5, -3, -2, -1, 0, 1, 2,
- -1, 0, 2, 3, 4, 5, 6, 6, 4, 6, 7, 8, 9, 10, 10, 10,
- 9, 10, 11, 12, 13, 14, 14, 14, 12, 14, 14, 15, 16, 16, 16, 16,
- 22, 21, 19, 17, 14, 11, 9, 5, 20, 19, 17, 14, 11, 8, 4, 1,
- 17, 15, 13, 10, 6, 3, 0, -4, 13, 11, 8, 5, 1, -2, -5, -9,
- 9, 6, 3, -1, -4, -7,-11,-13, 4, 0, -3, -6, -9,-12,-15,-17,
- -2, -5, -8,-11,-14,-16,-18,-20, -8,-10,-13,-16,-17,-19,-21,-22,
- 17, 18, 18, 18, 17, 16, 16, 14, 16, 16, 15, 15, 14, 13, 12, 11,
- 12, 12, 11, 10, 9, 8, 7, 5, 7, 6, 6, 4, 3, 2, 1, -1,
- 1, 0, -1, -2, -3, -4, -5, -6, -5, -6, -7, -8, -9,-10,-11,-12,
- -11,-12,-13,-14,-15,-16,-16,-17,-16,-17,-17,-18,-19,-20,-20,-20,
- 0, 0, 0, 0, -1, -1, -2, -3, 1, 0, 0, 0, 0, -1, -2, -3,
- 1, 1, 0, 0, -1, -1, -2, -2, 1, 1, 1, 0, 0, -1, -1, -2,
- 2, 1, 1, 1, 0, -1, -1, -2, 2, 2, 1, 1, 0, 0, -1, -2,
- 2, 2, 1, 1, 1, 0, -1, -1, 2, 2, 1, 1, 1, 0, 0, -2,
- 0, -1, -1, 0, 0, 1, 2, 3, 0, -1, -1, 0, 1, 1, 2, 2,
- -1, -1, -1, -1, 0, 1, 2, 2, -1, -1, -2, -1, 0, 1, 1, 2,
- -1, -2, -2, -1, 0, 0, 1, 2, -1, -2, -2, -2, -1, 0, 1, 2,
- -1, -1, -2, -1, 0, 0, 1, 2, -1, -1, -1, -1, 0, 1, 1, 2,
- 3, 2, 2, 2, 1, 1, 0, 0, 3, 2, 2, 2, 2, 1, 0, 0,
- 2, 2, 2, 1, 1, 1, 0, 0, 2, 2, 1, 1, 1, 0, 0, -1,
- 1, 1, 1, 0, 0, 0, -1, -1, 0, 0, -1, -1, -1, -1, -1, -1,
- -2, -2, -2, -2, -2, -2, -2, -2, -2, -3, -3, -3, -2, -2, -2, -2,
- 5, 2, 0, 0, -1, 0, 0, 0, 4, 2, 0, -1, -1, -1, 0, -1,
- 4, 1, -1, -1, -2, -1, -1, -1, 4, 1, -1, -1, -2, -1, -1, -1,
- 4, 1, -1, -2, -2, -1, -1, -1, 4, 1, -1, -2, -2, -1, -1, -1,
- 4, 1, -1, -1, -1, -1, -1, -1, 4, 2, 0, -1, 0, 0, 0, -1,
- -2, -1, 0, 1, 1, 1, 1, 1, -3, -1, 0, 1, 1, 1, 1, 1,
- -3, -1, 0, 1, 1, 1, 1, 1, -3, -1, 0, 1, 1, 1, 1, 1,
- -3, -2, 0, 1, 2, 2, 1, 1, -4, -2, 0, 1, 2, 2, 2, 2,
- -5, -3, -1, 1, 1, 2, 1, 2, -5, -3, -2, 0, 1, 1, 1, 1,
- 3, 3, 1, 0, -2, -4, -4, -5, 3, 3, 2, 0, -1, -2, -3, -4,
- 2, 2, 1, 1, 0, -1, -2, -2, 1, 1, 1, 1, 1, 0, 0, 0,
- 0, 0, 0, 1, 1, 1, 1, 1, -2, -1, -1, 0, 0, 1, 2, 2,
- -3, -2, -2, -1, 0, 1, 2, 3, -3, -3, -2, -1, 0, 1, 2, 3,
- -3, -3, -3, -3, -3, -2, -2, -2, -3, -3, -2, -2, -2, -1, -1, -1,
- -2, -2, -2, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 2, 2, 2, 2,
- 1, 1, 1, 2, 2, 3, 3, 3, 2, 2, 2, 2, 3, 3, 3, 3,
- -8, -7, -5, -3, -2, -1, 0, -1, -4, -3, -1, 0, 1, 2, 1, 1,
- -1, 1, 2, 3, 3, 2, 2, 1, 1, 2, 3, 3, 2, 2, 1, 0,
- 2, 3, 3, 2, 1, 0, 0, -1, 1, 2, 1, 0, -1, -1, -1, -1,
- 1, 1, 0, -1, -1, -2, -2, -1, 1, 1, 0, 0, -1, -1, 0, -1,
- -4, -3, -2, 0, 1, 2, 3, 3, -4, -3, -2, 0, 1, 2, 2, 2,
- -3, -3, -2, -1, 0, 1, 1, 1, -2, -2, -2, -1, -1, 0, 0, 0,
- 0, -1, -1, -1, -1, -1, -1, -1, 2, 1, 1, 0, 0, -1, -1, -2,
- 3, 3, 3, 1, 0, -1, -2, -2, 5, 4, 4, 2, 1, 0, -1, -2,
- 0, 0, 0, 0, 1, 2, 3, 3, 0, -1, 0, 0, 1, 2, 3, 3,
- 0, -1, 0, 0, 1, 2, 3, 2, 0, 0, 0, 1, 1, 2, 2, 2,
- 2, 1, 1, 1, 1, 1, 1, 0, 2, 2, 2, 1, 0, 0, -1, -2,
- 2, 1, 0, 0, -2, -3, -5, -6, 0, -1, -1, -3, -5, -6, -8, -9,
- -2, 0, 1, 2, 2, 1, -1, -4, -2, 0, 2, 2, 2, 1, -1, -4,
- -2, 0, 2, 2, 2, 1, -1, -3, -2, 0, 2, 2, 2, 1, -1, -3,
- -2, -1, 2, 2, 2, 1, -1, -3, -2, -1, 1, 2, 2, 1, -1, -3,
- -3, -1, 1, 2, 2, 1, -1, -3, -2, -1, 1, 2, 2, 1, -1, -3,
- -1, 1, 1, -1, -3, -3, 0, 4, -1, 1, 1, -1, -3, -3, 0, 4,
- -1, 1, 1, 0, -3, -3, 0, 4, -1, 1, 2, 0, -3, -3, 0, 5,
- 0, 1, 2, 0, -3, -4, 0, 4, 0, 1, 2, 0, -3, -4, 0, 5,
- 0, 1, 2, 0, -3, -3, 0, 4, 0, 1, 2, -1, -2, -2, 0, 4,
- 6, 6, 5, 6, 5, 5, 5, 5, 2, 2, 2, 2, 2, 2, 2, 2,
- 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -2, -2, -2, -2,
- -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 0, 0, 0, 0, 0,
- -1, -2, -2, -2, -2, -2, -2, -1, -3, -3, -3, -3, -3, -3, -3, -2,
- -3, -4, -4, -3, -3, -3, -2, -2, -2, -2, -2, -2, -1, -1, 0, 0,
- 0, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6,
- 4, 1, -2, -3, -3, -1, 1, 3, 4, 1, -2, -4, -3, -1, 1, 3,
- 5, 1, -2, -4, -3, -1, 1, 4, 5, 1, -2, -3, -3, -1, 2, 4,
- 5, 1, -2, -3, -3, -1, 2, 4, 4, 0, -3, -4, -3, -1, 2, 4,
- 4, 0, -3, -3, -3, -1, 1, 3, 3, 0, -2, -3, -2, -1, 1, 3,
- -3, -4, -4, -4, -4, -4, -4, -4, -1, -1, -1, -1, -1, -1, -2, -2,
- 2, 1, 1, 2, 2, 1, 1, 1, 3, 3, 3, 4, 4, 3, 3, 3,
- 3, 3, 3, 4, 4, 4, 3, 3, 1, 2, 1, 2, 2, 2, 2, 2,
- -2, -2, -2, -1, -1, -1, 0, 0, -4, -4, -4, -4, -3, -3, -3, -3,
- -1, -2, -3, -3, -2, -2, -1, 0, 0, -1, -2, -2, -2, -1, 0, 1,
- 2, 1, -1, -1, -1, -1, 0, 1, 3, 1, 0, -1, -1, 0, 0, 1,
- 3, 2, 0, -1, 0, 0, 0, 1, 3, 1, 0, -1, 0, 0, 0, 1,
- 3, 1, 0, -1, 0, 0, 0, 1, 2, 1, 0, 0, 0, 0, 0, 1,
- 0, 0, 0, 1, 1, 2, 3, 4, 0, 0, -1, 0, 0, 0, 2, 3,
- 0, -1, -1, -1, -1, -1, 0, 1, 0, -1, -1, -1, -1, -1, -1, 0,
- 0, 0, -1, -1, -1, -2, -2, -1, 1, 0, 0, -1, -1, -2, -2, -1,
- 2, 2, 1, 0, -1, -1, -1, -1, 3, 3, 2, 1, 0, -1, -1, 0,
- 1, 0, 1, 0, 0, -1, -2, -1, 0, 0, 0, 0, -1, -1, -2, -1,
- 0, -1, 0, 0, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0,
- -1, -1, -1, 0, 0, 0, 1, 1, -1, -1, -1, 0, 1, 1, 2, 3,
- -2, -2, -1, 0, 1, 2, 3, 4, -2, -2, -1, 0, 1, 2, 4, 5,
- -3, -1, 1, 0, 0, -1, 0, 1, -3, 0, 1, 0, -1, -1, 0, 2,
- -3, 0, 1, 0, -1, -1, 0, 2, -2, 1, 2, 0, -1, -1, 0, 2,
- -2, 1, 2, 0, -1, -1, 0, 2, -2, 1, 2, 0, -1, -1, 0, 2,
- -1, 2, 2, 0, -1, -1, 0, 2, -1, 1, 1, 0, -1, -1, -1, 1,
- -2, -2, -1, 1, 3, 4, 3, 1, -2, -2, -1, 0, 2, 3, 2, 0,
- -2, -2, -1, 0, 1, 2, 1, -1, -1, -1, -1, 0, 1, 2, 1, -1,
- -1, -1, -1, 0, 1, 1, 0, -2, 0, -1, -1, 0, 1, 1, 0, -1,
- 0, -1, -1, 0, 1, 1, 1, -1, 0, -1, -1, 0, 0, 1, 0, -1,
- -2, -1, 0, 1, 1, 1, 1, 1, -2, -1, 0, 0, 0, 0, 0, 0,
- -2, -1, -1, 0, -1, -1, -2, -2, -2, -1, -1, -1, -1, -2, -2, -3,
- -1, 0, 1, 1, 0, -1, -2, -2, 1, 2, 3, 3, 2, 1, 0, 0,
- 1, 2, 3, 3, 3, 2, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0,
- 0, -1, -1, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, -1, 0, 0, 1, 1, 0, 0, 0,
- -3, -2, -1, -1, -1, -1, 0, -1, -5, -5, -4, -3, -2, -2, -2, -1,
- 1, 1, 1, 1, 2, 1, 0, -1, 1, 1, 1, 2, 1, 1, 0, -1,
- 1, 1, 1, 1, 1, 1, 0, -2, 2, 1, 1, 1, 1, 1, 0, -2,
- 1, 1, 0, 0, 0, 0, -1, -3, 1, 1, 0, 0, 0, -1, -2, -3,
- 1, 1, 0, 0, -1, -1, -2, -4, 1, 0, 0, -1, -2, -2, -3, -4,
- 8, 7, 5, 3, 2, 1, 1, 1, 2, 1, 0, 0, -1, -1, -2, -1,
- -1, -1, -1, -2, -2, -2, -2, -1, -1, -1, -1, -1, 0, -1, -1, 0,
- 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0,
- -1, 0, 0, 0, 0, 0, -1, -1, -2, -2, -1, -1, -1, -2, -2, -1,
- 9, 4, 0, -2, -2, -2, -1, -1, 7, 2, -1, -2, -2, -1, 0, 0,
- 4, 0, -2, -2, -1, 0, 1, 1, 1, -2, -2, -2, -1, 0, 1, 1,
- -1, -2, -2, -1, 0, 1, 1, 1, -1, -2, -1, 0, 1, 1, 1, 0,
- -1, -1, 0, 1, 1, 1, 0, -1, 0, -1, 0, 1, 0, 0, -1, -1,
- 0, 1, 1, 1, 1, 1, 0, 0, 1, 2, 2, 2, 1, 0, 0, 0,
- 2, 2, 2, 2, 1, 0, -1, -1, 1, 1, 1, 0, -1, -2, -2, -2,
- 0, 0, 0, -1, -2, -3, -2, -2, -1, -1, -1, -2, -2, -2, -1, 0,
- -1, -1, -1, -1, 0, 0, 1, 2, -1, -1, -1, 0, 1, 2, 3, 4,
- -1, -1, 0, 0, -1, -2, -3, -3, -1, -1, 0, 0, 0, -1, -1, -1,
- -2, -2, -1, 0, 1, 1, 1, 1, -2, -2, -2, 0, 1, 2, 3, 3,
- -1, -1, -1, 0, 1, 3, 3, 3, 1, 0, 0, 0, 1, 1, 2, 2,
- 2, 2, 1, 0, 0, -1, -1, -1, 3, 2, 1, 0, -1, -2, -3, -3,
- -1, -1, -1, -2, -2, -3, -4, -5, 0, 0, 0, -1, -1, -3, -3, -4,
- 1, 1, 1, 0, 0, -1, -2, -3, 2, 2, 2, 1, 1, 0, -1, -1,
- 2, 2, 2, 2, 1, 1, 0, -1, 2, 2, 2, 2, 2, 1, 0, 0,
- 1, 1, 2, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, -1,
- -2, 2, 3, 1, -1, 1, 1, -1, -3, 2, 3, 0, -1, 1, 1, -1,
- -3, 2, 3, 0, -1, 1, 1, -1, -4, 2, 3, 0, -1, 1, 1, -2,
- -4, 1, 3, 0, -1, 1, 1, -2, -4, 1, 3, -1, -2, 1, 1, -2,
- -3, 1, 2, 0, -1, 1, 1, -2, -3, 1, 2, 0, -1, 1, 1, -1,
- -1, -1, -1, -2, -2, -2, -2, -2, 1, 1, 1, 1, 0, 0, 0, 0,
- 1, 2, 2, 2, 2, 2, 2, 2, 0, 0, 1, 1, 1, 2, 2, 2,
- -2, -2, -1, -1, -1, 0, 0, 0, -3, -3, -3, -3, -3, -3, -3, -2,
- -1, -1, -1, -1, -2, -2, -2, -2, 4, 4, 4, 4, 4, 3, 3, 2,
- -3, -3, -2, -1, 0, 1, 2, 5, -3, -3, -3, -2, -1, 1, 3, 6,
- -3, -3, -2, -2, 0, 2, 3, 5, -3, -2, -2, -2, 0, 1, 3, 5,
- -2, -2, -2, -1, -1, 1, 3, 5, -2, -2, -1, -1, 0, 1, 2, 4,
- -1, -1, -1, -1, 0, 1, 1, 4, -1, -1, -1, -1, 0, 1, 2, 3,
- 0, -1, 0, 1, 1, 0, -1, -1, 0, 0, 0, 1, 2, 0, -1, -1,
- 1, 0, -1, 0, 1, 0, 0, 0, 1, -1, -2, -1, 0, 0, 0, 0,
- 1, -2, -3, -1, 0, 0, 0, 1, 1, -1, -3, -2, 0, 1, 1, 2,
- 1, -1, -2, -1, 0, 1, 1, 2, 2, 0, -1, 0, 1, 1, 2, 2,
- 1, 1, 1, 1, 0, 0, 1, 2, -1, 0, 0, -1, 0, 0, 0, 1,
- -3, -2, -1, -1, -1, 0, 1, 1, -4, -2, -1, 0, 0, 1, 1, 1,
- -3, -2, 0, 0, 1, 1, 1, 1, -3, -1, 0, 1, 1, 1, 0, 0,
- -1, 0, 1, 1, 1, 0, 0, -1, 0, 1, 2, 2, 1, 0, 0, -1,
- -4, -4, -4, -3, -2, -1, -1, -1, -2, -2, -2, -1, 0, 0, 0, 0,
- -1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1,
- 0, 0, 1, 1, 2, 2, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0,
- 0, 0, 0, 1, 1, 1, 1, 0, -1, 0, 0, 1, 1, 1, 0, 0,
- 1, 2, 2, 2, 1, -1, -2, -4, 1, 1, 2, 2, 1, 0, -2, -4,
- 0, 1, 1, 1, 1, 0, -1, -3, -1, 0, 1, 1, 0, 0, -1, -2,
- -1, 0, 1, 1, 1, 0, 0, -1, -2, -1, 0, 0, 0, 0, 0, -1,
- -1, -1, 0, 1, 1, 0, 0, 0, -1, 0, 1, 1, 1, 1, 1, 0,
- 2, 2, 0, -1, -2, -1, -1, -2, 1, 1, -1, -2, -2, -1, -1, -2,
- 1, 1, -1, -2, -2, 0, 0, -1, 1, 1, 0, -2, -1, 1, 1, 0,
- 1, 1, 0, -1, -1, 1, 2, 1, 1, 1, 0, -1, -1, 1, 2, 1,
- 1, 1, 0, -1, -1, 1, 1, 1, 1, 1, 0, -1, 0, 1, 1, 1,
- 0, 0, -1, -2, -4, -4, -4, -4, 3, 3, 3, 2, 1, 0, 0, 0,
- 3, 3, 3, 3, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 1,
- -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, 0, 0, -1, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0,
- -1, -1, 0, -1, -1, 1, 2, -1, 1, 1, 0, 0, 0, 2, 3, -1,
- 1, 1, 0, -1, -1, 1, 3, -1, 1, 1, 0, -2, -2, 0, 1, -2,
- 1, 0, 0, -2, -2, 0, 1, -3, 0, 0, 0, 0, -1, 1, 1, -3,
- 0, 1, 1, 0, 1, 2, 1, -3, -1, 0, 1, 1, 1, 2, 1, -4,
- -4, -3, 0, 1, 1, 1, 0, 0, -4, -2, 0, 1, 1, 1, 0, -1,
- -3, -1, 1, 1, 1, 0, -1, -1, -1, 1, 1, 1, 1, 0, -1, 0,
- 1, 2, 2, 1, 0, -1, 0, 0, 2, 2, 1, 0, -1, -1, 0, 1,
- 2, 1, 0, -1, -2, -1, 0, 1, 2, 2, 0, -1, -2, -1, 1, 1,
- 1, 1, 0, 0, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, -1, -1, -1, -1, -1,
- 1, 0, 0, -1, -1, -1, -1, -1, 2, 1, 0, 0, -1, -1, -1, -1,
- 5, 3, 2, 1, 0, 0, 0, 0, 6, 5, 3, 2, 1, 0, 0, 0,
- 4, 4, 3, 1, 0, 0, 0, 1, 3, 3, 2, 1, 0, 0, 0, 1,
- 2, 2, 1, 0, -1, -1, 0, 1, 0, 0, 0, -1, -1, -1, 0, 1,
- 0, 0, -1, -1, -2, -1, 0, 2, 0, -1, -1, -2, -2, -2, 0, 1,
- 0, -1, -1, -2, -2, -2, -1, 0, 0, 0, -1, -2, -2, -2, -1, 0,
- 0, 0, -1, -1, -1, 0, 2, 3, 0, -1, -2, -2, -1, -1, 1, 2,
- 1, 0, -1, -1, -1, 0, 0, 0, 1, 1, 1, 0, 0, 0, -1, -1,
- 1, 2, 1, 0, 0, -1, -1, -1, -1, 0, 0, 0, -1, -1, -1, -1,
- -3, -2, -1, -1, 0, 1, 1, 2, -4, -3, -1, 1, 2, 3, 5, 5,
- 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
- 0, 0, 0, -1, 0, 0, 0, 1, -1, -1, -2, -2, -2, -1, -1, 0,
- 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3,
- 1, 1, 1, 1, 2, 2, 1, 1, -4, -3, -4, -4, -4, -4, -3, -3,
- -1, 0, 1, 2, 2, 3, 3, 3, -1, -1, -1, -1, 0, 0, 0, 0,
- 0, 0, -1, -2, -2, -3, -3, -2, 3, 2, 1, 0, -1, -2, -2, -2,
- 4, 3, 2, 1, 1, 0, 0, 0, 2, 2, 1, 1, 0, 1, 1, 1,
- 0, -1, -1, -1, -1, 0, 0, 1, -2, -2, -2, -2, -2, -1, 0, 0,
- 1, -1, 0, 2, 1, -2, -1, 1, 1, -1, 0, 2, 1, -2, -2, 1,
- 1, -1, 0, 3, 2, -2, -1, 1, 0, -2, 0, 3, 2, -2, -2, 1,
- 0, -2, 0, 3, 2, -2, -2, 1, 0, -2, 0, 3, 1, -2, -1, 1,
- 0, -2, 0, 2, 1, -2, -2, 1, 0, -1, 0, 2, 1, -2, -1, 1,
- 0, 1, 2, 2, 3, 3, 2, 2, 0, 1, 1, 2, 3, 3, 2, 1,
- 0, 0, 1, 2, 2, 2, 2, 1, -1, 0, 0, 1, 1, 1, 1, 1,
- -1, -1, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1,
- -2, -2, -2, -2, -2, -2, -2, -1, -2, -2, -2, -2, -2, -2, -2, -1,
- 0, 0, -1, -2, -1, 0, 3, 5, 0, 0, -1, -1, -1, 0, 2, 4,
- 1, 1, 0, 0, -1, -1, 1, 2, 1, 2, 1, 1, 0, -1, -1, 0,
- 0, 1, 2, 1, 0, -1, -2, -2, -1, 0, 1, 2, 1, 0, -3, -3,
- -2, -1, 1, 2, 2, 0, -2, -4, -2, -1, 0, 2, 2, 1, -1, -3,
- 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, -1, 0, 0, 0, 0, 0,
- -1, -1, -1, -1, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, 0,
- -1, -1, -1, -1, -1, -1, -1, 0, -1, 0, 0, 0, 0, -1, -1, 0,
- 0, 0, 1, 1, 0, 0, 0, 1, 3, 3, 3, 4, 3, 3, 3, 3,
- 5, 1, -2, -2, 0, 0, 0, -1, 4, -1, -3, -1, 0, 0, 0, -1,
- 3, -1, -1, 0, 1, 1, 0, -1, 2, 0, 0, 1, 1, 1, 0, -2,
- 1, 0, 0, 1, 1, 1, 0, -2, 0, -1, -1, -1, 0, 0, 0, -1,
- 0, -1, -1, -1, -1, 0, 0, -1, 2, 1, 0, 0, 0, 1, 0, 0,
- 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0,
- 1, -1, -1, 0, 0, 0, 0, 0, 2, 0, -1, -1, -1, -1, -1, 0,
- 3, 1, -1, -1, -2, -2, -2, -1, 4, 2, 1, 0, -1, -2, -2, -1,
- 2, 1, 0, 0, -1, -1, 0, 0, 0, -1, -1, -1, -1, 0, 1, 1,
- 0, 1, 2, 2, 2, 1, -1, -3, 0, 0, 1, 1, 1, 0, -1, -2,
- 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, -1, 0, 0, 1, 1, 0,
- 0, 0, -1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0,
- 0, 0, 1, 1, 2, 1, -1, -3, 0, 0, 0, 1, 1, -1, -4, -5,
- -2, -2, -2, -1, 0, 2, 2, 2, 0, 0, 0, 0, 1, 1, 1, 0,
- 1, 1, 1, 1, 1, 0, -2, -3, 0, 0, 1, 1, 0, -1, -3, -4,
- -1, -1, 0, 1, 0, 0, -2, -3, -1, -1, 0, 1, 1, 1, 0, -1,
- 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0,
- 0, 1, 0, 0, 1, 1, 1, 2, 1, 2, 0, 0, 0, 0, -1, 1,
- 0, 2, 0, -1, 1, 0, -1, 0, 0, 1, 0, 0, 2, 1, 0, 1,
- 0, 1, -1, 0, 2, 2, 0, 1, -1, 0, -1, -1, 2, 1, 1, 2,
- -2, -2, -3, -2, 0, 1, 1, 1, -2, -2, -3, -3, -1, -1, -1, 0,
- -3, -1, 0, 1, 2, 1, 1, 0, -3, -1, 0, 1, 2, 1, 1, 1,
- -2, 0, 0, 1, 1, 1, 1, 1, -1, 0, 0, 0, 0, 0, 0, 0,
- -2, 0, 0, 0, 0, -1, -1, 0, -2, 0, 0, 0, 0, 0, -1, -1,
- -3, 0, 1, 1, 1, 1, 0, 1, -5, -2, 0, 1, 2, 2, 1, 2,
- -2, -1, -1, 0, 0, 1, 2, 3, 0, 0, 1, 1, 0, 0, 1, 2,
- 0, 0, 1, 0, -1, -1, 0, 1, -1, -1, -1, -1, -2, -2, -1, 0,
- -2, -2, -2, -2, -2, -1, 0, 1, 0, 0, 0, -1, 0, 1, 2, 2,
- 2, 1, 0, 0, 0, 1, 2, 2, 2, 1, 0, -1, -1, -1, 0, 0,
- 0, 1, 1, 1, 1, 1, -1, -4, -1, -1, 0, 1, 1, 1, 0, -3,
- -2, -1, 0, 0, 1, 2, 2, -2, -1, 0, 0, 0, 0, 2, 3, -1,
- -1, 0, 0, 0, 0, 1, 2, 0, 0, 0, -1, -2, -1, 1, 1, 0,
- 0, 0, -1, -2, -2, 0, 2, 1, 0, 0, -1, -2, -1, 1, 2, 2,
- 1, 0, 0, 0, -2, -3, -2, -3, 0, 0, 1, 0, -2, -2, -1, -1,
- 0, -1, 1, 1, -1, -1, 0, 0, 0, -1, 1, 1, -1, -1, 0, 0,
- 0, 1, 2, 1, -1, -1, 0, 1, 1, 2, 3, 2, 0, 0, 1, 2,
- -1, 0, 2, 1, 0, 0, 2, 3, -2, -1, 0, 0, -1, 0, 1, 2,
- 1, 1, 0, -1, -2, -2, -1, 1, 1, 1, 1, -1, -2, -2, 0, 2,
- 1, 1, 1, -1, -1, -1, 0, 2, 0, 0, 0, 0, 0, 0, 1, 2,
- -1, -1, -1, 0, 0, 0, 1, 2, -1, -2, -1, 1, 1, 1, 0, 0,
- -1, -2, -1, 1, 2, 2, 0, -1, -1, -2, -1, 2, 2, 2, 0, -1,
- -1, -1, -1, -2, -1, -1, 0, 1, 0, 0, -1, -1, -1, 0, 1, 2,
- 1, 0, 0, 0, 0, 1, 1, 2, 1, 1, 0, 0, 1, 1, 1, 1,
- 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, -1, -1, -1,
- 1, 2, 1, 0, -1, -2, -2, -3, 2, 2, 1, 0, -2, -3, -4, -4,
- -4, -2, 1, 1, 1, 1, 0, 0, -2, 0, 1, 0, 0, 0, 0, 0,
- 0, 1, 1, -2, -2, -1, 0, 1, 2, 2, 1, -2, -2, -1, 1, 2,
- 1, 2, 1, -2, -2, -1, 1, 2, -1, 1, 1, -1, -1, -1, 0, 1,
- -2, 0, 1, 1, 0, -1, -1, 0, -2, 0, 2, 2, 1, -1, -1, 0,
- 1, 1, 0, 0, 0, 1, 0, 0, -2, -3, -3, -2, -2, -1, 0, 0,
- -3, -4, -3, -2, -1, 0, 0, 0, -1, -1, 0, 1, 2, 3, 2, 1,
- 0, 1, 2, 3, 3, 3, 2, 1, 1, 1, 1, 2, 1, 0, 0, -1,
- 0, 0, 0, 0, -1, -1, -1, -1, 0, -1, -1, 0, 0, 0, 0, 0,
- 1, 1, 0, 0, -1, -1, 0, 2, 0, 0, 1, 0, -1, -1, 1, 1,
- -2, -1, 0, 1, 1, 1, 1, 1, -3, -3, 0, 2, 2, 1, 1, 0,
- -2, -2, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, -1, -1,
- 3, 1, -1, -3, -2, -1, 0, 1, 4, 2, -1, -3, -3, -1, 1, 2,
- 0, 0, 0, -1, -1, -1, -1, -1, 1, 2, 1, 0, 0, 0, -1, -1,
- 2, 3, 3, 2, 1, 0, -1, -1, 3, 4, 4, 2, 1, 0, -1, -2,
- 3, 3, 2, 1, 0, -1, -2, -2, 1, 1, 0, -1, -1, -2, -2, -3,
- 0, 0, 0, -1, -1, -2, -2, -2, -1, -1, -1, -1, -1, -2, -2, -1,
- 1, 2, 2, 2, 2, 1, 2, 2, 0, 1, 1, 1, 1, 0, 0, 0,
- 0, 0, 0, 1, 1, 0, -1, -2, 0, 0, 0, 0, 1, 0, -1, -4,
- 1, 0, 0, 0, 0, 0, -2, -5, 1, 0, 0, 0, 0, 0, -1, -4,
- 1, 0, -1, 0, 0, 0, -1, -3, 0, -1, -1, 0, 1, 1, 1, -1,
- -2, -1, 0, 0, -1, -1, -1, -2, -1, 0, 0, 0, -1, -1, -2, -2,
- 0, 1, 1, 0, -1, -1, -1, -2, 0, 1, 1, 0, 0, 0, -1, -1,
- 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 2, 2, 1,
- 1, 1, 0, 0, 1, 2, 2, 1, 1, 1, 0, -1, 0, 1, 1, 0,
- 4, 2, 1, 0, 0, 1, 1, 1, 4, 2, 1, 0, 0, 0, 0, 1,
- 3, 1, 0, 0, -1, -1, -1, 0, 1, 0, 0, -1, -1, -2, -1, 0,
- 0, 0, 0, 0, -1, -1, -1, 0, -1, -1, 0, 0, -1, -1, 0, 1,
- -2, -1, 0, -1, -1, 0, 0, 1, -2, -2, -1, -2, -1, 0, 0, 1,
- 0, 1, 1, 1, 2, 1, 0, -1, -1, -1, -1, 0, 0, -1, -2, -2,
- -1, 0, -1, 0, 0, -1, -2, -1, 0, 0, 0, 0, 0, 0, 1, 2,
- 0, 0, 0, 0, 0, 0, 2, 3, -1, 0, -1, -1, -1, -1, 0, 3,
- -1, 0, 0, -1, -1, -2, 0, 3, 0, 0, 0, 0, -1, -1, 1, 4,
- 2, 2, 0, 0, 0, 0, 0, 1, 1, 1, -1, -2, -1, -2, -1, 1,
- -1, -1, -2, -2, -2, -3, -2, 0, -1, 0, -1, -1, -1, -2, -1, 1,
- 1, 1, 0, 0, 1, 0, 0, 1, 2, 2, 0, 0, 1, 0, 0, 1,
- 2, 2, 0, 0, 0, 0, -1, -1, 2, 2, 0, 0, 1, 0, -1, -1,
- -1, 0, 1, 1, 0, -1, -1, -1, 1, 2, 3, 2, 1, 0, 0, 0,
- 0, 1, 1, 1, 0, -1, 0, 0, -2, -2, -1, 0, 1, 0, 0, 0,
- -2, -2, -1, 2, 2, 2, 1, 0, -2, -1, 0, 1, 1, 0, 0, -1,
- -1, -1, 0, 0, -1, -2, -1, -2, 0, 1, 1, 1, 0, 0, 1, 1,
- -3, -3, -3, -2, -1, -1, -2, -2, -1, -1, 0, 1, 2, 1, 0, 0,
- 1, 1, 1, 2, 2, 1, 0, 0, 1, 1, 1, 1, 1, 0, -1, 1,
- 1, 0, -1, -1, 0, 0, -1, 1, 0, -1, -1, -1, 0, -1, -1, 1,
- 1, 0, -1, 0, 0, -1, 0, 2, 2, 0, -1, 0, 0, 0, 0, 2,
- 1, 0, -2, -1, 0, 1, 1, 0, 2, 0, -1, -1, 0, 1, 1, 0,
- 1, 0, -2, -1, 0, 1, 0, -1, 1, 0, -1, -1, 0, 1, 0, -1,
- 0, 1, 1, 0, 1, 1, 0, 0, -2, 1, 2, 1, 0, 0, 0, 1,
- -5, 0, 2, 1, 0, -1, 0, 1, -6, -1, 2, 1, 0, -1, 0, 0,
- 5, 3, 0, -1, -2, -1, -1, -1, 1, 1, 0, -1, -1, 0, -1, -1,
- -1, 0, 1, 1, 2, 2, 1, 0, -2, -1, 0, 1, 2, 1, 1, 1,
- -2, -1, -1, -1, 0, -1, 0, 1, 0, 1, 0, 0, -1, -1, 0, 0,
- 0, 1, 1, 1, 1, 0, 0, 0, -3, -2, 0, 1, 1, 0, 0, -1,
- -1, 0, 1, 0, -1, 0, 2, 3, -1, 0, 0, -2, -4, -2, -1, 0,
- 0, 1, 1, 0, -2, -1, 0, -1, 1, 2, 3, 1, 0, 1, 1, 0,
- -1, 0, 1, 1, 1, 1, 1, 0, -2, -3, -2, 0, 0, 0, 1, 0,
- -1, -2, -2, 0, 1, 0, 0, -1, 3, 1, 0, 0, 1, 0, -1, -1,
- -2, -1, 0, 0, -1, -1, 0, 0, -1, 0, 0, 0, 0, 1, 1, 1,
- -1, -1, -1, 0, 1, 1, 1, 1, 0, -2, -3, -1, 1, 0, 0, 0,
- 1, -1, -3, -1, 1, 1, 0, -1, 3, 1, -1, 1, 2, 2, 0, -1,
- 3, 1, 0, 1, 2, 1, 1, 0, 0, -2, -2, -1, -1, 0, 0, 0,
- 1, 0, -1, -1, 1, 2, 1, 0, 0, -1, -2, -1, 1, 2, 2, 1,
- -1, -1, -1, 0, 0, 1, 2, 0, -2, 0, 0, 0, 0, 0, 1, -1,
- -1, 0, 1, 0, -1, -1, -1, -1, 0, 1, 1, 2, 0, -2, -1, 0,
- 1, 2, 2, 2, 1, -1, -1, 0, 0, 1, 1, 1, 0, -2, -2, -1,
- 0, 0, -1, -1, -1, -1, -2, -2, 0, 0, -1, 0, 1, 2, 2, 1,
- 0, 0, -1, -1, 0, 1, 2, 2, 1, 1, -1, -2, -1, -1, -1, -1,
- 2, 2, 1, 0, 0, -1, -2, -2, 1, 2, 2, 1, 0, 0, -2, -2,
- 0, 0, 0, 0, 1, 1, 0, -1, 0, -1, -1, -1, 2, 3, 2, 1,
- 0, -2, 1, 2, -1, 0, 0, 1, -1, -2, 2, 3, -1, 0, 0, 0,
- 0, -2, 2, 3, -1, -1, 0, 0, 0, -1, 3, 2, -2, 0, 1, 0,
- 0, -1, 3, 1, -2, 0, 1, 0, 0, -1, 2, 1, -1, 1, 0, -1,
- 0, 0, 1, -1, -2, 0, 0, -1, 1, 0, 0, -2, -2, -1, -1, -1,
- 1, 1, 1, 1, 1, -1, -1, -2, 0, 0, 0, 1, 1, 1, 1, 1,
- 0, 0, 0, 1, 1, 1, 2, 3, 1, 0, 0, -1, 0, 0, 1, 2,
- 0, -1, -1, -2, -1, 0, 1, 2, -2, -2, -2, -2, -1, 0, 1, 1,
- -1, -1, -1, -1, 0, 0, 0, -1, 2, 2, 2, 0, -1, -1, -2, -4,
- -1, -2, -1, -1, 0, 1, 2, 3, -1, -1, -1, -1, 0, 1, 2, 3,
- 1, 0, -1, 0, -1, 0, 1, 2, 1, 0, 0, 0, -1, 0, 2, 2,
- 1, 0, -1, -1, -2, 0, 1, 2, 0, -2, -2, -2, -3, -1, 0, 1,
- 0, -2, -2, -2, -2, -1, 1, 1, 0, 0, 0, 0, 0, 1, 2, 2
-};
-
-/* list of codebooks for intra-coded vectors */
-const int8_t* const ff_svq1_intra_codebooks[6] = {
- svq1_intra_codebook_4x2, svq1_intra_codebook_4x4,
- svq1_intra_codebook_8x4, svq1_intra_codebook_8x8,
- NULL, NULL,
-};
-
-#endif /* AVCODEC_SVQ1_CB_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/svq1_vlc.h b/src/thirdparty/ffmpeg/libavcodec/svq1_vlc.h
deleted file mode 100644
index 53ba0d291..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/svq1_vlc.h
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * copyright (C) 2003 the ffmpeg project
- *
- * 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_SVQ1_VLC_H
-#define AVCODEC_SVQ1_VLC_H
-
-#include <stdint.h>
-
-/* values in this table range from 0..3; adjust retrieved value by +0 */
-const uint8_t ff_svq1_block_type_vlc[4][2] = {
- /* { code, length } */
- { 0x1, 1 }, { 0x1, 2 }, { 0x1, 3 }, { 0x0, 3 }
-};
-
-/* values in this table range from -1..6; adjust retrieved value by -1 */
-const uint8_t ff_svq1_intra_multistage_vlc[6][8][2] = {
- /* { code, length } */
- { { 0x1, 5 }, { 0x1, 1 }, { 0x3, 3 }, { 0x2, 3 },
- { 0x3, 4 }, { 0x2, 4 }, { 0x0, 5 }, { 0x1, 4 } },
- { { 0x1, 4 }, { 0x3, 2 }, { 0x5, 3 }, { 0x4, 3 },
- { 0x3, 3 }, { 0x2, 3 }, { 0x0, 4 }, { 0x1, 3 } },
- { { 0x1, 5 }, { 0x1, 1 }, { 0x3, 3 }, { 0x0, 5 },
- { 0x3, 4 }, { 0x2, 3 }, { 0x2, 4 }, { 0x1, 4 } },
- { { 0x1, 6 }, { 0x1, 1 }, { 0x1, 2 }, { 0x0, 6 },
- { 0x3, 4 }, { 0x2, 4 }, { 0x1, 5 }, { 0x1, 4 } },
- { { 0x1, 6 }, { 0x1, 1 }, { 0x1, 2 }, { 0x3, 5 },
- { 0x2, 5 }, { 0x0, 6 }, { 0x1, 5 }, { 0x1, 3 } },
- { { 0x1, 7 }, { 0x1, 1 }, { 0x1, 2 }, { 0x1, 3 },
- { 0x1, 4 }, { 0x1, 6 }, { 0x0, 7 }, { 0x1, 5 } }
-};
-
-/* values in this table range from -1..6; adjust retrieved value by -1 */
-const uint8_t ff_svq1_inter_multistage_vlc[6][8][2] = {
- /* { code, length } */
- { { 0x3, 2 }, { 0x5, 3 }, { 0x4, 3 }, { 0x3, 3 },
- { 0x2, 3 }, { 0x1, 3 }, { 0x1, 4 }, { 0x0, 4 } },
- { { 0x3, 2 }, { 0x5, 3 }, { 0x4, 3 }, { 0x3, 3 },
- { 0x2, 3 }, { 0x1, 3 }, { 0x1, 4 }, { 0x0, 4 } },
- { { 0x1, 1 }, { 0x3, 3 }, { 0x2, 3 }, { 0x3, 4 },
- { 0x2, 4 }, { 0x1, 4 }, { 0x1, 5 }, { 0x0, 5 } },
- { { 0x1, 1 }, { 0x3, 3 }, { 0x2, 3 }, { 0x3, 4 },
- { 0x2, 4 }, { 0x1, 4 }, { 0x1, 5 }, { 0x0, 5 } },
- { { 0x1, 1 }, { 0x3, 3 }, { 0x2, 3 }, { 0x3, 4 },
- { 0x2, 4 }, { 0x1, 4 }, { 0x1, 5 }, { 0x0, 5 } },
- { { 0x1, 1 }, { 0x1, 2 }, { 0x1, 3 }, { 0x3, 5 },
- { 0x2, 5 }, { 0x1, 5 }, { 0x1, 6 }, { 0x0, 6 } }
-};
-
-/* values in this table range from 0..255; adjust retrieved value by +0 */
-const uint16_t ff_svq1_intra_mean_vlc[256][2] = {
- /* { code, length } */
- { 0x37, 6 }, { 0x56, 7 }, { 0x01, 17 }, { 0x01, 20 },
- { 0x02, 20 }, { 0x03, 20 }, { 0x00, 20 }, { 0x04, 20 },
- { 0x05, 20 }, { 0x03, 19 }, { 0x15, 11 }, { 0x42, 9 },
- { 0x14, 11 }, { 0x03, 14 }, { 0x02, 14 }, { 0x01, 15 },
- { 0x01, 16 }, { 0x01, 12 }, { 0x2B, 10 }, { 0x18, 11 },
- { 0x0C, 11 }, { 0x41, 9 }, { 0x78, 8 }, { 0x6C, 8 },
- { 0x55, 7 }, { 0x0F, 4 }, { 0x0E, 4 }, { 0x34, 6 },
- { 0x51, 7 }, { 0x72, 8 }, { 0x6E, 8 }, { 0x40, 9 },
- { 0x3F, 9 }, { 0x3E, 9 }, { 0x3D, 9 }, { 0x3C, 9 },
- { 0x3B, 9 }, { 0x3A, 9 }, { 0x39, 9 }, { 0x38, 9 },
- { 0x37, 9 }, { 0x43, 9 }, { 0x46, 9 }, { 0x47, 9 },
- { 0x45, 9 }, { 0x44, 9 }, { 0x49, 9 }, { 0x48, 9 },
- { 0x4A, 8 }, { 0x79, 8 }, { 0x76, 8 }, { 0x77, 8 },
- { 0x71, 8 }, { 0x75, 8 }, { 0x74, 8 }, { 0x73, 8 },
- { 0x6A, 8 }, { 0x55, 8 }, { 0x70, 8 }, { 0x6F, 8 },
- { 0x52, 8 }, { 0x6D, 8 }, { 0x4C, 8 }, { 0x6B, 8 },
- { 0x40, 7 }, { 0x69, 8 }, { 0x68, 8 }, { 0x67, 8 },
- { 0x66, 8 }, { 0x65, 8 }, { 0x64, 8 }, { 0x63, 8 },
- { 0x62, 8 }, { 0x61, 8 }, { 0x60, 8 }, { 0x5F, 8 },
- { 0x5E, 8 }, { 0x5D, 8 }, { 0x5C, 8 }, { 0x5B, 8 },
- { 0x5A, 8 }, { 0x59, 8 }, { 0x58, 8 }, { 0x57, 8 },
- { 0x56, 8 }, { 0x3D, 7 }, { 0x54, 8 }, { 0x53, 8 },
- { 0x3F, 7 }, { 0x51, 8 }, { 0x50, 8 }, { 0x4F, 8 },
- { 0x4E, 8 }, { 0x4D, 8 }, { 0x41, 7 }, { 0x4B, 8 },
- { 0x53, 7 }, { 0x3E, 7 }, { 0x48, 8 }, { 0x4F, 7 },
- { 0x52, 7 }, { 0x45, 8 }, { 0x50, 7 }, { 0x43, 8 },
- { 0x42, 8 }, { 0x41, 8 }, { 0x42, 7 }, { 0x43, 7 },
- { 0x3E, 8 }, { 0x44, 7 }, { 0x3C, 8 }, { 0x45, 7 },
- { 0x46, 7 }, { 0x47, 7 }, { 0x48, 7 }, { 0x49, 7 },
- { 0x4A, 7 }, { 0x4B, 7 }, { 0x4C, 7 }, { 0x4D, 7 },
- { 0x4E, 7 }, { 0x58, 7 }, { 0x59, 7 }, { 0x5A, 7 },
- { 0x5B, 7 }, { 0x5C, 7 }, { 0x5D, 7 }, { 0x44, 8 },
- { 0x49, 8 }, { 0x29, 8 }, { 0x3F, 8 }, { 0x3D, 8 },
- { 0x3B, 8 }, { 0x2C, 8 }, { 0x28, 8 }, { 0x25, 8 },
- { 0x26, 8 }, { 0x5E, 7 }, { 0x57, 7 }, { 0x54, 7 },
- { 0x5F, 7 }, { 0x62, 7 }, { 0x63, 7 }, { 0x64, 7 },
- { 0x61, 7 }, { 0x65, 7 }, { 0x67, 7 }, { 0x66, 7 },
- { 0x35, 6 }, { 0x36, 6 }, { 0x60, 7 }, { 0x39, 8 },
- { 0x3A, 8 }, { 0x38, 8 }, { 0x37, 8 }, { 0x36, 8 },
- { 0x35, 8 }, { 0x34, 8 }, { 0x33, 8 }, { 0x32, 8 },
- { 0x31, 8 }, { 0x30, 8 }, { 0x2D, 8 }, { 0x2B, 8 },
- { 0x2A, 8 }, { 0x27, 8 }, { 0x40, 8 }, { 0x46, 8 },
- { 0x47, 8 }, { 0x26, 9 }, { 0x25, 9 }, { 0x24, 9 },
- { 0x23, 9 }, { 0x22, 9 }, { 0x2E, 8 }, { 0x2F, 8 },
- { 0x1F, 9 }, { 0x36, 9 }, { 0x1D, 9 }, { 0x21, 9 },
- { 0x1B, 9 }, { 0x1C, 9 }, { 0x19, 9 }, { 0x1A, 9 },
- { 0x18, 9 }, { 0x17, 9 }, { 0x16, 9 }, { 0x1E, 9 },
- { 0x20, 9 }, { 0x27, 9 }, { 0x28, 9 }, { 0x29, 9 },
- { 0x2A, 9 }, { 0x2B, 9 }, { 0x2C, 9 }, { 0x2D, 9 },
- { 0x2E, 9 }, { 0x2F, 9 }, { 0x30, 9 }, { 0x35, 9 },
- { 0x31, 9 }, { 0x32, 9 }, { 0x33, 9 }, { 0x34, 9 },
- { 0x19, 10 }, { 0x2A, 10 }, { 0x17, 10 }, { 0x16, 10 },
- { 0x15, 10 }, { 0x28, 10 }, { 0x26, 10 }, { 0x25, 10 },
- { 0x22, 10 }, { 0x21, 10 }, { 0x18, 10 }, { 0x14, 10 },
- { 0x29, 10 }, { 0x12, 10 }, { 0x0D, 10 }, { 0x0E, 10 },
- { 0x0F, 10 }, { 0x10, 10 }, { 0x11, 10 }, { 0x1A, 10 },
- { 0x1B, 10 }, { 0x1C, 10 }, { 0x1D, 10 }, { 0x1E, 10 },
- { 0x1F, 10 }, { 0x20, 10 }, { 0x13, 10 }, { 0x23, 10 },
- { 0x24, 10 }, { 0x09, 11 }, { 0x08, 11 }, { 0x07, 11 },
- { 0x27, 10 }, { 0x05, 11 }, { 0x0B, 11 }, { 0x06, 11 },
- { 0x04, 11 }, { 0x03, 11 }, { 0x02, 11 }, { 0x01, 11 },
- { 0x0A, 11 }, { 0x16, 11 }, { 0x19, 11 }, { 0x17, 11 },
- { 0x0D, 11 }, { 0x0E, 11 }, { 0x0F, 11 }, { 0x10, 11 },
- { 0x11, 11 }, { 0x12, 11 }, { 0x13, 11 }, { 0x01, 14 }
-};
-
-/* values in this table range from -256..255; adjust retrieved value by -256 */
-const uint16_t ff_svq1_inter_mean_vlc[512][2] = {
- /* { code, length } */
- { 0x5A, 22 }, { 0xD4, 22 }, { 0xD5, 22 }, { 0xD6, 22 },
- { 0xD7, 22 }, { 0xD8, 22 }, { 0xD9, 22 }, { 0xDA, 22 },
- { 0xDB, 22 }, { 0xDC, 22 }, { 0xDD, 22 }, { 0xDE, 22 },
- { 0xDF, 22 }, { 0xE0, 22 }, { 0xE1, 22 }, { 0xE2, 22 },
- { 0xE3, 22 }, { 0xE4, 22 }, { 0xE5, 22 }, { 0xE6, 22 },
- { 0xE8, 22 }, { 0xCB, 22 }, { 0xE9, 22 }, { 0xEA, 22 },
- { 0xE7, 22 }, { 0xEC, 22 }, { 0xED, 22 }, { 0xEE, 22 },
- { 0xEF, 22 }, { 0xF0, 22 }, { 0xF1, 22 }, { 0xF2, 22 },
- { 0xF3, 22 }, { 0xF4, 22 }, { 0xF5, 22 }, { 0xF6, 22 },
- { 0xF7, 22 }, { 0xF8, 22 }, { 0x102,22 }, { 0xEB, 22 },
- { 0xF9, 22 }, { 0xFC, 22 }, { 0xFD, 22 }, { 0xFE, 22 },
- { 0x100,22 }, { 0x5C, 22 }, { 0x60, 22 }, { 0x101,22 },
- { 0x71, 22 }, { 0x104,22 }, { 0x105,22 }, { 0xFB, 22 },
- { 0xFF, 22 }, { 0x86, 21 }, { 0xFA, 22 }, { 0x7C, 22 },
- { 0x75, 22 }, { 0x103,22 }, { 0x78, 22 }, { 0xD3, 22 },
- { 0x7B, 22 }, { 0x82, 22 }, { 0xD2, 22 }, { 0xD1, 22 },
- { 0xD0, 22 }, { 0xCF, 22 }, { 0xCE, 22 }, { 0xCD, 22 },
- { 0xCC, 22 }, { 0xC3, 22 }, { 0xCA, 22 }, { 0xC9, 22 },
- { 0xC8, 22 }, { 0xC7, 22 }, { 0xC6, 22 }, { 0xC5, 22 },
- { 0x8B, 22 }, { 0xC4, 22 }, { 0xC2, 22 }, { 0xC1, 22 },
- { 0xC0, 22 }, { 0xBF, 22 }, { 0xBE, 22 }, { 0xBD, 22 },
- { 0xBC, 22 }, { 0xBB, 22 }, { 0xBA, 22 }, { 0xB9, 22 },
- { 0x61, 22 }, { 0x84, 22 }, { 0x85, 22 }, { 0x86, 22 },
- { 0x87, 22 }, { 0x88, 22 }, { 0x89, 22 }, { 0x8A, 22 },
- { 0x8C, 22 }, { 0x8D, 22 }, { 0x8E, 22 }, { 0x8F, 22 },
- { 0x90, 22 }, { 0x91, 22 }, { 0x92, 22 }, { 0x93, 22 },
- { 0x94, 22 }, { 0x95, 22 }, { 0x96, 22 }, { 0x97, 22 },
- { 0x98, 22 }, { 0x99, 22 }, { 0x9A, 22 }, { 0x9B, 22 },
- { 0x9C, 22 }, { 0x9D, 22 }, { 0x9E, 22 }, { 0x9F, 22 },
- { 0xA0, 22 }, { 0xA1, 22 }, { 0xA2, 22 }, { 0xA3, 22 },
- { 0xA4, 22 }, { 0xA5, 22 }, { 0xA6, 22 }, { 0xA7, 22 },
- { 0xA8, 22 }, { 0xA9, 22 }, { 0xAA, 22 }, { 0xAB, 22 },
- { 0x7F, 22 }, { 0x8F, 21 }, { 0xAC, 22 }, { 0xAD, 22 },
- { 0xAE, 22 }, { 0xAF, 22 }, { 0xB0, 22 }, { 0xB1, 22 },
- { 0x53, 20 }, { 0x90, 21 }, { 0xB2, 22 }, { 0x91, 21 },
- { 0xB3, 22 }, { 0xB4, 22 }, { 0x54, 20 }, { 0xB5, 22 },
- { 0xB6, 22 }, { 0x8C, 21 }, { 0x34, 19 }, { 0x3D, 18 },
- { 0x55, 20 }, { 0xB7, 22 }, { 0xB8, 22 }, { 0x8B, 21 },
- { 0x56, 20 }, { 0x3D, 19 }, { 0x57, 20 }, { 0x58, 20 },
- { 0x40, 19 }, { 0x43, 19 }, { 0x47, 19 }, { 0x2A, 18 },
- { 0x2E, 19 }, { 0x2C, 18 }, { 0x46, 19 }, { 0x59, 20 },
- { 0x49, 19 }, { 0x2D, 19 }, { 0x38, 18 }, { 0x36, 18 },
- { 0x39, 18 }, { 0x45, 19 }, { 0x28, 18 }, { 0x30, 18 },
- { 0x35, 18 }, { 0x20, 17 }, { 0x44, 19 }, { 0x32, 18 },
- { 0x31, 18 }, { 0x1F, 17 }, { 0x2F, 18 }, { 0x2E, 18 },
- { 0x2D, 18 }, { 0x21, 17 }, { 0x22, 17 }, { 0x23, 17 },
- { 0x24, 17 }, { 0x27, 16 }, { 0x23, 16 }, { 0x20, 16 },
- { 0x1D, 16 }, { 0x25, 16 }, { 0x1E, 16 }, { 0x24, 16 },
- { 0x2A, 16 }, { 0x26, 16 }, { 0x21, 15 }, { 0x29, 16 },
- { 0x22, 15 }, { 0x23, 15 }, { 0x24, 15 }, { 0x1B, 15 },
- { 0x1A, 15 }, { 0x1D, 15 }, { 0x1F, 15 }, { 0x27, 15 },
- { 0x17, 14 }, { 0x18, 14 }, { 0x19, 14 }, { 0x1B, 14 },
- { 0x1C, 14 }, { 0x1E, 14 }, { 0x25, 14 }, { 0x20, 14 },
- { 0x21, 14 }, { 0x13, 13 }, { 0x14, 13 }, { 0x15, 13 },
- { 0x16, 13 }, { 0x17, 13 }, { 0x18, 13 }, { 0x19, 13 },
- { 0x1A, 13 }, { 0x18, 12 }, { 0x17, 12 }, { 0x15, 12 },
- { 0x14, 12 }, { 0x13, 12 }, { 0x12, 12 }, { 0x0F, 11 },
- { 0x10, 11 }, { 0x12, 11 }, { 0x13, 11 }, { 0x1B, 11 },
- { 0x1A, 11 }, { 0x0E, 10 }, { 0x13, 10 }, { 0x0F, 10 },
- { 0x10, 10 }, { 0x11, 10 }, { 0x12, 10 }, { 0x0D, 9 },
- { 0x14, 9 }, { 0x15, 9 }, { 0x0C, 9 }, { 0x13, 9 },
- { 0x0F, 8 }, { 0x0E, 8 }, { 0x10, 8 }, { 0x11, 8 },
- { 0x0C, 7 }, { 0x09, 7 }, { 0x0A, 7 }, { 0x08, 6 },
- { 0x09, 6 }, { 0x09, 5 }, { 0x08, 5 }, { 0x05, 4 },
- { 0x01, 1 }, { 0x03, 3 }, { 0x07, 5 }, { 0x06, 5 },
- { 0x0B, 6 }, { 0x0A, 6 }, { 0x0E, 7 }, { 0x0F, 7 },
- { 0x0B, 7 }, { 0x0D, 7 }, { 0x0B, 8 }, { 0x0D, 8 },
- { 0x0C, 8 }, { 0x0F, 9 }, { 0x10, 9 }, { 0x11, 9 },
- { 0x0E, 9 }, { 0x12, 9 }, { 0x17, 10 }, { 0x14, 10 },
- { 0x16, 10 }, { 0x15, 10 }, { 0x19, 11 }, { 0x18, 11 },
- { 0x17, 11 }, { 0x16, 11 }, { 0x15, 11 }, { 0x14, 11 },
- { 0x11, 11 }, { 0x19, 12 }, { 0x1A, 12 }, { 0x16, 12 },
- { 0x1D, 12 }, { 0x1B, 12 }, { 0x1C, 12 }, { 0x20, 13 },
- { 0x1C, 13 }, { 0x23, 13 }, { 0x22, 13 }, { 0x21, 13 },
- { 0x1F, 13 }, { 0x1E, 13 }, { 0x1B, 13 }, { 0x1D, 13 },
- { 0x24, 14 }, { 0x16, 14 }, { 0x1A, 14 }, { 0x22, 14 },
- { 0x1D, 14 }, { 0x1F, 14 }, { 0x15, 14 }, { 0x23, 14 },
- { 0x18, 15 }, { 0x20, 15 }, { 0x29, 15 }, { 0x28, 15 },
- { 0x26, 15 }, { 0x25, 15 }, { 0x19, 15 }, { 0x1C, 15 },
- { 0x1E, 15 }, { 0x17, 15 }, { 0x2C, 16 }, { 0x2B, 16 },
- { 0x1C, 16 }, { 0x21, 16 }, { 0x2D, 16 }, { 0x28, 16 },
- { 0x1F, 16 }, { 0x1B, 16 }, { 0x1A, 16 }, { 0x22, 16 },
- { 0x2D, 17 }, { 0x32, 17 }, { 0x2C, 17 }, { 0x27, 17 },
- { 0x31, 17 }, { 0x33, 17 }, { 0x2F, 17 }, { 0x2B, 17 },
- { 0x37, 18 }, { 0x2A, 17 }, { 0x2E, 17 }, { 0x30, 17 },
- { 0x29, 17 }, { 0x28, 17 }, { 0x26, 17 }, { 0x25, 17 },
- { 0x2F, 19 }, { 0x33, 18 }, { 0x34, 18 }, { 0x30, 19 },
- { 0x3A, 18 }, { 0x3B, 18 }, { 0x31, 19 }, { 0x3C, 18 },
- { 0x2B, 18 }, { 0x29, 18 }, { 0x48, 19 }, { 0x27, 18 },
- { 0x42, 19 }, { 0x41, 19 }, { 0x26, 18 }, { 0x52, 20 },
- { 0x51, 20 }, { 0x3F, 19 }, { 0x3E, 19 }, { 0x39, 19 },
- { 0x3C, 19 }, { 0x3B, 19 }, { 0x3A, 19 }, { 0x25, 18 },
- { 0x38, 19 }, { 0x50, 20 }, { 0x37, 19 }, { 0x36, 19 },
- { 0x87, 21 }, { 0x4F, 20 }, { 0x35, 19 }, { 0x4E, 20 },
- { 0x33, 19 }, { 0x32, 19 }, { 0x4D, 20 }, { 0x4C, 20 },
- { 0x83, 22 }, { 0x4B, 20 }, { 0x81, 22 }, { 0x80, 22 },
- { 0x8E, 21 }, { 0x7E, 22 }, { 0x7D, 22 }, { 0x84, 21 },
- { 0x8D, 21 }, { 0x7A, 22 }, { 0x79, 22 }, { 0x4A, 20 },
- { 0x77, 22 }, { 0x76, 22 }, { 0x89, 21 }, { 0x74, 22 },
- { 0x73, 22 }, { 0x72, 22 }, { 0x49, 20 }, { 0x70, 22 },
- { 0x6F, 22 }, { 0x6E, 22 }, { 0x6D, 22 }, { 0x6C, 22 },
- { 0x6B, 22 }, { 0x6A, 22 }, { 0x69, 22 }, { 0x68, 22 },
- { 0x67, 22 }, { 0x66, 22 }, { 0x65, 22 }, { 0x64, 22 },
- { 0x63, 22 }, { 0x62, 22 }, { 0x8A, 21 }, { 0x88, 21 },
- { 0x5F, 22 }, { 0x5E, 22 }, { 0x5D, 22 }, { 0x85, 21 },
- { 0x5B, 22 }, { 0x83, 21 }, { 0x59, 22 }, { 0x58, 22 },
- { 0x57, 22 }, { 0x56, 22 }, { 0x55, 22 }, { 0x54, 22 },
- { 0x53, 22 }, { 0x52, 22 }, { 0x51, 22 }, { 0x50, 22 },
- { 0x4F, 22 }, { 0x4E, 22 }, { 0x4D, 22 }, { 0x4C, 22 },
- { 0x4B, 22 }, { 0x4A, 22 }, { 0x49, 22 }, { 0x48, 22 },
- { 0x47, 22 }, { 0x46, 22 }, { 0x45, 22 }, { 0x44, 22 },
- { 0x43, 22 }, { 0x42, 22 }, { 0x41, 22 }, { 0x40, 22 },
- { 0x3F, 22 }, { 0x3E, 22 }, { 0x3D, 22 }, { 0x3C, 22 },
- { 0x3B, 22 }, { 0x3A, 22 }, { 0x39, 22 }, { 0x38, 22 },
- { 0x37, 22 }, { 0x36, 22 }, { 0x35, 22 }, { 0x34, 22 },
- { 0x33, 22 }, { 0x32, 22 }, { 0x31, 22 }, { 0x30, 22 },
- { 0x2F, 22 }, { 0x2E, 22 }, { 0x2D, 22 }, { 0x2C, 22 },
- { 0x2B, 22 }, { 0x2A, 22 }, { 0x29, 22 }, { 0x28, 22 },
- { 0x27, 22 }, { 0x26, 22 }, { 0x25, 22 }, { 0x24, 22 },
- { 0x23, 22 }, { 0x22, 22 }, { 0x21, 22 }, { 0x20, 22 },
- { 0x1F, 22 }, { 0x1E, 22 }, { 0x1D, 22 }, { 0x1C, 22 },
- { 0x1B, 22 }, { 0x1A, 22 }, { 0x19, 22 }, { 0x18, 22 },
- { 0x17, 22 }, { 0x16, 22 }, { 0x15, 22 }, { 0x14, 22 },
- { 0x13, 22 }, { 0x12, 22 }, { 0x11, 22 }, { 0x10, 22 },
- { 0x0F, 22 }, { 0x0E, 22 }, { 0x0D, 22 }, { 0x0C, 22 },
- { 0x0B, 22 }, { 0x0A, 22 }, { 0x09, 22 }, { 0x08, 22 },
- { 0x07, 22 }, { 0x06, 22 }, { 0x05, 22 }, { 0x04, 22 },
- { 0x03, 22 }, { 0x02, 22 }, { 0x01, 22 }, { 0x00, 22 }
-};
-
-#endif /* AVCODEC_SVQ1_VLC_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/svq1dec.c b/src/thirdparty/ffmpeg/libavcodec/svq1dec.c
deleted file mode 100644
index 171834df2..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/svq1dec.c
+++ /dev/null
@@ -1,834 +0,0 @@
-/*
- * SVQ1 decoder
- * ported to MPlayer by Arpi <arpi@thot.banki.hu>
- * ported to libavcodec by Nick Kurshev <nickols_k@mail.ru>
- *
- * Copyright (C) 2002 the xine project
- * Copyright (C) 2002 the ffmpeg project
- *
- * SVQ1 Encoder (c) 2004 Mike Melanson <melanson@pcisys.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
- */
-
-/**
- * @file
- * Sorenson Vector Quantizer #1 (SVQ1) video codec.
- * For more information of the SVQ1 algorithm, visit:
- * http://www.pcisys.net/~melanson/codecs/
- */
-
-#include "avcodec.h"
-#include "dsputil.h"
-#include "get_bits.h"
-#include "internal.h"
-#include "mathops.h"
-#include "svq1.h"
-
-#undef NDEBUG
-#include <assert.h>
-
-extern const uint8_t ff_mvtab[33][2];
-
-static VLC svq1_block_type;
-static VLC svq1_motion_component;
-static VLC svq1_intra_multistage[6];
-static VLC svq1_inter_multistage[6];
-static VLC svq1_intra_mean;
-static VLC svq1_inter_mean;
-
-/* motion vector (prediction) */
-typedef struct svq1_pmv_s {
- int x;
- int y;
-} svq1_pmv;
-
-typedef struct SVQ1Context {
- DSPContext dsp;
- GetBitContext gb;
- AVFrame *cur, *prev;
- int width;
- int height;
- int frame_code;
- int nonref; // 1 if the current frame won't be referenced
-} SVQ1Context;
-
-static const uint8_t string_table[256] = {
- 0x00, 0xD5, 0x7F, 0xAA, 0xFE, 0x2B, 0x81, 0x54,
- 0x29, 0xFC, 0x56, 0x83, 0xD7, 0x02, 0xA8, 0x7D,
- 0x52, 0x87, 0x2D, 0xF8, 0xAC, 0x79, 0xD3, 0x06,
- 0x7B, 0xAE, 0x04, 0xD1, 0x85, 0x50, 0xFA, 0x2F,
- 0xA4, 0x71, 0xDB, 0x0E, 0x5A, 0x8F, 0x25, 0xF0,
- 0x8D, 0x58, 0xF2, 0x27, 0x73, 0xA6, 0x0C, 0xD9,
- 0xF6, 0x23, 0x89, 0x5C, 0x08, 0xDD, 0x77, 0xA2,
- 0xDF, 0x0A, 0xA0, 0x75, 0x21, 0xF4, 0x5E, 0x8B,
- 0x9D, 0x48, 0xE2, 0x37, 0x63, 0xB6, 0x1C, 0xC9,
- 0xB4, 0x61, 0xCB, 0x1E, 0x4A, 0x9F, 0x35, 0xE0,
- 0xCF, 0x1A, 0xB0, 0x65, 0x31, 0xE4, 0x4E, 0x9B,
- 0xE6, 0x33, 0x99, 0x4C, 0x18, 0xCD, 0x67, 0xB2,
- 0x39, 0xEC, 0x46, 0x93, 0xC7, 0x12, 0xB8, 0x6D,
- 0x10, 0xC5, 0x6F, 0xBA, 0xEE, 0x3B, 0x91, 0x44,
- 0x6B, 0xBE, 0x14, 0xC1, 0x95, 0x40, 0xEA, 0x3F,
- 0x42, 0x97, 0x3D, 0xE8, 0xBC, 0x69, 0xC3, 0x16,
- 0xEF, 0x3A, 0x90, 0x45, 0x11, 0xC4, 0x6E, 0xBB,
- 0xC6, 0x13, 0xB9, 0x6C, 0x38, 0xED, 0x47, 0x92,
- 0xBD, 0x68, 0xC2, 0x17, 0x43, 0x96, 0x3C, 0xE9,
- 0x94, 0x41, 0xEB, 0x3E, 0x6A, 0xBF, 0x15, 0xC0,
- 0x4B, 0x9E, 0x34, 0xE1, 0xB5, 0x60, 0xCA, 0x1F,
- 0x62, 0xB7, 0x1D, 0xC8, 0x9C, 0x49, 0xE3, 0x36,
- 0x19, 0xCC, 0x66, 0xB3, 0xE7, 0x32, 0x98, 0x4D,
- 0x30, 0xE5, 0x4F, 0x9A, 0xCE, 0x1B, 0xB1, 0x64,
- 0x72, 0xA7, 0x0D, 0xD8, 0x8C, 0x59, 0xF3, 0x26,
- 0x5B, 0x8E, 0x24, 0xF1, 0xA5, 0x70, 0xDA, 0x0F,
- 0x20, 0xF5, 0x5F, 0x8A, 0xDE, 0x0B, 0xA1, 0x74,
- 0x09, 0xDC, 0x76, 0xA3, 0xF7, 0x22, 0x88, 0x5D,
- 0xD6, 0x03, 0xA9, 0x7C, 0x28, 0xFD, 0x57, 0x82,
- 0xFF, 0x2A, 0x80, 0x55, 0x01, 0xD4, 0x7E, 0xAB,
- 0x84, 0x51, 0xFB, 0x2E, 0x7A, 0xAF, 0x05, 0xD0,
- 0xAD, 0x78, 0xD2, 0x07, 0x53, 0x86, 0x2C, 0xF9
-};
-
-#define SVQ1_PROCESS_VECTOR() \
- for (; level > 0; i++) { \
- /* process next depth */ \
- if (i == m) { \
- m = n; \
- if (--level == 0) \
- break; \
- } \
- /* divide block if next bit set */ \
- if (!get_bits1(bitbuf)) \
- break; \
- /* add child nodes */ \
- list[n++] = list[i]; \
- list[n++] = list[i] + (((level & 1) ? pitch : 1) << ((level >> 1) + 1));\
- }
-
-#define SVQ1_ADD_CODEBOOK() \
- /* add codebook entries to vector */ \
- for (j = 0; j < stages; j++) { \
- n3 = codebook[entries[j]] ^ 0x80808080; \
- n1 += (n3 & 0xFF00FF00) >> 8; \
- n2 += n3 & 0x00FF00FF; \
- } \
- \
- /* clip to [0..255] */ \
- if (n1 & 0xFF00FF00) { \
- n3 = (n1 >> 15 & 0x00010001 | 0x01000100) - 0x00010001; \
- n1 += 0x7F007F00; \
- n1 |= (~n1 >> 15 & 0x00010001 | 0x01000100) - 0x00010001; \
- n1 &= n3 & 0x00FF00FF; \
- } \
- \
- if (n2 & 0xFF00FF00) { \
- n3 = (n2 >> 15 & 0x00010001 | 0x01000100) - 0x00010001; \
- n2 += 0x7F007F00; \
- n2 |= (~n2 >> 15 & 0x00010001 | 0x01000100) - 0x00010001; \
- n2 &= n3 & 0x00FF00FF; \
- }
-
-#define SVQ1_CALC_CODEBOOK_ENTRIES(cbook) \
- codebook = (const uint32_t *)cbook[level]; \
- if (stages > 0) \
- bit_cache = get_bits(bitbuf, 4 * stages); \
- /* calculate codebook entries for this vector */ \
- for (j = 0; j < stages; j++) { \
- entries[j] = (((bit_cache >> (4 * (stages - j - 1))) & 0xF) + \
- 16 * j) << (level + 1); \
- } \
- mean -= stages * 128; \
- n4 = (mean << 16) + mean;
-
-static int svq1_decode_block_intra(GetBitContext *bitbuf, uint8_t *pixels,
- int pitch)
-{
- uint32_t bit_cache;
- uint8_t *list[63];
- uint32_t *dst;
- const uint32_t *codebook;
- int entries[6];
- int i, j, m, n;
- int mean, stages;
- unsigned x, y, width, height, level;
- uint32_t n1, n2, n3, n4;
-
- /* initialize list for breadth first processing of vectors */
- list[0] = pixels;
-
- /* recursively process vector */
- for (i = 0, m = 1, n = 1, level = 5; i < n; i++) {
- SVQ1_PROCESS_VECTOR();
-
- /* destination address and vector size */
- dst = (uint32_t *)list[i];
- width = 1 << ((4 + level) / 2);
- height = 1 << ((3 + level) / 2);
-
- /* get number of stages (-1 skips vector, 0 for mean only) */
- stages = get_vlc2(bitbuf, svq1_intra_multistage[level].table, 3, 3) - 1;
-
- if (stages == -1) {
- for (y = 0; y < height; y++)
- memset(&dst[y * (pitch / 4)], 0, width);
- continue; /* skip vector */
- }
-
- if (stages > 0 && level >= 4) {
- av_dlog(NULL,
- "Error (svq1_decode_block_intra): invalid vector: stages=%i level=%i\n",
- stages, level);
- return AVERROR_INVALIDDATA; /* invalid vector */
- }
-
- mean = get_vlc2(bitbuf, svq1_intra_mean.table, 8, 3);
-
- if (stages == 0) {
- for (y = 0; y < height; y++)
- memset(&dst[y * (pitch / 4)], mean, width);
- } else {
- SVQ1_CALC_CODEBOOK_ENTRIES(ff_svq1_intra_codebooks);
-
- for (y = 0; y < height; y++) {
- for (x = 0; x < width / 4; x++, codebook++) {
- n1 = n4;
- n2 = n4;
- SVQ1_ADD_CODEBOOK()
- /* store result */
- dst[x] = n1 << 8 | n2;
- }
- dst += pitch / 4;
- }
- }
- }
-
- return 0;
-}
-
-static int svq1_decode_block_non_intra(GetBitContext *bitbuf, uint8_t *pixels,
- int pitch)
-{
- uint32_t bit_cache;
- uint8_t *list[63];
- uint32_t *dst;
- const uint32_t *codebook;
- int entries[6];
- int i, j, m, n;
- int mean, stages;
- int x, y, width, height, level;
- uint32_t n1, n2, n3, n4;
-
- /* initialize list for breadth first processing of vectors */
- list[0] = pixels;
-
- /* recursively process vector */
- for (i = 0, m = 1, n = 1, level = 5; i < n; i++) {
- SVQ1_PROCESS_VECTOR();
-
- /* destination address and vector size */
- dst = (uint32_t *)list[i];
- width = 1 << ((4 + level) / 2);
- height = 1 << ((3 + level) / 2);
-
- /* get number of stages (-1 skips vector, 0 for mean only) */
- stages = get_vlc2(bitbuf, svq1_inter_multistage[level].table, 3, 2) - 1;
-
- if (stages == -1)
- continue; /* skip vector */
-
- if ((stages > 0) && (level >= 4)) {
- av_dlog(NULL,
- "Error (svq1_decode_block_non_intra): invalid vector: stages=%i level=%i\n",
- stages, level);
- return AVERROR_INVALIDDATA; /* invalid vector */
- }
-
- mean = get_vlc2(bitbuf, svq1_inter_mean.table, 9, 3) - 256;
-
- SVQ1_CALC_CODEBOOK_ENTRIES(ff_svq1_inter_codebooks);
-
- for (y = 0; y < height; y++) {
- for (x = 0; x < width / 4; x++, codebook++) {
- n3 = dst[x];
- /* add mean value to vector */
- n1 = n4 + ((n3 & 0xFF00FF00) >> 8);
- n2 = n4 + (n3 & 0x00FF00FF);
- SVQ1_ADD_CODEBOOK()
- /* store result */
- dst[x] = n1 << 8 | n2;
- }
- dst += pitch / 4;
- }
- }
- return 0;
-}
-
-static int svq1_decode_motion_vector(GetBitContext *bitbuf, svq1_pmv *mv,
- svq1_pmv **pmv)
-{
- int diff;
- int i;
-
- for (i = 0; i < 2; i++) {
- /* get motion code */
- diff = get_vlc2(bitbuf, svq1_motion_component.table, 7, 2);
- if (diff < 0)
- return AVERROR_INVALIDDATA;
- else if (diff) {
- if (get_bits1(bitbuf))
- diff = -diff;
- }
-
- /* add median of motion vector predictors and clip result */
- if (i == 1)
- mv->y = sign_extend(diff + mid_pred(pmv[0]->y, pmv[1]->y, pmv[2]->y), 6);
- else
- mv->x = sign_extend(diff + mid_pred(pmv[0]->x, pmv[1]->x, pmv[2]->x), 6);
- }
-
- return 0;
-}
-
-static void svq1_skip_block(uint8_t *current, uint8_t *previous,
- int pitch, int x, int y)
-{
- uint8_t *src;
- uint8_t *dst;
- int i;
-
- src = &previous[x + y * pitch];
- dst = current;
-
- for (i = 0; i < 16; i++) {
- memcpy(dst, src, 16);
- src += pitch;
- dst += pitch;
- }
-}
-
-static int svq1_motion_inter_block(DSPContext *dsp, GetBitContext *bitbuf,
- uint8_t *current, uint8_t *previous,
- int pitch, svq1_pmv *motion, int x, int y)
-{
- uint8_t *src;
- uint8_t *dst;
- svq1_pmv mv;
- svq1_pmv *pmv[3];
- int result;
-
- /* predict and decode motion vector */
- pmv[0] = &motion[0];
- if (y == 0) {
- pmv[1] =
- pmv[2] = pmv[0];
- } else {
- pmv[1] = &motion[x / 8 + 2];
- pmv[2] = &motion[x / 8 + 4];
- }
-
- result = svq1_decode_motion_vector(bitbuf, &mv, pmv);
- if (result)
- return result;
-
- motion[0].x =
- motion[x / 8 + 2].x =
- motion[x / 8 + 3].x = mv.x;
- motion[0].y =
- motion[x / 8 + 2].y =
- motion[x / 8 + 3].y = mv.y;
-
- if (y + (mv.y >> 1) < 0)
- mv.y = 0;
- if (x + (mv.x >> 1) < 0)
- mv.x = 0;
-
- src = &previous[(x + (mv.x >> 1)) + (y + (mv.y >> 1)) * pitch];
- dst = current;
-
- dsp->put_pixels_tab[0][(mv.y & 1) << 1 | (mv.x & 1)](dst, src, pitch, 16);
-
- return 0;
-}
-
-static int svq1_motion_inter_4v_block(DSPContext *dsp, GetBitContext *bitbuf,
- uint8_t *current, uint8_t *previous,
- int pitch, svq1_pmv *motion, int x, int y)
-{
- uint8_t *src;
- uint8_t *dst;
- svq1_pmv mv;
- svq1_pmv *pmv[4];
- int i, result;
-
- /* predict and decode motion vector (0) */
- pmv[0] = &motion[0];
- if (y == 0) {
- pmv[1] =
- pmv[2] = pmv[0];
- } else {
- pmv[1] = &motion[(x / 8) + 2];
- pmv[2] = &motion[(x / 8) + 4];
- }
-
- result = svq1_decode_motion_vector(bitbuf, &mv, pmv);
- if (result)
- return result;
-
- /* predict and decode motion vector (1) */
- pmv[0] = &mv;
- if (y == 0) {
- pmv[1] =
- pmv[2] = pmv[0];
- } else {
- pmv[1] = &motion[(x / 8) + 3];
- }
- result = svq1_decode_motion_vector(bitbuf, &motion[0], pmv);
- if (result)
- return result;
-
- /* predict and decode motion vector (2) */
- pmv[1] = &motion[0];
- pmv[2] = &motion[(x / 8) + 1];
-
- result = svq1_decode_motion_vector(bitbuf, &motion[(x / 8) + 2], pmv);
- if (result)
- return result;
-
- /* predict and decode motion vector (3) */
- pmv[2] = &motion[(x / 8) + 2];
- pmv[3] = &motion[(x / 8) + 3];
-
- result = svq1_decode_motion_vector(bitbuf, pmv[3], pmv);
- if (result)
- return result;
-
- /* form predictions */
- for (i = 0; i < 4; i++) {
- int mvx = pmv[i]->x + (i & 1) * 16;
- int mvy = pmv[i]->y + (i >> 1) * 16;
-
- // FIXME: clipping or padding?
- if (y + (mvy >> 1) < 0)
- mvy = 0;
- if (x + (mvx >> 1) < 0)
- mvx = 0;
-
- src = &previous[(x + (mvx >> 1)) + (y + (mvy >> 1)) * pitch];
- dst = current;
-
- dsp->put_pixels_tab[1][((mvy & 1) << 1) | (mvx & 1)](dst, src, pitch, 8);
-
- /* select next block */
- if (i & 1)
- current += 8 * (pitch - 1);
- else
- current += 8;
- }
-
- return 0;
-}
-
-static int svq1_decode_delta_block(AVCodecContext *avctx, DSPContext *dsp,
- GetBitContext *bitbuf,
- uint8_t *current, uint8_t *previous,
- int pitch, svq1_pmv *motion, int x, int y)
-{
- uint32_t block_type;
- int result = 0;
-
- /* get block type */
- block_type = get_vlc2(bitbuf, svq1_block_type.table, 2, 2);
-
- /* reset motion vectors */
- if (block_type == SVQ1_BLOCK_SKIP || block_type == SVQ1_BLOCK_INTRA) {
- motion[0].x =
- motion[0].y =
- motion[x / 8 + 2].x =
- motion[x / 8 + 2].y =
- motion[x / 8 + 3].x =
- motion[x / 8 + 3].y = 0;
- }
-
- switch (block_type) {
- case SVQ1_BLOCK_SKIP:
- svq1_skip_block(current, previous, pitch, x, y);
- break;
-
- case SVQ1_BLOCK_INTER:
- result = svq1_motion_inter_block(dsp, bitbuf, current, previous,
- pitch, motion, x, y);
-
- if (result != 0) {
- av_dlog(avctx, "Error in svq1_motion_inter_block %i\n", result);
- break;
- }
- result = svq1_decode_block_non_intra(bitbuf, current, pitch);
- break;
-
- case SVQ1_BLOCK_INTER_4V:
- result = svq1_motion_inter_4v_block(dsp, bitbuf, current, previous,
- pitch, motion, x, y);
-
- if (result != 0) {
- av_dlog(avctx, "Error in svq1_motion_inter_4v_block %i\n", result);
- break;
- }
- result = svq1_decode_block_non_intra(bitbuf, current, pitch);
- break;
-
- case SVQ1_BLOCK_INTRA:
- result = svq1_decode_block_intra(bitbuf, current, pitch);
- break;
- }
-
- return result;
-}
-
-static void svq1_parse_string(GetBitContext *bitbuf, uint8_t *out)
-{
- uint8_t seed;
- int i;
-
- out[0] = get_bits(bitbuf, 8);
- seed = string_table[out[0]];
-
- for (i = 1; i <= out[0]; i++) {
- out[i] = get_bits(bitbuf, 8) ^ seed;
- seed = string_table[out[i] ^ seed];
- }
-}
-
-static int svq1_decode_frame_header(AVCodecContext *avctx, AVFrame *frame)
-{
- SVQ1Context *s = avctx->priv_data;
- GetBitContext *bitbuf = &s->gb;
- int frame_size_code;
- int width = s->width;
- int height = s->height;
-
- skip_bits(bitbuf, 8); /* temporal_reference */
-
- /* frame type */
- s->nonref = 0;
- switch (get_bits(bitbuf, 2)) {
- case 0:
- frame->pict_type = AV_PICTURE_TYPE_I;
- break;
- case 2:
- s->nonref = 1;
- case 1:
- frame->pict_type = AV_PICTURE_TYPE_P;
- break;
- default:
- av_log(avctx, AV_LOG_ERROR, "Invalid frame type.\n");
- return AVERROR_INVALIDDATA;
- }
-
- if (frame->pict_type == AV_PICTURE_TYPE_I) {
- /* unknown fields */
- if (s->frame_code == 0x50 || s->frame_code == 0x60) {
- int csum = get_bits(bitbuf, 16);
-
- csum = ff_svq1_packet_checksum(bitbuf->buffer,
- bitbuf->size_in_bits >> 3,
- csum);
-
- av_dlog(avctx, "%s checksum (%02x) for packet data\n",
- (csum == 0) ? "correct" : "incorrect", csum);
- }
-
- if ((s->frame_code ^ 0x10) >= 0x50) {
- uint8_t msg[256];
-
- svq1_parse_string(bitbuf, msg);
-
- av_log(avctx, AV_LOG_INFO,
- "embedded message: \"%s\"\n", (char *)msg);
- }
-
- skip_bits(bitbuf, 2);
- skip_bits(bitbuf, 2);
- skip_bits1(bitbuf);
-
- /* load frame size */
- frame_size_code = get_bits(bitbuf, 3);
-
- if (frame_size_code == 7) {
- /* load width, height (12 bits each) */
- width = get_bits(bitbuf, 12);
- height = get_bits(bitbuf, 12);
-
- if (!width || !height)
- return AVERROR_INVALIDDATA;
- } else {
- /* get width, height from table */
- width = ff_svq1_frame_size_table[frame_size_code][0];
- height = ff_svq1_frame_size_table[frame_size_code][1];
- }
- }
-
- /* unknown fields */
- if (get_bits1(bitbuf)) {
- skip_bits1(bitbuf); /* use packet checksum if (1) */
- skip_bits1(bitbuf); /* component checksums after image data if (1) */
-
- if (get_bits(bitbuf, 2) != 0)
- return AVERROR_INVALIDDATA;
- }
-
- if (get_bits1(bitbuf)) {
- skip_bits1(bitbuf);
- skip_bits(bitbuf, 4);
- skip_bits1(bitbuf);
- skip_bits(bitbuf, 2);
-
- while (get_bits1(bitbuf))
- skip_bits(bitbuf, 8);
- }
-
- s->width = width;
- s->height = height;
- return 0;
-}
-
-static int svq1_decode_frame(AVCodecContext *avctx, void *data,
- int *got_frame, AVPacket *avpkt)
-{
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
- SVQ1Context *s = avctx->priv_data;
- AVFrame *cur = s->cur;
- uint8_t *current;
- int result, i, x, y, width, height;
- svq1_pmv *pmv;
-
- if (cur->data[0])
- avctx->release_buffer(avctx, cur);
-
- /* initialize bit buffer */
- init_get_bits(&s->gb, buf, buf_size * 8);
-
- /* decode frame header */
- s->frame_code = get_bits(&s->gb, 22);
-
- if ((s->frame_code & ~0x70) || !(s->frame_code & 0x60))
- return AVERROR_INVALIDDATA;
-
- /* swap some header bytes (why?) */
- if (s->frame_code != 0x20) {
- uint32_t *src = (uint32_t *)(buf + 4);
-
- if (buf_size < 36)
- return AVERROR_INVALIDDATA;
-
- for (i = 0; i < 4; i++)
- src[i] = ((src[i] << 16) | (src[i] >> 16)) ^ src[7 - i];
- }
-
- result = svq1_decode_frame_header(avctx, cur);
- if (result != 0) {
- av_dlog(avctx, "Error in svq1_decode_frame_header %i\n", result);
- return result;
- }
- avcodec_set_dimensions(avctx, s->width, s->height);
-
- if ((avctx->skip_frame >= AVDISCARD_NONREF && s->nonref) ||
- (avctx->skip_frame >= AVDISCARD_NONKEY &&
- cur->pict_type != AV_PICTURE_TYPE_I) ||
- avctx->skip_frame >= AVDISCARD_ALL)
- return buf_size;
-
- result = ff_get_buffer(avctx, cur);
- if (result < 0)
- return result;
-
- pmv = av_malloc((FFALIGN(s->width, 16) / 8 + 3) * sizeof(*pmv));
- if (!pmv)
- return AVERROR(ENOMEM);
-
- /* decode y, u and v components */
- for (i = 0; i < 3; i++) {
- int linesize = cur->linesize[i];
- if (i == 0) {
- width = FFALIGN(s->width, 16);
- height = FFALIGN(s->height, 16);
- } else {
- if (avctx->flags & CODEC_FLAG_GRAY)
- break;
- width = FFALIGN(s->width / 4, 16);
- height = FFALIGN(s->height / 4, 16);
- }
-
- current = cur->data[i];
-
- if (cur->pict_type == AV_PICTURE_TYPE_I) {
- /* keyframe */
- for (y = 0; y < height; y += 16) {
- for (x = 0; x < width; x += 16) {
- result = svq1_decode_block_intra(&s->gb, &current[x],
- linesize);
- if (result) {
- av_log(avctx, AV_LOG_ERROR,
- "Error in svq1_decode_block %i (keyframe)\n",
- result);
- goto err;
- }
- }
- current += 16 * linesize;
- }
- } else {
- /* delta frame */
- uint8_t *previous = s->prev->data[i];
- if (!previous || s->prev->width != s->cur->width || s->prev->height != s->cur->height) {
- av_log(avctx, AV_LOG_ERROR, "Missing reference frame.\n");
- result = AVERROR_INVALIDDATA;
- goto err;
- }
-
- memset(pmv, 0, ((width / 8) + 3) * sizeof(svq1_pmv));
-
- for (y = 0; y < height; y += 16) {
- for (x = 0; x < width; x += 16) {
- result = svq1_decode_delta_block(avctx, &s->dsp,
- &s->gb, &current[x],
- previous, linesize,
- pmv, x, y);
- if (result) {
- av_dlog(avctx,
- "Error in svq1_decode_delta_block %i\n",
- result);
- goto err;
- }
- }
-
- pmv[0].x =
- pmv[0].y = 0;
-
- current += 16 * linesize;
- }
- }
- }
-
- *(AVFrame*)data = *cur;
- cur->qscale_table = NULL;
- if (!s->nonref)
- FFSWAP(AVFrame*, s->cur, s->prev);
-
- *got_frame = 1;
- result = buf_size;
-
-err:
- av_free(pmv);
- return result;
-}
-
-static av_cold int svq1_decode_init(AVCodecContext *avctx)
-{
- SVQ1Context *s = avctx->priv_data;
- int i;
- int offset = 0;
-
- s->cur = avcodec_alloc_frame();
- s->prev = avcodec_alloc_frame();
- if (!s->cur || !s->prev) {
- avcodec_free_frame(&s->cur);
- avcodec_free_frame(&s->prev);
- return AVERROR(ENOMEM);
- }
-
- s->width = avctx->width + 3 & ~3;
- s->height = avctx->height + 3 & ~3;
- avctx->pix_fmt = AV_PIX_FMT_YUV410P;
-
- ff_dsputil_init(&s->dsp, avctx);
-
- INIT_VLC_STATIC(&svq1_block_type, 2, 4,
- &ff_svq1_block_type_vlc[0][1], 2, 1,
- &ff_svq1_block_type_vlc[0][0], 2, 1, 6);
-
- INIT_VLC_STATIC(&svq1_motion_component, 7, 33,
- &ff_mvtab[0][1], 2, 1,
- &ff_mvtab[0][0], 2, 1, 176);
-
- for (i = 0; i < 6; i++) {
- static const uint8_t sizes[2][6] = { { 14, 10, 14, 18, 16, 18 },
- { 10, 10, 14, 14, 14, 16 } };
- static VLC_TYPE table[168][2];
- svq1_intra_multistage[i].table = &table[offset];
- svq1_intra_multistage[i].table_allocated = sizes[0][i];
- offset += sizes[0][i];
- init_vlc(&svq1_intra_multistage[i], 3, 8,
- &ff_svq1_intra_multistage_vlc[i][0][1], 2, 1,
- &ff_svq1_intra_multistage_vlc[i][0][0], 2, 1,
- INIT_VLC_USE_NEW_STATIC);
- svq1_inter_multistage[i].table = &table[offset];
- svq1_inter_multistage[i].table_allocated = sizes[1][i];
- offset += sizes[1][i];
- init_vlc(&svq1_inter_multistage[i], 3, 8,
- &ff_svq1_inter_multistage_vlc[i][0][1], 2, 1,
- &ff_svq1_inter_multistage_vlc[i][0][0], 2, 1,
- INIT_VLC_USE_NEW_STATIC);
- }
-
- INIT_VLC_STATIC(&svq1_intra_mean, 8, 256,
- &ff_svq1_intra_mean_vlc[0][1], 4, 2,
- &ff_svq1_intra_mean_vlc[0][0], 4, 2, 632);
-
- INIT_VLC_STATIC(&svq1_inter_mean, 9, 512,
- &ff_svq1_inter_mean_vlc[0][1], 4, 2,
- &ff_svq1_inter_mean_vlc[0][0], 4, 2, 1434);
-
- return 0;
-}
-
-static av_cold int svq1_decode_end(AVCodecContext *avctx)
-{
- SVQ1Context *s = avctx->priv_data;
-
- if (s->cur->data[0])
- avctx->release_buffer(avctx, s->cur);
- if (s->prev->data[0])
- avctx->release_buffer(avctx, s->prev);
- avcodec_free_frame(&s->cur);
- avcodec_free_frame(&s->prev);
-
- return 0;
-}
-
-static void svq1_flush(AVCodecContext *avctx)
-{
- SVQ1Context *s = avctx->priv_data;
-
- if (s->cur->data[0])
- avctx->release_buffer(avctx, s->cur);
- if (s->prev->data[0])
- avctx->release_buffer(avctx, s->prev);
-}
-
-AVCodec ff_svq1_decoder = {
- .name = "svq1",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_SVQ1,
- .priv_data_size = sizeof(SVQ1Context),
- .init = svq1_decode_init,
- .close = svq1_decode_end,
- .decode = svq1_decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .flush = svq1_flush,
- .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV410P,
- AV_PIX_FMT_NONE },
- .long_name = NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1"),
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/svq3.c b/src/thirdparty/ffmpeg/libavcodec/svq3.c
deleted file mode 100644
index 946e94f3f..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/svq3.c
+++ /dev/null
@@ -1,1206 +0,0 @@
-/*
- * Copyright (c) 2003 The FFmpeg Project
- *
- * 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
- */
-
-/*
- * How to use this decoder:
- * SVQ3 data is transported within Apple Quicktime files. Quicktime files
- * have stsd atoms to describe media trak properties. A stsd atom for a
- * video trak contains 1 or more ImageDescription atoms. These atoms begin
- * with the 4-byte length of the atom followed by the codec fourcc. Some
- * decoders need information in this atom to operate correctly. Such
- * is the case with SVQ3. In order to get the best use out of this decoder,
- * the calling app must make the SVQ3 ImageDescription atom available
- * via the AVCodecContext's extradata[_size] field:
- *
- * AVCodecContext.extradata = pointer to ImageDescription, first characters
- * are expected to be 'S', 'V', 'Q', and '3', NOT the 4-byte atom length
- * AVCodecContext.extradata_size = size of ImageDescription atom memory
- * buffer (which will be the same as the ImageDescription atom size field
- * from the QT file, minus 4 bytes since the length is missing)
- *
- * You will know you have these parameters passed correctly when the decoder
- * correctly decodes this file:
- * http://samples.mplayerhq.hu/V-codecs/SVQ3/Vertical400kbit.sorenson3.mov
- */
-#include "internal.h"
-#include "dsputil.h"
-#include "avcodec.h"
-#include "mpegvideo.h"
-#include "h264.h"
-
-#include "h264data.h" // FIXME FIXME FIXME
-
-#include "h264_mvpred.h"
-#include "golomb.h"
-#include "rectangle.h"
-#include "vdpau_internal.h"
-
-#if CONFIG_ZLIB
-#include <zlib.h>
-#endif
-
-#include "svq1.h"
-#include "svq3.h"
-
-/**
- * @file
- * svq3 decoder.
- */
-
-typedef struct {
- H264Context h;
- int halfpel_flag;
- int thirdpel_flag;
- int unknown_flag;
- int next_slice_index;
- uint32_t watermark_key;
- uint8_t *buf;
- int buf_size;
-} SVQ3Context;
-
-#define FULLPEL_MODE 1
-#define HALFPEL_MODE 2
-#define THIRDPEL_MODE 3
-#define PREDICT_MODE 4
-
-/* dual scan (from some older h264 draft)
- * o-->o-->o o
- * | /|
- * o o o / o
- * | / | |/ |
- * o o o o
- * /
- * o-->o-->o-->o
- */
-static const uint8_t svq3_scan[16] = {
- 0 + 0 * 4, 1 + 0 * 4, 2 + 0 * 4, 2 + 1 * 4,
- 2 + 2 * 4, 3 + 0 * 4, 3 + 1 * 4, 3 + 2 * 4,
- 0 + 1 * 4, 0 + 2 * 4, 1 + 1 * 4, 1 + 2 * 4,
- 0 + 3 * 4, 1 + 3 * 4, 2 + 3 * 4, 3 + 3 * 4,
-};
-
-static const uint8_t svq3_pred_0[25][2] = {
- { 0, 0 },
- { 1, 0 }, { 0, 1 },
- { 0, 2 }, { 1, 1 }, { 2, 0 },
- { 3, 0 }, { 2, 1 }, { 1, 2 }, { 0, 3 },
- { 0, 4 }, { 1, 3 }, { 2, 2 }, { 3, 1 }, { 4, 0 },
- { 4, 1 }, { 3, 2 }, { 2, 3 }, { 1, 4 },
- { 2, 4 }, { 3, 3 }, { 4, 2 },
- { 4, 3 }, { 3, 4 },
- { 4, 4 }
-};
-
-static const int8_t svq3_pred_1[6][6][5] = {
- { { 2, -1, -1, -1, -1 }, { 2, 1, -1, -1, -1 }, { 1, 2, -1, -1, -1 },
- { 2, 1, -1, -1, -1 }, { 1, 2, -1, -1, -1 }, { 1, 2, -1, -1, -1 } },
- { { 0, 2, -1, -1, -1 }, { 0, 2, 1, 4, 3 }, { 0, 1, 2, 4, 3 },
- { 0, 2, 1, 4, 3 }, { 2, 0, 1, 3, 4 }, { 0, 4, 2, 1, 3 } },
- { { 2, 0, -1, -1, -1 }, { 2, 1, 0, 4, 3 }, { 1, 2, 4, 0, 3 },
- { 2, 1, 0, 4, 3 }, { 2, 1, 4, 3, 0 }, { 1, 2, 4, 0, 3 } },
- { { 2, 0, -1, -1, -1 }, { 2, 0, 1, 4, 3 }, { 1, 2, 0, 4, 3 },
- { 2, 1, 0, 4, 3 }, { 2, 1, 3, 4, 0 }, { 2, 4, 1, 0, 3 } },
- { { 0, 2, -1, -1, -1 }, { 0, 2, 1, 3, 4 }, { 1, 2, 3, 0, 4 },
- { 2, 0, 1, 3, 4 }, { 2, 1, 3, 0, 4 }, { 2, 0, 4, 3, 1 } },
- { { 0, 2, -1, -1, -1 }, { 0, 2, 4, 1, 3 }, { 1, 4, 2, 0, 3 },
- { 4, 2, 0, 1, 3 }, { 2, 0, 1, 4, 3 }, { 4, 2, 1, 0, 3 } },
-};
-
-static const struct {
- uint8_t run;
- uint8_t level;
-} svq3_dct_tables[2][16] = {
- { { 0, 0 }, { 0, 1 }, { 1, 1 }, { 2, 1 }, { 0, 2 }, { 3, 1 }, { 4, 1 }, { 5, 1 },
- { 0, 3 }, { 1, 2 }, { 2, 2 }, { 6, 1 }, { 7, 1 }, { 8, 1 }, { 9, 1 }, { 0, 4 } },
- { { 0, 0 }, { 0, 1 }, { 1, 1 }, { 0, 2 }, { 2, 1 }, { 0, 3 }, { 0, 4 }, { 0, 5 },
- { 3, 1 }, { 4, 1 }, { 1, 2 }, { 1, 3 }, { 0, 6 }, { 0, 7 }, { 0, 8 }, { 0, 9 } }
-};
-
-static const uint32_t svq3_dequant_coeff[32] = {
- 3881, 4351, 4890, 5481, 6154, 6914, 7761, 8718,
- 9781, 10987, 12339, 13828, 15523, 17435, 19561, 21873,
- 24552, 27656, 30847, 34870, 38807, 43747, 49103, 54683,
- 61694, 68745, 77615, 89113, 100253, 109366, 126635, 141533
-};
-
-void ff_svq3_luma_dc_dequant_idct_c(int16_t *output, int16_t *input, int qp)
-{
- const int qmul = svq3_dequant_coeff[qp];
-#define stride 16
- int i;
- int temp[16];
- static const uint8_t x_offset[4] = { 0, 1 * stride, 4 * stride, 5 * stride };
-
- for (i = 0; i < 4; i++) {
- const int z0 = 13 * (input[4 * i + 0] + input[4 * i + 2]);
- const int z1 = 13 * (input[4 * i + 0] - input[4 * i + 2]);
- const int z2 = 7 * input[4 * i + 1] - 17 * input[4 * i + 3];
- const int z3 = 17 * input[4 * i + 1] + 7 * input[4 * i + 3];
-
- temp[4 * i + 0] = z0 + z3;
- temp[4 * i + 1] = z1 + z2;
- temp[4 * i + 2] = z1 - z2;
- temp[4 * i + 3] = z0 - z3;
- }
-
- for (i = 0; i < 4; i++) {
- const int offset = x_offset[i];
- const int z0 = 13 * (temp[4 * 0 + i] + temp[4 * 2 + i]);
- const int z1 = 13 * (temp[4 * 0 + i] - temp[4 * 2 + i]);
- const int z2 = 7 * temp[4 * 1 + i] - 17 * temp[4 * 3 + i];
- const int z3 = 17 * temp[4 * 1 + i] + 7 * temp[4 * 3 + i];
-
- output[stride * 0 + offset] = (z0 + z3) * qmul + 0x80000 >> 20;
- output[stride * 2 + offset] = (z1 + z2) * qmul + 0x80000 >> 20;
- output[stride * 8 + offset] = (z1 - z2) * qmul + 0x80000 >> 20;
- output[stride * 10 + offset] = (z0 - z3) * qmul + 0x80000 >> 20;
- }
-}
-#undef stride
-
-void ff_svq3_add_idct_c(uint8_t *dst, int16_t *block,
- int stride, int qp, int dc)
-{
- const int qmul = svq3_dequant_coeff[qp];
- int i;
-
- if (dc) {
- dc = 13 * 13 * (dc == 1 ? 1538 * block[0]
- : qmul * (block[0] >> 3) / 2);
- block[0] = 0;
- }
-
- for (i = 0; i < 4; i++) {
- const int z0 = 13 * (block[0 + 4 * i] + block[2 + 4 * i]);
- const int z1 = 13 * (block[0 + 4 * i] - block[2 + 4 * i]);
- const int z2 = 7 * block[1 + 4 * i] - 17 * block[3 + 4 * i];
- const int z3 = 17 * block[1 + 4 * i] + 7 * block[3 + 4 * i];
-
- block[0 + 4 * i] = z0 + z3;
- block[1 + 4 * i] = z1 + z2;
- block[2 + 4 * i] = z1 - z2;
- block[3 + 4 * i] = z0 - z3;
- }
-
- for (i = 0; i < 4; i++) {
- const int z0 = 13 * (block[i + 4 * 0] + block[i + 4 * 2]);
- const int z1 = 13 * (block[i + 4 * 0] - block[i + 4 * 2]);
- const int z2 = 7 * block[i + 4 * 1] - 17 * block[i + 4 * 3];
- const int z3 = 17 * block[i + 4 * 1] + 7 * block[i + 4 * 3];
- const int rr = (dc + 0x80000);
-
- dst[i + stride * 0] = av_clip_uint8(dst[i + stride * 0] + ((z0 + z3) * qmul + rr >> 20));
- dst[i + stride * 1] = av_clip_uint8(dst[i + stride * 1] + ((z1 + z2) * qmul + rr >> 20));
- dst[i + stride * 2] = av_clip_uint8(dst[i + stride * 2] + ((z1 - z2) * qmul + rr >> 20));
- dst[i + stride * 3] = av_clip_uint8(dst[i + stride * 3] + ((z0 - z3) * qmul + rr >> 20));
- }
-}
-
-static inline int svq3_decode_block(GetBitContext *gb, int16_t *block,
- int index, const int type)
-{
- static const uint8_t *const scan_patterns[4] =
- { luma_dc_zigzag_scan, zigzag_scan, svq3_scan, chroma_dc_scan };
-
- int run, level, sign, limit;
- unsigned vlc;
- const int intra = 3 * type >> 2;
- const uint8_t *const scan = scan_patterns[type];
-
- for (limit = (16 >> intra); index < 16; index = limit, limit += 8) {
- for (; (vlc = svq3_get_ue_golomb(gb)) != 0; index++) {
- if ((int32_t)vlc < 0)
- return -1;
-
- sign = (vlc & 1) ? 0 : -1;
- vlc = vlc + 1 >> 1;
-
- if (type == 3) {
- if (vlc < 3) {
- run = 0;
- level = vlc;
- } else if (vlc < 4) {
- run = 1;
- level = 1;
- } else {
- run = vlc & 0x3;
- level = (vlc + 9 >> 2) - run;
- }
- } else {
- if (vlc < 16U) {
- run = svq3_dct_tables[intra][vlc].run;
- level = svq3_dct_tables[intra][vlc].level;
- } else if (intra) {
- run = vlc & 0x7;
- level = (vlc >> 3) + ((run == 0) ? 8 : ((run < 2) ? 2 : ((run < 5) ? 0 : -1)));
- } else {
- run = vlc & 0xF;
- level = (vlc >> 4) + ((run == 0) ? 4 : ((run < 3) ? 2 : ((run < 10) ? 1 : 0)));
- }
- }
-
-
- if ((index += run) >= limit)
- return -1;
-
- block[scan[index]] = (level ^ sign) - sign;
- }
-
- if (type != 2) {
- break;
- }
- }
-
- return 0;
-}
-
-static inline void svq3_mc_dir_part(MpegEncContext *s,
- int x, int y, int width, int height,
- int mx, int my, int dxy,
- int thirdpel, int dir, int avg)
-{
- const Picture *pic = (dir == 0) ? &s->last_picture : &s->next_picture;
- uint8_t *src, *dest;
- int i, emu = 0;
- int blocksize = 2 - (width >> 3); // 16->0, 8->1, 4->2
-
- mx += x;
- my += y;
-
- if (mx < 0 || mx >= s->h_edge_pos - width - 1 ||
- my < 0 || my >= s->v_edge_pos - height - 1) {
- if ((s->flags & CODEC_FLAG_EMU_EDGE))
- emu = 1;
-
- mx = av_clip(mx, -16, s->h_edge_pos - width + 15);
- my = av_clip(my, -16, s->v_edge_pos - height + 15);
- }
-
- /* form component predictions */
- dest = s->current_picture.f.data[0] + x + y * s->linesize;
- src = pic->f.data[0] + mx + my * s->linesize;
-
- if (emu) {
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer, src, s->linesize,
- width + 1, height + 1,
- mx, my, s->h_edge_pos, s->v_edge_pos);
- src = s->edge_emu_buffer;
- }
- if (thirdpel)
- (avg ? s->dsp.avg_tpel_pixels_tab
- : s->dsp.put_tpel_pixels_tab)[dxy](dest, src, s->linesize,
- width, height);
- else
- (avg ? s->dsp.avg_pixels_tab
- : s->dsp.put_pixels_tab)[blocksize][dxy](dest, src, s->linesize,
- height);
-
- if (!(s->flags & CODEC_FLAG_GRAY)) {
- mx = mx + (mx < (int) x) >> 1;
- my = my + (my < (int) y) >> 1;
- width = width >> 1;
- height = height >> 1;
- blocksize++;
-
- for (i = 1; i < 3; i++) {
- dest = s->current_picture.f.data[i] + (x >> 1) + (y >> 1) * s->uvlinesize;
- src = pic->f.data[i] + mx + my * s->uvlinesize;
-
- if (emu) {
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer, src, s->uvlinesize,
- width + 1, height + 1,
- mx, my, (s->h_edge_pos >> 1),
- s->v_edge_pos >> 1);
- src = s->edge_emu_buffer;
- }
- if (thirdpel)
- (avg ? s->dsp.avg_tpel_pixels_tab
- : s->dsp.put_tpel_pixels_tab)[dxy](dest, src,
- s->uvlinesize,
- width, height);
- else
- (avg ? s->dsp.avg_pixels_tab
- : s->dsp.put_pixels_tab)[blocksize][dxy](dest, src,
- s->uvlinesize,
- height);
- }
- }
-}
-
-static inline int svq3_mc_dir(H264Context *h, int size, int mode,
- int dir, int avg)
-{
- int i, j, k, mx, my, dx, dy, x, y;
- MpegEncContext *const s = (MpegEncContext *)h;
- const int part_width = ((size & 5) == 4) ? 4 : 16 >> (size & 1);
- const int part_height = 16 >> ((unsigned)(size + 1) / 3);
- const int extra_width = (mode == PREDICT_MODE) ? -16 * 6 : 0;
- const int h_edge_pos = 6 * (s->h_edge_pos - part_width) - extra_width;
- const int v_edge_pos = 6 * (s->v_edge_pos - part_height) - extra_width;
-
- for (i = 0; i < 16; i += part_height)
- for (j = 0; j < 16; j += part_width) {
- const int b_xy = (4 * s->mb_x + (j >> 2)) +
- (4 * s->mb_y + (i >> 2)) * h->b_stride;
- int dxy;
- x = 16 * s->mb_x + j;
- y = 16 * s->mb_y + i;
- k = (j >> 2 & 1) + (i >> 1 & 2) +
- (j >> 1 & 4) + (i & 8);
-
- if (mode != PREDICT_MODE) {
- pred_motion(h, k, part_width >> 2, dir, 1, &mx, &my);
- } else {
- mx = s->next_picture.f.motion_val[0][b_xy][0] << 1;
- my = s->next_picture.f.motion_val[0][b_xy][1] << 1;
-
- if (dir == 0) {
- mx = mx * h->frame_num_offset /
- h->prev_frame_num_offset + 1 >> 1;
- my = my * h->frame_num_offset /
- h->prev_frame_num_offset + 1 >> 1;
- } else {
- mx = mx * (h->frame_num_offset - h->prev_frame_num_offset) /
- h->prev_frame_num_offset + 1 >> 1;
- my = my * (h->frame_num_offset - h->prev_frame_num_offset) /
- h->prev_frame_num_offset + 1 >> 1;
- }
- }
-
- /* clip motion vector prediction to frame border */
- mx = av_clip(mx, extra_width - 6 * x, h_edge_pos - 6 * x);
- my = av_clip(my, extra_width - 6 * y, v_edge_pos - 6 * y);
-
- /* get (optional) motion vector differential */
- if (mode == PREDICT_MODE) {
- dx = dy = 0;
- } else {
- dy = svq3_get_se_golomb(&s->gb);
- dx = svq3_get_se_golomb(&s->gb);
-
- if (dx == INVALID_VLC || dy == INVALID_VLC) {
- av_log(h->s.avctx, AV_LOG_ERROR, "invalid MV vlc\n");
- return -1;
- }
- }
-
- /* compute motion vector */
- if (mode == THIRDPEL_MODE) {
- int fx, fy;
- mx = (mx + 1 >> 1) + dx;
- my = (my + 1 >> 1) + dy;
- fx = (unsigned)(mx + 0x3000) / 3 - 0x1000;
- fy = (unsigned)(my + 0x3000) / 3 - 0x1000;
- dxy = (mx - 3 * fx) + 4 * (my - 3 * fy);
-
- svq3_mc_dir_part(s, x, y, part_width, part_height,
- fx, fy, dxy, 1, dir, avg);
- mx += mx;
- my += my;
- } else if (mode == HALFPEL_MODE || mode == PREDICT_MODE) {
- mx = (unsigned)(mx + 1 + 0x3000) / 3 + dx - 0x1000;
- my = (unsigned)(my + 1 + 0x3000) / 3 + dy - 0x1000;
- dxy = (mx & 1) + 2 * (my & 1);
-
- svq3_mc_dir_part(s, x, y, part_width, part_height,
- mx >> 1, my >> 1, dxy, 0, dir, avg);
- mx *= 3;
- my *= 3;
- } else {
- mx = (unsigned)(mx + 3 + 0x6000) / 6 + dx - 0x1000;
- my = (unsigned)(my + 3 + 0x6000) / 6 + dy - 0x1000;
-
- svq3_mc_dir_part(s, x, y, part_width, part_height,
- mx, my, 0, 0, dir, avg);
- mx *= 6;
- my *= 6;
- }
-
- /* update mv_cache */
- if (mode != PREDICT_MODE) {
- int32_t mv = pack16to32(mx, my);
-
- if (part_height == 8 && i < 8) {
- AV_WN32A(h->mv_cache[dir][scan8[k] + 1 * 8], mv);
-
- if (part_width == 8 && j < 8)
- AV_WN32A(h->mv_cache[dir][scan8[k] + 1 + 1 * 8], mv);
- }
- if (part_width == 8 && j < 8)
- AV_WN32A(h->mv_cache[dir][scan8[k] + 1], mv);
- if (part_width == 4 || part_height == 4)
- AV_WN32A(h->mv_cache[dir][scan8[k]], mv);
- }
-
- /* write back motion vectors */
- fill_rectangle(s->current_picture.f.motion_val[dir][b_xy],
- part_width >> 2, part_height >> 2, h->b_stride,
- pack16to32(mx, my), 4);
- }
-
- return 0;
-}
-
-static int svq3_decode_mb(SVQ3Context *svq3, unsigned int mb_type)
-{
- H264Context *h = &svq3->h;
- int i, j, k, m, dir, mode;
- int cbp = 0;
- uint32_t vlc;
- int8_t *top, *left;
- MpegEncContext *const s = (MpegEncContext *)h;
- const int mb_xy = h->mb_xy;
- const int b_xy = 4 * s->mb_x + 4 * s->mb_y * h->b_stride;
-
- h->top_samples_available = (s->mb_y == 0) ? 0x33FF : 0xFFFF;
- h->left_samples_available = (s->mb_x == 0) ? 0x5F5F : 0xFFFF;
- h->topright_samples_available = 0xFFFF;
-
- if (mb_type == 0) { /* SKIP */
- if (s->pict_type == AV_PICTURE_TYPE_P ||
- s->next_picture.f.mb_type[mb_xy] == -1) {
- svq3_mc_dir_part(s, 16 * s->mb_x, 16 * s->mb_y, 16, 16,
- 0, 0, 0, 0, 0, 0);
-
- if (s->pict_type == AV_PICTURE_TYPE_B)
- svq3_mc_dir_part(s, 16 * s->mb_x, 16 * s->mb_y, 16, 16,
- 0, 0, 0, 0, 1, 1);
-
- mb_type = MB_TYPE_SKIP;
- } else {
- mb_type = FFMIN(s->next_picture.f.mb_type[mb_xy], 6);
- if (svq3_mc_dir(h, mb_type, PREDICT_MODE, 0, 0) < 0)
- return -1;
- if (svq3_mc_dir(h, mb_type, PREDICT_MODE, 1, 1) < 0)
- return -1;
-
- mb_type = MB_TYPE_16x16;
- }
- } else if (mb_type < 8) { /* INTER */
- if (svq3->thirdpel_flag && svq3->halfpel_flag == !get_bits1(&s->gb))
- mode = THIRDPEL_MODE;
- else if (svq3->halfpel_flag &&
- svq3->thirdpel_flag == !get_bits1(&s->gb))
- mode = HALFPEL_MODE;
- else
- mode = FULLPEL_MODE;
-
- /* fill caches */
- /* note ref_cache should contain here:
- * ????????
- * ???11111
- * N??11111
- * N??11111
- * N??11111
- */
-
- for (m = 0; m < 2; m++) {
- if (s->mb_x > 0 && h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1] + 6] != -1) {
- for (i = 0; i < 4; i++)
- AV_COPY32(h->mv_cache[m][scan8[0] - 1 + i * 8],
- s->current_picture.f.motion_val[m][b_xy - 1 + i * h->b_stride]);
- } else {
- for (i = 0; i < 4; i++)
- AV_ZERO32(h->mv_cache[m][scan8[0] - 1 + i * 8]);
- }
- if (s->mb_y > 0) {
- memcpy(h->mv_cache[m][scan8[0] - 1 * 8],
- s->current_picture.f.motion_val[m][b_xy - h->b_stride],
- 4 * 2 * sizeof(int16_t));
- memset(&h->ref_cache[m][scan8[0] - 1 * 8],
- (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]] == -1) ? PART_NOT_AVAILABLE : 1, 4);
-
- if (s->mb_x < s->mb_width - 1) {
- AV_COPY32(h->mv_cache[m][scan8[0] + 4 - 1 * 8],
- s->current_picture.f.motion_val[m][b_xy - h->b_stride + 4]);
- h->ref_cache[m][scan8[0] + 4 - 1 * 8] =
- (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride + 1] + 6] == -1 ||
- h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride]] == -1) ? PART_NOT_AVAILABLE : 1;
- } else
- h->ref_cache[m][scan8[0] + 4 - 1 * 8] = PART_NOT_AVAILABLE;
- if (s->mb_x > 0) {
- AV_COPY32(h->mv_cache[m][scan8[0] - 1 - 1 * 8],
- s->current_picture.f.motion_val[m][b_xy - h->b_stride - 1]);
- h->ref_cache[m][scan8[0] - 1 - 1 * 8] =
- (h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride - 1] + 3] == -1) ? PART_NOT_AVAILABLE : 1;
- } else
- h->ref_cache[m][scan8[0] - 1 - 1 * 8] = PART_NOT_AVAILABLE;
- } else
- memset(&h->ref_cache[m][scan8[0] - 1 * 8 - 1],
- PART_NOT_AVAILABLE, 8);
-
- if (s->pict_type != AV_PICTURE_TYPE_B)
- break;
- }
-
- /* decode motion vector(s) and form prediction(s) */
- if (s->pict_type == AV_PICTURE_TYPE_P) {
- if (svq3_mc_dir(h, mb_type - 1, mode, 0, 0) < 0)
- return -1;
- } else { /* AV_PICTURE_TYPE_B */
- if (mb_type != 2) {
- if (svq3_mc_dir(h, 0, mode, 0, 0) < 0)
- return -1;
- } else {
- for (i = 0; i < 4; i++)
- memset(s->current_picture.f.motion_val[0][b_xy + i * h->b_stride],
- 0, 4 * 2 * sizeof(int16_t));
- }
- if (mb_type != 1) {
- if (svq3_mc_dir(h, 0, mode, 1, mb_type == 3) < 0)
- return -1;
- } else {
- for (i = 0; i < 4; i++)
- memset(s->current_picture.f.motion_val[1][b_xy + i * h->b_stride],
- 0, 4 * 2 * sizeof(int16_t));
- }
- }
-
- mb_type = MB_TYPE_16x16;
- } else if (mb_type == 8 || mb_type == 33) { /* INTRA4x4 */
- memset(h->intra4x4_pred_mode_cache, -1, 8 * 5 * sizeof(int8_t));
-
- if (mb_type == 8) {
- if (s->mb_x > 0) {
- for (i = 0; i < 4; i++)
- h->intra4x4_pred_mode_cache[scan8[0] - 1 + i * 8] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - 1] + 6 - i];
- if (h->intra4x4_pred_mode_cache[scan8[0] - 1] == -1)
- h->left_samples_available = 0x5F5F;
- }
- if (s->mb_y > 0) {
- h->intra4x4_pred_mode_cache[4 + 8 * 0] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride] + 0];
- h->intra4x4_pred_mode_cache[5 + 8 * 0] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride] + 1];
- h->intra4x4_pred_mode_cache[6 + 8 * 0] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride] + 2];
- h->intra4x4_pred_mode_cache[7 + 8 * 0] = h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride] + 3];
-
- if (h->intra4x4_pred_mode_cache[4 + 8 * 0] == -1)
- h->top_samples_available = 0x33FF;
- }
-
- /* decode prediction codes for luma blocks */
- for (i = 0; i < 16; i += 2) {
- vlc = svq3_get_ue_golomb(&s->gb);
-
- if (vlc >= 25U) {
- av_log(h->s.avctx, AV_LOG_ERROR, "luma prediction:%d\n", vlc);
- return -1;
- }
-
- left = &h->intra4x4_pred_mode_cache[scan8[i] - 1];
- top = &h->intra4x4_pred_mode_cache[scan8[i] - 8];
-
- left[1] = svq3_pred_1[top[0] + 1][left[0] + 1][svq3_pred_0[vlc][0]];
- left[2] = svq3_pred_1[top[1] + 1][left[1] + 1][svq3_pred_0[vlc][1]];
-
- if (left[1] == -1 || left[2] == -1) {
- av_log(h->s.avctx, AV_LOG_ERROR, "weird prediction\n");
- return -1;
- }
- }
- } else { /* mb_type == 33, DC_128_PRED block type */
- for (i = 0; i < 4; i++)
- memset(&h->intra4x4_pred_mode_cache[scan8[0] + 8 * i], DC_PRED, 4);
- }
-
- write_back_intra_pred_mode(h);
-
- if (mb_type == 8) {
- ff_h264_check_intra4x4_pred_mode(h);
-
- h->top_samples_available = (s->mb_y == 0) ? 0x33FF : 0xFFFF;
- h->left_samples_available = (s->mb_x == 0) ? 0x5F5F : 0xFFFF;
- } else {
- for (i = 0; i < 4; i++)
- memset(&h->intra4x4_pred_mode_cache[scan8[0] + 8 * i], DC_128_PRED, 4);
-
- h->top_samples_available = 0x33FF;
- h->left_samples_available = 0x5F5F;
- }
-
- mb_type = MB_TYPE_INTRA4x4;
- } else { /* INTRA16x16 */
- dir = i_mb_type_info[mb_type - 8].pred_mode;
- dir = (dir >> 1) ^ 3 * (dir & 1) ^ 1;
-
- if ((h->intra16x16_pred_mode = ff_h264_check_intra_pred_mode(h, dir, 0)) == -1) {
- av_log(h->s.avctx, AV_LOG_ERROR, "check_intra_pred_mode = -1\n");
- return -1;
- }
-
- cbp = i_mb_type_info[mb_type - 8].cbp;
- mb_type = MB_TYPE_INTRA16x16;
- }
-
- if (!IS_INTER(mb_type) && s->pict_type != AV_PICTURE_TYPE_I) {
- for (i = 0; i < 4; i++)
- memset(s->current_picture.f.motion_val[0][b_xy + i * h->b_stride],
- 0, 4 * 2 * sizeof(int16_t));
- if (s->pict_type == AV_PICTURE_TYPE_B) {
- for (i = 0; i < 4; i++)
- memset(s->current_picture.f.motion_val[1][b_xy + i * h->b_stride],
- 0, 4 * 2 * sizeof(int16_t));
- }
- }
- if (!IS_INTRA4x4(mb_type)) {
- memset(h->intra4x4_pred_mode + h->mb2br_xy[mb_xy], DC_PRED, 8);
- }
- if (!IS_SKIP(mb_type) || s->pict_type == AV_PICTURE_TYPE_B) {
- memset(h->non_zero_count_cache + 8, 0, 14 * 8 * sizeof(uint8_t));
- s->dsp.clear_blocks(h->mb + 0);
- s->dsp.clear_blocks(h->mb + 384);
- }
-
- if (!IS_INTRA16x16(mb_type) &&
- (!IS_SKIP(mb_type) || s->pict_type == AV_PICTURE_TYPE_B)) {
- if ((vlc = svq3_get_ue_golomb(&s->gb)) >= 48U){
- av_log(h->s.avctx, AV_LOG_ERROR, "cbp_vlc=%d\n", vlc);
- return -1;
- }
-
- cbp = IS_INTRA(mb_type) ? golomb_to_intra4x4_cbp[vlc]
- : golomb_to_inter_cbp[vlc];
- }
- if (IS_INTRA16x16(mb_type) ||
- (s->pict_type != AV_PICTURE_TYPE_I && s->adaptive_quant && cbp)) {
- s->qscale += svq3_get_se_golomb(&s->gb);
-
- if (s->qscale > 31u) {
- av_log(h->s.avctx, AV_LOG_ERROR, "qscale:%d\n", s->qscale);
- return -1;
- }
- }
- if (IS_INTRA16x16(mb_type)) {
- AV_ZERO128(h->mb_luma_dc[0] + 0);
- AV_ZERO128(h->mb_luma_dc[0] + 8);
- if (svq3_decode_block(&s->gb, h->mb_luma_dc[0], 0, 1)) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "error while decoding intra luma dc\n");
- return -1;
- }
- }
-
- if (cbp) {
- const int index = IS_INTRA16x16(mb_type) ? 1 : 0;
- const int type = ((s->qscale < 24 && IS_INTRA4x4(mb_type)) ? 2 : 1);
-
- for (i = 0; i < 4; i++)
- if ((cbp & (1 << i))) {
- for (j = 0; j < 4; j++) {
- k = index ? (1 * (j & 1) + 2 * (i & 1) +
- 2 * (j & 2) + 4 * (i & 2))
- : (4 * i + j);
- h->non_zero_count_cache[scan8[k]] = 1;
-
- if (svq3_decode_block(&s->gb, &h->mb[16 * k], index, type)) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "error while decoding block\n");
- return -1;
- }
- }
- }
-
- if ((cbp & 0x30)) {
- for (i = 1; i < 3; ++i)
- if (svq3_decode_block(&s->gb, &h->mb[16 * 16 * i], 0, 3)) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "error while decoding chroma dc block\n");
- return -1;
- }
-
- if ((cbp & 0x20)) {
- for (i = 1; i < 3; i++) {
- for (j = 0; j < 4; j++) {
- k = 16 * i + j;
- h->non_zero_count_cache[scan8[k]] = 1;
-
- if (svq3_decode_block(&s->gb, &h->mb[16 * k], 1, 1)) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "error while decoding chroma ac block\n");
- return -1;
- }
- }
- }
- }
- }
- }
-
- h->cbp = cbp;
- s->current_picture.f.mb_type[mb_xy] = mb_type;
-
- if (IS_INTRA(mb_type))
- h->chroma_pred_mode = ff_h264_check_intra_pred_mode(h, DC_PRED8x8, 1);
-
- return 0;
-}
-
-static int svq3_decode_slice_header(AVCodecContext *avctx)
-{
- SVQ3Context *svq3 = avctx->priv_data;
- H264Context *h = &svq3->h;
- MpegEncContext *s = &h->s;
- const int mb_xy = h->mb_xy;
- int i, header;
- unsigned slice_id;
-
- header = get_bits(&s->gb, 8);
-
- if (((header & 0x9F) != 1 && (header & 0x9F) != 2) || (header & 0x60) == 0) {
- /* TODO: what? */
- av_log(avctx, AV_LOG_ERROR, "unsupported slice header (%02X)\n", header);
- return -1;
- } else {
- int length = header >> 5 & 3;
-
- svq3->next_slice_index = get_bits_count(&s->gb) +
- 8 * show_bits(&s->gb, 8 * length) +
- 8 * length;
-
- if (svq3->next_slice_index > s->gb.size_in_bits) {
- av_log(avctx, AV_LOG_ERROR, "slice after bitstream end\n");
- return -1;
- }
-
- s->gb.size_in_bits = svq3->next_slice_index - 8 * (length - 1);
- skip_bits(&s->gb, 8);
-
- if (svq3->watermark_key) {
- uint32_t header = AV_RL32(&s->gb.buffer[(get_bits_count(&s->gb) >> 3) + 1]);
- AV_WL32(&s->gb.buffer[(get_bits_count(&s->gb) >> 3) + 1],
- header ^ svq3->watermark_key);
- }
- if (length > 0) {
- memcpy((uint8_t *) &s->gb.buffer[get_bits_count(&s->gb) >> 3],
- &s->gb.buffer[s->gb.size_in_bits >> 3], length - 1);
- }
- skip_bits_long(&s->gb, 0);
- }
-
- if ((slice_id = svq3_get_ue_golomb(&s->gb)) >= 3) {
- av_log(h->s.avctx, AV_LOG_ERROR, "illegal slice type %d \n", slice_id);
- return -1;
- }
-
- h->slice_type = golomb_to_pict_type[slice_id];
-
- if ((header & 0x9F) == 2) {
- i = (s->mb_num < 64) ? 6 : (1 + av_log2(s->mb_num - 1));
- s->mb_skip_run = get_bits(&s->gb, i) -
- (s->mb_y * s->mb_width + s->mb_x);
- } else {
- skip_bits1(&s->gb);
- s->mb_skip_run = 0;
- }
-
- h->slice_num = get_bits(&s->gb, 8);
- s->qscale = get_bits(&s->gb, 5);
- s->adaptive_quant = get_bits1(&s->gb);
-
- /* unknown fields */
- skip_bits1(&s->gb);
-
- if (svq3->unknown_flag)
- skip_bits1(&s->gb);
-
- skip_bits1(&s->gb);
- skip_bits(&s->gb, 2);
-
- while (get_bits1(&s->gb))
- skip_bits(&s->gb, 8);
-
- /* reset intra predictors and invalidate motion vector references */
- if (s->mb_x > 0) {
- memset(h->intra4x4_pred_mode + h->mb2br_xy[mb_xy - 1] + 3,
- -1, 4 * sizeof(int8_t));
- memset(h->intra4x4_pred_mode + h->mb2br_xy[mb_xy - s->mb_x],
- -1, 8 * sizeof(int8_t) * s->mb_x);
- }
- if (s->mb_y > 0) {
- memset(h->intra4x4_pred_mode + h->mb2br_xy[mb_xy - s->mb_stride],
- -1, 8 * sizeof(int8_t) * (s->mb_width - s->mb_x));
-
- if (s->mb_x > 0)
- h->intra4x4_pred_mode[h->mb2br_xy[mb_xy - s->mb_stride - 1] + 3] = -1;
- }
-
- return 0;
-}
-
-static av_cold int svq3_decode_init(AVCodecContext *avctx)
-{
- SVQ3Context *svq3 = avctx->priv_data;
- H264Context *h = &svq3->h;
- MpegEncContext *s = &h->s;
- int m;
- unsigned char *extradata;
- unsigned char *extradata_end;
- unsigned int size;
- int marker_found = 0;
-
- if (ff_h264_decode_init(avctx) < 0)
- return -1;
-
- s->flags = avctx->flags;
- s->flags2 = avctx->flags2;
- s->unrestricted_mv = 1;
- h->is_complex = 1;
- h->sps.chroma_format_idc = 1;
- avctx->pix_fmt = avctx->codec->pix_fmts[0];
-
- h->chroma_qp[0] = h->chroma_qp[1] = 4;
-
- svq3->halfpel_flag = 1;
- svq3->thirdpel_flag = 1;
- svq3->unknown_flag = 0;
-
- /* prowl for the "SEQH" marker in the extradata */
- extradata = (unsigned char *)avctx->extradata;
- extradata_end = avctx->extradata + avctx->extradata_size;
- if (extradata) {
- for (m = 0; m + 8 < avctx->extradata_size; m++) {
- if (!memcmp(extradata, "SEQH", 4)) {
- marker_found = 1;
- break;
- }
- extradata++;
- }
- }
-
- /* if a match was found, parse the extra data */
- if (marker_found) {
- GetBitContext gb;
- int frame_size_code;
-
- size = AV_RB32(&extradata[4]);
- if (size > extradata_end - extradata - 8)
- return AVERROR_INVALIDDATA;
- init_get_bits(&gb, extradata + 8, size * 8);
-
- /* 'frame size code' and optional 'width, height' */
- frame_size_code = get_bits(&gb, 3);
- switch (frame_size_code) {
- case 0:
- avctx->width = 160;
- avctx->height = 120;
- break;
- case 1:
- avctx->width = 128;
- avctx->height = 96;
- break;
- case 2:
- avctx->width = 176;
- avctx->height = 144;
- break;
- case 3:
- avctx->width = 352;
- avctx->height = 288;
- break;
- case 4:
- avctx->width = 704;
- avctx->height = 576;
- break;
- case 5:
- avctx->width = 240;
- avctx->height = 180;
- break;
- case 6:
- avctx->width = 320;
- avctx->height = 240;
- break;
- case 7:
- avctx->width = get_bits(&gb, 12);
- avctx->height = get_bits(&gb, 12);
- break;
- }
-
- svq3->halfpel_flag = get_bits1(&gb);
- svq3->thirdpel_flag = get_bits1(&gb);
-
- /* unknown fields */
- skip_bits1(&gb);
- skip_bits1(&gb);
- skip_bits1(&gb);
- skip_bits1(&gb);
-
- s->low_delay = get_bits1(&gb);
-
- /* unknown field */
- skip_bits1(&gb);
-
- while (get_bits1(&gb))
- skip_bits(&gb, 8);
-
- svq3->unknown_flag = get_bits1(&gb);
- avctx->has_b_frames = !s->low_delay;
- if (svq3->unknown_flag) {
-#if CONFIG_ZLIB
- unsigned watermark_width = svq3_get_ue_golomb(&gb);
- unsigned watermark_height = svq3_get_ue_golomb(&gb);
- int u1 = svq3_get_ue_golomb(&gb);
- int u2 = get_bits(&gb, 8);
- int u3 = get_bits(&gb, 2);
- int u4 = svq3_get_ue_golomb(&gb);
- unsigned long buf_len = watermark_width *
- watermark_height * 4;
- int offset = get_bits_count(&gb) + 7 >> 3;
- uint8_t *buf;
-
- if (watermark_height <= 0 || (uint64_t)watermark_width*4 > UINT_MAX/watermark_height)
- return -1;
-
- buf = av_malloc(buf_len);
- av_log(avctx, AV_LOG_DEBUG, "watermark size: %dx%d\n",
- watermark_width, watermark_height);
- av_log(avctx, AV_LOG_DEBUG,
- "u1: %x u2: %x u3: %x compressed data size: %d offset: %d\n",
- u1, u2, u3, u4, offset);
- if (uncompress(buf, &buf_len, extradata + 8 + offset,
- size - offset) != Z_OK) {
- av_log(avctx, AV_LOG_ERROR,
- "could not uncompress watermark logo\n");
- av_free(buf);
- return -1;
- }
- svq3->watermark_key = ff_svq1_packet_checksum(buf, buf_len, 0);
- svq3->watermark_key = svq3->watermark_key << 16 |
- svq3->watermark_key;
- av_log(avctx, AV_LOG_DEBUG,
- "watermark key %#x\n", svq3->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;
-#endif
- }
- }
-
- s->width = avctx->width;
- s->height = avctx->height;
-
- if (ff_MPV_common_init(s) < 0)
- return -1;
-
- h->b_stride = 4 * s->mb_width;
-
- if (ff_h264_alloc_tables(h) < 0) {
- av_log(avctx, AV_LOG_ERROR, "svq3 memory allocation failed\n");
- return AVERROR(ENOMEM);
- }
-
- return 0;
-}
-
-static int svq3_decode_frame(AVCodecContext *avctx, void *data,
- int *got_frame, AVPacket *avpkt)
-{
- SVQ3Context *svq3 = avctx->priv_data;
- H264Context *h = &svq3->h;
- MpegEncContext *s = &h->s;
- int buf_size = avpkt->size;
- int m, left;
- uint8_t *buf;
-
- /* special case for last picture */
- if (buf_size == 0) {
- if (s->next_picture_ptr && !s->low_delay) {
- *(AVFrame *) data = s->next_picture.f;
- s->next_picture_ptr = NULL;
- *got_frame = 1;
- }
- return 0;
- }
-
- s->mb_x = s->mb_y = h->mb_xy = 0;
-
- if (svq3->watermark_key) {
- av_fast_malloc(&svq3->buf, &svq3->buf_size,
- buf_size+FF_INPUT_BUFFER_PADDING_SIZE);
- if (!svq3->buf)
- return AVERROR(ENOMEM);
- memcpy(svq3->buf, avpkt->data, buf_size);
- buf = svq3->buf;
- } else {
- buf = avpkt->data;
- }
-
- init_get_bits(&s->gb, buf, 8 * buf_size);
-
- if (svq3_decode_slice_header(avctx))
- return -1;
-
- s->pict_type = h->slice_type;
- s->picture_number = h->slice_num;
-
- if (avctx->debug & FF_DEBUG_PICT_INFO)
- av_log(h->s.avctx, AV_LOG_DEBUG,
- "%c hpel:%d, tpel:%d aqp:%d qp:%d, slice_num:%02X\n",
- av_get_picture_type_char(s->pict_type),
- svq3->halfpel_flag, svq3->thirdpel_flag,
- s->adaptive_quant, s->qscale, h->slice_num);
-
- /* 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);
-
- /* Skip B-frames if we do not have reference frames. */
- if (s->last_picture_ptr == NULL && s->pict_type == AV_PICTURE_TYPE_B)
- return 0;
- 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 ||
- avctx->skip_frame >= AVDISCARD_ALL)
- return 0;
-
- if (s->next_p_frame_damaged) {
- if (s->pict_type == AV_PICTURE_TYPE_B)
- return 0;
- else
- s->next_p_frame_damaged = 0;
- }
-
- if (ff_h264_frame_start(h) < 0)
- return -1;
-
- if (s->pict_type == AV_PICTURE_TYPE_B) {
- h->frame_num_offset = h->slice_num - h->prev_frame_num;
-
- if (h->frame_num_offset < 0)
- h->frame_num_offset += 256;
- if (h->frame_num_offset == 0 ||
- h->frame_num_offset >= h->prev_frame_num_offset) {
- av_log(h->s.avctx, AV_LOG_ERROR, "error in B-frame picture id\n");
- return -1;
- }
- } else {
- h->prev_frame_num = h->frame_num;
- h->frame_num = h->slice_num;
- h->prev_frame_num_offset = h->frame_num - h->prev_frame_num;
-
- if (h->prev_frame_num_offset < 0)
- h->prev_frame_num_offset += 256;
- }
-
- for (m = 0; m < 2; m++) {
- int i;
- for (i = 0; i < 4; i++) {
- int j;
- for (j = -1; j < 4; j++)
- h->ref_cache[m][scan8[0] + 8 * i + j] = 1;
- if (i < 3)
- h->ref_cache[m][scan8[0] + 8 * i + j] = PART_NOT_AVAILABLE;
- }
- }
-
- for (s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) {
- for (s->mb_x = 0; s->mb_x < s->mb_width; s->mb_x++) {
- unsigned mb_type;
- h->mb_xy = s->mb_x + s->mb_y * s->mb_stride;
-
- if ((get_bits_count(&s->gb) + 7) >= s->gb.size_in_bits &&
- ((get_bits_count(&s->gb) & 7) == 0 ||
- show_bits(&s->gb, -get_bits_count(&s->gb) & 7) == 0)) {
- skip_bits(&s->gb, svq3->next_slice_index - get_bits_count(&s->gb));
- s->gb.size_in_bits = 8 * buf_size;
-
- if (svq3_decode_slice_header(avctx))
- return -1;
-
- /* TODO: support s->mb_skip_run */
- }
-
- mb_type = svq3_get_ue_golomb(&s->gb);
-
- if (s->pict_type == AV_PICTURE_TYPE_I)
- mb_type += 8;
- else if (s->pict_type == AV_PICTURE_TYPE_B && mb_type >= 4)
- mb_type += 4;
- if (mb_type > 33 || svq3_decode_mb(svq3, mb_type)) {
- av_log(h->s.avctx, AV_LOG_ERROR,
- "error while decoding MB %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
-
- if (mb_type != 0)
- ff_h264_hl_decode_mb(h);
-
- if (s->pict_type != AV_PICTURE_TYPE_B && !s->low_delay)
- s->current_picture.f.mb_type[s->mb_x + s->mb_y * s->mb_stride] =
- (s->pict_type == AV_PICTURE_TYPE_P && mb_type < 8) ? (mb_type - 1) : -1;
- }
-
- ff_draw_horiz_band(s, 16 * s->mb_y, 16);
- }
-
- left = buf_size*8 - get_bits_count(&s->gb);
-
- if (s->mb_y != s->mb_height || s->mb_x != s->mb_width) {
- av_log(avctx, AV_LOG_INFO, "frame num %d incomplete pic x %d y %d left %d\n", avctx->frame_number, s->mb_y, s->mb_x, left);
- //av_hex_dump(stderr, buf+buf_size-8, 8);
- }
-
- if (left < 0) {
- av_log(avctx, AV_LOG_ERROR, "frame num %d left %d\n", avctx->frame_number, left);
- return -1;
- }
-
- ff_MPV_frame_end(s);
-
- if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay)
- *(AVFrame *)data = s->current_picture.f;
- else
- *(AVFrame *)data = s->last_picture.f;
-
- /* Do not output the last pic after seeking. */
- if (s->last_picture_ptr || s->low_delay)
- *got_frame = 1;
-
- return buf_size;
-}
-
-static int svq3_decode_end(AVCodecContext *avctx)
-{
- SVQ3Context *svq3 = avctx->priv_data;
- H264Context *h = &svq3->h;
- MpegEncContext *s = &h->s;
-
- ff_h264_free_context(h);
-
- ff_MPV_common_end(s);
-
- av_freep(&svq3->buf);
- svq3->buf_size = 0;
-
- return 0;
-}
-
-AVCodec ff_svq3_decoder = {
- .name = "svq3",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_SVQ3,
- .priv_data_size = sizeof(SVQ3Context),
- .init = svq3_decode_init,
- .close = svq3_decode_end,
- .decode = svq3_decode_frame,
- .capabilities = CODEC_CAP_DRAW_HORIZ_BAND |
- CODEC_CAP_DR1 |
- CODEC_CAP_DELAY,
- .long_name = NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 3 / Sorenson Video 3 / SVQ3"),
- .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P,
- AV_PIX_FMT_NONE},
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/svq3.h b/src/thirdparty/ffmpeg/libavcodec/svq3.h
deleted file mode 100644
index 7a57d8ad0..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/svq3.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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_SVQ3_H
-#define AVCODEC_SVQ3_H
-
-#include <stdint.h>
-
-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 */
diff --git a/src/thirdparty/ffmpeg/libavcodec/synth_filter.c b/src/thirdparty/ffmpeg/libavcodec/synth_filter.c
deleted file mode 100644
index 517e83a61..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/synth_filter.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * copyright (c) 2008 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
- */
-
-#include "fft.h"
-#include "synth_filter.h"
-
-static void synth_filter_float(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;
- int i, j;
-
- imdct->imdct_half(imdct, synth_buf, in);
-
- for (i = 0; i < 16; i++){
- float a= synth_buf2[i ];
- float b= synth_buf2[i + 16];
- float c= 0;
- float d= 0;
- for (j = 0; j < 512 - *synth_buf_offset; j += 64){
- a += window[i + j ]*(-synth_buf[15 - i + j ]);
- b += window[i + j + 16]*( synth_buf[ i + j ]);
- c += window[i + j + 32]*( synth_buf[16 + i + j ]);
- d += window[i + j + 48]*( synth_buf[31 - i + j ]);
- }
- for ( ; j < 512; j += 64){
- a += window[i + j ]*(-synth_buf[15 - i + j - 512]);
- b += window[i + j + 16]*( synth_buf[ i + j - 512]);
- c += window[i + j + 32]*( synth_buf[16 + i + j - 512]);
- d += window[i + j + 48]*( synth_buf[31 - i + j - 512]);
- }
- out[i ] = a*scale;
- out[i + 16] = b*scale;
- synth_buf2[i ] = c;
- synth_buf2[i + 16] = d;
- }
- *synth_buf_offset= (*synth_buf_offset - 32)&511;
-}
-
-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);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/synth_filter.h b/src/thirdparty/ffmpeg/libavcodec/synth_filter.h
deleted file mode 100644
index c653477f5..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/synth_filter.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * copyright (c) 2008 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
- */
-
-#ifndef AVCODEC_SYNTH_FILTER_H
-#define AVCODEC_SYNTH_FILTER_H
-
-#include "fft.h"
-
-typedef struct SynthFilterContext {
- void (*synth_filter_float)(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);
-} SynthFilterContext;
-
-void ff_synth_filter_init(SynthFilterContext *c);
-void ff_synth_filter_init_arm(SynthFilterContext *c);
-
-#endif /* AVCODEC_SYNTH_FILTER_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/thread.h b/src/thirdparty/ffmpeg/libavcodec/thread.h
deleted file mode 100644
index 8ca46b4d5..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/thread.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (c) 2008 Alexander Strange <astrange@ithinksw.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
- * Multithreading support functions
- * @author Alexander Strange <astrange@ithinksw.com>
- */
-
-#ifndef AVCODEC_THREAD_H
-#define AVCODEC_THREAD_H
-
-#include "config.h"
-#include "avcodec.h"
-
-/**
- * Wait for decoding threads to finish and reset internal state.
- * Called by avcodec_flush_buffers().
- *
- * @param avctx The context.
- */
-void ff_thread_flush(AVCodecContext *avctx);
-
-/**
- * Submit a new frame to a decoding thread.
- * Returns the next available frame in picture. *got_picture_ptr
- * will be 0 if none is available.
- * The return value on success is the size of the consumed packet for
- * compatibility with avcodec_decode_video2(). This means the decoder
- * has to consume the full packet.
- *
- * Parameters are the same as avcodec_decode_video2().
- */
-int ff_thread_decode_frame(AVCodecContext *avctx, AVFrame *picture,
- int *got_picture_ptr, AVPacket *avpkt);
-
-/**
- * If the codec defines update_thread_context(), call this
- * when they are ready for the next thread to start decoding
- * the next frame. After calling it, do not change any variables
- * read by the update_thread_context() method, or call ff_thread_get_buffer().
- *
- * @param avctx The context.
- */
-void ff_thread_finish_setup(AVCodecContext *avctx);
-
-/**
- * Notify later decoding threads when part of their reference picture is ready.
- * Call this when some part of the picture is finished decoding.
- * Later calls with lower values of progress have no effect.
- *
- * @param f The picture being decoded.
- * @param progress Value, in arbitrary units, of how much of the picture has decoded.
- * @param field The field being decoded, for field-picture codecs.
- * 0 for top field or frame pictures, 1 for bottom field.
- */
-void ff_thread_report_progress(AVFrame *f, int progress, int field);
-
-/**
- * Wait for earlier decoding threads to finish reference pictures.
- * Call this before accessing some part of a picture, with a given
- * value for progress, and it will return after the responsible decoding
- * thread calls ff_thread_report_progress() with the same or
- * higher value for progress.
- *
- * @param f The picture being referenced.
- * @param progress Value, in arbitrary units, to wait for.
- * @param field The field being referenced, for field-picture codecs.
- * 0 for top field or frame pictures, 1 for bottom field.
- */
-void ff_thread_await_progress(AVFrame *f, int progress, int field);
-
-/**
- * Wrapper around get_buffer() for frame-multithreaded codecs.
- * Call this function instead of ff_get_buffer(f).
- * Cannot be called after the codec has called ff_thread_finish_setup().
- *
- * @param avctx The current context.
- * @param f The frame to write into.
- */
-int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f);
-
-/**
- * Wrapper around release_buffer() frame-for multithreaded codecs.
- * Call this function instead of avctx->release_buffer(f).
- * The AVFrame will be copied and the actual release_buffer() call
- * will be performed later. The contents of data pointed to by the
- * AVFrame should not be changed until ff_thread_get_buffer() is called
- * on it.
- *
- * @param avctx The current context.
- * @param f The picture being released.
- */
-void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f);
-
-int ff_thread_init(AVCodecContext *s);
-void ff_thread_free(AVCodecContext *s);
-
-// ==> Start patch MPC
-/**
- * Default lock manager for pthread system
- */
-int ff_pthread_lockmgr_cb(void **mutex, enum AVLockOp op);
-// ==> End patch MPC
-
-// ffdshow custom code. return pointer to the copied AVCodecContext for thread 0.
-AVCodecContext* get_thread0_avctx(AVCodecContext *avctx);
-
-#endif /* AVCODEC_THREAD_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/tscc.c b/src/thirdparty/ffmpeg/libavcodec/tscc.c
deleted file mode 100644
index fe1b63257..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/tscc.c
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * TechSmith Camtasia decoder
- * Copyright (c) 2004 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
- */
-
-/**
- * @file
- * TechSmith Camtasia decoder
- *
- * Fourcc: TSCC
- *
- * Codec is very simple:
- * it codes picture (picture difference, really)
- * with algorithm almost identical to Windows RLE8,
- * only without padding and with greater pixel sizes,
- * then this coded picture is packed with ZLib
- *
- * Supports: BGR8,BGR555,BGR24 - only BGR8 and BGR555 tested
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "avcodec.h"
-#include "internal.h"
-#include "msrledec.h"
-
-#include <zlib.h>
-
-typedef struct TsccContext {
-
- AVCodecContext *avctx;
- AVFrame pic;
-
- // Bits per pixel
- int bpp;
- // Decompressed data size
- unsigned int decomp_size;
- // Decompression buffer
- unsigned char* decomp_buf;
- GetByteContext gb;
- int height;
- z_stream zstream;
-
- uint32_t pal[256];
-} CamtasiaContext;
-
-static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
- AVPacket *avpkt)
-{
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
- CamtasiaContext * const c = avctx->priv_data;
- const unsigned char *encoded = buf;
- int zret; // Zlib return code
- int ret, len = buf_size;
-
- c->pic.reference = 3;
- c->pic.buffer_hints = FF_BUFFER_HINTS_VALID;
- if ((ret = avctx->reget_buffer(avctx, &c->pic)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return ret;
- }
-
- zret = inflateReset(&c->zstream);
- if (zret != Z_OK) {
- av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret);
- return AVERROR_UNKNOWN;
- }
- c->zstream.next_in = (uint8_t*)encoded;
- c->zstream.avail_in = len;
- c->zstream.next_out = c->decomp_buf;
- c->zstream.avail_out = c->decomp_size;
- zret = inflate(&c->zstream, Z_FINISH);
- // Z_DATA_ERROR means empty picture
- if ((zret != Z_OK) && (zret != Z_STREAM_END) && (zret != Z_DATA_ERROR)) {
- av_log(avctx, AV_LOG_ERROR, "Inflate error: %d\n", zret);
- return AVERROR_UNKNOWN;
- }
-
-
- if (zret != Z_DATA_ERROR) {
- bytestream2_init(&c->gb, c->decomp_buf,
- c->decomp_size - c->zstream.avail_out);
- ff_msrle_decode(avctx, (AVPicture*)&c->pic, c->bpp, &c->gb);
- }
-
- /* make the palette available on the way out */
- if (c->avctx->pix_fmt == AV_PIX_FMT_PAL8) {
- const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
-
- if (pal) {
- c->pic.palette_has_changed = 1;
- memcpy(c->pal, pal, AVPALETTE_SIZE);
- }
- memcpy(c->pic.data[1], c->pal, AVPALETTE_SIZE);
- }
-
- *got_frame = 1;
- *(AVFrame*)data = c->pic;
-
- /* always report that the buffer was completely consumed */
- return buf_size;
-}
-
-static av_cold int decode_init(AVCodecContext *avctx)
-{
- CamtasiaContext * const c = avctx->priv_data;
- int zret; // Zlib return code
-
- c->avctx = avctx;
-
- c->height = avctx->height;
-
- avcodec_get_frame_defaults(&c->pic);
- // Needed if zlib unused or init aborted before inflateInit
- memset(&c->zstream, 0, sizeof(z_stream));
- switch(avctx->bits_per_coded_sample){
- case 8: avctx->pix_fmt = AV_PIX_FMT_PAL8; break;
- case 16: avctx->pix_fmt = AV_PIX_FMT_RGB555; break;
- case 24:
- avctx->pix_fmt = AV_PIX_FMT_BGR24;
- break;
- case 32: avctx->pix_fmt = AV_PIX_FMT_RGB32; break;
- default: av_log(avctx, AV_LOG_ERROR, "Camtasia error: unknown depth %i bpp\n", avctx->bits_per_coded_sample);
- return AVERROR_PATCHWELCOME;
- }
- c->bpp = avctx->bits_per_coded_sample;
- // buffer size for RLE 'best' case when 2-byte code precedes each pixel and there may be padding after it too
- c->decomp_size = (((avctx->width * c->bpp + 7) >> 3) + 3 * avctx->width + 2) * avctx->height + 2;
-
- /* Allocate decompression buffer */
- if (c->decomp_size) {
- if ((c->decomp_buf = av_malloc(c->decomp_size)) == NULL) {
- av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
- return AVERROR(ENOMEM);
- }
- }
-
- c->zstream.zalloc = Z_NULL;
- c->zstream.zfree = Z_NULL;
- c->zstream.opaque = Z_NULL;
- zret = inflateInit(&c->zstream);
- if (zret != Z_OK) {
- av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret);
- return AVERROR_UNKNOWN;
- }
-
- return 0;
-}
-
-static av_cold int decode_end(AVCodecContext *avctx)
-{
- CamtasiaContext * const c = avctx->priv_data;
-
- av_freep(&c->decomp_buf);
-
- if (c->pic.data[0])
- avctx->release_buffer(avctx, &c->pic);
- inflateEnd(&c->zstream);
-
- return 0;
-}
-
-AVCodec ff_tscc_decoder = {
- .name = "camtasia",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_TSCC,
- .priv_data_size = sizeof(CamtasiaContext),
- .init = decode_init,
- .close = decode_end,
- .decode = decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("TechSmith Screen Capture Codec"),
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/unary.h b/src/thirdparty/ffmpeg/libavcodec/unary.h
deleted file mode 100644
index bcc31ab59..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/unary.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * copyright (c) 2004 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
- */
-
-#ifndef AVCODEC_UNARY_H
-#define AVCODEC_UNARY_H
-
-#include "get_bits.h"
-
-/**
- * Get unary code of limited length
- * @param gb GetBitContext
- * @param[in] stop The bitstop value (unary code of 1's or 0's)
- * @param[in] len Maximum length
- * @return Unary length/index
- */
-static inline int get_unary(GetBitContext *gb, int stop, int len)
-{
- int i;
-
- for(i = 0; i < len && get_bits1(gb) != stop; i++);
- return i;
-}
-
-/**
- * Get unary code terminated by a 0 with a maximum length of 33
- * @param gb GetBitContext
- * @return Unary length/index
- */
-static inline int get_unary_0_33(GetBitContext *gb)
-{
- return get_unary(gb, 0, 33);
-}
-
-static inline int get_unary_0_9(GetBitContext *gb)
-{
- return get_unary(gb, 0, 9);
-}
-
-#endif /* AVCODEC_UNARY_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/utils.c b/src/thirdparty/ffmpeg/libavcodec/utils.c
deleted file mode 100644
index 9185e17da..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/utils.c
+++ /dev/null
@@ -1,2750 +0,0 @@
-/*
- * utils for libavcodec
- * Copyright (c) 2001 Fabrice Bellard
- * Copyright (c) 2002-2004 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
- * utils.
- */
-
-#include "config.h"
-#include "libavutil/avassert.h"
-#include "libavutil/avstring.h"
-#include "libavutil/bprint.h"
-#include "libavutil/channel_layout.h"
-#include "libavutil/crc.h"
-#include "libavutil/mathematics.h"
-#include "libavutil/pixdesc.h"
-#include "libavutil/imgutils.h"
-#include "libavutil/samplefmt.h"
-#include "libavutil/dict.h"
-#include "libavutil/avassert.h"
-#include "avcodec.h"
-#include "dsputil.h"
-#include "libavutil/opt.h"
-#include "thread.h"
-#include "frame_thread_encoder.h"
-#include "internal.h"
-#include "bytestream.h"
-#include <stdlib.h>
-#include <stdarg.h>
-#include <limits.h>
-#include <float.h>
-
-volatile int ff_avcodec_locked;
-static int volatile entangled_thread_counter = 0;
-static int (*ff_lockmgr_cb)(void **mutex, enum AVLockOp op);
-static void *codec_mutex;
-static void *avformat_mutex;
-
-void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
-{
- if (min_size < *size)
- return ptr;
-
- min_size = FFMAX(17 * min_size / 16 + 32, min_size);
-
- ptr = av_realloc(ptr, min_size);
- /* we could set this to the unmodified min_size but this is safer
- * if the user lost the ptr and uses NULL now
- */
- if (!ptr)
- min_size = 0;
-
- *size = min_size;
-
- return ptr;
-}
-
-static inline int ff_fast_malloc(void *ptr, unsigned int *size, size_t min_size, int zero_realloc)
-{
- void **p = ptr;
- if (min_size < *size)
- return 0;
- min_size = FFMAX(17 * min_size / 16 + 32, min_size);
- av_free(*p);
- *p = zero_realloc ? av_mallocz(min_size) : av_malloc(min_size);
- if (!*p)
- min_size = 0;
- *size = min_size;
- return 1;
-}
-
-void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
-{
- ff_fast_malloc(ptr, size, min_size, 0);
-}
-
-void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
-{
- uint8_t **p = ptr;
- if (min_size > SIZE_MAX - FF_INPUT_BUFFER_PADDING_SIZE) {
- av_freep(p);
- *size = 0;
- return;
- }
- if (!ff_fast_malloc(p, size, min_size + FF_INPUT_BUFFER_PADDING_SIZE, 1))
- memset(*p + min_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
-}
-
-void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size)
-{
- uint8_t **p = ptr;
- if (min_size > SIZE_MAX - FF_INPUT_BUFFER_PADDING_SIZE) {
- av_freep(p);
- *size = 0;
- return;
- }
- if (!ff_fast_malloc(p, size, min_size + FF_INPUT_BUFFER_PADDING_SIZE, 1))
- memset(*p, 0, min_size + FF_INPUT_BUFFER_PADDING_SIZE);
-}
-
-/* encoder management */
-static AVCodec *first_avcodec = NULL;
-
-AVCodec *av_codec_next(const AVCodec *c)
-{
- if (c)
- return c->next;
- else
- return first_avcodec;
-}
-
-static void avcodec_init(void)
-{
- static int initialized = 0;
-
- if (initialized != 0)
- return;
- initialized = 1;
-
- ff_dsputil_static_init();
-}
-
-int av_codec_is_encoder(const AVCodec *codec)
-{
- return codec && (codec->encode_sub || codec->encode2);
-}
-
-int av_codec_is_decoder(const AVCodec *codec)
-{
- return codec && codec->decode;
-}
-
-void avcodec_register(AVCodec *codec)
-{
- AVCodec **p;
- avcodec_init();
- p = &first_avcodec;
- while (*p != NULL)
- p = &(*p)->next;
- *p = codec;
- codec->next = NULL;
-
- if (codec->init_static_data)
- codec->init_static_data(codec);
-}
-
-unsigned avcodec_get_edge_width(void)
-{
- return EDGE_WIDTH;
-}
-
-void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
-{
- s->coded_width = width;
- s->coded_height = height;
- s->width = -((-width ) >> s->lowres);
- s->height = -((-height) >> s->lowres);
-}
-
-#define INTERNAL_BUFFER_SIZE (32 + 1)
-
-#if (ARCH_ARM && HAVE_NEON) || ARCH_PPC || HAVE_MMX
-# define STRIDE_ALIGN 16
-#else
-# define STRIDE_ALIGN 8
-#endif
-
-void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
- int linesize_align[AV_NUM_DATA_POINTERS])
-{
- int i;
- int w_align = 1;
- int h_align = 1;
-
- switch (s->pix_fmt) {
- case AV_PIX_FMT_YUV420P:
- case AV_PIX_FMT_YUYV422:
- case AV_PIX_FMT_UYVY422:
- case AV_PIX_FMT_YUV422P:
- case AV_PIX_FMT_YUV440P:
- case AV_PIX_FMT_YUV444P:
- case AV_PIX_FMT_GBRP:
- case AV_PIX_FMT_GRAY8:
- case AV_PIX_FMT_GRAY16BE:
- case AV_PIX_FMT_GRAY16LE:
- case AV_PIX_FMT_YUVJ420P:
- case AV_PIX_FMT_YUVJ422P:
- case AV_PIX_FMT_YUVJ440P:
- case AV_PIX_FMT_YUVJ444P:
- case AV_PIX_FMT_YUVA420P:
- case AV_PIX_FMT_YUVA422P:
- case AV_PIX_FMT_YUVA444P:
- case AV_PIX_FMT_YUV420P9LE:
- case AV_PIX_FMT_YUV420P9BE:
- case AV_PIX_FMT_YUV420P10LE:
- case AV_PIX_FMT_YUV420P10BE:
- case AV_PIX_FMT_YUV420P12LE:
- case AV_PIX_FMT_YUV420P12BE:
- case AV_PIX_FMT_YUV420P14LE:
- case AV_PIX_FMT_YUV420P14BE:
- case AV_PIX_FMT_YUV422P9LE:
- case AV_PIX_FMT_YUV422P9BE:
- case AV_PIX_FMT_YUV422P10LE:
- case AV_PIX_FMT_YUV422P10BE:
- case AV_PIX_FMT_YUV422P12LE:
- case AV_PIX_FMT_YUV422P12BE:
- case AV_PIX_FMT_YUV422P14LE:
- case AV_PIX_FMT_YUV422P14BE:
- case AV_PIX_FMT_YUV444P9LE:
- case AV_PIX_FMT_YUV444P9BE:
- case AV_PIX_FMT_YUV444P10LE:
- case AV_PIX_FMT_YUV444P10BE:
- case AV_PIX_FMT_YUV444P12LE:
- case AV_PIX_FMT_YUV444P12BE:
- case AV_PIX_FMT_YUV444P14LE:
- case AV_PIX_FMT_YUV444P14BE:
- case AV_PIX_FMT_GBRP9LE:
- case AV_PIX_FMT_GBRP9BE:
- case AV_PIX_FMT_GBRP10LE:
- case AV_PIX_FMT_GBRP10BE:
- case AV_PIX_FMT_GBRP12LE:
- case AV_PIX_FMT_GBRP12BE:
- case AV_PIX_FMT_GBRP14LE:
- case AV_PIX_FMT_GBRP14BE:
- w_align = 16; //FIXME assume 16 pixel per macroblock
- h_align = 16 * 2; // interlaced needs 2 macroblocks height
- break;
- case AV_PIX_FMT_YUV411P:
- case AV_PIX_FMT_UYYVYY411:
- w_align = 32;
- h_align = 8;
- break;
- case AV_PIX_FMT_YUV410P:
- if (s->codec_id == AV_CODEC_ID_SVQ1) {
- w_align = 64;
- h_align = 64;
- }
- break;
- case AV_PIX_FMT_RGB555:
- if (s->codec_id == AV_CODEC_ID_RPZA) {
- w_align = 4;
- h_align = 4;
- }
- break;
- case AV_PIX_FMT_PAL8:
- case AV_PIX_FMT_BGR8:
- case AV_PIX_FMT_RGB8:
- if (s->codec_id == AV_CODEC_ID_SMC) {
- w_align = 4;
- h_align = 4;
- }
- break;
- case AV_PIX_FMT_BGR24:
- if ((s->codec_id == AV_CODEC_ID_MSZH) ||
- (s->codec_id == AV_CODEC_ID_ZLIB)) {
- w_align = 4;
- h_align = 4;
- }
- break;
- default:
- w_align = 1;
- h_align = 1;
- break;
- }
-
- if (s->codec_id == AV_CODEC_ID_IFF_ILBM || s->codec_id == AV_CODEC_ID_IFF_BYTERUN1) {
- w_align = FFMAX(w_align, 8);
- }
-
- *width = FFALIGN(*width, w_align);
- *height = FFALIGN(*height, h_align);
- if (s->codec_id == AV_CODEC_ID_H264 || s->lowres)
- // some of the optimized chroma MC reads one line too much
- // which is also done in mpeg decoders with lowres > 0
- *height += 2;
-
- for (i = 0; i < 4; i++)
- linesize_align[i] = STRIDE_ALIGN;
-}
-
-void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->pix_fmt);
- int chroma_shift = desc->log2_chroma_w;
- int linesize_align[AV_NUM_DATA_POINTERS];
- int align;
-
- avcodec_align_dimensions2(s, width, height, linesize_align);
- align = FFMAX(linesize_align[0], linesize_align[3]);
- linesize_align[1] <<= chroma_shift;
- linesize_align[2] <<= chroma_shift;
- align = FFMAX3(align, linesize_align[1], linesize_align[2]);
- *width = FFALIGN(*width, align);
-}
-
-int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels,
- enum AVSampleFormat sample_fmt, const uint8_t *buf,
- int buf_size, int align)
-{
- int ch, planar, needed_size, ret = 0;
-
- needed_size = av_samples_get_buffer_size(NULL, nb_channels,
- frame->nb_samples, sample_fmt,
- align);
- if (buf_size < needed_size)
- return AVERROR(EINVAL);
-
- planar = av_sample_fmt_is_planar(sample_fmt);
- if (planar && nb_channels > AV_NUM_DATA_POINTERS) {
- if (!(frame->extended_data = av_mallocz(nb_channels *
- sizeof(*frame->extended_data))))
- return AVERROR(ENOMEM);
- } else {
- frame->extended_data = frame->data;
- }
-
- if ((ret = av_samples_fill_arrays(frame->extended_data, &frame->linesize[0],
- (uint8_t *)(intptr_t)buf, nb_channels, frame->nb_samples,
- sample_fmt, align)) < 0) {
- if (frame->extended_data != frame->data)
- av_freep(&frame->extended_data);
- return ret;
- }
- if (frame->extended_data != frame->data) {
- for (ch = 0; ch < AV_NUM_DATA_POINTERS; ch++)
- frame->data[ch] = frame->extended_data[ch];
- }
-
- return ret;
-}
-
-static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame)
-{
- AVCodecInternal *avci = avctx->internal;
- int buf_size, ret;
-
- av_freep(&avci->audio_data);
- buf_size = av_samples_get_buffer_size(NULL, avctx->channels,
- frame->nb_samples, avctx->sample_fmt,
- 0);
- if (buf_size < 0)
- return AVERROR(EINVAL);
-
- frame->data[0] = av_mallocz(buf_size);
- if (!frame->data[0])
- return AVERROR(ENOMEM);
-
- ret = avcodec_fill_audio_frame(frame, avctx->channels, avctx->sample_fmt,
- frame->data[0], buf_size, 0);
- if (ret < 0) {
- av_freep(&frame->data[0]);
- return ret;
- }
-
- avci->audio_data = frame->data[0];
- if (avctx->debug & FF_DEBUG_BUFFERS)
- av_log(avctx, AV_LOG_DEBUG, "default_get_buffer called on frame %p, "
- "internal audio buffer used\n", frame);
-
- return 0;
-}
-
-static int video_get_buffer(AVCodecContext *s, AVFrame *pic)
-{
- int i;
- int w = s->width;
- int h = s->height;
- InternalBuffer *buf;
- AVCodecInternal *avci = s->internal;
-
- if (pic->data[0] != NULL) {
- av_log(s, AV_LOG_ERROR, "pic->data[0]!=NULL in avcodec_default_get_buffer\n");
- return -1;
- }
- if (avci->buffer_count >= INTERNAL_BUFFER_SIZE) {
- av_log(s, AV_LOG_ERROR, "buffer_count overflow (missing release_buffer?)\n");
- return -1;
- }
-
- if (av_image_check_size(w, h, 0, s) || s->pix_fmt<0) {
- av_log(s, AV_LOG_ERROR, "video_get_buffer: image parameters invalid\n");
- return -1;
- }
-
- if (!avci->buffer) {
- avci->buffer = av_mallocz((INTERNAL_BUFFER_SIZE + 1) *
- sizeof(InternalBuffer));
- }
-
- buf = &avci->buffer[avci->buffer_count];
-
- if (buf->base[0] && (buf->width != w || buf->height != h || buf->pix_fmt != s->pix_fmt)) {
- for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {
- av_freep(&buf->base[i]);
- buf->data[i] = NULL;
- }
- }
-
- if (!buf->base[0]) {
- int h_chroma_shift, v_chroma_shift;
- int size[4] = { 0 };
- int tmpsize;
- int unaligned;
- AVPicture picture;
- int stride_align[AV_NUM_DATA_POINTERS];
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->pix_fmt);
- const int pixel_size = desc->comp[0].step_minus1 + 1;
-
- av_pix_fmt_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift,
- &v_chroma_shift);
-
- avcodec_align_dimensions2(s, &w, &h, stride_align);
-
- if (!(s->flags & CODEC_FLAG_EMU_EDGE)) {
- w += EDGE_WIDTH * 2;
- h += EDGE_WIDTH * 2;
- }
-
- do {
- // NOTE: do not align linesizes individually, this breaks e.g. assumptions
- // that linesize[0] == 2*linesize[1] in the MPEG-encoder for 4:2:2
- av_image_fill_linesizes(picture.linesize, s->pix_fmt, w);
- // increase alignment of w for next try (rhs gives the lowest bit set in w)
- w += w & ~(w - 1);
-
- unaligned = 0;
- for (i = 0; i < 4; i++)
- unaligned |= picture.linesize[i] % stride_align[i];
- } while (unaligned);
-
- tmpsize = av_image_fill_pointers(picture.data, s->pix_fmt, h, NULL, picture.linesize);
- if (tmpsize < 0)
- return -1;
-
- for (i = 0; i < 3 && picture.data[i + 1]; i++)
- size[i] = picture.data[i + 1] - picture.data[i];
- size[i] = tmpsize - (picture.data[i] - picture.data[0]);
-
- memset(buf->base, 0, sizeof(buf->base));
- memset(buf->data, 0, sizeof(buf->data));
-
- for (i = 0; i < 4 && size[i]; i++) {
- const int h_shift = i == 0 ? 0 : h_chroma_shift;
- const int v_shift = i == 0 ? 0 : v_chroma_shift;
-
- buf->linesize[i] = picture.linesize[i];
-
- buf->base[i] = av_malloc(size[i] + 16); //FIXME 16
- if (buf->base[i] == NULL)
- return AVERROR(ENOMEM);
-
- // no edge if EDGE EMU or not planar YUV
- if ((s->flags & CODEC_FLAG_EMU_EDGE) || !size[2])
- buf->data[i] = buf->base[i];
- else
- buf->data[i] = buf->base[i] + FFALIGN((buf->linesize[i] * EDGE_WIDTH >> v_shift) + (pixel_size * EDGE_WIDTH >> h_shift), stride_align[i]);
- }
- for (; i < AV_NUM_DATA_POINTERS; i++) {
- buf->base[i] = buf->data[i] = NULL;
- buf->linesize[i] = 0;
- }
- if (size[1] && !size[2])
- avpriv_set_systematic_pal2((uint32_t *)buf->data[1], s->pix_fmt);
- buf->width = s->width;
- buf->height = s->height;
- buf->pix_fmt = s->pix_fmt;
- }
-
- for (i = 0; i < AV_NUM_DATA_POINTERS; i++) {
- pic->base[i] = buf->base[i];
- pic->data[i] = buf->data[i];
- pic->linesize[i] = buf->linesize[i];
- }
- pic->extended_data = pic->data;
- avci->buffer_count++;
-
- if (s->debug & FF_DEBUG_BUFFERS)
- av_log(s, AV_LOG_DEBUG, "default_get_buffer called on pic %p, %d "
- "buffers used\n", pic, avci->buffer_count);
-
- return 0;
-}
-
-void avpriv_color_frame(AVFrame *frame, const int c[4])
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
- int p, y, x;
-
- av_assert0(desc->flags & PIX_FMT_PLANAR);
-
- for (p = 0; p<desc->nb_components; p++) {
- uint8_t *dst = frame->data[p];
- int is_chroma = p == 1 || p == 2;
- int bytes = -((-frame->width) >> (is_chroma ? desc->log2_chroma_w : 0));
- for (y = 0; y<-((-frame->height) >> (is_chroma ? desc->log2_chroma_h : 0)); y++){
- if (desc->comp[0].depth_minus1 >= 8) {
- for (x = 0; x<bytes; x++)
- ((uint16_t*)dst)[x] = c[p];
- }else
- memset(dst, c[p], bytes);
- dst += frame->linesize[p];
- }
- }
-}
-
-int avcodec_default_get_buffer(AVCodecContext *avctx, AVFrame *frame)
-{
- frame->type = FF_BUFFER_TYPE_INTERNAL;
- switch (avctx->codec_type) {
- case AVMEDIA_TYPE_VIDEO:
- return video_get_buffer(avctx, frame);
- case AVMEDIA_TYPE_AUDIO:
- return audio_get_buffer(avctx, frame);
- default:
- return -1;
- }
-}
-
-void ff_init_buffer_info(AVCodecContext *s, AVFrame *frame)
-{
- if (s->pkt) {
- frame->pkt_pts = s->pkt->pts;
- frame->pkt_pos = s->pkt->pos;
- frame->pkt_duration = s->pkt->duration;
- frame->pkt_size = s->pkt->size;
- } else {
- frame->pkt_pts = AV_NOPTS_VALUE;
- frame->pkt_pos = -1;
- frame->pkt_duration = 0;
- frame->pkt_size = -1;
- }
- frame->reordered_opaque = s->reordered_opaque;
- // ==> Start patch MPC
- frame->reordered_opaque2= s->reordered_opaque2;
- // ==> End patch MPC
-
- switch (s->codec->type) {
- case AVMEDIA_TYPE_VIDEO:
- frame->width = s->width;
- frame->height = s->height;
- frame->format = s->pix_fmt;
- frame->sample_aspect_ratio = s->sample_aspect_ratio;
- break;
- case AVMEDIA_TYPE_AUDIO:
- frame->sample_rate = s->sample_rate;
- frame->format = s->sample_fmt;
- frame->channel_layout = s->channel_layout;
- frame->channels = s->channels;
- break;
- }
-}
-
-int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame)
-{
- ff_init_buffer_info(avctx, frame);
-
- return avctx->get_buffer(avctx, frame);
-}
-
-void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic)
-{
- int i;
- InternalBuffer *buf, *last;
- AVCodecInternal *avci = s->internal;
-
- av_assert0(s->codec_type == AVMEDIA_TYPE_VIDEO);
-
- assert(pic->type == FF_BUFFER_TYPE_INTERNAL);
- assert(avci->buffer_count);
-
- if (avci->buffer) {
- buf = NULL; /* avoids warning */
- for (i = 0; i < avci->buffer_count; i++) { //just 3-5 checks so is not worth to optimize
- buf = &avci->buffer[i];
- if (buf->data[0] == pic->data[0])
- break;
- }
- av_assert0(i < avci->buffer_count);
- avci->buffer_count--;
- last = &avci->buffer[avci->buffer_count];
-
- if (buf != last)
- FFSWAP(InternalBuffer, *buf, *last);
- }
-
- for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
- pic->data[i] = NULL;
-// pic->base[i]=NULL;
-
- if (s->debug & FF_DEBUG_BUFFERS)
- av_log(s, AV_LOG_DEBUG, "default_release_buffer called on pic %p, %d "
- "buffers used\n", pic, avci->buffer_count);
-}
-
-int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic)
-{
- AVFrame temp_pic;
- int i, ret;
-
- av_assert0(s->codec_type == AVMEDIA_TYPE_VIDEO);
-
- if (pic->data[0] && (pic->width != s->width || pic->height != s->height || pic->format != s->pix_fmt)) {
- av_log(s, AV_LOG_WARNING, "Picture changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s in reget buffer()\n",
- pic->width, pic->height, av_get_pix_fmt_name(pic->format), s->width, s->height, av_get_pix_fmt_name(s->pix_fmt));
- s->release_buffer(s, pic);
- }
-
- ff_init_buffer_info(s, pic);
-
- /* If no picture return a new buffer */
- if (pic->data[0] == NULL) {
- /* We will copy from buffer, so must be readable */
- pic->buffer_hints |= FF_BUFFER_HINTS_READABLE;
- return ff_get_buffer(s, pic);
- }
-
- assert(s->pix_fmt == pic->format);
-
- /* If internal buffer type return the same buffer */
- if (pic->type == FF_BUFFER_TYPE_INTERNAL) {
- return 0;
- }
-
- /*
- * Not internal type and reget_buffer not overridden, emulate cr buffer
- */
- temp_pic = *pic;
- for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
- pic->data[i] = pic->base[i] = NULL;
- pic->opaque = NULL;
- /* Allocate new frame */
- if ((ret = ff_get_buffer(s, pic)))
- return ret;
- /* Copy image data from old buffer to new buffer */
- av_picture_copy((AVPicture *)pic, (AVPicture *)&temp_pic, s->pix_fmt, s->width,
- s->height);
- s->release_buffer(s, &temp_pic); // Release old frame
- return 0;
-}
-
-int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2), void *arg, int *ret, int count, int size)
-{
- int i;
-
- for (i = 0; i < count; i++) {
- int r = func(c, (char *)arg + i * size);
- if (ret)
- ret[i] = r;
- }
- return 0;
-}
-
-int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int jobnr, int threadnr), void *arg, int *ret, int count)
-{
- int i;
-
- for (i = 0; i < count; i++) {
- int r = func(c, arg, i, 0);
- if (ret)
- ret[i] = r;
- }
- return 0;
-}
-
-static int is_hwaccel_pix_fmt(enum AVPixelFormat pix_fmt)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- return desc->flags & PIX_FMT_HWACCEL;
-}
-
-enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum AVPixelFormat *fmt)
-{
- while (*fmt != AV_PIX_FMT_NONE && is_hwaccel_pix_fmt(*fmt))
- ++fmt;
- return fmt[0];
-}
-
-void avcodec_get_frame_defaults(AVFrame *frame)
-{
-#if LIBAVCODEC_VERSION_MAJOR >= 55
- // extended_data should explicitly be freed when needed, this code is unsafe currently
- // also this is not compatible to the <55 ABI/API
- if (frame->extended_data != frame->data && 0)
- av_freep(&frame->extended_data);
-#endif
-
- memset(frame, 0, sizeof(AVFrame));
-
- frame->pts =
- frame->pkt_dts =
- frame->pkt_pts =
- frame->best_effort_timestamp = AV_NOPTS_VALUE;
- frame->pkt_duration = 0;
- frame->pkt_pos = -1;
- frame->pkt_size = -1;
- frame->key_frame = 1;
- frame->sample_aspect_ratio = (AVRational) {0, 1 };
- frame->format = -1; /* unknown */
- frame->extended_data = frame->data;
-}
-
-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;
-}
-
-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);
-}
-
-#define MAKE_ACCESSORS(str, name, type, field) \
- type av_##name##_get_##field(const str *s) { return s->field; } \
- void av_##name##_set_##field(str *s, type v) { s->field = v; }
-
-MAKE_ACCESSORS(AVFrame, frame, int64_t, best_effort_timestamp)
-MAKE_ACCESSORS(AVFrame, frame, int64_t, pkt_duration)
-MAKE_ACCESSORS(AVFrame, frame, int64_t, pkt_pos)
-MAKE_ACCESSORS(AVFrame, frame, int64_t, channel_layout)
-MAKE_ACCESSORS(AVFrame, frame, int, channels)
-MAKE_ACCESSORS(AVFrame, frame, int, sample_rate)
-MAKE_ACCESSORS(AVFrame, frame, AVDictionary *, metadata)
-MAKE_ACCESSORS(AVFrame, frame, int, decode_error_flags)
-MAKE_ACCESSORS(AVFrame, frame, int, pkt_size)
-
-MAKE_ACCESSORS(AVCodecContext, codec, AVRational, pkt_timebase)
-MAKE_ACCESSORS(AVCodecContext, codec, const AVCodecDescriptor *, codec_descriptor)
-
-static void avcodec_get_subtitle_defaults(AVSubtitle *sub)
-{
- memset(sub, 0, sizeof(*sub));
- sub->pts = AV_NOPTS_VALUE;
-}
-
-static int get_bit_rate(AVCodecContext *ctx)
-{
- int bit_rate;
- int bits_per_sample;
-
- switch (ctx->codec_type) {
- case AVMEDIA_TYPE_VIDEO:
- case AVMEDIA_TYPE_DATA:
- case AVMEDIA_TYPE_SUBTITLE:
- case AVMEDIA_TYPE_ATTACHMENT:
- bit_rate = ctx->bit_rate;
- break;
- case AVMEDIA_TYPE_AUDIO:
- bits_per_sample = av_get_bits_per_sample(ctx->codec_id);
- bit_rate = bits_per_sample ? ctx->sample_rate * ctx->channels * bits_per_sample : ctx->bit_rate;
- break;
- default:
- bit_rate = 0;
- break;
- }
- return bit_rate;
-}
-
-#if FF_API_AVCODEC_OPEN
-int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
-{
- return avcodec_open2(avctx, codec, NULL);
-}
-#endif
-
-int attribute_align_arg ff_codec_open2_recursive(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
-{
- int ret = 0;
-
- ff_unlock_avcodec();
-
- ret = avcodec_open2(avctx, codec, options);
-
- ff_lock_avcodec(avctx);
- return ret;
-}
-
-int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
-{
- int ret = 0;
- AVDictionary *tmp = NULL;
-
- if (avcodec_is_open(avctx))
- return 0;
-
- if ((!codec && !avctx->codec)) {
- av_log(avctx, AV_LOG_ERROR, "No codec provided to avcodec_open2()\n");
- return AVERROR(EINVAL);
- }
- if ((codec && avctx->codec && codec != avctx->codec)) {
- av_log(avctx, AV_LOG_ERROR, "This AVCodecContext was allocated for %s, "
- "but %s passed to avcodec_open2()\n", avctx->codec->name, codec->name);
- return AVERROR(EINVAL);
- }
- if (!codec)
- codec = avctx->codec;
-
- if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE)
- return AVERROR(EINVAL);
-
- if (options)
- av_dict_copy(&tmp, *options, 0);
-
- ret = ff_lock_avcodec(avctx);
- if (ret < 0)
- return ret;
-
- avctx->internal = av_mallocz(sizeof(AVCodecInternal));
- if (!avctx->internal) {
- ret = AVERROR(ENOMEM);
- goto end;
- }
-
- if (codec->priv_data_size > 0) {
- if (!avctx->priv_data) {
- avctx->priv_data = av_mallocz(codec->priv_data_size);
- if (!avctx->priv_data) {
- ret = AVERROR(ENOMEM);
- goto end;
- }
- if (codec->priv_class) {
- *(const AVClass **)avctx->priv_data = codec->priv_class;
- av_opt_set_defaults(avctx->priv_data);
- }
- }
- if (codec->priv_class && (ret = av_opt_set_dict(avctx->priv_data, &tmp)) < 0)
- goto free_and_end;
- } else {
- avctx->priv_data = NULL;
- }
- if ((ret = av_opt_set_dict(avctx, &tmp)) < 0)
- goto free_and_end;
-
- //We only call avcodec_set_dimensions() for non h264 codecs so as not to overwrite previously setup dimensions
- if (!( avctx->coded_width && avctx->coded_height && avctx->width && avctx->height && avctx->codec_id == AV_CODEC_ID_H264)){
-
- if (avctx->coded_width && avctx->coded_height)
- avcodec_set_dimensions(avctx, avctx->coded_width, avctx->coded_height);
- else if (avctx->width && avctx->height)
- avcodec_set_dimensions(avctx, avctx->width, avctx->height);
- }
-
- if ((avctx->coded_width || avctx->coded_height || avctx->width || avctx->height)
- && ( av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx) < 0
- || av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0)) {
- av_log(avctx, AV_LOG_WARNING, "Ignoring invalid width/height values\n");
- avcodec_set_dimensions(avctx, 0, 0);
- }
-
- /* if the decoder init function was already called previously,
- * free the already allocated subtitle_header before overwriting it */
- if (av_codec_is_decoder(codec))
- av_freep(&avctx->subtitle_header);
-
- if (avctx->channels > FF_SANE_NB_CHANNELS) {
- ret = AVERROR(EINVAL);
- goto free_and_end;
- }
-
- avctx->codec = codec;
- if ((avctx->codec_type == AVMEDIA_TYPE_UNKNOWN || avctx->codec_type == codec->type) &&
- avctx->codec_id == AV_CODEC_ID_NONE) {
- avctx->codec_type = codec->type;
- avctx->codec_id = codec->id;
- }
- if (avctx->codec_id != codec->id || (avctx->codec_type != codec->type
- && avctx->codec_type != AVMEDIA_TYPE_ATTACHMENT)) {
- av_log(avctx, AV_LOG_ERROR, "Codec type or id mismatches\n");
- ret = AVERROR(EINVAL);
- goto free_and_end;
- }
- avctx->frame_number = 0;
- avctx->codec_descriptor = avcodec_descriptor_get(avctx->codec_id);
-
- if (avctx->codec->capabilities & CODEC_CAP_EXPERIMENTAL &&
- avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
- const char *codec_string = av_codec_is_encoder(codec) ? "encoder" : "decoder";
- AVCodec *codec2;
- av_log(NULL, AV_LOG_ERROR,
- "The %s '%s' is experimental but experimental codecs are not enabled, "
- "add '-strict %d' if you want to use it.\n",
- codec_string, codec->name, FF_COMPLIANCE_EXPERIMENTAL);
- codec2 = av_codec_is_encoder(codec) ? avcodec_find_encoder(codec->id) : avcodec_find_decoder(codec->id);
- if (!(codec2->capabilities & CODEC_CAP_EXPERIMENTAL))
- av_log(NULL, AV_LOG_ERROR, "Alternatively use the non experimental %s '%s'.\n",
- codec_string, codec2->name);
- ret = AVERROR_EXPERIMENTAL;
- goto free_and_end;
- }
-
- if (avctx->codec_type == AVMEDIA_TYPE_AUDIO &&
- (!avctx->time_base.num || !avctx->time_base.den)) {
- avctx->time_base.num = 1;
- avctx->time_base.den = avctx->sample_rate;
- }
-
- if (!HAVE_THREADS)
- av_log(avctx, AV_LOG_WARNING, "Warning: not compiled with thread support, using thread emulation\n");
-
- if (HAVE_THREADS) {
- ff_unlock_avcodec(); //we will instanciate a few encoders thus kick the counter to prevent false detection of a problem
- ret = ff_frame_thread_encoder_init(avctx, options ? *options : NULL);
- ff_lock_avcodec(avctx);
- if (ret < 0)
- goto free_and_end;
- }
-
- if (HAVE_THREADS && !avctx->thread_opaque
- && !(avctx->internal->frame_thread_encoder && (avctx->active_thread_type&FF_THREAD_FRAME))) {
- ret = ff_thread_init(avctx);
- if (ret < 0) {
- goto free_and_end;
- }
- }
- if (!HAVE_THREADS && !(codec->capabilities & CODEC_CAP_AUTO_THREADS))
- avctx->thread_count = 1;
-
- if (avctx->codec->max_lowres < avctx->lowres || avctx->lowres < 0) {
- av_log(avctx, AV_LOG_ERROR, "The maximum value for lowres supported by the decoder is %d\n",
- avctx->codec->max_lowres);
- ret = AVERROR(EINVAL);
- goto free_and_end;
- }
-
- if (av_codec_is_encoder(avctx->codec)) {
- int i;
- if (avctx->codec->sample_fmts) {
- for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++) {
- if (avctx->sample_fmt == avctx->codec->sample_fmts[i])
- break;
- if (avctx->channels == 1 &&
- av_get_planar_sample_fmt(avctx->sample_fmt) ==
- av_get_planar_sample_fmt(avctx->codec->sample_fmts[i])) {
- avctx->sample_fmt = avctx->codec->sample_fmts[i];
- break;
- }
- }
- if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) {
- char buf[128];
- snprintf(buf, sizeof(buf), "%d", avctx->sample_fmt);
- av_log(avctx, AV_LOG_ERROR, "Specified sample format %s is invalid or not supported\n",
- (char *)av_x_if_null(av_get_sample_fmt_name(avctx->sample_fmt), buf));
- ret = AVERROR(EINVAL);
- goto free_and_end;
- }
- }
- if (avctx->codec->pix_fmts) {
- for (i = 0; avctx->codec->pix_fmts[i] != AV_PIX_FMT_NONE; i++)
- if (avctx->pix_fmt == avctx->codec->pix_fmts[i])
- break;
- if (avctx->codec->pix_fmts[i] == AV_PIX_FMT_NONE
- && !((avctx->codec_id == AV_CODEC_ID_MJPEG || avctx->codec_id == AV_CODEC_ID_LJPEG)
- && avctx->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL)) {
- char buf[128];
- snprintf(buf, sizeof(buf), "%d", avctx->pix_fmt);
- av_log(avctx, AV_LOG_ERROR, "Specified pixel format %s is invalid or not supported\n",
- (char *)av_x_if_null(av_get_pix_fmt_name(avctx->pix_fmt), buf));
- ret = AVERROR(EINVAL);
- goto free_and_end;
- }
- }
- if (avctx->codec->supported_samplerates) {
- for (i = 0; avctx->codec->supported_samplerates[i] != 0; i++)
- if (avctx->sample_rate == avctx->codec->supported_samplerates[i])
- break;
- if (avctx->codec->supported_samplerates[i] == 0) {
- av_log(avctx, AV_LOG_ERROR, "Specified sample rate %d is not supported\n",
- avctx->sample_rate);
- ret = AVERROR(EINVAL);
- goto free_and_end;
- }
- }
- if (avctx->codec->channel_layouts) {
- if (!avctx->channel_layout) {
- av_log(avctx, AV_LOG_WARNING, "Channel layout not specified\n");
- } else {
- for (i = 0; avctx->codec->channel_layouts[i] != 0; i++)
- if (avctx->channel_layout == avctx->codec->channel_layouts[i])
- break;
- if (avctx->codec->channel_layouts[i] == 0) {
- char buf[512];
- av_get_channel_layout_string(buf, sizeof(buf), -1, avctx->channel_layout);
- av_log(avctx, AV_LOG_ERROR, "Specified channel layout '%s' is not supported\n", buf);
- ret = AVERROR(EINVAL);
- goto free_and_end;
- }
- }
- }
- if (avctx->channel_layout && avctx->channels) {
- int channels = av_get_channel_layout_nb_channels(avctx->channel_layout);
- if (channels != avctx->channels) {
- char buf[512];
- av_get_channel_layout_string(buf, sizeof(buf), -1, avctx->channel_layout);
- av_log(avctx, AV_LOG_ERROR,
- "Channel layout '%s' with %d channels does not match number of specified channels %d\n",
- buf, channels, avctx->channels);
- ret = AVERROR(EINVAL);
- goto free_and_end;
- }
- } else if (avctx->channel_layout) {
- avctx->channels = av_get_channel_layout_nb_channels(avctx->channel_layout);
- }
- if(avctx->codec_type == AVMEDIA_TYPE_VIDEO &&
- avctx->codec_id != AV_CODEC_ID_PNG // For mplayer
- ) {
- if (avctx->width <= 0 || avctx->height <= 0) {
- av_log(avctx, AV_LOG_ERROR, "dimensions not set\n");
- ret = AVERROR(EINVAL);
- goto free_and_end;
- }
- }
- if ( (avctx->codec_type == AVMEDIA_TYPE_VIDEO || avctx->codec_type == AVMEDIA_TYPE_AUDIO)
- && avctx->bit_rate>0 && avctx->bit_rate<1000) {
- av_log(avctx, AV_LOG_WARNING, "Bitrate %d is extreemly low, did you mean %dk\n", avctx->bit_rate, avctx->bit_rate);
- }
-
- if (!avctx->rc_initial_buffer_occupancy)
- avctx->rc_initial_buffer_occupancy = avctx->rc_buffer_size * 3 / 4;
- }
-
- avctx->pts_correction_num_faulty_pts =
- avctx->pts_correction_num_faulty_dts = 0;
- avctx->pts_correction_last_pts =
- avctx->pts_correction_last_dts = INT64_MIN;
-
- if ( avctx->codec->init && (!(avctx->active_thread_type&FF_THREAD_FRAME)
- || avctx->internal->frame_thread_encoder)) {
- ret = avctx->codec->init(avctx);
- if (ret < 0) {
- goto free_and_end;
- }
- }
-
- ret=0;
-
- if (av_codec_is_decoder(avctx->codec)) {
- if (!avctx->bit_rate)
- avctx->bit_rate = get_bit_rate(avctx);
- /* validate channel layout from the decoder */
- if (avctx->channel_layout) {
- int channels = av_get_channel_layout_nb_channels(avctx->channel_layout);
- if (!avctx->channels)
- avctx->channels = channels;
- else if (channels != avctx->channels) {
- char buf[512];
- av_get_channel_layout_string(buf, sizeof(buf), -1, avctx->channel_layout);
- av_log(avctx, AV_LOG_WARNING,
- "Channel layout '%s' with %d channels does not match specified number of channels %d: "
- "ignoring specified channel layout\n",
- buf, channels, avctx->channels);
- avctx->channel_layout = 0;
- }
- }
- if (avctx->channels && avctx->channels < 0 ||
- avctx->channels > FF_SANE_NB_CHANNELS) {
- ret = AVERROR(EINVAL);
- goto free_and_end;
- }
- }
-end:
- ff_unlock_avcodec();
- if (options) {
- av_dict_free(options);
- *options = tmp;
- }
-
- return ret;
-free_and_end:
- av_dict_free(&tmp);
- av_freep(&avctx->priv_data);
- av_freep(&avctx->internal);
- avctx->codec = NULL;
- goto end;
-}
-
-int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int size)
-{
- if (size < 0 || avpkt->size < 0 || size > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE) {
- av_log(avctx, AV_LOG_ERROR, "Size %d invalid\n", size);
- return AVERROR(EINVAL);
- }
-
- if (avctx) {
- av_assert0(!avpkt->data || avpkt->data != avctx->internal->byte_buffer);
- if (!avpkt->data || avpkt->size < 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;
- avpkt->destruct = NULL;
- }
- }
-
- if (avpkt->data) {
- void *destruct = avpkt->destruct;
-
- if (avpkt->size < size) {
- av_log(avctx, AV_LOG_ERROR, "User packet is too small (%d < %d)\n", avpkt->size, size);
- return AVERROR(EINVAL);
- }
-
- av_init_packet(avpkt);
- avpkt->destruct = destruct;
- avpkt->size = size;
- return 0;
- } else {
- int ret = av_new_packet(avpkt, size);
- if (ret < 0)
- av_log(avctx, AV_LOG_ERROR, "Failed to allocate packet of size %d\n", size);
- return ret;
- }
-}
-
-int ff_alloc_packet(AVPacket *avpkt, int size)
-{
- return ff_alloc_packet2(NULL, avpkt, size);
-}
-
-/**
- * Pad last frame with silence.
- */
-static int pad_last_frame(AVCodecContext *s, AVFrame **dst, const AVFrame *src)
-{
- AVFrame *frame = NULL;
- uint8_t *buf = NULL;
- int ret;
-
- if (!(frame = avcodec_alloc_frame()))
- return AVERROR(ENOMEM);
- *frame = *src;
-
- if ((ret = av_samples_get_buffer_size(&frame->linesize[0], s->channels,
- s->frame_size, s->sample_fmt, 0)) < 0)
- goto fail;
-
- if (!(buf = av_malloc(ret))) {
- ret = AVERROR(ENOMEM);
- goto fail;
- }
-
- frame->nb_samples = s->frame_size;
- if ((ret = avcodec_fill_audio_frame(frame, s->channels, s->sample_fmt,
- buf, ret, 0)) < 0)
- goto fail;
- if ((ret = av_samples_copy(frame->extended_data, src->extended_data, 0, 0,
- src->nb_samples, s->channels, s->sample_fmt)) < 0)
- goto fail;
- if ((ret = av_samples_set_silence(frame->extended_data, src->nb_samples,
- frame->nb_samples - src->nb_samples,
- s->channels, s->sample_fmt)) < 0)
- goto fail;
-
- *dst = frame;
-
- return 0;
-
-fail:
- if (frame->extended_data != frame->data)
- av_freep(&frame->extended_data);
- av_freep(&buf);
- av_freep(&frame);
- return ret;
-}
-
-int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
- AVPacket *avpkt,
- const AVFrame *frame,
- int *got_packet_ptr)
-{
- AVFrame tmp;
- AVFrame *padded_frame = NULL;
- int ret;
- AVPacket user_pkt = *avpkt;
- int needs_realloc = !user_pkt.data;
-
- *got_packet_ptr = 0;
-
- if (!(avctx->codec->capabilities & CODEC_CAP_DELAY) && !frame) {
- av_free_packet(avpkt);
- av_init_packet(avpkt);
- return 0;
- }
-
- /* ensure that extended_data is properly set */
- if (frame && !frame->extended_data) {
- if (av_sample_fmt_is_planar(avctx->sample_fmt) &&
- avctx->channels > AV_NUM_DATA_POINTERS) {
- av_log(avctx, AV_LOG_ERROR, "Encoding to a planar sample format, "
- "with more than %d channels, but extended_data is not set.\n",
- AV_NUM_DATA_POINTERS);
- return AVERROR(EINVAL);
- }
- av_log(avctx, AV_LOG_WARNING, "extended_data is not set.\n");
-
- tmp = *frame;
- tmp.extended_data = tmp.data;
- frame = &tmp;
- }
-
- /* check for valid frame size */
- if (frame) {
- 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);
- }
- } 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;
-
- frame = padded_frame;
- avctx->internal->last_audio_frame = 1;
- }
-
- if (frame->nb_samples != avctx->frame_size) {
- av_log(avctx, AV_LOG_ERROR, "nb_samples (%d) != frame_size (%d) (avcodec_encode_audio2)\n", frame->nb_samples, avctx->frame_size);
- ret = AVERROR(EINVAL);
- goto end;
- }
- }
- }
-
- ret = avctx->codec->encode2(avctx, avpkt, frame, got_packet_ptr);
- if (!ret) {
- if (*got_packet_ptr) {
- if (!(avctx->codec->capabilities & CODEC_CAP_DELAY)) {
- if (avpkt->pts == AV_NOPTS_VALUE)
- avpkt->pts = frame->pts;
- if (!avpkt->duration)
- avpkt->duration = ff_samples_to_time_base(avctx,
- frame->nb_samples);
- }
- avpkt->dts = avpkt->pts;
- } else {
- avpkt->size = 0;
- }
- }
- if (avpkt->data && avpkt->data == avctx->internal->byte_buffer) {
- needs_realloc = 0;
- if (user_pkt.data) {
- if (user_pkt.size >= avpkt->size) {
- memcpy(user_pkt.data, avpkt->data, avpkt->size);
- } else {
- av_log(avctx, AV_LOG_ERROR, "Provided packet is too small, needs to be %d\n", avpkt->size);
- avpkt->size = user_pkt.size;
- ret = -1;
- }
- avpkt->data = user_pkt.data;
- avpkt->destruct = user_pkt.destruct;
- } else {
- if (av_dup_packet(avpkt) < 0) {
- ret = AVERROR(ENOMEM);
- }
- }
- }
-
- if (!ret) {
- if (needs_realloc && avpkt->data) {
- uint8_t *new_data = av_realloc(avpkt->data, avpkt->size + FF_INPUT_BUFFER_PADDING_SIZE);
- if (new_data)
- avpkt->data = new_data;
- }
-
- avctx->frame_number++;
- }
-
- if (ret < 0 || !*got_packet_ptr) {
- av_free_packet(avpkt);
- av_init_packet(avpkt);
- goto end;
- }
-
- /* NOTE: if we add any audio encoders which output non-keyframe packets,
- * this needs to be moved to the encoders, but for now we can do it
- * here to simplify things */
- avpkt->flags |= AV_PKT_FLAG_KEY;
-
-end:
- if (padded_frame) {
- av_freep(&padded_frame->data[0]);
- if (padded_frame->extended_data != padded_frame->data)
- av_freep(&padded_frame->extended_data);
- av_freep(&padded_frame);
- }
-
- return ret;
-}
-
-#if FF_API_OLD_ENCODE_AUDIO
-int attribute_align_arg avcodec_encode_audio(AVCodecContext *avctx,
- uint8_t *buf, int buf_size,
- const short *samples)
-{
- AVPacket pkt;
- AVFrame frame0 = { { 0 } };
- AVFrame *frame;
- int ret, samples_size, got_packet;
-
- av_init_packet(&pkt);
- pkt.data = buf;
- pkt.size = buf_size;
-
- if (samples) {
- frame = &frame0;
- avcodec_get_frame_defaults(frame);
-
- if (avctx->frame_size) {
- frame->nb_samples = avctx->frame_size;
- } else {
- /* if frame_size is not set, the number of samples must be
- * calculated from the buffer size */
- int64_t nb_samples;
- if (!av_get_bits_per_sample(avctx->codec_id)) {
- av_log(avctx, AV_LOG_ERROR, "avcodec_encode_audio() does not "
- "support this codec\n");
- 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)
- return AVERROR(EINVAL);
- frame->nb_samples = nb_samples;
- }
-
- /* it is assumed that the samples buffer is large enough based on the
- * relevant parameters */
- samples_size = av_samples_get_buffer_size(NULL, avctx->channels,
- frame->nb_samples,
- avctx->sample_fmt, 1);
- if ((ret = avcodec_fill_audio_frame(frame, avctx->channels,
- avctx->sample_fmt,
- (const uint8_t *)samples,
- samples_size, 1)) < 0)
- return ret;
-
- /* fabricate frame pts from sample count.
- * this is needed because the avcodec_encode_audio() API does not have
- * a way for the user to provide pts */
- if (avctx->sample_rate && avctx->time_base.num)
- frame->pts = ff_samples_to_time_base(avctx,
- avctx->internal->sample_count);
- else
- frame->pts = AV_NOPTS_VALUE;
- avctx->internal->sample_count += frame->nb_samples;
- } else {
- frame = NULL;
- }
-
- got_packet = 0;
- ret = avcodec_encode_audio2(avctx, &pkt, frame, &got_packet);
- if (!ret && got_packet && avctx->coded_frame) {
- avctx->coded_frame->pts = pkt.pts;
- avctx->coded_frame->key_frame = !!(pkt.flags & AV_PKT_FLAG_KEY);
- }
- /* free any side data since we cannot return it */
- ff_packet_free_side_data(&pkt);
-
- if (frame && frame->extended_data != frame->data)
- av_freep(&frame->extended_data);
-
- return ret ? ret : pkt.size;
-}
-
-#endif
-
-#if FF_API_OLD_ENCODE_VIDEO
-int attribute_align_arg avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
- const AVFrame *pict)
-{
- AVPacket pkt;
- int ret, got_packet = 0;
-
- if (buf_size < FF_MIN_BUFFER_SIZE) {
- av_log(avctx, AV_LOG_ERROR, "buffer smaller than minimum size\n");
- return -1;
- }
-
- av_init_packet(&pkt);
- pkt.data = buf;
- pkt.size = buf_size;
-
- ret = avcodec_encode_video2(avctx, &pkt, pict, &got_packet);
- if (!ret && got_packet && avctx->coded_frame) {
- avctx->coded_frame->pts = pkt.pts;
- avctx->coded_frame->key_frame = !!(pkt.flags & AV_PKT_FLAG_KEY);
- }
-
- /* free any side data since we cannot return it */
- if (pkt.side_data_elems > 0) {
- int i;
- for (i = 0; i < pkt.side_data_elems; i++)
- av_free(pkt.side_data[i].data);
- av_freep(&pkt.side_data);
- pkt.side_data_elems = 0;
- }
-
- return ret ? ret : pkt.size;
-}
-
-#endif
-
-int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
- AVPacket *avpkt,
- const AVFrame *frame,
- int *got_packet_ptr)
-{
- int ret;
- AVPacket user_pkt = *avpkt;
- int needs_realloc = !user_pkt.data;
-
- *got_packet_ptr = 0;
-
- if(HAVE_THREADS && avctx->internal->frame_thread_encoder && (avctx->active_thread_type&FF_THREAD_FRAME))
- return ff_thread_video_encode_frame(avctx, avpkt, frame, got_packet_ptr);
-
- if ((avctx->flags&CODEC_FLAG_PASS1) && avctx->stats_out)
- avctx->stats_out[0] = '\0';
-
- if (!(avctx->codec->capabilities & CODEC_CAP_DELAY) && !frame) {
- av_free_packet(avpkt);
- av_init_packet(avpkt);
- avpkt->size = 0;
- return 0;
- }
-
- if (av_image_check_size(avctx->width, avctx->height, 0, avctx))
- return AVERROR(EINVAL);
-
- av_assert0(avctx->codec->encode2);
-
- ret = avctx->codec->encode2(avctx, avpkt, frame, got_packet_ptr);
- av_assert0(ret <= 0);
-
- if (avpkt->data && avpkt->data == avctx->internal->byte_buffer) {
- needs_realloc = 0;
- if (user_pkt.data) {
- if (user_pkt.size >= avpkt->size) {
- memcpy(user_pkt.data, avpkt->data, avpkt->size);
- } else {
- av_log(avctx, AV_LOG_ERROR, "Provided packet is too small, needs to be %d\n", avpkt->size);
- avpkt->size = user_pkt.size;
- ret = -1;
- }
- avpkt->data = user_pkt.data;
- avpkt->destruct = user_pkt.destruct;
- } else {
- if (av_dup_packet(avpkt) < 0) {
- ret = AVERROR(ENOMEM);
- }
- }
- }
-
- if (!ret) {
- if (!*got_packet_ptr)
- avpkt->size = 0;
- else if (!(avctx->codec->capabilities & CODEC_CAP_DELAY))
- avpkt->pts = avpkt->dts = frame->pts;
-
- if (needs_realloc && avpkt->data &&
- avpkt->destruct == av_destruct_packet) {
- uint8_t *new_data = av_realloc(avpkt->data, avpkt->size + FF_INPUT_BUFFER_PADDING_SIZE);
- if (new_data)
- avpkt->data = new_data;
- }
-
- avctx->frame_number++;
- }
-
- if (ret < 0 || !*got_packet_ptr)
- av_free_packet(avpkt);
-
- emms_c();
- return ret;
-}
-
-int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
- const AVSubtitle *sub)
-{
- int ret;
- if (sub->start_display_time) {
- av_log(avctx, AV_LOG_ERROR, "start_display_time must be 0.\n");
- return -1;
- }
-
- ret = avctx->codec->encode_sub(avctx, buf, buf_size, sub);
- avctx->frame_number++;
- return ret;
-}
-
-/**
- * Attempt to guess proper monotonic timestamps for decoded video frames
- * which might have incorrect times. Input timestamps may wrap around, in
- * which case the output will as well.
- *
- * @param pts the pts field of the decoded AVPacket, as passed through
- * AVFrame.pkt_pts
- * @param dts the dts field of the decoded AVPacket
- * @return one of the input values, may be AV_NOPTS_VALUE
- */
-static int64_t guess_correct_pts(AVCodecContext *ctx,
- int64_t reordered_pts, int64_t dts)
-{
- int64_t pts = AV_NOPTS_VALUE;
-
- if (dts != AV_NOPTS_VALUE) {
- ctx->pts_correction_num_faulty_dts += dts <= ctx->pts_correction_last_dts;
- ctx->pts_correction_last_dts = dts;
- }
- 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;
- }
- 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;
- else
- pts = dts;
-
- return pts;
-}
-
-static void apply_param_change(AVCodecContext *avctx, AVPacket *avpkt)
-{
- int size = 0;
- const uint8_t *data;
- uint32_t flags;
-
- if (!(avctx->codec->capabilities & CODEC_CAP_PARAM_CHANGE))
- return;
-
- data = av_packet_get_side_data(avpkt, AV_PKT_DATA_PARAM_CHANGE, &size);
- if (!data || size < 4)
- return;
- flags = bytestream_get_le32(&data);
- size -= 4;
- if (size < 4) /* Required for any of the changes */
- return;
- if (flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT) {
- avctx->channels = bytestream_get_le32(&data);
- size -= 4;
- }
- if (flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT) {
- if (size < 8)
- return;
- avctx->channel_layout = bytestream_get_le64(&data);
- size -= 8;
- }
- if (size < 4)
- return;
- if (flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) {
- avctx->sample_rate = bytestream_get_le32(&data);
- size -= 4;
- }
- if (flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS) {
- if (size < 8)
- return;
- avctx->width = bytestream_get_le32(&data);
- avctx->height = bytestream_get_le32(&data);
- avcodec_set_dimensions(avctx, avctx->width, avctx->height);
- size -= 8;
- }
-}
-
-static int add_metadata_from_side_data(AVCodecContext *avctx, AVFrame *frame)
-{
- int size, ret = 0;
- const uint8_t *side_metadata;
- const uint8_t *end;
-
- av_dict_free(&avctx->metadata);
- side_metadata = av_packet_get_side_data(avctx->pkt,
- AV_PKT_DATA_STRINGS_METADATA, &size);
- if (!side_metadata)
- goto end;
- end = side_metadata + size;
- while (side_metadata < end) {
- const uint8_t *key = side_metadata;
- const uint8_t *val = side_metadata + strlen(key) + 1;
- int ret = av_dict_set(&frame->metadata, key, val, 0);
- if (ret < 0)
- break;
- side_metadata = val + strlen(val) + 1;
- }
-end:
- avctx->metadata = frame->metadata;
- return ret;
-}
-
-int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
- int *got_picture_ptr,
- const AVPacket *avpkt)
-{
- int ret;
- // copy to ensure we do not change avpkt
- AVPacket tmp = *avpkt;
-
- if (avctx->codec->type != AVMEDIA_TYPE_VIDEO) {
- av_log(avctx, AV_LOG_ERROR, "Invalid media type for video\n");
- return AVERROR(EINVAL);
- }
-
- *got_picture_ptr = 0;
- 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);
-
- 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);
- apply_param_change(avctx, &tmp);
- avctx->pkt = &tmp;
- if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)
- ret = ff_thread_decode_frame(avctx, picture, got_picture_ptr,
- &tmp);
- else {
- ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
- &tmp);
- picture->pkt_dts = avpkt->dts;
-
- if(!avctx->has_b_frames){
- picture->pkt_pos = avpkt->pos;
- }
- //FIXME these should be under if(!avctx->has_b_frames)
- /* get_buffer is supposed to set frame parameters */
- if (!(avctx->codec->capabilities & CODEC_CAP_DR1)) {
- if (!picture->sample_aspect_ratio.num) picture->sample_aspect_ratio = avctx->sample_aspect_ratio;
- if (!picture->width) picture->width = avctx->width;
- if (!picture->height) picture->height = avctx->height;
- if (picture->format == AV_PIX_FMT_NONE) picture->format = avctx->pix_fmt;
- }
- }
- add_metadata_from_side_data(avctx, picture);
-
- emms_c(); //needed to avoid an emms_c() call before every return;
-
- avctx->pkt = NULL;
- if (did_split) {
- ff_packet_free_side_data(&tmp);
- if(ret == tmp.size)
- ret = avpkt->size;
- }
-
- if (*got_picture_ptr){
- avctx->frame_number++;
- picture->best_effort_timestamp = guess_correct_pts(avctx,
- picture->pkt_pts,
- picture->pkt_dts);
- }
- } else
- ret = 0;
-
- /* many decoders assign whole AVFrames, thus overwriting extended_data;
- * make sure it's set correctly */
- picture->extended_data = picture->data;
-
- return ret;
-}
-
-#if FF_API_OLD_DECODE_AUDIO
-int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
- int *frame_size_ptr,
- AVPacket *avpkt)
-{
- AVFrame frame = { { 0 } };
- int ret, got_frame = 0;
-
- 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");
- av_log(avctx, AV_LOG_ERROR, "Please port your application to "
- "avcodec_decode_audio4()\n");
- avctx->get_buffer = avcodec_default_get_buffer;
- avctx->release_buffer = avcodec_default_release_buffer;
- }
-
- 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,
- 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);
- return AVERROR(EINVAL);
- }
-
- 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);
- out += plane_size;
- }
- }
- *frame_size_ptr = data_size;
- } else {
- *frame_size_ptr = 0;
- }
- return ret;
-}
-
-#endif
-
-int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
- AVFrame *frame,
- int *got_frame_ptr,
- const AVPacket *avpkt)
-{
- int planar, channels;
- int ret = 0;
-
- *got_frame_ptr = 0;
-
- if (!avpkt->data && avpkt->size) {
- av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n");
- return AVERROR(EINVAL);
- }
- if (avctx->codec->type != AVMEDIA_TYPE_AUDIO) {
- av_log(avctx, AV_LOG_ERROR, "Invalid media type for audio\n");
- return AVERROR(EINVAL);
- }
-
- avcodec_get_frame_defaults(frame);
-
- if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size) {
- uint8_t *side;
- int side_size;
- // copy to ensure we do not change avpkt
- AVPacket tmp = *avpkt;
- int did_split = av_packet_split_side_data(&tmp);
- apply_param_change(avctx, &tmp);
-
- avctx->pkt = &tmp;
- ret = avctx->codec->decode(avctx, frame, got_frame_ptr, &tmp);
- if (ret >= 0 && *got_frame_ptr) {
- avctx->frame_number++;
- frame->pkt_dts = avpkt->dts;
- frame->best_effort_timestamp = guess_correct_pts(avctx,
- frame->pkt_pts,
- frame->pkt_dts);
- if (frame->format == AV_SAMPLE_FMT_NONE)
- frame->format = avctx->sample_fmt;
- if (!frame->channel_layout)
- frame->channel_layout = avctx->channel_layout;
- if (!frame->channels)
- frame->channels = avctx->channels;
- if (!frame->sample_rate)
- frame->sample_rate = avctx->sample_rate;
- }
- add_metadata_from_side_data(avctx, frame);
-
- side= av_packet_get_side_data(avctx->pkt, AV_PKT_DATA_SKIP_SAMPLES, &side_size);
- if(side && side_size>=10) {
- avctx->internal->skip_samples = AV_RL32(side);
- av_log(avctx, AV_LOG_DEBUG, "skip %d samples due to side data\n",
- avctx->internal->skip_samples);
- }
- if (avctx->internal->skip_samples) {
- if(frame->nb_samples <= avctx->internal->skip_samples){
- *got_frame_ptr = 0;
- avctx->internal->skip_samples -= frame->nb_samples;
- av_log(avctx, AV_LOG_DEBUG, "skip whole frame, skip left: %d\n",
- avctx->internal->skip_samples);
- } else {
- av_samples_copy(frame->extended_data, frame->extended_data, 0, avctx->internal->skip_samples,
- frame->nb_samples - avctx->internal->skip_samples, avctx->channels, frame->format);
- if(avctx->pkt_timebase.num && avctx->sample_rate) {
- int64_t diff_ts = av_rescale_q(avctx->internal->skip_samples,
- (AVRational){1, avctx->sample_rate},
- avctx->pkt_timebase);
- if(frame->pkt_pts!=AV_NOPTS_VALUE)
- frame->pkt_pts += diff_ts;
- if(frame->pkt_dts!=AV_NOPTS_VALUE)
- frame->pkt_dts += diff_ts;
- if (frame->pkt_duration >= diff_ts)
- frame->pkt_duration -= diff_ts;
- } else {
- av_log(avctx, AV_LOG_WARNING, "Could not update timestamps for skipped samples.\n");
- }
- av_log(avctx, AV_LOG_DEBUG, "skip %d/%d samples\n",
- avctx->internal->skip_samples, frame->nb_samples);
- frame->nb_samples -= avctx->internal->skip_samples;
- avctx->internal->skip_samples = 0;
- }
- }
-
- avctx->pkt = NULL;
- if (did_split) {
- ff_packet_free_side_data(&tmp);
- if(ret == tmp.size)
- ret = avpkt->size;
- }
- }
-
- /* many decoders assign whole AVFrames, thus overwriting extended_data;
- * make sure it's set correctly; assume decoders that actually use
- * extended_data are doing it correctly */
- if (*got_frame_ptr) {
- planar = av_sample_fmt_is_planar(frame->format);
- channels = frame->channels;
- if (!(planar && channels > AV_NUM_DATA_POINTERS))
- frame->extended_data = frame->data;
- } else {
- frame->extended_data = NULL;
- }
-
- return ret;
-}
-
-int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
- int *got_sub_ptr,
- AVPacket *avpkt)
-{
- int ret = 0;
-
- if (avctx->codec->type != AVMEDIA_TYPE_SUBTITLE) {
- av_log(avctx, AV_LOG_ERROR, "Invalid media type for subtitles\n");
- return AVERROR(EINVAL);
- }
-
- *got_sub_ptr = 0;
- avcodec_get_subtitle_defaults(sub);
-
- if (avpkt->size) {
- AVPacket tmp = *avpkt;
- int did_split = av_packet_split_side_data(&tmp);
- //apply_param_change(avctx, &tmp);
-
- avctx->pkt = &tmp;
-
- if (avctx->pkt_timebase.den && avpkt->pts != AV_NOPTS_VALUE)
- sub->pts = av_rescale_q(avpkt->pts,
- avctx->pkt_timebase, AV_TIME_BASE_Q);
- ret = avctx->codec->decode(avctx, sub, got_sub_ptr, &tmp);
- sub->format = sub->num_rects && sub->rects[0]->ass;
-
- avctx->pkt = NULL;
- if (did_split) {
- ff_packet_free_side_data(&tmp);
- if(ret == tmp.size)
- ret = avpkt->size;
- }
-
- if (*got_sub_ptr)
- avctx->frame_number++;
- }
-
- return ret;
-}
-
-void avsubtitle_free(AVSubtitle *sub)
-{
- int i;
-
- for (i = 0; i < sub->num_rects; i++) {
- av_freep(&sub->rects[i]->pict.data[0]);
- av_freep(&sub->rects[i]->pict.data[1]);
- av_freep(&sub->rects[i]->pict.data[2]);
- av_freep(&sub->rects[i]->pict.data[3]);
- av_freep(&sub->rects[i]->text);
- av_freep(&sub->rects[i]->ass);
- av_freep(&sub->rects[i]);
- }
-
- av_freep(&sub->rects);
-
- memset(sub, 0, sizeof(AVSubtitle));
-}
-
-av_cold int ff_codec_close_recursive(AVCodecContext *avctx)
-{
- int ret = 0;
-
- ff_unlock_avcodec();
-
- ret = avcodec_close(avctx);
-
- ff_lock_avcodec(NULL);
- return ret;
-}
-
-av_cold int avcodec_close(AVCodecContext *avctx)
-{
- int ret = ff_lock_avcodec(avctx);
- if (ret < 0)
- return ret;
-
- if (avcodec_is_open(avctx)) {
- if (HAVE_THREADS && avctx->internal->frame_thread_encoder && avctx->thread_count > 1) {
- ff_unlock_avcodec();
- ff_frame_thread_encoder_free(avctx);
- ff_lock_avcodec(avctx);
- }
- if (HAVE_THREADS && avctx->thread_opaque)
- ff_thread_free(avctx);
- if (avctx->codec && avctx->codec->close)
- avctx->codec->close(avctx);
- avcodec_default_free_buffers(avctx);
- avctx->coded_frame = NULL;
- avctx->internal->byte_buffer_size = 0;
- av_freep(&avctx->internal->byte_buffer);
- av_freep(&avctx->internal);
- av_dict_free(&avctx->metadata);
- }
-
- if (avctx->priv_data && avctx->codec && avctx->codec->priv_class)
- av_opt_free(avctx->priv_data);
- av_opt_free(avctx);
- av_freep(&avctx->priv_data);
- if (av_codec_is_encoder(avctx->codec))
- av_freep(&avctx->extradata);
- avctx->codec = NULL;
- avctx->active_thread_type = 0;
-
- ff_unlock_avcodec();
- return 0;
-}
-
-static enum AVCodecID remap_deprecated_codec_id(enum AVCodecID id)
-{
- switch(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;
- default : return id;
- }
-}
-
-static AVCodec *find_encdec(enum AVCodecID id, int encoder)
-{
- AVCodec *p, *experimental = NULL;
- p = first_avcodec;
- id= remap_deprecated_codec_id(id);
- while (p) {
- if ((encoder ? av_codec_is_encoder(p) : av_codec_is_decoder(p)) &&
- p->id == id) {
- if (p->capabilities & CODEC_CAP_EXPERIMENTAL && !experimental) {
- experimental = p;
- } else
- return p;
- }
- p = p->next;
- }
- return experimental;
-}
-
-AVCodec *avcodec_find_encoder(enum AVCodecID id)
-{
- return find_encdec(id, 1);
-}
-
-AVCodec *avcodec_find_encoder_by_name(const char *name)
-{
- AVCodec *p;
- if (!name)
- return NULL;
- p = first_avcodec;
- while (p) {
- if (av_codec_is_encoder(p) && strcmp(name, p->name) == 0)
- return p;
- p = p->next;
- }
- return NULL;
-}
-
-AVCodec *avcodec_find_decoder(enum AVCodecID id)
-{
- return find_encdec(id, 0);
-}
-
-AVCodec *avcodec_find_decoder_by_name(const char *name)
-{
- AVCodec *p;
- if (!name)
- return NULL;
- p = first_avcodec;
- while (p) {
- if (av_codec_is_decoder(p) && strcmp(name, p->name) == 0)
- return p;
- p = p->next;
- }
- return NULL;
-}
-
-const char *avcodec_get_name(enum AVCodecID id)
-{
- const AVCodecDescriptor *cd;
- AVCodec *codec;
-
- if (id == AV_CODEC_ID_NONE)
- return "none";
- cd = avcodec_descriptor_get(id);
- if (cd)
- return cd->name;
- av_log(NULL, AV_LOG_WARNING, "Codec 0x%x is not in the full list.\n", id);
- codec = avcodec_find_decoder(id);
- if (codec)
- return codec->name;
- codec = avcodec_find_encoder(id);
- if (codec)
- return codec->name;
- return "unknown_codec";
-}
-
-size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag)
-{
- int i, len, ret = 0;
-
-#define IS_PRINT(x) \
- (((x) >= '0' && (x) <= '9') || \
- ((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z') || \
- ((x) == '.' || (x) == ' ' || (x) == '-' || (x) == '_'))
-
- for (i = 0; i < 4; i++) {
- len = snprintf(buf, buf_size,
- IS_PRINT(codec_tag&0xFF) ? "%c" : "[%d]", codec_tag&0xFF);
- buf += len;
- buf_size = buf_size > len ? buf_size - len : 0;
- ret += len;
- codec_tag >>= 8;
- }
- return ret;
-}
-
-void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
-{
- const char *codec_type;
- const char *codec_name;
- const char *profile = NULL;
- const AVCodec *p;
- int bitrate;
- AVRational display_aspect_ratio;
-
- if (!buf || buf_size <= 0)
- return;
- codec_type = av_get_media_type_string(enc->codec_type);
- codec_name = avcodec_get_name(enc->codec_id);
- if (enc->profile != FF_PROFILE_UNKNOWN) {
- if (enc->codec)
- p = enc->codec;
- else
- p = encode ? avcodec_find_encoder(enc->codec_id) :
- avcodec_find_decoder(enc->codec_id);
- if (p)
- profile = av_get_profile_name(p, enc->profile);
- }
-
- snprintf(buf, buf_size, "%s: %s%s", codec_type ? codec_type : "unknown",
- codec_name, enc->mb_decision ? " (hq)" : "");
- buf[0] ^= 'a' ^ 'A'; /* first letter in uppercase */
- if (profile)
- snprintf(buf + strlen(buf), buf_size - strlen(buf), " (%s)", profile);
- if (enc->codec_tag) {
- char tag_buf[32];
- av_get_codec_tag_string(tag_buf, sizeof(tag_buf), enc->codec_tag);
- snprintf(buf + strlen(buf), buf_size - strlen(buf),
- " (%s / 0x%04X)", tag_buf, enc->codec_tag);
- }
-
- switch (enc->codec_type) {
- case AVMEDIA_TYPE_VIDEO:
- if (enc->pix_fmt != AV_PIX_FMT_NONE) {
- snprintf(buf + strlen(buf), buf_size - strlen(buf),
- ", %s",
- av_get_pix_fmt_name(enc->pix_fmt));
- if (enc->bits_per_raw_sample &&
- enc->bits_per_raw_sample <= av_pix_fmt_desc_get(enc->pix_fmt)->comp[0].depth_minus1)
- snprintf(buf + strlen(buf), buf_size - strlen(buf),
- " (%d bpc)", enc->bits_per_raw_sample);
- }
- if (enc->width) {
- snprintf(buf + strlen(buf), buf_size - strlen(buf),
- ", %dx%d",
- enc->width, enc->height);
- if (enc->sample_aspect_ratio.num) {
- av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
- enc->width * enc->sample_aspect_ratio.num,
- enc->height * enc->sample_aspect_ratio.den,
- 1024 * 1024);
- snprintf(buf + strlen(buf), buf_size - strlen(buf),
- " [SAR %d:%d DAR %d:%d]",
- enc->sample_aspect_ratio.num, enc->sample_aspect_ratio.den,
- display_aspect_ratio.num, display_aspect_ratio.den);
- }
- if (av_log_get_level() >= AV_LOG_DEBUG) {
- int g = av_gcd(enc->time_base.num, enc->time_base.den);
- snprintf(buf + strlen(buf), buf_size - strlen(buf),
- ", %d/%d",
- enc->time_base.num / g, enc->time_base.den / g);
- }
- }
- if (encode) {
- snprintf(buf + strlen(buf), buf_size - strlen(buf),
- ", q=%d-%d", enc->qmin, enc->qmax);
- }
- break;
- case AVMEDIA_TYPE_AUDIO:
- if (enc->sample_rate) {
- snprintf(buf + strlen(buf), buf_size - strlen(buf),
- ", %d Hz", enc->sample_rate);
- }
- av_strlcat(buf, ", ", buf_size);
- av_get_channel_layout_string(buf + strlen(buf), buf_size - strlen(buf), enc->channels, enc->channel_layout);
- if (enc->sample_fmt != AV_SAMPLE_FMT_NONE) {
- snprintf(buf + strlen(buf), buf_size - strlen(buf),
- ", %s", av_get_sample_fmt_name(enc->sample_fmt));
- }
- break;
- case AVMEDIA_TYPE_DATA:
- if (av_log_get_level() >= AV_LOG_DEBUG) {
- int g = av_gcd(enc->time_base.num, enc->time_base.den);
- if (g)
- snprintf(buf + strlen(buf), buf_size - strlen(buf),
- ", %d/%d",
- enc->time_base.num / g, enc->time_base.den / g);
- }
- break;
- default:
- return;
- }
- if (encode) {
- if (enc->flags & CODEC_FLAG_PASS1)
- snprintf(buf + strlen(buf), buf_size - strlen(buf),
- ", pass 1");
- if (enc->flags & CODEC_FLAG_PASS2)
- snprintf(buf + strlen(buf), buf_size - strlen(buf),
- ", pass 2");
- }
- bitrate = get_bit_rate(enc);
- if (bitrate != 0) {
- snprintf(buf + strlen(buf), buf_size - strlen(buf),
- ", %d kb/s", bitrate / 1000);
- }
-}
-
-const char *av_get_profile_name(const AVCodec *codec, int profile)
-{
- const AVProfile *p;
- if (profile == FF_PROFILE_UNKNOWN || !codec->profiles)
- return NULL;
-
- for (p = codec->profiles; p->profile != FF_PROFILE_UNKNOWN; p++)
- if (p->profile == profile)
- return p->name;
-
- return NULL;
-}
-
-unsigned avcodec_version(void)
-{
-// av_assert0(AV_CODEC_ID_V410==164);
- av_assert0(AV_CODEC_ID_PCM_S8_PLANAR==65563);
- av_assert0(AV_CODEC_ID_ADPCM_G722==69660);
-// av_assert0(AV_CODEC_ID_BMV_AUDIO==86071);
- av_assert0(AV_CODEC_ID_SRT==94216);
- av_assert0(LIBAVCODEC_VERSION_MICRO >= 100);
-
- return LIBAVCODEC_VERSION_INT;
-}
-
-const char *avcodec_configuration(void)
-{
- return FFMPEG_CONFIGURATION;
-}
-
-const char *avcodec_license(void)
-{
-#define LICENSE_PREFIX "libavcodec license: "
- return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1;
-}
-
-void avcodec_flush_buffers(AVCodecContext *avctx)
-{
- if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)
- ff_thread_flush(avctx);
- else if (avctx->codec->flush)
- avctx->codec->flush(avctx);
-
- avctx->pts_correction_last_pts =
- avctx->pts_correction_last_dts = INT64_MIN;
-}
-
-static void video_free_buffers(AVCodecContext *s)
-{
- AVCodecInternal *avci = s->internal;
- int i, j;
-
- if (!avci->buffer)
- return;
-
- if (avci->buffer_count)
- av_log(s, AV_LOG_WARNING, "Found %i unreleased buffers!\n",
- avci->buffer_count);
- for (i = 0; i < INTERNAL_BUFFER_SIZE; i++) {
- InternalBuffer *buf = &avci->buffer[i];
- for (j = 0; j < 4; j++) {
- av_freep(&buf->base[j]);
- buf->data[j] = NULL;
- }
- }
- av_freep(&avci->buffer);
-
- avci->buffer_count = 0;
-}
-
-static void audio_free_buffers(AVCodecContext *avctx)
-{
- AVCodecInternal *avci = avctx->internal;
- av_freep(&avci->audio_data);
-}
-
-void avcodec_default_free_buffers(AVCodecContext *avctx)
-{
- switch (avctx->codec_type) {
- case AVMEDIA_TYPE_VIDEO:
- video_free_buffers(avctx);
- break;
- case AVMEDIA_TYPE_AUDIO:
- audio_free_buffers(avctx);
- break;
- default:
- break;
- }
-}
-
-int av_get_exact_bits_per_sample(enum AVCodecID codec_id)
-{
- switch (codec_id) {
- case AV_CODEC_ID_8SVX_EXP:
- case AV_CODEC_ID_8SVX_FIB:
- case AV_CODEC_ID_ADPCM_CT:
- case AV_CODEC_ID_ADPCM_IMA_APC:
- case AV_CODEC_ID_ADPCM_IMA_EA_SEAD:
- case AV_CODEC_ID_ADPCM_IMA_OKI:
- case AV_CODEC_ID_ADPCM_IMA_WS:
- case AV_CODEC_ID_ADPCM_G722:
- case AV_CODEC_ID_ADPCM_YAMAHA:
- return 4;
- case AV_CODEC_ID_PCM_ALAW:
- case AV_CODEC_ID_PCM_MULAW:
- case AV_CODEC_ID_PCM_S8:
- case AV_CODEC_ID_PCM_S8_PLANAR:
- case AV_CODEC_ID_PCM_U8:
- case AV_CODEC_ID_PCM_ZORK:
- return 8;
- case AV_CODEC_ID_PCM_S16BE:
- case AV_CODEC_ID_PCM_S16BE_PLANAR:
- case AV_CODEC_ID_PCM_S16LE:
- case AV_CODEC_ID_PCM_S16LE_PLANAR:
- case AV_CODEC_ID_PCM_U16BE:
- case AV_CODEC_ID_PCM_U16LE:
- return 16;
- case AV_CODEC_ID_PCM_S24DAUD:
- case AV_CODEC_ID_PCM_S24BE:
- case AV_CODEC_ID_PCM_S24LE:
- case AV_CODEC_ID_PCM_S24LE_PLANAR:
- case AV_CODEC_ID_PCM_U24BE:
- case AV_CODEC_ID_PCM_U24LE:
- return 24;
- case AV_CODEC_ID_PCM_S32BE:
- case AV_CODEC_ID_PCM_S32LE:
- case AV_CODEC_ID_PCM_S32LE_PLANAR:
- case AV_CODEC_ID_PCM_U32BE:
- case AV_CODEC_ID_PCM_U32LE:
- case AV_CODEC_ID_PCM_F32BE:
- case AV_CODEC_ID_PCM_F32LE:
- return 32;
- case AV_CODEC_ID_PCM_F64BE:
- case AV_CODEC_ID_PCM_F64LE:
- return 64;
- default:
- return 0;
- }
-}
-
-enum AVCodecID av_get_pcm_codec(enum AVSampleFormat fmt, int be)
-{
- static const enum AVCodecID map[AV_SAMPLE_FMT_NB][2] = {
- [AV_SAMPLE_FMT_U8 ] = { AV_CODEC_ID_PCM_U8, AV_CODEC_ID_PCM_U8 },
- [AV_SAMPLE_FMT_S16 ] = { AV_CODEC_ID_PCM_S16LE, AV_CODEC_ID_PCM_S16BE },
- [AV_SAMPLE_FMT_S32 ] = { AV_CODEC_ID_PCM_S32LE, AV_CODEC_ID_PCM_S32BE },
- [AV_SAMPLE_FMT_FLT ] = { AV_CODEC_ID_PCM_F32LE, AV_CODEC_ID_PCM_F32BE },
- [AV_SAMPLE_FMT_DBL ] = { AV_CODEC_ID_PCM_F64LE, AV_CODEC_ID_PCM_F64BE },
- [AV_SAMPLE_FMT_U8P ] = { AV_CODEC_ID_PCM_U8, AV_CODEC_ID_PCM_U8 },
- [AV_SAMPLE_FMT_S16P] = { AV_CODEC_ID_PCM_S16LE, AV_CODEC_ID_PCM_S16BE },
- [AV_SAMPLE_FMT_S32P] = { AV_CODEC_ID_PCM_S32LE, AV_CODEC_ID_PCM_S32BE },
- [AV_SAMPLE_FMT_FLTP] = { AV_CODEC_ID_PCM_F32LE, AV_CODEC_ID_PCM_F32BE },
- [AV_SAMPLE_FMT_DBLP] = { AV_CODEC_ID_PCM_F64LE, AV_CODEC_ID_PCM_F64BE },
- };
- if (fmt < 0 || fmt >= AV_SAMPLE_FMT_NB)
- return AV_CODEC_ID_NONE;
- if (be < 0 || be > 1)
- be = AV_NE(1, 0);
- return map[fmt][be];
-}
-
-int av_get_bits_per_sample(enum AVCodecID codec_id)
-{
- switch (codec_id) {
- case AV_CODEC_ID_ADPCM_SBPRO_2:
- return 2;
- case AV_CODEC_ID_ADPCM_SBPRO_3:
- return 3;
- case AV_CODEC_ID_ADPCM_SBPRO_4:
- case AV_CODEC_ID_ADPCM_IMA_WAV:
- case AV_CODEC_ID_ADPCM_IMA_QT:
- case AV_CODEC_ID_ADPCM_SWF:
- case AV_CODEC_ID_ADPCM_MS:
- return 4;
- default:
- return av_get_exact_bits_per_sample(codec_id);
- }
-}
-
-int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes)
-{
- int id, sr, ch, ba, tag, bps;
-
- id = avctx->codec_id;
- sr = avctx->sample_rate;
- ch = avctx->channels;
- ba = avctx->block_align;
- tag = avctx->codec_tag;
- bps = av_get_exact_bits_per_sample(avctx->codec_id);
-
- /* codecs with an exact constant bits per sample */
- if (bps > 0 && ch > 0 && frame_bytes > 0 && ch < 32768 && bps < 32768)
- return (frame_bytes * 8LL) / (bps * ch);
- bps = avctx->bits_per_coded_sample;
-
- /* codecs with a fixed packet duration */
- switch (id) {
- case AV_CODEC_ID_ADPCM_ADX: return 32;
- case AV_CODEC_ID_ADPCM_IMA_QT: return 64;
- case AV_CODEC_ID_ADPCM_EA_XAS: return 128;
- case AV_CODEC_ID_AMR_NB:
- case AV_CODEC_ID_EVRC:
- case AV_CODEC_ID_GSM:
- case AV_CODEC_ID_QCELP:
- case AV_CODEC_ID_RA_288: return 160;
- case AV_CODEC_ID_AMR_WB:
- case AV_CODEC_ID_GSM_MS: return 320;
- case AV_CODEC_ID_MP1: return 384;
- case AV_CODEC_ID_ATRAC1: return 512;
- case AV_CODEC_ID_ATRAC3: return 1024;
- case AV_CODEC_ID_MP2:
- case AV_CODEC_ID_MUSEPACK7: return 1152;
- case AV_CODEC_ID_AC3: return 1536;
- }
-
- if (sr > 0) {
- /* calc from sample rate */
- if (id == AV_CODEC_ID_TTA)
- return 256 * sr / 245;
-
- if (ch > 0) {
- /* calc from sample rate and channels */
- if (id == AV_CODEC_ID_BINKAUDIO_DCT)
- return (480 << (sr / 22050)) / ch;
- }
- }
-
- if (ba > 0) {
- /* calc from block_align */
- if (id == AV_CODEC_ID_SIPR) {
- switch (ba) {
- case 20: return 160;
- case 19: return 144;
- case 29: return 288;
- case 37: return 480;
- }
- } else if (id == AV_CODEC_ID_ILBC) {
- switch (ba) {
- case 38: return 160;
- case 50: return 240;
- }
- }
- }
-
- if (frame_bytes > 0) {
- /* calc from frame_bytes only */
- if (id == AV_CODEC_ID_TRUESPEECH)
- return 240 * (frame_bytes / 32);
- if (id == AV_CODEC_ID_NELLYMOSER)
- return 256 * (frame_bytes / 64);
- if (id == AV_CODEC_ID_RA_144)
- return 160 * (frame_bytes / 20);
- if (id == AV_CODEC_ID_G723_1)
- return 240 * (frame_bytes / 24);
-
- if (bps > 0) {
- /* calc from frame_bytes and bits_per_coded_sample */
- if (id == AV_CODEC_ID_ADPCM_G726)
- return frame_bytes * 8 / bps;
- }
-
- if (ch > 0) {
- /* calc from frame_bytes and channels */
- switch (id) {
- case AV_CODEC_ID_ADPCM_AFC:
- return frame_bytes / (9 * ch) * 16;
- case AV_CODEC_ID_ADPCM_4XM:
- case AV_CODEC_ID_ADPCM_IMA_ISS:
- return (frame_bytes - 4 * ch) * 2 / ch;
- case AV_CODEC_ID_ADPCM_IMA_SMJPEG:
- return (frame_bytes - 4) * 2 / ch;
- case AV_CODEC_ID_ADPCM_IMA_AMV:
- return (frame_bytes - 8) * 2 / ch;
- case AV_CODEC_ID_ADPCM_XA:
- return (frame_bytes / 128) * 224 / ch;
- case AV_CODEC_ID_INTERPLAY_DPCM:
- return (frame_bytes - 6 - ch) / ch;
- case AV_CODEC_ID_ROQ_DPCM:
- return (frame_bytes - 8) / ch;
- case AV_CODEC_ID_XAN_DPCM:
- return (frame_bytes - 2 * ch) / ch;
- case AV_CODEC_ID_MACE3:
- return 3 * frame_bytes / ch;
- case AV_CODEC_ID_MACE6:
- return 6 * frame_bytes / ch;
- case AV_CODEC_ID_PCM_LXF:
- return 2 * (frame_bytes / (5 * ch));
- case AV_CODEC_ID_IAC:
- case AV_CODEC_ID_IMC:
- return 4 * frame_bytes / ch;
- }
-
- if (tag) {
- /* calc from frame_bytes, channels, and codec_tag */
- if (id == AV_CODEC_ID_SOL_DPCM) {
- if (tag == 3)
- return frame_bytes / ch;
- else
- return frame_bytes * 2 / ch;
- }
- }
-
- if (ba > 0) {
- /* calc from frame_bytes, channels, and block_align */
- int blocks = frame_bytes / ba;
- switch (avctx->codec_id) {
- case AV_CODEC_ID_ADPCM_IMA_WAV:
- return blocks * (1 + (ba - 4 * ch) / (4 * ch) * 8);
- case AV_CODEC_ID_ADPCM_IMA_DK3:
- return blocks * (((ba - 16) * 2 / 3 * 4) / ch);
- case AV_CODEC_ID_ADPCM_IMA_DK4:
- return blocks * (1 + (ba - 4 * ch) * 2 / ch);
- case AV_CODEC_ID_ADPCM_MS:
- return blocks * (2 + (ba - 7 * ch) * 2 / ch);
- }
- }
-
- if (bps > 0) {
- /* calc from frame_bytes, channels, and bits_per_coded_sample */
- switch (avctx->codec_id) {
- case AV_CODEC_ID_PCM_DVD:
- if(bps<4)
- return 0;
- return 2 * (frame_bytes / ((bps * 2 / 8) * ch));
- case AV_CODEC_ID_PCM_BLURAY:
- if(bps<4)
- return 0;
- return frame_bytes / ((FFALIGN(ch, 2) * bps) / 8);
- case AV_CODEC_ID_S302M:
- return 2 * (frame_bytes / ((bps + 4) / 4)) / ch;
- }
- }
- }
- }
-
- return 0;
-}
-
-#if !HAVE_THREADS
-int ff_thread_init(AVCodecContext *s)
-{
- return -1;
-}
-
-#endif
-
-unsigned int av_xiphlacing(unsigned char *s, unsigned int v)
-{
- unsigned int n = 0;
-
- while (v >= 0xff) {
- *s++ = 0xff;
- v -= 0xff;
- n++;
- }
- *s = v;
- n++;
- return n;
-}
-
-int ff_match_2uint16(const uint16_t(*tab)[2], int size, int a, int b)
-{
- int i;
- for (i = 0; i < size && !(tab[i][0] == a && tab[i][1] == b); i++) ;
- return i;
-}
-
-void av_log_missing_feature(void *avc, const char *feature, int want_sample)
-{
- av_log(avc, AV_LOG_WARNING, "%s is not implemented. Update your FFmpeg "
- "version to the newest one from Git. If the problem still "
- "occurs, it means that your file has a feature which has not "
- "been implemented.\n", feature);
- if(want_sample)
- av_log_ask_for_sample(avc, NULL);
-}
-
-void av_log_ask_for_sample(void *avc, const char *msg, ...)
-{
- va_list argument_list;
-
- va_start(argument_list, msg);
-
- if (msg)
- av_vlog(avc, AV_LOG_WARNING, msg, argument_list);
- av_log(avc, AV_LOG_WARNING, "If you want to help, upload a sample "
- "of this file to ftp://upload.ffmpeg.org/MPlayer/incoming/ "
- "and contact the ffmpeg-devel mailing list.\n");
-
- va_end(argument_list);
-}
-
-static AVHWAccel *first_hwaccel = NULL;
-
-void av_register_hwaccel(AVHWAccel *hwaccel)
-{
- AVHWAccel **p = &first_hwaccel;
- while (*p)
- p = &(*p)->next;
- *p = hwaccel;
- hwaccel->next = NULL;
-}
-
-AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel)
-{
- return hwaccel ? hwaccel->next : first_hwaccel;
-}
-
-AVHWAccel *ff_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 av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op))
-{
- if (ff_lockmgr_cb) {
- if (ff_lockmgr_cb(&codec_mutex, AV_LOCK_DESTROY))
- return -1;
- if (ff_lockmgr_cb(&avformat_mutex, AV_LOCK_DESTROY))
- return -1;
- }
-
- ff_lockmgr_cb = cb;
-
- if (ff_lockmgr_cb) {
- if (ff_lockmgr_cb(&codec_mutex, AV_LOCK_CREATE))
- return -1;
- if (ff_lockmgr_cb(&avformat_mutex, AV_LOCK_CREATE))
- return -1;
- }
- return 0;
-}
-
-int ff_lock_avcodec(AVCodecContext *log_ctx)
-{
- if (ff_lockmgr_cb) {
- if ((*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN))
- return -1;
- }
- entangled_thread_counter++;
- if (entangled_thread_counter != 1) {
- av_log(log_ctx, AV_LOG_ERROR, "Insufficient thread locking around avcodec_open/close()\n");
- ff_avcodec_locked = 1;
- ff_unlock_avcodec();
- return AVERROR(EINVAL);
- }
- av_assert0(!ff_avcodec_locked);
- ff_avcodec_locked = 1;
- return 0;
-}
-
-int ff_unlock_avcodec(void)
-{
- av_assert0(ff_avcodec_locked);
- ff_avcodec_locked = 0;
- entangled_thread_counter--;
- if (ff_lockmgr_cb) {
- if ((*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE))
- return -1;
- }
- return 0;
-}
-
-int avpriv_lock_avformat(void)
-{
- if (ff_lockmgr_cb) {
- if ((*ff_lockmgr_cb)(&avformat_mutex, AV_LOCK_OBTAIN))
- return -1;
- }
- return 0;
-}
-
-int avpriv_unlock_avformat(void)
-{
- if (ff_lockmgr_cb) {
- if ((*ff_lockmgr_cb)(&avformat_mutex, AV_LOCK_RELEASE))
- return -1;
- }
- return 0;
-}
-
-unsigned int avpriv_toupper4(unsigned int x)
-{
- return toupper(x & 0xFF)
- + (toupper((x >> 8) & 0xFF) << 8)
- + (toupper((x >> 16) & 0xFF) << 16)
- + (toupper((x >> 24) & 0xFF) << 24);
-}
-
-#if !HAVE_THREADS
-
-int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f)
-{
- f->owner = avctx;
-
- return ff_get_buffer(avctx, f);
-}
-
-void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f)
-{
- f->owner->release_buffer(f->owner, f);
-}
-
-void ff_thread_finish_setup(AVCodecContext *avctx)
-{
-}
-
-void ff_thread_report_progress(AVFrame *f, int progress, int field)
-{
-}
-
-void ff_thread_await_progress(AVFrame *f, int progress, int field)
-{
-}
-
-int ff_thread_can_start_frame(AVCodecContext *avctx)
-{
- return 1;
-}
-
-#endif
-
-enum AVMediaType avcodec_get_type(enum AVCodecID codec_id)
-{
- AVCodec *c= avcodec_find_decoder(codec_id);
- if(!c)
- c= avcodec_find_encoder(codec_id);
- if(c)
- return c->type;
-
- if (codec_id <= AV_CODEC_ID_NONE)
- return AVMEDIA_TYPE_UNKNOWN;
- else if (codec_id < AV_CODEC_ID_FIRST_AUDIO)
- return AVMEDIA_TYPE_VIDEO;
- else if (codec_id < AV_CODEC_ID_FIRST_SUBTITLE)
- return AVMEDIA_TYPE_AUDIO;
- else if (codec_id < AV_CODEC_ID_FIRST_UNKNOWN)
- return AVMEDIA_TYPE_SUBTITLE;
-
- return AVMEDIA_TYPE_UNKNOWN;
-}
-
-int avcodec_is_open(AVCodecContext *s)
-{
- return !!s->internal;
-}
-
-int avpriv_bprint_to_extradata(AVCodecContext *avctx, struct AVBPrint *buf)
-{
- int ret;
- char *str;
-
- ret = av_bprint_finalize(buf, &str);
- if (ret < 0)
- return ret;
- avctx->extradata = str;
- /* Note: the string is NUL terminated (so extradata can be read as a
- * string), but the ending character is not accounted in the size (in
- * binary formats you are likely not supposed to mux that character). When
- * extradata is copied, it is also padded with FF_INPUT_BUFFER_PADDING_SIZE
- * zeros. */
- avctx->extradata_size = buf->len;
- return 0;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/vc1.c b/src/thirdparty/ffmpeg/libavcodec/vc1.c
deleted file mode 100644
index 1b2b56757..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vc1.c
+++ /dev/null
@@ -1,1667 +0,0 @@
-/*
- * VC-1 and WMV3 decoder common code
- * Copyright (c) 2011 Mashiat Sarker Shakkhar
- * Copyright (c) 2006-2007 Konstantin Shishkov
- * Partly based on vc9.c (c) 2005 Anonymous, Alex Beregszaszi, 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
- */
-
-/**
- * @file
- * VC-1 and WMV3 decoder common code
- *
- */
-
-#include "internal.h"
-#include "dsputil.h"
-#include "avcodec.h"
-#include "mpegvideo.h"
-#include "vc1.h"
-#include "vc1data.h"
-#include "msmpeg4data.h"
-#include "unary.h"
-#include "simple_idct.h"
-
-#undef NDEBUG
-#include <assert.h>
-
-/***********************************************************************/
-/**
- * @name VC-1 Bitplane decoding
- * @see 8.7, p56
- * @{
- */
-
-/**
- * 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
- * @param[in] height Height of this buffer
- * @param[in] stride of this buffer
- */
-static void decode_rowskip(uint8_t* plane, int width, int height, int stride,
- GetBitContext *gb)
-{
- int x, y;
-
- for (y = 0; y < height; y++) {
- if (!get_bits1(gb)) //rowskip
- memset(plane, 0, width);
- else
- for (x = 0; x < width; x++)
- plane[x] = get_bits1(gb);
- plane += stride;
- }
-}
-
-/** Decode columns by checking if they are skipped
- * @param plane Buffer to store decoded bits
- * @param[in] width Width of this buffer
- * @param[in] height Height of this buffer
- * @param[in] stride of this buffer
- * @todo FIXME: Optimize
- */
-static void decode_colskip(uint8_t* plane, int width, int height, int stride,
- GetBitContext *gb)
-{
- int x, y;
-
- for (x = 0; x < width; x++) {
- if (!get_bits1(gb)) //colskip
- for (y = 0; y < height; y++)
- plane[y*stride] = 0;
- else
- for (y = 0; y < height; y++)
- plane[y*stride] = get_bits1(gb);
- plane ++;
- }
-}
-
-/** Decode a bitplane's bits
- * @param data bitplane where to store the decode bits
- * @param[out] raw_flag pointer to the flag indicating that this bitplane is not coded explicitly
- * @param v VC-1 context for bit reading and logging
- * @return Status
- * @todo FIXME: Optimize
- */
-static int bitplane_decoding(uint8_t* data, int *raw_flag, VC1Context *v)
-{
- GetBitContext *gb = &v->s.gb;
-
- int imode, x, y, code, offset;
- uint8_t invert, *planep = data;
- int width, height, stride;
-
- width = v->s.mb_width;
- height = v->s.mb_height >> v->field_mode;
- stride = v->s.mb_stride;
- invert = get_bits1(gb);
- imode = get_vlc2(gb, ff_vc1_imode_vlc.table, VC1_IMODE_VLC_BITS, 1);
-
- *raw_flag = 0;
- switch (imode) {
- case IMODE_RAW:
- //Data is actually read in the MB layer (same for all tests == "raw")
- *raw_flag = 1; //invert ignored
- return invert;
- case IMODE_DIFF2:
- case IMODE_NORM2:
- if ((height * width) & 1) {
- *planep++ = get_bits1(gb);
- offset = 1;
- }
- else
- offset = 0;
- // decode bitplane as one long line
- for (y = offset; y < height * width; y += 2) {
- code = get_vlc2(gb, ff_vc1_norm2_vlc.table, VC1_NORM2_VLC_BITS, 1);
- *planep++ = code & 1;
- offset++;
- if (offset == width) {
- offset = 0;
- planep += stride - width;
- }
- *planep++ = code >> 1;
- offset++;
- if (offset == width) {
- offset = 0;
- planep += stride - width;
- }
- }
- break;
- case IMODE_DIFF6:
- case IMODE_NORM6:
- if (!(height % 3) && (width % 3)) { // use 2x3 decoding
- for (y = 0; y < height; y += 3) {
- for (x = width & 1; x < width; x += 2) {
- code = get_vlc2(gb, ff_vc1_norm6_vlc.table, VC1_NORM6_VLC_BITS, 2);
- if (code < 0) {
- av_log(v->s.avctx, AV_LOG_DEBUG, "invalid NORM-6 VLC\n");
- return -1;
- }
- planep[x + 0] = (code >> 0) & 1;
- planep[x + 1] = (code >> 1) & 1;
- planep[x + 0 + stride] = (code >> 2) & 1;
- planep[x + 1 + stride] = (code >> 3) & 1;
- planep[x + 0 + stride * 2] = (code >> 4) & 1;
- planep[x + 1 + stride * 2] = (code >> 5) & 1;
- }
- planep += stride * 3;
- }
- if (width & 1)
- decode_colskip(data, 1, height, stride, &v->s.gb);
- } else { // 3x2
- planep += (height & 1) * stride;
- for (y = height & 1; y < height; y += 2) {
- for (x = width % 3; x < width; x += 3) {
- code = get_vlc2(gb, ff_vc1_norm6_vlc.table, VC1_NORM6_VLC_BITS, 2);
- if (code < 0) {
- av_log(v->s.avctx, AV_LOG_DEBUG, "invalid NORM-6 VLC\n");
- return -1;
- }
- planep[x + 0] = (code >> 0) & 1;
- planep[x + 1] = (code >> 1) & 1;
- planep[x + 2] = (code >> 2) & 1;
- planep[x + 0 + stride] = (code >> 3) & 1;
- planep[x + 1 + stride] = (code >> 4) & 1;
- planep[x + 2 + stride] = (code >> 5) & 1;
- }
- planep += stride * 2;
- }
- x = width % 3;
- if (x)
- decode_colskip(data, x, height, stride, &v->s.gb);
- if (height & 1)
- decode_rowskip(data + x, width - x, 1, stride, &v->s.gb);
- }
- break;
- case IMODE_ROWSKIP:
- decode_rowskip(data, width, height, stride, &v->s.gb);
- break;
- case IMODE_COLSKIP:
- decode_colskip(data, width, height, stride, &v->s.gb);
- break;
- default:
- break;
- }
-
- /* Applying diff operator */
- if (imode == IMODE_DIFF2 || imode == IMODE_DIFF6) {
- planep = data;
- planep[0] ^= invert;
- for (x = 1; x < width; x++)
- planep[x] ^= planep[x-1];
- for (y = 1; y < height; y++) {
- planep += stride;
- planep[0] ^= planep[-stride];
- for (x = 1; x < width; x++) {
- if (planep[x-1] != planep[x-stride]) planep[x] ^= invert;
- else planep[x] ^= planep[x-1];
- }
- }
- } else if (invert) {
- planep = data;
- for (x = 0; x < stride * height; x++)
- planep[x] = !planep[x]; //FIXME stride
- }
- return (imode << 1) + invert;
-}
-
-/** @} */ //Bitplane group
-
-/***********************************************************************/
-/** VOP Dquant decoding
- * @param v VC-1 Context
- */
-static int vop_dquant_decoding(VC1Context *v)
-{
- GetBitContext *gb = &v->s.gb;
- int pqdiff;
-
- //variable size
- if (v->dquant == 2) {
- pqdiff = get_bits(gb, 3);
- if (pqdiff == 7)
- v->altpq = get_bits(gb, 5);
- else
- v->altpq = v->pq + pqdiff + 1;
- } else {
- v->dquantfrm = get_bits1(gb);
- if (v->dquantfrm) {
- v->dqprofile = get_bits(gb, 2);
- switch (v->dqprofile) {
- case DQPROFILE_SINGLE_EDGE:
- case DQPROFILE_DOUBLE_EDGES:
- v->dqsbedge = get_bits(gb, 2);
- break;
- case DQPROFILE_ALL_MBS:
- v->dqbilevel = get_bits1(gb);
- if (!v->dqbilevel)
- v->halfpq = 0;
- default:
- break; //Forbidden ?
- }
- if (v->dqbilevel || v->dqprofile != DQPROFILE_ALL_MBS) {
- pqdiff = get_bits(gb, 3);
- if (pqdiff == 7)
- v->altpq = get_bits(gb, 5);
- else
- v->altpq = v->pq + pqdiff + 1;
- }
- }
- }
- return 0;
-}
-
-static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb);
-
-/**
- * Decode Simple/Main Profiles sequence header
- * @see Figure 7-8, p16-17
- * @param avctx Codec context
- * @param gb GetBit context initialized from Codec context extra_data
- * @return Status
- */
-int ff_vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitContext *gb)
-{
- av_log(avctx, AV_LOG_DEBUG, "Header: %0X\n", show_bits_long(gb, 32));
- v->profile = get_bits(gb, 2);
- if (v->profile == PROFILE_COMPLEX) {
- av_log(avctx, AV_LOG_WARNING, "WMV3 Complex Profile is not fully supported\n");
- }
-
- if (v->profile == PROFILE_ADVANCED) {
- v->zz_8x4 = ff_vc1_adv_progressive_8x4_zz;
- v->zz_4x8 = ff_vc1_adv_progressive_4x8_zz;
- return decode_sequence_header_adv(v, gb);
- } else {
- v->zz_8x4 = ff_wmv2_scantableA;
- v->zz_4x8 = ff_wmv2_scantableB;
- v->res_y411 = get_bits1(gb);
- v->res_sprite = get_bits1(gb);
- if (v->res_y411) {
- av_log(avctx, AV_LOG_ERROR,
- "Old interlaced mode is not supported\n");
- return -1;
- }
- }
-
- // (fps-2)/4 (->30)
- v->frmrtq_postproc = get_bits(gb, 3); //common
- // (bitrate-32kbps)/64kbps
- v->bitrtq_postproc = get_bits(gb, 5); //common
- v->s.loop_filter = get_bits1(gb); //common
- if (v->s.loop_filter == 1 && v->profile == PROFILE_SIMPLE) {
- av_log(avctx, AV_LOG_ERROR,
- "LOOPFILTER shall not be enabled in Simple Profile\n");
- }
- if (v->s.avctx->skip_loop_filter >= AVDISCARD_ALL)
- v->s.loop_filter = 0;
-
- v->res_x8 = get_bits1(gb); //reserved
- v->multires = get_bits1(gb);
- v->res_fasttx = get_bits1(gb);
- if (!v->res_fasttx) {
- v->vc1dsp.vc1_inv_trans_8x8 = ff_simple_idct_8;
- v->vc1dsp.vc1_inv_trans_8x4 = ff_simple_idct84_add;
- v->vc1dsp.vc1_inv_trans_4x8 = ff_simple_idct48_add;
- v->vc1dsp.vc1_inv_trans_4x4 = ff_simple_idct44_add;
- v->vc1dsp.vc1_inv_trans_8x8_dc = ff_simple_idct_add_8;
- v->vc1dsp.vc1_inv_trans_8x4_dc = ff_simple_idct84_add;
- v->vc1dsp.vc1_inv_trans_4x8_dc = ff_simple_idct48_add;
- v->vc1dsp.vc1_inv_trans_4x4_dc = ff_simple_idct44_add;
- }
-
- v->fastuvmc = get_bits1(gb); //common
- if (!v->profile && !v->fastuvmc) {
- av_log(avctx, AV_LOG_ERROR,
- "FASTUVMC unavailable in Simple Profile\n");
- return -1;
- }
- v->extended_mv = get_bits1(gb); //common
- if (!v->profile && v->extended_mv)
- {
- av_log(avctx, AV_LOG_ERROR,
- "Extended MVs unavailable in Simple Profile\n");
- return -1;
- }
- v->dquant = get_bits(gb, 2); //common
- v->vstransform = get_bits1(gb); //common
-
- v->res_transtab = get_bits1(gb);
- if (v->res_transtab)
- {
- av_log(avctx, AV_LOG_ERROR,
- "1 for reserved RES_TRANSTAB is forbidden\n");
- return -1;
- }
-
- v->overlap = get_bits1(gb); //common
-
- v->s.resync_marker = get_bits1(gb);
- v->rangered = get_bits1(gb);
- if (v->rangered && v->profile == PROFILE_SIMPLE) {
- av_log(avctx, AV_LOG_INFO,
- "RANGERED should be set to 0 in Simple Profile\n");
- }
-
- v->s.max_b_frames = avctx->max_b_frames = get_bits(gb, 3); //common
- v->quantizer_mode = get_bits(gb, 2); //common
-
- v->finterpflag = get_bits1(gb); //common
-
- if (v->res_sprite) {
- int w = get_bits(gb, 11);
- int h = get_bits(gb, 11);
- avcodec_set_dimensions(v->s.avctx, w, h);
- skip_bits(gb, 5); //frame rate
- v->res_x8 = get_bits1(gb);
- if (get_bits1(gb)) { // something to do with DC VLC selection
- av_log(avctx, AV_LOG_ERROR, "Unsupported sprite feature\n");
- return -1;
- }
- skip_bits(gb, 3); //slice code
- v->res_rtm_flag = 0;
- } else {
- v->res_rtm_flag = get_bits1(gb); //reserved
- }
- if (!v->res_rtm_flag) {
- av_log(avctx, AV_LOG_ERROR,
- "Old WMV3 version detected, some frames may be decoded incorrectly\n");
- //return -1;
- }
- //TODO: figure out what they mean (always 0x402F)
- if (!v->res_fasttx)
- skip_bits(gb, 16);
- av_log(avctx, AV_LOG_DEBUG,
- "Profile %i:\nfrmrtq_postproc=%i, bitrtq_postproc=%i\n"
- "LoopFilter=%i, MultiRes=%i, FastUVMC=%i, Extended MV=%i\n"
- "Rangered=%i, VSTransform=%i, Overlap=%i, SyncMarker=%i\n"
- "DQuant=%i, Quantizer mode=%i, Max B frames=%i\n",
- v->profile, v->frmrtq_postproc, v->bitrtq_postproc,
- v->s.loop_filter, v->multires, v->fastuvmc, v->extended_mv,
- v->rangered, v->vstransform, v->overlap, v->s.resync_marker,
- v->dquant, v->quantizer_mode, avctx->max_b_frames);
- return 0;
-}
-
-static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb)
-{
- v->res_rtm_flag = 1;
- v->level = get_bits(gb, 3);
- if (v->level >= 5) {
- av_log(v->s.avctx, AV_LOG_ERROR, "Reserved LEVEL %i\n",v->level);
- }
- v->chromaformat = get_bits(gb, 2);
- if (v->chromaformat != 1) {
- av_log(v->s.avctx, AV_LOG_ERROR,
- "Only 4:2:0 chroma format supported\n");
- return -1;
- }
-
- // (fps-2)/4 (->30)
- v->frmrtq_postproc = get_bits(gb, 3); //common
- // (bitrate-32kbps)/64kbps
- v->bitrtq_postproc = get_bits(gb, 5); //common
- v->postprocflag = get_bits1(gb); //common
-
- v->max_coded_width = (get_bits(gb, 12) + 1) << 1;
- v->max_coded_height = (get_bits(gb, 12) + 1) << 1;
- v->broadcast = get_bits1(gb);
- v->interlace = get_bits1(gb);
- v->tfcntrflag = get_bits1(gb);
- v->finterpflag = get_bits1(gb);
- skip_bits1(gb); // reserved
-
- av_log(v->s.avctx, AV_LOG_DEBUG,
- "Advanced Profile level %i:\nfrmrtq_postproc=%i, bitrtq_postproc=%i\n"
- "LoopFilter=%i, ChromaFormat=%i, Pulldown=%i, Interlace: %i\n"
- "TFCTRflag=%i, FINTERPflag=%i\n",
- v->level, v->frmrtq_postproc, v->bitrtq_postproc,
- v->s.loop_filter, v->chromaformat, v->broadcast, v->interlace,
- v->tfcntrflag, v->finterpflag);
-
- v->psf = get_bits1(gb);
- if (v->psf) { //PsF, 6.1.13
- av_log(v->s.avctx, AV_LOG_ERROR, "Progressive Segmented Frame mode: not supported (yet)\n");
- return -1;
- }
- v->s.max_b_frames = v->s.avctx->max_b_frames = 7;
- if (get_bits1(gb)) { //Display Info - decoding is not affected by it
- int w, h, ar = 0;
- av_log(v->s.avctx, AV_LOG_DEBUG, "Display extended info:\n");
- w = get_bits(gb, 14) + 1;
- h = get_bits(gb, 14) + 1;
- av_log(v->s.avctx, AV_LOG_DEBUG, "Display dimensions: %ix%i\n", w, h);
- if (get_bits1(gb))
- ar = get_bits(gb, 4);
- if (ar && ar < 14) {
- v->s.avctx->sample_aspect_ratio = ff_vc1_pixel_aspect[ar];
- } else if (ar == 15) {
- w = get_bits(gb, 8) + 1;
- h = get_bits(gb, 8) + 1;
- v->s.avctx->sample_aspect_ratio = (AVRational){w, h};
- } else {
- av_reduce(&v->s.avctx->sample_aspect_ratio.num,
- &v->s.avctx->sample_aspect_ratio.den,
- v->s.avctx->height * w,
- v->s.avctx->width * h,
- 1 << 30);
- }
- av_log(v->s.avctx, AV_LOG_DEBUG, "Aspect: %i:%i\n",
- v->s.avctx->sample_aspect_ratio.num,
- v->s.avctx->sample_aspect_ratio.den);
-
- if (get_bits1(gb)) { //framerate stuff
- if (get_bits1(gb)) {
- v->s.avctx->time_base.num = 32;
- v->s.avctx->time_base.den = get_bits(gb, 16) + 1;
- } else {
- int nr, dr;
- nr = get_bits(gb, 8);
- dr = get_bits(gb, 4);
- if (nr > 0 && nr < 8 && dr > 0 && dr < 3) {
- v->s.avctx->time_base.num = ff_vc1_fps_dr[dr - 1];
- v->s.avctx->time_base.den = ff_vc1_fps_nr[nr - 1] * 1000;
- }
- }
- if (v->broadcast) { // Pulldown may be present
- v->s.avctx->time_base.den *= 2;
- v->s.avctx->ticks_per_frame = 2;
- }
- }
-
- if (get_bits1(gb)) {
- v->s.avctx->color_primaries = get_bits(gb, 8);
- v->s.avctx->color_trc = get_bits(gb, 8);
- v->s.avctx->colorspace = get_bits(gb, 8);
- v->s.avctx->color_range = AVCOL_RANGE_MPEG;
- }
- }
-
- v->hrd_param_flag = get_bits1(gb);
- if (v->hrd_param_flag) {
- int i;
- v->hrd_num_leaky_buckets = get_bits(gb, 5);
- skip_bits(gb, 4); //bitrate exponent
- skip_bits(gb, 4); //buffer size exponent
- for (i = 0; i < v->hrd_num_leaky_buckets; i++) {
- skip_bits(gb, 16); //hrd_rate[n]
- skip_bits(gb, 16); //hrd_buffer[n]
- }
- }
- return 0;
-}
-
-int ff_vc1_decode_entry_point(AVCodecContext *avctx, VC1Context *v, GetBitContext *gb)
-{
- int i;
- int w,h;
-
- av_log(avctx, AV_LOG_DEBUG, "Entry point: %08X\n", show_bits_long(gb, 32));
- v->broken_link = get_bits1(gb);
- v->closed_entry = get_bits1(gb);
- v->panscanflag = get_bits1(gb);
- v->refdist_flag = get_bits1(gb);
- v->s.loop_filter = get_bits1(gb);
- if (v->s.avctx->skip_loop_filter >= AVDISCARD_ALL)
- v->s.loop_filter = 0;
- v->fastuvmc = get_bits1(gb);
- v->extended_mv = get_bits1(gb);
- v->dquant = get_bits(gb, 2);
- v->vstransform = get_bits1(gb);
- v->overlap = get_bits1(gb);
- v->quantizer_mode = get_bits(gb, 2);
-
- if (v->hrd_param_flag) {
- for (i = 0; i < v->hrd_num_leaky_buckets; i++) {
- skip_bits(gb, 8); //hrd_full[n]
- }
- }
-
- if(get_bits1(gb)){
- w = (get_bits(gb, 12)+1)<<1;
- h = (get_bits(gb, 12)+1)<<1;
- } else {
- w = v->max_coded_width;
- h = v->max_coded_height;
- }
- avcodec_set_dimensions(avctx, w, h);
- if (v->extended_mv)
- v->extended_dmv = get_bits1(gb);
- if ((v->range_mapy_flag = get_bits1(gb))) {
- av_log(avctx, AV_LOG_ERROR, "Luma scaling is not supported, expect wrong picture\n");
- v->range_mapy = get_bits(gb, 3);
- }
- if ((v->range_mapuv_flag = get_bits1(gb))) {
- av_log(avctx, AV_LOG_ERROR, "Chroma scaling is not supported, expect wrong picture\n");
- v->range_mapuv = get_bits(gb, 3);
- }
-
- av_log(avctx, AV_LOG_DEBUG, "Entry point info:\n"
- "BrokenLink=%i, ClosedEntry=%i, PanscanFlag=%i\n"
- "RefDist=%i, Postproc=%i, FastUVMC=%i, ExtMV=%i\n"
- "DQuant=%i, VSTransform=%i, Overlap=%i, Qmode=%i\n",
- v->broken_link, v->closed_entry, v->panscanflag, v->refdist_flag, v->s.loop_filter,
- v->fastuvmc, v->extended_mv, v->dquant, v->vstransform, v->overlap, v->quantizer_mode);
-
- return 0;
-}
-
-int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* gb)
-{
- int pqindex, lowquant, status;
-
- if (v->finterpflag)
- v->interpfrm = get_bits1(gb);
- if (!v->s.avctx->codec)
- return -1;
- if (v->s.avctx->codec_id == AV_CODEC_ID_MSS2)
- v->respic =
- v->rangered =
- v->multires = get_bits(gb, 2) == 1;
- else
- skip_bits(gb, 2); //framecnt unused
- v->rangeredfrm = 0;
- if (v->rangered)
- v->rangeredfrm = get_bits1(gb);
- v->s.pict_type = get_bits1(gb);
- if (v->s.avctx->max_b_frames) {
- if (!v->s.pict_type) {
- if (get_bits1(gb))
- v->s.pict_type = AV_PICTURE_TYPE_I;
- else
- v->s.pict_type = AV_PICTURE_TYPE_B;
- } else
- v->s.pict_type = AV_PICTURE_TYPE_P;
- } else
- v->s.pict_type = v->s.pict_type ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
-
- 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 (v->bfraction == 0) {
- v->s.pict_type = AV_PICTURE_TYPE_BI;
- }
- }
- if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI)
- skip_bits(gb, 7); // skip buffer fullness
-
- if (v->parse_only)
- return 0;
-
- /* calculate RND */
- if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI)
- v->rnd = 1;
- if (v->s.pict_type == AV_PICTURE_TYPE_P)
- v->rnd ^= 1;
-
- /* Quantizer stuff */
- pqindex = get_bits(gb, 5);
- if (!pqindex)
- return -1;
- if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)
- v->pq = ff_vc1_pquant_table[0][pqindex];
- else
- v->pq = ff_vc1_pquant_table[1][pqindex];
-
- v->pquantizer = 1;
- if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)
- v->pquantizer = pqindex < 9;
- if (v->quantizer_mode == QUANT_NON_UNIFORM)
- v->pquantizer = 0;
- v->pqindex = pqindex;
- if (pqindex < 9)
- v->halfpq = get_bits1(gb);
- else
- v->halfpq = 0;
- if (v->quantizer_mode == QUANT_FRAME_EXPLICIT)
- v->pquantizer = get_bits1(gb);
- v->dquantfrm = 0;
- if (v->extended_mv == 1)
- v->mvrange = get_unary(gb, 0, 3);
- v->k_x = v->mvrange + 9 + (v->mvrange >> 1); //k_x can be 9 10 12 13
- v->k_y = v->mvrange + 8; //k_y can be 8 9 10 11
- v->range_x = 1 << (v->k_x - 1);
- v->range_y = 1 << (v->k_y - 1);
- if (v->multires && v->s.pict_type != AV_PICTURE_TYPE_B)
- v->respic = get_bits(gb, 2);
-
- if (v->res_x8 && (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI)) {
- v->x8_type = get_bits1(gb);
- } else
- v->x8_type = 0;
- av_dlog(v->s.avctx, "%c Frame: QP=[%i]%i (+%i/2) %i\n",
- (v->s.pict_type == AV_PICTURE_TYPE_P) ? 'P' : ((v->s.pict_type == AV_PICTURE_TYPE_I) ? 'I' : 'B'),
- pqindex, v->pq, v->halfpq, v->rangeredfrm);
-
- if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_P)
- v->use_ic = 0;
-
- switch (v->s.pict_type) {
- case AV_PICTURE_TYPE_P:
- if (v->pq < 5) v->tt_index = 0;
- else if (v->pq < 13) v->tt_index = 1;
- else v->tt_index = 2;
-
- lowquant = (v->pq > 12) ? 0 : 1;
- v->mv_mode = ff_vc1_mv_pmode_table[lowquant][get_unary(gb, 1, 4)];
- if (v->mv_mode == MV_PMODE_INTENSITY_COMP) {
- int scale, shift, i;
- v->mv_mode2 = ff_vc1_mv_pmode_table2[lowquant][get_unary(gb, 1, 3)];
- v->lumscale = get_bits(gb, 6);
- v->lumshift = get_bits(gb, 6);
- v->use_ic = 1;
- /* fill lookup tables for intensity compensation */
- if (!v->lumscale) {
- scale = -64;
- shift = (255 - v->lumshift * 2) << 6;
- if (v->lumshift > 31)
- shift += 128 << 6;
- } else {
- scale = v->lumscale + 32;
- if (v->lumshift > 31)
- shift = (v->lumshift - 64) << 6;
- else
- shift = v->lumshift << 6;
- }
- for (i = 0; i < 256; i++) {
- v->luty[i] = av_clip_uint8((scale * i + shift + 32) >> 6);
- v->lutuv[i] = av_clip_uint8((scale * (i - 128) + 128*64 + 32) >> 6);
- }
- }
- v->qs_last = v->s.quarter_sample;
- if (v->mv_mode == MV_PMODE_1MV_HPEL || v->mv_mode == MV_PMODE_1MV_HPEL_BILIN)
- v->s.quarter_sample = 0;
- else if (v->mv_mode == MV_PMODE_INTENSITY_COMP) {
- if (v->mv_mode2 == MV_PMODE_1MV_HPEL || v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN)
- v->s.quarter_sample = 0;
- else
- v->s.quarter_sample = 1;
- } else
- v->s.quarter_sample = 1;
- v->s.mspel = !(v->mv_mode == MV_PMODE_1MV_HPEL_BILIN || (v->mv_mode == MV_PMODE_INTENSITY_COMP && v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN));
-
- if ((v->mv_mode == MV_PMODE_INTENSITY_COMP &&
- v->mv_mode2 == MV_PMODE_MIXED_MV) ||
- v->mv_mode == MV_PMODE_MIXED_MV) {
- status = bitplane_decoding(v->mv_type_mb_plane, &v->mv_type_is_raw, v);
- if (status < 0)
- return -1;
- av_log(v->s.avctx, AV_LOG_DEBUG, "MB MV Type plane encoding: "
- "Imode: %i, Invert: %i\n", status>>1, status&1);
- } else {
- v->mv_type_is_raw = 0;
- memset(v->mv_type_mb_plane, 0, v->s.mb_stride * v->s.mb_height);
- }
- status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v);
- if (status < 0)
- return -1;
- av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: "
- "Imode: %i, Invert: %i\n", status>>1, status&1);
-
- /* Hopefully this is correct for P frames */
- v->s.mv_table_index = get_bits(gb, 2); //but using ff_vc1_ tables
- v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)];
-
- if (v->dquant) {
- av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
- vop_dquant_decoding(v);
- }
-
- v->ttfrm = 0; //FIXME Is that so ?
- if (v->vstransform) {
- v->ttmbf = get_bits1(gb);
- if (v->ttmbf) {
- v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)];
- }
- } else {
- v->ttmbf = 1;
- v->ttfrm = TT_8X8;
- }
- break;
- case AV_PICTURE_TYPE_B:
- if (v->pq < 5) v->tt_index = 0;
- else if (v->pq < 13) v->tt_index = 1;
- else v->tt_index = 2;
-
- v->mv_mode = get_bits1(gb) ? MV_PMODE_1MV : MV_PMODE_1MV_HPEL_BILIN;
- v->qs_last = v->s.quarter_sample;
- v->s.quarter_sample = (v->mv_mode == MV_PMODE_1MV);
- v->s.mspel = v->s.quarter_sample;
-
- status = bitplane_decoding(v->direct_mb_plane, &v->dmb_is_raw, v);
- if (status < 0)
- return -1;
- av_log(v->s.avctx, AV_LOG_DEBUG, "MB Direct Type plane encoding: "
- "Imode: %i, Invert: %i\n", status>>1, status&1);
- status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v);
- if (status < 0)
- return -1;
- av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: "
- "Imode: %i, Invert: %i\n", status>>1, status&1);
-
- v->s.mv_table_index = get_bits(gb, 2);
- v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)];
-
- if (v->dquant) {
- av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
- vop_dquant_decoding(v);
- }
-
- v->ttfrm = 0;
- if (v->vstransform) {
- v->ttmbf = get_bits1(gb);
- if (v->ttmbf) {
- v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)];
- }
- } else {
- v->ttmbf = 1;
- v->ttfrm = TT_8X8;
- }
- break;
- }
-
- if (!v->x8_type) {
- /* AC Syntax */
- v->c_ac_table_index = decode012(gb);
- if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI) {
- v->y_ac_table_index = decode012(gb);
- }
- /* DC Syntax */
- v->s.dc_table_index = get_bits1(gb);
- }
-
- if (v->s.pict_type == AV_PICTURE_TYPE_BI) {
- v->s.pict_type = AV_PICTURE_TYPE_B;
- v->bi_type = 1;
- }
- return 0;
-}
-
-/* fill lookup tables for intensity compensation */
-#define INIT_LUT(lumscale, lumshift, luty, lutuv) \
- if (!lumscale) { \
- scale = -64; \
- shift = (255 - lumshift * 2) << 6; \
- if (lumshift > 31) \
- shift += 128 << 6; \
- } else { \
- scale = lumscale + 32; \
- if (lumshift > 31) \
- shift = (lumshift - 64) << 6; \
- else \
- shift = lumshift << 6; \
- } \
- for (i = 0; i < 256; i++) { \
- luty[i] = av_clip_uint8((scale * i + shift + 32) >> 6); \
- lutuv[i] = av_clip_uint8((scale * (i - 128) + 128*64 + 32) >> 6); \
- }
-
-int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
-{
- int pqindex, lowquant;
- int status;
- int mbmodetab, imvtab, icbptab, twomvbptab, fourmvbptab; /* useful only for debugging */
- int scale, shift, i; /* for initializing LUT for intensity compensation */
- int field_mode, fcm;
-
- v->numref=0;
- v->p_frame_skipped = 0;
- if (v->second_field) {
- if(v->fcm!=2 || v->field_mode!=1)
- return -1;
- 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;
- if (!v->pic_header_flag)
- goto parse_common_info;
- }
-
- field_mode = 0;
- if (v->interlace) {
- fcm = decode012(gb);
- if (fcm) {
- if (fcm == ILACE_FIELD)
- field_mode = 1;
- if (!v->warn_interlaced++)
- av_log(v->s.avctx, AV_LOG_ERROR,
- "Interlaced frames/fields support is incomplete\n");
- }
- } else {
- fcm = PROGRESSIVE;
- }
- if (!v->first_pic_header_flag && v->field_mode != field_mode)
- return -1;
- v->field_mode = field_mode;
- v->fcm = fcm;
-
- if (v->field_mode) {
- 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 {
- switch (get_unary(gb, 0, 4)) {
- case 0:
- v->s.pict_type = AV_PICTURE_TYPE_P;
- break;
- case 1:
- v->s.pict_type = AV_PICTURE_TYPE_B;
- break;
- case 2:
- v->s.pict_type = AV_PICTURE_TYPE_I;
- break;
- case 3:
- v->s.pict_type = AV_PICTURE_TYPE_BI;
- break;
- case 4:
- v->s.pict_type = AV_PICTURE_TYPE_P; // skipped pic
- v->p_frame_skipped = 1;
- break;
- }
- }
- if (v->tfcntrflag)
- skip_bits(gb, 8);
- if (v->broadcast) {
- if (!v->interlace || v->psf) {
- v->rptfrm = get_bits(gb, 2);
- } else {
- v->tff = get_bits1(gb);
- v->rff = get_bits1(gb);
- }
- }
- if (v->panscanflag) {
- av_log_missing_feature(v->s.avctx, "Pan-scan", 0);
- //...
- }
- if (v->p_frame_skipped) {
- return 0;
- }
- v->rnd = get_bits1(gb);
- if (v->interlace)
- v->uvsamp = get_bits1(gb);
- if(!ff_vc1_bfraction_vlc.table)
- return 0; //parsing only, vlc tables havnt been allocated
- if (v->field_mode) {
- if (!v->refdist_flag)
- v->refdist = 0;
- else if ((v->s.pict_type != AV_PICTURE_TYPE_B) && (v->s.pict_type != AV_PICTURE_TYPE_BI)) {
- v->refdist = get_bits(gb, 2);
- if (v->refdist == 3)
- 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];
- v->frfd = (v->bfraction * v->refdist) >> 8;
- v->brfd = v->refdist - v->frfd - 1;
- if (v->brfd < 0)
- v->brfd = 0;
- }
- goto parse_common_info;
- }
- if (v->fcm == PROGRESSIVE) {
- 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 (v->bfraction == 0) {
- v->s.pict_type = AV_PICTURE_TYPE_BI; /* XXX: should not happen here */
- }
- }
- }
-
- parse_common_info:
- if (v->field_mode)
- v->cur_field_type = !(v->tff ^ v->second_field);
- pqindex = get_bits(gb, 5);
- if (!pqindex)
- return -1;
- v->pqindex = pqindex;
- if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)
- v->pq = ff_vc1_pquant_table[0][pqindex];
- else
- v->pq = ff_vc1_pquant_table[1][pqindex];
-
- v->pquantizer = 1;
- if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)
- v->pquantizer = pqindex < 9;
- if (v->quantizer_mode == QUANT_NON_UNIFORM)
- v->pquantizer = 0;
- v->pqindex = pqindex;
- if (pqindex < 9)
- v->halfpq = get_bits1(gb);
- else
- v->halfpq = 0;
- if (v->quantizer_mode == QUANT_FRAME_EXPLICIT)
- v->pquantizer = get_bits1(gb);
- if (v->postprocflag)
- v->postproc = get_bits(gb, 2);
-
- if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_P)
- v->use_ic = 0;
-
- if (v->parse_only)
- return 0;
-
- switch (v->s.pict_type) {
- case AV_PICTURE_TYPE_I:
- case AV_PICTURE_TYPE_BI:
- if (v->fcm == ILACE_FRAME) { //interlace frame picture
- status = bitplane_decoding(v->fieldtx_plane, &v->fieldtx_is_raw, v);
- if (status < 0)
- return -1;
- av_log(v->s.avctx, AV_LOG_DEBUG, "FIELDTX plane encoding: "
- "Imode: %i, Invert: %i\n", status>>1, status&1);
- }
- status = bitplane_decoding(v->acpred_plane, &v->acpred_is_raw, v);
- if (status < 0)
- return -1;
- av_log(v->s.avctx, AV_LOG_DEBUG, "ACPRED plane encoding: "
- "Imode: %i, Invert: %i\n", status>>1, status&1);
- v->condover = CONDOVER_NONE;
- if (v->overlap && v->pq <= 8) {
- v->condover = decode012(gb);
- if (v->condover == CONDOVER_SELECT) {
- status = bitplane_decoding(v->over_flags_plane, &v->overflg_is_raw, v);
- if (status < 0)
- return -1;
- av_log(v->s.avctx, AV_LOG_DEBUG, "CONDOVER plane encoding: "
- "Imode: %i, Invert: %i\n", status>>1, status&1);
- }
- }
- break;
- case AV_PICTURE_TYPE_P:
- if (v->field_mode) {
- v->numref = get_bits1(gb);
- if (!v->numref) {
- v->reffield = get_bits1(gb);
- v->ref_field_type[0] = v->reffield ^ !v->cur_field_type;
- }
- }
- if (v->extended_mv)
- v->mvrange = get_unary(gb, 0, 3);
- else
- v->mvrange = 0;
- if (v->interlace) {
- if (v->extended_dmv)
- v->dmvrange = get_unary(gb, 0, 3);
- else
- v->dmvrange = 0;
- if (v->fcm == ILACE_FRAME) { // interlaced frame picture
- v->fourmvswitch = get_bits1(gb);
- v->intcomp = get_bits1(gb);
- if (v->intcomp) {
- v->lumscale = get_bits(gb, 6);
- v->lumshift = get_bits(gb, 6);
- INIT_LUT(v->lumscale, v->lumshift, v->luty, v->lutuv);
- }
- status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v);
- av_log(v->s.avctx, AV_LOG_DEBUG, "SKIPMB plane encoding: "
- "Imode: %i, Invert: %i\n", status>>1, status&1);
- mbmodetab = get_bits(gb, 2);
- if (v->fourmvswitch)
- v->mbmode_vlc = &ff_vc1_intfr_4mv_mbmode_vlc[mbmodetab];
- else
- v->mbmode_vlc = &ff_vc1_intfr_non4mv_mbmode_vlc[mbmodetab];
- imvtab = get_bits(gb, 2);
- v->imv_vlc = &ff_vc1_1ref_mvdata_vlc[imvtab];
- // interlaced p-picture cbpcy range is [1, 63]
- icbptab = get_bits(gb, 3);
- v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[icbptab];
- twomvbptab = get_bits(gb, 2);
- v->twomvbp_vlc = &ff_vc1_2mv_block_pattern_vlc[twomvbptab];
- if (v->fourmvswitch) {
- fourmvbptab = get_bits(gb, 2);
- v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab];
- }
- }
- }
- v->k_x = v->mvrange + 9 + (v->mvrange >> 1); //k_x can be 9 10 12 13
- v->k_y = v->mvrange + 8; //k_y can be 8 9 10 11
- v->range_x = 1 << (v->k_x - 1);
- v->range_y = 1 << (v->k_y - 1);
-
- if (v->pq < 5)
- v->tt_index = 0;
- else if (v->pq < 13)
- v->tt_index = 1;
- else
- v->tt_index = 2;
- if (v->fcm != ILACE_FRAME) {
- int mvmode;
- mvmode = get_unary(gb, 1, 4);
- lowquant = (v->pq > 12) ? 0 : 1;
- v->mv_mode = ff_vc1_mv_pmode_table[lowquant][mvmode];
- if (v->mv_mode == MV_PMODE_INTENSITY_COMP) {
- int mvmode2;
- mvmode2 = get_unary(gb, 1, 3);
- v->mv_mode2 = ff_vc1_mv_pmode_table2[lowquant][mvmode2];
- if (v->field_mode)
- v->intcompfield = decode210(gb);
- v->lumscale = get_bits(gb, 6);
- v->lumshift = get_bits(gb, 6);
- INIT_LUT(v->lumscale, v->lumshift, v->luty, v->lutuv);
- if ((v->field_mode) && !v->intcompfield) {
- v->lumscale2 = get_bits(gb, 6);
- v->lumshift2 = get_bits(gb, 6);
- INIT_LUT(v->lumscale2, v->lumshift2, v->luty2, v->lutuv2);
- }
- v->use_ic = 1;
- }
- v->qs_last = v->s.quarter_sample;
- if (v->mv_mode == MV_PMODE_1MV_HPEL || v->mv_mode == MV_PMODE_1MV_HPEL_BILIN)
- v->s.quarter_sample = 0;
- else if (v->mv_mode == MV_PMODE_INTENSITY_COMP) {
- if (v->mv_mode2 == MV_PMODE_1MV_HPEL || v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN)
- v->s.quarter_sample = 0;
- else
- v->s.quarter_sample = 1;
- } else
- v->s.quarter_sample = 1;
- v->s.mspel = !(v->mv_mode == MV_PMODE_1MV_HPEL_BILIN
- || (v->mv_mode == MV_PMODE_INTENSITY_COMP
- && v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN));
- }
- if (v->fcm == PROGRESSIVE) { // progressive
- if ((v->mv_mode == MV_PMODE_INTENSITY_COMP &&
- v->mv_mode2 == MV_PMODE_MIXED_MV)
- || v->mv_mode == MV_PMODE_MIXED_MV) {
- status = bitplane_decoding(v->mv_type_mb_plane, &v->mv_type_is_raw, v);
- if (status < 0)
- return -1;
- av_log(v->s.avctx, AV_LOG_DEBUG, "MB MV Type plane encoding: "
- "Imode: %i, Invert: %i\n", status>>1, status&1);
- } else {
- v->mv_type_is_raw = 0;
- memset(v->mv_type_mb_plane, 0, v->s.mb_stride * v->s.mb_height);
- }
- status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v);
- if (status < 0)
- return -1;
- av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: "
- "Imode: %i, Invert: %i\n", status>>1, status&1);
-
- /* Hopefully this is correct for P frames */
- v->s.mv_table_index = get_bits(gb, 2); //but using ff_vc1_ tables
- v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)];
- } else if (v->fcm == ILACE_FRAME) { // frame interlaced
- v->qs_last = v->s.quarter_sample;
- v->s.quarter_sample = 1;
- v->s.mspel = 1;
- } else { // field interlaced
- mbmodetab = get_bits(gb, 3);
- imvtab = get_bits(gb, 2 + v->numref);
- if (!v->numref)
- v->imv_vlc = &ff_vc1_1ref_mvdata_vlc[imvtab];
- else
- v->imv_vlc = &ff_vc1_2ref_mvdata_vlc[imvtab];
- icbptab = get_bits(gb, 3);
- v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[icbptab];
- if ((v->mv_mode == MV_PMODE_INTENSITY_COMP &&
- v->mv_mode2 == MV_PMODE_MIXED_MV) || v->mv_mode == MV_PMODE_MIXED_MV) {
- fourmvbptab = get_bits(gb, 2);
- v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab];
- v->mbmode_vlc = &ff_vc1_if_mmv_mbmode_vlc[mbmodetab];
- } else {
- v->mbmode_vlc = &ff_vc1_if_1mv_mbmode_vlc[mbmodetab];
- }
- }
- if (v->dquant) {
- av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
- vop_dquant_decoding(v);
- }
-
- v->ttfrm = 0; //FIXME Is that so ?
- if (v->vstransform) {
- v->ttmbf = get_bits1(gb);
- if (v->ttmbf) {
- v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)];
- }
- } else {
- v->ttmbf = 1;
- v->ttfrm = TT_8X8;
- }
- 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 (v->bfraction == 0) {
- return -1;
- }
- }
- if (v->extended_mv)
- v->mvrange = get_unary(gb, 0, 3);
- else
- v->mvrange = 0;
- v->k_x = v->mvrange + 9 + (v->mvrange >> 1); //k_x can be 9 10 12 13
- v->k_y = v->mvrange + 8; //k_y can be 8 9 10 11
- v->range_x = 1 << (v->k_x - 1);
- v->range_y = 1 << (v->k_y - 1);
-
- if (v->pq < 5)
- v->tt_index = 0;
- else if (v->pq < 13)
- v->tt_index = 1;
- else
- v->tt_index = 2;
-
- if (v->field_mode) {
- int mvmode;
- av_log(v->s.avctx, AV_LOG_DEBUG, "B Fields\n");
- if (v->extended_dmv)
- v->dmvrange = get_unary(gb, 0, 3);
- mvmode = get_unary(gb, 1, 3);
- lowquant = (v->pq > 12) ? 0 : 1;
- v->mv_mode = ff_vc1_mv_pmode_table2[lowquant][mvmode];
- v->qs_last = v->s.quarter_sample;
- v->s.quarter_sample = (v->mv_mode == MV_PMODE_1MV || v->mv_mode == MV_PMODE_MIXED_MV);
- v->s.mspel = !(v->mv_mode == MV_PMODE_1MV_HPEL_BILIN || v->mv_mode == MV_PMODE_1MV_HPEL);
- status = bitplane_decoding(v->forward_mb_plane, &v->fmb_is_raw, v);
- if (status < 0)
- return -1;
- av_log(v->s.avctx, AV_LOG_DEBUG, "MB Forward Type plane encoding: "
- "Imode: %i, Invert: %i\n", status>>1, status&1);
- mbmodetab = get_bits(gb, 3);
- if (v->mv_mode == MV_PMODE_MIXED_MV)
- v->mbmode_vlc = &ff_vc1_if_mmv_mbmode_vlc[mbmodetab];
- else
- v->mbmode_vlc = &ff_vc1_if_1mv_mbmode_vlc[mbmodetab];
- imvtab = get_bits(gb, 3);
- v->imv_vlc = &ff_vc1_2ref_mvdata_vlc[imvtab];
- icbptab = get_bits(gb, 3);
- v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[icbptab];
- if (v->mv_mode == MV_PMODE_MIXED_MV) {
- fourmvbptab = get_bits(gb, 2);
- v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab];
- }
- v->numref = 1; // interlaced field B pictures are always 2-ref
- } else if (v->fcm == ILACE_FRAME) {
- if (v->extended_dmv)
- v->dmvrange = get_unary(gb, 0, 3);
- get_bits1(gb); /* intcomp - present but shall always be 0 */
- v->intcomp = 0;
- v->mv_mode = MV_PMODE_1MV;
- v->fourmvswitch = 0;
- v->qs_last = v->s.quarter_sample;
- v->s.quarter_sample = 1;
- v->s.mspel = 1;
- status = bitplane_decoding(v->direct_mb_plane, &v->dmb_is_raw, v);
- if (status < 0)
- return -1;
- av_log(v->s.avctx, AV_LOG_DEBUG, "MB Direct Type plane encoding: "
- "Imode: %i, Invert: %i\n", status>>1, status&1);
- status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v);
- if (status < 0)
- return -1;
- av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: "
- "Imode: %i, Invert: %i\n", status>>1, status&1);
- mbmodetab = get_bits(gb, 2);
- v->mbmode_vlc = &ff_vc1_intfr_non4mv_mbmode_vlc[mbmodetab];
- imvtab = get_bits(gb, 2);
- v->imv_vlc = &ff_vc1_1ref_mvdata_vlc[imvtab];
- // interlaced p/b-picture cbpcy range is [1, 63]
- icbptab = get_bits(gb, 3);
- v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[icbptab];
- twomvbptab = get_bits(gb, 2);
- v->twomvbp_vlc = &ff_vc1_2mv_block_pattern_vlc[twomvbptab];
- fourmvbptab = get_bits(gb, 2);
- v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab];
- } else {
- v->mv_mode = get_bits1(gb) ? MV_PMODE_1MV : MV_PMODE_1MV_HPEL_BILIN;
- v->qs_last = v->s.quarter_sample;
- v->s.quarter_sample = (v->mv_mode == MV_PMODE_1MV);
- v->s.mspel = v->s.quarter_sample;
- status = bitplane_decoding(v->direct_mb_plane, &v->dmb_is_raw, v);
- if (status < 0)
- return -1;
- av_log(v->s.avctx, AV_LOG_DEBUG, "MB Direct Type plane encoding: "
- "Imode: %i, Invert: %i\n", status>>1, status&1);
- status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v);
- if (status < 0)
- return -1;
- av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: "
- "Imode: %i, Invert: %i\n", status>>1, status&1);
- v->s.mv_table_index = get_bits(gb, 2);
- v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)];
- }
-
- if (v->dquant) {
- av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
- vop_dquant_decoding(v);
- }
-
- v->ttfrm = 0;
- if (v->vstransform) {
- v->ttmbf = get_bits1(gb);
- if (v->ttmbf) {
- v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)];
- }
- } else {
- v->ttmbf = 1;
- v->ttfrm = TT_8X8;
- }
- break;
- }
-
- if (v->fcm != PROGRESSIVE && !v->s.quarter_sample) {
- v->range_x <<= 1;
- v->range_y <<= 1;
- }
-
- /* AC Syntax */
- v->c_ac_table_index = decode012(gb);
- if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI) {
- v->y_ac_table_index = decode012(gb);
- }
- /* DC Syntax */
- v->s.dc_table_index = get_bits1(gb);
- if ((v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI)
- && v->dquant) {
- av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n");
- vop_dquant_decoding(v);
- }
-
- v->bi_type = 0;
- if (v->s.pict_type == AV_PICTURE_TYPE_BI) {
- v->s.pict_type = AV_PICTURE_TYPE_B;
- v->bi_type = 1;
- }
- return 0;
-}
-
-static const uint32_t vc1_ac_tables[AC_MODES][186][2] = {
-{
-{ 0x0001, 2}, { 0x0005, 3}, { 0x000D, 4}, { 0x0012, 5}, { 0x000E, 6}, { 0x0015, 7},
-{ 0x0013, 8}, { 0x003F, 8}, { 0x004B, 9}, { 0x011F, 9}, { 0x00B8, 10}, { 0x03E3, 10},
-{ 0x0172, 11}, { 0x024D, 12}, { 0x03DA, 12}, { 0x02DD, 13}, { 0x1F55, 13}, { 0x05B9, 14},
-{ 0x3EAE, 14}, { 0x0000, 4}, { 0x0010, 5}, { 0x0008, 7}, { 0x0020, 8}, { 0x0029, 9},
-{ 0x01F4, 9}, { 0x0233, 10}, { 0x01E0, 11}, { 0x012A, 12}, { 0x03DD, 12}, { 0x050A, 13},
-{ 0x1F29, 13}, { 0x0A42, 14}, { 0x1272, 15}, { 0x1737, 15}, { 0x0003, 5}, { 0x0011, 7},
-{ 0x00C4, 8}, { 0x004B, 10}, { 0x00B4, 11}, { 0x07D4, 11}, { 0x0345, 12}, { 0x02D7, 13},
-{ 0x07BF, 13}, { 0x0938, 14}, { 0x0BBB, 14}, { 0x095E, 15}, { 0x0013, 5}, { 0x0078, 7},
-{ 0x0069, 9}, { 0x0232, 10}, { 0x0461, 11}, { 0x03EC, 12}, { 0x0520, 13}, { 0x1F2A, 13},
-{ 0x3E50, 14}, { 0x3E51, 14}, { 0x1486, 15}, { 0x000C, 6}, { 0x0024, 9}, { 0x0094, 11},
-{ 0x08C0, 12}, { 0x0F09, 14}, { 0x1EF0, 15}, { 0x003D, 6}, { 0x0053, 9}, { 0x01A0, 11},
-{ 0x02D6, 13}, { 0x0F08, 14}, { 0x0013, 7}, { 0x007C, 9}, { 0x07C1, 11}, { 0x04AC, 14},
-{ 0x001B, 7}, { 0x00A0, 10}, { 0x0344, 12}, { 0x0F79, 14}, { 0x0079, 7}, { 0x03E1, 10},
-{ 0x02D4, 13}, { 0x2306, 14}, { 0x0021, 8}, { 0x023C, 10}, { 0x0FAE, 12}, { 0x23DE, 14},
-{ 0x0035, 8}, { 0x0175, 11}, { 0x07B3, 13}, { 0x00C5, 8}, { 0x0174, 11}, { 0x0785, 13},
-{ 0x0048, 9}, { 0x01A3, 11}, { 0x049E, 13}, { 0x002C, 9}, { 0x00FA, 10}, { 0x07D6, 11},
-{ 0x0092, 10}, { 0x05CC, 13}, { 0x1EF1, 15}, { 0x00A3, 10}, { 0x03ED, 12}, { 0x093E, 14},
-{ 0x01E2, 11}, { 0x1273, 15}, { 0x07C4, 11}, { 0x1487, 15}, { 0x0291, 12}, { 0x0293, 12},
-{ 0x0F8A, 12}, { 0x0509, 13}, { 0x0508, 13}, { 0x078D, 13}, { 0x07BE, 13}, { 0x078C, 13},
-{ 0x04AE, 14}, { 0x0BBA, 14}, { 0x2307, 14}, { 0x0B9A, 14}, { 0x1736, 15}, { 0x000E, 4},
-{ 0x0045, 7}, { 0x01F3, 9}, { 0x047A, 11}, { 0x05DC, 13}, { 0x23DF, 14}, { 0x0019, 5},
-{ 0x0028, 9}, { 0x0176, 11}, { 0x049D, 13}, { 0x23DD, 14}, { 0x0030, 6}, { 0x00A2, 10},
-{ 0x02EF, 12}, { 0x05B8, 14}, { 0x003F, 6}, { 0x00A5, 10}, { 0x03DB, 12}, { 0x093F, 14},
-{ 0x0044, 7}, { 0x07CB, 11}, { 0x095F, 15}, { 0x0063, 7}, { 0x03C3, 12}, { 0x0015, 8},
-{ 0x08F6, 12}, { 0x0017, 8}, { 0x0498, 13}, { 0x002C, 8}, { 0x07B2, 13}, { 0x002F, 8},
-{ 0x1F54, 13}, { 0x008D, 8}, { 0x07BD, 13}, { 0x008E, 8}, { 0x1182, 13}, { 0x00FB, 8},
-{ 0x050B, 13}, { 0x002D, 8}, { 0x07C0, 11}, { 0x0079, 9}, { 0x1F5F, 13}, { 0x007A, 9},
-{ 0x1F56, 13}, { 0x0231, 10}, { 0x03E4, 10}, { 0x01A1, 11}, { 0x0143, 11}, { 0x01F7, 11},
-{ 0x016F, 12}, { 0x0292, 12}, { 0x02E7, 12}, { 0x016C, 12}, { 0x016D, 12}, { 0x03DC, 12},
-{ 0x0F8B, 12}, { 0x0499, 13}, { 0x03D8, 12}, { 0x078E, 13}, { 0x02D5, 13}, { 0x1F5E, 13},
-{ 0x1F2B, 13}, { 0x078F, 13}, { 0x04AD, 14}, { 0x3EAF, 14}, { 0x23DC, 14}, { 0x004A, 9}
-},
-{
-{ 0x0000, 3}, { 0x0003, 4}, { 0x000B, 5}, { 0x0014, 6}, { 0x003F, 6}, { 0x005D, 7},
-{ 0x00A2, 8}, { 0x00AC, 9}, { 0x016E, 9}, { 0x020A, 10}, { 0x02E2, 10}, { 0x0432, 11},
-{ 0x05C9, 11}, { 0x0827, 12}, { 0x0B54, 12}, { 0x04E6, 13}, { 0x105F, 13}, { 0x172A, 13},
-{ 0x20B2, 14}, { 0x2D4E, 14}, { 0x39F0, 14}, { 0x4175, 15}, { 0x5A9E, 15}, { 0x0004, 4},
-{ 0x001E, 5}, { 0x0042, 7}, { 0x00B6, 8}, { 0x0173, 9}, { 0x0395, 10}, { 0x072E, 11},
-{ 0x0B94, 12}, { 0x16A4, 13}, { 0x20B3, 14}, { 0x2E45, 14}, { 0x0005, 5}, { 0x0040, 7},
-{ 0x0049, 9}, { 0x028F, 10}, { 0x05CB, 11}, { 0x048A, 13}, { 0x09DD, 14}, { 0x73E2, 15},
-{ 0x0018, 5}, { 0x0025, 8}, { 0x008A, 10}, { 0x051B, 11}, { 0x0E5F, 12}, { 0x09C9, 14},
-{ 0x139C, 15}, { 0x0029, 6}, { 0x004F, 9}, { 0x0412, 11}, { 0x048D, 13}, { 0x2E41, 14},
-{ 0x0038, 6}, { 0x010E, 9}, { 0x05A8, 11}, { 0x105C, 13}, { 0x39F2, 14}, { 0x0058, 7},
-{ 0x021F, 10}, { 0x0E7E, 12}, { 0x39FF, 14}, { 0x0023, 8}, { 0x02E3, 10}, { 0x04E5, 13},
-{ 0x2E40, 14}, { 0x00A1, 8}, { 0x05BE, 11}, { 0x09C8, 14}, { 0x0083, 8}, { 0x013A, 11},
-{ 0x1721, 13}, { 0x0044, 9}, { 0x0276, 12}, { 0x39F6, 14}, { 0x008B, 10}, { 0x04EF, 13},
-{ 0x5A9B, 15}, { 0x0208, 10}, { 0x1CFE, 13}, { 0x0399, 10}, { 0x1CB4, 13}, { 0x039E, 10},
-{ 0x39F3, 14}, { 0x05AB, 11}, { 0x73E3, 15}, { 0x0737, 11}, { 0x5A9F, 15}, { 0x082D, 12},
-{ 0x0E69, 12}, { 0x0E68, 12}, { 0x0433, 11}, { 0x0B7B, 12}, { 0x2DF8, 14}, { 0x2E56, 14},
-{ 0x2E57, 14}, { 0x39F7, 14}, { 0x51A5, 15}, { 0x0003, 3}, { 0x002A, 6}, { 0x00E4, 8},
-{ 0x028E, 10}, { 0x0735, 11}, { 0x1058, 13}, { 0x1CFA, 13}, { 0x2DF9, 14}, { 0x4174, 15},
-{ 0x0009, 4}, { 0x0054, 8}, { 0x0398, 10}, { 0x048B, 13}, { 0x139D, 15}, { 0x000D, 4},
-{ 0x00AD, 9}, { 0x0826, 12}, { 0x2D4C, 14}, { 0x0011, 5}, { 0x016B, 9}, { 0x0B7F, 12},
-{ 0x51A4, 15}, { 0x0019, 5}, { 0x021B, 10}, { 0x16FD, 13}, { 0x001D, 5}, { 0x0394, 10},
-{ 0x28D3, 14}, { 0x002B, 6}, { 0x05BC, 11}, { 0x5A9A, 15}, { 0x002F, 6}, { 0x0247, 12},
-{ 0x0010, 7}, { 0x0A35, 12}, { 0x003E, 6}, { 0x0B7A, 12}, { 0x0059, 7}, { 0x105E, 13},
-{ 0x0026, 8}, { 0x09CF, 14}, { 0x0055, 8}, { 0x1CB5, 13}, { 0x0057, 8}, { 0x0E5B, 12},
-{ 0x00A0, 8}, { 0x1468, 13}, { 0x0170, 9}, { 0x0090, 10}, { 0x01CE, 9}, { 0x021A, 10},
-{ 0x0218, 10}, { 0x0168, 9}, { 0x021E, 10}, { 0x0244, 12}, { 0x0736, 11}, { 0x0138, 11},
-{ 0x0519, 11}, { 0x0E5E, 12}, { 0x072C, 11}, { 0x0B55, 12}, { 0x09DC, 14}, { 0x20BB, 14},
-{ 0x048C, 13}, { 0x1723, 13}, { 0x2E44, 14}, { 0x16A5, 13}, { 0x0518, 11}, { 0x39FE, 14},
-{ 0x0169, 9}
-},
-{
-{ 0x0001, 2}, { 0x0006, 3}, { 0x000F, 4}, { 0x0016, 5}, { 0x0020, 6}, { 0x0018, 7},
-{ 0x0008, 8}, { 0x009A, 8}, { 0x0056, 9}, { 0x013E, 9}, { 0x00F0, 10}, { 0x03A5, 10},
-{ 0x0077, 11}, { 0x01EF, 11}, { 0x009A, 12}, { 0x005D, 13}, { 0x0001, 4}, { 0x0011, 5},
-{ 0x0002, 7}, { 0x000B, 8}, { 0x0012, 9}, { 0x01D6, 9}, { 0x027E, 10}, { 0x0191, 11},
-{ 0x00EA, 12}, { 0x03DC, 12}, { 0x013B, 13}, { 0x0004, 5}, { 0x0014, 7}, { 0x009E, 8},
-{ 0x0009, 10}, { 0x01AC, 11}, { 0x01E2, 11}, { 0x03CA, 12}, { 0x005F, 13}, { 0x0017, 5},
-{ 0x004E, 7}, { 0x005E, 9}, { 0x00F3, 10}, { 0x01AD, 11}, { 0x00EC, 12}, { 0x05F0, 13},
-{ 0x000E, 6}, { 0x00E1, 8}, { 0x03A4, 10}, { 0x009C, 12}, { 0x013D, 13}, { 0x003B, 6},
-{ 0x001C, 9}, { 0x0014, 11}, { 0x09BE, 12}, { 0x0006, 7}, { 0x007A, 9}, { 0x0190, 11},
-{ 0x0137, 13}, { 0x001B, 7}, { 0x0008, 10}, { 0x075C, 11}, { 0x0071, 7}, { 0x00D7, 10},
-{ 0x09BF, 12}, { 0x0007, 8}, { 0x00AF, 10}, { 0x04CC, 11}, { 0x0034, 8}, { 0x0265, 10},
-{ 0x009F, 12}, { 0x00E0, 8}, { 0x0016, 11}, { 0x0327, 12}, { 0x0015, 9}, { 0x017D, 11},
-{ 0x0EBB, 12}, { 0x0014, 9}, { 0x00F6, 10}, { 0x01E4, 11}, { 0x00CB, 10}, { 0x099D, 12},
-{ 0x00CA, 10}, { 0x02FC, 12}, { 0x017F, 11}, { 0x04CD, 11}, { 0x02FD, 12}, { 0x04FE, 11},
-{ 0x013A, 13}, { 0x000A, 4}, { 0x0042, 7}, { 0x01D3, 9}, { 0x04DD, 11}, { 0x0012, 5},
-{ 0x00E8, 8}, { 0x004C, 11}, { 0x0136, 13}, { 0x0039, 6}, { 0x0264, 10}, { 0x0EBA, 12},
-{ 0x0000, 7}, { 0x00AE, 10}, { 0x099C, 12}, { 0x001F, 7}, { 0x04DE, 11}, { 0x0043, 7},
-{ 0x04DC, 11}, { 0x0003, 8}, { 0x03CB, 12}, { 0x0006, 8}, { 0x099E, 12}, { 0x002A, 8},
-{ 0x05F1, 13}, { 0x000F, 8}, { 0x09FE, 12}, { 0x0033, 8}, { 0x09FF, 12}, { 0x0098, 8},
-{ 0x099F, 12}, { 0x00EA, 8}, { 0x013C, 13}, { 0x002E, 8}, { 0x0192, 11}, { 0x0136, 9},
-{ 0x006A, 9}, { 0x0015, 11}, { 0x03AF, 10}, { 0x01E3, 11}, { 0x0074, 11}, { 0x00EB, 12},
-{ 0x02F9, 12}, { 0x005C, 13}, { 0x00ED, 12}, { 0x03DD, 12}, { 0x0326, 12}, { 0x005E, 13},
-{ 0x0016, 7}
-},
-{
-{ 0x0004, 3}, { 0x0014, 5}, { 0x0017, 7}, { 0x007F, 8}, { 0x0154, 9}, { 0x01F2, 10},
-{ 0x00BF, 11}, { 0x0065, 12}, { 0x0AAA, 12}, { 0x0630, 13}, { 0x1597, 13}, { 0x03B7, 14},
-{ 0x2B22, 14}, { 0x0BE6, 15}, { 0x000B, 4}, { 0x0037, 7}, { 0x0062, 9}, { 0x0007, 11},
-{ 0x0166, 12}, { 0x00CE, 13}, { 0x1590, 13}, { 0x05F6, 14}, { 0x0BE7, 15}, { 0x0007, 5},
-{ 0x006D, 8}, { 0x0003, 11}, { 0x031F, 12}, { 0x05F2, 14}, { 0x0002, 6}, { 0x0061, 9},
-{ 0x0055, 12}, { 0x01DF, 14}, { 0x001A, 6}, { 0x001E, 10}, { 0x0AC9, 12}, { 0x2B23, 14},
-{ 0x001E, 6}, { 0x001F, 10}, { 0x0AC3, 12}, { 0x2B2B, 14}, { 0x0006, 7}, { 0x0004, 11},
-{ 0x02F8, 13}, { 0x0019, 7}, { 0x0006, 11}, { 0x063D, 13}, { 0x0057, 7}, { 0x0182, 11},
-{ 0x2AA2, 14}, { 0x0004, 8}, { 0x0180, 11}, { 0x059C, 14}, { 0x007D, 8}, { 0x0164, 12},
-{ 0x076D, 15}, { 0x0002, 9}, { 0x018D, 11}, { 0x1581, 13}, { 0x00AD, 8}, { 0x0060, 12},
-{ 0x0C67, 14}, { 0x001C, 9}, { 0x00EE, 13}, { 0x0003, 9}, { 0x02CF, 13}, { 0x00D9, 9},
-{ 0x1580, 13}, { 0x0002, 11}, { 0x0183, 11}, { 0x0057, 12}, { 0x0061, 12}, { 0x0031, 11},
-{ 0x0066, 12}, { 0x0631, 13}, { 0x0632, 13}, { 0x00AC, 13}, { 0x031D, 12}, { 0x0076, 12},
-{ 0x003A, 11}, { 0x0165, 12}, { 0x0C66, 14}, { 0x0003, 2}, { 0x0054, 7}, { 0x02AB, 10},
-{ 0x0016, 13}, { 0x05F7, 14}, { 0x0005, 4}, { 0x00F8, 9}, { 0x0AA9, 12}, { 0x005F, 15},
-{ 0x0004, 4}, { 0x001C, 10}, { 0x1550, 13}, { 0x0004, 5}, { 0x0077, 11}, { 0x076C, 15},
-{ 0x000E, 5}, { 0x000A, 12}, { 0x000C, 5}, { 0x0562, 11}, { 0x0004, 6}, { 0x031C, 12},
-{ 0x0006, 6}, { 0x00C8, 13}, { 0x000D, 6}, { 0x01DA, 13}, { 0x0007, 6}, { 0x00C9, 13},
-{ 0x0001, 7}, { 0x002E, 14}, { 0x0014, 7}, { 0x1596, 13}, { 0x000A, 7}, { 0x0AC2, 12},
-{ 0x0016, 7}, { 0x015B, 14}, { 0x0015, 7}, { 0x015A, 14}, { 0x000F, 8}, { 0x005E, 15},
-{ 0x007E, 8}, { 0x00AB, 8}, { 0x002D, 9}, { 0x00D8, 9}, { 0x000B, 9}, { 0x0014, 10},
-{ 0x02B3, 10}, { 0x01F3, 10}, { 0x003A, 10}, { 0x0000, 10}, { 0x0058, 10}, { 0x002E, 9},
-{ 0x005E, 10}, { 0x0563, 11}, { 0x00EC, 12}, { 0x0054, 12}, { 0x0AC1, 12}, { 0x1556, 13},
-{ 0x02FA, 13}, { 0x0181, 11}, { 0x1557, 13}, { 0x059D, 14}, { 0x2AA3, 14}, { 0x2B2A, 14},
-{ 0x01DE, 14}, { 0x063C, 13}, { 0x00CF, 13}, { 0x1594, 13}, { 0x000D, 9}
-},
-{
-{ 0x0002, 2}, { 0x0006, 3}, { 0x000F, 4}, { 0x000D, 5}, { 0x000C, 5}, { 0x0015, 6},
-{ 0x0013, 6}, { 0x0012, 6}, { 0x0017, 7}, { 0x001F, 8}, { 0x001E, 8}, { 0x001D, 8},
-{ 0x0025, 9}, { 0x0024, 9}, { 0x0023, 9}, { 0x0021, 9}, { 0x0021, 10}, { 0x0020, 10},
-{ 0x000F, 10}, { 0x000E, 10}, { 0x0007, 11}, { 0x0006, 11}, { 0x0020, 11}, { 0x0021, 11},
-{ 0x0050, 12}, { 0x0051, 12}, { 0x0052, 12}, { 0x000E, 4}, { 0x0014, 6}, { 0x0016, 7},
-{ 0x001C, 8}, { 0x0020, 9}, { 0x001F, 9}, { 0x000D, 10}, { 0x0022, 11}, { 0x0053, 12},
-{ 0x0055, 12}, { 0x000B, 5}, { 0x0015, 7}, { 0x001E, 9}, { 0x000C, 10}, { 0x0056, 12},
-{ 0x0011, 6}, { 0x001B, 8}, { 0x001D, 9}, { 0x000B, 10}, { 0x0010, 6}, { 0x0022, 9},
-{ 0x000A, 10}, { 0x000D, 6}, { 0x001C, 9}, { 0x0008, 10}, { 0x0012, 7}, { 0x001B, 9},
-{ 0x0054, 12}, { 0x0014, 7}, { 0x001A, 9}, { 0x0057, 12}, { 0x0019, 8}, { 0x0009, 10},
-{ 0x0018, 8}, { 0x0023, 11}, { 0x0017, 8}, { 0x0019, 9}, { 0x0018, 9}, { 0x0007, 10},
-{ 0x0058, 12}, { 0x0007, 4}, { 0x000C, 6}, { 0x0016, 8}, { 0x0017, 9}, { 0x0006, 10},
-{ 0x0005, 11}, { 0x0004, 11}, { 0x0059, 12}, { 0x000F, 6}, { 0x0016, 9}, { 0x0005, 10},
-{ 0x000E, 6}, { 0x0004, 10}, { 0x0011, 7}, { 0x0024, 11}, { 0x0010, 7}, { 0x0025, 11},
-{ 0x0013, 7}, { 0x005A, 12}, { 0x0015, 8}, { 0x005B, 12}, { 0x0014, 8}, { 0x0013, 8},
-{ 0x001A, 8}, { 0x0015, 9}, { 0x0014, 9}, { 0x0013, 9}, { 0x0012, 9}, { 0x0011, 9},
-{ 0x0026, 11}, { 0x0027, 11}, { 0x005C, 12}, { 0x005D, 12}, { 0x005E, 12}, { 0x005F, 12},
-{ 0x0003, 7}
-},
-{
-{ 0x0002, 2}, { 0x000F, 4}, { 0x0015, 6}, { 0x0017, 7}, { 0x001F, 8}, { 0x0025, 9},
-{ 0x0024, 9}, { 0x0021, 10}, { 0x0020, 10}, { 0x0007, 11}, { 0x0006, 11}, { 0x0020, 11},
-{ 0x0006, 3}, { 0x0014, 6}, { 0x001E, 8}, { 0x000F, 10}, { 0x0021, 11}, { 0x0050, 12},
-{ 0x000E, 4}, { 0x001D, 8}, { 0x000E, 10}, { 0x0051, 12}, { 0x000D, 5}, { 0x0023, 9},
-{ 0x000D, 10}, { 0x000C, 5}, { 0x0022, 9}, { 0x0052, 12}, { 0x000B, 5}, { 0x000C, 10},
-{ 0x0053, 12}, { 0x0013, 6}, { 0x000B, 10}, { 0x0054, 12}, { 0x0012, 6}, { 0x000A, 10},
-{ 0x0011, 6}, { 0x0009, 10}, { 0x0010, 6}, { 0x0008, 10}, { 0x0016, 7}, { 0x0055, 12},
-{ 0x0015, 7}, { 0x0014, 7}, { 0x001C, 8}, { 0x001B, 8}, { 0x0021, 9}, { 0x0020, 9},
-{ 0x001F, 9}, { 0x001E, 9}, { 0x001D, 9}, { 0x001C, 9}, { 0x001B, 9}, { 0x001A, 9},
-{ 0x0022, 11}, { 0x0023, 11}, { 0x0056, 12}, { 0x0057, 12}, { 0x0007, 4}, { 0x0019, 9},
-{ 0x0005, 11}, { 0x000F, 6}, { 0x0004, 11}, { 0x000E, 6}, { 0x000D, 6}, { 0x000C, 6},
-{ 0x0013, 7}, { 0x0012, 7}, { 0x0011, 7}, { 0x0010, 7}, { 0x001A, 8}, { 0x0019, 8},
-{ 0x0018, 8}, { 0x0017, 8}, { 0x0016, 8}, { 0x0015, 8}, { 0x0014, 8}, { 0x0013, 8},
-{ 0x0018, 9}, { 0x0017, 9}, { 0x0016, 9}, { 0x0015, 9}, { 0x0014, 9}, { 0x0013, 9},
-{ 0x0012, 9}, { 0x0011, 9}, { 0x0007, 10}, { 0x0006, 10}, { 0x0005, 10}, { 0x0004, 10},
-{ 0x0024, 11}, { 0x0025, 11}, { 0x0026, 11}, { 0x0027, 11}, { 0x0058, 12}, { 0x0059, 12},
-{ 0x005A, 12}, { 0x005B, 12}, { 0x005C, 12}, { 0x005D, 12}, { 0x005E, 12}, { 0x005F, 12},
-{ 0x0003, 7}
-},
-{
-{ 0x0000, 2}, { 0x0003, 3}, { 0x000D, 4}, { 0x0005, 4}, { 0x001C, 5}, { 0x0016, 5},
-{ 0x003F, 6}, { 0x003A, 6}, { 0x002E, 6}, { 0x0022, 6}, { 0x007B, 7}, { 0x0067, 7},
-{ 0x005F, 7}, { 0x0047, 7}, { 0x0026, 7}, { 0x00EF, 8}, { 0x00CD, 8}, { 0x00C1, 8},
-{ 0x00A9, 8}, { 0x004F, 8}, { 0x01F2, 9}, { 0x01DD, 9}, { 0x0199, 9}, { 0x0185, 9},
-{ 0x015D, 9}, { 0x011B, 9}, { 0x03EF, 10}, { 0x03E1, 10}, { 0x03C8, 10}, { 0x0331, 10},
-{ 0x0303, 10}, { 0x02F1, 10}, { 0x02A0, 10}, { 0x0233, 10}, { 0x0126, 10}, { 0x07C0, 11},
-{ 0x076F, 11}, { 0x076C, 11}, { 0x0661, 11}, { 0x0604, 11}, { 0x0572, 11}, { 0x0551, 11},
-{ 0x046A, 11}, { 0x0274, 11}, { 0x0F27, 12}, { 0x0F24, 12}, { 0x0EDB, 12}, { 0x0C8E, 12},
-{ 0x0C0B, 12}, { 0x0C0A, 12}, { 0x0AE3, 12}, { 0x08D6, 12}, { 0x0490, 12}, { 0x0495, 12},
-{ 0x1F19, 13}, { 0x1DB5, 13}, { 0x0009, 4}, { 0x0010, 5}, { 0x0029, 6}, { 0x0062, 7},
-{ 0x00F3, 8}, { 0x00AD, 8}, { 0x01E5, 9}, { 0x0179, 9}, { 0x009C, 9}, { 0x03B1, 10},
-{ 0x02AE, 10}, { 0x0127, 10}, { 0x076E, 11}, { 0x0570, 11}, { 0x0275, 11}, { 0x0F25, 12},
-{ 0x0EC0, 12}, { 0x0AA0, 12}, { 0x08D7, 12}, { 0x1E4C, 13}, { 0x0008, 5}, { 0x0063, 7},
-{ 0x00AF, 8}, { 0x017B, 9}, { 0x03B3, 10}, { 0x07DD, 11}, { 0x0640, 11}, { 0x0F8D, 12},
-{ 0x0BC1, 12}, { 0x0491, 12}, { 0x0028, 6}, { 0x00C3, 8}, { 0x0151, 9}, { 0x02A1, 10},
-{ 0x0573, 11}, { 0x0EC3, 12}, { 0x1F35, 13}, { 0x0065, 7}, { 0x01DA, 9}, { 0x02AF, 10},
-{ 0x0277, 11}, { 0x08C9, 12}, { 0x1781, 13}, { 0x0025, 7}, { 0x0118, 9}, { 0x0646, 11},
-{ 0x0AA6, 12}, { 0x1780, 13}, { 0x00C9, 8}, { 0x0321, 10}, { 0x0F9B, 12}, { 0x191E, 13},
-{ 0x0048, 8}, { 0x07CC, 11}, { 0x0AA1, 12}, { 0x0180, 9}, { 0x0465, 11}, { 0x1905, 13},
-{ 0x03E2, 10}, { 0x0EC1, 12}, { 0x3C9B, 14}, { 0x02F4, 10}, { 0x08C8, 12}, { 0x07C1, 11},
-{ 0x0928, 13}, { 0x05E1, 11}, { 0x320D, 14}, { 0x0EC2, 12}, { 0x6418, 15}, { 0x1F34, 13},
-{ 0x0078, 7}, { 0x0155, 9}, { 0x0552, 11}, { 0x191F, 13}, { 0x00FA, 8}, { 0x07DC, 11},
-{ 0x1907, 13}, { 0x00AC, 8}, { 0x0249, 11}, { 0x13B1, 14}, { 0x01F6, 9}, { 0x0AE2, 12},
-{ 0x01DC, 9}, { 0x04ED, 12}, { 0x0184, 9}, { 0x1904, 13}, { 0x0156, 9}, { 0x09D9, 13},
-{ 0x03E7, 10}, { 0x0929, 13}, { 0x03B2, 10}, { 0x3B68, 14}, { 0x02F5, 10}, { 0x13B0, 14},
-{ 0x0322, 10}, { 0x3B69, 14}, { 0x0234, 10}, { 0x7935, 15}, { 0x07C7, 11}, { 0xC833, 16},
-{ 0x0660, 11}, { 0x7934, 15}, { 0x024B, 11}, { 0xC832, 16}, { 0x0AA7, 12}, { 0x1F18, 13},
-{ 0x007A, 7}
-},
-{
-{ 0x0002, 2}, { 0x0000, 3}, { 0x001E, 5}, { 0x0004, 5}, { 0x0012, 6}, { 0x0070, 7},
-{ 0x001A, 7}, { 0x005F, 8}, { 0x0047, 8}, { 0x01D3, 9}, { 0x00B5, 9}, { 0x0057, 9},
-{ 0x03B5, 10}, { 0x016D, 10}, { 0x0162, 10}, { 0x07CE, 11}, { 0x0719, 11}, { 0x0691, 11},
-{ 0x02C6, 11}, { 0x0156, 11}, { 0x0F92, 12}, { 0x0D2E, 12}, { 0x0D20, 12}, { 0x059E, 12},
-{ 0x0468, 12}, { 0x02A6, 12}, { 0x1DA2, 13}, { 0x1C60, 13}, { 0x1A43, 13}, { 0x0B1D, 13},
-{ 0x08C0, 13}, { 0x055D, 13}, { 0x0003, 3}, { 0x000A, 5}, { 0x0077, 7}, { 0x00E5, 8},
-{ 0x01D9, 9}, { 0x03E5, 10}, { 0x0166, 10}, { 0x0694, 11}, { 0x0152, 11}, { 0x059F, 12},
-{ 0x1F3C, 13}, { 0x1A4B, 13}, { 0x055E, 13}, { 0x000C, 4}, { 0x007D, 7}, { 0x0044, 8},
-{ 0x03E0, 10}, { 0x0769, 11}, { 0x0E31, 12}, { 0x1F26, 13}, { 0x055C, 13}, { 0x001B, 5},
-{ 0x00E2, 8}, { 0x03A5, 10}, { 0x02C9, 11}, { 0x1F23, 13}, { 0x3B47, 14}, { 0x0007, 5},
-{ 0x01D8, 9}, { 0x02D8, 11}, { 0x1F27, 13}, { 0x3494, 14}, { 0x0035, 6}, { 0x03E1, 10},
-{ 0x059C, 12}, { 0x38C3, 14}, { 0x000C, 6}, { 0x0165, 10}, { 0x1D23, 13}, { 0x1638, 14},
-{ 0x0068, 7}, { 0x0693, 11}, { 0x3A45, 14}, { 0x0020, 7}, { 0x0F90, 12}, { 0x7CF6, 15},
-{ 0x00E8, 8}, { 0x058F, 12}, { 0x2CEF, 15}, { 0x0045, 8}, { 0x0B3A, 13}, { 0x01F1, 9},
-{ 0x3B46, 14}, { 0x01A7, 9}, { 0x1676, 14}, { 0x0056, 9}, { 0x692A, 15}, { 0x038D, 10},
-{ 0xE309, 16}, { 0x00AA, 10}, { 0x1C611, 17}, { 0x02DF, 11}, { 0xB3B9, 17}, { 0x02C8, 11},
-{ 0x38C20, 18}, { 0x01B0, 11}, { 0x16390, 18}, { 0x0F9F, 12}, { 0x16771, 18}, { 0x0ED0, 12},
-{ 0x71843, 19}, { 0x0D2A, 12}, { 0xF9E8C, 20}, { 0x0461, 12}, { 0xF9E8E, 20}, { 0x0B67, 13},
-{ 0x055F, 13}, { 0x003F, 6}, { 0x006D, 9}, { 0x0E90, 12}, { 0x054E, 13}, { 0x0013, 6},
-{ 0x0119, 10}, { 0x0B66, 13}, { 0x000B, 6}, { 0x0235, 11}, { 0x7CF5, 15}, { 0x0075, 7},
-{ 0x0D24, 12}, { 0xF9E9, 16}, { 0x002E, 7}, { 0x1F22, 13}, { 0x0021, 7}, { 0x054F, 13},
-{ 0x0014, 7}, { 0x3A44, 14}, { 0x00E4, 8}, { 0x7CF7, 15}, { 0x005E, 8}, { 0x7185, 15},
-{ 0x0037, 8}, { 0x2C73, 15}, { 0x01DB, 9}, { 0x59DD, 16}, { 0x01C7, 9}, { 0x692B, 15},
-{ 0x01A6, 9}, { 0x58E5, 16}, { 0x00B4, 9}, { 0x1F3D0, 17}, { 0x00B0, 9}, { 0xB1C9, 17},
-{ 0x03E6, 10}, { 0x16770, 18}, { 0x016E, 10}, { 0x3E7A2, 18}, { 0x011B, 10}, { 0xF9E8D, 20},
-{ 0x00D9, 10}, { 0xF9E8F, 20}, { 0x00A8, 10}, { 0x2C723, 19}, { 0x0749, 11}, { 0xE3084, 20},
-{ 0x0696, 11}, { 0x58E45, 20}, { 0x02DE, 11}, { 0xB1C88, 21}, { 0x0231, 11}, { 0x1C610A, 21},
-{ 0x01B1, 11}, { 0x71842D, 23}, { 0x0D2B, 12}, { 0x38C217, 22}, { 0x0D2F, 12}, { 0x163913, 22},
-{ 0x05B2, 12}, { 0x163912, 22}, { 0x0469, 12}, { 0x71842C, 23}, { 0x1A42, 13}, { 0x08C1, 13},
-{ 0x0073, 7}
-}
-};
-
-static const uint16_t vlc_offs[] = {
- 0, 520, 552, 616, 1128, 1160, 1224, 1740, 1772, 1836, 1900, 2436,
- 2986, 3050, 3610, 4154, 4218, 4746, 5326, 5390, 5902, 6554, 7658, 8342,
- 9304, 9988, 10630, 11234, 12174, 13006, 13560, 14232, 14786, 15432, 16350, 17522,
- 20372, 21818, 22330, 22394, 23166, 23678, 23742, 24820, 25332, 25396, 26460, 26980,
- 27048, 27592, 27600, 27608, 27616, 27624, 28224, 28258, 28290, 28802, 28834, 28866,
- 29378, 29412, 29444, 29960, 29994, 30026, 30538, 30572, 30604, 31120, 31154, 31186,
- 31714, 31746, 31778, 32306, 32340, 32372
-};
-
-/**
- * Init VC-1 specific tables and VC1Context members
- * @param v The VC1Context to initialize
- * @return Status
- */
-int ff_vc1_init_common(VC1Context *v)
-{
- static int done = 0;
- int i = 0;
- static VLC_TYPE vlc_table[32372][2];
-
- v->hrd_rate = v->hrd_buffer = NULL;
-
- /* VLC tables */
- if (!done) {
- INIT_VLC_STATIC(&ff_vc1_bfraction_vlc, VC1_BFRACTION_VLC_BITS, 23,
- ff_vc1_bfraction_bits, 1, 1,
- ff_vc1_bfraction_codes, 1, 1, 1 << VC1_BFRACTION_VLC_BITS);
- INIT_VLC_STATIC(&ff_vc1_norm2_vlc, VC1_NORM2_VLC_BITS, 4,
- ff_vc1_norm2_bits, 1, 1,
- ff_vc1_norm2_codes, 1, 1, 1 << VC1_NORM2_VLC_BITS);
- INIT_VLC_STATIC(&ff_vc1_norm6_vlc, VC1_NORM6_VLC_BITS, 64,
- ff_vc1_norm6_bits, 1, 1,
- ff_vc1_norm6_codes, 2, 2, 556);
- INIT_VLC_STATIC(&ff_vc1_imode_vlc, VC1_IMODE_VLC_BITS, 7,
- ff_vc1_imode_bits, 1, 1,
- ff_vc1_imode_codes, 1, 1, 1 << VC1_IMODE_VLC_BITS);
- for (i = 0; i < 3; i++) {
- ff_vc1_ttmb_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 0]];
- ff_vc1_ttmb_vlc[i].table_allocated = vlc_offs[i * 3 + 1] - vlc_offs[i * 3 + 0];
- init_vlc(&ff_vc1_ttmb_vlc[i], VC1_TTMB_VLC_BITS, 16,
- ff_vc1_ttmb_bits[i], 1, 1,
- ff_vc1_ttmb_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC);
- ff_vc1_ttblk_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 1]];
- ff_vc1_ttblk_vlc[i].table_allocated = vlc_offs[i * 3 + 2] - vlc_offs[i * 3 + 1];
- init_vlc(&ff_vc1_ttblk_vlc[i], VC1_TTBLK_VLC_BITS, 8,
- ff_vc1_ttblk_bits[i], 1, 1,
- ff_vc1_ttblk_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC);
- ff_vc1_subblkpat_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 2]];
- ff_vc1_subblkpat_vlc[i].table_allocated = vlc_offs[i * 3 + 3] - vlc_offs[i * 3 + 2];
- init_vlc(&ff_vc1_subblkpat_vlc[i], VC1_SUBBLKPAT_VLC_BITS, 15,
- ff_vc1_subblkpat_bits[i], 1, 1,
- ff_vc1_subblkpat_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC);
- }
- for (i = 0; i < 4; i++) {
- ff_vc1_4mv_block_pattern_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 9]];
- ff_vc1_4mv_block_pattern_vlc[i].table_allocated = vlc_offs[i * 3 + 10] - vlc_offs[i * 3 + 9];
- init_vlc(&ff_vc1_4mv_block_pattern_vlc[i], VC1_4MV_BLOCK_PATTERN_VLC_BITS, 16,
- ff_vc1_4mv_block_pattern_bits[i], 1, 1,
- ff_vc1_4mv_block_pattern_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC);
- ff_vc1_cbpcy_p_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 10]];
- ff_vc1_cbpcy_p_vlc[i].table_allocated = vlc_offs[i * 3 + 11] - vlc_offs[i * 3 + 10];
- init_vlc(&ff_vc1_cbpcy_p_vlc[i], VC1_CBPCY_P_VLC_BITS, 64,
- ff_vc1_cbpcy_p_bits[i], 1, 1,
- ff_vc1_cbpcy_p_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC);
- ff_vc1_mv_diff_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 11]];
- ff_vc1_mv_diff_vlc[i].table_allocated = vlc_offs[i * 3 + 12] - vlc_offs[i * 3 + 11];
- init_vlc(&ff_vc1_mv_diff_vlc[i], VC1_MV_DIFF_VLC_BITS, 73,
- ff_vc1_mv_diff_bits[i], 1, 1,
- ff_vc1_mv_diff_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC);
- }
- for (i = 0; i < 8; i++) {
- ff_vc1_ac_coeff_table[i].table = &vlc_table[vlc_offs[i * 2 + 21]];
- ff_vc1_ac_coeff_table[i].table_allocated = vlc_offs[i * 2 + 22] - vlc_offs[i * 2 + 21];
- init_vlc(&ff_vc1_ac_coeff_table[i], AC_VLC_BITS, ff_vc1_ac_sizes[i],
- &vc1_ac_tables[i][0][1], 8, 4,
- &vc1_ac_tables[i][0][0], 8, 4, INIT_VLC_USE_NEW_STATIC);
- /* initialize interlaced MVDATA tables (2-Ref) */
- ff_vc1_2ref_mvdata_vlc[i].table = &vlc_table[vlc_offs[i * 2 + 22]];
- ff_vc1_2ref_mvdata_vlc[i].table_allocated = vlc_offs[i * 2 + 23] - vlc_offs[i * 2 + 22];
- init_vlc(&ff_vc1_2ref_mvdata_vlc[i], VC1_2REF_MVDATA_VLC_BITS, 126,
- ff_vc1_2ref_mvdata_bits[i], 1, 1,
- ff_vc1_2ref_mvdata_codes[i], 4, 4, INIT_VLC_USE_NEW_STATIC);
- }
- for (i = 0; i < 4; i++) {
- /* initialize 4MV MBMODE VLC tables for interlaced frame P picture */
- ff_vc1_intfr_4mv_mbmode_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 37]];
- ff_vc1_intfr_4mv_mbmode_vlc[i].table_allocated = vlc_offs[i * 3 + 38] - vlc_offs[i * 3 + 37];
- init_vlc(&ff_vc1_intfr_4mv_mbmode_vlc[i], VC1_INTFR_4MV_MBMODE_VLC_BITS, 15,
- ff_vc1_intfr_4mv_mbmode_bits[i], 1, 1,
- ff_vc1_intfr_4mv_mbmode_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC);
- /* initialize NON-4MV MBMODE VLC tables for the same */
- ff_vc1_intfr_non4mv_mbmode_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 38]];
- ff_vc1_intfr_non4mv_mbmode_vlc[i].table_allocated = vlc_offs[i * 3 + 39] - vlc_offs[i * 3 + 38];
- init_vlc(&ff_vc1_intfr_non4mv_mbmode_vlc[i], VC1_INTFR_NON4MV_MBMODE_VLC_BITS, 9,
- ff_vc1_intfr_non4mv_mbmode_bits[i], 1, 1,
- ff_vc1_intfr_non4mv_mbmode_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC);
- /* initialize interlaced MVDATA tables (1-Ref) */
- ff_vc1_1ref_mvdata_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 39]];
- ff_vc1_1ref_mvdata_vlc[i].table_allocated = vlc_offs[i * 3 + 40] - vlc_offs[i * 3 + 39];
- init_vlc(&ff_vc1_1ref_mvdata_vlc[i], VC1_1REF_MVDATA_VLC_BITS, 72,
- ff_vc1_1ref_mvdata_bits[i], 1, 1,
- ff_vc1_1ref_mvdata_codes[i], 4, 4, INIT_VLC_USE_NEW_STATIC);
- }
- for (i = 0; i < 4; i++) {
- /* Initialize 2MV Block pattern VLC tables */
- ff_vc1_2mv_block_pattern_vlc[i].table = &vlc_table[vlc_offs[i + 49]];
- ff_vc1_2mv_block_pattern_vlc[i].table_allocated = vlc_offs[i + 50] - vlc_offs[i + 49];
- init_vlc(&ff_vc1_2mv_block_pattern_vlc[i], VC1_2MV_BLOCK_PATTERN_VLC_BITS, 4,
- ff_vc1_2mv_block_pattern_bits[i], 1, 1,
- ff_vc1_2mv_block_pattern_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC);
- }
- for (i = 0; i < 8; i++) {
- /* Initialize interlaced CBPCY VLC tables (Table 124 - Table 131) */
- ff_vc1_icbpcy_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 53]];
- ff_vc1_icbpcy_vlc[i].table_allocated = vlc_offs[i * 3 + 54] - vlc_offs[i * 3 + 53];
- init_vlc(&ff_vc1_icbpcy_vlc[i], VC1_ICBPCY_VLC_BITS, 63,
- ff_vc1_icbpcy_p_bits[i], 1, 1,
- ff_vc1_icbpcy_p_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC);
- /* Initialize interlaced field picture MBMODE VLC tables */
- ff_vc1_if_mmv_mbmode_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 54]];
- ff_vc1_if_mmv_mbmode_vlc[i].table_allocated = vlc_offs[i * 3 + 55] - vlc_offs[i * 3 + 54];
- init_vlc(&ff_vc1_if_mmv_mbmode_vlc[i], VC1_IF_MMV_MBMODE_VLC_BITS, 8,
- ff_vc1_if_mmv_mbmode_bits[i], 1, 1,
- ff_vc1_if_mmv_mbmode_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC);
- ff_vc1_if_1mv_mbmode_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 55]];
- ff_vc1_if_1mv_mbmode_vlc[i].table_allocated = vlc_offs[i * 3 + 56] - vlc_offs[i * 3 + 55];
- init_vlc(&ff_vc1_if_1mv_mbmode_vlc[i], VC1_IF_1MV_MBMODE_VLC_BITS, 6,
- ff_vc1_if_1mv_mbmode_bits[i], 1, 1,
- ff_vc1_if_1mv_mbmode_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC);
- }
- done = 1;
- }
-
- /* Other defaults */
- v->pq = -1;
- v->mvrange = 0; /* 7.1.1.18, p80 */
-
- return 0;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/vc1.h b/src/thirdparty/ffmpeg/libavcodec/vc1.h
deleted file mode 100644
index 279b19043..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vc1.h
+++ /dev/null
@@ -1,462 +0,0 @@
-/*
- * VC-1 and WMV3 decoder
- * Copyright (c) 2006-2007 Konstantin Shishkov
- * Partly based on vc9.c (c) 2005 Anonymous, Alex Beregszaszi, 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
- */
-
-#ifndef AVCODEC_VC1_H
-#define AVCODEC_VC1_H
-
-#include "avcodec.h"
-#include "h264chroma.h"
-#include "mpegvideo.h"
-#include "intrax8.h"
-#include "vc1dsp.h"
-
-#define AC_VLC_BITS 9
-
-/** Markers used in VC-1 AP frame data */
-//@{
-enum VC1Code {
- VC1_CODE_RES0 = 0x00000100,
- VC1_CODE_ENDOFSEQ = 0x0000010A,
- VC1_CODE_SLICE,
- VC1_CODE_FIELD,
- VC1_CODE_FRAME,
- VC1_CODE_ENTRYPOINT,
- VC1_CODE_SEQHDR,
-};
-//@}
-
-#define IS_MARKER(x) (((x) & ~0xFF) == VC1_CODE_RES0)
-
-/** Available Profiles */
-//@{
-enum Profile {
- PROFILE_SIMPLE,
- PROFILE_MAIN,
- PROFILE_COMPLEX, ///< TODO: WMV9 specific
- PROFILE_ADVANCED
-};
-//@}
-
-/** Sequence quantizer mode */
-//@{
-enum QuantMode {
- QUANT_FRAME_IMPLICIT, ///< Implicitly specified at frame level
- QUANT_FRAME_EXPLICIT, ///< Explicitly specified at frame level
- QUANT_NON_UNIFORM, ///< Non-uniform quant used for all frames
- QUANT_UNIFORM ///< Uniform quant used for all frames
-};
-//@}
-
-/** Where quant can be changed */
-//@{
-enum DQProfile {
- DQPROFILE_FOUR_EDGES,
- DQPROFILE_DOUBLE_EDGES,
- DQPROFILE_SINGLE_EDGE,
- DQPROFILE_ALL_MBS
-};
-//@}
-
-/** @name Where quant can be changed
- */
-//@{
-enum DQSingleEdge {
- DQSINGLE_BEDGE_LEFT,
- DQSINGLE_BEDGE_TOP,
- DQSINGLE_BEDGE_RIGHT,
- DQSINGLE_BEDGE_BOTTOM
-};
-//@}
-
-/** Which pair of edges is quantized with ALTPQUANT */
-//@{
-enum DQDoubleEdge {
- DQDOUBLE_BEDGE_TOPLEFT,
- DQDOUBLE_BEDGE_TOPRIGHT,
- DQDOUBLE_BEDGE_BOTTOMRIGHT,
- DQDOUBLE_BEDGE_BOTTOMLEFT
-};
-//@}
-
-/** MV modes for P frames */
-//@{
-enum MVModes {
- MV_PMODE_1MV_HPEL_BILIN,
- MV_PMODE_1MV,
- MV_PMODE_1MV_HPEL,
- MV_PMODE_MIXED_MV,
- MV_PMODE_INTENSITY_COMP
-};
-//@}
-
-/** MBMODE for interlaced frame P-picture */
-//@{
-enum MBModesIntfr {
- MV_PMODE_INTFR_1MV,
- MV_PMODE_INTFR_2MV_FIELD,
- MV_PMODE_INTFR_2MV,
- MV_PMODE_INTFR_4MV_FIELD,
- MV_PMODE_INTFR_4MV,
- MV_PMODE_INTFR_INTRA,
-};
-//@}
-
-/** @name MV types for B frames */
-//@{
-enum BMVTypes {
- BMV_TYPE_BACKWARD,
- BMV_TYPE_FORWARD,
- BMV_TYPE_INTERPOLATED,
- BMV_TYPE_DIRECT
-};
-//@}
-
-/** @name Block types for P/B frames */
-//@{
-enum TransformTypes {
- TT_8X8,
- TT_8X4_BOTTOM,
- TT_8X4_TOP,
- TT_8X4, // both halves
- TT_4X8_RIGHT,
- TT_4X8_LEFT,
- TT_4X8, // both halves
- TT_4X4
-};
-//@}
-
-enum CodingSet {
- CS_HIGH_MOT_INTRA = 0,
- CS_HIGH_MOT_INTER,
- CS_LOW_MOT_INTRA,
- CS_LOW_MOT_INTER,
- CS_MID_RATE_INTRA,
- CS_MID_RATE_INTER,
- CS_HIGH_RATE_INTRA,
- CS_HIGH_RATE_INTER
-};
-
-/** @name Overlap conditions for Advanced Profile */
-//@{
-enum COTypes {
- CONDOVER_NONE = 0,
- CONDOVER_ALL,
- CONDOVER_SELECT
-};
-//@}
-
-/**
- * FCM Frame Coding Mode
- * @note some content might be marked interlaced
- * but have fcm set to 0 as well (e.g. HD-DVD)
- */
-enum FrameCodingMode {
- PROGRESSIVE = 0, ///< in the bitstream is reported as 00b
- ILACE_FRAME, ///< in the bitstream is reported as 10b
- ILACE_FIELD ///< in the bitstream is reported as 11b
-};
-
-/** The VC1 Context
- * @todo Change size wherever another size is more efficient
- * Many members are only used for Advanced Profile
- */
-typedef struct VC1Context{
- MpegEncContext s;
- IntraX8Context x8;
- H264ChromaContext h264chroma;
- VC1DSPContext vc1dsp;
-
- int bits;
-
- /** Simple/Main Profile sequence header */
- //@{
- int res_sprite; ///< reserved, sprite mode
- int res_y411; ///< reserved, old interlaced mode
- int res_x8; ///< reserved
- int multires; ///< frame-level RESPIC syntax element present
- int res_fasttx; ///< reserved, always 1
- int res_transtab; ///< reserved, always 0
- int rangered; ///< RANGEREDFRM (range reduction) syntax element present
- ///< at frame level
- int res_rtm_flag; ///< reserved, set to 1
- int reserved; ///< reserved
- //@}
-
- /** Advanced Profile */
- //@{
- int level; ///< 3bits, for Advanced/Simple Profile, provided by TS layer
- int chromaformat; ///< 2bits, 2=4:2:0, only defined
- int postprocflag; ///< Per-frame processing suggestion flag present
- int broadcast; ///< TFF/RFF present
- int interlace; ///< Progressive/interlaced (RPTFTM syntax element)
- int tfcntrflag; ///< TFCNTR present
- int panscanflag; ///< NUMPANSCANWIN, TOPLEFT{X,Y}, BOTRIGHT{X,Y} present
- int refdist_flag; ///< REFDIST syntax element present in II, IP, PI or PP field picture headers
- int extended_dmv; ///< Additional extended dmv range at P/B frame-level
- int hrd_param_flag; ///< Presence of Hypothetical Reference
- ///< Decoder parameters
- int psf; ///< Progressive Segmented Frame
- //@}
-
- /** Sequence header data for all Profiles
- * TODO: choose between ints, uint8_ts and monobit flags
- */
- //@{
- int profile; ///< 2bits, Profile
- int frmrtq_postproc; ///< 3bits,
- int bitrtq_postproc; ///< 5bits, quantized framerate-based postprocessing strength
- int max_coded_width, max_coded_height;
- int fastuvmc; ///< Rounding of qpel vector to hpel ? (not in Simple)
- int extended_mv; ///< Ext MV in P/B (not in Simple)
- int dquant; ///< How qscale varies with MBs, 2bits (not in Simple)
- int vstransform; ///< variable-size [48]x[48] transform type + info
- int overlap; ///< overlapped transforms in use
- int quantizer_mode; ///< 2bits, quantizer mode used for sequence, see QUANT_*
- int finterpflag; ///< INTERPFRM present
- //@}
-
- /** Frame decoding info for all profiles */
- //@{
- uint8_t mv_mode; ///< MV coding monde
- uint8_t mv_mode2; ///< Secondary MV coding mode (B frames)
- int k_x; ///< Number of bits for MVs (depends on MV range)
- int k_y; ///< Number of bits for MVs (depends on MV range)
- int range_x, range_y; ///< MV range
- uint8_t pq, altpq; ///< Current/alternate frame quantizer scale
- uint8_t zz_8x8[4][64]; ///< Zigzag table for TT_8x8, permuted for IDCT
- int left_blk_sh, top_blk_sh; ///< Either 3 or 0, positions of l/t in blk[]
- const uint8_t* zz_8x4; ///< Zigzag scan table for TT_8x4 coding mode
- const uint8_t* zz_4x8; ///< Zigzag scan table for TT_4x8 coding mode
- /** pquant parameters */
- //@{
- uint8_t dquantfrm;
- uint8_t dqprofile;
- uint8_t dqsbedge;
- uint8_t dqbilevel;
- //@}
- /** AC coding set indexes
- * @see 8.1.1.10, p(1)10
- */
- //@{
- int c_ac_table_index; ///< Chroma index from ACFRM element
- int y_ac_table_index; ///< Luma index from AC2FRM element
- //@}
- int ttfrm; ///< Transform type info present at frame level
- uint8_t ttmbf; ///< Transform type flag
- int *ttblk_base, *ttblk; ///< Transform type at the block level
- int codingset; ///< index of current table set from 11.8 to use for luma block decoding
- int codingset2; ///< index of current table set from 11.8 to use for chroma block decoding
- int pqindex; ///< raw pqindex used in coding set selection
- int a_avail, c_avail;
- uint8_t *mb_type_base, *mb_type[3];
-
-
- /** Luma compensation parameters */
- //@{
- uint8_t lumscale;
- uint8_t lumshift;
- //@}
- int16_t bfraction; ///< Relative position % anchors=> how to scale MVs
- uint8_t halfpq; ///< Uniform quant over image and qp+.5
- uint8_t respic; ///< Frame-level flag for resized images
- int buffer_fullness; ///< HRD info
- /** Ranges:
- * -# 0 -> [-64n 63.f] x [-32, 31.f]
- * -# 1 -> [-128, 127.f] x [-64, 63.f]
- * -# 2 -> [-512, 511.f] x [-128, 127.f]
- * -# 3 -> [-1024, 1023.f] x [-256, 255.f]
- */
- uint8_t mvrange; ///< Extended MV range flag
- uint8_t pquantizer; ///< Uniform (over sequence) quantizer in use
- VLC *cbpcy_vlc; ///< CBPCY VLC table
- int tt_index; ///< Index for Transform Type tables (to decode TTMB)
- uint8_t* mv_type_mb_plane; ///< bitplane for mv_type == (4MV)
- uint8_t* direct_mb_plane; ///< bitplane for "direct" MBs
- uint8_t* forward_mb_plane; ///< bitplane for "forward" MBs
- int mv_type_is_raw; ///< mv type mb plane is not coded
- int dmb_is_raw; ///< direct mb plane is raw
- int fmb_is_raw; ///< forward mb plane is raw
- int skip_is_raw; ///< skip mb plane is not coded
- uint8_t luty[256], lutuv[256]; ///< lookup tables used for intensity compensation
- int use_ic; ///< use intensity compensation in B-frames
- int rnd; ///< rounding control
-
- /** Frame decoding info for S/M profiles only */
- //@{
- uint8_t rangeredfrm; ///< out_sample = CLIP((in_sample-128)*2+128)
- uint8_t interpfrm;
- //@}
-
- /** Frame decoding info for Advanced profile */
- //@{
- enum FrameCodingMode fcm;
- uint8_t numpanscanwin;
- uint8_t tfcntr;
- uint8_t rptfrm, tff, rff;
- uint16_t topleftx;
- uint16_t toplefty;
- uint16_t bottomrightx;
- uint16_t bottomrighty;
- uint8_t uvsamp;
- uint8_t postproc;
- int hrd_num_leaky_buckets;
- uint8_t bit_rate_exponent;
- uint8_t buffer_size_exponent;
- uint8_t* acpred_plane; ///< AC prediction flags bitplane
- int acpred_is_raw;
- uint8_t* over_flags_plane; ///< Overflags bitplane
- int overflg_is_raw;
- uint8_t condover;
- uint16_t *hrd_rate, *hrd_buffer;
- uint8_t *hrd_fullness;
- uint8_t range_mapy_flag;
- uint8_t range_mapuv_flag;
- uint8_t range_mapy;
- uint8_t range_mapuv;
- //@}
-
- /** Frame decoding info for interlaced picture */
- uint8_t dmvrange; ///< Extended differential MV range flag
- int fourmvswitch;
- int intcomp;
- uint8_t lumscale2; ///< for interlaced field P picture
- uint8_t lumshift2;
- uint8_t luty2[256], lutuv2[256]; // lookup tables used for intensity compensation
- VLC* mbmode_vlc;
- VLC* imv_vlc;
- VLC* twomvbp_vlc;
- VLC* fourmvbp_vlc;
- uint8_t twomvbp;
- uint8_t fourmvbp;
- uint8_t* fieldtx_plane;
- int fieldtx_is_raw;
- uint8_t zzi_8x8[64];
- uint8_t *blk_mv_type_base, *blk_mv_type; ///< 0: frame MV, 1: field MV (interlaced frame)
- uint8_t *mv_f_base, *mv_f[2]; ///< 0: MV obtained from same field, 1: opposite field
- uint8_t *mv_f_last_base, *mv_f_last[2];
- uint8_t *mv_f_next_base, *mv_f_next[2];
- int field_mode; ///< 1 for interlaced field pictures
- int fptype;
- int second_field;
- int refdist; ///< distance of the current picture from reference
- int numref; ///< number of past field pictures used as reference
- // 0 corresponds to 1 and 1 corresponds to 2 references
- int reffield; ///< if numref = 0 (1 reference) then reffield decides which
- // field to use among the two fields from previous frame
- int intcompfield; ///< which of the two fields to be intensity compensated
- // 0: both fields, 1: bottom field, 2: top field
- int cur_field_type; ///< 0: top, 1: bottom
- int ref_field_type[2]; ///< forward and backward reference field type (top or bottom)
- int blocks_off, mb_off;
- int qs_last; ///< if qpel has been used in the previous (tr.) picture
- int bmvtype;
- int frfd, brfd; ///< reference frame distance (forward or backward)
- int first_pic_header_flag;
- int pic_header_flag;
-
- /** Frame decoding info for sprite modes */
- //@{
- int new_sprite;
- int two_sprites;
- AVFrame sprite_output_frame;
- int output_width, output_height, sprite_width, sprite_height;
- uint8_t* sr_rows[2][2]; ///< Sprite resizer line cache
- //@}
-
- int p_frame_skipped;
- int bi_type;
- int x8_type;
-
- int16_t (*block)[6][64];
- int n_allocated_blks, cur_blk_idx, left_blk_idx, topleft_blk_idx, top_blk_idx;
- uint32_t *cbp_base, *cbp;
- uint8_t *is_intra_base, *is_intra;
- int16_t (*luma_mv_base)[2], (*luma_mv)[2];
- uint8_t bfraction_lut_index; ///< Index for BFRACTION value (see Table 40, reproduced into ff_vc1_bfraction_lut[])
- uint8_t broken_link; ///< Broken link flag (BROKEN_LINK syntax element)
- uint8_t closed_entry; ///< Closed entry point flag (CLOSED_ENTRY syntax element)
-
- int end_mb_x; ///< Horizontal macroblock limit (used only by mss2)
-
- int parse_only; ///< Context is used within parser
-
- int warn_interlaced;
-} VC1Context;
-
-/** Find VC-1 marker in buffer
- * @return position where next marker starts or end of buffer if no marker found
- */
-static av_always_inline const uint8_t* find_next_marker(const uint8_t *src, const uint8_t *end)
-{
- uint32_t mrk = 0xFFFFFFFF;
-
- if (end-src < 4)
- return end;
- while (src < end) {
- mrk = (mrk << 8) | *src++;
- if (IS_MARKER(mrk))
- return src - 4;
- }
- return end;
-}
-
-static av_always_inline int vc1_unescape_buffer(const uint8_t *src, int size, uint8_t *dst)
-{
- int dsize = 0, i;
-
- if (size < 4) {
- for (dsize = 0; dsize < size; dsize++)
- *dst++ = *src++;
- return size;
- }
- for (i = 0; i < size; i++, src++) {
- if (src[0] == 3 && i >= 2 && !src[-1] && !src[-2] && i < size-1 && src[1] < 4) {
- dst[dsize++] = src[1];
- src++;
- i++;
- } else
- dst[dsize++] = *src;
- }
- return dsize;
-}
-
-/**
- * Decode Simple/Main Profiles sequence header
- * @see Figure 7-8, p16-17
- * @param avctx Codec context
- * @param gb GetBit context initialized from Codec context extra_data
- * @return Status
- */
-int ff_vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitContext *gb);
-
-int ff_vc1_decode_entry_point(AVCodecContext *avctx, VC1Context *v, GetBitContext *gb);
-
-int ff_vc1_parse_frame_header (VC1Context *v, GetBitContext *gb);
-int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext *gb);
-int ff_vc1_init_common(VC1Context *v);
-
-av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v);
-av_cold void ff_vc1_init_transposed_scantables(VC1Context *v);
-av_cold int ff_vc1_decode_end(AVCodecContext *avctx);
-void ff_vc1_decode_blocks(VC1Context *v);
-
-#endif /* AVCODEC_VC1_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/vc1_dxva.c b/src/thirdparty/ffmpeg/libavcodec/vc1_dxva.c
deleted file mode 100644
index e0f0ef392..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vc1_dxva.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * (C) 2008-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-int av_vc1_decode_frame(AVCodecContext *avctx, const uint8_t *buf, int buf_size, int *nFrameSize)
-{
- int n_slices = 0, i;
- VC1Context *v = avctx->priv_data;
- MpegEncContext *s = &v->s;
- uint8_t *buf2 = NULL;
- const uint8_t *buf_start = buf, *buf_start_second_field = NULL;
- struct {
- uint8_t *buf;
- GetBitContext gb;
- int mby_start;
- } *slices = NULL, *tmp;
-
- v->second_field = 0;
- *nFrameSize = 0;
-
- /* for advanced profile we may need to parse and unescape data */
- if (avctx->codec_id == AV_CODEC_ID_VC1 || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) {
- int buf_size2 = 0;
- buf2 = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
-
- if (IS_MARKER(AV_RB32(buf))) { /* frame starts with marker and needs to be parsed */
- const uint8_t *start, *end, *next;
- int size;
-
- next = buf;
- for (start = buf, end = buf + buf_size; next < end; start = next) {
- next = find_next_marker(start + 4, end);
- size = next - start - 4;
- if (size <= 0) continue;
- switch (AV_RB32(start)) {
- case VC1_CODE_FRAME:
- buf_start = start;
- buf_size2 = vc1_unescape_buffer(start + 4, size, buf2);
- break;
- case VC1_CODE_FIELD: {
- int buf_size3;
- buf_start_second_field = start;
- slices = av_realloc(slices, sizeof(*slices) * (n_slices + 1));
- if (!slices)
- goto err;
- slices[n_slices].buf = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
- if (!slices[n_slices].buf)
- goto err;
- buf_size3 = vc1_unescape_buffer(start + 4, size,
- slices[n_slices].buf);
- init_get_bits(&slices[n_slices].gb, slices[n_slices].buf,
- 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;
- n_slices++;
- break;
- }
- case VC1_CODE_ENTRYPOINT: /* it should be before frame data */
- buf_size2 = vc1_unescape_buffer(start + 4, size, buf2);
- init_get_bits(&s->gb, buf2, buf_size2 * 8);
- ff_vc1_decode_entry_point(avctx, v, &s->gb);
- break;
- case VC1_CODE_SLICE: {
- int buf_size3;
- slices = av_realloc(slices, sizeof(*slices) * (n_slices + 1));
- if (!slices)
- goto err;
- slices[n_slices].buf = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
- if (!slices[n_slices].buf)
- goto err;
- buf_size3 = vc1_unescape_buffer(start + 4, size,
- slices[n_slices].buf);
- init_get_bits(&slices[n_slices].gb, slices[n_slices].buf,
- buf_size3 << 3);
- slices[n_slices].mby_start = get_bits(&slices[n_slices].gb, 9);
- n_slices++;
- break;
- }
- }
- }
- } else if (v->interlace && ((buf[0] & 0xC0) == 0xC0)) { /* WVC1 interlaced stores both fields divided by marker */
- const uint8_t *divider;
- int buf_size3;
-
- divider = find_next_marker(buf, buf + buf_size);
- if ((divider == (buf + buf_size)) || AV_RB32(divider) != VC1_CODE_FIELD) {
- av_log(avctx, AV_LOG_ERROR, "Error in WVC1 interlaced frame\n");
- goto err;
- } else { /* found field marker, unescape second field */
- buf_start_second_field = divider;
- tmp = av_realloc(slices, sizeof(*slices) * (n_slices + 1));
- if (!tmp)
- goto err;
- slices = tmp;
- slices[n_slices].buf = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
- if (!slices[n_slices].buf)
- goto err;
- 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;
- n_slices++;
- }
- buf_size2 = vc1_unescape_buffer(buf, divider - buf, buf2);
- } else {
- buf_size2 = vc1_unescape_buffer(buf, buf_size, buf2);
- }
- init_get_bits(&s->gb, buf2, buf_size2 * 8);
- } else
- init_get_bits(&s->gb, buf, buf_size * 8);
-
-
- if (s->context_initialized &&
- (s->width != avctx->coded_width ||
- s->height != avctx->coded_height)) {
- ff_vc1_decode_end(avctx);
- }
-
- if (!s->context_initialized) {
- if (ff_msmpeg4_decode_init(avctx) < 0 || ff_vc1_decode_init_alloc_tables(v) < 0)
- return -1;
-
- s->low_delay = !avctx->has_b_frames || v->res_sprite;
-
- s->h_edge_pos = avctx->coded_width;
- s->v_edge_pos = avctx->coded_height;
- }
-
- /* We need to set current_picture_ptr before reading the header,
- * otherwise we cannot store anything in there. */
- if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) {
- int i = ff_find_unused_picture(s, 0);
- if (i < 0)
- goto err;
- s->current_picture_ptr = &s->picture[i];
- }
-
- /* do parse frame header */
- v->pic_header_flag = 0;
- v->first_pic_header_flag = 1;
-
- if (v->profile < PROFILE_ADVANCED) {
- ff_vc1_parse_frame_header(v, &s->gb);
- } else {
- ff_vc1_parse_frame_header_adv(v, &s->gb);
- }
-
- if (v->field_mode && buf_start_second_field) {
- s->picture_structure = PICT_BOTTOM_FIELD - v->tff;
- *nFrameSize = buf_start_second_field - buf;
- } else {
- s->picture_structure = PICT_FRAME;
- }
-
-end:
- av_free(buf2);
- for (i = 0; i < n_slices; i++)
- av_free(slices[i].buf);
- av_free(slices);
- return buf_size;
-
-err:
- av_log(avctx, AV_LOG_ERROR, "Error in av_vc1_decode_frame()\n");
- av_free(buf2);
- for (i = 0; i < n_slices; i++)
- av_free(slices[i].buf);
- av_free(slices);
- return -1;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/vc1acdata.h b/src/thirdparty/ffmpeg/libavcodec/vc1acdata.h
deleted file mode 100644
index 83c0637b4..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vc1acdata.h
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- * VC-1 and WMV3 decoder
- * copyright (c) 2006 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_VC1ACDATA_H
-#define AVCODEC_VC1ACDATA_H
-
-#include <stdint.h>
-
-#include "vc1data.h"
-
-/* which indexes point to last=1 entries in tables */
-static const int vc1_last_decode_table[AC_MODES] = {
- 119, 99, 85, 81, 67, 58, 126, 109
-};
-
-static const uint8_t vc1_index_decode_table[AC_MODES][185][2] = {
-{
-{ 0, 1}, { 0, 2}, { 0, 3}, { 0, 4}, { 0, 5}, { 0, 6}, { 0, 7}, { 0, 8},
-{ 0, 9}, { 0, 10}, { 0, 11}, { 0, 12}, { 0, 13}, { 0, 14}, { 0, 15}, { 0, 16},
-{ 0, 17}, { 0, 18}, { 0, 19}, { 1, 1}, { 1, 2}, { 1, 3}, { 1, 4}, { 1, 5},
-{ 1, 6}, { 1, 7}, { 1, 8}, { 1, 9}, { 1, 10}, { 1, 11}, { 1, 12}, { 1, 13},
-{ 1, 14}, { 1, 15}, { 2, 1}, { 2, 2}, { 2, 3}, { 2, 4}, { 2, 5}, { 2, 6},
-{ 2, 7}, { 2, 8}, { 2, 9}, { 2, 10}, { 2, 11}, { 2, 12}, { 3, 1}, { 3, 2},
-{ 3, 3}, { 3, 4}, { 3, 5}, { 3, 6}, { 3, 7}, { 3, 8}, { 3, 9}, { 3, 10},
-{ 3, 11}, { 4, 1}, { 4, 2}, { 4, 3}, { 4, 4}, { 4, 5}, { 4, 6}, { 5, 1},
-{ 5, 2}, { 5, 3}, { 5, 4}, { 5, 5}, { 6, 1}, { 6, 2}, { 6, 3}, { 6, 4},
-{ 7, 1}, { 7, 2}, { 7, 3}, { 7, 4}, { 8, 1}, { 8, 2}, { 8, 3}, { 8, 4},
-{ 9, 1}, { 9, 2}, { 9, 3}, { 9, 4}, { 10, 1}, { 10, 2}, { 10, 3}, { 11, 1},
-{ 11, 2}, { 11, 3}, { 12, 1}, { 12, 2}, { 12, 3}, { 13, 1}, { 13, 2}, { 13, 3},
-{ 14, 1}, { 14, 2}, { 14, 3}, { 15, 1}, { 15, 2}, { 15, 3}, { 16, 1}, { 16, 2},
-{ 17, 1}, { 17, 2}, { 18, 1}, { 19, 1}, { 20, 1}, { 21, 1}, { 22, 1}, { 23, 1},
-{ 24, 1}, { 25, 1}, { 26, 1}, { 27, 1}, { 28, 1}, { 29, 1}, { 30, 1}, { 0, 1},
-{ 0, 2}, { 0, 3}, { 0, 4}, { 0, 5}, { 0, 6}, { 1, 1}, { 1, 2}, { 1, 3},
-{ 1, 4}, { 1, 5}, { 2, 1}, { 2, 2}, { 2, 3}, { 2, 4}, { 3, 1}, { 3, 2},
-{ 3, 3}, { 3, 4}, { 4, 1}, { 4, 2}, { 4, 3}, { 5, 1}, { 5, 2}, { 6, 1},
-{ 6, 2}, { 7, 1}, { 7, 2}, { 8, 1}, { 8, 2}, { 9, 1}, { 9, 2}, { 10, 1},
-{ 10, 2}, { 11, 1}, { 11, 2}, { 12, 1}, { 12, 2}, { 13, 1}, { 13, 2}, { 14, 1},
-{ 14, 2}, { 15, 1}, { 15, 2}, { 16, 1}, { 17, 1}, { 18, 1}, { 19, 1}, { 20, 1},
-{ 21, 1}, { 22, 1}, { 23, 1}, { 24, 1}, { 25, 1}, { 26, 1}, { 27, 1}, { 28, 1},
-{ 29, 1}, { 30, 1}, { 31, 1}, { 32, 1}, { 33, 1}, { 34, 1}, { 35, 1}, { 36, 1},
-{ 37, 1}
-},
-{
-{ 0, 1}, { 0, 2}, { 0, 3}, { 0, 4}, { 0, 5}, { 0, 6}, { 0, 7}, { 0, 8},
-{ 0, 9}, { 0, 10}, { 0, 11}, { 0, 12}, { 0, 13}, { 0, 14}, { 0, 15}, { 0, 16},
-{ 0, 17}, { 0, 18}, { 0, 19}, { 0, 20}, { 0, 21}, { 0, 22}, { 0, 23}, { 1, 1},
-{ 1, 2}, { 1, 3}, { 1, 4}, { 1, 5}, { 1, 6}, { 1, 7}, { 1, 8}, { 1, 9},
-{ 1, 10}, { 1, 11}, { 2, 1}, { 2, 2}, { 2, 3}, { 2, 4}, { 2, 5}, { 2, 6},
-{ 2, 7}, { 2, 8}, { 3, 1}, { 3, 2}, { 3, 3}, { 3, 4}, { 3, 5}, { 3, 6},
-{ 3, 7}, { 4, 1}, { 4, 2}, { 4, 3}, { 4, 4}, { 4, 5}, { 5, 1}, { 5, 2},
-{ 5, 3}, { 5, 4}, { 5, 5}, { 6, 1}, { 6, 2}, { 6, 3}, { 6, 4}, { 7, 1},
-{ 7, 2}, { 7, 3}, { 7, 4}, { 8, 1}, { 8, 2}, { 8, 3}, { 9, 1}, { 9, 2},
-{ 9, 3}, { 10, 1}, { 10, 2}, { 10, 3}, { 11, 1}, { 11, 2}, { 11, 3}, { 12, 1},
-{ 12, 2}, { 13, 1}, { 13, 2}, { 14, 1}, { 14, 2}, { 15, 1}, { 15, 2}, { 16, 1},
-{ 16, 2}, { 17, 1}, { 18, 1}, { 19, 1}, { 20, 1}, { 21, 1}, { 22, 1}, { 23, 1},
-{ 24, 1}, { 25, 1}, { 26, 1}, { 0, 1}, { 0, 2}, { 0, 3}, { 0, 4}, { 0, 5},
-{ 0, 6}, { 0, 7}, { 0, 8}, { 0, 9}, { 1, 1}, { 1, 2}, { 1, 3}, { 1, 4},
-{ 1, 5}, { 2, 1}, { 2, 2}, { 2, 3}, { 2, 4}, { 3, 1}, { 3, 2}, { 3, 3},
-{ 3, 4}, { 4, 1}, { 4, 2}, { 4, 3}, { 5, 1}, { 5, 2}, { 5, 3}, { 6, 1},
-{ 6, 2}, { 6, 3}, { 7, 1}, { 7, 2}, { 8, 1}, { 8, 2}, { 9, 1}, { 9, 2},
-{ 10, 1}, { 10, 2}, { 11, 1}, { 11, 2}, { 12, 1}, { 12, 2}, { 13, 1}, { 13, 2},
-{ 14, 1}, { 14, 2}, { 15, 1}, { 16, 1}, { 17, 1}, { 18, 1}, { 19, 1}, { 20, 1},
-{ 21, 1}, { 22, 1}, { 23, 1}, { 24, 1}, { 25, 1}, { 26, 1}, { 27, 1}, { 28, 1},
-{ 29, 1}, { 30, 1}, { 31, 1}, { 32, 1}, { 33, 1}, { 34, 1}, { 35, 1}, { 36, 1}
-},
-{
-{ 0, 1}, { 0, 2}, { 0, 3}, { 0, 4}, { 0, 5}, { 0, 6}, { 0, 7}, { 0, 8},
-{ 0, 9}, { 0, 10}, { 0, 11}, { 0, 12}, { 0, 13}, { 0, 14}, { 0, 15}, { 0, 16},
-{ 1, 1}, { 1, 2}, { 1, 3}, { 1, 4}, { 1, 5}, { 1, 6}, { 1, 7}, { 1, 8},
-{ 1, 9}, { 1, 10}, { 1, 11}, { 2, 1}, { 2, 2}, { 2, 3}, { 2, 4}, { 2, 5},
-{ 2, 6}, { 2, 7}, { 2, 8}, { 3, 1}, { 3, 2}, { 3, 3}, { 3, 4}, { 3, 5},
-{ 3, 6}, { 3, 7}, { 4, 1}, { 4, 2}, { 4, 3}, { 4, 4}, { 4, 5}, { 5, 1},
-{ 5, 2}, { 5, 3}, { 5, 4}, { 6, 1}, { 6, 2}, { 6, 3}, { 6, 4}, { 7, 1},
-{ 7, 2}, { 7, 3}, { 8, 1}, { 8, 2}, { 8, 3}, { 9, 1}, { 9, 2}, { 9, 3},
-{ 10, 1}, { 10, 2}, { 10, 3}, { 11, 1}, { 11, 2}, { 11, 3}, { 12, 1}, { 12, 2},
-{ 12, 3}, { 13, 1}, { 13, 2}, { 13, 3}, { 14, 1}, { 14, 2}, { 15, 1}, { 15, 2},
-{ 16, 1}, { 17, 1}, { 18, 1}, { 19, 1}, { 20, 1}, { 0, 1}, { 0, 2}, { 0, 3},
-{ 0, 4}, { 1, 1}, { 1, 2}, { 1, 3}, { 1, 4}, { 2, 1}, { 2, 2}, { 2, 3},
-{ 3, 1}, { 3, 2}, { 3, 3}, { 4, 1}, { 4, 2}, { 5, 1}, { 5, 2}, { 6, 1},
-{ 6, 2}, { 7, 1}, { 7, 2}, { 8, 1}, { 8, 2}, { 9, 1}, { 9, 2}, { 10, 1},
-{ 10, 2}, { 11, 1}, { 11, 2}, { 12, 1}, { 12, 2}, { 13, 1}, { 13, 2}, { 14, 1},
-{ 15, 1}, { 16, 1}, { 17, 1}, { 18, 1}, { 19, 1}, { 20, 1}, { 21, 1}, { 22, 1},
-{ 23, 1}, { 24, 1}, { 25, 1}, { 26, 1}
-},
-{
-{ 0, 1}, { 0, 2}, { 0, 3}, { 0, 4}, { 0, 5}, { 0, 6}, { 0, 7}, { 0, 8},
-{ 0, 9}, { 0, 10}, { 0, 11}, { 0, 12}, { 0, 13}, { 0, 14}, { 1, 1}, { 1, 2},
-{ 1, 3}, { 1, 4}, { 1, 5}, { 1, 6}, { 1, 7}, { 1, 8}, { 1, 9}, { 2, 1},
-{ 2, 2}, { 2, 3}, { 2, 4}, { 2, 5}, { 3, 1}, { 3, 2}, { 3, 3}, { 3, 4},
-{ 4, 1}, { 4, 2}, { 4, 3}, { 4, 4}, { 5, 1}, { 5, 2}, { 5, 3}, { 5, 4},
-{ 6, 1}, { 6, 2}, { 6, 3}, { 7, 1}, { 7, 2}, { 7, 3}, { 8, 1}, { 8, 2},
-{ 8, 3}, { 9, 1}, { 9, 2}, { 9, 3}, { 10, 1}, { 10, 2}, { 10, 3}, { 11, 1},
-{ 11, 2}, { 11, 3}, { 12, 1}, { 12, 2}, { 12, 3}, { 13, 1}, { 13, 2}, { 14, 1},
-{ 14, 2}, { 15, 1}, { 15, 2}, { 16, 1}, { 17, 1}, { 18, 1}, { 19, 1}, { 20, 1},
-{ 21, 1}, { 22, 1}, { 23, 1}, { 24, 1}, { 25, 1}, { 26, 1}, { 27, 1}, { 28, 1},
-{ 29, 1}, { 0, 1}, { 0, 2}, { 0, 3}, { 0, 4}, { 0, 5}, { 1, 1}, { 1, 2},
-{ 1, 3}, { 1, 4}, { 2, 1}, { 2, 2}, { 2, 3}, { 3, 1}, { 3, 2}, { 3, 3},
-{ 4, 1}, { 4, 2}, { 5, 1}, { 5, 2}, { 6, 1}, { 6, 2}, { 7, 1}, { 7, 2},
-{ 8, 1}, { 8, 2}, { 9, 1}, { 9, 2}, { 10, 1}, { 10, 2}, { 11, 1}, { 11, 2},
-{ 12, 1}, { 12, 2}, { 13, 1}, { 13, 2}, { 14, 1}, { 14, 2}, { 15, 1}, { 15, 2},
-{ 16, 1}, { 17, 1}, { 18, 1}, { 19, 1}, { 20, 1}, { 21, 1}, { 22, 1}, { 23, 1},
-{ 24, 1}, { 25, 1}, { 26, 1}, { 27, 1}, { 28, 1}, { 29, 1}, { 30, 1}, { 31, 1},
-{ 32, 1}, { 33, 1}, { 34, 1}, { 35, 1}, { 36, 1}, { 37, 1}, { 38, 1}, { 39, 1},
-{ 40, 1}, { 41, 1}, { 42, 1}, { 43, 1}
-},
-{
-{ 0, 1}, { 0, 2}, { 0, 3}, { 0, 4}, { 0, 5}, { 0, 6}, { 0, 7}, { 0, 8},
-{ 0, 9}, { 0, 10}, { 0, 11}, { 0, 12}, { 0, 13}, { 0, 14}, { 0, 15}, { 0, 16},
-{ 0, 17}, { 0, 18}, { 0, 19}, { 0, 20}, { 0, 21}, { 0, 22}, { 0, 23}, { 0, 24},
-{ 0, 25}, { 0, 26}, { 0, 27}, { 1, 1}, { 1, 2}, { 1, 3}, { 1, 4}, { 1, 5},
-{ 1, 6}, { 1, 7}, { 1, 8}, { 1, 9}, { 1, 10}, { 2, 1}, { 2, 2}, { 2, 3},
-{ 2, 4}, { 2, 5}, { 3, 1}, { 3, 2}, { 3, 3}, { 3, 4}, { 4, 1}, { 4, 2},
-{ 4, 3}, { 5, 1}, { 5, 2}, { 5, 3}, { 6, 1}, { 6, 2}, { 6, 3}, { 7, 1},
-{ 7, 2}, { 7, 3}, { 8, 1}, { 8, 2}, { 9, 1}, { 9, 2}, { 10, 1}, { 11, 1},
-{ 12, 1}, { 13, 1}, { 14, 1}, { 0, 1}, { 0, 2}, { 0, 3}, { 0, 4}, { 0, 5},
-{ 0, 6}, { 0, 7}, { 0, 8}, { 1, 1}, { 1, 2}, { 1, 3}, { 2, 1}, { 2, 2},
-{ 3, 1}, { 3, 2}, { 4, 1}, { 4, 2}, { 5, 1}, { 5, 2}, { 6, 1}, { 6, 2},
-{ 7, 1}, { 8, 1}, { 9, 1}, { 10, 1}, { 11, 1}, { 12, 1}, { 13, 1}, { 14, 1},
-{ 15, 1}, { 16, 1}, { 17, 1}, { 18, 1}, { 19, 1}, { 20, 1}
-},
-{
-{ 0, 1}, { 0, 2}, { 0, 3}, { 0, 4}, { 0, 5}, { 0, 6}, { 0, 7}, { 0, 8},
-{ 0, 9}, { 0, 10}, { 0, 11}, { 0, 12}, { 1, 1}, { 1, 2}, { 1, 3}, { 1, 4},
-{ 1, 5}, { 1, 6}, { 2, 1}, { 2, 2}, { 2, 3}, { 2, 4}, { 3, 1}, { 3, 2},
-{ 3, 3}, { 4, 1}, { 4, 2}, { 4, 3}, { 5, 1}, { 5, 2}, { 5, 3}, { 6, 1},
-{ 6, 2}, { 6, 3}, { 7, 1}, { 7, 2}, { 8, 1}, { 8, 2}, { 9, 1}, { 9, 2},
-{ 10, 1}, { 10, 2}, { 11, 1}, { 12, 1}, { 13, 1}, { 14, 1}, { 15, 1}, { 16, 1},
-{ 17, 1}, { 18, 1}, { 19, 1}, { 20, 1}, { 21, 1}, { 22, 1}, { 23, 1}, { 24, 1},
-{ 25, 1}, { 26, 1}, { 0, 1}, { 0, 2}, { 0, 3}, { 1, 1}, { 1, 2}, { 2, 1},
-{ 3, 1}, { 4, 1}, { 5, 1}, { 6, 1}, { 7, 1}, { 8, 1}, { 9, 1}, { 10, 1},
-{ 11, 1}, { 12, 1}, { 13, 1}, { 14, 1}, { 15, 1}, { 16, 1}, { 17, 1}, { 18, 1},
-{ 19, 1}, { 20, 1}, { 21, 1}, { 22, 1}, { 23, 1}, { 24, 1}, { 25, 1}, { 26, 1},
-{ 27, 1}, { 28, 1}, { 29, 1}, { 30, 1}, { 31, 1}, { 32, 1}, { 33, 1}, { 34, 1},
-{ 35, 1}, { 36, 1}, { 37, 1}, { 38, 1}, { 39, 1}, { 40, 1}
-},
-{
-{ 0, 1}, { 0, 2}, { 0, 3}, { 0, 4}, { 0, 5}, { 0, 6}, { 0, 7}, { 0, 8},
-{ 0, 9}, { 0, 10}, { 0, 11}, { 0, 12}, { 0, 13}, { 0, 14}, { 0, 15}, { 0, 16},
-{ 0, 17}, { 0, 18}, { 0, 19}, { 0, 20}, { 0, 21}, { 0, 22}, { 0, 23}, { 0, 24},
-{ 0, 25}, { 0, 26}, { 0, 27}, { 0, 28}, { 0, 29}, { 0, 30}, { 0, 31}, { 0, 32},
-{ 0, 33}, { 0, 34}, { 0, 35}, { 0, 36}, { 0, 37}, { 0, 38}, { 0, 39}, { 0, 40},
-{ 0, 41}, { 0, 42}, { 0, 43}, { 0, 44}, { 0, 45}, { 0, 46}, { 0, 47}, { 0, 48},
-{ 0, 49}, { 0, 50}, { 0, 51}, { 0, 52}, { 0, 53}, { 0, 54}, { 0, 55}, { 0, 56},
-{ 1, 1}, { 1, 2}, { 1, 3}, { 1, 4}, { 1, 5}, { 1, 6}, { 1, 7}, { 1, 8},
-{ 1, 9}, { 1, 10}, { 1, 11}, { 1, 12}, { 1, 13}, { 1, 14}, { 1, 15}, { 1, 16},
-{ 1, 17}, { 1, 18}, { 1, 19}, { 1, 20}, { 2, 1}, { 2, 2}, { 2, 3}, { 2, 4},
-{ 2, 5}, { 2, 6}, { 2, 7}, { 2, 8}, { 2, 9}, { 2, 10}, { 3, 1}, { 3, 2},
-{ 3, 3}, { 3, 4}, { 3, 5}, { 3, 6}, { 3, 7}, { 4, 1}, { 4, 2}, { 4, 3},
-{ 4, 4}, { 4, 5}, { 4, 6}, { 5, 1}, { 5, 2}, { 5, 3}, { 5, 4}, { 5, 5},
-{ 6, 1}, { 6, 2}, { 6, 3}, { 6, 4}, { 7, 1}, { 7, 2}, { 7, 3}, { 8, 1},
-{ 8, 2}, { 8, 3}, { 9, 1}, { 9, 2}, { 9, 3}, { 10, 1}, { 10, 2}, { 11, 1},
-{ 11, 2}, { 12, 1}, { 12, 2}, { 13, 1}, { 13, 2}, { 14, 1}, { 0, 1}, { 0, 2},
-{ 0, 3}, { 0, 4}, { 1, 1}, { 1, 2}, { 1, 3}, { 2, 1}, { 2, 2}, { 2, 3},
-{ 3, 1}, { 3, 2}, { 4, 1}, { 4, 2}, { 5, 1}, { 5, 2}, { 6, 1}, { 6, 2},
-{ 7, 1}, { 7, 2}, { 8, 1}, { 8, 2}, { 9, 1}, { 9, 2}, { 10, 1}, { 10, 2},
-{ 11, 1}, { 11, 2}, { 12, 1}, { 12, 2}, { 13, 1}, { 13, 2}, { 14, 1}, { 14, 2},
-{ 15, 1}, { 16, 1}
-},
-{
-{ 0, 1}, { 0, 2}, { 0, 3}, { 0, 4}, { 0, 5}, { 0, 6}, { 0, 7}, { 0, 8},
-{ 0, 9}, { 0, 10}, { 0, 11}, { 0, 12}, { 0, 13}, { 0, 14}, { 0, 15}, { 0, 16},
-{ 0, 17}, { 0, 18}, { 0, 19}, { 0, 20}, { 0, 21}, { 0, 22}, { 0, 23}, { 0, 24},
-{ 0, 25}, { 0, 26}, { 0, 27}, { 0, 28}, { 0, 29}, { 0, 30}, { 0, 31}, { 0, 32},
-{ 1, 1}, { 1, 2}, { 1, 3}, { 1, 4}, { 1, 5}, { 1, 6}, { 1, 7}, { 1, 8},
-{ 1, 9}, { 1, 10}, { 1, 11}, { 1, 12}, { 1, 13}, { 2, 1}, { 2, 2}, { 2, 3},
-{ 2, 4}, { 2, 5}, { 2, 6}, { 2, 7}, { 2, 8}, { 3, 1}, { 3, 2}, { 3, 3},
-{ 3, 4}, { 3, 5}, { 3, 6}, { 4, 1}, { 4, 2}, { 4, 3}, { 4, 4}, { 4, 5},
-{ 5, 1}, { 5, 2}, { 5, 3}, { 5, 4}, { 6, 1}, { 6, 2}, { 6, 3}, { 6, 4},
-{ 7, 1}, { 7, 2}, { 7, 3}, { 8, 1}, { 8, 2}, { 8, 3}, { 9, 1}, { 9, 2},
-{ 9, 3}, { 10, 1}, { 10, 2}, { 11, 1}, { 11, 2}, { 12, 1}, { 12, 2}, { 13, 1},
-{ 13, 2}, { 14, 1}, { 14, 2}, { 15, 1}, { 15, 2}, { 16, 1}, { 16, 2}, { 17, 1},
-{ 17, 2}, { 18, 1}, { 18, 2}, { 19, 1}, { 19, 2}, { 20, 1}, { 20, 2}, { 21, 1},
-{ 21, 2}, { 22, 1}, { 22, 2}, { 23, 1}, { 24, 1}, { 0, 1}, { 0, 2}, { 0, 3},
-{ 0, 4}, { 1, 1}, { 1, 2}, { 1, 3}, { 2, 1}, { 2, 2}, { 2, 3}, { 3, 1},
-{ 3, 2}, { 3, 3}, { 4, 1}, { 4, 2}, { 5, 1}, { 5, 2}, { 6, 1}, { 6, 2},
-{ 7, 1}, { 7, 2}, { 8, 1}, { 8, 2}, { 9, 1}, { 9, 2}, { 10, 1}, { 10, 2},
-{ 11, 1}, { 11, 2}, { 12, 1}, { 12, 2}, { 13, 1}, { 13, 2}, { 14, 1}, { 14, 2},
-{ 15, 1}, { 15, 2}, { 16, 1}, { 16, 2}, { 17, 1}, { 17, 2}, { 18, 1}, { 18, 2},
-{ 19, 1}, { 19, 2}, { 20, 1}, { 20, 2}, { 21, 1}, { 21, 2}, { 22, 1}, { 22, 2},
-{ 23, 1}, { 23, 2}, { 24, 1}, { 24, 2}, { 25, 1}, { 25, 2}, { 26, 1}, { 26, 2},
-{ 27, 1}, { 27, 2}, { 28, 1}, { 28, 2}, { 29, 1}, { 30, 1}
-}
-};
-
-static const uint8_t vc1_delta_level_table[AC_MODES][31] = {
-{
- 19, 15, 12, 11, 6, 5, 4, 4, 4, 4,
- 3, 3, 3, 3, 3, 3, 2, 2, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1
-},
-{
- 23, 11, 8, 7, 5, 5, 4, 4, 3, 3,
- 3, 3, 2, 2, 2, 2, 2, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1
-},
-{
- 16, 11, 8, 7, 5, 4, 4, 3, 3, 3,
- 3, 3, 3, 3, 2, 2, 1, 1, 1, 1,
- 1
-},
-{
- 14, 9, 5, 4, 4, 4, 3, 3, 3, 3,
- 3, 3, 3, 2, 2, 2, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1
-},
-{
- 27, 10, 5, 4, 3, 3, 3, 3, 2, 2,
- 1, 1, 1, 1, 1
-},
-{
- 12, 6, 4, 3, 3, 3, 3, 2, 2, 2,
- 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1
-},
-{
- 56, 20, 10, 7, 6, 5, 4, 3, 3, 3,
- 2, 2, 2, 2, 1
-},
-{
- 32, 13, 8, 6, 5, 4, 4, 3, 3, 3,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 1, 1
-}
-};
-
-static const uint8_t vc1_last_delta_level_table[AC_MODES][44] = {
-{
- 6, 5, 4, 4, 3, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1
-},
-{
- 9, 5, 4, 4, 3, 3, 3, 2, 2, 2,
- 2, 2, 2, 2, 2, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1
-},
-{
- 4, 4, 3, 3, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1
-},
-{
- 5, 4, 3, 3, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 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
-},
-{
- 8, 3, 2, 2, 2, 2, 2, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1
-},
-{
- 3, 2, 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
-},
-{
- 4, 3, 3, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 1, 1
-},
-{
- 4, 3, 3, 3, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 1,
- 1
-}
-};
-
-static const uint8_t vc1_delta_run_table[AC_MODES][57] = {
-{
- -1, 30, 17, 15, 9, 5, 4, 3, 3, 3,
- 3, 3, 2, 1, 1, 1, 0, 0, 0,
- 0
-},
-{
- -1, 26, 16, 11, 7, 5, 3, 3, 2, 1,
- 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0
-},
-{
- -1, 20, 15, 13, 6, 4, 3, 3, 2, 1,
- 1, 1, 0, 0, 0, 0, 0
-},
-{
- -1, 29, 15, 12, 5, 2, 1, 1, 1, 1,
- 0, 0, 0, 0, 0
-},
-{
- -1, 14, 9, 7, 3, 2, 1, 1, 1, 1,
- 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0
-},
-{
- -1, 26, 10, 6, 2, 1, 1, 0, 0, 0,
- 0, 0, 0
-},
-{
- -1, 14, 13, 9, 6, 5, 4, 3, 2, 2,
- 2, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0
-},
-{
- -1, 24, 22, 9, 6, 4, 3, 2, 2, 1,
- 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0
-}
-};
-
-static const uint8_t vc1_last_delta_run_table[AC_MODES][10] = {
-{
- -1, 37, 15, 4, 3, 1, 0
-},
-{
- -1, 36, 14, 6, 3, 1, 0, 0, 0,
- 0
-},
-{
- -1, 26, 13, 3, 1
-},
-{
- -1, 43, 15, 3, 1, 0
-},
-{
- -1, 20, 6, 1, 0, 0, 0, 0, 0
-},
-{
- -1, 40, 1, 0
-},
-{
- -1, 16, 14, 2, 0
-},
-{
- -1, 30, 28, 3, 0
-}
-};
-
-#endif /* AVCODEC_VC1ACDATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/vc1data.c b/src/thirdparty/ffmpeg/libavcodec/vc1data.c
deleted file mode 100644
index 37729394b..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vc1data.c
+++ /dev/null
@@ -1,1135 +0,0 @@
-/*
- * VC-1 and WMV3 decoder
- * copyright (c) 2011 Mashiat Sarker Shakkhar
- * copyright (c) 2006 Konstantin Shishkov
- * (c) 2005 anonymous, Alex Beregszaszi, 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
- */
-
-/**
- * @file
- * VC-1 tables.
- */
-
-#include "avcodec.h"
-#include "vc1.h"
-#include "vc1data.h"
-
-/** Table for conversion between TTBLK and TTMB */
-const int ff_vc1_ttblk_to_tt[3][8] = {
- { TT_8X4, TT_4X8, TT_8X8, TT_4X4, TT_8X4_TOP, TT_8X4_BOTTOM, TT_4X8_RIGHT, TT_4X8_LEFT },
- { TT_8X8, TT_4X8_RIGHT, TT_4X8_LEFT, TT_4X4, TT_8X4, TT_4X8, TT_8X4_BOTTOM, TT_8X4_TOP },
- { TT_8X8, TT_4X8, TT_4X4, TT_8X4_BOTTOM, TT_4X8_RIGHT, TT_4X8_LEFT, TT_8X4, TT_8X4_TOP }
-};
-
-const int ff_vc1_ttfrm_to_tt[4] = { TT_8X8, TT_8X4, TT_4X8, TT_4X4 };
-
-/** MV P mode - the 5th element is only used for mode 1 */
-const uint8_t ff_vc1_mv_pmode_table[2][5] = {
- { MV_PMODE_1MV_HPEL_BILIN, MV_PMODE_1MV, MV_PMODE_1MV_HPEL, MV_PMODE_INTENSITY_COMP, MV_PMODE_MIXED_MV },
- { MV_PMODE_1MV, MV_PMODE_MIXED_MV, MV_PMODE_1MV_HPEL, MV_PMODE_INTENSITY_COMP, MV_PMODE_1MV_HPEL_BILIN }
-};
-const uint8_t ff_vc1_mv_pmode_table2[2][4] = {
- { MV_PMODE_1MV_HPEL_BILIN, MV_PMODE_1MV, MV_PMODE_1MV_HPEL, MV_PMODE_MIXED_MV },
- { MV_PMODE_1MV, MV_PMODE_MIXED_MV, MV_PMODE_1MV_HPEL, MV_PMODE_1MV_HPEL_BILIN }
-};
-
-/* MBMODE table for interlaced frame P-picture */
-const uint8_t ff_vc1_mbmode_intfrp[2][15][4] = {
- { /* 1: 4-MV, 0: non-4-MV */
- /* Type, FIELDTX, 1-MV Differential present, Residuals (CBP) present */
- /* Table 164 - Table 167 */
- { MV_PMODE_INTFR_1MV , 0, 1, 1 },
- { MV_PMODE_INTFR_1MV , 1, 1, 1 },
- { MV_PMODE_INTFR_1MV , 0, 1, 0 },
- { MV_PMODE_INTFR_1MV , 0, 0, 1 },
- { MV_PMODE_INTFR_1MV , 1, 0, 1 },
- { MV_PMODE_INTFR_2MV_FIELD, 0, 0, 1 },
- { MV_PMODE_INTFR_2MV_FIELD, 1, 0, 1 },
- { MV_PMODE_INTFR_2MV_FIELD, 0, 0, 0 },
- { MV_PMODE_INTFR_INTRA , 0, 0, 0 }
- },
- {
- /* Table 160 - Table 163 */
- { MV_PMODE_INTFR_1MV , 0, 1, 1 },
- { MV_PMODE_INTFR_1MV , 1, 1, 1 },
- { MV_PMODE_INTFR_1MV , 0, 1, 0 },
- { MV_PMODE_INTFR_1MV , 0, 0, 1 },
- { MV_PMODE_INTFR_1MV , 1, 0, 1 },
- { MV_PMODE_INTFR_2MV_FIELD, 0, 0, 1 },
- { MV_PMODE_INTFR_2MV_FIELD, 1, 0, 1 },
- { MV_PMODE_INTFR_2MV_FIELD, 0, 0, 0 },
- { MV_PMODE_INTFR_4MV , 0, 0, 1 },
- { MV_PMODE_INTFR_4MV , 1, 0, 1 },
- { MV_PMODE_INTFR_4MV , 0, 0, 0 },
- { MV_PMODE_INTFR_4MV_FIELD, 0, 0, 1 },
- { MV_PMODE_INTFR_4MV_FIELD, 1, 0, 1 },
- { MV_PMODE_INTFR_4MV_FIELD, 0, 0, 0 },
- { MV_PMODE_INTFR_INTRA , 0, 0, 0 }
- }
-};
-
-const int ff_vc1_fps_nr[7] = { 24, 25, 30, 50, 60, 48, 72 },
- ff_vc1_fps_dr[2] = { 1000, 1001 };
-const uint8_t ff_vc1_pquant_table[3][32] = {
- /* Implicit quantizer */
- { 0, 1, 2, 3, 4, 5, 6, 7, 8, 6, 7, 8, 9, 10, 11, 12,
- 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 29, 31 },
- /* Explicit quantizer, pquantizer uniform */
- { 0, 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 },
- /* Explicit quantizer, pquantizer non-uniform */
- { 0, 1, 1, 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, 29, 31 }
-};
-
-/** @name VC-1 VLC tables and defines
- * @todo TODO move this into the context
- */
-//@{
-#define VC1_BFRACTION_VLC_BITS 7
-VLC ff_vc1_bfraction_vlc;
-#define VC1_IMODE_VLC_BITS 4
-VLC ff_vc1_imode_vlc;
-#define VC1_NORM2_VLC_BITS 3
-VLC ff_vc1_norm2_vlc;
-#define VC1_NORM6_VLC_BITS 9
-VLC ff_vc1_norm6_vlc;
-/* Could be optimized, one table only needs 8 bits */
-#define VC1_TTMB_VLC_BITS 9 //12
-VLC ff_vc1_ttmb_vlc[3];
-#define VC1_MV_DIFF_VLC_BITS 9 //15
-VLC ff_vc1_mv_diff_vlc[4];
-#define VC1_CBPCY_P_VLC_BITS 9 //14
-VLC ff_vc1_cbpcy_p_vlc[4];
-#define VC1_ICBPCY_VLC_BITS 9
-VLC ff_vc1_icbpcy_vlc[8];
-#define VC1_4MV_BLOCK_PATTERN_VLC_BITS 6
-VLC ff_vc1_4mv_block_pattern_vlc[4];
-#define VC1_2MV_BLOCK_PATTERN_VLC_BITS 3
-VLC ff_vc1_2mv_block_pattern_vlc[4];
-#define VC1_TTBLK_VLC_BITS 5
-VLC ff_vc1_ttblk_vlc[3];
-#define VC1_SUBBLKPAT_VLC_BITS 6
-VLC ff_vc1_subblkpat_vlc[3];
-#define VC1_INTFR_4MV_MBMODE_VLC_BITS 9
-VLC ff_vc1_intfr_4mv_mbmode_vlc[4];
-#define VC1_INTFR_NON4MV_MBMODE_VLC_BITS 6
-VLC ff_vc1_intfr_non4mv_mbmode_vlc[4];
-#define VC1_IF_MMV_MBMODE_VLC_BITS 5
-VLC ff_vc1_if_mmv_mbmode_vlc[8];
-#define VC1_IF_1MV_MBMODE_VLC_BITS 5
-VLC ff_vc1_if_1mv_mbmode_vlc[8];
-#define VC1_1REF_MVDATA_VLC_BITS 9
-VLC ff_vc1_1ref_mvdata_vlc[4];
-#define VC1_2REF_MVDATA_VLC_BITS 9
-VLC ff_vc1_2ref_mvdata_vlc[8];
-
-VLC ff_vc1_ac_coeff_table[8];
-
-#define VC1_IF_MBMODE_VLC_BITS 5 // as a placeholder for VC1_IF_MMV_MBMODE_VLC_BITS
- // or VC1_IF_1MV_MBMODE_VLC_BITS since they are the same
-//@}
-
-
-#if B_FRACTION_DEN == 840 // original bfraction from vc9data.h, not conforming to standard
-/* bfraction is fractional, we scale to the GCD 3*5*7*8 = 840 */
-const int16_t ff_vc1_bfraction_lut[23] = {
- 420 /*1/2*/, 280 /*1/3*/, 560 /*2/3*/, 210 /*1/4*/,
- 630 /*3/4*/, 168 /*1/5*/, 336 /*2/5*/,
- 504 /*3/5*/, 672 /*4/5*/, 140 /*1/6*/, 700 /*5/6*/,
- 120 /*1/7*/, 240 /*2/7*/, 360 /*3/7*/, 480 /*4/7*/,
- 600 /*5/7*/, 720 /*6/7*/, 105 /*1/8*/, 315 /*3/8*/,
- 525 /*5/8*/, 735 /*7/8*/,
- -1 /*inv.*/, 0 /*BI fm*/
-};
-#else
-/* pre-computed scales for all bfractions and base=256 */
-const int16_t ff_vc1_bfraction_lut[23] = {
- 128 /*1/2*/, 85 /*1/3*/, 170 /*2/3*/, 64 /*1/4*/,
- 192 /*3/4*/, 51 /*1/5*/, 102 /*2/5*/,
- 153 /*3/5*/, 204 /*4/5*/, 43 /*1/6*/, 215 /*5/6*/,
- 37 /*1/7*/, 74 /*2/7*/, 111 /*3/7*/, 148 /*4/7*/,
- 185 /*5/7*/, 222 /*6/7*/, 32 /*1/8*/, 96 /*3/8*/,
- 160 /*5/8*/, 224 /*7/8*/,
- -1 /*inv.*/, 0 /*BI fm*/
-};
-#endif
-
-const uint8_t ff_vc1_bfraction_bits[23] = {
- 3, 3, 3, 3,
- 3, 3, 3,
- 7, 7, 7, 7,
- 7, 7, 7, 7,
- 7, 7, 7, 7,
- 7, 7,
- 7, 7
-};
-const uint8_t ff_vc1_bfraction_codes[23] = {
- 0, 1, 2, 3,
- 4, 5, 6,
- 112, 113, 114, 115,
- 116, 117, 118, 119,
- 120, 121, 122, 123,
- 124, 125,
- 126, 127
-};
-
-//Same as H.264
-const AVRational ff_vc1_pixel_aspect[16] = {
- { 0, 1 },
- { 1, 1 },
- { 12, 11 },
- { 10, 11 },
- { 16, 11 },
- { 40, 33 },
- { 24, 11 },
- { 20, 11 },
- { 32, 11 },
- { 80, 33 },
- { 18, 11 },
- { 15, 11 },
- { 64, 33 },
- { 160, 99 },
- { 0, 1 },
- { 0, 1 }
-};
-
-/* BitPlane IMODE - such a small table... */
-const uint8_t ff_vc1_imode_codes[7] = {
- 0, 2, 1, 3, 1, 2, 3
-};
-const uint8_t ff_vc1_imode_bits[7] = {
- 4, 2, 3, 2, 4, 3, 3
-};
-
-/* Normal-2 imode */
-const uint8_t ff_vc1_norm2_codes[4] = {
- 0, 4, 5, 3
-};
-const uint8_t ff_vc1_norm2_bits[4] = {
- 1, 3, 3, 2
-};
-
-const uint16_t ff_vc1_norm6_codes[64] = {
- 0x001, 0x002, 0x003, 0x000, 0x004, 0x001, 0x002, 0x047, 0x005, 0x003, 0x004, 0x04B, 0x005, 0x04D, 0x04E, 0x30E,
- 0x006, 0x006, 0x007, 0x053, 0x008, 0x055, 0x056, 0x30D, 0x009, 0x059, 0x05A, 0x30C, 0x05C, 0x30B, 0x30A, 0x037,
- 0x007, 0x00A, 0x00B, 0x043, 0x00C, 0x045, 0x046, 0x309, 0x00D, 0x049, 0x04A, 0x308, 0x04C, 0x307, 0x306, 0x036,
- 0x00E, 0x051, 0x052, 0x305, 0x054, 0x304, 0x303, 0x035, 0x058, 0x302, 0x301, 0x034, 0x300, 0x033, 0x032, 0x007,
-};
-
-const uint8_t ff_vc1_norm6_bits[64] = {
- 1, 4, 4, 8, 4, 8, 8, 10, 4, 8, 8, 10, 8, 10, 10, 13,
- 4, 8, 8, 10, 8, 10, 10, 13, 8, 10, 10, 13, 10, 13, 13, 9,
- 4, 8, 8, 10, 8, 10, 10, 13, 8, 10, 10, 13, 10, 13, 13, 9,
- 8, 10, 10, 13, 10, 13, 13, 9, 10, 13, 13, 9, 13, 9, 9, 6,
-};
-
-/* 4MV Block pattern VLC tables */
-const uint8_t ff_vc1_4mv_block_pattern_codes[4][16] = {
- { 14, 58, 59, 25, 12, 26, 15, 15, 13, 24, 27, 0, 28, 1, 2, 2 },
- { 8, 18, 19, 4, 20, 5, 30, 11, 21, 31, 6, 12, 7, 13, 14, 0 },
- { 15, 6, 7, 2, 8, 3, 28, 9, 10, 29, 4, 11, 5, 12, 13, 0 },
- { 0, 11, 12, 4, 13, 5, 30, 16, 14, 31, 6, 17, 7, 18, 19, 10 }
-};
-const uint8_t ff_vc1_4mv_block_pattern_bits[4][16] = {
- { 5, 6, 6, 5, 5, 5, 5, 4, 5, 5, 5, 3, 5, 3, 3, 2 },
- { 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4, 4, 4, 4, 4, 2 },
- { 4, 4, 4, 4, 4, 4, 5, 4, 4, 5, 4, 4, 4, 4, 4, 3 },
- { 2, 4, 4, 4, 4, 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4 }
-};
-
-/* 2MV Block pattern VLC tables */
-const uint8_t ff_vc1_2mv_block_pattern_codes[4][4] = {
- { 2, 1, 0, 3 }, { 1, 0, 2, 3 }, { 2, 0, 3, 1 }, { 1, 3, 2, 0 }
-};
-
-const uint8_t ff_vc1_2mv_block_pattern_bits[4][4] = {
- { 2, 2, 2, 2 }, { 1, 2, 3, 3 }, { 3, 2, 3, 1 }, { 1, 3, 3, 2 }
-};
-
-/* Interlaced frame picture 4MV MBMODE VLC tables (p. 246, p. 360) */
-const uint16_t ff_vc1_intfr_4mv_mbmode_codes[4][15] = {
- { 22, 17, 0, 47, 32, 10, 1, 3, 67, 133, 132, 92, 19, 93, 18 },
- { 3, 45, 0, 7, 23, 6, 1, 2, 10, 39, 44, 8, 18, 77, 76 },
- { 15, 6, 28, 9, 41, 6, 2, 15, 14, 8, 40, 29, 0, 21, 11 },
- { 7, 198, 1, 2, 193, 13, 25, 0, 97, 1599, 98, 398, 798, 192, 1598 }
-};
-
-const uint8_t ff_vc1_intfr_4mv_mbmode_bits[4][15] = {
- { 5, 5, 2, 6, 6, 4, 2, 2, 7, 8, 8, 7, 5, 7, 5 },
- { 3, 6, 3, 3, 5, 3, 3, 3, 4, 6, 6, 4, 5, 7, 7 },
- { 4, 3, 5, 5, 7, 4, 2, 5, 5, 5, 7, 5, 2, 6, 5 },
- { 4, 9, 1, 3, 9, 5, 6, 2, 8, 12, 8, 10, 11, 9, 12 }
-};
-
-/* Interlaced frame picture NON-4MV MBMODE VLC tables (p. 363) */
-const uint8_t ff_vc1_intfr_non4mv_mbmode_codes[4][9] = {
- { 9, 22, 0, 17, 16, 10, 1, 3, 23 },
- { 7, 0, 5, 2, 1, 1, 6, 3, 4 },
- { 1, 0, 10, 23, 44, 8, 3, 9, 45 },
- { 7, 97, 1, 2, 49, 13, 25, 0, 96 }
-};
-
-const uint8_t ff_vc1_intfr_non4mv_mbmode_bits[4][9] = {
- { 4, 5, 2, 5, 5, 4, 2, 2, 5 },
- { 3, 4, 6, 2, 3, 2, 3, 5, 6 },
- { 2, 2, 4, 5, 6, 4, 2, 4, 6 },
- { 4, 8, 1, 3, 7, 5, 6, 2, 8 }
-};
-
-/* Interlaced field picture MBMODE VLC tables (p. 356 - 11.4.1, 11.4.2) */
-/* mixed-MV */
-const uint8_t ff_vc1_if_mmv_mbmode_codes[8][8] = {
- { 16, 17, 3, 3, 0, 5, 9, 2 },
- { 8, 9, 3, 6, 7, 0, 5, 2 },
- { 16, 17, 5, 3, 0, 3, 9, 2 },
- { 56, 57, 15, 4, 5, 6, 29, 0 },
- { 52, 53, 27, 14, 15, 2, 12, 0 },
- { 56, 57, 29, 5, 6, 0, 15, 4 },
- { 16, 17, 6, 7, 0, 1, 9, 5 },
- { 56, 57, 0, 5, 6, 29, 4, 15 }
-};
-const uint8_t ff_vc1_if_mmv_mbmode_bits[8][8] = {
- { 6, 6, 2, 3, 2, 4, 5, 2 },
- { 5, 5, 3, 3, 3, 2, 4, 2 },
- { 6, 6, 4, 3, 2, 2, 5, 2 },
- { 6, 6, 4, 3, 3, 3, 5, 1 },
- { 6, 6, 5, 4, 4, 2, 4, 1 },
- { 6, 6, 5, 3, 3, 1, 4, 3 },
- { 5, 5, 3, 3, 2, 2, 4, 3 },
- { 6, 6, 1, 3, 3, 5, 3, 4 }
-};
-/* 1MV */
-const uint8_t ff_vc1_if_1mv_mbmode_codes[8][6] = {
- { 0, 1, 1, 1, 1, 1 },
- { 0, 1, 1, 1, 1, 1 },
- { 16, 17, 3, 0, 9, 5 },
- { 20, 21, 3, 11, 0, 4 },
- { 4, 5, 2, 3, 3, 0 },
- { 4, 5, 3, 2, 0, 3 },
- { 0, 1, 1, 1, 1, 1 },
- { 16, 17, 9, 5, 3, 0 }
-};
-const uint8_t ff_vc1_if_1mv_mbmode_bits[8][6] = {
- { 5, 5, 1, 3, 2, 4 },
- { 5, 5, 1, 2, 3, 4 },
- { 5, 5, 2, 1, 4, 3 },
- { 5, 5, 2, 4, 1, 3 },
- { 4, 4, 2, 3, 2, 2 },
- { 4, 4, 3, 2, 2, 2 },
- { 5, 5, 3, 4, 1, 2 },
- { 5, 5, 4, 3, 2, 1 }
-};
-
-/* Interlaced frame/field picture MVDATA VLC tables */
-
-/* 1-reference tables */
-const uint32_t ff_vc1_1ref_mvdata_codes[4][72] = { /* uint32_t may be too big */
- {
- 0x00005, 0x0000C, 0x0001E, 0x00012, 0x0000C, 0x00034, 0x00075, 0x00070,
- 0x00000, 0x00008, 0x0001B, 0x00008, 0x0001D, 0x0007C, 0x000D6, 0x001DE,
- 0x001AF, 0x00005, 0x0001B, 0x00026, 0x0001E, 0x00012, 0x00076, 0x0004D,
- 0x001F6, 0x001F4, 0x00039, 0x0007F, 0x00027, 0x0006A, 0x00071, 0x00035,
- 0x00071, 0x00068, 0x001DC, 0x00027, 0x00073, 0x000FF, 0x000E8, 0x000E9,
- 0x0007E, 0x001F9, 0x001F5, 0x001FD, 0x0003E, 0x001CA, 0x003F9, 0x0004C,
- 0x00069, 0x001FA, 0x001DF, 0x001F7, 0x00070, 0x001DD, 0x00E4D, 0x00727,
- 0x00392, 0x001C8, 0x001CB, 0x003F8, 0x001AE, 0x001F8, 0x001FB, 0x0E4CE,
- 0x0E4CF, 0x07260, 0x07261, 0x07262, 0x07263, 0x07264, 0x07265, 0x07266
- },
- {
- 0x00007, 0x00001, 0x00007, 0x00016, 0x00001, 0x00045, 0x00018, 0x002B6,
- 0x00006, 0x00004, 0x00017, 0x00010, 0x00029, 0x0002C, 0x0015A, 0x00066,
- 0x0019E, 0x00009, 0x00028, 0x00017, 0x00000, 0x0002A, 0x00004, 0x0005B,
- 0x000B5, 0x000CE, 0x00006, 0x00044, 0x0000F, 0x00046, 0x0000E, 0x000AC,
- 0x00032, 0x00037, 0x011EB, 0x0000A, 0x0001A, 0x0011F, 0x00016, 0x00014,
- 0x0002B, 0x00168, 0x00055, 0x023D5, 0x00057, 0x0002F, 0x00036, 0x0002E,
- 0x00169, 0x00054, 0x0047B, 0x0019F, 0x02B7D, 0x0008E, 0x00ADE, 0x00479,
- 0x0056E, 0x008F4, 0x015BF, 0x00478, 0x023D4, 0x0ADF1, 0x056F9, 0xADF0E,
- 0xADF0F, 0x56F80, 0x56F81, 0x56F82, 0x56F83, 0x56F84, 0x56F85, 0x56F86
- },
- {
- 0x00002, 0x00006, 0x00007, 0x0000D, 0x00007, 0x00030, 0x000FF, 0x001F0,
- 0x00002, 0x00000, 0x00005, 0x00019, 0x0001E, 0x00007, 0x00063, 0x000FD,
- 0x00023, 0x0000E, 0x0001B, 0x0001A, 0x00006, 0x00009, 0x00018, 0x000C5,
- 0x00033, 0x001F1, 0x00002, 0x003FB, 0x001F3, 0x00022, 0x001FC, 0x00042,
- 0x00623, 0x00083, 0x00620, 0x0007D, 0x00040, 0x00043, 0x003E4, 0x003E5,
- 0x00191, 0x00FE9, 0x00105, 0x00208, 0x000FC, 0x00624, 0x00622, 0x00190,
- 0x00626, 0x007F5, 0x00C4B, 0x01FD0, 0x0104D, 0x00065, 0x00C42, 0x000C9,
- 0x00627, 0x00C43, 0x00C4A, 0x0104E, 0x01FD1, 0x0104F, 0x00412, 0x104CE,
- 0x104CF, 0x08260, 0x08261, 0x08262, 0x08263, 0x08264, 0x08265, 0x08266
- },
- {
- 0x0000D, 0x00001, 0x00004, 0x00000, 0x00017, 0x00005, 0x0007F, 0x0004D,
- 0x00003, 0x00011, 0x0003E, 0x0003B, 0x00017, 0x00067, 0x0004A, 0x000C3,
- 0x000F2, 0x0000A, 0x0002C, 0x00032, 0x0003D, 0x00015, 0x00028, 0x00093,
- 0x000CC, 0x00096, 0x00003, 0x00075, 0x00020, 0x0002D, 0x00021, 0x00029,
- 0x00090, 0x001D0, 0x001FB, 0x0001C, 0x0004C, 0x00060, 0x00009, 0x00008,
- 0x0002D, 0x0009F, 0x001FA, 0x0013D, 0x00031, 0x000FC, 0x00058, 0x00092,
- 0x000F0, 0x000F1, 0x000CD, 0x00185, 0x00165, 0x0004E, 0x00091, 0x000E9,
- 0x00184, 0x001D1, 0x001E6, 0x00097, 0x001E7, 0x000B3, 0x0013C, 0x0164E,
- 0x0164F, 0x00B20, 0x00B21, 0x00B22, 0x00B23, 0x00B24, 0x00B25, 0x00B26
- }
-};
-
-const uint8_t ff_vc1_1ref_mvdata_bits[4][72] = {
- {
- 3, 4, 5, 5, 5, 6, 7, 7, 2, 4, 5, 5, 6, 7, 8, 9, 9, 4,
- 6, 6, 6, 6, 7, 8, 9, 9, 6, 8, 7, 7, 7, 7, 8, 8, 9, 6,
- 8, 8, 8, 8, 8, 9, 9, 9, 7, 10, 10, 8, 8, 9, 9, 9, 8, 9,
- 13, 12, 11, 10, 10, 10, 9, 9, 9, 17, 17, 16, 16, 16, 16, 16, 16, 16
- },
- {
- 3, 3, 4, 5, 5, 7, 8, 10, 3, 4, 5, 5, 6, 7, 9, 10, 12, 4,
- 6, 6, 5, 6, 6, 8, 9, 11, 4, 7, 7, 7, 7, 8, 9, 9, 13, 5,
- 8, 9, 8, 8, 9, 10, 10, 14, 7, 9, 9, 9, 10, 10, 11, 12, 14, 8,
- 12, 11, 11, 12, 13, 11, 14, 16, 15, 20, 20, 19, 19, 19, 19, 19, 19, 19
- },
- {
- 3, 4, 4, 4, 5, 6, 8, 9, 2, 4, 5, 5, 5, 6, 7, 8, 8, 4,
- 7, 7, 6, 6, 7, 8, 8, 9, 5, 10, 9, 8, 9, 9, 11, 10, 11, 7,
- 9, 9, 10, 10, 11, 12, 11, 12, 8, 11, 11, 11, 11, 11, 12, 13, 15, 9,
- 12, 10, 11, 12, 12, 15, 13, 15, 13, 19, 19, 18, 18, 18, 18, 18, 18, 18
- },
- {
- 4, 4, 4, 4, 5, 5, 7, 7, 3, 5, 6, 6, 6, 7, 7, 8, 8, 4,
- 6, 6, 6, 6, 7, 8, 8, 8, 4, 7, 6, 6, 6, 7, 8, 9, 9, 5,
- 7, 7, 6, 6, 7, 8, 9, 9, 6, 8, 8, 8, 8, 8, 8, 9, 10, 7,
- 8, 8, 9, 9, 9, 8, 9, 9, 9, 14, 14, 13, 13, 13, 13, 13, 13, 13
- }
-};
-
-/* 2-reference tables */
-const uint32_t ff_vc1_2ref_mvdata_codes[8][126] = { /* table 132 - table 139 */
- {
- 0x0000C, 0x0001C, 0x0000B, 0x00000, 0x0000E, 0x0002A, 0x00050, 0x00368,
- 0x00002, 0x0001A, 0x00004, 0x0003A, 0x0001D, 0x0006C, 0x000EF, 0x001BC,
- 0x0015F, 0x0000F, 0x00003, 0x0001C, 0x0000D, 0x0000B, 0x0003E, 0x000A7,
- 0x00146, 0x00199, 0x00006, 0x0001F, 0x00004, 0x0003C, 0x00007, 0x001BE,
- 0x0008B, 0x0002C, 0x007B3, 0x00005, 0x000DB, 0x00056, 0x000EC, 0x00052,
- 0x001BD, 0x00078, 0x000CF, 0x00573, 0x00009, 0x00023, 0x000ED, 0x00018,
- 0x00006, 0x00044, 0x000F5, 0x00079, 0x006D2, 0x0006E, 0x0002B, 0x0015D,
- 0x00017, 0x0037F, 0x00144, 0x000CE, 0x00028, 0x000AB, 0x00010, 0x001B5,
- 0x000F7, 0x000A6, 0x0007B, 0x00028, 0x001ED, 0x001E9, 0x006FD, 0x00004,
- 0x000F5, 0x00029, 0x0028A, 0x0028B, 0x0028F, 0x00DF9, 0x00335, 0x01E85,
- 0x000EE, 0x002BD, 0x0002B, 0x003D8, 0x003D1, 0x00198, 0x001E9, 0x0051D,
- 0x000B4, 0x0003F, 0x00455, 0x0022B, 0x00229, 0x00451, 0x00578, 0x007B2,
- 0x00570, 0x00155, 0x00032, 0x003D0, 0x00054, 0x006D3, 0x00571, 0x00454,
- 0x00334, 0x01BF1, 0x000B7, 0x00029, 0x01E84, 0x0016C, 0x0019B, 0x01BF0,
- 0x00579, 0x00F43, 0x000B5, 0x008A1, 0x0002A, 0x0016D, 0x008A0, 0x007A0,
- 0x003D1, 0x00AE5, 0x00154, 0x00AE4, 0x00A39, 0x00A38
- },
- {
- 0x00003, 0x00009, 0x00016, 0x00010, 0x000D7, 0x00335, 0x00574, 0x00555,
- 0x00000, 0x0001D, 0x00009, 0x00017, 0x0002C, 0x000AD, 0x00374, 0x006B3,
- 0x00577, 0x0000F, 0x00018, 0x0000A, 0x0002E, 0x00022, 0x0017C, 0x00E7B,
- 0x01B89, 0x015D8, 0x00008, 0x00034, 0x0006D, 0x00023, 0x001C2, 0x00376,
- 0x002D3, 0x01C4A, 0x0330A, 0x00014, 0x0006A, 0x00072, 0x0006C, 0x000E3,
- 0x0019B, 0x0073F, 0x01CF0, 0x00B41, 0x00032, 0x000E6, 0x000E0, 0x000CF,
- 0x000AB, 0x0019C, 0x002AB, 0x00E2B, 0x015D9, 0x0006F, 0x001C3, 0x000AF,
- 0x000BF, 0x000AC, 0x0017D, 0x006E3, 0x00E29, 0x01984, 0x00054, 0x000B5,
- 0x0017A, 0x001AD, 0x00199, 0x00178, 0x00358, 0x002D2, 0x01C4B, 0x0005B,
- 0x002A8, 0x00331, 0x00388, 0x0038B, 0x00370, 0x00713, 0x00CC3, 0x01CF1,
- 0x001B9, 0x005EF, 0x00738, 0x002F2, 0x0033B, 0x002B9, 0x006EB, 0x00570,
- 0x00E24, 0x0039D, 0x005A2, 0x005A3, 0x00E7D, 0x005EE, 0x00739, 0x00554,
- 0x00AA5, 0x00AA4, 0x00377, 0x01CF5, 0x00BCE, 0x00E79, 0x00660, 0x00674,
- 0x006EA, 0x00E7C, 0x00D65, 0x002F6, 0x015DA, 0x01B88, 0x005A1, 0x01CF4,
- 0x005E6, 0x00E28, 0x00575, 0x00D64, 0x00334, 0x0330B, 0x015DB, 0x00B40,
- 0x00BCF, 0x00DC5, 0x00E2A, 0x00675, 0x00571, 0x00553
- },
- {
- 0x00004, 0x00002, 0x00010, 0x00003, 0x00017, 0x00045, 0x0003E, 0x0007E,
- 0x00003, 0x00002, 0x00028, 0x0001E, 0x00015, 0x00047, 0x00002, 0x0014D,
- 0x00060, 0x0000B, 0x00026, 0x00024, 0x00014, 0x00032, 0x0006F, 0x000C3,
- 0x00531, 0x006E5, 0x00015, 0x0003F, 0x0002D, 0x00001, 0x0013E, 0x000DD,
- 0x000F6, 0x00305, 0x00331, 0x0000E, 0x00003, 0x00034, 0x00033, 0x0001A,
- 0x0014A, 0x000C5, 0x000F4, 0x006E4, 0x00001, 0x0003C, 0x0007D, 0x0008D,
- 0x0009D, 0x00031, 0x0006E, 0x00296, 0x000CD, 0x00025, 0x00149, 0x00032,
- 0x00089, 0x00036, 0x00088, 0x0006F, 0x00003, 0x0031D, 0x0000E, 0x001AA,
- 0x0027E, 0x00061, 0x0014E, 0x0014F, 0x00067, 0x000FF, 0x00183, 0x00036,
- 0x00357, 0x000F5, 0x000C6, 0x000C2, 0x00299, 0x00119, 0x00231, 0x00350,
- 0x0002C, 0x0018F, 0x00530, 0x00297, 0x00004, 0x001B8, 0x000C0, 0x0027A,
- 0x00311, 0x0009C, 0x00621, 0x00199, 0x0031C, 0x000F7, 0x003E3, 0x00356,
- 0x00189, 0x00005, 0x0006B, 0x008C2, 0x00330, 0x004FF, 0x004F0, 0x00351,
- 0x004F2, 0x001F2, 0x00373, 0x00000, 0x00C41, 0x008C3, 0x009EC, 0x003E2,
- 0x00304, 0x004F7, 0x004F1, 0x001F0, 0x00148, 0x00C40, 0x009ED, 0x008C0,
- 0x008C1, 0x004F3, 0x004FE, 0x000FE, 0x001F3, 0x001A9
- },
- {
- 0x00000, 0x00004, 0x0002F, 0x00052, 0x00010, 0x000AD, 0x0050B, 0x00190,
- 0x00003, 0x00016, 0x00007, 0x0000D, 0x000BB, 0x00173, 0x000C9, 0x0050F,
- 0x0172C, 0x00003, 0x00011, 0x00005, 0x00043, 0x00023, 0x0004B, 0x0032E,
- 0x02E5B, 0x00482, 0x00009, 0x0002A, 0x00014, 0x0002A, 0x00108, 0x005CA,
- 0x0065A, 0x02136, 0x02132, 0x0000B, 0x00013, 0x00041, 0x000B8, 0x00174,
- 0x00100, 0x014DA, 0x0404E, 0x01437, 0x0002B, 0x00085, 0x000A7, 0x000A0,
- 0x0014C, 0x0029A, 0x0032C, 0x02133, 0x0142A, 0x00051, 0x00284, 0x000AC,
- 0x00102, 0x00045, 0x00044, 0x0081B, 0x0065E, 0x00CB7, 0x00018, 0x0050C,
- 0x00212, 0x002E4, 0x00203, 0x00094, 0x00122, 0x0081A, 0x00655, 0x00033,
- 0x002BA, 0x00246, 0x00242, 0x00A6E, 0x0040C, 0x00808, 0x02134, 0x0404F,
- 0x00175, 0x00405, 0x00247, 0x0012A, 0x00A14, 0x002BB, 0x00191, 0x0084F,
- 0x01438, 0x000AF, 0x00B97, 0x00483, 0x0143B, 0x0032B, 0x00243, 0x0142B,
- 0x00958, 0x029BF, 0x00049, 0x00A6C, 0x014DB, 0x004AD, 0x014DE, 0x0084E,
- 0x01434, 0x00257, 0x02E5A, 0x00207, 0x01435, 0x01439, 0x00CB6, 0x0143A,
- 0x00194, 0x00654, 0x02135, 0x0537C, 0x0015C, 0x00240, 0x01012, 0x0537D,
- 0x00959, 0x01098, 0x01436, 0x0065F, 0x02026, 0x02137
- },
- {
- 0x00005, 0x00019, 0x00016, 0x00011, 0x0003E, 0x0005E, 0x000EF, 0x000E2,
- 0x00000, 0x00039, 0x0002B, 0x00026, 0x00028, 0x00012, 0x000C2, 0x000ED,
- 0x0011D, 0x0000D, 0x00031, 0x0002A, 0x00025, 0x00020, 0x0005C, 0x001ED,
- 0x0024D, 0x00770, 0x00006, 0x0007A, 0x00060, 0x0004F, 0x00048, 0x00039,
- 0x00186, 0x00213, 0x00EC6, 0x0000F, 0x00026, 0x0005F, 0x00075, 0x00070,
- 0x00027, 0x001DB, 0x003C6, 0x0078F, 0x0003F, 0x000A6, 0x000F0, 0x0003A,
- 0x00052, 0x0004E, 0x000E3, 0x001D9, 0x0030F, 0x00010, 0x001DD, 0x000A7,
- 0x000F7, 0x00022, 0x00092, 0x003C4, 0x002EF, 0x00762, 0x00079, 0x0008F,
- 0x001DA, 0x00087, 0x000E8, 0x000BA, 0x00176, 0x000EE, 0x003B0, 0x00085,
- 0x00119, 0x0030E, 0x00108, 0x001D2, 0x0010C, 0x00773, 0x00424, 0x00434,
- 0x00071, 0x005DD, 0x001C1, 0x003A7, 0x00127, 0x0008D, 0x0021B, 0x007B2,
- 0x001DF, 0x003D8, 0x00764, 0x00EE4, 0x003B3, 0x0074D, 0x001D8, 0x005DC,
- 0x0084A, 0x00499, 0x003C5, 0x01D8E, 0x00765, 0x00435, 0x00771, 0x001C2,
- 0x00118, 0x003BC, 0x00381, 0x00387, 0x07B33, 0x01097, 0x01096, 0x01ECD,
- 0x00E99, 0x00F1C, 0x00F1D, 0x00EE5, 0x0011C, 0x07B32, 0x03D98, 0x01D8F,
- 0x00E98, 0x00F67, 0x003BD, 0x00380, 0x00498, 0x00386
- },
- {
- 0x0000D, 0x00010, 0x0002E, 0x00039, 0x0000D, 0x00074, 0x000ED, 0x000B6,
- 0x00001, 0x00002, 0x00000, 0x00030, 0x00029, 0x00070, 0x000F3, 0x0008C,
- 0x00166, 0x00009, 0x00033, 0x00078, 0x00006, 0x000C4, 0x0000B, 0x00163,
- 0x000CC, 0x005BE, 0x0001F, 0x0002F, 0x00064, 0x00018, 0x000C6, 0x0000A,
- 0x00162, 0x002C0, 0x00EF3, 0x00007, 0x0000F, 0x000E3, 0x000CA, 0x000B2,
- 0x0018F, 0x003AE, 0x0075F, 0x00C51, 0x00015, 0x00047, 0x000EE, 0x000E2,
- 0x000EA, 0x00009, 0x0016A, 0x002C3, 0x0059D, 0x0003D, 0x00008, 0x001D9,
- 0x00032, 0x0000E, 0x0016E, 0x0032C, 0x0065B, 0x0196B, 0x00002, 0x0000F,
- 0x001D8, 0x0008D, 0x000B4, 0x001E4, 0x00067, 0x00317, 0x00794, 0x00022,
- 0x003BE, 0x00315, 0x00034, 0x00037, 0x002DE, 0x0006C, 0x00EFE, 0x0066C,
- 0x00028, 0x003CB, 0x003AC, 0x00035, 0x0016B, 0x003BD, 0x002C1, 0x0062C,
- 0x01DFE, 0x0000E, 0x0059E, 0x005BF, 0x000DA, 0x00629, 0x00584, 0x00EB7,
- 0x00B0A, 0x0066D, 0x0000C, 0x0077E, 0x0059C, 0x00778, 0x0075E, 0x0075A,
- 0x0062D, 0x00337, 0x00334, 0x00197, 0x01E57, 0x01DE4, 0x0196A, 0x01E56,
- 0x00C50, 0x00B3F, 0x01E54, 0x00B0B, 0x0018E, 0x001B6, 0x01E55, 0x00CB4,
- 0x00B3E, 0x00EB6, 0x01DE5, 0x01DFF, 0x00335, 0x001B7
- },
- {
- 0x00001, 0x0000B, 0x00019, 0x0006F, 0x0002A, 0x00075, 0x007EB, 0x00163,
- 0x00001, 0x0000E, 0x0001A, 0x0003E, 0x0001C, 0x0002D, 0x00164, 0x007EC,
- 0x00165, 0x00004, 0x00006, 0x00036, 0x0007F, 0x000AE, 0x00158, 0x0015C,
- 0x0056D, 0xFD510, 0x00000, 0x00004, 0x0007B, 0x000F3, 0x0003B, 0x007ED,
- 0x002B3, 0x002CC, 0x0056E, 0x00018, 0x0003E, 0x00017, 0x0001E, 0x000AF,
- 0x003F7, 0x0056F, 0x002CD, 0xFD511, 0x00014, 0x000AD, 0x000AA, 0x00014,
- 0x000A8, 0x00153, 0x000E8, 0x001FE, 0x00DCF, 0x00078, 0x001B8, 0x00152,
- 0x000FE, 0x002B1, 0x0015D, 0x00160, 0xFD512, 0xFD513, 0x0007A, 0x002B0,
- 0x001E5, 0x000E9, 0x000FC, 0x006E6, 0x00DC8, 0x00584, 0xFD514, 0x000AB,
- 0x00DDE, 0x00159, 0x003F4, 0x00DC9, 0x00DCA, 0x001FA, 0xFD515, 0xFD516,
- 0x000FC, 0x001FF, 0x001E4, 0x000AF, 0x0015A, 0x00167, 0x00DCB, 0x00585,
- 0xFD517, 0x003F7, 0x03F55, 0xFD518, 0x00DDC, 0x00586, 0x03F56, 0xFD519,
- 0x03F57, 0xFD51A, 0x001BA, 0x00587, 0x00588, 0x00DDF, 0x002B2, 0xFD51B,
- 0x00DCE, 0x003F6, 0xFD51C, 0x00FD4, 0xFD51D, 0xFD51E, 0xFD51F, 0x7EA80,
- 0x7EA81, 0x0056C, 0x7EA82, 0x7EA83, 0x00376, 0x00589, 0x0058A, 0x7EA84,
- 0x7EA85, 0x00DDD, 0x7EA86, 0x7EA87, 0x0058B, 0x07EA9
- },
- {
- 0x00003, 0x0000E, 0x0000F, 0x0007E, 0x00062, 0x000C6, 0x00CD9, 0x0063E,
- 0x00002, 0x00002, 0x00000, 0x00018, 0x0000C, 0x00069, 0x00039, 0x00707,
- 0x00C7E, 0x00002, 0x0000D, 0x0001B, 0x0000F, 0x0019A, 0x00647, 0x01A37,
- 0x346C4, 0x0346D, 0x00001, 0x0001E, 0x0007F, 0x0000A, 0x000E1, 0x00661,
- 0x00CE4, 0x346C5, 0x346C6, 0x0001D, 0x00030, 0x0000D, 0x000CB, 0x00199,
- 0x00320, 0x0008E, 0x0652E, 0x346C7, 0x0003E, 0x00039, 0x00035, 0x00033,
- 0x0019F, 0x001C0, 0x00CDA, 0x346C8, 0x346C9, 0x0000B, 0x000D0, 0x0019E,
- 0x00022, 0x00038, 0x0018E, 0x0031E, 0x03294, 0x0023C, 0x00032, 0x00012,
- 0x00013, 0x00071, 0x0019D, 0x00020, 0x00C87, 0x00CC0, 0x346CA, 0x00338,
- 0x00653, 0x001A2, 0x0032A, 0x00322, 0x00CE7, 0x00084, 0x0011F, 0x346CB,
- 0x00325, 0x00649, 0x0032B, 0x00077, 0x00648, 0x00642, 0x00C86, 0x00C8C,
- 0x346CC, 0x0003A, 0x019B7, 0x00043, 0x00327, 0x0008C, 0x0008D, 0x00C8D,
- 0x346CD, 0x346CE, 0x00337, 0x00CE5, 0x00085, 0x00326, 0x00347, 0x00CA4,
- 0x00C7F, 0x00D1A, 0x346CF, 0x00328, 0x1A360, 0x1A361, 0x00CD8, 0x0068C,
- 0x03295, 0x03296, 0x0652F, 0x066D8, 0x00331, 0x00706, 0x0023D, 0x00076,
- 0x00CC1, 0x00382, 0x00CE6, 0x066D9, 0x066DA, 0x066DB
- }
-};
-
-const uint8_t ff_vc1_2ref_mvdata_bits[8][126] = {
- {
- 4, 5, 5, 5, 6, 7, 8, 10, 2, 5, 5, 6, 6, 7, 8, 9,
- 10, 4, 5, 6, 6, 7, 8, 9, 10, 11, 4, 6, 6, 7, 7, 9,
- 9, 10, 12, 5, 8, 8, 8, 8, 9, 9, 10, 12, 5, 7, 8, 7,
- 7, 8, 9, 9, 11, 7, 9, 10, 9, 10, 10, 10, 10, 12, 6, 9,
- 9, 9, 9, 9, 10, 10, 11, 7, 10, 10, 11, 11, 11, 12, 12, 14,
- 8, 11, 10, 11, 11, 11, 11, 12, 12, 8, 12, 11, 11, 12, 12, 12,
- 12, 13, 8, 12, 11, 11, 12, 12, 12, 13, 12, 9, 14, 13, 11, 13,
- 12, 13, 12, 13, 9, 13, 13, 12, 12, 13, 13, 13, 13, 13
- },
- {
- 3, 4, 5, 6, 8, 10, 11, 11, 2, 5, 5, 6, 7, 8, 10, 11,
- 11, 4, 5, 5, 6, 7, 9, 12, 13, 13, 4, 6, 7, 7, 9, 10,
- 11, 13, 14, 5, 7, 7, 7, 8, 9, 11, 13, 13, 6, 8, 8, 8,
- 8, 9, 10, 12, 13, 7, 9, 8, 8, 8, 9, 11, 12, 13, 7, 9,
- 9, 9, 9, 9, 10, 11, 13, 8, 10, 10, 10, 10, 10, 11, 12, 13,
- 9, 11, 11, 10, 10, 10, 11, 11, 12, 10, 12, 12, 12, 11, 11, 11,
- 12, 12, 10, 13, 12, 12, 11, 11, 11, 12, 12, 10, 13, 13, 12, 13,
- 11, 12, 11, 12, 10, 14, 13, 13, 12, 12, 12, 11, 11, 11
- },
- {
- 4, 4, 5, 5, 6, 7, 8, 9, 2, 5, 6, 6, 6, 7, 7, 9,
- 9, 4, 6, 6, 6, 7, 8, 9, 11, 12, 5, 7, 7, 7, 9, 9,
- 10, 11, 12, 5, 7, 7, 7, 7, 9, 9, 10, 12, 5, 8, 8, 8,
- 8, 8, 9, 10, 10, 6, 9, 8, 8, 8, 8, 9, 9, 11, 6, 10,
- 10, 9, 9, 9, 9, 10, 10, 7, 11, 10, 9, 9, 10, 9, 10, 11,
- 7, 10, 11, 10, 10, 10, 9, 10, 11, 8, 12, 11, 11, 10, 11, 11,
- 10, 10, 8, 12, 12, 11, 11, 11, 11, 10, 11, 8, 13, 12, 12, 11,
- 11, 11, 11, 10, 9, 13, 12, 12, 12, 11, 11, 10, 10, 10
- },
- {
- 3, 4, 6, 7, 7, 9, 11, 11, 2, 5, 5, 6, 8, 9, 10, 11,
- 13, 3, 5, 5, 7, 8, 9, 12, 14, 13, 4, 6, 6, 7, 9, 11,
- 13, 14, 14, 5, 7, 7, 8, 9, 9, 13, 15, 13, 6, 8, 8, 8,
- 9, 10, 12, 14, 13, 7, 10, 9, 9, 9, 9, 12, 13, 14, 7, 11,
- 10, 10, 10, 10, 11, 12, 13, 8, 11, 12, 12, 12, 11, 12, 14, 15,
- 9, 11, 12, 11, 12, 11, 11, 12, 13, 9, 12, 13, 13, 12, 12, 13,
- 14, 14, 9, 12, 13, 13, 13, 12, 13, 12, 14, 10, 13, 13, 14, 13,
- 11, 13, 14, 15, 10, 12, 13, 15, 14, 13, 13, 13, 14, 14
- },
- {
- 4, 5, 5, 5, 6, 7, 8, 8, 2, 6, 6, 6, 6, 6, 8, 9,
- 10, 4, 6, 6, 6, 6, 7, 9, 10, 11, 4, 7, 7, 7, 7, 7,
- 9, 10, 12, 5, 7, 7, 7, 7, 7, 9, 10, 11, 6, 8, 8, 7,
- 7, 7, 8, 9, 10, 6, 9, 8, 8, 7, 8, 10, 10, 11, 7, 9,
- 9, 8, 8, 8, 9, 9, 10, 8, 10, 10, 9, 9, 9, 11, 11, 11,
- 8, 11, 10, 10, 9, 9, 10, 11, 10, 10, 12, 12, 11, 11, 10, 11,
- 12, 11, 10, 13, 12, 11, 11, 10, 10, 11, 11, 11, 15, 13, 13, 13,
- 12, 12, 12, 12, 10, 15, 14, 13, 12, 12, 11, 11, 11, 11
- },
- {
- 4, 5, 6, 6, 6, 7, 8, 8, 2, 4, 5, 6, 6, 7, 8, 8,
- 9, 4, 6, 7, 7, 8, 8, 9, 10, 11, 5, 6, 7, 7, 8, 8,
- 9, 10, 12, 5, 7, 8, 8, 8, 9, 10, 11, 12, 5, 7, 8, 8,
- 8, 8, 9, 10, 11, 6, 8, 9, 8, 8, 9, 10, 11, 13, 5, 8,
- 9, 8, 8, 9, 9, 10, 11, 6, 10, 10, 9, 9, 10, 10, 12, 13,
- 6, 10, 10, 9, 9, 10, 10, 11, 13, 7, 11, 11, 11, 11, 11, 12,
- 12, 13, 7, 11, 11, 11, 11, 11, 11, 12, 12, 9, 13, 13, 13, 13,
- 12, 12, 13, 12, 9, 12, 13, 12, 12, 12, 13, 13, 12, 12
- },
- {
- 3, 5, 6, 8, 9, 10, 12, 12, 1, 5, 6, 7, 8, 9, 12, 12,
- 12, 4, 6, 7, 8, 9, 12, 12, 14, 21, 4, 6, 8, 9, 9, 12,
- 13, 13, 14, 6, 9, 8, 8, 9, 13, 14, 13, 21, 6, 9, 9, 8,
- 9, 10, 11, 12, 13, 8, 10, 10, 11, 11, 12, 12, 21, 21, 8, 11,
- 10, 11, 11, 12, 13, 14, 21, 9, 13, 10, 11, 13, 13, 12, 21, 21,
- 9, 12, 10, 11, 12, 12, 13, 14, 21, 11, 15, 21, 13, 14, 15, 21,
- 15, 21, 10, 14, 14, 13, 13, 21, 13, 13, 21, 13, 21, 21, 21, 20,
- 20, 14, 20, 20, 11, 14, 14, 20, 20, 13, 20, 20, 14, 16
- },
- {
- 2, 5, 6, 8, 9, 10, 13, 13, 2, 4, 5, 6, 8, 9, 10, 13,
- 14, 3, 5, 7, 8, 10, 12, 15, 20, 16, 4, 6, 8, 8, 10, 12,
- 13, 20, 20, 7, 8, 8, 9, 10, 11, 12, 16, 20, 7, 8, 8, 8,
- 10, 11, 13, 20, 20, 8, 10, 10, 10, 10, 11, 12, 15, 14, 8, 9,
- 9, 9, 10, 10, 13, 13, 20, 11, 12, 11, 11, 11, 13, 12, 13, 20,
- 11, 12, 11, 11, 12, 12, 13, 13, 20, 10, 14, 11, 11, 12, 12, 13,
- 20, 20, 11, 13, 12, 11, 12, 13, 14, 14, 20, 11, 19, 19, 13, 13,
- 15, 15, 16, 16, 11, 13, 14, 11, 13, 12, 13, 16, 16, 16
- }
-};
-
-const uint8_t ff_wmv3_dc_scale_table[32] = {
- 0, 2, 4, 8, 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
-};
-
-/* P-Picture CBPCY VLC tables */
-// Looks like original tables are not conforming to standard at all. Are they used for old WMV?
-const uint16_t ff_vc1_cbpcy_p_codes[4][64] = {
- {
- 0, 6, 15, 13, 13, 11, 3, 13, 5, 8, 49, 10, 12, 114, 102, 119,
- 1, 54, 96, 8, 10, 111, 5, 15, 12, 10, 2, 12, 13, 115, 53, 63,
- 1, 7, 1, 7, 14, 12, 4, 14, 1, 9, 97, 11, 7, 58, 52, 62,
- 4, 103, 1, 9, 11, 56, 101, 118, 4, 110, 100, 30, 2, 5, 4, 3
- },
- {
- 0, 9, 1, 18, 5, 14, 237, 26, 3, 121, 3, 22, 13, 16, 6, 30,
- 2, 10, 1, 20, 12, 241, 5, 28, 16, 12, 3, 24, 28, 124, 239, 247,
- 1, 240, 1, 19, 18, 15, 4, 27, 1, 122, 2, 23, 1, 17, 7, 31,
- 1, 11, 2, 21, 19, 246, 238, 29, 17, 13, 236, 25, 58, 63, 8, 125
- },
- {
- 0, 201, 25, 231, 5, 221, 1, 3, 2, 414, 2, 241, 16, 225, 195, 492,
- 2, 412, 1, 240, 7, 224, 98, 245, 1, 220, 96, 5, 9, 230, 101, 247,
- 1, 102, 1, 415, 24, 3, 2, 244, 3, 54, 3, 484, 17, 114, 200, 493,
- 3, 413, 1, 4, 13, 113, 99, 485, 4, 111, 194, 243, 5, 29, 26, 31
- },
- {
- 0, 28, 12, 44, 3, 36, 20, 52, 2, 32, 16, 48, 8, 40, 24, 28,
- 1, 30, 14, 46, 6, 38, 22, 54, 3, 34, 18, 50, 10, 42, 26, 30,
- 1, 29, 13, 45, 5, 37, 21, 53, 2, 33, 17, 49, 9, 41, 25, 29,
- 1, 31, 15, 47, 7, 39, 23, 55, 4, 35, 19, 51, 11, 43, 27, 31
- }
-};
-
-const uint8_t ff_vc1_cbpcy_p_bits[4][64] = {
- {
- 13, 13, 7, 13, 7, 13, 13, 12, 6, 13, 7, 12, 6, 8, 8, 8,
- 5, 7, 8, 12, 6, 8, 13, 12, 7, 13, 13, 12, 6, 8, 7, 7,
- 6, 13, 8, 12, 7, 13, 13, 12, 7, 13, 8, 12, 5, 7, 7, 7,
- 6, 8, 13, 12, 6, 7, 8, 8, 5, 8, 8, 6, 3, 3, 3, 2
- },
- {
- 14, 13, 8, 13, 3, 13, 8, 13, 3, 7, 8, 13, 4, 13, 13, 13,
- 3, 13, 13, 13, 4, 8, 13, 13, 5, 13, 13, 13, 5, 7, 8, 8,
- 3, 8, 14, 13, 5, 13, 13, 13, 4, 7, 13, 13, 6, 13, 13, 13,
- 5, 13, 8, 13, 5, 8, 8, 13, 5, 13, 8, 13, 6, 6, 13, 7
- },
- {
- 13, 8, 6, 8, 4, 8, 13, 12, 4, 9, 8, 8, 5, 8, 8, 9,
- 5, 9, 10, 8, 4, 8, 7, 8, 6, 8, 7, 13, 4, 8, 7, 8,
- 5, 7, 8, 9, 6, 13, 13, 8, 4, 6, 8, 9, 5, 7, 8, 9,
- 5, 9, 9, 13, 5, 7, 7, 9, 4, 7, 8, 8, 3, 5, 5, 5
- },
- {
- 9, 9, 9, 9, 2, 9, 9, 9, 2, 9, 9, 9, 9, 9, 9, 8,
- 3, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8,
- 2, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8
- }
-};
-
-/* Interlaced CBPCY VLC tables (Table 124 - Table 131) */
-const uint16_t ff_vc1_icbpcy_p_codes[8][63] = {
- {
- 0x2F1A, 0x2F1B, 0x178C, 0x0090, 0x02A8, 0x02A9, 0x0BC7, 0x0091,
- 0x02AA, 0x02AB, 0x05E0, 0x004A, 0x0096, 0x0097, 0x00BD, 0x0092,
- 0x02AC, 0x02AD, 0x05E1, 0x0098, 0x0132, 0x0133, 0x0179, 0x0134,
- 0x026A, 0x026B, 0x02FC, 0x004E, 0x0040, 0x0041, 0x002B, 0x0093,
- 0x02AE, 0x02AF, 0x05E2, 0x0136, 0x026E, 0x026F, 0x02FD, 0x009E,
- 0x013E, 0x013F, 0x017F, 0x0050, 0x0042, 0x0043, 0x002C, 0x0051,
- 0x00A4, 0x00A5, 0x00BE, 0x0053, 0x0044, 0x0045, 0x002D, 0x0054,
- 0x0046, 0x0047, 0x002E, 0x0003, 0x0000, 0x0001, 0x0001
- },
- {
- 0x0041, 0x0042, 0x0100, 0x0043, 0x0088, 0x0089, 0x0101, 0x0045,
- 0x008C, 0x008D, 0x0102, 0x0010, 0x0022, 0x0023, 0x0024, 0x0047,
- 0x0010, 0x0011, 0x0103, 0x0025, 0x0058, 0x0059, 0x005A, 0x005B,
- 0x005A, 0x005B, 0x005C, 0x000C, 0x0030, 0x0031, 0x0019, 0x0009,
- 0x0014, 0x0015, 0x002C, 0x005C, 0x005D, 0x005E, 0x005F, 0x0026,
- 0x005D, 0x005E, 0x005F, 0x000D, 0x0034, 0x0035, 0x001B, 0x0014,
- 0x0027, 0x002A, 0x002B, 0x000E, 0x0038, 0x0039, 0x001D, 0x000F,
- 0x003C, 0x003D, 0x001F, 0x0005, 0x0009, 0x0000, 0x0003
- },
- {
- 0x0032, 0x0033, 0x001A, 0x0026, 0x00E4, 0x00E5, 0x01E6, 0x0027,
- 0x00E6, 0x00E7, 0x01E7, 0x000E, 0x0063, 0x006C, 0x0077, 0x0028,
- 0x00E8, 0x00E9, 0x01E8, 0x007B, 0x00DA, 0x00DB, 0x00EC, 0x00F5,
- 0x01B8, 0x01B9, 0x01DA, 0x0021, 0x004B, 0x0054, 0x002B, 0x0029,
- 0x00EA, 0x00EB, 0x01E9, 0x004A, 0x01BA, 0x01BB, 0x01DB, 0x0020,
- 0x00DE, 0x00DF, 0x00F2, 0x0022, 0x0055, 0x0058, 0x002D, 0x000F,
- 0x0070, 0x0071, 0x0078, 0x0023, 0x0059, 0x005C, 0x002F, 0x0024,
- 0x005D, 0x0062, 0x0030, 0x0002, 0x001F, 0x0006, 0x0000
- },
- {
- 0x0028, 0x0029, 0x009D, 0x0000, 0x01EA, 0x01EB, 0x01EC, 0x0001,
- 0x01ED, 0x01EE, 0x01EF, 0x0005, 0x00F0, 0x00F1, 0x003B, 0x0002,
- 0x01F0, 0x01F1, 0x01F2, 0x003F, 0x015C, 0x015D, 0x0099, 0x0010,
- 0x03D0, 0x03D1, 0x0130, 0x000F, 0x009E, 0x009F, 0x00FB, 0x0003,
- 0x01F3, 0x01F4, 0x01F5, 0x0011, 0x03D2, 0x03D3, 0x0131, 0x0009,
- 0x015E, 0x015F, 0x009C, 0x0010, 0x00A8, 0x00A9, 0x0038, 0x0006,
- 0x00F2, 0x00F3, 0x004D, 0x0011, 0x00AA, 0x00AB, 0x0039, 0x0012,
- 0x00AC, 0x00AD, 0x003A, 0x0006, 0x0016, 0x0017, 0x000E
- },
- {
- 0x003C, 0x003D, 0x001F, 0x000A, 0x0061, 0x0062, 0x0002, 0x000B,
- 0x0063, 0x0064, 0x0003, 0x0007, 0x0003, 0x0004, 0x000B, 0x000C,
- 0x0065, 0x0066, 0x0004, 0x0012, 0x000A, 0x000B, 0x0014, 0x001B,
- 0x0018, 0x0019, 0x0034, 0x002C, 0x0067, 0x0068, 0x0035, 0x000D,
- 0x0069, 0x006C, 0x0005, 0x0060, 0x001A, 0x001B, 0x0035, 0x0013,
- 0x000E, 0x000F, 0x0015, 0x002D, 0x006D, 0x006E, 0x0038, 0x0008,
- 0x0008, 0x0009, 0x000C, 0x002E, 0x006F, 0x0072, 0x003A, 0x002F,
- 0x0073, 0x0000, 0x003B, 0x0007, 0x0014, 0x0015, 0x0004
- },
- {
- 0x0038, 0x0039, 0x009D, 0x000A, 0x0091, 0x0092, 0x0093, 0x000B,
- 0x0094, 0x0095, 0x0096, 0x0003, 0x00EE, 0x00EF, 0x0036, 0x000C,
- 0x0097, 0x0098, 0x0099, 0x0008, 0x01E4, 0x01E5, 0x006A, 0x0018,
- 0x03CC, 0x03CD, 0x00D6, 0x000E, 0x009E, 0x009F, 0x00F5, 0x000D,
- 0x009A, 0x009B, 0x009C, 0x0019, 0x03CE, 0x03CF, 0x00D7, 0x0009,
- 0x01E8, 0x01E9, 0x0090, 0x000F, 0x00E8, 0x00E9, 0x00F6, 0x0005,
- 0x00F0, 0x00F1, 0x0037, 0x0010, 0x00EA, 0x00EB, 0x00F7, 0x0011,
- 0x00EC, 0x00ED, 0x0034, 0x0000, 0x003E, 0x003F, 0x0002
- },
- {
- 0x003C, 0x003D, 0x01CF, 0x0000, 0x00BF, 0x00E0, 0x01FC, 0x0001,
- 0x00E1, 0x00E2, 0x01FD, 0x0009, 0x01F1, 0x01F2, 0x01F3, 0x0002,
- 0x00E3, 0x00E4, 0x01FE, 0x0011, 0x03EE, 0x03EF, 0x03F0, 0x0021,
- 0x07E2, 0x07E3, 0x07E4, 0x0018, 0x03F7, 0x03FE, 0x03FF, 0x0003,
- 0x00E5, 0x00E6, 0x0080, 0x002E, 0x07E5, 0x07E6, 0x07E7, 0x0016,
- 0x03F4, 0x03F5, 0x03F6, 0x0019, 0x0102, 0x0103, 0x0104, 0x000A,
- 0x01F4, 0x01F5, 0x01F6, 0x001A, 0x0105, 0x0106, 0x0107, 0x001B,
- 0x0178, 0x0179, 0x01CE, 0x001D, 0x00BD, 0x00BE, 0x01F0
- },
- {
- 0x0003, 0x0004, 0x01B6, 0x0004, 0x002E, 0x002F, 0x000E, 0x0005,
- 0x0030, 0x0031, 0x000F, 0x0003, 0x000A, 0x000B, 0x0014, 0x0006,
- 0x0032, 0x0033, 0x0010, 0x0005, 0x0030, 0x0031, 0x0032, 0x0009,
- 0x0066, 0x0067, 0x0068, 0x001D, 0x01B7, 0x01B8, 0x01B9, 0x0007,
- 0x0034, 0x0035, 0x0011, 0x0016, 0x0069, 0x006A, 0x006B, 0x000A,
- 0x0036, 0x0037, 0x00D8, 0x001E, 0x01BA, 0x01BB, 0x01BC, 0x0004,
- 0x0015, 0x0016, 0x0017, 0x001F, 0x01BD, 0x01BE, 0x01BF, 0x0000,
- 0x0010, 0x0011, 0x0012, 0x001C, 0x00D9, 0x00DA, 0x0013
- }
-};
-
-const uint8_t ff_vc1_icbpcy_p_bits[8][63] = {
- {
- 15, 15, 14, 9, 11, 11, 13, 9, 11, 11, 12, 8, 9, 9, 9, 9,
- 11, 11, 12, 9, 10, 10, 10, 10, 11, 11, 11, 8, 8, 8, 7, 9,
- 11, 11, 12, 10, 11, 11, 11, 9, 10, 10, 10, 8, 8, 8, 7, 8,
- 9, 9, 9, 8, 8, 8, 7, 8, 8, 8, 7, 3, 3, 3, 1
- },
- {
- 7, 7, 9, 7, 8, 8, 9, 7, 8, 8, 9, 6, 7, 7, 7, 7,
- 7, 7, 9, 7, 8, 8, 8, 8, 9, 9, 9, 6, 7, 7, 6, 6,
- 7, 7, 8, 8, 9, 9, 9, 7, 8, 8, 8, 6, 7, 7, 6, 6,
- 7, 7, 7, 6, 7, 7, 6, 6, 7, 7, 6, 3, 4, 3, 2
- },
- {
- 6, 6, 5, 6, 8, 8, 9, 6, 8, 8, 9, 5, 7, 7, 7, 6,
- 8, 8, 9, 7, 8, 8, 8, 8, 9, 9, 9, 6, 7, 7, 6, 6,
- 8, 8, 9, 7, 9, 9, 9, 6, 8, 8, 8, 6, 7, 7, 6, 5,
- 7, 7, 7, 6, 7, 7, 6, 6, 7, 7, 6, 3, 5, 4, 2
- },
- {
- 6, 6, 8, 4, 9, 9, 9, 4, 9, 9, 9, 4, 8, 8, 7, 4,
- 9, 9, 9, 6, 9, 9, 8, 6, 10, 10, 9, 5, 8, 8, 8, 4,
- 9, 9, 9, 6, 10, 10, 9, 5, 9, 9, 8, 5, 8, 8, 7, 4,
- 8, 8, 7, 5, 8, 8, 7, 5, 8, 8, 7, 3, 5, 5, 4
- },
- {
- 6, 6, 5, 5, 7, 7, 7, 5, 7, 7, 7, 5, 6, 6, 6, 5,
- 7, 7, 7, 6, 7, 7, 7, 7, 8, 8, 8, 6, 7, 7, 6, 5,
- 7, 7, 7, 7, 8, 8, 8, 6, 7, 7, 7, 6, 7, 7, 6, 5,
- 6, 6, 6, 6, 7, 7, 6, 6, 7, 6, 6, 4, 5, 5, 3
- },
- {
- 6, 6, 8, 4, 8, 8, 8, 4, 8, 8, 8, 4, 8, 8, 7, 4,
- 8, 8, 8, 5, 9, 9, 8, 6, 10, 10, 9, 5, 8, 8, 8, 4,
- 8, 8, 8, 6, 10, 10, 9, 5, 9, 9, 8, 5, 8, 8, 8, 4,
- 8, 8, 7, 5, 8, 8, 8, 5, 8, 8, 7, 3, 6, 6, 4
- },
- {
- 6, 6, 9, 3, 8, 8, 9, 3, 8, 8, 9, 4, 9, 9, 9, 3,
- 8, 8, 9, 5, 10, 10, 10, 6, 11, 11, 11, 5, 10, 10, 10, 3,
- 8, 8, 8, 6, 11, 11, 11, 5, 10, 10, 10, 5, 9, 9, 9, 4,
- 9, 9, 9, 5, 9, 9, 9, 5, 9, 9, 9, 5, 8, 8, 9
- },
- {
- 6, 6, 10, 3, 7, 7, 7, 3, 7, 7, 7, 4, 8, 8, 8, 3,
- 7, 7, 7, 5, 9, 9, 9, 6, 10, 10, 10, 6, 10, 10, 10, 3,
- 7, 7, 7, 6, 10, 10, 10, 5, 9, 9, 9, 6, 10, 10, 10, 4,
- 8, 8, 8, 6, 10, 10, 10, 5, 9, 9, 9, 6, 9, 9, 9
- }
-};
-
-/* MacroBlock Transform Type: 7.1.3.11, p89
- * 8x8:B
- * 8x4:B:btm 8x4:B:top 8x4:B:both,
- * 4x8:B:right 4x8:B:left 4x8:B:both
- * 4x4:B 8x8:MB
- * 8x4:MB:btm 8x4:MB:top 8x4,MB,both
- * 4x8,MB,right 4x8,MB,left
- * 4x4,MB */
-const uint16_t ff_vc1_ttmb_codes[3][16] = {
- {
- 0x0003,
- 0x002E, 0x005F, 0x0000,
- 0x0016, 0x0015, 0x0001,
- 0x0004, 0x0014,
- 0x02F1, 0x0179, 0x017B,
- 0x0BC0, 0x0BC1, 0x05E1,
- 0x017A
- },
- {
- 0x0006,
- 0x0006, 0x0003, 0x0007,
- 0x000F, 0x000E, 0x0000,
- 0x0002, 0x0002,
- 0x0014, 0x0011, 0x000B,
- 0x0009, 0x0021, 0x0015,
- 0x0020
- },
- {
- 0x0006,
- 0x0000, 0x000E, 0x0005,
- 0x0002, 0x0003, 0x0003,
- 0x000F, 0x0002,
- 0x0081, 0x0021, 0x0009,
- 0x0101, 0x0041, 0x0011,
- 0x0100
- }
-};
-
-const uint8_t ff_vc1_ttmb_bits[3][16] = {
- {
- 2,
- 6, 7, 2,
- 5, 5, 2,
- 3, 5,
- 10, 9, 9,
- 12, 12, 11,
- 9
- },
- {
- 3,
- 4, 4, 4,
- 4, 4, 3,
- 3, 2,
- 7, 7, 6,
- 6, 8, 7,
- 8
- },
- {
- 3,
- 3, 4, 5,
- 3, 3, 4,
- 4, 2,
- 10, 8, 6,
- 11, 9, 7,
- 11
- }
-};
-
-/* TTBLK (Transform Type per Block) tables */
-const uint8_t ff_vc1_ttblk_codes[3][8] = {
- { 0, 1, 3, 5, 16, 17, 18, 19 },
- { 3, 0, 1, 2, 3, 5, 8, 9 },
- { 1, 0, 1, 4, 6, 7, 10, 11 }
-};
-const uint8_t ff_vc1_ttblk_bits[3][8] = {
- { 2, 2, 2, 3, 5, 5, 5, 5 },
- { 2, 3, 3, 3, 3, 3, 4, 4 },
- { 2, 3, 3, 3, 3, 3, 4, 4 }
-};
-
-/* SUBBLKPAT tables, p93-94, reordered */
-const uint8_t ff_vc1_subblkpat_codes[3][15] = {
- { 14, 12, 7, 11, 9, 26, 2, 10, 27, 8, 0, 6, 1, 15, 1 },
- { 14, 0, 8, 15, 10, 4, 23, 13, 5, 9, 25, 3, 24, 22, 1 },
- { 5, 6, 2, 2, 8, 0, 28, 3, 1, 3, 29, 1, 19, 18, 15 }
-};
-const uint8_t ff_vc1_subblkpat_bits[3][15] = {
- { 5, 5, 5, 5, 5, 6, 4, 5, 6, 5, 4, 5, 4, 5, 1},
- { 4, 3, 4, 4, 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 2},
- { 3, 3, 4, 3, 4, 5, 5, 3, 5, 4, 5, 4, 5, 5, 4}
-};
-
-/* MV differential tables, p265 */
-const uint16_t ff_vc1_mv_diff_codes[4][73] = {
- {
- 0, 2, 3, 8, 576, 3, 2, 6,
- 5, 577, 578, 7, 8, 9, 40, 19,
- 37, 82, 21, 22, 23, 579, 580, 166,
- 96, 167, 49, 194, 195, 581, 582, 583,
- 292, 293, 294, 13, 2, 7, 24, 50,
- 102, 295, 13, 7, 8, 18, 50, 103,
- 38, 20, 21, 22, 39, 204, 103, 23,
- 24, 25, 104, 410, 105, 106, 107, 108,
- 109, 220, 411, 442, 222, 443, 446, 447,
- 7 /* 73 elements */
- },
- {
- 0, 4, 5, 3, 4, 3, 4, 5,
- 20, 6, 21, 44, 45, 46, 3008, 95,
- 112, 113, 57, 3009, 3010, 116, 117, 3011,
- 118, 3012, 3013, 3014, 3015, 3016, 3017, 3018,
- 3019, 3020, 3021, 3022, 1, 4, 15, 160,
- 161, 41, 6, 11, 42, 162, 43, 119,
- 56, 57, 58, 163, 236, 237, 3023, 119,
- 120, 242, 122, 486, 1512, 487, 246, 494,
- 1513, 495, 1514, 1515, 1516, 1517, 1518, 1519,
- 31 /* 73 elements */
- },
- {
- 0, 512, 513, 514, 515, 2, 3, 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, 1, 5, 287, 288,
- 289, 290, 6, 7, 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 /* 73 elements */
- },
- {
- 0, 1, 1, 2, 3, 4, 1, 5,
- 4, 3, 5, 8, 6, 9, 10, 11,
- 12, 7, 104, 14, 105, 4, 10, 15,
- 11, 6, 14, 8, 106, 107, 108, 15,
- 109, 9, 55, 10, 1, 2, 1, 2,
- 3, 12, 6, 2, 6, 7, 28, 7,
- 15, 8, 5, 18, 29, 152, 77, 24,
- 25, 26, 39, 108, 13, 109, 55, 56,
- 57, 116, 11, 153, 234, 235, 118, 119,
- 15 /* 73 elements */
- }
-};
-const uint8_t ff_vc1_mv_diff_bits[4][73] = {
- {
- 6, 7, 7, 8, 14, 6, 5, 6, 7, 14, 14, 6, 6, 6, 8, 9,
- 10, 9, 7, 7, 7, 14, 14, 10, 9, 10, 8, 10, 10, 14, 14, 14,
- 13, 13, 13, 6, 3, 5, 6, 8, 9, 13, 5, 4, 4, 5, 7, 9,
- 6, 5, 5, 5, 6, 9, 8, 5, 5, 5, 7, 10, 7, 7, 7, 7,
- 7, 8, 10, 9, 8, 9, 9, 9, 3 /* 73 elements */
- },
- {
- 5, 7, 7, 6, 6, 5, 5, 6, 7, 5, 7, 8, 8, 8, 14, 9,
- 9, 9, 8, 14, 14, 9, 9, 14, 9, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 2, 3, 6, 8, 8, 6, 3, 4, 6, 8, 6, 9,
- 6, 6, 6, 8, 8, 8, 14, 7, 7, 8, 7, 9, 13, 9, 8, 9,
- 13, 9, 13, 13, 13, 13, 13, 13, 5 /* 73 elements */
-
- },
- {
- 3, 12, 12, 12, 12, 3, 4, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 1, 5, 11, 11, 11, 11, 4, 4, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 11, 11, 11, 11, 11, 11, 11, 11, 11 /* 73 elements */
- },
- {
- 15, 11, 15, 15, 15, 15, 12, 15, 12, 11, 12, 12, 15, 12, 12, 12,
- 12, 15, 15, 12, 15, 10, 11, 12, 11, 10, 11, 10, 15, 15, 15, 11,
- 15, 10, 14, 10, 4, 4, 5, 7, 8, 9, 5, 3, 4, 5, 6, 8,
- 5, 4, 3, 5, 6, 8, 7, 5, 5, 5, 6, 7, 9, 7, 6, 6,
- 6, 7, 10, 8, 8, 8, 7, 7, 4 /* 73 elements */
- }
-};
-
-/* DC differentials low+hi-mo, p217 are the same as in msmpeg4data .h */
-
-/* Table 232 */
-const uint8_t ff_vc1_simple_progressive_4x4_zz [16] = {
- 0, 8, 16, 1,
- 9, 24, 17, 2,
- 10, 18, 25, 3,
- 11, 26, 19, 27
-};
-
-const uint8_t ff_vc1_adv_progressive_8x4_zz [32] = { /* Table 233 */
- 0, 8, 1, 16, 2, 9, 10, 3,
- 24, 17, 4, 11, 18, 12, 5, 19,
- 25, 13, 20, 26, 27, 6, 21, 28,
- 14, 22, 29, 7, 30, 15, 23, 31
-};
-
-const uint8_t ff_vc1_adv_progressive_4x8_zz [32] = { /* Table 234 */
- 0, 1, 8, 2,
- 9, 16, 17, 24,
- 10, 32, 25, 18,
- 40, 3, 33, 26,
- 48, 11, 56, 41,
- 34, 49, 57, 42,
- 19, 50, 27, 58,
- 35, 43, 51, 59
-};
-
-const uint8_t ff_vc1_adv_interlaced_8x8_zz [64] = { /* Table 235 */
- 0, 8, 1, 16, 24, 9, 2, 32,
- 40, 48, 56, 17, 10, 3, 25, 18,
- 11, 4, 33, 41, 49, 57, 26, 34,
- 42, 50, 58, 19, 12, 5, 27, 20,
- 13, 6, 35, 28, 21, 14, 7, 15,
- 22, 29, 36, 43, 51, 59, 60, 52,
- 44, 37, 30, 23, 31, 38, 45, 53,
- 61, 62, 54, 46, 39, 47, 55, 63
-};
-
-const uint8_t ff_vc1_adv_interlaced_8x4_zz [32] = { /* Table 236 */
- 0, 8, 16, 24, 1, 9, 2, 17,
- 25, 10, 3, 18, 26, 4, 11, 19,
- 12, 5, 13, 20, 27, 6, 21, 28,
- 14, 22, 29, 7, 30, 15, 23, 31
-};
-
-const uint8_t ff_vc1_adv_interlaced_4x8_zz [32] = { /* Table 237 */
- 0, 1, 2, 8,
- 16, 9, 24, 17,
- 10, 3, 32, 40,
- 48, 56, 25, 18,
- 33, 26, 41, 34,
- 49, 57, 11, 42,
- 19, 50, 27, 58,
- 35, 43, 51, 59
-};
-
-const uint8_t ff_vc1_adv_interlaced_4x4_zz [16] = { /* Table 238 */
- 0, 8, 16, 24,
- 1, 9, 17, 2,
- 25, 10, 18, 3,
- 26, 11, 19, 27
-};
-
-
-/* DQScale as specified in 8.1.3.9 - almost identical to 0x40000/i */
-const int32_t ff_vc1_dqscale[63] = {
- 0x40000, 0x20000, 0x15555, 0x10000, 0xCCCD, 0xAAAB, 0x9249, 0x8000,
- 0x71C7, 0x6666, 0x5D17, 0x5555, 0x4EC5, 0x4925, 0x4444, 0x4000,
- 0x3C3C, 0x38E4, 0x35E5, 0x3333, 0x30C3, 0x2E8C, 0x2C86, 0x2AAB,
- 0x28F6, 0x2762, 0x25ED, 0x2492, 0x234F, 0x2222, 0x2108, 0x2000,
- 0x1F08, 0x1E1E, 0x1D42, 0x1C72, 0x1BAD, 0x1AF3, 0x1A42, 0x199A,
- 0x18FA, 0x1862, 0x17D0, 0x1746, 0x16C1, 0x1643, 0x15CA, 0x1555,
- 0x14E6, 0x147B, 0x1414, 0x13B1, 0x1352, 0x12F7, 0x129E, 0x1249,
- 0x11F7, 0x11A8, 0x115B, 0x1111, 0x10C9, 0x1084, 0x1000
-};
-
-/* P Interlaced field picture MV predictor scaling values (Table 114) */
-const uint16_t ff_vc1_field_mvpred_scales[2][7][4] = {
-// Refdist:
-// 0 1 2 3 or greater
- { // current field is first
- { 128, 192, 213, 224 }, // SCALEOPP
- { 512, 341, 307, 293 }, // SCALESAME1
- { 219, 236, 242, 245 }, // SCALESAME2
- { 32, 48, 53, 56 }, // SCALEZONE1_X
- { 8, 12, 13, 14 }, // SCALEZONE1_Y
- { 37, 20, 14, 11 }, // ZONE1OFFSET_X
- { 10, 5, 4, 3 } // ZONE1OFFSET_Y
- },
- { // current field is second
- { 128, 64, 43, 32 }, // SCALEOPP
- { 512, 1024, 1536, 2048 }, // SCALESAME1
- { 219, 204, 200, 198 }, // SCALESAME2
- { 32, 16, 11, 8 }, // SCALEZONE1_X
- { 8, 4, 3, 2 }, // SCALEZONE1_Y
- { 37, 52, 56, 58 }, // ZONE1OFFSET_X
- { 10, 13, 14, 15 } // ZONE1OFFSET_Y
- }
-};
-
-/* B Interlaced field picture backward MV predictor scaling values for first field (Table 115) */
-const uint16_t ff_vc1_b_field_mvpred_scales[7][4] = {
- // BRFD:
- // 0 1 2 3 or greater
- { 171, 205, 219, 228 }, // SCALESAME
- { 384, 320, 299, 288 }, // SCALEOPP1
- { 230, 239, 244, 246 }, // SCALEOPP2
- { 43, 51, 55, 57 }, // SCALEZONE1_X
- { 11, 13, 14, 14 }, // SCALEZONE1_Y
- { 26, 17, 12, 10 }, // ZONE1OFFSET_X
- { 7, 4, 3, 3 } // ZONE1OFFSET_Y
-};
-
-const int ff_vc1_ac_sizes[AC_MODES] = {
- 186, 169, 133, 149, 103, 103, 163, 175
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/vc1data.h b/src/thirdparty/ffmpeg/libavcodec/vc1data.h
deleted file mode 100644
index e14ab7499..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vc1data.h
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * VC-1 and WMV3 decoder
- * copyright (c) 2006 Konstantin Shishkov
- * (c) 2005 anonymous, Alex Beregszaszi, 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
- */
-
-/**
- * @file
- * VC-1 tables.
- */
-
-#ifndef AVCODEC_VC1DATA_H
-#define AVCODEC_VC1DATA_H
-
-#include <stdint.h>
-#include "libavutil/rational.h"
-#include "get_bits.h"
-
-/** Table for conversion between TTBLK and TTMB */
-extern const int ff_vc1_ttblk_to_tt[3][8];
-
-extern const int ff_vc1_ttfrm_to_tt[4];
-
-/** MV P mode - the 5th element is only used for mode 1 */
-extern const uint8_t ff_vc1_mv_pmode_table[2][5];
-extern const uint8_t ff_vc1_mv_pmode_table2[2][4];
-
-extern const int ff_vc1_fps_nr[7], ff_vc1_fps_dr[2];
-extern const uint8_t ff_vc1_pquant_table[3][32];
-
-/* MBMODE table for interlaced frame P-picture */
-extern const uint8_t ff_vc1_mbmode_intfrp[2][15][4];
-
-/** @name VC-1 VLC tables and defines
- * @todo TODO move this into the context
- */
-//@{
-#define VC1_BFRACTION_VLC_BITS 7
-extern VLC ff_vc1_bfraction_vlc;
-#define VC1_IMODE_VLC_BITS 4
-extern VLC ff_vc1_imode_vlc;
-#define VC1_NORM2_VLC_BITS 3
-extern VLC ff_vc1_norm2_vlc;
-#define VC1_NORM6_VLC_BITS 9
-extern VLC ff_vc1_norm6_vlc;
-/* Could be optimized, one table only needs 8 bits */
-#define VC1_TTMB_VLC_BITS 9 //12
-extern VLC ff_vc1_ttmb_vlc[3];
-#define VC1_MV_DIFF_VLC_BITS 9 //15
-extern VLC ff_vc1_mv_diff_vlc[4];
-#define VC1_CBPCY_P_VLC_BITS 9 //14
-extern VLC ff_vc1_cbpcy_p_vlc[4];
-#define VC1_ICBPCY_VLC_BITS 9
-extern VLC ff_vc1_icbpcy_vlc[8];
-#define VC1_4MV_BLOCK_PATTERN_VLC_BITS 6
-extern VLC ff_vc1_4mv_block_pattern_vlc[4];
-#define VC1_2MV_BLOCK_PATTERN_VLC_BITS 3
-extern VLC ff_vc1_2mv_block_pattern_vlc[4];
-#define VC1_TTBLK_VLC_BITS 5
-extern VLC ff_vc1_ttblk_vlc[3];
-#define VC1_SUBBLKPAT_VLC_BITS 6
-extern VLC ff_vc1_subblkpat_vlc[3];
-#define VC1_INTFR_4MV_MBMODE_VLC_BITS 9
-extern VLC ff_vc1_intfr_4mv_mbmode_vlc[4];
-#define VC1_INTFR_NON4MV_MBMODE_VLC_BITS 6
-extern VLC ff_vc1_intfr_non4mv_mbmode_vlc[4];
-#define VC1_IF_MMV_MBMODE_VLC_BITS 5
-extern VLC ff_vc1_if_mmv_mbmode_vlc[8];
-#define VC1_IF_1MV_MBMODE_VLC_BITS 5
-extern VLC ff_vc1_if_1mv_mbmode_vlc[8];
-#define VC1_1REF_MVDATA_VLC_BITS 9
-extern VLC ff_vc1_1ref_mvdata_vlc[4];
-#define VC1_2REF_MVDATA_VLC_BITS 9
-extern VLC ff_vc1_2ref_mvdata_vlc[8];
-
-extern VLC ff_vc1_ac_coeff_table[8];
-
-#define VC1_IF_MBMODE_VLC_BITS 5
-//@}
-
-
-/* Denominator used for ff_vc1_bfraction_lut */
-#define B_FRACTION_DEN 256
-
-/* pre-computed scales for all bfractions and base=256 */
-extern const int16_t ff_vc1_bfraction_lut[23];
-extern const uint8_t ff_vc1_bfraction_bits[23];
-extern const uint8_t ff_vc1_bfraction_codes[23];
-
-//Same as H.264
-extern const AVRational ff_vc1_pixel_aspect[16];
-
-/* BitPlane IMODE - such a small table... */
-extern const uint8_t ff_vc1_imode_codes[7];
-extern const uint8_t ff_vc1_imode_bits[7];
-
-/* Normal-2 imode */
-extern const uint8_t ff_vc1_norm2_codes[4];
-extern const uint8_t ff_vc1_norm2_bits[4];
-extern const uint16_t ff_vc1_norm6_codes[64];
-extern const uint8_t ff_vc1_norm6_bits[64];
-/* Normal-6 imode */
-extern const uint8_t ff_vc1_norm6_spec[64][5];
-
-/* 4MV Block pattern VLC tables */
-extern const uint8_t ff_vc1_4mv_block_pattern_codes[4][16];
-extern const uint8_t ff_vc1_4mv_block_pattern_bits[4][16];
-
-/* 2MV Block pattern VLC tables */
-extern const uint8_t ff_vc1_2mv_block_pattern_codes[4][4];
-extern const uint8_t ff_vc1_2mv_block_pattern_bits[4][4];
-
-extern const uint8_t ff_wmv3_dc_scale_table[32];
-
-/* P-Picture CBPCY VLC tables */
-extern const uint16_t ff_vc1_cbpcy_p_codes[4][64];
-extern const uint8_t ff_vc1_cbpcy_p_bits[4][64];
-
-/* Interlaced CBPCY VLC tables (Table 124 - Table 131) */
-extern const uint16_t ff_vc1_icbpcy_p_codes[8][63];
-extern const uint8_t ff_vc1_icbpcy_p_bits[8][63];
-
-/* MacroBlock Transform Type: 7.1.3.11, p89
- * 8x8:B
- * 8x4:B:btm 8x4:B:top 8x4:B:both,
- * 4x8:B:right 4x8:B:left 4x8:B:both
- * 4x4:B 8x8:MB
- * 8x4:MB:btm 8x4:MB:top 8x4,MB,both
- * 4x8,MB,right 4x8,MB,left
- * 4x4,MB */
-extern const uint16_t ff_vc1_ttmb_codes[3][16];
-
-extern const uint8_t ff_vc1_ttmb_bits[3][16];
-
-/* TTBLK (Transform Type per Block) tables */
-extern const uint8_t ff_vc1_ttblk_codes[3][8];
-extern const uint8_t ff_vc1_ttblk_bits[3][8];
-
-/* SUBBLKPAT tables, p93-94, reordered */
-extern const uint8_t ff_vc1_subblkpat_codes[3][15];
-extern const uint8_t ff_vc1_subblkpat_bits[3][15];
-
-/* MV differential tables, p265 */
-extern const uint16_t ff_vc1_mv_diff_codes[4][73];
-extern const uint8_t ff_vc1_mv_diff_bits[4][73];
-
-/* Interlaced frame picture MBMODE VLC tables (p. 246, p. 360) */
-extern const uint16_t ff_vc1_intfr_4mv_mbmode_codes[4][15];
-extern const uint8_t ff_vc1_intfr_4mv_mbmode_bits[4][15];
-extern const uint8_t ff_vc1_intfr_non4mv_mbmode_codes[4][9];
-extern const uint8_t ff_vc1_intfr_non4mv_mbmode_bits[4][9];
-
-/* Interlaced field picture MBMODE VLC tables (p. 356 - 11.4.1, 11.4.2) */
-extern const uint8_t ff_vc1_if_mmv_mbmode_codes[8][8];
-extern const uint8_t ff_vc1_if_mmv_mbmode_bits[8][8];
-extern const uint8_t ff_vc1_if_1mv_mbmode_codes[8][6];
-extern const uint8_t ff_vc1_if_1mv_mbmode_bits[8][6];
-
-/* Interlaced frame/field picture MVDATA VLC tables */
-/* 1-reference tables */
-extern const uint32_t ff_vc1_1ref_mvdata_codes[4][72];
-extern const uint8_t ff_vc1_1ref_mvdata_bits[4][72];
-/* 2-reference tables */
-extern const uint32_t ff_vc1_2ref_mvdata_codes[8][126];
-extern const uint8_t ff_vc1_2ref_mvdata_bits[8][126];
-
-/* DC differentials low+hi-mo, p217 are the same as in msmpeg4data .h */
-
-/* Scantables/ZZ scan are at 11.9 (p262) and 8.1.1.12 (p10) */
-extern const uint8_t ff_vc1_simple_progressive_4x4_zz [16];
-extern const uint8_t ff_vc1_adv_progressive_8x4_zz [32];
-extern const uint8_t ff_vc1_adv_progressive_4x8_zz [32];
-extern const uint8_t ff_vc1_adv_interlaced_8x8_zz [64];
-extern const uint8_t ff_vc1_adv_interlaced_8x4_zz [32];
-extern const uint8_t ff_vc1_adv_interlaced_4x8_zz [32];
-extern const uint8_t ff_vc1_adv_interlaced_4x4_zz [16];
-extern const uint8_t ff_vc1_intra_horz_8x8_zz [64];
-extern const uint8_t ff_vc1_intra_vert_8x8_zz [64];
-
-/* DQScale as specified in 8.1.3.9 - almost identical to 0x40000/i */
-extern const int32_t ff_vc1_dqscale[63];
-
-/* P Interlaced field picture MV predictor scaling values (Table 114) */
-extern const uint16_t ff_vc1_field_mvpred_scales[2][7][4];
-/* B Interlaced field picture backward MV predictor scaling values for first field (Table 115) */
-extern const uint16_t ff_vc1_b_field_mvpred_scales[7][4];
-
-#define AC_MODES 8
-
-extern const int ff_vc1_ac_sizes[AC_MODES];
-
-#endif /* AVCODEC_VC1DATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/vc1dec.c b/src/thirdparty/ffmpeg/libavcodec/vc1dec.c
deleted file mode 100644
index 90fbc4d09..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vc1dec.c
+++ /dev/null
@@ -1,5890 +0,0 @@
-/*
- * VC-1 and WMV3 decoder
- * Copyright (c) 2011 Mashiat Sarker Shakkhar
- * Copyright (c) 2006-2007 Konstantin Shishkov
- * Partly based on vc9.c (c) 2005 Anonymous, Alex Beregszaszi, 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
- */
-
-/**
- * @file
- * VC-1 and WMV3 decoder
- */
-
-#include "internal.h"
-#include "dsputil.h"
-#include "avcodec.h"
-#include "mpegvideo.h"
-#include "h263.h"
-#include "h264chroma.h"
-#include "vc1.h"
-#include "vc1data.h"
-#include "vc1acdata.h"
-#include "msmpeg4data.h"
-#include "unary.h"
-#include "mathops.h"
-#include "vdpau_internal.h"
-#include "libavutil/avassert.h"
-
-#undef NDEBUG
-#include <assert.h>
-
-#define MB_INTRA_VLC_BITS 9
-#define DC_VLC_BITS 9
-
-
-// offset tables for interlaced picture MVDATA decoding
-static const int offset_table1[9] = { 0, 1, 2, 4, 8, 16, 32, 64, 128 };
-static const int offset_table2[9] = { 0, 1, 3, 7, 15, 31, 63, 127, 255 };
-
-/***********************************************************************/
-/**
- * @name VC-1 Bitplane decoding
- * @see 8.7, p56
- * @{
- */
-
-/**
- * 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) {
- 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];
- }
-}
-
-
-/** @} */ //Bitplane group
-
-static void vc1_put_signed_blocks_clamped(VC1Context *v)
-{
- MpegEncContext *s = &v->s;
- int topleft_mb_pos, top_mb_pos;
- int stride_y, fieldtx = 0;
- int v_dist;
-
- /* The put pixels loop is always one MB row behind the decoding loop,
- * because we can only put pixels when overlap filtering is done, and
- * for filtering of the bottom edge of a MB, we need the next MB row
- * present as well.
- * Within the row, the put pixels loop is also one MB col behind the
- * decoding loop. The reason for this is again, because for filtering
- * of the right MB edge, we need the next MB present. */
- if (!s->first_slice_line) {
- if (s->mb_x) {
- topleft_mb_pos = (s->mb_y - 1) * s->mb_stride + s->mb_x - 1;
- if (v->fcm == ILACE_FRAME)
- fieldtx = v->fieldtx_plane[topleft_mb_pos];
- stride_y = s->linesize << fieldtx;
- v_dist = (16 - fieldtx) >> (fieldtx == 0);
- s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][0],
- s->dest[0] - 16 * s->linesize - 16,
- stride_y);
- s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][1],
- s->dest[0] - 16 * s->linesize - 8,
- stride_y);
- s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][2],
- s->dest[0] - v_dist * s->linesize - 16,
- stride_y);
- s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][3],
- s->dest[0] - v_dist * s->linesize - 8,
- stride_y);
- s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][4],
- s->dest[1] - 8 * s->uvlinesize - 8,
- s->uvlinesize);
- s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][5],
- s->dest[2] - 8 * s->uvlinesize - 8,
- s->uvlinesize);
- }
- if (s->mb_x == s->mb_width - 1) {
- top_mb_pos = (s->mb_y - 1) * s->mb_stride + s->mb_x;
- if (v->fcm == ILACE_FRAME)
- fieldtx = v->fieldtx_plane[top_mb_pos];
- stride_y = s->linesize << fieldtx;
- v_dist = fieldtx ? 15 : 8;
- s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][0],
- s->dest[0] - 16 * s->linesize,
- stride_y);
- s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][1],
- s->dest[0] - 16 * s->linesize + 8,
- stride_y);
- s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][2],
- s->dest[0] - v_dist * s->linesize,
- stride_y);
- s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][3],
- s->dest[0] - v_dist * s->linesize + 8,
- stride_y);
- s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][4],
- s->dest[1] - 8 * s->uvlinesize,
- s->uvlinesize);
- s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][5],
- s->dest[2] - 8 * s->uvlinesize,
- s->uvlinesize);
- }
- }
-
-#define inc_blk_idx(idx) do { \
- idx++; \
- if (idx >= v->n_allocated_blks) \
- idx = 0; \
- } while (0)
-
- inc_blk_idx(v->topleft_blk_idx);
- inc_blk_idx(v->top_blk_idx);
- inc_blk_idx(v->left_blk_idx);
- inc_blk_idx(v->cur_blk_idx);
-}
-
-static void vc1_loop_filter_iblk(VC1Context *v, int pq)
-{
- MpegEncContext *s = &v->s;
- int j;
- if (!s->first_slice_line) {
- v->vc1dsp.vc1_v_loop_filter16(s->dest[0], s->linesize, pq);
- if (s->mb_x)
- v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16 * s->linesize, s->linesize, pq);
- v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16 * s->linesize + 8, s->linesize, pq);
- for (j = 0; j < 2; j++) {
- v->vc1dsp.vc1_v_loop_filter8(s->dest[j + 1], s->uvlinesize, pq);
- if (s->mb_x)
- v->vc1dsp.vc1_h_loop_filter8(s->dest[j + 1] - 8 * s->uvlinesize, s->uvlinesize, pq);
- }
- }
- v->vc1dsp.vc1_v_loop_filter16(s->dest[0] + 8 * s->linesize, s->linesize, pq);
-
- if (s->mb_y == s->end_mb_y - 1) {
- if (s->mb_x) {
- v->vc1dsp.vc1_h_loop_filter16(s->dest[0], s->linesize, pq);
- v->vc1dsp.vc1_h_loop_filter8(s->dest[1], s->uvlinesize, pq);
- v->vc1dsp.vc1_h_loop_filter8(s->dest[2], s->uvlinesize, pq);
- }
- v->vc1dsp.vc1_h_loop_filter16(s->dest[0] + 8, s->linesize, pq);
- }
-}
-
-static void vc1_loop_filter_iblk_delayed(VC1Context *v, int pq)
-{
- MpegEncContext *s = &v->s;
- int j;
-
- /* The loopfilter runs 1 row and 1 column behind the overlap filter, which
- * means it runs two rows/cols behind the decoding loop. */
- if (!s->first_slice_line) {
- if (s->mb_x) {
- if (s->mb_y >= s->start_mb_y + 2) {
- v->vc1dsp.vc1_v_loop_filter16(s->dest[0] - 16 * s->linesize - 16, s->linesize, pq);
-
- if (s->mb_x >= 2)
- v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 32 * s->linesize - 16, s->linesize, pq);
- v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 32 * s->linesize - 8, s->linesize, pq);
- for (j = 0; j < 2; j++) {
- v->vc1dsp.vc1_v_loop_filter8(s->dest[j + 1] - 8 * s->uvlinesize - 8, s->uvlinesize, pq);
- if (s->mb_x >= 2) {
- v->vc1dsp.vc1_h_loop_filter8(s->dest[j + 1] - 16 * s->uvlinesize - 8, s->uvlinesize, pq);
- }
- }
- }
- v->vc1dsp.vc1_v_loop_filter16(s->dest[0] - 8 * s->linesize - 16, s->linesize, pq);
- }
-
- if (s->mb_x == s->mb_width - 1) {
- if (s->mb_y >= s->start_mb_y + 2) {
- v->vc1dsp.vc1_v_loop_filter16(s->dest[0] - 16 * s->linesize, s->linesize, pq);
-
- if (s->mb_x)
- v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 32 * s->linesize, s->linesize, pq);
- v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 32 * s->linesize + 8, s->linesize, pq);
- for (j = 0; j < 2; j++) {
- v->vc1dsp.vc1_v_loop_filter8(s->dest[j + 1] - 8 * s->uvlinesize, s->uvlinesize, pq);
- if (s->mb_x >= 2) {
- v->vc1dsp.vc1_h_loop_filter8(s->dest[j + 1] - 16 * s->uvlinesize, s->uvlinesize, pq);
- }
- }
- }
- v->vc1dsp.vc1_v_loop_filter16(s->dest[0] - 8 * s->linesize, s->linesize, pq);
- }
-
- if (s->mb_y == s->end_mb_y) {
- if (s->mb_x) {
- if (s->mb_x >= 2)
- v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16 * s->linesize - 16, s->linesize, pq);
- v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16 * s->linesize - 8, s->linesize, pq);
- if (s->mb_x >= 2) {
- for (j = 0; j < 2; j++) {
- v->vc1dsp.vc1_h_loop_filter8(s->dest[j + 1] - 8 * s->uvlinesize - 8, s->uvlinesize, pq);
- }
- }
- }
-
- if (s->mb_x == s->mb_width - 1) {
- if (s->mb_x)
- v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16 * s->linesize, s->linesize, pq);
- v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16 * s->linesize + 8, s->linesize, pq);
- if (s->mb_x) {
- for (j = 0; j < 2; j++) {
- v->vc1dsp.vc1_h_loop_filter8(s->dest[j + 1] - 8 * s->uvlinesize, s->uvlinesize, pq);
- }
- }
- }
- }
- }
-}
-
-static void vc1_smooth_overlap_filter_iblk(VC1Context *v)
-{
- MpegEncContext *s = &v->s;
- int mb_pos;
-
- if (v->condover == CONDOVER_NONE)
- return;
-
- mb_pos = s->mb_x + s->mb_y * s->mb_stride;
-
- /* Within a MB, the horizontal overlap always runs before the vertical.
- * To accomplish that, we run the H on left and internal borders of the
- * currently decoded MB. Then, we wait for the next overlap iteration
- * to do H overlap on the right edge of this MB, before moving over and
- * running the V overlap. Therefore, the V overlap makes us trail by one
- * MB col and the H overlap filter makes us trail by one MB row. This
- * is reflected in the time at which we run the put_pixels loop. */
- if (v->condover == CONDOVER_ALL || v->pq >= 9 || v->over_flags_plane[mb_pos]) {
- if (s->mb_x && (v->condover == CONDOVER_ALL || v->pq >= 9 ||
- v->over_flags_plane[mb_pos - 1])) {
- v->vc1dsp.vc1_h_s_overlap(v->block[v->left_blk_idx][1],
- v->block[v->cur_blk_idx][0]);
- v->vc1dsp.vc1_h_s_overlap(v->block[v->left_blk_idx][3],
- v->block[v->cur_blk_idx][2]);
- if (!(s->flags & CODEC_FLAG_GRAY)) {
- v->vc1dsp.vc1_h_s_overlap(v->block[v->left_blk_idx][4],
- v->block[v->cur_blk_idx][4]);
- v->vc1dsp.vc1_h_s_overlap(v->block[v->left_blk_idx][5],
- v->block[v->cur_blk_idx][5]);
- }
- }
- v->vc1dsp.vc1_h_s_overlap(v->block[v->cur_blk_idx][0],
- v->block[v->cur_blk_idx][1]);
- v->vc1dsp.vc1_h_s_overlap(v->block[v->cur_blk_idx][2],
- v->block[v->cur_blk_idx][3]);
-
- if (s->mb_x == s->mb_width - 1) {
- if (!s->first_slice_line && (v->condover == CONDOVER_ALL || v->pq >= 9 ||
- v->over_flags_plane[mb_pos - s->mb_stride])) {
- v->vc1dsp.vc1_v_s_overlap(v->block[v->top_blk_idx][2],
- v->block[v->cur_blk_idx][0]);
- v->vc1dsp.vc1_v_s_overlap(v->block[v->top_blk_idx][3],
- v->block[v->cur_blk_idx][1]);
- if (!(s->flags & CODEC_FLAG_GRAY)) {
- v->vc1dsp.vc1_v_s_overlap(v->block[v->top_blk_idx][4],
- v->block[v->cur_blk_idx][4]);
- v->vc1dsp.vc1_v_s_overlap(v->block[v->top_blk_idx][5],
- v->block[v->cur_blk_idx][5]);
- }
- }
- v->vc1dsp.vc1_v_s_overlap(v->block[v->cur_blk_idx][0],
- v->block[v->cur_blk_idx][2]);
- v->vc1dsp.vc1_v_s_overlap(v->block[v->cur_blk_idx][1],
- v->block[v->cur_blk_idx][3]);
- }
- }
- if (s->mb_x && (v->condover == CONDOVER_ALL || v->over_flags_plane[mb_pos - 1])) {
- if (!s->first_slice_line && (v->condover == CONDOVER_ALL || v->pq >= 9 ||
- v->over_flags_plane[mb_pos - s->mb_stride - 1])) {
- v->vc1dsp.vc1_v_s_overlap(v->block[v->topleft_blk_idx][2],
- v->block[v->left_blk_idx][0]);
- v->vc1dsp.vc1_v_s_overlap(v->block[v->topleft_blk_idx][3],
- v->block[v->left_blk_idx][1]);
- if (!(s->flags & CODEC_FLAG_GRAY)) {
- v->vc1dsp.vc1_v_s_overlap(v->block[v->topleft_blk_idx][4],
- v->block[v->left_blk_idx][4]);
- v->vc1dsp.vc1_v_s_overlap(v->block[v->topleft_blk_idx][5],
- v->block[v->left_blk_idx][5]);
- }
- }
- v->vc1dsp.vc1_v_s_overlap(v->block[v->left_blk_idx][0],
- v->block[v->left_blk_idx][2]);
- v->vc1dsp.vc1_v_s_overlap(v->block[v->left_blk_idx][1],
- v->block[v->left_blk_idx][3]);
- }
-}
-
-/** Do motion compensation over 1 macroblock
- * Mostly adapted hpel_motion and qpel_motion from mpegvideo.c
- */
-static void vc1_mc_1mv(VC1Context *v, int dir)
-{
- MpegEncContext *s = &v->s;
- DSPContext *dsp = &v->s.dsp;
- H264ChromaContext *h264chroma = &v->h264chroma;
- uint8_t *srcY, *srcU, *srcV;
- int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;
- int off, off_uv;
- int v_edge_pos = s->v_edge_pos >> v->field_mode;
-
- if ((!v->field_mode ||
- (v->ref_field_type[dir] == 1 && v->cur_field_type == 1)) &&
- !v->s.last_picture.f.data[0])
- return;
-
- mx = s->mv[dir][0][0];
- my = s->mv[dir][0][1];
-
- // store motion vectors for further use in B frames
- if (s->pict_type == AV_PICTURE_TYPE_P) {
- s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][0] = mx;
- s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][1] = my;
- }
-
- uvmx = (mx + ((mx & 3) == 3)) >> 1;
- uvmy = (my + ((my & 3) == 3)) >> 1;
- v->luma_mv[s->mb_x][0] = uvmx;
- v->luma_mv[s->mb_x][1] = uvmy;
-
- if (v->field_mode &&
- v->cur_field_type != v->ref_field_type[dir]) {
- my = my - 2 + 4 * v->cur_field_type;
- uvmy = uvmy - 2 + 4 * v->cur_field_type;
- }
-
- // fastuvmc shall be ignored for interlaced frame picture
- if (v->fastuvmc && (v->fcm != ILACE_FRAME)) {
- uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1));
- uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1));
- }
- if (v->field_mode) { // interlaced field picture
- if (!dir) {
- if ((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];
- } else {
- srcY = s->last_picture.f.data[0];
- srcU = s->last_picture.f.data[1];
- srcV = s->last_picture.f.data[2];
- }
- } else {
- srcY = s->next_picture.f.data[0];
- srcU = s->next_picture.f.data[1];
- srcV = s->next_picture.f.data[2];
- }
- } else {
- if (!dir) {
- srcY = s->last_picture.f.data[0];
- srcU = s->last_picture.f.data[1];
- srcV = s->last_picture.f.data[2];
- } else {
- srcY = s->next_picture.f.data[0];
- srcU = s->next_picture.f.data[1];
- srcV = s->next_picture.f.data[2];
- }
- }
-
- if(!srcY)
- return;
-
- src_x = s->mb_x * 16 + (mx >> 2);
- src_y = s->mb_y * 16 + (my >> 2);
- uvsrc_x = s->mb_x * 8 + (uvmx >> 2);
- uvsrc_y = s->mb_y * 8 + (uvmy >> 2);
-
- if (v->profile != PROFILE_ADVANCED) {
- src_x = av_clip( src_x, -16, s->mb_width * 16);
- src_y = av_clip( src_y, -16, s->mb_height * 16);
- uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width * 8);
- uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8);
- } else {
- src_x = av_clip( src_x, -17, s->avctx->coded_width);
- src_y = av_clip( src_y, -18, s->avctx->coded_height + 1);
- uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1);
- uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1);
- }
-
- srcY += src_y * s->linesize + src_x;
- srcU += uvsrc_y * s->uvlinesize + uvsrc_x;
- 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];
- }
-
- /* for grayscale we should not try to read from unknown area */
- if (s->flags & CODEC_FLAG_GRAY) {
- srcU = s->edge_emu_buffer + 18 * s->linesize;
- srcV = s->edge_emu_buffer + 18 * s->linesize;
- }
-
- if (v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP)
- || s->h_edge_pos < 22 || v_edge_pos < 22
- || (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx&3) - 16 - s->mspel * 3
- || (unsigned)(src_y - 1) > v_edge_pos - (my&3) - 16 - 3) {
- uint8_t *uvbuf = s->edge_emu_buffer + 19 * s->linesize;
-
- srcY -= s->mspel * (1 + s->linesize);
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize,
- 17 + s->mspel * 2, 17 + s->mspel * 2,
- src_x - s->mspel, src_y - s->mspel,
- s->h_edge_pos, v_edge_pos);
- srcY = s->edge_emu_buffer;
- s->vdsp.emulated_edge_mc(uvbuf , srcU, s->uvlinesize, 8 + 1, 8 + 1,
- uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, v_edge_pos >> 1);
- s->vdsp.emulated_edge_mc(uvbuf + 16, srcV, s->uvlinesize, 8 + 1, 8 + 1,
- uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, v_edge_pos >> 1);
- srcU = uvbuf;
- srcV = uvbuf + 16;
- /* if we deal with range reduction we need to scale source blocks */
- if (v->rangeredfrm) {
- int i, j;
- uint8_t *src, *src2;
-
- src = srcY;
- for (j = 0; j < 17 + s->mspel * 2; j++) {
- for (i = 0; i < 17 + s->mspel * 2; i++)
- src[i] = ((src[i] - 128) >> 1) + 128;
- src += s->linesize;
- }
- src = srcU;
- src2 = srcV;
- for (j = 0; j < 9; j++) {
- for (i = 0; i < 9; i++) {
- src[i] = ((src[i] - 128) >> 1) + 128;
- src2[i] = ((src2[i] - 128) >> 1) + 128;
- }
- src += s->uvlinesize;
- src2 += s->uvlinesize;
- }
- }
- /* if we deal with intensity compensation we need to scale source blocks */
- if (v->mv_mode == MV_PMODE_INTENSITY_COMP) {
- int i, j;
- uint8_t *src, *src2;
-
- src = srcY;
- for (j = 0; j < 17 + s->mspel * 2; j++) {
- for (i = 0; i < 17 + s->mspel * 2; i++)
- src[i] = v->luty[src[i]];
- src += s->linesize;
- }
- src = srcU;
- src2 = srcV;
- for (j = 0; j < 9; j++) {
- for (i = 0; i < 9; i++) {
- src[i] = v->lutuv[src[i]];
- src2[i] = v->lutuv[src2[i]];
- }
- src += s->uvlinesize;
- src2 += s->uvlinesize;
- }
- }
- srcY += s->mspel * (1 + s->linesize);
- }
-
- off = 0;
- off_uv = 0;
- if (s->mspel) {
- dxy = ((my & 3) << 2) | (mx & 3);
- v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + off , srcY , s->linesize, v->rnd);
- v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8, srcY + 8, s->linesize, v->rnd);
- srcY += s->linesize * 8;
- v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8 * s->linesize , srcY , s->linesize, v->rnd);
- v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8 * s->linesize + 8, srcY + 8, s->linesize, v->rnd);
- } else { // hpel mc - always used for luma
- dxy = (my & 2) | ((mx & 2) >> 1);
- if (!v->rnd)
- dsp->put_pixels_tab[0][dxy](s->dest[0] + off, srcY, s->linesize, 16);
- else
- dsp->put_no_rnd_pixels_tab[0][dxy](s->dest[0] + off, srcY, s->linesize, 16);
- }
-
- if (s->flags & CODEC_FLAG_GRAY) return;
- /* Chroma MC always uses qpel bilinear */
- uvmx = (uvmx & 3) << 1;
- uvmy = (uvmy & 3) << 1;
- if (!v->rnd) {
- h264chroma->put_h264_chroma_pixels_tab[0](s->dest[1] + off_uv, srcU, s->uvlinesize, 8, uvmx, uvmy);
- h264chroma->put_h264_chroma_pixels_tab[0](s->dest[2] + off_uv, srcV, s->uvlinesize, 8, uvmx, uvmy);
- } else {
- v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1] + off_uv, srcU, s->uvlinesize, 8, uvmx, uvmy);
- v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2] + off_uv, srcV, s->uvlinesize, 8, uvmx, uvmy);
- }
-}
-
-static inline int median4(int a, int b, int c, int d)
-{
- if (a < b) {
- if (c < d) return (FFMIN(b, d) + FFMAX(a, c)) / 2;
- else return (FFMIN(b, c) + FFMAX(a, d)) / 2;
- } else {
- if (c < d) return (FFMIN(a, d) + FFMAX(b, c)) / 2;
- else return (FFMIN(a, c) + FFMAX(b, d)) / 2;
- }
-}
-
-/** Do motion compensation for 4-MV macroblock - luminance block
- */
-static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir)
-{
- MpegEncContext *s = &v->s;
- DSPContext *dsp = &v->s.dsp;
- uint8_t *srcY;
- int dxy, mx, my, src_x, src_y;
- int off;
- int fieldmv = (v->fcm == ILACE_FRAME) ? v->blk_mv_type[s->block_index[n]] : 0;
- int v_edge_pos = s->v_edge_pos >> v->field_mode;
-
- if ((!v->field_mode ||
- (v->ref_field_type[dir] == 1 && v->cur_field_type == 1)) &&
- !v->s.last_picture.f.data[0])
- return;
-
- mx = s->mv[dir][n][0];
- my = s->mv[dir][n][1];
-
- if (!dir) {
- if (v->field_mode) {
- if ((v->cur_field_type != v->ref_field_type[dir]) && v->second_field)
- srcY = s->current_picture.f.data[0];
- else
- srcY = s->last_picture.f.data[0];
- } else
- srcY = s->last_picture.f.data[0];
- } else
- srcY = s->next_picture.f.data[0];
-
- if(!srcY)
- return;
-
- if (v->field_mode) {
- if (v->cur_field_type != v->ref_field_type[dir])
- my = my - 2 + 4 * v->cur_field_type;
- }
-
- if (s->pict_type == AV_PICTURE_TYPE_P && n == 3 && v->field_mode) {
- int same_count = 0, opp_count = 0, k;
- int chosen_mv[2][4][2], f;
- int tx, ty;
- for (k = 0; k < 4; k++) {
- f = v->mv_f[0][s->block_index[k] + v->blocks_off];
- chosen_mv[f][f ? opp_count : same_count][0] = s->mv[0][k][0];
- chosen_mv[f][f ? opp_count : same_count][1] = s->mv[0][k][1];
- opp_count += f;
- same_count += 1 - f;
- }
- f = opp_count > same_count;
- switch (f ? opp_count : same_count) {
- case 4:
- tx = median4(chosen_mv[f][0][0], chosen_mv[f][1][0],
- chosen_mv[f][2][0], chosen_mv[f][3][0]);
- ty = median4(chosen_mv[f][0][1], chosen_mv[f][1][1],
- chosen_mv[f][2][1], chosen_mv[f][3][1]);
- break;
- case 3:
- tx = mid_pred(chosen_mv[f][0][0], chosen_mv[f][1][0], chosen_mv[f][2][0]);
- ty = mid_pred(chosen_mv[f][0][1], chosen_mv[f][1][1], chosen_mv[f][2][1]);
- break;
- case 2:
- tx = (chosen_mv[f][0][0] + chosen_mv[f][1][0]) / 2;
- ty = (chosen_mv[f][0][1] + chosen_mv[f][1][1]) / 2;
- break;
- default:
- av_assert2(0);
- }
- s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][0] = tx;
- s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][1] = ty;
- for (k = 0; k < 4; k++)
- v->mv_f[1][s->block_index[k] + v->blocks_off] = f;
- }
-
- if (v->fcm == ILACE_FRAME) { // not sure if needed for other types of picture
- int qx, qy;
- int width = s->avctx->coded_width;
- int height = s->avctx->coded_height >> 1;
- qx = (s->mb_x * 16) + (mx >> 2);
- qy = (s->mb_y * 8) + (my >> 3);
-
- if (qx < -17)
- mx -= 4 * (qx + 17);
- else if (qx > width)
- mx -= 4 * (qx - width);
- if (qy < -18)
- my -= 8 * (qy + 18);
- else if (qy > height + 1)
- my -= 8 * (qy - height - 1);
- }
-
- if ((v->fcm == ILACE_FRAME) && fieldmv)
- off = ((n > 1) ? s->linesize : 0) + (n & 1) * 8;
- else
- off = s->linesize * 4 * (n & 2) + (n & 1) * 8;
-
- src_x = s->mb_x * 16 + (n & 1) * 8 + (mx >> 2);
- if (!fieldmv)
- src_y = s->mb_y * 16 + (n & 2) * 4 + (my >> 2);
- else
- src_y = s->mb_y * 16 + ((n > 1) ? 1 : 0) + (my >> 2);
-
- if (v->profile != PROFILE_ADVANCED) {
- src_x = av_clip(src_x, -16, s->mb_width * 16);
- src_y = av_clip(src_y, -16, s->mb_height * 16);
- } else {
- src_x = av_clip(src_x, -17, s->avctx->coded_width);
- if (v->fcm == ILACE_FRAME) {
- if (src_y & 1)
- src_y = av_clip(src_y, -17, s->avctx->coded_height + 1);
- else
- src_y = av_clip(src_y, -18, s->avctx->coded_height);
- } else {
- src_y = av_clip(src_y, -18, s->avctx->coded_height + 1);
- }
- }
-
- srcY += src_y * s->linesize + src_x;
- if (v->field_mode && v->ref_field_type[dir])
- srcY += s->current_picture_ptr->f.linesize[0];
-
- if (fieldmv && !(src_y & 1))
- v_edge_pos--;
- if (fieldmv && (src_y & 1) && src_y < 4)
- src_y--;
- if (v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP)
- || s->h_edge_pos < 13 || v_edge_pos < 23
- || (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx & 3) - 8 - s->mspel * 2
- || (unsigned)(src_y - (s->mspel << fieldmv)) > v_edge_pos - (my & 3) - ((8 + s->mspel * 2) << fieldmv)) {
- srcY -= s->mspel * (1 + (s->linesize << fieldmv));
- /* check emulate edge stride and offset */
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize,
- 9 + s->mspel * 2, (9 + s->mspel * 2) << fieldmv,
- src_x - s->mspel, src_y - (s->mspel << fieldmv),
- s->h_edge_pos, v_edge_pos);
- srcY = s->edge_emu_buffer;
- /* if we deal with range reduction we need to scale source blocks */
- if (v->rangeredfrm) {
- int i, j;
- uint8_t *src;
-
- src = srcY;
- for (j = 0; j < 9 + s->mspel * 2; j++) {
- for (i = 0; i < 9 + s->mspel * 2; i++)
- src[i] = ((src[i] - 128) >> 1) + 128;
- src += s->linesize << fieldmv;
- }
- }
- /* if we deal with intensity compensation we need to scale source blocks */
- if (v->mv_mode == MV_PMODE_INTENSITY_COMP) {
- int i, j;
- uint8_t *src;
-
- src = srcY;
- for (j = 0; j < 9 + s->mspel * 2; j++) {
- for (i = 0; i < 9 + s->mspel * 2; i++)
- src[i] = v->luty[src[i]];
- src += s->linesize << fieldmv;
- }
- }
- srcY += s->mspel * (1 + (s->linesize << fieldmv));
- }
-
- if (s->mspel) {
- dxy = ((my & 3) << 2) | (mx & 3);
- v->vc1dsp.put_vc1_mspel_pixels_tab[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)
- dsp->put_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize, 8);
- else
- dsp->put_no_rnd_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize, 8);
- }
-}
-
-static av_always_inline int get_chroma_mv(int *mvx, int *mvy, int *a, int flag, int *tx, int *ty)
-{
- int idx, i;
- static const int count[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4};
-
- idx = ((a[3] != flag) << 3)
- | ((a[2] != flag) << 2)
- | ((a[1] != flag) << 1)
- | (a[0] != flag);
- if (!idx) {
- *tx = median4(mvx[0], mvx[1], mvx[2], mvx[3]);
- *ty = median4(mvy[0], mvy[1], mvy[2], mvy[3]);
- return 4;
- } else if (count[idx] == 1) {
- switch (idx) {
- case 0x1:
- *tx = mid_pred(mvx[1], mvx[2], mvx[3]);
- *ty = mid_pred(mvy[1], mvy[2], mvy[3]);
- return 3;
- case 0x2:
- *tx = mid_pred(mvx[0], mvx[2], mvx[3]);
- *ty = mid_pred(mvy[0], mvy[2], mvy[3]);
- return 3;
- case 0x4:
- *tx = mid_pred(mvx[0], mvx[1], mvx[3]);
- *ty = mid_pred(mvy[0], mvy[1], mvy[3]);
- return 3;
- case 0x8:
- *tx = mid_pred(mvx[0], mvx[1], mvx[2]);
- *ty = mid_pred(mvy[0], mvy[1], mvy[2]);
- return 3;
- }
- } else if (count[idx] == 2) {
- int t1 = 0, t2 = 0;
- for (i = 0; i < 3; i++)
- if (!a[i]) {
- t1 = i;
- break;
- }
- for (i = t1 + 1; i < 4; i++)
- if (!a[i]) {
- t2 = i;
- break;
- }
- *tx = (mvx[t1] + mvx[t2]) / 2;
- *ty = (mvy[t1] + mvy[t2]) / 2;
- return 2;
- } else {
- return 0;
- }
- return -1;
-}
-
-/** Do motion compensation for 4-MV macroblock - both chroma blocks
- */
-static void vc1_mc_4mv_chroma(VC1Context *v, int dir)
-{
- MpegEncContext *s = &v->s;
- H264ChromaContext *h264chroma = &v->h264chroma;
- uint8_t *srcU, *srcV;
- int uvmx, uvmy, uvsrc_x, uvsrc_y;
- int k, tx = 0, ty = 0;
- int mvx[4], mvy[4], intra[4], mv_f[4];
- int valid_count;
- int chroma_ref_type = v->cur_field_type, off = 0;
- int v_edge_pos = s->v_edge_pos >> v->field_mode;
-
- if (!v->field_mode && !v->s.last_picture.f.data[0])
- return;
- if (s->flags & CODEC_FLAG_GRAY)
- return;
-
- for (k = 0; k < 4; k++) {
- mvx[k] = s->mv[dir][k][0];
- mvy[k] = s->mv[dir][k][1];
- intra[k] = v->mb_type[0][s->block_index[k]];
- if (v->field_mode)
- mv_f[k] = v->mv_f[dir][s->block_index[k] + v->blocks_off];
- }
-
- /* calculate chroma MV vector from four luma MVs */
- if (!v->field_mode || (v->field_mode && !v->numref)) {
- valid_count = get_chroma_mv(mvx, mvy, intra, 0, &tx, &ty);
- chroma_ref_type = v->reffield;
- if (!valid_count) {
- s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][0] = 0;
- s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][1] = 0;
- v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0;
- return; //no need to do MC for intra blocks
- }
- } else {
- int dominant = 0;
- if (mv_f[0] + mv_f[1] + mv_f[2] + mv_f[3] > 2)
- dominant = 1;
- valid_count = get_chroma_mv(mvx, mvy, mv_f, dominant, &tx, &ty);
- 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])
- return;
- s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][0] = tx;
- s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][1] = ty;
- uvmx = (tx + ((tx & 3) == 3)) >> 1;
- uvmy = (ty + ((ty & 3) == 3)) >> 1;
-
- v->luma_mv[s->mb_x][0] = uvmx;
- v->luma_mv[s->mb_x][1] = uvmy;
-
- if (v->fastuvmc) {
- uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1));
- uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1));
- }
- // Field conversion bias
- if (v->cur_field_type != chroma_ref_type)
- uvmy += 2 - 4 * chroma_ref_type;
-
- uvsrc_x = s->mb_x * 8 + (uvmx >> 2);
- uvsrc_y = s->mb_y * 8 + (uvmy >> 2);
-
- if (v->profile != PROFILE_ADVANCED) {
- uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width * 8);
- uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8);
- } else {
- 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 (!dir) {
- if (v->field_mode) {
- if ((v->cur_field_type != chroma_ref_type) && v->cur_field_type) {
- srcU = s->current_picture.f.data[1];
- srcV = s->current_picture.f.data[2];
- } else {
- srcU = s->last_picture.f.data[1];
- srcV = s->last_picture.f.data[2];
- }
- } else {
- srcU = s->last_picture.f.data[1];
- srcV = s->last_picture.f.data[2];
- }
- } else {
- srcU = s->next_picture.f.data[1];
- srcV = s->next_picture.f.data[2];
- }
-
- if(!srcU)
- return;
-
- srcU += uvsrc_y * s->uvlinesize + uvsrc_x;
- srcV += uvsrc_y * s->uvlinesize + uvsrc_x;
-
- if (v->field_mode) {
- if (chroma_ref_type) {
- srcU += s->current_picture_ptr->f.linesize[1];
- srcV += s->current_picture_ptr->f.linesize[2];
- }
- off = 0;
- }
-
- if (v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP)
- || s->h_edge_pos < 18 || v_edge_pos < 18
- || (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 9
- || (unsigned)uvsrc_y > (v_edge_pos >> 1) - 9) {
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer , srcU, s->uvlinesize,
- 8 + 1, 8 + 1, uvsrc_x, uvsrc_y,
- s->h_edge_pos >> 1, v_edge_pos >> 1);
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer + 16, srcV, s->uvlinesize,
- 8 + 1, 8 + 1, uvsrc_x, uvsrc_y,
- s->h_edge_pos >> 1, v_edge_pos >> 1);
- srcU = s->edge_emu_buffer;
- srcV = s->edge_emu_buffer + 16;
-
- /* if we deal with range reduction we need to scale source blocks */
- if (v->rangeredfrm) {
- int i, j;
- uint8_t *src, *src2;
-
- src = srcU;
- src2 = srcV;
- for (j = 0; j < 9; j++) {
- for (i = 0; i < 9; i++) {
- src[i] = ((src[i] - 128) >> 1) + 128;
- src2[i] = ((src2[i] - 128) >> 1) + 128;
- }
- src += s->uvlinesize;
- src2 += s->uvlinesize;
- }
- }
- /* if we deal with intensity compensation we need to scale source blocks */
- if (v->mv_mode == MV_PMODE_INTENSITY_COMP) {
- int i, j;
- uint8_t *src, *src2;
-
- src = srcU;
- src2 = srcV;
- for (j = 0; j < 9; j++) {
- for (i = 0; i < 9; i++) {
- src[i] = v->lutuv[src[i]];
- src2[i] = v->lutuv[src2[i]];
- }
- src += s->uvlinesize;
- src2 += s->uvlinesize;
- }
- }
- }
-
- /* Chroma MC always uses qpel bilinear */
- uvmx = (uvmx & 3) << 1;
- uvmy = (uvmy & 3) << 1;
- if (!v->rnd) {
- h264chroma->put_h264_chroma_pixels_tab[0](s->dest[1] + off, srcU, s->uvlinesize, 8, uvmx, uvmy);
- h264chroma->put_h264_chroma_pixels_tab[0](s->dest[2] + off, srcV, s->uvlinesize, 8, uvmx, uvmy);
- } else {
- v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1] + off, srcU, s->uvlinesize, 8, uvmx, uvmy);
- v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2] + off, srcV, s->uvlinesize, 8, uvmx, uvmy);
- }
-}
-
-/** Do motion compensation for 4-MV field chroma macroblock (both U and V)
- */
-static void vc1_mc_4mv_chroma4(VC1Context *v)
-{
- MpegEncContext *s = &v->s;
- H264ChromaContext *h264chroma = &v->h264chroma;
- uint8_t *srcU, *srcV;
- int uvsrc_x, uvsrc_y;
- int uvmx_field[4], uvmy_field[4];
- int i, off, tx, ty;
- int fieldmv = v->blk_mv_type[s->block_index[0]];
- static const int s_rndtblfield[16] = { 0, 0, 1, 2, 4, 4, 5, 6, 2, 2, 3, 8, 6, 6, 7, 12 };
- int v_dist = fieldmv ? 1 : 4; // vertical offset for lower sub-blocks
- int v_edge_pos = s->v_edge_pos >> 1;
-
- if (!v->s.last_picture.f.data[0])
- return;
- if (s->flags & CODEC_FLAG_GRAY)
- return;
-
- for (i = 0; i < 4; i++) {
- tx = s->mv[0][i][0];
- uvmx_field[i] = (tx + ((tx & 3) == 3)) >> 1;
- ty = s->mv[0][i][1];
- if (fieldmv)
- uvmy_field[i] = (ty >> 4) * 8 + s_rndtblfield[ty & 0xF];
- else
- uvmy_field[i] = (ty + ((ty & 3) == 3)) >> 1;
- }
-
- for (i = 0; i < 4; i++) {
- off = (i & 1) * 4 + ((i & 2) ? v_dist * s->uvlinesize : 0);
- uvsrc_x = s->mb_x * 8 + (i & 1) * 4 + (uvmx_field[i] >> 2);
- uvsrc_y = s->mb_y * 8 + ((i & 2) ? v_dist : 0) + (uvmy_field[i] >> 2);
- // FIXME: implement proper pull-back (see vc1cropmv.c, vc1CROPMV_ChromaPullBack())
- uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1);
- uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1);
- srcU = s->last_picture.f.data[1] + uvsrc_y * s->uvlinesize + uvsrc_x;
- srcV = s->last_picture.f.data[2] + uvsrc_y * s->uvlinesize + uvsrc_x;
- uvmx_field[i] = (uvmx_field[i] & 3) << 1;
- uvmy_field[i] = (uvmy_field[i] & 3) << 1;
-
- if (fieldmv && !(uvsrc_y & 1))
- v_edge_pos = (s->v_edge_pos >> 1) - 1;
-
- if (fieldmv && (uvsrc_y & 1) && uvsrc_y < 2)
- uvsrc_y--;
- if ((v->mv_mode == MV_PMODE_INTENSITY_COMP)
- || s->h_edge_pos < 10 || v_edge_pos < (5 << fieldmv)
- || (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 5
- || (unsigned)uvsrc_y > v_edge_pos - (5 << fieldmv)) {
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer, srcU, s->uvlinesize,
- 5, (5 << fieldmv), uvsrc_x, uvsrc_y,
- s->h_edge_pos >> 1, v_edge_pos);
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer + 16, srcV, s->uvlinesize,
- 5, (5 << fieldmv), uvsrc_x, uvsrc_y,
- s->h_edge_pos >> 1, v_edge_pos);
- srcU = s->edge_emu_buffer;
- srcV = s->edge_emu_buffer + 16;
-
- /* if we deal with intensity compensation we need to scale source blocks */
- if (v->mv_mode == MV_PMODE_INTENSITY_COMP) {
- int i, j;
- uint8_t *src, *src2;
-
- src = srcU;
- src2 = srcV;
- for (j = 0; j < 5; j++) {
- for (i = 0; i < 5; i++) {
- src[i] = v->lutuv[src[i]];
- src2[i] = v->lutuv[src2[i]];
- }
- src += s->uvlinesize << 1;
- src2 += s->uvlinesize << 1;
- }
- }
- }
- if (!v->rnd) {
- h264chroma->put_h264_chroma_pixels_tab[1](s->dest[1] + off, srcU, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
- h264chroma->put_h264_chroma_pixels_tab[1](s->dest[2] + off, srcV, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
- } else {
- v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[1](s->dest[1] + off, srcU, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
- v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[1](s->dest[2] + off, srcV, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
- }
- }
-}
-
-/***********************************************************************/
-/**
- * @name VC-1 Block-level functions
- * @see 7.1.4, p91 and 8.1.1.7, p(1)04
- * @{
- */
-
-/**
- * @def GET_MQUANT
- * @brief Get macroblock-level quantizer scale
- */
-#define GET_MQUANT() \
- if (v->dquantfrm) { \
- int edges = 0; \
- if (v->dqprofile == DQPROFILE_ALL_MBS) { \
- if (v->dqbilevel) { \
- mquant = (get_bits1(gb)) ? v->altpq : v->pq; \
- } else { \
- mqdiff = get_bits(gb, 3); \
- if (mqdiff != 7) \
- mquant = v->pq + mqdiff; \
- else \
- mquant = get_bits(gb, 5); \
- } \
- } \
- if (v->dqprofile == DQPROFILE_SINGLE_EDGE) \
- edges = 1 << v->dqsbedge; \
- else if (v->dqprofile == DQPROFILE_DOUBLE_EDGES) \
- edges = (3 << v->dqsbedge) % 15; \
- else if (v->dqprofile == DQPROFILE_FOUR_EDGES) \
- edges = 15; \
- if ((edges&1) && !s->mb_x) \
- mquant = v->altpq; \
- if ((edges&2) && s->first_slice_line) \
- mquant = v->altpq; \
- if ((edges&4) && s->mb_x == (s->mb_width - 1)) \
- mquant = v->altpq; \
- if ((edges&8) && s->mb_y == (s->mb_height - 1)) \
- mquant = v->altpq; \
- if (!mquant || mquant > 31) { \
- av_log(v->s.avctx, AV_LOG_ERROR, \
- "Overriding invalid mquant %d\n", mquant); \
- mquant = 1; \
- } \
- }
-
-/**
- * @def GET_MVDATA(_dmv_x, _dmv_y)
- * @brief Get MV differentials
- * @see MVDATA decoding from 8.3.5.2, p(1)20
- * @param _dmv_x Horizontal differential for decoded MV
- * @param _dmv_y Vertical differential for decoded MV
- */
-#define GET_MVDATA(_dmv_x, _dmv_y) \
- index = 1 + get_vlc2(gb, ff_vc1_mv_diff_vlc[s->mv_table_index].table, \
- VC1_MV_DIFF_VLC_BITS, 2); \
- if (index > 36) { \
- mb_has_coeffs = 1; \
- index -= 37; \
- } else \
- mb_has_coeffs = 0; \
- s->mb_intra = 0; \
- if (!index) { \
- _dmv_x = _dmv_y = 0; \
- } else if (index == 35) { \
- _dmv_x = get_bits(gb, v->k_x - 1 + s->quarter_sample); \
- _dmv_y = get_bits(gb, v->k_y - 1 + s->quarter_sample); \
- } else if (index == 36) { \
- _dmv_x = 0; \
- _dmv_y = 0; \
- s->mb_intra = 1; \
- } else { \
- index1 = index % 6; \
- if (!s->quarter_sample && index1 == 5) val = 1; \
- else val = 0; \
- if (size_table[index1] - val > 0) \
- val = get_bits(gb, size_table[index1] - val); \
- else val = 0; \
- sign = 0 - (val&1); \
- _dmv_x = (sign ^ ((val>>1) + offset_table[index1])) - sign; \
- \
- index1 = index / 6; \
- if (!s->quarter_sample && index1 == 5) val = 1; \
- else val = 0; \
- if (size_table[index1] - val > 0) \
- val = get_bits(gb, size_table[index1] - val); \
- else val = 0; \
- sign = 0 - (val & 1); \
- _dmv_y = (sign ^ ((val >> 1) + offset_table[index1])) - sign; \
- }
-
-static av_always_inline void get_mvdata_interlaced(VC1Context *v, int *dmv_x,
- int *dmv_y, int *pred_flag)
-{
- int index, index1;
- int extend_x = 0, extend_y = 0;
- GetBitContext *gb = &v->s.gb;
- int bits, esc;
- int val, sign;
- const int* offs_tab;
-
- if (v->numref) {
- bits = VC1_2REF_MVDATA_VLC_BITS;
- esc = 125;
- } else {
- bits = VC1_1REF_MVDATA_VLC_BITS;
- esc = 71;
- }
- switch (v->dmvrange) {
- case 1:
- extend_x = 1;
- break;
- case 2:
- extend_y = 1;
- break;
- case 3:
- extend_x = extend_y = 1;
- break;
- }
- index = get_vlc2(gb, v->imv_vlc->table, bits, 3);
- if (index == esc) {
- *dmv_x = get_bits(gb, v->k_x);
- *dmv_y = get_bits(gb, v->k_y);
- if (v->numref) {
- if (pred_flag) {
- *pred_flag = *dmv_y & 1;
- *dmv_y = (*dmv_y + *pred_flag) >> 1;
- } else {
- *dmv_y = (*dmv_y + (*dmv_y & 1)) >> 1;
- }
- }
- }
- else {
- av_assert0(index < esc);
- if (extend_x)
- offs_tab = offset_table2;
- else
- offs_tab = offset_table1;
- index1 = (index + 1) % 9;
- if (index1 != 0) {
- val = get_bits(gb, index1 + extend_x);
- sign = 0 -(val & 1);
- *dmv_x = (sign ^ ((val >> 1) + offs_tab[index1])) - sign;
- } else
- *dmv_x = 0;
- if (extend_y)
- offs_tab = offset_table2;
- else
- offs_tab = offset_table1;
- index1 = (index + 1) / 9;
- if (index1 > v->numref) {
- val = get_bits(gb, (index1 + (extend_y << v->numref)) >> v->numref);
- sign = 0 - (val & 1);
- *dmv_y = (sign ^ ((val >> 1) + offs_tab[index1 >> v->numref])) - sign;
- } else
- *dmv_y = 0;
- if (v->numref && pred_flag)
- *pred_flag = index1 & 1;
- }
-}
-
-static av_always_inline int scaleforsame_x(VC1Context *v, int n /* MV */, int dir)
-{
- int scaledvalue, refdist;
- int scalesame1, scalesame2;
- int scalezone1_x, zone1offset_x;
- int table_index = dir ^ v->second_field;
-
- if (v->s.pict_type != AV_PICTURE_TYPE_B)
- refdist = v->refdist;
- else
- refdist = dir ? v->brfd : v->frfd;
- if (refdist > 3)
- refdist = 3;
- scalesame1 = ff_vc1_field_mvpred_scales[table_index][1][refdist];
- scalesame2 = ff_vc1_field_mvpred_scales[table_index][2][refdist];
- scalezone1_x = ff_vc1_field_mvpred_scales[table_index][3][refdist];
- zone1offset_x = ff_vc1_field_mvpred_scales[table_index][5][refdist];
-
- if (FFABS(n) > 255)
- scaledvalue = n;
- else {
- if (FFABS(n) < scalezone1_x)
- scaledvalue = (n * scalesame1) >> 8;
- else {
- if (n < 0)
- scaledvalue = ((n * scalesame2) >> 8) - zone1offset_x;
- else
- scaledvalue = ((n * scalesame2) >> 8) + zone1offset_x;
- }
- }
- return av_clip(scaledvalue, -v->range_x, v->range_x - 1);
-}
-
-static av_always_inline int scaleforsame_y(VC1Context *v, int i, int n /* MV */, int dir)
-{
- int scaledvalue, refdist;
- int scalesame1, scalesame2;
- int scalezone1_y, zone1offset_y;
- int table_index = dir ^ v->second_field;
-
- if (v->s.pict_type != AV_PICTURE_TYPE_B)
- refdist = v->refdist;
- else
- refdist = dir ? v->brfd : v->frfd;
- if (refdist > 3)
- refdist = 3;
- scalesame1 = ff_vc1_field_mvpred_scales[table_index][1][refdist];
- scalesame2 = ff_vc1_field_mvpred_scales[table_index][2][refdist];
- scalezone1_y = ff_vc1_field_mvpred_scales[table_index][4][refdist];
- zone1offset_y = ff_vc1_field_mvpred_scales[table_index][6][refdist];
-
- if (FFABS(n) > 63)
- scaledvalue = n;
- else {
- if (FFABS(n) < scalezone1_y)
- scaledvalue = (n * scalesame1) >> 8;
- else {
- if (n < 0)
- scaledvalue = ((n * scalesame2) >> 8) - zone1offset_y;
- else
- scaledvalue = ((n * scalesame2) >> 8) + zone1offset_y;
- }
- }
-
- if (v->cur_field_type && !v->ref_field_type[dir])
- return av_clip(scaledvalue, -v->range_y / 2 + 1, v->range_y / 2);
- else
- return av_clip(scaledvalue, -v->range_y / 2, v->range_y / 2 - 1);
-}
-
-static av_always_inline int scaleforopp_x(VC1Context *v, int n /* MV */)
-{
- int scalezone1_x, zone1offset_x;
- int scaleopp1, scaleopp2, brfd;
- int scaledvalue;
-
- brfd = FFMIN(v->brfd, 3);
- scalezone1_x = ff_vc1_b_field_mvpred_scales[3][brfd];
- zone1offset_x = ff_vc1_b_field_mvpred_scales[5][brfd];
- scaleopp1 = ff_vc1_b_field_mvpred_scales[1][brfd];
- scaleopp2 = ff_vc1_b_field_mvpred_scales[2][brfd];
-
- if (FFABS(n) > 255)
- scaledvalue = n;
- else {
- if (FFABS(n) < scalezone1_x)
- scaledvalue = (n * scaleopp1) >> 8;
- else {
- if (n < 0)
- scaledvalue = ((n * scaleopp2) >> 8) - zone1offset_x;
- else
- scaledvalue = ((n * scaleopp2) >> 8) + zone1offset_x;
- }
- }
- return av_clip(scaledvalue, -v->range_x, v->range_x - 1);
-}
-
-static av_always_inline int scaleforopp_y(VC1Context *v, int n /* MV */, int dir)
-{
- int scalezone1_y, zone1offset_y;
- int scaleopp1, scaleopp2, brfd;
- int scaledvalue;
-
- brfd = FFMIN(v->brfd, 3);
- scalezone1_y = ff_vc1_b_field_mvpred_scales[4][brfd];
- zone1offset_y = ff_vc1_b_field_mvpred_scales[6][brfd];
- scaleopp1 = ff_vc1_b_field_mvpred_scales[1][brfd];
- scaleopp2 = ff_vc1_b_field_mvpred_scales[2][brfd];
-
- if (FFABS(n) > 63)
- scaledvalue = n;
- else {
- if (FFABS(n) < scalezone1_y)
- scaledvalue = (n * scaleopp1) >> 8;
- else {
- if (n < 0)
- scaledvalue = ((n * scaleopp2) >> 8) - zone1offset_y;
- else
- scaledvalue = ((n * scaleopp2) >> 8) + zone1offset_y;
- }
- }
- if (v->cur_field_type && !v->ref_field_type[dir]) {
- return av_clip(scaledvalue, -v->range_y / 2 + 1, v->range_y / 2);
- } else {
- return av_clip(scaledvalue, -v->range_y / 2, v->range_y / 2 - 1);
- }
-}
-
-static av_always_inline int scaleforsame(VC1Context *v, int i, int n /* MV */,
- int dim, int dir)
-{
- int brfd, scalesame;
- int hpel = 1 - v->s.quarter_sample;
-
- n >>= hpel;
- if (v->s.pict_type != AV_PICTURE_TYPE_B || v->second_field || !dir) {
- if (dim)
- n = scaleforsame_y(v, i, n, dir) << hpel;
- else
- n = scaleforsame_x(v, n, dir) << hpel;
- return n;
- }
- brfd = FFMIN(v->brfd, 3);
- scalesame = ff_vc1_b_field_mvpred_scales[0][brfd];
-
- n = (n * scalesame >> 8) << hpel;
- return n;
-}
-
-static av_always_inline int scaleforopp(VC1Context *v, int n /* MV */,
- int dim, int dir)
-{
- int refdist, scaleopp;
- int hpel = 1 - v->s.quarter_sample;
-
- n >>= hpel;
- if (v->s.pict_type == AV_PICTURE_TYPE_B && !v->second_field && dir == 1) {
- if (dim)
- n = scaleforopp_y(v, n, dir) << hpel;
- else
- n = scaleforopp_x(v, n) << hpel;
- return n;
- }
- if (v->s.pict_type != AV_PICTURE_TYPE_B)
- refdist = FFMIN(v->refdist, 3);
- else
- refdist = dir ? v->brfd : v->frfd;
- scaleopp = ff_vc1_field_mvpred_scales[dir ^ v->second_field][0][refdist];
-
- n = (n * scaleopp >> 8) << hpel;
- return n;
-}
-
-/** Predict and set motion vector
- */
-static inline void vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y,
- int mv1, int r_x, int r_y, uint8_t* is_intra,
- int pred_flag, int dir)
-{
- MpegEncContext *s = &v->s;
- int xy, wrap, off = 0;
- int16_t *A, *B, *C;
- int px, py;
- int sum;
- int mixedmv_pic, num_samefield = 0, num_oppfield = 0;
- int opposite, a_f, b_f, c_f;
- int16_t field_predA[2];
- int16_t field_predB[2];
- int16_t field_predC[2];
- int a_valid, b_valid, c_valid;
- int hybridmv_thresh, y_bias = 0;
-
- if (v->mv_mode == MV_PMODE_MIXED_MV ||
- ((v->mv_mode == MV_PMODE_INTENSITY_COMP) && (v->mv_mode2 == MV_PMODE_MIXED_MV)))
- mixedmv_pic = 1;
- else
- mixedmv_pic = 0;
- /* scale MV difference to be quad-pel */
- dmv_x <<= 1 - s->quarter_sample;
- dmv_y <<= 1 - s->quarter_sample;
-
- wrap = s->b8_stride;
- xy = s->block_index[n];
-
- if (s->mb_intra) {
- s->mv[0][n][0] = s->current_picture.f.motion_val[0][xy + v->blocks_off][0] = 0;
- s->mv[0][n][1] = s->current_picture.f.motion_val[0][xy + v->blocks_off][1] = 0;
- s->current_picture.f.motion_val[1][xy + v->blocks_off][0] = 0;
- s->current_picture.f.motion_val[1][xy + v->blocks_off][1] = 0;
- if (mv1) { /* duplicate motion data for 1-MV block */
- s->current_picture.f.motion_val[0][xy + 1 + v->blocks_off][0] = 0;
- s->current_picture.f.motion_val[0][xy + 1 + v->blocks_off][1] = 0;
- s->current_picture.f.motion_val[0][xy + wrap + v->blocks_off][0] = 0;
- s->current_picture.f.motion_val[0][xy + wrap + v->blocks_off][1] = 0;
- s->current_picture.f.motion_val[0][xy + wrap + 1 + v->blocks_off][0] = 0;
- s->current_picture.f.motion_val[0][xy + wrap + 1 + v->blocks_off][1] = 0;
- v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0;
- s->current_picture.f.motion_val[1][xy + 1 + v->blocks_off][0] = 0;
- s->current_picture.f.motion_val[1][xy + 1 + v->blocks_off][1] = 0;
- s->current_picture.f.motion_val[1][xy + wrap][0] = 0;
- s->current_picture.f.motion_val[1][xy + wrap + v->blocks_off][1] = 0;
- s->current_picture.f.motion_val[1][xy + wrap + 1 + v->blocks_off][0] = 0;
- s->current_picture.f.motion_val[1][xy + wrap + 1 + v->blocks_off][1] = 0;
- }
- return;
- }
-
- C = s->current_picture.f.motion_val[dir][xy - 1 + v->blocks_off];
- A = s->current_picture.f.motion_val[dir][xy - wrap + v->blocks_off];
- if (mv1) {
- if (v->field_mode && mixedmv_pic)
- off = (s->mb_x == (s->mb_width - 1)) ? -2 : 2;
- else
- off = (s->mb_x == (s->mb_width - 1)) ? -1 : 2;
- } else {
- //in 4-MV mode different blocks have different B predictor position
- switch (n) {
- case 0:
- off = (s->mb_x > 0) ? -1 : 1;
- break;
- case 1:
- off = (s->mb_x == (s->mb_width - 1)) ? -1 : 1;
- break;
- case 2:
- off = 1;
- break;
- case 3:
- off = -1;
- }
- }
- B = s->current_picture.f.motion_val[dir][xy - wrap + off + v->blocks_off];
-
- a_valid = !s->first_slice_line || (n == 2 || n == 3);
- b_valid = a_valid && (s->mb_width > 1);
- c_valid = s->mb_x || (n == 1 || n == 3);
- if (v->field_mode) {
- a_valid = a_valid && !is_intra[xy - wrap];
- b_valid = b_valid && !is_intra[xy - wrap + off];
- c_valid = c_valid && !is_intra[xy - 1];
- }
-
- if (a_valid) {
- a_f = v->mv_f[dir][xy - wrap + v->blocks_off];
- num_oppfield += a_f;
- num_samefield += 1 - a_f;
- field_predA[0] = A[0];
- field_predA[1] = A[1];
- } else {
- field_predA[0] = field_predA[1] = 0;
- a_f = 0;
- }
- if (b_valid) {
- b_f = v->mv_f[dir][xy - wrap + off + v->blocks_off];
- num_oppfield += b_f;
- num_samefield += 1 - b_f;
- field_predB[0] = B[0];
- field_predB[1] = B[1];
- } else {
- field_predB[0] = field_predB[1] = 0;
- b_f = 0;
- }
- if (c_valid) {
- c_f = v->mv_f[dir][xy - 1 + v->blocks_off];
- num_oppfield += c_f;
- num_samefield += 1 - c_f;
- field_predC[0] = C[0];
- field_predC[1] = C[1];
- } else {
- field_predC[0] = field_predC[1] = 0;
- c_f = 0;
- }
-
- if (v->field_mode) {
- if (!v->numref)
- // REFFIELD determines if the last field or the second-last field is
- // to be used as reference
- opposite = 1 - v->reffield;
- else {
- if (num_samefield <= num_oppfield)
- opposite = 1 - pred_flag;
- else
- opposite = pred_flag;
- }
- } else
- opposite = 0;
- if (opposite) {
- if (a_valid && !a_f) {
- field_predA[0] = scaleforopp(v, field_predA[0], 0, dir);
- field_predA[1] = scaleforopp(v, field_predA[1], 1, dir);
- }
- if (b_valid && !b_f) {
- field_predB[0] = scaleforopp(v, field_predB[0], 0, dir);
- field_predB[1] = scaleforopp(v, field_predB[1], 1, dir);
- }
- if (c_valid && !c_f) {
- field_predC[0] = scaleforopp(v, field_predC[0], 0, dir);
- field_predC[1] = scaleforopp(v, field_predC[1], 1, dir);
- }
- v->mv_f[dir][xy + v->blocks_off] = 1;
- v->ref_field_type[dir] = !v->cur_field_type;
- } else {
- if (a_valid && a_f) {
- field_predA[0] = scaleforsame(v, n, field_predA[0], 0, dir);
- field_predA[1] = scaleforsame(v, n, field_predA[1], 1, dir);
- }
- if (b_valid && b_f) {
- field_predB[0] = scaleforsame(v, n, field_predB[0], 0, dir);
- field_predB[1] = scaleforsame(v, n, field_predB[1], 1, dir);
- }
- if (c_valid && c_f) {
- field_predC[0] = scaleforsame(v, n, field_predC[0], 0, dir);
- field_predC[1] = scaleforsame(v, n, field_predC[1], 1, dir);
- }
- v->mv_f[dir][xy + v->blocks_off] = 0;
- v->ref_field_type[dir] = v->cur_field_type;
- }
-
- if (a_valid) {
- px = field_predA[0];
- py = field_predA[1];
- } else if (c_valid) {
- px = field_predC[0];
- py = field_predC[1];
- } else if (b_valid) {
- px = field_predB[0];
- py = field_predB[1];
- } else {
- px = 0;
- py = 0;
- }
-
- if (num_samefield + num_oppfield > 1) {
- px = mid_pred(field_predA[0], field_predB[0], field_predC[0]);
- py = mid_pred(field_predA[1], field_predB[1], field_predC[1]);
- }
-
- /* Pullback MV as specified in 8.3.5.3.4 */
- if (!v->field_mode) {
- int qx, qy, X, Y;
- qx = (s->mb_x << 6) + ((n == 1 || n == 3) ? 32 : 0);
- qy = (s->mb_y << 6) + ((n == 2 || n == 3) ? 32 : 0);
- X = (s->mb_width << 6) - 4;
- Y = (s->mb_height << 6) - 4;
- if (mv1) {
- if (qx + px < -60) px = -60 - qx;
- if (qy + py < -60) py = -60 - qy;
- } else {
- if (qx + px < -28) px = -28 - qx;
- if (qy + py < -28) py = -28 - qy;
- }
- if (qx + px > X) px = X - qx;
- if (qy + py > Y) py = Y - qy;
- }
-
- if (!v->field_mode || s->pict_type != AV_PICTURE_TYPE_B) {
- /* Calculate hybrid prediction as specified in 8.3.5.3.5 (also 10.3.5.4.3.5) */
- hybridmv_thresh = 32;
- if (a_valid && c_valid) {
- if (is_intra[xy - wrap])
- sum = FFABS(px) + FFABS(py);
- else
- sum = FFABS(px - field_predA[0]) + FFABS(py - field_predA[1]);
- if (sum > hybridmv_thresh) {
- if (get_bits1(&s->gb)) { // read HYBRIDPRED bit
- px = field_predA[0];
- py = field_predA[1];
- } else {
- px = field_predC[0];
- py = field_predC[1];
- }
- } else {
- if (is_intra[xy - 1])
- sum = FFABS(px) + FFABS(py);
- else
- sum = FFABS(px - field_predC[0]) + FFABS(py - field_predC[1]);
- if (sum > hybridmv_thresh) {
- if (get_bits1(&s->gb)) {
- px = field_predA[0];
- py = field_predA[1];
- } else {
- px = field_predC[0];
- py = field_predC[1];
- }
- }
- }
- }
- }
-
- if (v->field_mode && v->numref)
- r_y >>= 1;
- if (v->field_mode && v->cur_field_type && v->ref_field_type[dir] == 0)
- y_bias = 1;
- /* store MV using signed modulus of MV range defined in 4.11 */
- s->mv[dir][n][0] = s->current_picture.f.motion_val[dir][xy + v->blocks_off][0] = ((px + dmv_x + r_x) & ((r_x << 1) - 1)) - r_x;
- s->mv[dir][n][1] = s->current_picture.f.motion_val[dir][xy + v->blocks_off][1] = ((py + dmv_y + r_y - y_bias) & ((r_y << 1) - 1)) - r_y + y_bias;
- if (mv1) { /* duplicate motion data for 1-MV block */
- s->current_picture.f.motion_val[dir][xy + 1 + v->blocks_off][0] = s->current_picture.f.motion_val[dir][xy + v->blocks_off][0];
- s->current_picture.f.motion_val[dir][xy + 1 + v->blocks_off][1] = s->current_picture.f.motion_val[dir][xy + v->blocks_off][1];
- s->current_picture.f.motion_val[dir][xy + wrap + v->blocks_off][0] = s->current_picture.f.motion_val[dir][xy + v->blocks_off][0];
- s->current_picture.f.motion_val[dir][xy + wrap + v->blocks_off][1] = s->current_picture.f.motion_val[dir][xy + v->blocks_off][1];
- s->current_picture.f.motion_val[dir][xy + wrap + 1 + v->blocks_off][0] = s->current_picture.f.motion_val[dir][xy + v->blocks_off][0];
- s->current_picture.f.motion_val[dir][xy + wrap + 1 + v->blocks_off][1] = s->current_picture.f.motion_val[dir][xy + v->blocks_off][1];
- v->mv_f[dir][xy + 1 + v->blocks_off] = v->mv_f[dir][xy + v->blocks_off];
- v->mv_f[dir][xy + wrap + v->blocks_off] = v->mv_f[dir][xy + wrap + 1 + v->blocks_off] = v->mv_f[dir][xy + v->blocks_off];
- }
-}
-
-/** Predict and set motion vector for interlaced frame picture MBs
- */
-static inline void vc1_pred_mv_intfr(VC1Context *v, int n, int dmv_x, int dmv_y,
- int mvn, int r_x, int r_y, uint8_t* is_intra)
-{
- MpegEncContext *s = &v->s;
- int xy, wrap, off = 0;
- int A[2], B[2], C[2];
- int px, py;
- int a_valid = 0, b_valid = 0, c_valid = 0;
- int field_a, field_b, field_c; // 0: same, 1: opposit
- int total_valid, num_samefield, num_oppfield;
- int pos_c, pos_b, n_adj;
-
- wrap = s->b8_stride;
- xy = s->block_index[n];
-
- if (s->mb_intra) {
- s->mv[0][n][0] = s->current_picture.f.motion_val[0][xy][0] = 0;
- s->mv[0][n][1] = s->current_picture.f.motion_val[0][xy][1] = 0;
- s->current_picture.f.motion_val[1][xy][0] = 0;
- s->current_picture.f.motion_val[1][xy][1] = 0;
- if (mvn == 1) { /* duplicate motion data for 1-MV block */
- s->current_picture.f.motion_val[0][xy + 1][0] = 0;
- s->current_picture.f.motion_val[0][xy + 1][1] = 0;
- s->current_picture.f.motion_val[0][xy + wrap][0] = 0;
- s->current_picture.f.motion_val[0][xy + wrap][1] = 0;
- s->current_picture.f.motion_val[0][xy + wrap + 1][0] = 0;
- s->current_picture.f.motion_val[0][xy + wrap + 1][1] = 0;
- v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0;
- s->current_picture.f.motion_val[1][xy + 1][0] = 0;
- s->current_picture.f.motion_val[1][xy + 1][1] = 0;
- s->current_picture.f.motion_val[1][xy + wrap][0] = 0;
- s->current_picture.f.motion_val[1][xy + wrap][1] = 0;
- s->current_picture.f.motion_val[1][xy + wrap + 1][0] = 0;
- s->current_picture.f.motion_val[1][xy + wrap + 1][1] = 0;
- }
- return;
- }
-
- off = ((n == 0) || (n == 1)) ? 1 : -1;
- /* predict A */
- if (s->mb_x || (n == 1) || (n == 3)) {
- if ((v->blk_mv_type[xy]) // current block (MB) has a field MV
- || (!v->blk_mv_type[xy] && !v->blk_mv_type[xy - 1])) { // or both have frame MV
- A[0] = s->current_picture.f.motion_val[0][xy - 1][0];
- A[1] = s->current_picture.f.motion_val[0][xy - 1][1];
- a_valid = 1;
- } else { // current block has frame mv and cand. has field MV (so average)
- A[0] = (s->current_picture.f.motion_val[0][xy - 1][0]
- + s->current_picture.f.motion_val[0][xy - 1 + off * wrap][0] + 1) >> 1;
- A[1] = (s->current_picture.f.motion_val[0][xy - 1][1]
- + s->current_picture.f.motion_val[0][xy - 1 + off * wrap][1] + 1) >> 1;
- a_valid = 1;
- }
- if (!(n & 1) && v->is_intra[s->mb_x - 1]) {
- a_valid = 0;
- A[0] = A[1] = 0;
- }
- } else
- A[0] = A[1] = 0;
- /* Predict B and C */
- B[0] = B[1] = C[0] = C[1] = 0;
- if (n == 0 || n == 1 || v->blk_mv_type[xy]) {
- if (!s->first_slice_line) {
- if (!v->is_intra[s->mb_x - s->mb_stride]) {
- b_valid = 1;
- n_adj = n | 2;
- pos_b = s->block_index[n_adj] - 2 * wrap;
- if (v->blk_mv_type[pos_b] && v->blk_mv_type[xy]) {
- n_adj = (n & 2) | (n & 1);
- }
- B[0] = s->current_picture.f.motion_val[0][s->block_index[n_adj] - 2 * wrap][0];
- B[1] = s->current_picture.f.motion_val[0][s->block_index[n_adj] - 2 * wrap][1];
- if (v->blk_mv_type[pos_b] && !v->blk_mv_type[xy]) {
- B[0] = (B[0] + s->current_picture.f.motion_val[0][s->block_index[n_adj ^ 2] - 2 * wrap][0] + 1) >> 1;
- B[1] = (B[1] + s->current_picture.f.motion_val[0][s->block_index[n_adj ^ 2] - 2 * wrap][1] + 1) >> 1;
- }
- }
- if (s->mb_width > 1) {
- if (!v->is_intra[s->mb_x - s->mb_stride + 1]) {
- c_valid = 1;
- n_adj = 2;
- pos_c = s->block_index[2] - 2 * wrap + 2;
- if (v->blk_mv_type[pos_c] && v->blk_mv_type[xy]) {
- n_adj = n & 2;
- }
- C[0] = s->current_picture.f.motion_val[0][s->block_index[n_adj] - 2 * wrap + 2][0];
- C[1] = s->current_picture.f.motion_val[0][s->block_index[n_adj] - 2 * wrap + 2][1];
- if (v->blk_mv_type[pos_c] && !v->blk_mv_type[xy]) {
- C[0] = (1 + C[0] + (s->current_picture.f.motion_val[0][s->block_index[n_adj ^ 2] - 2 * wrap + 2][0])) >> 1;
- C[1] = (1 + C[1] + (s->current_picture.f.motion_val[0][s->block_index[n_adj ^ 2] - 2 * wrap + 2][1])) >> 1;
- }
- if (s->mb_x == s->mb_width - 1) {
- if (!v->is_intra[s->mb_x - s->mb_stride - 1]) {
- c_valid = 1;
- n_adj = 3;
- pos_c = s->block_index[3] - 2 * wrap - 2;
- if (v->blk_mv_type[pos_c] && v->blk_mv_type[xy]) {
- n_adj = n | 1;
- }
- C[0] = s->current_picture.f.motion_val[0][s->block_index[n_adj] - 2 * wrap - 2][0];
- C[1] = s->current_picture.f.motion_val[0][s->block_index[n_adj] - 2 * wrap - 2][1];
- if (v->blk_mv_type[pos_c] && !v->blk_mv_type[xy]) {
- C[0] = (1 + C[0] + s->current_picture.f.motion_val[0][s->block_index[1] - 2 * wrap - 2][0]) >> 1;
- C[1] = (1 + C[1] + s->current_picture.f.motion_val[0][s->block_index[1] - 2 * wrap - 2][1]) >> 1;
- }
- } else
- c_valid = 0;
- }
- }
- }
- }
- } else {
- pos_b = s->block_index[1];
- b_valid = 1;
- B[0] = s->current_picture.f.motion_val[0][pos_b][0];
- B[1] = s->current_picture.f.motion_val[0][pos_b][1];
- pos_c = s->block_index[0];
- c_valid = 1;
- C[0] = s->current_picture.f.motion_val[0][pos_c][0];
- C[1] = s->current_picture.f.motion_val[0][pos_c][1];
- }
-
- total_valid = a_valid + b_valid + c_valid;
- // check if predictor A is out of bounds
- if (!s->mb_x && !(n == 1 || n == 3)) {
- A[0] = A[1] = 0;
- }
- // check if predictor B is out of bounds
- if ((s->first_slice_line && v->blk_mv_type[xy]) || (s->first_slice_line && !(n & 2))) {
- B[0] = B[1] = C[0] = C[1] = 0;
- }
- if (!v->blk_mv_type[xy]) {
- if (s->mb_width == 1) {
- px = B[0];
- py = B[1];
- } else {
- if (total_valid >= 2) {
- px = mid_pred(A[0], B[0], C[0]);
- py = mid_pred(A[1], B[1], C[1]);
- } else if (total_valid) {
- if (a_valid) { px = A[0]; py = A[1]; }
- else if (b_valid) { px = B[0]; py = B[1]; }
- else if (c_valid) { px = C[0]; py = C[1]; }
- else av_assert2(0);
- } else
- px = py = 0;
- }
- } else {
- if (a_valid)
- field_a = (A[1] & 4) ? 1 : 0;
- else
- field_a = 0;
- if (b_valid)
- field_b = (B[1] & 4) ? 1 : 0;
- else
- field_b = 0;
- if (c_valid)
- field_c = (C[1] & 4) ? 1 : 0;
- else
- field_c = 0;
-
- num_oppfield = field_a + field_b + field_c;
- num_samefield = total_valid - num_oppfield;
- if (total_valid == 3) {
- if ((num_samefield == 3) || (num_oppfield == 3)) {
- px = mid_pred(A[0], B[0], C[0]);
- py = mid_pred(A[1], B[1], C[1]);
- } else if (num_samefield >= num_oppfield) {
- /* take one MV from same field set depending on priority
- the check for B may not be necessary */
- px = !field_a ? A[0] : B[0];
- py = !field_a ? A[1] : B[1];
- } else {
- px = field_a ? A[0] : B[0];
- py = field_a ? A[1] : B[1];
- }
- } else if (total_valid == 2) {
- if (num_samefield >= num_oppfield) {
- if (!field_a && a_valid) {
- px = A[0];
- py = A[1];
- } else if (!field_b && b_valid) {
- px = B[0];
- py = B[1];
- } else if (c_valid) {
- px = C[0];
- py = C[1];
- } else px = py = 0;
- } else {
- if (field_a && a_valid) {
- px = A[0];
- py = A[1];
- } else if (field_b && b_valid) {
- px = B[0];
- py = B[1];
- } else if (c_valid) {
- px = C[0];
- py = C[1];
- } else px = py = 0;
- }
- } else if (total_valid == 1) {
- px = (a_valid) ? A[0] : ((b_valid) ? B[0] : C[0]);
- py = (a_valid) ? A[1] : ((b_valid) ? B[1] : C[1]);
- } else
- px = py = 0;
- }
-
- /* store MV using signed modulus of MV range defined in 4.11 */
- s->mv[0][n][0] = s->current_picture.f.motion_val[0][xy][0] = ((px + dmv_x + r_x) & ((r_x << 1) - 1)) - r_x;
- s->mv[0][n][1] = s->current_picture.f.motion_val[0][xy][1] = ((py + dmv_y + r_y) & ((r_y << 1) - 1)) - r_y;
- if (mvn == 1) { /* duplicate motion data for 1-MV block */
- s->current_picture.f.motion_val[0][xy + 1 ][0] = s->current_picture.f.motion_val[0][xy][0];
- s->current_picture.f.motion_val[0][xy + 1 ][1] = s->current_picture.f.motion_val[0][xy][1];
- s->current_picture.f.motion_val[0][xy + wrap ][0] = s->current_picture.f.motion_val[0][xy][0];
- s->current_picture.f.motion_val[0][xy + wrap ][1] = s->current_picture.f.motion_val[0][xy][1];
- s->current_picture.f.motion_val[0][xy + wrap + 1][0] = s->current_picture.f.motion_val[0][xy][0];
- s->current_picture.f.motion_val[0][xy + wrap + 1][1] = s->current_picture.f.motion_val[0][xy][1];
- } else if (mvn == 2) { /* duplicate motion data for 2-Field MV block */
- s->current_picture.f.motion_val[0][xy + 1][0] = s->current_picture.f.motion_val[0][xy][0];
- s->current_picture.f.motion_val[0][xy + 1][1] = s->current_picture.f.motion_val[0][xy][1];
- s->mv[0][n + 1][0] = s->mv[0][n][0];
- s->mv[0][n + 1][1] = s->mv[0][n][1];
- }
-}
-
-/** Motion compensation for direct or interpolated blocks in B-frames
- */
-static void vc1_interp_mc(VC1Context *v)
-{
- MpegEncContext *s = &v->s;
- DSPContext *dsp = &v->s.dsp;
- H264ChromaContext *h264chroma = &v->h264chroma;
- uint8_t *srcY, *srcU, *srcV;
- int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;
- int off, off_uv;
- int v_edge_pos = s->v_edge_pos >> v->field_mode;
-
- if (!v->field_mode && !v->s.next_picture.f.data[0])
- return;
-
- mx = s->mv[1][0][0];
- my = s->mv[1][0][1];
- 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])
- 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];
-
- src_x = s->mb_x * 16 + (mx >> 2);
- src_y = s->mb_y * 16 + (my >> 2);
- uvsrc_x = s->mb_x * 8 + (uvmx >> 2);
- uvsrc_y = s->mb_y * 8 + (uvmy >> 2);
-
- if (v->profile != PROFILE_ADVANCED) {
- src_x = av_clip( src_x, -16, s->mb_width * 16);
- src_y = av_clip( src_y, -16, s->mb_height * 16);
- uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width * 8);
- uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8);
- } else {
- src_x = av_clip( src_x, -17, s->avctx->coded_width);
- src_y = av_clip( src_y, -18, s->avctx->coded_height + 1);
- uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1);
- uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1);
- }
-
- srcY += src_y * s->linesize + src_x;
- srcU += uvsrc_y * s->uvlinesize + uvsrc_x;
- 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];
- }
-
- /* for grayscale we should not try to read from unknown area */
- if (s->flags & CODEC_FLAG_GRAY) {
- srcU = s->edge_emu_buffer + 18 * s->linesize;
- srcV = s->edge_emu_buffer + 18 * s->linesize;
- }
-
- if (v->rangeredfrm || s->h_edge_pos < 22 || v_edge_pos < 22
- || (unsigned)(src_x - 1) > s->h_edge_pos - (mx & 3) - 16 - 3
- || (unsigned)(src_y - 1) > v_edge_pos - (my & 3) - 16 - 3) {
- uint8_t *uvbuf = s->edge_emu_buffer + 19 * s->linesize;
-
- srcY -= s->mspel * (1 + s->linesize);
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize,
- 17 + s->mspel * 2, 17 + s->mspel * 2,
- src_x - s->mspel, src_y - s->mspel,
- s->h_edge_pos, v_edge_pos);
- srcY = s->edge_emu_buffer;
- s->vdsp.emulated_edge_mc(uvbuf , srcU, s->uvlinesize, 8 + 1, 8 + 1,
- uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, v_edge_pos >> 1);
- s->vdsp.emulated_edge_mc(uvbuf + 16, srcV, s->uvlinesize, 8 + 1, 8 + 1,
- uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, v_edge_pos >> 1);
- srcU = uvbuf;
- srcV = uvbuf + 16;
- /* if we deal with range reduction we need to scale source blocks */
- if (v->rangeredfrm) {
- int i, j;
- uint8_t *src, *src2;
-
- src = srcY;
- for (j = 0; j < 17 + s->mspel * 2; j++) {
- for (i = 0; i < 17 + s->mspel * 2; i++)
- src[i] = ((src[i] - 128) >> 1) + 128;
- src += s->linesize;
- }
- src = srcU;
- src2 = srcV;
- for (j = 0; j < 9; j++) {
- for (i = 0; i < 9; i++) {
- src[i] = ((src[i] - 128) >> 1) + 128;
- src2[i] = ((src2[i] - 128) >> 1) + 128;
- }
- src += s->uvlinesize;
- src2 += s->uvlinesize;
- }
- }
- srcY += s->mspel * (1 + s->linesize);
- }
-
- off = 0;
- off_uv = 0;
-
- 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);
- } else { // hpel mc
- dxy = (my & 2) | ((mx & 2) >> 1);
-
- if (!v->rnd)
- dsp->avg_pixels_tab[0][dxy](s->dest[0] + off, srcY, s->linesize, 16);
- else
- dsp->avg_no_rnd_pixels_tab[dxy](s->dest[0] + off, srcY, s->linesize, 16);
- }
-
- if (s->flags & CODEC_FLAG_GRAY) return;
- /* Chroma MC always uses qpel blilinear */
- uvmx = (uvmx & 3) << 1;
- uvmy = (uvmy & 3) << 1;
- if (!v->rnd) {
- h264chroma->avg_h264_chroma_pixels_tab[0](s->dest[1] + off_uv, srcU, s->uvlinesize, 8, uvmx, uvmy);
- h264chroma->avg_h264_chroma_pixels_tab[0](s->dest[2] + off_uv, srcV, s->uvlinesize, 8, uvmx, uvmy);
- } else {
- v->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1] + off_uv, srcU, s->uvlinesize, 8, uvmx, uvmy);
- v->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2] + off_uv, srcV, s->uvlinesize, 8, uvmx, uvmy);
- }
-}
-
-static av_always_inline int scale_mv(int value, int bfrac, int inv, int qs)
-{
- int n = bfrac;
-
-#if B_FRACTION_DEN==256
- if (inv)
- n -= 256;
- if (!qs)
- return 2 * ((value * n + 255) >> 9);
- return (value * n + 128) >> 8;
-#else
- if (inv)
- n -= B_FRACTION_DEN;
- if (!qs)
- return 2 * ((value * n + B_FRACTION_DEN - 1) / (2 * B_FRACTION_DEN));
- return (value * n + B_FRACTION_DEN/2) / B_FRACTION_DEN;
-#endif
-}
-
-/** Reconstruct motion vector for B-frame and do motion compensation
- */
-static inline void vc1_b_mc(VC1Context *v, int dmv_x[2], int dmv_y[2],
- int direct, int mode)
-{
- if (v->use_ic) {
- v->mv_mode2 = v->mv_mode;
- v->mv_mode = MV_PMODE_INTENSITY_COMP;
- }
- if (direct) {
- vc1_mc_1mv(v, 0);
- vc1_interp_mc(v);
- if (v->use_ic)
- v->mv_mode = v->mv_mode2;
- return;
- }
- if (mode == BMV_TYPE_INTERPOLATED) {
- vc1_mc_1mv(v, 0);
- vc1_interp_mc(v);
- if (v->use_ic)
- v->mv_mode = v->mv_mode2;
- return;
- }
-
- if (v->use_ic && (mode == BMV_TYPE_BACKWARD))
- v->mv_mode = v->mv_mode2;
- vc1_mc_1mv(v, (mode == BMV_TYPE_BACKWARD));
- if (v->use_ic)
- v->mv_mode = v->mv_mode2;
-}
-
-static inline void vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2],
- int direct, int mvtype)
-{
- MpegEncContext *s = &v->s;
- int xy, wrap, off = 0;
- int16_t *A, *B, *C;
- int px, py;
- int sum;
- int r_x, r_y;
- const uint8_t *is_intra = v->mb_type[0];
-
- r_x = v->range_x;
- r_y = v->range_y;
- /* scale MV difference to be quad-pel */
- dmv_x[0] <<= 1 - s->quarter_sample;
- dmv_y[0] <<= 1 - s->quarter_sample;
- dmv_x[1] <<= 1 - s->quarter_sample;
- dmv_y[1] <<= 1 - s->quarter_sample;
-
- wrap = s->b8_stride;
- xy = s->block_index[0];
-
- if (s->mb_intra) {
- s->current_picture.f.motion_val[0][xy + v->blocks_off][0] =
- s->current_picture.f.motion_val[0][xy + v->blocks_off][1] =
- s->current_picture.f.motion_val[1][xy + v->blocks_off][0] =
- s->current_picture.f.motion_val[1][xy + v->blocks_off][1] = 0;
- return;
- }
- if (!v->field_mode) {
- s->mv[0][0][0] = scale_mv(s->next_picture.f.motion_val[1][xy][0], v->bfraction, 0, s->quarter_sample);
- s->mv[0][0][1] = scale_mv(s->next_picture.f.motion_val[1][xy][1], v->bfraction, 0, s->quarter_sample);
- s->mv[1][0][0] = scale_mv(s->next_picture.f.motion_val[1][xy][0], v->bfraction, 1, s->quarter_sample);
- s->mv[1][0][1] = scale_mv(s->next_picture.f.motion_val[1][xy][1], v->bfraction, 1, s->quarter_sample);
-
- /* Pullback predicted motion vectors as specified in 8.4.5.4 */
- s->mv[0][0][0] = av_clip(s->mv[0][0][0], -60 - (s->mb_x << 6), (s->mb_width << 6) - 4 - (s->mb_x << 6));
- 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.f.motion_val[0][xy + v->blocks_off][0] = s->mv[0][0][0];
- s->current_picture.f.motion_val[0][xy + v->blocks_off][1] = s->mv[0][0][1];
- s->current_picture.f.motion_val[1][xy + v->blocks_off][0] = s->mv[1][0][0];
- s->current_picture.f.motion_val[1][xy + v->blocks_off][1] = s->mv[1][0][1];
- return;
- }
-
- if ((mvtype == BMV_TYPE_FORWARD) || (mvtype == BMV_TYPE_INTERPOLATED)) {
- C = s->current_picture.f.motion_val[0][xy - 2];
- A = s->current_picture.f.motion_val[0][xy - wrap * 2];
- off = (s->mb_x == (s->mb_width - 1)) ? -2 : 2;
- B = s->current_picture.f.motion_val[0][xy - wrap * 2 + off];
-
- if (!s->mb_x) C[0] = C[1] = 0;
- if (!s->first_slice_line) { // predictor A is not out of bounds
- if (s->mb_width == 1) {
- px = A[0];
- py = A[1];
- } else {
- px = mid_pred(A[0], B[0], C[0]);
- py = mid_pred(A[1], B[1], C[1]);
- }
- } else if (s->mb_x) { // predictor C is not out of bounds
- px = C[0];
- py = C[1];
- } else {
- px = py = 0;
- }
- /* Pullback MV as specified in 8.3.5.3.4 */
- {
- int qx, qy, X, Y;
- if (v->profile < PROFILE_ADVANCED) {
- qx = (s->mb_x << 5);
- qy = (s->mb_y << 5);
- X = (s->mb_width << 5) - 4;
- Y = (s->mb_height << 5) - 4;
- if (qx + px < -28) px = -28 - qx;
- if (qy + py < -28) py = -28 - qy;
- if (qx + px > X) px = X - qx;
- if (qy + py > Y) py = Y - qy;
- } else {
- qx = (s->mb_x << 6);
- qy = (s->mb_y << 6);
- X = (s->mb_width << 6) - 4;
- Y = (s->mb_height << 6) - 4;
- if (qx + px < -60) px = -60 - qx;
- if (qy + py < -60) py = -60 - qy;
- if (qx + px > X) px = X - qx;
- if (qy + py > Y) py = Y - qy;
- }
- }
- /* Calculate hybrid prediction as specified in 8.3.5.3.5 */
- if (0 && !s->first_slice_line && s->mb_x) {
- if (is_intra[xy - wrap])
- sum = FFABS(px) + FFABS(py);
- else
- sum = FFABS(px - A[0]) + FFABS(py - A[1]);
- if (sum > 32) {
- if (get_bits1(&s->gb)) {
- px = A[0];
- py = A[1];
- } else {
- px = C[0];
- py = C[1];
- }
- } else {
- if (is_intra[xy - 2])
- sum = FFABS(px) + FFABS(py);
- else
- sum = FFABS(px - C[0]) + FFABS(py - C[1]);
- if (sum > 32) {
- if (get_bits1(&s->gb)) {
- px = A[0];
- py = A[1];
- } else {
- px = C[0];
- py = C[1];
- }
- }
- }
- }
- /* store MV using signed modulus of MV range defined in 4.11 */
- s->mv[0][0][0] = ((px + dmv_x[0] + r_x) & ((r_x << 1) - 1)) - r_x;
- s->mv[0][0][1] = ((py + dmv_y[0] + r_y) & ((r_y << 1) - 1)) - r_y;
- }
- if ((mvtype == BMV_TYPE_BACKWARD) || (mvtype == BMV_TYPE_INTERPOLATED)) {
- C = s->current_picture.f.motion_val[1][xy - 2];
- A = s->current_picture.f.motion_val[1][xy - wrap * 2];
- off = (s->mb_x == (s->mb_width - 1)) ? -2 : 2;
- B = s->current_picture.f.motion_val[1][xy - wrap * 2 + off];
-
- if (!s->mb_x)
- C[0] = C[1] = 0;
- if (!s->first_slice_line) { // predictor A is not out of bounds
- if (s->mb_width == 1) {
- px = A[0];
- py = A[1];
- } else {
- px = mid_pred(A[0], B[0], C[0]);
- py = mid_pred(A[1], B[1], C[1]);
- }
- } else if (s->mb_x) { // predictor C is not out of bounds
- px = C[0];
- py = C[1];
- } else {
- px = py = 0;
- }
- /* Pullback MV as specified in 8.3.5.3.4 */
- {
- int qx, qy, X, Y;
- if (v->profile < PROFILE_ADVANCED) {
- qx = (s->mb_x << 5);
- qy = (s->mb_y << 5);
- X = (s->mb_width << 5) - 4;
- Y = (s->mb_height << 5) - 4;
- if (qx + px < -28) px = -28 - qx;
- if (qy + py < -28) py = -28 - qy;
- if (qx + px > X) px = X - qx;
- if (qy + py > Y) py = Y - qy;
- } else {
- qx = (s->mb_x << 6);
- qy = (s->mb_y << 6);
- X = (s->mb_width << 6) - 4;
- Y = (s->mb_height << 6) - 4;
- if (qx + px < -60) px = -60 - qx;
- if (qy + py < -60) py = -60 - qy;
- if (qx + px > X) px = X - qx;
- if (qy + py > Y) py = Y - qy;
- }
- }
- /* Calculate hybrid prediction as specified in 8.3.5.3.5 */
- if (0 && !s->first_slice_line && s->mb_x) {
- if (is_intra[xy - wrap])
- sum = FFABS(px) + FFABS(py);
- else
- sum = FFABS(px - A[0]) + FFABS(py - A[1]);
- if (sum > 32) {
- if (get_bits1(&s->gb)) {
- px = A[0];
- py = A[1];
- } else {
- px = C[0];
- py = C[1];
- }
- } else {
- if (is_intra[xy - 2])
- sum = FFABS(px) + FFABS(py);
- else
- sum = FFABS(px - C[0]) + FFABS(py - C[1]);
- if (sum > 32) {
- if (get_bits1(&s->gb)) {
- px = A[0];
- py = A[1];
- } else {
- px = C[0];
- py = C[1];
- }
- }
- }
- }
- /* store MV using signed modulus of MV range defined in 4.11 */
-
- s->mv[1][0][0] = ((px + dmv_x[1] + r_x) & ((r_x << 1) - 1)) - r_x;
- s->mv[1][0][1] = ((py + dmv_y[1] + r_y) & ((r_y << 1) - 1)) - r_y;
- }
- s->current_picture.f.motion_val[0][xy][0] = s->mv[0][0][0];
- s->current_picture.f.motion_val[0][xy][1] = s->mv[0][0][1];
- s->current_picture.f.motion_val[1][xy][0] = s->mv[1][0][0];
- s->current_picture.f.motion_val[1][xy][1] = s->mv[1][0][1];
-}
-
-static inline void vc1_pred_b_mv_intfi(VC1Context *v, int n, int *dmv_x, int *dmv_y, int mv1, int *pred_flag)
-{
- int dir = (v->bmvtype == BMV_TYPE_BACKWARD) ? 1 : 0;
- MpegEncContext *s = &v->s;
- int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
-
- if (v->bmvtype == BMV_TYPE_DIRECT) {
- int total_opp, k, f;
- if (s->next_picture.f.mb_type[mb_pos + v->mb_off] != MB_TYPE_INTRA) {
- s->mv[0][0][0] = scale_mv(s->next_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][0],
- v->bfraction, 0, s->quarter_sample);
- s->mv[0][0][1] = scale_mv(s->next_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][1],
- v->bfraction, 0, s->quarter_sample);
- s->mv[1][0][0] = scale_mv(s->next_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][0],
- v->bfraction, 1, s->quarter_sample);
- s->mv[1][0][1] = scale_mv(s->next_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][1],
- v->bfraction, 1, s->quarter_sample);
-
- total_opp = v->mv_f_next[0][s->block_index[0] + v->blocks_off]
- + v->mv_f_next[0][s->block_index[1] + v->blocks_off]
- + v->mv_f_next[0][s->block_index[2] + v->blocks_off]
- + v->mv_f_next[0][s->block_index[3] + v->blocks_off];
- f = (total_opp > 2) ? 1 : 0;
- } else {
- s->mv[0][0][0] = s->mv[0][0][1] = 0;
- s->mv[1][0][0] = s->mv[1][0][1] = 0;
- f = 0;
- }
- v->ref_field_type[0] = v->ref_field_type[1] = v->cur_field_type ^ f;
- for (k = 0; k < 4; k++) {
- s->current_picture.f.motion_val[0][s->block_index[k] + v->blocks_off][0] = s->mv[0][0][0];
- s->current_picture.f.motion_val[0][s->block_index[k] + v->blocks_off][1] = s->mv[0][0][1];
- s->current_picture.f.motion_val[1][s->block_index[k] + v->blocks_off][0] = s->mv[1][0][0];
- s->current_picture.f.motion_val[1][s->block_index[k] + v->blocks_off][1] = s->mv[1][0][1];
- v->mv_f[0][s->block_index[k] + v->blocks_off] = f;
- v->mv_f[1][s->block_index[k] + v->blocks_off] = f;
- }
- return;
- }
- if (v->bmvtype == BMV_TYPE_INTERPOLATED) {
- vc1_pred_mv(v, 0, dmv_x[0], dmv_y[0], 1, v->range_x, v->range_y, v->mb_type[0], pred_flag[0], 0);
- vc1_pred_mv(v, 0, dmv_x[1], dmv_y[1], 1, v->range_x, v->range_y, v->mb_type[0], pred_flag[1], 1);
- return;
- }
- if (dir) { // backward
- vc1_pred_mv(v, n, dmv_x[1], dmv_y[1], mv1, v->range_x, v->range_y, v->mb_type[0], pred_flag[1], 1);
- if (n == 3 || mv1) {
- vc1_pred_mv(v, 0, dmv_x[0], dmv_y[0], 1, v->range_x, v->range_y, v->mb_type[0], 0, 0);
- }
- } else { // forward
- vc1_pred_mv(v, n, dmv_x[0], dmv_y[0], mv1, v->range_x, v->range_y, v->mb_type[0], pred_flag[0], 0);
- if (n == 3 || mv1) {
- vc1_pred_mv(v, 0, dmv_x[1], dmv_y[1], 1, v->range_x, v->range_y, v->mb_type[0], 0, 1);
- }
- }
-}
-
-/** Get predicted DC value for I-frames only
- * prediction dir: left=0, top=1
- * @param s MpegEncContext
- * @param overlap flag indicating that overlap filtering is used
- * @param pq integer part of picture quantizer
- * @param[in] n block index in the current MB
- * @param dc_val_ptr Pointer to DC predictor
- * @param dir_ptr Prediction direction for use in AC prediction
- */
-static inline int vc1_i_pred_dc(MpegEncContext *s, int overlap, int pq, int n,
- int16_t **dc_val_ptr, int *dir_ptr)
-{
- int a, b, c, wrap, pred, scale;
- int16_t *dc_val;
- static const uint16_t dcpred[32] = {
- -1, 1024, 512, 341, 256, 205, 171, 146, 128,
- 114, 102, 93, 85, 79, 73, 68, 64,
- 60, 57, 54, 51, 49, 47, 45, 43,
- 41, 39, 38, 37, 35, 34, 33
- };
-
- /* find prediction - wmv3_dc_scale always used here in fact */
- if (n < 4) scale = s->y_dc_scale;
- else scale = s->c_dc_scale;
-
- wrap = s->block_wrap[n];
- dc_val = s->dc_val[0] + s->block_index[n];
-
- /* B A
- * C X
- */
- c = dc_val[ - 1];
- b = dc_val[ - 1 - wrap];
- a = dc_val[ - wrap];
-
- if (pq < 9 || !overlap) {
- /* Set outer values */
- if (s->first_slice_line && (n != 2 && n != 3))
- b = a = dcpred[scale];
- if (s->mb_x == 0 && (n != 1 && n != 3))
- b = c = dcpred[scale];
- } else {
- /* Set outer values */
- if (s->first_slice_line && (n != 2 && n != 3))
- b = a = 0;
- if (s->mb_x == 0 && (n != 1 && n != 3))
- b = c = 0;
- }
-
- if (abs(a - b) <= abs(b - c)) {
- pred = c;
- *dir_ptr = 1; // left
- } else {
- pred = a;
- *dir_ptr = 0; // top
- }
-
- /* update predictor */
- *dc_val_ptr = &dc_val[0];
- return pred;
-}
-
-
-/** Get predicted DC value
- * prediction dir: left=0, top=1
- * @param s MpegEncContext
- * @param overlap flag indicating that overlap filtering is used
- * @param pq integer part of picture quantizer
- * @param[in] n block index in the current MB
- * @param a_avail flag indicating top block availability
- * @param c_avail flag indicating left block availability
- * @param dc_val_ptr Pointer to DC predictor
- * @param dir_ptr Prediction direction for use in AC prediction
- */
-static inline int vc1_pred_dc(MpegEncContext *s, int overlap, int pq, int n,
- int a_avail, int c_avail,
- int16_t **dc_val_ptr, int *dir_ptr)
-{
- int a, b, c, wrap, pred;
- int16_t *dc_val;
- int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
- int q1, q2 = 0;
- int dqscale_index;
-
- wrap = s->block_wrap[n];
- dc_val = s->dc_val[0] + s->block_index[n];
-
- /* B A
- * C X
- */
- c = dc_val[ - 1];
- b = dc_val[ - 1 - wrap];
- a = dc_val[ - wrap];
- /* scale predictors if needed */
- q1 = s->current_picture.f.qscale_table[mb_pos];
- dqscale_index = s->y_dc_scale_table[q1] - 1;
- if (dqscale_index < 0)
- return 0;
- if (c_avail && (n != 1 && n != 3)) {
- q2 = s->current_picture.f.qscale_table[mb_pos - 1];
- if (q2 && q2 != q1)
- c = (c * s->y_dc_scale_table[q2] * ff_vc1_dqscale[dqscale_index] + 0x20000) >> 18;
- }
- if (a_avail && (n != 2 && n != 3)) {
- q2 = s->current_picture.f.qscale_table[mb_pos - s->mb_stride];
- if (q2 && q2 != q1)
- a = (a * s->y_dc_scale_table[q2] * ff_vc1_dqscale[dqscale_index] + 0x20000) >> 18;
- }
- if (a_avail && c_avail && (n != 3)) {
- int off = mb_pos;
- if (n != 1)
- off--;
- if (n != 2)
- off -= s->mb_stride;
- q2 = s->current_picture.f.qscale_table[off];
- if (q2 && q2 != q1)
- b = (b * s->y_dc_scale_table[q2] * ff_vc1_dqscale[dqscale_index] + 0x20000) >> 18;
- }
-
- if (a_avail && c_avail) {
- if (abs(a - b) <= abs(b - c)) {
- pred = c;
- *dir_ptr = 1; // left
- } else {
- pred = a;
- *dir_ptr = 0; // top
- }
- } else if (a_avail) {
- pred = a;
- *dir_ptr = 0; // top
- } else if (c_avail) {
- pred = c;
- *dir_ptr = 1; // left
- } else {
- pred = 0;
- *dir_ptr = 1; // left
- }
-
- /* update predictor */
- *dc_val_ptr = &dc_val[0];
- return pred;
-}
-
-/** @} */ // Block group
-
-/**
- * @name VC1 Macroblock-level functions in Simple/Main Profiles
- * @see 7.1.4, p91 and 8.1.1.7, p(1)04
- * @{
- */
-
-static inline int vc1_coded_block_pred(MpegEncContext * s, int n,
- uint8_t **coded_block_ptr)
-{
- int xy, wrap, pred, a, b, c;
-
- xy = s->block_index[n];
- wrap = s->b8_stride;
-
- /* B C
- * A X
- */
- a = s->coded_block[xy - 1 ];
- b = s->coded_block[xy - 1 - wrap];
- c = s->coded_block[xy - wrap];
-
- if (b == c) {
- pred = a;
- } else {
- pred = c;
- }
-
- /* store value */
- *coded_block_ptr = &s->coded_block[xy];
-
- return pred;
-}
-
-/**
- * Decode one AC coefficient
- * @param v The VC1 context
- * @param last Last coefficient
- * @param skip How much zero coefficients to skip
- * @param value Decoded AC coefficient value
- * @param codingset set of VLC to decode data
- * @see 8.1.3.4
- */
-static void vc1_decode_ac_coeff(VC1Context *v, int *last, int *skip,
- int *value, int codingset)
-{
- GetBitContext *gb = &v->s.gb;
- int index, escape, run = 0, level = 0, lst = 0;
-
- index = get_vlc2(gb, ff_vc1_ac_coeff_table[codingset].table, AC_VLC_BITS, 3);
- if (index != ff_vc1_ac_sizes[codingset] - 1) {
- run = vc1_index_decode_table[codingset][index][0];
- level = vc1_index_decode_table[codingset][index][1];
- lst = index >= vc1_last_decode_table[codingset] || get_bits_left(gb) < 0;
- if (get_bits1(gb))
- level = -level;
- } else {
- escape = decode210(gb);
- if (escape != 2) {
- index = get_vlc2(gb, ff_vc1_ac_coeff_table[codingset].table, AC_VLC_BITS, 3);
- run = vc1_index_decode_table[codingset][index][0];
- level = vc1_index_decode_table[codingset][index][1];
- lst = index >= vc1_last_decode_table[codingset];
- if (escape == 0) {
- if (lst)
- level += vc1_last_delta_level_table[codingset][run];
- else
- level += vc1_delta_level_table[codingset][run];
- } else {
- if (lst)
- run += vc1_last_delta_run_table[codingset][level] + 1;
- else
- run += vc1_delta_run_table[codingset][level] + 1;
- }
- if (get_bits1(gb))
- level = -level;
- } else {
- int sign;
- lst = get_bits1(gb);
- if (v->s.esc3_level_length == 0) {
- if (v->pq < 8 || v->dquantfrm) { // table 59
- v->s.esc3_level_length = get_bits(gb, 3);
- if (!v->s.esc3_level_length)
- v->s.esc3_level_length = get_bits(gb, 2) + 8;
- } else { // table 60
- v->s.esc3_level_length = get_unary(gb, 1, 6) + 2;
- }
- v->s.esc3_run_length = 3 + get_bits(gb, 2);
- }
- run = get_bits(gb, v->s.esc3_run_length);
- sign = get_bits1(gb);
- level = get_bits(gb, v->s.esc3_level_length);
- if (sign)
- level = -level;
- }
- }
-
- *last = lst;
- *skip = run;
- *value = level;
-}
-
-/** Decode intra block in intra frames - should be faster than decode_intra_block
- * @param v VC1Context
- * @param block block to decode
- * @param[in] n subblock index
- * @param coded are AC coeffs present or not
- * @param codingset set of VLC to decode data
- */
-static int vc1_decode_i_block(VC1Context *v, int16_t block[64], int n,
- int coded, int codingset)
-{
- GetBitContext *gb = &v->s.gb;
- MpegEncContext *s = &v->s;
- int dc_pred_dir = 0; /* Direction of the DC prediction used */
- int i;
- int16_t *dc_val;
- int16_t *ac_val, *ac_val2;
- int dcdiff;
-
- /* Get DC differential */
- if (n < 4) {
- dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
- } else {
- dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
- }
- if (dcdiff < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n");
- return -1;
- }
- if (dcdiff) {
- if (dcdiff == 119 /* ESC index value */) {
- /* TODO: Optimize */
- if (v->pq == 1) dcdiff = get_bits(gb, 10);
- else if (v->pq == 2) dcdiff = get_bits(gb, 9);
- else dcdiff = get_bits(gb, 8);
- } else {
- if (v->pq == 1)
- dcdiff = (dcdiff << 2) + get_bits(gb, 2) - 3;
- else if (v->pq == 2)
- dcdiff = (dcdiff << 1) + get_bits1(gb) - 1;
- }
- if (get_bits1(gb))
- dcdiff = -dcdiff;
- }
-
- /* Prediction */
- dcdiff += vc1_i_pred_dc(&v->s, v->overlap, v->pq, n, &dc_val, &dc_pred_dir);
- *dc_val = dcdiff;
-
- /* Store the quantized DC coeff, used for prediction */
- if (n < 4) {
- block[0] = dcdiff * s->y_dc_scale;
- } else {
- block[0] = dcdiff * s->c_dc_scale;
- }
- /* Skip ? */
- if (!coded) {
- goto not_coded;
- }
-
- // AC Decoding
- i = 1;
-
- {
- int last = 0, skip, value;
- const uint8_t *zz_table;
- int scale;
- int k;
-
- scale = v->pq * 2 + v->halfpq;
-
- if (v->s.ac_pred) {
- if (!dc_pred_dir)
- zz_table = v->zz_8x8[2];
- else
- zz_table = v->zz_8x8[3];
- } else
- zz_table = v->zz_8x8[1];
-
- ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
- ac_val2 = ac_val;
- if (dc_pred_dir) // left
- ac_val -= 16;
- else // top
- ac_val -= 16 * s->block_wrap[n];
-
- while (!last) {
- vc1_decode_ac_coeff(v, &last, &skip, &value, codingset);
- i += skip;
- if (i > 63)
- break;
- block[zz_table[i++]] = value;
- }
-
- /* apply AC prediction if needed */
- if (s->ac_pred) {
- if (dc_pred_dir) { // left
- for (k = 1; k < 8; k++)
- block[k << v->left_blk_sh] += ac_val[k];
- } else { // top
- for (k = 1; k < 8; k++)
- block[k << v->top_blk_sh] += ac_val[k + 8];
- }
- }
- /* save AC coeffs for further prediction */
- for (k = 1; k < 8; k++) {
- ac_val2[k] = block[k << v->left_blk_sh];
- ac_val2[k + 8] = block[k << v->top_blk_sh];
- }
-
- /* scale AC coeffs */
- for (k = 1; k < 64; k++)
- if (block[k]) {
- block[k] *= scale;
- if (!v->pquantizer)
- block[k] += (block[k] < 0) ? -v->pq : v->pq;
- }
-
- if (s->ac_pred) i = 63;
- }
-
-not_coded:
- if (!coded) {
- int k, scale;
- ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
- ac_val2 = ac_val;
-
- i = 0;
- scale = v->pq * 2 + v->halfpq;
- memset(ac_val2, 0, 16 * 2);
- if (dc_pred_dir) { // left
- ac_val -= 16;
- if (s->ac_pred)
- memcpy(ac_val2, ac_val, 8 * 2);
- } else { // top
- ac_val -= 16 * s->block_wrap[n];
- if (s->ac_pred)
- memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
- }
-
- /* apply AC prediction if needed */
- if (s->ac_pred) {
- if (dc_pred_dir) { //left
- for (k = 1; k < 8; k++) {
- block[k << v->left_blk_sh] = ac_val[k] * scale;
- if (!v->pquantizer && block[k << v->left_blk_sh])
- block[k << v->left_blk_sh] += (block[k << v->left_blk_sh] < 0) ? -v->pq : v->pq;
- }
- } else { // top
- for (k = 1; k < 8; k++) {
- block[k << v->top_blk_sh] = ac_val[k + 8] * scale;
- if (!v->pquantizer && block[k << v->top_blk_sh])
- block[k << v->top_blk_sh] += (block[k << v->top_blk_sh] < 0) ? -v->pq : v->pq;
- }
- }
- i = 63;
- }
- }
- s->block_last_index[n] = i;
-
- return 0;
-}
-
-/** Decode intra block in intra frames - should be faster than decode_intra_block
- * @param v VC1Context
- * @param block block to decode
- * @param[in] n subblock number
- * @param coded are AC coeffs present or not
- * @param codingset set of VLC to decode data
- * @param mquant quantizer value for this macroblock
- */
-static int vc1_decode_i_block_adv(VC1Context *v, int16_t block[64], int n,
- int coded, int codingset, int mquant)
-{
- GetBitContext *gb = &v->s.gb;
- MpegEncContext *s = &v->s;
- int dc_pred_dir = 0; /* Direction of the DC prediction used */
- int i;
- int16_t *dc_val = NULL;
- int16_t *ac_val, *ac_val2;
- int dcdiff;
- int a_avail = v->a_avail, c_avail = v->c_avail;
- int use_pred = s->ac_pred;
- int scale;
- int q1, q2 = 0;
- int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
-
- /* Get DC differential */
- if (n < 4) {
- dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
- } else {
- dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
- }
- if (dcdiff < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n");
- return -1;
- }
- if (dcdiff) {
- if (dcdiff == 119 /* ESC index value */) {
- /* TODO: Optimize */
- if (mquant == 1) dcdiff = get_bits(gb, 10);
- else if (mquant == 2) dcdiff = get_bits(gb, 9);
- else dcdiff = get_bits(gb, 8);
- } else {
- if (mquant == 1)
- dcdiff = (dcdiff << 2) + get_bits(gb, 2) - 3;
- else if (mquant == 2)
- dcdiff = (dcdiff << 1) + get_bits1(gb) - 1;
- }
- if (get_bits1(gb))
- dcdiff = -dcdiff;
- }
-
- /* Prediction */
- dcdiff += vc1_pred_dc(&v->s, v->overlap, mquant, n, v->a_avail, v->c_avail, &dc_val, &dc_pred_dir);
- *dc_val = dcdiff;
-
- /* Store the quantized DC coeff, used for prediction */
- if (n < 4) {
- block[0] = dcdiff * s->y_dc_scale;
- } else {
- block[0] = dcdiff * s->c_dc_scale;
- }
-
- //AC Decoding
- i = 1;
-
- /* check if AC is needed at all */
- if (!a_avail && !c_avail)
- use_pred = 0;
- ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
- ac_val2 = ac_val;
-
- scale = mquant * 2 + ((mquant == v->pq) ? v->halfpq : 0);
-
- if (dc_pred_dir) // left
- ac_val -= 16;
- else // top
- ac_val -= 16 * s->block_wrap[n];
-
- q1 = s->current_picture.f.qscale_table[mb_pos];
- if ( dc_pred_dir && c_avail && mb_pos)
- q2 = s->current_picture.f.qscale_table[mb_pos - 1];
- if (!dc_pred_dir && a_avail && mb_pos >= s->mb_stride)
- q2 = s->current_picture.f.qscale_table[mb_pos - s->mb_stride];
- if ( dc_pred_dir && n == 1)
- q2 = q1;
- if (!dc_pred_dir && n == 2)
- q2 = q1;
- if (n == 3)
- q2 = q1;
-
- if (coded) {
- int last = 0, skip, value;
- const uint8_t *zz_table;
- int k;
-
- if (v->s.ac_pred) {
- if (!use_pred && v->fcm == ILACE_FRAME) {
- zz_table = v->zzi_8x8;
- } else {
- if (!dc_pred_dir) // top
- zz_table = v->zz_8x8[2];
- else // left
- zz_table = v->zz_8x8[3];
- }
- } else {
- if (v->fcm != ILACE_FRAME)
- zz_table = v->zz_8x8[1];
- else
- zz_table = v->zzi_8x8;
- }
-
- while (!last) {
- vc1_decode_ac_coeff(v, &last, &skip, &value, codingset);
- i += skip;
- if (i > 63)
- break;
- block[zz_table[i++]] = value;
- }
-
- /* apply AC prediction if needed */
- if (use_pred) {
- /* scale predictors if needed*/
- if (q2 && q1 != q2) {
- q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
- q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
-
- if (q1 < 1)
- return AVERROR_INVALIDDATA;
- if (dc_pred_dir) { // left
- for (k = 1; k < 8; k++)
- block[k << v->left_blk_sh] += (ac_val[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
- } else { // top
- for (k = 1; k < 8; k++)
- block[k << v->top_blk_sh] += (ac_val[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
- }
- } else {
- if (dc_pred_dir) { //left
- for (k = 1; k < 8; k++)
- block[k << v->left_blk_sh] += ac_val[k];
- } else { //top
- for (k = 1; k < 8; k++)
- block[k << v->top_blk_sh] += ac_val[k + 8];
- }
- }
- }
- /* save AC coeffs for further prediction */
- for (k = 1; k < 8; k++) {
- ac_val2[k ] = block[k << v->left_blk_sh];
- ac_val2[k + 8] = block[k << v->top_blk_sh];
- }
-
- /* scale AC coeffs */
- for (k = 1; k < 64; k++)
- if (block[k]) {
- block[k] *= scale;
- if (!v->pquantizer)
- block[k] += (block[k] < 0) ? -mquant : mquant;
- }
-
- if (use_pred) i = 63;
- } else { // no AC coeffs
- int k;
-
- memset(ac_val2, 0, 16 * 2);
- if (dc_pred_dir) { // left
- if (use_pred) {
- memcpy(ac_val2, ac_val, 8 * 2);
- if (q2 && q1 != q2) {
- q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
- q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
- if (q1 < 1)
- return AVERROR_INVALIDDATA;
- for (k = 1; k < 8; k++)
- ac_val2[k] = (ac_val2[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
- }
- }
- } else { // top
- if (use_pred) {
- memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
- if (q2 && q1 != q2) {
- q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
- q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
- if (q1 < 1)
- return AVERROR_INVALIDDATA;
- for (k = 1; k < 8; k++)
- ac_val2[k + 8] = (ac_val2[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
- }
- }
- }
-
- /* apply AC prediction if needed */
- if (use_pred) {
- if (dc_pred_dir) { // left
- for (k = 1; k < 8; k++) {
- block[k << v->left_blk_sh] = ac_val2[k] * scale;
- if (!v->pquantizer && block[k << v->left_blk_sh])
- block[k << v->left_blk_sh] += (block[k << v->left_blk_sh] < 0) ? -mquant : mquant;
- }
- } else { // top
- for (k = 1; k < 8; k++) {
- block[k << v->top_blk_sh] = ac_val2[k + 8] * scale;
- if (!v->pquantizer && block[k << v->top_blk_sh])
- block[k << v->top_blk_sh] += (block[k << v->top_blk_sh] < 0) ? -mquant : mquant;
- }
- }
- i = 63;
- }
- }
- s->block_last_index[n] = i;
-
- return 0;
-}
-
-/** Decode intra block in inter frames - more generic version than vc1_decode_i_block
- * @param v VC1Context
- * @param block block to decode
- * @param[in] n subblock index
- * @param coded are AC coeffs present or not
- * @param mquant block quantizer
- * @param codingset set of VLC to decode data
- */
-static int vc1_decode_intra_block(VC1Context *v, int16_t block[64], int n,
- int coded, int mquant, int codingset)
-{
- GetBitContext *gb = &v->s.gb;
- MpegEncContext *s = &v->s;
- int dc_pred_dir = 0; /* Direction of the DC prediction used */
- int i;
- int16_t *dc_val = NULL;
- int16_t *ac_val, *ac_val2;
- int dcdiff;
- int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
- int a_avail = v->a_avail, c_avail = v->c_avail;
- int use_pred = s->ac_pred;
- int scale;
- int q1, q2 = 0;
-
- s->dsp.clear_block(block);
-
- /* XXX: Guard against dumb values of mquant */
- mquant = (mquant < 1) ? 0 : ((mquant > 31) ? 31 : mquant);
-
- /* Set DC scale - y and c use the same */
- s->y_dc_scale = s->y_dc_scale_table[mquant];
- s->c_dc_scale = s->c_dc_scale_table[mquant];
-
- /* Get DC differential */
- if (n < 4) {
- dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
- } else {
- dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3);
- }
- if (dcdiff < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n");
- return -1;
- }
- if (dcdiff) {
- if (dcdiff == 119 /* ESC index value */) {
- /* TODO: Optimize */
- if (mquant == 1) dcdiff = get_bits(gb, 10);
- else if (mquant == 2) dcdiff = get_bits(gb, 9);
- else dcdiff = get_bits(gb, 8);
- } else {
- if (mquant == 1)
- dcdiff = (dcdiff << 2) + get_bits(gb, 2) - 3;
- else if (mquant == 2)
- dcdiff = (dcdiff << 1) + get_bits1(gb) - 1;
- }
- if (get_bits1(gb))
- dcdiff = -dcdiff;
- }
-
- /* Prediction */
- dcdiff += vc1_pred_dc(&v->s, v->overlap, mquant, n, a_avail, c_avail, &dc_val, &dc_pred_dir);
- *dc_val = dcdiff;
-
- /* Store the quantized DC coeff, used for prediction */
-
- if (n < 4) {
- block[0] = dcdiff * s->y_dc_scale;
- } else {
- block[0] = dcdiff * s->c_dc_scale;
- }
-
- //AC Decoding
- i = 1;
-
- /* check if AC is needed at all and adjust direction if needed */
- if (!a_avail) dc_pred_dir = 1;
- if (!c_avail) dc_pred_dir = 0;
- if (!a_avail && !c_avail) use_pred = 0;
- ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
- ac_val2 = ac_val;
-
- scale = mquant * 2 + v->halfpq;
-
- if (dc_pred_dir) //left
- ac_val -= 16;
- else //top
- ac_val -= 16 * s->block_wrap[n];
-
- q1 = s->current_picture.f.qscale_table[mb_pos];
- if (dc_pred_dir && c_avail && mb_pos)
- q2 = s->current_picture.f.qscale_table[mb_pos - 1];
- if (!dc_pred_dir && a_avail && mb_pos >= s->mb_stride)
- q2 = s->current_picture.f.qscale_table[mb_pos - s->mb_stride];
- if ( dc_pred_dir && n == 1)
- q2 = q1;
- if (!dc_pred_dir && n == 2)
- q2 = q1;
- if (n == 3) q2 = q1;
-
- if (coded) {
- int last = 0, skip, value;
- int k;
-
- while (!last) {
- vc1_decode_ac_coeff(v, &last, &skip, &value, codingset);
- i += skip;
- if (i > 63)
- break;
- if (v->fcm == PROGRESSIVE)
- block[v->zz_8x8[0][i++]] = value;
- else {
- if (use_pred && (v->fcm == ILACE_FRAME)) {
- if (!dc_pred_dir) // top
- block[v->zz_8x8[2][i++]] = value;
- else // left
- block[v->zz_8x8[3][i++]] = value;
- } else {
- block[v->zzi_8x8[i++]] = value;
- }
- }
- }
-
- /* apply AC prediction if needed */
- if (use_pred) {
- /* scale predictors if needed*/
- if (q2 && q1 != q2) {
- q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
- q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
-
- if (q1 < 1)
- return AVERROR_INVALIDDATA;
- if (dc_pred_dir) { // left
- for (k = 1; k < 8; k++)
- block[k << v->left_blk_sh] += (ac_val[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
- } else { //top
- for (k = 1; k < 8; k++)
- block[k << v->top_blk_sh] += (ac_val[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
- }
- } else {
- if (dc_pred_dir) { // left
- for (k = 1; k < 8; k++)
- block[k << v->left_blk_sh] += ac_val[k];
- } else { // top
- for (k = 1; k < 8; k++)
- block[k << v->top_blk_sh] += ac_val[k + 8];
- }
- }
- }
- /* save AC coeffs for further prediction */
- for (k = 1; k < 8; k++) {
- ac_val2[k ] = block[k << v->left_blk_sh];
- ac_val2[k + 8] = block[k << v->top_blk_sh];
- }
-
- /* scale AC coeffs */
- for (k = 1; k < 64; k++)
- if (block[k]) {
- block[k] *= scale;
- if (!v->pquantizer)
- block[k] += (block[k] < 0) ? -mquant : mquant;
- }
-
- if (use_pred) i = 63;
- } else { // no AC coeffs
- int k;
-
- memset(ac_val2, 0, 16 * 2);
- if (dc_pred_dir) { // left
- if (use_pred) {
- memcpy(ac_val2, ac_val, 8 * 2);
- if (q2 && q1 != q2) {
- q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
- q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
- if (q1 < 1)
- return AVERROR_INVALIDDATA;
- for (k = 1; k < 8; k++)
- ac_val2[k] = (ac_val2[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
- }
- }
- } else { // top
- if (use_pred) {
- memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
- if (q2 && q1 != q2) {
- q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1;
- q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1;
- if (q1 < 1)
- return AVERROR_INVALIDDATA;
- for (k = 1; k < 8; k++)
- ac_val2[k + 8] = (ac_val2[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
- }
- }
- }
-
- /* apply AC prediction if needed */
- if (use_pred) {
- if (dc_pred_dir) { // left
- for (k = 1; k < 8; k++) {
- block[k << v->left_blk_sh] = ac_val2[k] * scale;
- if (!v->pquantizer && block[k << v->left_blk_sh])
- block[k << v->left_blk_sh] += (block[k << v->left_blk_sh] < 0) ? -mquant : mquant;
- }
- } else { // top
- for (k = 1; k < 8; k++) {
- block[k << v->top_blk_sh] = ac_val2[k + 8] * scale;
- if (!v->pquantizer && block[k << v->top_blk_sh])
- block[k << v->top_blk_sh] += (block[k << v->top_blk_sh] < 0) ? -mquant : mquant;
- }
- }
- i = 63;
- }
- }
- s->block_last_index[n] = i;
-
- return 0;
-}
-
-/** Decode P block
- */
-static int vc1_decode_p_block(VC1Context *v, int16_t block[64], int n,
- int mquant, int ttmb, int first_block,
- uint8_t *dst, int linesize, int skip_block,
- int *ttmb_out)
-{
- MpegEncContext *s = &v->s;
- GetBitContext *gb = &s->gb;
- int i, j;
- int subblkpat = 0;
- int scale, off, idx, last, skip, value;
- int ttblk = ttmb & 7;
- int pat = 0;
-
- s->dsp.clear_block(block);
-
- if (ttmb == -1) {
- ttblk = ff_vc1_ttblk_to_tt[v->tt_index][get_vlc2(gb, ff_vc1_ttblk_vlc[v->tt_index].table, VC1_TTBLK_VLC_BITS, 1)];
- }
- if (ttblk == TT_4X4) {
- subblkpat = ~(get_vlc2(gb, ff_vc1_subblkpat_vlc[v->tt_index].table, VC1_SUBBLKPAT_VLC_BITS, 1) + 1);
- }
- if ((ttblk != TT_8X8 && ttblk != TT_4X4)
- && ((v->ttmbf || (ttmb != -1 && (ttmb & 8) && !first_block))
- || (!v->res_rtm_flag && !first_block))) {
- subblkpat = decode012(gb);
- if (subblkpat)
- subblkpat ^= 3; // swap decoded pattern bits
- if (ttblk == TT_8X4_TOP || ttblk == TT_8X4_BOTTOM)
- ttblk = TT_8X4;
- if (ttblk == TT_4X8_RIGHT || ttblk == TT_4X8_LEFT)
- ttblk = TT_4X8;
- }
- scale = 2 * mquant + ((v->pq == mquant) ? v->halfpq : 0);
-
- // convert transforms like 8X4_TOP to generic TT and SUBBLKPAT
- if (ttblk == TT_8X4_TOP || ttblk == TT_8X4_BOTTOM) {
- subblkpat = 2 - (ttblk == TT_8X4_TOP);
- ttblk = TT_8X4;
- }
- if (ttblk == TT_4X8_RIGHT || ttblk == TT_4X8_LEFT) {
- subblkpat = 2 - (ttblk == TT_4X8_LEFT);
- ttblk = TT_4X8;
- }
- switch (ttblk) {
- case TT_8X8:
- pat = 0xF;
- i = 0;
- last = 0;
- while (!last) {
- vc1_decode_ac_coeff(v, &last, &skip, &value, v->codingset2);
- i += skip;
- if (i > 63)
- break;
- if (!v->fcm)
- idx = v->zz_8x8[0][i++];
- else
- idx = v->zzi_8x8[i++];
- block[idx] = value * scale;
- if (!v->pquantizer)
- block[idx] += (block[idx] < 0) ? -mquant : mquant;
- }
- if (!skip_block) {
- if (i == 1)
- v->vc1dsp.vc1_inv_trans_8x8_dc(dst, linesize, block);
- else {
- v->vc1dsp.vc1_inv_trans_8x8(block);
- s->dsp.add_pixels_clamped(block, dst, linesize);
- }
- }
- break;
- case TT_4X4:
- pat = ~subblkpat & 0xF;
- for (j = 0; j < 4; j++) {
- last = subblkpat & (1 << (3 - j));
- i = 0;
- off = (j & 1) * 4 + (j & 2) * 16;
- while (!last) {
- vc1_decode_ac_coeff(v, &last, &skip, &value, v->codingset2);
- i += skip;
- if (i > 15)
- break;
- if (!v->fcm)
- idx = ff_vc1_simple_progressive_4x4_zz[i++];
- else
- idx = ff_vc1_adv_interlaced_4x4_zz[i++];
- block[idx + off] = value * scale;
- if (!v->pquantizer)
- block[idx + off] += (block[idx + off] < 0) ? -mquant : mquant;
- }
- if (!(subblkpat & (1 << (3 - j))) && !skip_block) {
- if (i == 1)
- v->vc1dsp.vc1_inv_trans_4x4_dc(dst + (j & 1) * 4 + (j & 2) * 2 * linesize, linesize, block + off);
- else
- v->vc1dsp.vc1_inv_trans_4x4(dst + (j & 1) * 4 + (j & 2) * 2 * linesize, linesize, block + off);
- }
- }
- break;
- case TT_8X4:
- pat = ~((subblkpat & 2) * 6 + (subblkpat & 1) * 3) & 0xF;
- for (j = 0; j < 2; j++) {
- last = subblkpat & (1 << (1 - j));
- i = 0;
- off = j * 32;
- while (!last) {
- vc1_decode_ac_coeff(v, &last, &skip, &value, v->codingset2);
- i += skip;
- if (i > 31)
- break;
- if (!v->fcm)
- idx = v->zz_8x4[i++] + off;
- else
- idx = ff_vc1_adv_interlaced_8x4_zz[i++] + off;
- block[idx] = value * scale;
- if (!v->pquantizer)
- block[idx] += (block[idx] < 0) ? -mquant : mquant;
- }
- if (!(subblkpat & (1 << (1 - j))) && !skip_block) {
- if (i == 1)
- v->vc1dsp.vc1_inv_trans_8x4_dc(dst + j * 4 * linesize, linesize, block + off);
- else
- v->vc1dsp.vc1_inv_trans_8x4(dst + j * 4 * linesize, linesize, block + off);
- }
- }
- break;
- case TT_4X8:
- pat = ~(subblkpat * 5) & 0xF;
- for (j = 0; j < 2; j++) {
- last = subblkpat & (1 << (1 - j));
- i = 0;
- off = j * 4;
- while (!last) {
- vc1_decode_ac_coeff(v, &last, &skip, &value, v->codingset2);
- i += skip;
- if (i > 31)
- break;
- if (!v->fcm)
- idx = v->zz_4x8[i++] + off;
- else
- idx = ff_vc1_adv_interlaced_4x8_zz[i++] + off;
- block[idx] = value * scale;
- if (!v->pquantizer)
- block[idx] += (block[idx] < 0) ? -mquant : mquant;
- }
- if (!(subblkpat & (1 << (1 - j))) && !skip_block) {
- if (i == 1)
- v->vc1dsp.vc1_inv_trans_4x8_dc(dst + j * 4, linesize, block + off);
- else
- v->vc1dsp.vc1_inv_trans_4x8(dst + j*4, linesize, block + off);
- }
- }
- break;
- }
- if (ttmb_out)
- *ttmb_out |= ttblk << (n * 4);
- return pat;
-}
-
-/** @} */ // Macroblock group
-
-static const int size_table [6] = { 0, 2, 3, 4, 5, 8 };
-static const int offset_table[6] = { 0, 1, 3, 7, 15, 31 };
-
-static av_always_inline void vc1_apply_p_v_loop_filter(VC1Context *v, int block_num)
-{
- MpegEncContext *s = &v->s;
- int mb_cbp = v->cbp[s->mb_x - s->mb_stride],
- block_cbp = mb_cbp >> (block_num * 4), bottom_cbp,
- mb_is_intra = v->is_intra[s->mb_x - s->mb_stride],
- block_is_intra = mb_is_intra >> (block_num * 4), bottom_is_intra;
- int idx, linesize = block_num > 3 ? s->uvlinesize : s->linesize, ttblk;
- uint8_t *dst;
-
- if (block_num > 3) {
- dst = s->dest[block_num - 3];
- } else {
- dst = s->dest[0] + (block_num & 1) * 8 + ((block_num & 2) * 4 - 8) * linesize;
- }
- if (s->mb_y != s->end_mb_y || block_num < 2) {
- int16_t (*mv)[2];
- int mv_stride;
-
- if (block_num > 3) {
- bottom_cbp = v->cbp[s->mb_x] >> (block_num * 4);
- bottom_is_intra = v->is_intra[s->mb_x] >> (block_num * 4);
- mv = &v->luma_mv[s->mb_x - s->mb_stride];
- mv_stride = s->mb_stride;
- } else {
- bottom_cbp = (block_num < 2) ? (mb_cbp >> ((block_num + 2) * 4))
- : (v->cbp[s->mb_x] >> ((block_num - 2) * 4));
- bottom_is_intra = (block_num < 2) ? (mb_is_intra >> ((block_num + 2) * 4))
- : (v->is_intra[s->mb_x] >> ((block_num - 2) * 4));
- mv_stride = s->b8_stride;
- mv = &s->current_picture.f.motion_val[0][s->block_index[block_num] - 2 * mv_stride];
- }
-
- if (bottom_is_intra & 1 || block_is_intra & 1 ||
- mv[0][0] != mv[mv_stride][0] || mv[0][1] != mv[mv_stride][1]) {
- v->vc1dsp.vc1_v_loop_filter8(dst, linesize, v->pq);
- } else {
- idx = ((bottom_cbp >> 2) | block_cbp) & 3;
- if (idx == 3) {
- v->vc1dsp.vc1_v_loop_filter8(dst, linesize, v->pq);
- } else if (idx) {
- if (idx == 1)
- v->vc1dsp.vc1_v_loop_filter4(dst + 4, linesize, v->pq);
- else
- v->vc1dsp.vc1_v_loop_filter4(dst, linesize, v->pq);
- }
- }
- }
-
- dst -= 4 * linesize;
- ttblk = (v->ttblk[s->mb_x - s->mb_stride] >> (block_num * 4)) & 0xF;
- if (ttblk == TT_4X4 || ttblk == TT_8X4) {
- idx = (block_cbp | (block_cbp >> 2)) & 3;
- if (idx == 3) {
- v->vc1dsp.vc1_v_loop_filter8(dst, linesize, v->pq);
- } else if (idx) {
- if (idx == 1)
- v->vc1dsp.vc1_v_loop_filter4(dst + 4, linesize, v->pq);
- else
- v->vc1dsp.vc1_v_loop_filter4(dst, linesize, v->pq);
- }
- }
-}
-
-static av_always_inline void vc1_apply_p_h_loop_filter(VC1Context *v, int block_num)
-{
- MpegEncContext *s = &v->s;
- int mb_cbp = v->cbp[s->mb_x - 1 - s->mb_stride],
- block_cbp = mb_cbp >> (block_num * 4), right_cbp,
- mb_is_intra = v->is_intra[s->mb_x - 1 - s->mb_stride],
- block_is_intra = mb_is_intra >> (block_num * 4), right_is_intra;
- int idx, linesize = block_num > 3 ? s->uvlinesize : s->linesize, ttblk;
- uint8_t *dst;
-
- if (block_num > 3) {
- dst = s->dest[block_num - 3] - 8 * linesize;
- } else {
- dst = s->dest[0] + (block_num & 1) * 8 + ((block_num & 2) * 4 - 16) * linesize - 8;
- }
-
- if (s->mb_x != s->mb_width || !(block_num & 5)) {
- int16_t (*mv)[2];
-
- if (block_num > 3) {
- right_cbp = v->cbp[s->mb_x - s->mb_stride] >> (block_num * 4);
- right_is_intra = v->is_intra[s->mb_x - s->mb_stride] >> (block_num * 4);
- mv = &v->luma_mv[s->mb_x - s->mb_stride - 1];
- } else {
- right_cbp = (block_num & 1) ? (v->cbp[s->mb_x - s->mb_stride] >> ((block_num - 1) * 4))
- : (mb_cbp >> ((block_num + 1) * 4));
- right_is_intra = (block_num & 1) ? (v->is_intra[s->mb_x - s->mb_stride] >> ((block_num - 1) * 4))
- : (mb_is_intra >> ((block_num + 1) * 4));
- mv = &s->current_picture.f.motion_val[0][s->block_index[block_num] - s->b8_stride * 2 - 2];
- }
- if (block_is_intra & 1 || right_is_intra & 1 || mv[0][0] != mv[1][0] || mv[0][1] != mv[1][1]) {
- v->vc1dsp.vc1_h_loop_filter8(dst, linesize, v->pq);
- } else {
- idx = ((right_cbp >> 1) | block_cbp) & 5; // FIXME check
- if (idx == 5) {
- v->vc1dsp.vc1_h_loop_filter8(dst, linesize, v->pq);
- } else if (idx) {
- if (idx == 1)
- v->vc1dsp.vc1_h_loop_filter4(dst + 4 * linesize, linesize, v->pq);
- else
- v->vc1dsp.vc1_h_loop_filter4(dst, linesize, v->pq);
- }
- }
- }
-
- dst -= 4;
- ttblk = (v->ttblk[s->mb_x - s->mb_stride - 1] >> (block_num * 4)) & 0xf;
- if (ttblk == TT_4X4 || ttblk == TT_4X8) {
- idx = (block_cbp | (block_cbp >> 1)) & 5;
- if (idx == 5) {
- v->vc1dsp.vc1_h_loop_filter8(dst, linesize, v->pq);
- } else if (idx) {
- if (idx == 1)
- v->vc1dsp.vc1_h_loop_filter4(dst + linesize * 4, linesize, v->pq);
- else
- v->vc1dsp.vc1_h_loop_filter4(dst, linesize, v->pq);
- }
- }
-}
-
-static void vc1_apply_p_loop_filter(VC1Context *v)
-{
- MpegEncContext *s = &v->s;
- int i;
-
- for (i = 0; i < 6; i++) {
- vc1_apply_p_v_loop_filter(v, i);
- }
-
- /* V always precedes H, therefore we run H one MB before V;
- * at the end of a row, we catch up to complete the row */
- if (s->mb_x) {
- for (i = 0; i < 6; i++) {
- vc1_apply_p_h_loop_filter(v, i);
- }
- if (s->mb_x == s->mb_width - 1) {
- s->mb_x++;
- ff_update_block_index(s);
- for (i = 0; i < 6; i++) {
- vc1_apply_p_h_loop_filter(v, i);
- }
- }
- }
-}
-
-/** Decode one P-frame MB
- */
-static int vc1_decode_p_mb(VC1Context *v)
-{
- MpegEncContext *s = &v->s;
- GetBitContext *gb = &s->gb;
- int i, j;
- int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
- int cbp; /* cbp decoding stuff */
- int mqdiff, mquant; /* MB quantization */
- int ttmb = v->ttfrm; /* MB Transform type */
-
- int mb_has_coeffs = 1; /* last_flag */
- int dmv_x, dmv_y; /* Differential MV components */
- int index, index1; /* LUT indexes */
- int val, sign; /* temp values */
- int first_block = 1;
- int dst_idx, off;
- int skipped, fourmv;
- int block_cbp = 0, pat, block_tt = 0, block_intra = 0;
-
- mquant = v->pq; /* lossy initialization */
-
- if (v->mv_type_is_raw)
- fourmv = get_bits1(gb);
- else
- fourmv = v->mv_type_mb_plane[mb_pos];
- if (v->skip_is_raw)
- skipped = get_bits1(gb);
- else
- skipped = v->s.mbskip_table[mb_pos];
-
- if (!fourmv) { /* 1MV mode */
- if (!skipped) {
- GET_MVDATA(dmv_x, dmv_y);
-
- if (s->mb_intra) {
- s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0;
- s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0;
- }
- s->current_picture.f.mb_type[mb_pos] = s->mb_intra ? MB_TYPE_INTRA : MB_TYPE_16x16;
- vc1_pred_mv(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0], 0, 0);
-
- /* FIXME Set DC val for inter block ? */
- if (s->mb_intra && !mb_has_coeffs) {
- GET_MQUANT();
- s->ac_pred = get_bits1(gb);
- cbp = 0;
- } else if (mb_has_coeffs) {
- if (s->mb_intra)
- s->ac_pred = get_bits1(gb);
- cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
- GET_MQUANT();
- } else {
- mquant = v->pq;
- cbp = 0;
- }
- s->current_picture.f.qscale_table[mb_pos] = mquant;
-
- if (!v->ttmbf && !s->mb_intra && mb_has_coeffs)
- ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table,
- VC1_TTMB_VLC_BITS, 2);
- if (!s->mb_intra) vc1_mc_1mv(v, 0);
- dst_idx = 0;
- for (i = 0; i < 6; i++) {
- s->dc_val[0][s->block_index[i]] = 0;
- dst_idx += i >> 2;
- val = ((cbp >> (5 - i)) & 1);
- off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
- v->mb_type[0][s->block_index[i]] = s->mb_intra;
- if (s->mb_intra) {
- /* check if prediction blocks A and C are available */
- v->a_avail = v->c_avail = 0;
- if (i == 2 || i == 3 || !s->first_slice_line)
- v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]];
- if (i == 1 || i == 3 || s->mb_x)
- v->c_avail = v->mb_type[0][s->block_index[i] - 1];
-
- vc1_decode_intra_block(v, s->block[i], i, val, mquant,
- (i & 4) ? v->codingset2 : v->codingset);
- if ((i>3) && (s->flags & CODEC_FLAG_GRAY))
- continue;
- v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
- if (v->rangeredfrm)
- for (j = 0; j < 64; j++)
- s->block[i][j] <<= 1;
- s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
- if (v->pq >= 9 && v->overlap) {
- if (v->c_avail)
- v->vc1dsp.vc1_h_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
- if (v->a_avail)
- v->vc1dsp.vc1_v_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
- }
- block_cbp |= 0xF << (i << 2);
- block_intra |= 1 << i;
- } else if (val) {
- pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block,
- s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : s->linesize,
- (i & 4) && (s->flags & CODEC_FLAG_GRAY), &block_tt);
- block_cbp |= pat << (i << 2);
- if (!v->ttmbf && ttmb < 8)
- ttmb = -1;
- first_block = 0;
- }
- }
- } else { // skipped
- s->mb_intra = 0;
- for (i = 0; i < 6; i++) {
- v->mb_type[0][s->block_index[i]] = 0;
- s->dc_val[0][s->block_index[i]] = 0;
- }
- s->current_picture.f.mb_type[mb_pos] = MB_TYPE_SKIP;
- s->current_picture.f.qscale_table[mb_pos] = 0;
- vc1_pred_mv(v, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0], 0, 0);
- vc1_mc_1mv(v, 0);
- }
- } else { // 4MV mode
- if (!skipped /* unskipped MB */) {
- int intra_count = 0, coded_inter = 0;
- int is_intra[6], is_coded[6];
- /* Get CBPCY */
- cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
- for (i = 0; i < 6; i++) {
- val = ((cbp >> (5 - i)) & 1);
- s->dc_val[0][s->block_index[i]] = 0;
- s->mb_intra = 0;
- if (i < 4) {
- dmv_x = dmv_y = 0;
- s->mb_intra = 0;
- mb_has_coeffs = 0;
- if (val) {
- GET_MVDATA(dmv_x, dmv_y);
- }
- vc1_pred_mv(v, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, v->mb_type[0], 0, 0);
- if (!s->mb_intra)
- vc1_mc_4mv_luma(v, i, 0);
- intra_count += s->mb_intra;
- is_intra[i] = s->mb_intra;
- is_coded[i] = mb_has_coeffs;
- }
- if (i & 4) {
- is_intra[i] = (intra_count >= 3);
- is_coded[i] = val;
- }
- if (i == 4)
- vc1_mc_4mv_chroma(v, 0);
- v->mb_type[0][s->block_index[i]] = is_intra[i];
- if (!coded_inter)
- coded_inter = !is_intra[i] & is_coded[i];
- }
- // if there are no coded blocks then don't do anything more
- dst_idx = 0;
- if (!intra_count && !coded_inter)
- goto end;
- GET_MQUANT();
- s->current_picture.f.qscale_table[mb_pos] = mquant;
- /* test if block is intra and has pred */
- {
- int intrapred = 0;
- for (i = 0; i < 6; i++)
- if (is_intra[i]) {
- if (((!s->first_slice_line || (i == 2 || i == 3)) && v->mb_type[0][s->block_index[i] - s->block_wrap[i]])
- || ((s->mb_x || (i == 1 || i == 3)) && v->mb_type[0][s->block_index[i] - 1])) {
- intrapred = 1;
- break;
- }
- }
- if (intrapred)
- s->ac_pred = get_bits1(gb);
- else
- s->ac_pred = 0;
- }
- if (!v->ttmbf && coded_inter)
- ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
- for (i = 0; i < 6; i++) {
- dst_idx += i >> 2;
- off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
- s->mb_intra = is_intra[i];
- if (is_intra[i]) {
- /* check if prediction blocks A and C are available */
- v->a_avail = v->c_avail = 0;
- if (i == 2 || i == 3 || !s->first_slice_line)
- v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]];
- if (i == 1 || i == 3 || s->mb_x)
- v->c_avail = v->mb_type[0][s->block_index[i] - 1];
-
- vc1_decode_intra_block(v, s->block[i], i, is_coded[i], mquant,
- (i & 4) ? v->codingset2 : v->codingset);
- if ((i>3) && (s->flags & CODEC_FLAG_GRAY))
- continue;
- v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
- if (v->rangeredfrm)
- for (j = 0; j < 64; j++)
- s->block[i][j] <<= 1;
- s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off,
- (i & 4) ? s->uvlinesize : s->linesize);
- if (v->pq >= 9 && v->overlap) {
- if (v->c_avail)
- v->vc1dsp.vc1_h_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
- if (v->a_avail)
- v->vc1dsp.vc1_v_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
- }
- block_cbp |= 0xF << (i << 2);
- block_intra |= 1 << i;
- } else if (is_coded[i]) {
- pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb,
- first_block, s->dest[dst_idx] + off,
- (i & 4) ? s->uvlinesize : s->linesize,
- (i & 4) && (s->flags & CODEC_FLAG_GRAY),
- &block_tt);
- block_cbp |= pat << (i << 2);
- if (!v->ttmbf && ttmb < 8)
- ttmb = -1;
- first_block = 0;
- }
- }
- } else { // skipped MB
- s->mb_intra = 0;
- s->current_picture.f.qscale_table[mb_pos] = 0;
- for (i = 0; i < 6; i++) {
- v->mb_type[0][s->block_index[i]] = 0;
- s->dc_val[0][s->block_index[i]] = 0;
- }
- for (i = 0; i < 4; i++) {
- vc1_pred_mv(v, i, 0, 0, 0, v->range_x, v->range_y, v->mb_type[0], 0, 0);
- vc1_mc_4mv_luma(v, i, 0);
- }
- vc1_mc_4mv_chroma(v, 0);
- s->current_picture.f.qscale_table[mb_pos] = 0;
- }
- }
-end:
- v->cbp[s->mb_x] = block_cbp;
- v->ttblk[s->mb_x] = block_tt;
- v->is_intra[s->mb_x] = block_intra;
-
- return 0;
-}
-
-/* Decode one macroblock in an interlaced frame p picture */
-
-static int vc1_decode_p_mb_intfr(VC1Context *v)
-{
- MpegEncContext *s = &v->s;
- GetBitContext *gb = &s->gb;
- int i;
- int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
- int cbp = 0; /* cbp decoding stuff */
- int mqdiff, mquant; /* MB quantization */
- int ttmb = v->ttfrm; /* MB Transform type */
-
- int mb_has_coeffs = 1; /* last_flag */
- int dmv_x, dmv_y; /* Differential MV components */
- int val; /* temp value */
- int first_block = 1;
- int dst_idx, off;
- int skipped, fourmv = 0, twomv = 0;
- int block_cbp = 0, pat, block_tt = 0;
- int idx_mbmode = 0, mvbp;
- int stride_y, fieldtx;
-
- mquant = v->pq; /* Lossy initialization */
-
- if (v->skip_is_raw)
- skipped = get_bits1(gb);
- else
- skipped = v->s.mbskip_table[mb_pos];
- if (!skipped) {
- if (v->fourmvswitch)
- idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_INTFR_4MV_MBMODE_VLC_BITS, 2); // try getting this done
- else
- idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_INTFR_NON4MV_MBMODE_VLC_BITS, 2); // in a single line
- switch (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0]) {
- /* store the motion vector type in a flag (useful later) */
- case MV_PMODE_INTFR_4MV:
- fourmv = 1;
- v->blk_mv_type[s->block_index[0]] = 0;
- v->blk_mv_type[s->block_index[1]] = 0;
- v->blk_mv_type[s->block_index[2]] = 0;
- v->blk_mv_type[s->block_index[3]] = 0;
- break;
- case MV_PMODE_INTFR_4MV_FIELD:
- fourmv = 1;
- v->blk_mv_type[s->block_index[0]] = 1;
- v->blk_mv_type[s->block_index[1]] = 1;
- v->blk_mv_type[s->block_index[2]] = 1;
- v->blk_mv_type[s->block_index[3]] = 1;
- break;
- case MV_PMODE_INTFR_2MV_FIELD:
- twomv = 1;
- v->blk_mv_type[s->block_index[0]] = 1;
- v->blk_mv_type[s->block_index[1]] = 1;
- v->blk_mv_type[s->block_index[2]] = 1;
- v->blk_mv_type[s->block_index[3]] = 1;
- break;
- case MV_PMODE_INTFR_1MV:
- v->blk_mv_type[s->block_index[0]] = 0;
- v->blk_mv_type[s->block_index[1]] = 0;
- v->blk_mv_type[s->block_index[2]] = 0;
- v->blk_mv_type[s->block_index[3]] = 0;
- break;
- }
- if (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_INTRA) { // intra MB
- s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0;
- s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0;
- s->current_picture.f.mb_type[mb_pos] = MB_TYPE_INTRA;
- s->mb_intra = v->is_intra[s->mb_x] = 1;
- for (i = 0; i < 6; i++)
- v->mb_type[0][s->block_index[i]] = 1;
- fieldtx = v->fieldtx_plane[mb_pos] = get_bits1(gb);
- mb_has_coeffs = get_bits1(gb);
- if (mb_has_coeffs)
- cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
- v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb);
- GET_MQUANT();
- s->current_picture.f.qscale_table[mb_pos] = mquant;
- /* Set DC scale - y and c use the same (not sure if necessary here) */
- s->y_dc_scale = s->y_dc_scale_table[mquant];
- s->c_dc_scale = s->c_dc_scale_table[mquant];
- dst_idx = 0;
- for (i = 0; i < 6; i++) {
- s->dc_val[0][s->block_index[i]] = 0;
- dst_idx += i >> 2;
- val = ((cbp >> (5 - i)) & 1);
- v->mb_type[0][s->block_index[i]] = s->mb_intra;
- v->a_avail = v->c_avail = 0;
- if (i == 2 || i == 3 || !s->first_slice_line)
- v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]];
- if (i == 1 || i == 3 || s->mb_x)
- v->c_avail = v->mb_type[0][s->block_index[i] - 1];
-
- vc1_decode_intra_block(v, s->block[i], i, val, mquant,
- (i & 4) ? v->codingset2 : v->codingset);
- if ((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue;
- v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
- if (i < 4) {
- stride_y = s->linesize << fieldtx;
- off = (fieldtx) ? ((i & 1) * 8) + ((i & 2) >> 1) * s->linesize : (i & 1) * 8 + 4 * (i & 2) * s->linesize;
- } else {
- stride_y = s->uvlinesize;
- off = 0;
- }
- s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, stride_y);
- //TODO: loop filter
- }
-
- } else { // inter MB
- mb_has_coeffs = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][3];
- if (mb_has_coeffs)
- cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
- if (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_2MV_FIELD) {
- v->twomvbp = get_vlc2(gb, v->twomvbp_vlc->table, VC1_2MV_BLOCK_PATTERN_VLC_BITS, 1);
- } else {
- if ((ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_4MV)
- || (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_4MV_FIELD)) {
- v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);
- }
- }
- s->mb_intra = v->is_intra[s->mb_x] = 0;
- for (i = 0; i < 6; i++)
- v->mb_type[0][s->block_index[i]] = 0;
- fieldtx = v->fieldtx_plane[mb_pos] = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][1];
- /* for all motion vector read MVDATA and motion compensate each block */
- dst_idx = 0;
- if (fourmv) {
- mvbp = v->fourmvbp;
- for (i = 0; i < 6; i++) {
- if (i < 4) {
- dmv_x = dmv_y = 0;
- val = ((mvbp >> (3 - i)) & 1);
- if (val) {
- get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
- }
- vc1_pred_mv_intfr(v, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, v->mb_type[0]);
- vc1_mc_4mv_luma(v, i, 0);
- } else if (i == 4) {
- vc1_mc_4mv_chroma4(v);
- }
- }
- } else if (twomv) {
- mvbp = v->twomvbp;
- dmv_x = dmv_y = 0;
- if (mvbp & 2) {
- get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
- }
- vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 2, v->range_x, v->range_y, v->mb_type[0]);
- vc1_mc_4mv_luma(v, 0, 0);
- vc1_mc_4mv_luma(v, 1, 0);
- dmv_x = dmv_y = 0;
- if (mvbp & 1) {
- get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
- }
- vc1_pred_mv_intfr(v, 2, dmv_x, dmv_y, 2, v->range_x, v->range_y, v->mb_type[0]);
- vc1_mc_4mv_luma(v, 2, 0);
- vc1_mc_4mv_luma(v, 3, 0);
- vc1_mc_4mv_chroma4(v);
- } else {
- mvbp = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][2];
- dmv_x = dmv_y = 0;
- if (mvbp) {
- get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
- }
- vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0]);
- vc1_mc_1mv(v, 0);
- }
- if (cbp)
- GET_MQUANT(); // p. 227
- s->current_picture.f.qscale_table[mb_pos] = mquant;
- if (!v->ttmbf && cbp)
- ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
- for (i = 0; i < 6; i++) {
- s->dc_val[0][s->block_index[i]] = 0;
- dst_idx += i >> 2;
- val = ((cbp >> (5 - i)) & 1);
- if (!fieldtx)
- off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
- else
- off = (i & 4) ? 0 : ((i & 1) * 8 + ((i > 1) * s->linesize));
- if (val) {
- pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb,
- first_block, s->dest[dst_idx] + off,
- (i & 4) ? s->uvlinesize : (s->linesize << fieldtx),
- (i & 4) && (s->flags & CODEC_FLAG_GRAY), &block_tt);
- block_cbp |= pat << (i << 2);
- if (!v->ttmbf && ttmb < 8)
- ttmb = -1;
- first_block = 0;
- }
- }
- }
- } else { // skipped
- s->mb_intra = v->is_intra[s->mb_x] = 0;
- for (i = 0; i < 6; i++) {
- v->mb_type[0][s->block_index[i]] = 0;
- s->dc_val[0][s->block_index[i]] = 0;
- }
- s->current_picture.f.mb_type[mb_pos] = MB_TYPE_SKIP;
- s->current_picture.f.qscale_table[mb_pos] = 0;
- v->blk_mv_type[s->block_index[0]] = 0;
- v->blk_mv_type[s->block_index[1]] = 0;
- v->blk_mv_type[s->block_index[2]] = 0;
- v->blk_mv_type[s->block_index[3]] = 0;
- vc1_pred_mv_intfr(v, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0]);
- vc1_mc_1mv(v, 0);
- }
- if (s->mb_x == s->mb_width - 1)
- memmove(v->is_intra_base, v->is_intra, sizeof(v->is_intra_base[0])*s->mb_stride);
- return 0;
-}
-
-static int vc1_decode_p_mb_intfi(VC1Context *v)
-{
- MpegEncContext *s = &v->s;
- GetBitContext *gb = &s->gb;
- int i;
- int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
- int cbp = 0; /* cbp decoding stuff */
- int mqdiff, mquant; /* MB quantization */
- int ttmb = v->ttfrm; /* MB Transform type */
-
- int mb_has_coeffs = 1; /* last_flag */
- int dmv_x, dmv_y; /* Differential MV components */
- int val; /* temp values */
- int first_block = 1;
- int dst_idx, off;
- int pred_flag = 0;
- int block_cbp = 0, pat, block_tt = 0;
- int idx_mbmode = 0;
-
- mquant = v->pq; /* Lossy initialization */
-
- idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_IF_MBMODE_VLC_BITS, 2);
- if (idx_mbmode <= 1) { // intra MB
- s->mb_intra = v->is_intra[s->mb_x] = 1;
- s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][0] = 0;
- s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][1] = 0;
- s->current_picture.f.mb_type[mb_pos + v->mb_off] = MB_TYPE_INTRA;
- GET_MQUANT();
- s->current_picture.f.qscale_table[mb_pos] = mquant;
- /* Set DC scale - y and c use the same (not sure if necessary here) */
- s->y_dc_scale = s->y_dc_scale_table[mquant];
- s->c_dc_scale = s->c_dc_scale_table[mquant];
- v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb);
- mb_has_coeffs = idx_mbmode & 1;
- if (mb_has_coeffs)
- cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_ICBPCY_VLC_BITS, 2);
- dst_idx = 0;
- for (i = 0; i < 6; i++) {
- s->dc_val[0][s->block_index[i]] = 0;
- v->mb_type[0][s->block_index[i]] = 1;
- dst_idx += i >> 2;
- val = ((cbp >> (5 - i)) & 1);
- v->a_avail = v->c_avail = 0;
- if (i == 2 || i == 3 || !s->first_slice_line)
- v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]];
- if (i == 1 || i == 3 || s->mb_x)
- v->c_avail = v->mb_type[0][s->block_index[i] - 1];
-
- vc1_decode_intra_block(v, s->block[i], i, val, mquant,
- (i & 4) ? v->codingset2 : v->codingset);
- if ((i>3) && (s->flags & CODEC_FLAG_GRAY))
- continue;
- v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
- off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
- s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : s->linesize);
- // TODO: loop filter
- }
- } else {
- s->mb_intra = v->is_intra[s->mb_x] = 0;
- s->current_picture.f.mb_type[mb_pos + v->mb_off] = MB_TYPE_16x16;
- for (i = 0; i < 6; i++) v->mb_type[0][s->block_index[i]] = 0;
- if (idx_mbmode <= 5) { // 1-MV
- dmv_x = dmv_y = pred_flag = 0;
- if (idx_mbmode & 1) {
- get_mvdata_interlaced(v, &dmv_x, &dmv_y, &pred_flag);
- }
- vc1_pred_mv(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0], pred_flag, 0);
- vc1_mc_1mv(v, 0);
- mb_has_coeffs = !(idx_mbmode & 2);
- } else { // 4-MV
- v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);
- for (i = 0; i < 6; i++) {
- if (i < 4) {
- dmv_x = dmv_y = pred_flag = 0;
- val = ((v->fourmvbp >> (3 - i)) & 1);
- if (val) {
- get_mvdata_interlaced(v, &dmv_x, &dmv_y, &pred_flag);
- }
- vc1_pred_mv(v, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, v->mb_type[0], pred_flag, 0);
- vc1_mc_4mv_luma(v, i, 0);
- } else if (i == 4)
- vc1_mc_4mv_chroma(v, 0);
- }
- mb_has_coeffs = idx_mbmode & 1;
- }
- if (mb_has_coeffs)
- cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
- if (cbp) {
- GET_MQUANT();
- }
- s->current_picture.f.qscale_table[mb_pos] = mquant;
- if (!v->ttmbf && cbp) {
- ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
- }
- dst_idx = 0;
- for (i = 0; i < 6; i++) {
- s->dc_val[0][s->block_index[i]] = 0;
- dst_idx += i >> 2;
- val = ((cbp >> (5 - i)) & 1);
- off = (i & 4) ? 0 : (i & 1) * 8 + (i & 2) * 4 * s->linesize;
- if (val) {
- pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb,
- first_block, s->dest[dst_idx] + off,
- (i & 4) ? s->uvlinesize : s->linesize,
- (i & 4) && (s->flags & CODEC_FLAG_GRAY),
- &block_tt);
- block_cbp |= pat << (i << 2);
- if (!v->ttmbf && ttmb < 8) ttmb = -1;
- first_block = 0;
- }
- }
- }
- if (s->mb_x == s->mb_width - 1)
- memmove(v->is_intra_base, v->is_intra, sizeof(v->is_intra_base[0]) * s->mb_stride);
- return 0;
-}
-
-/** Decode one B-frame MB (in Main profile)
- */
-static void vc1_decode_b_mb(VC1Context *v)
-{
- MpegEncContext *s = &v->s;
- GetBitContext *gb = &s->gb;
- int i, j;
- int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
- int cbp = 0; /* cbp decoding stuff */
- int mqdiff, mquant; /* MB quantization */
- int ttmb = v->ttfrm; /* MB Transform type */
- int mb_has_coeffs = 0; /* last_flag */
- int index, index1; /* LUT indexes */
- int val, sign; /* temp values */
- int first_block = 1;
- int dst_idx, off;
- int skipped, direct;
- int dmv_x[2], dmv_y[2];
- int bmvtype = BMV_TYPE_BACKWARD;
-
- mquant = v->pq; /* lossy initialization */
- s->mb_intra = 0;
-
- if (v->dmb_is_raw)
- direct = get_bits1(gb);
- else
- direct = v->direct_mb_plane[mb_pos];
- if (v->skip_is_raw)
- skipped = get_bits1(gb);
- else
- skipped = v->s.mbskip_table[mb_pos];
-
- dmv_x[0] = dmv_x[1] = dmv_y[0] = dmv_y[1] = 0;
- for (i = 0; i < 6; i++) {
- v->mb_type[0][s->block_index[i]] = 0;
- s->dc_val[0][s->block_index[i]] = 0;
- }
- s->current_picture.f.qscale_table[mb_pos] = 0;
-
- if (!direct) {
- if (!skipped) {
- GET_MVDATA(dmv_x[0], dmv_y[0]);
- dmv_x[1] = dmv_x[0];
- dmv_y[1] = dmv_y[0];
- }
- if (skipped || !s->mb_intra) {
- bmvtype = decode012(gb);
- switch (bmvtype) {
- case 0:
- bmvtype = (v->bfraction >= (B_FRACTION_DEN/2)) ? BMV_TYPE_BACKWARD : BMV_TYPE_FORWARD;
- break;
- case 1:
- bmvtype = (v->bfraction >= (B_FRACTION_DEN/2)) ? BMV_TYPE_FORWARD : BMV_TYPE_BACKWARD;
- break;
- case 2:
- bmvtype = BMV_TYPE_INTERPOLATED;
- dmv_x[0] = dmv_y[0] = 0;
- }
- }
- }
- for (i = 0; i < 6; i++)
- v->mb_type[0][s->block_index[i]] = s->mb_intra;
-
- if (skipped) {
- if (direct)
- bmvtype = BMV_TYPE_INTERPOLATED;
- vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype);
- vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
- return;
- }
- if (direct) {
- cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
- GET_MQUANT();
- s->mb_intra = 0;
- s->current_picture.f.qscale_table[mb_pos] = mquant;
- if (!v->ttmbf)
- ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
- dmv_x[0] = dmv_y[0] = dmv_x[1] = dmv_y[1] = 0;
- vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype);
- vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
- } else {
- if (!mb_has_coeffs && !s->mb_intra) {
- /* no coded blocks - effectively skipped */
- vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype);
- vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
- return;
- }
- if (s->mb_intra && !mb_has_coeffs) {
- GET_MQUANT();
- s->current_picture.f.qscale_table[mb_pos] = mquant;
- s->ac_pred = get_bits1(gb);
- cbp = 0;
- vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype);
- } else {
- if (bmvtype == BMV_TYPE_INTERPOLATED) {
- GET_MVDATA(dmv_x[0], dmv_y[0]);
- if (!mb_has_coeffs) {
- /* interpolated skipped block */
- vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype);
- vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
- return;
- }
- }
- vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype);
- if (!s->mb_intra) {
- vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
- }
- if (s->mb_intra)
- s->ac_pred = get_bits1(gb);
- cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
- GET_MQUANT();
- s->current_picture.f.qscale_table[mb_pos] = mquant;
- if (!v->ttmbf && !s->mb_intra && mb_has_coeffs)
- ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
- }
- }
- dst_idx = 0;
- for (i = 0; i < 6; i++) {
- s->dc_val[0][s->block_index[i]] = 0;
- dst_idx += i >> 2;
- val = ((cbp >> (5 - i)) & 1);
- off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
- v->mb_type[0][s->block_index[i]] = s->mb_intra;
- if (s->mb_intra) {
- /* check if prediction blocks A and C are available */
- v->a_avail = v->c_avail = 0;
- if (i == 2 || i == 3 || !s->first_slice_line)
- v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]];
- if (i == 1 || i == 3 || s->mb_x)
- v->c_avail = v->mb_type[0][s->block_index[i] - 1];
-
- vc1_decode_intra_block(v, s->block[i], i, val, mquant,
- (i & 4) ? v->codingset2 : v->codingset);
- if ((i>3) && (s->flags & CODEC_FLAG_GRAY))
- continue;
- v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
- if (v->rangeredfrm)
- for (j = 0; j < 64; j++)
- s->block[i][j] <<= 1;
- s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize);
- } else if (val) {
- vc1_decode_p_block(v, s->block[i], i, mquant, ttmb,
- first_block, s->dest[dst_idx] + off,
- (i & 4) ? s->uvlinesize : s->linesize,
- (i & 4) && (s->flags & CODEC_FLAG_GRAY), NULL);
- if (!v->ttmbf && ttmb < 8)
- ttmb = -1;
- first_block = 0;
- }
- }
-}
-
-/** Decode one B-frame MB (in interlaced field B picture)
- */
-static void vc1_decode_b_mb_intfi(VC1Context *v)
-{
- MpegEncContext *s = &v->s;
- GetBitContext *gb = &s->gb;
- int i, j;
- int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
- int cbp = 0; /* cbp decoding stuff */
- int mqdiff, mquant; /* MB quantization */
- int ttmb = v->ttfrm; /* MB Transform type */
- int mb_has_coeffs = 0; /* last_flag */
- int val; /* temp value */
- int first_block = 1;
- int dst_idx, off;
- int fwd;
- int dmv_x[2], dmv_y[2], pred_flag[2];
- int bmvtype = BMV_TYPE_BACKWARD;
- int idx_mbmode, interpmvp;
-
- mquant = v->pq; /* Lossy initialization */
- s->mb_intra = 0;
-
- idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_IF_MBMODE_VLC_BITS, 2);
- if (idx_mbmode <= 1) { // intra MB
- s->mb_intra = v->is_intra[s->mb_x] = 1;
- s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0;
- s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0;
- s->current_picture.f.mb_type[mb_pos + v->mb_off] = MB_TYPE_INTRA;
- GET_MQUANT();
- s->current_picture.f.qscale_table[mb_pos] = mquant;
- /* Set DC scale - y and c use the same (not sure if necessary here) */
- s->y_dc_scale = s->y_dc_scale_table[mquant];
- s->c_dc_scale = s->c_dc_scale_table[mquant];
- v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb);
- mb_has_coeffs = idx_mbmode & 1;
- if (mb_has_coeffs)
- cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_ICBPCY_VLC_BITS, 2);
- dst_idx = 0;
- for (i = 0; i < 6; i++) {
- s->dc_val[0][s->block_index[i]] = 0;
- dst_idx += i >> 2;
- val = ((cbp >> (5 - i)) & 1);
- v->mb_type[0][s->block_index[i]] = s->mb_intra;
- v->a_avail = v->c_avail = 0;
- if (i == 2 || i == 3 || !s->first_slice_line)
- v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]];
- if (i == 1 || i == 3 || s->mb_x)
- v->c_avail = v->mb_type[0][s->block_index[i] - 1];
-
- vc1_decode_intra_block(v, s->block[i], i, val, mquant,
- (i & 4) ? v->codingset2 : v->codingset);
- if ((i>3) && (s->flags & CODEC_FLAG_GRAY))
- continue;
- v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
- if (v->rangeredfrm)
- for (j = 0; j < 64; j++)
- s->block[i][j] <<= 1;
- off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
- s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : s->linesize);
- // TODO: yet to perform loop filter
- }
- } else {
- s->mb_intra = v->is_intra[s->mb_x] = 0;
- s->current_picture.f.mb_type[mb_pos + v->mb_off] = MB_TYPE_16x16;
- for (i = 0; i < 6; i++) v->mb_type[0][s->block_index[i]] = 0;
- if (v->fmb_is_raw)
- fwd = v->forward_mb_plane[mb_pos] = get_bits1(gb);
- else
- fwd = v->forward_mb_plane[mb_pos];
- if (idx_mbmode <= 5) { // 1-MV
- dmv_x[0] = dmv_x[1] = dmv_y[0] = dmv_y[1] = 0;
- pred_flag[0] = pred_flag[1] = 0;
- if (fwd)
- bmvtype = BMV_TYPE_FORWARD;
- else {
- bmvtype = decode012(gb);
- switch (bmvtype) {
- case 0:
- bmvtype = BMV_TYPE_BACKWARD;
- break;
- case 1:
- bmvtype = BMV_TYPE_DIRECT;
- break;
- case 2:
- bmvtype = BMV_TYPE_INTERPOLATED;
- interpmvp = get_bits1(gb);
- }
- }
- v->bmvtype = bmvtype;
- if (bmvtype != BMV_TYPE_DIRECT && idx_mbmode & 1) {
- get_mvdata_interlaced(v, &dmv_x[bmvtype == BMV_TYPE_BACKWARD], &dmv_y[bmvtype == BMV_TYPE_BACKWARD], &pred_flag[bmvtype == BMV_TYPE_BACKWARD]);
- }
- if (bmvtype == BMV_TYPE_INTERPOLATED && interpmvp) {
- get_mvdata_interlaced(v, &dmv_x[1], &dmv_y[1], &pred_flag[1]);
- }
- 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;
- }
- 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);
- mb_has_coeffs = !(idx_mbmode & 2);
- } else { // 4-MV
- if (fwd)
- bmvtype = BMV_TYPE_FORWARD;
- v->bmvtype = bmvtype;
- v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);
- for (i = 0; i < 6; i++) {
- if (i < 4) {
- dmv_x[0] = dmv_y[0] = pred_flag[0] = 0;
- dmv_x[1] = dmv_y[1] = pred_flag[1] = 0;
- val = ((v->fourmvbp >> (3 - i)) & 1);
- if (val) {
- get_mvdata_interlaced(v, &dmv_x[bmvtype == BMV_TYPE_BACKWARD],
- &dmv_y[bmvtype == BMV_TYPE_BACKWARD],
- &pred_flag[bmvtype == BMV_TYPE_BACKWARD]);
- }
- vc1_pred_b_mv_intfi(v, i, dmv_x, dmv_y, 0, pred_flag);
- vc1_mc_4mv_luma(v, i, bmvtype == BMV_TYPE_BACKWARD);
- } else if (i == 4)
- vc1_mc_4mv_chroma(v, bmvtype == BMV_TYPE_BACKWARD);
- }
- mb_has_coeffs = idx_mbmode & 1;
- }
- if (mb_has_coeffs)
- cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
- if (cbp) {
- GET_MQUANT();
- }
- s->current_picture.f.qscale_table[mb_pos] = mquant;
- if (!v->ttmbf && cbp) {
- ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
- }
- dst_idx = 0;
- for (i = 0; i < 6; i++) {
- s->dc_val[0][s->block_index[i]] = 0;
- dst_idx += i >> 2;
- val = ((cbp >> (5 - i)) & 1);
- off = (i & 4) ? 0 : (i & 1) * 8 + (i & 2) * 4 * s->linesize;
- if (val) {
- vc1_decode_p_block(v, s->block[i], i, mquant, ttmb,
- first_block, s->dest[dst_idx] + off,
- (i & 4) ? s->uvlinesize : s->linesize,
- (i & 4) && (s->flags & CODEC_FLAG_GRAY), NULL);
- if (!v->ttmbf && ttmb < 8)
- ttmb = -1;
- first_block = 0;
- }
- }
- }
-}
-
-/** Decode blocks of I-frame
- */
-static void vc1_decode_i_blocks(VC1Context *v)
-{
- int k, j;
- MpegEncContext *s = &v->s;
- int cbp, val;
- uint8_t *coded_val;
- int mb_pos;
-
- /* select codingmode used for VLC tables selection */
- switch (v->y_ac_table_index) {
- case 0:
- v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA;
- break;
- case 1:
- v->codingset = CS_HIGH_MOT_INTRA;
- break;
- case 2:
- v->codingset = CS_MID_RATE_INTRA;
- break;
- }
-
- switch (v->c_ac_table_index) {
- case 0:
- v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER;
- break;
- case 1:
- v->codingset2 = CS_HIGH_MOT_INTER;
- break;
- case 2:
- v->codingset2 = CS_MID_RATE_INTER;
- break;
- }
-
- /* Set DC scale - y and c use the same */
- s->y_dc_scale = s->y_dc_scale_table[v->pq];
- s->c_dc_scale = s->c_dc_scale_table[v->pq];
-
- //do frame decode
- s->mb_x = s->mb_y = 0;
- s->mb_intra = 1;
- s->first_slice_line = 1;
- for (s->mb_y = 0; s->mb_y < s->end_mb_y; s->mb_y++) {
- s->mb_x = 0;
- init_block_index(v);
- for (; s->mb_x < v->end_mb_x; s->mb_x++) {
- uint8_t *dst[6];
- ff_update_block_index(s);
- dst[0] = s->dest[0];
- dst[1] = dst[0] + 8;
- dst[2] = s->dest[0] + s->linesize * 8;
- dst[3] = dst[2] + 8;
- dst[4] = s->dest[1];
- dst[5] = s->dest[2];
- s->dsp.clear_blocks(s->block[0]);
- mb_pos = s->mb_x + s->mb_y * s->mb_width;
- s->current_picture.f.mb_type[mb_pos] = MB_TYPE_INTRA;
- s->current_picture.f.qscale_table[mb_pos] = v->pq;
- s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0;
- s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0;
-
- // do actual MB decoding and displaying
- cbp = get_vlc2(&v->s.gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);
- v->s.ac_pred = get_bits1(&v->s.gb);
-
- for (k = 0; k < 6; k++) {
- val = ((cbp >> (5 - k)) & 1);
-
- if (k < 4) {
- int pred = vc1_coded_block_pred(&v->s, k, &coded_val);
- val = val ^ pred;
- *coded_val = val;
- }
- cbp |= val << (5 - k);
-
- vc1_decode_i_block(v, s->block[k], k, val, (k < 4) ? v->codingset : v->codingset2);
-
- if (k > 3 && (s->flags & CODEC_FLAG_GRAY))
- continue;
- v->vc1dsp.vc1_inv_trans_8x8(s->block[k]);
- if (v->pq >= 9 && v->overlap) {
- if (v->rangeredfrm)
- for (j = 0; j < 64; j++)
- s->block[k][j] <<= 1;
- s->dsp.put_signed_pixels_clamped(s->block[k], dst[k], k & 4 ? s->uvlinesize : s->linesize);
- } else {
- if (v->rangeredfrm)
- for (j = 0; j < 64; j++)
- s->block[k][j] = (s->block[k][j] - 64) << 1;
- s->dsp.put_pixels_clamped(s->block[k], dst[k], k & 4 ? s->uvlinesize : s->linesize);
- }
- }
-
- if (v->pq >= 9 && v->overlap) {
- if (s->mb_x) {
- v->vc1dsp.vc1_h_overlap(s->dest[0], s->linesize);
- v->vc1dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize, s->linesize);
- if (!(s->flags & CODEC_FLAG_GRAY)) {
- v->vc1dsp.vc1_h_overlap(s->dest[1], s->uvlinesize);
- v->vc1dsp.vc1_h_overlap(s->dest[2], s->uvlinesize);
- }
- }
- v->vc1dsp.vc1_h_overlap(s->dest[0] + 8, s->linesize);
- v->vc1dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize);
- if (!s->first_slice_line) {
- v->vc1dsp.vc1_v_overlap(s->dest[0], s->linesize);
- v->vc1dsp.vc1_v_overlap(s->dest[0] + 8, s->linesize);
- if (!(s->flags & CODEC_FLAG_GRAY)) {
- v->vc1dsp.vc1_v_overlap(s->dest[1], s->uvlinesize);
- v->vc1dsp.vc1_v_overlap(s->dest[2], s->uvlinesize);
- }
- }
- v->vc1dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize, s->linesize);
- v->vc1dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize);
- }
- if (v->s.loop_filter) vc1_loop_filter_iblk(v, v->pq);
-
- if (get_bits_count(&s->gb) > v->bits) {
- ff_er_add_slice(s, 0, 0, s->mb_x, s->mb_y, ER_MB_ERROR);
- av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i\n",
- get_bits_count(&s->gb), v->bits);
- return;
- }
- }
- if (!v->s.loop_filter)
- ff_draw_horiz_band(s, s->mb_y * 16, 16);
- else if (s->mb_y)
- ff_draw_horiz_band(s, (s->mb_y - 1) * 16, 16);
-
- s->first_slice_line = 0;
- }
- if (v->s.loop_filter)
- ff_draw_horiz_band(s, (s->end_mb_y - 1) * 16, 16);
-
- /* This is intentionally mb_height and not end_mb_y - unlike in advanced
- * profile, these only differ are when decoding MSS2 rectangles. */
- ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, ER_MB_END);
-}
-
-/** Decode blocks of I-frame for advanced profile
- */
-static void vc1_decode_i_blocks_adv(VC1Context *v)
-{
- int k;
- MpegEncContext *s = &v->s;
- int cbp, val;
- uint8_t *coded_val;
- int mb_pos;
- int mquant = v->pq;
- int mqdiff;
- GetBitContext *gb = &s->gb;
-
- /* select codingmode used for VLC tables selection */
- switch (v->y_ac_table_index) {
- case 0:
- v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA;
- break;
- case 1:
- v->codingset = CS_HIGH_MOT_INTRA;
- break;
- case 2:
- v->codingset = CS_MID_RATE_INTRA;
- break;
- }
-
- switch (v->c_ac_table_index) {
- case 0:
- v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER;
- break;
- case 1:
- v->codingset2 = CS_HIGH_MOT_INTER;
- break;
- case 2:
- v->codingset2 = CS_MID_RATE_INTER;
- break;
- }
-
- // do frame decode
- s->mb_x = s->mb_y = 0;
- s->mb_intra = 1;
- s->first_slice_line = 1;
- s->mb_y = s->start_mb_y;
- if (s->start_mb_y) {
- s->mb_x = 0;
- init_block_index(v);
- memset(&s->coded_block[s->block_index[0] - s->b8_stride], 0,
- (1 + s->b8_stride) * sizeof(*s->coded_block));
- }
- for (; s->mb_y < s->end_mb_y; s->mb_y++) {
- s->mb_x = 0;
- init_block_index(v);
- for (;s->mb_x < s->mb_width; s->mb_x++) {
- int16_t (*block)[64] = v->block[v->cur_blk_idx];
- ff_update_block_index(s);
- s->dsp.clear_blocks(block[0]);
- mb_pos = s->mb_x + s->mb_y * s->mb_stride;
- s->current_picture.f.mb_type[mb_pos + v->mb_off] = MB_TYPE_INTRA;
- s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][0] = 0;
- s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][1] = 0;
-
- // do actual MB decoding and displaying
- if (v->fieldtx_is_raw)
- v->fieldtx_plane[mb_pos] = get_bits1(&v->s.gb);
- cbp = get_vlc2(&v->s.gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);
- if ( v->acpred_is_raw)
- v->s.ac_pred = get_bits1(&v->s.gb);
- else
- v->s.ac_pred = v->acpred_plane[mb_pos];
-
- if (v->condover == CONDOVER_SELECT && v->overflg_is_raw)
- v->over_flags_plane[mb_pos] = get_bits1(&v->s.gb);
-
- GET_MQUANT();
-
- s->current_picture.f.qscale_table[mb_pos] = mquant;
- /* Set DC scale - y and c use the same */
- s->y_dc_scale = s->y_dc_scale_table[mquant];
- s->c_dc_scale = s->c_dc_scale_table[mquant];
-
- for (k = 0; k < 6; k++) {
- val = ((cbp >> (5 - k)) & 1);
-
- if (k < 4) {
- int pred = vc1_coded_block_pred(&v->s, k, &coded_val);
- val = val ^ pred;
- *coded_val = val;
- }
- cbp |= val << (5 - k);
-
- v->a_avail = !s->first_slice_line || (k == 2 || k == 3);
- v->c_avail = !!s->mb_x || (k == 1 || k == 3);
-
- vc1_decode_i_block_adv(v, block[k], k, val,
- (k < 4) ? v->codingset : v->codingset2, mquant);
-
- if (k > 3 && (s->flags & CODEC_FLAG_GRAY))
- continue;
- v->vc1dsp.vc1_inv_trans_8x8(block[k]);
- }
-
- vc1_smooth_overlap_filter_iblk(v);
- vc1_put_signed_blocks_clamped(v);
- if (v->s.loop_filter) vc1_loop_filter_iblk_delayed(v, v->pq);
-
- if (get_bits_count(&s->gb) > v->bits) {
- // TODO: may need modification to handle slice coding
- ff_er_add_slice(s, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR);
- av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i\n",
- get_bits_count(&s->gb), v->bits);
- return;
- }
- }
- if (!v->s.loop_filter)
- ff_draw_horiz_band(s, s->mb_y * 16, 16);
- else if (s->mb_y)
- ff_draw_horiz_band(s, (s->mb_y-1) * 16, 16);
- s->first_slice_line = 0;
- }
-
- /* raw bottom MB row */
- s->mb_x = 0;
- init_block_index(v);
-
- for (;s->mb_x < s->mb_width; s->mb_x++) {
- ff_update_block_index(s);
- vc1_put_signed_blocks_clamped(v);
- if (v->s.loop_filter)
- vc1_loop_filter_iblk_delayed(v, v->pq);
- }
- if (v->s.loop_filter)
- ff_draw_horiz_band(s, (s->end_mb_y-1)*16, 16);
- ff_er_add_slice(s, 0, s->start_mb_y << v->field_mode, s->mb_width - 1,
- (s->end_mb_y << v->field_mode) - 1, ER_MB_END);
-}
-
-static void vc1_decode_p_blocks(VC1Context *v)
-{
- MpegEncContext *s = &v->s;
- int apply_loop_filter;
-
- /* select codingmode used for VLC tables selection */
- switch (v->c_ac_table_index) {
- case 0:
- v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA;
- break;
- case 1:
- v->codingset = CS_HIGH_MOT_INTRA;
- break;
- case 2:
- v->codingset = CS_MID_RATE_INTRA;
- break;
- }
-
- switch (v->c_ac_table_index) {
- case 0:
- v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER;
- break;
- case 1:
- v->codingset2 = CS_HIGH_MOT_INTER;
- break;
- case 2:
- v->codingset2 = CS_MID_RATE_INTER;
- break;
- }
-
- apply_loop_filter = s->loop_filter && !(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY);
- s->first_slice_line = 1;
- memset(v->cbp_base, 0, sizeof(v->cbp_base[0])*2*s->mb_stride);
- for (s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) {
- s->mb_x = 0;
- init_block_index(v);
- for (; s->mb_x < s->mb_width; s->mb_x++) {
- ff_update_block_index(s);
-
- if (v->fcm == ILACE_FIELD)
- vc1_decode_p_mb_intfi(v);
- else if (v->fcm == ILACE_FRAME)
- vc1_decode_p_mb_intfr(v);
- else vc1_decode_p_mb(v);
- if (s->mb_y != s->start_mb_y && apply_loop_filter && v->fcm == PROGRESSIVE)
- vc1_apply_p_loop_filter(v);
- if (get_bits_count(&s->gb) > v->bits || get_bits_count(&s->gb) < 0) {
- // TODO: may need modification to handle slice coding
- ff_er_add_slice(s, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR);
- av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i at %ix%i\n",
- get_bits_count(&s->gb), v->bits, s->mb_x, s->mb_y);
- return;
- }
- }
- memmove(v->cbp_base, v->cbp, sizeof(v->cbp_base[0]) * s->mb_stride);
- memmove(v->ttblk_base, v->ttblk, sizeof(v->ttblk_base[0]) * s->mb_stride);
- memmove(v->is_intra_base, v->is_intra, sizeof(v->is_intra_base[0]) * s->mb_stride);
- memmove(v->luma_mv_base, v->luma_mv, sizeof(v->luma_mv_base[0]) * s->mb_stride);
- if (s->mb_y != s->start_mb_y) ff_draw_horiz_band(s, (s->mb_y - 1) * 16, 16);
- s->first_slice_line = 0;
- }
- if (apply_loop_filter && v->fcm == PROGRESSIVE) {
- s->mb_x = 0;
- init_block_index(v);
- for (; s->mb_x < s->mb_width; s->mb_x++) {
- ff_update_block_index(s);
- vc1_apply_p_loop_filter(v);
- }
- }
- if (s->end_mb_y >= s->start_mb_y)
- ff_draw_horiz_band(s, (s->end_mb_y - 1) * 16, 16);
- ff_er_add_slice(s, 0, s->start_mb_y << v->field_mode, s->mb_width - 1,
- (s->end_mb_y << v->field_mode) - 1, ER_MB_END);
-}
-
-static void vc1_decode_b_blocks(VC1Context *v)
-{
- MpegEncContext *s = &v->s;
-
- /* select codingmode used for VLC tables selection */
- switch (v->c_ac_table_index) {
- case 0:
- v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA;
- break;
- case 1:
- v->codingset = CS_HIGH_MOT_INTRA;
- break;
- case 2:
- v->codingset = CS_MID_RATE_INTRA;
- break;
- }
-
- switch (v->c_ac_table_index) {
- case 0:
- v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER;
- break;
- case 1:
- v->codingset2 = CS_HIGH_MOT_INTER;
- break;
- case 2:
- v->codingset2 = CS_MID_RATE_INTER;
- break;
- }
-
- s->first_slice_line = 1;
- for (s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) {
- s->mb_x = 0;
- init_block_index(v);
- for (; s->mb_x < s->mb_width; s->mb_x++) {
- ff_update_block_index(s);
-
- if (v->fcm == ILACE_FIELD)
- vc1_decode_b_mb_intfi(v);
- else
- vc1_decode_b_mb(v);
- if (get_bits_count(&s->gb) > v->bits || get_bits_count(&s->gb) < 0) {
- // TODO: may need modification to handle slice coding
- ff_er_add_slice(s, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR);
- av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i at %ix%i\n",
- get_bits_count(&s->gb), v->bits, s->mb_x, s->mb_y);
- return;
- }
- if (v->s.loop_filter) vc1_loop_filter_iblk(v, v->pq);
- }
- if (!v->s.loop_filter)
- ff_draw_horiz_band(s, s->mb_y * 16, 16);
- else if (s->mb_y)
- ff_draw_horiz_band(s, (s->mb_y - 1) * 16, 16);
- s->first_slice_line = 0;
- }
- if (v->s.loop_filter)
- ff_draw_horiz_band(s, (s->end_mb_y - 1) * 16, 16);
- ff_er_add_slice(s, 0, s->start_mb_y << v->field_mode, s->mb_width - 1,
- (s->end_mb_y << v->field_mode) - 1, ER_MB_END);
-}
-
-static void vc1_decode_skip_blocks(VC1Context *v)
-{
- MpegEncContext *s = &v->s;
-
- ff_er_add_slice(s, 0, s->start_mb_y, s->mb_width - 1, s->end_mb_y - 1, ER_MB_END);
- s->first_slice_line = 1;
- for (s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) {
- s->mb_x = 0;
- init_block_index(v);
- ff_update_block_index(s);
- if (s->last_picture.f.data[0]) {
- 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_draw_horiz_band(s, s->mb_y * 16, 16);
- s->first_slice_line = 0;
- }
- s->pict_type = AV_PICTURE_TYPE_P;
-}
-
-void ff_vc1_decode_blocks(VC1Context *v)
-{
-
- v->s.esc3_level_length = 0;
- if (v->x8_type) {
- ff_intrax8_decode_picture(&v->x8, 2*v->pq + v->halfpq, v->pq * !v->pquantizer);
- } else {
- v->cur_blk_idx = 0;
- v->left_blk_idx = -1;
- v->topleft_blk_idx = 1;
- v->top_blk_idx = 2;
- switch (v->s.pict_type) {
- case AV_PICTURE_TYPE_I:
- if (v->profile == PROFILE_ADVANCED)
- vc1_decode_i_blocks_adv(v);
- else
- vc1_decode_i_blocks(v);
- break;
- case AV_PICTURE_TYPE_P:
- if (v->p_frame_skipped)
- vc1_decode_skip_blocks(v);
- else
- vc1_decode_p_blocks(v);
- break;
- case AV_PICTURE_TYPE_B:
- if (v->bi_type) {
- if (v->profile == PROFILE_ADVANCED)
- vc1_decode_i_blocks_adv(v);
- else
- vc1_decode_i_blocks(v);
- } else
- vc1_decode_b_blocks(v);
- break;
- }
- }
-}
-
-#if CONFIG_WMV3IMAGE_DECODER || CONFIG_VC1IMAGE_DECODER
-
-typedef struct {
- /**
- * Transform coefficients for both sprites in 16.16 fixed point format,
- * in the order they appear in the bitstream:
- * x scale
- * rotation 1 (unused)
- * x offset
- * rotation 2 (unused)
- * y scale
- * y offset
- * alpha
- */
- int coefs[2][7];
-
- int effect_type, effect_flag;
- int effect_pcount1, effect_pcount2; ///< amount of effect parameters stored in effect_params
- int effect_params1[15], effect_params2[10]; ///< effect parameters in 16.16 fixed point format
-} SpriteData;
-
-static inline int get_fp_val(GetBitContext* gb)
-{
- return (get_bits_long(gb, 30) - (1 << 29)) << 1;
-}
-
-static void vc1_sprite_parse_transform(GetBitContext* gb, int c[7])
-{
- c[1] = c[3] = 0;
-
- switch (get_bits(gb, 2)) {
- case 0:
- c[0] = 1 << 16;
- c[2] = get_fp_val(gb);
- c[4] = 1 << 16;
- break;
- case 1:
- c[0] = c[4] = get_fp_val(gb);
- c[2] = get_fp_val(gb);
- break;
- case 2:
- c[0] = get_fp_val(gb);
- c[2] = get_fp_val(gb);
- c[4] = get_fp_val(gb);
- break;
- case 3:
- c[0] = get_fp_val(gb);
- c[1] = get_fp_val(gb);
- c[2] = get_fp_val(gb);
- c[3] = get_fp_val(gb);
- c[4] = get_fp_val(gb);
- break;
- }
- c[5] = get_fp_val(gb);
- if (get_bits1(gb))
- c[6] = get_fp_val(gb);
- else
- c[6] = 1 << 16;
-}
-
-static void vc1_parse_sprites(VC1Context *v, GetBitContext* gb, SpriteData* sd)
-{
- AVCodecContext *avctx = v->s.avctx;
- int sprite, i;
-
- for (sprite = 0; sprite <= v->two_sprites; sprite++) {
- vc1_sprite_parse_transform(gb, sd->coefs[sprite]);
- if (sd->coefs[sprite][1] || sd->coefs[sprite][3])
- av_log_ask_for_sample(avctx, "Rotation coefficients are not zero");
- av_log(avctx, AV_LOG_DEBUG, sprite ? "S2:" : "S1:");
- for (i = 0; i < 7; i++)
- av_log(avctx, AV_LOG_DEBUG, " %d.%.3d",
- sd->coefs[sprite][i] / (1<<16),
- (abs(sd->coefs[sprite][i]) & 0xFFFF) * 1000 / (1 << 16));
- av_log(avctx, AV_LOG_DEBUG, "\n");
- }
-
- skip_bits(gb, 2);
- if (sd->effect_type = get_bits_long(gb, 30)) {
- switch (sd->effect_pcount1 = get_bits(gb, 4)) {
- case 7:
- vc1_sprite_parse_transform(gb, sd->effect_params1);
- break;
- case 14:
- vc1_sprite_parse_transform(gb, sd->effect_params1);
- vc1_sprite_parse_transform(gb, sd->effect_params1 + 7);
- break;
- default:
- for (i = 0; i < sd->effect_pcount1; i++)
- sd->effect_params1[i] = get_fp_val(gb);
- }
- if (sd->effect_type != 13 || sd->effect_params1[0] != sd->coefs[0][6]) {
- // effect 13 is simple alpha blending and matches the opacity above
- av_log(avctx, AV_LOG_DEBUG, "Effect: %d; params: ", sd->effect_type);
- for (i = 0; i < sd->effect_pcount1; i++)
- av_log(avctx, AV_LOG_DEBUG, " %d.%.2d",
- sd->effect_params1[i] / (1 << 16),
- (abs(sd->effect_params1[i]) & 0xFFFF) * 1000 / (1 << 16));
- av_log(avctx, AV_LOG_DEBUG, "\n");
- }
-
- sd->effect_pcount2 = get_bits(gb, 16);
- if (sd->effect_pcount2 > 10) {
- av_log(avctx, AV_LOG_ERROR, "Too many effect parameters\n");
- return;
- } else if (sd->effect_pcount2) {
- i = -1;
- av_log(avctx, AV_LOG_DEBUG, "Effect params 2: ");
- while (++i < sd->effect_pcount2) {
- sd->effect_params2[i] = get_fp_val(gb);
- av_log(avctx, AV_LOG_DEBUG, " %d.%.2d",
- sd->effect_params2[i] / (1 << 16),
- (abs(sd->effect_params2[i]) & 0xFFFF) * 1000 / (1 << 16));
- }
- av_log(avctx, AV_LOG_DEBUG, "\n");
- }
- }
- if (sd->effect_flag = get_bits1(gb))
- 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))
- av_log(avctx, AV_LOG_ERROR, "Buffer overrun\n");
- if (get_bits_count(gb) < gb->size_in_bits - 8)
- av_log(avctx, AV_LOG_WARNING, "Buffer not fully read\n");
-}
-
-static void vc1_draw_sprites(VC1Context *v, SpriteData* sd)
-{
- int i, plane, row, sprite;
- int sr_cache[2][2] = { { -1, -1 }, { -1, -1 } };
- uint8_t* src_h[2][2];
- int xoff[2], xadv[2], yoff[2], yadv[2], alpha;
- int ysub[2];
- MpegEncContext *s = &v->s;
-
- for (i = 0; i < 2; 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])
- xadv[i] = av_clip(xadv[i], 0, ((v->sprite_width<<16) - xoff[i] - 1) / v->output_width);
-
- yoff[i] = av_clip(sd->coefs[i][5], 0, v->sprite_height-1 << 16);
- yadv[i] = av_clip(sd->coefs[i][4], 0, ((v->sprite_height << 16) - yoff[i]) / v->output_height);
- }
- alpha = av_clip(sd->coefs[1][6], 0, (1<<16) - 1);
-
- for (plane = 0; plane < (s->flags&CODEC_FLAG_GRAY ? 1 : 3); plane++) {
- int width = v->output_width>>!!plane;
-
- for (row = 0; row < v->output_height>>!!plane; row++) {
- uint8_t *dst = v->sprite_output_frame.data[plane] +
- 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];
- 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];
- }
- next_line = FFMIN(yline + 1, (v->sprite_height >> !!plane) - 1) * iline;
- if (!(xoff[sprite] & 0xFFFF) && xadv[sprite] == 1 << 16) {
- src_h[sprite][0] = iplane + (xoff[sprite] >> 16) + yline * iline;
- if (ysub[sprite])
- src_h[sprite][1] = iplane + (xoff[sprite] >> 16) + next_line;
- } else {
- if (sr_cache[sprite][0] != yline) {
- if (sr_cache[sprite][1] == yline) {
- FFSWAP(uint8_t*, v->sr_rows[sprite][0], v->sr_rows[sprite][1]);
- FFSWAP(int, sr_cache[sprite][0], sr_cache[sprite][1]);
- } else {
- v->vc1dsp.sprite_h(v->sr_rows[sprite][0], iplane + yline * iline, xoff[sprite], xadv[sprite], width);
- sr_cache[sprite][0] = yline;
- }
- }
- if (ysub[sprite] && sr_cache[sprite][1] != yline + 1) {
- v->vc1dsp.sprite_h(v->sr_rows[sprite][1],
- iplane + next_line, xoff[sprite],
- xadv[sprite], width);
- sr_cache[sprite][1] = yline + 1;
- }
- src_h[sprite][0] = v->sr_rows[sprite][0];
- src_h[sprite][1] = v->sr_rows[sprite][1];
- }
- }
-
- if (!v->two_sprites) {
- if (ysub[0]) {
- v->vc1dsp.sprite_v_single(dst, src_h[0][0], src_h[0][1], ysub[0], width);
- } else {
- memcpy(dst, src_h[0][0], width);
- }
- } else {
- if (ysub[0] && ysub[1]) {
- v->vc1dsp.sprite_v_double_twoscale(dst, src_h[0][0], src_h[0][1], ysub[0],
- src_h[1][0], src_h[1][1], ysub[1], alpha, width);
- } else if (ysub[0]) {
- v->vc1dsp.sprite_v_double_onescale(dst, src_h[0][0], src_h[0][1], ysub[0],
- src_h[1][0], alpha, width);
- } else if (ysub[1]) {
- v->vc1dsp.sprite_v_double_onescale(dst, src_h[1][0], src_h[1][1], ysub[1],
- src_h[0][0], (1<<16)-1-alpha, width);
- } else {
- v->vc1dsp.sprite_v_double_noscale(dst, src_h[0][0], src_h[1][0], alpha, width);
- }
- }
- }
-
- if (!plane) {
- for (i = 0; i < 2; i++) {
- xoff[i] >>= 1;
- yoff[i] >>= 1;
- }
- }
-
- }
-}
-
-
-static int vc1_decode_sprites(VC1Context *v, GetBitContext* gb)
-{
- MpegEncContext *s = &v->s;
- AVCodecContext *avctx = s->avctx;
- SpriteData sd;
-
- vc1_parse_sprites(v, gb, &sd);
-
- 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])) {
- av_log(avctx, AV_LOG_WARNING, "Need two sprites, only got one\n");
- v->two_sprites = 0;
- }
-
- if (v->sprite_output_frame.data[0])
- avctx->release_buffer(avctx, &v->sprite_output_frame);
-
- v->sprite_output_frame.buffer_hints = FF_BUFFER_HINTS_VALID;
- v->sprite_output_frame.reference = 0;
- if (ff_get_buffer(avctx, &v->sprite_output_frame) < 0) {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return -1;
- }
-
- vc1_draw_sprites(v, &sd);
-
- return 0;
-}
-
-static void vc1_sprite_flush(AVCodecContext *avctx)
-{
- VC1Context *v = avctx->priv_data;
- MpegEncContext *s = &v->s;
- AVFrame *f = &s->current_picture.f;
- int plane, i;
-
- /* Windows Media Image codecs have a convergence interval of two keyframes.
- Since we can't enforce it, clear to black the missing sprite. This is
- wrong but it looks better than doing nothing. */
-
- if (f->data[0])
- for (plane = 0; plane < (s->flags&CODEC_FLAG_GRAY ? 1 : 3); plane++)
- for (i = 0; i < v->sprite_height>>!!plane; i++)
- memset(f->data[plane] + i * f->linesize[plane],
- plane ? 128 : 0, f->linesize[plane]);
-}
-
-#endif
-
-av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v)
-{
- MpegEncContext *s = &v->s;
- int i;
-
- /* 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->n_allocated_blks = s->mb_width + 2;
- v->block = av_malloc(sizeof(*v->block) * v->n_allocated_blks);
- v->cbp_base = av_malloc(sizeof(v->cbp_base[0]) * 2 * s->mb_stride);
- v->cbp = v->cbp_base + s->mb_stride;
- v->ttblk_base = av_malloc(sizeof(v->ttblk_base[0]) * 2 * s->mb_stride);
- 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 = 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[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);
-
- /* 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 = 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[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_last_base = av_mallocz(2 * (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2));
- v->mv_f_last[0] = v->mv_f_last_base + s->b8_stride + 1;
- v->mv_f_last[1] = v->mv_f_last[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_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);
-
- /* Init coded blocks info */
- if (v->profile == PROFILE_ADVANCED) {
-// if (alloc_bitplane(&v->over_flags_plane, s->mb_width, s->mb_height) < 0)
-// return -1;
-// if (alloc_bitplane(&v->ac_pred_plane, s->mb_width, s->mb_height) < 0)
-// return -1;
- }
-
- ff_intrax8_common_init(&v->x8,s);
-
- if (s->avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || s->avctx->codec_id == AV_CODEC_ID_VC1IMAGE) {
- for (i = 0; i < 4; i++)
- if (!(v->sr_rows[i >> 1][i & 1] = av_malloc(v->output_width))) return -1;
- }
-
- if (!v->mv_type_mb_plane || !v->direct_mb_plane || !v->acpred_plane || !v->over_flags_plane ||
- !v->block || !v->cbp_base || !v->ttblk_base || !v->is_intra_base || !v->luma_mv_base ||
- !v->mb_type_base)
- return -1;
-
- return 0;
-}
-
-av_cold void ff_vc1_init_transposed_scantables(VC1Context *v)
-{
- int i;
- for (i = 0; i < 64; i++) {
-#define transpose(x) ((x >> 3) | ((x & 7) << 3))
- v->zz_8x8[0][i] = transpose(ff_wmv1_scantable[0][i]);
- v->zz_8x8[1][i] = transpose(ff_wmv1_scantable[1][i]);
- v->zz_8x8[2][i] = transpose(ff_wmv1_scantable[2][i]);
- v->zz_8x8[3][i] = transpose(ff_wmv1_scantable[3][i]);
- v->zzi_8x8[i] = transpose(ff_vc1_adv_interlaced_8x8_zz[i]);
- }
- v->left_blk_sh = 0;
- v->top_blk_sh = 3;
-}
-
-/** Initialize a VC1/WMV3 decoder
- * @todo TODO: Handle VC-1 IDUs (Transport level?)
- * @todo TODO: Decypher remaining bits in extra_data
- */
-static av_cold int vc1_decode_init(AVCodecContext *avctx)
-{
- VC1Context *v = avctx->priv_data;
- MpegEncContext *s = &v->s;
- GetBitContext gb;
-
- /* save the container output size for WMImage */
- v->output_width = avctx->width;
- v->output_height = avctx->height;
-
- 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);
- else
- avctx->pix_fmt = AV_PIX_FMT_GRAY8;
- avctx->hwaccel = ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt);
- v->s.avctx = avctx;
- avctx->flags |= CODEC_FLAG_EMU_EDGE;
- v->s.flags |= CODEC_FLAG_EMU_EDGE;
-
- if (ff_vc1_init_common(v) < 0)
- return -1;
- // ensure static VLC tables are initialized
- if (ff_msmpeg4_decode_init(avctx) < 0)
- return -1;
- if (ff_vc1_decode_init_alloc_tables(v) < 0)
- return -1;
- // Hack to ensure the above functions will be called
- // again once we know all necessary settings.
- // That this is necessary might indicate a bug.
- 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;
-
- // looks like WMV3 has a sequence header stored in the extradata
- // advanced sequence header may be before the first frame
- // the last byte of the extradata is a version number, 1 for the
- // samples we can decode
-
- init_get_bits(&gb, avctx->extradata, avctx->extradata_size*8);
-
- if (ff_vc1_decode_sequence_header(avctx, v, &gb) < 0)
- return -1;
-
- count = avctx->extradata_size*8 - get_bits_count(&gb);
- if (count > 0) {
- av_log(avctx, AV_LOG_INFO, "Extra data: %i bits left, value: %X\n",
- count, get_bits(&gb, count));
- } else if (count < 0) {
- av_log(avctx, AV_LOG_INFO, "Read %i bits in overflow\n", -count);
- }
- } else { // VC1/WVC1/WVP2
- const uint8_t *start = avctx->extradata;
- uint8_t *end = avctx->extradata + avctx->extradata_size;
- const uint8_t *next;
- int size, buf2_size;
- uint8_t *buf2 = NULL;
- int seq_initialized = 0, ep_initialized = 0;
-
- if (avctx->extradata_size < 16) {
- av_log(avctx, AV_LOG_ERROR, "Extradata size too small: %i\n", avctx->extradata_size);
- return -1;
- }
-
- buf2 = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
- start = find_next_marker(start, end); // in WVC1 extradata first byte is its size, but can be 0 in mkv
- next = start;
- for (; next < end; start = next) {
- next = find_next_marker(start + 4, end);
- size = next - start - 4;
- if (size <= 0)
- continue;
- buf2_size = vc1_unescape_buffer(start + 4, size, buf2);
- init_get_bits(&gb, buf2, buf2_size * 8);
- switch (AV_RB32(start)) {
- case VC1_CODE_SEQHDR:
- if (ff_vc1_decode_sequence_header(avctx, v, &gb) < 0) {
- av_free(buf2);
- return -1;
- }
- seq_initialized = 1;
- break;
- case VC1_CODE_ENTRYPOINT:
- if (ff_vc1_decode_entry_point(avctx, v, &gb) < 0) {
- av_free(buf2);
- return -1;
- }
- ep_initialized = 1;
- break;
- }
- }
- av_free(buf2);
- if (!seq_initialized || !ep_initialized) {
- av_log(avctx, AV_LOG_ERROR, "Incomplete extradata\n");
- return -1;
- }
- v->res_sprite = (avctx->codec_id == AV_CODEC_ID_VC1IMAGE);
- }
-
- avctx->profile = v->profile;
- if (v->profile == PROFILE_ADVANCED)
- avctx->level = v->level;
-
- avctx->has_b_frames = !!avctx->max_b_frames;
-
- s->mb_width = (avctx->coded_width + 15) >> 4;
- s->mb_height = (avctx->coded_height + 15) >> 4;
-
- if (v->profile == PROFILE_ADVANCED || v->res_fasttx) {
- ff_vc1_init_transposed_scantables(v);
- } else {
- memcpy(v->zz_8x8, ff_wmv1_scantable, 4*64);
- v->left_blk_sh = 3;
- v->top_blk_sh = 0;
- }
-
- if (avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) {
- v->sprite_width = avctx->coded_width;
- v->sprite_height = avctx->coded_height;
-
- avctx->coded_width = avctx->width = v->output_width;
- avctx->coded_height = avctx->height = v->output_height;
-
- // prevent 16.16 overflows
- if (v->sprite_width > 1 << 14 ||
- v->sprite_height > 1 << 14 ||
- v->output_width > 1 << 14 ||
- v->output_height > 1 << 14) return -1;
- }
- return 0;
-}
-
-/** Close a VC1/WMV3 decoder
- * @warning Initial try at using MpegEncContext stuff
- */
-av_cold int ff_vc1_decode_end(AVCodecContext *avctx)
-{
- VC1Context *v = avctx->priv_data;
- int i;
-
- if ((avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || avctx->codec_id == AV_CODEC_ID_VC1IMAGE)
- && v->sprite_output_frame.data[0])
- avctx->release_buffer(avctx, &v->sprite_output_frame);
- for (i = 0; i < 4; i++)
- av_freep(&v->sr_rows[i >> 1][i & 1]);
- av_freep(&v->hrd_rate);
- av_freep(&v->hrd_buffer);
- ff_MPV_common_end(&v->s);
- av_freep(&v->mv_type_mb_plane);
- av_freep(&v->direct_mb_plane);
- av_freep(&v->forward_mb_plane);
- av_freep(&v->fieldtx_plane);
- av_freep(&v->acpred_plane);
- av_freep(&v->over_flags_plane);
- av_freep(&v->mb_type_base);
- av_freep(&v->blk_mv_type_base);
- av_freep(&v->mv_f_base);
- av_freep(&v->mv_f_last_base);
- av_freep(&v->mv_f_next_base);
- av_freep(&v->block);
- av_freep(&v->cbp_base);
- av_freep(&v->ttblk_base);
- av_freep(&v->is_intra_base); // FIXME use v->mb_type[]
- av_freep(&v->luma_mv_base);
- ff_intrax8_common_end(&v->x8);
- return 0;
-}
-
-
-/** Decode a VC1/WMV3 frame
- * @todo TODO: Handle VC-1 IDUs (Transport level?)
- */
-static int vc1_decode_frame(AVCodecContext *avctx, void *data,
- int *got_frame, AVPacket *avpkt)
-{
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size, n_slices = 0, i;
- VC1Context *v = avctx->priv_data;
- MpegEncContext *s = &v->s;
- AVFrame *pict = data;
- uint8_t *buf2 = NULL;
- const uint8_t *buf_start = buf, *buf_start_second_field = NULL;
- int mb_height, n_slices1=-1;
- struct {
- uint8_t *buf;
- GetBitContext gb;
- int mby_start;
- } *slices = NULL, *tmp;
-
- v->second_field = 0;
-
- if(s->flags & CODEC_FLAG_LOW_DELAY)
- s->low_delay = 1;
-
- /* no supplementary picture */
- 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) {
- *pict = s->next_picture_ptr->f;
- s->next_picture_ptr = NULL;
-
- *got_frame = 1;
- }
-
- return buf_size;
- }
-
- if (s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) {
- if (v->profile < PROFILE_ADVANCED)
- avctx->pix_fmt = AV_PIX_FMT_VDPAU_WMV3;
- else
- avctx->pix_fmt = AV_PIX_FMT_VDPAU_VC1;
- }
-
- //for advanced profile we may need to parse and unescape data
- if (avctx->codec_id == AV_CODEC_ID_VC1 || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) {
- int buf_size2 = 0;
- buf2 = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
-
- if (IS_MARKER(AV_RB32(buf))) { /* frame starts with marker and needs to be parsed */
- const uint8_t *start, *end, *next;
- int size;
-
- next = buf;
- for (start = buf, end = buf + buf_size; next < end; start = next) {
- next = find_next_marker(start + 4, end);
- size = next - start - 4;
- if (size <= 0) continue;
- switch (AV_RB32(start)) {
- case VC1_CODE_FRAME:
- if (avctx->hwaccel ||
- s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
- buf_start = start;
- buf_size2 = vc1_unescape_buffer(start + 4, size, buf2);
- break;
- case VC1_CODE_FIELD: {
- int buf_size3;
- 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));
- if (!tmp)
- goto err;
- slices = tmp;
- slices[n_slices].buf = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
- if (!slices[n_slices].buf)
- goto err;
- buf_size3 = vc1_unescape_buffer(start + 4, size,
- slices[n_slices].buf);
- init_get_bits(&slices[n_slices].gb, slices[n_slices].buf,
- 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;
- n_slices1 = n_slices - 1; // index of the last slice of the first field
- n_slices++;
- break;
- }
- case VC1_CODE_ENTRYPOINT: /* it should be before frame data */
- buf_size2 = vc1_unescape_buffer(start + 4, size, buf2);
- init_get_bits(&s->gb, buf2, buf_size2 * 8);
- ff_vc1_decode_entry_point(avctx, v, &s->gb);
- break;
- case VC1_CODE_SLICE: {
- int buf_size3;
- tmp = av_realloc(slices, sizeof(*slices) * (n_slices+1));
- if (!tmp)
- goto err;
- slices = tmp;
- slices[n_slices].buf = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
- if (!slices[n_slices].buf)
- goto err;
- buf_size3 = vc1_unescape_buffer(start + 4, size,
- slices[n_slices].buf);
- init_get_bits(&slices[n_slices].gb, slices[n_slices].buf,
- buf_size3 << 3);
- slices[n_slices].mby_start = get_bits(&slices[n_slices].gb, 9);
- n_slices++;
- break;
- }
- }
- }
- } else if (v->interlace && ((buf[0] & 0xC0) == 0xC0)) { /* WVC1 interlaced stores both fields divided by marker */
- const uint8_t *divider;
- int buf_size3;
-
- divider = find_next_marker(buf, buf + buf_size);
- if ((divider == (buf + buf_size)) || AV_RB32(divider) != VC1_CODE_FIELD) {
- av_log(avctx, AV_LOG_ERROR, "Error in WVC1 interlaced frame\n");
- goto err;
- } else { // found field marker, unescape second field
- 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));
- if (!tmp)
- goto err;
- slices = tmp;
- slices[n_slices].buf = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
- if (!slices[n_slices].buf)
- goto err;
- 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;
- n_slices1 = n_slices - 1;
- n_slices++;
- }
- buf_size2 = vc1_unescape_buffer(buf, divider - buf, buf2);
- } else {
- buf_size2 = vc1_unescape_buffer(buf, buf_size, buf2);
- }
- init_get_bits(&s->gb, buf2, buf_size2*8);
- } else
- init_get_bits(&s->gb, buf, buf_size*8);
-
- if (v->res_sprite) {
- v->new_sprite = !get_bits1(&s->gb);
- v->two_sprites = get_bits1(&s->gb);
- /* res_sprite means a Windows Media Image stream, AV_CODEC_ID_*IMAGE means
- we're using the sprite compositor. These are intentionally kept separate
- so you can get the raw sprites by using the wmv3 decoder for WMVP or
- the vc1 one for WVP2 */
- if (avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) {
- if (v->new_sprite) {
- // switch AVCodecContext parameters to those of the sprites
- avctx->width = avctx->coded_width = v->sprite_width;
- avctx->height = avctx->coded_height = v->sprite_height;
- } else {
- goto image;
- }
- }
- }
-
- if (s->context_initialized &&
- (s->width != avctx->coded_width ||
- s->height != avctx->coded_height)) {
- ff_vc1_decode_end(avctx);
- }
-
- if (!s->context_initialized) {
- if (ff_msmpeg4_decode_init(avctx) < 0 || ff_vc1_decode_init_alloc_tables(v) < 0)
- goto err;
-
- s->low_delay = !avctx->has_b_frames || v->res_sprite;
-
- if (v->profile == PROFILE_ADVANCED) {
- if(avctx->coded_width<=1 || avctx->coded_height<=1)
- goto err;
- s->h_edge_pos = avctx->coded_width;
- s->v_edge_pos = avctx->coded_height;
- }
- }
-
- /* We need to set current_picture_ptr before reading the header,
- * otherwise we cannot store anything in there. */
- if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) {
- int i = ff_find_unused_picture(s, 0);
- if (i < 0)
- goto err;
- s->current_picture_ptr = &s->picture[i];
- }
-
- // do parse frame header
- v->pic_header_flag = 0;
- v->first_pic_header_flag = 1;
- if (v->profile < PROFILE_ADVANCED) {
- if (ff_vc1_parse_frame_header(v, &s->gb) < 0) {
- goto err;
- }
- } else {
- if (ff_vc1_parse_frame_header_adv(v, &s->gb) < 0) {
- goto err;
- }
- }
- v->first_pic_header_flag = 0;
-
- if (avctx->debug & FF_DEBUG_PICT_INFO)
- av_log(v->s.avctx, AV_LOG_DEBUG, "pict_type: %c\n", av_get_picture_type_char(s->pict_type));
-
- if ((avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || avctx->codec_id == AV_CODEC_ID_VC1IMAGE)
- && s->pict_type != AV_PICTURE_TYPE_I) {
- av_log(v->s.avctx, AV_LOG_ERROR, "Sprite decoder: expected I-frame\n");
- goto err;
- }
-
- if ((s->mb_height >> v->field_mode) == 0) {
- av_log(v->s.avctx, AV_LOG_ERROR, "image too short\n");
- goto err;
- }
-
- // process pulldown flags
- 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;
- } else if (v->rptfrm) {
- // repeat frames
- s->current_picture_ptr->f.repeat_pict = v->rptfrm * 2;
- }
-
- // 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;
-
- /* 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;
- }
- 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) ||
- avctx->skip_frame >= AVDISCARD_ALL) {
- goto end;
- }
-
- if (s->next_p_frame_damaged) {
- if (s->pict_type == AV_PICTURE_TYPE_B)
- goto end;
- else
- s->next_p_frame_damaged = 0;
- }
-
- if (ff_MPV_frame_start(s, avctx) < 0) {
- goto err;
- }
-
- v->s.current_picture_ptr->f.interlaced_frame = (v->fcm != PROGRESSIVE);
- v->s.current_picture_ptr->f.top_field_first = v->tff;
-
- s->me.qpel_put = s->dsp.put_qpel_pixels_tab;
- s->me.qpel_avg = s->dsp.avg_qpel_pixels_tab;
-
- if ((CONFIG_VC1_VDPAU_DECODER)
- &&s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
- ff_vdpau_vc1_decode_picture(s, buf_start, (buf + buf_size) - buf_start);
- else if (avctx->hwaccel) {
- if (v->field_mode && buf_start_second_field) {
- // decode first field
- s->picture_structure = PICT_BOTTOM_FIELD - v->tff;
- if (avctx->hwaccel->start_frame(avctx, buf_start, buf_start_second_field - buf_start) < 0)
- goto err;
- if (avctx->hwaccel->decode_slice(avctx, buf_start, buf_start_second_field - buf_start) < 0)
- goto err;
- if (avctx->hwaccel->end_frame(avctx) < 0)
- goto err;
-
- // decode second field
- s->gb = slices[n_slices1 + 1].gb;
- s->picture_structure = PICT_TOP_FIELD + v->tff;
- v->second_field = 1;
- v->pic_header_flag = 0;
- if (ff_vc1_parse_frame_header_adv(v, &s->gb) < 0) {
- 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;
-
- if (avctx->hwaccel->start_frame(avctx, buf_start_second_field, (buf + buf_size) - buf_start_second_field) < 0)
- goto err;
- if (avctx->hwaccel->decode_slice(avctx, buf_start_second_field, (buf + buf_size) - buf_start_second_field) < 0)
- goto err;
- if (avctx->hwaccel->end_frame(avctx) < 0)
- goto err;
- } else {
- s->picture_structure = PICT_FRAME;
- if (avctx->hwaccel->start_frame(avctx, buf_start, (buf + buf_size) - buf_start) < 0)
- goto err;
- if (avctx->hwaccel->decode_slice(avctx, buf_start, (buf + buf_size) - buf_start) < 0)
- goto err;
- if (avctx->hwaccel->end_frame(avctx) < 0)
- goto err;
- }
- } else {
- if (v->fcm == ILACE_FRAME && s->pict_type == AV_PICTURE_TYPE_B)
- goto err; // This codepath is still incomplete thus it is disabled
-
- ff_er_frame_start(s);
-
- v->bits = buf_size * 8;
- v->end_mb_x = s->mb_width;
- if (v->field_mode) {
- uint8_t *tmp[2];
- 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;
- tmp[0] = v->mv_f_last[0];
- tmp[1] = v->mv_f_last[1];
- v->mv_f_last[0] = v->mv_f_next[0];
- v->mv_f_last[1] = v->mv_f_next[1];
- v->mv_f_next[0] = v->mv_f[0];
- v->mv_f_next[1] = v->mv_f[1];
- v->mv_f[0] = tmp[0];
- v->mv_f[1] = tmp[1];
- }
- mb_height = s->mb_height >> v->field_mode;
- for (i = 0; i <= n_slices; i++) {
- if (i > 0 && slices[i - 1].mby_start >= mb_height) {
- if (v->field_mode <= 0) {
- av_log(v->s.avctx, AV_LOG_ERROR, "Slice %d starts beyond "
- "picture boundary (%d >= %d)\n", i,
- slices[i - 1].mby_start, mb_height);
- continue;
- }
- v->second_field = 1;
- v->blocks_off = s->b8_stride * (s->mb_height&~1);
- v->mb_off = s->mb_stride * s->mb_height >> 1;
- } else {
- v->second_field = 0;
- v->blocks_off = 0;
- v->mb_off = 0;
- }
- if (i) {
- v->pic_header_flag = 0;
- if (v->field_mode && i == n_slices1 + 2) {
- if (ff_vc1_parse_frame_header_adv(v, &s->gb) < 0) {
- av_log(v->s.avctx, AV_LOG_ERROR, "Field header damaged\n");
- continue;
- }
- } else if (get_bits1(&s->gb)) {
- v->pic_header_flag = 1;
- if (ff_vc1_parse_frame_header_adv(v, &s->gb) < 0) {
- av_log(v->s.avctx, AV_LOG_ERROR, "Slice header damaged\n");
- continue;
- }
- }
- }
- s->start_mb_y = (i == 0) ? 0 : FFMAX(0, slices[i-1].mby_start % mb_height);
- if (!v->field_mode || v->second_field)
- s->end_mb_y = (i == n_slices ) ? mb_height : FFMIN(mb_height, slices[i].mby_start % mb_height);
- else {
- if (i >= n_slices) {
- av_log(v->s.avctx, AV_LOG_ERROR, "first field slice count too large\n");
- continue;
- }
- s->end_mb_y = (i <= n_slices1 + 1) ? mb_height : FFMIN(mb_height, slices[i].mby_start % mb_height);
- }
- if (s->end_mb_y <= s->start_mb_y) {
- av_log(v->s.avctx, AV_LOG_ERROR, "end mb y %d %d invalid\n", s->end_mb_y, s->start_mb_y);
- continue;
- }
- if (!v->p_frame_skipped && s->pict_type != AV_PICTURE_TYPE_I && !v->cbpcy_vlc) {
- av_log(v->s.avctx, AV_LOG_ERROR, "missing cbpcy_vlc\n");
- continue;
- }
- ff_vc1_decode_blocks(v);
- if (i != n_slices)
- s->gb = slices[i].gb;
- }
- if (v->field_mode) {
- v->second_field = 0;
- if (s->pict_type == AV_PICTURE_TYPE_B) {
- memcpy(v->mv_f_base, v->mv_f_next_base,
- 2 * (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2));
- }
- 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;
- }
- av_dlog(s->avctx, "Consumed %i/%i bits\n",
- get_bits_count(&s->gb), s->gb.size_in_bits);
-// if (get_bits_count(&s->gb) > buf_size * 8)
-// return -1;
- if(s->error_occurred && s->pict_type == AV_PICTURE_TYPE_B)
- goto err;
- if(!v->field_mode)
- ff_er_frame_end(s);
- }
-
- ff_MPV_frame_end(s);
-
- if (avctx->codec_id == AV_CODEC_ID_WMV3IMAGE || avctx->codec_id == AV_CODEC_ID_VC1IMAGE) {
-image:
- avctx->width = avctx->coded_width = v->output_width;
- avctx->height = avctx->coded_height = v->output_height;
- if (avctx->skip_frame >= AVDISCARD_NONREF)
- goto end;
-#if CONFIG_WMV3IMAGE_DECODER || CONFIG_VC1IMAGE_DECODER
- if (vc1_decode_sprites(v, &s->gb))
- goto err;
-#endif
- *pict = v->sprite_output_frame;
- *got_frame = 1;
- } else {
- if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
- *pict = s->current_picture_ptr->f;
- } else if (s->last_picture_ptr != NULL) {
- *pict = s->last_picture_ptr->f;
- }
- if (s->last_picture_ptr || s->low_delay) {
- *got_frame = 1;
- ff_print_debug_info(s, pict);
- }
- }
-
-end:
- av_free(buf2);
- for (i = 0; i < n_slices; i++)
- av_free(slices[i].buf);
- av_free(slices);
- return buf_size;
-
-err:
- av_free(buf2);
- for (i = 0; i < n_slices; i++)
- av_free(slices[i].buf);
- av_free(slices);
- return -1;
-}
-
-
-static const AVProfile profiles[] = {
- { FF_PROFILE_VC1_SIMPLE, "Simple" },
- { FF_PROFILE_VC1_MAIN, "Main" },
- { FF_PROFILE_VC1_COMPLEX, "Complex" },
- { FF_PROFILE_VC1_ADVANCED, "Advanced" },
- { FF_PROFILE_UNKNOWN },
-};
-
-AVCodec ff_vc1_decoder = {
- .name = "vc1",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_VC1,
- .priv_data_size = sizeof(VC1Context),
- .init = vc1_decode_init,
- .close = ff_vc1_decode_end,
- .decode = vc1_decode_frame,
- .flush = ff_mpeg_flush,
- .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY,
- .long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1"),
- .pix_fmts = ff_hwaccel_pixfmt_list_420,
- .profiles = NULL_IF_CONFIG_SMALL(profiles)
-};
-
-#if CONFIG_WMV3_DECODER
-AVCodec ff_wmv3_decoder = {
- .name = "wmv3",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_WMV3,
- .priv_data_size = sizeof(VC1Context),
- .init = vc1_decode_init,
- .close = ff_vc1_decode_end,
- .decode = vc1_decode_frame,
- .flush = ff_mpeg_flush,
- .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY,
- .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9"),
- .pix_fmts = ff_hwaccel_pixfmt_list_420,
- .profiles = NULL_IF_CONFIG_SMALL(profiles)
-};
-#endif
-
-#if CONFIG_WMV3_VDPAU_DECODER
-AVCodec ff_wmv3_vdpau_decoder = {
- .name = "wmv3_vdpau",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_WMV3,
- .priv_data_size = sizeof(VC1Context),
- .init = vc1_decode_init,
- .close = ff_vc1_decode_end,
- .decode = vc1_decode_frame,
- .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU,
- .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9 VDPAU"),
- .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_VDPAU_WMV3, AV_PIX_FMT_NONE },
- .profiles = NULL_IF_CONFIG_SMALL(profiles)
-};
-#endif
-
-#if CONFIG_VC1_VDPAU_DECODER
-AVCodec ff_vc1_vdpau_decoder = {
- .name = "vc1_vdpau",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_VC1,
- .priv_data_size = sizeof(VC1Context),
- .init = vc1_decode_init,
- .close = ff_vc1_decode_end,
- .decode = vc1_decode_frame,
- .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU,
- .long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1 VDPAU"),
- .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_VDPAU_VC1, AV_PIX_FMT_NONE },
- .profiles = NULL_IF_CONFIG_SMALL(profiles)
-};
-#endif
-
-#if CONFIG_WMV3IMAGE_DECODER
-AVCodec ff_wmv3image_decoder = {
- .name = "wmv3image",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_WMV3IMAGE,
- .priv_data_size = sizeof(VC1Context),
- .init = vc1_decode_init,
- .close = ff_vc1_decode_end,
- .decode = vc1_decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .flush = vc1_sprite_flush,
- .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9 Image"),
- .pix_fmts = ff_pixfmt_list_420
-};
-#endif
-
-#if CONFIG_VC1IMAGE_DECODER
-AVCodec ff_vc1image_decoder = {
- .name = "vc1image",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_VC1IMAGE,
- .priv_data_size = sizeof(VC1Context),
- .init = vc1_decode_init,
- .close = ff_vc1_decode_end,
- .decode = vc1_decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .flush = vc1_sprite_flush,
- .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9 Image v2"),
- .pix_fmts = ff_pixfmt_list_420
-};
-#endif
-
-// ==> Start patch MPC
-#include "vc1_dxva.c"
-// ==> End patch MPC
diff --git a/src/thirdparty/ffmpeg/libavcodec/vc1dsp.c b/src/thirdparty/ffmpeg/libavcodec/vc1dsp.c
deleted file mode 100644
index 031232fb6..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vc1dsp.c
+++ /dev/null
@@ -1,868 +0,0 @@
-/*
- * VC-1 and WMV3 decoder - DSP functions
- * Copyright (c) 2006 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
- */
-
-/**
-* @file
- * VC-1 and WMV3 decoder
- *
- */
-
-#include "libavutil/avassert.h"
-#include "libavutil/common.h"
-#include "h264chroma.h"
-#include "rnd_avg.h"
-#include "vc1dsp.h"
-
-
-/** 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];
- 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++;
- rnd = !rnd;
- }
-}
-
-/** 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];
- 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;
- }
-}
-
-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];
- d1 = a - d;
- d2 = a - d + b - c;
-
- top[48] = ((a << 3) - d1 + rnd1) >> 3;
- top[56] = ((b << 3) - d2 + rnd2) >> 3;
- bottom[0] = ((c << 3) + d2 + rnd1) >> 3;
- bottom[8] = ((d << 3) + d1 + rnd2) >> 3;
-
- bottom++;
- top++;
- rnd2 = 7 - rnd2;
- rnd1 = 7 - rnd1;
- }
-}
-
-static void vc1_h_s_overlap_c(int16_t *left, int16_t *right)
-{
- int i;
- 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];
- d1 = a - d;
- d2 = a - d + b - c;
-
- left[6] = ((a << 3) - d1 + rnd1) >> 3;
- left[7] = ((b << 3) - d2 + rnd2) >> 3;
- right[0] = ((c << 3) + d2 + rnd1) >> 3;
- right[1] = ((d << 3) + d1 + rnd2) >> 3;
-
- right += 8;
- left += 8;
- rnd2 = 7 - rnd2;
- rnd1 = 7 - rnd1;
- }
-}
-
-/**
- * VC-1 in-loop deblocking filter for one line
- * @param src source block type
- * @param stride block stride
- * @param pq block quantizer
- * @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;
- 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];
- int clip_sign = clip >> 31;
- 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_sign ^= a0_sign;
-
- if( d_sign ^ clip_sign )
- d = 0;
- 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);
- }
- return 1;
- }
- }
- }
- return 0;
-}
-
-/**
- * VC-1 in-loop deblocking filter
- * @param src source block type
- * @param step distance between horizontally adjacent elements
- * @param stride distance between vertically adjacent elements
- * @param len edge length to filter (4 or 8 pixels)
- * @param pq block quantizer
- * @see 8.6
- */
-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);
- }
- src += step * 4;
- }
-}
-
-static void vc1_v_loop_filter4_c(uint8_t *src, int stride, int pq)
-{
- vc1_loop_filter(src, 1, stride, 4, pq);
-}
-
-static void vc1_h_loop_filter4_c(uint8_t *src, int stride, int pq)
-{
- vc1_loop_filter(src, stride, 1, 4, pq);
-}
-
-static void vc1_v_loop_filter8_c(uint8_t *src, int stride, int pq)
-{
- vc1_loop_filter(src, 1, stride, 8, pq);
-}
-
-static void vc1_h_loop_filter8_c(uint8_t *src, int stride, int pq)
-{
- vc1_loop_filter(src, stride, 1, 8, pq);
-}
-
-static void vc1_v_loop_filter16_c(uint8_t *src, int stride, int pq)
-{
- vc1_loop_filter(src, 1, stride, 16, pq);
-}
-
-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
-*/
-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++){
- dest[0] = av_clip_uint8(dest[0] + dc);
- dest[1] = av_clip_uint8(dest[1] + dc);
- dest[2] = av_clip_uint8(dest[2] + dc);
- dest[3] = av_clip_uint8(dest[3] + dc);
- dest[4] = av_clip_uint8(dest[4] + dc);
- 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 += linesize;
- }
-}
-
-static void vc1_inv_trans_8x8_c(int16_t block[64])
-{
- int i;
- 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++){
- t1 = 12 * (src[ 0] + src[32]) + 4;
- t2 = 12 * (src[ 0] - src[32]) + 4;
- t3 = 16 * src[16] + 6 * src[48];
- t4 = 6 * src[16] - 16 * src[48];
-
- t5 = t1 + t3;
- t6 = t2 + t4;
- t7 = t2 - t4;
- t8 = t1 - t3;
-
- t1 = 16 * src[ 8] + 15 * src[24] + 9 * src[40] + 4 * src[56];
- t2 = 15 * src[ 8] - 4 * src[24] - 16 * src[40] - 9 * src[56];
- 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];
-
- dst[0] = (t5 + t1) >> 3;
- dst[1] = (t6 + t2) >> 3;
- dst[2] = (t7 + t3) >> 3;
- dst[3] = (t8 + t4) >> 3;
- dst[4] = (t8 - t4) >> 3;
- dst[5] = (t7 - t3) >> 3;
- dst[6] = (t6 - t2) >> 3;
- dst[7] = (t5 - t1) >> 3;
-
- src += 1;
- dst += 8;
- }
-
- src = temp;
- dst = block;
- 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];
- t4 = 6 * src[16] - 16 * src[48];
-
- t5 = t1 + t3;
- t6 = t2 + t4;
- t7 = t2 - t4;
- t8 = t1 - t3;
-
- t1 = 16 * src[ 8] + 15 * src[24] + 9 * src[40] + 4 * src[56];
- t2 = 15 * src[ 8] - 4 * src[24] - 16 * src[40] - 9 * src[56];
- 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];
-
- dst[ 0] = (t5 + t1) >> 7;
- dst[ 8] = (t6 + t2) >> 7;
- dst[16] = (t7 + t3) >> 7;
- dst[24] = (t8 + t4) >> 7;
- dst[32] = (t8 - t4 + 1) >> 7;
- dst[40] = (t7 - t3 + 1) >> 7;
- dst[48] = (t6 - t2 + 1) >> 7;
- dst[56] = (t5 - t1 + 1) >> 7;
-
- src++;
- dst++;
- }
-}
-
-/** 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 = (17 * dc + 64) >> 7;
- 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);
- dest[3] = av_clip_uint8(dest[3] + dc);
- dest[4] = av_clip_uint8(dest[4] + dc);
- 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 += linesize;
- }
-}
-
-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;
- int16_t *src, *dst;
-
- src = block;
- dst = block;
- 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];
- t4 = 6 * src[2] - 16 * src[6];
-
- t5 = t1 + t3;
- t6 = t2 + t4;
- t7 = t2 - t4;
- t8 = t1 - t3;
-
- t1 = 16 * src[1] + 15 * src[3] + 9 * src[5] + 4 * src[7];
- t2 = 15 * src[1] - 4 * src[3] - 16 * src[5] - 9 * src[7];
- t3 = 9 * src[1] - 16 * src[3] + 4 * src[5] + 15 * src[7];
- t4 = 4 * src[1] - 9 * src[3] + 15 * src[5] - 16 * src[7];
-
- dst[0] = (t5 + t1) >> 3;
- dst[1] = (t6 + t2) >> 3;
- dst[2] = (t7 + t3) >> 3;
- dst[3] = (t8 + t4) >> 3;
- dst[4] = (t8 - t4) >> 3;
- dst[5] = (t7 - t3) >> 3;
- dst[6] = (t6 - t2) >> 3;
- dst[7] = (t5 - t1) >> 3;
-
- src += 8;
- dst += 8;
- }
-
- src = block;
- 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));
-
- src ++;
- dest++;
- }
-}
-
-/** 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++){
- dest[0] = av_clip_uint8(dest[0] + dc);
- dest[1] = av_clip_uint8(dest[1] + dc);
- dest[2] = av_clip_uint8(dest[2] + dc);
- dest[3] = av_clip_uint8(dest[3] + dc);
- dest += linesize;
- }
-}
-
-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;
- int16_t *src, *dst;
-
- src = block;
- dst = block;
- 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];
- t4 = 22 * src[3] - 10 * src[1];
-
- dst[0] = (t1 + t3) >> 3;
- dst[1] = (t2 - t4) >> 3;
- dst[2] = (t2 + t4) >> 3;
- dst[3] = (t1 - t3) >> 3;
-
- src += 8;
- dst += 8;
- }
-
- src = block;
- 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];
- t4 = 6 * src[16] - 16 * src[48];
-
- t5 = t1 + t3;
- t6 = t2 + t4;
- t7 = t2 - t4;
- t8 = t1 - t3;
-
- t1 = 16 * src[ 8] + 15 * src[24] + 9 * src[40] + 4 * src[56];
- t2 = 15 * src[ 8] - 4 * src[24] - 16 * src[40] - 9 * src[56];
- 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));
-
- src ++;
- dest++;
- }
-}
-
-/** 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++){
- dest[0] = av_clip_uint8(dest[0] + dc);
- dest[1] = av_clip_uint8(dest[1] + dc);
- dest[2] = av_clip_uint8(dest[2] + dc);
- dest[3] = av_clip_uint8(dest[3] + dc);
- dest += linesize;
- }
-}
-
-static void vc1_inv_trans_4x4_c(uint8_t *dest, int linesize, int16_t *block)
-{
- int i;
- register int t1,t2,t3,t4;
- int16_t *src, *dst;
-
- src = block;
- dst = block;
- 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];
- t4 = 22 * src[3] - 10 * src[1];
-
- dst[0] = (t1 + t3) >> 3;
- dst[1] = (t2 - t4) >> 3;
- dst[2] = (t2 + t4) >> 3;
- dst[3] = (t1 - t3) >> 3;
-
- src += 8;
- dst += 8;
- }
-
- 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];
-
- 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 ++;
- 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 */ \
-}
-
-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)
-{
- 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;
- case 2: // 1/2 shift
- return (-src[-stride] + 9*src[0] + 9*src[stride] - 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 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, int 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 void OPNAME ## pixels8x8_c(uint8_t *block, const uint8_t *pixels, int line_size, int rnd){\
- int i;\
- for(i=0; i<8; i++){\
- OP4(*(uint32_t*)(block ), AV_RN32(pixels ));\
- OP4(*(uint32_t*)(block+4), AV_RN32(pixels+4));\
- pixels+=line_size;\
- block +=line_size;\
- }\
-}
-
-#define op_put(a, b) a = av_clip_uint8(b)
-#define op_avg(a, b) a = (a + av_clip_uint8(b) + 1) >> 1
-#define op4_avg(a, b) a = rnd_avg32(a, b)
-#define op4_put(a, b) a = b
-
-VC1_MSPEL_MC(op_put, op4_put, put_)
-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, int 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, int stride, int rnd) { \
- avg_vc1_mspel_mc(dst, src, stride, a, b, rnd); \
-}
-
-PUT_VC1_MSPEL(1, 0)
-PUT_VC1_MSPEL(2, 0)
-PUT_VC1_MSPEL(3, 0)
-
-PUT_VC1_MSPEL(0, 1)
-PUT_VC1_MSPEL(1, 1)
-PUT_VC1_MSPEL(2, 1)
-PUT_VC1_MSPEL(3, 1)
-
-PUT_VC1_MSPEL(0, 2)
-PUT_VC1_MSPEL(1, 2)
-PUT_VC1_MSPEL(2, 2)
-PUT_VC1_MSPEL(3, 2)
-
-PUT_VC1_MSPEL(0, 3)
-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);
- 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;
- }
-}
-
-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);
-
- 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;
- }
-}
-
-#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;
- }
-}
-
-#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)
-{
- while (count--) {
- int a = src[(offset >> 16) ];
- int b = src[(offset >> 16) + 1];
- *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)
-{
- int a1, b1, a2, b2;
- while (width--) {
- a1 = *src1a++;
- if (scaled) {
- b1 = *src1b++;
- a1 = a1 + ((b1 - a1) * offset1 >> 16);
- }
- if (two_sprites) {
- a2 = *src2a++;
- if (scaled > 1) {
- b2 = *src2b++;
- a2 = a2 + ((b2 - a2) * offset2 >> 16);
- }
- a1 = a1 + ((a2 - a1) * alpha >> 16);
- }
- *dst++ = a1;
- }
-}
-
-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)
-{
- 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)
-{
- 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)
-{
- sprite_v_template(dst, src1a, src1b, offset1, 1, src2a, src2b, offset2, alpha, 2, width);
-}
-
-#endif
-
-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->put_no_rnd_vc1_chroma_pixels_tab[1] = put_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_v_double_onescale = sprite_v_double_onescale_c;
- dsp->sprite_v_double_twoscale = sprite_v_double_twoscale_c;
-#endif
-
- if (HAVE_ALTIVEC)
- ff_vc1dsp_init_altivec(dsp);
- if (ARCH_X86)
- ff_vc1dsp_init_x86(dsp);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/vc1dsp.h b/src/thirdparty/ffmpeg/libavcodec/vc1dsp.h
deleted file mode 100644
index c1be8ac6f..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vc1dsp.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * VC-1 and WMV3 decoder - DSP functions
- * Copyright (c) 2006 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
- */
-
-/**
- * @file
- * VC-1 and WMV3 decoder
- *
- */
-
-#ifndef AVCODEC_VC1DSP_H
-#define AVCODEC_VC1DSP_H
-
-#include "dsputil.h"
-#include "h264chroma.h"
-
-typedef void (*vc1op_pixels_func)(uint8_t *block/*align width (8 or 16)*/, const uint8_t *pixels/*align 1*/, int line_size, int h);
-
-typedef struct VC1DSPContext {
- /* vc1 functions */
- void (*vc1_inv_trans_8x8)(int16_t *b);
- void (*vc1_inv_trans_8x4)(uint8_t *dest, int line_size, int16_t *block);
- void (*vc1_inv_trans_4x8)(uint8_t *dest, int line_size, int16_t *block);
- void (*vc1_inv_trans_4x4)(uint8_t *dest, int line_size, int16_t *block);
- void (*vc1_inv_trans_8x8_dc)(uint8_t *dest, int line_size, int16_t *block);
- void (*vc1_inv_trans_8x4_dc)(uint8_t *dest, int line_size, int16_t *block);
- void (*vc1_inv_trans_4x8_dc)(uint8_t *dest, int line_size, int16_t *block);
- void (*vc1_inv_trans_4x4_dc)(uint8_t *dest, int line_size, int16_t *block);
- void (*vc1_v_overlap)(uint8_t *src, int stride);
- void (*vc1_h_overlap)(uint8_t *src, int stride);
- void (*vc1_v_s_overlap)(int16_t *top, int16_t *bottom);
- void (*vc1_h_s_overlap)(int16_t *left, int16_t *right);
- void (*vc1_v_loop_filter4)(uint8_t *src, int stride, int pq);
- void (*vc1_h_loop_filter4)(uint8_t *src, int stride, int pq);
- void (*vc1_v_loop_filter8)(uint8_t *src, int stride, int pq);
- void (*vc1_h_loop_filter8)(uint8_t *src, int stride, int pq);
- void (*vc1_v_loop_filter16)(uint8_t *src, int stride, int pq);
- void (*vc1_h_loop_filter16)(uint8_t *src, int stride, int pq);
-
- /* 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];
-
- /* This is really one func used in VC-1 decoding */
- h264_chroma_mc_func put_no_rnd_vc1_chroma_pixels_tab[3];
- h264_chroma_mc_func avg_no_rnd_vc1_chroma_pixels_tab[3];
-
- /* Windows Media Image functions */
- void (*sprite_h)(uint8_t *dst, const uint8_t *src, int offset, int advance, int count);
- void (*sprite_v_single)(uint8_t *dst, const uint8_t *src1a, const uint8_t *src1b, int offset, int width);
- void (*sprite_v_double_noscale)(uint8_t *dst, const uint8_t *src1a, const uint8_t *src2a, int alpha, int width);
- void (*sprite_v_double_onescale)(uint8_t *dst, const uint8_t *src1a, const uint8_t *src1b, int offset1,
- const uint8_t *src2a, int alpha, int width);
- 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);
-} VC1DSPContext;
-
-void ff_vc1dsp_init(VC1DSPContext* c);
-void ff_vc1dsp_init_altivec(VC1DSPContext* c);
-void ff_vc1dsp_init_x86(VC1DSPContext* dsp);
-
-#endif /* AVCODEC_VC1DSP_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/vdpau_internal.h b/src/thirdparty/ffmpeg/libavcodec/vdpau_internal.h
deleted file mode 100644
index 32023b8c4..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vdpau_internal.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Video Decode and Presentation API for UNIX (VDPAU) is used for
- * HW decode acceleration for MPEG-1/2, H.264 and VC-1.
- *
- * Copyright (C) 2008 NVIDIA
- *
- * 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_VDPAU_INTERNAL_H
-#define AVCODEC_VDPAU_INTERNAL_H
-
-#include <stdint.h>
-#include "mpegvideo.h"
-
-/** Extract VdpVideoSurface from a Picture */
-static inline uintptr_t ff_vdpau_get_surface_id(Picture *pic)
-{
- return (uintptr_t)pic->f.data[3];
-}
-
-int ff_vdpau_common_start_frame(AVCodecContext *avctx,
- const uint8_t *buffer, uint32_t size);
-int ff_vdpau_common_end_frame(AVCodecContext *avctx);
-int ff_vdpau_add_buffer(AVCodecContext *avctx,
- const uint8_t *buf, uint32_t buf_size);
-
-
-void ff_vdpau_add_data_chunk(MpegEncContext *s, const uint8_t *buf,
- int buf_size);
-
-void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf,
- int buf_size, int slice_count);
-
-void ff_vdpau_h264_picture_start(MpegEncContext *s);
-void ff_vdpau_h264_set_reference_frames(MpegEncContext *s);
-void ff_vdpau_h264_picture_complete(MpegEncContext *s);
-
-void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf,
- int buf_size);
-
-void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf,
- int buf_size);
-
-#endif /* AVCODEC_VDPAU_INTERNAL_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/version.h b/src/thirdparty/ffmpeg/libavcodec/version.h
deleted file mode 100644
index 5a364183f..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/version.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- *
- * 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_VERSION_H
-#define AVCODEC_VERSION_H
-
-/**
- * @file
- * @ingroup libavc
- * Libavcodec version macros.
- */
-
-#include "libavutil/avutil.h"
-
-#define LIBAVCODEC_VERSION_MAJOR 54
-#define LIBAVCODEC_VERSION_MINOR 91
-#define LIBAVCODEC_VERSION_MICRO 103
-
-#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
- LIBAVCODEC_VERSION_MINOR, \
- LIBAVCODEC_VERSION_MICRO)
-#define LIBAVCODEC_VERSION AV_VERSION(LIBAVCODEC_VERSION_MAJOR, \
- LIBAVCODEC_VERSION_MINOR, \
- LIBAVCODEC_VERSION_MICRO)
-#define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT
-
-#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
-
-/**
- * FF_API_* defines may be placed below to indicate public API that will be
- * dropped at a future version bump. The defines themselves are not part of
- * the public API and may change, break or disappear at any time.
- */
-
-#ifndef FF_API_REQUEST_CHANNELS
-#define FF_API_REQUEST_CHANNELS (LIBAVCODEC_VERSION_MAJOR < 55)
-#endif
-#ifndef FF_API_ALLOC_CONTEXT
-#define FF_API_ALLOC_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 55)
-#endif
-#ifndef FF_API_AVCODEC_OPEN
-#define FF_API_AVCODEC_OPEN (LIBAVCODEC_VERSION_MAJOR < 55)
-#endif
-#ifndef FF_API_OLD_DECODE_AUDIO
-#define FF_API_OLD_DECODE_AUDIO (LIBAVCODEC_VERSION_MAJOR < 55)
-#endif
-#ifndef FF_API_OLD_TIMECODE
-#define FF_API_OLD_TIMECODE (LIBAVCODEC_VERSION_MAJOR < 55)
-#endif
-
-#ifndef FF_API_OLD_ENCODE_AUDIO
-#define FF_API_OLD_ENCODE_AUDIO (LIBAVCODEC_VERSION_MAJOR < 55)
-#endif
-#ifndef FF_API_OLD_ENCODE_VIDEO
-#define FF_API_OLD_ENCODE_VIDEO (LIBAVCODEC_VERSION_MAJOR < 55)
-#endif
-#ifndef FF_API_MPV_GLOBAL_OPTS
-#define FF_API_MPV_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 55)
-#endif
-#ifndef FF_API_COLOR_TABLE_ID
-#define FF_API_COLOR_TABLE_ID (LIBAVCODEC_VERSION_MAJOR < 55)
-#endif
-#ifndef FF_API_INTER_THRESHOLD
-#define FF_API_INTER_THRESHOLD (LIBAVCODEC_VERSION_MAJOR < 55)
-#endif
-#ifndef FF_API_SUB_ID
-#define FF_API_SUB_ID (LIBAVCODEC_VERSION_MAJOR < 55)
-#endif
-#ifndef FF_API_DSP_MASK
-#define FF_API_DSP_MASK (LIBAVCODEC_VERSION_MAJOR < 55)
-#endif
-#ifndef FF_API_FIND_BEST_PIX_FMT
-#define FF_API_FIND_BEST_PIX_FMT (LIBAVCODEC_VERSION_MAJOR < 55)
-#endif
-#ifndef FF_API_CODEC_ID
-#define FF_API_CODEC_ID (LIBAVCODEC_VERSION_MAJOR < 55)
-#endif
-#ifndef FF_API_VDA_ASYNC
-#define FF_API_VDA_ASYNC (LIBAVCODEC_VERSION_MAJOR < 55)
-#endif
-#ifndef FF_API_AVCODEC_RESAMPLE
-#define FF_API_AVCODEC_RESAMPLE (LIBAVCODEC_VERSION_MAJOR < 55)
-#endif
-#ifndef FF_API_LIBMPEG2
-#define FF_API_LIBMPEG2 (LIBAVCODEC_VERSION_MAJOR < 55)
-#endif
-#ifndef FF_API_MMI
-#define FF_API_MMI (LIBAVCODEC_VERSION_MAJOR < 55)
-#endif
-#ifndef FF_API_IDCT
-#define FF_API_IDCT (LIBAVCODEC_VERSION_MAJOR < 55)
-#endif
-
-#endif /* AVCODEC_VERSION_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/videodsp.c b/src/thirdparty/ffmpeg/libavcodec/videodsp.c
deleted file mode 100644
index f91bac3a4..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/videodsp.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2012 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/avassert.h"
-#include "libavutil/common.h"
-#include "videodsp.h"
-
-#define BIT_DEPTH 8
-#include "videodsp_template.c"
-#undef BIT_DEPTH
-
-#define BIT_DEPTH 16
-#include "videodsp_template.c"
-#undef BIT_DEPTH
-
-static void just_return(uint8_t *buf, ptrdiff_t stride, int h)
-{
-}
-
-void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
-{
- ctx->prefetch = just_return;
- if (bpc <= 8) {
- ctx->emulated_edge_mc = ff_emulated_edge_mc_8;
- } else {
- ctx->emulated_edge_mc = ff_emulated_edge_mc_16;
- }
-
- if (ARCH_ARM)
- ff_videodsp_init_arm(ctx, bpc);
- if (ARCH_PPC)
- ff_videodsp_init_ppc(ctx, bpc);
- if (ARCH_X86)
- ff_videodsp_init_x86(ctx, bpc);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/videodsp.h b/src/thirdparty/ffmpeg/libavcodec/videodsp.h
deleted file mode 100644
index e39772077..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/videodsp.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2012 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
- */
-
-/**
- * @file
- * Core video DSP helper functions
- */
-
-#ifndef AVCODEC_VIDEODSP_H
-#define AVCODEC_VIDEODSP_H
-
-#include <stddef.h>
-#include <stdint.h>
-
-#define EMULATED_EDGE(depth) \
-void ff_emulated_edge_mc_ ## depth (uint8_t *buf, const uint8_t *src, ptrdiff_t linesize,\
- int block_w, int block_h,\
- int src_x, int src_y, int w, int h);
-
-EMULATED_EDGE(8)
-EMULATED_EDGE(16)
-
-typedef struct VideoDSPContext {
- /**
- * Copy a rectangular area of samples to a temporary buffer and replicate
- * the border samples.
- *
- * @param buf destination buffer
- * @param src source buffer
- * @param linesize number of bytes between 2 vertically adjacent samples
- * in both the source and destination buffers
- * @param block_w width of block
- * @param block_h height of block
- * @param src_x x coordinate of the top left sample of the block in the
- * source buffer
- * @param src_y y coordinate of the top left sample of the block in the
- * source buffer
- * @param w width of the source buffer
- * @param h height of the source buffer
- */
- void (*emulated_edge_mc)(uint8_t *buf, const uint8_t *src,
- ptrdiff_t linesize, int block_w, int block_h,
- int src_x, int src_y, int w, int h);
-
- /**
- * Prefetch memory into cache (if supported by hardware).
- *
- * @buf pointer to buffer to prefetch memory from
- * @stride distance between two lines of buf (in bytes)
- * @h number of lines to prefetch
- */
- void (*prefetch)(uint8_t *buf, ptrdiff_t stride, int h);
-} VideoDSPContext;
-
-void ff_videodsp_init(VideoDSPContext *ctx, int bpc);
-
-/* for internal use only (i.e. called by ff_videodsp_init() */
-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);
-
-#endif /* AVCODEC_VIDEODSP_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/videodsp_template.c b/src/thirdparty/ffmpeg/libavcodec/videodsp_template.c
deleted file mode 100644
index 44f6a4d63..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/videodsp_template.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 2002-2012 Michael Niedermayer
- * Copyright (C) 2012 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 "bit_depth_template.c"
-void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src,
- ptrdiff_t linesize_arg,
- int block_w, int block_h,
- int src_x, int src_y, int w, int h)
-{
- int x, y;
- int start_y, start_x, end_y, end_x;
- int linesize = linesize_arg;
-
- if (!w || !h)
- return;
-
- if (src_y >= h) {
- src -= src_y * linesize;
- src += (h - 1) * linesize;
- src_y = h - 1;
- } else if (src_y <= -block_h) {
- src -= src_y * linesize;
- src += (1 - block_h) * linesize;
- src_y = 1 - block_h;
- }
- if (src_x >= w) {
- src += (w - 1 - src_x) * sizeof(pixel);
- src_x = w - 1;
- } else if (src_x <= -block_w) {
- src += (1 - block_w - src_x) * sizeof(pixel);
- src_x = 1 - block_w;
- }
-
- start_y = FFMAX(0, -src_y);
- start_x = FFMAX(0, -src_x);
- end_y = FFMIN(block_h, h-src_y);
- end_x = FFMIN(block_w, w-src_x);
- av_assert2(start_y < end_y && block_h);
- av_assert2(start_x < end_x && block_w);
-
- w = end_x - start_x;
- src += start_y * linesize + start_x * sizeof(pixel);
- buf += start_x * sizeof(pixel);
-
- // top
- for (y = 0; y < start_y; y++) {
- memcpy(buf, src, w * sizeof(pixel));
- buf += linesize;
- }
-
- // copy existing part
- for (; y < end_y; y++) {
- memcpy(buf, src, w * sizeof(pixel));
- src += linesize;
- buf += linesize;
- }
-
- // bottom
- src -= linesize;
- for (; y < block_h; y++) {
- memcpy(buf, src, w * sizeof(pixel));
- buf += linesize;
- }
-
- buf -= block_h * linesize + start_x * sizeof(pixel);
- while (block_h--) {
- pixel *bufp = (pixel *) buf;
-
- // left
- for(x = 0; x < start_x; x++) {
- bufp[x] = bufp[start_x];
- }
-
- // right
- for (x = end_x; x < block_w; x++) {
- bufp[x] = bufp[end_x - 1];
- }
- buf += linesize;
- }
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/vmnc.c b/src/thirdparty/ffmpeg/libavcodec/vmnc.c
deleted file mode 100644
index eb39fc923..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vmnc.c
+++ /dev/null
@@ -1,533 +0,0 @@
-/*
- * VMware Screen Codec (VMnc) decoder
- * Copyright (c) 2006 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
- */
-
-/**
- * @file
- * VMware Screen Codec (VMnc) decoder
- * As Alex Beregszaszi discovered, this is effectively RFB data dump
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "libavutil/common.h"
-#include "libavutil/intreadwrite.h"
-#include "avcodec.h"
-
-enum EncTypes {
- MAGIC_WMVd = 0x574D5664,
- MAGIC_WMVe,
- MAGIC_WMVf,
- MAGIC_WMVg,
- MAGIC_WMVh,
- MAGIC_WMVi,
- MAGIC_WMVj
-};
-
-enum HexTile_Flags {
- HT_RAW = 1, // tile is raw
- HT_BKG = 2, // background color is present
- HT_FG = 4, // foreground color is present
- HT_SUB = 8, // subrects are present
- HT_CLR = 16 // each subrect has own color
-};
-
-/*
- * Decoder context
- */
-typedef struct VmncContext {
- AVCodecContext *avctx;
- AVFrame pic;
-
- int bpp;
- int bpp2;
- int bigendian;
- uint8_t pal[768];
- int width, height;
-
- /* cursor data */
- int cur_w, cur_h;
- int cur_x, cur_y;
- int cur_hx, cur_hy;
- uint8_t* curbits, *curmask;
- uint8_t* screendta;
-} VmncContext;
-
-/* read pixel value from stream */
-static av_always_inline int vmnc_get_pixel(const uint8_t* buf, int bpp, int be) {
- switch(bpp * 2 + be) {
- case 2:
- case 3: return *buf;
- case 4: return AV_RL16(buf);
- case 5: return AV_RB16(buf);
- case 8: return AV_RL32(buf);
- case 9: return AV_RB32(buf);
- default: return 0;
- }
-}
-
-static void load_cursor(VmncContext *c, const uint8_t *src)
-{
- int i, j, p;
- const int bpp = c->bpp2;
- uint8_t *dst8 = c->curbits;
- uint16_t *dst16 = (uint16_t*)c->curbits;
- uint32_t *dst32 = (uint32_t*)c->curbits;
-
- for(j = 0; j < c->cur_h; j++) {
- for(i = 0; i < c->cur_w; i++) {
- p = vmnc_get_pixel(src, bpp, c->bigendian);
- src += bpp;
- if(bpp == 1) *dst8++ = p;
- if(bpp == 2) *dst16++ = p;
- if(bpp == 4) *dst32++ = p;
- }
- }
- dst8 = c->curmask;
- dst16 = (uint16_t*)c->curmask;
- dst32 = (uint32_t*)c->curmask;
- for(j = 0; j < c->cur_h; j++) {
- for(i = 0; i < c->cur_w; i++) {
- p = vmnc_get_pixel(src, bpp, c->bigendian);
- src += bpp;
- if(bpp == 1) *dst8++ = p;
- if(bpp == 2) *dst16++ = p;
- if(bpp == 4) *dst32++ = p;
- }
- }
-}
-
-static void put_cursor(uint8_t *dst, int stride, VmncContext *c, int dx, int dy)
-{
- int i, j;
- int w, h, x, y;
- w = c->cur_w;
- if(c->width < c->cur_x + c->cur_w) w = c->width - c->cur_x;
- h = c->cur_h;
- if(c->height < c->cur_y + c->cur_h) h = c->height - c->cur_y;
- x = c->cur_x;
- y = c->cur_y;
- if(x < 0) {
- w += x;
- x = 0;
- }
- if(y < 0) {
- h += y;
- y = 0;
- }
-
- if((w < 1) || (h < 1)) return;
- dst += x * c->bpp2 + y * stride;
-
- if(c->bpp2 == 1) {
- uint8_t* cd = c->curbits, *msk = c->curmask;
- for(j = 0; j < h; j++) {
- for(i = 0; i < w; i++)
- dst[i] = (dst[i] & cd[i]) ^ msk[i];
- msk += c->cur_w;
- cd += c->cur_w;
- dst += stride;
- }
- } else if(c->bpp2 == 2) {
- uint16_t* cd = (uint16_t*)c->curbits, *msk = (uint16_t*)c->curmask;
- uint16_t* dst2;
- for(j = 0; j < h; j++) {
- dst2 = (uint16_t*)dst;
- for(i = 0; i < w; i++)
- dst2[i] = (dst2[i] & cd[i]) ^ msk[i];
- msk += c->cur_w;
- cd += c->cur_w;
- dst += stride;
- }
- } else if(c->bpp2 == 4) {
- uint32_t* cd = (uint32_t*)c->curbits, *msk = (uint32_t*)c->curmask;
- uint32_t* dst2;
- for(j = 0; j < h; j++) {
- dst2 = (uint32_t*)dst;
- for(i = 0; i < w; i++)
- dst2[i] = (dst2[i] & cd[i]) ^ msk[i];
- msk += c->cur_w;
- cd += c->cur_w;
- dst += stride;
- }
- }
-}
-
-/* fill rectangle with given color */
-static av_always_inline void paint_rect(uint8_t *dst, int dx, int dy, int w, int h, int color, int bpp, int stride)
-{
- int i, j;
- dst += dx * bpp + dy * stride;
- if(bpp == 1){
- for(j = 0; j < h; j++) {
- memset(dst, color, w);
- dst += stride;
- }
- }else if(bpp == 2){
- uint16_t* dst2;
- for(j = 0; j < h; j++) {
- dst2 = (uint16_t*)dst;
- for(i = 0; i < w; i++) {
- *dst2++ = color;
- }
- dst += stride;
- }
- }else if(bpp == 4){
- uint32_t* dst2;
- for(j = 0; j < h; j++) {
- dst2 = (uint32_t*)dst;
- for(i = 0; i < w; i++) {
- dst2[i] = color;
- }
- dst += stride;
- }
- }
-}
-
-static av_always_inline void paint_raw(uint8_t *dst, int w, int h, const uint8_t* src, int bpp, int be, int stride)
-{
- int i, j, p;
- for(j = 0; j < h; j++) {
- for(i = 0; i < w; i++) {
- p = vmnc_get_pixel(src, bpp, be);
- src += bpp;
- switch(bpp){
- case 1:
- dst[i] = p;
- break;
- case 2:
- ((uint16_t*)dst)[i] = p;
- break;
- case 4:
- ((uint32_t*)dst)[i] = p;
- break;
- }
- }
- dst += stride;
- }
-}
-
-static int decode_hextile(VmncContext *c, uint8_t* dst, const uint8_t* src, int ssize, int w, int h, int stride)
-{
- int i, j, k;
- int bg = 0, fg = 0, rects, color, flags, xy, wh;
- const int bpp = c->bpp2;
- uint8_t *dst2;
- int bw = 16, bh = 16;
- const uint8_t *ssrc=src;
-
- for(j = 0; j < h; j += 16) {
- dst2 = dst;
- bw = 16;
- if(j + 16 > h) bh = h - j;
- for(i = 0; i < w; i += 16, dst2 += 16 * bpp) {
- if(src - ssrc >= ssize) {
- av_log(c->avctx, AV_LOG_ERROR, "Premature end of data!\n");
- return -1;
- }
- if(i + 16 > w) bw = w - i;
- flags = *src++;
- if(flags & HT_RAW) {
- if(src - ssrc > ssize - bw * bh * bpp) {
- av_log(c->avctx, AV_LOG_ERROR, "Premature end of data!\n");
- return -1;
- }
- paint_raw(dst2, bw, bh, src, bpp, c->bigendian, stride);
- src += bw * bh * bpp;
- } else {
- if(flags & HT_BKG) {
- bg = vmnc_get_pixel(src, bpp, c->bigendian); src += bpp;
- }
- if(flags & HT_FG) {
- fg = vmnc_get_pixel(src, bpp, c->bigendian); src += bpp;
- }
- rects = 0;
- if(flags & HT_SUB)
- rects = *src++;
- color = !!(flags & HT_CLR);
-
- paint_rect(dst2, 0, 0, bw, bh, bg, bpp, stride);
-
- if(src - ssrc > ssize - rects * (color * bpp + 2)) {
- av_log(c->avctx, AV_LOG_ERROR, "Premature end of data!\n");
- return -1;
- }
- for(k = 0; k < rects; k++) {
- if(color) {
- fg = vmnc_get_pixel(src, bpp, c->bigendian); src += bpp;
- }
- xy = *src++;
- wh = *src++;
- paint_rect(dst2, xy >> 4, xy & 0xF, (wh>>4)+1, (wh & 0xF)+1, fg, bpp, stride);
- }
- }
- }
- dst += stride * 16;
- }
- return src - ssrc;
-}
-
-static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
- AVPacket *avpkt)
-{
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
- VmncContext * const c = avctx->priv_data;
- uint8_t *outptr;
- const uint8_t *src = buf;
- int dx, dy, w, h, depth, enc, chunks, res, size_left;
-
- c->pic.reference = 3;
- c->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
- if(avctx->reget_buffer(avctx, &c->pic) < 0){
- av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
- return -1;
- }
-
- c->pic.key_frame = 0;
- c->pic.pict_type = AV_PICTURE_TYPE_P;
-
- //restore screen after cursor
- if(c->screendta) {
- int i;
- w = c->cur_w;
- if(c->width < c->cur_x + w) w = c->width - c->cur_x;
- h = c->cur_h;
- if(c->height < c->cur_y + h) h = c->height - c->cur_y;
- dx = c->cur_x;
- if(dx < 0) {
- w += dx;
- dx = 0;
- }
- dy = c->cur_y;
- if(dy < 0) {
- h += dy;
- dy = 0;
- }
- if((w > 0) && (h > 0)) {
- outptr = c->pic.data[0] + dx * c->bpp2 + dy * c->pic.linesize[0];
- for(i = 0; i < h; i++) {
- memcpy(outptr, c->screendta + i * c->cur_w * c->bpp2, w * c->bpp2);
- outptr += c->pic.linesize[0];
- }
- }
- }
- src += 2;
- chunks = AV_RB16(src); src += 2;
- while(chunks--) {
- if(buf_size - (src - buf) < 12) {
- av_log(avctx, AV_LOG_ERROR, "Premature end of data!\n");
- return -1;
- }
- dx = AV_RB16(src); src += 2;
- dy = AV_RB16(src); src += 2;
- w = AV_RB16(src); src += 2;
- h = AV_RB16(src); src += 2;
- enc = AV_RB32(src); src += 4;
- outptr = c->pic.data[0] + dx * c->bpp2 + dy * c->pic.linesize[0];
- size_left = buf_size - (src - buf);
- switch(enc) {
- case MAGIC_WMVd: // cursor
- if (w*(int64_t)h*c->bpp2 > INT_MAX/2 - 2) {
- av_log(avctx, AV_LOG_ERROR, "dimensions too large\n");
- return AVERROR_INVALIDDATA;
- }
- if(size_left < 2 + w * h * c->bpp2 * 2) {
- av_log(avctx, AV_LOG_ERROR, "Premature end of data! (need %i got %i)\n", 2 + w * h * c->bpp2 * 2, size_left);
- return -1;
- }
- src += 2;
- c->cur_w = w;
- c->cur_h = h;
- c->cur_hx = dx;
- c->cur_hy = dy;
- if((c->cur_hx > c->cur_w) || (c->cur_hy > c->cur_h)) {
- av_log(avctx, AV_LOG_ERROR, "Cursor hot spot is not in image: %ix%i of %ix%i cursor size\n", c->cur_hx, c->cur_hy, c->cur_w, c->cur_h);
- c->cur_hx = c->cur_hy = 0;
- }
- c->curbits = av_realloc(c->curbits, c->cur_w * c->cur_h * c->bpp2);
- c->curmask = av_realloc(c->curmask, c->cur_w * c->cur_h * c->bpp2);
- c->screendta = av_realloc(c->screendta, c->cur_w * c->cur_h * c->bpp2);
- load_cursor(c, src);
- src += w * h * c->bpp2 * 2;
- break;
- case MAGIC_WMVe: // unknown
- src += 2;
- break;
- case MAGIC_WMVf: // update cursor position
- c->cur_x = dx - c->cur_hx;
- c->cur_y = dy - c->cur_hy;
- break;
- case MAGIC_WMVg: // unknown
- src += 10;
- break;
- case MAGIC_WMVh: // unknown
- src += 4;
- break;
- case MAGIC_WMVi: // ServerInitialization struct
- c->pic.key_frame = 1;
- c->pic.pict_type = AV_PICTURE_TYPE_I;
- depth = *src++;
- if(depth != c->bpp) {
- av_log(avctx, AV_LOG_INFO, "Depth mismatch. Container %i bpp, Frame data: %i bpp\n", c->bpp, depth);
- }
- src++;
- c->bigendian = *src++;
- if(c->bigendian & (~1)) {
- av_log(avctx, AV_LOG_INFO, "Invalid header: bigendian flag = %i\n", c->bigendian);
- return -1;
- }
- //skip the rest of pixel format data
- src += 13;
- break;
- case MAGIC_WMVj: // unknown
- src += 2;
- break;
- case 0x00000000: // raw rectangle data
- if((dx + w > c->width) || (dy + h > c->height)) {
- av_log(avctx, AV_LOG_ERROR, "Incorrect frame size: %ix%i+%ix%i of %ix%i\n", w, h, dx, dy, c->width, c->height);
- return -1;
- }
- if(size_left < w * h * c->bpp2) {
- av_log(avctx, AV_LOG_ERROR, "Premature end of data! (need %i got %i)\n", w * h * c->bpp2, size_left);
- return -1;
- }
- paint_raw(outptr, w, h, src, c->bpp2, c->bigendian, c->pic.linesize[0]);
- src += w * h * c->bpp2;
- break;
- case 0x00000005: // HexTile encoded rectangle
- if((dx + w > c->width) || (dy + h > c->height)) {
- av_log(avctx, AV_LOG_ERROR, "Incorrect frame size: %ix%i+%ix%i of %ix%i\n", w, h, dx, dy, c->width, c->height);
- return -1;
- }
- res = decode_hextile(c, outptr, src, size_left, w, h, c->pic.linesize[0]);
- if(res < 0)
- return -1;
- src += res;
- break;
- default:
- av_log(avctx, AV_LOG_ERROR, "Unsupported block type 0x%08X\n", enc);
- chunks = 0; // leave chunks decoding loop
- }
- }
- if(c->screendta){
- int i;
- //save screen data before painting cursor
- w = c->cur_w;
- if(c->width < c->cur_x + w) w = c->width - c->cur_x;
- h = c->cur_h;
- if(c->height < c->cur_y + h) h = c->height - c->cur_y;
- dx = c->cur_x;
- if(dx < 0) {
- w += dx;
- dx = 0;
- }
- dy = c->cur_y;
- if(dy < 0) {
- h += dy;
- dy = 0;
- }
- if((w > 0) && (h > 0)) {
- outptr = c->pic.data[0] + dx * c->bpp2 + dy * c->pic.linesize[0];
- for(i = 0; i < h; i++) {
- memcpy(c->screendta + i * c->cur_w * c->bpp2, outptr, w * c->bpp2);
- outptr += c->pic.linesize[0];
- }
- outptr = c->pic.data[0];
- put_cursor(outptr, c->pic.linesize[0], c, c->cur_x, c->cur_y);
- }
- }
- *got_frame = 1;
- *(AVFrame*)data = c->pic;
-
- /* always report that the buffer was completely consumed */
- return buf_size;
-}
-
-
-
-/*
- *
- * Init VMnc decoder
- *
- */
-static av_cold int decode_init(AVCodecContext *avctx)
-{
- VmncContext * const c = avctx->priv_data;
-
- c->avctx = avctx;
-
- c->width = avctx->width;
- c->height = avctx->height;
-
- c->bpp = avctx->bits_per_coded_sample;
- c->bpp2 = c->bpp/8;
- avcodec_get_frame_defaults(&c->pic);
-
- switch(c->bpp){
- case 8:
- avctx->pix_fmt = AV_PIX_FMT_PAL8;
- break;
- case 16:
- avctx->pix_fmt = AV_PIX_FMT_RGB555;
- break;
- case 32:
- avctx->pix_fmt = AV_PIX_FMT_RGB32;
- break;
- default:
- av_log(avctx, AV_LOG_ERROR, "Unsupported bitdepth %i\n", c->bpp);
- return AVERROR_INVALIDDATA;
- }
-
- return 0;
-}
-
-
-
-/*
- *
- * Uninit VMnc decoder
- *
- */
-static av_cold int decode_end(AVCodecContext *avctx)
-{
- VmncContext * const c = avctx->priv_data;
-
- if (c->pic.data[0])
- avctx->release_buffer(avctx, &c->pic);
-
- av_free(c->curbits);
- av_free(c->curmask);
- av_free(c->screendta);
- return 0;
-}
-
-AVCodec ff_vmnc_decoder = {
- .name = "vmnc",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_VMNC,
- .priv_data_size = sizeof(VmncContext),
- .init = decode_init,
- .close = decode_end,
- .decode = decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("VMware Screen Codec / VMware Video"),
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/vorbis.c b/src/thirdparty/ffmpeg/libavcodec/vorbis.c
deleted file mode 100644
index 60aac1725..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vorbis.c
+++ /dev/null
@@ -1,236 +0,0 @@
-/**
- * @file
- * Common code for Vorbis I encoder and decoder
- * @author Denes Balatoni ( dbalatoni programozo hu )
- *
- * 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
- * Common code for Vorbis I encoder and decoder
- * @author Denes Balatoni ( dbalatoni programozo hu )
- */
-
-#define BITSTREAM_READER_LE
-#include "avcodec.h"
-#include "get_bits.h"
-
-#include "vorbis.h"
-
-
-/* Helper functions */
-
-// x^(1/n)
-unsigned int ff_vorbis_nth_root(unsigned int x, unsigned int n)
-{
- unsigned int ret = 0, i, j;
-
- do {
- ++ret;
- for (i = 0, j = ret; i < n - 1; i++)
- j *= ret;
- } while (j <= x);
-
- return ret - 1;
-}
-
-// Generate vlc codes from vorbis huffman code lengths
-
-// the two bits[p] > 32 checks should be redundant, all calling code should
-// already ensure that, but since it allows overwriting the stack it seems
-// reasonable to check redundantly.
-int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num)
-{
- uint32_t exit_at_level[33] = { 404 };
-
- unsigned i, j, p, code;
-
-#ifdef DEBUG
- GetBitContext gb;
-#endif
-
- for (p = 0; (bits[p] == 0) && (p < num); ++p)
- ;
- if (p == num)
- return 0;
-
- codes[p] = 0;
- if (bits[p] > 32)
- return 1;
- for (i = 0; i < bits[p]; ++i)
- exit_at_level[i+1] = 1 << i;
-
-#ifdef DEBUG
- av_log(NULL, AV_LOG_INFO, " %u. of %u code len %d code %d - ", p, num, bits[p], codes[p]);
- init_get_bits(&gb, (uint8_t *)&codes[p], bits[p]);
- for (i = 0; i < bits[p]; ++i)
- av_log(NULL, AV_LOG_INFO, "%s", get_bits1(&gb) ? "1" : "0");
- av_log(NULL, AV_LOG_INFO, "\n");
-#endif
-
- ++p;
-
- for (; p < num; ++p) {
- if (bits[p] > 32)
- return 1;
- if (bits[p] == 0)
- continue;
- // find corresponding exit(node which the tree can grow further from)
- for (i = bits[p]; i > 0; --i)
- if (exit_at_level[i])
- break;
- if (!i) // overspecified tree
- return 1;
- code = exit_at_level[i];
- exit_at_level[i] = 0;
- // construct code (append 0s to end) and introduce new exits
- for (j = i + 1 ;j <= bits[p]; ++j)
- exit_at_level[j] = code + (1 << (j - 1));
- codes[p] = code;
-
-#ifdef DEBUG
- av_log(NULL, AV_LOG_INFO, " %d. code len %d code %d - ", p, bits[p], codes[p]);
- init_get_bits(&gb, (uint8_t *)&codes[p], bits[p]);
- for (i = 0; i < bits[p]; ++i)
- av_log(NULL, AV_LOG_INFO, "%s", get_bits1(&gb) ? "1" : "0");
- av_log(NULL, AV_LOG_INFO, "\n");
-#endif
-
- }
-
- //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 0;
-}
-
-int ff_vorbis_ready_floor1_list(AVCodecContext *avccontext,
- vorbis_floor1_entry *list, int values)
-{
- int i;
- list[0].sort = 0;
- list[1].sort = 1;
- for (i = 2; i < values; i++) {
- int j;
- list[i].low = 0;
- list[i].high = 1;
- list[i].sort = i;
- for (j = 2; j < i; j++) {
- int tmp = list[j].x;
- if (tmp < list[i].x) {
- if (tmp > list[list[i].low].x)
- list[i].low = j;
- } else {
- if (tmp < list[list[i].high].x)
- list[i].high = j;
- }
- }
- }
- for (i = 0; i < values - 1; i++) {
- int j;
- for (j = i + 1; j < values; j++) {
- if (list[i].x == list[j].x) {
- av_log(avccontext, AV_LOG_ERROR,
- "Duplicate value found in floor 1 X coordinates\n");
- return AVERROR_INVALIDDATA;
- }
- if (list[list[i].sort].x > list[list[j].sort].x) {
- int tmp = list[i].sort;
- list[i].sort = list[j].sort;
- list[j].sort = tmp;
- }
- }
- }
- return 0;
-}
-
-static inline void render_line_unrolled(intptr_t x, int y, int x1,
- intptr_t sy, int ady, int adx,
- float *buf)
-{
- int err = -adx;
- x -= x1 - 1;
- buf += x1 - 1;
- while (++x < 0) {
- err += ady;
- if (err >= 0) {
- err += ady - adx;
- y += sy;
- buf[x++] = ff_vorbis_floor1_inverse_db_table[av_clip_uint8(y)];
- }
- buf[x] = ff_vorbis_floor1_inverse_db_table[av_clip_uint8(y)];
- }
- if (x <= 0) {
- if (err + ady >= 0)
- y += sy;
- buf[x] = ff_vorbis_floor1_inverse_db_table[av_clip_uint8(y)];
- }
-}
-
-static void render_line(int x0, int y0, int x1, int y1, float *buf)
-{
- int dy = y1 - y0;
- int adx = x1 - x0;
- int ady = FFABS(dy);
- int sy = dy < 0 ? -1 : 1;
- buf[x0] = ff_vorbis_floor1_inverse_db_table[av_clip_uint8(y0)];
- if (ady*2 <= adx) { // optimized common case
- render_line_unrolled(x0, y0, x1, sy, ady, adx, buf);
- } else {
- int base = dy / adx;
- int x = x0;
- int y = y0;
- int err = -adx;
- ady -= FFABS(base) * adx;
- while (++x < x1) {
- y += base;
- err += ady;
- if (err >= 0) {
- err -= adx;
- y += sy;
- }
- buf[x] = ff_vorbis_floor1_inverse_db_table[av_clip_uint8(y)];
- }
- }
-}
-
-void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values,
- uint16_t *y_list, int *flag,
- int multiplier, float *out, int samples)
-{
- int lx, ly, i;
- lx = 0;
- ly = y_list[0] * multiplier;
- for (i = 1; i < values; i++) {
- int pos = list[i].sort;
- if (flag[pos]) {
- int x1 = list[pos].x;
- int y1 = y_list[pos] * multiplier;
- if (lx < samples)
- render_line(lx, ly, FFMIN(x1,samples), y1, out);
- lx = x1;
- ly = y1;
- }
- if (lx >= samples)
- break;
- }
- if (lx < samples)
- render_line(lx, ly, samples, ly, out);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/vorbis.h b/src/thirdparty/ffmpeg/libavcodec/vorbis.h
deleted file mode 100644
index 6f0c6ac40..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vorbis.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * copyright (c) 2006 Oded Shimon <ods15@ods15.dyndns.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_VORBIS_H
-#define AVCODEC_VORBIS_H
-
-#include "avcodec.h"
-
-extern const float ff_vorbis_floor1_inverse_db_table[256];
-extern const float * const ff_vorbis_vwin[8];
-extern const uint8_t ff_vorbis_channel_layout_offsets[8][8];
-extern const uint8_t ff_vorbis_encoding_channel_layout_offsets[8][8];
-extern const uint64_t ff_vorbis_channel_layouts[9];
-
-typedef struct vorbis_floor1_entry {
- uint16_t x;
- uint16_t sort;
- uint16_t low;
- uint16_t high;
-} vorbis_floor1_entry;
-
-int ff_vorbis_ready_floor1_list(AVCodecContext *avccontext,
- vorbis_floor1_entry *list, int values);
-unsigned int ff_vorbis_nth_root(unsigned int x, unsigned int n); // x^(1/n)
-int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num);
-void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values,
- uint16_t *y_list, int *flag,
- int multiplier, float * out, int samples);
-void ff_vorbis_inverse_coupling(float *mag, float *ang, intptr_t blocksize);
-
-#define ilog(i) av_log2(2*(i))
-
-#endif /* AVCODEC_VORBIS_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/vorbis_data.c b/src/thirdparty/ffmpeg/libavcodec/vorbis_data.c
deleted file mode 100644
index 75569e982..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vorbis_data.c
+++ /dev/null
@@ -1,2194 +0,0 @@
-/*
- * copyright (c) 2005 Denes Balatoni ( dbalatoni programozo hu )
- *
- * 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/mem.h"
-#include "dsputil.h"
-#include "vorbis.h"
-
-const uint8_t ff_vorbis_channel_layout_offsets[8][8] = {
- { 0 },
- { 0, 1 },
- { 0, 2, 1 },
- { 0, 1, 2, 3 },
- { 0, 2, 1, 3, 4 },
- { 0, 2, 1, 5, 3, 4 },
- { 0, 2, 1, 6, 5, 3, 4 },
- { 0, 2, 1, 7, 5, 6, 3, 4 },
-};
-
-const uint8_t ff_vorbis_encoding_channel_layout_offsets[8][8] = {
- { 0 },
- { 0, 1 },
- { 0, 2, 1 },
- { 0, 1, 2, 3 },
- { 0, 2, 1, 3, 4 },
- { 0, 2, 1, 4, 5, 3 },
- { 0, 2, 1, 5, 6, 4, 3 },
- { 0, 2, 1, 6, 7, 4, 5, 3 },
-};
-
-const uint64_t ff_vorbis_channel_layouts[9] = {
- AV_CH_LAYOUT_MONO,
- AV_CH_LAYOUT_STEREO,
- AV_CH_LAYOUT_SURROUND,
- AV_CH_LAYOUT_QUAD,
- AV_CH_LAYOUT_5POINT0_BACK,
- AV_CH_LAYOUT_5POINT1_BACK,
- AV_CH_LAYOUT_5POINT1|AV_CH_BACK_CENTER,
- AV_CH_LAYOUT_7POINT1,
- 0
-};
-
-DECLARE_ALIGNED(16, static const float, vwin64)[32] = {
- 0.0009460463F, 0.0085006468F, 0.0235352254F, 0.0458950567F,
- 0.0753351908F, 0.1115073077F, 0.1539457973F, 0.2020557475F,
- 0.2551056759F, 0.3122276645F, 0.3724270287F, 0.4346027792F,
- 0.4975789974F, 0.5601459521F, 0.6211085051F, 0.6793382689F,
- 0.7338252629F, 0.7837245849F, 0.8283939355F, 0.8674186656F,
- 0.9006222429F, 0.9280614787F, 0.9500073081F, 0.9669131782F,
- 0.9793740220F, 0.9880792941F, 0.9937636139F, 0.9971582668F,
- 0.9989462667F, 0.9997230082F, 0.9999638688F, 0.9999995525F,
-};
-
-DECLARE_ALIGNED(16, static const float, vwin128)[64] = {
- 0.0002365472F, 0.0021280687F, 0.0059065254F, 0.0115626550F,
- 0.0190823442F, 0.0284463735F, 0.0396300935F, 0.0526030430F,
- 0.0673285281F, 0.0837631763F, 0.1018564887F, 0.1215504095F,
- 0.1427789367F, 0.1654677960F, 0.1895342001F, 0.2148867160F,
- 0.2414252576F, 0.2690412240F, 0.2976177952F, 0.3270303960F,
- 0.3571473350F, 0.3878306189F, 0.4189369387F, 0.4503188188F,
- 0.4818259135F, 0.5133064334F, 0.5446086751F, 0.5755826278F,
- 0.6060816248F, 0.6359640047F, 0.6650947483F, 0.6933470543F,
- 0.7206038179F, 0.7467589810F, 0.7717187213F, 0.7954024542F,
- 0.8177436264F, 0.8386902831F, 0.8582053981F, 0.8762669622F,
- 0.8928678298F, 0.9080153310F, 0.9217306608F, 0.9340480615F,
- 0.9450138200F, 0.9546851041F, 0.9631286621F, 0.9704194171F,
- 0.9766389810F, 0.9818741197F, 0.9862151938F, 0.9897546035F,
- 0.9925852598F, 0.9947991032F, 0.9964856900F, 0.9977308602F,
- 0.9986155015F, 0.9992144193F, 0.9995953200F, 0.9998179155F,
- 0.9999331503F, 0.9999825563F, 0.9999977357F, 0.9999999720F,
-};
-
-DECLARE_ALIGNED(16, static const float, vwin256)[128] = {
- 0.0000591390F, 0.0005321979F, 0.0014780301F, 0.0028960636F,
- 0.0047854363F, 0.0071449926F, 0.0099732775F, 0.0132685298F,
- 0.0170286741F, 0.0212513119F, 0.0259337111F, 0.0310727950F,
- 0.0366651302F, 0.0427069140F, 0.0491939614F, 0.0561216907F,
- 0.0634851102F, 0.0712788035F, 0.0794969160F, 0.0881331402F,
- 0.0971807028F, 0.1066323515F, 0.1164803426F, 0.1267164297F,
- 0.1373318534F, 0.1483173323F, 0.1596630553F, 0.1713586755F,
- 0.1833933062F, 0.1957555184F, 0.2084333404F, 0.2214142599F,
- 0.2346852280F, 0.2482326664F, 0.2620424757F, 0.2761000481F,
- 0.2903902813F, 0.3048975959F, 0.3196059553F, 0.3344988887F,
- 0.3495595160F, 0.3647705766F, 0.3801144597F, 0.3955732382F,
- 0.4111287047F, 0.4267624093F, 0.4424557009F, 0.4581897696F,
- 0.4739456913F, 0.4897044744F, 0.5054471075F, 0.5211546088F,
- 0.5368080763F, 0.5523887395F, 0.5678780103F, 0.5832575361F,
- 0.5985092508F, 0.6136154277F, 0.6285587300F, 0.6433222619F,
- 0.6578896175F, 0.6722449294F, 0.6863729144F, 0.7002589187F,
- 0.7138889597F, 0.7272497662F, 0.7403288154F, 0.7531143679F,
- 0.7655954985F, 0.7777621249F, 0.7896050322F, 0.8011158947F,
- 0.8122872932F, 0.8231127294F, 0.8335866365F, 0.8437043850F,
- 0.8534622861F, 0.8628575905F, 0.8718884835F, 0.8805540765F,
- 0.8888543947F, 0.8967903616F, 0.9043637797F, 0.9115773078F,
- 0.9184344360F, 0.9249394562F, 0.9310974312F, 0.9369141608F,
- 0.9423961446F, 0.9475505439F, 0.9523851406F, 0.9569082947F,
- 0.9611289005F, 0.9650563408F, 0.9687004405F, 0.9720714191F,
- 0.9751798427F, 0.9780365753F, 0.9806527301F, 0.9830396204F,
- 0.9852087111F, 0.9871715701F, 0.9889398207F, 0.9905250941F,
- 0.9919389832F, 0.9931929973F, 0.9942985174F, 0.9952667537F,
- 0.9961087037F, 0.9968351119F, 0.9974564312F, 0.9979827858F,
- 0.9984239359F, 0.9987892441F, 0.9990876435F, 0.9993276081F,
- 0.9995171241F, 0.9996636648F, 0.9997741654F, 0.9998550016F,
- 0.9999119692F, 0.9999502656F, 0.9999744742F, 0.9999885497F,
- 0.9999958064F, 0.9999989077F, 0.9999998584F, 0.9999999983F,
-};
-
-DECLARE_ALIGNED(16, static const float, vwin512)[256] = {
- 0.0000147849F, 0.0001330607F, 0.0003695946F, 0.0007243509F,
- 0.0011972759F, 0.0017882983F, 0.0024973285F, 0.0033242588F,
- 0.0042689632F, 0.0053312973F, 0.0065110982F, 0.0078081841F,
- 0.0092223540F, 0.0107533880F, 0.0124010466F, 0.0141650703F,
- 0.0160451800F, 0.0180410758F, 0.0201524373F, 0.0223789233F,
- 0.0247201710F, 0.0271757958F, 0.0297453914F, 0.0324285286F,
- 0.0352247556F, 0.0381335972F, 0.0411545545F, 0.0442871045F,
- 0.0475306997F, 0.0508847676F, 0.0543487103F, 0.0579219038F,
- 0.0616036982F, 0.0653934164F, 0.0692903546F, 0.0732937809F,
- 0.0774029356F, 0.0816170305F, 0.0859352485F, 0.0903567428F,
- 0.0948806375F, 0.0995060259F, 0.1042319712F, 0.1090575056F,
- 0.1139816300F, 0.1190033137F, 0.1241214941F, 0.1293350764F,
- 0.1346429333F, 0.1400439046F, 0.1455367974F, 0.1511203852F,
- 0.1567934083F, 0.1625545735F, 0.1684025537F, 0.1743359881F,
- 0.1803534820F, 0.1864536069F, 0.1926349000F, 0.1988958650F,
- 0.2052349715F, 0.2116506555F, 0.2181413191F, 0.2247053313F,
- 0.2313410275F, 0.2380467105F, 0.2448206500F, 0.2516610835F,
- 0.2585662164F, 0.2655342226F, 0.2725632448F, 0.2796513950F,
- 0.2867967551F, 0.2939973773F, 0.3012512852F, 0.3085564739F,
- 0.3159109111F, 0.3233125375F, 0.3307592680F, 0.3382489922F,
- 0.3457795756F, 0.3533488602F, 0.3609546657F, 0.3685947904F,
- 0.3762670121F, 0.3839690896F, 0.3916987634F, 0.3994537572F,
- 0.4072317788F, 0.4150305215F, 0.4228476653F, 0.4306808783F,
- 0.4385278181F, 0.4463861329F, 0.4542534630F, 0.4621274424F,
- 0.4700057001F, 0.4778858615F, 0.4857655502F, 0.4936423891F,
- 0.5015140023F, 0.5093780165F, 0.5172320626F, 0.5250737772F,
- 0.5329008043F, 0.5407107971F, 0.5485014192F, 0.5562703465F,
- 0.5640152688F, 0.5717338914F, 0.5794239366F, 0.5870831457F,
- 0.5947092801F, 0.6023001235F, 0.6098534829F, 0.6173671907F,
- 0.6248391059F, 0.6322671161F, 0.6396491384F, 0.6469831217F,
- 0.6542670475F, 0.6614989319F, 0.6686768267F, 0.6757988210F,
- 0.6828630426F, 0.6898676592F, 0.6968108799F, 0.7036909564F,
- 0.7105061843F, 0.7172549043F, 0.7239355032F, 0.7305464154F,
- 0.7370861235F, 0.7435531598F, 0.7499461068F, 0.7562635986F,
- 0.7625043214F, 0.7686670148F, 0.7747504721F, 0.7807535410F,
- 0.7866751247F, 0.7925141825F, 0.7982697296F, 0.8039408387F,
- 0.8095266395F, 0.8150263196F, 0.8204391248F, 0.8257643590F,
- 0.8310013848F, 0.8361496236F, 0.8412085555F, 0.8461777194F,
- 0.8510567129F, 0.8558451924F, 0.8605428730F, 0.8651495278F,
- 0.8696649882F, 0.8740891432F, 0.8784219392F, 0.8826633797F,
- 0.8868135244F, 0.8908724888F, 0.8948404441F, 0.8987176157F,
- 0.9025042831F, 0.9062007791F, 0.9098074886F, 0.9133248482F,
- 0.9167533451F, 0.9200935163F, 0.9233459472F, 0.9265112712F,
- 0.9295901680F, 0.9325833632F, 0.9354916263F, 0.9383157705F,
- 0.9410566504F, 0.9437151618F, 0.9462922398F, 0.9487888576F,
- 0.9512060252F, 0.9535447882F, 0.9558062262F, 0.9579914516F,
- 0.9601016078F, 0.9621378683F, 0.9641014348F, 0.9659935361F,
- 0.9678154261F, 0.9695683830F, 0.9712537071F, 0.9728727198F,
- 0.9744267618F, 0.9759171916F, 0.9773453842F, 0.9787127293F,
- 0.9800206298F, 0.9812705006F, 0.9824637665F, 0.9836018613F,
- 0.9846862258F, 0.9857183066F, 0.9866995544F, 0.9876314227F,
- 0.9885153662F, 0.9893528393F, 0.9901452948F, 0.9908941823F,
- 0.9916009470F, 0.9922670279F, 0.9928938570F, 0.9934828574F,
- 0.9940354423F, 0.9945530133F, 0.9950369595F, 0.9954886562F,
- 0.9959094633F, 0.9963007242F, 0.9966637649F, 0.9969998925F,
- 0.9973103939F, 0.9975965351F, 0.9978595598F, 0.9981006885F,
- 0.9983211172F, 0.9985220166F, 0.9987045311F, 0.9988697776F,
- 0.9990188449F, 0.9991527924F, 0.9992726499F, 0.9993794157F,
- 0.9994740570F, 0.9995575079F, 0.9996306699F, 0.9996944099F,
- 0.9997495605F, 0.9997969190F, 0.9998372465F, 0.9998712678F,
- 0.9998996704F, 0.9999231041F, 0.9999421807F, 0.9999574732F,
- 0.9999695157F, 0.9999788026F, 0.9999857885F, 0.9999908879F,
- 0.9999944746F, 0.9999968817F, 0.9999984010F, 0.9999992833F,
- 0.9999997377F, 0.9999999317F, 0.9999999911F, 0.9999999999F,
-};
-
-DECLARE_ALIGNED(16, static const float, vwin1024)[512] = {
- 0.0000036962F, 0.0000332659F, 0.0000924041F, 0.0001811086F,
- 0.0002993761F, 0.0004472021F, 0.0006245811F, 0.0008315063F,
- 0.0010679699F, 0.0013339631F, 0.0016294757F, 0.0019544965F,
- 0.0023090133F, 0.0026930125F, 0.0031064797F, 0.0035493989F,
- 0.0040217533F, 0.0045235250F, 0.0050546946F, 0.0056152418F,
- 0.0062051451F, 0.0068243817F, 0.0074729278F, 0.0081507582F,
- 0.0088578466F, 0.0095941655F, 0.0103596863F, 0.0111543789F,
- 0.0119782122F, 0.0128311538F, 0.0137131701F, 0.0146242260F,
- 0.0155642855F, 0.0165333111F, 0.0175312640F, 0.0185581042F,
- 0.0196137903F, 0.0206982797F, 0.0218115284F, 0.0229534910F,
- 0.0241241208F, 0.0253233698F, 0.0265511886F, 0.0278075263F,
- 0.0290923308F, 0.0304055484F, 0.0317471241F, 0.0331170013F,
- 0.0345151222F, 0.0359414274F, 0.0373958560F, 0.0388783456F,
- 0.0403888325F, 0.0419272511F, 0.0434935347F, 0.0450876148F,
- 0.0467094213F, 0.0483588828F, 0.0500359261F, 0.0517404765F,
- 0.0534724575F, 0.0552317913F, 0.0570183983F, 0.0588321971F,
- 0.0606731048F, 0.0625410369F, 0.0644359070F, 0.0663576272F,
- 0.0683061077F, 0.0702812571F, 0.0722829821F, 0.0743111878F,
- 0.0763657775F, 0.0784466526F, 0.0805537129F, 0.0826868561F,
- 0.0848459782F, 0.0870309736F, 0.0892417345F, 0.0914781514F,
- 0.0937401128F, 0.0960275056F, 0.0983402145F, 0.1006781223F,
- 0.1030411101F, 0.1054290568F, 0.1078418397F, 0.1102793336F,
- 0.1127414119F, 0.1152279457F, 0.1177388042F, 0.1202738544F,
- 0.1228329618F, 0.1254159892F, 0.1280227980F, 0.1306532471F,
- 0.1333071937F, 0.1359844927F, 0.1386849970F, 0.1414085575F,
- 0.1441550230F, 0.1469242403F, 0.1497160539F, 0.1525303063F,
- 0.1553668381F, 0.1582254875F, 0.1611060909F, 0.1640084822F,
- 0.1669324936F, 0.1698779549F, 0.1728446939F, 0.1758325362F,
- 0.1788413055F, 0.1818708232F, 0.1849209084F, 0.1879913785F,
- 0.1910820485F, 0.1941927312F, 0.1973232376F, 0.2004733764F,
- 0.2036429541F, 0.2068317752F, 0.2100396421F, 0.2132663552F,
- 0.2165117125F, 0.2197755102F, 0.2230575422F, 0.2263576007F,
- 0.2296754753F, 0.2330109540F, 0.2363638225F, 0.2397338646F,
- 0.2431208619F, 0.2465245941F, 0.2499448389F, 0.2533813719F,
- 0.2568339669F, 0.2603023956F, 0.2637864277F, 0.2672858312F,
- 0.2708003718F, 0.2743298135F, 0.2778739186F, 0.2814324472F,
- 0.2850051576F, 0.2885918065F, 0.2921921485F, 0.2958059366F,
- 0.2994329219F, 0.3030728538F, 0.3067254799F, 0.3103905462F,
- 0.3140677969F, 0.3177569747F, 0.3214578205F, 0.3251700736F,
- 0.3288934718F, 0.3326277513F, 0.3363726468F, 0.3401278914F,
- 0.3438932168F, 0.3476683533F, 0.3514530297F, 0.3552469734F,
- 0.3590499106F, 0.3628615659F, 0.3666816630F, 0.3705099239F,
- 0.3743460698F, 0.3781898204F, 0.3820408945F, 0.3858990095F,
- 0.3897638820F, 0.3936352274F, 0.3975127601F, 0.4013961936F,
- 0.4052852405F, 0.4091796123F, 0.4130790198F, 0.4169831732F,
- 0.4208917815F, 0.4248045534F, 0.4287211965F, 0.4326414181F,
- 0.4365649248F, 0.4404914225F, 0.4444206167F, 0.4483522125F,
- 0.4522859146F, 0.4562214270F, 0.4601584538F, 0.4640966984F,
- 0.4680358644F, 0.4719756548F, 0.4759157726F, 0.4798559209F,
- 0.4837958024F, 0.4877351199F, 0.4916735765F, 0.4956108751F,
- 0.4995467188F, 0.5034808109F, 0.5074128550F, 0.5113425550F,
- 0.5152696149F, 0.5191937395F, 0.5231146336F, 0.5270320028F,
- 0.5309455530F, 0.5348549910F, 0.5387600239F, 0.5426603597F,
- 0.5465557070F, 0.5504457754F, 0.5543302752F, 0.5582089175F,
- 0.5620814145F, 0.5659474793F, 0.5698068262F, 0.5736591704F,
- 0.5775042283F, 0.5813417176F, 0.5851713571F, 0.5889928670F,
- 0.5928059689F, 0.5966103856F, 0.6004058415F, 0.6041920626F,
- 0.6079687761F, 0.6117357113F, 0.6154925986F, 0.6192391705F,
- 0.6229751612F, 0.6267003064F, 0.6304143441F, 0.6341170137F,
- 0.6378080569F, 0.6414872173F, 0.6451542405F, 0.6488088741F,
- 0.6524508681F, 0.6560799742F, 0.6596959469F, 0.6632985424F,
- 0.6668875197F, 0.6704626398F, 0.6740236662F, 0.6775703649F,
- 0.6811025043F, 0.6846198554F, 0.6881221916F, 0.6916092892F,
- 0.6950809269F, 0.6985368861F, 0.7019769510F, 0.7054009085F,
- 0.7088085484F, 0.7121996632F, 0.7155740484F, 0.7189315023F,
- 0.7222718263F, 0.7255948245F, 0.7289003043F, 0.7321880760F,
- 0.7354579530F, 0.7387097518F, 0.7419432921F, 0.7451583966F,
- 0.7483548915F, 0.7515326059F, 0.7546913723F, 0.7578310265F,
- 0.7609514077F, 0.7640523581F, 0.7671337237F, 0.7701953535F,
- 0.7732371001F, 0.7762588195F, 0.7792603711F, 0.7822416178F,
- 0.7852024259F, 0.7881426654F, 0.7910622097F, 0.7939609356F,
- 0.7968387237F, 0.7996954579F, 0.8025310261F, 0.8053453193F,
- 0.8081382324F, 0.8109096638F, 0.8136595156F, 0.8163876936F,
- 0.8190941071F, 0.8217786690F, 0.8244412960F, 0.8270819086F,
- 0.8297004305F, 0.8322967896F, 0.8348709171F, 0.8374227481F,
- 0.8399522213F, 0.8424592789F, 0.8449438672F, 0.8474059356F,
- 0.8498454378F, 0.8522623306F, 0.8546565748F, 0.8570281348F,
- 0.8593769787F, 0.8617030779F, 0.8640064080F, 0.8662869477F,
- 0.8685446796F, 0.8707795899F, 0.8729916682F, 0.8751809079F,
- 0.8773473059F, 0.8794908626F, 0.8816115819F, 0.8837094713F,
- 0.8857845418F, 0.8878368079F, 0.8898662874F, 0.8918730019F,
- 0.8938569760F, 0.8958182380F, 0.8977568194F, 0.8996727552F,
- 0.9015660837F, 0.9034368465F, 0.9052850885F, 0.9071108577F,
- 0.9089142057F, 0.9106951869F, 0.9124538591F, 0.9141902832F,
- 0.9159045233F, 0.9175966464F, 0.9192667228F, 0.9209148257F,
- 0.9225410313F, 0.9241454187F, 0.9257280701F, 0.9272890704F,
- 0.9288285075F, 0.9303464720F, 0.9318430576F, 0.9333183603F,
- 0.9347724792F, 0.9362055158F, 0.9376175745F, 0.9390087622F,
- 0.9403791881F, 0.9417289644F, 0.9430582055F, 0.9443670283F,
- 0.9456555521F, 0.9469238986F, 0.9481721917F, 0.9494005577F,
- 0.9506091252F, 0.9517980248F, 0.9529673894F, 0.9541173540F,
- 0.9552480557F, 0.9563596334F, 0.9574522282F, 0.9585259830F,
- 0.9595810428F, 0.9606175542F, 0.9616356656F, 0.9626355274F,
- 0.9636172915F, 0.9645811114F, 0.9655271425F, 0.9664555414F,
- 0.9673664664F, 0.9682600774F, 0.9691365355F, 0.9699960034F,
- 0.9708386448F, 0.9716646250F, 0.9724741103F, 0.9732672685F,
- 0.9740442683F, 0.9748052795F, 0.9755504729F, 0.9762800205F,
- 0.9769940950F, 0.9776928703F, 0.9783765210F, 0.9790452223F,
- 0.9796991504F, 0.9803384823F, 0.9809633954F, 0.9815740679F,
- 0.9821706784F, 0.9827534063F, 0.9833224312F, 0.9838779332F,
- 0.9844200928F, 0.9849490910F, 0.9854651087F, 0.9859683274F,
- 0.9864589286F, 0.9869370940F, 0.9874030054F, 0.9878568447F,
- 0.9882987937F, 0.9887290343F, 0.9891477481F, 0.9895551169F,
- 0.9899513220F, 0.9903365446F, 0.9907109658F, 0.9910747662F,
- 0.9914281260F, 0.9917712252F, 0.9921042433F, 0.9924273593F,
- 0.9927407516F, 0.9930445982F, 0.9933390763F, 0.9936243626F,
- 0.9939006331F, 0.9941680631F, 0.9944268269F, 0.9946770982F,
- 0.9949190498F, 0.9951528537F, 0.9953786808F, 0.9955967011F,
- 0.9958070836F, 0.9960099963F, 0.9962056061F, 0.9963940787F,
- 0.9965755786F, 0.9967502693F, 0.9969183129F, 0.9970798704F,
- 0.9972351013F, 0.9973841640F, 0.9975272151F, 0.9976644103F,
- 0.9977959036F, 0.9979218476F, 0.9980423932F, 0.9981576901F,
- 0.9982678862F, 0.9983731278F, 0.9984735596F, 0.9985693247F,
- 0.9986605645F, 0.9987474186F, 0.9988300248F, 0.9989085193F,
- 0.9989830364F, 0.9990537085F, 0.9991206662F, 0.9991840382F,
- 0.9992439513F, 0.9993005303F, 0.9993538982F, 0.9994041757F,
- 0.9994514817F, 0.9994959330F, 0.9995376444F, 0.9995767286F,
- 0.9996132960F, 0.9996474550F, 0.9996793121F, 0.9997089710F,
- 0.9997365339F, 0.9997621003F, 0.9997857677F, 0.9998076311F,
- 0.9998277836F, 0.9998463156F, 0.9998633155F, 0.9998788692F,
- 0.9998930603F, 0.9999059701F, 0.9999176774F, 0.9999282586F,
- 0.9999377880F, 0.9999463370F, 0.9999539749F, 0.9999607685F,
- 0.9999667820F, 0.9999720773F, 0.9999767136F, 0.9999807479F,
- 0.9999842344F, 0.9999872249F, 0.9999897688F, 0.9999919127F,
- 0.9999937009F, 0.9999951749F, 0.9999963738F, 0.9999973342F,
- 0.9999980900F, 0.9999986724F, 0.9999991103F, 0.9999994297F,
- 0.9999996543F, 0.9999998049F, 0.9999999000F, 0.9999999552F,
- 0.9999999836F, 0.9999999957F, 0.9999999994F, 1.0000000000F,
-};
-
-DECLARE_ALIGNED(16, static const float, vwin2048)[1024] = {
- 0.0000009241F, 0.0000083165F, 0.0000231014F, 0.0000452785F,
- 0.0000748476F, 0.0001118085F, 0.0001561608F, 0.0002079041F,
- 0.0002670379F, 0.0003335617F, 0.0004074748F, 0.0004887765F,
- 0.0005774661F, 0.0006735427F, 0.0007770054F, 0.0008878533F,
- 0.0010060853F, 0.0011317002F, 0.0012646969F, 0.0014050742F,
- 0.0015528307F, 0.0017079650F, 0.0018704756F, 0.0020403610F,
- 0.0022176196F, 0.0024022497F, 0.0025942495F, 0.0027936173F,
- 0.0030003511F, 0.0032144490F, 0.0034359088F, 0.0036647286F,
- 0.0039009061F, 0.0041444391F, 0.0043953253F, 0.0046535621F,
- 0.0049191472F, 0.0051920781F, 0.0054723520F, 0.0057599664F,
- 0.0060549184F, 0.0063572052F, 0.0066668239F, 0.0069837715F,
- 0.0073080449F, 0.0076396410F, 0.0079785566F, 0.0083247884F,
- 0.0086783330F, 0.0090391871F, 0.0094073470F, 0.0097828092F,
- 0.0101655700F, 0.0105556258F, 0.0109529726F, 0.0113576065F,
- 0.0117695237F, 0.0121887200F, 0.0126151913F, 0.0130489335F,
- 0.0134899422F, 0.0139382130F, 0.0143937415F, 0.0148565233F,
- 0.0153265536F, 0.0158038279F, 0.0162883413F, 0.0167800889F,
- 0.0172790660F, 0.0177852675F, 0.0182986882F, 0.0188193231F,
- 0.0193471668F, 0.0198822141F, 0.0204244594F, 0.0209738974F,
- 0.0215305225F, 0.0220943289F, 0.0226653109F, 0.0232434627F,
- 0.0238287784F, 0.0244212519F, 0.0250208772F, 0.0256276481F,
- 0.0262415582F, 0.0268626014F, 0.0274907711F, 0.0281260608F,
- 0.0287684638F, 0.0294179736F, 0.0300745833F, 0.0307382859F,
- 0.0314090747F, 0.0320869424F, 0.0327718819F, 0.0334638860F,
- 0.0341629474F, 0.0348690586F, 0.0355822122F, 0.0363024004F,
- 0.0370296157F, 0.0377638502F, 0.0385050960F, 0.0392533451F,
- 0.0400085896F, 0.0407708211F, 0.0415400315F, 0.0423162123F,
- 0.0430993552F, 0.0438894515F, 0.0446864926F, 0.0454904698F,
- 0.0463013742F, 0.0471191969F, 0.0479439288F, 0.0487755607F,
- 0.0496140836F, 0.0504594879F, 0.0513117642F, 0.0521709031F,
- 0.0530368949F, 0.0539097297F, 0.0547893979F, 0.0556758894F,
- 0.0565691941F, 0.0574693019F, 0.0583762026F, 0.0592898858F,
- 0.0602103410F, 0.0611375576F, 0.0620715250F, 0.0630122324F,
- 0.0639596688F, 0.0649138234F, 0.0658746848F, 0.0668422421F,
- 0.0678164838F, 0.0687973985F, 0.0697849746F, 0.0707792005F,
- 0.0717800645F, 0.0727875547F, 0.0738016591F, 0.0748223656F,
- 0.0758496620F, 0.0768835359F, 0.0779239751F, 0.0789709668F,
- 0.0800244985F, 0.0810845574F, 0.0821511306F, 0.0832242052F,
- 0.0843037679F, 0.0853898056F, 0.0864823050F, 0.0875812525F,
- 0.0886866347F, 0.0897984378F, 0.0909166480F, 0.0920412513F,
- 0.0931722338F, 0.0943095813F, 0.0954532795F, 0.0966033140F,
- 0.0977596702F, 0.0989223336F, 0.1000912894F, 0.1012665227F,
- 0.1024480185F, 0.1036357616F, 0.1048297369F, 0.1060299290F,
- 0.1072363224F, 0.1084489014F, 0.1096676504F, 0.1108925534F,
- 0.1121235946F, 0.1133607577F, 0.1146040267F, 0.1158533850F,
- 0.1171088163F, 0.1183703040F, 0.1196378312F, 0.1209113812F,
- 0.1221909370F, 0.1234764815F, 0.1247679974F, 0.1260654674F,
- 0.1273688740F, 0.1286781995F, 0.1299934263F, 0.1313145365F,
- 0.1326415121F, 0.1339743349F, 0.1353129866F, 0.1366574490F,
- 0.1380077035F, 0.1393637315F, 0.1407255141F, 0.1420930325F,
- 0.1434662677F, 0.1448452004F, 0.1462298115F, 0.1476200814F,
- 0.1490159906F, 0.1504175195F, 0.1518246482F, 0.1532373569F,
- 0.1546556253F, 0.1560794333F, 0.1575087606F, 0.1589435866F,
- 0.1603838909F, 0.1618296526F, 0.1632808509F, 0.1647374648F,
- 0.1661994731F, 0.1676668546F, 0.1691395880F, 0.1706176516F,
- 0.1721010238F, 0.1735896829F, 0.1750836068F, 0.1765827736F,
- 0.1780871610F, 0.1795967468F, 0.1811115084F, 0.1826314234F,
- 0.1841564689F, 0.1856866221F, 0.1872218600F, 0.1887621595F,
- 0.1903074974F, 0.1918578503F, 0.1934131947F, 0.1949735068F,
- 0.1965387630F, 0.1981089393F, 0.1996840117F, 0.2012639560F,
- 0.2028487479F, 0.2044383630F, 0.2060327766F, 0.2076319642F,
- 0.2092359007F, 0.2108445614F, 0.2124579211F, 0.2140759545F,
- 0.2156986364F, 0.2173259411F, 0.2189578432F, 0.2205943168F,
- 0.2222353361F, 0.2238808751F, 0.2255309076F, 0.2271854073F,
- 0.2288443480F, 0.2305077030F, 0.2321754457F, 0.2338475493F,
- 0.2355239869F, 0.2372047315F, 0.2388897560F, 0.2405790329F,
- 0.2422725350F, 0.2439702347F, 0.2456721043F, 0.2473781159F,
- 0.2490882418F, 0.2508024539F, 0.2525207240F, 0.2542430237F,
- 0.2559693248F, 0.2576995986F, 0.2594338166F, 0.2611719498F,
- 0.2629139695F, 0.2646598466F, 0.2664095520F, 0.2681630564F,
- 0.2699203304F, 0.2716813445F, 0.2734460691F, 0.2752144744F,
- 0.2769865307F, 0.2787622079F, 0.2805414760F, 0.2823243047F,
- 0.2841106637F, 0.2859005227F, 0.2876938509F, 0.2894906179F,
- 0.2912907928F, 0.2930943447F, 0.2949012426F, 0.2967114554F,
- 0.2985249520F, 0.3003417009F, 0.3021616708F, 0.3039848301F,
- 0.3058111471F, 0.3076405901F, 0.3094731273F, 0.3113087266F,
- 0.3131473560F, 0.3149889833F, 0.3168335762F, 0.3186811024F,
- 0.3205315294F, 0.3223848245F, 0.3242409552F, 0.3260998886F,
- 0.3279615918F, 0.3298260319F, 0.3316931758F, 0.3335629903F,
- 0.3354354423F, 0.3373104982F, 0.3391881247F, 0.3410682882F,
- 0.3429509551F, 0.3448360917F, 0.3467236642F, 0.3486136387F,
- 0.3505059811F, 0.3524006575F, 0.3542976336F, 0.3561968753F,
- 0.3580983482F, 0.3600020179F, 0.3619078499F, 0.3638158096F,
- 0.3657258625F, 0.3676379737F, 0.3695521086F, 0.3714682321F,
- 0.3733863094F, 0.3753063055F, 0.3772281852F, 0.3791519134F,
- 0.3810774548F, 0.3830047742F, 0.3849338362F, 0.3868646053F,
- 0.3887970459F, 0.3907311227F, 0.3926667998F, 0.3946040417F,
- 0.3965428125F, 0.3984830765F, 0.4004247978F, 0.4023679403F,
- 0.4043124683F, 0.4062583455F, 0.4082055359F, 0.4101540034F,
- 0.4121037117F, 0.4140546246F, 0.4160067058F, 0.4179599190F,
- 0.4199142277F, 0.4218695956F, 0.4238259861F, 0.4257833627F,
- 0.4277416888F, 0.4297009279F, 0.4316610433F, 0.4336219983F,
- 0.4355837562F, 0.4375462803F, 0.4395095337F, 0.4414734797F,
- 0.4434380815F, 0.4454033021F, 0.4473691046F, 0.4493354521F,
- 0.4513023078F, 0.4532696345F, 0.4552373954F, 0.4572055533F,
- 0.4591740713F, 0.4611429123F, 0.4631120393F, 0.4650814151F,
- 0.4670510028F, 0.4690207650F, 0.4709906649F, 0.4729606651F,
- 0.4749307287F, 0.4769008185F, 0.4788708972F, 0.4808409279F,
- 0.4828108732F, 0.4847806962F, 0.4867503597F, 0.4887198264F,
- 0.4906890593F, 0.4926580213F, 0.4946266753F, 0.4965949840F,
- 0.4985629105F, 0.5005304176F, 0.5024974683F, 0.5044640255F,
- 0.5064300522F, 0.5083955114F, 0.5103603659F, 0.5123245790F,
- 0.5142881136F, 0.5162509328F, 0.5182129997F, 0.5201742774F,
- 0.5221347290F, 0.5240943178F, 0.5260530070F, 0.5280107598F,
- 0.5299675395F, 0.5319233095F, 0.5338780330F, 0.5358316736F,
- 0.5377841946F, 0.5397355596F, 0.5416857320F, 0.5436346755F,
- 0.5455823538F, 0.5475287304F, 0.5494737691F, 0.5514174337F,
- 0.5533596881F, 0.5553004962F, 0.5572398218F, 0.5591776291F,
- 0.5611138821F, 0.5630485449F, 0.5649815818F, 0.5669129570F,
- 0.5688426349F, 0.5707705799F, 0.5726967564F, 0.5746211290F,
- 0.5765436624F, 0.5784643212F, 0.5803830702F, 0.5822998743F,
- 0.5842146984F, 0.5861275076F, 0.5880382669F, 0.5899469416F,
- 0.5918534968F, 0.5937578981F, 0.5956601107F, 0.5975601004F,
- 0.5994578326F, 0.6013532732F, 0.6032463880F, 0.6051371429F,
- 0.6070255039F, 0.6089114372F, 0.6107949090F, 0.6126758856F,
- 0.6145543334F, 0.6164302191F, 0.6183035092F, 0.6201741706F,
- 0.6220421700F, 0.6239074745F, 0.6257700513F, 0.6276298674F,
- 0.6294868903F, 0.6313410873F, 0.6331924262F, 0.6350408745F,
- 0.6368864001F, 0.6387289710F, 0.6405685552F, 0.6424051209F,
- 0.6442386364F, 0.6460690702F, 0.6478963910F, 0.6497205673F,
- 0.6515415682F, 0.6533593625F, 0.6551739194F, 0.6569852082F,
- 0.6587931984F, 0.6605978593F, 0.6623991609F, 0.6641970728F,
- 0.6659915652F, 0.6677826081F, 0.6695701718F, 0.6713542268F,
- 0.6731347437F, 0.6749116932F, 0.6766850461F, 0.6784547736F,
- 0.6802208469F, 0.6819832374F, 0.6837419164F, 0.6854968559F,
- 0.6872480275F, 0.6889954034F, 0.6907389556F, 0.6924786566F,
- 0.6942144788F, 0.6959463950F, 0.6976743780F, 0.6993984008F,
- 0.7011184365F, 0.7028344587F, 0.7045464407F, 0.7062543564F,
- 0.7079581796F, 0.7096578844F, 0.7113534450F, 0.7130448359F,
- 0.7147320316F, 0.7164150070F, 0.7180937371F, 0.7197681970F,
- 0.7214383620F, 0.7231042077F, 0.7247657098F, 0.7264228443F,
- 0.7280755871F, 0.7297239147F, 0.7313678035F, 0.7330072301F,
- 0.7346421715F, 0.7362726046F, 0.7378985069F, 0.7395198556F,
- 0.7411366285F, 0.7427488034F, 0.7443563584F, 0.7459592717F,
- 0.7475575218F, 0.7491510873F, 0.7507399471F, 0.7523240803F,
- 0.7539034661F, 0.7554780839F, 0.7570479136F, 0.7586129349F,
- 0.7601731279F, 0.7617284730F, 0.7632789506F, 0.7648245416F,
- 0.7663652267F, 0.7679009872F, 0.7694318044F, 0.7709576599F,
- 0.7724785354F, 0.7739944130F, 0.7755052749F, 0.7770111035F,
- 0.7785118815F, 0.7800075916F, 0.7814982170F, 0.7829837410F,
- 0.7844641472F, 0.7859394191F, 0.7874095408F, 0.7888744965F,
- 0.7903342706F, 0.7917888476F, 0.7932382124F, 0.7946823501F,
- 0.7961212460F, 0.7975548855F, 0.7989832544F, 0.8004063386F,
- 0.8018241244F, 0.8032365981F, 0.8046437463F, 0.8060455560F,
- 0.8074420141F, 0.8088331080F, 0.8102188253F, 0.8115991536F,
- 0.8129740810F, 0.8143435957F, 0.8157076861F, 0.8170663409F,
- 0.8184195489F, 0.8197672994F, 0.8211095817F, 0.8224463853F,
- 0.8237777001F, 0.8251035161F, 0.8264238235F, 0.8277386129F,
- 0.8290478750F, 0.8303516008F, 0.8316497814F, 0.8329424083F,
- 0.8342294731F, 0.8355109677F, 0.8367868841F, 0.8380572148F,
- 0.8393219523F, 0.8405810893F, 0.8418346190F, 0.8430825345F,
- 0.8443248294F, 0.8455614974F, 0.8467925323F, 0.8480179285F,
- 0.8492376802F, 0.8504517822F, 0.8516602292F, 0.8528630164F,
- 0.8540601391F, 0.8552515928F, 0.8564373733F, 0.8576174766F,
- 0.8587918990F, 0.8599606368F, 0.8611236868F, 0.8622810460F,
- 0.8634327113F, 0.8645786802F, 0.8657189504F, 0.8668535195F,
- 0.8679823857F, 0.8691055472F, 0.8702230025F, 0.8713347503F,
- 0.8724407896F, 0.8735411194F, 0.8746357394F, 0.8757246489F,
- 0.8768078479F, 0.8778853364F, 0.8789571146F, 0.8800231832F,
- 0.8810835427F, 0.8821381942F, 0.8831871387F, 0.8842303777F,
- 0.8852679127F, 0.8862997456F, 0.8873258784F, 0.8883463132F,
- 0.8893610527F, 0.8903700994F, 0.8913734562F, 0.8923711263F,
- 0.8933631129F, 0.8943494196F, 0.8953300500F, 0.8963050083F,
- 0.8972742985F, 0.8982379249F, 0.8991958922F, 0.9001482052F,
- 0.9010948688F, 0.9020358883F, 0.9029712690F, 0.9039010165F,
- 0.9048251367F, 0.9057436357F, 0.9066565195F, 0.9075637946F,
- 0.9084654678F, 0.9093615456F, 0.9102520353F, 0.9111369440F,
- 0.9120162792F, 0.9128900484F, 0.9137582595F, 0.9146209204F,
- 0.9154780394F, 0.9163296248F, 0.9171756853F, 0.9180162296F,
- 0.9188512667F, 0.9196808057F, 0.9205048559F, 0.9213234270F,
- 0.9221365285F, 0.9229441704F, 0.9237463629F, 0.9245431160F,
- 0.9253344404F, 0.9261203465F, 0.9269008453F, 0.9276759477F,
- 0.9284456648F, 0.9292100080F, 0.9299689889F, 0.9307226190F,
- 0.9314709103F, 0.9322138747F, 0.9329515245F, 0.9336838721F,
- 0.9344109300F, 0.9351327108F, 0.9358492275F, 0.9365604931F,
- 0.9372665208F, 0.9379673239F, 0.9386629160F, 0.9393533107F,
- 0.9400385220F, 0.9407185637F, 0.9413934501F, 0.9420631954F,
- 0.9427278141F, 0.9433873208F, 0.9440417304F, 0.9446910576F,
- 0.9453353176F, 0.9459745255F, 0.9466086968F, 0.9472378469F,
- 0.9478619915F, 0.9484811463F, 0.9490953274F, 0.9497045506F,
- 0.9503088323F, 0.9509081888F, 0.9515026365F, 0.9520921921F,
- 0.9526768723F, 0.9532566940F, 0.9538316742F, 0.9544018300F,
- 0.9549671786F, 0.9555277375F, 0.9560835241F, 0.9566345562F,
- 0.9571808513F, 0.9577224275F, 0.9582593027F, 0.9587914949F,
- 0.9593190225F, 0.9598419038F, 0.9603601571F, 0.9608738012F,
- 0.9613828546F, 0.9618873361F, 0.9623872646F, 0.9628826591F,
- 0.9633735388F, 0.9638599227F, 0.9643418303F, 0.9648192808F,
- 0.9652922939F, 0.9657608890F, 0.9662250860F, 0.9666849046F,
- 0.9671403646F, 0.9675914861F, 0.9680382891F, 0.9684807937F,
- 0.9689190202F, 0.9693529890F, 0.9697827203F, 0.9702082347F,
- 0.9706295529F, 0.9710466953F, 0.9714596828F, 0.9718685362F,
- 0.9722732762F, 0.9726739240F, 0.9730705005F, 0.9734630267F,
- 0.9738515239F, 0.9742360134F, 0.9746165163F, 0.9749930540F,
- 0.9753656481F, 0.9757343198F, 0.9760990909F, 0.9764599829F,
- 0.9768170175F, 0.9771702164F, 0.9775196013F, 0.9778651941F,
- 0.9782070167F, 0.9785450909F, 0.9788794388F, 0.9792100824F,
- 0.9795370437F, 0.9798603449F, 0.9801800080F, 0.9804960554F,
- 0.9808085092F, 0.9811173916F, 0.9814227251F, 0.9817245318F,
- 0.9820228343F, 0.9823176549F, 0.9826090160F, 0.9828969402F,
- 0.9831814498F, 0.9834625674F, 0.9837403156F, 0.9840147169F,
- 0.9842857939F, 0.9845535692F, 0.9848180654F, 0.9850793052F,
- 0.9853373113F, 0.9855921062F, 0.9858437127F, 0.9860921535F,
- 0.9863374512F, 0.9865796287F, 0.9868187085F, 0.9870547136F,
- 0.9872876664F, 0.9875175899F, 0.9877445067F, 0.9879684396F,
- 0.9881894112F, 0.9884074444F, 0.9886225619F, 0.9888347863F,
- 0.9890441404F, 0.9892506468F, 0.9894543284F, 0.9896552077F,
- 0.9898533074F, 0.9900486502F, 0.9902412587F, 0.9904311555F,
- 0.9906183633F, 0.9908029045F, 0.9909848019F, 0.9911640779F,
- 0.9913407550F, 0.9915148557F, 0.9916864025F, 0.9918554179F,
- 0.9920219241F, 0.9921859437F, 0.9923474989F, 0.9925066120F,
- 0.9926633054F, 0.9928176012F, 0.9929695218F, 0.9931190891F,
- 0.9932663254F, 0.9934112527F, 0.9935538932F, 0.9936942686F,
- 0.9938324012F, 0.9939683126F, 0.9941020248F, 0.9942335597F,
- 0.9943629388F, 0.9944901841F, 0.9946153170F, 0.9947383593F,
- 0.9948593325F, 0.9949782579F, 0.9950951572F, 0.9952100516F,
- 0.9953229625F, 0.9954339111F, 0.9955429186F, 0.9956500062F,
- 0.9957551948F, 0.9958585056F, 0.9959599593F, 0.9960595769F,
- 0.9961573792F, 0.9962533869F, 0.9963476206F, 0.9964401009F,
- 0.9965308483F, 0.9966198833F, 0.9967072261F, 0.9967928971F,
- 0.9968769164F, 0.9969593041F, 0.9970400804F, 0.9971192651F,
- 0.9971968781F, 0.9972729391F, 0.9973474680F, 0.9974204842F,
- 0.9974920074F, 0.9975620569F, 0.9976306521F, 0.9976978122F,
- 0.9977635565F, 0.9978279039F, 0.9978908736F, 0.9979524842F,
- 0.9980127547F, 0.9980717037F, 0.9981293499F, 0.9981857116F,
- 0.9982408073F, 0.9982946554F, 0.9983472739F, 0.9983986810F,
- 0.9984488947F, 0.9984979328F, 0.9985458132F, 0.9985925534F,
- 0.9986381711F, 0.9986826838F, 0.9987261086F, 0.9987684630F,
- 0.9988097640F, 0.9988500286F, 0.9988892738F, 0.9989275163F,
- 0.9989647727F, 0.9990010597F, 0.9990363938F, 0.9990707911F,
- 0.9991042679F, 0.9991368404F, 0.9991685244F, 0.9991993358F,
- 0.9992292905F, 0.9992584038F, 0.9992866914F, 0.9993141686F,
- 0.9993408506F, 0.9993667526F, 0.9993918895F, 0.9994162761F,
- 0.9994399273F, 0.9994628576F, 0.9994850815F, 0.9995066133F,
- 0.9995274672F, 0.9995476574F, 0.9995671978F, 0.9995861021F,
- 0.9996043841F, 0.9996220573F, 0.9996391352F, 0.9996556310F,
- 0.9996715579F, 0.9996869288F, 0.9997017568F, 0.9997160543F,
- 0.9997298342F, 0.9997431088F, 0.9997558905F, 0.9997681914F,
- 0.9997800236F, 0.9997913990F, 0.9998023292F, 0.9998128261F,
- 0.9998229009F, 0.9998325650F, 0.9998418296F, 0.9998507058F,
- 0.9998592044F, 0.9998673362F, 0.9998751117F, 0.9998825415F,
- 0.9998896358F, 0.9998964047F, 0.9999028584F, 0.9999090066F,
- 0.9999148590F, 0.9999204253F, 0.9999257148F, 0.9999307368F,
- 0.9999355003F, 0.9999400144F, 0.9999442878F, 0.9999483293F,
- 0.9999521472F, 0.9999557499F, 0.9999591457F, 0.9999623426F,
- 0.9999653483F, 0.9999681708F, 0.9999708175F, 0.9999732959F,
- 0.9999756132F, 0.9999777765F, 0.9999797928F, 0.9999816688F,
- 0.9999834113F, 0.9999850266F, 0.9999865211F, 0.9999879009F,
- 0.9999891721F, 0.9999903405F, 0.9999914118F, 0.9999923914F,
- 0.9999932849F, 0.9999940972F, 0.9999948336F, 0.9999954989F,
- 0.9999960978F, 0.9999966349F, 0.9999971146F, 0.9999975411F,
- 0.9999979185F, 0.9999982507F, 0.9999985414F, 0.9999987944F,
- 0.9999990129F, 0.9999992003F, 0.9999993596F, 0.9999994939F,
- 0.9999996059F, 0.9999996981F, 0.9999997732F, 0.9999998333F,
- 0.9999998805F, 0.9999999170F, 0.9999999444F, 0.9999999643F,
- 0.9999999784F, 0.9999999878F, 0.9999999937F, 0.9999999972F,
- 0.9999999990F, 0.9999999997F, 1.0000000000F, 1.0000000000F,
-};
-
-DECLARE_ALIGNED(16, static const float, vwin4096)[2048] = {
- 0.0000002310F, 0.0000020791F, 0.0000057754F, 0.0000113197F,
- 0.0000187121F, 0.0000279526F, 0.0000390412F, 0.0000519777F,
- 0.0000667623F, 0.0000833949F, 0.0001018753F, 0.0001222036F,
- 0.0001443798F, 0.0001684037F, 0.0001942754F, 0.0002219947F,
- 0.0002515616F, 0.0002829761F, 0.0003162380F, 0.0003513472F,
- 0.0003883038F, 0.0004271076F, 0.0004677584F, 0.0005102563F,
- 0.0005546011F, 0.0006007928F, 0.0006488311F, 0.0006987160F,
- 0.0007504474F, 0.0008040251F, 0.0008594490F, 0.0009167191F,
- 0.0009758351F, 0.0010367969F, 0.0010996044F, 0.0011642574F,
- 0.0012307558F, 0.0012990994F, 0.0013692880F, 0.0014413216F,
- 0.0015151998F, 0.0015909226F, 0.0016684898F, 0.0017479011F,
- 0.0018291565F, 0.0019122556F, 0.0019971983F, 0.0020839845F,
- 0.0021726138F, 0.0022630861F, 0.0023554012F, 0.0024495588F,
- 0.0025455588F, 0.0026434008F, 0.0027430847F, 0.0028446103F,
- 0.0029479772F, 0.0030531853F, 0.0031602342F, 0.0032691238F,
- 0.0033798538F, 0.0034924239F, 0.0036068338F, 0.0037230833F,
- 0.0038411721F, 0.0039610999F, 0.0040828664F, 0.0042064714F,
- 0.0043319145F, 0.0044591954F, 0.0045883139F, 0.0047192696F,
- 0.0048520622F, 0.0049866914F, 0.0051231569F, 0.0052614583F,
- 0.0054015953F, 0.0055435676F, 0.0056873748F, 0.0058330166F,
- 0.0059804926F, 0.0061298026F, 0.0062809460F, 0.0064339226F,
- 0.0065887320F, 0.0067453738F, 0.0069038476F, 0.0070641531F,
- 0.0072262899F, 0.0073902575F, 0.0075560556F, 0.0077236838F,
- 0.0078931417F, 0.0080644288F, 0.0082375447F, 0.0084124891F,
- 0.0085892615F, 0.0087678614F, 0.0089482885F, 0.0091305422F,
- 0.0093146223F, 0.0095005281F, 0.0096882592F, 0.0098778153F,
- 0.0100691958F, 0.0102624002F, 0.0104574281F, 0.0106542791F,
- 0.0108529525F, 0.0110534480F, 0.0112557651F, 0.0114599032F,
- 0.0116658618F, 0.0118736405F, 0.0120832387F, 0.0122946560F,
- 0.0125078917F, 0.0127229454F, 0.0129398166F, 0.0131585046F,
- 0.0133790090F, 0.0136013292F, 0.0138254647F, 0.0140514149F,
- 0.0142791792F, 0.0145087572F, 0.0147401481F, 0.0149733515F,
- 0.0152083667F, 0.0154451932F, 0.0156838304F, 0.0159242777F,
- 0.0161665345F, 0.0164106001F, 0.0166564741F, 0.0169041557F,
- 0.0171536443F, 0.0174049393F, 0.0176580401F, 0.0179129461F,
- 0.0181696565F, 0.0184281708F, 0.0186884883F, 0.0189506084F,
- 0.0192145303F, 0.0194802535F, 0.0197477772F, 0.0200171008F,
- 0.0202882236F, 0.0205611449F, 0.0208358639F, 0.0211123801F,
- 0.0213906927F, 0.0216708011F, 0.0219527043F, 0.0222364019F,
- 0.0225218930F, 0.0228091769F, 0.0230982529F, 0.0233891203F,
- 0.0236817782F, 0.0239762259F, 0.0242724628F, 0.0245704880F,
- 0.0248703007F, 0.0251719002F, 0.0254752858F, 0.0257804565F,
- 0.0260874117F, 0.0263961506F, 0.0267066722F, 0.0270189760F,
- 0.0273330609F, 0.0276489263F, 0.0279665712F, 0.0282859949F,
- 0.0286071966F, 0.0289301753F, 0.0292549303F, 0.0295814607F,
- 0.0299097656F, 0.0302398442F, 0.0305716957F, 0.0309053191F,
- 0.0312407135F, 0.0315778782F, 0.0319168122F, 0.0322575145F,
- 0.0325999844F, 0.0329442209F, 0.0332902231F, 0.0336379900F,
- 0.0339875208F, 0.0343388146F, 0.0346918703F, 0.0350466871F,
- 0.0354032640F, 0.0357616000F, 0.0361216943F, 0.0364835458F,
- 0.0368471535F, 0.0372125166F, 0.0375796339F, 0.0379485046F,
- 0.0383191276F, 0.0386915020F, 0.0390656267F, 0.0394415008F,
- 0.0398191231F, 0.0401984927F, 0.0405796086F, 0.0409624698F,
- 0.0413470751F, 0.0417334235F, 0.0421215141F, 0.0425113457F,
- 0.0429029172F, 0.0432962277F, 0.0436912760F, 0.0440880610F,
- 0.0444865817F, 0.0448868370F, 0.0452888257F, 0.0456925468F,
- 0.0460979992F, 0.0465051816F, 0.0469140931F, 0.0473247325F,
- 0.0477370986F, 0.0481511902F, 0.0485670064F, 0.0489845458F,
- 0.0494038074F, 0.0498247899F, 0.0502474922F, 0.0506719131F,
- 0.0510980514F, 0.0515259060F, 0.0519554756F, 0.0523867590F,
- 0.0528197550F, 0.0532544624F, 0.0536908800F, 0.0541290066F,
- 0.0545688408F, 0.0550103815F, 0.0554536274F, 0.0558985772F,
- 0.0563452297F, 0.0567935837F, 0.0572436377F, 0.0576953907F,
- 0.0581488412F, 0.0586039880F, 0.0590608297F, 0.0595193651F,
- 0.0599795929F, 0.0604415117F, 0.0609051202F, 0.0613704170F,
- 0.0618374009F, 0.0623060704F, 0.0627764243F, 0.0632484611F,
- 0.0637221795F, 0.0641975781F, 0.0646746555F, 0.0651534104F,
- 0.0656338413F, 0.0661159469F, 0.0665997257F, 0.0670851763F,
- 0.0675722973F, 0.0680610873F, 0.0685515448F, 0.0690436684F,
- 0.0695374567F, 0.0700329081F, 0.0705300213F, 0.0710287947F,
- 0.0715292269F, 0.0720313163F, 0.0725350616F, 0.0730404612F,
- 0.0735475136F, 0.0740562172F, 0.0745665707F, 0.0750785723F,
- 0.0755922207F, 0.0761075143F, 0.0766244515F, 0.0771430307F,
- 0.0776632505F, 0.0781851092F, 0.0787086052F, 0.0792337371F,
- 0.0797605032F, 0.0802889018F, 0.0808189315F, 0.0813505905F,
- 0.0818838773F, 0.0824187903F, 0.0829553277F, 0.0834934881F,
- 0.0840332697F, 0.0845746708F, 0.0851176899F, 0.0856623252F,
- 0.0862085751F, 0.0867564379F, 0.0873059119F, 0.0878569954F,
- 0.0884096867F, 0.0889639840F, 0.0895198858F, 0.0900773902F,
- 0.0906364955F, 0.0911972000F, 0.0917595019F, 0.0923233995F,
- 0.0928888909F, 0.0934559745F, 0.0940246485F, 0.0945949110F,
- 0.0951667604F, 0.0957401946F, 0.0963152121F, 0.0968918109F,
- 0.0974699893F, 0.0980497454F, 0.0986310773F, 0.0992139832F,
- 0.0997984614F, 0.1003845098F, 0.1009721267F, 0.1015613101F,
- 0.1021520582F, 0.1027443692F, 0.1033382410F, 0.1039336718F,
- 0.1045306597F, 0.1051292027F, 0.1057292990F, 0.1063309466F,
- 0.1069341435F, 0.1075388878F, 0.1081451776F, 0.1087530108F,
- 0.1093623856F, 0.1099732998F, 0.1105857516F, 0.1111997389F,
- 0.1118152597F, 0.1124323121F, 0.1130508939F, 0.1136710032F,
- 0.1142926379F, 0.1149157960F, 0.1155404755F, 0.1161666742F,
- 0.1167943901F, 0.1174236211F, 0.1180543652F, 0.1186866202F,
- 0.1193203841F, 0.1199556548F, 0.1205924300F, 0.1212307078F,
- 0.1218704860F, 0.1225117624F, 0.1231545349F, 0.1237988013F,
- 0.1244445596F, 0.1250918074F, 0.1257405427F, 0.1263907632F,
- 0.1270424667F, 0.1276956512F, 0.1283503142F, 0.1290064537F,
- 0.1296640674F, 0.1303231530F, 0.1309837084F, 0.1316457312F,
- 0.1323092193F, 0.1329741703F, 0.1336405820F, 0.1343084520F,
- 0.1349777782F, 0.1356485582F, 0.1363207897F, 0.1369944704F,
- 0.1376695979F, 0.1383461700F, 0.1390241842F, 0.1397036384F,
- 0.1403845300F, 0.1410668567F, 0.1417506162F, 0.1424358061F,
- 0.1431224240F, 0.1438104674F, 0.1444999341F, 0.1451908216F,
- 0.1458831274F, 0.1465768492F, 0.1472719844F, 0.1479685308F,
- 0.1486664857F, 0.1493658468F, 0.1500666115F, 0.1507687775F,
- 0.1514723422F, 0.1521773031F, 0.1528836577F, 0.1535914035F,
- 0.1543005380F, 0.1550110587F, 0.1557229631F, 0.1564362485F,
- 0.1571509124F, 0.1578669524F, 0.1585843657F, 0.1593031499F,
- 0.1600233024F, 0.1607448205F, 0.1614677017F, 0.1621919433F,
- 0.1629175428F, 0.1636444975F, 0.1643728047F, 0.1651024619F,
- 0.1658334665F, 0.1665658156F, 0.1672995067F, 0.1680345371F,
- 0.1687709041F, 0.1695086050F, 0.1702476372F, 0.1709879978F,
- 0.1717296843F, 0.1724726938F, 0.1732170237F, 0.1739626711F,
- 0.1747096335F, 0.1754579079F, 0.1762074916F, 0.1769583819F,
- 0.1777105760F, 0.1784640710F, 0.1792188642F, 0.1799749529F,
- 0.1807323340F, 0.1814910049F, 0.1822509628F, 0.1830122046F,
- 0.1837747277F, 0.1845385292F, 0.1853036062F, 0.1860699558F,
- 0.1868375751F, 0.1876064613F, 0.1883766114F, 0.1891480226F,
- 0.1899206919F, 0.1906946164F, 0.1914697932F, 0.1922462194F,
- 0.1930238919F, 0.1938028079F, 0.1945829643F, 0.1953643583F,
- 0.1961469868F, 0.1969308468F, 0.1977159353F, 0.1985022494F,
- 0.1992897859F, 0.2000785420F, 0.2008685145F, 0.2016597005F,
- 0.2024520968F, 0.2032457005F, 0.2040405084F, 0.2048365175F,
- 0.2056337247F, 0.2064321269F, 0.2072317211F, 0.2080325041F,
- 0.2088344727F, 0.2096376240F, 0.2104419547F, 0.2112474618F,
- 0.2120541420F, 0.2128619923F, 0.2136710094F, 0.2144811902F,
- 0.2152925315F, 0.2161050301F, 0.2169186829F, 0.2177334866F,
- 0.2185494381F, 0.2193665340F, 0.2201847712F, 0.2210041465F,
- 0.2218246565F, 0.2226462981F, 0.2234690680F, 0.2242929629F,
- 0.2251179796F, 0.2259441147F, 0.2267713650F, 0.2275997272F,
- 0.2284291979F, 0.2292597739F, 0.2300914518F, 0.2309242283F,
- 0.2317581001F, 0.2325930638F, 0.2334291160F, 0.2342662534F,
- 0.2351044727F, 0.2359437703F, 0.2367841431F, 0.2376255875F,
- 0.2384681001F, 0.2393116776F, 0.2401563165F, 0.2410020134F,
- 0.2418487649F, 0.2426965675F, 0.2435454178F, 0.2443953122F,
- 0.2452462474F, 0.2460982199F, 0.2469512262F, 0.2478052628F,
- 0.2486603262F, 0.2495164129F, 0.2503735194F, 0.2512316421F,
- 0.2520907776F, 0.2529509222F, 0.2538120726F, 0.2546742250F,
- 0.2555373760F, 0.2564015219F, 0.2572666593F, 0.2581327845F,
- 0.2589998939F, 0.2598679840F, 0.2607370510F, 0.2616070916F,
- 0.2624781019F, 0.2633500783F, 0.2642230173F, 0.2650969152F,
- 0.2659717684F, 0.2668475731F, 0.2677243257F, 0.2686020226F,
- 0.2694806601F, 0.2703602344F, 0.2712407419F, 0.2721221789F,
- 0.2730045417F, 0.2738878265F, 0.2747720297F, 0.2756571474F,
- 0.2765431760F, 0.2774301117F, 0.2783179508F, 0.2792066895F,
- 0.2800963240F, 0.2809868505F, 0.2818782654F, 0.2827705647F,
- 0.2836637447F, 0.2845578016F, 0.2854527315F, 0.2863485307F,
- 0.2872451953F, 0.2881427215F, 0.2890411055F, 0.2899403433F,
- 0.2908404312F, 0.2917413654F, 0.2926431418F, 0.2935457567F,
- 0.2944492061F, 0.2953534863F, 0.2962585932F, 0.2971645230F,
- 0.2980712717F, 0.2989788356F, 0.2998872105F, 0.3007963927F,
- 0.3017063781F, 0.3026171629F, 0.3035287430F, 0.3044411145F,
- 0.3053542736F, 0.3062682161F, 0.3071829381F, 0.3080984356F,
- 0.3090147047F, 0.3099317413F, 0.3108495414F, 0.3117681011F,
- 0.3126874163F, 0.3136074830F, 0.3145282972F, 0.3154498548F,
- 0.3163721517F, 0.3172951841F, 0.3182189477F, 0.3191434385F,
- 0.3200686525F, 0.3209945856F, 0.3219212336F, 0.3228485927F,
- 0.3237766585F, 0.3247054271F, 0.3256348943F, 0.3265650560F,
- 0.3274959081F, 0.3284274465F, 0.3293596671F, 0.3302925657F,
- 0.3312261382F, 0.3321603804F, 0.3330952882F, 0.3340308574F,
- 0.3349670838F, 0.3359039634F, 0.3368414919F, 0.3377796651F,
- 0.3387184789F, 0.3396579290F, 0.3405980113F, 0.3415387216F,
- 0.3424800556F, 0.3434220091F, 0.3443645779F, 0.3453077578F,
- 0.3462515446F, 0.3471959340F, 0.3481409217F, 0.3490865036F,
- 0.3500326754F, 0.3509794328F, 0.3519267715F, 0.3528746873F,
- 0.3538231759F, 0.3547722330F, 0.3557218544F, 0.3566720357F,
- 0.3576227727F, 0.3585740610F, 0.3595258964F, 0.3604782745F,
- 0.3614311910F, 0.3623846417F, 0.3633386221F, 0.3642931280F,
- 0.3652481549F, 0.3662036987F, 0.3671597548F, 0.3681163191F,
- 0.3690733870F, 0.3700309544F, 0.3709890167F, 0.3719475696F,
- 0.3729066089F, 0.3738661299F, 0.3748261285F, 0.3757866002F,
- 0.3767475406F, 0.3777089453F, 0.3786708100F, 0.3796331302F,
- 0.3805959014F, 0.3815591194F, 0.3825227796F, 0.3834868777F,
- 0.3844514093F, 0.3854163698F, 0.3863817549F, 0.3873475601F,
- 0.3883137810F, 0.3892804131F, 0.3902474521F, 0.3912148933F,
- 0.3921827325F, 0.3931509650F, 0.3941195865F, 0.3950885925F,
- 0.3960579785F, 0.3970277400F, 0.3979978725F, 0.3989683716F,
- 0.3999392328F, 0.4009104516F, 0.4018820234F, 0.4028539438F,
- 0.4038262084F, 0.4047988125F, 0.4057717516F, 0.4067450214F,
- 0.4077186172F, 0.4086925345F, 0.4096667688F, 0.4106413155F,
- 0.4116161703F, 0.4125913284F, 0.4135667854F, 0.4145425368F,
- 0.4155185780F, 0.4164949044F, 0.4174715116F, 0.4184483949F,
- 0.4194255498F, 0.4204029718F, 0.4213806563F, 0.4223585987F,
- 0.4233367946F, 0.4243152392F, 0.4252939281F, 0.4262728566F,
- 0.4272520202F, 0.4282314144F, 0.4292110345F, 0.4301908760F,
- 0.4311709343F, 0.4321512047F, 0.4331316828F, 0.4341123639F,
- 0.4350932435F, 0.4360743168F, 0.4370555794F, 0.4380370267F,
- 0.4390186540F, 0.4400004567F, 0.4409824303F, 0.4419645701F,
- 0.4429468716F, 0.4439293300F, 0.4449119409F, 0.4458946996F,
- 0.4468776014F, 0.4478606418F, 0.4488438162F, 0.4498271199F,
- 0.4508105483F, 0.4517940967F, 0.4527777607F, 0.4537615355F,
- 0.4547454165F, 0.4557293991F, 0.4567134786F, 0.4576976505F,
- 0.4586819101F, 0.4596662527F, 0.4606506738F, 0.4616351687F,
- 0.4626197328F, 0.4636043614F, 0.4645890499F, 0.4655737936F,
- 0.4665585880F, 0.4675434284F, 0.4685283101F, 0.4695132286F,
- 0.4704981791F, 0.4714831570F, 0.4724681577F, 0.4734531766F,
- 0.4744382089F, 0.4754232501F, 0.4764082956F, 0.4773933406F,
- 0.4783783806F, 0.4793634108F, 0.4803484267F, 0.4813334237F,
- 0.4823183969F, 0.4833033419F, 0.4842882540F, 0.4852731285F,
- 0.4862579608F, 0.4872427462F, 0.4882274802F, 0.4892121580F,
- 0.4901967751F, 0.4911813267F, 0.4921658083F, 0.4931502151F,
- 0.4941345427F, 0.4951187863F, 0.4961029412F, 0.4970870029F,
- 0.4980709667F, 0.4990548280F, 0.5000385822F, 0.5010222245F,
- 0.5020057505F, 0.5029891553F, 0.5039724345F, 0.5049555834F,
- 0.5059385973F, 0.5069214716F, 0.5079042018F, 0.5088867831F,
- 0.5098692110F, 0.5108514808F, 0.5118335879F, 0.5128155277F,
- 0.5137972956F, 0.5147788869F, 0.5157602971F, 0.5167415215F,
- 0.5177225555F, 0.5187033945F, 0.5196840339F, 0.5206644692F,
- 0.5216446956F, 0.5226247086F, 0.5236045035F, 0.5245840759F,
- 0.5255634211F, 0.5265425344F, 0.5275214114F, 0.5285000474F,
- 0.5294784378F, 0.5304565781F, 0.5314344637F, 0.5324120899F,
- 0.5333894522F, 0.5343665461F, 0.5353433670F, 0.5363199102F,
- 0.5372961713F, 0.5382721457F, 0.5392478287F, 0.5402232159F,
- 0.5411983027F, 0.5421730845F, 0.5431475569F, 0.5441217151F,
- 0.5450955548F, 0.5460690714F, 0.5470422602F, 0.5480151169F,
- 0.5489876368F, 0.5499598155F, 0.5509316484F, 0.5519031310F,
- 0.5528742587F, 0.5538450271F, 0.5548154317F, 0.5557854680F,
- 0.5567551314F, 0.5577244174F, 0.5586933216F, 0.5596618395F,
- 0.5606299665F, 0.5615976983F, 0.5625650302F, 0.5635319580F,
- 0.5644984770F, 0.5654645828F, 0.5664302709F, 0.5673955370F,
- 0.5683603765F, 0.5693247850F, 0.5702887580F, 0.5712522912F,
- 0.5722153800F, 0.5731780200F, 0.5741402069F, 0.5751019362F,
- 0.5760632034F, 0.5770240042F, 0.5779843341F, 0.5789441889F,
- 0.5799035639F, 0.5808624549F, 0.5818208575F, 0.5827787673F,
- 0.5837361800F, 0.5846930910F, 0.5856494961F, 0.5866053910F,
- 0.5875607712F, 0.5885156324F, 0.5894699703F, 0.5904237804F,
- 0.5913770586F, 0.5923298004F, 0.5932820016F, 0.5942336578F,
- 0.5951847646F, 0.5961353179F, 0.5970853132F, 0.5980347464F,
- 0.5989836131F, 0.5999319090F, 0.6008796298F, 0.6018267713F,
- 0.6027733292F, 0.6037192993F, 0.6046646773F, 0.6056094589F,
- 0.6065536400F, 0.6074972162F, 0.6084401833F, 0.6093825372F,
- 0.6103242736F, 0.6112653884F, 0.6122058772F, 0.6131457359F,
- 0.6140849604F, 0.6150235464F, 0.6159614897F, 0.6168987862F,
- 0.6178354318F, 0.6187714223F, 0.6197067535F, 0.6206414213F,
- 0.6215754215F, 0.6225087501F, 0.6234414028F, 0.6243733757F,
- 0.6253046646F, 0.6262352654F, 0.6271651739F, 0.6280943862F,
- 0.6290228982F, 0.6299507057F, 0.6308778048F, 0.6318041913F,
- 0.6327298612F, 0.6336548105F, 0.6345790352F, 0.6355025312F,
- 0.6364252945F, 0.6373473211F, 0.6382686070F, 0.6391891483F,
- 0.6401089409F, 0.6410279808F, 0.6419462642F, 0.6428637869F,
- 0.6437805452F, 0.6446965350F, 0.6456117524F, 0.6465261935F,
- 0.6474398544F, 0.6483527311F, 0.6492648197F, 0.6501761165F,
- 0.6510866174F, 0.6519963186F, 0.6529052162F, 0.6538133064F,
- 0.6547205854F, 0.6556270492F, 0.6565326941F, 0.6574375162F,
- 0.6583415117F, 0.6592446769F, 0.6601470079F, 0.6610485009F,
- 0.6619491521F, 0.6628489578F, 0.6637479143F, 0.6646460177F,
- 0.6655432643F, 0.6664396505F, 0.6673351724F, 0.6682298264F,
- 0.6691236087F, 0.6700165157F, 0.6709085436F, 0.6717996889F,
- 0.6726899478F, 0.6735793167F, 0.6744677918F, 0.6753553697F,
- 0.6762420466F, 0.6771278190F, 0.6780126832F, 0.6788966357F,
- 0.6797796728F, 0.6806617909F, 0.6815429866F, 0.6824232562F,
- 0.6833025961F, 0.6841810030F, 0.6850584731F, 0.6859350031F,
- 0.6868105894F, 0.6876852284F, 0.6885589168F, 0.6894316510F,
- 0.6903034275F, 0.6911742430F, 0.6920440939F, 0.6929129769F,
- 0.6937808884F, 0.6946478251F, 0.6955137837F, 0.6963787606F,
- 0.6972427525F, 0.6981057560F, 0.6989677678F, 0.6998287845F,
- 0.7006888028F, 0.7015478194F, 0.7024058309F, 0.7032628340F,
- 0.7041188254F, 0.7049738019F, 0.7058277601F, 0.7066806969F,
- 0.7075326089F, 0.7083834929F, 0.7092333457F, 0.7100821640F,
- 0.7109299447F, 0.7117766846F, 0.7126223804F, 0.7134670291F,
- 0.7143106273F, 0.7151531721F, 0.7159946602F, 0.7168350885F,
- 0.7176744539F, 0.7185127534F, 0.7193499837F, 0.7201861418F,
- 0.7210212247F, 0.7218552293F, 0.7226881526F, 0.7235199914F,
- 0.7243507428F, 0.7251804039F, 0.7260089715F, 0.7268364426F,
- 0.7276628144F, 0.7284880839F, 0.7293122481F, 0.7301353040F,
- 0.7309572487F, 0.7317780794F, 0.7325977930F, 0.7334163868F,
- 0.7342338579F, 0.7350502033F, 0.7358654202F, 0.7366795059F,
- 0.7374924573F, 0.7383042718F, 0.7391149465F, 0.7399244787F,
- 0.7407328655F, 0.7415401041F, 0.7423461920F, 0.7431511261F,
- 0.7439549040F, 0.7447575227F, 0.7455589797F, 0.7463592723F,
- 0.7471583976F, 0.7479563532F, 0.7487531363F, 0.7495487443F,
- 0.7503431745F, 0.7511364244F, 0.7519284913F, 0.7527193726F,
- 0.7535090658F, 0.7542975683F, 0.7550848776F, 0.7558709910F,
- 0.7566559062F, 0.7574396205F, 0.7582221314F, 0.7590034366F,
- 0.7597835334F, 0.7605624194F, 0.7613400923F, 0.7621165495F,
- 0.7628917886F, 0.7636658072F, 0.7644386030F, 0.7652101735F,
- 0.7659805164F, 0.7667496292F, 0.7675175098F, 0.7682841556F,
- 0.7690495645F, 0.7698137341F, 0.7705766622F, 0.7713383463F,
- 0.7720987844F, 0.7728579741F, 0.7736159132F, 0.7743725994F,
- 0.7751280306F, 0.7758822046F, 0.7766351192F, 0.7773867722F,
- 0.7781371614F, 0.7788862848F, 0.7796341401F, 0.7803807253F,
- 0.7811260383F, 0.7818700769F, 0.7826128392F, 0.7833543230F,
- 0.7840945263F, 0.7848334471F, 0.7855710833F, 0.7863074330F,
- 0.7870424941F, 0.7877762647F, 0.7885087428F, 0.7892399264F,
- 0.7899698137F, 0.7906984026F, 0.7914256914F, 0.7921516780F,
- 0.7928763607F, 0.7935997375F, 0.7943218065F, 0.7950425661F,
- 0.7957620142F, 0.7964801492F, 0.7971969692F, 0.7979124724F,
- 0.7986266570F, 0.7993395214F, 0.8000510638F, 0.8007612823F,
- 0.8014701754F, 0.8021777413F, 0.8028839784F, 0.8035888849F,
- 0.8042924592F, 0.8049946997F, 0.8056956048F, 0.8063951727F,
- 0.8070934020F, 0.8077902910F, 0.8084858381F, 0.8091800419F,
- 0.8098729007F, 0.8105644130F, 0.8112545774F, 0.8119433922F,
- 0.8126308561F, 0.8133169676F, 0.8140017251F, 0.8146851272F,
- 0.8153671726F, 0.8160478598F, 0.8167271874F, 0.8174051539F,
- 0.8180817582F, 0.8187569986F, 0.8194308741F, 0.8201033831F,
- 0.8207745244F, 0.8214442966F, 0.8221126986F, 0.8227797290F,
- 0.8234453865F, 0.8241096700F, 0.8247725781F, 0.8254341097F,
- 0.8260942636F, 0.8267530385F, 0.8274104334F, 0.8280664470F,
- 0.8287210782F, 0.8293743259F, 0.8300261889F, 0.8306766662F,
- 0.8313257566F, 0.8319734591F, 0.8326197727F, 0.8332646963F,
- 0.8339082288F, 0.8345503692F, 0.8351911167F, 0.8358304700F,
- 0.8364684284F, 0.8371049907F, 0.8377401562F, 0.8383739238F,
- 0.8390062927F, 0.8396372618F, 0.8402668305F, 0.8408949977F,
- 0.8415217626F, 0.8421471245F, 0.8427710823F, 0.8433936354F,
- 0.8440147830F, 0.8446345242F, 0.8452528582F, 0.8458697844F,
- 0.8464853020F, 0.8470994102F, 0.8477121084F, 0.8483233958F,
- 0.8489332718F, 0.8495417356F, 0.8501487866F, 0.8507544243F,
- 0.8513586479F, 0.8519614568F, 0.8525628505F, 0.8531628283F,
- 0.8537613897F, 0.8543585341F, 0.8549542611F, 0.8555485699F,
- 0.8561414603F, 0.8567329315F, 0.8573229832F, 0.8579116149F,
- 0.8584988262F, 0.8590846165F, 0.8596689855F, 0.8602519327F,
- 0.8608334577F, 0.8614135603F, 0.8619922399F, 0.8625694962F,
- 0.8631453289F, 0.8637197377F, 0.8642927222F, 0.8648642821F,
- 0.8654344172F, 0.8660031272F, 0.8665704118F, 0.8671362708F,
- 0.8677007039F, 0.8682637109F, 0.8688252917F, 0.8693854460F,
- 0.8699441737F, 0.8705014745F, 0.8710573485F, 0.8716117953F,
- 0.8721648150F, 0.8727164073F, 0.8732665723F, 0.8738153098F,
- 0.8743626197F, 0.8749085021F, 0.8754529569F, 0.8759959840F,
- 0.8765375835F, 0.8770777553F, 0.8776164996F, 0.8781538162F,
- 0.8786897054F, 0.8792241670F, 0.8797572013F, 0.8802888082F,
- 0.8808189880F, 0.8813477407F, 0.8818750664F, 0.8824009653F,
- 0.8829254375F, 0.8834484833F, 0.8839701028F, 0.8844902961F,
- 0.8850090636F, 0.8855264054F, 0.8860423218F, 0.8865568131F,
- 0.8870698794F, 0.8875815212F, 0.8880917386F, 0.8886005319F,
- 0.8891079016F, 0.8896138479F, 0.8901183712F, 0.8906214719F,
- 0.8911231503F, 0.8916234067F, 0.8921222417F, 0.8926196556F,
- 0.8931156489F, 0.8936102219F, 0.8941033752F, 0.8945951092F,
- 0.8950854244F, 0.8955743212F, 0.8960618003F, 0.8965478621F,
- 0.8970325071F, 0.8975157359F, 0.8979975490F, 0.8984779471F,
- 0.8989569307F, 0.8994345004F, 0.8999106568F, 0.9003854005F,
- 0.9008587323F, 0.9013306526F, 0.9018011623F, 0.9022702619F,
- 0.9027379521F, 0.9032042337F, 0.9036691074F, 0.9041325739F,
- 0.9045946339F, 0.9050552882F, 0.9055145376F, 0.9059723828F,
- 0.9064288246F, 0.9068838638F, 0.9073375013F, 0.9077897379F,
- 0.9082405743F, 0.9086900115F, 0.9091380503F, 0.9095846917F,
- 0.9100299364F, 0.9104737854F, 0.9109162397F, 0.9113573001F,
- 0.9117969675F, 0.9122352430F, 0.9126721275F, 0.9131076219F,
- 0.9135417273F, 0.9139744447F, 0.9144057750F, 0.9148357194F,
- 0.9152642787F, 0.9156914542F, 0.9161172468F, 0.9165416576F,
- 0.9169646877F, 0.9173863382F, 0.9178066102F, 0.9182255048F,
- 0.9186430232F, 0.9190591665F, 0.9194739359F, 0.9198873324F,
- 0.9202993574F, 0.9207100120F, 0.9211192973F, 0.9215272147F,
- 0.9219337653F, 0.9223389504F, 0.9227427713F, 0.9231452290F,
- 0.9235463251F, 0.9239460607F, 0.9243444371F, 0.9247414557F,
- 0.9251371177F, 0.9255314245F, 0.9259243774F, 0.9263159778F,
- 0.9267062270F, 0.9270951264F, 0.9274826774F, 0.9278688814F,
- 0.9282537398F, 0.9286372540F, 0.9290194254F, 0.9294002555F,
- 0.9297797458F, 0.9301578976F, 0.9305347125F, 0.9309101919F,
- 0.9312843373F, 0.9316571503F, 0.9320286323F, 0.9323987849F,
- 0.9327676097F, 0.9331351080F, 0.9335012816F, 0.9338661320F,
- 0.9342296607F, 0.9345918694F, 0.9349527596F, 0.9353123330F,
- 0.9356705911F, 0.9360275357F, 0.9363831683F, 0.9367374905F,
- 0.9370905042F, 0.9374422108F, 0.9377926122F, 0.9381417099F,
- 0.9384895057F, 0.9388360014F, 0.9391811985F, 0.9395250989F,
- 0.9398677043F, 0.9402090165F, 0.9405490371F, 0.9408877680F,
- 0.9412252110F, 0.9415613678F, 0.9418962402F, 0.9422298301F,
- 0.9425621392F, 0.9428931695F, 0.9432229226F, 0.9435514005F,
- 0.9438786050F, 0.9442045381F, 0.9445292014F, 0.9448525971F,
- 0.9451747268F, 0.9454955926F, 0.9458151963F, 0.9461335399F,
- 0.9464506253F, 0.9467664545F, 0.9470810293F, 0.9473943517F,
- 0.9477064238F, 0.9480172474F, 0.9483268246F, 0.9486351573F,
- 0.9489422475F, 0.9492480973F, 0.9495527087F, 0.9498560837F,
- 0.9501582243F, 0.9504591325F, 0.9507588105F, 0.9510572603F,
- 0.9513544839F, 0.9516504834F, 0.9519452609F, 0.9522388186F,
- 0.9525311584F, 0.9528222826F, 0.9531121932F, 0.9534008923F,
- 0.9536883821F, 0.9539746647F, 0.9542597424F, 0.9545436171F,
- 0.9548262912F, 0.9551077667F, 0.9553880459F, 0.9556671309F,
- 0.9559450239F, 0.9562217272F, 0.9564972429F, 0.9567715733F,
- 0.9570447206F, 0.9573166871F, 0.9575874749F, 0.9578570863F,
- 0.9581255236F, 0.9583927890F, 0.9586588849F, 0.9589238134F,
- 0.9591875769F, 0.9594501777F, 0.9597116180F, 0.9599719003F,
- 0.9602310267F, 0.9604889995F, 0.9607458213F, 0.9610014942F,
- 0.9612560206F, 0.9615094028F, 0.9617616433F, 0.9620127443F,
- 0.9622627083F, 0.9625115376F, 0.9627592345F, 0.9630058016F,
- 0.9632512411F, 0.9634955555F, 0.9637387471F, 0.9639808185F,
- 0.9642217720F, 0.9644616100F, 0.9647003349F, 0.9649379493F,
- 0.9651744556F, 0.9654098561F, 0.9656441534F, 0.9658773499F,
- 0.9661094480F, 0.9663404504F, 0.9665703593F, 0.9667991774F,
- 0.9670269071F, 0.9672535509F, 0.9674791114F, 0.9677035909F,
- 0.9679269921F, 0.9681493174F, 0.9683705694F, 0.9685907506F,
- 0.9688098636F, 0.9690279108F, 0.9692448948F, 0.9694608182F,
- 0.9696756836F, 0.9698894934F, 0.9701022503F, 0.9703139569F,
- 0.9705246156F, 0.9707342291F, 0.9709428000F, 0.9711503309F,
- 0.9713568243F, 0.9715622829F, 0.9717667093F, 0.9719701060F,
- 0.9721724757F, 0.9723738210F, 0.9725741446F, 0.9727734490F,
- 0.9729717369F, 0.9731690109F, 0.9733652737F, 0.9735605279F,
- 0.9737547762F, 0.9739480212F, 0.9741402656F, 0.9743315120F,
- 0.9745217631F, 0.9747110216F, 0.9748992901F, 0.9750865714F,
- 0.9752728681F, 0.9754581829F, 0.9756425184F, 0.9758258775F,
- 0.9760082627F, 0.9761896768F, 0.9763701224F, 0.9765496024F,
- 0.9767281193F, 0.9769056760F, 0.9770822751F, 0.9772579193F,
- 0.9774326114F, 0.9776063542F, 0.9777791502F, 0.9779510023F,
- 0.9781219133F, 0.9782918858F, 0.9784609226F, 0.9786290264F,
- 0.9787962000F, 0.9789624461F, 0.9791277676F, 0.9792921671F,
- 0.9794556474F, 0.9796182113F, 0.9797798615F, 0.9799406009F,
- 0.9801004321F, 0.9802593580F, 0.9804173813F, 0.9805745049F,
- 0.9807307314F, 0.9808860637F, 0.9810405046F, 0.9811940568F,
- 0.9813467232F, 0.9814985065F, 0.9816494095F, 0.9817994351F,
- 0.9819485860F, 0.9820968650F, 0.9822442750F, 0.9823908186F,
- 0.9825364988F, 0.9826813184F, 0.9828252801F, 0.9829683868F,
- 0.9831106413F, 0.9832520463F, 0.9833926048F, 0.9835323195F,
- 0.9836711932F, 0.9838092288F, 0.9839464291F, 0.9840827969F,
- 0.9842183351F, 0.9843530464F, 0.9844869337F, 0.9846199998F,
- 0.9847522475F, 0.9848836798F, 0.9850142993F, 0.9851441090F,
- 0.9852731117F, 0.9854013101F, 0.9855287073F, 0.9856553058F,
- 0.9857811087F, 0.9859061188F, 0.9860303388F, 0.9861537717F,
- 0.9862764202F, 0.9863982872F, 0.9865193756F, 0.9866396882F,
- 0.9867592277F, 0.9868779972F, 0.9869959993F, 0.9871132370F,
- 0.9872297131F, 0.9873454304F, 0.9874603918F, 0.9875746001F,
- 0.9876880581F, 0.9878007688F, 0.9879127348F, 0.9880239592F,
- 0.9881344447F, 0.9882441941F, 0.9883532104F, 0.9884614962F,
- 0.9885690546F, 0.9886758883F, 0.9887820001F, 0.9888873930F,
- 0.9889920697F, 0.9890960331F, 0.9891992859F, 0.9893018312F,
- 0.9894036716F, 0.9895048100F, 0.9896052493F, 0.9897049923F,
- 0.9898040418F, 0.9899024006F, 0.9900000717F, 0.9900970577F,
- 0.9901933616F, 0.9902889862F, 0.9903839343F, 0.9904782087F,
- 0.9905718122F, 0.9906647477F, 0.9907570180F, 0.9908486259F,
- 0.9909395742F, 0.9910298658F, 0.9911195034F, 0.9912084899F,
- 0.9912968281F, 0.9913845208F, 0.9914715708F, 0.9915579810F,
- 0.9916437540F, 0.9917288928F, 0.9918134001F, 0.9918972788F,
- 0.9919805316F, 0.9920631613F, 0.9921451707F, 0.9922265626F,
- 0.9923073399F, 0.9923875052F, 0.9924670615F, 0.9925460114F,
- 0.9926243577F, 0.9927021033F, 0.9927792508F, 0.9928558032F,
- 0.9929317631F, 0.9930071333F, 0.9930819167F, 0.9931561158F,
- 0.9932297337F, 0.9933027728F, 0.9933752362F, 0.9934471264F,
- 0.9935184462F, 0.9935891985F, 0.9936593859F, 0.9937290112F,
- 0.9937980771F, 0.9938665864F, 0.9939345418F, 0.9940019460F,
- 0.9940688018F, 0.9941351118F, 0.9942008789F, 0.9942661057F,
- 0.9943307950F, 0.9943949494F, 0.9944585717F, 0.9945216645F,
- 0.9945842307F, 0.9946462728F, 0.9947077936F, 0.9947687957F,
- 0.9948292820F, 0.9948892550F, 0.9949487174F, 0.9950076719F,
- 0.9950661212F, 0.9951240679F, 0.9951815148F, 0.9952384645F,
- 0.9952949196F, 0.9953508828F, 0.9954063568F, 0.9954613442F,
- 0.9955158476F, 0.9955698697F, 0.9956234132F, 0.9956764806F,
- 0.9957290746F, 0.9957811978F, 0.9958328528F, 0.9958840423F,
- 0.9959347688F, 0.9959850351F, 0.9960348435F, 0.9960841969F,
- 0.9961330977F, 0.9961815486F, 0.9962295521F, 0.9962771108F,
- 0.9963242274F, 0.9963709043F, 0.9964171441F, 0.9964629494F,
- 0.9965083228F, 0.9965532668F, 0.9965977840F, 0.9966418768F,
- 0.9966855479F, 0.9967287998F, 0.9967716350F, 0.9968140559F,
- 0.9968560653F, 0.9968976655F, 0.9969388591F, 0.9969796485F,
- 0.9970200363F, 0.9970600250F, 0.9970996170F, 0.9971388149F,
- 0.9971776211F, 0.9972160380F, 0.9972540683F, 0.9972917142F,
- 0.9973289783F, 0.9973658631F, 0.9974023709F, 0.9974385042F,
- 0.9974742655F, 0.9975096571F, 0.9975446816F, 0.9975793413F,
- 0.9976136386F, 0.9976475759F, 0.9976811557F, 0.9977143803F,
- 0.9977472521F, 0.9977797736F, 0.9978119470F, 0.9978437748F,
- 0.9978752593F, 0.9979064029F, 0.9979372079F, 0.9979676768F,
- 0.9979978117F, 0.9980276151F, 0.9980570893F, 0.9980862367F,
- 0.9981150595F, 0.9981435600F, 0.9981717406F, 0.9981996035F,
- 0.9982271511F, 0.9982543856F, 0.9982813093F, 0.9983079246F,
- 0.9983342336F, 0.9983602386F, 0.9983859418F, 0.9984113456F,
- 0.9984364522F, 0.9984612638F, 0.9984857825F, 0.9985100108F,
- 0.9985339507F, 0.9985576044F, 0.9985809743F, 0.9986040624F,
- 0.9986268710F, 0.9986494022F, 0.9986716583F, 0.9986936413F,
- 0.9987153535F, 0.9987367969F, 0.9987579738F, 0.9987788864F,
- 0.9987995366F, 0.9988199267F, 0.9988400587F, 0.9988599348F,
- 0.9988795572F, 0.9988989278F, 0.9989180487F, 0.9989369222F,
- 0.9989555501F, 0.9989739347F, 0.9989920780F, 0.9990099820F,
- 0.9990276487F, 0.9990450803F, 0.9990622787F, 0.9990792460F,
- 0.9990959841F, 0.9991124952F, 0.9991287812F, 0.9991448440F,
- 0.9991606858F, 0.9991763084F, 0.9991917139F, 0.9992069042F,
- 0.9992218813F, 0.9992366471F, 0.9992512035F, 0.9992655525F,
- 0.9992796961F, 0.9992936361F, 0.9993073744F, 0.9993209131F,
- 0.9993342538F, 0.9993473987F, 0.9993603494F, 0.9993731080F,
- 0.9993856762F, 0.9993980559F, 0.9994102490F, 0.9994222573F,
- 0.9994340827F, 0.9994457269F, 0.9994571918F, 0.9994684793F,
- 0.9994795910F, 0.9994905288F, 0.9995012945F, 0.9995118898F,
- 0.9995223165F, 0.9995325765F, 0.9995426713F, 0.9995526029F,
- 0.9995623728F, 0.9995719829F, 0.9995814349F, 0.9995907304F,
- 0.9995998712F, 0.9996088590F, 0.9996176954F, 0.9996263821F,
- 0.9996349208F, 0.9996433132F, 0.9996515609F, 0.9996596656F,
- 0.9996676288F, 0.9996754522F, 0.9996831375F, 0.9996906862F,
- 0.9996981000F, 0.9997053804F, 0.9997125290F, 0.9997195474F,
- 0.9997264371F, 0.9997331998F, 0.9997398369F, 0.9997463500F,
- 0.9997527406F, 0.9997590103F, 0.9997651606F, 0.9997711930F,
- 0.9997771089F, 0.9997829098F, 0.9997885973F, 0.9997941728F,
- 0.9997996378F, 0.9998049936F, 0.9998102419F, 0.9998153839F,
- 0.9998204211F, 0.9998253550F, 0.9998301868F, 0.9998349182F,
- 0.9998395503F, 0.9998440847F, 0.9998485226F, 0.9998528654F,
- 0.9998571146F, 0.9998612713F, 0.9998653370F, 0.9998693130F,
- 0.9998732007F, 0.9998770012F, 0.9998807159F, 0.9998843461F,
- 0.9998878931F, 0.9998913581F, 0.9998947424F, 0.9998980473F,
- 0.9999012740F, 0.9999044237F, 0.9999074976F, 0.9999104971F,
- 0.9999134231F, 0.9999162771F, 0.9999190601F, 0.9999217733F,
- 0.9999244179F, 0.9999269950F, 0.9999295058F, 0.9999319515F,
- 0.9999343332F, 0.9999366519F, 0.9999389088F, 0.9999411050F,
- 0.9999432416F, 0.9999453196F, 0.9999473402F, 0.9999493044F,
- 0.9999512132F, 0.9999530677F, 0.9999548690F, 0.9999566180F,
- 0.9999583157F, 0.9999599633F, 0.9999615616F, 0.9999631116F,
- 0.9999646144F, 0.9999660709F, 0.9999674820F, 0.9999688487F,
- 0.9999701719F, 0.9999714526F, 0.9999726917F, 0.9999738900F,
- 0.9999750486F, 0.9999761682F, 0.9999772497F, 0.9999782941F,
- 0.9999793021F, 0.9999802747F, 0.9999812126F, 0.9999821167F,
- 0.9999829878F, 0.9999838268F, 0.9999846343F, 0.9999854113F,
- 0.9999861584F, 0.9999868765F, 0.9999875664F, 0.9999882287F,
- 0.9999888642F, 0.9999894736F, 0.9999900577F, 0.9999906172F,
- 0.9999911528F, 0.9999916651F, 0.9999921548F, 0.9999926227F,
- 0.9999930693F, 0.9999934954F, 0.9999939015F, 0.9999942883F,
- 0.9999946564F, 0.9999950064F, 0.9999953390F, 0.9999956547F,
- 0.9999959541F, 0.9999962377F, 0.9999965062F, 0.9999967601F,
- 0.9999969998F, 0.9999972260F, 0.9999974392F, 0.9999976399F,
- 0.9999978285F, 0.9999980056F, 0.9999981716F, 0.9999983271F,
- 0.9999984724F, 0.9999986081F, 0.9999987345F, 0.9999988521F,
- 0.9999989613F, 0.9999990625F, 0.9999991562F, 0.9999992426F,
- 0.9999993223F, 0.9999993954F, 0.9999994625F, 0.9999995239F,
- 0.9999995798F, 0.9999996307F, 0.9999996768F, 0.9999997184F,
- 0.9999997559F, 0.9999997895F, 0.9999998195F, 0.9999998462F,
- 0.9999998698F, 0.9999998906F, 0.9999999088F, 0.9999999246F,
- 0.9999999383F, 0.9999999500F, 0.9999999600F, 0.9999999684F,
- 0.9999999754F, 0.9999999811F, 0.9999999858F, 0.9999999896F,
- 0.9999999925F, 0.9999999948F, 0.9999999965F, 0.9999999978F,
- 0.9999999986F, 0.9999999992F, 0.9999999996F, 0.9999999998F,
- 0.9999999999F, 1.0000000000F, 1.0000000000F, 1.0000000000F,
-};
-
-DECLARE_ALIGNED(16, static const float, vwin8192)[4096] = {
- 0.0000000578F, 0.0000005198F, 0.0000014438F, 0.0000028299F,
- 0.0000046780F, 0.0000069882F, 0.0000097604F, 0.0000129945F,
- 0.0000166908F, 0.0000208490F, 0.0000254692F, 0.0000305515F,
- 0.0000360958F, 0.0000421021F, 0.0000485704F, 0.0000555006F,
- 0.0000628929F, 0.0000707472F, 0.0000790635F, 0.0000878417F,
- 0.0000970820F, 0.0001067842F, 0.0001169483F, 0.0001275744F,
- 0.0001386625F, 0.0001502126F, 0.0001622245F, 0.0001746984F,
- 0.0001876343F, 0.0002010320F, 0.0002148917F, 0.0002292132F,
- 0.0002439967F, 0.0002592421F, 0.0002749493F, 0.0002911184F,
- 0.0003077493F, 0.0003248421F, 0.0003423967F, 0.0003604132F,
- 0.0003788915F, 0.0003978316F, 0.0004172335F, 0.0004370971F,
- 0.0004574226F, 0.0004782098F, 0.0004994587F, 0.0005211694F,
- 0.0005433418F, 0.0005659759F, 0.0005890717F, 0.0006126292F,
- 0.0006366484F, 0.0006611292F, 0.0006860716F, 0.0007114757F,
- 0.0007373414F, 0.0007636687F, 0.0007904576F, 0.0008177080F,
- 0.0008454200F, 0.0008735935F, 0.0009022285F, 0.0009313250F,
- 0.0009608830F, 0.0009909025F, 0.0010213834F, 0.0010523257F,
- 0.0010837295F, 0.0011155946F, 0.0011479211F, 0.0011807090F,
- 0.0012139582F, 0.0012476687F, 0.0012818405F, 0.0013164736F,
- 0.0013515679F, 0.0013871235F, 0.0014231402F, 0.0014596182F,
- 0.0014965573F, 0.0015339576F, 0.0015718190F, 0.0016101415F,
- 0.0016489251F, 0.0016881698F, 0.0017278754F, 0.0017680421F,
- 0.0018086698F, 0.0018497584F, 0.0018913080F, 0.0019333185F,
- 0.0019757898F, 0.0020187221F, 0.0020621151F, 0.0021059690F,
- 0.0021502837F, 0.0021950591F, 0.0022402953F, 0.0022859921F,
- 0.0023321497F, 0.0023787679F, 0.0024258467F, 0.0024733861F,
- 0.0025213861F, 0.0025698466F, 0.0026187676F, 0.0026681491F,
- 0.0027179911F, 0.0027682935F, 0.0028190562F, 0.0028702794F,
- 0.0029219628F, 0.0029741066F, 0.0030267107F, 0.0030797749F,
- 0.0031332994F, 0.0031872841F, 0.0032417289F, 0.0032966338F,
- 0.0033519988F, 0.0034078238F, 0.0034641089F, 0.0035208539F,
- 0.0035780589F, 0.0036357237F, 0.0036938485F, 0.0037524331F,
- 0.0038114775F, 0.0038709817F, 0.0039309456F, 0.0039913692F,
- 0.0040522524F, 0.0041135953F, 0.0041753978F, 0.0042376599F,
- 0.0043003814F, 0.0043635624F, 0.0044272029F, 0.0044913028F,
- 0.0045558620F, 0.0046208806F, 0.0046863585F, 0.0047522955F,
- 0.0048186919F, 0.0048855473F, 0.0049528619F, 0.0050206356F,
- 0.0050888684F, 0.0051575601F, 0.0052267108F, 0.0052963204F,
- 0.0053663890F, 0.0054369163F, 0.0055079025F, 0.0055793474F,
- 0.0056512510F, 0.0057236133F, 0.0057964342F, 0.0058697137F,
- 0.0059434517F, 0.0060176482F, 0.0060923032F, 0.0061674166F,
- 0.0062429883F, 0.0063190183F, 0.0063955066F, 0.0064724532F,
- 0.0065498579F, 0.0066277207F, 0.0067060416F, 0.0067848205F,
- 0.0068640575F, 0.0069437523F, 0.0070239051F, 0.0071045157F,
- 0.0071855840F, 0.0072671102F, 0.0073490940F, 0.0074315355F,
- 0.0075144345F, 0.0075977911F, 0.0076816052F, 0.0077658768F,
- 0.0078506057F, 0.0079357920F, 0.0080214355F, 0.0081075363F,
- 0.0081940943F, 0.0082811094F, 0.0083685816F, 0.0084565108F,
- 0.0085448970F, 0.0086337401F, 0.0087230401F, 0.0088127969F,
- 0.0089030104F, 0.0089936807F, 0.0090848076F, 0.0091763911F,
- 0.0092684311F, 0.0093609276F, 0.0094538805F, 0.0095472898F,
- 0.0096411554F, 0.0097354772F, 0.0098302552F, 0.0099254894F,
- 0.0100211796F, 0.0101173259F, 0.0102139281F, 0.0103109863F,
- 0.0104085002F, 0.0105064700F, 0.0106048955F, 0.0107037766F,
- 0.0108031133F, 0.0109029056F, 0.0110031534F, 0.0111038565F,
- 0.0112050151F, 0.0113066289F, 0.0114086980F, 0.0115112222F,
- 0.0116142015F, 0.0117176359F, 0.0118215252F, 0.0119258695F,
- 0.0120306686F, 0.0121359225F, 0.0122416312F, 0.0123477944F,
- 0.0124544123F, 0.0125614847F, 0.0126690116F, 0.0127769928F,
- 0.0128854284F, 0.0129943182F, 0.0131036623F, 0.0132134604F,
- 0.0133237126F, 0.0134344188F, 0.0135455790F, 0.0136571929F,
- 0.0137692607F, 0.0138817821F, 0.0139947572F, 0.0141081859F,
- 0.0142220681F, 0.0143364037F, 0.0144511927F, 0.0145664350F,
- 0.0146821304F, 0.0147982791F, 0.0149148808F, 0.0150319355F,
- 0.0151494431F, 0.0152674036F, 0.0153858168F, 0.0155046828F,
- 0.0156240014F, 0.0157437726F, 0.0158639962F, 0.0159846723F,
- 0.0161058007F, 0.0162273814F, 0.0163494142F, 0.0164718991F,
- 0.0165948361F, 0.0167182250F, 0.0168420658F, 0.0169663584F,
- 0.0170911027F, 0.0172162987F, 0.0173419462F, 0.0174680452F,
- 0.0175945956F, 0.0177215974F, 0.0178490504F, 0.0179769545F,
- 0.0181053098F, 0.0182341160F, 0.0183633732F, 0.0184930812F,
- 0.0186232399F, 0.0187538494F, 0.0188849094F, 0.0190164200F,
- 0.0191483809F, 0.0192807923F, 0.0194136539F, 0.0195469656F,
- 0.0196807275F, 0.0198149394F, 0.0199496012F, 0.0200847128F,
- 0.0202202742F, 0.0203562853F, 0.0204927460F, 0.0206296561F,
- 0.0207670157F, 0.0209048245F, 0.0210430826F, 0.0211817899F,
- 0.0213209462F, 0.0214605515F, 0.0216006057F, 0.0217411086F,
- 0.0218820603F, 0.0220234605F, 0.0221653093F, 0.0223076066F,
- 0.0224503521F, 0.0225935459F, 0.0227371879F, 0.0228812779F,
- 0.0230258160F, 0.0231708018F, 0.0233162355F, 0.0234621169F,
- 0.0236084459F, 0.0237552224F, 0.0239024462F, 0.0240501175F,
- 0.0241982359F, 0.0243468015F, 0.0244958141F, 0.0246452736F,
- 0.0247951800F, 0.0249455331F, 0.0250963329F, 0.0252475792F,
- 0.0253992720F, 0.0255514111F, 0.0257039965F, 0.0258570281F,
- 0.0260105057F, 0.0261644293F, 0.0263187987F, 0.0264736139F,
- 0.0266288747F, 0.0267845811F, 0.0269407330F, 0.0270973302F,
- 0.0272543727F, 0.0274118604F, 0.0275697930F, 0.0277281707F,
- 0.0278869932F, 0.0280462604F, 0.0282059723F, 0.0283661287F,
- 0.0285267295F, 0.0286877747F, 0.0288492641F, 0.0290111976F,
- 0.0291735751F, 0.0293363965F, 0.0294996617F, 0.0296633706F,
- 0.0298275231F, 0.0299921190F, 0.0301571583F, 0.0303226409F,
- 0.0304885667F, 0.0306549354F, 0.0308217472F, 0.0309890017F,
- 0.0311566989F, 0.0313248388F, 0.0314934211F, 0.0316624459F,
- 0.0318319128F, 0.0320018220F, 0.0321721732F, 0.0323429663F,
- 0.0325142013F, 0.0326858779F, 0.0328579962F, 0.0330305559F,
- 0.0332035570F, 0.0333769994F, 0.0335508829F, 0.0337252074F,
- 0.0338999728F, 0.0340751790F, 0.0342508259F, 0.0344269134F,
- 0.0346034412F, 0.0347804094F, 0.0349578178F, 0.0351356663F,
- 0.0353139548F, 0.0354926831F, 0.0356718511F, 0.0358514588F,
- 0.0360315059F, 0.0362119924F, 0.0363929182F, 0.0365742831F,
- 0.0367560870F, 0.0369383297F, 0.0371210113F, 0.0373041315F,
- 0.0374876902F, 0.0376716873F, 0.0378561226F, 0.0380409961F,
- 0.0382263077F, 0.0384120571F, 0.0385982443F, 0.0387848691F,
- 0.0389719315F, 0.0391594313F, 0.0393473683F, 0.0395357425F,
- 0.0397245537F, 0.0399138017F, 0.0401034866F, 0.0402936080F,
- 0.0404841660F, 0.0406751603F, 0.0408665909F, 0.0410584576F,
- 0.0412507603F, 0.0414434988F, 0.0416366731F, 0.0418302829F,
- 0.0420243282F, 0.0422188088F, 0.0424137246F, 0.0426090755F,
- 0.0428048613F, 0.0430010819F, 0.0431977371F, 0.0433948269F,
- 0.0435923511F, 0.0437903095F, 0.0439887020F, 0.0441875285F,
- 0.0443867889F, 0.0445864830F, 0.0447866106F, 0.0449871717F,
- 0.0451881661F, 0.0453895936F, 0.0455914542F, 0.0457937477F,
- 0.0459964738F, 0.0461996326F, 0.0464032239F, 0.0466072475F,
- 0.0468117032F, 0.0470165910F, 0.0472219107F, 0.0474276622F,
- 0.0476338452F, 0.0478404597F, 0.0480475056F, 0.0482549827F,
- 0.0484628907F, 0.0486712297F, 0.0488799994F, 0.0490891998F,
- 0.0492988306F, 0.0495088917F, 0.0497193830F, 0.0499303043F,
- 0.0501416554F, 0.0503534363F, 0.0505656468F, 0.0507782867F,
- 0.0509913559F, 0.0512048542F, 0.0514187815F, 0.0516331376F,
- 0.0518479225F, 0.0520631358F, 0.0522787775F, 0.0524948475F,
- 0.0527113455F, 0.0529282715F, 0.0531456252F, 0.0533634066F,
- 0.0535816154F, 0.0538002515F, 0.0540193148F, 0.0542388051F,
- 0.0544587222F, 0.0546790660F, 0.0548998364F, 0.0551210331F,
- 0.0553426561F, 0.0555647051F, 0.0557871801F, 0.0560100807F,
- 0.0562334070F, 0.0564571587F, 0.0566813357F, 0.0569059378F,
- 0.0571309649F, 0.0573564168F, 0.0575822933F, 0.0578085942F,
- 0.0580353195F, 0.0582624689F, 0.0584900423F, 0.0587180396F,
- 0.0589464605F, 0.0591753049F, 0.0594045726F, 0.0596342635F,
- 0.0598643774F, 0.0600949141F, 0.0603258735F, 0.0605572555F,
- 0.0607890597F, 0.0610212862F, 0.0612539346F, 0.0614870049F,
- 0.0617204968F, 0.0619544103F, 0.0621887451F, 0.0624235010F,
- 0.0626586780F, 0.0628942758F, 0.0631302942F, 0.0633667331F,
- 0.0636035923F, 0.0638408717F, 0.0640785710F, 0.0643166901F,
- 0.0645552288F, 0.0647941870F, 0.0650335645F, 0.0652733610F,
- 0.0655135765F, 0.0657542108F, 0.0659952636F, 0.0662367348F,
- 0.0664786242F, 0.0667209316F, 0.0669636570F, 0.0672068000F,
- 0.0674503605F, 0.0676943384F, 0.0679387334F, 0.0681835454F,
- 0.0684287742F, 0.0686744196F, 0.0689204814F, 0.0691669595F,
- 0.0694138536F, 0.0696611637F, 0.0699088894F, 0.0701570307F,
- 0.0704055873F, 0.0706545590F, 0.0709039458F, 0.0711537473F,
- 0.0714039634F, 0.0716545939F, 0.0719056387F, 0.0721570975F,
- 0.0724089702F, 0.0726612565F, 0.0729139563F, 0.0731670694F,
- 0.0734205956F, 0.0736745347F, 0.0739288866F, 0.0741836510F,
- 0.0744388277F, 0.0746944166F, 0.0749504175F, 0.0752068301F,
- 0.0754636543F, 0.0757208899F, 0.0759785367F, 0.0762365946F,
- 0.0764950632F, 0.0767539424F, 0.0770132320F, 0.0772729319F,
- 0.0775330418F, 0.0777935616F, 0.0780544909F, 0.0783158298F,
- 0.0785775778F, 0.0788397349F, 0.0791023009F, 0.0793652755F,
- 0.0796286585F, 0.0798924498F, 0.0801566492F, 0.0804212564F,
- 0.0806862712F, 0.0809516935F, 0.0812175231F, 0.0814837597F,
- 0.0817504031F, 0.0820174532F, 0.0822849097F, 0.0825527724F,
- 0.0828210412F, 0.0830897158F, 0.0833587960F, 0.0836282816F,
- 0.0838981724F, 0.0841684682F, 0.0844391688F, 0.0847102740F,
- 0.0849817835F, 0.0852536973F, 0.0855260150F, 0.0857987364F,
- 0.0860718614F, 0.0863453897F, 0.0866193211F, 0.0868936554F,
- 0.0871683924F, 0.0874435319F, 0.0877190737F, 0.0879950175F,
- 0.0882713632F, 0.0885481105F, 0.0888252592F, 0.0891028091F,
- 0.0893807600F, 0.0896591117F, 0.0899378639F, 0.0902170165F,
- 0.0904965692F, 0.0907765218F, 0.0910568740F, 0.0913376258F,
- 0.0916187767F, 0.0919003268F, 0.0921822756F, 0.0924646230F,
- 0.0927473687F, 0.0930305126F, 0.0933140545F, 0.0935979940F,
- 0.0938823310F, 0.0941670653F, 0.0944521966F, 0.0947377247F,
- 0.0950236494F, 0.0953099704F, 0.0955966876F, 0.0958838007F,
- 0.0961713094F, 0.0964592136F, 0.0967475131F, 0.0970362075F,
- 0.0973252967F, 0.0976147805F, 0.0979046585F, 0.0981949307F,
- 0.0984855967F, 0.0987766563F, 0.0990681093F, 0.0993599555F,
- 0.0996521945F, 0.0999448263F, 0.1002378506F, 0.1005312671F,
- 0.1008250755F, 0.1011192757F, 0.1014138675F, 0.1017088505F,
- 0.1020042246F, 0.1022999895F, 0.1025961450F, 0.1028926909F,
- 0.1031896268F, 0.1034869526F, 0.1037846680F, 0.1040827729F,
- 0.1043812668F, 0.1046801497F, 0.1049794213F, 0.1052790813F,
- 0.1055791294F, 0.1058795656F, 0.1061803894F, 0.1064816006F,
- 0.1067831991F, 0.1070851846F, 0.1073875568F, 0.1076903155F,
- 0.1079934604F, 0.1082969913F, 0.1086009079F, 0.1089052101F,
- 0.1092098975F, 0.1095149699F, 0.1098204270F, 0.1101262687F,
- 0.1104324946F, 0.1107391045F, 0.1110460982F, 0.1113534754F,
- 0.1116612359F, 0.1119693793F, 0.1122779055F, 0.1125868142F,
- 0.1128961052F, 0.1132057781F, 0.1135158328F, 0.1138262690F,
- 0.1141370863F, 0.1144482847F, 0.1147598638F, 0.1150718233F,
- 0.1153841631F, 0.1156968828F, 0.1160099822F, 0.1163234610F,
- 0.1166373190F, 0.1169515559F, 0.1172661714F, 0.1175811654F,
- 0.1178965374F, 0.1182122874F, 0.1185284149F, 0.1188449198F,
- 0.1191618018F, 0.1194790606F, 0.1197966960F, 0.1201147076F,
- 0.1204330953F, 0.1207518587F, 0.1210709976F, 0.1213905118F,
- 0.1217104009F, 0.1220306647F, 0.1223513029F, 0.1226723153F,
- 0.1229937016F, 0.1233154615F, 0.1236375948F, 0.1239601011F,
- 0.1242829803F, 0.1246062319F, 0.1249298559F, 0.1252538518F,
- 0.1255782195F, 0.1259029586F, 0.1262280689F, 0.1265535501F,
- 0.1268794019F, 0.1272056241F, 0.1275322163F, 0.1278591784F,
- 0.1281865099F, 0.1285142108F, 0.1288422805F, 0.1291707190F,
- 0.1294995259F, 0.1298287009F, 0.1301582437F, 0.1304881542F,
- 0.1308184319F, 0.1311490766F, 0.1314800881F, 0.1318114660F,
- 0.1321432100F, 0.1324753200F, 0.1328077955F, 0.1331406364F,
- 0.1334738422F, 0.1338074129F, 0.1341413479F, 0.1344756472F,
- 0.1348103103F, 0.1351453370F, 0.1354807270F, 0.1358164801F,
- 0.1361525959F, 0.1364890741F, 0.1368259145F, 0.1371631167F,
- 0.1375006805F, 0.1378386056F, 0.1381768917F, 0.1385155384F,
- 0.1388545456F, 0.1391939129F, 0.1395336400F, 0.1398737266F,
- 0.1402141724F, 0.1405549772F, 0.1408961406F, 0.1412376623F,
- 0.1415795421F, 0.1419217797F, 0.1422643746F, 0.1426073268F,
- 0.1429506358F, 0.1432943013F, 0.1436383231F, 0.1439827008F,
- 0.1443274342F, 0.1446725229F, 0.1450179667F, 0.1453637652F,
- 0.1457099181F, 0.1460564252F, 0.1464032861F, 0.1467505006F,
- 0.1470980682F, 0.1474459888F, 0.1477942620F, 0.1481428875F,
- 0.1484918651F, 0.1488411942F, 0.1491908748F, 0.1495409065F,
- 0.1498912889F, 0.1502420218F, 0.1505931048F, 0.1509445376F,
- 0.1512963200F, 0.1516484516F, 0.1520009321F, 0.1523537612F,
- 0.1527069385F, 0.1530604638F, 0.1534143368F, 0.1537685571F,
- 0.1541231244F, 0.1544780384F, 0.1548332987F, 0.1551889052F,
- 0.1555448574F, 0.1559011550F, 0.1562577978F, 0.1566147853F,
- 0.1569721173F, 0.1573297935F, 0.1576878135F, 0.1580461771F,
- 0.1584048838F, 0.1587639334F, 0.1591233255F, 0.1594830599F,
- 0.1598431361F, 0.1602035540F, 0.1605643131F, 0.1609254131F,
- 0.1612868537F, 0.1616486346F, 0.1620107555F, 0.1623732160F,
- 0.1627360158F, 0.1630991545F, 0.1634626319F, 0.1638264476F,
- 0.1641906013F, 0.1645550926F, 0.1649199212F, 0.1652850869F,
- 0.1656505892F, 0.1660164278F, 0.1663826024F, 0.1667491127F,
- 0.1671159583F, 0.1674831388F, 0.1678506541F, 0.1682185036F,
- 0.1685866872F, 0.1689552044F, 0.1693240549F, 0.1696932384F,
- 0.1700627545F, 0.1704326029F, 0.1708027833F, 0.1711732952F,
- 0.1715441385F, 0.1719153127F, 0.1722868175F, 0.1726586526F,
- 0.1730308176F, 0.1734033121F, 0.1737761359F, 0.1741492886F,
- 0.1745227698F, 0.1748965792F, 0.1752707164F, 0.1756451812F,
- 0.1760199731F, 0.1763950918F, 0.1767705370F, 0.1771463083F,
- 0.1775224054F, 0.1778988279F, 0.1782755754F, 0.1786526477F,
- 0.1790300444F, 0.1794077651F, 0.1797858094F, 0.1801641771F,
- 0.1805428677F, 0.1809218810F, 0.1813012165F, 0.1816808739F,
- 0.1820608528F, 0.1824411530F, 0.1828217739F, 0.1832027154F,
- 0.1835839770F, 0.1839655584F, 0.1843474592F, 0.1847296790F,
- 0.1851122175F, 0.1854950744F, 0.1858782492F, 0.1862617417F,
- 0.1866455514F, 0.1870296780F, 0.1874141211F, 0.1877988804F,
- 0.1881839555F, 0.1885693461F, 0.1889550517F, 0.1893410721F,
- 0.1897274068F, 0.1901140555F, 0.1905010178F, 0.1908882933F,
- 0.1912758818F, 0.1916637828F, 0.1920519959F, 0.1924405208F,
- 0.1928293571F, 0.1932185044F, 0.1936079625F, 0.1939977308F,
- 0.1943878091F, 0.1947781969F, 0.1951688939F, 0.1955598998F,
- 0.1959512141F, 0.1963428364F, 0.1967347665F, 0.1971270038F,
- 0.1975195482F, 0.1979123990F, 0.1983055561F, 0.1986990190F,
- 0.1990927873F, 0.1994868607F, 0.1998812388F, 0.2002759212F,
- 0.2006709075F, 0.2010661974F, 0.2014617904F, 0.2018576862F,
- 0.2022538844F, 0.2026503847F, 0.2030471865F, 0.2034442897F,
- 0.2038416937F, 0.2042393982F, 0.2046374028F, 0.2050357071F,
- 0.2054343107F, 0.2058332133F, 0.2062324145F, 0.2066319138F,
- 0.2070317110F, 0.2074318055F, 0.2078321970F, 0.2082328852F,
- 0.2086338696F, 0.2090351498F, 0.2094367255F, 0.2098385962F,
- 0.2102407617F, 0.2106432213F, 0.2110459749F, 0.2114490220F,
- 0.2118523621F, 0.2122559950F, 0.2126599202F, 0.2130641373F,
- 0.2134686459F, 0.2138734456F, 0.2142785361F, 0.2146839168F,
- 0.2150895875F, 0.2154955478F, 0.2159017972F, 0.2163083353F,
- 0.2167151617F, 0.2171222761F, 0.2175296780F, 0.2179373670F,
- 0.2183453428F, 0.2187536049F, 0.2191621529F, 0.2195709864F,
- 0.2199801051F, 0.2203895085F, 0.2207991961F, 0.2212091677F,
- 0.2216194228F, 0.2220299610F, 0.2224407818F, 0.2228518850F,
- 0.2232632699F, 0.2236749364F, 0.2240868839F, 0.2244991121F,
- 0.2249116204F, 0.2253244086F, 0.2257374763F, 0.2261508229F,
- 0.2265644481F, 0.2269783514F, 0.2273925326F, 0.2278069911F,
- 0.2282217265F, 0.2286367384F, 0.2290520265F, 0.2294675902F,
- 0.2298834292F, 0.2302995431F, 0.2307159314F, 0.2311325937F,
- 0.2315495297F, 0.2319667388F, 0.2323842207F, 0.2328019749F,
- 0.2332200011F, 0.2336382988F, 0.2340568675F, 0.2344757070F,
- 0.2348948166F, 0.2353141961F, 0.2357338450F, 0.2361537629F,
- 0.2365739493F, 0.2369944038F, 0.2374151261F, 0.2378361156F,
- 0.2382573720F, 0.2386788948F, 0.2391006836F, 0.2395227380F,
- 0.2399450575F, 0.2403676417F, 0.2407904902F, 0.2412136026F,
- 0.2416369783F, 0.2420606171F, 0.2424845185F, 0.2429086820F,
- 0.2433331072F, 0.2437577936F, 0.2441827409F, 0.2446079486F,
- 0.2450334163F, 0.2454591435F, 0.2458851298F, 0.2463113747F,
- 0.2467378779F, 0.2471646389F, 0.2475916573F, 0.2480189325F,
- 0.2484464643F, 0.2488742521F, 0.2493022955F, 0.2497305940F,
- 0.2501591473F, 0.2505879549F, 0.2510170163F, 0.2514463311F,
- 0.2518758989F, 0.2523057193F, 0.2527357916F, 0.2531661157F,
- 0.2535966909F, 0.2540275169F, 0.2544585931F, 0.2548899193F,
- 0.2553214948F, 0.2557533193F, 0.2561853924F, 0.2566177135F,
- 0.2570502822F, 0.2574830981F, 0.2579161608F, 0.2583494697F,
- 0.2587830245F, 0.2592168246F, 0.2596508697F, 0.2600851593F,
- 0.2605196929F, 0.2609544701F, 0.2613894904F, 0.2618247534F,
- 0.2622602586F, 0.2626960055F, 0.2631319938F, 0.2635682230F,
- 0.2640046925F, 0.2644414021F, 0.2648783511F, 0.2653155391F,
- 0.2657529657F, 0.2661906305F, 0.2666285329F, 0.2670666725F,
- 0.2675050489F, 0.2679436616F, 0.2683825101F, 0.2688215940F,
- 0.2692609127F, 0.2697004660F, 0.2701402532F, 0.2705802739F,
- 0.2710205278F, 0.2714610142F, 0.2719017327F, 0.2723426830F,
- 0.2727838644F, 0.2732252766F, 0.2736669191F, 0.2741087914F,
- 0.2745508930F, 0.2749932235F, 0.2754357824F, 0.2758785693F,
- 0.2763215837F, 0.2767648251F, 0.2772082930F, 0.2776519870F,
- 0.2780959066F, 0.2785400513F, 0.2789844207F, 0.2794290143F,
- 0.2798738316F, 0.2803188722F, 0.2807641355F, 0.2812096211F,
- 0.2816553286F, 0.2821012574F, 0.2825474071F, 0.2829937773F,
- 0.2834403673F, 0.2838871768F, 0.2843342053F, 0.2847814523F,
- 0.2852289174F, 0.2856765999F, 0.2861244996F, 0.2865726159F,
- 0.2870209482F, 0.2874694962F, 0.2879182594F, 0.2883672372F,
- 0.2888164293F, 0.2892658350F, 0.2897154540F, 0.2901652858F,
- 0.2906153298F, 0.2910655856F, 0.2915160527F, 0.2919667306F,
- 0.2924176189F, 0.2928687171F, 0.2933200246F, 0.2937715409F,
- 0.2942232657F, 0.2946751984F, 0.2951273386F, 0.2955796856F,
- 0.2960322391F, 0.2964849986F, 0.2969379636F, 0.2973911335F,
- 0.2978445080F, 0.2982980864F, 0.2987518684F, 0.2992058534F,
- 0.2996600409F, 0.3001144305F, 0.3005690217F, 0.3010238139F,
- 0.3014788067F, 0.3019339995F, 0.3023893920F, 0.3028449835F,
- 0.3033007736F, 0.3037567618F, 0.3042129477F, 0.3046693306F,
- 0.3051259102F, 0.3055826859F, 0.3060396572F, 0.3064968236F,
- 0.3069541847F, 0.3074117399F, 0.3078694887F, 0.3083274307F,
- 0.3087855653F, 0.3092438920F, 0.3097024104F, 0.3101611199F,
- 0.3106200200F, 0.3110791103F, 0.3115383902F, 0.3119978592F,
- 0.3124575169F, 0.3129173627F, 0.3133773961F, 0.3138376166F,
- 0.3142980238F, 0.3147586170F, 0.3152193959F, 0.3156803598F,
- 0.3161415084F, 0.3166028410F, 0.3170643573F, 0.3175260566F,
- 0.3179879384F, 0.3184500023F, 0.3189122478F, 0.3193746743F,
- 0.3198372814F, 0.3203000685F, 0.3207630351F, 0.3212261807F,
- 0.3216895048F, 0.3221530069F, 0.3226166865F, 0.3230805430F,
- 0.3235445760F, 0.3240087849F, 0.3244731693F, 0.3249377285F,
- 0.3254024622F, 0.3258673698F, 0.3263324507F, 0.3267977045F,
- 0.3272631306F, 0.3277287286F, 0.3281944978F, 0.3286604379F,
- 0.3291265482F, 0.3295928284F, 0.3300592777F, 0.3305258958F,
- 0.3309926821F, 0.3314596361F, 0.3319267573F, 0.3323940451F,
- 0.3328614990F, 0.3333291186F, 0.3337969033F, 0.3342648525F,
- 0.3347329658F, 0.3352012427F, 0.3356696825F, 0.3361382849F,
- 0.3366070492F, 0.3370759749F, 0.3375450616F, 0.3380143087F,
- 0.3384837156F, 0.3389532819F, 0.3394230071F, 0.3398928905F,
- 0.3403629317F, 0.3408331302F, 0.3413034854F, 0.3417739967F,
- 0.3422446638F, 0.3427154860F, 0.3431864628F, 0.3436575938F,
- 0.3441288782F, 0.3446003158F, 0.3450719058F, 0.3455436478F,
- 0.3460155412F, 0.3464875856F, 0.3469597804F, 0.3474321250F,
- 0.3479046189F, 0.3483772617F, 0.3488500527F, 0.3493229914F,
- 0.3497960774F, 0.3502693100F, 0.3507426887F, 0.3512162131F,
- 0.3516898825F, 0.3521636965F, 0.3526376545F, 0.3531117559F,
- 0.3535860003F, 0.3540603870F, 0.3545349157F, 0.3550095856F,
- 0.3554843964F, 0.3559593474F, 0.3564344381F, 0.3569096680F,
- 0.3573850366F, 0.3578605432F, 0.3583361875F, 0.3588119687F,
- 0.3592878865F, 0.3597639402F, 0.3602401293F, 0.3607164533F,
- 0.3611929117F, 0.3616695038F, 0.3621462292F, 0.3626230873F,
- 0.3631000776F, 0.3635771995F, 0.3640544525F, 0.3645318360F,
- 0.3650093496F, 0.3654869926F, 0.3659647645F, 0.3664426648F,
- 0.3669206930F, 0.3673988484F, 0.3678771306F, 0.3683555390F,
- 0.3688340731F, 0.3693127322F, 0.3697915160F, 0.3702704237F,
- 0.3707494549F, 0.3712286091F, 0.3717078857F, 0.3721872840F,
- 0.3726668037F, 0.3731464441F, 0.3736262047F, 0.3741060850F,
- 0.3745860843F, 0.3750662023F, 0.3755464382F, 0.3760267915F,
- 0.3765072618F, 0.3769878484F, 0.3774685509F, 0.3779493686F,
- 0.3784303010F, 0.3789113475F, 0.3793925076F, 0.3798737809F,
- 0.3803551666F, 0.3808366642F, 0.3813182733F, 0.3817999932F,
- 0.3822818234F, 0.3827637633F, 0.3832458124F, 0.3837279702F,
- 0.3842102360F, 0.3846926093F, 0.3851750897F, 0.3856576764F,
- 0.3861403690F, 0.3866231670F, 0.3871060696F, 0.3875890765F,
- 0.3880721870F, 0.3885554007F, 0.3890387168F, 0.3895221349F,
- 0.3900056544F, 0.3904892748F, 0.3909729955F, 0.3914568160F,
- 0.3919407356F, 0.3924247539F, 0.3929088702F, 0.3933930841F,
- 0.3938773949F, 0.3943618021F, 0.3948463052F, 0.3953309035F,
- 0.3958155966F, 0.3963003838F, 0.3967852646F, 0.3972702385F,
- 0.3977553048F, 0.3982404631F, 0.3987257127F, 0.3992110531F,
- 0.3996964838F, 0.4001820041F, 0.4006676136F, 0.4011533116F,
- 0.4016390976F, 0.4021249710F, 0.4026109313F, 0.4030969779F,
- 0.4035831102F, 0.4040693277F, 0.4045556299F, 0.4050420160F,
- 0.4055284857F, 0.4060150383F, 0.4065016732F, 0.4069883899F,
- 0.4074751879F, 0.4079620665F, 0.4084490252F, 0.4089360635F,
- 0.4094231807F, 0.4099103763F, 0.4103976498F, 0.4108850005F,
- 0.4113724280F, 0.4118599315F, 0.4123475107F, 0.4128351648F,
- 0.4133228934F, 0.4138106959F, 0.4142985716F, 0.4147865201F,
- 0.4152745408F, 0.4157626330F, 0.4162507963F, 0.4167390301F,
- 0.4172273337F, 0.4177157067F, 0.4182041484F, 0.4186926583F,
- 0.4191812359F, 0.4196698805F, 0.4201585915F, 0.4206473685F,
- 0.4211362108F, 0.4216251179F, 0.4221140892F, 0.4226031241F,
- 0.4230922221F, 0.4235813826F, 0.4240706050F, 0.4245598887F,
- 0.4250492332F, 0.4255386379F, 0.4260281022F, 0.4265176256F,
- 0.4270072075F, 0.4274968473F, 0.4279865445F, 0.4284762984F,
- 0.4289661086F, 0.4294559743F, 0.4299458951F, 0.4304358704F,
- 0.4309258996F, 0.4314159822F, 0.4319061175F, 0.4323963050F,
- 0.4328865441F, 0.4333768342F, 0.4338671749F, 0.4343575654F,
- 0.4348480052F, 0.4353384938F, 0.4358290306F, 0.4363196149F,
- 0.4368102463F, 0.4373009241F, 0.4377916478F, 0.4382824168F,
- 0.4387732305F, 0.4392640884F, 0.4397549899F, 0.4402459343F,
- 0.4407369212F, 0.4412279499F, 0.4417190198F, 0.4422101305F,
- 0.4427012813F, 0.4431924717F, 0.4436837010F, 0.4441749686F,
- 0.4446662742F, 0.4451576169F, 0.4456489963F, 0.4461404118F,
- 0.4466318628F, 0.4471233487F, 0.4476148690F, 0.4481064230F,
- 0.4485980103F, 0.4490896302F, 0.4495812821F, 0.4500729654F,
- 0.4505646797F, 0.4510564243F, 0.4515481986F, 0.4520400021F,
- 0.4525318341F, 0.4530236942F, 0.4535155816F, 0.4540074959F,
- 0.4544994365F, 0.4549914028F, 0.4554833941F, 0.4559754100F,
- 0.4564674499F, 0.4569595131F, 0.4574515991F, 0.4579437074F,
- 0.4584358372F, 0.4589279881F, 0.4594201595F, 0.4599123508F,
- 0.4604045615F, 0.4608967908F, 0.4613890383F, 0.4618813034F,
- 0.4623735855F, 0.4628658841F, 0.4633581984F, 0.4638505281F,
- 0.4643428724F, 0.4648352308F, 0.4653276028F, 0.4658199877F,
- 0.4663123849F, 0.4668047940F, 0.4672972143F, 0.4677896451F,
- 0.4682820861F, 0.4687745365F, 0.4692669958F, 0.4697594634F,
- 0.4702519387F, 0.4707444211F, 0.4712369102F, 0.4717294052F,
- 0.4722219056F, 0.4727144109F, 0.4732069204F, 0.4736994336F,
- 0.4741919498F, 0.4746844686F, 0.4751769893F, 0.4756695113F,
- 0.4761620341F, 0.4766545571F, 0.4771470797F, 0.4776396013F,
- 0.4781321213F, 0.4786246392F, 0.4791171544F, 0.4796096663F,
- 0.4801021744F, 0.4805946779F, 0.4810871765F, 0.4815796694F,
- 0.4820721561F, 0.4825646360F, 0.4830571086F, 0.4835495732F,
- 0.4840420293F, 0.4845344763F, 0.4850269136F, 0.4855193407F,
- 0.4860117569F, 0.4865041617F, 0.4869965545F, 0.4874889347F,
- 0.4879813018F, 0.4884736551F, 0.4889659941F, 0.4894583182F,
- 0.4899506268F, 0.4904429193F, 0.4909351952F, 0.4914274538F,
- 0.4919196947F, 0.4924119172F, 0.4929041207F, 0.4933963046F,
- 0.4938884685F, 0.4943806116F, 0.4948727335F, 0.4953648335F,
- 0.4958569110F, 0.4963489656F, 0.4968409965F, 0.4973330032F,
- 0.4978249852F, 0.4983169419F, 0.4988088726F, 0.4993007768F,
- 0.4997926539F, 0.5002845034F, 0.5007763247F, 0.5012681171F,
- 0.5017598801F, 0.5022516132F, 0.5027433157F, 0.5032349871F,
- 0.5037266268F, 0.5042182341F, 0.5047098086F, 0.5052013497F,
- 0.5056928567F, 0.5061843292F, 0.5066757664F, 0.5071671679F,
- 0.5076585330F, 0.5081498613F, 0.5086411520F, 0.5091324047F,
- 0.5096236187F, 0.5101147934F, 0.5106059284F, 0.5110970230F,
- 0.5115880766F, 0.5120790887F, 0.5125700587F, 0.5130609860F,
- 0.5135518700F, 0.5140427102F, 0.5145335059F, 0.5150242566F,
- 0.5155149618F, 0.5160056208F, 0.5164962331F, 0.5169867980F,
- 0.5174773151F, 0.5179677837F, 0.5184582033F, 0.5189485733F,
- 0.5194388931F, 0.5199291621F, 0.5204193798F, 0.5209095455F,
- 0.5213996588F, 0.5218897190F, 0.5223797256F, 0.5228696779F,
- 0.5233595755F, 0.5238494177F, 0.5243392039F, 0.5248289337F,
- 0.5253186063F, 0.5258082213F, 0.5262977781F, 0.5267872760F,
- 0.5272767146F, 0.5277660932F, 0.5282554112F, 0.5287446682F,
- 0.5292338635F, 0.5297229965F, 0.5302120667F, 0.5307010736F,
- 0.5311900164F, 0.5316788947F, 0.5321677079F, 0.5326564554F,
- 0.5331451366F, 0.5336337511F, 0.5341222981F, 0.5346107771F,
- 0.5350991876F, 0.5355875290F, 0.5360758007F, 0.5365640021F,
- 0.5370521327F, 0.5375401920F, 0.5380281792F, 0.5385160939F,
- 0.5390039355F, 0.5394917034F, 0.5399793971F, 0.5404670159F,
- 0.5409545594F, 0.5414420269F, 0.5419294179F, 0.5424167318F,
- 0.5429039680F, 0.5433911261F, 0.5438782053F, 0.5443652051F,
- 0.5448521250F, 0.5453389644F, 0.5458257228F, 0.5463123995F,
- 0.5467989940F, 0.5472855057F, 0.5477719341F, 0.5482582786F,
- 0.5487445387F, 0.5492307137F, 0.5497168031F, 0.5502028063F,
- 0.5506887228F, 0.5511745520F, 0.5516602934F, 0.5521459463F,
- 0.5526315103F, 0.5531169847F, 0.5536023690F, 0.5540876626F,
- 0.5545728649F, 0.5550579755F, 0.5555429937F, 0.5560279189F,
- 0.5565127507F, 0.5569974884F, 0.5574821315F, 0.5579666794F,
- 0.5584511316F, 0.5589354875F, 0.5594197465F, 0.5599039080F,
- 0.5603879716F, 0.5608719367F, 0.5613558026F, 0.5618395689F,
- 0.5623232350F, 0.5628068002F, 0.5632902642F, 0.5637736262F,
- 0.5642568858F, 0.5647400423F, 0.5652230953F, 0.5657060442F,
- 0.5661888883F, 0.5666716272F, 0.5671542603F, 0.5676367870F,
- 0.5681192069F, 0.5686015192F, 0.5690837235F, 0.5695658192F,
- 0.5700478058F, 0.5705296827F, 0.5710114494F, 0.5714931052F,
- 0.5719746497F, 0.5724560822F, 0.5729374023F, 0.5734186094F,
- 0.5738997029F, 0.5743806823F, 0.5748615470F, 0.5753422965F,
- 0.5758229301F, 0.5763034475F, 0.5767838480F, 0.5772641310F,
- 0.5777442960F, 0.5782243426F, 0.5787042700F, 0.5791840778F,
- 0.5796637654F, 0.5801433322F, 0.5806227778F, 0.5811021016F,
- 0.5815813029F, 0.5820603814F, 0.5825393363F, 0.5830181673F,
- 0.5834968737F, 0.5839754549F, 0.5844539105F, 0.5849322399F,
- 0.5854104425F, 0.5858885179F, 0.5863664653F, 0.5868442844F,
- 0.5873219746F, 0.5877995353F, 0.5882769660F, 0.5887542661F,
- 0.5892314351F, 0.5897084724F, 0.5901853776F, 0.5906621500F,
- 0.5911387892F, 0.5916152945F, 0.5920916655F, 0.5925679016F,
- 0.5930440022F, 0.5935199669F, 0.5939957950F, 0.5944714861F,
- 0.5949470396F, 0.5954224550F, 0.5958977317F, 0.5963728692F,
- 0.5968478669F, 0.5973227244F, 0.5977974411F, 0.5982720163F,
- 0.5987464497F, 0.5992207407F, 0.5996948887F, 0.6001688932F,
- 0.6006427537F, 0.6011164696F, 0.6015900405F, 0.6020634657F,
- 0.6025367447F, 0.6030098770F, 0.6034828621F, 0.6039556995F,
- 0.6044283885F, 0.6049009288F, 0.6053733196F, 0.6058455606F,
- 0.6063176512F, 0.6067895909F, 0.6072613790F, 0.6077330152F,
- 0.6082044989F, 0.6086758295F, 0.6091470065F, 0.6096180294F,
- 0.6100888977F, 0.6105596108F, 0.6110301682F, 0.6115005694F,
- 0.6119708139F, 0.6124409011F, 0.6129108305F, 0.6133806017F,
- 0.6138502139F, 0.6143196669F, 0.6147889599F, 0.6152580926F,
- 0.6157270643F, 0.6161958746F, 0.6166645230F, 0.6171330088F,
- 0.6176013317F, 0.6180694910F, 0.6185374863F, 0.6190053171F,
- 0.6194729827F, 0.6199404828F, 0.6204078167F, 0.6208749841F,
- 0.6213419842F, 0.6218088168F, 0.6222754811F, 0.6227419768F,
- 0.6232083032F, 0.6236744600F, 0.6241404465F, 0.6246062622F,
- 0.6250719067F, 0.6255373795F, 0.6260026799F, 0.6264678076F,
- 0.6269327619F, 0.6273975425F, 0.6278621487F, 0.6283265800F,
- 0.6287908361F, 0.6292549163F, 0.6297188201F, 0.6301825471F,
- 0.6306460966F, 0.6311094683F, 0.6315726617F, 0.6320356761F,
- 0.6324985111F, 0.6329611662F, 0.6334236410F, 0.6338859348F,
- 0.6343480472F, 0.6348099777F, 0.6352717257F, 0.6357332909F,
- 0.6361946726F, 0.6366558704F, 0.6371168837F, 0.6375777122F,
- 0.6380383552F, 0.6384988123F, 0.6389590830F, 0.6394191668F,
- 0.6398790631F, 0.6403387716F, 0.6407982916F, 0.6412576228F,
- 0.6417167645F, 0.6421757163F, 0.6426344778F, 0.6430930483F,
- 0.6435514275F, 0.6440096149F, 0.6444676098F, 0.6449254119F,
- 0.6453830207F, 0.6458404356F, 0.6462976562F, 0.6467546820F,
- 0.6472115125F, 0.6476681472F, 0.6481245856F, 0.6485808273F,
- 0.6490368717F, 0.6494927183F, 0.6499483667F, 0.6504038164F,
- 0.6508590670F, 0.6513141178F, 0.6517689684F, 0.6522236185F,
- 0.6526780673F, 0.6531323146F, 0.6535863598F, 0.6540402024F,
- 0.6544938419F, 0.6549472779F, 0.6554005099F, 0.6558535373F,
- 0.6563063598F, 0.6567589769F, 0.6572113880F, 0.6576635927F,
- 0.6581155906F, 0.6585673810F, 0.6590189637F, 0.6594703380F,
- 0.6599215035F, 0.6603724598F, 0.6608232064F, 0.6612737427F,
- 0.6617240684F, 0.6621741829F, 0.6626240859F, 0.6630737767F,
- 0.6635232550F, 0.6639725202F, 0.6644215720F, 0.6648704098F,
- 0.6653190332F, 0.6657674417F, 0.6662156348F, 0.6666636121F,
- 0.6671113731F, 0.6675589174F, 0.6680062445F, 0.6684533538F,
- 0.6689002450F, 0.6693469177F, 0.6697933712F, 0.6702396052F,
- 0.6706856193F, 0.6711314129F, 0.6715769855F, 0.6720223369F,
- 0.6724674664F, 0.6729123736F, 0.6733570581F, 0.6738015194F,
- 0.6742457570F, 0.6746897706F, 0.6751335596F, 0.6755771236F,
- 0.6760204621F, 0.6764635747F, 0.6769064609F, 0.6773491204F,
- 0.6777915525F, 0.6782337570F, 0.6786757332F, 0.6791174809F,
- 0.6795589995F, 0.6800002886F, 0.6804413477F, 0.6808821765F,
- 0.6813227743F, 0.6817631409F, 0.6822032758F, 0.6826431785F,
- 0.6830828485F, 0.6835222855F, 0.6839614890F, 0.6844004585F,
- 0.6848391936F, 0.6852776939F, 0.6857159589F, 0.6861539883F,
- 0.6865917815F, 0.6870293381F, 0.6874666576F, 0.6879037398F,
- 0.6883405840F, 0.6887771899F, 0.6892135571F, 0.6896496850F,
- 0.6900855733F, 0.6905212216F, 0.6909566294F, 0.6913917963F,
- 0.6918267218F, 0.6922614055F, 0.6926958471F, 0.6931300459F,
- 0.6935640018F, 0.6939977141F, 0.6944311825F, 0.6948644066F,
- 0.6952973859F, 0.6957301200F, 0.6961626085F, 0.6965948510F,
- 0.6970268470F, 0.6974585961F, 0.6978900980F, 0.6983213521F,
- 0.6987523580F, 0.6991831154F, 0.6996136238F, 0.7000438828F,
- 0.7004738921F, 0.7009036510F, 0.7013331594F, 0.7017624166F,
- 0.7021914224F, 0.7026201763F, 0.7030486779F, 0.7034769268F,
- 0.7039049226F, 0.7043326648F, 0.7047601531F, 0.7051873870F,
- 0.7056143662F, 0.7060410902F, 0.7064675586F, 0.7068937711F,
- 0.7073197271F, 0.7077454264F, 0.7081708684F, 0.7085960529F,
- 0.7090209793F, 0.7094456474F, 0.7098700566F, 0.7102942066F,
- 0.7107180970F, 0.7111417274F, 0.7115650974F, 0.7119882066F,
- 0.7124110545F, 0.7128336409F, 0.7132559653F, 0.7136780272F,
- 0.7140998264F, 0.7145213624F, 0.7149426348F, 0.7153636433F,
- 0.7157843874F, 0.7162048668F, 0.7166250810F, 0.7170450296F,
- 0.7174647124F, 0.7178841289F, 0.7183032786F, 0.7187221613F,
- 0.7191407765F, 0.7195591239F, 0.7199772030F, 0.7203950135F,
- 0.7208125550F, 0.7212298271F, 0.7216468294F, 0.7220635616F,
- 0.7224800233F, 0.7228962140F, 0.7233121335F, 0.7237277813F,
- 0.7241431571F, 0.7245582604F, 0.7249730910F, 0.7253876484F,
- 0.7258019322F, 0.7262159422F, 0.7266296778F, 0.7270431388F,
- 0.7274563247F, 0.7278692353F, 0.7282818700F, 0.7286942287F,
- 0.7291063108F, 0.7295181160F, 0.7299296440F, 0.7303408944F,
- 0.7307518669F, 0.7311625609F, 0.7315729763F, 0.7319831126F,
- 0.7323929695F, 0.7328025466F, 0.7332118435F, 0.7336208600F,
- 0.7340295955F, 0.7344380499F, 0.7348462226F, 0.7352541134F,
- 0.7356617220F, 0.7360690478F, 0.7364760907F, 0.7368828502F,
- 0.7372893259F, 0.7376955176F, 0.7381014249F, 0.7385070475F,
- 0.7389123849F, 0.7393174368F, 0.7397222029F, 0.7401266829F,
- 0.7405308763F, 0.7409347829F, 0.7413384023F, 0.7417417341F,
- 0.7421447780F, 0.7425475338F, 0.7429500009F, 0.7433521791F,
- 0.7437540681F, 0.7441556674F, 0.7445569769F, 0.7449579960F,
- 0.7453587245F, 0.7457591621F, 0.7461593084F, 0.7465591631F,
- 0.7469587259F, 0.7473579963F, 0.7477569741F, 0.7481556590F,
- 0.7485540506F, 0.7489521486F, 0.7493499526F, 0.7497474623F,
- 0.7501446775F, 0.7505415977F, 0.7509382227F, 0.7513345521F,
- 0.7517305856F, 0.7521263229F, 0.7525217636F, 0.7529169074F,
- 0.7533117541F, 0.7537063032F, 0.7541005545F, 0.7544945076F,
- 0.7548881623F, 0.7552815182F, 0.7556745749F, 0.7560673323F,
- 0.7564597899F, 0.7568519474F, 0.7572438046F, 0.7576353611F,
- 0.7580266166F, 0.7584175708F, 0.7588082235F, 0.7591985741F,
- 0.7595886226F, 0.7599783685F, 0.7603678116F, 0.7607569515F,
- 0.7611457879F, 0.7615343206F, 0.7619225493F, 0.7623104735F,
- 0.7626980931F, 0.7630854078F, 0.7634724171F, 0.7638591209F,
- 0.7642455188F, 0.7646316106F, 0.7650173959F, 0.7654028744F,
- 0.7657880459F, 0.7661729100F, 0.7665574664F, 0.7669417150F,
- 0.7673256553F, 0.7677092871F, 0.7680926100F, 0.7684756239F,
- 0.7688583284F, 0.7692407232F, 0.7696228080F, 0.7700045826F,
- 0.7703860467F, 0.7707671999F, 0.7711480420F, 0.7715285728F,
- 0.7719087918F, 0.7722886989F, 0.7726682938F, 0.7730475762F,
- 0.7734265458F, 0.7738052023F, 0.7741835454F, 0.7745615750F,
- 0.7749392906F, 0.7753166921F, 0.7756937791F, 0.7760705514F,
- 0.7764470087F, 0.7768231508F, 0.7771989773F, 0.7775744880F,
- 0.7779496827F, 0.7783245610F, 0.7786991227F, 0.7790733676F,
- 0.7794472953F, 0.7798209056F, 0.7801941982F, 0.7805671729F,
- 0.7809398294F, 0.7813121675F, 0.7816841869F, 0.7820558873F,
- 0.7824272684F, 0.7827983301F, 0.7831690720F, 0.7835394940F,
- 0.7839095957F, 0.7842793768F, 0.7846488373F, 0.7850179767F,
- 0.7853867948F, 0.7857552914F, 0.7861234663F, 0.7864913191F,
- 0.7868588497F, 0.7872260578F, 0.7875929431F, 0.7879595055F,
- 0.7883257445F, 0.7886916601F, 0.7890572520F, 0.7894225198F,
- 0.7897874635F, 0.7901520827F, 0.7905163772F, 0.7908803468F,
- 0.7912439912F, 0.7916073102F, 0.7919703035F, 0.7923329710F,
- 0.7926953124F, 0.7930573274F, 0.7934190158F, 0.7937803774F,
- 0.7941414120F, 0.7945021193F, 0.7948624991F, 0.7952225511F,
- 0.7955822752F, 0.7959416711F, 0.7963007387F, 0.7966594775F,
- 0.7970178875F, 0.7973759685F, 0.7977337201F, 0.7980911422F,
- 0.7984482346F, 0.7988049970F, 0.7991614292F, 0.7995175310F,
- 0.7998733022F, 0.8002287426F, 0.8005838519F, 0.8009386299F,
- 0.8012930765F, 0.8016471914F, 0.8020009744F, 0.8023544253F,
- 0.8027075438F, 0.8030603298F, 0.8034127831F, 0.8037649035F,
- 0.8041166906F, 0.8044681445F, 0.8048192647F, 0.8051700512F,
- 0.8055205038F, 0.8058706222F, 0.8062204062F, 0.8065698556F,
- 0.8069189702F, 0.8072677499F, 0.8076161944F, 0.8079643036F,
- 0.8083120772F, 0.8086595151F, 0.8090066170F, 0.8093533827F,
- 0.8096998122F, 0.8100459051F, 0.8103916613F, 0.8107370806F,
- 0.8110821628F, 0.8114269077F, 0.8117713151F, 0.8121153849F,
- 0.8124591169F, 0.8128025108F, 0.8131455666F, 0.8134882839F,
- 0.8138306627F, 0.8141727027F, 0.8145144038F, 0.8148557658F,
- 0.8151967886F, 0.8155374718F, 0.8158778154F, 0.8162178192F,
- 0.8165574830F, 0.8168968067F, 0.8172357900F, 0.8175744328F,
- 0.8179127349F, 0.8182506962F, 0.8185883164F, 0.8189255955F,
- 0.8192625332F, 0.8195991295F, 0.8199353840F, 0.8202712967F,
- 0.8206068673F, 0.8209420958F, 0.8212769820F, 0.8216115256F,
- 0.8219457266F, 0.8222795848F, 0.8226131000F, 0.8229462721F,
- 0.8232791009F, 0.8236115863F, 0.8239437280F, 0.8242755260F,
- 0.8246069801F, 0.8249380901F, 0.8252688559F, 0.8255992774F,
- 0.8259293544F, 0.8262590867F, 0.8265884741F, 0.8269175167F,
- 0.8272462141F, 0.8275745663F, 0.8279025732F, 0.8282302344F,
- 0.8285575501F, 0.8288845199F, 0.8292111437F, 0.8295374215F,
- 0.8298633530F, 0.8301889382F, 0.8305141768F, 0.8308390688F,
- 0.8311636141F, 0.8314878124F, 0.8318116637F, 0.8321351678F,
- 0.8324583246F, 0.8327811340F, 0.8331035957F, 0.8334257098F,
- 0.8337474761F, 0.8340688944F, 0.8343899647F, 0.8347106867F,
- 0.8350310605F, 0.8353510857F, 0.8356707624F, 0.8359900904F,
- 0.8363090696F, 0.8366276999F, 0.8369459811F, 0.8372639131F,
- 0.8375814958F, 0.8378987292F, 0.8382156130F, 0.8385321472F,
- 0.8388483316F, 0.8391641662F, 0.8394796508F, 0.8397947853F,
- 0.8401095697F, 0.8404240037F, 0.8407380873F, 0.8410518204F,
- 0.8413652029F, 0.8416782347F, 0.8419909156F, 0.8423032456F,
- 0.8426152245F, 0.8429268523F, 0.8432381289F, 0.8435490541F,
- 0.8438596279F, 0.8441698502F, 0.8444797208F, 0.8447892396F,
- 0.8450984067F, 0.8454072218F, 0.8457156849F, 0.8460237959F,
- 0.8463315547F, 0.8466389612F, 0.8469460154F, 0.8472527170F,
- 0.8475590661F, 0.8478650625F, 0.8481707063F, 0.8484759971F,
- 0.8487809351F, 0.8490855201F, 0.8493897521F, 0.8496936308F,
- 0.8499971564F, 0.8503003286F, 0.8506031474F, 0.8509056128F,
- 0.8512077246F, 0.8515094828F, 0.8518108872F, 0.8521119379F,
- 0.8524126348F, 0.8527129777F, 0.8530129666F, 0.8533126015F,
- 0.8536118822F, 0.8539108087F, 0.8542093809F, 0.8545075988F,
- 0.8548054623F, 0.8551029712F, 0.8554001257F, 0.8556969255F,
- 0.8559933707F, 0.8562894611F, 0.8565851968F, 0.8568805775F,
- 0.8571756034F, 0.8574702743F, 0.8577645902F, 0.8580585509F,
- 0.8583521566F, 0.8586454070F, 0.8589383021F, 0.8592308420F,
- 0.8595230265F, 0.8598148556F, 0.8601063292F, 0.8603974473F,
- 0.8606882098F, 0.8609786167F, 0.8612686680F, 0.8615583636F,
- 0.8618477034F, 0.8621366874F, 0.8624253156F, 0.8627135878F,
- 0.8630015042F, 0.8632890646F, 0.8635762690F, 0.8638631173F,
- 0.8641496096F, 0.8644357457F, 0.8647215257F, 0.8650069495F,
- 0.8652920171F, 0.8655767283F, 0.8658610833F, 0.8661450820F,
- 0.8664287243F, 0.8667120102F, 0.8669949397F, 0.8672775127F,
- 0.8675597293F, 0.8678415894F, 0.8681230929F, 0.8684042398F,
- 0.8686850302F, 0.8689654640F, 0.8692455412F, 0.8695252617F,
- 0.8698046255F, 0.8700836327F, 0.8703622831F, 0.8706405768F,
- 0.8709185138F, 0.8711960940F, 0.8714733174F, 0.8717501840F,
- 0.8720266939F, 0.8723028469F, 0.8725786430F, 0.8728540824F,
- 0.8731291648F, 0.8734038905F, 0.8736782592F, 0.8739522711F,
- 0.8742259261F, 0.8744992242F, 0.8747721653F, 0.8750447496F,
- 0.8753169770F, 0.8755888475F, 0.8758603611F, 0.8761315177F,
- 0.8764023175F, 0.8766727603F, 0.8769428462F, 0.8772125752F,
- 0.8774819474F, 0.8777509626F, 0.8780196209F, 0.8782879224F,
- 0.8785558669F, 0.8788234546F, 0.8790906854F, 0.8793575594F,
- 0.8796240765F, 0.8798902368F, 0.8801560403F, 0.8804214870F,
- 0.8806865768F, 0.8809513099F, 0.8812156863F, 0.8814797059F,
- 0.8817433687F, 0.8820066749F, 0.8822696243F, 0.8825322171F,
- 0.8827944532F, 0.8830563327F, 0.8833178556F, 0.8835790219F,
- 0.8838398316F, 0.8841002848F, 0.8843603815F, 0.8846201217F,
- 0.8848795054F, 0.8851385327F, 0.8853972036F, 0.8856555182F,
- 0.8859134764F, 0.8861710783F, 0.8864283239F, 0.8866852133F,
- 0.8869417464F, 0.8871979234F, 0.8874537443F, 0.8877092090F,
- 0.8879643177F, 0.8882190704F, 0.8884734671F, 0.8887275078F,
- 0.8889811927F, 0.8892345216F, 0.8894874948F, 0.8897401122F,
- 0.8899923738F, 0.8902442798F, 0.8904958301F, 0.8907470248F,
- 0.8909978640F, 0.8912483477F, 0.8914984759F, 0.8917482487F,
- 0.8919976662F, 0.8922467284F, 0.8924954353F, 0.8927437871F,
- 0.8929917837F, 0.8932394252F, 0.8934867118F, 0.8937336433F,
- 0.8939802199F, 0.8942264417F, 0.8944723087F, 0.8947178210F,
- 0.8949629785F, 0.8952077815F, 0.8954522299F, 0.8956963239F,
- 0.8959400634F, 0.8961834486F, 0.8964264795F, 0.8966691561F,
- 0.8969114786F, 0.8971534470F, 0.8973950614F, 0.8976363219F,
- 0.8978772284F, 0.8981177812F, 0.8983579802F, 0.8985978256F,
- 0.8988373174F, 0.8990764556F, 0.8993152405F, 0.8995536720F,
- 0.8997917502F, 0.9000294751F, 0.9002668470F, 0.9005038658F,
- 0.9007405317F, 0.9009768446F, 0.9012128048F, 0.9014484123F,
- 0.9016836671F, 0.9019185693F, 0.9021531191F, 0.9023873165F,
- 0.9026211616F, 0.9028546546F, 0.9030877954F, 0.9033205841F,
- 0.9035530210F, 0.9037851059F, 0.9040168392F, 0.9042482207F,
- 0.9044792507F, 0.9047099293F, 0.9049402564F, 0.9051702323F,
- 0.9053998569F, 0.9056291305F, 0.9058580531F, 0.9060866248F,
- 0.9063148457F, 0.9065427159F, 0.9067702355F, 0.9069974046F,
- 0.9072242233F, 0.9074506917F, 0.9076768100F, 0.9079025782F,
- 0.9081279964F, 0.9083530647F, 0.9085777833F, 0.9088021523F,
- 0.9090261717F, 0.9092498417F, 0.9094731623F, 0.9096961338F,
- 0.9099187561F, 0.9101410295F, 0.9103629540F, 0.9105845297F,
- 0.9108057568F, 0.9110266354F, 0.9112471656F, 0.9114673475F,
- 0.9116871812F, 0.9119066668F, 0.9121258046F, 0.9123445945F,
- 0.9125630367F, 0.9127811314F, 0.9129988786F, 0.9132162785F,
- 0.9134333312F, 0.9136500368F, 0.9138663954F, 0.9140824073F,
- 0.9142980724F, 0.9145133910F, 0.9147283632F, 0.9149429890F,
- 0.9151572687F, 0.9153712023F, 0.9155847900F, 0.9157980319F,
- 0.9160109282F, 0.9162234790F, 0.9164356844F, 0.9166475445F,
- 0.9168590595F, 0.9170702296F, 0.9172810548F, 0.9174915354F,
- 0.9177016714F, 0.9179114629F, 0.9181209102F, 0.9183300134F,
- 0.9185387726F, 0.9187471879F, 0.9189552595F, 0.9191629876F,
- 0.9193703723F, 0.9195774136F, 0.9197841119F, 0.9199904672F,
- 0.9201964797F, 0.9204021495F, 0.9206074767F, 0.9208124616F,
- 0.9210171043F, 0.9212214049F, 0.9214253636F, 0.9216289805F,
- 0.9218322558F, 0.9220351896F, 0.9222377821F, 0.9224400335F,
- 0.9226419439F, 0.9228435134F, 0.9230447423F, 0.9232456307F,
- 0.9234461787F, 0.9236463865F, 0.9238462543F, 0.9240457822F,
- 0.9242449704F, 0.9244438190F, 0.9246423282F, 0.9248404983F,
- 0.9250383293F, 0.9252358214F, 0.9254329747F, 0.9256297896F,
- 0.9258262660F, 0.9260224042F, 0.9262182044F, 0.9264136667F,
- 0.9266087913F, 0.9268035783F, 0.9269980280F, 0.9271921405F,
- 0.9273859160F, 0.9275793546F, 0.9277724566F, 0.9279652221F,
- 0.9281576513F, 0.9283497443F, 0.9285415014F, 0.9287329227F,
- 0.9289240084F, 0.9291147586F, 0.9293051737F, 0.9294952536F,
- 0.9296849987F, 0.9298744091F, 0.9300634850F, 0.9302522266F,
- 0.9304406340F, 0.9306287074F, 0.9308164471F, 0.9310038532F,
- 0.9311909259F, 0.9313776654F, 0.9315640719F, 0.9317501455F,
- 0.9319358865F, 0.9321212951F, 0.9323063713F, 0.9324911155F,
- 0.9326755279F, 0.9328596085F, 0.9330433577F, 0.9332267756F,
- 0.9334098623F, 0.9335926182F, 0.9337750434F, 0.9339571380F,
- 0.9341389023F, 0.9343203366F, 0.9345014409F, 0.9346822155F,
- 0.9348626606F, 0.9350427763F, 0.9352225630F, 0.9354020207F,
- 0.9355811498F, 0.9357599503F, 0.9359384226F, 0.9361165667F,
- 0.9362943830F, 0.9364718716F, 0.9366490327F, 0.9368258666F,
- 0.9370023733F, 0.9371785533F, 0.9373544066F, 0.9375299335F,
- 0.9377051341F, 0.9378800087F, 0.9380545576F, 0.9382287809F,
- 0.9384026787F, 0.9385762515F, 0.9387494993F, 0.9389224223F,
- 0.9390950209F, 0.9392672951F, 0.9394392453F, 0.9396108716F,
- 0.9397821743F, 0.9399531536F, 0.9401238096F, 0.9402941427F,
- 0.9404641530F, 0.9406338407F, 0.9408032061F, 0.9409722495F,
- 0.9411409709F, 0.9413093707F, 0.9414774491F, 0.9416452062F,
- 0.9418126424F, 0.9419797579F, 0.9421465528F, 0.9423130274F,
- 0.9424791819F, 0.9426450166F, 0.9428105317F, 0.9429757274F,
- 0.9431406039F, 0.9433051616F, 0.9434694005F, 0.9436333209F,
- 0.9437969232F, 0.9439602074F, 0.9441231739F, 0.9442858229F,
- 0.9444481545F, 0.9446101691F, 0.9447718669F, 0.9449332481F,
- 0.9450943129F, 0.9452550617F, 0.9454154945F, 0.9455756118F,
- 0.9457354136F, 0.9458949003F, 0.9460540721F, 0.9462129292F,
- 0.9463714719F, 0.9465297003F, 0.9466876149F, 0.9468452157F,
- 0.9470025031F, 0.9471594772F, 0.9473161384F, 0.9474724869F,
- 0.9476285229F, 0.9477842466F, 0.9479396584F, 0.9480947585F,
- 0.9482495470F, 0.9484040243F, 0.9485581906F, 0.9487120462F,
- 0.9488655913F, 0.9490188262F, 0.9491717511F, 0.9493243662F,
- 0.9494766718F, 0.9496286683F, 0.9497803557F, 0.9499317345F,
- 0.9500828047F, 0.9502335668F, 0.9503840209F, 0.9505341673F,
- 0.9506840062F, 0.9508335380F, 0.9509827629F, 0.9511316810F,
- 0.9512802928F, 0.9514285984F, 0.9515765982F, 0.9517242923F,
- 0.9518716810F, 0.9520187646F, 0.9521655434F, 0.9523120176F,
- 0.9524581875F, 0.9526040534F, 0.9527496154F, 0.9528948739F,
- 0.9530398292F, 0.9531844814F, 0.9533288310F, 0.9534728780F,
- 0.9536166229F, 0.9537600659F, 0.9539032071F, 0.9540460470F,
- 0.9541885858F, 0.9543308237F, 0.9544727611F, 0.9546143981F,
- 0.9547557351F, 0.9548967723F, 0.9550375100F, 0.9551779485F,
- 0.9553180881F, 0.9554579290F, 0.9555974714F, 0.9557367158F,
- 0.9558756623F, 0.9560143112F, 0.9561526628F, 0.9562907174F,
- 0.9564284752F, 0.9565659366F, 0.9567031017F, 0.9568399710F,
- 0.9569765446F, 0.9571128229F, 0.9572488061F, 0.9573844944F,
- 0.9575198883F, 0.9576549879F, 0.9577897936F, 0.9579243056F,
- 0.9580585242F, 0.9581924497F, 0.9583260824F, 0.9584594226F,
- 0.9585924705F, 0.9587252264F, 0.9588576906F, 0.9589898634F,
- 0.9591217452F, 0.9592533360F, 0.9593846364F, 0.9595156465F,
- 0.9596463666F, 0.9597767971F, 0.9599069382F, 0.9600367901F,
- 0.9601663533F, 0.9602956279F, 0.9604246143F, 0.9605533128F,
- 0.9606817236F, 0.9608098471F, 0.9609376835F, 0.9610652332F,
- 0.9611924963F, 0.9613194733F, 0.9614461644F, 0.9615725699F,
- 0.9616986901F, 0.9618245253F, 0.9619500757F, 0.9620753418F,
- 0.9622003238F, 0.9623250219F, 0.9624494365F, 0.9625735679F,
- 0.9626974163F, 0.9628209821F, 0.9629442656F, 0.9630672671F,
- 0.9631899868F, 0.9633124251F, 0.9634345822F, 0.9635564585F,
- 0.9636780543F, 0.9637993699F, 0.9639204056F, 0.9640411616F,
- 0.9641616383F, 0.9642818359F, 0.9644017549F, 0.9645213955F,
- 0.9646407579F, 0.9647598426F, 0.9648786497F, 0.9649971797F,
- 0.9651154328F, 0.9652334092F, 0.9653511095F, 0.9654685337F,
- 0.9655856823F, 0.9657025556F, 0.9658191538F, 0.9659354773F,
- 0.9660515263F, 0.9661673013F, 0.9662828024F, 0.9663980300F,
- 0.9665129845F, 0.9666276660F, 0.9667420750F, 0.9668562118F,
- 0.9669700766F, 0.9670836698F, 0.9671969917F, 0.9673100425F,
- 0.9674228227F, 0.9675353325F, 0.9676475722F, 0.9677595422F,
- 0.9678712428F, 0.9679826742F, 0.9680938368F, 0.9682047309F,
- 0.9683153569F, 0.9684257150F, 0.9685358056F, 0.9686456289F,
- 0.9687551853F, 0.9688644752F, 0.9689734987F, 0.9690822564F,
- 0.9691907483F, 0.9692989750F, 0.9694069367F, 0.9695146337F,
- 0.9696220663F, 0.9697292349F, 0.9698361398F, 0.9699427813F,
- 0.9700491597F, 0.9701552754F, 0.9702611286F, 0.9703667197F,
- 0.9704720490F, 0.9705771169F, 0.9706819236F, 0.9707864695F,
- 0.9708907549F, 0.9709947802F, 0.9710985456F, 0.9712020514F,
- 0.9713052981F, 0.9714082859F, 0.9715110151F, 0.9716134862F,
- 0.9717156993F, 0.9718176549F, 0.9719193532F, 0.9720207946F,
- 0.9721219794F, 0.9722229080F, 0.9723235806F, 0.9724239976F,
- 0.9725241593F, 0.9726240661F, 0.9727237183F, 0.9728231161F,
- 0.9729222601F, 0.9730211503F, 0.9731197873F, 0.9732181713F,
- 0.9733163027F, 0.9734141817F, 0.9735118088F, 0.9736091842F,
- 0.9737063083F, 0.9738031814F, 0.9738998039F, 0.9739961760F,
- 0.9740922981F, 0.9741881706F, 0.9742837938F, 0.9743791680F,
- 0.9744742935F, 0.9745691707F, 0.9746637999F, 0.9747581814F,
- 0.9748523157F, 0.9749462029F, 0.9750398435F, 0.9751332378F,
- 0.9752263861F, 0.9753192887F, 0.9754119461F, 0.9755043585F,
- 0.9755965262F, 0.9756884496F, 0.9757801291F, 0.9758715650F,
- 0.9759627575F, 0.9760537071F, 0.9761444141F, 0.9762348789F,
- 0.9763251016F, 0.9764150828F, 0.9765048228F, 0.9765943218F,
- 0.9766835802F, 0.9767725984F, 0.9768613767F, 0.9769499154F,
- 0.9770382149F, 0.9771262755F, 0.9772140976F, 0.9773016815F,
- 0.9773890275F, 0.9774761360F, 0.9775630073F, 0.9776496418F,
- 0.9777360398F, 0.9778222016F, 0.9779081277F, 0.9779938182F,
- 0.9780792736F, 0.9781644943F, 0.9782494805F, 0.9783342326F,
- 0.9784187509F, 0.9785030359F, 0.9785870877F, 0.9786709069F,
- 0.9787544936F, 0.9788378484F, 0.9789209714F, 0.9790038631F,
- 0.9790865238F, 0.9791689538F, 0.9792511535F, 0.9793331232F,
- 0.9794148633F, 0.9794963742F, 0.9795776561F, 0.9796587094F,
- 0.9797395345F, 0.9798201316F, 0.9799005013F, 0.9799806437F,
- 0.9800605593F, 0.9801402483F, 0.9802197112F, 0.9802989483F,
- 0.9803779600F, 0.9804567465F, 0.9805353082F, 0.9806136455F,
- 0.9806917587F, 0.9807696482F, 0.9808473143F, 0.9809247574F,
- 0.9810019778F, 0.9810789759F, 0.9811557519F, 0.9812323064F,
- 0.9813086395F, 0.9813847517F, 0.9814606433F, 0.9815363147F,
- 0.9816117662F, 0.9816869981F, 0.9817620108F, 0.9818368047F,
- 0.9819113801F, 0.9819857374F, 0.9820598769F, 0.9821337989F,
- 0.9822075038F, 0.9822809920F, 0.9823542638F, 0.9824273195F,
- 0.9825001596F, 0.9825727843F, 0.9826451940F, 0.9827173891F,
- 0.9827893700F, 0.9828611368F, 0.9829326901F, 0.9830040302F,
- 0.9830751574F, 0.9831460720F, 0.9832167745F, 0.9832872652F,
- 0.9833575444F, 0.9834276124F, 0.9834974697F, 0.9835671166F,
- 0.9836365535F, 0.9837057806F, 0.9837747983F, 0.9838436071F,
- 0.9839122072F, 0.9839805990F, 0.9840487829F, 0.9841167591F,
- 0.9841845282F, 0.9842520903F, 0.9843194459F, 0.9843865953F,
- 0.9844535389F, 0.9845202771F, 0.9845868101F, 0.9846531383F,
- 0.9847192622F, 0.9847851820F, 0.9848508980F, 0.9849164108F,
- 0.9849817205F, 0.9850468276F, 0.9851117324F, 0.9851764352F,
- 0.9852409365F, 0.9853052366F, 0.9853693358F, 0.9854332344F,
- 0.9854969330F, 0.9855604317F, 0.9856237309F, 0.9856868310F,
- 0.9857497325F, 0.9858124355F, 0.9858749404F, 0.9859372477F,
- 0.9859993577F, 0.9860612707F, 0.9861229871F, 0.9861845072F,
- 0.9862458315F, 0.9863069601F, 0.9863678936F, 0.9864286322F,
- 0.9864891764F, 0.9865495264F, 0.9866096826F, 0.9866696454F,
- 0.9867294152F, 0.9867889922F, 0.9868483769F, 0.9869075695F,
- 0.9869665706F, 0.9870253803F, 0.9870839991F, 0.9871424273F,
- 0.9872006653F, 0.9872587135F, 0.9873165721F, 0.9873742415F,
- 0.9874317222F, 0.9874890144F, 0.9875461185F, 0.9876030348F,
- 0.9876597638F, 0.9877163057F, 0.9877726610F, 0.9878288300F,
- 0.9878848130F, 0.9879406104F, 0.9879962225F, 0.9880516497F,
- 0.9881068924F, 0.9881619509F, 0.9882168256F, 0.9882715168F,
- 0.9883260249F, 0.9883803502F, 0.9884344931F, 0.9884884539F,
- 0.9885422331F, 0.9885958309F, 0.9886492477F, 0.9887024838F,
- 0.9887555397F, 0.9888084157F, 0.9888611120F, 0.9889136292F,
- 0.9889659675F, 0.9890181273F, 0.9890701089F, 0.9891219128F,
- 0.9891735392F, 0.9892249885F, 0.9892762610F, 0.9893273572F,
- 0.9893782774F, 0.9894290219F, 0.9894795911F, 0.9895299853F,
- 0.9895802049F, 0.9896302502F, 0.9896801217F, 0.9897298196F,
- 0.9897793443F, 0.9898286961F, 0.9898778755F, 0.9899268828F,
- 0.9899757183F, 0.9900243823F, 0.9900728753F, 0.9901211976F,
- 0.9901693495F, 0.9902173314F, 0.9902651436F, 0.9903127865F,
- 0.9903602605F, 0.9904075659F, 0.9904547031F, 0.9905016723F,
- 0.9905484740F, 0.9905951086F, 0.9906415763F, 0.9906878775F,
- 0.9907340126F, 0.9907799819F, 0.9908257858F, 0.9908714247F,
- 0.9909168988F, 0.9909622086F, 0.9910073543F, 0.9910523364F,
- 0.9910971552F, 0.9911418110F, 0.9911863042F, 0.9912306351F,
- 0.9912748042F, 0.9913188117F, 0.9913626580F, 0.9914063435F,
- 0.9914498684F, 0.9914932333F, 0.9915364383F, 0.9915794839F,
- 0.9916223703F, 0.9916650981F, 0.9917076674F, 0.9917500787F,
- 0.9917923323F, 0.9918344286F, 0.9918763679F, 0.9919181505F,
- 0.9919597769F, 0.9920012473F, 0.9920425621F, 0.9920837217F,
- 0.9921247263F, 0.9921655765F, 0.9922062724F, 0.9922468145F,
- 0.9922872030F, 0.9923274385F, 0.9923675211F, 0.9924074513F,
- 0.9924472294F, 0.9924868557F, 0.9925263306F, 0.9925656544F,
- 0.9926048275F, 0.9926438503F, 0.9926827230F, 0.9927214461F,
- 0.9927600199F, 0.9927984446F, 0.9928367208F, 0.9928748486F,
- 0.9929128285F, 0.9929506608F, 0.9929883459F, 0.9930258841F,
- 0.9930632757F, 0.9931005211F, 0.9931376207F, 0.9931745747F,
- 0.9932113836F, 0.9932480476F, 0.9932845671F, 0.9933209425F,
- 0.9933571742F, 0.9933932623F, 0.9934292074F, 0.9934650097F,
- 0.9935006696F, 0.9935361874F, 0.9935715635F, 0.9936067982F,
- 0.9936418919F, 0.9936768448F, 0.9937116574F, 0.9937463300F,
- 0.9937808629F, 0.9938152565F, 0.9938495111F, 0.9938836271F,
- 0.9939176047F, 0.9939514444F, 0.9939851465F, 0.9940187112F,
- 0.9940521391F, 0.9940854303F, 0.9941185853F, 0.9941516044F,
- 0.9941844879F, 0.9942172361F, 0.9942498495F, 0.9942823283F,
- 0.9943146729F, 0.9943468836F, 0.9943789608F, 0.9944109047F,
- 0.9944427158F, 0.9944743944F, 0.9945059408F, 0.9945373553F,
- 0.9945686384F, 0.9945997902F, 0.9946308112F, 0.9946617017F,
- 0.9946924621F, 0.9947230926F, 0.9947535937F, 0.9947839656F,
- 0.9948142086F, 0.9948443232F, 0.9948743097F, 0.9949041683F,
- 0.9949338995F, 0.9949635035F, 0.9949929807F, 0.9950223315F,
- 0.9950515561F, 0.9950806549F, 0.9951096282F, 0.9951384764F,
- 0.9951671998F, 0.9951957987F, 0.9952242735F, 0.9952526245F,
- 0.9952808520F, 0.9953089564F, 0.9953369380F, 0.9953647971F,
- 0.9953925340F, 0.9954201491F, 0.9954476428F, 0.9954750153F,
- 0.9955022670F, 0.9955293981F, 0.9955564092F, 0.9955833003F,
- 0.9956100720F, 0.9956367245F, 0.9956632582F, 0.9956896733F,
- 0.9957159703F, 0.9957421494F, 0.9957682110F, 0.9957941553F,
- 0.9958199828F, 0.9958456937F, 0.9958712884F, 0.9958967672F,
- 0.9959221305F, 0.9959473784F, 0.9959725115F, 0.9959975300F,
- 0.9960224342F, 0.9960472244F, 0.9960719011F, 0.9960964644F,
- 0.9961209148F, 0.9961452525F, 0.9961694779F, 0.9961935913F,
- 0.9962175930F, 0.9962414834F, 0.9962652627F, 0.9962889313F,
- 0.9963124895F, 0.9963359377F, 0.9963592761F, 0.9963825051F,
- 0.9964056250F, 0.9964286361F, 0.9964515387F, 0.9964743332F,
- 0.9964970198F, 0.9965195990F, 0.9965420709F, 0.9965644360F,
- 0.9965866946F, 0.9966088469F, 0.9966308932F, 0.9966528340F,
- 0.9966746695F, 0.9966964001F, 0.9967180260F, 0.9967395475F,
- 0.9967609651F, 0.9967822789F, 0.9968034894F, 0.9968245968F,
- 0.9968456014F, 0.9968665036F, 0.9968873037F, 0.9969080019F,
- 0.9969285987F, 0.9969490942F, 0.9969694889F, 0.9969897830F,
- 0.9970099769F, 0.9970300708F, 0.9970500651F, 0.9970699601F,
- 0.9970897561F, 0.9971094533F, 0.9971290522F, 0.9971485531F,
- 0.9971679561F, 0.9971872617F, 0.9972064702F, 0.9972255818F,
- 0.9972445968F, 0.9972635157F, 0.9972823386F, 0.9973010659F,
- 0.9973196980F, 0.9973382350F, 0.9973566773F, 0.9973750253F,
- 0.9973932791F, 0.9974114392F, 0.9974295059F, 0.9974474793F,
- 0.9974653599F, 0.9974831480F, 0.9975008438F, 0.9975184476F,
- 0.9975359598F, 0.9975533806F, 0.9975707104F, 0.9975879495F,
- 0.9976050981F, 0.9976221566F, 0.9976391252F, 0.9976560043F,
- 0.9976727941F, 0.9976894950F, 0.9977061073F, 0.9977226312F,
- 0.9977390671F, 0.9977554152F, 0.9977716759F, 0.9977878495F,
- 0.9978039361F, 0.9978199363F, 0.9978358501F, 0.9978516780F,
- 0.9978674202F, 0.9978830771F, 0.9978986488F, 0.9979141358F,
- 0.9979295383F, 0.9979448566F, 0.9979600909F, 0.9979752417F,
- 0.9979903091F, 0.9980052936F, 0.9980201952F, 0.9980350145F,
- 0.9980497515F, 0.9980644067F, 0.9980789804F, 0.9980934727F,
- 0.9981078841F, 0.9981222147F, 0.9981364649F, 0.9981506350F,
- 0.9981647253F, 0.9981787360F, 0.9981926674F, 0.9982065199F,
- 0.9982202936F, 0.9982339890F, 0.9982476062F, 0.9982611456F,
- 0.9982746074F, 0.9982879920F, 0.9983012996F, 0.9983145304F,
- 0.9983276849F, 0.9983407632F, 0.9983537657F, 0.9983666926F,
- 0.9983795442F, 0.9983923208F, 0.9984050226F, 0.9984176501F,
- 0.9984302033F, 0.9984426827F, 0.9984550884F, 0.9984674208F,
- 0.9984796802F, 0.9984918667F, 0.9985039808F, 0.9985160227F,
- 0.9985279926F, 0.9985398909F, 0.9985517177F, 0.9985634734F,
- 0.9985751583F, 0.9985867727F, 0.9985983167F, 0.9986097907F,
- 0.9986211949F, 0.9986325297F, 0.9986437953F, 0.9986549919F,
- 0.9986661199F, 0.9986771795F, 0.9986881710F, 0.9986990946F,
- 0.9987099507F, 0.9987207394F, 0.9987314611F, 0.9987421161F,
- 0.9987527045F, 0.9987632267F, 0.9987736829F, 0.9987840734F,
- 0.9987943985F, 0.9988046584F, 0.9988148534F, 0.9988249838F,
- 0.9988350498F, 0.9988450516F, 0.9988549897F, 0.9988648641F,
- 0.9988746753F, 0.9988844233F, 0.9988941086F, 0.9989037313F,
- 0.9989132918F, 0.9989227902F, 0.9989322269F, 0.9989416021F,
- 0.9989509160F, 0.9989601690F, 0.9989693613F, 0.9989784931F,
- 0.9989875647F, 0.9989965763F, 0.9990055283F, 0.9990144208F,
- 0.9990232541F, 0.9990320286F, 0.9990407443F, 0.9990494016F,
- 0.9990580008F, 0.9990665421F, 0.9990750257F, 0.9990834519F,
- 0.9990918209F, 0.9991001331F, 0.9991083886F, 0.9991165877F,
- 0.9991247307F, 0.9991328177F, 0.9991408491F, 0.9991488251F,
- 0.9991567460F, 0.9991646119F, 0.9991724232F, 0.9991801801F,
- 0.9991878828F, 0.9991955316F, 0.9992031267F, 0.9992106684F,
- 0.9992181569F, 0.9992255925F, 0.9992329753F, 0.9992403057F,
- 0.9992475839F, 0.9992548101F, 0.9992619846F, 0.9992691076F,
- 0.9992761793F, 0.9992832001F, 0.9992901701F, 0.9992970895F,
- 0.9993039587F, 0.9993107777F, 0.9993175470F, 0.9993242667F,
- 0.9993309371F, 0.9993375583F, 0.9993441307F, 0.9993506545F,
- 0.9993571298F, 0.9993635570F, 0.9993699362F, 0.9993762678F,
- 0.9993825519F, 0.9993887887F, 0.9993949785F, 0.9994011216F,
- 0.9994072181F, 0.9994132683F, 0.9994192725F, 0.9994252307F,
- 0.9994311434F, 0.9994370107F, 0.9994428327F, 0.9994486099F,
- 0.9994543423F, 0.9994600303F, 0.9994656739F, 0.9994712736F,
- 0.9994768294F, 0.9994823417F, 0.9994878105F, 0.9994932363F,
- 0.9994986191F, 0.9995039592F, 0.9995092568F, 0.9995145122F,
- 0.9995197256F, 0.9995248971F, 0.9995300270F, 0.9995351156F,
- 0.9995401630F, 0.9995451695F, 0.9995501352F, 0.9995550604F,
- 0.9995599454F, 0.9995647903F, 0.9995695953F, 0.9995743607F,
- 0.9995790866F, 0.9995837734F, 0.9995884211F, 0.9995930300F,
- 0.9995976004F, 0.9996021324F, 0.9996066263F, 0.9996110822F,
- 0.9996155004F, 0.9996198810F, 0.9996242244F, 0.9996285306F,
- 0.9996327999F, 0.9996370326F, 0.9996412287F, 0.9996453886F,
- 0.9996495125F, 0.9996536004F, 0.9996576527F, 0.9996616696F,
- 0.9996656512F, 0.9996695977F, 0.9996735094F, 0.9996773865F,
- 0.9996812291F, 0.9996850374F, 0.9996888118F, 0.9996925523F,
- 0.9996962591F, 0.9996999325F, 0.9997035727F, 0.9997071798F,
- 0.9997107541F, 0.9997142957F, 0.9997178049F, 0.9997212818F,
- 0.9997247266F, 0.9997281396F, 0.9997315209F, 0.9997348708F,
- 0.9997381893F, 0.9997414767F, 0.9997447333F, 0.9997479591F,
- 0.9997511544F, 0.9997543194F, 0.9997574542F, 0.9997605591F,
- 0.9997636342F, 0.9997666797F, 0.9997696958F, 0.9997726828F,
- 0.9997756407F, 0.9997785698F, 0.9997814703F, 0.9997843423F,
- 0.9997871860F, 0.9997900016F, 0.9997927894F, 0.9997955494F,
- 0.9997982818F, 0.9998009869F, 0.9998036648F, 0.9998063157F,
- 0.9998089398F, 0.9998115373F, 0.9998141082F, 0.9998166529F,
- 0.9998191715F, 0.9998216642F, 0.9998241311F, 0.9998265724F,
- 0.9998289884F, 0.9998313790F, 0.9998337447F, 0.9998360854F,
- 0.9998384015F, 0.9998406930F, 0.9998429602F, 0.9998452031F,
- 0.9998474221F, 0.9998496171F, 0.9998517885F, 0.9998539364F,
- 0.9998560610F, 0.9998581624F, 0.9998602407F, 0.9998622962F,
- 0.9998643291F, 0.9998663394F, 0.9998683274F, 0.9998702932F,
- 0.9998722370F, 0.9998741589F, 0.9998760591F, 0.9998779378F,
- 0.9998797952F, 0.9998816313F, 0.9998834464F, 0.9998852406F,
- 0.9998870141F, 0.9998887670F, 0.9998904995F, 0.9998922117F,
- 0.9998939039F, 0.9998955761F, 0.9998972285F, 0.9998988613F,
- 0.9999004746F, 0.9999020686F, 0.9999036434F, 0.9999051992F,
- 0.9999067362F, 0.9999082544F, 0.9999097541F, 0.9999112354F,
- 0.9999126984F, 0.9999141433F, 0.9999155703F, 0.9999169794F,
- 0.9999183709F, 0.9999197449F, 0.9999211014F, 0.9999224408F,
- 0.9999237631F, 0.9999250684F, 0.9999263570F, 0.9999276289F,
- 0.9999288843F, 0.9999301233F, 0.9999313461F, 0.9999325529F,
- 0.9999337437F, 0.9999349187F, 0.9999360780F, 0.9999372218F,
- 0.9999383503F, 0.9999394635F, 0.9999405616F, 0.9999416447F,
- 0.9999427129F, 0.9999437665F, 0.9999448055F, 0.9999458301F,
- 0.9999468404F, 0.9999478365F, 0.9999488185F, 0.9999497867F,
- 0.9999507411F, 0.9999516819F, 0.9999526091F, 0.9999535230F,
- 0.9999544236F, 0.9999553111F, 0.9999561856F, 0.9999570472F,
- 0.9999578960F, 0.9999587323F, 0.9999595560F, 0.9999603674F,
- 0.9999611666F, 0.9999619536F, 0.9999627286F, 0.9999634917F,
- 0.9999642431F, 0.9999649828F, 0.9999657110F, 0.9999664278F,
- 0.9999671334F, 0.9999678278F, 0.9999685111F, 0.9999691835F,
- 0.9999698451F, 0.9999704960F, 0.9999711364F, 0.9999717662F,
- 0.9999723858F, 0.9999729950F, 0.9999735942F, 0.9999741834F,
- 0.9999747626F, 0.9999753321F, 0.9999758919F, 0.9999764421F,
- 0.9999769828F, 0.9999775143F, 0.9999780364F, 0.9999785495F,
- 0.9999790535F, 0.9999795485F, 0.9999800348F, 0.9999805124F,
- 0.9999809813F, 0.9999814417F, 0.9999818938F, 0.9999823375F,
- 0.9999827731F, 0.9999832005F, 0.9999836200F, 0.9999840316F,
- 0.9999844353F, 0.9999848314F, 0.9999852199F, 0.9999856008F,
- 0.9999859744F, 0.9999863407F, 0.9999866997F, 0.9999870516F,
- 0.9999873965F, 0.9999877345F, 0.9999880656F, 0.9999883900F,
- 0.9999887078F, 0.9999890190F, 0.9999893237F, 0.9999896220F,
- 0.9999899140F, 0.9999901999F, 0.9999904796F, 0.9999907533F,
- 0.9999910211F, 0.9999912830F, 0.9999915391F, 0.9999917896F,
- 0.9999920345F, 0.9999922738F, 0.9999925077F, 0.9999927363F,
- 0.9999929596F, 0.9999931777F, 0.9999933907F, 0.9999935987F,
- 0.9999938018F, 0.9999940000F, 0.9999941934F, 0.9999943820F,
- 0.9999945661F, 0.9999947456F, 0.9999949206F, 0.9999950912F,
- 0.9999952575F, 0.9999954195F, 0.9999955773F, 0.9999957311F,
- 0.9999958807F, 0.9999960265F, 0.9999961683F, 0.9999963063F,
- 0.9999964405F, 0.9999965710F, 0.9999966979F, 0.9999968213F,
- 0.9999969412F, 0.9999970576F, 0.9999971707F, 0.9999972805F,
- 0.9999973871F, 0.9999974905F, 0.9999975909F, 0.9999976881F,
- 0.9999977824F, 0.9999978738F, 0.9999979624F, 0.9999980481F,
- 0.9999981311F, 0.9999982115F, 0.9999982892F, 0.9999983644F,
- 0.9999984370F, 0.9999985072F, 0.9999985750F, 0.9999986405F,
- 0.9999987037F, 0.9999987647F, 0.9999988235F, 0.9999988802F,
- 0.9999989348F, 0.9999989873F, 0.9999990379F, 0.9999990866F,
- 0.9999991334F, 0.9999991784F, 0.9999992217F, 0.9999992632F,
- 0.9999993030F, 0.9999993411F, 0.9999993777F, 0.9999994128F,
- 0.9999994463F, 0.9999994784F, 0.9999995091F, 0.9999995384F,
- 0.9999995663F, 0.9999995930F, 0.9999996184F, 0.9999996426F,
- 0.9999996657F, 0.9999996876F, 0.9999997084F, 0.9999997282F,
- 0.9999997469F, 0.9999997647F, 0.9999997815F, 0.9999997973F,
- 0.9999998123F, 0.9999998265F, 0.9999998398F, 0.9999998524F,
- 0.9999998642F, 0.9999998753F, 0.9999998857F, 0.9999998954F,
- 0.9999999045F, 0.9999999130F, 0.9999999209F, 0.9999999282F,
- 0.9999999351F, 0.9999999414F, 0.9999999472F, 0.9999999526F,
- 0.9999999576F, 0.9999999622F, 0.9999999664F, 0.9999999702F,
- 0.9999999737F, 0.9999999769F, 0.9999999798F, 0.9999999824F,
- 0.9999999847F, 0.9999999868F, 0.9999999887F, 0.9999999904F,
- 0.9999999919F, 0.9999999932F, 0.9999999943F, 0.9999999953F,
- 0.9999999961F, 0.9999999969F, 0.9999999975F, 0.9999999980F,
- 0.9999999985F, 0.9999999988F, 0.9999999991F, 0.9999999993F,
- 0.9999999995F, 0.9999999997F, 0.9999999998F, 0.9999999999F,
- 0.9999999999F, 1.0000000000F, 1.0000000000F, 1.0000000000F,
- 1.0000000000F, 1.0000000000F, 1.0000000000F, 1.0000000000F,
-};
-
-const float ff_vorbis_floor1_inverse_db_table[256]={
- 1.0649863e-07F, 1.1341951e-07F, 1.2079015e-07F, 1.2863978e-07F,
- 1.3699951e-07F, 1.4590251e-07F, 1.5538408e-07F, 1.6548181e-07F,
- 1.7623575e-07F, 1.8768855e-07F, 1.9988561e-07F, 2.128753e-07F,
- 2.2670913e-07F, 2.4144197e-07F, 2.5713223e-07F, 2.7384213e-07F,
- 2.9163793e-07F, 3.1059021e-07F, 3.3077411e-07F, 3.5226968e-07F,
- 3.7516214e-07F, 3.9954229e-07F, 4.2550680e-07F, 4.5315863e-07F,
- 4.8260743e-07F, 5.1396998e-07F, 5.4737065e-07F, 5.8294187e-07F,
- 6.2082472e-07F, 6.6116941e-07F, 7.0413592e-07F, 7.4989464e-07F,
- 7.9862701e-07F, 8.5052630e-07F, 9.0579828e-07F, 9.6466216e-07F,
- 1.0273513e-06F, 1.0941144e-06F, 1.1652161e-06F, 1.2409384e-06F,
- 1.3215816e-06F, 1.4074654e-06F, 1.4989305e-06F, 1.5963394e-06F,
- 1.7000785e-06F, 1.8105592e-06F, 1.9282195e-06F, 2.0535261e-06F,
- 2.1869758e-06F, 2.3290978e-06F, 2.4804557e-06F, 2.6416497e-06F,
- 2.8133190e-06F, 2.9961443e-06F, 3.1908506e-06F, 3.3982101e-06F,
- 3.6190449e-06F, 3.8542308e-06F, 4.1047004e-06F, 4.3714470e-06F,
- 4.6555282e-06F, 4.9580707e-06F, 5.2802740e-06F, 5.6234160e-06F,
- 5.9888572e-06F, 6.3780469e-06F, 6.7925283e-06F, 7.2339451e-06F,
- 7.7040476e-06F, 8.2047000e-06F, 8.7378876e-06F, 9.3057248e-06F,
- 9.9104632e-06F, 1.0554501e-05F, 1.1240392e-05F, 1.1970856e-05F,
- 1.2748789e-05F, 1.3577278e-05F, 1.4459606e-05F, 1.5399272e-05F,
- 1.6400004e-05F, 1.7465768e-05F, 1.8600792e-05F, 1.9809576e-05F,
- 2.1096914e-05F, 2.2467911e-05F, 2.3928002e-05F, 2.5482978e-05F,
- 2.7139006e-05F, 2.8902651e-05F, 3.0780908e-05F, 3.2781225e-05F,
- 3.4911534e-05F, 3.7180282e-05F, 3.9596466e-05F, 4.2169667e-05F,
- 4.4910090e-05F, 4.7828601e-05F, 5.0936773e-05F, 5.4246931e-05F,
- 5.7772202e-05F, 6.1526565e-05F, 6.5524908e-05F, 6.9783085e-05F,
- 7.4317983e-05F, 7.9147585e-05F, 8.4291040e-05F, 8.9768747e-05F,
- 9.5602426e-05F, 0.00010181521F, 0.00010843174F, 0.00011547824F,
- 0.00012298267F, 0.00013097477F, 0.00013948625F, 0.00014855085F,
- 0.00015820453F, 0.00016848555F, 0.00017943469F, 0.00019109536F,
- 0.00020351382F, 0.00021673929F, 0.00023082423F, 0.00024582449F,
- 0.00026179955F, 0.00027881276F, 0.00029693158F, 0.00031622787F,
- 0.00033677814F, 0.00035866388F, 0.00038197188F, 0.00040679456F,
- 0.00043323036F, 0.00046138411F, 0.00049136745F, 0.00052329927F,
- 0.00055730621F, 0.00059352311F, 0.00063209358F, 0.00067317058F,
- 0.00071691700F, 0.00076350630F, 0.00081312324F, 0.00086596457F,
- 0.00092223983F, 0.00098217216F, 0.0010459992F, 0.0011139742F,
- 0.0011863665F, 0.0012634633F, 0.0013455702F, 0.0014330129F,
- 0.0015261382F, 0.0016253153F, 0.0017309374F, 0.0018434235F,
- 0.0019632195F, 0.0020908006F, 0.0022266726F, 0.0023713743F,
- 0.0025254795F, 0.0026895994F, 0.0028643847F, 0.0030505286F,
- 0.0032487691F, 0.0034598925F, 0.0036847358F, 0.0039241906F,
- 0.0041792066F, 0.0044507950F, 0.0047400328F, 0.0050480668F,
- 0.0053761186F, 0.0057254891F, 0.0060975636F, 0.0064938176F,
- 0.0069158225F, 0.0073652516F, 0.0078438871F, 0.0083536271F,
- 0.0088964928F, 0.009474637F, 0.010090352F, 0.010746080F,
- 0.011444421F, 0.012188144F, 0.012980198F, 0.013823725F,
- 0.014722068F, 0.015678791F, 0.016697687F, 0.017782797F,
- 0.018938423F, 0.020169149F, 0.021479854F, 0.022875735F,
- 0.024362330F, 0.025945531F, 0.027631618F, 0.029427276F,
- 0.031339626F, 0.033376252F, 0.035545228F, 0.037855157F,
- 0.040315199F, 0.042935108F, 0.045725273F, 0.048696758F,
- 0.051861348F, 0.055231591F, 0.058820850F, 0.062643361F,
- 0.066714279F, 0.071049749F, 0.075666962F, 0.080584227F,
- 0.085821044F, 0.091398179F, 0.097337747F, 0.10366330F,
- 0.11039993F, 0.11757434F, 0.12521498F, 0.13335215F,
- 0.14201813F, 0.15124727F, 0.16107617F, 0.17154380F,
- 0.18269168F, 0.19456402F, 0.20720788F, 0.22067342F,
- 0.23501402F, 0.25028656F, 0.26655159F, 0.28387361F,
- 0.30232132F, 0.32196786F, 0.34289114F, 0.36517414F,
- 0.38890521F, 0.41417847F, 0.44109412F, 0.46975890F,
- 0.50028648F, 0.53279791F, 0.56742212F, 0.60429640F,
- 0.64356699F, 0.68538959F, 0.72993007F, 0.77736504F,
- 0.82788260F, 0.88168307F, 0.9389798F, 1.F,
-};
-
-const float * const ff_vorbis_vwin[8] = {
- vwin64, vwin128, vwin256, vwin512,
- vwin1024, vwin2048, vwin4096, vwin8192
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/vorbisdec.c b/src/thirdparty/ffmpeg/libavcodec/vorbisdec.c
deleted file mode 100644
index 8cfdc5af1..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vorbisdec.c
+++ /dev/null
@@ -1,1771 +0,0 @@
-/**
- * @file
- * Vorbis I decoder
- * @author Denes Balatoni ( dbalatoni programozo hu )
- *
- * 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
- * Vorbis I decoder
- * @author Denes Balatoni ( dbalatoni programozo hu )
- */
-
-#include <inttypes.h>
-#include <math.h>
-
-#define BITSTREAM_READER_LE
-#include "libavutil/float_dsp.h"
-#include "libavutil/avassert.h"
-#include "avcodec.h"
-#include "get_bits.h"
-#include "fft.h"
-#include "fmtconvert.h"
-#include "internal.h"
-
-#include "vorbis.h"
-#include "vorbisdsp.h"
-#include "xiph.h"
-
-#define V_NB_BITS 8
-#define V_NB_BITS2 11
-#define V_MAX_VLCS (1 << 16)
-#define V_MAX_PARTITIONS (1 << 20)
-
-typedef struct {
- uint8_t dimensions;
- uint8_t lookup_type;
- uint8_t maxdepth;
- VLC vlc;
- float *codevectors;
- unsigned int nb_bits;
-} vorbis_codebook;
-
-typedef union vorbis_floor_u vorbis_floor_data;
-typedef struct vorbis_floor0_s vorbis_floor0;
-typedef struct vorbis_floor1_s vorbis_floor1;
-struct vorbis_context_s;
-typedef
-int (* vorbis_floor_decode_func)
- (struct vorbis_context_s *, vorbis_floor_data *, float *);
-typedef struct {
- uint8_t floor_type;
- vorbis_floor_decode_func decode;
- union vorbis_floor_u {
- struct vorbis_floor0_s {
- uint8_t order;
- uint16_t rate;
- uint16_t bark_map_size;
- int32_t *map[2];
- uint32_t map_size[2];
- uint8_t amplitude_bits;
- uint8_t amplitude_offset;
- uint8_t num_books;
- uint8_t *book_list;
- float *lsp;
- } t0;
- struct vorbis_floor1_s {
- uint8_t partitions;
- uint8_t partition_class[32];
- uint8_t class_dimensions[16];
- uint8_t class_subclasses[16];
- uint8_t class_masterbook[16];
- int16_t subclass_books[16][8];
- uint8_t multiplier;
- uint16_t x_list_dim;
- vorbis_floor1_entry *list;
- } t1;
- } data;
-} vorbis_floor;
-
-typedef struct {
- uint16_t type;
- uint32_t begin;
- uint32_t end;
- unsigned partition_size;
- uint8_t classifications;
- uint8_t classbook;
- int16_t books[64][8];
- uint8_t maxpass;
- uint16_t ptns_to_read;
- uint8_t *classifs;
-} vorbis_residue;
-
-typedef struct {
- uint8_t submaps;
- uint16_t coupling_steps;
- uint8_t *magnitude;
- uint8_t *angle;
- uint8_t *mux;
- uint8_t submap_floor[16];
- uint8_t submap_residue[16];
-} vorbis_mapping;
-
-typedef struct {
- uint8_t blockflag;
- uint16_t windowtype;
- uint16_t transformtype;
- uint8_t mapping;
-} vorbis_mode;
-
-typedef struct vorbis_context_s {
- AVCodecContext *avccontext;
- GetBitContext gb;
- VorbisDSPContext dsp;
- AVFloatDSPContext fdsp;
- FmtConvertContext fmt_conv;
-
- FFTContext mdct[2];
- uint8_t first_frame;
- uint32_t version;
- uint8_t audio_channels;
- uint32_t audio_samplerate;
- uint32_t bitrate_maximum;
- uint32_t bitrate_nominal;
- uint32_t bitrate_minimum;
- uint32_t blocksize[2];
- const float *win[2];
- uint16_t codebook_count;
- vorbis_codebook *codebooks;
- uint8_t floor_count;
- vorbis_floor *floors;
- uint8_t residue_count;
- vorbis_residue *residues;
- uint8_t mapping_count;
- vorbis_mapping *mappings;
- uint8_t mode_count;
- vorbis_mode *modes;
- uint8_t mode_number; // mode number for the current packet
- uint8_t previous_window;
- float *channel_residues;
- float *saved;
-} vorbis_context;
-
-/* Helper functions */
-
-#define BARK(x) \
- (13.1f * atan(0.00074f * (x)) + 2.24f * atan(1.85e-8f * (x) * (x)) + 1e-4f * (x))
-
-static const char idx_err_str[] = "Index value %d out of range (0 - %d) for %s at %s:%i\n";
-#define VALIDATE_INDEX(idx, limit) \
- if (idx >= limit) {\
- av_log(vc->avccontext, AV_LOG_ERROR,\
- idx_err_str,\
- (int)(idx), (int)(limit - 1), #idx, __FILE__, __LINE__);\
- return AVERROR_INVALIDDATA;\
- }
-#define GET_VALIDATED_INDEX(idx, bits, limit) \
- {\
- idx = get_bits(gb, bits);\
- VALIDATE_INDEX(idx, limit)\
- }
-
-static float vorbisfloat2float(unsigned val)
-{
- double mant = val & 0x1fffff;
- long exp = (val & 0x7fe00000L) >> 21;
- if (val & 0x80000000)
- mant = -mant;
- return ldexp(mant, exp - 20 - 768);
-}
-
-
-// Free all allocated memory -----------------------------------------
-
-static void vorbis_free(vorbis_context *vc)
-{
- int i;
-
- av_freep(&vc->channel_residues);
- av_freep(&vc->saved);
-
- if (vc->residues)
- for (i = 0; i < vc->residue_count; i++)
- av_free(vc->residues[i].classifs);
- av_freep(&vc->residues);
- av_freep(&vc->modes);
-
- ff_mdct_end(&vc->mdct[0]);
- ff_mdct_end(&vc->mdct[1]);
-
- if (vc->codebooks)
- for (i = 0; i < vc->codebook_count; ++i) {
- av_free(vc->codebooks[i].codevectors);
- ff_free_vlc(&vc->codebooks[i].vlc);
- }
- av_freep(&vc->codebooks);
-
- if (vc->floors)
- for (i = 0; i < vc->floor_count; ++i) {
- if (vc->floors[i].floor_type == 0) {
- av_free(vc->floors[i].data.t0.map[0]);
- av_free(vc->floors[i].data.t0.map[1]);
- av_free(vc->floors[i].data.t0.book_list);
- av_free(vc->floors[i].data.t0.lsp);
- } else {
- av_free(vc->floors[i].data.t1.list);
- }
- }
- av_freep(&vc->floors);
-
- if (vc->mappings)
- for (i = 0; i < vc->mapping_count; ++i) {
- av_free(vc->mappings[i].magnitude);
- av_free(vc->mappings[i].angle);
- av_free(vc->mappings[i].mux);
- }
- av_freep(&vc->mappings);
-}
-
-// Parse setup header -------------------------------------------------
-
-// Process codebooks part
-
-static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc)
-{
- unsigned cb;
- uint8_t *tmp_vlc_bits;
- uint32_t *tmp_vlc_codes;
- GetBitContext *gb = &vc->gb;
- uint16_t *codebook_multiplicands;
- int ret = 0;
-
- vc->codebook_count = get_bits(gb, 8) + 1;
-
- av_dlog(NULL, " Codebooks: %d \n", vc->codebook_count);
-
- vc->codebooks = av_mallocz(vc->codebook_count * sizeof(*vc->codebooks));
- tmp_vlc_bits = av_mallocz(V_MAX_VLCS * sizeof(*tmp_vlc_bits));
- tmp_vlc_codes = av_mallocz(V_MAX_VLCS * sizeof(*tmp_vlc_codes));
- codebook_multiplicands = av_malloc(V_MAX_VLCS * sizeof(*codebook_multiplicands));
-
- for (cb = 0; cb < vc->codebook_count; ++cb) {
- vorbis_codebook *codebook_setup = &vc->codebooks[cb];
- unsigned ordered, t, entries, used_entries = 0;
-
- av_dlog(NULL, " %u. Codebook\n", cb);
-
- if (get_bits(gb, 24) != 0x564342) {
- av_log(vc->avccontext, AV_LOG_ERROR,
- " %u. Codebook setup data corrupt.\n", cb);
- ret = AVERROR_INVALIDDATA;
- goto error;
- }
-
- codebook_setup->dimensions=get_bits(gb, 16);
- if (codebook_setup->dimensions > 16 || codebook_setup->dimensions == 0) {
- av_log(vc->avccontext, AV_LOG_ERROR,
- " %u. Codebook's dimension is invalid (%d).\n",
- cb, codebook_setup->dimensions);
- ret = AVERROR_INVALIDDATA;
- goto error;
- }
- entries = get_bits(gb, 24);
- if (entries > V_MAX_VLCS) {
- av_log(vc->avccontext, AV_LOG_ERROR,
- " %u. Codebook has too many entries (%u).\n",
- cb, entries);
- ret = AVERROR_INVALIDDATA;
- goto error;
- }
-
- ordered = get_bits1(gb);
-
- av_dlog(NULL, " codebook_dimensions %d, codebook_entries %u\n",
- codebook_setup->dimensions, entries);
-
- if (!ordered) {
- unsigned ce, flag;
- unsigned sparse = get_bits1(gb);
-
- av_dlog(NULL, " not ordered \n");
-
- if (sparse) {
- av_dlog(NULL, " sparse \n");
-
- used_entries = 0;
- for (ce = 0; ce < entries; ++ce) {
- flag = get_bits1(gb);
- if (flag) {
- tmp_vlc_bits[ce] = get_bits(gb, 5) + 1;
- ++used_entries;
- } else
- tmp_vlc_bits[ce] = 0;
- }
- } else {
- av_dlog(NULL, " not sparse \n");
-
- used_entries = entries;
- for (ce = 0; ce < entries; ++ce)
- tmp_vlc_bits[ce] = get_bits(gb, 5) + 1;
- }
- } else {
- unsigned current_entry = 0;
- unsigned current_length = get_bits(gb, 5) + 1;
-
- av_dlog(NULL, " ordered, current length: %u\n", current_length); //FIXME
-
- used_entries = entries;
- for (; current_entry < used_entries && current_length <= 32; ++current_length) {
- unsigned i, number;
-
- av_dlog(NULL, " number bits: %u ", ilog(entries - current_entry));
-
- number = get_bits(gb, ilog(entries - current_entry));
-
- av_dlog(NULL, " number: %u\n", number);
-
- for (i = current_entry; i < number+current_entry; ++i)
- if (i < used_entries)
- tmp_vlc_bits[i] = current_length;
-
- current_entry+=number;
- }
- if (current_entry>used_entries) {
- av_log(vc->avccontext, AV_LOG_ERROR, " More codelengths than codes in codebook. \n");
- ret = AVERROR_INVALIDDATA;
- goto error;
- }
- }
-
- codebook_setup->lookup_type = get_bits(gb, 4);
-
- av_dlog(NULL, " lookup type: %d : %s \n", codebook_setup->lookup_type,
- codebook_setup->lookup_type ? "vq" : "no lookup");
-
-// If the codebook is used for (inverse) VQ, calculate codevectors.
-
- if (codebook_setup->lookup_type == 1) {
- unsigned i, j, k;
- unsigned codebook_lookup_values = ff_vorbis_nth_root(entries, codebook_setup->dimensions);
-
- float codebook_minimum_value = vorbisfloat2float(get_bits_long(gb, 32));
- float codebook_delta_value = vorbisfloat2float(get_bits_long(gb, 32));
- unsigned codebook_value_bits = get_bits(gb, 4) + 1;
- unsigned codebook_sequence_p = get_bits1(gb);
-
- av_dlog(NULL, " We expect %d numbers for building the codevectors. \n",
- codebook_lookup_values);
- av_dlog(NULL, " delta %f minmum %f \n",
- codebook_delta_value, codebook_minimum_value);
-
- for (i = 0; i < codebook_lookup_values; ++i) {
- codebook_multiplicands[i] = get_bits(gb, codebook_value_bits);
-
- av_dlog(NULL, " multiplicands*delta+minmum : %e \n",
- (float)codebook_multiplicands[i] * codebook_delta_value + codebook_minimum_value);
- av_dlog(NULL, " multiplicand %u\n", codebook_multiplicands[i]);
- }
-
-// Weed out unused vlcs and build codevector vector
- codebook_setup->codevectors = used_entries ? av_mallocz(used_entries *
- codebook_setup->dimensions *
- sizeof(*codebook_setup->codevectors))
- : NULL;
- for (j = 0, i = 0; i < entries; ++i) {
- unsigned dim = codebook_setup->dimensions;
-
- if (tmp_vlc_bits[i]) {
- float last = 0.0;
- unsigned lookup_offset = i;
-
- av_dlog(vc->avccontext, "Lookup offset %u ,", i);
-
- for (k = 0; k < dim; ++k) {
- unsigned multiplicand_offset = lookup_offset % codebook_lookup_values;
- codebook_setup->codevectors[j * dim + k] = codebook_multiplicands[multiplicand_offset] * codebook_delta_value + codebook_minimum_value + last;
- if (codebook_sequence_p)
- last = codebook_setup->codevectors[j * dim + k];
- lookup_offset/=codebook_lookup_values;
- }
- tmp_vlc_bits[j] = tmp_vlc_bits[i];
-
- av_dlog(vc->avccontext, "real lookup offset %u, vector: ", j);
- for (k = 0; k < dim; ++k)
- av_dlog(vc->avccontext, " %f ",
- codebook_setup->codevectors[j * dim + k]);
- av_dlog(vc->avccontext, "\n");
-
- ++j;
- }
- }
- if (j != used_entries) {
- av_log(vc->avccontext, AV_LOG_ERROR, "Bug in codevector vector building code. \n");
- ret = AVERROR_INVALIDDATA;
- goto error;
- }
- entries = used_entries;
- } else if (codebook_setup->lookup_type >= 2) {
- av_log(vc->avccontext, AV_LOG_ERROR, "Codebook lookup type not supported. \n");
- ret = AVERROR_INVALIDDATA;
- goto error;
- }
-
-// Initialize VLC table
- if (ff_vorbis_len2vlc(tmp_vlc_bits, tmp_vlc_codes, entries)) {
- av_log(vc->avccontext, AV_LOG_ERROR, " Invalid code lengths while generating vlcs. \n");
- ret = AVERROR_INVALIDDATA;
- goto error;
- }
- codebook_setup->maxdepth = 0;
- for (t = 0; t < entries; ++t)
- if (tmp_vlc_bits[t] >= codebook_setup->maxdepth)
- codebook_setup->maxdepth = tmp_vlc_bits[t];
-
- if (codebook_setup->maxdepth > 3 * V_NB_BITS)
- codebook_setup->nb_bits = V_NB_BITS2;
- else
- codebook_setup->nb_bits = V_NB_BITS;
-
- codebook_setup->maxdepth = (codebook_setup->maxdepth+codebook_setup->nb_bits - 1) / codebook_setup->nb_bits;
-
- if ((ret = init_vlc(&codebook_setup->vlc, codebook_setup->nb_bits,
- entries, tmp_vlc_bits, sizeof(*tmp_vlc_bits),
- sizeof(*tmp_vlc_bits), tmp_vlc_codes,
- sizeof(*tmp_vlc_codes), sizeof(*tmp_vlc_codes),
- INIT_VLC_LE))) {
- av_log(vc->avccontext, AV_LOG_ERROR, " Error generating vlc tables. \n");
- goto error;
- }
- }
-
- av_free(tmp_vlc_bits);
- av_free(tmp_vlc_codes);
- av_free(codebook_multiplicands);
- return 0;
-
-// Error:
-error:
- av_free(tmp_vlc_bits);
- av_free(tmp_vlc_codes);
- av_free(codebook_multiplicands);
- return ret;
-}
-
-// Process time domain transforms part (unused in Vorbis I)
-
-static int vorbis_parse_setup_hdr_tdtransforms(vorbis_context *vc)
-{
- GetBitContext *gb = &vc->gb;
- unsigned i, vorbis_time_count = get_bits(gb, 6) + 1;
-
- for (i = 0; i < vorbis_time_count; ++i) {
- unsigned vorbis_tdtransform = get_bits(gb, 16);
-
- av_dlog(NULL, " Vorbis time domain transform %u: %u\n",
- vorbis_time_count, vorbis_tdtransform);
-
- if (vorbis_tdtransform) {
- av_log(vc->avccontext, AV_LOG_ERROR, "Vorbis time domain transform data nonzero. \n");
- return AVERROR_INVALIDDATA;
- }
- }
- return 0;
-}
-
-// Process floors part
-
-static int vorbis_floor0_decode(vorbis_context *vc,
- vorbis_floor_data *vfu, float *vec);
-static void create_map(vorbis_context *vc, unsigned floor_number);
-static int vorbis_floor1_decode(vorbis_context *vc,
- vorbis_floor_data *vfu, float *vec);
-static int vorbis_parse_setup_hdr_floors(vorbis_context *vc)
-{
- GetBitContext *gb = &vc->gb;
- int i,j,k;
-
- vc->floor_count = get_bits(gb, 6) + 1;
-
- vc->floors = av_mallocz(vc->floor_count * sizeof(*vc->floors));
-
- for (i = 0; i < vc->floor_count; ++i) {
- vorbis_floor *floor_setup = &vc->floors[i];
-
- floor_setup->floor_type = get_bits(gb, 16);
-
- av_dlog(NULL, " %d. floor type %d \n", i, floor_setup->floor_type);
-
- if (floor_setup->floor_type == 1) {
- int maximum_class = -1;
- unsigned rangebits, rangemax, floor1_values = 2;
-
- floor_setup->decode = vorbis_floor1_decode;
-
- floor_setup->data.t1.partitions = get_bits(gb, 5);
-
- av_dlog(NULL, " %d.floor: %d partitions \n",
- i, floor_setup->data.t1.partitions);
-
- for (j = 0; j < floor_setup->data.t1.partitions; ++j) {
- floor_setup->data.t1.partition_class[j] = get_bits(gb, 4);
- if (floor_setup->data.t1.partition_class[j] > maximum_class)
- maximum_class = floor_setup->data.t1.partition_class[j];
-
- av_dlog(NULL, " %d. floor %d partition class %d \n",
- i, j, floor_setup->data.t1.partition_class[j]);
-
- }
-
- av_dlog(NULL, " maximum class %d \n", maximum_class);
-
- for (j = 0; j <= maximum_class; ++j) {
- floor_setup->data.t1.class_dimensions[j] = get_bits(gb, 3) + 1;
- floor_setup->data.t1.class_subclasses[j] = get_bits(gb, 2);
-
- av_dlog(NULL, " %d floor %d class dim: %d subclasses %d \n", i, j,
- floor_setup->data.t1.class_dimensions[j],
- floor_setup->data.t1.class_subclasses[j]);
-
- if (floor_setup->data.t1.class_subclasses[j]) {
- GET_VALIDATED_INDEX(floor_setup->data.t1.class_masterbook[j], 8, vc->codebook_count)
-
- av_dlog(NULL, " masterbook: %d \n", floor_setup->data.t1.class_masterbook[j]);
- }
-
- for (k = 0; k < (1 << floor_setup->data.t1.class_subclasses[j]); ++k) {
- int16_t bits = get_bits(gb, 8) - 1;
- if (bits != -1)
- VALIDATE_INDEX(bits, vc->codebook_count)
- floor_setup->data.t1.subclass_books[j][k] = bits;
-
- av_dlog(NULL, " book %d. : %d \n", k, floor_setup->data.t1.subclass_books[j][k]);
- }
- }
-
- floor_setup->data.t1.multiplier = get_bits(gb, 2) + 1;
- floor_setup->data.t1.x_list_dim = 2;
-
- 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 *
- sizeof(*floor_setup->data.t1.list));
-
-
- rangebits = get_bits(gb, 4);
- rangemax = (1 << rangebits);
- if (rangemax > vc->blocksize[1] / 2) {
- av_log(vc->avccontext, AV_LOG_ERROR,
- "Floor value is too large for blocksize: %u (%"PRIu32")\n",
- rangemax, vc->blocksize[1] / 2);
- return AVERROR_INVALIDDATA;
- }
- floor_setup->data.t1.list[0].x = 0;
- floor_setup->data.t1.list[1].x = rangemax;
-
- for (j = 0; j < floor_setup->data.t1.partitions; ++j) {
- for (k = 0; k < floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]]; ++k, ++floor1_values) {
- floor_setup->data.t1.list[floor1_values].x = get_bits(gb, rangebits);
-
- av_dlog(NULL, " %u. floor1 Y coord. %d\n", floor1_values,
- floor_setup->data.t1.list[floor1_values].x);
- }
- }
-
-// Precalculate order of x coordinates - needed for decode
- if (ff_vorbis_ready_floor1_list(vc->avccontext,
- floor_setup->data.t1.list,
- floor_setup->data.t1.x_list_dim)) {
- return AVERROR_INVALIDDATA;
- }
- } else if (floor_setup->floor_type == 0) {
- unsigned max_codebook_dim = 0;
-
- floor_setup->decode = vorbis_floor0_decode;
-
- floor_setup->data.t0.order = get_bits(gb, 8);
- floor_setup->data.t0.rate = get_bits(gb, 16);
- floor_setup->data.t0.bark_map_size = get_bits(gb, 16);
- floor_setup->data.t0.amplitude_bits = get_bits(gb, 6);
- /* zero would result in a div by zero later *
- * 2^0 - 1 == 0 */
- if (floor_setup->data.t0.amplitude_bits == 0) {
- av_log(vc->avccontext, AV_LOG_ERROR,
- "Floor 0 amplitude bits is 0.\n");
- return AVERROR_INVALIDDATA;
- }
- if (floor_setup->data.t0.bark_map_size == 0) {
- av_log(vc->avccontext, AV_LOG_ERROR, "Floor 0 bark map size is 0.\n");
- return AVERROR_INVALIDDATA;
- }
- floor_setup->data.t0.amplitude_offset = get_bits(gb, 8);
- floor_setup->data.t0.num_books = get_bits(gb, 4) + 1;
-
- /* allocate mem for booklist */
- floor_setup->data.t0.book_list =
- av_malloc(floor_setup->data.t0.num_books);
- if (!floor_setup->data.t0.book_list)
- return AVERROR(ENOMEM);
- /* read book indexes */
- {
- int idx;
- unsigned book_idx;
- for (idx = 0; idx < floor_setup->data.t0.num_books; ++idx) {
- GET_VALIDATED_INDEX(book_idx, 8, vc->codebook_count)
- floor_setup->data.t0.book_list[idx] = book_idx;
- if (vc->codebooks[book_idx].dimensions > max_codebook_dim)
- max_codebook_dim = vc->codebooks[book_idx].dimensions;
- }
- }
-
- create_map(vc, i);
-
- /* 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));
- if (!floor_setup->data.t0.lsp)
- return AVERROR(ENOMEM);
-
- /* debug output parsed headers */
- av_dlog(NULL, "floor0 order: %u\n", floor_setup->data.t0.order);
- av_dlog(NULL, "floor0 rate: %u\n", floor_setup->data.t0.rate);
- av_dlog(NULL, "floor0 bark map size: %u\n",
- floor_setup->data.t0.bark_map_size);
- av_dlog(NULL, "floor0 amplitude bits: %u\n",
- floor_setup->data.t0.amplitude_bits);
- av_dlog(NULL, "floor0 amplitude offset: %u\n",
- floor_setup->data.t0.amplitude_offset);
- av_dlog(NULL, "floor0 number of books: %u\n",
- floor_setup->data.t0.num_books);
- av_dlog(NULL, "floor0 book list pointer: %p\n",
- floor_setup->data.t0.book_list);
- {
- int idx;
- for (idx = 0; idx < floor_setup->data.t0.num_books; ++idx) {
- av_dlog(NULL, " Book %d: %u\n", idx + 1,
- floor_setup->data.t0.book_list[idx]);
- }
- }
- } else {
- av_log(vc->avccontext, AV_LOG_ERROR, "Invalid floor type!\n");
- return AVERROR_INVALIDDATA;
- }
- }
- return 0;
-}
-
-// Process residues part
-
-static int vorbis_parse_setup_hdr_residues(vorbis_context *vc)
-{
- GetBitContext *gb = &vc->gb;
- unsigned i, j, k;
-
- vc->residue_count = get_bits(gb, 6)+1;
- vc->residues = av_mallocz(vc->residue_count * sizeof(*vc->residues));
-
- av_dlog(NULL, " There are %d residues. \n", vc->residue_count);
-
- for (i = 0; i < vc->residue_count; ++i) {
- vorbis_residue *res_setup = &vc->residues[i];
- uint8_t cascade[64];
- unsigned high_bits, low_bits;
-
- res_setup->type = get_bits(gb, 16);
-
- av_dlog(NULL, " %u. residue type %d\n", i, res_setup->type);
-
- res_setup->begin = get_bits(gb, 24);
- res_setup->end = get_bits(gb, 24);
- 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) {
- av_log(vc->avccontext, 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,
- res_setup->partition_size, vc->blocksize[1] / 2);
- return AVERROR_INVALIDDATA;
- }
-
- res_setup->classifications = get_bits(gb, 6) + 1;
- GET_VALIDATED_INDEX(res_setup->classbook, 8, vc->codebook_count)
-
- 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 *
- vc->audio_channels *
- sizeof(*res_setup->classifs));
- if (!res_setup->classifs)
- return AVERROR(ENOMEM);
-
- av_dlog(NULL, " begin %d end %d part.size %d classif.s %d classbook %d \n",
- res_setup->begin, res_setup->end, res_setup->partition_size,
- res_setup->classifications, res_setup->classbook);
-
- for (j = 0; j < res_setup->classifications; ++j) {
- high_bits = 0;
- low_bits = get_bits(gb, 3);
- if (get_bits1(gb))
- high_bits = get_bits(gb, 5);
- cascade[j] = (high_bits << 3) + low_bits;
-
- av_dlog(NULL, " %u class cascade depth: %d\n", j, ilog(cascade[j]));
- }
-
- res_setup->maxpass = 0;
- for (j = 0; j < res_setup->classifications; ++j) {
- for (k = 0; k < 8; ++k) {
- if (cascade[j]&(1 << k)) {
- GET_VALIDATED_INDEX(res_setup->books[j][k], 8, vc->codebook_count)
-
- av_dlog(NULL, " %u class cascade depth %u book: %d\n",
- j, k, res_setup->books[j][k]);
-
- if (k>res_setup->maxpass)
- res_setup->maxpass = k;
- } else {
- res_setup->books[j][k] = -1;
- }
- }
- }
- }
- return 0;
-}
-
-// Process mappings part
-
-static int vorbis_parse_setup_hdr_mappings(vorbis_context *vc)
-{
- GetBitContext *gb = &vc->gb;
- unsigned i, j;
-
- vc->mapping_count = get_bits(gb, 6)+1;
- vc->mappings = av_mallocz(vc->mapping_count * sizeof(*vc->mappings));
-
- av_dlog(NULL, " There are %d mappings. \n", vc->mapping_count);
-
- for (i = 0; i < vc->mapping_count; ++i) {
- vorbis_mapping *mapping_setup = &vc->mappings[i];
-
- if (get_bits(gb, 16)) {
- av_log(vc->avccontext, AV_LOG_ERROR, "Other mappings than type 0 are not compliant with the Vorbis I specification. \n");
- return AVERROR_INVALIDDATA;
- }
- if (get_bits1(gb)) {
- mapping_setup->submaps = get_bits(gb, 4) + 1;
- } else {
- mapping_setup->submaps = 1;
- }
-
- if (get_bits1(gb)) {
- mapping_setup->coupling_steps = get_bits(gb, 8) + 1;
- mapping_setup->magnitude = av_mallocz(mapping_setup->coupling_steps *
- sizeof(*mapping_setup->magnitude));
- mapping_setup->angle = av_mallocz(mapping_setup->coupling_steps *
- sizeof(*mapping_setup->angle));
- for (j = 0; j < mapping_setup->coupling_steps; ++j) {
- GET_VALIDATED_INDEX(mapping_setup->magnitude[j], ilog(vc->audio_channels - 1), vc->audio_channels)
- GET_VALIDATED_INDEX(mapping_setup->angle[j], ilog(vc->audio_channels - 1), vc->audio_channels)
- }
- } else {
- mapping_setup->coupling_steps = 0;
- }
-
- av_dlog(NULL, " %u mapping coupling steps: %d\n",
- i, mapping_setup->coupling_steps);
-
- if (get_bits(gb, 2)) {
- av_log(vc->avccontext, AV_LOG_ERROR, "%u. mapping setup data invalid.\n", i);
- return AVERROR_INVALIDDATA; // following spec.
- }
-
- if (mapping_setup->submaps>1) {
- mapping_setup->mux = av_mallocz(vc->audio_channels *
- sizeof(*mapping_setup->mux));
- for (j = 0; j < vc->audio_channels; ++j)
- mapping_setup->mux[j] = get_bits(gb, 4);
- }
-
- for (j = 0; j < mapping_setup->submaps; ++j) {
- skip_bits(gb, 8); // FIXME check?
- GET_VALIDATED_INDEX(mapping_setup->submap_floor[j], 8, vc->floor_count)
- GET_VALIDATED_INDEX(mapping_setup->submap_residue[j], 8, vc->residue_count)
-
- av_dlog(NULL, " %u mapping %u submap : floor %d, residue %d\n", i, j,
- mapping_setup->submap_floor[j],
- mapping_setup->submap_residue[j]);
- }
- }
- return 0;
-}
-
-// Process modes part
-
-static void create_map(vorbis_context *vc, unsigned floor_number)
-{
- vorbis_floor *floors = vc->floors;
- vorbis_floor0 *vf;
- int idx;
- int blockflag, n;
- int32_t *map;
-
- 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
-
- map = floors[floor_number].data.t0.map[blockflag];
- vf = &floors[floor_number].data.t0;
-
- for (idx = 0; idx < n; ++idx) {
- map[idx] = floor(BARK((vf->rate * idx) / (2.0f * n)) *
- (vf->bark_map_size / BARK(vf->rate / 2.0f)));
- if (vf->bark_map_size-1 < map[idx])
- map[idx] = vf->bark_map_size - 1;
- }
- map[n] = -1;
- vf->map_size[blockflag] = n;
- }
-
- for (idx = 0; idx <= n; ++idx) {
- av_dlog(NULL, "floor0 map: map at pos %d is %d\n", idx, map[idx]);
- }
-}
-
-static int vorbis_parse_setup_hdr_modes(vorbis_context *vc)
-{
- GetBitContext *gb = &vc->gb;
- unsigned i;
-
- vc->mode_count = get_bits(gb, 6) + 1;
- vc->modes = av_mallocz(vc->mode_count * sizeof(*vc->modes));
-
- av_dlog(NULL, " There are %d modes.\n", vc->mode_count);
-
- for (i = 0; i < vc->mode_count; ++i) {
- vorbis_mode *mode_setup = &vc->modes[i];
-
- mode_setup->blockflag = get_bits1(gb);
- mode_setup->windowtype = get_bits(gb, 16); //FIXME check
- mode_setup->transformtype = get_bits(gb, 16); //FIXME check
- GET_VALIDATED_INDEX(mode_setup->mapping, 8, vc->mapping_count);
-
- av_dlog(NULL, " %u mode: blockflag %d, windowtype %d, transformtype %d, mapping %d\n",
- i, mode_setup->blockflag, mode_setup->windowtype,
- mode_setup->transformtype, mode_setup->mapping);
- }
- return 0;
-}
-
-// Process the whole setup header using the functions above
-
-static int vorbis_parse_setup_hdr(vorbis_context *vc)
-{
- GetBitContext *gb = &vc->gb;
- int ret;
-
- if ((get_bits(gb, 8) != 'v') || (get_bits(gb, 8) != 'o') ||
- (get_bits(gb, 8) != 'r') || (get_bits(gb, 8) != 'b') ||
- (get_bits(gb, 8) != 'i') || (get_bits(gb, 8) != 's')) {
- av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis setup header packet corrupt (no vorbis signature). \n");
- return AVERROR_INVALIDDATA;
- }
-
- if ((ret = vorbis_parse_setup_hdr_codebooks(vc))) {
- av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis setup header packet corrupt (codebooks). \n");
- return ret;
- }
- if ((ret = vorbis_parse_setup_hdr_tdtransforms(vc))) {
- av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis setup header packet corrupt (time domain transforms). \n");
- return ret;
- }
- if ((ret = vorbis_parse_setup_hdr_floors(vc))) {
- av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis setup header packet corrupt (floors). \n");
- return ret;
- }
- if ((ret = vorbis_parse_setup_hdr_residues(vc))) {
- av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis setup header packet corrupt (residues). \n");
- return ret;
- }
- if ((ret = vorbis_parse_setup_hdr_mappings(vc))) {
- av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis setup header packet corrupt (mappings). \n");
- return ret;
- }
- if ((ret = vorbis_parse_setup_hdr_modes(vc))) {
- av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis setup header packet corrupt (modes). \n");
- return ret;
- }
- if (!get_bits1(gb)) {
- av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis setup header packet corrupt (framing flag). \n");
- return AVERROR_INVALIDDATA; // framing flag bit unset error
- }
-
- return 0;
-}
-
-// Process the identification header
-
-static int vorbis_parse_id_hdr(vorbis_context *vc)
-{
- GetBitContext *gb = &vc->gb;
- unsigned bl0, bl1;
-
- if ((get_bits(gb, 8) != 'v') || (get_bits(gb, 8) != 'o') ||
- (get_bits(gb, 8) != 'r') || (get_bits(gb, 8) != 'b') ||
- (get_bits(gb, 8) != 'i') || (get_bits(gb, 8) != 's')) {
- av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis id header packet corrupt (no vorbis signature). \n");
- return AVERROR_INVALIDDATA;
- }
-
- vc->version = get_bits_long(gb, 32); //FIXME check 0
- vc->audio_channels = get_bits(gb, 8);
- if (vc->audio_channels <= 0) {
- av_log(vc->avccontext, AV_LOG_ERROR, "Invalid number of channels\n");
- return AVERROR_INVALIDDATA;
- }
- vc->audio_samplerate = get_bits_long(gb, 32);
- if (vc->audio_samplerate <= 0) {
- av_log(vc->avccontext, AV_LOG_ERROR, "Invalid samplerate\n");
- return AVERROR_INVALIDDATA;
- }
- vc->bitrate_maximum = get_bits_long(gb, 32);
- vc->bitrate_nominal = get_bits_long(gb, 32);
- vc->bitrate_minimum = get_bits_long(gb, 32);
- bl0 = get_bits(gb, 4);
- bl1 = get_bits(gb, 4);
- if (bl0 > 13 || bl0 < 6 || bl1 > 13 || bl1 < 6 || bl1 < bl0) {
- av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis id header packet corrupt (illegal blocksize). \n");
- return AVERROR_INVALIDDATA;
- }
- vc->blocksize[0] = (1 << bl0);
- vc->blocksize[1] = (1 << bl1);
- vc->win[0] = ff_vorbis_vwin[bl0 - 6];
- vc->win[1] = ff_vorbis_vwin[bl1 - 6];
-
- if ((get_bits1(gb)) == 0) {
- av_log(vc->avccontext, AV_LOG_ERROR, " Vorbis id header packet corrupt (framing flag not set). \n");
- 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->previous_window = 0;
-
- ff_mdct_init(&vc->mdct[0], bl0, 1, -1.0);
- ff_mdct_init(&vc->mdct[1], bl1, 1, -1.0);
-
- av_dlog(NULL, " vorbis version %d \n audio_channels %d \n audio_samplerate %d \n bitrate_max %d \n bitrate_nom %d \n bitrate_min %d \n blk_0 %d blk_1 %d \n ",
- vc->version, vc->audio_channels, vc->audio_samplerate, vc->bitrate_maximum, vc->bitrate_nominal, vc->bitrate_minimum, vc->blocksize[0], vc->blocksize[1]);
-
-/*
- BLK = vc->blocksize[0];
- for (i = 0; i < BLK / 2; ++i) {
- vc->win[0][i] = sin(0.5*3.14159265358*(sin(((float)i + 0.5) / (float)BLK*3.14159265358))*(sin(((float)i + 0.5) / (float)BLK*3.14159265358)));
- }
-*/
-
- return 0;
-}
-
-// Process the extradata using the functions above (identification header, setup header)
-
-static av_cold int vorbis_decode_init(AVCodecContext *avccontext)
-{
- vorbis_context *vc = avccontext->priv_data;
- uint8_t *headers = avccontext->extradata;
- int headers_len = avccontext->extradata_size;
- uint8_t *header_start[3];
- int header_len[3];
- GetBitContext *gb = &vc->gb;
- int hdr_type, ret;
-
- vc->avccontext = avccontext;
- ff_vorbisdsp_init(&vc->dsp);
- avpriv_float_dsp_init(&vc->fdsp, avccontext->flags & CODEC_FLAG_BITEXACT);
- ff_fmt_convert_init(&vc->fmt_conv, avccontext);
-
- avccontext->sample_fmt = AV_SAMPLE_FMT_FLTP;
-
- if (!headers_len) {
- av_log(avccontext, AV_LOG_ERROR, "Extradata missing.\n");
- return AVERROR_INVALIDDATA;
- }
-
- if ((ret = avpriv_split_xiph_headers(headers, headers_len, 30, header_start, header_len)) < 0) {
- av_log(avccontext, AV_LOG_ERROR, "Extradata corrupt.\n");
- return ret;
- }
-
- init_get_bits(gb, header_start[0], header_len[0]*8);
- hdr_type = get_bits(gb, 8);
- if (hdr_type != 1) {
- av_log(avccontext, AV_LOG_ERROR, "First header is not the id header.\n");
- return AVERROR_INVALIDDATA;
- }
- if ((ret = vorbis_parse_id_hdr(vc))) {
- av_log(avccontext, AV_LOG_ERROR, "Id header corrupt.\n");
- vorbis_free(vc);
- return ret;
- }
-
- init_get_bits(gb, header_start[2], header_len[2]*8);
- hdr_type = get_bits(gb, 8);
- if (hdr_type != 5) {
- av_log(avccontext, AV_LOG_ERROR, "Third header is not the setup header.\n");
- vorbis_free(vc);
- return AVERROR_INVALIDDATA;
- }
- if ((ret = vorbis_parse_setup_hdr(vc))) {
- av_log(avccontext, AV_LOG_ERROR, "Setup header corrupt.\n");
- vorbis_free(vc);
- return ret;
- }
-
- if (vc->audio_channels > 8)
- avccontext->channel_layout = 0;
- else
- avccontext->channel_layout = ff_vorbis_channel_layouts[vc->audio_channels - 1];
-
- avccontext->channels = vc->audio_channels;
- avccontext->sample_rate = vc->audio_samplerate;
-
- return 0;
-}
-
-// Decode audiopackets -------------------------------------------------
-
-// Read and decode floor
-
-static int vorbis_floor0_decode(vorbis_context *vc,
- vorbis_floor_data *vfu, float *vec)
-{
- vorbis_floor0 *vf = &vfu->t0;
- float *lsp = vf->lsp;
- unsigned amplitude, book_idx;
- unsigned blockflag = vc->modes[vc->mode_number].blockflag;
-
- amplitude = get_bits(&vc->gb, vf->amplitude_bits);
- if (amplitude > 0) {
- float last = 0;
- unsigned idx, lsp_len = 0;
- vorbis_codebook codebook;
-
- book_idx = get_bits(&vc->gb, ilog(vf->num_books));
- if (book_idx >= vf->num_books) {
- av_log(vc->avccontext, AV_LOG_ERROR,
- "floor0 dec: booknumber too high!\n");
- book_idx = 0;
- }
- av_dlog(NULL, "floor0 dec: booknumber: %u\n", book_idx);
- codebook = vc->codebooks[vf->book_list[book_idx]];
- /* Invalid codebook! */
- if (!codebook.codevectors)
- return AVERROR_INVALIDDATA;
-
- while (lsp_len<vf->order) {
- int vec_off;
-
- av_dlog(NULL, "floor0 dec: book dimension: %d\n", codebook.dimensions);
- av_dlog(NULL, "floor0 dec: maximum depth: %d\n", codebook.maxdepth);
- /* read temp vector */
- vec_off = get_vlc2(&vc->gb, codebook.vlc.table,
- codebook.nb_bits, codebook.maxdepth)
- * codebook.dimensions;
- av_dlog(NULL, "floor0 dec: vector offset: %d\n", vec_off);
- /* copy each vector component and add last to it */
- for (idx = 0; idx < codebook.dimensions; ++idx)
- lsp[lsp_len+idx] = codebook.codevectors[vec_off+idx] + last;
- last = lsp[lsp_len+idx-1]; /* set last to last vector component */
-
- lsp_len += codebook.dimensions;
- }
- /* DEBUG: output lsp coeffs */
- {
- int idx;
- for (idx = 0; idx < lsp_len; ++idx)
- av_dlog(NULL, "floor0 dec: coeff at %d is %f\n", idx, lsp[idx]);
- }
-
- /* synthesize floor output vector */
- {
- int i;
- int order = vf->order;
- float wstep = M_PI / vf->bark_map_size;
-
- for (i = 0; i < order; i++)
- lsp[i] = 2.0f * cos(lsp[i]);
-
- av_dlog(NULL, "floor0 synth: map_size = %"PRIu32"; m = %d; wstep = %f\n",
- vf->map_size[blockflag], order, wstep);
-
- i = 0;
- while (i < vf->map_size[blockflag]) {
- int j, iter_cond = vf->map[blockflag][i];
- float p = 0.5f;
- float q = 0.5f;
- float two_cos_w = 2.0f * cos(wstep * iter_cond); // needed all times
-
- /* similar part for the q and p products */
- for (j = 0; j + 1 < order; j += 2) {
- q *= lsp[j] - two_cos_w;
- p *= lsp[j + 1] - two_cos_w;
- }
- if (j == order) { // even order
- p *= p * (2.0f - two_cos_w);
- q *= q * (2.0f + two_cos_w);
- } else { // odd order
- q *= two_cos_w-lsp[j]; // one more time for q
-
- /* final step and square */
- p *= p * (4.f - two_cos_w * two_cos_w);
- q *= q;
- }
-
- /* calculate linear floor value */
- q = exp((((amplitude*vf->amplitude_offset) /
- (((1 << vf->amplitude_bits) - 1) * sqrt(p + q)))
- - vf->amplitude_offset) * .11512925f);
-
- /* fill vector */
- do {
- vec[i] = q; ++i;
- } while (vf->map[blockflag][i] == iter_cond);
- }
- }
- } else {
- /* this channel is unused */
- return 1;
- }
-
- av_dlog(NULL, " Floor0 decoded\n");
-
- return 0;
-}
-
-static int vorbis_floor1_decode(vorbis_context *vc,
- vorbis_floor_data *vfu, float *vec)
-{
- vorbis_floor1 *vf = &vfu->t1;
- GetBitContext *gb = &vc->gb;
- uint16_t range_v[4] = { 256, 128, 86, 64 };
- unsigned range = range_v[vf->multiplier - 1];
- uint16_t floor1_Y[258];
- uint16_t floor1_Y_final[258];
- int floor1_flag[258];
- unsigned partition_class, cdim, cbits, csub, cval, offset, i, j;
- int book, adx, ady, dy, off, predicted, err;
-
-
- if (!get_bits1(gb)) // silence
- return 1;
-
-// Read values (or differences) for the floor's points
-
- floor1_Y[0] = get_bits(gb, ilog(range - 1));
- floor1_Y[1] = get_bits(gb, ilog(range - 1));
-
- av_dlog(NULL, "floor 0 Y %d floor 1 Y %d \n", floor1_Y[0], floor1_Y[1]);
-
- offset = 2;
- for (i = 0; i < vf->partitions; ++i) {
- partition_class = vf->partition_class[i];
- cdim = vf->class_dimensions[partition_class];
- cbits = vf->class_subclasses[partition_class];
- csub = (1 << cbits) - 1;
- cval = 0;
-
- av_dlog(NULL, "Cbits %u\n", cbits);
-
- if (cbits) // this reads all subclasses for this partition's class
- cval = get_vlc2(gb, vc->codebooks[vf->class_masterbook[partition_class]].vlc.table,
- vc->codebooks[vf->class_masterbook[partition_class]].nb_bits, 3);
-
- for (j = 0; j < cdim; ++j) {
- book = vf->subclass_books[partition_class][cval & csub];
-
- av_dlog(NULL, "book %d Cbits %u cval %u bits:%d\n",
- book, cbits, cval, get_bits_count(gb));
-
- cval = cval >> cbits;
- if (book > -1) {
- floor1_Y[offset+j] = get_vlc2(gb, vc->codebooks[book].vlc.table,
- vc->codebooks[book].nb_bits, 3);
- } else {
- floor1_Y[offset+j] = 0;
- }
-
- av_dlog(NULL, " floor(%d) = %d \n",
- vf->list[offset+j].x, floor1_Y[offset+j]);
- }
- offset+=cdim;
- }
-
-// Amplitude calculation from the differences
-
- floor1_flag[0] = 1;
- floor1_flag[1] = 1;
- floor1_Y_final[0] = floor1_Y[0];
- floor1_Y_final[1] = floor1_Y[1];
-
- for (i = 2; i < vf->x_list_dim; ++i) {
- unsigned val, highroom, lowroom, room, high_neigh_offs, low_neigh_offs;
-
- low_neigh_offs = vf->list[i].low;
- high_neigh_offs = vf->list[i].high;
- dy = floor1_Y_final[high_neigh_offs] - floor1_Y_final[low_neigh_offs]; // render_point begin
- adx = vf->list[high_neigh_offs].x - vf->list[low_neigh_offs].x;
- ady = FFABS(dy);
- err = ady * (vf->list[i].x - vf->list[low_neigh_offs].x);
- off = err / adx;
- if (dy < 0) {
- predicted = floor1_Y_final[low_neigh_offs] - off;
- } else {
- predicted = floor1_Y_final[low_neigh_offs] + off;
- } // render_point end
-
- val = floor1_Y[i];
- highroom = range-predicted;
- lowroom = predicted;
- if (highroom < lowroom) {
- room = highroom * 2;
- } else {
- room = lowroom * 2; // SPEC misspelling
- }
- if (val) {
- floor1_flag[low_neigh_offs] = 1;
- floor1_flag[high_neigh_offs] = 1;
- floor1_flag[i] = 1;
- if (val >= room) {
- if (highroom > lowroom) {
- floor1_Y_final[i] = av_clip_uint16(val - lowroom + predicted);
- } else {
- floor1_Y_final[i] = av_clip_uint16(predicted - val + highroom - 1);
- }
- } else {
- if (val & 1) {
- floor1_Y_final[i] = av_clip_uint16(predicted - (val + 1) / 2);
- } else {
- floor1_Y_final[i] = av_clip_uint16(predicted + val / 2);
- }
- }
- } else {
- floor1_flag[i] = 0;
- floor1_Y_final[i] = av_clip_uint16(predicted);
- }
-
- av_dlog(NULL, " Decoded floor(%d) = %u / val %u\n",
- vf->list[i].x, floor1_Y_final[i], val);
- }
-
-// Curve synth - connect the calculated dots and convert from dB scale FIXME optimize ?
-
- ff_vorbis_floor1_render_list(vf->list, vf->x_list_dim, floor1_Y_final, floor1_flag, vf->multiplier, vec, vf->list[1].x);
-
- av_dlog(NULL, " Floor decoded\n");
-
- return 0;
-}
-
-// Read and decode residue
-
-static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
- vorbis_residue *vr,
- unsigned ch,
- uint8_t *do_not_decode,
- float *vec,
- unsigned vlen,
- unsigned ch_left,
- int vr_type)
-{
- GetBitContext *gb = &vc->gb;
- unsigned c_p_c = vc->codebooks[vr->classbook].dimensions;
- unsigned ptns_to_read = vr->ptns_to_read;
- uint8_t *classifs = vr->classifs;
- unsigned pass, ch_used, i, j, k, l;
- unsigned max_output = (ch - 1) * vlen;
-
- if (vr_type == 2) {
- for (j = 1; j < ch; ++j)
- do_not_decode[0] &= do_not_decode[j]; // FIXME - clobbering input
- if (do_not_decode[0])
- return 0;
- ch_used = 1;
- max_output += vr->end / ch;
- } else {
- ch_used = ch;
- max_output += vr->end;
- }
-
- if (max_output > ch_left * vlen) {
- av_log(vc->avccontext, AV_LOG_ERROR, "Insufficient output buffer\n");
- return -1;
- }
-
- av_dlog(NULL, " residue type 0/1/2 decode begin, ch: %d cpc %d \n", ch, c_p_c);
-
- for (pass = 0; pass <= vr->maxpass; ++pass) { // FIXME OPTIMIZE?
- uint16_t voffset, partition_count, j_times_ptns_to_read;
-
- voffset = vr->begin;
- for (partition_count = 0; partition_count < ptns_to_read;) { // SPEC error
- if (!pass) {
- unsigned inverse_class = ff_inverse[vr->classifications];
- for (j_times_ptns_to_read = 0, j = 0; j < ch_used; ++j) {
- if (!do_not_decode[j]) {
- unsigned temp = get_vlc2(gb, vc->codebooks[vr->classbook].vlc.table,
- vc->codebooks[vr->classbook].nb_bits, 3);
-
- av_dlog(NULL, "Classword: %u\n", temp);
-
- av_assert0(vr->classifications > 1 && temp <= 65536); //needed for inverse[]
- for (i = 0; i < c_p_c; ++i) {
- unsigned temp2;
-
- temp2 = (((uint64_t)temp) * inverse_class) >> 32;
- if (partition_count + c_p_c - 1 - i < ptns_to_read)
- classifs[j_times_ptns_to_read + partition_count + c_p_c - 1 - i] = temp - temp2 * vr->classifications;
- temp = temp2;
- }
- }
- j_times_ptns_to_read += ptns_to_read;
- }
- }
- for (i = 0; (i < c_p_c) && (partition_count < ptns_to_read); ++i) {
- for (j_times_ptns_to_read = 0, j = 0; j < ch_used; ++j) {
- unsigned voffs;
-
- if (!do_not_decode[j]) {
- unsigned vqclass = classifs[j_times_ptns_to_read + partition_count];
- int vqbook = vr->books[vqclass][pass];
-
- if (vqbook >= 0 && vc->codebooks[vqbook].codevectors) {
- unsigned coffs;
- unsigned dim = vc->codebooks[vqbook].dimensions;
- unsigned step = FASTDIV(vr->partition_size << 1, dim << 1);
- vorbis_codebook codebook = vc->codebooks[vqbook];
-
- if (vr_type == 0) {
-
- voffs = voffset+j*vlen;
- for (k = 0; k < step; ++k) {
- coffs = get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * dim;
- for (l = 0; l < dim; ++l)
- vec[voffs + k + l * step] += codebook.codevectors[coffs + l];
- }
- } else if (vr_type == 1) {
- voffs = voffset + j * vlen;
- for (k = 0; k < step; ++k) {
- coffs = get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * dim;
- for (l = 0; l < dim; ++l, ++voffs) {
- vec[voffs]+=codebook.codevectors[coffs+l];
-
- av_dlog(NULL, " pass %d offs: %d curr: %f change: %f cv offs.: %d \n",
- pass, voffs, vec[voffs], codebook.codevectors[coffs+l], coffs);
- }
- }
- } else if (vr_type == 2 && ch == 2 && (voffset & 1) == 0 && (dim & 1) == 0) { // most frequent case optimized
- voffs = voffset >> 1;
-
- if (dim == 2) {
- for (k = 0; k < step; ++k) {
- coffs = get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * 2;
- vec[voffs + k ] += codebook.codevectors[coffs ];
- vec[voffs + k + vlen] += codebook.codevectors[coffs + 1];
- }
- } else if (dim == 4) {
- for (k = 0; k < step; ++k, voffs += 2) {
- coffs = get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * 4;
- vec[voffs ] += codebook.codevectors[coffs ];
- vec[voffs + 1 ] += codebook.codevectors[coffs + 2];
- vec[voffs + vlen ] += codebook.codevectors[coffs + 1];
- vec[voffs + vlen + 1] += codebook.codevectors[coffs + 3];
- }
- } else
- for (k = 0; k < step; ++k) {
- coffs = get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * dim;
- for (l = 0; l < dim; l += 2, voffs++) {
- vec[voffs ] += codebook.codevectors[coffs + l ];
- vec[voffs + vlen] += codebook.codevectors[coffs + l + 1];
-
- av_dlog(NULL, " pass %d offs: %d curr: %f change: %f cv offs.: %d+%d \n",
- pass, voffset / ch + (voffs % ch) * vlen,
- vec[voffset / ch + (voffs % ch) * vlen],
- codebook.codevectors[coffs + l], coffs, l);
- }
- }
-
- } else if (vr_type == 2) {
- unsigned voffs_div = FASTDIV(voffset << 1, ch <<1);
- unsigned voffs_mod = voffset - voffs_div * ch;
-
- for (k = 0; k < step; ++k) {
- coffs = get_vlc2(gb, codebook.vlc.table, codebook.nb_bits, 3) * dim;
- for (l = 0; l < dim; ++l) {
- vec[voffs_div + voffs_mod * vlen] +=
- codebook.codevectors[coffs + l];
-
- av_dlog(NULL, " pass %d offs: %d curr: %f change: %f cv offs.: %d+%d \n",
- pass, voffs_div + voffs_mod * vlen,
- vec[voffs_div + voffs_mod * vlen],
- codebook.codevectors[coffs + l], coffs, l);
-
- if (++voffs_mod == ch) {
- voffs_div++;
- voffs_mod = 0;
- }
- }
- }
- }
- }
- }
- j_times_ptns_to_read += ptns_to_read;
- }
- ++partition_count;
- voffset += vr->partition_size;
- }
- }
- }
- return 0;
-}
-
-static inline int vorbis_residue_decode(vorbis_context *vc, vorbis_residue *vr,
- unsigned ch,
- uint8_t *do_not_decode,
- float *vec, unsigned vlen,
- unsigned ch_left)
-{
- if (vr->type == 2)
- return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, ch_left, 2);
- else if (vr->type == 1)
- return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, ch_left, 1);
- else if (vr->type == 0)
- return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, ch_left, 0);
- else {
- av_log(vc->avccontext, AV_LOG_ERROR, " Invalid residue type while residue decode?! \n");
- return AVERROR_INVALIDDATA;
- }
-}
-
-void ff_vorbis_inverse_coupling(float *mag, float *ang, intptr_t blocksize)
-{
- int i;
- for (i = 0; i < blocksize; i++) {
- if (mag[i] > 0.0) {
- if (ang[i] > 0.0) {
- ang[i] = mag[i] - ang[i];
- } else {
- float temp = ang[i];
- ang[i] = mag[i];
- mag[i] += temp;
- }
- } else {
- if (ang[i] > 0.0) {
- ang[i] += mag[i];
- } else {
- float temp = ang[i];
- ang[i] = mag[i];
- mag[i] -= temp;
- }
- }
- }
-}
-
-// Decode the audio packet using the functions above
-
-static int vorbis_parse_audio_packet(vorbis_context *vc, float **floor_ptr)
-{
- GetBitContext *gb = &vc->gb;
- FFTContext *mdct;
- unsigned previous_window = vc->previous_window;
- unsigned mode_number, blockflag, blocksize;
- int i, j;
- uint8_t no_residue[255];
- uint8_t do_not_decode[255];
- vorbis_mapping *mapping;
- float *ch_res_ptr = vc->channel_residues;
- uint8_t res_chan[255];
- unsigned res_num = 0;
- int retlen = 0;
- unsigned ch_left = vc->audio_channels;
- unsigned vlen;
-
- if (get_bits1(gb)) {
- av_log(vc->avccontext, AV_LOG_ERROR, "Not a Vorbis I audio packet.\n");
- return AVERROR_INVALIDDATA; // packet type not audio
- }
-
- if (vc->mode_count == 1) {
- mode_number = 0;
- } else {
- GET_VALIDATED_INDEX(mode_number, ilog(vc->mode_count-1), vc->mode_count)
- }
- vc->mode_number = mode_number;
- mapping = &vc->mappings[vc->modes[mode_number].mapping];
-
- av_dlog(NULL, " Mode number: %u , mapping: %d , blocktype %d\n", mode_number,
- vc->modes[mode_number].mapping, vc->modes[mode_number].blockflag);
-
- blockflag = vc->modes[mode_number].blockflag;
- blocksize = vc->blocksize[blockflag];
- vlen = blocksize / 2;
- if (blockflag) {
- previous_window = get_bits(gb, 1);
- skip_bits1(gb); // next_window
- }
-
- memset(ch_res_ptr, 0, sizeof(float) * vc->audio_channels * vlen); //FIXME can this be removed ?
- for (i = 0; i < vc->audio_channels; ++i)
- memset(floor_ptr[i], 0, vlen * sizeof(floor_ptr[0][0])); //FIXME can this be removed ?
-
-// Decode floor
-
- for (i = 0; i < vc->audio_channels; ++i) {
- vorbis_floor *floor;
- int ret;
- if (mapping->submaps > 1) {
- floor = &vc->floors[mapping->submap_floor[mapping->mux[i]]];
- } else {
- floor = &vc->floors[mapping->submap_floor[0]];
- }
-
- ret = floor->decode(vc, &floor->data, floor_ptr[i]);
-
- if (ret < 0) {
- av_log(vc->avccontext, AV_LOG_ERROR, "Invalid codebook in vorbis_floor_decode.\n");
- return AVERROR_INVALIDDATA;
- }
- no_residue[i] = ret;
- }
-
-// Nonzero vector propagate
-
- for (i = mapping->coupling_steps - 1; i >= 0; --i) {
- if (!(no_residue[mapping->magnitude[i]] & no_residue[mapping->angle[i]])) {
- no_residue[mapping->magnitude[i]] = 0;
- no_residue[mapping->angle[i]] = 0;
- }
- }
-
-// Decode residue
-
- for (i = 0; i < mapping->submaps; ++i) {
- vorbis_residue *residue;
- unsigned ch = 0;
- int ret;
-
- for (j = 0; j < vc->audio_channels; ++j) {
- if ((mapping->submaps == 1) || (i == mapping->mux[j])) {
- res_chan[j] = res_num;
- if (no_residue[j]) {
- do_not_decode[ch] = 1;
- } else {
- do_not_decode[ch] = 0;
- }
- ++ch;
- ++res_num;
- }
- }
- residue = &vc->residues[mapping->submap_residue[i]];
- if (ch_left < ch) {
- av_log(vc->avccontext, AV_LOG_ERROR, "Too many channels in vorbis_floor_decode.\n");
- return -1;
- }
- if (ch) {
- ret = vorbis_residue_decode(vc, residue, ch, do_not_decode, ch_res_ptr, vlen, ch_left);
- if (ret < 0)
- return ret;
- }
-
- ch_res_ptr += ch * vlen;
- ch_left -= ch;
- }
-
- if (ch_left > 0)
- return AVERROR_INVALIDDATA;
-
-// Inverse coupling
-
- for (i = mapping->coupling_steps - 1; i >= 0; --i) { //warning: i has to be signed
- float *mag, *ang;
-
- mag = vc->channel_residues+res_chan[mapping->magnitude[i]] * blocksize / 2;
- ang = vc->channel_residues+res_chan[mapping->angle[i]] * blocksize / 2;
- vc->dsp.vorbis_inverse_coupling(mag, ang, blocksize / 2);
- }
-
-// Dotproduct, MDCT
-
- mdct = &vc->mdct[blockflag];
-
- for (j = vc->audio_channels-1;j >= 0; j--) {
- ch_res_ptr = vc->channel_residues + res_chan[j] * blocksize / 2;
- vc->fdsp.vector_fmul(floor_ptr[j], floor_ptr[j], ch_res_ptr, blocksize / 2);
- mdct->imdct_half(mdct, ch_res_ptr, floor_ptr[j]);
- }
-
-// Overlap/add, save data for next overlapping
-
- retlen = (blocksize + vc->blocksize[previous_window]) / 4;
- for (j = 0; j < vc->audio_channels; j++) {
- unsigned bs0 = vc->blocksize[0];
- unsigned bs1 = vc->blocksize[1];
- float *residue = vc->channel_residues + res_chan[j] * blocksize / 2;
- float *saved = vc->saved + j * bs1 / 4;
- float *ret = floor_ptr[j];
- float *buf = residue;
- const float *win = vc->win[blockflag & previous_window];
-
- if (blockflag == previous_window) {
- vc->fdsp.vector_fmul_window(ret, saved, buf, win, blocksize / 4);
- } else if (blockflag > previous_window) {
- vc->fdsp.vector_fmul_window(ret, saved, buf, win, bs0 / 4);
- memcpy(ret+bs0/2, buf+bs0/4, ((bs1-bs0)/4) * sizeof(float));
- } else {
- memcpy(ret, saved, ((bs1 - bs0) / 4) * sizeof(float));
- vc->fdsp.vector_fmul_window(ret + (bs1 - bs0) / 4, saved + (bs1 - bs0) / 4, buf, win, bs0 / 4);
- }
- memcpy(saved, buf + blocksize / 4, blocksize / 4 * sizeof(float));
- }
-
- vc->previous_window = blockflag;
- return retlen;
-}
-
-// Return the decoded audio packet through the standard api
-
-static int vorbis_decode_frame(AVCodecContext *avccontext, void *data,
- int *got_frame_ptr, AVPacket *avpkt)
-{
- const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size;
- vorbis_context *vc = avccontext->priv_data;
- AVFrame *frame = data;
- GetBitContext *gb = &vc->gb;
- float *channel_ptrs[255];
- int i, len, ret;
-
- av_dlog(NULL, "packet length %d \n", buf_size);
-
- if (*buf == 1 && buf_size > 7) {
- init_get_bits(gb, buf+1, buf_size*8 - 8);
- vorbis_free(vc);
- if ((ret = vorbis_parse_id_hdr(vc))) {
- av_log(avccontext, AV_LOG_ERROR, "Id header corrupt.\n");
- vorbis_free(vc);
- return ret;
- }
-
- if (vc->audio_channels > 8)
- avccontext->channel_layout = 0;
- else
- avccontext->channel_layout = ff_vorbis_channel_layouts[vc->audio_channels - 1];
-
- avccontext->channels = vc->audio_channels;
- avccontext->sample_rate = vc->audio_samplerate;
- return buf_size;
- }
-
- if (*buf == 3 && buf_size > 7) {
- av_log(avccontext, AV_LOG_DEBUG, "Ignoring comment header\n");
- return buf_size;
- }
-
- if (*buf == 5 && buf_size > 7 && vc->channel_residues && !vc->modes) {
- init_get_bits(gb, buf+1, buf_size*8 - 8);
- if ((ret = vorbis_parse_setup_hdr(vc))) {
- av_log(avccontext, AV_LOG_ERROR, "Setup header corrupt.\n");
- vorbis_free(vc);
- return ret;
- }
- return buf_size;
- }
-
- if (!vc->channel_residues || !vc->modes) {
- av_log(avccontext, AV_LOG_ERROR, "Data packet before valid headers\n");
- return AVERROR_INVALIDDATA;
- }
-
- /* get output buffer */
- frame->nb_samples = vc->blocksize[1] / 2;
- if ((ret = ff_get_buffer(avccontext, frame)) < 0) {
- av_log(avccontext, AV_LOG_ERROR, "get_buffer() failed\n");
- return ret;
- }
-
- if (vc->audio_channels > 8) {
- for (i = 0; i < vc->audio_channels; i++)
- channel_ptrs[i] = (float *)frame->extended_data[i];
- } else {
- for (i = 0; i < vc->audio_channels; i++) {
- int ch = ff_vorbis_channel_layout_offsets[vc->audio_channels - 1][i];
- channel_ptrs[ch] = (float *)frame->extended_data[i];
- }
- }
-
- init_get_bits(gb, buf, buf_size*8);
-
- if ((len = vorbis_parse_audio_packet(vc, channel_ptrs)) <= 0)
- return len;
-
- if (!vc->first_frame) {
- vc->first_frame = 1;
- *got_frame_ptr = 0;
- return buf_size;
- }
-
- av_dlog(NULL, "parsed %d bytes %d bits, returned %d samples (*ch*bits) \n",
- get_bits_count(gb) / 8, get_bits_count(gb) % 8, len);
-
- frame->nb_samples = len;
- *got_frame_ptr = 1;
-
- return buf_size;
-}
-
-// Close decoder
-
-static av_cold int vorbis_decode_close(AVCodecContext *avccontext)
-{
- vorbis_context *vc = avccontext->priv_data;
-
- vorbis_free(vc);
-
- return 0;
-}
-
-static av_cold void vorbis_decode_flush(AVCodecContext *avccontext)
-{
- vorbis_context *vc = avccontext->priv_data;
-
- if (vc->saved) {
- memset(vc->saved, 0, (vc->blocksize[1] / 4) * vc->audio_channels *
- sizeof(*vc->saved));
- }
- vc->previous_window = 0;
-}
-
-AVCodec ff_vorbis_decoder = {
- .name = "vorbis",
- .type = AVMEDIA_TYPE_AUDIO,
- .id = AV_CODEC_ID_VORBIS,
- .priv_data_size = sizeof(vorbis_context),
- .init = vorbis_decode_init,
- .close = vorbis_decode_close,
- .decode = vorbis_decode_frame,
- .flush = vorbis_decode_flush,
- .capabilities = CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("Vorbis"),
- .channel_layouts = ff_vorbis_channel_layouts,
- .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
- AV_SAMPLE_FMT_NONE },
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/vorbisdsp.c b/src/thirdparty/ffmpeg/libavcodec/vorbisdsp.c
deleted file mode 100644
index fd8dcd7da..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vorbisdsp.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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 "vorbisdsp.h"
-#include "vorbis.h"
-
-void ff_vorbisdsp_init(VorbisDSPContext *dsp)
-{
- dsp->vorbis_inverse_coupling = ff_vorbis_inverse_coupling;
-
- if (ARCH_X86)
- ff_vorbisdsp_init_x86(dsp);
- if (ARCH_PPC)
- ff_vorbisdsp_init_ppc(dsp);
- if (ARCH_ARM)
- ff_vorbisdsp_init_arm(dsp);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/vorbisdsp.h b/src/thirdparty/ffmpeg/libavcodec/vorbisdsp.h
deleted file mode 100644
index ed14049c8..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vorbisdsp.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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_VORBISDSP_H
-#define AVCODEC_VORBISDSP_H
-
-#include <stdint.h>
-
-typedef struct VorbisDSPContext {
- /* assume len is a multiple of 4, and arrays are 16-byte aligned */
- void (*vorbis_inverse_coupling)(float *mag, float *ang,
- intptr_t blocksize);
-} VorbisDSPContext;
-
-void ff_vorbisdsp_init(VorbisDSPContext *dsp);
-
-/* for internal use only */
-void ff_vorbisdsp_init_x86(VorbisDSPContext *dsp);
-void ff_vorbisdsp_init_arm(VorbisDSPContext *dsp);
-void ff_vorbisdsp_init_ppc(VorbisDSPContext *dsp);
-
-#endif /* AVCODEC_VORBISDSP_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/vp3.c b/src/thirdparty/ffmpeg/libavcodec/vp3.c
deleted file mode 100644
index 55f2e4858..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vp3.c
+++ /dev/null
@@ -1,2452 +0,0 @@
-/*
- * Copyright (C) 2003-2004 the ffmpeg project
- *
- * 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
- * On2 VP3 Video Decoder
- *
- * VP3 Video Decoder by Mike Melanson (mike at multimedia.cx)
- * For more information about the VP3 coding process, visit:
- * http://wiki.multimedia.cx/index.php?title=On2_VP3
- *
- * Theora decoder by Alex Beregszaszi
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "libavutil/imgutils.h"
-#include "avcodec.h"
-#include "internal.h"
-#include "dsputil.h"
-#include "get_bits.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
-typedef struct Vp3Fragment {
- int16_t dc;
- uint8_t coding_method;
- uint8_t qpi;
-} Vp3Fragment;
-
-#define SB_NOT_CODED 0
-#define SB_PARTIALLY_CODED 1
-#define SB_FULLY_CODED 2
-
-// This is the maximum length of a single long bit run that can be encoded
-// for superblock coding or block qps. Theora special-cases this to read a
-// bit instead of flipping the current bit to allow for runs longer than 4129.
-#define MAXIMUM_LONG_BIT_RUN 4129
-
-#define MODE_INTER_NO_MV 0
-#define MODE_INTRA 1
-#define MODE_INTER_PLUS_MV 2
-#define MODE_INTER_LAST_MV 3
-#define MODE_INTER_PRIOR_LAST 4
-#define MODE_USING_GOLDEN 5
-#define MODE_GOLDEN_MV 6
-#define MODE_INTER_FOURMV 7
-#define CODING_MODE_COUNT 8
-
-/* special internal mode */
-#define MODE_COPY 8
-
-static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb);
-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] =
-{
- /* 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 },
-
- /* 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 },
-
- /* 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 },
-
- /* 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 },
-
- /* 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 },
-
- /* 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 },
-
-};
-
-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}
-};
-
-#define MIN_DEQUANT_VAL 2
-
-typedef struct Vp3DecodeContext {
- AVCodecContext *avctx;
- int theora, theora_tables;
- int version;
- int width, height;
- int chroma_x_shift, chroma_y_shift;
- AVFrame golden_frame;
- AVFrame last_frame;
- AVFrame current_frame;
- int keyframe;
- DSPContext dsp;
- VideoDSPContext vdsp;
- VP3DSPContext vp3dsp;
- DECLARE_ALIGNED(16, int16_t, block)[64];
- int flipped_image;
- int last_slice_end;
- int skip_loop_filter;
-
- int qps[3];
- int nqps;
- int last_qps[3];
-
- int superblock_count;
- int y_superblock_width;
- int y_superblock_height;
- int y_superblock_count;
- int c_superblock_width;
- int c_superblock_height;
- int c_superblock_count;
- int u_superblock_start;
- int v_superblock_start;
- unsigned char *superblock_coding;
-
- int macroblock_count;
- int macroblock_width;
- int macroblock_height;
-
- int fragment_count;
- int fragment_width[2];
- int fragment_height[2];
-
- Vp3Fragment *all_fragments;
- int fragment_start[3];
- int data_offset[3];
-
- int8_t (*motion_val[2])[2];
-
- ScanTable scantable;
-
- /* tables */
- uint16_t coded_dc_scale_factor[64];
- 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];
- uint16_t qr_base[2][3][64];
-
- /**
- * This is a list of all tokens in bitstream order. Reordering takes place
- * by pulling from each level during IDCT. As a consequence, IDCT must be
- * in Hilbert order, making the minimum slice height 64 for 4:2:0 and 32
- * otherwise. The 32 different tokens with up to 12 bits of extradata are
- * collapsed into 3 types, packed as follows:
- * (from the low to high bits)
- *
- * 2 bits: type (0,1,2)
- * 0: EOB run, 14 bits for run length (12 needed)
- * 1: zero run, 7 bits for run length
- * 7 bits for the next coefficient (3 needed)
- * 2: coefficient, 14 bits (11 needed)
- *
- * Coefficients are signed, so are packed in the highest bits for automatic
- * sign extension.
- */
- int16_t *dct_tokens[3][64];
- int16_t *dct_tokens_base;
-#define TOKEN_EOB(eob_run) ((eob_run) << 2)
-#define TOKEN_ZERO_RUN(coeff, zero_run) (((coeff) << 9) + ((zero_run) << 2) + 1)
-#define TOKEN_COEFF(coeff) (((coeff) << 2) + 2)
-
- /**
- * number of blocks that contain DCT coefficients at the given level or higher
- */
- int num_coded_frags[3][64];
- int total_num_coded_frags;
-
- /* this is a list of indexes into the all_fragments array indicating
- * which of the fragments are coded */
- int *coded_fragment_list[3];
-
- VLC dc_vlc[16];
- VLC ac_vlc_1[16];
- VLC ac_vlc_2[16];
- VLC ac_vlc_3[16];
- VLC ac_vlc_4[16];
-
- VLC superblock_run_length_vlc;
- VLC fragment_run_length_vlc;
- VLC mode_code_vlc;
- VLC motion_vector_vlc;
-
- /* these arrays need to be on 16-byte boundaries since SSE2 operations
- * index into them */
- DECLARE_ALIGNED(16, int16_t, qmat)[3][2][3][64]; ///< qmat[qpi][is_inter][plane]
-
- /* This table contains superblock_count * 16 entries. Each set of 16
- * numbers corresponds to the fragment indexes 0..15 of the superblock.
- * An entry will be -1 to indicate that no entry corresponds to that
- * index. */
- int *superblock_fragments;
-
- /* This is an array that indicates how a particular macroblock
- * is coded. */
- unsigned char *macroblock_coding;
-
- uint8_t *edge_emu_buffer;
-
- /* Huffman decode */
- int hti;
- unsigned int hbits;
- int entries;
- int huff_code_size;
- uint32_t huffman_table[80][32][2];
-
- uint8_t filter_limit_values[64];
- DECLARE_ALIGNED(8, int, bounding_values_array)[256+2];
-} Vp3DecodeContext;
-
-/************************************************************************
- * VP3 specific functions
- ************************************************************************/
-
-static void vp3_decode_flush(AVCodecContext *avctx)
-{
- Vp3DecodeContext *s = avctx->priv_data;
-
- if (s->golden_frame.data[0]) {
- if (s->golden_frame.data[0] == s->last_frame.data[0])
- memset(&s->last_frame, 0, sizeof(AVFrame));
- if (s->current_frame.data[0] == s->golden_frame.data[0])
- memset(&s->current_frame, 0, sizeof(AVFrame));
- ff_thread_release_buffer(avctx, &s->golden_frame);
- }
- if (s->last_frame.data[0]) {
- if (s->current_frame.data[0] == s->last_frame.data[0])
- memset(&s->current_frame, 0, sizeof(AVFrame));
- ff_thread_release_buffer(avctx, &s->last_frame);
- }
- if (s->current_frame.data[0])
- ff_thread_release_buffer(avctx, &s->current_frame);
-}
-
-static av_cold int vp3_decode_end(AVCodecContext *avctx)
-{
- Vp3DecodeContext *s = avctx->priv_data;
- int i;
-
- av_freep(&s->superblock_coding);
- av_freep(&s->all_fragments);
- av_freep(&s->coded_fragment_list[0]);
- av_freep(&s->dct_tokens_base);
- av_freep(&s->superblock_fragments);
- av_freep(&s->macroblock_coding);
- av_freep(&s->motion_val[0]);
- av_freep(&s->motion_val[1]);
- av_freep(&s->edge_emu_buffer);
-
- s->theora_tables = 0;
-
- if (avctx->internal->is_copy)
- return 0;
-
- for (i = 0; i < 16; i++) {
- ff_free_vlc(&s->dc_vlc[i]);
- ff_free_vlc(&s->ac_vlc_1[i]);
- ff_free_vlc(&s->ac_vlc_2[i]);
- ff_free_vlc(&s->ac_vlc_3[i]);
- ff_free_vlc(&s->ac_vlc_4[i]);
- }
-
- ff_free_vlc(&s->superblock_run_length_vlc);
- ff_free_vlc(&s->fragment_run_length_vlc);
- ff_free_vlc(&s->mode_code_vlc);
- ff_free_vlc(&s->motion_vector_vlc);
-
- /* release all frames */
- vp3_decode_flush(avctx);
-
- return 0;
-}
-
-/**
- * This function sets up all of the various blocks mappings:
- * superblocks <-> fragments, macroblocks <-> fragments,
- * superblocks <-> macroblocks
- *
- * @return 0 is successful; returns 1 if *anything* went wrong.
- */
-static int init_block_mapping(Vp3DecodeContext *s)
-{
- int sb_x, sb_y, plane;
- 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 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];
-
- if (x < frag_width && y < frag_height)
- s->superblock_fragments[j++] = s->fragment_start[plane] + y*frag_width + x;
- else
- s->superblock_fragments[j++] = -1;
- }
- }
-
- return 0; /* successful path out */
-}
-
-/*
- * This function sets up the dequantization tables used for a particular
- * frame.
- */
-static void init_dequantizer(Vp3DecodeContext *s, int qpi)
-{
- int ac_scale_factor = s->coded_ac_scale_factor[s->qps[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)
- 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;
-
- s->qmat[qpi][inter][plane][s->dsp.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
- s->qmat[qpi][inter][plane][0] = s->qmat[0][inter][plane][0];
- }
- }
-}
-
-/*
- * This function initializes the loop filter boundary limits if the frame's
- * quality index is different from the previous frame's.
- *
- * The filter_limit_values may not be larger than 127.
- */
-static void init_loop_filter(Vp3DecodeContext *s)
-{
- int *bounding_values= s->bounding_values_array+127;
- int filter_limit;
- int x;
- int value;
-
- filter_limit = s->filter_limit_values[s->qps[0]];
- av_assert0(filter_limit < 128U);
-
- /* set up the bounding values */
- memset(s->bounding_values_array, 0, 256 * sizeof(int));
- for (x = 0; x < filter_limit; x++) {
- bounding_values[-x] = -x;
- bounding_values[x] = x;
- }
- for (x = value = filter_limit; x < 128 && value; x++, value--) {
- bounding_values[ x] = value;
- bounding_values[-x] = -value;
- }
- if (value)
- bounding_values[128] = value;
- bounding_values[129] = bounding_values[130] = filter_limit * 0x02020202;
-}
-
-/*
- * This function unpacks all of the superblock/macroblock/fragment coding
- * information from the bitstream.
- */
-static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb)
-{
- int superblock_starts[3] = { 0, s->u_superblock_start, s->v_superblock_start };
- int bit = 0;
- int current_superblock = 0;
- int current_run = 0;
- int num_partial_superblocks = 0;
-
- int i, j;
- int current_fragment;
- int plane;
-
- 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;
- current_run = 0;
-
- while (current_superblock < s->superblock_count && 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);
-
- if (current_superblock + current_run > s->superblock_count) {
- av_log(s->avctx, AV_LOG_ERROR, "Invalid partially coded superblock run length\n");
- return -1;
- }
-
- memset(s->superblock_coding + current_superblock, bit, current_run);
-
- current_superblock += current_run;
- if (bit)
- num_partial_superblocks += current_run;
- }
-
- /* unpack the list of fully coded superblocks if any of the blocks were
- * not marked as partially coded in the previous step */
- if (num_partial_superblocks < s->superblock_count) {
- 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) {
-
- 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);
-
- 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");
- 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++;
- }
- }
- superblocks_decoded += current_run;
- }
- }
-
- /* if there were partial blocks, initialize bitstream for
- * unpacking fragment codings */
- if (num_partial_superblocks) {
-
- current_run = 0;
- 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;
- }
- }
-
- /* figure out which fragments are coded; iterate through each
- * superblock (all planes) */
- s->total_num_coded_frags = 0;
- memset(s->macroblock_coding, MODE_COPY, s->macroblock_count);
-
- 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 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);
- }
- coded = bit;
- }
-
- if (coded) {
- /* default mode; actual mode will be decoded in
- * the next phase */
- s->all_fragments[current_fragment].coding_method =
- MODE_INTER_NO_MV;
- s->coded_fragment_list[plane][num_coded_frags++] =
- current_fragment;
- } else {
- /* not coded; copy this fragment from the prior frame */
- 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;
- }
- return 0;
-}
-
-/*
- * This function unpacks all the coding mode data for individual macroblocks
- * from the bitstream.
- */
-static int unpack_modes(Vp3DecodeContext *s, GetBitContext *gb)
-{
- int i, j, k, sb_x, sb_y;
- int scheme;
- int current_macroblock;
- int current_fragment;
- int coding_mode;
- int custom_mode_alphabet[CODING_MODE_COUNT];
- const int *alphabet;
- Vp3Fragment *frag;
-
- 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);
-
- /* is it a custom coding scheme? */
- if (scheme == 0) {
- for (i = 0; i < 8; i++)
- custom_mode_alphabet[i] = MODE_INTER_NO_MV;
- for (i = 0; i < 8; i++)
- custom_mode_alphabet[get_bits(gb, 3)] = i;
- alphabet = custom_mode_alphabet;
- } else
- alphabet = ModeAlphabet[scheme-1];
-
- /* iterate through all of the macroblocks that contain 1 or more
- * coded fragments */
- for (sb_y = 0; sb_y < s->y_superblock_height; sb_y++) {
- for (sb_x = 0; sb_x < s->y_superblock_width; sb_x++) {
- 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;
-
- 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;
- }
-
- /* 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;
- }
-
-#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;
- SET_CHROMA_MODES
- }
- }
- }
- }
- }
- }
-
- return 0;
-}
-
-/*
- * This function unpacks all the motion vectors for the individual
- * macroblocks from the bitstream.
- */
-static int unpack_vectors(Vp3DecodeContext *s, GetBitContext *gb)
-{
- int j, k, sb_x, sb_y;
- int coding_mode;
- int motion_x[4];
- int motion_y[4];
- int last_motion_x = 0;
- int last_motion_y = 0;
- int prior_last_motion_x = 0;
- int prior_last_motion_y = 0;
- int current_macroblock;
- int current_fragment;
- int frag;
-
- if (s->keyframe)
- return 0;
-
- /* coding mode 0 is the VLC scheme; 1 is the fixed code scheme */
- coding_mode = get_bits1(gb);
-
- /* iterate through all of the macroblocks that contain 1 or more
- * coded fragments */
- for (sb_y = 0; sb_y < s->y_superblock_height; sb_y++) {
- for (sb_x = 0; sb_x < s->y_superblock_width; sb_x++) {
- 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;
-
- 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]) {
-
- 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;
-
- 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)];
- } 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] = 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;
- }
-
- /* 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];
- }
- }
-
- 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];
- }
- } 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;
-}
-
-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++) {
- i = blocks_decoded = num_blocks_at_qpi = 0;
-
- bit = get_bits1(gb) ^ 1;
- run_length = 0;
-
- do {
- if (run_length == MAXIMUM_LONG_BIT_RUN)
- bit = get_bits1(gb);
- else
- bit ^= 1;
-
- run_length = get_vlc2(gb, s->superblock_run_length_vlc.table, 6, 2) + 1;
- if (run_length == 34)
- run_length += get_bits(gb, 12);
- blocks_decoded += run_length;
-
- if (!bit)
- num_blocks_at_qpi += run_length;
-
- for (j = 0; j < run_length; i++) {
- if (i >= s->total_num_coded_frags)
- return -1;
-
- if (s->all_fragments[s->coded_fragment_list[0][i]].qpi == qpi) {
- s->all_fragments[s->coded_fragment_list[0][i]].qpi += bit;
- j++;
- }
- }
- } while (blocks_decoded < num_blocks && get_bits_left(gb) > 0);
-
- num_blocks -= num_blocks_at_qpi;
- }
-
- return 0;
-}
-
-/*
- * This function is called by unpack_dct_coeffs() to extract the VLCs from
- * the bitstream. The VLCs encode tokens which are used to unpack DCT
- * data. This function unpacks all the VLCs for either the Y plane or both
- * C planes, and is called for DC coefficients or different AC coefficient
- * levels (since different coefficient types require different VLC tables.
- *
- * This function returns a residual eob run. E.g, if a particular token gave
- * instructions to EOB the next 5 fragments and there were only 2 fragments
- * left in the current fragment range, 3 would be returned so that it could
- * 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)
-{
- int i, j = 0;
- int token;
- 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];
- 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];
- Vp3Fragment *all_fragments = s->all_fragments;
- 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);
-
- if (eob_run > num_coeffs) {
- coeff_i = blocks_ended = num_coeffs;
- eob_run -= num_coeffs;
- } else {
- coeff_i = blocks_ended = eob_run;
- eob_run = 0;
- }
-
- // insert fake EOB token to cover the split between planes or zzi
- if (blocks_ended)
- 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++;
- } 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])
- av_log(s->avctx, AV_LOG_ERROR, "More blocks ended than coded!\n");
-
- // 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++)
- 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;
- else if (coeff_index < 63)
- s->dct_tokens[0][coeff_index+1] = dct_tokens + j;
-
- return eob_run;
-}
-
-static void reverse_dc_prediction(Vp3DecodeContext *s,
- int first_fragment,
- int fragment_width,
- int fragment_height);
-/*
- * This function unpacks all of the DCT coefficient data from the
- * bitstream.
- */
-static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitContext *gb)
-{
- int i;
- int dc_y_table;
- int dc_c_table;
- int ac_y_table;
- int ac_c_table;
- int residual_eob_run = 0;
- VLC *y_tables[64];
- VLC *c_tables[64];
-
- s->dct_tokens[0][0] = s->dct_tokens_base;
-
- /* fetch the DC table indexes */
- dc_y_table = get_bits(gb, 4);
- dc_c_table = get_bits(gb, 4);
-
- /* unpack the Y plane DC coefficients */
- residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_y_table], 0,
- 0, residual_eob_run);
- if (residual_eob_run < 0)
- return residual_eob_run;
-
- /* reverse prediction of the Y-plane DC coefficients */
- reverse_dc_prediction(s, 0, s->fragment_width[0], s->fragment_height[0]);
-
- /* unpack the C plane DC coefficients */
- residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0,
- 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);
- if (residual_eob_run < 0)
- return residual_eob_run;
-
- /* reverse prediction of the C-plane DC coefficients */
- if (!(s->avctx->flags & CODEC_FLAG_GRAY))
- {
- reverse_dc_prediction(s, s->fragment_start[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]);
- }
-
- /* fetch the AC table indexes */
- ac_y_table = get_bits(gb, 4);
- ac_c_table = get_bits(gb, 4);
-
- /* build tables of AC VLC tables */
- for (i = 1; i <= 5; i++) {
- y_tables[i] = &s->ac_vlc_1[ac_y_table];
- c_tables[i] = &s->ac_vlc_1[ac_c_table];
- }
- for (i = 6; i <= 14; i++) {
- y_tables[i] = &s->ac_vlc_2[ac_y_table];
- c_tables[i] = &s->ac_vlc_2[ac_c_table];
- }
- for (i = 15; i <= 27; i++) {
- y_tables[i] = &s->ac_vlc_3[ac_y_table];
- c_tables[i] = &s->ac_vlc_3[ac_c_table];
- }
- for (i = 28; i <= 63; i++) {
- y_tables[i] = &s->ac_vlc_4[ac_y_table];
- c_tables[i] = &s->ac_vlc_4[ac_c_table];
- }
-
- /* 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;
- }
-
- return 0;
-}
-
-/*
- * This function reverses the DC prediction for each coded fragment in
- * 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 DC_COEFF(u) s->all_fragments[u].dc
-
-static void reverse_dc_prediction(Vp3DecodeContext *s,
- int first_fragment,
- int fragment_width,
- int fragment_height)
-{
-
-#define PUL 8
-#define PU 4
-#define PUR 2
-#define PL 1
-
- int x, y;
- int i = first_fragment;
-
- int predicted_dc;
-
- /* DC values for the left, up-left, up, and up-right fragments */
- int vl, vul, vu, vur;
-
- /* indexes for the left, up-left, up, and up-right fragments */
- int l, ul, u, ur;
-
- /*
- * The 6 fields mean:
- * 0: up-left multiplier
- * 1: up multiplier
- * 2: up-right multiplier
- * 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
- };
-
- /* This table shows which types of blocks can use other blocks for
- * prediction. For example, INTRA is the only mode in this table to
- * have a frame number of 0. That means INTRA blocks can only predict
- * from other INTRA blocks. There are 2 golden frame coding types;
- * blocks encoding in these modes can only predict from other blocks
- * that were encoded with these 1 of these 2 modes. */
- static const unsigned char compatible_frame[9] = {
- 1, /* MODE_INTER_NO_MV */
- 0, /* MODE_INTRA */
- 1, /* MODE_INTER_PLUS_MV */
- 1, /* MODE_INTER_LAST_MV */
- 1, /* MODE_INTER_PRIOR_MV */
- 2, /* MODE_USING_GOLDEN */
- 2, /* MODE_GOLDEN_MV */
- 1, /* MODE_INTER_FOUR_MV */
- 3 /* MODE_COPY */
- };
- int current_frame_type;
-
- /* there is a last DC predictor for each of the 3 frame types */
- short last_dc[3];
-
- int transform = 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;
- vl = DC_COEFF(l);
- if(COMPATIBLE_FRAME(l))
- transform |= PL;
- }
- if(y){
- u= i-fragment_width;
- vu = DC_COEFF(u);
- if(COMPATIBLE_FRAME(u))
- transform |= PU;
- if(x){
- ul= i-fragment_width-1;
- vul = DC_COEFF(ul);
- if(COMPATIBLE_FRAME(ul))
- transform |= PUL;
- }
- if(x + 1 < fragment_width){
- ur= i-fragment_width+1;
- vur = DC_COEFF(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) +
- (predictor_transform[transform][1] * vu) +
- (predictor_transform[transform][2] * vur) +
- (predictor_transform[transform][3] * vl);
-
- predicted_dc /= 128;
-
- /* check for outranging on the [ul u l] and
- * [ul u ur l] predictors */
- if ((transform == 15) || (transform == 13)) {
- if (FFABS(predicted_dc - vu) > 128)
- predicted_dc = vu;
- else if (FFABS(predicted_dc - vl) > 128)
- predicted_dc = vl;
- else if (FFABS(predicted_dc - vul) > 128)
- predicted_dc = vul;
- }
- }
-
- /* at long last, apply the predictor */
- DC_COEFF(i) += predicted_dc;
- /* save the DC */
- last_dc[current_frame_type] = DC_COEFF(i);
- }
- }
- }
-}
-
-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 width = s->fragment_width[!!plane];
- int height = s->fragment_height[!!plane];
- int fragment = s->fragment_start [plane] + ystart * width;
- int stride = s->current_frame.linesize[plane];
- uint8_t *plane_data = s->current_frame.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 )
- {
- /* do not perform left edge filter for left columns frags */
- if (x > 0) {
- s->vp3dsp.h_loop_filter(
- 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,
- stride, bounding_values);
- }
-
- /* do not perform right edge filter for right column
- * fragments or if right fragment neighbor is also coded
- * in this frame (it will be filtered in next iteration) */
- if ((x < width - 1) &&
- (s->all_fragments[fragment + 1].coding_method == MODE_COPY)) {
- s->vp3dsp.h_loop_filter(
- plane_data + 8*x + 8,
- stride, bounding_values);
- }
-
- /* do not perform bottom edge filter for bottom row
- * fragments or if bottom fragment neighbor is also coded
- * in this frame (it will be filtered in the next row) */
- if ((y < height - 1) &&
- (s->all_fragments[fragment + width].coding_method == MODE_COPY)) {
- s->vp3dsp.v_loop_filter(
- plane_data + 8*x + 8*stride,
- stride, bounding_values);
- }
- }
-
- fragment++;
- }
- plane_data += 8*stride;
- }
-}
-
-/**
- * Pull DCT tokens from the 64 levels to decode and dequant the coefficients
- * for the next block in coding order
- */
-static inline int vp3_dequant(Vp3DecodeContext *s, Vp3Fragment *frag,
- int plane, int inter, int16_t block[64])
-{
- int16_t *dequantizer = s->qmat[frag->qpi][inter][plane];
- uint8_t *perm = s->scantable.permutated;
- int i = 0;
-
- do {
- 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
- s->dct_tokens[plane][i]++;
- else
- *s->dct_tokens[plane][i] = token & ~3;
- goto end;
- case 1: // zero run
- s->dct_tokens[plane][i]++;
- i += (token >> 2) & 0x7f;
- if (i > 63) {
- av_log(s->avctx, AV_LOG_ERROR, "Coefficient index overflow\n");
- return i;
- }
- block[perm[i]] = (token >> 9) * dequantizer[perm[i]];
- i++;
- break;
- case 2: // coeff
- block[perm[i]] = (token >> 2) * dequantizer[perm[i]];
- s->dct_tokens[plane][i++]++;
- break;
- default: // shouldn't happen
- return i;
- }
- } while (i < 64);
- // return value is expected to be a valid level
- i--;
-end:
- // the actual DC+prediction is in the fragment structure
- block[0] = frag->dc * s->qmat[0][inter][plane][0];
- return i;
-}
-
-/**
- * called when all pixels up to row y are complete
- */
-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;
-
- // 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)
- return;
-
- h= y - s->last_slice_end;
- s->last_slice_end= y;
- y -= h;
-
- if (!s->flipped_image) {
- y = s->avctx->height - y - h;
- }
-
- cy = y >> s->chroma_y_shift;
- offset[0] = s->current_frame.linesize[0]*y;
- offset[1] = s->current_frame.linesize[1]*cy;
- offset[2] = s->current_frame.linesize[2]*cy;
- for (i = 3; i < AV_NUM_DATA_POINTERS; i++)
- offset[i] = 0;
-
- emms_c();
- s->avctx->draw_horiz_band(s->avctx, &s->current_frame, offset, y, 3, h);
-}
-
-/**
- * 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)
-{
- AVFrame *ref_frame;
- int ref_row;
- int border = motion_y&1;
-
- if (fragment->coding_method == MODE_USING_GOLDEN ||
- fragment->coding_method == MODE_GOLDEN_MV)
- ref_frame = &s->golden_frame;
- else
- ref_frame = &s->last_frame;
-
- 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);
-}
-
-/*
- * Perform the final rendering for a particular slice of data.
- * The slice number ranges from 0..(c_superblock_height - 1).
- */
-static void render_slice(Vp3DecodeContext *s, int slice)
-{
- int x, y, i, j, fragment;
- int16_t *block = s->block;
- int motion_x = 0xdeadbeef, motion_y = 0xdeadbeef;
- int motion_halfpel_index;
- uint8_t *motion_source;
- int plane, first_pixel;
-
- if (slice >= s->c_superblock_height)
- return;
-
- for (plane = 0; plane < 3; plane++) {
- uint8_t *output_plane = s->current_frame.data [plane] + s->data_offset[plane];
- uint8_t * last_plane = s-> last_frame.data [plane] + s->data_offset[plane];
- uint8_t *golden_plane = s-> golden_frame.data [plane] + s->data_offset[plane];
- int stride = s->current_frame.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;
-
- i = fragment_start + fragment;
-
- // bounds check
- 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, 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->dsp.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);
- }
- }
-
- /* 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);
- } else {
- s->vp3dsp.idct_dc_add(output_plane + first_pixel, stride, block);
- }
- }
- } else {
-
- /* copy directly from the previous frame */
- s->dsp.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));
- }
- }
-
- /* 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));
-}
-
-/// Allocate tables for per-frame data in Vp3DecodeContext
-static av_cold int allocate_tables(AVCodecContext *avctx)
-{
- Vp3DecodeContext *s = avctx->priv_data;
- int y_fragment_count, c_fragment_count;
-
- y_fragment_count = s->fragment_width[0] * s->fragment_height[0];
- c_fragment_count = s->fragment_width[1] * s->fragment_height[1];
-
- s->superblock_coding = av_malloc(s->superblock_count);
- s->all_fragments = av_malloc(s->fragment_count * sizeof(Vp3Fragment));
- s->coded_fragment_list[0] = av_malloc(s->fragment_count * sizeof(int));
- s->dct_tokens_base = av_malloc(64*s->fragment_count * sizeof(*s->dct_tokens_base));
- s->motion_val[0] = av_malloc(y_fragment_count * sizeof(*s->motion_val[0]));
- s->motion_val[1] = av_malloc(c_fragment_count * sizeof(*s->motion_val[1]));
-
- /* work out the block mapping tables */
- s->superblock_fragments = av_malloc(s->superblock_count * 16 * sizeof(int));
- s->macroblock_coding = av_malloc(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]) {
- vp3_decode_end(avctx);
- return -1;
- }
-
- init_block_mapping(s);
-
- return 0;
-}
-
-static av_cold int vp3_decode_init(AVCodecContext *avctx)
-{
- Vp3DecodeContext *s = avctx->priv_data;
- int i, inter, plane;
- int c_width;
- int c_height;
- int y_fragment_count, c_fragment_count;
-
- 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->height = FFALIGN(avctx->height, 16);
- if (avctx->codec_id != AV_CODEC_ID_THEORA)
- avctx->pix_fmt = AV_PIX_FMT_YUV420P;
- avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
- ff_dsputil_init(&s->dsp, avctx);
- ff_videodsp_init(&s->vdsp, 8);
- ff_vp3dsp_init(&s->vp3dsp, avctx->flags);
-
- ff_init_scantable_permutation(s->dsp.idct_permutation, s->vp3dsp.idct_perm);
- ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct);
-
- /* initialize to an impossible value which will force a recalculation
- * in the first frame decode */
- for (i = 0; i < 3; i++)
- s->qps[i] = -1;
-
- 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_height = (s->height + 31) / 32;
- 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;
- s->c_superblock_height = (c_height + 31) / 32;
- 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->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_height = (s->height + 15) / 16;
- s->macroblock_count = s->macroblock_width * s->macroblock_height;
-
- 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_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_start[1] = y_fragment_count;
- s->fragment_start[2] = y_fragment_count + c_fragment_count;
-
- 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];
- }
-
- 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);
-
- /* 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);
-
- /* 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);
-
- /* 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);
-
- /* 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);
- }
- } 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)
- 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)
- 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)
- 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)
- 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)
- 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);
-
- 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);
-
- 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);
-
- 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);
-
- for (i = 0; i < 3; i++) {
- s->current_frame.data[i] = NULL;
- s->last_frame.data[i] = NULL;
- s->golden_frame.data[i] = NULL;
- }
-
- return allocate_tables(avctx);
-
-vlc_fail:
- av_log(avctx, AV_LOG_FATAL, "Invalid huffman table\n");
- return -1;
-}
-
-/// Release and shuffle frames after decode finishes
-static void update_frames(AVCodecContext *avctx)
-{
- Vp3DecodeContext *s = avctx->priv_data;
-
- /* release the last frame, if it is allocated and if it is not the
- * golden frame */
- if (s->last_frame.data[0] && s->last_frame.type != FF_BUFFER_TYPE_COPY)
- ff_thread_release_buffer(avctx, &s->last_frame);
-
- /* shuffle frames (last = current) */
- s->last_frame= s->current_frame;
-
- if (s->keyframe) {
- if (s->golden_frame.data[0])
- ff_thread_release_buffer(avctx, &s->golden_frame);
- s->golden_frame = s->current_frame;
- s->last_frame.type = FF_BUFFER_TYPE_COPY;
- }
-
- s->current_frame.data[0]= NULL; /* ensure that we catch any access to this released frame */
-}
-
-static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
-{
- 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)
-
- if (!s1->current_frame.data[0]
- ||s->width != s1->width
- ||s->height!= s1->height) {
- if (s != s1)
- copy_fields(s, s1, golden_frame, keyframe);
- return -1;
- }
-
- if (s != s1) {
- // init tables if the first frame hasn't been decoded
- if (!s->current_frame.data[0]) {
- int y_fragment_count, c_fragment_count;
- s->avctx = dst;
- err = allocate_tables(dst);
- if (err)
- 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]));
- }
-
- // copy previous frame data
- copy_fields(s, s1, golden_frame, dsp);
-
- // copy qscale data if necessary
- for (i = 0; i < 3; i++) {
- if (s->qps[i] != s1->qps[1]) {
- qps_changed = 1;
- memcpy(&s->qmat[i], &s1->qmat[i], sizeof(s->qmat[i]));
- }
- }
-
- if (s->qps[0] != s1->qps[0])
- memcpy(&s->bounding_values_array, &s1->bounding_values_array, sizeof(s->bounding_values_array));
-
- if (qps_changed)
- copy_fields(s, s1, qps, superblock_count);
-#undef copy_fields
- }
-
- update_frames(dst);
-
- return 0;
-}
-
-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;
- Vp3DecodeContext *s = avctx->priv_data;
- GetBitContext gb;
- int i;
- int ret;
-
- init_get_bits(&gb, buf, buf_size * 8);
-
-#if CONFIG_THEORA_DECODER
- if (s->theora && get_bits1(&gb))
- {
- int type = get_bits(&gb, 7);
- skip_bits_long(&gb, 6*8); /* "theora" */
-
- if (s->avctx->active_thread_type&FF_THREAD_FRAME) {
- av_log(avctx, AV_LOG_ERROR, "midstream reconfiguration with multithreading is unsupported, try -threads 1\n");
- return AVERROR_PATCHWELCOME;
- }
- if (type == 0) {
- vp3_decode_end(avctx);
- ret = theora_decode_header(avctx, &gb);
-
- if (ret < 0) {
- vp3_decode_end(avctx);
- } else
- ret = vp3_decode_init(avctx);
- return ret;
- } else if (type == 2) {
- ret = theora_decode_tables(avctx, &gb);
- if (ret < 0) {
- vp3_decode_end(avctx);
- } else
- ret = vp3_decode_init(avctx);
- return ret;
- }
-
- av_log(avctx, AV_LOG_ERROR, "Header packet passed to frame decoder, skipping\n");
- return -1;
- }
-#endif
-
- s->keyframe = !get_bits1(&gb);
- if (!s->all_fragments) {
- av_log(avctx, AV_LOG_ERROR, "Data packet without prior valid headers\n");
- return -1;
- }
- if (!s->theora)
- skip_bits(&gb, 1);
- 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));
- 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->skip_loop_filter = !s->filter_limit_values[s->qps[0]] ||
- avctx->skip_loop_filter >= (s->keyframe ? AVDISCARD_ALL : AVDISCARD_NONKEY);
-
- if (s->qps[0] != s->last_qps[0])
- init_loop_filter(s);
-
- for (i = 0; i < s->nqps; i++)
- // reinit all dequantizers if the first one changed, because
- // the DC of the first quantizer must be used for all matrices
- if (s->qps[i] != s->last_qps[i] || s->qps[0] != s->last_qps[0])
- init_dequantizer(s, i);
-
- if (avctx->skip_frame >= AVDISCARD_NONKEY && !s->keyframe)
- return buf_size;
-
- s->current_frame.reference = 3;
- s->current_frame.pict_type = s->keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
- s->current_frame.key_frame = s->keyframe;
- if (ff_thread_get_buffer(avctx, &s->current_frame) < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- goto error;
- }
-
- if (!s->edge_emu_buffer)
- s->edge_emu_buffer = av_malloc(9*FFABS(s->current_frame.linesize[0]));
-
- if (s->keyframe) {
- if (!s->theora)
- {
- skip_bits(&gb, 4); /* width code */
- skip_bits(&gb, 4); /* height code */
- 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);
- }
- }
- 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.data[0]) {
- av_log(s->avctx, AV_LOG_WARNING, "vp3: first frame not a keyframe\n");
-
- s->golden_frame.reference = 3;
- s->golden_frame.pict_type = AV_PICTURE_TYPE_I;
- if (ff_thread_get_buffer(avctx, &s->golden_frame) < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- goto error;
- }
- s->last_frame = s->golden_frame;
- s->last_frame.type = FF_BUFFER_TYPE_COPY;
- ff_thread_report_progress(&s->last_frame, INT_MAX, 0);
- }
- }
-
- memset(s->all_fragments, 0, s->fragment_count * sizeof(Vp3Fragment));
- ff_thread_finish_setup(avctx);
-
- if (unpack_superblocks(s, &gb)){
- av_log(s->avctx, AV_LOG_ERROR, "error in unpack_superblocks\n");
- goto error;
- }
- if (unpack_modes(s, &gb)){
- av_log(s->avctx, AV_LOG_ERROR, "error in unpack_modes\n");
- goto error;
- }
- 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)){
- av_log(s->avctx, AV_LOG_ERROR, "error in unpack_block_qpis\n");
- goto error;
- }
- if (unpack_dct_coeffs(s, &gb)){
- av_log(s->avctx, AV_LOG_ERROR, "error in unpack_dct_coeffs\n");
- goto error;
- }
-
- for (i = 0; i < 3; i++) {
- int height = s->height >> (i && s->chroma_y_shift);
- if (s->flipped_image)
- s->data_offset[i] = 0;
- else
- s->data_offset[i] = (height-1) * s->current_frame.linesize[i];
- }
-
- s->last_slice_end = 0;
- for (i = 0; i < s->c_superblock_height; i++)
- render_slice(s, i);
-
- // 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);
- }
- vp3_draw_horiz_band(s, s->avctx->height);
-
- *got_frame = 1;
- *(AVFrame*)data= s->current_frame;
-
- if (!HAVE_THREADS || !(s->avctx->active_thread_type&FF_THREAD_FRAME))
- update_frames(avctx);
-
- return buf_size;
-
-error:
- ff_thread_report_progress(&s->current_frame, INT_MAX, 0);
-
- if (!HAVE_THREADS || !(s->avctx->active_thread_type&FF_THREAD_FRAME))
- avctx->release_buffer(avctx, &s->current_frame);
-
- return -1;
-}
-
-static int read_huffman_tree(AVCodecContext *avctx, GetBitContext *gb)
-{
- Vp3DecodeContext *s = avctx->priv_data;
-
- if (get_bits1(gb)) {
- int token;
- if (s->entries >= 32) { /* overflow */
- av_log(avctx, AV_LOG_ERROR, "huffman tree overflow\n");
- return -1;
- }
- token = get_bits(gb, 5);
- av_dlog(avctx, "hti %d hbits %x token %d entry : %d size %d\n",
- s->hti, s->hbits, token, s->entries, s->huff_code_size);
- 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 */
- av_log(avctx, AV_LOG_ERROR, "huffman tree overflow\n");
- return -1;
- }
- s->huff_code_size++;
- s->hbits <<= 1;
- if (read_huffman_tree(avctx, gb))
- return -1;
- s->hbits |= 1;
- if (read_huffman_tree(avctx, gb))
- return -1;
- s->hbits >>= 1;
- s->huff_code_size--;
- }
- return 0;
-}
-
-static int vp3_init_thread_copy(AVCodecContext *avctx)
-{
- Vp3DecodeContext *s = avctx->priv_data;
-
- s->superblock_coding = NULL;
- s->all_fragments = NULL;
- s->coded_fragment_list[0] = NULL;
- s->dct_tokens_base = NULL;
- s->superblock_fragments = NULL;
- s->macroblock_coding = NULL;
- s->motion_val[0] = NULL;
- s->motion_val[1] = NULL;
- s->edge_emu_buffer = NULL;
-
- return 0;
-}
-
-#if CONFIG_THEORA_DECODER
-static const enum AVPixelFormat theora_pix_fmts[4] = {
- AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P
-};
-
-static int theora_decode_header(AVCodecContext *avctx, GetBitContext *gb)
-{
- Vp3DecodeContext *s = avctx->priv_data;
- int visible_width, visible_height, colorspace;
- int offset_x = 0, offset_y = 0;
- AVRational fps, aspect;
-
- 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)
- {
- s->flipped_image = 1;
- 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;
-
- if(av_image_check_size(s->width, s->height, 0, avctx)){
- av_log(avctx, AV_LOG_ERROR, "Invalid dimensions (%dx%d)\n", s->width, s->height);
- s->width= s->height= 0;
- return -1;
- }
-
- if (s->theora >= 0x030200) {
- visible_width = get_bits_long(gb, 24);
- visible_height = get_bits_long(gb, 24);
-
- offset_x = get_bits(gb, 8); /* offset x */
- offset_y = get_bits(gb, 8); /* offset y, from bottom */
- }
-
- fps.num = get_bits_long(gb, 32);
- fps.den = get_bits_long(gb, 32);
- if (fps.num && fps.den) {
- av_reduce(&avctx->time_base.num, &avctx->time_base.den,
- fps.den, fps.num, 1<<30);
- }
-
- aspect.num = get_bits_long(gb, 24);
- aspect.den = get_bits_long(gb, 24);
- if (aspect.num && aspect.den) {
- av_reduce(&avctx->sample_aspect_ratio.num,
- &avctx->sample_aspect_ratio.den,
- aspect.num, aspect.den, 1<<30);
- }
-
- if (s->theora < 0x030200)
- skip_bits(gb, 5); /* keyframe frequency force */
- colorspace = get_bits(gb, 8);
- skip_bits(gb, 24); /* bitrate */
-
- skip_bits(gb, 6); /* quality hint */
-
- 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) {
- av_log(avctx, AV_LOG_ERROR, "Invalid pixel format\n");
- return AVERROR_INVALIDDATA;
- }
- skip_bits(gb, 3); /* reserved */
- }
-
-// 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))
- avcodec_set_dimensions(avctx, visible_width, visible_height);
- else
- avcodec_set_dimensions(avctx, s->width, s->height);
-
- if (colorspace == 1) {
- avctx->color_primaries = AVCOL_PRI_BT470M;
- } 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;
- }
-
- return 0;
-}
-
-static int theora_decode_tables(AVCodecContext *avctx, GetBitContext *gb)
-{
- Vp3DecodeContext *s = avctx->priv_data;
- int i, n, matrices, inter, plane;
-
- if (s->theora >= 0x030200) {
- n = get_bits(gb, 3);
- /* loop filter limit values table */
- if (n)
- for (i = 0; i < 64; i++)
- s->filter_limit_values[i] = get_bits(gb, n);
- }
-
- if (s->theora >= 0x030200)
- n = get_bits(gb, 4) + 1;
- else
- n = 16;
- /* quality threshold table */
- for (i = 0; i < 64; i++)
- s->coded_ac_scale_factor[i] = get_bits(gb, n);
-
- if (s->theora >= 0x030200)
- n = get_bits(gb, 4) + 1;
- else
- n = 16;
- /* dc scale factor table */
- for (i = 0; i < 64; i++)
- s->coded_dc_scale_factor[i] = get_bits(gb, n);
-
- if (s->theora >= 0x030200)
- matrices = get_bits(gb, 9) + 1;
- else
- matrices = 3;
-
- if(matrices > 384){
- av_log(avctx, AV_LOG_ERROR, "invalid number of base matrixes\n");
- return -1;
- }
-
- for(n=0; n<matrices; n++){
- for (i = 0; i < 64; i++)
- s->base_matrix[n][i]= get_bits(gb, 8);
- }
-
- for (inter = 0; inter <= 1; inter++) {
- for (plane = 0; plane <= 2; plane++) {
- int newqr= 1;
- if (inter || plane > 0)
- newqr = get_bits1(gb);
- if (!newqr) {
- int qtj, plj;
- if(inter && get_bits1(gb)){
- qtj = 0;
- plj = plane;
- }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]));
- } 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");
- return -1;
- }
- 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;
- qi += i;
- }
-
- if (qi > 63) {
- av_log(avctx, AV_LOG_ERROR, "invalid qi %d > 63\n", qi);
- return -1;
- }
- s->qr_count[inter][plane]= qri;
- }
- }
- }
-
- /* Huffman tables */
- for (s->hti = 0; s->hti < 80; s->hti++) {
- s->entries = 0;
- s->huff_code_size = 1;
- if (!get_bits1(gb)) {
- s->hbits = 0;
- if(read_huffman_tree(avctx, gb))
- return -1;
- s->hbits = 1;
- if(read_huffman_tree(avctx, gb))
- return -1;
- }
- }
-
- s->theora_tables = 1;
-
- return 0;
-}
-
-static av_cold int theora_decode_init(AVCodecContext *avctx)
-{
- Vp3DecodeContext *s = avctx->priv_data;
- GetBitContext gb;
- int ptype;
- uint8_t *header_start[3];
- int header_len[3];
- int i;
-
- avctx->pix_fmt = AV_PIX_FMT_YUV420P;
-
- s->theora = 1;
-
- 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) {
- 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);
-
- ptype = get_bits(&gb, 8);
-
- 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" */
-
- switch(ptype)
- {
- case 0x80:
- if (theora_decode_header(avctx, &gb) < 0)
- return -1;
- break;
- case 0x81:
-// FIXME: is this needed? it breaks sometimes
-// theora_decode_comments(avctx, gb);
- break;
- case 0x82:
- if (theora_decode_tables(avctx, &gb))
- return -1;
- break;
- default:
- 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;
- }
-
- return vp3_decode_init(avctx);
-}
-
-AVCodec ff_theora_decoder = {
- .name = "theora",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_THEORA,
- .priv_data_size = sizeof(Vp3DecodeContext),
- .init = theora_decode_init,
- .close = vp3_decode_end,
- .decode = vp3_decode_frame,
- .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND |
- CODEC_CAP_FRAME_THREADS,
- .flush = vp3_decode_flush,
- .long_name = NULL_IF_CONFIG_SMALL("Theora"),
- .init_thread_copy = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy),
- .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context)
-};
-#endif
-
-AVCodec ff_vp3_decoder = {
- .name = "vp3",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_VP3,
- .priv_data_size = sizeof(Vp3DecodeContext),
- .init = vp3_decode_init,
- .close = vp3_decode_end,
- .decode = vp3_decode_frame,
- .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND |
- CODEC_CAP_FRAME_THREADS,
- .flush = vp3_decode_flush,
- .long_name = NULL_IF_CONFIG_SMALL("On2 VP3"),
- .init_thread_copy = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy),
- .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context),
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/vp3data.h b/src/thirdparty/ffmpeg/libavcodec/vp3data.h
deleted file mode 100644
index c5d148e45..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vp3data.h
+++ /dev/null
@@ -1,3181 +0,0 @@
-/*
- * copyright (C) 2003 the ffmpeg project
- *
- * 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_VP3DATA_H
-#define AVCODEC_VP3DATA_H
-
-#include <stdint.h>
-#include <stdlib.h>
-
-/* 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
-};
-
-/* 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
-};
-
-/* 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_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 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 },
-
- { 4, 3 }, { 5, 3 },
-
- { 0xC, 4 }, { 0xD, 4 },
-
- { 0x38, 6 }, { 0x39, 6 }, { 0x3A, 6 }, { 0x3B, 6 },
-
- { 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 },
-
- { 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 },
-
- /* 3 -> 4 */
- { 0x4, 3 }, { 0x5, 3 },
-
- /* 5 -> 6 */
- { 0xC, 4 }, { 0xD, 4 },
-
- /* 7 -> 10 */
- { 0x38, 6 }, { 0x39, 6 },
- { 0x3A, 6 }, { 0x3B, 6 },
-
- /* 11 -> 14 */
- { 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 }
-};
-
-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 }
-};
-
-static const uint8_t motion_vector_vlc_table[63][2] = {
- { 0, 3 },
- { 1, 3 },
- { 2, 3 },
-
- { 6, 4 }, { 7, 4 },
-
- { 8, 4 }, { 9, 4 },
-
- { 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 },
-
- { 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 }
-};
-
-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,
- 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
-};
-
-/* only tokens 0..6 indicate eob runs */
-static const int eob_run_base[7] = {
- 1, 2, 3, 4, 8, 16, 0
-};
-static const int eob_run_get_bits[7] = {
- 0, 0, 0, 2, 3, 4, 12
-};
-
-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 */
-};
-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 */
-};
-
-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 */
-};
-
-static const int16_t coeff_table_token_7_8[1] = { 0 };
-static const int16_t coeff_table_token_9[1] = { 1 };
-static const int16_t coeff_table_token_10[1] = { -1 };
-static const int16_t coeff_table_token_11[1] = { 2 };
-static const int16_t coeff_table_token_12[1] = { -2 };
-
-static const int16_t coeff_table_token_13[2] = { 3, -3 };
-static const int16_t coeff_table_token_14[2] = { 4, -4 };
-static const int16_t coeff_table_token_15[2] = { 5, -5 };
-static const int16_t coeff_table_token_16[2] = { 6, -6 };
-
-static const int16_t coeff_table_token_23_24_25_26_27_28_29[2] = { 1, -1 };
-static const int16_t coeff_table_token_30[4] = { 2, 3, -2, -3 };
-static const int16_t coeff_table_token_31[4] = { 2, 3, -2, -3 };
-
-static const int16_t coeff_table_token_17[4] = {
- 7, 8, -7, -8
-};
-
-static const int16_t coeff_table_token_18[8] = {
- 9, 10, 11, 12, -9, -10, -11, -12
-};
-
-static const int16_t coeff_table_token_19[16] = {
- 13, 14, 15, 16, 17, 18, 19, 20, -13, -14, -15, -16, -17, -18, -19, -20
-};
-
-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
-};
-
-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
-};
-
-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,
- -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
-};
-
-static const int16_t *const coeff_tables[32] = {
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- coeff_table_token_7_8,
-
- coeff_table_token_7_8,
- coeff_table_token_9,
- coeff_table_token_10,
- coeff_table_token_11,
- coeff_table_token_12,
- coeff_table_token_13,
- coeff_table_token_14,
- coeff_table_token_15,
-
- coeff_table_token_16,
- coeff_table_token_17,
- coeff_table_token_18,
- coeff_table_token_19,
- coeff_table_token_20,
- coeff_table_token_21,
- coeff_table_token_22,
- coeff_table_token_23_24_25_26_27_28_29,
-
- coeff_table_token_23_24_25_26_27_28_29,
- coeff_table_token_23_24_25_26_27_28_29,
- coeff_table_token_23_24_25_26_27_28_29,
- coeff_table_token_23_24_25_26_27_28_29,
- coeff_table_token_23_24_25_26_27_28_29,
- coeff_table_token_23_24_25_26_27_28_29,
- coeff_table_token_30,
- coeff_table_token_31
-};
-
-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 }
- }
-};
-
-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 }
- }
-};
-
-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 }
- }
-};
-
-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 }
- }
-};
-
-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 }
- }
-};
-
-#endif /* AVCODEC_VP3DATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/vp3dsp.c b/src/thirdparty/ffmpeg/libavcodec/vp3dsp.c
deleted file mode 100644
index 930f4b187..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vp3dsp.c
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- * Copyright (C) 2004 the ffmpeg project
- *
- * 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
- * Standard C DSP-oriented functions cribbed from the original VP3
- * source code.
- */
-
-#include "libavutil/attributes.h"
-#include "libavutil/common.h"
-#include "avcodec.h"
-#include "dsputil.h"
-#include "rnd_avg.h"
-#include "vp3dsp.h"
-
-#define IdctAdjustBeforeShift 8
-#define xC1S7 64277
-#define xC2S6 60547
-#define xC3S5 54491
-#define xC4S4 46341
-#define xC5S3 36410
-#define xC6S2 25080
-#define xC7S1 12785
-
-#define M(a,b) (((a) * (b))>>16)
-
-static av_always_inline void idct(uint8_t *dst, int stride, int16_t *input, int type)
-{
- int16_t *ip = input;
-
- int A, B, C, D, Ad, Bd, Cd, Dd, E, F, G, H;
- int Ed, Gd, Add, Bdd, Fd, Hd;
-
- int i;
-
- /* Inverse DCT on the rows now */
- for (i = 0; i < 8; i++) {
- /* Check for non-zero values */
- if ( ip[0] | 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]);
- D = M(xC3S5, ip[5]) - M(xC5S3, ip[3]);
-
- Ad = M(xC4S4, (A - C));
- Bd = M(xC4S4, (B - D));
-
- Cd = A + C;
- Dd = B + D;
-
- E = M(xC4S4, (ip[0] + ip[4]));
- F = M(xC4S4, (ip[0] - ip[4]));
-
- G = M(xC2S6, ip[2]) + M(xC6S2, ip[6]);
- H = M(xC6S2, ip[2]) - M(xC2S6, ip[6]);
-
- Ed = E - G;
- Gd = E + G;
-
- Add = F + Ad;
- Bdd = Bd - H;
-
- Fd = F - Ad;
- Hd = Bd + H;
-
- /* Final sequence of operations over-write original inputs. */
- ip[0] = Gd + Cd ;
- ip[7] = Gd - Cd ;
-
- ip[1] = Add + Hd;
- ip[2] = Add - Hd;
-
- ip[3] = Ed + Dd ;
- ip[4] = Ed - Dd ;
-
- ip[5] = Fd + Bdd;
- ip[6] = Fd - Bdd;
- }
-
- ip += 8; /* next row */
- }
-
- ip = input;
-
- for ( i = 0; i < 8; i++) {
- /* Check for non-zero values (bitwise or faster than ||) */
- if ( 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]);
- D = M(xC3S5, ip[5*8]) - M(xC5S3, ip[3*8]);
-
- Ad = M(xC4S4, (A - C));
- Bd = M(xC4S4, (B - D));
-
- Cd = A + C;
- Dd = B + D;
-
- E = M(xC4S4, (ip[0*8] + ip[4*8])) + 8;
- F = M(xC4S4, (ip[0*8] - ip[4*8])) + 8;
-
- if(type==1){ //HACK
- E += 16*128;
- F += 16*128;
- }
-
- G = M(xC2S6, ip[2*8]) + M(xC6S2, ip[6*8]);
- H = M(xC6S2, ip[2*8]) - M(xC2S6, ip[6*8]);
-
- Ed = E - G;
- Gd = E + G;
-
- Add = F + Ad;
- Bdd = Bd - H;
-
- Fd = F - Ad;
- Hd = Bd + H;
-
- /* Final sequence of operations over-write original inputs. */
- if(type==0){
- ip[0*8] = (Gd + Cd ) >> 4;
- ip[7*8] = (Gd - Cd ) >> 4;
-
- ip[1*8] = (Add + Hd ) >> 4;
- ip[2*8] = (Add - Hd ) >> 4;
-
- ip[3*8] = (Ed + Dd ) >> 4;
- ip[4*8] = (Ed - Dd ) >> 4;
-
- ip[5*8] = (Fd + Bdd ) >> 4;
- ip[6*8] = (Fd - Bdd ) >> 4;
- }else if(type==1){
- 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[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[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[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==0){
- ip[0*8] =
- ip[1*8] =
- ip[2*8] =
- ip[3*8] =
- ip[4*8] =
- ip[5*8] =
- ip[6*8] =
- ip[7*8] = ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20);
- }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*8] + (IdctAdjustBeforeShift<<16))>>20));
- }else{
- if(ip[0*8]){
- int v= ((xC4S4 * ip[0*8] + (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);
- }
- }
- }
-
- ip++; /* next column */
- dst++;
- }
-}
-
-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*/)
-{
- 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*/)
-{
- int i, dc = (block[0] + 15) >> 5;
-
- 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);
- dest[3] = av_clip_uint8(dest[3] + dc);
- dest[4] = av_clip_uint8(dest[4] + dc);
- 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;
- }
- block[0] = 0;
-}
-
-static void vp3_v_loop_filter_c(uint8_t *first_pixel, int stride,
- int *bounding_values)
-{
- unsigned char *end;
- int filter_value;
- 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]);
- 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);
- }
-}
-
-static void vp3_h_loop_filter_c(uint8_t *first_pixel, int stride,
- int *bounding_values)
-{
- 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]);
- 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);
- }
-}
-
-static void put_no_rnd_pixels_l2(uint8_t *dst, const uint8_t *src1,
- const uint8_t *src2, ptrdiff_t stride, int h)
-{
- int i;
-
- for (i = 0; i < h; i++) {
- uint32_t a, b;
-
- a = AV_RN32(&src1[i * stride]);
- b = AV_RN32(&src2[i * stride]);
- AV_WN32A(&dst[i * stride], no_rnd_avg32(a, b));
- a = AV_RN32(&src1[i * stride + 4]);
- b = AV_RN32(&src2[i * stride + 4]);
- AV_WN32A(&dst[i * stride + 4], no_rnd_avg32(a, b));
- }
-}
-
-av_cold void ff_vp3dsp_init(VP3DSPContext *c, int flags)
-{
- c->put_no_rnd_pixels_l2 = put_no_rnd_pixels_l2;
-
- c->idct_put = vp3_idct_put_c;
- c->idct_add = vp3_idct_add_c;
- c->idct_dc_add = vp3_idct_dc_add_c;
- c->v_loop_filter = vp3_v_loop_filter_c;
- c->h_loop_filter = vp3_h_loop_filter_c;
-
- c->idct_perm = FF_NO_IDCT_PERM;
-
- if (ARCH_ARM)
- ff_vp3dsp_init_arm(c, flags);
- if (ARCH_BFIN)
- ff_vp3dsp_init_bfin(c, flags);
- if (ARCH_PPC)
- ff_vp3dsp_init_ppc(c, flags);
- if (ARCH_X86)
- ff_vp3dsp_init_x86(c, flags);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/vp3dsp.h b/src/thirdparty/ffmpeg/libavcodec/vp3dsp.h
deleted file mode 100644
index e356e68b4..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vp3dsp.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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_VP3DSP_H
-#define AVCODEC_VP3DSP_H
-
-#include <stddef.h>
-#include <stdint.h>
-
-typedef struct VP3DSPContext {
- /**
- * Copy 8xH pixels from source to destination buffer using a bilinear
- * filter with no rounding (i.e. *dst = (*a + *b) >> 1).
- *
- * @param dst destination buffer, aligned by 8
- * @param a first source buffer, no alignment
- * @param b second source buffer, no alignment
- * @param stride distance between two lines in source/dest buffers
- * @param h height
- */
- void (*put_no_rnd_pixels_l2)(uint8_t *dst,
- const uint8_t *a,
- const uint8_t *b,
- ptrdiff_t stride, int h);
-
- void (*idct_put)(uint8_t *dest, int line_size, int16_t *block);
- void (*idct_add)(uint8_t *dest, int line_size, int16_t *block);
- void (*idct_dc_add)(uint8_t *dest, int line_size, int16_t *block);
- void (*v_loop_filter)(uint8_t *src, int stride, int *bounding_values);
- void (*h_loop_filter)(uint8_t *src, int stride, int *bounding_values);
-
- int idct_perm;
-} VP3DSPContext;
-
-void ff_vp3dsp_init(VP3DSPContext *c, int flags);
-void ff_vp3dsp_init_arm(VP3DSPContext *c, int flags);
-void ff_vp3dsp_init_bfin(VP3DSPContext *c, int flags);
-void ff_vp3dsp_init_ppc(VP3DSPContext *c, int flags);
-void ff_vp3dsp_init_x86(VP3DSPContext *c, int flags);
-
-#endif /* AVCODEC_VP3DSP_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/vp5.c b/src/thirdparty/ffmpeg/libavcodec/vp5.c
deleted file mode 100644
index b4ef09b7b..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vp5.c
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.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
- */
-
-/**
- * @file
- * VP5 compatible video decoder
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "avcodec.h"
-#include "dsputil.h"
-#include "get_bits.h"
-
-#include "vp56.h"
-#include "vp56data.h"
-#include "vp5data.h"
-
-
-static int vp5_parse_header(VP56Context *s, const uint8_t *buf, int buf_size)
-{
- VP56RangeCoder *c = &s->c;
- int rows, cols;
-
- ff_vp56_init_range_decoder(&s->c, buf, buf_size);
- s->framep[VP56_FRAME_CURRENT]->key_frame = !vp56_rac_get(c);
- vp56_rac_get(c);
- ff_vp56_init_dequant(s, vp56_rac_gets(c, 6));
- if (s->framep[VP56_FRAME_CURRENT]->key_frame)
- {
- vp56_rac_gets(c, 8);
- if(vp56_rac_gets(c, 5) > 5)
- return AVERROR_INVALIDDATA;
- vp56_rac_gets(c, 2);
- if (vp56_rac_get(c)) {
- av_log(s->avctx, AV_LOG_ERROR, "interlacing not supported\n");
- return AVERROR_PATCHWELCOME;
- }
- rows = vp56_rac_gets(c, 8); /* number of stored macroblock rows */
- cols = vp56_rac_gets(c, 8); /* number of stored macroblock cols */
- if (!rows || !cols) {
- av_log(s->avctx, AV_LOG_ERROR, "Invalid size %dx%d\n",
- cols << 4, rows << 4);
- return AVERROR_INVALIDDATA;
- }
- vp56_rac_gets(c, 8); /* number of displayed macroblock rows */
- vp56_rac_gets(c, 8); /* number of displayed macroblock cols */
- vp56_rac_gets(c, 2);
- if (!s->macroblocks || /* first frame */
- 16*cols != s->avctx->coded_width ||
- 16*rows != s->avctx->coded_height) {
- avcodec_set_dimensions(s->avctx, 16*cols, 16*rows);
- return VP56_SIZE_CHANGE;
- }
- } else if (!s->macroblocks)
- return AVERROR_INVALIDDATA;
- return 0;
-}
-
-static void vp5_parse_vector_adjustment(VP56Context *s, VP56mv *vect)
-{
- VP56RangeCoder *c = &s->c;
- VP56Model *model = s->modelp;
- int comp, di;
-
- for (comp=0; comp<2; comp++) {
- int delta = 0;
- if (vp56_rac_get_prob(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;
- delta = vp56_rac_get_tree(c, ff_vp56_pva_tree,
- model->vector_pdv[comp]);
- delta = di | (delta << 2);
- delta = (delta ^ -sign) + sign;
- }
- if (!comp)
- vect->x = delta;
- else
- vect->y = delta;
- }
-}
-
-static void vp5_parse_vector_models(VP56Context *s)
-{
- VP56RangeCoder *c = &s->c;
- VP56Model *model = s->modelp;
- int comp, node;
-
- for (comp=0; comp<2; comp++) {
- if (vp56_rac_get_prob(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]))
- model->vector_sig[comp] = vp56_rac_gets_nn(c, 7);
- if (vp56_rac_get_prob(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]))
- 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]))
- model->vector_pdv[comp][node] = vp56_rac_gets_nn(c, 7);
-}
-
-static int vp5_parse_coeff_models(VP56Context *s)
-{
- VP56RangeCoder *c = &s->c;
- VP56Model *model = s->modelp;
- uint8_t def_prob[11];
- int node, cg, ctx;
- int ct; /* code type */
- int pt; /* plane type (0 for Y, 1 for U or V) */
-
- memset(def_prob, 0x80, sizeof(def_prob));
-
- for (pt=0; pt<2; pt++)
- for (node=0; node<11; node++)
- if (vp56_rac_get_prob(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->framep[VP56_FRAME_CURRENT]->key_frame) {
- model->coeff_dccv[pt][node] = def_prob[node];
- }
-
- 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, 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->framep[VP56_FRAME_CURRENT]->key_frame) {
- model->coeff_ract[pt][ct][cg][node] = def_prob[node];
- }
-
- /* coeff_dcct is a linear combination of coeff_dccv */
- for (pt=0; pt<2; pt++)
- for (ctx=0; ctx<36; ctx++)
- for (node=0; node<5; node++)
- model->coeff_dcct[pt][ctx][node] = av_clip(((model->coeff_dccv[pt][node] * vp5_dccv_lc[node][ctx][0] + 128) >> 8) + vp5_dccv_lc[node][ctx][1], 1, 254);
-
- /* coeff_acct is a linear combination of coeff_ract */
- for (ct=0; ct<3; ct++)
- for (pt=0; pt<2; pt++)
- for (cg=0; cg<3; cg++)
- for (ctx=0; ctx<6; ctx++)
- for (node=0; node<5; node++)
- model->coeff_acct[pt][ct][cg][ctx][node] = av_clip(((model->coeff_ract[pt][ct][cg][node] * vp5_ract_lc[ct][cg][node][ctx][0] + 128) >> 8) + vp5_ract_lc[ct][cg][node][ctx][1], 1, 254);
- return 0;
-}
-
-static void vp5_parse_coeff(VP56Context *s)
-{
- VP56RangeCoder *c = &s->c;
- VP56Model *model = s->modelp;
- uint8_t *permute = s->scantable.permutated;
- uint8_t *model1, *model2;
- int coeff, sign, coeff_idx;
- int b, i, cg, idx, ctx, ctx_last;
- int pt = 0; /* plane type (0 for Y, 1 for U or V) */
-
- for (b=0; b<6; b++) {
- int ct = 1; /* code type */
-
- if (b > 3) pt = 1;
-
- ctx = 6*s->coeff_ctx[ff_vp56_b6to4[b]][0]
- + s->above_blocks[s->above_block_idx[b]].not_null_dc;
- model1 = model->coeff_dccv[pt];
- model2 = model->coeff_dcct[pt][ctx];
-
- 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])) {
- 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);
- 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])) {
- coeff = 3 + vp56_rac_get_prob(c, model1[5]);
- s->coeff_ctx[ff_vp56_b6to4[b]][coeff_idx] = 3;
- } else {
- coeff = 2;
- s->coeff_ctx[ff_vp56_b6to4[b]][coeff_idx] = 2;
- }
- sign = vp56_rac_get(c);
- }
- ct = 2;
- } else {
- ct = 1;
- s->coeff_ctx[ff_vp56_b6to4[b]][coeff_idx] = 1;
- sign = vp56_rac_get(c);
- coeff = 1;
- }
- coeff = (coeff ^ -sign) + sign;
- if (coeff_idx)
- coeff *= s->dequant_ac;
- s->block_coeff[b][permute[coeff_idx]] = coeff;
- } else {
- if (ct && !vp56_rac_get_prob(c, model2[1]))
- break;
- ct = 0;
- s->coeff_ctx[ff_vp56_b6to4[b]][coeff_idx] = 0;
- }
- coeff_idx++;
- if (coeff_idx >= 64)
- break;
-
- cg = vp5_coeff_groups[coeff_idx];
- ctx = s->coeff_ctx[ff_vp56_b6to4[b]][coeff_idx];
- model1 = model->coeff_ract[pt][ct][cg];
- model2 = cg > 2 ? model1 : model->coeff_acct[pt][ct][cg][ctx];
- }
-
- ctx_last = FFMIN(s->coeff_ctx_last[ff_vp56_b6to4[b]], 24);
- s->coeff_ctx_last[ff_vp56_b6to4[b]] = coeff_idx;
- if (coeff_idx < ctx_last)
- for (i=coeff_idx; i<=ctx_last; i++)
- s->coeff_ctx[ff_vp56_b6to4[b]][i] = 5;
- s->above_blocks[s->above_block_idx[b]].not_null_dc = s->coeff_ctx[ff_vp56_b6to4[b]][0];
- }
-}
-
-static void vp5_default_models_init(VP56Context *s)
-{
- VP56Model *model = s->modelp;
- int i;
-
- for (i=0; i<2; i++) {
- model->vector_sig[i] = 0x80;
- model->vector_dct[i] = 0x80;
- model->vector_pdi[i][0] = 0x55;
- model->vector_pdi[i][1] = 0x80;
- }
- memcpy(model->mb_types_stats, ff_vp56_def_mb_types_stats, sizeof(model->mb_types_stats));
- memset(model->vector_pdv, 0x80, sizeof(model->vector_pdv));
-}
-
-static av_cold int vp5_decode_init(AVCodecContext *avctx)
-{
- VP56Context *s = avctx->priv_data;
-
- ff_vp56_init(avctx, 1, 0);
- s->vp56_coord_div = vp5_coord_div;
- s->parse_vector_adjustment = vp5_parse_vector_adjustment;
- s->parse_coeff = vp5_parse_coeff;
- s->default_models_init = vp5_default_models_init;
- s->parse_vector_models = vp5_parse_vector_models;
- s->parse_coeff_models = vp5_parse_coeff_models;
- s->parse_header = vp5_parse_header;
-
- return 0;
-}
-
-AVCodec ff_vp5_decoder = {
- .name = "vp5",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_VP5,
- .priv_data_size = sizeof(VP56Context),
- .init = vp5_decode_init,
- .close = ff_vp56_free,
- .decode = ff_vp56_decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("On2 VP5"),
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/vp56.c b/src/thirdparty/ffmpeg/libavcodec/vp56.c
deleted file mode 100644
index e1b93eff9..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vp56.c
+++ /dev/null
@@ -1,767 +0,0 @@
-/*
- * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.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
- */
-
-/**
- * @file
- * VP5 and VP6 compatible video decoder (common features)
- */
-
-#include "avcodec.h"
-#include "bytestream.h"
-#include "internal.h"
-#include "h264chroma.h"
-#include "vp56.h"
-#include "vp56data.h"
-
-
-void ff_vp56_init_dequant(VP56Context *s, int quantizer)
-{
- s->quantizer = quantizer;
- s->dequant_dc = vp56_dc_dequant[quantizer] << 2;
- s->dequant_ac = vp56_ac_dequant[quantizer] << 2;
- memset(s->qscale_table, quantizer, s->mb_width);
-}
-
-static int vp56_get_vectors_predictors(VP56Context *s, int row, int col,
- VP56Frame ref_frame)
-{
- int nb_pred = 0;
- VP56mv vect[2] = {{0,0}, {0,0}};
- int pos, offset;
- VP56mv mvp;
-
- for (pos=0; pos<12; pos++) {
- mvp.x = col + vp56_candidate_predictor_pos[pos][0];
- mvp.y = row + vp56_candidate_predictor_pos[pos][1];
- if (mvp.x < 0 || mvp.x >= s->mb_width ||
- mvp.y < 0 || mvp.y >= s->mb_height)
- continue;
- offset = mvp.x + s->mb_width*mvp.y;
-
- if (vp56_reference_frame[s->macroblocks[offset].type] != ref_frame)
- continue;
- if ((s->macroblocks[offset].mv.x == vect[0].x &&
- s->macroblocks[offset].mv.y == vect[0].y) ||
- (s->macroblocks[offset].mv.x == 0 &&
- s->macroblocks[offset].mv.y == 0))
- continue;
-
- vect[nb_pred++] = s->macroblocks[offset].mv;
- if (nb_pred > 1) {
- nb_pred = -1;
- break;
- }
- s->vector_candidate_pos = pos;
- }
-
- s->vector_candidate[0] = vect[0];
- s->vector_candidate[1] = vect[1];
-
- return nb_pred+1;
-}
-
-static void vp56_parse_mb_type_models(VP56Context *s)
-{
- VP56RangeCoder *c = &s->c;
- VP56Model *model = s->modelp;
- int i, ctx, type;
-
- for (ctx=0; ctx<3; ctx++) {
- if (vp56_rac_get_prob(c, 174)) {
- int idx = vp56_rac_gets(c, 4);
- memcpy(model->mb_types_stats[ctx],
- vp56_pre_def_mb_type_stats[idx][ctx],
- sizeof(model->mb_types_stats[ctx]));
- }
- if (vp56_rac_get_prob(c, 254)) {
- for (type=0; type<10; type++) {
- for(i=0; i<2; i++) {
- if (vp56_rac_get_prob(c, 205)) {
- int delta, sign = vp56_rac_get(c);
-
- delta = vp56_rac_get_tree(c, vp56_pmbtm_tree,
- vp56_mb_type_model_model);
- if (!delta)
- delta = 4 * vp56_rac_gets(c, 7);
- model->mb_types_stats[ctx][type][i] += (delta ^ -sign) + sign;
- }
- }
- }
- }
- }
-
- /* compute MB type probability tables based on previous MB type */
- for (ctx=0; ctx<3; ctx++) {
- int p[10];
-
- for (type=0; type<10; type++)
- p[type] = 100 * model->mb_types_stats[ctx][type][1];
-
- for (type=0; type<10; type++) {
- int p02, p34, p0234, p17, p56, p89, p5689, p156789;
-
- /* conservative MB type probability */
- model->mb_type[ctx][type][0] = 255 - (255 * model->mb_types_stats[ctx][type][0]) / (1 + model->mb_types_stats[ctx][type][0] + model->mb_types_stats[ctx][type][1]);
-
- p[type] = 0; /* same MB type => weight is null */
-
- /* binary tree parsing probabilities */
- p02 = p[0] + p[2];
- p34 = p[3] + p[4];
- p0234 = p02 + p34;
- p17 = p[1] + p[7];
- p56 = p[5] + p[6];
- p89 = p[8] + p[9];
- p5689 = p56 + p89;
- p156789 = p17 + p5689;
-
- model->mb_type[ctx][type][1] = 1 + 255 * p0234/(1+p0234+p156789);
- model->mb_type[ctx][type][2] = 1 + 255 * p02 / (1+p0234);
- model->mb_type[ctx][type][3] = 1 + 255 * p17 / (1+p156789);
- model->mb_type[ctx][type][4] = 1 + 255 * p[0] / (1+p02);
- model->mb_type[ctx][type][5] = 1 + 255 * p[3] / (1+p34);
- model->mb_type[ctx][type][6] = 1 + 255 * p[1] / (1+p17);
- model->mb_type[ctx][type][7] = 1 + 255 * p56 / (1+p5689);
- model->mb_type[ctx][type][8] = 1 + 255 * p[5] / (1+p56);
- model->mb_type[ctx][type][9] = 1 + 255 * p[8] / (1+p89);
-
- /* restore initial value */
- p[type] = 100 * model->mb_types_stats[ctx][type][1];
- }
- }
-}
-
-static VP56mb vp56_parse_mb_type(VP56Context *s,
- VP56mb prev_type, int ctx)
-{
- 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]))
- return prev_type;
- else
- return vp56_rac_get_tree(c, vp56_pmbt_tree, mb_type_model);
-}
-
-static void vp56_decode_4mv(VP56Context *s, int row, int col)
-{
- VP56mv mv = {0,0};
- int type[4];
- int b;
-
- /* parse each block type */
- for (b=0; b<4; b++) {
- type[b] = vp56_rac_gets(&s->c, 2);
- if (type[b])
- type[b]++; /* only returns 0, 2, 3 or 4 (all INTER_PF) */
- }
-
- /* get vectors */
- for (b=0; b<4; b++) {
- switch (type[b]) {
- case VP56_MB_INTER_NOVEC_PF:
- s->mv[b] = (VP56mv) {0,0};
- break;
- case VP56_MB_INTER_DELTA_PF:
- s->parse_vector_adjustment(s, &s->mv[b]);
- break;
- case VP56_MB_INTER_V1_PF:
- s->mv[b] = s->vector_candidate[0];
- break;
- case VP56_MB_INTER_V2_PF:
- s->mv[b] = s->vector_candidate[1];
- break;
- }
- mv.x += s->mv[b].x;
- mv.y += s->mv[b].y;
- }
-
- /* this is the one selected for the whole MB for prediction */
- s->macroblocks[row * s->mb_width + col].mv = s->mv[3];
-
- /* chroma vectors are average luma vectors */
- if (s->avctx->codec->id == AV_CODEC_ID_VP5) {
- s->mv[4].x = s->mv[5].x = RSHIFT(mv.x,2);
- s->mv[4].y = s->mv[5].y = RSHIFT(mv.y,2);
- } else {
- s->mv[4] = s->mv[5] = (VP56mv) {mv.x/4, mv.y/4};
- }
-}
-
-static VP56mb vp56_decode_mv(VP56Context *s, int row, int col)
-{
- VP56mv *mv, vect = {0,0};
- int ctx, b;
-
- ctx = vp56_get_vectors_predictors(s, row, col, VP56_FRAME_PREVIOUS);
- s->mb_type = vp56_parse_mb_type(s, s->mb_type, ctx);
- s->macroblocks[row * s->mb_width + col].type = s->mb_type;
-
- switch (s->mb_type) {
- case VP56_MB_INTER_V1_PF:
- mv = &s->vector_candidate[0];
- break;
-
- case VP56_MB_INTER_V2_PF:
- mv = &s->vector_candidate[1];
- break;
-
- case VP56_MB_INTER_V1_GF:
- vp56_get_vectors_predictors(s, row, col, VP56_FRAME_GOLDEN);
- mv = &s->vector_candidate[0];
- break;
-
- case VP56_MB_INTER_V2_GF:
- vp56_get_vectors_predictors(s, row, col, VP56_FRAME_GOLDEN);
- mv = &s->vector_candidate[1];
- break;
-
- case VP56_MB_INTER_DELTA_PF:
- s->parse_vector_adjustment(s, &vect);
- mv = &vect;
- break;
-
- case VP56_MB_INTER_DELTA_GF:
- vp56_get_vectors_predictors(s, row, col, VP56_FRAME_GOLDEN);
- s->parse_vector_adjustment(s, &vect);
- mv = &vect;
- break;
-
- case VP56_MB_INTER_4V:
- vp56_decode_4mv(s, row, col);
- return s->mb_type;
-
- default:
- mv = &vect;
- break;
- }
-
- s->macroblocks[row*s->mb_width + col].mv = *mv;
-
- /* same vector for all blocks */
- for (b=0; b<6; b++)
- s->mv[b] = *mv;
-
- return s->mb_type;
-}
-
-static void vp56_add_predictors_dc(VP56Context *s, VP56Frame ref_frame)
-{
- int idx = s->scantable.permutated[0];
- int b;
-
- for (b=0; b<6; b++) {
- VP56RefDc *ab = &s->above_blocks[s->above_block_idx[b]];
- VP56RefDc *lb = &s->left_block[ff_vp56_b6to4[b]];
- int count = 0;
- int dc = 0;
- int i;
-
- if (ref_frame == lb->ref_frame) {
- dc += lb->dc_coeff;
- count++;
- }
- if (ref_frame == ab->ref_frame) {
- dc += ab->dc_coeff;
- count++;
- }
- if (s->avctx->codec->id == AV_CODEC_ID_VP5)
- for (i=0; i<2; i++)
- if (count < 2 && ref_frame == ab[-1+2*i].ref_frame) {
- dc += ab[-1+2*i].dc_coeff;
- count++;
- }
- if (count == 0)
- dc = s->prev_dc[ff_vp56_b2p[b]][ref_frame];
- else if (count == 2)
- dc /= 2;
-
- s->block_coeff[b][idx] += dc;
- s->prev_dc[ff_vp56_b2p[b]][ref_frame] = s->block_coeff[b][idx];
- ab->dc_coeff = s->block_coeff[b][idx];
- ab->ref_frame = ref_frame;
- lb->dc_coeff = s->block_coeff[b][idx];
- lb->ref_frame = ref_frame;
- s->block_coeff[b][idx] *= s->dequant_dc;
- }
-}
-
-static void vp56_deblock_filter(VP56Context *s, uint8_t *yuv,
- int stride, int dx, int dy)
-{
- int t = vp56_filter_threshold[s->quantizer];
- if (dx) s->vp56dsp.edge_filter_hor(yuv + 10-dx , stride, t);
- if (dy) s->vp56dsp.edge_filter_ver(yuv + stride*(10-dy), stride, t);
-}
-
-static void vp56_mc(VP56Context *s, int b, int plane, uint8_t *src,
- int stride, int x, int y)
-{
- uint8_t *dst=s->framep[VP56_FRAME_CURRENT]->data[plane]+s->block_offset[b];
- uint8_t *src_block;
- int src_offset;
- int overlap_offset = 0;
- int mask = s->vp56_coord_div[b] - 1;
- int deblock_filtering = s->deblock_filtering;
- int dx;
- int dy;
-
- if (s->avctx->skip_loop_filter >= AVDISCARD_ALL ||
- (s->avctx->skip_loop_filter >= AVDISCARD_NONKEY
- && !s->framep[VP56_FRAME_CURRENT]->key_frame))
- deblock_filtering = 0;
-
- dx = s->mv[b].x / s->vp56_coord_div[b];
- dy = s->mv[b].y / s->vp56_coord_div[b];
-
- if (b >= 4) {
- x /= 2;
- y /= 2;
- }
- x += dx - 2;
- y += dy - 2;
-
- if (x<0 || x+12>=s->plane_width[plane] ||
- y<0 || y+12>=s->plane_height[plane]) {
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
- src + s->block_offset[b] + (dy-2)*stride + (dx-2),
- stride, 12, 12, x, y,
- s->plane_width[plane],
- s->plane_height[plane]);
- src_block = s->edge_emu_buffer;
- src_offset = 2 + 2*stride;
- } else if (deblock_filtering) {
- /* only need a 12x12 block, but there is no such dsp function, */
- /* so copy a 16x12 block */
- s->dsp.put_pixels_tab[0][0](s->edge_emu_buffer,
- src + s->block_offset[b] + (dy-2)*stride + (dx-2),
- stride, 12);
- src_block = s->edge_emu_buffer;
- src_offset = 2 + 2*stride;
- } else {
- src_block = src;
- src_offset = s->block_offset[b] + dy*stride + dx;
- }
-
- if (deblock_filtering)
- vp56_deblock_filter(s, src_block, stride, dx&7, dy&7);
-
- if (s->mv[b].x & mask)
- overlap_offset += (s->mv[b].x > 0) ? 1 : -1;
- if (s->mv[b].y & mask)
- overlap_offset += (s->mv[b].y > 0) ? stride : -stride;
-
- if (overlap_offset) {
- if (s->filter)
- s->filter(s, dst, src_block, src_offset, src_offset+overlap_offset,
- stride, s->mv[b], mask, s->filter_selection, b<4);
- else
- s->vp3dsp.put_no_rnd_pixels_l2(dst, src_block+src_offset,
- src_block+src_offset+overlap_offset,
- stride, 8);
- } else {
- s->dsp.put_pixels_tab[1][0](dst, src_block+src_offset, stride, 8);
- }
-}
-
-static void vp56_decode_mb(VP56Context *s, int row, int col, int is_alpha)
-{
- AVFrame *frame_current, *frame_ref;
- VP56mb mb_type;
- VP56Frame ref_frame;
- int b, ab, b_max, plane, off;
-
- if (s->framep[VP56_FRAME_CURRENT]->key_frame)
- mb_type = VP56_MB_INTRA;
- else
- mb_type = vp56_decode_mv(s, row, col);
- ref_frame = vp56_reference_frame[mb_type];
-
- s->parse_coeff(s);
-
- vp56_add_predictors_dc(s, ref_frame);
-
- frame_current = s->framep[VP56_FRAME_CURRENT];
- frame_ref = s->framep[ref_frame];
- if (mb_type != VP56_MB_INTRA && !frame_ref->data[0])
- return;
-
- ab = 6*is_alpha;
- b_max = 6 - 2*is_alpha;
-
- switch (mb_type) {
- case VP56_MB_INTRA:
- for (b=0; b<b_max; b++) {
- plane = ff_vp56_b2p[b+ab];
- s->vp3dsp.idct_put(frame_current->data[plane] + s->block_offset[b],
- s->stride[plane], s->block_coeff[b]);
- }
- break;
-
- case VP56_MB_INTER_NOVEC_PF:
- case VP56_MB_INTER_NOVEC_GF:
- for (b=0; b<b_max; b++) {
- plane = ff_vp56_b2p[b+ab];
- off = s->block_offset[b];
- s->dsp.put_pixels_tab[1][0](frame_current->data[plane] + off,
- frame_ref->data[plane] + off,
- s->stride[plane], 8);
- s->vp3dsp.idct_add(frame_current->data[plane] + off,
- s->stride[plane], s->block_coeff[b]);
- }
- break;
-
- case VP56_MB_INTER_DELTA_PF:
- case VP56_MB_INTER_V1_PF:
- case VP56_MB_INTER_V2_PF:
- case VP56_MB_INTER_DELTA_GF:
- case VP56_MB_INTER_4V:
- case VP56_MB_INTER_V1_GF:
- case VP56_MB_INTER_V2_GF:
- for (b=0; b<b_max; b++) {
- int x_off = b==1 || b==3 ? 8 : 0;
- int y_off = b==2 || b==3 ? 8 : 0;
- plane = ff_vp56_b2p[b+ab];
- vp56_mc(s, b, plane, frame_ref->data[plane], s->stride[plane],
- 16*col+x_off, 16*row+y_off);
- s->vp3dsp.idct_add(frame_current->data[plane] + s->block_offset[b],
- s->stride[plane], s->block_coeff[b]);
- }
- break;
- }
-
- if (is_alpha) {
- s->block_coeff[4][0] = 0;
- s->block_coeff[5][0] = 0;
- }
-}
-
-static int vp56_size_changed(VP56Context *s)
-{
- AVCodecContext *avctx = s->avctx;
- int stride = s->framep[VP56_FRAME_CURRENT]->linesize[0];
- int i;
-
- s->plane_width[0] = s->plane_width[3] = avctx->coded_width;
- s->plane_width[1] = s->plane_width[2] = avctx->coded_width/2;
- s->plane_height[0] = s->plane_height[3] = avctx->coded_height;
- s->plane_height[1] = s->plane_height[2] = avctx->coded_height/2;
-
- for (i=0; i<4; i++)
- s->stride[i] = s->flip * s->framep[VP56_FRAME_CURRENT]->linesize[i];
-
- s->mb_width = (avctx->coded_width +15) / 16;
- s->mb_height = (avctx->coded_height+15) / 16;
-
- if (s->mb_width > 1000 || s->mb_height > 1000) {
- avcodec_set_dimensions(avctx, 0, 0);
- av_log(avctx, AV_LOG_ERROR, "picture too big\n");
- return -1;
- }
-
- s->qscale_table = av_realloc(s->qscale_table, s->mb_width);
- s->above_blocks = av_realloc(s->above_blocks,
- (4*s->mb_width+6) * sizeof(*s->above_blocks));
- s->macroblocks = av_realloc(s->macroblocks,
- s->mb_width*s->mb_height*sizeof(*s->macroblocks));
- av_free(s->edge_emu_buffer_alloc);
- s->edge_emu_buffer_alloc = av_malloc(16*stride);
- s->edge_emu_buffer = s->edge_emu_buffer_alloc;
- if (s->flip < 0)
- s->edge_emu_buffer += 15 * stride;
-
- if (s->alpha_context)
- return vp56_size_changed(s->alpha_context);
-
- return 0;
-}
-
-static int ff_vp56_decode_mbs(AVCodecContext *avctx, void *, int, int);
-
-int ff_vp56_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
- AVPacket *avpkt)
-{
- const uint8_t *buf = avpkt->data;
- VP56Context *s = avctx->priv_data;
- AVFrame *p = 0;
- int remaining_buf_size = avpkt->size;
- int av_uninit(alpha_offset);
- int i, res;
-
- /* select a current frame from the unused frames */
- for (i = 0; i < 4; ++i) {
- if (!s->frames[i].data[0]) {
- p = &s->frames[i];
- break;
- }
- }
- av_assert0(p != 0);
- s->framep[VP56_FRAME_CURRENT] = p;
- if (s->alpha_context)
- s->alpha_context->framep[VP56_FRAME_CURRENT] = p;
-
- if (s->has_alpha) {
- if (remaining_buf_size < 3)
- return -1;
- alpha_offset = bytestream_get_be24(&buf);
- remaining_buf_size -= 3;
- if (remaining_buf_size < alpha_offset)
- return -1;
- }
-
- res = s->parse_header(s, buf, remaining_buf_size);
- if (res < 0)
- return res;
-
- if (res == VP56_SIZE_CHANGE) {
- for (i = 0; i < 4; i++) {
- if (s->frames[i].data[0])
- avctx->release_buffer(avctx, &s->frames[i]);
- }
- }
-
- p->reference = 3;
- if (ff_get_buffer(avctx, p) < 0) {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return -1;
- }
-
- if (res == VP56_SIZE_CHANGE) {
- if (vp56_size_changed(s)) {
- avctx->release_buffer(avctx, p);
- return -1;
- }
- }
-
- if (s->has_alpha) {
- int bak_w = avctx->width;
- int bak_h = avctx->height;
- int bak_cw = avctx->coded_width;
- int bak_ch = avctx->coded_height;
- buf += alpha_offset;
- remaining_buf_size -= alpha_offset;
-
- res = s->alpha_context->parse_header(s->alpha_context, buf, remaining_buf_size);
- if (res != 0) {
- if(res==VP56_SIZE_CHANGE) {
- av_log(avctx, AV_LOG_ERROR, "Alpha reconfiguration\n");
- avctx->width = bak_w;
- avctx->height = bak_h;
- avctx->coded_width = bak_cw;
- avctx->coded_height = bak_ch;
- }
- avctx->release_buffer(avctx, p);
- return -1;
- }
- }
-
- avctx->execute2(avctx, ff_vp56_decode_mbs, 0, 0, s->has_alpha + 1);
-
- /* release frames that aren't in use */
- for (i = 0; i < 4; ++i) {
- AVFrame *victim = &s->frames[i];
- if (!victim->data[0])
- continue;
- if (victim != s->framep[VP56_FRAME_PREVIOUS] &&
- victim != s->framep[VP56_FRAME_GOLDEN] &&
- (!s->has_alpha || victim != s->alpha_context->framep[VP56_FRAME_GOLDEN]))
- avctx->release_buffer(avctx, victim);
- }
-
- p->qstride = 0;
- p->qscale_table = s->qscale_table;
- p->qscale_type = FF_QSCALE_TYPE_VP56;
- *(AVFrame*)data = *p;
- *got_frame = 1;
-
- return avpkt->size;
-}
-
-static int ff_vp56_decode_mbs(AVCodecContext *avctx, void *data,
- int jobnr, int threadnr)
-{
- VP56Context *s0 = avctx->priv_data;
- int is_alpha = (jobnr == 1);
- VP56Context *s = is_alpha ? s0->alpha_context : s0;
- AVFrame *const p = s->framep[VP56_FRAME_CURRENT];
- int mb_row, mb_col, mb_row_flip, mb_offset = 0;
- int block, y, uv, stride_y, stride_uv;
-
- if (p->key_frame) {
- p->pict_type = AV_PICTURE_TYPE_I;
- s->default_models_init(s);
- for (block=0; block<s->mb_height*s->mb_width; block++)
- s->macroblocks[block].type = VP56_MB_INTRA;
- } else {
- p->pict_type = AV_PICTURE_TYPE_P;
- vp56_parse_mb_type_models(s);
- s->parse_vector_models(s);
- s->mb_type = VP56_MB_INTER_NOVEC_PF;
- }
-
- if (s->parse_coeff_models(s))
- goto next;
-
- memset(s->prev_dc, 0, sizeof(s->prev_dc));
- s->prev_dc[1][VP56_FRAME_CURRENT] = 128;
- s->prev_dc[2][VP56_FRAME_CURRENT] = 128;
-
- for (block=0; block < 4*s->mb_width+6; block++) {
- s->above_blocks[block].ref_frame = VP56_FRAME_NONE;
- s->above_blocks[block].dc_coeff = 0;
- s->above_blocks[block].not_null_dc = 0;
- }
- s->above_blocks[2*s->mb_width + 2].ref_frame = VP56_FRAME_CURRENT;
- s->above_blocks[3*s->mb_width + 4].ref_frame = VP56_FRAME_CURRENT;
-
- stride_y = p->linesize[0];
- stride_uv = p->linesize[1];
-
- if (s->flip < 0)
- mb_offset = 7;
-
- /* main macroblocks loop */
- for (mb_row=0; mb_row<s->mb_height; mb_row++) {
- if (s->flip < 0)
- mb_row_flip = s->mb_height - mb_row - 1;
- else
- mb_row_flip = mb_row;
-
- for (block=0; block<4; block++) {
- s->left_block[block].ref_frame = VP56_FRAME_NONE;
- s->left_block[block].dc_coeff = 0;
- s->left_block[block].not_null_dc = 0;
- }
- memset(s->coeff_ctx, 0, sizeof(s->coeff_ctx));
- memset(s->coeff_ctx_last, 24, sizeof(s->coeff_ctx_last));
-
- s->above_block_idx[0] = 1;
- s->above_block_idx[1] = 2;
- s->above_block_idx[2] = 1;
- s->above_block_idx[3] = 2;
- s->above_block_idx[4] = 2*s->mb_width + 2 + 1;
- s->above_block_idx[5] = 3*s->mb_width + 4 + 1;
-
- s->block_offset[s->frbi] = (mb_row_flip*16 + mb_offset) * stride_y;
- s->block_offset[s->srbi] = s->block_offset[s->frbi] + 8*stride_y;
- s->block_offset[1] = s->block_offset[0] + 8;
- s->block_offset[3] = s->block_offset[2] + 8;
- s->block_offset[4] = (mb_row_flip*8 + mb_offset) * stride_uv;
- s->block_offset[5] = s->block_offset[4];
-
- for (mb_col=0; mb_col<s->mb_width; mb_col++) {
- vp56_decode_mb(s, mb_row, mb_col, is_alpha);
-
- for (y=0; y<4; y++) {
- s->above_block_idx[y] += 2;
- s->block_offset[y] += 16;
- }
-
- for (uv=4; uv<6; uv++) {
- s->above_block_idx[uv] += 1;
- s->block_offset[uv] += 8;
- }
- }
- }
-
-next:
- if (p->key_frame || s->golden_frame) {
- s->framep[VP56_FRAME_GOLDEN] = p;
- }
-
- FFSWAP(AVFrame *, s->framep[VP56_FRAME_CURRENT],
- s->framep[VP56_FRAME_PREVIOUS]);
- return 0;
-}
-
-av_cold void ff_vp56_init(AVCodecContext *avctx, int flip, int has_alpha)
-{
- VP56Context *s = avctx->priv_data;
- ff_vp56_init_context(avctx, s, flip, has_alpha);
-}
-
-av_cold void ff_vp56_init_context(AVCodecContext *avctx, VP56Context *s,
- int flip, int has_alpha)
-{
- int i;
-
- s->avctx = avctx;
- avctx->pix_fmt = has_alpha ? AV_PIX_FMT_YUVA420P : AV_PIX_FMT_YUV420P;
-
- ff_dsputil_init(&s->dsp, avctx);
- ff_h264chroma_init(&s->h264chroma, 8);
- ff_videodsp_init(&s->vdsp, 8);
- ff_vp3dsp_init(&s->vp3dsp, avctx->flags);
- ff_vp56dsp_init(&s->vp56dsp, avctx->codec->id);
- ff_init_scantable_permutation(s->dsp.idct_permutation, s->vp3dsp.idct_perm);
- ff_init_scantable(s->dsp.idct_permutation, &s->scantable,ff_zigzag_direct);
-
- for (i=0; i<4; i++) {
- s->framep[i] = &s->frames[i];
- avcodec_get_frame_defaults(&s->frames[i]);
- }
- s->framep[VP56_FRAME_UNUSED] = s->framep[VP56_FRAME_GOLDEN];
- s->framep[VP56_FRAME_UNUSED2] = s->framep[VP56_FRAME_GOLDEN2];
- s->edge_emu_buffer_alloc = NULL;
-
- s->above_blocks = NULL;
- s->macroblocks = NULL;
- s->quantizer = -1;
- s->deblock_filtering = 1;
- s->golden_frame = 0;
-
- s->filter = NULL;
-
- s->has_alpha = has_alpha;
-
- s->modelp = &s->model;
-
- if (flip) {
- s->flip = -1;
- s->frbi = 2;
- s->srbi = 0;
- } else {
- s->flip = 1;
- s->frbi = 0;
- s->srbi = 2;
- }
-}
-
-av_cold int ff_vp56_free(AVCodecContext *avctx)
-{
- VP56Context *s = avctx->priv_data;
- return ff_vp56_free_context(s);
-}
-
-av_cold int ff_vp56_free_context(VP56Context *s)
-{
- AVCodecContext *avctx = s->avctx;
- int i;
-
- av_freep(&s->qscale_table);
- av_freep(&s->above_blocks);
- av_freep(&s->macroblocks);
- av_freep(&s->edge_emu_buffer_alloc);
- for (i = 0; i < 4; ++i) {
- if (s->frames[i].data[0])
- avctx->release_buffer(avctx, &s->frames[i]);
- }
- return 0;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/vp56.h b/src/thirdparty/ffmpeg/libavcodec/vp56.h
deleted file mode 100644
index c7d5ae714..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vp56.h
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.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
- */
-
-/**
- * @file
- * VP5 and VP6 compatible video decoder (common features)
- */
-
-#ifndef AVCODEC_VP56_H
-#define AVCODEC_VP56_H
-
-#include "vp56data.h"
-#include "dsputil.h"
-#include "get_bits.h"
-#include "bytestream.h"
-#include "h264chroma.h"
-#include "videodsp.h"
-#include "vp3dsp.h"
-#include "vp56dsp.h"
-
-typedef struct vp56_context VP56Context;
-
-typedef struct VP56mv {
- DECLARE_ALIGNED(4, int16_t, x);
- int16_t y;
-} VP56mv;
-
-#define VP56_SIZE_CHANGE 1
-
-typedef void (*VP56ParseVectorAdjustment)(VP56Context *s,
- VP56mv *vect);
-typedef void (*VP56Filter)(VP56Context *s, uint8_t *dst, uint8_t *src,
- int offset1, int offset2, int stride,
- VP56mv mv, int mask, int select, int luma);
-typedef void (*VP56ParseCoeff)(VP56Context *s);
-typedef void (*VP56DefaultModelsInit)(VP56Context *s);
-typedef void (*VP56ParseVectorModels)(VP56Context *s);
-typedef int (*VP56ParseCoeffModels)(VP56Context *s);
-typedef int (*VP56ParseHeader)(VP56Context *s, const uint8_t *buf,
- int buf_size);
-
-typedef struct VP56RangeCoder {
- int high;
- int bits; /* stored negated (i.e. negative "bits" is a positive number of
- bits left) in order to eliminate a negate in cache refilling */
- const uint8_t *buffer;
- const uint8_t *end;
- unsigned int code_word;
-} VP56RangeCoder;
-
-typedef struct VP56RefDc {
- uint8_t not_null_dc;
- VP56Frame ref_frame;
- int16_t dc_coeff;
-} VP56RefDc;
-
-typedef struct VP56Macroblock {
- uint8_t type;
- VP56mv mv;
-} VP56Macroblock;
-
-typedef struct VP56Model {
- uint8_t coeff_reorder[64]; /* used in vp6 only */
- uint8_t coeff_index_to_pos[64]; /* used in vp6 only */
- uint8_t vector_sig[2]; /* delta sign */
- uint8_t vector_dct[2]; /* delta coding types */
- uint8_t vector_pdi[2][2]; /* predefined delta init */
- uint8_t vector_pdv[2][7]; /* predefined delta values */
- uint8_t vector_fdv[2][8]; /* 8 bit delta value definition */
- uint8_t coeff_dccv[2][11]; /* DC coeff value */
- uint8_t coeff_ract[2][3][6][11]; /* Run/AC coding type and AC coeff value */
- uint8_t coeff_acct[2][3][3][6][5];/* vp5 only AC coding type for coding group < 3 */
- uint8_t coeff_dcct[2][36][5]; /* DC coeff coding type */
- uint8_t coeff_runv[2][14]; /* run value (vp6 only) */
- uint8_t mb_type[3][10][10]; /* model for decoding MB type */
- uint8_t mb_types_stats[3][10][2];/* contextual, next MB type stats */
-} VP56Model;
-
-struct vp56_context {
- AVCodecContext *avctx;
- DSPContext dsp;
- H264ChromaContext h264chroma;
- VideoDSPContext vdsp;
- VP3DSPContext vp3dsp;
- VP56DSPContext vp56dsp;
- ScanTable scantable;
- AVFrame frames[4];
- AVFrame *framep[6];
- uint8_t *edge_emu_buffer_alloc;
- uint8_t *edge_emu_buffer;
- VP56RangeCoder c;
- VP56RangeCoder cc;
- VP56RangeCoder *ccp;
- int sub_version;
-
- /* frame info */
- int golden_frame;
- int plane_width[4];
- int plane_height[4];
- int mb_width; /* number of horizontal MB */
- int mb_height; /* number of vertical MB */
- int block_offset[6];
-
- int quantizer;
- uint16_t dequant_dc;
- uint16_t dequant_ac;
- int8_t *qscale_table;
-
- /* DC predictors management */
- VP56RefDc *above_blocks;
- VP56RefDc left_block[4];
- int above_block_idx[6];
- int16_t prev_dc[3][3]; /* [plan][ref_frame] */
-
- /* blocks / macroblock */
- VP56mb mb_type;
- VP56Macroblock *macroblocks;
- DECLARE_ALIGNED(16, int16_t, block_coeff)[6][64];
-
- /* motion vectors */
- VP56mv mv[6]; /* vectors for each block in MB */
- VP56mv vector_candidate[2];
- int vector_candidate_pos;
-
- /* filtering hints */
- int filter_header; /* used in vp6 only */
- int deblock_filtering;
- int filter_selection;
- int filter_mode;
- int max_vector_length;
- int sample_variance_threshold;
-
- uint8_t coeff_ctx[4][64]; /* used in vp5 only */
- uint8_t coeff_ctx_last[4]; /* used in vp5 only */
-
- int has_alpha;
-
- /* upside-down flipping hints */
- int flip; /* are we flipping ? */
- int frbi; /* first row block index in MB */
- int srbi; /* second row block index in MB */
- int stride[4]; /* stride for each plan */
-
- const uint8_t *vp56_coord_div;
- VP56ParseVectorAdjustment parse_vector_adjustment;
- VP56Filter filter;
- VP56ParseCoeff parse_coeff;
- VP56DefaultModelsInit default_models_init;
- VP56ParseVectorModels parse_vector_models;
- VP56ParseCoeffModels parse_coeff_models;
- VP56ParseHeader parse_header;
-
- /* for "slice" parallelism between YUV and A */
- VP56Context *alpha_context;
-
- VP56Model *modelp;
- VP56Model model;
-
- /* huffman decoding */
- int use_huffman;
- GetBitContext gb;
- VLC dccv_vlc[2];
- VLC runv_vlc[2];
- VLC ract_vlc[2][3][6];
- unsigned int nb_null[2][2]; /* number of consecutive NULL DC/AC */
-};
-
-
-void ff_vp56_init(AVCodecContext *avctx, int flip, int has_alpha);
-void ff_vp56_init_context(AVCodecContext *avctx, VP56Context *s,
- int flip, int has_alpha);
-int ff_vp56_free(AVCodecContext *avctx);
-int ff_vp56_free_context(VP56Context *s);
-void ff_vp56_init_dequant(VP56Context *s, int quantizer);
-int ff_vp56_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
- AVPacket *avpkt);
-
-
-/**
- * vp56 specific range coder implementation
- */
-
-extern const uint8_t ff_vp56_norm_shift[256];
-void ff_vp56_init_range_decoder(VP56RangeCoder *c, const uint8_t *buf, int buf_size);
-
-static av_always_inline unsigned int vp56_rac_renorm(VP56RangeCoder *c)
-{
- int shift = ff_vp56_norm_shift[c->high];
- int bits = c->bits;
- unsigned int code_word = c->code_word;
-
- c->high <<= shift;
- code_word <<= shift;
- bits += shift;
- if(bits >= 0 && c->buffer < c->end) {
- code_word |= bytestream_get_be16(&c->buffer) << bits;
- bits -= 16;
- }
- c->bits = bits;
- return code_word;
-}
-
-#if ARCH_ARM
-#include "arm/vp56_arith.h"
-#elif ARCH_X86
-#include "x86/vp56_arith.h"
-#endif
-
-#ifndef vp56_rac_get_prob
-#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 low = 1 + (((c->high - 1) * prob) >> 8);
- unsigned int low_shift = low << 16;
- int bit = code_word >= low_shift;
-
- c->high = bit ? c->high - low : low;
- c->code_word = bit ? code_word - low_shift : code_word;
-
- return bit;
-}
-#endif
-
-#ifndef vp56_rac_get_prob_branchy
-// branchy variant, to be used where there's a branch based on the bit decoded
-static av_always_inline int vp56_rac_get_prob_branchy(VP56RangeCoder *c, int prob)
-{
- unsigned long code_word = vp56_rac_renorm(c);
- unsigned low = 1 + (((c->high - 1) * prob) >> 8);
- unsigned low_shift = low << 16;
-
- if (code_word >= low_shift) {
- c->high -= low;
- c->code_word = code_word - low_shift;
- return 1;
- }
-
- c->high = low;
- c->code_word = code_word;
- return 0;
-}
-#endif
-
-static av_always_inline int vp56_rac_get(VP56RangeCoder *c)
-{
- unsigned int code_word = vp56_rac_renorm(c);
- /* equiprobable */
- int low = (c->high + 1) >> 1;
- unsigned int low_shift = low << 16;
- int bit = code_word >= low_shift;
- if (bit) {
- c->high -= low;
- code_word -= low_shift;
- } else {
- c->high = low;
- }
-
- c->code_word = code_word;
- return bit;
-}
-
-// rounding is different than vp56_rac_get, is vp56_rac_get wrong?
-static av_always_inline int vp8_rac_get(VP56RangeCoder *c)
-{
- return vp56_rac_get_prob(c, 128);
-}
-
-static av_unused int vp56_rac_gets(VP56RangeCoder *c, int bits)
-{
- int value = 0;
-
- while (bits--) {
- value = (value << 1) | vp56_rac_get(c);
- }
-
- return value;
-}
-
-static av_unused int vp8_rac_get_uint(VP56RangeCoder *c, int bits)
-{
- int value = 0;
-
- while (bits--) {
- value = (value << 1) | vp8_rac_get(c);
- }
-
- return value;
-}
-
-// fixme: add 1 bit to all the calls to this?
-static av_unused int vp8_rac_get_sint(VP56RangeCoder *c, int bits)
-{
- int v;
-
- if (!vp8_rac_get(c))
- return 0;
-
- v = vp8_rac_get_uint(c, bits);
-
- if (vp8_rac_get(c))
- v = -v;
-
- return v;
-}
-
-// P(7)
-static av_unused int vp56_rac_gets_nn(VP56RangeCoder *c, int bits)
-{
- int v = vp56_rac_gets(c, 7) << 1;
- return v + !v;
-}
-
-static av_unused int vp8_rac_get_nn(VP56RangeCoder *c)
-{
- int v = vp8_rac_get_uint(c, 7) << 1;
- return v + !v;
-}
-
-static av_always_inline
-int vp56_rac_get_tree(VP56RangeCoder *c,
- const VP56Tree *tree,
- const uint8_t *probs)
-{
- while (tree->val > 0) {
- if (vp56_rac_get_prob(c, probs[tree->prob_idx]))
- tree += tree->val;
- else
- tree++;
- }
- return -tree->val;
-}
-
-// how probabilities are associated with decisions is different I think
-// well, the new scheme fits in the old but this way has one fewer branches per decision
-static av_always_inline int vp8_rac_get_tree(VP56RangeCoder *c, const int8_t (*tree)[2],
- const uint8_t *probs)
-{
- int i = 0;
-
- do {
- i = tree[i][vp56_rac_get_prob(c, probs[i])];
- } while (i > 0);
-
- return -i;
-}
-
-// DCTextra
-static av_always_inline int vp8_rac_get_coeff(VP56RangeCoder *c, const uint8_t *prob)
-{
- int v = 0;
-
- do {
- v = (v<<1) + vp56_rac_get_prob(c, *prob++);
- } while (*prob);
-
- return v;
-}
-
-#endif /* AVCODEC_VP56_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/vp56data.c b/src/thirdparty/ffmpeg/libavcodec/vp56data.c
deleted file mode 100644
index 21aec308a..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vp56data.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.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
- */
-
-/**
- * @file
- * VP5 and VP6 compatible video decoder (common data)
- */
-
-#include "vp56data.h"
-
-const uint8_t ff_vp56_b2p[] = { 0, 0, 0, 0, 1, 2, 3, 3, 3, 3 };
-const uint8_t ff_vp56_b6to4[] = { 0, 0, 1, 1, 2, 3 };
-
-const uint8_t ff_vp56_coeff_parse_table[6][11] = {
- { 159, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 145, 165, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 140, 148, 173, 0, 0, 0, 0, 0, 0, 0, 0 },
- { 135, 140, 155, 176, 0, 0, 0, 0, 0, 0, 0 },
- { 130, 134, 141, 157, 180, 0, 0, 0, 0, 0, 0 },
- { 129, 130, 133, 140, 153, 177, 196, 230, 243, 254, 254 },
-};
-
-const uint8_t ff_vp56_def_mb_types_stats[3][10][2] = {
- { { 69, 42 }, { 1, 2 }, { 1, 7 }, { 44, 42 }, { 6, 22 },
- { 1, 3 }, { 0, 2 }, { 1, 5 }, { 0, 1 }, { 0, 0 }, },
- { { 229, 8 }, { 1, 1 }, { 0, 8 }, { 0, 0 }, { 0, 0 },
- { 1, 2 }, { 0, 1 }, { 0, 0 }, { 1, 1 }, { 0, 0 }, },
- { { 122, 35 }, { 1, 1 }, { 1, 6 }, { 46, 34 }, { 0, 0 },
- { 1, 2 }, { 0, 1 }, { 0, 1 }, { 1, 1 }, { 0, 0 }, },
-};
-
-const VP56Tree ff_vp56_pva_tree[] = {
- { 8, 0},
- { 4, 1},
- { 2, 2}, {-0}, {-1},
- { 2, 3}, {-2}, {-3},
- { 4, 4},
- { 2, 5}, {-4}, {-5},
- { 2, 6}, {-6}, {-7},
-};
-
-const VP56Tree ff_vp56_pc_tree[] = {
- { 4, 6},
- { 2, 7}, {-0}, {-1},
- { 4, 8},
- { 2, 9}, {-2}, {-3},
- { 2,10}, {-4}, {-5},
-};
-
-const uint8_t ff_vp56_coeff_bias[] = { 0, 1, 2, 3, 4, 5, 7, 11, 19, 35, 67 };
-const uint8_t ff_vp56_coeff_bit_length[] = { 0, 1, 2, 3, 4, 10 };
diff --git a/src/thirdparty/ffmpeg/libavcodec/vp56data.h b/src/thirdparty/ffmpeg/libavcodec/vp56data.h
deleted file mode 100644
index 957788c1a..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vp56data.h
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.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
- */
-
-/**
- * @file
- * VP5 and VP6 compatible video decoder (common data)
- */
-
-#ifndef AVCODEC_VP56DATA_H
-#define AVCODEC_VP56DATA_H
-
-#include "libavutil/common.h"
-
-typedef enum {
- VP56_FRAME_NONE =-1,
- VP56_FRAME_CURRENT = 0,
- VP56_FRAME_PREVIOUS = 1,
- VP56_FRAME_GOLDEN = 2,
- VP56_FRAME_GOLDEN2 = 3,
- VP56_FRAME_UNUSED = 4,
- VP56_FRAME_UNUSED2 = 5,
-} VP56Frame;
-
-typedef enum {
- VP56_MB_INTER_NOVEC_PF = 0, /**< Inter MB, no vector, from previous frame */
- VP56_MB_INTRA = 1, /**< Intra MB */
- VP56_MB_INTER_DELTA_PF = 2, /**< Inter MB, above/left vector + delta, from previous frame */
- VP56_MB_INTER_V1_PF = 3, /**< Inter MB, first vector, from previous frame */
- VP56_MB_INTER_V2_PF = 4, /**< Inter MB, second vector, from previous frame */
- VP56_MB_INTER_NOVEC_GF = 5, /**< Inter MB, no vector, from golden frame */
- VP56_MB_INTER_DELTA_GF = 6, /**< Inter MB, above/left vector + delta, from golden frame */
- VP56_MB_INTER_4V = 7, /**< Inter MB, 4 vectors, from previous frame */
- VP56_MB_INTER_V1_GF = 8, /**< Inter MB, first vector, from golden frame */
- VP56_MB_INTER_V2_GF = 9, /**< Inter MB, second vector, from golden frame */
-} VP56mb;
-
-typedef struct VP56Tree {
- int8_t val;
- int8_t prob_idx;
-} VP56Tree;
-
-extern const uint8_t ff_vp56_b2p[];
-extern const uint8_t ff_vp56_b6to4[];
-extern const uint8_t ff_vp56_coeff_parse_table[6][11];
-extern const uint8_t ff_vp56_def_mb_types_stats[3][10][2];
-extern const VP56Tree ff_vp56_pva_tree[];
-extern const VP56Tree ff_vp56_pc_tree[];
-extern const uint8_t ff_vp56_coeff_bias[];
-extern const uint8_t ff_vp56_coeff_bit_length[];
-
-static const VP56Frame vp56_reference_frame[] = {
- VP56_FRAME_PREVIOUS, /* VP56_MB_INTER_NOVEC_PF */
- VP56_FRAME_CURRENT, /* VP56_MB_INTRA */
- VP56_FRAME_PREVIOUS, /* VP56_MB_INTER_DELTA_PF */
- VP56_FRAME_PREVIOUS, /* VP56_MB_INTER_V1_PF */
- VP56_FRAME_PREVIOUS, /* VP56_MB_INTER_V2_PF */
- VP56_FRAME_GOLDEN, /* VP56_MB_INTER_NOVEC_GF */
- VP56_FRAME_GOLDEN, /* VP56_MB_INTER_DELTA_GF */
- VP56_FRAME_PREVIOUS, /* VP56_MB_INTER_4V */
- VP56_FRAME_GOLDEN, /* VP56_MB_INTER_V1_GF */
- VP56_FRAME_GOLDEN, /* VP56_MB_INTER_V2_GF */
-};
-
-static const uint8_t vp56_ac_dequant[64] = {
- 94, 92, 90, 88, 86, 82, 78, 74,
- 70, 66, 62, 58, 54, 53, 52, 51,
- 50, 49, 48, 47, 46, 45, 44, 43,
- 42, 40, 39, 37, 36, 35, 34, 33,
- 32, 31, 30, 29, 28, 27, 26, 25,
- 24, 23, 22, 21, 20, 19, 18, 17,
- 16, 15, 14, 13, 12, 11, 10, 9,
- 8, 7, 6, 5, 4, 3, 2, 1,
-};
-
-static const uint8_t vp56_dc_dequant[64] = {
- 47, 47, 47, 47, 45, 43, 43, 43,
- 43, 43, 42, 41, 41, 40, 40, 40,
- 40, 35, 35, 35, 35, 33, 33, 33,
- 33, 32, 32, 32, 27, 27, 26, 26,
- 25, 25, 24, 24, 23, 23, 19, 19,
- 19, 19, 18, 18, 17, 16, 16, 16,
- 16, 16, 15, 11, 11, 11, 10, 10,
- 9, 8, 7, 5, 3, 3, 2, 2,
-};
-
-static const uint8_t vp56_pre_def_mb_type_stats[16][3][10][2] = {
- { { { 9, 15 }, { 32, 25 }, { 7, 19 }, { 9, 21 }, { 1, 12 },
- { 14, 12 }, { 3, 18 }, { 14, 23 }, { 3, 10 }, { 0, 4 }, },
- { { 41, 22 }, { 1, 0 }, { 1, 31 }, { 0, 0 }, { 0, 0 },
- { 0, 1 }, { 1, 7 }, { 0, 1 }, { 98, 25 }, { 4, 10 }, },
- { { 2, 3 }, { 2, 3 }, { 0, 2 }, { 0, 2 }, { 0, 0 },
- { 11, 4 }, { 1, 4 }, { 0, 2 }, { 3, 2 }, { 0, 4 }, }, },
- { { { 48, 39 }, { 1, 2 }, { 11, 27 }, { 29, 44 }, { 7, 27 },
- { 1, 4 }, { 0, 3 }, { 1, 6 }, { 1, 2 }, { 0, 0 }, },
- { { 123, 37 }, { 6, 4 }, { 1, 27 }, { 0, 0 }, { 0, 0 },
- { 5, 8 }, { 1, 7 }, { 0, 1 }, { 12, 10 }, { 0, 2 }, },
- { { 49, 46 }, { 3, 4 }, { 7, 31 }, { 42, 41 }, { 0, 0 },
- { 2, 6 }, { 1, 7 }, { 1, 4 }, { 2, 4 }, { 0, 1 }, }, },
- { { { 21, 32 }, { 1, 2 }, { 4, 10 }, { 32, 43 }, { 6, 23 },
- { 2, 3 }, { 1, 19 }, { 1, 6 }, { 12, 21 }, { 0, 7 }, },
- { { 26, 14 }, { 14, 12 }, { 0, 24 }, { 0, 0 }, { 0, 0 },
- { 55, 17 }, { 1, 9 }, { 0, 36 }, { 5, 7 }, { 1, 3 }, },
- { { 26, 25 }, { 1, 1 }, { 2, 10 }, { 67, 39 }, { 0, 0 },
- { 1, 1 }, { 0, 14 }, { 0, 2 }, { 31, 26 }, { 1, 6 }, }, },
- { { { 69, 83 }, { 0, 0 }, { 0, 2 }, { 10, 29 }, { 3, 12 },
- { 0, 1 }, { 0, 3 }, { 0, 3 }, { 2, 2 }, { 0, 0 }, },
- { { 209, 5 }, { 0, 0 }, { 0, 27 }, { 0, 0 }, { 0, 0 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 0 }, { 0, 0 }, },
- { { 103, 46 }, { 1, 2 }, { 2, 10 }, { 33, 42 }, { 0, 0 },
- { 1, 4 }, { 0, 3 }, { 0, 1 }, { 1, 3 }, { 0, 0 }, }, },
- { { { 11, 20 }, { 1, 4 }, { 18, 36 }, { 43, 48 }, { 13, 35 },
- { 0, 2 }, { 0, 5 }, { 3, 12 }, { 1, 2 }, { 0, 0 }, },
- { { 2, 5 }, { 4, 5 }, { 0, 121 }, { 0, 0 }, { 0, 0 },
- { 0, 3 }, { 2, 4 }, { 1, 4 }, { 2, 2 }, { 0, 1 }, },
- { { 14, 31 }, { 9, 13 }, { 14, 54 }, { 22, 29 }, { 0, 0 },
- { 2, 6 }, { 4, 18 }, { 6, 13 }, { 1, 5 }, { 0, 1 }, }, },
- { { { 70, 44 }, { 0, 1 }, { 2, 10 }, { 37, 46 }, { 8, 26 },
- { 0, 2 }, { 0, 2 }, { 0, 2 }, { 0, 1 }, { 0, 0 }, },
- { { 175, 5 }, { 0, 1 }, { 0, 48 }, { 0, 0 }, { 0, 0 },
- { 0, 2 }, { 0, 1 }, { 0, 2 }, { 0, 1 }, { 0, 0 }, },
- { { 85, 39 }, { 0, 0 }, { 1, 9 }, { 69, 40 }, { 0, 0 },
- { 0, 1 }, { 0, 3 }, { 0, 1 }, { 2, 3 }, { 0, 0 }, }, },
- { { { 8, 15 }, { 0, 1 }, { 8, 21 }, { 74, 53 }, { 22, 42 },
- { 0, 1 }, { 0, 2 }, { 0, 3 }, { 1, 2 }, { 0, 0 }, },
- { { 83, 5 }, { 2, 3 }, { 0, 102 }, { 0, 0 }, { 0, 0 },
- { 1, 3 }, { 0, 2 }, { 0, 1 }, { 0, 0 }, { 0, 0 }, },
- { { 31, 28 }, { 0, 0 }, { 3, 14 }, { 130, 34 }, { 0, 0 },
- { 0, 1 }, { 0, 3 }, { 0, 1 }, { 3, 3 }, { 0, 1 }, }, },
- { { { 141, 42 }, { 0, 0 }, { 1, 4 }, { 11, 24 }, { 1, 11 },
- { 0, 1 }, { 0, 1 }, { 0, 2 }, { 0, 0 }, { 0, 0 }, },
- { { 233, 6 }, { 0, 0 }, { 0, 8 }, { 0, 0 }, { 0, 0 },
- { 0, 1 }, { 0, 1 }, { 0, 0 }, { 0, 1 }, { 0, 0 }, },
- { { 171, 25 }, { 0, 0 }, { 1, 5 }, { 25, 21 }, { 0, 0 },
- { 0, 1 }, { 0, 1 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, }, },
- { { { 8, 19 }, { 4, 10 }, { 24, 45 }, { 21, 37 }, { 9, 29 },
- { 0, 3 }, { 1, 7 }, { 11, 25 }, { 0, 2 }, { 0, 1 }, },
- { { 34, 16 }, { 112, 21 }, { 1, 28 }, { 0, 0 }, { 0, 0 },
- { 6, 8 }, { 1, 7 }, { 0, 3 }, { 2, 5 }, { 0, 2 }, },
- { { 17, 21 }, { 68, 29 }, { 6, 15 }, { 13, 22 }, { 0, 0 },
- { 6, 12 }, { 3, 14 }, { 4, 10 }, { 1, 7 }, { 0, 3 }, }, },
- { { { 46, 42 }, { 0, 1 }, { 2, 10 }, { 54, 51 }, { 10, 30 },
- { 0, 2 }, { 0, 2 }, { 0, 1 }, { 0, 1 }, { 0, 0 }, },
- { { 159, 35 }, { 2, 2 }, { 0, 25 }, { 0, 0 }, { 0, 0 },
- { 3, 6 }, { 0, 5 }, { 0, 1 }, { 4, 4 }, { 0, 1 }, },
- { { 51, 39 }, { 0, 1 }, { 2, 12 }, { 91, 44 }, { 0, 0 },
- { 0, 2 }, { 0, 3 }, { 0, 1 }, { 2, 3 }, { 0, 1 }, }, },
- { { { 28, 32 }, { 0, 0 }, { 3, 10 }, { 75, 51 }, { 14, 33 },
- { 0, 1 }, { 0, 2 }, { 0, 1 }, { 1, 2 }, { 0, 0 }, },
- { { 75, 39 }, { 5, 7 }, { 2, 48 }, { 0, 0 }, { 0, 0 },
- { 3, 11 }, { 2, 16 }, { 1, 4 }, { 7, 10 }, { 0, 2 }, },
- { { 81, 25 }, { 0, 0 }, { 2, 9 }, { 106, 26 }, { 0, 0 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 1, 1 }, { 0, 0 }, }, },
- { { { 100, 46 }, { 0, 1 }, { 3, 9 }, { 21, 37 }, { 5, 20 },
- { 0, 1 }, { 0, 2 }, { 1, 2 }, { 0, 1 }, { 0, 0 }, },
- { { 212, 21 }, { 0, 1 }, { 0, 9 }, { 0, 0 }, { 0, 0 },
- { 1, 2 }, { 0, 2 }, { 0, 0 }, { 2, 2 }, { 0, 0 }, },
- { { 140, 37 }, { 0, 1 }, { 1, 8 }, { 24, 33 }, { 0, 0 },
- { 1, 2 }, { 0, 2 }, { 0, 1 }, { 1, 2 }, { 0, 0 }, }, },
- { { { 27, 29 }, { 0, 1 }, { 9, 25 }, { 53, 51 }, { 12, 34 },
- { 0, 1 }, { 0, 3 }, { 1, 5 }, { 0, 2 }, { 0, 0 }, },
- { { 4, 2 }, { 0, 0 }, { 0, 172 }, { 0, 0 }, { 0, 0 },
- { 0, 1 }, { 0, 2 }, { 0, 0 }, { 2, 0 }, { 0, 0 }, },
- { { 14, 23 }, { 1, 3 }, { 11, 53 }, { 90, 31 }, { 0, 0 },
- { 0, 3 }, { 1, 5 }, { 2, 6 }, { 1, 2 }, { 0, 0 }, }, },
- { { { 80, 38 }, { 0, 0 }, { 1, 4 }, { 69, 33 }, { 5, 16 },
- { 0, 1 }, { 0, 1 }, { 0, 0 }, { 0, 1 }, { 0, 0 }, },
- { { 187, 22 }, { 1, 1 }, { 0, 17 }, { 0, 0 }, { 0, 0 },
- { 3, 6 }, { 0, 4 }, { 0, 1 }, { 4, 4 }, { 0, 1 }, },
- { { 123, 29 }, { 0, 0 }, { 1, 7 }, { 57, 30 }, { 0, 0 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 0 }, }, },
- { { { 16, 20 }, { 0, 0 }, { 2, 8 }, { 104, 49 }, { 15, 33 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 1, 1 }, { 0, 0 }, },
- { { 133, 6 }, { 1, 2 }, { 1, 70 }, { 0, 0 }, { 0, 0 },
- { 0, 2 }, { 0, 4 }, { 0, 3 }, { 1, 1 }, { 0, 0 }, },
- { { 13, 14 }, { 0, 0 }, { 4, 20 }, { 175, 20 }, { 0, 0 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 1, 1 }, { 0, 0 }, }, },
- { { { 194, 16 }, { 0, 0 }, { 1, 1 }, { 1, 9 }, { 1, 3 },
- { 0, 0 }, { 0, 1 }, { 0, 1 }, { 0, 0 }, { 0, 0 }, },
- { { 251, 1 }, { 0, 0 }, { 0, 2 }, { 0, 0 }, { 0, 0 },
- { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, },
- { { 202, 23 }, { 0, 0 }, { 1, 3 }, { 2, 9 }, { 0, 0 },
- { 0, 1 }, { 0, 1 }, { 0, 1 }, { 0, 0 }, { 0, 0 }, }, },
-};
-
-static const uint8_t vp56_filter_threshold[] = {
- 14, 14, 13, 13, 12, 12, 10, 10,
- 10, 10, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 8, 8, 8, 7, 7, 7, 7,
- 7, 7, 6, 6, 6, 6, 6, 6,
- 5, 5, 5, 5, 4, 4, 4, 4,
- 4, 4, 4, 3, 3, 3, 3, 2,
-};
-
-static const uint8_t vp56_mb_type_model_model[] = {
- 171, 83, 199, 140, 125, 104,
-};
-
-static const VP56Tree vp56_pmbtm_tree[] = {
- { 4, 0},
- { 2, 1}, {-8}, {-4},
- { 8, 2},
- { 6, 3},
- { 4, 4},
- { 2, 5}, {-24}, {-20}, {-16}, {-12}, {-0},
-};
-
-static const VP56Tree vp56_pmbt_tree[] = {
- { 8, 1},
- { 4, 2},
- { 2, 4}, {-VP56_MB_INTER_NOVEC_PF}, {-VP56_MB_INTER_DELTA_PF},
- { 2, 5}, {-VP56_MB_INTER_V1_PF}, {-VP56_MB_INTER_V2_PF},
- { 4, 3},
- { 2, 6}, {-VP56_MB_INTRA}, {-VP56_MB_INTER_4V},
- { 4, 7},
- { 2, 8}, {-VP56_MB_INTER_NOVEC_GF}, {-VP56_MB_INTER_DELTA_GF},
- { 2, 9}, {-VP56_MB_INTER_V1_GF}, {-VP56_MB_INTER_V2_GF},
-};
-
-/* relative pos of surrounding blocks, from closest to farthest */
-static const int8_t vp56_candidate_predictor_pos[12][2] = {
- { 0, -1 },
- { -1, 0 },
- { -1, -1 },
- { 1, -1 },
- { 0, -2 },
- { -2, 0 },
- { -2, -1 },
- { -1, -2 },
- { 1, -2 },
- { 2, -1 },
- { -2, -2 },
- { 2, -2 },
-};
-
-#endif /* AVCODEC_VP56DATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/vp56dsp.c b/src/thirdparty/ffmpeg/libavcodec/vp56dsp.c
deleted file mode 100644
index d1ed3bd3b..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vp56dsp.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2006 Aurelien Jacobs <aurel@gnuage.org>
- * 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 "avcodec.h"
-#include "vp56dsp.h"
-#include "libavutil/common.h"
-
-/* Gives very similar result than the vp6 version except in a few cases */
-static int vp5_adjust(int v, int t)
-{
- int s2, s1 = v >> 31;
- v ^= s1;
- v -= s1;
- v *= v < 2*t;
- v -= t;
- s2 = v >> 31;
- v ^= s2;
- v -= s2;
- v = t - v;
- v += s1;
- v ^= s1;
- return v;
-}
-
-static int vp6_adjust(int v, int t)
-{
- int V = v, s = v >> 31;
- V ^= s;
- V -= s;
- if (V-t-1 >= (unsigned)(t-1))
- return v;
- V = 2*t - V;
- V += s;
- V ^= s;
- return V;
-}
-
-
-#define VP56_EDGE_FILTER(pfx, suf, pix_inc, line_inc) \
-static void pfx##_edge_filter_##suf(uint8_t *yuv, int stride, int t) \
-{ \
- int pix2_inc = 2 * pix_inc; \
- int i, v; \
- \
- for (i=0; i<12; i++) { \
- v = (yuv[-pix2_inc] + 3*(yuv[0]-yuv[-pix_inc]) - yuv[pix_inc] + 4)>>3;\
- v = pfx##_adjust(v, t); \
- yuv[-pix_inc] = av_clip_uint8(yuv[-pix_inc] + v); \
- yuv[0] = av_clip_uint8(yuv[0] - v); \
- yuv += line_inc; \
- } \
-}
-
-VP56_EDGE_FILTER(vp5, hor, 1, stride)
-VP56_EDGE_FILTER(vp5, ver, stride, 1)
-VP56_EDGE_FILTER(vp6, hor, 1, stride)
-VP56_EDGE_FILTER(vp6, ver, stride, 1)
-
-void ff_vp56dsp_init(VP56DSPContext *s, enum AVCodecID codec)
-{
- if (codec == AV_CODEC_ID_VP5) {
- s->edge_filter_hor = vp5_edge_filter_hor;
- s->edge_filter_ver = vp5_edge_filter_ver;
- } else {
- s->edge_filter_hor = vp6_edge_filter_hor;
- s->edge_filter_ver = vp6_edge_filter_ver;
-
- if (CONFIG_VP6_DECODER) {
- s->vp6_filter_diag4 = ff_vp6_filter_diag4_c;
- }
- }
-
- if (ARCH_ARM) ff_vp56dsp_init_arm(s, codec);
- if (ARCH_X86) ff_vp56dsp_init_x86(s, codec);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/vp56dsp.h b/src/thirdparty/ffmpeg/libavcodec/vp56dsp.h
deleted file mode 100644
index 3c20925d8..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vp56dsp.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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
- */
-
-#ifndef AVCODEC_VP56DSP_H
-#define AVCODEC_VP56DSP_H
-
-#include <stdint.h>
-#include "avcodec.h"
-
-typedef struct VP56DSPContext {
- void (*edge_filter_hor)(uint8_t *yuv, int stride, int t);
- void (*edge_filter_ver)(uint8_t *yuv, int stride, int t);
-
- void (*vp6_filter_diag4)(uint8_t *dst, uint8_t *src, int stride,
- const int16_t *h_weights,const int16_t *v_weights);
-} VP56DSPContext;
-
-void ff_vp6_filter_diag4_c(uint8_t *dst, uint8_t *src, int stride,
- const int16_t *h_weights, const int16_t *v_weights);
-
-void ff_vp56dsp_init(VP56DSPContext *s, enum AVCodecID codec);
-void ff_vp56dsp_init_arm(VP56DSPContext *s, enum AVCodecID codec);
-void ff_vp56dsp_init_x86(VP56DSPContext* c, enum AVCodecID codec);
-
-#endif /* AVCODEC_VP56DSP_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/vp56rac.c b/src/thirdparty/ffmpeg/libavcodec/vp56rac.c
deleted file mode 100644
index 5faabf5d9..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vp56rac.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * VP5/6/8 decoder
- * Copyright (c) 2010 Jason Garrett-Glaser <darkshikari@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/common.h"
-#include "vp56.h"
-
-const uint8_t ff_vp56_norm_shift[256]= {
- 8,7,6,6,5,5,5,5,4,4,4,4,4,4,4,4,
- 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
- 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
- 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
- 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,
- 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,
-};
-
-void ff_vp56_init_range_decoder(VP56RangeCoder *c, const uint8_t *buf, int buf_size)
-{
- c->high = 255;
- c->bits = -16;
- c->buffer = buf;
- c->end = buf + buf_size;
- c->code_word = bytestream_get_be24(&c->buffer);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/vp5data.h b/src/thirdparty/ffmpeg/libavcodec/vp5data.h
deleted file mode 100644
index 23ba600b0..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vp5data.h
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.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
- */
-
-/**
- * @file
- * VP5 compatible video decoder
- */
-
-#ifndef AVCODEC_VP5DATA_H
-#define AVCODEC_VP5DATA_H
-
-#include <stdint.h>
-
-static const uint8_t vp5_coeff_groups[] = {
- -1, 0, 1, 1, 2, 1, 1, 2,
- 2, 1, 1, 2, 2, 2, 1, 2,
- 2, 2, 2, 2, 1, 1, 2, 2,
- 3, 3, 4, 3, 4, 4, 4, 3,
- 3, 3, 3, 3, 4, 3, 3, 3,
- 4, 4, 4, 4, 4, 3, 3, 4,
- 4, 4, 3, 4, 4, 4, 4, 4,
- 4, 4, 5, 5, 5, 5, 5, 5,
-};
-
-static const uint8_t vp5_vmc_pct[2][11] = {
- { 243, 220, 251, 253, 237, 232, 241, 245, 247, 251, 253 },
- { 235, 211, 246, 249, 234, 231, 248, 249, 252, 252, 254 },
-};
-
-static const uint8_t vp5_dccv_pct[2][11] = {
- { 146, 197, 181, 207, 232, 243, 238, 251, 244, 250, 249 },
- { 179, 219, 214, 240, 250, 254, 244, 254, 254, 254, 254 },
-};
-
-static const uint8_t vp5_ract_pct[3][2][6][11] = {
- { { { 227, 246, 230, 247, 244, 254, 254, 254, 254, 254, 254 },
- { 202, 254, 209, 231, 231, 249, 249, 253, 254, 254, 254 },
- { 206, 254, 225, 242, 241, 251, 253, 254, 254, 254, 254 },
- { 235, 254, 241, 253, 252, 254, 254, 254, 254, 254, 254 },
- { 234, 254, 248, 254, 254, 254, 254, 254, 254, 254, 254 },
- { 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254 } },
- { { 240, 254, 248, 254, 254, 254, 254, 254, 254, 254, 254 },
- { 238, 254, 240, 253, 254, 254, 254, 254, 254, 254, 254 },
- { 244, 254, 251, 254, 254, 254, 254, 254, 254, 254, 254 },
- { 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254 },
- { 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254 },
- { 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254 } } },
- { { { 206, 203, 227, 239, 247, 254, 253, 254, 254, 254, 254 },
- { 207, 199, 220, 236, 243, 252, 252, 254, 254, 254, 254 },
- { 212, 219, 230, 243, 244, 253, 252, 254, 254, 254, 254 },
- { 236, 237, 247, 252, 253, 254, 254, 254, 254, 254, 254 },
- { 240, 240, 248, 254, 254, 254, 254, 254, 254, 254, 254 },
- { 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254 } },
- { { 230, 233, 249, 254, 254, 254, 254, 254, 254, 254, 254 },
- { 238, 238, 250, 254, 254, 254, 254, 254, 254, 254, 254 },
- { 248, 251, 254, 254, 254, 254, 254, 254, 254, 254, 254 },
- { 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254 },
- { 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254 },
- { 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254 } } },
- { { { 225, 239, 227, 231, 244, 253, 243, 254, 254, 253, 254 },
- { 232, 234, 224, 228, 242, 249, 242, 252, 251, 251, 254 },
- { 235, 249, 238, 240, 251, 254, 249, 254, 253, 253, 254 },
- { 249, 253, 251, 250, 254, 254, 254, 254, 254, 254, 254 },
- { 251, 250, 249, 254, 254, 254, 254, 254, 254, 254, 254 },
- { 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254 } },
- { { 243, 244, 250, 250, 254, 254, 254, 254, 254, 254, 254 },
- { 249, 248, 250, 253, 254, 254, 254, 254, 254, 254, 254 },
- { 253, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254 },
- { 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254 },
- { 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254 },
- { 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254 } } },
-};
-
-static const int16_t vp5_dccv_lc[5][36][2] = {
- { {154, 61}, {141, 54}, { 90, 45}, { 54, 34}, { 54, 13}, {128, 109},
- {136, 54}, {148, 45}, { 92, 41}, { 54, 33}, { 51, 15}, { 87, 113},
- { 87, 44}, { 97, 40}, { 67, 36}, { 46, 29}, { 41, 15}, { 64, 80},
- { 59, 33}, { 61, 31}, { 51, 28}, { 44, 22}, { 33, 12}, { 49, 63},
- { 69, 12}, { 59, 16}, { 46, 14}, { 31, 13}, { 26, 6}, { 92, 26},
- {128, 108}, { 77, 119}, { 54, 84}, { 26, 71}, { 87, 19}, { 95, 155} },
- { {154, 4}, {182, 0}, {159, -8}, {128, -5}, {143, -5}, {187, 55},
- {182, 0}, {228, -3}, {187, -7}, {174, -9}, {189, -11}, {169, 79},
- {161, -9}, {192, -8}, {187, -9}, {169, -10}, {136, -9}, {184, 40},
- {164, -11}, {179, -10}, {174, -10}, {161, -10}, {115, -7}, {197, 20},
- {195, -11}, {195, -11}, {146, -10}, {110, -6}, { 95, -4}, {195, 39},
- {182, 55}, {172, 77}, {177, 37}, {169, 29}, {172, 52}, { 92, 162} },
- { {174, 80}, {164, 80}, { 95, 80}, { 46, 66}, { 56, 24}, { 36, 193},
- {164, 80}, {166, 77}, {105, 76}, { 49, 68}, { 46, 31}, { 49, 186},
- { 97, 78}, {110, 74}, { 72, 72}, { 44, 60}, { 33, 30}, { 69, 131},
- { 61, 61}, { 69, 63}, { 51, 57}, { 31, 48}, { 26, 27}, { 64, 89},
- { 67, 23}, { 51, 32}, { 36, 33}, { 26, 28}, { 20, 12}, { 44, 68},
- { 26, 197}, { 41, 189}, { 61, 129}, { 28, 103}, { 49, 52}, {-12, 245} },
- { {102, 141}, { 79, 166}, { 72, 162}, { 97, 125}, {179, 4}, {307, 0},
- { 72, 168}, { 69, 175}, { 84, 160}, {105, 127}, {148, 34}, {310, 0},
- { 84, 151}, { 82, 161}, { 87, 153}, { 87, 135}, {115, 51}, {317, 0},
- { 97, 125}, {102, 131}, {105, 125}, { 87, 122}, { 84, 64}, { 54, 184},
- {166, 18}, {146, 43}, {125, 51}, { 90, 64}, { 95, 7}, { 38, 154},
- {294, 0}, { 13, 225}, { 10, 225}, { 67, 168}, { 0, 167}, {161, 94} },
- { {172, 76}, {172, 75}, {136, 80}, { 64, 98}, { 74, 67}, {315, 0},
- {169, 76}, {207, 56}, {164, 66}, { 97, 80}, { 67, 72}, {328, 0},
- {136, 80}, {187, 53}, {154, 62}, { 72, 85}, { -2, 105}, {305, 0},
- { 74, 91}, {128, 64}, {113, 64}, { 61, 77}, { 41, 75}, {259, 0},
- { 46, 84}, { 51, 81}, { 28, 89}, { 31, 78}, { 23, 77}, {202, 0},
- {323, 0}, {323, 0}, {300, 0}, {236, 0}, {195, 0}, {328, 0} },
-};
-
-static const int16_t vp5_ract_lc[3][3][5][6][2] = {
- { { { {276, 0}, {238, 0}, {195, 0}, {156, 0}, {113, 0}, {274, 0} },
- { { 0, 1}, { 0, 1}, { 0, 1}, { 0, 1}, { 0, 1}, { 0, 1} },
- { {192, 59}, {182, 50}, {141, 48}, {110, 40}, { 92, 19}, {125,128} },
- { {169, 87}, {169, 83}, {184, 62}, {220, 16}, {184, 0}, {264, 0} },
- { {212, 40}, {212, 36}, {169, 49}, {174, 27}, { 8,120}, {182, 71} } },
- { { {259, 10}, {197, 19}, {143, 22}, {123, 16}, {110, 8}, {133, 88} },
- { { 0, 1}, {256, 0}, { 0, 1}, { 0, 1}, { 0, 1}, { 0, 1} },
- { {207, 46}, {187, 50}, { 97, 83}, { 23,100}, { 41, 56}, { 56,188} },
- { {166, 90}, {146,108}, {161, 88}, {136, 95}, {174, 0}, {266, 0} },
- { {264, 7}, {243, 18}, {184, 43}, {-14,154}, { 20,112}, { 20,199} } },
- { { {230, 26}, {197, 22}, {159, 20}, {146, 12}, {136, 4}, { 54,162} },
- { { 0, 1}, { 0, 1}, { 0, 1}, { 0, 1}, { 0, 1}, { 0, 1} },
- { {192, 59}, {156, 72}, { 84,101}, { 49,101}, { 79, 47}, { 79,167} },
- { {138,115}, {136,116}, {166, 80}, {238, 0}, {195, 0}, {261, 0} },
- { {225, 33}, {205, 42}, {159, 61}, { 79, 96}, { 92, 66}, { 28,195} } },
- }, {
- { { {200, 37}, {197, 18}, {159, 13}, {143, 7}, {102, 5}, {123,126} },
- { {197, 3}, {220, -9}, {210,-12}, {187, -6}, {151, -2}, {174, 80} },
- { {200, 53}, {187, 47}, {159, 40}, {118, 38}, {100, 18}, {141,111} },
- { {179, 78}, {166, 86}, {197, 50}, {207, 27}, {187, 0}, {115,139} },
- { {218, 34}, {220, 29}, {174, 46}, {128, 61}, { 54, 89}, {187, 65} } },
- { { {238, 14}, {197, 18}, {125, 26}, { 90, 25}, { 82, 13}, {161, 86} },
- { {189, 1}, {205, -2}, {156, -4}, {143, -4}, {146, -4}, {172, 72} },
- { {230, 31}, {192, 45}, {102, 76}, { 38, 85}, { 56, 41}, { 64,173} },
- { {166, 91}, {141,111}, {128,116}, {118,109}, {177, 0}, { 23,222} },
- { {253, 14}, {236, 21}, {174, 49}, { 33,118}, { 44, 93}, { 23,187} } },
- { { {218, 28}, {179, 28}, {118, 35}, { 95, 30}, { 72, 24}, {128,108} },
- { {187, 1}, {174, -1}, {125, -1}, {110, -1}, {108, -1}, {202, 52} },
- { {197, 53}, {146, 75}, { 46,118}, { 33,103}, { 64, 50}, {118,126} },
- { {138,114}, {128,122}, {161, 86}, {243, -6}, {195, 0}, { 38,210} },
- { {215, 39}, {179, 58}, { 97,101}, { 95, 85}, { 87, 70}, { 69,152} } },
- }, {
- { { {236, 24}, {205, 18}, {172, 12}, {154, 6}, {125, 1}, {169, 75} },
- { {187, 4}, {230, -2}, {228, -4}, {236, -4}, {241, -2}, {192, 66} },
- { {200, 46}, {187, 42}, {159, 34}, {136, 25}, {105, 10}, {179, 62} },
- { {207, 55}, {192, 63}, {192, 54}, {195, 36}, {177, 1}, {143, 98} },
- { {225, 27}, {207, 34}, {200, 30}, {131, 57}, { 97, 60}, {197, 45} } },
- { { {271, 8}, {218, 13}, {133, 19}, { 90, 19}, { 72, 7}, {182, 51} },
- { {179, 1}, {225, -1}, {154, -2}, {110, -1}, { 92, 0}, {195, 41} },
- { {241, 26}, {189, 40}, { 82, 64}, { 33, 60}, { 67, 17}, {120, 94} },
- { {192, 68}, {151, 94}, {146, 90}, {143, 72}, {161, 0}, {113,128} },
- { {256, 12}, {218, 29}, {166, 48}, { 44, 99}, { 31, 87}, {148, 78} } },
- { { {238, 20}, {184, 22}, {113, 27}, { 90, 22}, { 74, 9}, {192, 37} },
- { {184, 0}, {215, -1}, {141, -1}, { 97, 0}, { 49, 0}, {264, 13} },
- { {182, 51}, {138, 61}, { 95, 63}, { 54, 59}, { 64, 25}, {200, 45} },
- { {179, 75}, {156, 87}, {174, 65}, {177, 44}, {174, 0}, {164, 85} },
- { {195, 45}, {148, 65}, {105, 79}, { 95, 72}, { 87, 60}, {169, 63} } },
- }
-};
-
-static const uint8_t vp5_coord_div[] = { 2, 2, 2, 2, 4, 4 };
-
-#endif /* AVCODEC_VP5DATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/vp6.c b/src/thirdparty/ffmpeg/libavcodec/vp6.c
deleted file mode 100644
index a0f717c51..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vp6.c
+++ /dev/null
@@ -1,696 +0,0 @@
-/*
- * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.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
- */
-
-/**
- * @file
- * VP6 compatible video decoder
- *
- * The VP6F decoder accepts an optional 1 byte extradata. It is composed of:
- * - upper 4 bits: difference between encoded width and visible width
- * - lower 4 bits: difference between encoded height and visible height
- */
-
-#include <stdlib.h>
-
-#include "avcodec.h"
-#include "dsputil.h"
-#include "get_bits.h"
-#include "huffman.h"
-
-#include "vp56.h"
-#include "vp56data.h"
-#include "vp6data.h"
-
-#define VP6_MAX_HUFF_SIZE 12
-
-static void vp6_parse_coeff(VP56Context *s);
-static void vp6_parse_coeff_huffman(VP56Context *s);
-
-static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size)
-{
- VP56RangeCoder *c = &s->c;
- int parse_filter_info = 0;
- int coeff_offset = 0;
- int vrt_shift = 0;
- int sub_version;
- int rows, cols;
- int res = 0;
- int separated_coeff = buf[0] & 1;
-
- s->framep[VP56_FRAME_CURRENT]->key_frame = !(buf[0] & 0x80);
- ff_vp56_init_dequant(s, (buf[0] >> 1) & 0x3F);
-
- if (s->framep[VP56_FRAME_CURRENT]->key_frame) {
- sub_version = buf[1] >> 3;
- if (sub_version > 8)
- return AVERROR_INVALIDDATA;
- s->filter_header = buf[1] & 0x06;
- if (buf[1] & 1) {
- av_log_missing_feature(s->avctx, "Interlacing", 0);
- return AVERROR_PATCHWELCOME;
- }
- if (separated_coeff || !s->filter_header) {
- coeff_offset = AV_RB16(buf+2) - 2;
- buf += 2;
- buf_size -= 2;
- }
-
- rows = buf[2]; /* number of stored macroblock rows */
- cols = buf[3]; /* number of stored macroblock cols */
- /* buf[4] is number of displayed macroblock rows */
- /* buf[5] is number of displayed macroblock cols */
- if (!rows || !cols) {
- av_log(s->avctx, AV_LOG_ERROR, "Invalid size %dx%d\n", cols << 4, rows << 4);
- return AVERROR_INVALIDDATA;
- }
-
- if (!s->macroblocks || /* first frame */
- 16*cols != s->avctx->coded_width ||
- 16*rows != s->avctx->coded_height) {
- avcodec_set_dimensions(s->avctx, 16*cols, 16*rows);
- if (s->avctx->extradata_size == 1) {
- s->avctx->width -= s->avctx->extradata[0] >> 4;
- s->avctx->height -= s->avctx->extradata[0] & 0x0F;
- }
- res = VP56_SIZE_CHANGE;
- }
-
- ff_vp56_init_range_decoder(c, buf+6, buf_size-6);
- vp56_rac_gets(c, 2);
-
- parse_filter_info = s->filter_header;
- if (sub_version < 8)
- vrt_shift = 5;
- s->sub_version = sub_version;
- s->golden_frame = 0;
- } else {
- if (!s->sub_version || !s->avctx->coded_width || !s->avctx->coded_height)
- return AVERROR_INVALIDDATA;
-
- if (separated_coeff || !s->filter_header) {
- coeff_offset = AV_RB16(buf+1) - 2;
- buf += 2;
- buf_size -= 2;
- }
- ff_vp56_init_range_decoder(c, buf+1, buf_size-1);
-
- s->golden_frame = vp56_rac_get(c);
- if (s->filter_header) {
- s->deblock_filtering = vp56_rac_get(c);
- if (s->deblock_filtering)
- vp56_rac_get(c);
- if (s->sub_version > 7)
- parse_filter_info = vp56_rac_get(c);
- }
- }
-
- if (parse_filter_info) {
- if (vp56_rac_get(c)) {
- s->filter_mode = 2;
- s->sample_variance_threshold = vp56_rac_gets(c, 5) << vrt_shift;
- s->max_vector_length = 2 << vp56_rac_gets(c, 3);
- } else if (vp56_rac_get(c)) {
- s->filter_mode = 1;
- } else {
- s->filter_mode = 0;
- }
- if (s->sub_version > 7)
- s->filter_selection = vp56_rac_gets(c, 4);
- else
- s->filter_selection = 16;
- }
-
- s->use_huffman = vp56_rac_get(c);
-
- s->parse_coeff = vp6_parse_coeff;
- if (coeff_offset) {
- buf += coeff_offset;
- buf_size -= coeff_offset;
- if (buf_size < 0) {
- if (s->framep[VP56_FRAME_CURRENT]->key_frame)
- avcodec_set_dimensions(s->avctx, 0, 0);
- return AVERROR_INVALIDDATA;
- }
- if (s->use_huffman) {
- s->parse_coeff = vp6_parse_coeff_huffman;
- init_get_bits(&s->gb, buf, buf_size<<3);
- } else {
- ff_vp56_init_range_decoder(&s->cc, buf, buf_size);
- s->ccp = &s->cc;
- }
- } else {
- s->ccp = &s->c;
- }
-
- return res;
-}
-
-static void vp6_coeff_order_table_init(VP56Context *s)
-{
- int i, pos, idx = 1;
-
- s->modelp->coeff_index_to_pos[0] = 0;
- for (i=0; i<16; i++)
- for (pos=1; pos<64; pos++)
- if (s->modelp->coeff_reorder[pos] == i)
- s->modelp->coeff_index_to_pos[idx++] = pos;
-}
-
-static void vp6_default_models_init(VP56Context *s)
-{
- VP56Model *model = s->modelp;
-
- model->vector_dct[0] = 0xA2;
- model->vector_dct[1] = 0xA4;
- model->vector_sig[0] = 0x80;
- model->vector_sig[1] = 0x80;
-
- memcpy(model->mb_types_stats, ff_vp56_def_mb_types_stats, sizeof(model->mb_types_stats));
- memcpy(model->vector_fdv, vp6_def_fdv_vector_model, sizeof(model->vector_fdv));
- memcpy(model->vector_pdv, vp6_def_pdv_vector_model, sizeof(model->vector_pdv));
- memcpy(model->coeff_runv, vp6_def_runv_coeff_model, sizeof(model->coeff_runv));
- memcpy(model->coeff_reorder, vp6_def_coeff_reorder, sizeof(model->coeff_reorder));
-
- vp6_coeff_order_table_init(s);
-}
-
-static void vp6_parse_vector_models(VP56Context *s)
-{
- VP56RangeCoder *c = &s->c;
- VP56Model *model = s->modelp;
- int comp, node;
-
- for (comp=0; comp<2; comp++) {
- if (vp56_rac_get_prob(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]))
- 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]))
- 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]))
- model->vector_fdv[comp][node] = vp56_rac_gets_nn(c, 7);
-}
-
-/* nodes must ascend by count, but with descending symbol order */
-static int vp6_huff_cmp(const void *va, const void *vb)
-{
- const Node *a = va, *b = vb;
- return (a->count - b->count)*16 + (b->sym - a->sym);
-}
-
-static int vp6_build_huff_tree(VP56Context *s, uint8_t coeff_model[],
- const uint8_t *map, unsigned size, VLC *vlc)
-{
- Node nodes[2*VP6_MAX_HUFF_SIZE], *tmp = &nodes[size];
- int a, b, i;
-
- /* first compute probabilities from model */
- tmp[0].count = 256;
- for (i=0; i<size-1; i++) {
- a = tmp[i].count * coeff_model[i] >> 8;
- b = tmp[i].count * (255 - coeff_model[i]) >> 8;
- nodes[map[2*i ]].count = a + !a;
- nodes[map[2*i+1]].count = b + !b;
- }
-
- ff_free_vlc(vlc);
- /* then build the huffman tree according to probabilities */
- return ff_huff_build_tree(s->avctx, vlc, size, nodes, vp6_huff_cmp,
- FF_HUFFMAN_FLAG_HNODE_FIRST);
-}
-
-static int vp6_parse_coeff_models(VP56Context *s)
-{
- VP56RangeCoder *c = &s->c;
- VP56Model *model = s->modelp;
- int def_prob[11];
- int node, cg, ctx, pos;
- int ct; /* code type */
- int pt; /* plane type (0 for Y, 1 for U or V) */
-
- memset(def_prob, 0x80, sizeof(def_prob));
-
- for (pt=0; pt<2; pt++)
- for (node=0; node<11; node++)
- if (vp56_rac_get_prob(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->framep[VP56_FRAME_CURRENT]->key_frame) {
- model->coeff_dccv[pt][node] = def_prob[node];
- }
-
- if (vp56_rac_get(c)) {
- for (pos=1; pos<64; pos++)
- if (vp56_rac_get_prob(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]))
- 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])) {
- def_prob[node] = vp56_rac_gets_nn(c, 7);
- model->coeff_ract[pt][ct][cg][node] = def_prob[node];
- } else if (s->framep[VP56_FRAME_CURRENT]->key_frame) {
- model->coeff_ract[pt][ct][cg][node] = def_prob[node];
- }
-
- if (s->use_huffman) {
- for (pt=0; pt<2; pt++) {
- if (vp6_build_huff_tree(s, model->coeff_dccv[pt],
- vp6_huff_coeff_map, 12, &s->dccv_vlc[pt]))
- return -1;
- if (vp6_build_huff_tree(s, model->coeff_runv[pt],
- vp6_huff_run_map, 9, &s->runv_vlc[pt]))
- return -1;
- for (ct=0; ct<3; ct++)
- for (cg = 0; cg < 6; cg++)
- if (vp6_build_huff_tree(s, model->coeff_ract[pt][ct][cg],
- vp6_huff_coeff_map, 12,
- &s->ract_vlc[pt][ct][cg]))
- return -1;
- }
- memset(s->nb_null, 0, sizeof(s->nb_null));
- } else {
- /* coeff_dcct is a linear combination of coeff_dccv */
- for (pt=0; pt<2; pt++)
- for (ctx=0; ctx<3; ctx++)
- for (node=0; node<5; node++)
- model->coeff_dcct[pt][ctx][node] = av_clip(((model->coeff_dccv[pt][node] * vp6_dccv_lc[ctx][node][0] + 128) >> 8) + vp6_dccv_lc[ctx][node][1], 1, 255);
- }
- return 0;
-}
-
-static void vp6_parse_vector_adjustment(VP56Context *s, VP56mv *vect)
-{
- VP56RangeCoder *c = &s->c;
- VP56Model *model = s->modelp;
- int comp;
-
- *vect = (VP56mv) {0,0};
- if (s->vector_candidate_pos < 2)
- *vect = s->vector_candidate[0];
-
- for (comp=0; comp<2; comp++) {
- int i, delta = 0;
-
- if (vp56_rac_get_prob(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];
- delta |= vp56_rac_get_prob(c, model->vector_fdv[comp][j])<<j;
- }
- if (delta & 0xF0)
- delta |= vp56_rac_get_prob(c, model->vector_fdv[comp][3])<<3;
- else
- delta |= 8;
- } else {
- delta = vp56_rac_get_tree(c, ff_vp56_pva_tree,
- model->vector_pdv[comp]);
- }
-
- if (delta && vp56_rac_get_prob(c, model->vector_sig[comp]))
- delta = -delta;
-
- if (!comp)
- vect->x += delta;
- else
- vect->y += delta;
- }
-}
-
-/**
- * Read number of consecutive blocks with null DC or AC.
- * This value is < 74.
- */
-static unsigned vp6_get_nb_null(VP56Context *s)
-{
- unsigned val = get_bits(&s->gb, 2);
- if (val == 2)
- val += get_bits(&s->gb, 2);
- else if (val == 3) {
- val = get_bits1(&s->gb) << 2;
- val = 6+val + get_bits(&s->gb, 2+val);
- }
- return val;
-}
-
-static void vp6_parse_coeff_huffman(VP56Context *s)
-{
- VP56Model *model = s->modelp;
- uint8_t *permute = s->scantable.permutated;
- VLC *vlc_coeff;
- int coeff, sign, coeff_idx;
- int b, cg, idx;
- int pt = 0; /* plane type (0 for Y, 1 for U or V) */
-
- for (b=0; b<6; b++) {
- int ct = 0; /* code type */
- if (b > 3) pt = 1;
- vlc_coeff = &s->dccv_vlc[pt];
-
- for (coeff_idx = 0;;) {
- int run = 1;
- if (coeff_idx<2 && s->nb_null[coeff_idx][pt]) {
- s->nb_null[coeff_idx][pt]--;
- if (coeff_idx)
- break;
- } else {
- if (get_bits_left(&s->gb) <= 0)
- return;
- coeff = get_vlc2(&s->gb, vlc_coeff->table, 9, 3);
- if (coeff == 0) {
- if (coeff_idx) {
- int pt = (coeff_idx >= 6);
- run += get_vlc2(&s->gb, s->runv_vlc[pt].table, 9, 3);
- if (run >= 9)
- run += get_bits(&s->gb, 6);
- } else
- s->nb_null[0][pt] = vp6_get_nb_null(s);
- ct = 0;
- } else if (coeff == 11) { /* end of block */
- if (coeff_idx == 1) /* first AC coeff ? */
- s->nb_null[1][pt] = vp6_get_nb_null(s);
- break;
- } else {
- int coeff2 = ff_vp56_coeff_bias[coeff];
- if (coeff > 4)
- coeff2 += get_bits(&s->gb, coeff <= 9 ? coeff - 4 : 11);
- ct = 1 + (coeff2 > 1);
- sign = get_bits1(&s->gb);
- coeff2 = (coeff2 ^ -sign) + sign;
- if (coeff_idx)
- coeff2 *= s->dequant_ac;
- idx = model->coeff_index_to_pos[coeff_idx];
- s->block_coeff[b][permute[idx]] = coeff2;
- }
- }
- coeff_idx+=run;
- if (coeff_idx >= 64)
- break;
- cg = FFMIN(vp6_coeff_groups[coeff_idx], 3);
- vlc_coeff = &s->ract_vlc[pt][ct][cg];
- }
- }
-}
-
-static void vp6_parse_coeff(VP56Context *s)
-{
- VP56RangeCoder *c = s->ccp;
- VP56Model *model = s->modelp;
- uint8_t *permute = s->scantable.permutated;
- uint8_t *model1, *model2, *model3;
- int coeff, sign, coeff_idx;
- int b, i, cg, idx, ctx;
- int pt = 0; /* plane type (0 for Y, 1 for U or V) */
-
- for (b=0; b<6; b++) {
- int ct = 1; /* code type */
- int run = 1;
-
- if (b > 3) pt = 1;
-
- ctx = s->left_block[ff_vp56_b6to4[b]].not_null_dc
- + s->above_blocks[s->above_block_idx[b]].not_null_dc;
- model1 = model->coeff_dccv[pt];
- model2 = model->coeff_dcct[pt][ctx];
-
- coeff_idx = 0;
- for (;;) {
- if ((coeff_idx>1 && ct==0) || vp56_rac_get_prob(c, model2[0])) {
- /* parse a coeff */
- if (vp56_rac_get_prob(c, model2[2])) {
- if (vp56_rac_get_prob(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]))
- coeff = 3 + vp56_rac_get_prob(c, model1[5]);
- else
- coeff = 2;
- }
- ct = 2;
- } else {
- ct = 1;
- coeff = 1;
- }
- sign = vp56_rac_get(c);
- coeff = (coeff ^ -sign) + sign;
- if (coeff_idx)
- coeff *= s->dequant_ac;
- idx = model->coeff_index_to_pos[coeff_idx];
- s->block_coeff[b][permute[idx]] = coeff;
- run = 1;
- } else {
- /* parse a run */
- ct = 0;
- if (coeff_idx > 0) {
- if (!vp56_rac_get_prob(c, model2[1]))
- break;
-
- model3 = model->coeff_runv[coeff_idx >= 6];
- run = vp56_rac_get_tree(c, vp6_pcr_tree, model3);
- if (!run)
- for (run=9, i=0; i<6; i++)
- run += vp56_rac_get_prob(c, model3[i+8]) << i;
- }
- }
- coeff_idx += run;
- if (coeff_idx >= 64)
- break;
- cg = vp6_coeff_groups[coeff_idx];
- model1 = model2 = model->coeff_ract[pt][ct][cg];
- }
-
- s->left_block[ff_vp56_b6to4[b]].not_null_dc =
- s->above_blocks[s->above_block_idx[b]].not_null_dc = !!s->block_coeff[b][0];
- }
-}
-
-static int vp6_block_variance(uint8_t *src, int stride)
-{
- int sum = 0, square_sum = 0;
- int y, x;
-
- for (y=0; y<8; y+=2) {
- for (x=0; x<8; x+=2) {
- sum += src[x];
- square_sum += src[x]*src[x];
- }
- src += 2*stride;
- }
- return (16*square_sum - sum*sum) >> 8;
-}
-
-static void vp6_filter_hv4(uint8_t *dst, uint8_t *src, int stride,
- int delta, const int16_t *weights)
-{
- int x, y;
-
- for (y=0; y<8; y++) {
- for (x=0; x<8; x++) {
- dst[x] = av_clip_uint8(( src[x-delta ] * weights[0]
- + src[x ] * weights[1]
- + src[x+delta ] * weights[2]
- + src[x+2*delta] * weights[3] + 64) >> 7);
- }
- src += stride;
- dst += stride;
- }
-}
-
-static void vp6_filter_diag2(VP56Context *s, uint8_t *dst, uint8_t *src,
- int stride, int h_weight, int v_weight)
-{
- uint8_t *tmp = s->edge_emu_buffer+16;
- s->h264chroma.put_h264_chroma_pixels_tab[0](tmp, src, stride, 9, h_weight, 0);
- s->h264chroma.put_h264_chroma_pixels_tab[0](dst, tmp, stride, 8, 0, v_weight);
-}
-
-static void vp6_filter(VP56Context *s, uint8_t *dst, uint8_t *src,
- int offset1, int offset2, int stride,
- VP56mv mv, int mask, int select, int luma)
-{
- int filter4 = 0;
- int x8 = mv.x & mask;
- int y8 = mv.y & mask;
-
- if (luma) {
- x8 *= 2;
- y8 *= 2;
- filter4 = s->filter_mode;
- if (filter4 == 2) {
- if (s->max_vector_length &&
- (FFABS(mv.x) > s->max_vector_length ||
- FFABS(mv.y) > s->max_vector_length)) {
- filter4 = 0;
- } else if (s->sample_variance_threshold
- && (vp6_block_variance(src+offset1, stride)
- < s->sample_variance_threshold)) {
- filter4 = 0;
- }
- }
- }
-
- if ((y8 && (offset2-offset1)*s->flip<0) || (!y8 && offset1 > offset2)) {
- offset1 = offset2;
- }
-
- if (filter4) {
- if (!y8) { /* left or right combine */
- vp6_filter_hv4(dst, src+offset1, stride, 1,
- vp6_block_copy_filter[select][x8]);
- } else if (!x8) { /* above or below combine */
- vp6_filter_hv4(dst, src+offset1, stride, stride,
- vp6_block_copy_filter[select][y8]);
- } else {
- s->vp56dsp.vp6_filter_diag4(dst, src+offset1+((mv.x^mv.y)>>31), stride,
- vp6_block_copy_filter[select][x8],
- vp6_block_copy_filter[select][y8]);
- }
- } else {
- if (!x8 || !y8) {
- s->h264chroma.put_h264_chroma_pixels_tab[0](dst, src + offset1, stride, 8, x8, y8);
- } else {
- vp6_filter_diag2(s, dst, src+offset1 + ((mv.x^mv.y)>>31), stride, x8, y8);
- }
- }
-}
-
-static av_cold void vp6_decode_init_context(VP56Context *s);
-
-static av_cold int vp6_decode_init(AVCodecContext *avctx)
-{
- VP56Context *s = avctx->priv_data;
-
- ff_vp56_init(avctx, avctx->codec->id == AV_CODEC_ID_VP6,
- avctx->codec->id == AV_CODEC_ID_VP6A);
- vp6_decode_init_context(s);
-
- if (s->has_alpha) {
- int i;
-
- s->alpha_context = av_mallocz(sizeof(VP56Context));
- ff_vp56_init_context(avctx, s->alpha_context,
- s->flip == -1, s->has_alpha);
- vp6_decode_init_context(s->alpha_context);
- for (i = 0; i < 6; ++i)
- s->alpha_context->framep[i] = s->framep[i];
- }
-
- return 0;
-}
-
-static av_cold void vp6_decode_init_context(VP56Context *s)
-{
- s->deblock_filtering = 0;
- s->vp56_coord_div = vp6_coord_div;
- s->parse_vector_adjustment = vp6_parse_vector_adjustment;
- s->filter = vp6_filter;
- s->default_models_init = vp6_default_models_init;
- s->parse_vector_models = vp6_parse_vector_models;
- s->parse_coeff_models = vp6_parse_coeff_models;
- s->parse_header = vp6_parse_header;
-}
-
-static av_cold void vp6_decode_free_context(VP56Context *s);
-
-static av_cold int vp6_decode_free(AVCodecContext *avctx)
-{
- VP56Context *s = avctx->priv_data;
-
- ff_vp56_free(avctx);
- vp6_decode_free_context(s);
-
- if (s->alpha_context) {
- ff_vp56_free_context(s->alpha_context);
- vp6_decode_free_context(s->alpha_context);
- av_free(s->alpha_context);
- }
-
- return 0;
-}
-
-static av_cold void vp6_decode_free_context(VP56Context *s)
-{
- int pt, ct, cg;
-
- for (pt=0; pt<2; pt++) {
- ff_free_vlc(&s->dccv_vlc[pt]);
- ff_free_vlc(&s->runv_vlc[pt]);
- for (ct=0; ct<3; ct++)
- for (cg=0; cg<6; cg++)
- ff_free_vlc(&s->ract_vlc[pt][ct][cg]);
- }
-}
-
-AVCodec ff_vp6_decoder = {
- .name = "vp6",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_VP6,
- .priv_data_size = sizeof(VP56Context),
- .init = vp6_decode_init,
- .close = vp6_decode_free,
- .decode = ff_vp56_decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("On2 VP6"),
-};
-
-/* flash version, not flipped upside-down */
-AVCodec ff_vp6f_decoder = {
- .name = "vp6f",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_VP6F,
- .priv_data_size = sizeof(VP56Context),
- .init = vp6_decode_init,
- .close = vp6_decode_free,
- .decode = ff_vp56_decode_frame,
- .capabilities = CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("On2 VP6 (Flash version)"),
-};
-
-/* flash version, not flipped upside-down, with alpha channel */
-AVCodec ff_vp6a_decoder = {
- .name = "vp6a",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_VP6A,
- .priv_data_size = sizeof(VP56Context),
- .init = vp6_decode_init,
- .close = vp6_decode_free,
- .decode = ff_vp56_decode_frame,
- .capabilities = CODEC_CAP_DR1 | CODEC_CAP_SLICE_THREADS,
- .long_name = NULL_IF_CONFIG_SMALL("On2 VP6 (Flash version, with alpha channel)"),
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/vp6data.h b/src/thirdparty/ffmpeg/libavcodec/vp6data.h
deleted file mode 100644
index 45c6e207f..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vp6data.h
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.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
- */
-
-/**
- * @file
- * VP6 compatible video decoder
- */
-
-#ifndef AVCODEC_VP6DATA_H
-#define AVCODEC_VP6DATA_H
-
-#include "vp56data.h"
-
-static const uint8_t vp6_def_fdv_vector_model[2][8] = {
- { 247, 210, 135, 68, 138, 220, 239, 246 },
- { 244, 184, 201, 44, 173, 221, 239, 253 },
-};
-
-static const uint8_t vp6_def_pdv_vector_model[2][7] = {
- { 225, 146, 172, 147, 214, 39, 156 },
- { 204, 170, 119, 235, 140, 230, 228 },
-};
-
-static const uint8_t vp6_def_coeff_reorder[] = {
- 0, 0, 1, 1, 1, 2, 2, 2,
- 2, 2, 2, 3, 3, 4, 4, 4,
- 5, 5, 5, 5, 6, 6, 7, 7,
- 7, 7, 7, 8, 8, 9, 9, 9,
- 9, 9, 9, 10, 10, 11, 11, 11,
- 11, 11, 11, 12, 12, 12, 12, 12,
- 12, 13, 13, 13, 13, 13, 14, 14,
- 14, 14, 15, 15, 15, 15, 15, 15,
-};
-
-static const uint8_t vp6_def_runv_coeff_model[2][14] = {
- { 198, 197, 196, 146, 198, 204, 169, 142, 130, 136, 149, 149, 191, 249 },
- { 135, 201, 181, 154, 98, 117, 132, 126, 146, 169, 184, 240, 246, 254 },
-};
-
-static const uint8_t vp6_sig_dct_pct[2][2] = {
- { 237, 246 },
- { 231, 243 },
-};
-
-static const uint8_t vp6_pdv_pct[2][7] = {
- { 253, 253, 254, 254, 254, 254, 254 },
- { 245, 253, 254, 254, 254, 254, 254 },
-};
-
-static const uint8_t vp6_fdv_pct[2][8] = {
- { 254, 254, 254, 254, 254, 250, 250, 252 },
- { 254, 254, 254, 254, 254, 251, 251, 254 },
-};
-
-static const uint8_t vp6_dccv_pct[2][11] = {
- { 146, 255, 181, 207, 232, 243, 238, 251, 244, 250, 249 },
- { 179, 255, 214, 240, 250, 255, 244, 255, 255, 255, 255 },
-};
-
-static const uint8_t vp6_coeff_reorder_pct[] = {
- 255, 132, 132, 159, 153, 151, 161, 170,
- 164, 162, 136, 110, 103, 114, 129, 118,
- 124, 125, 132, 136, 114, 110, 142, 135,
- 134, 123, 143, 126, 153, 183, 166, 161,
- 171, 180, 179, 164, 203, 218, 225, 217,
- 215, 206, 203, 217, 229, 241, 248, 243,
- 253, 255, 253, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255,
-};
-
-static const uint8_t vp6_runv_pct[2][14] = {
- { 219, 246, 238, 249, 232, 239, 249, 255, 248, 253, 239, 244, 241, 248 },
- { 198, 232, 251, 253, 219, 241, 253, 255, 248, 249, 244, 238, 251, 255 },
-};
-
-static const uint8_t vp6_ract_pct[3][2][6][11] = {
- { { { 227, 246, 230, 247, 244, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 209, 231, 231, 249, 249, 253, 255, 255, 255 },
- { 255, 255, 225, 242, 241, 251, 253, 255, 255, 255, 255 },
- { 255, 255, 241, 253, 252, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 248, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 } },
- { { 240, 255, 248, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 240, 253, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 } } },
- { { { 206, 203, 227, 239, 247, 255, 253, 255, 255, 255, 255 },
- { 207, 199, 220, 236, 243, 252, 252, 255, 255, 255, 255 },
- { 212, 219, 230, 243, 244, 253, 252, 255, 255, 255, 255 },
- { 236, 237, 247, 252, 253, 255, 255, 255, 255, 255, 255 },
- { 240, 240, 248, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 } },
- { { 230, 233, 249, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 238, 238, 250, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 248, 251, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 } } },
- { { { 225, 239, 227, 231, 244, 253, 243, 255, 255, 253, 255 },
- { 232, 234, 224, 228, 242, 249, 242, 252, 251, 251, 255 },
- { 235, 249, 238, 240, 251, 255, 249, 255, 253, 253, 255 },
- { 249, 253, 251, 250, 255, 255, 255, 255, 255, 255, 255 },
- { 251, 250, 249, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 } },
- { { 243, 244, 250, 250, 255, 255, 255, 255, 255, 255, 255 },
- { 249, 248, 250, 253, 255, 255, 255, 255, 255, 255, 255 },
- { 253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 } } }
-};
-
-static const int vp6_dccv_lc[3][5][2] = {
- { { 122, 133 }, { 0, 1 }, { 78, 171 }, { 139, 117 }, { 168, 79 } },
- { { 133, 51 }, { 0, 1 }, { 169, 71 }, { 214, 44 }, { 210, 38 } },
- { { 142, -16 }, { 0, 1 }, { 221, -30 }, { 246, -3 }, { 203, 17 } },
-};
-
-static const uint8_t vp6_coeff_groups[] = {
- 0, 0, 1, 1, 1, 2, 2, 2,
- 2, 2, 2, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 5, 5, 5, 5,
-};
-
-static const int16_t vp6_block_copy_filter[17][8][4] = {
- { { 0, 128, 0, 0 }, /* 0 */
- { -3, 122, 9, 0 },
- { -4, 109, 24, -1 },
- { -5, 91, 45, -3 },
- { -4, 68, 68, -4 },
- { -3, 45, 91, -5 },
- { -1, 24, 109, -4 },
- { 0, 9, 122, -3 } },
- { { 0, 128, 0, 0 }, /* 1 */
- { -4, 124, 9, -1 },
- { -5, 110, 25, -2 },
- { -6, 91, 46, -3 },
- { -5, 69, 69, -5 },
- { -3, 46, 91, -6 },
- { -2, 25, 110, -5 },
- { -1, 9, 124, -4 } },
- { { 0, 128, 0, 0 }, /* 2 */
- { -4, 123, 10, -1 },
- { -6, 110, 26, -2 },
- { -7, 92, 47, -4 },
- { -6, 70, 70, -6 },
- { -4, 47, 92, -7 },
- { -2, 26, 110, -6 },
- { -1, 10, 123, -4 } },
- { { 0, 128, 0, 0 }, /* 3 */
- { -5, 124, 10, -1 },
- { -7, 110, 27, -2 },
- { -7, 91, 48, -4 },
- { -6, 70, 70, -6 },
- { -4, 48, 92, -8 },
- { -2, 27, 110, -7 },
- { -1, 10, 124, -5 } },
- { { 0, 128, 0, 0 }, /* 4 */
- { -6, 124, 11, -1 },
- { -8, 111, 28, -3 },
- { -8, 92, 49, -5 },
- { -7, 71, 71, -7 },
- { -5, 49, 92, -8 },
- { -3, 28, 111, -8 },
- { -1, 11, 124, -6 } },
- { { 0, 128, 0, 0 }, /* 5 */
- { -6, 123, 12, -1 },
- { -9, 111, 29, -3 },
- { -9, 93, 50, -6 },
- { -8, 72, 72, -8 },
- { -6, 50, 93, -9 },
- { -3, 29, 111, -9 },
- { -1, 12, 123, -6 } },
- { { 0, 128, 0, 0 }, /* 6 */
- { -7, 124, 12, -1 },
- { -10, 111, 30, -3 },
- { -10, 93, 51, -6 },
- { -9, 73, 73, -9 },
- { -6, 51, 93, -10 },
- { -3, 30, 111, -10 },
- { -1, 12, 124, -7 } },
- { { 0, 128, 0, 0 }, /* 7 */
- { -7, 123, 13, -1 },
- { -11, 112, 31, -4 },
- { -11, 94, 52, -7 },
- { -10, 74, 74, -10 },
- { -7, 52, 94, -11 },
- { -4, 31, 112, -11 },
- { -1, 13, 123, -7 } },
- { { 0, 128, 0, 0 }, /* 8 */
- { -8, 124, 13, -1 },
- { -12, 112, 32, -4 },
- { -12, 94, 53, -7 },
- { -10, 74, 74, -10 },
- { -7, 53, 94, -12 },
- { -4, 32, 112, -12 },
- { -1, 13, 124, -8 } },
- { { 0, 128, 0, 0 }, /* 9 */
- { -9, 124, 14, -1 },
- { -13, 112, 33, -4 },
- { -13, 95, 54, -8 },
- { -11, 75, 75, -11 },
- { -8, 54, 95, -13 },
- { -4, 33, 112, -13 },
- { -1, 14, 124, -9 } },
- { { 0, 128, 0, 0 }, /* 10 */
- { -9, 123, 15, -1 },
- { -14, 113, 34, -5 },
- { -14, 95, 55, -8 },
- { -12, 76, 76, -12 },
- { -8, 55, 95, -14 },
- { -5, 34, 112, -13 },
- { -1, 15, 123, -9 } },
- { { 0, 128, 0, 0 }, /* 11 */
- { -10, 124, 15, -1 },
- { -14, 113, 34, -5 },
- { -15, 96, 56, -9 },
- { -13, 77, 77, -13 },
- { -9, 56, 96, -15 },
- { -5, 34, 113, -14 },
- { -1, 15, 124, -10 } },
- { { 0, 128, 0, 0 }, /* 12 */
- { -10, 123, 16, -1 },
- { -15, 113, 35, -5 },
- { -16, 98, 56, -10 },
- { -14, 78, 78, -14 },
- { -10, 56, 98, -16 },
- { -5, 35, 113, -15 },
- { -1, 16, 123, -10 } },
- { { 0, 128, 0, 0 }, /* 13 */
- { -11, 124, 17, -2 },
- { -16, 113, 36, -5 },
- { -17, 98, 57, -10 },
- { -14, 78, 78, -14 },
- { -10, 57, 98, -17 },
- { -5, 36, 113, -16 },
- { -2, 17, 124, -11 } },
- { { 0, 128, 0, 0 }, /* 14 */
- { -12, 125, 17, -2 },
- { -17, 114, 37, -6 },
- { -18, 99, 58, -11 },
- { -15, 79, 79, -15 },
- { -11, 58, 99, -18 },
- { -6, 37, 114, -17 },
- { -2, 17, 125, -12 } },
- { { 0, 128, 0, 0 }, /* 15 */
- { -12, 124, 18, -2 },
- { -18, 114, 38, -6 },
- { -19, 99, 59, -11 },
- { -16, 80, 80, -16 },
- { -11, 59, 99, -19 },
- { -6, 38, 114, -18 },
- { -2, 18, 124, -12 } },
- { { 0, 128, 0, 0 }, /* 16 */
- { -4, 118, 16, -2 },
- { -7, 106, 34, -5 },
- { -8, 90, 53, -7 },
- { -8, 72, 72, -8 },
- { -7, 53, 90, -8 },
- { -5, 34, 106, -7 },
- { -2, 16, 118, -4 } },
-};
-
-static const VP56Tree vp6_pcr_tree[] = {
- { 8, 0},
- { 4, 1},
- { 2, 2}, {-1}, {-2},
- { 2, 3}, {-3}, {-4},
- { 8, 4},
- { 4, 5},
- { 2, 6}, {-5}, {-6},
- { 2, 7}, {-7}, {-8},
- {-0},
-};
-
-static const uint8_t vp6_coord_div[] = { 4, 4, 4, 4, 8, 8 };
-
-static const uint8_t vp6_huff_coeff_map[] = {
- 13, 14, 11, 0, 1, 15, 16, 18, 2, 17, 3, 4, 19, 20, 5, 6, 21, 22, 7, 8, 9, 10
-};
-
-static const uint8_t vp6_huff_run_map[] = {
- 10, 13, 11, 12, 0, 1, 2, 3, 14, 8, 15, 16, 4, 5, 6, 7
-};
-
-#endif /* AVCODEC_VP6DATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/vp6dsp.c b/src/thirdparty/ffmpeg/libavcodec/vp6dsp.c
deleted file mode 100644
index 6654ce1f7..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vp6dsp.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.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
- */
-
-/**
- * @file
- * VP6 DSP-oriented functions
- */
-
-#include "libavutil/common.h"
-#include "vp56dsp.h"
-
-
-void ff_vp6_filter_diag4_c(uint8_t *dst, uint8_t *src, int stride,
- const int16_t *h_weights, const int16_t *v_weights)
-{
- int x, y;
- int tmp[8*11];
- int *t = tmp;
-
- src -= stride;
-
- for (y=0; y<11; y++) {
- for (x=0; x<8; x++) {
- t[x] = av_clip_uint8(( src[x-1] * h_weights[0]
- + src[x ] * h_weights[1]
- + src[x+1] * h_weights[2]
- + src[x+2] * h_weights[3] + 64) >> 7);
- }
- src += stride;
- t += 8;
- }
-
- t = tmp + 8;
- for (y=0; y<8; y++) {
- for (x=0; x<8; x++) {
- dst[x] = av_clip_uint8(( t[x-8 ] * v_weights[0]
- + t[x ] * v_weights[1]
- + t[x+8 ] * v_weights[2]
- + t[x+16] * v_weights[3] + 64) >> 7);
- }
- dst += stride;
- t += 8;
- }
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/vp8.c b/src/thirdparty/ffmpeg/libavcodec/vp8.c
deleted file mode 100644
index 4d6f18754..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vp8.c
+++ /dev/null
@@ -1,2089 +0,0 @@
-/*
- * 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
- *
- * 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/imgutils.h"
-#include "avcodec.h"
-#include "internal.h"
-#include "vp8.h"
-#include "vp8data.h"
-#include "rectangle.h"
-#include "thread.h"
-
-#if ARCH_ARM
-# include "arm/vp8.h"
-#endif
-
-static void free_buffers(VP8Context *s)
-{
- int i;
- if (s->thread_data)
- for (i = 0; i < MAX_THREADS; i++) {
- av_freep(&s->thread_data[i].filter_strength);
- av_freep(&s->thread_data[i].edge_emu_buffer);
- }
- av_freep(&s->thread_data);
- av_freep(&s->macroblocks_base);
- av_freep(&s->intra4x4_pred_mode_top);
- av_freep(&s->top_nnz);
- av_freep(&s->top_border);
-
- s->macroblocks = NULL;
-}
-
-static int vp8_alloc_frame(VP8Context *s, AVFrame *f)
-{
- int ret;
- if ((ret = ff_thread_get_buffer(s->avctx, f)) < 0)
- return ret;
- if (s->num_maps_to_be_freed && !s->maps_are_invalid) {
- f->ref_index[0] = s->segmentation_maps[--s->num_maps_to_be_freed];
- } else if (!(f->ref_index[0] = av_mallocz(s->mb_width * s->mb_height))) {
- ff_thread_release_buffer(s->avctx, f);
- return AVERROR(ENOMEM);
- }
- return 0;
-}
-
-static void vp8_release_frame(VP8Context *s, AVFrame *f, int prefer_delayed_free, int can_direct_free)
-{
- if (f->ref_index[0]) {
- if (prefer_delayed_free) {
- /* Upon a size change, we want to free the maps but other threads may still
- * be using them, so queue them. Upon a seek, all threads are inactive so
- * we want to cache one to prevent re-allocation in the next decoding
- * iteration, but the rest we can free directly. */
- int max_queued_maps = can_direct_free ? 1 : FF_ARRAY_ELEMS(s->segmentation_maps);
- if (s->num_maps_to_be_freed < max_queued_maps) {
- s->segmentation_maps[s->num_maps_to_be_freed++] = f->ref_index[0];
- } else if (can_direct_free) /* vp8_decode_flush(), but our queue is full */ {
- av_free(f->ref_index[0]);
- } /* else: MEMLEAK (should never happen, but better that than crash) */
- f->ref_index[0] = NULL;
- } else /* vp8_decode_free() */ {
- av_free(f->ref_index[0]);
- }
- }
- ff_thread_release_buffer(s->avctx, f);
-}
-
-static void vp8_decode_flush_impl(AVCodecContext *avctx,
- int prefer_delayed_free, int can_direct_free, int free_mem)
-{
- VP8Context *s = avctx->priv_data;
- int i;
-
- if (!avctx->internal->is_copy) {
- for (i = 0; i < 5; i++)
- if (s->frames[i].data[0])
- vp8_release_frame(s, &s->frames[i], prefer_delayed_free, can_direct_free);
- }
- memset(s->framep, 0, sizeof(s->framep));
-
- if (free_mem) {
- free_buffers(s);
- s->maps_are_invalid = 1;
- }
-}
-
-static void vp8_decode_flush(AVCodecContext *avctx)
-{
- vp8_decode_flush_impl(avctx, 1, 1, 0);
-}
-
-static int update_dimensions(VP8Context *s, int width, int height)
-{
- AVCodecContext *avctx = s->avctx;
- int i;
-
- if (width != s->avctx->width || ((width+15)/16 != s->mb_width || (height+15)/16 != s->mb_height) && s->macroblocks_base ||
- height != s->avctx->height) {
- if (av_image_check_size(width, height, 0, s->avctx))
- return AVERROR_INVALIDDATA;
-
- vp8_decode_flush_impl(s->avctx, 1, 0, 1);
-
- avcodec_set_dimensions(s->avctx, width, height);
- }
-
- 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);
- 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));
-
- 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));
-#if HAVE_THREADS
- pthread_mutex_init(&s->thread_data[i].lock, NULL);
- pthread_cond_init(&s->thread_data[i].cond, NULL);
-#endif
- }
-
- if (!s->macroblocks_base || !s->top_nnz || !s->top_border ||
- (!s->intra4x4_pred_mode_top && !s->mb_layout))
- return AVERROR(ENOMEM);
-
- s->macroblocks = s->macroblocks_base + 1;
-
- return 0;
-}
-
-static void parse_segment_info(VP8Context *s)
-{
- VP56RangeCoder *c = &s->c;
- int i;
-
- s->segmentation.update_map = vp8_rac_get(c);
-
- if (vp8_rac_get(c)) { // update segment feature data
- s->segmentation.absolute_vals = vp8_rac_get(c);
-
- for (i = 0; i < 4; i++)
- s->segmentation.base_quant[i] = vp8_rac_get_sint(c, 7);
-
- for (i = 0; i < 4; i++)
- s->segmentation.filter_level[i] = vp8_rac_get_sint(c, 6);
- }
- if (s->segmentation.update_map)
- for (i = 0; i < 3; i++)
- s->prob->segmentid[i] = vp8_rac_get(c) ? vp8_rac_get_uint(c, 8) : 255;
-}
-
-static void update_lf_deltas(VP8Context *s)
-{
- VP56RangeCoder *c = &s->c;
- int i;
-
- for (i = 0; i < 4; i++) {
- if (vp8_rac_get(c)) {
- s->lf_delta.ref[i] = vp8_rac_get_uint(c, 6);
-
- if (vp8_rac_get(c))
- s->lf_delta.ref[i] = -s->lf_delta.ref[i];
- }
- }
-
- for (i = MODE_I4x4; i <= VP8_MVMODE_SPLIT; i++) {
- if (vp8_rac_get(c)) {
- s->lf_delta.mode[i] = vp8_rac_get_uint(c, 6);
-
- if (vp8_rac_get(c))
- s->lf_delta.mode[i] = -s->lf_delta.mode[i];
- }
- }
-}
-
-static int setup_partitions(VP8Context *s, const uint8_t *buf, int buf_size)
-{
- const uint8_t *sizes = buf;
- int i;
-
- 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);
- if (buf_size < 0)
- return -1;
-
- for (i = 0; i < s->num_coeff_partitions-1; i++) {
- int size = AV_RL24(sizes + 3*i);
- if (buf_size - size < 0)
- return -1;
-
- ff_vp56_init_range_decoder(&s->coeff_partition[i], buf, size);
- buf += size;
- buf_size -= size;
- }
- ff_vp56_init_range_decoder(&s->coeff_partition[i], buf, buf_size);
-
- return 0;
-}
-
-static void get_quants(VP8Context *s)
-{
- VP56RangeCoder *c = &s->c;
- int i, base_qi;
-
- int yac_qi = vp8_rac_get_uint(c, 7);
- int ydc_delta = vp8_rac_get_sint(c, 4);
- int y2dc_delta = vp8_rac_get_sint(c, 4);
- int y2ac_delta = vp8_rac_get_sint(c, 4);
- int uvdc_delta = vp8_rac_get_sint(c, 4);
- int uvac_delta = vp8_rac_get_sint(c, 4);
-
- for (i = 0; i < 4; i++) {
- if (s->segmentation.enabled) {
- base_qi = s->segmentation.base_quant[i];
- if (!s->segmentation.absolute_vals)
- base_qi += yac_qi;
- } 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)];
- /* 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] = FFMAX(s->qmat[i].luma_dc_qmul[1], 8);
- s->qmat[i].chroma_qmul[0] = FFMIN(s->qmat[i].chroma_qmul[0], 132);
- }
-}
-
-/**
- * Determine which buffers golden and altref should be updated with after this frame.
- * The spec isn't clear here, so I'm going by my understanding of what libvpx does
- *
- * Intra frames update all 3 references
- * Inter frames update VP56_FRAME_PREVIOUS if the update_last flag is set
- * If the update (golden|altref) flag is set, it's updated with the current frame
- * if update_last is set, and VP56_FRAME_PREVIOUS otherwise.
- * If the flag is not set, the number read means:
- * 0: no update
- * 1: VP56_FRAME_PREVIOUS
- * 2: update golden with altref, or update altref with golden
- */
-static VP56Frame ref_to_update(VP8Context *s, int update, VP56Frame ref)
-{
- VP56RangeCoder *c = &s->c;
-
- if (update)
- return VP56_FRAME_CURRENT;
-
- switch (vp8_rac_get_uint(c, 2)) {
- case 1:
- return VP56_FRAME_PREVIOUS;
- case 2:
- return (ref == VP56_FRAME_GOLDEN) ? VP56_FRAME_GOLDEN2 : VP56_FRAME_GOLDEN;
- }
- return VP56_FRAME_NONE;
-}
-
-static void update_refs(VP8Context *s)
-{
- VP56RangeCoder *c = &s->c;
-
- int update_golden = vp8_rac_get(c);
- int update_altref = vp8_rac_get(c);
-
- s->update_golden = ref_to_update(s, update_golden, VP56_FRAME_GOLDEN);
- 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)
-{
- VP56RangeCoder *c = &s->c;
- int header_size, hscale, vscale, i, j, k, l, m, ret;
- int width = s->avctx->width;
- int height = s->avctx->height;
-
- s->keyframe = !(buf[0] & 1);
- s->profile = (buf[0]>>1) & 7;
- s->invisible = !(buf[0] & 0x10);
- header_size = AV_RL24(buf) >> 5;
- buf += 3;
- buf_size -= 3;
-
- if (s->profile > 3)
- 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));
- 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));
-
- 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));
- return AVERROR_INVALIDDATA;
- }
- 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;
-
- if (hscale || vscale)
- av_log_missing_feature(s->avctx, "Upscaling", 1);
-
- 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));
- memset(&s->segmentation, 0, sizeof(s->segmentation));
- memset(&s->lf_delta, 0, sizeof(s->lf_delta));
- }
-
- ff_vp56_init_range_decoder(c, buf, header_size);
- buf += header_size;
- buf_size -= header_size;
-
- if (s->keyframe) {
- if (vp8_rac_get(c))
- av_log(s->avctx, AV_LOG_WARNING, "Unspecified colorspace\n");
- vp8_rac_get(c); // whether we can skip clamping in dsp functions
- }
-
- if ((s->segmentation.enabled = vp8_rac_get(c)))
- parse_segment_info(s);
- else
- s->segmentation.update_map = 0; // FIXME: move this to some init function?
-
- 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);
-
- if ((s->lf_delta.enabled = vp8_rac_get(c)))
- if (vp8_rac_get(c))
- update_lf_deltas(s);
-
- if (setup_partitions(s, buf, buf_size)) {
- av_log(s->avctx, AV_LOG_ERROR, "Invalid partitions\n");
- return AVERROR_INVALIDDATA;
- }
-
- 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)
- return ret;
- }
-
- get_quants(s);
-
- if (!s->keyframe) {
- update_refs(s);
- s->sign_bias[VP56_FRAME_GOLDEN] = vp8_rac_get(c);
- s->sign_bias[VP56_FRAME_GOLDEN2 /* altref */] = vp8_rac_get(c);
- }
-
- // if we aren't saving this frame's probabilities for future frames,
- // make a copy of the current probabilities
- if (!(s->update_probabilities = vp8_rac_get(c)))
- s->prob[1] = s->prob[0];
-
- 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;
- }
-
- if ((s->mbskip_enabled = vp8_rac_get(c)))
- s->prob->mbskip = vp8_rac_get_uint(c, 8);
-
- if (!s->keyframe) {
- 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);
- }
-
- return 0;
-}
-
-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);
-}
-
-/**
- * Motion vector coding, 17.1.
- */
-static int read_mv_component(VP56RangeCoder *c, const uint8_t *p)
-{
- int bit, x = 0;
-
- if (vp56_rac_get_prob_branchy(c, p[0])) {
- int i;
-
- for (i = 0; i < 3; i++)
- x += vp56_rac_get_prob(c, p[9 + i]) << i;
- for (i = 9; i > 3; i--)
- x += vp56_rac_get_prob(c, p[9 + i]) << i;
- if (!(x & 0xFFF0) || vp56_rac_get_prob(c, p[12]))
- x += 8;
- } else {
- // small_mvtree
- const uint8_t *ps = p+2;
- bit = vp56_rac_get_prob(c, *ps);
- ps += 1 + 3*bit;
- x += 4*bit;
- bit = vp56_rac_get_prob(c, *ps);
- ps += 1 + bit;
- x += 2*bit;
- x += vp56_rac_get_prob(c, *ps);
- }
-
- return (x && vp56_rac_get_prob(c, p[1])) ? -x : x;
-}
-
-static av_always_inline
-const uint8_t *get_submv_prob(uint32_t left, uint32_t top)
-{
- if (left == top)
- return vp8_submv_prob[4-!!left];
- if (!top)
- return vp8_submv_prob[2];
- return vp8_submv_prob[1-!!left];
-}
-
-/**
- * Split motion vector prediction, 16.4.
- * @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 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;
- VP56mv *top_mv;
- VP56mv *left_mv = left_mb->bmv;
- VP56mv *cur_mv = mb->bmv;
-
- if (!layout) // layout is inlined, s->mb_layout is not
- top_mb = &mb[2];
- else
- top_mb = &mb[-s->mb_width-1];
- mbsplits_top = vp8_mbsplits[top_mb->partitioning];
- 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])) {
- part_idx = VP8_SPLITMVMODE_16x8 + vp56_rac_get_prob(c, vp8_mbsplit_prob[2]);
- } 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];
- mb->partitioning = part_idx;
-
- for (n = 0; n < num; n++) {
- int k = firstidx[n];
- uint32_t left, above;
- const uint8_t *submv_prob;
-
- if (!(k & 3))
- left = AV_RN32A(&left_mv[mbsplits_left[k + 3]]);
- else
- 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);
-
- 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]);
- } else {
- AV_ZERO32(&mb->bmv[n]);
- }
- } else {
- AV_WN32A(&mb->bmv[n], above);
- }
- } else {
- AV_WN32A(&mb->bmv[n], left);
- }
- }
-
- return num;
-}
-
-static av_always_inline
-void 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 */ };
- enum { CNT_ZERO, CNT_NEAREST, CNT_NEAR, CNT_SPLITMV };
- enum { VP8_EDGE_TOP, VP8_EDGE_LEFT, VP8_EDGE_TOPLEFT };
- int idx = CNT_ZERO;
- int cur_sign_bias = s->sign_bias[mb->ref_frame];
- int8_t *sign_bias = s->sign_bias;
- VP56mv near_mv[4];
- uint8_t cnt[4] = { 0 };
- VP56RangeCoder *c = &s->c;
-
- 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;
- }
-
- AV_ZERO32(&near_mv[0]);
- AV_ZERO32(&near_mv[1]);
- 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);\
- }\
- }
-
- MV_EDGE_CHECK(0)
- MV_EDGE_CHECK(1)
- MV_EDGE_CHECK(2)
-
- mb->partitioning = VP8_SPLITMVMODE_NONE;
- if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_ZERO]][0])) {
- 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]))
- cnt[CNT_NEAREST] += 1;
-
- /* Swap near and nearest if necessary */
- if (cnt[CNT_NEAR] > cnt[CNT_NEAREST]) {
- FFSWAP(uint8_t, cnt[CNT_NEAREST], cnt[CNT_NEAR]);
- FFSWAP( VP56mv, near_mv[CNT_NEAREST], near_mv[CNT_NEAR]);
- }
-
- 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) +
- (mb_edge[VP8_EDGE_TOP]->mode == VP8_MVMODE_SPLIT)) * 2 +
- (mb_edge[VP8_EDGE_TOPLEFT]->mode == VP8_MVMODE_SPLIT);
-
- 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];
- } else {
- mb->mv.y += read_mv_component(c, s->prob->mvc[0]);
- mb->mv.x += read_mv_component(c, s->prob->mvc[1]);
- mb->bmv[0] = mb->mv;
- }
- } else {
- clamp_mv(s, &mb->mv, &near_mv[CNT_NEAR]);
- mb->bmv[0] = mb->mv;
- }
- } else {
- clamp_mv(s, &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 decode_intra4x4_modes(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb,
- int mb_x, int keyframe, int layout)
-{
- uint8_t *intra4x4 = mb->intra4x4_pred_mode_mb;
-
- if (layout == 1) {
- 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)
- 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]];
- *intra4x4 = vp8_rac_get_tree(c, vp8_pred4x4_tree, ctx);
- 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);
- }
-}
-
-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)
-{
- VP56RangeCoder *c = &s->c;
-
- 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)
- *segment = ref ? *ref : *segment;
- mb->segment = *segment;
-
- 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);
-
- 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)
- 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);
- }
-
- 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;
- else
- mb->ref_frame = VP56_FRAME_PREVIOUS;
- s->ref_count[mb->ref_frame-1]++;
-
- // motion vectors, 16.3
- 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);
-
- 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;
- AV_ZERO32(&mb->bmv[0]);
- }
-}
-
-#ifndef decode_block_coeffs_internal
-/**
- * @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
- * @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])
-{
- VP56RangeCoder c = *r;
- goto skip_eob;
- do {
- int coeff;
- if (!vp56_rac_get_prob_branchy(&c, token_prob[0])) // DCT_EOB
- break;
-
-skip_eob:
- if (!vp56_rac_get_prob_branchy(&c, token_prob[1])) { // DCT_0
- if (++i == 16)
- break; // invalid input; blocks should end with EOB
- token_prob = probs[i][0];
- goto skip_eob;
- }
-
- if (!vp56_rac_get_prob_branchy(&c, token_prob[2])) { // DCT_1
- coeff = 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]);
- if (coeff)
- coeff += vp56_rac_get_prob(&c, token_prob[5]);
- coeff += 2;
- } else {
- // 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]);
- } 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);
- coeff += vp8_rac_get_coeff(&c, ff_vp8_dct_cat_prob[cat]);
- }
- }
- token_prob = probs[i+1][2];
- }
- block[zigzag_scan[i]] = (vp8_rac_get(&c) ? -coeff : coeff) * qmul[!!i];
- } while (++i < 16);
-
- *r = c;
- return i;
-}
-#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 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
- * @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 *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);
-}
-
-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])
-{
- 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) {
- 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);
- l_nnz[8] = t_nnz[8] = !!nnz;
- if (nnz) {
- nnz_total += nnz;
- 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 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
- td->non_zero_count_cache[y][x] = nnz + block_dc;
- t_nnz[x] = l_nnz[y] = !!nnz;
- nnz_total += nnz;
- }
-
- // chroma blocks
- // TODO: what to do about dimensions? 2nd dim for luma is x,
- // but for chroma it's (y<<1)|x
- 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_total += nnz;
- }
-
- // if there were no coded coeffs despite the macroblock not being marked skip,
- // we MUST not do the inner loop filter and should not do IDCT
- // Since skip isn't used for bitstream prediction, just manually set it.
- if (!nnz_total)
- mb->skip = 1;
-}
-
-static av_always_inline
-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);
- if (!simple) {
- 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)
-{
- 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); \
- } 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);
-
- // 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);
- }
-}
-
-static av_always_inline
-int check_dc_pred8x8_mode(int mode, int mb_x, int mb_y)
-{
- if (!mb_x) {
- return mb_y ? TOP_DC_PRED8x8 : DC_128_PRED8x8;
- } 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)
-{
- if (!mb_x) {
- return mb_y ? VERT_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)
-{
- 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;
- 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 mode;
-}
-
-static av_always_inline
-int check_tm_pred4x4_mode(int mode, int mb_x, int mb_y)
-{
- if (!mb_x) {
- return mb_y ? VERT_VP8_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)
-{
- switch (mode) {
- case VERT_PRED:
- if (!mb_x && mb_y) {
- *copy_buf = 1;
- return mode;
- }
- /* fall-through */
- case DIAG_DOWN_LEFT_PRED:
- case VERT_LEFT_PRED:
- return !mb_y ? DC_127_PRED : mode;
- case HOR_PRED:
- if (!mb_y) {
- *copy_buf = 1;
- return mode;
- }
- /* fall-through */
- case HOR_UP_PRED:
- return !mb_x ? 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
- case DIAG_DOWN_RIGHT_PRED:
- case VERT_RIGHT_PRED:
- case HOR_DOWN_PRED:
- if (!mb_y || !mb_x)
- *copy_buf = 1;
- return mode;
- }
- return mode;
-}
-
-static av_always_inline
-void intra_predict(VP8Context *s, VP8ThreadData *td, uint8_t *dst[3],
- VP8Macroblock *mb, int mb_x, int mb_y)
-{
- 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],
- 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);
- }
- 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 };
-
- // all blocks on the right edge of the macroblock use bottom edge
- // the top macroblock for their topright edge
- uint8_t *tr_right = ptr - s->linesize + 16;
-
- // 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->skip)
- AV_ZERO128(td->non_zero_count_cache);
-
- for (y = 0; y < 4; y++) {
- 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];
-
- if ((y == 0 || x == 3) && mb_y == 0 && avctx->flags & CODEC_FLAG_EMU_EDGE) {
- 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];
- }
- }
- if (!(mb_x + x)) {
- copy_dst[11] =
- copy_dst[19] =
- copy_dst[27] =
- copy_dst[35] = 129U;
- } 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];
- }
- }
- } else {
- mode = intra4x4[x];
- }
- 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);
- }
-
- 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);
- else
- s->vp8dsp.vp8_idct_add(ptr+4*x, td->block[y][x], s->linesize);
- }
- topright += 4;
- }
-
- 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);
- }
- 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],
- s->linesize, s->uvlinesize, mb_x, mb_y, s->mb_width,
- s->filter.simple, 0);
-}
-
-static const uint8_t subpel_idx[3][8] = {
- { 0, 1, 2, 1, 2, 1, 2, 1 }, // nr. of left extra pixels,
- // also function pointer index
- { 0, 3, 5, 3, 5, 3, 5, 3 }, // nr. of extra pixels required
- { 0, 2, 3, 2, 3, 2, 3, 2 }, // nr. of right extra pixels
-};
-
-/**
- * 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 linesize size of a single line of plane data, including padding
- * @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,
- AVFrame *ref, const VP56mv *mv,
- int x_off, int y_off, int block_w, int block_h,
- int width, int height, int linesize,
- vp8_mc_func mc_func[3][3])
-{
- uint8_t *src = ref->data[0];
-
- if (AV_RN32A(mv)) {
-
- 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;
-
- // edge emulation
- ff_thread_await_progress(ref, (3 + y_off + block_h + subpel_idx[2][my]) >> 4, 0);
- src += y_off * linesize + x_off;
- if (x_off < mx_idx || x_off >= width - block_w - subpel_idx[2][mx] ||
- 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, 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 + linesize * my_idx;
- }
- mc_func[my_idx][mx_idx](dst, linesize, 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);
- }
-}
-
-/**
- * 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 linesize size of a single line of plane data, including padding
- * @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,
- AVFrame *ref, const VP56mv *mv, int x_off, int y_off,
- int block_w, int block_h, int width, int height, int linesize,
- vp8_mc_func mc_func[3][3])
-{
- uint8_t *src1 = ref->data[1], *src2 = ref->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];
-
- x_off += mv->x >> 3;
- y_off += mv->y >> 3;
-
- // edge emulation
- src1 += y_off * linesize + x_off;
- src2 += y_off * linesize + x_off;
- ff_thread_await_progress(ref, (3 + y_off + block_h + subpel_idx[2][my]) >> 3, 0);
- if (x_off < mx_idx || x_off >= width - block_w - subpel_idx[2][mx] ||
- 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, 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 + linesize * my_idx;
- mc_func[my_idx][mx_idx](dst1, linesize, src1, linesize, block_h, mx, my);
-
- s->vdsp.emulated_edge_mc(td->edge_emu_buffer, src2 - my_idx * linesize - mx_idx, 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 + linesize * my_idx;
- mc_func[my_idx][mx_idx](dst2, linesize, src2, 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);
- }
- } else {
- ff_thread_await_progress(ref, (3 + y_off + block_h) >> 3, 0);
- mc_func[0][0](dst1, linesize, src1 + y_off * linesize + x_off, linesize, block_h, 0, 0);
- mc_func[0][0](dst2, linesize, src2 + y_off * linesize + x_off, linesize, block_h, 0, 0);
- }
-}
-
-static av_always_inline
-void vp8_mc_part(VP8Context *s, VP8ThreadData *td, uint8_t *dst[3],
- AVFrame *ref_frame, int x_off, int y_off,
- int bx_off, int by_off,
- int block_w, int block_h,
- int width, int height, VP56mv *mv)
-{
- VP56mv uvmv = *mv;
-
- /* Y */
- vp8_mc_luma(s, td, dst[0] + by_off * s->linesize + bx_off,
- ref_frame, mv, x_off + bx_off, y_off + by_off,
- block_w, block_h, width, height, s->linesize,
- s->put_pixels_tab[block_w == 8]);
-
- /* U/V */
- if (s->profile == 3) {
- 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;
- 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,
- block_w, block_h, width, height, s->uvlinesize,
- s->put_pixels_tab[1 + (block_w == 4)]);
-}
-
-/* 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)
-{
- /* Don't prefetch refs that haven't been used very often this frame. */
- 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]->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);
- }
-}
-
-/**
- * Apply motion vectors to prediction buffer, chapter 18.
- */
-static av_always_inline
-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;
- AVFrame *ref = s->framep[mb->ref_frame];
- VP56mv *bmv = mb->bmv;
-
- switch (mb->partitioning) {
- case VP8_SPLITMVMODE_NONE:
- vp8_mc_part(s, td, dst, ref, x_off, y_off,
- 0, 0, 16, 16, width, height, &mb->mv);
- break;
- case VP8_SPLITMVMODE_4x4: {
- int x, y;
- VP56mv uvmv;
-
- /* 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,
- width, height, s->linesize,
- s->put_pixels_tab[2]);
- }
- }
-
- /* U/V */
- 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;
- 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,
- width, height, s->uvlinesize,
- s->put_pixels_tab[2]);
- }
- }
- break;
- }
- case VP8_SPLITMVMODE_16x8:
- vp8_mc_part(s, td, dst, ref, x_off, y_off,
- 0, 0, 16, 8, width, height, &bmv[0]);
- vp8_mc_part(s, td, dst, ref, x_off, y_off,
- 0, 8, 16, 8, width, height, &bmv[1]);
- break;
- case VP8_SPLITMVMODE_8x16:
- vp8_mc_part(s, td, dst, ref, x_off, y_off,
- 0, 0, 8, 16, width, height, &bmv[0]);
- vp8_mc_part(s, td, dst, ref, x_off, y_off,
- 8, 0, 8, 16, width, height, &bmv[1]);
- break;
- case VP8_SPLITMVMODE_8x8:
- vp8_mc_part(s, td, dst, ref, x_off, y_off,
- 0, 0, 8, 8, width, height, &bmv[0]);
- vp8_mc_part(s, td, dst, ref, x_off, y_off,
- 8, 0, 8, 8, width, height, &bmv[1]);
- vp8_mc_part(s, td, dst, ref, x_off, y_off,
- 0, 8, 8, 8, width, height, &bmv[2]);
- vp8_mc_part(s, td, dst, ref, x_off, y_off,
- 8, 8, 8, 8, width, height, &bmv[3]);
- break;
- }
-}
-
-static av_always_inline void idct_mb(VP8Context *s, VP8ThreadData *td,
- uint8_t *dst[3], VP8Macroblock *mb)
-{
- int x, y, ch;
-
- if (mb->mode != MODE_I4x4) {
- uint8_t *y_dst = dst[0];
- for (y = 0; y < 4; y++) {
- uint32_t nnz4 = AV_RL32(td->non_zero_count_cache[y]);
- if (nnz4) {
- 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);
- nnz4 >>= 8;
- if (!nnz4)
- break;
- }
- } else {
- s->vp8dsp.vp8_idct_dc_add4y(y_dst, td->block[y], 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]);
- if (nnz4) {
- 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);
- nnz4 >>= 8;
- if (!nnz4)
- goto chroma_idct_end;
- }
- ch_dst += 4*s->uvlinesize;
- }
- } else {
- s->vp8dsp.vp8_idct_dc_add4uv(ch_dst, td->block[4+ch], s->uvlinesize);
- }
- }
-chroma_idct_end: ;
- }
-}
-
-static av_always_inline void filter_level_for_mb(VP8Context *s, VP8Macroblock *mb, VP8FilterStrength *f )
-{
- int interior_limit, filter_level;
-
- if (s->segmentation.enabled) {
- filter_level = s->segmentation.filter_level[mb->segment];
- if (!s->segmentation.absolute_vals)
- filter_level += s->filter.level;
- } else
- filter_level = s->filter.level;
-
- if (s->lf_delta.enabled) {
- filter_level += s->lf_delta.ref[mb->ref_frame];
- filter_level += s->lf_delta.mode[mb->mode];
- }
-
- filter_level = av_clip_uintp2(filter_level, 6);
-
- interior_limit = filter_level;
- if (s->filter.sharpness) {
- interior_limit >>= (s->filter.sharpness + 3) >> 2;
- interior_limit = FFMIN(interior_limit, 9 - s->filter.sharpness);
- }
- interior_limit = FFMAX(interior_limit, 1);
-
- f->filter_level = filter_level;
- f->inner_limit = interior_limit;
- f->inner_filter = !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)
-{
- int mbedge_lim, bedge_lim, hev_thresh;
- int filter_level = f->filter_level;
- int inner_limit = f->inner_limit;
- int inner_filter = f->inner_filter;
- int linesize = s->linesize;
- int uvlinesize = s->uvlinesize;
- static const uint8_t hev_thresh_lut[2][64] = {
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2 }
- };
-
- if (!filter_level)
- return;
-
- bedge_lim = 2*filter_level + inner_limit;
- mbedge_lim = bedge_lim + 4;
-
- hev_thresh = hev_thresh_lut[s->keyframe][filter_level];
-
- if (mb_x) {
- 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,
- 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);
- }
-
- if (mb_y) {
- 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,
- mbedge_lim, inner_limit, hev_thresh);
- }
-
- if (inner_filter) {
- s->vp8dsp.vp8_v_loop_filter16y_inner(dst[0]+ 4*linesize,
- linesize, bedge_lim,
- inner_limit, hev_thresh);
- s->vp8dsp.vp8_v_loop_filter16y_inner(dst[0]+ 8*linesize,
- linesize, bedge_lim,
- inner_limit, hev_thresh);
- s->vp8dsp.vp8_v_loop_filter16y_inner(dst[0]+12*linesize,
- linesize, bedge_lim,
- inner_limit, hev_thresh);
- s->vp8dsp.vp8_v_loop_filter8uv_inner(dst[1] + 4 * uvlinesize,
- dst[2] + 4 * uvlinesize,
- uvlinesize, bedge_lim,
- inner_limit, hev_thresh);
- }
-}
-
-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_filter = f->inner_filter;
- int linesize = s->linesize;
-
- if (!filter_level)
- return;
-
- 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);
- }
-
- 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);
- }
-}
-
-static void release_queued_segmaps(VP8Context *s, int is_close)
-{
- int leave_behind = is_close ? 0 : !s->maps_are_invalid;
- while (s->num_maps_to_be_freed > leave_behind)
- av_freep(&s->segmentation_maps[--s->num_maps_to_be_freed]);
- s->maps_are_invalid = 0;
-}
-
-#define MARGIN (16 << 2)
-static void vp8_decode_mv_mb_modes(AVCodecContext *avctx, AVFrame *curframe,
- AVFrame *prev_frame)
-{
- VP8Context *s = avctx->priv_data;
- int mb_x, mb_y;
-
- 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;
-
- 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);
- decode_mb_mode(s, mb, mb_x, mb_y, curframe->ref_index[0] + mb_xy,
- prev_frame && prev_frame->ref_index[0] ? prev_frame->ref_index[0] + mb_xy : NULL, 1);
- s->mv_min.x -= 64;
- s->mv_max.x -= 64;
- }
- s->mv_min.y -= 64;
- s->mv_max.y -= 64;
- }
-}
-
-#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);
-#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)
-{
- 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 num_jobs = s->num_jobs;
- AVFrame *curframe = s->curframe, *prev_frame = s->prev_frame;
- VP56RangeCoder *c = &s->coeff_partition[mb_y & (s->num_coeff_partitions-1)];
- VP8Macroblock *mb;
- 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
- };
- 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);
- else {
- 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);
- }
-
- 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->linesize[i]-1] = 129;
- if (mb_y == 1) {
- s->top_border[0][15] = s->top_border[0][23] = s->top_border[0][31] = 129;
- }
- }
-
- 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++) {
- // 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);
- } else {
- check_thread_pos(td, prev_td, (s->mb_width+3) + (mb_x+1), mb_y-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);
-
- if (!s->mb_layout)
- decode_mb_mode(s, mb, mb_x, mb_y, curframe->ref_index[0] + mb_xy,
- prev_frame && prev_frame->ref_index[0] ? prev_frame->ref_index[0] + mb_xy : NULL, 0);
-
- 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);
-
- if (mb->mode <= MODE_I4x4)
- intra_predict(s, td, dst, mb, mb_x, mb_y);
- else
- inter_predict(s, td, dst, mb, mb_x, mb_y);
-
- prefetch_motion(s, mb, mb_x, mb_y, mb_xy, VP56_FRAME_GOLDEN);
-
- if (!mb->skip) {
- idct_mb(s, td, dst, mb);
- } else {
- 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
- if (mb->mode != MODE_I4x4 && mb->mode != VP8_MVMODE_SPLIT) {
- td->left_nnz[8] = 0;
- s->top_nnz[mb_x][8] = 0;
- }
- }
-
- if (s->deblock_filter)
- filter_level_for_mb(s, mb, &td->filter_strength[mb_x]);
-
- 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);
- else
- 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;
- 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);
- } else {
- update_pos(td, mb_y, mb_x);
- }
- }
-}
-
-static void vp8_filter_mb_row(AVCodecContext *avctx, void *tdata,
- int jobnr, int threadnr)
-{
- 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;
- AVFrame *curframe = s->curframe;
- 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
- };
-
- if (s->mb_layout == 1)
- mb = s->macroblocks_base + ((s->mb_width+1)*(mb_y + 1) + 1);
- else
- 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];
-
- 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 (next_td != td)
- 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);
- else
- 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);
- dst[0] += 16;
- dst[1] += 8;
- dst[2] += 8;
-
- 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)
-{
- VP8Context *s = avctx->priv_data;
- VP8ThreadData *td = &s->thread_data[jobnr];
- VP8ThreadData *next_td = NULL, *prev_td = NULL;
- AVFrame *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 (s->deblock_filter)
- vp8_filter_mb_row(avctx, tdata, jobnr, threadnr);
- update_pos(td, mb_y, INT_MAX & 0xFFFF);
-
- s->mv_min.y -= 64;
- s->mv_max.y -= 64;
-
- if (avctx->active_thread_type == FF_THREAD_FRAME)
- ff_thread_report_progress(curframe, mb_y, 0);
- }
-
- return 0;
-}
-
-static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
- AVPacket *avpkt)
-{
- VP8Context *s = avctx->priv_data;
- int ret, i, referenced, num_jobs;
- enum AVDiscard skip_thresh;
- AVFrame *av_uninit(curframe), *prev_frame;
-
- release_queued_segmaps(s, 0);
-
- if ((ret = decode_frame_header(s, avpkt->data, avpkt->size)) < 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;
-
- skip_thresh = !referenced ? AVDISCARD_NONREF :
- !s->keyframe ? AVDISCARD_NONKEY : AVDISCARD_ALL;
-
- if (avctx->skip_frame >= skip_thresh) {
- s->invisible = 1;
- memcpy(&s->next_framep[0], &s->framep[0], sizeof(s->framep[0]) * 4);
- goto skip_decode;
- }
- s->deblock_filter = s->filter.level && avctx->skip_loop_filter < skip_thresh;
-
- // release no longer referenced frames
- for (i = 0; i < 5; i++)
- if (s->frames[i].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_GOLDEN2])
- vp8_release_frame(s, &s->frames[i], 1, 0);
-
- // 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->data[0])
- vp8_release_frame(s, curframe, 1, 0);
-
- // 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_GOLDEN2])) {
- av_log(avctx, AV_LOG_WARNING, "Discarding interframe without a prior keyframe!\n");
- ret = AVERROR_INVALIDDATA;
- goto err;
- }
-
- curframe->key_frame = s->keyframe;
- curframe->pict_type = s->keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
- curframe->reference = referenced ? 3 : 0;
- if ((ret = vp8_alloc_frame(s, curframe))) {
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed!\n");
- 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) {
- s->next_framep[VP56_FRAME_PREVIOUS] = curframe;
- } else {
- s->next_framep[VP56_FRAME_PREVIOUS] = s->framep[VP56_FRAME_PREVIOUS];
- }
- s->next_framep[VP56_FRAME_CURRENT] = curframe;
-
- ff_thread_finish_setup(avctx);
-
- s->linesize = curframe->linesize[0];
- s->uvlinesize = curframe->linesize[1];
-
- if (!s->thread_data[0].edge_emu_buffer)
- for (i = 0; i < MAX_THREADS; i++)
- s->thread_data[i].edge_emu_buffer = av_malloc(21*s->linesize);
-
- 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));
- if (!s->mb_layout && s->keyframe)
- 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));
-
-
- // 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, 1, 0);
-
- if (s->mb_layout == 1)
- vp8_decode_mv_mb_modes(avctx, curframe, prev_frame);
-
- if (avctx->active_thread_type == FF_THREAD_FRAME)
- num_jobs = 1;
- else
- num_jobs = FFMIN(s->num_coeff_partitions, avctx->thread_count);
- s->num_jobs = num_jobs;
- s->curframe = curframe;
- s->prev_frame = prev_frame;
- s->mv_min.y = -MARGIN;
- 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;
- }
- avctx->execute2(avctx, vp8_decode_mb_row_sliced, s->thread_data, NULL, num_jobs);
-
- ff_thread_report_progress(curframe, INT_MAX, 0);
- memcpy(&s->framep[0], &s->next_framep[0], sizeof(s->framep[0]) * 4);
-
-skip_decode:
- // if future frames don't use the updated probabilities,
- // reset them to the values we saved
- if (!s->update_probabilities)
- s->prob[0] = s->prob[1];
-
- if (!s->invisible) {
- *(AVFrame*)data = *curframe;
- *got_frame = 1;
- }
-
- return avpkt->size;
-err:
- memcpy(&s->next_framep[0], &s->framep[0], sizeof(s->framep[0]) * 4);
- return ret;
-}
-
-static av_cold int vp8_decode_init(AVCodecContext *avctx)
-{
- VP8Context *s = avctx->priv_data;
-
- s->avctx = avctx;
- avctx->pix_fmt = AV_PIX_FMT_YUV420P;
-
- ff_videodsp_init(&s->vdsp, 8);
- ff_h264_pred_init(&s->hpc, AV_CODEC_ID_VP8, 8, 1);
- ff_vp8dsp_init(&s->vp8dsp);
-
- return 0;
-}
-
-static av_cold int vp8_decode_free(AVCodecContext *avctx)
-{
- vp8_decode_flush_impl(avctx, 0, 1, 1);
- release_queued_segmaps(avctx->priv_data, 1);
- return 0;
-}
-
-static av_cold int vp8_decode_init_thread_copy(AVCodecContext *avctx)
-{
- VP8Context *s = avctx->priv_data;
-
- s->avctx = avctx;
-
- return 0;
-}
-
-#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)
-{
- VP8Context *s = dst->priv_data, *s_src = src->priv_data;
-
- if (s->macroblocks_base &&
- (s_src->mb_width != s->mb_width || s_src->mb_height != s->mb_height)) {
- free_buffers(s);
- s->maps_are_invalid = 1;
- s->mb_width = s_src->mb_width;
- s->mb_height = s_src->mb_height;
- }
-
- s->prob[0] = s_src->prob[!s_src->update_probabilities];
- s->segmentation = s_src->segmentation;
- s->lf_delta = s_src->lf_delta;
- memcpy(s->sign_bias, s_src->sign_bias, sizeof(s->sign_bias));
-
- memcpy(&s->frames, &s_src->frames, sizeof(s->frames));
- s->framep[0] = REBASE(s_src->next_framep[0]);
- s->framep[1] = REBASE(s_src->next_framep[1]);
- s->framep[2] = REBASE(s_src->next_framep[2]);
- s->framep[3] = REBASE(s_src->next_framep[3]);
-
- return 0;
-}
-
-AVCodec ff_vp8_decoder = {
- .name = "vp8",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_VP8,
- .priv_data_size = sizeof(VP8Context),
- .init = vp8_decode_init,
- .close = vp8_decode_free,
- .decode = vp8_decode_frame,
- .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS | CODEC_CAP_SLICE_THREADS,
- .flush = vp8_decode_flush,
- .long_name = NULL_IF_CONFIG_SMALL("On2 VP8"),
- .init_thread_copy = ONLY_IF_THREADS_ENABLED(vp8_decode_init_thread_copy),
- .update_thread_context = ONLY_IF_THREADS_ENABLED(vp8_decode_update_thread_context),
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/vp8.h b/src/thirdparty/ffmpeg/libavcodec/vp8.h
deleted file mode 100644
index d2cadde74..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vp8.h
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * 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
- *
- * 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_VP8_H
-#define AVCODEC_VP8_H
-
-#include "vp56.h"
-#include "vp56data.h"
-#include "vp8dsp.h"
-#include "h264pred.h"
-#if HAVE_PTHREADS
-#include <pthread.h>
-#elif HAVE_W32THREADS
-#include "w32pthreads.h"
-#elif HAVE_OS2THREADS
-#include "os2threads.h"
-#endif
-
-#define VP8_MAX_QUANT 127
-
-enum dct_token {
- DCT_0,
- DCT_1,
- DCT_2,
- DCT_3,
- DCT_4,
- DCT_CAT1,
- DCT_CAT2,
- DCT_CAT3,
- DCT_CAT4,
- DCT_CAT5,
- DCT_CAT6,
- DCT_EOB,
-
- NUM_DCT_TOKENS
-};
-
-// used to signal 4x4 intra pred in luma MBs
-#define MODE_I4x4 4
-
-enum inter_mvmode {
- VP8_MVMODE_ZERO = MODE_I4x4 + 1,
- VP8_MVMODE_MV,
- VP8_MVMODE_SPLIT
-};
-
-enum inter_splitmvmode {
- VP8_SPLITMVMODE_16x8 = 0, ///< 2 16x8 blocks (vertical)
- VP8_SPLITMVMODE_8x16, ///< 2 8x16 blocks (horizontal)
- VP8_SPLITMVMODE_8x8, ///< 2x2 blocks of 8x8px each
- VP8_SPLITMVMODE_4x4, ///< 4x4 blocks of 4x4px each
- VP8_SPLITMVMODE_NONE, ///< (only used in prediction) no split MVs
-};
-
-typedef struct VP8FilterStrength {
- uint8_t filter_level;
- uint8_t inner_limit;
- uint8_t inner_filter;
-} VP8FilterStrength;
-
-typedef struct VP8Macroblock {
- uint8_t skip;
- // 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;
- uint8_t partitioning;
- uint8_t chroma_pred_mode;
- uint8_t segment;
- uint8_t intra4x4_pred_mode_mb[16];
- uint8_t intra4x4_pred_mode_top[4];
- VP56mv mv;
- VP56mv bmv[16];
-} VP8Macroblock;
-
-typedef struct VP8ThreadData {
- DECLARE_ALIGNED(16, int16_t, block)[6][4][16];
- DECLARE_ALIGNED(16, int16_t, block_dc)[16];
- /**
- * This is the index plus one of the last non-zero coeff
- * for each of the blocks in the current macroblock.
- * So, 0 -> no coeffs
- * 1 -> dc-only (special transform)
- * 2+-> full transform
- */
- DECLARE_ALIGNED(16, uint8_t, non_zero_count_cache)[6][4];
- /**
- * For coeff decode, we need to know whether the above block had non-zero
- * coefficients. This means for each macroblock, we need data for 4 luma
- * blocks, 2 u blocks, 2 v blocks, and the luma dc block, for a total of 9
- * per macroblock. We keep the last row in top_nnz.
- */
- DECLARE_ALIGNED(8, uint8_t, left_nnz)[9];
- int thread_nr;
-#if HAVE_THREADS
- pthread_mutex_t lock;
- 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.
- uint8_t *edge_emu_buffer;
- VP8FilterStrength *filter_strength;
-} VP8ThreadData;
-
-#define MAX_THREADS 8
-typedef struct VP8Context {
- VP8ThreadData *thread_data;
- AVCodecContext *avctx;
- AVFrame *framep[4];
- AVFrame *next_framep[4];
- AVFrame *curframe;
- AVFrame *prev_frame;
-
- uint16_t mb_width; /* number of horizontal MB */
- uint16_t mb_height; /* number of vertical MB */
- int linesize;
- int uvlinesize;
-
- uint8_t keyframe;
- uint8_t deblock_filter;
- uint8_t mbskip_enabled;
- uint8_t profile;
- VP56mv mv_min;
- VP56mv mv_max;
-
- int8_t sign_bias[4]; ///< one state [0, 1] per ref frame type
- int ref_count[3];
-
- /**
- * Base parameters for segmentation, i.e. per-macroblock parameters.
- * These must be kept unchanged even if segmentation is not used for
- * a frame, since the values persist between interframes.
- */
- struct {
- uint8_t enabled;
- uint8_t absolute_vals;
- uint8_t update_map;
- int8_t base_quant[4];
- int8_t filter_level[4]; ///< base loop filter level
- } segmentation;
-
- struct {
- uint8_t simple;
- uint8_t level;
- uint8_t sharpness;
- } filter;
-
- VP8Macroblock *macroblocks;
-
- uint8_t *intra4x4_pred_mode_top;
- uint8_t intra4x4_pred_mode_left[4];
-
- /**
- * Macroblocks can have one of 4 different quants in a frame when
- * segmentation is enabled.
- * If segmentation is disabled, only the first segment's values are used.
- */
- struct {
- // [0] - DC qmul [1] - AC qmul
- int16_t luma_qmul[2];
- int16_t luma_dc_qmul[2]; ///< luma dc-only block quant
- int16_t chroma_qmul[2];
- } qmat[4];
-
- struct {
- uint8_t enabled; ///< whether each mb can have a different strength based on mode/ref
-
- /**
- * filter strength adjustment for the following macroblock modes:
- * [0-3] - i16x16 (always zero)
- * [4] - i4x4
- * [5] - zero mv
- * [6] - inter modes except for zero or split mv
- * [7] - split mv
- * i16x16 modes never have any adjustment
- */
- int8_t mode[VP8_MVMODE_SPLIT+1];
-
- /**
- * filter strength adjustment for macroblocks that reference:
- * [0] - intra / VP56_FRAME_CURRENT
- * [1] - VP56_FRAME_PREVIOUS
- * [2] - VP56_FRAME_GOLDEN
- * [3] - altref / VP56_FRAME_GOLDEN2
- */
- int8_t ref[4];
- } lf_delta;
-
- uint8_t (*top_border)[16+8+8];
- uint8_t (*top_nnz)[9];
-
- VP56RangeCoder c; ///< header context, includes mb modes and motion vectors
-
- /**
- * These are all of the updatable probabilities for binary decisions.
- * They are only implictly reset on keyframes, making it quite likely
- * for an interframe to desync if a prior frame's header was corrupt
- * or missing outright!
- */
- struct {
- uint8_t segmentid[3];
- uint8_t mbskip;
- uint8_t intra;
- uint8_t last;
- uint8_t golden;
- uint8_t pred16x16[4];
- uint8_t pred8x8c[3];
- uint8_t token[4][16][3][NUM_DCT_TOKENS-1];
- uint8_t mvc[2][19];
- } prob[2];
-
- VP8Macroblock *macroblocks_base;
- int invisible;
- int update_last; ///< update VP56_FRAME_PREVIOUS with the current one
- int update_golden; ///< VP56_FRAME_NONE if not updated, or which frame to copy if so
- int update_altref;
-
- /**
- * If this flag is not set, all the probability updates
- * are discarded after this frame is decoded.
- */
- int update_probabilities;
-
- /**
- * All coefficients are contained in separate arith coding contexts.
- * There can be 1, 2, 4, or 8 of these after the header context.
- */
- int num_coeff_partitions;
- VP56RangeCoder coeff_partition[8];
- VideoDSPContext vdsp;
- VP8DSPContext vp8dsp;
- H264PredContext hpc;
- vp8_mc_func put_pixels_tab[3][3][3];
- AVFrame frames[5];
-
- /**
- * A list of segmentation_map buffers that are to be free()'ed in
- * the next decoding iteration. We can't free() them right away
- * because the map may still be used by subsequent decoding threads.
- * Unused if frame threading is off.
- */
- uint8_t *segmentation_maps[5];
- int num_maps_to_be_freed;
- int maps_are_invalid;
- int num_jobs;
- /**
- * This describes the macroblock memory layout.
- * 0 -> Only width+height*2+1 macroblocks allocated (frame/single thread).
- * 1 -> Macroblocks for entire frame alloced (sliced thread).
- */
- int mb_layout;
-} VP8Context;
-
-#endif /* AVCODEC_VP8_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/vp8data.h b/src/thirdparty/ffmpeg/libavcodec/vp8data.h
deleted file mode 100644
index dfd7384dd..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vp8data.h
+++ /dev/null
@@ -1,691 +0,0 @@
-/*
- * Copyright (C) 2010 David Conrad
- * 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
- */
-
-/**
- * @file
- * VP8 compatible video decoder
- */
-
-#ifndef AVCODEC_VP8DATA_H
-#define AVCODEC_VP8DATA_H
-
-#include "vp8.h"
-#include "h264pred.h"
-
-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_inter[4][2] =
-{
- { -DC_PRED8x8, 1 }, // '0'
- { 2, 3 },
- { -VERT_PRED8x8, -HOR_PRED8x8 }, // '100', '101'
- { -PLANE_PRED8x8, -MODE_I4x4 }, // '110', '111'
-};
-
-static const int vp8_mode_contexts[6][4] = {
- { 7, 1, 1, 143 },
- { 14, 18, 14, 107 },
- { 135, 64, 57, 68 },
- { 60, 56, 128, 65 },
- { 159, 134, 128, 34 },
- { 234, 188, 128, 28 },
-};
-
-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 }
-};
-
-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 }
-};
-
-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_submv_prob[5][3] = {
- { 147, 136, 18 },
- { 106, 145, 1 },
- { 179, 121, 1 },
- { 223, 1, 34 },
- { 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 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 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] =
-{
- {
- { 39, 53, 200, 87, 26, 21, 43, 232, 171 },
- { 56, 34, 51, 104, 114, 102, 29, 93, 77 },
- { 88, 88, 147, 150, 42, 46, 45, 196, 205 },
- { 107, 54, 32, 26, 51, 1, 81, 43, 31 },
- { 39, 28, 85, 171, 58, 165, 90, 98, 64 },
- { 34, 22, 116, 206, 23, 34, 43, 166, 73 },
- { 34, 19, 21, 102, 132, 188, 16, 76, 124 },
- { 68, 25, 106, 22, 64, 171, 36, 225, 114 },
- { 62, 18, 78, 95, 85, 57, 50, 48, 51 },
- { 43, 97, 183, 117, 85, 38, 35, 179, 61 },
- },
- {
- { 112, 113, 77, 85, 179, 255, 38, 120, 114 },
- { 40, 42, 1, 196, 245, 209, 10, 25, 109 },
- { 193, 101, 35, 159, 215, 111, 89, 46, 111 },
- { 100, 80, 8, 43, 154, 1, 51, 26, 71 },
- { 88, 43, 29, 140, 166, 213, 37, 43, 154 },
- { 61, 63, 30, 155, 67, 45, 68, 1, 209 },
- { 41, 40, 5, 102, 211, 183, 4, 1, 221 },
- { 142, 78, 78, 16, 255, 128, 34, 197, 171 },
- { 51, 50, 17, 168, 209, 192, 23, 25, 82 },
- { 60, 148, 31, 172, 219, 228, 21, 18, 111 },
- },
- {
- { 175, 69, 143, 80, 85, 82, 72, 155, 103 },
- { 56, 58, 10, 171, 218, 189, 17, 13, 152 },
- { 231, 120, 48, 89, 115, 113, 120, 152, 112 },
- { 144, 71, 10, 38, 171, 213, 144, 34, 26 },
- { 114, 26, 17, 163, 44, 195, 21, 10, 173 },
- { 121, 24, 80, 195, 26, 62, 44, 64, 85 },
- { 63, 20, 8, 114, 114, 208, 12, 9, 226 },
- { 170, 46, 55, 19, 136, 160, 33, 206, 71 },
- { 81, 40, 11, 96, 182, 84, 29, 16, 36 },
- { 152, 179, 64, 126, 170, 118, 46, 70, 95 },
- },
- {
- { 75, 79, 123, 47, 51, 128, 81, 171, 1 },
- { 57, 17, 5, 71, 102, 57, 53, 41, 49 },
- { 125, 98, 42, 88, 104, 85, 117, 175, 82 },
- { 115, 21, 2, 10, 102, 255, 166, 23, 6 },
- { 38, 33, 13, 121, 57, 73, 26, 1, 85 },
- { 41, 10, 67, 138, 77, 110, 90, 47, 114 },
- { 57, 18, 10, 102, 102, 213, 34, 20, 43 },
- { 101, 29, 16, 10, 85, 128, 101, 196, 26 },
- { 117, 20, 15, 36, 163, 128, 68, 1, 26 },
- { 95, 84, 53, 89, 128, 100, 113, 101, 45 },
- },
- {
- { 63, 59, 90, 180, 59, 166, 93, 73, 154 },
- { 40, 40, 21, 116, 143, 209, 34, 39, 175 },
- { 138, 31, 36, 171, 27, 166, 38, 44, 229 },
- { 57, 46, 22, 24, 128, 1, 54, 17, 37 },
- { 47, 15, 16, 183, 34, 223, 49, 45, 183 },
- { 46, 17, 33, 183, 6, 98, 15, 32, 183 },
- { 40, 3, 9, 115, 51, 192, 18, 6, 223 },
- { 65, 32, 73, 115, 28, 128, 23, 128, 205 },
- { 87, 37, 9, 115, 59, 77, 64, 21, 47 },
- { 67, 87, 58, 169, 82, 115, 26, 59, 179 },
- },
- {
- { 54, 57, 112, 184, 5, 41, 38, 166, 213 },
- { 30, 34, 26, 133, 152, 116, 10, 32, 134 },
- { 104, 55, 44, 218, 9, 54, 53, 130, 226 },
- { 75, 32, 12, 51, 192, 255, 160, 43, 51 },
- { 39, 19, 53, 221, 26, 114, 32, 73, 255 },
- { 31, 9, 65, 234, 2, 15, 1, 118, 73 },
- { 56, 21, 23, 111, 59, 205, 45, 37, 192 },
- { 88, 31, 35, 67, 102, 85, 55, 186, 85 },
- { 55, 38, 70, 124, 73, 102, 1, 34, 98 },
- { 64, 90, 70, 205, 40, 41, 23, 26, 57 },
- },
- {
- { 86, 40, 64, 135, 148, 224, 45, 183, 128 },
- { 22, 26, 17, 131, 240, 154, 14, 1, 209 },
- { 164, 50, 31, 137, 154, 133, 25, 35, 218 },
- { 83, 12, 13, 54, 192, 255, 68, 47, 28 },
- { 45, 16, 21, 91, 64, 222, 7, 1, 197 },
- { 56, 21, 39, 155, 60, 138, 23, 102, 213 },
- { 18, 11, 7, 63, 144, 171, 4, 4, 246 },
- { 85, 26, 85, 85, 128, 128, 32, 146, 171 },
- { 35, 27, 10, 146, 174, 171, 12, 26, 128 },
- { 51, 103, 44, 131, 131, 123, 31, 6, 158 },
- },
- {
- { 68, 45, 128, 34, 1, 47, 11, 245, 171 },
- { 62, 17, 19, 70, 146, 85, 55, 62, 70 },
- { 102, 61, 71, 37, 34, 53, 31, 243, 192 },
- { 75, 15, 9, 9, 64, 255, 184, 119, 16 },
- { 37, 43, 37, 154, 100, 163, 85, 160, 1 },
- { 63, 9, 92, 136, 28, 64, 32, 201, 85 },
- { 56, 8, 17, 132, 137, 255, 55, 116, 128 },
- { 86, 6, 28, 5, 64, 255, 25, 248, 1 },
- { 58, 15, 20, 82, 135, 57, 26, 121, 40 },
- { 69, 60, 71, 38, 73, 119, 28, 222, 37 },
- },
- {
- { 101, 75, 128, 139, 118, 146, 116, 128, 85 },
- { 56, 41, 15, 176, 236, 85, 37, 9, 62 },
- { 190, 80, 35, 99, 180, 80, 126, 54, 45 },
- { 146, 36, 19, 30, 171, 255, 97, 27, 20 },
- { 71, 30, 17, 119, 118, 255, 17, 18, 138 },
- { 101, 38, 60, 138, 55, 70, 43, 26, 142 },
- { 32, 41, 20, 117, 151, 142, 20, 21, 163 },
- { 138, 45, 61, 62, 219, 1, 81, 188, 64 },
- { 112, 19, 12, 61, 195, 128, 48, 4, 24 },
- { 85, 126, 47, 87, 176, 51, 41, 20, 32 },
- },
- {
- { 66, 102, 167, 99, 74, 62, 40, 234, 128 },
- { 41, 53, 9, 178, 241, 141, 26, 8, 107 },
- { 134, 183, 89, 137, 98, 101, 106, 165, 148 },
- { 104, 79, 12, 27, 217, 255, 87, 17, 7 },
- { 74, 43, 26, 146, 73, 166, 49, 23, 157 },
- { 65, 38, 105, 160, 51, 52, 31, 115, 128 },
- { 47, 41, 14, 110, 182, 183, 21, 17, 194 },
- { 87, 68, 71, 44, 114, 51, 15, 186, 23 },
- { 66, 45, 25, 102, 197, 189, 23, 18, 22 },
- { 72, 187, 100, 130, 157, 111, 32, 75, 80 },
- },
-};
-
-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] =
-{
- 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 };
-
-// only used for cat3 and above; cat 1 and 2 are referenced directly
-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] =
-{
- {
- {
- { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
- },
- {
- { 253, 136, 254, 255, 228, 219, 128, 128, 128, 128, 128 },
- { 189, 129, 242, 255, 227, 213, 255, 219, 128, 128, 128 },
- { 106, 126, 227, 252, 214, 209, 255, 255, 128, 128, 128 },
- },
- {
- { 1, 98, 248, 255, 236, 226, 255, 255, 128, 128, 128 },
- { 181, 133, 238, 254, 221, 234, 255, 154, 128, 128, 128 },
- { 78, 134, 202, 247, 198, 180, 255, 219, 128, 128, 128 },
- },
- {
- { 1, 185, 249, 255, 243, 255, 128, 128, 128, 128, 128 },
- { 184, 150, 247, 255, 236, 224, 128, 128, 128, 128, 128 },
- { 77, 110, 216, 255, 236, 230, 128, 128, 128, 128, 128 },
- },
- {
- { 1, 101, 251, 255, 241, 255, 128, 128, 128, 128, 128 },
- { 170, 139, 241, 252, 236, 209, 255, 255, 128, 128, 128 },
- { 37, 116, 196, 243, 228, 255, 255, 255, 128, 128, 128 },
- },
- {
- { 1, 204, 254, 255, 245, 255, 128, 128, 128, 128, 128 },
- { 207, 160, 250, 255, 238, 128, 128, 128, 128, 128, 128 },
- { 102, 103, 231, 255, 211, 171, 128, 128, 128, 128, 128 },
- },
- {
- { 1, 152, 252, 255, 240, 255, 128, 128, 128, 128, 128 },
- { 177, 135, 243, 255, 234, 225, 128, 128, 128, 128, 128 },
- { 80, 129, 211, 255, 194, 224, 128, 128, 128, 128, 128 },
- },
- {
- { 1, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 246, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 255, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
- },
- },
- {
- {
- { 198, 35, 237, 223, 193, 187, 162, 160, 145, 155, 62 },
- { 131, 45, 198, 221, 172, 176, 220, 157, 252, 221, 1 },
- { 68, 47, 146, 208, 149, 167, 221, 162, 255, 223, 128 },
- },
- {
- { 1, 149, 241, 255, 221, 224, 255, 255, 128, 128, 128 },
- { 184, 141, 234, 253, 222, 220, 255, 199, 128, 128, 128 },
- { 81, 99, 181, 242, 176, 190, 249, 202, 255, 255, 128 },
- },
- {
- { 1, 129, 232, 253, 214, 197, 242, 196, 255, 255, 128 },
- { 99, 121, 210, 250, 201, 198, 255, 202, 128, 128, 128 },
- { 23, 91, 163, 242, 170, 187, 247, 210, 255, 255, 128 },
- },
- {
- { 1, 200, 246, 255, 234, 255, 128, 128, 128, 128, 128 },
- { 109, 178, 241, 255, 231, 245, 255, 255, 128, 128, 128 },
- { 44, 130, 201, 253, 205, 192, 255, 255, 128, 128, 128 },
- },
- {
- { 1, 132, 239, 251, 219, 209, 255, 165, 128, 128, 128 },
- { 94, 136, 225, 251, 218, 190, 255, 255, 128, 128, 128 },
- { 22, 100, 174, 245, 186, 161, 255, 199, 128, 128, 128 },
- },
- {
- { 1, 182, 249, 255, 232, 235, 128, 128, 128, 128, 128 },
- { 124, 143, 241, 255, 227, 234, 128, 128, 128, 128, 128 },
- { 35, 77, 181, 251, 193, 211, 255, 205, 128, 128, 128 },
- },
- {
- { 1, 157, 247, 255, 236, 231, 255, 255, 128, 128, 128 },
- { 121, 141, 235, 255, 225, 227, 255, 255, 128, 128, 128 },
- { 45, 99, 188, 251, 195, 217, 255, 224, 128, 128, 128 },
- },
- {
- { 1, 1, 251, 255, 213, 255, 128, 128, 128, 128, 128 },
- { 203, 1, 248, 255, 255, 128, 128, 128, 128, 128, 128 },
- { 137, 1, 177, 255, 224, 255, 128, 128, 128, 128, 128 },
- },
- },
- {
- {
- { 253, 9, 248, 251, 207, 208, 255, 192, 128, 128, 128 },
- { 175, 13, 224, 243, 193, 185, 249, 198, 255, 255, 128 },
- { 73, 17, 171, 221, 161, 179, 236, 167, 255, 234, 128 },
- },
- {
- { 1, 95, 247, 253, 212, 183, 255, 255, 128, 128, 128 },
- { 239, 90, 244, 250, 211, 209, 255, 255, 128, 128, 128 },
- { 155, 77, 195, 248, 188, 195, 255, 255, 128, 128, 128 },
- },
- {
- { 1, 24, 239, 251, 218, 219, 255, 205, 128, 128, 128 },
- { 201, 51, 219, 255, 196, 186, 128, 128, 128, 128, 128 },
- { 69, 46, 190, 239, 201, 218, 255, 228, 128, 128, 128 },
- },
- {
- { 1, 191, 251, 255, 255, 128, 128, 128, 128, 128, 128 },
- { 223, 165, 249, 255, 213, 255, 128, 128, 128, 128, 128 },
- { 141, 124, 248, 255, 255, 128, 128, 128, 128, 128, 128 },
- },
- {
- { 1, 16, 248, 255, 255, 128, 128, 128, 128, 128, 128 },
- { 190, 36, 230, 255, 236, 255, 128, 128, 128, 128, 128 },
- { 149, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- },
- {
- { 1, 226, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 247, 192, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 240, 128, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- },
- {
- { 1, 134, 252, 255, 255, 128, 128, 128, 128, 128, 128 },
- { 213, 62, 250, 255, 255, 128, 128, 128, 128, 128, 128 },
- { 55, 93, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- },
- {
- { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 },
- },
- },
- {
- {
- { 202, 24, 213, 235, 186, 191, 220, 160, 240, 175, 255 },
- { 126, 38, 182, 232, 169, 184, 228, 174, 255, 187, 128 },
- { 61, 46, 138, 219, 151, 178, 240, 170, 255, 216, 128 },
- },
- {
- { 1, 112, 230, 250, 199, 191, 247, 159, 255, 255, 128 },
- { 166, 109, 228, 252, 211, 215, 255, 174, 128, 128, 128 },
- { 39, 77, 162, 232, 172, 180, 245, 178, 255, 255, 128 },
- },
- {
- { 1, 52, 220, 246, 198, 199, 249, 220, 255, 255, 128 },
- { 124, 74, 191, 243, 183, 193, 250, 221, 255, 255, 128 },
- { 24, 71, 130, 219, 154, 170, 243, 182, 255, 255, 128 },
- },
- {
- { 1, 182, 225, 249, 219, 240, 255, 224, 128, 128, 128 },
- { 149, 150, 226, 252, 216, 205, 255, 171, 128, 128, 128 },
- { 28, 108, 170, 242, 183, 194, 254, 223, 255, 255, 128 },
- },
- {
- { 1, 81, 230, 252, 204, 203, 255, 192, 128, 128, 128 },
- { 123, 102, 209, 247, 188, 196, 255, 233, 128, 128, 128 },
- { 20, 95, 153, 243, 164, 173, 255, 203, 128, 128, 128 },
- },
- {
- { 1, 222, 248, 255, 216, 213, 128, 128, 128, 128, 128 },
- { 168, 175, 246, 252, 235, 205, 255, 255, 128, 128, 128 },
- { 47, 116, 215, 255, 211, 212, 255, 255, 128, 128, 128 },
- },
- {
- { 1, 121, 236, 253, 212, 214, 255, 255, 128, 128, 128 },
- { 141, 84, 213, 252, 201, 202, 255, 219, 128, 128, 128 },
- { 42, 80, 160, 240, 162, 185, 255, 205, 128, 128, 128 },
- },
- {
- { 1, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 244, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- { 238, 1, 255, 128, 128, 128, 128, 128, 128, 128, 128 },
- },
- },
-};
-
-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 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- },
- {
- { 176, 246, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 223, 241, 252, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 249, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255 },
- },
- {
- { 255, 244, 252, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 234, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- },
- {
- { 255, 246, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 239, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- },
- {
- { 255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 251, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- },
- {
- { 255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 251, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- },
- {
- { 255, 254, 253, 255, 254, 255, 255, 255, 255, 255, 255 },
- { 250, 255, 254, 255, 254, 255, 255, 255, 255, 255, 255 },
- { 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- },
- {
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- },
- },
- {
- {
- { 217, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 225, 252, 241, 253, 255, 255, 254, 255, 255, 255, 255 },
- { 234, 250, 241, 250, 253, 255, 253, 254, 255, 255, 255 },
- },
- {
- { 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 223, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 238, 253, 254, 254, 255, 255, 255, 255, 255, 255, 255 },
- },
- {
- { 255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 249, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- },
- {
- { 255, 253, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 247, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- },
- {
- { 255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 252, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- },
- {
- { 255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- },
- {
- { 255, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- },
- {
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- },
- },
- {
- {
- { 186, 251, 250, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 234, 251, 244, 254, 255, 255, 255, 255, 255, 255, 255 },
- { 251, 251, 243, 253, 254, 255, 254, 255, 255, 255, 255 },
- },
- {
- { 255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 236, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 251, 253, 253, 254, 254, 255, 255, 255, 255, 255, 255 },
- },
- {
- { 255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- },
- {
- { 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- },
- {
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- },
- {
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- },
- {
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- },
- {
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- },
- },
- {
- {
- { 248, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 250, 254, 252, 254, 255, 255, 255, 255, 255, 255, 255 },
- { 248, 254, 249, 253, 255, 255, 255, 255, 255, 255, 255 },
- },
- {
- { 255, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 246, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 252, 254, 251, 254, 254, 255, 255, 255, 255, 255, 255 },
- },
- {
- { 255, 254, 252, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 248, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 253, 255, 254, 254, 255, 255, 255, 255, 255, 255, 255 },
- },
- {
- { 255, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 245, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 253, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- },
- {
- { 255, 251, 253, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 252, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- },
- {
- { 255, 252, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 249, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255 },
- },
- {
- { 255, 255, 253, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- },
- {
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 },
- },
- },
-};
-
-// 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,
-};
-
-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,
- 44, 45, 46, 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, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
- 91, 93, 95, 96, 98, 100, 101, 102, 104, 106, 108, 110, 112, 114, 116, 118,
- 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] =
-{
- 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,
- 52, 53, 54, 55, 56, 57, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76,
- 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108,
- 110, 112, 114, 116, 119, 122, 125, 128, 131, 134, 137, 140, 143, 146, 149, 152,
- 155, 158, 161, 164, 167, 170, 173, 177, 181, 185, 189, 193, 197, 201, 205, 209,
- 213, 217, 221, 225, 229, 234, 239, 245, 249, 254, 259, 264, 269, 274, 279, 284,
-};
-
-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 },
- { 231,
- 243,
- 245, 253, 254, 254, 254, 254, 254,
- 254, 254, 254, 254, 254, 251, 251, 254, 254, 254 }
-};
-
-static const uint8_t vp8_mv_default_prob[2][19] = {
- { 162,
- 128,
- 225, 146, 172, 147, 214, 39, 156,
- 128, 129, 132, 75, 145, 178, 206, 239, 254, 254 },
- { 164,
- 128,
- 204, 170, 119, 235, 140, 230, 228,
- 128, 130, 130, 74, 148, 180, 203, 236, 254, 254 }
-};
-
-#endif /* AVCODEC_VP8DATA_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/vp8dsp.c b/src/thirdparty/ffmpeg/libavcodec/vp8dsp.c
deleted file mode 100644
index aabf5147e..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vp8dsp.c
+++ /dev/null
@@ -1,530 +0,0 @@
-/*
- * Copyright (C) 2010 David Conrad
- * 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
- */
-
-/**
- * @file
- * VP8 compatible video decoder
- */
-
-#include "dsputil.h"
-#include "vp8dsp.h"
-#include "libavutil/common.h"
-
-// TODO: Maybe add dequant
-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;
- }
-
- 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;
-
- block[i][0][0] = (t0 + t1) >> 3;
- block[i][1][0] = (t3 + t2) >> 3;
- block[i][2][0] = (t0 - t1) >> 3;
- block[i][3][0] = (t3 - t2) >> 3;
- }
-}
-
-static void vp8_luma_dc_wht_dc_c(int16_t block[4][4][16], int16_t dc[16])
-{
- int i, val = (dc[0] + 3) >> 3;
- 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;
- }
-}
-
-#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)
-{
- int i, t0, t1, t2, t3;
- 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;
- }
-
- 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]);
-
- 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;
- }
-}
-
-static void vp8_idct_dc_add_c(uint8_t *dst, int16_t block[16], ptrdiff_t stride)
-{
- int i, dc = (block[0] + 4) >> 3;
- 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;
- }
-}
-
-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);
-}
-
-// 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)
-{
- LOAD_PIXELS
- int a, f1, f2;
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
-
- a = 3*(q0 - p0);
-
- if (is4tap)
- a += clip_int8(p1 - q1);
-
- a = clip_int8(a);
-
- // 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;
-
- // 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];
-
- // 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];
- }
-}
-
-static av_always_inline int simple_limit(uint8_t *p, ptrdiff_t stride, int flim)
-{
- LOAD_PIXELS
- 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;
-}
-
-// 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;
-}
-
-static av_always_inline void filter_mbedge(uint8_t *p, ptrdiff_t stride)
-{
- int a0, a1, a2, w;
- uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
-
- LOAD_PIXELS
-
- 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;
-
- 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);\
- }\
-}
-
-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);\
-}
-
-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);
-}
-
-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);
-}
-
-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 },
-};
-
-#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]; \
- 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 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]; \
- 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_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]; \
- 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; \
- } \
-}
-
-VP8_EPEL_H(16, 4)
-VP8_EPEL_H(8, 4)
-VP8_EPEL_H(4, 4)
-VP8_EPEL_H(16, 6)
-VP8_EPEL_H(8, 6)
-VP8_EPEL_H(4, 6)
-VP8_EPEL_V(16, 4)
-VP8_EPEL_V(8, 4)
-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)
-VP8_EPEL_HV(16, 4, 6)
-VP8_EPEL_HV(8, 4, 6)
-VP8_EPEL_HV(4, 4, 6)
-VP8_EPEL_HV(16, 6, 4)
-VP8_EPEL_HV(8, 6, 4)
-VP8_EPEL_HV(4, 6, 4)
-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 stride, uint8_t *src, ptrdiff_t s2, 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 += stride; \
- src += stride; \
- } \
-} \
-static void put_vp8_bilinear ## SIZE ## _v_c(uint8_t *dst, ptrdiff_t stride, uint8_t *src, ptrdiff_t s2, 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+stride] + 4) >> 3; \
- dst += stride; \
- src += stride; \
- } \
-} \
-\
-static void put_vp8_bilinear ## SIZE ## _hv_c(uint8_t *dst, ptrdiff_t stride, uint8_t *src, ptrdiff_t s2, 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 += stride; \
- } \
-\
- 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 += stride; \
- 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; \
- 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][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; \
- 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; \
- dsp->put_vp8_bilinear_pixels_tab[IDX][1][1] = put_vp8_bilinear ## SIZE ## _hv_c; \
- dsp->put_vp8_bilinear_pixels_tab[IDX][1][2] = put_vp8_bilinear ## SIZE ## _hv_c; \
- dsp->put_vp8_bilinear_pixels_tab[IDX][2][0] = put_vp8_bilinear ## SIZE ## _v_c; \
- 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_vp8dsp_init(VP8DSPContext *dsp)
-{
- dsp->vp8_luma_dc_wht = vp8_luma_dc_wht_c;
- dsp->vp8_luma_dc_wht_dc = vp8_luma_dc_wht_dc_c;
- dsp->vp8_idct_add = vp8_idct_add_c;
- dsp->vp8_idct_dc_add = vp8_idct_dc_add_c;
- dsp->vp8_idct_dc_add4y = vp8_idct_dc_add4y_c;
- dsp->vp8_idct_dc_add4uv = vp8_idct_dc_add4uv_c;
-
- dsp->vp8_v_loop_filter16y = vp8_v_loop_filter16_c;
- dsp->vp8_h_loop_filter16y = vp8_h_loop_filter16_c;
- dsp->vp8_v_loop_filter8uv = vp8_v_loop_filter8uv_c;
- dsp->vp8_h_loop_filter8uv = vp8_h_loop_filter8uv_c;
-
- dsp->vp8_v_loop_filter16y_inner = vp8_v_loop_filter16_inner_c;
- dsp->vp8_h_loop_filter16y_inner = vp8_h_loop_filter16_inner_c;
- dsp->vp8_v_loop_filter8uv_inner = vp8_v_loop_filter8uv_inner_c;
- dsp->vp8_h_loop_filter8uv_inner = vp8_h_loop_filter8uv_inner_c;
-
- 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_X86)
- ff_vp8dsp_init_x86(dsp);
- if (HAVE_ALTIVEC)
- ff_vp8dsp_init_altivec(dsp);
- if (ARCH_ARM)
- ff_vp8dsp_init_arm(dsp);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/vp8dsp.h b/src/thirdparty/ffmpeg/libavcodec/vp8dsp.h
deleted file mode 100644
index f88994ab5..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/vp8dsp.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2010 David Conrad
- * 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
- */
-
-/**
- * @file
- * VP8 compatible video decoder
- */
-
-#ifndef AVCODEC_VP8DSP_H
-#define AVCODEC_VP8DSP_H
-
-#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,
- int h, int x, int y);
-
-typedef struct VP8DSPContext {
- void (*vp8_luma_dc_wht)(int16_t block[4][4][16], int16_t dc[16]);
- void (*vp8_luma_dc_wht_dc)(int16_t block[4][4][16], int16_t dc[16]);
- void (*vp8_idct_add)(uint8_t *dst, int16_t block[16], ptrdiff_t stride);
- void (*vp8_idct_dc_add)(uint8_t *dst, int16_t block[16], ptrdiff_t stride);
- void (*vp8_idct_dc_add4y)(uint8_t *dst, int16_t block[4][16],
- ptrdiff_t stride);
- void (*vp8_idct_dc_add4uv)(uint8_t *dst, int16_t block[4][16],
- ptrdiff_t stride);
-
- // loop filter applied to edges between macroblocks
- void (*vp8_v_loop_filter16y)(uint8_t *dst, ptrdiff_t stride,
- int flim_E, int flim_I, int hev_thresh);
- void (*vp8_h_loop_filter16y)(uint8_t *dst, ptrdiff_t stride,
- int flim_E, int flim_I, int hev_thresh);
- void (*vp8_v_loop_filter8uv)(uint8_t *dstU, uint8_t *dstV, ptrdiff_t stride,
- int flim_E, int flim_I, int hev_thresh);
- void (*vp8_h_loop_filter8uv)(uint8_t *dstU, uint8_t *dstV, ptrdiff_t stride,
- int flim_E, int flim_I, int hev_thresh);
-
- // loop filter applied to inner macroblock edges
- void (*vp8_v_loop_filter16y_inner)(uint8_t *dst, ptrdiff_t stride,
- int flim_E, int flim_I, int hev_thresh);
- void (*vp8_h_loop_filter16y_inner)(uint8_t *dst, ptrdiff_t stride,
- int flim_E, int flim_I, int hev_thresh);
- void (*vp8_v_loop_filter8uv_inner)(uint8_t *dstU, uint8_t *dstV,
- ptrdiff_t stride,
- int flim_E, int flim_I, int hev_thresh);
- void (*vp8_h_loop_filter8uv_inner)(uint8_t *dstU, uint8_t *dstV,
- ptrdiff_t stride,
- int flim_E, int flim_I, int hev_thresh);
-
- void (*vp8_v_loop_filter_simple)(uint8_t *dst, ptrdiff_t stride, int flim);
- void (*vp8_h_loop_filter_simple)(uint8_t *dst, ptrdiff_t stride, int flim);
-
- /**
- * first dimension: width>>3, height is assumed equal to width
- * second dimension: 0 if no vertical interpolation is needed;
- * 1 4-tap vertical interpolation filter (my & 1)
- * 2 6-tap vertical interpolation filter (!(my & 1))
- * third dimension: same as second dimension, for horizontal interpolation
- * so something like put_vp8_epel_pixels_tab[width>>3][2*!!my-(my&1)][2*!!mx-(mx&1)](..., mx, my)
- */
- vp8_mc_func put_vp8_epel_pixels_tab[3][3][3];
- vp8_mc_func put_vp8_bilinear_pixels_tab[3][3][3];
-} VP8DSPContext;
-
-void ff_put_vp8_pixels16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
- int h, int x, int y);
-void ff_put_vp8_pixels8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
- int h, int x, int y);
-void ff_put_vp8_pixels4_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
- int h, int x, int y);
-
-void ff_vp8dsp_init(VP8DSPContext *c);
-void ff_vp8dsp_init_x86(VP8DSPContext *c);
-void ff_vp8dsp_init_altivec(VP8DSPContext *c);
-void ff_vp8dsp_init_arm(VP8DSPContext *c);
-
-#endif /* AVCODEC_VP8DSP_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/w32pthreads.h b/src/thirdparty/ffmpeg/libavcodec/w32pthreads.h
deleted file mode 100644
index 7294b19c2..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/w32pthreads.h
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * Copyright (C) 2010-2011 x264 project
- *
- * Authors: Steven Walters <kemuri9@gmail.com>
- * Pegasys Inc. <http://www.pegasys-inc.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * w32threads to pthreads wrapper
- */
-
-#ifndef AVCODEC_W32PTHREADS_H
-#define AVCODEC_W32PTHREADS_H
-
-/* Build up a pthread-like API using underlying Windows API. Have only static
- * methods so as to not conflict with a potentially linked in pthread-win32
- * library.
- * As most functions here are used without checking return values,
- * only implement return values as necessary. */
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include <process.h>
-
-#include "libavutil/common.h"
-#include "libavutil/internal.h"
-#include "libavutil/mem.h"
-
-typedef struct pthread_t {
- void *handle;
- void *(*func)(void* arg);
- void *arg;
- void *ret;
-} pthread_t;
-
-/* the conditional variable api for windows 6.0+ uses critical sections and
- * not mutexes */
-typedef CRITICAL_SECTION pthread_mutex_t;
-
-/* This is the CONDITIONAL_VARIABLE typedef for using Window's native
- * conditional variables on kernels 6.0+.
- * MinGW does not currently have this typedef. */
-typedef struct pthread_cond_t {
- void *ptr;
-} pthread_cond_t;
-
-/* function pointers to conditional variable API on windows 6.0+ kernels */
-static void (WINAPI *cond_broadcast)(pthread_cond_t *cond);
-static void (WINAPI *cond_init)(pthread_cond_t *cond);
-static void (WINAPI *cond_signal)(pthread_cond_t *cond);
-static BOOL (WINAPI *cond_wait)(pthread_cond_t *cond, pthread_mutex_t *mutex,
- DWORD milliseconds);
-
-static unsigned __stdcall attribute_align_arg win32thread_worker(void *arg)
-{
- pthread_t *h = arg;
- h->ret = h->func(h->arg);
- return 0;
-}
-
-static int pthread_create(pthread_t *thread, const void *unused_attr,
- void *(*start_routine)(void*), void *arg)
-{
- thread->func = start_routine;
- thread->arg = arg;
- thread->handle = (void*)_beginthreadex(NULL, 0, win32thread_worker, thread,
- 0, NULL);
- return !thread->handle;
-}
-
-static void pthread_join(pthread_t thread, void **value_ptr)
-{
- DWORD ret = WaitForSingleObject(thread.handle, INFINITE);
- if (ret != WAIT_OBJECT_0)
- return;
- if (value_ptr)
- *value_ptr = thread.ret;
- CloseHandle(thread.handle);
-}
-
-static inline int pthread_mutex_init(pthread_mutex_t *m, void* attr)
-{
- InitializeCriticalSection(m);
- return 0;
-}
-static inline int pthread_mutex_destroy(pthread_mutex_t *m)
-{
- DeleteCriticalSection(m);
- return 0;
-}
-static inline int pthread_mutex_lock(pthread_mutex_t *m)
-{
- EnterCriticalSection(m);
- return 0;
-}
-static inline int pthread_mutex_unlock(pthread_mutex_t *m)
-{
- LeaveCriticalSection(m);
- return 0;
-}
-
-/* for pre-Windows 6.0 platforms we need to define and use our own condition
- * variable and api */
-typedef struct win32_cond_t {
- pthread_mutex_t mtx_broadcast;
- pthread_mutex_t mtx_waiter_count;
- volatile int waiter_count;
- HANDLE semaphore;
- HANDLE waiters_done;
- volatile int is_broadcast;
-} win32_cond_t;
-
-static void pthread_cond_init(pthread_cond_t *cond, const void *unused_attr)
-{
- win32_cond_t *win32_cond = NULL;
- if (cond_init) {
- cond_init(cond);
- return;
- }
-
- /* non native condition variables */
- win32_cond = av_mallocz(sizeof(win32_cond_t));
- if (!win32_cond)
- return;
- cond->ptr = win32_cond;
- win32_cond->semaphore = CreateSemaphore(NULL, 0, 0x7fffffff, NULL);
- if (!win32_cond->semaphore)
- return;
- win32_cond->waiters_done = CreateEvent(NULL, TRUE, FALSE, NULL);
- if (!win32_cond->waiters_done)
- return;
-
- pthread_mutex_init(&win32_cond->mtx_waiter_count, NULL);
- pthread_mutex_init(&win32_cond->mtx_broadcast, NULL);
-}
-
-static void pthread_cond_destroy(pthread_cond_t *cond)
-{
- win32_cond_t *win32_cond = cond->ptr;
- /* native condition variables do not destroy */
- if (cond_init)
- return;
-
- /* non native condition variables */
- CloseHandle(win32_cond->semaphore);
- CloseHandle(win32_cond->waiters_done);
- pthread_mutex_destroy(&win32_cond->mtx_waiter_count);
- pthread_mutex_destroy(&win32_cond->mtx_broadcast);
- av_freep(&win32_cond);
- cond->ptr = NULL;
-}
-
-static void pthread_cond_broadcast(pthread_cond_t *cond)
-{
- win32_cond_t *win32_cond = cond->ptr;
- int have_waiter;
-
- if (cond_broadcast) {
- cond_broadcast(cond);
- return;
- }
-
- /* non native condition variables */
- pthread_mutex_lock(&win32_cond->mtx_broadcast);
- pthread_mutex_lock(&win32_cond->mtx_waiter_count);
- have_waiter = 0;
-
- if (win32_cond->waiter_count) {
- win32_cond->is_broadcast = 1;
- have_waiter = 1;
- }
-
- if (have_waiter) {
- ReleaseSemaphore(win32_cond->semaphore, win32_cond->waiter_count, NULL);
- pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
- WaitForSingleObject(win32_cond->waiters_done, INFINITE);
- ResetEvent(win32_cond->waiters_done);
- win32_cond->is_broadcast = 0;
- } else
- pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
- pthread_mutex_unlock(&win32_cond->mtx_broadcast);
-}
-
-static int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
-{
- win32_cond_t *win32_cond = cond->ptr;
- int last_waiter;
- if (cond_wait) {
- cond_wait(cond, mutex, INFINITE);
- return 0;
- }
-
- /* non native condition variables */
- pthread_mutex_lock(&win32_cond->mtx_broadcast);
- pthread_mutex_lock(&win32_cond->mtx_waiter_count);
- win32_cond->waiter_count++;
- pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
- pthread_mutex_unlock(&win32_cond->mtx_broadcast);
-
- // unlock the external mutex
- pthread_mutex_unlock(mutex);
- WaitForSingleObject(win32_cond->semaphore, INFINITE);
-
- pthread_mutex_lock(&win32_cond->mtx_waiter_count);
- win32_cond->waiter_count--;
- last_waiter = !win32_cond->waiter_count || !win32_cond->is_broadcast;
- pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
-
- if (last_waiter)
- SetEvent(win32_cond->waiters_done);
-
- // lock the external mutex
- return pthread_mutex_lock(mutex);
-}
-
-static void pthread_cond_signal(pthread_cond_t *cond)
-{
- win32_cond_t *win32_cond = cond->ptr;
- int have_waiter;
- if (cond_signal) {
- cond_signal(cond);
- return;
- }
-
- pthread_mutex_lock(&win32_cond->mtx_broadcast);
-
- /* non-native condition variables */
- pthread_mutex_lock(&win32_cond->mtx_waiter_count);
- have_waiter = win32_cond->waiter_count;
- pthread_mutex_unlock(&win32_cond->mtx_waiter_count);
-
- if (have_waiter) {
- ReleaseSemaphore(win32_cond->semaphore, 1, NULL);
- WaitForSingleObject(win32_cond->waiters_done, INFINITE);
- ResetEvent(win32_cond->waiters_done);
- }
-
- pthread_mutex_unlock(&win32_cond->mtx_broadcast);
-}
-
-static void w32thread_init(void)
-{
- HANDLE kernel_dll = GetModuleHandle(TEXT("kernel32.dll"));
- /* if one is available, then they should all be available */
- cond_init =
- (void*)GetProcAddress(kernel_dll, "InitializeConditionVariable");
- cond_broadcast =
- (void*)GetProcAddress(kernel_dll, "WakeAllConditionVariable");
- cond_signal =
- (void*)GetProcAddress(kernel_dll, "WakeConditionVariable");
- cond_wait =
- (void*)GetProcAddress(kernel_dll, "SleepConditionVariableCS");
-}
-
-#endif /* AVCODEC_W32PTHREADS_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/wmv2.c b/src/thirdparty/ffmpeg/libavcodec/wmv2.c
deleted file mode 100644
index f1b58ec97..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/wmv2.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (c) 2002 The FFmpeg Project
- *
- * 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 "mpegvideo.h"
-#include "msmpeg4data.h"
-#include "simple_idct.h"
-#include "wmv2.h"
-
-
-av_cold void ff_wmv2_common_init(Wmv2Context * w){
- MpegEncContext * const s= &w->s;
-
- ff_wmv2dsp_init(&w->wdsp);
- s->dsp.idct_permutation_type = w->wdsp.idct_perm;
- ff_init_scantable_permutation(s->dsp.idct_permutation,
- w->wdsp.idct_perm);
- ff_init_scantable(s->dsp.idct_permutation, &w->abt_scantable[0],
- ff_wmv2_scantableA);
- ff_init_scantable(s->dsp.idct_permutation, &w->abt_scantable[1],
- ff_wmv2_scantableB);
- ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable,
- ff_wmv1_scantable[1]);
- ff_init_scantable(s->dsp.idct_permutation, &s->intra_h_scantable,
- ff_wmv1_scantable[2]);
- ff_init_scantable(s->dsp.idct_permutation, &s->intra_v_scantable,
- ff_wmv1_scantable[3]);
- ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable,
- ff_wmv1_scantable[0]);
- s->dsp.idct_put = w->wdsp.idct_put;
- s->dsp.idct_add = w->wdsp.idct_add;
- s->dsp.idct = NULL;
-}
-
-static void wmv2_add_block(Wmv2Context *w, int16_t *block1, uint8_t *dst, int stride, int n){
- MpegEncContext * const s= &w->s;
-
- if (s->block_last_index[n] >= 0) {
- switch(w->abt_type_table[n]){
- case 0:
- w->wdsp.idct_add(dst, stride, block1);
- break;
- case 1:
- ff_simple_idct84_add(dst , stride, block1);
- ff_simple_idct84_add(dst + 4*stride, stride, w->abt_block2[n]);
- s->dsp.clear_block(w->abt_block2[n]);
- break;
- case 2:
- ff_simple_idct48_add(dst , stride, block1);
- ff_simple_idct48_add(dst + 4 , stride, w->abt_block2[n]);
- s->dsp.clear_block(w->abt_block2[n]);
- break;
- default:
- av_log(s->avctx, AV_LOG_ERROR, "internal error in WMV2 abt\n");
- }
- }
-}
-
-void ff_wmv2_add_mb(MpegEncContext *s, int16_t block1[6][64], uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr){
- Wmv2Context * const w= (Wmv2Context*)s;
-
- wmv2_add_block(w, block1[0], dest_y , s->linesize, 0);
- wmv2_add_block(w, block1[1], dest_y + 8 , s->linesize, 1);
- wmv2_add_block(w, block1[2], dest_y + 8*s->linesize, s->linesize, 2);
- wmv2_add_block(w, block1[3], dest_y + 8 + 8*s->linesize, s->linesize, 3);
-
- if(s->flags&CODEC_FLAG_GRAY) return;
-
- wmv2_add_block(w, block1[4], dest_cb , s->uvlinesize, 4);
- wmv2_add_block(w, block1[5], dest_cr , s->uvlinesize, 5);
-}
-
-void ff_mspel_motion(MpegEncContext *s,
- uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
- uint8_t **ref_picture, op_pixels_func (*pix_op)[4],
- int motion_x, int motion_y, int h)
-{
- Wmv2Context * const w= (Wmv2Context*)s;
- uint8_t *ptr;
- int dxy, offset, mx, my, src_x, src_y, v_edge_pos, linesize, uvlinesize;
- int emu=0;
-
- dxy = ((motion_y & 1) << 1) | (motion_x & 1);
- dxy = 2*dxy + w->hshift;
- src_x = s->mb_x * 16 + (motion_x >> 1);
- src_y = s->mb_y * 16 + (motion_y >> 1);
-
- /* WARNING: do no forget half pels */
- v_edge_pos = s->v_edge_pos;
- src_x = av_clip(src_x, -16, s->width);
- src_y = av_clip(src_y, -16, s->height);
-
- if(src_x<=-16 || src_x >= s->width)
- dxy &= ~3;
- if(src_y<=-16 || src_y >= s->height)
- dxy &= ~4;
-
- linesize = s->linesize;
- uvlinesize = s->uvlinesize;
- ptr = ref_picture[0] + (src_y * linesize) + src_x;
-
- if(s->flags&CODEC_FLAG_EMU_EDGE){
- 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, 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);
- s->dsp.put_mspel_pixels_tab[dxy](dest_y +8*linesize, ptr +8*linesize, linesize);
- s->dsp.put_mspel_pixels_tab[dxy](dest_y+8+8*linesize, ptr+8+8*linesize, linesize);
-
- if(s->flags&CODEC_FLAG_GRAY) return;
-
- if (s->out_format == FMT_H263) {
- dxy = 0;
- if ((motion_x & 3) != 0)
- dxy |= 1;
- if ((motion_y & 3) != 0)
- dxy |= 2;
- mx = motion_x >> 2;
- my = motion_y >> 2;
- } else {
- mx = motion_x / 2;
- my = motion_y / 2;
- dxy = ((my & 1) << 1) | (mx & 1);
- mx >>= 1;
- my >>= 1;
- }
-
- src_x = s->mb_x * 8 + mx;
- src_y = s->mb_y * 8 + my;
- src_x = av_clip(src_x, -8, s->width >> 1);
- if (src_x == (s->width >> 1))
- dxy &= ~1;
- src_y = av_clip(src_y, -8, s->height >> 1);
- if (src_y == (s->height >> 1))
- dxy &= ~2;
- offset = (src_y * uvlinesize) + src_x;
- ptr = ref_picture[1] + offset;
- if(emu){
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9,
- src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
- ptr= s->edge_emu_buffer;
- }
- pix_op[1][dxy](dest_cb, ptr, uvlinesize, h >> 1);
-
- ptr = ref_picture[2] + offset;
- if(emu){
- s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9,
- src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
- ptr= s->edge_emu_buffer;
- }
- pix_op[1][dxy](dest_cr, ptr, uvlinesize, h >> 1);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/wmv2.h b/src/thirdparty/ffmpeg/libavcodec/wmv2.h
deleted file mode 100644
index f393ab1a8..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/wmv2.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2002 The FFmpeg Project
- *
- * 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_WMV2_H
-#define AVCODEC_WMV2_H
-
-#include "avcodec.h"
-#include "dsputil.h"
-#include "mpegvideo.h"
-#include "intrax8.h"
-#include "wmv2dsp.h"
-
-#define SKIP_TYPE_NONE 0
-#define SKIP_TYPE_MPEG 1
-#define SKIP_TYPE_ROW 2
-#define SKIP_TYPE_COL 3
-
-
-typedef struct Wmv2Context{
- MpegEncContext s;
- IntraX8Context x8;
- WMV2DSPContext wdsp;
- int j_type_bit;
- int j_type;
- int abt_flag;
- int abt_type;
- int abt_type_table[6];
- int per_mb_abt;
- int per_block_abt;
- int mspel_bit;
- int cbp_table_index;
- int top_left_mv_flag;
- int per_mb_rl_bit;
- int skip_type;
- int hshift;
-
- ScanTable abt_scantable[2];
- DECLARE_ALIGNED(16, int16_t, abt_block2)[6][64];
-}Wmv2Context;
-
-void ff_wmv2_common_init(Wmv2Context * w);
-
-#endif /* AVCODEC_WMV2_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/wmv2dec.c b/src/thirdparty/ffmpeg/libavcodec/wmv2dec.c
deleted file mode 100644
index 3fb57aac1..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/wmv2dec.c
+++ /dev/null
@@ -1,479 +0,0 @@
-/*
- * Copyright (c) 2002 The FFmpeg Project
- *
- * 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 "dsputil.h"
-#include "mpegvideo.h"
-#include "h263.h"
-#include "mathops.h"
-#include "msmpeg4.h"
-#include "msmpeg4data.h"
-#include "intrax8.h"
-#include "wmv2.h"
-
-
-static void parse_mb_skip(Wmv2Context * w){
- int mb_x, mb_y;
- MpegEncContext * const s= &w->s;
- uint32_t * const mb_type = s->current_picture_ptr->f.mb_type;
-
- w->skip_type= get_bits(&s->gb, 2);
- switch(w->skip_type){
- case SKIP_TYPE_NONE:
- for(mb_y=0; mb_y<s->mb_height; mb_y++){
- for(mb_x=0; mb_x<s->mb_width; mb_x++){
- mb_type[mb_y*s->mb_stride + mb_x]= MB_TYPE_16x16 | MB_TYPE_L0;
- }
- }
- break;
- case SKIP_TYPE_MPEG:
- for(mb_y=0; mb_y<s->mb_height; mb_y++){
- for(mb_x=0; mb_x<s->mb_width; mb_x++){
- mb_type[mb_y*s->mb_stride + mb_x]= (get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_L0;
- }
- }
- break;
- case SKIP_TYPE_ROW:
- for(mb_y=0; mb_y<s->mb_height; mb_y++){
- if(get_bits1(&s->gb)){
- for(mb_x=0; mb_x<s->mb_width; mb_x++){
- mb_type[mb_y*s->mb_stride + mb_x]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
- }
- }else{
- for(mb_x=0; mb_x<s->mb_width; mb_x++){
- mb_type[mb_y*s->mb_stride + mb_x]= (get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_L0;
- }
- }
- }
- break;
- case SKIP_TYPE_COL:
- for(mb_x=0; mb_x<s->mb_width; mb_x++){
- if(get_bits1(&s->gb)){
- for(mb_y=0; mb_y<s->mb_height; mb_y++){
- mb_type[mb_y*s->mb_stride + mb_x]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
- }
- }else{
- for(mb_y=0; mb_y<s->mb_height; mb_y++){
- mb_type[mb_y*s->mb_stride + mb_x]= (get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_L0;
- }
- }
- }
- break;
- }
-}
-
-static int decode_ext_header(Wmv2Context *w){
- MpegEncContext * const s= &w->s;
- GetBitContext gb;
- int fps;
- int code;
-
- if(s->avctx->extradata_size<4) return -1;
-
- init_get_bits(&gb, s->avctx->extradata, 32);
-
- fps = get_bits(&gb, 5);
- s->bit_rate = get_bits(&gb, 11)*1024;
- w->mspel_bit = get_bits1(&gb);
- s->loop_filter = get_bits1(&gb);
- w->abt_flag = get_bits1(&gb);
- w->j_type_bit = get_bits1(&gb);
- w->top_left_mv_flag= get_bits1(&gb);
- w->per_mb_rl_bit = get_bits1(&gb);
- code = get_bits(&gb, 3);
-
- if(code==0) return -1;
-
- s->slice_height = s->mb_height / code;
-
- if(s->avctx->debug&FF_DEBUG_PICT_INFO){
- av_log(s->avctx, AV_LOG_DEBUG, "fps:%d, br:%d, qpbit:%d, abt_flag:%d, j_type_bit:%d, tl_mv_flag:%d, mbrl_bit:%d, code:%d, loop_filter:%d, slices:%d\n",
- fps, s->bit_rate, w->mspel_bit, w->abt_flag, w->j_type_bit, w->top_left_mv_flag, w->per_mb_rl_bit, code, s->loop_filter,
- code);
- }
- return 0;
-}
-
-int ff_wmv2_decode_picture_header(MpegEncContext * s)
-{
- Wmv2Context * const w= (Wmv2Context*)s;
- int code;
-
- if(s->picture_number==0)
- decode_ext_header(w);
-
- s->pict_type = get_bits1(&s->gb) + 1;
- if(s->pict_type == AV_PICTURE_TYPE_I){
- code = get_bits(&s->gb, 7);
- av_log(s->avctx, AV_LOG_DEBUG, "I7:%X/\n", code);
- }
- s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
- if(s->qscale <= 0)
- return -1;
-
- return 0;
-}
-
-int ff_wmv2_decode_secondary_picture_header(MpegEncContext * s)
-{
- Wmv2Context * const w= (Wmv2Context*)s;
-
- if (s->pict_type == AV_PICTURE_TYPE_I) {
- if(w->j_type_bit) w->j_type= get_bits1(&s->gb);
- else w->j_type= 0; //FIXME check
-
- if(!w->j_type){
- if(w->per_mb_rl_bit) s->per_mb_rl_table= get_bits1(&s->gb);
- else s->per_mb_rl_table= 0;
-
- if(!s->per_mb_rl_table){
- s->rl_chroma_table_index = decode012(&s->gb);
- s->rl_table_index = decode012(&s->gb);
- }
-
- s->dc_table_index = get_bits1(&s->gb);
- }
- s->inter_intra_pred= 0;
- s->no_rounding = 1;
- if(s->avctx->debug&FF_DEBUG_PICT_INFO){
- av_log(s->avctx, AV_LOG_DEBUG, "qscale:%d rlc:%d rl:%d dc:%d mbrl:%d j_type:%d \n",
- s->qscale,
- s->rl_chroma_table_index,
- s->rl_table_index,
- s->dc_table_index,
- s->per_mb_rl_table,
- w->j_type);
- }
- }else{
- int cbp_index;
- w->j_type=0;
-
- parse_mb_skip(w);
- cbp_index= decode012(&s->gb);
- if(s->qscale <= 10){
- int map[3]= {0,2,1};
- w->cbp_table_index= map[cbp_index];
- }else if(s->qscale <= 20){
- int map[3]= {1,0,2};
- w->cbp_table_index= map[cbp_index];
- }else{
- int map[3]= {2,1,0};
- w->cbp_table_index= map[cbp_index];
- }
-
- if(w->mspel_bit) s->mspel= get_bits1(&s->gb);
- else s->mspel= 0; //FIXME check
-
- if(w->abt_flag){
- w->per_mb_abt= get_bits1(&s->gb)^1;
- if(!w->per_mb_abt){
- w->abt_type= decode012(&s->gb);
- }
- }
-
- if(w->per_mb_rl_bit) s->per_mb_rl_table= get_bits1(&s->gb);
- else s->per_mb_rl_table= 0;
-
- if(!s->per_mb_rl_table){
- s->rl_table_index = decode012(&s->gb);
- s->rl_chroma_table_index = s->rl_table_index;
- }
-
- s->dc_table_index = get_bits1(&s->gb);
- s->mv_table_index = get_bits1(&s->gb);
-
- s->inter_intra_pred= 0;//(s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE);
- s->no_rounding ^= 1;
-
- if(s->avctx->debug&FF_DEBUG_PICT_INFO){
- av_log(s->avctx, AV_LOG_DEBUG, "rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d mspel:%d per_mb_abt:%d abt_type:%d cbp:%d ii:%d\n",
- s->rl_table_index,
- s->rl_chroma_table_index,
- s->dc_table_index,
- s->mv_table_index,
- s->per_mb_rl_table,
- s->qscale,
- s->mspel,
- w->per_mb_abt,
- w->abt_type,
- w->cbp_table_index,
- s->inter_intra_pred);
- }
- }
- s->esc3_level_length= 0;
- s->esc3_run_length= 0;
-
-s->picture_number++; //FIXME ?
-
-
- if(w->j_type){
- ff_intrax8_decode_picture(&w->x8, 2*s->qscale, (s->qscale-1)|1 );
- return 1;
- }
-
- return 0;
-}
-
-static inline int wmv2_decode_motion(Wmv2Context *w, int *mx_ptr, int *my_ptr){
- MpegEncContext * const s= &w->s;
- int ret;
-
- ret= ff_msmpeg4_decode_motion(s, mx_ptr, my_ptr);
-
- if(ret<0) return -1;
-
- if((((*mx_ptr)|(*my_ptr)) & 1) && s->mspel)
- w->hshift= get_bits1(&s->gb);
- else
- w->hshift= 0;
-
- return 0;
-}
-
-static int16_t *wmv2_pred_motion(Wmv2Context *w, int *px, int *py){
- MpegEncContext * const s= &w->s;
- int xy, wrap, diff, type;
- int16_t *A, *B, *C, *mot_val;
-
- wrap = s->b8_stride;
- xy = s->block_index[0];
-
- mot_val = s->current_picture.f.motion_val[0][xy];
-
- A = s->current_picture.f.motion_val[0][xy - 1];
- B = s->current_picture.f.motion_val[0][xy - wrap];
- C = s->current_picture.f.motion_val[0][xy + 2 - wrap];
-
- if(s->mb_x && !s->first_slice_line && !s->mspel && w->top_left_mv_flag)
- diff= FFMAX(FFABS(A[0] - B[0]), FFABS(A[1] - B[1]));
- else
- diff=0;
-
- if(diff >= 8)
- type= get_bits1(&s->gb);
- else
- type= 2;
-
- if(type == 0){
- *px= A[0];
- *py= A[1];
- }else if(type == 1){
- *px= B[0];
- *py= B[1];
- }else{
- /* special case for first (slice) line */
- if (s->first_slice_line) {
- *px = A[0];
- *py = A[1];
- } else {
- *px = mid_pred(A[0], B[0], C[0]);
- *py = mid_pred(A[1], B[1], C[1]);
- }
- }
-
- return mot_val;
-}
-
-static inline int wmv2_decode_inter_block(Wmv2Context *w, int16_t *block, int n, int cbp){
- MpegEncContext * const s= &w->s;
- static const int sub_cbp_table[3]= {2,3,1};
- int sub_cbp;
-
- if(!cbp){
- s->block_last_index[n] = -1;
-
- return 0;
- }
-
- if(w->per_block_abt)
- w->abt_type= decode012(&s->gb);
- w->abt_type_table[n]= w->abt_type;
-
- if(w->abt_type){
-// const uint8_t *scantable= w->abt_scantable[w->abt_type-1].permutated;
- const uint8_t *scantable= w->abt_scantable[w->abt_type-1].scantable;
-// const uint8_t *scantable= w->abt_type-1 ? w->abt_scantable[1].permutated : w->abt_scantable[0].scantable;
-
- sub_cbp= sub_cbp_table[ decode012(&s->gb) ];
-
- if(sub_cbp&1){
- if (ff_msmpeg4_decode_block(s, block, n, 1, scantable) < 0)
- return -1;
- }
-
- if(sub_cbp&2){
- if (ff_msmpeg4_decode_block(s, w->abt_block2[n], n, 1, scantable) < 0)
- return -1;
- }
- s->block_last_index[n] = 63;
-
- return 0;
- }else{
- return ff_msmpeg4_decode_block(s, block, n, 1, s->inter_scantable.permutated);
- }
-}
-
-
-int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64])
-{
- Wmv2Context * const w= (Wmv2Context*)s;
- int cbp, code, i;
- uint8_t *coded_val;
-
- if(w->j_type) return 0;
-
- if (s->pict_type == AV_PICTURE_TYPE_P) {
- if (IS_SKIP(s->current_picture.f.mb_type[s->mb_y * s->mb_stride + s->mb_x])) {
- /* skip mb */
- s->mb_intra = 0;
- for(i=0;i<6;i++)
- s->block_last_index[i] = -1;
- s->mv_dir = MV_DIR_FORWARD;
- s->mv_type = MV_TYPE_16X16;
- s->mv[0][0][0] = 0;
- s->mv[0][0][1] = 0;
- s->mb_skipped = 1;
- w->hshift=0;
- return 0;
- }
-
- code = get_vlc2(&s->gb, ff_mb_non_intra_vlc[w->cbp_table_index].table, MB_NON_INTRA_VLC_BITS, 3);
- if (code < 0)
- return -1;
- s->mb_intra = (~code & 0x40) >> 6;
-
- cbp = code & 0x3f;
- } else {
- s->mb_intra = 1;
- code = get_vlc2(&s->gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2);
- if (code < 0){
- av_log(s->avctx, AV_LOG_ERROR, "II-cbp illegal at %d %d\n", s->mb_x, s->mb_y);
- return -1;
- }
- /* predict coded block pattern */
- cbp = 0;
- for(i=0;i<6;i++) {
- int val = ((code >> (5 - i)) & 1);
- if (i < 4) {
- int pred = ff_msmpeg4_coded_block_pred(s, i, &coded_val);
- val = val ^ pred;
- *coded_val = val;
- }
- cbp |= val << (5 - i);
- }
- }
-
- if (!s->mb_intra) {
- int mx, my;
- wmv2_pred_motion(w, &mx, &my);
-
- if(cbp){
- s->dsp.clear_blocks(s->block[0]);
- if(s->per_mb_rl_table){
- s->rl_table_index = decode012(&s->gb);
- s->rl_chroma_table_index = s->rl_table_index;
- }
-
- if(w->abt_flag && w->per_mb_abt){
- w->per_block_abt= get_bits1(&s->gb);
- if(!w->per_block_abt)
- w->abt_type= decode012(&s->gb);
- }else
- w->per_block_abt=0;
- }
-
- if (wmv2_decode_motion(w, &mx, &my) < 0)
- return -1;
-
- s->mv_dir = MV_DIR_FORWARD;
- s->mv_type = MV_TYPE_16X16;
- s->mv[0][0][0] = mx;
- s->mv[0][0][1] = my;
-
- for (i = 0; i < 6; i++) {
- if (wmv2_decode_inter_block(w, block[i], i, (cbp >> (5 - i)) & 1) < 0)
- {
- av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding inter block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
- return -1;
- }
- }
- } else {
- if (s->pict_type==AV_PICTURE_TYPE_P)
- av_dlog(s->avctx, "%d%d ", s->inter_intra_pred, cbp);
- av_dlog(s->avctx, "I at %d %d %d %06X\n", s->mb_x, s->mb_y,
- ((cbp & 3) ? 1 : 0) +((cbp & 0x3C)? 2 : 0),
- show_bits(&s->gb, 24));
- s->ac_pred = get_bits1(&s->gb);
- if(s->inter_intra_pred){
- s->h263_aic_dir= get_vlc2(&s->gb, ff_inter_intra_vlc.table, INTER_INTRA_VLC_BITS, 1);
- av_dlog(s->avctx, "%d%d %d %d/",
- s->ac_pred, s->h263_aic_dir, s->mb_x, s->mb_y);
- }
- if(s->per_mb_rl_table && cbp){
- s->rl_table_index = decode012(&s->gb);
- s->rl_chroma_table_index = s->rl_table_index;
- }
-
- s->dsp.clear_blocks(s->block[0]);
- for (i = 0; i < 6; i++) {
- if (ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)
- {
- av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding intra block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);
- return -1;
- }
- }
- }
-
- return 0;
-}
-
-static av_cold int wmv2_decode_init(AVCodecContext *avctx){
- Wmv2Context * const w= avctx->priv_data;
-
- if(ff_msmpeg4_decode_init(avctx) < 0)
- return -1;
-
- ff_wmv2_common_init(w);
-
- ff_intrax8_common_init(&w->x8,&w->s);
-
- return 0;
-}
-
-static av_cold int wmv2_decode_end(AVCodecContext *avctx)
-{
- Wmv2Context *w = avctx->priv_data;
-
- ff_intrax8_common_end(&w->x8);
- return ff_h263_decode_end(avctx);
-}
-
-AVCodec ff_wmv2_decoder = {
- .name = "wmv2",
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_WMV2,
- .priv_data_size = sizeof(Wmv2Context),
- .init = wmv2_decode_init,
- .close = wmv2_decode_end,
- .decode = ff_h263_decode_frame,
- .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 8"),
- .pix_fmts = ff_pixfmt_list_420,
-};
diff --git a/src/thirdparty/ffmpeg/libavcodec/wmv2dsp.c b/src/thirdparty/ffmpeg/libavcodec/wmv2dsp.c
deleted file mode 100644
index 9627442b3..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/wmv2dsp.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * 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/common.h"
-#include "avcodec.h"
-#include "dsputil.h"
-#include "wmv2dsp.h"
-
-#define W0 2048
-#define W1 2841 /* 2048*sqrt (2)*cos (1*pi/16) */
-#define W2 2676 /* 2048*sqrt (2)*cos (2*pi/16) */
-#define W3 2408 /* 2048*sqrt (2)*cos (3*pi/16) */
-#define W4 2048 /* 2048*sqrt (2)*cos (4*pi/16) */
-#define W5 1609 /* 2048*sqrt (2)*cos (5*pi/16) */
-#define W6 1108 /* 2048*sqrt (2)*cos (6*pi/16) */
-#define W7 565 /* 2048*sqrt (2)*cos (7*pi/16) */
-
-static void wmv2_idct_row(short * b)
-{
- int s1, s2;
- int a0, a1, a2, a3, a4, a5, a6, a7;
-
- /* step 1 */
- a1 = W1 * b[1] + W7 * b[7];
- a7 = W7 * b[1] - W1 * b[7];
- a5 = W5 * b[5] + W3 * b[3];
- a3 = W3 * b[5] - W5 * b[3];
- a2 = W2 * b[2] + W6 * b[6];
- a6 = W6 * b[2] - W2 * b[6];
- a0 = W0 * b[0] + W0 * b[4];
- a4 = W0 * b[0] - W0 * b[4];
-
- /* step 2 */
- s1 = (181 * (a1 - a5 + a7 - a3) + 128) >> 8; // 1, 3, 5, 7
- s2 = (181 * (a1 - a5 - a7 + a3) + 128) >> 8;
-
- /* step 3 */
- b[0] = (a0 + a2 + a1 + a5 + (1 << 7)) >> 8;
- b[1] = (a4 + a6 + s1 + (1 << 7)) >> 8;
- b[2] = (a4 - a6 + s2 + (1 << 7)) >> 8;
- b[3] = (a0 - a2 + a7 + a3 + (1 << 7)) >> 8;
- b[4] = (a0 - a2 - a7 - a3 + (1 << 7)) >> 8;
- b[5] = (a4 - a6 - s2 + (1 << 7)) >> 8;
- b[6] = (a4 + a6 - s1 + (1 << 7)) >> 8;
- b[7] = (a0 + a2 - a1 - a5 + (1 << 7)) >> 8;
-}
-
-static void wmv2_idct_col(short * b)
-{
- int s1, s2;
- int a0, a1, a2, a3, a4, a5, a6, a7;
-
- /* step 1, with extended precision */
- a1 = (W1 * b[8 * 1] + W7 * b[8 * 7] + 4) >> 3;
- a7 = (W7 * b[8 * 1] - W1 * b[8 * 7] + 4) >> 3;
- a5 = (W5 * b[8 * 5] + W3 * b[8 * 3] + 4) >> 3;
- a3 = (W3 * b[8 * 5] - W5 * b[8 * 3] + 4) >> 3;
- a2 = (W2 * b[8 * 2] + W6 * b[8 * 6] + 4) >> 3;
- a6 = (W6 * b[8 * 2] - W2 * b[8 * 6] + 4) >> 3;
- a0 = (W0 * b[8 * 0] + W0 * b[8 * 4] ) >> 3;
- a4 = (W0 * b[8 * 0] - W0 * b[8 * 4] ) >> 3;
-
- /* step 2 */
- s1 = (181 * (a1 - a5 + a7 - a3) + 128) >> 8;
- s2 = (181 * (a1 - a5 - a7 + a3) + 128) >> 8;
-
- /* step 3 */
- b[8 * 0] = (a0 + a2 + a1 + a5 + (1 << 13)) >> 14;
- b[8 * 1] = (a4 + a6 + s1 + (1 << 13)) >> 14;
- b[8 * 2] = (a4 - a6 + s2 + (1 << 13)) >> 14;
- b[8 * 3] = (a0 - a2 + a7 + a3 + (1 << 13)) >> 14;
-
- b[8 * 4] = (a0 - a2 - a7 - a3 + (1 << 13)) >> 14;
- b[8 * 5] = (a4 - a6 - s2 + (1 << 13)) >> 14;
- b[8 * 6] = (a4 + a6 - s1 + (1 << 13)) >> 14;
- b[8 * 7] = (a0 + a2 - a1 - a5 + (1 << 13)) >> 14;
-}
-
-static void wmv2_idct_add_c(uint8_t *dest, int line_size, int16_t *block)
-{
- int i;
-
- for (i = 0; i < 64; i += 8)
- wmv2_idct_row(block + i);
- for (i = 0; i < 8; i++)
- wmv2_idct_col(block + i);
-
- for (i = 0; i < 8; i++) {
- dest[0] = av_clip_uint8(dest[0] + block[0]);
- dest[1] = av_clip_uint8(dest[1] + block[1]);
- dest[2] = av_clip_uint8(dest[2] + block[2]);
- dest[3] = av_clip_uint8(dest[3] + block[3]);
- dest[4] = av_clip_uint8(dest[4] + block[4]);
- dest[5] = av_clip_uint8(dest[5] + block[5]);
- dest[6] = av_clip_uint8(dest[6] + block[6]);
- dest[7] = av_clip_uint8(dest[7] + block[7]);
- dest += line_size;
- block += 8;
- }
-}
-
-static void wmv2_idct_put_c(uint8_t *dest, int line_size, int16_t *block)
-{
- int i;
-
- for (i = 0; i < 64; i += 8)
- wmv2_idct_row(block + i);
- for (i = 0; i < 8; i++)
- wmv2_idct_col(block + i);
-
- for (i = 0; i < 8; i++) {
- dest[0] = av_clip_uint8(block[0]);
- dest[1] = av_clip_uint8(block[1]);
- dest[2] = av_clip_uint8(block[2]);
- dest[3] = av_clip_uint8(block[3]);
- dest[4] = av_clip_uint8(block[4]);
- dest[5] = av_clip_uint8(block[5]);
- dest[6] = av_clip_uint8(block[6]);
- dest[7] = av_clip_uint8(block[7]);
- dest += line_size;
- block += 8;
- }
-}
-
-av_cold void ff_wmv2dsp_init(WMV2DSPContext *c)
-{
- c->idct_add = wmv2_idct_add_c;
- c->idct_put = wmv2_idct_put_c;
- c->idct_perm = FF_NO_IDCT_PERM;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/wmv2dsp.h b/src/thirdparty/ffmpeg/libavcodec/wmv2dsp.h
deleted file mode 100644
index 37bee205a..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/wmv2dsp.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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_WMV2DSP_H
-#define AVCODEC_WMV2DSP_H
-
-#include <stdint.h>
-
-typedef struct WMV2DSPContext {
- void (*idct_add)(uint8_t *dest, int line_size, int16_t *block);
- void (*idct_put)(uint8_t *dest, int line_size, int16_t *block);
-
- int idct_perm;
-} WMV2DSPContext;
-
-void ff_wmv2dsp_init(WMV2DSPContext *c);
-
-#endif /* AVCODEC_WMV2DSP_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/ac3dsp.asm b/src/thirdparty/ffmpeg/libavcodec/x86/ac3dsp.asm
deleted file mode 100644
index f4c0b3921..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/ac3dsp.asm
+++ /dev/null
@@ -1,457 +0,0 @@
-;*****************************************************************************
-;* x86-optimized AC-3 DSP utils
-;* Copyright (c) 2011 Justin Ruggles
-;*
-;* 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
-
-; 16777216.0f - used in ff_float_to_fixed24()
-pf_1_24: times 4 dd 0x4B800000
-
-; used in ff_ac3_compute_mantissa_size()
-cextern ac3_bap_bits
-pw_bap_mul1: dw 21846, 21846, 0, 32768, 21846, 21846, 0, 32768
-pw_bap_mul2: dw 5, 7, 0, 7, 5, 7, 0, 7
-
-; used in ff_ac3_extract_exponents()
-pd_1: times 4 dd 1
-pd_151: times 4 dd 151
-
-SECTION .text
-
-;-----------------------------------------------------------------------------
-; void ff_ac3_exponent_min(uint8_t *exp, int num_reuse_blocks, int nb_coefs)
-;-----------------------------------------------------------------------------
-
-%macro AC3_EXPONENT_MIN 0
-cglobal ac3_exponent_min, 3, 4, 2, exp, reuse_blks, expn, offset
- shl reuse_blksq, 8
- jz .end
- LOOP_ALIGN
-.nextexp:
- mov offsetq, reuse_blksq
- mova m0, [expq+offsetq]
- sub offsetq, 256
- LOOP_ALIGN
-.nextblk:
- PMINUB m0, [expq+offsetq], m1
- sub offsetq, 256
- jae .nextblk
- mova [expq], m0
- add expq, mmsize
- sub expnq, mmsize
- jg .nextexp
-.end:
- REP_RET
-%endmacro
-
-%define LOOP_ALIGN
-INIT_MMX mmx
-AC3_EXPONENT_MIN
-%if HAVE_MMXEXT_EXTERNAL
-%define LOOP_ALIGN ALIGN 16
-INIT_MMX mmxext
-AC3_EXPONENT_MIN
-%endif
-%if HAVE_SSE2_EXTERNAL
-INIT_XMM sse2
-AC3_EXPONENT_MIN
-%endif
-%undef LOOP_ALIGN
-
-;-----------------------------------------------------------------------------
-; int ff_ac3_max_msb_abs_int16(const int16_t *src, int len)
-;
-; This function uses 2 different methods to calculate a valid result.
-; 1) logical 'or' of abs of each element
-; This is used for ssse3 because of the pabsw instruction.
-; It is also used for mmx because of the lack of min/max instructions.
-; 2) calculate min/max for the array, then or(abs(min),abs(max))
-; This is used for mmxext and sse2 because they have pminsw/pmaxsw.
-;-----------------------------------------------------------------------------
-
-; logical 'or' of 4 or 8 words in an mmx or xmm register into the low word
-%macro OR_WORDS_HORIZ 2 ; src, tmp
-%if cpuflag(sse2)
- movhlps %2, %1
- por %1, %2
- pshuflw %2, %1, q0032
- por %1, %2
- pshuflw %2, %1, q0001
- por %1, %2
-%elif cpuflag(mmxext)
- pshufw %2, %1, q0032
- por %1, %2
- pshufw %2, %1, q0001
- por %1, %2
-%else ; mmx
- movq %2, %1
- psrlq %2, 32
- por %1, %2
- movq %2, %1
- psrlq %2, 16
- por %1, %2
-%endif
-%endmacro
-
-%macro AC3_MAX_MSB_ABS_INT16 1
-cglobal ac3_max_msb_abs_int16, 2,2,5, src, len
- pxor m2, m2
- pxor m3, m3
-.loop:
-%ifidn %1, min_max
- mova m0, [srcq]
- mova m1, [srcq+mmsize]
- pminsw m2, m0
- pminsw m2, m1
- pmaxsw m3, m0
- pmaxsw m3, m1
-%else ; or_abs
-%if notcpuflag(ssse3)
- mova m0, [srcq]
- mova m1, [srcq+mmsize]
- ABS2 m0, m1, m3, m4
-%else ; ssse3
- ; using memory args is faster for ssse3
- pabsw m0, [srcq]
- pabsw m1, [srcq+mmsize]
-%endif
- por m2, m0
- por m2, m1
-%endif
- add srcq, mmsize*2
- sub lend, mmsize
- ja .loop
-%ifidn %1, min_max
- ABS2 m2, m3, m0, m1
- por m2, m3
-%endif
- OR_WORDS_HORIZ m2, m0
- movd eax, m2
- and eax, 0xFFFF
- RET
-%endmacro
-
-INIT_MMX mmx
-AC3_MAX_MSB_ABS_INT16 or_abs
-INIT_MMX mmxext
-AC3_MAX_MSB_ABS_INT16 min_max
-INIT_XMM sse2
-AC3_MAX_MSB_ABS_INT16 min_max
-INIT_XMM ssse3
-AC3_MAX_MSB_ABS_INT16 or_abs
-
-;-----------------------------------------------------------------------------
-; macro used for ff_ac3_lshift_int16() and ff_ac3_rshift_int32()
-;-----------------------------------------------------------------------------
-
-%macro AC3_SHIFT 3 ; l/r, 16/32, shift instruction, instruction set
-cglobal ac3_%1shift_int%2, 3, 3, 5, src, len, shift
- movd m0, shiftd
-.loop:
- mova m1, [srcq ]
- mova m2, [srcq+mmsize ]
- mova m3, [srcq+mmsize*2]
- mova m4, [srcq+mmsize*3]
- %3 m1, m0
- %3 m2, m0
- %3 m3, m0
- %3 m4, m0
- mova [srcq ], m1
- mova [srcq+mmsize ], m2
- mova [srcq+mmsize*2], m3
- mova [srcq+mmsize*3], m4
- add srcq, mmsize*4
- sub lend, mmsize*32/%2
- ja .loop
-.end:
- REP_RET
-%endmacro
-
-;-----------------------------------------------------------------------------
-; void ff_ac3_lshift_int16(int16_t *src, unsigned int len, unsigned int shift)
-;-----------------------------------------------------------------------------
-
-INIT_MMX mmx
-AC3_SHIFT l, 16, psllw
-INIT_XMM sse2
-AC3_SHIFT l, 16, psllw
-
-;-----------------------------------------------------------------------------
-; void ff_ac3_rshift_int32(int32_t *src, unsigned int len, unsigned int shift)
-;-----------------------------------------------------------------------------
-
-INIT_MMX mmx
-AC3_SHIFT r, 32, psrad
-INIT_XMM sse2
-AC3_SHIFT r, 32, psrad
-
-;-----------------------------------------------------------------------------
-; void ff_float_to_fixed24(int32_t *dst, const float *src, unsigned int len)
-;-----------------------------------------------------------------------------
-
-; The 3DNow! version is not bit-identical because pf2id uses truncation rather
-; than round-to-nearest.
-INIT_MMX 3dnow
-cglobal float_to_fixed24, 3, 3, 0, dst, src, len
- movq m0, [pf_1_24]
-.loop:
- movq m1, [srcq ]
- movq m2, [srcq+8 ]
- movq m3, [srcq+16]
- movq m4, [srcq+24]
- pfmul m1, m0
- pfmul m2, m0
- pfmul m3, m0
- pfmul m4, m0
- pf2id m1, m1
- pf2id m2, m2
- pf2id m3, m3
- pf2id m4, m4
- movq [dstq ], m1
- movq [dstq+8 ], m2
- movq [dstq+16], m3
- movq [dstq+24], m4
- add srcq, 32
- add dstq, 32
- sub lend, 8
- ja .loop
- femms
- RET
-
-INIT_XMM sse
-cglobal float_to_fixed24, 3, 3, 3, dst, src, len
- movaps m0, [pf_1_24]
-.loop:
- movaps m1, [srcq ]
- movaps m2, [srcq+16]
- mulps m1, m0
- mulps m2, m0
- cvtps2pi mm0, m1
- movhlps m1, m1
- cvtps2pi mm1, m1
- cvtps2pi mm2, m2
- movhlps m2, m2
- cvtps2pi mm3, m2
- movq [dstq ], mm0
- movq [dstq+ 8], mm1
- movq [dstq+16], mm2
- movq [dstq+24], mm3
- add srcq, 32
- add dstq, 32
- sub lend, 8
- ja .loop
- emms
- RET
-
-INIT_XMM sse2
-cglobal float_to_fixed24, 3, 3, 9, dst, src, len
- movaps m0, [pf_1_24]
-.loop:
- movaps m1, [srcq ]
- movaps m2, [srcq+16 ]
- movaps m3, [srcq+32 ]
- movaps m4, [srcq+48 ]
-%ifdef m8
- movaps m5, [srcq+64 ]
- movaps m6, [srcq+80 ]
- movaps m7, [srcq+96 ]
- movaps m8, [srcq+112]
-%endif
- mulps m1, m0
- mulps m2, m0
- mulps m3, m0
- mulps m4, m0
-%ifdef m8
- mulps m5, m0
- mulps m6, m0
- mulps m7, m0
- mulps m8, m0
-%endif
- cvtps2dq m1, m1
- cvtps2dq m2, m2
- cvtps2dq m3, m3
- cvtps2dq m4, m4
-%ifdef m8
- cvtps2dq m5, m5
- cvtps2dq m6, m6
- cvtps2dq m7, m7
- cvtps2dq m8, m8
-%endif
- movdqa [dstq ], m1
- movdqa [dstq+16 ], m2
- movdqa [dstq+32 ], m3
- movdqa [dstq+48 ], m4
-%ifdef m8
- movdqa [dstq+64 ], m5
- movdqa [dstq+80 ], m6
- movdqa [dstq+96 ], m7
- movdqa [dstq+112], m8
- add srcq, 128
- add dstq, 128
- sub lenq, 32
-%else
- add srcq, 64
- add dstq, 64
- sub lenq, 16
-%endif
- ja .loop
- REP_RET
-
-;------------------------------------------------------------------------------
-; int ff_ac3_compute_mantissa_size(uint16_t mant_cnt[6][16])
-;------------------------------------------------------------------------------
-
-%macro PHADDD4 2 ; xmm src, xmm tmp
- movhlps %2, %1
- paddd %1, %2
- pshufd %2, %1, 0x1
- paddd %1, %2
-%endmacro
-
-INIT_XMM sse2
-cglobal ac3_compute_mantissa_size, 1, 2, 4, mant_cnt, sum
- movdqa m0, [mant_cntq ]
- movdqa m1, [mant_cntq+ 1*16]
- paddw m0, [mant_cntq+ 2*16]
- paddw m1, [mant_cntq+ 3*16]
- paddw m0, [mant_cntq+ 4*16]
- paddw m1, [mant_cntq+ 5*16]
- paddw m0, [mant_cntq+ 6*16]
- paddw m1, [mant_cntq+ 7*16]
- paddw m0, [mant_cntq+ 8*16]
- paddw m1, [mant_cntq+ 9*16]
- paddw m0, [mant_cntq+10*16]
- paddw m1, [mant_cntq+11*16]
- pmaddwd m0, [ac3_bap_bits ]
- pmaddwd m1, [ac3_bap_bits+16]
- paddd m0, m1
- PHADDD4 m0, m1
- movd sumd, m0
- movdqa m3, [pw_bap_mul1]
- movhpd m0, [mant_cntq +2]
- movlpd m0, [mant_cntq+1*32+2]
- movhpd m1, [mant_cntq+2*32+2]
- movlpd m1, [mant_cntq+3*32+2]
- movhpd m2, [mant_cntq+4*32+2]
- movlpd m2, [mant_cntq+5*32+2]
- pmulhuw m0, m3
- pmulhuw m1, m3
- pmulhuw m2, m3
- paddusw m0, m1
- paddusw m0, m2
- pmaddwd m0, [pw_bap_mul2]
- PHADDD4 m0, m1
- movd eax, m0
- add eax, sumd
- RET
-
-;------------------------------------------------------------------------------
-; void ff_ac3_extract_exponents(uint8_t *exp, int32_t *coef, int nb_coefs)
-;------------------------------------------------------------------------------
-
-%macro PABSD 1-2 ; src/dst, unused
-%if cpuflag(ssse3)
- pabsd %1, %1
-%else ; src/dst, tmp
- pxor %2, %2
- pcmpgtd %2, %1
- pxor %1, %2
- psubd %1, %2
-%endif
-%endmacro
-
-%if HAVE_AMD3DNOW_EXTERNAL
-INIT_MMX 3dnow
-cglobal ac3_extract_exponents, 3, 3, 0, exp, coef, len
- add expq, lenq
- lea coefq, [coefq+4*lenq]
- neg lenq
- movq m3, [pd_1]
- movq m4, [pd_151]
-.loop:
- movq m0, [coefq+4*lenq ]
- movq m1, [coefq+4*lenq+8]
- PABSD m0, m2
- PABSD m1, m2
- pslld m0, 1
- por m0, m3
- pi2fd m2, m0
- psrld m2, 23
- movq m0, m4
- psubd m0, m2
- pslld m1, 1
- por m1, m3
- pi2fd m2, m1
- psrld m2, 23
- movq m1, m4
- psubd m1, m2
- packssdw m0, m0
- packuswb m0, m0
- packssdw m1, m1
- packuswb m1, m1
- punpcklwd m0, m1
- movd [expq+lenq], m0
- add lenq, 4
- jl .loop
- REP_RET
-%endif
-
-%macro AC3_EXTRACT_EXPONENTS 0
-cglobal ac3_extract_exponents, 3, 3, 4, exp, coef, len
- add expq, lenq
- lea coefq, [coefq+4*lenq]
- neg lenq
- mova m2, [pd_1]
- mova m3, [pd_151]
-.loop:
- ; move 4 32-bit coefs to xmm0
- mova m0, [coefq+4*lenq]
- ; absolute value
- PABSD m0, m1
- ; convert to float and extract exponents
- pslld m0, 1
- por m0, m2
- cvtdq2ps m1, m0
- psrld m1, 23
- mova m0, m3
- psubd m0, m1
- ; move the lowest byte in each of 4 dwords to the low dword
- ; NOTE: We cannot just extract the low bytes with pshufb because the dword
- ; result for 16777215 is -1 due to float inaccuracy. Using packuswb
- ; clips this to 0, which is the correct exponent.
- packssdw m0, m0
- packuswb m0, m0
- movd [expq+lenq], m0
-
- add lenq, 4
- jl .loop
- REP_RET
-%endmacro
-
-%if HAVE_SSE2_EXTERNAL
-INIT_XMM sse2
-AC3_EXTRACT_EXPONENTS
-%endif
-%if HAVE_SSSE3_EXTERNAL
-INIT_XMM ssse3
-AC3_EXTRACT_EXPONENTS
-%endif
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/ac3dsp_init.c b/src/thirdparty/ffmpeg/libavcodec/x86/ac3dsp_init.c
deleted file mode 100644
index e2a190e07..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/ac3dsp_init.c
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * x86-optimized AC-3 DSP utils
- * Copyright (c) 2011 Justin Ruggles
- *
- * 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/mem.h"
-#include "libavutil/x86/asm.h"
-#include "libavutil/x86/cpu.h"
-#include "dsputil_mmx.h"
-#include "libavcodec/ac3.h"
-#include "libavcodec/ac3dsp.h"
-
-extern void ff_ac3_exponent_min_mmx (uint8_t *exp, int num_reuse_blocks, int nb_coefs);
-extern void ff_ac3_exponent_min_mmxext(uint8_t *exp, int num_reuse_blocks, int nb_coefs);
-extern void ff_ac3_exponent_min_sse2 (uint8_t *exp, int num_reuse_blocks, int nb_coefs);
-
-extern int ff_ac3_max_msb_abs_int16_mmx (const int16_t *src, int len);
-extern int ff_ac3_max_msb_abs_int16_mmxext(const int16_t *src, int len);
-extern int ff_ac3_max_msb_abs_int16_sse2 (const int16_t *src, int len);
-extern int ff_ac3_max_msb_abs_int16_ssse3(const int16_t *src, int len);
-
-extern void ff_ac3_lshift_int16_mmx (int16_t *src, unsigned int len, unsigned int shift);
-extern void ff_ac3_lshift_int16_sse2(int16_t *src, unsigned int len, unsigned int shift);
-
-extern void ff_ac3_rshift_int32_mmx (int32_t *src, unsigned int len, unsigned int shift);
-extern void ff_ac3_rshift_int32_sse2(int32_t *src, unsigned int len, unsigned int shift);
-
-extern void ff_float_to_fixed24_3dnow(int32_t *dst, const float *src, unsigned int len);
-extern void ff_float_to_fixed24_sse (int32_t *dst, const float *src, unsigned int len);
-extern void ff_float_to_fixed24_sse2 (int32_t *dst, const float *src, unsigned int len);
-
-extern int ff_ac3_compute_mantissa_size_sse2(uint16_t mant_cnt[6][16]);
-
-extern void ff_ac3_extract_exponents_3dnow(uint8_t *exp, int32_t *coef, int nb_coefs);
-extern void ff_ac3_extract_exponents_sse2 (uint8_t *exp, int32_t *coef, int nb_coefs);
-extern void ff_ac3_extract_exponents_ssse3(uint8_t *exp, int32_t *coef, int nb_coefs);
-
-#if ARCH_X86_32 && defined(__INTEL_COMPILER)
-# undef HAVE_7REGS
-# define HAVE_7REGS 0
-#endif
-
-#if HAVE_SSE_INLINE && HAVE_7REGS
-
-#define IF1(x) x
-#define IF0(x)
-
-#define MIX5(mono, stereo) \
- __asm__ volatile ( \
- "movss 0(%1), %%xmm5 \n" \
- "movss 8(%1), %%xmm6 \n" \
- "movss 24(%1), %%xmm7 \n" \
- "shufps $0, %%xmm5, %%xmm5 \n" \
- "shufps $0, %%xmm6, %%xmm6 \n" \
- "shufps $0, %%xmm7, %%xmm7 \n" \
- "1: \n" \
- "movaps (%0, %2), %%xmm0 \n" \
- "movaps (%0, %3), %%xmm1 \n" \
- "movaps (%0, %4), %%xmm2 \n" \
- "movaps (%0, %5), %%xmm3 \n" \
- "movaps (%0, %6), %%xmm4 \n" \
- "mulps %%xmm5, %%xmm0 \n" \
- "mulps %%xmm6, %%xmm1 \n" \
- "mulps %%xmm5, %%xmm2 \n" \
- "mulps %%xmm7, %%xmm3 \n" \
- "mulps %%xmm7, %%xmm4 \n" \
- stereo("addps %%xmm1, %%xmm0 \n") \
- "addps %%xmm1, %%xmm2 \n" \
- "addps %%xmm3, %%xmm0 \n" \
- "addps %%xmm4, %%xmm2 \n" \
- mono("addps %%xmm2, %%xmm0 \n") \
- "movaps %%xmm0, (%0, %2) \n" \
- stereo("movaps %%xmm2, (%0, %3) \n") \
- "add $16, %0 \n" \
- "jl 1b \n" \
- : "+&r"(i) \
- : "r"(matrix), \
- "r"(samples[0] + len), \
- "r"(samples[1] + len), \
- "r"(samples[2] + len), \
- "r"(samples[3] + len), \
- "r"(samples[4] + len) \
- : XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3", \
- "%xmm4", "%xmm5", "%xmm6", "%xmm7",) \
- "memory" \
- );
-
-#define MIX_MISC(stereo) \
- __asm__ volatile ( \
- "mov %5, %2 \n" \
- "1: \n" \
- "mov -%c7(%6, %2, %c8), %3 \n" \
- "movaps (%3, %0), %%xmm0 \n" \
- stereo("movaps %%xmm0, %%xmm1 \n") \
- "mulps %%xmm4, %%xmm0 \n" \
- stereo("mulps %%xmm5, %%xmm1 \n") \
- "2: \n" \
- "mov (%6, %2, %c8), %1 \n" \
- "movaps (%1, %0), %%xmm2 \n" \
- stereo("movaps %%xmm2, %%xmm3 \n") \
- "mulps (%4, %2, 8), %%xmm2 \n" \
- stereo("mulps 16(%4, %2, 8), %%xmm3 \n") \
- "addps %%xmm2, %%xmm0 \n" \
- stereo("addps %%xmm3, %%xmm1 \n") \
- "add $4, %2 \n" \
- "jl 2b \n" \
- "mov %5, %2 \n" \
- stereo("mov (%6, %2, %c8), %1 \n") \
- "movaps %%xmm0, (%3, %0) \n" \
- stereo("movaps %%xmm1, (%1, %0) \n") \
- "add $16, %0 \n" \
- "jl 1b \n" \
- : "+&r"(i), "=&r"(j), "=&r"(k), "=&r"(m) \
- : "r"(matrix_simd + in_ch), \
- "g"((intptr_t) - 4 * (in_ch - 1)), \
- "r"(samp + in_ch), \
- "i"(sizeof(float *)), "i"(sizeof(float *)/4) \
- : "memory" \
- );
-
-static void ac3_downmix_sse(float **samples, float (*matrix)[2],
- int out_ch, int in_ch, int len)
-{
- int (*matrix_cmp)[2] = (int(*)[2])matrix;
- intptr_t i, j, k, m;
-
- i = -len * sizeof(float);
- if (in_ch == 5 && out_ch == 2 &&
- !(matrix_cmp[0][1] | matrix_cmp[2][0] |
- matrix_cmp[3][1] | matrix_cmp[4][0] |
- (matrix_cmp[1][0] ^ matrix_cmp[1][1]) |
- (matrix_cmp[0][0] ^ matrix_cmp[2][1]))) {
- MIX5(IF0, IF1);
- } else if (in_ch == 5 && out_ch == 1 &&
- matrix_cmp[0][0] == matrix_cmp[2][0] &&
- matrix_cmp[3][0] == matrix_cmp[4][0]) {
- MIX5(IF1, IF0);
- } else {
- DECLARE_ALIGNED(16, float, matrix_simd)[AC3_MAX_CHANNELS][2][4];
- float *samp[AC3_MAX_CHANNELS];
-
- for (j = 0; j < in_ch; j++)
- samp[j] = samples[j] + len;
-
- j = 2 * in_ch * sizeof(float);
- __asm__ volatile (
- "1: \n"
- "sub $8, %0 \n"
- "movss (%2, %0), %%xmm4 \n"
- "movss 4(%2, %0), %%xmm5 \n"
- "shufps $0, %%xmm4, %%xmm4 \n"
- "shufps $0, %%xmm5, %%xmm5 \n"
- "movaps %%xmm4, (%1, %0, 4) \n"
- "movaps %%xmm5, 16(%1, %0, 4) \n"
- "jg 1b \n"
- : "+&r"(j)
- : "r"(matrix_simd), "r"(matrix)
- : "memory"
- );
- if (out_ch == 2) {
- MIX_MISC(IF1);
- } else {
- MIX_MISC(IF0);
- }
- }
-}
-
-#endif /* HAVE_SSE_INLINE && HAVE_7REGS */
-
-av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c, int bit_exact)
-{
- int mm_flags = av_get_cpu_flags();
-
- if (EXTERNAL_MMX(mm_flags)) {
- c->ac3_exponent_min = ff_ac3_exponent_min_mmx;
- c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_mmx;
- c->ac3_lshift_int16 = ff_ac3_lshift_int16_mmx;
- c->ac3_rshift_int32 = ff_ac3_rshift_int32_mmx;
- }
- if (EXTERNAL_AMD3DNOW(mm_flags)) {
- c->extract_exponents = ff_ac3_extract_exponents_3dnow;
- if (!bit_exact) {
- c->float_to_fixed24 = ff_float_to_fixed24_3dnow;
- }
- }
- if (EXTERNAL_MMXEXT(mm_flags)) {
- c->ac3_exponent_min = ff_ac3_exponent_min_mmxext;
- c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_mmxext;
- }
- if (EXTERNAL_SSE(mm_flags)) {
- c->float_to_fixed24 = ff_float_to_fixed24_sse;
- }
- if (EXTERNAL_SSE2(mm_flags)) {
- c->ac3_exponent_min = ff_ac3_exponent_min_sse2;
- c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_sse2;
- c->float_to_fixed24 = ff_float_to_fixed24_sse2;
- c->compute_mantissa_size = ff_ac3_compute_mantissa_size_sse2;
- c->extract_exponents = ff_ac3_extract_exponents_sse2;
- if (!(mm_flags & AV_CPU_FLAG_SSE2SLOW)) {
- c->ac3_lshift_int16 = ff_ac3_lshift_int16_sse2;
- c->ac3_rshift_int32 = ff_ac3_rshift_int32_sse2;
- }
- }
- if (EXTERNAL_SSSE3(mm_flags)) {
- c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_ssse3;
- if (!(mm_flags & AV_CPU_FLAG_ATOM)) {
- c->extract_exponents = ff_ac3_extract_exponents_ssse3;
- }
- }
-
-#if HAVE_SSE_INLINE && HAVE_7REGS
- if (INLINE_SSE(mm_flags)) {
- c->downmix = ac3_downmix_sse;
- }
-#endif
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/cabac.h b/src/thirdparty/ffmpeg/libavcodec/x86/cabac.h
deleted file mode 100644
index 55ce26f86..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/cabac.h
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_X86_CABAC_H
-#define AVCODEC_X86_CABAC_H
-
-#include "libavcodec/cabac.h"
-#include "libavutil/attributes.h"
-#include "libavutil/x86/asm.h"
-#include "libavutil/internal.h"
-#include "config.h"
-
-#if HAVE_INLINE_ASM
-
-#ifdef BROKEN_RELOCATIONS
-#define TABLES_ARG , "r"(tables)
-
-#if HAVE_FAST_CMOV
-#define BRANCHLESS_GET_CABAC_UPDATE(ret, retq, low, range, tmp) \
- "cmp "low" , "tmp" \n\t"\
- "cmova %%ecx , "range" \n\t"\
- "sbb %%rcx , %%rcx \n\t"\
- "and %%ecx , "tmp" \n\t"\
- "xor %%rcx , "retq" \n\t"\
- "sub "tmp" , "low" \n\t"
-#else /* HAVE_FAST_CMOV */
-#define BRANCHLESS_GET_CABAC_UPDATE(ret, retq, low, range, tmp) \
-/* P4 Prescott has crappy cmov,sbb,64bit shift so avoid them */ \
- "sub "low" , "tmp" \n\t"\
- "sar $31 , "tmp" \n\t"\
- "sub %%ecx , "range" \n\t"\
- "and "tmp" , "range" \n\t"\
- "add %%ecx , "range" \n\t"\
- "shl $17 , %%ecx \n\t"\
- "and "tmp" , %%ecx \n\t"\
- "sub %%ecx , "low" \n\t"\
- "xor "tmp" , "ret" \n\t"\
- "movslq "ret" , "retq" \n\t"
-#endif /* HAVE_FAST_CMOV */
-
-#define BRANCHLESS_GET_CABAC(ret, retq, statep, low, lowword, range, rangeq, tmp, tmpbyte, byte, end, norm_off, lps_off, mlps_off, tables) \
- "movzbl "statep" , "ret" \n\t"\
- "mov "range" , "tmp" \n\t"\
- "and $0xC0 , "range" \n\t"\
- "lea ("ret", "range", 2), %%ecx \n\t"\
- "movzbl "lps_off"("tables", %%rcx), "range" \n\t"\
- "sub "range" , "tmp" \n\t"\
- "mov "tmp" , %%ecx \n\t"\
- "shl $17 , "tmp" \n\t"\
- BRANCHLESS_GET_CABAC_UPDATE(ret, retq, low, range, tmp) \
- "movzbl "norm_off"("tables", "rangeq"), %%ecx \n\t"\
- "shl %%cl , "range" \n\t"\
- "movzbl "mlps_off"+128("tables", "retq"), "tmp" \n\t"\
- "shl %%cl , "low" \n\t"\
- "mov "tmpbyte" , "statep" \n\t"\
- "test "lowword" , "lowword" \n\t"\
- "jnz 2f \n\t"\
- "mov "byte" , %%"REG_c" \n\t"\
- "add"OPSIZE" $2 , "byte" \n\t"\
- "movzwl (%%"REG_c") , "tmp" \n\t"\
- "lea -1("low") , %%ecx \n\t"\
- "xor "low" , %%ecx \n\t"\
- "shr $15 , %%ecx \n\t"\
- "bswap "tmp" \n\t"\
- "shr $15 , "tmp" \n\t"\
- "movzbl "norm_off"("tables", %%rcx), %%ecx \n\t"\
- "sub $0xFFFF , "tmp" \n\t"\
- "neg %%ecx \n\t"\
- "add $7 , %%ecx \n\t"\
- "shl %%cl , "tmp" \n\t"\
- "add "tmp" , "low" \n\t"\
- "2: \n\t"
-
-#else /* BROKEN_RELOCATIONS */
-#define TABLES_ARG
-#define RIP_ARG
-
-#if HAVE_FAST_CMOV
-#define BRANCHLESS_GET_CABAC_UPDATE(ret, low, range, tmp)\
- "mov "tmp" , %%ecx \n\t"\
- "shl $17 , "tmp" \n\t"\
- "cmp "low" , "tmp" \n\t"\
- "cmova %%ecx , "range" \n\t"\
- "sbb %%ecx , %%ecx \n\t"\
- "and %%ecx , "tmp" \n\t"\
- "xor %%ecx , "ret" \n\t"\
- "sub "tmp" , "low" \n\t"
-#else /* HAVE_FAST_CMOV */
-#define BRANCHLESS_GET_CABAC_UPDATE(ret, low, range, tmp)\
- "mov "tmp" , %%ecx \n\t"\
- "shl $17 , "tmp" \n\t"\
- "sub "low" , "tmp" \n\t"\
- "sar $31 , "tmp" \n\t" /*lps_mask*/\
- "sub %%ecx , "range" \n\t" /*RangeLPS - range*/\
- "and "tmp" , "range" \n\t" /*(RangeLPS - range)&lps_mask*/\
- "add %%ecx , "range" \n\t" /*new range*/\
- "shl $17 , %%ecx \n\t"\
- "and "tmp" , %%ecx \n\t"\
- "sub %%ecx , "low" \n\t"\
- "xor "tmp" , "ret" \n\t"
-#endif /* HAVE_FAST_CMOV */
-
-#define BRANCHLESS_GET_CABAC(ret, retq, statep, low, lowword, range, rangeq, tmp, tmpbyte, byte, end, norm_off, lps_off, mlps_off, tables) \
- "movzbl "statep" , "ret" \n\t"\
- "mov "range" , "tmp" \n\t"\
- "and $0xC0 , "range" \n\t"\
- "movzbl "MANGLE(ff_h264_cabac_tables)"+"lps_off"("ret", "range", 2), "range" \n\t"\
- "sub "range" , "tmp" \n\t"\
- BRANCHLESS_GET_CABAC_UPDATE(ret, low, range, tmp) \
- "movzbl "MANGLE(ff_h264_cabac_tables)"+"norm_off"("range"), %%ecx \n\t"\
- "shl %%cl , "range" \n\t"\
- "movzbl "MANGLE(ff_h264_cabac_tables)"+"mlps_off"+128("ret"), "tmp" \n\t"\
- "shl %%cl , "low" \n\t"\
- "mov "tmpbyte" , "statep" \n\t"\
- "test "lowword" , "lowword" \n\t"\
- " jnz 2f \n\t"\
- "mov "byte" , %%"REG_c" \n\t"\
- "add"OPSIZE" $2 , "byte" \n\t"\
- "movzwl (%%"REG_c") , "tmp" \n\t"\
- "lea -1("low") , %%ecx \n\t"\
- "xor "low" , %%ecx \n\t"\
- "shr $15 , %%ecx \n\t"\
- "bswap "tmp" \n\t"\
- "shr $15 , "tmp" \n\t"\
- "movzbl "MANGLE(ff_h264_cabac_tables)"+"norm_off"(%%ecx), %%ecx \n\t"\
- "sub $0xFFFF , "tmp" \n\t"\
- "neg %%ecx \n\t"\
- "add $7 , %%ecx \n\t"\
- "shl %%cl , "tmp" \n\t"\
- "add "tmp" , "low" \n\t"\
- "2: \n\t"
-
-#endif /* BROKEN_RELOCATIONS */
-
-
-#if HAVE_7REGS && !(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)
-#define get_cabac_inline get_cabac_inline_x86
-static av_always_inline int get_cabac_inline_x86(CABACContext *c,
- uint8_t *const state)
-{
- int bit, tmp;
-#ifdef BROKEN_RELOCATIONS
- void *tables;
-
- __asm__ volatile(
- "lea "MANGLE(ff_h264_cabac_tables)", %0 \n\t"
- : "=&r"(tables)
- );
-#endif
-
- __asm__ volatile(
- BRANCHLESS_GET_CABAC("%0", "%q0", "(%4)", "%1", "%w1",
- "%2", "%q2", "%3", "%b3",
- "%c6(%5)", "%c7(%5)",
- AV_STRINGIFY(H264_NORM_SHIFT_OFFSET),
- AV_STRINGIFY(H264_LPS_RANGE_OFFSET),
- AV_STRINGIFY(H264_MLPS_STATE_OFFSET),
- "%8")
- : "=&r"(bit), "=&r"(c->low), "=&r"(c->range), "=&q"(tmp)
- : "r"(state), "r"(c),
- "i"(offsetof(CABACContext, bytestream)),
- "i"(offsetof(CABACContext, bytestream_end))
- TABLES_ARG
- ,"1"(c->low), "2"(c->range)
- : "%"REG_c, "memory"
- );
- return bit & 1;
-}
-#endif /* HAVE_7REGS */
-
-#define get_cabac_bypass_sign get_cabac_bypass_sign_x86
-static av_always_inline int get_cabac_bypass_sign_x86(CABACContext *c, int val)
-{
- x86_reg tmp;
- __asm__ volatile(
- "movl %c6(%2), %k1 \n\t"
- "movl %c3(%2), %%eax \n\t"
- "shl $17, %k1 \n\t"
- "add %%eax, %%eax \n\t"
- "sub %k1, %%eax \n\t"
- "cltd \n\t"
- "and %%edx, %k1 \n\t"
- "add %k1, %%eax \n\t"
- "xor %%edx, %%ecx \n\t"
- "sub %%edx, %%ecx \n\t"
- "test %%ax, %%ax \n\t"
- "jnz 1f \n\t"
- "mov %c4(%2), %1 \n\t"
- "subl $0xFFFF, %%eax \n\t"
- "movzwl (%1), %%edx \n\t"
- "bswap %%edx \n\t"
- "shrl $15, %%edx \n\t"
- "add $2, %1 \n\t"
- "addl %%edx, %%eax \n\t"
- "mov %1, %c4(%2) \n\t"
- "1: \n\t"
- "movl %%eax, %c3(%2) \n\t"
-
- : "+c"(val), "=&r"(tmp)
- : "r"(c),
- "i"(offsetof(CABACContext, low)),
- "i"(offsetof(CABACContext, bytestream)),
- "i"(offsetof(CABACContext, bytestream_end)),
- "i"(offsetof(CABACContext, range))
- : "%eax", "%edx", "memory"
- );
- return val;
-}
-
-#endif /* HAVE_INLINE_ASM */
-#endif /* AVCODEC_X86_CABAC_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/dct32.asm b/src/thirdparty/ffmpeg/libavcodec/x86/dct32.asm
deleted file mode 100644
index 6fd5ba350..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/dct32.asm
+++ /dev/null
@@ -1,490 +0,0 @@
-;******************************************************************************
-;* 32 point SSE-optimized DCT transform
-;* Copyright (c) 2010 Vitor Sessak
-;*
-;* 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 32
-
-align 32
-ps_cos_vec: dd 0.500603, 0.505471, 0.515447, 0.531043
- dd 0.553104, 0.582935, 0.622504, 0.674808
- dd -10.190008, -3.407609, -2.057781, -1.484165
- dd -1.169440, -0.972568, -0.839350, -0.744536
- dd 0.502419, 0.522499, 0.566944, 0.646822
- dd 0.788155, 1.060678, 1.722447, 5.101149
- dd 0.509796, 0.601345, 0.899976, 2.562916
- dd 0.509796, 0.601345, 0.899976, 2.562916
- dd 1.000000, 1.000000, 1.306563, 0.541196
- dd 1.000000, 1.000000, 1.306563, 0.541196
- dd 1.000000, 0.707107, 1.000000, -0.707107
- dd 1.000000, 0.707107, 1.000000, -0.707107
- dd 0.707107, 0.707107, 0.707107, 0.707107
-
-align 32
-ps_p1p1m1m1: dd 0, 0, 0x80000000, 0x80000000, 0, 0, 0x80000000, 0x80000000
-
-%macro BUTTERFLY 4
- subps %4, %1, %2
- addps %2, %2, %1
- mulps %1, %4, %3
-%endmacro
-
-%macro BUTTERFLY0 5
-%if cpuflag(sse2) && notcpuflag(avx)
- pshufd %4, %1, %5
- xorps %1, %2
- addps %1, %4
- mulps %1, %3
-%else
- shufps %4, %1, %1, %5
- xorps %1, %1, %2
- addps %4, %4, %1
- mulps %1, %4, %3
-%endif
-%endmacro
-
-%macro BUTTERFLY2 4
- BUTTERFLY0 %1, %2, %3, %4, 0x1b
-%endmacro
-
-%macro BUTTERFLY3 4
- BUTTERFLY0 %1, %2, %3, %4, 0xb1
-%endmacro
-
-%macro BUTTERFLY3V 5
- movaps m%5, m%1
- addps m%1, m%2
- subps m%5, m%2
- SWAP %2, %5
- mulps m%2, [ps_cos_vec+192]
- movaps m%5, m%3
- addps m%3, m%4
- subps m%4, m%5
- mulps m%4, [ps_cos_vec+192]
-%endmacro
-
-%macro PASS6_AND_PERMUTE 0
- mov tmpd, [outq+4]
- movss m7, [outq+72]
- addss m7, [outq+76]
- movss m3, [outq+56]
- addss m3, [outq+60]
- addss m4, m3
- movss m2, [outq+52]
- addss m2, m3
- movss m3, [outq+104]
- addss m3, [outq+108]
- addss m1, m3
- addss m5, m4
- movss [outq+ 16], m1
- movss m1, [outq+100]
- addss m1, m3
- movss m3, [outq+40]
- movss [outq+ 48], m1
- addss m3, [outq+44]
- movss m1, [outq+100]
- addss m4, m3
- addss m3, m2
- addss m1, [outq+108]
- movss [outq+ 40], m3
- addss m2, [outq+36]
- movss m3, [outq+8]
- movss [outq+ 56], m2
- addss m3, [outq+12]
- movss [outq+ 32], m3
- movss m3, [outq+80]
- movss [outq+ 8], m5
- movss [outq+ 80], m1
- movss m2, [outq+52]
- movss m5, [outq+120]
- addss m5, [outq+124]
- movss m1, [outq+64]
- addss m2, [outq+60]
- addss m0, m5
- addss m5, [outq+116]
- mov [outq+64], tmpd
- addss m6, m0
- addss m1, m6
- mov tmpd, [outq+12]
- mov [outq+ 96], tmpd
- movss [outq+ 4], m1
- movss m1, [outq+24]
- movss [outq+ 24], m4
- movss m4, [outq+88]
- addss m4, [outq+92]
- addss m3, m4
- addss m4, [outq+84]
- mov tmpd, [outq+108]
- addss m1, [outq+28]
- addss m0, m1
- addss m1, m5
- addss m6, m3
- addss m3, m0
- addss m0, m7
- addss m5, [outq+20]
- addss m7, m1
- movss [outq+ 12], m6
- mov [outq+112], tmpd
- movss m6, [outq+28]
- movss [outq+ 28], m0
- movss m0, [outq+36]
- movss [outq+ 36], m7
- addss m1, m4
- movss m7, [outq+116]
- addss m0, m2
- addss m7, [outq+124]
- movss [outq+ 72], m0
- movss m0, [outq+44]
- addss m2, m0
- movss [outq+ 44], m1
- movss [outq+ 88], m2
- addss m0, [outq+60]
- mov tmpd, [outq+60]
- mov [outq+120], tmpd
- movss [outq+104], m0
- addss m4, m5
- addss m5, [outq+68]
- movss [outq+52], m4
- movss [outq+60], m5
- movss m4, [outq+68]
- movss m5, [outq+20]
- movss [outq+ 20], m3
- addss m5, m7
- addss m7, m6
- addss m4, m5
- movss m2, [outq+84]
- addss m2, [outq+92]
- addss m5, m2
- movss [outq+ 68], m4
- addss m2, m7
- movss m4, [outq+76]
- movss [outq+ 84], m2
- movss [outq+ 76], m5
- addss m7, m4
- addss m6, [outq+124]
- addss m4, m6
- addss m6, [outq+92]
- movss [outq+100], m4
- movss [outq+108], m6
- movss m6, [outq+92]
- movss [outq+92], m7
- addss m6, [outq+124]
- movss [outq+116], m6
-%endmacro
-
-INIT_YMM avx
-SECTION_TEXT
-%if HAVE_AVX_EXTERNAL
-; void ff_dct32_float_avx(FFTSample *out, const FFTSample *in)
-cglobal dct32_float, 2,3,8, out, in, tmp
- ; pass 1
- vmovaps m4, [inq+0]
- vinsertf128 m5, m5, [inq+96], 1
- vinsertf128 m5, m5, [inq+112], 0
- vshufps m5, m5, m5, 0x1b
- BUTTERFLY m4, m5, [ps_cos_vec], m6
-
- vmovaps m2, [inq+64]
- vinsertf128 m6, m6, [inq+32], 1
- vinsertf128 m6, m6, [inq+48], 0
- vshufps m6, m6, m6, 0x1b
- BUTTERFLY m2, m6, [ps_cos_vec+32], m0
-
- ; pass 2
-
- BUTTERFLY m5, m6, [ps_cos_vec+64], m0
- BUTTERFLY m4, m2, [ps_cos_vec+64], m7
-
-
- ; pass 3
- vperm2f128 m3, m6, m4, 0x31
- vperm2f128 m1, m6, m4, 0x20
- vshufps m3, m3, m3, 0x1b
-
- BUTTERFLY m1, m3, [ps_cos_vec+96], m6
-
-
- vperm2f128 m4, m5, m2, 0x20
- vperm2f128 m5, m5, m2, 0x31
- vshufps m5, m5, m5, 0x1b
-
- BUTTERFLY m4, m5, [ps_cos_vec+96], m6
-
- ; pass 4
- vmovaps m6, [ps_p1p1m1m1+0]
- vmovaps m2, [ps_cos_vec+128]
-
- BUTTERFLY2 m5, m6, m2, m7
- BUTTERFLY2 m4, m6, m2, m7
- BUTTERFLY2 m1, m6, m2, m7
- BUTTERFLY2 m3, m6, m2, m7
-
-
- ; pass 5
- vshufps m6, m6, m6, 0xcc
- vmovaps m2, [ps_cos_vec+160]
-
- BUTTERFLY3 m5, m6, m2, m7
- BUTTERFLY3 m4, m6, m2, m7
- BUTTERFLY3 m1, m6, m2, m7
- BUTTERFLY3 m3, m6, m2, m7
-
- vperm2f128 m6, m3, m3, 0x31
- vmovaps [outq], m3
-
- vextractf128 [outq+64], m5, 1
- vextractf128 [outq+32], m5, 0
-
- vextractf128 [outq+80], m4, 1
- vextractf128 [outq+48], m4, 0
-
- vperm2f128 m0, m1, m1, 0x31
- vmovaps [outq+96], m1
-
- vzeroupper
-
- ; pass 6, no SIMD...
-INIT_XMM
- PASS6_AND_PERMUTE
- RET
-%endif
-
-%if ARCH_X86_64
-%define SPILL SWAP
-%define UNSPILL SWAP
-
-%macro PASS5 0
- nop ; FIXME code alignment
- SWAP 5, 8
- SWAP 4, 12
- SWAP 6, 14
- SWAP 7, 13
- SWAP 0, 15
- PERMUTE 9,10, 10,12, 11,14, 12,9, 13,11, 14,13
- TRANSPOSE4x4PS 8, 9, 10, 11, 0
- BUTTERFLY3V 8, 9, 10, 11, 0
- addps m10, m11
- TRANSPOSE4x4PS 12, 13, 14, 15, 0
- BUTTERFLY3V 12, 13, 14, 15, 0
- addps m14, m15
- addps m12, m14
- addps m14, m13
- addps m13, m15
-%endmacro
-
-%macro PASS6 0
- SWAP 9, 12
- SWAP 11, 14
- movss [outq+0x00], m8
- pshuflw m0, m8, 0xe
- movss [outq+0x10], m9
- pshuflw m1, m9, 0xe
- movss [outq+0x20], m10
- pshuflw m2, m10, 0xe
- movss [outq+0x30], m11
- pshuflw m3, m11, 0xe
- movss [outq+0x40], m12
- pshuflw m4, m12, 0xe
- movss [outq+0x50], m13
- pshuflw m5, m13, 0xe
- movss [outq+0x60], m14
- pshuflw m6, m14, 0xe
- movaps [outq+0x70], m15
- pshuflw m7, m15, 0xe
- addss m0, m1
- addss m1, m2
- movss [outq+0x08], m0
- addss m2, m3
- movss [outq+0x18], m1
- addss m3, m4
- movss [outq+0x28], m2
- addss m4, m5
- movss [outq+0x38], m3
- addss m5, m6
- movss [outq+0x48], m4
- addss m6, m7
- movss [outq+0x58], m5
- movss [outq+0x68], m6
- movss [outq+0x78], m7
-
- PERMUTE 1,8, 3,9, 5,10, 7,11, 9,12, 11,13, 13,14, 8,1, 10,3, 12,5, 14,7
- movhlps m0, m1
- pshufd m1, m1, 3
- SWAP 0, 2, 4, 6, 8, 10, 12, 14
- SWAP 1, 3, 5, 7, 9, 11, 13, 15
-%rep 7
- movhlps m0, m1
- pshufd m1, m1, 3
- addss m15, m1
- SWAP 0, 2, 4, 6, 8, 10, 12, 14
- SWAP 1, 3, 5, 7, 9, 11, 13, 15
-%endrep
-%assign i 4
-%rep 15
- addss m0, m1
- movss [outq+i], m0
- SWAP 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
- %assign i i+8
-%endrep
-%endmacro
-
-%else ; ARCH_X86_32
-%macro SPILL 2 ; xmm#, mempos
- movaps [outq+(%2-8)*16], m%1
-%endmacro
-%macro UNSPILL 2
- movaps m%1, [outq+(%2-8)*16]
-%endmacro
-
-%define PASS6 PASS6_AND_PERMUTE
-%macro PASS5 0
- movaps m2, [ps_cos_vec+160]
- shufps m3, m3, 0xcc
-
- BUTTERFLY3 m5, m3, m2, m1
- SPILL 5, 8
-
- UNSPILL 1, 9
- BUTTERFLY3 m1, m3, m2, m5
- SPILL 1, 14
-
- BUTTERFLY3 m4, m3, m2, m5
- SPILL 4, 12
-
- BUTTERFLY3 m7, m3, m2, m5
- SPILL 7, 13
-
- UNSPILL 5, 10
- BUTTERFLY3 m5, m3, m2, m7
- SPILL 5, 10
-
- UNSPILL 4, 11
- BUTTERFLY3 m4, m3, m2, m7
- SPILL 4, 11
-
- BUTTERFLY3 m6, m3, m2, m7
- SPILL 6, 9
-
- BUTTERFLY3 m0, m3, m2, m7
- SPILL 0, 15
-%endmacro
-%endif
-
-
-; void ff_dct32_float_sse(FFTSample *out, const FFTSample *in)
-%macro DCT32_FUNC 0
-cglobal dct32_float, 2, 3, 16, out, in, tmp
- ; pass 1
-
- movaps m0, [inq+0]
- LOAD_INV m1, [inq+112]
- BUTTERFLY m0, m1, [ps_cos_vec], m3
-
- movaps m7, [inq+64]
- LOAD_INV m4, [inq+48]
- BUTTERFLY m7, m4, [ps_cos_vec+32], m3
-
- ; pass 2
- movaps m2, [ps_cos_vec+64]
- BUTTERFLY m1, m4, m2, m3
- SPILL 1, 11
- SPILL 4, 8
-
- ; pass 1
- movaps m1, [inq+16]
- LOAD_INV m6, [inq+96]
- BUTTERFLY m1, m6, [ps_cos_vec+16], m3
-
- movaps m4, [inq+80]
- LOAD_INV m5, [inq+32]
- BUTTERFLY m4, m5, [ps_cos_vec+48], m3
-
- ; pass 2
- BUTTERFLY m0, m7, m2, m3
-
- movaps m2, [ps_cos_vec+80]
- BUTTERFLY m6, m5, m2, m3
-
- BUTTERFLY m1, m4, m2, m3
-
- ; pass 3
- movaps m2, [ps_cos_vec+96]
- shufps m1, m1, 0x1b
- BUTTERFLY m0, m1, m2, m3
- SPILL 0, 15
- SPILL 1, 14
-
- UNSPILL 0, 8
- shufps m5, m5, 0x1b
- BUTTERFLY m0, m5, m2, m3
-
- UNSPILL 1, 11
- shufps m6, m6, 0x1b
- BUTTERFLY m1, m6, m2, m3
- SPILL 1, 11
-
- shufps m4, m4, 0x1b
- BUTTERFLY m7, m4, m2, m3
-
- ; pass 4
- movaps m3, [ps_p1p1m1m1+0]
- movaps m2, [ps_cos_vec+128]
-
- BUTTERFLY2 m5, m3, m2, m1
-
- BUTTERFLY2 m0, m3, m2, m1
- SPILL 0, 9
-
- BUTTERFLY2 m6, m3, m2, m1
- SPILL 6, 10
-
- UNSPILL 0, 11
- BUTTERFLY2 m0, m3, m2, m1
- SPILL 0, 11
-
- BUTTERFLY2 m4, m3, m2, m1
-
- BUTTERFLY2 m7, m3, m2, m1
-
- UNSPILL 6, 14
- BUTTERFLY2 m6, m3, m2, m1
-
- UNSPILL 0, 15
- BUTTERFLY2 m0, m3, m2, m1
-
- PASS5
- PASS6
- RET
-%endmacro
-
-%macro LOAD_INV 2
-%if cpuflag(sse2)
- pshufd %1, %2, 0x1b
-%elif cpuflag(sse)
- movaps %1, %2
- shufps %1, %1, 0x1b
-%endif
-%endmacro
-
-INIT_XMM sse
-DCT32_FUNC
-INIT_XMM sse2
-DCT32_FUNC
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/deinterlace.asm b/src/thirdparty/ffmpeg/libavcodec/x86/deinterlace.asm
deleted file mode 100644
index 111644da3..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/deinterlace.asm
+++ /dev/null
@@ -1,82 +0,0 @@
-;******************************************************************************
-;* MMX optimized deinterlacing functions
-;* Copyright (c) 2010 Vitor Sessak
-;* Copyright (c) 2002 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
-
-cextern pw_4
-
-SECTION .text
-
-%macro DEINTERLACE 1
-%ifidn %1, inplace
-;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)
-cglobal deinterlace_line_inplace_mmx, 6,6,7, lum_m4, lum_m3, lum_m2, lum_m1, lum, size
-%else
-;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)
-cglobal deinterlace_line_mmx, 7,7,7, dst, lum_m4, lum_m3, lum_m2, lum_m1, lum, size
-%endif
- pxor mm7, mm7
- movq mm6, [pw_4]
-.nextrow:
- movd mm0, [lum_m4q]
- movd mm1, [lum_m3q]
- movd mm2, [lum_m2q]
-%ifidn %1, inplace
- movd [lum_m4q], mm2
-%endif
- movd mm3, [lum_m1q]
- movd mm4, [lumq]
- punpcklbw mm0, mm7
- punpcklbw mm1, mm7
- punpcklbw mm2, mm7
- punpcklbw mm3, mm7
- punpcklbw mm4, mm7
- paddw mm1, mm3
- psllw mm2, 1
- paddw mm0, mm4
- psllw mm1, 2
- paddw mm2, mm6
- paddw mm1, mm2
- psubusw mm1, mm0
- psrlw mm1, 3
- packuswb mm1, mm7
-%ifidn %1, inplace
- movd [lum_m2q], mm1
-%else
- movd [dstq], mm1
- add dstq, 4
-%endif
- add lum_m4q, 4
- add lum_m3q, 4
- add lum_m2q, 4
- add lum_m1q, 4
- add lumq, 4
- sub sized, 4
- jg .nextrow
- REP_RET
-%endmacro
-
-DEINTERLACE ""
-
-DEINTERLACE inplace
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/diracdsp_mmx.h b/src/thirdparty/ffmpeg/libavcodec/x86/diracdsp_mmx.h
deleted file mode 100644
index 0f67e2eea..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/diracdsp_mmx.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2010 David Conrad
- *
- * 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_DIRACDSP_H
-#define AVCODEC_X86_DIRACDSP_H
-
-#include "libavcodec/diracdsp.h"
-
-void ff_diracdsp_init_mmx(DiracDSPContext* c);
-
-DECL_DIRAC_PIXOP(put, mmx);
-DECL_DIRAC_PIXOP(avg, mmx);
-DECL_DIRAC_PIXOP(avg, mmxext);
-
-void ff_put_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h);
-void ff_avg_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h);
-void ff_put_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h);
-void ff_avg_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h);
-
-void ff_add_rect_clamped_mmx(uint8_t *, const uint16_t *, int, const int16_t *, int, int, int);
-void ff_add_rect_clamped_sse2(uint8_t *, const uint16_t *, int, const int16_t *, int, int, int);
-
-void ff_add_dirac_obmc8_mmx(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen);
-void ff_add_dirac_obmc16_mmx(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen);
-void ff_add_dirac_obmc32_mmx(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen);
-
-void ff_add_dirac_obmc16_sse2(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen);
-void ff_add_dirac_obmc32_sse2(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen);
-
-#endif
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/dsputil.asm b/src/thirdparty/ffmpeg/libavcodec/x86/dsputil.asm
deleted file mode 100644
index f5df52112..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/dsputil.asm
+++ /dev/null
@@ -1,815 +0,0 @@
-;******************************************************************************
-;* MMX optimized DSP utils
-;* Copyright (c) 2008 Loren Merritt
-;* Copyright (c) 2003-2013 Michael Niedermayer
-;* Copyright (c) 2013 Daniel Kang
-;*
-;* 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
-cextern pb_FC
-cextern h263_loop_filter_strength
-pb_f: times 16 db 15
-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)
-cglobal scalarproduct_int16, 3,3,3, v1, v2, order
- shl orderq, 1
- add v1q, orderq
- add v2q, orderq
- neg orderq
- pxor m2, m2
-.loop:
- movu m0, [v1q + orderq]
- movu m1, [v1q + orderq + mmsize]
- pmaddwd m0, [v2q + orderq]
- pmaddwd m1, [v2q + orderq + mmsize]
- paddd m2, m0
- 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
- movd eax, m2
- RET
-
-; int 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
-%if mmsize == 16
- pshuflw m7, m7, 0
- punpcklqdq m7, m7
-%else
- pshufw m7, m7, 0
-%endif
- pxor m6, m6
- add v1q, orderq
- add v2q, orderq
- add v3q, orderq
- neg orderq
-.loop:
- movu m0, [v2q + orderq]
- movu m1, [v2q + orderq + mmsize]
- mova m4, [v1q + orderq]
- mova m5, [v1q + orderq + mmsize]
- movu m2, [v3q + orderq]
- movu m3, [v3q + orderq + mmsize]
- pmaddwd m0, m4
- pmaddwd m1, m5
- pmullw m2, m7
- pmullw m3, m7
- paddd m6, m0
- paddd m6, m1
- paddw m2, m4
- paddw m3, m5
- mova [v1q + orderq], m2
- 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
- movd eax, m6
- RET
-%endmacro
-
-INIT_MMX mmxext
-SCALARPRODUCT
-INIT_XMM sse2
-SCALARPRODUCT
-
-%macro SCALARPRODUCT_LOOP 1
-align 16
-.loop%1:
- sub orderq, mmsize*2
-%if %1
- mova m1, m4
- mova m4, [v2q + orderq]
- mova m0, [v2q + orderq + mmsize]
- palignr m1, m0, %1
- palignr m0, m4, %1
- mova m3, m5
- mova m5, [v3q + orderq]
- mova m2, [v3q + orderq + mmsize]
- palignr m3, m2, %1
- palignr m2, m5, %1
-%else
- mova m0, [v2q + orderq]
- mova m1, [v2q + orderq + mmsize]
- mova m2, [v3q + orderq]
- mova m3, [v3q + orderq + mmsize]
-%endif
- %define t0 [v1q + orderq]
- %define t1 [v1q + orderq + mmsize]
-%if ARCH_X86_64
- mova m8, t0
- mova m9, t1
- %define t0 m8
- %define t1 m9
-%endif
- pmaddwd m0, t0
- pmaddwd m1, t1
- pmullw m2, m7
- pmullw m3, m7
- paddw m2, t0
- paddw m3, t1
- paddd m6, m0
- paddd m6, m1
- mova [v1q + orderq], m2
- mova [v1q + orderq + mmsize], m3
- jg .loop%1
-%if %1
- jmp .end
-%endif
-%endmacro
-
-; int 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
- movd m7, mulm
- pshuflw m7, m7, 0
- punpcklqdq m7, m7
- pxor m6, m6
- mov r4d, v2d
- and r4d, 15
- and v2q, ~15
- and v3q, ~15
- mova m4, [v2q + orderq]
- mova m5, [v3q + orderq]
- ; linear is faster than branch tree or jump table, because the branches taken are cyclic (i.e. predictable)
- cmp r4d, 0
- je .loop0
- cmp r4d, 2
- je .loop2
- cmp r4d, 4
- je .loop4
- cmp r4d, 6
- je .loop6
- cmp r4d, 8
- je .loop8
- cmp r4d, 10
- je .loop10
- cmp r4d, 12
- je .loop12
-SCALARPRODUCT_LOOP 14
-SCALARPRODUCT_LOOP 12
-SCALARPRODUCT_LOOP 10
-SCALARPRODUCT_LOOP 8
-SCALARPRODUCT_LOOP 6
-SCALARPRODUCT_LOOP 4
-SCALARPRODUCT_LOOP 2
-SCALARPRODUCT_LOOP 0
-.end:
- movhlps m0, m6
- paddd m6, m0
- pshuflw m0, m6, 0x4e
- paddd 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)
-INIT_MMX mmxext
-cglobal add_hfyu_median_prediction, 6,6,0, dst, top, diff, w, left, left_top
- movq mm0, [topq]
- movq mm2, mm0
- movd mm4, [left_topq]
- psllq mm2, 8
- movq mm1, mm0
- por mm4, mm2
- movd mm3, [leftq]
- psubb 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, 8
- por mm4, mm1
- movq mm1, mm0 ; t
- psubb mm0, mm4 ; t-tl
-.skip:
- movq mm2, [diffq+wq]
-%assign i 0
-%rep 8
- movq mm4, mm0
- paddb mm4, mm3 ; t-tl+l
- movq mm5, mm3
- pmaxub mm3, mm1
- pminub mm5, mm1
- pminub mm3, mm4
- pmaxub mm3, mm5 ; median
- paddb mm3, mm2 ; +residual
-%if i==0
- movq mm7, mm3
- psllq mm7, 56
-%else
- movq mm6, mm3
- psrlq mm7, 8
- psllq mm6, 56
- por mm7, mm6
-%endif
-%if i<7
- psrlq mm0, 8
- psrlq mm1, 8
- psrlq mm2, 8
-%endif
-%assign i i+1
-%endrep
- movq [dstq+wq], mm7
- add wq, 8
- jl .loop
- movzx r2d, byte [dstq-1]
- mov [leftq], r2d
- movzx r2d, byte [topq-1]
- mov [left_topq], r2d
- RET
-
-
-%macro ADD_HFYU_LEFT_LOOP 2 ; %1 = dst_is_aligned, %2 = src_is_aligned
- add srcq, wq
- add dstq, wq
- neg wq
-%%.loop:
-%if %2
- mova m1, [srcq+wq]
-%else
- movu m1, [srcq+wq]
-%endif
- mova m2, m1
- psllw m1, 8
- paddb m1, m2
- mova m2, m1
- pshufb m1, m3
- paddb m1, m2
- pshufb m0, m5
- mova m2, m1
- pshufb m1, m4
- paddb m1, m2
-%if mmsize == 16
- mova m2, m1
- pshufb m1, m6
- paddb m1, m2
-%endif
- paddb m0, m1
-%if %1
- 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
- movd m1, eax
- pshufb m0, m1
- movd eax, m0
- RET
-%endmacro
-
-; int 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:
- mova m5, [pb_7]
- mova m4, [pb_zzzz3333zzzzbbbb]
- mova m3, [pb_zz11zz55zz99zzdd]
- movd m0, leftm
- psllq m0, 56
- ADD_HFYU_LEFT_LOOP 1, 1
-
-INIT_XMM sse4
-cglobal add_hfyu_left_prediction, 3,3,7, dst, src, w, left
- mova m5, [pb_f]
- mova m6, [pb_zzzzzzzz77777777]
- mova m4, [pb_zzzz3333zzzzbbbb]
- mova m3, [pb_zz11zz55zz99zzdd]
- movd m0, leftm
- pslldq m0, 15
- test srcq, 15
- jnz .src_unaligned
- test dstq, 15
- jnz .dst_unaligned
- ADD_HFYU_LEFT_LOOP 1, 1
-.dst_unaligned:
- ADD_HFYU_LEFT_LOOP 0, 1
-.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)
-;-----------------------------------------------------------------------------
-
-; %1 = number of xmm registers used
-; %2 = number of inline load/process/store loops per asm loop
-; %3 = process 4*mmsize (%3=0) or 8*mmsize (%3=1) bytes per loop
-; %4 = CLIPD function takes min/max as float instead of int (CLIPD_SSE2)
-; %5 = suffix
-%macro VECTOR_CLIP_INT32 4-5
-cglobal vector_clip_int32%5, 5,5,%1, dst, src, min, max, len
-%if %4
- cvtsi2ss m4, minm
- cvtsi2ss m5, maxm
-%else
- movd m4, minm
- movd m5, maxm
-%endif
- SPLATD m4
- SPLATD m5
-.loop:
-%assign %%i 1
-%rep %2
- mova m0, [srcq+mmsize*0*%%i]
- mova m1, [srcq+mmsize*1*%%i]
- mova m2, [srcq+mmsize*2*%%i]
- mova m3, [srcq+mmsize*3*%%i]
-%if %3
- mova m7, [srcq+mmsize*4*%%i]
- mova m8, [srcq+mmsize*5*%%i]
- mova m9, [srcq+mmsize*6*%%i]
- mova m10, [srcq+mmsize*7*%%i]
-%endif
- CLIPD m0, m4, m5, m6
- CLIPD m1, m4, m5, m6
- CLIPD m2, m4, m5, m6
- CLIPD m3, m4, m5, m6
-%if %3
- CLIPD m7, m4, m5, m6
- CLIPD m8, m4, m5, m6
- CLIPD m9, m4, m5, m6
- CLIPD m10, m4, m5, m6
-%endif
- mova [dstq+mmsize*0*%%i], m0
- mova [dstq+mmsize*1*%%i], m1
- mova [dstq+mmsize*2*%%i], m2
- mova [dstq+mmsize*3*%%i], m3
-%if %3
- mova [dstq+mmsize*4*%%i], m7
- mova [dstq+mmsize*5*%%i], m8
- mova [dstq+mmsize*6*%%i], m9
- mova [dstq+mmsize*7*%%i], m10
-%endif
-%assign %%i %%i+1
-%endrep
- add srcq, mmsize*4*(%2+%3)
- add dstq, mmsize*4*(%2+%3)
- sub lend, mmsize*(%2+%3)
- jg .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmx
-%define CLIPD CLIPD_MMX
-VECTOR_CLIP_INT32 0, 1, 0, 0
-INIT_XMM sse2
-VECTOR_CLIP_INT32 6, 1, 0, 0, _int
-%define CLIPD CLIPD_SSE2
-VECTOR_CLIP_INT32 6, 2, 0, 1
-INIT_XMM sse4
-%define CLIPD CLIPD_SSE41
-%ifdef m8
-VECTOR_CLIP_INT32 11, 1, 1, 0
-%else
-VECTOR_CLIP_INT32 6, 1, 0, 0
-%endif
-
-; %1 = aligned/unaligned
-%macro BSWAP_LOOPS 1
- mov r3, r2
- sar r2, 3
- jz .left4_%1
-.loop8_%1:
- mov%1 m0, [r1 + 0]
- mov%1 m1, [r1 + 16]
-%if cpuflag(ssse3)
- pshufb m0, m2
- pshufb m1, m2
- mova [r0 + 0], m0
- mova [r0 + 16], m1
-%else
- pshuflw m0, m0, 10110001b
- pshuflw m1, m1, 10110001b
- pshufhw m0, m0, 10110001b
- pshufhw m1, m1, 10110001b
- mova m2, m0
- mova m3, m1
- psllw m0, 8
- psllw m1, 8
- psrlw m2, 8
- psrlw m3, 8
- por m2, m0
- por m3, m1
- mova [r0 + 0], m2
- mova [r0 + 16], m3
-%endif
- add r0, 32
- add r1, 32
- dec r2
- jnz .loop8_%1
-.left4_%1:
- mov r2, r3
- and r3, 4
- jz .left
- mov%1 m0, [r1]
-%if cpuflag(ssse3)
- pshufb m0, m2
- mova [r0], m0
-%else
- pshuflw m0, m0, 10110001b
- pshufhw m0, m0, 10110001b
- mova m2, m0
- psllw m0, 8
- psrlw m2, 8
- por m2, m0
- mova [r0], m2
-%endif
- add r1, 16
- add r0, 16
-%endmacro
-
-; void bswap_buf(uint32_t *dst, const uint32_t *src, int w);
-%macro BSWAP32_BUF 0
-%if cpuflag(ssse3)
-cglobal bswap32_buf, 3,4,3
- mov r3, r1
- mova m2, [pb_bswap32]
-%else
-cglobal bswap32_buf, 3,4,5
- mov r3, r1
-%endif
- and r3, 15
- jz .start_align
- BSWAP_LOOPS u
- jmp .left
-.start_align:
- BSWAP_LOOPS a
-.left:
-%if cpuflag(ssse3)
- mov r3, r2
- and r2, 2
- jz .left1
- movq m0, [r1]
- pshufb m0, m2
- movq [r0], m0
- add r1, 8
- add r0, 8
-.left1:
- and r3, 1
- jz .end
- mov r2d, [r1]
- bswap r2d
- mov [r0], r2d
-%else
- and r2, 3
- jz .end
-.loop2:
- mov r3d, [r1]
- bswap r3d
- mov [r0], r3d
- add r1, 4
- add r0, 4
- dec r2
- jnz .loop2
-%endif
-.end:
- RET
-%endmacro
-
-INIT_XMM sse2
-BSWAP32_BUF
-
-INIT_XMM ssse3
-BSWAP32_BUF
-
-
-%macro H263_LOOP_FILTER 5
- pxor m7, m7
- mova m0, [%1]
- mova m1, [%1]
- mova m2, [%4]
- mova m3, [%4]
- punpcklbw m0, m7
- punpckhbw m1, m7
- punpcklbw m2, m7
- punpckhbw m3, m7
- psubw m0, m2
- psubw m1, m3
- mova m2, [%2]
- mova m3, [%2]
- mova m4, [%3]
- mova m5, [%3]
- punpcklbw m2, m7
- punpckhbw m3, m7
- punpcklbw m4, m7
- punpckhbw m5, m7
- psubw m4, m2
- psubw m5, m3
- psllw m4, 2
- psllw m5, 2
- paddw m4, m0
- paddw m5, m1
- pxor m6, m6
- pcmpgtw m6, m4
- pcmpgtw m7, m5
- pxor m4, m6
- pxor m5, m7
- psubw m4, m6
- psubw m5, m7
- psrlw m4, 3
- psrlw m5, 3
- packuswb m4, m5
- packsswb m6, m7
- pxor m7, m7
- movd m2, %5
- punpcklbw m2, m2
- punpcklbw m2, m2
- punpcklbw m2, m2
- psubusb m2, m4
- mova m3, m2
- psubusb m3, m4
- psubb m2, m3
- mova m3, [%2]
- mova m4, [%3]
- pxor m3, m6
- pxor m4, m6
- paddusb m3, m2
- psubusb m4, m2
- pxor m3, m6
- pxor m4, m6
- paddusb m2, m2
- packsswb m0, m1
- pcmpgtb m7, m0
- pxor m0, m7
- psubb m0, m7
- mova m1, m0
- psubusb m0, m2
- psubb m1, m0
- pand m1, [pb_FC]
- psrlw m1, 2
- pxor m1, m7
- psubb m1, m7
- mova m5, [%1]
- mova m6, [%4]
- psubb m5, m1
- paddb m6, m1
-%endmacro
-
-INIT_MMX mmx
-; void h263_v_loop_filter(uint8_t *src, int stride, int qscale)
-cglobal h263_v_loop_filter, 3,5
- movsxdifnidn r1, r1d
- movsxdifnidn r2, r2d
-
- lea r4, [h263_loop_filter_strength]
- movzx r3d, BYTE [r4+r2]
- movsx r2, r3b
- shl r2, 1
-
- mov r3, r0
- sub r3, r1
- mov r4, r3
- sub r4, r1
- H263_LOOP_FILTER r4, r3, r0, r0+r1, r2d
-
- mova [r3], m3
- mova [r0], m4
- mova [r4], m5
- mova [r0+r1], m6
- RET
-
-%macro TRANSPOSE4X4 2
- movd m0, [%1]
- movd m1, [%1+r1]
- movd m2, [%1+r1*2]
- movd m3, [%1+r3]
- punpcklbw m0, m1
- punpcklbw m2, m3
- mova m1, m0
- punpcklwd m0, m2
- punpckhwd m1, m2
- movd [%2+ 0], m0
- punpckhdq m0, m0
- movd [%2+ 8], m0
- movd [%2+16], m1
- punpckhdq m1, m1
- movd [%2+24], m1
-%endmacro
-
-
-; void h263_h_loop_filter(uint8_t *src, int stride, int qscale)
-INIT_MMX mmx
-cglobal h263_h_loop_filter, 3,5,0,32
- movsxdifnidn r1, r1d
- movsxdifnidn r2, r2d
-
- lea r4, [h263_loop_filter_strength]
- movzx r3d, BYTE [r4+r2]
- movsx r2, r3b
- shl r2, 1
-
- sub r0, 2
- lea r3, [r1*3]
-
- TRANSPOSE4X4 r0, rsp
- lea r4, [r0+r1*4]
- TRANSPOSE4X4 r4, rsp+4
-
- H263_LOOP_FILTER rsp, rsp+8, rsp+16, rsp+24, r2d
-
- mova m1, m5
- mova m0, m4
- punpcklbw m5, m3
- punpcklbw m4, m6
- punpckhbw m1, m3
- punpckhbw m0, m6
- mova m3, m5
- mova m6, m1
- punpcklwd m5, m4
- punpcklwd m1, m0
- punpckhwd m3, m4
- punpckhwd m6, m0
- movd [r0], m5
- punpckhdq m5, m5
- movd [r0+r1*1], m5
- movd [r0+r1*2], m3
- punpckhdq m3, m3
- movd [r0+r3], m3
- movd [r4], m1
- punpckhdq m1, m1
- movd [r4+r1*1], m1
- movd [r4+r1*2], m6
- punpckhdq m6, m6
- movd [r4+r3], m6
- RET
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/dsputil_avg_template.c b/src/thirdparty/ffmpeg/libavcodec/x86/dsputil_avg_template.c
deleted file mode 100644
index b9a8f8340..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/dsputil_avg_template.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * DSP utils : average functions are compiled twice for 3dnow/mmxext
- * Copyright (c) 2000, 2001 Fabrice Bellard
- * Copyright (c) 2002-2004 Michael Niedermayer
- *
- * MMX optimization by Nick Kurshev <nickols_k@mail.ru>
- * mostly rewritten by Michael Niedermayer <michaelni@gmx.at>
- * and improved by Zdenek Kabelac <kabi@users.sf.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
- */
-
-//FIXME the following could be optimized too ...
-static void DEF(ff_put_no_rnd_pixels16_x2)(uint8_t *block,
- const uint8_t *pixels,
- ptrdiff_t line_size, int h)
-{
- DEF(ff_put_no_rnd_pixels8_x2)(block, pixels, line_size, h);
- DEF(ff_put_no_rnd_pixels8_x2)(block + 8, pixels + 8, line_size, h);
-}
-
-static void DEF(ff_put_pixels16_y2)(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h)
-{
- DEF(ff_put_pixels8_y2)(block, pixels, line_size, h);
- DEF(ff_put_pixels8_y2)(block + 8, pixels + 8, line_size, h);
-}
-
-static void DEF(ff_put_no_rnd_pixels16_y2)(uint8_t *block,
- const uint8_t *pixels,
- ptrdiff_t line_size, int h)
-{
- DEF(ff_put_no_rnd_pixels8_y2)(block, pixels, line_size, h);
- DEF(ff_put_no_rnd_pixels8_y2)(block + 8, pixels + 8, line_size, h);
-}
-
-static void DEF(ff_avg_pixels16)(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h)
-{
- DEF(ff_avg_pixels8)(block, pixels, line_size, h);
- DEF(ff_avg_pixels8)(block + 8, pixels + 8, line_size, h);
-}
-
-static void DEF(ff_avg_pixels16_x2)(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h)
-{
- DEF(ff_avg_pixels8_x2)(block, pixels, line_size, h);
- DEF(ff_avg_pixels8_x2)(block + 8, pixels + 8, line_size, h);
-}
-
-static void DEF(ff_avg_pixels16_y2)(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h)
-{
- DEF(ff_avg_pixels8_y2)(block, pixels, line_size, h);
- DEF(ff_avg_pixels8_y2)(block + 8, pixels + 8, line_size, h);
-}
-
-static void DEF(ff_avg_pixels16_xy2)(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h)
-{
- DEF(ff_avg_pixels8_xy2)(block, pixels, line_size, h);
- DEF(ff_avg_pixels8_xy2)(block + 8, pixels + 8, line_size, h);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/dsputil_mmx.c b/src/thirdparty/ffmpeg/libavcodec/x86/dsputil_mmx.c
deleted file mode 100644
index 6311b88ff..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/dsputil_mmx.c
+++ /dev/null
@@ -1,1927 +0,0 @@
-/*
- * MMX optimized DSP utils
- * Copyright (c) 2000, 2001 Fabrice Bellard
- * Copyright (c) 2002-2004 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
- *
- * MMX optimization by Nick Kurshev <nickols_k@mail.ru>
- */
-
-#include "libavutil/attributes.h"
-#include "libavutil/cpu.h"
-#include "libavutil/x86/asm.h"
-#include "libavcodec/dsputil.h"
-#include "libavcodec/h264dsp.h"
-#include "libavcodec/mpegvideo.h"
-#include "libavcodec/simple_idct.h"
-#include "libavcodec/videodsp.h"
-#include "dsputil_mmx.h"
-#include "idct_xvid.h"
-#include "diracdsp_mmx.h"
-
-//#undef NDEBUG
-//#include <assert.h>
-
-/* pixel operations */
-DECLARE_ALIGNED(8, const uint64_t, ff_bone) = 0x0101010101010101ULL;
-DECLARE_ALIGNED(8, const uint64_t, ff_wtwo) = 0x0002000200020002ULL;
-
-DECLARE_ALIGNED(16, const xmm_reg, ff_pw_1) = { 0x0001000100010001ULL, 0x0001000100010001ULL };
-DECLARE_ALIGNED(16, const xmm_reg, ff_pw_2) = { 0x0002000200020002ULL, 0x0002000200020002ULL };
-DECLARE_ALIGNED(16, const xmm_reg, ff_pw_3) = { 0x0003000300030003ULL, 0x0003000300030003ULL };
-DECLARE_ALIGNED(16, const xmm_reg, ff_pw_4) = { 0x0004000400040004ULL, 0x0004000400040004ULL };
-DECLARE_ALIGNED(16, const xmm_reg, ff_pw_5) = { 0x0005000500050005ULL, 0x0005000500050005ULL };
-DECLARE_ALIGNED(16, const xmm_reg, ff_pw_8) = { 0x0008000800080008ULL, 0x0008000800080008ULL };
-DECLARE_ALIGNED(16, const xmm_reg, ff_pw_9) = { 0x0009000900090009ULL, 0x0009000900090009ULL };
-DECLARE_ALIGNED(8, const uint64_t, ff_pw_15) = 0x000F000F000F000FULL;
-DECLARE_ALIGNED(16, const xmm_reg, ff_pw_16) = { 0x0010001000100010ULL, 0x0010001000100010ULL };
-DECLARE_ALIGNED(16, const xmm_reg, ff_pw_17) = { 0x0011001100110011ULL, 0x0011001100110011ULL };
-DECLARE_ALIGNED(16, const xmm_reg, ff_pw_18) = { 0x0012001200120012ULL, 0x0012001200120012ULL };
-DECLARE_ALIGNED(8, const uint64_t, ff_pw_20) = 0x0014001400140014ULL;
-DECLARE_ALIGNED(16, const xmm_reg, ff_pw_27) = { 0x001B001B001B001BULL, 0x001B001B001B001BULL };
-DECLARE_ALIGNED(16, const xmm_reg, ff_pw_28) = { 0x001C001C001C001CULL, 0x001C001C001C001CULL };
-DECLARE_ALIGNED(16, const xmm_reg, ff_pw_32) = { 0x0020002000200020ULL, 0x0020002000200020ULL };
-DECLARE_ALIGNED(8, const uint64_t, ff_pw_42) = 0x002A002A002A002AULL;
-DECLARE_ALIGNED(8, const uint64_t, ff_pw_53) = 0x0035003500350035ULL;
-DECLARE_ALIGNED(16, const xmm_reg, ff_pw_63) = { 0x003F003F003F003FULL, 0x003F003F003F003FULL };
-DECLARE_ALIGNED(16, const xmm_reg, ff_pw_64) = { 0x0040004000400040ULL, 0x0040004000400040ULL };
-DECLARE_ALIGNED(8, const uint64_t, ff_pw_96) = 0x0060006000600060ULL;
-DECLARE_ALIGNED(8, const uint64_t, ff_pw_128) = 0x0080008000800080ULL;
-DECLARE_ALIGNED(8, const uint64_t, ff_pw_255) = 0x00ff00ff00ff00ffULL;
-DECLARE_ALIGNED(16, const xmm_reg, ff_pw_512) = { 0x0200020002000200ULL, 0x0200020002000200ULL };
-DECLARE_ALIGNED(16, const xmm_reg, ff_pw_1019) = { 0x03FB03FB03FB03FBULL, 0x03FB03FB03FB03FBULL };
-
-DECLARE_ALIGNED(16, const xmm_reg, ff_pb_0) = { 0x0000000000000000ULL, 0x0000000000000000ULL };
-DECLARE_ALIGNED(16, const xmm_reg, ff_pb_1) = { 0x0101010101010101ULL, 0x0101010101010101ULL };
-DECLARE_ALIGNED(16, const xmm_reg, ff_pb_3) = { 0x0303030303030303ULL, 0x0303030303030303ULL };
-DECLARE_ALIGNED(16, const xmm_reg, ff_pb_4) = { 0x0404040404040404ULL, 0x0404040404040404ULL };
-DECLARE_ALIGNED(8, const uint64_t, ff_pb_7) = 0x0707070707070707ULL;
-DECLARE_ALIGNED(8, const uint64_t, ff_pb_1F) = 0x1F1F1F1F1F1F1F1FULL;
-DECLARE_ALIGNED(8, const uint64_t, ff_pb_3F) = 0x3F3F3F3F3F3F3F3FULL;
-DECLARE_ALIGNED(16, const xmm_reg, ff_pb_80) = { 0x8080808080808080ULL, 0x8080808080808080ULL };
-DECLARE_ALIGNED(8, const uint64_t, ff_pb_81) = 0x8181818181818181ULL;
-DECLARE_ALIGNED(16, const xmm_reg, ff_pb_A1) = { 0xA1A1A1A1A1A1A1A1ULL, 0xA1A1A1A1A1A1A1A1ULL };
-DECLARE_ALIGNED(16, const xmm_reg, ff_pb_F8) = { 0xF8F8F8F8F8F8F8F8ULL, 0xF8F8F8F8F8F8F8F8ULL };
-DECLARE_ALIGNED(8, const uint64_t, ff_pb_FC) = 0xFCFCFCFCFCFCFCFCULL;
-DECLARE_ALIGNED(16, const xmm_reg, ff_pb_FE) = { 0xFEFEFEFEFEFEFEFEULL, 0xFEFEFEFEFEFEFEFEULL };
-
-DECLARE_ALIGNED(16, const double, ff_pd_1)[2] = { 1.0, 1.0 };
-DECLARE_ALIGNED(16, const double, ff_pd_2)[2] = { 2.0, 2.0 };
-
-
-#if HAVE_YASM
-void ff_put_pixels8_x2_mmxext(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_put_pixels8_x2_3dnow(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_put_pixels8_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
- int dstStride, int src1Stride, int h);
-void ff_put_no_rnd_pixels8_l2_mmxext(uint8_t *dst, uint8_t *src1,
- uint8_t *src2, int dstStride,
- int src1Stride, int h);
-void ff_avg_pixels8_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
- int dstStride, int src1Stride, int h);
-void ff_put_pixels16_x2_mmxext(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_put_pixels16_x2_3dnow(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_put_pixels16_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
- int dstStride, int src1Stride, int h);
-void ff_avg_pixels16_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
- int dstStride, int src1Stride, int h);
-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_no_rnd_pixels8_x2_mmxext(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_put_no_rnd_pixels8_x2_3dnow(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_put_no_rnd_pixels8_x2_exact_mmxext(uint8_t *block,
- const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_put_no_rnd_pixels8_x2_exact_3dnow(uint8_t *block,
- const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_put_pixels8_y2_mmxext(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_put_pixels8_y2_3dnow(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_put_no_rnd_pixels8_y2_mmxext(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_put_no_rnd_pixels8_y2_3dnow(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_put_no_rnd_pixels8_y2_exact_mmxext(uint8_t *block,
- const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_put_no_rnd_pixels8_y2_exact_3dnow(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_pixels8_3dnow(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_avg_pixels8_x2_mmxext(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_avg_pixels8_x2_3dnow(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_avg_pixels8_y2_mmxext(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_avg_pixels8_y2_3dnow(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_avg_pixels8_xy2_mmxext(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h);
-void ff_avg_pixels8_xy2_3dnow(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);
-static void ff_put_pixels16_mmxext(uint8_t *block, const uint8_t *pixels,
- int line_size, int h)
-{
- ff_put_pixels8_mmxext(block, pixels, line_size, h);
- ff_put_pixels8_mmxext(block + 8, pixels + 8, line_size, h);
-}
-
-void ff_put_mpeg4_qpel16_h_lowpass_mmxext(uint8_t *dst, uint8_t *src,
- 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);
-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);
-void ff_avg_mpeg4_qpel8_h_lowpass_mmxext(uint8_t *dst, uint8_t *src,
- 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);
-void ff_avg_mpeg4_qpel16_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
- 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);
-void ff_avg_mpeg4_qpel8_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
- 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
-#define ff_put_no_rnd_pixels8_mmxext ff_put_pixels8_mmxext
-#endif /* HAVE_YASM */
-
-
-#if HAVE_INLINE_ASM
-
-#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_BONE(regd) __asm__ volatile ("movq %0, %%"#regd" \n\t" :: "m"(ff_bone))
-#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_BONE(regd) \
- __asm__ volatile ( \
- "pcmpeqd %%"#regd", %%"#regd" \n\t" \
- "psrlw $15, %%"#regd" \n\t" \
- "packuswb %%"#regd", %%"#regd" \n\t" ::)
-
-#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"
-
-/***********************************/
-/* MMX no rounding */
-#define NO_RND 1
-#define DEF(x, y) x ## _no_rnd_ ## y ## _mmx
-#define SET_RND MOVQ_WONE
-#define PAVGBP(a, b, c, d, e, f) PAVGBP_MMX_NO_RND(a, b, c, d, e, f)
-#define PAVGB(a, b, c, e) PAVGB_MMX_NO_RND(a, b, c, e)
-#define OP_AVG(a, b, c, e) PAVGB_MMX(a, b, c, e)
-
-#include "dsputil_rnd_template.c"
-
-#undef DEF
-#undef SET_RND
-#undef PAVGBP
-#undef PAVGB
-#undef NO_RND
-/***********************************/
-/* MMX rounding */
-
-#define DEF(x, y) 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)
-
-#include "dsputil_rnd_template.c"
-
-#undef DEF
-#undef SET_RND
-#undef PAVGBP
-#undef PAVGB
-#undef OP_AVG
-
-#endif /* HAVE_INLINE_ASM */
-
-
-#if HAVE_YASM
-#define ff_put_pixels8_mmx ff_put_pixels8_mmxext
-
-/***********************************/
-/* 3Dnow specific */
-
-#define DEF(x) x ## _3dnow
-
-#include "dsputil_avg_template.c"
-
-#undef DEF
-
-/***********************************/
-/* MMXEXT specific */
-
-#define DEF(x) x ## _mmxext
-
-#include "dsputil_avg_template.c"
-
-#undef DEF
-
-#endif /* HAVE_YASM */
-
-
-#if HAVE_INLINE_ASM
-#define put_no_rnd_pixels16_mmx put_pixels16_mmx
-#define put_no_rnd_pixels8_mmx put_pixels8_mmx
-#define put_pixels16_mmxext put_pixels16_mmx
-#define put_pixels8_mmxext put_pixels8_mmx
-#define put_pixels4_mmxext put_pixels4_mmx
-#define put_no_rnd_pixels16_mmxext put_no_rnd_pixels16_mmx
-#define put_no_rnd_pixels8_mmxext put_no_rnd_pixels8_mmx
-
-/***********************************/
-/* standard MMX */
-
-void ff_put_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
- int line_size)
-{
- const int16_t *p;
- uint8_t *pix;
-
- /* read the pixels */
- p = block;
- pix = pixels;
- /* unrolled loop */
- __asm__ volatile (
- "movq (%3), %%mm0 \n\t"
- "movq 8(%3), %%mm1 \n\t"
- "movq 16(%3), %%mm2 \n\t"
- "movq 24(%3), %%mm3 \n\t"
- "movq 32(%3), %%mm4 \n\t"
- "movq 40(%3), %%mm5 \n\t"
- "movq 48(%3), %%mm6 \n\t"
- "movq 56(%3), %%mm7 \n\t"
- "packuswb %%mm1, %%mm0 \n\t"
- "packuswb %%mm3, %%mm2 \n\t"
- "packuswb %%mm5, %%mm4 \n\t"
- "packuswb %%mm7, %%mm6 \n\t"
- "movq %%mm0, (%0) \n\t"
- "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)
- : "memory");
- pix += line_size * 4;
- p += 32;
-
- // if here would be an exact copy of the code above
- // compiler would generate some very strange code
- // thus using "r"
- __asm__ volatile (
- "movq (%3), %%mm0 \n\t"
- "movq 8(%3), %%mm1 \n\t"
- "movq 16(%3), %%mm2 \n\t"
- "movq 24(%3), %%mm3 \n\t"
- "movq 32(%3), %%mm4 \n\t"
- "movq 40(%3), %%mm5 \n\t"
- "movq 48(%3), %%mm6 \n\t"
- "movq 56(%3), %%mm7 \n\t"
- "packuswb %%mm1, %%mm0 \n\t"
- "packuswb %%mm3, %%mm2 \n\t"
- "packuswb %%mm5, %%mm4 \n\t"
- "packuswb %%mm7, %%mm6 \n\t"
- "movq %%mm0, (%0) \n\t"
- "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)
- : "memory");
-}
-
-#define put_signed_pixels_clamped_mmx_half(off) \
- "movq "#off"(%2), %%mm1 \n\t" \
- "movq 16 + "#off"(%2), %%mm2 \n\t" \
- "movq 32 + "#off"(%2), %%mm3 \n\t" \
- "movq 48 + "#off"(%2), %%mm4 \n\t" \
- "packsswb 8 + "#off"(%2), %%mm1 \n\t" \
- "packsswb 24 + "#off"(%2), %%mm2 \n\t" \
- "packsswb 40 + "#off"(%2), %%mm3 \n\t" \
- "packsswb 56 + "#off"(%2), %%mm4 \n\t" \
- "paddb %%mm0, %%mm1 \n\t" \
- "paddb %%mm0, %%mm2 \n\t" \
- "paddb %%mm0, %%mm3 \n\t" \
- "paddb %%mm0, %%mm4 \n\t" \
- "movq %%mm1, (%0) \n\t" \
- "movq %%mm2, (%0, %3) \n\t" \
- "movq %%mm3, (%0, %3, 2) \n\t" \
- "movq %%mm4, (%0, %1) \n\t"
-
-void ff_put_signed_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
- int line_size)
-{
- x86_reg line_skip = line_size;
- x86_reg line_skip3;
-
- __asm__ volatile (
- "movq "MANGLE(ff_pb_80)", %%mm0 \n\t"
- "lea (%3, %3, 2), %1 \n\t"
- 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)
- : "memory");
-}
-
-void ff_add_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
- int line_size)
-{
- const int16_t *p;
- uint8_t *pix;
- int i;
-
- /* read the pixels */
- p = block;
- pix = pixels;
- MOVQ_ZERO(mm7);
- i = 4;
- do {
- __asm__ volatile (
- "movq (%2), %%mm0 \n\t"
- "movq 8(%2), %%mm1 \n\t"
- "movq 16(%2), %%mm2 \n\t"
- "movq 24(%2), %%mm3 \n\t"
- "movq %0, %%mm4 \n\t"
- "movq %1, %%mm6 \n\t"
- "movq %%mm4, %%mm5 \n\t"
- "punpcklbw %%mm7, %%mm4 \n\t"
- "punpckhbw %%mm7, %%mm5 \n\t"
- "paddsw %%mm4, %%mm0 \n\t"
- "paddsw %%mm5, %%mm1 \n\t"
- "movq %%mm6, %%mm5 \n\t"
- "punpcklbw %%mm7, %%mm6 \n\t"
- "punpckhbw %%mm7, %%mm5 \n\t"
- "paddsw %%mm6, %%mm2 \n\t"
- "paddsw %%mm5, %%mm3 \n\t"
- "packuswb %%mm1, %%mm0 \n\t"
- "packuswb %%mm3, %%mm2 \n\t"
- "movq %%mm0, %0 \n\t"
- "movq %%mm2, %1 \n\t"
- : "+m"(*pix), "+m"(*(pix + line_size))
- : "r"(p)
- : "memory");
- pix += line_size * 2;
- p += 16;
- } while (--i);
-}
-
-static void put_pixels8_mmx(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h)
-{
- __asm__ volatile (
- "lea (%3, %3), %%"REG_a" \n\t"
- ".p2align 3 \n\t"
- "1: \n\t"
- "movq (%1 ), %%mm0 \n\t"
- "movq (%1, %3), %%mm1 \n\t"
- "movq %%mm0, (%2) \n\t"
- "movq %%mm1, (%2, %3) \n\t"
- "add %%"REG_a", %1 \n\t"
- "add %%"REG_a", %2 \n\t"
- "movq (%1 ), %%mm0 \n\t"
- "movq (%1, %3), %%mm1 \n\t"
- "movq %%mm0, (%2) \n\t"
- "movq %%mm1, (%2, %3) \n\t"
- "add %%"REG_a", %1 \n\t"
- "add %%"REG_a", %2 \n\t"
- "subl $4, %0 \n\t"
- "jnz 1b \n\t"
- : "+g"(h), "+r"(pixels), "+r"(block)
- : "r"((x86_reg)line_size)
- : "%"REG_a, "memory"
- );
-}
-
-static void put_pixels16_mmx(uint8_t *block, const uint8_t *pixels,
- ptrdiff_t line_size, int h)
-{
- __asm__ volatile (
- "lea (%3, %3), %%"REG_a" \n\t"
- ".p2align 3 \n\t"
- "1: \n\t"
- "movq (%1 ), %%mm0 \n\t"
- "movq 8(%1 ), %%mm4 \n\t"
- "movq (%1, %3), %%mm1 \n\t"
- "movq 8(%1, %3), %%mm5 \n\t"
- "movq %%mm0, (%2) \n\t"
- "movq %%mm4, 8(%2) \n\t"
- "movq %%mm1, (%2, %3) \n\t"
- "movq %%mm5, 8(%2, %3) \n\t"
- "add %%"REG_a", %1 \n\t"
- "add %%"REG_a", %2 \n\t"
- "movq (%1 ), %%mm0 \n\t"
- "movq 8(%1 ), %%mm4 \n\t"
- "movq (%1, %3), %%mm1 \n\t"
- "movq 8(%1, %3), %%mm5 \n\t"
- "movq %%mm0, (%2) \n\t"
- "movq %%mm4, 8(%2) \n\t"
- "movq %%mm1, (%2, %3) \n\t"
- "movq %%mm5, 8(%2, %3) \n\t"
- "add %%"REG_a", %1 \n\t"
- "add %%"REG_a", %2 \n\t"
- "subl $4, %0 \n\t"
- "jnz 1b \n\t"
- : "+g"(h), "+r"(pixels), "+r"(block)
- : "r"((x86_reg)line_size)
- : "%"REG_a, "memory"
- );
-}
-
-#define CLEAR_BLOCKS(name, n) \
-static void name(int16_t *blocks) \
-{ \
- __asm__ volatile ( \
- "pxor %%mm7, %%mm7 \n\t" \
- "mov %1, %%"REG_a" \n\t" \
- "1: \n\t" \
- "movq %%mm7, (%0, %%"REG_a") \n\t" \
- "movq %%mm7, 8(%0, %%"REG_a") \n\t" \
- "movq %%mm7, 16(%0, %%"REG_a") \n\t" \
- "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 \
- ); \
-}
-CLEAR_BLOCKS(clear_blocks_mmx, 6)
-CLEAR_BLOCKS(clear_block_mmx, 1)
-
-static void clear_block_sse(int16_t *block)
-{
- __asm__ volatile (
- "xorps %%xmm0, %%xmm0 \n"
- "movaps %%xmm0, (%0) \n"
- "movaps %%xmm0, 16(%0) \n"
- "movaps %%xmm0, 32(%0) \n"
- "movaps %%xmm0, 48(%0) \n"
- "movaps %%xmm0, 64(%0) \n"
- "movaps %%xmm0, 80(%0) \n"
- "movaps %%xmm0, 96(%0) \n"
- "movaps %%xmm0, 112(%0) \n"
- :: "r"(block)
- : "memory"
- );
-}
-
-static void clear_blocks_sse(int16_t *blocks)
-{
- __asm__ volatile (
- "xorps %%xmm0, %%xmm0 \n"
- "mov %1, %%"REG_a" \n"
- "1: \n"
- "movaps %%xmm0, (%0, %%"REG_a") \n"
- "movaps %%xmm0, 16(%0, %%"REG_a") \n"
- "movaps %%xmm0, 32(%0, %%"REG_a") \n"
- "movaps %%xmm0, 48(%0, %%"REG_a") \n"
- "movaps %%xmm0, 64(%0, %%"REG_a") \n"
- "movaps %%xmm0, 80(%0, %%"REG_a") \n"
- "movaps %%xmm0, 96(%0, %%"REG_a") \n"
- "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
- );
-}
-
-static void add_bytes_mmx(uint8_t *dst, uint8_t *src, int w)
-{
- x86_reg i = 0;
- __asm__ volatile (
- "jmp 2f \n\t"
- "1: \n\t"
- "movq (%1, %0), %%mm0 \n\t"
- "movq (%2, %0), %%mm1 \n\t"
- "paddb %%mm0, %%mm1 \n\t"
- "movq %%mm1, (%2, %0) \n\t"
- "movq 8(%1, %0), %%mm0 \n\t"
- "movq 8(%2, %0), %%mm1 \n\t"
- "paddb %%mm0, %%mm1 \n\t"
- "movq %%mm1, 8(%2, %0) \n\t"
- "add $16, %0 \n\t"
- "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++)
- dst[i + 0] += src[i + 0];
-}
-
-#if HAVE_7REGS
-static void add_hfyu_median_prediction_cmov(uint8_t *dst, const uint8_t *top,
- const uint8_t *diff, int w,
- int *left, int *left_top)
-{
- x86_reg w2 = -w;
- x86_reg x;
- int l = *left & 0xff;
- int tl = *left_top & 0xff;
- int t;
- __asm__ volatile (
- "mov %7, %3 \n"
- "1: \n"
- "movzbl (%3, %4), %2 \n"
- "mov %2, %k3 \n"
- "sub %b1, %b3 \n"
- "add %b0, %b3 \n"
- "mov %2, %1 \n"
- "cmp %0, %2 \n"
- "cmovg %0, %2 \n"
- "cmovg %1, %0 \n"
- "cmp %k3, %0 \n"
- "cmovg %k3, %0 \n"
- "mov %7, %3 \n"
- "cmp %2, %0 \n"
- "cmovl %2, %0 \n"
- "add (%6, %4), %b0 \n"
- "mov %b0, (%5, %4) \n"
- "inc %4 \n"
- "jl 1b \n"
- : "+&q"(l), "+&q"(tl), "=&r"(t), "=&q"(x), "+&r"(w2)
- : "r"(dst + w), "r"(diff + w), "rm"(top + w)
- );
- *left = l;
- *left_top = tl;
-}
-#endif
-#endif /* HAVE_INLINE_ASM */
-
-void ff_h263_v_loop_filter_mmx(uint8_t *src, int stride, int qscale);
-void ff_h263_h_loop_filter_mmx(uint8_t *src, int stride, int qscale);
-
-#if HAVE_INLINE_ASM
-/* Draw the edges of width 'w' of an image of size width, height
- * this MMX version can only handle w == 8 || w == 16. */
-static void draw_edges_mmx(uint8_t *buf, int wrap, int width, int height,
- int w, int h, int sides)
-{
- uint8_t *ptr, *last_line;
- int i;
-
- last_line = buf + (height - 1) * wrap;
- /* left and right */
- ptr = buf;
- if (w == 8) {
- __asm__ volatile (
- "1: \n\t"
- "movd (%0), %%mm0 \n\t"
- "punpcklbw %%mm0, %%mm0 \n\t"
- "punpcklwd %%mm0, %%mm0 \n\t"
- "punpckldq %%mm0, %%mm0 \n\t"
- "movq %%mm0, -8(%0) \n\t"
- "movq -8(%0, %2), %%mm1 \n\t"
- "punpckhbw %%mm1, %%mm1 \n\t"
- "punpckhwd %%mm1, %%mm1 \n\t"
- "punpckhdq %%mm1, %%mm1 \n\t"
- "movq %%mm1, (%0, %2) \n\t"
- "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){
- __asm__ volatile (
- "1: \n\t"
- "movd (%0), %%mm0 \n\t"
- "punpcklbw %%mm0, %%mm0 \n\t"
- "punpcklwd %%mm0, %%mm0 \n\t"
- "punpckldq %%mm0, %%mm0 \n\t"
- "movq %%mm0, -8(%0) \n\t"
- "movq %%mm0, -16(%0) \n\t"
- "movq -8(%0, %2), %%mm1 \n\t"
- "punpckhbw %%mm1, %%mm1 \n\t"
- "punpckhwd %%mm1, %%mm1 \n\t"
- "punpckhdq %%mm1, %%mm1 \n\t"
- "movq %%mm1, (%0, %2) \n\t"
- "movq %%mm1, 8(%0, %2) \n\t"
- "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 {
- av_assert1(w == 4);
- __asm__ volatile (
- "1: \n\t"
- "movd (%0), %%mm0 \n\t"
- "punpcklbw %%mm0, %%mm0 \n\t"
- "punpcklwd %%mm0, %%mm0 \n\t"
- "movd %%mm0, -4(%0) \n\t"
- "movd -4(%0, %2), %%mm1 \n\t"
- "punpcklbw %%mm1, %%mm1 \n\t"
- "punpckhwd %%mm1, %%mm1 \n\t"
- "punpckhdq %%mm1, %%mm1 \n\t"
- "movd %%mm1, (%0, %2) \n\t"
- "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)
- );
- }
-
- /* top and bottom (and hopefully also the corners) */
- if (sides & EDGE_TOP) {
- for (i = 0; i < h; i += 4) {
- ptr = buf - (i + 1) * wrap - w;
- __asm__ volatile (
- "1: \n\t"
- "movq (%1, %0), %%mm0 \n\t"
- "movq %%mm0, (%0) \n\t"
- "movq %%mm0, (%0, %2) \n\t"
- "movq %%mm0, (%0, %2, 2) \n\t"
- "movq %%mm0, (%0, %3) \n\t"
- "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)
- );
- }
- }
-
- if (sides & EDGE_BOTTOM) {
- for (i = 0; i < h; i += 4) {
- ptr = last_line + (i + 1) * wrap - w;
- __asm__ volatile (
- "1: \n\t"
- "movq (%1, %0), %%mm0 \n\t"
- "movq %%mm0, (%0) \n\t"
- "movq %%mm0, (%0, %2) \n\t"
- "movq %%mm0, (%0, %2, 2) \n\t"
- "movq %%mm0, (%0, %3) \n\t"
- "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)
- );
- }
- }
-}
-#endif /* HAVE_INLINE_ASM */
-
-
-#if HAVE_YASM
-#define QPEL_OP(OPNAME, ROUNDER, RND, OP, MMX) \
-static void OPNAME ## qpel8_mc00_ ## MMX (uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- ff_ ## OPNAME ## pixels8_ ## MMX(dst, src, stride, 8); \
-} \
- \
-static void OPNAME ## qpel8_mc10_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- uint64_t temp[8]; \
- 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, \
- stride, stride, 8); \
-} \
- \
-static void OPNAME ## qpel8_mc20_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- ff_ ## OPNAME ## mpeg4_qpel8_h_lowpass_ ## MMX(dst, src, stride, \
- stride, 8); \
-} \
- \
-static void OPNAME ## qpel8_mc30_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- uint64_t temp[8]; \
- 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, \
- stride, 8); \
-} \
- \
-static void OPNAME ## qpel8_mc01_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- uint64_t temp[8]; \
- 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, \
- stride, stride, 8); \
-} \
- \
-static void OPNAME ## qpel8_mc02_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- ff_ ## OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, src, \
- stride, stride); \
-} \
- \
-static void OPNAME ## qpel8_mc03_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- uint64_t temp[8]; \
- 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,\
- stride, 8); \
-} \
- \
-static void OPNAME ## qpel8_mc11_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- uint64_t half[8 + 9]; \
- 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, \
- stride, 9); \
- ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
- ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, halfH, halfHV, \
- stride, 8, 8); \
-} \
- \
-static void OPNAME ## qpel8_mc31_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- uint64_t half[8 + 9]; \
- 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, \
- stride, 9); \
- ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
- ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, halfH, halfHV, \
- stride, 8, 8); \
-} \
- \
-static void OPNAME ## qpel8_mc13_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- uint64_t half[8 + 9]; \
- 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, \
- stride, 9); \
- ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
- ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, halfH + 8, halfHV, \
- stride, 8, 8); \
-} \
- \
-static void OPNAME ## qpel8_mc33_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- uint64_t half[8 + 9]; \
- 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, \
- stride, 9); \
- ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
- ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, halfH + 8, halfHV, \
- stride, 8, 8); \
-} \
- \
-static void OPNAME ## qpel8_mc21_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- uint64_t half[8 + 9]; \
- 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);\
- ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, halfH, halfHV, \
- stride, 8, 8); \
-} \
- \
-static void OPNAME ## qpel8_mc23_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- uint64_t half[8 + 9]; \
- 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);\
- ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, halfH + 8, halfHV, \
- stride, 8, 8); \
-} \
- \
-static void OPNAME ## qpel8_mc12_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- uint64_t half[8 + 9]; \
- 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, \
- 8, stride, 9); \
- ff_ ## OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH, \
- stride, 8); \
-} \
- \
-static void OPNAME ## qpel8_mc32_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- uint64_t half[8 + 9]; \
- 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, \
- stride, 9); \
- ff_ ## OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH, \
- stride, 8); \
-} \
- \
-static void OPNAME ## qpel8_mc22_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- uint64_t half[9]; \
- 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, \
- int stride) \
-{ \
- ff_ ## OPNAME ## pixels16_ ## MMX(dst, src, stride, 16); \
-} \
- \
-static void OPNAME ## qpel16_mc10_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- uint64_t temp[32]; \
- 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, \
- stride, 16); \
-} \
- \
-static void OPNAME ## qpel16_mc20_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- ff_ ## OPNAME ## mpeg4_qpel16_h_lowpass_ ## MMX(dst, src, \
- stride, stride, 16);\
-} \
- \
-static void OPNAME ## qpel16_mc30_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- uint64_t temp[32]; \
- 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, \
- stride, stride, 16); \
-} \
- \
-static void OPNAME ## qpel16_mc01_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- uint64_t temp[32]; \
- 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, \
- stride, 16); \
-} \
- \
-static void OPNAME ## qpel16_mc02_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- ff_ ## OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, src, \
- stride, stride); \
-} \
- \
-static void OPNAME ## qpel16_mc03_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- uint64_t temp[32]; \
- 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, \
- stride, stride, 16); \
-} \
- \
-static void OPNAME ## qpel16_mc11_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- uint64_t half[16 * 2 + 17 * 2]; \
- 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, \
- stride, 17); \
- ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, \
- 16, 16); \
- ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, halfH, halfHV, \
- stride, 16, 16); \
-} \
- \
-static void OPNAME ## qpel16_mc31_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- uint64_t half[16 * 2 + 17 * 2]; \
- 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, \
- stride, 17); \
- ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, \
- 16, 16); \
- ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, halfH, halfHV, \
- stride, 16, 16); \
-} \
- \
-static void OPNAME ## qpel16_mc13_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- uint64_t half[16 * 2 + 17 * 2]; \
- 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, \
- stride, 17); \
- ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, \
- 16, 16); \
- ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, halfH + 16, halfHV, \
- stride, 16, 16); \
-} \
- \
-static void OPNAME ## qpel16_mc33_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- uint64_t half[16 * 2 + 17 * 2]; \
- 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, \
- stride, 17); \
- ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH, \
- 16, 16); \
- ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, halfH + 16, halfHV, \
- stride, 16, 16); \
-} \
- \
-static void OPNAME ## qpel16_mc21_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- uint64_t half[16 * 2 + 17 * 2]; \
- 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, \
- 16, 16); \
- ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, halfH, halfHV, \
- stride, 16, 16); \
-} \
- \
-static void OPNAME ## qpel16_mc23_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- uint64_t half[16 * 2 + 17 * 2]; \
- 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, \
- 16, 16); \
- ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, halfH + 16, halfHV, \
- stride, 16, 16); \
-} \
- \
-static void OPNAME ## qpel16_mc12_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- uint64_t half[17 * 2]; \
- 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, \
- stride, 17); \
- ff_ ## OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, halfH, \
- stride, 16); \
-} \
- \
-static void OPNAME ## qpel16_mc32_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- uint64_t half[17 * 2]; \
- 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, \
- stride, 17); \
- ff_ ## OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, halfH, \
- stride, 16); \
-} \
- \
-static void OPNAME ## qpel16_mc22_ ## MMX(uint8_t *dst, uint8_t *src, \
- int stride) \
-{ \
- uint64_t half[17 * 2]; \
- 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, \
- stride, 16); \
-}
-
-#define PUT_OP(a, b, temp, size) \
- "mov"#size" "#a", "#b" \n\t"
-
-#define AVG_MMXEXT_OP(a, b, temp, size) \
- "mov"#size" "#b", "#temp" \n\t" \
- "pavgb "#temp", "#a" \n\t" \
- "mov"#size" "#a", "#b" \n\t"
-
-QPEL_OP(put_, ff_pw_16, _, PUT_OP, mmxext)
-QPEL_OP(avg_, ff_pw_16, _, AVG_MMXEXT_OP, mmxext)
-QPEL_OP(put_no_rnd_, ff_pw_15, _no_rnd_, PUT_OP, mmxext)
-#endif /* HAVE_YASM */
-
-
-#if HAVE_INLINE_ASM
-void ff_put_rv40_qpel8_mc33_mmx(uint8_t *dst, uint8_t *src, int stride)
-{
- put_pixels8_xy2_mmx(dst, src, stride, 8);
-}
-void ff_put_rv40_qpel16_mc33_mmx(uint8_t *dst, uint8_t *src, int stride)
-{
- put_pixels16_xy2_mmx(dst, src, stride, 16);
-}
-void ff_avg_rv40_qpel8_mc33_mmx(uint8_t *dst, uint8_t *src, int stride)
-{
- avg_pixels8_xy2_mmx(dst, src, stride, 8);
-}
-void ff_avg_rv40_qpel16_mc33_mmx(uint8_t *dst, uint8_t *src, int stride)
-{
- avg_pixels16_xy2_mmx(dst, src, stride, 16);
-}
-
-typedef void emulated_edge_mc_func(uint8_t *dst, const uint8_t *src,
- ptrdiff_t linesize, int block_w, int block_h,
- int src_x, int src_y, int w, int h);
-
-static av_always_inline void gmc(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,
- emulated_edge_mc_func *emu_edge_fn)
-{
- const int w = 8;
- const int ix = ox >> (16 + shift);
- const int iy = oy >> (16 + shift);
- const int oxs = ox >> 4;
- const int oys = oy >> 4;
- const int dxxs = dxx >> 4;
- const int dxys = dxy >> 4;
- const int dyxs = dyx >> 4;
- const int dyys = dyy >> 4;
- 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;
-#define MAX_STRIDE 4096U
-#define MAX_H 8U
- uint8_t edge_buf[(MAX_H + 1) * MAX_STRIDE];
- int x, y;
-
- const int dxw = (dxx - (1 << (16 + shift))) * (w - 1);
- 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;
-
- 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)
- // 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))) {
- // 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);
- return;
- }
-
- src += ix + iy * stride;
- if (need_emu) {
- emu_edge_fn(edge_buf, src, stride, w + 1, h + 1, ix, iy, width, height);
- src = edge_buf;
- }
-
- __asm__ volatile (
- "movd %0, %%mm6 \n\t"
- "pxor %%mm7, %%mm7 \n\t"
- "punpcklwd %%mm6, %%mm6 \n\t"
- "punpcklwd %%mm6, %%mm6 \n\t"
- :: "r"(1<<shift)
- );
-
- for (x = 0; x < w; x += 4) {
- uint16_t dx4[4] = { oxs - dxys + dxxs * (x + 0),
- oxs - dxys + dxxs * (x + 1),
- oxs - dxys + dxxs * (x + 2),
- oxs - dxys + dxxs * (x + 3) };
- uint16_t dy4[4] = { oys - dyys + dyxs * (x + 0),
- oys - dyys + dyxs * (x + 1),
- oys - dyys + dyxs * (x + 2),
- oys - dyys + dyxs * (x + 3) };
-
- for (y = 0; y < h; y++) {
- __asm__ volatile (
- "movq %0, %%mm4 \n\t"
- "movq %1, %%mm5 \n\t"
- "paddw %2, %%mm4 \n\t"
- "paddw %3, %%mm5 \n\t"
- "movq %%mm4, %0 \n\t"
- "movq %%mm5, %1 \n\t"
- "psrlw $12, %%mm4 \n\t"
- "psrlw $12, %%mm5 \n\t"
- : "+m"(*dx4), "+m"(*dy4)
- : "m"(*dxy4), "m"(*dyy4)
- );
-
- __asm__ volatile (
- "movq %%mm6, %%mm2 \n\t"
- "movq %%mm6, %%mm1 \n\t"
- "psubw %%mm4, %%mm2 \n\t"
- "psubw %%mm5, %%mm1 \n\t"
- "movq %%mm2, %%mm0 \n\t"
- "movq %%mm4, %%mm3 \n\t"
- "pmullw %%mm1, %%mm0 \n\t" // (s - dx) * (s - dy)
- "pmullw %%mm5, %%mm3 \n\t" // dx * dy
- "pmullw %%mm5, %%mm2 \n\t" // (s - dx) * dy
- "pmullw %%mm4, %%mm1 \n\t" // dx * (s - dy)
-
- "movd %4, %%mm5 \n\t"
- "movd %3, %%mm4 \n\t"
- "punpcklbw %%mm7, %%mm5 \n\t"
- "punpcklbw %%mm7, %%mm4 \n\t"
- "pmullw %%mm5, %%mm3 \n\t" // src[1, 1] * dx * dy
- "pmullw %%mm4, %%mm2 \n\t" // src[0, 1] * (s - dx) * dy
-
- "movd %2, %%mm5 \n\t"
- "movd %1, %%mm4 \n\t"
- "punpcklbw %%mm7, %%mm5 \n\t"
- "punpcklbw %%mm7, %%mm4 \n\t"
- "pmullw %%mm5, %%mm1 \n\t" // src[1, 0] * dx * (s - dy)
- "pmullw %%mm4, %%mm0 \n\t" // src[0, 0] * (s - dx) * (s - dy)
- "paddw %5, %%mm1 \n\t"
- "paddw %%mm3, %%mm2 \n\t"
- "paddw %%mm1, %%mm0 \n\t"
- "paddw %%mm2, %%mm0 \n\t"
-
- "psrlw %6, %%mm0 \n\t"
- "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)
- );
- src += stride;
- }
- src += 4 - h * stride;
- }
-}
-
-#if CONFIG_VIDEODSP
-#if HAVE_YASM
-#if ARCH_X86_32
-static void gmc_mmx(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)
-{
- gmc(dst, src, stride, h, ox, oy, dxx, dxy, dyx, dyy, shift, r,
- width, height, &ff_emulated_edge_mc_8);
-}
-#endif
-static void gmc_sse(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)
-{
- gmc(dst, src, stride, h, ox, oy, dxx, dxy, dyx, dyy, shift, r,
- width, height, &ff_emulated_edge_mc_8);
-}
-#else
-static void gmc_mmx(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)
-{
- gmc(dst, src, stride, h, ox, oy, dxx, dxy, dyx, dyy, shift, r,
- width, height, &ff_emulated_edge_mc_8);
-}
-#endif
-#endif
-
-#endif /* HAVE_INLINE_ASM */
-
-void ff_put_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);
-
-#if HAVE_INLINE_ASM
-
-/* CAVS-specific */
-void ff_put_cavs_qpel8_mc00_mmxext(uint8_t *dst, uint8_t *src, int stride)
-{
- put_pixels8_mmx(dst, src, stride, 8);
-}
-
-void ff_avg_cavs_qpel8_mc00_mmxext(uint8_t *dst, uint8_t *src, int stride)
-{
- avg_pixels8_mmx(dst, src, stride, 8);
-}
-
-void ff_put_cavs_qpel16_mc00_mmxext(uint8_t *dst, uint8_t *src, int stride)
-{
- put_pixels16_mmx(dst, src, stride, 16);
-}
-
-void ff_avg_cavs_qpel16_mc00_mmxext(uint8_t *dst, uint8_t *src, int stride)
-{
- avg_pixels16_mmx(dst, src, stride, 16);
-}
-#endif /* HAVE_INLINE_ASM */
-
-#if HAVE_YASM
-/* VC-1-specific */
-void ff_put_vc1_mspel_mc00_mmx(uint8_t *dst, const uint8_t *src,
- int stride, int rnd)
-{
- ff_put_pixels8_mmx(dst, src, stride, 8);
-}
-
-void ff_avg_vc1_mspel_mc00_mmxext(uint8_t *dst, const uint8_t *src,
- int stride, int rnd)
-{
- ff_avg_pixels8_mmxext(dst, src, stride, 8);
-}
-#endif /* HAVE_YASM */
-
-#if CONFIG_DIRAC_DECODER
-#define DIRAC_PIXOP(OPNAME2, OPNAME, EXT)\
-void ff_ ## OPNAME2 ## _dirac_pixels8_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
-{\
- if (h&3)\
- ff_ ## OPNAME2 ## _dirac_pixels8_c(dst, src, stride, h);\
- else\
- OPNAME ## _pixels8_ ## EXT(dst, src[0], stride, h);\
-}\
-void ff_ ## OPNAME2 ## _dirac_pixels16_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
-{\
- if (h&3)\
- ff_ ## OPNAME2 ## _dirac_pixels16_c(dst, src, stride, h);\
- else\
- OPNAME ## _pixels16_ ## EXT(dst, src[0], stride, h);\
-}\
-void ff_ ## OPNAME2 ## _dirac_pixels32_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
-{\
- if (h&3) {\
- ff_ ## OPNAME2 ## _dirac_pixels32_c(dst, src, stride, h);\
- } else {\
- OPNAME ## _pixels16_ ## EXT(dst , src[0] , stride, h);\
- OPNAME ## _pixels16_ ## EXT(dst+16, src[0]+16, stride, h);\
- }\
-}
-
-#if HAVE_MMX_INLINE
-DIRAC_PIXOP(put, put, mmx)
-DIRAC_PIXOP(avg, avg, mmx)
-#endif
-
-#if HAVE_YASM
-DIRAC_PIXOP(avg, ff_avg, mmxext)
-
-void ff_put_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
-{
- if (h&3)
- ff_put_dirac_pixels16_c(dst, src, stride, h);
- else
- ff_put_pixels16_sse2(dst, src[0], stride, h);
-}
-void ff_avg_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
-{
- if (h&3)
- ff_avg_dirac_pixels16_c(dst, src, stride, h);
- else
- ff_avg_pixels16_sse2(dst, src[0], stride, h);
-}
-void ff_put_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
-{
- if (h&3) {
- ff_put_dirac_pixels32_c(dst, src, stride, h);
- } else {
- ff_put_pixels16_sse2(dst , src[0] , stride, h);
- ff_put_pixels16_sse2(dst+16, src[0]+16, stride, h);
- }
-}
-void ff_avg_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
-{
- if (h&3) {
- ff_avg_dirac_pixels32_c(dst, src, stride, h);
- } else {
- ff_avg_pixels16_sse2(dst , src[0] , stride, h);
- ff_avg_pixels16_sse2(dst+16, src[0]+16, stride, h);
- }
-}
-#endif
-#endif
-
-/* XXX: Those functions should be suppressed ASAP when all IDCTs are
- * converted. */
-#if CONFIG_GPL
-static void ff_libmpeg2mmx_idct_put(uint8_t *dest, int line_size,
- int16_t *block)
-{
- ff_mmx_idct(block);
- ff_put_pixels_clamped_mmx(block, dest, line_size);
-}
-
-static void ff_libmpeg2mmx_idct_add(uint8_t *dest, int line_size,
- int16_t *block)
-{
- ff_mmx_idct(block);
- ff_add_pixels_clamped_mmx(block, dest, line_size);
-}
-
-static void ff_libmpeg2mmx2_idct_put(uint8_t *dest, int line_size,
- int16_t *block)
-{
- ff_mmxext_idct(block);
- ff_put_pixels_clamped_mmx(block, dest, line_size);
-}
-
-static void ff_libmpeg2mmx2_idct_add(uint8_t *dest, int line_size,
- int16_t *block)
-{
- ff_mmxext_idct(block);
- ff_add_pixels_clamped_mmx(block, dest, line_size);
-}
-#endif
-
-#if HAVE_INLINE_ASM
-static void vector_clipf_sse(float *dst, const float *src,
- float min, float max, int len)
-{
- x86_reg i = (len - 16) * 4;
- __asm__ volatile (
- "movss %3, %%xmm4 \n\t"
- "movss %4, %%xmm5 \n\t"
- "shufps $0, %%xmm4, %%xmm4 \n\t"
- "shufps $0, %%xmm5, %%xmm5 \n\t"
- "1: \n\t"
- "movaps (%2, %0), %%xmm0 \n\t" // 3/1 on intel
- "movaps 16(%2, %0), %%xmm1 \n\t"
- "movaps 32(%2, %0), %%xmm2 \n\t"
- "movaps 48(%2, %0), %%xmm3 \n\t"
- "maxps %%xmm4, %%xmm0 \n\t"
- "maxps %%xmm4, %%xmm1 \n\t"
- "maxps %%xmm4, %%xmm2 \n\t"
- "maxps %%xmm4, %%xmm3 \n\t"
- "minps %%xmm5, %%xmm0 \n\t"
- "minps %%xmm5, %%xmm1 \n\t"
- "minps %%xmm5, %%xmm2 \n\t"
- "minps %%xmm5, %%xmm3 \n\t"
- "movaps %%xmm0, (%1, %0) \n\t"
- "movaps %%xmm1, 16(%1, %0) \n\t"
- "movaps %%xmm2, 32(%1, %0) \n\t"
- "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"
- );
-}
-
-#endif /* HAVE_INLINE_ASM */
-
-int32_t ff_scalarproduct_int16_mmxext(const int16_t *v1, const int16_t *v2,
- int order);
-int32_t ff_scalarproduct_int16_sse2(const int16_t *v1, const int16_t *v2,
- int order);
-int32_t ff_scalarproduct_and_madd_int16_mmxext(int16_t *v1, const int16_t *v2,
- const int16_t *v3,
- int order, int mul);
-int32_t ff_scalarproduct_and_madd_int16_sse2(int16_t *v1, const int16_t *v2,
- const int16_t *v3,
- int order, int mul);
-int32_t ff_scalarproduct_and_madd_int16_ssse3(int16_t *v1, const int16_t *v2,
- const int16_t *v3,
- int order, int mul);
-
-void ff_apply_window_int16_round_mmxext(int16_t *output, const int16_t *input,
- const int16_t *window, unsigned int len);
-void ff_apply_window_int16_round_sse2(int16_t *output, const int16_t *input,
- const int16_t *window, unsigned int len);
-void ff_apply_window_int16_mmxext(int16_t *output, const int16_t *input,
- const int16_t *window, unsigned int len);
-void ff_apply_window_int16_sse2(int16_t *output, const int16_t *input,
- const int16_t *window, unsigned int len);
-void ff_apply_window_int16_ssse3(int16_t *output, const int16_t *input,
- const int16_t *window, unsigned int len);
-void ff_apply_window_int16_ssse3_atom(int16_t *output, const int16_t *input,
- const int16_t *window, unsigned int len);
-
-void ff_bswap32_buf_ssse3(uint32_t *dst, const uint32_t *src, int w);
-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 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_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);
-
-#define SET_QPEL_FUNCS(PFX, IDX, SIZE, CPU, PREFIX) \
- 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; \
- c->PFX ## _pixels_tab[IDX][ 3] = PREFIX ## PFX ## SIZE ## _mc30_ ## CPU; \
- c->PFX ## _pixels_tab[IDX][ 4] = PREFIX ## PFX ## SIZE ## _mc01_ ## CPU; \
- c->PFX ## _pixels_tab[IDX][ 5] = PREFIX ## PFX ## SIZE ## _mc11_ ## CPU; \
- c->PFX ## _pixels_tab[IDX][ 6] = PREFIX ## PFX ## SIZE ## _mc21_ ## CPU; \
- c->PFX ## _pixels_tab[IDX][ 7] = PREFIX ## PFX ## SIZE ## _mc31_ ## CPU; \
- c->PFX ## _pixels_tab[IDX][ 8] = PREFIX ## PFX ## SIZE ## _mc02_ ## CPU; \
- c->PFX ## _pixels_tab[IDX][ 9] = PREFIX ## PFX ## SIZE ## _mc12_ ## CPU; \
- c->PFX ## _pixels_tab[IDX][10] = PREFIX ## PFX ## SIZE ## _mc22_ ## CPU; \
- c->PFX ## _pixels_tab[IDX][11] = PREFIX ## PFX ## SIZE ## _mc32_ ## CPU; \
- c->PFX ## _pixels_tab[IDX][12] = PREFIX ## PFX ## SIZE ## _mc03_ ## CPU; \
- 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)
-
-#define SET_HPEL_FUNCS(PFX, IDX, SIZE, CPU) \
- do { \
- c->PFX ## _pixels_tab IDX [0] = PFX ## _pixels ## SIZE ## _ ## CPU; \
- c->PFX ## _pixels_tab IDX [1] = PFX ## _pixels ## SIZE ## _x2_ ## CPU; \
- c->PFX ## _pixels_tab IDX [2] = PFX ## _pixels ## SIZE ## _y2_ ## CPU; \
- c->PFX ## _pixels_tab IDX [3] = PFX ## _pixels ## SIZE ## _xy2_ ## CPU; \
- } while (0)
-
-static av_cold void dsputil_init_mmx(DSPContext *c, AVCodecContext *avctx,
- int mm_flags)
-{
- const int high_bit_depth = avctx->bits_per_raw_sample > 8;
-
-#if HAVE_INLINE_ASM
- 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;
-
- if (!high_bit_depth) {
- c->clear_block = clear_block_mmx;
- c->clear_blocks = clear_blocks_mmx;
- c->draw_edges = draw_edges_mmx;
-
- SET_HPEL_FUNCS(put, [0], 16, mmx);
- SET_HPEL_FUNCS(put_no_rnd, [0], 16, mmx);
- SET_HPEL_FUNCS(avg, [0], 16, mmx);
- SET_HPEL_FUNCS(avg_no_rnd, , 16, mmx);
- SET_HPEL_FUNCS(put, [1], 8, mmx);
- SET_HPEL_FUNCS(put_no_rnd, [1], 8, mmx);
- SET_HPEL_FUNCS(avg, [1], 8, mmx);
- }
-
-#if CONFIG_VIDEODSP && (ARCH_X86_32 || !HAVE_YASM)
- c->gmc = gmc_mmx;
-#endif
-
- c->add_bytes = add_bytes_mmx;
-#endif /* HAVE_INLINE_ASM */
-
-#if HAVE_YASM
- if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
- c->h263_v_loop_filter = ff_h263_v_loop_filter_mmx;
- c->h263_h_loop_filter = ff_h263_h_loop_filter_mmx;
- }
-
- c->vector_clip_int32 = ff_vector_clip_int32_mmx;
-#endif
-
-}
-
-static av_cold void dsputil_init_mmxext(DSPContext *c, AVCodecContext *avctx,
- int mm_flags)
-{
- const int bit_depth = avctx->bits_per_raw_sample;
- const int high_bit_depth = bit_depth > 8;
-
-#if HAVE_YASM
- SET_QPEL_FUNCS(avg_qpel, 0, 16, mmxext, );
- SET_QPEL_FUNCS(avg_qpel, 1, 8, mmxext, );
-
- SET_QPEL_FUNCS(put_qpel, 0, 16, mmxext, );
- SET_QPEL_FUNCS(put_qpel, 1, 8, mmxext, );
- SET_QPEL_FUNCS(put_no_rnd_qpel, 0, 16, mmxext, );
- SET_QPEL_FUNCS(put_no_rnd_qpel, 1, 8, mmxext, );
-
- if (!high_bit_depth) {
- c->put_pixels_tab[0][1] = ff_put_pixels16_x2_mmxext;
- c->put_pixels_tab[0][2] = ff_put_pixels16_y2_mmxext;
-
- c->avg_pixels_tab[0][0] = ff_avg_pixels16_mmxext;
- c->avg_pixels_tab[0][1] = ff_avg_pixels16_x2_mmxext;
- c->avg_pixels_tab[0][2] = ff_avg_pixels16_y2_mmxext;
-
- c->put_pixels_tab[1][1] = ff_put_pixels8_x2_mmxext;
- c->put_pixels_tab[1][2] = ff_put_pixels8_y2_mmxext;
-
- c->avg_pixels_tab[1][0] = ff_avg_pixels8_mmxext;
- c->avg_pixels_tab[1][1] = ff_avg_pixels8_x2_mmxext;
- c->avg_pixels_tab[1][2] = ff_avg_pixels8_y2_mmxext;
- }
-
- if (!(avctx->flags & CODEC_FLAG_BITEXACT)) {
- if (!high_bit_depth) {
- c->put_no_rnd_pixels_tab[0][1] = ff_put_no_rnd_pixels16_x2_mmxext;
- c->put_no_rnd_pixels_tab[0][2] = ff_put_no_rnd_pixels16_y2_mmxext;
- c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_mmxext;
- c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_mmxext;
-
- c->avg_pixels_tab[0][3] = ff_avg_pixels16_xy2_mmxext;
- c->avg_pixels_tab[1][3] = ff_avg_pixels8_xy2_mmxext;
- }
- }
-#endif /* HAVE_YASM */
-
-#if HAVE_MMXEXT_EXTERNAL
- if (CONFIG_VP3_DECODER && (avctx->codec_id == AV_CODEC_ID_VP3 ||
- avctx->codec_id == AV_CODEC_ID_THEORA)) {
- c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_exact_mmxext;
- c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_exact_mmxext;
- }
-
- /* slower than cmov version on AMD */
- if (!(mm_flags & AV_CPU_FLAG_3DNOW))
- c->add_hfyu_median_prediction = ff_add_hfyu_median_prediction_mmxext;
-
- c->scalarproduct_int16 = ff_scalarproduct_int16_mmxext;
- c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_mmxext;
-
- if (avctx->flags & CODEC_FLAG_BITEXACT) {
- c->apply_window_int16 = ff_apply_window_int16_mmxext;
- } else {
- c->apply_window_int16 = ff_apply_window_int16_round_mmxext;
- }
-#endif /* HAVE_MMXEXT_EXTERNAL */
-}
-
-static av_cold void dsputil_init_3dnow(DSPContext *c, AVCodecContext *avctx,
- int mm_flags)
-{
- const int high_bit_depth = avctx->bits_per_raw_sample > 8;
-
-#if HAVE_YASM
- if (!high_bit_depth) {
- c->put_pixels_tab[0][1] = ff_put_pixels16_x2_3dnow;
- c->put_pixels_tab[0][2] = ff_put_pixels16_y2_3dnow;
-
- c->avg_pixels_tab[0][0] = ff_avg_pixels16_3dnow;
- c->avg_pixels_tab[0][1] = ff_avg_pixels16_x2_3dnow;
- c->avg_pixels_tab[0][2] = ff_avg_pixels16_y2_3dnow;
-
- c->put_pixels_tab[1][1] = ff_put_pixels8_x2_3dnow;
- c->put_pixels_tab[1][2] = ff_put_pixels8_y2_3dnow;
-
- c->avg_pixels_tab[1][0] = ff_avg_pixels8_3dnow;
- c->avg_pixels_tab[1][1] = ff_avg_pixels8_x2_3dnow;
- c->avg_pixels_tab[1][2] = ff_avg_pixels8_y2_3dnow;
-
- if (!(avctx->flags & CODEC_FLAG_BITEXACT)){
- c->put_no_rnd_pixels_tab[0][1] = ff_put_no_rnd_pixels16_x2_3dnow;
- c->put_no_rnd_pixels_tab[0][2] = ff_put_no_rnd_pixels16_y2_3dnow;
- c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_3dnow;
- c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_3dnow;
-
- c->avg_pixels_tab[0][3] = ff_avg_pixels16_xy2_3dnow;
- c->avg_pixels_tab[1][3] = ff_avg_pixels8_xy2_3dnow;
- }
- }
-
- if (CONFIG_VP3_DECODER && (avctx->codec_id == AV_CODEC_ID_VP3 ||
- avctx->codec_id == AV_CODEC_ID_THEORA)) {
- c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_exact_3dnow;
- c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_exact_3dnow;
- }
-#endif /* HAVE_YASM */
-}
-
-static av_cold void dsputil_init_sse(DSPContext *c, AVCodecContext *avctx,
- int mm_flags)
-{
- const int high_bit_depth = avctx->bits_per_raw_sample > 8;
-
-#if HAVE_INLINE_ASM
- if (!high_bit_depth) {
- if (!(CONFIG_MPEG_XVMC_DECODER && avctx->xvmc_acceleration > 1)) {
- /* XvMCCreateBlocks() may not allocate 16-byte aligned blocks */
- c->clear_block = clear_block_sse;
- c->clear_blocks = clear_blocks_sse;
- }
- }
-
- c->vector_clipf = vector_clipf_sse;
-#endif /* HAVE_INLINE_ASM */
-
-#if HAVE_YASM
-#if HAVE_INLINE_ASM && CONFIG_VIDEODSP
- c->gmc = gmc_sse;
-#endif
-#endif /* HAVE_YASM */
-}
-
-static av_cold void dsputil_init_sse2(DSPContext *c, AVCodecContext *avctx,
- int mm_flags)
-{
- const int bit_depth = avctx->bits_per_raw_sample;
- const int high_bit_depth = bit_depth > 8;
-
-#if HAVE_SSE2_INLINE
- if (!high_bit_depth && avctx->idct_algo == FF_IDCT_XVIDMMX) {
- c->idct_put = ff_idct_xvid_sse2_put;
- c->idct_add = ff_idct_xvid_sse2_add;
- c->idct = ff_idct_xvid_sse2;
- c->idct_permutation_type = FF_SSE2_IDCT_PERM;
- }
-#endif /* HAVE_SSE2_INLINE */
-
-#if HAVE_SSE2_EXTERNAL
- if (!(mm_flags & AV_CPU_FLAG_SSE2SLOW)) {
- // these functions are slower than mmx on AMD, but faster on Intel
- if (!high_bit_depth) {
- c->put_pixels_tab[0][0] = ff_put_pixels16_sse2;
- c->put_no_rnd_pixels_tab[0][0] = ff_put_pixels16_sse2;
- c->avg_pixels_tab[0][0] = ff_avg_pixels16_sse2;
- }
- }
-
- c->scalarproduct_int16 = ff_scalarproduct_int16_sse2;
- c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_sse2;
- if (mm_flags & AV_CPU_FLAG_ATOM) {
- c->vector_clip_int32 = ff_vector_clip_int32_int_sse2;
- } else {
- c->vector_clip_int32 = ff_vector_clip_int32_sse2;
- }
- if (avctx->flags & CODEC_FLAG_BITEXACT) {
- c->apply_window_int16 = ff_apply_window_int16_sse2;
- } else if (!(mm_flags & AV_CPU_FLAG_SSE2SLOW)) {
- c->apply_window_int16 = ff_apply_window_int16_round_sse2;
- }
- c->bswap_buf = ff_bswap32_buf_sse2;
-#endif /* HAVE_SSE2_EXTERNAL */
-}
-
-static av_cold void dsputil_init_ssse3(DSPContext *c, AVCodecContext *avctx,
- int mm_flags)
-{
-#if HAVE_SSSE3_EXTERNAL
- c->add_hfyu_left_prediction = ff_add_hfyu_left_prediction_ssse3;
- if (mm_flags & AV_CPU_FLAG_SSE4) // not really sse4, just slow on Conroe
- c->add_hfyu_left_prediction = ff_add_hfyu_left_prediction_sse4;
-
- if (mm_flags & AV_CPU_FLAG_ATOM)
- c->apply_window_int16 = ff_apply_window_int16_ssse3_atom;
- else
- c->apply_window_int16 = ff_apply_window_int16_ssse3;
- if (!(mm_flags & (AV_CPU_FLAG_SSE42|AV_CPU_FLAG_3DNOW))) // cachesplit
- c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_ssse3;
- c->bswap_buf = ff_bswap32_buf_ssse3;
-#endif /* HAVE_SSSE3_EXTERNAL */
-}
-
-static av_cold void dsputil_init_sse4(DSPContext *c, AVCodecContext *avctx,
- int mm_flags)
-{
-#if HAVE_SSE4_EXTERNAL
- c->vector_clip_int32 = ff_vector_clip_int32_sse4;
-#endif /* HAVE_SSE4_EXTERNAL */
-}
-
-av_cold void ff_dsputil_init_mmx(DSPContext *c, AVCodecContext *avctx)
-{
- int mm_flags = av_get_cpu_flags();
-
-#if HAVE_7REGS && HAVE_INLINE_ASM
- if (mm_flags & AV_CPU_FLAG_CMOV)
- c->add_hfyu_median_prediction = add_hfyu_median_prediction_cmov;
-#endif
-
- if (mm_flags & AV_CPU_FLAG_MMX) {
-#if HAVE_INLINE_ASM
- const int idct_algo = avctx->idct_algo;
-
- if (avctx->lowres == 0 && avctx->bits_per_raw_sample <= 8) {
- 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;
- c->idct = ff_simple_idct_mmx;
- c->idct_permutation_type = FF_SIMPLE_IDCT_PERM;
-#if CONFIG_GPL
- } else if (idct_algo == FF_IDCT_LIBMPEG2MMX) {
- if (mm_flags & AV_CPU_FLAG_MMX2) {
- c->idct_put = ff_libmpeg2mmx2_idct_put;
- c->idct_add = ff_libmpeg2mmx2_idct_add;
- c->idct = ff_mmxext_idct;
- } else {
- c->idct_put = ff_libmpeg2mmx_idct_put;
- c->idct_add = ff_libmpeg2mmx_idct_add;
- c->idct = ff_mmx_idct;
- }
- c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;
-#endif
- } else if (idct_algo == FF_IDCT_XVIDMMX) {
- if (mm_flags & AV_CPU_FLAG_SSE2) {
- c->idct_put = ff_idct_xvid_sse2_put;
- c->idct_add = ff_idct_xvid_sse2_add;
- c->idct = ff_idct_xvid_sse2;
- c->idct_permutation_type = FF_SSE2_IDCT_PERM;
- } else if (mm_flags & AV_CPU_FLAG_MMXEXT) {
- c->idct_put = ff_idct_xvid_mmxext_put;
- c->idct_add = ff_idct_xvid_mmxext_add;
- c->idct = ff_idct_xvid_mmxext;
- } else {
- c->idct_put = ff_idct_xvid_mmx_put;
- c->idct_add = ff_idct_xvid_mmx_add;
- c->idct = ff_idct_xvid_mmx;
- }
- }
- }
-#endif /* HAVE_INLINE_ASM */
-
- dsputil_init_mmx(c, avctx, mm_flags);
- }
-
- if (mm_flags & AV_CPU_FLAG_MMXEXT)
- dsputil_init_mmxext(c, avctx, mm_flags);
-
- if (mm_flags & AV_CPU_FLAG_3DNOW)
- dsputil_init_3dnow(c, avctx, mm_flags);
-
- if (mm_flags & AV_CPU_FLAG_SSE)
- dsputil_init_sse(c, avctx, mm_flags);
-
- if (mm_flags & AV_CPU_FLAG_SSE2)
- dsputil_init_sse2(c, avctx, mm_flags);
-
- if (mm_flags & AV_CPU_FLAG_SSSE3)
- dsputil_init_ssse3(c, avctx, mm_flags);
-
- if (mm_flags & AV_CPU_FLAG_SSE4)
- dsputil_init_sse4(c, avctx, mm_flags);
-
- if (CONFIG_ENCODERS)
- ff_dsputilenc_init_mmx(c, avctx);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/dsputil_mmx.h b/src/thirdparty/ffmpeg/libavcodec/x86/dsputil_mmx.h
deleted file mode 100644
index 0a0ea502b..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/dsputil_mmx.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * MMX optimized DSP utils
- * Copyright (c) 2007 Aurelien Jacobs <aurel@gnuage.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_X86_DSPUTIL_MMX_H
-#define AVCODEC_X86_DSPUTIL_MMX_H
-
-#include <stdint.h>
-#include "libavcodec/dsputil.h"
-#include "libavutil/x86/asm.h"
-
-typedef struct xmm_reg { uint64_t a, b; } xmm_reg;
-
-extern const uint64_t ff_bone;
-extern const uint64_t ff_wtwo;
-
-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 uint64_t ff_pw_15;
-extern const xmm_reg ff_pw_16;
-extern const xmm_reg ff_pw_18;
-extern const uint64_t ff_pw_20;
-extern const xmm_reg ff_pw_27;
-extern const xmm_reg ff_pw_28;
-extern const xmm_reg ff_pw_32;
-extern const uint64_t ff_pw_42;
-extern const uint64_t ff_pw_53;
-extern const xmm_reg ff_pw_63;
-extern const xmm_reg ff_pw_64;
-extern const uint64_t ff_pw_96;
-extern const uint64_t ff_pw_128;
-extern const uint64_t ff_pw_255;
-
-extern const xmm_reg ff_pb_1;
-extern const xmm_reg ff_pb_3;
-extern const uint64_t ff_pb_7;
-extern const uint64_t ff_pb_1F;
-extern const uint64_t ff_pb_3F;
-extern const uint64_t ff_pb_81;
-extern const xmm_reg ff_pb_A1;
-extern const xmm_reg ff_pb_F8;
-extern const uint64_t ff_pb_FC;
-extern const xmm_reg ff_pb_FE;
-
-extern const double ff_pd_1[2];
-extern const double ff_pd_2[2];
-
-#define SBUTTERFLY(a,b,t,n,m)\
- "mov" #m " " #a ", " #t " \n\t" /* abcd */\
- "punpckl" #n " " #b ", " #a " \n\t" /* aebf */\
- "punpckh" #n " " #b ", " #t " \n\t" /* cgdh */\
-
-#define TRANSPOSE4(a,b,c,d,t)\
- SBUTTERFLY(a,b,t,wd,q) /* a=aebf t=cgdh */\
- SBUTTERFLY(c,d,b,wd,q) /* c=imjn b=kolp */\
- SBUTTERFLY(a,c,d,dq,q) /* a=aeim d=bfjn */\
- SBUTTERFLY(t,b,c,dq,q) /* t=cgko c=dhlp */
-
-#define MOVQ_WONE(regd) \
- __asm__ volatile ( \
- "pcmpeqd %%" #regd ", %%" #regd " \n\t" \
- "psrlw $15, %%" #regd ::)
-
-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_put_cavs_qpel8_mc00_mmxext(uint8_t *dst, uint8_t *src, int stride);
-void ff_avg_cavs_qpel8_mc00_mmxext(uint8_t *dst, uint8_t *src, int stride);
-void ff_put_cavs_qpel16_mc00_mmxext(uint8_t *dst, uint8_t *src, int stride);
-void ff_avg_cavs_qpel16_mc00_mmxext(uint8_t *dst, uint8_t *src, int stride);
-
-void ff_put_vc1_mspel_mc00_mmx(uint8_t *dst, const uint8_t *src, int stride, int rnd);
-void ff_avg_vc1_mspel_mc00_mmxext(uint8_t *dst, const uint8_t *src, int stride, int rnd);
-
-void ff_put_rv40_qpel8_mc33_mmx(uint8_t *block, uint8_t *pixels, int line_size);
-void ff_put_rv40_qpel16_mc33_mmx(uint8_t *block, uint8_t *pixels, int line_size);
-void ff_avg_rv40_qpel8_mc33_mmx(uint8_t *block, uint8_t *pixels, int line_size);
-void ff_avg_rv40_qpel16_mc33_mmx(uint8_t *block, uint8_t *pixels, int line_size);
-
-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);
-
-#endif /* AVCODEC_X86_DSPUTIL_MMX_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/dsputil_qns_template.c b/src/thirdparty/ffmpeg/libavcodec/x86/dsputil_qns_template.c
deleted file mode 100644
index 77a41b9dc..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/dsputil_qns_template.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * DSP utils : QNS functions are compiled 3 times for mmx/3dnow/ssse3
- * Copyright (c) 2004 Michael Niedermayer
- *
- * MMX optimization by Michael Niedermayer <michaelni@gmx.at>
- * 3DNow! and SSSE3 optimization by Zuxy Meng <zuxy.meng@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
- */
-
-#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)
-{
- x86_reg i=0;
-
- assert(FFABS(scale) < MAX_ABS);
- scale<<= 16 + SCALE_OFFSET - BASIS_SHIFT + RECON_SHIFT;
-
- SET_RND(mm6);
- __asm__ volatile(
- "pxor %%mm7, %%mm7 \n\t"
- "movd %4, %%mm5 \n\t"
- "punpcklwd %%mm5, %%mm5 \n\t"
- "punpcklwd %%mm5, %%mm5 \n\t"
- ".p2align 4 \n\t"
- "1: \n\t"
- "movq (%1, %0), %%mm0 \n\t"
- "movq 8(%1, %0), %%mm1 \n\t"
- PMULHRW(%%mm0, %%mm1, %%mm5, %%mm6)
- "paddw (%2, %0), %%mm0 \n\t"
- "paddw 8(%2, %0), %%mm1 \n\t"
- "psraw $6, %%mm0 \n\t"
- "psraw $6, %%mm1 \n\t"
- "pmullw (%3, %0), %%mm0 \n\t"
- "pmullw 8(%3, %0), %%mm1 \n\t"
- "pmaddwd %%mm0, %%mm0 \n\t"
- "pmaddwd %%mm1, %%mm1 \n\t"
- "paddd %%mm1, %%mm0 \n\t"
- "psrld $4, %%mm0 \n\t"
- "paddd %%mm0, %%mm7 \n\t"
- "add $16, %0 \n\t"
- "cmp $128, %0 \n\t" //FIXME optimize & bench
- " jb 1b \n\t"
- PHADDD(%%mm7, %%mm6)
- "psrld $2, %%mm7 \n\t"
- "movd %%mm7, %0 \n\t"
-
- : "+r" (i)
- : "r"(basis), "r"(rem), "r"(weight), "g"(scale)
- );
- return i;
-}
-
-static void DEF(add_8x8basis)(int16_t rem[64], int16_t basis[64], int scale)
-{
- x86_reg i=0;
-
- if(FFABS(scale) < MAX_ABS){
- scale<<= 16 + SCALE_OFFSET - BASIS_SHIFT + RECON_SHIFT;
- SET_RND(mm6);
- __asm__ volatile(
- "movd %3, %%mm5 \n\t"
- "punpcklwd %%mm5, %%mm5 \n\t"
- "punpcklwd %%mm5, %%mm5 \n\t"
- ".p2align 4 \n\t"
- "1: \n\t"
- "movq (%1, %0), %%mm0 \n\t"
- "movq 8(%1, %0), %%mm1 \n\t"
- PMULHRW(%%mm0, %%mm1, %%mm5, %%mm6)
- "paddw (%2, %0), %%mm0 \n\t"
- "paddw 8(%2, %0), %%mm1 \n\t"
- "movq %%mm0, (%2, %0) \n\t"
- "movq %%mm1, 8(%2, %0) \n\t"
- "add $16, %0 \n\t"
- "cmp $128, %0 \n\t" // FIXME optimize & bench
- " jb 1b \n\t"
-
- : "+r" (i)
- : "r"(basis), "r"(rem), "g"(scale)
- );
- }else{
- for(i=0; i<8*8; i++){
- rem[i] += (basis[i]*scale + (1<<(BASIS_SHIFT - RECON_SHIFT-1)))>>(BASIS_SHIFT - RECON_SHIFT);
- }
- }
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/dsputil_rnd_template.c b/src/thirdparty/ffmpeg/libavcodec/x86/dsputil_rnd_template.c
deleted file mode 100644
index 4568207a2..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/dsputil_rnd_template.c
+++ /dev/null
@@ -1,594 +0,0 @@
-/*
- * DSP utils mmx functions are compiled twice for rnd/no_rnd
- * Copyright (c) 2000, 2001 Fabrice Bellard
- * Copyright (c) 2003-2004 Michael Niedermayer <michaelni@gmx.at>
- *
- * MMX optimization by Nick Kurshev <nickols_k@mail.ru>
- * mostly rewritten by Michael Niedermayer <michaelni@gmx.at>
- * and improved by Zdenek Kabelac <kabi@users.sf.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
- */
-
-// put_pixels
-static void DEF(put, pixels8_x2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
- MOVQ_BFE(mm6);
- __asm__ volatile(
- "lea (%3, %3), %%"REG_a" \n\t"
- ".p2align 3 \n\t"
- "1: \n\t"
- "movq (%1), %%mm0 \n\t"
- "movq 1(%1), %%mm1 \n\t"
- "movq (%1, %3), %%mm2 \n\t"
- "movq 1(%1, %3), %%mm3 \n\t"
- PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)
- "movq %%mm4, (%2) \n\t"
- "movq %%mm5, (%2, %3) \n\t"
- "add %%"REG_a", %1 \n\t"
- "add %%"REG_a", %2 \n\t"
- "movq (%1), %%mm0 \n\t"
- "movq 1(%1), %%mm1 \n\t"
- "movq (%1, %3), %%mm2 \n\t"
- "movq 1(%1, %3), %%mm3 \n\t"
- PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)
- "movq %%mm4, (%2) \n\t"
- "movq %%mm5, (%2, %3) \n\t"
- "add %%"REG_a", %1 \n\t"
- "add %%"REG_a", %2 \n\t"
- "subl $4, %0 \n\t"
- "jnz 1b \n\t"
- :"+g"(h), "+S"(pixels), "+D"(block)
- :"r"((x86_reg)line_size)
- :REG_a, "memory");
-}
-
-static void av_unused DEF(put, pixels8_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
-{
- MOVQ_BFE(mm6);
- __asm__ volatile(
- "testl $1, %0 \n\t"
- " jz 1f \n\t"
- "movq (%1), %%mm0 \n\t"
- "movq (%2), %%mm1 \n\t"
- "add %4, %1 \n\t"
- "add $8, %2 \n\t"
- PAVGB(%%mm0, %%mm1, %%mm4, %%mm6)
- "movq %%mm4, (%3) \n\t"
- "add %5, %3 \n\t"
- "decl %0 \n\t"
- ".p2align 3 \n\t"
- "1: \n\t"
- "movq (%1), %%mm0 \n\t"
- "movq (%2), %%mm1 \n\t"
- "add %4, %1 \n\t"
- "movq (%1), %%mm2 \n\t"
- "movq 8(%2), %%mm3 \n\t"
- "add %4, %1 \n\t"
- PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)
- "movq %%mm4, (%3) \n\t"
- "add %5, %3 \n\t"
- "movq %%mm5, (%3) \n\t"
- "add %5, %3 \n\t"
- "movq (%1), %%mm0 \n\t"
- "movq 16(%2), %%mm1 \n\t"
- "add %4, %1 \n\t"
- "movq (%1), %%mm2 \n\t"
- "movq 24(%2), %%mm3 \n\t"
- "add %4, %1 \n\t"
- "add $32, %2 \n\t"
- PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)
- "movq %%mm4, (%3) \n\t"
- "add %5, %3 \n\t"
- "movq %%mm5, (%3) \n\t"
- "add %5, %3 \n\t"
- "subl $4, %0 \n\t"
- "jnz 1b \n\t"
-#if !HAVE_EBX_AVAILABLE //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cannot be used
- :"+m"(h), "+a"(src1), "+c"(src2), "+d"(dst)
-#else
- :"+b"(h), "+a"(src1), "+c"(src2), "+d"(dst)
-#endif
- :"S"((x86_reg)src1Stride), "D"((x86_reg)dstStride)
- :"memory");
-}
-
-static void DEF(put, pixels16_x2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
- MOVQ_BFE(mm6);
- __asm__ volatile(
- "lea (%3, %3), %%"REG_a" \n\t"
- ".p2align 3 \n\t"
- "1: \n\t"
- "movq (%1), %%mm0 \n\t"
- "movq 1(%1), %%mm1 \n\t"
- "movq (%1, %3), %%mm2 \n\t"
- "movq 1(%1, %3), %%mm3 \n\t"
- PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)
- "movq %%mm4, (%2) \n\t"
- "movq %%mm5, (%2, %3) \n\t"
- "movq 8(%1), %%mm0 \n\t"
- "movq 9(%1), %%mm1 \n\t"
- "movq 8(%1, %3), %%mm2 \n\t"
- "movq 9(%1, %3), %%mm3 \n\t"
- PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)
- "movq %%mm4, 8(%2) \n\t"
- "movq %%mm5, 8(%2, %3) \n\t"
- "add %%"REG_a", %1 \n\t"
- "add %%"REG_a", %2 \n\t"
- "movq (%1), %%mm0 \n\t"
- "movq 1(%1), %%mm1 \n\t"
- "movq (%1, %3), %%mm2 \n\t"
- "movq 1(%1, %3), %%mm3 \n\t"
- PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)
- "movq %%mm4, (%2) \n\t"
- "movq %%mm5, (%2, %3) \n\t"
- "movq 8(%1), %%mm0 \n\t"
- "movq 9(%1), %%mm1 \n\t"
- "movq 8(%1, %3), %%mm2 \n\t"
- "movq 9(%1, %3), %%mm3 \n\t"
- PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)
- "movq %%mm4, 8(%2) \n\t"
- "movq %%mm5, 8(%2, %3) \n\t"
- "add %%"REG_a", %1 \n\t"
- "add %%"REG_a", %2 \n\t"
- "subl $4, %0 \n\t"
- "jnz 1b \n\t"
- :"+g"(h), "+S"(pixels), "+D"(block)
- :"r"((x86_reg)line_size)
- :REG_a, "memory");
-}
-
-static void av_unused DEF(put, pixels16_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
-{
- MOVQ_BFE(mm6);
- __asm__ volatile(
- "testl $1, %0 \n\t"
- " jz 1f \n\t"
- "movq (%1), %%mm0 \n\t"
- "movq (%2), %%mm1 \n\t"
- "movq 8(%1), %%mm2 \n\t"
- "movq 8(%2), %%mm3 \n\t"
- "add %4, %1 \n\t"
- "add $16, %2 \n\t"
- PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)
- "movq %%mm4, (%3) \n\t"
- "movq %%mm5, 8(%3) \n\t"
- "add %5, %3 \n\t"
- "decl %0 \n\t"
- ".p2align 3 \n\t"
- "1: \n\t"
- "movq (%1), %%mm0 \n\t"
- "movq (%2), %%mm1 \n\t"
- "movq 8(%1), %%mm2 \n\t"
- "movq 8(%2), %%mm3 \n\t"
- "add %4, %1 \n\t"
- PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)
- "movq %%mm4, (%3) \n\t"
- "movq %%mm5, 8(%3) \n\t"
- "add %5, %3 \n\t"
- "movq (%1), %%mm0 \n\t"
- "movq 16(%2), %%mm1 \n\t"
- "movq 8(%1), %%mm2 \n\t"
- "movq 24(%2), %%mm3 \n\t"
- "add %4, %1 \n\t"
- PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)
- "movq %%mm4, (%3) \n\t"
- "movq %%mm5, 8(%3) \n\t"
- "add %5, %3 \n\t"
- "add $32, %2 \n\t"
- "subl $2, %0 \n\t"
- "jnz 1b \n\t"
-#if !HAVE_EBX_AVAILABLE //Note "+bm" and "+mb" are buggy too (with gcc 3.2.2 at least) and cannot be used
- :"+m"(h), "+a"(src1), "+c"(src2), "+d"(dst)
-#else
- :"+b"(h), "+a"(src1), "+c"(src2), "+d"(dst)
-#endif
- :"S"((x86_reg)src1Stride), "D"((x86_reg)dstStride)
- :"memory");
-}
-
-static void DEF(put, pixels8_y2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
- MOVQ_BFE(mm6);
- __asm__ volatile(
- "lea (%3, %3), %%"REG_a" \n\t"
- "movq (%1), %%mm0 \n\t"
- ".p2align 3 \n\t"
- "1: \n\t"
- "movq (%1, %3), %%mm1 \n\t"
- "movq (%1, %%"REG_a"),%%mm2 \n\t"
- PAVGBP(%%mm1, %%mm0, %%mm4, %%mm2, %%mm1, %%mm5)
- "movq %%mm4, (%2) \n\t"
- "movq %%mm5, (%2, %3) \n\t"
- "add %%"REG_a", %1 \n\t"
- "add %%"REG_a", %2 \n\t"
- "movq (%1, %3), %%mm1 \n\t"
- "movq (%1, %%"REG_a"),%%mm0 \n\t"
- PAVGBP(%%mm1, %%mm2, %%mm4, %%mm0, %%mm1, %%mm5)
- "movq %%mm4, (%2) \n\t"
- "movq %%mm5, (%2, %3) \n\t"
- "add %%"REG_a", %1 \n\t"
- "add %%"REG_a", %2 \n\t"
- "subl $4, %0 \n\t"
- "jnz 1b \n\t"
- :"+g"(h), "+S"(pixels), "+D"(block)
- :"r"((x86_reg)line_size)
- :REG_a, "memory");
-}
-
-static void DEF(put, pixels8_xy2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
- MOVQ_ZERO(mm7);
- SET_RND(mm6); // =2 for rnd and =1 for no_rnd version
- __asm__ volatile(
- "movq (%1), %%mm0 \n\t"
- "movq 1(%1), %%mm4 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "movq %%mm4, %%mm5 \n\t"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "punpcklbw %%mm7, %%mm4 \n\t"
- "punpckhbw %%mm7, %%mm1 \n\t"
- "punpckhbw %%mm7, %%mm5 \n\t"
- "paddusw %%mm0, %%mm4 \n\t"
- "paddusw %%mm1, %%mm5 \n\t"
- "xor %%"REG_a", %%"REG_a" \n\t"
- "add %3, %1 \n\t"
- ".p2align 3 \n\t"
- "1: \n\t"
- "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"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
- "punpckhbw %%mm7, %%mm1 \n\t"
- "punpckhbw %%mm7, %%mm3 \n\t"
- "paddusw %%mm2, %%mm0 \n\t"
- "paddusw %%mm3, %%mm1 \n\t"
- "paddusw %%mm6, %%mm4 \n\t"
- "paddusw %%mm6, %%mm5 \n\t"
- "paddusw %%mm0, %%mm4 \n\t"
- "paddusw %%mm1, %%mm5 \n\t"
- "psrlw $2, %%mm4 \n\t"
- "psrlw $2, %%mm5 \n\t"
- "packuswb %%mm5, %%mm4 \n\t"
- "movq %%mm4, (%2, %%"REG_a") \n\t"
- "add %3, %%"REG_a" \n\t"
-
- "movq (%1, %%"REG_a"), %%mm2 \n\t" // 0 <-> 2 1 <-> 3
- "movq 1(%1, %%"REG_a"), %%mm4 \n\t"
- "movq %%mm2, %%mm3 \n\t"
- "movq %%mm4, %%mm5 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
- "punpcklbw %%mm7, %%mm4 \n\t"
- "punpckhbw %%mm7, %%mm3 \n\t"
- "punpckhbw %%mm7, %%mm5 \n\t"
- "paddusw %%mm2, %%mm4 \n\t"
- "paddusw %%mm3, %%mm5 \n\t"
- "paddusw %%mm6, %%mm0 \n\t"
- "paddusw %%mm6, %%mm1 \n\t"
- "paddusw %%mm4, %%mm0 \n\t"
- "paddusw %%mm5, %%mm1 \n\t"
- "psrlw $2, %%mm0 \n\t"
- "psrlw $2, %%mm1 \n\t"
- "packuswb %%mm1, %%mm0 \n\t"
- "movq %%mm0, (%2, %%"REG_a") \n\t"
- "add %3, %%"REG_a" \n\t"
-
- "subl $2, %0 \n\t"
- "jnz 1b \n\t"
- :"+g"(h), "+S"(pixels)
- :"D"(block), "r"((x86_reg)line_size)
- :REG_a, "memory");
-}
-
-// avg_pixels
-static void av_unused DEF(avg, pixels4)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
- MOVQ_BFE(mm6);
- JUMPALIGN();
- do {
- __asm__ volatile(
- "movd %0, %%mm0 \n\t"
- "movd %1, %%mm1 \n\t"
- OP_AVG(%%mm0, %%mm1, %%mm2, %%mm6)
- "movd %%mm2, %0 \n\t"
- :"+m"(*block)
- :"m"(*pixels)
- :"memory");
- pixels += line_size;
- block += line_size;
- }
- while (--h);
-}
-
-#ifndef NO_RND
-// in case more speed is needed - unroling would certainly help
-static void DEF(avg, pixels8)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
- MOVQ_BFE(mm6);
- JUMPALIGN();
- do {
- __asm__ volatile(
- "movq %0, %%mm0 \n\t"
- "movq %1, %%mm1 \n\t"
- OP_AVG(%%mm0, %%mm1, %%mm2, %%mm6)
- "movq %%mm2, %0 \n\t"
- :"+m"(*block)
- :"m"(*pixels)
- :"memory");
- pixels += line_size;
- block += line_size;
- }
- while (--h);
-}
-#endif // NO_RND
-
-static void DEF(avg, pixels16)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
- MOVQ_BFE(mm6);
- JUMPALIGN();
- do {
- __asm__ volatile(
- "movq %0, %%mm0 \n\t"
- "movq %1, %%mm1 \n\t"
- OP_AVG(%%mm0, %%mm1, %%mm2, %%mm6)
- "movq %%mm2, %0 \n\t"
- "movq 8%0, %%mm0 \n\t"
- "movq 8%1, %%mm1 \n\t"
- OP_AVG(%%mm0, %%mm1, %%mm2, %%mm6)
- "movq %%mm2, 8%0 \n\t"
- :"+m"(*block)
- :"m"(*pixels)
- :"memory");
- pixels += line_size;
- block += line_size;
- }
- while (--h);
-}
-
-#ifndef NO_RND
-static void DEF(avg, pixels8_x2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
- MOVQ_BFE(mm6);
- JUMPALIGN();
- do {
- __asm__ volatile(
- "movq %1, %%mm0 \n\t"
- "movq 1%1, %%mm1 \n\t"
- "movq %0, %%mm3 \n\t"
- PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
- OP_AVG(%%mm3, %%mm2, %%mm0, %%mm6)
- "movq %%mm0, %0 \n\t"
- :"+m"(*block)
- :"m"(*pixels)
- :"memory");
- pixels += line_size;
- block += line_size;
- } while (--h);
-}
-#endif // NO_RND
-
-static av_unused void DEF(avg, pixels8_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
-{
- MOVQ_BFE(mm6);
- JUMPALIGN();
- do {
- __asm__ volatile(
- "movq %1, %%mm0 \n\t"
- "movq %2, %%mm1 \n\t"
- "movq %0, %%mm3 \n\t"
- PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
- OP_AVG(%%mm3, %%mm2, %%mm0, %%mm6)
- "movq %%mm0, %0 \n\t"
- :"+m"(*dst)
- :"m"(*src1), "m"(*src2)
- :"memory");
- dst += dstStride;
- src1 += src1Stride;
- src2 += 8;
- } while (--h);
-}
-
-static void DEF(avg, pixels16_x2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
- MOVQ_BFE(mm6);
- JUMPALIGN();
- do {
- __asm__ volatile(
- "movq %1, %%mm0 \n\t"
- "movq 1%1, %%mm1 \n\t"
- "movq %0, %%mm3 \n\t"
- PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
- OP_AVG(%%mm3, %%mm2, %%mm0, %%mm6)
- "movq %%mm0, %0 \n\t"
- "movq 8%1, %%mm0 \n\t"
- "movq 9%1, %%mm1 \n\t"
- "movq 8%0, %%mm3 \n\t"
- PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
- OP_AVG(%%mm3, %%mm2, %%mm0, %%mm6)
- "movq %%mm0, 8%0 \n\t"
- :"+m"(*block)
- :"m"(*pixels)
- :"memory");
- pixels += line_size;
- block += line_size;
- } while (--h);
-}
-
-static av_unused void DEF(avg, pixels16_l2)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
-{
- MOVQ_BFE(mm6);
- JUMPALIGN();
- do {
- __asm__ volatile(
- "movq %1, %%mm0 \n\t"
- "movq %2, %%mm1 \n\t"
- "movq %0, %%mm3 \n\t"
- PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
- OP_AVG(%%mm3, %%mm2, %%mm0, %%mm6)
- "movq %%mm0, %0 \n\t"
- "movq 8%1, %%mm0 \n\t"
- "movq 8%2, %%mm1 \n\t"
- "movq 8%0, %%mm3 \n\t"
- PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
- OP_AVG(%%mm3, %%mm2, %%mm0, %%mm6)
- "movq %%mm0, 8%0 \n\t"
- :"+m"(*dst)
- :"m"(*src1), "m"(*src2)
- :"memory");
- dst += dstStride;
- src1 += src1Stride;
- src2 += 16;
- } while (--h);
-}
-
-static void DEF(avg, pixels8_y2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
- MOVQ_BFE(mm6);
- __asm__ volatile(
- "lea (%3, %3), %%"REG_a" \n\t"
- "movq (%1), %%mm0 \n\t"
- ".p2align 3 \n\t"
- "1: \n\t"
- "movq (%1, %3), %%mm1 \n\t"
- "movq (%1, %%"REG_a"), %%mm2 \n\t"
- PAVGBP(%%mm1, %%mm0, %%mm4, %%mm2, %%mm1, %%mm5)
- "movq (%2), %%mm3 \n\t"
- OP_AVG(%%mm3, %%mm4, %%mm0, %%mm6)
- "movq (%2, %3), %%mm3 \n\t"
- OP_AVG(%%mm3, %%mm5, %%mm1, %%mm6)
- "movq %%mm0, (%2) \n\t"
- "movq %%mm1, (%2, %3) \n\t"
- "add %%"REG_a", %1 \n\t"
- "add %%"REG_a", %2 \n\t"
-
- "movq (%1, %3), %%mm1 \n\t"
- "movq (%1, %%"REG_a"), %%mm0 \n\t"
- PAVGBP(%%mm1, %%mm2, %%mm4, %%mm0, %%mm1, %%mm5)
- "movq (%2), %%mm3 \n\t"
- OP_AVG(%%mm3, %%mm4, %%mm2, %%mm6)
- "movq (%2, %3), %%mm3 \n\t"
- OP_AVG(%%mm3, %%mm5, %%mm1, %%mm6)
- "movq %%mm2, (%2) \n\t"
- "movq %%mm1, (%2, %3) \n\t"
- "add %%"REG_a", %1 \n\t"
- "add %%"REG_a", %2 \n\t"
-
- "subl $4, %0 \n\t"
- "jnz 1b \n\t"
- :"+g"(h), "+S"(pixels), "+D"(block)
- :"r"((x86_reg)line_size)
- :REG_a, "memory");
-}
-
-// this routine is 'slightly' suboptimal but mostly unused
-static void DEF(avg, pixels8_xy2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
- MOVQ_ZERO(mm7);
- SET_RND(mm6); // =2 for rnd and =1 for no_rnd version
- __asm__ volatile(
- "movq (%1), %%mm0 \n\t"
- "movq 1(%1), %%mm4 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "movq %%mm4, %%mm5 \n\t"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "punpcklbw %%mm7, %%mm4 \n\t"
- "punpckhbw %%mm7, %%mm1 \n\t"
- "punpckhbw %%mm7, %%mm5 \n\t"
- "paddusw %%mm0, %%mm4 \n\t"
- "paddusw %%mm1, %%mm5 \n\t"
- "xor %%"REG_a", %%"REG_a" \n\t"
- "add %3, %1 \n\t"
- ".p2align 3 \n\t"
- "1: \n\t"
- "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"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
- "punpckhbw %%mm7, %%mm1 \n\t"
- "punpckhbw %%mm7, %%mm3 \n\t"
- "paddusw %%mm2, %%mm0 \n\t"
- "paddusw %%mm3, %%mm1 \n\t"
- "paddusw %%mm6, %%mm4 \n\t"
- "paddusw %%mm6, %%mm5 \n\t"
- "paddusw %%mm0, %%mm4 \n\t"
- "paddusw %%mm1, %%mm5 \n\t"
- "psrlw $2, %%mm4 \n\t"
- "psrlw $2, %%mm5 \n\t"
- "movq (%2, %%"REG_a"), %%mm3 \n\t"
- "packuswb %%mm5, %%mm4 \n\t"
- "pcmpeqd %%mm2, %%mm2 \n\t"
- "paddb %%mm2, %%mm2 \n\t"
- OP_AVG(%%mm3, %%mm4, %%mm5, %%mm2)
- "movq %%mm5, (%2, %%"REG_a") \n\t"
- "add %3, %%"REG_a" \n\t"
-
- "movq (%1, %%"REG_a"), %%mm2 \n\t" // 0 <-> 2 1 <-> 3
- "movq 1(%1, %%"REG_a"), %%mm4 \n\t"
- "movq %%mm2, %%mm3 \n\t"
- "movq %%mm4, %%mm5 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
- "punpcklbw %%mm7, %%mm4 \n\t"
- "punpckhbw %%mm7, %%mm3 \n\t"
- "punpckhbw %%mm7, %%mm5 \n\t"
- "paddusw %%mm2, %%mm4 \n\t"
- "paddusw %%mm3, %%mm5 \n\t"
- "paddusw %%mm6, %%mm0 \n\t"
- "paddusw %%mm6, %%mm1 \n\t"
- "paddusw %%mm4, %%mm0 \n\t"
- "paddusw %%mm5, %%mm1 \n\t"
- "psrlw $2, %%mm0 \n\t"
- "psrlw $2, %%mm1 \n\t"
- "movq (%2, %%"REG_a"), %%mm3 \n\t"
- "packuswb %%mm1, %%mm0 \n\t"
- "pcmpeqd %%mm2, %%mm2 \n\t"
- "paddb %%mm2, %%mm2 \n\t"
- OP_AVG(%%mm3, %%mm0, %%mm1, %%mm2)
- "movq %%mm1, (%2, %%"REG_a") \n\t"
- "add %3, %%"REG_a" \n\t"
-
- "subl $2, %0 \n\t"
- "jnz 1b \n\t"
- :"+g"(h), "+S"(pixels)
- :"D"(block), "r"((x86_reg)line_size)
- :REG_a, "memory");
-}
-
-//FIXME optimize
-static void DEF(put, pixels16_y2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){
- DEF(put, pixels8_y2)(block , pixels , line_size, h);
- DEF(put, pixels8_y2)(block+8, pixels+8, line_size, h);
-}
-
-static void DEF(put, pixels16_xy2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){
- DEF(put, pixels8_xy2)(block , pixels , line_size, h);
- DEF(put, pixels8_xy2)(block+8, pixels+8, line_size, h);
-}
-
-static void DEF(avg, pixels16_y2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){
- DEF(avg, pixels8_y2)(block , pixels , line_size, h);
- DEF(avg, pixels8_y2)(block+8, pixels+8, line_size, h);
-}
-
-static void DEF(avg, pixels16_xy2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){
- DEF(avg, pixels8_xy2)(block , pixels , line_size, h);
- DEF(avg, pixels8_xy2)(block+8, pixels+8, line_size, h);
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/fdct.c b/src/thirdparty/ffmpeg/libavcodec/x86/fdct.c
deleted file mode 100644
index d35245dbb..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/fdct.c
+++ /dev/null
@@ -1,586 +0,0 @@
-/*
- * MMX 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.
- *
- * from fdctam32.c - AP922 MMX(3D-Now) forward-DCT
- *
- * Intel Application Note AP-922 - fast, precise implementation of DCT
- * http://developer.intel.com/vtune/cbts/appnotes.htm
- *
- * Also of inspiration:
- * a page about fdct at http://www.geocities.com/ssavekar/dct.htm
- * Skal's fdct at http://skal.planet-d.net/coding/dct.html
- *
- * 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 "libavutil/x86/asm.h"
-#include "libavcodec/dct.h"
-
-#if HAVE_INLINE_ASM
-
-//////////////////////////////////////////////////////////////////////
-//
-// constants for the forward DCT
-// -----------------------------
-//
-// Be sure to check that your compiler is aligning all constants to QWORD
-// (8-byte) memory boundaries! Otherwise the unaligned memory access will
-// severely stall MMX execution.
-//
-//////////////////////////////////////////////////////////////////////
-
-#define BITS_FRW_ACC 3 //; 2 or 3 for accuracy
-#define SHIFT_FRW_COL BITS_FRW_ACC
-#define SHIFT_FRW_ROW (BITS_FRW_ACC + 17 - 3)
-#define RND_FRW_ROW (1 << (SHIFT_FRW_ROW-1))
-//#define RND_FRW_COL (1 << (SHIFT_FRW_COL-1))
-
-#define X8(x) x,x,x,x,x,x,x,x
-
-//concatenated table, for forward DCT transformation
-DECLARE_ALIGNED(16, static const int16_t, fdct_tg_all_16)[24] = {
- X8(13036), // tg * (2<<16) + 0.5
- X8(27146), // tg * (2<<16) + 0.5
- X8(-21746) // tg * (2<<16) + 0.5
-};
-
-DECLARE_ALIGNED(16, static const int16_t, ocos_4_16)[8] = {
- X8(23170) //cos * (2<<15) + 0.5
-};
-
-DECLARE_ALIGNED(16, static const int16_t, fdct_one_corr)[8] = { X8(1) };
-
-DECLARE_ALIGNED(8, static const int32_t, fdct_r_row)[2] = {RND_FRW_ROW, RND_FRW_ROW };
-
-static const struct
-{
- DECLARE_ALIGNED(16, const int32_t, fdct_r_row_sse2)[4];
-} fdct_r_row_sse2 =
-{{
- RND_FRW_ROW, RND_FRW_ROW, RND_FRW_ROW, RND_FRW_ROW
-}};
-//DECLARE_ALIGNED(16, static const long, fdct_r_row_sse2)[4] = {RND_FRW_ROW, RND_FRW_ROW, RND_FRW_ROW, RND_FRW_ROW};
-
-DECLARE_ALIGNED(8, static const int16_t, tab_frw_01234567)[] = { // forward_dct coeff table
- 16384, 16384, 22725, 19266,
- 16384, 16384, 12873, 4520,
- 21407, 8867, 19266, -4520,
- -8867, -21407, -22725, -12873,
- 16384, -16384, 12873, -22725,
- -16384, 16384, 4520, 19266,
- 8867, -21407, 4520, -12873,
- 21407, -8867, 19266, -22725,
-
- 22725, 22725, 31521, 26722,
- 22725, 22725, 17855, 6270,
- 29692, 12299, 26722, -6270,
- -12299, -29692, -31521, -17855,
- 22725, -22725, 17855, -31521,
- -22725, 22725, 6270, 26722,
- 12299, -29692, 6270, -17855,
- 29692, -12299, 26722, -31521,
-
- 21407, 21407, 29692, 25172,
- 21407, 21407, 16819, 5906,
- 27969, 11585, 25172, -5906,
- -11585, -27969, -29692, -16819,
- 21407, -21407, 16819, -29692,
- -21407, 21407, 5906, 25172,
- 11585, -27969, 5906, -16819,
- 27969, -11585, 25172, -29692,
-
- 19266, 19266, 26722, 22654,
- 19266, 19266, 15137, 5315,
- 25172, 10426, 22654, -5315,
- -10426, -25172, -26722, -15137,
- 19266, -19266, 15137, -26722,
- -19266, 19266, 5315, 22654,
- 10426, -25172, 5315, -15137,
- 25172, -10426, 22654, -26722,
-
- 16384, 16384, 22725, 19266,
- 16384, 16384, 12873, 4520,
- 21407, 8867, 19266, -4520,
- -8867, -21407, -22725, -12873,
- 16384, -16384, 12873, -22725,
- -16384, 16384, 4520, 19266,
- 8867, -21407, 4520, -12873,
- 21407, -8867, 19266, -22725,
-
- 19266, 19266, 26722, 22654,
- 19266, 19266, 15137, 5315,
- 25172, 10426, 22654, -5315,
- -10426, -25172, -26722, -15137,
- 19266, -19266, 15137, -26722,
- -19266, 19266, 5315, 22654,
- 10426, -25172, 5315, -15137,
- 25172, -10426, 22654, -26722,
-
- 21407, 21407, 29692, 25172,
- 21407, 21407, 16819, 5906,
- 27969, 11585, 25172, -5906,
- -11585, -27969, -29692, -16819,
- 21407, -21407, 16819, -29692,
- -21407, 21407, 5906, 25172,
- 11585, -27969, 5906, -16819,
- 27969, -11585, 25172, -29692,
-
- 22725, 22725, 31521, 26722,
- 22725, 22725, 17855, 6270,
- 29692, 12299, 26722, -6270,
- -12299, -29692, -31521, -17855,
- 22725, -22725, 17855, -31521,
- -22725, 22725, 6270, 26722,
- 12299, -29692, 6270, -17855,
- 29692, -12299, 26722, -31521,
-};
-
-static const struct
-{
- DECLARE_ALIGNED(16, const int16_t, tab_frw_01234567_sse2)[256];
-} tab_frw_01234567_sse2 =
-{{
-//DECLARE_ALIGNED(16, static const int16_t, tab_frw_01234567_sse2)[] = { // forward_dct coeff table
-#define TABLE_SSE2 C4, C4, C1, C3, -C6, -C2, -C1, -C5, \
- C4, C4, C5, C7, C2, C6, C3, -C7, \
- -C4, C4, C7, C3, C6, -C2, C7, -C5, \
- C4, -C4, C5, -C1, C2, -C6, C3, -C1,
-// c1..c7 * cos(pi/4) * 2^15
-#define C1 22725
-#define C2 21407
-#define C3 19266
-#define C4 16384
-#define C5 12873
-#define C6 8867
-#define C7 4520
-TABLE_SSE2
-
-#undef C1
-#undef C2
-#undef C3
-#undef C4
-#undef C5
-#undef C6
-#undef C7
-#define C1 31521
-#define C2 29692
-#define C3 26722
-#define C4 22725
-#define C5 17855
-#define C6 12299
-#define C7 6270
-TABLE_SSE2
-
-#undef C1
-#undef C2
-#undef C3
-#undef C4
-#undef C5
-#undef C6
-#undef C7
-#define C1 29692
-#define C2 27969
-#define C3 25172
-#define C4 21407
-#define C5 16819
-#define C6 11585
-#define C7 5906
-TABLE_SSE2
-
-#undef C1
-#undef C2
-#undef C3
-#undef C4
-#undef C5
-#undef C6
-#undef C7
-#define C1 26722
-#define C2 25172
-#define C3 22654
-#define C4 19266
-#define C5 15137
-#define C6 10426
-#define C7 5315
-TABLE_SSE2
-
-#undef C1
-#undef C2
-#undef C3
-#undef C4
-#undef C5
-#undef C6
-#undef C7
-#define C1 22725
-#define C2 21407
-#define C3 19266
-#define C4 16384
-#define C5 12873
-#define C6 8867
-#define C7 4520
-TABLE_SSE2
-
-#undef C1
-#undef C2
-#undef C3
-#undef C4
-#undef C5
-#undef C6
-#undef C7
-#define C1 26722
-#define C2 25172
-#define C3 22654
-#define C4 19266
-#define C5 15137
-#define C6 10426
-#define C7 5315
-TABLE_SSE2
-
-#undef C1
-#undef C2
-#undef C3
-#undef C4
-#undef C5
-#undef C6
-#undef C7
-#define C1 29692
-#define C2 27969
-#define C3 25172
-#define C4 21407
-#define C5 16819
-#define C6 11585
-#define C7 5906
-TABLE_SSE2
-
-#undef C1
-#undef C2
-#undef C3
-#undef C4
-#undef C5
-#undef C6
-#undef C7
-#define C1 31521
-#define C2 29692
-#define C3 26722
-#define C4 22725
-#define C5 17855
-#define C6 12299
-#define C7 6270
-TABLE_SSE2
-}};
-
-#define S(s) AV_TOSTRING(s) //AV_STRINGIFY is too long
-
-#define FDCT_COL(cpu, mm, mov)\
-static av_always_inline void fdct_col_##cpu(const int16_t *in, int16_t *out, int offset)\
-{\
- __asm__ volatile (\
- #mov" 16(%0), %%"#mm"0 \n\t" \
- #mov" 96(%0), %%"#mm"1 \n\t" \
- #mov" %%"#mm"0, %%"#mm"2 \n\t" \
- #mov" 32(%0), %%"#mm"3 \n\t" \
- "paddsw %%"#mm"1, %%"#mm"0 \n\t" \
- #mov" 80(%0), %%"#mm"4 \n\t" \
- "psllw $"S(SHIFT_FRW_COL)", %%"#mm"0 \n\t" \
- #mov" (%0), %%"#mm"5 \n\t" \
- "paddsw %%"#mm"3, %%"#mm"4 \n\t" \
- "paddsw 112(%0), %%"#mm"5 \n\t" \
- "psllw $"S(SHIFT_FRW_COL)", %%"#mm"4 \n\t" \
- #mov" %%"#mm"0, %%"#mm"6 \n\t" \
- "psubsw %%"#mm"1, %%"#mm"2 \n\t" \
- #mov" 16(%1), %%"#mm"1 \n\t" \
- "psubsw %%"#mm"4, %%"#mm"0 \n\t" \
- #mov" 48(%0), %%"#mm"7 \n\t" \
- "pmulhw %%"#mm"0, %%"#mm"1 \n\t" \
- "paddsw 64(%0), %%"#mm"7 \n\t" \
- "psllw $"S(SHIFT_FRW_COL)", %%"#mm"5 \n\t" \
- "paddsw %%"#mm"4, %%"#mm"6 \n\t" \
- "psllw $"S(SHIFT_FRW_COL)", %%"#mm"7 \n\t" \
- #mov" %%"#mm"5, %%"#mm"4 \n\t" \
- "psubsw %%"#mm"7, %%"#mm"5 \n\t" \
- "paddsw %%"#mm"5, %%"#mm"1 \n\t" \
- "paddsw %%"#mm"7, %%"#mm"4 \n\t" \
- "por (%2), %%"#mm"1 \n\t" \
- "psllw $"S(SHIFT_FRW_COL)"+1, %%"#mm"2 \n\t" \
- "pmulhw 16(%1), %%"#mm"5 \n\t" \
- #mov" %%"#mm"4, %%"#mm"7 \n\t" \
- "psubsw 80(%0), %%"#mm"3 \n\t" \
- "psubsw %%"#mm"6, %%"#mm"4 \n\t" \
- #mov" %%"#mm"1, 32(%3) \n\t" \
- "paddsw %%"#mm"6, %%"#mm"7 \n\t" \
- #mov" 48(%0), %%"#mm"1 \n\t" \
- "psllw $"S(SHIFT_FRW_COL)"+1, %%"#mm"3 \n\t" \
- "psubsw 64(%0), %%"#mm"1 \n\t" \
- #mov" %%"#mm"2, %%"#mm"6 \n\t" \
- #mov" %%"#mm"4, 64(%3) \n\t" \
- "paddsw %%"#mm"3, %%"#mm"2 \n\t" \
- "pmulhw (%4), %%"#mm"2 \n\t" \
- "psubsw %%"#mm"3, %%"#mm"6 \n\t" \
- "pmulhw (%4), %%"#mm"6 \n\t" \
- "psubsw %%"#mm"0, %%"#mm"5 \n\t" \
- "por (%2), %%"#mm"5 \n\t" \
- "psllw $"S(SHIFT_FRW_COL)", %%"#mm"1 \n\t" \
- "por (%2), %%"#mm"2 \n\t" \
- #mov" %%"#mm"1, %%"#mm"4 \n\t" \
- #mov" (%0), %%"#mm"3 \n\t" \
- "paddsw %%"#mm"6, %%"#mm"1 \n\t" \
- "psubsw 112(%0), %%"#mm"3 \n\t" \
- "psubsw %%"#mm"6, %%"#mm"4 \n\t" \
- #mov" (%1), %%"#mm"0 \n\t" \
- "psllw $"S(SHIFT_FRW_COL)", %%"#mm"3 \n\t" \
- #mov" 32(%1), %%"#mm"6 \n\t" \
- "pmulhw %%"#mm"1, %%"#mm"0 \n\t" \
- #mov" %%"#mm"7, (%3) \n\t" \
- "pmulhw %%"#mm"4, %%"#mm"6 \n\t" \
- #mov" %%"#mm"5, 96(%3) \n\t" \
- #mov" %%"#mm"3, %%"#mm"7 \n\t" \
- #mov" 32(%1), %%"#mm"5 \n\t" \
- "psubsw %%"#mm"2, %%"#mm"7 \n\t" \
- "paddsw %%"#mm"2, %%"#mm"3 \n\t" \
- "pmulhw %%"#mm"7, %%"#mm"5 \n\t" \
- "paddsw %%"#mm"3, %%"#mm"0 \n\t" \
- "paddsw %%"#mm"4, %%"#mm"6 \n\t" \
- "pmulhw (%1), %%"#mm"3 \n\t" \
- "por (%2), %%"#mm"0 \n\t" \
- "paddsw %%"#mm"7, %%"#mm"5 \n\t" \
- "psubsw %%"#mm"6, %%"#mm"7 \n\t" \
- #mov" %%"#mm"0, 16(%3) \n\t" \
- "paddsw %%"#mm"4, %%"#mm"5 \n\t" \
- #mov" %%"#mm"7, 48(%3) \n\t" \
- "psubsw %%"#mm"1, %%"#mm"3 \n\t" \
- #mov" %%"#mm"5, 80(%3) \n\t" \
- #mov" %%"#mm"3, 112(%3) \n\t" \
- : \
- : "r" (in + offset), "r" (fdct_tg_all_16), "r" (fdct_one_corr), \
- "r" (out + offset), "r" (ocos_4_16)); \
-}
-
-FDCT_COL(mmx, mm, movq)
-FDCT_COL(sse2, xmm, movdqa)
-
-static av_always_inline void fdct_row_sse2(const int16_t *in, int16_t *out)
-{
- __asm__ volatile(
-#define FDCT_ROW_SSE2_H1(i,t) \
- "movq " #i "(%0), %%xmm2 \n\t" \
- "movq " #i "+8(%0), %%xmm0 \n\t" \
- "movdqa " #t "+32(%1), %%xmm3 \n\t" \
- "movdqa " #t "+48(%1), %%xmm7 \n\t" \
- "movdqa " #t "(%1), %%xmm4 \n\t" \
- "movdqa " #t "+16(%1), %%xmm5 \n\t"
-
-#define FDCT_ROW_SSE2_H2(i,t) \
- "movq " #i "(%0), %%xmm2 \n\t" \
- "movq " #i "+8(%0), %%xmm0 \n\t" \
- "movdqa " #t "+32(%1), %%xmm3 \n\t" \
- "movdqa " #t "+48(%1), %%xmm7 \n\t"
-
-#define FDCT_ROW_SSE2(i) \
- "movq %%xmm2, %%xmm1 \n\t" \
- "pshuflw $27, %%xmm0, %%xmm0 \n\t" \
- "paddsw %%xmm0, %%xmm1 \n\t" \
- "psubsw %%xmm0, %%xmm2 \n\t" \
- "punpckldq %%xmm2, %%xmm1 \n\t" \
- "pshufd $78, %%xmm1, %%xmm2 \n\t" \
- "pmaddwd %%xmm2, %%xmm3 \n\t" \
- "pmaddwd %%xmm1, %%xmm7 \n\t" \
- "pmaddwd %%xmm5, %%xmm2 \n\t" \
- "pmaddwd %%xmm4, %%xmm1 \n\t" \
- "paddd %%xmm7, %%xmm3 \n\t" \
- "paddd %%xmm2, %%xmm1 \n\t" \
- "paddd %%xmm6, %%xmm3 \n\t" \
- "paddd %%xmm6, %%xmm1 \n\t" \
- "psrad %3, %%xmm3 \n\t" \
- "psrad %3, %%xmm1 \n\t" \
- "packssdw %%xmm3, %%xmm1 \n\t" \
- "movdqa %%xmm1, " #i "(%4) \n\t"
-
- "movdqa (%2), %%xmm6 \n\t"
- FDCT_ROW_SSE2_H1(0,0)
- FDCT_ROW_SSE2(0)
- FDCT_ROW_SSE2_H2(64,0)
- FDCT_ROW_SSE2(64)
-
- FDCT_ROW_SSE2_H1(16,64)
- FDCT_ROW_SSE2(16)
- FDCT_ROW_SSE2_H2(112,64)
- FDCT_ROW_SSE2(112)
-
- FDCT_ROW_SSE2_H1(32,128)
- FDCT_ROW_SSE2(32)
- FDCT_ROW_SSE2_H2(96,128)
- FDCT_ROW_SSE2(96)
-
- FDCT_ROW_SSE2_H1(48,192)
- FDCT_ROW_SSE2(48)
- FDCT_ROW_SSE2_H2(80,192)
- FDCT_ROW_SSE2(80)
- :
- : "r" (in), "r" (tab_frw_01234567_sse2.tab_frw_01234567_sse2),
- "r" (fdct_r_row_sse2.fdct_r_row_sse2), "i" (SHIFT_FRW_ROW), "r" (out)
- XMM_CLOBBERS_ONLY("%xmm0", "%xmm1", "%xmm2", "%xmm3",
- "%xmm4", "%xmm5", "%xmm6", "%xmm7")
- );
-}
-
-static av_always_inline void fdct_row_mmxext(const int16_t *in, int16_t *out,
- const int16_t *table)
-{
- __asm__ volatile (
- "pshufw $0x1B, 8(%0), %%mm5 \n\t"
- "movq (%0), %%mm0 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "paddsw %%mm5, %%mm0 \n\t"
- "psubsw %%mm5, %%mm1 \n\t"
- "movq %%mm0, %%mm2 \n\t"
- "punpckldq %%mm1, %%mm0 \n\t"
- "punpckhdq %%mm1, %%mm2 \n\t"
- "movq (%1), %%mm1 \n\t"
- "movq 8(%1), %%mm3 \n\t"
- "movq 16(%1), %%mm4 \n\t"
- "movq 24(%1), %%mm5 \n\t"
- "movq 32(%1), %%mm6 \n\t"
- "movq 40(%1), %%mm7 \n\t"
- "pmaddwd %%mm0, %%mm1 \n\t"
- "pmaddwd %%mm2, %%mm3 \n\t"
- "pmaddwd %%mm0, %%mm4 \n\t"
- "pmaddwd %%mm2, %%mm5 \n\t"
- "pmaddwd %%mm0, %%mm6 \n\t"
- "pmaddwd %%mm2, %%mm7 \n\t"
- "pmaddwd 48(%1), %%mm0 \n\t"
- "pmaddwd 56(%1), %%mm2 \n\t"
- "paddd %%mm1, %%mm3 \n\t"
- "paddd %%mm4, %%mm5 \n\t"
- "paddd %%mm6, %%mm7 \n\t"
- "paddd %%mm0, %%mm2 \n\t"
- "movq (%2), %%mm0 \n\t"
- "paddd %%mm0, %%mm3 \n\t"
- "paddd %%mm0, %%mm5 \n\t"
- "paddd %%mm0, %%mm7 \n\t"
- "paddd %%mm0, %%mm2 \n\t"
- "psrad $"S(SHIFT_FRW_ROW)", %%mm3 \n\t"
- "psrad $"S(SHIFT_FRW_ROW)", %%mm5 \n\t"
- "psrad $"S(SHIFT_FRW_ROW)", %%mm7 \n\t"
- "psrad $"S(SHIFT_FRW_ROW)", %%mm2 \n\t"
- "packssdw %%mm5, %%mm3 \n\t"
- "packssdw %%mm2, %%mm7 \n\t"
- "movq %%mm3, (%3) \n\t"
- "movq %%mm7, 8(%3) \n\t"
- :
- : "r" (in), "r" (table), "r" (fdct_r_row), "r" (out));
-}
-
-static av_always_inline void fdct_row_mmx(const int16_t *in, int16_t *out, const int16_t *table)
-{
- //FIXME reorder (I do not have an old MMX-only CPU here to benchmark ...)
- __asm__ volatile(
- "movd 12(%0), %%mm1 \n\t"
- "punpcklwd 8(%0), %%mm1 \n\t"
- "movq %%mm1, %%mm2 \n\t"
- "psrlq $0x20, %%mm1 \n\t"
- "movq 0(%0), %%mm0 \n\t"
- "punpcklwd %%mm2, %%mm1 \n\t"
- "movq %%mm0, %%mm5 \n\t"
- "paddsw %%mm1, %%mm0 \n\t"
- "psubsw %%mm1, %%mm5 \n\t"
- "movq %%mm0, %%mm2 \n\t"
- "punpckldq %%mm5, %%mm0 \n\t"
- "punpckhdq %%mm5, %%mm2 \n\t"
- "movq 0(%1), %%mm1 \n\t"
- "movq 8(%1), %%mm3 \n\t"
- "movq 16(%1), %%mm4 \n\t"
- "movq 24(%1), %%mm5 \n\t"
- "movq 32(%1), %%mm6 \n\t"
- "movq 40(%1), %%mm7 \n\t"
- "pmaddwd %%mm0, %%mm1 \n\t"
- "pmaddwd %%mm2, %%mm3 \n\t"
- "pmaddwd %%mm0, %%mm4 \n\t"
- "pmaddwd %%mm2, %%mm5 \n\t"
- "pmaddwd %%mm0, %%mm6 \n\t"
- "pmaddwd %%mm2, %%mm7 \n\t"
- "pmaddwd 48(%1), %%mm0 \n\t"
- "pmaddwd 56(%1), %%mm2 \n\t"
- "paddd %%mm1, %%mm3 \n\t"
- "paddd %%mm4, %%mm5 \n\t"
- "paddd %%mm6, %%mm7 \n\t"
- "paddd %%mm0, %%mm2 \n\t"
- "movq (%2), %%mm0 \n\t"
- "paddd %%mm0, %%mm3 \n\t"
- "paddd %%mm0, %%mm5 \n\t"
- "paddd %%mm0, %%mm7 \n\t"
- "paddd %%mm0, %%mm2 \n\t"
- "psrad $"S(SHIFT_FRW_ROW)", %%mm3 \n\t"
- "psrad $"S(SHIFT_FRW_ROW)", %%mm5 \n\t"
- "psrad $"S(SHIFT_FRW_ROW)", %%mm7 \n\t"
- "psrad $"S(SHIFT_FRW_ROW)", %%mm2 \n\t"
- "packssdw %%mm5, %%mm3 \n\t"
- "packssdw %%mm2, %%mm7 \n\t"
- "movq %%mm3, 0(%3) \n\t"
- "movq %%mm7, 8(%3) \n\t"
- :
- : "r" (in), "r" (table), "r" (fdct_r_row), "r" (out));
-}
-
-void ff_fdct_mmx(int16_t *block)
-{
- DECLARE_ALIGNED(8, int64_t, align_tmp)[16];
- int16_t * block1= (int16_t*)align_tmp;
- const int16_t *table= tab_frw_01234567;
- int i;
-
- fdct_col_mmx(block, block1, 0);
- fdct_col_mmx(block, block1, 4);
-
- for(i=8;i>0;i--) {
- fdct_row_mmx(block1, block, table);
- block1 += 8;
- table += 32;
- block += 8;
- }
-}
-
-void ff_fdct_mmxext(int16_t *block)
-{
- DECLARE_ALIGNED(8, int64_t, align_tmp)[16];
- int16_t *block1= (int16_t*)align_tmp;
- const int16_t *table= tab_frw_01234567;
- int i;
-
- fdct_col_mmx(block, block1, 0);
- fdct_col_mmx(block, block1, 4);
-
- for(i=8;i>0;i--) {
- fdct_row_mmxext(block1, block, table);
- block1 += 8;
- table += 32;
- block += 8;
- }
-}
-
-void ff_fdct_sse2(int16_t *block)
-{
- DECLARE_ALIGNED(16, int64_t, align_tmp)[16];
- int16_t * const block1= (int16_t*)align_tmp;
-
- fdct_col_sse2(block, block1, 0);
- fdct_row_sse2(block1, block);
-}
-
-#endif /* HAVE_INLINE_ASM */
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/fft.asm b/src/thirdparty/ffmpeg/libavcodec/x86/fft.asm
deleted file mode 100644
index 5071741d6..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/fft.asm
+++ /dev/null
@@ -1,1093 +0,0 @@
-;******************************************************************************
-;* FFT transform with SSE/3DNow optimizations
-;* Copyright (c) 2008 Loren Merritt
-;* Copyright (c) 2011 Vitor Sessak
-;*
-;* 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
-;******************************************************************************
-
-; These functions are not individually interchangeable with the C versions.
-; While C takes arrays of FFTComplex, SSE/3DNow leave intermediate results
-; in blocks as conventient to the vector size.
-; i.e. {4x real, 4x imaginary, 4x real, ...} (or 2x respectively)
-
-%include "libavutil/x86/x86util.asm"
-
-%if ARCH_X86_64
-%define pointer resq
-%else
-%define pointer resd
-%endif
-
-SECTION_RODATA
-
-struc FFTContext
- .nbits: resd 1
- .reverse: resd 1
- .revtab: pointer 1
- .tmpbuf: pointer 1
- .mdctsize: resd 1
- .mdctbits: resd 1
- .tcos: pointer 1
- .tsin: pointer 1
- .fftperm: pointer 1
- .fftcalc: pointer 1
- .imdctcalc:pointer 1
- .imdcthalf:pointer 1
-endstruc
-
-%define M_SQRT1_2 0.70710678118654752440
-%define M_COS_PI_1_8 0.923879532511287
-%define M_COS_PI_3_8 0.38268343236509
-
-align 32
-ps_cos16_1: dd 1.0, M_COS_PI_1_8, M_SQRT1_2, M_COS_PI_3_8, 1.0, M_COS_PI_1_8, M_SQRT1_2, M_COS_PI_3_8
-ps_cos16_2: dd 0, M_COS_PI_3_8, M_SQRT1_2, M_COS_PI_1_8, 0, -M_COS_PI_3_8, -M_SQRT1_2, -M_COS_PI_1_8
-
-ps_root2: times 8 dd M_SQRT1_2
-ps_root2mppm: dd -M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, -M_SQRT1_2, -M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, -M_SQRT1_2
-ps_p1p1m1p1: dd 0, 0, 1<<31, 0, 0, 0, 1<<31, 0
-
-perm1: dd 0x00, 0x02, 0x03, 0x01, 0x03, 0x00, 0x02, 0x01
-perm2: dd 0x00, 0x01, 0x02, 0x03, 0x01, 0x00, 0x02, 0x03
-ps_p1p1m1p1root2: dd 1.0, 1.0, -1.0, 1.0, M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, M_SQRT1_2
-ps_m1m1p1m1p1m1m1m1: dd 1<<31, 1<<31, 0, 1<<31, 0, 1<<31, 1<<31, 1<<31
-ps_m1m1m1m1: times 4 dd 1<<31
-ps_m1p1: dd 1<<31, 0
-
-%assign i 16
-%rep 13
-cextern cos_ %+ i
-%assign i i<<1
-%endrep
-
-%if ARCH_X86_64
- %define pointer dq
-%else
- %define pointer dd
-%endif
-
-%macro IF0 1+
-%endmacro
-%macro IF1 1+
- %1
-%endmacro
-
-SECTION_TEXT
-
-%macro T2_3DNOW 4 ; z0, z1, mem0, mem1
- mova %1, %3
- mova %2, %1
- pfadd %1, %4
- pfsub %2, %4
-%endmacro
-
-%macro T4_3DNOW 6 ; z0, z1, z2, z3, tmp0, tmp1
- mova %5, %3
- pfsub %3, %4
- pfadd %5, %4 ; {t6,t5}
- pxor %3, [ps_m1p1] ; {t8,t7}
- mova %6, %1
- movd [r0+12], %3
- punpckhdq %3, [r0+8]
- pfadd %1, %5 ; {r0,i0}
- pfsub %6, %5 ; {r2,i2}
- mova %4, %2
- pfadd %2, %3 ; {r1,i1}
- pfsub %4, %3 ; {r3,i3}
- SWAP %3, %6
-%endmacro
-
-; in: %1 = {r0,i0,r2,i2,r4,i4,r6,i6}
-; %2 = {r1,i1,r3,i3,r5,i5,r7,i7}
-; %3, %4, %5 tmp
-; out: %1 = {r0,r1,r2,r3,i0,i1,i2,i3}
-; %2 = {r4,r5,r6,r7,i4,i5,i6,i7}
-%macro T8_AVX 5
- vsubps %5, %1, %2 ; v = %1 - %2
- vaddps %3, %1, %2 ; w = %1 + %2
- vmulps %2, %5, [ps_p1p1m1p1root2] ; v *= vals1
- vpermilps %2, %2, [perm1]
- vblendps %1, %2, %3, 0x33 ; q = {w1,w2,v4,v2,w5,w6,v7,v6}
- vshufps %5, %3, %2, 0x4e ; r = {w3,w4,v1,v3,w7,w8,v8,v5}
- vsubps %4, %5, %1 ; s = r - q
- vaddps %1, %5, %1 ; u = r + q
- vpermilps %1, %1, [perm2] ; k = {u1,u2,u3,u4,u6,u5,u7,u8}
- vshufps %5, %4, %1, 0xbb
- vshufps %3, %4, %1, 0xee
- vperm2f128 %3, %3, %5, 0x13
- vxorps %4, %4, [ps_m1m1p1m1p1m1m1m1] ; s *= {1,1,-1,-1,1,-1,-1,-1}
- vshufps %2, %1, %4, 0xdd
- vshufps %1, %1, %4, 0x88
- vperm2f128 %4, %2, %1, 0x02 ; v = {k1,k3,s1,s3,k2,k4,s2,s4}
- vperm2f128 %1, %1, %2, 0x13 ; w = {k6,k8,s6,s8,k5,k7,s5,s7}
- vsubps %5, %1, %3
- vblendps %1, %5, %1, 0x55 ; w -= {0,s7,0,k7,0,s8,0,k8}
- vsubps %2, %4, %1 ; %2 = v - w
- vaddps %1, %4, %1 ; %1 = v + w
-%endmacro
-
-; In SSE mode do one fft4 transforms
-; in: %1={r0,i0,r2,i2} %2={r1,i1,r3,i3}
-; out: %1={r0,r1,r2,r3} %2={i0,i1,i2,i3}
-;
-; In AVX mode do two fft4 transforms
-; in: %1={r0,i0,r2,i2,r4,i4,r6,i6} %2={r1,i1,r3,i3,r5,i5,r7,i7}
-; out: %1={r0,r1,r2,r3,r4,r5,r6,r7} %2={i0,i1,i2,i3,i4,i5,i6,i7}
-%macro T4_SSE 3
- subps %3, %1, %2 ; {t3,t4,-t8,t7}
- addps %1, %1, %2 ; {t1,t2,t6,t5}
- xorps %3, %3, [ps_p1p1m1p1]
- shufps %2, %1, %3, 0xbe ; {t6,t5,t7,t8}
- shufps %1, %1, %3, 0x44 ; {t1,t2,t3,t4}
- subps %3, %1, %2 ; {r2,i2,r3,i3}
- addps %1, %1, %2 ; {r0,i0,r1,i1}
- shufps %2, %1, %3, 0xdd ; {i0,i1,i2,i3}
- shufps %1, %1, %3, 0x88 ; {r0,r1,r2,r3}
-%endmacro
-
-; In SSE mode do one FFT8
-; in: %1={r0,r1,r2,r3} %2={i0,i1,i2,i3} %3={r4,i4,r6,i6} %4={r5,i5,r7,i7}
-; out: %1={r0,r1,r2,r3} %2={i0,i1,i2,i3} %1={r4,r5,r6,r7} %2={i4,i5,i6,i7}
-;
-; In AVX mode do two FFT8
-; in: %1={r0,i0,r2,i2,r8, i8, r10,i10} %2={r1,i1,r3,i3,r9, i9, r11,i11}
-; %3={r4,i4,r6,i6,r12,i12,r14,i14} %4={r5,i5,r7,i7,r13,i13,r15,i15}
-; out: %1={r0,r1,r2,r3,r8, r9, r10,r11} %2={i0,i1,i2,i3,i8, i9, i10,i11}
-; %3={r4,r5,r6,r7,r12,r13,r14,r15} %4={i4,i5,i6,i7,i12,i13,i14,i15}
-%macro T8_SSE 6
- addps %6, %3, %4 ; {t1,t2,t3,t4}
- subps %3, %3, %4 ; {r5,i5,r7,i7}
- shufps %4, %3, %3, 0xb1 ; {i5,r5,i7,r7}
- mulps %3, %3, [ps_root2mppm] ; {-r5,i5,r7,-i7}
- mulps %4, %4, [ps_root2]
- addps %3, %3, %4 ; {t8,t7,ta,t9}
- shufps %4, %6, %3, 0x9c ; {t1,t4,t7,ta}
- shufps %6, %6, %3, 0x36 ; {t3,t2,t9,t8}
- subps %3, %6, %4 ; {t6,t5,tc,tb}
- addps %6, %6, %4 ; {t1,t2,t9,ta}
- shufps %5, %6, %3, 0x8d ; {t2,ta,t6,tc}
- shufps %6, %6, %3, 0xd8 ; {t1,t9,t5,tb}
- subps %3, %1, %6 ; {r4,r5,r6,r7}
- addps %1, %1, %6 ; {r0,r1,r2,r3}
- subps %4, %2, %5 ; {i4,i5,i6,i7}
- addps %2, %2, %5 ; {i0,i1,i2,i3}
-%endmacro
-
-; scheduled for cpu-bound sizes
-%macro PASS_SMALL 3 ; (to load m4-m7), wre, wim
-IF%1 mova m4, Z(4)
-IF%1 mova m5, Z(5)
- mova m0, %2 ; wre
- mova m1, %3 ; wim
- mulps m2, m4, m0 ; r2*wre
-IF%1 mova m6, Z2(6)
- mulps m3, m5, m1 ; i2*wim
-IF%1 mova m7, Z2(7)
- mulps m4, m4, m1 ; r2*wim
- mulps m5, m5, m0 ; i2*wre
- addps m2, m2, m3 ; r2*wre + i2*wim
- mulps m3, m1, m7 ; i3*wim
- subps m5, m5, m4 ; i2*wre - r2*wim
- mulps m1, m1, m6 ; r3*wim
- mulps m4, m0, m6 ; r3*wre
- mulps m0, m0, m7 ; i3*wre
- subps m4, m4, m3 ; r3*wre - i3*wim
- mova m3, Z(0)
- addps m0, m0, m1 ; i3*wre + r3*wim
- subps m1, m4, m2 ; t3
- addps m4, m4, m2 ; t5
- subps m3, m3, m4 ; r2
- addps m4, m4, Z(0) ; r0
- mova m6, Z(2)
- mova Z(4), m3
- mova Z(0), m4
- subps m3, m5, m0 ; t4
- subps m4, m6, m3 ; r3
- addps m3, m3, m6 ; r1
- mova Z2(6), m4
- mova Z(2), m3
- mova m2, Z(3)
- addps m3, m5, m0 ; t6
- subps m2, m2, m1 ; i3
- mova m7, Z(1)
- addps m1, m1, Z(3) ; i1
- mova Z2(7), m2
- mova Z(3), m1
- subps m4, m7, m3 ; i2
- addps m3, m3, m7 ; i0
- mova Z(5), m4
- mova Z(1), m3
-%endmacro
-
-; scheduled to avoid store->load aliasing
-%macro PASS_BIG 1 ; (!interleave)
- mova m4, Z(4) ; r2
- mova m5, Z(5) ; i2
- mova m0, [wq] ; wre
- mova m1, [wq+o1q] ; wim
- mulps m2, m4, m0 ; r2*wre
- mova m6, Z2(6) ; r3
- mulps m3, m5, m1 ; i2*wim
- mova m7, Z2(7) ; i3
- mulps m4, m4, m1 ; r2*wim
- mulps m5, m5, m0 ; i2*wre
- addps m2, m2, m3 ; r2*wre + i2*wim
- mulps m3, m1, m7 ; i3*wim
- mulps m1, m1, m6 ; r3*wim
- subps m5, m5, m4 ; i2*wre - r2*wim
- mulps m4, m0, m6 ; r3*wre
- mulps m0, m0, m7 ; i3*wre
- subps m4, m4, m3 ; r3*wre - i3*wim
- mova m3, Z(0)
- addps m0, m0, m1 ; i3*wre + r3*wim
- subps m1, m4, m2 ; t3
- addps m4, m4, m2 ; t5
- subps m3, m3, m4 ; r2
- addps m4, m4, Z(0) ; r0
- mova m6, Z(2)
- mova Z(4), m3
- mova Z(0), m4
- subps m3, m5, m0 ; t4
- subps m4, m6, m3 ; r3
- addps m3, m3, m6 ; r1
-IF%1 mova Z2(6), m4
-IF%1 mova Z(2), m3
- mova m2, Z(3)
- addps m5, m5, m0 ; t6
- subps m2, m2, m1 ; i3
- mova m7, Z(1)
- addps m1, m1, Z(3) ; i1
-IF%1 mova Z2(7), m2
-IF%1 mova Z(3), m1
- subps m6, m7, m5 ; i2
- addps m5, m5, m7 ; i0
-IF%1 mova Z(5), m6
-IF%1 mova Z(1), m5
-%if %1==0
- INTERL m1, m3, m7, Z, 2
- INTERL m2, m4, m0, Z2, 6
-
- mova m1, Z(0)
- mova m2, Z(4)
-
- INTERL m5, m1, m3, Z, 0
- INTERL m6, m2, m7, Z, 4
-%endif
-%endmacro
-
-%macro PUNPCK 3
- mova %3, %1
- punpckldq %1, %2
- punpckhdq %3, %2
-%endmacro
-
-%define Z(x) [r0+mmsize*x]
-%define Z2(x) [r0+mmsize*x]
-%define ZH(x) [r0+mmsize*x+mmsize/2]
-
-INIT_YMM avx
-
-%if HAVE_AVX_EXTERNAL
-align 16
-fft8_avx:
- mova m0, Z(0)
- mova m1, Z(1)
- T8_AVX m0, m1, m2, m3, m4
- mova Z(0), m0
- mova Z(1), m1
- ret
-
-
-align 16
-fft16_avx:
- mova m2, Z(2)
- mova m3, Z(3)
- T4_SSE m2, m3, m7
-
- mova m0, Z(0)
- mova m1, Z(1)
- T8_AVX m0, m1, m4, m5, m7
-
- mova m4, [ps_cos16_1]
- mova m5, [ps_cos16_2]
- vmulps m6, m2, m4
- vmulps m7, m3, m5
- vaddps m7, m7, m6
- vmulps m2, m2, m5
- vmulps m3, m3, m4
- vsubps m3, m3, m2
- vblendps m2, m7, m3, 0xf0
- vperm2f128 m3, m7, m3, 0x21
- vaddps m4, m2, m3
- vsubps m2, m3, m2
- vperm2f128 m2, m2, m2, 0x01
- vsubps m3, m1, m2
- vaddps m1, m1, m2
- vsubps m5, m0, m4
- vaddps m0, m0, m4
- vextractf128 Z(0), m0, 0
- vextractf128 ZH(0), m1, 0
- vextractf128 Z(1), m0, 1
- vextractf128 ZH(1), m1, 1
- vextractf128 Z(2), m5, 0
- vextractf128 ZH(2), m3, 0
- vextractf128 Z(3), m5, 1
- vextractf128 ZH(3), m3, 1
- ret
-
-align 16
-fft32_avx:
- call fft16_avx
-
- mova m0, Z(4)
- mova m1, Z(5)
-
- T4_SSE m0, m1, m4
-
- mova m2, Z(6)
- mova m3, Z(7)
-
- T8_SSE m0, m1, m2, m3, m4, m6
- ; m0={r0,r1,r2,r3,r8, r9, r10,r11} m1={i0,i1,i2,i3,i8, i9, i10,i11}
- ; m2={r4,r5,r6,r7,r12,r13,r14,r15} m3={i4,i5,i6,i7,i12,i13,i14,i15}
-
- vperm2f128 m4, m0, m2, 0x20
- vperm2f128 m5, m1, m3, 0x20
- vperm2f128 m6, m0, m2, 0x31
- vperm2f128 m7, m1, m3, 0x31
-
- PASS_SMALL 0, [cos_32], [cos_32+32]
-
- ret
-
-fft32_interleave_avx:
- call fft32_avx
- mov r2d, 32
-.deint_loop:
- mova m2, Z(0)
- mova m3, Z(1)
- vunpcklps m0, m2, m3
- vunpckhps m1, m2, m3
- vextractf128 Z(0), m0, 0
- vextractf128 ZH(0), m1, 0
- vextractf128 Z(1), m0, 1
- vextractf128 ZH(1), m1, 1
- add r0, mmsize*2
- sub r2d, mmsize/4
- jg .deint_loop
- ret
-
-%endif
-
-INIT_XMM sse
-
-align 16
-fft4_avx:
-fft4_sse:
- mova m0, Z(0)
- mova m1, Z(1)
- T4_SSE m0, m1, m2
- mova Z(0), m0
- mova Z(1), m1
- ret
-
-align 16
-fft8_sse:
- mova m0, Z(0)
- mova m1, Z(1)
- T4_SSE m0, m1, m2
- mova m2, Z(2)
- mova m3, Z(3)
- T8_SSE m0, m1, m2, m3, m4, m5
- mova Z(0), m0
- mova Z(1), m1
- mova Z(2), m2
- mova Z(3), m3
- ret
-
-align 16
-fft16_sse:
- mova m0, Z(0)
- mova m1, Z(1)
- T4_SSE m0, m1, m2
- mova m2, Z(2)
- mova m3, Z(3)
- T8_SSE m0, m1, m2, m3, m4, m5
- mova m4, Z(4)
- mova m5, Z(5)
- mova Z(0), m0
- mova Z(1), m1
- mova Z(2), m2
- mova Z(3), m3
- T4_SSE m4, m5, m6
- mova m6, Z2(6)
- mova m7, Z2(7)
- T4_SSE m6, m7, m0
- PASS_SMALL 0, [cos_16], [cos_16+16]
- ret
-
-
-%macro FFT48_3DNOW 0
-align 16
-fft4 %+ SUFFIX:
- T2_3DNOW m0, m1, Z(0), Z(1)
- mova m2, Z(2)
- mova m3, Z(3)
- T4_3DNOW m0, m1, m2, m3, m4, m5
- PUNPCK m0, m1, m4
- PUNPCK m2, m3, m5
- mova Z(0), m0
- mova Z(1), m4
- mova Z(2), m2
- mova Z(3), m5
- ret
-
-align 16
-fft8 %+ SUFFIX:
- T2_3DNOW m0, m1, Z(0), Z(1)
- mova m2, Z(2)
- mova m3, Z(3)
- T4_3DNOW m0, m1, m2, m3, m4, m5
- mova Z(0), m0
- mova Z(2), m2
- T2_3DNOW m4, m5, Z(4), Z(5)
- T2_3DNOW m6, m7, Z2(6), Z2(7)
- PSWAPD m0, m5
- PSWAPD m2, m7
- pxor m0, [ps_m1p1]
- pxor m2, [ps_m1p1]
- pfsub m5, m0
- pfadd m7, m2
- pfmul m5, [ps_root2]
- pfmul m7, [ps_root2]
- T4_3DNOW m1, m3, m5, m7, m0, m2
- mova Z(5), m5
- mova Z2(7), m7
- mova m0, Z(0)
- mova m2, Z(2)
- T4_3DNOW m0, m2, m4, m6, m5, m7
- PUNPCK m0, m1, m5
- PUNPCK m2, m3, m7
- mova Z(0), m0
- mova Z(1), m5
- mova Z(2), m2
- mova Z(3), m7
- PUNPCK m4, Z(5), m5
- PUNPCK m6, Z2(7), m7
- mova Z(4), m4
- mova Z(5), m5
- mova Z2(6), m6
- mova Z2(7), m7
- ret
-%endmacro
-
-%if ARCH_X86_32
-INIT_MMX 3dnowext
-FFT48_3DNOW
-
-INIT_MMX 3dnow
-FFT48_3DNOW
-%endif
-
-%define Z(x) [zcq + o1q*(x&6) + mmsize*(x&1)]
-%define Z2(x) [zcq + o3q + mmsize*(x&1)]
-%define ZH(x) [zcq + o1q*(x&6) + mmsize*(x&1) + mmsize/2]
-%define Z2H(x) [zcq + o3q + mmsize*(x&1) + mmsize/2]
-
-%macro DECL_PASS 2+ ; name, payload
-align 16
-%1:
-DEFINE_ARGS zc, w, n, o1, o3
- lea o3q, [nq*3]
- lea o1q, [nq*8]
- shl o3q, 4
-.loop:
- %2
- add zcq, mmsize*2
- add wq, mmsize
- sub nd, mmsize/8
- jg .loop
- rep ret
-%endmacro
-
-%macro FFT_DISPATCH 2; clobbers 5 GPRs, 8 XMMs
- lea r2, [dispatch_tab%1]
- mov r2, [r2 + (%2q-2)*gprsize]
-%ifdef PIC
- lea r3, [$$]
- add r2, r3
-%endif
- call r2
-%endmacro ; FFT_DISPATCH
-
-INIT_YMM avx
-
-%if HAVE_AVX_EXTERNAL
-%macro INTERL_AVX 5
- vunpckhps %3, %2, %1
- vunpcklps %2, %2, %1
- vextractf128 %4(%5), %2, 0
- vextractf128 %4 %+ H(%5), %3, 0
- vextractf128 %4(%5 + 1), %2, 1
- vextractf128 %4 %+ H(%5 + 1), %3, 1
-%endmacro
-
-%define INTERL INTERL_AVX
-
-DECL_PASS pass_avx, PASS_BIG 1
-DECL_PASS pass_interleave_avx, PASS_BIG 0
-
-cglobal fft_calc, 2,5,8
- mov r3d, [r0 + FFTContext.nbits]
- mov r0, r1
- mov r1, r3
- FFT_DISPATCH _interleave %+ SUFFIX, r1
- REP_RET
-
-%endif
-
-INIT_XMM sse
-
-%macro INTERL_SSE 5
- mova %3, %2
- unpcklps %2, %1
- unpckhps %3, %1
- mova %4(%5), %2
- mova %4(%5+1), %3
-%endmacro
-
-%define INTERL INTERL_SSE
-
-DECL_PASS pass_sse, PASS_BIG 1
-DECL_PASS pass_interleave_sse, PASS_BIG 0
-
-%macro FFT_CALC_FUNC 0
-cglobal fft_calc, 2,5,8
- mov r3d, [r0 + FFTContext.nbits]
- PUSH r1
- PUSH r3
- mov r0, r1
- mov r1, r3
- FFT_DISPATCH _interleave %+ SUFFIX, r1
- POP rcx
- POP r4
- cmp rcx, 3+(mmsize/16)
- jg .end
- mov r2, -1
- add rcx, 3
- shl r2, cl
- sub r4, r2
-.loop:
-%if mmsize == 8
- PSWAPD m0, [r4 + r2 + 4]
- mova [r4 + r2 + 4], m0
-%else
- movaps xmm0, [r4 + r2]
- movaps xmm1, xmm0
- unpcklps xmm0, [r4 + r2 + 16]
- unpckhps xmm1, [r4 + r2 + 16]
- movaps [r4 + r2], xmm0
- movaps [r4 + r2 + 16], xmm1
-%endif
- add r2, mmsize*2
- jl .loop
-.end:
-%if cpuflag(3dnow)
- femms
- RET
-%else
- REP_RET
-%endif
-%endmacro
-
-%if ARCH_X86_32
-INIT_MMX 3dnow
-FFT_CALC_FUNC
-INIT_MMX 3dnowext
-FFT_CALC_FUNC
-%endif
-INIT_XMM sse
-FFT_CALC_FUNC
-
-cglobal fft_permute, 2,7,1
- mov r4, [r0 + FFTContext.revtab]
- mov r5, [r0 + FFTContext.tmpbuf]
- mov ecx, [r0 + FFTContext.nbits]
- mov r2, 1
- shl r2, cl
- xor r0, r0
-%if ARCH_X86_32
- mov r1, r1m
-%endif
-.loop:
- movaps xmm0, [r1 + 8*r0]
- movzx r6, word [r4 + 2*r0]
- movzx r3, word [r4 + 2*r0 + 2]
- movlps [r5 + 8*r6], xmm0
- movhps [r5 + 8*r3], xmm0
- add r0, 2
- cmp r0, r2
- jl .loop
- shl r2, 3
- add r1, r2
- add r5, r2
- neg r2
-; nbits >= 2 (FFT4) and sizeof(FFTComplex)=8 => at least 32B
-.loopcopy:
- movaps xmm0, [r5 + r2]
- movaps xmm1, [r5 + r2 + 16]
- movaps [r1 + r2], xmm0
- movaps [r1 + r2 + 16], xmm1
- add r2, 32
- jl .loopcopy
- REP_RET
-
-%macro IMDCT_CALC_FUNC 0
-cglobal imdct_calc, 3,5,3
- mov r3d, [r0 + FFTContext.mdctsize]
- mov r4, [r0 + FFTContext.imdcthalf]
- add r1, r3
- PUSH r3
- PUSH r1
-%if ARCH_X86_32
- push r2
- push r1
- push r0
-%else
- sub rsp, 8
-%endif
- call r4
-%if ARCH_X86_32
- add esp, 12
-%else
- add rsp, 8
-%endif
- POP r1
- POP r3
- lea r0, [r1 + 2*r3]
- mov r2, r3
- sub r3, mmsize
- neg r2
- mova m2, [ps_m1m1m1m1]
-.loop:
-%if mmsize == 8
- PSWAPD m0, [r1 + r3]
- PSWAPD m1, [r0 + r2]
- pxor m0, m2
-%else
- mova m0, [r1 + r3]
- mova m1, [r0 + r2]
- shufps m0, m0, 0x1b
- shufps m1, m1, 0x1b
- xorps m0, m2
-%endif
- mova [r0 + r3], m1
- mova [r1 + r2], m0
- sub r3, mmsize
- add r2, mmsize
- jl .loop
-%if cpuflag(3dnow)
- femms
- RET
-%else
- REP_RET
-%endif
-%endmacro
-
-%if ARCH_X86_32
-INIT_MMX 3dnow
-IMDCT_CALC_FUNC
-INIT_MMX 3dnowext
-IMDCT_CALC_FUNC
-%endif
-
-INIT_XMM sse
-IMDCT_CALC_FUNC
-
-%if ARCH_X86_32
-INIT_MMX 3dnow
-%define mulps pfmul
-%define addps pfadd
-%define subps pfsub
-%define unpcklps punpckldq
-%define unpckhps punpckhdq
-DECL_PASS pass_3dnow, PASS_SMALL 1, [wq], [wq+o1q]
-DECL_PASS pass_interleave_3dnow, PASS_BIG 0
-%define pass_3dnowext pass_3dnow
-%define pass_interleave_3dnowext pass_interleave_3dnow
-%endif
-
-%ifdef PIC
-%define SECTION_REL - $$
-%else
-%define SECTION_REL
-%endif
-
-%macro DECL_FFT 1-2 ; nbits, suffix
-%ifidn %0, 1
-%xdefine fullsuffix SUFFIX
-%else
-%xdefine fullsuffix %2 %+ SUFFIX
-%endif
-%xdefine list_of_fft fft4 %+ SUFFIX SECTION_REL, fft8 %+ SUFFIX SECTION_REL
-%if %1>=5
-%xdefine list_of_fft list_of_fft, fft16 %+ SUFFIX SECTION_REL
-%endif
-%if %1>=6
-%xdefine list_of_fft list_of_fft, fft32 %+ fullsuffix SECTION_REL
-%endif
-
-%assign n 1<<%1
-%rep 17-%1
-%assign n2 n/2
-%assign n4 n/4
-%xdefine list_of_fft list_of_fft, fft %+ n %+ fullsuffix SECTION_REL
-
-align 16
-fft %+ n %+ fullsuffix:
- call fft %+ n2 %+ SUFFIX
- add r0, n*4 - (n&(-2<<%1))
- call fft %+ n4 %+ SUFFIX
- add r0, n*2 - (n2&(-2<<%1))
- call fft %+ n4 %+ SUFFIX
- sub r0, n*6 + (n2&(-2<<%1))
- lea r1, [cos_ %+ n]
- mov r2d, n4/2
- jmp pass %+ fullsuffix
-
-%assign n n*2
-%endrep
-%undef n
-
-align 8
-dispatch_tab %+ fullsuffix: pointer list_of_fft
-%endmacro ; DECL_FFT
-
-%if HAVE_AVX_EXTERNAL
-INIT_YMM avx
-DECL_FFT 6
-DECL_FFT 6, _interleave
-%endif
-INIT_XMM sse
-DECL_FFT 5
-DECL_FFT 5, _interleave
-%if ARCH_X86_32
-INIT_MMX 3dnow
-DECL_FFT 4
-DECL_FFT 4, _interleave
-INIT_MMX 3dnowext
-DECL_FFT 4
-DECL_FFT 4, _interleave
-%endif
-
-INIT_XMM sse
-%undef mulps
-%undef addps
-%undef subps
-%undef unpcklps
-%undef unpckhps
-
-%macro PREROTATER 5 ;-2*k, 2*k, input+n4, tcos+n8, tsin+n8
-%if mmsize == 8 ; j*2+2-n4, n4-2-j*2, input+n4, tcos+n8, tsin+n8
- PSWAPD m0, [%3+%2*4]
- movq m2, [%3+%1*4-8]
- movq m3, m0
- punpckldq m0, m2
- punpckhdq m2, m3
- movd m1, [%4+%1*2-4] ; tcos[j]
- movd m3, [%4+%2*2] ; tcos[n4-j-1]
- punpckldq m1, [%5+%1*2-4] ; tsin[j]
- punpckldq m3, [%5+%2*2] ; tsin[n4-j-1]
-
- mova m4, m0
- PSWAPD m5, m1
- pfmul m0, m1
- pfmul m4, m5
- mova m6, m2
- PSWAPD m5, m3
- pfmul m2, m3
- pfmul m6, m5
-%if cpuflag(3dnowext)
- pfpnacc m0, m4
- pfpnacc m2, m6
-%else
- SBUTTERFLY dq, 0, 4, 1
- SBUTTERFLY dq, 2, 6, 3
- pxor m4, m7
- pxor m6, m7
- pfadd m0, m4
- pfadd m2, m6
-%endif
-%else
- movaps xmm0, [%3+%2*4]
- movaps xmm1, [%3+%1*4-0x10]
- movaps xmm2, xmm0
- shufps xmm0, xmm1, 0x88
- shufps xmm1, xmm2, 0x77
- movlps xmm4, [%4+%2*2]
- movlps xmm5, [%5+%2*2+0x0]
- movhps xmm4, [%4+%1*2-0x8]
- movhps xmm5, [%5+%1*2-0x8]
- movaps xmm2, xmm0
- movaps xmm3, xmm1
- mulps xmm0, xmm5
- mulps xmm1, xmm4
- mulps xmm2, xmm4
- mulps xmm3, xmm5
- subps xmm1, xmm0
- addps xmm2, xmm3
- movaps xmm0, xmm1
- unpcklps xmm1, xmm2
- unpckhps xmm0, xmm2
-%endif
-%endmacro
-
-%macro CMUL 6 ;j, xmm0, xmm1, 3, 4, 5
- mulps m6, %3, [%5+%1]
- mulps m7, %2, [%5+%1]
- mulps %2, %2, [%6+%1]
- mulps %3, %3, [%6+%1]
- subps %2, %2, m6
- addps %3, %3, m7
-%endmacro
-
-%macro POSROTATESHUF_AVX 5 ;j, k, z+n8, tcos+n8, tsin+n8
-.post:
- vmovaps ymm1, [%3+%1*2]
- vmovaps ymm0, [%3+%1*2+0x20]
- vmovaps ymm3, [%3+%2*2]
- vmovaps ymm2, [%3+%2*2+0x20]
-
- CMUL %1, ymm0, ymm1, %3, %4, %5
- CMUL %2, ymm2, ymm3, %3, %4, %5
- vshufps ymm1, ymm1, ymm1, 0x1b
- vshufps ymm3, ymm3, ymm3, 0x1b
- vperm2f128 ymm1, ymm1, ymm1, 0x01
- vperm2f128 ymm3, ymm3, ymm3, 0x01
- vunpcklps ymm6, ymm2, ymm1
- vunpckhps ymm4, ymm2, ymm1
- vunpcklps ymm7, ymm0, ymm3
- vunpckhps ymm5, ymm0, ymm3
-
- vextractf128 [%3+%1*2], ymm7, 0
- vextractf128 [%3+%1*2+0x10], ymm5, 0
- vextractf128 [%3+%1*2+0x20], ymm7, 1
- vextractf128 [%3+%1*2+0x30], ymm5, 1
-
- vextractf128 [%3+%2*2], ymm6, 0
- vextractf128 [%3+%2*2+0x10], ymm4, 0
- vextractf128 [%3+%2*2+0x20], ymm6, 1
- vextractf128 [%3+%2*2+0x30], ymm4, 1
- sub %2, 0x20
- add %1, 0x20
- jl .post
-%endmacro
-
-%macro POSROTATESHUF 5 ;j, k, z+n8, tcos+n8, tsin+n8
-.post:
- movaps xmm1, [%3+%1*2]
- movaps xmm0, [%3+%1*2+0x10]
- CMUL %1, xmm0, xmm1, %3, %4, %5
- movaps xmm5, [%3+%2*2]
- movaps xmm4, [%3+%2*2+0x10]
- CMUL %2, xmm4, xmm5, %3, %4, %5
- shufps xmm1, xmm1, 0x1b
- shufps xmm5, xmm5, 0x1b
- movaps xmm6, xmm4
- unpckhps xmm4, xmm1
- unpcklps xmm6, xmm1
- movaps xmm2, xmm0
- unpcklps xmm0, xmm5
- unpckhps xmm2, xmm5
- movaps [%3+%2*2], xmm6
- movaps [%3+%2*2+0x10], xmm4
- movaps [%3+%1*2], xmm0
- movaps [%3+%1*2+0x10], xmm2
- sub %2, 0x10
- add %1, 0x10
- jl .post
-%endmacro
-
-%macro CMUL_3DNOW 6
- mova m6, [%1+%2*2]
- mova %3, [%1+%2*2+8]
- mova %4, m6
- mova m7, %3
- pfmul m6, [%5+%2]
- pfmul %3, [%6+%2]
- pfmul %4, [%6+%2]
- pfmul m7, [%5+%2]
- pfsub %3, m6
- pfadd %4, m7
-%endmacro
-
-%macro POSROTATESHUF_3DNOW 5 ;j, k, z+n8, tcos+n8, tsin+n8
-.post:
- CMUL_3DNOW %3, %1, m0, m1, %4, %5
- CMUL_3DNOW %3, %2, m2, m3, %4, %5
- movd [%3+%1*2+ 0], m0
- movd [%3+%2*2+12], m1
- movd [%3+%2*2+ 0], m2
- movd [%3+%1*2+12], m3
- psrlq m0, 32
- psrlq m1, 32
- psrlq m2, 32
- psrlq m3, 32
- movd [%3+%1*2+ 8], m0
- movd [%3+%2*2+ 4], m1
- movd [%3+%2*2+ 8], m2
- movd [%3+%1*2+ 4], m3
- sub %2, 8
- add %1, 8
- jl .post
-%endmacro
-
-%macro DECL_IMDCT 1
-cglobal imdct_half, 3,12,8; FFTContext *s, FFTSample *output, const FFTSample *input
-%if ARCH_X86_64
-%define rrevtab r7
-%define rtcos r8
-%define rtsin r9
-%else
-%define rrevtab r6
-%define rtsin r6
-%define rtcos r5
-%endif
- mov r3d, [r0+FFTContext.mdctsize]
- add r2, r3
- shr r3, 1
- mov rtcos, [r0+FFTContext.tcos]
- mov rtsin, [r0+FFTContext.tsin]
- add rtcos, r3
- add rtsin, r3
-%if ARCH_X86_64 == 0
- push rtcos
- push rtsin
-%endif
- shr r3, 1
- mov rrevtab, [r0+FFTContext.revtab]
- add rrevtab, r3
-%if ARCH_X86_64 == 0
- push rrevtab
-%endif
-
-%if mmsize == 8
- sub r3, 2
-%else
- sub r3, 4
-%endif
-%if ARCH_X86_64 || mmsize == 8
- xor r4, r4
- sub r4, r3
-%endif
-%if notcpuflag(3dnowext) && mmsize == 8
- movd m7, [ps_m1m1m1m1]
-%endif
-.pre:
-%if ARCH_X86_64 == 0
-;unspill
-%if mmsize != 8
- xor r4, r4
- sub r4, r3
-%endif
- mov rtcos, [esp+8]
- mov rtsin, [esp+4]
-%endif
-
- PREROTATER r4, r3, r2, rtcos, rtsin
-%if mmsize == 8
- mov r6, [esp] ; rrevtab = ptr+n8
- movzx r5, word [rrevtab+r4-2] ; rrevtab[j]
- movzx r6, word [rrevtab+r3] ; rrevtab[n4-j-1]
- mova [r1+r5*8], m0
- mova [r1+r6*8], m2
- add r4, 2
- sub r3, 2
-%else
-%if ARCH_X86_64
- movzx r5, word [rrevtab+r4-4]
- movzx r6, word [rrevtab+r4-2]
- movzx r10, word [rrevtab+r3]
- movzx r11, word [rrevtab+r3+2]
- movlps [r1+r5 *8], xmm0
- movhps [r1+r6 *8], xmm0
- movlps [r1+r10*8], xmm1
- movhps [r1+r11*8], xmm1
- add r4, 4
-%else
- mov r6, [esp]
- movzx r5, word [r6+r4-4]
- movzx r4, word [r6+r4-2]
- movlps [r1+r5*8], xmm0
- movhps [r1+r4*8], xmm0
- movzx r5, word [r6+r3]
- movzx r4, word [r6+r3+2]
- movlps [r1+r5*8], xmm1
- movhps [r1+r4*8], xmm1
-%endif
- sub r3, 4
-%endif
- jns .pre
-
- mov r5, r0
- mov r6, r1
- mov r0, r1
- mov r1d, [r5+FFTContext.nbits]
-
- FFT_DISPATCH SUFFIX, r1
-
- mov r0d, [r5+FFTContext.mdctsize]
- add r6, r0
- shr r0, 1
-%if ARCH_X86_64 == 0
-%define rtcos r2
-%define rtsin r3
- mov rtcos, [esp+8]
- mov rtsin, [esp+4]
-%endif
- neg r0
- mov r1, -mmsize
- sub r1, r0
- %1 r0, r1, r6, rtcos, rtsin
-%if ARCH_X86_64 == 0
- add esp, 12
-%endif
-%if mmsize == 8
- femms
-%endif
- RET
-%endmacro
-
-DECL_IMDCT POSROTATESHUF
-
-%if ARCH_X86_32
-INIT_MMX 3dnow
-DECL_IMDCT POSROTATESHUF_3DNOW
-
-INIT_MMX 3dnowext
-DECL_IMDCT POSROTATESHUF_3DNOW
-%endif
-
-INIT_YMM avx
-
-%if HAVE_AVX_EXTERNAL
-DECL_IMDCT POSROTATESHUF_AVX
-%endif
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/fft.h b/src/thirdparty/ffmpeg/libavcodec/x86/fft.h
deleted file mode 100644
index 82c09ab23..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/fft.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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_FFT_H
-#define AVCODEC_X86_FFT_H
-
-#include "libavcodec/fft.h"
-
-void ff_fft_permute_sse(FFTContext *s, FFTComplex *z);
-void ff_fft_calc_avx(FFTContext *s, FFTComplex *z);
-void ff_fft_calc_sse(FFTContext *s, FFTComplex *z);
-void ff_fft_calc_3dnow(FFTContext *s, FFTComplex *z);
-void ff_fft_calc_3dnowext(FFTContext *s, FFTComplex *z);
-
-void ff_imdct_calc_3dnow(FFTContext *s, FFTSample *output, const FFTSample *input);
-void ff_imdct_half_3dnow(FFTContext *s, FFTSample *output, const FFTSample *input);
-void ff_imdct_calc_3dnowext(FFTContext *s, FFTSample *output, const FFTSample *input);
-void ff_imdct_half_3dnowext(FFTContext *s, FFTSample *output, const FFTSample *input);
-void ff_imdct_calc_sse(FFTContext *s, FFTSample *output, const FFTSample *input);
-void ff_imdct_half_sse(FFTContext *s, FFTSample *output, const FFTSample *input);
-void ff_imdct_half_avx(FFTContext *s, FFTSample *output, const FFTSample *input);
-void ff_dct32_float_sse(FFTSample *out, const FFTSample *in);
-void ff_dct32_float_sse2(FFTSample *out, const FFTSample *in);
-void ff_dct32_float_avx(FFTSample *out, const FFTSample *in);
-
-#endif /* AVCODEC_X86_FFT_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/fft_init.c b/src/thirdparty/ffmpeg/libavcodec/x86/fft_init.c
deleted file mode 100644
index a9d95799b..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/fft_init.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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/cpu.h"
-#include "libavutil/x86/cpu.h"
-#include "libavcodec/dsputil.h"
-#include "libavcodec/dct.h"
-#include "fft.h"
-
-av_cold void ff_fft_init_x86(FFTContext *s)
-{
- int has_vectors = av_get_cpu_flags();
-#if ARCH_X86_32
- if (EXTERNAL_AMD3DNOW(has_vectors)) {
- /* 3DNow! for K6-2/3 */
- s->imdct_calc = ff_imdct_calc_3dnow;
- s->imdct_half = ff_imdct_half_3dnow;
- s->fft_calc = ff_fft_calc_3dnow;
- }
- if (EXTERNAL_AMD3DNOWEXT(has_vectors)) {
- /* 3DNowEx for K7 */
- s->imdct_calc = ff_imdct_calc_3dnowext;
- s->imdct_half = ff_imdct_half_3dnowext;
- s->fft_calc = ff_fft_calc_3dnowext;
- }
-#endif
- if (EXTERNAL_SSE(has_vectors)) {
- /* SSE for P3/P4/K8 */
- s->imdct_calc = ff_imdct_calc_sse;
- s->imdct_half = ff_imdct_half_sse;
- s->fft_permute = ff_fft_permute_sse;
- s->fft_calc = ff_fft_calc_sse;
- s->fft_permutation = FF_FFT_PERM_SWAP_LSBS;
- }
- if (EXTERNAL_AVX(has_vectors) && s->nbits >= 5) {
- /* AVX for SB */
- s->imdct_half = ff_imdct_half_avx;
- s->fft_calc = ff_fft_calc_avx;
- s->fft_permutation = FF_FFT_PERM_AVX;
- }
-}
-
-#if CONFIG_DCT
-av_cold void ff_dct_init_x86(DCTContext *s)
-{
- int has_vectors = av_get_cpu_flags();
- if (EXTERNAL_SSE(has_vectors))
- s->dct32 = ff_dct32_float_sse;
- if (EXTERNAL_SSE2(has_vectors))
- s->dct32 = ff_dct32_float_sse2;
- if (EXTERNAL_AVX(has_vectors))
- s->dct32 = ff_dct32_float_avx;
-}
-#endif
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/fmtconvert.asm b/src/thirdparty/ffmpeg/libavcodec/x86/fmtconvert.asm
deleted file mode 100644
index 3c5895a95..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/fmtconvert.asm
+++ /dev/null
@@ -1,429 +0,0 @@
-;******************************************************************************
-;* x86 optimized Format Conversion Utils
-;* Copyright (c) 2008 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 CVTPS2PI 2
-%if cpuflag(sse)
- cvtps2pi %1, %2
-%elif cpuflag(3dnow)
- pf2id %1, %2
-%endif
-%endmacro
-
-;---------------------------------------------------------------------------------
-; void int32_to_float_fmul_scalar(float *dst, const int *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
-%else
-cglobal int32_to_float_fmul_scalar, 4, 4, %1, dst, src, mul, len
-%endif
-%if WIN64
- SWAP 0, 2
-%elif ARCH_X86_32
- movss m0, mulm
-%endif
- SPLATD m0
- shl lenq, 2
- add srcq, lenq
- add dstq, lenq
- neg lenq
-.loop:
-%if cpuflag(sse2)
- cvtdq2ps m1, [srcq+lenq ]
- cvtdq2ps m2, [srcq+lenq+16]
-%else
- cvtpi2ps m1, [srcq+lenq ]
- cvtpi2ps m3, [srcq+lenq+ 8]
- cvtpi2ps m2, [srcq+lenq+16]
- cvtpi2ps m4, [srcq+lenq+24]
- movlhps m1, m3
- movlhps m2, m4
-%endif
- mulps m1, m0
- mulps m2, m0
- mova [dstq+lenq ], m1
- mova [dstq+lenq+16], m2
- add lenq, 32
- jl .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse
-INT32_TO_FLOAT_FMUL_SCALAR 5
-INIT_XMM sse2
-INT32_TO_FLOAT_FMUL_SCALAR 3
-
-
-;------------------------------------------------------------------------------
-; void ff_float_to_int16(int16_t *dst, const float *src, long len);
-;------------------------------------------------------------------------------
-%macro FLOAT_TO_INT16 1
-cglobal float_to_int16, 3, 3, %1, dst, src, len
- add lenq, lenq
- lea srcq, [srcq+2*lenq]
- add dstq, lenq
- neg lenq
-.loop:
-%if cpuflag(sse2)
- cvtps2dq m0, [srcq+2*lenq ]
- cvtps2dq m1, [srcq+2*lenq+16]
- packssdw m0, m1
- mova [dstq+lenq], m0
-%else
- CVTPS2PI m0, [srcq+2*lenq ]
- CVTPS2PI m1, [srcq+2*lenq+ 8]
- CVTPS2PI m2, [srcq+2*lenq+16]
- CVTPS2PI m3, [srcq+2*lenq+24]
- packssdw m0, m1
- packssdw m2, m3
- mova [dstq+lenq ], m0
- mova [dstq+lenq+8], m2
-%endif
- add lenq, 16
- js .loop
-%if mmsize == 8
- emms
-%endif
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-FLOAT_TO_INT16 2
-INIT_MMX sse
-FLOAT_TO_INT16 0
-INIT_MMX 3dnow
-FLOAT_TO_INT16 0
-
-;------------------------------------------------------------------------------
-; void ff_float_to_int16_step(int16_t *dst, const float *src, long len, long step);
-;------------------------------------------------------------------------------
-%macro FLOAT_TO_INT16_STEP 1
-cglobal float_to_int16_step, 4, 7, %1, dst, src, len, step, step3, v1, v2
- add lenq, lenq
- lea srcq, [srcq+2*lenq]
- lea step3q, [stepq*3]
- neg lenq
-.loop:
-%if cpuflag(sse2)
- cvtps2dq m0, [srcq+2*lenq ]
- cvtps2dq m1, [srcq+2*lenq+16]
- packssdw m0, m1
- movd v1d, m0
- psrldq m0, 4
- movd v2d, m0
- psrldq m0, 4
- mov [dstq], v1w
- mov [dstq+stepq*4], v2w
- shr v1d, 16
- shr v2d, 16
- mov [dstq+stepq*2], v1w
- mov [dstq+step3q*2], v2w
- lea dstq, [dstq+stepq*8]
- movd v1d, m0
- psrldq m0, 4
- movd v2d, m0
- mov [dstq], v1w
- mov [dstq+stepq*4], v2w
- shr v1d, 16
- shr v2d, 16
- mov [dstq+stepq*2], v1w
- mov [dstq+step3q*2], v2w
- lea dstq, [dstq+stepq*8]
-%else
- CVTPS2PI m0, [srcq+2*lenq ]
- CVTPS2PI m1, [srcq+2*lenq+ 8]
- CVTPS2PI m2, [srcq+2*lenq+16]
- CVTPS2PI m3, [srcq+2*lenq+24]
- packssdw m0, m1
- packssdw m2, m3
- movd v1d, m0
- psrlq m0, 32
- movd v2d, m0
- mov [dstq], v1w
- mov [dstq+stepq*4], v2w
- shr v1d, 16
- shr v2d, 16
- mov [dstq+stepq*2], v1w
- mov [dstq+step3q*2], v2w
- lea dstq, [dstq+stepq*8]
- movd v1d, m2
- psrlq m2, 32
- movd v2d, m2
- mov [dstq], v1w
- mov [dstq+stepq*4], v2w
- shr v1d, 16
- shr v2d, 16
- mov [dstq+stepq*2], v1w
- mov [dstq+step3q*2], v2w
- lea dstq, [dstq+stepq*8]
-%endif
- add lenq, 16
- js .loop
-%if mmsize == 8
- emms
-%endif
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-FLOAT_TO_INT16_STEP 2
-INIT_MMX sse
-FLOAT_TO_INT16_STEP 0
-INIT_MMX 3dnow
-FLOAT_TO_INT16_STEP 0
-
-;-------------------------------------------------------------------------------
-; void ff_float_to_int16_interleave2(int16_t *dst, const float **src, long len);
-;-------------------------------------------------------------------------------
-%macro FLOAT_TO_INT16_INTERLEAVE2 0
-cglobal float_to_int16_interleave2, 3, 4, 2, dst, src0, src1, len
- lea lenq, [4*r2q]
- mov src1q, [src0q+gprsize]
- mov src0q, [src0q]
- add dstq, lenq
- add src0q, lenq
- add src1q, lenq
- neg lenq
-.loop:
-%if cpuflag(sse2)
- cvtps2dq m0, [src0q+lenq]
- cvtps2dq m1, [src1q+lenq]
- packssdw m0, m1
- movhlps m1, m0
- punpcklwd m0, m1
- mova [dstq+lenq], m0
-%else
- CVTPS2PI m0, [src0q+lenq ]
- CVTPS2PI m1, [src0q+lenq+8]
- CVTPS2PI m2, [src1q+lenq ]
- CVTPS2PI m3, [src1q+lenq+8]
- packssdw m0, m1
- packssdw m2, m3
- mova m1, m0
- punpcklwd m0, m2
- punpckhwd m1, m2
- mova [dstq+lenq ], m0
- mova [dstq+lenq+8], m1
-%endif
- add lenq, 16
- js .loop
-%if mmsize == 8
- emms
-%endif
- REP_RET
-%endmacro
-
-INIT_MMX 3dnow
-FLOAT_TO_INT16_INTERLEAVE2
-INIT_MMX sse
-FLOAT_TO_INT16_INTERLEAVE2
-INIT_XMM sse2
-FLOAT_TO_INT16_INTERLEAVE2
-
-%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
-%else
- %define lend dword r2m
-%endif
- mov src1q, [srcq+1*gprsize]
- mov src2q, [srcq+2*gprsize]
- mov src3q, [srcq+3*gprsize]
- mov src4q, [srcq+4*gprsize]
- mov src5q, [srcq+5*gprsize]
- mov srcq, [srcq]
- sub src1q, srcq
- sub src2q, srcq
- sub src3q, srcq
- sub src4q, srcq
- sub src5q, srcq
-.loop:
- CVTPS2PI mm0, [srcq]
- CVTPS2PI mm1, [srcq+src1q]
- CVTPS2PI mm2, [srcq+src2q]
- CVTPS2PI mm3, [srcq+src3q]
- CVTPS2PI mm4, [srcq+src4q]
- CVTPS2PI mm5, [srcq+src5q]
- packssdw mm0, mm3
- packssdw mm1, mm4
- packssdw mm2, mm5
- PSWAPD mm3, mm0
- punpcklwd mm0, mm1
- punpckhwd mm1, mm2
- punpcklwd mm2, mm3
- PSWAPD mm3, mm0
- punpckldq mm0, mm2
- punpckhdq mm2, mm1
- punpckldq mm1, mm3
- movq [dstq ], mm0
- movq [dstq+16], mm2
- movq [dstq+ 8], mm1
- add srcq, 8
- add dstq, 24
- sub lend, 2
- jg .loop
- emms
- RET
-%endmacro ; FLOAT_TO_INT16_INTERLEAVE6
-
-INIT_MMX sse
-FLOAT_TO_INT16_INTERLEAVE6
-INIT_MMX 3dnow
-FLOAT_TO_INT16_INTERLEAVE6
-INIT_MMX 3dnowext
-FLOAT_TO_INT16_INTERLEAVE6
-
-;-----------------------------------------------------------------------------
-; void ff_float_interleave6(float *dst, const float **src, unsigned int len);
-;-----------------------------------------------------------------------------
-
-%macro FLOAT_INTERLEAVE6 1
-cglobal float_interleave6, 2, 8, %1, dst, src, src1, src2, src3, src4, src5, len
-%if ARCH_X86_64
- mov lend, r2d
-%else
- %define lend dword r2m
-%endif
- mov src1q, [srcq+1*gprsize]
- mov src2q, [srcq+2*gprsize]
- mov src3q, [srcq+3*gprsize]
- mov src4q, [srcq+4*gprsize]
- mov src5q, [srcq+5*gprsize]
- mov srcq, [srcq]
- sub src1q, srcq
- sub src2q, srcq
- sub src3q, srcq
- sub src4q, srcq
- sub src5q, srcq
-.loop:
-%if cpuflag(sse)
- movaps m0, [srcq]
- movaps m1, [srcq+src1q]
- movaps m2, [srcq+src2q]
- movaps m3, [srcq+src3q]
- movaps m4, [srcq+src4q]
- movaps m5, [srcq+src5q]
-
- SBUTTERFLYPS 0, 1, 6
- SBUTTERFLYPS 2, 3, 6
- SBUTTERFLYPS 4, 5, 6
-
- movaps m6, m4
- shufps m4, m0, 0xe4
- movlhps m0, m2
- movhlps m6, m2
- movaps [dstq ], m0
- movaps [dstq+16], m4
- movaps [dstq+32], m6
-
- movaps m6, m5
- shufps m5, m1, 0xe4
- movlhps m1, m3
- movhlps m6, m3
- movaps [dstq+48], m1
- movaps [dstq+64], m5
- movaps [dstq+80], m6
-%else ; mmx
- movq m0, [srcq]
- movq m1, [srcq+src1q]
- movq m2, [srcq+src2q]
- movq m3, [srcq+src3q]
- movq m4, [srcq+src4q]
- movq m5, [srcq+src5q]
-
- SBUTTERFLY dq, 0, 1, 6
- SBUTTERFLY dq, 2, 3, 6
- SBUTTERFLY dq, 4, 5, 6
- movq [dstq ], m0
- movq [dstq+ 8], m2
- movq [dstq+16], m4
- movq [dstq+24], m1
- movq [dstq+32], m3
- movq [dstq+40], m5
-%endif
- add srcq, mmsize
- add dstq, mmsize*6
- sub lend, mmsize/4
- jg .loop
-%if mmsize == 8
- emms
-%endif
- REP_RET
-%endmacro
-
-INIT_MMX mmx
-FLOAT_INTERLEAVE6 0
-INIT_XMM sse
-FLOAT_INTERLEAVE6 7
-
-;-----------------------------------------------------------------------------
-; void ff_float_interleave2(float *dst, const float **src, unsigned int len);
-;-----------------------------------------------------------------------------
-
-%macro FLOAT_INTERLEAVE2 1
-cglobal float_interleave2, 3, 4, %1, dst, src, len, src1
- mov src1q, [srcq+gprsize]
- mov srcq, [srcq ]
- sub src1q, srcq
-.loop:
- mova m0, [srcq ]
- mova m1, [srcq+src1q ]
- mova m3, [srcq +mmsize]
- mova m4, [srcq+src1q+mmsize]
-
- mova m2, m0
- PUNPCKLDQ m0, m1
- PUNPCKHDQ m2, m1
-
- mova m1, m3
- PUNPCKLDQ m3, m4
- PUNPCKHDQ m1, m4
-
- mova [dstq ], m0
- mova [dstq+1*mmsize], m2
- mova [dstq+2*mmsize], m3
- mova [dstq+3*mmsize], m1
-
- add srcq, mmsize*2
- add dstq, mmsize*4
- sub lend, mmsize/2
- jg .loop
-%if mmsize == 8
- emms
-%endif
- REP_RET
-%endmacro
-
-INIT_MMX mmx
-%define PUNPCKLDQ punpckldq
-%define PUNPCKHDQ punpckhdq
-FLOAT_INTERLEAVE2 0
-INIT_XMM sse
-%define PUNPCKLDQ unpcklps
-%define PUNPCKHDQ unpckhps
-FLOAT_INTERLEAVE2 5
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/fmtconvert_init.c b/src/thirdparty/ffmpeg/libavcodec/x86/fmtconvert_init.c
deleted file mode 100644
index 7a4bbdb2c..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/fmtconvert_init.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Format Conversion Utils
- * Copyright (c) 2000, 2001 Fabrice Bellard
- * Copyright (c) 2002-2004 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
- *
- * 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/fmtconvert.h"
-#include "libavcodec/dsputil.h"
-
-#if HAVE_YASM
-
-void ff_int32_to_float_fmul_scalar_sse (float *dst, const int *src, float mul, int len);
-void ff_int32_to_float_fmul_scalar_sse2(float *dst, const int *src, float mul, int len);
-
-void ff_float_to_int16_3dnow(int16_t *dst, const float *src, long len);
-void ff_float_to_int16_sse (int16_t *dst, const float *src, long len);
-void ff_float_to_int16_sse2 (int16_t *dst, const float *src, long len);
-
-void ff_float_to_int16_step_3dnow(int16_t *dst, const float *src, long len, long step);
-void ff_float_to_int16_step_sse (int16_t *dst, const float *src, long len, long step);
-void ff_float_to_int16_step_sse2 (int16_t *dst, const float *src, long len, long step);
-
-void ff_float_to_int16_interleave2_3dnow(int16_t *dst, const float **src, long len);
-void ff_float_to_int16_interleave2_sse (int16_t *dst, const float **src, long len);
-void ff_float_to_int16_interleave2_sse2 (int16_t *dst, const float **src, long len);
-
-void ff_float_to_int16_interleave6_sse(int16_t *dst, const float **src, int len);
-void ff_float_to_int16_interleave6_3dnow(int16_t *dst, const float **src, int len);
-void ff_float_to_int16_interleave6_3dnowext(int16_t *dst, const float **src, int len);
-
-#define ff_float_to_int16_interleave6_sse2 ff_float_to_int16_interleave6_sse
-
-#define FLOAT_TO_INT16_INTERLEAVE(cpu) \
-/* gcc pessimizes register allocation if this is in the same function as float_to_int16_interleave_sse2*/\
-static av_noinline void float_to_int16_interleave_misc_##cpu(int16_t *dst, const float **src, long len, int channels){\
- int c;\
- for(c=0; c<channels; c++){\
- ff_float_to_int16_step_##cpu(dst+c, src[c], len, channels);\
- }\
-}\
-\
-static void float_to_int16_interleave_##cpu(int16_t *dst, const float **src, long len, int channels){\
- if(channels==1)\
- ff_float_to_int16_##cpu(dst, src[0], len);\
- else if(channels==2){\
- ff_float_to_int16_interleave2_##cpu(dst, src, len);\
- }else if(channels==6){\
- ff_float_to_int16_interleave6_##cpu(dst, src, len);\
- }else\
- float_to_int16_interleave_misc_##cpu(dst, src, len, channels);\
-}
-
-FLOAT_TO_INT16_INTERLEAVE(3dnow)
-FLOAT_TO_INT16_INTERLEAVE(sse)
-FLOAT_TO_INT16_INTERLEAVE(sse2)
-
-static void float_to_int16_interleave_3dnowext(int16_t *dst, const float **src,
- long len, int channels)
-{
- if(channels==6)
- ff_float_to_int16_interleave6_3dnowext(dst, src, len);
- else
- float_to_int16_interleave_3dnow(dst, src, len, channels);
-}
-
-void ff_float_interleave2_mmx(float *dst, const float **src, unsigned int len);
-void ff_float_interleave2_sse(float *dst, const float **src, unsigned int len);
-
-void ff_float_interleave6_mmx(float *dst, const float **src, unsigned int len);
-void ff_float_interleave6_sse(float *dst, const float **src, unsigned int len);
-
-static void float_interleave_mmx(float *dst, const float **src,
- unsigned int len, int channels)
-{
- if (channels == 2) {
- ff_float_interleave2_mmx(dst, src, len);
- } else if (channels == 6)
- ff_float_interleave6_mmx(dst, src, len);
- else
- ff_float_interleave_c(dst, src, len, channels);
-}
-
-static void float_interleave_sse(float *dst, const float **src,
- unsigned int len, int channels)
-{
- if (channels == 2) {
- ff_float_interleave2_sse(dst, src, len);
- } else if (channels == 6)
- ff_float_interleave6_sse(dst, src, len);
- else
- ff_float_interleave_c(dst, src, len, channels);
-}
-#endif /* HAVE_YASM */
-
-av_cold void ff_fmt_convert_init_x86(FmtConvertContext *c, AVCodecContext *avctx)
-{
-#if HAVE_YASM
- int mm_flags = av_get_cpu_flags();
-
- if (EXTERNAL_MMX(mm_flags)) {
- c->float_interleave = float_interleave_mmx;
-
- if (EXTERNAL_AMD3DNOW(mm_flags)) {
- if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
- c->float_to_int16 = ff_float_to_int16_3dnow;
- c->float_to_int16_interleave = float_to_int16_interleave_3dnow;
- }
- }
- if (EXTERNAL_AMD3DNOWEXT(mm_flags)) {
- if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
- c->float_to_int16_interleave = float_to_int16_interleave_3dnowext;
- }
- }
- if (EXTERNAL_SSE(mm_flags)) {
- c->int32_to_float_fmul_scalar = ff_int32_to_float_fmul_scalar_sse;
- c->float_to_int16 = ff_float_to_int16_sse;
- c->float_to_int16_interleave = float_to_int16_interleave_sse;
- c->float_interleave = float_interleave_sse;
- }
- if (EXTERNAL_SSE2(mm_flags)) {
- c->int32_to_float_fmul_scalar = ff_int32_to_float_fmul_scalar_sse2;
- c->float_to_int16 = ff_float_to_int16_sse2;
- c->float_to_int16_interleave = float_to_int16_interleave_sse2;
- }
- }
-#endif /* HAVE_YASM */
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/h264_chromamc.asm b/src/thirdparty/ffmpeg/libavcodec/x86/h264_chromamc.asm
deleted file mode 100644
index f5b8c9194..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/h264_chromamc.asm
+++ /dev/null
@@ -1,678 +0,0 @@
-;******************************************************************************
-;* MMX/SSSE3-optimized functions for H264 chroma MC
-;* Copyright (c) 2005 Zoltan Hidvegi <hzoli -a- hzoli -d- com>,
-;* 2005-2008 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_RODATA
-
-rnd_rv40_2d_tbl: times 4 dw 0
- times 4 dw 16
- times 4 dw 32
- times 4 dw 16
- times 4 dw 32
- times 4 dw 28
- times 4 dw 32
- times 4 dw 28
- times 4 dw 0
- times 4 dw 32
- times 4 dw 16
- times 4 dw 32
- times 4 dw 32
- times 4 dw 28
- times 4 dw 32
- times 4 dw 28
-rnd_rv40_1d_tbl: times 4 dw 0
- times 4 dw 2
- times 4 dw 4
- times 4 dw 2
- times 4 dw 4
- times 4 dw 3
- times 4 dw 4
- times 4 dw 3
- times 4 dw 0
- times 4 dw 4
- times 4 dw 2
- times 4 dw 4
- times 4 dw 4
- times 4 dw 3
- times 4 dw 4
- times 4 dw 3
-
-cextern pw_3
-cextern pw_4
-cextern pw_8
-cextern pw_28
-cextern pw_32
-cextern pw_64
-
-SECTION .text
-
-%macro mv0_pixels_mc8 0
- lea r4, [r2*2 ]
-.next4rows:
- movq mm0, [r1 ]
- movq mm1, [r1+r2]
- add r1, r4
- CHROMAMC_AVG mm0, [r0 ]
- CHROMAMC_AVG mm1, [r0+r2]
- movq [r0 ], mm0
- movq [r0+r2], mm1
- add r0, r4
- movq mm0, [r1 ]
- movq mm1, [r1+r2]
- add r1, r4
- CHROMAMC_AVG mm0, [r0 ]
- CHROMAMC_AVG mm1, [r0+r2]
- movq [r0 ], mm0
- movq [r0+r2], mm1
- add r0, r4
- sub r3d, 4
- jne .next4rows
-%endmacro
-
-%macro chroma_mc8_mmx_func 2-3
-%ifidn %2, rv40
-%ifdef PIC
-%define rnd_1d_rv40 r8
-%define rnd_2d_rv40 r8
-%define extra_regs 2
-%else ; no-PIC
-%define rnd_1d_rv40 rnd_rv40_1d_tbl
-%define rnd_2d_rv40 rnd_rv40_2d_tbl
-%define extra_regs 1
-%endif ; PIC
-%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)
-cglobal %1_%2_chroma_mc8%3, 6, 7 + extra_regs, 0
-%if ARCH_X86_64
- movsxd r2, r2d
-%endif
- mov r6d, r5d
- or r6d, r4d
- jne .at_least_one_non_zero
- ; mx == 0 AND my == 0 - no filter needed
- mv0_pixels_mc8
- REP_RET
-
-.at_least_one_non_zero:
-%ifidn %2, rv40
-%if ARCH_X86_64
- mov r7, r5
- and r7, 6 ; &~1 for mx/my=[0,7]
- lea r7, [r7*4+r4]
- sar r7d, 1
-%define rnd_bias r7
-%define dest_reg r0
-%else ; x86-32
- mov r0, r5
- and r0, 6 ; &~1 for mx/my=[0,7]
- lea r0, [r0*4+r4]
- sar r0d, 1
-%define rnd_bias r0
-%define dest_reg r5
-%endif
-%else ; vc1, h264
-%define rnd_bias 0
-%define dest_reg r0
-%endif
-
- test r5d, r5d
- mov r6, 1
- je .my_is_zero
- test r4d, r4d
- mov r6, r2 ; dxy = x ? 1 : stride
- jne .both_non_zero
-.my_is_zero:
- ; mx == 0 XOR my == 0 - 1 dimensional filter only
- or r4d, r5d ; x + y
-
-%ifidn %2, rv40
-%ifdef PIC
- lea r8, [rnd_rv40_1d_tbl]
-%endif
-%if ARCH_X86_64 == 0
- mov r5, r0m
-%endif
-%endif
-
- movd m5, r4d
- movq m4, [pw_8]
- movq m6, [rnd_1d_%2+rnd_bias*8] ; mm6 = rnd >> 3
- punpcklwd m5, m5
- punpckldq m5, m5 ; mm5 = B = x
- pxor m7, m7
- psubw m4, m5 ; mm4 = A = 8-x
-
-.next1drow:
- movq m0, [r1 ] ; mm0 = src[0..7]
- movq m2, [r1+r6] ; mm1 = src[1..8]
-
- movq m1, m0
- movq m3, m2
- punpcklbw m0, m7
- punpckhbw m1, m7
- punpcklbw m2, m7
- punpckhbw m3, m7
- pmullw m0, m4 ; [mm0,mm1] = A * src[0..7]
- pmullw m1, m4
- pmullw m2, m5 ; [mm2,mm3] = B * src[1..8]
- pmullw m3, m5
-
- paddw m0, m6
- paddw m1, m6
- paddw m0, m2
- paddw m1, m3
- psrlw m0, 3
- psrlw m1, 3
- packuswb m0, m1
- CHROMAMC_AVG m0, [dest_reg]
- movq [dest_reg], m0 ; dst[0..7] = (A * src[0..7] + B * src[1..8] + (rnd >> 3)) >> 3
-
- add dest_reg, r2
- add r1, r2
- dec r3d
- jne .next1drow
- REP_RET
-
-.both_non_zero: ; general case, bilinear
- movd m4, r4d ; x
- movd m6, r5d ; y
-%ifidn %2, rv40
-%ifdef PIC
- lea r8, [rnd_rv40_2d_tbl]
-%endif
-%if ARCH_X86_64 == 0
- mov r5, r0m
-%endif
-%endif
- mov r6, rsp ; backup stack pointer
- and rsp, ~(mmsize-1) ; align stack
- sub rsp, 16 ; AA and DD
-
- punpcklwd m4, m4
- punpcklwd m6, m6
- punpckldq m4, m4 ; mm4 = x words
- punpckldq m6, m6 ; mm6 = y words
- movq m5, m4
- pmullw m4, m6 ; mm4 = x * y
- psllw m5, 3
- psllw m6, 3
- movq m7, m5
- paddw m7, m6
- movq [rsp+8], m4 ; DD = x * y
- psubw m5, m4 ; mm5 = B = 8x - xy
- psubw m6, m4 ; mm6 = C = 8y - xy
- paddw m4, [pw_64]
- psubw m4, m7 ; mm4 = A = xy - (8x+8y) + 64
- pxor m7, m7
- movq [rsp ], m4
-
- movq m0, [r1 ] ; mm0 = src[0..7]
- movq m1, [r1+1] ; mm1 = src[1..8]
-.next2drow:
- add r1, r2
-
- movq m2, m0
- movq m3, m1
- punpckhbw m0, m7
- punpcklbw m1, m7
- punpcklbw m2, m7
- punpckhbw m3, m7
- pmullw m0, [rsp]
- pmullw m2, [rsp]
- pmullw m1, m5
- pmullw m3, m5
- paddw m2, m1 ; mm2 = A * src[0..3] + B * src[1..4]
- paddw m3, m0 ; mm3 = A * src[4..7] + B * src[5..8]
-
- movq m0, [r1]
- movq m1, m0
- punpcklbw m0, m7
- punpckhbw m1, m7
- pmullw m0, m6
- pmullw m1, m6
- paddw m2, m0
- paddw m3, m1 ; [mm2,mm3] += C * src[0..7]
-
- movq m1, [r1+1]
- movq m0, m1
- movq m4, m1
- punpcklbw m0, m7
- punpckhbw m4, m7
- pmullw m0, [rsp+8]
- pmullw m4, [rsp+8]
- paddw m2, m0
- paddw m3, m4 ; [mm2,mm3] += D * src[1..8]
- movq m0, [r1]
-
- paddw m2, [rnd_2d_%2+rnd_bias*8]
- paddw m3, [rnd_2d_%2+rnd_bias*8]
- psrlw m2, 6
- psrlw m3, 6
- packuswb m2, m3
- CHROMAMC_AVG m2, [dest_reg]
- movq [dest_reg], m2 ; dst[0..7] = ([mm2,mm3] + rnd) >> 6
-
- add dest_reg, r2
- dec r3d
- jne .next2drow
- mov rsp, r6 ; restore stack pointer
- RET
-%endmacro
-
-%macro chroma_mc4_mmx_func 2
-%define extra_regs 0
-%ifidn %2, rv40
-%ifdef PIC
-%define extra_regs 1
-%endif ; PIC
-%endif ; rv40
-cglobal %1_%2_chroma_mc4, 6, 6 + extra_regs, 0
-%if ARCH_X86_64
- movsxd r2, r2d
-%endif
- pxor m7, m7
- movd m2, r4d ; x
- movd m3, r5d ; y
- movq m4, [pw_8]
- movq m5, [pw_8]
- punpcklwd m2, m2
- punpcklwd m3, m3
- punpcklwd m2, m2
- punpcklwd m3, m3
- psubw m4, m2
- psubw m5, m3
-
-%ifidn %2, rv40
-%ifdef PIC
- lea r6, [rnd_rv40_2d_tbl]
-%define rnd_2d_rv40 r6
-%else
-%define rnd_2d_rv40 rnd_rv40_2d_tbl
-%endif
- and r5, 6 ; &~1 for mx/my=[0,7]
- lea r5, [r5*4+r4]
- sar r5d, 1
-%define rnd_bias r5
-%else ; vc1, h264
-%define rnd_bias 0
-%endif
-
- movd m0, [r1 ]
- movd m6, [r1+1]
- add r1, r2
- punpcklbw m0, m7
- punpcklbw m6, m7
- pmullw m0, m4
- pmullw m6, m2
- paddw m6, m0
-
-.next2rows:
- movd m0, [r1 ]
- movd m1, [r1+1]
- add r1, r2
- punpcklbw m0, m7
- punpcklbw m1, m7
- pmullw m0, m4
- pmullw m1, m2
- paddw m1, m0
- movq m0, m1
-
- pmullw m6, m5
- pmullw m1, m3
- paddw m6, [rnd_2d_%2+rnd_bias*8]
- paddw m1, m6
- psrlw m1, 6
- packuswb m1, m1
- CHROMAMC_AVG4 m1, m6, [r0]
- movd [r0], m1
- add r0, r2
-
- movd m6, [r1 ]
- movd m1, [r1+1]
- add r1, r2
- punpcklbw m6, m7
- punpcklbw m1, m7
- pmullw m6, m4
- pmullw m1, m2
- paddw m1, m6
- movq m6, m1
- pmullw m0, m5
- pmullw m1, m3
- paddw m0, [rnd_2d_%2+rnd_bias*8]
- paddw m1, m0
- psrlw m1, 6
- packuswb m1, m1
- CHROMAMC_AVG4 m1, m0, [r0]
- movd [r0], m1
- add r0, r2
- sub r3d, 2
- jnz .next2rows
- REP_RET
-%endmacro
-
-%macro chroma_mc2_mmx_func 2
-cglobal %1_%2_chroma_mc2, 6, 7, 0
-%if ARCH_X86_64
- movsxd r2, r2d
-%endif
-
- mov r6d, r4d
- shl r4d, 16
- sub r4d, r6d
- add r4d, 8
- imul r5d, r4d ; x*y<<16 | y*(8-x)
- shl r4d, 3
- sub r4d, r5d ; x*(8-y)<<16 | (8-x)*(8-y)
-
- movd m5, r4d
- movd m6, r5d
- punpckldq m5, m5 ; mm5 = {A,B,A,B}
- punpckldq m6, m6 ; mm6 = {C,D,C,D}
- pxor m7, m7
- movd m2, [r1]
- punpcklbw m2, m7
- pshufw m2, m2, 0x94 ; mm0 = src[0,1,1,2]
-
-.nextrow:
- add r1, r2
- movq m1, m2
- pmaddwd m1, m5 ; mm1 = A * src[0,1] + B * src[1,2]
- movd m0, [r1]
- punpcklbw m0, m7
- pshufw m0, m0, 0x94 ; mm0 = src[0,1,1,2]
- movq m2, m0
- pmaddwd m0, m6
- paddw m1, [rnd_2d_%2]
- paddw m1, m0 ; mm1 += C * src[0,1] + D * src[1,2]
- psrlw m1, 6
- packssdw m1, m7
- packuswb m1, m7
- CHROMAMC_AVG4 m1, m3, [r0]
- movd r5d, m1
- mov [r0], r5w
- add r0, r2
- sub r3d, 1
- jnz .nextrow
- REP_RET
-%endmacro
-
-%define rnd_1d_h264 pw_4
-%define rnd_2d_h264 pw_32
-%define rnd_1d_vc1 pw_3
-%define rnd_2d_vc1 pw_28
-
-%macro NOTHING 2-3
-%endmacro
-%macro DIRECT_AVG 2
- PAVGB %1, %2
-%endmacro
-%macro COPY_AVG 3
- movd %2, %3
- PAVGB %1, %2
-%endmacro
-
-INIT_MMX mmx
-%define CHROMAMC_AVG NOTHING
-%define CHROMAMC_AVG4 NOTHING
-chroma_mc8_mmx_func put, h264, _rnd
-chroma_mc8_mmx_func put, vc1, _nornd
-chroma_mc8_mmx_func put, rv40
-chroma_mc4_mmx_func put, h264
-chroma_mc4_mmx_func put, rv40
-
-INIT_MMX mmxext
-chroma_mc2_mmx_func put, h264
-
-%define CHROMAMC_AVG DIRECT_AVG
-%define CHROMAMC_AVG4 COPY_AVG
-chroma_mc8_mmx_func avg, h264, _rnd
-chroma_mc8_mmx_func avg, vc1, _nornd
-chroma_mc8_mmx_func avg, rv40
-chroma_mc4_mmx_func avg, h264
-chroma_mc4_mmx_func avg, rv40
-chroma_mc2_mmx_func avg, h264
-
-INIT_MMX 3dnow
-chroma_mc8_mmx_func avg, h264, _rnd
-chroma_mc8_mmx_func avg, vc1, _nornd
-chroma_mc8_mmx_func avg, rv40
-chroma_mc4_mmx_func avg, h264
-chroma_mc4_mmx_func avg, rv40
-
-%macro chroma_mc8_ssse3_func 2-3
-cglobal %1_%2_chroma_mc8%3, 6, 7, 8
-%if ARCH_X86_64
- movsxd r2, r2d
-%endif
- mov r6d, r5d
- or r6d, r4d
- jne .at_least_one_non_zero
- ; mx == 0 AND my == 0 - no filter needed
- mv0_pixels_mc8
- REP_RET
-
-.at_least_one_non_zero:
- test r5d, r5d
- je .my_is_zero
- test r4d, r4d
- je .mx_is_zero
-
- ; general case, bilinear
- mov r6d, r4d
- shl r4d, 8
- sub r4, r6
- mov r6, 8
- add r4, 8 ; x*288+8 = x<<8 | (8-x)
- sub r6d, r5d
- imul r6, r4 ; (8-y)*(x*255+8) = (8-y)*x<<8 | (8-y)*(8-x)
- imul r4d, r5d ; y *(x*255+8) = y *x<<8 | y *(8-x)
-
- movd m7, r6d
- movd m6, r4d
- movdqa m5, [rnd_2d_%2]
- movq m0, [r1 ]
- movq m1, [r1+1]
- pshuflw m7, m7, 0
- pshuflw m6, m6, 0
- punpcklbw m0, m1
- movlhps m7, m7
- movlhps m6, m6
-
-.next2rows:
- movq m1, [r1+r2*1 ]
- movq m2, [r1+r2*1+1]
- movq m3, [r1+r2*2 ]
- movq m4, [r1+r2*2+1]
- lea r1, [r1+r2*2]
- punpcklbw m1, m2
- movdqa m2, m1
- punpcklbw m3, m4
- movdqa m4, m3
- pmaddubsw m0, m7
- pmaddubsw m1, m6
- pmaddubsw m2, m7
- pmaddubsw m3, m6
- paddw m0, m5
- paddw m2, m5
- paddw m1, m0
- paddw m3, m2
- psrlw m1, 6
- movdqa m0, m4
- psrlw m3, 6
-%ifidn %1, avg
- movq m2, [r0 ]
- movhps m2, [r0+r2]
-%endif
- packuswb m1, m3
- CHROMAMC_AVG m1, m2
- movq [r0 ], m1
- movhps [r0+r2], m1
- sub r3d, 2
- lea r0, [r0+r2*2]
- jg .next2rows
- REP_RET
-
-.my_is_zero:
- mov r5d, r4d
- shl r4d, 8
- add r4, 8
- sub r4, r5 ; 255*x+8 = x<<8 | (8-x)
- movd m7, r4d
- movdqa m6, [rnd_1d_%2]
- pshuflw m7, m7, 0
- movlhps m7, m7
-
-.next2xrows:
- movq m0, [r1 ]
- movq m1, [r1 +1]
- movq m2, [r1+r2 ]
- movq m3, [r1+r2+1]
- punpcklbw m0, m1
- punpcklbw m2, m3
- pmaddubsw m0, m7
- pmaddubsw m2, m7
-%ifidn %1, avg
- movq m4, [r0 ]
- movhps m4, [r0+r2]
-%endif
- paddw m0, m6
- paddw m2, m6
- psrlw m0, 3
- psrlw m2, 3
- packuswb m0, m2
- CHROMAMC_AVG m0, m4
- movq [r0 ], m0
- movhps [r0+r2], m0
- sub r3d, 2
- lea r0, [r0+r2*2]
- lea r1, [r1+r2*2]
- jg .next2xrows
- REP_RET
-
-.mx_is_zero:
- mov r4d, r5d
- shl r5d, 8
- add r5, 8
- sub r5, r4 ; 255*y+8 = y<<8 | (8-y)
- movd m7, r5d
- movdqa m6, [rnd_1d_%2]
- pshuflw m7, m7, 0
- movlhps m7, m7
-
-.next2yrows:
- movq m0, [r1 ]
- movq m1, [r1+r2 ]
- movdqa m2, m1
- movq m3, [r1+r2*2]
- lea r1, [r1+r2*2]
- punpcklbw m0, m1
- punpcklbw m2, m3
- pmaddubsw m0, m7
- pmaddubsw m2, m7
-%ifidn %1, avg
- movq m4, [r0 ]
- movhps m4, [r0+r2]
-%endif
- paddw m0, m6
- paddw m2, m6
- psrlw m0, 3
- psrlw m2, 3
- packuswb m0, m2
- CHROMAMC_AVG m0, m4
- movq [r0 ], m0
- movhps [r0+r2], m0
- sub r3d, 2
- lea r0, [r0+r2*2]
- jg .next2yrows
- REP_RET
-%endmacro
-
-%macro chroma_mc4_ssse3_func 2
-cglobal %1_%2_chroma_mc4, 6, 7, 0
-%if ARCH_X86_64
- movsxd r2, r2d
-%endif
- mov r6, r4
- shl r4d, 8
- sub r4d, r6d
- mov r6, 8
- add r4d, 8 ; x*288+8
- sub r6d, r5d
- imul r6d, r4d ; (8-y)*(x*255+8) = (8-y)*x<<8 | (8-y)*(8-x)
- imul r4d, r5d ; y *(x*255+8) = y *x<<8 | y *(8-x)
-
- movd m7, r6d
- movd m6, r4d
- movq m5, [pw_32]
- movd m0, [r1 ]
- pshufw m7, m7, 0
- punpcklbw m0, [r1+1]
- pshufw m6, m6, 0
-
-.next2rows:
- movd m1, [r1+r2*1 ]
- movd m3, [r1+r2*2 ]
- punpcklbw m1, [r1+r2*1+1]
- punpcklbw m3, [r1+r2*2+1]
- lea r1, [r1+r2*2]
- movq m2, m1
- movq m4, m3
- pmaddubsw m0, m7
- pmaddubsw m1, m6
- pmaddubsw m2, m7
- pmaddubsw m3, m6
- paddw m0, m5
- paddw m2, m5
- paddw m1, m0
- paddw m3, m2
- psrlw m1, 6
- movq m0, m4
- psrlw m3, 6
- packuswb m1, m1
- packuswb m3, m3
- CHROMAMC_AVG m1, [r0 ]
- CHROMAMC_AVG m3, [r0+r2]
- movd [r0 ], m1
- movd [r0+r2], m3
- sub r3d, 2
- lea r0, [r0+r2*2]
- jg .next2rows
- REP_RET
-%endmacro
-
-%define CHROMAMC_AVG NOTHING
-INIT_XMM ssse3
-chroma_mc8_ssse3_func put, h264, _rnd
-chroma_mc8_ssse3_func put, vc1, _nornd
-INIT_MMX ssse3
-chroma_mc4_ssse3_func put, h264
-
-%define CHROMAMC_AVG DIRECT_AVG
-INIT_XMM ssse3
-chroma_mc8_ssse3_func avg, h264, _rnd
-chroma_mc8_ssse3_func avg, vc1, _nornd
-INIT_MMX ssse3
-chroma_mc4_ssse3_func avg, h264
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/h264_chromamc_10bit.asm b/src/thirdparty/ffmpeg/libavcodec/x86/h264_chromamc_10bit.asm
deleted file mode 100644
index eda833cc0..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/h264_chromamc_10bit.asm
+++ /dev/null
@@ -1,271 +0,0 @@
-;*****************************************************************************
-;* MMX/SSE2/AVX-optimized 10-bit H.264 chroma MC code
-;*****************************************************************************
-;* Copyright (C) 2005-2011 x264 project
-;*
-;* Authors: Daniel Kang <daniel.d.kang@gmail.com>
-;*
-;* This file is part of Libav.
-;*
-;* Libav is free software; you can redistribute it and/or
-;* modify it under the terms of the GNU Lesser General Public
-;* License as published by the Free Software Foundation; either
-;* version 2.1 of the License, or (at your option) any later version.
-;*
-;* Libav is distributed in the hope that it will be useful,
-;* but WITHOUT ANY WARRANTY; without even the implied warranty of
-;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-;* Lesser General Public License for more details.
-;*
-;* You should have received a copy of the GNU Lesser General Public
-;* License along with Libav; if not, write to the Free Software
-;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-;******************************************************************************
-
-%include "libavutil/x86/x86util.asm"
-
-SECTION_RODATA
-
-cextern pw_4
-cextern pw_8
-cextern pw_32
-cextern pw_64
-
-SECTION .text
-
-
-%macro MV0_PIXELS_MC8 0
- lea r4, [r2*3 ]
- lea r5, [r2*4 ]
-.next4rows:
- movu m0, [r1 ]
- movu m1, [r1+r2 ]
- CHROMAMC_AVG m0, [r0 ]
- CHROMAMC_AVG m1, [r0+r2 ]
- mova [r0 ], m0
- mova [r0+r2 ], m1
- movu m0, [r1+r2*2]
- movu m1, [r1+r4 ]
- CHROMAMC_AVG m0, [r0+r2*2]
- CHROMAMC_AVG m1, [r0+r4 ]
- mova [r0+r2*2], m0
- mova [r0+r4 ], m1
- add r1, r5
- add r0, r5
- sub r3d, 4
- jne .next4rows
-%endmacro
-
-;-----------------------------------------------------------------------------
-; void 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
- or r6d, r4d
- jne .at_least_one_non_zero
- ; mx == 0 AND my == 0 - no filter needed
- MV0_PIXELS_MC8
- REP_RET
-
-.at_least_one_non_zero:
- mov r6d, 2
- test r5d, r5d
- je .x_interpolation
- mov r6, r2 ; dxy = x ? 1 : stride
- test r4d, r4d
- jne .xy_interpolation
-.x_interpolation:
- ; mx == 0 XOR my == 0 - 1 dimensional filter only
- or r4d, r5d ; x + y
- movd m5, r4d
- mova m4, [pw_8]
- mova m6, [pw_4] ; mm6 = rnd >> 3
- SPLATW m5, m5 ; mm5 = B = x
- psubw m4, m5 ; mm4 = A = 8-x
-
-.next1drow:
- movu m0, [r1 ] ; mm0 = src[0..7]
- movu m2, [r1+r6] ; mm2 = src[1..8]
-
- pmullw m0, m4 ; mm0 = A * src[0..7]
- pmullw m2, m5 ; mm2 = B * src[1..8]
-
- paddw m0, m6
- paddw m0, m2
- psrlw m0, 3
- CHROMAMC_AVG m0, [r0]
- mova [r0], m0 ; dst[0..7] = (A * src[0..7] + B * src[1..8] + (rnd >> 3)) >> 3
-
- add r0, r2
- add r1, r2
- dec r3d
- jne .next1drow
- REP_RET
-
-.xy_interpolation: ; general case, bilinear
- movd m4, r4m ; x
- movd m6, r5m ; y
-
- SPLATW m4, m4 ; mm4 = x words
- SPLATW m6, m6 ; mm6 = y words
- psllw m5, m4, 3 ; mm5 = 8x
- pmullw m4, m6 ; mm4 = x * y
- psllw m6, 3 ; mm6 = 8y
- paddw m1, m5, m6 ; mm7 = 8x+8y
- mova m7, m4 ; DD = x * y
- psubw m5, m4 ; mm5 = B = 8x - xy
- psubw m6, m4 ; mm6 = C = 8y - xy
- paddw m4, [pw_64]
- psubw m4, m1 ; mm4 = A = xy - (8x+8y) + 64
-
- movu m0, [r1 ] ; mm0 = src[0..7]
- movu m1, [r1+2] ; mm1 = src[1..8]
-.next2drow:
- add r1, r2
-
- pmullw m2, m0, m4
- pmullw m1, m5
- paddw m2, m1 ; mm2 = A * src[0..7] + B * src[1..8]
-
- movu m0, [r1]
- movu m1, [r1+2]
- pmullw m3, m0, m6
- paddw m2, m3 ; mm2 += C * src[0..7+strde]
- pmullw m3, m1, m7
- paddw m2, m3 ; mm2 += D * src[1..8+strde]
-
- paddw m2, [pw_32]
- psrlw m2, 6
- CHROMAMC_AVG m2, [r0]
- mova [r0], m2 ; dst[0..7] = (mm2 + 32) >> 6
-
- add r0, r2
- dec r3d
- jne .next2drow
- REP_RET
-%endmacro
-
-;-----------------------------------------------------------------------------
-; void put/avg_h264_chroma_mc4(pixel *dst, pixel *src, int stride, int h, int mx, int my)
-;-----------------------------------------------------------------------------
-;TODO: xmm mc4
-%macro MC4_OP 2
- movq %1, [r1 ]
- movq m1, [r1+2]
- add r1, r2
- pmullw %1, m4
- pmullw m1, m2
- paddw m1, %1
- mova %1, m1
-
- pmullw %2, m5
- pmullw m1, m3
- paddw %2, [pw_32]
- paddw m1, %2
- psrlw m1, 6
- CHROMAMC_AVG m1, %2, [r0]
- movq [r0], m1
- add r0, r2
-%endmacro
-
-%macro CHROMA_MC4 1
-cglobal %1_h264_chroma_mc4_10, 6,6,7
- movsxdifnidn r2, r2d
- movd m2, r4m ; x
- movd m3, r5m ; y
- mova m4, [pw_8]
- mova m5, m4
- SPLATW m2, m2
- SPLATW m3, m3
- psubw m4, m2
- psubw m5, m3
-
- movq m0, [r1 ]
- movq m6, [r1+2]
- add r1, r2
- pmullw m0, m4
- pmullw m6, m2
- paddw m6, m0
-
-.next2rows:
- MC4_OP m0, m6
- MC4_OP m6, m0
- sub r3d, 2
- jnz .next2rows
- REP_RET
-%endmacro
-
-;-----------------------------------------------------------------------------
-; void 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
- movsxdifnidn r2, r2d
- mov r6d, r4d
- shl r4d, 16
- sub r4d, r6d
- add r4d, 8
- imul r5d, r4d ; x*y<<16 | y*(8-x)
- shl r4d, 3
- sub r4d, r5d ; x*(8-y)<<16 | (8-x)*(8-y)
-
- movd m5, r4d
- movd m6, r5d
- punpckldq m5, m5 ; mm5 = {A,B,A,B}
- punpckldq m6, m6 ; mm6 = {C,D,C,D}
- pxor m7, m7
- pshufw m2, [r1], 0x94 ; mm0 = src[0,1,1,2]
-
-.nextrow:
- add r1, r2
- movq m1, m2
- pmaddwd m1, m5 ; mm1 = A * src[0,1] + B * src[1,2]
- pshufw m0, [r1], 0x94 ; mm0 = src[0,1,1,2]
- movq m2, m0
- pmaddwd m0, m6
- paddw m1, [pw_32]
- paddw m1, m0 ; mm1 += C * src[0,1] + D * src[1,2]
- psrlw m1, 6
- packssdw m1, m7
- CHROMAMC_AVG m1, m3, [r0]
- movd [r0], m1
- add r0, r2
- dec r3d
- jnz .nextrow
- REP_RET
-%endmacro
-
-%macro NOTHING 2-3
-%endmacro
-%macro AVG 2-3
-%if %0==3
- movq %2, %3
-%endif
- pavgw %1, %2
-%endmacro
-
-%define CHROMAMC_AVG NOTHING
-INIT_XMM sse2
-CHROMA_MC8 put
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-CHROMA_MC8 put
-%endif
-INIT_MMX mmxext
-CHROMA_MC4 put
-CHROMA_MC2 put
-
-%define CHROMAMC_AVG AVG
-INIT_XMM sse2
-CHROMA_MC8 avg
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-CHROMA_MC8 avg
-%endif
-INIT_MMX mmxext
-CHROMA_MC4 avg
-CHROMA_MC2 avg
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/h264_deblock.asm b/src/thirdparty/ffmpeg/libavcodec/x86/h264_deblock.asm
deleted file mode 100644
index 4ca1c1697..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/h264_deblock.asm
+++ /dev/null
@@ -1,1075 +0,0 @@
-;*****************************************************************************
-;* MMX/SSE2/AVX-optimized H.264 deblocking code
-;*****************************************************************************
-;* Copyright (C) 2005-2011 x264 project
-;*
-;* Authors: Loren Merritt <lorenm@u.washington.edu>
-;* Jason Garrett-Glaser <darkshikari@gmail.com>
-;* Oskar Arvidsson <oskar@irock.se>
-;*
-;* 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_3_1: times 4 db 3, 1
-
-SECTION .text
-
-cextern pb_0
-cextern pb_1
-cextern pb_3
-cextern pb_A1
-
-; expands to [base],...,[base+7*stride]
-%define PASS8ROWS(base, base3, stride, stride3) \
- [base], [base+stride], [base+stride*2], [base3], \
- [base3+stride], [base3+stride*2], [base3+stride3], [base3+stride*4]
-
-%define PASS8ROWS(base, base3, stride, stride3, offset) \
- PASS8ROWS(base+offset, base3+offset, stride, stride3)
-
-; in: 8 rows of 4 bytes in %4..%11
-; out: 4 rows of 8 bytes in m0..m3
-%macro TRANSPOSE4x8_LOAD 11
- movh m0, %4
- movh m2, %5
- movh m1, %6
- movh m3, %7
- punpckl%1 m0, m2
- punpckl%1 m1, m3
- mova m2, m0
- punpckl%2 m0, m1
- punpckh%2 m2, m1
-
- movh m4, %8
- movh m6, %9
- movh m5, %10
- movh m7, %11
- punpckl%1 m4, m6
- punpckl%1 m5, m7
- mova m6, m4
- punpckl%2 m4, m5
- punpckh%2 m6, m5
-
- punpckh%3 m1, m0, m4
- punpckh%3 m3, m2, m6
- punpckl%3 m0, m4
- punpckl%3 m2, m6
-%endmacro
-
-; in: 4 rows of 8 bytes in m0..m3
-; out: 8 rows of 4 bytes in %1..%8
-%macro TRANSPOSE8x4B_STORE 8
- punpckhdq m4, m0, m0
- punpckhdq m5, m1, m1
- punpckhdq m6, m2, m2
-
- punpcklbw m0, m1
- punpcklbw m2, m3
- punpcklwd m1, m0, m2
- punpckhwd m0, m2
- movh %1, m1
- punpckhdq m1, m1
- movh %2, m1
- movh %3, m0
- punpckhdq m0, m0
- movh %4, m0
-
- punpckhdq m3, m3
- punpcklbw m4, m5
- punpcklbw m6, m3
- punpcklwd m5, m4, m6
- punpckhwd m4, m6
- movh %5, m5
- punpckhdq m5, m5
- movh %6, m5
- movh %7, m4
- punpckhdq m4, m4
- movh %8, m4
-%endmacro
-
-%macro TRANSPOSE4x8B_LOAD 8
- TRANSPOSE4x8_LOAD bw, wd, dq, %1, %2, %3, %4, %5, %6, %7, %8
-%endmacro
-
-%macro SBUTTERFLY3 4
- punpckh%1 %4, %2, %3
- punpckl%1 %2, %3
-%endmacro
-
-; in: 8 rows of 8 (only the middle 6 pels are used) in %1..%8
-; out: 6 rows of 8 in [%9+0*16] .. [%9+5*16]
-%macro TRANSPOSE6x8_MEM 9
- RESET_MM_PERMUTATION
- movq m0, %1
- movq m1, %2
- movq m2, %3
- movq m3, %4
- movq m4, %5
- movq m5, %6
- movq m6, %7
- SBUTTERFLY bw, 0, 1, 7
- SBUTTERFLY bw, 2, 3, 7
- SBUTTERFLY bw, 4, 5, 7
- movq [%9+0x10], m3
- SBUTTERFLY3 bw, m6, %8, m7
- SBUTTERFLY wd, 0, 2, 3
- SBUTTERFLY wd, 4, 6, 3
- punpckhdq m0, m4
- movq [%9+0x00], m0
- SBUTTERFLY3 wd, m1, [%9+0x10], m3
- SBUTTERFLY wd, 5, 7, 0
- SBUTTERFLY dq, 1, 5, 0
- SBUTTERFLY dq, 2, 6, 0
- punpckldq m3, m7
- movq [%9+0x10], m2
- movq [%9+0x20], m6
- movq [%9+0x30], m1
- movq [%9+0x40], m5
- movq [%9+0x50], m3
- RESET_MM_PERMUTATION
-%endmacro
-
-; in: 8 rows of 8 in %1..%8
-; out: 8 rows of 8 in %9..%16
-%macro TRANSPOSE8x8_MEM 16
- RESET_MM_PERMUTATION
- movq m0, %1
- movq m1, %2
- movq m2, %3
- movq m3, %4
- movq m4, %5
- movq m5, %6
- movq m6, %7
- SBUTTERFLY bw, 0, 1, 7
- SBUTTERFLY bw, 2, 3, 7
- SBUTTERFLY bw, 4, 5, 7
- SBUTTERFLY3 bw, m6, %8, m7
- movq %9, m5
- SBUTTERFLY wd, 0, 2, 5
- SBUTTERFLY wd, 4, 6, 5
- SBUTTERFLY wd, 1, 3, 5
- movq %11, m6
- movq m6, %9
- SBUTTERFLY wd, 6, 7, 5
- SBUTTERFLY dq, 0, 4, 5
- SBUTTERFLY dq, 1, 6, 5
- movq %9, m0
- movq %10, m4
- movq %13, m1
- movq %14, m6
- SBUTTERFLY3 dq, m2, %11, m0
- SBUTTERFLY dq, 3, 7, 4
- movq %11, m2
- movq %12, m0
- movq %15, m3
- movq %16, m7
- RESET_MM_PERMUTATION
-%endmacro
-
-; out: %4 = |%1-%2|>%3
-; clobbers: %5
-%macro DIFF_GT 5
-%if avx_enabled == 0
- mova %5, %2
- mova %4, %1
- psubusb %5, %1
- psubusb %4, %2
-%else
- psubusb %5, %2, %1
- psubusb %4, %1, %2
-%endif
- por %4, %5
- psubusb %4, %3
-%endmacro
-
-; out: %4 = |%1-%2|>%3
-; clobbers: %5
-%macro DIFF_GT2 5
-%if ARCH_X86_64
- psubusb %5, %2, %1
- psubusb %4, %1, %2
-%else
- mova %5, %2
- mova %4, %1
- psubusb %5, %1
- psubusb %4, %2
-%endif
- psubusb %5, %3
- psubusb %4, %3
- pcmpeqb %4, %5
-%endmacro
-
-; in: m0=p1 m1=p0 m2=q0 m3=q1 %1=alpha-1 %2=beta-1
-; out: m5=beta-1, m7=mask, %3=alpha-1
-; clobbers: m4,m6
-%macro LOAD_MASK 2-3
- movd m4, %1
- movd m5, %2
- SPLATW m4, m4
- SPLATW m5, m5
- packuswb m4, m4 ; 16x alpha-1
- packuswb m5, m5 ; 16x beta-1
-%if %0>2
- mova %3, m4
-%endif
- DIFF_GT m1, m2, m4, m7, m6 ; |p0-q0| > alpha-1
- DIFF_GT m0, m1, m5, m4, m6 ; |p1-p0| > beta-1
- por m7, m4
- DIFF_GT m3, m2, m5, m4, m6 ; |q1-q0| > beta-1
- por m7, m4
- pxor m6, m6
- pcmpeqb m7, m6
-%endmacro
-
-; in: m0=p1 m1=p0 m2=q0 m3=q1 m7=(tc&mask)
-; out: m1=p0' m2=q0'
-; clobbers: m0,3-6
-%macro DEBLOCK_P0_Q0 0
- pcmpeqb m4, m4
- pxor m5, m1, m2 ; p0^q0
- pxor m3, m4
- pand m5, [pb_1] ; (p0^q0)&1
- pavgb m3, m0 ; (p1 - q1 + 256)>>1
- pxor m4, m1
- pavgb m3, [pb_3] ; (((p1 - q1 + 256)>>1)+4)>>1 = 64+2+(p1-q1)>>2
- pavgb m4, m2 ; (q0 - p0 + 256)>>1
- pavgb m3, m5
- mova m6, [pb_A1]
- paddusb m3, m4 ; d+128+33
- psubusb m6, m3
- psubusb m3, [pb_A1]
- pminub m6, m7
- pminub m3, m7
- psubusb m1, m6
- psubusb m2, m3
- paddusb m1, m3
- paddusb m2, m6
-%endmacro
-
-; in: m1=p0 m2=q0
-; %1=p1 %2=q2 %3=[q2] %4=[q1] %5=tc0 %6=tmp
-; out: [q1] = clip( (q2+((p0+q0+1)>>1))>>1, q1-tc0, q1+tc0 )
-; clobbers: q2, tmp, tc0
-%macro LUMA_Q1 6
- pavgb %6, m1, m2
- pavgb %2, %6 ; avg(p2,avg(p0,q0))
- pxor %6, %3
- pand %6, [pb_1] ; (p2^avg(p0,q0))&1
- psubusb %2, %6 ; (p2+((p0+q0+1)>>1))>>1
- psubusb %6, %1, %5
- paddusb %5, %1
- pmaxub %2, %6
- pminub %2, %5
- mova %4, %2
-%endmacro
-
-%if ARCH_X86_64
-;-----------------------------------------------------------------------------
-; void 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
- movd m8, [r4] ; tc0
- lea r4, [r1*3]
- dec r2d ; alpha-1
- neg r4
- dec r3d ; beta-1
- add r4, r0 ; pix-3*stride
-
- mova m0, [r4+r1] ; p1
- mova m1, [r4+2*r1] ; p0
- mova m2, [r0] ; q0
- mova m3, [r0+r1] ; q1
- LOAD_MASK r2d, r3d
-
- punpcklbw m8, m8
- punpcklbw m8, m8 ; tc = 4x tc0[3], 4x tc0[2], 4x tc0[1], 4x tc0[0]
- pcmpeqb m9, m9
- pcmpeqb m9, m8
- pandn m9, m7
- pand m8, m9
-
- movdqa m3, [r4] ; p2
- DIFF_GT2 m1, m3, m5, m6, m7 ; |p2-p0| > beta-1
- pand m6, m9
- psubb m7, m8, m6
- pand m6, m8
- LUMA_Q1 m0, m3, [r4], [r4+r1], m6, m4
-
- movdqa m4, [r0+2*r1] ; q2
- DIFF_GT2 m2, m4, m5, m6, m3 ; |q2-q0| > beta-1
- pand m6, m9
- pand m8, m6
- psubb m7, m6
- mova m3, [r0+r1]
- LUMA_Q1 m3, m4, [r0+2*r1], [r0+r1], m8, m6
-
- DEBLOCK_P0_Q0
- mova [r4+2*r1], m1
- mova [r0], m2
- RET
-
-;-----------------------------------------------------------------------------
-; void 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
- movsxd r7, r1d
- lea r8, [r7+r7*2]
- lea r6, [r0-4]
- lea r5, [r0-4+r8]
-%if WIN64
- sub rsp, 0x98
- %define pix_tmp rsp+0x30
-%else
- sub rsp, 0x68
- %define pix_tmp rsp
-%endif
-
- ; transpose 6x16 -> tmp space
- TRANSPOSE6x8_MEM PASS8ROWS(r6, r5, r7, r8), pix_tmp
- lea r6, [r6+r7*8]
- lea r5, [r5+r7*8]
- TRANSPOSE6x8_MEM PASS8ROWS(r6, r5, r7, r8), pix_tmp+8
-
- ; vertical filter
- ; alpha, beta, tc0 are still in r2d, r3d, r4
- ; don't backup r6, r5, r7, r8 because deblock_v_luma_sse2 doesn't use them
- lea r0, [pix_tmp+0x30]
- mov r1d, 0x10
-%if WIN64
- mov [rsp+0x20], r4
-%endif
- call deblock_v_luma_8
-
- ; transpose 16x4 -> original space (only the middle 4 rows were changed by the filter)
- add r6, 2
- add r5, 2
- movq m0, [pix_tmp+0x18]
- movq m1, [pix_tmp+0x28]
- movq m2, [pix_tmp+0x38]
- movq m3, [pix_tmp+0x48]
- TRANSPOSE8x4B_STORE PASS8ROWS(r6, r5, r7, r8)
-
- shl r7, 3
- sub r6, r7
- sub r5, r7
- shr r7, 3
- movq m0, [pix_tmp+0x10]
- movq m1, [pix_tmp+0x20]
- movq m2, [pix_tmp+0x30]
- movq m3, [pix_tmp+0x40]
- TRANSPOSE8x4B_STORE PASS8ROWS(r6, r5, r7, r8)
-
-%if WIN64
- add rsp, 0x98
-%else
- add rsp, 0x68
-%endif
- RET
-%endmacro
-
-INIT_XMM sse2
-DEBLOCK_LUMA
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-DEBLOCK_LUMA
-%endif
-
-%else
-
-%macro DEBLOCK_LUMA 2
-;-----------------------------------------------------------------------------
-; void 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]
- dec r2 ; alpha-1
- neg r4
- dec r3 ; beta-1
- add r4, r0 ; pix-3*stride
-
- mova m0, [r4+r1] ; p1
- mova m1, [r4+2*r1] ; p0
- mova m2, [r0] ; q0
- mova m3, [r0+r1] ; q1
- LOAD_MASK r2, r3
-
- mov r3, r4mp
- pcmpeqb m3, m3
- movd m4, [r3] ; tc0
- punpcklbw m4, m4
- punpcklbw m4, m4 ; tc = 4x tc0[3], 4x tc0[2], 4x tc0[1], 4x tc0[0]
- mova [esp+%2], m4 ; tc
- pcmpgtb m4, m3
- mova m3, [r4] ; p2
- pand m4, m7
- mova [esp], m4 ; mask
-
- DIFF_GT2 m1, m3, m5, m6, m7 ; |p2-p0| > beta-1
- pand m6, m4
- pand m4, [esp+%2] ; tc
- psubb m7, m4, m6
- pand m6, m4
- LUMA_Q1 m0, m3, [r4], [r4+r1], m6, m4
-
- mova m4, [r0+2*r1] ; q2
- DIFF_GT2 m2, m4, m5, m6, m3 ; |q2-q0| > beta-1
- pand m6, [esp] ; mask
- mova m5, [esp+%2] ; tc
- psubb m7, m6
- pand m5, m6
- mova m3, [r0+r1]
- LUMA_Q1 m3, m4, [r0+2*r1], [r0+r1], m5, m6
-
- DEBLOCK_P0_Q0
- mova [r4+2*r1], m1
- mova [r0], m2
- RET
-
-;-----------------------------------------------------------------------------
-; void 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
- mov r0, r0mp
- mov r3, r1m
- lea r4, [r3*3]
- sub r0, 4
- lea r1, [r0+r4]
-%define pix_tmp esp+12*HAVE_ALIGNED_STACK
-
- ; transpose 6x16 -> tmp space
- TRANSPOSE6x8_MEM PASS8ROWS(r0, r1, r3, r4), pix_tmp
- lea r0, [r0+r3*8]
- lea r1, [r1+r3*8]
- TRANSPOSE6x8_MEM PASS8ROWS(r0, r1, r3, r4), pix_tmp+8
-
- ; vertical filter
- lea r0, [pix_tmp+0x30]
- PUSH dword r4m
- PUSH dword r3m
- PUSH dword r2m
- PUSH dword 16
- PUSH dword r0
- call deblock_%1_luma_8
-%ifidn %1, v8
- add dword [esp ], 8 ; pix_tmp+0x38
- add dword [esp+16], 2 ; tc0+2
- call deblock_%1_luma_8
-%endif
- ADD esp, 20
-
- ; transpose 16x4 -> original space (only the middle 4 rows were changed by the filter)
- mov r0, r0mp
- sub r0, 2
-
- movq m0, [pix_tmp+0x10]
- movq m1, [pix_tmp+0x20]
- lea r1, [r0+r4]
- movq m2, [pix_tmp+0x30]
- movq m3, [pix_tmp+0x40]
- TRANSPOSE8x4B_STORE PASS8ROWS(r0, r1, r3, r4)
-
- lea r0, [r0+r3*8]
- lea r1, [r1+r3*8]
- movq m0, [pix_tmp+0x18]
- movq m1, [pix_tmp+0x28]
- movq m2, [pix_tmp+0x38]
- movq m3, [pix_tmp+0x48]
- TRANSPOSE8x4B_STORE PASS8ROWS(r0, r1, r3, r4)
-
- RET
-%endmacro ; DEBLOCK_LUMA
-
-INIT_MMX mmxext
-DEBLOCK_LUMA v8, 8
-INIT_XMM sse2
-DEBLOCK_LUMA v, 16
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-DEBLOCK_LUMA v, 16
-%endif
-
-%endif ; ARCH
-
-
-
-%macro LUMA_INTRA_P012 4 ; p0..p3 in memory
-%if ARCH_X86_64
- pavgb t0, p2, p1
- pavgb t1, p0, q0
-%else
- mova t0, p2
- mova t1, p0
- pavgb t0, p1
- pavgb t1, q0
-%endif
- pavgb t0, t1 ; ((p2+p1+1)/2 + (p0+q0+1)/2 + 1)/2
- mova t5, t1
-%if ARCH_X86_64
- paddb t2, p2, p1
- paddb t3, p0, q0
-%else
- mova t2, p2
- mova t3, p0
- paddb t2, p1
- paddb t3, q0
-%endif
- paddb t2, t3
- mova t3, t2
- mova t4, t2
- psrlw t2, 1
- pavgb t2, mpb_0
- pxor t2, t0
- pand t2, mpb_1
- psubb t0, t2 ; p1' = (p2+p1+p0+q0+2)/4;
-
-%if ARCH_X86_64
- pavgb t1, p2, q1
- psubb t2, p2, q1
-%else
- mova t1, p2
- mova t2, p2
- pavgb t1, q1
- psubb t2, q1
-%endif
- paddb t3, t3
- psubb t3, t2 ; p2+2*p1+2*p0+2*q0+q1
- pand t2, mpb_1
- psubb t1, t2
- pavgb t1, p1
- pavgb t1, t5 ; (((p2+q1)/2 + p1+1)/2 + (p0+q0+1)/2 + 1)/2
- psrlw t3, 2
- pavgb t3, mpb_0
- pxor t3, t1
- pand t3, mpb_1
- psubb t1, t3 ; p0'a = (p2+2*p1+2*p0+2*q0+q1+4)/8
-
- pxor t3, p0, q1
- pavgb t2, p0, q1
- pand t3, mpb_1
- psubb t2, t3
- pavgb t2, p1 ; p0'b = (2*p1+p0+q0+2)/4
-
- pxor t1, t2
- pxor t2, p0
- pand t1, mask1p
- pand t2, mask0
- pxor t1, t2
- pxor t1, p0
- mova %1, t1 ; store p0
-
- mova t1, %4 ; p3
- paddb t2, t1, p2
- pavgb t1, p2
- pavgb t1, t0 ; (p3+p2+1)/2 + (p2+p1+p0+q0+2)/4
- paddb t2, t2
- paddb t2, t4 ; 2*p3+3*p2+p1+p0+q0
- psrlw t2, 2
- pavgb t2, mpb_0
- pxor t2, t1
- pand t2, mpb_1
- psubb t1, t2 ; p2' = (2*p3+3*p2+p1+p0+q0+4)/8
-
- pxor t0, p1
- pxor t1, p2
- pand t0, mask1p
- pand t1, mask1p
- pxor t0, p1
- pxor t1, p2
- mova %2, t0 ; store p1
- mova %3, t1 ; store p2
-%endmacro
-
-%macro LUMA_INTRA_SWAP_PQ 0
- %define q1 m0
- %define q0 m1
- %define p0 m2
- %define p1 m3
- %define p2 q2
- %define mask1p mask1q
-%endmacro
-
-%macro DEBLOCK_LUMA_INTRA 1
- %define p1 m0
- %define p0 m1
- %define q0 m2
- %define q1 m3
- %define t0 m4
- %define t1 m5
- %define t2 m6
- %define t3 m7
-%if ARCH_X86_64
- %define p2 m8
- %define q2 m9
- %define t4 m10
- %define t5 m11
- %define mask0 m12
- %define mask1p m13
- %define mask1q [rsp-24]
- %define mpb_0 m14
- %define mpb_1 m15
-%else
- %define spill(x) [esp+16*x]
- %define p2 [r4+r1]
- %define q2 [r0+2*r1]
- %define t4 spill(0)
- %define t5 spill(1)
- %define mask0 spill(2)
- %define mask1p spill(3)
- %define mask1q spill(4)
- %define mpb_0 [pb_0]
- %define mpb_1 [pb_1]
-%endif
-
-;-----------------------------------------------------------------------------
-; void deblock_v_luma_intra( uint8_t *pix, int stride, int alpha, int beta )
-;-----------------------------------------------------------------------------
-cglobal deblock_%1_luma_intra_8, 4,6,16,ARCH_X86_64*0x50-0x50
- lea r4, [r1*4]
- lea r5, [r1*3] ; 3*stride
- dec r2d ; alpha-1
- jl .end
- neg r4
- dec r3d ; beta-1
- jl .end
- add r4, r0 ; pix-4*stride
- mova p1, [r4+2*r1]
- mova p0, [r4+r5]
- mova q0, [r0]
- mova q1, [r0+r1]
-%if ARCH_X86_64
- pxor mpb_0, mpb_0
- mova mpb_1, [pb_1]
- LOAD_MASK r2d, r3d, t5 ; m5=beta-1, t5=alpha-1, m7=mask0
- SWAP 7, 12 ; m12=mask0
- pavgb t5, mpb_0
- pavgb t5, mpb_1 ; alpha/4+1
- movdqa p2, [r4+r1]
- movdqa q2, [r0+2*r1]
- DIFF_GT2 p0, q0, t5, t0, t3 ; t0 = |p0-q0| > alpha/4+1
- DIFF_GT2 p0, p2, m5, t2, t5 ; mask1 = |p2-p0| > beta-1
- DIFF_GT2 q0, q2, m5, t4, t5 ; t4 = |q2-q0| > beta-1
- pand t0, mask0
- pand t4, t0
- pand t2, t0
- mova mask1q, t4
- mova mask1p, t2
-%else
- LOAD_MASK r2d, r3d, t5 ; m5=beta-1, t5=alpha-1, m7=mask0
- mova m4, t5
- mova mask0, m7
- pavgb m4, [pb_0]
- pavgb m4, [pb_1] ; alpha/4+1
- DIFF_GT2 p0, q0, m4, m6, m7 ; m6 = |p0-q0| > alpha/4+1
- pand m6, mask0
- DIFF_GT2 p0, p2, m5, m4, m7 ; m4 = |p2-p0| > beta-1
- pand m4, m6
- mova mask1p, m4
- DIFF_GT2 q0, q2, m5, m4, m7 ; m4 = |q2-q0| > beta-1
- pand m4, m6
- mova mask1q, m4
-%endif
- LUMA_INTRA_P012 [r4+r5], [r4+2*r1], [r4+r1], [r4]
- LUMA_INTRA_SWAP_PQ
- LUMA_INTRA_P012 [r0], [r0+r1], [r0+2*r1], [r0+r5]
-.end:
- RET
-
-INIT_MMX cpuname
-%if ARCH_X86_64
-;-----------------------------------------------------------------------------
-; void deblock_h_luma_intra( uint8_t *pix, int stride, int alpha, int beta )
-;-----------------------------------------------------------------------------
-cglobal deblock_h_luma_intra_8, 4,9
- movsxd r7, r1d
- lea r8, [r7*3]
- lea r6, [r0-4]
- lea r5, [r0-4+r8]
- sub rsp, 0x88
- %define pix_tmp rsp
-
- ; transpose 8x16 -> tmp space
- TRANSPOSE8x8_MEM PASS8ROWS(r6, r5, r7, r8), PASS8ROWS(pix_tmp, pix_tmp+0x30, 0x10, 0x30)
- lea r6, [r6+r7*8]
- lea r5, [r5+r7*8]
- TRANSPOSE8x8_MEM PASS8ROWS(r6, r5, r7, r8), PASS8ROWS(pix_tmp+8, pix_tmp+0x38, 0x10, 0x30)
-
- lea r0, [pix_tmp+0x40]
- mov r1, 0x10
- call deblock_v_luma_intra_8
-
- ; transpose 16x6 -> original space (but we can't write only 6 pixels, so really 16x8)
- lea r5, [r6+r8]
- TRANSPOSE8x8_MEM PASS8ROWS(pix_tmp+8, pix_tmp+0x38, 0x10, 0x30), PASS8ROWS(r6, r5, r7, r8)
- shl r7, 3
- sub r6, r7
- sub r5, r7
- shr r7, 3
- TRANSPOSE8x8_MEM PASS8ROWS(pix_tmp, pix_tmp+0x30, 0x10, 0x30), PASS8ROWS(r6, r5, r7, r8)
- add rsp, 0x88
- RET
-%else
-cglobal deblock_h_luma_intra_8, 2,4,8,0x80
- lea r3, [r1*3]
- sub r0, 4
- lea r2, [r0+r3]
- %define pix_tmp rsp
-
- ; transpose 8x16 -> tmp space
- TRANSPOSE8x8_MEM PASS8ROWS(r0, r2, r1, r3), PASS8ROWS(pix_tmp, pix_tmp+0x30, 0x10, 0x30)
- lea r0, [r0+r1*8]
- lea r2, [r2+r1*8]
- TRANSPOSE8x8_MEM PASS8ROWS(r0, r2, r1, r3), PASS8ROWS(pix_tmp+8, pix_tmp+0x38, 0x10, 0x30)
-
- lea r0, [pix_tmp+0x40]
- PUSH dword r3m
- PUSH dword r2m
- PUSH dword 16
- PUSH r0
- call deblock_%1_luma_intra_8
-%ifidn %1, v8
- add dword [rsp], 8 ; pix_tmp+8
- call deblock_%1_luma_intra_8
-%endif
- ADD esp, 16
-
- mov r1, r1m
- mov r0, r0mp
- lea r3, [r1*3]
- sub r0, 4
- lea r2, [r0+r3]
- ; transpose 16x6 -> original space (but we can't write only 6 pixels, so really 16x8)
- TRANSPOSE8x8_MEM PASS8ROWS(pix_tmp, pix_tmp+0x30, 0x10, 0x30), PASS8ROWS(r0, r2, r1, r3)
- lea r0, [r0+r1*8]
- lea r2, [r2+r1*8]
- TRANSPOSE8x8_MEM PASS8ROWS(pix_tmp+8, pix_tmp+0x38, 0x10, 0x30), PASS8ROWS(r0, r2, r1, r3)
- RET
-%endif ; ARCH_X86_64
-%endmacro ; DEBLOCK_LUMA_INTRA
-
-INIT_XMM sse2
-DEBLOCK_LUMA_INTRA v
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-DEBLOCK_LUMA_INTRA v
-%endif
-%if ARCH_X86_64 == 0
-INIT_MMX mmxext
-DEBLOCK_LUMA_INTRA v8
-%endif
-
-INIT_MMX mmxext
-
-%macro CHROMA_V_START 0
- dec r2d ; alpha-1
- dec r3d ; beta-1
- mov t5, r0
- sub t5, r1
- sub t5, r1
-%endmacro
-
-%macro CHROMA_H_START 0
- dec r2d
- dec r3d
- sub r0, 2
- lea t6, [r1*3]
- mov t5, r0
- add r0, t6
-%endmacro
-
-%define t5 r5
-%define t6 r6
-
-;-----------------------------------------------------------------------------
-; 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
- movq m0, [t5]
- movq m1, [t5+r1]
- movq m2, [r0]
- movq m3, [r0+r1]
- call ff_chroma_inter_body_mmxext
- movq [t5+r1], m1
- movq [r0], m2
- RET
-
-;-----------------------------------------------------------------------------
-; 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
- %define buf0 [rsp-24]
- %define buf1 [rsp-16]
-%elif WIN64
- sub rsp, 16
- %define buf0 [rsp]
- %define buf1 [rsp+8]
-%else
- %define buf0 r0m
- %define buf1 r2m
-%endif
- CHROMA_H_START
- TRANSPOSE4x8_LOAD bw, wd, dq, PASS8ROWS(t5, r0, r1, t6)
- movq buf0, m0
- movq buf1, m3
- LOAD_MASK r2d, r3d
- movd m6, [r4] ; tc0
- punpcklbw m6, m6
- pand m7, m6
- DEBLOCK_P0_Q0
- movq m0, buf0
- movq m3, buf1
- TRANSPOSE8x4B_STORE PASS8ROWS(t5, r0, r1, t6)
-%if WIN64
- add rsp, 16
-%endif
- RET
-
-ALIGN 16
-ff_chroma_inter_body_mmxext:
- LOAD_MASK r2d, r3d
- movd m6, [r4] ; tc0
- punpcklbw m6, m6
- pand m7, m6
- DEBLOCK_P0_Q0
- ret
-
-
-
-; in: %1=p0 %2=p1 %3=q1
-; out: p0 = (p0 + q1 + 2*p1 + 2) >> 2
-%macro CHROMA_INTRA_P0 3
- movq m4, %1
- pxor m4, %3
- pand m4, [pb_1] ; m4 = (p0^q1)&1
- pavgb %1, %3
- psubusb %1, m4
- pavgb %1, %2 ; dst = avg(p1, avg(p0,q1) - ((p0^q1)&1))
-%endmacro
-
-%define t5 r4
-%define t6 r5
-
-;-----------------------------------------------------------------------------
-; 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]
- movq m1, [t5+r1]
- movq m2, [r0]
- movq m3, [r0+r1]
- call ff_chroma_intra_body_mmxext
- movq [t5+r1], m1
- movq [r0], m2
- RET
-
-;-----------------------------------------------------------------------------
-; 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)
- call ff_chroma_intra_body_mmxext
- TRANSPOSE8x4B_STORE PASS8ROWS(t5, r0, r1, t6)
- RET
-
-ALIGN 16
-ff_chroma_intra_body_mmxext:
- LOAD_MASK r2d, r3d
- movq m5, m1
- movq m6, m2
- CHROMA_INTRA_P0 m1, m0, m3
- CHROMA_INTRA_P0 m2, m3, m0
- psubb m1, m5
- psubb m2, m6
- pand m1, m7
- pand m2, m7
- paddb m1, m5
- paddb m2, m6
- 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);
-;
-; bidir is 0 or 1
-; edges is 1 or 4
-; step is 1 or 2
-; mask_mv0 is 0 or 3
-; mask_mv1 is 0 or 1
-; field is 0 or 1
-;-----------------------------------------------------------------------------
-%macro loop_filter_strength_iteration 7 ; edges, step, mask_mv,
- ; dir, d_idx, mask_dir, bidir
-%define edgesd %1
-%define stepd %2
-%define mask_mvd %3
-%define dir %4
-%define d_idx %5
-%define mask_dir %6
-%define bidir %7
- xor b_idxd, b_idxd ; for (b_idx = 0; b_idx < edges; b_idx += step)
-%%.b_idx_loop:
-%if mask_dir == 0
- pxor m0, m0
-%endif
- test b_idxd, dword mask_mvd
- jnz %%.skip_loop_iter ; if (!(b_idx & mask_mv))
-%if bidir == 1
- movd m2, [refq+b_idxq+d_idx+12] ; { ref0[bn] }
- punpckldq m2, [refq+b_idxq+d_idx+52] ; { ref0[bn], ref1[bn] }
- pshufw m0, [refq+b_idxq+12], 0x44 ; { ref0[b], ref0[b] }
- pshufw m1, [refq+b_idxq+52], 0x44 ; { ref1[b], ref1[b] }
- pshufw m3, m2, 0x4E ; { ref1[bn], ref0[bn] }
- psubb m0, m2 ; { ref0[b] != ref0[bn],
- ; ref0[b] != ref1[bn] }
- psubb m1, m3 ; { ref1[b] != ref1[bn],
- ; ref1[b] != ref0[bn] }
-
- por m0, m1
- mova m1, [mvq+b_idxq*4+(d_idx+12)*4]
- mova m2, [mvq+b_idxq*4+(d_idx+12)*4+mmsize]
- mova m3, m1
- mova m4, m2
- psubw m1, [mvq+b_idxq*4+12*4]
- psubw m2, [mvq+b_idxq*4+12*4+mmsize]
- psubw m3, [mvq+b_idxq*4+52*4]
- psubw m4, [mvq+b_idxq*4+52*4+mmsize]
- packsswb m1, m2
- packsswb m3, m4
- paddb m1, m6
- paddb m3, m6
- psubusb m1, m5 ; abs(mv[b] - mv[bn]) >= limit
- psubusb m3, m5
- packsswb m1, m3
-
- por m0, m1
- mova m1, [mvq+b_idxq*4+(d_idx+52)*4]
- mova m2, [mvq+b_idxq*4+(d_idx+52)*4+mmsize]
- mova m3, m1
- mova m4, m2
- psubw m1, [mvq+b_idxq*4+12*4]
- psubw m2, [mvq+b_idxq*4+12*4+mmsize]
- psubw m3, [mvq+b_idxq*4+52*4]
- psubw m4, [mvq+b_idxq*4+52*4+mmsize]
- packsswb m1, m2
- packsswb m3, m4
- paddb m1, m6
- paddb m3, m6
- psubusb m1, m5 ; abs(mv[b] - mv[bn]) >= limit
- psubusb m3, m5
- packsswb m1, m3
-
- pshufw m1, m1, 0x4E
- por m0, m1
- pshufw m1, m0, 0x4E
- pminub m0, m1
-%else ; bidir == 0
- movd m0, [refq+b_idxq+12]
- psubb m0, [refq+b_idxq+d_idx+12] ; ref[b] != ref[bn]
-
- mova m1, [mvq+b_idxq*4+12*4]
- mova m2, [mvq+b_idxq*4+12*4+mmsize]
- psubw m1, [mvq+b_idxq*4+(d_idx+12)*4]
- psubw m2, [mvq+b_idxq*4+(d_idx+12)*4+mmsize]
- packsswb m1, m2
- paddb m1, m6
- psubusb m1, m5 ; abs(mv[b] - mv[bn]) >= limit
- packsswb m1, m1
- por m0, m1
-%endif ; bidir == 1/0
-
-%%.skip_loop_iter:
- movd m1, [nnzq+b_idxq+12]
- por m1, [nnzq+b_idxq+d_idx+12] ; nnz[b] || nnz[bn]
-
- pminub m1, m7
- pminub m0, m7
- psllw m1, 1
- pxor m2, m2
- pmaxub m1, m0
- punpcklbw m1, m2
- movq [bsq+b_idxq+32*dir], m1
-
- add b_idxd, dword stepd
- cmp b_idxd, dword edgesd
- jl %%.b_idx_loop
-%endmacro
-
-INIT_MMX mmxext
-cglobal h264_loop_filter_strength, 9, 9, 0, bs, nnz, ref, mv, bidir, edges, \
- step, mask_mv0, mask_mv1, field
-%define b_idxq bidirq
-%define b_idxd bidird
- cmp dword fieldm, 0
- mova m7, [pb_1]
- mova m5, [pb_3]
- je .nofield
- mova m5, [pb_3_1]
-.nofield:
- mova m6, m5
- paddb m5, m5
-
- shl dword stepd, 3
- shl dword edgesd, 3
-%if ARCH_X86_32
-%define mask_mv0d mask_mv0m
-%define mask_mv1d mask_mv1m
-%endif
- shl dword mask_mv1d, 3
- shl dword mask_mv0d, 3
-
- cmp dword bidird, 0
- jne .bidir
- loop_filter_strength_iteration edgesd, stepd, mask_mv1d, 1, -8, 0, 0
- loop_filter_strength_iteration 32, 8, mask_mv0d, 0, -1, -1, 0
-
- mova m0, [bsq+mmsize*0]
- mova m1, [bsq+mmsize*1]
- mova m2, [bsq+mmsize*2]
- mova m3, [bsq+mmsize*3]
- TRANSPOSE4x4W 0, 1, 2, 3, 4
- mova [bsq+mmsize*0], m0
- mova [bsq+mmsize*1], m1
- mova [bsq+mmsize*2], m2
- mova [bsq+mmsize*3], m3
- RET
-
-.bidir:
- loop_filter_strength_iteration edgesd, stepd, mask_mv1d, 1, -8, 0, 1
- loop_filter_strength_iteration 32, 8, mask_mv0d, 0, -1, -1, 1
-
- mova m0, [bsq+mmsize*0]
- mova m1, [bsq+mmsize*1]
- mova m2, [bsq+mmsize*2]
- mova m3, [bsq+mmsize*3]
- TRANSPOSE4x4W 0, 1, 2, 3, 4
- mova [bsq+mmsize*0], m0
- mova [bsq+mmsize*1], m1
- mova [bsq+mmsize*2], m2
- mova [bsq+mmsize*3], m3
- RET
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/h264_deblock_10bit.asm b/src/thirdparty/ffmpeg/libavcodec/x86/h264_deblock_10bit.asm
deleted file mode 100644
index 8c0570790..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/h264_deblock_10bit.asm
+++ /dev/null
@@ -1,923 +0,0 @@
-;*****************************************************************************
-;* MMX/SSE2/AVX-optimized 10-bit H.264 deblocking code
-;*****************************************************************************
-;* Copyright (C) 2005-2011 x264 project
-;*
-;* Authors: Oskar Arvidsson <oskar@irock.se>
-;* Loren Merritt <lorenm@u.washington.edu>
-;* Jason Garrett-Glaser <darkshikari@gmail.com>
-;*
-;* This file is part of Libav.
-;*
-;* Libav is free software; you can redistribute it and/or
-;* modify it under the terms of the GNU Lesser General Public
-;* License as published by the Free Software Foundation; either
-;* version 2.1 of the License, or (at your option) any later version.
-;*
-;* Libav is distributed in the hope that it will be useful,
-;* but WITHOUT ANY WARRANTY; without even the implied warranty of
-;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-;* Lesser General Public License for more details.
-;*
-;* You should have received a copy of the GNU Lesser General Public
-;* License along with Libav; if not, write to the Free Software
-;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-;******************************************************************************
-
-%include "libavutil/x86/x86util.asm"
-
-SECTION_RODATA
-
-pw_pixel_max: times 8 dw ((1 << 10)-1)
-
-SECTION .text
-
-cextern pw_2
-cextern pw_3
-cextern pw_4
-
-; out: %4 = |%1-%2|-%3
-; clobbers: %5
-%macro ABS_SUB 5
- psubusw %5, %2, %1
- psubusw %4, %1, %2
- por %4, %5
- psubw %4, %3
-%endmacro
-
-; out: %4 = |%1-%2|<%3
-%macro DIFF_LT 5
- psubusw %4, %2, %1
- psubusw %5, %1, %2
- por %5, %4 ; |%1-%2|
- pxor %4, %4
- psubw %5, %3 ; |%1-%2|-%3
- pcmpgtw %4, %5 ; 0 > |%1-%2|-%3
-%endmacro
-
-%macro LOAD_AB 4
- movd %1, %3
- movd %2, %4
- SPLATW %1, %1
- SPLATW %2, %2
-%endmacro
-
-; in: %2=tc reg
-; out: %1=splatted tc
-%macro LOAD_TC 2
- movd %1, [%2]
- punpcklbw %1, %1
-%if mmsize == 8
- pshufw %1, %1, 0
-%else
- pshuflw %1, %1, 01010000b
- pshufd %1, %1, 01010000b
-%endif
- psraw %1, 6
-%endmacro
-
-; in: %1=p1, %2=p0, %3=q0, %4=q1
-; %5=alpha, %6=beta, %7-%9=tmp
-; out: %7=mask
-%macro LOAD_MASK 9
- ABS_SUB %2, %3, %5, %8, %7 ; |p0-q0| - alpha
- ABS_SUB %1, %2, %6, %9, %7 ; |p1-p0| - beta
- pand %8, %9
- ABS_SUB %3, %4, %6, %9, %7 ; |q1-q0| - beta
- pxor %7, %7
- pand %8, %9
- pcmpgtw %7, %8
-%endmacro
-
-; in: %1=p0, %2=q0, %3=p1, %4=q1, %5=mask, %6=tmp, %7=tmp
-; out: %1=p0', m2=q0'
-%macro DEBLOCK_P0_Q0 7
- psubw %3, %4
- pxor %7, %7
- paddw %3, [pw_4]
- psubw %7, %5
- psubw %6, %2, %1
- psllw %6, 2
- paddw %3, %6
- psraw %3, 3
- mova %6, [pw_pixel_max]
- CLIPW %3, %7, %5
- pxor %7, %7
- paddw %1, %3
- psubw %2, %3
- CLIPW %1, %7, %6
- CLIPW %2, %7, %6
-%endmacro
-
-; in: %1=x2, %2=x1, %3=p0, %4=q0 %5=mask&tc, %6=tmp
-%macro LUMA_Q1 6
- pavgw %6, %3, %4 ; (p0+q0+1)>>1
- paddw %1, %6
- pxor %6, %6
- psraw %1, 1
- psubw %6, %5
- psubw %1, %2
- CLIPW %1, %6, %5
- paddw %1, %2
-%endmacro
-
-%macro LUMA_DEBLOCK_ONE 3
- DIFF_LT m5, %1, bm, m4, m6
- pxor m6, m6
- mova %3, m4
- pcmpgtw m6, tcm
- pand m4, tcm
- pandn m6, m7
- pand m4, m6
- LUMA_Q1 m5, %2, m1, m2, m4, m6
-%endmacro
-
-%macro LUMA_H_STORE 2
-%if mmsize == 8
- movq [r0-4], m0
- movq [r0+r1-4], m1
- movq [r0+r1*2-4], m2
- movq [r0+%2-4], m3
-%else
- movq [r0-4], m0
- movhps [r0+r1-4], m0
- movq [r0+r1*2-4], m1
- movhps [%1-4], m1
- movq [%1+r1-4], m2
- movhps [%1+r1*2-4], m2
- movq [%1+%2-4], m3
- movhps [%1+r1*4-4], m3
-%endif
-%endmacro
-
-%macro DEBLOCK_LUMA 0
-;-----------------------------------------------------------------------------
-; void deblock_v_luma( 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)
- %define tcm [rsp]
- %define ms1 [rsp+mmsize]
- %define ms2 [rsp+mmsize*2]
- %define am [rsp+mmsize*3]
- %define bm [rsp+mmsize*4]
- SUB rsp, pad
- shl r2d, 2
- shl r3d, 2
- LOAD_AB m4, m5, r2d, r3d
- mov r3, 32/mmsize
- mov r2, r0
- sub r0, r1
- mova am, m4
- sub r0, r1
- mova bm, m5
- sub r0, r1
-.loop:
- mova m0, [r0+r1]
- mova m1, [r0+r1*2]
- mova m2, [r2]
- mova m3, [r2+r1]
-
- LOAD_MASK m0, m1, m2, m3, am, bm, m7, m4, m6
- LOAD_TC m6, r4
- mova tcm, m6
-
- mova m5, [r0]
- LUMA_DEBLOCK_ONE m1, m0, ms1
- mova [r0+r1], m5
-
- mova m5, [r2+r1*2]
- LUMA_DEBLOCK_ONE m2, m3, ms2
- mova [r2+r1], m5
-
- pxor m5, m5
- mova m6, tcm
- pcmpgtw m5, tcm
- psubw m6, ms1
- pandn m5, m7
- psubw m6, ms2
- pand m5, m6
- DEBLOCK_P0_Q0 m1, m2, m0, m3, m5, m7, m6
- mova [r0+r1*2], m1
- mova [r2], m2
-
- add r0, mmsize
- add r2, mmsize
- add r4, mmsize/8
- dec r3
- jg .loop
- ADD rsp, pad
- RET
-
-cglobal deblock_h_luma_10, 5,6,8*(mmsize/16)
- %assign pad 7*mmsize+12-(stack_offset&15)
- %define tcm [rsp]
- %define ms1 [rsp+mmsize]
- %define ms2 [rsp+mmsize*2]
- %define p1m [rsp+mmsize*3]
- %define p2m [rsp+mmsize*4]
- %define am [rsp+mmsize*5]
- %define bm [rsp+mmsize*6]
- SUB rsp, pad
- shl r2d, 2
- shl r3d, 2
- LOAD_AB m4, m5, r2d, r3d
- mov r3, r1
- mova am, m4
- add r3, r1
- mov r5, 32/mmsize
- mova bm, m5
- add r3, r1
-%if mmsize == 16
- mov r2, r0
- add r2, r3
-%endif
-.loop:
-%if mmsize == 8
- movq m2, [r0-8] ; y q2 q1 q0
- movq m7, [r0+0]
- movq m5, [r0+r1-8]
- movq m3, [r0+r1+0]
- movq m0, [r0+r1*2-8]
- movq m6, [r0+r1*2+0]
- movq m1, [r0+r3-8]
- TRANSPOSE4x4W 2, 5, 0, 1, 4
- SWAP 2, 7
- movq m7, [r0+r3]
- TRANSPOSE4x4W 2, 3, 6, 7, 4
-%else
- movu m5, [r0-8] ; y q2 q1 q0 p0 p1 p2 x
- movu m0, [r0+r1-8]
- movu m2, [r0+r1*2-8]
- movu m3, [r2-8]
- TRANSPOSE4x4W 5, 0, 2, 3, 6
- mova tcm, m3
-
- movu m4, [r2+r1-8]
- movu m1, [r2+r1*2-8]
- movu m3, [r2+r3-8]
- movu m7, [r2+r1*4-8]
- TRANSPOSE4x4W 4, 1, 3, 7, 6
-
- mova m6, tcm
- punpcklqdq m6, m7
- punpckhqdq m5, m4
- SBUTTERFLY qdq, 0, 1, 7
- SBUTTERFLY qdq, 2, 3, 7
-%endif
-
- mova p2m, m6
- LOAD_MASK m0, m1, m2, m3, am, bm, m7, m4, m6
- LOAD_TC m6, r4
- mova tcm, m6
-
- LUMA_DEBLOCK_ONE m1, m0, ms1
- mova p1m, m5
-
- mova m5, p2m
- LUMA_DEBLOCK_ONE m2, m3, ms2
- mova p2m, m5
-
- pxor m5, m5
- mova m6, tcm
- pcmpgtw m5, tcm
- psubw m6, ms1
- pandn m5, m7
- psubw m6, ms2
- pand m5, m6
- DEBLOCK_P0_Q0 m1, m2, m0, m3, m5, m7, m6
- mova m0, p1m
- mova m3, p2m
- TRANSPOSE4x4W 0, 1, 2, 3, 4
- LUMA_H_STORE r2, r3
-
- add r4, mmsize/8
- lea r0, [r0+r1*(mmsize/2)]
- lea r2, [r2+r1*(mmsize/2)]
- dec r5
- jg .loop
- ADD rsp, pad
- RET
-%endmacro
-
-%if ARCH_X86_64
-; in: m0=p1, m1=p0, m2=q0, m3=q1, m8=p2, m9=q2
-; m12=alpha, m13=beta
-; out: m0=p1', m3=q1', m1=p0', m2=q0'
-; clobbers: m4, m5, m6, m7, m10, m11, m14
-%macro DEBLOCK_LUMA_INTER_SSE2 0
- LOAD_MASK m0, m1, m2, m3, m12, m13, m7, m4, m6
- LOAD_TC m6, r4
- DIFF_LT m8, m1, m13, m10, m4
- DIFF_LT m9, m2, m13, m11, m4
- pand m6, m7
-
- mova m14, m6
- pxor m4, m4
- pcmpgtw m6, m4
- pand m6, m14
-
- mova m5, m10
- pand m5, m6
- LUMA_Q1 m8, m0, m1, m2, m5, m4
-
- mova m5, m11
- pand m5, m6
- LUMA_Q1 m9, m3, m1, m2, m5, m4
-
- pxor m4, m4
- psubw m6, m10
- pcmpgtw m4, m14
- pandn m4, m7
- psubw m6, m11
- pand m4, m6
- DEBLOCK_P0_Q0 m1, m2, m0, m3, m4, m5, m6
-
- SWAP 0, 8
- SWAP 3, 9
-%endmacro
-
-%macro DEBLOCK_LUMA_64 0
-cglobal deblock_v_luma_10, 5,5,15
- %define p2 m8
- %define p1 m0
- %define p0 m1
- %define q0 m2
- %define q1 m3
- %define q2 m9
- %define mask0 m7
- %define mask1 m10
- %define mask2 m11
- shl r2d, 2
- shl r3d, 2
- LOAD_AB m12, m13, r2d, r3d
- mov r2, r0
- sub r0, r1
- sub r0, r1
- sub r0, r1
- mov r3, 2
-.loop:
- mova p2, [r0]
- mova p1, [r0+r1]
- mova p0, [r0+r1*2]
- mova q0, [r2]
- mova q1, [r2+r1]
- mova q2, [r2+r1*2]
- DEBLOCK_LUMA_INTER_SSE2
- mova [r0+r1], p1
- mova [r0+r1*2], p0
- mova [r2], q0
- mova [r2+r1], q1
- add r0, mmsize
- add r2, mmsize
- add r4, 2
- dec r3
- jg .loop
- REP_RET
-
-cglobal deblock_h_luma_10, 5,7,15
- shl r2d, 2
- shl r3d, 2
- LOAD_AB m12, m13, r2d, r3d
- mov r2, r1
- add r2, r1
- add r2, r1
- mov r5, r0
- add r5, r2
- mov r6, 2
-.loop:
- movu m8, [r0-8] ; y q2 q1 q0 p0 p1 p2 x
- movu m0, [r0+r1-8]
- movu m2, [r0+r1*2-8]
- movu m9, [r5-8]
- movu m5, [r5+r1-8]
- movu m1, [r5+r1*2-8]
- movu m3, [r5+r2-8]
- movu m7, [r5+r1*4-8]
-
- TRANSPOSE4x4W 8, 0, 2, 9, 10
- TRANSPOSE4x4W 5, 1, 3, 7, 10
-
- punpckhqdq m8, m5
- SBUTTERFLY qdq, 0, 1, 10
- SBUTTERFLY qdq, 2, 3, 10
- punpcklqdq m9, m7
-
- DEBLOCK_LUMA_INTER_SSE2
-
- TRANSPOSE4x4W 0, 1, 2, 3, 4
- LUMA_H_STORE r5, r2
- add r4, 2
- lea r0, [r0+r1*8]
- lea r5, [r5+r1*8]
- dec r6
- jg .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-DEBLOCK_LUMA_64
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-DEBLOCK_LUMA_64
-%endif
-%endif
-
-%macro SWAPMOVA 2
-%ifid %1
- SWAP %1, %2
-%else
- mova %1, %2
-%endif
-%endmacro
-
-; in: t0-t2: tmp registers
-; %1=p0 %2=p1 %3=p2 %4=p3 %5=q0 %6=q1 %7=mask0
-; %8=mask1p %9=2 %10=p0' %11=p1' %12=p2'
-%macro LUMA_INTRA_P012 12 ; p0..p3 in memory
-%if ARCH_X86_64
- paddw t0, %3, %2
- mova t2, %4
- paddw t2, %3
-%else
- mova t0, %3
- mova t2, %4
- paddw t0, %2
- paddw t2, %3
-%endif
- paddw t0, %1
- paddw t2, t2
- paddw t0, %5
- paddw t2, %9
- paddw t0, %9 ; (p2 + p1 + p0 + q0 + 2)
- paddw t2, t0 ; (2*p3 + 3*p2 + p1 + p0 + q0 + 4)
-
- psrlw t2, 3
- psrlw t1, t0, 2
- psubw t2, %3
- psubw t1, %2
- pand t2, %8
- pand t1, %8
- paddw t2, %3
- paddw t1, %2
- SWAPMOVA %11, t1
-
- psubw t1, t0, %3
- paddw t0, t0
- psubw t1, %5
- psubw t0, %3
- paddw t1, %6
- paddw t1, %2
- paddw t0, %6
- psrlw t1, 2 ; (2*p1 + p0 + q1 + 2)/4
- psrlw t0, 3 ; (p2 + 2*p1 + 2*p0 + 2*q0 + q1 + 4)>>3
-
- pxor t0, t1
- pxor t1, %1
- pand t0, %8
- pand t1, %7
- pxor t0, t1
- pxor t0, %1
- SWAPMOVA %10, t0
- SWAPMOVA %12, t2
-%endmacro
-
-%macro LUMA_INTRA_INIT 1
- %xdefine pad %1*mmsize+((gprsize*3) % mmsize)-(stack_offset&15)
- %define t0 m4
- %define t1 m5
- %define t2 m6
- %define t3 m7
- %assign i 4
-%rep %1
- CAT_XDEFINE t, i, [rsp+mmsize*(i-4)]
- %assign i i+1
-%endrep
- SUB rsp, pad
-%endmacro
-
-; in: %1-%3=tmp, %4=p2, %5=q2
-%macro LUMA_INTRA_INTER 5
- LOAD_AB t0, t1, r2d, r3d
- mova %1, t0
- LOAD_MASK m0, m1, m2, m3, %1, t1, t0, t2, t3
-%if ARCH_X86_64
- mova %2, t0 ; mask0
- psrlw t3, %1, 2
-%else
- mova t3, %1
- mova %2, t0 ; mask0
- psrlw t3, 2
-%endif
- paddw t3, [pw_2] ; alpha/4+2
- DIFF_LT m1, m2, t3, t2, t0 ; t2 = |p0-q0| < alpha/4+2
- pand t2, %2
- mova t3, %5 ; q2
- mova %1, t2 ; mask1
- DIFF_LT t3, m2, t1, t2, t0 ; t2 = |q2-q0| < beta
- pand t2, %1
- mova t3, %4 ; p2
- mova %3, t2 ; mask1q
- DIFF_LT t3, m1, t1, t2, t0 ; t2 = |p2-p0| < beta
- pand t2, %1
- mova %1, t2 ; mask1p
-%endmacro
-
-%macro LUMA_H_INTRA_LOAD 0
-%if mmsize == 8
- movu t0, [r0-8]
- movu t1, [r0+r1-8]
- movu m0, [r0+r1*2-8]
- movu m1, [r0+r4-8]
- TRANSPOSE4x4W 4, 5, 0, 1, 2
- mova t4, t0 ; p3
- mova t5, t1 ; p2
-
- movu m2, [r0]
- movu m3, [r0+r1]
- movu t0, [r0+r1*2]
- movu t1, [r0+r4]
- TRANSPOSE4x4W 2, 3, 4, 5, 6
- mova t6, t0 ; q2
- mova t7, t1 ; q3
-%else
- movu t0, [r0-8]
- movu t1, [r0+r1-8]
- movu m0, [r0+r1*2-8]
- movu m1, [r0+r5-8]
- movu m2, [r4-8]
- movu m3, [r4+r1-8]
- movu t2, [r4+r1*2-8]
- movu t3, [r4+r5-8]
- TRANSPOSE8x8W 4, 5, 0, 1, 2, 3, 6, 7, t4, t5
- mova t4, t0 ; p3
- mova t5, t1 ; p2
- mova t6, t2 ; q2
- mova t7, t3 ; q3
-%endif
-%endmacro
-
-; in: %1=q3 %2=q2' %3=q1' %4=q0' %5=p0' %6=p1' %7=p2' %8=p3 %9=tmp
-%macro LUMA_H_INTRA_STORE 9
-%if mmsize == 8
- TRANSPOSE4x4W %1, %2, %3, %4, %9
- movq [r0-8], m%1
- movq [r0+r1-8], m%2
- movq [r0+r1*2-8], m%3
- movq [r0+r4-8], m%4
- movq m%1, %8
- TRANSPOSE4x4W %5, %6, %7, %1, %9
- movq [r0], m%5
- movq [r0+r1], m%6
- movq [r0+r1*2], m%7
- movq [r0+r4], m%1
-%else
- TRANSPOSE2x4x4W %1, %2, %3, %4, %9
- movq [r0-8], m%1
- movq [r0+r1-8], m%2
- movq [r0+r1*2-8], m%3
- movq [r0+r5-8], m%4
- movhps [r4-8], m%1
- movhps [r4+r1-8], m%2
- movhps [r4+r1*2-8], m%3
- movhps [r4+r5-8], m%4
-%ifnum %8
- SWAP %1, %8
-%else
- mova m%1, %8
-%endif
- TRANSPOSE2x4x4W %5, %6, %7, %1, %9
- movq [r0], m%5
- movq [r0+r1], m%6
- movq [r0+r1*2], m%7
- movq [r0+r5], m%1
- movhps [r4], m%5
- movhps [r4+r1], m%6
- movhps [r4+r1*2], m%7
- movhps [r4+r5], m%1
-%endif
-%endmacro
-
-%if ARCH_X86_64
-;-----------------------------------------------------------------------------
-; void deblock_v_luma_intra( uint16_t *pix, int stride, int alpha, int beta )
-;-----------------------------------------------------------------------------
-%macro DEBLOCK_LUMA_INTRA_64 0
-cglobal deblock_v_luma_intra_10, 4,7,16
- %define t0 m1
- %define t1 m2
- %define t2 m4
- %define p2 m8
- %define p1 m9
- %define p0 m10
- %define q0 m11
- %define q1 m12
- %define q2 m13
- %define aa m5
- %define bb m14
- lea r4, [r1*4]
- lea r5, [r1*3] ; 3*stride
- neg r4
- add r4, r0 ; pix-4*stride
- mov r6, 2
- mova m0, [pw_2]
- shl r2d, 2
- shl r3d, 2
- LOAD_AB aa, bb, r2d, r3d
-.loop:
- mova p2, [r4+r1]
- mova p1, [r4+2*r1]
- mova p0, [r4+r5]
- mova q0, [r0]
- mova q1, [r0+r1]
- mova q2, [r0+2*r1]
-
- LOAD_MASK p1, p0, q0, q1, aa, bb, m3, t0, t1
- mova t2, aa
- psrlw t2, 2
- paddw t2, m0 ; alpha/4+2
- DIFF_LT p0, q0, t2, m6, t0 ; m6 = |p0-q0| < alpha/4+2
- DIFF_LT p2, p0, bb, t1, t0 ; m7 = |p2-p0| < beta
- DIFF_LT q2, q0, bb, m7, t0 ; t1 = |q2-q0| < beta
- pand m6, m3
- pand m7, m6
- pand m6, t1
- LUMA_INTRA_P012 p0, p1, p2, [r4], q0, q1, m3, m6, m0, [r4+r5], [r4+2*r1], [r4+r1]
- LUMA_INTRA_P012 q0, q1, q2, [r0+r5], p0, p1, m3, m7, m0, [r0], [r0+r1], [r0+2*r1]
- add r0, mmsize
- add r4, mmsize
- dec r6
- jg .loop
- REP_RET
-
-;-----------------------------------------------------------------------------
-; void deblock_h_luma_intra( uint16_t *pix, int stride, int alpha, int beta )
-;-----------------------------------------------------------------------------
-cglobal deblock_h_luma_intra_10, 4,7,16
- %define t0 m15
- %define t1 m14
- %define t2 m2
- %define q3 m5
- %define q2 m8
- %define q1 m9
- %define q0 m10
- %define p0 m11
- %define p1 m12
- %define p2 m13
- %define p3 m4
- %define spill [rsp]
- %assign pad 24-(stack_offset&15)
- SUB rsp, pad
- lea r4, [r1*4]
- lea r5, [r1*3] ; 3*stride
- add r4, r0 ; pix+4*stride
- mov r6, 2
- mova m0, [pw_2]
- shl r2d, 2
- shl r3d, 2
-.loop:
- movu q3, [r0-8]
- movu q2, [r0+r1-8]
- movu q1, [r0+r1*2-8]
- movu q0, [r0+r5-8]
- movu p0, [r4-8]
- movu p1, [r4+r1-8]
- movu p2, [r4+r1*2-8]
- movu p3, [r4+r5-8]
- TRANSPOSE8x8W 5, 8, 9, 10, 11, 12, 13, 4, 1
-
- LOAD_AB m1, m2, r2d, r3d
- LOAD_MASK q1, q0, p0, p1, m1, m2, m3, t0, t1
- psrlw m1, 2
- paddw m1, m0 ; alpha/4+2
- DIFF_LT p0, q0, m1, m6, t0 ; m6 = |p0-q0| < alpha/4+2
- DIFF_LT q2, q0, m2, t1, t0 ; t1 = |q2-q0| < beta
- DIFF_LT p0, p2, m2, m7, t0 ; m7 = |p2-p0| < beta
- pand m6, m3
- pand m7, m6
- pand m6, t1
-
- mova spill, q3
- LUMA_INTRA_P012 q0, q1, q2, q3, p0, p1, m3, m6, m0, m5, m1, q2
- LUMA_INTRA_P012 p0, p1, p2, p3, q0, q1, m3, m7, m0, p0, m6, p2
- mova m7, spill
-
- LUMA_H_INTRA_STORE 7, 8, 1, 5, 11, 6, 13, 4, 14
-
- lea r0, [r0+r1*8]
- lea r4, [r4+r1*8]
- dec r6
- jg .loop
- ADD rsp, pad
- RET
-%endmacro
-
-INIT_XMM sse2
-DEBLOCK_LUMA_INTRA_64
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-DEBLOCK_LUMA_INTRA_64
-%endif
-
-%endif
-
-%macro DEBLOCK_LUMA_INTRA 0
-;-----------------------------------------------------------------------------
-; void deblock_v_luma_intra( uint16_t *pix, int stride, int alpha, int beta )
-;-----------------------------------------------------------------------------
-cglobal deblock_v_luma_intra_10, 4,7,8*(mmsize/16)
- LUMA_INTRA_INIT 3
- lea r4, [r1*4]
- lea r5, [r1*3]
- neg r4
- add r4, r0
- mov r6, 32/mmsize
- shl r2d, 2
- shl r3d, 2
-.loop:
- mova m0, [r4+r1*2] ; p1
- mova m1, [r4+r5] ; p0
- mova m2, [r0] ; q0
- mova m3, [r0+r1] ; q1
- LUMA_INTRA_INTER t4, t5, t6, [r4+r1], [r0+r1*2]
- LUMA_INTRA_P012 m1, m0, t3, [r4], m2, m3, t5, t4, [pw_2], [r4+r5], [r4+2*r1], [r4+r1]
- mova t3, [r0+r1*2] ; q2
- LUMA_INTRA_P012 m2, m3, t3, [r0+r5], m1, m0, t5, t6, [pw_2], [r0], [r0+r1], [r0+2*r1]
- add r0, mmsize
- add r4, mmsize
- dec r6
- jg .loop
- ADD rsp, pad
- RET
-
-;-----------------------------------------------------------------------------
-; void deblock_h_luma_intra( uint16_t *pix, int stride, int alpha, int beta )
-;-----------------------------------------------------------------------------
-cglobal deblock_h_luma_intra_10, 4,7,8*(mmsize/16)
- LUMA_INTRA_INIT 8
-%if mmsize == 8
- lea r4, [r1*3]
- mov r5, 32/mmsize
-%else
- lea r4, [r1*4]
- lea r5, [r1*3] ; 3*stride
- add r4, r0 ; pix+4*stride
- mov r6, 32/mmsize
-%endif
- shl r2d, 2
- shl r3d, 2
-.loop:
- LUMA_H_INTRA_LOAD
- LUMA_INTRA_INTER t8, t9, t10, t5, t6
-
- LUMA_INTRA_P012 m1, m0, t3, t4, m2, m3, t9, t8, [pw_2], t8, t5, t11
- mova t3, t6 ; q2
- LUMA_INTRA_P012 m2, m3, t3, t7, m1, m0, t9, t10, [pw_2], m4, t6, m5
-
- mova m2, t4
- mova m0, t11
- mova m1, t5
- mova m3, t8
- mova m6, t6
-
- LUMA_H_INTRA_STORE 2, 0, 1, 3, 4, 6, 5, t7, 7
-
- lea r0, [r0+r1*(mmsize/2)]
-%if mmsize == 8
- dec r5
-%else
- lea r4, [r4+r1*(mmsize/2)]
- dec r6
-%endif
- jg .loop
- ADD rsp, pad
- RET
-%endmacro
-
-%if ARCH_X86_64 == 0
-INIT_MMX mmxext
-DEBLOCK_LUMA
-DEBLOCK_LUMA_INTRA
-INIT_XMM sse2
-DEBLOCK_LUMA
-DEBLOCK_LUMA_INTRA
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-DEBLOCK_LUMA
-DEBLOCK_LUMA_INTRA
-%endif
-%endif
-
-; in: %1=p0, %2=q0, %3=p1, %4=q1, %5=mask, %6=tmp, %7=tmp
-; out: %1=p0', %2=q0'
-%macro CHROMA_DEBLOCK_P0_Q0_INTRA 7
- mova %6, [pw_2]
- paddw %6, %3
- paddw %6, %4
- paddw %7, %6, %2
- paddw %6, %1
- paddw %6, %3
- paddw %7, %4
- psraw %6, 2
- psraw %7, 2
- psubw %6, %1
- psubw %7, %2
- pand %6, %5
- pand %7, %5
- paddw %1, %6
- paddw %2, %7
-%endmacro
-
-%macro CHROMA_V_LOAD 1
- mova m0, [r0] ; p1
- mova m1, [r0+r1] ; p0
- mova m2, [%1] ; q0
- mova m3, [%1+r1] ; q1
-%endmacro
-
-%macro CHROMA_V_STORE 0
- mova [r0+1*r1], m1
- mova [r0+2*r1], m2
-%endmacro
-
-%macro CHROMA_V_LOAD_TC 2
- movd %1, [%2]
- punpcklbw %1, %1
- punpcklwd %1, %1
- psraw %1, 6
-%endmacro
-
-%macro DEBLOCK_CHROMA 0
-;-----------------------------------------------------------------------------
-; void deblock_v_chroma( 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
- sub r0, r1
- sub r0, r1
- shl r2d, 2
- shl r3d, 2
-%if mmsize < 16
- mov r6, 16/mmsize
-.loop:
-%endif
- CHROMA_V_LOAD r5
- LOAD_AB m4, m5, r2d, r3d
- LOAD_MASK m0, m1, m2, m3, m4, m5, m7, m6, m4
- pxor m4, m4
- CHROMA_V_LOAD_TC m6, r4
- psubw m6, [pw_3]
- pmaxsw m6, m4
- pand m7, m6
- DEBLOCK_P0_Q0 m1, m2, m0, m3, m7, m5, m6
- CHROMA_V_STORE
-%if mmsize < 16
- add r0, mmsize
- add r5, mmsize
- add r4, mmsize/4
- dec r6
- jg .loop
- REP_RET
-%else
- RET
-%endif
-
-;-----------------------------------------------------------------------------
-; void deblock_v_chroma_intra( 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
- sub r0, r1
- sub r0, r1
- shl r2d, 2
- shl r3d, 2
-%if mmsize < 16
- mov r5, 16/mmsize
-.loop:
-%endif
- CHROMA_V_LOAD r4
- LOAD_AB m4, m5, r2d, r3d
- LOAD_MASK m0, m1, m2, m3, m4, m5, m7, m6, m4
- CHROMA_DEBLOCK_P0_Q0_INTRA m1, m2, m0, m3, m7, m5, m6
- CHROMA_V_STORE
-%if mmsize < 16
- add r0, mmsize
- add r4, mmsize
- dec r5
- jg .loop
- REP_RET
-%else
- RET
-%endif
-%endmacro
-
-%if ARCH_X86_64 == 0
-INIT_MMX mmxext
-DEBLOCK_CHROMA
-%endif
-INIT_XMM sse2
-DEBLOCK_CHROMA
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-DEBLOCK_CHROMA
-%endif
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/h264_i386.h b/src/thirdparty/ffmpeg/libavcodec/x86/h264_i386.h
deleted file mode 100644
index 862c3342d..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/h264_i386.h
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * H.26L/H.264/AVC/JVT/14496-10/... encoder/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.
- * non-MMX i386-specific optimizations for H.264
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#ifndef AVCODEC_X86_H264_I386_H
-#define AVCODEC_X86_H264_I386_H
-
-#include <stddef.h>
-
-#include "libavcodec/cabac.h"
-#include "cabac.h"
-
-#if HAVE_INLINE_ASM
-
-//FIXME use some macros to avoid duplicating get_cabac (cannot be done yet
-//as that would make optimization work hard)
-#if HAVE_7REGS
-#define decode_significance decode_significance_x86
-static int decode_significance_x86(CABACContext *c, int max_coeff,
- uint8_t *significant_coeff_ctx_base,
- int *index, x86_reg last_off){
- void *end= significant_coeff_ctx_base + max_coeff - 1;
- int minusstart= -(intptr_t)significant_coeff_ctx_base;
- int minusindex= 4-(intptr_t)index;
- int bit;
- x86_reg coeff_count;
-
-#ifdef BROKEN_RELOCATIONS
- void *tables;
-
- __asm__ volatile(
- "lea "MANGLE(ff_h264_cabac_tables)", %0 \n\t"
- : "=&r"(tables)
- );
-#endif
-
- __asm__ volatile(
- "3: \n\t"
-
- BRANCHLESS_GET_CABAC("%4", "%q4", "(%1)", "%3", "%w3",
- "%5", "%q5", "%k0", "%b0",
- "%c11(%6)", "%c12(%6)",
- AV_STRINGIFY(H264_NORM_SHIFT_OFFSET),
- AV_STRINGIFY(H264_LPS_RANGE_OFFSET),
- AV_STRINGIFY(H264_MLPS_STATE_OFFSET),
- "%13")
-
- "test $1, %4 \n\t"
- " jz 4f \n\t"
- "add %10, %1 \n\t"
-
- BRANCHLESS_GET_CABAC("%4", "%q4", "(%1)", "%3", "%w3",
- "%5", "%q5", "%k0", "%b0",
- "%c11(%6)", "%c12(%6)",
- AV_STRINGIFY(H264_NORM_SHIFT_OFFSET),
- AV_STRINGIFY(H264_LPS_RANGE_OFFSET),
- AV_STRINGIFY(H264_MLPS_STATE_OFFSET),
- "%13")
-
- "sub %10, %1 \n\t"
- "mov %2, %0 \n\t"
- "movl %7, %%ecx \n\t"
- "add %1, %%"REG_c" \n\t"
- "movl %%ecx, (%0) \n\t"
-
- "test $1, %4 \n\t"
- " jnz 5f \n\t"
-
- "add"OPSIZE" $4, %2 \n\t"
-
- "4: \n\t"
- "add $1, %1 \n\t"
- "cmp %8, %1 \n\t"
- " jb 3b \n\t"
- "mov %2, %0 \n\t"
- "movl %7, %%ecx \n\t"
- "add %1, %%"REG_c" \n\t"
- "movl %%ecx, (%0) \n\t"
- "5: \n\t"
- "add %9, %k0 \n\t"
- "shr $2, %k0 \n\t"
- : "=&q"(coeff_count), "+r"(significant_coeff_ctx_base), "+m"(index),
- "+&r"(c->low), "=&r"(bit), "+&r"(c->range)
- : "r"(c), "m"(minusstart), "m"(end), "m"(minusindex), "m"(last_off),
- "i"(offsetof(CABACContext, bytestream)),
- "i"(offsetof(CABACContext, bytestream_end))
- TABLES_ARG
- : "%"REG_c, "memory"
- );
- return coeff_count;
-}
-
-#define decode_significance_8x8 decode_significance_8x8_x86
-static int decode_significance_8x8_x86(CABACContext *c,
- uint8_t *significant_coeff_ctx_base,
- int *index, uint8_t *last_coeff_ctx_base, const uint8_t *sig_off){
- int minusindex= 4-(intptr_t)index;
- int bit;
- x86_reg coeff_count;
- x86_reg last=0;
- x86_reg state;
-
-#ifdef BROKEN_RELOCATIONS
- void *tables;
-
- __asm__ volatile(
- "lea "MANGLE(ff_h264_cabac_tables)", %0 \n\t"
- : "=&r"(tables)
- );
-#endif
-
- __asm__ volatile(
- "mov %1, %6 \n\t"
- "3: \n\t"
-
- "mov %10, %0 \n\t"
- "movzbl (%0, %6), %k6 \n\t"
- "add %9, %6 \n\t"
-
- BRANCHLESS_GET_CABAC("%4", "%q4", "(%6)", "%3", "%w3",
- "%5", "%q5", "%k0", "%b0",
- "%c12(%7)", "%c13(%7)",
- AV_STRINGIFY(H264_NORM_SHIFT_OFFSET),
- AV_STRINGIFY(H264_LPS_RANGE_OFFSET),
- AV_STRINGIFY(H264_MLPS_STATE_OFFSET),
- "%15")
-
- "mov %1, %k6 \n\t"
- "test $1, %4 \n\t"
- " jz 4f \n\t"
-
-#ifdef BROKEN_RELOCATIONS
- "movzbl %c14(%15, %q6), %k6\n\t"
-#else
- "movzbl "MANGLE(ff_h264_cabac_tables)"+%c14(%k6), %k6\n\t"
-#endif
- "add %11, %6 \n\t"
-
- BRANCHLESS_GET_CABAC("%4", "%q4", "(%6)", "%3", "%w3",
- "%5", "%q5", "%k0", "%b0",
- "%c12(%7)", "%c13(%7)",
- AV_STRINGIFY(H264_NORM_SHIFT_OFFSET),
- AV_STRINGIFY(H264_LPS_RANGE_OFFSET),
- AV_STRINGIFY(H264_MLPS_STATE_OFFSET),
- "%15")
-
- "mov %2, %0 \n\t"
- "mov %1, %k6 \n\t"
- "movl %k6, (%0) \n\t"
-
- "test $1, %4 \n\t"
- " jnz 5f \n\t"
-
- "add"OPSIZE" $4, %2 \n\t"
-
- "4: \n\t"
- "addl $1, %k6 \n\t"
- "mov %k6, %1 \n\t"
- "cmpl $63, %k6 \n\t"
- " jb 3b \n\t"
- "mov %2, %0 \n\t"
- "movl %k6, (%0) \n\t"
- "5: \n\t"
- "addl %8, %k0 \n\t"
- "shr $2, %k0 \n\t"
- : "=&q"(coeff_count), "+m"(last), "+m"(index), "+&r"(c->low),
- "=&r"(bit), "+&r"(c->range), "=&r"(state)
- : "r"(c), "m"(minusindex), "m"(significant_coeff_ctx_base),
- "m"(sig_off), "m"(last_coeff_ctx_base),
- "i"(offsetof(CABACContext, bytestream)),
- "i"(offsetof(CABACContext, bytestream_end)),
- "i"(H264_LAST_COEFF_FLAG_OFFSET_8x8_OFFSET) TABLES_ARG
- : "%"REG_c, "memory"
- );
- return coeff_count;
-}
-#endif /* HAVE_7REGS && !defined(BROKEN_RELOCATIONS) */
-
-#endif /* HAVE_INLINE_ASM */
-#endif /* AVCODEC_X86_H264_I386_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/h264_idct.asm b/src/thirdparty/ffmpeg/libavcodec/x86/h264_idct.asm
deleted file mode 100644
index 0fb2e915a..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/h264_idct.asm
+++ /dev/null
@@ -1,1015 +0,0 @@
-;*****************************************************************************
-;* MMX/SSE2-optimized H.264 iDCT
-;*****************************************************************************
-;* Copyright (C) 2004-2005 Michael Niedermayer, Loren Merritt
-;* Copyright (C) 2003-2008 x264 project
-;*
-;* Authors: Laurent Aimar <fenrir@via.ecp.fr>
-;* Loren Merritt <lorenm@u.washington.edu>
-;* Holger Lubitz <hal@duncan.ol.sub.de>
-;* Min Chen <chenm001.163.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
-
-; FIXME this table is a duplicate from h264data.h, and will be removed once the tables from, h264 have been split
-scan8_mem: db 4+ 1*8, 5+ 1*8, 4+ 2*8, 5+ 2*8
- db 6+ 1*8, 7+ 1*8, 6+ 2*8, 7+ 2*8
- db 4+ 3*8, 5+ 3*8, 4+ 4*8, 5+ 4*8
- db 6+ 3*8, 7+ 3*8, 6+ 4*8, 7+ 4*8
- db 4+ 6*8, 5+ 6*8, 4+ 7*8, 5+ 7*8
- db 6+ 6*8, 7+ 6*8, 6+ 7*8, 7+ 7*8
- db 4+ 8*8, 5+ 8*8, 4+ 9*8, 5+ 9*8
- db 6+ 8*8, 7+ 8*8, 6+ 9*8, 7+ 9*8
- db 4+11*8, 5+11*8, 4+12*8, 5+12*8
- db 6+11*8, 7+11*8, 6+12*8, 7+12*8
- db 4+13*8, 5+13*8, 4+14*8, 5+14*8
- db 6+13*8, 7+13*8, 6+14*8, 7+14*8
-%ifdef PIC
-%define npicregs 1
-%define scan8 picregq
-%else
-%define npicregs 0
-%define scan8 scan8_mem
-%endif
-
-cextern pw_32
-cextern pw_1
-
-SECTION .text
-
-; %1=uint8_t *dst, %2=int16_t *block, %3=int stride
-%macro IDCT4_ADD 3
- ; Load dct coeffs
- movq m0, [%2]
- movq m1, [%2+8]
- movq m2, [%2+16]
- movq m3, [%2+24]
-
- IDCT4_1D w, 0, 1, 2, 3, 4, 5
- mova m6, [pw_32]
- TRANSPOSE4x4W 0, 1, 2, 3, 4
- paddw m0, m6
- IDCT4_1D w, 0, 1, 2, 3, 4, 5
- pxor m7, m7
-
- STORE_DIFFx2 m0, m1, m4, m5, m7, 6, %1, %3
- lea %1, [%1+%3*2]
- STORE_DIFFx2 m2, m3, m4, m5, m7, 6, %1, %3
-%endmacro
-
-INIT_MMX mmx
-; ff_h264_idct_add_mmx(uint8_t *dst, int16_t *block, int stride)
-cglobal h264_idct_add_8, 3, 3, 0
- IDCT4_ADD r0, r1, r2
- RET
-
-%macro IDCT8_1D 2
- mova m0, m1
- psraw m1, 1
- mova m4, m5
- psraw m4, 1
- paddw m4, m5
- paddw m1, m0
- paddw m4, m7
- paddw m1, m5
- psubw m4, m0
- paddw m1, m3
-
- psubw m0, m3
- psubw m5, m3
- psraw m3, 1
- paddw m0, m7
- psubw m5, m7
- psraw m7, 1
- psubw m0, m3
- psubw m5, m7
-
- mova m7, m1
- psraw m1, 2
- mova m3, m4
- psraw m3, 2
- paddw m3, m0
- psraw m0, 2
- paddw m1, m5
- psraw m5, 2
- psubw m0, m4
- psubw m7, m5
-
- mova m5, m6
- psraw m6, 1
- mova m4, m2
- psraw m4, 1
- paddw m6, m2
- psubw m4, m5
-
- mova m2, %1
- mova m5, %2
- SUMSUB_BA w, 5, 2
- SUMSUB_BA w, 6, 5
- SUMSUB_BA w, 4, 2
- SUMSUB_BA w, 7, 6
- SUMSUB_BA w, 0, 4
- SUMSUB_BA w, 3, 2
- SUMSUB_BA w, 1, 5
- SWAP 7, 6, 4, 5, 2, 3, 1, 0 ; 70315246 -> 01234567
-%endmacro
-
-%macro IDCT8_1D_FULL 1
- mova m7, [%1+112]
- mova m6, [%1+ 96]
- mova m5, [%1+ 80]
- mova m3, [%1+ 48]
- mova m2, [%1+ 32]
- mova m1, [%1+ 16]
- IDCT8_1D [%1], [%1+ 64]
-%endmacro
-
-; %1=int16_t *block, %2=int16_t *dstblock
-%macro IDCT8_ADD_MMX_START 2
- IDCT8_1D_FULL %1
- mova [%1], m7
- TRANSPOSE4x4W 0, 1, 2, 3, 7
- mova m7, [%1]
- mova [%2 ], m0
- mova [%2+16], m1
- mova [%2+32], m2
- mova [%2+48], m3
- TRANSPOSE4x4W 4, 5, 6, 7, 3
- mova [%2+ 8], m4
- mova [%2+24], m5
- mova [%2+40], m6
- mova [%2+56], m7
-%endmacro
-
-; %1=uint8_t *dst, %2=int16_t *block, %3=int stride
-%macro IDCT8_ADD_MMX_END 3
- IDCT8_1D_FULL %2
- mova [%2 ], m5
- mova [%2+16], m6
- mova [%2+32], m7
-
- pxor m7, m7
- STORE_DIFFx2 m0, m1, m5, m6, m7, 6, %1, %3
- lea %1, [%1+%3*2]
- STORE_DIFFx2 m2, m3, m5, m6, m7, 6, %1, %3
- mova m0, [%2 ]
- mova m1, [%2+16]
- mova m2, [%2+32]
- lea %1, [%1+%3*2]
- STORE_DIFFx2 m4, m0, m5, m6, m7, 6, %1, %3
- lea %1, [%1+%3*2]
- STORE_DIFFx2 m1, m2, m5, m6, m7, 6, %1, %3
-%endmacro
-
-INIT_MMX mmx
-; ff_h264_idct8_add_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
-
- add word [r1], 32
- IDCT8_ADD_MMX_START r1 , rsp
- IDCT8_ADD_MMX_START r1+8, rsp+64
- lea r3, [r0+4]
- IDCT8_ADD_MMX_END r0 , rsp, r2
- IDCT8_ADD_MMX_END r3 , rsp+8, r2
-
- ADD rsp, pad
- RET
-
-; %1=uint8_t *dst, %2=int16_t *block, %3=int stride
-%macro IDCT8_ADD_SSE 4
- IDCT8_1D_FULL %2
-%if ARCH_X86_64
- TRANSPOSE8x8W 0, 1, 2, 3, 4, 5, 6, 7, 8
-%else
- TRANSPOSE8x8W 0, 1, 2, 3, 4, 5, 6, 7, [%2], [%2+16]
-%endif
- paddw m0, [pw_32]
-
-%if ARCH_X86_64 == 0
- mova [%2 ], m0
- mova [%2+16], m4
- IDCT8_1D [%2], [%2+ 16]
- mova [%2 ], m6
- mova [%2+16], m7
-%else
- SWAP 0, 8
- SWAP 4, 9
- IDCT8_1D m8, m9
- SWAP 6, 8
- SWAP 7, 9
-%endif
-
- pxor m7, m7
- lea %4, [%3*3]
- STORE_DIFF m0, m6, m7, [%1 ]
- STORE_DIFF m1, m6, m7, [%1+%3 ]
- STORE_DIFF m2, m6, m7, [%1+%3*2]
- STORE_DIFF m3, m6, m7, [%1+%4 ]
-%if ARCH_X86_64 == 0
- mova m0, [%2 ]
- mova m1, [%2+16]
-%else
- SWAP 0, 8
- SWAP 1, 9
-%endif
- lea %1, [%1+%3*4]
- STORE_DIFF m4, m6, m7, [%1 ]
- STORE_DIFF m5, m6, m7, [%1+%3 ]
- STORE_DIFF m0, m6, m7, [%1+%3*2]
- STORE_DIFF m1, m6, m7, [%1+%4 ]
-%endmacro
-
-INIT_XMM sse2
-; ff_h264_idct8_add_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
-
-%macro DC_ADD_MMXEXT_INIT 2-3
-%if %0 == 2
- movsx %1, word [%1]
- add %1, 32
- sar %1, 6
- movd m0, %1d
- lea %1, [%2*3]
-%else
- add %3, 32
- sar %3, 6
- movd m0, %3d
- lea %3, [%2*3]
-%endif
- pshufw m0, m0, 0
- pxor m1, m1
- psubw m1, m0
- packuswb m0, m0
- packuswb m1, m1
-%endmacro
-
-%macro DC_ADD_MMXEXT_OP 4
- %1 m2, [%2 ]
- %1 m3, [%2+%3 ]
- %1 m4, [%2+%3*2]
- %1 m5, [%2+%4 ]
- paddusb m2, m0
- paddusb m3, m0
- paddusb m4, m0
- paddusb m5, m0
- psubusb m2, m1
- psubusb m3, m1
- psubusb m4, m1
- psubusb m5, m1
- %1 [%2 ], m2
- %1 [%2+%3 ], m3
- %1 [%2+%3*2], m4
- %1 [%2+%4 ], m5
-%endmacro
-
-INIT_MMX mmxext
-; ff_h264_idct_dc_add_mmxext(uint8_t *dst, int16_t *block, int stride)
-cglobal h264_idct_dc_add_8, 3, 3, 0
- DC_ADD_MMXEXT_INIT r1, r2
- DC_ADD_MMXEXT_OP movh, r0, r2, r1
- RET
-
-; ff_h264_idct8_dc_add_mmxext(uint8_t *dst, int16_t *block, int stride)
-cglobal h264_idct8_dc_add_8, 3, 3, 0
- DC_ADD_MMXEXT_INIT r1, r2
- DC_ADD_MMXEXT_OP mova, r0, r2, r1
- lea r0, [r0+r2*4]
- DC_ADD_MMXEXT_OP mova, r0, r2, r1
- RET
-
-INIT_MMX mmx
-; ff_h264_idct_add16_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
- lea picregq, [scan8_mem]
-%endif
-.nextblock:
- movzx r6, byte [scan8+r5]
- movzx r6, byte [r4+r6]
- test r6, r6
- jz .skipblock
- mov r6d, dword [r1+r5*4]
- lea r6, [r0+r6]
- IDCT4_ADD r6, r2, r3
-.skipblock:
- inc r5
- add r2, 32
- cmp r5, 16
- jl .nextblock
- REP_RET
-
-; ff_h264_idct8_add4_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
-
- xor r5, r5
-%ifdef PIC
- lea picregq, [scan8_mem]
-%endif
-.nextblock:
- movzx r6, byte [scan8+r5]
- movzx r6, byte [r4+r6]
- test r6, r6
- jz .skipblock
- mov r6d, dword [r1+r5*4]
- add r6, r0
- add word [r2], 32
- IDCT8_ADD_MMX_START r2 , rsp
- IDCT8_ADD_MMX_START r2+8, rsp+64
- IDCT8_ADD_MMX_END r6 , rsp, r3
- mov r6d, dword [r1+r5*4]
- lea r6, [r0+r6+4]
- IDCT8_ADD_MMX_END r6 , rsp+8, r3
-.skipblock:
- add r5, 4
- add r2, 128
- cmp r5, 16
- jl .nextblock
- ADD rsp, pad
- RET
-
-INIT_MMX mmxext
-; ff_h264_idct_add16_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
- lea picregq, [scan8_mem]
-%endif
-.nextblock:
- movzx r6, byte [scan8+r5]
- movzx r6, byte [r4+r6]
- test r6, r6
- jz .skipblock
- cmp r6, 1
- jnz .no_dc
- movsx r6, word [r2]
- test r6, r6
- jz .no_dc
- DC_ADD_MMXEXT_INIT r2, r3, r6
-%if ARCH_X86_64 == 0
-%define dst2q r1
-%define dst2d r1d
-%endif
- mov dst2d, dword [r1+r5*4]
- lea dst2q, [r0+dst2q]
- DC_ADD_MMXEXT_OP movh, dst2q, r3, r6
-%if ARCH_X86_64 == 0
- mov r1, r1m
-%endif
- inc r5
- add r2, 32
- cmp r5, 16
- jl .nextblock
- REP_RET
-.no_dc:
- mov r6d, dword [r1+r5*4]
- add r6, r0
- IDCT4_ADD r6, r2, r3
-.skipblock:
- inc r5
- add r2, 32
- cmp r5, 16
- jl .nextblock
- REP_RET
-
-INIT_MMX mmx
-; ff_h264_idct_add16intra_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
- lea picregq, [scan8_mem]
-%endif
-.nextblock:
- movzx r6, byte [scan8+r5]
- movzx r6, byte [r4+r6]
- or r6w, word [r2]
- test r6, r6
- jz .skipblock
- mov r6d, dword [r1+r5*4]
- add r6, r0
- IDCT4_ADD r6, r2, r3
-.skipblock:
- inc r5
- add r2, 32
- cmp r5, 16
- jl .nextblock
- REP_RET
-
-INIT_MMX mmxext
-; ff_h264_idct_add16intra_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
- lea picregq, [scan8_mem]
-%endif
-.nextblock:
- movzx r6, byte [scan8+r5]
- movzx r6, byte [r4+r6]
- test r6, r6
- jz .try_dc
- mov r6d, dword [r1+r5*4]
- lea r6, [r0+r6]
- IDCT4_ADD r6, r2, r3
- inc r5
- add r2, 32
- cmp r5, 16
- jl .nextblock
- REP_RET
-.try_dc:
- movsx r6, word [r2]
- test r6, r6
- jz .skipblock
- DC_ADD_MMXEXT_INIT r2, r3, r6
-%if ARCH_X86_64 == 0
-%define dst2q r1
-%define dst2d r1d
-%endif
- mov dst2d, dword [r1+r5*4]
- add dst2q, r0
- DC_ADD_MMXEXT_OP movh, dst2q, r3, r6
-%if ARCH_X86_64 == 0
- mov r1, r1m
-%endif
-.skipblock:
- inc r5
- add r2, 32
- cmp r5, 16
- jl .nextblock
- REP_RET
-
-; ff_h264_idct8_add4_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
-
- xor r5, r5
-%ifdef PIC
- lea picregq, [scan8_mem]
-%endif
-.nextblock:
- movzx r6, byte [scan8+r5]
- movzx r6, byte [r4+r6]
- test r6, r6
- jz .skipblock
- cmp r6, 1
- jnz .no_dc
- movsx r6, word [r2]
- test r6, r6
- jz .no_dc
- DC_ADD_MMXEXT_INIT r2, r3, r6
-%if ARCH_X86_64 == 0
-%define dst2q r1
-%define dst2d r1d
-%endif
- mov dst2d, dword [r1+r5*4]
- lea dst2q, [r0+dst2q]
- DC_ADD_MMXEXT_OP mova, dst2q, r3, r6
- lea dst2q, [dst2q+r3*4]
- DC_ADD_MMXEXT_OP mova, dst2q, r3, r6
-%if ARCH_X86_64 == 0
- mov r1, r1m
-%endif
- add r5, 4
- add r2, 128
- cmp r5, 16
- jl .nextblock
-
- ADD rsp, pad
- RET
-.no_dc:
- mov r6d, dword [r1+r5*4]
- add r6, r0
- add word [r2], 32
- IDCT8_ADD_MMX_START r2 , rsp
- IDCT8_ADD_MMX_START r2+8, rsp+64
- IDCT8_ADD_MMX_END r6 , rsp, r3
- mov r6d, dword [r1+r5*4]
- lea r6, [r0+r6+4]
- IDCT8_ADD_MMX_END r6 , rsp+8, r3
-.skipblock:
- add r5, 4
- add r2, 128
- cmp r5, 16
- jl .nextblock
-
- ADD rsp, pad
- RET
-
-INIT_XMM sse2
-; ff_h264_idct8_add4_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
- lea picregq, [scan8_mem]
-%endif
-.nextblock:
- movzx r6, byte [scan8+r5]
- movzx r6, byte [r4+r6]
- test r6, r6
- jz .skipblock
- cmp r6, 1
- jnz .no_dc
- movsx r6, word [r2]
- test r6, r6
- jz .no_dc
-INIT_MMX cpuname
- DC_ADD_MMXEXT_INIT r2, r3, r6
-%if ARCH_X86_64 == 0
-%define dst2q r1
-%define dst2d r1d
-%endif
- mov dst2d, dword [r1+r5*4]
- add dst2q, r0
- DC_ADD_MMXEXT_OP mova, dst2q, r3, r6
- lea dst2q, [dst2q+r3*4]
- DC_ADD_MMXEXT_OP mova, dst2q, r3, r6
-%if ARCH_X86_64 == 0
- mov r1, r1m
-%endif
- add r5, 4
- add r2, 128
- cmp r5, 16
- jl .nextblock
- REP_RET
-.no_dc:
-INIT_XMM cpuname
- mov dst2d, dword [r1+r5*4]
- add dst2q, r0
- IDCT8_ADD_SSE dst2q, r2, r3, r6
-%if ARCH_X86_64 == 0
- mov r1, r1m
-%endif
-.skipblock:
- add r5, 4
- add r2, 128
- cmp r5, 16
- jl .nextblock
- REP_RET
-
-INIT_MMX mmx
-h264_idct_add8_mmx_plane:
-.nextblock:
- movzx r6, byte [scan8+r5]
- movzx r6, byte [r4+r6]
- or r6w, word [r2]
- test r6, r6
- jz .skipblock
-%if ARCH_X86_64
- mov r0d, dword [r1+r5*4]
- add r0, [dst2q]
-%else
- mov r0, r1m ; XXX r1m here is actually r0m of the calling func
- mov r0, [r0]
- add r0, dword [r1+r5*4]
-%endif
- IDCT4_ADD r0, r2, r3
-.skipblock:
- inc r5
- add r2, 32
- test r5, 3
- jnz .nextblock
- rep ret
-
-; ff_h264_idct_add8_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
-%ifdef PIC
- lea picregq, [scan8_mem]
-%endif
-%if ARCH_X86_64
- mov dst2q, r0
-%endif
- call h264_idct_add8_mmx_plane
- mov r5, 32
- add r2, 384
-%if ARCH_X86_64
- add dst2q, gprsize
-%else
- add r0mp, gprsize
-%endif
- call h264_idct_add8_mmx_plane
- RET
-
-h264_idct_add8_mmxext_plane:
-.nextblock:
- movzx r6, byte [scan8+r5]
- movzx r6, byte [r4+r6]
- test r6, r6
- jz .try_dc
-%if ARCH_X86_64
- mov r0d, dword [r1+r5*4]
- add r0, [dst2q]
-%else
- mov r0, r1m ; XXX r1m here is actually r0m of the calling func
- mov r0, [r0]
- add r0, dword [r1+r5*4]
-%endif
- IDCT4_ADD r0, r2, r3
- inc r5
- add r2, 32
- test r5, 3
- jnz .nextblock
- rep ret
-.try_dc:
- movsx r6, word [r2]
- test r6, r6
- jz .skipblock
- DC_ADD_MMXEXT_INIT r2, r3, r6
-%if ARCH_X86_64
- mov r0d, dword [r1+r5*4]
- add r0, [dst2q]
-%else
- mov r0, r1m ; XXX r1m here is actually r0m of the calling func
- mov r0, [r0]
- add r0, dword [r1+r5*4]
-%endif
- DC_ADD_MMXEXT_OP movh, r0, r3, r6
-.skipblock:
- inc r5
- add r2, 32
- test r5, 3
- jnz .nextblock
- rep ret
-
-INIT_MMX mmxext
-; ff_h264_idct_add8_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
-%if ARCH_X86_64
- mov dst2q, r0
-%endif
-%ifdef PIC
- lea picregq, [scan8_mem]
-%endif
- call h264_idct_add8_mmxext_plane
- mov r5, 32
- add r2, 384
-%if ARCH_X86_64
- add dst2q, gprsize
-%else
- add r0mp, gprsize
-%endif
- call h264_idct_add8_mmxext_plane
- RET
-
-; r0 = uint8_t *dst, r2 = int16_t *block, r3 = int stride, r6=clobbered
-h264_idct_dc_add8_mmxext:
- movd m0, [r2 ] ; 0 0 X D
- punpcklwd m0, [r2+32] ; x X d D
- paddsw m0, [pw_32]
- psraw m0, 6
- punpcklwd m0, m0 ; d d D D
- pxor m1, m1 ; 0 0 0 0
- psubw m1, m0 ; -d-d-D-D
- packuswb m0, m1 ; -d-d-D-D d d D D
- pshufw m1, m0, 0xFA ; -d-d-d-d-D-D-D-D
- punpcklwd m0, m0 ; d d d d D D D D
- lea r6, [r3*3]
- DC_ADD_MMXEXT_OP movq, r0, r3, r6
- ret
-
-ALIGN 16
-INIT_XMM sse2
-; r0 = uint8_t *dst (clobbered), r2 = int16_t *block, r3 = int stride
-h264_add8x4_idct_sse2:
- movq m0, [r2+ 0]
- movq m1, [r2+ 8]
- movq m2, [r2+16]
- movq m3, [r2+24]
- movhps m0, [r2+32]
- movhps m1, [r2+40]
- movhps m2, [r2+48]
- movhps m3, [r2+56]
- IDCT4_1D w,0,1,2,3,4,5
- TRANSPOSE2x4x4W 0,1,2,3,4
- paddw m0, [pw_32]
- IDCT4_1D w,0,1,2,3,4,5
- pxor m7, m7
- STORE_DIFFx2 m0, m1, m4, m5, m7, 6, r0, r3
- lea r0, [r0+r3*2]
- STORE_DIFFx2 m2, m3, m4, m5, m7, 6, r0, r3
- ret
-
-%macro add16_sse2_cycle 2
- movzx r0, word [r4+%2]
- test r0, r0
- jz .cycle%1end
- mov r0d, dword [r1+%1*8]
-%if ARCH_X86_64
- add r0, r5
-%else
- add r0, r0m
-%endif
- call h264_add8x4_idct_sse2
-.cycle%1end:
-%if %1 < 7
- add r2, 64
-%endif
-%endmacro
-
-; ff_h264_idct_add16_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
-%endif
- ; unrolling of the loop leads to an average performance gain of
- ; 20-25%
- add16_sse2_cycle 0, 0xc
- add16_sse2_cycle 1, 0x14
- add16_sse2_cycle 2, 0xe
- add16_sse2_cycle 3, 0x16
- add16_sse2_cycle 4, 0x1c
- add16_sse2_cycle 5, 0x24
- add16_sse2_cycle 6, 0x1e
- add16_sse2_cycle 7, 0x26
- RET
-
-%macro add16intra_sse2_cycle 2
- movzx r0, word [r4+%2]
- test r0, r0
- jz .try%1dc
- mov r0d, dword [r1+%1*8]
-%if ARCH_X86_64
- add r0, r7
-%else
- add r0, r0m
-%endif
- call h264_add8x4_idct_sse2
- jmp .cycle%1end
-.try%1dc:
- movsx r0, word [r2 ]
- or r0w, word [r2+32]
- jz .cycle%1end
- mov r0d, dword [r1+%1*8]
-%if ARCH_X86_64
- add r0, r7
-%else
- add r0, r0m
-%endif
- call h264_idct_dc_add8_mmxext
-.cycle%1end:
-%if %1 < 7
- add r2, 64
-%endif
-%endmacro
-
-; ff_h264_idct_add16intra_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
-%endif
- add16intra_sse2_cycle 0, 0xc
- add16intra_sse2_cycle 1, 0x14
- add16intra_sse2_cycle 2, 0xe
- add16intra_sse2_cycle 3, 0x16
- add16intra_sse2_cycle 4, 0x1c
- add16intra_sse2_cycle 5, 0x24
- add16intra_sse2_cycle 6, 0x1e
- add16intra_sse2_cycle 7, 0x26
- RET
-
-%macro add8_sse2_cycle 2
- movzx r0, word [r4+%2]
- test r0, r0
- jz .try%1dc
-%if ARCH_X86_64
- mov r0d, dword [r1+(%1&1)*8+64*(1+(%1>>1))]
- add r0, [r7]
-%else
- mov r0, r0m
- mov r0, [r0]
- add r0, dword [r1+(%1&1)*8+64*(1+(%1>>1))]
-%endif
- call h264_add8x4_idct_sse2
- jmp .cycle%1end
-.try%1dc:
- movsx r0, word [r2 ]
- or r0w, word [r2+32]
- jz .cycle%1end
-%if ARCH_X86_64
- mov r0d, dword [r1+(%1&1)*8+64*(1+(%1>>1))]
- add r0, [r7]
-%else
- mov r0, r0m
- mov r0, [r0]
- add r0, dword [r1+(%1&1)*8+64*(1+(%1>>1))]
-%endif
- call h264_idct_dc_add8_mmxext
-.cycle%1end:
-%if %1 == 1
- add r2, 384+64
-%elif %1 < 3
- add r2, 64
-%endif
-%endmacro
-
-; ff_h264_idct_add8_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
- mov r7, r0
-%endif
- add8_sse2_cycle 0, 0x34
- add8_sse2_cycle 1, 0x3c
-%if ARCH_X86_64
- add r7, gprsize
-%else
- add r0mp, gprsize
-%endif
- add8_sse2_cycle 2, 0x5c
- add8_sse2_cycle 3, 0x64
- RET
-
-;void ff_h264_luma_dc_dequant_idct_mmx(int16_t *output, int16_t *input, int qmul)
-
-%macro WALSH4_1D 5
- SUMSUB_BADC w, %4, %3, %2, %1, %5
- SUMSUB_BADC w, %4, %2, %3, %1, %5
- SWAP %1, %4, %3
-%endmacro
-
-%macro DEQUANT_MMX 3
- mova m7, [pw_1]
- mova m4, %1
- punpcklwd %1, m7
- punpckhwd m4, m7
- mova m5, %2
- punpcklwd %2, m7
- punpckhwd m5, m7
- movd m7, t3d
- punpckldq m7, m7
- pmaddwd %1, m7
- pmaddwd %2, m7
- pmaddwd m4, m7
- pmaddwd m5, m7
- psrad %1, %3
- psrad %2, %3
- psrad m4, %3
- psrad m5, %3
- packssdw %1, m4
- packssdw %2, m5
-%endmacro
-
-%macro STORE_WORDS 5-9
-%if cpuflag(sse)
- movd t0d, %1
- psrldq %1, 4
- movd t1d, %1
- psrldq %1, 4
- mov [t2+%2*32], t0w
- mov [t2+%4*32], t1w
- shr t0d, 16
- shr t1d, 16
- mov [t2+%3*32], t0w
- mov [t2+%5*32], t1w
- movd t0d, %1
- psrldq %1, 4
- movd t1d, %1
- mov [t2+%6*32], t0w
- mov [t2+%8*32], t1w
- shr t0d, 16
- shr t1d, 16
- mov [t2+%7*32], t0w
- mov [t2+%9*32], t1w
-%else
- movd t0d, %1
- psrlq %1, 32
- movd t1d, %1
- mov [t2+%2*32], t0w
- mov [t2+%4*32], t1w
- shr t0d, 16
- shr t1d, 16
- mov [t2+%3*32], t0w
- mov [t2+%5*32], t1w
-%endif
-%endmacro
-
-%macro DEQUANT_STORE 1
-%if cpuflag(sse2)
- movd xmm4, t3d
- movq xmm5, [pw_1]
- pshufd xmm4, xmm4, 0
- movq2dq xmm0, m0
- movq2dq xmm1, m1
- movq2dq xmm2, m2
- movq2dq xmm3, m3
- punpcklwd xmm0, xmm5
- punpcklwd xmm1, xmm5
- punpcklwd xmm2, xmm5
- punpcklwd xmm3, xmm5
- pmaddwd xmm0, xmm4
- pmaddwd xmm1, xmm4
- pmaddwd xmm2, xmm4
- pmaddwd xmm3, xmm4
- psrad xmm0, %1
- psrad xmm1, %1
- psrad xmm2, %1
- psrad xmm3, %1
- packssdw xmm0, xmm1
- packssdw xmm2, xmm3
- STORE_WORDS xmm0, 0, 1, 4, 5, 2, 3, 6, 7
- STORE_WORDS xmm2, 8, 9, 12, 13, 10, 11, 14, 15
-%else
- DEQUANT_MMX m0, m1, %1
- STORE_WORDS m0, 0, 1, 4, 5
- STORE_WORDS m1, 2, 3, 6, 7
-
- DEQUANT_MMX m2, m3, %1
- STORE_WORDS m2, 8, 9, 12, 13
- STORE_WORDS m3, 10, 11, 14, 15
-%endif
-%endmacro
-
-%macro IDCT_DC_DEQUANT 1
-cglobal h264_luma_dc_dequant_idct, 3, 4, %1
- ; manually spill XMM registers for Win64 because
- ; the code here is initialized with INIT_MMX
- WIN64_SPILL_XMM %1
- movq m3, [r1+24]
- movq m2, [r1+16]
- movq m1, [r1+ 8]
- movq m0, [r1+ 0]
- WALSH4_1D 0,1,2,3,4
- TRANSPOSE4x4W 0,1,2,3,4
- WALSH4_1D 0,1,2,3,4
-
-; shift, tmp, output, qmul
-%if WIN64
- DECLARE_REG_TMP 0,3,1,2
- ; we can't avoid this, because r0 is the shift register (ecx) on win64
- xchg r0, t2
-%elif ARCH_X86_64
- DECLARE_REG_TMP 3,1,0,2
-%else
- DECLARE_REG_TMP 1,3,0,2
-%endif
-
- cmp t3d, 32767
- jg .big_qmul
- add t3d, 128 << 16
- DEQUANT_STORE 8
- RET
-.big_qmul:
- bsr t0d, t3d
- add t3d, 128 << 16
- mov t1d, 7
- cmp t0d, t1d
- cmovg t0d, t1d
- inc t1d
- shr t3d, t0b
- sub t1d, t0d
-%if cpuflag(sse2)
- movd xmm6, t1d
- DEQUANT_STORE xmm6
-%else
- movd m6, t1d
- DEQUANT_STORE m6
-%endif
- RET
-%endmacro
-
-INIT_MMX mmx
-IDCT_DC_DEQUANT 0
-INIT_MMX sse2
-IDCT_DC_DEQUANT 7
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/h264_idct_10bit.asm b/src/thirdparty/ffmpeg/libavcodec/x86/h264_idct_10bit.asm
deleted file mode 100644
index 5f8bcbf0c..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/h264_idct_10bit.asm
+++ /dev/null
@@ -1,546 +0,0 @@
-;*****************************************************************************
-;* MMX/SSE2/AVX-optimized 10-bit H.264 iDCT code
-;*****************************************************************************
-;* Copyright (C) 2005-2011 x264 project
-;*
-;* Authors: Daniel Kang <daniel.d.kang@gmail.com>
-;*
-;* This file is part of Libav.
-;*
-;* Libav is free software; you can redistribute it and/or
-;* modify it under the terms of the GNU Lesser General Public
-;* License as published by the Free Software Foundation; either
-;* version 2.1 of the License, or (at your option) any later version.
-;*
-;* Libav is distributed in the hope that it will be useful,
-;* but WITHOUT ANY WARRANTY; without even the implied warranty of
-;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-;* Lesser General Public License for more details.
-;*
-;* You should have received a copy of the GNU Lesser General Public
-;* License along with Libav; if not, write to the Free Software
-;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-;******************************************************************************
-
-%include "libavutil/x86/x86util.asm"
-
-SECTION_RODATA
-
-pw_pixel_max: times 8 dw ((1 << 10)-1)
-pd_32: times 4 dd 32
-
-SECTION .text
-
-;-----------------------------------------------------------------------------
-; void h264_idct_add(pixel *dst, dctcoef *block, int stride)
-;-----------------------------------------------------------------------------
-%macro STORE_DIFFx2 6
- psrad %1, 6
- psrad %2, 6
- packssdw %1, %2
- movq %3, [%5]
- movhps %3, [%5+%6]
- paddsw %1, %3
- CLIPW %1, %4, [pw_pixel_max]
- movq [%5], %1
- movhps [%5+%6], %1
-%endmacro
-
-%macro STORE_DIFF16 5
- psrad %1, 6
- psrad %2, 6
- packssdw %1, %2
- paddsw %1, [%5]
- CLIPW %1, %3, %4
- mova [%5], %1
-%endmacro
-
-;dst, in, stride
-%macro IDCT4_ADD_10 3
- mova m0, [%2+ 0]
- mova m1, [%2+16]
- mova m2, [%2+32]
- mova m3, [%2+48]
- IDCT4_1D d,0,1,2,3,4,5
- TRANSPOSE4x4D 0,1,2,3,4
- paddd m0, [pd_32]
- IDCT4_1D d,0,1,2,3,4,5
- pxor m5, m5
- STORE_DIFFx2 m0, m1, m4, m5, %1, %3
- lea %1, [%1+%3*2]
- STORE_DIFFx2 m2, m3, m4, m5, %1, %3
-%endmacro
-
-%macro IDCT_ADD_10 0
-cglobal h264_idct_add_10, 3,3
- IDCT4_ADD_10 r0, r1, r2
- RET
-%endmacro
-
-INIT_XMM sse2
-IDCT_ADD_10
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-IDCT_ADD_10
-%endif
-
-;-----------------------------------------------------------------------------
-; h264_idct_add16(pixel *dst, const int *block_offset, dctcoef *block, int stride, const uint8_t nnzc[6*8])
-;-----------------------------------------------------------------------------
-;;;;;;; NO FATE SAMPLES TRIGGER THIS
-%macro ADD4x4IDCT 0
-add4x4_idct %+ SUFFIX:
- add r5, r0
- mova m0, [r2+ 0]
- mova m1, [r2+16]
- mova m2, [r2+32]
- mova m3, [r2+48]
- IDCT4_1D d,0,1,2,3,4,5
- TRANSPOSE4x4D 0,1,2,3,4
- paddd m0, [pd_32]
- IDCT4_1D d,0,1,2,3,4,5
- pxor m5, m5
- STORE_DIFFx2 m0, m1, m4, m5, r5, r3
- lea r5, [r5+r3*2]
- STORE_DIFFx2 m2, m3, m4, m5, r5, r3
- ret
-%endmacro
-
-INIT_XMM sse2
-ALIGN 16
-ADD4x4IDCT
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-ALIGN 16
-ADD4x4IDCT
-%endif
-
-%macro ADD16_OP 2
- cmp byte [r4+%2], 0
- jz .skipblock%1
- mov r5d, [r1+%1*4]
- call add4x4_idct %+ SUFFIX
-.skipblock%1:
-%if %1<15
- add r2, 64
-%endif
-%endmacro
-
-%macro IDCT_ADD16_10 0
-cglobal h264_idct_add16_10, 5,6
- ADD16_OP 0, 4+1*8
- ADD16_OP 1, 5+1*8
- ADD16_OP 2, 4+2*8
- ADD16_OP 3, 5+2*8
- ADD16_OP 4, 6+1*8
- ADD16_OP 5, 7+1*8
- ADD16_OP 6, 6+2*8
- ADD16_OP 7, 7+2*8
- ADD16_OP 8, 4+3*8
- ADD16_OP 9, 5+3*8
- ADD16_OP 10, 4+4*8
- ADD16_OP 11, 5+4*8
- ADD16_OP 12, 6+3*8
- ADD16_OP 13, 7+3*8
- ADD16_OP 14, 6+4*8
- ADD16_OP 15, 7+4*8
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-IDCT_ADD16_10
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-IDCT_ADD16_10
-%endif
-
-;-----------------------------------------------------------------------------
-; void h264_idct_dc_add(pixel *dst, dctcoef *block, int stride)
-;-----------------------------------------------------------------------------
-%macro IDCT_DC_ADD_OP_10 3
- pxor m5, m5
-%if avx_enabled
- paddw m1, m0, [%1+0 ]
- paddw m2, m0, [%1+%2 ]
- paddw m3, m0, [%1+%2*2]
- paddw m4, m0, [%1+%3 ]
-%else
- mova m1, [%1+0 ]
- mova m2, [%1+%2 ]
- mova m3, [%1+%2*2]
- mova m4, [%1+%3 ]
- paddw m1, m0
- paddw m2, m0
- paddw m3, m0
- paddw m4, m0
-%endif
- CLIPW m1, m5, m6
- CLIPW m2, m5, m6
- CLIPW m3, m5, m6
- CLIPW m4, m5, m6
- mova [%1+0 ], m1
- mova [%1+%2 ], m2
- mova [%1+%2*2], m3
- mova [%1+%3 ], m4
-%endmacro
-
-INIT_MMX mmxext
-cglobal h264_idct_dc_add_10,3,3
- movd m0, [r1]
- paddd m0, [pd_32]
- psrad m0, 6
- lea r1, [r2*3]
- pshufw m0, m0, 0
- mova m6, [pw_pixel_max]
- IDCT_DC_ADD_OP_10 r0, r2, r1
- RET
-
-;-----------------------------------------------------------------------------
-; void h264_idct8_dc_add(pixel *dst, dctcoef *block, int stride)
-;-----------------------------------------------------------------------------
-%macro IDCT8_DC_ADD 0
-cglobal h264_idct8_dc_add_10,3,3,7
- mov r1d, [r1]
- add r1, 32
- sar r1, 6
- movd m0, r1d
- lea r1, [r2*3]
- SPLATW m0, m0, 0
- mova m6, [pw_pixel_max]
- IDCT_DC_ADD_OP_10 r0, r2, r1
- lea r0, [r0+r2*4]
- IDCT_DC_ADD_OP_10 r0, r2, r1
- RET
-%endmacro
-
-INIT_XMM sse2
-IDCT8_DC_ADD
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-IDCT8_DC_ADD
-%endif
-
-;-----------------------------------------------------------------------------
-; h264_idct_add16intra(pixel *dst, const int *block_offset, dctcoef *block, int stride, const uint8_t nnzc[6*8])
-;-----------------------------------------------------------------------------
-%macro AC 1
-.ac%1:
- mov r5d, [r1+(%1+0)*4]
- call add4x4_idct %+ SUFFIX
- mov r5d, [r1+(%1+1)*4]
- add r2, 64
- call add4x4_idct %+ SUFFIX
- add r2, 64
- jmp .skipadd%1
-%endmacro
-
-%assign last_block 16
-%macro ADD16_OP_INTRA 2
- cmp word [r4+%2], 0
- jnz .ac%1
- mov r5d, [r2+ 0]
- or r5d, [r2+64]
- jz .skipblock%1
- mov r5d, [r1+(%1+0)*4]
- call idct_dc_add %+ SUFFIX
-.skipblock%1:
-%if %1<last_block-2
- add r2, 128
-%endif
-.skipadd%1:
-%endmacro
-
-%macro IDCT_ADD16INTRA_10 0
-idct_dc_add %+ SUFFIX:
- add r5, r0
- movq m0, [r2+ 0]
- movhps m0, [r2+64]
- paddd m0, [pd_32]
- psrad m0, 6
- pshufhw m0, m0, 0
- pshuflw m0, m0, 0
- lea r6, [r3*3]
- mova m6, [pw_pixel_max]
- IDCT_DC_ADD_OP_10 r5, r3, r6
- ret
-
-cglobal h264_idct_add16intra_10,5,7,8
- ADD16_OP_INTRA 0, 4+1*8
- ADD16_OP_INTRA 2, 4+2*8
- ADD16_OP_INTRA 4, 6+1*8
- ADD16_OP_INTRA 6, 6+2*8
- ADD16_OP_INTRA 8, 4+3*8
- ADD16_OP_INTRA 10, 4+4*8
- ADD16_OP_INTRA 12, 6+3*8
- ADD16_OP_INTRA 14, 6+4*8
- REP_RET
- AC 8
- AC 10
- AC 12
- AC 14
- AC 0
- AC 2
- AC 4
- AC 6
-%endmacro
-
-INIT_XMM sse2
-IDCT_ADD16INTRA_10
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-IDCT_ADD16INTRA_10
-%endif
-
-%assign last_block 36
-;-----------------------------------------------------------------------------
-; h264_idct_add8(pixel **dst, const int *block_offset, dctcoef *block, int stride, const uint8_t nnzc[6*8])
-;-----------------------------------------------------------------------------
-%macro IDCT_ADD8 0
-cglobal h264_idct_add8_10,5,8,7
-%if ARCH_X86_64
- mov r7, r0
-%endif
- add r2, 1024
- mov r0, [r0]
- ADD16_OP_INTRA 16, 4+ 6*8
- ADD16_OP_INTRA 18, 4+ 7*8
- add r2, 1024-128*2
-%if ARCH_X86_64
- mov r0, [r7+gprsize]
-%else
- mov r0, r0m
- mov r0, [r0+gprsize]
-%endif
- ADD16_OP_INTRA 32, 4+11*8
- ADD16_OP_INTRA 34, 4+12*8
- REP_RET
- AC 16
- AC 18
- AC 32
- AC 34
-
-%endmacro ; IDCT_ADD8
-
-INIT_XMM sse2
-IDCT_ADD8
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-IDCT_ADD8
-%endif
-
-;-----------------------------------------------------------------------------
-; void h264_idct8_add(pixel *dst, dctcoef *block, int stride)
-;-----------------------------------------------------------------------------
-%macro IDCT8_1D 2
- SWAP 0, 1
- psrad m4, m5, 1
- psrad m1, m0, 1
- paddd m4, m5
- paddd m1, m0
- paddd m4, m7
- paddd m1, m5
- psubd m4, m0
- paddd m1, m3
-
- psubd m0, m3
- psubd m5, m3
- paddd m0, m7
- psubd m5, m7
- psrad m3, 1
- psrad m7, 1
- psubd m0, m3
- psubd m5, m7
-
- SWAP 1, 7
- psrad m1, m7, 2
- psrad m3, m4, 2
- paddd m3, m0
- psrad m0, 2
- paddd m1, m5
- psrad m5, 2
- psubd m0, m4
- psubd m7, m5
-
- SWAP 5, 6
- psrad m4, m2, 1
- psrad m6, m5, 1
- psubd m4, m5
- paddd m6, m2
-
- mova m2, %1
- mova m5, %2
- SUMSUB_BA d, 5, 2
- SUMSUB_BA d, 6, 5
- SUMSUB_BA d, 4, 2
- SUMSUB_BA d, 7, 6
- SUMSUB_BA d, 0, 4
- SUMSUB_BA d, 3, 2
- SUMSUB_BA d, 1, 5
- SWAP 7, 6, 4, 5, 2, 3, 1, 0 ; 70315246 -> 01234567
-%endmacro
-
-%macro IDCT8_1D_FULL 1
- mova m7, [%1+112*2]
- mova m6, [%1+ 96*2]
- mova m5, [%1+ 80*2]
- mova m3, [%1+ 48*2]
- mova m2, [%1+ 32*2]
- mova m1, [%1+ 16*2]
- IDCT8_1D [%1], [%1+ 64*2]
-%endmacro
-
-; %1=int16_t *block, %2=int16_t *dstblock
-%macro IDCT8_ADD_SSE_START 2
- IDCT8_1D_FULL %1
-%if ARCH_X86_64
- TRANSPOSE4x4D 0,1,2,3,8
- mova [%2 ], m0
- TRANSPOSE4x4D 4,5,6,7,8
- mova [%2+8*2], m4
-%else
- mova [%1], m7
- TRANSPOSE4x4D 0,1,2,3,7
- mova m7, [%1]
- mova [%2 ], m0
- mova [%2+16*2], m1
- mova [%2+32*2], m2
- mova [%2+48*2], m3
- TRANSPOSE4x4D 4,5,6,7,3
- mova [%2+ 8*2], m4
- mova [%2+24*2], m5
- mova [%2+40*2], m6
- mova [%2+56*2], m7
-%endif
-%endmacro
-
-; %1=uint8_t *dst, %2=int16_t *block, %3=int stride
-%macro IDCT8_ADD_SSE_END 3
- IDCT8_1D_FULL %2
- mova [%2 ], m6
- mova [%2+16*2], m7
-
- pxor m7, m7
- STORE_DIFFx2 m0, m1, m6, m7, %1, %3
- lea %1, [%1+%3*2]
- STORE_DIFFx2 m2, m3, m6, m7, %1, %3
- mova m0, [%2 ]
- mova m1, [%2+16*2]
- lea %1, [%1+%3*2]
- STORE_DIFFx2 m4, m5, m6, m7, %1, %3
- lea %1, [%1+%3*2]
- STORE_DIFFx2 m0, m1, m6, m7, %1, %3
-%endmacro
-
-%macro IDCT8_ADD 0
-cglobal h264_idct8_add_10, 3,4,16
-%if UNIX64 == 0
- %assign pad 16-gprsize-(stack_offset&15)
- sub rsp, pad
- call h264_idct8_add1_10 %+ SUFFIX
- add rsp, pad
- RET
-%endif
-
-ALIGN 16
-; TODO: does not need to use stack
-h264_idct8_add1_10 %+ SUFFIX:
-%assign pad 256+16-gprsize
- sub rsp, pad
- add dword [r1], 32
-
-%if ARCH_X86_64
- IDCT8_ADD_SSE_START r1, rsp
- SWAP 1, 9
- SWAP 2, 10
- SWAP 3, 11
- SWAP 5, 13
- SWAP 6, 14
- SWAP 7, 15
- IDCT8_ADD_SSE_START r1+16, rsp+128
- PERMUTE 1,9, 2,10, 3,11, 5,1, 6,2, 7,3, 9,13, 10,14, 11,15, 13,5, 14,6, 15,7
- IDCT8_1D [rsp], [rsp+128]
- SWAP 0, 8
- SWAP 1, 9
- SWAP 2, 10
- SWAP 3, 11
- SWAP 4, 12
- SWAP 5, 13
- SWAP 6, 14
- SWAP 7, 15
- IDCT8_1D [rsp+16], [rsp+144]
- psrad m8, 6
- psrad m0, 6
- packssdw m8, m0
- paddsw m8, [r0]
- pxor m0, m0
- CLIPW m8, m0, [pw_pixel_max]
- mova [r0], m8
- mova m8, [pw_pixel_max]
- STORE_DIFF16 m9, m1, m0, m8, r0+r2
- lea r0, [r0+r2*2]
- STORE_DIFF16 m10, m2, m0, m8, r0
- STORE_DIFF16 m11, m3, m0, m8, r0+r2
- lea r0, [r0+r2*2]
- STORE_DIFF16 m12, m4, m0, m8, r0
- STORE_DIFF16 m13, m5, m0, m8, r0+r2
- lea r0, [r0+r2*2]
- STORE_DIFF16 m14, m6, m0, m8, r0
- STORE_DIFF16 m15, m7, m0, m8, r0+r2
-%else
- IDCT8_ADD_SSE_START r1, rsp
- IDCT8_ADD_SSE_START r1+16, rsp+128
- lea r3, [r0+8]
- IDCT8_ADD_SSE_END r0, rsp, r2
- IDCT8_ADD_SSE_END r3, rsp+16, r2
-%endif ; ARCH_X86_64
-
- add rsp, pad
- ret
-%endmacro
-
-INIT_XMM sse2
-IDCT8_ADD
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-IDCT8_ADD
-%endif
-
-;-----------------------------------------------------------------------------
-; h264_idct8_add4(pixel **dst, const int *block_offset, dctcoef *block, int stride, const uint8_t nnzc[6*8])
-;-----------------------------------------------------------------------------
-;;;;;;; NO FATE SAMPLES TRIGGER THIS
-%macro IDCT8_ADD4_OP 2
- cmp byte [r4+%2], 0
- jz .skipblock%1
- mov r0d, [r6+%1*4]
- add r0, r5
- call h264_idct8_add1_10 %+ SUFFIX
-.skipblock%1:
-%if %1<12
- add r1, 256
-%endif
-%endmacro
-
-%macro IDCT8_ADD4 0
-cglobal h264_idct8_add4_10, 0,7,16
- %assign pad 16-gprsize-(stack_offset&15)
- SUB rsp, pad
- mov r5, r0mp
- mov r6, r1mp
- mov r1, r2mp
- mov r2d, r3m
- movifnidn r4, r4mp
- IDCT8_ADD4_OP 0, 4+1*8
- IDCT8_ADD4_OP 4, 6+1*8
- IDCT8_ADD4_OP 8, 4+3*8
- IDCT8_ADD4_OP 12, 6+3*8
- ADD rsp, pad
- RET
-%endmacro ; IDCT8_ADD4
-
-INIT_XMM sse2
-IDCT8_ADD4
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-IDCT8_ADD4
-%endif
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/h264_intrapred.asm b/src/thirdparty/ffmpeg/libavcodec/x86/h264_intrapred.asm
deleted file mode 100644
index 879ca2b14..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/h264_intrapred.asm
+++ /dev/null
@@ -1,2702 +0,0 @@
-;******************************************************************************
-;* 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
-
-tm_shuf: times 8 db 0x03, 0x80
-pw_ff00: times 8 dw 0xff00
-plane_shuf: db -8, -7, -6, -5, -4, -3, -2, -1
- db 1, 2, 3, 4, 5, 6, 7, 8
-plane8_shuf: db -4, -3, -2, -1, 0, 0, 0, 0
- db 1, 2, 3, 4, 0, 0, 0, 0
-pw_0to7: dw 0, 1, 2, 3, 4, 5, 6, 7
-pw_1to8: dw 1, 2, 3, 4, 5, 6, 7, 8
-pw_m8tom1: dw -8, -7, -6, -5, -4, -3, -2, -1
-pw_m4to4: dw -4, -3, -2, -1, 1, 2, 3, 4
-
-SECTION .text
-
-cextern pb_1
-cextern pb_3
-cextern pw_4
-cextern pw_5
-cextern pw_8
-cextern pw_16
-cextern pw_17
-cextern pw_32
-
-;-----------------------------------------------------------------------------
-; void pred16x16_vertical_8(uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-
-INIT_MMX mmx
-cglobal pred16x16_vertical_8, 2,3
- sub r0, r1
- mov r2, 8
- movq mm0, [r0+0]
- movq mm1, [r0+8]
-.loop:
- movq [r0+r1*1+0], mm0
- movq [r0+r1*1+8], mm1
- movq [r0+r1*2+0], mm0
- movq [r0+r1*2+8], mm1
- lea r0, [r0+r1*2]
- dec r2
- jg .loop
- REP_RET
-
-INIT_XMM sse
-cglobal pred16x16_vertical_8, 2,3
- sub r0, r1
- mov r2, 4
- movaps xmm0, [r0]
-.loop:
- movaps [r0+r1*1], xmm0
- movaps [r0+r1*2], xmm0
- lea r0, [r0+r1*2]
- movaps [r0+r1*1], xmm0
- movaps [r0+r1*2], xmm0
- lea r0, [r0+r1*2]
- dec r2
- jg .loop
- REP_RET
-
-;-----------------------------------------------------------------------------
-; void pred16x16_horizontal_8(uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-
-%macro PRED16x16_H 0
-cglobal pred16x16_horizontal_8, 2,3
- mov r2, 8
-%if cpuflag(ssse3)
- mova m2, [pb_3]
-%endif
-.loop:
- movd m0, [r0+r1*0-4]
- movd m1, [r0+r1*1-4]
-
-%if cpuflag(ssse3)
- pshufb m0, m2
- pshufb m1, m2
-%else
- punpcklbw m0, m0
- punpcklbw m1, m1
- SPLATW m0, m0, 3
- SPLATW m1, m1, 3
- mova [r0+r1*0+8], m0
- mova [r0+r1*1+8], m1
-%endif
-
- mova [r0+r1*0], m0
- mova [r0+r1*1], m1
- lea r0, [r0+r1*2]
- dec r2
- jg .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmx
-PRED16x16_H
-INIT_MMX mmxext
-PRED16x16_H
-INIT_XMM ssse3
-PRED16x16_H
-
-;-----------------------------------------------------------------------------
-; void pred16x16_dc_8(uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-
-%macro PRED16x16_DC 0
-cglobal pred16x16_dc_8, 2,7
- mov r4, r0
- sub r0, r1
- pxor mm0, mm0
- pxor mm1, mm1
- psadbw mm0, [r0+0]
- psadbw mm1, [r0+8]
- dec r0
- movzx r5d, byte [r0+r1*1]
- paddw mm0, mm1
- movd r6d, mm0
- lea r0, [r0+r1*2]
-%rep 7
- movzx r2d, byte [r0+r1*0]
- movzx r3d, byte [r0+r1*1]
- add r5d, r2d
- add r6d, r3d
- lea r0, [r0+r1*2]
-%endrep
- movzx r2d, byte [r0+r1*0]
- add r5d, r6d
- lea r2d, [r2+r5+16]
- shr r2d, 5
-%if cpuflag(ssse3)
- pxor m1, m1
-%endif
- SPLATB_REG m0, r2, m1
-
-%if mmsize==8
- mov r3d, 8
-.loop:
- mova [r4+r1*0+0], m0
- mova [r4+r1*0+8], m0
- mova [r4+r1*1+0], m0
- mova [r4+r1*1+8], m0
-%else
- mov r3d, 4
-.loop:
- mova [r4+r1*0], m0
- mova [r4+r1*1], m0
- lea r4, [r4+r1*2]
- mova [r4+r1*0], m0
- mova [r4+r1*1], m0
-%endif
- lea r4, [r4+r1*2]
- dec r3d
- jg .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-PRED16x16_DC
-INIT_XMM sse2
-PRED16x16_DC
-INIT_XMM ssse3
-PRED16x16_DC
-
-;-----------------------------------------------------------------------------
-; void pred16x16_tm_vp8_8(uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-
-%macro PRED16x16_TM 0
-cglobal pred16x16_tm_vp8_8, 2,5
- sub r0, r1
- pxor mm7, mm7
- movq mm0, [r0+0]
- movq mm2, [r0+8]
- movq mm1, mm0
- movq mm3, mm2
- punpcklbw mm0, mm7
- punpckhbw mm1, mm7
- punpcklbw mm2, mm7
- punpckhbw mm3, mm7
- movzx r3d, byte [r0-1]
- mov r4d, 16
-.loop:
- movzx r2d, byte [r0+r1-1]
- sub r2d, r3d
- movd mm4, r2d
- SPLATW mm4, mm4, 0
- movq mm5, mm4
- movq mm6, mm4
- movq mm7, mm4
- paddw mm4, mm0
- paddw mm5, mm1
- paddw mm6, mm2
- paddw mm7, mm3
- packuswb mm4, mm5
- packuswb mm6, mm7
- movq [r0+r1+0], mm4
- movq [r0+r1+8], mm6
- add r0, r1
- dec r4d
- jg .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmx
-PRED16x16_TM
-INIT_MMX mmxext
-PRED16x16_TM
-
-INIT_XMM sse2
-cglobal pred16x16_tm_vp8_8, 2,6,6
- sub r0, r1
- pxor xmm2, xmm2
- movdqa xmm0, [r0]
- movdqa xmm1, xmm0
- punpcklbw xmm0, xmm2
- punpckhbw xmm1, xmm2
- movzx r4d, byte [r0-1]
- mov r5d, 8
-.loop:
- movzx r2d, byte [r0+r1*1-1]
- movzx r3d, byte [r0+r1*2-1]
- sub r2d, r4d
- sub r3d, r4d
- movd xmm2, r2d
- movd xmm4, r3d
- pshuflw xmm2, xmm2, 0
- pshuflw xmm4, xmm4, 0
- punpcklqdq xmm2, xmm2
- punpcklqdq xmm4, xmm4
- movdqa xmm3, xmm2
- movdqa xmm5, xmm4
- paddw xmm2, xmm0
- paddw xmm3, xmm1
- paddw xmm4, xmm0
- paddw xmm5, xmm1
- packuswb xmm2, xmm3
- packuswb xmm4, xmm5
- movdqa [r0+r1*1], xmm2
- movdqa [r0+r1*2], xmm4
- lea r0, [r0+r1*2]
- dec r5d
- jg .loop
- REP_RET
-
-;-----------------------------------------------------------------------------
-; void pred16x16_plane_*_8(uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-
-%macro H264_PRED16x16_PLANE 1
-cglobal pred16x16_plane_%1_8, 2,9,7
- mov r2, r1 ; +stride
- neg r1 ; -stride
-
- movh m0, [r0+r1 -1]
-%if mmsize == 8
- pxor m4, m4
- movh m1, [r0+r1 +3 ]
- movh m2, [r0+r1 +8 ]
- movh m3, [r0+r1 +12]
- punpcklbw m0, m4
- punpcklbw m1, m4
- punpcklbw m2, m4
- punpcklbw m3, m4
- pmullw m0, [pw_m8tom1 ]
- pmullw m1, [pw_m8tom1+8]
- pmullw m2, [pw_1to8 ]
- pmullw m3, [pw_1to8 +8]
- paddw m0, m2
- paddw m1, m3
-%else ; mmsize == 16
-%if cpuflag(ssse3)
- movhps m0, [r0+r1 +8]
- pmaddubsw m0, [plane_shuf] ; H coefficients
-%else ; sse2
- pxor m2, m2
- movh m1, [r0+r1 +8]
- punpcklbw m0, m2
- punpcklbw m1, m2
- pmullw m0, [pw_m8tom1]
- pmullw m1, [pw_1to8]
- paddw m0, m1
-%endif
- movhlps m1, m0
-%endif
- paddw m0, m1
-%if cpuflag(mmxext)
- PSHUFLW m1, m0, 0xE
-%elif cpuflag(mmx)
- mova m1, m0
- psrlq m1, 32
-%endif
- paddw m0, m1
-%if cpuflag(mmxext)
- PSHUFLW m1, m0, 0x1
-%elif cpuflag(mmx)
- mova m1, m0
- psrlq m1, 16
-%endif
- paddw m0, m1 ; sum of H coefficients
-
- lea r4, [r0+r2*8-1]
- lea r3, [r0+r2*4-1]
- add r4, r2
-
-%if ARCH_X86_64
-%define e_reg r8
-%else
-%define e_reg r0
-%endif
-
- movzx e_reg, byte [r3+r2*2 ]
- movzx r5, byte [r4+r1 ]
- sub r5, e_reg
-
- movzx e_reg, byte [r3+r2 ]
- movzx r6, byte [r4 ]
- sub r6, e_reg
- lea r5, [r5+r6*2]
-
- movzx e_reg, byte [r3+r1 ]
- movzx r6, byte [r4+r2*2 ]
- sub r6, e_reg
- lea r5, [r5+r6*4]
-
- movzx e_reg, byte [r3 ]
-%if ARCH_X86_64
- movzx r7, byte [r4+r2 ]
- sub r7, e_reg
-%else
- movzx r6, byte [r4+r2 ]
- sub r6, e_reg
- lea r5, [r5+r6*4]
- sub r5, r6
-%endif
-
- lea e_reg, [r3+r1*4]
- lea r3, [r4+r2*4]
-
- movzx r4, byte [e_reg+r2 ]
- movzx r6, byte [r3 ]
- sub r6, r4
-%if ARCH_X86_64
- lea r6, [r7+r6*2]
- lea r5, [r5+r6*2]
- add r5, r6
-%else
- lea r5, [r5+r6*4]
- lea r5, [r5+r6*2]
-%endif
-
- movzx r4, byte [e_reg ]
-%if ARCH_X86_64
- movzx r7, byte [r3 +r2 ]
- sub r7, r4
- sub r5, r7
-%else
- movzx r6, byte [r3 +r2 ]
- sub r6, r4
- lea r5, [r5+r6*8]
- sub r5, r6
-%endif
-
- movzx r4, byte [e_reg+r1 ]
- movzx r6, byte [r3 +r2*2]
- sub r6, r4
-%if ARCH_X86_64
- add r6, r7
-%endif
- lea r5, [r5+r6*8]
-
- movzx r4, byte [e_reg+r2*2]
- movzx r6, byte [r3 +r1 ]
- sub r6, r4
- lea r5, [r5+r6*4]
- add r5, r6 ; sum of V coefficients
-
-%if ARCH_X86_64 == 0
- mov r0, r0m
-%endif
-
-%ifidn %1, h264
- lea r5, [r5*5+32]
- sar r5, 6
-%elifidn %1, rv40
- lea r5, [r5*5]
- sar r5, 6
-%elifidn %1, svq3
- test r5, r5
- lea r6, [r5+3]
- cmovs r5, r6
- sar r5, 2 ; V/4
- lea r5, [r5*5] ; 5*(V/4)
- test r5, r5
- lea r6, [r5+15]
- cmovs r5, r6
- sar r5, 4 ; (5*(V/4))/16
-%endif
-
- movzx r4, byte [r0+r1 +15]
- movzx r3, byte [r3+r2*2 ]
- lea r3, [r3+r4+1]
- shl r3, 4
-
- movd r1d, m0
- movsx r1d, r1w
-%ifnidn %1, svq3
-%ifidn %1, h264
- lea r1d, [r1d*5+32]
-%else ; rv40
- lea r1d, [r1d*5]
-%endif
- sar r1d, 6
-%else ; svq3
- test r1d, r1d
- lea r4d, [r1d+3]
- cmovs r1d, r4d
- sar r1d, 2 ; H/4
- lea r1d, [r1d*5] ; 5*(H/4)
- test r1d, r1d
- lea r4d, [r1d+15]
- cmovs r1d, r4d
- sar r1d, 4 ; (5*(H/4))/16
-%endif
- movd m0, r1d
-
- add r1d, r5d
- add r3d, r1d
- shl r1d, 3
- sub r3d, r1d ; a
-
- movd m1, r5d
- movd m3, r3d
- SPLATW m0, m0, 0 ; H
- SPLATW m1, m1, 0 ; V
- SPLATW m3, m3, 0 ; a
-%ifidn %1, svq3
- SWAP 0, 1
-%endif
- mova m2, m0
-%if mmsize == 8
- mova m5, m0
-%endif
- pmullw m0, [pw_0to7] ; 0*H, 1*H, ..., 7*H (words)
-%if mmsize == 16
- psllw m2, 3
-%else
- psllw m5, 3
- psllw m2, 2
- mova m6, m5
- paddw m6, m2
-%endif
- paddw m0, m3 ; a + {0,1,2,3,4,5,6,7}*H
- paddw m2, m0 ; a + {8,9,10,11,12,13,14,15}*H
-%if mmsize == 8
- paddw m5, m0 ; a + {8,9,10,11}*H
- paddw m6, m0 ; a + {12,13,14,15}*H
-%endif
-
- mov r4, 8
-.loop:
- mova m3, m0 ; b[0..7]
- mova m4, m2 ; b[8..15]
- psraw m3, 5
- psraw m4, 5
- packuswb m3, m4
- mova [r0], m3
-%if mmsize == 8
- mova m3, m5 ; b[8..11]
- mova m4, m6 ; b[12..15]
- psraw m3, 5
- psraw m4, 5
- packuswb m3, m4
- mova [r0+8], m3
-%endif
- paddw m0, m1
- paddw m2, m1
-%if mmsize == 8
- paddw m5, m1
- paddw m6, m1
-%endif
-
- mova m3, m0 ; b[0..7]
- mova m4, m2 ; b[8..15]
- psraw m3, 5
- psraw m4, 5
- packuswb m3, m4
- mova [r0+r2], m3
-%if mmsize == 8
- mova m3, m5 ; b[8..11]
- mova m4, m6 ; b[12..15]
- psraw m3, 5
- psraw m4, 5
- packuswb m3, m4
- mova [r0+r2+8], m3
-%endif
- paddw m0, m1
- paddw m2, m1
-%if mmsize == 8
- paddw m5, m1
- paddw m6, m1
-%endif
-
- lea r0, [r0+r2*2]
- dec r4
- jg .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmx
-H264_PRED16x16_PLANE h264
-H264_PRED16x16_PLANE rv40
-H264_PRED16x16_PLANE svq3
-INIT_MMX mmxext
-H264_PRED16x16_PLANE h264
-H264_PRED16x16_PLANE rv40
-H264_PRED16x16_PLANE svq3
-INIT_XMM sse2
-H264_PRED16x16_PLANE h264
-H264_PRED16x16_PLANE rv40
-H264_PRED16x16_PLANE svq3
-INIT_XMM ssse3
-H264_PRED16x16_PLANE h264
-H264_PRED16x16_PLANE rv40
-H264_PRED16x16_PLANE svq3
-
-;-----------------------------------------------------------------------------
-; void pred8x8_plane_8(uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-
-%macro H264_PRED8x8_PLANE 0
-cglobal pred8x8_plane_8, 2,9,7
- mov r2, r1 ; +stride
- neg r1 ; -stride
-
- movd m0, [r0+r1 -1]
-%if mmsize == 8
- pxor m2, m2
- movh m1, [r0+r1 +4 ]
- punpcklbw m0, m2
- punpcklbw m1, m2
- pmullw m0, [pw_m4to4]
- pmullw m1, [pw_m4to4+8]
-%else ; mmsize == 16
-%if cpuflag(ssse3)
- movhps m0, [r0+r1 +4] ; this reads 4 bytes more than necessary
- pmaddubsw m0, [plane8_shuf] ; H coefficients
-%else ; sse2
- pxor m2, m2
- movd m1, [r0+r1 +4]
- punpckldq m0, m1
- punpcklbw m0, m2
- pmullw m0, [pw_m4to4]
-%endif
- movhlps m1, m0
-%endif
- paddw m0, m1
-
-%if notcpuflag(ssse3)
-%if cpuflag(mmxext)
- PSHUFLW m1, m0, 0xE
-%elif cpuflag(mmx)
- mova m1, m0
- psrlq m1, 32
-%endif
- paddw m0, m1
-%endif ; !ssse3
-
-%if cpuflag(mmxext)
- PSHUFLW m1, m0, 0x1
-%elif cpuflag(mmx)
- mova m1, m0
- psrlq m1, 16
-%endif
- paddw m0, m1 ; sum of H coefficients
-
- lea r4, [r0+r2*4-1]
- lea r3, [r0 -1]
- add r4, r2
-
-%if ARCH_X86_64
-%define e_reg r8
-%else
-%define e_reg r0
-%endif
-
- movzx e_reg, byte [r3+r2*2 ]
- movzx r5, byte [r4+r1 ]
- sub r5, e_reg
-
- movzx e_reg, byte [r3 ]
-%if ARCH_X86_64
- movzx r7, byte [r4+r2 ]
- sub r7, e_reg
- sub r5, r7
-%else
- movzx r6, byte [r4+r2 ]
- sub r6, e_reg
- lea r5, [r5+r6*4]
- sub r5, r6
-%endif
-
- movzx e_reg, byte [r3+r1 ]
- movzx r6, byte [r4+r2*2 ]
- sub r6, e_reg
-%if ARCH_X86_64
- add r6, r7
-%endif
- lea r5, [r5+r6*4]
-
- movzx e_reg, byte [r3+r2 ]
- movzx r6, byte [r4 ]
- sub r6, e_reg
- lea r6, [r5+r6*2]
-
- lea r5, [r6*9+16]
- lea r5, [r5+r6*8]
- sar r5, 5
-
-%if ARCH_X86_64 == 0
- mov r0, r0m
-%endif
-
- movzx r3, byte [r4+r2*2 ]
- movzx r4, byte [r0+r1 +7]
- lea r3, [r3+r4+1]
- shl r3, 4
- movd r1d, m0
- movsx r1d, r1w
- imul r1d, 17
- add r1d, 16
- sar r1d, 5
- movd m0, r1d
- add r1d, r5d
- sub r3d, r1d
- add r1d, r1d
- sub r3d, r1d ; a
-
- movd m1, r5d
- movd m3, r3d
- SPLATW m0, m0, 0 ; H
- SPLATW m1, m1, 0 ; V
- SPLATW m3, m3, 0 ; a
-%if mmsize == 8
- mova m2, m0
-%endif
- pmullw m0, [pw_0to7] ; 0*H, 1*H, ..., 7*H (words)
- paddw m0, m3 ; a + {0,1,2,3,4,5,6,7}*H
-%if mmsize == 8
- psllw m2, 2
- paddw m2, m0 ; a + {4,5,6,7}*H
-%endif
-
- mov r4, 4
-ALIGN 16
-.loop:
-%if mmsize == 16
- mova m3, m0 ; b[0..7]
- paddw m0, m1
- psraw m3, 5
- mova m4, m0 ; V+b[0..7]
- paddw m0, m1
- psraw m4, 5
- packuswb m3, m4
- movh [r0], m3
- movhps [r0+r2], m3
-%else ; mmsize == 8
- mova m3, m0 ; b[0..3]
- mova m4, m2 ; b[4..7]
- paddw m0, m1
- paddw m2, m1
- psraw m3, 5
- psraw m4, 5
- mova m5, m0 ; V+b[0..3]
- mova m6, m2 ; V+b[4..7]
- paddw m0, m1
- paddw m2, m1
- psraw m5, 5
- psraw m6, 5
- packuswb m3, m4
- packuswb m5, m6
- mova [r0], m3
- mova [r0+r2], m5
-%endif
-
- lea r0, [r0+r2*2]
- dec r4
- jg .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmx
-H264_PRED8x8_PLANE
-INIT_MMX mmxext
-H264_PRED8x8_PLANE
-INIT_XMM sse2
-H264_PRED8x8_PLANE
-INIT_XMM ssse3
-H264_PRED8x8_PLANE
-
-;-----------------------------------------------------------------------------
-; void pred8x8_vertical_8(uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-
-INIT_MMX mmx
-cglobal pred8x8_vertical_8, 2,2
- sub r0, r1
- movq mm0, [r0]
-%rep 3
- movq [r0+r1*1], mm0
- movq [r0+r1*2], mm0
- lea r0, [r0+r1*2]
-%endrep
- movq [r0+r1*1], mm0
- movq [r0+r1*2], mm0
- RET
-
-;-----------------------------------------------------------------------------
-; void pred8x8_horizontal_8(uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-
-%macro PRED8x8_H 0
-cglobal pred8x8_horizontal_8, 2,3
- mov r2, 4
-%if cpuflag(ssse3)
- mova m2, [pb_3]
-%endif
-.loop:
- SPLATB_LOAD m0, r0+r1*0-1, m2
- SPLATB_LOAD m1, r0+r1*1-1, m2
- mova [r0+r1*0], m0
- mova [r0+r1*1], m1
- lea r0, [r0+r1*2]
- dec r2
- jg .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmx
-PRED8x8_H
-INIT_MMX mmxext
-PRED8x8_H
-INIT_MMX ssse3
-PRED8x8_H
-
-;-----------------------------------------------------------------------------
-; void pred8x8_top_dc_8_mmxext(uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-INIT_MMX mmxext
-cglobal pred8x8_top_dc_8, 2,5
- sub r0, r1
- movq mm0, [r0]
- pxor mm1, mm1
- pxor mm2, mm2
- lea r2, [r0+r1*2]
- punpckhbw mm1, mm0
- punpcklbw mm0, mm2
- psadbw mm1, mm2 ; s1
- lea r3, [r2+r1*2]
- psadbw mm0, mm2 ; s0
- psrlw mm1, 1
- psrlw mm0, 1
- pavgw mm1, mm2
- lea r4, [r3+r1*2]
- pavgw mm0, mm2
- pshufw mm1, mm1, 0
- pshufw mm0, mm0, 0 ; dc0 (w)
- packuswb mm0, mm1 ; dc0,dc1 (b)
- movq [r0+r1*1], mm0
- movq [r0+r1*2], mm0
- lea r0, [r3+r1*2]
- movq [r2+r1*1], mm0
- movq [r2+r1*2], mm0
- movq [r3+r1*1], mm0
- movq [r3+r1*2], mm0
- movq [r0+r1*1], mm0
- movq [r0+r1*2], mm0
- RET
-
-;-----------------------------------------------------------------------------
-; void pred8x8_dc_8_mmxext(uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-
-INIT_MMX mmxext
-cglobal pred8x8_dc_8, 2,5
- sub r0, r1
- pxor m7, m7
- movd m0, [r0+0]
- movd m1, [r0+4]
- psadbw m0, m7 ; s0
- mov r4, r0
- psadbw m1, m7 ; s1
-
- movzx r2d, byte [r0+r1*1-1]
- movzx r3d, byte [r0+r1*2-1]
- lea r0, [r0+r1*2]
- add r2d, r3d
- movzx r3d, byte [r0+r1*1-1]
- add r2d, r3d
- movzx r3d, byte [r0+r1*2-1]
- add r2d, r3d
- lea r0, [r0+r1*2]
- movd m2, r2d ; s2
- movzx r2d, byte [r0+r1*1-1]
- movzx r3d, byte [r0+r1*2-1]
- lea r0, [r0+r1*2]
- add r2d, r3d
- movzx r3d, byte [r0+r1*1-1]
- add r2d, r3d
- movzx r3d, byte [r0+r1*2-1]
- add r2d, r3d
- movd m3, r2d ; s3
-
- punpcklwd m0, m1
- mov r0, r4
- punpcklwd m2, m3
- punpckldq m0, m2 ; s0, s1, s2, s3
- pshufw m3, m0, 11110110b ; s2, s1, s3, s3
- lea r2, [r0+r1*2]
- pshufw m0, m0, 01110100b ; s0, s1, s3, s1
- paddw m0, m3
- lea r3, [r2+r1*2]
- psrlw m0, 2
- pavgw m0, m7 ; s0+s2, s1, s3, s1+s3
- lea r4, [r3+r1*2]
- packuswb m0, m0
- punpcklbw m0, m0
- movq m1, m0
- punpcklbw m0, m0
- punpckhbw m1, m1
- movq [r0+r1*1], m0
- movq [r0+r1*2], m0
- movq [r2+r1*1], m0
- movq [r2+r1*2], m0
- movq [r3+r1*1], m1
- movq [r3+r1*2], m1
- movq [r4+r1*1], m1
- movq [r4+r1*2], m1
- RET
-
-;-----------------------------------------------------------------------------
-; void pred8x8_dc_rv40_8(uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-
-INIT_MMX mmxext
-cglobal pred8x8_dc_rv40_8, 2,7
- mov r4, r0
- sub r0, r1
- pxor mm0, mm0
- psadbw mm0, [r0]
- dec r0
- movzx r5d, byte [r0+r1*1]
- movd r6d, mm0
- lea r0, [r0+r1*2]
-%rep 3
- movzx r2d, byte [r0+r1*0]
- movzx r3d, byte [r0+r1*1]
- add r5d, r2d
- add r6d, r3d
- lea r0, [r0+r1*2]
-%endrep
- movzx r2d, byte [r0+r1*0]
- add r5d, r6d
- lea r2d, [r2+r5+8]
- shr r2d, 4
- movd mm0, r2d
- punpcklbw mm0, mm0
- pshufw mm0, mm0, 0
- mov r3d, 4
-.loop:
- movq [r4+r1*0], mm0
- movq [r4+r1*1], mm0
- lea r4, [r4+r1*2]
- dec r3d
- jg .loop
- REP_RET
-
-;-----------------------------------------------------------------------------
-; void pred8x8_tm_vp8_8(uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-
-%macro PRED8x8_TM 0
-cglobal pred8x8_tm_vp8_8, 2,6
- sub r0, r1
- pxor mm7, mm7
- movq mm0, [r0]
- movq mm1, mm0
- punpcklbw mm0, mm7
- punpckhbw mm1, mm7
- movzx r4d, byte [r0-1]
- mov r5d, 4
-.loop:
- movzx r2d, byte [r0+r1*1-1]
- movzx r3d, byte [r0+r1*2-1]
- sub r2d, r4d
- sub r3d, r4d
- movd mm2, r2d
- movd mm4, r3d
- SPLATW mm2, mm2, 0
- SPLATW mm4, mm4, 0
- movq mm3, mm2
- movq mm5, mm4
- paddw mm2, mm0
- paddw mm3, mm1
- paddw mm4, mm0
- paddw mm5, mm1
- packuswb mm2, mm3
- packuswb mm4, mm5
- movq [r0+r1*1], mm2
- movq [r0+r1*2], mm4
- lea r0, [r0+r1*2]
- dec r5d
- jg .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmx
-PRED8x8_TM
-INIT_MMX mmxext
-PRED8x8_TM
-
-INIT_XMM sse2
-cglobal pred8x8_tm_vp8_8, 2,6,4
- sub r0, r1
- pxor xmm1, xmm1
- movq xmm0, [r0]
- punpcklbw xmm0, xmm1
- movzx r4d, byte [r0-1]
- mov r5d, 4
-.loop:
- movzx r2d, byte [r0+r1*1-1]
- movzx r3d, byte [r0+r1*2-1]
- sub r2d, r4d
- sub r3d, r4d
- movd xmm2, r2d
- movd xmm3, r3d
- pshuflw xmm2, xmm2, 0
- pshuflw xmm3, xmm3, 0
- punpcklqdq xmm2, xmm2
- punpcklqdq xmm3, xmm3
- paddw xmm2, xmm0
- paddw xmm3, xmm0
- packuswb xmm2, xmm3
- movq [r0+r1*1], xmm2
- movhps [r0+r1*2], xmm2
- lea r0, [r0+r1*2]
- dec r5d
- jg .loop
- REP_RET
-
-INIT_XMM ssse3
-cglobal pred8x8_tm_vp8_8, 2,3,6
- sub r0, r1
- movdqa xmm4, [tm_shuf]
- pxor xmm1, xmm1
- movq xmm0, [r0]
- punpcklbw xmm0, xmm1
- movd xmm5, [r0-4]
- pshufb xmm5, xmm4
- mov r2d, 4
-.loop:
- movd xmm2, [r0+r1*1-4]
- movd xmm3, [r0+r1*2-4]
- pshufb xmm2, xmm4
- pshufb xmm3, xmm4
- psubw xmm2, xmm5
- psubw xmm3, xmm5
- paddw xmm2, xmm0
- paddw xmm3, xmm0
- packuswb xmm2, xmm3
- movq [r0+r1*1], xmm2
- movhps [r0+r1*2], xmm2
- lea r0, [r0+r1*2]
- dec r2d
- jg .loop
- REP_RET
-
-; dest, left, right, src, tmp
-; output: %1 = (t[n-1] + t[n]*2 + t[n+1] + 2) >> 2
-%macro PRED4x4_LOWPASS 5
- mova %5, %2
- pavgb %2, %3
- pxor %3, %5
- mova %1, %4
- pand %3, [pb_1]
- psubusb %2, %3
- pavgb %1, %2
-%endmacro
-
-;-----------------------------------------------------------------------------
-; void 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
- sub r0, r3
- pxor mm7, mm7
- movq mm0, [r0-8]
- movq mm3, [r0]
- movq mm1, [r0+8]
- movq mm2, mm3
- movq mm4, mm3
- PALIGNR mm2, mm0, 7, mm0
- PALIGNR mm1, mm4, 1, mm4
- test r1, r1 ; top_left
- jz .fix_lt_2
- test r2, r2 ; top_right
- jz .fix_tr_1
- jmp .body
-.fix_lt_2:
- movq mm5, mm3
- pxor mm5, mm2
- psllq mm5, 56
- psrlq mm5, 56
- pxor mm2, mm5
- test r2, r2 ; top_right
- jnz .body
-.fix_tr_1:
- movq mm5, mm3
- pxor mm5, mm1
- psrlq mm5, 56
- psllq mm5, 56
- pxor mm1, mm5
-.body:
- PRED4x4_LOWPASS mm0, mm2, mm1, mm3, mm5
- psadbw mm7, mm0
- paddw mm7, [pw_4]
- psrlw mm7, 3
- pshufw mm7, mm7, 0
- packuswb mm7, mm7
-%rep 3
- movq [r0+r3*1], mm7
- movq [r0+r3*2], mm7
- lea r0, [r0+r3*2]
-%endrep
- movq [r0+r3*1], mm7
- movq [r0+r3*2], mm7
- RET
-%endmacro
-
-INIT_MMX mmxext
-PRED8x8L_TOP_DC
-INIT_MMX ssse3
-PRED8x8L_TOP_DC
-
-;-----------------------------------------------------------------------------
-;void pred8x8l_dc_8(uint8_t *src, int has_topleft, int has_topright, int stride)
-;-----------------------------------------------------------------------------
-
-%macro PRED8x8L_DC 0
-cglobal pred8x8l_dc_8, 4,5
- sub r0, r3
- lea r4, [r0+r3*2]
- movq mm0, [r0+r3*1-8]
- punpckhbw mm0, [r0+r3*0-8]
- movq mm1, [r4+r3*1-8]
- punpckhbw mm1, [r0+r3*2-8]
- mov r4, r0
- punpckhwd mm1, mm0
- lea r0, [r0+r3*4]
- movq mm2, [r0+r3*1-8]
- punpckhbw mm2, [r0+r3*0-8]
- lea r0, [r0+r3*2]
- movq mm3, [r0+r3*1-8]
- punpckhbw mm3, [r0+r3*0-8]
- punpckhwd mm3, mm2
- punpckhdq mm3, mm1
- lea r0, [r0+r3*2]
- movq mm0, [r0+r3*0-8]
- movq mm1, [r4]
- mov r0, r4
- movq mm4, mm3
- movq mm2, mm3
- PALIGNR mm4, mm0, 7, mm0
- PALIGNR mm1, mm2, 1, mm2
- test r1, r1
- jnz .do_left
-.fix_lt_1:
- movq mm5, mm3
- pxor mm5, mm4
- psrlq mm5, 56
- psllq mm5, 48
- pxor mm1, mm5
- jmp .do_left
-.fix_lt_2:
- movq mm5, mm3
- pxor mm5, mm2
- psllq mm5, 56
- psrlq mm5, 56
- pxor mm2, mm5
- test r2, r2
- jnz .body
-.fix_tr_1:
- movq mm5, mm3
- pxor mm5, mm1
- psrlq mm5, 56
- psllq mm5, 56
- pxor mm1, mm5
- jmp .body
-.do_left:
- movq mm0, mm4
- PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
- movq mm4, mm0
- movq mm7, mm2
- PRED4x4_LOWPASS mm1, mm3, mm0, mm4, mm5
- psllq mm1, 56
- PALIGNR mm7, mm1, 7, mm3
- movq mm0, [r0-8]
- movq mm3, [r0]
- movq mm1, [r0+8]
- movq mm2, mm3
- movq mm4, mm3
- PALIGNR mm2, mm0, 7, mm0
- PALIGNR mm1, mm4, 1, mm4
- test r1, r1
- jz .fix_lt_2
- test r2, r2
- jz .fix_tr_1
-.body:
- lea r1, [r0+r3*2]
- PRED4x4_LOWPASS mm6, mm2, mm1, mm3, mm5
- pxor mm0, mm0
- pxor mm1, mm1
- lea r2, [r1+r3*2]
- psadbw mm0, mm7
- psadbw mm1, mm6
- paddw mm0, [pw_8]
- paddw mm0, mm1
- lea r4, [r2+r3*2]
- psrlw mm0, 4
- pshufw mm0, mm0, 0
- packuswb mm0, mm0
- movq [r0+r3*1], mm0
- movq [r0+r3*2], mm0
- movq [r1+r3*1], mm0
- movq [r1+r3*2], mm0
- movq [r2+r3*1], mm0
- movq [r2+r3*2], mm0
- movq [r4+r3*1], mm0
- movq [r4+r3*2], mm0
- RET
-%endmacro
-
-INIT_MMX mmxext
-PRED8x8L_DC
-INIT_MMX ssse3
-PRED8x8L_DC
-
-;-----------------------------------------------------------------------------
-; void pred8x8l_horizontal_8(uint8_t *src, int has_topleft, int has_topright, int stride)
-;-----------------------------------------------------------------------------
-
-%macro PRED8x8L_HORIZONTAL 0
-cglobal pred8x8l_horizontal_8, 4,4
- sub r0, r3
- lea r2, [r0+r3*2]
- movq mm0, [r0+r3*1-8]
- test r1, r1
- lea r1, [r0+r3]
- cmovnz r1, r0
- punpckhbw mm0, [r1+r3*0-8]
- movq mm1, [r2+r3*1-8]
- punpckhbw mm1, [r0+r3*2-8]
- mov r2, r0
- punpckhwd mm1, mm0
- lea r0, [r0+r3*4]
- movq mm2, [r0+r3*1-8]
- punpckhbw mm2, [r0+r3*0-8]
- lea r0, [r0+r3*2]
- movq mm3, [r0+r3*1-8]
- punpckhbw mm3, [r0+r3*0-8]
- punpckhwd mm3, mm2
- punpckhdq mm3, mm1
- lea r0, [r0+r3*2]
- movq mm0, [r0+r3*0-8]
- movq mm1, [r1+r3*0-8]
- mov r0, r2
- movq mm4, mm3
- movq mm2, mm3
- PALIGNR mm4, mm0, 7, mm0
- PALIGNR mm1, mm2, 1, mm2
- movq mm0, mm4
- PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
- movq mm4, mm0
- movq mm7, mm2
- PRED4x4_LOWPASS mm1, mm3, mm0, mm4, mm5
- psllq mm1, 56
- PALIGNR mm7, mm1, 7, mm3
- movq mm3, mm7
- lea r1, [r0+r3*2]
- movq mm7, mm3
- punpckhbw mm3, mm3
- punpcklbw mm7, mm7
- pshufw mm0, mm3, 0xff
- pshufw mm1, mm3, 0xaa
- lea r2, [r1+r3*2]
- pshufw mm2, mm3, 0x55
- pshufw mm3, mm3, 0x00
- pshufw mm4, mm7, 0xff
- pshufw mm5, mm7, 0xaa
- pshufw mm6, mm7, 0x55
- pshufw mm7, mm7, 0x00
- movq [r0+r3*1], mm0
- movq [r0+r3*2], mm1
- movq [r1+r3*1], mm2
- movq [r1+r3*2], mm3
- movq [r2+r3*1], mm4
- movq [r2+r3*2], mm5
- lea r0, [r2+r3*2]
- movq [r0+r3*1], mm6
- movq [r0+r3*2], mm7
- RET
-%endmacro
-
-INIT_MMX mmxext
-PRED8x8L_HORIZONTAL
-INIT_MMX ssse3
-PRED8x8L_HORIZONTAL
-
-;-----------------------------------------------------------------------------
-; void pred8x8l_vertical_8(uint8_t *src, int has_topleft, int has_topright, int stride)
-;-----------------------------------------------------------------------------
-
-%macro PRED8x8L_VERTICAL 0
-cglobal pred8x8l_vertical_8, 4,4
- sub r0, r3
- movq mm0, [r0-8]
- movq mm3, [r0]
- movq mm1, [r0+8]
- movq mm2, mm3
- movq mm4, mm3
- PALIGNR mm2, mm0, 7, mm0
- PALIGNR mm1, mm4, 1, mm4
- test r1, r1 ; top_left
- jz .fix_lt_2
- test r2, r2 ; top_right
- jz .fix_tr_1
- jmp .body
-.fix_lt_2:
- movq mm5, mm3
- pxor mm5, mm2
- psllq mm5, 56
- psrlq mm5, 56
- pxor mm2, mm5
- test r2, r2 ; top_right
- jnz .body
-.fix_tr_1:
- movq mm5, mm3
- pxor mm5, mm1
- psrlq mm5, 56
- psllq mm5, 56
- pxor mm1, mm5
-.body:
- PRED4x4_LOWPASS mm0, mm2, mm1, mm3, mm5
-%rep 3
- movq [r0+r3*1], mm0
- movq [r0+r3*2], mm0
- lea r0, [r0+r3*2]
-%endrep
- movq [r0+r3*1], mm0
- movq [r0+r3*2], mm0
- RET
-%endmacro
-
-INIT_MMX mmxext
-PRED8x8L_VERTICAL
-INIT_MMX ssse3
-PRED8x8L_VERTICAL
-
-;-----------------------------------------------------------------------------
-;void pred8x8l_down_left_8(uint8_t *src, int has_topleft, int has_topright, int stride)
-;-----------------------------------------------------------------------------
-
-INIT_MMX mmxext
-cglobal pred8x8l_down_left_8, 4,5
- sub r0, r3
- movq mm0, [r0-8]
- movq mm3, [r0]
- movq mm1, [r0+8]
- movq mm2, mm3
- movq mm4, mm3
- PALIGNR mm2, mm0, 7, mm0
- PALIGNR mm1, mm4, 1, mm4
- test r1, r1
- jz .fix_lt_2
- test r2, r2
- jz .fix_tr_1
- jmp .do_top
-.fix_lt_2:
- movq mm5, mm3
- pxor mm5, mm2
- psllq mm5, 56
- psrlq mm5, 56
- pxor mm2, mm5
- test r2, r2
- jnz .do_top
-.fix_tr_1:
- movq mm5, mm3
- pxor mm5, mm1
- psrlq mm5, 56
- psllq mm5, 56
- pxor mm1, mm5
- jmp .do_top
-.fix_tr_2:
- punpckhbw mm3, mm3
- pshufw mm1, mm3, 0xFF
- jmp .do_topright
-.do_top:
- PRED4x4_LOWPASS mm4, mm2, mm1, mm3, mm5
- movq mm7, mm4
- test r2, r2
- jz .fix_tr_2
- movq mm0, [r0+8]
- movq mm5, mm0
- movq mm2, mm0
- movq mm4, mm0
- psrlq mm5, 56
- PALIGNR mm2, mm3, 7, mm3
- PALIGNR mm5, mm4, 1, mm4
- PRED4x4_LOWPASS mm1, mm2, mm5, mm0, mm4
-.do_topright:
- lea r1, [r0+r3*2]
- movq mm6, mm1
- psrlq mm1, 56
- movq mm4, mm1
- lea r2, [r1+r3*2]
- movq mm2, mm6
- PALIGNR mm2, mm7, 1, mm0
- movq mm3, mm6
- PALIGNR mm3, mm7, 7, mm0
- PALIGNR mm4, mm6, 1, mm0
- movq mm5, mm7
- movq mm1, mm7
- movq mm7, mm6
- lea r4, [r2+r3*2]
- psllq mm1, 8
- PRED4x4_LOWPASS mm0, mm1, mm2, mm5, mm6
- PRED4x4_LOWPASS mm1, mm3, mm4, mm7, mm6
- movq [r4+r3*2], mm1
- movq mm2, mm0
- psllq mm1, 8
- psrlq mm2, 56
- psllq mm0, 8
- por mm1, mm2
- movq [r4+r3*1], mm1
- movq mm2, mm0
- psllq mm1, 8
- psrlq mm2, 56
- psllq mm0, 8
- por mm1, mm2
- movq [r2+r3*2], mm1
- movq mm2, mm0
- psllq mm1, 8
- psrlq mm2, 56
- psllq mm0, 8
- por mm1, mm2
- movq [r2+r3*1], mm1
- movq mm2, mm0
- psllq mm1, 8
- psrlq mm2, 56
- psllq mm0, 8
- por mm1, mm2
- movq [r1+r3*2], mm1
- movq mm2, mm0
- psllq mm1, 8
- psrlq mm2, 56
- psllq mm0, 8
- por mm1, mm2
- movq [r1+r3*1], mm1
- movq mm2, mm0
- psllq mm1, 8
- psrlq mm2, 56
- psllq mm0, 8
- por mm1, mm2
- movq [r0+r3*2], mm1
- psllq mm1, 8
- psrlq mm0, 56
- por mm1, mm0
- movq [r0+r3*1], mm1
- RET
-
-%macro PRED8x8L_DOWN_LEFT 0
-cglobal pred8x8l_down_left_8, 4,4
- sub r0, r3
- movq mm0, [r0-8]
- movq mm3, [r0]
- movq mm1, [r0+8]
- movq mm2, mm3
- movq mm4, mm3
- PALIGNR mm2, mm0, 7, mm0
- PALIGNR mm1, mm4, 1, mm4
- test r1, r1 ; top_left
- jz .fix_lt_2
- test r2, r2 ; top_right
- jz .fix_tr_1
- jmp .do_top
-.fix_lt_2:
- movq mm5, mm3
- pxor mm5, mm2
- psllq mm5, 56
- psrlq mm5, 56
- pxor mm2, mm5
- test r2, r2 ; top_right
- jnz .do_top
-.fix_tr_1:
- movq mm5, mm3
- pxor mm5, mm1
- psrlq mm5, 56
- psllq mm5, 56
- pxor mm1, mm5
- jmp .do_top
-.fix_tr_2:
- punpckhbw mm3, mm3
- pshufw mm1, mm3, 0xFF
- jmp .do_topright
-.do_top:
- PRED4x4_LOWPASS mm4, mm2, mm1, mm3, mm5
- movq2dq xmm3, mm4
- test r2, r2 ; top_right
- jz .fix_tr_2
- movq mm0, [r0+8]
- movq mm5, mm0
- movq mm2, mm0
- movq mm4, mm0
- psrlq mm5, 56
- PALIGNR mm2, mm3, 7, mm3
- PALIGNR mm5, mm4, 1, mm4
- PRED4x4_LOWPASS mm1, mm2, mm5, mm0, mm4
-.do_topright:
- movq2dq xmm4, mm1
- psrlq mm1, 56
- movq2dq xmm5, mm1
- lea r1, [r0+r3*2]
- pslldq xmm4, 8
- por xmm3, xmm4
- movdqa xmm2, xmm3
- psrldq xmm2, 1
- pslldq xmm5, 15
- por xmm2, xmm5
- lea r2, [r1+r3*2]
- movdqa xmm1, xmm3
- pslldq xmm1, 1
-INIT_XMM cpuname
- PRED4x4_LOWPASS xmm0, xmm1, xmm2, xmm3, xmm4
- psrldq xmm0, 1
- movq [r0+r3*1], xmm0
- psrldq xmm0, 1
- movq [r0+r3*2], xmm0
- psrldq xmm0, 1
- lea r0, [r2+r3*2]
- movq [r1+r3*1], xmm0
- psrldq xmm0, 1
- movq [r1+r3*2], xmm0
- psrldq xmm0, 1
- movq [r2+r3*1], xmm0
- psrldq xmm0, 1
- movq [r2+r3*2], xmm0
- psrldq xmm0, 1
- movq [r0+r3*1], xmm0
- psrldq xmm0, 1
- movq [r0+r3*2], xmm0
- RET
-%endmacro
-
-INIT_MMX sse2
-PRED8x8L_DOWN_LEFT
-INIT_MMX ssse3
-PRED8x8L_DOWN_LEFT
-
-;-----------------------------------------------------------------------------
-;void pred8x8l_down_right_8_mmxext(uint8_t *src, int has_topleft, int has_topright, int stride)
-;-----------------------------------------------------------------------------
-
-INIT_MMX mmxext
-cglobal pred8x8l_down_right_8, 4,5
- sub r0, r3
- lea r4, [r0+r3*2]
- movq mm0, [r0+r3*1-8]
- punpckhbw mm0, [r0+r3*0-8]
- movq mm1, [r4+r3*1-8]
- punpckhbw mm1, [r0+r3*2-8]
- mov r4, r0
- punpckhwd mm1, mm0
- lea r0, [r0+r3*4]
- movq mm2, [r0+r3*1-8]
- punpckhbw mm2, [r0+r3*0-8]
- lea r0, [r0+r3*2]
- movq mm3, [r0+r3*1-8]
- punpckhbw mm3, [r0+r3*0-8]
- punpckhwd mm3, mm2
- punpckhdq mm3, mm1
- lea r0, [r0+r3*2]
- movq mm0, [r0+r3*0-8]
- movq mm1, [r4]
- mov r0, r4
- movq mm4, mm3
- movq mm2, mm3
- PALIGNR mm4, mm0, 7, mm0
- PALIGNR mm1, mm2, 1, mm2
- test r1, r1 ; top_left
- jz .fix_lt_1
-.do_left:
- movq mm0, mm4
- PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
- movq mm4, mm0
- movq mm7, mm2
- movq mm6, mm2
- PRED4x4_LOWPASS mm1, mm3, mm0, mm4, mm5
- psllq mm1, 56
- PALIGNR mm7, mm1, 7, mm3
- movq mm0, [r0-8]
- movq mm3, [r0]
- movq mm1, [r0+8]
- movq mm2, mm3
- movq mm4, mm3
- PALIGNR mm2, mm0, 7, mm0
- PALIGNR mm1, mm4, 1, mm4
- test r1, r1 ; top_left
- jz .fix_lt_2
- test r2, r2 ; top_right
- jz .fix_tr_1
-.do_top:
- PRED4x4_LOWPASS mm4, mm2, mm1, mm3, mm5
- movq mm5, mm4
- jmp .body
-.fix_lt_1:
- movq mm5, mm3
- pxor mm5, mm4
- psrlq mm5, 56
- psllq mm5, 48
- pxor mm1, mm5
- jmp .do_left
-.fix_lt_2:
- movq mm5, mm3
- pxor mm5, mm2
- psllq mm5, 56
- psrlq mm5, 56
- pxor mm2, mm5
- test r2, r2 ; top_right
- jnz .do_top
-.fix_tr_1:
- movq mm5, mm3
- pxor mm5, mm1
- psrlq mm5, 56
- psllq mm5, 56
- pxor mm1, mm5
- jmp .do_top
-.body:
- lea r1, [r0+r3*2]
- movq mm1, mm7
- movq mm7, mm5
- movq mm5, mm6
- movq mm2, mm7
- lea r2, [r1+r3*2]
- PALIGNR mm2, mm6, 1, mm0
- movq mm3, mm7
- PALIGNR mm3, mm6, 7, mm0
- movq mm4, mm7
- lea r4, [r2+r3*2]
- psrlq mm4, 8
- PRED4x4_LOWPASS mm0, mm1, mm2, mm5, mm6
- PRED4x4_LOWPASS mm1, mm3, mm4, mm7, mm6
- movq [r4+r3*2], mm0
- movq mm2, mm1
- psrlq mm0, 8
- psllq mm2, 56
- psrlq mm1, 8
- por mm0, mm2
- movq [r4+r3*1], mm0
- movq mm2, mm1
- psrlq mm0, 8
- psllq mm2, 56
- psrlq mm1, 8
- por mm0, mm2
- movq [r2+r3*2], mm0
- movq mm2, mm1
- psrlq mm0, 8
- psllq mm2, 56
- psrlq mm1, 8
- por mm0, mm2
- movq [r2+r3*1], mm0
- movq mm2, mm1
- psrlq mm0, 8
- psllq mm2, 56
- psrlq mm1, 8
- por mm0, mm2
- movq [r1+r3*2], mm0
- movq mm2, mm1
- psrlq mm0, 8
- psllq mm2, 56
- psrlq mm1, 8
- por mm0, mm2
- movq [r1+r3*1], mm0
- movq mm2, mm1
- psrlq mm0, 8
- psllq mm2, 56
- psrlq mm1, 8
- por mm0, mm2
- movq [r0+r3*2], mm0
- psrlq mm0, 8
- psllq mm1, 56
- por mm0, mm1
- movq [r0+r3*1], mm0
- RET
-
-%macro PRED8x8L_DOWN_RIGHT 0
-cglobal pred8x8l_down_right_8, 4,5
- sub r0, r3
- lea r4, [r0+r3*2]
- movq mm0, [r0+r3*1-8]
- punpckhbw mm0, [r0+r3*0-8]
- movq mm1, [r4+r3*1-8]
- punpckhbw mm1, [r0+r3*2-8]
- mov r4, r0
- punpckhwd mm1, mm0
- lea r0, [r0+r3*4]
- movq mm2, [r0+r3*1-8]
- punpckhbw mm2, [r0+r3*0-8]
- lea r0, [r0+r3*2]
- movq mm3, [r0+r3*1-8]
- punpckhbw mm3, [r0+r3*0-8]
- punpckhwd mm3, mm2
- punpckhdq mm3, mm1
- lea r0, [r0+r3*2]
- movq mm0, [r0+r3*0-8]
- movq mm1, [r4]
- mov r0, r4
- movq mm4, mm3
- movq mm2, mm3
- PALIGNR mm4, mm0, 7, mm0
- PALIGNR mm1, mm2, 1, mm2
- test r1, r1
- jz .fix_lt_1
- jmp .do_left
-.fix_lt_1:
- movq mm5, mm3
- pxor mm5, mm4
- psrlq mm5, 56
- psllq mm5, 48
- pxor mm1, mm5
- jmp .do_left
-.fix_lt_2:
- movq mm5, mm3
- pxor mm5, mm2
- psllq mm5, 56
- psrlq mm5, 56
- pxor mm2, mm5
- test r2, r2
- jnz .do_top
-.fix_tr_1:
- movq mm5, mm3
- pxor mm5, mm1
- psrlq mm5, 56
- psllq mm5, 56
- pxor mm1, mm5
- jmp .do_top
-.do_left:
- movq mm0, mm4
- PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
- movq mm4, mm0
- movq mm7, mm2
- movq2dq xmm3, mm2
- PRED4x4_LOWPASS mm1, mm3, mm0, mm4, mm5
- psllq mm1, 56
- PALIGNR mm7, mm1, 7, mm3
- movq2dq xmm1, mm7
- movq mm0, [r0-8]
- movq mm3, [r0]
- movq mm1, [r0+8]
- movq mm2, mm3
- movq mm4, mm3
- PALIGNR mm2, mm0, 7, mm0
- PALIGNR mm1, mm4, 1, mm4
- test r1, r1
- jz .fix_lt_2
- test r2, r2
- jz .fix_tr_1
-.do_top:
- PRED4x4_LOWPASS mm4, mm2, mm1, mm3, mm5
- movq2dq xmm4, mm4
- lea r1, [r0+r3*2]
- movdqa xmm0, xmm3
- pslldq xmm4, 8
- por xmm3, xmm4
- lea r2, [r1+r3*2]
- pslldq xmm4, 1
- por xmm1, xmm4
- psrldq xmm0, 7
- pslldq xmm0, 15
- psrldq xmm0, 7
- por xmm1, xmm0
- lea r0, [r2+r3*2]
- movdqa xmm2, xmm3
- psrldq xmm2, 1
-INIT_XMM cpuname
- PRED4x4_LOWPASS xmm0, xmm1, xmm2, xmm3, xmm4
- movdqa xmm1, xmm0
- psrldq xmm1, 1
- movq [r0+r3*2], xmm0
- movq [r0+r3*1], xmm1
- psrldq xmm0, 2
- psrldq xmm1, 2
- movq [r2+r3*2], xmm0
- movq [r2+r3*1], xmm1
- psrldq xmm0, 2
- psrldq xmm1, 2
- movq [r1+r3*2], xmm0
- movq [r1+r3*1], xmm1
- psrldq xmm0, 2
- psrldq xmm1, 2
- movq [r4+r3*2], xmm0
- movq [r4+r3*1], xmm1
- RET
-%endmacro
-
-INIT_MMX sse2
-PRED8x8L_DOWN_RIGHT
-INIT_MMX ssse3
-PRED8x8L_DOWN_RIGHT
-
-;-----------------------------------------------------------------------------
-; void pred8x8l_vertical_right_8(uint8_t *src, int has_topleft, int has_topright, int stride)
-;-----------------------------------------------------------------------------
-
-INIT_MMX mmxext
-cglobal pred8x8l_vertical_right_8, 4,5
- sub r0, r3
- lea r4, [r0+r3*2]
- movq mm0, [r0+r3*1-8]
- punpckhbw mm0, [r0+r3*0-8]
- movq mm1, [r4+r3*1-8]
- punpckhbw mm1, [r0+r3*2-8]
- mov r4, r0
- punpckhwd mm1, mm0
- lea r0, [r0+r3*4]
- movq mm2, [r0+r3*1-8]
- punpckhbw mm2, [r0+r3*0-8]
- lea r0, [r0+r3*2]
- movq mm3, [r0+r3*1-8]
- punpckhbw mm3, [r0+r3*0-8]
- punpckhwd mm3, mm2
- punpckhdq mm3, mm1
- lea r0, [r0+r3*2]
- movq mm0, [r0+r3*0-8]
- movq mm1, [r4]
- mov r0, r4
- movq mm4, mm3
- movq mm2, mm3
- PALIGNR mm4, mm0, 7, mm0
- PALIGNR mm1, mm2, 1, mm2
- test r1, r1
- jz .fix_lt_1
- jmp .do_left
-.fix_lt_1:
- movq mm5, mm3
- pxor mm5, mm4
- psrlq mm5, 56
- psllq mm5, 48
- pxor mm1, mm5
- jmp .do_left
-.fix_lt_2:
- movq mm5, mm3
- pxor mm5, mm2
- psllq mm5, 56
- psrlq mm5, 56
- pxor mm2, mm5
- test r2, r2
- jnz .do_top
-.fix_tr_1:
- movq mm5, mm3
- pxor mm5, mm1
- psrlq mm5, 56
- psllq mm5, 56
- pxor mm1, mm5
- jmp .do_top
-.do_left:
- movq mm0, mm4
- PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
- movq mm7, mm2
- movq mm0, [r0-8]
- movq mm3, [r0]
- movq mm1, [r0+8]
- movq mm2, mm3
- movq mm4, mm3
- PALIGNR mm2, mm0, 7, mm0
- PALIGNR mm1, mm4, 1, mm4
- test r1, r1
- jz .fix_lt_2
- test r2, r2
- jz .fix_tr_1
-.do_top:
- PRED4x4_LOWPASS mm6, mm2, mm1, mm3, mm5
- lea r1, [r0+r3*2]
- movq mm2, mm6
- movq mm3, mm6
- PALIGNR mm3, mm7, 7, mm0
- PALIGNR mm6, mm7, 6, mm1
- movq mm4, mm3
- pavgb mm3, mm2
- lea r2, [r1+r3*2]
- PRED4x4_LOWPASS mm0, mm6, mm2, mm4, mm5
- movq [r0+r3*1], mm3
- movq [r0+r3*2], mm0
- movq mm5, mm0
- movq mm6, mm3
- movq mm1, mm7
- movq mm2, mm1
- psllq mm2, 8
- movq mm3, mm1
- psllq mm3, 16
- lea r4, [r2+r3*2]
- PRED4x4_LOWPASS mm0, mm1, mm3, mm2, mm4
- PALIGNR mm6, mm0, 7, mm2
- movq [r1+r3*1], mm6
- psllq mm0, 8
- PALIGNR mm5, mm0, 7, mm1
- movq [r1+r3*2], mm5
- psllq mm0, 8
- PALIGNR mm6, mm0, 7, mm2
- movq [r2+r3*1], mm6
- psllq mm0, 8
- PALIGNR mm5, mm0, 7, mm1
- movq [r2+r3*2], mm5
- psllq mm0, 8
- PALIGNR mm6, mm0, 7, mm2
- movq [r4+r3*1], mm6
- psllq mm0, 8
- PALIGNR mm5, mm0, 7, mm1
- movq [r4+r3*2], mm5
- RET
-
-%macro PRED8x8L_VERTICAL_RIGHT 0
-cglobal pred8x8l_vertical_right_8, 4,5,7
- ; manually spill XMM registers for Win64 because
- ; the code here is initialized with INIT_MMX
- WIN64_SPILL_XMM 7
- sub r0, r3
- lea r4, [r0+r3*2]
- movq mm0, [r0+r3*1-8]
- punpckhbw mm0, [r0+r3*0-8]
- movq mm1, [r4+r3*1-8]
- punpckhbw mm1, [r0+r3*2-8]
- mov r4, r0
- punpckhwd mm1, mm0
- lea r0, [r0+r3*4]
- movq mm2, [r0+r3*1-8]
- punpckhbw mm2, [r0+r3*0-8]
- lea r0, [r0+r3*2]
- movq mm3, [r0+r3*1-8]
- punpckhbw mm3, [r0+r3*0-8]
- punpckhwd mm3, mm2
- punpckhdq mm3, mm1
- lea r0, [r0+r3*2]
- movq mm0, [r0+r3*0-8]
- movq mm1, [r4]
- mov r0, r4
- movq mm4, mm3
- movq mm2, mm3
- PALIGNR mm4, mm0, 7, mm0
- PALIGNR mm1, mm2, 1, mm2
- test r1, r1
- jnz .do_left
-.fix_lt_1:
- movq mm5, mm3
- pxor mm5, mm4
- psrlq mm5, 56
- psllq mm5, 48
- pxor mm1, mm5
- jmp .do_left
-.fix_lt_2:
- movq mm5, mm3
- pxor mm5, mm2
- psllq mm5, 56
- psrlq mm5, 56
- pxor mm2, mm5
- test r2, r2
- jnz .do_top
-.fix_tr_1:
- movq mm5, mm3
- pxor mm5, mm1
- psrlq mm5, 56
- psllq mm5, 56
- pxor mm1, mm5
- jmp .do_top
-.do_left:
- movq mm0, mm4
- PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
- movq2dq xmm0, mm2
- movq mm0, [r0-8]
- movq mm3, [r0]
- movq mm1, [r0+8]
- movq mm2, mm3
- movq mm4, mm3
- PALIGNR mm2, mm0, 7, mm0
- PALIGNR mm1, mm4, 1, mm4
- test r1, r1
- jz .fix_lt_2
- test r2, r2
- jz .fix_tr_1
-.do_top:
- PRED4x4_LOWPASS mm6, mm2, mm1, mm3, mm5
- lea r1, [r0+r3*2]
- movq2dq xmm4, mm6
- pslldq xmm4, 8
- por xmm0, xmm4
- movdqa xmm6, [pw_ff00]
- movdqa xmm1, xmm0
- lea r2, [r1+r3*2]
- movdqa xmm2, xmm0
- movdqa xmm3, xmm0
- pslldq xmm0, 1
- pslldq xmm1, 2
- pavgb xmm2, xmm0
-INIT_XMM cpuname
- PRED4x4_LOWPASS xmm4, xmm3, xmm1, xmm0, xmm5
- pandn xmm6, xmm4
- movdqa xmm5, xmm4
- psrlw xmm4, 8
- packuswb xmm6, xmm4
- movhlps xmm4, xmm6
- movhps [r0+r3*2], xmm5
- movhps [r0+r3*1], xmm2
- psrldq xmm5, 4
- movss xmm5, xmm6
- psrldq xmm2, 4
- movss xmm2, xmm4
- lea r0, [r2+r3*2]
- psrldq xmm5, 1
- psrldq xmm2, 1
- movq [r0+r3*2], xmm5
- movq [r0+r3*1], xmm2
- psrldq xmm5, 1
- psrldq xmm2, 1
- movq [r2+r3*2], xmm5
- movq [r2+r3*1], xmm2
- psrldq xmm5, 1
- psrldq xmm2, 1
- movq [r1+r3*2], xmm5
- movq [r1+r3*1], xmm2
- RET
-%endmacro
-
-INIT_MMX sse2
-PRED8x8L_VERTICAL_RIGHT
-INIT_MMX ssse3
-PRED8x8L_VERTICAL_RIGHT
-
-;-----------------------------------------------------------------------------
-;void pred8x8l_vertical_left_8(uint8_t *src, int has_topleft, int has_topright, int stride)
-;-----------------------------------------------------------------------------
-
-%macro PRED8x8L_VERTICAL_LEFT 0
-cglobal pred8x8l_vertical_left_8, 4,4
- sub r0, r3
- movq mm0, [r0-8]
- movq mm3, [r0]
- movq mm1, [r0+8]
- movq mm2, mm3
- movq mm4, mm3
- PALIGNR mm2, mm0, 7, mm0
- PALIGNR mm1, mm4, 1, mm4
- test r1, r1
- jz .fix_lt_2
- test r2, r2
- jz .fix_tr_1
- jmp .do_top
-.fix_lt_2:
- movq mm5, mm3
- pxor mm5, mm2
- psllq mm5, 56
- psrlq mm5, 56
- pxor mm2, mm5
- test r2, r2
- jnz .do_top
-.fix_tr_1:
- movq mm5, mm3
- pxor mm5, mm1
- psrlq mm5, 56
- psllq mm5, 56
- pxor mm1, mm5
- jmp .do_top
-.fix_tr_2:
- punpckhbw mm3, mm3
- pshufw mm1, mm3, 0xFF
- jmp .do_topright
-.do_top:
- PRED4x4_LOWPASS mm4, mm2, mm1, mm3, mm5
- movq2dq xmm4, mm4
- test r2, r2
- jz .fix_tr_2
- movq mm0, [r0+8]
- movq mm5, mm0
- movq mm2, mm0
- movq mm4, mm0
- psrlq mm5, 56
- PALIGNR mm2, mm3, 7, mm3
- PALIGNR mm5, mm4, 1, mm4
- PRED4x4_LOWPASS mm1, mm2, mm5, mm0, mm4
-.do_topright:
- movq2dq xmm3, mm1
- lea r1, [r0+r3*2]
- pslldq xmm3, 8
- por xmm4, xmm3
- movdqa xmm2, xmm4
- movdqa xmm1, xmm4
- movdqa xmm3, xmm4
- psrldq xmm2, 1
- pslldq xmm1, 1
- pavgb xmm3, xmm2
- lea r2, [r1+r3*2]
-INIT_XMM cpuname
- PRED4x4_LOWPASS xmm0, xmm1, xmm2, xmm4, xmm5
- psrldq xmm0, 1
- movq [r0+r3*1], xmm3
- movq [r0+r3*2], xmm0
- lea r0, [r2+r3*2]
- psrldq xmm3, 1
- psrldq xmm0, 1
- movq [r1+r3*1], xmm3
- movq [r1+r3*2], xmm0
- psrldq xmm3, 1
- psrldq xmm0, 1
- movq [r2+r3*1], xmm3
- movq [r2+r3*2], xmm0
- psrldq xmm3, 1
- psrldq xmm0, 1
- movq [r0+r3*1], xmm3
- movq [r0+r3*2], xmm0
- RET
-%endmacro
-
-INIT_MMX sse2
-PRED8x8L_VERTICAL_LEFT
-INIT_MMX ssse3
-PRED8x8L_VERTICAL_LEFT
-
-;-----------------------------------------------------------------------------
-; void pred8x8l_horizontal_up_8(uint8_t *src, int has_topleft, int has_topright, int stride)
-;-----------------------------------------------------------------------------
-
-%macro PRED8x8L_HORIZONTAL_UP 0
-cglobal pred8x8l_horizontal_up_8, 4,4
- sub r0, r3
- lea r2, [r0+r3*2]
- movq mm0, [r0+r3*1-8]
- test r1, r1
- lea r1, [r0+r3]
- cmovnz r1, r0
- punpckhbw mm0, [r1+r3*0-8]
- movq mm1, [r2+r3*1-8]
- punpckhbw mm1, [r0+r3*2-8]
- mov r2, r0
- punpckhwd mm1, mm0
- lea r0, [r0+r3*4]
- movq mm2, [r0+r3*1-8]
- punpckhbw mm2, [r0+r3*0-8]
- lea r0, [r0+r3*2]
- movq mm3, [r0+r3*1-8]
- punpckhbw mm3, [r0+r3*0-8]
- punpckhwd mm3, mm2
- punpckhdq mm3, mm1
- lea r0, [r0+r3*2]
- movq mm0, [r0+r3*0-8]
- movq mm1, [r1+r3*0-8]
- mov r0, r2
- movq mm4, mm3
- movq mm2, mm3
- PALIGNR mm4, mm0, 7, mm0
- PALIGNR mm1, mm2, 1, mm2
- movq mm0, mm4
- PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
- movq mm4, mm0
- movq mm7, mm2
- PRED4x4_LOWPASS mm1, mm3, mm0, mm4, mm5
- psllq mm1, 56
- PALIGNR mm7, mm1, 7, mm3
- lea r1, [r0+r3*2]
- pshufw mm0, mm7, 00011011b ; l6 l7 l4 l5 l2 l3 l0 l1
- psllq mm7, 56 ; l7 .. .. .. .. .. .. ..
- movq mm2, mm0
- psllw mm0, 8
- psrlw mm2, 8
- por mm2, mm0 ; l7 l6 l5 l4 l3 l2 l1 l0
- movq mm3, mm2
- movq mm4, mm2
- movq mm5, mm2
- psrlq mm2, 8
- psrlq mm3, 16
- lea r2, [r1+r3*2]
- por mm2, mm7 ; l7 l7 l6 l5 l4 l3 l2 l1
- punpckhbw mm7, mm7
- por mm3, mm7 ; l7 l7 l7 l6 l5 l4 l3 l2
- pavgb mm4, mm2
- PRED4x4_LOWPASS mm1, mm3, mm5, mm2, mm6
- movq mm5, mm4
- punpcklbw mm4, mm1 ; p4 p3 p2 p1
- punpckhbw mm5, mm1 ; p8 p7 p6 p5
- movq mm6, mm5
- movq mm7, mm5
- movq mm0, mm5
- PALIGNR mm5, mm4, 2, mm1
- pshufw mm1, mm6, 11111001b
- PALIGNR mm6, mm4, 4, mm2
- pshufw mm2, mm7, 11111110b
- PALIGNR mm7, mm4, 6, mm3
- pshufw mm3, mm0, 11111111b
- movq [r0+r3*1], mm4
- movq [r0+r3*2], mm5
- lea r0, [r2+r3*2]
- movq [r1+r3*1], mm6
- movq [r1+r3*2], mm7
- movq [r2+r3*1], mm0
- movq [r2+r3*2], mm1
- movq [r0+r3*1], mm2
- movq [r0+r3*2], mm3
- RET
-%endmacro
-
-INIT_MMX mmxext
-PRED8x8L_HORIZONTAL_UP
-INIT_MMX ssse3
-PRED8x8L_HORIZONTAL_UP
-
-;-----------------------------------------------------------------------------
-;void pred8x8l_horizontal_down_8(uint8_t *src, int has_topleft, int has_topright, int stride)
-;-----------------------------------------------------------------------------
-
-INIT_MMX mmxext
-cglobal pred8x8l_horizontal_down_8, 4,5
- sub r0, r3
- lea r4, [r0+r3*2]
- movq mm0, [r0+r3*1-8]
- punpckhbw mm0, [r0+r3*0-8]
- movq mm1, [r4+r3*1-8]
- punpckhbw mm1, [r0+r3*2-8]
- mov r4, r0
- punpckhwd mm1, mm0
- lea r0, [r0+r3*4]
- movq mm2, [r0+r3*1-8]
- punpckhbw mm2, [r0+r3*0-8]
- lea r0, [r0+r3*2]
- movq mm3, [r0+r3*1-8]
- punpckhbw mm3, [r0+r3*0-8]
- punpckhwd mm3, mm2
- punpckhdq mm3, mm1
- lea r0, [r0+r3*2]
- movq mm0, [r0+r3*0-8]
- movq mm1, [r4]
- mov r0, r4
- movq mm4, mm3
- movq mm2, mm3
- PALIGNR mm4, mm0, 7, mm0
- PALIGNR mm1, mm2, 1, mm2
- test r1, r1
- jnz .do_left
-.fix_lt_1:
- movq mm5, mm3
- pxor mm5, mm4
- psrlq mm5, 56
- psllq mm5, 48
- pxor mm1, mm5
- jmp .do_left
-.fix_lt_2:
- movq mm5, mm3
- pxor mm5, mm2
- psllq mm5, 56
- psrlq mm5, 56
- pxor mm2, mm5
- test r2, r2
- jnz .do_top
-.fix_tr_1:
- movq mm5, mm3
- pxor mm5, mm1
- psrlq mm5, 56
- psllq mm5, 56
- pxor mm1, mm5
- jmp .do_top
-.do_left:
- movq mm0, mm4
- PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
- movq mm4, mm0
- movq mm7, mm2
- movq mm6, mm2
- PRED4x4_LOWPASS mm1, mm3, mm0, mm4, mm5
- psllq mm1, 56
- PALIGNR mm7, mm1, 7, mm3
- movq mm0, [r0-8]
- movq mm3, [r0]
- movq mm1, [r0+8]
- movq mm2, mm3
- movq mm4, mm3
- PALIGNR mm2, mm0, 7, mm0
- PALIGNR mm1, mm4, 1, mm4
- test r1, r1
- jz .fix_lt_2
- test r2, r2
- jz .fix_tr_1
-.do_top:
- PRED4x4_LOWPASS mm4, mm2, mm1, mm3, mm5
- movq mm5, mm4
- lea r1, [r0+r3*2]
- psllq mm7, 56
- movq mm2, mm5
- movq mm3, mm6
- movq mm4, mm2
- PALIGNR mm2, mm6, 7, mm5
- PALIGNR mm6, mm7, 7, mm0
- lea r2, [r1+r3*2]
- PALIGNR mm4, mm3, 1, mm7
- movq mm5, mm3
- pavgb mm3, mm6
- PRED4x4_LOWPASS mm0, mm4, mm6, mm5, mm7
- movq mm4, mm2
- movq mm1, mm2
- lea r4, [r2+r3*2]
- psrlq mm4, 16
- psrlq mm1, 8
- PRED4x4_LOWPASS mm6, mm4, mm2, mm1, mm5
- movq mm7, mm3
- punpcklbw mm3, mm0
- punpckhbw mm7, mm0
- movq mm1, mm7
- movq mm0, mm7
- movq mm4, mm7
- movq [r4+r3*2], mm3
- PALIGNR mm7, mm3, 2, mm5
- movq [r4+r3*1], mm7
- PALIGNR mm1, mm3, 4, mm5
- movq [r2+r3*2], mm1
- PALIGNR mm0, mm3, 6, mm3
- movq [r2+r3*1], mm0
- movq mm2, mm6
- movq mm3, mm6
- movq [r1+r3*2], mm4
- PALIGNR mm6, mm4, 2, mm5
- movq [r1+r3*1], mm6
- PALIGNR mm2, mm4, 4, mm5
- movq [r0+r3*2], mm2
- PALIGNR mm3, mm4, 6, mm4
- movq [r0+r3*1], mm3
- RET
-
-%macro PRED8x8L_HORIZONTAL_DOWN 0
-cglobal pred8x8l_horizontal_down_8, 4,5
- sub r0, r3
- lea r4, [r0+r3*2]
- movq mm0, [r0+r3*1-8]
- punpckhbw mm0, [r0+r3*0-8]
- movq mm1, [r4+r3*1-8]
- punpckhbw mm1, [r0+r3*2-8]
- mov r4, r0
- punpckhwd mm1, mm0
- lea r0, [r0+r3*4]
- movq mm2, [r0+r3*1-8]
- punpckhbw mm2, [r0+r3*0-8]
- lea r0, [r0+r3*2]
- movq mm3, [r0+r3*1-8]
- punpckhbw mm3, [r0+r3*0-8]
- punpckhwd mm3, mm2
- punpckhdq mm3, mm1
- lea r0, [r0+r3*2]
- movq mm0, [r0+r3*0-8]
- movq mm1, [r4]
- mov r0, r4
- movq mm4, mm3
- movq mm2, mm3
- PALIGNR mm4, mm0, 7, mm0
- PALIGNR mm1, mm2, 1, mm2
- test r1, r1
- jnz .do_left
-.fix_lt_1:
- movq mm5, mm3
- pxor mm5, mm4
- psrlq mm5, 56
- psllq mm5, 48
- pxor mm1, mm5
- jmp .do_left
-.fix_lt_2:
- movq mm5, mm3
- pxor mm5, mm2
- psllq mm5, 56
- psrlq mm5, 56
- pxor mm2, mm5
- test r2, r2
- jnz .do_top
-.fix_tr_1:
- movq mm5, mm3
- pxor mm5, mm1
- psrlq mm5, 56
- psllq mm5, 56
- pxor mm1, mm5
- jmp .do_top
-.fix_tr_2:
- punpckhbw mm3, mm3
- pshufw mm1, mm3, 0xFF
- jmp .do_topright
-.do_left:
- movq mm0, mm4
- PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
- movq2dq xmm0, mm2
- pslldq xmm0, 8
- movq mm4, mm0
- PRED4x4_LOWPASS mm1, mm3, mm0, mm4, mm5
- movq2dq xmm2, mm1
- pslldq xmm2, 15
- psrldq xmm2, 8
- por xmm0, xmm2
- movq mm0, [r0-8]
- movq mm3, [r0]
- movq mm1, [r0+8]
- movq mm2, mm3
- movq mm4, mm3
- PALIGNR mm2, mm0, 7, mm0
- PALIGNR mm1, mm4, 1, mm4
- test r1, r1
- jz .fix_lt_2
- test r2, r2
- jz .fix_tr_1
-.do_top:
- PRED4x4_LOWPASS mm4, mm2, mm1, mm3, mm5
- movq2dq xmm1, mm4
- test r2, r2
- jz .fix_tr_2
- movq mm0, [r0+8]
- movq mm5, mm0
- movq mm2, mm0
- movq mm4, mm0
- psrlq mm5, 56
- PALIGNR mm2, mm3, 7, mm3
- PALIGNR mm5, mm4, 1, mm4
- PRED4x4_LOWPASS mm1, mm2, mm5, mm0, mm4
-.do_topright:
- movq2dq xmm5, mm1
- pslldq xmm5, 8
- por xmm1, xmm5
-INIT_XMM cpuname
- lea r2, [r4+r3*2]
- movdqa xmm2, xmm1
- movdqa xmm3, xmm1
- PALIGNR xmm1, xmm0, 7, xmm4
- PALIGNR xmm2, xmm0, 9, xmm5
- lea r1, [r2+r3*2]
- PALIGNR xmm3, xmm0, 8, xmm0
- movdqa xmm4, xmm1
- pavgb xmm4, xmm3
- lea r0, [r1+r3*2]
- PRED4x4_LOWPASS xmm0, xmm1, xmm2, xmm3, xmm5
- punpcklbw xmm4, xmm0
- movhlps xmm0, xmm4
- movq [r0+r3*2], xmm4
- movq [r2+r3*2], xmm0
- psrldq xmm4, 2
- psrldq xmm0, 2
- movq [r0+r3*1], xmm4
- movq [r2+r3*1], xmm0
- psrldq xmm4, 2
- psrldq xmm0, 2
- movq [r1+r3*2], xmm4
- movq [r4+r3*2], xmm0
- psrldq xmm4, 2
- psrldq xmm0, 2
- movq [r1+r3*1], xmm4
- movq [r4+r3*1], xmm0
- RET
-%endmacro
-
-INIT_MMX sse2
-PRED8x8L_HORIZONTAL_DOWN
-INIT_MMX ssse3
-PRED8x8L_HORIZONTAL_DOWN
-
-;-----------------------------------------------------------------------------
-; void pred4x4_dc_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
-;-----------------------------------------------------------------------------
-
-INIT_MMX mmxext
-cglobal pred4x4_dc_8, 3,5
- pxor mm7, mm7
- mov r4, r0
- sub r0, r2
- movd mm0, [r0]
- psadbw mm0, mm7
- movzx r1d, byte [r0+r2*1-1]
- movd r3d, mm0
- add r3d, r1d
- movzx r1d, byte [r0+r2*2-1]
- lea r0, [r0+r2*2]
- add r3d, r1d
- movzx r1d, byte [r0+r2*1-1]
- add r3d, r1d
- movzx r1d, byte [r0+r2*2-1]
- add r3d, r1d
- add r3d, 4
- shr r3d, 3
- imul r3d, 0x01010101
- mov [r4+r2*0], r3d
- mov [r0+r2*0], r3d
- mov [r0+r2*1], r3d
- mov [r0+r2*2], r3d
- RET
-
-;-----------------------------------------------------------------------------
-; void pred4x4_tm_vp8_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
-;-----------------------------------------------------------------------------
-
-%macro PRED4x4_TM 0
-cglobal pred4x4_tm_vp8_8, 3,6
- sub r0, r2
- pxor mm7, mm7
- movd mm0, [r0]
- punpcklbw mm0, mm7
- movzx r4d, byte [r0-1]
- mov r5d, 2
-.loop:
- movzx r1d, byte [r0+r2*1-1]
- movzx r3d, byte [r0+r2*2-1]
- sub r1d, r4d
- sub r3d, r4d
- movd mm2, r1d
- movd mm4, r3d
-%if cpuflag(mmxext)
- pshufw mm2, mm2, 0
- pshufw mm4, mm4, 0
-%else
- punpcklwd mm2, mm2
- punpcklwd mm4, mm4
- punpckldq mm2, mm2
- punpckldq mm4, mm4
-%endif
- paddw mm2, mm0
- paddw mm4, mm0
- packuswb mm2, mm2
- packuswb mm4, mm4
- movd [r0+r2*1], mm2
- movd [r0+r2*2], mm4
- lea r0, [r0+r2*2]
- dec r5d
- jg .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmx
-PRED4x4_TM
-INIT_MMX mmxext
-PRED4x4_TM
-
-INIT_XMM ssse3
-cglobal pred4x4_tm_vp8_8, 3,3
- sub r0, r2
- movq mm6, [tm_shuf]
- pxor mm1, mm1
- movd mm0, [r0]
- punpcklbw mm0, mm1
- movd mm7, [r0-4]
- pshufb mm7, mm6
- lea r1, [r0+r2*2]
- movd mm2, [r0+r2*1-4]
- movd mm3, [r0+r2*2-4]
- movd mm4, [r1+r2*1-4]
- movd mm5, [r1+r2*2-4]
- pshufb mm2, mm6
- pshufb mm3, mm6
- pshufb mm4, mm6
- pshufb mm5, mm6
- psubw mm2, mm7
- psubw mm3, mm7
- psubw mm4, mm7
- psubw mm5, mm7
- paddw mm2, mm0
- paddw mm3, mm0
- paddw mm4, mm0
- paddw mm5, mm0
- packuswb mm2, mm2
- packuswb mm3, mm3
- packuswb mm4, mm4
- packuswb mm5, mm5
- movd [r0+r2*1], mm2
- movd [r0+r2*2], mm3
- movd [r1+r2*1], mm4
- movd [r1+r2*2], mm5
- RET
-
-;-----------------------------------------------------------------------------
-; void pred4x4_vertical_vp8_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
-;-----------------------------------------------------------------------------
-
-INIT_MMX mmxext
-cglobal pred4x4_vertical_vp8_8, 3,3
- sub r0, r2
- movd m1, [r0-1]
- movd m0, [r0]
- mova m2, m0 ;t0 t1 t2 t3
- punpckldq m0, [r1] ;t0 t1 t2 t3 t4 t5 t6 t7
- lea r1, [r0+r2*2]
- psrlq m0, 8 ;t1 t2 t3 t4
- PRED4x4_LOWPASS m3, m1, m0, m2, m4
- movd [r0+r2*1], m3
- movd [r0+r2*2], m3
- movd [r1+r2*1], m3
- movd [r1+r2*2], m3
- RET
-
-;-----------------------------------------------------------------------------
-; void pred4x4_down_left_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
-;-----------------------------------------------------------------------------
-INIT_MMX mmxext
-cglobal pred4x4_down_left_8, 3,3
- sub r0, r2
- movq m1, [r0]
- punpckldq m1, [r1]
- movq m2, m1
- movq m3, m1
- psllq m1, 8
- pxor m2, m1
- psrlq m2, 8
- pxor m2, m3
- PRED4x4_LOWPASS m0, m1, m2, m3, m4
- lea r1, [r0+r2*2]
- psrlq m0, 8
- movd [r0+r2*1], m0
- psrlq m0, 8
- movd [r0+r2*2], m0
- psrlq m0, 8
- movd [r1+r2*1], m0
- psrlq m0, 8
- movd [r1+r2*2], m0
- RET
-
-;-----------------------------------------------------------------------------
-; void pred4x4_vertical_left_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
-;-----------------------------------------------------------------------------
-
-INIT_MMX mmxext
-cglobal pred4x4_vertical_left_8, 3,3
- sub r0, r2
- movq m1, [r0]
- punpckldq m1, [r1]
- movq m3, m1
- movq m2, m1
- psrlq m3, 8
- psrlq m2, 16
- movq m4, m3
- pavgb m4, m1
- PRED4x4_LOWPASS m0, m1, m2, m3, m5
- lea r1, [r0+r2*2]
- movh [r0+r2*1], m4
- movh [r0+r2*2], m0
- psrlq m4, 8
- psrlq m0, 8
- movh [r1+r2*1], m4
- movh [r1+r2*2], m0
- RET
-
-;-----------------------------------------------------------------------------
-; void pred4x4_horizontal_up_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
-;-----------------------------------------------------------------------------
-
-INIT_MMX mmxext
-cglobal pred4x4_horizontal_up_8, 3,3
- sub r0, r2
- lea r1, [r0+r2*2]
- movd m0, [r0+r2*1-4]
- punpcklbw m0, [r0+r2*2-4]
- movd m1, [r1+r2*1-4]
- punpcklbw m1, [r1+r2*2-4]
- punpckhwd m0, m1
- movq m1, m0
- punpckhbw m1, m1
- pshufw m1, m1, 0xFF
- punpckhdq m0, m1
- movq m2, m0
- movq m3, m0
- movq m7, m0
- psrlq m2, 16
- psrlq m3, 8
- pavgb m7, m3
- PRED4x4_LOWPASS m4, m0, m2, m3, m5
- punpcklbw m7, m4
- movd [r0+r2*1], m7
- psrlq m7, 16
- movd [r0+r2*2], m7
- psrlq m7, 16
- movd [r1+r2*1], m7
- movd [r1+r2*2], m1
- RET
-
-;-----------------------------------------------------------------------------
-; void pred4x4_horizontal_down_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
-;-----------------------------------------------------------------------------
-
-INIT_MMX mmxext
-cglobal pred4x4_horizontal_down_8, 3,3
- sub r0, r2
- lea r1, [r0+r2*2]
- movh m0, [r0-4] ; lt ..
- punpckldq m0, [r0] ; t3 t2 t1 t0 lt .. .. ..
- psllq m0, 8 ; t2 t1 t0 lt .. .. .. ..
- movd m1, [r1+r2*2-4] ; l3
- punpcklbw m1, [r1+r2*1-4] ; l2 l3
- movd m2, [r0+r2*2-4] ; l1
- punpcklbw m2, [r0+r2*1-4] ; l0 l1
- punpckhwd m1, m2 ; l0 l1 l2 l3
- punpckhdq m1, m0 ; t2 t1 t0 lt l0 l1 l2 l3
- movq m0, m1
- movq m2, m1
- movq m5, m1
- psrlq m0, 16 ; .. .. t2 t1 t0 lt l0 l1
- psrlq m2, 8 ; .. t2 t1 t0 lt l0 l1 l2
- pavgb m5, m2
- PRED4x4_LOWPASS m3, m1, m0, m2, m4
- punpcklbw m5, m3
- psrlq m3, 32
- PALIGNR m3, m5, 6, m4
- movh [r1+r2*2], m5
- psrlq m5, 16
- movh [r1+r2*1], m5
- psrlq m5, 16
- movh [r0+r2*2], m5
- movh [r0+r2*1], m3
- RET
-
-;-----------------------------------------------------------------------------
-; void pred4x4_vertical_right_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
-;-----------------------------------------------------------------------------
-
-INIT_MMX mmxext
-cglobal pred4x4_vertical_right_8, 3,3
- sub r0, r2
- lea r1, [r0+r2*2]
- movh m0, [r0] ; ........t3t2t1t0
- movq m5, m0
- PALIGNR m0, [r0-8], 7, m1 ; ......t3t2t1t0lt
- pavgb m5, m0
- PALIGNR m0, [r0+r2*1-8], 7, m1 ; ....t3t2t1t0ltl0
- movq m1, m0
- PALIGNR m0, [r0+r2*2-8], 7, m2 ; ..t3t2t1t0ltl0l1
- movq m2, m0
- PALIGNR m0, [r1+r2*1-8], 7, m3 ; t3t2t1t0ltl0l1l2
- PRED4x4_LOWPASS m3, m1, m0, m2, m4
- movq m1, m3
- psrlq m3, 16
- psllq m1, 48
- movh [r0+r2*1], m5
- movh [r0+r2*2], m3
- PALIGNR m5, m1, 7, m2
- psllq m1, 8
- movh [r1+r2*1], m5
- PALIGNR m3, m1, 7, m1
- movh [r1+r2*2], m3
- RET
-
-;-----------------------------------------------------------------------------
-; void pred4x4_down_right_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
-;-----------------------------------------------------------------------------
-
-INIT_MMX mmxext
-cglobal pred4x4_down_right_8, 3,3
- sub r0, r2
- lea r1, [r0+r2*2]
- movq m1, [r1-8]
- movq m2, [r0+r2*1-8]
- punpckhbw m2, [r0-8]
- movh m3, [r0]
- punpckhwd m1, m2
- PALIGNR m3, m1, 5, m1
- movq m1, m3
- PALIGNR m3, [r1+r2*1-8], 7, m4
- movq m2, m3
- PALIGNR m3, [r1+r2*2-8], 7, m4
- PRED4x4_LOWPASS m0, m3, m1, m2, m4
- movh [r1+r2*2], m0
- psrlq m0, 8
- movh [r1+r2*1], m0
- psrlq m0, 8
- movh [r0+r2*2], m0
- psrlq m0, 8
- movh [r0+r2*1], m0
- RET
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/h264_intrapred_10bit.asm b/src/thirdparty/ffmpeg/libavcodec/x86/h264_intrapred_10bit.asm
deleted file mode 100644
index 9d78f520a..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/h264_intrapred_10bit.asm
+++ /dev/null
@@ -1,1199 +0,0 @@
-;*****************************************************************************
-;* MMX/SSE2/AVX-optimized 10-bit H.264 intra prediction code
-;*****************************************************************************
-;* Copyright (C) 2005-2011 x264 project
-;*
-;* Authors: Daniel Kang <daniel.d.kang@gmail.com>
-;*
-;* This file is part of Libav.
-;*
-;* Libav is free software; you can redistribute it and/or
-;* modify it under the terms of the GNU Lesser General Public
-;* License as published by the Free Software Foundation; either
-;* version 2.1 of the License, or (at your option) any later version.
-;*
-;* Libav is distributed in the hope that it will be useful,
-;* but WITHOUT ANY WARRANTY; without even the implied warranty of
-;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-;* Lesser General Public License for more details.
-;*
-;* You should have received a copy of the GNU Lesser General Public
-;* License along with Libav; if not, write to the Free Software
-;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-;******************************************************************************
-
-%include "libavutil/x86/x86util.asm"
-
-SECTION_RODATA
-
-cextern pw_16
-cextern pw_8
-cextern pw_4
-cextern pw_2
-cextern pw_1
-
-pw_m32101234: dw -3, -2, -1, 0, 1, 2, 3, 4
-pw_m3: times 8 dw -3
-pw_pixel_max: times 8 dw ((1 << 10)-1)
-pw_512: times 8 dw 512
-pd_17: times 4 dd 17
-pd_16: times 4 dd 16
-
-SECTION .text
-
-; dest, left, right, src
-; output: %1 = (t[n-1] + t[n]*2 + t[n+1] + 2) >> 2
-%macro PRED4x4_LOWPASS 4
- paddw %2, %3
- psrlw %2, 1
- pavgw %1, %4, %2
-%endmacro
-
-;-----------------------------------------------------------------------------
-; void pred4x4_down_right(pixel *src, const pixel *topright, int stride)
-;-----------------------------------------------------------------------------
-%macro PRED4x4_DR 0
-cglobal pred4x4_down_right_10, 3, 3
- sub r0, r2
- lea r1, [r0+r2*2]
- movhps m1, [r1-8]
- movhps m2, [r0+r2*1-8]
- movhps m4, [r0-8]
- punpckhwd m2, m4
- movq m3, [r0]
- punpckhdq m1, m2
- PALIGNR m3, m1, 10, m1
- movhps m4, [r1+r2*1-8]
- PALIGNR m0, m3, m4, 14, m4
- movhps m4, [r1+r2*2-8]
- PALIGNR m2, m0, m4, 14, m4
- PRED4x4_LOWPASS m0, m2, m3, m0
- movq [r1+r2*2], m0
- psrldq m0, 2
- movq [r1+r2*1], m0
- psrldq m0, 2
- movq [r0+r2*2], m0
- psrldq m0, 2
- movq [r0+r2*1], m0
- RET
-%endmacro
-
-INIT_XMM sse2
-PRED4x4_DR
-INIT_XMM ssse3
-PRED4x4_DR
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-PRED4x4_DR
-%endif
-
-;-----------------------------------------------------------------------------
-; void 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
- lea r1, [r0+r2*2]
- movq m5, [r0] ; ........t3t2t1t0
- movhps m1, [r0-8]
- PALIGNR m0, m5, m1, 14, m1 ; ......t3t2t1t0lt
- pavgw m5, m0
- movhps m1, [r0+r2*1-8]
- PALIGNR m0, m1, 14, m1 ; ....t3t2t1t0ltl0
- movhps m2, [r0+r2*2-8]
- PALIGNR m1, m0, m2, 14, m2 ; ..t3t2t1t0ltl0l1
- movhps m3, [r1+r2*1-8]
- PALIGNR m2, m1, m3, 14, m3 ; t3t2t1t0ltl0l1l2
- PRED4x4_LOWPASS m1, m0, m2, m1
- pslldq m0, m1, 12
- psrldq m1, 4
- movq [r0+r2*1], m5
- movq [r0+r2*2], m1
- PALIGNR m5, m0, 14, m2
- pslldq m0, 2
- movq [r1+r2*1], m5
- PALIGNR m1, m0, 14, m0
- movq [r1+r2*2], m1
- RET
-%endmacro
-
-INIT_XMM sse2
-PRED4x4_VR
-INIT_XMM ssse3
-PRED4x4_VR
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-PRED4x4_VR
-%endif
-
-;-----------------------------------------------------------------------------
-; void pred4x4_horizontal_down(pixel *src, const pixel *topright, int stride)
-;-----------------------------------------------------------------------------
-%macro PRED4x4_HD 0
-cglobal pred4x4_horizontal_down_10, 3, 3
- sub r0, r2
- lea r1, [r0+r2*2]
- movq m0, [r0-8] ; lt ..
- movhps m0, [r0]
- pslldq m0, 2 ; t2 t1 t0 lt .. .. .. ..
- movq m1, [r1+r2*2-8] ; l3
- movq m3, [r1+r2*1-8]
- punpcklwd m1, m3 ; l2 l3
- movq m2, [r0+r2*2-8] ; l1
- movq m3, [r0+r2*1-8]
- punpcklwd m2, m3 ; l0 l1
- punpckhdq m1, m2 ; l0 l1 l2 l3
- punpckhqdq m1, m0 ; t2 t1 t0 lt l0 l1 l2 l3
- psrldq m0, m1, 4 ; .. .. t2 t1 t0 lt l0 l1
- psrldq m3, m1, 2 ; .. t2 t1 t0 lt l0 l1 l2
- pavgw m5, m1, m3
- PRED4x4_LOWPASS m3, m1, m0, m3
- punpcklwd m5, m3
- psrldq m3, 8
- PALIGNR m3, m5, 12, m4
- movq [r1+r2*2], m5
- movhps [r0+r2*2], m5
- psrldq m5, 4
- movq [r1+r2*1], m5
- movq [r0+r2*1], m3
- RET
-%endmacro
-
-INIT_XMM sse2
-PRED4x4_HD
-INIT_XMM ssse3
-PRED4x4_HD
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-PRED4x4_HD
-%endif
-
-;-----------------------------------------------------------------------------
-; void 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
- sub r0, r2
- lea r1, [r0+r2*2]
- movq m2, [r0+r2*1-8]
- paddw m2, [r0+r2*2-8]
- paddw m2, [r1+r2*1-8]
- paddw m2, [r1+r2*2-8]
- psrlq m2, 48
- movq m0, [r0]
- HADDW m0, m1
- paddw m0, [pw_4]
- paddw m0, m2
- psrlw m0, 3
- SPLATW m0, m0, 0
- movq [r0+r2*1], m0
- movq [r0+r2*2], m0
- movq [r1+r2*1], m0
- movq [r1+r2*2], m0
- RET
-
-;-----------------------------------------------------------------------------
-; void pred4x4_down_left(pixel *src, const pixel *topright, int stride)
-;-----------------------------------------------------------------------------
-%macro PRED4x4_DL 0
-cglobal pred4x4_down_left_10, 3, 3
- sub r0, r2
- movq m0, [r0]
- movhps m0, [r1]
- psrldq m2, m0, 2
- pslldq m3, m0, 2
- pshufhw m2, m2, 10100100b
- PRED4x4_LOWPASS m0, m3, m2, m0
- lea r1, [r0+r2*2]
- movhps [r1+r2*2], m0
- psrldq m0, 2
- movq [r0+r2*1], m0
- psrldq m0, 2
- movq [r0+r2*2], m0
- psrldq m0, 2
- movq [r1+r2*1], m0
- RET
-%endmacro
-
-INIT_XMM sse2
-PRED4x4_DL
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-PRED4x4_DL
-%endif
-
-;-----------------------------------------------------------------------------
-; void pred4x4_vertical_left(pixel *src, const pixel *topright, int stride)
-;-----------------------------------------------------------------------------
-%macro PRED4x4_VL 0
-cglobal pred4x4_vertical_left_10, 3, 3
- sub r0, r2
- movu m1, [r0]
- movhps m1, [r1]
- psrldq m0, m1, 2
- psrldq m2, m1, 4
- pavgw m4, m0, m1
- PRED4x4_LOWPASS m0, m1, m2, m0
- lea r1, [r0+r2*2]
- movq [r0+r2*1], m4
- movq [r0+r2*2], m0
- psrldq m4, 2
- psrldq m0, 2
- movq [r1+r2*1], m4
- movq [r1+r2*2], m0
- RET
-%endmacro
-
-INIT_XMM sse2
-PRED4x4_VL
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-PRED4x4_VL
-%endif
-
-;-----------------------------------------------------------------------------
-; void pred4x4_horizontal_up(pixel *src, const pixel *topright, int stride)
-;-----------------------------------------------------------------------------
-INIT_MMX mmxext
-cglobal pred4x4_horizontal_up_10, 3, 3
- sub r0, r2
- lea r1, [r0+r2*2]
- movq m0, [r0+r2*1-8]
- punpckhwd m0, [r0+r2*2-8]
- movq m1, [r1+r2*1-8]
- punpckhwd m1, [r1+r2*2-8]
- punpckhdq m0, m1
- pshufw m1, m1, 0xFF
- movq [r1+r2*2], m1
- movd [r1+r2*1+4], m1
- pshufw m2, m0, 11111001b
- movq m1, m2
- pavgw m2, m0
-
- pshufw m5, m0, 11111110b
- PRED4x4_LOWPASS m1, m0, m5, m1
- movq m6, m2
- punpcklwd m6, m1
- movq [r0+r2*1], m6
- psrlq m2, 16
- psrlq m1, 16
- punpcklwd m2, m1
- movq [r0+r2*2], m2
- psrlq m2, 32
- movd [r1+r2*1], m2
- RET
-
-
-
-;-----------------------------------------------------------------------------
-; void pred8x8_vertical(pixel *src, int stride)
-;-----------------------------------------------------------------------------
-INIT_XMM sse2
-cglobal pred8x8_vertical_10, 2, 2
- sub r0, r1
- mova m0, [r0]
-%rep 3
- mova [r0+r1*1], m0
- mova [r0+r1*2], m0
- lea r0, [r0+r1*2]
-%endrep
- mova [r0+r1*1], m0
- mova [r0+r1*2], m0
- RET
-
-;-----------------------------------------------------------------------------
-; void pred8x8_horizontal(pixel *src, int stride)
-;-----------------------------------------------------------------------------
-INIT_XMM sse2
-cglobal pred8x8_horizontal_10, 2, 3
- mov r2d, 4
-.loop:
- movq m0, [r0+r1*0-8]
- movq m1, [r0+r1*1-8]
- pshuflw m0, m0, 0xff
- pshuflw m1, m1, 0xff
- punpcklqdq m0, m0
- punpcklqdq m1, m1
- mova [r0+r1*0], m0
- mova [r0+r1*1], m1
- lea r0, [r0+r1*2]
- dec r2d
- jg .loop
- REP_RET
-
-;-----------------------------------------------------------------------------
-; void predict_8x8_dc(pixel *src, int stride)
-;-----------------------------------------------------------------------------
-%macro MOV8 2-3
-; sort of a hack, but it works
-%if mmsize==8
- movq [%1+0], %2
- movq [%1+8], %3
-%else
- movdqa [%1], %2
-%endif
-%endmacro
-
-%macro PRED8x8_DC 1
-cglobal pred8x8_dc_10, 2, 6
- sub r0, r1
- pxor m4, m4
- movq m0, [r0+0]
- movq m1, [r0+8]
-%if mmsize==16
- punpcklwd m0, m1
- movhlps m1, m0
- paddw m0, m1
-%else
- pshufw m2, m0, 00001110b
- pshufw m3, m1, 00001110b
- paddw m0, m2
- paddw m1, m3
- punpcklwd m0, m1
-%endif
- %1 m2, m0, 00001110b
- paddw m0, m2
-
- lea r5, [r1*3]
- lea r4, [r0+r1*4]
- movzx r2d, word [r0+r1*1-2]
- movzx r3d, word [r0+r1*2-2]
- add r2d, r3d
- movzx r3d, word [r0+r5*1-2]
- add r2d, r3d
- movzx r3d, word [r4-2]
- add r2d, r3d
- movd m2, r2d ; s2
-
- movzx r2d, word [r4+r1*1-2]
- movzx r3d, word [r4+r1*2-2]
- add r2d, r3d
- movzx r3d, word [r4+r5*1-2]
- add r2d, r3d
- movzx r3d, word [r4+r1*4-2]
- add r2d, r3d
- movd m3, r2d ; s3
-
- punpcklwd m2, m3
- punpckldq m0, m2 ; s0, s1, s2, s3
- %1 m3, m0, 11110110b ; s2, s1, s3, s3
- %1 m0, m0, 01110100b ; s0, s1, s3, s1
- paddw m0, m3
- psrlw m0, 2
- pavgw m0, m4 ; s0+s2, s1, s3, s1+s3
-%if mmsize==16
- punpcklwd m0, m0
- pshufd m3, m0, 11111010b
- punpckldq m0, m0
- SWAP 0,1
-%else
- pshufw m1, m0, 0x00
- pshufw m2, m0, 0x55
- pshufw m3, m0, 0xaa
- pshufw m4, m0, 0xff
-%endif
- MOV8 r0+r1*1, m1, m2
- MOV8 r0+r1*2, m1, m2
- MOV8 r0+r5*1, m1, m2
- MOV8 r0+r1*4, m1, m2
- MOV8 r4+r1*1, m3, m4
- MOV8 r4+r1*2, m3, m4
- MOV8 r4+r5*1, m3, m4
- MOV8 r4+r1*4, m3, m4
- RET
-%endmacro
-
-INIT_MMX mmxext
-PRED8x8_DC pshufw
-INIT_XMM sse2
-PRED8x8_DC pshuflw
-
-;-----------------------------------------------------------------------------
-; void pred8x8_top_dc(pixel *src, int stride)
-;-----------------------------------------------------------------------------
-INIT_XMM sse2
-cglobal pred8x8_top_dc_10, 2, 4
- sub r0, r1
- mova m0, [r0]
- pshuflw m1, m0, 0x4e
- pshufhw m1, m1, 0x4e
- paddw m0, m1
- pshuflw m1, m0, 0xb1
- pshufhw m1, m1, 0xb1
- paddw m0, m1
- lea r2, [r1*3]
- lea r3, [r0+r1*4]
- paddw m0, [pw_2]
- psrlw m0, 2
- mova [r0+r1*1], m0
- mova [r0+r1*2], m0
- mova [r0+r2*1], m0
- mova [r0+r1*4], m0
- mova [r3+r1*1], m0
- mova [r3+r1*2], m0
- mova [r3+r2*1], m0
- mova [r3+r1*4], m0
- RET
-
-;-----------------------------------------------------------------------------
-; void pred8x8_plane(pixel *src, int stride)
-;-----------------------------------------------------------------------------
-INIT_XMM sse2
-cglobal pred8x8_plane_10, 2, 7, 7
- sub r0, r1
- lea r2, [r1*3]
- lea r3, [r0+r1*4]
- mova m2, [r0]
- pmaddwd m2, [pw_m32101234]
- HADDD m2, m1
- movd m0, [r0-4]
- psrld m0, 14
- psubw m2, m0 ; H
- movd m0, [r3+r1*4-4]
- movd m1, [r0+12]
- paddw m0, m1
- psllw m0, 4 ; 16*(src[7*stride-1] + src[-stride+7])
- movzx r4d, word [r3+r1*1-2] ; src[4*stride-1]
- movzx r5d, word [r0+r2*1-2] ; src[2*stride-1]
- sub r4d, r5d
- movzx r6d, word [r3+r1*2-2] ; src[5*stride-1]
- movzx r5d, word [r0+r1*2-2] ; src[1*stride-1]
- sub r6d, r5d
- lea r4d, [r4+r6*2]
- movzx r5d, word [r3+r2*1-2] ; src[6*stride-1]
- movzx r6d, word [r0+r1*1-2] ; src[0*stride-1]
- sub r5d, r6d
- lea r5d, [r5*3]
- add r4d, r5d
- movzx r6d, word [r3+r1*4-2] ; src[7*stride-1]
- movzx r5d, word [r0+r1*0-2] ; src[ -stride-1]
- sub r6d, r5d
- lea r4d, [r4+r6*4]
- movd m3, r4d ; V
- punpckldq m2, m3
- pmaddwd m2, [pd_17]
- paddd m2, [pd_16]
- psrad m2, 5 ; b, c
-
- mova m3, [pw_pixel_max]
- pxor m1, m1
- SPLATW m0, m0, 1
- SPLATW m4, m2, 2
- SPLATW m2, m2, 0
- pmullw m2, [pw_m32101234] ; b
- pmullw m5, m4, [pw_m3] ; c
- paddw m5, [pw_16]
- mov r2d, 8
- add r0, r1
-.loop:
- paddsw m6, m2, m5
- paddsw m6, m0
- psraw m6, 5
- CLIPW m6, m1, m3
- mova [r0], m6
- paddw m5, m4
- add r0, r1
- dec r2d
- jg .loop
- REP_RET
-
-
-;-----------------------------------------------------------------------------
-; void 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
- mova m0, [pw_512] ; (1<<(BIT_DEPTH-1))
- lea r1, [r3*3]
- lea r2, [r0+r3*4]
- MOV8 r0+r3*0, m0, m0
- MOV8 r0+r3*1, m0, m0
- MOV8 r0+r3*2, m0, m0
- MOV8 r0+r1*1, m0, m0
- MOV8 r2+r3*0, m0, m0
- MOV8 r2+r3*1, m0, m0
- MOV8 r2+r3*2, m0, m0
- MOV8 r2+r1*1, m0, m0
- RET
-%endmacro
-
-INIT_MMX mmxext
-PRED8x8L_128_DC
-INIT_XMM sse2
-PRED8x8L_128_DC
-
-;-----------------------------------------------------------------------------
-; void 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
- sub r0, r3
- mova m0, [r0]
- shr r1d, 14
- shr r2d, 13
- neg r1
- pslldq m1, m0, 2
- psrldq m2, m0, 2
- pinsrw m1, [r0+r1], 0
- pinsrw m2, [r0+r2+14], 7
- lea r1, [r3*3]
- lea r2, [r0+r3*4]
- PRED4x4_LOWPASS m0, m2, m1, m0
- HADDW m0, m1
- paddw m0, [pw_4]
- psrlw m0, 3
- SPLATW m0, m0, 0
- mova [r0+r3*1], m0
- mova [r0+r3*2], m0
- mova [r0+r1*1], m0
- mova [r0+r3*4], m0
- mova [r2+r3*1], m0
- mova [r2+r3*2], m0
- mova [r2+r1*1], m0
- mova [r2+r3*4], m0
- RET
-%endmacro
-
-INIT_XMM sse2
-PRED8x8L_TOP_DC
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-PRED8x8L_TOP_DC
-%endif
-
-;-----------------------------------------------------------------------------
-;void 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
- sub r0, r3
- lea r4, [r0+r3*4]
- lea r5, [r3*3]
- mova m0, [r0+r3*2-16]
- punpckhwd m0, [r0+r3*1-16]
- mova m1, [r4+r3*0-16]
- punpckhwd m1, [r0+r5*1-16]
- punpckhdq m1, m0
- mova m2, [r4+r3*2-16]
- punpckhwd m2, [r4+r3*1-16]
- mova m3, [r4+r3*4-16]
- punpckhwd m3, [r4+r5*1-16]
- punpckhdq m3, m2
- punpckhqdq m3, m1
- mova m0, [r0]
- shr r1d, 14
- shr r2d, 13
- neg r1
- pslldq m1, m0, 2
- psrldq m2, m0, 2
- pinsrw m1, [r0+r1], 0
- pinsrw m2, [r0+r2+14], 7
- not r1
- and r1, r3
- pslldq m4, m3, 2
- psrldq m5, m3, 2
- pshuflw m4, m4, 11100101b
- pinsrw m5, [r0+r1-2], 7
- PRED4x4_LOWPASS m3, m4, m5, m3
- PRED4x4_LOWPASS m0, m2, m1, m0
- paddw m0, m3
- HADDW m0, m1
- paddw m0, [pw_8]
- psrlw m0, 4
- SPLATW m0, m0
- mova [r0+r3*1], m0
- mova [r0+r3*2], m0
- mova [r0+r5*1], m0
- mova [r0+r3*4], m0
- mova [r4+r3*1], m0
- mova [r4+r3*2], m0
- mova [r4+r5*1], m0
- mova [r4+r3*4], m0
- RET
-%endmacro
-
-INIT_XMM sse2
-PRED8x8L_DC
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-PRED8x8L_DC
-%endif
-
-;-----------------------------------------------------------------------------
-; void pred8x8l_vertical(pixel *src, int has_topleft, int has_topright, int stride)
-;-----------------------------------------------------------------------------
-%macro PRED8x8L_VERTICAL 0
-cglobal pred8x8l_vertical_10, 4, 4, 6
- sub r0, r3
- mova m0, [r0]
- shr r1d, 14
- shr r2d, 13
- neg r1
- pslldq m1, m0, 2
- psrldq m2, m0, 2
- pinsrw m1, [r0+r1], 0
- pinsrw m2, [r0+r2+14], 7
- lea r1, [r3*3]
- lea r2, [r0+r3*4]
- PRED4x4_LOWPASS m0, m2, m1, m0
- mova [r0+r3*1], m0
- mova [r0+r3*2], m0
- mova [r0+r1*1], m0
- mova [r0+r3*4], m0
- mova [r2+r3*1], m0
- mova [r2+r3*2], m0
- mova [r2+r1*1], m0
- mova [r2+r3*4], m0
- RET
-%endmacro
-
-INIT_XMM sse2
-PRED8x8L_VERTICAL
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-PRED8x8L_VERTICAL
-%endif
-
-;-----------------------------------------------------------------------------
-; void pred8x8l_horizontal(uint8_t *src, int has_topleft, int has_topright, int stride)
-;-----------------------------------------------------------------------------
-%macro PRED8x8L_HORIZONTAL 0
-cglobal pred8x8l_horizontal_10, 4, 4, 5
- mova m0, [r0-16]
- shr r1d, 14
- dec r1
- and r1, r3
- sub r1, r3
- punpckhwd m0, [r0+r1-16]
- mova m1, [r0+r3*2-16]
- punpckhwd m1, [r0+r3*1-16]
- lea r2, [r0+r3*4]
- lea r1, [r3*3]
- punpckhdq m1, m0
- mova m2, [r2+r3*0-16]
- punpckhwd m2, [r0+r1-16]
- mova m3, [r2+r3*2-16]
- punpckhwd m3, [r2+r3*1-16]
- punpckhdq m3, m2
- punpckhqdq m3, m1
- PALIGNR m4, m3, [r2+r1-16], 14, m0
- pslldq m0, m4, 2
- pshuflw m0, m0, 11100101b
- PRED4x4_LOWPASS m4, m3, m0, m4
- punpckhwd m3, m4, m4
- punpcklwd m4, m4
- pshufd m0, m3, 0xff
- pshufd m1, m3, 0xaa
- pshufd m2, m3, 0x55
- pshufd m3, m3, 0x00
- mova [r0+r3*0], m0
- mova [r0+r3*1], m1
- mova [r0+r3*2], m2
- mova [r0+r1*1], m3
- pshufd m0, m4, 0xff
- pshufd m1, m4, 0xaa
- pshufd m2, m4, 0x55
- pshufd m3, m4, 0x00
- mova [r2+r3*0], m0
- mova [r2+r3*1], m1
- mova [r2+r3*2], m2
- mova [r2+r1*1], m3
- RET
-%endmacro
-
-INIT_XMM sse2
-PRED8x8L_HORIZONTAL
-INIT_XMM ssse3
-PRED8x8L_HORIZONTAL
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-PRED8x8L_HORIZONTAL
-%endif
-
-;-----------------------------------------------------------------------------
-;void 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
- sub r0, r3
- mova m3, [r0]
- shr r1d, 14
- neg r1
- shr r2d, 13
- pslldq m1, m3, 2
- psrldq m2, m3, 2
- pinsrw m1, [r0+r1], 0
- pinsrw m2, [r0+r2+14], 7
- PRED4x4_LOWPASS m6, m2, m1, m3
- jz .fix_tr ; flags from shr r2d
- mova m1, [r0+16]
- psrldq m5, m1, 2
- PALIGNR m2, m1, m3, 14, m3
- pshufhw m5, m5, 10100100b
- PRED4x4_LOWPASS m1, m2, m5, m1
-.do_topright:
- lea r1, [r3*3]
- psrldq m5, m1, 14
- lea r2, [r0+r3*4]
- PALIGNR m2, m1, m6, 2, m0
- PALIGNR m3, m1, m6, 14, m0
- PALIGNR m5, m1, 2, m0
- pslldq m4, m6, 2
- PRED4x4_LOWPASS m6, m4, m2, m6
- PRED4x4_LOWPASS m1, m3, m5, m1
- mova [r2+r3*4], m1
- PALIGNR m1, m6, 14, m2
- pslldq m6, 2
- mova [r2+r1*1], m1
- PALIGNR m1, m6, 14, m2
- pslldq m6, 2
- mova [r2+r3*2], m1
- PALIGNR m1, m6, 14, m2
- pslldq m6, 2
- mova [r2+r3*1], m1
- PALIGNR m1, m6, 14, m2
- pslldq m6, 2
- mova [r0+r3*4], m1
- PALIGNR m1, m6, 14, m2
- pslldq m6, 2
- mova [r0+r1*1], m1
- PALIGNR m1, m6, 14, m2
- pslldq m6, 2
- mova [r0+r3*2], m1
- PALIGNR m1, m6, 14, m6
- mova [r0+r3*1], m1
- RET
-.fix_tr:
- punpckhwd m3, m3
- pshufd m1, m3, 0xFF
- jmp .do_topright
-%endmacro
-
-INIT_XMM sse2
-PRED8x8L_DOWN_LEFT
-INIT_XMM ssse3
-PRED8x8L_DOWN_LEFT
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-PRED8x8L_DOWN_LEFT
-%endif
-
-;-----------------------------------------------------------------------------
-;void 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
-; no need to check
-cglobal pred8x8l_down_right_10, 4, 5, 8
- sub r0, r3
- lea r4, [r0+r3*4]
- lea r1, [r3*3]
- mova m0, [r0+r3*1-16]
- punpckhwd m0, [r0+r3*0-16]
- mova m1, [r0+r1*1-16]
- punpckhwd m1, [r0+r3*2-16]
- punpckhdq m1, m0
- mova m2, [r4+r3*1-16]
- punpckhwd m2, [r4+r3*0-16]
- mova m3, [r4+r1*1-16]
- punpckhwd m3, [r4+r3*2-16]
- punpckhdq m3, m2
- punpckhqdq m3, m1
- mova m0, [r4+r3*4-16]
- mova m1, [r0]
- PALIGNR m4, m3, m0, 14, m0
- PALIGNR m1, m3, 2, m2
- pslldq m0, m4, 2
- pshuflw m0, m0, 11100101b
- PRED4x4_LOWPASS m6, m1, m4, m3
- PRED4x4_LOWPASS m4, m3, m0, m4
- mova m3, [r0]
- shr r2d, 13
- pslldq m1, m3, 2
- psrldq m2, m3, 2
- pinsrw m1, [r0-2], 0
- pinsrw m2, [r0+r2+14], 7
- PRED4x4_LOWPASS m3, m2, m1, m3
- PALIGNR m2, m3, m6, 2, m0
- PALIGNR m5, m3, m6, 14, m0
- psrldq m7, m3, 2
- PRED4x4_LOWPASS m6, m4, m2, m6
- PRED4x4_LOWPASS m3, m5, m7, m3
- mova [r4+r3*4], m6
- PALIGNR m3, m6, 14, m2
- pslldq m6, 2
- mova [r0+r3*1], m3
- PALIGNR m3, m6, 14, m2
- pslldq m6, 2
- mova [r0+r3*2], m3
- PALIGNR m3, m6, 14, m2
- pslldq m6, 2
- mova [r0+r1*1], m3
- PALIGNR m3, m6, 14, m2
- pslldq m6, 2
- mova [r0+r3*4], m3
- PALIGNR m3, m6, 14, m2
- pslldq m6, 2
- mova [r4+r3*1], m3
- PALIGNR m3, m6, 14, m2
- pslldq m6, 2
- mova [r4+r3*2], m3
- PALIGNR m3, m6, 14, m6
- mova [r4+r1*1], m3
- RET
-%endmacro
-
-INIT_XMM sse2
-PRED8x8L_DOWN_RIGHT
-INIT_XMM ssse3
-PRED8x8L_DOWN_RIGHT
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-PRED8x8L_DOWN_RIGHT
-%endif
-
-;-----------------------------------------------------------------------------
-; void pred8x8l_vertical_right(pixel *src, int has_topleft, int has_topright, int stride)
-;-----------------------------------------------------------------------------
-%macro PRED8x8L_VERTICAL_RIGHT 0
-; likewise with 8x8l_down_right
-cglobal pred8x8l_vertical_right_10, 4, 5, 7
- sub r0, r3
- lea r4, [r0+r3*4]
- lea r1, [r3*3]
- mova m0, [r0+r3*1-16]
- punpckhwd m0, [r0+r3*0-16]
- mova m1, [r0+r1*1-16]
- punpckhwd m1, [r0+r3*2-16]
- punpckhdq m1, m0
- mova m2, [r4+r3*1-16]
- punpckhwd m2, [r4+r3*0-16]
- mova m3, [r4+r1*1-16]
- punpckhwd m3, [r4+r3*2-16]
- punpckhdq m3, m2
- punpckhqdq m3, m1
- mova m0, [r4+r3*4-16]
- mova m1, [r0]
- PALIGNR m4, m3, m0, 14, m0
- PALIGNR m1, m3, 2, m2
- PRED4x4_LOWPASS m3, m1, m4, m3
- mova m2, [r0]
- shr r2d, 13
- pslldq m1, m2, 2
- psrldq m5, m2, 2
- pinsrw m1, [r0-2], 0
- pinsrw m5, [r0+r2+14], 7
- PRED4x4_LOWPASS m2, m5, m1, m2
- PALIGNR m6, m2, m3, 12, m1
- PALIGNR m5, m2, m3, 14, m0
- PRED4x4_LOWPASS m0, m6, m2, m5
- pavgw m2, m5
- mova [r0+r3*2], m0
- mova [r0+r3*1], m2
- pslldq m6, m3, 4
- pslldq m1, m3, 2
- PRED4x4_LOWPASS m1, m3, m6, m1
- PALIGNR m2, m1, 14, m4
- mova [r0+r1*1], m2
- pslldq m1, 2
- PALIGNR m0, m1, 14, m3
- mova [r0+r3*4], m0
- pslldq m1, 2
- PALIGNR m2, m1, 14, m4
- mova [r4+r3*1], m2
- pslldq m1, 2
- PALIGNR m0, m1, 14, m3
- mova [r4+r3*2], m0
- pslldq m1, 2
- PALIGNR m2, m1, 14, m4
- mova [r4+r1*1], m2
- pslldq m1, 2
- PALIGNR m0, m1, 14, m1
- mova [r4+r3*4], m0
- RET
-%endmacro
-
-INIT_XMM sse2
-PRED8x8L_VERTICAL_RIGHT
-INIT_XMM ssse3
-PRED8x8L_VERTICAL_RIGHT
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-PRED8x8L_VERTICAL_RIGHT
-%endif
-
-;-----------------------------------------------------------------------------
-; void 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
- mova m0, [r0+r3*0-16]
- punpckhwd m0, [r0+r3*1-16]
- shr r1d, 14
- dec r1
- and r1, r3
- sub r1, r3
- mova m4, [r0+r1*1-16]
- lea r1, [r3*3]
- lea r2, [r0+r3*4]
- mova m1, [r0+r3*2-16]
- punpckhwd m1, [r0+r1*1-16]
- punpckhdq m0, m1
- mova m2, [r2+r3*0-16]
- punpckhwd m2, [r2+r3*1-16]
- mova m3, [r2+r3*2-16]
- punpckhwd m3, [r2+r1*1-16]
- punpckhdq m2, m3
- punpckhqdq m0, m2
- PALIGNR m1, m0, m4, 14, m4
- psrldq m2, m0, 2
- pshufhw m2, m2, 10100100b
- PRED4x4_LOWPASS m0, m1, m2, m0
- psrldq m1, m0, 2
- psrldq m2, m0, 4
- pshufhw m1, m1, 10100100b
- pshufhw m2, m2, 01010100b
- pavgw m4, m0, m1
- PRED4x4_LOWPASS m1, m2, m0, m1
- punpckhwd m5, m4, m1
- punpcklwd m4, m1
- mova [r2+r3*0], m5
- mova [r0+r3*0], m4
- pshufd m0, m5, 11111001b
- pshufd m1, m5, 11111110b
- pshufd m2, m5, 11111111b
- mova [r2+r3*1], m0
- mova [r2+r3*2], m1
- mova [r2+r1*1], m2
- PALIGNR m2, m5, m4, 4, m0
- PALIGNR m3, m5, m4, 8, m1
- PALIGNR m5, m5, m4, 12, m4
- mova [r0+r3*1], m2
- mova [r0+r3*2], m3
- mova [r0+r1*1], m5
- RET
-%endmacro
-
-INIT_XMM sse2
-PRED8x8L_HORIZONTAL_UP
-INIT_XMM ssse3
-PRED8x8L_HORIZONTAL_UP
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-PRED8x8L_HORIZONTAL_UP
-%endif
-
-
-;-----------------------------------------------------------------------------
-; void pred16x16_vertical(pixel *src, int stride)
-;-----------------------------------------------------------------------------
-%macro MOV16 3-5
- mova [%1+ 0], %2
- mova [%1+mmsize], %3
-%if mmsize==8
- mova [%1+ 16], %4
- mova [%1+ 24], %5
-%endif
-%endmacro
-
-%macro PRED16x16_VERTICAL 0
-cglobal pred16x16_vertical_10, 2, 3
- sub r0, r1
- mov r2d, 8
- mova m0, [r0+ 0]
- mova m1, [r0+mmsize]
-%if mmsize==8
- mova m2, [r0+16]
- mova m3, [r0+24]
-%endif
-.loop:
- MOV16 r0+r1*1, m0, m1, m2, m3
- MOV16 r0+r1*2, m0, m1, m2, m3
- lea r0, [r0+r1*2]
- dec r2d
- jg .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-PRED16x16_VERTICAL
-INIT_XMM sse2
-PRED16x16_VERTICAL
-
-;-----------------------------------------------------------------------------
-; void pred16x16_horizontal(pixel *src, int stride)
-;-----------------------------------------------------------------------------
-%macro PRED16x16_HORIZONTAL 0
-cglobal pred16x16_horizontal_10, 2, 3
- mov r2d, 8
-.vloop:
- movd m0, [r0+r1*0-4]
- movd m1, [r0+r1*1-4]
- SPLATW m0, m0, 1
- SPLATW m1, m1, 1
- MOV16 r0+r1*0, m0, m0, m0, m0
- MOV16 r0+r1*1, m1, m1, m1, m1
- lea r0, [r0+r1*2]
- dec r2d
- jg .vloop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-PRED16x16_HORIZONTAL
-INIT_XMM sse2
-PRED16x16_HORIZONTAL
-
-;-----------------------------------------------------------------------------
-; void pred16x16_dc(pixel *src, int stride)
-;-----------------------------------------------------------------------------
-%macro PRED16x16_DC 0
-cglobal pred16x16_dc_10, 2, 6
- mov r5, r0
- sub r0, r1
- mova m0, [r0+0]
- paddw m0, [r0+mmsize]
-%if mmsize==8
- paddw m0, [r0+16]
- paddw m0, [r0+24]
-%endif
- HADDW m0, m2
-
- lea r0, [r0+r1-2]
- movzx r3d, word [r0]
- movzx r4d, word [r0+r1]
-%rep 7
- lea r0, [r0+r1*2]
- movzx r2d, word [r0]
- add r3d, r2d
- movzx r2d, word [r0+r1]
- add r4d, r2d
-%endrep
- lea r3d, [r3+r4+16]
-
- movd m1, r3d
- paddw m0, m1
- psrlw m0, 5
- SPLATW m0, m0
- mov r3d, 8
-.loop:
- MOV16 r5+r1*0, m0, m0, m0, m0
- MOV16 r5+r1*1, m0, m0, m0, m0
- lea r5, [r5+r1*2]
- dec r3d
- jg .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-PRED16x16_DC
-INIT_XMM sse2
-PRED16x16_DC
-
-;-----------------------------------------------------------------------------
-; void pred16x16_top_dc(pixel *src, int stride)
-;-----------------------------------------------------------------------------
-%macro PRED16x16_TOP_DC 0
-cglobal pred16x16_top_dc_10, 2, 3
- sub r0, r1
- mova m0, [r0+0]
- paddw m0, [r0+mmsize]
-%if mmsize==8
- paddw m0, [r0+16]
- paddw m0, [r0+24]
-%endif
- HADDW m0, m2
-
- SPLATW m0, m0
- paddw m0, [pw_8]
- psrlw m0, 4
- mov r2d, 8
-.loop:
- MOV16 r0+r1*1, m0, m0, m0, m0
- MOV16 r0+r1*2, m0, m0, m0, m0
- lea r0, [r0+r1*2]
- dec r2d
- jg .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-PRED16x16_TOP_DC
-INIT_XMM sse2
-PRED16x16_TOP_DC
-
-;-----------------------------------------------------------------------------
-; void pred16x16_left_dc(pixel *src, int stride)
-;-----------------------------------------------------------------------------
-%macro PRED16x16_LEFT_DC 0
-cglobal pred16x16_left_dc_10, 2, 6
- mov r5, r0
-
- sub r0, 2
- movzx r3d, word [r0]
- movzx r4d, word [r0+r1]
-%rep 7
- lea r0, [r0+r1*2]
- movzx r2d, word [r0]
- add r3d, r2d
- movzx r2d, word [r0+r1]
- add r4d, r2d
-%endrep
- lea r3d, [r3+r4+8]
- shr r3d, 4
-
- movd m0, r3d
- SPLATW m0, m0
- mov r3d, 8
-.loop:
- MOV16 r5+r1*0, m0, m0, m0, m0
- MOV16 r5+r1*1, m0, m0, m0, m0
- lea r5, [r5+r1*2]
- dec r3d
- jg .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-PRED16x16_LEFT_DC
-INIT_XMM sse2
-PRED16x16_LEFT_DC
-
-;-----------------------------------------------------------------------------
-; void pred16x16_128_dc(pixel *src, int stride)
-;-----------------------------------------------------------------------------
-%macro PRED16x16_128_DC 0
-cglobal pred16x16_128_dc_10, 2,3
- mova m0, [pw_512]
- mov r2d, 8
-.loop:
- MOV16 r0+r1*0, m0, m0, m0, m0
- MOV16 r0+r1*1, m0, m0, m0, m0
- lea r0, [r0+r1*2]
- dec r2d
- jg .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-PRED16x16_128_DC
-INIT_XMM sse2
-PRED16x16_128_DC
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/h264_intrapred_init.c b/src/thirdparty/ffmpeg/libavcodec/x86/h264_intrapred_init.c
deleted file mode 100644
index abee293c8..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/h264_intrapred_init.c
+++ /dev/null
@@ -1,402 +0,0 @@
-/*
- * Copyright (c) 2010 Jason Garrett-Glaser
- *
- * 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/avcodec.h"
-#include "libavcodec/h264pred.h"
-
-#define PRED4x4(TYPE, DEPTH, OPT) \
-void ff_pred4x4_ ## TYPE ## _ ## DEPTH ## _ ## OPT (uint8_t *src, \
- const uint8_t *topright, \
- ptrdiff_t stride);
-
-PRED4x4(dc, 10, mmxext)
-PRED4x4(down_left, 10, sse2)
-PRED4x4(down_left, 10, avx)
-PRED4x4(down_right, 10, sse2)
-PRED4x4(down_right, 10, ssse3)
-PRED4x4(down_right, 10, avx)
-PRED4x4(vertical_left, 10, sse2)
-PRED4x4(vertical_left, 10, avx)
-PRED4x4(vertical_right, 10, sse2)
-PRED4x4(vertical_right, 10, ssse3)
-PRED4x4(vertical_right, 10, avx)
-PRED4x4(horizontal_up, 10, mmxext)
-PRED4x4(horizontal_down, 10, sse2)
-PRED4x4(horizontal_down, 10, ssse3)
-PRED4x4(horizontal_down, 10, avx)
-
-#define PRED8x8(TYPE, DEPTH, OPT) \
-void ff_pred8x8_ ## TYPE ## _ ## DEPTH ## _ ## OPT (uint8_t *src, \
- ptrdiff_t stride);
-
-PRED8x8(dc, 10, mmxext)
-PRED8x8(dc, 10, sse2)
-PRED8x8(top_dc, 10, sse2)
-PRED8x8(plane, 10, sse2)
-PRED8x8(vertical, 10, sse2)
-PRED8x8(horizontal, 10, sse2)
-
-#define PRED8x8L(TYPE, DEPTH, OPT)\
-void ff_pred8x8l_ ## TYPE ## _ ## DEPTH ## _ ## OPT (uint8_t *src, \
- int has_topleft, \
- int has_topright, \
- ptrdiff_t stride);
-
-PRED8x8L(dc, 10, sse2)
-PRED8x8L(dc, 10, avx)
-PRED8x8L(128_dc, 10, mmxext)
-PRED8x8L(128_dc, 10, sse2)
-PRED8x8L(top_dc, 10, sse2)
-PRED8x8L(top_dc, 10, avx)
-PRED8x8L(vertical, 10, sse2)
-PRED8x8L(vertical, 10, avx)
-PRED8x8L(horizontal, 10, sse2)
-PRED8x8L(horizontal, 10, ssse3)
-PRED8x8L(horizontal, 10, avx)
-PRED8x8L(down_left, 10, sse2)
-PRED8x8L(down_left, 10, ssse3)
-PRED8x8L(down_left, 10, avx)
-PRED8x8L(down_right, 10, sse2)
-PRED8x8L(down_right, 10, ssse3)
-PRED8x8L(down_right, 10, avx)
-PRED8x8L(vertical_right, 10, sse2)
-PRED8x8L(vertical_right, 10, ssse3)
-PRED8x8L(vertical_right, 10, avx)
-PRED8x8L(horizontal_up, 10, sse2)
-PRED8x8L(horizontal_up, 10, ssse3)
-PRED8x8L(horizontal_up, 10, avx)
-
-#define PRED16x16(TYPE, DEPTH, OPT)\
-void ff_pred16x16_ ## TYPE ## _ ## DEPTH ## _ ## OPT (uint8_t *src, \
- ptrdiff_t stride);
-
-PRED16x16(dc, 10, mmxext)
-PRED16x16(dc, 10, sse2)
-PRED16x16(top_dc, 10, mmxext)
-PRED16x16(top_dc, 10, sse2)
-PRED16x16(128_dc, 10, mmxext)
-PRED16x16(128_dc, 10, sse2)
-PRED16x16(left_dc, 10, mmxext)
-PRED16x16(left_dc, 10, sse2)
-PRED16x16(vertical, 10, mmxext)
-PRED16x16(vertical, 10, sse2)
-PRED16x16(horizontal, 10, mmxext)
-PRED16x16(horizontal, 10, sse2)
-
-/* 8-bit versions */
-PRED16x16(vertical, 8, mmx)
-PRED16x16(vertical, 8, sse)
-PRED16x16(horizontal, 8, mmx)
-PRED16x16(horizontal, 8, mmxext)
-PRED16x16(horizontal, 8, ssse3)
-PRED16x16(dc, 8, mmxext)
-PRED16x16(dc, 8, sse2)
-PRED16x16(dc, 8, ssse3)
-PRED16x16(plane_h264, 8, mmx)
-PRED16x16(plane_h264, 8, mmxext)
-PRED16x16(plane_h264, 8, sse2)
-PRED16x16(plane_h264, 8, ssse3)
-PRED16x16(plane_rv40, 8, mmx)
-PRED16x16(plane_rv40, 8, mmxext)
-PRED16x16(plane_rv40, 8, sse2)
-PRED16x16(plane_rv40, 8, ssse3)
-PRED16x16(plane_svq3, 8, mmx)
-PRED16x16(plane_svq3, 8, mmxext)
-PRED16x16(plane_svq3, 8, sse2)
-PRED16x16(plane_svq3, 8, ssse3)
-PRED16x16(tm_vp8, 8, mmx)
-PRED16x16(tm_vp8, 8, mmxext)
-PRED16x16(tm_vp8, 8, sse2)
-
-PRED8x8(top_dc, 8, mmxext)
-PRED8x8(dc_rv40, 8, mmxext)
-PRED8x8(dc, 8, mmxext)
-PRED8x8(vertical, 8, mmx)
-PRED8x8(horizontal, 8, mmx)
-PRED8x8(horizontal, 8, mmxext)
-PRED8x8(horizontal, 8, ssse3)
-PRED8x8(plane, 8, mmx)
-PRED8x8(plane, 8, mmxext)
-PRED8x8(plane, 8, sse2)
-PRED8x8(plane, 8, ssse3)
-PRED8x8(tm_vp8, 8, mmx)
-PRED8x8(tm_vp8, 8, mmxext)
-PRED8x8(tm_vp8, 8, sse2)
-PRED8x8(tm_vp8, 8, ssse3)
-
-PRED8x8L(top_dc, 8, mmxext)
-PRED8x8L(top_dc, 8, ssse3)
-PRED8x8L(dc, 8, mmxext)
-PRED8x8L(dc, 8, ssse3)
-PRED8x8L(horizontal, 8, mmxext)
-PRED8x8L(horizontal, 8, ssse3)
-PRED8x8L(vertical, 8, mmxext)
-PRED8x8L(vertical, 8, ssse3)
-PRED8x8L(down_left, 8, mmxext)
-PRED8x8L(down_left, 8, sse2)
-PRED8x8L(down_left, 8, ssse3)
-PRED8x8L(down_right, 8, mmxext)
-PRED8x8L(down_right, 8, sse2)
-PRED8x8L(down_right, 8, ssse3)
-PRED8x8L(vertical_right, 8, mmxext)
-PRED8x8L(vertical_right, 8, sse2)
-PRED8x8L(vertical_right, 8, ssse3)
-PRED8x8L(vertical_left, 8, sse2)
-PRED8x8L(vertical_left, 8, ssse3)
-PRED8x8L(horizontal_up, 8, mmxext)
-PRED8x8L(horizontal_up, 8, ssse3)
-PRED8x8L(horizontal_down, 8, mmxext)
-PRED8x8L(horizontal_down, 8, sse2)
-PRED8x8L(horizontal_down, 8, ssse3)
-
-PRED4x4(dc, 8, mmxext)
-PRED4x4(down_left, 8, mmxext)
-PRED4x4(down_right, 8, mmxext)
-PRED4x4(vertical_left, 8, mmxext)
-PRED4x4(vertical_right, 8, mmxext)
-PRED4x4(horizontal_up, 8, mmxext)
-PRED4x4(horizontal_down, 8, mmxext)
-PRED4x4(tm_vp8, 8, mmx)
-PRED4x4(tm_vp8, 8, mmxext)
-PRED4x4(tm_vp8, 8, ssse3)
-PRED4x4(vertical_vp8, 8, mmxext)
-
-av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
- const int bit_depth,
- const int chroma_format_idc)
-{
- int mm_flags = av_get_cpu_flags();
-
- if (bit_depth == 8) {
- if (EXTERNAL_MMX(mm_flags)) {
- h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_8_mmx;
- h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_8_mmx;
- 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) {
- 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)
- h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_8_mmx;
- if (codec_id == AV_CODEC_ID_SVQ3) {
- if (mm_flags & AV_CPU_FLAG_CMOV)
- h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_8_mmx;
- } else if (codec_id == AV_CODEC_ID_RV40) {
- h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_8_mmx;
- } else {
- h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_8_mmx;
- }
- }
- }
-
- if (EXTERNAL_MMXEXT(mm_flags)) {
- h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_8_mmxext;
- h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_8_mmxext;
- 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;
- h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_8_mmxext;
- h->pred8x8l [VERT_PRED ] = ff_pred8x8l_vertical_8_mmxext;
- h->pred8x8l [DIAG_DOWN_RIGHT_PRED ] = ff_pred8x8l_down_right_8_mmxext;
- h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_8_mmxext;
- h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_8_mmxext;
- h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_8_mmxext;
- h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_8_mmxext;
- h->pred4x4 [DIAG_DOWN_RIGHT_PRED ] = ff_pred4x4_down_right_8_mmxext;
- 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) {
- 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) {
- h->pred4x4 [VERT_LEFT_PRED ] = ff_pred4x4_vertical_left_8_mmxext;
- }
- if (codec_id != AV_CODEC_ID_RV40) {
- 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) {
- 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) {
- 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)
- 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;
- } else if (codec_id == AV_CODEC_ID_RV40) {
- h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_rv40_8_mmxext;
- } else {
- h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_h264_8_mmxext;
- }
- }
- }
-
- if (EXTERNAL_SSE(mm_flags)) {
- h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_8_sse;
- }
-
- if (EXTERNAL_SSE2(mm_flags)) {
- h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_8_sse2;
- h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_8_sse2;
- h->pred8x8l [DIAG_DOWN_RIGHT_PRED ] = ff_pred8x8l_down_right_8_sse2;
- 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) {
- 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)
- 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;
- } else if (codec_id == AV_CODEC_ID_RV40) {
- h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_8_sse2;
- } else {
- h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_8_sse2;
- }
- }
- }
-
- if (EXTERNAL_SSSE3(mm_flags)) {
- h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_8_ssse3;
- h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_8_ssse3;
- 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;
- h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_8_ssse3;
- h->pred8x8l [VERT_PRED ] = ff_pred8x8l_vertical_8_ssse3;
- h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_8_ssse3;
- h->pred8x8l [DIAG_DOWN_RIGHT_PRED ] = ff_pred8x8l_down_right_8_ssse3;
- h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_8_ssse3;
- 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) {
- 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)
- 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;
- } else if (codec_id == AV_CODEC_ID_RV40) {
- h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_8_ssse3;
- } else {
- h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_8_ssse3;
- }
- }
- }
- } else if (bit_depth == 10) {
- if (EXTERNAL_MMXEXT(mm_flags)) {
- 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)
- h->pred8x8[DC_PRED8x8 ] = ff_pred8x8_dc_10_mmxext;
-
- h->pred8x8l[DC_128_PRED ] = ff_pred8x8l_128_dc_10_mmxext;
-
- h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_10_mmxext;
- h->pred16x16[TOP_DC_PRED8x8 ] = ff_pred16x16_top_dc_10_mmxext;
- h->pred16x16[DC_128_PRED8x8 ] = ff_pred16x16_128_dc_10_mmxext;
- h->pred16x16[LEFT_DC_PRED8x8 ] = ff_pred16x16_left_dc_10_mmxext;
- h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_10_mmxext;
- h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_10_mmxext;
- }
- if (EXTERNAL_SSE2(mm_flags)) {
- h->pred4x4[DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_10_sse2;
- h->pred4x4[DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_10_sse2;
- h->pred4x4[VERT_LEFT_PRED ] = ff_pred4x4_vertical_left_10_sse2;
- 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) {
- 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;
- h->pred8x8[VERT_PRED8x8 ] = ff_pred8x8_vertical_10_sse2;
- h->pred8x8[HOR_PRED8x8 ] = ff_pred8x8_horizontal_10_sse2;
- }
-
- h->pred8x8l[VERT_PRED ] = ff_pred8x8l_vertical_10_sse2;
- h->pred8x8l[HOR_PRED ] = ff_pred8x8l_horizontal_10_sse2;
- h->pred8x8l[DC_PRED ] = ff_pred8x8l_dc_10_sse2;
- h->pred8x8l[DC_128_PRED ] = ff_pred8x8l_128_dc_10_sse2;
- h->pred8x8l[TOP_DC_PRED ] = ff_pred8x8l_top_dc_10_sse2;
- h->pred8x8l[DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_10_sse2;
- h->pred8x8l[DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_10_sse2;
- h->pred8x8l[VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_10_sse2;
- h->pred8x8l[HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_10_sse2;
-
- h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_10_sse2;
- h->pred16x16[TOP_DC_PRED8x8 ] = ff_pred16x16_top_dc_10_sse2;
- h->pred16x16[DC_128_PRED8x8 ] = ff_pred16x16_128_dc_10_sse2;
- h->pred16x16[LEFT_DC_PRED8x8 ] = ff_pred16x16_left_dc_10_sse2;
- h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_10_sse2;
- h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_10_sse2;
- }
- if (EXTERNAL_SSSE3(mm_flags)) {
- h->pred4x4[DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_10_ssse3;
- h->pred4x4[VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_10_ssse3;
- h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_ssse3;
-
- h->pred8x8l[HOR_PRED ] = ff_pred8x8l_horizontal_10_ssse3;
- h->pred8x8l[DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_10_ssse3;
- h->pred8x8l[DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_10_ssse3;
- h->pred8x8l[VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_10_ssse3;
- h->pred8x8l[HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_10_ssse3;
- }
- if (EXTERNAL_AVX(mm_flags)) {
- h->pred4x4[DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_10_avx;
- h->pred4x4[DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_10_avx;
- h->pred4x4[VERT_LEFT_PRED ] = ff_pred4x4_vertical_left_10_avx;
- h->pred4x4[VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_10_avx;
- h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_avx;
-
- h->pred8x8l[VERT_PRED ] = ff_pred8x8l_vertical_10_avx;
- h->pred8x8l[HOR_PRED ] = ff_pred8x8l_horizontal_10_avx;
- h->pred8x8l[DC_PRED ] = ff_pred8x8l_dc_10_avx;
- h->pred8x8l[TOP_DC_PRED ] = ff_pred8x8l_top_dc_10_avx;
- h->pred8x8l[DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_10_avx;
- h->pred8x8l[DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_10_avx;
- h->pred8x8l[VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_10_avx;
- h->pred8x8l[HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_10_avx;
- }
- }
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/h264_qpel.c b/src/thirdparty/ffmpeg/libavcodec/x86/h264_qpel.c
deleted file mode 100644
index 382e509e0..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/h264_qpel.c
+++ /dev/null
@@ -1,626 +0,0 @@
-/*
- * Copyright (c) 2004-2005 Michael Niedermayer, Loren Merritt
- * Copyright (c) 2011 Daniel Kang
- *
- * 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/asm.h"
-#include "libavutil/x86/cpu.h"
-#include "libavcodec/dsputil.h"
-#include "libavcodec/h264qpel.h"
-#include "libavcodec/mpegvideo.h"
-#include "dsputil_mmx.h"
-
-#if HAVE_YASM
-void ff_put_pixels4_mmxext(uint8_t *block, const uint8_t *pixels, int line_size, int h);
-void ff_avg_pixels4_mmxext(uint8_t *block, const uint8_t *pixels, int line_size, int h);
-void ff_put_pixels8_mmxext(uint8_t *block, const uint8_t *pixels, int line_size, int h);
-void ff_avg_pixels8_mmxext(uint8_t *block, const uint8_t *pixels, int line_size, int h);
-static void ff_put_pixels16_mmxext(uint8_t *block, const uint8_t *pixels,
- int line_size, int h)
-{
- ff_put_pixels8_mmxext(block, pixels, line_size, h);
- ff_put_pixels8_mmxext(block + 8, pixels + 8, line_size, h);
-}
-static void ff_avg_pixels16_mmxext(uint8_t *block, const uint8_t *pixels,
- int line_size, int h)
-{
- ff_avg_pixels8_mmxext(block, pixels, line_size, h);
- ff_avg_pixels8_mmxext(block + 8, pixels + 8, line_size, h);
-}
-void ff_put_pixels4_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
- int dstStride, int src1Stride, int h);
-void ff_avg_pixels4_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
- int dstStride, int src1Stride, int h);
-void ff_put_pixels8_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
- int dstStride, int src1Stride, int h);
-void ff_avg_pixels8_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
- int dstStride, int src1Stride, int h);
-void ff_put_pixels16_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
- int dstStride, int src1Stride, int h);
-void ff_avg_pixels16_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
- int dstStride, int src1Stride, int h);
-void ff_put_pixels16_sse2(uint8_t *block, const uint8_t *pixels,
- int line_size, int h);
-void ff_avg_pixels16_sse2(uint8_t *block, const uint8_t *pixels,
- int line_size, int h);
-#define ff_put_pixels8_l2_sse2 ff_put_pixels8_l2_mmxext
-#define ff_avg_pixels8_l2_sse2 ff_avg_pixels8_l2_mmxext
-#define ff_put_pixels16_l2_sse2 ff_put_pixels16_l2_mmxext
-#define ff_avg_pixels16_l2_sse2 ff_avg_pixels16_l2_mmxext
-
-#define DEF_QPEL(OPNAME)\
-void ff_ ## OPNAME ## _h264_qpel4_h_lowpass_mmxext(uint8_t *dst, uint8_t *src, int dstStride, int srcStride);\
-void ff_ ## OPNAME ## _h264_qpel8_h_lowpass_mmxext(uint8_t *dst, uint8_t *src, int dstStride, int srcStride);\
-void ff_ ## OPNAME ## _h264_qpel8_h_lowpass_ssse3(uint8_t *dst, uint8_t *src, int dstStride, int srcStride);\
-void ff_ ## OPNAME ## _h264_qpel4_h_lowpass_l2_mmxext(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride);\
-void ff_ ## OPNAME ## _h264_qpel8_h_lowpass_l2_mmxext(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride);\
-void ff_ ## OPNAME ## _h264_qpel8_h_lowpass_l2_ssse3(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride);\
-void ff_ ## OPNAME ## _h264_qpel4_v_lowpass_mmxext(uint8_t *dst, uint8_t *src, int dstStride, int srcStride);\
-void ff_ ## OPNAME ## _h264_qpel8or16_v_lowpass_op_mmxext(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h);\
-void ff_ ## OPNAME ## _h264_qpel8or16_v_lowpass_sse2(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h);\
-void ff_ ## OPNAME ## _h264_qpel4_hv_lowpass_v_mmxext(uint8_t *src, int16_t *tmp, int srcStride);\
-void ff_ ## OPNAME ## _h264_qpel4_hv_lowpass_h_mmxext(int16_t *tmp, uint8_t *dst, int dstStride);\
-void ff_ ## OPNAME ## _h264_qpel8or16_hv1_lowpass_op_mmxext(uint8_t *src, int16_t *tmp, int srcStride, int size);\
-void ff_ ## OPNAME ## _h264_qpel8or16_hv1_lowpass_op_sse2(uint8_t *src, int16_t *tmp, int srcStride, int size);\
-void ff_ ## OPNAME ## _h264_qpel8or16_hv2_lowpass_op_mmxext(uint8_t *dst, int16_t *tmp, int dstStride, int unused, int h);\
-void ff_ ## OPNAME ## _h264_qpel8or16_hv2_lowpass_ssse3(uint8_t *dst, int16_t *tmp, int dstStride, int tmpStride, int size);\
-void ff_ ## OPNAME ## _pixels4_l2_shift5_mmxext(uint8_t *dst, int16_t *src16, uint8_t *src8, int dstStride, int src8Stride, int h);\
-void ff_ ## OPNAME ## _pixels8_l2_shift5_mmxext(uint8_t *dst, int16_t *src16, uint8_t *src8, int dstStride, int src8Stride, int h);
-
-DEF_QPEL(avg)
-DEF_QPEL(put)
-
-#define QPEL_H264(OPNAME, OP, MMX)\
-static av_always_inline void ff_ ## OPNAME ## h264_qpel4_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
- int w=3;\
- src -= 2*srcStride+2;\
- while(w--){\
- ff_ ## OPNAME ## h264_qpel4_hv_lowpass_v_mmxext(src, tmp, srcStride);\
- tmp += 4;\
- src += 4;\
- }\
- tmp -= 3*4;\
- ff_ ## OPNAME ## h264_qpel4_hv_lowpass_h_mmxext(tmp, dst, dstStride);\
-}\
-\
-static av_always_inline void ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
- src -= 2*srcStride;\
- ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_op_mmxext(dst, src, dstStride, srcStride, h);\
- src += 4;\
- dst += 4;\
- ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_op_mmxext(dst, src, dstStride, srcStride, h);\
-}\
-static av_always_inline void ff_ ## OPNAME ## h264_qpel8or16_hv1_lowpass_ ## MMX(int16_t *tmp, uint8_t *src, int tmpStride, int srcStride, int size){\
- int w = (size+8)>>2;\
- src -= 2*srcStride+2;\
- while(w--){\
- ff_ ## OPNAME ## h264_qpel8or16_hv1_lowpass_op_mmxext(src, tmp, srcStride, size);\
- tmp += 4;\
- src += 4;\
- }\
-}\
-static av_always_inline void ff_ ## OPNAME ## h264_qpel8or16_hv2_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, int dstStride, int tmpStride, int size){\
- int w = size>>4;\
- do{\
- ff_ ## OPNAME ## h264_qpel8or16_hv2_lowpass_op_mmxext(dst, tmp, dstStride, 0, size);\
- tmp += 8;\
- dst += 8;\
- }while(w--);\
-}\
-\
-static av_always_inline void ff_ ## OPNAME ## h264_qpel8_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
- ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 8);\
-}\
-static av_always_inline void ff_ ## OPNAME ## h264_qpel16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
- ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 16);\
- ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
-}\
-\
-static av_always_inline void ff_ ## OPNAME ## h264_qpel16_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
- ff_ ## OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\
- ff_ ## OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\
- src += 8*srcStride;\
- dst += 8*dstStride;\
- ff_ ## OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\
- ff_ ## OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\
-}\
-\
-static av_always_inline void ff_ ## OPNAME ## h264_qpel16_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\
- ff_ ## OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\
- ff_ ## OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\
- src += 8*dstStride;\
- dst += 8*dstStride;\
- src2 += 8*src2Stride;\
- ff_ ## OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\
- ff_ ## OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\
-}\
-\
-static av_always_inline void ff_ ## OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride, int size){\
- ff_put_h264_qpel8or16_hv1_lowpass_ ## MMX(tmp, src, tmpStride, srcStride, size);\
- ff_ ## OPNAME ## h264_qpel8or16_hv2_lowpass_ ## MMX(dst, tmp, dstStride, tmpStride, size);\
-}\
-static av_always_inline void ff_ ## OPNAME ## h264_qpel8_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
- ff_ ## OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst , tmp , src , dstStride, tmpStride, srcStride, 8);\
-}\
-\
-static av_always_inline void ff_ ## OPNAME ## h264_qpel16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
- ff_ ## OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst , tmp , src , dstStride, tmpStride, srcStride, 16);\
-}\
-\
-static av_always_inline void ff_ ## OPNAME ## pixels16_l2_shift5_ ## MMX(uint8_t *dst, int16_t *src16, uint8_t *src8, int dstStride, int src8Stride, int h)\
-{\
- ff_ ## OPNAME ## pixels8_l2_shift5_ ## MMX(dst , src16 , src8 , dstStride, src8Stride, h);\
- ff_ ## OPNAME ## pixels8_l2_shift5_ ## MMX(dst+8, src16+8, src8+8, dstStride, src8Stride, h);\
-}\
-
-
-#if ARCH_X86_64
-#define QPEL_H264_H16_XMM(OPNAME, OP, MMX)\
-
-void ff_avg_h264_qpel16_h_lowpass_l2_ssse3(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride);
-void ff_put_h264_qpel16_h_lowpass_l2_ssse3(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride);
-
-#else // ARCH_X86_64
-#define QPEL_H264_H16_XMM(OPNAME, OP, MMX)\
-static av_always_inline void ff_ ## OPNAME ## h264_qpel16_h_lowpass_l2_ ## MMX(uint8_t *dst, uint8_t *src, uint8_t *src2, int dstStride, int src2Stride){\
- ff_ ## OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\
- ff_ ## OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\
- src += 8*dstStride;\
- dst += 8*dstStride;\
- src2 += 8*src2Stride;\
- ff_ ## OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst , src , src2 , dstStride, src2Stride);\
- ff_ ## OPNAME ## h264_qpel8_h_lowpass_l2_ ## MMX(dst+8, src+8, src2+8, dstStride, src2Stride);\
-}
-#endif // ARCH_X86_64
-
-#define QPEL_H264_H_XMM(OPNAME, OP, MMX)\
-QPEL_H264_H16_XMM(OPNAME, OP, MMX)\
-static av_always_inline void ff_ ## OPNAME ## h264_qpel16_h_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
- ff_ ## OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\
- ff_ ## OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\
- src += 8*srcStride;\
- dst += 8*dstStride;\
- ff_ ## OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst , src , dstStride, srcStride);\
- ff_ ## OPNAME ## h264_qpel8_h_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride);\
-}\
-
-#define QPEL_H264_V_XMM(OPNAME, OP, MMX)\
-static av_always_inline void ff_ ## OPNAME ## h264_qpel8_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
- ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 8);\
-}\
-static av_always_inline void ff_ ## OPNAME ## h264_qpel16_v_lowpass_ ## MMX(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
- ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst , src , dstStride, srcStride, 16);\
- ff_ ## OPNAME ## h264_qpel8or16_v_lowpass_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
-}
-
-static av_always_inline void ff_put_h264_qpel8or16_hv1_lowpass_sse2(int16_t *tmp, uint8_t *src, int tmpStride, int srcStride, int size){
- int w = (size+8)>>3;
- src -= 2*srcStride+2;
- while(w--){
- ff_put_h264_qpel8or16_hv1_lowpass_op_sse2(src, tmp, srcStride, size);
- tmp += 8;
- src += 8;
- }
-}
-
-#define QPEL_H264_HV_XMM(OPNAME, OP, MMX)\
-static av_always_inline void ff_ ## OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride, int size){\
- ff_put_h264_qpel8or16_hv1_lowpass_sse2(tmp, src, tmpStride, srcStride, size);\
- ff_ ## OPNAME ## h264_qpel8or16_hv2_lowpass_ ## MMX(dst, tmp, dstStride, tmpStride, size);\
-}\
-static av_always_inline void ff_ ## OPNAME ## h264_qpel8_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
- ff_ ## OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst, tmp, src, dstStride, tmpStride, srcStride, 8);\
-}\
-static av_always_inline void ff_ ## OPNAME ## h264_qpel16_hv_lowpass_ ## MMX(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
- ff_ ## OPNAME ## h264_qpel8or16_hv_lowpass_ ## MMX(dst, tmp, src, dstStride, tmpStride, srcStride, 16);\
-}\
-
-#define ff_put_h264_qpel8_h_lowpass_l2_sse2 ff_put_h264_qpel8_h_lowpass_l2_mmxext
-#define ff_avg_h264_qpel8_h_lowpass_l2_sse2 ff_avg_h264_qpel8_h_lowpass_l2_mmxext
-#define ff_put_h264_qpel16_h_lowpass_l2_sse2 ff_put_h264_qpel16_h_lowpass_l2_mmxext
-#define ff_avg_h264_qpel16_h_lowpass_l2_sse2 ff_avg_h264_qpel16_h_lowpass_l2_mmxext
-
-#define ff_put_h264_qpel8_v_lowpass_ssse3 ff_put_h264_qpel8_v_lowpass_sse2
-#define ff_avg_h264_qpel8_v_lowpass_ssse3 ff_avg_h264_qpel8_v_lowpass_sse2
-#define ff_put_h264_qpel16_v_lowpass_ssse3 ff_put_h264_qpel16_v_lowpass_sse2
-#define ff_avg_h264_qpel16_v_lowpass_ssse3 ff_avg_h264_qpel16_v_lowpass_sse2
-
-#define ff_put_h264_qpel8or16_hv2_lowpass_sse2 ff_put_h264_qpel8or16_hv2_lowpass_mmxext
-#define ff_avg_h264_qpel8or16_hv2_lowpass_sse2 ff_avg_h264_qpel8or16_hv2_lowpass_mmxext
-
-#define H264_MC(OPNAME, SIZE, MMX, ALIGN) \
-H264_MC_C(OPNAME, SIZE, MMX, ALIGN)\
-H264_MC_V(OPNAME, SIZE, MMX, ALIGN)\
-H264_MC_H(OPNAME, SIZE, MMX, ALIGN)\
-H264_MC_HV(OPNAME, SIZE, MMX, ALIGN)\
-
-static void put_h264_qpel16_mc00_sse2 (uint8_t *dst, uint8_t *src, int stride){
- ff_put_pixels16_sse2(dst, src, stride, 16);
-}
-static void avg_h264_qpel16_mc00_sse2 (uint8_t *dst, uint8_t *src, int stride){
- ff_avg_pixels16_sse2(dst, src, stride, 16);
-}
-#define put_h264_qpel8_mc00_sse2 put_h264_qpel8_mc00_mmxext
-#define avg_h264_qpel8_mc00_sse2 avg_h264_qpel8_mc00_mmxext
-
-#define H264_MC_C(OPNAME, SIZE, MMX, ALIGN) \
-static void OPNAME ## h264_qpel ## SIZE ## _mc00_ ## MMX (uint8_t *dst, uint8_t *src, int stride){\
- ff_ ## OPNAME ## pixels ## SIZE ## _ ## MMX(dst, src, stride, SIZE);\
-}\
-
-#define H264_MC_H(OPNAME, SIZE, MMX, ALIGN) \
-static void OPNAME ## h264_qpel ## SIZE ## _mc10_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, src, stride, stride);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc20_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_ ## MMX(dst, src, stride, stride);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc30_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, src+1, stride, stride);\
-}\
-
-#define H264_MC_V(OPNAME, SIZE, MMX, ALIGN) \
-static void OPNAME ## h264_qpel ## SIZE ## _mc01_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\
- ff_put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src, SIZE, stride);\
- ff_ ## OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, src, temp, stride, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc02_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- ff_ ## OPNAME ## h264_qpel ## SIZE ## _v_lowpass_ ## MMX(dst, src, stride, stride);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc03_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\
- ff_put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src, SIZE, stride);\
- ff_ ## OPNAME ## pixels ## SIZE ## _l2_ ## MMX(dst, src+stride, temp, stride, stride, SIZE);\
-}\
-
-#define H264_MC_HV(OPNAME, SIZE, MMX, ALIGN) \
-static void OPNAME ## h264_qpel ## SIZE ## _mc11_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\
- ff_put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src, SIZE, stride);\
- ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, temp, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc31_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\
- ff_put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src+1, SIZE, stride);\
- ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, temp, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc13_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\
- ff_put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src, SIZE, stride);\
- ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src+stride, temp, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc33_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*SIZE];\
- ff_put_h264_qpel ## SIZE ## _v_lowpass_ ## MMX(temp, src+1, SIZE, stride);\
- ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src+stride, temp, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc22_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- DECLARE_ALIGNED(ALIGN, uint16_t, temp)[SIZE*(SIZE<8?12:24)];\
- ff_ ## OPNAME ## h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(dst, temp, src, stride, SIZE, stride);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc21_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*(SIZE<8?12:24)*2 + SIZE*SIZE];\
- uint8_t * const halfHV= temp;\
- int16_t * const halfV= (int16_t*)(temp + SIZE*SIZE);\
- assert(((int)temp & 7) == 0);\
- ff_put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\
- ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src, halfHV, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc23_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*(SIZE<8?12:24)*2 + SIZE*SIZE];\
- uint8_t * const halfHV= temp;\
- int16_t * const halfV= (int16_t*)(temp + SIZE*SIZE);\
- assert(((int)temp & 7) == 0);\
- ff_put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\
- ff_ ## OPNAME ## h264_qpel ## SIZE ## _h_lowpass_l2_ ## MMX(dst, src+stride, halfHV, stride, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc12_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*(SIZE<8?12:24)*2 + SIZE*SIZE];\
- uint8_t * const halfHV= temp;\
- int16_t * const halfV= (int16_t*)(temp + SIZE*SIZE);\
- assert(((int)temp & 7) == 0);\
- ff_put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\
- ff_ ## OPNAME ## pixels ## SIZE ## _l2_shift5_mmxext(dst, halfV+2, halfHV, stride, SIZE, SIZE);\
-}\
-\
-static void OPNAME ## h264_qpel ## SIZE ## _mc32_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- DECLARE_ALIGNED(ALIGN, uint8_t, temp)[SIZE*(SIZE<8?12:24)*2 + SIZE*SIZE];\
- uint8_t * const halfHV= temp;\
- int16_t * const halfV= (int16_t*)(temp + SIZE*SIZE);\
- assert(((int)temp & 7) == 0);\
- ff_put_h264_qpel ## SIZE ## _hv_lowpass_ ## MMX(halfHV, halfV, src, SIZE, SIZE, stride);\
- ff_ ## OPNAME ## pixels ## SIZE ## _l2_shift5_mmxext(dst, halfV+3, halfHV, stride, SIZE, SIZE);\
-}\
-
-#define H264_MC_4816(MMX)\
-H264_MC(put_, 4, MMX, 8)\
-H264_MC(put_, 8, MMX, 8)\
-H264_MC(put_, 16,MMX, 8)\
-H264_MC(avg_, 4, MMX, 8)\
-H264_MC(avg_, 8, MMX, 8)\
-H264_MC(avg_, 16,MMX, 8)\
-
-#define H264_MC_816(QPEL, XMM)\
-QPEL(put_, 8, XMM, 16)\
-QPEL(put_, 16,XMM, 16)\
-QPEL(avg_, 8, XMM, 16)\
-QPEL(avg_, 16,XMM, 16)\
-
-#undef PAVGB
-#define PAVGB "pavgb"
-QPEL_H264(put_, PUT_OP, mmxext)
-QPEL_H264(avg_, AVG_MMXEXT_OP, mmxext)
-QPEL_H264_V_XMM(put_, PUT_OP, sse2)
-QPEL_H264_V_XMM(avg_,AVG_MMXEXT_OP, sse2)
-QPEL_H264_HV_XMM(put_, PUT_OP, sse2)
-QPEL_H264_HV_XMM(avg_,AVG_MMXEXT_OP, sse2)
-QPEL_H264_H_XMM(put_, PUT_OP, ssse3)
-QPEL_H264_H_XMM(avg_,AVG_MMXEXT_OP, ssse3)
-QPEL_H264_HV_XMM(put_, PUT_OP, ssse3)
-QPEL_H264_HV_XMM(avg_,AVG_MMXEXT_OP, ssse3)
-#undef PAVGB
-
-H264_MC_4816(mmxext)
-H264_MC_816(H264_MC_V, sse2)
-H264_MC_816(H264_MC_HV, sse2)
-H264_MC_816(H264_MC_H, ssse3)
-H264_MC_816(H264_MC_HV, ssse3)
-
-
-//10bit
-#define LUMA_MC_OP(OP, NUM, DEPTH, TYPE, OPT) \
-void ff_ ## OP ## _h264_qpel ## NUM ## _ ## TYPE ## _ ## DEPTH ## _ ## OPT \
- (uint8_t *dst, uint8_t *src, int stride);
-
-#define LUMA_MC_ALL(DEPTH, TYPE, OPT) \
- LUMA_MC_OP(put, 4, DEPTH, TYPE, OPT) \
- LUMA_MC_OP(avg, 4, DEPTH, TYPE, OPT) \
- LUMA_MC_OP(put, 8, DEPTH, TYPE, OPT) \
- LUMA_MC_OP(avg, 8, DEPTH, TYPE, OPT) \
- LUMA_MC_OP(put, 16, DEPTH, TYPE, OPT) \
- LUMA_MC_OP(avg, 16, DEPTH, TYPE, OPT)
-
-#define LUMA_MC_816(DEPTH, TYPE, OPT) \
- LUMA_MC_OP(put, 8, DEPTH, TYPE, OPT) \
- LUMA_MC_OP(avg, 8, DEPTH, TYPE, OPT) \
- LUMA_MC_OP(put, 16, DEPTH, TYPE, OPT) \
- LUMA_MC_OP(avg, 16, DEPTH, TYPE, OPT)
-
-LUMA_MC_ALL(10, mc00, mmxext)
-LUMA_MC_ALL(10, mc10, mmxext)
-LUMA_MC_ALL(10, mc20, mmxext)
-LUMA_MC_ALL(10, mc30, mmxext)
-LUMA_MC_ALL(10, mc01, mmxext)
-LUMA_MC_ALL(10, mc11, mmxext)
-LUMA_MC_ALL(10, mc21, mmxext)
-LUMA_MC_ALL(10, mc31, mmxext)
-LUMA_MC_ALL(10, mc02, mmxext)
-LUMA_MC_ALL(10, mc12, mmxext)
-LUMA_MC_ALL(10, mc22, mmxext)
-LUMA_MC_ALL(10, mc32, mmxext)
-LUMA_MC_ALL(10, mc03, mmxext)
-LUMA_MC_ALL(10, mc13, mmxext)
-LUMA_MC_ALL(10, mc23, mmxext)
-LUMA_MC_ALL(10, mc33, mmxext)
-
-LUMA_MC_816(10, mc00, sse2)
-LUMA_MC_816(10, mc10, sse2)
-LUMA_MC_816(10, mc10, sse2_cache64)
-LUMA_MC_816(10, mc10, ssse3_cache64)
-LUMA_MC_816(10, mc20, sse2)
-LUMA_MC_816(10, mc20, sse2_cache64)
-LUMA_MC_816(10, mc20, ssse3_cache64)
-LUMA_MC_816(10, mc30, sse2)
-LUMA_MC_816(10, mc30, sse2_cache64)
-LUMA_MC_816(10, mc30, ssse3_cache64)
-LUMA_MC_816(10, mc01, sse2)
-LUMA_MC_816(10, mc11, sse2)
-LUMA_MC_816(10, mc21, sse2)
-LUMA_MC_816(10, mc31, sse2)
-LUMA_MC_816(10, mc02, sse2)
-LUMA_MC_816(10, mc12, sse2)
-LUMA_MC_816(10, mc22, sse2)
-LUMA_MC_816(10, mc32, sse2)
-LUMA_MC_816(10, mc03, sse2)
-LUMA_MC_816(10, mc13, sse2)
-LUMA_MC_816(10, mc23, sse2)
-LUMA_MC_816(10, mc33, sse2)
-
-#define QPEL16_OPMC(OP, MC, MMX)\
-void ff_ ## OP ## _h264_qpel16_ ## MC ## _10_ ## MMX(uint8_t *dst, uint8_t *src, int stride){\
- ff_ ## OP ## _h264_qpel8_ ## MC ## _10_ ## MMX(dst , src , stride);\
- ff_ ## OP ## _h264_qpel8_ ## MC ## _10_ ## MMX(dst+16, src+16, stride);\
- src += 8*stride;\
- dst += 8*stride;\
- ff_ ## OP ## _h264_qpel8_ ## MC ## _10_ ## MMX(dst , src , stride);\
- ff_ ## OP ## _h264_qpel8_ ## MC ## _10_ ## MMX(dst+16, src+16, stride);\
-}
-
-#define QPEL16_OP(MC, MMX)\
-QPEL16_OPMC(put, MC, MMX)\
-QPEL16_OPMC(avg, MC, MMX)
-
-#define QPEL16(MMX)\
-QPEL16_OP(mc00, MMX)\
-QPEL16_OP(mc01, MMX)\
-QPEL16_OP(mc02, MMX)\
-QPEL16_OP(mc03, MMX)\
-QPEL16_OP(mc10, MMX)\
-QPEL16_OP(mc11, MMX)\
-QPEL16_OP(mc12, MMX)\
-QPEL16_OP(mc13, MMX)\
-QPEL16_OP(mc20, MMX)\
-QPEL16_OP(mc21, MMX)\
-QPEL16_OP(mc22, MMX)\
-QPEL16_OP(mc23, MMX)\
-QPEL16_OP(mc30, MMX)\
-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+
-QPEL16(mmxext)
-#endif
-
-#endif /* HAVE_YASM */
-
-#define SET_QPEL_FUNCS(PFX, IDX, SIZE, CPU, PREFIX) \
- 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; \
- c->PFX ## _pixels_tab[IDX][ 3] = PREFIX ## PFX ## SIZE ## _mc30_ ## CPU; \
- c->PFX ## _pixels_tab[IDX][ 4] = PREFIX ## PFX ## SIZE ## _mc01_ ## CPU; \
- c->PFX ## _pixels_tab[IDX][ 5] = PREFIX ## PFX ## SIZE ## _mc11_ ## CPU; \
- c->PFX ## _pixels_tab[IDX][ 6] = PREFIX ## PFX ## SIZE ## _mc21_ ## CPU; \
- c->PFX ## _pixels_tab[IDX][ 7] = PREFIX ## PFX ## SIZE ## _mc31_ ## CPU; \
- c->PFX ## _pixels_tab[IDX][ 8] = PREFIX ## PFX ## SIZE ## _mc02_ ## CPU; \
- c->PFX ## _pixels_tab[IDX][ 9] = PREFIX ## PFX ## SIZE ## _mc12_ ## CPU; \
- c->PFX ## _pixels_tab[IDX][10] = PREFIX ## PFX ## SIZE ## _mc22_ ## CPU; \
- c->PFX ## _pixels_tab[IDX][11] = PREFIX ## PFX ## SIZE ## _mc32_ ## CPU; \
- c->PFX ## _pixels_tab[IDX][12] = PREFIX ## PFX ## SIZE ## _mc03_ ## CPU; \
- 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)
-
-#define H264_QPEL_FUNCS(x, y, CPU) \
- do { \
- c->put_h264_qpel_pixels_tab[0][x + y * 4] = put_h264_qpel16_mc ## x ## y ## _ ## CPU; \
- c->put_h264_qpel_pixels_tab[1][x + y * 4] = put_h264_qpel8_mc ## x ## y ## _ ## CPU; \
- c->avg_h264_qpel_pixels_tab[0][x + y * 4] = avg_h264_qpel16_mc ## x ## y ## _ ## CPU; \
- c->avg_h264_qpel_pixels_tab[1][x + y * 4] = avg_h264_qpel8_mc ## x ## y ## _ ## CPU; \
- } while (0)
-
-#define H264_QPEL_FUNCS_10(x, y, CPU) \
- do { \
- c->put_h264_qpel_pixels_tab[0][x + y * 4] = ff_put_h264_qpel16_mc ## x ## y ## _10_ ## CPU; \
- c->put_h264_qpel_pixels_tab[1][x + y * 4] = ff_put_h264_qpel8_mc ## x ## y ## _10_ ## CPU; \
- c->avg_h264_qpel_pixels_tab[0][x + y * 4] = ff_avg_h264_qpel16_mc ## x ## y ## _10_ ## CPU; \
- c->avg_h264_qpel_pixels_tab[1][x + y * 4] = ff_avg_h264_qpel8_mc ## x ## y ## _10_ ## CPU; \
- } while (0)
-
-av_cold void ff_h264qpel_init_x86(H264QpelContext *c, int bit_depth)
-{
-#if HAVE_YASM
- int high_bit_depth = bit_depth > 8;
- int mm_flags = av_get_cpu_flags();
-
- if (EXTERNAL_MMXEXT(mm_flags)) {
- if (!high_bit_depth) {
- SET_QPEL_FUNCS(put_h264_qpel, 0, 16, mmxext, );
- SET_QPEL_FUNCS(put_h264_qpel, 1, 8, mmxext, );
- SET_QPEL_FUNCS(put_h264_qpel, 2, 4, mmxext, );
- SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, mmxext, );
- SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, mmxext, );
- SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, mmxext, );
- } else if (bit_depth == 10) {
-#if ARCH_X86_32
- SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, 10_mmxext, ff_);
- SET_QPEL_FUNCS(put_h264_qpel, 0, 16, 10_mmxext, ff_);
- SET_QPEL_FUNCS(put_h264_qpel, 1, 8, 10_mmxext, ff_);
- SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, 10_mmxext, ff_);
-#endif
- SET_QPEL_FUNCS(put_h264_qpel, 2, 4, 10_mmxext, ff_);
- SET_QPEL_FUNCS(avg_h264_qpel, 2, 4, 10_mmxext, ff_);
- }
- }
-
- if (EXTERNAL_SSE2(mm_flags)) {
- if (!(mm_flags & AV_CPU_FLAG_SSE2SLOW) && !high_bit_depth) {
- // these functions are slower than mmx on AMD, but faster on Intel
- H264_QPEL_FUNCS(0, 0, sse2);
- }
-
- if (!high_bit_depth) {
- H264_QPEL_FUNCS(0, 1, sse2);
- H264_QPEL_FUNCS(0, 2, sse2);
- H264_QPEL_FUNCS(0, 3, sse2);
- H264_QPEL_FUNCS(1, 1, sse2);
- H264_QPEL_FUNCS(1, 2, sse2);
- H264_QPEL_FUNCS(1, 3, sse2);
- H264_QPEL_FUNCS(2, 1, sse2);
- H264_QPEL_FUNCS(2, 2, sse2);
- H264_QPEL_FUNCS(2, 3, sse2);
- H264_QPEL_FUNCS(3, 1, sse2);
- H264_QPEL_FUNCS(3, 2, sse2);
- H264_QPEL_FUNCS(3, 3, sse2);
- }
-
- if (bit_depth == 10) {
- SET_QPEL_FUNCS(put_h264_qpel, 0, 16, 10_sse2, ff_);
- SET_QPEL_FUNCS(put_h264_qpel, 1, 8, 10_sse2, ff_);
- SET_QPEL_FUNCS(avg_h264_qpel, 0, 16, 10_sse2, ff_);
- SET_QPEL_FUNCS(avg_h264_qpel, 1, 8, 10_sse2, ff_);
- H264_QPEL_FUNCS_10(1, 0, sse2_cache64);
- H264_QPEL_FUNCS_10(2, 0, sse2_cache64);
- H264_QPEL_FUNCS_10(3, 0, sse2_cache64);
- }
- }
-
- if (EXTERNAL_SSSE3(mm_flags)) {
- if (!high_bit_depth) {
- H264_QPEL_FUNCS(1, 0, ssse3);
- H264_QPEL_FUNCS(1, 1, ssse3);
- H264_QPEL_FUNCS(1, 2, ssse3);
- H264_QPEL_FUNCS(1, 3, ssse3);
- H264_QPEL_FUNCS(2, 0, ssse3);
- H264_QPEL_FUNCS(2, 1, ssse3);
- H264_QPEL_FUNCS(2, 2, ssse3);
- H264_QPEL_FUNCS(2, 3, ssse3);
- H264_QPEL_FUNCS(3, 0, ssse3);
- H264_QPEL_FUNCS(3, 1, ssse3);
- H264_QPEL_FUNCS(3, 2, ssse3);
- H264_QPEL_FUNCS(3, 3, ssse3);
- }
-
- if (bit_depth == 10) {
- H264_QPEL_FUNCS_10(1, 0, ssse3_cache64);
- H264_QPEL_FUNCS_10(2, 0, ssse3_cache64);
- H264_QPEL_FUNCS_10(3, 0, ssse3_cache64);
- }
- }
-
- if (EXTERNAL_AVX(mm_flags)) {
- /* AVX implies 64 byte cache lines without the need to avoid unaligned
- * memory accesses that cross the boundary between two cache lines.
- * TODO: Port X264_CPU_CACHELINE_32/64 detection from x264 to avoid
- * having to treat SSE2 functions with such properties as AVX. */
- if (bit_depth == 10) {
- H264_QPEL_FUNCS_10(1, 0, sse2);
- H264_QPEL_FUNCS_10(2, 0, sse2);
- H264_QPEL_FUNCS_10(3, 0, sse2);
- }
- }
-#endif
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/h264_qpel_10bit.asm b/src/thirdparty/ffmpeg/libavcodec/x86/h264_qpel_10bit.asm
deleted file mode 100644
index f88b9a37b..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/h264_qpel_10bit.asm
+++ /dev/null
@@ -1,884 +0,0 @@
-;*****************************************************************************
-;* MMX/SSE2/AVX-optimized 10-bit H.264 qpel code
-;*****************************************************************************
-;* Copyright (C) 2011 x264 project
-;*
-;* Authors: Daniel Kang <daniel.d.kang@gmail.com>
-;*
-;* This file is part of Libav.
-;*
-;* Libav is free software; you can redistribute it and/or
-;* modify it under the terms of the GNU Lesser General Public
-;* License as published by the Free Software Foundation; either
-;* version 2.1 of the License, or (at your option) any later version.
-;*
-;* Libav is distributed in the hope that it will be useful,
-;* but WITHOUT ANY WARRANTY; without even the implied warranty of
-;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-;* Lesser General Public License for more details.
-;*
-;* You should have received a copy of the GNU Lesser General Public
-;* License along with Libav; if not, write to the Free Software
-;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-;******************************************************************************
-
-%include "libavutil/x86/x86util.asm"
-
-SECTION_RODATA 32
-
-cextern pw_16
-cextern pw_1
-cextern pb_0
-
-pw_pixel_max: times 8 dw ((1 << 10)-1)
-
-pad10: times 8 dw 10*1023
-pad20: times 8 dw 20*1023
-pad30: times 8 dw 30*1023
-depad: times 4 dd 32*20*1023 + 512
-depad2: times 8 dw 20*1023 + 16*1022 + 16
-unpad: times 8 dw 16*1022/32 ; needs to be mod 16
-
-tap1: times 4 dw 1, -5
-tap2: times 4 dw 20, 20
-tap3: times 4 dw -5, 1
-pd_0f: times 4 dd 0xffff
-
-SECTION .text
-
-
-%macro AVG_MOV 2
- pavgw %2, %1
- mova %1, %2
-%endmacro
-
-%macro ADDW 3
-%if mmsize == 8
- paddw %1, %2
-%else
- movu %3, %2
- paddw %1, %3
-%endif
-%endmacro
-
-%macro FILT_H 4
- paddw %1, %4
- psubw %1, %2 ; a-b
- psraw %1, 2 ; (a-b)/4
- psubw %1, %2 ; (a-b)/4-b
- paddw %1, %3 ; (a-b)/4-b+c
- psraw %1, 2 ; ((a-b)/4-b+c)/4
- paddw %1, %3 ; ((a-b)/4-b+c)/4+c = (a-5*b+20*c)/16
-%endmacro
-
-%macro PRELOAD_V 0
- lea r3, [r2*3]
- sub r1, r3
- movu m0, [r1+r2]
- movu m1, [r1+r2*2]
- add r1, r3
- movu m2, [r1]
- movu m3, [r1+r2]
- movu m4, [r1+r2*2]
- add r1, r3
-%endmacro
-
-%macro FILT_V 8
- movu %6, [r1]
- paddw %1, %6
- mova %7, %2
- paddw %7, %5
- mova %8, %3
- paddw %8, %4
- FILT_H %1, %7, %8, [pw_16]
- psraw %1, 1
- CLIPW %1, [pb_0], [pw_pixel_max]
-%endmacro
-
-%macro MC 1
-%define OP_MOV mova
-INIT_MMX mmxext
-%1 put, 4
-INIT_XMM sse2
-%1 put, 8
-
-%define OP_MOV AVG_MOV
-INIT_MMX mmxext
-%1 avg, 4
-INIT_XMM sse2
-%1 avg, 8
-%endmacro
-
-%macro MCAxA_OP 7
-%if ARCH_X86_32
-cglobal %1_h264_qpel%4_%2_10, %5,%6,%7
- call stub_%1_h264_qpel%3_%2_10 %+ SUFFIX
- mov r0, r0m
- mov r1, r1m
- add r0, %3*2
- add r1, %3*2
- call stub_%1_h264_qpel%3_%2_10 %+ SUFFIX
- mov r0, r0m
- mov r1, r1m
- lea r0, [r0+r2*%3]
- lea r1, [r1+r2*%3]
- call stub_%1_h264_qpel%3_%2_10 %+ SUFFIX
- mov r0, r0m
- mov r1, r1m
- lea r0, [r0+r2*%3+%3*2]
- lea r1, [r1+r2*%3+%3*2]
- call stub_%1_h264_qpel%3_%2_10 %+ SUFFIX
- RET
-%else ; ARCH_X86_64
-cglobal %1_h264_qpel%4_%2_10, %5,%6 + 2,%7
- mov r%6, r0
-%assign p1 %6+1
- mov r %+ p1, r1
- call stub_%1_h264_qpel%3_%2_10 %+ SUFFIX
- lea r0, [r%6+%3*2]
- lea r1, [r %+ p1+%3*2]
- call stub_%1_h264_qpel%3_%2_10 %+ SUFFIX
- lea r0, [r%6+r2*%3]
- lea r1, [r %+ p1+r2*%3]
- call stub_%1_h264_qpel%3_%2_10 %+ SUFFIX
- lea r0, [r%6+r2*%3+%3*2]
- lea r1, [r %+ p1+r2*%3+%3*2]
-%if UNIX64 == 0 ; fall through to function
- call stub_%1_h264_qpel%3_%2_10 %+ SUFFIX
- RET
-%endif
-%endif
-%endmacro
-
-;cpu, put/avg, mc, 4/8, ...
-%macro cglobal_mc 6
-%assign i %3*2
-%if ARCH_X86_32 || cpuflag(sse2)
-MCAxA_OP %1, %2, %3, i, %4,%5,%6
-%endif
-
-cglobal %1_h264_qpel%3_%2_10, %4,%5,%6
-%if UNIX64 == 0 ; no prologue or epilogue for UNIX64
- call stub_%1_h264_qpel%3_%2_10 %+ SUFFIX
- RET
-%endif
-
-stub_%1_h264_qpel%3_%2_10 %+ SUFFIX:
-%endmacro
-
-;-----------------------------------------------------------------------------
-; void h264_qpel_mc00(uint8_t *dst, uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-%macro COPY4 0
- movu m0, [r1 ]
- OP_MOV [r0 ], m0
- movu m0, [r1+r2 ]
- OP_MOV [r0+r2 ], m0
- movu m0, [r1+r2*2]
- OP_MOV [r0+r2*2], m0
- movu m0, [r1+r3 ]
- OP_MOV [r0+r3 ], m0
-%endmacro
-
-%macro MC00 1
-INIT_MMX mmxext
-cglobal_mc %1, mc00, 4, 3,4,0
- lea r3, [r2*3]
- COPY4
- ret
-
-INIT_XMM sse2
-cglobal %1_h264_qpel8_mc00_10, 3,4
- lea r3, [r2*3]
- COPY4
- lea r0, [r0+r2*4]
- lea r1, [r1+r2*4]
- COPY4
- RET
-
-cglobal %1_h264_qpel16_mc00_10, 3,4
- mov r3d, 8
-.loop:
- movu m0, [r1 ]
- movu m1, [r1 +16]
- OP_MOV [r0 ], m0
- OP_MOV [r0 +16], m1
- movu m0, [r1+r2 ]
- movu m1, [r1+r2+16]
- OP_MOV [r0+r2 ], m0
- OP_MOV [r0+r2+16], m1
- lea r0, [r0+r2*2]
- lea r1, [r1+r2*2]
- dec r3d
- jg .loop
- REP_RET
-%endmacro
-
-%define OP_MOV mova
-MC00 put
-
-%define OP_MOV AVG_MOV
-MC00 avg
-
-;-----------------------------------------------------------------------------
-; void h264_qpel_mc20(uint8_t *dst, uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-%macro MC_CACHE 1
-%define OP_MOV mova
-INIT_MMX mmxext
-%1 put, 4
-INIT_XMM sse2, cache64
-%1 put, 8
-INIT_XMM ssse3, cache64
-%1 put, 8
-INIT_XMM sse2
-%1 put, 8
-
-%define OP_MOV AVG_MOV
-INIT_MMX mmxext
-%1 avg, 4
-INIT_XMM sse2, cache64
-%1 avg, 8
-INIT_XMM ssse3, cache64
-%1 avg, 8
-INIT_XMM sse2
-%1 avg, 8
-%endmacro
-
-%macro MC20 2
-cglobal_mc %1, mc20, %2, 3,4,9
- mov r3d, %2
- mova m1, [pw_pixel_max]
-%if num_mmregs > 8
- mova m8, [pw_16]
- %define p16 m8
-%else
- %define p16 [pw_16]
-%endif
-.nextrow:
-%if %0 == 4
- movu m2, [r1-4]
- movu m3, [r1-2]
- movu m4, [r1+0]
- ADDW m2, [r1+6], m5
- ADDW m3, [r1+4], m5
- ADDW m4, [r1+2], m5
-%else ; movu is slow on these processors
-%if mmsize==16
- movu m2, [r1-4]
- movu m0, [r1+6]
- mova m6, m0
- psrldq m0, 6
-
- paddw m6, m2
- PALIGNR m3, m0, m2, 2, m5
- PALIGNR m7, m0, m2, 8, m5
- paddw m3, m7
- PALIGNR m4, m0, m2, 4, m5
- PALIGNR m7, m0, m2, 6, m5
- paddw m4, m7
- SWAP 2, 6
-%else
- movu m2, [r1-4]
- movu m6, [r1+4]
- PALIGNR m3, m6, m2, 2, m5
- paddw m3, m6
- PALIGNR m4, m6, m2, 4, m5
- PALIGNR m7, m6, m2, 6, m5
- paddw m4, m7
- paddw m2, [r1+6]
-%endif
-%endif
-
- FILT_H m2, m3, m4, p16
- psraw m2, 1
- pxor m0, m0
- CLIPW m2, m0, m1
- OP_MOV [r0], m2
- add r0, r2
- add r1, r2
- dec r3d
- jg .nextrow
- rep ret
-%endmacro
-
-MC_CACHE MC20
-
-;-----------------------------------------------------------------------------
-; void h264_qpel_mc30(uint8_t *dst, uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-%macro MC30 2
-cglobal_mc %1, mc30, %2, 3,5,9
- lea r4, [r1+2]
- jmp stub_%1_h264_qpel%2_mc10_10 %+ SUFFIX %+ .body
-%endmacro
-
-MC_CACHE MC30
-
-;-----------------------------------------------------------------------------
-; void h264_qpel_mc10(uint8_t *dst, uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-%macro MC10 2
-cglobal_mc %1, mc10, %2, 3,5,9
- mov r4, r1
-.body:
- mov r3d, %2
- mova m1, [pw_pixel_max]
-%if num_mmregs > 8
- mova m8, [pw_16]
- %define p16 m8
-%else
- %define p16 [pw_16]
-%endif
-.nextrow:
-%if %0 == 4
- movu m2, [r1-4]
- movu m3, [r1-2]
- movu m4, [r1+0]
- ADDW m2, [r1+6], m5
- ADDW m3, [r1+4], m5
- ADDW m4, [r1+2], m5
-%else ; movu is slow on these processors
-%if mmsize==16
- movu m2, [r1-4]
- movu m0, [r1+6]
- mova m6, m0
- psrldq m0, 6
-
- paddw m6, m2
- PALIGNR m3, m0, m2, 2, m5
- PALIGNR m7, m0, m2, 8, m5
- paddw m3, m7
- PALIGNR m4, m0, m2, 4, m5
- PALIGNR m7, m0, m2, 6, m5
- paddw m4, m7
- SWAP 2, 6
-%else
- movu m2, [r1-4]
- movu m6, [r1+4]
- PALIGNR m3, m6, m2, 2, m5
- paddw m3, m6
- PALIGNR m4, m6, m2, 4, m5
- PALIGNR m7, m6, m2, 6, m5
- paddw m4, m7
- paddw m2, [r1+6]
-%endif
-%endif
-
- FILT_H m2, m3, m4, p16
- psraw m2, 1
- pxor m0, m0
- CLIPW m2, m0, m1
- movu m3, [r4]
- pavgw m2, m3
- OP_MOV [r0], m2
- add r0, r2
- add r1, r2
- add r4, r2
- dec r3d
- jg .nextrow
- rep ret
-%endmacro
-
-MC_CACHE MC10
-
-;-----------------------------------------------------------------------------
-; void h264_qpel_mc02(uint8_t *dst, uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-%macro V_FILT 10
-v_filt%9_%10_10
- add r4, r2
-.no_addr4:
- FILT_V m0, m1, m2, m3, m4, m5, m6, m7
- add r1, r2
- add r0, r2
- ret
-%endmacro
-
-INIT_MMX mmxext
-RESET_MM_PERMUTATION
-%assign i 0
-%rep 4
-V_FILT m0, m1, m2, m3, m4, m5, m6, m7, 4, i
-SWAP 0,1,2,3,4,5
-%assign i i+1
-%endrep
-
-INIT_XMM sse2
-RESET_MM_PERMUTATION
-%assign i 0
-%rep 6
-V_FILT m0, m1, m2, m3, m4, m5, m6, m7, 8, i
-SWAP 0,1,2,3,4,5
-%assign i i+1
-%endrep
-
-%macro MC02 2
-cglobal_mc %1, mc02, %2, 3,4,8
- PRELOAD_V
-
- sub r0, r2
-%assign j 0
-%rep %2
- %assign i (j % 6)
- call v_filt%2_ %+ i %+ _10.no_addr4
- OP_MOV [r0], m0
- SWAP 0,1,2,3,4,5
- %assign j j+1
-%endrep
- ret
-%endmacro
-
-MC MC02
-
-;-----------------------------------------------------------------------------
-; void h264_qpel_mc01(uint8_t *dst, uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-%macro MC01 2
-cglobal_mc %1, mc01, %2, 3,5,8
- mov r4, r1
-.body:
- PRELOAD_V
-
- sub r4, r2
- sub r0, r2
-%assign j 0
-%rep %2
- %assign i (j % 6)
- call v_filt%2_ %+ i %+ _10
- movu m7, [r4]
- pavgw m0, m7
- OP_MOV [r0], m0
- SWAP 0,1,2,3,4,5
- %assign j j+1
-%endrep
- ret
-%endmacro
-
-MC MC01
-
-;-----------------------------------------------------------------------------
-; void h264_qpel_mc03(uint8_t *dst, uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-%macro MC03 2
-cglobal_mc %1, mc03, %2, 3,5,8
- lea r4, [r1+r2]
- jmp stub_%1_h264_qpel%2_mc01_10 %+ SUFFIX %+ .body
-%endmacro
-
-MC MC03
-
-;-----------------------------------------------------------------------------
-; void h264_qpel_mc11(uint8_t *dst, uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-%macro H_FILT_AVG 2-3
-h_filt%1_%2_10:
-;FILT_H with fewer registers and averaged with the FILT_V result
-;m6,m7 are tmp registers, m0 is the FILT_V result, the rest are to be used next in the next iteration
-;unfortunately I need three registers, so m5 will have to be re-read from memory
- movu m5, [r4-4]
- ADDW m5, [r4+6], m7
- movu m6, [r4-2]
- ADDW m6, [r4+4], m7
- paddw m5, [pw_16]
- psubw m5, m6 ; a-b
- psraw m5, 2 ; (a-b)/4
- psubw m5, m6 ; (a-b)/4-b
- movu m6, [r4+0]
- ADDW m6, [r4+2], m7
- paddw m5, m6 ; (a-b)/4-b+c
- psraw m5, 2 ; ((a-b)/4-b+c)/4
- paddw m5, m6 ; ((a-b)/4-b+c)/4+c = (a-5*b+20*c)/16
- psraw m5, 1
- CLIPW m5, [pb_0], [pw_pixel_max]
-;avg FILT_V, FILT_H
- pavgw m0, m5
-%if %0!=4
- movu m5, [r1+r5]
-%endif
- ret
-%endmacro
-
-INIT_MMX mmxext
-RESET_MM_PERMUTATION
-%assign i 0
-%rep 3
-H_FILT_AVG 4, i
-SWAP 0,1,2,3,4,5
-%assign i i+1
-%endrep
-H_FILT_AVG 4, i, 0
-
-INIT_XMM sse2
-RESET_MM_PERMUTATION
-%assign i 0
-%rep 6
-%if i==1
-H_FILT_AVG 8, i, 0
-%else
-H_FILT_AVG 8, i
-%endif
-SWAP 0,1,2,3,4,5
-%assign i i+1
-%endrep
-
-%macro MC11 2
-; this REALLY needs x86_64
-cglobal_mc %1, mc11, %2, 3,6,8
- mov r4, r1
-.body:
- PRELOAD_V
-
- sub r0, r2
- sub r4, r2
- mov r5, r2
- neg r5
-%assign j 0
-%rep %2
- %assign i (j % 6)
- call v_filt%2_ %+ i %+ _10
- call h_filt%2_ %+ i %+ _10
-%if %2==8 && i==1
- movu m5, [r1+r5]
-%endif
- OP_MOV [r0], m0
- SWAP 0,1,2,3,4,5
- %assign j j+1
-%endrep
- ret
-%endmacro
-
-MC MC11
-
-;-----------------------------------------------------------------------------
-; void h264_qpel_mc31(uint8_t *dst, uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-%macro MC31 2
-cglobal_mc %1, mc31, %2, 3,6,8
- mov r4, r1
- add r1, 2
- jmp stub_%1_h264_qpel%2_mc11_10 %+ SUFFIX %+ .body
-%endmacro
-
-MC MC31
-
-;-----------------------------------------------------------------------------
-; void h264_qpel_mc13(uint8_t *dst, uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-%macro MC13 2
-cglobal_mc %1, mc13, %2, 3,7,12
- lea r4, [r1+r2]
- jmp stub_%1_h264_qpel%2_mc11_10 %+ SUFFIX %+ .body
-%endmacro
-
-MC MC13
-
-;-----------------------------------------------------------------------------
-; void h264_qpel_mc33(uint8_t *dst, uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-%macro MC33 2
-cglobal_mc %1, mc33, %2, 3,6,8
- lea r4, [r1+r2]
- add r1, 2
- jmp stub_%1_h264_qpel%2_mc11_10 %+ SUFFIX %+ .body
-%endmacro
-
-MC MC33
-
-;-----------------------------------------------------------------------------
-; void h264_qpel_mc22(uint8_t *dst, uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-%macro FILT_H2 3
- psubw %1, %2 ; a-b
- psubw %2, %3 ; b-c
- psllw %2, 2
- psubw %1, %2 ; a-5*b+4*c
- psllw %3, 4
- paddw %1, %3 ; a-5*b+20*c
-%endmacro
-
-%macro FILT_VNRD 8
- movu %6, [r1]
- paddw %1, %6
- mova %7, %2
- paddw %7, %5
- mova %8, %3
- paddw %8, %4
- FILT_H2 %1, %7, %8
-%endmacro
-
-%macro HV 1
-%if mmsize==16
-%define PAD 12
-%define COUNT 2
-%else
-%define PAD 4
-%define COUNT 3
-%endif
-put_hv%1_10:
- neg r2 ; This actually saves instructions
- lea r1, [r1+r2*2-mmsize+PAD]
- lea r4, [rsp+PAD+gprsize]
- mov r3d, COUNT
-.v_loop:
- movu m0, [r1]
- sub r1, r2
- movu m1, [r1]
- sub r1, r2
- movu m2, [r1]
- sub r1, r2
- movu m3, [r1]
- sub r1, r2
- movu m4, [r1]
- sub r1, r2
-%assign i 0
-%rep %1-1
- FILT_VNRD m0, m1, m2, m3, m4, m5, m6, m7
- psubw m0, [pad20]
- movu [r4+i*mmsize*3], m0
- sub r1, r2
- SWAP 0,1,2,3,4,5
-%assign i i+1
-%endrep
- FILT_VNRD m0, m1, m2, m3, m4, m5, m6, m7
- psubw m0, [pad20]
- movu [r4+i*mmsize*3], m0
- add r4, mmsize
- lea r1, [r1+r2*8+mmsize]
-%if %1==8
- lea r1, [r1+r2*4]
-%endif
- dec r3d
- jg .v_loop
- neg r2
- ret
-%endmacro
-
-INIT_MMX mmxext
-HV 4
-INIT_XMM sse2
-HV 8
-
-%macro H_LOOP 1
-%if num_mmregs > 8
- %define s1 m8
- %define s2 m9
- %define s3 m10
- %define d1 m11
-%else
- %define s1 [tap1]
- %define s2 [tap2]
- %define s3 [tap3]
- %define d1 [depad]
-%endif
-h%1_loop_op:
- movu m1, [r1+mmsize-4]
- movu m2, [r1+mmsize-2]
- mova m3, [r1+mmsize+0]
- movu m4, [r1+mmsize+2]
- movu m5, [r1+mmsize+4]
- movu m6, [r1+mmsize+6]
-%if num_mmregs > 8
- pmaddwd m1, s1
- pmaddwd m2, s1
- pmaddwd m3, s2
- pmaddwd m4, s2
- pmaddwd m5, s3
- pmaddwd m6, s3
- paddd m1, d1
- paddd m2, d1
-%else
- mova m0, s1
- pmaddwd m1, m0
- pmaddwd m2, m0
- mova m0, s2
- pmaddwd m3, m0
- pmaddwd m4, m0
- mova m0, s3
- pmaddwd m5, m0
- pmaddwd m6, m0
- mova m0, d1
- paddd m1, m0
- paddd m2, m0
-%endif
- paddd m3, m5
- paddd m4, m6
- paddd m1, m3
- paddd m2, m4
- psrad m1, 10
- psrad m2, 10
- pslld m2, 16
- pand m1, [pd_0f]
- por m1, m2
-%if num_mmregs <= 8
- pxor m0, m0
-%endif
- CLIPW m1, m0, m7
- add r1, mmsize*3
- ret
-%endmacro
-
-INIT_MMX mmxext
-H_LOOP 4
-INIT_XMM sse2
-H_LOOP 8
-
-%macro MC22 2
-cglobal_mc %1, mc22, %2, 3,7,12
-%define PAD mmsize*8*4*2 ; SIZE*16*4*sizeof(pixel)
- mov r6, rsp ; backup stack pointer
- and rsp, ~(mmsize-1) ; align stack
- sub rsp, PAD
-
- call put_hv%2_10
-
- mov r3d, %2
- mova m7, [pw_pixel_max]
-%if num_mmregs > 8
- pxor m0, m0
- mova m8, [tap1]
- mova m9, [tap2]
- mova m10, [tap3]
- mova m11, [depad]
-%endif
- mov r1, rsp
-.h_loop:
- call h%2_loop_op
-
- OP_MOV [r0], m1
- add r0, r2
- dec r3d
- jg .h_loop
-
- mov rsp, r6 ; restore stack pointer
- ret
-%endmacro
-
-MC MC22
-
-;-----------------------------------------------------------------------------
-; void h264_qpel_mc12(uint8_t *dst, uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-%macro MC12 2
-cglobal_mc %1, mc12, %2, 3,7,12
-%define PAD mmsize*8*4*2 ; SIZE*16*4*sizeof(pixel)
- mov r6, rsp ; backup stack pointer
- and rsp, ~(mmsize-1) ; align stack
- sub rsp, PAD
-
- call put_hv%2_10
-
- xor r4d, r4d
-.body:
- mov r3d, %2
- pxor m0, m0
- mova m7, [pw_pixel_max]
-%if num_mmregs > 8
- mova m8, [tap1]
- mova m9, [tap2]
- mova m10, [tap3]
- mova m11, [depad]
-%endif
- mov r1, rsp
-.h_loop:
- call h%2_loop_op
-
- movu m3, [r1+r4-2*mmsize] ; movu needed for mc32, etc
- paddw m3, [depad2]
- psrlw m3, 5
- psubw m3, [unpad]
- CLIPW m3, m0, m7
- pavgw m1, m3
-
- OP_MOV [r0], m1
- add r0, r2
- dec r3d
- jg .h_loop
-
- mov rsp, r6 ; restore stack pointer
- ret
-%endmacro
-
-MC MC12
-
-;-----------------------------------------------------------------------------
-; void h264_qpel_mc32(uint8_t *dst, uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-%macro MC32 2
-cglobal_mc %1, mc32, %2, 3,7,12
-%define PAD mmsize*8*3*2 ; SIZE*16*4*sizeof(pixel)
- mov r6, rsp ; backup stack pointer
- and rsp, ~(mmsize-1) ; align stack
- sub rsp, PAD
-
- call put_hv%2_10
-
- mov r4d, 2 ; sizeof(pixel)
- jmp stub_%1_h264_qpel%2_mc12_10 %+ SUFFIX %+ .body
-%endmacro
-
-MC MC32
-
-;-----------------------------------------------------------------------------
-; void h264_qpel_mc21(uint8_t *dst, uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-%macro H_NRD 1
-put_h%1_10:
- add rsp, gprsize
- mov r3d, %1
- xor r4d, r4d
- mova m6, [pad20]
-.nextrow:
- movu m2, [r5-4]
- movu m3, [r5-2]
- movu m4, [r5+0]
- ADDW m2, [r5+6], m5
- ADDW m3, [r5+4], m5
- ADDW m4, [r5+2], m5
-
- FILT_H2 m2, m3, m4
- psubw m2, m6
- mova [rsp+r4], m2
- add r4d, mmsize*3
- add r5, r2
- dec r3d
- jg .nextrow
- sub rsp, gprsize
- ret
-%endmacro
-
-INIT_MMX mmxext
-H_NRD 4
-INIT_XMM sse2
-H_NRD 8
-
-%macro MC21 2
-cglobal_mc %1, mc21, %2, 3,7,12
- mov r5, r1
-.body:
-%define PAD mmsize*8*3*2 ; SIZE*16*4*sizeof(pixel)
- mov r6, rsp ; backup stack pointer
- and rsp, ~(mmsize-1) ; align stack
-
- sub rsp, PAD
- call put_h%2_10
-
- sub rsp, PAD
- call put_hv%2_10
-
- mov r4d, PAD-mmsize ; H buffer
- jmp stub_%1_h264_qpel%2_mc12_10 %+ SUFFIX %+ .body
-%endmacro
-
-MC MC21
-
-;-----------------------------------------------------------------------------
-; void h264_qpel_mc23(uint8_t *dst, uint8_t *src, int stride)
-;-----------------------------------------------------------------------------
-%macro MC23 2
-cglobal_mc %1, mc23, %2, 3,7,12
- lea r5, [r1+r2]
- jmp stub_%1_h264_qpel%2_mc21_10 %+ SUFFIX %+ .body
-%endmacro
-
-MC MC23
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/h264_qpel_8bit.asm b/src/thirdparty/ffmpeg/libavcodec/x86/h264_qpel_8bit.asm
deleted file mode 100644
index 3039f1720..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/h264_qpel_8bit.asm
+++ /dev/null
@@ -1,1031 +0,0 @@
-;*****************************************************************************
-;* MMX/SSE2/SSSE3-optimized H.264 QPEL code
-;*****************************************************************************
-;* Copyright (c) 2004-2005 Michael Niedermayer, Loren Merritt
-;* Copyright (C) 2012 Daniel Kang
-;*
-;* Authors: Daniel Kang <daniel.d.kang@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 32
-
-cextern pw_16
-cextern pw_5
-cextern pb_0
-
-SECTION .text
-
-
-%macro op_avgh 3
- movh %3, %2
- pavgb %1, %3
- movh %2, %1
-%endmacro
-
-%macro op_avg 2-3
- pavgb %1, %2
- mova %2, %1
-%endmacro
-
-%macro op_puth 2-3
- movh %2, %1
-%endmacro
-
-%macro op_put 2-3
- mova %2, %1
-%endmacro
-
-%macro QPEL4_H_LOWPASS_OP 1
-cglobal %1_h264_qpel4_h_lowpass, 4,5 ; dst, src, dstStride, srcStride
- movsxdifnidn r2, r2d
- movsxdifnidn r3, r3d
- pxor m7, m7
- mova m4, [pw_5]
- mova m5, [pw_16]
- mov r4d, 4
-.loop:
- movh m1, [r1-1]
- movh m2, [r1+0]
- movh m3, [r1+1]
- movh m0, [r1+2]
- punpcklbw m1, m7
- punpcklbw m2, m7
- punpcklbw m3, m7
- punpcklbw m0, m7
- paddw m1, m0
- paddw m2, m3
- movh m0, [r1-2]
- movh m3, [r1+3]
- punpcklbw m0, m7
- punpcklbw m3, m7
- paddw m0, m3
- psllw m2, 2
- psubw m2, m1
- pmullw m2, m4
- paddw m0, m5
- paddw m0, m2
- psraw m0, 5
- packuswb m0, m0
- op_%1h m0, [r0], m6
- add r0, r2
- add r1, r3
- dec r4d
- jg .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-QPEL4_H_LOWPASS_OP put
-QPEL4_H_LOWPASS_OP avg
-
-%macro QPEL8_H_LOWPASS_OP 1
-cglobal %1_h264_qpel8_h_lowpass, 4,5 ; dst, src, dstStride, srcStride
- movsxdifnidn r2, r2d
- movsxdifnidn r3, r3d
- mov r4d, 8
- pxor m7, m7
- mova m6, [pw_5]
-.loop:
- mova m0, [r1]
- mova m2, [r1+1]
- mova m1, m0
- mova m3, m2
- punpcklbw m0, m7
- punpckhbw m1, m7
- punpcklbw m2, m7
- punpckhbw m3, m7
- paddw m0, m2
- paddw m1, m3
- psllw m0, 2
- psllw m1, 2
- mova m2, [r1-1]
- mova m4, [r1+2]
- mova m3, m2
- mova m5, m4
- punpcklbw m2, m7
- punpckhbw m3, m7
- punpcklbw m4, m7
- punpckhbw m5, m7
- paddw m2, m4
- paddw m5, m3
- psubw m0, m2
- psubw m1, m5
- pmullw m0, m6
- pmullw m1, m6
- movd m2, [r1-2]
- movd m5, [r1+7]
- punpcklbw m2, m7
- punpcklbw m5, m7
- paddw m2, m3
- paddw m4, m5
- mova m5, [pw_16]
- paddw m2, m5
- paddw m4, m5
- paddw m0, m2
- paddw m1, m4
- psraw m0, 5
- psraw m1, 5
- packuswb m0, m1
- op_%1 m0, [r0], m4
- add r0, r2
- add r1, r3
- dec r4d
- jg .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-QPEL8_H_LOWPASS_OP put
-QPEL8_H_LOWPASS_OP avg
-
-%macro QPEL8_H_LOWPASS_OP_XMM 1
-cglobal %1_h264_qpel8_h_lowpass, 4,5,8 ; dst, src, dstStride, srcStride
- movsxdifnidn r2, r2d
- movsxdifnidn r3, r3d
- mov r4d, 8
- pxor m7, m7
- mova m6, [pw_5]
-.loop:
- movu m1, [r1-2]
- mova m0, m1
- punpckhbw m1, m7
- punpcklbw m0, m7
- mova m2, m1
- mova m3, m1
- mova m4, m1
- mova m5, m1
- palignr m4, m0, 2
- palignr m3, m0, 4
- palignr m2, m0, 6
- palignr m1, m0, 8
- palignr m5, m0, 10
- paddw m0, m5
- paddw m2, m3
- paddw m1, m4
- psllw m2, 2
- psubw m2, m1
- paddw m0, [pw_16]
- pmullw m2, m6
- paddw m2, m0
- psraw m2, 5
- packuswb m2, m2
- op_%1h m2, [r0], m4
- add r1, r3
- add r0, r2
- dec r4d
- jne .loop
- REP_RET
-%endmacro
-
-INIT_XMM ssse3
-QPEL8_H_LOWPASS_OP_XMM put
-QPEL8_H_LOWPASS_OP_XMM avg
-
-
-%macro QPEL4_H_LOWPASS_L2_OP 1
-cglobal %1_h264_qpel4_h_lowpass_l2, 5,6 ; dst, src, src2, dstStride, srcStride
- movsxdifnidn r3, r3d
- movsxdifnidn r4, r4d
- pxor m7, m7
- mova m4, [pw_5]
- mova m5, [pw_16]
- mov r5d, 4
-.loop:
- movh m1, [r1-1]
- movh m2, [r1+0]
- movh m3, [r1+1]
- movh m0, [r1+2]
- punpcklbw m1, m7
- punpcklbw m2, m7
- punpcklbw m3, m7
- punpcklbw m0, m7
- paddw m1, m0
- paddw m2, m3
- movh m0, [r1-2]
- movh m3, [r1+3]
- punpcklbw m0, m7
- punpcklbw m3, m7
- paddw m0, m3
- psllw m2, 2
- psubw m2, m1
- pmullw m2, m4
- paddw m0, m5
- paddw m0, m2
- movh m3, [r2]
- psraw m0, 5
- packuswb m0, m0
- pavgb m0, m3
- op_%1h m0, [r0], m6
- add r0, r3
- add r1, r3
- add r2, r4
- dec r5d
- jg .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-QPEL4_H_LOWPASS_L2_OP put
-QPEL4_H_LOWPASS_L2_OP avg
-
-
-%macro QPEL8_H_LOWPASS_L2_OP 1
-cglobal %1_h264_qpel8_h_lowpass_l2, 5,6 ; dst, src, src2, dstStride, srcStride
- movsxdifnidn r3, r3d
- movsxdifnidn r4, r4d
- mov r5d, 8
- pxor m7, m7
- mova m6, [pw_5]
-.loop:
- mova m0, [r1]
- mova m2, [r1+1]
- mova m1, m0
- mova m3, m2
- punpcklbw m0, m7
- punpckhbw m1, m7
- punpcklbw m2, m7
- punpckhbw m3, m7
- paddw m0, m2
- paddw m1, m3
- psllw m0, 2
- psllw m1, 2
- mova m2, [r1-1]
- mova m4, [r1+2]
- mova m3, m2
- mova m5, m4
- punpcklbw m2, m7
- punpckhbw m3, m7
- punpcklbw m4, m7
- punpckhbw m5, m7
- paddw m2, m4
- paddw m5, m3
- psubw m0, m2
- psubw m1, m5
- pmullw m0, m6
- pmullw m1, m6
- movd m2, [r1-2]
- movd m5, [r1+7]
- punpcklbw m2, m7
- punpcklbw m5, m7
- paddw m2, m3
- paddw m4, m5
- mova m5, [pw_16]
- paddw m2, m5
- paddw m4, m5
- paddw m0, m2
- paddw m1, m4
- psraw m0, 5
- psraw m1, 5
- mova m4, [r2]
- packuswb m0, m1
- pavgb m0, m4
- op_%1 m0, [r0], m4
- add r0, r3
- add r1, r3
- add r2, r4
- dec r5d
- jg .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-QPEL8_H_LOWPASS_L2_OP put
-QPEL8_H_LOWPASS_L2_OP avg
-
-
-%macro QPEL8_H_LOWPASS_L2_OP_XMM 1
-cglobal %1_h264_qpel8_h_lowpass_l2, 5,6,8 ; dst, src, src2, dstStride, src2Stride
- movsxdifnidn r3, r3d
- movsxdifnidn r4, r4d
- mov r5d, 8
- pxor m7, m7
- mova m6, [pw_5]
-.loop:
- lddqu m1, [r1-2]
- mova m0, m1
- punpckhbw m1, m7
- punpcklbw m0, m7
- mova m2, m1
- mova m3, m1
- mova m4, m1
- mova m5, m1
- palignr m4, m0, 2
- palignr m3, m0, 4
- palignr m2, m0, 6
- palignr m1, m0, 8
- palignr m5, m0, 10
- paddw m0, m5
- paddw m2, m3
- paddw m1, m4
- psllw m2, 2
- movh m3, [r2]
- psubw m2, m1
- paddw m0, [pw_16]
- pmullw m2, m6
- paddw m2, m0
- psraw m2, 5
- packuswb m2, m2
- pavgb m2, m3
- op_%1h m2, [r0], m4
- add r1, r3
- add r0, r3
- add r2, r4
- dec r5d
- jg .loop
- REP_RET
-%endmacro
-
-INIT_XMM ssse3
-QPEL8_H_LOWPASS_L2_OP_XMM put
-QPEL8_H_LOWPASS_L2_OP_XMM avg
-
-
-; All functions that call this are required to have function arguments of
-; dst, src, dstStride, srcStride
-%macro FILT_V 1
- mova m6, m2
- movh m5, [r1]
- paddw m6, m3
- psllw m6, 2
- psubw m6, m1
- psubw m6, m4
- punpcklbw m5, m7
- pmullw m6, [pw_5]
- paddw m0, [pw_16]
- add r1, r3
- paddw m0, m5
- paddw m6, m0
- psraw m6, 5
- packuswb m6, m6
- op_%1h m6, [r0], m0 ; 1
- add r0, r2
- SWAP 0, 1, 2, 3, 4, 5
-%endmacro
-
-%macro QPEL4_V_LOWPASS_OP 1
-cglobal %1_h264_qpel4_v_lowpass, 4,4 ; dst, src, dstStride, srcStride
- movsxdifnidn r2, r2d
- movsxdifnidn r3, r3d
- sub r1, r3
- sub r1, r3
- pxor m7, m7
- movh m0, [r1]
- movh m1, [r1+r3]
- lea r1, [r1+2*r3]
- movh m2, [r1]
- movh m3, [r1+r3]
- lea r1, [r1+2*r3]
- movh m4, [r1]
- add r1, r3
- punpcklbw m0, m7
- punpcklbw m1, m7
- punpcklbw m2, m7
- punpcklbw m3, m7
- punpcklbw m4, m7
- FILT_V %1
- FILT_V %1
- FILT_V %1
- FILT_V %1
- RET
-%endmacro
-
-INIT_MMX mmxext
-QPEL4_V_LOWPASS_OP put
-QPEL4_V_LOWPASS_OP avg
-
-
-
-%macro QPEL8OR16_V_LOWPASS_OP 1
-%if cpuflag(sse2)
-cglobal %1_h264_qpel8or16_v_lowpass, 5,5,8 ; dst, src, dstStride, srcStride, h
- movsxdifnidn r2, r2d
- movsxdifnidn r3, r3d
- sub r1, r3
- sub r1, r3
-%else
-cglobal %1_h264_qpel8or16_v_lowpass_op, 5,5,8 ; dst, src, dstStride, srcStride, h
- movsxdifnidn r2, r2d
- movsxdifnidn r3, r3d
-%endif
- pxor m7, m7
- movh m0, [r1]
- movh m1, [r1+r3]
- lea r1, [r1+2*r3]
- movh m2, [r1]
- movh m3, [r1+r3]
- lea r1, [r1+2*r3]
- movh m4, [r1]
- add r1, r3
- punpcklbw m0, m7
- punpcklbw m1, m7
- punpcklbw m2, m7
- punpcklbw m3, m7
- punpcklbw m4, m7
- FILT_V %1
- FILT_V %1
- FILT_V %1
- FILT_V %1
- FILT_V %1
- FILT_V %1
- FILT_V %1
- FILT_V %1
- cmp r4d, 16
- jne .end
- FILT_V %1
- FILT_V %1
- FILT_V %1
- FILT_V %1
- FILT_V %1
- FILT_V %1
- FILT_V %1
- FILT_V %1
-.end:
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-QPEL8OR16_V_LOWPASS_OP put
-QPEL8OR16_V_LOWPASS_OP avg
-
-INIT_XMM sse2
-QPEL8OR16_V_LOWPASS_OP put
-QPEL8OR16_V_LOWPASS_OP avg
-
-
-; All functions that use this are required to have args:
-; src, tmp, srcSize
-%macro FILT_HV 1 ; offset
- mova m6, m2
- movh m5, [r0]
- paddw m6, m3
- psllw m6, 2
- paddw m0, [pw_16]
- psubw m6, m1
- psubw m6, m4
- punpcklbw m5, m7
- pmullw m6, [pw_5]
- paddw m0, m5
- add r0, r2
- paddw m6, m0
- mova [r1+%1], m6
- SWAP 0, 1, 2, 3, 4, 5
-%endmacro
-
-%macro QPEL4_HV1_LOWPASS_OP 1
-cglobal %1_h264_qpel4_hv_lowpass_v, 3,3 ; src, tmp, srcStride
- movsxdifnidn r2, r2d
- pxor m7, m7
- movh m0, [r0]
- movh m1, [r0+r2]
- lea r0, [r0+2*r2]
- movh m2, [r0]
- movh m3, [r0+r2]
- lea r0, [r0+2*r2]
- movh m4, [r0]
- add r0, r2
- punpcklbw m0, m7
- punpcklbw m1, m7
- punpcklbw m2, m7
- punpcklbw m3, m7
- punpcklbw m4, m7
- FILT_HV 0*24
- FILT_HV 1*24
- FILT_HV 2*24
- FILT_HV 3*24
- RET
-
-cglobal %1_h264_qpel4_hv_lowpass_h, 3,4 ; tmp, dst, dstStride
- movsxdifnidn r2, r2d
- mov r3d, 4
-.loop:
- mova m0, [r0]
- paddw m0, [r0+10]
- mova m1, [r0+2]
- paddw m1, [r0+8]
- mova m2, [r0+4]
- paddw m2, [r0+6]
- psubw m0, m1
- psraw m0, 2
- psubw m0, m1
- paddsw m0, m2
- psraw m0, 2
- paddw m0, m2
- psraw m0, 6
- packuswb m0, m0
- op_%1h m0, [r1], m7
- add r0, 24
- add r1, r2
- dec r3d
- jnz .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-QPEL4_HV1_LOWPASS_OP put
-QPEL4_HV1_LOWPASS_OP avg
-
-%macro QPEL8OR16_HV1_LOWPASS_OP 1
-cglobal %1_h264_qpel8or16_hv1_lowpass_op, 4,4,8 ; src, tmp, srcStride, size
- movsxdifnidn r2, r2d
- pxor m7, m7
- movh m0, [r0]
- movh m1, [r0+r2]
- lea r0, [r0+2*r2]
- movh m2, [r0]
- movh m3, [r0+r2]
- lea r0, [r0+2*r2]
- movh m4, [r0]
- add r0, r2
- punpcklbw m0, m7
- punpcklbw m1, m7
- punpcklbw m2, m7
- punpcklbw m3, m7
- punpcklbw m4, m7
- FILT_HV 0*48
- FILT_HV 1*48
- FILT_HV 2*48
- FILT_HV 3*48
- FILT_HV 4*48
- FILT_HV 5*48
- FILT_HV 6*48
- FILT_HV 7*48
- cmp r3d, 16
- jne .end
- FILT_HV 8*48
- FILT_HV 9*48
- FILT_HV 10*48
- FILT_HV 11*48
- FILT_HV 12*48
- FILT_HV 13*48
- FILT_HV 14*48
- FILT_HV 15*48
-.end:
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-QPEL8OR16_HV1_LOWPASS_OP put
-QPEL8OR16_HV1_LOWPASS_OP avg
-
-INIT_XMM sse2
-QPEL8OR16_HV1_LOWPASS_OP put
-
-
-
-%macro QPEL8OR16_HV2_LOWPASS_OP 1
-; unused is to match ssse3 and mmxext args
-cglobal %1_h264_qpel8or16_hv2_lowpass_op, 5,5 ; dst, tmp, dstStride, unused, h
- movsxdifnidn r2, r2d
-.loop:
- mova m0, [r1]
- mova m3, [r1+8]
- mova m1, [r1+2]
- mova m4, [r1+10]
- paddw m0, m4
- paddw m1, m3
- paddw m3, [r1+18]
- paddw m4, [r1+16]
- mova m2, [r1+4]
- mova m5, [r1+12]
- paddw m2, [r1+6]
- paddw m5, [r1+14]
- psubw m0, m1
- psubw m3, m4
- psraw m0, 2
- psraw m3, 2
- psubw m0, m1
- psubw m3, m4
- paddsw m0, m2
- paddsw m3, m5
- psraw m0, 2
- psraw m3, 2
- paddw m0, m2
- paddw m3, m5
- psraw m0, 6
- psraw m3, 6
- packuswb m0, m3
- op_%1 m0, [r0], m7
- add r1, 48
- add r0, r2
- dec r4d
- jne .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-QPEL8OR16_HV2_LOWPASS_OP put
-QPEL8OR16_HV2_LOWPASS_OP avg
-
-%macro QPEL8OR16_HV2_LOWPASS_OP_XMM 1
-cglobal %1_h264_qpel8or16_hv2_lowpass, 5,5,8 ; dst, tmp, dstStride, tmpStride, size
- movsxdifnidn r2, r2d
- movsxdifnidn r3, r3d
- cmp r4d, 16
- je .op16
-.loop8:
- mova m1, [r1+16]
- mova m0, [r1]
- mova m2, m1
- mova m3, m1
- mova m4, m1
- mova m5, m1
- palignr m5, m0, 10
- palignr m4, m0, 8
- palignr m3, m0, 6
- palignr m2, m0, 4
- palignr m1, m0, 2
- paddw m0, m5
- paddw m1, m4
- paddw m2, m3
- psubw m0, m1
- psraw m0, 2
- psubw m0, m1
- paddw m0, m2
- psraw m0, 2
- paddw m0, m2
- psraw m0, 6
- packuswb m0, m0
- op_%1h m0, [r0], m7
- add r1, 48
- add r0, r2
- dec r4d
- jne .loop8
- jmp .done
-.op16:
- mova m4, [r1+32]
- mova m5, [r1+16]
- mova m7, [r1]
- mova m3, m4
- mova m2, m4
- mova m1, m4
- mova m0, m4
- palignr m0, m5, 10
- palignr m1, m5, 8
- palignr m2, m5, 6
- palignr m3, m5, 4
- palignr m4, m5, 2
- paddw m0, m5
- paddw m1, m4
- paddw m2, m3
- mova m6, m5
- mova m4, m5
- mova m3, m5
- palignr m4, m7, 8
- palignr m6, m7, 2
- palignr m3, m7, 10
- paddw m4, m6
- mova m6, m5
- palignr m5, m7, 6
- palignr m6, m7, 4
- paddw m3, m7
- paddw m5, m6
- psubw m0, m1
- psubw m3, m4
- psraw m0, 2
- psraw m3, 2
- psubw m0, m1
- psubw m3, m4
- paddw m0, m2
- paddw m3, m5
- psraw m0, 2
- psraw m3, 2
- paddw m0, m2
- paddw m3, m5
- psraw m0, 6
- psraw m3, 6
- packuswb m3, m0
- op_%1 m3, [r0], m7
- add r1, 48
- add r0, r2
- dec r4d
- jne .op16
-.done:
- REP_RET
-%endmacro
-
-INIT_XMM ssse3
-QPEL8OR16_HV2_LOWPASS_OP_XMM put
-QPEL8OR16_HV2_LOWPASS_OP_XMM avg
-
-
-%macro PIXELS4_L2_SHIFT5 1
-cglobal %1_pixels4_l2_shift5,6,6 ; dst, src16, src8, dstStride, src8Stride, h
- movsxdifnidn r3, r3d
- movsxdifnidn r4, r4d
- mova m0, [r1]
- mova m1, [r1+24]
- psraw m0, 5
- psraw m1, 5
- packuswb m0, m0
- packuswb m1, m1
- pavgb m0, [r2]
- pavgb m1, [r2+r4]
- op_%1h m0, [r0], m4
- op_%1h m1, [r0+r3], m5
- lea r2, [r2+r4*2]
- lea r0, [r0+r3*2]
- mova m0, [r1+48]
- mova m1, [r1+72]
- psraw m0, 5
- psraw m1, 5
- packuswb m0, m0
- packuswb m1, m1
- pavgb m0, [r2]
- pavgb m1, [r2+r4]
- op_%1h m0, [r0], m4
- op_%1h m1, [r0+r3], m5
- RET
-%endmacro
-
-INIT_MMX mmxext
-PIXELS4_L2_SHIFT5 put
-PIXELS4_L2_SHIFT5 avg
-
-
-%macro PIXELS8_L2_SHIFT5 1
-cglobal %1_pixels8_l2_shift5, 6, 6 ; dst, src16, src8, dstStride, src8Stride, h
- movsxdifnidn r3, r3d
- movsxdifnidn r4, r4d
-.loop:
- mova m0, [r1]
- mova m1, [r1+8]
- mova m2, [r1+48]
- mova m3, [r1+48+8]
- psraw m0, 5
- psraw m1, 5
- psraw m2, 5
- psraw m3, 5
- packuswb m0, m1
- packuswb m2, m3
- pavgb m0, [r2]
- pavgb m2, [r2+r4]
- op_%1 m0, [r0], m4
- op_%1 m2, [r0+r3], m5
- lea r2, [r2+2*r4]
- add r1, 48*2
- lea r0, [r0+2*r3]
- sub r5d, 2
- jne .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-PIXELS8_L2_SHIFT5 put
-PIXELS8_L2_SHIFT5 avg
-
-
-%if ARCH_X86_64
-%macro QPEL16_H_LOWPASS_L2_OP 1
-cglobal %1_h264_qpel16_h_lowpass_l2, 5, 6, 16 ; dst, src, src2, dstStride, src2Stride
- movsxdifnidn r3, r3d
- movsxdifnidn r4, r4d
- mov r5d, 16
- pxor m15, m15
- mova m14, [pw_5]
- mova m13, [pw_16]
-.loop:
- lddqu m1, [r1+6]
- lddqu m7, [r1-2]
- mova m0, m1
- punpckhbw m1, m15
- punpcklbw m0, m15
- punpcklbw m7, m15
- mova m2, m1
- mova m6, m0
- mova m3, m1
- mova m8, m0
- mova m4, m1
- mova m9, m0
- mova m12, m0
- mova m11, m1
- palignr m11, m0, 10
- palignr m12, m7, 10
- palignr m4, m0, 2
- palignr m9, m7, 2
- palignr m3, m0, 4
- palignr m8, m7, 4
- palignr m2, m0, 6
- palignr m6, m7, 6
- paddw m11, m0
- palignr m1, m0, 8
- palignr m0, m7, 8
- paddw m7, m12
- paddw m2, m3
- paddw m6, m8
- paddw m1, m4
- paddw m0, m9
- psllw m2, 2
- psllw m6, 2
- psubw m2, m1
- psubw m6, m0
- paddw m11, m13
- paddw m7, m13
- pmullw m2, m14
- pmullw m6, m14
- lddqu m3, [r2]
- paddw m2, m11
- paddw m6, m7
- psraw m2, 5
- psraw m6, 5
- packuswb m6, m2
- pavgb m6, m3
- op_%1 m6, [r0], m11
- add r1, r3
- add r0, r3
- add r2, r4
- dec r5d
- jg .loop
- REP_RET
-%endmacro
-
-INIT_XMM ssse3
-QPEL16_H_LOWPASS_L2_OP put
-QPEL16_H_LOWPASS_L2_OP avg
-%endif
-
-; void 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
- movsxdifnidn r3, r3d
- movsxdifnidn r4, r4d
- test r5d, 1
- je .loop
- movd m0, [r1]
- movd m1, [r2]
- add r1, r4
- add r2, 4
- pavgb m0, m1
- OP m0, [r0], m3
- add r0, r3
- dec r5d
-.loop:
- mova m0, [r1]
- mova m1, [r1+r4]
- lea r1, [r1+2*r4]
- pavgb m0, [r2]
- pavgb m1, [r2+4]
- OP m0, [r0], m3
- OP m1, [r0+r3], m3
- lea r0, [r0+2*r3]
- mova m0, [r1]
- mova m1, [r1+r4]
- lea r1, [r1+2*r4]
- pavgb m0, [r2+8]
- pavgb m1, [r2+12]
- OP m0, [r0], m3
- OP m1, [r0+r3], m3
- lea r0, [r0+2*r3]
- add r2, 16
- sub r5d, 4
- jne .loop
- REP_RET
-%endmacro
-
-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)
-%macro PIXELS8_L2 1
-%define OP op_%1
-cglobal %1_pixels8_l2, 6,6
- movsxdifnidn r3, r3d
- movsxdifnidn r4, r4d
- test r5d, 1
- je .loop
- mova m0, [r1]
- mova m1, [r2]
- add r1, r4
- add r2, 8
- pavgb m0, m1
- OP m0, [r0]
- add r0, r3
- dec r5d
-.loop:
- mova m0, [r1]
- mova m1, [r1+r4]
- lea r1, [r1+2*r4]
- pavgb m0, [r2]
- pavgb m1, [r2+8]
- OP m0, [r0]
- OP m1, [r0+r3]
- lea r0, [r0+2*r3]
- mova m0, [r1]
- mova m1, [r1+r4]
- lea r1, [r1+2*r4]
- pavgb m0, [r2+16]
- pavgb m1, [r2+24]
- OP m0, [r0]
- OP m1, [r0+r3]
- lea r0, [r0+2*r3]
- add r2, 32
- sub r5d, 4
- jne .loop
- REP_RET
-%endmacro
-
-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)
-%macro PIXELS16_L2 1
-%define OP op_%1
-cglobal %1_pixels16_l2, 6,6
- movsxdifnidn r3, r3d
- movsxdifnidn r4, r4d
- test r5d, 1
- je .loop
- mova m0, [r1]
- mova m1, [r1+8]
- pavgb m0, [r2]
- pavgb m1, [r2+8]
- add r1, r4
- add r2, 16
- OP m0, [r0]
- OP m1, [r0+8]
- add r0, r3
- dec r5d
-.loop:
- mova m0, [r1]
- mova m1, [r1+8]
- add r1, r4
- pavgb m0, [r2]
- pavgb m1, [r2+8]
- OP m0, [r0]
- OP m1, [r0+8]
- add r0, r3
- mova m0, [r1]
- mova m1, [r1+8]
- add r1, r4
- pavgb m0, [r2+16]
- pavgb m1, [r2+24]
- OP m0, [r0]
- OP m1, [r0+8]
- add r0, r3
- add r2, 32
- sub r5d, 2
- jne .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-PIXELS16_L2 put
-PIXELS16_L2 avg
-
-INIT_MMX mmxext
-; void pixels(uint8_t *block, const uint8_t *pixels, int line_size, int h)
-%macro PIXELS48 2
-%if %2 == 4
-%define OP movh
-%else
-%define OP mova
-%endif
-cglobal %1_pixels%2, 4,5
- movsxdifnidn r2, r2d
- lea r4, [r2*3]
-.loop:
- OP m0, [r1]
- OP m1, [r1+r2]
- OP m2, [r1+r2*2]
- OP m3, [r1+r4]
- lea r1, [r1+r2*4]
-%ifidn %1, avg
- pavgb m0, [r0]
- pavgb m1, [r0+r2]
- pavgb m2, [r0+r2*2]
- pavgb m3, [r0+r4]
-%endif
- OP [r0], m0
- OP [r0+r2], m1
- OP [r0+r2*2], m2
- OP [r0+r4], m3
- sub r3d, 4
- lea r0, [r0+r2*4]
- jne .loop
- RET
-%endmacro
-
-PIXELS48 put, 4
-PIXELS48 avg, 4
-PIXELS48 put, 8
-PIXELS48 avg, 8
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/h264_weight.asm b/src/thirdparty/ffmpeg/libavcodec/x86/h264_weight.asm
deleted file mode 100644
index 98bf6cc12..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/h264_weight.asm
+++ /dev/null
@@ -1,317 +0,0 @@
-;*****************************************************************************
-;* SSE2-optimized weighted prediction code
-;*****************************************************************************
-;* Copyright (c) 2004-2005 Michael Niedermayer, Loren Merritt
-;* Copyright (C) 2010 Eli Friedman <eli.friedman@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 .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);
-; and
-; void h264_weight_16_sse2(uint8_t *dst, int stride, int height,
-; int log2_denom, int weight, int offset);
-;-----------------------------------------------------------------------------
-
-%macro WEIGHT_SETUP 0
- add r5, r5
- inc r5
- movd m3, r4d
- movd m5, r5d
- movd m6, r3d
- pslld m5, m6
- psrld m5, 1
-%if mmsize == 16
- pshuflw m3, m3, 0
- pshuflw m5, m5, 0
- punpcklqdq m3, m3
- punpcklqdq m5, m5
-%else
- pshufw m3, m3, 0
- pshufw m5, m5, 0
-%endif
- pxor m7, m7
-%endmacro
-
-%macro WEIGHT_OP 2
- movh m0, [r0+%1]
- movh m1, [r0+%2]
- punpcklbw m0, m7
- punpcklbw m1, m7
- pmullw m0, m3
- pmullw m1, m3
- paddsw m0, m5
- paddsw m1, m5
- psraw m0, m6
- psraw m1, m6
- packuswb m0, m1
-%endmacro
-
-INIT_MMX mmxext
-cglobal h264_weight_16, 6, 6, 0
- WEIGHT_SETUP
-.nextrow:
- WEIGHT_OP 0, 4
- mova [r0 ], m0
- WEIGHT_OP 8, 12
- mova [r0+8], m0
- add r0, r1
- dec r2d
- jnz .nextrow
- REP_RET
-
-%macro WEIGHT_FUNC_MM 2
-cglobal h264_weight_%1, 6, 6, %2
- WEIGHT_SETUP
-.nextrow:
- WEIGHT_OP 0, mmsize/2
- mova [r0], m0
- add r0, r1
- dec r2d
- jnz .nextrow
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-WEIGHT_FUNC_MM 8, 0
-INIT_XMM sse2
-WEIGHT_FUNC_MM 16, 8
-
-%macro WEIGHT_FUNC_HALF_MM 2
-cglobal h264_weight_%1, 6, 6, %2
- WEIGHT_SETUP
- sar r2d, 1
- lea r3, [r1*2]
-.nextrow:
- WEIGHT_OP 0, r1
- movh [r0], m0
-%if mmsize == 16
- movhps [r0+r1], m0
-%else
- psrlq m0, 32
- movh [r0+r1], m0
-%endif
- add r0, r3
- dec r2d
- jnz .nextrow
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-WEIGHT_FUNC_HALF_MM 4, 0
-INIT_XMM sse2
-WEIGHT_FUNC_HALF_MM 8, 8
-
-%macro BIWEIGHT_SETUP 0
-%if ARCH_X86_64
-%define off_regd r7d
-%else
-%define off_regd r3d
-%endif
- mov off_regd, r7m
- add off_regd, 1
- or off_regd, 1
- add r4, 1
- cmp r5, 128
- jne .normal
- sar r5, 1
- sar r6, 1
- sar off_regd, 1
- sub r4, 1
-.normal
-%if cpuflag(ssse3)
- movd m4, r5d
- movd m0, r6d
-%else
- movd m3, r5d
- movd m4, r6d
-%endif
- movd m5, off_regd
- movd m6, r4d
- pslld m5, m6
- psrld m5, 1
-%if cpuflag(ssse3)
- punpcklbw m4, m0
- pshuflw m4, m4, 0
- pshuflw m5, m5, 0
- punpcklqdq m4, m4
- punpcklqdq m5, m5
-
-%else
-%if mmsize == 16
- pshuflw m3, m3, 0
- pshuflw m4, m4, 0
- pshuflw m5, m5, 0
- punpcklqdq m3, m3
- punpcklqdq m4, m4
- punpcklqdq m5, m5
-%else
- pshufw m3, m3, 0
- pshufw m4, m4, 0
- pshufw m5, m5, 0
-%endif
- pxor m7, m7
-%endif
-%endmacro
-
-%macro BIWEIGHT_STEPA 3
- movh m%1, [r0+%3]
- movh m%2, [r1+%3]
- punpcklbw m%1, m7
- punpcklbw m%2, m7
- pmullw m%1, m3
- pmullw m%2, m4
- paddsw m%1, m%2
-%endmacro
-
-%macro BIWEIGHT_STEPB 0
- paddsw m0, m5
- paddsw m1, m5
- psraw m0, m6
- psraw m1, m6
- packuswb m0, m1
-%endmacro
-
-INIT_MMX mmxext
-cglobal h264_biweight_16, 7, 8, 0
- BIWEIGHT_SETUP
- movifnidn r3d, r3m
-.nextrow:
- BIWEIGHT_STEPA 0, 1, 0
- BIWEIGHT_STEPA 1, 2, 4
- BIWEIGHT_STEPB
- mova [r0], m0
- BIWEIGHT_STEPA 0, 1, 8
- BIWEIGHT_STEPA 1, 2, 12
- BIWEIGHT_STEPB
- mova [r0+8], m0
- add r0, r2
- add r1, r2
- dec r3d
- jnz .nextrow
- REP_RET
-
-%macro BIWEIGHT_FUNC_MM 2
-cglobal h264_biweight_%1, 7, 8, %2
- BIWEIGHT_SETUP
- movifnidn r3d, r3m
-.nextrow:
- BIWEIGHT_STEPA 0, 1, 0
- BIWEIGHT_STEPA 1, 2, mmsize/2
- BIWEIGHT_STEPB
- mova [r0], m0
- add r0, r2
- add r1, r2
- dec r3d
- jnz .nextrow
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-BIWEIGHT_FUNC_MM 8, 0
-INIT_XMM sse2
-BIWEIGHT_FUNC_MM 16, 8
-
-%macro BIWEIGHT_FUNC_HALF_MM 2
-cglobal h264_biweight_%1, 7, 8, %2
- BIWEIGHT_SETUP
- movifnidn r3d, r3m
- sar r3, 1
- lea r4, [r2*2]
-.nextrow:
- BIWEIGHT_STEPA 0, 1, 0
- BIWEIGHT_STEPA 1, 2, r2
- BIWEIGHT_STEPB
- movh [r0], m0
-%if mmsize == 16
- movhps [r0+r2], m0
-%else
- psrlq m0, 32
- movh [r0+r2], m0
-%endif
- add r0, r4
- add r1, r4
- dec r3d
- jnz .nextrow
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-BIWEIGHT_FUNC_HALF_MM 4, 0
-INIT_XMM sse2
-BIWEIGHT_FUNC_HALF_MM 8, 8
-
-%macro BIWEIGHT_SSSE3_OP 0
- pmaddubsw m0, m4
- pmaddubsw m2, m4
- paddsw m0, m5
- paddsw m2, m5
- psraw m0, m6
- psraw m2, m6
- packuswb m0, m2
-%endmacro
-
-INIT_XMM ssse3
-cglobal h264_biweight_16, 7, 8, 8
- BIWEIGHT_SETUP
- movifnidn r3d, r3m
-
-.nextrow:
- movh m0, [r0]
- movh m2, [r0+8]
- movh m3, [r1+8]
- punpcklbw m0, [r1]
- punpcklbw m2, m3
- BIWEIGHT_SSSE3_OP
- mova [r0], m0
- add r0, r2
- add r1, r2
- dec r3d
- jnz .nextrow
- REP_RET
-
-INIT_XMM ssse3
-cglobal h264_biweight_8, 7, 8, 8
- BIWEIGHT_SETUP
- movifnidn r3d, r3m
- sar r3, 1
- lea r4, [r2*2]
-
-.nextrow:
- movh m0, [r0]
- movh m1, [r1]
- movh m2, [r0+r2]
- movh m3, [r1+r2]
- punpcklbw m0, m1
- punpcklbw m2, m3
- BIWEIGHT_SSSE3_OP
- movh [r0], m0
- movhps [r0+r2], m0
- add r0, r4
- add r1, r4
- dec r3d
- jnz .nextrow
- REP_RET
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/h264_weight_10bit.asm b/src/thirdparty/ffmpeg/libavcodec/x86/h264_weight_10bit.asm
deleted file mode 100644
index 409a08f70..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/h264_weight_10bit.asm
+++ /dev/null
@@ -1,282 +0,0 @@
-;*****************************************************************************
-;* MMX/SSE2/AVX-optimized 10-bit H.264 weighted prediction code
-;*****************************************************************************
-;* Copyright (C) 2005-2011 x264 project
-;*
-;* Authors: Daniel Kang <daniel.d.kang@gmail.com>
-;*
-;* This file is part of Libav.
-;*
-;* Libav is free software; you can redistribute it and/or
-;* modify it under the terms of the GNU Lesser General Public
-;* License as published by the Free Software Foundation; either
-;* version 2.1 of the License, or (at your option) any later version.
-;*
-;* Libav is distributed in the hope that it will be useful,
-;* but WITHOUT ANY WARRANTY; without even the implied warranty of
-;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-;* Lesser General Public License for more details.
-;*
-;* You should have received a copy of the GNU Lesser General Public
-;* License along with Libav; if not, write to the Free Software
-;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-;******************************************************************************
-
-%include "libavutil/x86/x86util.asm"
-
-SECTION_RODATA 32
-
-pw_pixel_max: times 8 dw ((1 << 10)-1)
-sq_1: dq 1
- dq 0
-
-cextern pw_1
-
-SECTION .text
-
-;-----------------------------------------------------------------------------
-; void h264_weight(uint8_t *dst, int stride, int height, int log2_denom,
-; int weight, int offset);
-;-----------------------------------------------------------------------------
-%macro WEIGHT_PROLOGUE 0
-.prologue:
- PROLOGUE 0,6,8
- movifnidn r0, r0mp
- movifnidn r1d, r1m
- movifnidn r2d, r2m
- movifnidn r4d, r4m
- movifnidn r5d, r5m
-%endmacro
-
-%macro WEIGHT_SETUP 0
- mova m0, [pw_1]
- movd m2, r3m
- pslld m0, m2 ; 1<<log2_denom
- SPLATW m0, m0
- shl r5, 19 ; *8, move to upper half of dword
- lea r5, [r5+r4*2+0x10000]
- movd m3, r5d ; weight<<1 | 1+(offset<<(3))
- pshufd m3, m3, 0
- mova m4, [pw_pixel_max]
- paddw m2, [sq_1] ; log2_denom+1
-%if notcpuflag(sse4)
- pxor m7, m7
-%endif
-%endmacro
-
-%macro WEIGHT_OP 1-2
-%if %0==1
- mova m5, [r0+%1]
- punpckhwd m6, m5, m0
- punpcklwd m5, m0
-%else
- movq m5, [r0+%1]
- movq m6, [r0+%2]
- punpcklwd m5, m0
- punpcklwd m6, m0
-%endif
- pmaddwd m5, m3
- pmaddwd m6, m3
- psrad m5, m2
- psrad m6, m2
-%if cpuflag(sse4)
- packusdw m5, m6
- pminsw m5, m4
-%else
- packssdw m5, m6
- CLIPW m5, m7, m4
-%endif
-%endmacro
-
-%macro WEIGHT_FUNC_DBL 0
-cglobal h264_weight_16_10
- WEIGHT_PROLOGUE
- WEIGHT_SETUP
-.nextrow:
- WEIGHT_OP 0
- mova [r0 ], m5
- WEIGHT_OP 16
- mova [r0+16], m5
- add r0, r1
- dec r2d
- jnz .nextrow
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-WEIGHT_FUNC_DBL
-INIT_XMM sse4
-WEIGHT_FUNC_DBL
-
-
-%macro WEIGHT_FUNC_MM 0
-cglobal h264_weight_8_10
- WEIGHT_PROLOGUE
- WEIGHT_SETUP
-.nextrow:
- WEIGHT_OP 0
- mova [r0], m5
- add r0, r1
- dec r2d
- jnz .nextrow
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-WEIGHT_FUNC_MM
-INIT_XMM sse4
-WEIGHT_FUNC_MM
-
-
-%macro WEIGHT_FUNC_HALF_MM 0
-cglobal h264_weight_4_10
- WEIGHT_PROLOGUE
- sar r2d, 1
- WEIGHT_SETUP
- lea r3, [r1*2]
-.nextrow:
- WEIGHT_OP 0, r1
- movh [r0], m5
- movhps [r0+r1], m5
- add r0, r3
- dec r2d
- jnz .nextrow
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-WEIGHT_FUNC_HALF_MM
-INIT_XMM sse4
-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);
-;-----------------------------------------------------------------------------
-%if ARCH_X86_32
-DECLARE_REG_TMP 3
-%else
-DECLARE_REG_TMP 7
-%endif
-
-%macro BIWEIGHT_PROLOGUE 0
-.prologue:
- PROLOGUE 0,8,8
- movifnidn r0, r0mp
- movifnidn r1, r1mp
- movifnidn r2d, r2m
- movifnidn r5d, r5m
- movifnidn r6d, r6m
- movifnidn t0d, r7m
-%endmacro
-
-%macro BIWEIGHT_SETUP 0
- lea t0, [t0*4+1] ; (offset<<2)+1
- or t0, 1
- shl r6, 16
- or r5, r6
- movd m4, r5d ; weightd | weights
- movd m5, t0d ; (offset+1)|1
- movd m6, r4m ; log2_denom
- pslld m5, m6 ; (((offset<<2)+1)|1)<<log2_denom
- paddd m6, [sq_1]
- pshufd m4, m4, 0
- pshufd m5, m5, 0
- mova m3, [pw_pixel_max]
- movifnidn r3d, r3m
-%if notcpuflag(sse4)
- pxor m7, m7
-%endif
-%endmacro
-
-%macro BIWEIGHT 1-2
-%if %0==1
- mova m0, [r0+%1]
- mova m1, [r1+%1]
- punpckhwd m2, m0, m1
- punpcklwd m0, m1
-%else
- movq m0, [r0+%1]
- movq m1, [r1+%1]
- punpcklwd m0, m1
- movq m2, [r0+%2]
- movq m1, [r1+%2]
- punpcklwd m2, m1
-%endif
- pmaddwd m0, m4
- pmaddwd m2, m4
- paddd m0, m5
- paddd m2, m5
- psrad m0, m6
- psrad m2, m6
-%if cpuflag(sse4)
- packusdw m0, m2
- pminsw m0, m3
-%else
- packssdw m0, m2
- CLIPW m0, m7, m3
-%endif
-%endmacro
-
-%macro BIWEIGHT_FUNC_DBL 0
-cglobal h264_biweight_16_10
- BIWEIGHT_PROLOGUE
- BIWEIGHT_SETUP
-.nextrow:
- BIWEIGHT 0
- mova [r0 ], m0
- BIWEIGHT 16
- mova [r0+16], m0
- add r0, r2
- add r1, r2
- dec r3d
- jnz .nextrow
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-BIWEIGHT_FUNC_DBL
-INIT_XMM sse4
-BIWEIGHT_FUNC_DBL
-
-%macro BIWEIGHT_FUNC 0
-cglobal h264_biweight_8_10
- BIWEIGHT_PROLOGUE
- BIWEIGHT_SETUP
-.nextrow:
- BIWEIGHT 0
- mova [r0], m0
- add r0, r2
- add r1, r2
- dec r3d
- jnz .nextrow
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-BIWEIGHT_FUNC
-INIT_XMM sse4
-BIWEIGHT_FUNC
-
-%macro BIWEIGHT_FUNC_HALF 0
-cglobal h264_biweight_4_10
- BIWEIGHT_PROLOGUE
- BIWEIGHT_SETUP
- sar r3d, 1
- lea r4, [r2*2]
-.nextrow:
- BIWEIGHT 0, r2
- movh [r0 ], m0
- movhps [r0+r2], m0
- add r0, r4
- add r1, r4
- dec r3d
- jnz .nextrow
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-BIWEIGHT_FUNC_HALF
-INIT_XMM sse4
-BIWEIGHT_FUNC_HALF
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/h264chroma_init.c b/src/thirdparty/ffmpeg/libavcodec/x86/h264chroma_init.c
deleted file mode 100644
index b5c078f73..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/h264chroma_init.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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/cpu.h"
-#include "libavutil/x86/cpu.h"
-#include "libavcodec/h264chroma.h"
-
-void ff_put_h264_chroma_mc8_rnd_mmx (uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
-void ff_avg_h264_chroma_mc8_rnd_mmxext(uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
-void ff_avg_h264_chroma_mc8_rnd_3dnow(uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
-
-void ff_put_h264_chroma_mc4_mmx (uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
-void ff_avg_h264_chroma_mc4_mmxext (uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
-void ff_avg_h264_chroma_mc4_3dnow (uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
-
-void ff_put_h264_chroma_mc2_mmxext (uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
-void ff_avg_h264_chroma_mc2_mmxext (uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
-
-void ff_put_h264_chroma_mc8_rnd_ssse3(uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
-void ff_put_h264_chroma_mc4_ssse3 (uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
-
-void ff_avg_h264_chroma_mc8_rnd_ssse3(uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
-void ff_avg_h264_chroma_mc4_ssse3 (uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
-
-#define CHROMA_MC(OP, NUM, DEPTH, OPT) \
-void ff_ ## OP ## _h264_chroma_mc ## NUM ## _ ## DEPTH ## _ ## OPT \
- (uint8_t *dst, uint8_t *src, \
- int stride, int h, int x, int y);
-
-CHROMA_MC(put, 2, 10, mmxext)
-CHROMA_MC(avg, 2, 10, mmxext)
-CHROMA_MC(put, 4, 10, mmxext)
-CHROMA_MC(avg, 4, 10, mmxext)
-CHROMA_MC(put, 8, 10, sse2)
-CHROMA_MC(avg, 8, 10, sse2)
-CHROMA_MC(put, 8, 10, avx)
-CHROMA_MC(avg, 8, 10, avx)
-
-void ff_h264chroma_init_x86(H264ChromaContext *c, int bit_depth)
-{
-#if HAVE_YASM
- int high_bit_depth = bit_depth > 8;
- int mm_flags = av_get_cpu_flags();
-
- if (EXTERNAL_MMX(mm_flags) && !high_bit_depth) {
- c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_rnd_mmx;
- c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_mmx;
- }
-
- if (EXTERNAL_AMD3DNOW(mm_flags) && !high_bit_depth) {
- c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_rnd_3dnow;
- c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_3dnow;
- }
-
- if (EXTERNAL_MMXEXT(mm_flags) && !high_bit_depth) {
- c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_rnd_mmxext;
- c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_mmxext;
- c->avg_h264_chroma_pixels_tab[2] = ff_avg_h264_chroma_mc2_mmxext;
- c->put_h264_chroma_pixels_tab[2] = ff_put_h264_chroma_mc2_mmxext;
- }
-
- if (EXTERNAL_MMXEXT(mm_flags) && bit_depth > 8 && bit_depth <= 10) {
- c->put_h264_chroma_pixels_tab[2] = ff_put_h264_chroma_mc2_10_mmxext;
- c->avg_h264_chroma_pixels_tab[2] = ff_avg_h264_chroma_mc2_10_mmxext;
- c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_10_mmxext;
- c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_10_mmxext;
- }
-
- if (EXTERNAL_SSE2(mm_flags) && bit_depth > 8 && bit_depth <= 10) {
- c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_10_sse2;
- c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_10_sse2;
- }
-
- if (EXTERNAL_SSSE3(mm_flags) && !high_bit_depth) {
- c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_rnd_ssse3;
- c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_rnd_ssse3;
- c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_ssse3;
- c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_ssse3;
- }
-
- if (EXTERNAL_AVX(mm_flags) && bit_depth > 8 && bit_depth <= 10) {
- // AVX implies !cache64.
- // TODO: Port cache(32|64) detection from x264.
- 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/src/thirdparty/ffmpeg/libavcodec/x86/h264dsp_init.c b/src/thirdparty/ffmpeg/libavcodec/x86/h264dsp_init.c
deleted file mode 100644
index 11aae77d2..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/h264dsp_init.c
+++ /dev/null
@@ -1,375 +0,0 @@
-/*
- * Copyright (c) 2004-2005 Michael Niedermayer, 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/attributes.h"
-#include "libavutil/cpu.h"
-#include "libavutil/x86/asm.h"
-#include "libavutil/x86/cpu.h"
-#include "libavcodec/h264dsp.h"
-#include "dsputil_mmx.h"
-
-/***********************************/
-/* IDCT */
-#define IDCT_ADD_FUNC(NUM, DEPTH, OPT) \
-void ff_h264_idct ## NUM ## _add_ ## DEPTH ## _ ## OPT(uint8_t *dst, \
- int16_t *block, \
- int stride);
-
-IDCT_ADD_FUNC(, 8, mmx)
-IDCT_ADD_FUNC(, 10, sse2)
-IDCT_ADD_FUNC(_dc, 8, mmxext)
-IDCT_ADD_FUNC(_dc, 10, mmxext)
-IDCT_ADD_FUNC(8_dc, 8, mmxext)
-IDCT_ADD_FUNC(8_dc, 10, sse2)
-IDCT_ADD_FUNC(8, 8, mmx)
-IDCT_ADD_FUNC(8, 8, sse2)
-IDCT_ADD_FUNC(8, 10, sse2)
-IDCT_ADD_FUNC(, 10, avx)
-IDCT_ADD_FUNC(8_dc, 10, avx)
-IDCT_ADD_FUNC(8, 10, avx)
-
-
-#define IDCT_ADD_REP_FUNC(NUM, REP, DEPTH, OPT) \
-void ff_h264_idct ## NUM ## _add ## REP ## _ ## DEPTH ## _ ## OPT \
- (uint8_t *dst, const int *block_offset, \
- int16_t *block, int stride, const uint8_t nnzc[6 * 8]);
-
-IDCT_ADD_REP_FUNC(8, 4, 8, mmx)
-IDCT_ADD_REP_FUNC(8, 4, 8, mmxext)
-IDCT_ADD_REP_FUNC(8, 4, 8, sse2)
-IDCT_ADD_REP_FUNC(8, 4, 10, sse2)
-IDCT_ADD_REP_FUNC(8, 4, 10, avx)
-IDCT_ADD_REP_FUNC(, 16, 8, mmx)
-IDCT_ADD_REP_FUNC(, 16, 8, mmxext)
-IDCT_ADD_REP_FUNC(, 16, 8, sse2)
-IDCT_ADD_REP_FUNC(, 16, 10, sse2)
-IDCT_ADD_REP_FUNC(, 16intra, 8, mmx)
-IDCT_ADD_REP_FUNC(, 16intra, 8, mmxext)
-IDCT_ADD_REP_FUNC(, 16intra, 8, sse2)
-IDCT_ADD_REP_FUNC(, 16intra, 10, sse2)
-IDCT_ADD_REP_FUNC(, 16, 10, avx)
-IDCT_ADD_REP_FUNC(, 16intra, 10, avx)
-
-
-#define IDCT_ADD_REP_FUNC2(NUM, REP, DEPTH, OPT) \
-void ff_h264_idct ## NUM ## _add ## REP ## _ ## DEPTH ## _ ## OPT \
- (uint8_t **dst, const int *block_offset, \
- int16_t *block, int stride, const uint8_t nnzc[6 * 8]);
-
-IDCT_ADD_REP_FUNC2(, 8, 8, mmx)
-IDCT_ADD_REP_FUNC2(, 8, 8, mmxext)
-IDCT_ADD_REP_FUNC2(, 8, 8, sse2)
-IDCT_ADD_REP_FUNC2(, 8, 10, sse2)
-IDCT_ADD_REP_FUNC2(, 8, 10, avx)
-
-void ff_h264_luma_dc_dequant_idct_mmx(int16_t *output, int16_t *input, int qmul);
-void ff_h264_luma_dc_dequant_idct_sse2(int16_t *output, int16_t *input, int qmul);
-
-/***********************************/
-/* deblocking */
-
-void ff_h264_loop_filter_strength_mmxext(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);
-
-#define LF_FUNC(DIR, TYPE, DEPTH, OPT) \
-void ff_deblock_ ## DIR ## _ ## TYPE ## _ ## DEPTH ## _ ## OPT(uint8_t *pix, \
- int stride, \
- int alpha, \
- int beta, \
- int8_t *tc0);
-#define LF_IFUNC(DIR, TYPE, DEPTH, OPT) \
-void ff_deblock_ ## DIR ## _ ## TYPE ## _ ## DEPTH ## _ ## OPT(uint8_t *pix, \
- int stride, \
- int alpha, \
- int beta);
-
-#define LF_FUNCS(type, depth) \
-LF_FUNC(h, chroma, depth, mmxext) \
-LF_IFUNC(h, chroma_intra, depth, mmxext) \
-LF_FUNC(v, chroma, depth, mmxext) \
-LF_IFUNC(v, chroma_intra, depth, mmxext) \
-LF_FUNC(h, luma, depth, mmxext) \
-LF_IFUNC(h, luma_intra, depth, mmxext) \
-LF_FUNC(h, luma, depth, sse2) \
-LF_IFUNC(h, luma_intra, depth, sse2) \
-LF_FUNC(v, luma, depth, sse2) \
-LF_IFUNC(v, luma_intra, depth, sse2) \
-LF_FUNC(h, chroma, depth, sse2) \
-LF_IFUNC(h, chroma_intra, depth, sse2) \
-LF_FUNC(v, chroma, depth, sse2) \
-LF_IFUNC(v, chroma_intra, depth, sse2) \
-LF_FUNC(h, luma, depth, avx) \
-LF_IFUNC(h, luma_intra, depth, avx) \
-LF_FUNC(v, luma, depth, avx) \
-LF_IFUNC(v, luma_intra, depth, avx) \
-LF_FUNC(h, chroma, depth, avx) \
-LF_IFUNC(h, chroma_intra, depth, avx) \
-LF_FUNC(v, chroma, depth, avx) \
-LF_IFUNC(v, chroma_intra, depth, avx)
-
-LF_FUNCS(uint8_t, 8)
-LF_FUNCS(uint16_t, 10)
-
-#if ARCH_X86_32 && HAVE_MMXEXT_EXTERNAL
-LF_FUNC(v8, luma, 8, mmxext)
-static void ff_deblock_v_luma_8_mmxext(uint8_t *pix, int stride, int alpha,
- int beta, int8_t *tc0)
-{
- if ((tc0[0] & tc0[1]) >= 0)
- ff_deblock_v8_luma_8_mmxext(pix + 0, stride, alpha, beta, tc0);
- if ((tc0[2] & tc0[3]) >= 0)
- ff_deblock_v8_luma_8_mmxext(pix + 8, stride, alpha, beta, tc0 + 2);
-}
-LF_IFUNC(v8, luma_intra, 8, mmxext)
-static void ff_deblock_v_luma_intra_8_mmxext(uint8_t *pix, int stride,
- int alpha, int beta)
-{
- ff_deblock_v8_luma_intra_8_mmxext(pix + 0, stride, alpha, beta);
- ff_deblock_v8_luma_intra_8_mmxext(pix + 8, stride, alpha, beta);
-}
-#endif /* ARCH_X86_32 && HAVE_MMXEXT_EXTERNAL */
-
-LF_FUNC(v, luma, 10, mmxext)
-LF_IFUNC(v, luma_intra, 10, mmxext)
-
-/***********************************/
-/* weighted prediction */
-
-#define H264_WEIGHT(W, OPT) \
-void ff_h264_weight_ ## W ## _ ## OPT(uint8_t *dst, int stride, \
- int height, int log2_denom, \
- int weight, int offset);
-
-#define H264_BIWEIGHT(W, OPT) \
-void ff_h264_biweight_ ## W ## _ ## OPT(uint8_t *dst, uint8_t *src, \
- int stride, int height, \
- int log2_denom, int weightd, \
- int weights, int offset);
-
-#define H264_BIWEIGHT_MMX(W) \
- H264_WEIGHT(W, mmxext) \
- H264_BIWEIGHT(W, mmxext)
-
-#define H264_BIWEIGHT_MMX_SSE(W) \
- H264_BIWEIGHT_MMX(W) \
- H264_WEIGHT(W, sse2) \
- H264_BIWEIGHT(W, sse2) \
- H264_BIWEIGHT(W, ssse3)
-
-H264_BIWEIGHT_MMX_SSE(16)
-H264_BIWEIGHT_MMX_SSE(8)
-H264_BIWEIGHT_MMX(4)
-
-#define H264_WEIGHT_10(W, DEPTH, OPT) \
-void ff_h264_weight_ ## W ## _ ## DEPTH ## _ ## OPT(uint8_t *dst, \
- int stride, \
- int height, \
- int log2_denom, \
- int weight, \
- int offset);
-
-#define H264_BIWEIGHT_10(W, DEPTH, OPT) \
-void ff_h264_biweight_ ## W ## _ ## DEPTH ## _ ## OPT(uint8_t *dst, \
- uint8_t *src, \
- int stride, \
- int height, \
- int log2_denom, \
- int weightd, \
- int weights, \
- int offset);
-
-#define H264_BIWEIGHT_10_SSE(W, DEPTH) \
- H264_WEIGHT_10(W, DEPTH, sse2) \
- H264_WEIGHT_10(W, DEPTH, sse4) \
- H264_BIWEIGHT_10(W, DEPTH, sse2) \
- H264_BIWEIGHT_10(W, DEPTH, sse4)
-
-H264_BIWEIGHT_10_SSE(16, 10)
-H264_BIWEIGHT_10_SSE(8, 10)
-H264_BIWEIGHT_10_SSE(4, 10)
-
-av_cold void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth,
- const int chroma_format_idc)
-{
-#if HAVE_YASM
- int mm_flags = av_get_cpu_flags();
-
- if (chroma_format_idc == 1 && EXTERNAL_MMXEXT(mm_flags))
- c->h264_loop_filter_strength = ff_h264_loop_filter_strength_mmxext;
-
- if (bit_depth == 8) {
- if (EXTERNAL_MMX(mm_flags)) {
- c->h264_idct_dc_add =
- c->h264_idct_add = ff_h264_idct_add_8_mmx;
- c->h264_idct8_dc_add =
- c->h264_idct8_add = ff_h264_idct8_add_8_mmx;
-
- 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)
- c->h264_idct_add8 = ff_h264_idct_add8_8_mmx;
- c->h264_idct_add16intra = ff_h264_idct_add16intra_8_mmx;
- if (mm_flags & AV_CPU_FLAG_CMOV)
- c->h264_luma_dc_dequant_idct = ff_h264_luma_dc_dequant_idct_mmx;
-
- if (EXTERNAL_MMXEXT(mm_flags)) {
- c->h264_idct_dc_add = ff_h264_idct_dc_add_8_mmxext;
- 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)
- 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) {
- 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;
- }
-#if ARCH_X86_32 && HAVE_MMXEXT_EXTERNAL
- c->h264_v_loop_filter_luma = ff_deblock_v_luma_8_mmxext;
- c->h264_h_loop_filter_luma = ff_deblock_h_luma_8_mmxext;
- c->h264_v_loop_filter_luma_intra = ff_deblock_v_luma_intra_8_mmxext;
- c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_8_mmxext;
-#endif /* ARCH_X86_32 && HAVE_MMXEXT_EXTERNAL */
- c->weight_h264_pixels_tab[0] = ff_h264_weight_16_mmxext;
- c->weight_h264_pixels_tab[1] = ff_h264_weight_8_mmxext;
- c->weight_h264_pixels_tab[2] = ff_h264_weight_4_mmxext;
-
- c->biweight_h264_pixels_tab[0] = ff_h264_biweight_16_mmxext;
- c->biweight_h264_pixels_tab[1] = ff_h264_biweight_8_mmxext;
- c->biweight_h264_pixels_tab[2] = ff_h264_biweight_4_mmxext;
-
- if (EXTERNAL_SSE2(mm_flags)) {
- c->h264_idct8_add = ff_h264_idct8_add_8_sse2;
-
- 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)
- 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;
-
- c->weight_h264_pixels_tab[0] = ff_h264_weight_16_sse2;
- c->weight_h264_pixels_tab[1] = ff_h264_weight_8_sse2;
-
- c->biweight_h264_pixels_tab[0] = ff_h264_biweight_16_sse2;
- c->biweight_h264_pixels_tab[1] = ff_h264_biweight_8_sse2;
-
- c->h264_v_loop_filter_luma = ff_deblock_v_luma_8_sse2;
- c->h264_h_loop_filter_luma = ff_deblock_h_luma_8_sse2;
- c->h264_v_loop_filter_luma_intra = ff_deblock_v_luma_intra_8_sse2;
- c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_8_sse2;
- }
- if (EXTERNAL_SSSE3(mm_flags)) {
- c->biweight_h264_pixels_tab[0] = ff_h264_biweight_16_ssse3;
- c->biweight_h264_pixels_tab[1] = ff_h264_biweight_8_ssse3;
- }
- if (EXTERNAL_AVX(mm_flags)) {
- c->h264_v_loop_filter_luma = ff_deblock_v_luma_8_avx;
- c->h264_h_loop_filter_luma = ff_deblock_h_luma_8_avx;
- c->h264_v_loop_filter_luma_intra = ff_deblock_v_luma_intra_8_avx;
- c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_8_avx;
- }
- }
- }
- } else if (bit_depth == 10) {
- if (EXTERNAL_MMX(mm_flags)) {
- if (EXTERNAL_MMXEXT(mm_flags)) {
-#if ARCH_X86_32
- c->h264_v_loop_filter_chroma = ff_deblock_v_chroma_10_mmxext;
- c->h264_v_loop_filter_chroma_intra = ff_deblock_v_chroma_intra_10_mmxext;
- c->h264_v_loop_filter_luma = ff_deblock_v_luma_10_mmxext;
- c->h264_h_loop_filter_luma = ff_deblock_h_luma_10_mmxext;
- c->h264_v_loop_filter_luma_intra = ff_deblock_v_luma_intra_10_mmxext;
- c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_10_mmxext;
-#endif /* ARCH_X86_32 */
- c->h264_idct_dc_add = ff_h264_idct_dc_add_10_mmxext;
- if (EXTERNAL_SSE2(mm_flags)) {
- c->h264_idct_add = ff_h264_idct_add_10_sse2;
- 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)
- c->h264_idct_add8 = ff_h264_idct_add8_10_sse2;
- c->h264_idct_add16intra = ff_h264_idct_add16intra_10_sse2;
-#if HAVE_ALIGNED_STACK
- c->h264_idct8_add = ff_h264_idct8_add_10_sse2;
- c->h264_idct8_add4 = ff_h264_idct8_add4_10_sse2;
-#endif /* HAVE_ALIGNED_STACK */
-
- c->weight_h264_pixels_tab[0] = ff_h264_weight_16_10_sse2;
- c->weight_h264_pixels_tab[1] = ff_h264_weight_8_10_sse2;
- c->weight_h264_pixels_tab[2] = ff_h264_weight_4_10_sse2;
-
- c->biweight_h264_pixels_tab[0] = ff_h264_biweight_16_10_sse2;
- c->biweight_h264_pixels_tab[1] = ff_h264_biweight_8_10_sse2;
- c->biweight_h264_pixels_tab[2] = ff_h264_biweight_4_10_sse2;
-
- c->h264_v_loop_filter_chroma = ff_deblock_v_chroma_10_sse2;
- c->h264_v_loop_filter_chroma_intra = ff_deblock_v_chroma_intra_10_sse2;
-#if HAVE_ALIGNED_STACK
- c->h264_v_loop_filter_luma = ff_deblock_v_luma_10_sse2;
- c->h264_h_loop_filter_luma = ff_deblock_h_luma_10_sse2;
- c->h264_v_loop_filter_luma_intra = ff_deblock_v_luma_intra_10_sse2;
- c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_10_sse2;
-#endif /* HAVE_ALIGNED_STACK */
- }
- if (EXTERNAL_SSE4(mm_flags)) {
- c->weight_h264_pixels_tab[0] = ff_h264_weight_16_10_sse4;
- c->weight_h264_pixels_tab[1] = ff_h264_weight_8_10_sse4;
- c->weight_h264_pixels_tab[2] = ff_h264_weight_4_10_sse4;
-
- c->biweight_h264_pixels_tab[0] = ff_h264_biweight_16_10_sse4;
- c->biweight_h264_pixels_tab[1] = ff_h264_biweight_8_10_sse4;
- c->biweight_h264_pixels_tab[2] = ff_h264_biweight_4_10_sse4;
- }
- if (EXTERNAL_AVX(mm_flags)) {
- c->h264_idct_dc_add =
- c->h264_idct_add = ff_h264_idct_add_10_avx;
- 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)
- c->h264_idct_add8 = ff_h264_idct_add8_10_avx;
- c->h264_idct_add16intra = ff_h264_idct_add16intra_10_avx;
-#if HAVE_ALIGNED_STACK
- c->h264_idct8_add = ff_h264_idct8_add_10_avx;
- c->h264_idct8_add4 = ff_h264_idct8_add4_10_avx;
-#endif /* HAVE_ALIGNED_STACK */
-
- c->h264_v_loop_filter_chroma = ff_deblock_v_chroma_10_avx;
- c->h264_v_loop_filter_chroma_intra = ff_deblock_v_chroma_intra_10_avx;
-#if HAVE_ALIGNED_STACK
- c->h264_v_loop_filter_luma = ff_deblock_v_luma_10_avx;
- c->h264_h_loop_filter_luma = ff_deblock_h_luma_10_avx;
- c->h264_v_loop_filter_luma_intra = ff_deblock_v_luma_intra_10_avx;
- c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_10_avx;
-#endif /* HAVE_ALIGNED_STACK */
- }
- }
- }
- }
-#endif
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/hpeldsp.asm b/src/thirdparty/ffmpeg/libavcodec/x86/hpeldsp.asm
deleted file mode 100644
index c83c38870..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/hpeldsp.asm
+++ /dev/null
@@ -1,502 +0,0 @@
-;******************************************************************************
-;*
-;* Copyright (c) 2000-2001 Fabrice Bellard <fabrice@bellard.org>
-;* Copyright (c) Nick Kurshev <nickols_k@mail.ru>
-;* Copyright (c) 2002 Michael Niedermayer <michaelni@gmx.at>
-;* Copyright (c) 2002 Zdenek Kabelac <kabi@informatics.muni.cz>
-;* Copyright (c) 2013 Daniel Kang
-;*
-;* MMX optimized hpel 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 "libavutil/x86/x86util.asm"
-
-SECTION_RODATA
-cextern pb_1
-
-SECTION_TEXT
-
-; 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]
-.loop:
- mova m0, [r1]
- mova m1, [r1+r2]
- PAVGB m0, [r1+1]
- PAVGB m1, [r1+r2+1]
- mova [r0], m0
- mova [r0+r2], m1
- add r1, r4
- add r0, r4
- mova m0, [r1]
- mova m1, [r1+r2]
- PAVGB m0, [r1+1]
- PAVGB m1, [r1+r2+1]
- add r1, r4
- mova [r0], m0
- mova [r0+r2], m1
- add r0, r4
- sub r3d, 4
- jne .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-PUT_PIXELS8_X2
-INIT_MMX 3dnow
-PUT_PIXELS8_X2
-
-
-; 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]
-.loop:
- mova m0, [r1]
- mova m1, [r1+r2]
- mova m2, [r1+8]
- mova m3, [r1+r2+8]
- PAVGB m0, [r1+1]
- PAVGB m1, [r1+r2+1]
- PAVGB m2, [r1+9]
- PAVGB m3, [r1+r2+9]
- mova [r0], m0
- mova [r0+r2], m1
- mova [r0+8], m2
- mova [r0+r2+8], m3
- add r1, r4
- add r0, r4
- mova m0, [r1]
- mova m1, [r1+r2]
- mova m2, [r1+8]
- mova m3, [r1+r2+8]
- PAVGB m0, [r1+1]
- PAVGB m1, [r1+r2+1]
- PAVGB m2, [r1+9]
- PAVGB m3, [r1+r2+9]
- add r1, r4
- mova [r0], m0
- mova [r0+r2], m1
- mova [r0+8], m2
- mova [r0+r2+8], m3
- add r0, r4
- sub r3d, 4
- jne .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-PUT_PIXELS_16
-INIT_MMX 3dnow
-PUT_PIXELS_16
-
-
-; 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]
- lea r4, [r2*2]
-.loop:
- mova m0, [r1]
- mova m2, [r1+r2]
- mova m1, [r1+1]
- mova m3, [r1+r2+1]
- add r1, r4
- psubusb m0, m6
- psubusb m2, m6
- PAVGB m0, m1
- PAVGB m2, m3
- mova [r0], m0
- mova [r0+r2], m2
- mova m0, [r1]
- mova m1, [r1+1]
- mova m2, [r1+r2]
- mova m3, [r1+r2+1]
- add r0, r4
- add r1, r4
- psubusb m0, m6
- psubusb m2, m6
- PAVGB m0, m1
- PAVGB m2, m3
- mova [r0], m0
- mova [r0+r2], m2
- add r0, r4
- sub r3d, 4
- jne .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-PUT_NO_RND_PIXELS8_X2
-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)
-%macro PUT_NO_RND_PIXELS8_X2_EXACT 0
-cglobal put_no_rnd_pixels8_x2_exact, 4,5
- lea r4, [r2*3]
- pcmpeqb m6, m6
-.loop:
- mova m0, [r1]
- mova m2, [r1+r2]
- mova m1, [r1+1]
- mova m3, [r1+r2+1]
- pxor m0, m6
- pxor m2, m6
- pxor m1, m6
- pxor m3, m6
- PAVGB m0, m1
- PAVGB m2, m3
- pxor m0, m6
- pxor m2, m6
- mova [r0], m0
- mova [r0+r2], m2
- mova m0, [r1+r2*2]
- mova m1, [r1+r2*2+1]
- mova m2, [r1+r4]
- mova m3, [r1+r4+1]
- pxor m0, m6
- pxor m1, m6
- pxor m2, m6
- pxor m3, m6
- PAVGB m0, m1
- PAVGB m2, m3
- pxor m0, m6
- pxor m2, m6
- mova [r0+r2*2], m0
- mova [r0+r4], m2
- lea r1, [r1+r2*4]
- lea r0, [r0+r2*4]
- sub r3d, 4
- jg .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-PUT_NO_RND_PIXELS8_X2_EXACT
-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)
-%macro PUT_PIXELS8_Y2 0
-cglobal put_pixels8_y2, 4,5
- lea r4, [r2*2]
- mova m0, [r1]
- sub r0, r2
-.loop:
- mova m1, [r1+r2]
- mova m2, [r1+r4]
- add r1, r4
- PAVGB m0, m1
- PAVGB m1, m2
- mova [r0+r2], m0
- mova [r0+r4], m1
- mova m1, [r1+r2]
- mova m0, [r1+r4]
- add r0, r4
- add r1, r4
- PAVGB m2, m1
- PAVGB m1, m0
- mova [r0+r2], m2
- mova [r0+r4], m1
- add r0, r4
- sub r3d, 4
- jne .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-PUT_PIXELS8_Y2
-INIT_MMX 3dnow
-PUT_PIXELS8_Y2
-
-
-; 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]
- lea r4, [r2+r2]
- mova m0, [r1]
- sub r0, r2
-.loop:
- mova m1, [r1+r2]
- mova m2, [r1+r4]
- add r1, r4
- psubusb m1, m6
- PAVGB m0, m1
- PAVGB m1, m2
- mova [r0+r2], m0
- mova [r0+r4], m1
- mova m1, [r1+r2]
- mova m0, [r1+r4]
- add r0, r4
- add r1, r4
- psubusb m1, m6
- PAVGB m2, m1
- PAVGB m1, m0
- mova [r0+r2], m2
- mova [r0+r4], m1
- add r0, r4
- sub r3d, 4
- jne .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-PUT_NO_RND_PIXELS8_Y2
-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)
-%macro PUT_NO_RND_PIXELS8_Y2_EXACT 0
-cglobal put_no_rnd_pixels8_y2_exact, 4,5
- lea r4, [r2*3]
- mova m0, [r1]
- pcmpeqb m6, m6
- add r1, r2
- pxor m0, m6
-.loop:
- mova m1, [r1]
- mova m2, [r1+r2]
- pxor m1, m6
- pxor m2, m6
- PAVGB m0, m1
- PAVGB m1, m2
- pxor m0, m6
- pxor m1, m6
- mova [r0], m0
- mova [r0+r2], m1
- mova m1, [r1+r2*2]
- mova m0, [r1+r4]
- pxor m1, m6
- pxor m0, m6
- PAVGB m2, m1
- PAVGB m1, m0
- pxor m2, m6
- pxor m1, m6
- mova [r0+r2*2], m2
- mova [r0+r4], m1
- lea r1, [r1+r2*4]
- lea r0, [r0+r2*4]
- sub r3d, 4
- jg .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-PUT_NO_RND_PIXELS8_Y2_EXACT
-INIT_MMX 3dnow
-PUT_NO_RND_PIXELS8_Y2_EXACT
-
-
-; 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]
-.loop:
- mova m0, [r0]
- mova m1, [r0+r2]
- PAVGB m0, [r1]
- PAVGB m1, [r1+r2]
- mova [r0], m0
- mova [r0+r2], m1
- add r1, r4
- add r0, r4
- mova m0, [r0]
- mova m1, [r0+r2]
- PAVGB m0, [r1]
- PAVGB m1, [r1+r2]
- add r1, r4
- mova [r0], m0
- mova [r0+r2], m1
- add r0, r4
- sub r3d, 4
- jne .loop
- REP_RET
-%endmacro
-
-INIT_MMX 3dnow
-AVG_PIXELS8
-
-
-; 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]
-.loop:
- mova m0, [r1]
- mova m2, [r1+r2]
- PAVGB m0, [r1+1]
- PAVGB m2, [r1+r2+1]
- PAVGB m0, [r0]
- PAVGB m2, [r0+r2]
- add r1, r4
- mova [r0], m0
- mova [r0+r2], m2
- mova m0, [r1]
- mova m2, [r1+r2]
- PAVGB m0, [r1+1]
- PAVGB m2, [r1+r2+1]
- add r0, r4
- add r1, r4
- PAVGB m0, [r0]
- PAVGB m2, [r0+r2]
- mova [r0], m0
- mova [r0+r2], m2
- add r0, r4
- sub r3d, 4
- jne .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-AVG_PIXELS8_X2
-INIT_MMX 3dnow
-AVG_PIXELS8_X2
-
-
-; 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]
- mova m0, [r1]
- sub r0, r2
-.loop:
- mova m1, [r1+r2]
- mova m2, [r1+r4]
- add r1, r4
- PAVGB m0, m1
- PAVGB m1, m2
- mova m3, [r0+r2]
- mova m4, [r0+r4]
- PAVGB m0, m3
- PAVGB m1, m4
- mova [r0+r2], m0
- mova [r0+r4], m1
- mova m1, [r1+r2]
- mova m0, [r1+r4]
- PAVGB m2, m1
- PAVGB m1, m0
- add r0, r4
- add r1, r4
- mova m3, [r0+r2]
- mova m4, [r0+r4]
- PAVGB m2, m3
- PAVGB m1, m4
- mova [r0+r2], m2
- mova [r0+r4], m1
- add r0, r4
- sub r3d, 4
- jne .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-AVG_PIXELS8_Y2
-INIT_MMX 3dnow
-AVG_PIXELS8_Y2
-
-
-; 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]
- lea r4, [r2*2]
- mova m0, [r1]
- pavgb m0, [r1+1]
-.loop:
- mova m2, [r1+r4]
- mova m1, [r1+r2]
- psubusb m2, m6
- pavgb m1, [r1+r2+1]
- pavgb m2, [r1+r4+1]
- add r1, r4
- pavgb m0, m1
- pavgb m1, m2
- pavgb m0, [r0]
- pavgb m1, [r0+r2]
- mova [r0], m0
- mova [r0+r2], m1
- mova m1, [r1+r2]
- mova m0, [r1+r4]
- pavgb m1, [r1+r2+1]
- pavgb m0, [r1+r4+1]
- add r0, r4
- add r1, r4
- pavgb m2, m1
- pavgb m1, m0
- pavgb m2, [r0]
- pavgb m1, [r0+r2]
- mova [r0], m2
- mova [r0+r2], m1
- add r0, r4
- sub r3d, 4
- jne .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-AVG_PIXELS8_XY2
-INIT_MMX 3dnow
-AVG_PIXELS8_XY2
-
-INIT_XMM sse2
-; void 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:
- movu m0, [r1]
- movu m1, [r1+r2]
- movu m2, [r1+r2*2]
- movu m3, [r1+r4]
- lea r1, [r1+r2*4]
- mova [r0], m0
- mova [r0+r2], m1
- mova [r0+r2*2], m2
- mova [r0+r4], m3
- sub r3d, 4
- lea r0, [r0+r2*4]
- jnz .loop
- REP_RET
-
-; void 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:
- movu m0, [r1]
- movu m1, [r1+r2]
- movu m2, [r1+r2*2]
- movu m3, [r1+r4]
- lea r1, [r1+r2*4]
- pavgb m0, [r0]
- pavgb m1, [r0+r2]
- pavgb m2, [r0+r2*2]
- pavgb m3, [r0+r4]
- mova [r0], m0
- mova [r0+r2], m1
- mova [r0+r2*2], m2
- mova [r0+r4], m3
- sub r3d, 4
- lea r0, [r0+r2*4]
- jnz .loop
- REP_RET
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/idct_mmx.c b/src/thirdparty/ffmpeg/libavcodec/x86/idct_mmx.c
deleted file mode 100644
index 66ab8234a..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/idct_mmx.c
+++ /dev/null
@@ -1,632 +0,0 @@
-/*
- * Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
- *
- * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
- * See http://libmpeg2.sourceforge.net/ for updates.
- *
- * mpeg2dec is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * mpeg2dec 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with mpeg2dec; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/common.h"
-#include "libavcodec/dsputil.h"
-
-#include "libavutil/x86/asm.h"
-#include "dsputil_mmx.h"
-
-#if HAVE_INLINE_ASM
-
-#define ROW_SHIFT 11
-#define COL_SHIFT 6
-
-#define round(bias) ((int)(((bias)+0.5) * (1<<ROW_SHIFT)))
-#define rounder(bias) {round (bias), round (bias)}
-
-
-#if 0
-/* C row IDCT - it is just here to document the MMXEXT and MMX versions */
-static inline void idct_row (int16_t * row, int offset,
- int16_t * table, int32_t * rounder)
-{
- int C1, C2, C3, C4, C5, C6, C7;
- int a0, a1, a2, a3, b0, b1, b2, b3;
-
- row += offset;
-
- C1 = table[1];
- C2 = table[2];
- C3 = table[3];
- C4 = table[4];
- C5 = table[5];
- C6 = table[6];
- C7 = table[7];
-
- a0 = C4*row[0] + C2*row[2] + C4*row[4] + C6*row[6] + *rounder;
- a1 = C4*row[0] + C6*row[2] - C4*row[4] - C2*row[6] + *rounder;
- a2 = C4*row[0] - C6*row[2] - C4*row[4] + C2*row[6] + *rounder;
- a3 = C4*row[0] - C2*row[2] + C4*row[4] - C6*row[6] + *rounder;
-
- b0 = C1*row[1] + C3*row[3] + C5*row[5] + C7*row[7];
- b1 = C3*row[1] - C7*row[3] - C1*row[5] - C5*row[7];
- b2 = C5*row[1] - C1*row[3] + C7*row[5] + C3*row[7];
- b3 = C7*row[1] - C5*row[3] + C3*row[5] - C1*row[7];
-
- row[0] = (a0 + b0) >> ROW_SHIFT;
- row[1] = (a1 + b1) >> ROW_SHIFT;
- row[2] = (a2 + b2) >> ROW_SHIFT;
- row[3] = (a3 + b3) >> ROW_SHIFT;
- row[4] = (a3 - b3) >> ROW_SHIFT;
- row[5] = (a2 - b2) >> ROW_SHIFT;
- row[6] = (a1 - b1) >> ROW_SHIFT;
- row[7] = (a0 - b0) >> ROW_SHIFT;
-}
-#endif
-
-
-/* MMXEXT row IDCT */
-
-#define mmxext_table(c1,c2,c3,c4,c5,c6,c7) { c4, c2, -c4, -c2, \
- c4, c6, c4, c6, \
- c1, c3, -c1, -c5, \
- c5, c7, c3, -c7, \
- c4, -c6, c4, -c6, \
- -c4, c2, c4, -c2, \
- c5, -c1, c3, -c1, \
- c7, c3, c7, -c5 }
-
-static inline void mmxext_row_head (int16_t * const row, const int offset,
- const int16_t * const table)
-{
- __asm__ volatile(
- "movq (%0), %%mm2 \n\t" /* mm2 = x6 x4 x2 x0 */
-
- "movq 8(%0), %%mm5 \n\t" /* mm5 = x7 x5 x3 x1 */
- "movq %%mm2, %%mm0 \n\t" /* mm0 = x6 x4 x2 x0 */
-
- "movq (%1), %%mm3 \n\t" /* mm3 = -C2 -C4 C2 C4 */
- "movq %%mm5, %%mm6 \n\t" /* mm6 = x7 x5 x3 x1 */
-
- "movq 8(%1), %%mm4 \n\t" /* mm4 = C6 C4 C6 C4 */
- "pmaddwd %%mm0, %%mm3 \n\t" /* mm3 = -C4*x4-C2*x6 C4*x0+C2*x2 */
-
- "pshufw $0x4e, %%mm2, %%mm2 \n\t" /* mm2 = x2 x0 x6 x4 */
- :: "r" ((row+offset)), "r" (table)
- );
-}
-
-static inline void mmxext_row (const int16_t * const table,
- const int32_t * const rounder)
-{
- __asm__ volatile (
- "movq 16(%0), %%mm1 \n\t" /* mm1 = -C5 -C1 C3 C1 */
- "pmaddwd %%mm2, %%mm4 \n\t" /* mm4 = C4*x0+C6*x2 C4*x4+C6*x6 */
-
- "pmaddwd 32(%0), %%mm0 \n\t" /* mm0 = C4*x4-C6*x6 C4*x0-C6*x2 */
- "pshufw $0x4e, %%mm6, %%mm6 \n\t" /* mm6 = x3 x1 x7 x5 */
-
- "movq 24(%0), %%mm7 \n\t" /* mm7 = -C7 C3 C7 C5 */
- "pmaddwd %%mm5, %%mm1 \n\t" /* mm1= -C1*x5-C5*x7 C1*x1+C3*x3 */
-
- "paddd (%1), %%mm3 \n\t" /* mm3 += rounder */
- "pmaddwd %%mm6, %%mm7 \n\t" /* mm7 = C3*x1-C7*x3 C5*x5+C7*x7 */
-
- "pmaddwd 40(%0), %%mm2 \n\t" /* mm2= C4*x0-C2*x2 -C4*x4+C2*x6 */
- "paddd %%mm4, %%mm3 \n\t" /* mm3 = a1 a0 + rounder */
-
- "pmaddwd 48(%0), %%mm5 \n\t" /* mm5 = C3*x5-C1*x7 C5*x1-C1*x3 */
- "movq %%mm3, %%mm4 \n\t" /* mm4 = a1 a0 + rounder */
-
- "pmaddwd 56(%0), %%mm6 \n\t" /* mm6 = C7*x1-C5*x3 C7*x5+C3*x7 */
- "paddd %%mm7, %%mm1 \n\t" /* mm1 = b1 b0 */
-
- "paddd (%1), %%mm0 \n\t" /* mm0 += rounder */
- "psubd %%mm1, %%mm3 \n\t" /* mm3 = a1-b1 a0-b0 + rounder */
-
- "psrad $" AV_STRINGIFY(ROW_SHIFT) ", %%mm3 \n\t" /* mm3 = y6 y7 */
- "paddd %%mm4, %%mm1 \n\t" /* mm1 = a1+b1 a0+b0 + rounder */
-
- "paddd %%mm2, %%mm0 \n\t" /* mm0 = a3 a2 + rounder */
- "psrad $" AV_STRINGIFY(ROW_SHIFT) ", %%mm1 \n\t" /* mm1 = y1 y0 */
-
- "paddd %%mm6, %%mm5 \n\t" /* mm5 = b3 b2 */
- "movq %%mm0, %%mm4 \n\t" /* mm4 = a3 a2 + rounder */
-
- "paddd %%mm5, %%mm0 \n\t" /* mm0 = a3+b3 a2+b2 + rounder */
- "psubd %%mm5, %%mm4 \n\t" /* mm4 = a3-b3 a2-b2 + rounder */
- : : "r" (table), "r" (rounder));
-}
-
-static inline void mmxext_row_tail (int16_t * const row, const int store)
-{
- __asm__ volatile (
- "psrad $" AV_STRINGIFY(ROW_SHIFT) ", %%mm0 \n\t" /* mm0 = y3 y2 */
-
- "psrad $" AV_STRINGIFY(ROW_SHIFT) ", %%mm4 \n\t" /* mm4 = y4 y5 */
-
- "packssdw %%mm0, %%mm1 \n\t" /* mm1 = y3 y2 y1 y0 */
-
- "packssdw %%mm3, %%mm4 \n\t" /* mm4 = y6 y7 y4 y5 */
-
- "movq %%mm1, (%0) \n\t" /* save y3 y2 y1 y0 */
- "pshufw $0xb1, %%mm4, %%mm4 \n\t" /* mm4 = y7 y6 y5 y4 */
-
- /* slot */
-
- "movq %%mm4, 8(%0) \n\t" /* save y7 y6 y5 y4 */
- :: "r" (row+store)
- );
-}
-
-static inline void mmxext_row_mid (int16_t * const row, const int store,
- const int offset,
- const int16_t * const table)
-{
- __asm__ volatile (
- "movq (%0,%1), %%mm2 \n\t" /* mm2 = x6 x4 x2 x0 */
- "psrad $" AV_STRINGIFY(ROW_SHIFT) ", %%mm0 \n\t" /* mm0 = y3 y2 */
-
- "movq 8(%0,%1), %%mm5 \n\t" /* mm5 = x7 x5 x3 x1 */
- "psrad $" AV_STRINGIFY(ROW_SHIFT) ", %%mm4 \n\t" /* mm4 = y4 y5 */
-
- "packssdw %%mm0, %%mm1 \n\t" /* mm1 = y3 y2 y1 y0 */
- "movq %%mm5, %%mm6 \n\t" /* mm6 = x7 x5 x3 x1 */
-
- "packssdw %%mm3, %%mm4 \n\t" /* mm4 = y6 y7 y4 y5 */
- "movq %%mm2, %%mm0 \n\t" /* mm0 = x6 x4 x2 x0 */
-
- "movq %%mm1, (%0,%2) \n\t" /* save y3 y2 y1 y0 */
- "pshufw $0xb1, %%mm4, %%mm4\n\t" /* mm4 = y7 y6 y5 y4 */
-
- "movq (%3), %%mm3 \n\t" /* mm3 = -C2 -C4 C2 C4 */
- "movq %%mm4, 8(%0,%2) \n\t" /* save y7 y6 y5 y4 */
-
- "pmaddwd %%mm0, %%mm3 \n\t" /* mm3= -C4*x4-C2*x6 C4*x0+C2*x2 */
-
- "movq 8(%3), %%mm4 \n\t" /* mm4 = C6 C4 C6 C4 */
- "pshufw $0x4e, %%mm2, %%mm2\n\t" /* mm2 = x2 x0 x6 x4 */
- :: "r" (row), "r" ((x86_reg) (2*offset)), "r" ((x86_reg) (2*store)), "r" (table)
- );
-}
-
-
-/* MMX row IDCT */
-
-#define mmx_table(c1,c2,c3,c4,c5,c6,c7) { c4, c2, c4, c6, \
- c4, c6, -c4, -c2, \
- c1, c3, c3, -c7, \
- c5, c7, -c1, -c5, \
- c4, -c6, c4, -c2, \
- -c4, c2, c4, -c6, \
- c5, -c1, c7, -c5, \
- c7, c3, c3, -c1 }
-
-static inline void mmx_row_head (int16_t * const row, const int offset,
- const int16_t * const table)
-{
- __asm__ volatile (
- "movq (%0), %%mm2 \n\t" /* mm2 = x6 x4 x2 x0 */
-
- "movq 8(%0), %%mm5 \n\t" /* mm5 = x7 x5 x3 x1 */
- "movq %%mm2, %%mm0 \n\t" /* mm0 = x6 x4 x2 x0 */
-
- "movq (%1), %%mm3 \n\t" /* mm3 = C6 C4 C2 C4 */
- "movq %%mm5, %%mm6 \n\t" /* mm6 = x7 x5 x3 x1 */
-
- "punpckldq %%mm0, %%mm0 \n\t" /* mm0 = x2 x0 x2 x0 */
-
- "movq 8(%1), %%mm4 \n\t" /* mm4 = -C2 -C4 C6 C4 */
- "pmaddwd %%mm0, %%mm3 \n\t" /* mm3 = C4*x0+C6*x2 C4*x0+C2*x2 */
-
- "movq 16(%1), %%mm1 \n\t" /* mm1 = -C7 C3 C3 C1 */
- "punpckhdq %%mm2, %%mm2 \n\t" /* mm2 = x6 x4 x6 x4 */
- :: "r" ((row+offset)), "r" (table)
- );
-}
-
-static inline void mmx_row (const int16_t * const table,
- const int32_t * const rounder)
-{
- __asm__ volatile (
- "pmaddwd %%mm2, %%mm4 \n\t" /* mm4 = -C4*x4-C2*x6 C4*x4+C6*x6 */
- "punpckldq %%mm5, %%mm5 \n\t" /* mm5 = x3 x1 x3 x1 */
-
- "pmaddwd 32(%0), %%mm0 \n\t" /* mm0 = C4*x0-C2*x2 C4*x0-C6*x2 */
- "punpckhdq %%mm6, %%mm6 \n\t" /* mm6 = x7 x5 x7 x5 */
-
- "movq 24(%0), %%mm7 \n\t" /* mm7 = -C5 -C1 C7 C5 */
- "pmaddwd %%mm5, %%mm1 \n\t" /* mm1 = C3*x1-C7*x3 C1*x1+C3*x3 */
-
- "paddd (%1), %%mm3 \n\t" /* mm3 += rounder */
- "pmaddwd %%mm6, %%mm7 \n\t" /* mm7 = -C1*x5-C5*x7 C5*x5+C7*x7 */
-
- "pmaddwd 40(%0), %%mm2 \n\t" /* mm2 = C4*x4-C6*x6 -C4*x4+C2*x6 */
- "paddd %%mm4, %%mm3 \n\t" /* mm3 = a1 a0 + rounder */
-
- "pmaddwd 48(%0), %%mm5 \n\t" /* mm5 = C7*x1-C5*x3 C5*x1-C1*x3 */
- "movq %%mm3, %%mm4 \n\t" /* mm4 = a1 a0 + rounder */
-
- "pmaddwd 56(%0), %%mm6 \n\t" /* mm6 = C3*x5-C1*x7 C7*x5+C3*x7 */
- "paddd %%mm7, %%mm1 \n\t" /* mm1 = b1 b0 */
-
- "paddd (%1), %%mm0 \n\t" /* mm0 += rounder */
- "psubd %%mm1, %%mm3 \n\t" /* mm3 = a1-b1 a0-b0 + rounder */
-
- "psrad $" AV_STRINGIFY(ROW_SHIFT) ", %%mm3 \n\t" /* mm3 = y6 y7 */
- "paddd %%mm4, %%mm1 \n\t" /* mm1 = a1+b1 a0+b0 + rounder */
-
- "paddd %%mm2, %%mm0 \n\t" /* mm0 = a3 a2 + rounder */
- "psrad $" AV_STRINGIFY(ROW_SHIFT) ", %%mm1 \n\t" /* mm1 = y1 y0 */
-
- "paddd %%mm6, %%mm5 \n\t" /* mm5 = b3 b2 */
- "movq %%mm0, %%mm7 \n\t" /* mm7 = a3 a2 + rounder */
-
- "paddd %%mm5, %%mm0 \n\t" /* mm0 = a3+b3 a2+b2 + rounder */
- "psubd %%mm5, %%mm7 \n\t" /* mm7 = a3-b3 a2-b2 + rounder */
- :: "r" (table), "r" (rounder)
- );
-}
-
-static inline void mmx_row_tail (int16_t * const row, const int store)
-{
- __asm__ volatile (
- "psrad $" AV_STRINGIFY(ROW_SHIFT) ", %%mm0 \n\t" /* mm0 = y3 y2 */
-
- "psrad $" AV_STRINGIFY(ROW_SHIFT) ", %%mm7 \n\t" /* mm7 = y4 y5 */
-
- "packssdw %%mm0, %%mm1 \n\t" /* mm1 = y3 y2 y1 y0 */
-
- "packssdw %%mm3, %%mm7 \n\t" /* mm7 = y6 y7 y4 y5 */
-
- "movq %%mm1, (%0) \n\t" /* save y3 y2 y1 y0 */
- "movq %%mm7, %%mm4 \n\t" /* mm4 = y6 y7 y4 y5 */
-
- "pslld $16, %%mm7 \n\t" /* mm7 = y7 0 y5 0 */
-
- "psrld $16, %%mm4 \n\t" /* mm4 = 0 y6 0 y4 */
-
- "por %%mm4, %%mm7 \n\t" /* mm7 = y7 y6 y5 y4 */
-
- /* slot */
-
- "movq %%mm7, 8(%0) \n\t" /* save y7 y6 y5 y4 */
- :: "r" (row+store)
- );
-}
-
-static inline void mmx_row_mid (int16_t * const row, const int store,
- const int offset, const int16_t * const table)
-{
-
- __asm__ volatile (
- "movq (%0,%1), %%mm2 \n\t" /* mm2 = x6 x4 x2 x0 */
- "psrad $" AV_STRINGIFY(ROW_SHIFT) ", %%mm0 \n\t" /* mm0 = y3 y2 */
-
- "movq 8(%0,%1), %%mm5 \n\t" /* mm5 = x7 x5 x3 x1 */
- "psrad $" AV_STRINGIFY(ROW_SHIFT) ", %%mm7 \n\t" /* mm7 = y4 y5 */
-
- "packssdw %%mm0, %%mm1 \n\t" /* mm1 = y3 y2 y1 y0 */
- "movq %%mm5, %%mm6 \n\t" /* mm6 = x7 x5 x3 x1 */
-
- "packssdw %%mm3, %%mm7 \n\t" /* mm7 = y6 y7 y4 y5 */
- "movq %%mm2, %%mm0 \n\t" /* mm0 = x6 x4 x2 x0 */
-
- "movq %%mm1, (%0,%2) \n\t" /* save y3 y2 y1 y0 */
- "movq %%mm7, %%mm1 \n\t" /* mm1 = y6 y7 y4 y5 */
-
- "punpckldq %%mm0, %%mm0 \n\t" /* mm0 = x2 x0 x2 x0 */
- "psrld $16, %%mm7 \n\t" /* mm7 = 0 y6 0 y4 */
-
- "movq (%3), %%mm3 \n\t" /* mm3 = C6 C4 C2 C4 */
- "pslld $16, %%mm1 \n\t" /* mm1 = y7 0 y5 0 */
-
- "movq 8(%3), %%mm4 \n\t" /* mm4 = -C2 -C4 C6 C4 */
- "por %%mm1, %%mm7 \n\t" /* mm7 = y7 y6 y5 y4 */
-
- "movq 16(%3), %%mm1 \n\t" /* mm1 = -C7 C3 C3 C1 */
- "punpckhdq %%mm2, %%mm2 \n\t" /* mm2 = x6 x4 x6 x4 */
-
- "movq %%mm7, 8(%0,%2) \n\t" /* save y7 y6 y5 y4 */
- "pmaddwd %%mm0, %%mm3 \n\t" /* mm3 = C4*x0+C6*x2 C4*x0+C2*x2 */
- : : "r" (row), "r" ((x86_reg) (2*offset)), "r" ((x86_reg) (2*store)), "r" (table)
- );
-}
-
-
-#if 0
-/* C column IDCT - it is just here to document the MMXEXT and MMX versions */
-static inline void idct_col (int16_t * col, int offset)
-{
-/* multiplication - as implemented on mmx */
-#define F(c,x) (((c) * (x)) >> 16)
-
-/* saturation - it helps us handle torture test cases */
-#define S(x) (((x)>32767) ? 32767 : ((x)<-32768) ? -32768 : (x))
-
- int16_t x0, x1, x2, x3, x4, x5, x6, x7;
- int16_t y0, y1, y2, y3, y4, y5, y6, y7;
- int16_t a0, a1, a2, a3, b0, b1, b2, b3;
- int16_t u04, v04, u26, v26, u17, v17, u35, v35, u12, v12;
-
- col += offset;
-
- x0 = col[0*8];
- x1 = col[1*8];
- x2 = col[2*8];
- x3 = col[3*8];
- x4 = col[4*8];
- x5 = col[5*8];
- x6 = col[6*8];
- x7 = col[7*8];
-
- u04 = S (x0 + x4);
- v04 = S (x0 - x4);
- u26 = S (F (T2, x6) + x2);
- v26 = S (F (T2, x2) - x6);
-
- a0 = S (u04 + u26);
- a1 = S (v04 + v26);
- a2 = S (v04 - v26);
- a3 = S (u04 - u26);
-
- u17 = S (F (T1, x7) + x1);
- v17 = S (F (T1, x1) - x7);
- u35 = S (F (T3, x5) + x3);
- v35 = S (F (T3, x3) - x5);
-
- b0 = S (u17 + u35);
- b3 = S (v17 - v35);
- u12 = S (u17 - u35);
- v12 = S (v17 + v35);
- u12 = S (2 * F (C4, u12));
- v12 = S (2 * F (C4, v12));
- b1 = S (u12 + v12);
- b2 = S (u12 - v12);
-
- y0 = S (a0 + b0) >> COL_SHIFT;
- y1 = S (a1 + b1) >> COL_SHIFT;
- y2 = S (a2 + b2) >> COL_SHIFT;
- y3 = S (a3 + b3) >> COL_SHIFT;
-
- y4 = S (a3 - b3) >> COL_SHIFT;
- y5 = S (a2 - b2) >> COL_SHIFT;
- y6 = S (a1 - b1) >> COL_SHIFT;
- y7 = S (a0 - b0) >> COL_SHIFT;
-
- col[0*8] = y0;
- col[1*8] = y1;
- col[2*8] = y2;
- col[3*8] = y3;
- col[4*8] = y4;
- col[5*8] = y5;
- col[6*8] = y6;
- col[7*8] = y7;
-}
-#endif
-
-
-/* MMX column IDCT */
-static inline void idct_col (int16_t * const col, const int offset)
-{
-#define T1 13036
-#define T2 27146
-#define T3 43790
-#define C4 23170
-
- DECLARE_ALIGNED(8, static const short, t1_vector)[] = {
- T1,T1,T1,T1,
- T2,T2,T2,T2,
- T3,T3,T3,T3,
- C4,C4,C4,C4
- };
-
- /* column code adapted from Peter Gubanov */
- /* http://www.elecard.com/peter/idct.shtml */
-
- __asm__ volatile (
- "movq (%0), %%mm0 \n\t" /* mm0 = T1 */
-
- "movq 2*8(%1), %%mm1 \n\t" /* mm1 = x1 */
- "movq %%mm0, %%mm2 \n\t" /* mm2 = T1 */
-
- "movq 7*2*8(%1), %%mm4 \n\t" /* mm4 = x7 */
- "pmulhw %%mm1, %%mm0 \n\t" /* mm0 = T1*x1 */
-
- "movq 16(%0), %%mm5 \n\t" /* mm5 = T3 */
- "pmulhw %%mm4, %%mm2 \n\t" /* mm2 = T1*x7 */
-
- "movq 2*5*8(%1), %%mm6 \n\t" /* mm6 = x5 */
- "movq %%mm5, %%mm7 \n\t" /* mm7 = T3-1 */
-
- "movq 3*8*2(%1), %%mm3 \n\t" /* mm3 = x3 */
- "psubsw %%mm4, %%mm0 \n\t" /* mm0 = v17 */
-
- "movq 8(%0), %%mm4 \n\t" /* mm4 = T2 */
- "pmulhw %%mm3, %%mm5 \n\t" /* mm5 = (T3-1)*x3 */
-
- "paddsw %%mm2, %%mm1 \n\t" /* mm1 = u17 */
- "pmulhw %%mm6, %%mm7 \n\t" /* mm7 = (T3-1)*x5 */
-
- /* slot */
-
- "movq %%mm4, %%mm2 \n\t" /* mm2 = T2 */
- "paddsw %%mm3, %%mm5 \n\t" /* mm5 = T3*x3 */
-
- "pmulhw 2*8*2(%1), %%mm4 \n\t" /* mm4 = T2*x2 */
- "paddsw %%mm6, %%mm7 \n\t" /* mm7 = T3*x5 */
-
- "psubsw %%mm6, %%mm5 \n\t" /* mm5 = v35 */
- "paddsw %%mm3, %%mm7 \n\t" /* mm7 = u35 */
-
- "movq 6*8*2(%1), %%mm3 \n\t" /* mm3 = x6 */
- "movq %%mm0, %%mm6 \n\t" /* mm6 = v17 */
-
- "pmulhw %%mm3, %%mm2 \n\t" /* mm2 = T2*x6 */
- "psubsw %%mm5, %%mm0 \n\t" /* mm0 = b3 */
-
- "psubsw %%mm3, %%mm4 \n\t" /* mm4 = v26 */
- "paddsw %%mm6, %%mm5 \n\t" /* mm5 = v12 */
-
- "movq %%mm0, 3*8*2(%1)\n\t" /* save b3 in scratch0 */
- "movq %%mm1, %%mm6 \n\t" /* mm6 = u17 */
-
- "paddsw 2*8*2(%1), %%mm2 \n\t" /* mm2 = u26 */
- "paddsw %%mm7, %%mm6 \n\t" /* mm6 = b0 */
-
- "psubsw %%mm7, %%mm1 \n\t" /* mm1 = u12 */
- "movq %%mm1, %%mm7 \n\t" /* mm7 = u12 */
-
- "movq 0*8(%1), %%mm3 \n\t" /* mm3 = x0 */
- "paddsw %%mm5, %%mm1 \n\t" /* mm1 = u12+v12 */
-
- "movq 24(%0), %%mm0 \n\t" /* mm0 = C4/2 */
- "psubsw %%mm5, %%mm7 \n\t" /* mm7 = u12-v12 */
-
- "movq %%mm6, 5*8*2(%1)\n\t" /* save b0 in scratch1 */
- "pmulhw %%mm0, %%mm1 \n\t" /* mm1 = b1/2 */
-
- "movq %%mm4, %%mm6 \n\t" /* mm6 = v26 */
- "pmulhw %%mm0, %%mm7 \n\t" /* mm7 = b2/2 */
-
- "movq 4*8*2(%1), %%mm5 \n\t" /* mm5 = x4 */
- "movq %%mm3, %%mm0 \n\t" /* mm0 = x0 */
-
- "psubsw %%mm5, %%mm3 \n\t" /* mm3 = v04 */
- "paddsw %%mm5, %%mm0 \n\t" /* mm0 = u04 */
-
- "paddsw %%mm3, %%mm4 \n\t" /* mm4 = a1 */
- "movq %%mm0, %%mm5 \n\t" /* mm5 = u04 */
-
- "psubsw %%mm6, %%mm3 \n\t" /* mm3 = a2 */
- "paddsw %%mm2, %%mm5 \n\t" /* mm5 = a0 */
-
- "paddsw %%mm1, %%mm1 \n\t" /* mm1 = b1 */
- "psubsw %%mm2, %%mm0 \n\t" /* mm0 = a3 */
-
- "paddsw %%mm7, %%mm7 \n\t" /* mm7 = b2 */
- "movq %%mm3, %%mm2 \n\t" /* mm2 = a2 */
-
- "movq %%mm4, %%mm6 \n\t" /* mm6 = a1 */
- "paddsw %%mm7, %%mm3 \n\t" /* mm3 = a2+b2 */
-
- "psraw $" AV_STRINGIFY(COL_SHIFT) ", %%mm3\n\t" /* mm3 = y2 */
- "paddsw %%mm1, %%mm4\n\t" /* mm4 = a1+b1 */
-
- "psraw $" AV_STRINGIFY(COL_SHIFT) ", %%mm4\n\t" /* mm4 = y1 */
- "psubsw %%mm1, %%mm6 \n\t" /* mm6 = a1-b1 */
-
- "movq 5*8*2(%1), %%mm1 \n\t" /* mm1 = b0 */
- "psubsw %%mm7, %%mm2 \n\t" /* mm2 = a2-b2 */
-
- "psraw $" AV_STRINGIFY(COL_SHIFT) ", %%mm6\n\t" /* mm6 = y6 */
- "movq %%mm5, %%mm7 \n\t" /* mm7 = a0 */
-
- "movq %%mm4, 1*8*2(%1)\n\t" /* save y1 */
- "psraw $" AV_STRINGIFY(COL_SHIFT) ", %%mm2\n\t" /* mm2 = y5 */
-
- "movq %%mm3, 2*8*2(%1)\n\t" /* save y2 */
- "paddsw %%mm1, %%mm5 \n\t" /* mm5 = a0+b0 */
-
- "movq 3*8*2(%1), %%mm4 \n\t" /* mm4 = b3 */
- "psubsw %%mm1, %%mm7 \n\t" /* mm7 = a0-b0 */
-
- "psraw $" AV_STRINGIFY(COL_SHIFT) ", %%mm5\n\t" /* mm5 = y0 */
- "movq %%mm0, %%mm3 \n\t" /* mm3 = a3 */
-
- "movq %%mm2, 5*8*2(%1)\n\t" /* save y5 */
- "psubsw %%mm4, %%mm3 \n\t" /* mm3 = a3-b3 */
-
- "psraw $" AV_STRINGIFY(COL_SHIFT) ", %%mm7\n\t" /* mm7 = y7 */
- "paddsw %%mm0, %%mm4 \n\t" /* mm4 = a3+b3 */
-
- "movq %%mm5, 0*8*2(%1)\n\t" /* save y0 */
- "psraw $" AV_STRINGIFY(COL_SHIFT) ", %%mm3\n\t" /* mm3 = y4 */
-
- "movq %%mm6, 6*8*2(%1)\n\t" /* save y6 */
- "psraw $" AV_STRINGIFY(COL_SHIFT) ", %%mm4\n\t" /* mm4 = y3 */
-
- "movq %%mm7, 7*8*2(%1)\n\t" /* save y7 */
-
- "movq %%mm3, 4*8*2(%1)\n\t" /* save y4 */
-
- "movq %%mm4, 3*8*2(%1)\n\t" /* save y3 */
- :: "r" (t1_vector), "r" (col+offset)
- );
-
-#undef T1
-#undef T2
-#undef T3
-#undef C4
-}
-
-
-DECLARE_ALIGNED(8, static const int32_t, rounder0)[] =
- rounder ((1 << (COL_SHIFT - 1)) - 0.5);
-DECLARE_ALIGNED(8, static const int32_t, rounder4)[] = rounder (0);
-DECLARE_ALIGNED(8, static const int32_t, rounder1)[] =
- rounder (1.25683487303); /* C1*(C1/C4+C1+C7)/2 */
-DECLARE_ALIGNED(8, static const int32_t, rounder7)[] =
- rounder (-0.25); /* C1*(C7/C4+C7-C1)/2 */
-DECLARE_ALIGNED(8, static const int32_t, rounder2)[] =
- rounder (0.60355339059); /* C2 * (C6+C2)/2 */
-DECLARE_ALIGNED(8, static const int32_t, rounder6)[] =
- rounder (-0.25); /* C2 * (C6-C2)/2 */
-DECLARE_ALIGNED(8, static const int32_t, rounder3)[] =
- rounder (0.087788325588); /* C3*(-C3/C4+C3+C5)/2 */
-DECLARE_ALIGNED(8, static const int32_t, rounder5)[] =
- rounder (-0.441341716183); /* C3*(-C5/C4+C5-C3)/2 */
-
-#undef COL_SHIFT
-#undef ROW_SHIFT
-
-#define declare_idct(idct,table,idct_row_head,idct_row,idct_row_tail,idct_row_mid) \
-void idct (int16_t * const block) \
-{ \
- DECLARE_ALIGNED(16, static const int16_t, table04)[] = \
- table (22725, 21407, 19266, 16384, 12873, 8867, 4520); \
- DECLARE_ALIGNED(16, static const int16_t, table17)[] = \
- table (31521, 29692, 26722, 22725, 17855, 12299, 6270); \
- DECLARE_ALIGNED(16, static const int16_t, table26)[] = \
- table (29692, 27969, 25172, 21407, 16819, 11585, 5906); \
- DECLARE_ALIGNED(16, static const int16_t, table35)[] = \
- table (26722, 25172, 22654, 19266, 15137, 10426, 5315); \
- \
- idct_row_head (block, 0*8, table04); \
- idct_row (table04, rounder0); \
- idct_row_mid (block, 0*8, 4*8, table04); \
- idct_row (table04, rounder4); \
- idct_row_mid (block, 4*8, 1*8, table17); \
- idct_row (table17, rounder1); \
- idct_row_mid (block, 1*8, 7*8, table17); \
- idct_row (table17, rounder7); \
- idct_row_mid (block, 7*8, 2*8, table26); \
- idct_row (table26, rounder2); \
- idct_row_mid (block, 2*8, 6*8, table26); \
- idct_row (table26, rounder6); \
- idct_row_mid (block, 6*8, 3*8, table35); \
- idct_row (table35, rounder3); \
- idct_row_mid (block, 3*8, 5*8, table35); \
- idct_row (table35, rounder5); \
- idct_row_tail (block, 5*8); \
- \
- idct_col (block, 0); \
- idct_col (block, 4); \
-}
-
-declare_idct (ff_mmxext_idct, mmxext_table,
- mmxext_row_head, mmxext_row, mmxext_row_tail, mmxext_row_mid)
-
-declare_idct (ff_mmx_idct, mmx_table,
- mmx_row_head, mmx_row, mmx_row_tail, mmx_row_mid)
-
-#endif /* HAVE_INLINE_ASM */
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/idct_mmx_xvid.c b/src/thirdparty/ffmpeg/libavcodec/x86/idct_mmx_xvid.c
deleted file mode 100644
index 947b55dd8..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/idct_mmx_xvid.c
+++ /dev/null
@@ -1,558 +0,0 @@
-/*
- * XVID MPEG-4 VIDEO CODEC
- * - MMX and XMM forward discrete cosine transform -
- *
- * Copyright(C) 2001 Peter Ross <pross@xvid.org>
- *
- * Originally provided by Intel at AP-922
- * http://developer.intel.com/vtune/cbts/strmsimd/922down.htm
- * (See more app notes at http://developer.intel.com/vtune/cbts/strmsimd/appnotes.htm)
- * but in a limited edition.
- * New macro implements a column part for precise iDCT
- * The routine precision now satisfies IEEE standard 1180-1990.
- *
- * Copyright(C) 2000-2001 Peter Gubanov <peter@elecard.net.ru>
- * Rounding trick Copyright(C) 2000 Michel Lespinasse <walken@zoy.org>
- *
- * http://www.elecard.com/peter/idct.html
- * http://www.linuxvideo.org/mpeg2dec/
- *
- * These examples contain code fragments for first stage iDCT 8x8
- * (for rows) and first stage DCT 8x8 (for columns)
- *
- * conversion to gcc syntax by 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 <inttypes.h>
-
-#include "config.h"
-#include "libavcodec/avcodec.h"
-#include "libavutil/mem.h"
-#include "dsputil_mmx.h"
-#include "idct_xvid.h"
-
-#if HAVE_INLINE_ASM
-
-//=============================================================================
-// Macros and other preprocessor constants
-//=============================================================================
-
-#define BITS_INV_ACC 5 // 4 or 5 for IEEE
-#define SHIFT_INV_ROW (16 - BITS_INV_ACC) //11
-#define SHIFT_INV_COL (1 + BITS_INV_ACC) //6
-#define RND_INV_ROW (1024 * (6 - BITS_INV_ACC))
-#define RND_INV_COL (16 * (BITS_INV_ACC - 3))
-#define RND_INV_CORR (RND_INV_COL - 1)
-
-#define BITS_FRW_ACC 3 // 2 or 3 for accuracy
-#define SHIFT_FRW_COL BITS_FRW_ACC
-#define SHIFT_FRW_ROW (BITS_FRW_ACC + 17)
-#define RND_FRW_ROW (262144*(BITS_FRW_ACC - 1))
-
-
-//-----------------------------------------------------------------------------
-// Various memory constants (trigonometric values or rounding values)
-//-----------------------------------------------------------------------------
-
-
-DECLARE_ALIGNED(8, static const int16_t, tg_1_16)[4*4] = {
- 13036,13036,13036,13036, // tg * (2<<16) + 0.5
- 27146,27146,27146,27146, // tg * (2<<16) + 0.5
- -21746,-21746,-21746,-21746, // tg * (2<<16) + 0.5
- 23170,23170,23170,23170}; // cos * (2<<15) + 0.5
-
-DECLARE_ALIGNED(8, static const int32_t, rounder_0)[2*8] = {
- 65536,65536,
- 3597,3597,
- 2260,2260,
- 1203,1203,
- 0,0,
- 120,120,
- 512,512,
- 512,512};
-
-//-----------------------------------------------------------------------------
-//
-// The first stage iDCT 8x8 - inverse DCTs of rows
-//
-//-----------------------------------------------------------------------------
-// The 8-point inverse DCT direct algorithm
-//-----------------------------------------------------------------------------
-//
-// static const short w[32] = {
-// FIX(cos_4_16), FIX(cos_2_16), FIX(cos_4_16), FIX(cos_6_16),
-// FIX(cos_4_16), FIX(cos_6_16), -FIX(cos_4_16), -FIX(cos_2_16),
-// FIX(cos_4_16), -FIX(cos_6_16), -FIX(cos_4_16), FIX(cos_2_16),
-// FIX(cos_4_16), -FIX(cos_2_16), FIX(cos_4_16), -FIX(cos_6_16),
-// FIX(cos_1_16), FIX(cos_3_16), FIX(cos_5_16), FIX(cos_7_16),
-// FIX(cos_3_16), -FIX(cos_7_16), -FIX(cos_1_16), -FIX(cos_5_16),
-// FIX(cos_5_16), -FIX(cos_1_16), FIX(cos_7_16), FIX(cos_3_16),
-// FIX(cos_7_16), -FIX(cos_5_16), FIX(cos_3_16), -FIX(cos_1_16) };
-//
-// #define DCT_8_INV_ROW(x, y)
-// {
-// int a0, a1, a2, a3, b0, b1, b2, b3;
-//
-// a0 =x[0]*w[0]+x[2]*w[1]+x[4]*w[2]+x[6]*w[3];
-// a1 =x[0]*w[4]+x[2]*w[5]+x[4]*w[6]+x[6]*w[7];
-// a2 = x[0] * w[ 8] + x[2] * w[ 9] + x[4] * w[10] + x[6] * w[11];
-// a3 = x[0] * w[12] + x[2] * w[13] + x[4] * w[14] + x[6] * w[15];
-// b0 = x[1] * w[16] + x[3] * w[17] + x[5] * w[18] + x[7] * w[19];
-// b1 = x[1] * w[20] + x[3] * w[21] + x[5] * w[22] + x[7] * w[23];
-// b2 = x[1] * w[24] + x[3] * w[25] + x[5] * w[26] + x[7] * w[27];
-// b3 = x[1] * w[28] + x[3] * w[29] + x[5] * w[30] + x[7] * w[31];
-//
-// y[0] = SHIFT_ROUND ( a0 + b0 );
-// y[1] = SHIFT_ROUND ( a1 + b1 );
-// y[2] = SHIFT_ROUND ( a2 + b2 );
-// y[3] = SHIFT_ROUND ( a3 + b3 );
-// y[4] = SHIFT_ROUND ( a3 - b3 );
-// y[5] = SHIFT_ROUND ( a2 - b2 );
-// y[6] = SHIFT_ROUND ( a1 - b1 );
-// y[7] = SHIFT_ROUND ( a0 - b0 );
-// }
-//
-//-----------------------------------------------------------------------------
-//
-// In this implementation the outputs of the iDCT-1D are multiplied
-// for rows 0,4 - by cos_4_16,
-// for rows 1,7 - by cos_1_16,
-// for rows 2,6 - by cos_2_16,
-// for rows 3,5 - by cos_3_16
-// and are shifted to the left for better accuracy
-//
-// For the constants used,
-// FIX(float_const) = (short) (float_const * (1<<15) + 0.5)
-//
-//-----------------------------------------------------------------------------
-
-//-----------------------------------------------------------------------------
-// Tables for mmx processors
-//-----------------------------------------------------------------------------
-
-// Table for rows 0,4 - constants are multiplied by cos_4_16
-DECLARE_ALIGNED(8, static const int16_t, tab_i_04_mmx)[32*4] = {
- 16384,16384,16384,-16384, // movq-> w06 w04 w02 w00
- 21407,8867,8867,-21407, // w07 w05 w03 w01
- 16384,-16384,16384,16384, // w14 w12 w10 w08
- -8867,21407,-21407,-8867, // w15 w13 w11 w09
- 22725,12873,19266,-22725, // w22 w20 w18 w16
- 19266,4520,-4520,-12873, // w23 w21 w19 w17
- 12873,4520,4520,19266, // w30 w28 w26 w24
- -22725,19266,-12873,-22725, // w31 w29 w27 w25
-// Table for rows 1,7 - constants are multiplied by cos_1_16
- 22725,22725,22725,-22725, // movq-> w06 w04 w02 w00
- 29692,12299,12299,-29692, // w07 w05 w03 w01
- 22725,-22725,22725,22725, // w14 w12 w10 w08
- -12299,29692,-29692,-12299, // w15 w13 w11 w09
- 31521,17855,26722,-31521, // w22 w20 w18 w16
- 26722,6270,-6270,-17855, // w23 w21 w19 w17
- 17855,6270,6270,26722, // w30 w28 w26 w24
- -31521,26722,-17855,-31521, // w31 w29 w27 w25
-// Table for rows 2,6 - constants are multiplied by cos_2_16
- 21407,21407,21407,-21407, // movq-> w06 w04 w02 w00
- 27969,11585,11585,-27969, // w07 w05 w03 w01
- 21407,-21407,21407,21407, // w14 w12 w10 w08
- -11585,27969,-27969,-11585, // w15 w13 w11 w09
- 29692,16819,25172,-29692, // w22 w20 w18 w16
- 25172,5906,-5906,-16819, // w23 w21 w19 w17
- 16819,5906,5906,25172, // w30 w28 w26 w24
- -29692,25172,-16819,-29692, // w31 w29 w27 w25
-// Table for rows 3,5 - constants are multiplied by cos_3_16
- 19266,19266,19266,-19266, // movq-> w06 w04 w02 w00
- 25172,10426,10426,-25172, // w07 w05 w03 w01
- 19266,-19266,19266,19266, // w14 w12 w10 w08
- -10426,25172,-25172,-10426, // w15 w13 w11 w09
- 26722,15137,22654,-26722, // w22 w20 w18 w16
- 22654,5315,-5315,-15137, // w23 w21 w19 w17
- 15137,5315,5315,22654, // w30 w28 w26 w24
- -26722,22654,-15137,-26722, // w31 w29 w27 w25
-};
-//-----------------------------------------------------------------------------
-// Tables for xmm processors
-//-----------------------------------------------------------------------------
-
-// %3 for rows 0,4 - constants are multiplied by cos_4_16
-DECLARE_ALIGNED(8, static const int16_t, tab_i_04_xmm)[32*4] = {
- 16384,21407,16384,8867, // movq-> w05 w04 w01 w00
- 16384,8867,-16384,-21407, // w07 w06 w03 w02
- 16384,-8867,16384,-21407, // w13 w12 w09 w08
- -16384,21407,16384,-8867, // w15 w14 w11 w10
- 22725,19266,19266,-4520, // w21 w20 w17 w16
- 12873,4520,-22725,-12873, // w23 w22 w19 w18
- 12873,-22725,4520,-12873, // w29 w28 w25 w24
- 4520,19266,19266,-22725, // w31 w30 w27 w26
-// %3 for rows 1,7 - constants are multiplied by cos_1_16
- 22725,29692,22725,12299, // movq-> w05 w04 w01 w00
- 22725,12299,-22725,-29692, // w07 w06 w03 w02
- 22725,-12299,22725,-29692, // w13 w12 w09 w08
- -22725,29692,22725,-12299, // w15 w14 w11 w10
- 31521,26722,26722,-6270, // w21 w20 w17 w16
- 17855,6270,-31521,-17855, // w23 w22 w19 w18
- 17855,-31521,6270,-17855, // w29 w28 w25 w24
- 6270,26722,26722,-31521, // w31 w30 w27 w26
-// %3 for rows 2,6 - constants are multiplied by cos_2_16
- 21407,27969,21407,11585, // movq-> w05 w04 w01 w00
- 21407,11585,-21407,-27969, // w07 w06 w03 w02
- 21407,-11585,21407,-27969, // w13 w12 w09 w08
- -21407,27969,21407,-11585, // w15 w14 w11 w10
- 29692,25172,25172,-5906, // w21 w20 w17 w16
- 16819,5906,-29692,-16819, // w23 w22 w19 w18
- 16819,-29692,5906,-16819, // w29 w28 w25 w24
- 5906,25172,25172,-29692, // w31 w30 w27 w26
-// %3 for rows 3,5 - constants are multiplied by cos_3_16
- 19266,25172,19266,10426, // movq-> w05 w04 w01 w00
- 19266,10426,-19266,-25172, // w07 w06 w03 w02
- 19266,-10426,19266,-25172, // w13 w12 w09 w08
- -19266,25172,19266,-10426, // w15 w14 w11 w10
- 26722,22654,22654,-5315, // w21 w20 w17 w16
- 15137,5315,-26722,-15137, // w23 w22 w19 w18
- 15137,-26722,5315,-15137, // w29 w28 w25 w24
- 5315,22654,22654,-26722, // w31 w30 w27 w26
-};
-//=============================================================================
-// Helper macros for the code
-//=============================================================================
-
-//-----------------------------------------------------------------------------
-// DCT_8_INV_ROW_MMX( INP, OUT, TABLE, ROUNDER
-//-----------------------------------------------------------------------------
-
-#define DCT_8_INV_ROW_MMX(A1,A2,A3,A4)\
- "movq " #A1 ",%%mm0 \n\t"/* 0 ; x3 x2 x1 x0*/\
- "movq 8+" #A1 ",%%mm1 \n\t"/* 1 ; x7 x6 x5 x4*/\
- "movq %%mm0,%%mm2 \n\t"/* 2 ; x3 x2 x1 x0*/\
- "movq " #A3 ",%%mm3 \n\t"/* 3 ; w06 w04 w02 w00*/\
- "punpcklwd %%mm1,%%mm0 \n\t"/* x5 x1 x4 x0*/\
- "movq %%mm0,%%mm5 \n\t"/* 5 ; x5 x1 x4 x0*/\
- "punpckldq %%mm0,%%mm0 \n\t"/* x4 x0 x4 x0*/\
- "movq 8+" #A3 ",%%mm4 \n\t"/* 4 ; w07 w05 w03 w01*/\
- "punpckhwd %%mm1,%%mm2 \n\t"/* 1 ; x7 x3 x6 x2*/\
- "pmaddwd %%mm0,%%mm3 \n\t"/* x4*w06+x0*w04 x4*w02+x0*w00*/\
- "movq %%mm2,%%mm6 \n\t"/* 6 ; x7 x3 x6 x2*/\
- "movq 32+" #A3 ",%%mm1 \n\t"/* 1 ; w22 w20 w18 w16*/\
- "punpckldq %%mm2,%%mm2 \n\t"/* x6 x2 x6 x2*/\
- "pmaddwd %%mm2,%%mm4 \n\t"/* x6*w07+x2*w05 x6*w03+x2*w01*/\
- "punpckhdq %%mm5,%%mm5 \n\t"/* x5 x1 x5 x1*/\
- "pmaddwd 16+" #A3 ",%%mm0 \n\t"/* x4*w14+x0*w12 x4*w10+x0*w08*/\
- "punpckhdq %%mm6,%%mm6 \n\t"/* x7 x3 x7 x3*/\
- "movq 40+" #A3 ",%%mm7 \n\t"/* 7 ; w23 w21 w19 w17*/\
- "pmaddwd %%mm5,%%mm1 \n\t"/* x5*w22+x1*w20 x5*w18+x1*w16*/\
- "paddd " #A4 ",%%mm3 \n\t"/* +%4*/\
- "pmaddwd %%mm6,%%mm7 \n\t"/* x7*w23+x3*w21 x7*w19+x3*w17*/\
- "pmaddwd 24+" #A3 ",%%mm2 \n\t"/* x6*w15+x2*w13 x6*w11+x2*w09*/\
- "paddd %%mm4,%%mm3 \n\t"/* 4 ; a1=sum(even1) a0=sum(even0)*/\
- "pmaddwd 48+" #A3 ",%%mm5 \n\t"/* x5*w30+x1*w28 x5*w26+x1*w24*/\
- "movq %%mm3,%%mm4 \n\t"/* 4 ; a1 a0*/\
- "pmaddwd 56+" #A3 ",%%mm6 \n\t"/* x7*w31+x3*w29 x7*w27+x3*w25*/\
- "paddd %%mm7,%%mm1 \n\t"/* 7 ; b1=sum(odd1) b0=sum(odd0)*/\
- "paddd " #A4 ",%%mm0 \n\t"/* +%4*/\
- "psubd %%mm1,%%mm3 \n\t"/* a1-b1 a0-b0*/\
- "psrad $11,%%mm3 \n\t"/* y6=a1-b1 y7=a0-b0*/\
- "paddd %%mm4,%%mm1 \n\t"/* 4 ; a1+b1 a0+b0*/\
- "paddd %%mm2,%%mm0 \n\t"/* 2 ; a3=sum(even3) a2=sum(even2)*/\
- "psrad $11,%%mm1 \n\t"/* y1=a1+b1 y0=a0+b0*/\
- "paddd %%mm6,%%mm5 \n\t"/* 6 ; b3=sum(odd3) b2=sum(odd2)*/\
- "movq %%mm0,%%mm4 \n\t"/* 4 ; a3 a2*/\
- "paddd %%mm5,%%mm0 \n\t"/* a3+b3 a2+b2*/\
- "psubd %%mm5,%%mm4 \n\t"/* 5 ; a3-b3 a2-b2*/\
- "psrad $11,%%mm0 \n\t"/* y3=a3+b3 y2=a2+b2*/\
- "psrad $11,%%mm4 \n\t"/* y4=a3-b3 y5=a2-b2*/\
- "packssdw %%mm0,%%mm1 \n\t"/* 0 ; y3 y2 y1 y0*/\
- "packssdw %%mm3,%%mm4 \n\t"/* 3 ; y6 y7 y4 y5*/\
- "movq %%mm4,%%mm7 \n\t"/* 7 ; y6 y7 y4 y5*/\
- "psrld $16,%%mm4 \n\t"/* 0 y6 0 y4*/\
- "pslld $16,%%mm7 \n\t"/* y7 0 y5 0*/\
- "movq %%mm1," #A2 " \n\t"/* 1 ; save y3 y2 y1 y0*/\
- "por %%mm4,%%mm7 \n\t"/* 4 ; y7 y6 y5 y4*/\
- "movq %%mm7,8 +" #A2 "\n\t"/* 7 ; save y7 y6 y5 y4*/\
-
-
-//-----------------------------------------------------------------------------
-// DCT_8_INV_ROW_XMM( INP, OUT, TABLE, ROUNDER
-//-----------------------------------------------------------------------------
-
-#define DCT_8_INV_ROW_XMM(A1,A2,A3,A4)\
- "movq " #A1 ",%%mm0 \n\t"/* 0 ; x3 x2 x1 x0*/\
- "movq 8+" #A1 ",%%mm1 \n\t"/* 1 ; x7 x6 x5 x4*/\
- "movq %%mm0,%%mm2 \n\t"/* 2 ; x3 x2 x1 x0*/\
- "movq " #A3 ",%%mm3 \n\t"/* 3 ; w05 w04 w01 w00*/\
- "pshufw $0x88,%%mm0,%%mm0 \n\t"/* x2 x0 x2 x0*/\
- "movq 8+" #A3 ",%%mm4 \n\t"/* 4 ; w07 w06 w03 w02*/\
- "movq %%mm1,%%mm5 \n\t"/* 5 ; x7 x6 x5 x4*/\
- "pmaddwd %%mm0,%%mm3 \n\t"/* x2*w05+x0*w04 x2*w01+x0*w00*/\
- "movq 32+" #A3 ",%%mm6 \n\t"/* 6 ; w21 w20 w17 w16*/\
- "pshufw $0x88,%%mm1,%%mm1 \n\t"/* x6 x4 x6 x4*/\
- "pmaddwd %%mm1,%%mm4 \n\t"/* x6*w07+x4*w06 x6*w03+x4*w02*/\
- "movq 40+" #A3 ",%%mm7 \n\t"/* 7 ; w23 w22 w19 w18*/\
- "pshufw $0xdd,%%mm2,%%mm2 \n\t"/* x3 x1 x3 x1*/\
- "pmaddwd %%mm2,%%mm6 \n\t"/* x3*w21+x1*w20 x3*w17+x1*w16*/\
- "pshufw $0xdd,%%mm5,%%mm5 \n\t"/* x7 x5 x7 x5*/\
- "pmaddwd %%mm5,%%mm7 \n\t"/* x7*w23+x5*w22 x7*w19+x5*w18*/\
- "paddd " #A4 ",%%mm3 \n\t"/* +%4*/\
- "pmaddwd 16+" #A3 ",%%mm0 \n\t"/* x2*w13+x0*w12 x2*w09+x0*w08*/\
- "paddd %%mm4,%%mm3 \n\t"/* 4 ; a1=sum(even1) a0=sum(even0)*/\
- "pmaddwd 24+" #A3 ",%%mm1 \n\t"/* x6*w15+x4*w14 x6*w11+x4*w10*/\
- "movq %%mm3,%%mm4 \n\t"/* 4 ; a1 a0*/\
- "pmaddwd 48+" #A3 ",%%mm2 \n\t"/* x3*w29+x1*w28 x3*w25+x1*w24*/\
- "paddd %%mm7,%%mm6 \n\t"/* 7 ; b1=sum(odd1) b0=sum(odd0)*/\
- "pmaddwd 56+" #A3 ",%%mm5 \n\t"/* x7*w31+x5*w30 x7*w27+x5*w26*/\
- "paddd %%mm6,%%mm3 \n\t"/* a1+b1 a0+b0*/\
- "paddd " #A4 ",%%mm0 \n\t"/* +%4*/\
- "psrad $11,%%mm3 \n\t"/* y1=a1+b1 y0=a0+b0*/\
- "paddd %%mm1,%%mm0 \n\t"/* 1 ; a3=sum(even3) a2=sum(even2)*/\
- "psubd %%mm6,%%mm4 \n\t"/* 6 ; a1-b1 a0-b0*/\
- "movq %%mm0,%%mm7 \n\t"/* 7 ; a3 a2*/\
- "paddd %%mm5,%%mm2 \n\t"/* 5 ; b3=sum(odd3) b2=sum(odd2)*/\
- "paddd %%mm2,%%mm0 \n\t"/* a3+b3 a2+b2*/\
- "psrad $11,%%mm4 \n\t"/* y6=a1-b1 y7=a0-b0*/\
- "psubd %%mm2,%%mm7 \n\t"/* 2 ; a3-b3 a2-b2*/\
- "psrad $11,%%mm0 \n\t"/* y3=a3+b3 y2=a2+b2*/\
- "psrad $11,%%mm7 \n\t"/* y4=a3-b3 y5=a2-b2*/\
- "packssdw %%mm0,%%mm3 \n\t"/* 0 ; y3 y2 y1 y0*/\
- "packssdw %%mm4,%%mm7 \n\t"/* 4 ; y6 y7 y4 y5*/\
- "movq %%mm3, " #A2 " \n\t"/* 3 ; save y3 y2 y1 y0*/\
- "pshufw $0xb1,%%mm7,%%mm7 \n\t"/* y7 y6 y5 y4*/\
- "movq %%mm7,8 +" #A2 "\n\t"/* 7 ; save y7 y6 y5 y4*/\
-
-
-//-----------------------------------------------------------------------------
-//
-// The first stage DCT 8x8 - forward DCTs of columns
-//
-// The %2puts are multiplied
-// for rows 0,4 - on cos_4_16,
-// for rows 1,7 - on cos_1_16,
-// for rows 2,6 - on cos_2_16,
-// for rows 3,5 - on cos_3_16
-// and are shifted to the left for rise of accuracy
-//
-//-----------------------------------------------------------------------------
-//
-// The 8-point scaled forward DCT algorithm (26a8m)
-//
-//-----------------------------------------------------------------------------
-//
-// #define DCT_8_FRW_COL(x, y)
-//{
-// short t0, t1, t2, t3, t4, t5, t6, t7;
-// short tp03, tm03, tp12, tm12, tp65, tm65;
-// short tp465, tm465, tp765, tm765;
-//
-// t0 = LEFT_SHIFT ( x[0] + x[7] );
-// t1 = LEFT_SHIFT ( x[1] + x[6] );
-// t2 = LEFT_SHIFT ( x[2] + x[5] );
-// t3 = LEFT_SHIFT ( x[3] + x[4] );
-// t4 = LEFT_SHIFT ( x[3] - x[4] );
-// t5 = LEFT_SHIFT ( x[2] - x[5] );
-// t6 = LEFT_SHIFT ( x[1] - x[6] );
-// t7 = LEFT_SHIFT ( x[0] - x[7] );
-//
-// tp03 = t0 + t3;
-// tm03 = t0 - t3;
-// tp12 = t1 + t2;
-// tm12 = t1 - t2;
-//
-// y[0] = tp03 + tp12;
-// y[4] = tp03 - tp12;
-//
-// y[2] = tm03 + tm12 * tg_2_16;
-// y[6] = tm03 * tg_2_16 - tm12;
-//
-// tp65 =(t6 +t5 )*cos_4_16;
-// tm65 =(t6 -t5 )*cos_4_16;
-//
-// tp765 = t7 + tp65;
-// tm765 = t7 - tp65;
-// tp465 = t4 + tm65;
-// tm465 = t4 - tm65;
-//
-// y[1] = tp765 + tp465 * tg_1_16;
-// y[7] = tp765 * tg_1_16 - tp465;
-// y[5] = tm765 * tg_3_16 + tm465;
-// y[3] = tm765 - tm465 * tg_3_16;
-//}
-//
-//-----------------------------------------------------------------------------
-
-//-----------------------------------------------------------------------------
-// DCT_8_INV_COL_4 INP,OUT
-//-----------------------------------------------------------------------------
-
-#define DCT_8_INV_COL(A1,A2)\
- "movq 2*8(%3),%%mm0\n\t"\
- "movq 16*3+" #A1 ",%%mm3\n\t"\
- "movq %%mm0,%%mm1 \n\t"/* tg_3_16*/\
- "movq 16*5+" #A1 ",%%mm5\n\t"\
- "pmulhw %%mm3,%%mm0 \n\t"/* x3*(tg_3_16-1)*/\
- "movq (%3),%%mm4\n\t"\
- "pmulhw %%mm5,%%mm1 \n\t"/* x5*(tg_3_16-1)*/\
- "movq 16*7+" #A1 ",%%mm7\n\t"\
- "movq %%mm4,%%mm2 \n\t"/* tg_1_16*/\
- "movq 16*1+" #A1 ",%%mm6\n\t"\
- "pmulhw %%mm7,%%mm4 \n\t"/* x7*tg_1_16*/\
- "paddsw %%mm3,%%mm0 \n\t"/* x3*tg_3_16*/\
- "pmulhw %%mm6,%%mm2 \n\t"/* x1*tg_1_16*/\
- "paddsw %%mm3,%%mm1 \n\t"/* x3+x5*(tg_3_16-1)*/\
- "psubsw %%mm5,%%mm0 \n\t"/* x3*tg_3_16-x5 = tm35*/\
- "movq 3*8(%3),%%mm3\n\t"\
- "paddsw %%mm5,%%mm1 \n\t"/* x3+x5*tg_3_16 = tp35*/\
- "paddsw %%mm6,%%mm4 \n\t"/* x1+tg_1_16*x7 = tp17*/\
- "psubsw %%mm7,%%mm2 \n\t"/* x1*tg_1_16-x7 = tm17*/\
- "movq %%mm4,%%mm5 \n\t"/* tp17*/\
- "movq %%mm2,%%mm6 \n\t"/* tm17*/\
- "paddsw %%mm1,%%mm5 \n\t"/* tp17+tp35 = b0*/\
- "psubsw %%mm0,%%mm6 \n\t"/* tm17-tm35 = b3*/\
- "psubsw %%mm1,%%mm4 \n\t"/* tp17-tp35 = t1*/\
- "paddsw %%mm0,%%mm2 \n\t"/* tm17+tm35 = t2*/\
- "movq 1*8(%3),%%mm7\n\t"\
- "movq %%mm4,%%mm1 \n\t"/* t1*/\
- "movq %%mm5,3*16 +" #A2 "\n\t"/* save b0*/\
- "paddsw %%mm2,%%mm1 \n\t"/* t1+t2*/\
- "movq %%mm6,5*16 +" #A2 "\n\t"/* save b3*/\
- "psubsw %%mm2,%%mm4 \n\t"/* t1-t2*/\
- "movq 2*16+" #A1 ",%%mm5\n\t"\
- "movq %%mm7,%%mm0 \n\t"/* tg_2_16*/\
- "movq 6*16+" #A1 ",%%mm6\n\t"\
- "pmulhw %%mm5,%%mm0 \n\t"/* x2*tg_2_16*/\
- "pmulhw %%mm6,%%mm7 \n\t"/* x6*tg_2_16*/\
- "pmulhw %%mm3,%%mm1 \n\t"/* ocos_4_16*(t1+t2) = b1/2*/\
- "movq 0*16+" #A1 ",%%mm2\n\t"\
- "pmulhw %%mm3,%%mm4 \n\t"/* ocos_4_16*(t1-t2) = b2/2*/\
- "psubsw %%mm6,%%mm0 \n\t"/* t2*tg_2_16-x6 = tm26*/\
- "movq %%mm2,%%mm3 \n\t"/* x0*/\
- "movq 4*16+" #A1 ",%%mm6\n\t"\
- "paddsw %%mm5,%%mm7 \n\t"/* x2+x6*tg_2_16 = tp26*/\
- "paddsw %%mm6,%%mm2 \n\t"/* x0+x4 = tp04*/\
- "psubsw %%mm6,%%mm3 \n\t"/* x0-x4 = tm04*/\
- "movq %%mm2,%%mm5 \n\t"/* tp04*/\
- "movq %%mm3,%%mm6 \n\t"/* tm04*/\
- "psubsw %%mm7,%%mm2 \n\t"/* tp04-tp26 = a3*/\
- "paddsw %%mm0,%%mm3 \n\t"/* tm04+tm26 = a1*/\
- "paddsw %%mm1,%%mm1 \n\t"/* b1*/\
- "paddsw %%mm4,%%mm4 \n\t"/* b2*/\
- "paddsw %%mm7,%%mm5 \n\t"/* tp04+tp26 = a0*/\
- "psubsw %%mm0,%%mm6 \n\t"/* tm04-tm26 = a2*/\
- "movq %%mm3,%%mm7 \n\t"/* a1*/\
- "movq %%mm6,%%mm0 \n\t"/* a2*/\
- "paddsw %%mm1,%%mm3 \n\t"/* a1+b1*/\
- "paddsw %%mm4,%%mm6 \n\t"/* a2+b2*/\
- "psraw $6,%%mm3 \n\t"/* dst1*/\
- "psubsw %%mm1,%%mm7 \n\t"/* a1-b1*/\
- "psraw $6,%%mm6 \n\t"/* dst2*/\
- "psubsw %%mm4,%%mm0 \n\t"/* a2-b2*/\
- "movq 3*16+" #A2 ",%%mm1 \n\t"/* load b0*/\
- "psraw $6,%%mm7 \n\t"/* dst6*/\
- "movq %%mm5,%%mm4 \n\t"/* a0*/\
- "psraw $6,%%mm0 \n\t"/* dst5*/\
- "movq %%mm3,1*16+" #A2 "\n\t"\
- "paddsw %%mm1,%%mm5 \n\t"/* a0+b0*/\
- "movq %%mm6,2*16+" #A2 "\n\t"\
- "psubsw %%mm1,%%mm4 \n\t"/* a0-b0*/\
- "movq 5*16+" #A2 ",%%mm3 \n\t"/* load b3*/\
- "psraw $6,%%mm5 \n\t"/* dst0*/\
- "movq %%mm2,%%mm6 \n\t"/* a3*/\
- "psraw $6,%%mm4 \n\t"/* dst7*/\
- "movq %%mm0,5*16+" #A2 "\n\t"\
- "paddsw %%mm3,%%mm2 \n\t"/* a3+b3*/\
- "movq %%mm7,6*16+" #A2 "\n\t"\
- "psubsw %%mm3,%%mm6 \n\t"/* a3-b3*/\
- "movq %%mm5,0*16+" #A2 "\n\t"\
- "psraw $6,%%mm2 \n\t"/* dst3*/\
- "movq %%mm4,7*16+" #A2 "\n\t"\
- "psraw $6,%%mm6 \n\t"/* dst4*/\
- "movq %%mm2,3*16+" #A2 "\n\t"\
- "movq %%mm6,4*16+" #A2 "\n\t"
-
-//=============================================================================
-// Code
-//=============================================================================
-
-//-----------------------------------------------------------------------------
-// void idct_mmx(uint16_t block[64]);
-//-----------------------------------------------------------------------------
-
-
-void ff_idct_xvid_mmx(short *block){
-__asm__ volatile(
- //# Process each row
- DCT_8_INV_ROW_MMX(0*16(%0), 0*16(%0), 64*0(%2), 8*0(%1))
- DCT_8_INV_ROW_MMX(1*16(%0), 1*16(%0), 64*1(%2), 8*1(%1))
- DCT_8_INV_ROW_MMX(2*16(%0), 2*16(%0), 64*2(%2), 8*2(%1))
- DCT_8_INV_ROW_MMX(3*16(%0), 3*16(%0), 64*3(%2), 8*3(%1))
- DCT_8_INV_ROW_MMX(4*16(%0), 4*16(%0), 64*0(%2), 8*4(%1))
- DCT_8_INV_ROW_MMX(5*16(%0), 5*16(%0), 64*3(%2), 8*5(%1))
- DCT_8_INV_ROW_MMX(6*16(%0), 6*16(%0), 64*2(%2), 8*6(%1))
- DCT_8_INV_ROW_MMX(7*16(%0), 7*16(%0), 64*1(%2), 8*7(%1))
-
- //# Process the columns (4 at a time)
- DCT_8_INV_COL(0(%0), 0(%0))
- DCT_8_INV_COL(8(%0), 8(%0))
- :: "r"(block), "r"(rounder_0), "r"(tab_i_04_mmx), "r"(tg_1_16));
-}
-
-//-----------------------------------------------------------------------------
-// void idct_xmm(uint16_t block[64]);
-//-----------------------------------------------------------------------------
-
-
-void ff_idct_xvid_mmxext(short *block)
-{
-__asm__ volatile(
- //# Process each row
- DCT_8_INV_ROW_XMM(0*16(%0), 0*16(%0), 64*0(%2), 8*0(%1))
- DCT_8_INV_ROW_XMM(1*16(%0), 1*16(%0), 64*1(%2), 8*1(%1))
- DCT_8_INV_ROW_XMM(2*16(%0), 2*16(%0), 64*2(%2), 8*2(%1))
- DCT_8_INV_ROW_XMM(3*16(%0), 3*16(%0), 64*3(%2), 8*3(%1))
- DCT_8_INV_ROW_XMM(4*16(%0), 4*16(%0), 64*0(%2), 8*4(%1))
- DCT_8_INV_ROW_XMM(5*16(%0), 5*16(%0), 64*3(%2), 8*5(%1))
- DCT_8_INV_ROW_XMM(6*16(%0), 6*16(%0), 64*2(%2), 8*6(%1))
- DCT_8_INV_ROW_XMM(7*16(%0), 7*16(%0), 64*1(%2), 8*7(%1))
-
- //# Process the columns (4 at a time)
- DCT_8_INV_COL(0(%0), 0(%0))
- DCT_8_INV_COL(8(%0), 8(%0))
- :: "r"(block), "r"(rounder_0), "r"(tab_i_04_xmm), "r"(tg_1_16));
-}
-
-void ff_idct_xvid_mmx_put(uint8_t *dest, int line_size, int16_t *block)
-{
- ff_idct_xvid_mmx(block);
- ff_put_pixels_clamped_mmx(block, dest, line_size);
-}
-
-void ff_idct_xvid_mmx_add(uint8_t *dest, int line_size, int16_t *block)
-{
- ff_idct_xvid_mmx(block);
- ff_add_pixels_clamped_mmx(block, dest, line_size);
-}
-
-void ff_idct_xvid_mmxext_put(uint8_t *dest, int line_size, int16_t *block)
-{
- ff_idct_xvid_mmxext(block);
- ff_put_pixels_clamped_mmx(block, dest, line_size);
-}
-
-void ff_idct_xvid_mmxext_add(uint8_t *dest, int line_size, int16_t *block)
-{
- ff_idct_xvid_mmxext(block);
- ff_add_pixels_clamped_mmx(block, dest, line_size);
-}
-
-#endif /* HAVE_INLINE_ASM */
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/idct_sse2_xvid.c b/src/thirdparty/ffmpeg/libavcodec/x86/idct_sse2_xvid.c
deleted file mode 100644
index 5dad4266b..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/idct_sse2_xvid.c
+++ /dev/null
@@ -1,408 +0,0 @@
-/*
- * XVID MPEG-4 VIDEO CODEC
- * - SSE2 inverse discrete cosine transform -
- *
- * Copyright(C) 2003 Pascal Massimino <skal@planet-d.net>
- *
- * Conversion to gcc syntax with modifications
- * by Alexander Strange <astrange@ithinksw.com>
- *
- * Originally from dct/x86_asm/fdct_sse2_skal.asm in Xvid.
- *
- * This file is part of FFmpeg.
- *
- * Vertical pass is an implementation of the scheme:
- * Loeffler C., Ligtenberg A., and Moschytz C.S.:
- * Practical Fast 1D DCT Algorithm with Eleven Multiplications,
- * Proc. ICASSP 1989, 988-991.
- *
- * Horizontal pass is a double 4x4 vector/matrix multiplication,
- * (see also Intel's Application Note 922:
- * http://developer.intel.com/vtune/cbts/strmsimd/922down.htm
- * Copyright (C) 1999 Intel Corporation)
- *
- * More details at http://skal.planet-d.net/coding/dct.html
- *
- * 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/dsputil.h"
-#include "libavutil/mem.h"
-#include "libavutil/x86/asm.h"
-#include "idct_xvid.h"
-#include "dsputil_mmx.h"
-
-#if HAVE_INLINE_ASM
-
-/**
- * @file
- * @brief SSE2 idct compatible with xvidmmx
- */
-
-#define X8(x) x,x,x,x,x,x,x,x
-
-#define ROW_SHIFT 11
-#define COL_SHIFT 6
-
-DECLARE_ASM_CONST(16, int16_t, tan1)[] = {X8(13036)}; // tan( pi/16)
-DECLARE_ASM_CONST(16, int16_t, tan2)[] = {X8(27146)}; // tan(2pi/16) = sqrt(2)-1
-DECLARE_ASM_CONST(16, int16_t, tan3)[] = {X8(43790)}; // tan(3pi/16)-1
-DECLARE_ASM_CONST(16, int16_t, sqrt2)[]= {X8(23170)}; // 0.5/sqrt(2)
-DECLARE_ASM_CONST(8, uint8_t, m127)[] = {X8(127)};
-
-DECLARE_ASM_CONST(16, int16_t, iTab1)[] = {
- 0x4000, 0x539f, 0xc000, 0xac61, 0x4000, 0xdd5d, 0x4000, 0xdd5d,
- 0x4000, 0x22a3, 0x4000, 0x22a3, 0xc000, 0x539f, 0x4000, 0xac61,
- 0x3249, 0x11a8, 0x4b42, 0xee58, 0x11a8, 0x4b42, 0x11a8, 0xcdb7,
- 0x58c5, 0x4b42, 0xa73b, 0xcdb7, 0x3249, 0xa73b, 0x4b42, 0xa73b
-};
-
-DECLARE_ASM_CONST(16, int16_t, iTab2)[] = {
- 0x58c5, 0x73fc, 0xa73b, 0x8c04, 0x58c5, 0xcff5, 0x58c5, 0xcff5,
- 0x58c5, 0x300b, 0x58c5, 0x300b, 0xa73b, 0x73fc, 0x58c5, 0x8c04,
- 0x45bf, 0x187e, 0x6862, 0xe782, 0x187e, 0x6862, 0x187e, 0xba41,
- 0x7b21, 0x6862, 0x84df, 0xba41, 0x45bf, 0x84df, 0x6862, 0x84df
-};
-
-DECLARE_ASM_CONST(16, int16_t, iTab3)[] = {
- 0x539f, 0x6d41, 0xac61, 0x92bf, 0x539f, 0xd2bf, 0x539f, 0xd2bf,
- 0x539f, 0x2d41, 0x539f, 0x2d41, 0xac61, 0x6d41, 0x539f, 0x92bf,
- 0x41b3, 0x1712, 0x6254, 0xe8ee, 0x1712, 0x6254, 0x1712, 0xbe4d,
- 0x73fc, 0x6254, 0x8c04, 0xbe4d, 0x41b3, 0x8c04, 0x6254, 0x8c04
-};
-
-DECLARE_ASM_CONST(16, int16_t, iTab4)[] = {
- 0x4b42, 0x6254, 0xb4be, 0x9dac, 0x4b42, 0xd746, 0x4b42, 0xd746,
- 0x4b42, 0x28ba, 0x4b42, 0x28ba, 0xb4be, 0x6254, 0x4b42, 0x9dac,
- 0x3b21, 0x14c3, 0x587e, 0xeb3d, 0x14c3, 0x587e, 0x14c3, 0xc4df,
- 0x6862, 0x587e, 0x979e, 0xc4df, 0x3b21, 0x979e, 0x587e, 0x979e
-};
-
-DECLARE_ASM_CONST(16, int32_t, walkenIdctRounders)[] = {
- 65536, 65536, 65536, 65536,
- 3597, 3597, 3597, 3597,
- 2260, 2260, 2260, 2260,
- 1203, 1203, 1203, 1203,
- 120, 120, 120, 120,
- 512, 512, 512, 512
-};
-
-// Temporary storage before the column pass
-#define ROW1 "%%xmm6"
-#define ROW3 "%%xmm4"
-#define ROW5 "%%xmm5"
-#define ROW7 "%%xmm7"
-
-#define CLEAR_ODD(r) "pxor "r","r" \n\t"
-#define PUT_ODD(dst) "pshufhw $0x1B, %%xmm2, "dst" \n\t"
-
-#if ARCH_X86_64
-
-# define ROW0 "%%xmm8"
-# define REG0 ROW0
-# define ROW2 "%%xmm9"
-# define REG2 ROW2
-# define ROW4 "%%xmm10"
-# define REG4 ROW4
-# define ROW6 "%%xmm11"
-# define REG6 ROW6
-# define CLEAR_EVEN(r) CLEAR_ODD(r)
-# define PUT_EVEN(dst) PUT_ODD(dst)
-# define XMMS "%%xmm12"
-# define MOV_32_ONLY "#"
-# define SREG2 REG2
-# define TAN3 "%%xmm13"
-# define TAN1 "%%xmm14"
-
-#else
-
-# define ROW0 "(%0)"
-# define REG0 "%%xmm4"
-# define ROW2 "2*16(%0)"
-# define REG2 "%%xmm4"
-# define ROW4 "4*16(%0)"
-# define REG4 "%%xmm6"
-# define ROW6 "6*16(%0)"
-# define REG6 "%%xmm6"
-# define CLEAR_EVEN(r)
-# define PUT_EVEN(dst) \
- "pshufhw $0x1B, %%xmm2, %%xmm2 \n\t" \
- "movdqa %%xmm2, "dst" \n\t"
-# define XMMS "%%xmm2"
-# define MOV_32_ONLY "movdqa "
-# define SREG2 "%%xmm7"
-# define TAN3 "%%xmm0"
-# define TAN1 "%%xmm2"
-
-#endif
-
-#define ROUND(x) "paddd "MANGLE(x)
-
-#define JZ(reg, to) \
- "testl "reg","reg" \n\t" \
- "jz "to" \n\t"
-
-#define JNZ(reg, to) \
- "testl "reg","reg" \n\t" \
- "jnz "to" \n\t"
-
-#define TEST_ONE_ROW(src, reg, clear) \
- clear \
- "movq "src", %%mm1 \n\t" \
- "por 8+"src", %%mm1 \n\t" \
- "paddusb %%mm0, %%mm1 \n\t" \
- "pmovmskb %%mm1, "reg" \n\t"
-
-#define TEST_TWO_ROWS(row1, row2, reg1, reg2, clear1, clear2) \
- clear1 \
- clear2 \
- "movq "row1", %%mm1 \n\t" \
- "por 8+"row1", %%mm1 \n\t" \
- "movq "row2", %%mm2 \n\t" \
- "por 8+"row2", %%mm2 \n\t" \
- "paddusb %%mm0, %%mm1 \n\t" \
- "paddusb %%mm0, %%mm2 \n\t" \
- "pmovmskb %%mm1, "reg1" \n\t" \
- "pmovmskb %%mm2, "reg2" \n\t"
-
-///IDCT pass on rows.
-#define iMTX_MULT(src, table, rounder, put) \
- "movdqa "src", %%xmm3 \n\t" \
- "movdqa %%xmm3, %%xmm0 \n\t" \
- "pshufd $0x11, %%xmm3, %%xmm1 \n\t" /* 4602 */ \
- "punpcklqdq %%xmm0, %%xmm0 \n\t" /* 0246 */ \
- "pmaddwd "table", %%xmm0 \n\t" \
- "pmaddwd 16+"table", %%xmm1 \n\t" \
- "pshufd $0xBB, %%xmm3, %%xmm2 \n\t" /* 5713 */ \
- "punpckhqdq %%xmm3, %%xmm3 \n\t" /* 1357 */ \
- "pmaddwd 32+"table", %%xmm2 \n\t" \
- "pmaddwd 48+"table", %%xmm3 \n\t" \
- "paddd %%xmm1, %%xmm0 \n\t" \
- "paddd %%xmm3, %%xmm2 \n\t" \
- rounder", %%xmm0 \n\t" \
- "movdqa %%xmm2, %%xmm3 \n\t" \
- "paddd %%xmm0, %%xmm2 \n\t" \
- "psubd %%xmm3, %%xmm0 \n\t" \
- "psrad $11, %%xmm2 \n\t" \
- "psrad $11, %%xmm0 \n\t" \
- "packssdw %%xmm0, %%xmm2 \n\t" \
- put \
- "1: \n\t"
-
-#define iLLM_HEAD \
- "movdqa "MANGLE(tan3)", "TAN3" \n\t" \
- "movdqa "MANGLE(tan1)", "TAN1" \n\t" \
-
-///IDCT pass on columns.
-#define iLLM_PASS(dct) \
- "movdqa "TAN3", %%xmm1 \n\t" \
- "movdqa "TAN1", %%xmm3 \n\t" \
- "pmulhw %%xmm4, "TAN3" \n\t" \
- "pmulhw %%xmm5, %%xmm1 \n\t" \
- "paddsw %%xmm4, "TAN3" \n\t" \
- "paddsw %%xmm5, %%xmm1 \n\t" \
- "psubsw %%xmm5, "TAN3" \n\t" \
- "paddsw %%xmm4, %%xmm1 \n\t" \
- "pmulhw %%xmm7, %%xmm3 \n\t" \
- "pmulhw %%xmm6, "TAN1" \n\t" \
- "paddsw %%xmm6, %%xmm3 \n\t" \
- "psubsw %%xmm7, "TAN1" \n\t" \
- "movdqa %%xmm3, %%xmm7 \n\t" \
- "movdqa "TAN1", %%xmm6 \n\t" \
- "psubsw %%xmm1, %%xmm3 \n\t" \
- "psubsw "TAN3", "TAN1" \n\t" \
- "paddsw %%xmm7, %%xmm1 \n\t" \
- "paddsw %%xmm6, "TAN3" \n\t" \
- "movdqa %%xmm3, %%xmm6 \n\t" \
- "psubsw "TAN3", %%xmm3 \n\t" \
- "paddsw %%xmm6, "TAN3" \n\t" \
- "movdqa "MANGLE(sqrt2)", %%xmm4 \n\t" \
- "pmulhw %%xmm4, %%xmm3 \n\t" \
- "pmulhw %%xmm4, "TAN3" \n\t" \
- "paddsw "TAN3", "TAN3" \n\t" \
- "paddsw %%xmm3, %%xmm3 \n\t" \
- "movdqa "MANGLE(tan2)", %%xmm7 \n\t" \
- MOV_32_ONLY ROW2", "REG2" \n\t" \
- MOV_32_ONLY ROW6", "REG6" \n\t" \
- "movdqa %%xmm7, %%xmm5 \n\t" \
- "pmulhw "REG6", %%xmm7 \n\t" \
- "pmulhw "REG2", %%xmm5 \n\t" \
- "paddsw "REG2", %%xmm7 \n\t" \
- "psubsw "REG6", %%xmm5 \n\t" \
- MOV_32_ONLY ROW0", "REG0" \n\t" \
- MOV_32_ONLY ROW4", "REG4" \n\t" \
- MOV_32_ONLY" "TAN1", (%0) \n\t" \
- "movdqa "REG0", "XMMS" \n\t" \
- "psubsw "REG4", "REG0" \n\t" \
- "paddsw "XMMS", "REG4" \n\t" \
- "movdqa "REG4", "XMMS" \n\t" \
- "psubsw %%xmm7, "REG4" \n\t" \
- "paddsw "XMMS", %%xmm7 \n\t" \
- "movdqa "REG0", "XMMS" \n\t" \
- "psubsw %%xmm5, "REG0" \n\t" \
- "paddsw "XMMS", %%xmm5 \n\t" \
- "movdqa %%xmm5, "XMMS" \n\t" \
- "psubsw "TAN3", %%xmm5 \n\t" \
- "paddsw "XMMS", "TAN3" \n\t" \
- "movdqa "REG0", "XMMS" \n\t" \
- "psubsw %%xmm3, "REG0" \n\t" \
- "paddsw "XMMS", %%xmm3 \n\t" \
- MOV_32_ONLY" (%0), "TAN1" \n\t" \
- "psraw $6, %%xmm5 \n\t" \
- "psraw $6, "REG0" \n\t" \
- "psraw $6, "TAN3" \n\t" \
- "psraw $6, %%xmm3 \n\t" \
- "movdqa "TAN3", 1*16("dct") \n\t" \
- "movdqa %%xmm3, 2*16("dct") \n\t" \
- "movdqa "REG0", 5*16("dct") \n\t" \
- "movdqa %%xmm5, 6*16("dct") \n\t" \
- "movdqa %%xmm7, %%xmm0 \n\t" \
- "movdqa "REG4", %%xmm4 \n\t" \
- "psubsw %%xmm1, %%xmm7 \n\t" \
- "psubsw "TAN1", "REG4" \n\t" \
- "paddsw %%xmm0, %%xmm1 \n\t" \
- "paddsw %%xmm4, "TAN1" \n\t" \
- "psraw $6, %%xmm1 \n\t" \
- "psraw $6, %%xmm7 \n\t" \
- "psraw $6, "TAN1" \n\t" \
- "psraw $6, "REG4" \n\t" \
- "movdqa %%xmm1, ("dct") \n\t" \
- "movdqa "TAN1", 3*16("dct") \n\t" \
- "movdqa "REG4", 4*16("dct") \n\t" \
- "movdqa %%xmm7, 7*16("dct") \n\t"
-
-///IDCT pass on columns, assuming rows 4-7 are zero.
-#define iLLM_PASS_SPARSE(dct) \
- "pmulhw %%xmm4, "TAN3" \n\t" \
- "paddsw %%xmm4, "TAN3" \n\t" \
- "movdqa %%xmm6, %%xmm3 \n\t" \
- "pmulhw %%xmm6, "TAN1" \n\t" \
- "movdqa %%xmm4, %%xmm1 \n\t" \
- "psubsw %%xmm1, %%xmm3 \n\t" \
- "paddsw %%xmm6, %%xmm1 \n\t" \
- "movdqa "TAN1", %%xmm6 \n\t" \
- "psubsw "TAN3", "TAN1" \n\t" \
- "paddsw %%xmm6, "TAN3" \n\t" \
- "movdqa %%xmm3, %%xmm6 \n\t" \
- "psubsw "TAN3", %%xmm3 \n\t" \
- "paddsw %%xmm6, "TAN3" \n\t" \
- "movdqa "MANGLE(sqrt2)", %%xmm4 \n\t" \
- "pmulhw %%xmm4, %%xmm3 \n\t" \
- "pmulhw %%xmm4, "TAN3" \n\t" \
- "paddsw "TAN3", "TAN3" \n\t" \
- "paddsw %%xmm3, %%xmm3 \n\t" \
- "movdqa "MANGLE(tan2)", %%xmm5 \n\t" \
- MOV_32_ONLY ROW2", "SREG2" \n\t" \
- "pmulhw "SREG2", %%xmm5 \n\t" \
- MOV_32_ONLY ROW0", "REG0" \n\t" \
- "movdqa "REG0", %%xmm6 \n\t" \
- "psubsw "SREG2", %%xmm6 \n\t" \
- "paddsw "REG0", "SREG2" \n\t" \
- MOV_32_ONLY" "TAN1", (%0) \n\t" \
- "movdqa "REG0", "XMMS" \n\t" \
- "psubsw %%xmm5, "REG0" \n\t" \
- "paddsw "XMMS", %%xmm5 \n\t" \
- "movdqa %%xmm5, "XMMS" \n\t" \
- "psubsw "TAN3", %%xmm5 \n\t" \
- "paddsw "XMMS", "TAN3" \n\t" \
- "movdqa "REG0", "XMMS" \n\t" \
- "psubsw %%xmm3, "REG0" \n\t" \
- "paddsw "XMMS", %%xmm3 \n\t" \
- MOV_32_ONLY" (%0), "TAN1" \n\t" \
- "psraw $6, %%xmm5 \n\t" \
- "psraw $6, "REG0" \n\t" \
- "psraw $6, "TAN3" \n\t" \
- "psraw $6, %%xmm3 \n\t" \
- "movdqa "TAN3", 1*16("dct") \n\t" \
- "movdqa %%xmm3, 2*16("dct") \n\t" \
- "movdqa "REG0", 5*16("dct") \n\t" \
- "movdqa %%xmm5, 6*16("dct") \n\t" \
- "movdqa "SREG2", %%xmm0 \n\t" \
- "movdqa %%xmm6, %%xmm4 \n\t" \
- "psubsw %%xmm1, "SREG2" \n\t" \
- "psubsw "TAN1", %%xmm6 \n\t" \
- "paddsw %%xmm0, %%xmm1 \n\t" \
- "paddsw %%xmm4, "TAN1" \n\t" \
- "psraw $6, %%xmm1 \n\t" \
- "psraw $6, "SREG2" \n\t" \
- "psraw $6, "TAN1" \n\t" \
- "psraw $6, %%xmm6 \n\t" \
- "movdqa %%xmm1, ("dct") \n\t" \
- "movdqa "TAN1", 3*16("dct") \n\t" \
- "movdqa %%xmm6, 4*16("dct") \n\t" \
- "movdqa "SREG2", 7*16("dct") \n\t"
-
-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))
-
- 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))
-
- 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))
- iLLM_HEAD
- ".p2align 4 \n\t"
- JNZ("%%ecx", "2f")
- JNZ("%%eax", "3f")
- JNZ("%%edx", "4f")
- JNZ("%%esi", "5f")
- iLLM_PASS_SPARSE("%0")
- "jmp 6f \n\t"
- "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))
- JZ("%%edx", "1f")
- "4: \n\t"
- iMTX_MULT("6*16(%0)", MANGLE(iTab3), ROUND(walkenIdctRounders+5*16), PUT_EVEN(ROW6))
- JZ("%%esi", "1f")
- "5: \n\t"
- iMTX_MULT("7*16(%0)", MANGLE(iTab2), ROUND(walkenIdctRounders+5*16), PUT_ODD(ROW7))
-#if ARCH_X86_32
- iLLM_HEAD
-#endif
- iLLM_PASS("%0")
- "6: \n\t"
- : "+r"(block)
- :
- : XMM_CLOBBERS("%xmm0" , "%xmm1" , "%xmm2" , "%xmm3" ,
- "%xmm4" , "%xmm5" , "%xmm6" , "%xmm7" ,)
-#if ARCH_X86_64
- XMM_CLOBBERS("%xmm8" , "%xmm9" , "%xmm10", "%xmm11",
- "%xmm12", "%xmm13", "%xmm14",)
-#endif
- "%eax", "%ecx", "%edx", "%esi", "memory"
- );
-}
-
-void ff_idct_xvid_sse2_put(uint8_t *dest, int line_size, short *block)
-{
- ff_idct_xvid_sse2(block);
- ff_put_pixels_clamped_mmx(block, dest, line_size);
-}
-
-void ff_idct_xvid_sse2_add(uint8_t *dest, int line_size, short *block)
-{
- ff_idct_xvid_sse2(block);
- ff_add_pixels_clamped_mmx(block, dest, line_size);
-}
-
-#endif /* HAVE_INLINE_ASM */
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/idct_xvid.h b/src/thirdparty/ffmpeg/libavcodec/x86/idct_xvid.h
deleted file mode 100644
index 6cee2654b..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/idct_xvid.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * XVID MPEG-4 VIDEO CODEC
- *
- * 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
- * header for Xvid IDCT functions
- */
-
-#ifndef AVCODEC_X86_IDCT_XVID_H
-#define AVCODEC_X86_IDCT_XVID_H
-
-#include <stdint.h>
-
-void ff_idct_xvid_mmx(short *block);
-void ff_idct_xvid_mmx_put(uint8_t *dest, int line_size, int16_t *block);
-void ff_idct_xvid_mmx_add(uint8_t *dest, int line_size, int16_t *block);
-
-void ff_idct_xvid_mmxext(short *block);
-void ff_idct_xvid_mmxext_put(uint8_t *dest, int line_size, int16_t *block);
-void ff_idct_xvid_mmxext_add(uint8_t *dest, int line_size, int16_t *block);
-
-void ff_idct_xvid_sse2(short *block);
-void ff_idct_xvid_sse2_put(uint8_t *dest, int line_size, short *block);
-void ff_idct_xvid_sse2_add(uint8_t *dest, int line_size, short *block);
-
-#endif /* AVCODEC_X86_IDCT_XVID_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/imdct36.asm b/src/thirdparty/ffmpeg/libavcodec/x86/imdct36.asm
deleted file mode 100644
index d311fbe1a..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/imdct36.asm
+++ /dev/null
@@ -1,724 +0,0 @@
-;******************************************************************************
-;* 36 point SSE-optimized IMDCT transform
-;* Copyright (c) 2011 Vitor Sessak
-;*
-;* 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
-
-align 16
-ps_mask: dd 0, ~0, ~0, ~0
-ps_mask2: dd 0, ~0, 0, ~0
-ps_mask3: dd 0, 0, 0, ~0
-ps_mask4: dd 0, ~0, 0, 0
-
-ps_val1: dd -0.5, -0.5, -0.8660254038, -0.8660254038
-ps_val2: dd 1.0, 1.0, 0.8660254038, 0.8660254038
-ps_val3: dd 0.1736481777, 0.1736481777, 0.3420201433, 0.3420201433
-ps_val4: dd -0.7660444431, -0.7660444431, 0.8660254038, 0.8660254038
-ps_val5: dd -0.9396926208, -0.9396926208, -0.9848077530, -0.9848077530
-ps_val6: dd 0.5, 0.5, -0.6427876097, -0.6427876097
-ps_val7: dd 1.0, 1.0, -0.6427876097, -0.6427876097
-
-ps_p1p1m1m1: dd 0, 0, 0x80000000, 0x80000000
-ps_p1m1p1m1: dd 0, 0x80000000, 0, 0x80000000
-
-ps_cosh: 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
-
-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
-
-costabs: times 4 dd 0.98480773
- times 4 dd 0.93969262
- times 4 dd 0.86602539
- times 4 dd -0.76604444
- times 4 dd -0.64278764
- times 4 dd 0.50000000
- times 4 dd -0.50000000
- times 4 dd -0.34202015
- times 4 dd -0.17364818
- times 4 dd 0.50190992
- times 4 dd 0.51763808
- times 4 dd 0.55168896
- times 4 dd 0.61038726
- times 4 dd 0.70710677
- times 4 dd 0.87172341
- times 4 dd 1.18310082
- times 4 dd 1.93185163
- times 4 dd 5.73685646
-
-%define SBLIMIT 32
-SECTION_TEXT
-
-%macro PSHUFD 3
-%if cpuflag(sse2) && notcpuflag(avx)
- pshufd %1, %2, %3
-%else
- shufps %1, %2, %2, %3
-%endif
-%endmacro
-
-; input %2={x1,x2,x3,x4}, %3={y1,y2,y3,y4}
-; output %1={x3,x4,y1,y2}
-%macro BUILDINVHIGHLOW 3
-%if cpuflag(avx)
- shufps %1, %2, %3, 0x4e
-%else
- movlhps %1, %3
- movhlps %1, %2
-%endif
-%endmacro
-
-; input %2={x1,x2,x3,x4}, %3={y1,y2,y3,y4}
-; output %1={x4,y1,y2,y3}
-%macro ROTLEFT 3
-%if cpuflag(ssse3)
- palignr %1, %3, %2, 12
-%else
- BUILDINVHIGHLOW %1, %2, %3
- shufps %1, %1, %3, 0x99
-%endif
-%endmacro
-
-%macro INVERTHL 2
-%if cpuflag(sse2)
- PSHUFD %1, %2, 0x4e
-%else
- movhlps %1, %2
- movlhps %1, %2
-%endif
-%endmacro
-
-%macro BUTTERF 3
- INVERTHL %2, %1
- xorps %1, [ps_p1p1m1m1]
- addps %1, %2
-%if cpuflag(sse3)
- mulps %1, %1, [ps_cosh_sse3 + %3]
- PSHUFD %2, %1, 0xb1
- addsubps %1, %1, %2
-%else
- mulps %1, [ps_cosh + %3]
- PSHUFD %2, %1, 0xb1
- xorps %1, [ps_p1m1p1m1]
- addps %1, %2
-%endif
-%endmacro
-
-%macro STORE 4
- movhlps %2, %1
- movss [%3 ], %1
- movss [%3 + 2*%4], %2
- shufps %1, %1, 0xb1
- movss [%3 + %4], %1
- movhlps %2, %1
- movss [%3 + 3*%4], %2
-%endmacro
-
-%macro LOAD 4
- movlps %1, [%3 ]
- movhps %1, [%3 + %4]
- movlps %2, [%3 + 2*%4]
- movhps %2, [%3 + 3*%4]
- shufps %1, %2, 0x88
-%endmacro
-
-%macro LOADA64 2
-%if cpuflag(avx)
- movu %1, [%2]
-%else
- movlps %1, [%2]
- movhps %1, [%2 + 8]
-%endif
-%endmacro
-
-%macro DEFINE_IMDCT 0
-cglobal imdct36_float, 4,4,9, out, buf, in, win
-
- ; for(i=17;i>=1;i--) in[i] += in[i-1];
- LOADA64 m0, inq
- LOADA64 m1, inq + 16
-
- ROTLEFT m5, m0, m1
-
- PSHUFD m6, m0, 0x93
- andps m6, m6, [ps_mask]
- addps m0, m0, m6
-
- LOADA64 m2, inq + 32
-
- ROTLEFT m7, m1, m2
-
- addps m1, m1, m5
- LOADA64 m3, inq + 48
-
- ROTLEFT m5, m2, m3
-
- xorps m4, m4, m4
- movlps m4, [inq+64]
- BUILDINVHIGHLOW m6, m3, m4
- shufps m6, m6, m4, 0xa9
-
- addps m4, m4, m6
- addps m2, m2, m7
- addps m3, m3, m5
-
- ; for(i=17;i>=3;i-=2) in[i] += in[i-2];
- movlhps m5, m5, m0
- andps m5, m5, [ps_mask3]
-
- BUILDINVHIGHLOW m7, m0, m1
- andps m7, m7, [ps_mask2]
-
- addps m0, m0, m5
-
- BUILDINVHIGHLOW m6, m1, m2
- andps m6, m6, [ps_mask2]
-
- addps m1, m1, m7
-
- BUILDINVHIGHLOW m7, m2, m3
- andps m7, m7, [ps_mask2]
-
- addps m2, m2, m6
-
- movhlps m6, m6, m3
- andps m6, m6, [ps_mask4]
-
- addps m3, m3, m7
- addps m4, m4, m6
-
- ; Populate tmp[]
- movlhps m6, m1, m5 ; zero out high values
- subps m6, m6, m4
-
- subps m5, m0, m3
-
-%if ARCH_X86_64
- SWAP m5, m8
-%endif
-
- mulps m7, m2, [ps_val1]
-
-%if ARCH_X86_64
- mulps m5, m8, [ps_val2]
-%else
- mulps m5, m5, [ps_val2]
-%endif
- addps m7, m7, m5
-
- mulps m5, m6, [ps_val1]
- subps m7, m7, m5
-
-%if ARCH_X86_64
- SWAP m5, m8
-%else
- subps m5, m0, m3
-%endif
-
- subps m5, m5, m6
- addps m5, m5, m2
-
- shufps m6, m4, m3, 0xe4
- subps m6, m6, m2
- mulps m6, m6, [ps_val3]
-
- addps m4, m4, m1
- mulps m4, m4, [ps_val4]
-
- shufps m1, m1, m0, 0xe4
- addps m1, m1, m2
- mulps m1, m1, [ps_val5]
-
- mulps m3, m3, [ps_val6]
- mulps m0, m0, [ps_val7]
- addps m0, m0, m3
-
- xorps m2, m1, [ps_p1p1m1m1]
- subps m2, m2, m4
- addps m2, m2, m0
-
- addps m3, m4, m0
- subps m3, m3, m6
- xorps m3, m3, [ps_p1p1m1m1]
-
- shufps m0, m0, m4, 0xe4
- subps m0, m0, m1
- addps m0, m0, m6
-
- BUILDINVHIGHLOW m4, m2, m3
- shufps m3, m3, m2, 0x4e
-
- ; we have tmp = {SwAPLH(m0), SwAPLH(m7), m3, m4, m5}
-
- BUTTERF m0, m1, 0
- 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
-
- ; permutates:
- ; m0 0 1 2 3 => 2 6 10 14 m1
- ; m7 4 5 6 7 => 3 7 11 15 m2
- ; m3 8 9 10 11 => 17 13 9 5 m3
- ; m4 12 13 14 15 => 16 12 8 4 m5
- ; m5 16 17 xx xx => 0 1 xx xx m0
-
- unpckhps m1, m0, m7
- unpckhps m6, m3, m4
- movhlps m2, m6, m1
- movlhps m1, m1, m6
-
- unpcklps m5, m5, m4
- unpcklps m3, m3, m7
- movhlps m4, m3, m5
- movlhps m5, m5, m3
- SWAP m4, m3
- ; permutation done
-
- PSHUFD m6, m2, 0xb1
- movss m4, [bufq + 4*68]
- movss m7, [bufq + 4*64]
- unpcklps m7, m7, m4
- mulps m6, m6, [winq + 16*4]
- addps m6, m6, m7
- movss [outq + 64*SBLIMIT], m6
- shufps m6, m6, m6, 0xb1
- movss [outq + 68*SBLIMIT], m6
-
- mulps m6, m3, [winq + 4*4]
- LOAD m4, m7, bufq + 4*16, 16
- addps m6, m6, m4
- STORE m6, m7, outq + 16*SBLIMIT, 4*SBLIMIT
-
- shufps m4, m0, m3, 0xb5
- mulps m4, m4, [winq + 8*4]
- LOAD m7, m6, bufq + 4*32, 16
- addps m4, m4, m7
- STORE m4, m6, outq + 32*SBLIMIT, 4*SBLIMIT
-
- shufps m3, m3, m2, 0xb1
- mulps m3, m3, [winq + 12*4]
- LOAD m7, m6, bufq + 4*48, 16
- addps m3, m3, m7
- STORE m3, m7, outq + 48*SBLIMIT, 4*SBLIMIT
-
- mulps m2, m2, [winq]
- LOAD m6, m7, bufq, 16
- addps m2, m2, m6
- STORE m2, m7, outq, 4*SBLIMIT
-
- mulps m4, m1, [winq + 20*4]
- STORE m4, m7, bufq, 16
-
- mulps m3, m5, [winq + 24*4]
- STORE m3, m7, bufq + 4*16, 16
-
- shufps m0, m0, m5, 0xb0
- mulps m0, m0, [winq + 28*4]
- STORE m0, m7, bufq + 4*32, 16
-
- shufps m5, m5, m1, 0xb1
- mulps m5, m5, [winq + 32*4]
- STORE m5, m7, bufq + 4*48, 16
-
- shufps m1, m1, m1, 0xb1
- mulps m1, m1, [winq + 36*4]
- movss [bufq + 4*64], m1
- shufps m1, m1, 0xb1
- movss [bufq + 4*68], m1
- RET
-%endmacro
-
-INIT_XMM sse
-DEFINE_IMDCT
-
-INIT_XMM sse2
-DEFINE_IMDCT
-
-INIT_XMM sse3
-DEFINE_IMDCT
-
-INIT_XMM ssse3
-DEFINE_IMDCT
-
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-DEFINE_IMDCT
-%endif
-
-INIT_XMM sse
-
-%if ARCH_X86_64
-%define SPILL SWAP
-%define UNSPILL SWAP
-%define SPILLED(x) m %+ x
-%else
-%define SPILLED(x) [tmpq+(x-8)*16 + 32*4]
-%macro SPILL 2 ; xmm#, mempos
- movaps SPILLED(%2), m%1
-%endmacro
-%macro UNSPILL 2
- movaps m%1, SPILLED(%2)
-%endmacro
-%endif
-
-%macro DEFINE_FOUR_IMDCT 0
-cglobal four_imdct36_float, 5,5,16, out, buf, in, win, tmp
- movlps m0, [inq+64]
- movhps m0, [inq+64 + 72]
- movlps m3, [inq+64 + 2*72]
- movhps m3, [inq+64 + 3*72]
-
- shufps m5, m0, m3, 0xdd
- shufps m0, m0, m3, 0x88
-
- mova m1, [inq+48]
- movu m6, [inq+48 + 72]
- mova m7, [inq+48 + 2*72]
- movu m3, [inq+48 + 3*72]
-
- TRANSPOSE4x4PS 1, 6, 7, 3, 4
-
- addps m4, m6, m7
- mova [tmpq+4*28], m4
-
- addps m7, m3
- addps m6, m1
- addps m3, m0
- addps m0, m5
- addps m0, m7
- addps m7, m6
- mova [tmpq+4*12], m7
- SPILL 3, 12
-
- mova m4, [inq+32]
- movu m5, [inq+32 + 72]
- mova m2, [inq+32 + 2*72]
- movu m7, [inq+32 + 3*72]
-
- TRANSPOSE4x4PS 4, 5, 2, 7, 3
-
- addps m1, m7
- SPILL 1, 11
-
- addps m3, m5, m2
- SPILL 3, 13
-
- addps m7, m2
- addps m5, m4
- addps m6, m7
- mova [tmpq], m6
- addps m7, m5
- mova [tmpq+4*16], m7
-
- mova m2, [inq+16]
- movu m7, [inq+16 + 72]
- mova m1, [inq+16 + 2*72]
- movu m6, [inq+16 + 3*72]
-
- TRANSPOSE4x4PS 2, 7, 1, 6, 3
-
- addps m4, m6
- addps m6, m1
- addps m1, m7
- addps m7, m2
- addps m5, m6
- SPILL 5, 15
- addps m6, m7
- mulps m6, [costabs + 16*2]
- mova [tmpq+4*8], m6
- SPILL 1, 10
- SPILL 0, 14
-
- mova m1, [inq]
- movu m6, [inq + 72]
- mova m3, [inq + 2*72]
- movu m5, [inq + 3*72]
-
- TRANSPOSE4x4PS 1, 6, 3, 5, 0
-
- addps m2, m5
- addps m5, m3
- addps m7, m5
- addps m3, m6
- addps m6, m1
- SPILL 7, 8
- addps m5, m6
- SPILL 6, 9
- addps m6, m4, SPILLED(12)
- subps m6, m2
- UNSPILL 7, 11
- SPILL 5, 11
- subps m5, m1, m7
- mulps m7, [costabs + 16*5]
- addps m7, m1
- mulps m0, m6, [costabs + 16*6]
- addps m0, m5
- mova [tmpq+4*24], m0
- addps m6, m5
- mova [tmpq+4*4], m6
- addps m6, m4, m2
- mulps m6, [costabs + 16*1]
- subps m4, SPILLED(12)
- mulps m4, [costabs + 16*8]
- addps m2, SPILLED(12)
- mulps m2, [costabs + 16*3]
- subps m5, m7, m6
- subps m5, m2
- addps m6, m7
- addps m6, m4
- addps m7, m2
- subps m7, m4
- mova [tmpq+4*20], m7
- mova m2, [tmpq+4*28]
- mova [tmpq+4*28], m5
- UNSPILL 7, 13
- subps m5, m7, m2
- mulps m5, [costabs + 16*7]
- UNSPILL 1, 10
- mulps m1, [costabs + 16*2]
- addps m4, m3, m2
- mulps m4, [costabs + 16*4]
- addps m2, m7
- addps m7, m3
- mulps m7, [costabs]
- subps m3, m2
- mulps m3, [costabs + 16*2]
- addps m2, m7, m5
- addps m2, m1
- SPILL 2, 10
- addps m7, m4
- subps m7, m1
- SPILL 7, 12
- subps m5, m4
- subps m5, m1
- UNSPILL 0, 14
- SPILL 5, 13
- addps m1, m0, SPILLED(15)
- subps m1, SPILLED(8)
- mova m4, [costabs + 16*5]
- mulps m4, [tmpq]
- UNSPILL 2, 9
- addps m4, m2
- subps m2, [tmpq]
- mulps m5, m1, [costabs + 16*6]
- addps m5, m2
- SPILL 5, 9
- addps m2, m1
- SPILL 2, 14
- UNSPILL 5, 15
- subps m7, m5, m0
- addps m5, SPILLED(8)
- mulps m5, [costabs + 16*1]
- mulps m7, [costabs + 16*8]
- addps m0, SPILLED(8)
- mulps m0, [costabs + 16*3]
- subps m2, m4, m5
- subps m2, m0
- SPILL 2, 15
- addps m5, m4
- addps m5, m7
- addps m4, m0
- subps m4, m7
- SPILL 4, 8
- mova m7, [tmpq+4*16]
- mova m2, [tmpq+4*12]
- addps m0, m7, m2
- subps m0, SPILLED(11)
- mulps m0, [costabs + 16*2]
- addps m4, m7, SPILLED(11)
- mulps m4, [costabs]
- subps m7, m2
- mulps m7, [costabs + 16*7]
- addps m2, SPILLED(11)
- mulps m2, [costabs + 16*4]
- addps m1, m7, [tmpq+4*8]
- addps m1, m4
- addps m4, m2
- subps m4, [tmpq+4*8]
- SPILL 4, 11
- subps m7, m2
- subps m7, [tmpq+4*8]
- addps m4, m6, SPILLED(10)
- subps m6, SPILLED(10)
- addps m2, m5, m1
- mulps m2, [costabs + 16*9]
- subps m5, m1
- mulps m5, [costabs + 16*17]
- subps m1, m4, m2
- addps m4, m2
- mulps m2, m1, [winq+4*36]
- addps m2, [bufq+4*36]
- mova [outq+1152], m2
- mulps m1, [winq+4*32]
- addps m1, [bufq+4*32]
- mova [outq+1024], m1
- mulps m1, m4, [winq+4*116]
- mova [bufq+4*36], m1
- mulps m4, [winq+4*112]
- mova [bufq+4*32], m4
- addps m2, m6, m5
- subps m6, m5
- mulps m1, m6, [winq+4*68]
- addps m1, [bufq+4*68]
- mova [outq+2176], m1
- mulps m6, [winq]
- addps m6, [bufq]
- mova [outq], m6
- mulps m1, m2, [winq+4*148]
- mova [bufq+4*68], m1
- mulps m2, [winq+4*80]
- mova [bufq], m2
- addps m5, m3, [tmpq+4*24]
- mova m2, [tmpq+4*24]
- subps m2, m3
- mova m1, SPILLED(9)
- subps m1, m0
- mulps m1, [costabs + 16*10]
- addps m0, SPILLED(9)
- mulps m0, [costabs + 16*16]
- addps m6, m5, m1
- subps m5, m1
- mulps m3, m5, [winq+4*40]
- addps m3, [bufq+4*40]
- mova [outq+1280], m3
- mulps m5, [winq+4*28]
- addps m5, [bufq+4*28]
- mova [outq+896], m5
- mulps m1, m6, [winq+4*120]
- mova [bufq+4*40], m1
- mulps m6, [winq+4*108]
- mova [bufq+4*28], m6
- addps m1, m2, m0
- subps m2, m0
- mulps m5, m2, [winq+4*64]
- addps m5, [bufq+4*64]
- mova [outq+2048], m5
- mulps m2, [winq+4*4]
- addps m2, [bufq+4*4]
- mova [outq+128], m2
- mulps m0, m1, [winq+4*144]
- mova [bufq+4*64], m0
- mulps m1, [winq+4*84]
- mova [bufq+4*4], m1
- mova m1, [tmpq+4*28]
- mova m5, m1
- addps m1, SPILLED(13)
- subps m5, SPILLED(13)
- UNSPILL 3, 15
- addps m2, m7, m3
- mulps m2, [costabs + 16*11]
- subps m3, m7
- mulps m3, [costabs + 16*15]
- addps m0, m2, m1
- subps m1, m2
- SWAP m0, m2
- mulps m6, m1, [winq+4*44]
- addps m6, [bufq+4*44]
- mova [outq+1408], m6
- mulps m1, [winq+4*24]
- addps m1, [bufq+4*24]
- mova [outq+768], m1
- mulps m0, m2, [winq+4*124]
- mova [bufq+4*44], m0
- mulps m2, [winq+4*104]
- mova [bufq+4*24], m2
- addps m0, m5, m3
- subps m5, m3
- mulps m1, m5, [winq+4*60]
- addps m1, [bufq+4*60]
- mova [outq+1920], m1
- mulps m5, [winq+4*8]
- addps m5, [bufq+4*8]
- mova [outq+256], m5
- mulps m1, m0, [winq+4*140]
- mova [bufq+4*60], m1
- mulps m0, [winq+4*88]
- mova [bufq+4*8], m0
- mova m1, [tmpq+4*20]
- addps m1, SPILLED(12)
- mova m2, [tmpq+4*20]
- subps m2, SPILLED(12)
- UNSPILL 7, 8
- subps m0, m7, SPILLED(11)
- addps m7, SPILLED(11)
- mulps m4, m7, [costabs + 16*12]
- mulps m0, [costabs + 16*14]
- addps m5, m1, m4
- subps m1, m4
- mulps m7, m1, [winq+4*48]
- addps m7, [bufq+4*48]
- mova [outq+1536], m7
- mulps m1, [winq+4*20]
- addps m1, [bufq+4*20]
- mova [outq+640], m1
- mulps m1, m5, [winq+4*128]
- mova [bufq+4*48], m1
- mulps m5, [winq+4*100]
- mova [bufq+4*20], m5
- addps m6, m2, m0
- subps m2, m0
- mulps m1, m2, [winq+4*56]
- addps m1, [bufq+4*56]
- mova [outq+1792], m1
- mulps m2, [winq+4*12]
- addps m2, [bufq+4*12]
- mova [outq+384], m2
- mulps m0, m6, [winq+4*136]
- mova [bufq+4*56], m0
- mulps m6, [winq+4*92]
- mova [bufq+4*12], m6
- UNSPILL 0, 14
- mulps m0, [costabs + 16*13]
- mova m3, [tmpq+4*4]
- addps m2, m0, m3
- subps m3, m0
- mulps m0, m3, [winq+4*52]
- addps m0, [bufq+4*52]
- mova [outq+1664], m0
- mulps m3, [winq+4*16]
- addps m3, [bufq+4*16]
- mova [outq+512], m3
- mulps m0, m2, [winq+4*132]
- mova [bufq+4*52], m0
- mulps m2, [winq+4*96]
- mova [bufq+4*16], m2
- RET
-%endmacro
-
-INIT_XMM sse
-DEFINE_FOUR_IMDCT
-
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-DEFINE_FOUR_IMDCT
-%endif
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/mathops.h b/src/thirdparty/ffmpeg/libavcodec/x86/mathops.h
deleted file mode 100644
index 5409912c6..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/mathops.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * simple math operations
- * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> et al
- *
- * 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_MATHOPS_H
-#define AVCODEC_X86_MATHOPS_H
-
-#include "config.h"
-#include "libavutil/common.h"
-
-#if HAVE_INLINE_ASM
-
-#if ARCH_X86_32
-
-#define MULL MULL
-static av_always_inline av_const int MULL(int a, int b, unsigned shift)
-{
- int rt, dummy;
- __asm__ (
- "imull %3 \n\t"
- "shrdl %4, %%edx, %%eax \n\t"
- :"=a"(rt), "=d"(dummy)
- :"a"(a), "rm"(b), "ci"((uint8_t)shift)
- );
- return rt;
-}
-
-#define MULH MULH
-static av_always_inline av_const int MULH(int a, int b)
-{
- int rt, dummy;
- __asm__ (
- "imull %3"
- :"=d"(rt), "=a"(dummy)
- :"a"(a), "rm"(b)
- );
- return rt;
-}
-
-#define MUL64 MUL64
-static av_always_inline av_const int64_t MUL64(int a, int b)
-{
- int64_t rt;
- __asm__ (
- "imull %2"
- :"=A"(rt)
- :"a"(a), "rm"(b)
- );
- return rt;
-}
-
-#endif /* ARCH_X86_32 */
-
-#if HAVE_CMOV
-/* median of 3 */
-#define mid_pred mid_pred
-static inline av_const int mid_pred(int a, int b, int c)
-{
- int i=b;
- __asm__ volatile(
- "cmp %2, %1 \n\t"
- "cmovg %1, %0 \n\t"
- "cmovg %2, %1 \n\t"
- "cmp %3, %1 \n\t"
- "cmovl %3, %1 \n\t"
- "cmp %1, %0 \n\t"
- "cmovg %1, %0 \n\t"
- :"+&r"(i), "+&r"(a)
- :"r"(b), "r"(c)
- );
- return i;
-}
-#endif
-
-#if HAVE_CMOV
-#define COPY3_IF_LT(x, y, a, b, c, d)\
-__asm__ volatile(\
- "cmpl %0, %3 \n\t"\
- "cmovl %3, %0 \n\t"\
- "cmovl %4, %1 \n\t"\
- "cmovl %5, %2 \n\t"\
- : "+&r" (x), "+&r" (a), "+r" (c)\
- : "r" (y), "r" (b), "r" (d)\
-);
-#endif
-
-#define MASK_ABS(mask, level) \
- __asm__ ("cltd \n\t" \
- "xorl %1, %0 \n\t" \
- "subl %1, %0 \n\t" \
- : "+a"(level), "=&d"(mask))
-
-// avoid +32 for shift optimization (gcc should do that ...)
-#define NEG_SSR32 NEG_SSR32
-static inline int32_t NEG_SSR32( int32_t a, int8_t s){
- __asm__ ("sarl %1, %0\n\t"
- : "+r" (a)
- : "ic" ((uint8_t)(-s))
- );
- return a;
-}
-
-#define NEG_USR32 NEG_USR32
-static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
- __asm__ ("shrl %1, %0\n\t"
- : "+r" (a)
- : "ic" ((uint8_t)(-s))
- );
- return a;
-}
-
-#endif /* HAVE_INLINE_ASM */
-#endif /* AVCODEC_X86_MATHOPS_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/mlpdsp.c b/src/thirdparty/ffmpeg/libavcodec/x86/mlpdsp.c
deleted file mode 100644
index bc819c87f..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/mlpdsp.c
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * MLP DSP functions x86-optimized
- * Copyright (c) 2009 Ramiro Polla
- *
- * 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 "libavcodec/mlpdsp.h"
-#include "libavcodec/mlp.h"
-
-#if HAVE_7REGS && HAVE_INLINE_ASM
-
-extern char ff_mlp_firorder_8;
-extern char ff_mlp_firorder_7;
-extern char ff_mlp_firorder_6;
-extern char ff_mlp_firorder_5;
-extern char ff_mlp_firorder_4;
-extern char ff_mlp_firorder_3;
-extern char ff_mlp_firorder_2;
-extern char ff_mlp_firorder_1;
-extern char ff_mlp_firorder_0;
-
-extern char ff_mlp_iirorder_4;
-extern char ff_mlp_iirorder_3;
-extern char ff_mlp_iirorder_2;
-extern char ff_mlp_iirorder_1;
-extern char ff_mlp_iirorder_0;
-
-static const void *firtable[9] = { &ff_mlp_firorder_0, &ff_mlp_firorder_1,
- &ff_mlp_firorder_2, &ff_mlp_firorder_3,
- &ff_mlp_firorder_4, &ff_mlp_firorder_5,
- &ff_mlp_firorder_6, &ff_mlp_firorder_7,
- &ff_mlp_firorder_8 };
-static const void *iirtable[5] = { &ff_mlp_iirorder_0, &ff_mlp_iirorder_1,
- &ff_mlp_iirorder_2, &ff_mlp_iirorder_3,
- &ff_mlp_iirorder_4 };
-
-#if ARCH_X86_64
-
-#define MLPMUL(label, offset, offs, offc) \
- LABEL_MANGLE(label)": \n\t" \
- "movslq "offset"+"offs"(%0), %%rax\n\t" \
- "movslq "offset"+"offc"(%1), %%rdx\n\t" \
- "imul %%rdx, %%rax\n\t" \
- "add %%rax, %%rsi\n\t"
-
-#define FIRMULREG(label, offset, firc)\
- LABEL_MANGLE(label)": \n\t" \
- "movslq "#offset"(%0), %%rax\n\t" \
- "imul %"#firc", %%rax\n\t" \
- "add %%rax, %%rsi\n\t"
-
-#define CLEAR_ACCUM \
- "xor %%rsi, %%rsi\n\t"
-
-#define SHIFT_ACCUM \
- "shr %%cl, %%rsi\n\t"
-
-#define ACCUM "%%rdx"
-#define RESULT "%%rsi"
-#define RESULT32 "%%esi"
-
-#else /* if ARCH_X86_32 */
-
-#define MLPMUL(label, offset, offs, offc) \
- LABEL_MANGLE(label)": \n\t" \
- "mov "offset"+"offs"(%0), %%eax\n\t" \
- "imull "offset"+"offc"(%1) \n\t" \
- "add %%eax , %%esi\n\t" \
- "adc %%edx , %%ecx\n\t"
-
-#define FIRMULREG(label, offset, firc) \
- MLPMUL(label, #offset, "0", "0")
-
-#define CLEAR_ACCUM \
- "xor %%esi, %%esi\n\t" \
- "xor %%ecx, %%ecx\n\t"
-
-#define SHIFT_ACCUM \
- "mov %%ecx, %%edx\n\t" \
- "mov %%esi, %%eax\n\t" \
- "movzbl %7 , %%ecx\n\t" \
- "shrd %%cl, %%edx, %%eax\n\t" \
-
-#define ACCUM "%%edx"
-#define RESULT "%%eax"
-#define RESULT32 "%%eax"
-
-#endif /* !ARCH_X86_64 */
-
-#define BINC AV_STRINGIFY(4* MAX_CHANNELS)
-#define IOFFS AV_STRINGIFY(4*(MAX_FIR_ORDER + MAX_BLOCKSIZE))
-#define IOFFC AV_STRINGIFY(4* MAX_FIR_ORDER)
-
-#define FIRMUL(label, offset) MLPMUL(label, #offset, "0", "0")
-#define IIRMUL(label, offset) MLPMUL(label, #offset, IOFFS, IOFFC)
-
-static void mlp_filter_channel_x86(int32_t *state, const int32_t *coeff,
- int firorder, int iirorder,
- unsigned int filter_shift, int32_t mask,
- int blocksize, int32_t *sample_buffer)
-{
- const void *firjump = firtable[firorder];
- const void *iirjump = iirtable[iirorder];
-
- blocksize = -blocksize;
-
- __asm__ volatile(
- "1: \n\t"
- CLEAR_ACCUM
- "jmp *%5 \n\t"
- FIRMUL (ff_mlp_firorder_8, 0x1c )
- FIRMUL (ff_mlp_firorder_7, 0x18 )
- FIRMUL (ff_mlp_firorder_6, 0x14 )
- FIRMUL (ff_mlp_firorder_5, 0x10 )
- FIRMUL (ff_mlp_firorder_4, 0x0c )
- FIRMULREG(ff_mlp_firorder_3, 0x08,10)
- FIRMULREG(ff_mlp_firorder_2, 0x04, 9)
- FIRMULREG(ff_mlp_firorder_1, 0x00, 8)
- LABEL_MANGLE(ff_mlp_firorder_0)":\n\t"
- "jmp *%6 \n\t"
- IIRMUL (ff_mlp_iirorder_4, 0x0c )
- IIRMUL (ff_mlp_iirorder_3, 0x08 )
- IIRMUL (ff_mlp_iirorder_2, 0x04 )
- IIRMUL (ff_mlp_iirorder_1, 0x00 )
- LABEL_MANGLE(ff_mlp_iirorder_0)":\n\t"
- SHIFT_ACCUM
- "mov "RESULT" ,"ACCUM" \n\t"
- "add (%2) ,"RESULT" \n\t"
- "and %4 ,"RESULT" \n\t"
- "sub $4 , %0 \n\t"
- "mov "RESULT32", (%0) \n\t"
- "mov "RESULT32", (%2) \n\t"
- "add $"BINC" , %2 \n\t"
- "sub "ACCUM" ,"RESULT" \n\t"
- "mov "RESULT32","IOFFS"(%0) \n\t"
- "incl %3 \n\t"
- "js 1b \n\t"
- : /* 0*/"+r"(state),
- /* 1*/"+r"(coeff),
- /* 2*/"+r"(sample_buffer),
-#if ARCH_X86_64
- /* 3*/"+r"(blocksize)
- : /* 4*/"r"((x86_reg)mask), /* 5*/"r"(firjump),
- /* 6*/"r"(iirjump) , /* 7*/"c"(filter_shift)
- , /* 8*/"r"((int64_t)coeff[0])
- , /* 9*/"r"((int64_t)coeff[1])
- , /*10*/"r"((int64_t)coeff[2])
- : "rax", "rdx", "rsi"
-#else /* ARCH_X86_32 */
- /* 3*/"+m"(blocksize)
- : /* 4*/"m"( mask), /* 5*/"m"(firjump),
- /* 6*/"m"(iirjump) , /* 7*/"m"(filter_shift)
- : "eax", "edx", "esi", "ecx"
-#endif /* !ARCH_X86_64 */
- );
-}
-
-#endif /* HAVE_7REGS && HAVE_INLINE_ASM */
-
-av_cold void ff_mlpdsp_init_x86(MLPDSPContext *c)
-{
-#if HAVE_7REGS && HAVE_INLINE_ASM
- c->mlp_filter_channel = mlp_filter_channel_x86;
-#endif
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/motion_est.c b/src/thirdparty/ffmpeg/libavcodec/x86/motion_est.c
deleted file mode 100644
index 670659312..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/motion_est.c
+++ /dev/null
@@ -1,474 +0,0 @@
-/*
- * MMX optimized motion estimation
- * Copyright (c) 2001 Fabrice Bellard
- * Copyright (c) 2002-2004 Michael Niedermayer
- *
- * mostly 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
- */
-
-#include "libavutil/attributes.h"
-#include "libavutil/avassert.h"
-#include "libavutil/mem.h"
-#include "libavutil/x86/asm.h"
-#include "libavcodec/dsputil.h"
-#include "dsputil_mmx.h"
-
-#if HAVE_INLINE_ASM
-
-DECLARE_ASM_CONST(8, uint64_t, round_tab)[3]={
-0x0000000000000000ULL,
-0x0001000100010001ULL,
-0x0002000200020002ULL,
-};
-
-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(
- ".p2align 4 \n\t"
- "1: \n\t"
- "movq (%1, %%"REG_a"), %%mm0 \n\t"
- "movq (%2, %%"REG_a"), %%mm2 \n\t"
- "movq (%2, %%"REG_a"), %%mm4 \n\t"
- "add %3, %%"REG_a" \n\t"
- "psubusb %%mm0, %%mm2 \n\t"
- "psubusb %%mm4, %%mm0 \n\t"
- "movq (%1, %%"REG_a"), %%mm1 \n\t"
- "movq (%2, %%"REG_a"), %%mm3 \n\t"
- "movq (%2, %%"REG_a"), %%mm5 \n\t"
- "psubusb %%mm1, %%mm3 \n\t"
- "psubusb %%mm5, %%mm1 \n\t"
- "por %%mm2, %%mm0 \n\t"
- "por %%mm1, %%mm3 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "movq %%mm3, %%mm2 \n\t"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "punpckhbw %%mm7, %%mm1 \n\t"
- "punpcklbw %%mm7, %%mm3 \n\t"
- "punpckhbw %%mm7, %%mm2 \n\t"
- "paddw %%mm1, %%mm0 \n\t"
- "paddw %%mm3, %%mm2 \n\t"
- "paddw %%mm2, %%mm0 \n\t"
- "paddw %%mm0, %%mm6 \n\t"
- "add %3, %%"REG_a" \n\t"
- " js 1b \n\t"
- : "+a" (len)
- : "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(
- ".p2align 4 \n\t"
- "1: \n\t"
- "movq (%1), %%mm0 \n\t"
- "movq (%1, %3), %%mm1 \n\t"
- "psadbw (%2), %%mm0 \n\t"
- "psadbw (%2, %3), %%mm1 \n\t"
- "paddw %%mm0, %%mm6 \n\t"
- "paddw %%mm1, %%mm6 \n\t"
- "lea (%1,%3,2), %1 \n\t"
- "lea (%2,%3,2), %2 \n\t"
- "sub $2, %0 \n\t"
- " jg 1b \n\t"
- : "+r" (h), "+r" (blk1), "+r" (blk2)
- : "r" ((x86_reg)stride)
- );
-}
-
-static int sad16_sse2(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)
-{
- int ret;
- __asm__ volatile(
- "pxor %%xmm2, %%xmm2 \n\t"
- ".p2align 4 \n\t"
- "1: \n\t"
- "movdqu (%1), %%xmm0 \n\t"
- "movdqu (%1, %4), %%xmm1 \n\t"
- "psadbw (%2), %%xmm0 \n\t"
- "psadbw (%2, %4), %%xmm1 \n\t"
- "paddw %%xmm0, %%xmm2 \n\t"
- "paddw %%xmm1, %%xmm2 \n\t"
- "lea (%1,%4,2), %1 \n\t"
- "lea (%2,%4,2), %2 \n\t"
- "sub $2, %0 \n\t"
- " jg 1b \n\t"
- "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)
- );
- return ret;
-}
-
-static inline void sad8_x2a_mmxext(uint8_t *blk1, uint8_t *blk2,
- int stride, int h)
-{
- __asm__ volatile(
- ".p2align 4 \n\t"
- "1: \n\t"
- "movq (%1), %%mm0 \n\t"
- "movq (%1, %3), %%mm1 \n\t"
- "pavgb 1(%1), %%mm0 \n\t"
- "pavgb 1(%1, %3), %%mm1 \n\t"
- "psadbw (%2), %%mm0 \n\t"
- "psadbw (%2, %3), %%mm1 \n\t"
- "paddw %%mm0, %%mm6 \n\t"
- "paddw %%mm1, %%mm6 \n\t"
- "lea (%1,%3,2), %1 \n\t"
- "lea (%2,%3,2), %2 \n\t"
- "sub $2, %0 \n\t"
- " jg 1b \n\t"
- : "+r" (h), "+r" (blk1), "+r" (blk2)
- : "r" ((x86_reg)stride)
- );
-}
-
-static inline void sad8_y2a_mmxext(uint8_t *blk1, uint8_t *blk2,
- int stride, int h)
-{
- __asm__ volatile(
- "movq (%1), %%mm0 \n\t"
- "add %3, %1 \n\t"
- ".p2align 4 \n\t"
- "1: \n\t"
- "movq (%1), %%mm1 \n\t"
- "movq (%1, %3), %%mm2 \n\t"
- "pavgb %%mm1, %%mm0 \n\t"
- "pavgb %%mm2, %%mm1 \n\t"
- "psadbw (%2), %%mm0 \n\t"
- "psadbw (%2, %3), %%mm1 \n\t"
- "paddw %%mm0, %%mm6 \n\t"
- "paddw %%mm1, %%mm6 \n\t"
- "movq %%mm2, %%mm0 \n\t"
- "lea (%1,%3,2), %1 \n\t"
- "lea (%2,%3,2), %2 \n\t"
- "sub $2, %0 \n\t"
- " jg 1b \n\t"
- : "+r" (h), "+r" (blk1), "+r" (blk2)
- : "r" ((x86_reg)stride)
- );
-}
-
-static inline void sad8_4_mmxext(uint8_t *blk1, uint8_t *blk2,
- int stride, int h)
-{
- __asm__ volatile(
- "movq "MANGLE(bone)", %%mm5 \n\t"
- "movq (%1), %%mm0 \n\t"
- "pavgb 1(%1), %%mm0 \n\t"
- "add %3, %1 \n\t"
- ".p2align 4 \n\t"
- "1: \n\t"
- "movq (%1), %%mm1 \n\t"
- "movq (%1,%3), %%mm2 \n\t"
- "pavgb 1(%1), %%mm1 \n\t"
- "pavgb 1(%1,%3), %%mm2 \n\t"
- "psubusb %%mm5, %%mm1 \n\t"
- "pavgb %%mm1, %%mm0 \n\t"
- "pavgb %%mm2, %%mm1 \n\t"
- "psadbw (%2), %%mm0 \n\t"
- "psadbw (%2,%3), %%mm1 \n\t"
- "paddw %%mm0, %%mm6 \n\t"
- "paddw %%mm1, %%mm6 \n\t"
- "movq %%mm2, %%mm0 \n\t"
- "lea (%1,%3,2), %1 \n\t"
- "lea (%2,%3,2), %2 \n\t"
- "sub $2, %0 \n\t"
- " jg 1b \n\t"
- : "+r" (h), "+r" (blk1), "+r" (blk2)
- : "r" ((x86_reg)stride)
- );
-}
-
-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(
- ".p2align 4 \n\t"
- "1: \n\t"
- "movq (%1, %%"REG_a"), %%mm0 \n\t"
- "movq (%2, %%"REG_a"), %%mm1 \n\t"
- "movq (%1, %%"REG_a"), %%mm2 \n\t"
- "movq (%2, %%"REG_a"), %%mm3 \n\t"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "punpcklbw %%mm7, %%mm1 \n\t"
- "punpckhbw %%mm7, %%mm2 \n\t"
- "punpckhbw %%mm7, %%mm3 \n\t"
- "paddw %%mm0, %%mm1 \n\t"
- "paddw %%mm2, %%mm3 \n\t"
- "movq (%3, %%"REG_a"), %%mm4 \n\t"
- "movq (%3, %%"REG_a"), %%mm2 \n\t"
- "paddw %%mm5, %%mm1 \n\t"
- "paddw %%mm5, %%mm3 \n\t"
- "psrlw $1, %%mm1 \n\t"
- "psrlw $1, %%mm3 \n\t"
- "packuswb %%mm3, %%mm1 \n\t"
- "psubusb %%mm1, %%mm4 \n\t"
- "psubusb %%mm2, %%mm1 \n\t"
- "por %%mm4, %%mm1 \n\t"
- "movq %%mm1, %%mm0 \n\t"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "punpckhbw %%mm7, %%mm1 \n\t"
- "paddw %%mm1, %%mm0 \n\t"
- "paddw %%mm0, %%mm6 \n\t"
- "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)
- );
-}
-
-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"
- "movq 1(%1, %%"REG_a"), %%mm2 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "movq %%mm2, %%mm3 \n\t"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "punpckhbw %%mm7, %%mm1 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
- "punpckhbw %%mm7, %%mm3 \n\t"
- "paddw %%mm2, %%mm0 \n\t"
- "paddw %%mm3, %%mm1 \n\t"
- ".p2align 4 \n\t"
- "1: \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"
- "punpcklbw %%mm7, %%mm2 \n\t"
- "punpckhbw %%mm7, %%mm3 \n\t"
- "punpcklbw %%mm7, %%mm4 \n\t"
- "punpckhbw %%mm7, %%mm5 \n\t"
- "paddw %%mm4, %%mm2 \n\t"
- "paddw %%mm5, %%mm3 \n\t"
- "movq 16+"MANGLE(round_tab)", %%mm5 \n\t"
- "paddw %%mm2, %%mm0 \n\t"
- "paddw %%mm3, %%mm1 \n\t"
- "paddw %%mm5, %%mm0 \n\t"
- "paddw %%mm5, %%mm1 \n\t"
- "movq (%3, %%"REG_a"), %%mm4 \n\t"
- "movq (%3, %%"REG_a"), %%mm5 \n\t"
- "psrlw $2, %%mm0 \n\t"
- "psrlw $2, %%mm1 \n\t"
- "packuswb %%mm1, %%mm0 \n\t"
- "psubusb %%mm0, %%mm4 \n\t"
- "psubusb %%mm5, %%mm0 \n\t"
- "por %%mm4, %%mm0 \n\t"
- "movq %%mm0, %%mm4 \n\t"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "punpckhbw %%mm7, %%mm4 \n\t"
- "paddw %%mm0, %%mm6 \n\t"
- "paddw %%mm4, %%mm6 \n\t"
- "movq %%mm2, %%mm0 \n\t"
- "movq %%mm3, %%mm1 \n\t"
- "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)
- );
-}
-
-static inline int sum_mmx(void)
-{
- int ret;
- __asm__ volatile(
- "movq %%mm6, %%mm0 \n\t"
- "psrlq $32, %%mm6 \n\t"
- "paddw %%mm0, %%mm6 \n\t"
- "movq %%mm6, %%mm0 \n\t"
- "psrlq $16, %%mm6 \n\t"
- "paddw %%mm0, %%mm6 \n\t"
- "movd %%mm6, %0 \n\t"
- : "=r" (ret)
- );
- return ret&0xFFFF;
-}
-
-static inline int sum_mmxext(void)
-{
- int ret;
- __asm__ volatile(
- "movd %%mm6, %0 \n\t"
- : "=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);
-}
-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);
-}
-
-
-#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();\
-}\
-
-PIX_SAD(mmx)
-PIX_SAD(mmxext)
-
-#endif /* HAVE_INLINE_ASM */
-
-av_cold void ff_dsputil_init_pix_mmx(DSPContext *c, AVCodecContext *avctx)
-{
-#if HAVE_INLINE_ASM
- int mm_flags = av_get_cpu_flags();
-
- if (mm_flags & AV_CPU_FLAG_MMX) {
- c->pix_abs[0][0] = sad16_mmx;
- c->pix_abs[0][1] = sad16_x2_mmx;
- c->pix_abs[0][2] = sad16_y2_mmx;
- c->pix_abs[0][3] = sad16_xy2_mmx;
- c->pix_abs[1][0] = sad8_mmx;
- c->pix_abs[1][1] = sad8_x2_mmx;
- 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;
- }
- if (mm_flags & AV_CPU_FLAG_MMXEXT) {
- c->pix_abs[0][0] = sad16_mmxext;
- c->pix_abs[1][0] = sad8_mmxext;
-
- c->sad[0] = sad16_mmxext;
- c->sad[1] = sad8_mmxext;
-
- 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;
- c->pix_abs[1][1] = sad8_x2_mmxext;
- c->pix_abs[1][2] = sad8_y2_mmxext;
- c->pix_abs[1][3] = sad8_xy2_mmxext;
- }
- }
- if ((mm_flags & AV_CPU_FLAG_SSE2) && !(mm_flags & AV_CPU_FLAG_3DNOW) && avctx->codec_id != AV_CODEC_ID_SNOW) {
- c->sad[0]= sad16_sse2;
- }
-#endif /* HAVE_INLINE_ASM */
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/mpeg4qpel.asm b/src/thirdparty/ffmpeg/libavcodec/x86/mpeg4qpel.asm
deleted file mode 100644
index ca52375a7..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/mpeg4qpel.asm
+++ /dev/null
@@ -1,560 +0,0 @@
-;******************************************************************************
-;* mpeg4 qpel
-;* Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
-;* Copyright (c) 2008 Loren Merritt
-;* Copyright (c) 2013 Daniel Kang
-;*
-;* 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
-cextern pb_1
-cextern pw_3
-cextern pw_15
-cextern pw_16
-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)
-%macro PUT_NO_RND_PIXELS8_L2 0
-cglobal put_no_rnd_pixels8_l2, 6,6
- movsxdifnidn r4, r4d
- movsxdifnidn r3, r3d
- pcmpeqb m6, m6
- test r5d, 1
- je .loop
- mova m0, [r1]
- mova m1, [r2]
- add r1, r4
- add r2, 8
- pxor m0, m6
- pxor m1, m6
- PAVGB m0, m1
- pxor m0, m6
- mova [r0], m0
- add r0, r3
- dec r5d
-.loop:
- mova m0, [r1]
- add r1, r4
- mova m1, [r1]
- add r1, r4
- mova m2, [r2]
- mova m3, [r2+8]
- pxor m0, m6
- pxor m1, m6
- pxor m2, m6
- pxor m3, m6
- PAVGB m0, m2
- PAVGB m1, m3
- pxor m0, m6
- pxor m1, m6
- mova [r0], m0
- add r0, r3
- mova [r0], m1
- add r0, r3
- mova m0, [r1]
- add r1, r4
- mova m1, [r1]
- add r1, r4
- mova m2, [r2+16]
- mova m3, [r2+24]
- pxor m0, m6
- pxor m1, m6
- pxor m2, m6
- pxor m3, m6
- PAVGB m0, m2
- PAVGB m1, m3
- pxor m0, m6
- pxor m1, m6
- mova [r0], m0
- add r0, r3
- mova [r0], m1
- add r0, r3
- add r2, 32
- sub r5d, 4
- jne .loop
- REP_RET
-%endmacro
-
-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)
-%macro PUT_NO_RND_PIXELS16_l2 0
-cglobal put_no_rnd_pixels16_l2, 6,6
- movsxdifnidn r3, r3d
- movsxdifnidn r4, r4d
- pcmpeqb m6, m6
- test r5d, 1
- je .loop
- mova m0, [r1]
- mova m1, [r1+8]
- mova m2, [r2]
- mova m3, [r2+8]
- pxor m0, m6
- pxor m1, m6
- pxor m2, m6
- pxor m3, m6
- PAVGB m0, m2
- PAVGB m1, m3
- pxor m0, m6
- pxor m1, m6
- add r1, r4
- add r2, 16
- mova [r0], m0
- mova [r0+8], m1
- add r0, r3
- dec r5d
-.loop:
- mova m0, [r1]
- mova m1, [r1+8]
- add r1, r4
- mova m2, [r2]
- mova m3, [r2+8]
- pxor m0, m6
- pxor m1, m6
- pxor m2, m6
- pxor m3, m6
- PAVGB m0, m2
- PAVGB m1, m3
- pxor m0, m6
- pxor m1, m6
- mova [r0], m0
- mova [r0+8], m1
- add r0, r3
- mova m0, [r1]
- mova m1, [r1+8]
- add r1, r4
- mova m2, [r2+16]
- mova m3, [r2+24]
- pxor m0, m6
- pxor m1, m6
- pxor m2, m6
- pxor m3, m6
- PAVGB m0, m2
- PAVGB m1, m3
- pxor m0, m6
- pxor m1, m6
- mova [r0], m0
- mova [r0+8], m1
- add r0, r3
- add r2, 32
- sub r5d, 2
- jne .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-PUT_NO_RND_PIXELS16_l2
-INIT_MMX 3dnow
-PUT_NO_RND_PIXELS16_l2
-
-%macro MPEG4_QPEL16_H_LOWPASS 1
-cglobal %1_mpeg4_qpel16_h_lowpass, 5, 5, 0, 16
- movsxdifnidn r2, r2d
- movsxdifnidn r3, r3d
- pxor m7, m7
-.loop:
- mova m0, [r1]
- mova m1, m0
- mova m2, m0
- punpcklbw m0, m7
- punpckhbw m1, m7
- pshufw m5, m0, 0x90
- pshufw m6, m0, 0x41
- mova m3, m2
- mova m4, m2
- psllq m2, 8
- psllq m3, 16
- psllq m4, 24
- punpckhbw m2, m7
- punpckhbw m3, m7
- punpckhbw m4, m7
- paddw m5, m3
- paddw m6, m2
- paddw m5, m5
- psubw m6, m5
- pshufw m5, m0, 6
- pmullw m6, [pw_3]
- paddw m0, m4
- paddw m5, m1
- pmullw m0, [pw_20]
- psubw m0, m5
- paddw m6, [PW_ROUND]
- paddw m0, m6
- psraw m0, 5
- mova [rsp+8], m0
- mova m0, [r1+5]
- mova m5, m0
- mova m6, m0
- psrlq m0, 8
- psrlq m5, 16
- punpcklbw m0, m7
- punpcklbw m5, m7
- paddw m2, m0
- paddw m3, m5
- paddw m2, m2
- psubw m3, m2
- mova m2, m6
- psrlq m6, 24
- punpcklbw m2, m7
- punpcklbw m6, m7
- pmullw m3, [pw_3]
- paddw m1, m2
- paddw m4, m6
- pmullw m1, [pw_20]
- psubw m3, m4
- paddw m1, [PW_ROUND]
- paddw m3, m1
- psraw m3, 5
- mova m1, [rsp+8]
- packuswb m1, m3
- OP_MOV [r0], m1, m4
- mova m1, [r1+9]
- mova m4, m1
- mova m3, m1
- psrlq m1, 8
- psrlq m4, 16
- punpcklbw m1, m7
- punpcklbw m4, m7
- paddw m5, m1
- paddw m0, m4
- paddw m5, m5
- psubw m0, m5
- mova m5, m3
- psrlq m3, 24
- pmullw m0, [pw_3]
- punpcklbw m3, m7
- paddw m2, m3
- psubw m0, m2
- mova m2, m5
- punpcklbw m2, m7
- punpckhbw m5, m7
- paddw m6, m2
- pmullw m6, [pw_20]
- paddw m0, [PW_ROUND]
- paddw m0, m6
- psraw m0, 5
- paddw m3, m5
- pshufw m6, m5, 0xf9
- paddw m6, m4
- pshufw m4, m5, 0xbe
- pshufw m5, m5, 0x6f
- paddw m4, m1
- paddw m5, m2
- paddw m6, m6
- psubw m4, m6
- pmullw m3, [pw_20]
- pmullw m4, [pw_3]
- psubw m3, m5
- paddw m4, [PW_ROUND]
- paddw m4, m3
- psraw m4, 5
- packuswb m0, m4
- OP_MOV [r0+8], m0, m4
- add r1, r3
- add r0, r2
- dec r4d
- jne .loop
- REP_RET
-%endmacro
-
-%macro PUT_OP 2-3
- mova %1, %2
-%endmacro
-
-%macro AVG_OP 2-3
- mova %3, %1
- pavgb %2, %3
- mova %1, %2
-%endmacro
-
-INIT_MMX mmxext
-%define PW_ROUND pw_16
-%define OP_MOV PUT_OP
-MPEG4_QPEL16_H_LOWPASS put
-%define PW_ROUND pw_16
-%define OP_MOV AVG_OP
-MPEG4_QPEL16_H_LOWPASS avg
-%define PW_ROUND pw_15
-%define OP_MOV PUT_OP
-MPEG4_QPEL16_H_LOWPASS put_no_rnd
-
-
-
-%macro MPEG4_QPEL8_H_LOWPASS 1
-cglobal %1_mpeg4_qpel8_h_lowpass, 5, 5, 0, 8
- movsxdifnidn r2, r2d
- movsxdifnidn r3, r3d
- pxor m7, m7
-.loop:
- mova m0, [r1]
- mova m1, m0
- mova m2, m0
- punpcklbw m0, m7
- punpckhbw m1, m7
- pshufw m5, m0, 0x90
- pshufw m6, m0, 0x41
- mova m3, m2
- mova m4, m2
- psllq m2, 8
- psllq m3, 16
- psllq m4, 24
- punpckhbw m2, m7
- punpckhbw m3, m7
- punpckhbw m4, m7
- paddw m5, m3
- paddw m6, m2
- paddw m5, m5
- psubw m6, m5
- pshufw m5, m0, 0x6
- pmullw m6, [pw_3]
- paddw m0, m4
- paddw m5, m1
- pmullw m0, [pw_20]
- psubw m0, m5
- paddw m6, [PW_ROUND]
- paddw m0, m6
- psraw m0, 5
- movh m5, [r1+5]
- punpcklbw m5, m7
- pshufw m6, m5, 0xf9
- paddw m1, m5
- paddw m2, m6
- pshufw m6, m5, 0xbe
- pshufw m5, m5, 0x6f
- paddw m3, m6
- paddw m4, m5
- paddw m2, m2
- psubw m3, m2
- pmullw m1, [pw_20]
- pmullw m3, [pw_3]
- psubw m3, m4
- paddw m1, [PW_ROUND]
- paddw m3, m1
- psraw m3, 5
- packuswb m0, m3
- OP_MOV [r0], m0, m4
- add r1, r3
- add r0, r2
- dec r4d
- jne .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-%define PW_ROUND pw_16
-%define OP_MOV PUT_OP
-MPEG4_QPEL8_H_LOWPASS put
-%define PW_ROUND pw_16
-%define OP_MOV AVG_OP
-MPEG4_QPEL8_H_LOWPASS avg
-%define PW_ROUND pw_15
-%define OP_MOV PUT_OP
-MPEG4_QPEL8_H_LOWPASS put_no_rnd
-
-
-
-%macro QPEL_V_LOW 5
- paddw m0, m1
- mova m4, [pw_20]
- pmullw m4, m0
- mova m0, %4
- mova m5, %1
- paddw m5, m0
- psubw m4, m5
- mova m5, %2
- mova m6, %3
- paddw m5, m3
- paddw m6, m2
- paddw m6, m6
- psubw m5, m6
- pmullw m5, [pw_3]
- paddw m4, [PW_ROUND]
- paddw m5, m4
- psraw m5, 5
- packuswb m5, m5
- OP_MOV %5, m5, m7
- SWAP 0,1,2,3
-%endmacro
-
-%macro MPEG4_QPEL16_V_LOWPASS 1
-cglobal %1_mpeg4_qpel16_v_lowpass, 4, 6, 0, 544
- movsxdifnidn r2, r2d
- movsxdifnidn r3, r3d
-
- mov r4d, 17
- mov r5, rsp
- pxor m7, m7
-.looph:
- mova m0, [r1]
- mova m1, [r1]
- mova m2, [r1+8]
- mova m3, [r1+8]
- punpcklbw m0, m7
- punpckhbw m1, m7
- punpcklbw m2, m7
- punpckhbw m3, m7
- mova [r5], m0
- mova [r5+0x88], m1
- mova [r5+0x110], m2
- mova [r5+0x198], m3
- add r5, 8
- add r1, r3
- dec r4d
- jne .looph
-
-
- ; NOTE: r1 CHANGES VALUES: r1 -> 4 - 14*dstStride
- mov r4d, 4
- mov r1, 4
- neg r2
- lea r1, [r1+r2*8]
- lea r1, [r1+r2*4]
- lea r1, [r1+r2*2]
- neg r2
- mov r5, rsp
-.loopv:
- pxor m7, m7
- mova m0, [r5+ 0x0]
- mova m1, [r5+ 0x8]
- mova m2, [r5+0x10]
- mova m3, [r5+0x18]
- QPEL_V_LOW [r5+0x10], [r5+ 0x8], [r5+ 0x0], [r5+0x20], [r0]
- QPEL_V_LOW [r5+ 0x8], [r5+ 0x0], [r5+ 0x0], [r5+0x28], [r0+r2]
- lea r0, [r0+r2*2]
- QPEL_V_LOW [r5+ 0x0], [r5+ 0x0], [r5+ 0x8], [r5+0x30], [r0]
- QPEL_V_LOW [r5+ 0x0], [r5+ 0x8], [r5+0x10], [r5+0x38], [r0+r2]
- lea r0, [r0+r2*2]
- QPEL_V_LOW [r5+ 0x8], [r5+0x10], [r5+0x18], [r5+0x40], [r0]
- QPEL_V_LOW [r5+0x10], [r5+0x18], [r5+0x20], [r5+0x48], [r0+r2]
- lea r0, [r0+r2*2]
- QPEL_V_LOW [r5+0x18], [r5+0x20], [r5+0x28], [r5+0x50], [r0]
- QPEL_V_LOW [r5+0x20], [r5+0x28], [r5+0x30], [r5+0x58], [r0+r2]
- lea r0, [r0+r2*2]
- QPEL_V_LOW [r5+0x28], [r5+0x30], [r5+0x38], [r5+0x60], [r0]
- QPEL_V_LOW [r5+0x30], [r5+0x38], [r5+0x40], [r5+0x68], [r0+r2]
- lea r0, [r0+r2*2]
- QPEL_V_LOW [r5+0x38], [r5+0x40], [r5+0x48], [r5+0x70], [r0]
- QPEL_V_LOW [r5+0x40], [r5+0x48], [r5+0x50], [r5+0x78], [r0+r2]
- lea r0, [r0+r2*2]
- QPEL_V_LOW [r5+0x48], [r5+0x50], [r5+0x58], [r5+0x80], [r0]
- QPEL_V_LOW [r5+0x50], [r5+0x58], [r5+0x60], [r5+0x80], [r0+r2]
- lea r0, [r0+r2*2]
- QPEL_V_LOW [r5+0x58], [r5+0x60], [r5+0x68], [r5+0x78], [r0]
- QPEL_V_LOW [r5+0x60], [r5+0x68], [r5+0x70], [r5+0x70], [r0+r2]
-
- add r5, 0x88
- add r0, r1
- dec r4d
- jne .loopv
- REP_RET
-%endmacro
-
-%macro PUT_OPH 2-3
- movh %1, %2
-%endmacro
-
-%macro AVG_OPH 2-3
- movh %3, %1
- pavgb %2, %3
- movh %1, %2
-%endmacro
-
-INIT_MMX mmxext
-%define PW_ROUND pw_16
-%define OP_MOV PUT_OPH
-MPEG4_QPEL16_V_LOWPASS put
-%define PW_ROUND pw_16
-%define OP_MOV AVG_OPH
-MPEG4_QPEL16_V_LOWPASS avg
-%define PW_ROUND pw_15
-%define OP_MOV PUT_OPH
-MPEG4_QPEL16_V_LOWPASS put_no_rnd
-
-
-
-%macro MPEG4_QPEL8_V_LOWPASS 1
-cglobal %1_mpeg4_qpel8_v_lowpass, 4, 6, 0, 288
- movsxdifnidn r2, r2d
- movsxdifnidn r3, r3d
-
- mov r4d, 9
- mov r5, rsp
- pxor m7, m7
-.looph:
- mova m0, [r1]
- mova m1, [r1]
- punpcklbw m0, m7
- punpckhbw m1, m7
- mova [r5], m0
- mova [r5+0x48], m1
- add r5, 8
- add r1, r3
- dec r4d
- jne .looph
-
-
- ; NOTE: r1 CHANGES VALUES: r1 -> 4 - 6*dstStride
- mov r4d, 2
- mov r1, 4
- neg r2
- lea r1, [r1+r2*4]
- lea r1, [r1+r2*2]
- neg r2
- mov r5, rsp
-.loopv:
- pxor m7, m7
- mova m0, [r5+ 0x0]
- mova m1, [r5+ 0x8]
- mova m2, [r5+0x10]
- mova m3, [r5+0x18]
- QPEL_V_LOW [r5+0x10], [r5+ 0x8], [r5+ 0x0], [r5+0x20], [r0]
- QPEL_V_LOW [r5+ 0x8], [r5+ 0x0], [r5+ 0x0], [r5+0x28], [r0+r2]
- lea r0, [r0+r2*2]
- QPEL_V_LOW [r5+ 0x0], [r5+ 0x0], [r5+ 0x8], [r5+0x30], [r0]
- QPEL_V_LOW [r5+ 0x0], [r5+ 0x8], [r5+0x10], [r5+0x38], [r0+r2]
- lea r0, [r0+r2*2]
- QPEL_V_LOW [r5+ 0x8], [r5+0x10], [r5+0x18], [r5+0x40], [r0]
- QPEL_V_LOW [r5+0x10], [r5+0x18], [r5+0x20], [r5+0x40], [r0+r2]
- lea r0, [r0+r2*2]
- QPEL_V_LOW [r5+0x18], [r5+0x20], [r5+0x28], [r5+0x38], [r0]
- QPEL_V_LOW [r5+0x20], [r5+0x28], [r5+0x30], [r5+0x30], [r0+r2]
-
- add r5, 0x48
- add r0, r1
- dec r4d
- jne .loopv
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-%define PW_ROUND pw_16
-%define OP_MOV PUT_OPH
-MPEG4_QPEL8_V_LOWPASS put
-%define PW_ROUND pw_16
-%define OP_MOV AVG_OPH
-MPEG4_QPEL8_V_LOWPASS avg
-%define PW_ROUND pw_15
-%define OP_MOV PUT_OPH
-MPEG4_QPEL8_V_LOWPASS put_no_rnd
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/mpegaudiodec.c b/src/thirdparty/ffmpeg/libavcodec/x86/mpegaudiodec.c
deleted file mode 100644
index 287d8ff12..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/mpegaudiodec.c
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * MMX optimized MP3 decoding functions
- * Copyright (c) 2010 Vitor Sessak
- *
- * 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/internal.h"
-#include "libavutil/x86/asm.h"
-#include "libavutil/x86/cpu.h"
-#include "libavcodec/mpegaudiodsp.h"
-
-#define DECL(CPU)\
-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);
-
-DECL(sse)
-DECL(sse2)
-DECL(sse3)
-DECL(ssse3)
-DECL(avx)
-
-void ff_four_imdct36_float_sse(float *out, float *buf, float *in, float *win,
- float *tmpbuf);
-void ff_four_imdct36_float_avx(float *out, float *buf, float *in, float *win,
- float *tmpbuf);
-
-DECLARE_ALIGNED(16, static float, mdct_win_sse)[2][4][4*40];
-
-#if HAVE_SSE2_INLINE
-
-#define MACS(rt, ra, rb) rt+=(ra)*(rb)
-#define MLSS(rt, ra, rb) rt-=(ra)*(rb)
-
-#define SUM8(op, sum, w, p) \
-{ \
- op(sum, (w)[0 * 64], (p)[0 * 64]); \
- op(sum, (w)[1 * 64], (p)[1 * 64]); \
- op(sum, (w)[2 * 64], (p)[2 * 64]); \
- op(sum, (w)[3 * 64], (p)[3 * 64]); \
- op(sum, (w)[4 * 64], (p)[4 * 64]); \
- op(sum, (w)[5 * 64], (p)[5 * 64]); \
- op(sum, (w)[6 * 64], (p)[6 * 64]); \
- op(sum, (w)[7 * 64], (p)[7 * 64]); \
-}
-
-static void apply_window(const float *buf, const float *win1,
- const float *win2, float *sum1, float *sum2, int len)
-{
- x86_reg count = - 4*len;
- const float *win1a = win1+len;
- const float *win2a = win2+len;
- const float *bufa = buf+len;
- float *sum1a = sum1+len;
- float *sum2a = sum2+len;
-
-
-#define MULT(a, b) \
- "movaps " #a "(%1,%0), %%xmm1 \n\t" \
- "movaps " #a "(%3,%0), %%xmm2 \n\t" \
- "mulps %%xmm2, %%xmm1 \n\t" \
- "subps %%xmm1, %%xmm0 \n\t" \
- "mulps " #b "(%2,%0), %%xmm2 \n\t" \
- "subps %%xmm2, %%xmm4 \n\t" \
-
- __asm__ volatile(
- "1: \n\t"
- "xorps %%xmm0, %%xmm0 \n\t"
- "xorps %%xmm4, %%xmm4 \n\t"
-
- MULT( 0, 0)
- MULT( 256, 64)
- MULT( 512, 128)
- MULT( 768, 192)
- MULT(1024, 256)
- MULT(1280, 320)
- MULT(1536, 384)
- MULT(1792, 448)
-
- "movaps %%xmm0, (%4,%0) \n\t"
- "movaps %%xmm4, (%5,%0) \n\t"
- "add $16, %0 \n\t"
- "jl 1b \n\t"
- :"+&r"(count)
- :"r"(win1a), "r"(win2a), "r"(bufa), "r"(sum1a), "r"(sum2a)
- );
-
-#undef MULT
-}
-
-static void apply_window_mp3(float *in, float *win, int *unused, float *out,
- int incr)
-{
- LOCAL_ALIGNED_16(float, suma, [17]);
- LOCAL_ALIGNED_16(float, sumb, [17]);
- LOCAL_ALIGNED_16(float, sumc, [17]);
- LOCAL_ALIGNED_16(float, sumd, [17]);
-
- float sum;
-
- /* copy to avoid wrap */
- __asm__ volatile(
- "movaps 0(%0), %%xmm0 \n\t" \
- "movaps 16(%0), %%xmm1 \n\t" \
- "movaps 32(%0), %%xmm2 \n\t" \
- "movaps 48(%0), %%xmm3 \n\t" \
- "movaps %%xmm0, 0(%1) \n\t" \
- "movaps %%xmm1, 16(%1) \n\t" \
- "movaps %%xmm2, 32(%1) \n\t" \
- "movaps %%xmm3, 48(%1) \n\t" \
- "movaps 64(%0), %%xmm0 \n\t" \
- "movaps 80(%0), %%xmm1 \n\t" \
- "movaps 96(%0), %%xmm2 \n\t" \
- "movaps 112(%0), %%xmm3 \n\t" \
- "movaps %%xmm0, 64(%1) \n\t" \
- "movaps %%xmm1, 80(%1) \n\t" \
- "movaps %%xmm2, 96(%1) \n\t" \
- "movaps %%xmm3, 112(%1) \n\t"
- ::"r"(in), "r"(in+512)
- :"memory"
- );
-
- apply_window(in + 16, win , win + 512, suma, sumc, 16);
- apply_window(in + 32, win + 48, win + 640, sumb, sumd, 16);
-
- SUM8(MACS, suma[0], win + 32, in + 48);
-
- sumc[ 0] = 0;
- sumb[16] = 0;
- sumd[16] = 0;
-
-#define SUMS(suma, sumb, sumc, sumd, out1, out2) \
- "movups " #sumd "(%4), %%xmm0 \n\t" \
- "shufps $0x1b, %%xmm0, %%xmm0 \n\t" \
- "subps " #suma "(%1), %%xmm0 \n\t" \
- "movaps %%xmm0," #out1 "(%0) \n\t" \
-\
- "movups " #sumc "(%3), %%xmm0 \n\t" \
- "shufps $0x1b, %%xmm0, %%xmm0 \n\t" \
- "addps " #sumb "(%2), %%xmm0 \n\t" \
- "movaps %%xmm0," #out2 "(%0) \n\t"
-
- if (incr == 1) {
- __asm__ volatile(
- SUMS( 0, 48, 4, 52, 0, 112)
- SUMS(16, 32, 20, 36, 16, 96)
- SUMS(32, 16, 36, 20, 32, 80)
- SUMS(48, 0, 52, 4, 48, 64)
-
- :"+&r"(out)
- :"r"(&suma[0]), "r"(&sumb[0]), "r"(&sumc[0]), "r"(&sumd[0])
- :"memory"
- );
- out += 16*incr;
- } else {
- int j;
- float *out2 = out + 32 * incr;
- out[0 ] = -suma[ 0];
- out += incr;
- out2 -= incr;
- for(j=1;j<16;j++) {
- *out = -suma[ j] + sumd[16-j];
- *out2 = sumb[16-j] + sumc[ j];
- out += incr;
- out2 -= incr;
- }
- }
-
- sum = 0;
- SUM8(MLSS, sum, win + 16 + 32, in + 32);
- *out = sum;
-}
-
-#endif /* HAVE_SSE2_INLINE */
-
-#if HAVE_YASM
-#define DECL_IMDCT_BLOCKS(CPU1, CPU2) \
-static void imdct36_blocks_ ## CPU1(float *out, float *buf, float *in, \
- int count, int switch_point, int block_type) \
-{ \
- int align_end = count - (count & 3); \
- int j; \
- for (j = 0; j < align_end; j+= 4) { \
- LOCAL_ALIGNED_16(float, tmpbuf, [1024]); \
- float *win = mdct_win_sse[switch_point && j < 4][block_type]; \
- /* apply window & overlap with previous buffer */ \
- \
- /* select window */ \
- ff_four_imdct36_float_ ## CPU2(out, buf, in, win, tmpbuf); \
- in += 4*18; \
- buf += 4*18; \
- out += 4; \
- } \
- for (; j < count; j++) { \
- /* apply window & overlap with previous buffer */ \
- \
- /* select window */ \
- int win_idx = (switch_point && j < 2) ? 0 : block_type; \
- float *win = ff_mdct_win_float[win_idx + (4 & -(j & 1))]; \
- \
- ff_imdct36_float_ ## CPU1(out, buf, in, win); \
- \
- in += 18; \
- buf++; \
- out++; \
- } \
-}
-
-#if HAVE_SSE
-DECL_IMDCT_BLOCKS(sse,sse)
-DECL_IMDCT_BLOCKS(sse2,sse)
-DECL_IMDCT_BLOCKS(sse3,sse)
-DECL_IMDCT_BLOCKS(ssse3,sse)
-#endif
-#if HAVE_AVX_EXTERNAL
-DECL_IMDCT_BLOCKS(avx,avx)
-#endif
-#endif /* HAVE_YASM */
-
-av_cold void ff_mpadsp_init_x86(MPADSPContext *s)
-{
- int mm_flags = av_get_cpu_flags();
-
- int i, j;
- for (j = 0; j < 4; j++) {
- for (i = 0; i < 40; i ++) {
- mdct_win_sse[0][j][4*i ] = ff_mdct_win_float[j ][i];
- mdct_win_sse[0][j][4*i + 1] = ff_mdct_win_float[j + 4][i];
- mdct_win_sse[0][j][4*i + 2] = ff_mdct_win_float[j ][i];
- mdct_win_sse[0][j][4*i + 3] = ff_mdct_win_float[j + 4][i];
- mdct_win_sse[1][j][4*i ] = ff_mdct_win_float[0 ][i];
- mdct_win_sse[1][j][4*i + 1] = ff_mdct_win_float[4 ][i];
- mdct_win_sse[1][j][4*i + 2] = ff_mdct_win_float[j ][i];
- mdct_win_sse[1][j][4*i + 3] = ff_mdct_win_float[j + 4][i];
- }
- }
-
-#if HAVE_SSE2_INLINE
- if (mm_flags & AV_CPU_FLAG_SSE2) {
- s->apply_window_float = apply_window_mp3;
- }
-#endif /* HAVE_SSE2_INLINE */
-
-#if HAVE_YASM
- if (EXTERNAL_AVX(mm_flags)) {
- s->imdct36_blocks_float = imdct36_blocks_avx;
- } else if (EXTERNAL_SSSE3(mm_flags)) {
- s->imdct36_blocks_float = imdct36_blocks_ssse3;
- } else if (EXTERNAL_SSE3(mm_flags)) {
- s->imdct36_blocks_float = imdct36_blocks_sse3;
- } else if (EXTERNAL_SSE2(mm_flags)) {
- s->imdct36_blocks_float = imdct36_blocks_sse2;
- } else if (EXTERNAL_SSE(mm_flags)) {
- s->imdct36_blocks_float = imdct36_blocks_sse;
- }
-#endif /* HAVE_YASM */
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/mpegvideo.c b/src/thirdparty/ffmpeg/libavcodec/x86/mpegvideo.c
deleted file mode 100644
index 697d28ba1..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/mpegvideo.c
+++ /dev/null
@@ -1,601 +0,0 @@
-/*
- * Optimized for ia32 CPUs by Nick Kurshev <nickols_k@mail.ru>
- * h263, mpeg1, mpeg2 dequantizer & draw_edges 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
- */
-
-#include "libavutil/attributes.h"
-#include "libavutil/cpu.h"
-#include "libavutil/x86/asm.h"
-#include "libavcodec/avcodec.h"
-#include "libavcodec/dsputil.h"
-#include "libavcodec/mpegvideo.h"
-#include "dsputil_mmx.h"
-
-#if HAVE_INLINE_ASM
-
-static void dct_unquantize_h263_intra_mmx(MpegEncContext *s,
- int16_t *block, int n, int qscale)
-{
- x86_reg level, qmul, qadd, nCoeffs;
-
- qmul = qscale << 1;
-
- av_assert2(s->block_last_index[n]>=0 || s->h263_aic);
-
- if (!s->h263_aic) {
- if (n < 4)
- level = block[0] * s->y_dc_scale;
- else
- level = block[0] * s->c_dc_scale;
- qadd = (qscale - 1) | 1;
- }else{
- qadd = 0;
- level= block[0];
- }
- if(s->ac_pred)
- nCoeffs=63;
- else
- nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
-
-__asm__ volatile(
- "movd %1, %%mm6 \n\t" //qmul
- "packssdw %%mm6, %%mm6 \n\t"
- "packssdw %%mm6, %%mm6 \n\t"
- "movd %2, %%mm5 \n\t" //qadd
- "pxor %%mm7, %%mm7 \n\t"
- "packssdw %%mm5, %%mm5 \n\t"
- "packssdw %%mm5, %%mm5 \n\t"
- "psubw %%mm5, %%mm7 \n\t"
- "pxor %%mm4, %%mm4 \n\t"
- ".p2align 4 \n\t"
- "1: \n\t"
- "movq (%0, %3), %%mm0 \n\t"
- "movq 8(%0, %3), %%mm1 \n\t"
-
- "pmullw %%mm6, %%mm0 \n\t"
- "pmullw %%mm6, %%mm1 \n\t"
-
- "movq (%0, %3), %%mm2 \n\t"
- "movq 8(%0, %3), %%mm3 \n\t"
-
- "pcmpgtw %%mm4, %%mm2 \n\t" // block[i] < 0 ? -1 : 0
- "pcmpgtw %%mm4, %%mm3 \n\t" // block[i] < 0 ? -1 : 0
-
- "pxor %%mm2, %%mm0 \n\t"
- "pxor %%mm3, %%mm1 \n\t"
-
- "paddw %%mm7, %%mm0 \n\t"
- "paddw %%mm7, %%mm1 \n\t"
-
- "pxor %%mm0, %%mm2 \n\t"
- "pxor %%mm1, %%mm3 \n\t"
-
- "pcmpeqw %%mm7, %%mm0 \n\t" // block[i] == 0 ? -1 : 0
- "pcmpeqw %%mm7, %%mm1 \n\t" // block[i] == 0 ? -1 : 0
-
- "pandn %%mm2, %%mm0 \n\t"
- "pandn %%mm3, %%mm1 \n\t"
-
- "movq %%mm0, (%0, %3) \n\t"
- "movq %%mm1, 8(%0, %3) \n\t"
-
- "add $16, %3 \n\t"
- "jng 1b \n\t"
- ::"r" (block+nCoeffs), "rm"(qmul), "rm" (qadd), "r" (2*(-nCoeffs))
- : "memory"
- );
- block[0]= level;
-}
-
-
-static void dct_unquantize_h263_inter_mmx(MpegEncContext *s,
- int16_t *block, int n, int qscale)
-{
- x86_reg qmul, qadd, nCoeffs;
-
- qmul = qscale << 1;
- qadd = (qscale - 1) | 1;
-
- assert(s->block_last_index[n]>=0 || s->h263_aic);
-
- nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
-
-__asm__ volatile(
- "movd %1, %%mm6 \n\t" //qmul
- "packssdw %%mm6, %%mm6 \n\t"
- "packssdw %%mm6, %%mm6 \n\t"
- "movd %2, %%mm5 \n\t" //qadd
- "pxor %%mm7, %%mm7 \n\t"
- "packssdw %%mm5, %%mm5 \n\t"
- "packssdw %%mm5, %%mm5 \n\t"
- "psubw %%mm5, %%mm7 \n\t"
- "pxor %%mm4, %%mm4 \n\t"
- ".p2align 4 \n\t"
- "1: \n\t"
- "movq (%0, %3), %%mm0 \n\t"
- "movq 8(%0, %3), %%mm1 \n\t"
-
- "pmullw %%mm6, %%mm0 \n\t"
- "pmullw %%mm6, %%mm1 \n\t"
-
- "movq (%0, %3), %%mm2 \n\t"
- "movq 8(%0, %3), %%mm3 \n\t"
-
- "pcmpgtw %%mm4, %%mm2 \n\t" // block[i] < 0 ? -1 : 0
- "pcmpgtw %%mm4, %%mm3 \n\t" // block[i] < 0 ? -1 : 0
-
- "pxor %%mm2, %%mm0 \n\t"
- "pxor %%mm3, %%mm1 \n\t"
-
- "paddw %%mm7, %%mm0 \n\t"
- "paddw %%mm7, %%mm1 \n\t"
-
- "pxor %%mm0, %%mm2 \n\t"
- "pxor %%mm1, %%mm3 \n\t"
-
- "pcmpeqw %%mm7, %%mm0 \n\t" // block[i] == 0 ? -1 : 0
- "pcmpeqw %%mm7, %%mm1 \n\t" // block[i] == 0 ? -1 : 0
-
- "pandn %%mm2, %%mm0 \n\t"
- "pandn %%mm3, %%mm1 \n\t"
-
- "movq %%mm0, (%0, %3) \n\t"
- "movq %%mm1, 8(%0, %3) \n\t"
-
- "add $16, %3 \n\t"
- "jng 1b \n\t"
- ::"r" (block+nCoeffs), "rm"(qmul), "rm" (qadd), "r" (2*(-nCoeffs))
- : "memory"
- );
-}
-
-
-/*
- We can suppose that result of two multiplications can't be greater than 0xFFFF
- i.e. is 16-bit, so we use here only PMULLW instruction and can avoid
- a complex multiplication.
-=====================================================
- Full formula for multiplication of 2 integer numbers
- which are represent as high:low words:
- input: value1 = high1:low1
- value2 = high2:low2
- output: value3 = value1*value2
- value3=high3:low3 (on overflow: modulus 2^32 wrap-around)
- this mean that for 0x123456 * 0x123456 correct result is 0x766cb0ce4
- but this algorithm will compute only 0x66cb0ce4
- this limited by 16-bit size of operands
- ---------------------------------
- tlow1 = high1*low2
- tlow2 = high2*low1
- tlow1 = tlow1 + tlow2
- high3:low3 = low1*low2
- high3 += tlow1
-*/
-static void dct_unquantize_mpeg1_intra_mmx(MpegEncContext *s,
- int16_t *block, int n, int qscale)
-{
- x86_reg nCoeffs;
- const uint16_t *quant_matrix;
- int block0;
-
- av_assert2(s->block_last_index[n]>=0);
-
- nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ]+1;
-
- if (n < 4)
- block0 = block[0] * s->y_dc_scale;
- else
- block0 = block[0] * s->c_dc_scale;
- /* XXX: only mpeg1 */
- quant_matrix = s->intra_matrix;
-__asm__ volatile(
- "pcmpeqw %%mm7, %%mm7 \n\t"
- "psrlw $15, %%mm7 \n\t"
- "movd %2, %%mm6 \n\t"
- "packssdw %%mm6, %%mm6 \n\t"
- "packssdw %%mm6, %%mm6 \n\t"
- "mov %3, %%"REG_a" \n\t"
- ".p2align 4 \n\t"
- "1: \n\t"
- "movq (%0, %%"REG_a"), %%mm0 \n\t"
- "movq 8(%0, %%"REG_a"), %%mm1 \n\t"
- "movq (%1, %%"REG_a"), %%mm4 \n\t"
- "movq 8(%1, %%"REG_a"), %%mm5 \n\t"
- "pmullw %%mm6, %%mm4 \n\t" // q=qscale*quant_matrix[i]
- "pmullw %%mm6, %%mm5 \n\t" // q=qscale*quant_matrix[i]
- "pxor %%mm2, %%mm2 \n\t"
- "pxor %%mm3, %%mm3 \n\t"
- "pcmpgtw %%mm0, %%mm2 \n\t" // block[i] < 0 ? -1 : 0
- "pcmpgtw %%mm1, %%mm3 \n\t" // block[i] < 0 ? -1 : 0
- "pxor %%mm2, %%mm0 \n\t"
- "pxor %%mm3, %%mm1 \n\t"
- "psubw %%mm2, %%mm0 \n\t" // abs(block[i])
- "psubw %%mm3, %%mm1 \n\t" // abs(block[i])
- "pmullw %%mm4, %%mm0 \n\t" // abs(block[i])*q
- "pmullw %%mm5, %%mm1 \n\t" // abs(block[i])*q
- "pxor %%mm4, %%mm4 \n\t"
- "pxor %%mm5, %%mm5 \n\t" // FIXME slow
- "pcmpeqw (%0, %%"REG_a"), %%mm4 \n\t" // block[i] == 0 ? -1 : 0
- "pcmpeqw 8(%0, %%"REG_a"), %%mm5\n\t" // block[i] == 0 ? -1 : 0
- "psraw $3, %%mm0 \n\t"
- "psraw $3, %%mm1 \n\t"
- "psubw %%mm7, %%mm0 \n\t"
- "psubw %%mm7, %%mm1 \n\t"
- "por %%mm7, %%mm0 \n\t"
- "por %%mm7, %%mm1 \n\t"
- "pxor %%mm2, %%mm0 \n\t"
- "pxor %%mm3, %%mm1 \n\t"
- "psubw %%mm2, %%mm0 \n\t"
- "psubw %%mm3, %%mm1 \n\t"
- "pandn %%mm0, %%mm4 \n\t"
- "pandn %%mm1, %%mm5 \n\t"
- "movq %%mm4, (%0, %%"REG_a") \n\t"
- "movq %%mm5, 8(%0, %%"REG_a") \n\t"
-
- "add $16, %%"REG_a" \n\t"
- "js 1b \n\t"
- ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "rm" (qscale), "g" (-2*nCoeffs)
- : "%"REG_a, "memory"
- );
- block[0]= block0;
-}
-
-static void dct_unquantize_mpeg1_inter_mmx(MpegEncContext *s,
- int16_t *block, int n, int qscale)
-{
- x86_reg nCoeffs;
- const uint16_t *quant_matrix;
-
- av_assert2(s->block_last_index[n]>=0);
-
- nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ]+1;
-
- quant_matrix = s->inter_matrix;
-__asm__ volatile(
- "pcmpeqw %%mm7, %%mm7 \n\t"
- "psrlw $15, %%mm7 \n\t"
- "movd %2, %%mm6 \n\t"
- "packssdw %%mm6, %%mm6 \n\t"
- "packssdw %%mm6, %%mm6 \n\t"
- "mov %3, %%"REG_a" \n\t"
- ".p2align 4 \n\t"
- "1: \n\t"
- "movq (%0, %%"REG_a"), %%mm0 \n\t"
- "movq 8(%0, %%"REG_a"), %%mm1 \n\t"
- "movq (%1, %%"REG_a"), %%mm4 \n\t"
- "movq 8(%1, %%"REG_a"), %%mm5 \n\t"
- "pmullw %%mm6, %%mm4 \n\t" // q=qscale*quant_matrix[i]
- "pmullw %%mm6, %%mm5 \n\t" // q=qscale*quant_matrix[i]
- "pxor %%mm2, %%mm2 \n\t"
- "pxor %%mm3, %%mm3 \n\t"
- "pcmpgtw %%mm0, %%mm2 \n\t" // block[i] < 0 ? -1 : 0
- "pcmpgtw %%mm1, %%mm3 \n\t" // block[i] < 0 ? -1 : 0
- "pxor %%mm2, %%mm0 \n\t"
- "pxor %%mm3, %%mm1 \n\t"
- "psubw %%mm2, %%mm0 \n\t" // abs(block[i])
- "psubw %%mm3, %%mm1 \n\t" // abs(block[i])
- "paddw %%mm0, %%mm0 \n\t" // abs(block[i])*2
- "paddw %%mm1, %%mm1 \n\t" // abs(block[i])*2
- "paddw %%mm7, %%mm0 \n\t" // abs(block[i])*2 + 1
- "paddw %%mm7, %%mm1 \n\t" // abs(block[i])*2 + 1
- "pmullw %%mm4, %%mm0 \n\t" // (abs(block[i])*2 + 1)*q
- "pmullw %%mm5, %%mm1 \n\t" // (abs(block[i])*2 + 1)*q
- "pxor %%mm4, %%mm4 \n\t"
- "pxor %%mm5, %%mm5 \n\t" // FIXME slow
- "pcmpeqw (%0, %%"REG_a"), %%mm4 \n\t" // block[i] == 0 ? -1 : 0
- "pcmpeqw 8(%0, %%"REG_a"), %%mm5\n\t" // block[i] == 0 ? -1 : 0
- "psraw $4, %%mm0 \n\t"
- "psraw $4, %%mm1 \n\t"
- "psubw %%mm7, %%mm0 \n\t"
- "psubw %%mm7, %%mm1 \n\t"
- "por %%mm7, %%mm0 \n\t"
- "por %%mm7, %%mm1 \n\t"
- "pxor %%mm2, %%mm0 \n\t"
- "pxor %%mm3, %%mm1 \n\t"
- "psubw %%mm2, %%mm0 \n\t"
- "psubw %%mm3, %%mm1 \n\t"
- "pandn %%mm0, %%mm4 \n\t"
- "pandn %%mm1, %%mm5 \n\t"
- "movq %%mm4, (%0, %%"REG_a") \n\t"
- "movq %%mm5, 8(%0, %%"REG_a") \n\t"
-
- "add $16, %%"REG_a" \n\t"
- "js 1b \n\t"
- ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "rm" (qscale), "g" (-2*nCoeffs)
- : "%"REG_a, "memory"
- );
-}
-
-static void dct_unquantize_mpeg2_intra_mmx(MpegEncContext *s,
- int16_t *block, int n, int qscale)
-{
- x86_reg nCoeffs;
- const uint16_t *quant_matrix;
- int block0;
-
- av_assert2(s->block_last_index[n]>=0);
-
- if(s->alternate_scan) nCoeffs= 63; //FIXME
- else nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ];
-
- if (n < 4)
- block0 = block[0] * s->y_dc_scale;
- else
- block0 = block[0] * s->c_dc_scale;
- quant_matrix = s->intra_matrix;
-__asm__ volatile(
- "pcmpeqw %%mm7, %%mm7 \n\t"
- "psrlw $15, %%mm7 \n\t"
- "movd %2, %%mm6 \n\t"
- "packssdw %%mm6, %%mm6 \n\t"
- "packssdw %%mm6, %%mm6 \n\t"
- "mov %3, %%"REG_a" \n\t"
- ".p2align 4 \n\t"
- "1: \n\t"
- "movq (%0, %%"REG_a"), %%mm0 \n\t"
- "movq 8(%0, %%"REG_a"), %%mm1 \n\t"
- "movq (%1, %%"REG_a"), %%mm4 \n\t"
- "movq 8(%1, %%"REG_a"), %%mm5 \n\t"
- "pmullw %%mm6, %%mm4 \n\t" // q=qscale*quant_matrix[i]
- "pmullw %%mm6, %%mm5 \n\t" // q=qscale*quant_matrix[i]
- "pxor %%mm2, %%mm2 \n\t"
- "pxor %%mm3, %%mm3 \n\t"
- "pcmpgtw %%mm0, %%mm2 \n\t" // block[i] < 0 ? -1 : 0
- "pcmpgtw %%mm1, %%mm3 \n\t" // block[i] < 0 ? -1 : 0
- "pxor %%mm2, %%mm0 \n\t"
- "pxor %%mm3, %%mm1 \n\t"
- "psubw %%mm2, %%mm0 \n\t" // abs(block[i])
- "psubw %%mm3, %%mm1 \n\t" // abs(block[i])
- "pmullw %%mm4, %%mm0 \n\t" // abs(block[i])*q
- "pmullw %%mm5, %%mm1 \n\t" // abs(block[i])*q
- "pxor %%mm4, %%mm4 \n\t"
- "pxor %%mm5, %%mm5 \n\t" // FIXME slow
- "pcmpeqw (%0, %%"REG_a"), %%mm4 \n\t" // block[i] == 0 ? -1 : 0
- "pcmpeqw 8(%0, %%"REG_a"), %%mm5\n\t" // block[i] == 0 ? -1 : 0
- "psraw $3, %%mm0 \n\t"
- "psraw $3, %%mm1 \n\t"
- "pxor %%mm2, %%mm0 \n\t"
- "pxor %%mm3, %%mm1 \n\t"
- "psubw %%mm2, %%mm0 \n\t"
- "psubw %%mm3, %%mm1 \n\t"
- "pandn %%mm0, %%mm4 \n\t"
- "pandn %%mm1, %%mm5 \n\t"
- "movq %%mm4, (%0, %%"REG_a") \n\t"
- "movq %%mm5, 8(%0, %%"REG_a") \n\t"
-
- "add $16, %%"REG_a" \n\t"
- "jng 1b \n\t"
- ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "rm" (qscale), "g" (-2*nCoeffs)
- : "%"REG_a, "memory"
- );
- block[0]= block0;
- //Note, we do not do mismatch control for intra as errors cannot accumulate
-}
-
-static void dct_unquantize_mpeg2_inter_mmx(MpegEncContext *s,
- int16_t *block, int n, int qscale)
-{
- x86_reg nCoeffs;
- const uint16_t *quant_matrix;
-
- av_assert2(s->block_last_index[n]>=0);
-
- if(s->alternate_scan) nCoeffs= 63; //FIXME
- else nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ];
-
- quant_matrix = s->inter_matrix;
-__asm__ volatile(
- "pcmpeqw %%mm7, %%mm7 \n\t"
- "psrlq $48, %%mm7 \n\t"
- "movd %2, %%mm6 \n\t"
- "packssdw %%mm6, %%mm6 \n\t"
- "packssdw %%mm6, %%mm6 \n\t"
- "mov %3, %%"REG_a" \n\t"
- ".p2align 4 \n\t"
- "1: \n\t"
- "movq (%0, %%"REG_a"), %%mm0 \n\t"
- "movq 8(%0, %%"REG_a"), %%mm1 \n\t"
- "movq (%1, %%"REG_a"), %%mm4 \n\t"
- "movq 8(%1, %%"REG_a"), %%mm5 \n\t"
- "pmullw %%mm6, %%mm4 \n\t" // q=qscale*quant_matrix[i]
- "pmullw %%mm6, %%mm5 \n\t" // q=qscale*quant_matrix[i]
- "pxor %%mm2, %%mm2 \n\t"
- "pxor %%mm3, %%mm3 \n\t"
- "pcmpgtw %%mm0, %%mm2 \n\t" // block[i] < 0 ? -1 : 0
- "pcmpgtw %%mm1, %%mm3 \n\t" // block[i] < 0 ? -1 : 0
- "pxor %%mm2, %%mm0 \n\t"
- "pxor %%mm3, %%mm1 \n\t"
- "psubw %%mm2, %%mm0 \n\t" // abs(block[i])
- "psubw %%mm3, %%mm1 \n\t" // abs(block[i])
- "paddw %%mm0, %%mm0 \n\t" // abs(block[i])*2
- "paddw %%mm1, %%mm1 \n\t" // abs(block[i])*2
- "pmullw %%mm4, %%mm0 \n\t" // abs(block[i])*2*q
- "pmullw %%mm5, %%mm1 \n\t" // abs(block[i])*2*q
- "paddw %%mm4, %%mm0 \n\t" // (abs(block[i])*2 + 1)*q
- "paddw %%mm5, %%mm1 \n\t" // (abs(block[i])*2 + 1)*q
- "pxor %%mm4, %%mm4 \n\t"
- "pxor %%mm5, %%mm5 \n\t" // FIXME slow
- "pcmpeqw (%0, %%"REG_a"), %%mm4 \n\t" // block[i] == 0 ? -1 : 0
- "pcmpeqw 8(%0, %%"REG_a"), %%mm5\n\t" // block[i] == 0 ? -1 : 0
- "psrlw $4, %%mm0 \n\t"
- "psrlw $4, %%mm1 \n\t"
- "pxor %%mm2, %%mm0 \n\t"
- "pxor %%mm3, %%mm1 \n\t"
- "psubw %%mm2, %%mm0 \n\t"
- "psubw %%mm3, %%mm1 \n\t"
- "pandn %%mm0, %%mm4 \n\t"
- "pandn %%mm1, %%mm5 \n\t"
- "pxor %%mm4, %%mm7 \n\t"
- "pxor %%mm5, %%mm7 \n\t"
- "movq %%mm4, (%0, %%"REG_a") \n\t"
- "movq %%mm5, 8(%0, %%"REG_a") \n\t"
-
- "add $16, %%"REG_a" \n\t"
- "jng 1b \n\t"
- "movd 124(%0, %3), %%mm0 \n\t"
- "movq %%mm7, %%mm6 \n\t"
- "psrlq $32, %%mm7 \n\t"
- "pxor %%mm6, %%mm7 \n\t"
- "movq %%mm7, %%mm6 \n\t"
- "psrlq $16, %%mm7 \n\t"
- "pxor %%mm6, %%mm7 \n\t"
- "pslld $31, %%mm7 \n\t"
- "psrlq $15, %%mm7 \n\t"
- "pxor %%mm7, %%mm0 \n\t"
- "movd %%mm0, 124(%0, %3) \n\t"
-
- ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "rm" (qscale), "r" (-2*nCoeffs)
- : "%"REG_a, "memory"
- );
-}
-
-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_MPV_common_init_x86(MpegEncContext *s)
-{
-#if HAVE_INLINE_ASM
- int mm_flags = av_get_cpu_flags();
-
- if (mm_flags & AV_CPU_FLAG_MMX) {
- s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_mmx;
- s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_mmx;
- s->dct_unquantize_mpeg1_intra = dct_unquantize_mpeg1_intra_mmx;
- s->dct_unquantize_mpeg1_inter = dct_unquantize_mpeg1_inter_mmx;
- 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;
-
- if (mm_flags & AV_CPU_FLAG_SSE2) {
- s->denoise_dct= denoise_dct_sse2;
- } else {
- s->denoise_dct= denoise_dct_mmx;
- }
- }
-#endif /* HAVE_INLINE_ASM */
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/rv34dsp.asm b/src/thirdparty/ffmpeg/libavcodec/x86/rv34dsp.asm
deleted file mode 100644
index 3f6e27141..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/rv34dsp.asm
+++ /dev/null
@@ -1,196 +0,0 @@
-;******************************************************************************
-;* MMX/SSE2-optimized functions for the RV30 and RV40 decoders
-;* Copyright (C) 2012 Christophe Gisquet <christophe.gisquet@gmail.com>
-;*
-;* This file is part of Libav.
-;*
-;* Libav is free software; you can redistribute it and/or
-;* modify it under the terms of the GNU Lesser General Public
-;* License as published by the Free Software Foundation; either
-;* version 2.1 of the License, or (at your option) any later version.
-;*
-;* Libav is distributed in the hope that it will be useful,
-;* but WITHOUT ANY WARRANTY; without even the implied warranty of
-;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-;* Lesser General Public License for more details.
-;*
-;* You should have received a copy of the GNU Lesser General Public
-;* License along with Libav; if not, write to the Free Software
-;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-;******************************************************************************
-
-%include "libavutil/x86/x86util.asm"
-
-SECTION_RODATA
-pw_row_coeffs: times 4 dw 13
- times 4 dw 17
- times 4 dw 7
-pd_512: times 2 dd 0x200
-pw_col_coeffs: dw 13, 13, 13, -13
- dw 17, 7, 7, -17
- dw 13, -13, 13, 13
- dw -7, 17, -17, -7
-
-SECTION .text
-
-%macro IDCT_DC_NOROUND 1
- imul %1, 13*13*3
- sar %1, 11
-%endmacro
-
-%macro IDCT_DC_ROUND 1
- imul %1, 13*13
- add %1, 0x200
- sar %1, 10
-%endmacro
-
-%macro rv34_idct 1
-cglobal rv34_idct_%1, 1, 2, 0
- movsx r1, word [r0]
- IDCT_DC r1
- movd m0, r1d
- pshufw m0, m0, 0
- movq [r0+ 0], m0
- movq [r0+ 8], m0
- movq [r0+16], m0
- movq [r0+24], m0
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-%define IDCT_DC IDCT_DC_ROUND
-rv34_idct dc
-%define IDCT_DC IDCT_DC_NOROUND
-rv34_idct dc_noround
-
-; ff_rv34_idct_dc_add_mmx(uint8_t *dst, int stride, int dc);
-INIT_MMX mmx
-cglobal rv34_idct_dc_add, 3, 3
- ; calculate DC
- IDCT_DC_ROUND r2
- pxor m1, m1
- movd m0, r2d
- psubw m1, m0
- packuswb m0, m0
- packuswb m1, m1
- punpcklbw m0, m0
- punpcklbw m1, m1
- punpcklwd m0, m0
- punpcklwd m1, m1
-
- ; add DC
- lea r2, [r0+r1*2]
- movh m2, [r0]
- movh m3, [r0+r1]
- movh m4, [r2]
- movh m5, [r2+r1]
- paddusb m2, m0
- paddusb m3, m0
- paddusb m4, m0
- paddusb m5, m0
- psubusb m2, m1
- psubusb m3, m1
- psubusb m4, m1
- psubusb m5, m1
- movh [r0], m2
- movh [r0+r1], m3
- movh [r2], m4
- movh [r2+r1], m5
- RET
-
-; Load coeffs and perform row transform
-; Output: coeffs in mm[0467], rounder in mm5
-%macro ROW_TRANSFORM 1
- pxor mm7, mm7
- mova mm0, [%1+ 0*8]
- mova mm1, [%1+ 1*8]
- mova mm2, [%1+ 2*8]
- mova mm3, [%1+ 3*8]
- mova [%1+ 0*8], mm7
- mova [%1+ 1*8], mm7
- mova [%1+ 2*8], mm7
- mova [%1+ 3*8], mm7
- mova mm4, mm0
- mova mm6, [pw_row_coeffs+ 0]
- paddsw mm0, mm2 ; b0 + b2
- psubsw mm4, mm2 ; b0 - b2
- pmullw mm0, mm6 ; *13 = z0
- pmullw mm4, mm6 ; *13 = z1
- mova mm5, mm1
- pmullw mm1, [pw_row_coeffs+ 8] ; b1*17
- pmullw mm5, [pw_row_coeffs+16] ; b1* 7
- mova mm7, mm3
- pmullw mm3, [pw_row_coeffs+ 8] ; b3*17
- pmullw mm7, [pw_row_coeffs+16] ; b3* 7
- paddsw mm1, mm7 ; z3 = b1*17 + b3* 7
- psubsw mm5, mm3 ; z2 = b1* 7 - b3*17
- mova mm7, mm0
- mova mm6, mm4
- paddsw mm0, mm1 ; z0 + z3
- psubsw mm7, mm1 ; z0 - z3
- paddsw mm4, mm5 ; z1 + z2
- psubsw mm6, mm5 ; z1 - z2
- mova mm5, [pd_512] ; 0x200
-%endmacro
-
-; ff_rv34_idct_add_mmxext(uint8_t *dst, ptrdiff_t stride, int16_t *block);
-%macro COL_TRANSFORM 4
- pshufw mm3, %2, 0xDD ; col. 1,3,1,3
- pshufw %2, %2, 0x88 ; col. 0,2,0,2
- pmaddwd %2, %3 ; 13*c0+13*c2 | 13*c0-13*c2 = z0 | z1
- pmaddwd mm3, %4 ; 17*c1+ 7*c3 | 7*c1-17*c3 = z3 | z2
- paddd %2, mm5
- pshufw mm1, %2, 01001110b ; z1 | z0
- pshufw mm2, mm3, 01001110b ; z2 | z3
- paddd %2, mm3 ; z0+z3 | z1+z2
- psubd mm1, mm2 ; z1-z2 | z0-z3
- movd mm3, %1
- psrad %2, 10
- pxor mm2, mm2
- psrad mm1, 10
- punpcklbw mm3, mm2
- packssdw %2, mm1
- paddw %2, mm3
- packuswb %2, %2
- movd %1, %2
-%endmacro
-INIT_MMX mmxext
-cglobal rv34_idct_add, 3,3,0, d, s, b
- ROW_TRANSFORM bq
- COL_TRANSFORM [dq], mm0, [pw_col_coeffs+ 0], [pw_col_coeffs+ 8]
- mova mm0, [pw_col_coeffs+ 0]
- COL_TRANSFORM [dq+sq], mm4, mm0, [pw_col_coeffs+ 8]
- mova mm4, [pw_col_coeffs+ 8]
- lea dq, [dq + 2*sq]
- COL_TRANSFORM [dq], mm6, mm0, mm4
- COL_TRANSFORM [dq+sq], mm7, mm0, mm4
- ret
-
-; ff_rv34_idct_dc_add_sse4(uint8_t *dst, int stride, int dc);
-INIT_XMM sse4
-cglobal rv34_idct_dc_add, 3, 3, 6
- ; load data
- IDCT_DC_ROUND r2
- pxor m1, m1
-
- ; calculate DC
- movd m0, r2d
- lea r2, [r0+r1*2]
- movd m2, [r0]
- movd m3, [r0+r1]
- pshuflw m0, m0, 0
- movd m4, [r2]
- movd m5, [r2+r1]
- punpcklqdq m0, m0
- punpckldq m2, m3
- punpckldq m4, m5
- punpcklbw m2, m1
- punpcklbw m4, m1
- paddw m2, m0
- paddw m4, m0
- packuswb m2, m4
- movd [r0], m2
- pextrd [r0+r1], m2, 1
- pextrd [r2], m2, 2
- pextrd [r2+r1], m2, 3
- RET
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/rv34dsp_init.c b/src/thirdparty/ffmpeg/libavcodec/x86/rv34dsp_init.c
deleted file mode 100644
index f7796e47d..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/rv34dsp_init.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * RV30/40 MMX/SSE2 optimizations
- * Copyright (C) 2012 Christophe Gisquet <christophe.gisquet@gmail.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/cpu.h"
-#include "libavutil/x86/asm.h"
-#include "libavutil/x86/cpu.h"
-#include "libavcodec/dsputil.h"
-#include "libavcodec/rv34dsp.h"
-
-void ff_rv34_idct_dc_mmxext(int16_t *block);
-void ff_rv34_idct_dc_noround_mmxext(int16_t *block);
-void ff_rv34_idct_dc_add_mmx(uint8_t *dst, ptrdiff_t stride, int dc);
-void ff_rv34_idct_dc_add_sse4(uint8_t *dst, ptrdiff_t stride, int dc);
-void ff_rv34_idct_add_mmxext(uint8_t *dst, ptrdiff_t stride, int16_t *block);
-
-av_cold void ff_rv34dsp_init_x86(RV34DSPContext* c)
-{
- int mm_flags = av_get_cpu_flags();
-
- if (EXTERNAL_MMX(mm_flags))
- c->rv34_idct_dc_add = ff_rv34_idct_dc_add_mmx;
- if (EXTERNAL_MMXEXT(mm_flags)) {
- c->rv34_inv_transform_dc = ff_rv34_idct_dc_noround_mmxext;
- c->rv34_idct_add = ff_rv34_idct_add_mmxext;
- }
- if (EXTERNAL_SSE4(mm_flags))
- c->rv34_idct_dc_add = ff_rv34_idct_dc_add_sse4;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/rv40dsp.asm b/src/thirdparty/ffmpeg/libavcodec/x86/rv40dsp.asm
deleted file mode 100644
index 95e52b5ef..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/rv40dsp.asm
+++ /dev/null
@@ -1,505 +0,0 @@
-;******************************************************************************
-;* MMX/SSE2-optimized functions for the RV40 decoder
-;* Copyright (c) 2010 Ronald S. Bultje <rsbultje@gmail.com>
-;* Copyright (c) 2010 Jason Garrett-Glaser <darkshikari@gmail.com>
-;* Copyright (C) 2012 Christophe Gisquet <christophe.gisquet@gmail.com>
-;*
-;* This file is part of Libav.
-;*
-;* Libav is free software; you can redistribute it and/or
-;* modify it under the terms of the GNU Lesser General Public
-;* License as published by the Free Software Foundation; either
-;* version 2.1 of the License, or (at your option) any later version.
-;*
-;* Libav is distributed in the hope that it will be useful,
-;* but WITHOUT ANY WARRANTY; without even the implied warranty of
-;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-;* Lesser General Public License for more details.
-;*
-;* You should have received a copy of the GNU Lesser General Public
-;* License along with Libav; if not, write to the Free Software
-;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-;******************************************************************************
-
-%include "libavutil/x86/x86util.asm"
-
-SECTION_RODATA
-
-align 16
-pw_1024: times 8 dw 1 << (16 - 6) ; pw_1024
-
-sixtap_filter_hb_m: times 8 db 1, -5
- times 8 db 52, 20
- ; multiplied by 2 to have the same shift
- times 8 db 2, -10
- times 8 db 40, 40
- ; back to normal
- times 8 db 1, -5
- times 8 db 20, 52
-
-sixtap_filter_v_m: times 8 dw 1
- times 8 dw -5
- times 8 dw 52
- times 8 dw 20
- ; multiplied by 2 to have the same shift
- times 8 dw 2
- times 8 dw -10
- times 8 dw 40
- times 8 dw 40
- ; back to normal
- times 8 dw 1
- times 8 dw -5
- times 8 dw 20
- times 8 dw 52
-
-%ifdef PIC
-%define sixtap_filter_hw picregq
-%define sixtap_filter_hb picregq
-%define sixtap_filter_v picregq
-%define npicregs 1
-%else
-%define sixtap_filter_hw sixtap_filter_hw_m
-%define sixtap_filter_hb sixtap_filter_hb_m
-%define sixtap_filter_v sixtap_filter_v_m
-%define npicregs 0
-%endif
-
-filter_h6_shuf1: db 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8
-filter_h6_shuf2: db 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10
-filter_h6_shuf3: db 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11
-
-cextern pw_32
-cextern pw_16
-cextern pw_512
-
-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);
-;----------------------------------------------------------------------
-%macro LOAD 2
-%if WIN64
- movsxd %1q, %1d
-%endif
-%ifdef PIC
- add %1q, picregq
-%else
- add %1q, %2
-%endif
-%endmacro
-
-%macro STORE 3
-%ifidn %3, avg
- movh %2, [dstq]
-%endif
- packuswb %1, %1
-%ifidn %3, avg
-%if cpuflag(3dnow)
- pavgusb %1, %2
-%else
- pavgb %1, %2
-%endif
-%endif
- movh [dstq], %1
-%endmacro
-
-%macro FILTER_V 1
-cglobal %1_rv40_qpel_v, 6,6+npicregs,12, dst, dststride, src, srcstride, height, my, picreg
-%ifdef PIC
- lea picregq, [sixtap_filter_v_m]
-%endif
- pxor m7, m7
- LOAD my, sixtap_filter_v
-
- ; read 5 lines
- sub srcq, srcstrideq
- sub srcq, srcstrideq
- movh m0, [srcq]
- movh m1, [srcq+srcstrideq]
- movh m2, [srcq+srcstrideq*2]
- lea srcq, [srcq+srcstrideq*2]
- add srcq, srcstrideq
- movh m3, [srcq]
- movh m4, [srcq+srcstrideq]
- punpcklbw m0, m7
- punpcklbw m1, m7
- punpcklbw m2, m7
- punpcklbw m3, m7
- punpcklbw m4, m7
-
-%ifdef m8
- mova m8, [myq+ 0]
- mova m9, [myq+16]
- mova m10, [myq+32]
- mova m11, [myq+48]
-%define COEFF05 m8
-%define COEFF14 m9
-%define COEFF2 m10
-%define COEFF3 m11
-%else
-%define COEFF05 [myq+ 0]
-%define COEFF14 [myq+16]
-%define COEFF2 [myq+32]
-%define COEFF3 [myq+48]
-%endif
-.nextrow:
- mova m6, m1
- movh m5, [srcq+2*srcstrideq] ; read new row
- paddw m6, m4
- punpcklbw m5, m7
- pmullw m6, COEFF14
- paddw m0, m5
- pmullw m0, COEFF05
- paddw m6, m0
- mova m0, m1
- paddw m6, [pw_32]
- mova m1, m2
- pmullw m2, COEFF2
- paddw m6, m2
- mova m2, m3
- pmullw m3, COEFF3
- paddw m6, m3
-
- ; round/clip/store
- mova m3, m4
- psraw m6, 6
- mova m4, m5
- STORE m6, m5, %1
-
- ; go to next line
- add dstq, dststrideq
- add srcq, srcstrideq
- dec heightd ; next row
- jg .nextrow
- REP_RET
-%endmacro
-
-%macro FILTER_H 1
-cglobal %1_rv40_qpel_h, 6, 6+npicregs, 12, dst, dststride, src, srcstride, height, mx, picreg
-%ifdef PIC
- lea picregq, [sixtap_filter_v_m]
-%endif
- pxor m7, m7
- LOAD mx, sixtap_filter_v
- mova m6, [pw_32]
-%ifdef m8
- mova m8, [mxq+ 0]
- mova m9, [mxq+16]
- mova m10, [mxq+32]
- mova m11, [mxq+48]
-%define COEFF05 m8
-%define COEFF14 m9
-%define COEFF2 m10
-%define COEFF3 m11
-%else
-%define COEFF05 [mxq+ 0]
-%define COEFF14 [mxq+16]
-%define COEFF2 [mxq+32]
-%define COEFF3 [mxq+48]
-%endif
-.nextrow:
- movq m0, [srcq-2]
- movq m5, [srcq+3]
- movq m1, [srcq-1]
- movq m4, [srcq+2]
- punpcklbw m0, m7
- punpcklbw m5, m7
- punpcklbw m1, m7
- punpcklbw m4, m7
- movq m2, [srcq-0]
- movq m3, [srcq+1]
- paddw m0, m5
- paddw m1, m4
- punpcklbw m2, m7
- punpcklbw m3, m7
- pmullw m0, COEFF05
- pmullw m1, COEFF14
- pmullw m2, COEFF2
- pmullw m3, COEFF3
- paddw m0, m6
- paddw m1, m2
- paddw m0, m3
- paddw m0, m1
- psraw m0, 6
- STORE m0, m1, %1
-
- ; go to next line
- add dstq, dststrideq
- add srcq, srcstrideq
- dec heightd ; next row
- jg .nextrow
- REP_RET
-%endmacro
-
-%if ARCH_X86_32
-INIT_MMX mmx
-FILTER_V put
-FILTER_H put
-
-INIT_MMX mmxext
-FILTER_V avg
-FILTER_H avg
-
-INIT_MMX 3dnow
-FILTER_V avg
-FILTER_H avg
-%endif
-
-INIT_XMM sse2
-FILTER_H put
-FILTER_H avg
-FILTER_V put
-FILTER_V avg
-
-%macro FILTER_SSSE3 1
-cglobal %1_rv40_qpel_v, 6,6+npicregs,8, dst, dststride, src, srcstride, height, my, picreg
-%ifdef PIC
- lea picregq, [sixtap_filter_hb_m]
-%endif
-
- ; read 5 lines
- sub srcq, srcstrideq
- LOAD my, sixtap_filter_hb
- sub srcq, srcstrideq
- movh m0, [srcq]
- movh m1, [srcq+srcstrideq]
- movh m2, [srcq+srcstrideq*2]
- lea srcq, [srcq+srcstrideq*2]
- add srcq, srcstrideq
- mova m5, [myq]
- movh m3, [srcq]
- movh m4, [srcq+srcstrideq]
- lea srcq, [srcq+2*srcstrideq]
-
-.nextrow:
- mova m6, m2
- punpcklbw m0, m1
- punpcklbw m6, m3
- pmaddubsw m0, m5
- pmaddubsw m6, [myq+16]
- movh m7, [srcq] ; read new row
- paddw m6, m0
- mova m0, m1
- mova m1, m2
- mova m2, m3
- mova m3, m4
- mova m4, m7
- punpcklbw m7, m3
- pmaddubsw m7, m5
- paddw m6, m7
- pmulhrsw m6, [pw_512]
- STORE m6, m7, %1
-
- ; go to next line
- add dstq, dststrideq
- add srcq, srcstrideq
- dec heightd ; next row
- jg .nextrow
- REP_RET
-
-cglobal %1_rv40_qpel_h, 6,6+npicregs,8, dst, dststride, src, srcstride, height, mx, picreg
-%ifdef PIC
- lea picregq, [sixtap_filter_hb_m]
-%endif
- mova m3, [filter_h6_shuf2]
- mova m4, [filter_h6_shuf3]
- LOAD mx, sixtap_filter_hb
- mova m5, [mxq] ; set up 6tap filter in bytes
- mova m6, [mxq+16]
- mova m7, [filter_h6_shuf1]
-
-.nextrow:
- movu m0, [srcq-2]
- mova m1, m0
- mova m2, m0
- pshufb m0, m7
- pshufb m1, m3
- pshufb m2, m4
- pmaddubsw m0, m5
- pmaddubsw m1, m6
- pmaddubsw m2, m5
- paddw m0, m1
- paddw m0, m2
- pmulhrsw m0, [pw_512]
- STORE m0, m1, %1
-
- ; go to next line
- add dstq, dststrideq
- add srcq, srcstrideq
- dec heightd ; next row
- jg .nextrow
- REP_RET
-%endmacro
-
-INIT_XMM ssse3
-FILTER_SSSE3 put
-FILTER_SSSE3 avg
-
-; %1=5bits weights?, %2=dst %3=src1 %4=src3 %5=stride if sse2
-%macro RV40_WCORE 4-5
- movh m4, [%3 + r6 + 0]
- movh m5, [%4 + r6 + 0]
-%if %0 == 4
-%define OFFSET r6 + mmsize / 2
-%else
- ; 8x8 block and sse2, stride was provided
-%define OFFSET r6
- add r6, r5
-%endif
- movh m6, [%3 + OFFSET]
- movh m7, [%4 + OFFSET]
-
-%if %1 == 0
- ; 14bits weights
- punpcklbw m4, m0
- punpcklbw m5, m0
- punpcklbw m6, m0
- punpcklbw m7, m0
-
- psllw m4, 7
- psllw m5, 7
- psllw m6, 7
- psllw m7, 7
- pmulhw m4, m3
- pmulhw m5, m2
- pmulhw m6, m3
- pmulhw m7, m2
-
- paddw m4, m5
- paddw m6, m7
-%else
- ; 5bits weights
-%if cpuflag(ssse3)
- punpcklbw m4, m5
- punpcklbw m6, m7
-
- pmaddubsw m4, m3
- pmaddubsw m6, m3
-%else
- punpcklbw m4, m0
- punpcklbw m5, m0
- punpcklbw m6, m0
- punpcklbw m7, m0
-
- pmullw m4, m3
- pmullw m5, m2
- pmullw m6, m3
- pmullw m7, m2
- paddw m4, m5
- paddw m6, m7
-%endif
-
-%endif
-
- ; bias and shift down
-%if cpuflag(ssse3)
- pmulhrsw m4, m1
- pmulhrsw m6, m1
-%else
- paddw m4, m1
- paddw m6, m1
- psrlw m4, 5
- psrlw m6, 5
-%endif
-
- packuswb m4, m6
-%if %0 == 5
- ; Only called for 8x8 blocks and sse2
- sub r6, r5
- movh [%2 + r6], m4
- add r6, r5
- movhps [%2 + r6], m4
-%else
- mova [%2 + r6], m4
-%endif
-%endmacro
-
-
-%macro MAIN_LOOP 2
-%if mmsize == 8
- RV40_WCORE %2, r0, r1, r2
-%if %1 == 16
- RV40_WCORE %2, r0 + 8, r1 + 8, r2 + 8
-%endif
-
- ; Prepare for next loop
- add r6, r5
-%else
-%ifidn %1, 8
- RV40_WCORE %2, r0, r1, r2, r5
- ; Prepare 2 next lines
- add r6, r5
-%else
- RV40_WCORE %2, r0, r1, r2
- ; Prepare single next line
- add r6, r5
-%endif
-%endif
-
-%endmacro
-
-; 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
-; can be simplified, and several operations can be avoided.
-; Therefore, we check here whether they are multiples of 2^9 for
-; those simplifications to occur.
-%macro RV40_WEIGHT 3
-cglobal rv40_weight_func_%1_%2, 6, 7, 8
-%if cpuflag(ssse3)
- mova m1, [pw_1024]
-%else
- mova m1, [pw_16]
-%endif
- pxor m0, m0
- ; Set loop counter and increments
- mov r6, r5
- shl r6, %3
- add r0, r6
- add r1, r6
- add r2, r6
- neg r6
-
- movd m2, r3d
- movd m3, r4d
-%ifidn %1,rnd
-%define RND 0
- SPLATW m2, m2
-%else
-%define RND 1
-%if cpuflag(ssse3)
- punpcklbw m3, m2
-%else
- SPLATW m2, m2
-%endif
-%endif
- SPLATW m3, m3
-
-.loop:
- MAIN_LOOP %2, RND
- jnz .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-RV40_WEIGHT rnd, 8, 3
-RV40_WEIGHT rnd, 16, 4
-RV40_WEIGHT nornd, 8, 3
-RV40_WEIGHT nornd, 16, 4
-
-INIT_XMM sse2
-RV40_WEIGHT rnd, 8, 3
-RV40_WEIGHT rnd, 16, 4
-RV40_WEIGHT nornd, 8, 3
-RV40_WEIGHT nornd, 16, 4
-
-INIT_XMM ssse3
-RV40_WEIGHT rnd, 8, 3
-RV40_WEIGHT rnd, 16, 4
-RV40_WEIGHT nornd, 8, 3
-RV40_WEIGHT nornd, 16, 4
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/rv40dsp_init.c b/src/thirdparty/ffmpeg/libavcodec/x86/rv40dsp_init.c
deleted file mode 100644
index df9d87ccb..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/rv40dsp_init.c
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * RV40 decoder motion compensation functions x86-optimised
- * Copyright (c) 2008 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
- */
-
-/**
- * @file
- * RV40 decoder motion compensation functions x86-optimised
- * 2,0 and 0,2 have h264 equivalents.
- * 3,3 is bugged in the rv40 format and maps to _xy2 version
- */
-
-#include "libavcodec/rv34dsp.h"
-#include "libavutil/attributes.h"
-#include "libavutil/mem.h"
-#include "libavutil/x86/cpu.h"
-#include "dsputil_mmx.h"
-
-#if HAVE_YASM
-void ff_put_rv40_chroma_mc8_mmx (uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
-void ff_avg_rv40_chroma_mc8_mmxext(uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
-void ff_avg_rv40_chroma_mc8_3dnow(uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
-
-void ff_put_rv40_chroma_mc4_mmx (uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
-void ff_avg_rv40_chroma_mc4_mmxext(uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
-void ff_avg_rv40_chroma_mc4_3dnow(uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
-
-#define DECLARE_WEIGHT(opt) \
-void ff_rv40_weight_func_rnd_16_##opt(uint8_t *dst, uint8_t *src1, uint8_t *src2, \
- int w1, int w2, ptrdiff_t stride); \
-void ff_rv40_weight_func_rnd_8_##opt (uint8_t *dst, uint8_t *src1, uint8_t *src2, \
- int w1, int w2, ptrdiff_t stride); \
-void ff_rv40_weight_func_nornd_16_##opt(uint8_t *dst, uint8_t *src1, uint8_t *src2, \
- int w1, int w2, ptrdiff_t stride); \
-void ff_rv40_weight_func_nornd_8_##opt (uint8_t *dst, uint8_t *src1, uint8_t *src2, \
- int w1, int w2, ptrdiff_t stride);
-DECLARE_WEIGHT(mmxext)
-DECLARE_WEIGHT(sse2)
-DECLARE_WEIGHT(ssse3)
-
-/** @{ */
-/**
- * Define one qpel function.
- * LOOPSIZE must be already set to the number of pixels processed per
- * iteration in the inner loop of the called functions.
- * COFF(x) must be already defined so as to provide the offset into any
- * array of coeffs used by the called function for the qpel position x.
- */
-#define QPEL_FUNC_DECL(OP, SIZE, PH, PV, OPT) \
-static void OP ## rv40_qpel ##SIZE ##_mc ##PH ##PV ##OPT(uint8_t *dst, \
- uint8_t *src, \
- int stride) \
-{ \
- int i; \
- if (PH && PV) { \
- DECLARE_ALIGNED(16, uint8_t, tmp)[SIZE * (SIZE + 5)]; \
- uint8_t *tmpptr = tmp + SIZE * 2; \
- src -= stride * 2; \
- \
- for (i = 0; i < SIZE; i += LOOPSIZE) \
- ff_put_rv40_qpel_h ##OPT(tmp + i, SIZE, src + i, stride, \
- SIZE + 5, HCOFF(PH)); \
- for (i = 0; i < SIZE; i += LOOPSIZE) \
- ff_ ##OP ##rv40_qpel_v ##OPT(dst + i, stride, tmpptr + i, \
- SIZE, SIZE, VCOFF(PV)); \
- } else if (PV) { \
- for (i = 0; i < SIZE; i += LOOPSIZE) \
- ff_ ##OP ##rv40_qpel_v ## OPT(dst + i, stride, src + i, \
- stride, SIZE, VCOFF(PV)); \
- } else { \
- for (i = 0; i < SIZE; i += LOOPSIZE) \
- ff_ ##OP ##rv40_qpel_h ## OPT(dst + i, stride, src + i, \
- stride, SIZE, HCOFF(PH)); \
- } \
-};
-
-/** Declare functions for sizes 8 and 16 and given operations
- * and qpel position. */
-#define QPEL_FUNCS_DECL(OP, PH, PV, OPT) \
- QPEL_FUNC_DECL(OP, 8, PH, PV, OPT) \
- QPEL_FUNC_DECL(OP, 16, PH, PV, OPT)
-
-/** Declare all functions for all sizes and qpel positions */
-#define QPEL_MC_DECL(OP, OPT) \
-void ff_ ##OP ##rv40_qpel_h ##OPT(uint8_t *dst, ptrdiff_t dstStride, \
- const uint8_t *src, \
- ptrdiff_t srcStride, \
- int len, int m); \
-void ff_ ##OP ##rv40_qpel_v ##OPT(uint8_t *dst, ptrdiff_t dstStride, \
- const uint8_t *src, \
- ptrdiff_t srcStride, \
- int len, int m); \
-QPEL_FUNCS_DECL(OP, 0, 1, OPT) \
-QPEL_FUNCS_DECL(OP, 0, 3, OPT) \
-QPEL_FUNCS_DECL(OP, 1, 0, OPT) \
-QPEL_FUNCS_DECL(OP, 1, 1, OPT) \
-QPEL_FUNCS_DECL(OP, 1, 2, OPT) \
-QPEL_FUNCS_DECL(OP, 1, 3, OPT) \
-QPEL_FUNCS_DECL(OP, 2, 1, OPT) \
-QPEL_FUNCS_DECL(OP, 2, 2, OPT) \
-QPEL_FUNCS_DECL(OP, 2, 3, OPT) \
-QPEL_FUNCS_DECL(OP, 3, 0, OPT) \
-QPEL_FUNCS_DECL(OP, 3, 1, OPT) \
-QPEL_FUNCS_DECL(OP, 3, 2, OPT)
-/** @} */
-
-#define LOOPSIZE 8
-#define HCOFF(x) (32 * (x - 1))
-#define VCOFF(x) (32 * (x - 1))
-QPEL_MC_DECL(put_, _ssse3)
-QPEL_MC_DECL(avg_, _ssse3)
-
-#undef LOOPSIZE
-#undef HCOFF
-#undef VCOFF
-#define LOOPSIZE 8
-#define HCOFF(x) (64 * (x - 1))
-#define VCOFF(x) (64 * (x - 1))
-QPEL_MC_DECL(put_, _sse2)
-QPEL_MC_DECL(avg_, _sse2)
-
-#if ARCH_X86_32
-#undef LOOPSIZE
-#undef HCOFF
-#undef VCOFF
-#define LOOPSIZE 4
-#define HCOFF(x) (64 * (x - 1))
-#define VCOFF(x) (64 * (x - 1))
-
-QPEL_MC_DECL(put_, _mmx)
-
-#define ff_put_rv40_qpel_h_mmxext ff_put_rv40_qpel_h_mmx
-#define ff_put_rv40_qpel_v_mmxext ff_put_rv40_qpel_v_mmx
-QPEL_MC_DECL(avg_, _mmxext)
-
-#define ff_put_rv40_qpel_h_3dnow ff_put_rv40_qpel_h_mmx
-#define ff_put_rv40_qpel_v_3dnow ff_put_rv40_qpel_v_mmx
-QPEL_MC_DECL(avg_, _3dnow)
-#endif
-
-/** @{ */
-/** Set one function */
-#define QPEL_FUNC_SET(OP, SIZE, PH, PV, OPT) \
- c-> OP ## pixels_tab[2 - SIZE / 8][4 * PV + PH] = OP ## rv40_qpel ##SIZE ## _mc ##PH ##PV ##OPT;
-
-/** Set functions put and avg for sizes 8 and 16 and a given qpel position */
-#define QPEL_FUNCS_SET(OP, PH, PV, OPT) \
- QPEL_FUNC_SET(OP, 8, PH, PV, OPT) \
- QPEL_FUNC_SET(OP, 16, PH, PV, OPT)
-
-/** Set all functions for all sizes and qpel positions */
-#define QPEL_MC_SET(OP, OPT) \
-QPEL_FUNCS_SET (OP, 0, 1, OPT) \
-QPEL_FUNCS_SET (OP, 0, 3, OPT) \
-QPEL_FUNCS_SET (OP, 1, 0, OPT) \
-QPEL_FUNCS_SET (OP, 1, 1, OPT) \
-QPEL_FUNCS_SET (OP, 1, 2, OPT) \
-QPEL_FUNCS_SET (OP, 1, 3, OPT) \
-QPEL_FUNCS_SET (OP, 2, 1, OPT) \
-QPEL_FUNCS_SET (OP, 2, 2, OPT) \
-QPEL_FUNCS_SET (OP, 2, 3, OPT) \
-QPEL_FUNCS_SET (OP, 3, 0, OPT) \
-QPEL_FUNCS_SET (OP, 3, 1, OPT) \
-QPEL_FUNCS_SET (OP, 3, 2, OPT)
-/** @} */
-
-#endif /* HAVE_YASM */
-
-av_cold void ff_rv40dsp_init_x86(RV34DSPContext *c)
-{
-#if HAVE_YASM
- int mm_flags = av_get_cpu_flags();
-
- if (EXTERNAL_MMX(mm_flags)) {
- c->put_chroma_pixels_tab[0] = ff_put_rv40_chroma_mc8_mmx;
- c->put_chroma_pixels_tab[1] = ff_put_rv40_chroma_mc4_mmx;
-#if HAVE_MMX_INLINE
- c->put_pixels_tab[0][15] = ff_put_rv40_qpel16_mc33_mmx;
- c->put_pixels_tab[1][15] = ff_put_rv40_qpel8_mc33_mmx;
- c->avg_pixels_tab[0][15] = ff_avg_rv40_qpel16_mc33_mmx;
- c->avg_pixels_tab[1][15] = ff_avg_rv40_qpel8_mc33_mmx;
-#endif /* HAVE_MMX_INLINE */
-#if ARCH_X86_32
- QPEL_MC_SET(put_, _mmx)
-#endif
- }
- if (EXTERNAL_MMXEXT(mm_flags)) {
- c->avg_chroma_pixels_tab[0] = ff_avg_rv40_chroma_mc8_mmxext;
- c->avg_chroma_pixels_tab[1] = ff_avg_rv40_chroma_mc4_mmxext;
- c->rv40_weight_pixels_tab[0][0] = ff_rv40_weight_func_rnd_16_mmxext;
- c->rv40_weight_pixels_tab[0][1] = ff_rv40_weight_func_rnd_8_mmxext;
- c->rv40_weight_pixels_tab[1][0] = ff_rv40_weight_func_nornd_16_mmxext;
- c->rv40_weight_pixels_tab[1][1] = ff_rv40_weight_func_nornd_8_mmxext;
-#if ARCH_X86_32
- QPEL_MC_SET(avg_, _mmxext)
-#endif
- } else if (EXTERNAL_AMD3DNOW(mm_flags)) {
- c->avg_chroma_pixels_tab[0] = ff_avg_rv40_chroma_mc8_3dnow;
- c->avg_chroma_pixels_tab[1] = ff_avg_rv40_chroma_mc4_3dnow;
-#if ARCH_X86_32
- QPEL_MC_SET(avg_, _3dnow)
-#endif
- }
- if (EXTERNAL_SSE2(mm_flags)) {
- c->rv40_weight_pixels_tab[0][0] = ff_rv40_weight_func_rnd_16_sse2;
- c->rv40_weight_pixels_tab[0][1] = ff_rv40_weight_func_rnd_8_sse2;
- c->rv40_weight_pixels_tab[1][0] = ff_rv40_weight_func_nornd_16_sse2;
- c->rv40_weight_pixels_tab[1][1] = ff_rv40_weight_func_nornd_8_sse2;
- QPEL_MC_SET(put_, _sse2)
- QPEL_MC_SET(avg_, _sse2)
- }
- if (EXTERNAL_SSSE3(mm_flags)) {
- c->rv40_weight_pixels_tab[0][0] = ff_rv40_weight_func_rnd_16_ssse3;
- c->rv40_weight_pixels_tab[0][1] = ff_rv40_weight_func_rnd_8_ssse3;
- c->rv40_weight_pixels_tab[1][0] = ff_rv40_weight_func_nornd_16_ssse3;
- c->rv40_weight_pixels_tab[1][1] = ff_rv40_weight_func_nornd_8_ssse3;
- QPEL_MC_SET(put_, _ssse3)
- QPEL_MC_SET(avg_, _ssse3)
- }
-#endif /* HAVE_YASM */
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/sbrdsp.asm b/src/thirdparty/ffmpeg/libavcodec/x86/sbrdsp.asm
deleted file mode 100644
index 3fb3ed206..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/sbrdsp.asm
+++ /dev/null
@@ -1,222 +0,0 @@
-;******************************************************************************
-;* AAC Spectral Band Replication decoding functions
-;* Copyright (C) 2012 Christophe Gisquet <christophe.gisquet@gmail.com>
-;*
-;* This file is part of Libav.
-;*
-;* Libav is free software; you can redistribute it and/or
-;* modify it under the terms of the GNU Lesser General Public
-;* License as published by the Free Software Foundation; either
-;* version 2.1 of the License, or (at your option) any later version.
-;*
-;* Libav is distributed in the hope that it will be useful,
-;* but WITHOUT ANY WARRANTY; without even the implied warranty of
-;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-;* Lesser General Public License for more details.
-;*
-;* You should have received a copy of the GNU Lesser General Public
-;* License along with Libav; if not, write to the Free Software
-;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-;******************************************************************************
-
-%include "libavutil/x86/x86util.asm"
-
-SECTION_RODATA
-; mask equivalent for multiply by -1.0 1.0
-ps_mask times 2 dd 1<<31, 0
-ps_neg times 4 dd 1<<31
-
-SECTION_TEXT
-
-INIT_XMM sse
-cglobal sbr_sum_square, 2, 3, 6
- mov r2, r1
- xorps m0, m0
- xorps m1, m1
- sar r2, 3
- jz .prepare
-.loop:
- movu m2, [r0 + 0]
- movu m3, [r0 + 16]
- movu m4, [r0 + 32]
- movu m5, [r0 + 48]
- mulps m2, m2
- mulps m3, m3
- mulps m4, m4
- mulps m5, m5
- addps m0, m2
- addps m1, m3
- addps m0, m4
- addps m1, m5
- add r0, 64
- dec r2
- jnz .loop
-.prepare:
- and r1, 7
- sar r1, 1
- jz .end
-; len is a multiple of 2, thus there are at least 4 elements to process
-.endloop:
- movu m2, [r0]
- add r0, 16
- mulps m2, m2
- dec r1
- addps m0, m2
- jnz .endloop
-.end:
- addps m0, m1
- movhlps m2, m0
- addps m0, m2
- movss m1, m0
- shufps m0, m0, 1
- addss m0, m1
-%if ARCH_X86_64 == 0
- movss r0m, m0
- fld dword r0m
-%endif
- RET
-
-%define STEP 40*4*2
-cglobal sbr_hf_g_filt, 5, 6, 5
- lea r1, [r1 + 8*r4] ; offset by ixh elements into X_high
- mov r5, r3
- and r3, 0xFC
- lea r2, [r2 + r3*4]
- lea r0, [r0 + r3*8]
- neg r3
- jz .loop1
-.loop4:
- movlps m0, [r2 + 4*r3 + 0]
- movlps m1, [r2 + 4*r3 + 8]
- movlps m2, [r1 + 0*STEP]
- movlps m3, [r1 + 2*STEP]
- movhps m2, [r1 + 1*STEP]
- movhps m3, [r1 + 3*STEP]
- unpcklps m0, m0
- unpcklps m1, m1
- mulps m0, m2
- mulps m1, m3
- movu [r0 + 8*r3 + 0], m0
- movu [r0 + 8*r3 + 16], m1
- add r1, 4*STEP
- add r3, 4
- jnz .loop4
- and r5, 3 ; number of single element loops
- jz .end
-.loop1: ; element 0 and 1 can be computed at the same time
- movss m0, [r2]
- movlps m2, [r1]
- unpcklps m0, m0
- mulps m2, m0
- movlps [r0], m2
- add r0, 8
- add r2, 4
- add r1, STEP
- dec r5
- jnz .loop1
-.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)
-;
-cglobal sbr_hf_gen, 4,4,8, X_high, X_low, alpha0, alpha1, BW, S, E
- ; load alpha factors
-%define bw m0
-%if ARCH_X86_64 == 0 || WIN64
- movss bw, BWm
-%endif
- movlps m2, [alpha1q]
- movlps m1, [alpha0q]
- shufps bw, bw, 0
- mulps m2, bw ; (a1[0] a1[1])*bw
- mulps m1, bw ; (a0[0] a0[1])*bw = (a2 a3)
- mulps m2, bw ; (a1[0] a1[1])*bw*bw = (a0 a1)
- mova m3, m1
- mova m4, m2
-
- ; Set pointers
-%if ARCH_X86_64 == 0 || WIN64
- ; start and end 6th and 7th args on stack
- mov r2d, Sm
- mov r3d, Em
-%define start r2q
-%define end r3q
-%else
-; BW does not actually occupy a register, so shift by 1
-%define start BWq
-%define end Sq
-%endif
- sub start, end ; neg num of loops
- lea X_highq, [X_highq + end*2*4]
- lea X_lowq, [X_lowq + end*2*4 - 2*2*4]
- shl start, 3 ; offset from num loops
-
- mova m0, [X_lowq + start]
- shufps m3, m3, q1111
- shufps m4, m4, q1111
- xorps m3, [ps_mask]
- shufps m1, m1, q0000
- shufps m2, m2, q0000
- xorps m4, [ps_mask]
-.loop2:
- movu m7, [X_lowq + start + 8] ; BbCc
- mova m6, m0
- mova m5, m7
- shufps m0, m0, q2301 ; aAbB
- shufps m7, m7, q2301 ; bBcC
- mulps m0, m4
- mulps m7, m3
- mulps m6, m2
- mulps m5, m1
- addps m7, m0
- mova m0, [X_lowq + start +16] ; CcDd
- addps m7, m0
- addps m6, m5
- addps m7, m6
- mova [X_highq + start], m7
- add start, 16
- jnz .loop2
- RET
-
-cglobal sbr_sum64x5, 1,2,4,z
- lea r1q, [zq+ 256]
-.loop:
- mova m0, [zq+ 0]
- mova m2, [zq+ 16]
- mova m1, [zq+ 256]
- mova m3, [zq+ 272]
- addps m0, [zq+ 512]
- addps m2, [zq+ 528]
- addps m1, [zq+ 768]
- addps m3, [zq+ 784]
- addps m0, [zq+1024]
- addps m2, [zq+1040]
- addps m0, m1
- addps m2, m3
- mova [zq], m0
- mova [zq+16], m2
- add zq, 32
- cmp zq, r1q
- jne .loop
- REP_RET
-
-INIT_XMM sse
-cglobal sbr_qmf_post_shuffle, 2,3,4,W,z
- lea r2q, [zq + (64-4)*4]
- mova m3, [ps_neg]
-.loop:
- mova m1, [zq]
- xorps m0, m3, [r2q]
- shufps m0, m0, m0, q0123
- unpcklps m2, m0, m1
- unpckhps m0, m0, m1
- mova [Wq + 0], m2
- mova [Wq + 16], m0
- add Wq, 32
- sub r2q, 16
- add zq, 16
- cmp zq, r2q
- jl .loop
- REP_RET
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/sbrdsp_init.c b/src/thirdparty/ffmpeg/libavcodec/x86/sbrdsp_init.c
deleted file mode 100644
index ecfed83b4..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/sbrdsp_init.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * AAC Spectral Band Replication decoding functions
- * Copyright (c) 2012 Christophe Gisquet <christophe.gisquet@gmail.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "config.h"
-#include "libavutil/attributes.h"
-#include "libavutil/cpu.h"
-#include "libavutil/x86/cpu.h"
-#include "libavcodec/sbrdsp.h"
-
-float ff_sbr_sum_square_sse(float (*x)[2], int n);
-void ff_sbr_sum64x5_sse(float *z);
-void ff_sbr_hf_g_filt_sse(float (*Y)[2], const float (*X_high)[40][2],
- const float *g_filt, int m_max, intptr_t ixh);
-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);
-void ff_sbr_qmf_post_shuffle_sse(float W[32][2], const float *z);
-
-av_cold void ff_sbrdsp_init_x86(SBRDSPContext *s)
-{
- int mm_flags = av_get_cpu_flags();
-
- if (EXTERNAL_SSE(mm_flags)) {
- s->sum_square = ff_sbr_sum_square_sse;
- s->sum64x5 = ff_sbr_sum64x5_sse;
- s->hf_g_filt = ff_sbr_hf_g_filt_sse;
- s->hf_gen = ff_sbr_hf_gen_sse;
- s->qmf_post_shuffle = ff_sbr_qmf_post_shuffle_sse;
- }
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/simple_idct.c b/src/thirdparty/ffmpeg/libavcodec/x86/simple_idct.c
deleted file mode 100644
index f9fd7dc3c..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/simple_idct.c
+++ /dev/null
@@ -1,1168 +0,0 @@
-/*
- * Simple IDCT MMX
- *
- * Copyright (c) 2001, 2002 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
- */
-#include "libavcodec/dsputil.h"
-#include "libavcodec/simple_idct.h"
-#include "libavutil/mem.h"
-#include "dsputil_mmx.h"
-
-#if HAVE_INLINE_ASM
-
-/*
-23170.475006
-22725.260826
-21406.727617
-19265.545870
-16384.000000
-12872.826198
-8866.956905
-4520.335430
-*/
-#define C0 23170 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define C1 22725 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define C2 21407 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define C3 19266 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define C4 16383 //cos(i*M_PI/16)*sqrt(2)*(1<<14) - 0.5
-#define C5 12873 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define C6 8867 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-#define C7 4520 //cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5
-
-#define ROW_SHIFT 11
-#define COL_SHIFT 20 // 6
-
-DECLARE_ASM_CONST(8, uint64_t, wm1010)= 0xFFFF0000FFFF0000ULL;
-DECLARE_ASM_CONST(8, uint64_t, d40000)= 0x0000000000040000ULL;
-
-DECLARE_ALIGNED(8, static const int16_t, coeffs)[]= {
- 1<<(ROW_SHIFT-1), 0, 1<<(ROW_SHIFT-1), 0,
-// 1<<(COL_SHIFT-1), 0, 1<<(COL_SHIFT-1), 0,
-// 0, 1<<(COL_SHIFT-1-16), 0, 1<<(COL_SHIFT-1-16),
- 1<<(ROW_SHIFT-1), 1, 1<<(ROW_SHIFT-1), 0,
- // the 1 = ((1<<(COL_SHIFT-1))/C4)<<ROW_SHIFT :)
-// 0, 0, 0, 0,
-// 0, 0, 0, 0,
-
- C4, C4, C4, C4,
- C4, -C4, C4, -C4,
-
- C2, C6, C2, C6,
- C6, -C2, C6, -C2,
-
- C1, C3, C1, C3,
- C5, C7, C5, C7,
-
- C3, -C7, C3, -C7,
--C1, -C5, -C1, -C5,
-
- C5, -C1, C5, -C1,
- C7, C3, C7, C3,
-
- C7, -C5, C7, -C5,
- C3, -C1, C3, -C1
-};
-
-static inline void idct(int16_t *block)
-{
- DECLARE_ALIGNED(8, int64_t, align_tmp)[16];
- int16_t * const temp= (int16_t*)align_tmp;
-
- __asm__ volatile(
-#if 0 //Alternative, simpler variant
-
-#define ROW_IDCT(src0, src4, src1, src5, dst, rounder, shift) \
- "movq " #src0 ", %%mm0 \n\t" /* R4 R0 r4 r0 */\
- "movq " #src4 ", %%mm1 \n\t" /* R6 R2 r6 r2 */\
- "movq " #src1 ", %%mm2 \n\t" /* R3 R1 r3 r1 */\
- "movq " #src5 ", %%mm3 \n\t" /* R7 R5 r7 r5 */\
- "movq 16(%2), %%mm4 \n\t" /* C4 C4 C4 C4 */\
- "pmaddwd %%mm0, %%mm4 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "movq 24(%2), %%mm5 \n\t" /* -C4 C4 -C4 C4 */\
- "pmaddwd %%mm5, %%mm0 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\
- "movq 32(%2), %%mm5 \n\t" /* C6 C2 C6 C2 */\
- "pmaddwd %%mm1, %%mm5 \n\t" /* C6R6+C2R2 C6r6+C2r2 */\
- "movq 40(%2), %%mm6 \n\t" /* -C2 C6 -C2 C6 */\
- "pmaddwd %%mm6, %%mm1 \n\t" /* -C2R6+C6R2 -C2r6+C6r2 */\
- "movq 48(%2), %%mm7 \n\t" /* C3 C1 C3 C1 */\
- "pmaddwd %%mm2, %%mm7 \n\t" /* C3R3+C1R1 C3r3+C1r1 */\
- #rounder ", %%mm4 \n\t"\
- "movq %%mm4, %%mm6 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "paddd %%mm5, %%mm4 \n\t" /* A0 a0 */\
- "psubd %%mm5, %%mm6 \n\t" /* A3 a3 */\
- "movq 56(%2), %%mm5 \n\t" /* C7 C5 C7 C5 */\
- "pmaddwd %%mm3, %%mm5 \n\t" /* C7R7+C5R5 C7r7+C5r5 */\
- #rounder ", %%mm0 \n\t"\
- "paddd %%mm0, %%mm1 \n\t" /* A1 a1 */\
- "paddd %%mm0, %%mm0 \n\t" \
- "psubd %%mm1, %%mm0 \n\t" /* A2 a2 */\
- "pmaddwd 64(%2), %%mm2 \n\t" /* -C7R3+C3R1 -C7r3+C3r1 */\
- "paddd %%mm5, %%mm7 \n\t" /* B0 b0 */\
- "movq 72(%2), %%mm5 \n\t" /* -C5 -C1 -C5 -C1 */\
- "pmaddwd %%mm3, %%mm5 \n\t" /* -C5R7-C1R5 -C5r7-C1r5 */\
- "paddd %%mm4, %%mm7 \n\t" /* A0+B0 a0+b0 */\
- "paddd %%mm4, %%mm4 \n\t" /* 2A0 2a0 */\
- "psubd %%mm7, %%mm4 \n\t" /* A0-B0 a0-b0 */\
- "paddd %%mm2, %%mm5 \n\t" /* B1 b1 */\
- "psrad $" #shift ", %%mm7 \n\t"\
- "psrad $" #shift ", %%mm4 \n\t"\
- "movq %%mm1, %%mm2 \n\t" /* A1 a1 */\
- "paddd %%mm5, %%mm1 \n\t" /* A1+B1 a1+b1 */\
- "psubd %%mm5, %%mm2 \n\t" /* A1-B1 a1-b1 */\
- "psrad $" #shift ", %%mm1 \n\t"\
- "psrad $" #shift ", %%mm2 \n\t"\
- "packssdw %%mm1, %%mm7 \n\t" /* A1+B1 a1+b1 A0+B0 a0+b0 */\
- "packssdw %%mm4, %%mm2 \n\t" /* A0-B0 a0-b0 A1-B1 a1-b1 */\
- "movq %%mm7, " #dst " \n\t"\
- "movq " #src1 ", %%mm1 \n\t" /* R3 R1 r3 r1 */\
- "movq 80(%2), %%mm4 \n\t" /* -C1 C5 -C1 C5 */\
- "movq %%mm2, 24+" #dst " \n\t"\
- "pmaddwd %%mm1, %%mm4 \n\t" /* -C1R3+C5R1 -C1r3+C5r1 */\
- "movq 88(%2), %%mm7 \n\t" /* C3 C7 C3 C7 */\
- "pmaddwd 96(%2), %%mm1 \n\t" /* -C5R3+C7R1 -C5r3+C7r1 */\
- "pmaddwd %%mm3, %%mm7 \n\t" /* C3R7+C7R5 C3r7+C7r5 */\
- "movq %%mm0, %%mm2 \n\t" /* A2 a2 */\
- "pmaddwd 104(%2), %%mm3 \n\t" /* -C1R7+C3R5 -C1r7+C3r5 */\
- "paddd %%mm7, %%mm4 \n\t" /* B2 b2 */\
- "paddd %%mm4, %%mm2 \n\t" /* A2+B2 a2+b2 */\
- "psubd %%mm4, %%mm0 \n\t" /* a2-B2 a2-b2 */\
- "psrad $" #shift ", %%mm2 \n\t"\
- "psrad $" #shift ", %%mm0 \n\t"\
- "movq %%mm6, %%mm4 \n\t" /* A3 a3 */\
- "paddd %%mm1, %%mm3 \n\t" /* B3 b3 */\
- "paddd %%mm3, %%mm6 \n\t" /* A3+B3 a3+b3 */\
- "psubd %%mm3, %%mm4 \n\t" /* a3-B3 a3-b3 */\
- "psrad $" #shift ", %%mm6 \n\t"\
- "packssdw %%mm6, %%mm2 \n\t" /* A3+B3 a3+b3 A2+B2 a2+b2 */\
- "movq %%mm2, 8+" #dst " \n\t"\
- "psrad $" #shift ", %%mm4 \n\t"\
- "packssdw %%mm0, %%mm4 \n\t" /* A2-B2 a2-b2 A3-B3 a3-b3 */\
- "movq %%mm4, 16+" #dst " \n\t"\
-
-#define COL_IDCT(src0, src4, src1, src5, dst, shift) \
- "movq " #src0 ", %%mm0 \n\t" /* R4 R0 r4 r0 */\
- "movq " #src4 ", %%mm1 \n\t" /* R6 R2 r6 r2 */\
- "movq " #src1 ", %%mm2 \n\t" /* R3 R1 r3 r1 */\
- "movq " #src5 ", %%mm3 \n\t" /* R7 R5 r7 r5 */\
- "movq 16(%2), %%mm4 \n\t" /* C4 C4 C4 C4 */\
- "pmaddwd %%mm0, %%mm4 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "movq 24(%2), %%mm5 \n\t" /* -C4 C4 -C4 C4 */\
- "pmaddwd %%mm5, %%mm0 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\
- "movq 32(%2), %%mm5 \n\t" /* C6 C2 C6 C2 */\
- "pmaddwd %%mm1, %%mm5 \n\t" /* C6R6+C2R2 C6r6+C2r2 */\
- "movq 40(%2), %%mm6 \n\t" /* -C2 C6 -C2 C6 */\
- "pmaddwd %%mm6, %%mm1 \n\t" /* -C2R6+C6R2 -C2r6+C6r2 */\
- "movq %%mm4, %%mm6 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "movq 48(%2), %%mm7 \n\t" /* C3 C1 C3 C1 */\
- "pmaddwd %%mm2, %%mm7 \n\t" /* C3R3+C1R1 C3r3+C1r1 */\
- "paddd %%mm5, %%mm4 \n\t" /* A0 a0 */\
- "psubd %%mm5, %%mm6 \n\t" /* A3 a3 */\
- "movq %%mm0, %%mm5 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\
- "paddd %%mm1, %%mm0 \n\t" /* A1 a1 */\
- "psubd %%mm1, %%mm5 \n\t" /* A2 a2 */\
- "movq 56(%2), %%mm1 \n\t" /* C7 C5 C7 C5 */\
- "pmaddwd %%mm3, %%mm1 \n\t" /* C7R7+C5R5 C7r7+C5r5 */\
- "pmaddwd 64(%2), %%mm2 \n\t" /* -C7R3+C3R1 -C7r3+C3r1 */\
- "paddd %%mm1, %%mm7 \n\t" /* B0 b0 */\
- "movq 72(%2), %%mm1 \n\t" /* -C5 -C1 -C5 -C1 */\
- "pmaddwd %%mm3, %%mm1 \n\t" /* -C5R7-C1R5 -C5r7-C1r5 */\
- "paddd %%mm4, %%mm7 \n\t" /* A0+B0 a0+b0 */\
- "paddd %%mm4, %%mm4 \n\t" /* 2A0 2a0 */\
- "psubd %%mm7, %%mm4 \n\t" /* A0-B0 a0-b0 */\
- "paddd %%mm2, %%mm1 \n\t" /* B1 b1 */\
- "psrad $" #shift ", %%mm7 \n\t"\
- "psrad $" #shift ", %%mm4 \n\t"\
- "movq %%mm0, %%mm2 \n\t" /* A1 a1 */\
- "paddd %%mm1, %%mm0 \n\t" /* A1+B1 a1+b1 */\
- "psubd %%mm1, %%mm2 \n\t" /* A1-B1 a1-b1 */\
- "psrad $" #shift ", %%mm0 \n\t"\
- "psrad $" #shift ", %%mm2 \n\t"\
- "packssdw %%mm7, %%mm7 \n\t" /* A0+B0 a0+b0 */\
- "movd %%mm7, " #dst " \n\t"\
- "packssdw %%mm0, %%mm0 \n\t" /* A1+B1 a1+b1 */\
- "movd %%mm0, 16+" #dst " \n\t"\
- "packssdw %%mm2, %%mm2 \n\t" /* A1-B1 a1-b1 */\
- "movd %%mm2, 96+" #dst " \n\t"\
- "packssdw %%mm4, %%mm4 \n\t" /* A0-B0 a0-b0 */\
- "movd %%mm4, 112+" #dst " \n\t"\
- "movq " #src1 ", %%mm0 \n\t" /* R3 R1 r3 r1 */\
- "movq 80(%2), %%mm4 \n\t" /* -C1 C5 -C1 C5 */\
- "pmaddwd %%mm0, %%mm4 \n\t" /* -C1R3+C5R1 -C1r3+C5r1 */\
- "movq 88(%2), %%mm7 \n\t" /* C3 C7 C3 C7 */\
- "pmaddwd 96(%2), %%mm0 \n\t" /* -C5R3+C7R1 -C5r3+C7r1 */\
- "pmaddwd %%mm3, %%mm7 \n\t" /* C3R7+C7R5 C3r7+C7r5 */\
- "movq %%mm5, %%mm2 \n\t" /* A2 a2 */\
- "pmaddwd 104(%2), %%mm3 \n\t" /* -C1R7+C3R5 -C1r7+C3r5 */\
- "paddd %%mm7, %%mm4 \n\t" /* B2 b2 */\
- "paddd %%mm4, %%mm2 \n\t" /* A2+B2 a2+b2 */\
- "psubd %%mm4, %%mm5 \n\t" /* a2-B2 a2-b2 */\
- "psrad $" #shift ", %%mm2 \n\t"\
- "psrad $" #shift ", %%mm5 \n\t"\
- "movq %%mm6, %%mm4 \n\t" /* A3 a3 */\
- "paddd %%mm0, %%mm3 \n\t" /* B3 b3 */\
- "paddd %%mm3, %%mm6 \n\t" /* A3+B3 a3+b3 */\
- "psubd %%mm3, %%mm4 \n\t" /* a3-B3 a3-b3 */\
- "psrad $" #shift ", %%mm6 \n\t"\
- "psrad $" #shift ", %%mm4 \n\t"\
- "packssdw %%mm2, %%mm2 \n\t" /* A2+B2 a2+b2 */\
- "packssdw %%mm6, %%mm6 \n\t" /* A3+B3 a3+b3 */\
- "movd %%mm2, 32+" #dst " \n\t"\
- "packssdw %%mm4, %%mm4 \n\t" /* A3-B3 a3-b3 */\
- "packssdw %%mm5, %%mm5 \n\t" /* A2-B2 a2-b2 */\
- "movd %%mm6, 48+" #dst " \n\t"\
- "movd %%mm4, 64+" #dst " \n\t"\
- "movd %%mm5, 80+" #dst " \n\t"\
-
-
-#define DC_COND_ROW_IDCT(src0, src4, src1, src5, dst, rounder, shift) \
- "movq " #src0 ", %%mm0 \n\t" /* R4 R0 r4 r0 */\
- "movq " #src4 ", %%mm1 \n\t" /* R6 R2 r6 r2 */\
- "movq " #src1 ", %%mm2 \n\t" /* R3 R1 r3 r1 */\
- "movq " #src5 ", %%mm3 \n\t" /* R7 R5 r7 r5 */\
- "movq "MANGLE(wm1010)", %%mm4 \n\t"\
- "pand %%mm0, %%mm4 \n\t"\
- "por %%mm1, %%mm4 \n\t"\
- "por %%mm2, %%mm4 \n\t"\
- "por %%mm3, %%mm4 \n\t"\
- "packssdw %%mm4,%%mm4 \n\t"\
- "movd %%mm4, %%eax \n\t"\
- "orl %%eax, %%eax \n\t"\
- "jz 1f \n\t"\
- "movq 16(%2), %%mm4 \n\t" /* C4 C4 C4 C4 */\
- "pmaddwd %%mm0, %%mm4 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "movq 24(%2), %%mm5 \n\t" /* -C4 C4 -C4 C4 */\
- "pmaddwd %%mm5, %%mm0 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\
- "movq 32(%2), %%mm5 \n\t" /* C6 C2 C6 C2 */\
- "pmaddwd %%mm1, %%mm5 \n\t" /* C6R6+C2R2 C6r6+C2r2 */\
- "movq 40(%2), %%mm6 \n\t" /* -C2 C6 -C2 C6 */\
- "pmaddwd %%mm6, %%mm1 \n\t" /* -C2R6+C6R2 -C2r6+C6r2 */\
- "movq 48(%2), %%mm7 \n\t" /* C3 C1 C3 C1 */\
- "pmaddwd %%mm2, %%mm7 \n\t" /* C3R3+C1R1 C3r3+C1r1 */\
- #rounder ", %%mm4 \n\t"\
- "movq %%mm4, %%mm6 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "paddd %%mm5, %%mm4 \n\t" /* A0 a0 */\
- "psubd %%mm5, %%mm6 \n\t" /* A3 a3 */\
- "movq 56(%2), %%mm5 \n\t" /* C7 C5 C7 C5 */\
- "pmaddwd %%mm3, %%mm5 \n\t" /* C7R7+C5R5 C7r7+C5r5 */\
- #rounder ", %%mm0 \n\t"\
- "paddd %%mm0, %%mm1 \n\t" /* A1 a1 */\
- "paddd %%mm0, %%mm0 \n\t" \
- "psubd %%mm1, %%mm0 \n\t" /* A2 a2 */\
- "pmaddwd 64(%2), %%mm2 \n\t" /* -C7R3+C3R1 -C7r3+C3r1 */\
- "paddd %%mm5, %%mm7 \n\t" /* B0 b0 */\
- "movq 72(%2), %%mm5 \n\t" /* -C5 -C1 -C5 -C1 */\
- "pmaddwd %%mm3, %%mm5 \n\t" /* -C5R7-C1R5 -C5r7-C1r5 */\
- "paddd %%mm4, %%mm7 \n\t" /* A0+B0 a0+b0 */\
- "paddd %%mm4, %%mm4 \n\t" /* 2A0 2a0 */\
- "psubd %%mm7, %%mm4 \n\t" /* A0-B0 a0-b0 */\
- "paddd %%mm2, %%mm5 \n\t" /* B1 b1 */\
- "psrad $" #shift ", %%mm7 \n\t"\
- "psrad $" #shift ", %%mm4 \n\t"\
- "movq %%mm1, %%mm2 \n\t" /* A1 a1 */\
- "paddd %%mm5, %%mm1 \n\t" /* A1+B1 a1+b1 */\
- "psubd %%mm5, %%mm2 \n\t" /* A1-B1 a1-b1 */\
- "psrad $" #shift ", %%mm1 \n\t"\
- "psrad $" #shift ", %%mm2 \n\t"\
- "packssdw %%mm1, %%mm7 \n\t" /* A1+B1 a1+b1 A0+B0 a0+b0 */\
- "packssdw %%mm4, %%mm2 \n\t" /* A0-B0 a0-b0 A1-B1 a1-b1 */\
- "movq %%mm7, " #dst " \n\t"\
- "movq " #src1 ", %%mm1 \n\t" /* R3 R1 r3 r1 */\
- "movq 80(%2), %%mm4 \n\t" /* -C1 C5 -C1 C5 */\
- "movq %%mm2, 24+" #dst " \n\t"\
- "pmaddwd %%mm1, %%mm4 \n\t" /* -C1R3+C5R1 -C1r3+C5r1 */\
- "movq 88(%2), %%mm7 \n\t" /* C3 C7 C3 C7 */\
- "pmaddwd 96(%2), %%mm1 \n\t" /* -C5R3+C7R1 -C5r3+C7r1 */\
- "pmaddwd %%mm3, %%mm7 \n\t" /* C3R7+C7R5 C3r7+C7r5 */\
- "movq %%mm0, %%mm2 \n\t" /* A2 a2 */\
- "pmaddwd 104(%2), %%mm3 \n\t" /* -C1R7+C3R5 -C1r7+C3r5 */\
- "paddd %%mm7, %%mm4 \n\t" /* B2 b2 */\
- "paddd %%mm4, %%mm2 \n\t" /* A2+B2 a2+b2 */\
- "psubd %%mm4, %%mm0 \n\t" /* a2-B2 a2-b2 */\
- "psrad $" #shift ", %%mm2 \n\t"\
- "psrad $" #shift ", %%mm0 \n\t"\
- "movq %%mm6, %%mm4 \n\t" /* A3 a3 */\
- "paddd %%mm1, %%mm3 \n\t" /* B3 b3 */\
- "paddd %%mm3, %%mm6 \n\t" /* A3+B3 a3+b3 */\
- "psubd %%mm3, %%mm4 \n\t" /* a3-B3 a3-b3 */\
- "psrad $" #shift ", %%mm6 \n\t"\
- "packssdw %%mm6, %%mm2 \n\t" /* A3+B3 a3+b3 A2+B2 a2+b2 */\
- "movq %%mm2, 8+" #dst " \n\t"\
- "psrad $" #shift ", %%mm4 \n\t"\
- "packssdw %%mm0, %%mm4 \n\t" /* A2-B2 a2-b2 A3-B3 a3-b3 */\
- "movq %%mm4, 16+" #dst " \n\t"\
- "jmp 2f \n\t"\
- "1: \n\t"\
- "pslld $16, %%mm0 \n\t"\
- "#paddd "MANGLE(d40000)", %%mm0 \n\t"\
- "psrad $13, %%mm0 \n\t"\
- "packssdw %%mm0, %%mm0 \n\t"\
- "movq %%mm0, " #dst " \n\t"\
- "movq %%mm0, 8+" #dst " \n\t"\
- "movq %%mm0, 16+" #dst " \n\t"\
- "movq %%mm0, 24+" #dst " \n\t"\
- "2: \n\t"
-
-
-//IDCT( src0, src4, src1, src5, dst, rounder, shift)
-ROW_IDCT( (%0), 8(%0), 16(%0), 24(%0), 0(%1),paddd 8(%2), 11)
-/*ROW_IDCT( 32(%0), 40(%0), 48(%0), 56(%0), 32(%1), paddd (%2), 11)
-ROW_IDCT( 64(%0), 72(%0), 80(%0), 88(%0), 64(%1), paddd (%2), 11)
-ROW_IDCT( 96(%0),104(%0),112(%0),120(%0), 96(%1), paddd (%2), 11)*/
-
-DC_COND_ROW_IDCT( 32(%0), 40(%0), 48(%0), 56(%0), 32(%1),paddd (%2), 11)
-DC_COND_ROW_IDCT( 64(%0), 72(%0), 80(%0), 88(%0), 64(%1),paddd (%2), 11)
-DC_COND_ROW_IDCT( 96(%0),104(%0),112(%0),120(%0), 96(%1),paddd (%2), 11)
-
-
-//IDCT( src0, src4, src1, src5, dst, shift)
-COL_IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
-COL_IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20)
-COL_IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
-COL_IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
-
-#else
-
-#define DC_COND_IDCT(src0, src4, src1, src5, dst, rounder, shift) \
- "movq " #src0 ", %%mm0 \n\t" /* R4 R0 r4 r0 */\
- "movq " #src4 ", %%mm1 \n\t" /* R6 R2 r6 r2 */\
- "movq " #src1 ", %%mm2 \n\t" /* R3 R1 r3 r1 */\
- "movq " #src5 ", %%mm3 \n\t" /* R7 R5 r7 r5 */\
- "movq "MANGLE(wm1010)", %%mm4 \n\t"\
- "pand %%mm0, %%mm4 \n\t"\
- "por %%mm1, %%mm4 \n\t"\
- "por %%mm2, %%mm4 \n\t"\
- "por %%mm3, %%mm4 \n\t"\
- "packssdw %%mm4,%%mm4 \n\t"\
- "movd %%mm4, %%eax \n\t"\
- "orl %%eax, %%eax \n\t"\
- "jz 1f \n\t"\
- "movq 16(%2), %%mm4 \n\t" /* C4 C4 C4 C4 */\
- "pmaddwd %%mm0, %%mm4 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "movq 24(%2), %%mm5 \n\t" /* -C4 C4 -C4 C4 */\
- "pmaddwd %%mm5, %%mm0 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\
- "movq 32(%2), %%mm5 \n\t" /* C6 C2 C6 C2 */\
- "pmaddwd %%mm1, %%mm5 \n\t" /* C6R6+C2R2 C6r6+C2r2 */\
- "movq 40(%2), %%mm6 \n\t" /* -C2 C6 -C2 C6 */\
- "pmaddwd %%mm6, %%mm1 \n\t" /* -C2R6+C6R2 -C2r6+C6r2 */\
- "movq 48(%2), %%mm7 \n\t" /* C3 C1 C3 C1 */\
- "pmaddwd %%mm2, %%mm7 \n\t" /* C3R3+C1R1 C3r3+C1r1 */\
- #rounder ", %%mm4 \n\t"\
- "movq %%mm4, %%mm6 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "paddd %%mm5, %%mm4 \n\t" /* A0 a0 */\
- "psubd %%mm5, %%mm6 \n\t" /* A3 a3 */\
- "movq 56(%2), %%mm5 \n\t" /* C7 C5 C7 C5 */\
- "pmaddwd %%mm3, %%mm5 \n\t" /* C7R7+C5R5 C7r7+C5r5 */\
- #rounder ", %%mm0 \n\t"\
- "paddd %%mm0, %%mm1 \n\t" /* A1 a1 */\
- "paddd %%mm0, %%mm0 \n\t" \
- "psubd %%mm1, %%mm0 \n\t" /* A2 a2 */\
- "pmaddwd 64(%2), %%mm2 \n\t" /* -C7R3+C3R1 -C7r3+C3r1 */\
- "paddd %%mm5, %%mm7 \n\t" /* B0 b0 */\
- "movq 72(%2), %%mm5 \n\t" /* -C5 -C1 -C5 -C1 */\
- "pmaddwd %%mm3, %%mm5 \n\t" /* -C5R7-C1R5 -C5r7-C1r5 */\
- "paddd %%mm4, %%mm7 \n\t" /* A0+B0 a0+b0 */\
- "paddd %%mm4, %%mm4 \n\t" /* 2A0 2a0 */\
- "psubd %%mm7, %%mm4 \n\t" /* A0-B0 a0-b0 */\
- "paddd %%mm2, %%mm5 \n\t" /* B1 b1 */\
- "psrad $" #shift ", %%mm7 \n\t"\
- "psrad $" #shift ", %%mm4 \n\t"\
- "movq %%mm1, %%mm2 \n\t" /* A1 a1 */\
- "paddd %%mm5, %%mm1 \n\t" /* A1+B1 a1+b1 */\
- "psubd %%mm5, %%mm2 \n\t" /* A1-B1 a1-b1 */\
- "psrad $" #shift ", %%mm1 \n\t"\
- "psrad $" #shift ", %%mm2 \n\t"\
- "packssdw %%mm1, %%mm7 \n\t" /* A1+B1 a1+b1 A0+B0 a0+b0 */\
- "packssdw %%mm4, %%mm2 \n\t" /* A0-B0 a0-b0 A1-B1 a1-b1 */\
- "movq %%mm7, " #dst " \n\t"\
- "movq " #src1 ", %%mm1 \n\t" /* R3 R1 r3 r1 */\
- "movq 80(%2), %%mm4 \n\t" /* -C1 C5 -C1 C5 */\
- "movq %%mm2, 24+" #dst " \n\t"\
- "pmaddwd %%mm1, %%mm4 \n\t" /* -C1R3+C5R1 -C1r3+C5r1 */\
- "movq 88(%2), %%mm7 \n\t" /* C3 C7 C3 C7 */\
- "pmaddwd 96(%2), %%mm1 \n\t" /* -C5R3+C7R1 -C5r3+C7r1 */\
- "pmaddwd %%mm3, %%mm7 \n\t" /* C3R7+C7R5 C3r7+C7r5 */\
- "movq %%mm0, %%mm2 \n\t" /* A2 a2 */\
- "pmaddwd 104(%2), %%mm3 \n\t" /* -C1R7+C3R5 -C1r7+C3r5 */\
- "paddd %%mm7, %%mm4 \n\t" /* B2 b2 */\
- "paddd %%mm4, %%mm2 \n\t" /* A2+B2 a2+b2 */\
- "psubd %%mm4, %%mm0 \n\t" /* a2-B2 a2-b2 */\
- "psrad $" #shift ", %%mm2 \n\t"\
- "psrad $" #shift ", %%mm0 \n\t"\
- "movq %%mm6, %%mm4 \n\t" /* A3 a3 */\
- "paddd %%mm1, %%mm3 \n\t" /* B3 b3 */\
- "paddd %%mm3, %%mm6 \n\t" /* A3+B3 a3+b3 */\
- "psubd %%mm3, %%mm4 \n\t" /* a3-B3 a3-b3 */\
- "psrad $" #shift ", %%mm6 \n\t"\
- "packssdw %%mm6, %%mm2 \n\t" /* A3+B3 a3+b3 A2+B2 a2+b2 */\
- "movq %%mm2, 8+" #dst " \n\t"\
- "psrad $" #shift ", %%mm4 \n\t"\
- "packssdw %%mm0, %%mm4 \n\t" /* A2-B2 a2-b2 A3-B3 a3-b3 */\
- "movq %%mm4, 16+" #dst " \n\t"\
- "jmp 2f \n\t"\
- "1: \n\t"\
- "pslld $16, %%mm0 \n\t"\
- "paddd "MANGLE(d40000)", %%mm0 \n\t"\
- "psrad $13, %%mm0 \n\t"\
- "packssdw %%mm0, %%mm0 \n\t"\
- "movq %%mm0, " #dst " \n\t"\
- "movq %%mm0, 8+" #dst " \n\t"\
- "movq %%mm0, 16+" #dst " \n\t"\
- "movq %%mm0, 24+" #dst " \n\t"\
- "2: \n\t"
-
-#define Z_COND_IDCT(src0, src4, src1, src5, dst, rounder, shift, bt) \
- "movq " #src0 ", %%mm0 \n\t" /* R4 R0 r4 r0 */\
- "movq " #src4 ", %%mm1 \n\t" /* R6 R2 r6 r2 */\
- "movq " #src1 ", %%mm2 \n\t" /* R3 R1 r3 r1 */\
- "movq " #src5 ", %%mm3 \n\t" /* R7 R5 r7 r5 */\
- "movq %%mm0, %%mm4 \n\t"\
- "por %%mm1, %%mm4 \n\t"\
- "por %%mm2, %%mm4 \n\t"\
- "por %%mm3, %%mm4 \n\t"\
- "packssdw %%mm4,%%mm4 \n\t"\
- "movd %%mm4, %%eax \n\t"\
- "orl %%eax, %%eax \n\t"\
- "jz " #bt " \n\t"\
- "movq 16(%2), %%mm4 \n\t" /* C4 C4 C4 C4 */\
- "pmaddwd %%mm0, %%mm4 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "movq 24(%2), %%mm5 \n\t" /* -C4 C4 -C4 C4 */\
- "pmaddwd %%mm5, %%mm0 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\
- "movq 32(%2), %%mm5 \n\t" /* C6 C2 C6 C2 */\
- "pmaddwd %%mm1, %%mm5 \n\t" /* C6R6+C2R2 C6r6+C2r2 */\
- "movq 40(%2), %%mm6 \n\t" /* -C2 C6 -C2 C6 */\
- "pmaddwd %%mm6, %%mm1 \n\t" /* -C2R6+C6R2 -C2r6+C6r2 */\
- "movq 48(%2), %%mm7 \n\t" /* C3 C1 C3 C1 */\
- "pmaddwd %%mm2, %%mm7 \n\t" /* C3R3+C1R1 C3r3+C1r1 */\
- #rounder ", %%mm4 \n\t"\
- "movq %%mm4, %%mm6 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "paddd %%mm5, %%mm4 \n\t" /* A0 a0 */\
- "psubd %%mm5, %%mm6 \n\t" /* A3 a3 */\
- "movq 56(%2), %%mm5 \n\t" /* C7 C5 C7 C5 */\
- "pmaddwd %%mm3, %%mm5 \n\t" /* C7R7+C5R5 C7r7+C5r5 */\
- #rounder ", %%mm0 \n\t"\
- "paddd %%mm0, %%mm1 \n\t" /* A1 a1 */\
- "paddd %%mm0, %%mm0 \n\t" \
- "psubd %%mm1, %%mm0 \n\t" /* A2 a2 */\
- "pmaddwd 64(%2), %%mm2 \n\t" /* -C7R3+C3R1 -C7r3+C3r1 */\
- "paddd %%mm5, %%mm7 \n\t" /* B0 b0 */\
- "movq 72(%2), %%mm5 \n\t" /* -C5 -C1 -C5 -C1 */\
- "pmaddwd %%mm3, %%mm5 \n\t" /* -C5R7-C1R5 -C5r7-C1r5 */\
- "paddd %%mm4, %%mm7 \n\t" /* A0+B0 a0+b0 */\
- "paddd %%mm4, %%mm4 \n\t" /* 2A0 2a0 */\
- "psubd %%mm7, %%mm4 \n\t" /* A0-B0 a0-b0 */\
- "paddd %%mm2, %%mm5 \n\t" /* B1 b1 */\
- "psrad $" #shift ", %%mm7 \n\t"\
- "psrad $" #shift ", %%mm4 \n\t"\
- "movq %%mm1, %%mm2 \n\t" /* A1 a1 */\
- "paddd %%mm5, %%mm1 \n\t" /* A1+B1 a1+b1 */\
- "psubd %%mm5, %%mm2 \n\t" /* A1-B1 a1-b1 */\
- "psrad $" #shift ", %%mm1 \n\t"\
- "psrad $" #shift ", %%mm2 \n\t"\
- "packssdw %%mm1, %%mm7 \n\t" /* A1+B1 a1+b1 A0+B0 a0+b0 */\
- "packssdw %%mm4, %%mm2 \n\t" /* A0-B0 a0-b0 A1-B1 a1-b1 */\
- "movq %%mm7, " #dst " \n\t"\
- "movq " #src1 ", %%mm1 \n\t" /* R3 R1 r3 r1 */\
- "movq 80(%2), %%mm4 \n\t" /* -C1 C5 -C1 C5 */\
- "movq %%mm2, 24+" #dst " \n\t"\
- "pmaddwd %%mm1, %%mm4 \n\t" /* -C1R3+C5R1 -C1r3+C5r1 */\
- "movq 88(%2), %%mm7 \n\t" /* C3 C7 C3 C7 */\
- "pmaddwd 96(%2), %%mm1 \n\t" /* -C5R3+C7R1 -C5r3+C7r1 */\
- "pmaddwd %%mm3, %%mm7 \n\t" /* C3R7+C7R5 C3r7+C7r5 */\
- "movq %%mm0, %%mm2 \n\t" /* A2 a2 */\
- "pmaddwd 104(%2), %%mm3 \n\t" /* -C1R7+C3R5 -C1r7+C3r5 */\
- "paddd %%mm7, %%mm4 \n\t" /* B2 b2 */\
- "paddd %%mm4, %%mm2 \n\t" /* A2+B2 a2+b2 */\
- "psubd %%mm4, %%mm0 \n\t" /* a2-B2 a2-b2 */\
- "psrad $" #shift ", %%mm2 \n\t"\
- "psrad $" #shift ", %%mm0 \n\t"\
- "movq %%mm6, %%mm4 \n\t" /* A3 a3 */\
- "paddd %%mm1, %%mm3 \n\t" /* B3 b3 */\
- "paddd %%mm3, %%mm6 \n\t" /* A3+B3 a3+b3 */\
- "psubd %%mm3, %%mm4 \n\t" /* a3-B3 a3-b3 */\
- "psrad $" #shift ", %%mm6 \n\t"\
- "packssdw %%mm6, %%mm2 \n\t" /* A3+B3 a3+b3 A2+B2 a2+b2 */\
- "movq %%mm2, 8+" #dst " \n\t"\
- "psrad $" #shift ", %%mm4 \n\t"\
- "packssdw %%mm0, %%mm4 \n\t" /* A2-B2 a2-b2 A3-B3 a3-b3 */\
- "movq %%mm4, 16+" #dst " \n\t"\
-
-#define ROW_IDCT(src0, src4, src1, src5, dst, rounder, shift) \
- "movq " #src0 ", %%mm0 \n\t" /* R4 R0 r4 r0 */\
- "movq " #src4 ", %%mm1 \n\t" /* R6 R2 r6 r2 */\
- "movq " #src1 ", %%mm2 \n\t" /* R3 R1 r3 r1 */\
- "movq " #src5 ", %%mm3 \n\t" /* R7 R5 r7 r5 */\
- "movq 16(%2), %%mm4 \n\t" /* C4 C4 C4 C4 */\
- "pmaddwd %%mm0, %%mm4 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "movq 24(%2), %%mm5 \n\t" /* -C4 C4 -C4 C4 */\
- "pmaddwd %%mm5, %%mm0 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\
- "movq 32(%2), %%mm5 \n\t" /* C6 C2 C6 C2 */\
- "pmaddwd %%mm1, %%mm5 \n\t" /* C6R6+C2R2 C6r6+C2r2 */\
- "movq 40(%2), %%mm6 \n\t" /* -C2 C6 -C2 C6 */\
- "pmaddwd %%mm6, %%mm1 \n\t" /* -C2R6+C6R2 -C2r6+C6r2 */\
- "movq 48(%2), %%mm7 \n\t" /* C3 C1 C3 C1 */\
- "pmaddwd %%mm2, %%mm7 \n\t" /* C3R3+C1R1 C3r3+C1r1 */\
- #rounder ", %%mm4 \n\t"\
- "movq %%mm4, %%mm6 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "paddd %%mm5, %%mm4 \n\t" /* A0 a0 */\
- "psubd %%mm5, %%mm6 \n\t" /* A3 a3 */\
- "movq 56(%2), %%mm5 \n\t" /* C7 C5 C7 C5 */\
- "pmaddwd %%mm3, %%mm5 \n\t" /* C7R7+C5R5 C7r7+C5r5 */\
- #rounder ", %%mm0 \n\t"\
- "paddd %%mm0, %%mm1 \n\t" /* A1 a1 */\
- "paddd %%mm0, %%mm0 \n\t" \
- "psubd %%mm1, %%mm0 \n\t" /* A2 a2 */\
- "pmaddwd 64(%2), %%mm2 \n\t" /* -C7R3+C3R1 -C7r3+C3r1 */\
- "paddd %%mm5, %%mm7 \n\t" /* B0 b0 */\
- "movq 72(%2), %%mm5 \n\t" /* -C5 -C1 -C5 -C1 */\
- "pmaddwd %%mm3, %%mm5 \n\t" /* -C5R7-C1R5 -C5r7-C1r5 */\
- "paddd %%mm4, %%mm7 \n\t" /* A0+B0 a0+b0 */\
- "paddd %%mm4, %%mm4 \n\t" /* 2A0 2a0 */\
- "psubd %%mm7, %%mm4 \n\t" /* A0-B0 a0-b0 */\
- "paddd %%mm2, %%mm5 \n\t" /* B1 b1 */\
- "psrad $" #shift ", %%mm7 \n\t"\
- "psrad $" #shift ", %%mm4 \n\t"\
- "movq %%mm1, %%mm2 \n\t" /* A1 a1 */\
- "paddd %%mm5, %%mm1 \n\t" /* A1+B1 a1+b1 */\
- "psubd %%mm5, %%mm2 \n\t" /* A1-B1 a1-b1 */\
- "psrad $" #shift ", %%mm1 \n\t"\
- "psrad $" #shift ", %%mm2 \n\t"\
- "packssdw %%mm1, %%mm7 \n\t" /* A1+B1 a1+b1 A0+B0 a0+b0 */\
- "packssdw %%mm4, %%mm2 \n\t" /* A0-B0 a0-b0 A1-B1 a1-b1 */\
- "movq %%mm7, " #dst " \n\t"\
- "movq " #src1 ", %%mm1 \n\t" /* R3 R1 r3 r1 */\
- "movq 80(%2), %%mm4 \n\t" /* -C1 C5 -C1 C5 */\
- "movq %%mm2, 24+" #dst " \n\t"\
- "pmaddwd %%mm1, %%mm4 \n\t" /* -C1R3+C5R1 -C1r3+C5r1 */\
- "movq 88(%2), %%mm7 \n\t" /* C3 C7 C3 C7 */\
- "pmaddwd 96(%2), %%mm1 \n\t" /* -C5R3+C7R1 -C5r3+C7r1 */\
- "pmaddwd %%mm3, %%mm7 \n\t" /* C3R7+C7R5 C3r7+C7r5 */\
- "movq %%mm0, %%mm2 \n\t" /* A2 a2 */\
- "pmaddwd 104(%2), %%mm3 \n\t" /* -C1R7+C3R5 -C1r7+C3r5 */\
- "paddd %%mm7, %%mm4 \n\t" /* B2 b2 */\
- "paddd %%mm4, %%mm2 \n\t" /* A2+B2 a2+b2 */\
- "psubd %%mm4, %%mm0 \n\t" /* a2-B2 a2-b2 */\
- "psrad $" #shift ", %%mm2 \n\t"\
- "psrad $" #shift ", %%mm0 \n\t"\
- "movq %%mm6, %%mm4 \n\t" /* A3 a3 */\
- "paddd %%mm1, %%mm3 \n\t" /* B3 b3 */\
- "paddd %%mm3, %%mm6 \n\t" /* A3+B3 a3+b3 */\
- "psubd %%mm3, %%mm4 \n\t" /* a3-B3 a3-b3 */\
- "psrad $" #shift ", %%mm6 \n\t"\
- "packssdw %%mm6, %%mm2 \n\t" /* A3+B3 a3+b3 A2+B2 a2+b2 */\
- "movq %%mm2, 8+" #dst " \n\t"\
- "psrad $" #shift ", %%mm4 \n\t"\
- "packssdw %%mm0, %%mm4 \n\t" /* A2-B2 a2-b2 A3-B3 a3-b3 */\
- "movq %%mm4, 16+" #dst " \n\t"\
-
-//IDCT( src0, src4, src1, src5, dst, rounder, shift)
-DC_COND_IDCT( 0(%0), 8(%0), 16(%0), 24(%0), 0(%1),paddd 8(%2), 11)
-Z_COND_IDCT( 32(%0), 40(%0), 48(%0), 56(%0), 32(%1),paddd (%2), 11, 4f)
-Z_COND_IDCT( 64(%0), 72(%0), 80(%0), 88(%0), 64(%1),paddd (%2), 11, 2f)
-Z_COND_IDCT( 96(%0),104(%0),112(%0),120(%0), 96(%1),paddd (%2), 11, 1f)
-
-#undef IDCT
-#define IDCT(src0, src4, src1, src5, dst, shift) \
- "movq " #src0 ", %%mm0 \n\t" /* R4 R0 r4 r0 */\
- "movq " #src4 ", %%mm1 \n\t" /* R6 R2 r6 r2 */\
- "movq " #src1 ", %%mm2 \n\t" /* R3 R1 r3 r1 */\
- "movq " #src5 ", %%mm3 \n\t" /* R7 R5 r7 r5 */\
- "movq 16(%2), %%mm4 \n\t" /* C4 C4 C4 C4 */\
- "pmaddwd %%mm0, %%mm4 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "movq 24(%2), %%mm5 \n\t" /* -C4 C4 -C4 C4 */\
- "pmaddwd %%mm5, %%mm0 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\
- "movq 32(%2), %%mm5 \n\t" /* C6 C2 C6 C2 */\
- "pmaddwd %%mm1, %%mm5 \n\t" /* C6R6+C2R2 C6r6+C2r2 */\
- "movq 40(%2), %%mm6 \n\t" /* -C2 C6 -C2 C6 */\
- "pmaddwd %%mm6, %%mm1 \n\t" /* -C2R6+C6R2 -C2r6+C6r2 */\
- "movq %%mm4, %%mm6 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "movq 48(%2), %%mm7 \n\t" /* C3 C1 C3 C1 */\
- "pmaddwd %%mm2, %%mm7 \n\t" /* C3R3+C1R1 C3r3+C1r1 */\
- "paddd %%mm5, %%mm4 \n\t" /* A0 a0 */\
- "psubd %%mm5, %%mm6 \n\t" /* A3 a3 */\
- "movq %%mm0, %%mm5 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\
- "paddd %%mm1, %%mm0 \n\t" /* A1 a1 */\
- "psubd %%mm1, %%mm5 \n\t" /* A2 a2 */\
- "movq 56(%2), %%mm1 \n\t" /* C7 C5 C7 C5 */\
- "pmaddwd %%mm3, %%mm1 \n\t" /* C7R7+C5R5 C7r7+C5r5 */\
- "pmaddwd 64(%2), %%mm2 \n\t" /* -C7R3+C3R1 -C7r3+C3r1 */\
- "paddd %%mm1, %%mm7 \n\t" /* B0 b0 */\
- "movq 72(%2), %%mm1 \n\t" /* -C5 -C1 -C5 -C1 */\
- "pmaddwd %%mm3, %%mm1 \n\t" /* -C5R7-C1R5 -C5r7-C1r5 */\
- "paddd %%mm4, %%mm7 \n\t" /* A0+B0 a0+b0 */\
- "paddd %%mm4, %%mm4 \n\t" /* 2A0 2a0 */\
- "psubd %%mm7, %%mm4 \n\t" /* A0-B0 a0-b0 */\
- "paddd %%mm2, %%mm1 \n\t" /* B1 b1 */\
- "psrad $" #shift ", %%mm7 \n\t"\
- "psrad $" #shift ", %%mm4 \n\t"\
- "movq %%mm0, %%mm2 \n\t" /* A1 a1 */\
- "paddd %%mm1, %%mm0 \n\t" /* A1+B1 a1+b1 */\
- "psubd %%mm1, %%mm2 \n\t" /* A1-B1 a1-b1 */\
- "psrad $" #shift ", %%mm0 \n\t"\
- "psrad $" #shift ", %%mm2 \n\t"\
- "packssdw %%mm7, %%mm7 \n\t" /* A0+B0 a0+b0 */\
- "movd %%mm7, " #dst " \n\t"\
- "packssdw %%mm0, %%mm0 \n\t" /* A1+B1 a1+b1 */\
- "movd %%mm0, 16+" #dst " \n\t"\
- "packssdw %%mm2, %%mm2 \n\t" /* A1-B1 a1-b1 */\
- "movd %%mm2, 96+" #dst " \n\t"\
- "packssdw %%mm4, %%mm4 \n\t" /* A0-B0 a0-b0 */\
- "movd %%mm4, 112+" #dst " \n\t"\
- "movq " #src1 ", %%mm0 \n\t" /* R3 R1 r3 r1 */\
- "movq 80(%2), %%mm4 \n\t" /* -C1 C5 -C1 C5 */\
- "pmaddwd %%mm0, %%mm4 \n\t" /* -C1R3+C5R1 -C1r3+C5r1 */\
- "movq 88(%2), %%mm7 \n\t" /* C3 C7 C3 C7 */\
- "pmaddwd 96(%2), %%mm0 \n\t" /* -C5R3+C7R1 -C5r3+C7r1 */\
- "pmaddwd %%mm3, %%mm7 \n\t" /* C3R7+C7R5 C3r7+C7r5 */\
- "movq %%mm5, %%mm2 \n\t" /* A2 a2 */\
- "pmaddwd 104(%2), %%mm3 \n\t" /* -C1R7+C3R5 -C1r7+C3r5 */\
- "paddd %%mm7, %%mm4 \n\t" /* B2 b2 */\
- "paddd %%mm4, %%mm2 \n\t" /* A2+B2 a2+b2 */\
- "psubd %%mm4, %%mm5 \n\t" /* a2-B2 a2-b2 */\
- "psrad $" #shift ", %%mm2 \n\t"\
- "psrad $" #shift ", %%mm5 \n\t"\
- "movq %%mm6, %%mm4 \n\t" /* A3 a3 */\
- "paddd %%mm0, %%mm3 \n\t" /* B3 b3 */\
- "paddd %%mm3, %%mm6 \n\t" /* A3+B3 a3+b3 */\
- "psubd %%mm3, %%mm4 \n\t" /* a3-B3 a3-b3 */\
- "psrad $" #shift ", %%mm6 \n\t"\
- "psrad $" #shift ", %%mm4 \n\t"\
- "packssdw %%mm2, %%mm2 \n\t" /* A2+B2 a2+b2 */\
- "packssdw %%mm6, %%mm6 \n\t" /* A3+B3 a3+b3 */\
- "movd %%mm2, 32+" #dst " \n\t"\
- "packssdw %%mm4, %%mm4 \n\t" /* A3-B3 a3-b3 */\
- "packssdw %%mm5, %%mm5 \n\t" /* A2-B2 a2-b2 */\
- "movd %%mm6, 48+" #dst " \n\t"\
- "movd %%mm4, 64+" #dst " \n\t"\
- "movd %%mm5, 80+" #dst " \n\t"
-
-
-//IDCT( src0, src4, src1, src5, dst, shift)
-IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
-IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20)
-IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
-IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
- "jmp 9f \n\t"
-
- "# .p2align 4 \n\t"\
- "4: \n\t"
-Z_COND_IDCT( 64(%0), 72(%0), 80(%0), 88(%0), 64(%1),paddd (%2), 11, 6f)
-Z_COND_IDCT( 96(%0),104(%0),112(%0),120(%0), 96(%1),paddd (%2), 11, 5f)
-
-#undef IDCT
-#define IDCT(src0, src4, src1, src5, dst, shift) \
- "movq " #src0 ", %%mm0 \n\t" /* R4 R0 r4 r0 */\
- "movq " #src4 ", %%mm1 \n\t" /* R6 R2 r6 r2 */\
- "movq " #src5 ", %%mm3 \n\t" /* R7 R5 r7 r5 */\
- "movq 16(%2), %%mm4 \n\t" /* C4 C4 C4 C4 */\
- "pmaddwd %%mm0, %%mm4 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "movq 24(%2), %%mm5 \n\t" /* -C4 C4 -C4 C4 */\
- "pmaddwd %%mm5, %%mm0 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\
- "movq 32(%2), %%mm5 \n\t" /* C6 C2 C6 C2 */\
- "pmaddwd %%mm1, %%mm5 \n\t" /* C6R6+C2R2 C6r6+C2r2 */\
- "movq 40(%2), %%mm6 \n\t" /* -C2 C6 -C2 C6 */\
- "pmaddwd %%mm6, %%mm1 \n\t" /* -C2R6+C6R2 -C2r6+C6r2 */\
- "movq %%mm4, %%mm6 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "paddd %%mm5, %%mm4 \n\t" /* A0 a0 */\
- "psubd %%mm5, %%mm6 \n\t" /* A3 a3 */\
- "movq %%mm0, %%mm5 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\
- "paddd %%mm1, %%mm0 \n\t" /* A1 a1 */\
- "psubd %%mm1, %%mm5 \n\t" /* A2 a2 */\
- "movq 56(%2), %%mm1 \n\t" /* C7 C5 C7 C5 */\
- "pmaddwd %%mm3, %%mm1 \n\t" /* C7R7+C5R5 C7r7+C5r5 */\
- "movq 72(%2), %%mm7 \n\t" /* -C5 -C1 -C5 -C1 */\
- "pmaddwd %%mm3, %%mm7 \n\t" /* -C5R7-C1R5 -C5r7-C1r5 */\
- "paddd %%mm4, %%mm1 \n\t" /* A0+B0 a0+b0 */\
- "paddd %%mm4, %%mm4 \n\t" /* 2A0 2a0 */\
- "psubd %%mm1, %%mm4 \n\t" /* A0-B0 a0-b0 */\
- "psrad $" #shift ", %%mm1 \n\t"\
- "psrad $" #shift ", %%mm4 \n\t"\
- "movq %%mm0, %%mm2 \n\t" /* A1 a1 */\
- "paddd %%mm7, %%mm0 \n\t" /* A1+B1 a1+b1 */\
- "psubd %%mm7, %%mm2 \n\t" /* A1-B1 a1-b1 */\
- "psrad $" #shift ", %%mm0 \n\t"\
- "psrad $" #shift ", %%mm2 \n\t"\
- "packssdw %%mm1, %%mm1 \n\t" /* A0+B0 a0+b0 */\
- "movd %%mm1, " #dst " \n\t"\
- "packssdw %%mm0, %%mm0 \n\t" /* A1+B1 a1+b1 */\
- "movd %%mm0, 16+" #dst " \n\t"\
- "packssdw %%mm2, %%mm2 \n\t" /* A1-B1 a1-b1 */\
- "movd %%mm2, 96+" #dst " \n\t"\
- "packssdw %%mm4, %%mm4 \n\t" /* A0-B0 a0-b0 */\
- "movd %%mm4, 112+" #dst " \n\t"\
- "movq 88(%2), %%mm1 \n\t" /* C3 C7 C3 C7 */\
- "pmaddwd %%mm3, %%mm1 \n\t" /* C3R7+C7R5 C3r7+C7r5 */\
- "movq %%mm5, %%mm2 \n\t" /* A2 a2 */\
- "pmaddwd 104(%2), %%mm3 \n\t" /* -C1R7+C3R5 -C1r7+C3r5 */\
- "paddd %%mm1, %%mm2 \n\t" /* A2+B2 a2+b2 */\
- "psubd %%mm1, %%mm5 \n\t" /* a2-B2 a2-b2 */\
- "psrad $" #shift ", %%mm2 \n\t"\
- "psrad $" #shift ", %%mm5 \n\t"\
- "movq %%mm6, %%mm1 \n\t" /* A3 a3 */\
- "paddd %%mm3, %%mm6 \n\t" /* A3+B3 a3+b3 */\
- "psubd %%mm3, %%mm1 \n\t" /* a3-B3 a3-b3 */\
- "psrad $" #shift ", %%mm6 \n\t"\
- "psrad $" #shift ", %%mm1 \n\t"\
- "packssdw %%mm2, %%mm2 \n\t" /* A2+B2 a2+b2 */\
- "packssdw %%mm6, %%mm6 \n\t" /* A3+B3 a3+b3 */\
- "movd %%mm2, 32+" #dst " \n\t"\
- "packssdw %%mm1, %%mm1 \n\t" /* A3-B3 a3-b3 */\
- "packssdw %%mm5, %%mm5 \n\t" /* A2-B2 a2-b2 */\
- "movd %%mm6, 48+" #dst " \n\t"\
- "movd %%mm1, 64+" #dst " \n\t"\
- "movd %%mm5, 80+" #dst " \n\t"
-
-//IDCT( src0, src4, src1, src5, dst, shift)
-IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
-IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20)
-IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
-IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
- "jmp 9f \n\t"
-
- "# .p2align 4 \n\t"\
- "6: \n\t"
-Z_COND_IDCT( 96(%0),104(%0),112(%0),120(%0), 96(%1),paddd (%2), 11, 7f)
-
-#undef IDCT
-#define IDCT(src0, src4, src1, src5, dst, shift) \
- "movq " #src0 ", %%mm0 \n\t" /* R4 R0 r4 r0 */\
- "movq " #src5 ", %%mm3 \n\t" /* R7 R5 r7 r5 */\
- "movq 16(%2), %%mm4 \n\t" /* C4 C4 C4 C4 */\
- "pmaddwd %%mm0, %%mm4 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "movq 24(%2), %%mm5 \n\t" /* -C4 C4 -C4 C4 */\
- "pmaddwd %%mm5, %%mm0 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\
- "movq %%mm4, %%mm6 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "movq %%mm0, %%mm5 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\
- "movq 56(%2), %%mm1 \n\t" /* C7 C5 C7 C5 */\
- "pmaddwd %%mm3, %%mm1 \n\t" /* C7R7+C5R5 C7r7+C5r5 */\
- "movq 72(%2), %%mm7 \n\t" /* -C5 -C1 -C5 -C1 */\
- "pmaddwd %%mm3, %%mm7 \n\t" /* -C5R7-C1R5 -C5r7-C1r5 */\
- "paddd %%mm4, %%mm1 \n\t" /* A0+B0 a0+b0 */\
- "paddd %%mm4, %%mm4 \n\t" /* 2A0 2a0 */\
- "psubd %%mm1, %%mm4 \n\t" /* A0-B0 a0-b0 */\
- "psrad $" #shift ", %%mm1 \n\t"\
- "psrad $" #shift ", %%mm4 \n\t"\
- "movq %%mm0, %%mm2 \n\t" /* A1 a1 */\
- "paddd %%mm7, %%mm0 \n\t" /* A1+B1 a1+b1 */\
- "psubd %%mm7, %%mm2 \n\t" /* A1-B1 a1-b1 */\
- "psrad $" #shift ", %%mm0 \n\t"\
- "psrad $" #shift ", %%mm2 \n\t"\
- "packssdw %%mm1, %%mm1 \n\t" /* A0+B0 a0+b0 */\
- "movd %%mm1, " #dst " \n\t"\
- "packssdw %%mm0, %%mm0 \n\t" /* A1+B1 a1+b1 */\
- "movd %%mm0, 16+" #dst " \n\t"\
- "packssdw %%mm2, %%mm2 \n\t" /* A1-B1 a1-b1 */\
- "movd %%mm2, 96+" #dst " \n\t"\
- "packssdw %%mm4, %%mm4 \n\t" /* A0-B0 a0-b0 */\
- "movd %%mm4, 112+" #dst " \n\t"\
- "movq 88(%2), %%mm1 \n\t" /* C3 C7 C3 C7 */\
- "pmaddwd %%mm3, %%mm1 \n\t" /* C3R7+C7R5 C3r7+C7r5 */\
- "movq %%mm5, %%mm2 \n\t" /* A2 a2 */\
- "pmaddwd 104(%2), %%mm3 \n\t" /* -C1R7+C3R5 -C1r7+C3r5 */\
- "paddd %%mm1, %%mm2 \n\t" /* A2+B2 a2+b2 */\
- "psubd %%mm1, %%mm5 \n\t" /* a2-B2 a2-b2 */\
- "psrad $" #shift ", %%mm2 \n\t"\
- "psrad $" #shift ", %%mm5 \n\t"\
- "movq %%mm6, %%mm1 \n\t" /* A3 a3 */\
- "paddd %%mm3, %%mm6 \n\t" /* A3+B3 a3+b3 */\
- "psubd %%mm3, %%mm1 \n\t" /* a3-B3 a3-b3 */\
- "psrad $" #shift ", %%mm6 \n\t"\
- "psrad $" #shift ", %%mm1 \n\t"\
- "packssdw %%mm2, %%mm2 \n\t" /* A2+B2 a2+b2 */\
- "packssdw %%mm6, %%mm6 \n\t" /* A3+B3 a3+b3 */\
- "movd %%mm2, 32+" #dst " \n\t"\
- "packssdw %%mm1, %%mm1 \n\t" /* A3-B3 a3-b3 */\
- "packssdw %%mm5, %%mm5 \n\t" /* A2-B2 a2-b2 */\
- "movd %%mm6, 48+" #dst " \n\t"\
- "movd %%mm1, 64+" #dst " \n\t"\
- "movd %%mm5, 80+" #dst " \n\t"
-
-
-//IDCT( src0, src4, src1, src5, dst, shift)
-IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
-IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20)
-IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
-IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
- "jmp 9f \n\t"
-
- "# .p2align 4 \n\t"\
- "2: \n\t"
-Z_COND_IDCT( 96(%0),104(%0),112(%0),120(%0), 96(%1),paddd (%2), 11, 3f)
-
-#undef IDCT
-#define IDCT(src0, src4, src1, src5, dst, shift) \
- "movq " #src0 ", %%mm0 \n\t" /* R4 R0 r4 r0 */\
- "movq " #src1 ", %%mm2 \n\t" /* R3 R1 r3 r1 */\
- "movq " #src5 ", %%mm3 \n\t" /* R7 R5 r7 r5 */\
- "movq 16(%2), %%mm4 \n\t" /* C4 C4 C4 C4 */\
- "pmaddwd %%mm0, %%mm4 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "movq 24(%2), %%mm5 \n\t" /* -C4 C4 -C4 C4 */\
- "pmaddwd %%mm5, %%mm0 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\
- "movq %%mm4, %%mm6 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "movq 48(%2), %%mm7 \n\t" /* C3 C1 C3 C1 */\
- "pmaddwd %%mm2, %%mm7 \n\t" /* C3R3+C1R1 C3r3+C1r1 */\
- "movq %%mm0, %%mm5 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\
- "movq 56(%2), %%mm1 \n\t" /* C7 C5 C7 C5 */\
- "pmaddwd %%mm3, %%mm1 \n\t" /* C7R7+C5R5 C7r7+C5r5 */\
- "pmaddwd 64(%2), %%mm2 \n\t" /* -C7R3+C3R1 -C7r3+C3r1 */\
- "paddd %%mm1, %%mm7 \n\t" /* B0 b0 */\
- "movq 72(%2), %%mm1 \n\t" /* -C5 -C1 -C5 -C1 */\
- "pmaddwd %%mm3, %%mm1 \n\t" /* -C5R7-C1R5 -C5r7-C1r5 */\
- "paddd %%mm4, %%mm7 \n\t" /* A0+B0 a0+b0 */\
- "paddd %%mm4, %%mm4 \n\t" /* 2A0 2a0 */\
- "psubd %%mm7, %%mm4 \n\t" /* A0-B0 a0-b0 */\
- "paddd %%mm2, %%mm1 \n\t" /* B1 b1 */\
- "psrad $" #shift ", %%mm7 \n\t"\
- "psrad $" #shift ", %%mm4 \n\t"\
- "movq %%mm0, %%mm2 \n\t" /* A1 a1 */\
- "paddd %%mm1, %%mm0 \n\t" /* A1+B1 a1+b1 */\
- "psubd %%mm1, %%mm2 \n\t" /* A1-B1 a1-b1 */\
- "psrad $" #shift ", %%mm0 \n\t"\
- "psrad $" #shift ", %%mm2 \n\t"\
- "packssdw %%mm7, %%mm7 \n\t" /* A0+B0 a0+b0 */\
- "movd %%mm7, " #dst " \n\t"\
- "packssdw %%mm0, %%mm0 \n\t" /* A1+B1 a1+b1 */\
- "movd %%mm0, 16+" #dst " \n\t"\
- "packssdw %%mm2, %%mm2 \n\t" /* A1-B1 a1-b1 */\
- "movd %%mm2, 96+" #dst " \n\t"\
- "packssdw %%mm4, %%mm4 \n\t" /* A0-B0 a0-b0 */\
- "movd %%mm4, 112+" #dst " \n\t"\
- "movq " #src1 ", %%mm0 \n\t" /* R3 R1 r3 r1 */\
- "movq 80(%2), %%mm4 \n\t" /* -C1 C5 -C1 C5 */\
- "pmaddwd %%mm0, %%mm4 \n\t" /* -C1R3+C5R1 -C1r3+C5r1 */\
- "movq 88(%2), %%mm7 \n\t" /* C3 C7 C3 C7 */\
- "pmaddwd 96(%2), %%mm0 \n\t" /* -C5R3+C7R1 -C5r3+C7r1 */\
- "pmaddwd %%mm3, %%mm7 \n\t" /* C3R7+C7R5 C3r7+C7r5 */\
- "movq %%mm5, %%mm2 \n\t" /* A2 a2 */\
- "pmaddwd 104(%2), %%mm3 \n\t" /* -C1R7+C3R5 -C1r7+C3r5 */\
- "paddd %%mm7, %%mm4 \n\t" /* B2 b2 */\
- "paddd %%mm4, %%mm2 \n\t" /* A2+B2 a2+b2 */\
- "psubd %%mm4, %%mm5 \n\t" /* a2-B2 a2-b2 */\
- "psrad $" #shift ", %%mm2 \n\t"\
- "psrad $" #shift ", %%mm5 \n\t"\
- "movq %%mm6, %%mm4 \n\t" /* A3 a3 */\
- "paddd %%mm0, %%mm3 \n\t" /* B3 b3 */\
- "paddd %%mm3, %%mm6 \n\t" /* A3+B3 a3+b3 */\
- "psubd %%mm3, %%mm4 \n\t" /* a3-B3 a3-b3 */\
- "psrad $" #shift ", %%mm6 \n\t"\
- "psrad $" #shift ", %%mm4 \n\t"\
- "packssdw %%mm2, %%mm2 \n\t" /* A2+B2 a2+b2 */\
- "packssdw %%mm6, %%mm6 \n\t" /* A3+B3 a3+b3 */\
- "movd %%mm2, 32+" #dst " \n\t"\
- "packssdw %%mm4, %%mm4 \n\t" /* A3-B3 a3-b3 */\
- "packssdw %%mm5, %%mm5 \n\t" /* A2-B2 a2-b2 */\
- "movd %%mm6, 48+" #dst " \n\t"\
- "movd %%mm4, 64+" #dst " \n\t"\
- "movd %%mm5, 80+" #dst " \n\t"
-
-//IDCT( src0, src4, src1, src5, dst, shift)
-IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
-IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20)
-IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
-IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
- "jmp 9f \n\t"
-
- "# .p2align 4 \n\t"\
- "3: \n\t"
-#undef IDCT
-#define IDCT(src0, src4, src1, src5, dst, shift) \
- "movq " #src0 ", %%mm0 \n\t" /* R4 R0 r4 r0 */\
- "movq " #src1 ", %%mm2 \n\t" /* R3 R1 r3 r1 */\
- "movq 16(%2), %%mm4 \n\t" /* C4 C4 C4 C4 */\
- "pmaddwd %%mm0, %%mm4 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "movq 24(%2), %%mm5 \n\t" /* -C4 C4 -C4 C4 */\
- "pmaddwd %%mm5, %%mm0 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\
- "movq %%mm4, %%mm6 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "movq 48(%2), %%mm7 \n\t" /* C3 C1 C3 C1 */\
- "pmaddwd %%mm2, %%mm7 \n\t" /* C3R3+C1R1 C3r3+C1r1 */\
- "movq %%mm0, %%mm5 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\
- "movq 64(%2), %%mm3 \n\t"\
- "pmaddwd %%mm2, %%mm3 \n\t" /* -C7R3+C3R1 -C7r3+C3r1 */\
- "paddd %%mm4, %%mm7 \n\t" /* A0+B0 a0+b0 */\
- "paddd %%mm4, %%mm4 \n\t" /* 2A0 2a0 */\
- "psubd %%mm7, %%mm4 \n\t" /* A0-B0 a0-b0 */\
- "psrad $" #shift ", %%mm7 \n\t"\
- "psrad $" #shift ", %%mm4 \n\t"\
- "movq %%mm0, %%mm1 \n\t" /* A1 a1 */\
- "paddd %%mm3, %%mm0 \n\t" /* A1+B1 a1+b1 */\
- "psubd %%mm3, %%mm1 \n\t" /* A1-B1 a1-b1 */\
- "psrad $" #shift ", %%mm0 \n\t"\
- "psrad $" #shift ", %%mm1 \n\t"\
- "packssdw %%mm7, %%mm7 \n\t" /* A0+B0 a0+b0 */\
- "movd %%mm7, " #dst " \n\t"\
- "packssdw %%mm0, %%mm0 \n\t" /* A1+B1 a1+b1 */\
- "movd %%mm0, 16+" #dst " \n\t"\
- "packssdw %%mm1, %%mm1 \n\t" /* A1-B1 a1-b1 */\
- "movd %%mm1, 96+" #dst " \n\t"\
- "packssdw %%mm4, %%mm4 \n\t" /* A0-B0 a0-b0 */\
- "movd %%mm4, 112+" #dst " \n\t"\
- "movq 80(%2), %%mm4 \n\t" /* -C1 C5 -C1 C5 */\
- "pmaddwd %%mm2, %%mm4 \n\t" /* -C1R3+C5R1 -C1r3+C5r1 */\
- "pmaddwd 96(%2), %%mm2 \n\t" /* -C5R3+C7R1 -C5r3+C7r1 */\
- "movq %%mm5, %%mm1 \n\t" /* A2 a2 */\
- "paddd %%mm4, %%mm1 \n\t" /* A2+B2 a2+b2 */\
- "psubd %%mm4, %%mm5 \n\t" /* a2-B2 a2-b2 */\
- "psrad $" #shift ", %%mm1 \n\t"\
- "psrad $" #shift ", %%mm5 \n\t"\
- "movq %%mm6, %%mm4 \n\t" /* A3 a3 */\
- "paddd %%mm2, %%mm6 \n\t" /* A3+B3 a3+b3 */\
- "psubd %%mm2, %%mm4 \n\t" /* a3-B3 a3-b3 */\
- "psrad $" #shift ", %%mm6 \n\t"\
- "psrad $" #shift ", %%mm4 \n\t"\
- "packssdw %%mm1, %%mm1 \n\t" /* A2+B2 a2+b2 */\
- "packssdw %%mm6, %%mm6 \n\t" /* A3+B3 a3+b3 */\
- "movd %%mm1, 32+" #dst " \n\t"\
- "packssdw %%mm4, %%mm4 \n\t" /* A3-B3 a3-b3 */\
- "packssdw %%mm5, %%mm5 \n\t" /* A2-B2 a2-b2 */\
- "movd %%mm6, 48+" #dst " \n\t"\
- "movd %%mm4, 64+" #dst " \n\t"\
- "movd %%mm5, 80+" #dst " \n\t"
-
-
-//IDCT( src0, src4, src1, src5, dst, shift)
-IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
-IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20)
-IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
-IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
- "jmp 9f \n\t"
-
- "# .p2align 4 \n\t"\
- "5: \n\t"
-#undef IDCT
-#define IDCT(src0, src4, src1, src5, dst, shift) \
- "movq " #src0 ", %%mm0 \n\t" /* R4 R0 r4 r0 */\
- "movq " #src4 ", %%mm1 \n\t" /* R6 R2 r6 r2 */\
- "movq 16(%2), %%mm4 \n\t" /* C4 C4 C4 C4 */\
- "pmaddwd %%mm0, %%mm4 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "movq 24(%2), %%mm5 \n\t" /* -C4 C4 -C4 C4 */\
- "pmaddwd %%mm5, %%mm0 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\
- "movq 32(%2), %%mm5 \n\t" /* C6 C2 C6 C2 */\
- "pmaddwd %%mm1, %%mm5 \n\t" /* C6R6+C2R2 C6r6+C2r2 */\
- "movq 40(%2), %%mm6 \n\t" /* -C2 C6 -C2 C6 */\
- "pmaddwd %%mm6, %%mm1 \n\t" /* -C2R6+C6R2 -C2r6+C6r2 */\
- "movq %%mm4, %%mm6 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "paddd %%mm5, %%mm4 \n\t" /* A0 a0 */\
- "psubd %%mm5, %%mm6 \n\t" /* A3 a3 */\
- "movq %%mm0, %%mm5 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\
- "paddd %%mm1, %%mm0 \n\t" /* A1 a1 */\
- "psubd %%mm1, %%mm5 \n\t" /* A2 a2 */\
- "movq 8+" #src0 ", %%mm2 \n\t" /* R4 R0 r4 r0 */\
- "movq 8+" #src4 ", %%mm3 \n\t" /* R6 R2 r6 r2 */\
- "movq 16(%2), %%mm1 \n\t" /* C4 C4 C4 C4 */\
- "pmaddwd %%mm2, %%mm1 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "movq 24(%2), %%mm7 \n\t" /* -C4 C4 -C4 C4 */\
- "pmaddwd %%mm7, %%mm2 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\
- "movq 32(%2), %%mm7 \n\t" /* C6 C2 C6 C2 */\
- "pmaddwd %%mm3, %%mm7 \n\t" /* C6R6+C2R2 C6r6+C2r2 */\
- "pmaddwd 40(%2), %%mm3 \n\t" /* -C2R6+C6R2 -C2r6+C6r2 */\
- "paddd %%mm1, %%mm7 \n\t" /* A0 a0 */\
- "paddd %%mm1, %%mm1 \n\t" /* 2C0 2c0 */\
- "psubd %%mm7, %%mm1 \n\t" /* A3 a3 */\
- "paddd %%mm2, %%mm3 \n\t" /* A1 a1 */\
- "paddd %%mm2, %%mm2 \n\t" /* 2C1 2c1 */\
- "psubd %%mm3, %%mm2 \n\t" /* A2 a2 */\
- "psrad $" #shift ", %%mm4 \n\t"\
- "psrad $" #shift ", %%mm7 \n\t"\
- "psrad $" #shift ", %%mm3 \n\t"\
- "packssdw %%mm7, %%mm4 \n\t" /* A0 a0 */\
- "movq %%mm4, " #dst " \n\t"\
- "psrad $" #shift ", %%mm0 \n\t"\
- "packssdw %%mm3, %%mm0 \n\t" /* A1 a1 */\
- "movq %%mm0, 16+" #dst " \n\t"\
- "movq %%mm0, 96+" #dst " \n\t"\
- "movq %%mm4, 112+" #dst " \n\t"\
- "psrad $" #shift ", %%mm5 \n\t"\
- "psrad $" #shift ", %%mm6 \n\t"\
- "psrad $" #shift ", %%mm2 \n\t"\
- "packssdw %%mm2, %%mm5 \n\t" /* A2-B2 a2-b2 */\
- "movq %%mm5, 32+" #dst " \n\t"\
- "psrad $" #shift ", %%mm1 \n\t"\
- "packssdw %%mm1, %%mm6 \n\t" /* A3+B3 a3+b3 */\
- "movq %%mm6, 48+" #dst " \n\t"\
- "movq %%mm6, 64+" #dst " \n\t"\
- "movq %%mm5, 80+" #dst " \n\t"
-
-
-//IDCT( src0, src4, src1, src5, dst, shift)
-IDCT( 0(%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
-//IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20)
-IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
-//IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
- "jmp 9f \n\t"
-
-
- "# .p2align 4 \n\t"\
- "1: \n\t"
-#undef IDCT
-#define IDCT(src0, src4, src1, src5, dst, shift) \
- "movq " #src0 ", %%mm0 \n\t" /* R4 R0 r4 r0 */\
- "movq " #src4 ", %%mm1 \n\t" /* R6 R2 r6 r2 */\
- "movq " #src1 ", %%mm2 \n\t" /* R3 R1 r3 r1 */\
- "movq 16(%2), %%mm4 \n\t" /* C4 C4 C4 C4 */\
- "pmaddwd %%mm0, %%mm4 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "movq 24(%2), %%mm5 \n\t" /* -C4 C4 -C4 C4 */\
- "pmaddwd %%mm5, %%mm0 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\
- "movq 32(%2), %%mm5 \n\t" /* C6 C2 C6 C2 */\
- "pmaddwd %%mm1, %%mm5 \n\t" /* C6R6+C2R2 C6r6+C2r2 */\
- "movq 40(%2), %%mm6 \n\t" /* -C2 C6 -C2 C6 */\
- "pmaddwd %%mm6, %%mm1 \n\t" /* -C2R6+C6R2 -C2r6+C6r2 */\
- "movq %%mm4, %%mm6 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "movq 48(%2), %%mm7 \n\t" /* C3 C1 C3 C1 */\
- "pmaddwd %%mm2, %%mm7 \n\t" /* C3R3+C1R1 C3r3+C1r1 */\
- "paddd %%mm5, %%mm4 \n\t" /* A0 a0 */\
- "psubd %%mm5, %%mm6 \n\t" /* A3 a3 */\
- "movq %%mm0, %%mm5 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\
- "paddd %%mm1, %%mm0 \n\t" /* A1 a1 */\
- "psubd %%mm1, %%mm5 \n\t" /* A2 a2 */\
- "movq 64(%2), %%mm1 \n\t"\
- "pmaddwd %%mm2, %%mm1 \n\t" /* -C7R3+C3R1 -C7r3+C3r1 */\
- "paddd %%mm4, %%mm7 \n\t" /* A0+B0 a0+b0 */\
- "paddd %%mm4, %%mm4 \n\t" /* 2A0 2a0 */\
- "psubd %%mm7, %%mm4 \n\t" /* A0-B0 a0-b0 */\
- "psrad $" #shift ", %%mm7 \n\t"\
- "psrad $" #shift ", %%mm4 \n\t"\
- "movq %%mm0, %%mm3 \n\t" /* A1 a1 */\
- "paddd %%mm1, %%mm0 \n\t" /* A1+B1 a1+b1 */\
- "psubd %%mm1, %%mm3 \n\t" /* A1-B1 a1-b1 */\
- "psrad $" #shift ", %%mm0 \n\t"\
- "psrad $" #shift ", %%mm3 \n\t"\
- "packssdw %%mm7, %%mm7 \n\t" /* A0+B0 a0+b0 */\
- "movd %%mm7, " #dst " \n\t"\
- "packssdw %%mm0, %%mm0 \n\t" /* A1+B1 a1+b1 */\
- "movd %%mm0, 16+" #dst " \n\t"\
- "packssdw %%mm3, %%mm3 \n\t" /* A1-B1 a1-b1 */\
- "movd %%mm3, 96+" #dst " \n\t"\
- "packssdw %%mm4, %%mm4 \n\t" /* A0-B0 a0-b0 */\
- "movd %%mm4, 112+" #dst " \n\t"\
- "movq 80(%2), %%mm4 \n\t" /* -C1 C5 -C1 C5 */\
- "pmaddwd %%mm2, %%mm4 \n\t" /* -C1R3+C5R1 -C1r3+C5r1 */\
- "pmaddwd 96(%2), %%mm2 \n\t" /* -C5R3+C7R1 -C5r3+C7r1 */\
- "movq %%mm5, %%mm3 \n\t" /* A2 a2 */\
- "paddd %%mm4, %%mm3 \n\t" /* A2+B2 a2+b2 */\
- "psubd %%mm4, %%mm5 \n\t" /* a2-B2 a2-b2 */\
- "psrad $" #shift ", %%mm3 \n\t"\
- "psrad $" #shift ", %%mm5 \n\t"\
- "movq %%mm6, %%mm4 \n\t" /* A3 a3 */\
- "paddd %%mm2, %%mm6 \n\t" /* A3+B3 a3+b3 */\
- "psubd %%mm2, %%mm4 \n\t" /* a3-B3 a3-b3 */\
- "psrad $" #shift ", %%mm6 \n\t"\
- "packssdw %%mm3, %%mm3 \n\t" /* A2+B2 a2+b2 */\
- "movd %%mm3, 32+" #dst " \n\t"\
- "psrad $" #shift ", %%mm4 \n\t"\
- "packssdw %%mm6, %%mm6 \n\t" /* A3+B3 a3+b3 */\
- "movd %%mm6, 48+" #dst " \n\t"\
- "packssdw %%mm4, %%mm4 \n\t" /* A3-B3 a3-b3 */\
- "packssdw %%mm5, %%mm5 \n\t" /* A2-B2 a2-b2 */\
- "movd %%mm4, 64+" #dst " \n\t"\
- "movd %%mm5, 80+" #dst " \n\t"
-
-
-//IDCT( src0, src4, src1, src5, dst, shift)
-IDCT( (%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
-IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20)
-IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
-IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
- "jmp 9f \n\t"
-
-
- "# .p2align 4 \n\t"
- "7: \n\t"
-#undef IDCT
-#define IDCT(src0, src4, src1, src5, dst, shift) \
- "movq " #src0 ", %%mm0 \n\t" /* R4 R0 r4 r0 */\
- "movq 16(%2), %%mm4 \n\t" /* C4 C4 C4 C4 */\
- "pmaddwd %%mm0, %%mm4 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "movq 24(%2), %%mm5 \n\t" /* -C4 C4 -C4 C4 */\
- "pmaddwd %%mm5, %%mm0 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\
- "psrad $" #shift ", %%mm4 \n\t"\
- "psrad $" #shift ", %%mm0 \n\t"\
- "movq 8+" #src0 ", %%mm2 \n\t" /* R4 R0 r4 r0 */\
- "movq 16(%2), %%mm1 \n\t" /* C4 C4 C4 C4 */\
- "pmaddwd %%mm2, %%mm1 \n\t" /* C4R4+C4R0 C4r4+C4r0 */\
- "movq 24(%2), %%mm7 \n\t" /* -C4 C4 -C4 C4 */\
- "pmaddwd %%mm7, %%mm2 \n\t" /* -C4R4+C4R0 -C4r4+C4r0 */\
- "movq 32(%2), %%mm7 \n\t" /* C6 C2 C6 C2 */\
- "psrad $" #shift ", %%mm1 \n\t"\
- "packssdw %%mm1, %%mm4 \n\t" /* A0 a0 */\
- "movq %%mm4, " #dst " \n\t"\
- "psrad $" #shift ", %%mm2 \n\t"\
- "packssdw %%mm2, %%mm0 \n\t" /* A1 a1 */\
- "movq %%mm0, 16+" #dst " \n\t"\
- "movq %%mm0, 96+" #dst " \n\t"\
- "movq %%mm4, 112+" #dst " \n\t"\
- "movq %%mm0, 32+" #dst " \n\t"\
- "movq %%mm4, 48+" #dst " \n\t"\
- "movq %%mm4, 64+" #dst " \n\t"\
- "movq %%mm0, 80+" #dst " \n\t"
-
-//IDCT( src0, src4, src1, src5, dst, shift)
-IDCT( 0(%1), 64(%1), 32(%1), 96(%1), 0(%0), 20)
-//IDCT( 8(%1), 72(%1), 40(%1), 104(%1), 4(%0), 20)
-IDCT( 16(%1), 80(%1), 48(%1), 112(%1), 8(%0), 20)
-//IDCT( 24(%1), 88(%1), 56(%1), 120(%1), 12(%0), 20)
-
-
-#endif
-
-/*
-Input
- 00 40 04 44 20 60 24 64
- 10 30 14 34 50 70 54 74
- 01 41 03 43 21 61 23 63
- 11 31 13 33 51 71 53 73
- 02 42 06 46 22 62 26 66
- 12 32 16 36 52 72 56 76
- 05 45 07 47 25 65 27 67
- 15 35 17 37 55 75 57 77
-
-Temp
- 00 04 10 14 20 24 30 34
- 40 44 50 54 60 64 70 74
- 01 03 11 13 21 23 31 33
- 41 43 51 53 61 63 71 73
- 02 06 12 16 22 26 32 36
- 42 46 52 56 62 66 72 76
- 05 07 15 17 25 27 35 37
- 45 47 55 57 65 67 75 77
-*/
-
-"9: \n\t"
- :: "r" (block), "r" (temp), "r" (coeffs)
- : "%eax"
- );
-}
-
-void ff_simple_idct_mmx(int16_t *block)
-{
- idct(block);
-}
-
-//FIXME merge add/put into the idct
-
-void ff_simple_idct_put_mmx(uint8_t *dest, int line_size, int16_t *block)
-{
- idct(block);
- ff_put_pixels_clamped_mmx(block, dest, line_size);
-}
-void ff_simple_idct_add_mmx(uint8_t *dest, int line_size, int16_t *block)
-{
- idct(block);
- ff_add_pixels_clamped_mmx(block, dest, line_size);
-}
-
-#endif /* HAVE_INLINE_ASM */
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/vc1dsp.asm b/src/thirdparty/ffmpeg/libavcodec/x86/vc1dsp.asm
deleted file mode 100644
index 546688cf9..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/vc1dsp.asm
+++ /dev/null
@@ -1,317 +0,0 @@
-;******************************************************************************
-;* VC1 deblocking optimizations
-;* Copyright (c) 2009 David Conrad
-;*
-;* 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"
-
-cextern pw_4
-cextern pw_5
-
-section .text
-
-; dst_low, dst_high (src), zero
-; zero-extends one vector from 8 to 16 bits
-%macro UNPACK_8TO16 4
- mova m%2, m%3
- punpckh%1 m%3, m%4
- punpckl%1 m%2, m%4
-%endmacro
-
-%macro STORE_4_WORDS 6
-%if cpuflag(sse4)
- pextrw %1, %5, %6+0
- pextrw %2, %5, %6+1
- pextrw %3, %5, %6+2
- pextrw %4, %5, %6+3
-%else
- movd %6d, %5
-%if mmsize==16
- psrldq %5, 4
-%else
- psrlq %5, 32
-%endif
- mov %1, %6w
- shr %6, 16
- mov %2, %6w
- movd %6d, %5
- mov %3, %6w
- shr %6, 16
- mov %4, %6w
-%endif
-%endmacro
-
-; in: p1 p0 q0 q1, clobbers p0
-; out: p1 = (2*(p1 - q1) - 5*(p0 - q0) + 4) >> 3
-%macro VC1_LOOP_FILTER_A0 4
- psubw %1, %4
- psubw %2, %3
- paddw %1, %1
- pmullw %2, [pw_5]
- psubw %1, %2
- paddw %1, [pw_4]
- psraw %1, 3
-%endmacro
-
-; in: p0 q0 a0 a1 a2
-; m0 m1 m7 m6 m5
-; %1: size
-; out: m0=p0' m1=q0'
-%macro VC1_FILTER 1
- PABSW m4, m7
- PABSW m3, m6
- PABSW m2, m5
- mova m6, m4
- pminsw m3, m2
- pcmpgtw m6, m3 ; if (a2 < a0 || a1 < a0)
- psubw m3, m4
- pmullw m3, [pw_5] ; 5*(a3 - a0)
- PABSW m2, m3
- psraw m2, 3 ; abs(d/8)
- pxor m7, m3 ; d_sign ^= a0_sign
-
- pxor m5, m5
- movd m3, r2d
-%if %1 > 4
- punpcklbw m3, m3
-%endif
- punpcklbw m3, m5
- pcmpgtw m3, m4 ; if (a0 < pq)
- pand m6, m3
-
- mova m3, m0
- psubw m3, m1
- PABSW m4, m3
- psraw m4, 1
- pxor m3, m7 ; d_sign ^ clip_sign
- psraw m3, 15
- pminsw m2, m4 ; min(d, clip)
- pcmpgtw m4, m5
- pand m6, m4 ; filt3 (C return value)
-
-; each set of 4 pixels is not filtered if the 3rd is not
-%if mmsize==16
- pshuflw m4, m6, 0xaa
-%if %1 > 4
- pshufhw m4, m4, 0xaa
-%endif
-%else
- pshufw m4, m6, 0xaa
-%endif
- pandn m3, m4
- pand m2, m6
- pand m3, m2 ; d final
-
- psraw m7, 15
- pxor m3, m7
- psubw m3, m7
- psubw m0, m3
- paddw m1, m3
- packuswb m0, m0
- packuswb m1, m1
-%endmacro
-
-; 1st param: size of filter
-; 2nd param: mov suffix equivalent to the filter size
-%macro VC1_V_LOOP_FILTER 2
- pxor m5, m5
- mov%2 m6, [r4]
- mov%2 m4, [r4+r1]
- mov%2 m7, [r4+2*r1]
- mov%2 m0, [r4+r3]
- punpcklbw m6, m5
- punpcklbw m4, m5
- punpcklbw m7, m5
- punpcklbw m0, m5
-
- VC1_LOOP_FILTER_A0 m6, m4, m7, m0
- mov%2 m1, [r0]
- mov%2 m2, [r0+r1]
- punpcklbw m1, m5
- punpcklbw m2, m5
- mova m4, m0
- VC1_LOOP_FILTER_A0 m7, m4, m1, m2
- mov%2 m3, [r0+2*r1]
- mov%2 m4, [r0+r3]
- punpcklbw m3, m5
- punpcklbw m4, m5
- mova m5, m1
- VC1_LOOP_FILTER_A0 m5, m2, m3, m4
-
- VC1_FILTER %1
- mov%2 [r4+r3], m0
- mov%2 [r0], m1
-%endmacro
-
-; 1st param: size of filter
-; NOTE: UNPACK_8TO16 this number of 8 bit numbers are in half a register
-; 2nd (optional) param: temp register to use for storing words
-%macro VC1_H_LOOP_FILTER 1-2
-%if %1 == 4
- movq m0, [r0 -4]
- movq m1, [r0+ r1-4]
- movq m2, [r0+2*r1-4]
- movq m3, [r0+ r3-4]
- TRANSPOSE4x4B 0, 1, 2, 3, 4
-%else
- movq m0, [r0 -4]
- movq m4, [r0+ r1-4]
- movq m1, [r0+2*r1-4]
- movq m5, [r0+ r3-4]
- movq m2, [r4 -4]
- movq m6, [r4+ r1-4]
- movq m3, [r4+2*r1-4]
- movq m7, [r4+ r3-4]
- punpcklbw m0, m4
- punpcklbw m1, m5
- punpcklbw m2, m6
- punpcklbw m3, m7
- TRANSPOSE4x4W 0, 1, 2, 3, 4
-%endif
- pxor m5, m5
-
- UNPACK_8TO16 bw, 6, 0, 5
- UNPACK_8TO16 bw, 7, 1, 5
- VC1_LOOP_FILTER_A0 m6, m0, m7, m1
- UNPACK_8TO16 bw, 4, 2, 5
- mova m0, m1 ; m0 = p0
- VC1_LOOP_FILTER_A0 m7, m1, m4, m2
- UNPACK_8TO16 bw, 1, 3, 5
- mova m5, m4
- VC1_LOOP_FILTER_A0 m5, m2, m1, m3
- SWAP 1, 4 ; m1 = q0
-
- VC1_FILTER %1
- punpcklbw m0, m1
-%if %0 > 1
- STORE_4_WORDS [r0-1], [r0+r1-1], [r0+2*r1-1], [r0+r3-1], m0, %2
-%if %1 > 4
- psrldq m0, 4
- STORE_4_WORDS [r4-1], [r4+r1-1], [r4+2*r1-1], [r4+r3-1], m0, %2
-%endif
-%else
- STORE_4_WORDS [r0-1], [r0+r1-1], [r0+2*r1-1], [r0+r3-1], m0, 0
- STORE_4_WORDS [r4-1], [r4+r1-1], [r4+2*r1-1], [r4+r3-1], m0, 4
-%endif
-%endmacro
-
-
-%macro START_V_FILTER 0
- mov r4, r0
- lea r3, [4*r1]
- sub r4, r3
- lea r3, [r1+2*r1]
- imul r2, 0x01010101
-%endmacro
-
-%macro START_H_FILTER 1
- lea r3, [r1+2*r1]
-%if %1 > 4
- lea r4, [r0+4*r1]
-%endif
- imul r2, 0x01010101
-%endmacro
-
-%macro VC1_LF 0
-cglobal vc1_v_loop_filter_internal
- VC1_V_LOOP_FILTER 4, d
- ret
-
-cglobal vc1_h_loop_filter_internal
- VC1_H_LOOP_FILTER 4, r4
- ret
-
-; void ff_vc1_v_loop_filter4_mmxext(uint8_t *src, int stride, int pq)
-cglobal vc1_v_loop_filter4, 3,5,0
- START_V_FILTER
- call vc1_v_loop_filter_internal
- RET
-
-; void ff_vc1_h_loop_filter4_mmxext(uint8_t *src, int stride, int pq)
-cglobal vc1_h_loop_filter4, 3,5,0
- START_H_FILTER 4
- call vc1_h_loop_filter_internal
- RET
-
-; void ff_vc1_v_loop_filter8_mmxext(uint8_t *src, int stride, int pq)
-cglobal vc1_v_loop_filter8, 3,5,0
- START_V_FILTER
- call vc1_v_loop_filter_internal
- add r4, 4
- add r0, 4
- call vc1_v_loop_filter_internal
- RET
-
-; void ff_vc1_h_loop_filter8_mmxext(uint8_t *src, int stride, int pq)
-cglobal vc1_h_loop_filter8, 3,5,0
- START_H_FILTER 4
- call vc1_h_loop_filter_internal
- lea r0, [r0+4*r1]
- call vc1_h_loop_filter_internal
- RET
-%endmacro
-
-INIT_MMX mmxext
-VC1_LF
-
-INIT_XMM sse2
-; void ff_vc1_v_loop_filter8_sse2(uint8_t *src, int stride, int pq)
-cglobal vc1_v_loop_filter8, 3,5,8
- START_V_FILTER
- VC1_V_LOOP_FILTER 8, q
- RET
-
-; void ff_vc1_h_loop_filter8_sse2(uint8_t *src, int stride, int pq)
-cglobal vc1_h_loop_filter8, 3,6,8
- START_H_FILTER 8
- VC1_H_LOOP_FILTER 8, r5
- RET
-
-INIT_MMX ssse3
-; void ff_vc1_v_loop_filter4_ssse3(uint8_t *src, int stride, int pq)
-cglobal vc1_v_loop_filter4, 3,5,0
- START_V_FILTER
- VC1_V_LOOP_FILTER 4, d
- RET
-
-; void ff_vc1_h_loop_filter4_ssse3(uint8_t *src, int stride, int pq)
-cglobal vc1_h_loop_filter4, 3,5,0
- START_H_FILTER 4
- VC1_H_LOOP_FILTER 4, r4
- RET
-
-INIT_XMM ssse3
-; void ff_vc1_v_loop_filter8_ssse3(uint8_t *src, int stride, int pq)
-cglobal vc1_v_loop_filter8, 3,5,8
- START_V_FILTER
- VC1_V_LOOP_FILTER 8, q
- RET
-
-; void ff_vc1_h_loop_filter8_ssse3(uint8_t *src, int stride, int pq)
-cglobal vc1_h_loop_filter8, 3,6,8
- START_H_FILTER 8
- VC1_H_LOOP_FILTER 8, r5
- RET
-
-INIT_XMM sse4
-; void ff_vc1_h_loop_filter8_sse4(uint8_t *src, int stride, int pq)
-cglobal vc1_h_loop_filter8, 3,5,8
- START_H_FILTER 8
- VC1_H_LOOP_FILTER 8
- RET
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/vc1dsp.h b/src/thirdparty/ffmpeg/libavcodec/x86/vc1dsp.h
deleted file mode 100644
index fdd4de181..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/vc1dsp.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * VC-1 and WMV3 decoder - X86 DSP init 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_X86_VC1DSP_H
-#define AVCODEC_X86_VC1DSP_H
-
-#include "libavcodec/vc1dsp.h"
-
-void ff_vc1dsp_init_mmx(VC1DSPContext *dsp);
-void ff_vc1dsp_init_mmxext(VC1DSPContext *dsp);
-
-#endif /* AVCODEC_X86_VC1DSP_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/vc1dsp_init.c b/src/thirdparty/ffmpeg/libavcodec/x86/vc1dsp_init.c
deleted file mode 100644
index 230d06f0c..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/vc1dsp_init.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * VC-1 and WMV3 - DSP functions MMX-optimized
- * Copyright (c) 2007 Christophe GISQUET <christophe.gisquet@free.fr>
- *
- * 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.
- */
-
-#include "libavutil/cpu.h"
-#include "libavutil/x86/cpu.h"
-#include "libavcodec/vc1dsp.h"
-#include "vc1dsp.h"
-#include "config.h"
-
-#define LOOP_FILTER(EXT) \
-void ff_vc1_v_loop_filter4_ ## EXT(uint8_t *src, int stride, int pq); \
-void ff_vc1_h_loop_filter4_ ## EXT(uint8_t *src, int stride, int pq); \
-void ff_vc1_v_loop_filter8_ ## EXT(uint8_t *src, int stride, int pq); \
-void ff_vc1_h_loop_filter8_ ## EXT(uint8_t *src, int stride, int pq); \
-\
-static void vc1_v_loop_filter16_ ## EXT(uint8_t *src, int stride, int pq) \
-{ \
- ff_vc1_v_loop_filter8_ ## EXT(src, stride, pq); \
- ff_vc1_v_loop_filter8_ ## EXT(src+8, stride, pq); \
-} \
-\
-static void vc1_h_loop_filter16_ ## EXT(uint8_t *src, int stride, int pq) \
-{ \
- ff_vc1_h_loop_filter8_ ## EXT(src, stride, pq); \
- ff_vc1_h_loop_filter8_ ## EXT(src+8*stride, stride, pq); \
-}
-
-#if HAVE_YASM
-LOOP_FILTER(mmxext)
-LOOP_FILTER(sse2)
-LOOP_FILTER(ssse3)
-
-void ff_vc1_h_loop_filter8_sse4(uint8_t *src, int stride, int pq);
-
-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);
-}
-#endif /* HAVE_YASM */
-
-void ff_put_vc1_chroma_mc8_nornd_mmx (uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
-void ff_avg_vc1_chroma_mc8_nornd_mmxext(uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
-void ff_avg_vc1_chroma_mc8_nornd_3dnow(uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
-void ff_put_vc1_chroma_mc8_nornd_ssse3(uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
-void ff_avg_vc1_chroma_mc8_nornd_ssse3(uint8_t *dst, uint8_t *src,
- int stride, int h, int x, int y);
-
-
-av_cold void ff_vc1dsp_init_x86(VC1DSPContext *dsp)
-{
- int mm_flags = av_get_cpu_flags();
-
- if (INLINE_MMX(mm_flags))
- ff_vc1dsp_init_mmx(dsp);
-
- if (INLINE_MMXEXT(mm_flags))
- ff_vc1dsp_init_mmxext(dsp);
-
-#define ASSIGN_LF(EXT) \
- dsp->vc1_v_loop_filter4 = ff_vc1_v_loop_filter4_ ## EXT; \
- dsp->vc1_h_loop_filter4 = ff_vc1_h_loop_filter4_ ## EXT; \
- dsp->vc1_v_loop_filter8 = ff_vc1_v_loop_filter8_ ## EXT; \
- dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_ ## EXT; \
- dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_ ## EXT; \
- dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_ ## EXT
-
-#if HAVE_YASM
- if (mm_flags & AV_CPU_FLAG_MMX) {
- dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = ff_put_vc1_chroma_mc8_nornd_mmx;
- }
-
- if (mm_flags & AV_CPU_FLAG_MMXEXT) {
- ASSIGN_LF(mmxext);
- dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_vc1_chroma_mc8_nornd_mmxext;
- } else if (mm_flags & AV_CPU_FLAG_3DNOW) {
- dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_vc1_chroma_mc8_nornd_3dnow;
- }
-
- if (mm_flags & AV_CPU_FLAG_SSE2) {
- 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;
- }
- if (mm_flags & AV_CPU_FLAG_SSSE3) {
- ASSIGN_LF(ssse3);
- dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = ff_put_vc1_chroma_mc8_nornd_ssse3;
- dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_vc1_chroma_mc8_nornd_ssse3;
- }
- if (mm_flags & AV_CPU_FLAG_SSE4) {
- dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_sse4;
- dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_sse4;
- }
-#endif /* HAVE_YASM */
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/vc1dsp_mmx.c b/src/thirdparty/ffmpeg/libavcodec/x86/vc1dsp_mmx.c
deleted file mode 100644
index 7902dbc5d..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/vc1dsp_mmx.c
+++ /dev/null
@@ -1,751 +0,0 @@
-/*
- * VC-1 and WMV3 - DSP functions MMX-optimized
- * Copyright (c) 2007 Christophe GISQUET <christophe.gisquet@free.fr>
- *
- * 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.
- */
-
-#include "libavutil/cpu.h"
-#include "libavutil/mem.h"
-#include "libavutil/x86/asm.h"
-#include "libavutil/x86/cpu.h"
-#include "libavcodec/dsputil.h"
-#include "dsputil_mmx.h"
-#include "libavcodec/vc1dsp.h"
-#include "vc1dsp.h"
-
-#if HAVE_INLINE_ASM
-
-#define OP_PUT(S,D)
-#define OP_AVG(S,D) "pavgb " #S ", " #D " \n\t"
-
-/** Add rounder from mm7 to mm3 and pack result at destination */
-#define NORMALIZE_MMX(SHIFT) \
- "paddw %%mm7, %%mm3 \n\t" /* +bias-r */ \
- "paddw %%mm7, %%mm4 \n\t" /* +bias-r */ \
- "psraw "SHIFT", %%mm3 \n\t" \
- "psraw "SHIFT", %%mm4 \n\t"
-
-#define TRANSFER_DO_PACK(OP) \
- "packuswb %%mm4, %%mm3 \n\t" \
- OP((%2), %%mm3) \
- "movq %%mm3, (%2) \n\t"
-
-#define TRANSFER_DONT_PACK(OP) \
- OP(0(%2), %%mm3) \
- OP(8(%2), %%mm4) \
- "movq %%mm3, 0(%2) \n\t" \
- "movq %%mm4, 8(%2) \n\t"
-
-/** @see MSPEL_FILTER13_CORE for use as UNPACK macro */
-#define DO_UNPACK(reg) "punpcklbw %%mm0, " reg "\n\t"
-#define DONT_UNPACK(reg)
-
-/** Compute the rounder 32-r or 8-r and unpacks it to mm7 */
-#define LOAD_ROUNDER_MMX(ROUND) \
- "movd "ROUND", %%mm7 \n\t" \
- "punpcklwd %%mm7, %%mm7 \n\t" \
- "punpckldq %%mm7, %%mm7 \n\t"
-
-#define SHIFT2_LINE(OFF, R0,R1,R2,R3) \
- "paddw %%mm"#R2", %%mm"#R1" \n\t" \
- "movd (%0,%3), %%mm"#R0" \n\t" \
- "pmullw %%mm6, %%mm"#R1" \n\t" \
- "punpcklbw %%mm0, %%mm"#R0" \n\t" \
- "movd (%0,%2), %%mm"#R3" \n\t" \
- "psubw %%mm"#R0", %%mm"#R1" \n\t" \
- "punpcklbw %%mm0, %%mm"#R3" \n\t" \
- "paddw %%mm7, %%mm"#R1" \n\t" \
- "psubw %%mm"#R3", %%mm"#R1" \n\t" \
- "psraw %4, %%mm"#R1" \n\t" \
- "movq %%mm"#R1", "#OFF"(%1) \n\t" \
- "add %2, %0 \n\t"
-
-/** Sacrifying mm6 allows to pipeline loads from src */
-static void vc1_put_ver_16b_shift2_mmx(int16_t *dst,
- const uint8_t *src, x86_reg stride,
- int rnd, int64_t shift)
-{
- __asm__ volatile(
- "mov $3, %%"REG_c" \n\t"
- LOAD_ROUNDER_MMX("%5")
- "movq "MANGLE(ff_pw_9)", %%mm6 \n\t"
- "1: \n\t"
- "movd (%0), %%mm2 \n\t"
- "add %2, %0 \n\t"
- "movd (%0), %%mm3 \n\t"
- "punpcklbw %%mm0, %%mm2 \n\t"
- "punpcklbw %%mm0, %%mm3 \n\t"
- SHIFT2_LINE( 0, 1, 2, 3, 4)
- SHIFT2_LINE( 24, 2, 3, 4, 1)
- SHIFT2_LINE( 48, 3, 4, 1, 2)
- SHIFT2_LINE( 72, 4, 1, 2, 3)
- SHIFT2_LINE( 96, 1, 2, 3, 4)
- SHIFT2_LINE(120, 2, 3, 4, 1)
- SHIFT2_LINE(144, 3, 4, 1, 2)
- SHIFT2_LINE(168, 4, 1, 2, 3)
- "sub %6, %0 \n\t"
- "add $8, %1 \n\t"
- "dec %%"REG_c" \n\t"
- "jnz 1b \n\t"
- : "+r"(src), "+r"(dst)
- : "r"(stride), "r"(-2*stride),
- "m"(shift), "m"(rnd), "r"(9*stride-4)
- : "%"REG_c, "memory"
- );
-}
-
-/**
- * Data is already unpacked, so some operations can directly be made from
- * memory.
- */
-#define VC1_HOR_16b_SHIFT2(OP, OPNAME)\
-static void OPNAME ## vc1_hor_16b_shift2_mmx(uint8_t *dst, x86_reg stride,\
- const int16_t *src, int rnd)\
-{\
- int h = 8;\
-\
- src -= 1;\
- rnd -= (-1+9+9-1)*1024; /* Add -1024 bias */\
- __asm__ volatile(\
- LOAD_ROUNDER_MMX("%4")\
- "movq "MANGLE(ff_pw_128)", %%mm6\n\t"\
- "movq "MANGLE(ff_pw_9)", %%mm5 \n\t"\
- "1: \n\t"\
- "movq 2*0+0(%1), %%mm1 \n\t"\
- "movq 2*0+8(%1), %%mm2 \n\t"\
- "movq 2*1+0(%1), %%mm3 \n\t"\
- "movq 2*1+8(%1), %%mm4 \n\t"\
- "paddw 2*3+0(%1), %%mm1 \n\t"\
- "paddw 2*3+8(%1), %%mm2 \n\t"\
- "paddw 2*2+0(%1), %%mm3 \n\t"\
- "paddw 2*2+8(%1), %%mm4 \n\t"\
- "pmullw %%mm5, %%mm3 \n\t"\
- "pmullw %%mm5, %%mm4 \n\t"\
- "psubw %%mm1, %%mm3 \n\t"\
- "psubw %%mm2, %%mm4 \n\t"\
- NORMALIZE_MMX("$7")\
- /* Remove bias */\
- "paddw %%mm6, %%mm3 \n\t"\
- "paddw %%mm6, %%mm4 \n\t"\
- TRANSFER_DO_PACK(OP)\
- "add $24, %1 \n\t"\
- "add %3, %2 \n\t"\
- "decl %0 \n\t"\
- "jnz 1b \n\t"\
- : "+r"(h), "+r" (src), "+r" (dst)\
- : "r"(stride), "m"(rnd)\
- : "memory"\
- );\
-}
-
-VC1_HOR_16b_SHIFT2(OP_PUT, put_)
-VC1_HOR_16b_SHIFT2(OP_AVG, avg_)
-
-
-/**
- * Purely vertical or horizontal 1/2 shift interpolation.
- * Sacrify mm6 for *9 factor.
- */
-#define VC1_SHIFT2(OP, OPNAME)\
-static void OPNAME ## vc1_shift2_mmx(uint8_t *dst, const uint8_t *src,\
- x86_reg stride, int rnd, x86_reg offset)\
-{\
- rnd = 8-rnd;\
- __asm__ volatile(\
- "mov $8, %%"REG_c" \n\t"\
- LOAD_ROUNDER_MMX("%5")\
- "movq "MANGLE(ff_pw_9)", %%mm6\n\t"\
- "1: \n\t"\
- "movd 0(%0 ), %%mm3 \n\t"\
- "movd 4(%0 ), %%mm4 \n\t"\
- "movd 0(%0,%2), %%mm1 \n\t"\
- "movd 4(%0,%2), %%mm2 \n\t"\
- "add %2, %0 \n\t"\
- "punpcklbw %%mm0, %%mm3 \n\t"\
- "punpcklbw %%mm0, %%mm4 \n\t"\
- "punpcklbw %%mm0, %%mm1 \n\t"\
- "punpcklbw %%mm0, %%mm2 \n\t"\
- "paddw %%mm1, %%mm3 \n\t"\
- "paddw %%mm2, %%mm4 \n\t"\
- "movd 0(%0,%3), %%mm1 \n\t"\
- "movd 4(%0,%3), %%mm2 \n\t"\
- "pmullw %%mm6, %%mm3 \n\t" /* 0,9,9,0*/\
- "pmullw %%mm6, %%mm4 \n\t" /* 0,9,9,0*/\
- "punpcklbw %%mm0, %%mm1 \n\t"\
- "punpcklbw %%mm0, %%mm2 \n\t"\
- "psubw %%mm1, %%mm3 \n\t" /*-1,9,9,0*/\
- "psubw %%mm2, %%mm4 \n\t" /*-1,9,9,0*/\
- "movd 0(%0,%2), %%mm1 \n\t"\
- "movd 4(%0,%2), %%mm2 \n\t"\
- "punpcklbw %%mm0, %%mm1 \n\t"\
- "punpcklbw %%mm0, %%mm2 \n\t"\
- "psubw %%mm1, %%mm3 \n\t" /*-1,9,9,-1*/\
- "psubw %%mm2, %%mm4 \n\t" /*-1,9,9,-1*/\
- NORMALIZE_MMX("$4")\
- "packuswb %%mm4, %%mm3 \n\t"\
- OP((%1), %%mm3)\
- "movq %%mm3, (%1) \n\t"\
- "add %6, %0 \n\t"\
- "add %4, %1 \n\t"\
- "dec %%"REG_c" \n\t"\
- "jnz 1b \n\t"\
- : "+r"(src), "+r"(dst)\
- : "r"(offset), "r"(-2*offset), "g"(stride), "m"(rnd),\
- "g"(stride-offset)\
- : "%"REG_c, "memory"\
- );\
-}
-
-VC1_SHIFT2(OP_PUT, put_)
-VC1_SHIFT2(OP_AVG, avg_)
-
-/**
- * Core of the 1/4 and 3/4 shift bicubic interpolation.
- *
- * @param UNPACK Macro unpacking arguments from 8 to 16bits (can be empty).
- * @param MOVQ "movd 1" or "movq 2", if data read is already unpacked.
- * @param A1 Address of 1st tap (beware of unpacked/packed).
- * @param A2 Address of 2nd tap
- * @param A3 Address of 3rd tap
- * @param A4 Address of 4th tap
- */
-#define MSPEL_FILTER13_CORE(UNPACK, MOVQ, A1, A2, A3, A4) \
- MOVQ "*0+"A1", %%mm1 \n\t" \
- MOVQ "*4+"A1", %%mm2 \n\t" \
- UNPACK("%%mm1") \
- UNPACK("%%mm2") \
- "pmullw "MANGLE(ff_pw_3)", %%mm1\n\t" \
- "pmullw "MANGLE(ff_pw_3)", %%mm2\n\t" \
- MOVQ "*0+"A2", %%mm3 \n\t" \
- MOVQ "*4+"A2", %%mm4 \n\t" \
- UNPACK("%%mm3") \
- UNPACK("%%mm4") \
- "pmullw %%mm6, %%mm3 \n\t" /* *18 */ \
- "pmullw %%mm6, %%mm4 \n\t" /* *18 */ \
- "psubw %%mm1, %%mm3 \n\t" /* 18,-3 */ \
- "psubw %%mm2, %%mm4 \n\t" /* 18,-3 */ \
- MOVQ "*0+"A4", %%mm1 \n\t" \
- MOVQ "*4+"A4", %%mm2 \n\t" \
- UNPACK("%%mm1") \
- UNPACK("%%mm2") \
- "psllw $2, %%mm1 \n\t" /* 4* */ \
- "psllw $2, %%mm2 \n\t" /* 4* */ \
- "psubw %%mm1, %%mm3 \n\t" /* -4,18,-3 */ \
- "psubw %%mm2, %%mm4 \n\t" /* -4,18,-3 */ \
- MOVQ "*0+"A3", %%mm1 \n\t" \
- MOVQ "*4+"A3", %%mm2 \n\t" \
- UNPACK("%%mm1") \
- UNPACK("%%mm2") \
- "pmullw %%mm5, %%mm1 \n\t" /* *53 */ \
- "pmullw %%mm5, %%mm2 \n\t" /* *53 */ \
- "paddw %%mm1, %%mm3 \n\t" /* 4,53,18,-3 */ \
- "paddw %%mm2, %%mm4 \n\t" /* 4,53,18,-3 */
-
-/**
- * Macro to build the vertical 16bits version of vc1_put_shift[13].
- * Here, offset=src_stride. Parameters passed A1 to A4 must use
- * %3 (src_stride) and %4 (3*src_stride).
- *
- * @param NAME Either 1 or 3
- * @see MSPEL_FILTER13_CORE for information on A1->A4
- */
-#define MSPEL_FILTER13_VER_16B(NAME, A1, A2, A3, A4) \
-static void \
-vc1_put_ver_16b_ ## NAME ## _mmx(int16_t *dst, const uint8_t *src, \
- x86_reg src_stride, \
- int rnd, int64_t shift) \
-{ \
- int h = 8; \
- src -= src_stride; \
- __asm__ volatile( \
- LOAD_ROUNDER_MMX("%5") \
- "movq "MANGLE(ff_pw_53)", %%mm5\n\t" \
- "movq "MANGLE(ff_pw_18)", %%mm6\n\t" \
- ".p2align 3 \n\t" \
- "1: \n\t" \
- MSPEL_FILTER13_CORE(DO_UNPACK, "movd 1", A1, A2, A3, A4) \
- NORMALIZE_MMX("%6") \
- TRANSFER_DONT_PACK(OP_PUT) \
- /* Last 3 (in fact 4) bytes on the line */ \
- "movd 8+"A1", %%mm1 \n\t" \
- DO_UNPACK("%%mm1") \
- "movq %%mm1, %%mm3 \n\t" \
- "paddw %%mm1, %%mm1 \n\t" \
- "paddw %%mm3, %%mm1 \n\t" /* 3* */ \
- "movd 8+"A2", %%mm3 \n\t" \
- DO_UNPACK("%%mm3") \
- "pmullw %%mm6, %%mm3 \n\t" /* *18 */ \
- "psubw %%mm1, %%mm3 \n\t" /*18,-3 */ \
- "movd 8+"A3", %%mm1 \n\t" \
- DO_UNPACK("%%mm1") \
- "pmullw %%mm5, %%mm1 \n\t" /* *53 */ \
- "paddw %%mm1, %%mm3 \n\t" /*53,18,-3 */ \
- "movd 8+"A4", %%mm1 \n\t" \
- DO_UNPACK("%%mm1") \
- "psllw $2, %%mm1 \n\t" /* 4* */ \
- "psubw %%mm1, %%mm3 \n\t" \
- "paddw %%mm7, %%mm3 \n\t" \
- "psraw %6, %%mm3 \n\t" \
- "movq %%mm3, 16(%2) \n\t" \
- "add %3, %1 \n\t" \
- "add $24, %2 \n\t" \
- "decl %0 \n\t" \
- "jnz 1b \n\t" \
- : "+r"(h), "+r" (src), "+r" (dst) \
- : "r"(src_stride), "r"(3*src_stride), \
- "m"(rnd), "m"(shift) \
- : "memory" \
- ); \
-}
-
-/**
- * Macro to build the horizontal 16bits version of vc1_put_shift[13].
- * Here, offset=16bits, so parameters passed A1 to A4 should be simple.
- *
- * @param NAME Either 1 or 3
- * @see MSPEL_FILTER13_CORE for information on A1->A4
- */
-#define MSPEL_FILTER13_HOR_16B(NAME, A1, A2, A3, A4, OP, OPNAME) \
-static void \
-OPNAME ## vc1_hor_16b_ ## NAME ## _mmx(uint8_t *dst, x86_reg stride, \
- const int16_t *src, int rnd) \
-{ \
- int h = 8; \
- src -= 1; \
- rnd -= (-4+58+13-3)*256; /* Add -256 bias */ \
- __asm__ volatile( \
- LOAD_ROUNDER_MMX("%4") \
- "movq "MANGLE(ff_pw_18)", %%mm6 \n\t" \
- "movq "MANGLE(ff_pw_53)", %%mm5 \n\t" \
- ".p2align 3 \n\t" \
- "1: \n\t" \
- MSPEL_FILTER13_CORE(DONT_UNPACK, "movq 2", A1, A2, A3, A4) \
- NORMALIZE_MMX("$7") \
- /* Remove bias */ \
- "paddw "MANGLE(ff_pw_128)", %%mm3 \n\t" \
- "paddw "MANGLE(ff_pw_128)", %%mm4 \n\t" \
- TRANSFER_DO_PACK(OP) \
- "add $24, %1 \n\t" \
- "add %3, %2 \n\t" \
- "decl %0 \n\t" \
- "jnz 1b \n\t" \
- : "+r"(h), "+r" (src), "+r" (dst) \
- : "r"(stride), "m"(rnd) \
- : "memory" \
- ); \
-}
-
-/**
- * Macro to build the 8bits, any direction, version of vc1_put_shift[13].
- * Here, offset=src_stride. Parameters passed A1 to A4 must use
- * %3 (offset) and %4 (3*offset).
- *
- * @param NAME Either 1 or 3
- * @see MSPEL_FILTER13_CORE for information on A1->A4
- */
-#define MSPEL_FILTER13_8B(NAME, A1, A2, A3, A4, OP, OPNAME) \
-static void \
-OPNAME ## vc1_## NAME ## _mmx(uint8_t *dst, const uint8_t *src, \
- x86_reg stride, int rnd, x86_reg offset) \
-{ \
- int h = 8; \
- src -= offset; \
- rnd = 32-rnd; \
- __asm__ volatile ( \
- LOAD_ROUNDER_MMX("%6") \
- "movq "MANGLE(ff_pw_53)", %%mm5 \n\t" \
- "movq "MANGLE(ff_pw_18)", %%mm6 \n\t" \
- ".p2align 3 \n\t" \
- "1: \n\t" \
- MSPEL_FILTER13_CORE(DO_UNPACK, "movd 1", A1, A2, A3, A4) \
- NORMALIZE_MMX("$6") \
- TRANSFER_DO_PACK(OP) \
- "add %5, %1 \n\t" \
- "add %5, %2 \n\t" \
- "decl %0 \n\t" \
- "jnz 1b \n\t" \
- : "+r"(h), "+r" (src), "+r" (dst) \
- : "r"(offset), "r"(3*offset), "g"(stride), "m"(rnd) \
- : "memory" \
- ); \
-}
-
-/** 1/4 shift bicubic interpolation */
-MSPEL_FILTER13_8B (shift1, "0(%1,%4 )", "0(%1,%3,2)", "0(%1,%3 )", "0(%1 )", OP_PUT, put_)
-MSPEL_FILTER13_8B (shift1, "0(%1,%4 )", "0(%1,%3,2)", "0(%1,%3 )", "0(%1 )", OP_AVG, avg_)
-MSPEL_FILTER13_VER_16B(shift1, "0(%1,%4 )", "0(%1,%3,2)", "0(%1,%3 )", "0(%1 )")
-MSPEL_FILTER13_HOR_16B(shift1, "2*3(%1)", "2*2(%1)", "2*1(%1)", "2*0(%1)", OP_PUT, put_)
-MSPEL_FILTER13_HOR_16B(shift1, "2*3(%1)", "2*2(%1)", "2*1(%1)", "2*0(%1)", OP_AVG, avg_)
-
-/** 3/4 shift bicubic interpolation */
-MSPEL_FILTER13_8B (shift3, "0(%1 )", "0(%1,%3 )", "0(%1,%3,2)", "0(%1,%4 )", OP_PUT, put_)
-MSPEL_FILTER13_8B (shift3, "0(%1 )", "0(%1,%3 )", "0(%1,%3,2)", "0(%1,%4 )", OP_AVG, avg_)
-MSPEL_FILTER13_VER_16B(shift3, "0(%1 )", "0(%1,%3 )", "0(%1,%3,2)", "0(%1,%4 )")
-MSPEL_FILTER13_HOR_16B(shift3, "2*0(%1)", "2*1(%1)", "2*2(%1)", "2*3(%1)", OP_PUT, put_)
-MSPEL_FILTER13_HOR_16B(shift3, "2*0(%1)", "2*1(%1)", "2*2(%1)", "2*3(%1)", OP_AVG, avg_)
-
-typedef void (*vc1_mspel_mc_filter_ver_16bits)(int16_t *dst, const uint8_t *src, x86_reg src_stride, int rnd, int64_t shift);
-typedef void (*vc1_mspel_mc_filter_hor_16bits)(uint8_t *dst, x86_reg dst_stride, const int16_t *src, int rnd);
-typedef void (*vc1_mspel_mc_filter_8bits)(uint8_t *dst, const uint8_t *src, x86_reg stride, int rnd, x86_reg offset);
-
-/**
- * Interpolate fractional pel values by applying proper vertical then
- * horizontal filter.
- *
- * @param dst Destination buffer for interpolated pels.
- * @param src Source buffer.
- * @param stride Stride for both src and dst buffers.
- * @param hmode Horizontal filter (expressed in quarter pixels shift).
- * @param hmode Vertical filter.
- * @param rnd Rounding bias.
- */
-#define VC1_MSPEL_MC(OP)\
-static void OP ## vc1_mspel_mc(uint8_t *dst, const uint8_t *src, int stride,\
- int hmode, int vmode, int rnd)\
-{\
- static const vc1_mspel_mc_filter_ver_16bits vc1_put_shift_ver_16bits[] =\
- { NULL, vc1_put_ver_16b_shift1_mmx, vc1_put_ver_16b_shift2_mmx, vc1_put_ver_16b_shift3_mmx };\
- static const vc1_mspel_mc_filter_hor_16bits vc1_put_shift_hor_16bits[] =\
- { NULL, OP ## vc1_hor_16b_shift1_mmx, OP ## vc1_hor_16b_shift2_mmx, OP ## vc1_hor_16b_shift3_mmx };\
- static const vc1_mspel_mc_filter_8bits vc1_put_shift_8bits[] =\
- { NULL, OP ## vc1_shift1_mmx, OP ## vc1_shift2_mmx, OP ## vc1_shift3_mmx };\
-\
- __asm__ volatile(\
- "pxor %%mm0, %%mm0 \n\t"\
- ::: "memory"\
- );\
-\
- if (vmode) { /* Vertical filter to apply */\
- if (hmode) { /* Horizontal filter to apply, output to tmp */\
- static const int shift_value[] = { 0, 5, 1, 5 };\
- int shift = (shift_value[hmode]+shift_value[vmode])>>1;\
- int r;\
- DECLARE_ALIGNED(16, int16_t, tmp)[12*8];\
-\
- r = (1<<(shift-1)) + rnd-1;\
- vc1_put_shift_ver_16bits[vmode](tmp, src-1, stride, r, shift);\
-\
- vc1_put_shift_hor_16bits[hmode](dst, stride, tmp+1, 64-rnd);\
- return;\
- }\
- else { /* No horizontal filter, output 8 lines to dst */\
- vc1_put_shift_8bits[vmode](dst, src, stride, 1-rnd, stride);\
- return;\
- }\
- }\
-\
- /* Horizontal mode with no vertical mode */\
- vc1_put_shift_8bits[hmode](dst, src, stride, rnd, 1);\
-}
-
-VC1_MSPEL_MC(put_)
-VC1_MSPEL_MC(avg_)
-
-/** Macro to ease bicubic filter interpolation functions declarations */
-#define DECLARE_FUNCTION(a, b) \
-static void put_vc1_mspel_mc ## a ## b ## _mmx(uint8_t *dst, const uint8_t *src, int stride, int rnd) { \
- put_vc1_mspel_mc(dst, src, stride, a, b, rnd); \
-}\
-static void avg_vc1_mspel_mc ## a ## b ## _mmxext(uint8_t *dst, \
- const uint8_t *src, \
- int stride, int rnd) \
-{ \
- avg_vc1_mspel_mc(dst, src, stride, a, b, rnd); \
-}
-
-DECLARE_FUNCTION(0, 1)
-DECLARE_FUNCTION(0, 2)
-DECLARE_FUNCTION(0, 3)
-
-DECLARE_FUNCTION(1, 0)
-DECLARE_FUNCTION(1, 1)
-DECLARE_FUNCTION(1, 2)
-DECLARE_FUNCTION(1, 3)
-
-DECLARE_FUNCTION(2, 0)
-DECLARE_FUNCTION(2, 1)
-DECLARE_FUNCTION(2, 2)
-DECLARE_FUNCTION(2, 3)
-
-DECLARE_FUNCTION(3, 0)
-DECLARE_FUNCTION(3, 1)
-DECLARE_FUNCTION(3, 2)
-DECLARE_FUNCTION(3, 3)
-
-static void vc1_inv_trans_4x4_dc_mmxext(uint8_t *dest, int linesize,
- int16_t *block)
-{
- int dc = block[0];
- dc = (17 * dc + 4) >> 3;
- dc = (17 * dc + 64) >> 7;
- __asm__ volatile(
- "movd %0, %%mm0 \n\t"
- "pshufw $0, %%mm0, %%mm0 \n\t"
- "pxor %%mm1, %%mm1 \n\t"
- "psubw %%mm0, %%mm1 \n\t"
- "packuswb %%mm0, %%mm0 \n\t"
- "packuswb %%mm1, %%mm1 \n\t"
- ::"r"(dc)
- );
- __asm__ volatile(
- "movd %0, %%mm2 \n\t"
- "movd %1, %%mm3 \n\t"
- "movd %2, %%mm4 \n\t"
- "movd %3, %%mm5 \n\t"
- "paddusb %%mm0, %%mm2 \n\t"
- "paddusb %%mm0, %%mm3 \n\t"
- "paddusb %%mm0, %%mm4 \n\t"
- "paddusb %%mm0, %%mm5 \n\t"
- "psubusb %%mm1, %%mm2 \n\t"
- "psubusb %%mm1, %%mm3 \n\t"
- "psubusb %%mm1, %%mm4 \n\t"
- "psubusb %%mm1, %%mm5 \n\t"
- "movd %%mm2, %0 \n\t"
- "movd %%mm3, %1 \n\t"
- "movd %%mm4, %2 \n\t"
- "movd %%mm5, %3 \n\t"
- :"+m"(*(uint32_t*)(dest+0*linesize)),
- "+m"(*(uint32_t*)(dest+1*linesize)),
- "+m"(*(uint32_t*)(dest+2*linesize)),
- "+m"(*(uint32_t*)(dest+3*linesize))
- );
-}
-
-static void vc1_inv_trans_4x8_dc_mmxext(uint8_t *dest, int linesize,
- int16_t *block)
-{
- int dc = block[0];
- dc = (17 * dc + 4) >> 3;
- dc = (12 * dc + 64) >> 7;
- __asm__ volatile(
- "movd %0, %%mm0 \n\t"
- "pshufw $0, %%mm0, %%mm0 \n\t"
- "pxor %%mm1, %%mm1 \n\t"
- "psubw %%mm0, %%mm1 \n\t"
- "packuswb %%mm0, %%mm0 \n\t"
- "packuswb %%mm1, %%mm1 \n\t"
- ::"r"(dc)
- );
- __asm__ volatile(
- "movd %0, %%mm2 \n\t"
- "movd %1, %%mm3 \n\t"
- "movd %2, %%mm4 \n\t"
- "movd %3, %%mm5 \n\t"
- "paddusb %%mm0, %%mm2 \n\t"
- "paddusb %%mm0, %%mm3 \n\t"
- "paddusb %%mm0, %%mm4 \n\t"
- "paddusb %%mm0, %%mm5 \n\t"
- "psubusb %%mm1, %%mm2 \n\t"
- "psubusb %%mm1, %%mm3 \n\t"
- "psubusb %%mm1, %%mm4 \n\t"
- "psubusb %%mm1, %%mm5 \n\t"
- "movd %%mm2, %0 \n\t"
- "movd %%mm3, %1 \n\t"
- "movd %%mm4, %2 \n\t"
- "movd %%mm5, %3 \n\t"
- :"+m"(*(uint32_t*)(dest+0*linesize)),
- "+m"(*(uint32_t*)(dest+1*linesize)),
- "+m"(*(uint32_t*)(dest+2*linesize)),
- "+m"(*(uint32_t*)(dest+3*linesize))
- );
- dest += 4*linesize;
- __asm__ volatile(
- "movd %0, %%mm2 \n\t"
- "movd %1, %%mm3 \n\t"
- "movd %2, %%mm4 \n\t"
- "movd %3, %%mm5 \n\t"
- "paddusb %%mm0, %%mm2 \n\t"
- "paddusb %%mm0, %%mm3 \n\t"
- "paddusb %%mm0, %%mm4 \n\t"
- "paddusb %%mm0, %%mm5 \n\t"
- "psubusb %%mm1, %%mm2 \n\t"
- "psubusb %%mm1, %%mm3 \n\t"
- "psubusb %%mm1, %%mm4 \n\t"
- "psubusb %%mm1, %%mm5 \n\t"
- "movd %%mm2, %0 \n\t"
- "movd %%mm3, %1 \n\t"
- "movd %%mm4, %2 \n\t"
- "movd %%mm5, %3 \n\t"
- :"+m"(*(uint32_t*)(dest+0*linesize)),
- "+m"(*(uint32_t*)(dest+1*linesize)),
- "+m"(*(uint32_t*)(dest+2*linesize)),
- "+m"(*(uint32_t*)(dest+3*linesize))
- );
-}
-
-static void vc1_inv_trans_8x4_dc_mmxext(uint8_t *dest, int linesize,
- int16_t *block)
-{
- int dc = block[0];
- dc = ( 3 * dc + 1) >> 1;
- dc = (17 * dc + 64) >> 7;
- __asm__ volatile(
- "movd %0, %%mm0 \n\t"
- "pshufw $0, %%mm0, %%mm0 \n\t"
- "pxor %%mm1, %%mm1 \n\t"
- "psubw %%mm0, %%mm1 \n\t"
- "packuswb %%mm0, %%mm0 \n\t"
- "packuswb %%mm1, %%mm1 \n\t"
- ::"r"(dc)
- );
- __asm__ volatile(
- "movq %0, %%mm2 \n\t"
- "movq %1, %%mm3 \n\t"
- "movq %2, %%mm4 \n\t"
- "movq %3, %%mm5 \n\t"
- "paddusb %%mm0, %%mm2 \n\t"
- "paddusb %%mm0, %%mm3 \n\t"
- "paddusb %%mm0, %%mm4 \n\t"
- "paddusb %%mm0, %%mm5 \n\t"
- "psubusb %%mm1, %%mm2 \n\t"
- "psubusb %%mm1, %%mm3 \n\t"
- "psubusb %%mm1, %%mm4 \n\t"
- "psubusb %%mm1, %%mm5 \n\t"
- "movq %%mm2, %0 \n\t"
- "movq %%mm3, %1 \n\t"
- "movq %%mm4, %2 \n\t"
- "movq %%mm5, %3 \n\t"
- :"+m"(*(uint32_t*)(dest+0*linesize)),
- "+m"(*(uint32_t*)(dest+1*linesize)),
- "+m"(*(uint32_t*)(dest+2*linesize)),
- "+m"(*(uint32_t*)(dest+3*linesize))
- );
-}
-
-static void vc1_inv_trans_8x8_dc_mmxext(uint8_t *dest, int linesize,
- int16_t *block)
-{
- int dc = block[0];
- dc = (3 * dc + 1) >> 1;
- dc = (3 * dc + 16) >> 5;
- __asm__ volatile(
- "movd %0, %%mm0 \n\t"
- "pshufw $0, %%mm0, %%mm0 \n\t"
- "pxor %%mm1, %%mm1 \n\t"
- "psubw %%mm0, %%mm1 \n\t"
- "packuswb %%mm0, %%mm0 \n\t"
- "packuswb %%mm1, %%mm1 \n\t"
- ::"r"(dc)
- );
- __asm__ volatile(
- "movq %0, %%mm2 \n\t"
- "movq %1, %%mm3 \n\t"
- "movq %2, %%mm4 \n\t"
- "movq %3, %%mm5 \n\t"
- "paddusb %%mm0, %%mm2 \n\t"
- "paddusb %%mm0, %%mm3 \n\t"
- "paddusb %%mm0, %%mm4 \n\t"
- "paddusb %%mm0, %%mm5 \n\t"
- "psubusb %%mm1, %%mm2 \n\t"
- "psubusb %%mm1, %%mm3 \n\t"
- "psubusb %%mm1, %%mm4 \n\t"
- "psubusb %%mm1, %%mm5 \n\t"
- "movq %%mm2, %0 \n\t"
- "movq %%mm3, %1 \n\t"
- "movq %%mm4, %2 \n\t"
- "movq %%mm5, %3 \n\t"
- :"+m"(*(uint32_t*)(dest+0*linesize)),
- "+m"(*(uint32_t*)(dest+1*linesize)),
- "+m"(*(uint32_t*)(dest+2*linesize)),
- "+m"(*(uint32_t*)(dest+3*linesize))
- );
- dest += 4*linesize;
- __asm__ volatile(
- "movq %0, %%mm2 \n\t"
- "movq %1, %%mm3 \n\t"
- "movq %2, %%mm4 \n\t"
- "movq %3, %%mm5 \n\t"
- "paddusb %%mm0, %%mm2 \n\t"
- "paddusb %%mm0, %%mm3 \n\t"
- "paddusb %%mm0, %%mm4 \n\t"
- "paddusb %%mm0, %%mm5 \n\t"
- "psubusb %%mm1, %%mm2 \n\t"
- "psubusb %%mm1, %%mm3 \n\t"
- "psubusb %%mm1, %%mm4 \n\t"
- "psubusb %%mm1, %%mm5 \n\t"
- "movq %%mm2, %0 \n\t"
- "movq %%mm3, %1 \n\t"
- "movq %%mm4, %2 \n\t"
- "movq %%mm5, %3 \n\t"
- :"+m"(*(uint32_t*)(dest+0*linesize)),
- "+m"(*(uint32_t*)(dest+1*linesize)),
- "+m"(*(uint32_t*)(dest+2*linesize)),
- "+m"(*(uint32_t*)(dest+3*linesize))
- );
-}
-
-av_cold void ff_vc1dsp_init_mmx(VC1DSPContext *dsp)
-{
-#if HAVE_YASM
- dsp->put_vc1_mspel_pixels_tab[ 0] = ff_put_vc1_mspel_mc00_mmx;
-#endif /* HAVE_YASM */
- 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;
-}
-
-av_cold void ff_vc1dsp_init_mmxext(VC1DSPContext *dsp)
-{
-#if HAVE_YASM
- dsp->avg_vc1_mspel_pixels_tab[ 0] = ff_avg_vc1_mspel_mc00_mmxext;
-#endif /* HAVE_YASM */
- 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;
-
- 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;
-
- 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;
-
- 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;
-
- 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 */
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/videodsp.asm b/src/thirdparty/ffmpeg/libavcodec/x86/videodsp.asm
deleted file mode 100644
index 0eb4721c6..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/videodsp.asm
+++ /dev/null
@@ -1,612 +0,0 @@
-;******************************************************************************
-;* Core video DSP functions
-;* Copyright (c) 2012 Ronald S. Bultje <rsbultje@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 .text
-
-; extern void ff_emu_edge_core(uint8_t *buf, const uint8_t *src, x86_reg linesize,
-; x86_reg start_y, x86_reg end_y, x86_reg block_h,
-; x86_reg start_x, x86_reg end_x, x86_reg block_w);
-;
-; The actual function itself is below. It basically wraps a very simple
-; w = end_x - start_x
-; if (w) {
-; if (w > 22) {
-; jump to the slow loop functions
-; } else {
-; jump to the fast loop functions
-; }
-; }
-;
-; ... and then the same for left/right extend also. See below for loop
-; function implementations. Fast are fixed-width, slow is variable-width
-
-%macro EMU_EDGE_FUNC 0
-%if ARCH_X86_64
-%define w_reg r7
-cglobal emu_edge_core, 6, 9, 1
- mov r8, r5 ; save block_h
-%else
-%define w_reg r6
-cglobal emu_edge_core, 2, 7, 0
- mov r4, r4m ; end_y
- mov r5, r5m ; block_h
-%endif
-
- ; start with vertical extend (top/bottom) and body pixel copy
- mov w_reg, r7m
- sub w_reg, r6m ; w = start_x - end_x
- sub r5, r4
-%if ARCH_X86_64
- sub r4, r3
-%else
- sub r4, dword r3m
-%endif
- cmp w_reg, 22
- jg .slow_v_extend_loop
-%if ARCH_X86_32
- mov r2, r2m ; linesize
-%endif
- sal w_reg, 7 ; w * 128
-%ifdef PIC
- lea rax, [.emuedge_v_extend_1 - (.emuedge_v_extend_2 - .emuedge_v_extend_1)]
- add w_reg, rax
-%else
- lea w_reg, [.emuedge_v_extend_1 - (.emuedge_v_extend_2 - .emuedge_v_extend_1)+w_reg]
-%endif
- call w_reg ; fast top extend, body copy and bottom extend
-.v_extend_end:
-
- ; horizontal extend (left/right)
- mov w_reg, r6m ; start_x
- sub r0, w_reg
-%if ARCH_X86_64
- mov r3, r0 ; backup of buf+block_h*linesize
- mov r5, r8
-%else
- mov r0m, r0 ; backup of buf+block_h*linesize
- mov r5, r5m
-%endif
- test w_reg, w_reg
- jz .right_extend
- cmp w_reg, 22
- jg .slow_left_extend_loop
- mov r1, w_reg
- dec w_reg
- ; FIXME we can do a if size == 1 here if that makes any speed difference, test me
- sar w_reg, 1
- sal w_reg, 6
- ; r0=buf+block_h*linesize,r7(64)/r6(32)=start_x offset for funcs
- ; r6(rax)/r3(ebx)=val,r2=linesize,r1=start_x,r5=block_h
-%ifdef PIC
- lea rax, [.emuedge_extend_left_2]
- add w_reg, rax
-%else
- lea w_reg, [.emuedge_extend_left_2+w_reg]
-%endif
- call w_reg
-
- ; now r3(64)/r0(32)=buf,r2=linesize,r8/r5=block_h,r6/r3=val, r7/r6=end_x, r1=block_w
-.right_extend:
-%if ARCH_X86_32
- mov r0, r0m
- mov r5, r5m
-%endif
- mov w_reg, r7m ; end_x
- mov r1, r8m ; block_w
- mov r4, r1
- sub r1, w_reg
- jz .h_extend_end ; if (end_x == block_w) goto h_extend_end
- cmp r1, 22
- jg .slow_right_extend_loop
- dec r1
- ; FIXME we can do a if size == 1 here if that makes any speed difference, test me
- sar r1, 1
- sal r1, 6
-%ifdef PIC
- lea rax, [.emuedge_extend_right_2]
- add r1, rax
-%else
- lea r1, [.emuedge_extend_right_2+r1]
-%endif
- call r1
-.h_extend_end:
- RET
-
-%if ARCH_X86_64
-%define vall al
-%define valh ah
-%define valw ax
-%define valw2 r7w
-%define valw3 r3w
-%if WIN64
-%define valw4 r7w
-%else ; unix64
-%define valw4 r3w
-%endif
-%define vald eax
-%else
-%define vall bl
-%define valh bh
-%define valw bx
-%define valw2 r6w
-%define valw3 valw2
-%define valw4 valw3
-%define vald ebx
-%define stack_offset 0x14
-%endif
-
-%endmacro
-
-; macro to read/write a horizontal number of pixels (%2) to/from registers
-; on x86-64, - fills xmm0-15 for consecutive sets of 16 pixels
-; - if (%2 & 15 == 8) fills the last 8 bytes into rax
-; - else if (%2 & 8) fills 8 bytes into mm0
-; - if (%2 & 7 == 4) fills the last 4 bytes into rax
-; - else if (%2 & 4) fills 4 bytes into mm0-1
-; - if (%2 & 3 == 3) fills 2 bytes into r7/r3, and 1 into eax
-; (note that we're using r3 for body/bottom because it's a shorter
-; opcode, and then the loop fits in 128 bytes)
-; - else fills remaining bytes into rax
-; on x86-32, - fills mm0-7 for consecutive sets of 8 pixels
-; - if (%2 & 7 == 4) fills 4 bytes into ebx
-; - else if (%2 & 4) fills 4 bytes into mm0-7
-; - if (%2 & 3 == 3) fills 2 bytes into r6, and 1 into ebx
-; - else fills remaining bytes into ebx
-; writing data out is in the same way
-%macro READ_NUM_BYTES 2
-%assign %%src_off 0 ; offset in source buffer
-%assign %%smidx 0 ; mmx register idx
-%assign %%sxidx 0 ; xmm register idx
-
-%if cpuflag(sse)
-%rep %2/16
- movups xmm %+ %%sxidx, [r1+%%src_off]
-%assign %%src_off %%src_off+16
-%assign %%sxidx %%sxidx+1
-%endrep ; %2/16
-%endif
-
-%if ARCH_X86_64
-%if (%2-%%src_off) == 8
- mov rax, [r1+%%src_off]
-%assign %%src_off %%src_off+8
-%endif ; (%2-%%src_off) == 8
-%endif ; x86-64
-
-%rep (%2-%%src_off)/8
- movq mm %+ %%smidx, [r1+%%src_off]
-%assign %%src_off %%src_off+8
-%assign %%smidx %%smidx+1
-%endrep ; (%2-%%dst_off)/8
-
-%if (%2-%%src_off) == 4
- mov vald, [r1+%%src_off]
-%elif (%2-%%src_off) & 4
- movd mm %+ %%smidx, [r1+%%src_off]
-%assign %%src_off %%src_off+4
-%endif ; (%2-%%src_off) ==/& 4
-
-%if (%2-%%src_off) == 1
- mov vall, [r1+%%src_off]
-%elif (%2-%%src_off) == 2
- mov valw, [r1+%%src_off]
-%elif (%2-%%src_off) == 3
-%ifidn %1, top
- mov valw2, [r1+%%src_off]
-%elifidn %1, body
- mov valw3, [r1+%%src_off]
-%elifidn %1, bottom
- mov valw4, [r1+%%src_off]
-%endif ; %1 ==/!= top
- mov vall, [r1+%%src_off+2]
-%endif ; (%2-%%src_off) == 1/2/3
-%endmacro ; READ_NUM_BYTES
-
-%macro WRITE_NUM_BYTES 2
-%assign %%dst_off 0 ; offset in destination buffer
-%assign %%dmidx 0 ; mmx register idx
-%assign %%dxidx 0 ; xmm register idx
-
-%if cpuflag(sse)
-%rep %2/16
- movups [r0+%%dst_off], xmm %+ %%dxidx
-%assign %%dst_off %%dst_off+16
-%assign %%dxidx %%dxidx+1
-%endrep ; %2/16
-%endif
-
-%if ARCH_X86_64
-%if (%2-%%dst_off) == 8
- mov [r0+%%dst_off], rax
-%assign %%dst_off %%dst_off+8
-%endif ; (%2-%%dst_off) == 8
-%endif ; x86-64
-
-%rep (%2-%%dst_off)/8
- movq [r0+%%dst_off], mm %+ %%dmidx
-%assign %%dst_off %%dst_off+8
-%assign %%dmidx %%dmidx+1
-%endrep ; (%2-%%dst_off)/8
-
-%if (%2-%%dst_off) == 4
- mov [r0+%%dst_off], vald
-%elif (%2-%%dst_off) & 4
- movd [r0+%%dst_off], mm %+ %%dmidx
-%assign %%dst_off %%dst_off+4
-%endif ; (%2-%%dst_off) ==/& 4
-
-%if (%2-%%dst_off) == 1
- mov [r0+%%dst_off], vall
-%elif (%2-%%dst_off) == 2
- mov [r0+%%dst_off], valw
-%elif (%2-%%dst_off) == 3
-%ifidn %1, top
- mov [r0+%%dst_off], valw2
-%elifidn %1, body
- mov [r0+%%dst_off], valw3
-%elifidn %1, bottom
- mov [r0+%%dst_off], valw4
-%endif ; %1 ==/!= top
- mov [r0+%%dst_off+2], vall
-%endif ; (%2-%%dst_off) == 1/2/3
-%endmacro ; WRITE_NUM_BYTES
-
-; vertical top/bottom extend and body copy fast loops
-; these are function pointers to set-width line copy functions, i.e.
-; they read a fixed number of pixels into set registers, and write
-; those out into the destination buffer
-; r0=buf,r1=src,r2=linesize,r3(64)/r3m(32)=start_x,r4=end_y,r5=block_h
-; r6(eax/64)/r3(ebx/32)=val_reg
-%macro VERTICAL_EXTEND 0
-%assign %%n 1
-%rep 22
-ALIGN 128
-.emuedge_v_extend_ %+ %%n:
- ; extend pixels above body
-%if ARCH_X86_64
- test r3 , r3 ; if (!start_y)
- jz .emuedge_copy_body_ %+ %%n %+ _loop ; goto body
-%else ; ARCH_X86_32
- cmp dword r3m, 0
- je .emuedge_copy_body_ %+ %%n %+ _loop
-%endif ; ARCH_X86_64/32
- READ_NUM_BYTES top, %%n ; read bytes
-.emuedge_extend_top_ %+ %%n %+ _loop: ; do {
- WRITE_NUM_BYTES top, %%n ; write bytes
- add r0 , r2 ; dst += linesize
-%if ARCH_X86_64
- dec r3d
-%else ; ARCH_X86_32
- dec dword r3m
-%endif ; ARCH_X86_64/32
- jnz .emuedge_extend_top_ %+ %%n %+ _loop ; } while (--start_y)
-
- ; copy body pixels
-.emuedge_copy_body_ %+ %%n %+ _loop: ; do {
- READ_NUM_BYTES body, %%n ; read bytes
- WRITE_NUM_BYTES body, %%n ; write bytes
- add r0 , r2 ; dst += linesize
- add r1 , r2 ; src += linesize
- dec r4d
- jnz .emuedge_copy_body_ %+ %%n %+ _loop ; } while (--end_y)
-
- ; copy bottom pixels
- test r5 , r5 ; if (!block_h)
- jz .emuedge_v_extend_end_ %+ %%n ; goto end
- sub r1 , r2 ; src -= linesize
- READ_NUM_BYTES bottom, %%n ; read bytes
-.emuedge_extend_bottom_ %+ %%n %+ _loop: ; do {
- WRITE_NUM_BYTES bottom, %%n ; write bytes
- add r0 , r2 ; dst += linesize
- dec r5d
- jnz .emuedge_extend_bottom_ %+ %%n %+ _loop ; } while (--block_h)
-
-.emuedge_v_extend_end_ %+ %%n:
-%if ARCH_X86_64
- ret
-%else ; ARCH_X86_32
- rep ret
-%endif ; ARCH_X86_64/32
-%assign %%n %%n+1
-%endrep
-%endmacro VERTICAL_EXTEND
-
-; left/right (horizontal) fast extend functions
-; these are essentially identical to the vertical extend ones above,
-; just left/right separated because number of pixels to extend is
-; obviously not the same on both sides.
-; for reading, pixels are placed in eax (x86-64) or ebx (x86-64) in the
-; lowest two bytes of the register (so val*0x0101), and are splatted
-; into each byte of mm0 as well if n_pixels >= 8
-
-%macro READ_V_PIXEL 2
- mov vall, %2
- mov valh, vall
-%if %1 >= 8
- movd mm0, vald
-%if cpuflag(mmxext)
- pshufw mm0, mm0, 0
-%else ; mmx
- punpcklwd mm0, mm0
- punpckldq mm0, mm0
-%endif ; sse
-%endif ; %1 >= 8
-%endmacro
-
-%macro WRITE_V_PIXEL 2
-%assign %%dst_off 0
-%rep %1/8
- movq [%2+%%dst_off], mm0
-%assign %%dst_off %%dst_off+8
-%endrep
-%if %1 & 4
-%if %1 >= 8
- movd [%2+%%dst_off], mm0
-%else ; %1 < 8
- mov [%2+%%dst_off] , valw
- mov [%2+%%dst_off+2], valw
-%endif ; %1 >=/< 8
-%assign %%dst_off %%dst_off+4
-%endif ; %1 & 4
-%if %1&2
- mov [%2+%%dst_off], valw
-%endif ; %1 & 2
-%endmacro
-
-; r0=buf+block_h*linesize, r1=start_x, r2=linesize, r5=block_h, r6/r3=val
-%macro LEFT_EXTEND 0
-%assign %%n 2
-%rep 11
-ALIGN 64
-.emuedge_extend_left_ %+ %%n: ; do {
- sub r0, r2 ; dst -= linesize
- READ_V_PIXEL %%n, [r0+r1] ; read pixels
- WRITE_V_PIXEL %%n, r0 ; write pixels
- dec r5
- jnz .emuedge_extend_left_ %+ %%n ; } while (--block_h)
-%if ARCH_X86_64
- ret
-%else ; ARCH_X86_32
- rep ret
-%endif ; ARCH_X86_64/32
-%assign %%n %%n+2
-%endrep
-%endmacro ; LEFT_EXTEND
-
-; r3/r0=buf+block_h*linesize, r2=linesize, r8/r5=block_h, r0/r6=end_x, r6/r3=val
-%macro RIGHT_EXTEND 0
-%assign %%n 2
-%rep 11
-ALIGN 64
-.emuedge_extend_right_ %+ %%n: ; do {
-%if ARCH_X86_64
- sub r3, r2 ; dst -= linesize
- READ_V_PIXEL %%n, [r3+w_reg-1] ; read pixels
- WRITE_V_PIXEL %%n, r3+r4-%%n ; write pixels
- dec r8
-%else ; ARCH_X86_32
- sub r0, r2 ; dst -= linesize
- READ_V_PIXEL %%n, [r0+w_reg-1] ; read pixels
- WRITE_V_PIXEL %%n, r0+r4-%%n ; write pixels
- dec r5
-%endif ; ARCH_X86_64/32
- jnz .emuedge_extend_right_ %+ %%n ; } while (--block_h)
-%if ARCH_X86_64
- ret
-%else ; ARCH_X86_32
- rep ret
-%endif ; ARCH_X86_64/32
-%assign %%n %%n+2
-%endrep
-
-%if ARCH_X86_32
-%define stack_offset 0x10
-%endif
-%endmacro ; RIGHT_EXTEND
-
-; below follow the "slow" copy/extend functions, these act on a non-fixed
-; width specified in a register, and run a loop to copy the full amount
-; of bytes. They are optimized for copying of large amounts of pixels per
-; line, so they unconditionally splat data into mm registers to copy 8
-; bytes per loop iteration. It could be considered to use xmm for x86-64
-; also, but I haven't optimized this as much (i.e. FIXME)
-%macro V_COPY_NPX 4-5
-%if %0 == 4
- test w_reg, %4
- jz .%1_skip_%4_px
-%else ; %0 == 5
-.%1_%4_px_loop:
-%endif
- %3 %2, [r1+cnt_reg]
- %3 [r0+cnt_reg], %2
- add cnt_reg, %4
-%if %0 == 5
- sub w_reg, %4
- test w_reg, %5
- jnz .%1_%4_px_loop
-%endif
-.%1_skip_%4_px:
-%endmacro
-
-%macro V_COPY_ROW 2
-%ifidn %1, bottom
- sub r1, linesize
-%endif
-.%1_copy_loop:
- xor cnt_reg, cnt_reg
-%if notcpuflag(sse)
-%define linesize r2m
- V_COPY_NPX %1, mm0, movq, 8, 0xFFFFFFF8
-%else ; sse
- V_COPY_NPX %1, xmm0, movups, 16, 0xFFFFFFF0
-%if ARCH_X86_64
-%define linesize r2
- V_COPY_NPX %1, rax , mov, 8
-%else ; ARCH_X86_32
-%define linesize r2m
- V_COPY_NPX %1, mm0, movq, 8
-%endif ; ARCH_X86_64/32
-%endif ; sse
- V_COPY_NPX %1, vald, mov, 4
- V_COPY_NPX %1, valw, mov, 2
- V_COPY_NPX %1, vall, mov, 1
- mov w_reg, cnt_reg
-%ifidn %1, body
- add r1, linesize
-%endif
- add r0, linesize
- dec %2
- jnz .%1_copy_loop
-%endmacro
-
-%macro SLOW_V_EXTEND 0
-.slow_v_extend_loop:
-; r0=buf,r1=src,r2(64)/r2m(32)=linesize,r3(64)/r3m(32)=start_x,r4=end_y,r5=block_h
-; r8(64)/r3(later-64)/r2(32)=cnt_reg,r6(64)/r3(32)=val_reg,r7(64)/r6(32)=w=end_x-start_x
-%if ARCH_X86_64
- push r8 ; save old value of block_h
- test r3, r3
-%define cnt_reg r8
- jz .do_body_copy ; if (!start_y) goto do_body_copy
- V_COPY_ROW top, r3
-%else
- cmp dword r3m, 0
-%define cnt_reg r2
- je .do_body_copy ; if (!start_y) goto do_body_copy
- V_COPY_ROW top, dword r3m
-%endif
-
-.do_body_copy:
- V_COPY_ROW body, r4
-
-%if ARCH_X86_64
- pop r8 ; restore old value of block_h
-%define cnt_reg r3
-%endif
- test r5, r5
-%if ARCH_X86_64
- jz .v_extend_end
-%else
- jz .skip_bottom_extend
-%endif
- V_COPY_ROW bottom, r5
-%if ARCH_X86_32
-.skip_bottom_extend:
- mov r2, r2m
-%endif
- jmp .v_extend_end
-%endmacro
-
-%macro SLOW_LEFT_EXTEND 0
-.slow_left_extend_loop:
-; r0=buf+block_h*linesize,r2=linesize,r6(64)/r3(32)=val,r5=block_h,r4=cntr,r7/r6=start_x
- mov r4, 8
- sub r0, linesize
- READ_V_PIXEL 8, [r0+w_reg]
-.left_extend_8px_loop:
- movq [r0+r4-8], mm0
- add r4, 8
- cmp r4, w_reg
- jle .left_extend_8px_loop
- sub r4, 8
- cmp r4, w_reg
- jge .left_extend_loop_end
-.left_extend_2px_loop:
- mov [r0+r4], valw
- add r4, 2
- cmp r4, w_reg
- jl .left_extend_2px_loop
-.left_extend_loop_end:
- dec r5
- jnz .slow_left_extend_loop
-%if ARCH_X86_32
- mov r2, r2m
-%endif
- jmp .right_extend
-%endmacro
-
-%macro SLOW_RIGHT_EXTEND 0
-.slow_right_extend_loop:
-; r3(64)/r0(32)=buf+block_h*linesize,r2=linesize,r4=block_w,r8(64)/r5(32)=block_h,
-; r7(64)/r6(32)=end_x,r6/r3=val,r1=cntr
-%if ARCH_X86_64
-%define buf_reg r3
-%define bh_reg r8
-%else
-%define buf_reg r0
-%define bh_reg r5
-%endif
- lea r1, [r4-8]
- sub buf_reg, linesize
- READ_V_PIXEL 8, [buf_reg+w_reg-1]
-.right_extend_8px_loop:
- movq [buf_reg+r1], mm0
- sub r1, 8
- cmp r1, w_reg
- jge .right_extend_8px_loop
- add r1, 8
- cmp r1, w_reg
- je .right_extend_loop_end
-.right_extend_2px_loop:
- sub r1, 2
- mov [buf_reg+r1], valw
- cmp r1, w_reg
- jg .right_extend_2px_loop
-.right_extend_loop_end:
- dec bh_reg
- jnz .slow_right_extend_loop
- jmp .h_extend_end
-%endmacro
-
-%macro emu_edge 1
-INIT_XMM %1
-EMU_EDGE_FUNC
-VERTICAL_EXTEND
-LEFT_EXTEND
-RIGHT_EXTEND
-SLOW_V_EXTEND
-SLOW_LEFT_EXTEND
-SLOW_RIGHT_EXTEND
-%endmacro
-
-emu_edge sse
-%if ARCH_X86_32
-emu_edge mmx
-%endif
-
-%macro PREFETCH_FN 1
-cglobal prefetch, 3, 3, 0, buf, stride, h
-.loop:
- %1 [bufq]
- add bufq, strideq
- dec hd
- jg .loop
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-PREFETCH_FN prefetcht0
-%if ARCH_X86_32
-INIT_MMX 3dnow
-PREFETCH_FN prefetch
-%endif
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/videodsp_init.c b/src/thirdparty/ffmpeg/libavcodec/x86/videodsp_init.c
deleted file mode 100644
index 902450ea4..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/videodsp_init.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2002-2012 Michael Niedermayer
- * Copyright (C) 2012 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 "config.h"
-#include "libavutil/attributes.h"
-#include "libavutil/avassert.h"
-#include "libavutil/common.h"
-#include "libavutil/cpu.h"
-#include "libavutil/mem.h"
-#include "libavutil/x86/asm.h"
-#include "libavcodec/videodsp.h"
-
-#if HAVE_YASM
-typedef void emu_edge_core_func(uint8_t *buf, const uint8_t *src,
- x86_reg linesize, x86_reg start_y,
- x86_reg end_y, x86_reg block_h,
- x86_reg start_x, x86_reg end_x,
- x86_reg block_w);
-extern emu_edge_core_func ff_emu_edge_core_mmx;
-extern emu_edge_core_func ff_emu_edge_core_sse;
-
-static av_always_inline void emulated_edge_mc(uint8_t *buf, const uint8_t *src,
- ptrdiff_t linesize_arg,
- int block_w, int block_h,
- int src_x, int src_y,
- int w, int h,
- emu_edge_core_func *core_fn)
-{
- int start_y, start_x, end_y, end_x, src_y_add = 0;
- int linesize = linesize_arg;
-
- if(!w || !h)
- return;
-
- if (src_y >= h) {
- src -= src_y*linesize;
- src_y_add = h - 1;
- src_y = h - 1;
- } else if (src_y <= -block_h) {
- src -= src_y*linesize;
- src_y_add = 1 - block_h;
- src_y = 1 - block_h;
- }
- if (src_x >= w) {
- src += w - 1 - src_x;
- src_x = w - 1;
- } else if (src_x <= -block_w) {
- src += 1 - block_w - src_x;
- src_x = 1 - block_w;
- }
-
- start_y = FFMAX(0, -src_y);
- start_x = FFMAX(0, -src_x);
- end_y = FFMIN(block_h, h-src_y);
- end_x = FFMIN(block_w, w-src_x);
- av_assert2(start_x < end_x && block_w > 0);
- av_assert2(start_y < end_y && block_h > 0);
-
- // fill in the to-be-copied part plus all above/below
- src += (src_y_add + start_y) * linesize + start_x;
- buf += start_x;
- core_fn(buf, src, linesize, start_y, end_y,
- block_h, start_x, end_x, block_w);
-}
-
-#if ARCH_X86_32
-static av_noinline void emulated_edge_mc_mmx(uint8_t *buf, const uint8_t *src,
- ptrdiff_t linesize,
- int block_w, int block_h,
- int src_x, int src_y, int w, int h)
-{
- emulated_edge_mc(buf, src, linesize, block_w, block_h, src_x, src_y,
- w, h, &ff_emu_edge_core_mmx);
-}
-#endif
-
-static av_noinline void emulated_edge_mc_sse(uint8_t *buf, const uint8_t *src,
- ptrdiff_t linesize,
- int block_w, int block_h,
- int src_x, int src_y, int w, int h)
-{
- emulated_edge_mc(buf, src, linesize, block_w, block_h, src_x, src_y,
- w, h, &ff_emu_edge_core_sse);
-}
-#endif /* HAVE_YASM */
-
-void ff_prefetch_mmxext(uint8_t *buf, ptrdiff_t stride, int h);
-void ff_prefetch_3dnow(uint8_t *buf, ptrdiff_t stride, int h);
-
-av_cold void ff_videodsp_init_x86(VideoDSPContext *ctx, int bpc)
-{
-#if HAVE_YASM
- int mm_flags = av_get_cpu_flags();
-
-#if ARCH_X86_32
- if (bpc <= 8 && mm_flags & AV_CPU_FLAG_MMX) {
- ctx->emulated_edge_mc = emulated_edge_mc_mmx;
- }
- if (mm_flags & AV_CPU_FLAG_3DNOW) {
- ctx->prefetch = ff_prefetch_3dnow;
- }
-#endif /* ARCH_X86_32 */
- if (mm_flags & AV_CPU_FLAG_MMXEXT) {
- ctx->prefetch = ff_prefetch_mmxext;
- }
- if (bpc <= 8 && mm_flags & AV_CPU_FLAG_SSE) {
- ctx->emulated_edge_mc = emulated_edge_mc_sse;
- }
-#endif /* HAVE_YASM */
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/vorbisdsp.asm b/src/thirdparty/ffmpeg/libavcodec/x86/vorbisdsp.asm
deleted file mode 100644
index b25d83886..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/vorbisdsp.asm
+++ /dev/null
@@ -1,83 +0,0 @@
-;******************************************************************************
-;* Vorbis x86 optimizations
-;* Copyright (C) 2006 Loren Merritt <lorenm@u.washington.edu>
-;*
-;* 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
-
-pdw_80000000: times 4 dd 0x80000000
-
-SECTION .text
-
-%if ARCH_X86_32
-INIT_MMX 3dnow
-cglobal vorbis_inverse_coupling, 3, 3, 6, mag, ang, block_size
- pxor m7, m7
- lea magq, [magq+block_sizeq*4]
- lea angq, [angq+block_sizeq*4]
- neg block_sizeq
-.loop:
- mova m0, [magq+block_sizeq*4]
- mova m1, [angq+block_sizeq*4]
- mova m2, m0
- mova m3, m1
- pfcmpge m2, m7 ; m <= 0.0
- pfcmpge m3, m7 ; a <= 0.0
- pslld m2, 31 ; keep only the sign bit
- pxor m1, m2
- mova m4, m3
- pand m3, m1
- pandn m4, m1
- pfadd m3, m0 ; a = m + ((a < 0) & (a ^ sign(m)))
- pfsub m0, m4 ; m = m + ((a > 0) & (a ^ sign(m)))
- mova [angq+block_sizeq*4], m3
- mova [magq+block_sizeq*4], m0
- add block_sizeq, 2
- jl .loop
- femms
- RET
-%endif
-
-INIT_XMM sse
-cglobal vorbis_inverse_coupling, 3, 4, 6, mag, ang, block_size, cntr
- mova m5, [pdw_80000000]
- xor cntrq, cntrq
-align 16
-.loop:
- mova m0, [magq+cntrq*4]
- mova m1, [angq+cntrq*4]
- xorps m2, m2
- xorps m3, m3
- cmpleps m2, m0 ; m <= 0.0
- cmpleps m3, m1 ; a <= 0.0
- andps m2, m5 ; keep only the sign bit
- xorps m1, m2
- mova m4, m3
- andps m3, m1
- andnps m4, m1
- addps m3, m0 ; a = m + ((a < 0) & (a ^ sign(m)))
- subps m0, m4 ; m = m + ((a > 0) & (a ^ sign(m)))
- mova [angq+cntrq*4], m3
- mova [magq+cntrq*4], m0
- add cntrq, 4
- cmp cntrq, block_sizeq
- jl .loop
- RET
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/vorbisdsp_init.c b/src/thirdparty/ffmpeg/libavcodec/x86/vorbisdsp_init.c
deleted file mode 100644
index 08a2c096f..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/vorbisdsp_init.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2006 Loren Merritt <lorenm@u.washington.edu>
- *
- * 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/attributes.h"
-#include "libavutil/cpu.h"
-#include "libavcodec/vorbisdsp.h"
-
-void ff_vorbis_inverse_coupling_3dnow(float *mag, float *ang,
- intptr_t blocksize);
-void ff_vorbis_inverse_coupling_sse(float *mag, float *ang,
- intptr_t blocksize);
-
-av_cold void ff_vorbisdsp_init_x86(VorbisDSPContext *dsp)
-{
-#if HAVE_YASM
- int mm_flags = av_get_cpu_flags();
-
-#if ARCH_X86_32
- if (mm_flags & AV_CPU_FLAG_3DNOW)
- dsp->vorbis_inverse_coupling = ff_vorbis_inverse_coupling_3dnow;
-#endif /* ARCH_X86_32 */
- if (mm_flags & AV_CPU_FLAG_SSE)
- dsp->vorbis_inverse_coupling = ff_vorbis_inverse_coupling_sse;
-#endif /* HAVE_YASM */
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/vp3dsp.asm b/src/thirdparty/ffmpeg/libavcodec/x86/vp3dsp.asm
deleted file mode 100644
index a0a865a82..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/vp3dsp.asm
+++ /dev/null
@@ -1,667 +0,0 @@
-;******************************************************************************
-;* MMX/SSE2-optimized functions for the VP3 decoder
-;* Copyright (c) 2007 Aurelien Jacobs <aurel@gnuage.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/x86/x86util.asm"
-
-; MMX-optimized functions cribbed from the original VP3 source code.
-
-SECTION_RODATA
-
-vp3_idct_data: times 8 dw 64277
- times 8 dw 60547
- times 8 dw 54491
- times 8 dw 46341
- times 8 dw 36410
- times 8 dw 25080
- times 8 dw 12785
-
-cextern pb_1
-cextern pb_3
-cextern pb_7
-cextern pb_1F
-cextern pb_80
-cextern pb_81
-
-cextern pw_8
-
-SECTION .text
-
-; this is off by one or two for some cases when filter_limit is greater than 63
-; in: p0 in mm6, p1 in mm4, p2 in mm2, p3 in mm1
-; out: p1 in mm4, p2 in mm3
-%macro VP3_LOOP_FILTER 0
- movq m7, m6
- pand m6, [pb_7] ; p0&7
- psrlw m7, 3
- pand m7, [pb_1F] ; p0>>3
- movq m3, m2 ; p2
- pxor m2, m4
- pand m2, [pb_1] ; (p2^p1)&1
- movq m5, m2
- paddb m2, m2
- paddb m2, m5 ; 3*(p2^p1)&1
- paddb m2, m6 ; extra bits lost in shifts
- pcmpeqb m0, m0
- pxor m1, m0 ; 255 - p3
- pavgb m1, m2 ; (256 - p3 + extrabits) >> 1
- pxor m0, m4 ; 255 - p1
- pavgb m0, m3 ; (256 + p2-p1) >> 1
- paddb m1, [pb_3]
- pavgb m1, m0 ; 128+2+( p2-p1 - p3) >> 2
- pavgb m1, m0 ; 128+1+(3*(p2-p1) - p3) >> 3
- paddusb m7, m1 ; d+128+1
- movq m6, [pb_81]
- psubusb m6, m7
- psubusb m7, [pb_81]
-
- movq m5, [r2+516] ; flim
- pminub m6, m5
- pminub m7, m5
- movq m0, m6
- movq m1, m7
- paddb m6, m6
- paddb m7, m7
- pminub m6, m5
- pminub m7, m5
- psubb m6, m0
- psubb m7, m1
- paddusb m4, m7
- psubusb m4, m6
- psubusb m3, m7
- paddusb m3, m6
-%endmacro
-
-%macro STORE_4_WORDS 1
- movd r2d, %1
- mov [r0 -1], r2w
- psrlq %1, 32
- shr r2, 16
- mov [r0+r1 -1], r2w
- movd r2d, %1
- mov [r0+r1*2-1], r2w
- shr r2, 16
- mov [r0+r3 -1], r2w
-%endmacro
-
-INIT_MMX mmxext
-cglobal vp3_v_loop_filter, 3, 4
-%if ARCH_X86_64
- movsxd r1, r1d
-%endif
- mov r3, r1
- neg r1
- movq m6, [r0+r1*2]
- movq m4, [r0+r1 ]
- movq m2, [r0 ]
- movq m1, [r0+r3 ]
-
- VP3_LOOP_FILTER
-
- movq [r0+r1], m4
- movq [r0 ], m3
- RET
-
-cglobal vp3_h_loop_filter, 3, 4
-%if ARCH_X86_64
- movsxd r1, r1d
-%endif
- lea r3, [r1*3]
-
- movd m6, [r0 -2]
- movd m4, [r0+r1 -2]
- movd m2, [r0+r1*2-2]
- movd m1, [r0+r3 -2]
- lea r0, [r0+r1*4 ]
- punpcklbw m6, [r0 -2]
- punpcklbw m4, [r0+r1 -2]
- punpcklbw m2, [r0+r1*2-2]
- punpcklbw m1, [r0+r3 -2]
- sub r0, r3
- sub r0, r1
-
- TRANSPOSE4x4B 6, 4, 2, 1, 0
- VP3_LOOP_FILTER
- SBUTTERFLY bw, 4, 3, 5
-
- STORE_4_WORDS m4
- lea r0, [r0+r1*4 ]
- STORE_4_WORDS m3
- RET
-
-; from original comments: The Macro does IDct on 4 1-D Dcts
-%macro BeginIDCT 0
- movq m2, I(3)
- movq m6, C(3)
- movq m4, m2
- movq m7, J(5)
- pmulhw m4, m6 ; r4 = c3*i3 - i3
- movq m1, C(5)
- pmulhw m6, m7 ; r6 = c3*i5 - i5
- movq m5, m1
- pmulhw m1, m2 ; r1 = c5*i3 - i3
- movq m3, I(1)
- pmulhw m5, m7 ; r5 = c5*i5 - i5
- movq m0, C(1)
- paddw m4, m2 ; r4 = c3*i3
- paddw m6, m7 ; r6 = c3*i5
- paddw m2, m1 ; r2 = c5*i3
- movq m1, J(7)
- paddw m7, m5 ; r7 = c5*i5
- movq m5, m0 ; r5 = c1
- pmulhw m0, m3 ; r0 = c1*i1 - i1
- paddsw m4, m7 ; r4 = C = c3*i3 + c5*i5
- pmulhw m5, m1 ; r5 = c1*i7 - i7
- movq m7, C(7)
- psubsw m6, m2 ; r6 = D = c3*i5 - c5*i3
- paddw m0, m3 ; r0 = c1*i1
- pmulhw m3, m7 ; r3 = c7*i1
- movq m2, I(2)
- pmulhw m7, m1 ; r7 = c7*i7
- paddw m5, m1 ; r5 = c1*i7
- movq m1, m2 ; r1 = i2
- pmulhw m2, C(2) ; r2 = c2*i2 - i2
- psubsw m3, m5 ; r3 = B = c7*i1 - c1*i7
- movq m5, J(6)
- paddsw m0, m7 ; r0 = A = c1*i1 + c7*i7
- movq m7, m5 ; r7 = i6
- psubsw m0, m4 ; r0 = A - C
- pmulhw m5, C(2) ; r5 = c2*i6 - i6
- paddw m2, m1 ; r2 = c2*i2
- pmulhw m1, C(6) ; r1 = c6*i2
- paddsw m4, m4 ; r4 = C + C
- paddsw m4, m0 ; r4 = C. = A + C
- psubsw m3, m6 ; r3 = B - D
- paddw m5, m7 ; r5 = c2*i6
- paddsw m6, m6 ; r6 = D + D
- pmulhw m7, C(6) ; r7 = c6*i6
- paddsw m6, m3 ; r6 = D. = B + D
- movq I(1), m4 ; save C. at I(1)
- psubsw m1, m5 ; r1 = H = c6*i2 - c2*i6
- movq m4, C(4)
- movq m5, m3 ; r5 = B - D
- pmulhw m3, m4 ; r3 = (c4 - 1) * (B - D)
- paddsw m7, m2 ; r3 = (c4 - 1) * (B - D)
- movq I(2), m6 ; save D. at I(2)
- movq m2, m0 ; r2 = A - C
- movq m6, I(0)
- pmulhw m0, m4 ; r0 = (c4 - 1) * (A - C)
- paddw m5, m3 ; r5 = B. = c4 * (B - D)
- movq m3, J(4)
- psubsw m5, m1 ; r5 = B.. = B. - H
- paddw m2, m0 ; r0 = A. = c4 * (A - C)
- psubsw m6, m3 ; r6 = i0 - i4
- movq m0, m6
- pmulhw m6, m4 ; r6 = (c4 - 1) * (i0 - i4)
- paddsw m3, m3 ; r3 = i4 + i4
- paddsw m1, m1 ; r1 = H + H
- paddsw m3, m0 ; r3 = i0 + i4
- paddsw m1, m5 ; r1 = H. = B + H
- pmulhw m4, m3 ; r4 = (c4 - 1) * (i0 + i4)
- paddsw m6, m0 ; r6 = F = c4 * (i0 - i4)
- psubsw m6, m2 ; r6 = F. = F - A.
- paddsw m2, m2 ; r2 = A. + A.
- movq m0, I(1) ; r0 = C.
- paddsw m2, m6 ; r2 = A.. = F + A.
- paddw m4, m3 ; r4 = E = c4 * (i0 + i4)
- psubsw m2, m1 ; r2 = R2 = A.. - H.
-%endmacro
-
-; RowIDCT gets ready to transpose
-%macro RowIDCT 0
- BeginIDCT
- movq m3, I(2) ; r3 = D.
- psubsw m4, m7 ; r4 = E. = E - G
- paddsw m1, m1 ; r1 = H. + H.
- paddsw m7, m7 ; r7 = G + G
- paddsw m1, m2 ; r1 = R1 = A.. + H.
- paddsw m7, m4 ; r1 = R1 = A.. + H.
- psubsw m4, m3 ; r4 = R4 = E. - D.
- paddsw m3, m3
- psubsw m6, m5 ; r6 = R6 = F. - B..
- paddsw m5, m5
- paddsw m3, m4 ; r3 = R3 = E. + D.
- paddsw m5, m6 ; r5 = R5 = F. + B..
- psubsw m7, m0 ; r7 = R7 = G. - C.
- paddsw m0, m0
- movq I(1), m1 ; save R1
- paddsw m0, m7 ; r0 = R0 = G. + C.
-%endmacro
-
-; Column IDCT normalizes and stores final results
-%macro ColumnIDCT 0
- BeginIDCT
- paddsw m2, OC_8 ; adjust R2 (and R1) for shift
- paddsw m1, m1 ; r1 = H. + H.
- paddsw m1, m2 ; r1 = R1 = A.. + H.
- psraw m2, 4 ; r2 = NR2
- psubsw m4, m7 ; r4 = E. = E - G
- psraw m1, 4 ; r1 = NR2
- movq m3, I(2) ; r3 = D.
- paddsw m7, m7 ; r7 = G + G
- movq I(2), m2 ; store NR2 at I2
- paddsw m7, m4 ; r7 = G. = E + G
- movq I(1), m1 ; store NR1 at I1
- psubsw m4, m3 ; r4 = R4 = E. - D.
- paddsw m4, OC_8 ; adjust R4 (and R3) for shift
- paddsw m3, m3 ; r3 = D. + D.
- paddsw m3, m4 ; r3 = R3 = E. + D.
- psraw m4, 4 ; r4 = NR4
- psubsw m6, m5 ; r6 = R6 = F. - B..
- psraw m3, 4 ; r3 = NR3
- paddsw m6, OC_8 ; adjust R6 (and R5) for shift
- paddsw m5, m5 ; r5 = B.. + B..
- paddsw m5, m6 ; r5 = R5 = F. + B..
- psraw m6, 4 ; r6 = NR6
- movq J(4), m4 ; store NR4 at J4
- psraw m5, 4 ; r5 = NR5
- movq I(3), m3 ; store NR3 at I3
- psubsw m7, m0 ; r7 = R7 = G. - C.
- paddsw m7, OC_8 ; adjust R7 (and R0) for shift
- paddsw m0, m0 ; r0 = C. + C.
- paddsw m0, m7 ; r0 = R0 = G. + C.
- psraw m7, 4 ; r7 = NR7
- movq J(6), m6 ; store NR6 at J6
- psraw m0, 4 ; r0 = NR0
- movq J(5), m5 ; store NR5 at J5
- movq J(7), m7 ; store NR7 at J7
- movq I(0), m0 ; store NR0 at I0
-%endmacro
-
-; Following macro does two 4x4 transposes in place.
-;
-; At entry (we assume):
-;
-; r0 = a3 a2 a1 a0
-; I(1) = b3 b2 b1 b0
-; r2 = c3 c2 c1 c0
-; r3 = d3 d2 d1 d0
-;
-; r4 = e3 e2 e1 e0
-; r5 = f3 f2 f1 f0
-; r6 = g3 g2 g1 g0
-; r7 = h3 h2 h1 h0
-;
-; At exit, we have:
-;
-; I(0) = d0 c0 b0 a0
-; I(1) = d1 c1 b1 a1
-; I(2) = d2 c2 b2 a2
-; I(3) = d3 c3 b3 a3
-;
-; J(4) = h0 g0 f0 e0
-; J(5) = h1 g1 f1 e1
-; J(6) = h2 g2 f2 e2
-; J(7) = h3 g3 f3 e3
-;
-; I(0) I(1) I(2) I(3) is the transpose of r0 I(1) r2 r3.
-; J(4) J(5) J(6) J(7) is the transpose of r4 r5 r6 r7.
-;
-; Since r1 is free at entry, we calculate the Js first.
-%macro Transpose 0
- movq m1, m4 ; r1 = e3 e2 e1 e0
- punpcklwd m4, m5 ; r4 = f1 e1 f0 e0
- movq I(0), m0 ; save a3 a2 a1 a0
- punpckhwd m1, m5 ; r1 = f3 e3 f2 e2
- movq m0, m6 ; r0 = g3 g2 g1 g0
- punpcklwd m6, m7 ; r6 = h1 g1 h0 g0
- movq m5, m4 ; r5 = f1 e1 f0 e0
- punpckldq m4, m6 ; r4 = h0 g0 f0 e0 = R4
- punpckhdq m5, m6 ; r5 = h1 g1 f1 e1 = R5
- movq m6, m1 ; r6 = f3 e3 f2 e2
- movq J(4), m4
- punpckhwd m0, m7 ; r0 = h3 g3 h2 g2
- movq J(5), m5
- punpckhdq m6, m0 ; r6 = h3 g3 f3 e3 = R7
- movq m4, I(0) ; r4 = a3 a2 a1 a0
- punpckldq m1, m0 ; r1 = h2 g2 f2 e2 = R6
- movq m5, I(1) ; r5 = b3 b2 b1 b0
- movq m0, m4 ; r0 = a3 a2 a1 a0
- movq J(7), m6
- punpcklwd m0, m5 ; r0 = b1 a1 b0 a0
- movq J(6), m1
- punpckhwd m4, m5 ; r4 = b3 a3 b2 a2
- movq m5, m2 ; r5 = c3 c2 c1 c0
- punpcklwd m2, m3 ; r2 = d1 c1 d0 c0
- movq m1, m0 ; r1 = b1 a1 b0 a0
- punpckldq m0, m2 ; r0 = d0 c0 b0 a0 = R0
- punpckhdq m1, m2 ; r1 = d1 c1 b1 a1 = R1
- movq m2, m4 ; r2 = b3 a3 b2 a2
- movq I(0), m0
- punpckhwd m5, m3 ; r5 = d3 c3 d2 c2
- movq I(1), m1
- punpckhdq m4, m5 ; r4 = d3 c3 b3 a3 = R3
- punpckldq m2, m5 ; r2 = d2 c2 b2 a2 = R2
- movq I(3), m4
- movq I(2), m2
-%endmacro
-
-%macro VP3_1D_IDCT_SSE2 0
- movdqa m2, I(3) ; xmm2 = i3
- movdqa m6, C(3) ; xmm6 = c3
- movdqa m4, m2 ; xmm4 = i3
- movdqa m7, I(5) ; xmm7 = i5
- pmulhw m4, m6 ; xmm4 = c3 * i3 - i3
- movdqa m1, C(5) ; xmm1 = c5
- pmulhw m6, m7 ; xmm6 = c3 * i5 - i5
- movdqa m5, m1 ; xmm5 = c5
- pmulhw m1, m2 ; xmm1 = c5 * i3 - i3
- movdqa m3, I(1) ; xmm3 = i1
- pmulhw m5, m7 ; xmm5 = c5 * i5 - i5
- movdqa m0, C(1) ; xmm0 = c1
- paddw m4, m2 ; xmm4 = c3 * i3
- paddw m6, m7 ; xmm6 = c3 * i5
- paddw m2, m1 ; xmm2 = c5 * i3
- movdqa m1, I(7) ; xmm1 = i7
- paddw m7, m5 ; xmm7 = c5 * i5
- movdqa m5, m0 ; xmm5 = c1
- pmulhw m0, m3 ; xmm0 = c1 * i1 - i1
- paddsw m4, m7 ; xmm4 = c3 * i3 + c5 * i5 = C
- pmulhw m5, m1 ; xmm5 = c1 * i7 - i7
- movdqa m7, C(7) ; xmm7 = c7
- psubsw m6, m2 ; xmm6 = c3 * i5 - c5 * i3 = D
- paddw m0, m3 ; xmm0 = c1 * i1
- pmulhw m3, m7 ; xmm3 = c7 * i1
- movdqa m2, I(2) ; xmm2 = i2
- pmulhw m7, m1 ; xmm7 = c7 * i7
- paddw m5, m1 ; xmm5 = c1 * i7
- movdqa m1, m2 ; xmm1 = i2
- pmulhw m2, C(2) ; xmm2 = i2 * c2 -i2
- psubsw m3, m5 ; xmm3 = c7 * i1 - c1 * i7 = B
- movdqa m5, I(6) ; xmm5 = i6
- paddsw m0, m7 ; xmm0 = c1 * i1 + c7 * i7 = A
- movdqa m7, m5 ; xmm7 = i6
- psubsw m0, m4 ; xmm0 = A - C
- pmulhw m5, C(2) ; xmm5 = c2 * i6 - i6
- paddw m2, m1 ; xmm2 = i2 * c2
- pmulhw m1, C(6) ; xmm1 = c6 * i2
- paddsw m4, m4 ; xmm4 = C + C
- paddsw m4, m0 ; xmm4 = A + C = C.
- psubsw m3, m6 ; xmm3 = B - D
- paddw m5, m7 ; xmm5 = c2 * i6
- paddsw m6, m6 ; xmm6 = D + D
- pmulhw m7, C(6) ; xmm7 = c6 * i6
- paddsw m6, m3 ; xmm6 = B + D = D.
- movdqa I(1), m4 ; Save C. at I(1)
- psubsw m1, m5 ; xmm1 = c6 * i2 - c2 * i6 = H
- movdqa m4, C(4) ; xmm4 = C4
- movdqa m5, m3 ; xmm5 = B - D
- pmulhw m3, m4 ; xmm3 = ( c4 -1 ) * ( B - D )
- paddsw m7, m2 ; xmm7 = c2 * i2 + c6 * i6 = G
- movdqa I(2), m6 ; save D. at I(2)
- movdqa m2, m0 ; xmm2 = A - C
- movdqa m6, I(0) ; xmm6 = i0
- pmulhw m0, m4 ; xmm0 = ( c4 - 1 ) * ( A - C ) = A.
- paddw m5, m3 ; xmm5 = c4 * ( B - D ) = B.
- movdqa m3, I(4) ; xmm3 = i4
- psubsw m5, m1 ; xmm5 = B. - H = B..
- paddw m2, m0 ; xmm2 = c4 * ( A - C) = A.
- psubsw m6, m3 ; xmm6 = i0 - i4
- movdqa m0, m6 ; xmm0 = i0 - i4
- pmulhw m6, m4 ; xmm6 = (c4 - 1) * (i0 - i4) = F
- paddsw m3, m3 ; xmm3 = i4 + i4
- paddsw m1, m1 ; xmm1 = H + H
- paddsw m3, m0 ; xmm3 = i0 + i4
- paddsw m1, m5 ; xmm1 = B. + H = H.
- pmulhw m4, m3 ; xmm4 = ( c4 - 1 ) * ( i0 + i4 )
- paddw m6, m0 ; xmm6 = c4 * ( i0 - i4 )
- psubsw m6, m2 ; xmm6 = F - A. = F.
- paddsw m2, m2 ; xmm2 = A. + A.
- movdqa m0, I(1) ; Load C. from I(1)
- paddsw m2, m6 ; xmm2 = F + A. = A..
- paddw m4, m3 ; xmm4 = c4 * ( i0 + i4 ) = 3
- psubsw m2, m1 ; xmm2 = A.. - H. = R2
- ADD(m2) ; Adjust R2 and R1 before shifting
- paddsw m1, m1 ; xmm1 = H. + H.
- paddsw m1, m2 ; xmm1 = A.. + H. = R1
- SHIFT(m2) ; xmm2 = op2
- psubsw m4, m7 ; xmm4 = E - G = E.
- SHIFT(m1) ; xmm1 = op1
- movdqa m3, I(2) ; Load D. from I(2)
- paddsw m7, m7 ; xmm7 = G + G
- paddsw m7, m4 ; xmm7 = E + G = G.
- psubsw m4, m3 ; xmm4 = E. - D. = R4
- ADD(m4) ; Adjust R4 and R3 before shifting
- paddsw m3, m3 ; xmm3 = D. + D.
- paddsw m3, m4 ; xmm3 = E. + D. = R3
- SHIFT(m4) ; xmm4 = op4
- psubsw m6, m5 ; xmm6 = F. - B..= R6
- SHIFT(m3) ; xmm3 = op3
- ADD(m6) ; Adjust R6 and R5 before shifting
- paddsw m5, m5 ; xmm5 = B.. + B..
- paddsw m5, m6 ; xmm5 = F. + B.. = R5
- SHIFT(m6) ; xmm6 = op6
- SHIFT(m5) ; xmm5 = op5
- psubsw m7, m0 ; xmm7 = G. - C. = R7
- ADD(m7) ; Adjust R7 and R0 before shifting
- paddsw m0, m0 ; xmm0 = C. + C.
- paddsw m0, m7 ; xmm0 = G. + C.
- SHIFT(m7) ; xmm7 = op7
- SHIFT(m0) ; xmm0 = op0
-%endmacro
-
-%macro PUT_BLOCK 8
- movdqa O(0), m%1
- movdqa O(1), m%2
- movdqa O(2), m%3
- movdqa O(3), m%4
- movdqa O(4), m%5
- movdqa O(5), m%6
- movdqa O(6), m%7
- movdqa O(7), m%8
-%endmacro
-
-%macro VP3_IDCT 1
-%if mmsize == 16
-%define I(x) [%1+16*x]
-%define O(x) [%1+16*x]
-%define C(x) [vp3_idct_data+16*(x-1)]
-%define SHIFT(x)
-%define ADD(x)
- VP3_1D_IDCT_SSE2
-%if ARCH_X86_64
- TRANSPOSE8x8W 0, 1, 2, 3, 4, 5, 6, 7, 8
-%else
- TRANSPOSE8x8W 0, 1, 2, 3, 4, 5, 6, 7, [%1], [%1+16]
-%endif
- PUT_BLOCK 0, 1, 2, 3, 4, 5, 6, 7
-
-%define SHIFT(x) psraw x, 4
-%define ADD(x) paddsw x, [pw_8]
- VP3_1D_IDCT_SSE2
- PUT_BLOCK 0, 1, 2, 3, 4, 5, 6, 7
-%else ; mmsize == 8
- ; eax = quantized input
- ; ebx = dequantizer matrix
- ; ecx = IDCT constants
- ; M(I) = ecx + MaskOffset(0) + I * 8
- ; C(I) = ecx + CosineOffset(32) + (I-1) * 8
- ; edx = output
- ; r0..r7 = mm0..mm7
-%define OC_8 [pw_8]
-%define C(x) [vp3_idct_data+16*(x-1)]
-
- ; at this point, function has completed dequantization + dezigzag +
- ; partial transposition; now do the idct itself
-%define I(x) [%1+16* x ]
-%define J(x) [%1+16*(x-4)+8]
- RowIDCT
- Transpose
-
-%define I(x) [%1+16* x +64]
-%define J(x) [%1+16*(x-4)+72]
- RowIDCT
- Transpose
-
-%define I(x) [%1+16*x]
-%define J(x) [%1+16*x]
- ColumnIDCT
-
-%define I(x) [%1+16*x+8]
-%define J(x) [%1+16*x+8]
- ColumnIDCT
-%endif ; mmsize == 16/8
-%endmacro
-
-%macro vp3_idct_funcs 0
-cglobal vp3_idct_put, 3, 4, 9
- VP3_IDCT r2
-
- movsxdifnidn r1, r1d
- mova m4, [pb_80]
- lea r3, [r1*3]
-%assign %%i 0
-%rep 16/mmsize
- mova m0, [r2+mmsize*0+%%i]
- mova m1, [r2+mmsize*2+%%i]
- mova m2, [r2+mmsize*4+%%i]
- mova m3, [r2+mmsize*6+%%i]
- packsswb m0, [r2+mmsize*1+%%i]
- packsswb m1, [r2+mmsize*3+%%i]
- packsswb m2, [r2+mmsize*5+%%i]
- packsswb m3, [r2+mmsize*7+%%i]
- paddb m0, m4
- paddb m1, m4
- paddb m2, m4
- paddb m3, m4
- movq [r0 ], m0
-%if mmsize == 8
- movq [r0+r1 ], m1
- movq [r0+r1*2], m2
- movq [r0+r3 ], m3
-%else
- movhps [r0+r1 ], m0
- movq [r0+r1*2], m1
- movhps [r0+r3 ], m1
-%endif
-%if %%i == 0
- lea r0, [r0+r1*4]
-%endif
-%if mmsize == 16
- movq [r0 ], m2
- movhps [r0+r1 ], m2
- movq [r0+r1*2], m3
- movhps [r0+r3 ], m3
-%endif
-%assign %%i %%i+64
-%endrep
-
- pxor m0, m0
-%assign %%offset 0
-%rep 128/mmsize
- mova [r2+%%offset], m0
-%assign %%offset %%offset+mmsize
-%endrep
- RET
-
-cglobal vp3_idct_add, 3, 4, 9
- VP3_IDCT r2
-
- mov r3, 4
- pxor m4, m4
- movsxdifnidn r1, r1d
-.loop:
- movq m0, [r0]
- movq m1, [r0+r1]
-%if mmsize == 8
- mova m2, m0
- mova m3, m1
-%endif
- punpcklbw m0, m4
- punpcklbw m1, m4
-%if mmsize == 8
- punpckhbw m2, m4
- punpckhbw m3, m4
-%endif
- paddsw m0, [r2+ 0]
- paddsw m1, [r2+16]
-%if mmsize == 8
- paddsw m2, [r2+ 8]
- paddsw m3, [r2+24]
- packuswb m0, m2
- packuswb m1, m3
-%else ; mmsize == 16
- packuswb m0, m1
-%endif
- movq [r0 ], m0
-%if mmsize == 8
- movq [r0+r1], m1
-%else ; mmsize == 16
- movhps [r0+r1], m0
-%endif
- lea r0, [r0+r1*2]
-%assign %%offset 0
-%rep 32/mmsize
- mova [r2+%%offset], m4
-%assign %%offset %%offset+mmsize
-%endrep
- add r2, 32
- dec r3
- jg .loop
- RET
-%endmacro
-
-%if ARCH_X86_32
-INIT_MMX mmx
-vp3_idct_funcs
-%endif
-
-INIT_XMM sse2
-vp3_idct_funcs
-
-%macro DC_ADD 0
- movq m2, [r0 ]
- movq m3, [r0+r1 ]
- paddusb m2, m0
- movq m4, [r0+r1*2]
- paddusb m3, m0
- movq m5, [r0+r2 ]
- paddusb m4, m0
- paddusb m5, m0
- psubusb m2, m1
- psubusb m3, m1
- movq [r0 ], m2
- psubusb m4, m1
- movq [r0+r1 ], m3
- psubusb m5, m1
- movq [r0+r1*2], m4
- movq [r0+r2 ], m5
-%endmacro
-
-INIT_MMX mmxext
-cglobal vp3_idct_dc_add, 3, 4
-%if ARCH_X86_64
- movsxd r1, r1d
-%endif
- movsx r3, word [r2]
- mov word [r2], 0
- lea r2, [r1*3]
- add r3, 15
- sar r3, 5
- movd m0, r3d
- pshufw m0, m0, 0x0
- pxor m1, m1
- psubw m1, m0
- packuswb m0, m0
- packuswb m1, m1
- DC_ADD
- lea r0, [r0+r1*4]
- DC_ADD
- RET
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/vp3dsp_init.c b/src/thirdparty/ffmpeg/libavcodec/x86/vp3dsp_init.c
deleted file mode 100644
index 48801d63f..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/vp3dsp_init.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 2009 David Conrad <lessen42@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 <stdint.h>
-
-#include "libavutil/attributes.h"
-#include "libavutil/cpu.h"
-#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"
-
-void ff_vp3_idct_put_mmx(uint8_t *dest, int line_size, int16_t *block);
-void ff_vp3_idct_add_mmx(uint8_t *dest, int line_size, int16_t *block);
-
-void ff_vp3_idct_put_sse2(uint8_t *dest, int line_size, int16_t *block);
-void ff_vp3_idct_add_sse2(uint8_t *dest, int line_size, int16_t *block);
-
-void ff_vp3_idct_dc_add_mmxext(uint8_t *dest, int line_size,
- int16_t *block);
-
-void ff_vp3_v_loop_filter_mmxext(uint8_t *src, int stride,
- int *bounding_values);
-void ff_vp3_h_loop_filter_mmxext(uint8_t *src, int stride,
- int *bounding_values);
-
-#if HAVE_INLINE_ASM
-
-#define MOVQ_BFE(regd) \
- __asm__ volatile ( \
- "pcmpeqd %%"#regd", %%"#regd" \n\t" \
- "paddb %%"#regd", %%"#regd" \n\t" ::)
-
-#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"
-
-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
- MOVQ_BFE(mm6);
- __asm__ volatile(
- "1: \n\t"
- "movq (%1), %%mm0 \n\t"
- "movq (%2), %%mm1 \n\t"
- "movq (%1,%4), %%mm2 \n\t"
- "movq (%2,%4), %%mm3 \n\t"
- PAVGBP_MMX_NO_RND(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)
- "movq %%mm4, (%3) \n\t"
- "movq %%mm5, (%3,%4) \n\t"
-
- "movq (%1,%4,2), %%mm0 \n\t"
- "movq (%2,%4,2), %%mm1 \n\t"
- "movq (%1,%5), %%mm2 \n\t"
- "movq (%2,%5), %%mm3 \n\t"
- "lea (%1,%4,4), %1 \n\t"
- "lea (%2,%4,4), %2 \n\t"
- PAVGBP_MMX_NO_RND(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)
- "movq %%mm4, (%3,%4,2) \n\t"
- "movq %%mm5, (%3,%5) \n\t"
- "lea (%3,%4,4), %3 \n\t"
- "subl $4, %0 \n\t"
- "jnz 1b \n\t"
- :"+r"(h), "+r"(a), "+r"(b), "+r"(dst)
- :"r"((x86_reg)stride), "r"((x86_reg)3L*stride)
- :"memory");
-// STOP_TIMER("put_vp_no_rnd_pixels8_l2_mmx")
-}
-#endif /* HAVE_INLINE_ASM */
-
-av_cold void ff_vp3dsp_init_x86(VP3DSPContext *c, int flags)
-{
- int cpuflags = av_get_cpu_flags();
-
-#if HAVE_INLINE_ASM
- c->put_no_rnd_pixels_l2 = put_vp_no_rnd_pixels8_l2_mmx;
-#endif /* HAVE_INLINE_ASM */
-
-#if ARCH_X86_32
- if (EXTERNAL_MMX(cpuflags)) {
- c->idct_put = ff_vp3_idct_put_mmx;
- c->idct_add = ff_vp3_idct_add_mmx;
- c->idct_perm = FF_PARTTRANS_IDCT_PERM;
- }
-#endif
-
- if (EXTERNAL_MMXEXT(cpuflags)) {
- c->idct_dc_add = ff_vp3_idct_dc_add_mmxext;
-
- if (!(flags & CODEC_FLAG_BITEXACT)) {
- c->v_loop_filter = ff_vp3_v_loop_filter_mmxext;
- c->h_loop_filter = ff_vp3_h_loop_filter_mmxext;
- }
- }
-
- if (EXTERNAL_SSE2(cpuflags)) {
- c->idct_put = ff_vp3_idct_put_sse2;
- c->idct_add = ff_vp3_idct_add_sse2;
- c->idct_perm = FF_TRANSPOSE_IDCT_PERM;
- }
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/vp56_arith.h b/src/thirdparty/ffmpeg/libavcodec/x86/vp56_arith.h
deleted file mode 100644
index 2146d799e..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/vp56_arith.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * VP5 and VP6 compatible video decoder (arith decoder)
- *
- * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
- * Copyright (C) 2010 Eli Friedman
- *
- * 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_VP56_ARITH_H
-#define AVCODEC_X86_VP56_ARITH_H
-
-#if HAVE_INLINE_ASM && HAVE_FAST_CMOV
-#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_shift = low << 16;
- int bit = 0;
-
- __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)
- );
-
- c->high = high;
- c->code_word = code_word;
- return bit;
-}
-#endif
-
-#endif /* AVCODEC_X86_VP56_ARITH_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/vp56dsp.asm b/src/thirdparty/ffmpeg/libavcodec/x86/vp56dsp.asm
deleted file mode 100644
index 06b70e1ee..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/vp56dsp.asm
+++ /dev/null
@@ -1,170 +0,0 @@
-;******************************************************************************
-;* MMX/SSE2-optimized functions for the VP6 decoder
-;* Copyright (C) 2009 Sebastien Lucas <sebastien.lucas@gmail.com>
-;* Copyright (C) 2009 Zuxy Meng <zuxy.meng@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"
-
-cextern pw_64
-
-SECTION .text
-
-%macro DIAG4 6
-%if mmsize == 8
- movq m0, [%1+%2]
- movq m1, [%1+%3]
- movq m3, m0
- movq m4, m1
- punpcklbw m0, m7
- punpcklbw m1, m7
- punpckhbw m3, m7
- punpckhbw m4, m7
- pmullw m0, [rsp+8*11] ; src[x-8 ] * biweight [0]
- pmullw m1, [rsp+8*12] ; src[x ] * biweight [1]
- pmullw m3, [rsp+8*11] ; src[x-8 ] * biweight [0]
- pmullw m4, [rsp+8*12] ; src[x ] * biweight [1]
- paddw m0, m1
- paddw m3, m4
- movq m1, [%1+%4]
- movq m2, [%1+%5]
- movq m4, m1
- movq m5, m2
- punpcklbw m1, m7
- punpcklbw m2, m7
- punpckhbw m4, m7
- punpckhbw m5, m7
- pmullw m1, [rsp+8*13] ; src[x+8 ] * biweight [2]
- pmullw m2, [rsp+8*14] ; src[x+16] * biweight [3]
- pmullw m4, [rsp+8*13] ; src[x+8 ] * biweight [2]
- pmullw m5, [rsp+8*14] ; src[x+16] * biweight [3]
- paddw m1, m2
- paddw m4, m5
- paddsw m0, m1
- paddsw m3, m4
- paddsw m0, m6 ; Add 64
- paddsw m3, m6 ; Add 64
- psraw m0, 7
- psraw m3, 7
- packuswb m0, m3
- movq [%6], m0
-%else ; mmsize == 16
- movq m0, [%1+%2]
- movq m1, [%1+%3]
- punpcklbw m0, m7
- punpcklbw m1, m7
- pmullw m0, m4 ; src[x-8 ] * biweight [0]
- pmullw m1, m5 ; src[x ] * biweight [1]
- paddw m0, m1
- movq m1, [%1+%4]
- movq m2, [%1+%5]
- punpcklbw m1, m7
- punpcklbw m2, m7
- pmullw m1, m6 ; src[x+8 ] * biweight [2]
- pmullw m2, m3 ; src[x+16] * biweight [3]
- paddw m1, m2
- paddsw m0, m1
- paddsw m0, [pw_64] ; Add 64
- psraw m0, 7
- packuswb m0, m0
- movq [%6], m0
-%endif ; mmsize == 8/16
-%endmacro
-
-%macro SPLAT4REGS 0
-%if mmsize == 8
- movq m5, m3
- punpcklwd m3, m3
- movq m4, m3
- punpckldq m3, m3
- punpckhdq m4, m4
- punpckhwd m5, m5
- movq m2, m5
- punpckhdq m2, m2
- punpckldq m5, m5
- movq [rsp+8*11], m3
- movq [rsp+8*12], m4
- movq [rsp+8*13], m5
- movq [rsp+8*14], m2
-%else ; mmsize == 16
- pshuflw m4, m3, 0x0
- pshuflw m5, m3, 0x55
- pshuflw m6, m3, 0xAA
- pshuflw m3, m3, 0xFF
- punpcklqdq m4, m4
- punpcklqdq m5, m5
- punpcklqdq m6, m6
- punpcklqdq m3, m3
-%endif ; mmsize == 8/16
-%endmacro
-
-%macro vp6_filter_diag4 0
-; void ff_vp6_filter_diag4_<opt>(uint8_t *dst, uint8_t *src, int stride,
-; const int16_t h_weight[4], const int16_t v_weights[4])
-cglobal vp6_filter_diag4, 5, 7, 8
- mov r5, rsp ; backup stack pointer
- and rsp, ~(mmsize-1) ; align stack
-%if mmsize == 16
- sub rsp, 8*11
-%else
- sub rsp, 8*15
- movq m6, [pw_64]
-%endif
-%if ARCH_X86_64
- movsxd r2, r2d
-%endif
-
- sub r1, r2
-
- pxor m7, m7
- movq m3, [r3]
- SPLAT4REGS
-
- mov r3, rsp
- mov r6, 11
-.nextrow:
- DIAG4 r1, -1, 0, 1, 2, r3
- add r3, 8
- add r1, r2
- dec r6
- jnz .nextrow
-
- movq m3, [r4]
- SPLAT4REGS
-
- lea r3, [rsp+8]
- mov r6, 8
-.nextcol:
- DIAG4 r3, -8, 0, 8, 16, r0
- add r3, 8
- add r0, r2
- dec r6
- jnz .nextcol
-
- mov rsp, r5 ; restore stack pointer
- RET
-%endmacro
-
-%if ARCH_X86_32
-INIT_MMX mmx
-vp6_filter_diag4
-%endif
-
-INIT_XMM sse2
-vp6_filter_diag4
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/vp56dsp_init.c b/src/thirdparty/ffmpeg/libavcodec/x86/vp56dsp_init.c
deleted file mode 100644
index d8d58ab4a..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/vp56dsp_init.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * VP6 MMX/SSE2 optimizations
- * Copyright (C) 2009 Sebastien Lucas <sebastien.lucas@gmail.com>
- * Copyright (C) 2009 Zuxy Meng <zuxy.meng@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/cpu.h"
-#include "libavutil/x86/asm.h"
-#include "libavutil/x86/cpu.h"
-#include "libavcodec/dsputil.h"
-#include "libavcodec/vp56dsp.h"
-
-void ff_vp6_filter_diag4_mmx(uint8_t *dst, uint8_t *src, int stride,
- const int16_t *h_weights,const int16_t *v_weights);
-void ff_vp6_filter_diag4_sse2(uint8_t *dst, uint8_t *src, int stride,
- const int16_t *h_weights,const int16_t *v_weights);
-
-av_cold void ff_vp56dsp_init_x86(VP56DSPContext* c, enum AVCodecID codec)
-{
- int mm_flags = av_get_cpu_flags();
-
- if (CONFIG_VP6_DECODER && codec == AV_CODEC_ID_VP6) {
-#if ARCH_X86_32
- if (EXTERNAL_MMX(mm_flags)) {
- c->vp6_filter_diag4 = ff_vp6_filter_diag4_mmx;
- }
-#endif
-
- if (EXTERNAL_SSE2(mm_flags)) {
- c->vp6_filter_diag4 = ff_vp6_filter_diag4_sse2;
- }
- }
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/vp8dsp.asm b/src/thirdparty/ffmpeg/libavcodec/x86/vp8dsp.asm
deleted file mode 100644
index 0af4fdaea..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/vp8dsp.asm
+++ /dev/null
@@ -1,2781 +0,0 @@
-;******************************************************************************
-;* VP8 MMXEXT optimizations
-;* Copyright (c) 2010 Ronald S. Bultje <rsbultje@gmail.com>
-;* Copyright (c) 2010 Jason Garrett-Glaser <darkshikari@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
-
-fourtap_filter_hw_m: times 4 dw -6, 123
- times 4 dw 12, -1
- times 4 dw -9, 93
- times 4 dw 50, -6
- times 4 dw -6, 50
- times 4 dw 93, -9
- times 4 dw -1, 12
- times 4 dw 123, -6
-
-sixtap_filter_hw_m: times 4 dw 2, -11
- times 4 dw 108, 36
- times 4 dw -8, 1
- times 4 dw 3, -16
- times 4 dw 77, 77
- times 4 dw -16, 3
- times 4 dw 1, -8
- times 4 dw 36, 108
- times 4 dw -11, 2
-
-fourtap_filter_hb_m: times 8 db -6, 123
- times 8 db 12, -1
- times 8 db -9, 93
- times 8 db 50, -6
- times 8 db -6, 50
- times 8 db 93, -9
- times 8 db -1, 12
- times 8 db 123, -6
-
-sixtap_filter_hb_m: times 8 db 2, 1
- times 8 db -11, 108
- times 8 db 36, -8
- times 8 db 3, 3
- times 8 db -16, 77
- times 8 db 77, -16
- times 8 db 1, 2
- times 8 db -8, 36
- times 8 db 108, -11
-
-fourtap_filter_v_m: times 8 dw -6
- times 8 dw 123
- times 8 dw 12
- times 8 dw -1
- times 8 dw -9
- times 8 dw 93
- times 8 dw 50
- times 8 dw -6
- times 8 dw -6
- times 8 dw 50
- times 8 dw 93
- times 8 dw -9
- times 8 dw -1
- times 8 dw 12
- times 8 dw 123
- times 8 dw -6
-
-sixtap_filter_v_m: times 8 dw 2
- times 8 dw -11
- times 8 dw 108
- times 8 dw 36
- times 8 dw -8
- times 8 dw 1
- times 8 dw 3
- times 8 dw -16
- times 8 dw 77
- times 8 dw 77
- times 8 dw -16
- times 8 dw 3
- times 8 dw 1
- times 8 dw -8
- times 8 dw 36
- times 8 dw 108
- times 8 dw -11
- times 8 dw 2
-
-bilinear_filter_vw_m: times 8 dw 1
- times 8 dw 2
- times 8 dw 3
- times 8 dw 4
- times 8 dw 5
- times 8 dw 6
- times 8 dw 7
-
-bilinear_filter_vb_m: times 8 db 7, 1
- times 8 db 6, 2
- times 8 db 5, 3
- times 8 db 4, 4
- times 8 db 3, 5
- times 8 db 2, 6
- times 8 db 1, 7
-
-%ifdef PIC
-%define fourtap_filter_hw picregq
-%define sixtap_filter_hw picregq
-%define fourtap_filter_hb picregq
-%define sixtap_filter_hb picregq
-%define fourtap_filter_v picregq
-%define sixtap_filter_v picregq
-%define bilinear_filter_vw picregq
-%define bilinear_filter_vb picregq
-%define npicregs 1
-%else
-%define fourtap_filter_hw fourtap_filter_hw_m
-%define sixtap_filter_hw sixtap_filter_hw_m
-%define fourtap_filter_hb fourtap_filter_hb_m
-%define sixtap_filter_hb sixtap_filter_hb_m
-%define fourtap_filter_v fourtap_filter_v_m
-%define sixtap_filter_v sixtap_filter_v_m
-%define bilinear_filter_vw bilinear_filter_vw_m
-%define bilinear_filter_vb bilinear_filter_vb_m
-%define npicregs 0
-%endif
-
-filter_h2_shuf: db 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8
-filter_h4_shuf: db 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10
-
-filter_h6_shuf1: db 0, 5, 1, 6, 2, 7, 3, 8, 4, 9, 5, 10, 6, 11, 7, 12
-filter_h6_shuf2: db 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9
-filter_h6_shuf3: db 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11
-
-pw_256: times 8 dw 256
-
-pw_20091: times 4 dw 20091
-pw_17734: times 4 dw 17734
-
-pb_27_63: times 8 db 27, 63
-pb_18_63: times 8 db 18, 63
-pb_9_63: times 8 db 9, 63
-
-cextern pb_1
-cextern pw_3
-cextern pb_3
-cextern pw_4
-cextern pb_4
-cextern pw_9
-cextern pw_18
-cextern pw_27
-cextern pw_63
-cextern pw_64
-cextern pb_80
-cextern pb_F8
-cextern pb_FE
-
-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);
-;-----------------------------------------------------------------------------
-
-%macro FILTER_SSSE3 1
-cglobal put_vp8_epel%1_h6, 6, 6 + npicregs, 8, dst, dststride, src, srcstride, height, mx, picreg
- lea mxd, [mxq*3]
- mova m3, [filter_h6_shuf2]
- mova m4, [filter_h6_shuf3]
-%ifdef PIC
- lea picregq, [sixtap_filter_hb_m]
-%endif
- mova m5, [sixtap_filter_hb+mxq*8-48] ; set up 6tap filter in bytes
- mova m6, [sixtap_filter_hb+mxq*8-32]
- mova m7, [sixtap_filter_hb+mxq*8-16]
-
-.nextrow:
- movu m0, [srcq-2]
- mova m1, m0
- mova m2, m0
-%if mmsize == 8
-; For epel4, we need 9 bytes, but only 8 get loaded; to compensate, do the
-; shuffle with a memory operand
- punpcklbw m0, [srcq+3]
-%else
- pshufb m0, [filter_h6_shuf1]
-%endif
- pshufb m1, m3
- pshufb m2, m4
- pmaddubsw m0, m5
- pmaddubsw m1, m6
- pmaddubsw m2, m7
- paddsw m0, m1
- paddsw m0, m2
- pmulhrsw m0, [pw_256]
- packuswb m0, m0
- movh [dstq], m0 ; store
-
- ; go to next line
- add dstq, dststrideq
- add srcq, srcstrideq
- dec heightd ; next row
- jg .nextrow
- REP_RET
-
-cglobal put_vp8_epel%1_h4, 6, 6 + npicregs, 7, dst, dststride, src, srcstride, height, mx, picreg
- shl mxd, 4
- mova m2, [pw_256]
- mova m3, [filter_h2_shuf]
- mova m4, [filter_h4_shuf]
-%ifdef PIC
- lea picregq, [fourtap_filter_hb_m]
-%endif
- mova m5, [fourtap_filter_hb+mxq-16] ; set up 4tap filter in bytes
- mova m6, [fourtap_filter_hb+mxq]
-
-.nextrow:
- movu m0, [srcq-1]
- mova m1, m0
- pshufb m0, m3
- pshufb m1, m4
- pmaddubsw m0, m5
- pmaddubsw m1, m6
- paddsw m0, m1
- pmulhrsw m0, m2
- packuswb m0, m0
- movh [dstq], m0 ; store
-
- ; go to next line
- add dstq, dststrideq
- add srcq, srcstrideq
- dec heightd ; next row
- jg .nextrow
- REP_RET
-
-cglobal put_vp8_epel%1_v4, 7, 7, 8, dst, dststride, src, srcstride, height, picreg, my
- shl myd, 4
-%ifdef PIC
- lea picregq, [fourtap_filter_hb_m]
-%endif
- mova m5, [fourtap_filter_hb+myq-16]
- mova m6, [fourtap_filter_hb+myq]
- mova m7, [pw_256]
-
- ; read 3 lines
- sub srcq, srcstrideq
- movh m0, [srcq]
- movh m1, [srcq+ srcstrideq]
- movh m2, [srcq+2*srcstrideq]
- add srcq, srcstrideq
-
-.nextrow:
- movh m3, [srcq+2*srcstrideq] ; read new row
- mova m4, m0
- mova m0, m1
- punpcklbw m4, m1
- mova m1, m2
- punpcklbw m2, m3
- pmaddubsw m4, m5
- pmaddubsw m2, m6
- paddsw m4, m2
- mova m2, m3
- pmulhrsw m4, m7
- packuswb m4, m4
- movh [dstq], m4
-
- ; go to next line
- add dstq, dststrideq
- add srcq, srcstrideq
- dec heightd ; next row
- jg .nextrow
- REP_RET
-
-cglobal put_vp8_epel%1_v6, 7, 7, 8, dst, dststride, src, srcstride, height, picreg, my
- lea myd, [myq*3]
-%ifdef PIC
- lea picregq, [sixtap_filter_hb_m]
-%endif
- lea myq, [sixtap_filter_hb+myq*8]
-
- ; read 5 lines
- sub srcq, srcstrideq
- sub srcq, srcstrideq
- movh m0, [srcq]
- movh m1, [srcq+srcstrideq]
- movh m2, [srcq+srcstrideq*2]
- lea srcq, [srcq+srcstrideq*2]
- add srcq, srcstrideq
- movh m3, [srcq]
- movh m4, [srcq+srcstrideq]
-
-.nextrow:
- movh m5, [srcq+2*srcstrideq] ; read new row
- mova m6, m0
- punpcklbw m6, m5
- mova m0, m1
- punpcklbw m1, m2
- mova m7, m3
- punpcklbw m7, m4
- pmaddubsw m6, [myq-48]
- pmaddubsw m1, [myq-32]
- pmaddubsw m7, [myq-16]
- paddsw m6, m1
- paddsw m6, m7
- mova m1, m2
- mova m2, m3
- pmulhrsw m6, [pw_256]
- mova m3, m4
- packuswb m6, m6
- mova m4, m5
- movh [dstq], m6
-
- ; go to next line
- add dstq, dststrideq
- add srcq, srcstrideq
- dec heightd ; next row
- jg .nextrow
- REP_RET
-%endmacro
-
-INIT_MMX ssse3
-FILTER_SSSE3 4
-INIT_XMM ssse3
-FILTER_SSSE3 8
-
-; 4x4 block, H-only 4-tap filter
-INIT_MMX mmxext
-cglobal put_vp8_epel4_h4, 6, 6 + npicregs, 0, dst, dststride, src, srcstride, height, mx, picreg
- shl mxd, 4
-%ifdef PIC
- lea picregq, [fourtap_filter_hw_m]
-%endif
- movq mm4, [fourtap_filter_hw+mxq-16] ; set up 4tap filter in words
- movq mm5, [fourtap_filter_hw+mxq]
- movq mm7, [pw_64]
- pxor mm6, mm6
-
-.nextrow:
- movq mm1, [srcq-1] ; (ABCDEFGH) load 8 horizontal pixels
-
- ; first set of 2 pixels
- movq mm2, mm1 ; byte ABCD..
- punpcklbw mm1, mm6 ; byte->word ABCD
- pshufw mm0, mm2, 9 ; byte CDEF..
- punpcklbw mm0, mm6 ; byte->word CDEF
- pshufw mm3, mm1, 0x94 ; word ABBC
- pshufw mm1, mm0, 0x94 ; word CDDE
- pmaddwd mm3, mm4 ; multiply 2px with F0/F1
- movq mm0, mm1 ; backup for second set of pixels
- pmaddwd mm1, mm5 ; multiply 2px with F2/F3
- paddd mm3, mm1 ; finish 1st 2px
-
- ; second set of 2 pixels, use backup of above
- punpckhbw mm2, mm6 ; byte->word EFGH
- pmaddwd mm0, mm4 ; multiply backed up 2px with F0/F1
- pshufw mm1, mm2, 0x94 ; word EFFG
- pmaddwd mm1, mm5 ; multiply 2px with F2/F3
- paddd mm0, mm1 ; finish 2nd 2px
-
- ; merge two sets of 2 pixels into one set of 4, round/clip/store
- packssdw mm3, mm0 ; merge dword->word (4px)
- paddsw mm3, mm7 ; rounding
- psraw mm3, 7
- packuswb mm3, mm6 ; clip and word->bytes
- movd [dstq], mm3 ; store
-
- ; go to next line
- add dstq, dststrideq
- add srcq, srcstrideq
- dec heightd ; next row
- jg .nextrow
- REP_RET
-
-; 4x4 block, H-only 6-tap filter
-INIT_MMX mmxext
-cglobal put_vp8_epel4_h6, 6, 6 + npicregs, 0, dst, dststride, src, srcstride, height, mx, picreg
- lea mxd, [mxq*3]
-%ifdef PIC
- lea picregq, [sixtap_filter_hw_m]
-%endif
- movq mm4, [sixtap_filter_hw+mxq*8-48] ; set up 4tap filter in words
- movq mm5, [sixtap_filter_hw+mxq*8-32]
- movq mm6, [sixtap_filter_hw+mxq*8-16]
- movq mm7, [pw_64]
- pxor mm3, mm3
-
-.nextrow:
- movq mm1, [srcq-2] ; (ABCDEFGH) load 8 horizontal pixels
-
- ; first set of 2 pixels
- movq mm2, mm1 ; byte ABCD..
- punpcklbw mm1, mm3 ; byte->word ABCD
- pshufw mm0, mm2, 0x9 ; byte CDEF..
- punpckhbw mm2, mm3 ; byte->word EFGH
- punpcklbw mm0, mm3 ; byte->word CDEF
- pshufw mm1, mm1, 0x94 ; word ABBC
- pshufw mm2, mm2, 0x94 ; word EFFG
- pmaddwd mm1, mm4 ; multiply 2px with F0/F1
- pshufw mm3, mm0, 0x94 ; word CDDE
- movq mm0, mm3 ; backup for second set of pixels
- pmaddwd mm3, mm5 ; multiply 2px with F2/F3
- paddd mm1, mm3 ; add to 1st 2px cache
- movq mm3, mm2 ; backup for second set of pixels
- pmaddwd mm2, mm6 ; multiply 2px with F4/F5
- paddd mm1, mm2 ; finish 1st 2px
-
- ; second set of 2 pixels, use backup of above
- movd mm2, [srcq+3] ; byte FGHI (prevent overreads)
- pmaddwd mm0, mm4 ; multiply 1st backed up 2px with F0/F1
- pmaddwd mm3, mm5 ; multiply 2nd backed up 2px with F2/F3
- paddd mm0, mm3 ; add to 2nd 2px cache
- pxor mm3, mm3
- punpcklbw mm2, mm3 ; byte->word FGHI
- pshufw mm2, mm2, 0xE9 ; word GHHI
- pmaddwd mm2, mm6 ; multiply 2px with F4/F5
- paddd mm0, mm2 ; finish 2nd 2px
-
- ; merge two sets of 2 pixels into one set of 4, round/clip/store
- packssdw mm1, mm0 ; merge dword->word (4px)
- paddsw mm1, mm7 ; rounding
- psraw mm1, 7
- packuswb mm1, mm3 ; clip and word->bytes
- movd [dstq], mm1 ; store
-
- ; go to next line
- add dstq, dststrideq
- add srcq, srcstrideq
- dec heightd ; next row
- jg .nextrow
- REP_RET
-
-INIT_XMM sse2
-cglobal put_vp8_epel8_h4, 6, 6 + npicregs, 10, dst, dststride, src, srcstride, height, mx, picreg
- shl mxd, 5
-%ifdef PIC
- lea picregq, [fourtap_filter_v_m]
-%endif
- lea mxq, [fourtap_filter_v+mxq-32]
- pxor m7, m7
- mova m4, [pw_64]
- mova m5, [mxq+ 0]
- mova m6, [mxq+16]
-%ifdef m8
- mova m8, [mxq+32]
- mova m9, [mxq+48]
-%endif
-.nextrow:
- movq m0, [srcq-1]
- movq m1, [srcq-0]
- movq m2, [srcq+1]
- movq m3, [srcq+2]
- punpcklbw m0, m7
- punpcklbw m1, m7
- punpcklbw m2, m7
- punpcklbw m3, m7
- pmullw m0, m5
- pmullw m1, m6
-%ifdef m8
- pmullw m2, m8
- pmullw m3, m9
-%else
- pmullw m2, [mxq+32]
- pmullw m3, [mxq+48]
-%endif
- paddsw m0, m1
- paddsw m2, m3
- paddsw m0, m2
- paddsw m0, m4
- psraw m0, 7
- packuswb m0, m7
- movh [dstq], m0 ; store
-
- ; go to next line
- add dstq, dststrideq
- add srcq, srcstrideq
- dec heightd ; next row
- jg .nextrow
- REP_RET
-
-INIT_XMM sse2
-cglobal put_vp8_epel8_h6, 6, 6 + npicregs, 14, dst, dststride, src, srcstride, height, mx, picreg
- lea mxd, [mxq*3]
- shl mxd, 4
-%ifdef PIC
- lea picregq, [sixtap_filter_v_m]
-%endif
- lea mxq, [sixtap_filter_v+mxq-96]
- pxor m7, m7
- mova m6, [pw_64]
-%ifdef m8
- mova m8, [mxq+ 0]
- mova m9, [mxq+16]
- mova m10, [mxq+32]
- mova m11, [mxq+48]
- mova m12, [mxq+64]
- mova m13, [mxq+80]
-%endif
-.nextrow:
- movq m0, [srcq-2]
- movq m1, [srcq-1]
- movq m2, [srcq-0]
- movq m3, [srcq+1]
- movq m4, [srcq+2]
- movq m5, [srcq+3]
- punpcklbw m0, m7
- punpcklbw m1, m7
- punpcklbw m2, m7
- punpcklbw m3, m7
- punpcklbw m4, m7
- punpcklbw m5, m7
-%ifdef m8
- pmullw m0, m8
- pmullw m1, m9
- pmullw m2, m10
- pmullw m3, m11
- pmullw m4, m12
- pmullw m5, m13
-%else
- pmullw m0, [mxq+ 0]
- pmullw m1, [mxq+16]
- pmullw m2, [mxq+32]
- pmullw m3, [mxq+48]
- pmullw m4, [mxq+64]
- pmullw m5, [mxq+80]
-%endif
- paddsw m1, m4
- paddsw m0, m5
- paddsw m1, m2
- paddsw m0, m3
- paddsw m0, m1
- paddsw m0, m6
- psraw m0, 7
- packuswb m0, m7
- movh [dstq], m0 ; store
-
- ; go to next line
- add dstq, dststrideq
- add srcq, srcstrideq
- dec heightd ; next row
- jg .nextrow
- REP_RET
-
-%macro FILTER_V 1
-; 4x4 block, V-only 4-tap filter
-cglobal put_vp8_epel%1_v4, 7, 7, 8, dst, dststride, src, srcstride, height, picreg, my
- shl myd, 5
-%ifdef PIC
- lea picregq, [fourtap_filter_v_m]
-%endif
- lea myq, [fourtap_filter_v+myq-32]
- mova m6, [pw_64]
- pxor m7, m7
- mova m5, [myq+48]
-
- ; read 3 lines
- sub srcq, srcstrideq
- movh m0, [srcq]
- movh m1, [srcq+ srcstrideq]
- movh m2, [srcq+2*srcstrideq]
- add srcq, srcstrideq
- punpcklbw m0, m7
- punpcklbw m1, m7
- punpcklbw m2, m7
-
-.nextrow:
- ; first calculate negative taps (to prevent losing positive overflows)
- movh m4, [srcq+2*srcstrideq] ; read new row
- punpcklbw m4, m7
- mova m3, m4
- pmullw m0, [myq+0]
- pmullw m4, m5
- paddsw m4, m0
-
- ; then calculate positive taps
- mova m0, m1
- pmullw m1, [myq+16]
- paddsw m4, m1
- mova m1, m2
- pmullw m2, [myq+32]
- paddsw m4, m2
- mova m2, m3
-
- ; round/clip/store
- paddsw m4, m6
- psraw m4, 7
- packuswb m4, m7
- movh [dstq], m4
-
- ; go to next line
- add dstq, dststrideq
- add srcq, srcstrideq
- dec heightd ; next row
- jg .nextrow
- REP_RET
-
-
-; 4x4 block, V-only 6-tap filter
-cglobal put_vp8_epel%1_v6, 7, 7, 8, dst, dststride, src, srcstride, height, picreg, my
- shl myd, 4
- lea myq, [myq*3]
-%ifdef PIC
- lea picregq, [sixtap_filter_v_m]
-%endif
- lea myq, [sixtap_filter_v+myq-96]
- pxor m7, m7
-
- ; read 5 lines
- sub srcq, srcstrideq
- sub srcq, srcstrideq
- movh m0, [srcq]
- movh m1, [srcq+srcstrideq]
- movh m2, [srcq+srcstrideq*2]
- lea srcq, [srcq+srcstrideq*2]
- add srcq, srcstrideq
- movh m3, [srcq]
- movh m4, [srcq+srcstrideq]
- punpcklbw m0, m7
- punpcklbw m1, m7
- punpcklbw m2, m7
- punpcklbw m3, m7
- punpcklbw m4, m7
-
-.nextrow:
- ; first calculate negative taps (to prevent losing positive overflows)
- mova m5, m1
- pmullw m5, [myq+16]
- mova m6, m4
- pmullw m6, [myq+64]
- paddsw m6, m5
-
- ; then calculate positive taps
- movh m5, [srcq+2*srcstrideq] ; read new row
- punpcklbw m5, m7
- pmullw m0, [myq+0]
- paddsw m6, m0
- mova m0, m1
- mova m1, m2
- pmullw m2, [myq+32]
- paddsw m6, m2
- mova m2, m3
- pmullw m3, [myq+48]
- paddsw m6, m3
- mova m3, m4
- mova m4, m5
- pmullw m5, [myq+80]
- paddsw m6, m5
-
- ; round/clip/store
- paddsw m6, [pw_64]
- psraw m6, 7
- packuswb m6, m7
- movh [dstq], m6
-
- ; go to next line
- add dstq, dststrideq
- add srcq, srcstrideq
- dec heightd ; next row
- jg .nextrow
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-FILTER_V 4
-INIT_XMM sse2
-FILTER_V 8
-
-%macro FILTER_BILINEAR 1
-cglobal put_vp8_bilinear%1_v, 7, 7, 7, dst, dststride, src, srcstride, height, picreg, my
- shl myd, 4
-%ifdef PIC
- lea picregq, [bilinear_filter_vw_m]
-%endif
- pxor m6, m6
- mova m5, [bilinear_filter_vw+myq-1*16]
- neg myq
- mova m4, [bilinear_filter_vw+myq+7*16]
-.nextrow:
- movh m0, [srcq+srcstrideq*0]
- movh m1, [srcq+srcstrideq*1]
- movh m3, [srcq+srcstrideq*2]
- punpcklbw m0, m6
- punpcklbw m1, m6
- punpcklbw m3, m6
- mova m2, m1
- pmullw m0, m4
- pmullw m1, m5
- pmullw m2, m4
- pmullw m3, m5
- paddsw m0, m1
- paddsw m2, m3
- psraw m0, 2
- psraw m2, 2
- pavgw m0, m6
- pavgw m2, m6
-%if mmsize == 8
- packuswb m0, m0
- packuswb m2, m2
- movh [dstq+dststrideq*0], m0
- movh [dstq+dststrideq*1], m2
-%else
- packuswb m0, m2
- movh [dstq+dststrideq*0], m0
- movhps [dstq+dststrideq*1], m0
-%endif
-
- lea dstq, [dstq+dststrideq*2]
- lea srcq, [srcq+srcstrideq*2]
- sub heightd, 2
- jg .nextrow
- REP_RET
-
-cglobal put_vp8_bilinear%1_h, 6, 6 + npicregs, 7, dst, dststride, src, srcstride, height, mx, picreg
- shl mxd, 4
-%ifdef PIC
- lea picregq, [bilinear_filter_vw_m]
-%endif
- pxor m6, m6
- mova m5, [bilinear_filter_vw+mxq-1*16]
- neg mxq
- mova m4, [bilinear_filter_vw+mxq+7*16]
-.nextrow:
- movh m0, [srcq+srcstrideq*0+0]
- movh m1, [srcq+srcstrideq*0+1]
- movh m2, [srcq+srcstrideq*1+0]
- movh m3, [srcq+srcstrideq*1+1]
- punpcklbw m0, m6
- punpcklbw m1, m6
- punpcklbw m2, m6
- punpcklbw m3, m6
- pmullw m0, m4
- pmullw m1, m5
- pmullw m2, m4
- pmullw m3, m5
- paddsw m0, m1
- paddsw m2, m3
- psraw m0, 2
- psraw m2, 2
- pavgw m0, m6
- pavgw m2, m6
-%if mmsize == 8
- packuswb m0, m0
- packuswb m2, m2
- movh [dstq+dststrideq*0], m0
- movh [dstq+dststrideq*1], m2
-%else
- packuswb m0, m2
- movh [dstq+dststrideq*0], m0
- movhps [dstq+dststrideq*1], m0
-%endif
-
- lea dstq, [dstq+dststrideq*2]
- lea srcq, [srcq+srcstrideq*2]
- sub heightd, 2
- jg .nextrow
- REP_RET
-%endmacro
-
-INIT_MMX mmxext
-FILTER_BILINEAR 4
-INIT_XMM sse2
-FILTER_BILINEAR 8
-
-%macro FILTER_BILINEAR_SSSE3 1
-cglobal put_vp8_bilinear%1_v, 7, 7, 5, dst, dststride, src, srcstride, height, picreg, my
- shl myd, 4
-%ifdef PIC
- lea picregq, [bilinear_filter_vb_m]
-%endif
- pxor m4, m4
- mova m3, [bilinear_filter_vb+myq-16]
-.nextrow:
- movh m0, [srcq+srcstrideq*0]
- movh m1, [srcq+srcstrideq*1]
- movh m2, [srcq+srcstrideq*2]
- punpcklbw m0, m1
- punpcklbw m1, m2
- pmaddubsw m0, m3
- pmaddubsw m1, m3
- psraw m0, 2
- psraw m1, 2
- pavgw m0, m4
- pavgw m1, m4
-%if mmsize==8
- packuswb m0, m0
- packuswb m1, m1
- movh [dstq+dststrideq*0], m0
- movh [dstq+dststrideq*1], m1
-%else
- packuswb m0, m1
- movh [dstq+dststrideq*0], m0
- movhps [dstq+dststrideq*1], m0
-%endif
-
- lea dstq, [dstq+dststrideq*2]
- lea srcq, [srcq+srcstrideq*2]
- sub heightd, 2
- jg .nextrow
- REP_RET
-
-cglobal put_vp8_bilinear%1_h, 6, 6 + npicregs, 5, dst, dststride, src, srcstride, height, mx, picreg
- shl mxd, 4
-%ifdef PIC
- lea picregq, [bilinear_filter_vb_m]
-%endif
- pxor m4, m4
- mova m2, [filter_h2_shuf]
- mova m3, [bilinear_filter_vb+mxq-16]
-.nextrow:
- movu m0, [srcq+srcstrideq*0]
- movu m1, [srcq+srcstrideq*1]
- pshufb m0, m2
- pshufb m1, m2
- pmaddubsw m0, m3
- pmaddubsw m1, m3
- psraw m0, 2
- psraw m1, 2
- pavgw m0, m4
- pavgw m1, m4
-%if mmsize==8
- packuswb m0, m0
- packuswb m1, m1
- movh [dstq+dststrideq*0], m0
- movh [dstq+dststrideq*1], m1
-%else
- packuswb m0, m1
- movh [dstq+dststrideq*0], m0
- movhps [dstq+dststrideq*1], m0
-%endif
-
- lea dstq, [dstq+dststrideq*2]
- lea srcq, [srcq+srcstrideq*2]
- sub heightd, 2
- jg .nextrow
- REP_RET
-%endmacro
-
-INIT_MMX ssse3
-FILTER_BILINEAR_SSSE3 4
-INIT_XMM ssse3
-FILTER_BILINEAR_SSSE3 8
-
-INIT_MMX mmx
-cglobal put_vp8_pixels8, 5, 5, 0, dst, dststride, src, srcstride, height
-.nextrow:
- movq mm0, [srcq+srcstrideq*0]
- movq mm1, [srcq+srcstrideq*1]
- lea srcq, [srcq+srcstrideq*2]
- movq [dstq+dststrideq*0], mm0
- movq [dstq+dststrideq*1], mm1
- lea dstq, [dstq+dststrideq*2]
- sub heightd, 2
- jg .nextrow
- REP_RET
-
-%if ARCH_X86_32
-INIT_MMX mmx
-cglobal put_vp8_pixels16, 5, 5, 0, dst, dststride, src, srcstride, height
-.nextrow:
- movq mm0, [srcq+srcstrideq*0+0]
- movq mm1, [srcq+srcstrideq*0+8]
- movq mm2, [srcq+srcstrideq*1+0]
- movq mm3, [srcq+srcstrideq*1+8]
- lea srcq, [srcq+srcstrideq*2]
- movq [dstq+dststrideq*0+0], mm0
- movq [dstq+dststrideq*0+8], mm1
- movq [dstq+dststrideq*1+0], mm2
- movq [dstq+dststrideq*1+8], mm3
- lea dstq, [dstq+dststrideq*2]
- sub heightd, 2
- jg .nextrow
- REP_RET
-%endif
-
-INIT_XMM sse
-cglobal put_vp8_pixels16, 5, 5, 2, dst, dststride, src, srcstride, height
-.nextrow:
- movups xmm0, [srcq+srcstrideq*0]
- movups xmm1, [srcq+srcstrideq*1]
- lea srcq, [srcq+srcstrideq*2]
- movaps [dstq+dststrideq*0], xmm0
- movaps [dstq+dststrideq*1], xmm1
- lea dstq, [dstq+dststrideq*2]
- sub heightd, 2
- jg .nextrow
- REP_RET
-
-;-----------------------------------------------------------------------------
-; void vp8_idct_dc_add_<opt>(uint8_t *dst, int16_t block[16], int stride);
-;-----------------------------------------------------------------------------
-
-%macro ADD_DC 4
- %4 m2, [dst1q+%3]
- %4 m3, [dst1q+strideq+%3]
- %4 m4, [dst2q+%3]
- %4 m5, [dst2q+strideq+%3]
- paddusb m2, %1
- paddusb m3, %1
- paddusb m4, %1
- paddusb m5, %1
- psubusb m2, %2
- psubusb m3, %2
- psubusb m4, %2
- psubusb m5, %2
- %4 [dst1q+%3], m2
- %4 [dst1q+strideq+%3], m3
- %4 [dst2q+%3], m4
- %4 [dst2q+strideq+%3], m5
-%endmacro
-
-INIT_MMX mmx
-cglobal vp8_idct_dc_add, 3, 3, 0, dst, block, stride
- ; load data
- movd m0, [blockq]
-
- ; calculate DC
- paddw m0, [pw_4]
- pxor m1, m1
- psraw m0, 3
- movd [blockq], m1
- psubw m1, m0
- packuswb m0, m0
- packuswb m1, m1
- punpcklbw m0, m0
- punpcklbw m1, m1
- punpcklwd m0, m0
- punpcklwd m1, m1
-
- ; add DC
- DEFINE_ARGS dst1, dst2, stride
- lea dst2q, [dst1q+strideq*2]
- ADD_DC m0, m1, 0, movh
- RET
-
-INIT_XMM sse4
-cglobal vp8_idct_dc_add, 3, 3, 6, dst, block, stride
- ; load data
- movd m0, [blockq]
- pxor m1, m1
-
- ; calculate DC
- paddw m0, [pw_4]
- movd [blockq], m1
- DEFINE_ARGS dst1, dst2, stride
- lea dst2q, [dst1q+strideq*2]
- movd m2, [dst1q]
- movd m3, [dst1q+strideq]
- movd m4, [dst2q]
- movd m5, [dst2q+strideq]
- psraw m0, 3
- pshuflw m0, m0, 0
- punpcklqdq m0, m0
- punpckldq m2, m3
- punpckldq m4, m5
- punpcklbw m2, m1
- punpcklbw m4, m1
- paddw m2, m0
- paddw m4, m0
- packuswb m2, m4
- movd [dst1q], m2
- pextrd [dst1q+strideq], m2, 1
- pextrd [dst2q], m2, 2
- pextrd [dst2q+strideq], m2, 3
- RET
-
-;-----------------------------------------------------------------------------
-; void vp8_idct_dc_add4y_<opt>(uint8_t *dst, int16_t block[4][16], int stride);
-;-----------------------------------------------------------------------------
-
-%if ARCH_X86_32
-INIT_MMX mmx
-cglobal vp8_idct_dc_add4y, 3, 3, 0, dst, block, stride
- ; load data
- movd m0, [blockq+32*0] ; A
- movd m1, [blockq+32*2] ; C
- punpcklwd m0, [blockq+32*1] ; A B
- punpcklwd m1, [blockq+32*3] ; C D
- punpckldq m0, m1 ; A B C D
- pxor m6, m6
-
- ; calculate DC
- paddw m0, [pw_4]
- movd [blockq+32*0], m6
- movd [blockq+32*1], m6
- movd [blockq+32*2], m6
- movd [blockq+32*3], m6
- psraw m0, 3
- psubw m6, m0
- packuswb m0, m0
- packuswb m6, m6
- punpcklbw m0, m0 ; AABBCCDD
- punpcklbw m6, m6 ; AABBCCDD
- movq m1, m0
- movq m7, m6
- punpcklbw m0, m0 ; AAAABBBB
- punpckhbw m1, m1 ; CCCCDDDD
- punpcklbw m6, m6 ; AAAABBBB
- punpckhbw m7, m7 ; CCCCDDDD
-
- ; add DC
- DEFINE_ARGS dst1, dst2, stride
- lea dst2q, [dst1q+strideq*2]
- ADD_DC m0, m6, 0, mova
- ADD_DC m1, m7, 8, mova
- RET
-%endif
-
-INIT_XMM sse2
-cglobal vp8_idct_dc_add4y, 3, 3, 6, dst, block, stride
- ; load data
- movd m0, [blockq+32*0] ; A
- movd m1, [blockq+32*2] ; C
- punpcklwd m0, [blockq+32*1] ; A B
- punpcklwd m1, [blockq+32*3] ; C D
- punpckldq m0, m1 ; A B C D
- pxor m1, m1
-
- ; calculate DC
- paddw m0, [pw_4]
- movd [blockq+32*0], m1
- movd [blockq+32*1], m1
- movd [blockq+32*2], m1
- movd [blockq+32*3], m1
- psraw m0, 3
- psubw m1, m0
- packuswb m0, m0
- packuswb m1, m1
- punpcklbw m0, m0
- punpcklbw m1, m1
- punpcklbw m0, m0
- punpcklbw m1, m1
-
- ; add DC
- DEFINE_ARGS dst1, dst2, stride
- lea dst2q, [dst1q+strideq*2]
- ADD_DC m0, m1, 0, mova
- RET
-
-;-----------------------------------------------------------------------------
-; void vp8_idct_dc_add4uv_<opt>(uint8_t *dst, int16_t block[4][16], int stride);
-;-----------------------------------------------------------------------------
-
-INIT_MMX mmx
-cglobal vp8_idct_dc_add4uv, 3, 3, 0, dst, block, stride
- ; load data
- movd m0, [blockq+32*0] ; A
- movd m1, [blockq+32*2] ; C
- punpcklwd m0, [blockq+32*1] ; A B
- punpcklwd m1, [blockq+32*3] ; C D
- punpckldq m0, m1 ; A B C D
- pxor m6, m6
-
- ; calculate DC
- paddw m0, [pw_4]
- movd [blockq+32*0], m6
- movd [blockq+32*1], m6
- movd [blockq+32*2], m6
- movd [blockq+32*3], m6
- psraw m0, 3
- psubw m6, m0
- packuswb m0, m0
- packuswb m6, m6
- punpcklbw m0, m0 ; AABBCCDD
- punpcklbw m6, m6 ; AABBCCDD
- movq m1, m0
- movq m7, m6
- punpcklbw m0, m0 ; AAAABBBB
- punpckhbw m1, m1 ; CCCCDDDD
- punpcklbw m6, m6 ; AAAABBBB
- punpckhbw m7, m7 ; CCCCDDDD
-
- ; add DC
- DEFINE_ARGS dst1, dst2, stride
- lea dst2q, [dst1q+strideq*2]
- ADD_DC m0, m6, 0, mova
- lea dst1q, [dst1q+strideq*4]
- lea dst2q, [dst2q+strideq*4]
- ADD_DC m1, m7, 0, mova
- RET
-
-;-----------------------------------------------------------------------------
-; void 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)
-; this macro assumes that m6/m7 have words for 20091/17734 loaded
-%macro VP8_MULTIPLY_SUMSUB 4
- mova %3, %1
- mova %4, %2
- pmulhw %3, m6 ;20091(1)
- pmulhw %4, m6 ;20091(2)
- paddw %3, %1
- paddw %4, %2
- paddw %1, %1
- paddw %2, %2
- pmulhw %1, m7 ;35468(1)
- pmulhw %2, m7 ;35468(2)
- psubw %1, %4
- paddw %2, %3
-%endmacro
-
-; calculate x0=%1+%3; x1=%1-%3
-; x2=mul_35468(%2)-mul_20091(%4); x3=mul_20091(%2)+mul_35468(%4)
-; %1=x0+x3 (tmp0); %2=x1+x2 (tmp1); %3=x1-x2 (tmp2); %4=x0-x3 (tmp3)
-; %5/%6 are temporary registers
-; we assume m6/m7 have constant words 20091/17734 loaded in them
-%macro VP8_IDCT_TRANSFORM4x4_1D 6
- SUMSUB_BA w, %3, %1, %5 ;t0, t1
- VP8_MULTIPLY_SUMSUB m%2, m%4, m%5,m%6 ;t2, t3
- SUMSUB_BA w, %4, %3, %5 ;tmp0, tmp3
- SUMSUB_BA w, %2, %1, %5 ;tmp1, tmp2
- SWAP %4, %1
- SWAP %4, %3
-%endmacro
-
-%macro VP8_IDCT_ADD 0
-cglobal vp8_idct_add, 3, 3, 0, dst, block, stride
- ; load block data
- movq m0, [blockq+ 0]
- movq m1, [blockq+ 8]
- movq m2, [blockq+16]
- movq m3, [blockq+24]
- movq m6, [pw_20091]
- movq m7, [pw_17734]
-%if cpuflag(sse)
- xorps xmm0, xmm0
- movaps [blockq+ 0], xmm0
- movaps [blockq+16], xmm0
-%else
- pxor m4, m4
- movq [blockq+ 0], m4
- movq [blockq+ 8], m4
- movq [blockq+16], m4
- movq [blockq+24], m4
-%endif
-
- ; actual IDCT
- VP8_IDCT_TRANSFORM4x4_1D 0, 1, 2, 3, 4, 5
- TRANSPOSE4x4W 0, 1, 2, 3, 4
- paddw m0, [pw_4]
- VP8_IDCT_TRANSFORM4x4_1D 0, 1, 2, 3, 4, 5
- TRANSPOSE4x4W 0, 1, 2, 3, 4
-
- ; store
- pxor m4, m4
- DEFINE_ARGS dst1, dst2, stride
- lea dst2q, [dst1q+2*strideq]
- STORE_DIFFx2 m0, m1, m6, m7, m4, 3, dst1q, strideq
- STORE_DIFFx2 m2, m3, m6, m7, m4, 3, dst2q, strideq
-
- RET
-%endmacro
-
-%if ARCH_X86_32
-INIT_MMX mmx
-VP8_IDCT_ADD
-%endif
-INIT_MMX sse
-VP8_IDCT_ADD
-
-;-----------------------------------------------------------------------------
-; void vp8_luma_dc_wht_mmxext(int16_t block[4][4][16], int16_t dc[16])
-;-----------------------------------------------------------------------------
-
-%macro SCATTER_WHT 3
- movd dc1d, m%1
- movd dc2d, m%2
- mov [blockq+2*16*(0+%3)], dc1w
- mov [blockq+2*16*(1+%3)], dc2w
- shr dc1d, 16
- shr dc2d, 16
- psrlq m%1, 32
- psrlq m%2, 32
- mov [blockq+2*16*(4+%3)], dc1w
- mov [blockq+2*16*(5+%3)], dc2w
- movd dc1d, m%1
- movd dc2d, m%2
- mov [blockq+2*16*(8+%3)], dc1w
- mov [blockq+2*16*(9+%3)], dc2w
- shr dc1d, 16
- shr dc2d, 16
- mov [blockq+2*16*(12+%3)], dc1w
- mov [blockq+2*16*(13+%3)], dc2w
-%endmacro
-
-%macro HADAMARD4_1D 4
- SUMSUB_BADC w, %2, %1, %4, %3
- SUMSUB_BADC w, %4, %2, %3, %1
- SWAP %1, %4, %3
-%endmacro
-
-%macro VP8_DC_WHT 0
-cglobal vp8_luma_dc_wht, 2, 3, 0, block, dc1, dc2
- movq m0, [dc1q]
- movq m1, [dc1q+8]
- movq m2, [dc1q+16]
- movq m3, [dc1q+24]
-%if cpuflag(sse)
- xorps xmm0, xmm0
- movaps [dc1q+ 0], xmm0
- movaps [dc1q+16], xmm0
-%else
- pxor m4, m4
- movq [dc1q+ 0], m4
- movq [dc1q+ 8], m4
- movq [dc1q+16], m4
- movq [dc1q+24], m4
-%endif
- HADAMARD4_1D 0, 1, 2, 3
- TRANSPOSE4x4W 0, 1, 2, 3, 4
- paddw m0, [pw_3]
- HADAMARD4_1D 0, 1, 2, 3
- psraw m0, 3
- psraw m1, 3
- psraw m2, 3
- psraw m3, 3
- SCATTER_WHT 0, 1, 0
- SCATTER_WHT 2, 3, 2
- RET
-%endmacro
-
-%if ARCH_X86_32
-INIT_MMX mmx
-VP8_DC_WHT
-%endif
-INIT_MMX sse
-VP8_DC_WHT
-
-;-----------------------------------------------------------------------------
-; void 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
-;
-; first 4 mm registers will carry the transposed pixel data
-; the other three are scratchspace (one would be sufficient, but this allows
-; for more spreading/pipelining and thus faster execution on OOE CPUs)
-;
-; first two regular registers are buf+4*stride and buf+5*stride
-; third is -stride, fourth is +stride
-%macro READ_8x4_INTERLEAVED 11
- ; interleave 8 (A-H) rows of 4 pixels each
- movd m%1, [%8+%10*4] ; A0-3
- movd m%5, [%9+%10*4] ; B0-3
- movd m%2, [%8+%10*2] ; C0-3
- movd m%6, [%8+%10] ; D0-3
- movd m%3, [%8] ; E0-3
- movd m%7, [%9] ; F0-3
- movd m%4, [%9+%11] ; G0-3
- punpcklbw m%1, m%5 ; A/B interleaved
- movd m%5, [%9+%11*2] ; H0-3
- punpcklbw m%2, m%6 ; C/D interleaved
- punpcklbw m%3, m%7 ; E/F interleaved
- punpcklbw m%4, m%5 ; G/H interleaved
-%endmacro
-
-; macro called with 7 mm register indexes as argument, and 5 regular registers
-; first 11 mean the same as READ_8x4_TRANSPOSED above
-; fifth regular register is scratchspace to reach the bottom 8 rows, it
-; will be set to second regular register + 8*stride at the end
-%macro READ_16x4_INTERLEAVED 12
- ; transpose 16 (A-P) rows of 4 pixels each
- lea %12, [r0+8*r2]
-
- ; read (and interleave) those addressable by %8 (=r0), A/C/D/E/I/K/L/M
- movd m%1, [%8+%10*4] ; A0-3
- movd m%3, [%12+%10*4] ; I0-3
- movd m%2, [%8+%10*2] ; C0-3
- movd m%4, [%12+%10*2] ; K0-3
- movd m%6, [%8+%10] ; D0-3
- movd m%5, [%12+%10] ; L0-3
- movd m%7, [%12] ; M0-3
- add %12, %11
- punpcklbw m%1, m%3 ; A/I
- movd m%3, [%8] ; E0-3
- punpcklbw m%2, m%4 ; C/K
- punpcklbw m%6, m%5 ; D/L
- punpcklbw m%3, m%7 ; E/M
- punpcklbw m%2, m%6 ; C/D/K/L interleaved
-
- ; read (and interleave) those addressable by %9 (=r4), B/F/G/H/J/N/O/P
- movd m%5, [%9+%10*4] ; B0-3
- movd m%4, [%12+%10*4] ; J0-3
- movd m%7, [%9] ; F0-3
- movd m%6, [%12] ; N0-3
- punpcklbw m%5, m%4 ; B/J
- punpcklbw m%7, m%6 ; F/N
- punpcklbw m%1, m%5 ; A/B/I/J interleaved
- punpcklbw m%3, m%7 ; E/F/M/N interleaved
- movd m%4, [%9+%11] ; G0-3
- movd m%6, [%12+%11] ; O0-3
- movd m%5, [%9+%11*2] ; H0-3
- movd m%7, [%12+%11*2] ; P0-3
- punpcklbw m%4, m%6 ; G/O
- punpcklbw m%5, m%7 ; H/P
- punpcklbw m%4, m%5 ; G/H/O/P interleaved
-%endmacro
-
-; write 4 mm registers of 2 dwords each
-; first four arguments are mm register indexes containing source data
-; last four are registers containing buf+4*stride, buf+5*stride,
-; -stride and +stride
-%macro WRITE_4x2D 8
- ; write out (2 dwords per register)
- movd [%5+%7*4], m%1
- movd [%5+%7*2], m%2
- movd [%5], m%3
- movd [%6+%8], m%4
- punpckhdq m%1, m%1
- punpckhdq m%2, m%2
- punpckhdq m%3, m%3
- punpckhdq m%4, m%4
- movd [%6+%7*4], m%1
- movd [%5+%7], m%2
- movd [%6], m%3
- movd [%6+%8*2], m%4
-%endmacro
-
-; write 4 xmm registers of 4 dwords each
-; arguments same as WRITE_2x4D, but with an extra register, so that the 5 regular
-; registers contain buf+4*stride, buf+5*stride, buf+12*stride, -stride and +stride
-; we add 1*stride to the third regular registry in the process
-; the 10th argument is 16 if it's a Y filter (i.e. all regular registers cover the
-; same memory region), or 8 if they cover two separate buffers (third one points to
-; a different memory region than the first two), allowing for more optimal code for
-; the 16-width case
-%macro WRITE_4x4D 10
- ; write out (4 dwords per register), start with dwords zero
- movd [%5+%8*4], m%1
- movd [%5], m%2
- movd [%7+%8*4], m%3
- movd [%7], m%4
-
- ; store dwords 1
- psrldq m%1, 4
- psrldq m%2, 4
- psrldq m%3, 4
- psrldq m%4, 4
- movd [%6+%8*4], m%1
- movd [%6], m%2
-%if %10 == 16
- movd [%6+%9*4], m%3
-%endif
- movd [%7+%9], m%4
-
- ; write dwords 2
- psrldq m%1, 4
- psrldq m%2, 4
-%if %10 == 8
- movd [%5+%8*2], m%1
- movd %5d, m%3
-%endif
- psrldq m%3, 4
- psrldq m%4, 4
-%if %10 == 16
- movd [%5+%8*2], m%1
-%endif
- movd [%6+%9], m%2
- movd [%7+%8*2], m%3
- movd [%7+%9*2], m%4
- add %7, %9
-
- ; store dwords 3
- psrldq m%1, 4
- psrldq m%2, 4
- psrldq m%3, 4
- psrldq m%4, 4
-%if %10 == 8
- mov [%7+%8*4], %5d
- movd [%6+%8*2], m%1
-%else
- movd [%5+%8], m%1
-%endif
- movd [%6+%9*2], m%2
- movd [%7+%8*2], m%3
- movd [%7+%9*2], m%4
-%endmacro
-
-; write 4 or 8 words in the mmx/xmm registers as 8 lines
-; 1 and 2 are the registers to write, this can be the same (for SSE2)
-; for pre-SSE4:
-; 3 is a general-purpose register that we will clobber
-; for SSE4:
-; 3 is a pointer to the destination's 5th line
-; 4 is a pointer to the destination's 4th line
-; 5/6 is -stride and +stride
-%macro WRITE_2x4W 6
- movd %3d, %1
- punpckhdq %1, %1
- mov [%4+%5*4], %3w
- shr %3, 16
- add %4, %6
- mov [%4+%5*4], %3w
-
- movd %3d, %1
- add %4, %5
- mov [%4+%5*2], %3w
- shr %3, 16
- mov [%4+%5 ], %3w
-
- movd %3d, %2
- punpckhdq %2, %2
- mov [%4 ], %3w
- shr %3, 16
- mov [%4+%6 ], %3w
-
- movd %3d, %2
- add %4, %6
- mov [%4+%6 ], %3w
- shr %3, 16
- mov [%4+%6*2], %3w
- add %4, %5
-%endmacro
-
-%macro WRITE_8W 5
-%if cpuflag(sse4)
- pextrw [%3+%4*4], %1, 0
- pextrw [%2+%4*4], %1, 1
- pextrw [%3+%4*2], %1, 2
- pextrw [%3+%4 ], %1, 3
- pextrw [%3 ], %1, 4
- pextrw [%2 ], %1, 5
- pextrw [%2+%5 ], %1, 6
- pextrw [%2+%5*2], %1, 7
-%else
- movd %2d, %1
- psrldq %1, 4
- mov [%3+%4*4], %2w
- shr %2, 16
- add %3, %5
- mov [%3+%4*4], %2w
-
- movd %2d, %1
- psrldq %1, 4
- add %3, %4
- mov [%3+%4*2], %2w
- shr %2, 16
- mov [%3+%4 ], %2w
-
- movd %2d, %1
- psrldq %1, 4
- mov [%3 ], %2w
- shr %2, 16
- mov [%3+%5 ], %2w
-
- movd %2d, %1
- add %3, %5
- mov [%3+%5 ], %2w
- shr %2, 16
- mov [%3+%5*2], %2w
-%endif
-%endmacro
-
-%macro SIMPLE_LOOPFILTER 2
-cglobal vp8_%1_loop_filter_simple, 3, %2, 8, dst, stride, flim, cntr
-%if mmsize == 8 ; mmx/mmxext
- mov cntrq, 2
-%endif
-%if cpuflag(ssse3)
- pxor m0, m0
-%endif
- SPLATB_REG m7, flim, m0 ; splat "flim" into register
-
- ; set up indexes to address 4 rows
-%if mmsize == 8
- DEFINE_ARGS dst1, mstride, stride, cntr, dst2
-%else
- DEFINE_ARGS dst1, mstride, stride, dst3, dst2
-%endif
- mov strideq, mstrideq
- neg mstrideq
-%ifidn %1, h
- lea dst1q, [dst1q+4*strideq-2]
-%endif
-
-%if mmsize == 8 ; mmx / mmxext
-.next8px:
-%endif
-%ifidn %1, v
- ; read 4 half/full rows of pixels
- mova m0, [dst1q+mstrideq*2] ; p1
- mova m1, [dst1q+mstrideq] ; p0
- mova m2, [dst1q] ; q0
- mova m3, [dst1q+ strideq] ; q1
-%else ; h
- lea dst2q, [dst1q+ strideq]
-
-%if mmsize == 8 ; mmx/mmxext
- READ_8x4_INTERLEAVED 0, 1, 2, 3, 4, 5, 6, dst1q, dst2q, mstrideq, strideq
-%else ; sse2
- READ_16x4_INTERLEAVED 0, 1, 2, 3, 4, 5, 6, dst1q, dst2q, mstrideq, strideq, dst3q
-%endif
- TRANSPOSE4x4W 0, 1, 2, 3, 4
-%endif
-
- ; simple_limit
- mova m5, m2 ; m5=backup of q0
- mova m6, m1 ; m6=backup of p0
- psubusb m1, m2 ; p0-q0
- psubusb m2, m6 ; q0-p0
- por m1, m2 ; FFABS(p0-q0)
- paddusb m1, m1 ; m1=FFABS(p0-q0)*2
-
- mova m4, m3
- mova m2, m0
- psubusb m3, m0 ; q1-p1
- psubusb m0, m4 ; p1-q1
- por m3, m0 ; FFABS(p1-q1)
- mova m0, [pb_80]
- pxor m2, m0
- pxor m4, m0
- psubsb m2, m4 ; m2=p1-q1 (signed) backup for below
- pand m3, [pb_FE]
- psrlq m3, 1 ; m3=FFABS(p1-q1)/2, this can be used signed
- paddusb m3, m1
- psubusb m3, m7
- pxor m1, m1
- pcmpeqb m3, m1 ; abs(p0-q0)*2+abs(p1-q1)/2<=flim mask(0xff/0x0)
-
- ; filter_common (use m2/p1-q1, m4=q0, m6=p0, m5/q0-p0 and m3/mask)
- mova m4, m5
- pxor m5, m0
- pxor m0, m6
- psubsb m5, m0 ; q0-p0 (signed)
- paddsb m2, m5
- paddsb m2, m5
- paddsb m2, m5 ; a=(p1-q1) + 3*(q0-p0)
- pand m2, m3 ; apply filter mask (m3)
-
- mova m3, [pb_F8]
- mova m1, m2
- paddsb m2, [pb_4] ; f1<<3=a+4
- paddsb m1, [pb_3] ; f2<<3=a+3
- pand m2, m3
- pand m1, m3 ; cache f2<<3
-
- pxor m0, m0
- pxor m3, m3
- pcmpgtb m0, m2 ; which values are <0?
- psubb m3, m2 ; -f1<<3
- psrlq m2, 3 ; +f1
- psrlq m3, 3 ; -f1
- pand m3, m0
- pandn m0, m2
- psubusb m4, m0
- paddusb m4, m3 ; q0-f1
-
- pxor m0, m0
- pxor m3, m3
- pcmpgtb m0, m1 ; which values are <0?
- psubb m3, m1 ; -f2<<3
- psrlq m1, 3 ; +f2
- psrlq m3, 3 ; -f2
- pand m3, m0
- pandn m0, m1
- paddusb m6, m0
- psubusb m6, m3 ; p0+f2
-
- ; store
-%ifidn %1, v
- mova [dst1q], m4
- mova [dst1q+mstrideq], m6
-%else ; h
- inc dst1q
- SBUTTERFLY bw, 6, 4, 0
-
-%if mmsize == 16 ; sse2
-%if cpuflag(sse4)
- inc dst2q
-%endif
- WRITE_8W m6, dst2q, dst1q, mstrideq, strideq
- lea dst2q, [dst3q+mstrideq+1]
-%if cpuflag(sse4)
- inc dst3q
-%endif
- WRITE_8W m4, dst3q, dst2q, mstrideq, strideq
-%else ; mmx/mmxext
- WRITE_2x4W m6, m4, dst2q, dst1q, mstrideq, strideq
-%endif
-%endif
-
-%if mmsize == 8 ; mmx/mmxext
- ; next 8 pixels
-%ifidn %1, v
- add dst1q, 8 ; advance 8 cols = pixels
-%else ; h
- lea dst1q, [dst1q+strideq*8-1] ; advance 8 rows = lines
-%endif
- dec cntrq
- jg .next8px
- REP_RET
-%else ; sse2
- RET
-%endif
-%endmacro
-
-%if ARCH_X86_32
-INIT_MMX mmx
-SIMPLE_LOOPFILTER v, 4
-SIMPLE_LOOPFILTER h, 5
-INIT_MMX mmxext
-SIMPLE_LOOPFILTER v, 4
-SIMPLE_LOOPFILTER h, 5
-%endif
-
-INIT_XMM sse2
-SIMPLE_LOOPFILTER v, 3
-SIMPLE_LOOPFILTER h, 5
-INIT_XMM ssse3
-SIMPLE_LOOPFILTER v, 3
-SIMPLE_LOOPFILTER h, 5
-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);
-;-----------------------------------------------------------------------------
-
-%macro INNER_LOOPFILTER 2
-%define stack_size 0
-%ifndef m8 ; stack layout: [0]=E, [1]=I, [2]=hev_thr
-%ifidn %1, v ; [3]=hev() result
-%define stack_size mmsize * -4
-%else ; h ; extra storage space for transposes
-%define stack_size mmsize * -5
-%endif
-%endif
-
-%if %2 == 8 ; chroma
-cglobal vp8_%1_loop_filter8uv_inner, 6, 6, 13, stack_size, dst, dst8, stride, flimE, flimI, hevthr
-%else ; luma
-cglobal vp8_%1_loop_filter16y_inner, 5, 5, 13, stack_size, dst, stride, flimE, flimI, hevthr
-%endif
-
-%if cpuflag(ssse3)
- pxor m7, m7
-%endif
-
-%ifndef m8
- ; splat function arguments
- SPLATB_REG m0, flimEq, m7 ; E
- SPLATB_REG m1, flimIq, m7 ; I
- SPLATB_REG m2, hevthrq, m7 ; hev_thresh
-
-%define m_flimE [rsp]
-%define m_flimI [rsp+mmsize]
-%define m_hevthr [rsp+mmsize*2]
-%define m_maskres [rsp+mmsize*3]
-%define m_p0backup [rsp+mmsize*3]
-%define m_q0backup [rsp+mmsize*4]
-
- mova m_flimE, m0
- mova m_flimI, m1
- mova m_hevthr, m2
-%else
-%define m_flimE m9
-%define m_flimI m10
-%define m_hevthr m11
-%define m_maskres m12
-%define m_p0backup m12
-%define m_q0backup m8
-
- ; splat function arguments
- SPLATB_REG m_flimE, flimEq, m7 ; E
- SPLATB_REG m_flimI, flimIq, m7 ; I
- SPLATB_REG m_hevthr, hevthrq, m7 ; hev_thresh
-%endif
-
-%if %2 == 8 ; chroma
- DEFINE_ARGS dst1, dst8, mstride, stride, dst2
-%elif mmsize == 8
- DEFINE_ARGS dst1, mstride, stride, dst2, cntr
- mov cntrq, 2
-%else
- DEFINE_ARGS dst1, mstride, stride, dst2, dst8
-%endif
- mov strideq, mstrideq
- neg mstrideq
-%ifidn %1, h
- lea dst1q, [dst1q+strideq*4-4]
-%if %2 == 8 ; chroma
- lea dst8q, [dst8q+strideq*4-4]
-%endif
-%endif
-
-%if mmsize == 8
-.next8px:
-%endif
- ; read
- lea dst2q, [dst1q+strideq]
-%ifidn %1, v
-%if %2 == 8 && mmsize == 16
-%define movrow movh
-%else
-%define movrow mova
-%endif
- movrow m0, [dst1q+mstrideq*4] ; p3
- movrow m1, [dst2q+mstrideq*4] ; p2
- movrow m2, [dst1q+mstrideq*2] ; p1
- movrow m5, [dst2q] ; q1
- movrow m6, [dst2q+ strideq*1] ; q2
- movrow m7, [dst2q+ strideq*2] ; q3
-%if mmsize == 16 && %2 == 8
- movhps m0, [dst8q+mstrideq*4]
- movhps m2, [dst8q+mstrideq*2]
- add dst8q, strideq
- movhps m1, [dst8q+mstrideq*4]
- movhps m5, [dst8q]
- movhps m6, [dst8q+ strideq ]
- movhps m7, [dst8q+ strideq*2]
- add dst8q, mstrideq
-%endif
-%elif mmsize == 8 ; mmx/mmxext (h)
- ; read 8 rows of 8px each
- movu m0, [dst1q+mstrideq*4]
- movu m1, [dst2q+mstrideq*4]
- movu m2, [dst1q+mstrideq*2]
- movu m3, [dst1q+mstrideq ]
- movu m4, [dst1q]
- movu m5, [dst2q]
- movu m6, [dst2q+ strideq ]
-
- ; 8x8 transpose
- TRANSPOSE4x4B 0, 1, 2, 3, 7
- mova m_q0backup, m1
- movu m7, [dst2q+ strideq*2]
- TRANSPOSE4x4B 4, 5, 6, 7, 1
- SBUTTERFLY dq, 0, 4, 1 ; p3/p2
- SBUTTERFLY dq, 2, 6, 1 ; q0/q1
- SBUTTERFLY dq, 3, 7, 1 ; q2/q3
- mova m1, m_q0backup
- mova m_q0backup, m2 ; store q0
- SBUTTERFLY dq, 1, 5, 2 ; p1/p0
- mova m_p0backup, m5 ; store p0
- SWAP 1, 4
- SWAP 2, 4
- SWAP 6, 3
- SWAP 5, 3
-%else ; sse2 (h)
-%if %2 == 16
- lea dst8q, [dst1q+ strideq*8]
-%endif
-
- ; read 16 rows of 8px each, interleave
- movh m0, [dst1q+mstrideq*4]
- movh m1, [dst8q+mstrideq*4]
- movh m2, [dst1q+mstrideq*2]
- movh m5, [dst8q+mstrideq*2]
- movh m3, [dst1q+mstrideq ]
- movh m6, [dst8q+mstrideq ]
- movh m4, [dst1q]
- movh m7, [dst8q]
- punpcklbw m0, m1 ; A/I
- punpcklbw m2, m5 ; C/K
- punpcklbw m3, m6 ; D/L
- punpcklbw m4, m7 ; E/M
-
- add dst8q, strideq
- movh m1, [dst2q+mstrideq*4]
- movh m6, [dst8q+mstrideq*4]
- movh m5, [dst2q]
- movh m7, [dst8q]
- punpcklbw m1, m6 ; B/J
- punpcklbw m5, m7 ; F/N
- movh m6, [dst2q+ strideq ]
- movh m7, [dst8q+ strideq ]
- punpcklbw m6, m7 ; G/O
-
- ; 8x16 transpose
- TRANSPOSE4x4B 0, 1, 2, 3, 7
-%ifdef m8
- SWAP 1, 8
-%else
- mova m_q0backup, m1
-%endif
- movh m7, [dst2q+ strideq*2]
- movh m1, [dst8q+ strideq*2]
- punpcklbw m7, m1 ; H/P
- TRANSPOSE4x4B 4, 5, 6, 7, 1
- SBUTTERFLY dq, 0, 4, 1 ; p3/p2
- SBUTTERFLY dq, 2, 6, 1 ; q0/q1
- SBUTTERFLY dq, 3, 7, 1 ; q2/q3
-%ifdef m8
- SWAP 1, 8
- SWAP 2, 8
-%else
- mova m1, m_q0backup
- mova m_q0backup, m2 ; store q0
-%endif
- SBUTTERFLY dq, 1, 5, 2 ; p1/p0
-%ifdef m12
- SWAP 5, 12
-%else
- mova m_p0backup, m5 ; store p0
-%endif
- SWAP 1, 4
- SWAP 2, 4
- SWAP 6, 3
- SWAP 5, 3
-%endif
-
- ; normal_limit for p3-p2, p2-p1, q3-q2 and q2-q1
- mova m4, m1
- SWAP 4, 1
- psubusb m4, m0 ; p2-p3
- psubusb m0, m1 ; p3-p2
- por m0, m4 ; abs(p3-p2)
-
- mova m4, m2
- SWAP 4, 2
- psubusb m4, m1 ; p1-p2
- psubusb m1, m2 ; p2-p1
- por m1, m4 ; abs(p2-p1)
-
- mova m4, m6
- SWAP 4, 6
- psubusb m4, m7 ; q2-q3
- psubusb m7, m6 ; q3-q2
- por m7, m4 ; abs(q3-q2)
-
- mova m4, m5
- SWAP 4, 5
- psubusb m4, m6 ; q1-q2
- psubusb m6, m5 ; q2-q1
- por m6, m4 ; abs(q2-q1)
-
-%if notcpuflag(mmxext)
- mova m4, m_flimI
- pxor m3, m3
- psubusb m0, m4
- psubusb m1, m4
- psubusb m7, m4
- psubusb m6, m4
- pcmpeqb m0, m3 ; abs(p3-p2) <= I
- pcmpeqb m1, m3 ; abs(p2-p1) <= I
- pcmpeqb m7, m3 ; abs(q3-q2) <= I
- pcmpeqb m6, m3 ; abs(q2-q1) <= I
- pand m0, m1
- pand m7, m6
- pand m0, m7
-%else ; mmxext/sse2
- pmaxub m0, m1
- pmaxub m6, m7
- pmaxub m0, m6
-%endif
-
- ; normal_limit and high_edge_variance for p1-p0, q1-q0
- SWAP 7, 3 ; now m7 is zero
-%ifidn %1, v
- movrow m3, [dst1q+mstrideq ] ; p0
-%if mmsize == 16 && %2 == 8
- movhps m3, [dst8q+mstrideq ]
-%endif
-%elifdef m12
- SWAP 3, 12
-%else
- mova m3, m_p0backup
-%endif
-
- mova m1, m2
- SWAP 1, 2
- mova m6, m3
- SWAP 3, 6
- psubusb m1, m3 ; p1-p0
- psubusb m6, m2 ; p0-p1
- por m1, m6 ; abs(p1-p0)
-%if notcpuflag(mmxext)
- mova m6, m1
- psubusb m1, m4
- psubusb m6, m_hevthr
- pcmpeqb m1, m7 ; abs(p1-p0) <= I
- pcmpeqb m6, m7 ; abs(p1-p0) <= hev_thresh
- pand m0, m1
- mova m_maskres, m6
-%else ; mmxext/sse2
- pmaxub m0, m1 ; max_I
- SWAP 1, 4 ; max_hev_thresh
-%endif
-
- SWAP 6, 4 ; now m6 is I
-%ifidn %1, v
- movrow m4, [dst1q] ; q0
-%if mmsize == 16 && %2 == 8
- movhps m4, [dst8q]
-%endif
-%elifdef m8
- SWAP 4, 8
-%else
- mova m4, m_q0backup
-%endif
- mova m1, m4
- SWAP 1, 4
- mova m7, m5
- SWAP 7, 5
- psubusb m1, m5 ; q0-q1
- psubusb m7, m4 ; q1-q0
- por m1, m7 ; abs(q1-q0)
-%if notcpuflag(mmxext)
- mova m7, m1
- psubusb m1, m6
- psubusb m7, m_hevthr
- pxor m6, m6
- pcmpeqb m1, m6 ; abs(q1-q0) <= I
- pcmpeqb m7, m6 ; abs(q1-q0) <= hev_thresh
- mova m6, m_maskres
- pand m0, m1 ; abs([pq][321]-[pq][210]) <= I
- pand m6, m7
-%else ; mmxext/sse2
- pxor m7, m7
- pmaxub m0, m1
- pmaxub m6, m1
- psubusb m0, m_flimI
- psubusb m6, m_hevthr
- pcmpeqb m0, m7 ; max(abs(..)) <= I
- pcmpeqb m6, m7 ; !(max(abs..) > thresh)
-%endif
-%ifdef m12
- SWAP 6, 12
-%else
- mova m_maskres, m6 ; !(abs(p1-p0) > hev_t || abs(q1-q0) > hev_t)
-%endif
-
- ; simple_limit
- mova m1, m3
- SWAP 1, 3
- mova m6, m4 ; keep copies of p0/q0 around for later use
- SWAP 6, 4
- psubusb m1, m4 ; p0-q0
- psubusb m6, m3 ; q0-p0
- por m1, m6 ; abs(q0-p0)
- paddusb m1, m1 ; m1=2*abs(q0-p0)
-
- mova m7, m2
- SWAP 7, 2
- mova m6, m5
- SWAP 6, 5
- psubusb m7, m5 ; p1-q1
- psubusb m6, m2 ; q1-p1
- por m7, m6 ; abs(q1-p1)
- pxor m6, m6
- pand m7, [pb_FE]
- psrlq m7, 1 ; abs(q1-p1)/2
- paddusb m7, m1 ; abs(q0-p0)*2+abs(q1-p1)/2
- psubusb m7, m_flimE
- pcmpeqb m7, m6 ; abs(q0-p0)*2+abs(q1-p1)/2 <= E
- pand m0, m7 ; normal_limit result
-
- ; filter_common; at this point, m2-m5=p1-q1 and m0 is filter_mask
-%ifdef m8 ; x86-64 && sse2
- mova m8, [pb_80]
-%define m_pb_80 m8
-%else ; x86-32 or mmx/mmxext
-%define m_pb_80 [pb_80]
-%endif
- mova m1, m4
- mova m7, m3
- pxor m1, m_pb_80
- pxor m7, m_pb_80
- psubsb m1, m7 ; (signed) q0-p0
- mova m6, m2
- mova m7, m5
- pxor m6, m_pb_80
- pxor m7, m_pb_80
- psubsb m6, m7 ; (signed) p1-q1
- mova m7, m_maskres
- pandn m7, m6
- paddsb m7, m1
- paddsb m7, m1
- paddsb m7, m1 ; 3*(q0-p0)+is4tap?(p1-q1)
-
- pand m7, m0
- mova m1, [pb_F8]
- mova m6, m7
- paddsb m7, [pb_3]
- paddsb m6, [pb_4]
- pand m7, m1
- pand m6, m1
-
- pxor m1, m1
- pxor m0, m0
- pcmpgtb m1, m7
- psubb m0, m7
- psrlq m7, 3 ; +f2
- psrlq m0, 3 ; -f2
- pand m0, m1
- pandn m1, m7
- psubusb m3, m0
- paddusb m3, m1 ; p0+f2
-
- pxor m1, m1
- pxor m0, m0
- pcmpgtb m0, m6
- psubb m1, m6
- psrlq m6, 3 ; +f1
- psrlq m1, 3 ; -f1
- pand m1, m0
- pandn m0, m6
- psubusb m4, m0
- paddusb m4, m1 ; q0-f1
-
-%ifdef m12
- SWAP 6, 12
-%else
- mova m6, m_maskres
-%endif
-%if notcpuflag(mmxext)
- mova m7, [pb_1]
-%else ; mmxext/sse2
- pxor m7, m7
-%endif
- pand m0, m6
- pand m1, m6
-%if notcpuflag(mmxext)
- paddusb m0, m7
- pand m1, [pb_FE]
- pandn m7, m0
- psrlq m1, 1
- psrlq m7, 1
- SWAP 0, 7
-%else ; mmxext/sse2
- psubusb m1, [pb_1]
- pavgb m0, m7 ; a
- pavgb m1, m7 ; -a
-%endif
- psubusb m5, m0
- psubusb m2, m1
- paddusb m5, m1 ; q1-a
- paddusb m2, m0 ; p1+a
-
- ; store
-%ifidn %1, v
- movrow [dst1q+mstrideq*2], m2
- movrow [dst1q+mstrideq ], m3
- movrow [dst1q], m4
- movrow [dst1q+ strideq ], m5
-%if mmsize == 16 && %2 == 8
- movhps [dst8q+mstrideq*2], m2
- movhps [dst8q+mstrideq ], m3
- movhps [dst8q], m4
- movhps [dst8q+ strideq ], m5
-%endif
-%else ; h
- add dst1q, 2
- add dst2q, 2
-
- ; 4x8/16 transpose
- TRANSPOSE4x4B 2, 3, 4, 5, 6
-
-%if mmsize == 8 ; mmx/mmxext (h)
- WRITE_4x2D 2, 3, 4, 5, dst1q, dst2q, mstrideq, strideq
-%else ; sse2 (h)
- lea dst8q, [dst8q+mstrideq +2]
- WRITE_4x4D 2, 3, 4, 5, dst1q, dst2q, dst8q, mstrideq, strideq, %2
-%endif
-%endif
-
-%if mmsize == 8
-%if %2 == 8 ; chroma
-%ifidn %1, h
- sub dst1q, 2
-%endif
- cmp dst1q, dst8q
- mov dst1q, dst8q
- jnz .next8px
-%else
-%ifidn %1, h
- lea dst1q, [dst1q+ strideq*8-2]
-%else ; v
- add dst1q, 8
-%endif
- dec cntrq
- jg .next8px
-%endif
- REP_RET
-%else ; mmsize == 16
- RET
-%endif
-%endmacro
-
-%if ARCH_X86_32
-INIT_MMX mmx
-INNER_LOOPFILTER v, 16
-INNER_LOOPFILTER h, 16
-INNER_LOOPFILTER v, 8
-INNER_LOOPFILTER h, 8
-
-INIT_MMX mmxext
-INNER_LOOPFILTER v, 16
-INNER_LOOPFILTER h, 16
-INNER_LOOPFILTER v, 8
-INNER_LOOPFILTER h, 8
-%endif
-
-INIT_XMM sse2
-INNER_LOOPFILTER v, 16
-INNER_LOOPFILTER h, 16
-INNER_LOOPFILTER v, 8
-INNER_LOOPFILTER h, 8
-
-INIT_XMM ssse3
-INNER_LOOPFILTER v, 16
-INNER_LOOPFILTER h, 16
-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);
-;-----------------------------------------------------------------------------
-
-%macro MBEDGE_LOOPFILTER 2
-%define stack_size 0
-%ifndef m8 ; stack layout: [0]=E, [1]=I, [2]=hev_thr
-%if mmsize == 16 ; [3]=hev() result
- ; [4]=filter tmp result
- ; [5]/[6] = p2/q2 backup
- ; [7]=lim_res sign result
-%define stack_size mmsize * -7
-%else ; 8 ; extra storage space for transposes
-%define stack_size mmsize * -8
-%endif
-%endif
-
-%if %2 == 8 ; chroma
-cglobal vp8_%1_loop_filter8uv_mbedge, 6, 6, 15, stack_size, dst1, dst8, stride, flimE, flimI, hevthr
-%else ; luma
-cglobal vp8_%1_loop_filter16y_mbedge, 5, 5, 15, stack_size, dst1, stride, flimE, flimI, hevthr
-%endif
-
-%if cpuflag(ssse3)
- pxor m7, m7
-%endif
-
-%ifndef m8
- ; splat function arguments
- SPLATB_REG m0, flimEq, m7 ; E
- SPLATB_REG m1, flimIq, m7 ; I
- SPLATB_REG m2, hevthrq, m7 ; hev_thresh
-
-%define m_flimE [rsp]
-%define m_flimI [rsp+mmsize]
-%define m_hevthr [rsp+mmsize*2]
-%define m_maskres [rsp+mmsize*3]
-%define m_limres [rsp+mmsize*4]
-%define m_p0backup [rsp+mmsize*3]
-%define m_q0backup [rsp+mmsize*4]
-%define m_p2backup [rsp+mmsize*5]
-%define m_q2backup [rsp+mmsize*6]
-%if mmsize == 16
-%define m_limsign [rsp]
-%else
-%define m_limsign [rsp+mmsize*7]
-%endif
-
- mova m_flimE, m0
- mova m_flimI, m1
- mova m_hevthr, m2
-%else ; sse2 on x86-64
-%define m_flimE m9
-%define m_flimI m10
-%define m_hevthr m11
-%define m_maskres m12
-%define m_limres m8
-%define m_p0backup m12
-%define m_q0backup m8
-%define m_p2backup m13
-%define m_q2backup m14
-%define m_limsign m9
-
- ; splat function arguments
- SPLATB_REG m_flimE, flimEq, m7 ; E
- SPLATB_REG m_flimI, flimIq, m7 ; I
- SPLATB_REG m_hevthr, hevthrq, m7 ; hev_thresh
-%endif
-
-%if %2 == 8 ; chroma
- DEFINE_ARGS dst1, dst8, mstride, stride, dst2
-%elif mmsize == 8
- DEFINE_ARGS dst1, mstride, stride, dst2, cntr
- mov cntrq, 2
-%else
- DEFINE_ARGS dst1, mstride, stride, dst2, dst8
-%endif
- mov strideq, mstrideq
- neg mstrideq
-%ifidn %1, h
- lea dst1q, [dst1q+strideq*4-4]
-%if %2 == 8 ; chroma
- lea dst8q, [dst8q+strideq*4-4]
-%endif
-%endif
-
-%if mmsize == 8
-.next8px:
-%endif
- ; read
- lea dst2q, [dst1q+ strideq ]
-%ifidn %1, v
-%if %2 == 8 && mmsize == 16
-%define movrow movh
-%else
-%define movrow mova
-%endif
- movrow m0, [dst1q+mstrideq*4] ; p3
- movrow m1, [dst2q+mstrideq*4] ; p2
- movrow m2, [dst1q+mstrideq*2] ; p1
- movrow m5, [dst2q] ; q1
- movrow m6, [dst2q+ strideq ] ; q2
- movrow m7, [dst2q+ strideq*2] ; q3
-%if mmsize == 16 && %2 == 8
- movhps m0, [dst8q+mstrideq*4]
- movhps m2, [dst8q+mstrideq*2]
- add dst8q, strideq
- movhps m1, [dst8q+mstrideq*4]
- movhps m5, [dst8q]
- movhps m6, [dst8q+ strideq ]
- movhps m7, [dst8q+ strideq*2]
- add dst8q, mstrideq
-%endif
-%elif mmsize == 8 ; mmx/mmxext (h)
- ; read 8 rows of 8px each
- movu m0, [dst1q+mstrideq*4]
- movu m1, [dst2q+mstrideq*4]
- movu m2, [dst1q+mstrideq*2]
- movu m3, [dst1q+mstrideq ]
- movu m4, [dst1q]
- movu m5, [dst2q]
- movu m6, [dst2q+ strideq ]
-
- ; 8x8 transpose
- TRANSPOSE4x4B 0, 1, 2, 3, 7
- mova m_q0backup, m1
- movu m7, [dst2q+ strideq*2]
- TRANSPOSE4x4B 4, 5, 6, 7, 1
- SBUTTERFLY dq, 0, 4, 1 ; p3/p2
- SBUTTERFLY dq, 2, 6, 1 ; q0/q1
- SBUTTERFLY dq, 3, 7, 1 ; q2/q3
- mova m1, m_q0backup
- mova m_q0backup, m2 ; store q0
- SBUTTERFLY dq, 1, 5, 2 ; p1/p0
- mova m_p0backup, m5 ; store p0
- SWAP 1, 4
- SWAP 2, 4
- SWAP 6, 3
- SWAP 5, 3
-%else ; sse2 (h)
-%if %2 == 16
- lea dst8q, [dst1q+ strideq*8 ]
-%endif
-
- ; read 16 rows of 8px each, interleave
- movh m0, [dst1q+mstrideq*4]
- movh m1, [dst8q+mstrideq*4]
- movh m2, [dst1q+mstrideq*2]
- movh m5, [dst8q+mstrideq*2]
- movh m3, [dst1q+mstrideq ]
- movh m6, [dst8q+mstrideq ]
- movh m4, [dst1q]
- movh m7, [dst8q]
- punpcklbw m0, m1 ; A/I
- punpcklbw m2, m5 ; C/K
- punpcklbw m3, m6 ; D/L
- punpcklbw m4, m7 ; E/M
-
- add dst8q, strideq
- movh m1, [dst2q+mstrideq*4]
- movh m6, [dst8q+mstrideq*4]
- movh m5, [dst2q]
- movh m7, [dst8q]
- punpcklbw m1, m6 ; B/J
- punpcklbw m5, m7 ; F/N
- movh m6, [dst2q+ strideq ]
- movh m7, [dst8q+ strideq ]
- punpcklbw m6, m7 ; G/O
-
- ; 8x16 transpose
- TRANSPOSE4x4B 0, 1, 2, 3, 7
-%ifdef m8
- SWAP 1, 8
-%else
- mova m_q0backup, m1
-%endif
- movh m7, [dst2q+ strideq*2]
- movh m1, [dst8q+ strideq*2]
- punpcklbw m7, m1 ; H/P
- TRANSPOSE4x4B 4, 5, 6, 7, 1
- SBUTTERFLY dq, 0, 4, 1 ; p3/p2
- SBUTTERFLY dq, 2, 6, 1 ; q0/q1
- SBUTTERFLY dq, 3, 7, 1 ; q2/q3
-%ifdef m8
- SWAP 1, 8
- SWAP 2, 8
-%else
- mova m1, m_q0backup
- mova m_q0backup, m2 ; store q0
-%endif
- SBUTTERFLY dq, 1, 5, 2 ; p1/p0
-%ifdef m12
- SWAP 5, 12
-%else
- mova m_p0backup, m5 ; store p0
-%endif
- SWAP 1, 4
- SWAP 2, 4
- SWAP 6, 3
- SWAP 5, 3
-%endif
-
- ; normal_limit for p3-p2, p2-p1, q3-q2 and q2-q1
- mova m4, m1
- SWAP 4, 1
- psubusb m4, m0 ; p2-p3
- psubusb m0, m1 ; p3-p2
- por m0, m4 ; abs(p3-p2)
-
- mova m4, m2
- SWAP 4, 2
- psubusb m4, m1 ; p1-p2
- mova m_p2backup, m1
- psubusb m1, m2 ; p2-p1
- por m1, m4 ; abs(p2-p1)
-
- mova m4, m6
- SWAP 4, 6
- psubusb m4, m7 ; q2-q3
- psubusb m7, m6 ; q3-q2
- por m7, m4 ; abs(q3-q2)
-
- mova m4, m5
- SWAP 4, 5
- psubusb m4, m6 ; q1-q2
- mova m_q2backup, m6
- psubusb m6, m5 ; q2-q1
- por m6, m4 ; abs(q2-q1)
-
-%if notcpuflag(mmxext)
- mova m4, m_flimI
- pxor m3, m3
- psubusb m0, m4
- psubusb m1, m4
- psubusb m7, m4
- psubusb m6, m4
- pcmpeqb m0, m3 ; abs(p3-p2) <= I
- pcmpeqb m1, m3 ; abs(p2-p1) <= I
- pcmpeqb m7, m3 ; abs(q3-q2) <= I
- pcmpeqb m6, m3 ; abs(q2-q1) <= I
- pand m0, m1
- pand m7, m6
- pand m0, m7
-%else ; mmxext/sse2
- pmaxub m0, m1
- pmaxub m6, m7
- pmaxub m0, m6
-%endif
-
- ; normal_limit and high_edge_variance for p1-p0, q1-q0
- SWAP 7, 3 ; now m7 is zero
-%ifidn %1, v
- movrow m3, [dst1q+mstrideq ] ; p0
-%if mmsize == 16 && %2 == 8
- movhps m3, [dst8q+mstrideq ]
-%endif
-%elifdef m12
- SWAP 3, 12
-%else
- mova m3, m_p0backup
-%endif
-
- mova m1, m2
- SWAP 1, 2
- mova m6, m3
- SWAP 3, 6
- psubusb m1, m3 ; p1-p0
- psubusb m6, m2 ; p0-p1
- por m1, m6 ; abs(p1-p0)
-%if notcpuflag(mmxext)
- mova m6, m1
- psubusb m1, m4
- psubusb m6, m_hevthr
- pcmpeqb m1, m7 ; abs(p1-p0) <= I
- pcmpeqb m6, m7 ; abs(p1-p0) <= hev_thresh
- pand m0, m1
- mova m_maskres, m6
-%else ; mmxext/sse2
- pmaxub m0, m1 ; max_I
- SWAP 1, 4 ; max_hev_thresh
-%endif
-
- SWAP 6, 4 ; now m6 is I
-%ifidn %1, v
- movrow m4, [dst1q] ; q0
-%if mmsize == 16 && %2 == 8
- movhps m4, [dst8q]
-%endif
-%elifdef m8
- SWAP 4, 8
-%else
- mova m4, m_q0backup
-%endif
- mova m1, m4
- SWAP 1, 4
- mova m7, m5
- SWAP 7, 5
- psubusb m1, m5 ; q0-q1
- psubusb m7, m4 ; q1-q0
- por m1, m7 ; abs(q1-q0)
-%if notcpuflag(mmxext)
- mova m7, m1
- psubusb m1, m6
- psubusb m7, m_hevthr
- pxor m6, m6
- pcmpeqb m1, m6 ; abs(q1-q0) <= I
- pcmpeqb m7, m6 ; abs(q1-q0) <= hev_thresh
- mova m6, m_maskres
- pand m0, m1 ; abs([pq][321]-[pq][210]) <= I
- pand m6, m7
-%else ; mmxext/sse2
- pxor m7, m7
- pmaxub m0, m1
- pmaxub m6, m1
- psubusb m0, m_flimI
- psubusb m6, m_hevthr
- pcmpeqb m0, m7 ; max(abs(..)) <= I
- pcmpeqb m6, m7 ; !(max(abs..) > thresh)
-%endif
-%ifdef m12
- SWAP 6, 12
-%else
- mova m_maskres, m6 ; !(abs(p1-p0) > hev_t || abs(q1-q0) > hev_t)
-%endif
-
- ; simple_limit
- mova m1, m3
- SWAP 1, 3
- mova m6, m4 ; keep copies of p0/q0 around for later use
- SWAP 6, 4
- psubusb m1, m4 ; p0-q0
- psubusb m6, m3 ; q0-p0
- por m1, m6 ; abs(q0-p0)
- paddusb m1, m1 ; m1=2*abs(q0-p0)
-
- mova m7, m2
- SWAP 7, 2
- mova m6, m5
- SWAP 6, 5
- psubusb m7, m5 ; p1-q1
- psubusb m6, m2 ; q1-p1
- por m7, m6 ; abs(q1-p1)
- pxor m6, m6
- pand m7, [pb_FE]
- psrlq m7, 1 ; abs(q1-p1)/2
- paddusb m7, m1 ; abs(q0-p0)*2+abs(q1-p1)/2
- psubusb m7, m_flimE
- pcmpeqb m7, m6 ; abs(q0-p0)*2+abs(q1-p1)/2 <= E
- pand m0, m7 ; normal_limit result
-
- ; filter_common; at this point, m2-m5=p1-q1 and m0 is filter_mask
-%ifdef m8 ; x86-64 && sse2
- mova m8, [pb_80]
-%define m_pb_80 m8
-%else ; x86-32 or mmx/mmxext
-%define m_pb_80 [pb_80]
-%endif
- mova m1, m4
- mova m7, m3
- pxor m1, m_pb_80
- pxor m7, m_pb_80
- psubsb m1, m7 ; (signed) q0-p0
- mova m6, m2
- mova m7, m5
- pxor m6, m_pb_80
- pxor m7, m_pb_80
- psubsb m6, m7 ; (signed) p1-q1
- mova m7, m_maskres
- paddsb m6, m1
- paddsb m6, m1
- paddsb m6, m1
- pand m6, m0
-%ifdef m8
- mova m_limres, m6 ; 3*(qp-p0)+(p1-q1) masked for filter_mbedge
- pand m_limres, m7
-%else
- mova m0, m6
- pand m0, m7
- mova m_limres, m0
-%endif
- pandn m7, m6 ; 3*(q0-p0)+(p1-q1) masked for filter_common
-
- mova m1, [pb_F8]
- mova m6, m7
- paddsb m7, [pb_3]
- paddsb m6, [pb_4]
- pand m7, m1
- pand m6, m1
-
- pxor m1, m1
- pxor m0, m0
- pcmpgtb m1, m7
- psubb m0, m7
- psrlq m7, 3 ; +f2
- psrlq m0, 3 ; -f2
- pand m0, m1
- pandn m1, m7
- psubusb m3, m0
- paddusb m3, m1 ; p0+f2
-
- pxor m1, m1
- pxor m0, m0
- pcmpgtb m0, m6
- psubb m1, m6
- psrlq m6, 3 ; +f1
- psrlq m1, 3 ; -f1
- pand m1, m0
- pandn m0, m6
- psubusb m4, m0
- paddusb m4, m1 ; q0-f1
-
- ; filter_mbedge (m2-m5 = p1-q1; lim_res carries w)
-%if cpuflag(ssse3)
- mova m7, [pb_1]
-%else
- mova m7, [pw_63]
-%endif
-%ifdef m8
- SWAP 1, 8
-%else
- mova m1, m_limres
-%endif
- pxor m0, m0
- mova m6, m1
- pcmpgtb m0, m1 ; which are negative
-%if cpuflag(ssse3)
- punpcklbw m6, m7 ; interleave with "1" for rounding
- punpckhbw m1, m7
-%else
- punpcklbw m6, m0 ; signed byte->word
- punpckhbw m1, m0
-%endif
- mova m_limsign, m0
-%if cpuflag(ssse3)
- mova m7, [pb_27_63]
-%ifndef m8
- mova m_limres, m1
-%endif
-%ifdef m10
- SWAP 0, 10 ; don't lose lim_sign copy
-%endif
- mova m0, m7
- pmaddubsw m7, m6
- SWAP 6, 7
- pmaddubsw m0, m1
- SWAP 1, 0
-%ifdef m10
- SWAP 0, 10
-%else
- mova m0, m_limsign
-%endif
-%else
- mova m_maskres, m6 ; backup for later in filter
- mova m_limres, m1
- pmullw m6, [pw_27]
- pmullw m1, [pw_27]
- paddw m6, m7
- paddw m1, m7
-%endif
- psraw m6, 7
- psraw m1, 7
- packsswb m6, m1 ; a0
- pxor m1, m1
- psubb m1, m6
- pand m1, m0 ; -a0
- pandn m0, m6 ; +a0
-%if cpuflag(ssse3)
- mova m6, [pb_18_63] ; pipelining
-%endif
- psubusb m3, m1
- paddusb m4, m1
- paddusb m3, m0 ; p0+a0
- psubusb m4, m0 ; q0-a0
-
-%if cpuflag(ssse3)
- SWAP 6, 7
-%ifdef m10
- SWAP 1, 10
-%else
- mova m1, m_limres
-%endif
- mova m0, m7
- pmaddubsw m7, m6
- SWAP 6, 7
- pmaddubsw m0, m1
- SWAP 1, 0
-%ifdef m10
- SWAP 0, 10
-%endif
- mova m0, m_limsign
-%else
- mova m6, m_maskres
- mova m1, m_limres
- pmullw m6, [pw_18]
- pmullw m1, [pw_18]
- paddw m6, m7
- paddw m1, m7
-%endif
- mova m0, m_limsign
- psraw m6, 7
- psraw m1, 7
- packsswb m6, m1 ; a1
- pxor m1, m1
- psubb m1, m6
- pand m1, m0 ; -a1
- pandn m0, m6 ; +a1
-%if cpuflag(ssse3)
- mova m6, [pb_9_63]
-%endif
- psubusb m2, m1
- paddusb m5, m1
- paddusb m2, m0 ; p1+a1
- psubusb m5, m0 ; q1-a1
-
-%if cpuflag(ssse3)
- SWAP 6, 7
-%ifdef m10
- SWAP 1, 10
-%else
- mova m1, m_limres
-%endif
- mova m0, m7
- pmaddubsw m7, m6
- SWAP 6, 7
- pmaddubsw m0, m1
- SWAP 1, 0
-%else
-%ifdef m8
- SWAP 6, 12
- SWAP 1, 8
-%else
- mova m6, m_maskres
- mova m1, m_limres
-%endif
- pmullw m6, [pw_9]
- pmullw m1, [pw_9]
- paddw m6, m7
- paddw m1, m7
-%endif
-%ifdef m9
- SWAP 7, 9
-%else
- mova m7, m_limsign
-%endif
- psraw m6, 7
- psraw m1, 7
- packsswb m6, m1 ; a1
- pxor m0, m0
- psubb m0, m6
- pand m0, m7 ; -a1
- pandn m7, m6 ; +a1
-%ifdef m8
- SWAP 1, 13
- SWAP 6, 14
-%else
- mova m1, m_p2backup
- mova m6, m_q2backup
-%endif
- psubusb m1, m0
- paddusb m6, m0
- paddusb m1, m7 ; p1+a1
- psubusb m6, m7 ; q1-a1
-
- ; store
-%ifidn %1, v
- movrow [dst2q+mstrideq*4], m1
- movrow [dst1q+mstrideq*2], m2
- movrow [dst1q+mstrideq ], m3
- movrow [dst1q], m4
- movrow [dst2q], m5
- movrow [dst2q+ strideq ], m6
-%if mmsize == 16 && %2 == 8
- add dst8q, mstrideq
- movhps [dst8q+mstrideq*2], m1
- movhps [dst8q+mstrideq ], m2
- movhps [dst8q], m3
- add dst8q, strideq
- movhps [dst8q], m4
- movhps [dst8q+ strideq ], m5
- movhps [dst8q+ strideq*2], m6
-%endif
-%else ; h
- inc dst1q
- inc dst2q
-
- ; 4x8/16 transpose
- TRANSPOSE4x4B 1, 2, 3, 4, 0
- SBUTTERFLY bw, 5, 6, 0
-
-%if mmsize == 8 ; mmx/mmxext (h)
- WRITE_4x2D 1, 2, 3, 4, dst1q, dst2q, mstrideq, strideq
- add dst1q, 4
- WRITE_2x4W m5, m6, dst2q, dst1q, mstrideq, strideq
-%else ; sse2 (h)
- lea dst8q, [dst8q+mstrideq+1]
- WRITE_4x4D 1, 2, 3, 4, dst1q, dst2q, dst8q, mstrideq, strideq, %2
- lea dst1q, [dst2q+mstrideq+4]
- lea dst8q, [dst8q+mstrideq+4]
-%if cpuflag(sse4)
- add dst2q, 4
-%endif
- WRITE_8W m5, dst2q, dst1q, mstrideq, strideq
-%if cpuflag(sse4)
- lea dst2q, [dst8q+ strideq ]
-%endif
- WRITE_8W m6, dst2q, dst8q, mstrideq, strideq
-%endif
-%endif
-
-%if mmsize == 8
-%if %2 == 8 ; chroma
-%ifidn %1, h
- sub dst1q, 5
-%endif
- cmp dst1q, dst8q
- mov dst1q, dst8q
- jnz .next8px
-%else
-%ifidn %1, h
- lea dst1q, [dst1q+ strideq*8-5]
-%else ; v
- add dst1q, 8
-%endif
- dec cntrq
- jg .next8px
-%endif
- REP_RET
-%else ; mmsize == 16
- RET
-%endif
-%endmacro
-
-%if ARCH_X86_32
-INIT_MMX mmx
-MBEDGE_LOOPFILTER v, 16
-MBEDGE_LOOPFILTER h, 16
-MBEDGE_LOOPFILTER v, 8
-MBEDGE_LOOPFILTER h, 8
-
-INIT_MMX mmxext
-MBEDGE_LOOPFILTER v, 16
-MBEDGE_LOOPFILTER h, 16
-MBEDGE_LOOPFILTER v, 8
-MBEDGE_LOOPFILTER h, 8
-%endif
-
-INIT_XMM sse2
-MBEDGE_LOOPFILTER v, 16
-MBEDGE_LOOPFILTER h, 16
-MBEDGE_LOOPFILTER v, 8
-MBEDGE_LOOPFILTER h, 8
-
-INIT_XMM ssse3
-MBEDGE_LOOPFILTER v, 16
-MBEDGE_LOOPFILTER h, 16
-MBEDGE_LOOPFILTER v, 8
-MBEDGE_LOOPFILTER h, 8
-
-INIT_XMM sse4
-MBEDGE_LOOPFILTER h, 16
-MBEDGE_LOOPFILTER h, 8
diff --git a/src/thirdparty/ffmpeg/libavcodec/x86/vp8dsp_init.c b/src/thirdparty/ffmpeg/libavcodec/x86/vp8dsp_init.c
deleted file mode 100644
index 09e2d9109..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/x86/vp8dsp_init.c
+++ /dev/null
@@ -1,442 +0,0 @@
-/*
- * VP8 DSP functions x86-optimized
- * Copyright (c) 2010 Ronald S. Bultje <rsbultje@gmail.com>
- * Copyright (c) 2010 Jason Garrett-Glaser <darkshikari@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/cpu.h"
-#include "libavutil/mem.h"
-#include "libavutil/x86/asm.h"
-#include "libavcodec/vp8dsp.h"
-
-#if HAVE_YASM
-
-/*
- * MC functions
- */
-extern void ff_put_vp8_epel4_h4_mmxext(uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-extern void ff_put_vp8_epel4_h6_mmxext(uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-extern void ff_put_vp8_epel4_v4_mmxext(uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-extern void ff_put_vp8_epel4_v6_mmxext(uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-
-extern void ff_put_vp8_epel8_h4_sse2 (uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-extern void ff_put_vp8_epel8_h6_sse2 (uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-extern void ff_put_vp8_epel8_v4_sse2 (uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-extern void ff_put_vp8_epel8_v6_sse2 (uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-
-extern void ff_put_vp8_epel4_h4_ssse3 (uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-extern void ff_put_vp8_epel4_h6_ssse3 (uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-extern void ff_put_vp8_epel4_v4_ssse3 (uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-extern void ff_put_vp8_epel4_v6_ssse3 (uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-extern void ff_put_vp8_epel8_h4_ssse3 (uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-extern void ff_put_vp8_epel8_h6_ssse3 (uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-extern void ff_put_vp8_epel8_v4_ssse3 (uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-extern void ff_put_vp8_epel8_v6_ssse3 (uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-
-extern void ff_put_vp8_bilinear4_h_mmxext(uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-extern void ff_put_vp8_bilinear8_h_sse2 (uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-extern void ff_put_vp8_bilinear4_h_ssse3 (uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-extern void ff_put_vp8_bilinear8_h_ssse3 (uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-
-extern void ff_put_vp8_bilinear4_v_mmxext(uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-extern void ff_put_vp8_bilinear8_v_sse2 (uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-extern void ff_put_vp8_bilinear4_v_ssse3 (uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-extern void ff_put_vp8_bilinear8_v_ssse3 (uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-
-
-extern void ff_put_vp8_pixels8_mmx (uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-extern void ff_put_vp8_pixels16_mmx(uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-extern void ff_put_vp8_pixels16_sse(uint8_t *dst, ptrdiff_t dststride,
- uint8_t *src, ptrdiff_t srcstride,
- int height, int mx, int my);
-
-#define TAP_W16(OPT, FILTERTYPE, TAPTYPE) \
-static void ff_put_vp8_ ## FILTERTYPE ## 16_ ## TAPTYPE ## _ ## OPT( \
- uint8_t *dst, ptrdiff_t dststride, uint8_t *src, \
- ptrdiff_t srcstride, int height, int mx, int my) \
-{ \
- ff_put_vp8_ ## FILTERTYPE ## 8_ ## TAPTYPE ## _ ## OPT( \
- dst, dststride, src, srcstride, height, mx, my); \
- ff_put_vp8_ ## FILTERTYPE ## 8_ ## TAPTYPE ## _ ## OPT( \
- dst + 8, dststride, src + 8, srcstride, height, mx, my); \
-}
-#define TAP_W8(OPT, FILTERTYPE, TAPTYPE) \
-static void ff_put_vp8_ ## FILTERTYPE ## 8_ ## TAPTYPE ## _ ## OPT( \
- uint8_t *dst, ptrdiff_t dststride, uint8_t *src, \
- ptrdiff_t srcstride, int height, int mx, int my) \
-{ \
- ff_put_vp8_ ## FILTERTYPE ## 4_ ## TAPTYPE ## _ ## OPT( \
- dst, dststride, src, srcstride, height, mx, my); \
- ff_put_vp8_ ## FILTERTYPE ## 4_ ## TAPTYPE ## _ ## OPT( \
- dst + 4, dststride, src + 4, srcstride, height, mx, my); \
-}
-
-#if ARCH_X86_32
-TAP_W8 (mmxext, epel, h4)
-TAP_W8 (mmxext, epel, h6)
-TAP_W16(mmxext, epel, h6)
-TAP_W8 (mmxext, epel, v4)
-TAP_W8 (mmxext, epel, v6)
-TAP_W16(mmxext, epel, v6)
-TAP_W8 (mmxext, bilinear, h)
-TAP_W16(mmxext, bilinear, h)
-TAP_W8 (mmxext, bilinear, v)
-TAP_W16(mmxext, bilinear, v)
-#endif
-
-TAP_W16(sse2, epel, h6)
-TAP_W16(sse2, epel, v6)
-TAP_W16(sse2, bilinear, h)
-TAP_W16(sse2, bilinear, v)
-
-TAP_W16(ssse3, epel, h6)
-TAP_W16(ssse3, epel, v6)
-TAP_W16(ssse3, bilinear, h)
-TAP_W16(ssse3, bilinear, v)
-
-#define HVTAP(OPT, ALIGN, TAPNUMX, TAPNUMY, SIZE, MAXHEIGHT) \
-static void ff_put_vp8_epel ## SIZE ## _h ## TAPNUMX ## v ## TAPNUMY ## _ ## OPT( \
- uint8_t *dst, ptrdiff_t dststride, uint8_t *src, \
- ptrdiff_t srcstride, int height, int mx, int my) \
-{ \
- DECLARE_ALIGNED(ALIGN, uint8_t, tmp)[SIZE * (MAXHEIGHT + TAPNUMY - 1)]; \
- uint8_t *tmpptr = tmp + SIZE * (TAPNUMY / 2 - 1); \
- src -= srcstride * (TAPNUMY / 2 - 1); \
- ff_put_vp8_epel ## SIZE ## _h ## TAPNUMX ## _ ## OPT( \
- tmp, SIZE, src, srcstride, height + TAPNUMY - 1, mx, my); \
- ff_put_vp8_epel ## SIZE ## _v ## TAPNUMY ## _ ## OPT( \
- dst, dststride, tmpptr, SIZE, height, mx, my); \
-}
-
-#if ARCH_X86_32
-#define HVTAPMMX(x, y) \
-HVTAP(mmxext, 8, x, y, 4, 8) \
-HVTAP(mmxext, 8, x, y, 8, 16)
-
-HVTAP(mmxext, 8, 6, 6, 16, 16)
-#else
-#define HVTAPMMX(x, y) \
-HVTAP(mmxext, 8, x, y, 4, 8)
-#endif
-
-HVTAPMMX(4, 4)
-HVTAPMMX(4, 6)
-HVTAPMMX(6, 4)
-HVTAPMMX(6, 6)
-
-#define HVTAPSSE2(x, y, w) \
-HVTAP(sse2, 16, x, y, w, 16) \
-HVTAP(ssse3, 16, x, y, w, 16)
-
-HVTAPSSE2(4, 4, 8)
-HVTAPSSE2(4, 6, 8)
-HVTAPSSE2(6, 4, 8)
-HVTAPSSE2(6, 6, 8)
-HVTAPSSE2(6, 6, 16)
-
-HVTAP(ssse3, 16, 4, 4, 4, 8)
-HVTAP(ssse3, 16, 4, 6, 4, 8)
-HVTAP(ssse3, 16, 6, 4, 4, 8)
-HVTAP(ssse3, 16, 6, 6, 4, 8)
-
-#define HVBILIN(OPT, ALIGN, SIZE, MAXHEIGHT) \
-static void ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT( \
- uint8_t *dst, ptrdiff_t dststride, uint8_t *src, \
- ptrdiff_t srcstride, int height, int mx, int my) \
-{ \
- DECLARE_ALIGNED(ALIGN, uint8_t, tmp)[SIZE * (MAXHEIGHT + 2)]; \
- ff_put_vp8_bilinear ## SIZE ## _h_ ## OPT( \
- tmp, SIZE, src, srcstride, height + 1, mx, my); \
- ff_put_vp8_bilinear ## SIZE ## _v_ ## OPT( \
- dst, dststride, tmp, SIZE, height, mx, my); \
-}
-
-HVBILIN(mmxext, 8, 4, 8)
-#if ARCH_X86_32
-HVBILIN(mmxext, 8, 8, 16)
-HVBILIN(mmxext, 8, 16, 16)
-#endif
-HVBILIN(sse2, 8, 8, 16)
-HVBILIN(sse2, 8, 16, 16)
-HVBILIN(ssse3, 8, 4, 8)
-HVBILIN(ssse3, 8, 8, 16)
-HVBILIN(ssse3, 8, 16, 16)
-
-extern void ff_vp8_idct_dc_add_mmx(uint8_t *dst, int16_t block[16],
- ptrdiff_t stride);
-extern void ff_vp8_idct_dc_add_sse4(uint8_t *dst, int16_t block[16],
- ptrdiff_t stride);
-extern void ff_vp8_idct_dc_add4y_mmx(uint8_t *dst, int16_t block[4][16],
- ptrdiff_t stride);
-extern void ff_vp8_idct_dc_add4y_sse2(uint8_t *dst, int16_t block[4][16],
- ptrdiff_t stride);
-extern void ff_vp8_idct_dc_add4uv_mmx(uint8_t *dst, int16_t block[2][16],
- ptrdiff_t stride);
-extern void ff_vp8_luma_dc_wht_mmx(int16_t block[4][4][16], int16_t dc[16]);
-extern void ff_vp8_luma_dc_wht_sse(int16_t block[4][4][16], int16_t dc[16]);
-extern void ff_vp8_idct_add_mmx(uint8_t *dst, int16_t block[16],
- ptrdiff_t stride);
-extern void ff_vp8_idct_add_sse(uint8_t *dst, int16_t block[16],
- ptrdiff_t stride);
-
-#define DECLARE_LOOP_FILTER(NAME)\
-extern void ff_vp8_v_loop_filter_simple_ ## NAME(uint8_t *dst, \
- ptrdiff_t stride, \
- int flim);\
-extern void ff_vp8_h_loop_filter_simple_ ## NAME(uint8_t *dst, \
- ptrdiff_t stride, \
- int flim);\
-extern void ff_vp8_v_loop_filter16y_inner_ ## NAME (uint8_t *dst, \
- ptrdiff_t stride,\
- int e, int i, int hvt);\
-extern void ff_vp8_h_loop_filter16y_inner_ ## NAME (uint8_t *dst, \
- ptrdiff_t stride,\
- int e, int i, int hvt);\
-extern void ff_vp8_v_loop_filter8uv_inner_ ## NAME (uint8_t *dstU, \
- uint8_t *dstV,\
- ptrdiff_t s, \
- int e, int i, int hvt);\
-extern void ff_vp8_h_loop_filter8uv_inner_ ## NAME (uint8_t *dstU, \
- uint8_t *dstV,\
- ptrdiff_t s, \
- int e, int i, int hvt);\
-extern void ff_vp8_v_loop_filter16y_mbedge_ ## NAME(uint8_t *dst, \
- ptrdiff_t stride,\
- int e, int i, int hvt);\
-extern void ff_vp8_h_loop_filter16y_mbedge_ ## NAME(uint8_t *dst, \
- ptrdiff_t stride,\
- int e, int i, int hvt);\
-extern void ff_vp8_v_loop_filter8uv_mbedge_ ## NAME(uint8_t *dstU, \
- uint8_t *dstV,\
- ptrdiff_t s, \
- int e, int i, int hvt);\
-extern void ff_vp8_h_loop_filter8uv_mbedge_ ## NAME(uint8_t *dstU, \
- uint8_t *dstV,\
- ptrdiff_t s, \
- int e, int i, int hvt);
-
-DECLARE_LOOP_FILTER(mmx)
-DECLARE_LOOP_FILTER(mmxext)
-DECLARE_LOOP_FILTER(sse2)
-DECLARE_LOOP_FILTER(ssse3)
-DECLARE_LOOP_FILTER(sse4)
-
-#endif /* HAVE_YASM */
-
-#define VP8_LUMA_MC_FUNC(IDX, SIZE, OPT) \
- c->put_vp8_epel_pixels_tab[IDX][0][2] = ff_put_vp8_epel ## SIZE ## _h6_ ## OPT; \
- c->put_vp8_epel_pixels_tab[IDX][2][0] = ff_put_vp8_epel ## SIZE ## _v6_ ## OPT; \
- c->put_vp8_epel_pixels_tab[IDX][2][2] = ff_put_vp8_epel ## SIZE ## _h6v6_ ## OPT
-
-#define VP8_MC_FUNC(IDX, SIZE, OPT) \
- c->put_vp8_epel_pixels_tab[IDX][0][1] = ff_put_vp8_epel ## SIZE ## _h4_ ## OPT; \
- c->put_vp8_epel_pixels_tab[IDX][1][0] = ff_put_vp8_epel ## SIZE ## _v4_ ## OPT; \
- c->put_vp8_epel_pixels_tab[IDX][1][1] = ff_put_vp8_epel ## SIZE ## _h4v4_ ## OPT; \
- c->put_vp8_epel_pixels_tab[IDX][1][2] = ff_put_vp8_epel ## SIZE ## _h6v4_ ## OPT; \
- c->put_vp8_epel_pixels_tab[IDX][2][1] = ff_put_vp8_epel ## SIZE ## _h4v6_ ## OPT; \
- VP8_LUMA_MC_FUNC(IDX, SIZE, OPT)
-
-#define VP8_BILINEAR_MC_FUNC(IDX, SIZE, OPT) \
- c->put_vp8_bilinear_pixels_tab[IDX][0][1] = ff_put_vp8_bilinear ## SIZE ## _h_ ## OPT; \
- c->put_vp8_bilinear_pixels_tab[IDX][0][2] = ff_put_vp8_bilinear ## SIZE ## _h_ ## OPT; \
- c->put_vp8_bilinear_pixels_tab[IDX][1][0] = ff_put_vp8_bilinear ## SIZE ## _v_ ## OPT; \
- c->put_vp8_bilinear_pixels_tab[IDX][1][1] = ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT; \
- c->put_vp8_bilinear_pixels_tab[IDX][1][2] = ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT; \
- c->put_vp8_bilinear_pixels_tab[IDX][2][0] = ff_put_vp8_bilinear ## SIZE ## _v_ ## OPT; \
- c->put_vp8_bilinear_pixels_tab[IDX][2][1] = ff_put_vp8_bilinear ## SIZE ## _hv_ ## OPT; \
- 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)
-{
-#if HAVE_YASM
- int mm_flags = av_get_cpu_flags();
-
- if (mm_flags & AV_CPU_FLAG_MMX) {
- 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;
-
-#if ARCH_X86_32
- 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;
-
- c->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16y_inner_mmx;
- c->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16y_inner_mmx;
- c->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_mmx;
- c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_mmx;
-
- c->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16y_mbedge_mmx;
- c->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16y_mbedge_mmx;
- c->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_mbedge_mmx;
- c->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_mbedge_mmx;
-#endif
- }
-
- /* 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 (mm_flags & AV_CPU_FLAG_MMXEXT) {
- 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;
-
- c->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16y_inner_mmxext;
- c->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16y_inner_mmxext;
- c->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_mmxext;
- c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_mmxext;
-
- c->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16y_mbedge_mmxext;
- c->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16y_mbedge_mmxext;
- c->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_mbedge_mmxext;
- c->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_mbedge_mmxext;
-#endif
- }
-
- if (mm_flags & AV_CPU_FLAG_SSE) {
- 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 (mm_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;
- c->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_sse2;
-
- c->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16y_mbedge_sse2;
- c->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_mbedge_sse2;
- }
-
- if (mm_flags & AV_CPU_FLAG_SSE2) {
- 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_filter16y_inner = ff_vp8_h_loop_filter16y_inner_sse2;
- c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_sse2;
-
- c->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16y_mbedge_sse2;
- c->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_mbedge_sse2;
- }
-
- if (mm_flags & AV_CPU_FLAG_SSSE3) {
- 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;
-
- c->vp8_v_loop_filter16y_inner = ff_vp8_v_loop_filter16y_inner_ssse3;
- c->vp8_h_loop_filter16y_inner = ff_vp8_h_loop_filter16y_inner_ssse3;
- c->vp8_v_loop_filter8uv_inner = ff_vp8_v_loop_filter8uv_inner_ssse3;
- c->vp8_h_loop_filter8uv_inner = ff_vp8_h_loop_filter8uv_inner_ssse3;
-
- c->vp8_v_loop_filter16y = ff_vp8_v_loop_filter16y_mbedge_ssse3;
- c->vp8_h_loop_filter16y = ff_vp8_h_loop_filter16y_mbedge_ssse3;
- c->vp8_v_loop_filter8uv = ff_vp8_v_loop_filter8uv_mbedge_ssse3;
- c->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_mbedge_ssse3;
- }
-
- if (mm_flags & AV_CPU_FLAG_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;
- c->vp8_h_loop_filter8uv = ff_vp8_h_loop_filter8uv_mbedge_sse4;
- }
-#endif /* HAVE_YASM */
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/xiph.c b/src/thirdparty/ffmpeg/libavcodec/xiph.c
deleted file mode 100644
index 4620ae484..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/xiph.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2007 FFmpeg Project
- *
- * 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 "xiph.h"
-
-int avpriv_split_xiph_headers(uint8_t *extradata, int extradata_size,
- int first_header_size, uint8_t *header_start[3],
- int header_len[3])
-{
- int i;
-
- if (extradata_size >= 6 && AV_RB16(extradata) == first_header_size) {
- int overall_len = 6;
- for (i=0; i<3; i++) {
- header_len[i] = AV_RB16(extradata);
- extradata += 2;
- header_start[i] = extradata;
- extradata += header_len[i];
- if (overall_len > extradata_size - header_len[i])
- return -1;
- overall_len += header_len[i];
- }
- } else if (extradata_size >= 3 && extradata_size < INT_MAX - 0x1ff && extradata[0] == 2) {
- int overall_len = 3;
- extradata++;
- for (i=0; i<2; i++, extradata++) {
- header_len[i] = 0;
- for (; overall_len < extradata_size && *extradata==0xff; extradata++) {
- header_len[i] += 0xff;
- overall_len += 0xff + 1;
- }
- header_len[i] += *extradata;
- overall_len += *extradata;
- if (overall_len > extradata_size)
- return -1;
- }
- header_len[2] = extradata_size - overall_len;
- header_start[0] = extradata;
- header_start[1] = header_start[0] + header_len[0];
- header_start[2] = header_start[1] + header_len[1];
- } else {
- return -1;
- }
- return 0;
-}
diff --git a/src/thirdparty/ffmpeg/libavcodec/xiph.h b/src/thirdparty/ffmpeg/libavcodec/xiph.h
deleted file mode 100644
index 7fd8472b4..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/xiph.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2007 FFmpeg Project
- *
- * 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_XIPH_H
-#define AVCODEC_XIPH_H
-
-#include "libavutil/common.h"
-
-/**
- * Split a single extradata buffer into the three headers that most
- * Xiph codecs use. (e.g. Theora and Vorbis)
- * Works both with Matroska's packing and lavc's packing.
- *
- * @param[in] extradata The single chunk that combines all three headers
- * @param[in] extradata_size The size of the extradata buffer
- * @param[in] first_header_size The size of the first header, used to
- * differentiate between the Matroska packing and lavc packing.
- * @param[out] header_start Pointers to the start of the three separate headers.
- * @param[out] header_len The sizes of each of the three headers.
- * @return On error a negative value is returned, on success zero.
- */
-int avpriv_split_xiph_headers(uint8_t *extradata, int extradata_size,
- int first_header_size, uint8_t *header_start[3],
- int header_len[3]);
-
-#endif /* AVCODEC_XIPH_H */
diff --git a/src/thirdparty/ffmpeg/libavcodec/xvmc_internal.h b/src/thirdparty/ffmpeg/libavcodec/xvmc_internal.h
deleted file mode 100644
index ccf377929..000000000
--- a/src/thirdparty/ffmpeg/libavcodec/xvmc_internal.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * XVideo Motion Compensation internal 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_XVMC_INTERNAL_H
-#define AVCODEC_XVMC_INTERNAL_H
-
-#include "avcodec.h"
-#include "mpegvideo.h"
-
-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 /* AVCODEC_XVMC_INTERNAL_H */
diff --git a/src/thirdparty/ffmpeg/libavresample/audio_convert.c b/src/thirdparty/ffmpeg/libavresample/audio_convert.c
deleted file mode 100644
index 371617cc2..000000000
--- a/src/thirdparty/ffmpeg/libavresample/audio_convert.c
+++ /dev/null
@@ -1,414 +0,0 @@
-/*
- * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
- * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdint.h>
-
-#include "config.h"
-#include "libavutil/common.h"
-#include "libavutil/libm.h"
-#include "libavutil/log.h"
-#include "libavutil/mem.h"
-#include "libavutil/samplefmt.h"
-#include "audio_convert.h"
-#include "audio_data.h"
-#include "dither.h"
-
-enum ConvFuncType {
- CONV_FUNC_TYPE_FLAT,
- CONV_FUNC_TYPE_INTERLEAVE,
- CONV_FUNC_TYPE_DEINTERLEAVE,
-};
-
-typedef void (conv_func_flat)(uint8_t *out, const uint8_t *in, int len);
-
-typedef void (conv_func_interleave)(uint8_t *out, uint8_t *const *in,
- int len, int channels);
-
-typedef void (conv_func_deinterleave)(uint8_t **out, const uint8_t *in, int len,
- int channels);
-
-struct AudioConvert {
- AVAudioResampleContext *avr;
- DitherContext *dc;
- enum AVSampleFormat in_fmt;
- enum AVSampleFormat out_fmt;
- int apply_map;
- int channels;
- int planes;
- int ptr_align;
- int samples_align;
- int has_optimized_func;
- const char *func_descr;
- const char *func_descr_generic;
- enum ConvFuncType func_type;
- conv_func_flat *conv_flat;
- conv_func_flat *conv_flat_generic;
- conv_func_interleave *conv_interleave;
- conv_func_interleave *conv_interleave_generic;
- conv_func_deinterleave *conv_deinterleave;
- conv_func_deinterleave *conv_deinterleave_generic;
-};
-
-void ff_audio_convert_set_func(AudioConvert *ac, enum AVSampleFormat out_fmt,
- enum AVSampleFormat in_fmt, int channels,
- int ptr_align, int samples_align,
- const char *descr, void *conv)
-{
- int found = 0;
-
- switch (ac->func_type) {
- case CONV_FUNC_TYPE_FLAT:
- if (av_get_packed_sample_fmt(ac->in_fmt) == in_fmt &&
- av_get_packed_sample_fmt(ac->out_fmt) == out_fmt) {
- ac->conv_flat = conv;
- ac->func_descr = descr;
- ac->ptr_align = ptr_align;
- ac->samples_align = samples_align;
- if (ptr_align == 1 && samples_align == 1) {
- ac->conv_flat_generic = conv;
- ac->func_descr_generic = descr;
- } else {
- ac->has_optimized_func = 1;
- }
- found = 1;
- }
- break;
- case CONV_FUNC_TYPE_INTERLEAVE:
- if (ac->in_fmt == in_fmt && ac->out_fmt == out_fmt &&
- (!channels || ac->channels == channels)) {
- ac->conv_interleave = conv;
- ac->func_descr = descr;
- ac->ptr_align = ptr_align;
- ac->samples_align = samples_align;
- if (ptr_align == 1 && samples_align == 1) {
- ac->conv_interleave_generic = conv;
- ac->func_descr_generic = descr;
- } else {
- ac->has_optimized_func = 1;
- }
- found = 1;
- }
- break;
- case CONV_FUNC_TYPE_DEINTERLEAVE:
- if (ac->in_fmt == in_fmt && ac->out_fmt == out_fmt &&
- (!channels || ac->channels == channels)) {
- ac->conv_deinterleave = conv;
- ac->func_descr = descr;
- ac->ptr_align = ptr_align;
- ac->samples_align = samples_align;
- if (ptr_align == 1 && samples_align == 1) {
- ac->conv_deinterleave_generic = conv;
- ac->func_descr_generic = descr;
- } else {
- ac->has_optimized_func = 1;
- }
- found = 1;
- }
- break;
- }
- if (found) {
- av_log(ac->avr, AV_LOG_DEBUG, "audio_convert: found function: %-4s "
- "to %-4s (%s)\n", av_get_sample_fmt_name(ac->in_fmt),
- av_get_sample_fmt_name(ac->out_fmt), descr);
- }
-}
-
-#define CONV_FUNC_NAME(dst_fmt, src_fmt) conv_ ## src_fmt ## _to_ ## dst_fmt
-
-#define CONV_LOOP(otype, expr) \
- do { \
- *(otype *)po = expr; \
- pi += is; \
- po += os; \
- } while (po < end); \
-
-#define CONV_FUNC_FLAT(ofmt, otype, ifmt, itype, expr) \
-static void CONV_FUNC_NAME(ofmt, ifmt)(uint8_t *out, const uint8_t *in, \
- int len) \
-{ \
- int is = sizeof(itype); \
- int os = sizeof(otype); \
- const uint8_t *pi = in; \
- uint8_t *po = out; \
- uint8_t *end = out + os * len; \
- CONV_LOOP(otype, expr) \
-}
-
-#define CONV_FUNC_INTERLEAVE(ofmt, otype, ifmt, itype, expr) \
-static void CONV_FUNC_NAME(ofmt, ifmt)(uint8_t *out, const uint8_t **in, \
- int len, int channels) \
-{ \
- int ch; \
- int out_bps = sizeof(otype); \
- int is = sizeof(itype); \
- int os = channels * out_bps; \
- for (ch = 0; ch < channels; ch++) { \
- const uint8_t *pi = in[ch]; \
- uint8_t *po = out + ch * out_bps; \
- uint8_t *end = po + os * len; \
- CONV_LOOP(otype, expr) \
- } \
-}
-
-#define CONV_FUNC_DEINTERLEAVE(ofmt, otype, ifmt, itype, expr) \
-static void CONV_FUNC_NAME(ofmt, ifmt)(uint8_t **out, const uint8_t *in, \
- int len, int channels) \
-{ \
- int ch; \
- int in_bps = sizeof(itype); \
- int is = channels * in_bps; \
- int os = sizeof(otype); \
- for (ch = 0; ch < channels; ch++) { \
- const uint8_t *pi = in + ch * in_bps; \
- uint8_t *po = out[ch]; \
- uint8_t *end = po + os * len; \
- CONV_LOOP(otype, expr) \
- } \
-}
-
-#define CONV_FUNC_GROUP(ofmt, otype, ifmt, itype, expr) \
-CONV_FUNC_FLAT( ofmt, otype, ifmt, itype, expr) \
-CONV_FUNC_INTERLEAVE( ofmt, otype, ifmt ## P, itype, expr) \
-CONV_FUNC_DEINTERLEAVE(ofmt ## P, otype, ifmt, itype, expr)
-
-CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_U8, uint8_t, *(const uint8_t *)pi)
-CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_U8, uint8_t, (*(const uint8_t *)pi - 0x80) << 8)
-CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_U8, uint8_t, (*(const uint8_t *)pi - 0x80) << 24)
-CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t, (*(const uint8_t *)pi - 0x80) * (1.0f / (1 << 7)))
-CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t, (*(const uint8_t *)pi - 0x80) * (1.0 / (1 << 7)))
-CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t, (*(const int16_t *)pi >> 8) + 0x80)
-CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *)pi)
-CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *)pi << 16)
-CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *)pi * (1.0f / (1 << 15)))
-CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *)pi * (1.0 / (1 << 15)))
-CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t, (*(const int32_t *)pi >> 24) + 0x80)
-CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *)pi >> 16)
-CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *)pi)
-CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *)pi * (1.0f / (1U << 31)))
-CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *)pi * (1.0 / (1U << 31)))
-CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8( lrintf(*(const float *)pi * (1 << 7)) + 0x80))
-CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16( lrintf(*(const float *)pi * (1 << 15))))
-CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *)pi * (1U << 31))))
-CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_FLT, float, *(const float *)pi)
-CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_FLT, float, *(const float *)pi)
-CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8( lrint(*(const double *)pi * (1 << 7)) + 0x80))
-CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16( lrint(*(const double *)pi * (1 << 15))))
-CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *)pi * (1U << 31))))
-CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_DBL, double, *(const double *)pi)
-CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_DBL, double, *(const double *)pi)
-
-#define SET_CONV_FUNC_GROUP(ofmt, ifmt) \
-ff_audio_convert_set_func(ac, ofmt, ifmt, 0, 1, 1, "C", CONV_FUNC_NAME(ofmt, ifmt)); \
-ff_audio_convert_set_func(ac, ofmt ## P, ifmt, 0, 1, 1, "C", CONV_FUNC_NAME(ofmt ## P, ifmt)); \
-ff_audio_convert_set_func(ac, ofmt, ifmt ## P, 0, 1, 1, "C", CONV_FUNC_NAME(ofmt, ifmt ## P));
-
-static void set_generic_function(AudioConvert *ac)
-{
- SET_CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8)
- SET_CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8)
- SET_CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8)
- SET_CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8)
- SET_CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8)
- SET_CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16)
- SET_CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16)
- SET_CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16)
- SET_CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16)
- SET_CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16)
- SET_CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32)
- SET_CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32)
- SET_CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32)
- SET_CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32)
- SET_CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32)
- SET_CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT)
- SET_CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT)
- SET_CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT)
- SET_CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT)
- SET_CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT)
- SET_CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL)
- SET_CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL)
- SET_CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL)
- SET_CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL)
- SET_CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL)
-}
-
-void ff_audio_convert_free(AudioConvert **ac)
-{
- if (!*ac)
- return;
- ff_dither_free(&(*ac)->dc);
- av_freep(ac);
-}
-
-AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr,
- enum AVSampleFormat out_fmt,
- enum AVSampleFormat in_fmt,
- int channels, int sample_rate,
- int apply_map)
-{
- AudioConvert *ac;
- int in_planar, out_planar;
-
- ac = av_mallocz(sizeof(*ac));
- if (!ac)
- return NULL;
-
- ac->avr = avr;
- ac->out_fmt = out_fmt;
- ac->in_fmt = in_fmt;
- ac->channels = channels;
- ac->apply_map = apply_map;
-
- if (avr->dither_method != AV_RESAMPLE_DITHER_NONE &&
- av_get_packed_sample_fmt(out_fmt) == AV_SAMPLE_FMT_S16 &&
- av_get_bytes_per_sample(in_fmt) > 2) {
- ac->dc = ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate,
- apply_map);
- if (!ac->dc) {
- av_free(ac);
- return NULL;
- }
- return ac;
- }
-
- in_planar = av_sample_fmt_is_planar(in_fmt);
- out_planar = av_sample_fmt_is_planar(out_fmt);
-
- if (in_planar == out_planar) {
- ac->func_type = CONV_FUNC_TYPE_FLAT;
- ac->planes = in_planar ? ac->channels : 1;
- } else if (in_planar)
- ac->func_type = CONV_FUNC_TYPE_INTERLEAVE;
- else
- ac->func_type = CONV_FUNC_TYPE_DEINTERLEAVE;
-
- set_generic_function(ac);
-
- if (ARCH_ARM)
- ff_audio_convert_init_arm(ac);
- if (ARCH_X86)
- ff_audio_convert_init_x86(ac);
-
- return ac;
-}
-
-int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in)
-{
- int use_generic = 1;
- int len = in->nb_samples;
- int p;
-
- if (ac->dc) {
- /* dithered conversion */
- av_dlog(ac->avr, "%d samples - audio_convert: %s to %s (dithered)\n",
- len, av_get_sample_fmt_name(ac->in_fmt),
- av_get_sample_fmt_name(ac->out_fmt));
-
- return ff_convert_dither(ac->dc, out, in);
- }
-
- /* determine whether to use the optimized function based on pointer and
- samples alignment in both the input and output */
- if (ac->has_optimized_func) {
- int ptr_align = FFMIN(in->ptr_align, out->ptr_align);
- int samples_align = FFMIN(in->samples_align, out->samples_align);
- int aligned_len = FFALIGN(len, ac->samples_align);
- if (!(ptr_align % ac->ptr_align) && samples_align >= aligned_len) {
- len = aligned_len;
- use_generic = 0;
- }
- }
- av_dlog(ac->avr, "%d samples - audio_convert: %s to %s (%s)\n", len,
- av_get_sample_fmt_name(ac->in_fmt),
- av_get_sample_fmt_name(ac->out_fmt),
- use_generic ? ac->func_descr_generic : ac->func_descr);
-
- if (ac->apply_map) {
- ChannelMapInfo *map = &ac->avr->ch_map_info;
-
- if (!av_sample_fmt_is_planar(ac->out_fmt)) {
- av_log(ac->avr, AV_LOG_ERROR, "cannot remap packed format during conversion\n");
- return AVERROR(EINVAL);
- }
-
- if (map->do_remap) {
- if (av_sample_fmt_is_planar(ac->in_fmt)) {
- conv_func_flat *convert = use_generic ? ac->conv_flat_generic :
- ac->conv_flat;
-
- for (p = 0; p < ac->planes; p++)
- if (map->channel_map[p] >= 0)
- convert(out->data[p], in->data[map->channel_map[p]], len);
- } else {
- uint8_t *data[AVRESAMPLE_MAX_CHANNELS];
- conv_func_deinterleave *convert = use_generic ?
- ac->conv_deinterleave_generic :
- ac->conv_deinterleave;
-
- for (p = 0; p < ac->channels; p++)
- data[map->input_map[p]] = out->data[p];
-
- convert(data, in->data[0], len, ac->channels);
- }
- }
- if (map->do_copy || map->do_zero) {
- for (p = 0; p < ac->planes; p++) {
- if (map->channel_copy[p])
- memcpy(out->data[p], out->data[map->channel_copy[p]],
- len * out->stride);
- else if (map->channel_zero[p])
- av_samples_set_silence(&out->data[p], 0, len, 1, ac->out_fmt);
- }
- }
- } else {
- switch (ac->func_type) {
- case CONV_FUNC_TYPE_FLAT: {
- if (!in->is_planar)
- len *= in->channels;
- if (use_generic) {
- for (p = 0; p < ac->planes; p++)
- ac->conv_flat_generic(out->data[p], in->data[p], len);
- } else {
- for (p = 0; p < ac->planes; p++)
- ac->conv_flat(out->data[p], in->data[p], len);
- }
- break;
- }
- case CONV_FUNC_TYPE_INTERLEAVE:
- if (use_generic)
- ac->conv_interleave_generic(out->data[0], in->data, len,
- ac->channels);
- else
- ac->conv_interleave(out->data[0], in->data, len, ac->channels);
- break;
- case CONV_FUNC_TYPE_DEINTERLEAVE:
- if (use_generic)
- ac->conv_deinterleave_generic(out->data, in->data[0], len,
- ac->channels);
- else
- ac->conv_deinterleave(out->data, in->data[0], len,
- ac->channels);
- break;
- }
- }
-
- out->nb_samples = in->nb_samples;
- return 0;
-}
diff --git a/src/thirdparty/ffmpeg/libavresample/audio_convert.h b/src/thirdparty/ffmpeg/libavresample/audio_convert.h
deleted file mode 100644
index 6a3089d4f..000000000
--- a/src/thirdparty/ffmpeg/libavresample/audio_convert.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVRESAMPLE_AUDIO_CONVERT_H
-#define AVRESAMPLE_AUDIO_CONVERT_H
-
-#include "libavutil/samplefmt.h"
-#include "avresample.h"
-#include "internal.h"
-#include "audio_data.h"
-
-/**
- * Set conversion function if the parameters match.
- *
- * This compares the parameters of the conversion function to the parameters
- * in the AudioConvert context. If the parameters do not match, no changes are
- * made to the active functions. If the parameters do match and the alignment
- * is not constrained, the function is set as the generic conversion function.
- * If the parameters match and the alignment is constrained, the function is
- * set as the optimized conversion function.
- *
- * @param ac AudioConvert context
- * @param out_fmt output sample format
- * @param in_fmt input sample format
- * @param channels number of channels, or 0 for any number of channels
- * @param ptr_align buffer pointer alignment, in bytes
- * @param samples_align buffer size alignment, in samples
- * @param descr function type description (e.g. "C" or "SSE")
- * @param conv conversion function pointer
- */
-void ff_audio_convert_set_func(AudioConvert *ac, enum AVSampleFormat out_fmt,
- enum AVSampleFormat in_fmt, int channels,
- int ptr_align, int samples_align,
- const char *descr, void *conv);
-
-/**
- * Allocate and initialize AudioConvert context for sample format conversion.
- *
- * @param avr AVAudioResampleContext
- * @param out_fmt output sample format
- * @param in_fmt input sample format
- * @param channels number of channels
- * @param sample_rate sample rate (used for dithering)
- * @param apply_map apply channel map during conversion
- * @return newly-allocated AudioConvert context
- */
-AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr,
- enum AVSampleFormat out_fmt,
- enum AVSampleFormat in_fmt,
- int channels, int sample_rate,
- int apply_map);
-
-/**
- * Free AudioConvert.
- *
- * The AudioConvert must have been previously allocated with ff_audio_convert_alloc().
- *
- * @param ac AudioConvert struct
- */
-void ff_audio_convert_free(AudioConvert **ac);
-
-/**
- * Convert audio data from one sample format to another.
- *
- * For each call, the alignment of the input and output AudioData buffers are
- * examined to determine whether to use the generic or optimized conversion
- * function (when available).
- *
- * The number of samples to convert is determined by in->nb_samples. The output
- * buffer must be large enough to handle this many samples. out->nb_samples is
- * set by this function before a successful return.
- *
- * @param ac AudioConvert context
- * @param out output audio data
- * @param in input audio data
- * @return 0 on success, negative AVERROR code on failure
- */
-int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in);
-
-/* arch-specific initialization functions */
-
-void ff_audio_convert_init_arm(AudioConvert *ac);
-void ff_audio_convert_init_x86(AudioConvert *ac);
-
-#endif /* AVRESAMPLE_AUDIO_CONVERT_H */
diff --git a/src/thirdparty/ffmpeg/libavresample/audio_data.c b/src/thirdparty/ffmpeg/libavresample/audio_data.c
deleted file mode 100644
index c52f518e9..000000000
--- a/src/thirdparty/ffmpeg/libavresample/audio_data.c
+++ /dev/null
@@ -1,372 +0,0 @@
-/*
- * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdint.h>
-#include <string.h>
-
-#include "libavutil/mem.h"
-#include "audio_data.h"
-
-static const AVClass audio_data_class = {
- .class_name = "AudioData",
- .item_name = av_default_item_name,
- .version = LIBAVUTIL_VERSION_INT,
-};
-
-/*
- * Calculate alignment for data pointers.
- */
-static void calc_ptr_alignment(AudioData *a)
-{
- int p;
- int min_align = 128;
-
- for (p = 0; p < a->planes; p++) {
- int cur_align = 128;
- while ((intptr_t)a->data[p] % cur_align)
- cur_align >>= 1;
- if (cur_align < min_align)
- min_align = cur_align;
- }
- a->ptr_align = min_align;
-}
-
-int ff_audio_data_set_channels(AudioData *a, int channels)
-{
- if (channels < 1 || channels > AVRESAMPLE_MAX_CHANNELS ||
- channels > a->allocated_channels)
- return AVERROR(EINVAL);
-
- a->channels = channels;
- a->planes = a->is_planar ? channels : 1;
-
- calc_ptr_alignment(a);
-
- return 0;
-}
-
-int ff_audio_data_init(AudioData *a, uint8_t **src, int plane_size, int channels,
- int nb_samples, enum AVSampleFormat sample_fmt,
- int read_only, const char *name)
-{
- int p;
-
- memset(a, 0, sizeof(*a));
- a->class = &audio_data_class;
-
- if (channels < 1 || channels > AVRESAMPLE_MAX_CHANNELS) {
- av_log(a, AV_LOG_ERROR, "invalid channel count: %d\n", channels);
- return AVERROR(EINVAL);
- }
-
- a->sample_size = av_get_bytes_per_sample(sample_fmt);
- if (!a->sample_size) {
- av_log(a, AV_LOG_ERROR, "invalid sample format\n");
- return AVERROR(EINVAL);
- }
- a->is_planar = av_sample_fmt_is_planar(sample_fmt);
- a->planes = a->is_planar ? channels : 1;
- a->stride = a->sample_size * (a->is_planar ? 1 : channels);
-
- for (p = 0; p < (a->is_planar ? channels : 1); p++) {
- if (!src[p]) {
- av_log(a, AV_LOG_ERROR, "invalid NULL pointer for src[%d]\n", p);
- return AVERROR(EINVAL);
- }
- a->data[p] = src[p];
- }
- a->allocated_samples = nb_samples * !read_only;
- a->nb_samples = nb_samples;
- a->sample_fmt = sample_fmt;
- a->channels = channels;
- a->allocated_channels = channels;
- a->read_only = read_only;
- a->allow_realloc = 0;
- a->name = name ? name : "{no name}";
-
- calc_ptr_alignment(a);
- a->samples_align = plane_size / a->stride;
-
- return 0;
-}
-
-AudioData *ff_audio_data_alloc(int channels, int nb_samples,
- enum AVSampleFormat sample_fmt, const char *name)
-{
- AudioData *a;
- int ret;
-
- if (channels < 1 || channels > AVRESAMPLE_MAX_CHANNELS)
- return NULL;
-
- a = av_mallocz(sizeof(*a));
- if (!a)
- return NULL;
-
- a->sample_size = av_get_bytes_per_sample(sample_fmt);
- if (!a->sample_size) {
- av_free(a);
- return NULL;
- }
- a->is_planar = av_sample_fmt_is_planar(sample_fmt);
- a->planes = a->is_planar ? channels : 1;
- a->stride = a->sample_size * (a->is_planar ? 1 : channels);
-
- a->class = &audio_data_class;
- a->sample_fmt = sample_fmt;
- a->channels = channels;
- a->allocated_channels = channels;
- a->read_only = 0;
- a->allow_realloc = 1;
- a->name = name ? name : "{no name}";
-
- if (nb_samples > 0) {
- ret = ff_audio_data_realloc(a, nb_samples);
- if (ret < 0) {
- av_free(a);
- return NULL;
- }
- return a;
- } else {
- calc_ptr_alignment(a);
- return a;
- }
-}
-
-int ff_audio_data_realloc(AudioData *a, int nb_samples)
-{
- int ret, new_buf_size, plane_size, p;
-
- /* check if buffer is already large enough */
- if (a->allocated_samples >= nb_samples)
- return 0;
-
- /* validate that the output is not read-only and realloc is allowed */
- if (a->read_only || !a->allow_realloc)
- return AVERROR(EINVAL);
-
- new_buf_size = av_samples_get_buffer_size(&plane_size,
- a->allocated_channels, nb_samples,
- a->sample_fmt, 0);
- if (new_buf_size < 0)
- return new_buf_size;
-
- /* if there is already data in the buffer and the sample format is planar,
- allocate a new buffer and copy the data, otherwise just realloc the
- internal buffer and set new data pointers */
- if (a->nb_samples > 0 && a->is_planar) {
- uint8_t *new_data[AVRESAMPLE_MAX_CHANNELS] = { NULL };
-
- ret = av_samples_alloc(new_data, &plane_size, a->allocated_channels,
- nb_samples, a->sample_fmt, 0);
- if (ret < 0)
- return ret;
-
- for (p = 0; p < a->planes; p++)
- memcpy(new_data[p], a->data[p], a->nb_samples * a->stride);
-
- av_freep(&a->buffer);
- memcpy(a->data, new_data, sizeof(new_data));
- a->buffer = a->data[0];
- } else {
- av_freep(&a->buffer);
- a->buffer = av_malloc(new_buf_size);
- if (!a->buffer)
- return AVERROR(ENOMEM);
- ret = av_samples_fill_arrays(a->data, &plane_size, a->buffer,
- a->allocated_channels, nb_samples,
- a->sample_fmt, 0);
- if (ret < 0)
- return ret;
- }
- a->buffer_size = new_buf_size;
- a->allocated_samples = nb_samples;
-
- calc_ptr_alignment(a);
- a->samples_align = plane_size / a->stride;
-
- return 0;
-}
-
-void ff_audio_data_free(AudioData **a)
-{
- if (!*a)
- return;
- av_free((*a)->buffer);
- av_freep(a);
-}
-
-int ff_audio_data_copy(AudioData *dst, AudioData *src, ChannelMapInfo *map)
-{
- int ret, p;
-
- /* validate input/output compatibility */
- if (dst->sample_fmt != src->sample_fmt || dst->channels < src->channels)
- return AVERROR(EINVAL);
-
- if (map && !src->is_planar) {
- av_log(src, AV_LOG_ERROR, "cannot remap packed format during copy\n");
- return AVERROR(EINVAL);
- }
-
- /* if the input is empty, just empty the output */
- if (!src->nb_samples) {
- dst->nb_samples = 0;
- return 0;
- }
-
- /* reallocate output if necessary */
- ret = ff_audio_data_realloc(dst, src->nb_samples);
- if (ret < 0)
- return ret;
-
- /* copy data */
- if (map) {
- if (map->do_remap) {
- for (p = 0; p < src->planes; p++) {
- if (map->channel_map[p] >= 0)
- memcpy(dst->data[p], src->data[map->channel_map[p]],
- src->nb_samples * src->stride);
- }
- }
- if (map->do_copy || map->do_zero) {
- for (p = 0; p < src->planes; p++) {
- if (map->channel_copy[p])
- memcpy(dst->data[p], dst->data[map->channel_copy[p]],
- src->nb_samples * src->stride);
- else if (map->channel_zero[p])
- av_samples_set_silence(&dst->data[p], 0, src->nb_samples,
- 1, dst->sample_fmt);
- }
- }
- } else {
- for (p = 0; p < src->planes; p++)
- memcpy(dst->data[p], src->data[p], src->nb_samples * src->stride);
- }
-
- dst->nb_samples = src->nb_samples;
-
- return 0;
-}
-
-int ff_audio_data_combine(AudioData *dst, int dst_offset, AudioData *src,
- int src_offset, int nb_samples)
-{
- int ret, p, dst_offset2, dst_move_size;
-
- /* validate input/output compatibility */
- if (dst->sample_fmt != src->sample_fmt || dst->channels != src->channels) {
- av_log(src, AV_LOG_ERROR, "sample format mismatch\n");
- return AVERROR(EINVAL);
- }
-
- /* validate offsets are within the buffer bounds */
- if (dst_offset < 0 || dst_offset > dst->nb_samples ||
- src_offset < 0 || src_offset > src->nb_samples) {
- av_log(src, AV_LOG_ERROR, "offset out-of-bounds: src=%d dst=%d\n",
- src_offset, dst_offset);
- return AVERROR(EINVAL);
- }
-
- /* check offsets and sizes to see if we can just do nothing and return */
- if (nb_samples > src->nb_samples - src_offset)
- nb_samples = src->nb_samples - src_offset;
- if (nb_samples <= 0)
- return 0;
-
- /* validate that the output is not read-only */
- if (dst->read_only) {
- av_log(dst, AV_LOG_ERROR, "dst is read-only\n");
- return AVERROR(EINVAL);
- }
-
- /* reallocate output if necessary */
- ret = ff_audio_data_realloc(dst, dst->nb_samples + nb_samples);
- if (ret < 0) {
- av_log(dst, AV_LOG_ERROR, "error reallocating dst\n");
- return ret;
- }
-
- dst_offset2 = dst_offset + nb_samples;
- dst_move_size = dst->nb_samples - dst_offset;
-
- for (p = 0; p < src->planes; p++) {
- if (dst_move_size > 0) {
- memmove(dst->data[p] + dst_offset2 * dst->stride,
- dst->data[p] + dst_offset * dst->stride,
- dst_move_size * dst->stride);
- }
- memcpy(dst->data[p] + dst_offset * dst->stride,
- src->data[p] + src_offset * src->stride,
- nb_samples * src->stride);
- }
- dst->nb_samples += nb_samples;
-
- return 0;
-}
-
-void ff_audio_data_drain(AudioData *a, int nb_samples)
-{
- if (a->nb_samples <= nb_samples) {
- /* drain the whole buffer */
- a->nb_samples = 0;
- } else {
- int p;
- int move_offset = a->stride * nb_samples;
- int move_size = a->stride * (a->nb_samples - nb_samples);
-
- for (p = 0; p < a->planes; p++)
- memmove(a->data[p], a->data[p] + move_offset, move_size);
-
- a->nb_samples -= nb_samples;
- }
-}
-
-int ff_audio_data_add_to_fifo(AVAudioFifo *af, AudioData *a, int offset,
- int nb_samples)
-{
- uint8_t *offset_data[AVRESAMPLE_MAX_CHANNELS];
- int offset_size, p;
-
- if (offset >= a->nb_samples)
- return 0;
- offset_size = offset * a->stride;
- for (p = 0; p < a->planes; p++)
- offset_data[p] = a->data[p] + offset_size;
-
- return av_audio_fifo_write(af, (void **)offset_data, nb_samples);
-}
-
-int ff_audio_data_read_from_fifo(AVAudioFifo *af, AudioData *a, int nb_samples)
-{
- int ret;
-
- if (a->read_only)
- return AVERROR(EINVAL);
-
- ret = ff_audio_data_realloc(a, nb_samples);
- if (ret < 0)
- return ret;
-
- ret = av_audio_fifo_read(af, (void **)a->data, nb_samples);
- if (ret >= 0)
- a->nb_samples = ret;
- return ret;
-}
diff --git a/src/thirdparty/ffmpeg/libavresample/audio_data.h b/src/thirdparty/ffmpeg/libavresample/audio_data.h
deleted file mode 100644
index 97236bb5d..000000000
--- a/src/thirdparty/ffmpeg/libavresample/audio_data.h
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVRESAMPLE_AUDIO_DATA_H
-#define AVRESAMPLE_AUDIO_DATA_H
-
-#include <stdint.h>
-
-#include "libavutil/audio_fifo.h"
-#include "libavutil/log.h"
-#include "libavutil/samplefmt.h"
-#include "avresample.h"
-#include "internal.h"
-
-/**
- * Audio buffer used for intermediate storage between conversion phases.
- */
-struct AudioData {
- const AVClass *class; /**< AVClass for logging */
- uint8_t *data[AVRESAMPLE_MAX_CHANNELS]; /**< data plane pointers */
- uint8_t *buffer; /**< data buffer */
- unsigned int buffer_size; /**< allocated buffer size */
- int allocated_samples; /**< number of samples the buffer can hold */
- int nb_samples; /**< current number of samples */
- enum AVSampleFormat sample_fmt; /**< sample format */
- int channels; /**< channel count */
- int allocated_channels; /**< allocated channel count */
- int is_planar; /**< sample format is planar */
- int planes; /**< number of data planes */
- int sample_size; /**< bytes per sample */
- int stride; /**< sample byte offset within a plane */
- int read_only; /**< data is read-only */
- int allow_realloc; /**< realloc is allowed */
- int ptr_align; /**< minimum data pointer alignment */
- int samples_align; /**< allocated samples alignment */
- const char *name; /**< name for debug logging */
-};
-
-int ff_audio_data_set_channels(AudioData *a, int channels);
-
-/**
- * Initialize AudioData using a given source.
- *
- * This does not allocate an internal buffer. It only sets the data pointers
- * and audio parameters.
- *
- * @param a AudioData struct
- * @param src source data pointers
- * @param plane_size plane size, in bytes.
- * This can be 0 if unknown, but that will lead to
- * optimized functions not being used in many cases,
- * which could slow down some conversions.
- * @param channels channel count
- * @param nb_samples number of samples in the source data
- * @param sample_fmt sample format
- * @param read_only indicates if buffer is read only or read/write
- * @param name name for debug logging (can be NULL)
- * @return 0 on success, negative AVERROR value on error
- */
-int ff_audio_data_init(AudioData *a, uint8_t **src, int plane_size, int channels,
- int nb_samples, enum AVSampleFormat sample_fmt,
- int read_only, const char *name);
-
-/**
- * Allocate AudioData.
- *
- * This allocates an internal buffer and sets audio parameters.
- *
- * @param channels channel count
- * @param nb_samples number of samples to allocate space for
- * @param sample_fmt sample format
- * @param name name for debug logging (can be NULL)
- * @return newly allocated AudioData struct, or NULL on error
- */
-AudioData *ff_audio_data_alloc(int channels, int nb_samples,
- enum AVSampleFormat sample_fmt,
- const char *name);
-
-/**
- * Reallocate AudioData.
- *
- * The AudioData must have been previously allocated with ff_audio_data_alloc().
- *
- * @param a AudioData struct
- * @param nb_samples number of samples to allocate space for
- * @return 0 on success, negative AVERROR value on error
- */
-int ff_audio_data_realloc(AudioData *a, int nb_samples);
-
-/**
- * Free AudioData.
- *
- * The AudioData must have been previously allocated with ff_audio_data_alloc().
- *
- * @param a AudioData struct
- */
-void ff_audio_data_free(AudioData **a);
-
-/**
- * Copy data from one AudioData to another.
- *
- * @param out output AudioData
- * @param in input AudioData
- * @param map channel map, NULL if not remapping
- * @return 0 on success, negative AVERROR value on error
- */
-int ff_audio_data_copy(AudioData *out, AudioData *in, ChannelMapInfo *map);
-
-/**
- * Append data from one AudioData to the end of another.
- *
- * @param dst destination AudioData
- * @param dst_offset offset, in samples, to start writing, relative to the
- * start of dst
- * @param src source AudioData
- * @param src_offset offset, in samples, to start copying, relative to the
- * start of the src
- * @param nb_samples number of samples to copy
- * @return 0 on success, negative AVERROR value on error
- */
-int ff_audio_data_combine(AudioData *dst, int dst_offset, AudioData *src,
- int src_offset, int nb_samples);
-
-/**
- * Drain samples from the start of the AudioData.
- *
- * Remaining samples are shifted to the start of the AudioData.
- *
- * @param a AudioData struct
- * @param nb_samples number of samples to drain
- */
-void ff_audio_data_drain(AudioData *a, int nb_samples);
-
-/**
- * Add samples in AudioData to an AVAudioFifo.
- *
- * @param af Audio FIFO Buffer
- * @param a AudioData struct
- * @param offset number of samples to skip from the start of the data
- * @param nb_samples number of samples to add to the FIFO
- * @return number of samples actually added to the FIFO, or
- * negative AVERROR code on error
- */
-int ff_audio_data_add_to_fifo(AVAudioFifo *af, AudioData *a, int offset,
- int nb_samples);
-
-/**
- * Read samples from an AVAudioFifo to AudioData.
- *
- * @param af Audio FIFO Buffer
- * @param a AudioData struct
- * @param nb_samples number of samples to read from the FIFO
- * @return number of samples actually read from the FIFO, or
- * negative AVERROR code on error
- */
-int ff_audio_data_read_from_fifo(AVAudioFifo *af, AudioData *a, int nb_samples);
-
-#endif /* AVRESAMPLE_AUDIO_DATA_H */
diff --git a/src/thirdparty/ffmpeg/libavresample/audio_mix.c b/src/thirdparty/ffmpeg/libavresample/audio_mix.c
deleted file mode 100644
index b69bfbcf3..000000000
--- a/src/thirdparty/ffmpeg/libavresample/audio_mix.c
+++ /dev/null
@@ -1,739 +0,0 @@
-/*
- * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdint.h>
-
-#include "libavutil/common.h"
-#include "libavutil/libm.h"
-#include "libavutil/samplefmt.h"
-#include "avresample.h"
-#include "internal.h"
-#include "audio_data.h"
-#include "audio_mix.h"
-
-static const char *coeff_type_names[] = { "q8", "q15", "flt" };
-
-struct AudioMix {
- AVAudioResampleContext *avr;
- enum AVSampleFormat fmt;
- enum AVMixCoeffType coeff_type;
- uint64_t in_layout;
- uint64_t out_layout;
- int in_channels;
- int out_channels;
-
- int ptr_align;
- int samples_align;
- int has_optimized_func;
- const char *func_descr;
- const char *func_descr_generic;
- mix_func *mix;
- mix_func *mix_generic;
-
- int in_matrix_channels;
- int out_matrix_channels;
- int output_zero[AVRESAMPLE_MAX_CHANNELS];
- int input_skip[AVRESAMPLE_MAX_CHANNELS];
- int output_skip[AVRESAMPLE_MAX_CHANNELS];
- int16_t *matrix_q8[AVRESAMPLE_MAX_CHANNELS];
- int32_t *matrix_q15[AVRESAMPLE_MAX_CHANNELS];
- float *matrix_flt[AVRESAMPLE_MAX_CHANNELS];
- void **matrix;
-};
-
-void ff_audio_mix_set_func(AudioMix *am, enum AVSampleFormat fmt,
- enum AVMixCoeffType coeff_type, int in_channels,
- int out_channels, int ptr_align, int samples_align,
- const char *descr, void *mix_func)
-{
- if (fmt == am->fmt && coeff_type == am->coeff_type &&
- ( in_channels == am->in_matrix_channels || in_channels == 0) &&
- (out_channels == am->out_matrix_channels || out_channels == 0)) {
- char chan_str[16];
- am->mix = mix_func;
- am->func_descr = descr;
- am->ptr_align = ptr_align;
- am->samples_align = samples_align;
- if (ptr_align == 1 && samples_align == 1) {
- am->mix_generic = mix_func;
- am->func_descr_generic = descr;
- } else {
- am->has_optimized_func = 1;
- }
- if (in_channels) {
- if (out_channels)
- snprintf(chan_str, sizeof(chan_str), "[%d to %d] ",
- in_channels, out_channels);
- else
- snprintf(chan_str, sizeof(chan_str), "[%d to any] ",
- in_channels);
- } else if (out_channels) {
- snprintf(chan_str, sizeof(chan_str), "[any to %d] ",
- out_channels);
- } else {
- snprintf(chan_str, sizeof(chan_str), "[any to any] ");
- }
- av_log(am->avr, AV_LOG_DEBUG, "audio_mix: found function: [fmt=%s] "
- "[c=%s] %s(%s)\n", av_get_sample_fmt_name(fmt),
- coeff_type_names[coeff_type], chan_str, descr);
- }
-}
-
-#define MIX_FUNC_NAME(fmt, cfmt) mix_any_ ## fmt ##_## cfmt ##_c
-
-#define MIX_FUNC_GENERIC(fmt, cfmt, stype, ctype, sumtype, expr) \
-static void MIX_FUNC_NAME(fmt, cfmt)(stype **samples, ctype **matrix, \
- int len, int out_ch, int in_ch) \
-{ \
- int i, in, out; \
- stype temp[AVRESAMPLE_MAX_CHANNELS]; \
- for (i = 0; i < len; i++) { \
- for (out = 0; out < out_ch; out++) { \
- sumtype sum = 0; \
- for (in = 0; in < in_ch; in++) \
- sum += samples[in][i] * matrix[out][in]; \
- temp[out] = expr; \
- } \
- for (out = 0; out < out_ch; out++) \
- samples[out][i] = temp[out]; \
- } \
-}
-
-MIX_FUNC_GENERIC(FLTP, FLT, float, float, float, sum)
-MIX_FUNC_GENERIC(S16P, FLT, int16_t, float, float, av_clip_int16(lrintf(sum)))
-MIX_FUNC_GENERIC(S16P, Q15, int16_t, int32_t, int64_t, av_clip_int16(sum >> 15))
-MIX_FUNC_GENERIC(S16P, Q8, int16_t, int16_t, int32_t, av_clip_int16(sum >> 8))
-
-/* TODO: templatize the channel-specific C functions */
-
-static void mix_2_to_1_fltp_flt_c(float **samples, float **matrix, int len,
- int out_ch, int in_ch)
-{
- float *src0 = samples[0];
- float *src1 = samples[1];
- float *dst = src0;
- float m0 = matrix[0][0];
- float m1 = matrix[0][1];
-
- while (len > 4) {
- *dst++ = *src0++ * m0 + *src1++ * m1;
- *dst++ = *src0++ * m0 + *src1++ * m1;
- *dst++ = *src0++ * m0 + *src1++ * m1;
- *dst++ = *src0++ * m0 + *src1++ * m1;
- len -= 4;
- }
- while (len > 0) {
- *dst++ = *src0++ * m0 + *src1++ * m1;
- len--;
- }
-}
-
-static void mix_2_to_1_s16p_flt_c(int16_t **samples, float **matrix, int len,
- int out_ch, int in_ch)
-{
- int16_t *src0 = samples[0];
- int16_t *src1 = samples[1];
- int16_t *dst = src0;
- float m0 = matrix[0][0];
- float m1 = matrix[0][1];
-
- while (len > 4) {
- *dst++ = av_clip_int16(lrintf(*src0++ * m0 + *src1++ * m1));
- *dst++ = av_clip_int16(lrintf(*src0++ * m0 + *src1++ * m1));
- *dst++ = av_clip_int16(lrintf(*src0++ * m0 + *src1++ * m1));
- *dst++ = av_clip_int16(lrintf(*src0++ * m0 + *src1++ * m1));
- len -= 4;
- }
- while (len > 0) {
- *dst++ = av_clip_int16(lrintf(*src0++ * m0 + *src1++ * m1));
- len--;
- }
-}
-
-static void mix_2_to_1_s16p_q8_c(int16_t **samples, int16_t **matrix, int len,
- int out_ch, int in_ch)
-{
- int16_t *src0 = samples[0];
- int16_t *src1 = samples[1];
- int16_t *dst = src0;
- int16_t m0 = matrix[0][0];
- int16_t m1 = matrix[0][1];
-
- while (len > 4) {
- *dst++ = (*src0++ * m0 + *src1++ * m1) >> 8;
- *dst++ = (*src0++ * m0 + *src1++ * m1) >> 8;
- *dst++ = (*src0++ * m0 + *src1++ * m1) >> 8;
- *dst++ = (*src0++ * m0 + *src1++ * m1) >> 8;
- len -= 4;
- }
- while (len > 0) {
- *dst++ = (*src0++ * m0 + *src1++ * m1) >> 8;
- len--;
- }
-}
-
-static void mix_1_to_2_fltp_flt_c(float **samples, float **matrix, int len,
- int out_ch, int in_ch)
-{
- float v;
- float *dst0 = samples[0];
- float *dst1 = samples[1];
- float *src = dst0;
- float m0 = matrix[0][0];
- float m1 = matrix[1][0];
-
- while (len > 4) {
- v = *src++;
- *dst0++ = v * m1;
- *dst1++ = v * m0;
- v = *src++;
- *dst0++ = v * m1;
- *dst1++ = v * m0;
- v = *src++;
- *dst0++ = v * m1;
- *dst1++ = v * m0;
- v = *src++;
- *dst0++ = v * m1;
- *dst1++ = v * m0;
- len -= 4;
- }
- while (len > 0) {
- v = *src++;
- *dst0++ = v * m1;
- *dst1++ = v * m0;
- len--;
- }
-}
-
-static void mix_6_to_2_fltp_flt_c(float **samples, float **matrix, int len,
- int out_ch, int in_ch)
-{
- float v0, v1;
- float *src0 = samples[0];
- float *src1 = samples[1];
- float *src2 = samples[2];
- float *src3 = samples[3];
- float *src4 = samples[4];
- float *src5 = samples[5];
- float *dst0 = src0;
- float *dst1 = src1;
- float *m0 = matrix[0];
- float *m1 = matrix[1];
-
- while (len > 0) {
- v0 = *src0++;
- v1 = *src1++;
- *dst0++ = v0 * m0[0] +
- v1 * m0[1] +
- *src2 * m0[2] +
- *src3 * m0[3] +
- *src4 * m0[4] +
- *src5 * m0[5];
- *dst1++ = v0 * m1[0] +
- v1 * m1[1] +
- *src2++ * m1[2] +
- *src3++ * m1[3] +
- *src4++ * m1[4] +
- *src5++ * m1[5];
- len--;
- }
-}
-
-static void mix_2_to_6_fltp_flt_c(float **samples, float **matrix, int len,
- int out_ch, int in_ch)
-{
- float v0, v1;
- float *dst0 = samples[0];
- float *dst1 = samples[1];
- float *dst2 = samples[2];
- float *dst3 = samples[3];
- float *dst4 = samples[4];
- float *dst5 = samples[5];
- float *src0 = dst0;
- float *src1 = dst1;
-
- while (len > 0) {
- v0 = *src0++;
- v1 = *src1++;
- *dst0++ = v0 * matrix[0][0] + v1 * matrix[0][1];
- *dst1++ = v0 * matrix[1][0] + v1 * matrix[1][1];
- *dst2++ = v0 * matrix[2][0] + v1 * matrix[2][1];
- *dst3++ = v0 * matrix[3][0] + v1 * matrix[3][1];
- *dst4++ = v0 * matrix[4][0] + v1 * matrix[4][1];
- *dst5++ = v0 * matrix[5][0] + v1 * matrix[5][1];
- len--;
- }
-}
-
-static int mix_function_init(AudioMix *am)
-{
- am->func_descr = am->func_descr_generic = "n/a";
- am->mix = am->mix_generic = NULL;
-
- /* no need to set a mix function when we're skipping mixing */
- if (!am->in_matrix_channels || !am->out_matrix_channels)
- return 0;
-
- /* any-to-any C versions */
-
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,
- 0, 0, 1, 1, "C", MIX_FUNC_NAME(FLTP, FLT));
-
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,
- 0, 0, 1, 1, "C", MIX_FUNC_NAME(S16P, FLT));
-
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_Q15,
- 0, 0, 1, 1, "C", MIX_FUNC_NAME(S16P, Q15));
-
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_Q8,
- 0, 0, 1, 1, "C", MIX_FUNC_NAME(S16P, Q8));
-
- /* channel-specific C versions */
-
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,
- 2, 1, 1, 1, "C", mix_2_to_1_fltp_flt_c);
-
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,
- 2, 1, 1, 1, "C", mix_2_to_1_s16p_flt_c);
-
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_Q8,
- 2, 1, 1, 1, "C", mix_2_to_1_s16p_q8_c);
-
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,
- 1, 2, 1, 1, "C", mix_1_to_2_fltp_flt_c);
-
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,
- 6, 2, 1, 1, "C", mix_6_to_2_fltp_flt_c);
-
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,
- 2, 6, 1, 1, "C", mix_2_to_6_fltp_flt_c);
-
- if (ARCH_X86)
- ff_audio_mix_init_x86(am);
-
- if (!am->mix) {
- av_log(am->avr, AV_LOG_ERROR, "audio_mix: NO FUNCTION FOUND: [fmt=%s] "
- "[c=%s] [%d to %d]\n", av_get_sample_fmt_name(am->fmt),
- coeff_type_names[am->coeff_type], am->in_channels,
- am->out_channels);
- return AVERROR_PATCHWELCOME;
- }
- return 0;
-}
-
-AudioMix *ff_audio_mix_alloc(AVAudioResampleContext *avr)
-{
- AudioMix *am;
- int ret;
-
- am = av_mallocz(sizeof(*am));
- if (!am)
- return NULL;
- am->avr = avr;
-
- if (avr->internal_sample_fmt != AV_SAMPLE_FMT_S16P &&
- avr->internal_sample_fmt != AV_SAMPLE_FMT_FLTP) {
- av_log(avr, AV_LOG_ERROR, "Unsupported internal format for "
- "mixing: %s\n",
- av_get_sample_fmt_name(avr->internal_sample_fmt));
- goto error;
- }
-
- am->fmt = avr->internal_sample_fmt;
- am->coeff_type = avr->mix_coeff_type;
- am->in_layout = avr->in_channel_layout;
- am->out_layout = avr->out_channel_layout;
- am->in_channels = avr->in_channels;
- am->out_channels = avr->out_channels;
-
- /* build matrix if the user did not already set one */
- if (avr->mix_matrix) {
- ret = ff_audio_mix_set_matrix(am, avr->mix_matrix, avr->in_channels);
- if (ret < 0)
- goto error;
- av_freep(&avr->mix_matrix);
- } else {
- double *matrix_dbl = av_mallocz(avr->out_channels * avr->in_channels *
- sizeof(*matrix_dbl));
- if (!matrix_dbl)
- goto error;
-
- ret = avresample_build_matrix(avr->in_channel_layout,
- avr->out_channel_layout,
- avr->center_mix_level,
- avr->surround_mix_level,
- avr->lfe_mix_level,
- avr->normalize_mix_level,
- matrix_dbl,
- avr->in_channels,
- avr->matrix_encoding);
- if (ret < 0) {
- av_free(matrix_dbl);
- goto error;
- }
-
- ret = ff_audio_mix_set_matrix(am, matrix_dbl, avr->in_channels);
- if (ret < 0) {
- av_log(avr, AV_LOG_ERROR, "error setting mix matrix\n");
- av_free(matrix_dbl);
- goto error;
- }
-
- av_free(matrix_dbl);
- }
-
- return am;
-
-error:
- av_free(am);
- return NULL;
-}
-
-void ff_audio_mix_free(AudioMix **am_p)
-{
- AudioMix *am;
-
- if (!*am_p)
- return;
- am = *am_p;
-
- if (am->matrix) {
- av_free(am->matrix[0]);
- am->matrix = NULL;
- }
- memset(am->matrix_q8, 0, sizeof(am->matrix_q8 ));
- memset(am->matrix_q15, 0, sizeof(am->matrix_q15));
- memset(am->matrix_flt, 0, sizeof(am->matrix_flt));
-
- av_freep(am_p);
-}
-
-int ff_audio_mix(AudioMix *am, AudioData *src)
-{
- int use_generic = 1;
- int len = src->nb_samples;
- int i, j;
-
- /* determine whether to use the optimized function based on pointer and
- samples alignment in both the input and output */
- if (am->has_optimized_func) {
- int aligned_len = FFALIGN(len, am->samples_align);
- if (!(src->ptr_align % am->ptr_align) &&
- src->samples_align >= aligned_len) {
- len = aligned_len;
- use_generic = 0;
- }
- }
- av_dlog(am->avr, "audio_mix: %d samples - %d to %d channels (%s)\n",
- src->nb_samples, am->in_channels, am->out_channels,
- use_generic ? am->func_descr_generic : am->func_descr);
-
- if (am->in_matrix_channels && am->out_matrix_channels) {
- uint8_t **data;
- uint8_t *data0[AVRESAMPLE_MAX_CHANNELS];
-
- if (am->out_matrix_channels < am->out_channels ||
- am->in_matrix_channels < am->in_channels) {
- for (i = 0, j = 0; i < FFMAX(am->in_channels, am->out_channels); i++) {
- if (am->input_skip[i] || am->output_skip[i] || am->output_zero[i])
- continue;
- data0[j++] = src->data[i];
- }
- data = data0;
- } else {
- data = src->data;
- }
-
- if (use_generic)
- am->mix_generic(data, am->matrix, len, am->out_matrix_channels,
- am->in_matrix_channels);
- else
- am->mix(data, am->matrix, len, am->out_matrix_channels,
- am->in_matrix_channels);
- }
-
- if (am->out_matrix_channels < am->out_channels) {
- for (i = 0; i < am->out_channels; i++)
- if (am->output_zero[i])
- av_samples_set_silence(&src->data[i], 0, len, 1, am->fmt);
- }
-
- ff_audio_data_set_channels(src, am->out_channels);
-
- return 0;
-}
-
-int ff_audio_mix_get_matrix(AudioMix *am, double *matrix, int stride)
-{
- int i, o, i0, o0;
-
- if ( am->in_channels <= 0 || am->in_channels > AVRESAMPLE_MAX_CHANNELS ||
- am->out_channels <= 0 || am->out_channels > AVRESAMPLE_MAX_CHANNELS) {
- av_log(am->avr, AV_LOG_ERROR, "Invalid channel counts\n");
- return AVERROR(EINVAL);
- }
-
-#define GET_MATRIX_CONVERT(suffix, scale) \
- if (!am->matrix_ ## suffix[0]) { \
- av_log(am->avr, AV_LOG_ERROR, "matrix is not set\n"); \
- return AVERROR(EINVAL); \
- } \
- for (o = 0, o0 = 0; o < am->out_channels; o++) { \
- for (i = 0, i0 = 0; i < am->in_channels; i++) { \
- if (am->input_skip[i] || am->output_zero[o]) \
- matrix[o * stride + i] = 0.0; \
- else \
- matrix[o * stride + i] = am->matrix_ ## suffix[o0][i0] * \
- (scale); \
- if (!am->input_skip[i]) \
- i0++; \
- } \
- if (!am->output_zero[o]) \
- o0++; \
- }
-
- switch (am->coeff_type) {
- case AV_MIX_COEFF_TYPE_Q8:
- GET_MATRIX_CONVERT(q8, 1.0 / 256.0);
- break;
- case AV_MIX_COEFF_TYPE_Q15:
- GET_MATRIX_CONVERT(q15, 1.0 / 32768.0);
- break;
- case AV_MIX_COEFF_TYPE_FLT:
- GET_MATRIX_CONVERT(flt, 1.0);
- break;
- default:
- av_log(am->avr, AV_LOG_ERROR, "Invalid mix coeff type\n");
- return AVERROR(EINVAL);
- }
-
- return 0;
-}
-
-static void reduce_matrix(AudioMix *am, const double *matrix, int stride)
-{
- int i, o;
-
- memset(am->output_zero, 0, sizeof(am->output_zero));
- memset(am->input_skip, 0, sizeof(am->input_skip));
- memset(am->output_skip, 0, sizeof(am->output_skip));
-
- /* exclude output channels if they can be zeroed instead of mixed */
- for (o = 0; o < am->out_channels; o++) {
- int zero = 1;
-
- /* check if the output is always silent */
- for (i = 0; i < am->in_channels; i++) {
- if (matrix[o * stride + i] != 0.0) {
- zero = 0;
- break;
- }
- }
- /* check if the corresponding input channel makes a contribution to
- any output channel */
- if (o < am->in_channels) {
- for (i = 0; i < am->out_channels; i++) {
- if (matrix[i * stride + o] != 0.0) {
- zero = 0;
- break;
- }
- }
- }
- if (zero) {
- am->output_zero[o] = 1;
- am->out_matrix_channels--;
- }
- }
- if (am->out_matrix_channels == 0) {
- am->in_matrix_channels = 0;
- return;
- }
-
- /* skip input channels that contribute fully only to the corresponding
- output channel */
- for (i = 0; i < FFMIN(am->in_channels, am->out_channels); i++) {
- int skip = 1;
-
- for (o = 0; o < am->out_channels; o++) {
- int i0;
- if ((o != i && matrix[o * stride + i] != 0.0) ||
- (o == i && matrix[o * stride + i] != 1.0)) {
- skip = 0;
- break;
- }
- /* if the input contributes fully to the output, also check that no
- other inputs contribute to this output */
- if (o == i) {
- for (i0 = 0; i0 < am->in_channels; i0++) {
- if (i0 != i && matrix[o * stride + i0] != 0.0) {
- skip = 0;
- break;
- }
- }
- }
- }
- if (skip) {
- am->input_skip[i] = 1;
- am->in_matrix_channels--;
- }
- }
- /* skip input channels that do not contribute to any output channel */
- for (; i < am->in_channels; i++) {
- int contrib = 0;
-
- for (o = 0; o < am->out_channels; o++) {
- if (matrix[o * stride + i] != 0.0) {
- contrib = 1;
- break;
- }
- }
- if (!contrib) {
- am->input_skip[i] = 1;
- am->in_matrix_channels--;
- }
- }
- if (am->in_matrix_channels == 0) {
- am->out_matrix_channels = 0;
- return;
- }
-
- /* skip output channels that only get full contribution from the
- corresponding input channel */
- for (o = 0; o < FFMIN(am->in_channels, am->out_channels); o++) {
- int skip = 1;
- int o0;
-
- for (i = 0; i < am->in_channels; i++) {
- if ((o != i && matrix[o * stride + i] != 0.0) ||
- (o == i && matrix[o * stride + i] != 1.0)) {
- skip = 0;
- break;
- }
- }
- /* check if the corresponding input channel makes a contribution to
- any other output channel */
- i = o;
- for (o0 = 0; o0 < am->out_channels; o0++) {
- if (o0 != i && matrix[o0 * stride + i] != 0.0) {
- skip = 0;
- break;
- }
- }
- if (skip) {
- am->output_skip[o] = 1;
- am->out_matrix_channels--;
- }
- }
- if (am->out_matrix_channels == 0) {
- am->in_matrix_channels = 0;
- return;
- }
-}
-
-int ff_audio_mix_set_matrix(AudioMix *am, const double *matrix, int stride)
-{
- int i, o, i0, o0, ret;
- char in_layout_name[128];
- char out_layout_name[128];
-
- if ( am->in_channels <= 0 || am->in_channels > AVRESAMPLE_MAX_CHANNELS ||
- am->out_channels <= 0 || am->out_channels > AVRESAMPLE_MAX_CHANNELS) {
- av_log(am->avr, AV_LOG_ERROR, "Invalid channel counts\n");
- return AVERROR(EINVAL);
- }
-
- if (am->matrix) {
- av_free(am->matrix[0]);
- am->matrix = NULL;
- }
-
- am->in_matrix_channels = am->in_channels;
- am->out_matrix_channels = am->out_channels;
-
- reduce_matrix(am, matrix, stride);
-
-#define CONVERT_MATRIX(type, expr) \
- am->matrix_## type[0] = av_mallocz(am->out_matrix_channels * \
- am->in_matrix_channels * \
- sizeof(*am->matrix_## type[0])); \
- if (!am->matrix_## type[0]) \
- return AVERROR(ENOMEM); \
- for (o = 0, o0 = 0; o < am->out_channels; o++) { \
- if (am->output_zero[o] || am->output_skip[o]) \
- continue; \
- if (o0 > 0) \
- am->matrix_## type[o0] = am->matrix_## type[o0 - 1] + \
- am->in_matrix_channels; \
- for (i = 0, i0 = 0; i < am->in_channels; i++) { \
- double v; \
- if (am->input_skip[i]) \
- continue; \
- v = matrix[o * stride + i]; \
- am->matrix_## type[o0][i0] = expr; \
- i0++; \
- } \
- o0++; \
- } \
- am->matrix = (void **)am->matrix_## type;
-
- if (am->in_matrix_channels && am->out_matrix_channels) {
- switch (am->coeff_type) {
- case AV_MIX_COEFF_TYPE_Q8:
- CONVERT_MATRIX(q8, av_clip_int16(lrint(256.0 * v)))
- break;
- case AV_MIX_COEFF_TYPE_Q15:
- CONVERT_MATRIX(q15, av_clipl_int32(llrint(32768.0 * v)))
- break;
- case AV_MIX_COEFF_TYPE_FLT:
- CONVERT_MATRIX(flt, v)
- break;
- default:
- av_log(am->avr, AV_LOG_ERROR, "Invalid mix coeff type\n");
- return AVERROR(EINVAL);
- }
- }
-
- ret = mix_function_init(am);
- if (ret < 0)
- return ret;
-
- av_get_channel_layout_string(in_layout_name, sizeof(in_layout_name),
- am->in_channels, am->in_layout);
- av_get_channel_layout_string(out_layout_name, sizeof(out_layout_name),
- am->out_channels, am->out_layout);
- av_log(am->avr, AV_LOG_DEBUG, "audio_mix: %s to %s\n",
- in_layout_name, out_layout_name);
- av_log(am->avr, AV_LOG_DEBUG, "matrix size: %d x %d\n",
- am->in_matrix_channels, am->out_matrix_channels);
- for (o = 0; o < am->out_channels; o++) {
- for (i = 0; i < am->in_channels; i++) {
- if (am->output_zero[o])
- av_log(am->avr, AV_LOG_DEBUG, " (ZERO)");
- else if (am->input_skip[i] || am->output_skip[o])
- av_log(am->avr, AV_LOG_DEBUG, " (SKIP)");
- else
- av_log(am->avr, AV_LOG_DEBUG, " %0.3f ",
- matrix[o * am->in_channels + i]);
- }
- av_log(am->avr, AV_LOG_DEBUG, "\n");
- }
-
- return 0;
-}
diff --git a/src/thirdparty/ffmpeg/libavresample/audio_mix.h b/src/thirdparty/ffmpeg/libavresample/audio_mix.h
deleted file mode 100644
index 5bae5ab6d..000000000
--- a/src/thirdparty/ffmpeg/libavresample/audio_mix.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVRESAMPLE_AUDIO_MIX_H
-#define AVRESAMPLE_AUDIO_MIX_H
-
-#include <stdint.h>
-
-#include "libavutil/samplefmt.h"
-#include "avresample.h"
-#include "internal.h"
-#include "audio_data.h"
-
-typedef void (mix_func)(uint8_t **src, void **matrix, int len, int out_ch,
- int in_ch);
-
-/**
- * Set mixing function if the parameters match.
- *
- * This compares the parameters of the mixing function to the parameters in the
- * AudioMix context. If the parameters do not match, no changes are made to the
- * active functions. If the parameters do match and the alignment is not
- * constrained, the function is set as the generic mixing function. If the
- * parameters match and the alignment is constrained, the function is set as
- * the optimized mixing function.
- *
- * @param am AudioMix context
- * @param fmt input/output sample format
- * @param coeff_type mixing coefficient type
- * @param in_channels number of input channels, or 0 for any number of channels
- * @param out_channels number of output channels, or 0 for any number of channels
- * @param ptr_align buffer pointer alignment, in bytes
- * @param samples_align buffer size alignment, in samples
- * @param descr function type description (e.g. "C" or "SSE")
- * @param mix_func mixing function pointer
- */
-void ff_audio_mix_set_func(AudioMix *am, enum AVSampleFormat fmt,
- enum AVMixCoeffType coeff_type, int in_channels,
- int out_channels, int ptr_align, int samples_align,
- const char *descr, void *mix_func);
-
-/**
- * Allocate and initialize an AudioMix context.
- *
- * The parameters in the AVAudioResampleContext are used to initialize the
- * AudioMix context.
- *
- * @param avr AVAudioResampleContext
- * @return newly-allocated AudioMix context.
- */
-AudioMix *ff_audio_mix_alloc(AVAudioResampleContext *avr);
-
-/**
- * Free an AudioMix context.
- */
-void ff_audio_mix_free(AudioMix **am);
-
-/**
- * Apply channel mixing to audio data using the current mixing matrix.
- */
-int ff_audio_mix(AudioMix *am, AudioData *src);
-
-/**
- * Get the current mixing matrix.
- */
-int ff_audio_mix_get_matrix(AudioMix *am, double *matrix, int stride);
-
-/**
- * Set the current mixing matrix.
- */
-int ff_audio_mix_set_matrix(AudioMix *am, const double *matrix, int stride);
-
-/* arch-specific initialization functions */
-
-void ff_audio_mix_init_x86(AudioMix *am);
-
-#endif /* AVRESAMPLE_AUDIO_MIX_H */
diff --git a/src/thirdparty/ffmpeg/libavresample/audio_mix_matrix.c b/src/thirdparty/ffmpeg/libavresample/audio_mix_matrix.c
deleted file mode 100644
index 8da1b487a..000000000
--- a/src/thirdparty/ffmpeg/libavresample/audio_mix_matrix.c
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Copyright (C) 2011 Michael Niedermayer (michaelni@gmx.at)
- * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdint.h>
-
-#include "libavutil/common.h"
-#include "libavutil/libm.h"
-#include "libavutil/samplefmt.h"
-#include "avresample.h"
-#include "internal.h"
-#include "audio_data.h"
-#include "audio_mix.h"
-
-/* channel positions */
-#define FRONT_LEFT 0
-#define FRONT_RIGHT 1
-#define FRONT_CENTER 2
-#define LOW_FREQUENCY 3
-#define BACK_LEFT 4
-#define BACK_RIGHT 5
-#define FRONT_LEFT_OF_CENTER 6
-#define FRONT_RIGHT_OF_CENTER 7
-#define BACK_CENTER 8
-#define SIDE_LEFT 9
-#define SIDE_RIGHT 10
-#define TOP_CENTER 11
-#define TOP_FRONT_LEFT 12
-#define TOP_FRONT_CENTER 13
-#define TOP_FRONT_RIGHT 14
-#define TOP_BACK_LEFT 15
-#define TOP_BACK_CENTER 16
-#define TOP_BACK_RIGHT 17
-#define STEREO_LEFT 29
-#define STEREO_RIGHT 30
-#define WIDE_LEFT 31
-#define WIDE_RIGHT 32
-#define SURROUND_DIRECT_LEFT 33
-#define SURROUND_DIRECT_RIGHT 34
-#define LOW_FREQUENCY_2 35
-
-#define SQRT3_2 1.22474487139158904909 /* sqrt(3/2) */
-
-static av_always_inline int even(uint64_t layout)
-{
- return (!layout || (layout & (layout - 1)));
-}
-
-static int sane_layout(uint64_t layout)
-{
- /* check that there is at least 1 front speaker */
- if (!(layout & AV_CH_LAYOUT_SURROUND))
- return 0;
-
- /* check for left/right symmetry */
- if (!even(layout & (AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT)) ||
- !even(layout & (AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT)) ||
- !even(layout & (AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT)) ||
- !even(layout & (AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER)) ||
- !even(layout & (AV_CH_TOP_FRONT_LEFT | AV_CH_TOP_FRONT_RIGHT)) ||
- !even(layout & (AV_CH_TOP_BACK_LEFT | AV_CH_TOP_BACK_RIGHT)) ||
- !even(layout & (AV_CH_STEREO_LEFT | AV_CH_STEREO_RIGHT)) ||
- !even(layout & (AV_CH_WIDE_LEFT | AV_CH_WIDE_RIGHT)) ||
- !even(layout & (AV_CH_SURROUND_DIRECT_LEFT | AV_CH_SURROUND_DIRECT_RIGHT)))
- return 0;
-
- return 1;
-}
-
-int avresample_build_matrix(uint64_t in_layout, uint64_t out_layout,
- double center_mix_level, double surround_mix_level,
- double lfe_mix_level, int normalize,
- double *matrix_out, int stride,
- enum AVMatrixEncoding matrix_encoding)
-{
- int i, j, out_i, out_j;
- double matrix[64][64] = {{0}};
- int64_t unaccounted;
- double maxcoef = 0;
- int in_channels, out_channels;
-
- if ((out_layout & AV_CH_LAYOUT_STEREO_DOWNMIX) == AV_CH_LAYOUT_STEREO_DOWNMIX) {
- out_layout = AV_CH_LAYOUT_STEREO;
- }
-
- unaccounted = in_layout & ~out_layout;
-
- in_channels = av_get_channel_layout_nb_channels( in_layout);
- out_channels = av_get_channel_layout_nb_channels(out_layout);
-
- memset(matrix_out, 0, out_channels * stride * sizeof(*matrix_out));
-
- /* check if layouts are supported */
- if (!in_layout || in_channels > AVRESAMPLE_MAX_CHANNELS)
- return AVERROR(EINVAL);
- if (!out_layout || out_channels > AVRESAMPLE_MAX_CHANNELS)
- return AVERROR(EINVAL);
-
- /* check if layouts are unbalanced or abnormal */
- if (!sane_layout(in_layout) || !sane_layout(out_layout))
- return AVERROR_PATCHWELCOME;
-
- /* route matching input/output channels */
- for (i = 0; i < 64; i++) {
- if (in_layout & out_layout & (1ULL << i))
- matrix[i][i] = 1.0;
- }
-
- /* mix front center to front left/right */
- if (unaccounted & AV_CH_FRONT_CENTER) {
- if ((out_layout & AV_CH_LAYOUT_STEREO) == AV_CH_LAYOUT_STEREO) {
- matrix[FRONT_LEFT ][FRONT_CENTER] += M_SQRT1_2;
- matrix[FRONT_RIGHT][FRONT_CENTER] += M_SQRT1_2;
- } else
- return AVERROR_PATCHWELCOME;
- }
- /* mix front left/right to center */
- if (unaccounted & AV_CH_LAYOUT_STEREO) {
- if (out_layout & AV_CH_FRONT_CENTER) {
- matrix[FRONT_CENTER][FRONT_LEFT ] += M_SQRT1_2;
- matrix[FRONT_CENTER][FRONT_RIGHT] += M_SQRT1_2;
- /* mix left/right/center to center */
- if (in_layout & AV_CH_FRONT_CENTER)
- matrix[FRONT_CENTER][FRONT_CENTER] = center_mix_level * M_SQRT2;
- } else
- return AVERROR_PATCHWELCOME;
- }
- /* mix back center to back, side, or front */
- if (unaccounted & AV_CH_BACK_CENTER) {
- if (out_layout & AV_CH_BACK_LEFT) {
- matrix[BACK_LEFT ][BACK_CENTER] += M_SQRT1_2;
- matrix[BACK_RIGHT][BACK_CENTER] += M_SQRT1_2;
- } else if (out_layout & AV_CH_SIDE_LEFT) {
- matrix[SIDE_LEFT ][BACK_CENTER] += M_SQRT1_2;
- matrix[SIDE_RIGHT][BACK_CENTER] += M_SQRT1_2;
- } else if (out_layout & AV_CH_FRONT_LEFT) {
- if (matrix_encoding == AV_MATRIX_ENCODING_DOLBY ||
- matrix_encoding == AV_MATRIX_ENCODING_DPLII) {
- if (unaccounted & (AV_CH_BACK_LEFT | AV_CH_SIDE_LEFT)) {
- matrix[FRONT_LEFT ][BACK_CENTER] -= surround_mix_level * M_SQRT1_2;
- matrix[FRONT_RIGHT][BACK_CENTER] += surround_mix_level * M_SQRT1_2;
- } else {
- matrix[FRONT_LEFT ][BACK_CENTER] -= surround_mix_level;
- matrix[FRONT_RIGHT][BACK_CENTER] += surround_mix_level;
- }
- } else {
- matrix[FRONT_LEFT ][BACK_CENTER] += surround_mix_level * M_SQRT1_2;
- matrix[FRONT_RIGHT][BACK_CENTER] += surround_mix_level * M_SQRT1_2;
- }
- } else if (out_layout & AV_CH_FRONT_CENTER) {
- matrix[FRONT_CENTER][BACK_CENTER] += surround_mix_level * M_SQRT1_2;
- } else
- return AVERROR_PATCHWELCOME;
- }
- /* mix back left/right to back center, side, or front */
- if (unaccounted & AV_CH_BACK_LEFT) {
- if (out_layout & AV_CH_BACK_CENTER) {
- matrix[BACK_CENTER][BACK_LEFT ] += M_SQRT1_2;
- matrix[BACK_CENTER][BACK_RIGHT] += M_SQRT1_2;
- } else if (out_layout & AV_CH_SIDE_LEFT) {
- /* if side channels do not exist in the input, just copy back
- channels to side channels, otherwise mix back into side */
- if (in_layout & AV_CH_SIDE_LEFT) {
- matrix[SIDE_LEFT ][BACK_LEFT ] += M_SQRT1_2;
- matrix[SIDE_RIGHT][BACK_RIGHT] += M_SQRT1_2;
- } else {
- matrix[SIDE_LEFT ][BACK_LEFT ] += 1.0;
- matrix[SIDE_RIGHT][BACK_RIGHT] += 1.0;
- }
- } else if (out_layout & AV_CH_FRONT_LEFT) {
- if (matrix_encoding == AV_MATRIX_ENCODING_DOLBY) {
- matrix[FRONT_LEFT ][BACK_LEFT ] -= surround_mix_level * M_SQRT1_2;
- matrix[FRONT_LEFT ][BACK_RIGHT] -= surround_mix_level * M_SQRT1_2;
- matrix[FRONT_RIGHT][BACK_LEFT ] += surround_mix_level * M_SQRT1_2;
- matrix[FRONT_RIGHT][BACK_RIGHT] += surround_mix_level * M_SQRT1_2;
- } else if (matrix_encoding == AV_MATRIX_ENCODING_DPLII) {
- matrix[FRONT_LEFT ][BACK_LEFT ] -= surround_mix_level * SQRT3_2;
- matrix[FRONT_LEFT ][BACK_RIGHT] -= surround_mix_level * M_SQRT1_2;
- matrix[FRONT_RIGHT][BACK_LEFT ] += surround_mix_level * M_SQRT1_2;
- matrix[FRONT_RIGHT][BACK_RIGHT] += surround_mix_level * SQRT3_2;
- } else {
- matrix[FRONT_LEFT ][BACK_LEFT ] += surround_mix_level;
- matrix[FRONT_RIGHT][BACK_RIGHT] += surround_mix_level;
- }
- } else if (out_layout & AV_CH_FRONT_CENTER) {
- matrix[FRONT_CENTER][BACK_LEFT ] += surround_mix_level * M_SQRT1_2;
- matrix[FRONT_CENTER][BACK_RIGHT] += surround_mix_level * M_SQRT1_2;
- } else
- return AVERROR_PATCHWELCOME;
- }
- /* mix side left/right into back or front */
- if (unaccounted & AV_CH_SIDE_LEFT) {
- if (out_layout & AV_CH_BACK_LEFT) {
- /* if back channels do not exist in the input, just copy side
- channels to back channels, otherwise mix side into back */
- if (in_layout & AV_CH_BACK_LEFT) {
- matrix[BACK_LEFT ][SIDE_LEFT ] += M_SQRT1_2;
- matrix[BACK_RIGHT][SIDE_RIGHT] += M_SQRT1_2;
- } else {
- matrix[BACK_LEFT ][SIDE_LEFT ] += 1.0;
- matrix[BACK_RIGHT][SIDE_RIGHT] += 1.0;
- }
- } else if (out_layout & AV_CH_BACK_CENTER) {
- matrix[BACK_CENTER][SIDE_LEFT ] += M_SQRT1_2;
- matrix[BACK_CENTER][SIDE_RIGHT] += M_SQRT1_2;
- } else if (out_layout & AV_CH_FRONT_LEFT) {
- if (matrix_encoding == AV_MATRIX_ENCODING_DOLBY) {
- matrix[FRONT_LEFT ][SIDE_LEFT ] -= surround_mix_level * M_SQRT1_2;
- matrix[FRONT_LEFT ][SIDE_RIGHT] -= surround_mix_level * M_SQRT1_2;
- matrix[FRONT_RIGHT][SIDE_LEFT ] += surround_mix_level * M_SQRT1_2;
- matrix[FRONT_RIGHT][SIDE_RIGHT] += surround_mix_level * M_SQRT1_2;
- } else if (matrix_encoding == AV_MATRIX_ENCODING_DPLII) {
- matrix[FRONT_LEFT ][SIDE_LEFT ] -= surround_mix_level * SQRT3_2;
- matrix[FRONT_LEFT ][SIDE_RIGHT] -= surround_mix_level * M_SQRT1_2;
- matrix[FRONT_RIGHT][SIDE_LEFT ] += surround_mix_level * M_SQRT1_2;
- matrix[FRONT_RIGHT][SIDE_RIGHT] += surround_mix_level * SQRT3_2;
- } else {
- matrix[FRONT_LEFT ][SIDE_LEFT ] += surround_mix_level;
- matrix[FRONT_RIGHT][SIDE_RIGHT] += surround_mix_level;
- }
- } else if (out_layout & AV_CH_FRONT_CENTER) {
- matrix[FRONT_CENTER][SIDE_LEFT ] += surround_mix_level * M_SQRT1_2;
- matrix[FRONT_CENTER][SIDE_RIGHT] += surround_mix_level * M_SQRT1_2;
- } else
- return AVERROR_PATCHWELCOME;
- }
- /* mix left-of-center/right-of-center into front left/right or center */
- if (unaccounted & AV_CH_FRONT_LEFT_OF_CENTER) {
- if (out_layout & AV_CH_FRONT_LEFT) {
- matrix[FRONT_LEFT ][FRONT_LEFT_OF_CENTER ] += 1.0;
- matrix[FRONT_RIGHT][FRONT_RIGHT_OF_CENTER] += 1.0;
- } else if (out_layout & AV_CH_FRONT_CENTER) {
- matrix[FRONT_CENTER][FRONT_LEFT_OF_CENTER ] += M_SQRT1_2;
- matrix[FRONT_CENTER][FRONT_RIGHT_OF_CENTER] += M_SQRT1_2;
- } else
- return AVERROR_PATCHWELCOME;
- }
- /* mix LFE into front left/right or center */
- if (unaccounted & AV_CH_LOW_FREQUENCY) {
- if (out_layout & AV_CH_FRONT_CENTER) {
- matrix[FRONT_CENTER][LOW_FREQUENCY] += lfe_mix_level;
- } else if (out_layout & AV_CH_FRONT_LEFT) {
- matrix[FRONT_LEFT ][LOW_FREQUENCY] += lfe_mix_level * M_SQRT1_2;
- matrix[FRONT_RIGHT][LOW_FREQUENCY] += lfe_mix_level * M_SQRT1_2;
- } else
- return AVERROR_PATCHWELCOME;
- }
-
- /* transfer internal matrix to output matrix and calculate maximum
- per-channel coefficient sum */
- for (out_i = i = 0; out_i < out_channels && i < 64; i++) {
- double sum = 0;
- for (out_j = j = 0; out_j < in_channels && j < 64; j++) {
- matrix_out[out_i * stride + out_j] = matrix[i][j];
- sum += fabs(matrix[i][j]);
- if (in_layout & (1ULL << j))
- out_j++;
- }
- maxcoef = FFMAX(maxcoef, sum);
- if (out_layout & (1ULL << i))
- out_i++;
- }
-
- /* normalize */
- if (normalize && maxcoef > 1.0) {
- for (i = 0; i < out_channels; i++)
- for (j = 0; j < in_channels; j++)
- matrix_out[i * stride + j] /= maxcoef;
- }
-
- return 0;
-}
diff --git a/src/thirdparty/ffmpeg/libavresample/avresample.h b/src/thirdparty/ffmpeg/libavresample/avresample.h
deleted file mode 100644
index d26f2ca22..000000000
--- a/src/thirdparty/ffmpeg/libavresample/avresample.h
+++ /dev/null
@@ -1,409 +0,0 @@
-/*
- * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVRESAMPLE_AVRESAMPLE_H
-#define AVRESAMPLE_AVRESAMPLE_H
-
-/**
- * @file
- * @ingroup lavr
- * external API header
- */
-
-/**
- * @defgroup lavr Libavresample
- * @{
- *
- * Libavresample (lavr) is a library that handles audio resampling, sample
- * format conversion and mixing.
- *
- * Interaction with lavr is done through AVAudioResampleContext, which is
- * allocated with avresample_alloc_context(). It is opaque, so all parameters
- * must be set with the @ref avoptions API.
- *
- * For example the following code will setup conversion from planar float sample
- * format to interleaved signed 16-bit integer, downsampling from 48kHz to
- * 44.1kHz and downmixing from 5.1 channels to stereo (using the default mixing
- * matrix):
- * @code
- * AVAudioResampleContext *avr = avresample_alloc_context();
- * av_opt_set_int(avr, "in_channel_layout", AV_CH_LAYOUT_5POINT1, 0);
- * av_opt_set_int(avr, "out_channel_layout", AV_CH_LAYOUT_STEREO, 0);
- * av_opt_set_int(avr, "in_sample_rate", 48000, 0);
- * av_opt_set_int(avr, "out_sample_rate", 44100, 0);
- * av_opt_set_int(avr, "in_sample_fmt", AV_SAMPLE_FMT_FLTP, 0);
- * av_opt_set_int(avr, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0);
- * @endcode
- *
- * Once the context is initialized, it must be opened with avresample_open(). If
- * you need to change the conversion parameters, you must close the context with
- * avresample_close(), change the parameters as described above, then reopen it
- * again.
- *
- * The conversion itself is done by repeatedly calling avresample_convert().
- * Note that the samples may get buffered in two places in lavr. The first one
- * is the output FIFO, where the samples end up if the output buffer is not
- * large enough. The data stored in there may be retrieved at any time with
- * avresample_read(). The second place is the resampling delay buffer,
- * applicable only when resampling is done. The samples in it require more input
- * before they can be processed. Their current amount is returned by
- * avresample_get_delay(). At the end of conversion the resampling buffer can be
- * flushed by calling avresample_convert() with NULL input.
- *
- * The following code demonstrates the conversion loop assuming the parameters
- * from above and caller-defined functions get_input() and handle_output():
- * @code
- * uint8_t **input;
- * int in_linesize, in_samples;
- *
- * while (get_input(&input, &in_linesize, &in_samples)) {
- * uint8_t *output
- * int out_linesize;
- * int out_samples = avresample_available(avr) +
- * av_rescale_rnd(avresample_get_delay(avr) +
- * in_samples, 44100, 48000, AV_ROUND_UP);
- * av_samples_alloc(&output, &out_linesize, 2, out_samples,
- * AV_SAMPLE_FMT_S16, 0);
- * out_samples = avresample_convert(avr, &output, out_linesize, out_samples,
- * input, in_linesize, in_samples);
- * handle_output(output, out_linesize, out_samples);
- * av_freep(&output);
- * }
- * @endcode
- *
- * When the conversion is finished and the FIFOs are flushed if required, the
- * conversion context and everything associated with it must be freed with
- * avresample_free().
- */
-
-#include "libavutil/avutil.h"
-#include "libavutil/channel_layout.h"
-#include "libavutil/dict.h"
-#include "libavutil/log.h"
-
-#include "libavresample/version.h"
-
-#define AVRESAMPLE_MAX_CHANNELS 32
-
-typedef struct AVAudioResampleContext AVAudioResampleContext;
-
-/** Mixing Coefficient Types */
-enum AVMixCoeffType {
- AV_MIX_COEFF_TYPE_Q8, /** 16-bit 8.8 fixed-point */
- AV_MIX_COEFF_TYPE_Q15, /** 32-bit 17.15 fixed-point */
- AV_MIX_COEFF_TYPE_FLT, /** floating-point */
- AV_MIX_COEFF_TYPE_NB, /** Number of coeff types. Not part of ABI */
-};
-
-/** Resampling Filter Types */
-enum AVResampleFilterType {
- AV_RESAMPLE_FILTER_TYPE_CUBIC, /**< Cubic */
- AV_RESAMPLE_FILTER_TYPE_BLACKMAN_NUTTALL, /**< Blackman Nuttall Windowed Sinc */
- AV_RESAMPLE_FILTER_TYPE_KAISER, /**< Kaiser Windowed Sinc */
-};
-
-enum AVResampleDitherMethod {
- AV_RESAMPLE_DITHER_NONE, /**< Do not use dithering */
- AV_RESAMPLE_DITHER_RECTANGULAR, /**< Rectangular Dither */
- AV_RESAMPLE_DITHER_TRIANGULAR, /**< Triangular Dither*/
- AV_RESAMPLE_DITHER_TRIANGULAR_HP, /**< Triangular Dither with High Pass */
- AV_RESAMPLE_DITHER_TRIANGULAR_NS, /**< Triangular Dither with Noise Shaping */
- AV_RESAMPLE_DITHER_NB, /**< Number of dither types. Not part of ABI. */
-};
-
-/**
- * Return the LIBAVRESAMPLE_VERSION_INT constant.
- */
-unsigned avresample_version(void);
-
-/**
- * Return the libavresample build-time configuration.
- * @return configure string
- */
-const char *avresample_configuration(void);
-
-/**
- * Return the libavresample license.
- */
-const char *avresample_license(void);
-
-/**
- * Get the AVClass for AVAudioResampleContext.
- *
- * Can be used in combination with AV_OPT_SEARCH_FAKE_OBJ for examining options
- * without allocating a context.
- *
- * @see av_opt_find().
- *
- * @return AVClass for AVAudioResampleContext
- */
-const AVClass *avresample_get_class(void);
-
-/**
- * Allocate AVAudioResampleContext and set options.
- *
- * @return allocated audio resample context, or NULL on failure
- */
-AVAudioResampleContext *avresample_alloc_context(void);
-
-/**
- * Initialize AVAudioResampleContext.
- *
- * @param avr audio resample context
- * @return 0 on success, negative AVERROR code on failure
- */
-int avresample_open(AVAudioResampleContext *avr);
-
-/**
- * Close AVAudioResampleContext.
- *
- * This closes the context, but it does not change the parameters. The context
- * can be reopened with avresample_open(). It does, however, clear the output
- * FIFO and any remaining leftover samples in the resampling delay buffer. If
- * there was a custom matrix being used, that is also cleared.
- *
- * @see avresample_convert()
- * @see avresample_set_matrix()
- *
- * @param avr audio resample context
- */
-void avresample_close(AVAudioResampleContext *avr);
-
-/**
- * Free AVAudioResampleContext and associated AVOption values.
- *
- * This also calls avresample_close() before freeing.
- *
- * @param avr audio resample context
- */
-void avresample_free(AVAudioResampleContext **avr);
-
-/**
- * Generate a channel mixing matrix.
- *
- * This function is the one used internally by libavresample for building the
- * default mixing matrix. It is made public just as a utility function for
- * building custom matrices.
- *
- * @param in_layout input channel layout
- * @param out_layout output channel layout
- * @param center_mix_level mix level for the center channel
- * @param surround_mix_level mix level for the surround channel(s)
- * @param lfe_mix_level mix level for the low-frequency effects channel
- * @param normalize if 1, coefficients will be normalized to prevent
- * overflow. if 0, coefficients will not be
- * normalized.
- * @param[out] matrix mixing coefficients; matrix[i + stride * o] is
- * the weight of input channel i in output channel o.
- * @param stride distance between adjacent input channels in the
- * matrix array
- * @param matrix_encoding matrixed stereo downmix mode (e.g. dplii)
- * @return 0 on success, negative AVERROR code on failure
- */
-int avresample_build_matrix(uint64_t in_layout, uint64_t out_layout,
- double center_mix_level, double surround_mix_level,
- double lfe_mix_level, int normalize, double *matrix,
- int stride, enum AVMatrixEncoding matrix_encoding);
-
-/**
- * Get the current channel mixing matrix.
- *
- * If no custom matrix has been previously set or the AVAudioResampleContext is
- * not open, an error is returned.
- *
- * @param avr audio resample context
- * @param matrix mixing coefficients; matrix[i + stride * o] is the weight of
- * input channel i in output channel o.
- * @param stride distance between adjacent input channels in the matrix array
- * @return 0 on success, negative AVERROR code on failure
- */
-int avresample_get_matrix(AVAudioResampleContext *avr, double *matrix,
- int stride);
-
-/**
- * Set channel mixing matrix.
- *
- * Allows for setting a custom mixing matrix, overriding the default matrix
- * generated internally during avresample_open(). This function can be called
- * anytime on an allocated context, either before or after calling
- * avresample_open(), as long as the channel layouts have been set.
- * avresample_convert() always uses the current matrix.
- * Calling avresample_close() on the context will clear the current matrix.
- *
- * @see avresample_close()
- *
- * @param avr audio resample context
- * @param matrix mixing coefficients; matrix[i + stride * o] is the weight of
- * input channel i in output channel o.
- * @param stride distance between adjacent input channels in the matrix array
- * @return 0 on success, negative AVERROR code on failure
- */
-int avresample_set_matrix(AVAudioResampleContext *avr, const double *matrix,
- int stride);
-
-/**
- * Set a customized input channel mapping.
- *
- * This function can only be called when the allocated context is not open.
- * Also, the input channel layout must have already been set.
- *
- * Calling avresample_close() on the context will clear the channel mapping.
- *
- * The map for each input channel specifies the channel index in the source to
- * use for that particular channel, or -1 to mute the channel. Source channels
- * can be duplicated by using the same index for multiple input channels.
- *
- * Examples:
- *
- * Reordering 5.1 AAC order (C,L,R,Ls,Rs,LFE) to Libav order (L,R,C,LFE,Ls,Rs):
- * { 1, 2, 0, 5, 3, 4 }
- *
- * Muting the 3rd channel in 4-channel input:
- * { 0, 1, -1, 3 }
- *
- * Duplicating the left channel of stereo input:
- * { 0, 0 }
- *
- * @param avr audio resample context
- * @param channel_map customized input channel mapping
- * @return 0 on success, negative AVERROR code on failure
- */
-int avresample_set_channel_mapping(AVAudioResampleContext *avr,
- const int *channel_map);
-
-/**
- * Set compensation for resampling.
- *
- * This can be called anytime after avresample_open(). If resampling is not
- * automatically enabled because of a sample rate conversion, the
- * "force_resampling" option must have been set to 1 when opening the context
- * in order to use resampling compensation.
- *
- * @param avr audio resample context
- * @param sample_delta compensation delta, in samples
- * @param compensation_distance compensation distance, in samples
- * @return 0 on success, negative AVERROR code on failure
- */
-int avresample_set_compensation(AVAudioResampleContext *avr, int sample_delta,
- int compensation_distance);
-
-/**
- * Convert input samples and write them to the output FIFO.
- *
- * The upper bound on the number of output samples is given by
- * avresample_available() + (avresample_get_delay() + number of input samples) *
- * output sample rate / input sample rate.
- *
- * The output data can be NULL or have fewer allocated samples than required.
- * In this case, any remaining samples not written to the output will be added
- * to an internal FIFO buffer, to be returned at the next call to this function
- * or to avresample_read().
- *
- * If converting sample rate, there may be data remaining in the internal
- * resampling delay buffer. avresample_get_delay() tells the number of remaining
- * samples. To get this data as output, call avresample_convert() with NULL
- * input.
- *
- * At the end of the conversion process, there may be data remaining in the
- * internal FIFO buffer. avresample_available() tells the number of remaining
- * samples. To get this data as output, either call avresample_convert() with
- * NULL input or call avresample_read().
- *
- * @see avresample_available()
- * @see avresample_read()
- * @see avresample_get_delay()
- *
- * @param avr audio resample context
- * @param output output data pointers
- * @param out_plane_size output plane size, in bytes.
- * This can be 0 if unknown, but that will lead to
- * optimized functions not being used directly on the
- * output, which could slow down some conversions.
- * @param out_samples maximum number of samples that the output buffer can hold
- * @param input input data pointers
- * @param in_plane_size input plane size, in bytes
- * This can be 0 if unknown, but that will lead to
- * optimized functions not being used directly on the
- * input, which could slow down some conversions.
- * @param in_samples number of input samples to convert
- * @return number of samples written to the output buffer,
- * not including converted samples added to the internal
- * output FIFO
- */
-int avresample_convert(AVAudioResampleContext *avr, uint8_t **output,
- int out_plane_size, int out_samples, uint8_t **input,
- int in_plane_size, int in_samples);
-
-/**
- * Return the number of samples currently in the resampling delay buffer.
- *
- * When resampling, there may be a delay between the input and output. Any
- * unconverted samples in each call are stored internally in a delay buffer.
- * This function allows the user to determine the current number of samples in
- * the delay buffer, which can be useful for synchronization.
- *
- * @see avresample_convert()
- *
- * @param avr audio resample context
- * @return number of samples currently in the resampling delay buffer
- */
-int avresample_get_delay(AVAudioResampleContext *avr);
-
-/**
- * Return the number of available samples in the output FIFO.
- *
- * During conversion, if the user does not specify an output buffer or
- * specifies an output buffer that is smaller than what is needed, remaining
- * samples that are not written to the output are stored to an internal FIFO
- * buffer. The samples in the FIFO can be read with avresample_read() or
- * avresample_convert().
- *
- * @see avresample_read()
- * @see avresample_convert()
- *
- * @param avr audio resample context
- * @return number of samples available for reading
- */
-int avresample_available(AVAudioResampleContext *avr);
-
-/**
- * Read samples from the output FIFO.
- *
- * During conversion, if the user does not specify an output buffer or
- * specifies an output buffer that is smaller than what is needed, remaining
- * samples that are not written to the output are stored to an internal FIFO
- * buffer. This function can be used to read samples from that internal FIFO.
- *
- * @see avresample_available()
- * @see avresample_convert()
- *
- * @param avr audio resample context
- * @param output output data pointers. May be NULL, in which case
- * nb_samples of data is discarded from output FIFO.
- * @param nb_samples number of samples to read from the FIFO
- * @return the number of samples written to output
- */
-int avresample_read(AVAudioResampleContext *avr, uint8_t **output, int nb_samples);
-
-/**
- * @}
- */
-
-#endif /* AVRESAMPLE_AVRESAMPLE_H */
diff --git a/src/thirdparty/ffmpeg/libavresample/dither.c b/src/thirdparty/ffmpeg/libavresample/dither.c
deleted file mode 100644
index f24bf5c76..000000000
--- a/src/thirdparty/ffmpeg/libavresample/dither.c
+++ /dev/null
@@ -1,439 +0,0 @@
-/*
- * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
- *
- * Triangular with Noise Shaping is based on opusfile.
- * Copyright (c) 1994-2012 by the Xiph.Org Foundation and contributors
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * Dithered Audio Sample Quantization
- *
- * Converts from dbl, flt, or s32 to s16 using dithering.
- */
-
-#include <math.h>
-#include <stdint.h>
-
-#include "libavutil/common.h"
-#include "libavutil/lfg.h"
-#include "libavutil/mem.h"
-#include "libavutil/samplefmt.h"
-#include "audio_convert.h"
-#include "dither.h"
-#include "internal.h"
-
-typedef struct DitherState {
- int mute;
- unsigned int seed;
- AVLFG lfg;
- float *noise_buf;
- int noise_buf_size;
- int noise_buf_ptr;
- float dither_a[4];
- float dither_b[4];
-} DitherState;
-
-struct DitherContext {
- DitherDSPContext ddsp;
- enum AVResampleDitherMethod method;
- int apply_map;
- ChannelMapInfo *ch_map_info;
-
- int mute_dither_threshold; // threshold for disabling dither
- int mute_reset_threshold; // threshold for resetting noise shaping
- const float *ns_coef_b; // noise shaping coeffs
- const float *ns_coef_a; // noise shaping coeffs
-
- int channels;
- DitherState *state; // dither states for each channel
-
- AudioData *flt_data; // input data in fltp
- AudioData *s16_data; // dithered output in s16p
- AudioConvert *ac_in; // converter for input to fltp
- AudioConvert *ac_out; // converter for s16p to s16 (if needed)
-
- void (*quantize)(int16_t *dst, const float *src, float *dither, int len);
- int samples_align;
-};
-
-/* mute threshold, in seconds */
-#define MUTE_THRESHOLD_SEC 0.000333
-
-/* scale factor for 16-bit output.
- The signal is attenuated slightly to avoid clipping */
-#define S16_SCALE 32753.0f
-
-/* scale to convert lfg from INT_MIN/INT_MAX to -0.5/0.5 */
-#define LFG_SCALE (1.0f / (2.0f * INT32_MAX))
-
-/* noise shaping coefficients */
-
-static const float ns_48_coef_b[4] = {
- 2.2374f, -0.7339f, -0.1251f, -0.6033f
-};
-
-static const float ns_48_coef_a[4] = {
- 0.9030f, 0.0116f, -0.5853f, -0.2571f
-};
-
-static const float ns_44_coef_b[4] = {
- 2.2061f, -0.4707f, -0.2534f, -0.6213f
-};
-
-static const float ns_44_coef_a[4] = {
- 1.0587f, 0.0676f, -0.6054f, -0.2738f
-};
-
-static void dither_int_to_float_rectangular_c(float *dst, int *src, int len)
-{
- int i;
- for (i = 0; i < len; i++)
- dst[i] = src[i] * LFG_SCALE;
-}
-
-static void dither_int_to_float_triangular_c(float *dst, int *src0, int len)
-{
- int i;
- int *src1 = src0 + len;
-
- for (i = 0; i < len; i++) {
- float r = src0[i] * LFG_SCALE;
- r += src1[i] * LFG_SCALE;
- dst[i] = r;
- }
-}
-
-static void quantize_c(int16_t *dst, const float *src, float *dither, int len)
-{
- int i;
- for (i = 0; i < len; i++)
- dst[i] = av_clip_int16(lrintf(src[i] * S16_SCALE + dither[i]));
-}
-
-#define SQRT_1_6 0.40824829046386301723f
-
-static void dither_highpass_filter(float *src, int len)
-{
- int i;
-
- /* filter is from libswresample in FFmpeg */
- for (i = 0; i < len - 2; i++)
- src[i] = (-src[i] + 2 * src[i + 1] - src[i + 2]) * SQRT_1_6;
-}
-
-static int generate_dither_noise(DitherContext *c, DitherState *state,
- int min_samples)
-{
- int i;
- int nb_samples = FFALIGN(min_samples, 16) + 16;
- int buf_samples = nb_samples *
- (c->method == AV_RESAMPLE_DITHER_RECTANGULAR ? 1 : 2);
- unsigned int *noise_buf_ui;
-
- av_freep(&state->noise_buf);
- state->noise_buf_size = state->noise_buf_ptr = 0;
-
- state->noise_buf = av_malloc(buf_samples * sizeof(*state->noise_buf));
- if (!state->noise_buf)
- return AVERROR(ENOMEM);
- state->noise_buf_size = FFALIGN(min_samples, 16);
- noise_buf_ui = (unsigned int *)state->noise_buf;
-
- av_lfg_init(&state->lfg, state->seed);
- for (i = 0; i < buf_samples; i++)
- noise_buf_ui[i] = av_lfg_get(&state->lfg);
-
- c->ddsp.dither_int_to_float(state->noise_buf, noise_buf_ui, nb_samples);
-
- if (c->method == AV_RESAMPLE_DITHER_TRIANGULAR_HP)
- dither_highpass_filter(state->noise_buf, nb_samples);
-
- return 0;
-}
-
-static void quantize_triangular_ns(DitherContext *c, DitherState *state,
- int16_t *dst, const float *src,
- int nb_samples)
-{
- int i, j;
- float *dither = &state->noise_buf[state->noise_buf_ptr];
-
- if (state->mute > c->mute_reset_threshold)
- memset(state->dither_a, 0, sizeof(state->dither_a));
-
- for (i = 0; i < nb_samples; i++) {
- float err = 0;
- float sample = src[i] * S16_SCALE;
-
- for (j = 0; j < 4; j++) {
- err += c->ns_coef_b[j] * state->dither_b[j] -
- c->ns_coef_a[j] * state->dither_a[j];
- }
- for (j = 3; j > 0; j--) {
- state->dither_a[j] = state->dither_a[j - 1];
- state->dither_b[j] = state->dither_b[j - 1];
- }
- state->dither_a[0] = err;
- sample -= err;
-
- if (state->mute > c->mute_dither_threshold) {
- dst[i] = av_clip_int16(lrintf(sample));
- state->dither_b[0] = 0;
- } else {
- dst[i] = av_clip_int16(lrintf(sample + dither[i]));
- state->dither_b[0] = av_clipf(dst[i] - sample, -1.5f, 1.5f);
- }
-
- state->mute++;
- if (src[i])
- state->mute = 0;
- }
-}
-
-static int convert_samples(DitherContext *c, int16_t **dst, float * const *src,
- int channels, int nb_samples)
-{
- int ch, ret;
- int aligned_samples = FFALIGN(nb_samples, 16);
-
- for (ch = 0; ch < channels; ch++) {
- DitherState *state = &c->state[ch];
-
- if (state->noise_buf_size < aligned_samples) {
- ret = generate_dither_noise(c, state, nb_samples);
- if (ret < 0)
- return ret;
- } else if (state->noise_buf_size - state->noise_buf_ptr < aligned_samples) {
- state->noise_buf_ptr = 0;
- }
-
- if (c->method == AV_RESAMPLE_DITHER_TRIANGULAR_NS) {
- quantize_triangular_ns(c, state, dst[ch], src[ch], nb_samples);
- } else {
- c->quantize(dst[ch], src[ch],
- &state->noise_buf[state->noise_buf_ptr],
- FFALIGN(nb_samples, c->samples_align));
- }
-
- state->noise_buf_ptr += aligned_samples;
- }
-
- return 0;
-}
-
-int ff_convert_dither(DitherContext *c, AudioData *dst, AudioData *src)
-{
- int ret;
- AudioData *flt_data;
-
- /* output directly to dst if it is planar */
- if (dst->sample_fmt == AV_SAMPLE_FMT_S16P)
- c->s16_data = dst;
- else {
- /* make sure s16_data is large enough for the output */
- ret = ff_audio_data_realloc(c->s16_data, src->nb_samples);
- if (ret < 0)
- return ret;
- }
-
- if (src->sample_fmt != AV_SAMPLE_FMT_FLTP || c->apply_map) {
- /* make sure flt_data is large enough for the input */
- ret = ff_audio_data_realloc(c->flt_data, src->nb_samples);
- if (ret < 0)
- return ret;
- flt_data = c->flt_data;
- }
-
- if (src->sample_fmt != AV_SAMPLE_FMT_FLTP) {
- /* convert input samples to fltp and scale to s16 range */
- ret = ff_audio_convert(c->ac_in, flt_data, src);
- if (ret < 0)
- return ret;
- } else if (c->apply_map) {
- ret = ff_audio_data_copy(flt_data, src, c->ch_map_info);
- if (ret < 0)
- return ret;
- } else {
- flt_data = src;
- }
-
- /* check alignment and padding constraints */
- if (c->method != AV_RESAMPLE_DITHER_TRIANGULAR_NS) {
- int ptr_align = FFMIN(flt_data->ptr_align, c->s16_data->ptr_align);
- int samples_align = FFMIN(flt_data->samples_align, c->s16_data->samples_align);
- int aligned_len = FFALIGN(src->nb_samples, c->ddsp.samples_align);
-
- if (!(ptr_align % c->ddsp.ptr_align) && samples_align >= aligned_len) {
- c->quantize = c->ddsp.quantize;
- c->samples_align = c->ddsp.samples_align;
- } else {
- c->quantize = quantize_c;
- c->samples_align = 1;
- }
- }
-
- ret = convert_samples(c, (int16_t **)c->s16_data->data,
- (float * const *)flt_data->data, src->channels,
- src->nb_samples);
- if (ret < 0)
- return ret;
-
- c->s16_data->nb_samples = src->nb_samples;
-
- /* interleave output to dst if needed */
- if (dst->sample_fmt == AV_SAMPLE_FMT_S16) {
- ret = ff_audio_convert(c->ac_out, dst, c->s16_data);
- if (ret < 0)
- return ret;
- } else
- c->s16_data = NULL;
-
- return 0;
-}
-
-void ff_dither_free(DitherContext **cp)
-{
- DitherContext *c = *cp;
- int ch;
-
- if (!c)
- return;
- ff_audio_data_free(&c->flt_data);
- ff_audio_data_free(&c->s16_data);
- ff_audio_convert_free(&c->ac_in);
- ff_audio_convert_free(&c->ac_out);
- for (ch = 0; ch < c->channels; ch++)
- av_free(c->state[ch].noise_buf);
- av_free(c->state);
- av_freep(cp);
-}
-
-static void dither_init(DitherDSPContext *ddsp,
- enum AVResampleDitherMethod method)
-{
- ddsp->quantize = quantize_c;
- ddsp->ptr_align = 1;
- ddsp->samples_align = 1;
-
- if (method == AV_RESAMPLE_DITHER_RECTANGULAR)
- ddsp->dither_int_to_float = dither_int_to_float_rectangular_c;
- else
- ddsp->dither_int_to_float = dither_int_to_float_triangular_c;
-
- if (ARCH_X86)
- ff_dither_init_x86(ddsp, method);
-}
-
-DitherContext *ff_dither_alloc(AVAudioResampleContext *avr,
- enum AVSampleFormat out_fmt,
- enum AVSampleFormat in_fmt,
- int channels, int sample_rate, int apply_map)
-{
- AVLFG seed_gen;
- DitherContext *c;
- int ch;
-
- if (av_get_packed_sample_fmt(out_fmt) != AV_SAMPLE_FMT_S16 ||
- av_get_bytes_per_sample(in_fmt) <= 2) {
- av_log(avr, AV_LOG_ERROR, "dithering %s to %s is not supported\n",
- av_get_sample_fmt_name(in_fmt), av_get_sample_fmt_name(out_fmt));
- return NULL;
- }
-
- c = av_mallocz(sizeof(*c));
- if (!c)
- return NULL;
-
- c->apply_map = apply_map;
- if (apply_map)
- c->ch_map_info = &avr->ch_map_info;
-
- if (avr->dither_method == AV_RESAMPLE_DITHER_TRIANGULAR_NS &&
- sample_rate != 48000 && sample_rate != 44100) {
- av_log(avr, AV_LOG_WARNING, "sample rate must be 48000 or 44100 Hz "
- "for triangular_ns dither. using triangular_hp instead.\n");
- avr->dither_method = AV_RESAMPLE_DITHER_TRIANGULAR_HP;
- }
- c->method = avr->dither_method;
- dither_init(&c->ddsp, c->method);
-
- if (c->method == AV_RESAMPLE_DITHER_TRIANGULAR_NS) {
- if (sample_rate == 48000) {
- c->ns_coef_b = ns_48_coef_b;
- c->ns_coef_a = ns_48_coef_a;
- } else {
- c->ns_coef_b = ns_44_coef_b;
- c->ns_coef_a = ns_44_coef_a;
- }
- }
-
- /* Either s16 or s16p output format is allowed, but s16p is used
- internally, so we need to use a temp buffer and interleave if the output
- format is s16 */
- if (out_fmt != AV_SAMPLE_FMT_S16P) {
- c->s16_data = ff_audio_data_alloc(channels, 1024, AV_SAMPLE_FMT_S16P,
- "dither s16 buffer");
- if (!c->s16_data)
- goto fail;
-
- c->ac_out = ff_audio_convert_alloc(avr, out_fmt, AV_SAMPLE_FMT_S16P,
- channels, sample_rate, 0);
- if (!c->ac_out)
- goto fail;
- }
-
- if (in_fmt != AV_SAMPLE_FMT_FLTP || c->apply_map) {
- c->flt_data = ff_audio_data_alloc(channels, 1024, AV_SAMPLE_FMT_FLTP,
- "dither flt buffer");
- if (!c->flt_data)
- goto fail;
- }
- if (in_fmt != AV_SAMPLE_FMT_FLTP) {
- c->ac_in = ff_audio_convert_alloc(avr, AV_SAMPLE_FMT_FLTP, in_fmt,
- channels, sample_rate, c->apply_map);
- if (!c->ac_in)
- goto fail;
- }
-
- c->state = av_mallocz(channels * sizeof(*c->state));
- if (!c->state)
- goto fail;
- c->channels = channels;
-
- /* calculate thresholds for turning off dithering during periods of
- silence to avoid replacing digital silence with quiet dither noise */
- c->mute_dither_threshold = lrintf(sample_rate * MUTE_THRESHOLD_SEC);
- c->mute_reset_threshold = c->mute_dither_threshold * 4;
-
- /* initialize dither states */
- av_lfg_init(&seed_gen, 0xC0FFEE);
- for (ch = 0; ch < channels; ch++) {
- DitherState *state = &c->state[ch];
- state->mute = c->mute_reset_threshold + 1;
- state->seed = av_lfg_get(&seed_gen);
- generate_dither_noise(c, state, FFMAX(32768, sample_rate / 2));
- }
-
- return c;
-
-fail:
- ff_dither_free(&c);
- return NULL;
-}
diff --git a/src/thirdparty/ffmpeg/libavresample/dither.h b/src/thirdparty/ffmpeg/libavresample/dither.h
deleted file mode 100644
index 8db37146f..000000000
--- a/src/thirdparty/ffmpeg/libavresample/dither.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVRESAMPLE_DITHER_H
-#define AVRESAMPLE_DITHER_H
-
-#include "avresample.h"
-#include "audio_data.h"
-
-typedef struct DitherContext DitherContext;
-
-typedef struct DitherDSPContext {
- /**
- * Convert samples from flt to s16 with added dither noise.
- *
- * @param dst destination float array, range -0.5 to 0.5
- * @param src source int array, range INT_MIN to INT_MAX.
- * @param dither float dither noise array
- * @param len number of samples
- */
- void (*quantize)(int16_t *dst, const float *src, float *dither, int len);
-
- int ptr_align; ///< src and dst constraits for quantize()
- int samples_align; ///< len constraits for quantize()
-
- /**
- * Convert dither noise from int to float with triangular distribution.
- *
- * @param dst destination float array, range -0.5 to 0.5
- * constraints: 32-byte aligned
- * @param src0 source int array, range INT_MIN to INT_MAX.
- * the array size is len * 2
- * constraints: 32-byte aligned
- * @param len number of output noise samples
- * constraints: multiple of 16
- */
- void (*dither_int_to_float)(float *dst, int *src0, int len);
-} DitherDSPContext;
-
-/**
- * Allocate and initialize a DitherContext.
- *
- * The parameters in the AVAudioResampleContext are used to initialize the
- * DitherContext.
- *
- * @param avr AVAudioResampleContext
- * @return newly-allocated DitherContext
- */
-DitherContext *ff_dither_alloc(AVAudioResampleContext *avr,
- enum AVSampleFormat out_fmt,
- enum AVSampleFormat in_fmt,
- int channels, int sample_rate, int apply_map);
-
-/**
- * Free a DitherContext.
- *
- * @param c DitherContext
- */
-void ff_dither_free(DitherContext **c);
-
-/**
- * Convert audio sample format with dithering.
- *
- * @param c DitherContext
- * @param dst destination audio data
- * @param src source audio data
- * @return 0 if ok, negative AVERROR code on failure
- */
-int ff_convert_dither(DitherContext *c, AudioData *dst, AudioData *src);
-
-/* arch-specific initialization functions */
-
-void ff_dither_init_x86(DitherDSPContext *ddsp,
- enum AVResampleDitherMethod method);
-
-#endif /* AVRESAMPLE_DITHER_H */
diff --git a/src/thirdparty/ffmpeg/libavresample/internal.h b/src/thirdparty/ffmpeg/libavresample/internal.h
deleted file mode 100644
index 057f89a49..000000000
--- a/src/thirdparty/ffmpeg/libavresample/internal.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVRESAMPLE_INTERNAL_H
-#define AVRESAMPLE_INTERNAL_H
-
-#include "libavutil/audio_fifo.h"
-#include "libavutil/log.h"
-#include "libavutil/opt.h"
-#include "libavutil/samplefmt.h"
-#include "avresample.h"
-
-typedef struct AudioData AudioData;
-typedef struct AudioConvert AudioConvert;
-typedef struct AudioMix AudioMix;
-typedef struct ResampleContext ResampleContext;
-
-enum RemapPoint {
- REMAP_NONE,
- REMAP_IN_COPY,
- REMAP_IN_CONVERT,
- REMAP_OUT_COPY,
- REMAP_OUT_CONVERT,
-};
-
-typedef struct ChannelMapInfo {
- int channel_map[AVRESAMPLE_MAX_CHANNELS]; /**< source index of each output channel, -1 if not remapped */
- int do_remap; /**< remap needed */
- int channel_copy[AVRESAMPLE_MAX_CHANNELS]; /**< dest index to copy from */
- int do_copy; /**< copy needed */
- int channel_zero[AVRESAMPLE_MAX_CHANNELS]; /**< dest index to zero */
- int do_zero; /**< zeroing needed */
- int input_map[AVRESAMPLE_MAX_CHANNELS]; /**< dest index of each input channel */
-} ChannelMapInfo;
-
-struct AVAudioResampleContext {
- const AVClass *av_class; /**< AVClass for logging and AVOptions */
-
- uint64_t in_channel_layout; /**< input channel layout */
- enum AVSampleFormat in_sample_fmt; /**< input sample format */
- int in_sample_rate; /**< input sample rate */
- uint64_t out_channel_layout; /**< output channel layout */
- enum AVSampleFormat out_sample_fmt; /**< output sample format */
- int out_sample_rate; /**< output sample rate */
- enum AVSampleFormat internal_sample_fmt; /**< internal sample format */
- enum AVMixCoeffType mix_coeff_type; /**< mixing coefficient type */
- double center_mix_level; /**< center mix level */
- double surround_mix_level; /**< surround mix level */
- double lfe_mix_level; /**< lfe mix level */
- int normalize_mix_level; /**< enable mix level normalization */
- int force_resampling; /**< force resampling */
- int filter_size; /**< length of each FIR filter in the resampling filterbank relative to the cutoff frequency */
- int phase_shift; /**< log2 of the number of entries in the resampling polyphase filterbank */
- int linear_interp; /**< if 1 then the resampling FIR filter will be linearly interpolated */
- double cutoff; /**< resampling cutoff frequency. 1.0 corresponds to half the output sample rate */
- enum AVResampleFilterType filter_type; /**< resampling filter type */
- int kaiser_beta; /**< beta value for Kaiser window (only applicable if filter_type == AV_FILTER_TYPE_KAISER) */
- enum AVResampleDitherMethod dither_method; /**< dither method */
-
- int in_channels; /**< number of input channels */
- int out_channels; /**< number of output channels */
- int resample_channels; /**< number of channels used for resampling */
- int downmix_needed; /**< downmixing is needed */
- int upmix_needed; /**< upmixing is needed */
- int mixing_needed; /**< either upmixing or downmixing is needed */
- int resample_needed; /**< resampling is needed */
- int in_convert_needed; /**< input sample format conversion is needed */
- int out_convert_needed; /**< output sample format conversion is needed */
- int in_copy_needed; /**< input data copy is needed */
-
- AudioData *in_buffer; /**< buffer for converted input */
- AudioData *resample_out_buffer; /**< buffer for output from resampler */
- AudioData *out_buffer; /**< buffer for converted output */
- AVAudioFifo *out_fifo; /**< FIFO for output samples */
-
- AudioConvert *ac_in; /**< input sample format conversion context */
- AudioConvert *ac_out; /**< output sample format conversion context */
- ResampleContext *resample; /**< resampling context */
- AudioMix *am; /**< channel mixing context */
- enum AVMatrixEncoding matrix_encoding; /**< matrixed stereo encoding */
-
- /**
- * mix matrix
- * only used if avresample_set_matrix() is called before avresample_open()
- */
- double *mix_matrix;
-
- int use_channel_map;
- enum RemapPoint remap_point;
- ChannelMapInfo ch_map_info;
-};
-
-#endif /* AVRESAMPLE_INTERNAL_H */
diff --git a/src/thirdparty/ffmpeg/libavresample/options.c b/src/thirdparty/ffmpeg/libavresample/options.c
deleted file mode 100644
index 68548f049..000000000
--- a/src/thirdparty/ffmpeg/libavresample/options.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/mathematics.h"
-#include "libavutil/mem.h"
-#include "libavutil/opt.h"
-#include "avresample.h"
-#include "internal.h"
-#include "audio_mix.h"
-
-/**
- * @file
- * Options definition for AVAudioResampleContext.
- */
-
-#define OFFSET(x) offsetof(AVAudioResampleContext, x)
-#define PARAM AV_OPT_FLAG_AUDIO_PARAM
-
-static const AVOption options[] = {
- { "in_channel_layout", "Input Channel Layout", OFFSET(in_channel_layout), AV_OPT_TYPE_INT64, { .i64 = 0 }, INT64_MIN, INT64_MAX, PARAM },
- { "in_sample_fmt", "Input Sample Format", OFFSET(in_sample_fmt), AV_OPT_TYPE_INT, { .i64 = AV_SAMPLE_FMT_S16 }, AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_NB-1, PARAM },
- { "in_sample_rate", "Input Sample Rate", OFFSET(in_sample_rate), AV_OPT_TYPE_INT, { .i64 = 48000 }, 1, INT_MAX, PARAM },
- { "out_channel_layout", "Output Channel Layout", OFFSET(out_channel_layout), AV_OPT_TYPE_INT64, { .i64 = 0 }, INT64_MIN, INT64_MAX, PARAM },
- { "out_sample_fmt", "Output Sample Format", OFFSET(out_sample_fmt), AV_OPT_TYPE_INT, { .i64 = AV_SAMPLE_FMT_S16 }, AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_NB-1, PARAM },
- { "out_sample_rate", "Output Sample Rate", OFFSET(out_sample_rate), AV_OPT_TYPE_INT, { .i64 = 48000 }, 1, INT_MAX, PARAM },
- { "internal_sample_fmt", "Internal Sample Format", OFFSET(internal_sample_fmt), AV_OPT_TYPE_INT, { .i64 = AV_SAMPLE_FMT_NONE }, AV_SAMPLE_FMT_NONE, AV_SAMPLE_FMT_NB-1, PARAM },
- { "mix_coeff_type", "Mixing Coefficient Type", OFFSET(mix_coeff_type), AV_OPT_TYPE_INT, { .i64 = AV_MIX_COEFF_TYPE_FLT }, AV_MIX_COEFF_TYPE_Q8, AV_MIX_COEFF_TYPE_NB-1, PARAM, "mix_coeff_type" },
- { "q8", "16-bit 8.8 Fixed-Point", 0, AV_OPT_TYPE_CONST, { .i64 = AV_MIX_COEFF_TYPE_Q8 }, INT_MIN, INT_MAX, PARAM, "mix_coeff_type" },
- { "q15", "32-bit 17.15 Fixed-Point", 0, AV_OPT_TYPE_CONST, { .i64 = AV_MIX_COEFF_TYPE_Q15 }, INT_MIN, INT_MAX, PARAM, "mix_coeff_type" },
- { "flt", "Floating-Point", 0, AV_OPT_TYPE_CONST, { .i64 = AV_MIX_COEFF_TYPE_FLT }, INT_MIN, INT_MAX, PARAM, "mix_coeff_type" },
- { "center_mix_level", "Center Mix Level", OFFSET(center_mix_level), AV_OPT_TYPE_DOUBLE, { .dbl = M_SQRT1_2 }, -32.0, 32.0, PARAM },
- { "surround_mix_level", "Surround Mix Level", OFFSET(surround_mix_level), AV_OPT_TYPE_DOUBLE, { .dbl = M_SQRT1_2 }, -32.0, 32.0, PARAM },
- { "lfe_mix_level", "LFE Mix Level", OFFSET(lfe_mix_level), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, -32.0, 32.0, PARAM },
- { "normalize_mix_level", "Normalize Mix Level", OFFSET(normalize_mix_level), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, PARAM },
- { "force_resampling", "Force Resampling", OFFSET(force_resampling), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, PARAM },
- { "filter_size", "Resampling Filter Size", OFFSET(filter_size), AV_OPT_TYPE_INT, { .i64 = 16 }, 0, 32, /* ??? */ PARAM },
- { "phase_shift", "Resampling Phase Shift", OFFSET(phase_shift), AV_OPT_TYPE_INT, { .i64 = 10 }, 0, 30, /* ??? */ PARAM },
- { "linear_interp", "Use Linear Interpolation", OFFSET(linear_interp), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, PARAM },
- { "cutoff", "Cutoff Frequency Ratio", OFFSET(cutoff), AV_OPT_TYPE_DOUBLE, { .dbl = 0.8 }, 0.0, 1.0, PARAM },
- { "matrix_encoding", "Matrixed Stereo Encoding", OFFSET(matrix_encoding), AV_OPT_TYPE_INT, {.i64 = AV_MATRIX_ENCODING_NONE}, AV_MATRIX_ENCODING_NONE, AV_MATRIX_ENCODING_NB-1, PARAM, "matrix_encoding" },
- { "none", "None", 0, AV_OPT_TYPE_CONST, { .i64 = AV_MATRIX_ENCODING_NONE }, INT_MIN, INT_MAX, PARAM, "matrix_encoding" },
- { "dolby", "Dolby", 0, AV_OPT_TYPE_CONST, { .i64 = AV_MATRIX_ENCODING_DOLBY }, INT_MIN, INT_MAX, PARAM, "matrix_encoding" },
- { "dplii", "Dolby Pro Logic II", 0, AV_OPT_TYPE_CONST, { .i64 = AV_MATRIX_ENCODING_DPLII }, INT_MIN, INT_MAX, PARAM, "matrix_encoding" },
- { "filter_type", "Filter Type", OFFSET(filter_type), AV_OPT_TYPE_INT, { .i64 = AV_RESAMPLE_FILTER_TYPE_KAISER }, AV_RESAMPLE_FILTER_TYPE_CUBIC, AV_RESAMPLE_FILTER_TYPE_KAISER, PARAM, "filter_type" },
- { "cubic", "Cubic", 0, AV_OPT_TYPE_CONST, { .i64 = AV_RESAMPLE_FILTER_TYPE_CUBIC }, INT_MIN, INT_MAX, PARAM, "filter_type" },
- { "blackman_nuttall", "Blackman Nuttall Windowed Sinc", 0, AV_OPT_TYPE_CONST, { .i64 = AV_RESAMPLE_FILTER_TYPE_BLACKMAN_NUTTALL }, INT_MIN, INT_MAX, PARAM, "filter_type" },
- { "kaiser", "Kaiser Windowed Sinc", 0, AV_OPT_TYPE_CONST, { .i64 = AV_RESAMPLE_FILTER_TYPE_KAISER }, INT_MIN, INT_MAX, PARAM, "filter_type" },
- { "kaiser_beta", "Kaiser Window Beta", OFFSET(kaiser_beta), AV_OPT_TYPE_INT, { .i64 = 9 }, 2, 16, PARAM },
- { "dither_method", "Dither Method", OFFSET(dither_method), AV_OPT_TYPE_INT, { .i64 = AV_RESAMPLE_DITHER_NONE }, 0, AV_RESAMPLE_DITHER_NB-1, PARAM, "dither_method"},
- {"none", "No Dithering", 0, AV_OPT_TYPE_CONST, { .i64 = AV_RESAMPLE_DITHER_NONE }, INT_MIN, INT_MAX, PARAM, "dither_method"},
- {"rectangular", "Rectangular Dither", 0, AV_OPT_TYPE_CONST, { .i64 = AV_RESAMPLE_DITHER_RECTANGULAR }, INT_MIN, INT_MAX, PARAM, "dither_method"},
- {"triangular", "Triangular Dither", 0, AV_OPT_TYPE_CONST, { .i64 = AV_RESAMPLE_DITHER_TRIANGULAR }, INT_MIN, INT_MAX, PARAM, "dither_method"},
- {"triangular_hp", "Triangular Dither With High Pass", 0, AV_OPT_TYPE_CONST, { .i64 = AV_RESAMPLE_DITHER_TRIANGULAR_HP }, INT_MIN, INT_MAX, PARAM, "dither_method"},
- {"triangular_ns", "Triangular Dither With Noise Shaping", 0, AV_OPT_TYPE_CONST, { .i64 = AV_RESAMPLE_DITHER_TRIANGULAR_NS }, INT_MIN, INT_MAX, PARAM, "dither_method"},
- { NULL },
-};
-
-static const AVClass av_resample_context_class = {
- .class_name = "AVAudioResampleContext",
- .item_name = av_default_item_name,
- .option = options,
- .version = LIBAVUTIL_VERSION_INT,
-};
-
-AVAudioResampleContext *avresample_alloc_context(void)
-{
- AVAudioResampleContext *avr;
-
- avr = av_mallocz(sizeof(*avr));
- if (!avr)
- return NULL;
-
- avr->av_class = &av_resample_context_class;
- av_opt_set_defaults(avr);
-
- return avr;
-}
-
-const AVClass *avresample_get_class(void)
-{
- return &av_resample_context_class;
-}
diff --git a/src/thirdparty/ffmpeg/libavresample/resample.c b/src/thirdparty/ffmpeg/libavresample/resample.c
deleted file mode 100644
index 69c9bab89..000000000
--- a/src/thirdparty/ffmpeg/libavresample/resample.c
+++ /dev/null
@@ -1,469 +0,0 @@
-/*
- * Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at>
- * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/common.h"
-#include "libavutil/libm.h"
-#include "libavutil/log.h"
-#include "internal.h"
-#include "resample.h"
-#include "audio_data.h"
-
-struct ResampleContext {
- AVAudioResampleContext *avr;
- AudioData *buffer;
- uint8_t *filter_bank;
- int filter_length;
- int ideal_dst_incr;
- int dst_incr;
- int index;
- int frac;
- int src_incr;
- int compensation_distance;
- int phase_shift;
- int phase_mask;
- int linear;
- enum AVResampleFilterType filter_type;
- int kaiser_beta;
- double factor;
- void (*set_filter)(void *filter, double *tab, int phase, int tap_count);
- void (*resample_one)(struct ResampleContext *c, int no_filter, void *dst0,
- int dst_index, const void *src0, int src_size,
- int index, int frac);
-};
-
-
-/* double template */
-#define CONFIG_RESAMPLE_DBL
-#include "resample_template.c"
-#undef CONFIG_RESAMPLE_DBL
-
-/* float template */
-#define CONFIG_RESAMPLE_FLT
-#include "resample_template.c"
-#undef CONFIG_RESAMPLE_FLT
-
-/* s32 template */
-#define CONFIG_RESAMPLE_S32
-#include "resample_template.c"
-#undef CONFIG_RESAMPLE_S32
-
-/* s16 template */
-#include "resample_template.c"
-
-
-/* 0th order modified bessel function of the first kind. */
-static double bessel(double x)
-{
- double v = 1;
- double lastv = 0;
- double t = 1;
- int i;
-
- x = x * x / 4;
- for (i = 1; v != lastv; i++) {
- lastv = v;
- t *= x / (i * i);
- v += t;
- }
- return v;
-}
-
-/* Build a polyphase filterbank. */
-static int build_filter(ResampleContext *c)
-{
- int ph, i;
- double x, y, w, factor;
- double *tab;
- int tap_count = c->filter_length;
- int phase_count = 1 << c->phase_shift;
- const int center = (tap_count - 1) / 2;
-
- tab = av_malloc(tap_count * sizeof(*tab));
- if (!tab)
- return AVERROR(ENOMEM);
-
- /* if upsampling, only need to interpolate, no filter */
- factor = FFMIN(c->factor, 1.0);
-
- for (ph = 0; ph < phase_count; ph++) {
- double norm = 0;
- for (i = 0; i < tap_count; i++) {
- x = M_PI * ((double)(i - center) - (double)ph / phase_count) * factor;
- if (x == 0) y = 1.0;
- else y = sin(x) / x;
- switch (c->filter_type) {
- case AV_RESAMPLE_FILTER_TYPE_CUBIC: {
- const float d = -0.5; //first order derivative = -0.5
- x = fabs(((double)(i - center) - (double)ph / phase_count) * factor);
- if (x < 1.0) y = 1 - 3 * x*x + 2 * x*x*x + d * ( -x*x + x*x*x);
- else y = d * (-4 + 8 * x - 5 * x*x + x*x*x);
- break;
- }
- case AV_RESAMPLE_FILTER_TYPE_BLACKMAN_NUTTALL:
- w = 2.0 * x / (factor * tap_count) + M_PI;
- y *= 0.3635819 - 0.4891775 * cos( w) +
- 0.1365995 * cos(2 * w) -
- 0.0106411 * cos(3 * w);
- break;
- case AV_RESAMPLE_FILTER_TYPE_KAISER:
- w = 2.0 * x / (factor * tap_count * M_PI);
- y *= bessel(c->kaiser_beta * sqrt(FFMAX(1 - w * w, 0)));
- break;
- }
-
- tab[i] = y;
- norm += y;
- }
- /* normalize so that an uniform color remains the same */
- for (i = 0; i < tap_count; i++)
- tab[i] = tab[i] / norm;
-
- c->set_filter(c->filter_bank, tab, ph, tap_count);
- }
-
- av_free(tab);
- return 0;
-}
-
-ResampleContext *ff_audio_resample_init(AVAudioResampleContext *avr)
-{
- ResampleContext *c;
- int out_rate = avr->out_sample_rate;
- int in_rate = avr->in_sample_rate;
- double factor = FFMIN(out_rate * avr->cutoff / in_rate, 1.0);
- int phase_count = 1 << avr->phase_shift;
- int felem_size;
-
- if (avr->internal_sample_fmt != AV_SAMPLE_FMT_S16P &&
- avr->internal_sample_fmt != AV_SAMPLE_FMT_S32P &&
- avr->internal_sample_fmt != AV_SAMPLE_FMT_FLTP &&
- avr->internal_sample_fmt != AV_SAMPLE_FMT_DBLP) {
- av_log(avr, AV_LOG_ERROR, "Unsupported internal format for "
- "resampling: %s\n",
- av_get_sample_fmt_name(avr->internal_sample_fmt));
- return NULL;
- }
- c = av_mallocz(sizeof(*c));
- if (!c)
- return NULL;
-
- c->avr = avr;
- c->phase_shift = avr->phase_shift;
- c->phase_mask = phase_count - 1;
- c->linear = avr->linear_interp;
- c->factor = factor;
- c->filter_length = FFMAX((int)ceil(avr->filter_size / factor), 1);
- c->filter_type = avr->filter_type;
- c->kaiser_beta = avr->kaiser_beta;
-
- switch (avr->internal_sample_fmt) {
- case AV_SAMPLE_FMT_DBLP:
- c->resample_one = resample_one_dbl;
- c->set_filter = set_filter_dbl;
- break;
- case AV_SAMPLE_FMT_FLTP:
- c->resample_one = resample_one_flt;
- c->set_filter = set_filter_flt;
- break;
- case AV_SAMPLE_FMT_S32P:
- c->resample_one = resample_one_s32;
- c->set_filter = set_filter_s32;
- break;
- case AV_SAMPLE_FMT_S16P:
- c->resample_one = resample_one_s16;
- c->set_filter = set_filter_s16;
- break;
- }
-
- felem_size = av_get_bytes_per_sample(avr->internal_sample_fmt);
- c->filter_bank = av_mallocz(c->filter_length * (phase_count + 1) * felem_size);
- if (!c->filter_bank)
- goto error;
-
- if (build_filter(c) < 0)
- goto error;
-
- memcpy(&c->filter_bank[(c->filter_length * phase_count + 1) * felem_size],
- c->filter_bank, (c->filter_length - 1) * felem_size);
- memcpy(&c->filter_bank[c->filter_length * phase_count * felem_size],
- &c->filter_bank[(c->filter_length - 1) * felem_size], felem_size);
-
- c->compensation_distance = 0;
- if (!av_reduce(&c->src_incr, &c->dst_incr, out_rate,
- in_rate * (int64_t)phase_count, INT32_MAX / 2))
- goto error;
- c->ideal_dst_incr = c->dst_incr;
-
- c->index = -phase_count * ((c->filter_length - 1) / 2);
- c->frac = 0;
-
- /* allocate internal buffer */
- c->buffer = ff_audio_data_alloc(avr->resample_channels, 0,
- avr->internal_sample_fmt,
- "resample buffer");
- if (!c->buffer)
- goto error;
-
- av_log(avr, AV_LOG_DEBUG, "resample: %s from %d Hz to %d Hz\n",
- av_get_sample_fmt_name(avr->internal_sample_fmt),
- avr->in_sample_rate, avr->out_sample_rate);
-
- return c;
-
-error:
- ff_audio_data_free(&c->buffer);
- av_free(c->filter_bank);
- av_free(c);
- return NULL;
-}
-
-void ff_audio_resample_free(ResampleContext **c)
-{
- if (!*c)
- return;
- ff_audio_data_free(&(*c)->buffer);
- av_free((*c)->filter_bank);
- av_freep(c);
-}
-
-int avresample_set_compensation(AVAudioResampleContext *avr, int sample_delta,
- int compensation_distance)
-{
- ResampleContext *c;
- AudioData *fifo_buf = NULL;
- int ret = 0;
-
- if (compensation_distance < 0)
- return AVERROR(EINVAL);
- if (!compensation_distance && sample_delta)
- return AVERROR(EINVAL);
-
- if (!avr->resample_needed) {
-#if FF_API_RESAMPLE_CLOSE_OPEN
- /* if resampling was not enabled previously, re-initialize the
- AVAudioResampleContext and force resampling */
- int fifo_samples;
- int restore_matrix = 0;
- double matrix[AVRESAMPLE_MAX_CHANNELS * AVRESAMPLE_MAX_CHANNELS] = { 0 };
-
- /* buffer any remaining samples in the output FIFO before closing */
- fifo_samples = av_audio_fifo_size(avr->out_fifo);
- if (fifo_samples > 0) {
- fifo_buf = ff_audio_data_alloc(avr->out_channels, fifo_samples,
- avr->out_sample_fmt, NULL);
- if (!fifo_buf)
- return AVERROR(EINVAL);
- ret = ff_audio_data_read_from_fifo(avr->out_fifo, fifo_buf,
- fifo_samples);
- if (ret < 0)
- goto reinit_fail;
- }
- /* save the channel mixing matrix */
- if (avr->am) {
- ret = avresample_get_matrix(avr, matrix, AVRESAMPLE_MAX_CHANNELS);
- if (ret < 0)
- goto reinit_fail;
- restore_matrix = 1;
- }
-
- /* close the AVAudioResampleContext */
- avresample_close(avr);
-
- avr->force_resampling = 1;
-
- /* restore the channel mixing matrix */
- if (restore_matrix) {
- ret = avresample_set_matrix(avr, matrix, AVRESAMPLE_MAX_CHANNELS);
- if (ret < 0)
- goto reinit_fail;
- }
-
- /* re-open the AVAudioResampleContext */
- ret = avresample_open(avr);
- if (ret < 0)
- goto reinit_fail;
-
- /* restore buffered samples to the output FIFO */
- if (fifo_samples > 0) {
- ret = ff_audio_data_add_to_fifo(avr->out_fifo, fifo_buf, 0,
- fifo_samples);
- if (ret < 0)
- goto reinit_fail;
- ff_audio_data_free(&fifo_buf);
- }
-#else
- av_log(avr, AV_LOG_ERROR, "Unable to set resampling compensation\n");
- return AVERROR(EINVAL);
-#endif
- }
- c = avr->resample;
- c->compensation_distance = compensation_distance;
- if (compensation_distance) {
- c->dst_incr = c->ideal_dst_incr - c->ideal_dst_incr *
- (int64_t)sample_delta / compensation_distance;
- } else {
- c->dst_incr = c->ideal_dst_incr;
- }
- return 0;
-
-reinit_fail:
- ff_audio_data_free(&fifo_buf);
- return ret;
-}
-
-static int resample(ResampleContext *c, void *dst, const void *src,
- int *consumed, int src_size, int dst_size, int update_ctx)
-{
- int dst_index;
- int index = c->index;
- int frac = c->frac;
- int dst_incr_frac = c->dst_incr % c->src_incr;
- int dst_incr = c->dst_incr / c->src_incr;
- int compensation_distance = c->compensation_distance;
-
- if (!dst != !src)
- return AVERROR(EINVAL);
-
- if (compensation_distance == 0 && c->filter_length == 1 &&
- c->phase_shift == 0) {
- int64_t index2 = ((int64_t)index) << 32;
- int64_t incr = (1LL << 32) * c->dst_incr / c->src_incr;
- dst_size = FFMIN(dst_size,
- (src_size-1-index) * (int64_t)c->src_incr /
- c->dst_incr);
-
- if (dst) {
- for(dst_index = 0; dst_index < dst_size; dst_index++) {
- c->resample_one(c, 1, dst, dst_index, src, 0, index2 >> 32, 0);
- index2 += incr;
- }
- } else {
- dst_index = dst_size;
- }
- index += dst_index * dst_incr;
- index += (frac + dst_index * (int64_t)dst_incr_frac) / c->src_incr;
- frac = (frac + dst_index * (int64_t)dst_incr_frac) % c->src_incr;
- } else {
- for (dst_index = 0; dst_index < dst_size; dst_index++) {
- int sample_index = index >> c->phase_shift;
-
- if (sample_index + c->filter_length > src_size ||
- -sample_index >= src_size)
- break;
-
- if (dst)
- c->resample_one(c, 0, dst, dst_index, src, src_size, index, frac);
-
- frac += dst_incr_frac;
- index += dst_incr;
- if (frac >= c->src_incr) {
- frac -= c->src_incr;
- index++;
- }
- if (dst_index + 1 == compensation_distance) {
- compensation_distance = 0;
- dst_incr_frac = c->ideal_dst_incr % c->src_incr;
- dst_incr = c->ideal_dst_incr / c->src_incr;
- }
- }
- }
- if (consumed)
- *consumed = FFMAX(index, 0) >> c->phase_shift;
-
- if (update_ctx) {
- if (index >= 0)
- index &= c->phase_mask;
-
- if (compensation_distance) {
- compensation_distance -= dst_index;
- if (compensation_distance <= 0)
- return AVERROR_BUG;
- }
- c->frac = frac;
- c->index = index;
- c->dst_incr = dst_incr_frac + c->src_incr*dst_incr;
- c->compensation_distance = compensation_distance;
- }
-
- return dst_index;
-}
-
-int ff_audio_resample(ResampleContext *c, AudioData *dst, AudioData *src)
-{
- int ch, in_samples, in_leftover, consumed = 0, out_samples = 0;
- int ret = AVERROR(EINVAL);
-
- in_samples = src ? src->nb_samples : 0;
- in_leftover = c->buffer->nb_samples;
-
- /* add input samples to the internal buffer */
- if (src) {
- ret = ff_audio_data_combine(c->buffer, in_leftover, src, 0, in_samples);
- if (ret < 0)
- return ret;
- } else if (!in_leftover) {
- /* no remaining samples to flush */
- return 0;
- } else {
- /* TODO: pad buffer to flush completely */
- }
-
- /* calculate output size and reallocate output buffer if needed */
- /* TODO: try to calculate this without the dummy resample() run */
- if (!dst->read_only && dst->allow_realloc) {
- out_samples = resample(c, NULL, NULL, NULL, c->buffer->nb_samples,
- INT_MAX, 0);
- ret = ff_audio_data_realloc(dst, out_samples);
- if (ret < 0) {
- av_log(c->avr, AV_LOG_ERROR, "error reallocating output\n");
- return ret;
- }
- }
-
- /* resample each channel plane */
- for (ch = 0; ch < c->buffer->channels; ch++) {
- out_samples = resample(c, (void *)dst->data[ch],
- (const void *)c->buffer->data[ch], &consumed,
- c->buffer->nb_samples, dst->allocated_samples,
- ch + 1 == c->buffer->channels);
- }
- if (out_samples < 0) {
- av_log(c->avr, AV_LOG_ERROR, "error during resampling\n");
- return out_samples;
- }
-
- /* drain consumed samples from the internal buffer */
- ff_audio_data_drain(c->buffer, consumed);
-
- av_dlog(c->avr, "resampled %d in + %d leftover to %d out + %d leftover\n",
- in_samples, in_leftover, out_samples, c->buffer->nb_samples);
-
- dst->nb_samples = out_samples;
- return 0;
-}
-
-int avresample_get_delay(AVAudioResampleContext *avr)
-{
- if (!avr->resample_needed || !avr->resample)
- return 0;
-
- return avr->resample->buffer->nb_samples;
-}
diff --git a/src/thirdparty/ffmpeg/libavresample/resample.h b/src/thirdparty/ffmpeg/libavresample/resample.h
deleted file mode 100644
index 4544dab92..000000000
--- a/src/thirdparty/ffmpeg/libavresample/resample.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVRESAMPLE_RESAMPLE_H
-#define AVRESAMPLE_RESAMPLE_H
-
-#include "avresample.h"
-#include "internal.h"
-#include "audio_data.h"
-
-/**
- * Allocate and initialize a ResampleContext.
- *
- * The parameters in the AVAudioResampleContext are used to initialize the
- * ResampleContext.
- *
- * @param avr AVAudioResampleContext
- * @return newly-allocated ResampleContext
- */
-ResampleContext *ff_audio_resample_init(AVAudioResampleContext *avr);
-
-/**
- * Free a ResampleContext.
- *
- * @param c ResampleContext
- */
-void ff_audio_resample_free(ResampleContext **c);
-
-/**
- * Resample audio data.
- *
- * Changes the sample rate.
- *
- * @par
- * All samples in the source data may not be consumed depending on the
- * resampling parameters and the size of the output buffer. The unconsumed
- * samples are automatically added to the start of the source in the next call.
- * If the destination data can be reallocated, that may be done in this function
- * in order to fit all available output. If it cannot be reallocated, fewer
- * input samples will be consumed in order to have the output fit in the
- * destination data buffers.
- *
- * @param c ResampleContext
- * @param dst destination audio data
- * @param src source audio data
- * @return 0 on success, negative AVERROR code on failure
- */
-int ff_audio_resample(ResampleContext *c, AudioData *dst, AudioData *src);
-
-#endif /* AVRESAMPLE_RESAMPLE_H */
diff --git a/src/thirdparty/ffmpeg/libavresample/resample_template.c b/src/thirdparty/ffmpeg/libavresample/resample_template.c
deleted file mode 100644
index 06da90fe9..000000000
--- a/src/thirdparty/ffmpeg/libavresample/resample_template.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2004 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
- */
-
-#if defined(CONFIG_RESAMPLE_DBL)
-#define SET_TYPE(func) func ## _dbl
-#define FELEM double
-#define FELEM2 double
-#define FELEML double
-#define OUT(d, v) d = v
-#define DBL_TO_FELEM(d, v) d = v
-#elif defined(CONFIG_RESAMPLE_FLT)
-#define SET_TYPE(func) func ## _flt
-#define FELEM float
-#define FELEM2 float
-#define FELEML float
-#define OUT(d, v) d = v
-#define DBL_TO_FELEM(d, v) d = v
-#elif defined(CONFIG_RESAMPLE_S32)
-#define SET_TYPE(func) func ## _s32
-#define FELEM int32_t
-#define FELEM2 int64_t
-#define FELEML int64_t
-#define OUT(d, v) d = av_clipl_int32((v + (1 << 29)) >> 30)
-#define DBL_TO_FELEM(d, v) d = av_clipl_int32(llrint(v * (1 << 30)));
-#else
-#define SET_TYPE(func) func ## _s16
-#define FELEM int16_t
-#define FELEM2 int32_t
-#define FELEML int64_t
-#define OUT(d, v) d = av_clip_int16((v + (1 << 14)) >> 15)
-#define DBL_TO_FELEM(d, v) d = av_clip_int16(lrint(v * (1 << 15)))
-#endif
-
-static void SET_TYPE(resample_one)(ResampleContext *c, int no_filter,
- void *dst0, int dst_index, const void *src0,
- int src_size, int index, int frac)
-{
- FELEM *dst = dst0;
- const FELEM *src = src0;
-
- if (no_filter) {
- dst[dst_index] = src[index];
- } else {
- int i;
- int sample_index = index >> c->phase_shift;
- FELEM2 val = 0;
- FELEM *filter = ((FELEM *)c->filter_bank) +
- c->filter_length * (index & c->phase_mask);
-
- if (sample_index < 0) {
- for (i = 0; i < c->filter_length; i++)
- val += src[FFABS(sample_index + i) % src_size] *
- (FELEM2)filter[i];
- } else if (c->linear) {
- FELEM2 v2 = 0;
- for (i = 0; i < c->filter_length; i++) {
- val += src[abs(sample_index + i)] * (FELEM2)filter[i];
- v2 += src[abs(sample_index + i)] * (FELEM2)filter[i + c->filter_length];
- }
- val += (v2 - val) * (FELEML)frac / c->src_incr;
- } else {
- for (i = 0; i < c->filter_length; i++)
- val += src[sample_index + i] * (FELEM2)filter[i];
- }
-
- OUT(dst[dst_index], val);
- }
-}
-
-static void SET_TYPE(set_filter)(void *filter0, double *tab, int phase,
- int tap_count)
-{
- int i;
- FELEM *filter = ((FELEM *)filter0) + phase * tap_count;
- for (i = 0; i < tap_count; i++) {
- DBL_TO_FELEM(filter[i], tab[i]);
- }
-}
-
-#undef SET_TYPE
-#undef FELEM
-#undef FELEM2
-#undef FELEML
-#undef OUT
-#undef DBL_TO_FELEM
diff --git a/src/thirdparty/ffmpeg/libavresample/utils.c b/src/thirdparty/ffmpeg/libavresample/utils.c
deleted file mode 100644
index c159e3320..000000000
--- a/src/thirdparty/ffmpeg/libavresample/utils.c
+++ /dev/null
@@ -1,635 +0,0 @@
-/*
- * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/common.h"
-#include "libavutil/dict.h"
-// #include "libavutil/error.h"
-#include "libavutil/log.h"
-#include "libavutil/mem.h"
-#include "libavutil/opt.h"
-
-#include "avresample.h"
-#include "internal.h"
-#include "audio_data.h"
-#include "audio_convert.h"
-#include "audio_mix.h"
-#include "resample.h"
-
-int avresample_open(AVAudioResampleContext *avr)
-{
- int ret;
-
- /* set channel mixing parameters */
- avr->in_channels = av_get_channel_layout_nb_channels(avr->in_channel_layout);
- if (avr->in_channels <= 0 || avr->in_channels > AVRESAMPLE_MAX_CHANNELS) {
- av_log(avr, AV_LOG_ERROR, "Invalid input channel layout: %"PRIu64"\n",
- avr->in_channel_layout);
- return AVERROR(EINVAL);
- }
- avr->out_channels = av_get_channel_layout_nb_channels(avr->out_channel_layout);
- if (avr->out_channels <= 0 || avr->out_channels > AVRESAMPLE_MAX_CHANNELS) {
- av_log(avr, AV_LOG_ERROR, "Invalid output channel layout: %"PRIu64"\n",
- avr->out_channel_layout);
- return AVERROR(EINVAL);
- }
- avr->resample_channels = FFMIN(avr->in_channels, avr->out_channels);
- avr->downmix_needed = avr->in_channels > avr->out_channels;
- avr->upmix_needed = avr->out_channels > avr->in_channels ||
- (!avr->downmix_needed && (avr->mix_matrix ||
- avr->in_channel_layout != avr->out_channel_layout));
- avr->mixing_needed = avr->downmix_needed || avr->upmix_needed;
-
- /* set resampling parameters */
- avr->resample_needed = avr->in_sample_rate != avr->out_sample_rate ||
- avr->force_resampling;
-
- /* select internal sample format if not specified by the user */
- if (avr->internal_sample_fmt == AV_SAMPLE_FMT_NONE &&
- (avr->mixing_needed || avr->resample_needed)) {
- enum AVSampleFormat in_fmt = av_get_planar_sample_fmt(avr->in_sample_fmt);
- enum AVSampleFormat out_fmt = av_get_planar_sample_fmt(avr->out_sample_fmt);
- int max_bps = FFMAX(av_get_bytes_per_sample(in_fmt),
- av_get_bytes_per_sample(out_fmt));
- if (max_bps <= 2) {
- avr->internal_sample_fmt = AV_SAMPLE_FMT_S16P;
- } else if (avr->mixing_needed) {
- avr->internal_sample_fmt = AV_SAMPLE_FMT_FLTP;
- } else {
- if (max_bps <= 4) {
- if (in_fmt == AV_SAMPLE_FMT_S32P ||
- out_fmt == AV_SAMPLE_FMT_S32P) {
- if (in_fmt == AV_SAMPLE_FMT_FLTP ||
- out_fmt == AV_SAMPLE_FMT_FLTP) {
- /* if one is s32 and the other is flt, use dbl */
- avr->internal_sample_fmt = AV_SAMPLE_FMT_DBLP;
- } else {
- /* if one is s32 and the other is s32, s16, or u8, use s32 */
- avr->internal_sample_fmt = AV_SAMPLE_FMT_S32P;
- }
- } else {
- /* if one is flt and the other is flt, s16 or u8, use flt */
- avr->internal_sample_fmt = AV_SAMPLE_FMT_FLTP;
- }
- } else {
- /* if either is dbl, use dbl */
- avr->internal_sample_fmt = AV_SAMPLE_FMT_DBLP;
- }
- }
- av_log(avr, AV_LOG_DEBUG, "Using %s as internal sample format\n",
- av_get_sample_fmt_name(avr->internal_sample_fmt));
- }
-
- /* treat all mono as planar for easier comparison */
- if (avr->in_channels == 1)
- avr->in_sample_fmt = av_get_planar_sample_fmt(avr->in_sample_fmt);
- if (avr->out_channels == 1)
- avr->out_sample_fmt = av_get_planar_sample_fmt(avr->out_sample_fmt);
-
- /* we may need to add an extra conversion in order to remap channels if
- the output format is not planar */
- if (avr->use_channel_map && !avr->mixing_needed && !avr->resample_needed &&
- !av_sample_fmt_is_planar(avr->out_sample_fmt)) {
- avr->internal_sample_fmt = av_get_planar_sample_fmt(avr->out_sample_fmt);
- }
-
- /* set sample format conversion parameters */
- if (avr->resample_needed || avr->mixing_needed)
- avr->in_convert_needed = avr->in_sample_fmt != avr->internal_sample_fmt;
- else
- avr->in_convert_needed = avr->use_channel_map &&
- !av_sample_fmt_is_planar(avr->out_sample_fmt);
-
- if (avr->resample_needed || avr->mixing_needed || avr->in_convert_needed)
- avr->out_convert_needed = avr->internal_sample_fmt != avr->out_sample_fmt;
- else
- avr->out_convert_needed = avr->in_sample_fmt != avr->out_sample_fmt;
-
- avr->in_copy_needed = !avr->in_convert_needed && (avr->mixing_needed ||
- (avr->use_channel_map && avr->resample_needed));
-
- if (avr->use_channel_map) {
- if (avr->in_copy_needed) {
- avr->remap_point = REMAP_IN_COPY;
- av_dlog(avr, "remap channels during in_copy\n");
- } else if (avr->in_convert_needed) {
- avr->remap_point = REMAP_IN_CONVERT;
- av_dlog(avr, "remap channels during in_convert\n");
- } else if (avr->out_convert_needed) {
- avr->remap_point = REMAP_OUT_CONVERT;
- av_dlog(avr, "remap channels during out_convert\n");
- } else {
- avr->remap_point = REMAP_OUT_COPY;
- av_dlog(avr, "remap channels during out_copy\n");
- }
-
-#ifdef DEBUG
- {
- int ch;
- av_dlog(avr, "output map: ");
- if (avr->ch_map_info.do_remap)
- for (ch = 0; ch < avr->in_channels; ch++)
- av_dlog(avr, " % 2d", avr->ch_map_info.channel_map[ch]);
- else
- av_dlog(avr, "n/a");
- av_dlog(avr, "\n");
- av_dlog(avr, "copy map: ");
- if (avr->ch_map_info.do_copy)
- for (ch = 0; ch < avr->in_channels; ch++)
- av_dlog(avr, " % 2d", avr->ch_map_info.channel_copy[ch]);
- else
- av_dlog(avr, "n/a");
- av_dlog(avr, "\n");
- av_dlog(avr, "zero map: ");
- if (avr->ch_map_info.do_zero)
- for (ch = 0; ch < avr->in_channels; ch++)
- av_dlog(avr, " % 2d", avr->ch_map_info.channel_zero[ch]);
- else
- av_dlog(avr, "n/a");
- av_dlog(avr, "\n");
- av_dlog(avr, "input map: ");
- for (ch = 0; ch < avr->in_channels; ch++)
- av_dlog(avr, " % 2d", avr->ch_map_info.input_map[ch]);
- av_dlog(avr, "\n");
- }
-#endif
- } else
- avr->remap_point = REMAP_NONE;
-
- /* allocate buffers */
- if (avr->in_copy_needed || avr->in_convert_needed) {
- avr->in_buffer = ff_audio_data_alloc(FFMAX(avr->in_channels, avr->out_channels),
- 0, avr->internal_sample_fmt,
- "in_buffer");
- if (!avr->in_buffer) {
- ret = AVERROR(EINVAL);
- goto error;
- }
- }
- if (avr->resample_needed) {
- avr->resample_out_buffer = ff_audio_data_alloc(avr->out_channels,
- 0, avr->internal_sample_fmt,
- "resample_out_buffer");
- if (!avr->resample_out_buffer) {
- ret = AVERROR(EINVAL);
- goto error;
- }
- }
- if (avr->out_convert_needed) {
- avr->out_buffer = ff_audio_data_alloc(avr->out_channels, 0,
- avr->out_sample_fmt, "out_buffer");
- if (!avr->out_buffer) {
- ret = AVERROR(EINVAL);
- goto error;
- }
- }
- avr->out_fifo = av_audio_fifo_alloc(avr->out_sample_fmt, avr->out_channels,
- 1024);
- if (!avr->out_fifo) {
- ret = AVERROR(ENOMEM);
- goto error;
- }
-
- /* setup contexts */
- if (avr->in_convert_needed) {
- avr->ac_in = ff_audio_convert_alloc(avr, avr->internal_sample_fmt,
- avr->in_sample_fmt, avr->in_channels,
- avr->in_sample_rate,
- avr->remap_point == REMAP_IN_CONVERT);
- if (!avr->ac_in) {
- ret = AVERROR(ENOMEM);
- goto error;
- }
- }
- if (avr->out_convert_needed) {
- enum AVSampleFormat src_fmt;
- if (avr->in_convert_needed)
- src_fmt = avr->internal_sample_fmt;
- else
- src_fmt = avr->in_sample_fmt;
- avr->ac_out = ff_audio_convert_alloc(avr, avr->out_sample_fmt, src_fmt,
- avr->out_channels,
- avr->out_sample_rate,
- avr->remap_point == REMAP_OUT_CONVERT);
- if (!avr->ac_out) {
- ret = AVERROR(ENOMEM);
- goto error;
- }
- }
- if (avr->resample_needed) {
- avr->resample = ff_audio_resample_init(avr);
- if (!avr->resample) {
- ret = AVERROR(ENOMEM);
- goto error;
- }
- }
- if (avr->mixing_needed) {
- avr->am = ff_audio_mix_alloc(avr);
- if (!avr->am) {
- ret = AVERROR(ENOMEM);
- goto error;
- }
- }
-
- return 0;
-
-error:
- avresample_close(avr);
- return ret;
-}
-
-void avresample_close(AVAudioResampleContext *avr)
-{
- ff_audio_data_free(&avr->in_buffer);
- ff_audio_data_free(&avr->resample_out_buffer);
- ff_audio_data_free(&avr->out_buffer);
- av_audio_fifo_free(avr->out_fifo);
- avr->out_fifo = NULL;
- ff_audio_convert_free(&avr->ac_in);
- ff_audio_convert_free(&avr->ac_out);
- ff_audio_resample_free(&avr->resample);
- ff_audio_mix_free(&avr->am);
- av_freep(&avr->mix_matrix);
-
- avr->use_channel_map = 0;
-}
-
-void avresample_free(AVAudioResampleContext **avr)
-{
- if (!*avr)
- return;
- avresample_close(*avr);
- av_opt_free(*avr);
- av_freep(avr);
-}
-
-static int handle_buffered_output(AVAudioResampleContext *avr,
- AudioData *output, AudioData *converted)
-{
- int ret;
-
- if (!output || av_audio_fifo_size(avr->out_fifo) > 0 ||
- (converted && output->allocated_samples < converted->nb_samples)) {
- if (converted) {
- /* if there are any samples in the output FIFO or if the
- user-supplied output buffer is not large enough for all samples,
- we add to the output FIFO */
- av_dlog(avr, "[FIFO] add %s to out_fifo\n", converted->name);
- ret = ff_audio_data_add_to_fifo(avr->out_fifo, converted, 0,
- converted->nb_samples);
- if (ret < 0)
- return ret;
- }
-
- /* if the user specified an output buffer, read samples from the output
- FIFO to the user output */
- if (output && output->allocated_samples > 0) {
- av_dlog(avr, "[FIFO] read from out_fifo to output\n");
- av_dlog(avr, "[end conversion]\n");
- return ff_audio_data_read_from_fifo(avr->out_fifo, output,
- output->allocated_samples);
- }
- } else if (converted) {
- /* copy directly to output if it is large enough or there is not any
- data in the output FIFO */
- av_dlog(avr, "[copy] %s to output\n", converted->name);
- output->nb_samples = 0;
- ret = ff_audio_data_copy(output, converted,
- avr->remap_point == REMAP_OUT_COPY ?
- &avr->ch_map_info : NULL);
- if (ret < 0)
- return ret;
- av_dlog(avr, "[end conversion]\n");
- return output->nb_samples;
- }
- av_dlog(avr, "[end conversion]\n");
- return 0;
-}
-
-int attribute_align_arg avresample_convert(AVAudioResampleContext *avr,
- uint8_t **output, int out_plane_size,
- int out_samples, uint8_t **input,
- int in_plane_size, int in_samples)
-{
- AudioData input_buffer;
- AudioData output_buffer;
- AudioData *current_buffer;
- int ret, direct_output;
-
- /* reset internal buffers */
- if (avr->in_buffer) {
- avr->in_buffer->nb_samples = 0;
- ff_audio_data_set_channels(avr->in_buffer,
- avr->in_buffer->allocated_channels);
- }
- if (avr->resample_out_buffer) {
- avr->resample_out_buffer->nb_samples = 0;
- ff_audio_data_set_channels(avr->resample_out_buffer,
- avr->resample_out_buffer->allocated_channels);
- }
- if (avr->out_buffer) {
- avr->out_buffer->nb_samples = 0;
- ff_audio_data_set_channels(avr->out_buffer,
- avr->out_buffer->allocated_channels);
- }
-
- av_dlog(avr, "[start conversion]\n");
-
- /* initialize output_buffer with output data */
- direct_output = output && av_audio_fifo_size(avr->out_fifo) == 0;
- if (output) {
- ret = ff_audio_data_init(&output_buffer, output, out_plane_size,
- avr->out_channels, out_samples,
- avr->out_sample_fmt, 0, "output");
- if (ret < 0)
- return ret;
- output_buffer.nb_samples = 0;
- }
-
- if (input) {
- /* initialize input_buffer with input data */
- ret = ff_audio_data_init(&input_buffer, input, in_plane_size,
- avr->in_channels, in_samples,
- avr->in_sample_fmt, 1, "input");
- if (ret < 0)
- return ret;
- current_buffer = &input_buffer;
-
- if (avr->upmix_needed && !avr->in_convert_needed && !avr->resample_needed &&
- !avr->out_convert_needed && direct_output && out_samples >= in_samples) {
- /* in some rare cases we can copy input to output and upmix
- directly in the output buffer */
- av_dlog(avr, "[copy] %s to output\n", current_buffer->name);
- ret = ff_audio_data_copy(&output_buffer, current_buffer,
- avr->remap_point == REMAP_OUT_COPY ?
- &avr->ch_map_info : NULL);
- if (ret < 0)
- return ret;
- current_buffer = &output_buffer;
- } else if (avr->remap_point == REMAP_OUT_COPY &&
- (!direct_output || out_samples < in_samples)) {
- /* if remapping channels during output copy, we may need to
- * use an intermediate buffer in order to remap before adding
- * samples to the output fifo */
- av_dlog(avr, "[copy] %s to out_buffer\n", current_buffer->name);
- ret = ff_audio_data_copy(avr->out_buffer, current_buffer,
- &avr->ch_map_info);
- if (ret < 0)
- return ret;
- current_buffer = avr->out_buffer;
- } else if (avr->in_copy_needed || avr->in_convert_needed) {
- /* if needed, copy or convert input to in_buffer, and downmix if
- applicable */
- if (avr->in_convert_needed) {
- ret = ff_audio_data_realloc(avr->in_buffer,
- current_buffer->nb_samples);
- if (ret < 0)
- return ret;
- av_dlog(avr, "[convert] %s to in_buffer\n", current_buffer->name);
- ret = ff_audio_convert(avr->ac_in, avr->in_buffer,
- current_buffer);
- if (ret < 0)
- return ret;
- } else {
- av_dlog(avr, "[copy] %s to in_buffer\n", current_buffer->name);
- ret = ff_audio_data_copy(avr->in_buffer, current_buffer,
- avr->remap_point == REMAP_IN_COPY ?
- &avr->ch_map_info : NULL);
- if (ret < 0)
- return ret;
- }
- ff_audio_data_set_channels(avr->in_buffer, avr->in_channels);
- if (avr->downmix_needed) {
- av_dlog(avr, "[downmix] in_buffer\n");
- ret = ff_audio_mix(avr->am, avr->in_buffer);
- if (ret < 0)
- return ret;
- }
- current_buffer = avr->in_buffer;
- }
- } else {
- /* flush resampling buffer and/or output FIFO if input is NULL */
- if (!avr->resample_needed)
- return handle_buffered_output(avr, output ? &output_buffer : NULL,
- NULL);
- current_buffer = NULL;
- }
-
- if (avr->resample_needed) {
- AudioData *resample_out;
-
- if (!avr->out_convert_needed && direct_output && out_samples > 0)
- resample_out = &output_buffer;
- else
- resample_out = avr->resample_out_buffer;
- av_dlog(avr, "[resample] %s to %s\n", current_buffer->name,
- resample_out->name);
- ret = ff_audio_resample(avr->resample, resample_out,
- current_buffer);
- if (ret < 0)
- return ret;
-
- /* if resampling did not produce any samples, just return 0 */
- if (resample_out->nb_samples == 0) {
- av_dlog(avr, "[end conversion]\n");
- return 0;
- }
-
- current_buffer = resample_out;
- }
-
- if (avr->upmix_needed) {
- av_dlog(avr, "[upmix] %s\n", current_buffer->name);
- ret = ff_audio_mix(avr->am, current_buffer);
- if (ret < 0)
- return ret;
- }
-
- /* if we resampled or upmixed directly to output, return here */
- if (current_buffer == &output_buffer) {
- av_dlog(avr, "[end conversion]\n");
- return current_buffer->nb_samples;
- }
-
- if (avr->out_convert_needed) {
- if (direct_output && out_samples >= current_buffer->nb_samples) {
- /* convert directly to output */
- av_dlog(avr, "[convert] %s to output\n", current_buffer->name);
- ret = ff_audio_convert(avr->ac_out, &output_buffer, current_buffer);
- if (ret < 0)
- return ret;
-
- av_dlog(avr, "[end conversion]\n");
- return output_buffer.nb_samples;
- } else {
- ret = ff_audio_data_realloc(avr->out_buffer,
- current_buffer->nb_samples);
- if (ret < 0)
- return ret;
- av_dlog(avr, "[convert] %s to out_buffer\n", current_buffer->name);
- ret = ff_audio_convert(avr->ac_out, avr->out_buffer,
- current_buffer);
- if (ret < 0)
- return ret;
- current_buffer = avr->out_buffer;
- }
- }
-
- return handle_buffered_output(avr, output ? &output_buffer : NULL,
- current_buffer);
-}
-
-int avresample_get_matrix(AVAudioResampleContext *avr, double *matrix,
- int stride)
-{
- int in_channels, out_channels, i, o;
-
- if (avr->am)
- return ff_audio_mix_get_matrix(avr->am, matrix, stride);
-
- in_channels = av_get_channel_layout_nb_channels(avr->in_channel_layout);
- out_channels = av_get_channel_layout_nb_channels(avr->out_channel_layout);
-
- if ( in_channels <= 0 || in_channels > AVRESAMPLE_MAX_CHANNELS ||
- out_channels <= 0 || out_channels > AVRESAMPLE_MAX_CHANNELS) {
- av_log(avr, AV_LOG_ERROR, "Invalid channel layouts\n");
- return AVERROR(EINVAL);
- }
-
- if (!avr->mix_matrix) {
- av_log(avr, AV_LOG_ERROR, "matrix is not set\n");
- return AVERROR(EINVAL);
- }
-
- for (o = 0; o < out_channels; o++)
- for (i = 0; i < in_channels; i++)
- matrix[o * stride + i] = avr->mix_matrix[o * in_channels + i];
-
- return 0;
-}
-
-int avresample_set_matrix(AVAudioResampleContext *avr, const double *matrix,
- int stride)
-{
- int in_channels, out_channels, i, o;
-
- if (avr->am)
- return ff_audio_mix_set_matrix(avr->am, matrix, stride);
-
- in_channels = av_get_channel_layout_nb_channels(avr->in_channel_layout);
- out_channels = av_get_channel_layout_nb_channels(avr->out_channel_layout);
-
- if ( in_channels <= 0 || in_channels > AVRESAMPLE_MAX_CHANNELS ||
- out_channels <= 0 || out_channels > AVRESAMPLE_MAX_CHANNELS) {
- av_log(avr, AV_LOG_ERROR, "Invalid channel layouts\n");
- return AVERROR(EINVAL);
- }
-
- if (avr->mix_matrix)
- av_freep(&avr->mix_matrix);
- avr->mix_matrix = av_malloc(in_channels * out_channels *
- sizeof(*avr->mix_matrix));
- if (!avr->mix_matrix)
- return AVERROR(ENOMEM);
-
- for (o = 0; o < out_channels; o++)
- for (i = 0; i < in_channels; i++)
- avr->mix_matrix[o * in_channels + i] = matrix[o * stride + i];
-
- return 0;
-}
-
-int avresample_set_channel_mapping(AVAudioResampleContext *avr,
- const int *channel_map)
-{
- ChannelMapInfo *info = &avr->ch_map_info;
- int in_channels, ch, i;
-
- in_channels = av_get_channel_layout_nb_channels(avr->in_channel_layout);
- if (in_channels <= 0 || in_channels > AVRESAMPLE_MAX_CHANNELS) {
- av_log(avr, AV_LOG_ERROR, "Invalid input channel layout\n");
- return AVERROR(EINVAL);
- }
-
- memset(info, 0, sizeof(*info));
- memset(info->input_map, -1, sizeof(info->input_map));
-
- for (ch = 0; ch < in_channels; ch++) {
- if (channel_map[ch] >= in_channels) {
- av_log(avr, AV_LOG_ERROR, "Invalid channel map\n");
- return AVERROR(EINVAL);
- }
- if (channel_map[ch] < 0) {
- info->channel_zero[ch] = 1;
- info->channel_map[ch] = -1;
- info->do_zero = 1;
- } else if (info->input_map[channel_map[ch]] >= 0) {
- info->channel_copy[ch] = info->input_map[channel_map[ch]];
- info->channel_map[ch] = -1;
- info->do_copy = 1;
- } else {
- info->channel_map[ch] = channel_map[ch];
- info->input_map[channel_map[ch]] = ch;
- info->do_remap = 1;
- }
- }
- /* Fill-in unmapped input channels with unmapped output channels.
- This is used when remapping during conversion from interleaved to
- planar format. */
- for (ch = 0, i = 0; ch < in_channels && i < in_channels; ch++, i++) {
- while (ch < in_channels && info->input_map[ch] >= 0)
- ch++;
- while (i < in_channels && info->channel_map[i] >= 0)
- i++;
- if (ch >= in_channels || i >= in_channels)
- break;
- info->input_map[ch] = i;
- }
-
- avr->use_channel_map = 1;
- return 0;
-}
-
-int avresample_available(AVAudioResampleContext *avr)
-{
- return av_audio_fifo_size(avr->out_fifo);
-}
-
-int avresample_read(AVAudioResampleContext *avr, uint8_t **output, int nb_samples)
-{
- if (!output)
- return av_audio_fifo_drain(avr->out_fifo, nb_samples);
- return av_audio_fifo_read(avr->out_fifo, (void**)output, nb_samples);
-}
-
-unsigned avresample_version(void)
-{
- return LIBAVRESAMPLE_VERSION_INT;
-}
-
-const char *avresample_license(void)
-{
-#define LICENSE_PREFIX "libavresample license: "
- return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1;
-}
-
-const char *avresample_configuration(void)
-{
- return FFMPEG_CONFIGURATION;
-}
diff --git a/src/thirdparty/ffmpeg/libavresample/version.h b/src/thirdparty/ffmpeg/libavresample/version.h
deleted file mode 100644
index 387d097d3..000000000
--- a/src/thirdparty/ffmpeg/libavresample/version.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVRESAMPLE_VERSION_H
-#define AVRESAMPLE_VERSION_H
-
-#define LIBAVRESAMPLE_VERSION_MAJOR 1
-#define LIBAVRESAMPLE_VERSION_MINOR 1
-#define LIBAVRESAMPLE_VERSION_MICRO 0
-
-#define LIBAVRESAMPLE_VERSION_INT AV_VERSION_INT(LIBAVRESAMPLE_VERSION_MAJOR, \
- LIBAVRESAMPLE_VERSION_MINOR, \
- LIBAVRESAMPLE_VERSION_MICRO)
-#define LIBAVRESAMPLE_VERSION AV_VERSION(LIBAVRESAMPLE_VERSION_MAJOR, \
- LIBAVRESAMPLE_VERSION_MINOR, \
- LIBAVRESAMPLE_VERSION_MICRO)
-#define LIBAVRESAMPLE_BUILD LIBAVRESAMPLE_VERSION_INT
-
-#define LIBAVRESAMPLE_IDENT "Lavr" AV_STRINGIFY(LIBAVRESAMPLE_VERSION)
-
-/**
- * FF_API_* defines may be placed below to indicate public API that will be
- * dropped at a future version bump. The defines themselves are not part of
- * the public API and may change, break or disappear at any time.
- */
-
-#ifndef FF_API_RESAMPLE_CLOSE_OPEN
-#define FF_API_RESAMPLE_CLOSE_OPEN (LIBAVRESAMPLE_VERSION_MAJOR < 2)
-#endif
-
-#endif /* AVRESAMPLE_VERSION_H */
diff --git a/src/thirdparty/ffmpeg/libavresample/x86/audio_convert.asm b/src/thirdparty/ffmpeg/libavresample/x86/audio_convert.asm
deleted file mode 100644
index 1d125c2b5..000000000
--- a/src/thirdparty/ffmpeg/libavresample/x86/audio_convert.asm
+++ /dev/null
@@ -1,1261 +0,0 @@
-;******************************************************************************
-;* x86 optimized Format Conversion Utils
-;* Copyright (c) 2008 Loren Merritt
-;* Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
-;*
-;* This file is part of Libav.
-;*
-;* Libav is free software; you can redistribute it and/or
-;* modify it under the terms of the GNU Lesser General Public
-;* License as published by the Free Software Foundation; either
-;* version 2.1 of the License, or (at your option) any later version.
-;*
-;* Libav is distributed in the hope that it will be useful,
-;* but WITHOUT ANY WARRANTY; without even the implied warranty of
-;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-;* Lesser General Public License for more details.
-;*
-;* You should have received a copy of the GNU Lesser General Public
-;* License along with Libav; if not, write to the Free Software
-;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-;******************************************************************************
-
-%include "libavutil/x86/x86util.asm"
-%include "util.asm"
-
-SECTION_RODATA 32
-
-pf_s32_inv_scale: times 8 dd 0x30000000
-pf_s32_scale: times 8 dd 0x4f000000
-pf_s32_clip: times 8 dd 0x4effffff
-pf_s16_inv_scale: times 4 dd 0x38000000
-pf_s16_scale: times 4 dd 0x47000000
-pb_shuf_unpack_even: db -1, -1, 0, 1, -1, -1, 2, 3, -1, -1, 8, 9, -1, -1, 10, 11
-pb_shuf_unpack_odd: db -1, -1, 4, 5, -1, -1, 6, 7, -1, -1, 12, 13, -1, -1, 14, 15
-pb_interleave_words: SHUFFLE_MASK_W 0, 4, 1, 5, 2, 6, 3, 7
-pb_deinterleave_words: SHUFFLE_MASK_W 0, 2, 4, 6, 1, 3, 5, 7
-pw_zero_even: times 4 dw 0x0000, 0xffff
-
-SECTION_TEXT
-
-;------------------------------------------------------------------------------
-; void ff_conv_s16_to_s32(int32_t *dst, const int16_t *src, int len);
-;------------------------------------------------------------------------------
-
-INIT_XMM sse2
-cglobal conv_s16_to_s32, 3,3,3, dst, src, len
- lea lenq, [2*lend]
- lea dstq, [dstq+2*lenq]
- add srcq, lenq
- neg lenq
-.loop:
- mova m2, [srcq+lenq]
- pxor m0, m0
- pxor m1, m1
- punpcklwd m0, m2
- punpckhwd m1, m2
- mova [dstq+2*lenq ], m0
- mova [dstq+2*lenq+mmsize], m1
- add lenq, mmsize
- jl .loop
- REP_RET
-
-;------------------------------------------------------------------------------
-; void ff_conv_s16_to_flt(float *dst, const int16_t *src, int len);
-;------------------------------------------------------------------------------
-
-%macro CONV_S16_TO_FLT 0
-cglobal conv_s16_to_flt, 3,3,3, dst, src, len
- lea lenq, [2*lend]
- add srcq, lenq
- lea dstq, [dstq + 2*lenq]
- neg lenq
- mova m2, [pf_s16_inv_scale]
- ALIGN 16
-.loop:
- mova m0, [srcq+lenq]
- S16_TO_S32_SX 0, 1
- cvtdq2ps m0, m0
- cvtdq2ps m1, m1
- mulps m0, m2
- mulps m1, m2
- mova [dstq+2*lenq ], m0
- mova [dstq+2*lenq+mmsize], m1
- add lenq, mmsize
- jl .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-CONV_S16_TO_FLT
-INIT_XMM sse4
-CONV_S16_TO_FLT
-
-;------------------------------------------------------------------------------
-; void ff_conv_s32_to_s16(int16_t *dst, const int32_t *src, int len);
-;------------------------------------------------------------------------------
-
-%macro CONV_S32_TO_S16 0
-cglobal conv_s32_to_s16, 3,3,4, dst, src, len
- lea lenq, [2*lend]
- lea srcq, [srcq+2*lenq]
- add dstq, lenq
- neg lenq
-.loop:
- mova m0, [srcq+2*lenq ]
- mova m1, [srcq+2*lenq+ mmsize]
- mova m2, [srcq+2*lenq+2*mmsize]
- mova m3, [srcq+2*lenq+3*mmsize]
- psrad m0, 16
- psrad m1, 16
- psrad m2, 16
- psrad m3, 16
- packssdw m0, m1
- packssdw m2, m3
- mova [dstq+lenq ], m0
- mova [dstq+lenq+mmsize], m2
- add lenq, mmsize*2
- jl .loop
-%if mmsize == 8
- emms
- RET
-%else
- REP_RET
-%endif
-%endmacro
-
-INIT_MMX mmx
-CONV_S32_TO_S16
-INIT_XMM sse2
-CONV_S32_TO_S16
-
-;------------------------------------------------------------------------------
-; void ff_conv_s32_to_flt(float *dst, const int32_t *src, int len);
-;------------------------------------------------------------------------------
-
-%macro CONV_S32_TO_FLT 0
-cglobal conv_s32_to_flt, 3,3,3, dst, src, len
- lea lenq, [4*lend]
- add srcq, lenq
- add dstq, lenq
- neg lenq
- mova m0, [pf_s32_inv_scale]
- ALIGN 16
-.loop:
- cvtdq2ps m1, [srcq+lenq ]
- cvtdq2ps m2, [srcq+lenq+mmsize]
- mulps m1, m1, m0
- mulps m2, m2, m0
- mova [dstq+lenq ], m1
- mova [dstq+lenq+mmsize], m2
- add lenq, mmsize*2
- jl .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-CONV_S32_TO_FLT
-%if HAVE_AVX_EXTERNAL
-INIT_YMM avx
-CONV_S32_TO_FLT
-%endif
-
-;------------------------------------------------------------------------------
-; void ff_conv_flt_to_s16(int16_t *dst, const float *src, int len);
-;------------------------------------------------------------------------------
-
-INIT_XMM sse2
-cglobal conv_flt_to_s16, 3,3,5, dst, src, len
- lea lenq, [2*lend]
- lea srcq, [srcq+2*lenq]
- add dstq, lenq
- neg lenq
- mova m4, [pf_s16_scale]
-.loop:
- mova m0, [srcq+2*lenq ]
- mova m1, [srcq+2*lenq+1*mmsize]
- mova m2, [srcq+2*lenq+2*mmsize]
- mova m3, [srcq+2*lenq+3*mmsize]
- mulps m0, m4
- mulps m1, m4
- mulps m2, m4
- mulps m3, m4
- cvtps2dq m0, m0
- cvtps2dq m1, m1
- cvtps2dq m2, m2
- cvtps2dq m3, m3
- packssdw m0, m1
- packssdw m2, m3
- mova [dstq+lenq ], m0
- mova [dstq+lenq+mmsize], m2
- add lenq, mmsize*2
- jl .loop
- REP_RET
-
-;------------------------------------------------------------------------------
-; void ff_conv_flt_to_s32(int32_t *dst, const float *src, int len);
-;------------------------------------------------------------------------------
-
-%macro CONV_FLT_TO_S32 0
-cglobal conv_flt_to_s32, 3,3,6, dst, src, len
- lea lenq, [lend*4]
- add srcq, lenq
- add dstq, lenq
- neg lenq
- mova m4, [pf_s32_scale]
- mova m5, [pf_s32_clip]
-.loop:
- mulps m0, m4, [srcq+lenq ]
- mulps m1, m4, [srcq+lenq+1*mmsize]
- mulps m2, m4, [srcq+lenq+2*mmsize]
- mulps m3, m4, [srcq+lenq+3*mmsize]
- minps m0, m0, m5
- minps m1, m1, m5
- minps m2, m2, m5
- minps m3, m3, m5
- cvtps2dq m0, m0
- cvtps2dq m1, m1
- cvtps2dq m2, m2
- cvtps2dq m3, m3
- mova [dstq+lenq ], m0
- mova [dstq+lenq+1*mmsize], m1
- mova [dstq+lenq+2*mmsize], m2
- mova [dstq+lenq+3*mmsize], m3
- add lenq, mmsize*4
- jl .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-CONV_FLT_TO_S32
-%if HAVE_AVX_EXTERNAL
-INIT_YMM avx
-CONV_FLT_TO_S32
-%endif
-
-;------------------------------------------------------------------------------
-; void ff_conv_s16p_to_s16_2ch(int16_t *dst, int16_t *const *src, int len,
-; int channels);
-;------------------------------------------------------------------------------
-
-%macro CONV_S16P_TO_S16_2CH 0
-cglobal conv_s16p_to_s16_2ch, 3,4,5, dst, src0, len, src1
- mov src1q, [src0q+gprsize]
- mov src0q, [src0q ]
- lea lenq, [2*lend]
- add src0q, lenq
- add src1q, lenq
- lea dstq, [dstq+2*lenq]
- neg lenq
-.loop:
- mova m0, [src0q+lenq ]
- mova m1, [src1q+lenq ]
- mova m2, [src0q+lenq+mmsize]
- mova m3, [src1q+lenq+mmsize]
- SBUTTERFLY2 wd, 0, 1, 4
- SBUTTERFLY2 wd, 2, 3, 4
- mova [dstq+2*lenq+0*mmsize], m0
- mova [dstq+2*lenq+1*mmsize], m1
- mova [dstq+2*lenq+2*mmsize], m2
- mova [dstq+2*lenq+3*mmsize], m3
- add lenq, 2*mmsize
- jl .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-CONV_S16P_TO_S16_2CH
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-CONV_S16P_TO_S16_2CH
-%endif
-
-;------------------------------------------------------------------------------
-; void ff_conv_s16p_to_s16_6ch(int16_t *dst, int16_t *const *src, int len,
-; int channels);
-;------------------------------------------------------------------------------
-
-;------------------------------------------------------------------------------
-; NOTE: In the 6-channel functions, len could be used as an index on x86-64
-; instead of just a counter, which would avoid incrementing the
-; pointers, but the extra complexity and amount of code is not worth
-; the small gain. On x86-32 there are not enough registers to use len
-; as an index without keeping two of the pointers on the stack and
-; loading them in each iteration.
-;------------------------------------------------------------------------------
-
-%macro CONV_S16P_TO_S16_6CH 0
-%if ARCH_X86_64
-cglobal conv_s16p_to_s16_6ch, 3,8,7, dst, src0, len, src1, src2, src3, src4, src5
-%else
-cglobal conv_s16p_to_s16_6ch, 2,7,7, dst, src0, src1, src2, src3, src4, src5
-%define lend dword r2m
-%endif
- mov src1q, [src0q+1*gprsize]
- mov src2q, [src0q+2*gprsize]
- mov src3q, [src0q+3*gprsize]
- mov src4q, [src0q+4*gprsize]
- mov src5q, [src0q+5*gprsize]
- mov src0q, [src0q]
- sub src1q, src0q
- sub src2q, src0q
- sub src3q, src0q
- sub src4q, src0q
- sub src5q, src0q
-.loop:
-%if cpuflag(sse2slow)
- movq m0, [src0q ] ; m0 = 0, 6, 12, 18, x, x, x, x
- movq m1, [src0q+src1q] ; m1 = 1, 7, 13, 19, x, x, x, x
- movq m2, [src0q+src2q] ; m2 = 2, 8, 14, 20, x, x, x, x
- movq m3, [src0q+src3q] ; m3 = 3, 9, 15, 21, x, x, x, x
- movq m4, [src0q+src4q] ; m4 = 4, 10, 16, 22, x, x, x, x
- movq m5, [src0q+src5q] ; m5 = 5, 11, 17, 23, x, x, x, x
- ; unpack words:
- punpcklwd m0, m1 ; m0 = 0, 1, 6, 7, 12, 13, 18, 19
- punpcklwd m2, m3 ; m2 = 4, 5, 10, 11, 16, 17, 22, 23
- punpcklwd m4, m5 ; m4 = 2, 3, 8, 9, 14, 15, 20, 21
- ; blend dwords
- shufps m1, m0, m2, q2020 ; m1 = 0, 1, 12, 13, 2, 3, 14, 15
- shufps m0, m4, q2031 ; m0 = 6, 7, 18, 19, 4, 5, 16, 17
- shufps m2, m4, q3131 ; m2 = 8, 9, 20, 21, 10, 11, 22, 23
- ; shuffle dwords
- pshufd m0, m0, q1302 ; m0 = 4, 5, 6, 7, 16, 17, 18, 19
- pshufd m1, m1, q3120 ; m1 = 0, 1, 2, 3, 12, 13, 14, 15
- pshufd m2, m2, q3120 ; m2 = 8, 9, 10, 11, 20, 21, 22, 23
- movq [dstq+0*mmsize/2], m1
- movq [dstq+1*mmsize/2], m0
- movq [dstq+2*mmsize/2], m2
- movhps [dstq+3*mmsize/2], m1
- movhps [dstq+4*mmsize/2], m0
- movhps [dstq+5*mmsize/2], m2
- add src0q, mmsize/2
- add dstq, mmsize*3
- sub lend, mmsize/4
-%else
- mova m0, [src0q ] ; m0 = 0, 6, 12, 18, 24, 30, 36, 42
- mova m1, [src0q+src1q] ; m1 = 1, 7, 13, 19, 25, 31, 37, 43
- mova m2, [src0q+src2q] ; m2 = 2, 8, 14, 20, 26, 32, 38, 44
- mova m3, [src0q+src3q] ; m3 = 3, 9, 15, 21, 27, 33, 39, 45
- mova m4, [src0q+src4q] ; m4 = 4, 10, 16, 22, 28, 34, 40, 46
- mova m5, [src0q+src5q] ; m5 = 5, 11, 17, 23, 29, 35, 41, 47
- ; unpack words:
- SBUTTERFLY2 wd, 0, 1, 6 ; m0 = 0, 1, 6, 7, 12, 13, 18, 19
- ; m1 = 24, 25, 30, 31, 36, 37, 42, 43
- SBUTTERFLY2 wd, 2, 3, 6 ; m2 = 2, 3, 8, 9, 14, 15, 20, 21
- ; m3 = 26, 27, 32, 33, 38, 39, 44, 45
- SBUTTERFLY2 wd, 4, 5, 6 ; m4 = 4, 5, 10, 11, 16, 17, 22, 23
- ; m5 = 28, 29, 34, 35, 40, 41, 46, 47
- ; blend dwords
- shufps m6, m0, m2, q2020 ; m6 = 0, 1, 12, 13, 2, 3, 14, 15
- shufps m0, m4, q2031 ; m0 = 6, 7, 18, 19, 4, 5, 16, 17
- shufps m2, m4, q3131 ; m2 = 8, 9, 20, 21, 10, 11, 22, 23
- SWAP 4,6 ; m4 = 0, 1, 12, 13, 2, 3, 14, 15
- shufps m6, m1, m3, q2020 ; m6 = 24, 25, 36, 37, 26, 27, 38, 39
- shufps m1, m5, q2031 ; m1 = 30, 31, 42, 43, 28, 29, 40, 41
- shufps m3, m5, q3131 ; m3 = 32, 33, 44, 45, 34, 35, 46, 47
- SWAP 5,6 ; m5 = 24, 25, 36, 37, 26, 27, 38, 39
- ; shuffle dwords
- pshufd m0, m0, q1302 ; m0 = 4, 5, 6, 7, 16, 17, 18, 19
- pshufd m2, m2, q3120 ; m2 = 8, 9, 10, 11, 20, 21, 22, 23
- pshufd m4, m4, q3120 ; m4 = 0, 1, 2, 3, 12, 13, 14, 15
- pshufd m1, m1, q1302 ; m1 = 28, 29, 30, 31, 40, 41, 42, 43
- pshufd m3, m3, q3120 ; m3 = 32, 33, 34, 35, 44, 45, 46, 47
- pshufd m5, m5, q3120 ; m5 = 24, 25, 26, 27, 36, 37, 38, 39
- ; shuffle qwords
- punpcklqdq m6, m4, m0 ; m6 = 0, 1, 2, 3, 4, 5, 6, 7
- punpckhqdq m0, m2 ; m0 = 16, 17, 18, 19, 20, 21, 22, 23
- shufps m2, m4, q3210 ; m2 = 8, 9, 10, 11, 12, 13, 14, 15
- SWAP 4,6 ; m4 = 0, 1, 2, 3, 4, 5, 6, 7
- punpcklqdq m6, m5, m1 ; m6 = 24, 25, 26, 27, 28, 29, 30, 31
- punpckhqdq m1, m3 ; m1 = 40, 41, 42, 43, 44, 45, 46, 47
- shufps m3, m5, q3210 ; m3 = 32, 33, 34, 35, 36, 37, 38, 39
- SWAP 5,6 ; m5 = 24, 25, 26, 27, 28, 29, 30, 31
- mova [dstq+0*mmsize], m4
- mova [dstq+1*mmsize], m2
- mova [dstq+2*mmsize], m0
- mova [dstq+3*mmsize], m5
- mova [dstq+4*mmsize], m3
- mova [dstq+5*mmsize], m1
- add src0q, mmsize
- add dstq, mmsize*6
- sub lend, mmsize/2
-%endif
- jg .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-CONV_S16P_TO_S16_6CH
-INIT_XMM sse2slow
-CONV_S16P_TO_S16_6CH
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-CONV_S16P_TO_S16_6CH
-%endif
-
-;------------------------------------------------------------------------------
-; void ff_conv_s16p_to_flt_2ch(float *dst, int16_t *const *src, int len,
-; int channels);
-;------------------------------------------------------------------------------
-
-%macro CONV_S16P_TO_FLT_2CH 0
-cglobal conv_s16p_to_flt_2ch, 3,4,6, dst, src0, len, src1
- lea lenq, [2*lend]
- mov src1q, [src0q+gprsize]
- mov src0q, [src0q ]
- lea dstq, [dstq+4*lenq]
- add src0q, lenq
- add src1q, lenq
- neg lenq
- mova m5, [pf_s32_inv_scale]
-.loop:
- mova m2, [src0q+lenq] ; m2 = 0, 2, 4, 6, 8, 10, 12, 14
- mova m4, [src1q+lenq] ; m4 = 1, 3, 5, 7, 9, 11, 13, 15
- SBUTTERFLY2 wd, 2, 4, 3 ; m2 = 0, 1, 2, 3, 4, 5, 6, 7
- ; m4 = 8, 9, 10, 11, 12, 13, 14, 15
- pxor m3, m3
- punpcklwd m0, m3, m2 ; m0 = 0, 1, 2, 3
- punpckhwd m1, m3, m2 ; m1 = 4, 5, 6, 7
- punpcklwd m2, m3, m4 ; m2 = 8, 9, 10, 11
- punpckhwd m3, m4 ; m3 = 12, 13, 14, 15
- cvtdq2ps m0, m0
- cvtdq2ps m1, m1
- cvtdq2ps m2, m2
- cvtdq2ps m3, m3
- mulps m0, m5
- mulps m1, m5
- mulps m2, m5
- mulps m3, m5
- mova [dstq+4*lenq ], m0
- mova [dstq+4*lenq+ mmsize], m1
- mova [dstq+4*lenq+2*mmsize], m2
- mova [dstq+4*lenq+3*mmsize], m3
- add lenq, mmsize
- jl .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-CONV_S16P_TO_FLT_2CH
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-CONV_S16P_TO_FLT_2CH
-%endif
-
-;------------------------------------------------------------------------------
-; void ff_conv_s16p_to_flt_6ch(float *dst, int16_t *const *src, int len,
-; int channels);
-;------------------------------------------------------------------------------
-
-%macro CONV_S16P_TO_FLT_6CH 0
-%if ARCH_X86_64
-cglobal conv_s16p_to_flt_6ch, 3,8,8, dst, src, len, src1, src2, src3, src4, src5
-%else
-cglobal conv_s16p_to_flt_6ch, 2,7,8, dst, src, src1, src2, src3, src4, src5
-%define lend dword r2m
-%endif
- mov src1q, [srcq+1*gprsize]
- mov src2q, [srcq+2*gprsize]
- mov src3q, [srcq+3*gprsize]
- mov src4q, [srcq+4*gprsize]
- mov src5q, [srcq+5*gprsize]
- mov srcq, [srcq]
- sub src1q, srcq
- sub src2q, srcq
- sub src3q, srcq
- sub src4q, srcq
- sub src5q, srcq
- mova m7, [pf_s32_inv_scale]
-%if cpuflag(ssse3)
- %define unpack_even m6
- mova m6, [pb_shuf_unpack_even]
-%if ARCH_X86_64
- %define unpack_odd m8
- mova m8, [pb_shuf_unpack_odd]
-%else
- %define unpack_odd [pb_shuf_unpack_odd]
-%endif
-%endif
-.loop:
- movq m0, [srcq ] ; m0 = 0, 6, 12, 18, x, x, x, x
- movq m1, [srcq+src1q] ; m1 = 1, 7, 13, 19, x, x, x, x
- movq m2, [srcq+src2q] ; m2 = 2, 8, 14, 20, x, x, x, x
- movq m3, [srcq+src3q] ; m3 = 3, 9, 15, 21, x, x, x, x
- movq m4, [srcq+src4q] ; m4 = 4, 10, 16, 22, x, x, x, x
- movq m5, [srcq+src5q] ; m5 = 5, 11, 17, 23, x, x, x, x
- ; unpack words:
- punpcklwd m0, m1 ; m0 = 0, 1, 6, 7, 12, 13, 18, 19
- punpcklwd m2, m3 ; m2 = 2, 3, 8, 9, 14, 15, 20, 21
- punpcklwd m4, m5 ; m4 = 4, 5, 10, 11, 16, 17, 22, 23
- ; blend dwords
- shufps m1, m4, m0, q3120 ; m1 = 4, 5, 16, 17, 6, 7, 18, 19
- shufps m0, m2, q2020 ; m0 = 0, 1, 12, 13, 2, 3, 14, 15
- shufps m2, m4, q3131 ; m2 = 8, 9, 20, 21, 10, 11, 22, 23
-%if cpuflag(ssse3)
- pshufb m3, m0, unpack_odd ; m3 = 12, 13, 14, 15
- pshufb m0, unpack_even ; m0 = 0, 1, 2, 3
- pshufb m4, m1, unpack_odd ; m4 = 16, 17, 18, 19
- pshufb m1, unpack_even ; m1 = 4, 5, 6, 7
- pshufb m5, m2, unpack_odd ; m5 = 20, 21, 22, 23
- pshufb m2, unpack_even ; m2 = 8, 9, 10, 11
-%else
- ; shuffle dwords
- pshufd m0, m0, q3120 ; m0 = 0, 1, 2, 3, 12, 13, 14, 15
- pshufd m1, m1, q3120 ; m1 = 4, 5, 6, 7, 16, 17, 18, 19
- pshufd m2, m2, q3120 ; m2 = 8, 9, 10, 11, 20, 21, 22, 23
- pxor m6, m6 ; convert s16 in m0-m2 to s32 in m0-m5
- punpcklwd m3, m6, m0 ; m3 = 0, 1, 2, 3
- punpckhwd m4, m6, m0 ; m4 = 12, 13, 14, 15
- punpcklwd m0, m6, m1 ; m0 = 4, 5, 6, 7
- punpckhwd m5, m6, m1 ; m5 = 16, 17, 18, 19
- punpcklwd m1, m6, m2 ; m1 = 8, 9, 10, 11
- punpckhwd m6, m2 ; m6 = 20, 21, 22, 23
- SWAP 6,2,1,0,3,4,5 ; swap registers 3,0,1,4,5,6 to 0,1,2,3,4,5
-%endif
- cvtdq2ps m0, m0 ; convert s32 to float
- cvtdq2ps m1, m1
- cvtdq2ps m2, m2
- cvtdq2ps m3, m3
- cvtdq2ps m4, m4
- cvtdq2ps m5, m5
- mulps m0, m7 ; scale float from s32 range to [-1.0,1.0]
- mulps m1, m7
- mulps m2, m7
- mulps m3, m7
- mulps m4, m7
- mulps m5, m7
- mova [dstq ], m0
- mova [dstq+ mmsize], m1
- mova [dstq+2*mmsize], m2
- mova [dstq+3*mmsize], m3
- mova [dstq+4*mmsize], m4
- mova [dstq+5*mmsize], m5
- add srcq, mmsize/2
- add dstq, mmsize*6
- sub lend, mmsize/4
- jg .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-CONV_S16P_TO_FLT_6CH
-INIT_XMM ssse3
-CONV_S16P_TO_FLT_6CH
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-CONV_S16P_TO_FLT_6CH
-%endif
-
-;------------------------------------------------------------------------------
-; void ff_conv_fltp_to_s16_2ch(int16_t *dst, float *const *src, int len,
-; int channels);
-;------------------------------------------------------------------------------
-
-%macro CONV_FLTP_TO_S16_2CH 0
-cglobal conv_fltp_to_s16_2ch, 3,4,3, dst, src0, len, src1
- lea lenq, [4*lend]
- mov src1q, [src0q+gprsize]
- mov src0q, [src0q ]
- add dstq, lenq
- add src0q, lenq
- add src1q, lenq
- neg lenq
- mova m2, [pf_s16_scale]
-%if cpuflag(ssse3)
- mova m3, [pb_interleave_words]
-%endif
-.loop:
- mulps m0, m2, [src0q+lenq] ; m0 = 0, 2, 4, 6
- mulps m1, m2, [src1q+lenq] ; m1 = 1, 3, 5, 7
- cvtps2dq m0, m0
- cvtps2dq m1, m1
-%if cpuflag(ssse3)
- packssdw m0, m1 ; m0 = 0, 2, 4, 6, 1, 3, 5, 7
- pshufb m0, m3 ; m0 = 0, 1, 2, 3, 4, 5, 6, 7
-%else
- packssdw m0, m0 ; m0 = 0, 2, 4, 6, x, x, x, x
- packssdw m1, m1 ; m1 = 1, 3, 5, 7, x, x, x, x
- punpcklwd m0, m1 ; m0 = 0, 1, 2, 3, 4, 5, 6, 7
-%endif
- mova [dstq+lenq], m0
- add lenq, mmsize
- jl .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-CONV_FLTP_TO_S16_2CH
-INIT_XMM ssse3
-CONV_FLTP_TO_S16_2CH
-
-;------------------------------------------------------------------------------
-; void ff_conv_fltp_to_s16_6ch(int16_t *dst, float *const *src, int len,
-; int channels);
-;------------------------------------------------------------------------------
-
-%macro CONV_FLTP_TO_S16_6CH 0
-%if ARCH_X86_64
-cglobal conv_fltp_to_s16_6ch, 3,8,7, dst, src, len, src1, src2, src3, src4, src5
-%else
-cglobal conv_fltp_to_s16_6ch, 2,7,7, dst, src, src1, src2, src3, src4, src5
-%define lend dword r2m
-%endif
- mov src1q, [srcq+1*gprsize]
- mov src2q, [srcq+2*gprsize]
- mov src3q, [srcq+3*gprsize]
- mov src4q, [srcq+4*gprsize]
- mov src5q, [srcq+5*gprsize]
- mov srcq, [srcq]
- sub src1q, srcq
- sub src2q, srcq
- sub src3q, srcq
- sub src4q, srcq
- sub src5q, srcq
- movaps xmm6, [pf_s16_scale]
-.loop:
-%if cpuflag(sse2)
- mulps m0, m6, [srcq ]
- mulps m1, m6, [srcq+src1q]
- mulps m2, m6, [srcq+src2q]
- mulps m3, m6, [srcq+src3q]
- mulps m4, m6, [srcq+src4q]
- mulps m5, m6, [srcq+src5q]
- cvtps2dq m0, m0
- cvtps2dq m1, m1
- cvtps2dq m2, m2
- cvtps2dq m3, m3
- cvtps2dq m4, m4
- cvtps2dq m5, m5
- packssdw m0, m3 ; m0 = 0, 6, 12, 18, 3, 9, 15, 21
- packssdw m1, m4 ; m1 = 1, 7, 13, 19, 4, 10, 16, 22
- packssdw m2, m5 ; m2 = 2, 8, 14, 20, 5, 11, 17, 23
- ; unpack words:
- movhlps m3, m0 ; m3 = 3, 9, 15, 21, x, x, x, x
- punpcklwd m0, m1 ; m0 = 0, 1, 6, 7, 12, 13, 18, 19
- punpckhwd m1, m2 ; m1 = 4, 5, 10, 11, 16, 17, 22, 23
- punpcklwd m2, m3 ; m2 = 2, 3, 8, 9, 14, 15, 20, 21
- ; blend dwords:
- shufps m3, m0, m2, q2020 ; m3 = 0, 1, 12, 13, 2, 3, 14, 15
- shufps m0, m1, q2031 ; m0 = 6, 7, 18, 19, 4, 5, 16, 17
- shufps m2, m1, q3131 ; m2 = 8, 9, 20, 21, 10, 11, 22, 23
- ; shuffle dwords:
- shufps m1, m2, m3, q3120 ; m1 = 8, 9, 10, 11, 12, 13, 14, 15
- shufps m3, m0, q0220 ; m3 = 0, 1, 2, 3, 4, 5, 6, 7
- shufps m0, m2, q3113 ; m0 = 16, 17, 18, 19, 20, 21, 22, 23
- mova [dstq+0*mmsize], m3
- mova [dstq+1*mmsize], m1
- mova [dstq+2*mmsize], m0
-%else ; sse
- movlps xmm0, [srcq ]
- movlps xmm1, [srcq+src1q]
- movlps xmm2, [srcq+src2q]
- movlps xmm3, [srcq+src3q]
- movlps xmm4, [srcq+src4q]
- movlps xmm5, [srcq+src5q]
- mulps xmm0, xmm6
- mulps xmm1, xmm6
- mulps xmm2, xmm6
- mulps xmm3, xmm6
- mulps xmm4, xmm6
- mulps xmm5, xmm6
- cvtps2pi mm0, xmm0
- cvtps2pi mm1, xmm1
- cvtps2pi mm2, xmm2
- cvtps2pi mm3, xmm3
- cvtps2pi mm4, xmm4
- cvtps2pi mm5, xmm5
- packssdw mm0, mm3 ; m0 = 0, 6, 3, 9
- packssdw mm1, mm4 ; m1 = 1, 7, 4, 10
- packssdw mm2, mm5 ; m2 = 2, 8, 5, 11
- ; unpack words
- pshufw mm3, mm0, q1032 ; m3 = 3, 9, 0, 6
- punpcklwd mm0, mm1 ; m0 = 0, 1, 6, 7
- punpckhwd mm1, mm2 ; m1 = 4, 5, 10, 11
- punpcklwd mm2, mm3 ; m2 = 2, 3, 8, 9
- ; unpack dwords
- pshufw mm3, mm0, q1032 ; m3 = 6, 7, 0, 1
- punpckldq mm0, mm2 ; m0 = 0, 1, 2, 3 (final)
- punpckhdq mm2, mm1 ; m2 = 8, 9, 10, 11 (final)
- punpckldq mm1, mm3 ; m1 = 4, 5, 6, 7 (final)
- mova [dstq+0*mmsize], mm0
- mova [dstq+1*mmsize], mm1
- mova [dstq+2*mmsize], mm2
-%endif
- add srcq, mmsize
- add dstq, mmsize*3
- sub lend, mmsize/4
- jg .loop
-%if mmsize == 8
- emms
- RET
-%else
- REP_RET
-%endif
-%endmacro
-
-INIT_MMX sse
-CONV_FLTP_TO_S16_6CH
-INIT_XMM sse2
-CONV_FLTP_TO_S16_6CH
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-CONV_FLTP_TO_S16_6CH
-%endif
-
-;------------------------------------------------------------------------------
-; void ff_conv_fltp_to_flt_2ch(float *dst, float *const *src, int len,
-; int channels);
-;------------------------------------------------------------------------------
-
-%macro CONV_FLTP_TO_FLT_2CH 0
-cglobal conv_fltp_to_flt_2ch, 3,4,5, dst, src0, len, src1
- mov src1q, [src0q+gprsize]
- mov src0q, [src0q]
- lea lenq, [4*lend]
- add src0q, lenq
- add src1q, lenq
- lea dstq, [dstq+2*lenq]
- neg lenq
-.loop:
- mova m0, [src0q+lenq ]
- mova m1, [src1q+lenq ]
- mova m2, [src0q+lenq+mmsize]
- mova m3, [src1q+lenq+mmsize]
- SBUTTERFLYPS 0, 1, 4
- SBUTTERFLYPS 2, 3, 4
- mova [dstq+2*lenq+0*mmsize], m0
- mova [dstq+2*lenq+1*mmsize], m1
- mova [dstq+2*lenq+2*mmsize], m2
- mova [dstq+2*lenq+3*mmsize], m3
- add lenq, 2*mmsize
- jl .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse
-CONV_FLTP_TO_FLT_2CH
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-CONV_FLTP_TO_FLT_2CH
-%endif
-
-;-----------------------------------------------------------------------------
-; void ff_conv_fltp_to_flt_6ch(float *dst, float *const *src, int len,
-; int channels);
-;-----------------------------------------------------------------------------
-
-%macro CONV_FLTP_TO_FLT_6CH 0
-cglobal conv_fltp_to_flt_6ch, 2,8,7, dst, src, src1, src2, src3, src4, src5, len
-%if ARCH_X86_64
- mov lend, r2d
-%else
- %define lend dword r2m
-%endif
- mov src1q, [srcq+1*gprsize]
- mov src2q, [srcq+2*gprsize]
- mov src3q, [srcq+3*gprsize]
- mov src4q, [srcq+4*gprsize]
- mov src5q, [srcq+5*gprsize]
- mov srcq, [srcq]
- sub src1q, srcq
- sub src2q, srcq
- sub src3q, srcq
- sub src4q, srcq
- sub src5q, srcq
-.loop:
- mova m0, [srcq ]
- mova m1, [srcq+src1q]
- mova m2, [srcq+src2q]
- mova m3, [srcq+src3q]
- mova m4, [srcq+src4q]
- mova m5, [srcq+src5q]
-%if cpuflag(sse4)
- SBUTTERFLYPS 0, 1, 6
- SBUTTERFLYPS 2, 3, 6
- SBUTTERFLYPS 4, 5, 6
-
- blendps m6, m4, m0, 1100b
- movlhps m0, m2
- movhlps m4, m2
- blendps m2, m5, m1, 1100b
- movlhps m1, m3
- movhlps m5, m3
-
- movaps [dstq ], m0
- movaps [dstq+16], m6
- movaps [dstq+32], m4
- movaps [dstq+48], m1
- movaps [dstq+64], m2
- movaps [dstq+80], m5
-%else ; mmx
- SBUTTERFLY dq, 0, 1, 6
- SBUTTERFLY dq, 2, 3, 6
- SBUTTERFLY dq, 4, 5, 6
-
- movq [dstq ], m0
- movq [dstq+ 8], m2
- movq [dstq+16], m4
- movq [dstq+24], m1
- movq [dstq+32], m3
- movq [dstq+40], m5
-%endif
- add srcq, mmsize
- add dstq, mmsize*6
- sub lend, mmsize/4
- jg .loop
-%if mmsize == 8
- emms
- RET
-%else
- REP_RET
-%endif
-%endmacro
-
-INIT_MMX mmx
-CONV_FLTP_TO_FLT_6CH
-INIT_XMM sse4
-CONV_FLTP_TO_FLT_6CH
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-CONV_FLTP_TO_FLT_6CH
-%endif
-
-;------------------------------------------------------------------------------
-; void ff_conv_s16_to_s16p_2ch(int16_t *const *dst, int16_t *src, int len,
-; int channels);
-;------------------------------------------------------------------------------
-
-%macro CONV_S16_TO_S16P_2CH 0
-cglobal conv_s16_to_s16p_2ch, 3,4,4, dst0, src, len, dst1
- lea lenq, [2*lend]
- mov dst1q, [dst0q+gprsize]
- mov dst0q, [dst0q ]
- lea srcq, [srcq+2*lenq]
- add dst0q, lenq
- add dst1q, lenq
- neg lenq
-%if cpuflag(ssse3)
- mova m3, [pb_deinterleave_words]
-%endif
-.loop:
- mova m0, [srcq+2*lenq ] ; m0 = 0, 1, 2, 3, 4, 5, 6, 7
- mova m1, [srcq+2*lenq+mmsize] ; m1 = 8, 9, 10, 11, 12, 13, 14, 15
-%if cpuflag(ssse3)
- pshufb m0, m3 ; m0 = 0, 2, 4, 6, 1, 3, 5, 7
- pshufb m1, m3 ; m1 = 8, 10, 12, 14, 9, 11, 13, 15
- SBUTTERFLY2 qdq, 0, 1, 2 ; m0 = 0, 2, 4, 6, 8, 10, 12, 14
- ; m1 = 1, 3, 5, 7, 9, 11, 13, 15
-%else ; sse2
- pshuflw m0, m0, q3120 ; m0 = 0, 2, 1, 3, 4, 5, 6, 7
- pshufhw m0, m0, q3120 ; m0 = 0, 2, 1, 3, 4, 6, 5, 7
- pshuflw m1, m1, q3120 ; m1 = 8, 10, 9, 11, 12, 13, 14, 15
- pshufhw m1, m1, q3120 ; m1 = 8, 10, 9, 11, 12, 14, 13, 15
- DEINT2_PS 0, 1, 2 ; m0 = 0, 2, 4, 6, 8, 10, 12, 14
- ; m1 = 1, 3, 5, 7, 9, 11, 13, 15
-%endif
- mova [dst0q+lenq], m0
- mova [dst1q+lenq], m1
- add lenq, mmsize
- jl .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-CONV_S16_TO_S16P_2CH
-INIT_XMM ssse3
-CONV_S16_TO_S16P_2CH
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-CONV_S16_TO_S16P_2CH
-%endif
-
-;------------------------------------------------------------------------------
-; void ff_conv_s16_to_s16p_6ch(int16_t *const *dst, int16_t *src, int len,
-; int channels);
-;------------------------------------------------------------------------------
-
-%macro CONV_S16_TO_S16P_6CH 0
-%if ARCH_X86_64
-cglobal conv_s16_to_s16p_6ch, 3,8,5, dst, src, len, dst1, dst2, dst3, dst4, dst5
-%else
-cglobal conv_s16_to_s16p_6ch, 2,7,5, dst, src, dst1, dst2, dst3, dst4, dst5
-%define lend dword r2m
-%endif
- mov dst1q, [dstq+ gprsize]
- mov dst2q, [dstq+2*gprsize]
- mov dst3q, [dstq+3*gprsize]
- mov dst4q, [dstq+4*gprsize]
- mov dst5q, [dstq+5*gprsize]
- mov dstq, [dstq ]
- sub dst1q, dstq
- sub dst2q, dstq
- sub dst3q, dstq
- sub dst4q, dstq
- sub dst5q, dstq
-.loop:
- mova m0, [srcq+0*mmsize] ; m0 = 0, 1, 2, 3, 4, 5, 6, 7
- mova m3, [srcq+1*mmsize] ; m3 = 8, 9, 10, 11, 12, 13, 14, 15
- mova m2, [srcq+2*mmsize] ; m2 = 16, 17, 18, 19, 20, 21, 22, 23
- PALIGNR m1, m3, m0, 12, m4 ; m1 = 6, 7, 8, 9, 10, 11, x, x
- shufps m3, m2, q1032 ; m3 = 12, 13, 14, 15, 16, 17, 18, 19
- psrldq m2, 4 ; m2 = 18, 19, 20, 21, 22, 23, x, x
- SBUTTERFLY2 wd, 0, 1, 4 ; m0 = 0, 6, 1, 7, 2, 8, 3, 9
- ; m1 = 4, 10, 5, 11, x, x, x, x
- SBUTTERFLY2 wd, 3, 2, 4 ; m3 = 12, 18, 13, 19, 14, 20, 15, 21
- ; m2 = 16, 22, 17, 23, x, x, x, x
- SBUTTERFLY2 dq, 0, 3, 4 ; m0 = 0, 6, 12, 18, 1, 7, 13, 19
- ; m3 = 2, 8, 14, 20, 3, 9, 15, 21
- punpckldq m1, m2 ; m1 = 4, 10, 16, 22, 5, 11, 17, 23
- movq [dstq ], m0
- movhps [dstq+dst1q], m0
- movq [dstq+dst2q], m3
- movhps [dstq+dst3q], m3
- movq [dstq+dst4q], m1
- movhps [dstq+dst5q], m1
- add srcq, mmsize*3
- add dstq, mmsize/2
- sub lend, mmsize/4
- jg .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-CONV_S16_TO_S16P_6CH
-INIT_XMM ssse3
-CONV_S16_TO_S16P_6CH
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-CONV_S16_TO_S16P_6CH
-%endif
-
-;------------------------------------------------------------------------------
-; void ff_conv_s16_to_fltp_2ch(float *const *dst, int16_t *src, int len,
-; int channels);
-;------------------------------------------------------------------------------
-
-%macro CONV_S16_TO_FLTP_2CH 0
-cglobal conv_s16_to_fltp_2ch, 3,4,5, dst0, src, len, dst1
- lea lenq, [4*lend]
- mov dst1q, [dst0q+gprsize]
- mov dst0q, [dst0q ]
- add srcq, lenq
- add dst0q, lenq
- add dst1q, lenq
- neg lenq
- mova m3, [pf_s32_inv_scale]
- mova m4, [pw_zero_even]
-.loop:
- mova m1, [srcq+lenq]
- pslld m0, m1, 16
- pand m1, m4
- cvtdq2ps m0, m0
- cvtdq2ps m1, m1
- mulps m0, m0, m3
- mulps m1, m1, m3
- mova [dst0q+lenq], m0
- mova [dst1q+lenq], m1
- add lenq, mmsize
- jl .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-CONV_S16_TO_FLTP_2CH
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-CONV_S16_TO_FLTP_2CH
-%endif
-
-;------------------------------------------------------------------------------
-; void ff_conv_s16_to_fltp_6ch(float *const *dst, int16_t *src, int len,
-; int channels);
-;------------------------------------------------------------------------------
-
-%macro CONV_S16_TO_FLTP_6CH 0
-%if ARCH_X86_64
-cglobal conv_s16_to_fltp_6ch, 3,8,7, dst, src, len, dst1, dst2, dst3, dst4, dst5
-%else
-cglobal conv_s16_to_fltp_6ch, 2,7,7, dst, src, dst1, dst2, dst3, dst4, dst5
-%define lend dword r2m
-%endif
- mov dst1q, [dstq+ gprsize]
- mov dst2q, [dstq+2*gprsize]
- mov dst3q, [dstq+3*gprsize]
- mov dst4q, [dstq+4*gprsize]
- mov dst5q, [dstq+5*gprsize]
- mov dstq, [dstq ]
- sub dst1q, dstq
- sub dst2q, dstq
- sub dst3q, dstq
- sub dst4q, dstq
- sub dst5q, dstq
- mova m6, [pf_s16_inv_scale]
-.loop:
- mova m0, [srcq+0*mmsize] ; m0 = 0, 1, 2, 3, 4, 5, 6, 7
- mova m3, [srcq+1*mmsize] ; m3 = 8, 9, 10, 11, 12, 13, 14, 15
- mova m2, [srcq+2*mmsize] ; m2 = 16, 17, 18, 19, 20, 21, 22, 23
- PALIGNR m1, m3, m0, 12, m4 ; m1 = 6, 7, 8, 9, 10, 11, x, x
- shufps m3, m2, q1032 ; m3 = 12, 13, 14, 15, 16, 17, 18, 19
- psrldq m2, 4 ; m2 = 18, 19, 20, 21, 22, 23, x, x
- SBUTTERFLY2 wd, 0, 1, 4 ; m0 = 0, 6, 1, 7, 2, 8, 3, 9
- ; m1 = 4, 10, 5, 11, x, x, x, x
- SBUTTERFLY2 wd, 3, 2, 4 ; m3 = 12, 18, 13, 19, 14, 20, 15, 21
- ; m2 = 16, 22, 17, 23, x, x, x, x
- SBUTTERFLY2 dq, 0, 3, 4 ; m0 = 0, 6, 12, 18, 1, 7, 13, 19
- ; m3 = 2, 8, 14, 20, 3, 9, 15, 21
- punpckldq m1, m2 ; m1 = 4, 10, 16, 22, 5, 11, 17, 23
- S16_TO_S32_SX 0, 2 ; m0 = 0, 6, 12, 18
- ; m2 = 1, 7, 13, 19
- S16_TO_S32_SX 3, 4 ; m3 = 2, 8, 14, 20
- ; m4 = 3, 9, 15, 21
- S16_TO_S32_SX 1, 5 ; m1 = 4, 10, 16, 22
- ; m5 = 5, 11, 17, 23
- SWAP 1,2,3,4
- cvtdq2ps m0, m0
- cvtdq2ps m1, m1
- cvtdq2ps m2, m2
- cvtdq2ps m3, m3
- cvtdq2ps m4, m4
- cvtdq2ps m5, m5
- mulps m0, m6
- mulps m1, m6
- mulps m2, m6
- mulps m3, m6
- mulps m4, m6
- mulps m5, m6
- mova [dstq ], m0
- mova [dstq+dst1q], m1
- mova [dstq+dst2q], m2
- mova [dstq+dst3q], m3
- mova [dstq+dst4q], m4
- mova [dstq+dst5q], m5
- add srcq, mmsize*3
- add dstq, mmsize
- sub lend, mmsize/4
- jg .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-CONV_S16_TO_FLTP_6CH
-INIT_XMM ssse3
-CONV_S16_TO_FLTP_6CH
-INIT_XMM sse4
-CONV_S16_TO_FLTP_6CH
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-CONV_S16_TO_FLTP_6CH
-%endif
-
-;------------------------------------------------------------------------------
-; void ff_conv_flt_to_s16p_2ch(int16_t *const *dst, float *src, int len,
-; int channels);
-;------------------------------------------------------------------------------
-
-%macro CONV_FLT_TO_S16P_2CH 0
-cglobal conv_flt_to_s16p_2ch, 3,4,6, dst0, src, len, dst1
- lea lenq, [2*lend]
- mov dst1q, [dst0q+gprsize]
- mov dst0q, [dst0q ]
- lea srcq, [srcq+4*lenq]
- add dst0q, lenq
- add dst1q, lenq
- neg lenq
- mova m5, [pf_s16_scale]
-.loop:
- mova m0, [srcq+4*lenq ]
- mova m1, [srcq+4*lenq+ mmsize]
- mova m2, [srcq+4*lenq+2*mmsize]
- mova m3, [srcq+4*lenq+3*mmsize]
- DEINT2_PS 0, 1, 4
- DEINT2_PS 2, 3, 4
- mulps m0, m0, m5
- mulps m1, m1, m5
- mulps m2, m2, m5
- mulps m3, m3, m5
- cvtps2dq m0, m0
- cvtps2dq m1, m1
- cvtps2dq m2, m2
- cvtps2dq m3, m3
- packssdw m0, m2
- packssdw m1, m3
- mova [dst0q+lenq], m0
- mova [dst1q+lenq], m1
- add lenq, mmsize
- jl .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-CONV_FLT_TO_S16P_2CH
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-CONV_FLT_TO_S16P_2CH
-%endif
-
-;------------------------------------------------------------------------------
-; void ff_conv_flt_to_s16p_6ch(int16_t *const *dst, float *src, int len,
-; int channels);
-;------------------------------------------------------------------------------
-
-%macro CONV_FLT_TO_S16P_6CH 0
-%if ARCH_X86_64
-cglobal conv_flt_to_s16p_6ch, 3,8,7, dst, src, len, dst1, dst2, dst3, dst4, dst5
-%else
-cglobal conv_flt_to_s16p_6ch, 2,7,7, dst, src, dst1, dst2, dst3, dst4, dst5
-%define lend dword r2m
-%endif
- mov dst1q, [dstq+ gprsize]
- mov dst2q, [dstq+2*gprsize]
- mov dst3q, [dstq+3*gprsize]
- mov dst4q, [dstq+4*gprsize]
- mov dst5q, [dstq+5*gprsize]
- mov dstq, [dstq ]
- sub dst1q, dstq
- sub dst2q, dstq
- sub dst3q, dstq
- sub dst4q, dstq
- sub dst5q, dstq
- mova m6, [pf_s16_scale]
-.loop:
- mulps m0, m6, [srcq+0*mmsize]
- mulps m3, m6, [srcq+1*mmsize]
- mulps m1, m6, [srcq+2*mmsize]
- mulps m4, m6, [srcq+3*mmsize]
- mulps m2, m6, [srcq+4*mmsize]
- mulps m5, m6, [srcq+5*mmsize]
- cvtps2dq m0, m0
- cvtps2dq m1, m1
- cvtps2dq m2, m2
- cvtps2dq m3, m3
- cvtps2dq m4, m4
- cvtps2dq m5, m5
- packssdw m0, m3 ; m0 = 0, 1, 2, 3, 4, 5, 6, 7
- packssdw m1, m4 ; m1 = 8, 9, 10, 11, 12, 13, 14, 15
- packssdw m2, m5 ; m2 = 16, 17, 18, 19, 20, 21, 22, 23
- PALIGNR m3, m1, m0, 12, m4 ; m3 = 6, 7, 8, 9, 10, 11, x, x
- shufps m1, m2, q1032 ; m1 = 12, 13, 14, 15, 16, 17, 18, 19
- psrldq m2, 4 ; m2 = 18, 19, 20, 21, 22, 23, x, x
- SBUTTERFLY2 wd, 0, 3, 4 ; m0 = 0, 6, 1, 7, 2, 8, 3, 9
- ; m3 = 4, 10, 5, 11, x, x, x, x
- SBUTTERFLY2 wd, 1, 2, 4 ; m1 = 12, 18, 13, 19, 14, 20, 15, 21
- ; m2 = 16, 22, 17, 23, x, x, x, x
- SBUTTERFLY2 dq, 0, 1, 4 ; m0 = 0, 6, 12, 18, 1, 7, 13, 19
- ; m1 = 2, 8, 14, 20, 3, 9, 15, 21
- punpckldq m3, m2 ; m3 = 4, 10, 16, 22, 5, 11, 17, 23
- movq [dstq ], m0
- movhps [dstq+dst1q], m0
- movq [dstq+dst2q], m1
- movhps [dstq+dst3q], m1
- movq [dstq+dst4q], m3
- movhps [dstq+dst5q], m3
- add srcq, mmsize*6
- add dstq, mmsize/2
- sub lend, mmsize/4
- jg .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-CONV_FLT_TO_S16P_6CH
-INIT_XMM ssse3
-CONV_FLT_TO_S16P_6CH
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-CONV_FLT_TO_S16P_6CH
-%endif
-
-;------------------------------------------------------------------------------
-; void ff_conv_flt_to_fltp_2ch(float *const *dst, float *src, int len,
-; int channels);
-;------------------------------------------------------------------------------
-
-%macro CONV_FLT_TO_FLTP_2CH 0
-cglobal conv_flt_to_fltp_2ch, 3,4,3, dst0, src, len, dst1
- lea lenq, [4*lend]
- mov dst1q, [dst0q+gprsize]
- mov dst0q, [dst0q ]
- lea srcq, [srcq+2*lenq]
- add dst0q, lenq
- add dst1q, lenq
- neg lenq
-.loop:
- mova m0, [srcq+2*lenq ]
- mova m1, [srcq+2*lenq+mmsize]
- DEINT2_PS 0, 1, 2
- mova [dst0q+lenq], m0
- mova [dst1q+lenq], m1
- add lenq, mmsize
- jl .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse
-CONV_FLT_TO_FLTP_2CH
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-CONV_FLT_TO_FLTP_2CH
-%endif
-
-;------------------------------------------------------------------------------
-; void ff_conv_flt_to_fltp_6ch(float *const *dst, float *src, int len,
-; int channels);
-;------------------------------------------------------------------------------
-
-%macro CONV_FLT_TO_FLTP_6CH 0
-%if ARCH_X86_64
-cglobal conv_flt_to_fltp_6ch, 3,8,7, dst, src, len, dst1, dst2, dst3, dst4, dst5
-%else
-cglobal conv_flt_to_fltp_6ch, 2,7,7, dst, src, dst1, dst2, dst3, dst4, dst5
-%define lend dword r2m
-%endif
- mov dst1q, [dstq+ gprsize]
- mov dst2q, [dstq+2*gprsize]
- mov dst3q, [dstq+3*gprsize]
- mov dst4q, [dstq+4*gprsize]
- mov dst5q, [dstq+5*gprsize]
- mov dstq, [dstq ]
- sub dst1q, dstq
- sub dst2q, dstq
- sub dst3q, dstq
- sub dst4q, dstq
- sub dst5q, dstq
-.loop:
- mova m0, [srcq+0*mmsize] ; m0 = 0, 1, 2, 3
- mova m1, [srcq+1*mmsize] ; m1 = 4, 5, 6, 7
- mova m2, [srcq+2*mmsize] ; m2 = 8, 9, 10, 11
- mova m3, [srcq+3*mmsize] ; m3 = 12, 13, 14, 15
- mova m4, [srcq+4*mmsize] ; m4 = 16, 17, 18, 19
- mova m5, [srcq+5*mmsize] ; m5 = 20, 21, 22, 23
-
- SBUTTERFLY2 dq, 0, 3, 6 ; m0 = 0, 12, 1, 13
- ; m3 = 2, 14, 3, 15
- SBUTTERFLY2 dq, 1, 4, 6 ; m1 = 4, 16, 5, 17
- ; m4 = 6, 18, 7, 19
- SBUTTERFLY2 dq, 2, 5, 6 ; m2 = 8, 20, 9, 21
- ; m5 = 10, 22, 11, 23
- SBUTTERFLY2 dq, 0, 4, 6 ; m0 = 0, 6, 12, 18
- ; m4 = 1, 7, 13, 19
- SBUTTERFLY2 dq, 3, 2, 6 ; m3 = 2, 8, 14, 20
- ; m2 = 3, 9, 15, 21
- SBUTTERFLY2 dq, 1, 5, 6 ; m1 = 4, 10, 16, 22
- ; m5 = 5, 11, 17, 23
- mova [dstq ], m0
- mova [dstq+dst1q], m4
- mova [dstq+dst2q], m3
- mova [dstq+dst3q], m2
- mova [dstq+dst4q], m1
- mova [dstq+dst5q], m5
- add srcq, mmsize*6
- add dstq, mmsize
- sub lend, mmsize/4
- jg .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-CONV_FLT_TO_FLTP_6CH
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-CONV_FLT_TO_FLTP_6CH
-%endif
diff --git a/src/thirdparty/ffmpeg/libavresample/x86/audio_convert_init.c b/src/thirdparty/ffmpeg/libavresample/x86/audio_convert_init.c
deleted file mode 100644
index 879108dff..000000000
--- a/src/thirdparty/ffmpeg/libavresample/x86/audio_convert_init.c
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "config.h"
-#include "libavutil/cpu.h"
-#include "libavutil/x86/cpu.h"
-#include "libavresample/audio_convert.h"
-
-/* flat conversions */
-
-extern void ff_conv_s16_to_s32_sse2(int16_t *dst, const int32_t *src, int len);
-
-extern void ff_conv_s16_to_flt_sse2(float *dst, const int16_t *src, int len);
-extern void ff_conv_s16_to_flt_sse4(float *dst, const int16_t *src, int len);
-
-extern void ff_conv_s32_to_s16_mmx (int16_t *dst, const int32_t *src, int len);
-extern void ff_conv_s32_to_s16_sse2(int16_t *dst, const int32_t *src, int len);
-
-extern void ff_conv_s32_to_flt_sse2(float *dst, const int32_t *src, int len);
-extern void ff_conv_s32_to_flt_avx (float *dst, const int32_t *src, int len);
-
-extern void ff_conv_flt_to_s16_sse2(int16_t *dst, const float *src, int len);
-
-extern void ff_conv_flt_to_s32_sse2(int32_t *dst, const float *src, int len);
-extern void ff_conv_flt_to_s32_avx (int32_t *dst, const float *src, int len);
-
-/* interleave conversions */
-
-extern void ff_conv_s16p_to_s16_2ch_sse2(int16_t *dst, int16_t *const *src,
- int len, int channels);
-extern void ff_conv_s16p_to_s16_2ch_avx (int16_t *dst, int16_t *const *src,
- int len, int channels);
-
-extern void ff_conv_s16p_to_s16_6ch_sse2(int16_t *dst, int16_t *const *src,
- int len, int channels);
-extern void ff_conv_s16p_to_s16_6ch_sse2slow(int16_t *dst, int16_t *const *src,
- int len, int channels);
-extern void ff_conv_s16p_to_s16_6ch_avx (int16_t *dst, int16_t *const *src,
- int len, int channels);
-
-extern void ff_conv_s16p_to_flt_2ch_sse2(float *dst, int16_t *const *src,
- int len, int channels);
-extern void ff_conv_s16p_to_flt_2ch_avx (float *dst, int16_t *const *src,
- int len, int channels);
-
-extern void ff_conv_s16p_to_flt_6ch_sse2 (float *dst, int16_t *const *src,
- int len, int channels);
-extern void ff_conv_s16p_to_flt_6ch_ssse3(float *dst, int16_t *const *src,
- int len, int channels);
-extern void ff_conv_s16p_to_flt_6ch_avx (float *dst, int16_t *const *src,
- int len, int channels);
-
-extern void ff_conv_fltp_to_s16_2ch_sse2 (int16_t *dst, float *const *src,
- int len, int channels);
-extern void ff_conv_fltp_to_s16_2ch_ssse3(int16_t *dst, float *const *src,
- int len, int channels);
-
-extern void ff_conv_fltp_to_s16_6ch_sse (int16_t *dst, float *const *src,
- int len, int channels);
-extern void ff_conv_fltp_to_s16_6ch_sse2(int16_t *dst, float *const *src,
- int len, int channels);
-extern void ff_conv_fltp_to_s16_6ch_avx (int16_t *dst, float *const *src,
- int len, int channels);
-
-extern void ff_conv_fltp_to_flt_2ch_sse(float *dst, float *const *src, int len,
- int channels);
-extern void ff_conv_fltp_to_flt_2ch_avx(float *dst, float *const *src, int len,
- int channels);
-
-extern void ff_conv_fltp_to_flt_6ch_mmx (float *dst, float *const *src, int len,
- int channels);
-extern void ff_conv_fltp_to_flt_6ch_sse4(float *dst, float *const *src, int len,
- int channels);
-extern void ff_conv_fltp_to_flt_6ch_avx (float *dst, float *const *src, int len,
- int channels);
-
-/* deinterleave conversions */
-
-extern void ff_conv_s16_to_s16p_2ch_sse2(int16_t *const *dst, int16_t *src,
- int len, int channels);
-extern void ff_conv_s16_to_s16p_2ch_ssse3(int16_t *const *dst, int16_t *src,
- int len, int channels);
-extern void ff_conv_s16_to_s16p_2ch_avx (int16_t *const *dst, int16_t *src,
- int len, int channels);
-
-extern void ff_conv_s16_to_s16p_6ch_sse2 (int16_t *const *dst, int16_t *src,
- int len, int channels);
-extern void ff_conv_s16_to_s16p_6ch_ssse3(int16_t *const *dst, int16_t *src,
- int len, int channels);
-extern void ff_conv_s16_to_s16p_6ch_avx (int16_t *const *dst, int16_t *src,
- int len, int channels);
-
-extern void ff_conv_s16_to_fltp_2ch_sse2(float *const *dst, int16_t *src,
- int len, int channels);
-extern void ff_conv_s16_to_fltp_2ch_avx (float *const *dst, int16_t *src,
- int len, int channels);
-
-extern void ff_conv_s16_to_fltp_6ch_sse2 (float *const *dst, int16_t *src,
- int len, int channels);
-extern void ff_conv_s16_to_fltp_6ch_ssse3(float *const *dst, int16_t *src,
- int len, int channels);
-extern void ff_conv_s16_to_fltp_6ch_sse4 (float *const *dst, int16_t *src,
- int len, int channels);
-extern void ff_conv_s16_to_fltp_6ch_avx (float *const *dst, int16_t *src,
- int len, int channels);
-
-extern void ff_conv_flt_to_s16p_2ch_sse2(int16_t *const *dst, float *src,
- int len, int channels);
-extern void ff_conv_flt_to_s16p_2ch_avx (int16_t *const *dst, float *src,
- int len, int channels);
-
-extern void ff_conv_flt_to_s16p_6ch_sse2 (int16_t *const *dst, float *src,
- int len, int channels);
-extern void ff_conv_flt_to_s16p_6ch_ssse3(int16_t *const *dst, float *src,
- int len, int channels);
-extern void ff_conv_flt_to_s16p_6ch_avx (int16_t *const *dst, float *src,
- int len, int channels);
-
-extern void ff_conv_flt_to_fltp_2ch_sse(float *const *dst, float *src, int len,
- int channels);
-extern void ff_conv_flt_to_fltp_2ch_avx(float *const *dst, float *src, int len,
- int channels);
-
-extern void ff_conv_flt_to_fltp_6ch_sse2(float *const *dst, float *src, int len,
- int channels);
-extern void ff_conv_flt_to_fltp_6ch_avx (float *const *dst, float *src, int len,
- int channels);
-
-av_cold void ff_audio_convert_init_x86(AudioConvert *ac)
-{
- int mm_flags = av_get_cpu_flags();
-
- if (EXTERNAL_MMX(mm_flags)) {
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32,
- 0, 1, 8, "MMX", ff_conv_s32_to_s16_mmx);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
- 6, 1, 4, "MMX", ff_conv_fltp_to_flt_6ch_mmx);
- }
- if (EXTERNAL_SSE(mm_flags)) {
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP,
- 6, 1, 2, "SSE", ff_conv_fltp_to_s16_6ch_sse);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
- 2, 16, 8, "SSE", ff_conv_fltp_to_flt_2ch_sse);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT,
- 2, 16, 4, "SSE", ff_conv_flt_to_fltp_2ch_sse);
- }
- if (EXTERNAL_SSE2(mm_flags)) {
- if (!(mm_flags & AV_CPU_FLAG_SSE2SLOW)) {
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32,
- 0, 16, 16, "SSE2", ff_conv_s32_to_s16_sse2);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P,
- 6, 16, 8, "SSE2", ff_conv_s16p_to_s16_6ch_sse2);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP,
- 6, 16, 4, "SSE2", ff_conv_fltp_to_s16_6ch_sse2);
- } else {
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P,
- 6, 1, 4, "SSE2SLOW", ff_conv_s16p_to_s16_6ch_sse2slow);
- }
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16,
- 0, 16, 8, "SSE2", ff_conv_s16_to_s32_sse2);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16,
- 0, 16, 8, "SSE2", ff_conv_s16_to_flt_sse2);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32,
- 0, 16, 8, "SSE2", ff_conv_s32_to_flt_sse2);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT,
- 0, 16, 16, "SSE2", ff_conv_flt_to_s16_sse2);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT,
- 0, 16, 16, "SSE2", ff_conv_flt_to_s32_sse2);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P,
- 2, 16, 16, "SSE2", ff_conv_s16p_to_s16_2ch_sse2);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16P,
- 2, 16, 8, "SSE2", ff_conv_s16p_to_flt_2ch_sse2);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16P,
- 6, 16, 4, "SSE2", ff_conv_s16p_to_flt_6ch_sse2);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP,
- 2, 16, 4, "SSE2", ff_conv_fltp_to_s16_2ch_sse2);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16,
- 2, 16, 8, "SSE2", ff_conv_s16_to_s16p_2ch_sse2);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16,
- 6, 16, 4, "SSE2", ff_conv_s16_to_s16p_6ch_sse2);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16,
- 2, 16, 8, "SSE2", ff_conv_s16_to_fltp_2ch_sse2);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16,
- 6, 16, 4, "SSE2", ff_conv_s16_to_fltp_6ch_sse2);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_FLT,
- 2, 16, 8, "SSE2", ff_conv_flt_to_s16p_2ch_sse2);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_FLT,
- 6, 16, 4, "SSE2", ff_conv_flt_to_s16p_6ch_sse2);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT,
- 6, 16, 4, "SSE2", ff_conv_flt_to_fltp_6ch_sse2);
- }
- if (EXTERNAL_SSSE3(mm_flags)) {
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16P,
- 6, 16, 4, "SSSE3", ff_conv_s16p_to_flt_6ch_ssse3);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP,
- 2, 16, 4, "SSSE3", ff_conv_fltp_to_s16_2ch_ssse3);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16,
- 2, 16, 8, "SSSE3", ff_conv_s16_to_s16p_2ch_ssse3);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16,
- 6, 16, 4, "SSSE3", ff_conv_s16_to_s16p_6ch_ssse3);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16,
- 6, 16, 4, "SSSE3", ff_conv_s16_to_fltp_6ch_ssse3);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_FLT,
- 6, 16, 4, "SSSE3", ff_conv_flt_to_s16p_6ch_ssse3);
- }
- if (EXTERNAL_SSE4(mm_flags)) {
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16,
- 0, 16, 8, "SSE4", ff_conv_s16_to_flt_sse4);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
- 6, 16, 4, "SSE4", ff_conv_fltp_to_flt_6ch_sse4);
- }
- if (EXTERNAL_AVX(mm_flags)) {
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32,
- 0, 32, 16, "AVX", ff_conv_s32_to_flt_avx);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT,
- 0, 32, 32, "AVX", ff_conv_flt_to_s32_avx);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P,
- 2, 16, 16, "AVX", ff_conv_s16p_to_s16_2ch_avx);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P,
- 6, 16, 8, "AVX", ff_conv_s16p_to_s16_6ch_avx);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16P,
- 2, 16, 8, "AVX", ff_conv_s16p_to_flt_2ch_avx);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16P,
- 6, 16, 4, "AVX", ff_conv_s16p_to_flt_6ch_avx);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLTP,
- 6, 16, 4, "AVX", ff_conv_fltp_to_s16_6ch_avx);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
- 6, 16, 4, "AVX", ff_conv_fltp_to_flt_6ch_avx);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16,
- 2, 16, 8, "AVX", ff_conv_s16_to_s16p_2ch_avx);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S16,
- 6, 16, 4, "AVX", ff_conv_s16_to_s16p_6ch_avx);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16,
- 2, 16, 8, "AVX", ff_conv_s16_to_fltp_2ch_avx);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_S16,
- 6, 16, 4, "AVX", ff_conv_s16_to_fltp_6ch_avx);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_FLT,
- 2, 16, 8, "AVX", ff_conv_flt_to_s16p_2ch_avx);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_FLT,
- 6, 16, 4, "AVX", ff_conv_flt_to_s16p_6ch_avx);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT,
- 2, 16, 4, "AVX", ff_conv_flt_to_fltp_2ch_avx);
- ff_audio_convert_set_func(ac, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_FLT,
- 6, 16, 4, "AVX", ff_conv_flt_to_fltp_6ch_avx);
- }
-}
diff --git a/src/thirdparty/ffmpeg/libavresample/x86/audio_mix.asm b/src/thirdparty/ffmpeg/libavresample/x86/audio_mix.asm
deleted file mode 100644
index 935359300..000000000
--- a/src/thirdparty/ffmpeg/libavresample/x86/audio_mix.asm
+++ /dev/null
@@ -1,511 +0,0 @@
-;******************************************************************************
-;* x86 optimized channel mixing
-;* Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
-;*
-;* This file is part of Libav.
-;*
-;* Libav is free software; you can redistribute it and/or
-;* modify it under the terms of the GNU Lesser General Public
-;* License as published by the Free Software Foundation; either
-;* version 2.1 of the License, or (at your option) any later version.
-;*
-;* Libav is distributed in the hope that it will be useful,
-;* but WITHOUT ANY WARRANTY; without even the implied warranty of
-;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-;* Lesser General Public License for more details.
-;*
-;* You should have received a copy of the GNU Lesser General Public
-;* License along with Libav; if not, write to the Free Software
-;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-;******************************************************************************
-
-%include "libavutil/x86/x86util.asm"
-%include "util.asm"
-
-SECTION_TEXT
-
-;-----------------------------------------------------------------------------
-; void ff_mix_2_to_1_fltp_flt(float **src, float **matrix, int len,
-; int out_ch, int in_ch);
-;-----------------------------------------------------------------------------
-
-%macro MIX_2_TO_1_FLTP_FLT 0
-cglobal mix_2_to_1_fltp_flt, 3,4,6, src, matrix, len, src1
- mov src1q, [srcq+gprsize]
- mov srcq, [srcq ]
- sub src1q, srcq
- mov matrixq, [matrixq ]
- VBROADCASTSS m4, [matrixq ]
- VBROADCASTSS m5, [matrixq+4]
- ALIGN 16
-.loop:
- mulps m0, m4, [srcq ]
- mulps m1, m5, [srcq+src1q ]
- mulps m2, m4, [srcq+ mmsize]
- mulps m3, m5, [srcq+src1q+mmsize]
- addps m0, m0, m1
- addps m2, m2, m3
- mova [srcq ], m0
- mova [srcq+mmsize], m2
- add srcq, mmsize*2
- sub lend, mmsize*2/4
- jg .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse
-MIX_2_TO_1_FLTP_FLT
-%if HAVE_AVX_EXTERNAL
-INIT_YMM avx
-MIX_2_TO_1_FLTP_FLT
-%endif
-
-;-----------------------------------------------------------------------------
-; void ff_mix_2_to_1_s16p_flt(int16_t **src, float **matrix, int len,
-; int out_ch, int in_ch);
-;-----------------------------------------------------------------------------
-
-%macro MIX_2_TO_1_S16P_FLT 0
-cglobal mix_2_to_1_s16p_flt, 3,4,6, src, matrix, len, src1
- mov src1q, [srcq+gprsize]
- mov srcq, [srcq]
- sub src1q, srcq
- mov matrixq, [matrixq ]
- VBROADCASTSS m4, [matrixq ]
- VBROADCASTSS m5, [matrixq+4]
- ALIGN 16
-.loop:
- mova m0, [srcq ]
- mova m2, [srcq+src1q]
- S16_TO_S32_SX 0, 1
- S16_TO_S32_SX 2, 3
- cvtdq2ps m0, m0
- cvtdq2ps m1, m1
- cvtdq2ps m2, m2
- cvtdq2ps m3, m3
- mulps m0, m4
- mulps m1, m4
- mulps m2, m5
- mulps m3, m5
- addps m0, m2
- addps m1, m3
- cvtps2dq m0, m0
- cvtps2dq m1, m1
- packssdw m0, m1
- mova [srcq], m0
- add srcq, mmsize
- sub lend, mmsize/2
- jg .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-MIX_2_TO_1_S16P_FLT
-INIT_XMM sse4
-MIX_2_TO_1_S16P_FLT
-
-;-----------------------------------------------------------------------------
-; void ff_mix_2_to_1_s16p_q8(int16_t **src, int16_t **matrix, int len,
-; int out_ch, int in_ch);
-;-----------------------------------------------------------------------------
-
-INIT_XMM sse2
-cglobal mix_2_to_1_s16p_q8, 3,4,6, src, matrix, len, src1
- mov src1q, [srcq+gprsize]
- mov srcq, [srcq]
- sub src1q, srcq
- mov matrixq, [matrixq]
- movd m4, [matrixq]
- movd m5, [matrixq]
- SPLATW m4, m4, 0
- SPLATW m5, m5, 1
- pxor m0, m0
- punpcklwd m4, m0
- punpcklwd m5, m0
- ALIGN 16
-.loop:
- mova m0, [srcq ]
- mova m2, [srcq+src1q]
- punpckhwd m1, m0, m0
- punpcklwd m0, m0
- punpckhwd m3, m2, m2
- punpcklwd m2, m2
- pmaddwd m0, m4
- pmaddwd m1, m4
- pmaddwd m2, m5
- pmaddwd m3, m5
- paddd m0, m2
- paddd m1, m3
- psrad m0, 8
- psrad m1, 8
- packssdw m0, m1
- mova [srcq], m0
- add srcq, mmsize
- sub lend, mmsize/2
- jg .loop
- REP_RET
-
-;-----------------------------------------------------------------------------
-; void ff_mix_1_to_2_fltp_flt(float **src, float **matrix, int len,
-; int out_ch, int in_ch);
-;-----------------------------------------------------------------------------
-
-%macro MIX_1_TO_2_FLTP_FLT 0
-cglobal mix_1_to_2_fltp_flt, 3,5,4, src0, matrix0, len, src1, matrix1
- mov src1q, [src0q+gprsize]
- mov src0q, [src0q]
- sub src1q, src0q
- mov matrix1q, [matrix0q+gprsize]
- mov matrix0q, [matrix0q]
- VBROADCASTSS m2, [matrix0q]
- VBROADCASTSS m3, [matrix1q]
- ALIGN 16
-.loop:
- mova m0, [src0q]
- mulps m1, m0, m3
- mulps m0, m0, m2
- mova [src0q ], m0
- mova [src0q+src1q], m1
- add src0q, mmsize
- sub lend, mmsize/4
- jg .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse
-MIX_1_TO_2_FLTP_FLT
-%if HAVE_AVX_EXTERNAL
-INIT_YMM avx
-MIX_1_TO_2_FLTP_FLT
-%endif
-
-;-----------------------------------------------------------------------------
-; void ff_mix_1_to_2_s16p_flt(int16_t **src, float **matrix, int len,
-; int out_ch, int in_ch);
-;-----------------------------------------------------------------------------
-
-%macro MIX_1_TO_2_S16P_FLT 0
-cglobal mix_1_to_2_s16p_flt, 3,5,6, src0, matrix0, len, src1, matrix1
- mov src1q, [src0q+gprsize]
- mov src0q, [src0q]
- sub src1q, src0q
- mov matrix1q, [matrix0q+gprsize]
- mov matrix0q, [matrix0q]
- VBROADCASTSS m4, [matrix0q]
- VBROADCASTSS m5, [matrix1q]
- ALIGN 16
-.loop:
- mova m0, [src0q]
- S16_TO_S32_SX 0, 2
- cvtdq2ps m0, m0
- cvtdq2ps m2, m2
- mulps m1, m0, m5
- mulps m0, m0, m4
- mulps m3, m2, m5
- mulps m2, m2, m4
- cvtps2dq m0, m0
- cvtps2dq m1, m1
- cvtps2dq m2, m2
- cvtps2dq m3, m3
- packssdw m0, m2
- packssdw m1, m3
- mova [src0q ], m0
- mova [src0q+src1q], m1
- add src0q, mmsize
- sub lend, mmsize/2
- jg .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-MIX_1_TO_2_S16P_FLT
-INIT_XMM sse4
-MIX_1_TO_2_S16P_FLT
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-MIX_1_TO_2_S16P_FLT
-%endif
-
-;-----------------------------------------------------------------------------
-; void ff_mix_3_8_to_1_2_fltp/s16p_flt(float/int16_t **src, float **matrix,
-; int len, int out_ch, int in_ch);
-;-----------------------------------------------------------------------------
-
-%macro MIX_3_8_TO_1_2_FLT 3 ; %1 = in channels, %2 = out channels, %3 = s16p or fltp
-; define some names to make the code clearer
-%assign in_channels %1
-%assign out_channels %2
-%assign stereo out_channels - 1
-%ifidn %3, s16p
- %assign is_s16 1
-%else
- %assign is_s16 0
-%endif
-
-; determine how many matrix elements must go on the stack vs. mmregs
-%assign matrix_elements in_channels * out_channels
-%if is_s16
- %if stereo
- %assign needed_mmregs 7
- %else
- %assign needed_mmregs 5
- %endif
-%else
- %if stereo
- %assign needed_mmregs 4
- %else
- %assign needed_mmregs 3
- %endif
-%endif
-%assign matrix_elements_mm num_mmregs - needed_mmregs
-%if matrix_elements < matrix_elements_mm
- %assign matrix_elements_mm matrix_elements
-%endif
-%if matrix_elements_mm < matrix_elements
- %assign matrix_elements_stack matrix_elements - matrix_elements_mm
-%else
- %assign matrix_elements_stack 0
-%endif
-%assign matrix_stack_size matrix_elements_stack * mmsize
-
-%assign needed_stack_size -1 * matrix_stack_size
-%if ARCH_X86_32 && in_channels >= 7
-%assign needed_stack_size needed_stack_size - 16
-%endif
-
-cglobal mix_%1_to_%2_%3_flt, 3,in_channels+2,needed_mmregs+matrix_elements_mm, needed_stack_size, src0, src1, len, src2, src3, src4, src5, src6, src7
-
-; define src pointers on stack if needed
-%if matrix_elements_stack > 0 && ARCH_X86_32 && in_channels >= 7
- %define src5m [rsp+matrix_stack_size+0]
- %define src6m [rsp+matrix_stack_size+4]
- %define src7m [rsp+matrix_stack_size+8]
-%endif
-
-; load matrix pointers
-%define matrix0q r1q
-%define matrix1q r3q
-%if stereo
- mov matrix1q, [matrix0q+gprsize]
-%endif
- mov matrix0q, [matrix0q]
-
-; define matrix coeff names
-%assign %%i 0
-%assign %%j needed_mmregs
-%rep in_channels
- %if %%i >= matrix_elements_mm
- CAT_XDEFINE mx_stack_0_, %%i, 1
- CAT_XDEFINE mx_0_, %%i, [rsp+(%%i-matrix_elements_mm)*mmsize]
- %else
- CAT_XDEFINE mx_stack_0_, %%i, 0
- CAT_XDEFINE mx_0_, %%i, m %+ %%j
- %assign %%j %%j+1
- %endif
- %assign %%i %%i+1
-%endrep
-%if stereo
-%assign %%i 0
-%rep in_channels
- %if in_channels + %%i >= matrix_elements_mm
- CAT_XDEFINE mx_stack_1_, %%i, 1
- CAT_XDEFINE mx_1_, %%i, [rsp+(in_channels+%%i-matrix_elements_mm)*mmsize]
- %else
- CAT_XDEFINE mx_stack_1_, %%i, 0
- CAT_XDEFINE mx_1_, %%i, m %+ %%j
- %assign %%j %%j+1
- %endif
- %assign %%i %%i+1
-%endrep
-%endif
-
-; load/splat matrix coeffs
-%assign %%i 0
-%rep in_channels
- %if mx_stack_0_ %+ %%i
- VBROADCASTSS m0, [matrix0q+4*%%i]
- mova mx_0_ %+ %%i, m0
- %else
- VBROADCASTSS mx_0_ %+ %%i, [matrix0q+4*%%i]
- %endif
- %if stereo
- %if mx_stack_1_ %+ %%i
- VBROADCASTSS m0, [matrix1q+4*%%i]
- mova mx_1_ %+ %%i, m0
- %else
- VBROADCASTSS mx_1_ %+ %%i, [matrix1q+4*%%i]
- %endif
- %endif
- %assign %%i %%i+1
-%endrep
-
-; load channel pointers to registers as offsets from the first channel pointer
-%if ARCH_X86_64
- movsxd lenq, r2d
-%endif
- shl lenq, 2-is_s16
-%assign %%i 1
-%rep (in_channels - 1)
- %if ARCH_X86_32 && in_channels >= 7 && %%i >= 5
- mov src5q, [src0q+%%i*gprsize]
- add src5q, lenq
- mov src %+ %%i %+ m, src5q
- %else
- mov src %+ %%i %+ q, [src0q+%%i*gprsize]
- add src %+ %%i %+ q, lenq
- %endif
- %assign %%i %%i+1
-%endrep
- mov src0q, [src0q]
- add src0q, lenq
- neg lenq
-.loop:
-; for x86-32 with 7-8 channels we do not have enough gp registers for all src
-; pointers, so we have to load some of them from the stack each time
-%define copy_src_from_stack ARCH_X86_32 && in_channels >= 7 && %%i >= 5
-%if is_s16
- ; mix with s16p input
- mova m0, [src0q+lenq]
- S16_TO_S32_SX 0, 1
- cvtdq2ps m0, m0
- cvtdq2ps m1, m1
- %if stereo
- mulps m2, m0, mx_1_0
- mulps m3, m1, mx_1_0
- %endif
- mulps m0, m0, mx_0_0
- mulps m1, m1, mx_0_0
-%assign %%i 1
-%rep (in_channels - 1)
- %if copy_src_from_stack
- %define src_ptr src5q
- %else
- %define src_ptr src %+ %%i %+ q
- %endif
- %if stereo
- %if copy_src_from_stack
- mov src_ptr, src %+ %%i %+ m
- %endif
- mova m4, [src_ptr+lenq]
- S16_TO_S32_SX 4, 5
- cvtdq2ps m4, m4
- cvtdq2ps m5, m5
- fmaddps m2, m4, mx_1_ %+ %%i, m2, m6
- fmaddps m3, m5, mx_1_ %+ %%i, m3, m6
- fmaddps m0, m4, mx_0_ %+ %%i, m0, m4
- fmaddps m1, m5, mx_0_ %+ %%i, m1, m5
- %else
- %if copy_src_from_stack
- mov src_ptr, src %+ %%i %+ m
- %endif
- mova m2, [src_ptr+lenq]
- S16_TO_S32_SX 2, 3
- cvtdq2ps m2, m2
- cvtdq2ps m3, m3
- fmaddps m0, m2, mx_0_ %+ %%i, m0, m4
- fmaddps m1, m3, mx_0_ %+ %%i, m1, m4
- %endif
- %assign %%i %%i+1
-%endrep
- %if stereo
- cvtps2dq m2, m2
- cvtps2dq m3, m3
- packssdw m2, m3
- mova [src1q+lenq], m2
- %endif
- cvtps2dq m0, m0
- cvtps2dq m1, m1
- packssdw m0, m1
- mova [src0q+lenq], m0
-%else
- ; mix with fltp input
- %if stereo || mx_stack_0_0
- mova m0, [src0q+lenq]
- %endif
- %if stereo
- mulps m1, m0, mx_1_0
- %endif
- %if stereo || mx_stack_0_0
- mulps m0, m0, mx_0_0
- %else
- mulps m0, [src0q+lenq], mx_0_0
- %endif
-%assign %%i 1
-%rep (in_channels - 1)
- %if copy_src_from_stack
- %define src_ptr src5q
- mov src_ptr, src %+ %%i %+ m
- %else
- %define src_ptr src %+ %%i %+ q
- %endif
- ; avoid extra load for mono if matrix is in a mm register
- %if stereo || mx_stack_0_ %+ %%i
- mova m2, [src_ptr+lenq]
- %endif
- %if stereo
- fmaddps m1, m2, mx_1_ %+ %%i, m1, m3
- %endif
- %if stereo || mx_stack_0_ %+ %%i
- fmaddps m0, m2, mx_0_ %+ %%i, m0, m2
- %else
- fmaddps m0, mx_0_ %+ %%i, [src_ptr+lenq], m0, m1
- %endif
- %assign %%i %%i+1
-%endrep
- mova [src0q+lenq], m0
- %if stereo
- mova [src1q+lenq], m1
- %endif
-%endif
-
- add lenq, mmsize
- jl .loop
-; zero ymm high halves
-%if mmsize == 32
- vzeroupper
-%endif
- RET
-%endmacro
-
-%macro MIX_3_8_TO_1_2_FLT_FUNCS 0
-%assign %%i 3
-%rep 6
- INIT_XMM sse
- MIX_3_8_TO_1_2_FLT %%i, 1, fltp
- MIX_3_8_TO_1_2_FLT %%i, 2, fltp
- INIT_XMM sse2
- MIX_3_8_TO_1_2_FLT %%i, 1, s16p
- MIX_3_8_TO_1_2_FLT %%i, 2, s16p
- INIT_XMM sse4
- MIX_3_8_TO_1_2_FLT %%i, 1, s16p
- MIX_3_8_TO_1_2_FLT %%i, 2, s16p
- ; do not use ymm AVX or FMA4 in x86-32 for 6 or more channels due to stack alignment issues
- %if HAVE_AVX_EXTERNAL
- %if ARCH_X86_64 || %%i < 6
- INIT_YMM avx
- %else
- INIT_XMM avx
- %endif
- MIX_3_8_TO_1_2_FLT %%i, 1, fltp
- MIX_3_8_TO_1_2_FLT %%i, 2, fltp
- INIT_XMM avx
- MIX_3_8_TO_1_2_FLT %%i, 1, s16p
- MIX_3_8_TO_1_2_FLT %%i, 2, s16p
- %endif
- %if HAVE_FMA4_EXTERNAL
- %if ARCH_X86_64 || %%i < 6
- INIT_YMM fma4
- %else
- INIT_XMM fma4
- %endif
- MIX_3_8_TO_1_2_FLT %%i, 1, fltp
- MIX_3_8_TO_1_2_FLT %%i, 2, fltp
- INIT_XMM fma4
- MIX_3_8_TO_1_2_FLT %%i, 1, s16p
- MIX_3_8_TO_1_2_FLT %%i, 2, s16p
- %endif
- %assign %%i %%i+1
-%endrep
-%endmacro
-
-MIX_3_8_TO_1_2_FLT_FUNCS
diff --git a/src/thirdparty/ffmpeg/libavresample/x86/audio_mix_init.c b/src/thirdparty/ffmpeg/libavresample/x86/audio_mix_init.c
deleted file mode 100644
index 72b2397ad..000000000
--- a/src/thirdparty/ffmpeg/libavresample/x86/audio_mix_init.c
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "config.h"
-#include "libavutil/cpu.h"
-#include "libavutil/x86/cpu.h"
-#include "libavresample/audio_mix.h"
-
-extern void ff_mix_2_to_1_fltp_flt_sse(float **src, float **matrix, int len,
- int out_ch, int in_ch);
-extern void ff_mix_2_to_1_fltp_flt_avx(float **src, float **matrix, int len,
- int out_ch, int in_ch);
-
-extern void ff_mix_2_to_1_s16p_flt_sse2(int16_t **src, float **matrix, int len,
- int out_ch, int in_ch);
-extern void ff_mix_2_to_1_s16p_flt_sse4(int16_t **src, float **matrix, int len,
- int out_ch, int in_ch);
-
-extern void ff_mix_2_to_1_s16p_q8_sse2(int16_t **src, int16_t **matrix,
- int len, int out_ch, int in_ch);
-
-extern void ff_mix_1_to_2_fltp_flt_sse(float **src, float **matrix, int len,
- int out_ch, int in_ch);
-extern void ff_mix_1_to_2_fltp_flt_avx(float **src, float **matrix, int len,
- int out_ch, int in_ch);
-
-extern void ff_mix_1_to_2_s16p_flt_sse2(int16_t **src, float **matrix, int len,
- int out_ch, int in_ch);
-extern void ff_mix_1_to_2_s16p_flt_sse4(int16_t **src, float **matrix, int len,
- int out_ch, int in_ch);
-extern void ff_mix_1_to_2_s16p_flt_avx (int16_t **src, float **matrix, int len,
- int out_ch, int in_ch);
-
-#define DEFINE_MIX_3_8_TO_1_2(chan) \
-extern void ff_mix_ ## chan ## _to_1_fltp_flt_sse(float **src, \
- float **matrix, int len, \
- int out_ch, int in_ch); \
-extern void ff_mix_ ## chan ## _to_2_fltp_flt_sse(float **src, \
- float **matrix, int len, \
- int out_ch, int in_ch); \
- \
-extern void ff_mix_ ## chan ## _to_1_s16p_flt_sse2(int16_t **src, \
- float **matrix, int len, \
- int out_ch, int in_ch); \
-extern void ff_mix_ ## chan ## _to_2_s16p_flt_sse2(int16_t **src, \
- float **matrix, int len, \
- int out_ch, int in_ch); \
- \
-extern void ff_mix_ ## chan ## _to_1_s16p_flt_sse4(int16_t **src, \
- float **matrix, int len, \
- int out_ch, int in_ch); \
-extern void ff_mix_ ## chan ## _to_2_s16p_flt_sse4(int16_t **src, \
- float **matrix, int len, \
- int out_ch, int in_ch); \
- \
-extern void ff_mix_ ## chan ## _to_1_fltp_flt_avx(float **src, \
- float **matrix, int len, \
- int out_ch, int in_ch); \
-extern void ff_mix_ ## chan ## _to_2_fltp_flt_avx(float **src, \
- float **matrix, int len, \
- int out_ch, int in_ch); \
- \
-extern void ff_mix_ ## chan ## _to_1_s16p_flt_avx(int16_t **src, \
- float **matrix, int len, \
- int out_ch, int in_ch); \
-extern void ff_mix_ ## chan ## _to_2_s16p_flt_avx(int16_t **src, \
- float **matrix, int len, \
- int out_ch, int in_ch); \
- \
-extern void ff_mix_ ## chan ## _to_1_fltp_flt_fma4(float **src, \
- float **matrix, int len, \
- int out_ch, int in_ch); \
-extern void ff_mix_ ## chan ## _to_2_fltp_flt_fma4(float **src, \
- float **matrix, int len, \
- int out_ch, int in_ch); \
- \
-extern void ff_mix_ ## chan ## _to_1_s16p_flt_fma4(int16_t **src, \
- float **matrix, int len, \
- int out_ch, int in_ch); \
-extern void ff_mix_ ## chan ## _to_2_s16p_flt_fma4(int16_t **src, \
- float **matrix, int len, \
- int out_ch, int in_ch);
-
-DEFINE_MIX_3_8_TO_1_2(3)
-DEFINE_MIX_3_8_TO_1_2(4)
-DEFINE_MIX_3_8_TO_1_2(5)
-DEFINE_MIX_3_8_TO_1_2(6)
-DEFINE_MIX_3_8_TO_1_2(7)
-DEFINE_MIX_3_8_TO_1_2(8)
-
-#define SET_MIX_3_8_TO_1_2(chan) \
- if (EXTERNAL_SSE(mm_flags)) { \
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,\
- chan, 1, 16, 4, "SSE", \
- ff_mix_ ## chan ## _to_1_fltp_flt_sse); \
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,\
- chan, 2, 16, 4, "SSE", \
- ff_mix_## chan ##_to_2_fltp_flt_sse); \
- } \
- if (EXTERNAL_SSE2(mm_flags)) { \
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,\
- chan, 1, 16, 8, "SSE2", \
- ff_mix_ ## chan ## _to_1_s16p_flt_sse2); \
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,\
- chan, 2, 16, 8, "SSE2", \
- ff_mix_ ## chan ## _to_2_s16p_flt_sse2); \
- } \
- if (EXTERNAL_SSE4(mm_flags)) { \
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,\
- chan, 1, 16, 8, "SSE4", \
- ff_mix_ ## chan ## _to_1_s16p_flt_sse4); \
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,\
- chan, 2, 16, 8, "SSE4", \
- ff_mix_ ## chan ## _to_2_s16p_flt_sse4); \
- } \
- if (EXTERNAL_AVX(mm_flags)) { \
- int ptr_align = 32; \
- int smp_align = 8; \
- if (ARCH_X86_32 || chan >= 6) { \
- ptr_align = 16; \
- smp_align = 4; \
- } \
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,\
- chan, 1, ptr_align, smp_align, "AVX", \
- ff_mix_ ## chan ## _to_1_fltp_flt_avx); \
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,\
- chan, 2, ptr_align, smp_align, "AVX", \
- ff_mix_ ## chan ## _to_2_fltp_flt_avx); \
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,\
- chan, 1, 16, 8, "AVX", \
- ff_mix_ ## chan ## _to_1_s16p_flt_avx); \
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,\
- chan, 2, 16, 8, "AVX", \
- ff_mix_ ## chan ## _to_2_s16p_flt_avx); \
- } \
- if (EXTERNAL_FMA4(mm_flags)) { \
- int ptr_align = 32; \
- int smp_align = 8; \
- if (ARCH_X86_32 || chan >= 6) { \
- ptr_align = 16; \
- smp_align = 4; \
- } \
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,\
- chan, 1, ptr_align, smp_align, "FMA4", \
- ff_mix_ ## chan ## _to_1_fltp_flt_fma4); \
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,\
- chan, 2, ptr_align, smp_align, "FMA4", \
- ff_mix_ ## chan ## _to_2_fltp_flt_fma4); \
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,\
- chan, 1, 16, 8, "FMA4", \
- ff_mix_ ## chan ## _to_1_s16p_flt_fma4); \
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,\
- chan, 2, 16, 8, "FMA4", \
- ff_mix_ ## chan ## _to_2_s16p_flt_fma4); \
- }
-
-av_cold void ff_audio_mix_init_x86(AudioMix *am)
-{
-#if HAVE_YASM
- int mm_flags = av_get_cpu_flags();
-
- if (EXTERNAL_SSE(mm_flags)) {
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,
- 2, 1, 16, 8, "SSE", ff_mix_2_to_1_fltp_flt_sse);
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,
- 1, 2, 16, 4, "SSE", ff_mix_1_to_2_fltp_flt_sse);
- }
- if (EXTERNAL_SSE2(mm_flags)) {
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,
- 2, 1, 16, 8, "SSE2", ff_mix_2_to_1_s16p_flt_sse2);
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_Q8,
- 2, 1, 16, 8, "SSE2", ff_mix_2_to_1_s16p_q8_sse2);
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,
- 1, 2, 16, 8, "SSE2", ff_mix_1_to_2_s16p_flt_sse2);
- }
- if (EXTERNAL_SSE4(mm_flags)) {
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,
- 2, 1, 16, 8, "SSE4", ff_mix_2_to_1_s16p_flt_sse4);
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,
- 1, 2, 16, 8, "SSE4", ff_mix_1_to_2_s16p_flt_sse4);
- }
- if (EXTERNAL_AVX(mm_flags)) {
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,
- 2, 1, 32, 16, "AVX", ff_mix_2_to_1_fltp_flt_avx);
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_FLTP, AV_MIX_COEFF_TYPE_FLT,
- 1, 2, 32, 8, "AVX", ff_mix_1_to_2_fltp_flt_avx);
- ff_audio_mix_set_func(am, AV_SAMPLE_FMT_S16P, AV_MIX_COEFF_TYPE_FLT,
- 1, 2, 16, 8, "AVX", ff_mix_1_to_2_s16p_flt_avx);
- }
-
- SET_MIX_3_8_TO_1_2(3)
- SET_MIX_3_8_TO_1_2(4)
- SET_MIX_3_8_TO_1_2(5)
- SET_MIX_3_8_TO_1_2(6)
- SET_MIX_3_8_TO_1_2(7)
- SET_MIX_3_8_TO_1_2(8)
-#endif /* HAVE_YASM */
-}
diff --git a/src/thirdparty/ffmpeg/libavresample/x86/dither.asm b/src/thirdparty/ffmpeg/libavresample/x86/dither.asm
deleted file mode 100644
index 757f2800b..000000000
--- a/src/thirdparty/ffmpeg/libavresample/x86/dither.asm
+++ /dev/null
@@ -1,117 +0,0 @@
-;******************************************************************************
-;* x86 optimized dithering format conversion
-;* Copyright (c) 2012 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
-;******************************************************************************
-
-%include "libavutil/x86/x86util.asm"
-
-SECTION_RODATA 32
-
-; 1.0f / (2.0f * INT32_MAX)
-pf_dither_scale: times 8 dd 2.32830643762e-10
-
-pf_s16_scale: times 4 dd 32753.0
-
-SECTION_TEXT
-
-;------------------------------------------------------------------------------
-; void ff_quantize(int16_t *dst, float *src, float *dither, int len);
-;------------------------------------------------------------------------------
-
-INIT_XMM sse2
-cglobal quantize, 4,4,3, dst, src, dither, len
- lea lenq, [2*lend]
- add dstq, lenq
- lea srcq, [srcq+2*lenq]
- lea ditherq, [ditherq+2*lenq]
- neg lenq
- mova m2, [pf_s16_scale]
-.loop:
- mulps m0, m2, [srcq+2*lenq]
- mulps m1, m2, [srcq+2*lenq+mmsize]
- addps m0, [ditherq+2*lenq]
- addps m1, [ditherq+2*lenq+mmsize]
- cvtps2dq m0, m0
- cvtps2dq m1, m1
- packssdw m0, m1
- mova [dstq+lenq], m0
- add lenq, mmsize
- jl .loop
- REP_RET
-
-;------------------------------------------------------------------------------
-; void ff_dither_int_to_float_rectangular(float *dst, int *src, int len)
-;------------------------------------------------------------------------------
-
-%macro DITHER_INT_TO_FLOAT_RECTANGULAR 0
-cglobal dither_int_to_float_rectangular, 3,3,3, dst, src, len
- lea lenq, [4*lend]
- add srcq, lenq
- add dstq, lenq
- neg lenq
- mova m0, [pf_dither_scale]
-.loop:
- cvtdq2ps m1, [srcq+lenq]
- cvtdq2ps m2, [srcq+lenq+mmsize]
- mulps m1, m1, m0
- mulps m2, m2, m0
- mova [dstq+lenq], m1
- mova [dstq+lenq+mmsize], m2
- add lenq, 2*mmsize
- jl .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-DITHER_INT_TO_FLOAT_RECTANGULAR
-INIT_YMM avx
-DITHER_INT_TO_FLOAT_RECTANGULAR
-
-;------------------------------------------------------------------------------
-; void ff_dither_int_to_float_triangular(float *dst, int *src0, int len)
-;------------------------------------------------------------------------------
-
-%macro DITHER_INT_TO_FLOAT_TRIANGULAR 0
-cglobal dither_int_to_float_triangular, 3,4,5, dst, src0, len, src1
- lea lenq, [4*lend]
- lea src1q, [src0q+2*lenq]
- add src0q, lenq
- add dstq, lenq
- neg lenq
- mova m0, [pf_dither_scale]
-.loop:
- cvtdq2ps m1, [src0q+lenq]
- cvtdq2ps m2, [src0q+lenq+mmsize]
- cvtdq2ps m3, [src1q+lenq]
- cvtdq2ps m4, [src1q+lenq+mmsize]
- addps m1, m1, m3
- addps m2, m2, m4
- mulps m1, m1, m0
- mulps m2, m2, m0
- mova [dstq+lenq], m1
- mova [dstq+lenq+mmsize], m2
- add lenq, 2*mmsize
- jl .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-DITHER_INT_TO_FLOAT_TRIANGULAR
-INIT_YMM avx
-DITHER_INT_TO_FLOAT_TRIANGULAR
diff --git a/src/thirdparty/ffmpeg/libavresample/x86/dither_init.c b/src/thirdparty/ffmpeg/libavresample/x86/dither_init.c
deleted file mode 100644
index 6532887c0..000000000
--- a/src/thirdparty/ffmpeg/libavresample/x86/dither_init.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2012 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
- */
-
-#include "config.h"
-#include "libavutil/cpu.h"
-#include "libavutil/x86/cpu.h"
-#include "libavresample/dither.h"
-
-extern void ff_quantize_sse2(int16_t *dst, const float *src, float *dither,
- int len);
-
-extern void ff_dither_int_to_float_rectangular_sse2(float *dst, int *src, int len);
-extern void ff_dither_int_to_float_rectangular_avx(float *dst, int *src, int len);
-
-extern void ff_dither_int_to_float_triangular_sse2(float *dst, int *src0, int len);
-extern void ff_dither_int_to_float_triangular_avx(float *dst, int *src0, int len);
-
-av_cold void ff_dither_init_x86(DitherDSPContext *ddsp,
- enum AVResampleDitherMethod method)
-{
- int mm_flags = av_get_cpu_flags();
-
- if (EXTERNAL_SSE2(mm_flags)) {
- ddsp->quantize = ff_quantize_sse2;
- ddsp->ptr_align = 16;
- ddsp->samples_align = 8;
- }
-
- if (method == AV_RESAMPLE_DITHER_RECTANGULAR) {
- if (EXTERNAL_SSE2(mm_flags)) {
- ddsp->dither_int_to_float = ff_dither_int_to_float_rectangular_sse2;
- }
- if (EXTERNAL_AVX(mm_flags)) {
- ddsp->dither_int_to_float = ff_dither_int_to_float_rectangular_avx;
- }
- } else {
- if (EXTERNAL_SSE2(mm_flags)) {
- ddsp->dither_int_to_float = ff_dither_int_to_float_triangular_sse2;
- }
- if (EXTERNAL_AVX(mm_flags)) {
- ddsp->dither_int_to_float = ff_dither_int_to_float_triangular_avx;
- }
- }
-}
diff --git a/src/thirdparty/ffmpeg/libavresample/x86/util.asm b/src/thirdparty/ffmpeg/libavresample/x86/util.asm
deleted file mode 100644
index 0ce953159..000000000
--- a/src/thirdparty/ffmpeg/libavresample/x86/util.asm
+++ /dev/null
@@ -1,41 +0,0 @@
-;******************************************************************************
-;* x86 utility macros for libavresample
-;* Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
-;*
-;* This file is part of Libav.
-;*
-;* Libav is free software; you can redistribute it and/or
-;* modify it under the terms of the GNU Lesser General Public
-;* License as published by the Free Software Foundation; either
-;* version 2.1 of the License, or (at your option) any later version.
-;*
-;* Libav is distributed in the hope that it will be useful,
-;* but WITHOUT ANY WARRANTY; without even the implied warranty of
-;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-;* Lesser General Public License for more details.
-;*
-;* You should have received a copy of the GNU Lesser General Public
-;* License along with Libav; if not, write to the Free Software
-;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-;******************************************************************************
-
-%macro S16_TO_S32_SX 2 ; src/low dst, high dst
-%if cpuflag(sse4)
- pmovsxwd m%2, m%1
- psrldq m%1, 8
- pmovsxwd m%1, m%1
- SWAP %1, %2
-%else
- mova m%2, m%1
- punpckhwd m%2, m%2
- punpcklwd m%1, m%1
- psrad m%2, 16
- psrad m%1, 16
-%endif
-%endmacro
-
-%macro DEINT2_PS 3 ; src0/even dst, src1/odd dst, temp
- shufps m%3, m%1, m%2, q3131
- shufps m%1, m%2, q2020
- SWAP %2,%3
-%endmacro
diff --git a/src/thirdparty/ffmpeg/libavutil/attributes.h b/src/thirdparty/ffmpeg/libavutil/attributes.h
deleted file mode 100644
index db875beef..000000000
--- a/src/thirdparty/ffmpeg/libavutil/attributes.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * copyright (c) 2006 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
- * Macro definitions for various function/variable attributes
- */
-
-#ifndef AVUTIL_ATTRIBUTES_H
-#define AVUTIL_ATTRIBUTES_H
-
-#ifdef __GNUC__
-# define AV_GCC_VERSION_AT_LEAST(x,y) (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y)
-#else
-# define AV_GCC_VERSION_AT_LEAST(x,y) 0
-#endif
-
-#ifndef av_always_inline
-#if AV_GCC_VERSION_AT_LEAST(3,1)
-# define av_always_inline __attribute__((always_inline)) inline
-#elif defined(_MSC_VER)
-# define av_always_inline __forceinline
-#else
-# define av_always_inline inline
-#endif
-#endif
-
-#ifndef av_extern_inline
-#if defined(__ICL) && __ICL >= 1210 || defined(__GNUC_STDC_INLINE__)
-# define av_extern_inline extern inline
-#else
-# define av_extern_inline inline
-#endif
-#endif
-
-#if AV_GCC_VERSION_AT_LEAST(3,1)
-# define av_noinline __attribute__((noinline))
-#else
-# define av_noinline
-#endif
-
-#if AV_GCC_VERSION_AT_LEAST(3,1)
-# define av_pure __attribute__((pure))
-#else
-# define av_pure
-#endif
-
-#ifndef av_restrict
-#define av_restrict restrict
-#endif
-
-#if AV_GCC_VERSION_AT_LEAST(2,6)
-# define av_const __attribute__((const))
-#else
-# define av_const
-#endif
-
-#if AV_GCC_VERSION_AT_LEAST(4,3)
-# define av_cold __attribute__((cold))
-#else
-# define av_cold
-#endif
-
-#if AV_GCC_VERSION_AT_LEAST(4,1)
-# define av_flatten __attribute__((flatten))
-#else
-# define av_flatten
-#endif
-
-#if AV_GCC_VERSION_AT_LEAST(3,1)
-# define attribute_deprecated __attribute__((deprecated))
-#else
-# define attribute_deprecated
-#endif
-
-/**
- * Disable warnings about deprecated features
- * This is useful for sections of code kept for backward compatibility and
- * scheduled for removal.
- */
-#ifndef AV_NOWARN_DEPRECATED
-#if AV_GCC_VERSION_AT_LEAST(4,6)
-# define AV_NOWARN_DEPRECATED(code) \
- _Pragma("GCC diagnostic push") \
- _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \
- code \
- _Pragma("GCC diagnostic pop")
-#else
-# define AV_NOWARN_DEPRECATED(code) code
-#endif
-#endif
-
-
-#if defined(__GNUC__)
-# define av_unused __attribute__((unused))
-#else
-# define av_unused
-#endif
-
-/**
- * Mark a variable as used and prevent the compiler from optimizing it
- * away. This is useful for variables accessed only from inline
- * assembler without the compiler being aware.
- */
-#if AV_GCC_VERSION_AT_LEAST(3,1)
-# define av_used __attribute__((used))
-#else
-# define av_used
-#endif
-
-#if AV_GCC_VERSION_AT_LEAST(3,3)
-# define av_alias __attribute__((may_alias))
-#else
-# define av_alias
-#endif
-
-#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__)
-# define av_uninit(x) x=x
-#else
-# define av_uninit(x) x
-#endif
-
-#ifdef __GNUC__
-# define av_builtin_constant_p __builtin_constant_p
-# define av_printf_format(fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos)))
-#else
-# define av_builtin_constant_p(x) 0
-# define av_printf_format(fmtpos, attrpos)
-#endif
-
-#if AV_GCC_VERSION_AT_LEAST(2,5)
-# define av_noreturn __attribute__((noreturn))
-#else
-# define av_noreturn
-#endif
-
-#endif /* AVUTIL_ATTRIBUTES_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/audio_fifo.c b/src/thirdparty/ffmpeg/libavutil/audio_fifo.c
deleted file mode 100644
index b562537cf..000000000
--- a/src/thirdparty/ffmpeg/libavutil/audio_fifo.c
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Audio FIFO
- * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * Audio FIFO
- */
-
-#include "avutil.h"
-#include "audio_fifo.h"
-#include "common.h"
-#include "fifo.h"
-#include "mem.h"
-#include "samplefmt.h"
-
-struct AVAudioFifo {
- AVFifoBuffer **buf; /**< single buffer for interleaved, per-channel buffers for planar */
- int nb_buffers; /**< number of buffers */
- int nb_samples; /**< number of samples currently in the FIFO */
- int allocated_samples; /**< current allocated size, in samples */
-
- int channels; /**< number of channels */
- enum AVSampleFormat sample_fmt; /**< sample format */
- int sample_size; /**< size, in bytes, of one sample in a buffer */
-};
-
-void av_audio_fifo_free(AVAudioFifo *af)
-{
- if (af) {
- if (af->buf) {
- int i;
- for (i = 0; i < af->nb_buffers; i++) {
- if (af->buf[i])
- av_fifo_free(af->buf[i]);
- }
- av_free(af->buf);
- }
- av_free(af);
- }
-}
-
-AVAudioFifo *av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels,
- int nb_samples)
-{
- AVAudioFifo *af;
- int buf_size, i;
-
- /* get channel buffer size (also validates parameters) */
- if (av_samples_get_buffer_size(&buf_size, channels, nb_samples, sample_fmt, 1) < 0)
- return NULL;
-
- af = av_mallocz(sizeof(*af));
- if (!af)
- return NULL;
-
- af->channels = channels;
- af->sample_fmt = sample_fmt;
- af->sample_size = buf_size / nb_samples;
- af->nb_buffers = av_sample_fmt_is_planar(sample_fmt) ? channels : 1;
-
- af->buf = av_mallocz(af->nb_buffers * sizeof(*af->buf));
- if (!af->buf)
- goto error;
-
- for (i = 0; i < af->nb_buffers; i++) {
- af->buf[i] = av_fifo_alloc(buf_size);
- if (!af->buf[i])
- goto error;
- }
- af->allocated_samples = nb_samples;
-
- return af;
-
-error:
- av_audio_fifo_free(af);
- return NULL;
-}
-
-int av_audio_fifo_realloc(AVAudioFifo *af, int nb_samples)
-{
- int i, ret, buf_size;
-
- if ((ret = av_samples_get_buffer_size(&buf_size, af->channels, nb_samples,
- af->sample_fmt, 1)) < 0)
- return ret;
-
- for (i = 0; i < af->nb_buffers; i++) {
- if ((ret = av_fifo_realloc2(af->buf[i], buf_size)) < 0)
- return ret;
- }
- af->allocated_samples = nb_samples;
- return 0;
-}
-
-int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples)
-{
- int i, ret, size;
-
- /* automatically reallocate buffers if needed */
- if (av_audio_fifo_space(af) < nb_samples) {
- int current_size = av_audio_fifo_size(af);
- /* check for integer overflow in new size calculation */
- if (INT_MAX / 2 - current_size < nb_samples)
- return AVERROR(EINVAL);
- /* reallocate buffers */
- if ((ret = av_audio_fifo_realloc(af, 2 * (current_size + nb_samples))) < 0)
- return ret;
- }
-
- size = nb_samples * af->sample_size;
- for (i = 0; i < af->nb_buffers; i++) {
- ret = av_fifo_generic_write(af->buf[i], data[i], size, NULL);
- if (ret != size)
- return AVERROR_BUG;
- }
- af->nb_samples += nb_samples;
-
- return nb_samples;
-}
-
-int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples)
-{
- int i, ret, size;
-
- if (nb_samples < 0)
- return AVERROR(EINVAL);
- nb_samples = FFMIN(nb_samples, af->nb_samples);
- if (!nb_samples)
- return 0;
-
- size = nb_samples * af->sample_size;
- for (i = 0; i < af->nb_buffers; i++) {
- if ((ret = av_fifo_generic_read(af->buf[i], data[i], size, NULL)) < 0)
- return AVERROR_BUG;
- }
- af->nb_samples -= nb_samples;
-
- return nb_samples;
-}
-
-int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples)
-{
- int i, size;
-
- if (nb_samples < 0)
- return AVERROR(EINVAL);
- nb_samples = FFMIN(nb_samples, af->nb_samples);
-
- if (nb_samples) {
- size = nb_samples * af->sample_size;
- for (i = 0; i < af->nb_buffers; i++)
- av_fifo_drain(af->buf[i], size);
- af->nb_samples -= nb_samples;
- }
- return 0;
-}
-
-void av_audio_fifo_reset(AVAudioFifo *af)
-{
- int i;
-
- for (i = 0; i < af->nb_buffers; i++)
- av_fifo_reset(af->buf[i]);
-
- af->nb_samples = 0;
-}
-
-int av_audio_fifo_size(AVAudioFifo *af)
-{
- return af->nb_samples;
-}
-
-int av_audio_fifo_space(AVAudioFifo *af)
-{
- return af->allocated_samples - af->nb_samples;
-}
diff --git a/src/thirdparty/ffmpeg/libavutil/audio_fifo.h b/src/thirdparty/ffmpeg/libavutil/audio_fifo.h
deleted file mode 100644
index 8c7638825..000000000
--- a/src/thirdparty/ffmpeg/libavutil/audio_fifo.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Audio FIFO
- * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * Audio FIFO Buffer
- */
-
-#ifndef AVUTIL_AUDIO_FIFO_H
-#define AVUTIL_AUDIO_FIFO_H
-
-#include "avutil.h"
-#include "fifo.h"
-#include "samplefmt.h"
-
-/**
- * @addtogroup lavu_audio
- * @{
- */
-
-/**
- * Context for an Audio FIFO Buffer.
- *
- * - Operates at the sample level rather than the byte level.
- * - Supports multiple channels with either planar or packed sample format.
- * - Automatic reallocation when writing to a full buffer.
- */
-typedef struct AVAudioFifo AVAudioFifo;
-
-/**
- * Free an AVAudioFifo.
- *
- * @param af AVAudioFifo to free
- */
-void av_audio_fifo_free(AVAudioFifo *af);
-
-/**
- * Allocate an AVAudioFifo.
- *
- * @param sample_fmt sample format
- * @param channels number of channels
- * @param nb_samples initial allocation size, in samples
- * @return newly allocated AVAudioFifo, or NULL on error
- */
-AVAudioFifo *av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels,
- int nb_samples);
-
-/**
- * Reallocate an AVAudioFifo.
- *
- * @param af AVAudioFifo to reallocate
- * @param nb_samples new allocation size, in samples
- * @return 0 if OK, or negative AVERROR code on failure
- */
-int av_audio_fifo_realloc(AVAudioFifo *af, int nb_samples);
-
-/**
- * Write data to an AVAudioFifo.
- *
- * The AVAudioFifo will be reallocated automatically if the available space
- * is less than nb_samples.
- *
- * @see enum AVSampleFormat
- * The documentation for AVSampleFormat describes the data layout.
- *
- * @param af AVAudioFifo to write to
- * @param data audio data plane pointers
- * @param nb_samples number of samples to write
- * @return number of samples actually written, or negative AVERROR
- * code on failure.
- */
-int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples);
-
-/**
- * Read data from an AVAudioFifo.
- *
- * @see enum AVSampleFormat
- * The documentation for AVSampleFormat describes the data layout.
- *
- * @param af AVAudioFifo to read from
- * @param data audio data plane pointers
- * @param nb_samples number of samples to read
- * @return number of samples actually read, or negative AVERROR code
- * on failure.
- */
-int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples);
-
-/**
- * Drain data from an AVAudioFifo.
- *
- * Removes the data without reading it.
- *
- * @param af AVAudioFifo to drain
- * @param nb_samples number of samples to drain
- * @return 0 if OK, or negative AVERROR code on failure
- */
-int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples);
-
-/**
- * Reset the AVAudioFifo buffer.
- *
- * This empties all data in the buffer.
- *
- * @param af AVAudioFifo to reset
- */
-void av_audio_fifo_reset(AVAudioFifo *af);
-
-/**
- * Get the current number of samples in the AVAudioFifo available for reading.
- *
- * @param af the AVAudioFifo to query
- * @return number of samples available for reading
- */
-int av_audio_fifo_size(AVAudioFifo *af);
-
-/**
- * Get the current number of samples in the AVAudioFifo available for writing.
- *
- * @param af the AVAudioFifo to query
- * @return number of samples available for writing
- */
-int av_audio_fifo_space(AVAudioFifo *af);
-
-/**
- * @}
- */
-
-#endif /* AVUTIL_AUDIO_FIFO_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/audioconvert.h b/src/thirdparty/ffmpeg/libavutil/audioconvert.h
deleted file mode 100644
index e48d97e4c..000000000
--- a/src/thirdparty/ffmpeg/libavutil/audioconvert.h
+++ /dev/null
@@ -1,6 +0,0 @@
-
-#include "version.h"
-
-#if FF_API_AUDIOCONVERT
-#include "channel_layout.h"
-#endif
diff --git a/src/thirdparty/ffmpeg/libavutil/avassert.h b/src/thirdparty/ffmpeg/libavutil/avassert.h
deleted file mode 100644
index a846c76d9..000000000
--- a/src/thirdparty/ffmpeg/libavutil/avassert.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * copyright (c) 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
- * simple assert() macros that are a bit more flexible than ISO C assert().
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#ifndef AVUTIL_AVASSERT_H
-#define AVUTIL_AVASSERT_H
-
-#include <stdlib.h>
-#include "avutil.h"
-#include "log.h"
-
-/**
- * assert() equivalent, that is always enabled.
- */
-#define av_assert0(cond) do { \
- if (!(cond)) { \
- av_log(NULL, AV_LOG_PANIC, "Assertion %s failed at %s:%d\n", \
- AV_STRINGIFY(cond), __FILE__, __LINE__); \
- abort(); \
- } \
-} while (0)
-
-
-/**
- * assert() equivalent, that does not lie in speed critical code.
- * These asserts() thus can be enabled without fearing speedloss.
- */
-#if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 0
-#define av_assert1(cond) av_assert0(cond)
-#else
-#define av_assert1(cond) ((void)0)
-#endif
-
-
-/**
- * assert() equivalent, that does lie in speed critical code.
- */
-#if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 1
-#define av_assert2(cond) av_assert0(cond)
-#else
-#define av_assert2(cond) ((void)0)
-#endif
-
-#endif /* AVUTIL_AVASSERT_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/avconfig.h b/src/thirdparty/ffmpeg/libavutil/avconfig.h
deleted file mode 100644
index 2ec333d15..000000000
--- a/src/thirdparty/ffmpeg/libavutil/avconfig.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Generated by ffconf */
-#ifndef AVUTIL_AVCONFIG_H
-#define AVUTIL_AVCONFIG_H
-#define AV_HAVE_BIGENDIAN 0
-#define AV_HAVE_FAST_UNALIGNED 1
-#define AV_HAVE_INCOMPATIBLE_FORK_ABI 0
-#endif /* AVUTIL_AVCONFIG_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/avstring.c b/src/thirdparty/ffmpeg/libavutil/avstring.c
deleted file mode 100644
index 7ddf92b08..000000000
--- a/src/thirdparty/ffmpeg/libavutil/avstring.c
+++ /dev/null
@@ -1,319 +0,0 @@
-/*
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
- * Copyright (c) 2007 Mans Rullgard
- *
- * 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 <stdarg.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-
-#include "config.h"
-#include "common.h"
-#include "mem.h"
-#include "avstring.h"
-
-int av_strstart(const char *str, const char *pfx, const char **ptr)
-{
- while (*pfx && *pfx == *str) {
- pfx++;
- str++;
- }
- if (!*pfx && ptr)
- *ptr = str;
- return !*pfx;
-}
-
-int av_stristart(const char *str, const char *pfx, const char **ptr)
-{
- while (*pfx && toupper((unsigned)*pfx) == toupper((unsigned)*str)) {
- pfx++;
- str++;
- }
- if (!*pfx && ptr)
- *ptr = str;
- return !*pfx;
-}
-
-char *av_stristr(const char *s1, const char *s2)
-{
- if (!*s2)
- return (char*)(intptr_t)s1;
-
- do
- if (av_stristart(s1, s2, NULL))
- return (char*)(intptr_t)s1;
- while (*s1++);
-
- return NULL;
-}
-
-char *av_strnstr(const char *haystack, const char *needle, size_t hay_length)
-{
- size_t needle_len = strlen(needle);
- if (!needle_len)
- return (char*)haystack;
- while (hay_length >= needle_len) {
- hay_length--;
- if (!memcmp(haystack, needle, needle_len))
- return (char*)haystack;
- haystack++;
- }
- return NULL;
-}
-
-size_t av_strlcpy(char *dst, const char *src, size_t size)
-{
- size_t len = 0;
- while (++len < size && *src)
- *dst++ = *src++;
- if (len <= size)
- *dst = 0;
- return len + strlen(src) - 1;
-}
-
-size_t av_strlcat(char *dst, const char *src, size_t size)
-{
- size_t len = strlen(dst);
- if (size <= len + 1)
- return len + strlen(src);
- return len + av_strlcpy(dst + len, src, size - len);
-}
-
-size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...)
-{
- int len = strlen(dst);
- va_list vl;
-
- va_start(vl, fmt);
- len += vsnprintf(dst + len, size > len ? size - len : 0, fmt, vl);
- va_end(vl);
-
- return len;
-}
-
-char *av_asprintf(const char *fmt, ...)
-{
- char *p = NULL;
- va_list va;
- int len;
-
- va_start(va, fmt);
- len = vsnprintf(NULL, 0, fmt, va);
- va_end(va);
- if (len < 0)
- goto end;
-
- p = av_malloc(len + 1);
- if (!p)
- goto end;
-
- va_start(va, fmt);
- len = vsnprintf(p, len + 1, fmt, va);
- va_end(va);
- if (len < 0)
- av_freep(&p);
-
-end:
- return p;
-}
-
-char *av_d2str(double d)
-{
- char *str = av_malloc(16);
- if (str)
- snprintf(str, 16, "%f", d);
- return str;
-}
-
-#define WHITESPACES " \n\t"
-
-char *av_get_token(const char **buf, const char *term)
-{
- char *out = av_malloc(strlen(*buf) + 1);
- char *ret = out, *end = out;
- const char *p = *buf;
- if (!out)
- return NULL;
- p += strspn(p, WHITESPACES);
-
- while (*p && !strspn(p, term)) {
- char c = *p++;
- if (c == '\\' && *p) {
- *out++ = *p++;
- end = out;
- } else if (c == '\'') {
- while (*p && *p != '\'')
- *out++ = *p++;
- if (*p) {
- p++;
- end = out;
- }
- } else {
- *out++ = c;
- }
- }
-
- do
- *out-- = 0;
- while (out >= end && strspn(out, WHITESPACES));
-
- *buf = p;
-
- return ret;
-}
-
-char *av_strtok(char *s, const char *delim, char **saveptr)
-{
- char *tok;
-
- if (!s && !(s = *saveptr))
- return NULL;
-
- /* skip leading delimiters */
- s += strspn(s, delim);
-
- /* s now points to the first non delimiter char, or to the end of the string */
- if (!*s) {
- *saveptr = NULL;
- return NULL;
- }
- tok = s++;
-
- /* skip non delimiters */
- s += strcspn(s, delim);
- if (*s) {
- *s = 0;
- *saveptr = s+1;
- } else {
- *saveptr = NULL;
- }
-
- return tok;
-}
-
-int av_strcasecmp(const char *a, const char *b)
-{
- uint8_t c1, c2;
- do {
- c1 = av_tolower(*a++);
- c2 = av_tolower(*b++);
- } while (c1 && c1 == c2);
- return c1 - c2;
-}
-
-int av_strncasecmp(const char *a, const char *b, size_t n)
-{
- const char *end = a + n;
- uint8_t c1, c2;
- do {
- c1 = av_tolower(*a++);
- c2 = av_tolower(*b++);
- } while (a < end && c1 && c1 == c2);
- return c1 - c2;
-}
-
-const char *av_basename(const char *path)
-{
- char *p = strrchr(path, '/');
-
-#if HAVE_DOS_PATHS
- char *q = strrchr(path, '\\');
- char *d = strchr(path, ':');
-
- p = FFMAX3(p, q, d);
-#endif
-
- if (!p)
- return path;
-
- return p + 1;
-}
-
-const char *av_dirname(char *path)
-{
- char *p = strrchr(path, '/');
-
-#if HAVE_DOS_PATHS
- char *q = strrchr(path, '\\');
- char *d = strchr(path, ':');
-
- d = d ? d + 1 : d;
-
- p = FFMAX3(p, q, d);
-#endif
-
- if (!p)
- return ".";
-
- *p = '\0';
-
- return path;
-}
-
-#ifdef TEST
-
-int main(void)
-{
- int i;
- const char *strings[] = {
- "''",
- "",
- ":",
- "\\",
- "'",
- " '' :",
- " '' '' :",
- "foo '' :",
- "'foo'",
- "foo ",
- " ' foo ' ",
- "foo\\",
- "foo': blah:blah",
- "foo\\: blah:blah",
- "foo\'",
- "'foo : ' :blahblah",
- "\\ :blah",
- " foo",
- " foo ",
- " foo \\ ",
- "foo ':blah",
- " foo bar : blahblah",
- "\\f\\o\\o",
- "'foo : \\ \\ ' : blahblah",
- "'\\fo\\o:': blahblah",
- "\\'fo\\o\\:': foo ' :blahblah"
- };
-
- printf("Testing av_get_token()\n");
- for (i = 0; i < FF_ARRAY_ELEMS(strings); i++) {
- const char *p = strings[i];
- char *q;
- printf("|%s|", p);
- q = av_get_token(&p, ":");
- printf(" -> |%s|", q);
- printf(" + |%s|\n", p);
- av_free(q);
- }
-
- return 0;
-}
-
-#endif /* TEST */
diff --git a/src/thirdparty/ffmpeg/libavutil/avstring.h b/src/thirdparty/ffmpeg/libavutil/avstring.h
deleted file mode 100644
index 1924d84e2..000000000
--- a/src/thirdparty/ffmpeg/libavutil/avstring.h
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Copyright (c) 2007 Mans Rullgard
- *
- * 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 AVUTIL_AVSTRING_H
-#define AVUTIL_AVSTRING_H
-
-#include <stddef.h>
-#include "attributes.h"
-
-/**
- * @addtogroup lavu_string
- * @{
- */
-
-/**
- * Return non-zero if pfx is a prefix of str. If it is, *ptr is set to
- * the address of the first character in str after the prefix.
- *
- * @param str input string
- * @param pfx prefix to test
- * @param ptr updated if the prefix is matched inside str
- * @return non-zero if the prefix matches, zero otherwise
- */
-int av_strstart(const char *str, const char *pfx, const char **ptr);
-
-/**
- * Return non-zero if pfx is a prefix of str independent of case. If
- * it is, *ptr is set to the address of the first character in str
- * after the prefix.
- *
- * @param str input string
- * @param pfx prefix to test
- * @param ptr updated if the prefix is matched inside str
- * @return non-zero if the prefix matches, zero otherwise
- */
-int av_stristart(const char *str, const char *pfx, const char **ptr);
-
-/**
- * Locate the first case-independent occurrence in the string haystack
- * of the string needle. A zero-length string needle is considered to
- * match at the start of haystack.
- *
- * This function is a case-insensitive version of the standard strstr().
- *
- * @param haystack string to search in
- * @param needle string to search for
- * @return pointer to the located match within haystack
- * or a null pointer if no match
- */
-char *av_stristr(const char *haystack, const char *needle);
-
-/**
- * Locate the first occurrence of the string needle in the string haystack
- * where not more than hay_length characters are searched. A zero-length
- * string needle is considered to match at the start of haystack.
- *
- * This function is a length-limited version of the standard strstr().
- *
- * @param haystack string to search in
- * @param needle string to search for
- * @param hay_length length of string to search in
- * @return pointer to the located match within haystack
- * or a null pointer if no match
- */
-char *av_strnstr(const char *haystack, const char *needle, size_t hay_length);
-
-/**
- * Copy the string src to dst, but no more than size - 1 bytes, and
- * null-terminate dst.
- *
- * This function is the same as BSD strlcpy().
- *
- * @param dst destination buffer
- * @param src source string
- * @param size size of destination buffer
- * @return the length of src
- *
- * @warning since the return value is the length of src, src absolutely
- * _must_ be a properly 0-terminated string, otherwise this will read beyond
- * the end of the buffer and possibly crash.
- */
-size_t av_strlcpy(char *dst, const char *src, size_t size);
-
-/**
- * Append the string src to the string dst, but to a total length of
- * no more than size - 1 bytes, and null-terminate dst.
- *
- * This function is similar to BSD strlcat(), but differs when
- * size <= strlen(dst).
- *
- * @param dst destination buffer
- * @param src source string
- * @param size size of destination buffer
- * @return the total length of src and dst
- *
- * @warning since the return value use the length of src and dst, these
- * absolutely _must_ be a properly 0-terminated strings, otherwise this
- * will read beyond the end of the buffer and possibly crash.
- */
-size_t av_strlcat(char *dst, const char *src, size_t size);
-
-/**
- * Append output to a string, according to a format. Never write out of
- * the destination buffer, and always put a terminating 0 within
- * the buffer.
- * @param dst destination buffer (string to which the output is
- * appended)
- * @param size total size of the destination buffer
- * @param fmt printf-compatible format string, specifying how the
- * following parameters are used
- * @return the length of the string that would have been generated
- * if enough space had been available
- */
-size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...) av_printf_format(3, 4);
-
-/**
- * Print arguments following specified format into a large enough auto
- * allocated buffer. It is similar to GNU asprintf().
- * @param fmt printf-compatible format string, specifying how the
- * following parameters are used.
- * @return the allocated string
- * @note You have to free the string yourself with av_free().
- */
-char *av_asprintf(const char *fmt, ...) av_printf_format(1, 2);
-
-/**
- * Convert a number to a av_malloced string.
- */
-char *av_d2str(double d);
-
-/**
- * Unescape the given string until a non escaped terminating char,
- * and return the token corresponding to the unescaped string.
- *
- * The normal \ and ' escaping is supported. Leading and trailing
- * whitespaces are removed, unless they are escaped with '\' or are
- * enclosed between ''.
- *
- * @param buf the buffer to parse, buf will be updated to point to the
- * terminating char
- * @param term a 0-terminated list of terminating chars
- * @return the malloced unescaped string, which must be av_freed by
- * the user, NULL in case of allocation failure
- */
-char *av_get_token(const char **buf, const char *term);
-
-/**
- * Split the string into several tokens which can be accessed by
- * successive calls to av_strtok().
- *
- * A token is defined as a sequence of characters not belonging to the
- * set specified in delim.
- *
- * On the first call to av_strtok(), s should point to the string to
- * parse, and the value of saveptr is ignored. In subsequent calls, s
- * should be NULL, and saveptr should be unchanged since the previous
- * call.
- *
- * This function is similar to strtok_r() defined in POSIX.1.
- *
- * @param s the string to parse, may be NULL
- * @param delim 0-terminated list of token delimiters, must be non-NULL
- * @param saveptr user-provided pointer which points to stored
- * information necessary for av_strtok() to continue scanning the same
- * string. saveptr is updated to point to the next character after the
- * first delimiter found, or to NULL if the string was terminated
- * @return the found token, or NULL when no token is found
- */
-char *av_strtok(char *s, const char *delim, char **saveptr);
-
-/**
- * Locale-independent conversion of ASCII characters to uppercase.
- */
-static inline int av_toupper(int c)
-{
- if (c >= 'a' && c <= 'z')
- c ^= 0x20;
- return c;
-}
-
-/**
- * Locale-independent conversion of ASCII characters to lowercase.
- */
-static inline int av_tolower(int c)
-{
- if (c >= 'A' && c <= 'Z')
- c ^= 0x20;
- return c;
-}
-
-/**
- * Locale-independent case-insensitive compare.
- * @note This means only ASCII-range characters are case-insensitive
- */
-int av_strcasecmp(const char *a, const char *b);
-
-/**
- * Locale-independent case-insensitive compare.
- * @note This means only ASCII-range characters are case-insensitive
- */
-int av_strncasecmp(const char *a, const char *b, size_t n);
-
-
-/**
- * Thread safe basename.
- * @param path the path, on DOS both \ and / are considered separators.
- * @return pointer to the basename substring.
- */
-const char *av_basename(const char *path);
-
-/**
- * Thread safe dirname.
- * @param path the path, on DOS both \ and / are considered separators.
- * @return the path with the separator replaced by the string terminator or ".".
- * @note the function may change the input string.
- */
-const char *av_dirname(char *path);
-
-/**
- * @}
- */
-
-#endif /* AVUTIL_AVSTRING_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/avutil.h b/src/thirdparty/ffmpeg/libavutil/avutil.h
deleted file mode 100644
index 517f6fadc..000000000
--- a/src/thirdparty/ffmpeg/libavutil/avutil.h
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * copyright (c) 2006 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
- */
-
-#ifndef AVUTIL_AVUTIL_H
-#define AVUTIL_AVUTIL_H
-
-/**
- * @file
- * external API header
- */
-
-/**
- * @mainpage
- *
- * @section ffmpeg_intro Introduction
- *
- * This document describes the usage of the different libraries
- * provided by FFmpeg.
- *
- * @li @ref libavc "libavcodec" encoding/decoding library
- * @li @ref lavfi "libavfilter" graph based frame editing library
- * @li @ref libavf "libavformat" I/O and muxing/demuxing library
- * @li @ref lavd "libavdevice" special devices muxing/demuxing library
- * @li @ref lavu "libavutil" common utility library
- * @li @ref lswr "libswresample" audio resampling, format conversion and mixing
- * @li @ref lpp "libpostproc" post processing library
- * @li @ref lsws "libswscale" color conversion and scaling library
- */
-
-/**
- * @defgroup lavu Common utility functions
- *
- * @brief
- * libavutil contains the code shared across all the other FFmpeg
- * libraries
- *
- * @note In order to use the functions provided by avutil you must include
- * the specific header.
- *
- * @{
- *
- * @defgroup lavu_crypto Crypto and Hashing
- *
- * @{
- * @}
- *
- * @defgroup lavu_math Maths
- * @{
- *
- * @}
- *
- * @defgroup lavu_string String Manipulation
- *
- * @{
- *
- * @}
- *
- * @defgroup lavu_mem Memory Management
- *
- * @{
- *
- * @}
- *
- * @defgroup lavu_data Data Structures
- * @{
- *
- * @}
- *
- * @defgroup lavu_audio Audio related
- *
- * @{
- *
- * @}
- *
- * @defgroup lavu_error Error Codes
- *
- * @{
- *
- * @}
- *
- * @defgroup lavu_misc Other
- *
- * @{
- *
- * @defgroup lavu_internal Internal
- *
- * Not exported functions, for internal usage only
- *
- * @{
- *
- * @}
- */
-
-
-/**
- * @addtogroup lavu_ver
- * @{
- */
-
-/**
- * Return the LIBAVUTIL_VERSION_INT constant.
- */
-unsigned avutil_version(void);
-
-/**
- * Return the libavutil build-time configuration.
- */
-const char *avutil_configuration(void);
-
-/**
- * Return the libavutil license.
- */
-const char *avutil_license(void);
-
-/**
- * @}
- */
-
-/**
- * @addtogroup lavu_media Media Type
- * @brief Media Type
- */
-
-enum AVMediaType {
- AVMEDIA_TYPE_UNKNOWN = -1, ///< Usually treated as AVMEDIA_TYPE_DATA
- AVMEDIA_TYPE_VIDEO,
- AVMEDIA_TYPE_AUDIO,
- AVMEDIA_TYPE_DATA, ///< Opaque data information usually continuous
- AVMEDIA_TYPE_SUBTITLE,
- AVMEDIA_TYPE_ATTACHMENT, ///< Opaque data information usually sparse
- AVMEDIA_TYPE_NB
-};
-
-/**
- * Return a string describing the media_type enum, NULL if media_type
- * is unknown.
- */
-const char *av_get_media_type_string(enum AVMediaType media_type);
-
-/**
- * @defgroup lavu_const Constants
- * @{
- *
- * @defgroup lavu_enc Encoding specific
- *
- * @note those definition should move to avcodec
- * @{
- */
-
-#define FF_LAMBDA_SHIFT 7
-#define FF_LAMBDA_SCALE (1<<FF_LAMBDA_SHIFT)
-#define FF_QP2LAMBDA 118 ///< factor to convert from H.263 QP to lambda
-#define FF_LAMBDA_MAX (256*128-1)
-
-#define FF_QUALITY_SCALE FF_LAMBDA_SCALE //FIXME maybe remove
-
-/**
- * @}
- * @defgroup lavu_time Timestamp specific
- *
- * FFmpeg internal timebase and timestamp definitions
- *
- * @{
- */
-
-/**
- * @brief Undefined timestamp value
- *
- * Usually reported by demuxer that work on containers that do not provide
- * either pts or dts.
- */
-
-#define AV_NOPTS_VALUE ((int64_t)UINT64_C(0x8000000000000000))
-
-/**
- * Internal time base represented as integer
- */
-
-#define AV_TIME_BASE 1000000
-
-/**
- * Internal time base represented as fractional value
- */
-
-#define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE}
-
-/**
- * @}
- * @}
- * @defgroup lavu_picture Image related
- *
- * AVPicture types, pixel formats and basic image planes manipulation.
- *
- * @{
- */
-
-enum AVPictureType {
- AV_PICTURE_TYPE_NONE = 0, ///< Undefined
- AV_PICTURE_TYPE_I, ///< Intra
- AV_PICTURE_TYPE_P, ///< Predicted
- AV_PICTURE_TYPE_B, ///< Bi-dir predicted
- AV_PICTURE_TYPE_S, ///< S(GMC)-VOP MPEG4
- AV_PICTURE_TYPE_SI, ///< Switching Intra
- AV_PICTURE_TYPE_SP, ///< Switching Predicted
- AV_PICTURE_TYPE_BI, ///< BI type
-};
-
-/**
- * Return a single letter to describe the given picture type
- * pict_type.
- *
- * @param[in] pict_type the picture type @return a single character
- * representing the picture type, '?' if pict_type is unknown
- */
-char av_get_picture_type_char(enum AVPictureType pict_type);
-
-/**
- * @}
- */
-
-#include "common.h"
-#include "error.h"
-#include "version.h"
-#include "mathematics.h"
-#include "rational.h"
-#include "intfloat_readwrite.h"
-#include "log.h"
-#include "pixfmt.h"
-
-/**
- * Return x default pointer in case p is NULL.
- */
-static inline void *av_x_if_null(const void *p, const void *x)
-{
- return (void *)(intptr_t)(p ? p : x);
-}
-
-/**
- * @}
- * @}
- */
-
-#endif /* AVUTIL_AVUTIL_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/bprint.c b/src/thirdparty/ffmpeg/libavutil/bprint.c
deleted file mode 100644
index 653b4dfd5..000000000
--- a/src/thirdparty/ffmpeg/libavutil/bprint.c
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Copyright (c) 2012 Nicolas George
- *
- * 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 <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-#include "avassert.h"
-#include "bprint.h"
-#include "common.h"
-#include "error.h"
-#include "mem.h"
-
-#define av_bprint_room(buf) ((buf)->size - FFMIN((buf)->len, (buf)->size))
-#define av_bprint_is_allocated(buf) ((buf)->str != (buf)->reserved_internal_buffer)
-
-static int av_bprint_alloc(AVBPrint *buf, unsigned room)
-{
- char *old_str, *new_str;
- unsigned min_size, new_size;
-
- if (buf->size == buf->size_max)
- return AVERROR(EIO);
- if (!av_bprint_is_complete(buf))
- return AVERROR_INVALIDDATA; /* it is already truncated anyway */
- min_size = buf->len + 1 + FFMIN(UINT_MAX - buf->len - 1, room);
- new_size = buf->size > buf->size_max / 2 ? buf->size_max : buf->size * 2;
- if (new_size < min_size)
- new_size = FFMIN(buf->size_max, min_size);
- old_str = av_bprint_is_allocated(buf) ? buf->str : NULL;
- new_str = av_realloc(old_str, new_size);
- if (!new_str)
- return AVERROR(ENOMEM);
- if (!old_str)
- memcpy(new_str, buf->str, buf->len + 1);
- buf->str = new_str;
- buf->size = new_size;
- return 0;
-}
-
-static void av_bprint_grow(AVBPrint *buf, unsigned extra_len)
-{
- /* arbitrary margin to avoid small overflows */
- extra_len = FFMIN(extra_len, UINT_MAX - 5 - buf->len);
- buf->len += extra_len;
- if (buf->size)
- buf->str[FFMIN(buf->len, buf->size - 1)] = 0;
-}
-
-void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
-{
- unsigned size_auto = (char *)buf + sizeof(*buf) -
- buf->reserved_internal_buffer;
-
- if (size_max == 1)
- size_max = size_auto;
- buf->str = buf->reserved_internal_buffer;
- buf->len = 0;
- buf->size = FFMIN(size_auto, size_max);
- buf->size_max = size_max;
- *buf->str = 0;
- if (size_init > buf->size)
- av_bprint_alloc(buf, size_init - 1);
-}
-
-void av_bprint_init_for_buffer(AVBPrint *buf, char *buffer, unsigned size)
-{
- buf->str = buffer;
- buf->len = 0;
- buf->size = size;
- buf->size_max = size;
- *buf->str = 0;
-}
-
-void av_bprintf(AVBPrint *buf, const char *fmt, ...)
-{
- unsigned room;
- char *dst;
- va_list vl;
- int extra_len;
-
- while (1) {
- room = av_bprint_room(buf);
- dst = room ? buf->str + buf->len : NULL;
- va_start(vl, fmt);
- extra_len = vsnprintf(dst, room, fmt, vl);
- va_end(vl);
- if (extra_len <= 0)
- return;
- if (extra_len < room)
- break;
- if (av_bprint_alloc(buf, extra_len))
- break;
- }
- av_bprint_grow(buf, extra_len);
-}
-
-void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
-{
- unsigned room, real_n;
-
- while (1) {
- room = av_bprint_room(buf);
- if (n < room)
- break;
- if (av_bprint_alloc(buf, n))
- break;
- }
- if (room) {
- real_n = FFMIN(n, room - 1);
- memset(buf->str + buf->len, c, real_n);
- }
- av_bprint_grow(buf, n);
-}
-
-void av_bprint_strftime(AVBPrint *buf, const char *fmt, const struct tm *tm)
-{
- unsigned room;
- size_t l;
-
- if (!*fmt)
- return;
- while (1) {
- room = av_bprint_room(buf);
- if (room && (l = strftime(buf->str + buf->len, room, fmt, tm)))
- break;
- /* strftime does not tell us how much room it would need: let us
- retry with twice as much until the buffer is large enough */
- room = !room ? strlen(fmt) + 1 :
- room <= INT_MAX / 2 ? room * 2 : INT_MAX;
- if (av_bprint_alloc(buf, room)) {
- /* impossible to grow, try to manage something useful anyway */
- room = av_bprint_room(buf);
- if (room < 1024) {
- /* if strftime fails because the buffer has (almost) reached
- its maximum size, let us try in a local buffer; 1k should
- be enough to format any real date+time string */
- char buf2[1024];
- if ((l = strftime(buf2, sizeof(buf2), fmt, tm))) {
- av_bprintf(buf, "%s", buf2);
- return;
- }
- }
- if (room) {
- /* if anything else failed and the buffer is not already
- truncated, let us add a stock string and force truncation */
- static const char txt[] = "[truncated strftime output]";
- memset(buf->str + buf->len, '!', room);
- memcpy(buf->str + buf->len, txt, FFMIN(sizeof(txt) - 1, room));
- av_bprint_grow(buf, room); /* force truncation */
- }
- return;
- }
- }
- av_bprint_grow(buf, l);
-}
-
-void av_bprint_get_buffer(AVBPrint *buf, unsigned size,
- unsigned char **mem, unsigned *actual_size)
-{
- if (size > av_bprint_room(buf))
- av_bprint_alloc(buf, size);
- *actual_size = av_bprint_room(buf);
- *mem = *actual_size ? buf->str + buf->len : NULL;
-}
-
-void av_bprint_clear(AVBPrint *buf)
-{
- if (buf->len) {
- *buf->str = 0;
- buf->len = 0;
- }
-}
-
-int av_bprint_finalize(AVBPrint *buf, char **ret_str)
-{
- unsigned real_size = FFMIN(buf->len + 1, buf->size);
- char *str;
- int ret = 0;
-
- if (ret_str) {
- if (av_bprint_is_allocated(buf)) {
- str = av_realloc(buf->str, real_size);
- if (!str)
- str = buf->str;
- buf->str = NULL;
- } else {
- str = av_malloc(real_size);
- if (str)
- memcpy(str, buf->str, real_size);
- else
- ret = AVERROR(ENOMEM);
- }
- *ret_str = str;
- } else {
- if (av_bprint_is_allocated(buf))
- av_freep(&buf->str);
- }
- buf->size = real_size;
- return ret;
-}
-
-#ifdef TEST
-
-#undef printf
-
-static void bprint_pascal(AVBPrint *b, unsigned size)
-{
- unsigned i, j;
- unsigned p[42];
-
- av_assert0(size < FF_ARRAY_ELEMS(p));
-
- p[0] = 1;
- av_bprintf(b, "%8d\n", 1);
- for (i = 1; i <= size; i++) {
- p[i] = 1;
- for (j = i - 1; j > 0; j--)
- p[j] = p[j] + p[j - 1];
- for (j = 0; j <= i; j++)
- av_bprintf(b, "%8d", p[j]);
- av_bprintf(b, "\n");
- }
-}
-
-int main(void)
-{
- AVBPrint b;
- char buf[256];
- struct tm testtime = { .tm_year = 100, .tm_mon = 11, .tm_mday = 20 };
-
- av_bprint_init(&b, 0, -1);
- bprint_pascal(&b, 5);
- printf("Short text in unlimited buffer: %u/%u\n", (unsigned)strlen(b.str), b.len);
- printf("%s\n", b.str);
- av_bprint_finalize(&b, NULL);
-
- av_bprint_init(&b, 0, -1);
- bprint_pascal(&b, 25);
- printf("Long text in unlimited buffer: %u/%u\n", (unsigned)strlen(b.str), b.len);
- av_bprint_finalize(&b, NULL);
-
- av_bprint_init(&b, 0, 2048);
- bprint_pascal(&b, 25);
- printf("Long text in limited buffer: %u/%u\n", (unsigned)strlen(b.str), b.len);
- av_bprint_finalize(&b, NULL);
-
- av_bprint_init(&b, 0, 1);
- bprint_pascal(&b, 5);
- printf("Short text in automatic buffer: %u/%u\n", (unsigned)strlen(b.str), b.len);
-
- av_bprint_init(&b, 0, 1);
- bprint_pascal(&b, 25);
- printf("Long text in automatic buffer: %u/%u\n", (unsigned)strlen(b.str)/8*8, b.len);
- /* Note that the size of the automatic buffer is arch-dependant. */
-
- av_bprint_init(&b, 0, 0);
- bprint_pascal(&b, 25);
- printf("Long text count only buffer: %u/%u\n", (unsigned)strlen(b.str), b.len);
-
- av_bprint_init_for_buffer(&b, buf, sizeof(buf));
- bprint_pascal(&b, 25);
- printf("Long text count only buffer: %u/%u\n", (unsigned)strlen(buf), b.len);
-
- av_bprint_init(&b, 0, -1);
- av_bprint_strftime(&b, "%Y-%m-%d", &testtime);
- printf("strftime full: %u/%u \"%s\"\n", (unsigned)strlen(buf), b.len, b.str);
- av_bprint_finalize(&b, NULL);
-
- av_bprint_init(&b, 0, 8);
- av_bprint_strftime(&b, "%Y-%m-%d", &testtime);
- printf("strftime truncated: %u/%u \"%s\"\n", (unsigned)strlen(buf), b.len, b.str);
-
- return 0;
-}
-
-#endif
diff --git a/src/thirdparty/ffmpeg/libavutil/bprint.h b/src/thirdparty/ffmpeg/libavutil/bprint.h
deleted file mode 100644
index 1c744e0ff..000000000
--- a/src/thirdparty/ffmpeg/libavutil/bprint.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright (c) 2012 Nicolas George
- *
- * 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 AVUTIL_BPRINT_H
-#define AVUTIL_BPRINT_H
-
-#include "attributes.h"
-
-/**
- * Define a structure with extra padding to a fixed size
- * This helps ensuring binary compatibility with future versions.
- */
-#define FF_PAD_STRUCTURE(size, ...) \
- __VA_ARGS__ \
- char reserved_padding[size - sizeof(struct { __VA_ARGS__ })];
-
-/**
- * Buffer to print data progressively
- *
- * The string buffer grows as necessary and is always 0-terminated.
- * The content of the string is never accessed, and thus is
- * encoding-agnostic and can even hold binary data.
- *
- * Small buffers are kept in the structure itself, and thus require no
- * memory allocation at all (unless the contents of the buffer is needed
- * after the structure goes out of scope). This is almost as lightweight as
- * declaring a local "char buf[512]".
- *
- * The length of the string can go beyond the allocated size: the buffer is
- * then truncated, but the functions still keep account of the actual total
- * length.
- *
- * In other words, buf->len can be greater than buf->size and records the
- * total length of what would have been to the buffer if there had been
- * enough memory.
- *
- * Append operations do not need to be tested for failure: if a memory
- * allocation fails, data stop being appended to the buffer, but the length
- * is still updated. This situation can be tested with
- * av_bprint_is_complete().
- *
- * The size_max field determines several possible behaviours:
- *
- * size_max = -1 (= UINT_MAX) or any large value will let the buffer be
- * reallocated as necessary, with an amortized linear cost.
- *
- * size_max = 0 prevents writing anything to the buffer: only the total
- * length is computed. The write operations can then possibly be repeated in
- * a buffer with exactly the necessary size
- * (using size_init = size_max = len + 1).
- *
- * size_max = 1 is automatically replaced by the exact size available in the
- * structure itself, thus ensuring no dynamic memory allocation. The
- * internal buffer is large enough to hold a reasonable paragraph of text,
- * such as the current paragraph.
- */
-typedef struct AVBPrint {
- FF_PAD_STRUCTURE(1024,
- char *str; /** string so far */
- unsigned len; /** length so far */
- unsigned size; /** allocated memory */
- unsigned size_max; /** maximum allocated memory */
- char reserved_internal_buffer[1];
- )
-} AVBPrint;
-
-/**
- * Convenience macros for special values for av_bprint_init() size_max
- * parameter.
- */
-#define AV_BPRINT_SIZE_UNLIMITED ((unsigned)-1)
-#define AV_BPRINT_SIZE_AUTOMATIC 1
-#define AV_BPRINT_SIZE_COUNT_ONLY 0
-
-/**
- * Init a print buffer.
- *
- * @param buf buffer to init
- * @param size_init initial size (including the final 0)
- * @param size_max maximum size;
- * 0 means do not write anything, just count the length;
- * 1 is replaced by the maximum value for automatic storage;
- * any large value means that the internal buffer will be
- * reallocated as needed up to that limit; -1 is converted to
- * UINT_MAX, the largest limit possible.
- * Check also AV_BPRINT_SIZE_* macros.
- */
-void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max);
-
-/**
- * Init a print buffer using a pre-existing buffer.
- *
- * The buffer will not be reallocated.
- *
- * @param buf buffer structure to init
- * @param buffer byte buffer to use for the string data
- * @param size size of buffer
- */
-void av_bprint_init_for_buffer(AVBPrint *buf, char *buffer, unsigned size);
-
-/**
- * Append a formatted string to a print buffer.
- */
-void av_bprintf(AVBPrint *buf, const char *fmt, ...) av_printf_format(2, 3);
-
-/**
- * Append char c n times to a print buffer.
- */
-void av_bprint_chars(AVBPrint *buf, char c, unsigned n);
-
-struct tm;
-/**
- * Append a formatted date and time to a print buffer.
- *
- * param buf bprint buffer to use
- * param fmt date and time format string, see strftime()
- * param tm broken-down time structure to translate
- *
- * @note due to poor design of the standard strftime function, it may
- * produce poor results if the format string expands to a very long text and
- * the bprint buffer is near the limit stated by the size_max option.
- */
-void av_bprint_strftime(AVBPrint *buf, const char *fmt, const struct tm *tm);
-
-/**
- * Allocate bytes in the buffer for external use.
- *
- * @param[in] buf buffer structure
- * @param[in] size required size
- * @param[out] mem pointer to the memory area
- * @param[out] actual_size size of the memory area after allocation;
- * can be larger or smaller than size
- */
-void av_bprint_get_buffer(AVBPrint *buf, unsigned size,
- unsigned char **mem, unsigned *actual_size);
-
-/**
- * Reset the string to "" but keep internal allocated data.
- */
-void av_bprint_clear(AVBPrint *buf);
-
-/**
- * Test if the print buffer is complete (not truncated).
- *
- * It may have been truncated due to a memory allocation failure
- * or the size_max limit (compare size and size_max if necessary).
- */
-static inline int av_bprint_is_complete(AVBPrint *buf)
-{
- return buf->len < buf->size;
-}
-
-/**
- * Finalize a print buffer.
- *
- * The print buffer can no longer be used afterwards,
- * but the len and size fields are still valid.
- *
- * @arg[out] ret_str if not NULL, used to return a permanent copy of the
- * buffer contents, or NULL if memory allocation fails;
- * if NULL, the buffer is discarded and freed
- * @return 0 for success or error code (probably AVERROR(ENOMEM))
- */
-int av_bprint_finalize(AVBPrint *buf, char **ret_str);
-
-#endif /* AVUTIL_BPRINT_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/bswap.h b/src/thirdparty/ffmpeg/libavutil/bswap.h
deleted file mode 100644
index b6da12437..000000000
--- a/src/thirdparty/ffmpeg/libavutil/bswap.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * copyright (c) 2006 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
- * byte swapping routines
- */
-
-#ifndef AVUTIL_BSWAP_H
-#define AVUTIL_BSWAP_H
-
-#include <stdint.h>
-#include "libavutil/avconfig.h"
-#include "attributes.h"
-
-#ifdef HAVE_AV_CONFIG_H
-
-#include "config.h"
-
-#if ARCH_ARM
-# include "arm/bswap.h"
-#elif ARCH_AVR32
-# include "avr32/bswap.h"
-#elif ARCH_BFIN
-# include "bfin/bswap.h"
-#elif ARCH_SH4
-# include "sh4/bswap.h"
-#elif ARCH_X86
-# include "x86/bswap.h"
-#endif
-
-#endif /* HAVE_AV_CONFIG_H */
-
-#define AV_BSWAP16C(x) (((x) << 8 & 0xff00) | ((x) >> 8 & 0x00ff))
-#define AV_BSWAP32C(x) (AV_BSWAP16C(x) << 16 | AV_BSWAP16C((x) >> 16))
-#define AV_BSWAP64C(x) (AV_BSWAP32C(x) << 32 | AV_BSWAP32C((x) >> 32))
-
-#define AV_BSWAPC(s, x) AV_BSWAP##s##C(x)
-
-#ifndef av_bswap16
-static av_always_inline av_const uint16_t av_bswap16(uint16_t x)
-{
- x= (x>>8) | (x<<8);
- return x;
-}
-#endif
-
-#ifndef av_bswap32
-static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
-{
- return AV_BSWAP32C(x);
-}
-#endif
-
-#ifndef av_bswap64
-static inline uint64_t av_const av_bswap64(uint64_t x)
-{
- return (uint64_t)av_bswap32(x) << 32 | av_bswap32(x >> 32);
-}
-#endif
-
-// be2ne ... big-endian to native-endian
-// le2ne ... little-endian to native-endian
-
-#if AV_HAVE_BIGENDIAN
-#define av_be2ne16(x) (x)
-#define av_be2ne32(x) (x)
-#define av_be2ne64(x) (x)
-#define av_le2ne16(x) av_bswap16(x)
-#define av_le2ne32(x) av_bswap32(x)
-#define av_le2ne64(x) av_bswap64(x)
-#define AV_BE2NEC(s, x) (x)
-#define AV_LE2NEC(s, x) AV_BSWAPC(s, x)
-#else
-#define av_be2ne16(x) av_bswap16(x)
-#define av_be2ne32(x) av_bswap32(x)
-#define av_be2ne64(x) av_bswap64(x)
-#define av_le2ne16(x) (x)
-#define av_le2ne32(x) (x)
-#define av_le2ne64(x) (x)
-#define AV_BE2NEC(s, x) AV_BSWAPC(s, x)
-#define AV_LE2NEC(s, x) (x)
-#endif
-
-#define AV_BE2NE16C(x) AV_BE2NEC(16, x)
-#define AV_BE2NE32C(x) AV_BE2NEC(32, x)
-#define AV_BE2NE64C(x) AV_BE2NEC(64, x)
-#define AV_LE2NE16C(x) AV_LE2NEC(16, x)
-#define AV_LE2NE32C(x) AV_LE2NEC(32, x)
-#define AV_LE2NE64C(x) AV_LE2NEC(64, x)
-
-#endif /* AVUTIL_BSWAP_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/channel_layout.c b/src/thirdparty/ffmpeg/libavutil/channel_layout.c
deleted file mode 100644
index 3a9b91ac5..000000000
--- a/src/thirdparty/ffmpeg/libavutil/channel_layout.c
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Copyright (c) 2006 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
- * audio channel layout utility functions
- */
-
-#include "avstring.h"
-#include "avutil.h"
-#include "channel_layout.h"
-#include "bprint.h"
-#include "common.h"
-
-struct channel_name {
- const char *name;
- const char *description;
-};
-
-static const struct channel_name channel_names[] = {
- [0] = { "FL", "front left" },
- [1] = { "FR", "front right" },
- [2] = { "FC", "front center" },
- [3] = { "LFE", "low frequency" },
- [4] = { "BL", "back left" },
- [5] = { "BR", "back right" },
- [6] = { "FLC", "front left-of-center" },
- [7] = { "FRC", "front right-of-center" },
- [8] = { "BC", "back center" },
- [9] = { "SL", "side left" },
- [10] = { "SR", "side right" },
- [11] = { "TC", "top center" },
- [12] = { "TFL", "top front left" },
- [13] = { "TFC", "top front center" },
- [14] = { "TFR", "top front right" },
- [15] = { "TBL", "top back left" },
- [16] = { "TBC", "top back center" },
- [17] = { "TBR", "top back right" },
- [29] = { "DL", "downmix left" },
- [30] = { "DR", "downmix right" },
- [31] = { "WL", "wide left" },
- [32] = { "WR", "wide right" },
- [33] = { "SDL", "surround direct left" },
- [34] = { "SDR", "surround direct right" },
- [35] = { "LFE2", "low frequency 2" },
-};
-
-static const char *get_channel_name(int channel_id)
-{
- if (channel_id < 0 || channel_id >= FF_ARRAY_ELEMS(channel_names))
- return NULL;
- return channel_names[channel_id].name;
-}
-
-static const struct {
- const char *name;
- int nb_channels;
- uint64_t layout;
-} channel_layout_map[] = {
- { "mono", 1, AV_CH_LAYOUT_MONO },
- { "stereo", 2, AV_CH_LAYOUT_STEREO },
- { "2.1", 3, AV_CH_LAYOUT_2POINT1 },
- { "3.0", 3, AV_CH_LAYOUT_SURROUND },
- { "3.0(back)", 3, AV_CH_LAYOUT_2_1 },
- { "4.0", 4, AV_CH_LAYOUT_4POINT0 },
- { "quad", 4, AV_CH_LAYOUT_QUAD },
- { "quad(side)", 4, AV_CH_LAYOUT_2_2 },
- { "3.1", 4, AV_CH_LAYOUT_3POINT1 },
- { "5.0", 5, AV_CH_LAYOUT_5POINT0_BACK },
- { "5.0(side)", 5, AV_CH_LAYOUT_5POINT0 },
- { "4.1", 5, AV_CH_LAYOUT_4POINT1 },
- { "5.1", 6, AV_CH_LAYOUT_5POINT1_BACK },
- { "5.1(side)", 6, AV_CH_LAYOUT_5POINT1 },
- { "6.0", 6, AV_CH_LAYOUT_6POINT0 },
- { "6.0(front)", 6, AV_CH_LAYOUT_6POINT0_FRONT },
- { "hexagonal", 6, AV_CH_LAYOUT_HEXAGONAL },
- { "6.1", 7, AV_CH_LAYOUT_6POINT1 },
- { "6.1", 7, AV_CH_LAYOUT_6POINT1_BACK },
- { "6.1(front)", 7, AV_CH_LAYOUT_6POINT1_FRONT },
- { "7.0", 7, AV_CH_LAYOUT_7POINT0 },
- { "7.0(front)", 7, AV_CH_LAYOUT_7POINT0_FRONT },
- { "7.1", 8, AV_CH_LAYOUT_7POINT1 },
- { "7.1(wide)", 8, AV_CH_LAYOUT_7POINT1_WIDE_BACK },
- { "7.1(wide-side)", 8, AV_CH_LAYOUT_7POINT1_WIDE },
- { "octagonal", 8, AV_CH_LAYOUT_OCTAGONAL },
- { "downmix", 2, AV_CH_LAYOUT_STEREO_DOWNMIX, },
-};
-
-static uint64_t get_channel_layout_single(const char *name, int name_len)
-{
- int i;
- char *end;
- int64_t layout;
-
- for (i = 0; i < FF_ARRAY_ELEMS(channel_layout_map); i++) {
- if (strlen(channel_layout_map[i].name) == name_len &&
- !memcmp(channel_layout_map[i].name, name, name_len))
- return channel_layout_map[i].layout;
- }
- for (i = 0; i < FF_ARRAY_ELEMS(channel_names); i++)
- if (channel_names[i].name &&
- strlen(channel_names[i].name) == name_len &&
- !memcmp(channel_names[i].name, name, name_len))
- return (int64_t)1 << i;
- i = strtol(name, &end, 10);
- if (end - name == name_len ||
- (end + 1 - name == name_len && *end == 'c'))
- return av_get_default_channel_layout(i);
- layout = strtoll(name, &end, 0);
- if (end - name == name_len)
- return FFMAX(layout, 0);
- return 0;
-}
-
-uint64_t av_get_channel_layout(const char *name)
-{
- const char *n, *e;
- const char *name_end = name + strlen(name);
- int64_t layout = 0, layout_single;
-
- for (n = name; n < name_end; n = e + 1) {
- for (e = n; e < name_end && *e != '+' && *e != '|'; e++);
- layout_single = get_channel_layout_single(n, e - n);
- if (!layout_single)
- return 0;
- layout |= layout_single;
- }
- return layout;
-}
-
-void av_bprint_channel_layout(struct AVBPrint *bp,
- int nb_channels, uint64_t channel_layout)
-{
- int i;
-
- if (nb_channels <= 0)
- nb_channels = av_get_channel_layout_nb_channels(channel_layout);
-
- for (i = 0; i < FF_ARRAY_ELEMS(channel_layout_map); i++)
- if (nb_channels == channel_layout_map[i].nb_channels &&
- channel_layout == channel_layout_map[i].layout) {
- av_bprintf(bp, "%s", channel_layout_map[i].name);
- return;
- }
-
- av_bprintf(bp, "%d channels", nb_channels);
- if (channel_layout) {
- int i, ch;
- av_bprintf(bp, " (");
- for (i = 0, ch = 0; i < 64; i++) {
- if ((channel_layout & (UINT64_C(1) << i))) {
- const char *name = get_channel_name(i);
- if (name) {
- if (ch > 0)
- av_bprintf(bp, "+");
- av_bprintf(bp, "%s", name);
- }
- ch++;
- }
- }
- av_bprintf(bp, ")");
- }
-}
-
-void av_get_channel_layout_string(char *buf, int buf_size,
- int nb_channels, uint64_t channel_layout)
-{
- AVBPrint bp;
-
- av_bprint_init_for_buffer(&bp, buf, buf_size);
- av_bprint_channel_layout(&bp, nb_channels, channel_layout);
-}
-
-int av_get_channel_layout_nb_channels(uint64_t channel_layout)
-{
- return av_popcount64(channel_layout);
-}
-
-int64_t av_get_default_channel_layout(int nb_channels) {
- int i;
- for (i = 0; i < FF_ARRAY_ELEMS(channel_layout_map); i++)
- if (nb_channels == channel_layout_map[i].nb_channels)
- return channel_layout_map[i].layout;
- return 0;
-}
-
-int av_get_channel_layout_channel_index(uint64_t channel_layout,
- uint64_t channel)
-{
- if (!(channel_layout & channel) ||
- av_get_channel_layout_nb_channels(channel) != 1)
- return AVERROR(EINVAL);
- channel_layout &= channel - 1;
- return av_get_channel_layout_nb_channels(channel_layout);
-}
-
-const char *av_get_channel_name(uint64_t channel)
-{
- int i;
- if (av_get_channel_layout_nb_channels(channel) != 1)
- return NULL;
- for (i = 0; i < 64; i++)
- if ((1ULL<<i) & channel)
- return get_channel_name(i);
- return NULL;
-}
-
-const char *av_get_channel_description(uint64_t channel)
-{
- int i;
- if (av_get_channel_layout_nb_channels(channel) != 1)
- return NULL;
- for (i = 0; i < FF_ARRAY_ELEMS(channel_names); i++)
- if ((1ULL<<i) & channel)
- return channel_names[i].description;
- return NULL;
-}
-
-uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index)
-{
- int i;
-
- if (av_get_channel_layout_nb_channels(channel_layout) <= index)
- return 0;
-
- for (i = 0; i < 64; i++) {
- if ((1ULL << i) & channel_layout && !index--)
- return 1ULL << i;
- }
- return 0;
-}
-
-int av_get_standard_channel_layout(unsigned index, uint64_t *layout,
- const char **name)
-{
- if (index >= FF_ARRAY_ELEMS(channel_layout_map))
- return AVERROR_EOF;
- if (layout) *layout = channel_layout_map[index].layout;
- if (name) *name = channel_layout_map[index].name;
- return 0;
-}
diff --git a/src/thirdparty/ffmpeg/libavutil/channel_layout.h b/src/thirdparty/ffmpeg/libavutil/channel_layout.h
deleted file mode 100644
index 290609831..000000000
--- a/src/thirdparty/ffmpeg/libavutil/channel_layout.h
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
- * Copyright (c) 2008 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
- */
-
-#ifndef AVUTIL_CHANNEL_LAYOUT_H
-#define AVUTIL_CHANNEL_LAYOUT_H
-
-#include <stdint.h>
-
-/**
- * @file
- * audio channel layout utility functions
- */
-
-/**
- * @addtogroup lavu_audio
- * @{
- */
-
-/**
- * @defgroup channel_masks Audio channel masks
- *
- * A channel layout is a 64-bits integer with a bit set for every channel.
- * The number of bits set must be equal to the number of channels.
- * The value 0 means that the channel layout is not known.
- * @note this data structure is not powerful enough to handle channels
- * combinations that have the same channel multiple times, such as
- * dual-mono.
- *
- * @{
- */
-#define AV_CH_FRONT_LEFT 0x00000001
-#define AV_CH_FRONT_RIGHT 0x00000002
-#define AV_CH_FRONT_CENTER 0x00000004
-#define AV_CH_LOW_FREQUENCY 0x00000008
-#define AV_CH_BACK_LEFT 0x00000010
-#define AV_CH_BACK_RIGHT 0x00000020
-#define AV_CH_FRONT_LEFT_OF_CENTER 0x00000040
-#define AV_CH_FRONT_RIGHT_OF_CENTER 0x00000080
-#define AV_CH_BACK_CENTER 0x00000100
-#define AV_CH_SIDE_LEFT 0x00000200
-#define AV_CH_SIDE_RIGHT 0x00000400
-#define AV_CH_TOP_CENTER 0x00000800
-#define AV_CH_TOP_FRONT_LEFT 0x00001000
-#define AV_CH_TOP_FRONT_CENTER 0x00002000
-#define AV_CH_TOP_FRONT_RIGHT 0x00004000
-#define AV_CH_TOP_BACK_LEFT 0x00008000
-#define AV_CH_TOP_BACK_CENTER 0x00010000
-#define AV_CH_TOP_BACK_RIGHT 0x00020000
-#define AV_CH_STEREO_LEFT 0x20000000 ///< Stereo downmix.
-#define AV_CH_STEREO_RIGHT 0x40000000 ///< See AV_CH_STEREO_LEFT.
-#define AV_CH_WIDE_LEFT 0x0000000080000000ULL
-#define AV_CH_WIDE_RIGHT 0x0000000100000000ULL
-#define AV_CH_SURROUND_DIRECT_LEFT 0x0000000200000000ULL
-#define AV_CH_SURROUND_DIRECT_RIGHT 0x0000000400000000ULL
-#define AV_CH_LOW_FREQUENCY_2 0x0000000800000000ULL
-
-/** Channel mask value used for AVCodecContext.request_channel_layout
- to indicate that the user requests the channel order of the decoder output
- to be the native codec channel order. */
-#define AV_CH_LAYOUT_NATIVE 0x8000000000000000ULL
-
-/**
- * @}
- * @defgroup channel_mask_c Audio channel convenience macros
- * @{
- * */
-#define AV_CH_LAYOUT_MONO (AV_CH_FRONT_CENTER)
-#define AV_CH_LAYOUT_STEREO (AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT)
-#define AV_CH_LAYOUT_2POINT1 (AV_CH_LAYOUT_STEREO|AV_CH_LOW_FREQUENCY)
-#define AV_CH_LAYOUT_2_1 (AV_CH_LAYOUT_STEREO|AV_CH_BACK_CENTER)
-#define AV_CH_LAYOUT_SURROUND (AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER)
-#define AV_CH_LAYOUT_3POINT1 (AV_CH_LAYOUT_SURROUND|AV_CH_LOW_FREQUENCY)
-#define AV_CH_LAYOUT_4POINT0 (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_CENTER)
-#define AV_CH_LAYOUT_4POINT1 (AV_CH_LAYOUT_4POINT0|AV_CH_LOW_FREQUENCY)
-#define AV_CH_LAYOUT_2_2 (AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)
-#define AV_CH_LAYOUT_QUAD (AV_CH_LAYOUT_STEREO|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
-#define AV_CH_LAYOUT_5POINT0 (AV_CH_LAYOUT_SURROUND|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)
-#define AV_CH_LAYOUT_5POINT1 (AV_CH_LAYOUT_5POINT0|AV_CH_LOW_FREQUENCY)
-#define AV_CH_LAYOUT_5POINT0_BACK (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
-#define AV_CH_LAYOUT_5POINT1_BACK (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_LOW_FREQUENCY)
-#define AV_CH_LAYOUT_6POINT0 (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_CENTER)
-#define AV_CH_LAYOUT_6POINT0_FRONT (AV_CH_LAYOUT_2_2|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
-#define AV_CH_LAYOUT_HEXAGONAL (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_BACK_CENTER)
-#define AV_CH_LAYOUT_6POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_CENTER)
-#define AV_CH_LAYOUT_6POINT1_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_BACK_CENTER)
-#define AV_CH_LAYOUT_6POINT1_FRONT (AV_CH_LAYOUT_6POINT0_FRONT|AV_CH_LOW_FREQUENCY)
-#define AV_CH_LAYOUT_7POINT0 (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
-#define AV_CH_LAYOUT_7POINT0_FRONT (AV_CH_LAYOUT_5POINT0|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
-#define AV_CH_LAYOUT_7POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
-#define AV_CH_LAYOUT_7POINT1_WIDE (AV_CH_LAYOUT_5POINT1|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
-#define AV_CH_LAYOUT_7POINT1_WIDE_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
-#define AV_CH_LAYOUT_OCTAGONAL (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_CENTER|AV_CH_BACK_RIGHT)
-#define AV_CH_LAYOUT_STEREO_DOWNMIX (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT)
-
-enum AVMatrixEncoding {
- AV_MATRIX_ENCODING_NONE,
- AV_MATRIX_ENCODING_DOLBY,
- AV_MATRIX_ENCODING_DPLII,
- AV_MATRIX_ENCODING_NB
-};
-
-/**
- * @}
- */
-
-/**
- * Return a channel layout id that matches name, or 0 if no match is found.
- *
- * name can be one or several of the following notations,
- * separated by '+' or '|':
- * - the name of an usual channel layout (mono, stereo, 4.0, quad, 5.0,
- * 5.0(side), 5.1, 5.1(side), 7.1, 7.1(wide), downmix);
- * - the name of a single channel (FL, FR, FC, LFE, BL, BR, FLC, FRC, BC,
- * SL, SR, TC, TFL, TFC, TFR, TBL, TBC, TBR, DL, DR);
- * - a number of channels, in decimal, optionally followed by 'c', yielding
- * the default channel layout for that number of channels (@see
- * av_get_default_channel_layout);
- * - a channel layout mask, in hexadecimal starting with "0x" (see the
- * AV_CH_* macros).
- *
- * Example: "stereo+FC" = "2+FC" = "2c+1c" = "0x7"
- */
-uint64_t av_get_channel_layout(const char *name);
-
-/**
- * Return a description of a channel layout.
- * If nb_channels is <= 0, it is guessed from the channel_layout.
- *
- * @param buf put here the string containing the channel layout
- * @param buf_size size in bytes of the buffer
- */
-void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout);
-
-struct AVBPrint;
-/**
- * Append a description of a channel layout to a bprint buffer.
- */
-void av_bprint_channel_layout(struct AVBPrint *bp, int nb_channels, uint64_t channel_layout);
-
-/**
- * Return the number of channels in the channel layout.
- */
-int av_get_channel_layout_nb_channels(uint64_t channel_layout);
-
-/**
- * Return default channel layout for a given number of channels.
- */
-int64_t av_get_default_channel_layout(int nb_channels);
-
-/**
- * Get the index of a channel in channel_layout.
- *
- * @param channel a channel layout describing exactly one channel which must be
- * present in channel_layout.
- *
- * @return index of channel in channel_layout on success, a negative AVERROR
- * on error.
- */
-int av_get_channel_layout_channel_index(uint64_t channel_layout,
- uint64_t channel);
-
-/**
- * Get the channel with the given index in channel_layout.
- */
-uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index);
-
-/**
- * Get the name of a given channel.
- *
- * @return channel name on success, NULL on error.
- */
-const char *av_get_channel_name(uint64_t channel);
-
-/**
- * Get the description of a given channel.
- *
- * @param channel a channel layout with a single channel
- * @return channel description on success, NULL on error
- */
-const char *av_get_channel_description(uint64_t channel);
-
-/**
- * Get the value and name of a standard channel layout.
- *
- * @param[in] index index in an internal list, starting at 0
- * @param[out] layout channel layout mask
- * @param[out] name name of the layout
- * @return 0 if the layout exists,
- * <0 if index is beyond the limits
- */
-int av_get_standard_channel_layout(unsigned index, uint64_t *layout,
- const char **name);
-
-/**
- * @}
- */
-
-#endif /* AVUTIL_CHANNEL_LAYOUT_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/colorspace.h b/src/thirdparty/ffmpeg/libavutil/colorspace.h
deleted file mode 100644
index ce2a172c3..000000000
--- a/src/thirdparty/ffmpeg/libavutil/colorspace.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Colorspace conversion defines
- * Copyright (c) 2001, 2002, 2003 Fabrice Bellard
- *
- * 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
- * Various defines for YUV<->RGB conversion
- */
-
-#ifndef AVUTIL_COLORSPACE_H
-#define AVUTIL_COLORSPACE_H
-
-#define SCALEBITS 10
-#define ONE_HALF (1 << (SCALEBITS - 1))
-#define FIX(x) ((int) ((x) * (1<<SCALEBITS) + 0.5))
-
-#define YUV_TO_RGB1_CCIR(cb1, cr1)\
-{\
- cb = (cb1) - 128;\
- cr = (cr1) - 128;\
- r_add = FIX(1.40200*255.0/224.0) * cr + ONE_HALF;\
- g_add = - FIX(0.34414*255.0/224.0) * cb - FIX(0.71414*255.0/224.0) * cr + \
- ONE_HALF;\
- b_add = FIX(1.77200*255.0/224.0) * cb + ONE_HALF;\
-}
-
-#define YUV_TO_RGB2_CCIR(r, g, b, y1)\
-{\
- y = ((y1) - 16) * FIX(255.0/219.0);\
- r = cm[(y + r_add) >> SCALEBITS];\
- g = cm[(y + g_add) >> SCALEBITS];\
- b = cm[(y + b_add) >> SCALEBITS];\
-}
-
-#define YUV_TO_RGB1(cb1, cr1)\
-{\
- cb = (cb1) - 128;\
- cr = (cr1) - 128;\
- r_add = FIX(1.40200) * cr + ONE_HALF;\
- g_add = - FIX(0.34414) * cb - FIX(0.71414) * cr + ONE_HALF;\
- b_add = FIX(1.77200) * cb + ONE_HALF;\
-}
-
-#define YUV_TO_RGB2(r, g, b, y1)\
-{\
- y = (y1) << SCALEBITS;\
- r = cm[(y + r_add) >> SCALEBITS];\
- g = cm[(y + g_add) >> SCALEBITS];\
- b = cm[(y + b_add) >> SCALEBITS];\
-}
-
-#define Y_CCIR_TO_JPEG(y)\
- cm[((y) * FIX(255.0/219.0) + (ONE_HALF - 16 * FIX(255.0/219.0))) >> SCALEBITS]
-
-#define Y_JPEG_TO_CCIR(y)\
- (((y) * FIX(219.0/255.0) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS)
-
-#define C_CCIR_TO_JPEG(y)\
- cm[(((y) - 128) * FIX(127.0/112.0) + (ONE_HALF + (128 << SCALEBITS))) >> SCALEBITS]
-
-/* NOTE: the clamp is really necessary! */
-static inline int C_JPEG_TO_CCIR(int y) {
- y = (((y - 128) * FIX(112.0/127.0) + (ONE_HALF + (128 << SCALEBITS))) >> SCALEBITS);
- if (y < 16)
- y = 16;
- return y;
-}
-
-
-#define RGB_TO_Y(r, g, b) \
-((FIX(0.29900) * (r) + FIX(0.58700) * (g) + \
- FIX(0.11400) * (b) + ONE_HALF) >> SCALEBITS)
-
-#define RGB_TO_U(r1, g1, b1, shift)\
-(((- FIX(0.16874) * r1 - FIX(0.33126) * g1 + \
- FIX(0.50000) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
-
-#define RGB_TO_V(r1, g1, b1, shift)\
-(((FIX(0.50000) * r1 - FIX(0.41869) * g1 - \
- FIX(0.08131) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
-
-#define RGB_TO_Y_CCIR(r, g, b) \
-((FIX(0.29900*219.0/255.0) * (r) + FIX(0.58700*219.0/255.0) * (g) + \
- FIX(0.11400*219.0/255.0) * (b) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS)
-
-#define RGB_TO_U_CCIR(r1, g1, b1, shift)\
-(((- FIX(0.16874*224.0/255.0) * r1 - FIX(0.33126*224.0/255.0) * g1 + \
- FIX(0.50000*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
-
-#define RGB_TO_V_CCIR(r1, g1, b1, shift)\
-(((FIX(0.50000*224.0/255.0) * r1 - FIX(0.41869*224.0/255.0) * g1 - \
- FIX(0.08131*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
-
-#endif /* AVUTIL_COLORSPACE_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/common.h b/src/thirdparty/ffmpeg/libavutil/common.h
deleted file mode 100644
index 0983af4ba..000000000
--- a/src/thirdparty/ffmpeg/libavutil/common.h
+++ /dev/null
@@ -1,437 +0,0 @@
-/*
- * copyright (c) 2006 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
- * common internal and external API header
- */
-
-#ifndef AVUTIL_COMMON_H
-#define AVUTIL_COMMON_H
-
-#include <ctype.h>
-#include <errno.h>
-#include <inttypes.h>
-#include <limits.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "attributes.h"
-#include "version.h"
-#include "libavutil/avconfig.h"
-
-#if AV_HAVE_BIGENDIAN
-# define AV_NE(be, le) (be)
-#else
-# define AV_NE(be, le) (le)
-#endif
-
-//rounded division & shift
-#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b))
-/* assume b>0 */
-#define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b))
-#define FFUDIV(a,b) (((a)>0 ?(a):(a)-(b)+1) / (b))
-#define FFUMOD(a,b) ((a)-(b)*FFUDIV(a,b))
-#define FFABS(a) ((a) >= 0 ? (a) : (-(a)))
-#define FFSIGN(a) ((a) > 0 ? 1 : -1)
-
-#define FFMAX(a,b) ((a) > (b) ? (a) : (b))
-#define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c)
-#define FFMIN(a,b) ((a) > (b) ? (b) : (a))
-#define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c)
-
-#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0)
-#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
-#define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1))
-
-/* misc math functions */
-
-/**
- * Reverse the order of the bits of an 8-bits unsigned integer.
- */
-#if FF_API_AV_REVERSE
-extern attribute_deprecated const uint8_t av_reverse[256];
-#endif
-
-#ifdef HAVE_AV_CONFIG_H
-# include "config.h"
-# include "intmath.h"
-#endif
-
-/* Pull in unguarded fallback defines at the end of this file. */
-#include "common.h"
-
-#ifndef av_log2
-av_const int av_log2(unsigned v);
-#endif
-
-#ifndef av_log2_16bit
-av_const int av_log2_16bit(unsigned v);
-#endif
-
-/**
- * Clip a signed integer value into the amin-amax range.
- * @param a value to clip
- * @param amin minimum value of the clip range
- * @param amax maximum value of the clip range
- * @return clipped value
- */
-static av_always_inline av_const int av_clip_c(int a, int amin, int amax)
-{
-#if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
- if (amin > amax) abort();
-#endif
- if (a < amin) return amin;
- else if (a > amax) return amax;
- else return a;
-}
-
-/**
- * Clip a signed 64bit integer value into the amin-amax range.
- * @param a value to clip
- * @param amin minimum value of the clip range
- * @param amax maximum value of the clip range
- * @return clipped value
- */
-static av_always_inline av_const int64_t av_clip64_c(int64_t a, int64_t amin, int64_t amax)
-{
-#if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
- if (amin > amax) abort();
-#endif
- if (a < amin) return amin;
- else if (a > amax) return amax;
- else return a;
-}
-
-/**
- * Clip a signed integer value into the 0-255 range.
- * @param a value to clip
- * @return clipped value
- */
-static av_always_inline av_const uint8_t av_clip_uint8_c(int a)
-{
- if (a&(~0xFF)) return (-a)>>31;
- else return a;
-}
-
-/**
- * Clip a signed integer value into the -128,127 range.
- * @param a value to clip
- * @return clipped value
- */
-static av_always_inline av_const int8_t av_clip_int8_c(int a)
-{
- if ((a+0x80) & ~0xFF) return (a>>31) ^ 0x7F;
- else return a;
-}
-
-/**
- * Clip a signed integer value into the 0-65535 range.
- * @param a value to clip
- * @return clipped value
- */
-static av_always_inline av_const uint16_t av_clip_uint16_c(int a)
-{
- if (a&(~0xFFFF)) return (-a)>>31;
- else return a;
-}
-
-/**
- * Clip a signed integer value into the -32768,32767 range.
- * @param a value to clip
- * @return clipped value
- */
-static av_always_inline av_const int16_t av_clip_int16_c(int a)
-{
- if ((a+0x8000) & ~0xFFFF) return (a>>31) ^ 0x7FFF;
- else return a;
-}
-
-/**
- * Clip a signed 64-bit integer value into the -2147483648,2147483647 range.
- * @param a value to clip
- * @return clipped value
- */
-static av_always_inline av_const int32_t av_clipl_int32_c(int64_t a)
-{
- if ((a+0x80000000u) & ~UINT64_C(0xFFFFFFFF)) return (a>>63) ^ 0x7FFFFFFF;
- else return (int32_t)a;
-}
-
-/**
- * Clip a signed integer to an unsigned power of two range.
- * @param a value to clip
- * @param p bit position to clip at
- * @return clipped value
- */
-static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p)
-{
- if (a & ~((1<<p) - 1)) return -a >> 31 & ((1<<p) - 1);
- else return a;
-}
-
-/**
- * Add two signed 32-bit values with saturation.
- *
- * @param a one value
- * @param b another value
- * @return sum with signed saturation
- */
-static av_always_inline int av_sat_add32_c(int a, int b)
-{
- return av_clipl_int32((int64_t)a + b);
-}
-
-/**
- * Add a doubled value to another value with saturation at both stages.
- *
- * @param a first value
- * @param b value doubled and added to a
- * @return sum with signed saturation
- */
-static av_always_inline int av_sat_dadd32_c(int a, int b)
-{
- return av_sat_add32(a, av_sat_add32(b, b));
-}
-
-/**
- * Clip a float value into the amin-amax range.
- * @param a value to clip
- * @param amin minimum value of the clip range
- * @param amax maximum value of the clip range
- * @return clipped value
- */
-static av_always_inline av_const float av_clipf_c(float a, float amin, float amax)
-{
-#if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
- if (amin > amax) abort();
-#endif
- if (a < amin) return amin;
- else if (a > amax) return amax;
- else return a;
-}
-
-/** Compute ceil(log2(x)).
- * @param x value used to compute ceil(log2(x))
- * @return computed ceiling of log2(x)
- */
-static av_always_inline av_const int av_ceil_log2_c(int x)
-{
- return av_log2((x - 1) << 1);
-}
-
-/**
- * Count number of bits set to one in x
- * @param x value to count bits of
- * @return the number of bits set to one in x
- */
-static av_always_inline av_const int av_popcount_c(uint32_t x)
-{
- x -= (x >> 1) & 0x55555555;
- x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
- x = (x + (x >> 4)) & 0x0F0F0F0F;
- x += x >> 8;
- return (x + (x >> 16)) & 0x3F;
-}
-
-/**
- * Count number of bits set to one in x
- * @param x value to count bits of
- * @return the number of bits set to one in x
- */
-static av_always_inline av_const int av_popcount64_c(uint64_t x)
-{
- return av_popcount((uint32_t)x) + av_popcount(x >> 32);
-}
-
-#define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24))
-#define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((unsigned)(a) << 24))
-
-/**
- * Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form.
- *
- * @param val Output value, must be an lvalue of type uint32_t.
- * @param GET_BYTE Expression reading one byte from the input.
- * Evaluated up to 7 times (4 for the currently
- * assigned Unicode range). With a memory buffer
- * input, this could be *ptr++.
- * @param ERROR Expression to be evaluated on invalid input,
- * typically a goto statement.
- */
-#define GET_UTF8(val, GET_BYTE, ERROR)\
- val= GET_BYTE;\
- {\
- uint32_t top = (val & 128) >> 1;\
- if ((val & 0xc0) == 0x80)\
- ERROR\
- while (val & top) {\
- int tmp= GET_BYTE - 128;\
- if(tmp>>6)\
- ERROR\
- val= (val<<6) + tmp;\
- top <<= 5;\
- }\
- val &= (top << 1) - 1;\
- }
-
-/**
- * Convert a UTF-16 character (2 or 4 bytes) to its 32-bit UCS-4 encoded form.
- *
- * @param val Output value, must be an lvalue of type uint32_t.
- * @param GET_16BIT Expression returning two bytes of UTF-16 data converted
- * to native byte order. Evaluated one or two times.
- * @param ERROR Expression to be evaluated on invalid input,
- * typically a goto statement.
- */
-#define GET_UTF16(val, GET_16BIT, ERROR)\
- val = GET_16BIT;\
- {\
- unsigned int hi = val - 0xD800;\
- if (hi < 0x800) {\
- val = GET_16BIT - 0xDC00;\
- if (val > 0x3FFU || hi > 0x3FFU)\
- ERROR\
- val += (hi<<10) + 0x10000;\
- }\
- }\
-
-/**
- * @def PUT_UTF8(val, tmp, PUT_BYTE)
- * Convert a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long).
- * @param val is an input-only argument and should be of type uint32_t. It holds
- * a UCS-4 encoded Unicode character that is to be converted to UTF-8. If
- * val is given as a function it is executed only once.
- * @param tmp is a temporary variable and should be of type uint8_t. It
- * represents an intermediate value during conversion that is to be
- * output by PUT_BYTE.
- * @param PUT_BYTE writes the converted UTF-8 bytes to any proper destination.
- * It could be a function or a statement, and uses tmp as the input byte.
- * For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be
- * executed up to 4 times for values in the valid UTF-8 range and up to
- * 7 times in the general case, depending on the length of the converted
- * Unicode character.
- */
-#define PUT_UTF8(val, tmp, PUT_BYTE)\
- {\
- int bytes, shift;\
- uint32_t in = val;\
- if (in < 0x80) {\
- tmp = in;\
- PUT_BYTE\
- } else {\
- bytes = (av_log2(in) + 4) / 5;\
- shift = (bytes - 1) * 6;\
- tmp = (256 - (256 >> bytes)) | (in >> shift);\
- PUT_BYTE\
- while (shift >= 6) {\
- shift -= 6;\
- tmp = 0x80 | ((in >> shift) & 0x3f);\
- PUT_BYTE\
- }\
- }\
- }
-
-/**
- * @def PUT_UTF16(val, tmp, PUT_16BIT)
- * Convert a 32-bit Unicode character to its UTF-16 encoded form (2 or 4 bytes).
- * @param val is an input-only argument and should be of type uint32_t. It holds
- * a UCS-4 encoded Unicode character that is to be converted to UTF-16. If
- * val is given as a function it is executed only once.
- * @param tmp is a temporary variable and should be of type uint16_t. It
- * represents an intermediate value during conversion that is to be
- * output by PUT_16BIT.
- * @param PUT_16BIT writes the converted UTF-16 data to any proper destination
- * in desired endianness. It could be a function or a statement, and uses tmp
- * as the input byte. For example, PUT_BYTE could be "*output++ = tmp;"
- * PUT_BYTE will be executed 1 or 2 times depending on input character.
- */
-#define PUT_UTF16(val, tmp, PUT_16BIT)\
- {\
- uint32_t in = val;\
- if (in < 0x10000) {\
- tmp = in;\
- PUT_16BIT\
- } else {\
- tmp = 0xD800 | ((in - 0x10000) >> 10);\
- PUT_16BIT\
- tmp = 0xDC00 | ((in - 0x10000) & 0x3FF);\
- PUT_16BIT\
- }\
- }\
-
-
-
-#include "mem.h"
-
-#ifdef HAVE_AV_CONFIG_H
-# include "internal.h"
-#endif /* HAVE_AV_CONFIG_H */
-
-#endif /* AVUTIL_COMMON_H */
-
-/*
- * The following definitions are outside the multiple inclusion guard
- * to ensure they are immediately available in intmath.h.
- */
-
-#ifndef av_ceil_log2
-# define av_ceil_log2 av_ceil_log2_c
-#endif
-#ifndef av_clip
-# define av_clip av_clip_c
-#endif
-#ifndef av_clip64
-# define av_clip64 av_clip64_c
-#endif
-#ifndef av_clip_uint8
-# define av_clip_uint8 av_clip_uint8_c
-#endif
-#ifndef av_clip_int8
-# define av_clip_int8 av_clip_int8_c
-#endif
-#ifndef av_clip_uint16
-# define av_clip_uint16 av_clip_uint16_c
-#endif
-#ifndef av_clip_int16
-# define av_clip_int16 av_clip_int16_c
-#endif
-#ifndef av_clipl_int32
-# define av_clipl_int32 av_clipl_int32_c
-#endif
-#ifndef av_clip_uintp2
-# define av_clip_uintp2 av_clip_uintp2_c
-#endif
-#ifndef av_sat_add32
-# define av_sat_add32 av_sat_add32_c
-#endif
-#ifndef av_sat_dadd32
-# define av_sat_dadd32 av_sat_dadd32_c
-#endif
-#ifndef av_clipf
-# define av_clipf av_clipf_c
-#endif
-#ifndef av_popcount
-# define av_popcount av_popcount_c
-#endif
-#ifndef av_popcount64
-# define av_popcount64 av_popcount64_c
-#endif
diff --git a/src/thirdparty/ffmpeg/libavutil/cpu.c b/src/thirdparty/ffmpeg/libavutil/cpu.c
deleted file mode 100644
index 576777313..000000000
--- a/src/thirdparty/ffmpeg/libavutil/cpu.c
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * 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 "cpu.h"
-#include "config.h"
-#include "opt.h"
-
-static int flags, checked;
-
-void av_force_cpu_flags(int arg){
- flags = arg;
- checked = arg != -1;
-}
-
-int av_get_cpu_flags(void)
-{
- if (checked)
- return flags;
-
- if (ARCH_ARM) flags = ff_get_cpu_flags_arm();
- if (ARCH_PPC) flags = ff_get_cpu_flags_ppc();
- if (ARCH_X86) flags = ff_get_cpu_flags_x86();
-
- checked = 1;
- return flags;
-}
-
-void av_set_cpu_flags_mask(int mask)
-{
- checked = 0;
- flags = av_get_cpu_flags() & mask;
- checked = 1;
-}
-
-int av_parse_cpu_flags(const char *s)
-{
-#define CPUFLAG_MMXEXT (AV_CPU_FLAG_MMX | AV_CPU_FLAG_MMXEXT | AV_CPU_FLAG_CMOV)
-#define CPUFLAG_3DNOW (AV_CPU_FLAG_3DNOW | AV_CPU_FLAG_MMX)
-#define CPUFLAG_3DNOWEXT (AV_CPU_FLAG_3DNOWEXT | CPUFLAG_3DNOW)
-#define CPUFLAG_SSE (AV_CPU_FLAG_SSE | CPUFLAG_MMXEXT)
-#define CPUFLAG_SSE2 (AV_CPU_FLAG_SSE2 | CPUFLAG_SSE)
-#define CPUFLAG_SSE2SLOW (AV_CPU_FLAG_SSE2SLOW | CPUFLAG_SSE2)
-#define CPUFLAG_SSE3 (AV_CPU_FLAG_SSE3 | CPUFLAG_SSE2)
-#define CPUFLAG_SSE3SLOW (AV_CPU_FLAG_SSE3SLOW | CPUFLAG_SSE3)
-#define CPUFLAG_SSSE3 (AV_CPU_FLAG_SSSE3 | CPUFLAG_SSE3)
-#define CPUFLAG_SSE4 (AV_CPU_FLAG_SSE4 | CPUFLAG_SSSE3)
-#define CPUFLAG_SSE42 (AV_CPU_FLAG_SSE42 | CPUFLAG_SSE4)
-#define CPUFLAG_AVX (AV_CPU_FLAG_AVX | CPUFLAG_SSE42)
-#define CPUFLAG_XOP (AV_CPU_FLAG_XOP | CPUFLAG_AVX)
-#define CPUFLAG_FMA4 (AV_CPU_FLAG_FMA4 | CPUFLAG_AVX)
- static const AVOption cpuflags_opts[] = {
- { "flags" , NULL, 0, AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, INT64_MAX, .unit = "flags" },
-#if ARCH_PPC
- { "altivec" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ALTIVEC }, .unit = "flags" },
-#elif ARCH_X86
- { "mmx" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_MMX }, .unit = "flags" },
- { "mmxext" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_MMXEXT }, .unit = "flags" },
- { "sse" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE }, .unit = "flags" },
- { "sse2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE2 }, .unit = "flags" },
- { "sse2slow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE2SLOW }, .unit = "flags" },
- { "sse3" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE3 }, .unit = "flags" },
- { "sse3slow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE3SLOW }, .unit = "flags" },
- { "ssse3" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSSE3 }, .unit = "flags" },
- { "atom" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ATOM }, .unit = "flags" },
- { "sse4.1" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE4 }, .unit = "flags" },
- { "sse4.2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE42 }, .unit = "flags" },
- { "avx" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_AVX }, .unit = "flags" },
- { "xop" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_XOP }, .unit = "flags" },
- { "fma4" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_FMA4 }, .unit = "flags" },
- { "3dnow" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_3DNOW }, .unit = "flags" },
- { "3dnowext", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_3DNOWEXT }, .unit = "flags" },
- { "cmov", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_CMOV }, .unit = "flags" },
-#elif ARCH_ARM
- { "armv5te", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV5TE }, .unit = "flags" },
- { "armv6", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV6 }, .unit = "flags" },
- { "armv6t2", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV6T2 }, .unit = "flags" },
- { "vfp", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFP }, .unit = "flags" },
- { "vfpv3", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFPV3 }, .unit = "flags" },
- { "neon", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_NEON }, .unit = "flags" },
-#endif
- { NULL },
- };
- static const AVClass class = {
- .class_name = "cpuflags",
- .item_name = av_default_item_name,
- .option = cpuflags_opts,
- .version = LIBAVUTIL_VERSION_INT,
- };
-
- int flags = 0, ret;
- const AVClass *pclass = &class;
-
- if ((ret = av_opt_eval_flags(&pclass, &cpuflags_opts[0], s, &flags)) < 0)
- return ret;
-
- return flags & INT_MAX;
-}
-
-int av_parse_cpu_caps(unsigned *flags, const char *s)
-{
- static const AVOption cpuflags_opts[] = {
- { "flags" , NULL, 0, AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, INT64_MAX, .unit = "flags" },
-#if ARCH_PPC
- { "altivec" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ALTIVEC }, .unit = "flags" },
-#elif ARCH_X86
- { "mmx" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_MMX }, .unit = "flags" },
- { "mmx2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_MMX2 }, .unit = "flags" },
- { "mmxext" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_MMX2 }, .unit = "flags" },
- { "sse" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SSE }, .unit = "flags" },
- { "sse2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SSE2 }, .unit = "flags" },
- { "sse2slow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SSE2SLOW }, .unit = "flags" },
- { "sse3" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SSE3 }, .unit = "flags" },
- { "sse3slow", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SSE3SLOW }, .unit = "flags" },
- { "ssse3" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SSSE3 }, .unit = "flags" },
- { "atom" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ATOM }, .unit = "flags" },
- { "sse4.1" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SSE4 }, .unit = "flags" },
- { "sse4.2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SSE42 }, .unit = "flags" },
- { "avx" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_AVX }, .unit = "flags" },
- { "xop" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_XOP }, .unit = "flags" },
- { "fma4" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_FMA4 }, .unit = "flags" },
- { "3dnow" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_3DNOW }, .unit = "flags" },
- { "3dnowext", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_3DNOWEXT }, .unit = "flags" },
- { "cmov", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_CMOV }, .unit = "flags" },
-
-#define CPU_FLAG_P2 AV_CPU_FLAG_CMOV | AV_CPU_FLAG_MMX
-#define CPU_FLAG_P3 CPU_FLAG_P2 | AV_CPU_FLAG_MMX2 | AV_CPU_FLAG_SSE
-#define CPU_FLAG_P4 CPU_FLAG_P3| AV_CPU_FLAG_SSE2
- { "pentium2", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPU_FLAG_P2 }, .unit = "flags" },
- { "pentium3", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPU_FLAG_P3 }, .unit = "flags" },
- { "pentium4", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPU_FLAG_P4 }, .unit = "flags" },
-
-#define CPU_FLAG_K62 AV_CPU_FLAG_MMX | AV_CPU_FLAG_3DNOW
-#define CPU_FLAG_ATHLON CPU_FLAG_K62 | AV_CPU_FLAG_CMOV | AV_CPU_FLAG_3DNOWEXT | AV_CPU_FLAG_MMX2
-#define CPU_FLAG_ATHLONXP CPU_FLAG_ATHLON | AV_CPU_FLAG_SSE
-#define CPU_FLAG_K8 CPU_FLAG_ATHLONXP | AV_CPU_FLAG_SSE2
- { "k6", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_MMX }, .unit = "flags" },
- { "k62", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPU_FLAG_K62 }, .unit = "flags" },
- { "athlon", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPU_FLAG_ATHLON }, .unit = "flags" },
- { "athlonxp", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPU_FLAG_ATHLONXP }, .unit = "flags" },
- { "k8", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPU_FLAG_K8 }, .unit = "flags" },
-#elif ARCH_ARM
- { "armv5te", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV5TE }, .unit = "flags" },
- { "armv6", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV6 }, .unit = "flags" },
- { "armv6t2", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV6T2 }, .unit = "flags" },
- { "vfp", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFP }, .unit = "flags" },
- { "vfpv3", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFPV3 }, .unit = "flags" },
- { "neon", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_NEON }, .unit = "flags" },
-#endif
- { NULL },
- };
- static const AVClass class = {
- .class_name = "cpuflags",
- .item_name = av_default_item_name,
- .option = cpuflags_opts,
- .version = LIBAVUTIL_VERSION_INT,
- };
- const AVClass *pclass = &class;
-
- return av_opt_eval_flags(&pclass, &cpuflags_opts[0], s, flags);
-}
-#ifdef TEST
-
-#include <stdio.h>
-
-static const struct {
- int flag;
- const char *name;
-} cpu_flag_tab[] = {
-#if ARCH_ARM
- { AV_CPU_FLAG_ARMV5TE, "armv5te" },
- { AV_CPU_FLAG_ARMV6, "armv6" },
- { AV_CPU_FLAG_ARMV6T2, "armv6t2" },
- { AV_CPU_FLAG_VFP, "vfp" },
- { AV_CPU_FLAG_VFPV3, "vfpv3" },
- { AV_CPU_FLAG_NEON, "neon" },
-#elif ARCH_PPC
- { AV_CPU_FLAG_ALTIVEC, "altivec" },
-#elif ARCH_X86
- { AV_CPU_FLAG_MMX, "mmx" },
- { AV_CPU_FLAG_MMXEXT, "mmxext" },
- { AV_CPU_FLAG_SSE, "sse" },
- { AV_CPU_FLAG_SSE2, "sse2" },
- { AV_CPU_FLAG_SSE2SLOW, "sse2(slow)" },
- { AV_CPU_FLAG_SSE3, "sse3" },
- { AV_CPU_FLAG_SSE3SLOW, "sse3(slow)" },
- { AV_CPU_FLAG_SSSE3, "ssse3" },
- { AV_CPU_FLAG_ATOM, "atom" },
- { AV_CPU_FLAG_SSE4, "sse4.1" },
- { AV_CPU_FLAG_SSE42, "sse4.2" },
- { AV_CPU_FLAG_AVX, "avx" },
- { AV_CPU_FLAG_XOP, "xop" },
- { AV_CPU_FLAG_FMA4, "fma4" },
- { AV_CPU_FLAG_3DNOW, "3dnow" },
- { AV_CPU_FLAG_3DNOWEXT, "3dnowext" },
- { AV_CPU_FLAG_CMOV, "cmov" },
-#endif
- { 0 }
-};
-
-int main(void)
-{
- int cpu_flags = av_get_cpu_flags();
- int i;
-
- printf("cpu_flags = 0x%08X\n", cpu_flags);
- printf("cpu_flags =");
- for (i = 0; cpu_flag_tab[i].flag; i++)
- if (cpu_flags & cpu_flag_tab[i].flag)
- printf(" %s", cpu_flag_tab[i].name);
- printf("\n");
-
- return 0;
-}
-
-#endif
diff --git a/src/thirdparty/ffmpeg/libavutil/cpu.h b/src/thirdparty/ffmpeg/libavutil/cpu.h
deleted file mode 100644
index 19c97409a..000000000
--- a/src/thirdparty/ffmpeg/libavutil/cpu.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
- *
- * 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 AVUTIL_CPU_H
-#define AVUTIL_CPU_H
-
-#include "attributes.h"
-
-#define AV_CPU_FLAG_FORCE 0x80000000 /* force usage of selected flags (OR) */
-
- /* lower 16 bits - CPU features */
-#define AV_CPU_FLAG_MMX 0x0001 ///< standard MMX
-#define AV_CPU_FLAG_MMXEXT 0x0002 ///< SSE integer functions or AMD MMX ext
-#define AV_CPU_FLAG_MMX2 0x0002 ///< SSE integer functions or AMD MMX ext
-#define AV_CPU_FLAG_3DNOW 0x0004 ///< AMD 3DNOW
-#define AV_CPU_FLAG_SSE 0x0008 ///< SSE functions
-#define AV_CPU_FLAG_SSE2 0x0010 ///< PIV SSE2 functions
-#define AV_CPU_FLAG_SSE2SLOW 0x40000000 ///< SSE2 supported, but usually not faster
-#define AV_CPU_FLAG_3DNOWEXT 0x0020 ///< AMD 3DNowExt
-#define AV_CPU_FLAG_SSE3 0x0040 ///< Prescott SSE3 functions
-#define AV_CPU_FLAG_SSE3SLOW 0x20000000 ///< SSE3 supported, but usually not faster
-#define AV_CPU_FLAG_SSSE3 0x0080 ///< Conroe SSSE3 functions
-#define AV_CPU_FLAG_ATOM 0x10000000 ///< Atom processor, some SSSE3 instructions are slower
-#define AV_CPU_FLAG_SSE4 0x0100 ///< Penryn SSE4.1 functions
-#define AV_CPU_FLAG_SSE42 0x0200 ///< Nehalem SSE4.2 functions
-#define AV_CPU_FLAG_AVX 0x4000 ///< AVX functions: requires OS support even if YMM registers aren't used
-#define AV_CPU_FLAG_XOP 0x0400 ///< Bulldozer XOP functions
-#define AV_CPU_FLAG_FMA4 0x0800 ///< Bulldozer FMA4 functions
-// #if LIBAVUTIL_VERSION_MAJOR <52
-#define AV_CPU_FLAG_CMOV 0x1001000 ///< supports cmov instruction
-// #else
-// #define AV_CPU_FLAG_CMOV 0x1000 ///< supports cmov instruction
-// #endif
-
-#define AV_CPU_FLAG_ALTIVEC 0x0001 ///< standard
-
-#define AV_CPU_FLAG_ARMV5TE (1 << 0)
-#define AV_CPU_FLAG_ARMV6 (1 << 1)
-#define AV_CPU_FLAG_ARMV6T2 (1 << 2)
-#define AV_CPU_FLAG_VFP (1 << 3)
-#define AV_CPU_FLAG_VFPV3 (1 << 4)
-#define AV_CPU_FLAG_NEON (1 << 5)
-
-/**
- * Return the flags which specify extensions supported by the CPU.
- * The returned value is affected by av_force_cpu_flags() if that was used
- * before. So av_get_cpu_flags() can easily be used in a application to
- * detect the enabled cpu flags.
- */
-int av_get_cpu_flags(void);
-
-/**
- * Disables cpu detection and forces the specified flags.
- * -1 is a special case that disables forcing of specific flags.
- */
-void av_force_cpu_flags(int flags);
-
-/**
- * Set a mask on flags returned by av_get_cpu_flags().
- * This function is mainly useful for testing.
- * Please use av_force_cpu_flags() and av_get_cpu_flags() instead which are more flexible
- *
- * @warning this function is not thread safe.
- */
-attribute_deprecated void av_set_cpu_flags_mask(int mask);
-
-/**
- * Parse CPU flags from a string.
- *
- * The returned flags contain the specified flags as well as related unspecified flags.
- *
- * This function exists only for compatibility with libav.
- * Please use av_parse_cpu_caps() when possible.
- * @return a combination of AV_CPU_* flags, negative on error.
- */
-attribute_deprecated
-int av_parse_cpu_flags(const char *s);
-
-/**
- * Parse CPU caps from a string and update the given AV_CPU_* flags based on that.
- *
- * @return negative on error.
- */
-int av_parse_cpu_caps(unsigned *flags, const char *s);
-
-/* The following CPU-specific functions shall not be called directly. */
-int ff_get_cpu_flags_arm(void);
-int ff_get_cpu_flags_ppc(void);
-int ff_get_cpu_flags_x86(void);
-
-#endif /* AVUTIL_CPU_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/crc.c b/src/thirdparty/ffmpeg/libavutil/crc.c
deleted file mode 100644
index 685f0382f..000000000
--- a/src/thirdparty/ffmpeg/libavutil/crc.c
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * copyright (c) 2006 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
- */
-
-#include "config.h"
-#include "common.h"
-#include "bswap.h"
-#include "crc.h"
-
-#if CONFIG_HARDCODED_TABLES
-static const AVCRC av_crc_table[AV_CRC_MAX][257] = {
- [AV_CRC_8_ATM] = {
- 0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15, 0x38, 0x3F, 0x36, 0x31,
- 0x24, 0x23, 0x2A, 0x2D, 0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65,
- 0x48, 0x4F, 0x46, 0x41, 0x54, 0x53, 0x5A, 0x5D, 0xE0, 0xE7, 0xEE, 0xE9,
- 0xFC, 0xFB, 0xF2, 0xF5, 0xD8, 0xDF, 0xD6, 0xD1, 0xC4, 0xC3, 0xCA, 0xCD,
- 0x90, 0x97, 0x9E, 0x99, 0x8C, 0x8B, 0x82, 0x85, 0xA8, 0xAF, 0xA6, 0xA1,
- 0xB4, 0xB3, 0xBA, 0xBD, 0xC7, 0xC0, 0xC9, 0xCE, 0xDB, 0xDC, 0xD5, 0xD2,
- 0xFF, 0xF8, 0xF1, 0xF6, 0xE3, 0xE4, 0xED, 0xEA, 0xB7, 0xB0, 0xB9, 0xBE,
- 0xAB, 0xAC, 0xA5, 0xA2, 0x8F, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9D, 0x9A,
- 0x27, 0x20, 0x29, 0x2E, 0x3B, 0x3C, 0x35, 0x32, 0x1F, 0x18, 0x11, 0x16,
- 0x03, 0x04, 0x0D, 0x0A, 0x57, 0x50, 0x59, 0x5E, 0x4B, 0x4C, 0x45, 0x42,
- 0x6F, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7D, 0x7A, 0x89, 0x8E, 0x87, 0x80,
- 0x95, 0x92, 0x9B, 0x9C, 0xB1, 0xB6, 0xBF, 0xB8, 0xAD, 0xAA, 0xA3, 0xA4,
- 0xF9, 0xFE, 0xF7, 0xF0, 0xE5, 0xE2, 0xEB, 0xEC, 0xC1, 0xC6, 0xCF, 0xC8,
- 0xDD, 0xDA, 0xD3, 0xD4, 0x69, 0x6E, 0x67, 0x60, 0x75, 0x72, 0x7B, 0x7C,
- 0x51, 0x56, 0x5F, 0x58, 0x4D, 0x4A, 0x43, 0x44, 0x19, 0x1E, 0x17, 0x10,
- 0x05, 0x02, 0x0B, 0x0C, 0x21, 0x26, 0x2F, 0x28, 0x3D, 0x3A, 0x33, 0x34,
- 0x4E, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5C, 0x5B, 0x76, 0x71, 0x78, 0x7F,
- 0x6A, 0x6D, 0x64, 0x63, 0x3E, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2C, 0x2B,
- 0x06, 0x01, 0x08, 0x0F, 0x1A, 0x1D, 0x14, 0x13, 0xAE, 0xA9, 0xA0, 0xA7,
- 0xB2, 0xB5, 0xBC, 0xBB, 0x96, 0x91, 0x98, 0x9F, 0x8A, 0x8D, 0x84, 0x83,
- 0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB, 0xE6, 0xE1, 0xE8, 0xEF,
- 0xFA, 0xFD, 0xF4, 0xF3, 0x01
- },
- [AV_CRC_16_ANSI] = {
- 0x0000, 0x0580, 0x0F80, 0x0A00, 0x1B80, 0x1E00, 0x1400, 0x1180,
- 0x3380, 0x3600, 0x3C00, 0x3980, 0x2800, 0x2D80, 0x2780, 0x2200,
- 0x6380, 0x6600, 0x6C00, 0x6980, 0x7800, 0x7D80, 0x7780, 0x7200,
- 0x5000, 0x5580, 0x5F80, 0x5A00, 0x4B80, 0x4E00, 0x4400, 0x4180,
- 0xC380, 0xC600, 0xCC00, 0xC980, 0xD800, 0xDD80, 0xD780, 0xD200,
- 0xF000, 0xF580, 0xFF80, 0xFA00, 0xEB80, 0xEE00, 0xE400, 0xE180,
- 0xA000, 0xA580, 0xAF80, 0xAA00, 0xBB80, 0xBE00, 0xB400, 0xB180,
- 0x9380, 0x9600, 0x9C00, 0x9980, 0x8800, 0x8D80, 0x8780, 0x8200,
- 0x8381, 0x8601, 0x8C01, 0x8981, 0x9801, 0x9D81, 0x9781, 0x9201,
- 0xB001, 0xB581, 0xBF81, 0xBA01, 0xAB81, 0xAE01, 0xA401, 0xA181,
- 0xE001, 0xE581, 0xEF81, 0xEA01, 0xFB81, 0xFE01, 0xF401, 0xF181,
- 0xD381, 0xD601, 0xDC01, 0xD981, 0xC801, 0xCD81, 0xC781, 0xC201,
- 0x4001, 0x4581, 0x4F81, 0x4A01, 0x5B81, 0x5E01, 0x5401, 0x5181,
- 0x7381, 0x7601, 0x7C01, 0x7981, 0x6801, 0x6D81, 0x6781, 0x6201,
- 0x2381, 0x2601, 0x2C01, 0x2981, 0x3801, 0x3D81, 0x3781, 0x3201,
- 0x1001, 0x1581, 0x1F81, 0x1A01, 0x0B81, 0x0E01, 0x0401, 0x0181,
- 0x0383, 0x0603, 0x0C03, 0x0983, 0x1803, 0x1D83, 0x1783, 0x1203,
- 0x3003, 0x3583, 0x3F83, 0x3A03, 0x2B83, 0x2E03, 0x2403, 0x2183,
- 0x6003, 0x6583, 0x6F83, 0x6A03, 0x7B83, 0x7E03, 0x7403, 0x7183,
- 0x5383, 0x5603, 0x5C03, 0x5983, 0x4803, 0x4D83, 0x4783, 0x4203,
- 0xC003, 0xC583, 0xCF83, 0xCA03, 0xDB83, 0xDE03, 0xD403, 0xD183,
- 0xF383, 0xF603, 0xFC03, 0xF983, 0xE803, 0xED83, 0xE783, 0xE203,
- 0xA383, 0xA603, 0xAC03, 0xA983, 0xB803, 0xBD83, 0xB783, 0xB203,
- 0x9003, 0x9583, 0x9F83, 0x9A03, 0x8B83, 0x8E03, 0x8403, 0x8183,
- 0x8002, 0x8582, 0x8F82, 0x8A02, 0x9B82, 0x9E02, 0x9402, 0x9182,
- 0xB382, 0xB602, 0xBC02, 0xB982, 0xA802, 0xAD82, 0xA782, 0xA202,
- 0xE382, 0xE602, 0xEC02, 0xE982, 0xF802, 0xFD82, 0xF782, 0xF202,
- 0xD002, 0xD582, 0xDF82, 0xDA02, 0xCB82, 0xCE02, 0xC402, 0xC182,
- 0x4382, 0x4602, 0x4C02, 0x4982, 0x5802, 0x5D82, 0x5782, 0x5202,
- 0x7002, 0x7582, 0x7F82, 0x7A02, 0x6B82, 0x6E02, 0x6402, 0x6182,
- 0x2002, 0x2582, 0x2F82, 0x2A02, 0x3B82, 0x3E02, 0x3402, 0x3182,
- 0x1382, 0x1602, 0x1C02, 0x1982, 0x0802, 0x0D82, 0x0782, 0x0202,
- 0x0001
- },
- [AV_CRC_16_CCITT] = {
- 0x0000, 0x2110, 0x4220, 0x6330, 0x8440, 0xA550, 0xC660, 0xE770,
- 0x0881, 0x2991, 0x4AA1, 0x6BB1, 0x8CC1, 0xADD1, 0xCEE1, 0xEFF1,
- 0x3112, 0x1002, 0x7332, 0x5222, 0xB552, 0x9442, 0xF772, 0xD662,
- 0x3993, 0x1883, 0x7BB3, 0x5AA3, 0xBDD3, 0x9CC3, 0xFFF3, 0xDEE3,
- 0x6224, 0x4334, 0x2004, 0x0114, 0xE664, 0xC774, 0xA444, 0x8554,
- 0x6AA5, 0x4BB5, 0x2885, 0x0995, 0xEEE5, 0xCFF5, 0xACC5, 0x8DD5,
- 0x5336, 0x7226, 0x1116, 0x3006, 0xD776, 0xF666, 0x9556, 0xB446,
- 0x5BB7, 0x7AA7, 0x1997, 0x3887, 0xDFF7, 0xFEE7, 0x9DD7, 0xBCC7,
- 0xC448, 0xE558, 0x8668, 0xA778, 0x4008, 0x6118, 0x0228, 0x2338,
- 0xCCC9, 0xEDD9, 0x8EE9, 0xAFF9, 0x4889, 0x6999, 0x0AA9, 0x2BB9,
- 0xF55A, 0xD44A, 0xB77A, 0x966A, 0x711A, 0x500A, 0x333A, 0x122A,
- 0xFDDB, 0xDCCB, 0xBFFB, 0x9EEB, 0x799B, 0x588B, 0x3BBB, 0x1AAB,
- 0xA66C, 0x877C, 0xE44C, 0xC55C, 0x222C, 0x033C, 0x600C, 0x411C,
- 0xAEED, 0x8FFD, 0xECCD, 0xCDDD, 0x2AAD, 0x0BBD, 0x688D, 0x499D,
- 0x977E, 0xB66E, 0xD55E, 0xF44E, 0x133E, 0x322E, 0x511E, 0x700E,
- 0x9FFF, 0xBEEF, 0xDDDF, 0xFCCF, 0x1BBF, 0x3AAF, 0x599F, 0x788F,
- 0x8891, 0xA981, 0xCAB1, 0xEBA1, 0x0CD1, 0x2DC1, 0x4EF1, 0x6FE1,
- 0x8010, 0xA100, 0xC230, 0xE320, 0x0450, 0x2540, 0x4670, 0x6760,
- 0xB983, 0x9893, 0xFBA3, 0xDAB3, 0x3DC3, 0x1CD3, 0x7FE3, 0x5EF3,
- 0xB102, 0x9012, 0xF322, 0xD232, 0x3542, 0x1452, 0x7762, 0x5672,
- 0xEAB5, 0xCBA5, 0xA895, 0x8985, 0x6EF5, 0x4FE5, 0x2CD5, 0x0DC5,
- 0xE234, 0xC324, 0xA014, 0x8104, 0x6674, 0x4764, 0x2454, 0x0544,
- 0xDBA7, 0xFAB7, 0x9987, 0xB897, 0x5FE7, 0x7EF7, 0x1DC7, 0x3CD7,
- 0xD326, 0xF236, 0x9106, 0xB016, 0x5766, 0x7676, 0x1546, 0x3456,
- 0x4CD9, 0x6DC9, 0x0EF9, 0x2FE9, 0xC899, 0xE989, 0x8AB9, 0xABA9,
- 0x4458, 0x6548, 0x0678, 0x2768, 0xC018, 0xE108, 0x8238, 0xA328,
- 0x7DCB, 0x5CDB, 0x3FEB, 0x1EFB, 0xF98B, 0xD89B, 0xBBAB, 0x9ABB,
- 0x754A, 0x545A, 0x376A, 0x167A, 0xF10A, 0xD01A, 0xB32A, 0x923A,
- 0x2EFD, 0x0FED, 0x6CDD, 0x4DCD, 0xAABD, 0x8BAD, 0xE89D, 0xC98D,
- 0x267C, 0x076C, 0x645C, 0x454C, 0xA23C, 0x832C, 0xE01C, 0xC10C,
- 0x1FEF, 0x3EFF, 0x5DCF, 0x7CDF, 0x9BAF, 0xBABF, 0xD98F, 0xF89F,
- 0x176E, 0x367E, 0x554E, 0x745E, 0x932E, 0xB23E, 0xD10E, 0xF01E,
- 0x0001
- },
- [AV_CRC_32_IEEE] = {
- 0x00000000, 0xB71DC104, 0x6E3B8209, 0xD926430D, 0xDC760413, 0x6B6BC517,
- 0xB24D861A, 0x0550471E, 0xB8ED0826, 0x0FF0C922, 0xD6D68A2F, 0x61CB4B2B,
- 0x649B0C35, 0xD386CD31, 0x0AA08E3C, 0xBDBD4F38, 0x70DB114C, 0xC7C6D048,
- 0x1EE09345, 0xA9FD5241, 0xACAD155F, 0x1BB0D45B, 0xC2969756, 0x758B5652,
- 0xC836196A, 0x7F2BD86E, 0xA60D9B63, 0x11105A67, 0x14401D79, 0xA35DDC7D,
- 0x7A7B9F70, 0xCD665E74, 0xE0B62398, 0x57ABE29C, 0x8E8DA191, 0x39906095,
- 0x3CC0278B, 0x8BDDE68F, 0x52FBA582, 0xE5E66486, 0x585B2BBE, 0xEF46EABA,
- 0x3660A9B7, 0x817D68B3, 0x842D2FAD, 0x3330EEA9, 0xEA16ADA4, 0x5D0B6CA0,
- 0x906D32D4, 0x2770F3D0, 0xFE56B0DD, 0x494B71D9, 0x4C1B36C7, 0xFB06F7C3,
- 0x2220B4CE, 0x953D75CA, 0x28803AF2, 0x9F9DFBF6, 0x46BBB8FB, 0xF1A679FF,
- 0xF4F63EE1, 0x43EBFFE5, 0x9ACDBCE8, 0x2DD07DEC, 0x77708634, 0xC06D4730,
- 0x194B043D, 0xAE56C539, 0xAB068227, 0x1C1B4323, 0xC53D002E, 0x7220C12A,
- 0xCF9D8E12, 0x78804F16, 0xA1A60C1B, 0x16BBCD1F, 0x13EB8A01, 0xA4F64B05,
- 0x7DD00808, 0xCACDC90C, 0x07AB9778, 0xB0B6567C, 0x69901571, 0xDE8DD475,
- 0xDBDD936B, 0x6CC0526F, 0xB5E61162, 0x02FBD066, 0xBF469F5E, 0x085B5E5A,
- 0xD17D1D57, 0x6660DC53, 0x63309B4D, 0xD42D5A49, 0x0D0B1944, 0xBA16D840,
- 0x97C6A5AC, 0x20DB64A8, 0xF9FD27A5, 0x4EE0E6A1, 0x4BB0A1BF, 0xFCAD60BB,
- 0x258B23B6, 0x9296E2B2, 0x2F2BAD8A, 0x98366C8E, 0x41102F83, 0xF60DEE87,
- 0xF35DA999, 0x4440689D, 0x9D662B90, 0x2A7BEA94, 0xE71DB4E0, 0x500075E4,
- 0x892636E9, 0x3E3BF7ED, 0x3B6BB0F3, 0x8C7671F7, 0x555032FA, 0xE24DF3FE,
- 0x5FF0BCC6, 0xE8ED7DC2, 0x31CB3ECF, 0x86D6FFCB, 0x8386B8D5, 0x349B79D1,
- 0xEDBD3ADC, 0x5AA0FBD8, 0xEEE00C69, 0x59FDCD6D, 0x80DB8E60, 0x37C64F64,
- 0x3296087A, 0x858BC97E, 0x5CAD8A73, 0xEBB04B77, 0x560D044F, 0xE110C54B,
- 0x38368646, 0x8F2B4742, 0x8A7B005C, 0x3D66C158, 0xE4408255, 0x535D4351,
- 0x9E3B1D25, 0x2926DC21, 0xF0009F2C, 0x471D5E28, 0x424D1936, 0xF550D832,
- 0x2C769B3F, 0x9B6B5A3B, 0x26D61503, 0x91CBD407, 0x48ED970A, 0xFFF0560E,
- 0xFAA01110, 0x4DBDD014, 0x949B9319, 0x2386521D, 0x0E562FF1, 0xB94BEEF5,
- 0x606DADF8, 0xD7706CFC, 0xD2202BE2, 0x653DEAE6, 0xBC1BA9EB, 0x0B0668EF,
- 0xB6BB27D7, 0x01A6E6D3, 0xD880A5DE, 0x6F9D64DA, 0x6ACD23C4, 0xDDD0E2C0,
- 0x04F6A1CD, 0xB3EB60C9, 0x7E8D3EBD, 0xC990FFB9, 0x10B6BCB4, 0xA7AB7DB0,
- 0xA2FB3AAE, 0x15E6FBAA, 0xCCC0B8A7, 0x7BDD79A3, 0xC660369B, 0x717DF79F,
- 0xA85BB492, 0x1F467596, 0x1A163288, 0xAD0BF38C, 0x742DB081, 0xC3307185,
- 0x99908A5D, 0x2E8D4B59, 0xF7AB0854, 0x40B6C950, 0x45E68E4E, 0xF2FB4F4A,
- 0x2BDD0C47, 0x9CC0CD43, 0x217D827B, 0x9660437F, 0x4F460072, 0xF85BC176,
- 0xFD0B8668, 0x4A16476C, 0x93300461, 0x242DC565, 0xE94B9B11, 0x5E565A15,
- 0x87701918, 0x306DD81C, 0x353D9F02, 0x82205E06, 0x5B061D0B, 0xEC1BDC0F,
- 0x51A69337, 0xE6BB5233, 0x3F9D113E, 0x8880D03A, 0x8DD09724, 0x3ACD5620,
- 0xE3EB152D, 0x54F6D429, 0x7926A9C5, 0xCE3B68C1, 0x171D2BCC, 0xA000EAC8,
- 0xA550ADD6, 0x124D6CD2, 0xCB6B2FDF, 0x7C76EEDB, 0xC1CBA1E3, 0x76D660E7,
- 0xAFF023EA, 0x18EDE2EE, 0x1DBDA5F0, 0xAAA064F4, 0x738627F9, 0xC49BE6FD,
- 0x09FDB889, 0xBEE0798D, 0x67C63A80, 0xD0DBFB84, 0xD58BBC9A, 0x62967D9E,
- 0xBBB03E93, 0x0CADFF97, 0xB110B0AF, 0x060D71AB, 0xDF2B32A6, 0x6836F3A2,
- 0x6D66B4BC, 0xDA7B75B8, 0x035D36B5, 0xB440F7B1, 0x00000001
- },
- [AV_CRC_32_IEEE_LE] = {
- 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F,
- 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
- 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2,
- 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
- 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9,
- 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
- 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C,
- 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
- 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423,
- 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
- 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106,
- 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
- 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D,
- 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
- 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950,
- 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
- 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7,
- 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
- 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA,
- 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
- 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81,
- 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
- 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84,
- 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
- 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB,
- 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
- 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E,
- 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
- 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55,
- 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
- 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28,
- 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
- 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F,
- 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
- 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242,
- 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
- 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69,
- 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
- 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC,
- 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
- 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693,
- 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
- 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D, 0x00000001
- },
-};
-#else
-static struct {
- uint8_t le;
- uint8_t bits;
- uint32_t poly;
-} av_crc_table_params[AV_CRC_MAX] = {
- [AV_CRC_8_ATM] = { 0, 8, 0x07 },
- [AV_CRC_16_ANSI] = { 0, 16, 0x8005 },
- [AV_CRC_16_CCITT] = { 0, 16, 0x1021 },
- [AV_CRC_32_IEEE] = { 0, 32, 0x04C11DB7 },
- [AV_CRC_32_IEEE_LE] = { 1, 32, 0xEDB88320 },
-};
-static AVCRC av_crc_table[AV_CRC_MAX][257];
-#endif
-
-int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size)
-{
- unsigned i, j;
- uint32_t c;
-
- if (bits < 8 || bits > 32 || poly >= (1LL << bits))
- return -1;
- if (ctx_size != sizeof(AVCRC) * 257 && ctx_size != sizeof(AVCRC) * 1024)
- return -1;
-
- for (i = 0; i < 256; i++) {
- if (le) {
- for (c = i, j = 0; j < 8; j++)
- c = (c >> 1) ^ (poly & (-(c & 1)));
- ctx[i] = c;
- } else {
- for (c = i << 24, j = 0; j < 8; j++)
- c = (c << 1) ^ ((poly << (32 - bits)) & (((int32_t) c) >> 31));
- ctx[i] = av_bswap32(c);
- }
- }
- ctx[256] = 1;
-#if !CONFIG_SMALL
- if (ctx_size >= sizeof(AVCRC) * 1024)
- for (i = 0; i < 256; i++)
- for (j = 0; j < 3; j++)
- ctx[256 *(j + 1) + i] =
- (ctx[256 * j + i] >> 8) ^ ctx[ctx[256 * j + i] & 0xFF];
-#endif
-
- return 0;
-}
-
-const AVCRC *av_crc_get_table(AVCRCId crc_id)
-{
-#if !CONFIG_HARDCODED_TABLES
- if (!av_crc_table[crc_id][FF_ARRAY_ELEMS(av_crc_table[crc_id]) - 1])
- if (av_crc_init(av_crc_table[crc_id],
- av_crc_table_params[crc_id].le,
- av_crc_table_params[crc_id].bits,
- av_crc_table_params[crc_id].poly,
- sizeof(av_crc_table[crc_id])) < 0)
- return NULL;
-#endif
- return av_crc_table[crc_id];
-}
-
-uint32_t av_crc(const AVCRC *ctx, uint32_t crc,
- const uint8_t *buffer, size_t length)
-{
- const uint8_t *end = buffer + length;
-
-#if !CONFIG_SMALL
- if (!ctx[256]) {
- while (((intptr_t) buffer & 3) && buffer < end)
- crc = ctx[((uint8_t) crc) ^ *buffer++] ^ (crc >> 8);
-
- while (buffer < end - 3) {
- crc ^= av_le2ne32(*(const uint32_t *) buffer); buffer += 4;
- crc = ctx[3 * 256 + ( crc & 0xFF)] ^
- ctx[2 * 256 + ((crc >> 8 ) & 0xFF)] ^
- ctx[1 * 256 + ((crc >> 16) & 0xFF)] ^
- ctx[0 * 256 + ((crc >> 24) )];
- }
- }
-#endif
- while (buffer < end)
- crc = ctx[((uint8_t) crc) ^ *buffer++] ^ (crc >> 8);
-
- return crc;
-}
-
-#ifdef TEST
-int main(void)
-{
- uint8_t buf[1999];
- int i;
- int p[4][3] = { { AV_CRC_32_IEEE_LE, 0xEDB88320, 0x3D5CDD04 },
- { AV_CRC_32_IEEE , 0x04C11DB7, 0xC0F5BAE0 },
- { AV_CRC_16_ANSI , 0x8005 , 0x1FBB },
- { AV_CRC_8_ATM , 0x07 , 0xE3 }
- };
- const AVCRC *ctx;
-
- for (i = 0; i < sizeof(buf); i++)
- buf[i] = i + i * i;
-
- for (i = 0; i < 4; i++) {
- ctx = av_crc_get_table(p[i][0]);
- printf("crc %08X = %X\n", p[i][1], av_crc(ctx, 0, buf, sizeof(buf)));
- }
- return 0;
-}
-#endif
diff --git a/src/thirdparty/ffmpeg/libavutil/crc.h b/src/thirdparty/ffmpeg/libavutil/crc.h
deleted file mode 100644
index 7bfcdfe58..000000000
--- a/src/thirdparty/ffmpeg/libavutil/crc.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * copyright (c) 2006 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
- */
-
-#ifndef AVUTIL_CRC_H
-#define AVUTIL_CRC_H
-
-#include <stdint.h>
-#include <stddef.h>
-#include "attributes.h"
-
-typedef uint32_t AVCRC;
-
-typedef enum {
- AV_CRC_8_ATM,
- AV_CRC_16_ANSI,
- AV_CRC_16_CCITT,
- AV_CRC_32_IEEE,
- AV_CRC_32_IEEE_LE, /*< reversed bitorder version of AV_CRC_32_IEEE */
- AV_CRC_MAX, /*< Not part of public API! Do not use outside libavutil. */
-}AVCRCId;
-
-/**
- * Initialize a CRC table.
- * @param ctx must be an array of size sizeof(AVCRC)*257 or sizeof(AVCRC)*1024
- * @param le If 1, the lowest bit represents the coefficient for the highest
- * exponent of the corresponding polynomial (both for poly and
- * actual CRC).
- * If 0, you must swap the CRC parameter and the result of av_crc
- * if you need the standard representation (can be simplified in
- * most cases to e.g. bswap16):
- * av_bswap32(crc << (32-bits))
- * @param bits number of bits for the CRC
- * @param poly generator polynomial without the x**bits coefficient, in the
- * representation as specified by le
- * @param ctx_size size of ctx in bytes
- * @return <0 on failure
- */
-int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size);
-
-/**
- * Get an initialized standard CRC table.
- * @param crc_id ID of a standard CRC
- * @return a pointer to the CRC table or NULL on failure
- */
-const AVCRC *av_crc_get_table(AVCRCId crc_id);
-
-/**
- * Calculate the CRC of a block.
- * @param crc CRC of previous blocks if any or initial value for CRC
- * @return CRC updated with the data from the given block
- *
- * @see av_crc_init() "le" parameter
- */
-uint32_t av_crc(const AVCRC *ctx, uint32_t crc,
- const uint8_t *buffer, size_t length) av_pure;
-
-#endif /* AVUTIL_CRC_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/dict.c b/src/thirdparty/ffmpeg/libavutil/dict.c
deleted file mode 100644
index 9ef74b5c1..000000000
--- a/src/thirdparty/ffmpeg/libavutil/dict.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * copyright (c) 2009 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 <ctype.h>
-#include <string.h>
-
-#include "avstring.h"
-#include "dict.h"
-#include "internal.h"
-#include "mem.h"
-
-struct AVDictionary {
- int count;
- AVDictionaryEntry *elems;
-};
-
-int av_dict_count(const AVDictionary *m)
-{
- return m ? m->count : 0;
-}
-
-AVDictionaryEntry *
-av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
-{
- unsigned int i, j;
-
- if(!m)
- return NULL;
-
- if(prev) i= prev - m->elems + 1;
- else i= 0;
-
- for(; i<m->count; i++){
- const char *s= m->elems[i].key;
- if(flags & AV_DICT_MATCH_CASE) for(j=0; s[j] == key[j] && key[j]; j++);
- else for(j=0; toupper(s[j]) == toupper(key[j]) && key[j]; j++);
- if(key[j])
- continue;
- if(s[j] && !(flags & AV_DICT_IGNORE_SUFFIX))
- continue;
- return &m->elems[i];
- }
- return NULL;
-}
-
-int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
-{
- AVDictionary *m = *pm;
- AVDictionaryEntry *tag = av_dict_get(m, key, NULL, flags);
- char *oldval = NULL;
-
- if(!m)
- m = *pm = av_mallocz(sizeof(*m));
-
- if(tag) {
- if (flags & AV_DICT_DONT_OVERWRITE)
- return 0;
- if (flags & AV_DICT_APPEND)
- oldval = tag->value;
- else
- av_free(tag->value);
- av_free(tag->key);
- *tag = m->elems[--m->count];
- } else {
- AVDictionaryEntry *tmp = av_realloc(m->elems, (m->count+1) * sizeof(*m->elems));
- if(tmp) {
- m->elems = tmp;
- } else
- return AVERROR(ENOMEM);
- }
- if (value) {
- if (flags & AV_DICT_DONT_STRDUP_KEY) {
- m->elems[m->count].key = (char*)(intptr_t)key;
- } else
- m->elems[m->count].key = av_strdup(key );
- if (flags & AV_DICT_DONT_STRDUP_VAL) {
- m->elems[m->count].value = (char*)(intptr_t)value;
- } else if (oldval && flags & AV_DICT_APPEND) {
- int len = strlen(oldval) + strlen(value) + 1;
- char *newval = av_mallocz(len);
- if (!newval)
- return AVERROR(ENOMEM);
- av_strlcat(newval, oldval, len);
- av_freep(&oldval);
- av_strlcat(newval, value, len);
- m->elems[m->count].value = newval;
- } else
- m->elems[m->count].value = av_strdup(value);
- m->count++;
- }
- if (!m->count) {
- av_free(m->elems);
- av_freep(pm);
- }
-
- return 0;
-}
-
-static int parse_key_value_pair(AVDictionary **pm, const char **buf,
- const char *key_val_sep, const char *pairs_sep,
- int flags)
-{
- char *key = av_get_token(buf, key_val_sep);
- char *val = NULL;
- int ret;
-
- if (key && *key && strspn(*buf, key_val_sep)) {
- (*buf)++;
- val = av_get_token(buf, pairs_sep);
- }
-
- if (key && *key && val && *val)
- ret = av_dict_set(pm, key, val, flags);
- else
- ret = AVERROR(EINVAL);
-
- av_freep(&key);
- av_freep(&val);
-
- return ret;
-}
-
-int av_dict_parse_string(AVDictionary **pm, const char *str,
- const char *key_val_sep, const char *pairs_sep,
- int flags)
-{
- int ret;
-
- if (!str)
- return 0;
-
- /* ignore STRDUP flags */
- flags &= ~(AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
-
- while (*str) {
- if ((ret = parse_key_value_pair(pm, &str, key_val_sep, pairs_sep, flags)) < 0)
- return ret;
-
- if (*str)
- str++;
- }
-
- return 0;
-}
-
-void av_dict_free(AVDictionary **pm)
-{
- AVDictionary *m = *pm;
-
- if (m) {
- while(m->count--) {
- av_free(m->elems[m->count].key);
- av_free(m->elems[m->count].value);
- }
- av_free(m->elems);
- }
- av_freep(pm);
-}
-
-void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags)
-{
- AVDictionaryEntry *t = NULL;
-
- while ((t = av_dict_get(src, "", t, AV_DICT_IGNORE_SUFFIX)))
- av_dict_set(dst, t->key, t->value, flags);
-}
diff --git a/src/thirdparty/ffmpeg/libavutil/dict.h b/src/thirdparty/ffmpeg/libavutil/dict.h
deleted file mode 100644
index d1523915e..000000000
--- a/src/thirdparty/ffmpeg/libavutil/dict.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- *
- * 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
- * Public dictionary API.
- * @deprecated
- * AVDictionary is provided for compatibility with libav. It is both in
- * implementation as well as API inefficient. It does not scale and is
- * extremely slow with large dictionaries.
- * It is recommended that new code uses our tree container from tree.c/h
- * where applicable, which uses AVL trees to achieve O(log n) performance.
- */
-
-#ifndef AVUTIL_DICT_H
-#define AVUTIL_DICT_H
-
-/**
- * @addtogroup lavu_dict AVDictionary
- * @ingroup lavu_data
- *
- * @brief Simple key:value store
- *
- * @{
- * Dictionaries are used for storing key:value pairs. To create
- * an AVDictionary, simply pass an address of a NULL pointer to
- * av_dict_set(). NULL can be used as an empty dictionary wherever
- * a pointer to an AVDictionary is required.
- * Use av_dict_get() to retrieve an entry or iterate over all
- * entries and finally av_dict_free() to free the dictionary
- * and all its contents.
- *
- * @code
- * AVDictionary *d = NULL; // "create" an empty dictionary
- * av_dict_set(&d, "foo", "bar", 0); // add an entry
- *
- * char *k = av_strdup("key"); // if your strings are already allocated,
- * char *v = av_strdup("value"); // you can avoid copying them like this
- * av_dict_set(&d, k, v, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
- *
- * AVDictionaryEntry *t = NULL;
- * while (t = av_dict_get(d, "", t, AV_DICT_IGNORE_SUFFIX)) {
- * <....> // iterate over all entries in d
- * }
- *
- * av_dict_free(&d);
- * @endcode
- *
- */
-
-#define AV_DICT_MATCH_CASE 1
-#define AV_DICT_IGNORE_SUFFIX 2
-#define AV_DICT_DONT_STRDUP_KEY 4 /**< Take ownership of a key that's been
- allocated with av_malloc() and children. */
-#define AV_DICT_DONT_STRDUP_VAL 8 /**< Take ownership of a value that's been
- allocated with av_malloc() and chilren. */
-#define AV_DICT_DONT_OVERWRITE 16 ///< Don't overwrite existing entries.
-#define AV_DICT_APPEND 32 /**< If the entry already exists, append to it. Note that no
- delimiter is added, the strings are simply concatenated. */
-
-typedef struct AVDictionaryEntry {
- char *key;
- char *value;
-} AVDictionaryEntry;
-
-typedef struct AVDictionary AVDictionary;
-
-/**
- * Get a dictionary entry with matching key.
- *
- * @param prev Set to the previous matching element to find the next.
- * If set to NULL the first matching element is returned.
- * @param flags Allows case as well as suffix-insensitive comparisons.
- * @return Found entry or NULL, changing key or value leads to undefined behavior.
- */
-AVDictionaryEntry *
-av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags);
-
-/**
- * Get number of entries in dictionary.
- *
- * @param m dictionary
- * @return number of entries in dictionary
- */
-int av_dict_count(const AVDictionary *m);
-
-/**
- * Set the given entry in *pm, overwriting an existing entry.
- *
- * @param pm pointer to a pointer to a dictionary struct. If *pm is NULL
- * a dictionary struct is allocated and put in *pm.
- * @param key entry key to add to *pm (will be av_strduped depending on flags)
- * @param value entry value to add to *pm (will be av_strduped depending on flags).
- * Passing a NULL value will cause an existing entry to be deleted.
- * @return >= 0 on success otherwise an error code <0
- */
-int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags);
-
-/**
- * Parse the key/value pairs list and add to a dictionary.
- *
- * @param key_val_sep a 0-terminated list of characters used to separate
- * key from value
- * @param pairs_sep a 0-terminated list of characters used to separate
- * two pairs from each other
- * @param flags flags to use when adding to dictionary.
- * AV_DICT_DONT_STRDUP_KEY and AV_DICT_DONT_STRDUP_VAL
- * are ignored since the key/value tokens will always
- * be duplicated.
- * @return 0 on success, negative AVERROR code on failure
- */
-int av_dict_parse_string(AVDictionary **pm, const char *str,
- const char *key_val_sep, const char *pairs_sep,
- int flags);
-
-/**
- * Copy entries from one AVDictionary struct into another.
- * @param dst pointer to a pointer to a AVDictionary struct. If *dst is NULL,
- * this function will allocate a struct for you and put it in *dst
- * @param src pointer to source AVDictionary struct
- * @param flags flags to use when setting entries in *dst
- * @note metadata is read using the AV_DICT_IGNORE_SUFFIX flag
- */
-void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags);
-
-/**
- * Free all the memory allocated for an AVDictionary struct
- * and all keys and values.
- */
-void av_dict_free(AVDictionary **m);
-
-/**
- * @}
- */
-
-#endif /* AVUTIL_DICT_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/error.c b/src/thirdparty/ffmpeg/libavutil/error.c
deleted file mode 100644
index bd66354df..000000000
--- a/src/thirdparty/ffmpeg/libavutil/error.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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
- */
-
-#undef _GNU_SOURCE
-#include "avutil.h"
-#include "avstring.h"
-#include "common.h"
-
-struct error_entry {
- int num;
- const char *tag;
- const char *str;
-};
-
-#define ERROR_TAG(tag) AVERROR_##tag, #tag
-static const struct error_entry error_entries[] = {
- { ERROR_TAG(BSF_NOT_FOUND), "Bitstream filter not found" },
- { ERROR_TAG(BUG), "Internal bug, should not have happened" },
- { ERROR_TAG(BUG2), "Internal bug, should not have happened" },
- { ERROR_TAG(BUFFER_TOO_SMALL), "Buffer too small" },
- { ERROR_TAG(DECODER_NOT_FOUND), "Decoder not found" },
- { ERROR_TAG(DEMUXER_NOT_FOUND), "Demuxer not found" },
- { ERROR_TAG(ENCODER_NOT_FOUND), "Encoder not found" },
- { ERROR_TAG(EOF), "End of file" },
- { ERROR_TAG(EXIT), "Immediate exit requested" },
- { ERROR_TAG(EXTERNAL), "Generic error in an external library" },
- { ERROR_TAG(FILTER_NOT_FOUND), "Filter not found" },
- { ERROR_TAG(INVALIDDATA), "Invalid data found when processing input" },
- { ERROR_TAG(MUXER_NOT_FOUND), "Muxer not found" },
- { ERROR_TAG(OPTION_NOT_FOUND), "Option not found" },
- { ERROR_TAG(PATCHWELCOME), "Not yet implemented in FFmpeg, patches welcome" },
- { ERROR_TAG(PROTOCOL_NOT_FOUND), "Protocol not found" },
- { ERROR_TAG(STREAM_NOT_FOUND), "Stream not found" },
- { ERROR_TAG(UNKNOWN), "Unknown error occurred" },
- { ERROR_TAG(EXPERIMENTAL), "Experimental feature" },
-};
-
-int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
-{
- int ret = 0, i;
- const struct error_entry *entry = NULL;
-
- for (i = 0; i < FF_ARRAY_ELEMS(error_entries); i++) {
- if (errnum == error_entries[i].num) {
- entry = &error_entries[i];
- break;
- }
- }
- if (entry) {
- av_strlcpy(errbuf, entry->str, errbuf_size);
- } else {
-#if HAVE_STRERROR_R
- ret = AVERROR(strerror_r(AVUNERROR(errnum), errbuf, errbuf_size));
-#else
- ret = -1;
-#endif
- if (ret < 0)
- snprintf(errbuf, errbuf_size, "Error number %d occurred", errnum);
- }
-
- return ret;
-}
-
-#ifdef TEST
-
-#undef printf
-
-int main(void)
-{
- int i;
-
- for (i = 0; i < FF_ARRAY_ELEMS(error_entries); i++) {
- const struct error_entry *entry = &error_entries[i];
- printf("%d: %s [%s]\n", entry->num, av_err2str(entry->num), entry->tag);
- }
-
- for (i = 0; i < 256; i++) {
- printf("%d: %s\n", -i, av_err2str(-i));
- }
-
- return 0;
-}
-
-#endif /* TEST */
diff --git a/src/thirdparty/ffmpeg/libavutil/error.h b/src/thirdparty/ffmpeg/libavutil/error.h
deleted file mode 100644
index b5f63fdfc..000000000
--- a/src/thirdparty/ffmpeg/libavutil/error.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * 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
- * error code definitions
- */
-
-#ifndef AVUTIL_ERROR_H
-#define AVUTIL_ERROR_H
-
-#include <errno.h>
-#include <stddef.h>
-
-/**
- * @addtogroup lavu_error
- *
- * @{
- */
-
-
-/* error handling */
-#if EDOM > 0
-#define AVERROR(e) (-(e)) ///< Returns a negative error code from a POSIX error code, to return from library functions.
-#define AVUNERROR(e) (-(e)) ///< Returns a POSIX error code from a library function error return value.
-#else
-/* Some platforms have E* and errno already negated. */
-#define AVERROR(e) (e)
-#define AVUNERROR(e) (e)
-#endif
-
-#define FFERRTAG(a, b, c, d) (-(int)MKTAG(a, b, c, d))
-
-#define AVERROR_BSF_NOT_FOUND FFERRTAG(0xF8,'B','S','F') ///< Bitstream filter not found
-#define AVERROR_BUG FFERRTAG( 'B','U','G','!') ///< Internal bug, also see AVERROR_BUG2
-#define AVERROR_BUFFER_TOO_SMALL FFERRTAG( 'B','U','F','S') ///< Buffer too small
-#define AVERROR_DECODER_NOT_FOUND FFERRTAG(0xF8,'D','E','C') ///< Decoder not found
-#define AVERROR_DEMUXER_NOT_FOUND FFERRTAG(0xF8,'D','E','M') ///< Demuxer not found
-#define AVERROR_ENCODER_NOT_FOUND FFERRTAG(0xF8,'E','N','C') ///< Encoder not found
-#define AVERROR_EOF FFERRTAG( 'E','O','F',' ') ///< End of file
-#define AVERROR_EXIT FFERRTAG( 'E','X','I','T') ///< Immediate exit was requested; the called function should not be restarted
-#define AVERROR_EXTERNAL FFERRTAG( 'E','X','T',' ') ///< Generic error in an external library
-#define AVERROR_FILTER_NOT_FOUND FFERRTAG(0xF8,'F','I','L') ///< Filter not found
-#define AVERROR_INVALIDDATA FFERRTAG( 'I','N','D','A') ///< Invalid data found when processing input
-#define AVERROR_MUXER_NOT_FOUND FFERRTAG(0xF8,'M','U','X') ///< Muxer not found
-#define AVERROR_OPTION_NOT_FOUND FFERRTAG(0xF8,'O','P','T') ///< Option not found
-#define AVERROR_PATCHWELCOME FFERRTAG( 'P','A','W','E') ///< Not yet implemented in FFmpeg, patches welcome
-#define AVERROR_PROTOCOL_NOT_FOUND FFERRTAG(0xF8,'P','R','O') ///< Protocol not found
-
-#define AVERROR_STREAM_NOT_FOUND FFERRTAG(0xF8,'S','T','R') ///< Stream not found
-/**
- * This is semantically identical to AVERROR_BUG
- * it has been introduced in Libav after our AVERROR_BUG and with a modified value.
- */
-#define AVERROR_BUG2 FFERRTAG( 'B','U','G',' ')
-#define AVERROR_UNKNOWN FFERRTAG( 'U','N','K','N') ///< Unknown error, typically from an external library
-#define AVERROR_EXPERIMENTAL (-0x2bb2afa8) ///< Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it.
-
-#define AV_ERROR_MAX_STRING_SIZE 64
-
-/**
- * Put a description of the AVERROR code errnum in errbuf.
- * In case of failure the global variable errno is set to indicate the
- * error. Even in case of failure av_strerror() will print a generic
- * error message indicating the errnum provided to errbuf.
- *
- * @param errnum error code to describe
- * @param errbuf buffer to which description is written
- * @param errbuf_size the size in bytes of errbuf
- * @return 0 on success, a negative value if a description for errnum
- * cannot be found
- */
-int av_strerror(int errnum, char *errbuf, size_t errbuf_size);
-
-/**
- * Fill the provided buffer with a string containing an error string
- * corresponding to the AVERROR code errnum.
- *
- * @param errbuf a buffer
- * @param errbuf_size size in bytes of errbuf
- * @param errnum error code to describe
- * @return the buffer in input, filled with the error description
- * @see av_strerror()
- */
-static inline char *av_make_error_string(char *errbuf, size_t errbuf_size, int errnum)
-{
- av_strerror(errnum, errbuf, errbuf_size);
- return errbuf;
-}
-
-/**
- * Convenience macro, the return value should be used only directly in
- * function arguments but never stand-alone.
- */
-#define av_err2str(errnum) \
- av_make_error_string((char[AV_ERROR_MAX_STRING_SIZE]){0}, AV_ERROR_MAX_STRING_SIZE, errnum)
-
-/**
- * @}
- */
-
-#endif /* AVUTIL_ERROR_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/eval.c b/src/thirdparty/ffmpeg/libavutil/eval.c
deleted file mode 100644
index 542e43165..000000000
--- a/src/thirdparty/ffmpeg/libavutil/eval.c
+++ /dev/null
@@ -1,834 +0,0 @@
-/*
- * Copyright (c) 2002-2006 Michael Niedermayer <michaelni@gmx.at>
- * Copyright (c) 2006 Oded Shimon <ods15@ods15.dyndns.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
- */
-
-/**
- * @file
- * simple arithmetic expression evaluator.
- *
- * see http://joe.hotchkiss.com/programming/eval/eval.html
- */
-
-#include <float.h>
-#include "avutil.h"
-#include "common.h"
-#include "eval.h"
-#include "log.h"
-#include "mathematics.h"
-#include "time.h"
-
-typedef struct Parser {
- const AVClass *class;
- int stack_index;
- char *s;
- const double *const_values;
- const char * const *const_names; // NULL terminated
- double (* const *funcs1)(void *, double a); // NULL terminated
- const char * const *func1_names; // NULL terminated
- double (* const *funcs2)(void *, double a, double b); // NULL terminated
- const char * const *func2_names; // NULL terminated
- void *opaque;
- int log_offset;
- void *log_ctx;
-#define VARS 10
- double *var;
-} Parser;
-
-static const AVClass class = { "Eval", av_default_item_name, NULL, LIBAVUTIL_VERSION_INT, offsetof(Parser,log_offset), offsetof(Parser,log_ctx) };
-
-static const int8_t si_prefixes['z' - 'E' + 1] = {
- ['y'-'E']= -24,
- ['z'-'E']= -21,
- ['a'-'E']= -18,
- ['f'-'E']= -15,
- ['p'-'E']= -12,
- ['n'-'E']= - 9,
- ['u'-'E']= - 6,
- ['m'-'E']= - 3,
- ['c'-'E']= - 2,
- ['d'-'E']= - 1,
- ['h'-'E']= 2,
- ['k'-'E']= 3,
- ['K'-'E']= 3,
- ['M'-'E']= 6,
- ['G'-'E']= 9,
- ['T'-'E']= 12,
- ['P'-'E']= 15,
- ['E'-'E']= 18,
- ['Z'-'E']= 21,
- ['Y'-'E']= 24,
-};
-
-static const struct {
- const char *name;
- double value;
-} constants[] = {
- { "E", M_E },
- { "PI", M_PI },
- { "PHI", M_PHI },
-};
-
-double av_strtod(const char *numstr, char **tail)
-{
- double d;
- char *next;
- if(numstr[0]=='0' && (numstr[1]|0x20)=='x') {
- d = strtoul(numstr, &next, 16);
- } else
- d = strtod(numstr, &next);
- /* if parsing succeeded, check for and interpret postfixes */
- if (next!=numstr) {
- if (next[0] == 'd' && next[1] == 'B') {
- /* treat dB as decibels instead of decibytes */
- d = pow(10, d / 20);
- next += 2;
- } else if (*next >= 'E' && *next <= 'z') {
- int e= si_prefixes[*next - 'E'];
- if (e) {
- if (next[1] == 'i') {
- d*= pow( 2, e/0.3);
- next+=2;
- } else {
- d*= pow(10, e);
- next++;
- }
- }
- }
-
- if (*next=='B') {
- d*=8;
- next++;
- }
- }
- /* if requested, fill in tail with the position after the last parsed
- character */
- if (tail)
- *tail = next;
- return d;
-}
-
-#define IS_IDENTIFIER_CHAR(c) ((c) - '0' <= 9U || (c) - 'a' <= 25U || (c) - 'A' <= 25U || (c) == '_')
-
-static int strmatch(const char *s, const char *prefix)
-{
- int i;
- for (i=0; prefix[i]; i++) {
- if (prefix[i] != s[i]) return 0;
- }
- /* return 1 only if the s identifier is terminated */
- return !IS_IDENTIFIER_CHAR(s[i]);
-}
-
-struct AVExpr {
- enum {
- e_value, e_const, e_func0, e_func1, e_func2,
- e_squish, e_gauss, e_ld, e_isnan, e_isinf,
- e_mod, e_max, e_min, e_eq, e_gt, e_gte,
- e_pow, e_mul, e_div, e_add,
- e_last, e_st, e_while, e_taylor, e_root, e_floor, e_ceil, e_trunc,
- e_sqrt, e_not, e_random, e_hypot, e_gcd,
- e_if, e_ifnot,
- } type;
- double value; // is sign in other types
- union {
- int const_index;
- double (*func0)(double);
- double (*func1)(void *, double);
- double (*func2)(void *, double, double);
- } a;
- struct AVExpr *param[3];
- double *var;
-};
-
-static double etime(double v)
-{
- return av_gettime() * 0.000001;
-}
-
-static double eval_expr(Parser *p, AVExpr *e)
-{
- switch (e->type) {
- case e_value: return e->value;
- case e_const: return e->value * p->const_values[e->a.const_index];
- case e_func0: return e->value * e->a.func0(eval_expr(p, e->param[0]));
- case e_func1: return e->value * e->a.func1(p->opaque, eval_expr(p, e->param[0]));
- case e_func2: return e->value * e->a.func2(p->opaque, eval_expr(p, e->param[0]), eval_expr(p, e->param[1]));
- case e_squish: return 1/(1+exp(4*eval_expr(p, e->param[0])));
- case e_gauss: { double d = eval_expr(p, e->param[0]); return exp(-d*d/2)/sqrt(2*M_PI); }
- case e_ld: return e->value * p->var[av_clip(eval_expr(p, e->param[0]), 0, VARS-1)];
- case e_isnan: return e->value * !!isnan(eval_expr(p, e->param[0]));
- case e_isinf: return e->value * !!isinf(eval_expr(p, e->param[0]));
- case e_floor: return e->value * floor(eval_expr(p, e->param[0]));
- case e_ceil : return e->value * ceil (eval_expr(p, e->param[0]));
- case e_trunc: return e->value * trunc(eval_expr(p, e->param[0]));
- case e_sqrt: return e->value * sqrt (eval_expr(p, e->param[0]));
- case e_not: return e->value * (eval_expr(p, e->param[0]) == 0);
- case e_if: return e->value * (eval_expr(p, e->param[0]) ? eval_expr(p, e->param[1]) :
- e->param[2] ? eval_expr(p, e->param[2]) : 0);
- case e_ifnot: return e->value * (!eval_expr(p, e->param[0]) ? eval_expr(p, e->param[1]) :
- e->param[2] ? eval_expr(p, e->param[2]) : 0);
- case e_random:{
- int idx= av_clip(eval_expr(p, e->param[0]), 0, VARS-1);
- uint64_t r= isnan(p->var[idx]) ? 0 : p->var[idx];
- r= r*1664525+1013904223;
- p->var[idx]= r;
- return e->value * (r * (1.0/UINT64_MAX));
- }
- case e_while: {
- double d = NAN;
- while (eval_expr(p, e->param[0]))
- d=eval_expr(p, e->param[1]);
- return d;
- }
- case e_taylor: {
- double t = 1, d = 0, v;
- double x = eval_expr(p, e->param[1]);
- int id = e->param[2] ? av_clip(eval_expr(p, e->param[2]), 0, VARS-1) : 0;
- int i;
- double var0 = p->var[id];
- for(i=0; i<1000; i++) {
- double ld = d;
- p->var[id] = i;
- v = eval_expr(p, e->param[0]);
- d += t*v;
- if(ld==d && v)
- break;
- t *= x / (i+1);
- }
- p->var[id] = var0;
- return d;
- }
- case e_root: {
- int i, j;
- double low = -1, high = -1, v, low_v = -DBL_MAX, high_v = DBL_MAX;
- double var0 = p->var[0];
- double x_max = eval_expr(p, e->param[1]);
- for(i=-1; i<1024; i++) {
- if(i<255) {
- p->var[0] = av_reverse[i&255]*x_max/255;
- } else {
- p->var[0] = x_max*pow(0.9, i-255);
- if (i&1) p->var[0] *= -1;
- if (i&2) p->var[0] += low;
- else p->var[0] += high;
- }
- v = eval_expr(p, e->param[0]);
- if (v<=0 && v>low_v) {
- low = p->var[0];
- low_v = v;
- }
- if (v>=0 && v<high_v) {
- high = p->var[0];
- high_v = v;
- }
- if (low>=0 && high>=0){
- for (j=0; j<1000; j++) {
- p->var[0] = (low+high)*0.5;
- if (low == p->var[0] || high == p->var[0])
- break;
- v = eval_expr(p, e->param[0]);
- if (v<=0) low = p->var[0];
- if (v>=0) high= p->var[0];
- if (isnan(v)) {
- low = high = v;
- break;
- }
- }
- break;
- }
- }
- p->var[0] = var0;
- return -low_v<high_v ? low : high;
- }
- default: {
- double d = eval_expr(p, e->param[0]);
- double d2 = eval_expr(p, e->param[1]);
- switch (e->type) {
- case e_mod: return e->value * (d - floor((!CONFIG_FTRAPV || d2) ? d / d2 : d * INFINITY) * d2);
- case e_gcd: return e->value * av_gcd(d,d2);
- case e_max: return e->value * (d > d2 ? d : d2);
- case e_min: return e->value * (d < d2 ? d : d2);
- case e_eq: return e->value * (d == d2 ? 1.0 : 0.0);
- case e_gt: return e->value * (d > d2 ? 1.0 : 0.0);
- case e_gte: return e->value * (d >= d2 ? 1.0 : 0.0);
- case e_pow: return e->value * pow(d, d2);
- case e_mul: return e->value * (d * d2);
- case e_div: return e->value * ((!CONFIG_FTRAPV || d2 ) ? (d / d2) : d * INFINITY);
- case e_add: return e->value * (d + d2);
- case e_last:return e->value * d2;
- case e_st : return e->value * (p->var[av_clip(d, 0, VARS-1)]= d2);
- case e_hypot:return e->value * (sqrt(d*d + d2*d2));
- }
- }
- }
- return NAN;
-}
-
-static int parse_expr(AVExpr **e, Parser *p);
-
-void av_expr_free(AVExpr *e)
-{
- if (!e) return;
- av_expr_free(e->param[0]);
- av_expr_free(e->param[1]);
- av_expr_free(e->param[2]);
- av_freep(&e->var);
- av_freep(&e);
-}
-
-static int parse_primary(AVExpr **e, Parser *p)
-{
- AVExpr *d = av_mallocz(sizeof(AVExpr));
- char *next = p->s, *s0 = p->s;
- int ret, i;
-
- if (!d)
- return AVERROR(ENOMEM);
-
- /* number */
- d->value = av_strtod(p->s, &next);
- if (next != p->s) {
- d->type = e_value;
- p->s= next;
- *e = d;
- return 0;
- }
- d->value = 1;
-
- /* named constants */
- for (i=0; p->const_names && p->const_names[i]; i++) {
- if (strmatch(p->s, p->const_names[i])) {
- p->s+= strlen(p->const_names[i]);
- d->type = e_const;
- d->a.const_index = i;
- *e = d;
- return 0;
- }
- }
- for (i = 0; i < FF_ARRAY_ELEMS(constants); i++) {
- if (strmatch(p->s, constants[i].name)) {
- p->s += strlen(constants[i].name);
- d->type = e_value;
- d->value = constants[i].value;
- *e = d;
- return 0;
- }
- }
-
- p->s= strchr(p->s, '(');
- if (p->s==NULL) {
- av_log(p, AV_LOG_ERROR, "Undefined constant or missing '(' in '%s'\n", s0);
- p->s= next;
- av_expr_free(d);
- return AVERROR(EINVAL);
- }
- p->s++; // "("
- if (*next == '(') { // special case do-nothing
- av_freep(&d);
- if ((ret = parse_expr(&d, p)) < 0)
- return ret;
- if (p->s[0] != ')') {
- av_log(p, AV_LOG_ERROR, "Missing ')' in '%s'\n", s0);
- av_expr_free(d);
- return AVERROR(EINVAL);
- }
- p->s++; // ")"
- *e = d;
- return 0;
- }
- if ((ret = parse_expr(&(d->param[0]), p)) < 0) {
- av_expr_free(d);
- return ret;
- }
- if (p->s[0]== ',') {
- p->s++; // ","
- parse_expr(&d->param[1], p);
- }
- if (p->s[0]== ',') {
- p->s++; // ","
- parse_expr(&d->param[2], p);
- }
- if (p->s[0] != ')') {
- av_log(p, AV_LOG_ERROR, "Missing ')' or too many args in '%s'\n", s0);
- av_expr_free(d);
- return AVERROR(EINVAL);
- }
- p->s++; // ")"
-
- d->type = e_func0;
- if (strmatch(next, "sinh" )) d->a.func0 = sinh;
- else if (strmatch(next, "cosh" )) d->a.func0 = cosh;
- else if (strmatch(next, "tanh" )) d->a.func0 = tanh;
- else if (strmatch(next, "sin" )) d->a.func0 = sin;
- else if (strmatch(next, "cos" )) d->a.func0 = cos;
- else if (strmatch(next, "tan" )) d->a.func0 = tan;
- else if (strmatch(next, "atan" )) d->a.func0 = atan;
- else if (strmatch(next, "asin" )) d->a.func0 = asin;
- else if (strmatch(next, "acos" )) d->a.func0 = acos;
- else if (strmatch(next, "exp" )) d->a.func0 = exp;
- else if (strmatch(next, "log" )) d->a.func0 = log;
- else if (strmatch(next, "abs" )) d->a.func0 = fabs;
- else if (strmatch(next, "time" )) d->a.func0 = etime;
- else if (strmatch(next, "squish")) d->type = e_squish;
- else if (strmatch(next, "gauss" )) d->type = e_gauss;
- else if (strmatch(next, "mod" )) d->type = e_mod;
- else if (strmatch(next, "max" )) d->type = e_max;
- else if (strmatch(next, "min" )) d->type = e_min;
- else if (strmatch(next, "eq" )) d->type = e_eq;
- else if (strmatch(next, "gte" )) d->type = e_gte;
- else if (strmatch(next, "gt" )) d->type = e_gt;
- else if (strmatch(next, "lte" )) { AVExpr *tmp = d->param[1]; d->param[1] = d->param[0]; d->param[0] = tmp; d->type = e_gte; }
- else if (strmatch(next, "lt" )) { AVExpr *tmp = d->param[1]; d->param[1] = d->param[0]; d->param[0] = tmp; d->type = e_gt; }
- else if (strmatch(next, "ld" )) d->type = e_ld;
- else if (strmatch(next, "isnan" )) d->type = e_isnan;
- else if (strmatch(next, "isinf" )) d->type = e_isinf;
- else if (strmatch(next, "st" )) d->type = e_st;
- else if (strmatch(next, "while" )) d->type = e_while;
- else if (strmatch(next, "taylor")) d->type = e_taylor;
- else if (strmatch(next, "root" )) d->type = e_root;
- else if (strmatch(next, "floor" )) d->type = e_floor;
- else if (strmatch(next, "ceil" )) d->type = e_ceil;
- else if (strmatch(next, "trunc" )) d->type = e_trunc;
- else if (strmatch(next, "sqrt" )) d->type = e_sqrt;
- else if (strmatch(next, "not" )) d->type = e_not;
- else if (strmatch(next, "pow" )) d->type = e_pow;
- else if (strmatch(next, "random")) d->type = e_random;
- else if (strmatch(next, "hypot" )) d->type = e_hypot;
- else if (strmatch(next, "gcd" )) d->type = e_gcd;
- else if (strmatch(next, "if" )) d->type = e_if;
- else if (strmatch(next, "ifnot" )) d->type = e_ifnot;
- else {
- for (i=0; p->func1_names && p->func1_names[i]; i++) {
- if (strmatch(next, p->func1_names[i])) {
- d->a.func1 = p->funcs1[i];
- d->type = e_func1;
- *e = d;
- return 0;
- }
- }
-
- for (i=0; p->func2_names && p->func2_names[i]; i++) {
- if (strmatch(next, p->func2_names[i])) {
- d->a.func2 = p->funcs2[i];
- d->type = e_func2;
- *e = d;
- return 0;
- }
- }
-
- av_log(p, AV_LOG_ERROR, "Unknown function in '%s'\n", s0);
- av_expr_free(d);
- return AVERROR(EINVAL);
- }
-
- *e = d;
- return 0;
-}
-
-static AVExpr *new_eval_expr(int type, int value, AVExpr *p0, AVExpr *p1)
-{
- AVExpr *e = av_mallocz(sizeof(AVExpr));
- if (!e)
- return NULL;
- e->type =type ;
- e->value =value ;
- e->param[0] =p0 ;
- e->param[1] =p1 ;
- return e;
-}
-
-static int parse_pow(AVExpr **e, Parser *p, int *sign)
-{
- *sign= (*p->s == '+') - (*p->s == '-');
- p->s += *sign&1;
- return parse_primary(e, p);
-}
-
-static int parse_dB(AVExpr **e, Parser *p, int *sign)
-{
- /* do not filter out the negative sign when parsing a dB value.
- for example, -3dB is not the same as -(3dB) */
- if (*p->s == '-') {
- char *next;
- double av_unused v = strtod(p->s, &next);
- if (next != p->s && next[0] == 'd' && next[1] == 'B') {
- *sign = 0;
- return parse_primary(e, p);
- }
- }
- return parse_pow(e, p, sign);
-}
-
-static int parse_factor(AVExpr **e, Parser *p)
-{
- int sign, sign2, ret;
- AVExpr *e0, *e1, *e2;
- if ((ret = parse_dB(&e0, p, &sign)) < 0)
- return ret;
- while(p->s[0]=='^'){
- e1 = e0;
- p->s++;
- if ((ret = parse_dB(&e2, p, &sign2)) < 0) {
- av_expr_free(e1);
- return ret;
- }
- e0 = new_eval_expr(e_pow, 1, e1, e2);
- if (!e0) {
- av_expr_free(e1);
- av_expr_free(e2);
- return AVERROR(ENOMEM);
- }
- if (e0->param[1]) e0->param[1]->value *= (sign2|1);
- }
- if (e0) e0->value *= (sign|1);
-
- *e = e0;
- return 0;
-}
-
-static int parse_term(AVExpr **e, Parser *p)
-{
- int ret;
- AVExpr *e0, *e1, *e2;
- if ((ret = parse_factor(&e0, p)) < 0)
- return ret;
- while (p->s[0]=='*' || p->s[0]=='/') {
- int c= *p->s++;
- e1 = e0;
- if ((ret = parse_factor(&e2, p)) < 0) {
- av_expr_free(e1);
- return ret;
- }
- e0 = new_eval_expr(c == '*' ? e_mul : e_div, 1, e1, e2);
- if (!e0) {
- av_expr_free(e1);
- av_expr_free(e2);
- return AVERROR(ENOMEM);
- }
- }
- *e = e0;
- return 0;
-}
-
-static int parse_subexpr(AVExpr **e, Parser *p)
-{
- int ret;
- AVExpr *e0, *e1, *e2;
- if ((ret = parse_term(&e0, p)) < 0)
- return ret;
- while (*p->s == '+' || *p->s == '-') {
- e1 = e0;
- if ((ret = parse_term(&e2, p)) < 0) {
- av_expr_free(e1);
- return ret;
- }
- e0 = new_eval_expr(e_add, 1, e1, e2);
- if (!e0) {
- av_expr_free(e1);
- av_expr_free(e2);
- return AVERROR(ENOMEM);
- }
- };
-
- *e = e0;
- return 0;
-}
-
-static int parse_expr(AVExpr **e, Parser *p)
-{
- int ret;
- AVExpr *e0, *e1, *e2;
- if (p->stack_index <= 0) //protect against stack overflows
- return AVERROR(EINVAL);
- p->stack_index--;
-
- if ((ret = parse_subexpr(&e0, p)) < 0)
- return ret;
- while (*p->s == ';') {
- p->s++;
- e1 = e0;
- if ((ret = parse_subexpr(&e2, p)) < 0) {
- av_expr_free(e1);
- return ret;
- }
- e0 = new_eval_expr(e_last, 1, e1, e2);
- if (!e0) {
- av_expr_free(e1);
- av_expr_free(e2);
- return AVERROR(ENOMEM);
- }
- };
-
- p->stack_index++;
- *e = e0;
- return 0;
-}
-
-static int verify_expr(AVExpr *e)
-{
- if (!e) return 0;
- switch (e->type) {
- case e_value:
- case e_const: return 1;
- case e_func0:
- case e_func1:
- case e_squish:
- case e_ld:
- case e_gauss:
- case e_isnan:
- case e_isinf:
- case e_floor:
- case e_ceil:
- case e_trunc:
- case e_sqrt:
- case e_not:
- case e_random:
- return verify_expr(e->param[0]) && !e->param[1];
- case e_if:
- case e_ifnot:
- case e_taylor:
- return verify_expr(e->param[0]) && verify_expr(e->param[1])
- && (!e->param[2] || verify_expr(e->param[2]));
- default: return verify_expr(e->param[0]) && verify_expr(e->param[1]) && !e->param[2];
- }
-}
-
-int av_expr_parse(AVExpr **expr, const char *s,
- const char * const *const_names,
- const char * const *func1_names, double (* const *funcs1)(void *, double),
- const char * const *func2_names, double (* const *funcs2)(void *, double, double),
- int log_offset, void *log_ctx)
-{
- Parser p = { 0 };
- AVExpr *e = NULL;
- char *w = av_malloc(strlen(s) + 1);
- char *wp = w;
- const char *s0 = s;
- int ret = 0;
-
- if (!w)
- return AVERROR(ENOMEM);
-
- while (*s)
- if (!isspace(*s++)) *wp++ = s[-1];
- *wp++ = 0;
-
- p.class = &class;
- p.stack_index=100;
- p.s= w;
- p.const_names = const_names;
- p.funcs1 = funcs1;
- p.func1_names = func1_names;
- p.funcs2 = funcs2;
- p.func2_names = func2_names;
- p.log_offset = log_offset;
- p.log_ctx = log_ctx;
-
- if ((ret = parse_expr(&e, &p)) < 0)
- goto end;
- if (*p.s) {
- av_expr_free(e);
- av_log(&p, AV_LOG_ERROR, "Invalid chars '%s' at the end of expression '%s'\n", p.s, s0);
- ret = AVERROR(EINVAL);
- goto end;
- }
- if (!verify_expr(e)) {
- av_expr_free(e);
- ret = AVERROR(EINVAL);
- goto end;
- }
- e->var= av_mallocz(sizeof(double) *VARS);
- *expr = e;
-end:
- av_free(w);
- return ret;
-}
-
-double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
-{
- Parser p = { 0 };
- p.var= e->var;
-
- p.const_values = const_values;
- p.opaque = opaque;
- return eval_expr(&p, e);
-}
-
-int av_expr_parse_and_eval(double *d, const char *s,
- const char * const *const_names, const double *const_values,
- const char * const *func1_names, double (* const *funcs1)(void *, double),
- const char * const *func2_names, double (* const *funcs2)(void *, double, double),
- void *opaque, int log_offset, void *log_ctx)
-{
- AVExpr *e = NULL;
- int ret = av_expr_parse(&e, s, const_names, func1_names, funcs1, func2_names, funcs2, log_offset, log_ctx);
-
- if (ret < 0) {
- *d = NAN;
- return ret;
- }
- *d = av_expr_eval(e, const_values, opaque);
- av_expr_free(e);
- return isnan(*d) ? AVERROR(EINVAL) : 0;
-}
-
-#ifdef TEST
-#include <string.h>
-
-static const double const_values[] = {
- M_PI,
- M_E,
- 0
-};
-
-static const char *const const_names[] = {
- "PI",
- "E",
- 0
-};
-
-int main(int argc, char **argv)
-{
- int i;
- double d;
- const char *const *expr;
- static const char *const exprs[] = {
- "",
- "1;2",
- "-20",
- "-PI",
- "+PI",
- "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)",
- "80G/80Gi",
- "1k",
- "1Gi",
- "1gi",
- "1GiFoo",
- "1k+1k",
- "1Gi*3foo",
- "foo",
- "foo(",
- "foo()",
- "foo)",
- "sin",
- "sin(",
- "sin()",
- "sin)",
- "sin 10",
- "sin(1,2,3)",
- "sin(1 )",
- "1",
- "1foo",
- "bar + PI + E + 100f*2 + foo",
- "13k + 12f - foo(1, 2)",
- "1gi",
- "1Gi",
- "st(0, 123)",
- "st(1, 123); ld(1)",
- "lte(0, 1)",
- "lte(1, 1)",
- "lte(1, 0)",
- "lt(0, 1)",
- "lt(1, 1)",
- "gt(1, 0)",
- "gt(2, 7)",
- "gte(122, 122)",
- /* compute 1+2+...+N */
- "st(0, 1); while(lte(ld(0), 100), st(1, ld(1)+ld(0));st(0, ld(0)+1)); ld(1)",
- /* compute Fib(N) */
- "st(1, 1); st(2, 2); st(0, 1); while(lte(ld(0),10), st(3, ld(1)+ld(2)); st(1, ld(2)); st(2, ld(3)); st(0, ld(0)+1)); ld(3)",
- "while(0, 10)",
- "st(0, 1); while(lte(ld(0),100), st(1, ld(1)+ld(0)); st(0, ld(0)+1))",
- "isnan(1)",
- "isnan(NAN)",
- "isnan(INF)",
- "isinf(1)",
- "isinf(NAN)",
- "isinf(INF)",
- "floor(NAN)",
- "floor(123.123)",
- "floor(-123.123)",
- "trunc(123.123)",
- "trunc(-123.123)",
- "ceil(123.123)",
- "ceil(-123.123)",
- "sqrt(1764)",
- "isnan(sqrt(-1))",
- "not(1)",
- "not(NAN)",
- "not(0)",
- "6.0206dB",
- "-3.0103dB",
- "pow(0,1.23)",
- "pow(PI,1.23)",
- "PI^1.23",
- "pow(-1,1.23)",
- "if(1, 2)",
- "if(1, 1, 2)",
- "if(0, 1, 2)",
- "ifnot(0, 23)",
- "ifnot(1, NaN) + if(0, 1)",
- "ifnot(1, 1, 2)",
- "ifnot(0, 1, 2)",
- "taylor(1, 1)",
- "taylor(eq(mod(ld(1),4),1)-eq(mod(ld(1),4),3), PI/2, 1)",
- "root(sin(ld(0))-1, 2)",
- "root(sin(ld(0))+6+sin(ld(0)/12)-log(ld(0)), 100)",
- "7000000B*random(0)",
- "squish(2)",
- "gauss(0.1)",
- "hypot(4,3)",
- "gcd(30,55)*min(9,1)",
- NULL
- };
-
- for (expr = exprs; *expr; expr++) {
- printf("Evaluating '%s'\n", *expr);
- av_expr_parse_and_eval(&d, *expr,
- const_names, const_values,
- NULL, NULL, NULL, NULL, NULL, 0, NULL);
- if (isnan(d))
- printf("'%s' -> nan\n\n", *expr);
- else
- printf("'%s' -> %f\n\n", *expr, d);
- }
-
- av_expr_parse_and_eval(&d, "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)",
- const_names, const_values,
- NULL, NULL, NULL, NULL, NULL, 0, NULL);
- printf("%f == 12.7\n", d);
- av_expr_parse_and_eval(&d, "80G/80Gi",
- const_names, const_values,
- NULL, NULL, NULL, NULL, NULL, 0, NULL);
- printf("%f == 0.931322575\n", d);
-
- if (argc > 1 && !strcmp(argv[1], "-t")) {
- for (i = 0; i < 1050; i++) {
- START_TIMER;
- av_expr_parse_and_eval(&d, "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)",
- const_names, const_values,
- NULL, NULL, NULL, NULL, NULL, 0, NULL);
- STOP_TIMER("av_expr_parse_and_eval");
- }
- }
-
- return 0;
-}
-#endif
diff --git a/src/thirdparty/ffmpeg/libavutil/eval.h b/src/thirdparty/ffmpeg/libavutil/eval.h
deleted file mode 100644
index da2770518..000000000
--- a/src/thirdparty/ffmpeg/libavutil/eval.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 2002 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
- * simple arithmetic expression evaluator
- */
-
-#ifndef AVUTIL_EVAL_H
-#define AVUTIL_EVAL_H
-
-#include "avutil.h"
-
-typedef struct AVExpr AVExpr;
-
-/**
- * Parse and evaluate an expression.
- * Note, this is significantly slower than av_expr_eval().
- *
- * @param res a pointer to a double where is put the result value of
- * the expression, or NAN in case of error
- * @param s expression as a zero terminated string, for example "1+2^3+5*5+sin(2/3)"
- * @param const_names NULL terminated array of zero terminated strings of constant identifiers, for example {"PI", "E", 0}
- * @param const_values a zero terminated array of values for the identifiers from const_names
- * @param func1_names NULL terminated array of zero terminated strings of funcs1 identifiers
- * @param funcs1 NULL terminated array of function pointers for functions which take 1 argument
- * @param func2_names NULL terminated array of zero terminated strings of funcs2 identifiers
- * @param funcs2 NULL terminated array of function pointers for functions which take 2 arguments
- * @param opaque a pointer which will be passed to all functions from funcs1 and funcs2
- * @param log_ctx parent logging context
- * @return 0 in case of success, a negative value corresponding to an
- * AVERROR code otherwise
- */
-int av_expr_parse_and_eval(double *res, const char *s,
- const char * const *const_names, const double *const_values,
- const char * const *func1_names, double (* const *funcs1)(void *, double),
- const char * const *func2_names, double (* const *funcs2)(void *, double, double),
- void *opaque, int log_offset, void *log_ctx);
-
-/**
- * Parse an expression.
- *
- * @param expr a pointer where is put an AVExpr containing the parsed
- * value in case of successful parsing, or NULL otherwise.
- * The pointed to AVExpr must be freed with av_expr_free() by the user
- * when it is not needed anymore.
- * @param s expression as a zero terminated string, for example "1+2^3+5*5+sin(2/3)"
- * @param const_names NULL terminated array of zero terminated strings of constant identifiers, for example {"PI", "E", 0}
- * @param func1_names NULL terminated array of zero terminated strings of funcs1 identifiers
- * @param funcs1 NULL terminated array of function pointers for functions which take 1 argument
- * @param func2_names NULL terminated array of zero terminated strings of funcs2 identifiers
- * @param funcs2 NULL terminated array of function pointers for functions which take 2 arguments
- * @param log_ctx parent logging context
- * @return 0 in case of success, a negative value corresponding to an
- * AVERROR code otherwise
- */
-int av_expr_parse(AVExpr **expr, const char *s,
- const char * const *const_names,
- const char * const *func1_names, double (* const *funcs1)(void *, double),
- const char * const *func2_names, double (* const *funcs2)(void *, double, double),
- int log_offset, void *log_ctx);
-
-/**
- * Evaluate a previously parsed expression.
- *
- * @param const_values a zero terminated array of values for the identifiers from av_expr_parse() const_names
- * @param opaque a pointer which will be passed to all functions from funcs1 and funcs2
- * @return the value of the expression
- */
-double av_expr_eval(AVExpr *e, const double *const_values, void *opaque);
-
-/**
- * Free a parsed expression previously created with av_expr_parse().
- */
-void av_expr_free(AVExpr *e);
-
-/**
- * Parse the string in numstr and return its value as a double. If
- * the string is empty, contains only whitespaces, or does not contain
- * an initial substring that has the expected syntax for a
- * floating-point number, no conversion is performed. In this case,
- * returns a value of zero and the value returned in tail is the value
- * of numstr.
- *
- * @param numstr a string representing a number, may contain one of
- * the International System number postfixes, for example 'K', 'M',
- * 'G'. If 'i' is appended after the postfix, powers of 2 are used
- * instead of powers of 10. The 'B' postfix multiplies the value for
- * 8, and can be appended after another postfix or used alone. This
- * allows using for example 'KB', 'MiB', 'G' and 'B' as postfix.
- * @param tail if non-NULL puts here the pointer to the char next
- * after the last parsed character
- */
-double av_strtod(const char *numstr, char **tail);
-
-#endif /* AVUTIL_EVAL_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/fifo.c b/src/thirdparty/ffmpeg/libavutil/fifo.c
deleted file mode 100644
index 8c727dbdc..000000000
--- a/src/thirdparty/ffmpeg/libavutil/fifo.c
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * a very simple circular buffer FIFO implementation
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
- * Copyright (c) 2006 Roman Shaposhnik
- *
- * 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 "common.h"
-#include "fifo.h"
-
-AVFifoBuffer *av_fifo_alloc(unsigned int size)
-{
- AVFifoBuffer *f= av_mallocz(sizeof(AVFifoBuffer));
- if (!f)
- return NULL;
- f->buffer = av_malloc(size);
- f->end = f->buffer + size;
- av_fifo_reset(f);
- if (!f->buffer)
- av_freep(&f);
- return f;
-}
-
-void av_fifo_free(AVFifoBuffer *f)
-{
- if (f) {
- av_freep(&f->buffer);
- av_free(f);
- }
-}
-
-void av_fifo_reset(AVFifoBuffer *f)
-{
- f->wptr = f->rptr = f->buffer;
- f->wndx = f->rndx = 0;
-}
-
-int av_fifo_size(AVFifoBuffer *f)
-{
- return (uint32_t)(f->wndx - f->rndx);
-}
-
-int av_fifo_space(AVFifoBuffer *f)
-{
- return f->end - f->buffer - av_fifo_size(f);
-}
-
-int av_fifo_realloc2(AVFifoBuffer *f, unsigned int new_size)
-{
- unsigned int old_size = f->end - f->buffer;
-
- if (old_size < new_size) {
- int len = av_fifo_size(f);
- AVFifoBuffer *f2 = av_fifo_alloc(new_size);
-
- if (!f2)
- return AVERROR(ENOMEM);
- av_fifo_generic_read(f, f2->buffer, len, NULL);
- f2->wptr += len;
- f2->wndx += len;
- av_free(f->buffer);
- *f = *f2;
- av_free(f2);
- }
- return 0;
-}
-
-int av_fifo_grow(AVFifoBuffer *f, unsigned int size)
-{
- unsigned int old_size = f->end - f->buffer;
- if(size + (unsigned)av_fifo_size(f) < size)
- return AVERROR(EINVAL);
-
- size += av_fifo_size(f);
-
- if (old_size < size)
- return av_fifo_realloc2(f, FFMAX(size, 2*size));
- return 0;
-}
-
-// src must NOT be const as it can be a context for func that may need updating (like a pointer or byte counter)
-int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int))
-{
- int total = size;
- uint32_t wndx= f->wndx;
- uint8_t *wptr= f->wptr;
-
- do {
- int len = FFMIN(f->end - wptr, size);
- if (func) {
- if (func(src, wptr, len) <= 0)
- break;
- } else {
- memcpy(wptr, src, len);
- src = (uint8_t*)src + len;
- }
-// Write memory barrier needed for SMP here in theory
- wptr += len;
- if (wptr >= f->end)
- wptr = f->buffer;
- wndx += len;
- size -= len;
- } while (size > 0);
- f->wndx= wndx;
- f->wptr= wptr;
- return total - size;
-}
-
-
-int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int))
-{
-// Read memory barrier needed for SMP here in theory
- do {
- int len = FFMIN(f->end - f->rptr, buf_size);
- if(func) func(dest, f->rptr, len);
- else{
- memcpy(dest, f->rptr, len);
- dest = (uint8_t*)dest + len;
- }
-// memory barrier needed for SMP here in theory
- av_fifo_drain(f, len);
- buf_size -= len;
- } while (buf_size > 0);
- return 0;
-}
-
-/** Discard data from the FIFO. */
-void av_fifo_drain(AVFifoBuffer *f, int size)
-{
- f->rptr += size;
- if (f->rptr >= f->end)
- f->rptr -= f->end - f->buffer;
- f->rndx += size;
-}
-
-#ifdef TEST
-
-int main(void)
-{
- /* create a FIFO buffer */
- AVFifoBuffer *fifo = av_fifo_alloc(13 * sizeof(int));
- int i, j, n;
-
- /* fill data */
- for (i = 0; av_fifo_space(fifo) >= sizeof(int); i++)
- av_fifo_generic_write(fifo, &i, sizeof(int), NULL);
-
- /* peek at FIFO */
- n = av_fifo_size(fifo)/sizeof(int);
- for (i = -n+1; i < n; i++) {
- int *v = (int *)av_fifo_peek2(fifo, i*sizeof(int));
- printf("%d: %d\n", i, *v);
- }
- printf("\n");
-
- /* read data */
- for (i = 0; av_fifo_size(fifo) >= sizeof(int); i++) {
- av_fifo_generic_read(fifo, &j, sizeof(int), NULL);
- printf("%d ", j);
- }
- printf("\n");
-
- av_fifo_free(fifo);
-
- return 0;
-}
-
-#endif
diff --git a/src/thirdparty/ffmpeg/libavutil/fifo.h b/src/thirdparty/ffmpeg/libavutil/fifo.h
deleted file mode 100644
index 697d9cd99..000000000
--- a/src/thirdparty/ffmpeg/libavutil/fifo.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * 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
- * a very simple circular buffer FIFO implementation
- */
-
-#ifndef AVUTIL_FIFO_H
-#define AVUTIL_FIFO_H
-
-#include <stdint.h>
-#include "avutil.h"
-#include "attributes.h"
-
-typedef struct AVFifoBuffer {
- uint8_t *buffer;
- uint8_t *rptr, *wptr, *end;
- uint32_t rndx, wndx;
-} AVFifoBuffer;
-
-/**
- * Initialize an AVFifoBuffer.
- * @param size of FIFO
- * @return AVFifoBuffer or NULL in case of memory allocation failure
- */
-AVFifoBuffer *av_fifo_alloc(unsigned int size);
-
-/**
- * Free an AVFifoBuffer.
- * @param f AVFifoBuffer to free
- */
-void av_fifo_free(AVFifoBuffer *f);
-
-/**
- * Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied.
- * @param f AVFifoBuffer to reset
- */
-void av_fifo_reset(AVFifoBuffer *f);
-
-/**
- * Return the amount of data in bytes in the AVFifoBuffer, that is the
- * amount of data you can read from it.
- * @param f AVFifoBuffer to read from
- * @return size
- */
-int av_fifo_size(AVFifoBuffer *f);
-
-/**
- * Return the amount of space in bytes in the AVFifoBuffer, that is the
- * amount of data you can write into it.
- * @param f AVFifoBuffer to write into
- * @return size
- */
-int av_fifo_space(AVFifoBuffer *f);
-
-/**
- * Feed data from an AVFifoBuffer to a user-supplied callback.
- * @param f AVFifoBuffer to read from
- * @param buf_size number of bytes to read
- * @param func generic read function
- * @param dest data destination
- */
-int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int));
-
-/**
- * Feed data from a user-supplied callback to an AVFifoBuffer.
- * @param f AVFifoBuffer to write to
- * @param src data source; non-const since it may be used as a
- * modifiable context by the function defined in func
- * @param size number of bytes to write
- * @param func generic write function; the first parameter is src,
- * the second is dest_buf, the third is dest_buf_size.
- * func must return the number of bytes written to dest_buf, or <= 0 to
- * indicate no more data available to write.
- * If func is NULL, src is interpreted as a simple byte array for source data.
- * @return the number of bytes written to the FIFO
- */
-int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int));
-
-/**
- * Resize an AVFifoBuffer.
- * In case of reallocation failure, the old FIFO is kept unchanged.
- *
- * @param f AVFifoBuffer to resize
- * @param size new AVFifoBuffer size in bytes
- * @return <0 for failure, >=0 otherwise
- */
-int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size);
-
-/**
- * Enlarge an AVFifoBuffer.
- * In case of reallocation failure, the old FIFO is kept unchanged.
- * The new fifo size may be larger than the requested size.
- *
- * @param f AVFifoBuffer to resize
- * @param additional_space the amount of space in bytes to allocate in addition to av_fifo_size()
- * @return <0 for failure, >=0 otherwise
- */
-int av_fifo_grow(AVFifoBuffer *f, unsigned int additional_space);
-
-/**
- * Read and discard the specified amount of data from an AVFifoBuffer.
- * @param f AVFifoBuffer to read from
- * @param size amount of data to read in bytes
- */
-void av_fifo_drain(AVFifoBuffer *f, int size);
-
-/**
- * Return a pointer to the data stored in a FIFO buffer at a certain offset.
- * The FIFO buffer is not modified.
- *
- * @param f AVFifoBuffer to peek at, f must be non-NULL
- * @param offs an offset in bytes, its absolute value must be less
- * than the used buffer size or the returned pointer will
- * point outside to the buffer data.
- * The used buffer size can be checked with av_fifo_size().
- */
-static inline uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs)
-{
- uint8_t *ptr = f->rptr + offs;
- if (ptr >= f->end)
- ptr = f->buffer + (ptr - f->end);
- else if (ptr < f->buffer)
- ptr = f->end - (f->buffer - ptr);
- return ptr;
-}
-
-#endif /* AVUTIL_FIFO_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/float_dsp.c b/src/thirdparty/ffmpeg/libavutil/float_dsp.c
deleted file mode 100644
index b3bd39058..000000000
--- a/src/thirdparty/ffmpeg/libavutil/float_dsp.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright 2005 Balatoni Denes
- * Copyright 2006 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 "config.h"
-
-#include "float_dsp.h"
-
-static void vector_fmul_c(float *dst, const float *src0, const float *src1,
- int len)
-{
- int i;
- for (i = 0; i < len; i++)
- dst[i] = src0[i] * src1[i];
-}
-
-static void vector_fmac_scalar_c(float *dst, const float *src, float mul,
- int len)
-{
- int i;
- for (i = 0; i < len; i++)
- dst[i] += src[i] * mul;
-}
-
-static void vector_fmul_scalar_c(float *dst, const float *src, float mul,
- int len)
-{
- int i;
- for (i = 0; i < len; i++)
- dst[i] = src[i] * mul;
-}
-
-static void vector_dmul_scalar_c(double *dst, const double *src, double mul,
- int len)
-{
- int i;
- for (i = 0; i < len; i++)
- dst[i] = src[i] * mul;
-}
-
-static void vector_fmul_window_c(float *dst, const float *src0,
- const float *src1, const float *win, int len)
-{
- int i, j;
-
- dst += len;
- win += len;
- src0 += len;
-
- for (i = -len, j = len - 1; i < 0; i++, j--) {
- float s0 = src0[i];
- float s1 = src1[j];
- float wi = win[i];
- float wj = win[j];
- dst[i] = s0 * wj - s1 * wi;
- dst[j] = s0 * wi + s1 * wj;
- }
-}
-
-static void vector_fmul_add_c(float *dst, const float *src0, const float *src1,
- const float *src2, int len){
- int i;
-
- for (i = 0; i < len; i++)
- dst[i] = src0[i] * src1[i] + src2[i];
-}
-
-static void vector_fmul_reverse_c(float *dst, const float *src0,
- const float *src1, int len)
-{
- int i;
-
- src1 += len-1;
- for (i = 0; i < len; i++)
- dst[i] = src0[i] * src1[-i];
-}
-
-static void butterflies_float_c(float *av_restrict v1, float *av_restrict v2,
- int len)
-{
- int i;
-
- for (i = 0; i < len; i++) {
- float t = v1[i] - v2[i];
- v1[i] += v2[i];
- v2[i] = t;
- }
-}
-
-float avpriv_scalarproduct_float_c(const float *v1, const float *v2, int len)
-{
- float p = 0.0;
- int i;
-
- for (i = 0; i < len; i++)
- p += v1[i] * v2[i];
-
- return p;
-}
-
-void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact)
-{
- fdsp->vector_fmul = vector_fmul_c;
- fdsp->vector_fmac_scalar = vector_fmac_scalar_c;
- fdsp->vector_fmul_scalar = vector_fmul_scalar_c;
- fdsp->vector_dmul_scalar = vector_dmul_scalar_c;
- fdsp->vector_fmul_window = vector_fmul_window_c;
- fdsp->vector_fmul_add = vector_fmul_add_c;
- fdsp->vector_fmul_reverse = vector_fmul_reverse_c;
- fdsp->butterflies_float = butterflies_float_c;
- fdsp->scalarproduct_float = avpriv_scalarproduct_float_c;
-
-#if ARCH_ARM
- ff_float_dsp_init_arm(fdsp);
-#elif ARCH_PPC
- ff_float_dsp_init_ppc(fdsp, bit_exact);
-#elif ARCH_X86
- ff_float_dsp_init_x86(fdsp);
-#elif ARCH_MIPS
- ff_float_dsp_init_mips(fdsp);
-#endif
-}
diff --git a/src/thirdparty/ffmpeg/libavutil/float_dsp.h b/src/thirdparty/ffmpeg/libavutil/float_dsp.h
deleted file mode 100644
index 82dd5169c..000000000
--- a/src/thirdparty/ffmpeg/libavutil/float_dsp.h
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * 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 AVUTIL_FLOAT_DSP_H
-#define AVUTIL_FLOAT_DSP_H
-
-#include "config.h"
-
-typedef struct AVFloatDSPContext {
- /**
- * Calculate the product of two vectors of floats and store the result in
- * a vector of floats.
- *
- * @param dst output vector
- * constraints: 32-byte aligned
- * @param src0 first input vector
- * constraints: 32-byte aligned
- * @param src1 second input vector
- * constraints: 32-byte aligned
- * @param len number of elements in the input
- * constraints: multiple of 16
- */
- void (*vector_fmul)(float *dst, const float *src0, const float *src1,
- int len);
-
- /**
- * Multiply a vector of floats by a scalar float and add to
- * destination vector. Source and destination vectors must
- * overlap exactly or not at all.
- *
- * @param dst result vector
- * constraints: 32-byte aligned
- * @param src input vector
- * constraints: 32-byte aligned
- * @param mul scalar value
- * @param len length of vector
- * constraints: multiple of 16
- */
- void (*vector_fmac_scalar)(float *dst, const float *src, float mul,
- int len);
-
- /**
- * Multiply a vector of floats by a scalar float. Source and
- * destination vectors must overlap exactly or not at all.
- *
- * @param dst result vector
- * constraints: 16-byte aligned
- * @param src input vector
- * constraints: 16-byte aligned
- * @param mul scalar value
- * @param len length of vector
- * constraints: multiple of 4
- */
- void (*vector_fmul_scalar)(float *dst, const float *src, float mul,
- int len);
-
- /**
- * Multiply a vector of double by a scalar double. Source and
- * destination vectors must overlap exactly or not at all.
- *
- * @param dst result vector
- * constraints: 32-byte aligned
- * @param src input vector
- * constraints: 32-byte aligned
- * @param mul scalar value
- * @param len length of vector
- * constraints: multiple of 8
- */
- void (*vector_dmul_scalar)(double *dst, const double *src, double mul,
- int len);
-
- /**
- * Overlap/add with window function.
- * Used primarily by MDCT-based audio codecs.
- * Source and destination vectors must overlap exactly or not at all.
- *
- * @param dst result vector
- * constraints: 16-byte aligned
- * @param src0 first source vector
- * constraints: 16-byte aligned
- * @param src1 second source vector
- * constraints: 16-byte aligned
- * @param win half-window vector
- * constraints: 16-byte aligned
- * @param len length of vector
- * constraints: multiple of 4
- */
- void (*vector_fmul_window)(float *dst, const float *src0,
- const float *src1, const float *win, int len);
-
- /**
- * Calculate the product of two vectors of floats, add a third vector of
- * floats and store the result in a vector of floats.
- *
- * @param dst output vector
- * constraints: 32-byte aligned
- * @param src0 first input vector
- * constraints: 32-byte aligned
- * @param src1 second input vector
- * constraints: 32-byte aligned
- * @param src1 third input vector
- * constraints: 32-byte aligned
- * @param len number of elements in the input
- * constraints: multiple of 16
- */
- void (*vector_fmul_add)(float *dst, const float *src0, const float *src1,
- const float *src2, int len);
-
- /**
- * Calculate the product of two vectors of floats, and store the result
- * in a vector of floats. The second vector of floats is iterated over
- * in reverse order.
- *
- * @param dst output vector
- * constraints: 32-byte aligned
- * @param src0 first input vector
- * constraints: 32-byte aligned
- * @param src1 second input vector
- * constraints: 32-byte aligned
- * @param src1 third input vector
- * constraints: 32-byte aligned
- * @param len number of elements in the input
- * constraints: multiple of 16
- */
- void (*vector_fmul_reverse)(float *dst, const float *src0,
- const float *src1, int len);
-
- /**
- * Calculate the sum and difference of two vectors of floats.
- *
- * @param v1 first input vector, sum output, 16-byte aligned
- * @param v2 second input vector, difference output, 16-byte aligned
- * @param len length of vectors, multiple of 4
- */
- void (*butterflies_float)(float *av_restrict v1, float *av_restrict v2, int len);
-
- /**
- * Calculate the scalar product of two vectors of floats.
- *
- * @param v1 first vector, 16-byte aligned
- * @param v2 second vector, 16-byte aligned
- * @param len length of vectors, multiple of 4
- *
- * @return sum of elementwise products
- */
- float (*scalarproduct_float)(const float *v1, const float *v2, int len);
-} AVFloatDSPContext;
-
-/**
- * Return the scalar product of two vectors.
- *
- * @param v1 first input vector
- * @param v2 first input vector
- * @param len number of elements
- *
- * @return sum of elementwise products
- */
-float avpriv_scalarproduct_float_c(const float *v1, const float *v2, int len);
-
-/**
- * Initialize a float DSP context.
- *
- * @param fdsp float DSP context
- * @param strict setting to non-zero avoids using functions which may not be IEEE-754 compliant
- */
-void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int strict);
-
-
-void ff_float_dsp_init_arm(AVFloatDSPContext *fdsp);
-void ff_float_dsp_init_ppc(AVFloatDSPContext *fdsp, int strict);
-void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp);
-void ff_float_dsp_init_mips(AVFloatDSPContext *fdsp);
-
-#endif /* AVUTIL_FLOAT_DSP_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/imgutils.c b/src/thirdparty/ffmpeg/libavutil/imgutils.c
deleted file mode 100644
index f0cf97ee4..000000000
--- a/src/thirdparty/ffmpeg/libavutil/imgutils.c
+++ /dev/null
@@ -1,368 +0,0 @@
-/*
- * 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
- * misc image utilities
- */
-
-#include "avassert.h"
-#include "common.h"
-#include "imgutils.h"
-#include "internal.h"
-#include "intreadwrite.h"
-#include "log.h"
-#include "pixdesc.h"
-
-void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
- const AVPixFmtDescriptor *pixdesc)
-{
- int i;
- memset(max_pixsteps, 0, 4*sizeof(max_pixsteps[0]));
- if (max_pixstep_comps)
- memset(max_pixstep_comps, 0, 4*sizeof(max_pixstep_comps[0]));
-
- for (i = 0; i < 4; i++) {
- const AVComponentDescriptor *comp = &(pixdesc->comp[i]);
- if ((comp->step_minus1+1) > max_pixsteps[comp->plane]) {
- max_pixsteps[comp->plane] = comp->step_minus1+1;
- if (max_pixstep_comps)
- max_pixstep_comps[comp->plane] = i;
- }
- }
-}
-
-static inline
-int image_get_linesize(int width, int plane,
- int max_step, int max_step_comp,
- const AVPixFmtDescriptor *desc)
-{
- int s, shifted_w, linesize;
-
- if (!desc)
- return AVERROR(EINVAL);
-
- if (width < 0)
- return AVERROR(EINVAL);
- s = (max_step_comp == 1 || max_step_comp == 2) ? desc->log2_chroma_w : 0;
- shifted_w = ((width + (1 << s) - 1)) >> s;
- if (shifted_w && max_step > INT_MAX / shifted_w)
- return AVERROR(EINVAL);
- linesize = max_step * shifted_w;
-
- if (desc->flags & PIX_FMT_BITSTREAM)
- linesize = (linesize + 7) >> 3;
- return linesize;
-}
-
-int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- int max_step [4]; /* max pixel step for each plane */
- int max_step_comp[4]; /* the component for each plane which has the max pixel step */
-
- if ((unsigned)pix_fmt >= AV_PIX_FMT_NB || desc->flags & PIX_FMT_HWACCEL)
- return AVERROR(EINVAL);
-
- av_image_fill_max_pixsteps(max_step, max_step_comp, desc);
- return image_get_linesize(width, plane, max_step[plane], max_step_comp[plane], desc);
-}
-
-int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
-{
- int i, ret;
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- int max_step [4]; /* max pixel step for each plane */
- int max_step_comp[4]; /* the component for each plane which has the max pixel step */
-
- memset(linesizes, 0, 4*sizeof(linesizes[0]));
-
- if (!desc || desc->flags & PIX_FMT_HWACCEL)
- return AVERROR(EINVAL);
-
- av_image_fill_max_pixsteps(max_step, max_step_comp, desc);
- for (i = 0; i < 4; i++) {
- if ((ret = image_get_linesize(width, i, max_step[i], max_step_comp[i], desc)) < 0)
- return ret;
- linesizes[i] = ret;
- }
-
- return 0;
-}
-
-int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, int height,
- uint8_t *ptr, const int linesizes[4])
-{
- int i, total_size, size[4] = { 0 }, has_plane[4] = { 0 };
-
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- memset(data , 0, sizeof(data[0])*4);
-
- if (!desc || desc->flags & PIX_FMT_HWACCEL)
- return AVERROR(EINVAL);
-
- data[0] = ptr;
- if (linesizes[0] > (INT_MAX - 1024) / height)
- return AVERROR(EINVAL);
- size[0] = linesizes[0] * height;
-
- if (desc->flags & PIX_FMT_PAL ||
- desc->flags & PIX_FMT_PSEUDOPAL) {
- size[0] = (size[0] + 3) & ~3;
- data[1] = ptr + size[0]; /* palette is stored here as 256 32 bits words */
- return size[0] + 256 * 4;
- }
-
- for (i = 0; i < 4; i++)
- has_plane[desc->comp[i].plane] = 1;
-
- total_size = size[0];
- for (i = 1; i < 4 && has_plane[i]; i++) {
- int h, s = (i == 1 || i == 2) ? desc->log2_chroma_h : 0;
- data[i] = data[i-1] + size[i-1];
- h = (height + (1 << s) - 1) >> s;
- if (linesizes[i] > INT_MAX / h)
- return AVERROR(EINVAL);
- size[i] = h * linesizes[i];
- if (total_size > INT_MAX - size[i])
- return AVERROR(EINVAL);
- total_size += size[i];
- }
-
- return total_size;
-}
-
-int avpriv_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt)
-{
- int i;
-
- for (i = 0; i < 256; i++) {
- int r, g, b;
-
- switch (pix_fmt) {
- case AV_PIX_FMT_RGB8:
- r = (i>>5 )*36;
- g = ((i>>2)&7)*36;
- b = (i&3 )*85;
- break;
- case AV_PIX_FMT_BGR8:
- b = (i>>6 )*85;
- g = ((i>>3)&7)*36;
- r = (i&7 )*36;
- break;
- case AV_PIX_FMT_RGB4_BYTE:
- r = (i>>3 )*255;
- g = ((i>>1)&3)*85;
- b = (i&1 )*255;
- break;
- case AV_PIX_FMT_BGR4_BYTE:
- b = (i>>3 )*255;
- g = ((i>>1)&3)*85;
- r = (i&1 )*255;
- break;
- case AV_PIX_FMT_GRAY8:
- r = b = g = i;
- break;
- default:
- return AVERROR(EINVAL);
- }
- pal[i] = b + (g<<8) + (r<<16) + (0xFFU<<24);
- }
-
- return 0;
-}
-
-int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
- int w, int h, enum AVPixelFormat pix_fmt, int align)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- int i, ret;
- uint8_t *buf;
-
- if (!desc)
- return AVERROR(EINVAL);
-
- if ((ret = av_image_check_size(w, h, 0, NULL)) < 0)
- return ret;
- if ((ret = av_image_fill_linesizes(linesizes, pix_fmt, align>7 ? FFALIGN(w, 8) : w)) < 0)
- return ret;
-
- for (i = 0; i < 4; i++)
- linesizes[i] = FFALIGN(linesizes[i], align);
-
- if ((ret = av_image_fill_pointers(pointers, pix_fmt, h, NULL, linesizes)) < 0)
- return ret;
- buf = av_malloc(ret + align);
- if (!buf)
- return AVERROR(ENOMEM);
- if ((ret = av_image_fill_pointers(pointers, pix_fmt, h, buf, linesizes)) < 0) {
- av_free(buf);
- return ret;
- }
- if (desc->flags & PIX_FMT_PAL || desc->flags & PIX_FMT_PSEUDOPAL)
- avpriv_set_systematic_pal2((uint32_t*)pointers[1], pix_fmt);
-
- return ret;
-}
-
-typedef struct ImgUtils {
- const AVClass *class;
- int log_offset;
- void *log_ctx;
-} ImgUtils;
-
-static const AVClass imgutils_class = { "IMGUTILS", av_default_item_name, NULL, LIBAVUTIL_VERSION_INT, offsetof(ImgUtils, log_offset), offsetof(ImgUtils, log_ctx) };
-
-int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
-{
- ImgUtils imgutils = { &imgutils_class, log_offset, log_ctx };
-
- if ((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8)
- return 0;
-
- av_log(&imgutils, AV_LOG_ERROR, "Picture size %ux%u is invalid\n", w, h);
- return AVERROR(EINVAL);
-}
-
-void av_image_copy_plane(uint8_t *dst, int dst_linesize,
- const uint8_t *src, int src_linesize,
- int bytewidth, int height)
-{
- if (!dst || !src)
- return;
- av_assert0(abs(src_linesize) >= bytewidth);
- av_assert0(abs(dst_linesize) >= bytewidth);
- for (;height > 0; height--) {
- memcpy(dst, src, bytewidth);
- dst += dst_linesize;
- src += src_linesize;
- }
-}
-
-void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
- const uint8_t *src_data[4], const int src_linesizes[4],
- enum AVPixelFormat pix_fmt, int width, int height)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
-
- if (!desc || desc->flags & PIX_FMT_HWACCEL)
- return;
-
- if (desc->flags & PIX_FMT_PAL ||
- desc->flags & PIX_FMT_PSEUDOPAL) {
- av_image_copy_plane(dst_data[0], dst_linesizes[0],
- src_data[0], src_linesizes[0],
- width, height);
- /* copy the palette */
- memcpy(dst_data[1], src_data[1], 4*256);
- } else {
- int i, planes_nb = 0;
-
- for (i = 0; i < desc->nb_components; i++)
- planes_nb = FFMAX(planes_nb, desc->comp[i].plane + 1);
-
- for (i = 0; i < planes_nb; i++) {
- int h = height;
- int bwidth = av_image_get_linesize(pix_fmt, width, i);
- if (bwidth < 0) {
- av_log(NULL, AV_LOG_ERROR, "av_image_get_linesize failed\n");
- return;
- }
- if (i == 1 || i == 2) {
- h= -((-height)>>desc->log2_chroma_h);
- }
- av_image_copy_plane(dst_data[i], dst_linesizes[i],
- src_data[i], src_linesizes[i],
- bwidth, h);
- }
- }
-}
-
-int av_image_fill_arrays(uint8_t *dst_data[4], int dst_linesize[4],
- const uint8_t *src,
- enum AVPixelFormat pix_fmt, int width, int height, int align)
-{
- int ret, i;
-
- if ((ret = av_image_check_size(width, height, 0, NULL)) < 0)
- return ret;
-
- if ((ret = av_image_fill_linesizes(dst_linesize, pix_fmt, width)) < 0)
- return ret;
-
- for (i = 0; i < 4; i++)
- dst_linesize[i] = FFALIGN(dst_linesize[i], align);
-
- if ((ret = av_image_fill_pointers(dst_data, pix_fmt, width, NULL, dst_linesize)) < 0)
- return ret;
-
- return av_image_fill_pointers(dst_data, pix_fmt, height, (uint8_t *)src, dst_linesize);
-}
-
-int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height, int align)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- uint8_t *data[4];
- int linesize[4];
-
- if (!desc)
- return AVERROR(EINVAL);
- if (av_image_check_size(width, height, 0, NULL) < 0)
- return AVERROR(EINVAL);
- if (desc->flags & PIX_FMT_PSEUDOPAL)
- // do not include palette for these pseudo-paletted formats
- return width * height;
- return av_image_fill_arrays(data, linesize, NULL, pix_fmt, width, height, align);
-}
-
-int av_image_copy_to_buffer(uint8_t *dst, int dst_size,
- const uint8_t * const src_data[4], const int src_linesize[4],
- enum AVPixelFormat pix_fmt, int width, int height, int align)
-{
- int i, j, nb_planes = 0, linesize[4];
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- int size = av_image_get_buffer_size(pix_fmt, width, height, align);
-
- if (size > dst_size || size < 0)
- return AVERROR(EINVAL);
-
- for (i = 0; i < desc->nb_components; i++)
- nb_planes = FFMAX(desc->comp[i].plane, nb_planes);
- nb_planes++;
-
- av_image_fill_linesizes(linesize, pix_fmt, width);
- for (i = 0; i < nb_planes; i++) {
- int h, shift = (i == 1 || i == 2) ? desc->log2_chroma_h : 0;
- const uint8_t *src = src_data[i];
- h = (height + (1 << shift) - 1) >> shift;
-
- for (j = 0; j < h; j++) {
- memcpy(dst, src, linesize[i]);
- dst += FFALIGN(linesize[i], align);
- src += src_linesize[i];
- }
- }
-
- if (desc->flags & PIX_FMT_PAL) {
- uint32_t *d32 = (uint32_t *)(((size_t)dst + 3) & ~3);
- for (i = 0; i<256; i++)
- AV_WL32(d32 + i, AV_RN32(src_data[1] + 4*i));
- }
-
- return size;
-}
diff --git a/src/thirdparty/ffmpeg/libavutil/imgutils.h b/src/thirdparty/ffmpeg/libavutil/imgutils.h
deleted file mode 100644
index fea8af995..000000000
--- a/src/thirdparty/ffmpeg/libavutil/imgutils.h
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * 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 AVUTIL_IMGUTILS_H
-#define AVUTIL_IMGUTILS_H
-
-/**
- * @file
- * misc image utilities
- *
- * @addtogroup lavu_picture
- * @{
- */
-
-#include "avutil.h"
-#include "pixdesc.h"
-
-/**
- * Compute the max pixel step for each plane of an image with a
- * format described by pixdesc.
- *
- * The pixel step is the distance in bytes between the first byte of
- * the group of bytes which describe a pixel component and the first
- * byte of the successive group in the same plane for the same
- * component.
- *
- * @param max_pixsteps an array which is filled with the max pixel step
- * for each plane. Since a plane may contain different pixel
- * components, the computed max_pixsteps[plane] is relative to the
- * component in the plane with the max pixel step.
- * @param max_pixstep_comps an array which is filled with the component
- * for each plane which has the max pixel step. May be NULL.
- */
-void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
- const AVPixFmtDescriptor *pixdesc);
-
-/**
- * Compute the size of an image line with format pix_fmt and width
- * width for the plane plane.
- *
- * @return the computed size in bytes
- */
-int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane);
-
-/**
- * Fill plane linesizes for an image with pixel format pix_fmt and
- * width width.
- *
- * @param linesizes array to be filled with the linesize for each plane
- * @return >= 0 in case of success, a negative error code otherwise
- */
-int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width);
-
-/**
- * Fill plane data pointers for an image with pixel format pix_fmt and
- * height height.
- *
- * @param data pointers array to be filled with the pointer for each image plane
- * @param ptr the pointer to a buffer which will contain the image
- * @param linesizes the array containing the linesize for each
- * plane, should be filled by av_image_fill_linesizes()
- * @return the size in bytes required for the image buffer, a negative
- * error code in case of failure
- */
-int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, int height,
- uint8_t *ptr, const int linesizes[4]);
-
-/**
- * Allocate an image with size w and h and pixel format pix_fmt, and
- * fill pointers and linesizes accordingly.
- * The allocated image buffer has to be freed by using
- * av_freep(&pointers[0]).
- *
- * @param align the value to use for buffer size alignment
- * @return the size in bytes required for the image buffer, a negative
- * error code in case of failure
- */
-int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
- int w, int h, enum AVPixelFormat pix_fmt, int align);
-
-/**
- * Copy image plane from src to dst.
- * That is, copy "height" number of lines of "bytewidth" bytes each.
- * The first byte of each successive line is separated by *_linesize
- * bytes.
- *
- * bytewidth must be contained by both absolute values of dst_linesize
- * and src_linesize, otherwise the function behavior is undefined.
- *
- * @param dst_linesize linesize for the image plane in dst
- * @param src_linesize linesize for the image plane in src
- */
-void av_image_copy_plane(uint8_t *dst, int dst_linesize,
- const uint8_t *src, int src_linesize,
- int bytewidth, int height);
-
-/**
- * Copy image in src_data to dst_data.
- *
- * @param dst_linesizes linesizes for the image in dst_data
- * @param src_linesizes linesizes for the image in src_data
- */
-void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
- const uint8_t *src_data[4], const int src_linesizes[4],
- enum AVPixelFormat pix_fmt, int width, int height);
-
-/**
- * Setup the data pointers and linesizes based on the specified image
- * parameters and the provided array.
- *
- * The fields of the given image are filled in by using the src
- * address which points to the image data buffer. Depending on the
- * specified pixel format, one or multiple image data pointers and
- * line sizes will be set. If a planar format is specified, several
- * pointers will be set pointing to the different picture planes and
- * the line sizes of the different planes will be stored in the
- * lines_sizes array. Call with src == NULL to get the required
- * size for the src buffer.
- *
- * To allocate the buffer and fill in the dst_data and dst_linesize in
- * one call, use av_image_alloc().
- *
- * @param dst_data data pointers to be filled in
- * @param dst_linesizes linesizes for the image in dst_data to be filled in
- * @param src buffer which will contain or contains the actual image data, can be NULL
- * @param pix_fmt the pixel format of the image
- * @param width the width of the image in pixels
- * @param height the height of the image in pixels
- * @param align the value used in src for linesize alignment
- * @return the size in bytes required for src, a negative error code
- * in case of failure
- */
-int av_image_fill_arrays(uint8_t *dst_data[4], int dst_linesize[4],
- const uint8_t *src,
- enum AVPixelFormat pix_fmt, int width, int height, int align);
-
-/**
- * Return the size in bytes of the amount of data required to store an
- * image with the given parameters.
- *
- * @param[in] align the assumed linesize alignment
- */
-int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height, int align);
-
-/**
- * Copy image data from an image into a buffer.
- *
- * av_image_get_buffer_size() can be used to compute the required size
- * for the buffer to fill.
- *
- * @param dst a buffer into which picture data will be copied
- * @param dst_size the size in bytes of dst
- * @param src_data pointers containing the source image data
- * @param src_linesizes linesizes for the image in src_data
- * @param pix_fmt the pixel format of the source image
- * @param width the width of the source image in pixels
- * @param height the height of the source image in pixels
- * @param align the assumed linesize alignment for dst
- * @return the number of bytes written to dst, or a negative value
- * (error code) on error
- */
-int av_image_copy_to_buffer(uint8_t *dst, int dst_size,
- const uint8_t * const src_data[4], const int src_linesize[4],
- enum AVPixelFormat pix_fmt, int width, int height, int align);
-
-/**
- * Check if the given dimension of an image is valid, meaning that all
- * bytes of the image can be addressed with a signed int.
- *
- * @param w the width of the picture
- * @param h the height of the picture
- * @param log_offset the offset to sum to the log level for logging with log_ctx
- * @param log_ctx the parent logging context, it may be NULL
- * @return >= 0 if valid, a negative error code otherwise
- */
-int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx);
-
-int avpriv_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt);
-
-/**
- * @}
- */
-
-
-#endif /* AVUTIL_IMGUTILS_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/internal.h b/src/thirdparty/ffmpeg/libavutil/internal.h
deleted file mode 100644
index 276b05a48..000000000
--- a/src/thirdparty/ffmpeg/libavutil/internal.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * copyright (c) 2006 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
- * common internal API header
- */
-
-#ifndef AVUTIL_INTERNAL_H
-#define AVUTIL_INTERNAL_H
-
-#if !defined(DEBUG) && !defined(NDEBUG)
-# define NDEBUG
-#endif
-
-#include <limits.h>
-#include <stdint.h>
-#include <stddef.h>
-#include <assert.h>
-#include "config.h"
-#include "attributes.h"
-#include "timer.h"
-#include "cpu.h"
-#include "dict.h"
-
-#if ARCH_X86
-# include "x86/emms.h"
-#endif
-
-#ifndef emms_c
-# define emms_c()
-#endif
-
-#ifndef attribute_align_arg
-#if ARCH_X86_32 && AV_GCC_VERSION_AT_LEAST(4,2)
-# define attribute_align_arg __attribute__((force_align_arg_pointer))
-#else
-# define attribute_align_arg
-#endif
-#endif
-
-#if defined(_MSC_VER) && CONFIG_SHARED
-# define av_export __declspec(dllimport)
-#else
-# define av_export
-#endif
-
-#ifndef INT_BIT
-# define INT_BIT (CHAR_BIT * sizeof(int))
-#endif
-
-// Some broken preprocessors need a second expansion
-// to be forced to tokenize __VA_ARGS__
-#define E1(x) x
-
-#define LOCAL_ALIGNED_A(a, t, v, s, o, ...) \
- uint8_t la_##v[sizeof(t s o) + (a)]; \
- t (*v) o = (void *)FFALIGN((uintptr_t)la_##v, a)
-
-#define LOCAL_ALIGNED_D(a, t, v, s, o, ...) \
- DECLARE_ALIGNED(a, t, la_##v) s o; \
- t (*v) o = la_##v
-
-#define LOCAL_ALIGNED(a, t, v, ...) E1(LOCAL_ALIGNED_A(a, t, v, __VA_ARGS__,,))
-
-#if HAVE_LOCAL_ALIGNED_8
-# define LOCAL_ALIGNED_8(t, v, ...) E1(LOCAL_ALIGNED_D(8, t, v, __VA_ARGS__,,))
-#else
-# define LOCAL_ALIGNED_8(t, v, ...) LOCAL_ALIGNED(8, t, v, __VA_ARGS__)
-#endif
-
-#if HAVE_LOCAL_ALIGNED_16
-# define LOCAL_ALIGNED_16(t, v, ...) E1(LOCAL_ALIGNED_D(16, t, v, __VA_ARGS__,,))
-#else
-# define LOCAL_ALIGNED_16(t, v, ...) LOCAL_ALIGNED(16, t, v, __VA_ARGS__)
-#endif
-
-#define FF_ALLOC_OR_GOTO(ctx, p, size, label)\
-{\
- p = av_malloc(size);\
- if (p == NULL && (size) != 0) {\
- av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
- goto label;\
- }\
-}
-
-#define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)\
-{\
- p = av_mallocz(size);\
- if (p == NULL && (size) != 0) {\
- av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\
- goto label;\
- }\
-}
-
-#include "libm.h"
-
-/**
- * Return NULL if CONFIG_SMALL is true, otherwise the argument
- * without modification. Used to disable the definition of strings
- * (for example AVCodec long_names).
- */
-#if CONFIG_SMALL
-# define NULL_IF_CONFIG_SMALL(x) NULL
-#else
-# define NULL_IF_CONFIG_SMALL(x) x
-#endif
-
-/**
- * Define a function with only the non-default version specified.
- *
- * On systems with ELF shared libraries, all symbols exported from
- * FFmpeg libraries are tagged with the name and major version of the
- * library to which they belong. If a function is moved from one
- * library to another, a wrapper must be retained in the original
- * location to preserve binary compatibility.
- *
- * Functions defined with this macro will never be used to resolve
- * symbols by the build-time linker.
- *
- * @param type return type of function
- * @param name name of function
- * @param args argument list of function
- * @param ver version tag to assign function
- */
-#if HAVE_SYMVER_ASM_LABEL
-# define FF_SYMVER(type, name, args, ver) \
- type ff_##name args __asm__ (EXTERN_PREFIX #name "@" ver); \
- type ff_##name args
-#elif HAVE_SYMVER_GNU_ASM
-# define FF_SYMVER(type, name, args, ver) \
- __asm__ (".symver ff_" #name "," EXTERN_PREFIX #name "@" ver); \
- type ff_##name args; \
- type ff_##name args
-#endif
-
-/**
- * Return NULL if a threading library has not been enabled.
- * Used to disable threading functions in AVCodec definitions
- * when not needed.
- */
-#if HAVE_THREADS
-# define ONLY_IF_THREADS_ENABLED(x) x
-#else
-# define ONLY_IF_THREADS_ENABLED(x) NULL
-#endif
-
-#endif /* AVUTIL_INTERNAL_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/intfloat.h b/src/thirdparty/ffmpeg/libavutil/intfloat.h
deleted file mode 100644
index 395903925..000000000
--- a/src/thirdparty/ffmpeg/libavutil/intfloat.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2011 Mans Rullgard
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVUTIL_INTFLOAT_H
-#define AVUTIL_INTFLOAT_H
-
-#include <stdint.h>
-#include "attributes.h"
-
-union av_intfloat32 {
- uint32_t i;
- float f;
-};
-
-union av_intfloat64 {
- uint64_t i;
- double f;
-};
-
-/**
- * Reinterpret a 32-bit integer as a float.
- */
-static av_always_inline float av_int2float(uint32_t i)
-{
- union av_intfloat32 v;
- v.i = i;
- return v.f;
-}
-
-/**
- * Reinterpret a float as a 32-bit integer.
- */
-static av_always_inline uint32_t av_float2int(float f)
-{
- union av_intfloat32 v;
- v.f = f;
- return v.i;
-}
-
-/**
- * Reinterpret a 64-bit integer as a double.
- */
-static av_always_inline double av_int2double(uint64_t i)
-{
- union av_intfloat64 v;
- v.i = i;
- return v.f;
-}
-
-/**
- * Reinterpret a double as a 64-bit integer.
- */
-static av_always_inline uint64_t av_double2int(double f)
-{
- union av_intfloat64 v;
- v.f = f;
- return v.i;
-}
-
-#endif /* AVUTIL_INTFLOAT_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/intfloat_readwrite.c b/src/thirdparty/ffmpeg/libavutil/intfloat_readwrite.c
deleted file mode 100644
index ef9e53571..000000000
--- a/src/thirdparty/ffmpeg/libavutil/intfloat_readwrite.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * portable IEEE float/double read/write functions
- *
- * Copyright (c) 2005 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
- * portable IEEE float/double read/write functions
- */
-
-#include <stdint.h>
-#include "mathematics.h"
-#include "intfloat_readwrite.h"
-
-double av_int2dbl(int64_t v){
- if((uint64_t)v+v > 0xFFEULL<<52)
- return NAN;
- return ldexp(((v&((1LL<<52)-1)) + (1LL<<52)) * (v>>63|1), (v>>52&0x7FF)-1075);
-}
-
-float av_int2flt(int32_t v){
- if((uint32_t)v+v > 0xFF000000U)
- return NAN;
- return ldexp(((v&0x7FFFFF) + (1<<23)) * (v>>31|1), (v>>23&0xFF)-150);
-}
-
-double av_ext2dbl(const AVExtFloat ext){
- uint64_t m = 0;
- int e, i;
-
- for (i = 0; i < 8; i++)
- m = (m<<8) + ext.mantissa[i];
- e = (((int)ext.exponent[0]&0x7f)<<8) | ext.exponent[1];
- if (e == 0x7fff && m)
- return NAN;
- e -= 16383 + 63; /* In IEEE 80 bits, the whole (i.e. 1.xxxx)
- * mantissa bit is written as opposed to the
- * single and double precision formats. */
- if (ext.exponent[0]&0x80)
- m= -m;
- return ldexp(m, e);
-}
-
-int64_t av_dbl2int(double d){
- int e;
- if ( !d) return 0;
- else if(d-d) return 0x7FF0000000000000LL + ((int64_t)(d<0)<<63) + (d!=d);
- d= frexp(d, &e);
- return (int64_t)(d<0)<<63 | (e+1022LL)<<52 | (int64_t)((fabs(d)-0.5)*(1LL<<53));
-}
-
-int32_t av_flt2int(float d){
- int e;
- if ( !d) return 0;
- else if(d-d) return 0x7F800000 + ((d<0)<<31) + (d!=d);
- d= frexp(d, &e);
- return (d<0)<<31 | (e+126)<<23 | (int64_t)((fabs(d)-0.5)*(1<<24));
-}
-
-AVExtFloat av_dbl2ext(double d){
- struct AVExtFloat ext= {{0}};
- int e, i; double f; uint64_t m;
-
- f = fabs(frexp(d, &e));
- if (f >= 0.5 && f < 1) {
- e += 16382;
- ext.exponent[0] = e>>8;
- ext.exponent[1] = e;
- m = (uint64_t)ldexp(f, 64);
- for (i=0; i < 8; i++)
- ext.mantissa[i] = m>>(56-(i<<3));
- } else if (f != 0.0) {
- ext.exponent[0] = 0x7f; ext.exponent[1] = 0xff;
- if (f != INFINITY)
- ext.mantissa[0] = ~0;
- }
- if (d < 0)
- ext.exponent[0] |= 0x80;
- return ext;
-}
diff --git a/src/thirdparty/ffmpeg/libavutil/intfloat_readwrite.h b/src/thirdparty/ffmpeg/libavutil/intfloat_readwrite.h
deleted file mode 100644
index 54e8f9b23..000000000
--- a/src/thirdparty/ffmpeg/libavutil/intfloat_readwrite.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * copyright (c) 2005 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
- */
-
-#ifndef AVUTIL_INTFLOAT_READWRITE_H
-#define AVUTIL_INTFLOAT_READWRITE_H
-
-#include <stdint.h>
-#include "attributes.h"
-
-/* IEEE 80 bits extended float */
-typedef struct AVExtFloat {
- uint8_t exponent[2];
- uint8_t mantissa[8];
-} AVExtFloat;
-
-attribute_deprecated double av_int2dbl(int64_t v) av_const;
-attribute_deprecated float av_int2flt(int32_t v) av_const;
-attribute_deprecated double av_ext2dbl(const AVExtFloat ext) av_const;
-attribute_deprecated int64_t av_dbl2int(double d) av_const;
-attribute_deprecated int32_t av_flt2int(float d) av_const;
-attribute_deprecated AVExtFloat av_dbl2ext(double d) av_const;
-
-#endif /* AVUTIL_INTFLOAT_READWRITE_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/intmath.h b/src/thirdparty/ffmpeg/libavutil/intmath.h
deleted file mode 100644
index cb62c6632..000000000
--- a/src/thirdparty/ffmpeg/libavutil/intmath.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * 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
- */
-
-#ifndef AVUTIL_INTMATH_H
-#define AVUTIL_INTMATH_H
-
-#include <stdint.h>
-
-#include "config.h"
-#include "attributes.h"
-
-#if ARCH_ARM
-# include "arm/intmath.h"
-#endif
-
-/**
- * @addtogroup lavu_internal
- * @{
- */
-
-#if ARCH_ARM
-# include "arm/intmath.h"
-#endif
-
-#if HAVE_FAST_CLZ && AV_GCC_VERSION_AT_LEAST(3,4)
-
-#ifndef ff_log2
-# define ff_log2(x) (31 - __builtin_clz((x)|1))
-# ifndef ff_log2_16bit
-# define ff_log2_16bit av_log2
-# endif
-#endif /* ff_log2 */
-
-#endif /* AV_GCC_VERSION_AT_LEAST(3,4) */
-
-extern const uint8_t ff_log2_tab[256];
-
-#ifndef ff_log2
-#define ff_log2 ff_log2_c
-static av_always_inline av_const int ff_log2_c(unsigned int v)
-{
- int n = 0;
- if (v & 0xffff0000) {
- v >>= 16;
- n += 16;
- }
- if (v & 0xff00) {
- v >>= 8;
- n += 8;
- }
- n += ff_log2_tab[v];
-
- return n;
-}
-#endif
-
-#ifndef ff_log2_16bit
-#define ff_log2_16bit ff_log2_16bit_c
-static av_always_inline av_const int ff_log2_16bit_c(unsigned int v)
-{
- int n = 0;
- if (v & 0xff00) {
- v >>= 8;
- n += 8;
- }
- n += ff_log2_tab[v];
-
- return n;
-}
-#endif
-
-#define av_log2 ff_log2
-#define av_log2_16bit ff_log2_16bit
-
-/**
- * @}
- */
-
-/**
- * @addtogroup lavu_math
- * @{
- */
-
-#if HAVE_FAST_CLZ && AV_GCC_VERSION_AT_LEAST(3,4)
-#ifndef ff_ctz
-#define ff_ctz(v) __builtin_ctz(v)
-#endif
-#endif
-
-#ifndef ff_ctz
-#define ff_ctz ff_ctz_c
-static av_always_inline av_const int ff_ctz_c(int v)
-{
- int c;
-
- if (v & 0x1)
- return 0;
-
- c = 1;
- if (!(v & 0xffff)) {
- v >>= 16;
- c += 16;
- }
- if (!(v & 0xff)) {
- v >>= 8;
- c += 8;
- }
- if (!(v & 0xf)) {
- v >>= 4;
- c += 4;
- }
- if (!(v & 0x3)) {
- v >>= 2;
- c += 2;
- }
- c -= v & 0x1;
-
- return c;
-}
-#endif
-
-/**
- * Trailing zero bit count.
- *
- * @param v input value. If v is 0, the result is undefined.
- * @return the number of trailing 0-bits
- */
-int av_ctz(int v);
-
-/**
- * @}
- */
-#endif /* AVUTIL_INTMATH_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/intreadwrite.h b/src/thirdparty/ffmpeg/libavutil/intreadwrite.h
deleted file mode 100644
index 810b1b0cc..000000000
--- a/src/thirdparty/ffmpeg/libavutil/intreadwrite.h
+++ /dev/null
@@ -1,621 +0,0 @@
-/*
- * 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 AVUTIL_INTREADWRITE_H
-#define AVUTIL_INTREADWRITE_H
-
-#include <stdint.h>
-#include "libavutil/avconfig.h"
-#include "attributes.h"
-#include "bswap.h"
-
-typedef union {
- uint64_t u64;
- uint32_t u32[2];
- uint16_t u16[4];
- uint8_t u8 [8];
- double f64;
- float f32[2];
-} av_alias av_alias64;
-
-typedef union {
- uint32_t u32;
- uint16_t u16[2];
- uint8_t u8 [4];
- float f32;
-} av_alias av_alias32;
-
-typedef union {
- uint16_t u16;
- uint8_t u8 [2];
-} av_alias av_alias16;
-
-/*
- * Arch-specific headers can provide any combination of
- * AV_[RW][BLN](16|24|32|48|64) and AV_(COPY|SWAP|ZERO)(64|128) macros.
- * Preprocessor symbols must be defined, even if these are implemented
- * as inline functions.
- */
-
-#ifdef HAVE_AV_CONFIG_H
-
-#include "config.h"
-
-#if ARCH_ARM
-# include "arm/intreadwrite.h"
-#elif ARCH_AVR32
-# include "avr32/intreadwrite.h"
-#elif ARCH_MIPS
-# include "mips/intreadwrite.h"
-#elif ARCH_PPC
-# include "ppc/intreadwrite.h"
-#elif ARCH_TOMI
-# include "tomi/intreadwrite.h"
-#elif ARCH_X86
-# include "x86/intreadwrite.h"
-#endif
-
-#endif /* HAVE_AV_CONFIG_H */
-
-/*
- * Map AV_RNXX <-> AV_R[BL]XX for all variants provided by per-arch headers.
- */
-
-#if AV_HAVE_BIGENDIAN
-
-# if defined(AV_RN16) && !defined(AV_RB16)
-# define AV_RB16(p) AV_RN16(p)
-# elif !defined(AV_RN16) && defined(AV_RB16)
-# define AV_RN16(p) AV_RB16(p)
-# endif
-
-# if defined(AV_WN16) && !defined(AV_WB16)
-# define AV_WB16(p, v) AV_WN16(p, v)
-# elif !defined(AV_WN16) && defined(AV_WB16)
-# define AV_WN16(p, v) AV_WB16(p, v)
-# endif
-
-# if defined(AV_RN24) && !defined(AV_RB24)
-# define AV_RB24(p) AV_RN24(p)
-# elif !defined(AV_RN24) && defined(AV_RB24)
-# define AV_RN24(p) AV_RB24(p)
-# endif
-
-# if defined(AV_WN24) && !defined(AV_WB24)
-# define AV_WB24(p, v) AV_WN24(p, v)
-# elif !defined(AV_WN24) && defined(AV_WB24)
-# define AV_WN24(p, v) AV_WB24(p, v)
-# endif
-
-# if defined(AV_RN32) && !defined(AV_RB32)
-# define AV_RB32(p) AV_RN32(p)
-# elif !defined(AV_RN32) && defined(AV_RB32)
-# define AV_RN32(p) AV_RB32(p)
-# endif
-
-# if defined(AV_WN32) && !defined(AV_WB32)
-# define AV_WB32(p, v) AV_WN32(p, v)
-# elif !defined(AV_WN32) && defined(AV_WB32)
-# define AV_WN32(p, v) AV_WB32(p, v)
-# endif
-
-# if defined(AV_RN48) && !defined(AV_RB48)
-# define AV_RB48(p) AV_RN48(p)
-# elif !defined(AV_RN48) && defined(AV_RB48)
-# define AV_RN48(p) AV_RB48(p)
-# endif
-
-# if defined(AV_WN48) && !defined(AV_WB48)
-# define AV_WB48(p, v) AV_WN48(p, v)
-# elif !defined(AV_WN48) && defined(AV_WB48)
-# define AV_WN48(p, v) AV_WB48(p, v)
-# endif
-
-# if defined(AV_RN64) && !defined(AV_RB64)
-# define AV_RB64(p) AV_RN64(p)
-# elif !defined(AV_RN64) && defined(AV_RB64)
-# define AV_RN64(p) AV_RB64(p)
-# endif
-
-# if defined(AV_WN64) && !defined(AV_WB64)
-# define AV_WB64(p, v) AV_WN64(p, v)
-# elif !defined(AV_WN64) && defined(AV_WB64)
-# define AV_WN64(p, v) AV_WB64(p, v)
-# endif
-
-#else /* AV_HAVE_BIGENDIAN */
-
-# if defined(AV_RN16) && !defined(AV_RL16)
-# define AV_RL16(p) AV_RN16(p)
-# elif !defined(AV_RN16) && defined(AV_RL16)
-# define AV_RN16(p) AV_RL16(p)
-# endif
-
-# if defined(AV_WN16) && !defined(AV_WL16)
-# define AV_WL16(p, v) AV_WN16(p, v)
-# elif !defined(AV_WN16) && defined(AV_WL16)
-# define AV_WN16(p, v) AV_WL16(p, v)
-# endif
-
-# if defined(AV_RN24) && !defined(AV_RL24)
-# define AV_RL24(p) AV_RN24(p)
-# elif !defined(AV_RN24) && defined(AV_RL24)
-# define AV_RN24(p) AV_RL24(p)
-# endif
-
-# if defined(AV_WN24) && !defined(AV_WL24)
-# define AV_WL24(p, v) AV_WN24(p, v)
-# elif !defined(AV_WN24) && defined(AV_WL24)
-# define AV_WN24(p, v) AV_WL24(p, v)
-# endif
-
-# if defined(AV_RN32) && !defined(AV_RL32)
-# define AV_RL32(p) AV_RN32(p)
-# elif !defined(AV_RN32) && defined(AV_RL32)
-# define AV_RN32(p) AV_RL32(p)
-# endif
-
-# if defined(AV_WN32) && !defined(AV_WL32)
-# define AV_WL32(p, v) AV_WN32(p, v)
-# elif !defined(AV_WN32) && defined(AV_WL32)
-# define AV_WN32(p, v) AV_WL32(p, v)
-# endif
-
-# if defined(AV_RN48) && !defined(AV_RL48)
-# define AV_RL48(p) AV_RN48(p)
-# elif !defined(AV_RN48) && defined(AV_RL48)
-# define AV_RN48(p) AV_RL48(p)
-# endif
-
-# if defined(AV_WN48) && !defined(AV_WL48)
-# define AV_WL48(p, v) AV_WN48(p, v)
-# elif !defined(AV_WN48) && defined(AV_WL48)
-# define AV_WN48(p, v) AV_WL48(p, v)
-# endif
-
-# if defined(AV_RN64) && !defined(AV_RL64)
-# define AV_RL64(p) AV_RN64(p)
-# elif !defined(AV_RN64) && defined(AV_RL64)
-# define AV_RN64(p) AV_RL64(p)
-# endif
-
-# if defined(AV_WN64) && !defined(AV_WL64)
-# define AV_WL64(p, v) AV_WN64(p, v)
-# elif !defined(AV_WN64) && defined(AV_WL64)
-# define AV_WN64(p, v) AV_WL64(p, v)
-# endif
-
-#endif /* !AV_HAVE_BIGENDIAN */
-
-/*
- * Define AV_[RW]N helper macros to simplify definitions not provided
- * by per-arch headers.
- */
-
-#if defined(__GNUC__) && !defined(__TI_COMPILER_VERSION__)
-
-union unaligned_64 { uint64_t l; } __attribute__((packed)) av_alias;
-union unaligned_32 { uint32_t l; } __attribute__((packed)) av_alias;
-union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
-
-# define AV_RN(s, p) (((const union unaligned_##s *) (p))->l)
-# define AV_WN(s, p, v) ((((union unaligned_##s *) (p))->l) = (v))
-
-#elif defined(__DECC)
-
-# define AV_RN(s, p) (*((const __unaligned uint##s##_t*)(p)))
-# define AV_WN(s, p, v) (*((__unaligned uint##s##_t*)(p)) = (v))
-
-#elif AV_HAVE_FAST_UNALIGNED
-
-# define AV_RN(s, p) (((const av_alias##s*)(p))->u##s)
-# define AV_WN(s, p, v) (((av_alias##s*)(p))->u##s = (v))
-
-#else
-
-#ifndef AV_RB16
-# define AV_RB16(x) \
- ((((const uint8_t*)(x))[0] << 8) | \
- ((const uint8_t*)(x))[1])
-#endif
-#ifndef AV_WB16
-# define AV_WB16(p, darg) do { \
- unsigned d = (darg); \
- ((uint8_t*)(p))[1] = (d); \
- ((uint8_t*)(p))[0] = (d)>>8; \
- } while(0)
-#endif
-
-#ifndef AV_RL16
-# define AV_RL16(x) \
- ((((const uint8_t*)(x))[1] << 8) | \
- ((const uint8_t*)(x))[0])
-#endif
-#ifndef AV_WL16
-# define AV_WL16(p, darg) do { \
- unsigned d = (darg); \
- ((uint8_t*)(p))[0] = (d); \
- ((uint8_t*)(p))[1] = (d)>>8; \
- } while(0)
-#endif
-
-#ifndef AV_RB32
-# define AV_RB32(x) \
- (((uint32_t)((const uint8_t*)(x))[0] << 24) | \
- (((const uint8_t*)(x))[1] << 16) | \
- (((const uint8_t*)(x))[2] << 8) | \
- ((const uint8_t*)(x))[3])
-#endif
-#ifndef AV_WB32
-# define AV_WB32(p, darg) do { \
- unsigned d = (darg); \
- ((uint8_t*)(p))[3] = (d); \
- ((uint8_t*)(p))[2] = (d)>>8; \
- ((uint8_t*)(p))[1] = (d)>>16; \
- ((uint8_t*)(p))[0] = (d)>>24; \
- } while(0)
-#endif
-
-#ifndef AV_RL32
-# define AV_RL32(x) \
- (((uint32_t)((const uint8_t*)(x))[3] << 24) | \
- (((const uint8_t*)(x))[2] << 16) | \
- (((const uint8_t*)(x))[1] << 8) | \
- ((const uint8_t*)(x))[0])
-#endif
-#ifndef AV_WL32
-# define AV_WL32(p, darg) do { \
- unsigned d = (darg); \
- ((uint8_t*)(p))[0] = (d); \
- ((uint8_t*)(p))[1] = (d)>>8; \
- ((uint8_t*)(p))[2] = (d)>>16; \
- ((uint8_t*)(p))[3] = (d)>>24; \
- } while(0)
-#endif
-
-#ifndef AV_RB64
-# define AV_RB64(x) \
- (((uint64_t)((const uint8_t*)(x))[0] << 56) | \
- ((uint64_t)((const uint8_t*)(x))[1] << 48) | \
- ((uint64_t)((const uint8_t*)(x))[2] << 40) | \
- ((uint64_t)((const uint8_t*)(x))[3] << 32) | \
- ((uint64_t)((const uint8_t*)(x))[4] << 24) | \
- ((uint64_t)((const uint8_t*)(x))[5] << 16) | \
- ((uint64_t)((const uint8_t*)(x))[6] << 8) | \
- (uint64_t)((const uint8_t*)(x))[7])
-#endif
-#ifndef AV_WB64
-# define AV_WB64(p, darg) do { \
- uint64_t d = (darg); \
- ((uint8_t*)(p))[7] = (d); \
- ((uint8_t*)(p))[6] = (d)>>8; \
- ((uint8_t*)(p))[5] = (d)>>16; \
- ((uint8_t*)(p))[4] = (d)>>24; \
- ((uint8_t*)(p))[3] = (d)>>32; \
- ((uint8_t*)(p))[2] = (d)>>40; \
- ((uint8_t*)(p))[1] = (d)>>48; \
- ((uint8_t*)(p))[0] = (d)>>56; \
- } while(0)
-#endif
-
-#ifndef AV_RL64
-# define AV_RL64(x) \
- (((uint64_t)((const uint8_t*)(x))[7] << 56) | \
- ((uint64_t)((const uint8_t*)(x))[6] << 48) | \
- ((uint64_t)((const uint8_t*)(x))[5] << 40) | \
- ((uint64_t)((const uint8_t*)(x))[4] << 32) | \
- ((uint64_t)((const uint8_t*)(x))[3] << 24) | \
- ((uint64_t)((const uint8_t*)(x))[2] << 16) | \
- ((uint64_t)((const uint8_t*)(x))[1] << 8) | \
- (uint64_t)((const uint8_t*)(x))[0])
-#endif
-#ifndef AV_WL64
-# define AV_WL64(p, darg) do { \
- uint64_t d = (darg); \
- ((uint8_t*)(p))[0] = (d); \
- ((uint8_t*)(p))[1] = (d)>>8; \
- ((uint8_t*)(p))[2] = (d)>>16; \
- ((uint8_t*)(p))[3] = (d)>>24; \
- ((uint8_t*)(p))[4] = (d)>>32; \
- ((uint8_t*)(p))[5] = (d)>>40; \
- ((uint8_t*)(p))[6] = (d)>>48; \
- ((uint8_t*)(p))[7] = (d)>>56; \
- } while(0)
-#endif
-
-#if AV_HAVE_BIGENDIAN
-# define AV_RN(s, p) AV_RB##s(p)
-# define AV_WN(s, p, v) AV_WB##s(p, v)
-#else
-# define AV_RN(s, p) AV_RL##s(p)
-# define AV_WN(s, p, v) AV_WL##s(p, v)
-#endif
-
-#endif /* HAVE_FAST_UNALIGNED */
-
-#ifndef AV_RN16
-# define AV_RN16(p) AV_RN(16, p)
-#endif
-
-#ifndef AV_RN32
-# define AV_RN32(p) AV_RN(32, p)
-#endif
-
-#ifndef AV_RN64
-# define AV_RN64(p) AV_RN(64, p)
-#endif
-
-#ifndef AV_WN16
-# define AV_WN16(p, v) AV_WN(16, p, v)
-#endif
-
-#ifndef AV_WN32
-# define AV_WN32(p, v) AV_WN(32, p, v)
-#endif
-
-#ifndef AV_WN64
-# define AV_WN64(p, v) AV_WN(64, p, v)
-#endif
-
-#if AV_HAVE_BIGENDIAN
-# define AV_RB(s, p) AV_RN##s(p)
-# define AV_WB(s, p, v) AV_WN##s(p, v)
-# define AV_RL(s, p) av_bswap##s(AV_RN##s(p))
-# define AV_WL(s, p, v) AV_WN##s(p, av_bswap##s(v))
-#else
-# define AV_RB(s, p) av_bswap##s(AV_RN##s(p))
-# define AV_WB(s, p, v) AV_WN##s(p, av_bswap##s(v))
-# define AV_RL(s, p) AV_RN##s(p)
-# define AV_WL(s, p, v) AV_WN##s(p, v)
-#endif
-
-#define AV_RB8(x) (((const uint8_t*)(x))[0])
-#define AV_WB8(p, d) do { ((uint8_t*)(p))[0] = (d); } while(0)
-
-#define AV_RL8(x) AV_RB8(x)
-#define AV_WL8(p, d) AV_WB8(p, d)
-
-#ifndef AV_RB16
-# define AV_RB16(p) AV_RB(16, p)
-#endif
-#ifndef AV_WB16
-# define AV_WB16(p, v) AV_WB(16, p, v)
-#endif
-
-#ifndef AV_RL16
-# define AV_RL16(p) AV_RL(16, p)
-#endif
-#ifndef AV_WL16
-# define AV_WL16(p, v) AV_WL(16, p, v)
-#endif
-
-#ifndef AV_RB32
-# define AV_RB32(p) AV_RB(32, p)
-#endif
-#ifndef AV_WB32
-# define AV_WB32(p, v) AV_WB(32, p, v)
-#endif
-
-#ifndef AV_RL32
-# define AV_RL32(p) AV_RL(32, p)
-#endif
-#ifndef AV_WL32
-# define AV_WL32(p, v) AV_WL(32, p, v)
-#endif
-
-#ifndef AV_RB64
-# define AV_RB64(p) AV_RB(64, p)
-#endif
-#ifndef AV_WB64
-# define AV_WB64(p, v) AV_WB(64, p, v)
-#endif
-
-#ifndef AV_RL64
-# define AV_RL64(p) AV_RL(64, p)
-#endif
-#ifndef AV_WL64
-# define AV_WL64(p, v) AV_WL(64, p, v)
-#endif
-
-#ifndef AV_RB24
-# define AV_RB24(x) \
- ((((const uint8_t*)(x))[0] << 16) | \
- (((const uint8_t*)(x))[1] << 8) | \
- ((const uint8_t*)(x))[2])
-#endif
-#ifndef AV_WB24
-# define AV_WB24(p, d) do { \
- ((uint8_t*)(p))[2] = (d); \
- ((uint8_t*)(p))[1] = (d)>>8; \
- ((uint8_t*)(p))[0] = (d)>>16; \
- } while(0)
-#endif
-
-#ifndef AV_RL24
-# define AV_RL24(x) \
- ((((const uint8_t*)(x))[2] << 16) | \
- (((const uint8_t*)(x))[1] << 8) | \
- ((const uint8_t*)(x))[0])
-#endif
-#ifndef AV_WL24
-# define AV_WL24(p, d) do { \
- ((uint8_t*)(p))[0] = (d); \
- ((uint8_t*)(p))[1] = (d)>>8; \
- ((uint8_t*)(p))[2] = (d)>>16; \
- } while(0)
-#endif
-
-#ifndef AV_RB48
-# define AV_RB48(x) \
- (((uint64_t)((const uint8_t*)(x))[0] << 40) | \
- ((uint64_t)((const uint8_t*)(x))[1] << 32) | \
- ((uint64_t)((const uint8_t*)(x))[2] << 24) | \
- ((uint64_t)((const uint8_t*)(x))[3] << 16) | \
- ((uint64_t)((const uint8_t*)(x))[4] << 8) | \
- (uint64_t)((const uint8_t*)(x))[5])
-#endif
-#ifndef AV_WB48
-# define AV_WB48(p, darg) do { \
- uint64_t d = (darg); \
- ((uint8_t*)(p))[5] = (d); \
- ((uint8_t*)(p))[4] = (d)>>8; \
- ((uint8_t*)(p))[3] = (d)>>16; \
- ((uint8_t*)(p))[2] = (d)>>24; \
- ((uint8_t*)(p))[1] = (d)>>32; \
- ((uint8_t*)(p))[0] = (d)>>40; \
- } while(0)
-#endif
-
-#ifndef AV_RL48
-# define AV_RL48(x) \
- (((uint64_t)((const uint8_t*)(x))[5] << 40) | \
- ((uint64_t)((const uint8_t*)(x))[4] << 32) | \
- ((uint64_t)((const uint8_t*)(x))[3] << 24) | \
- ((uint64_t)((const uint8_t*)(x))[2] << 16) | \
- ((uint64_t)((const uint8_t*)(x))[1] << 8) | \
- (uint64_t)((const uint8_t*)(x))[0])
-#endif
-#ifndef AV_WL48
-# define AV_WL48(p, darg) do { \
- uint64_t d = (darg); \
- ((uint8_t*)(p))[0] = (d); \
- ((uint8_t*)(p))[1] = (d)>>8; \
- ((uint8_t*)(p))[2] = (d)>>16; \
- ((uint8_t*)(p))[3] = (d)>>24; \
- ((uint8_t*)(p))[4] = (d)>>32; \
- ((uint8_t*)(p))[5] = (d)>>40; \
- } while(0)
-#endif
-
-/*
- * The AV_[RW]NA macros access naturally aligned data
- * in a type-safe way.
- */
-
-#define AV_RNA(s, p) (((const av_alias##s*)(p))->u##s)
-#define AV_WNA(s, p, v) (((av_alias##s*)(p))->u##s = (v))
-
-#ifndef AV_RN16A
-# define AV_RN16A(p) AV_RNA(16, p)
-#endif
-
-#ifndef AV_RN32A
-# define AV_RN32A(p) AV_RNA(32, p)
-#endif
-
-#ifndef AV_RN64A
-# define AV_RN64A(p) AV_RNA(64, p)
-#endif
-
-#ifndef AV_WN16A
-# define AV_WN16A(p, v) AV_WNA(16, p, v)
-#endif
-
-#ifndef AV_WN32A
-# define AV_WN32A(p, v) AV_WNA(32, p, v)
-#endif
-
-#ifndef AV_WN64A
-# define AV_WN64A(p, v) AV_WNA(64, p, v)
-#endif
-
-/*
- * The AV_COPYxxU macros are suitable for copying data to/from unaligned
- * memory locations.
- */
-
-#define AV_COPYU(n, d, s) AV_WN##n(d, AV_RN##n(s));
-
-#ifndef AV_COPY16U
-# define AV_COPY16U(d, s) AV_COPYU(16, d, s)
-#endif
-
-#ifndef AV_COPY32U
-# define AV_COPY32U(d, s) AV_COPYU(32, d, s)
-#endif
-
-#ifndef AV_COPY64U
-# define AV_COPY64U(d, s) AV_COPYU(64, d, s)
-#endif
-
-#ifndef AV_COPY128U
-# define AV_COPY128U(d, s) \
- do { \
- AV_COPY64U(d, s); \
- AV_COPY64U((char *)(d) + 8, (const char *)(s) + 8); \
- } while(0)
-#endif
-
-/* Parameters for AV_COPY*, AV_SWAP*, AV_ZERO* must be
- * naturally aligned. They may be implemented using MMX,
- * so emms_c() must be called before using any float code
- * afterwards.
- */
-
-#define AV_COPY(n, d, s) \
- (((av_alias##n*)(d))->u##n = ((const av_alias##n*)(s))->u##n)
-
-#ifndef AV_COPY16
-# define AV_COPY16(d, s) AV_COPY(16, d, s)
-#endif
-
-#ifndef AV_COPY32
-# define AV_COPY32(d, s) AV_COPY(32, d, s)
-#endif
-
-#ifndef AV_COPY64
-# define AV_COPY64(d, s) AV_COPY(64, d, s)
-#endif
-
-#ifndef AV_COPY128
-# define AV_COPY128(d, s) \
- do { \
- AV_COPY64(d, s); \
- AV_COPY64((char*)(d)+8, (char*)(s)+8); \
- } while(0)
-#endif
-
-#define AV_SWAP(n, a, b) FFSWAP(av_alias##n, *(av_alias##n*)(a), *(av_alias##n*)(b))
-
-#ifndef AV_SWAP64
-# define AV_SWAP64(a, b) AV_SWAP(64, a, b)
-#endif
-
-#define AV_ZERO(n, d) (((av_alias##n*)(d))->u##n = 0)
-
-#ifndef AV_ZERO16
-# define AV_ZERO16(d) AV_ZERO(16, d)
-#endif
-
-#ifndef AV_ZERO32
-# define AV_ZERO32(d) AV_ZERO(32, d)
-#endif
-
-#ifndef AV_ZERO64
-# define AV_ZERO64(d) AV_ZERO(64, d)
-#endif
-
-#ifndef AV_ZERO128
-# define AV_ZERO128(d) \
- do { \
- AV_ZERO64(d); \
- AV_ZERO64((char*)(d)+8); \
- } while(0)
-#endif
-
-#endif /* AVUTIL_INTREADWRITE_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/lfg.c b/src/thirdparty/ffmpeg/libavutil/lfg.c
deleted file mode 100644
index 1a5319e74..000000000
--- a/src/thirdparty/ffmpeg/libavutil/lfg.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Lagged Fibonacci PRNG
- * Copyright (c) 2008 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 <inttypes.h>
-#include <limits.h>
-#include <math.h>
-#include "lfg.h"
-#include "md5.h"
-#include "intreadwrite.h"
-#include "attributes.h"
-
-av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
-{
- uint8_t tmp[16] = { 0 };
- int i;
-
- for (i = 8; i < 64; i += 4) {
- AV_WL32(tmp, seed);
- tmp[4] = i;
- av_md5_sum(tmp, tmp, 16);
- c->state[i ] = AV_RL32(tmp);
- c->state[i + 1] = AV_RL32(tmp + 4);
- c->state[i + 2] = AV_RL32(tmp + 8);
- c->state[i + 3] = AV_RL32(tmp + 12);
- }
- c->index = 0;
-}
-
-void av_bmg_get(AVLFG *lfg, double out[2])
-{
- double x1, x2, w;
-
- do {
- x1 = 2.0 / UINT_MAX * av_lfg_get(lfg) - 1.0;
- x2 = 2.0 / UINT_MAX * av_lfg_get(lfg) - 1.0;
- w = x1 * x1 + x2 * x2;
- } while (w >= 1.0);
-
- w = sqrt((-2.0 * log(w)) / w);
- out[0] = x1 * w;
- out[1] = x2 * w;
-}
-
-#ifdef TEST
-#include "log.h"
-#include "timer.h"
-
-int main(void)
-{
- int x = 0;
- int i, j;
- AVLFG state;
-
- av_lfg_init(&state, 0xdeadbeef);
- for (j = 0; j < 10000; j++) {
- START_TIMER
- for (i = 0; i < 624; i++) {
- //av_log(NULL, AV_LOG_ERROR, "%X\n", av_lfg_get(&state));
- x += av_lfg_get(&state);
- }
- STOP_TIMER("624 calls of av_lfg_get");
- }
- av_log(NULL, AV_LOG_ERROR, "final value:%X\n", x);
-
- /* BMG usage example */
- {
- double mean = 1000;
- double stddev = 53;
-
- av_lfg_init(&state, 42);
-
- for (i = 0; i < 1000; i += 2) {
- double bmg_out[2];
- av_bmg_get(&state, bmg_out);
- av_log(NULL, AV_LOG_INFO,
- "%f\n%f\n",
- bmg_out[0] * stddev + mean,
- bmg_out[1] * stddev + mean);
- }
- }
-
- return 0;
-}
-#endif
diff --git a/src/thirdparty/ffmpeg/libavutil/lfg.h b/src/thirdparty/ffmpeg/libavutil/lfg.h
deleted file mode 100644
index b53b8e4e1..000000000
--- a/src/thirdparty/ffmpeg/libavutil/lfg.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Lagged Fibonacci PRNG
- * Copyright (c) 2008 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
- */
-
-#ifndef AVUTIL_LFG_H
-#define AVUTIL_LFG_H
-
-typedef struct AVLFG {
- unsigned int state[64];
- int index;
-} AVLFG;
-
-void av_lfg_init(AVLFG *c, unsigned int seed);
-
-/**
- * Get the next random unsigned 32-bit number using an ALFG.
- *
- * Please also consider a simple LCG like state= state*1664525+1013904223,
- * it may be good enough and faster for your specific use case.
- */
-static inline unsigned int av_lfg_get(AVLFG *c){
- c->state[c->index & 63] = c->state[(c->index-24) & 63] + c->state[(c->index-55) & 63];
- return c->state[c->index++ & 63];
-}
-
-/**
- * Get the next random unsigned 32-bit number using a MLFG.
- *
- * Please also consider av_lfg_get() above, it is faster.
- */
-static inline unsigned int av_mlfg_get(AVLFG *c){
- unsigned int a= c->state[(c->index-55) & 63];
- unsigned int b= c->state[(c->index-24) & 63];
- return c->state[c->index++ & 63] = 2*a*b+a+b;
-}
-
-/**
- * Get the next two numbers generated by a Box-Muller Gaussian
- * generator using the random numbers issued by lfg.
- *
- * @param out array where the two generated numbers are placed
- */
-void av_bmg_get(AVLFG *lfg, double out[2]);
-
-#endif /* AVUTIL_LFG_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/libm.h b/src/thirdparty/ffmpeg/libavutil/libm.h
deleted file mode 100644
index e00b04fbf..000000000
--- a/src/thirdparty/ffmpeg/libavutil/libm.h
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * 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
- * Replacements for frequently missing libm functions
- */
-
-#ifndef AVUTIL_LIBM_H
-#define AVUTIL_LIBM_H
-
-#include <math.h>
-#include "config.h"
-#include "attributes.h"
-#include "intfloat.h"
-
-#if HAVE_MIPSFPU && HAVE_INLINE_ASM
-#include "libavutil/mips/libm_mips.h"
-#endif /* HAVE_MIPSFPU && HAVE_INLINE_ASM*/
-
-#if !HAVE_ATANF
-#undef atanf
-#define atanf(x) ((float)atan(x))
-#endif
-
-#if !HAVE_ATAN2F
-#undef atan2f
-#define atan2f(y, x) ((float)atan2(y, x))
-#endif
-
-#if !HAVE_POWF
-#undef powf
-#define powf(x, y) ((float)pow(x, y))
-#endif
-
-#if !HAVE_CBRT
-static av_always_inline double cbrt(double x)
-{
- return x < 0 ? -pow(-x, 1.0 / 3.0) : pow(x, 1.0 / 3.0);
-}
-#endif
-
-#if !HAVE_CBRTF
-static av_always_inline float cbrtf(float x)
-{
- return x < 0 ? -powf(-x, 1.0 / 3.0) : powf(x, 1.0 / 3.0);
-}
-#endif
-
-#if !HAVE_COSF
-#undef cosf
-#define cosf(x) ((float)cos(x))
-#endif
-
-#if !HAVE_EXPF
-#undef expf
-#define expf(x) ((float)exp(x))
-#endif
-
-#if !HAVE_EXP2
-#undef exp2
-#define exp2(x) exp((x) * 0.693147180559945)
-#endif /* HAVE_EXP2 */
-
-#if !HAVE_EXP2F
-#undef exp2f
-#define exp2f(x) ((float)exp2(x))
-#endif /* HAVE_EXP2F */
-
-#if !HAVE_ISINF
-static av_always_inline av_const int isinf(float x)
-{
- uint32_t v = av_float2int(x);
- if ((v & 0x7f800000) != 0x7f800000)
- return 0;
- return !(v & 0x007fffff);
-}
-#endif /* HAVE_ISINF */
-
-#if !HAVE_ISNAN
-static av_always_inline av_const int isnan(float x)
-{
- uint32_t v = av_float2int(x);
- if ((v & 0x7f800000) != 0x7f800000)
- return 0;
- return v & 0x007fffff;
-}
-#endif /* HAVE_ISNAN */
-
-#if !HAVE_LDEXPF
-#undef ldexpf
-#define ldexpf(x, exp) ((float)ldexp(x, exp))
-#endif
-
-#if !HAVE_LLRINT
-#undef llrint
-#define llrint(x) ((long long)rint(x))
-#endif /* HAVE_LLRINT */
-
-#if !HAVE_LLRINTF
-#undef llrintf
-#define llrintf(x) ((long long)rint(x))
-#endif /* HAVE_LLRINT */
-
-#if !HAVE_LOG2
-#undef log2
-#define log2(x) (log(x) * 1.44269504088896340736)
-#endif /* HAVE_LOG2 */
-
-#if !HAVE_LOG2F
-#undef log2f
-#define log2f(x) ((float)log2(x))
-#endif /* HAVE_LOG2F */
-
-#if !HAVE_LOG10F
-#undef log10f
-#define log10f(x) ((float)log10(x))
-#endif
-
-#if !HAVE_SINF
-#undef sinf
-#define sinf(x) ((float)sin(x))
-#endif
-
-#if !HAVE_RINT
-static inline double rint(double x)
-{
- return x >= 0 ? floor(x + 0.5) : ceil(x - 0.5);
-}
-#endif /* HAVE_RINT */
-
-#if !HAVE_LRINT
-static av_always_inline av_const long int lrint(double x)
-{
- return rint(x);
-}
-#endif /* HAVE_LRINT */
-
-#if !HAVE_LRINTF
-static av_always_inline av_const long int lrintf(float x)
-{
- return (int)(rint(x));
-}
-#endif /* HAVE_LRINTF */
-
-#if !HAVE_ROUND
-static av_always_inline av_const double round(double x)
-{
- return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
-}
-#endif /* HAVE_ROUND */
-
-#if !HAVE_ROUNDF
-static av_always_inline av_const float roundf(float x)
-{
- return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5);
-}
-#endif /* HAVE_ROUNDF */
-
-#if !HAVE_TRUNC
-static av_always_inline av_const double trunc(double x)
-{
- return (x > 0) ? floor(x) : ceil(x);
-}
-#endif /* HAVE_TRUNC */
-
-#if !HAVE_TRUNCF
-static av_always_inline av_const float truncf(float x)
-{
- return (x > 0) ? floor(x) : ceil(x);
-}
-#endif /* HAVE_TRUNCF */
-
-#endif /* AVUTIL_LIBM_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/lls.c b/src/thirdparty/ffmpeg/libavutil/lls.c
deleted file mode 100644
index 726abc8ec..000000000
--- a/src/thirdparty/ffmpeg/libavutil/lls.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * linear least squares model
- *
- * Copyright (c) 2006 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
- * linear least squares model
- */
-
-#include <math.h>
-#include <string.h>
-
-#include "lls.h"
-
-void av_init_lls(LLSModel *m, int indep_count)
-{
- memset(m, 0, sizeof(LLSModel));
- m->indep_count = indep_count;
-}
-
-void av_update_lls(LLSModel *m, double *var, double decay)
-{
- int i, j;
-
- for (i = 0; i <= m->indep_count; i++) {
- for (j = i; j <= m->indep_count; j++) {
- m->covariance[i][j] *= decay;
- m->covariance[i][j] += var[i] * var[j];
- }
- }
-}
-
-void av_solve_lls(LLSModel *m, double threshold, int min_order)
-{
- int i, j, k;
- double (*factor)[MAX_VARS + 1] = (void *) &m->covariance[1][0];
- double (*covar) [MAX_VARS + 1] = (void *) &m->covariance[1][1];
- double *covar_y = m->covariance[0];
- int count = m->indep_count;
-
- for (i = 0; i < count; i++) {
- for (j = i; j < count; j++) {
- double sum = covar[i][j];
-
- for (k = i - 1; k >= 0; k--)
- sum -= factor[i][k] * factor[j][k];
-
- if (i == j) {
- if (sum < threshold)
- sum = 1.0;
- factor[i][i] = sqrt(sum);
- } else {
- factor[j][i] = sum / factor[i][i];
- }
- }
- }
-
- for (i = 0; i < count; i++) {
- double sum = covar_y[i + 1];
-
- for (k = i - 1; k >= 0; k--)
- sum -= factor[i][k] * m->coeff[0][k];
-
- m->coeff[0][i] = sum / factor[i][i];
- }
-
- for (j = count - 1; j >= min_order; j--) {
- for (i = j; i >= 0; i--) {
- double sum = m->coeff[0][i];
-
- for (k = i + 1; k <= j; k++)
- sum -= factor[k][i] * m->coeff[j][k];
-
- m->coeff[j][i] = sum / factor[i][i];
- }
-
- m->variance[j] = covar_y[0];
-
- for (i = 0; i <= j; i++) {
- double sum = m->coeff[j][i] * covar[i][i] - 2 * covar_y[i + 1];
-
- for (k = 0; k < i; k++)
- sum += 2 * m->coeff[j][k] * covar[k][i];
-
- m->variance[j] += m->coeff[j][i] * sum;
- }
- }
-}
-
-double av_evaluate_lls(LLSModel *m, double *param, int order)
-{
- int i;
- double out = 0;
-
- for (i = 0; i <= order; i++)
- out += param[i] * m->coeff[order][i];
-
- return out;
-}
-
-#ifdef TEST
-
-#include <stdio.h>
-#include <limits.h>
-#include "lfg.h"
-
-int main(void)
-{
- LLSModel m;
- int i, order;
- AVLFG lfg;
-
- av_lfg_init(&lfg, 1);
- av_init_lls(&m, 3);
-
- for (i = 0; i < 100; i++) {
- double var[4];
- double eval;
-
- var[0] = (av_lfg_get(&lfg) / (double) UINT_MAX - 0.5) * 2;
- var[1] = var[0] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5;
- var[2] = var[1] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5;
- var[3] = var[2] + av_lfg_get(&lfg) / (double) UINT_MAX - 0.5;
- av_update_lls(&m, var, 0.99);
- av_solve_lls(&m, 0.001, 0);
- for (order = 0; order < 3; order++) {
- eval = av_evaluate_lls(&m, var + 1, order);
- printf("real:%9f order:%d pred:%9f var:%f coeffs:%f %9f %9f\n",
- var[0], order, eval, sqrt(m.variance[order] / (i + 1)),
- m.coeff[order][0], m.coeff[order][1],
- m.coeff[order][2]);
- }
- }
- return 0;
-}
-
-#endif
diff --git a/src/thirdparty/ffmpeg/libavutil/lls.h b/src/thirdparty/ffmpeg/libavutil/lls.h
deleted file mode 100644
index b91397de9..000000000
--- a/src/thirdparty/ffmpeg/libavutil/lls.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * linear least squares model
- *
- * Copyright (c) 2006 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
- */
-
-#ifndef AVUTIL_LLS_H
-#define AVUTIL_LLS_H
-
-#define MAX_VARS 32
-
-//FIXME avoid direct access to LLSModel from outside
-
-/**
- * Linear least squares model.
- */
-typedef struct LLSModel{
- double covariance[MAX_VARS+1][MAX_VARS+1];
- double coeff[MAX_VARS][MAX_VARS];
- double variance[MAX_VARS];
- int indep_count;
-}LLSModel;
-
-void av_init_lls(LLSModel *m, int indep_count);
-void av_update_lls(LLSModel *m, double *param, double decay);
-void av_solve_lls(LLSModel *m, double threshold, int min_order);
-double av_evaluate_lls(LLSModel *m, double *param, int order);
-
-#endif /* AVUTIL_LLS_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/log.c b/src/thirdparty/ffmpeg/libavutil/log.c
deleted file mode 100644
index 98f2af912..000000000
--- a/src/thirdparty/ffmpeg/libavutil/log.c
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * log functions
- * Copyright (c) 2003 Michel Bardiaux
- *
- * 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
- * logging functions
- */
-
-#include "config.h"
-
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#if HAVE_IO_H
-#include <io.h>
-#endif
-#include <stdlib.h>
-#include "avutil.h"
-#include "common.h"
-#include "log.h"
-
-#define LINE_SZ 1024
-
-static int av_log_level = AV_LOG_INFO;
-static int flags;
-
-#if HAVE_SETCONSOLETEXTATTRIBUTE
-#include <windows.h>
-static const uint8_t color[16 + AV_CLASS_CATEGORY_NB] = {
- [AV_LOG_PANIC /8] = 12,
- [AV_LOG_FATAL /8] = 12,
- [AV_LOG_ERROR /8] = 12,
- [AV_LOG_WARNING/8] = 14,
- [AV_LOG_INFO /8] = 7,
- [AV_LOG_VERBOSE/8] = 10,
- [AV_LOG_DEBUG /8] = 10,
- [16+AV_CLASS_CATEGORY_NA ] = 7,
- [16+AV_CLASS_CATEGORY_INPUT ] = 13,
- [16+AV_CLASS_CATEGORY_OUTPUT ] = 5,
- [16+AV_CLASS_CATEGORY_MUXER ] = 13,
- [16+AV_CLASS_CATEGORY_DEMUXER ] = 5,
- [16+AV_CLASS_CATEGORY_ENCODER ] = 11,
- [16+AV_CLASS_CATEGORY_DECODER ] = 3,
- [16+AV_CLASS_CATEGORY_FILTER ] = 10,
- [16+AV_CLASS_CATEGORY_BITSTREAM_FILTER] = 9,
- [16+AV_CLASS_CATEGORY_SWSCALER ] = 7,
- [16+AV_CLASS_CATEGORY_SWRESAMPLER ] = 7,
-};
-
-static int16_t background, attr_orig;
-static HANDLE con;
-#define set_color(x) SetConsoleTextAttribute(con, background | color[x])
-#define set_256color set_color
-#define reset_color() SetConsoleTextAttribute(con, attr_orig)
-#else
-
-static const uint32_t color[16 + AV_CLASS_CATEGORY_NB] = {
- [AV_LOG_PANIC /8] = 52 << 16 | 196 << 8 | 0x41,
- [AV_LOG_FATAL /8] = 208 << 8 | 0x41,
- [AV_LOG_ERROR /8] = 196 << 8 | 0x11,
- [AV_LOG_WARNING/8] = 226 << 8 | 0x03,
- [AV_LOG_INFO /8] = 253 << 8 | 0x09,
- [AV_LOG_VERBOSE/8] = 40 << 8 | 0x02,
- [AV_LOG_DEBUG /8] = 34 << 8 | 0x02,
- [16+AV_CLASS_CATEGORY_NA ] = 250 << 8 | 0x09,
- [16+AV_CLASS_CATEGORY_INPUT ] = 219 << 8 | 0x15,
- [16+AV_CLASS_CATEGORY_OUTPUT ] = 201 << 8 | 0x05,
- [16+AV_CLASS_CATEGORY_MUXER ] = 213 << 8 | 0x15,
- [16+AV_CLASS_CATEGORY_DEMUXER ] = 207 << 8 | 0x05,
- [16+AV_CLASS_CATEGORY_ENCODER ] = 51 << 8 | 0x16,
- [16+AV_CLASS_CATEGORY_DECODER ] = 39 << 8 | 0x06,
- [16+AV_CLASS_CATEGORY_FILTER ] = 155 << 8 | 0x12,
- [16+AV_CLASS_CATEGORY_BITSTREAM_FILTER] = 192 << 8 | 0x14,
- [16+AV_CLASS_CATEGORY_SWSCALER ] = 153 << 8 | 0x14,
- [16+AV_CLASS_CATEGORY_SWRESAMPLER ] = 147 << 8 | 0x14,
-};
-
-#define set_color(x) fprintf(stderr, "\033[%d;3%dm", (color[x] >> 4) & 15, color[x] & 15)
-#define set_256color(x) fprintf(stderr, "\033[48;5;%dm\033[38;5;%dm", (color[x] >> 16) & 0xff, (color[x] >> 8) & 0xff)
-#define reset_color() fprintf(stderr, "\033[0m")
-#endif
-static int use_color = -1;
-
-static void colored_fputs(int level, const char *str)
-{
- if (use_color < 0) {
-#if HAVE_SETCONSOLETEXTATTRIBUTE
- CONSOLE_SCREEN_BUFFER_INFO con_info;
- con = GetStdHandle(STD_ERROR_HANDLE);
- use_color = (con != INVALID_HANDLE_VALUE) && !getenv("NO_COLOR") &&
- !getenv("AV_LOG_FORCE_NOCOLOR");
- if (use_color) {
- GetConsoleScreenBufferInfo(con, &con_info);
- attr_orig = con_info.wAttributes;
- background = attr_orig & 0xF0;
- }
-#elif HAVE_ISATTY
- use_color = !getenv("NO_COLOR") && !getenv("AV_LOG_FORCE_NOCOLOR") &&
- (getenv("TERM") && isatty(2) ||
- getenv("AV_LOG_FORCE_COLOR"));
- if (getenv("AV_LOG_FORCE_256COLOR"))
- use_color *= 256;
-#else
- use_color = getenv("AV_LOG_FORCE_COLOR") && !getenv("NO_COLOR") &&
- !getenv("AV_LOG_FORCE_NOCOLOR");
-#endif
- }
-
- if (use_color == 1) {
- set_color(level);
- } else if (use_color == 256)
- set_256color(level);
- fputs(str, stderr);
- if (use_color) {
- reset_color();
- }
-}
-
-const char *av_default_item_name(void *ptr)
-{
- return (*(AVClass **) ptr)->class_name;
-}
-
-AVClassCategory av_default_get_category(void *ptr)
-{
- return (*(AVClass **) ptr)->category;
-}
-
-static void sanitize(uint8_t *line){
- while(*line){
- if(*line < 0x08 || (*line > 0x0D && *line < 0x20))
- *line='?';
- line++;
- }
-}
-
-static int get_category(void *ptr){
- AVClass *avc = *(AVClass **) ptr;
- if( !avc
- || (avc->version&0xFF)<100
- || avc->version < (51 << 16 | 59 << 8)
- || avc->category >= AV_CLASS_CATEGORY_NB) return AV_CLASS_CATEGORY_NA + 16;
-
- if(avc->get_category)
- return avc->get_category(ptr) + 16;
-
- return avc->category + 16;
-}
-
-static void format_line(void *ptr, int level, const char *fmt, va_list vl,
- char part[3][LINE_SZ], int part_size, int *print_prefix, int type[2])
-{
- AVClass* avc = ptr ? *(AVClass **) ptr : NULL;
- part[0][0] = part[1][0] = part[2][0] = 0;
- if(type) type[0] = type[1] = AV_CLASS_CATEGORY_NA + 16;
- if (*print_prefix && avc) {
- if (avc->parent_log_context_offset) {
- AVClass** parent = *(AVClass ***) (((uint8_t *) ptr) +
- avc->parent_log_context_offset);
- if (parent && *parent) {
- snprintf(part[0], part_size, "[%s @ %p] ",
- (*parent)->item_name(parent), parent);
- if(type) type[0] = get_category(((uint8_t *) ptr) + avc->parent_log_context_offset);
- }
- }
- snprintf(part[1], part_size, "[%s @ %p] ",
- avc->item_name(ptr), ptr);
- if(type) type[1] = get_category(ptr);
- }
-
- vsnprintf(part[2], part_size, fmt, vl);
-
- *print_prefix = strlen(part[2]) && part[2][strlen(part[2]) - 1] == '\n';
-}
-
-void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl,
- char *line, int line_size, int *print_prefix)
-{
- char part[3][LINE_SZ];
- format_line(ptr, level, fmt, vl, part, sizeof(part[0]), print_prefix, NULL);
- snprintf(line, line_size, "%s%s%s", part[0], part[1], part[2]);
-}
-
-void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
-{
- static int print_prefix = 1;
- static int count;
- static char prev[LINE_SZ];
- char part[3][LINE_SZ];
- char line[LINE_SZ];
- static int is_atty;
- int type[2];
-
- if (level > av_log_level)
- return;
- format_line(ptr, level, fmt, vl, part, sizeof(part[0]), &print_prefix, type);
- snprintf(line, sizeof(line), "%s%s%s", part[0], part[1], part[2]);
-
-#if HAVE_ISATTY
- if (!is_atty)
- is_atty = isatty(2) ? 1 : -1;
-#endif
-
- if (print_prefix && (flags & AV_LOG_SKIP_REPEATED) && !strcmp(line, prev)){
- count++;
- if (is_atty == 1)
- fprintf(stderr, " Last message repeated %d times\r", count);
- return;
- }
- if (count > 0) {
- fprintf(stderr, " Last message repeated %d times\n", count);
- count = 0;
- }
- strcpy(prev, line);
- sanitize(part[0]);
- colored_fputs(type[0], part[0]);
- sanitize(part[1]);
- colored_fputs(type[1], part[1]);
- sanitize(part[2]);
- colored_fputs(av_clip(level >> 3, 0, 6), part[2]);
-}
-
-static void (*av_log_callback)(void*, int, const char*, va_list) =
- av_log_default_callback;
-
-void av_log(void* avcl, int level, const char *fmt, ...)
-{
- AVClass* avc = avcl ? *(AVClass **) avcl : NULL;
- va_list vl;
- va_start(vl, fmt);
- if (avc && avc->version >= (50 << 16 | 15 << 8 | 2) &&
- avc->log_level_offset_offset && level >= AV_LOG_FATAL)
- level += *(int *) (((uint8_t *) avcl) + avc->log_level_offset_offset);
- av_vlog(avcl, level, fmt, vl);
- va_end(vl);
-}
-
-void av_vlog(void* avcl, int level, const char *fmt, va_list vl)
-{
- if(av_log_callback)
- av_log_callback(avcl, level, fmt, vl);
-}
-
-int av_log_get_level(void)
-{
- return av_log_level;
-}
-
-void av_log_set_level(int level)
-{
- av_log_level = level;
-}
-
-void av_log_set_flags(int arg)
-{
- flags = arg;
-}
-
-void av_log_set_callback(void (*callback)(void*, int, const char*, va_list))
-{
- av_log_callback = callback;
-}
diff --git a/src/thirdparty/ffmpeg/libavutil/log.h b/src/thirdparty/ffmpeg/libavutil/log.h
deleted file mode 100644
index c534da441..000000000
--- a/src/thirdparty/ffmpeg/libavutil/log.h
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * copyright (c) 2006 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
- */
-
-#ifndef AVUTIL_LOG_H
-#define AVUTIL_LOG_H
-
-#include <stdarg.h>
-#include "avutil.h"
-#include "attributes.h"
-
-typedef enum {
- AV_CLASS_CATEGORY_NA = 0,
- AV_CLASS_CATEGORY_INPUT,
- AV_CLASS_CATEGORY_OUTPUT,
- AV_CLASS_CATEGORY_MUXER,
- AV_CLASS_CATEGORY_DEMUXER,
- AV_CLASS_CATEGORY_ENCODER,
- AV_CLASS_CATEGORY_DECODER,
- AV_CLASS_CATEGORY_FILTER,
- AV_CLASS_CATEGORY_BITSTREAM_FILTER,
- AV_CLASS_CATEGORY_SWSCALER,
- AV_CLASS_CATEGORY_SWRESAMPLER,
- AV_CLASS_CATEGORY_NB, ///< not part of ABI/API
-}AVClassCategory;
-
-struct AVOptionRanges;
-
-/**
- * Describe the class of an AVClass context structure. That is an
- * arbitrary struct of which the first field is a pointer to an
- * AVClass struct (e.g. AVCodecContext, AVFormatContext etc.).
- */
-typedef struct AVClass {
- /**
- * The name of the class; usually it is the same name as the
- * context structure type to which the AVClass is associated.
- */
- const char* class_name;
-
- /**
- * A pointer to a function which returns the name of a context
- * instance ctx associated with the class.
- */
- const char* (*item_name)(void* ctx);
-
- /**
- * a pointer to the first option specified in the class if any or NULL
- *
- * @see av_set_default_options()
- */
- const struct AVOption *option;
-
- /**
- * LIBAVUTIL_VERSION with which this structure was created.
- * This is used to allow fields to be added without requiring major
- * version bumps everywhere.
- */
-
- int version;
-
- /**
- * Offset in the structure where log_level_offset is stored.
- * 0 means there is no such variable
- */
- int log_level_offset_offset;
-
- /**
- * Offset in the structure where a pointer to the parent context for
- * logging is stored. For example a decoder could pass its AVCodecContext
- * to eval as such a parent context, which an av_log() implementation
- * could then leverage to display the parent context.
- * The offset can be NULL.
- */
- int parent_log_context_offset;
-
- /**
- * Return next AVOptions-enabled child or NULL
- */
- void* (*child_next)(void *obj, void *prev);
-
- /**
- * Return an AVClass corresponding to the next potential
- * AVOptions-enabled child.
- *
- * The difference between child_next and this is that
- * child_next iterates over _already existing_ objects, while
- * child_class_next iterates over _all possible_ children.
- */
- const struct AVClass* (*child_class_next)(const struct AVClass *prev);
-
- /**
- * Category used for visualization (like color)
- * This is only set if the category is equal for all objects using this class.
- * available since version (51 << 16 | 56 << 8 | 100)
- */
- AVClassCategory category;
-
- /**
- * Callback to return the category.
- * available since version (51 << 16 | 59 << 8 | 100)
- */
- AVClassCategory (*get_category)(void* ctx);
-
- /**
- * Callback to return the supported/allowed ranges.
- * available since version (52.12)
- */
- int (*query_ranges)(struct AVOptionRanges **, void *obj, const char *key, int flags);
-} AVClass;
-
-/* av_log API */
-
-#define AV_LOG_QUIET -8
-
-/**
- * Something went really wrong and we will crash now.
- */
-#define AV_LOG_PANIC 0
-
-/**
- * Something went wrong and recovery is not possible.
- * For example, no header was found for a format which depends
- * on headers or an illegal combination of parameters is used.
- */
-#define AV_LOG_FATAL 8
-
-/**
- * Something went wrong and cannot losslessly be recovered.
- * However, not all future data is affected.
- */
-#define AV_LOG_ERROR 16
-
-/**
- * Something somehow does not look correct. This may or may not
- * lead to problems. An example would be the use of '-vstrict -2'.
- */
-#define AV_LOG_WARNING 24
-
-#define AV_LOG_INFO 32
-#define AV_LOG_VERBOSE 40
-
-/**
- * Stuff which is only useful for libav* developers.
- */
-#define AV_LOG_DEBUG 48
-
-#define AV_LOG_MAX_OFFSET (AV_LOG_DEBUG - AV_LOG_QUIET)
-
-/**
- * Send the specified message to the log if the level is less than or equal
- * to the current av_log_level. By default, all logging messages are sent to
- * stderr. This behavior can be altered by setting a different av_vlog callback
- * function.
- *
- * @param avcl A pointer to an arbitrary struct of which the first field is a
- * pointer to an AVClass struct.
- * @param level The importance level of the message, lower values signifying
- * higher importance.
- * @param fmt The format string (printf-compatible) that specifies how
- * subsequent arguments are converted to output.
- * @see av_vlog
- */
-void av_log(void *avcl, int level, const char *fmt, ...) av_printf_format(3, 4);
-
-void av_vlog(void *avcl, int level, const char *fmt, va_list);
-int av_log_get_level(void);
-void av_log_set_level(int);
-void av_log_set_callback(void (*)(void*, int, const char*, va_list));
-void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl);
-const char* av_default_item_name(void* ctx);
-AVClassCategory av_default_get_category(void *ptr);
-
-/**
- * Format a line of log the same way as the default callback.
- * @param line buffer to receive the formated line
- * @param line_size size of the buffer
- * @param print_prefix used to store whether the prefix must be printed;
- * must point to a persistent integer initially set to 1
- */
-void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl,
- char *line, int line_size, int *print_prefix);
-
-/**
- * av_dlog macros
- * Useful to print debug messages that shouldn't get compiled in normally.
- */
-
-#ifdef DEBUG
-# define av_dlog(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__)
-#else
-# define av_dlog(pctx, ...) do { if (0) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__); } while (0)
-#endif
-
-/**
- * Skip repeated messages, this requires the user app to use av_log() instead of
- * (f)printf as the 2 would otherwise interfere and lead to
- * "Last message repeated x times" messages below (f)printf messages with some
- * bad luck.
- * Also to receive the last, "last repeated" line if any, the user app must
- * call av_log(NULL, AV_LOG_QUIET, "%s", ""); at the end
- */
-#define AV_LOG_SKIP_REPEATED 1
-void av_log_set_flags(int arg);
-
-#endif /* AVUTIL_LOG_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/log2_tab.c b/src/thirdparty/ffmpeg/libavutil/log2_tab.c
deleted file mode 100644
index 0dbf07d74..000000000
--- a/src/thirdparty/ffmpeg/libavutil/log2_tab.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2003-2012 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
- */
-
-#include <stdint.h>
-
-const uint8_t ff_log2_tab[256]={
- 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
- 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
- 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
- 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
- 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,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,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,7,7,7,7,7,7,7,7
-};
diff --git a/src/thirdparty/ffmpeg/libavutil/lzo.c b/src/thirdparty/ffmpeg/libavutil/lzo.c
deleted file mode 100644
index 89e801821..000000000
--- a/src/thirdparty/ffmpeg/libavutil/lzo.c
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * LZO 1x decompression
- * Copyright (c) 2006 Reimar Doeffinger
- *
- * 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 <string.h>
-
-#include "avutil.h"
-#include "common.h"
-#include "intreadwrite.h"
-#include "lzo.h"
-
-/// Define if we may write up to 12 bytes beyond the output buffer.
-#define OUTBUF_PADDED 1
-/// Define if we may read up to 8 bytes beyond the input buffer.
-#define INBUF_PADDED 1
-
-typedef struct LZOContext {
- const uint8_t *in, *in_end;
- uint8_t *out_start, *out, *out_end;
- int error;
-} LZOContext;
-
-/**
- * @brief Reads one byte from the input buffer, avoiding an overrun.
- * @return byte read
- */
-static inline int get_byte(LZOContext *c)
-{
- if (c->in < c->in_end)
- return *c->in++;
- c->error |= AV_LZO_INPUT_DEPLETED;
- return 1;
-}
-
-#ifdef INBUF_PADDED
-#define GETB(c) (*(c).in++)
-#else
-#define GETB(c) get_byte(&(c))
-#endif
-
-/**
- * @brief Decodes a length value in the coding used by lzo.
- * @param x previous byte value
- * @param mask bits used from x
- * @return decoded length value
- */
-static inline int get_len(LZOContext *c, int x, int mask)
-{
- int cnt = x & mask;
- if (!cnt) {
- while (!(x = get_byte(c)))
- cnt += 255;
- cnt += mask + x;
- }
- return cnt;
-}
-
-/**
- * @brief Copies bytes from input to output buffer with checking.
- * @param cnt number of bytes to copy, must be >= 0
- */
-static inline void copy(LZOContext *c, int cnt)
-{
- register const uint8_t *src = c->in;
- register uint8_t *dst = c->out;
- if (cnt > c->in_end - src) {
- cnt = FFMAX(c->in_end - src, 0);
- c->error |= AV_LZO_INPUT_DEPLETED;
- }
- if (cnt > c->out_end - dst) {
- cnt = FFMAX(c->out_end - dst, 0);
- c->error |= AV_LZO_OUTPUT_FULL;
- }
-#if defined(INBUF_PADDED) && defined(OUTBUF_PADDED)
- AV_COPY32U(dst, src);
- src += 4;
- dst += 4;
- cnt -= 4;
- if (cnt > 0)
-#endif
- memcpy(dst, src, cnt);
- c->in = src + cnt;
- c->out = dst + cnt;
-}
-
-/**
- * @brief Copies previously decoded bytes to current position.
- * @param back how many bytes back we start, must be > 0
- * @param cnt number of bytes to copy, must be >= 0
- *
- * cnt > back is valid, this will copy the bytes we just copied,
- * thus creating a repeating pattern with a period length of back.
- */
-static inline void copy_backptr(LZOContext *c, int back, int cnt)
-{
- register const uint8_t *src = &c->out[-back];
- register uint8_t *dst = c->out;
- if (src < c->out_start || src > dst) {
- c->error |= AV_LZO_INVALID_BACKPTR;
- return;
- }
- if (cnt > c->out_end - dst) {
- cnt = FFMAX(c->out_end - dst, 0);
- c->error |= AV_LZO_OUTPUT_FULL;
- }
- av_memcpy_backptr(dst, back, cnt);
- c->out = dst + cnt;
-}
-
-int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen)
-{
- int state = 0;
- int x;
- LZOContext c;
- if (*outlen <= 0 || *inlen <= 0) {
- int res = 0;
- if (*outlen <= 0)
- res |= AV_LZO_OUTPUT_FULL;
- if (*inlen <= 0)
- res |= AV_LZO_INPUT_DEPLETED;
- return res;
- }
- c.in = in;
- c.in_end = (const uint8_t *)in + *inlen;
- c.out = c.out_start = out;
- c.out_end = (uint8_t *)out + *outlen;
- c.error = 0;
- x = GETB(c);
- if (x > 17) {
- copy(&c, x - 17);
- x = GETB(c);
- if (x < 16)
- c.error |= AV_LZO_ERROR;
- }
- if (c.in > c.in_end)
- c.error |= AV_LZO_INPUT_DEPLETED;
- while (!c.error) {
- int cnt, back;
- if (x > 15) {
- if (x > 63) {
- cnt = (x >> 5) - 1;
- back = (GETB(c) << 3) + ((x >> 2) & 7) + 1;
- } else if (x > 31) {
- cnt = get_len(&c, x, 31);
- x = GETB(c);
- back = (GETB(c) << 6) + (x >> 2) + 1;
- } else {
- cnt = get_len(&c, x, 7);
- back = (1 << 14) + ((x & 8) << 11);
- x = GETB(c);
- back += (GETB(c) << 6) + (x >> 2);
- if (back == (1 << 14)) {
- if (cnt != 1)
- c.error |= AV_LZO_ERROR;
- break;
- }
- }
- } else if (!state) {
- cnt = get_len(&c, x, 15);
- copy(&c, cnt + 3);
- x = GETB(c);
- if (x > 15)
- continue;
- cnt = 1;
- back = (1 << 11) + (GETB(c) << 2) + (x >> 2) + 1;
- } else {
- cnt = 0;
- back = (GETB(c) << 2) + (x >> 2) + 1;
- }
- copy_backptr(&c, back, cnt + 2);
- state =
- cnt = x & 3;
- copy(&c, cnt);
- x = GETB(c);
- }
- *inlen = c.in_end - c.in;
- if (c.in > c.in_end)
- *inlen = 0;
- *outlen = c.out_end - c.out;
- return c.error;
-}
-
-#ifdef TEST
-#include <stdio.h>
-#include <lzo/lzo1x.h>
-#include "log.h"
-#define MAXSZ (10*1024*1024)
-
-/* Define one of these to 1 if you wish to benchmark liblzo
- * instead of our native implementation. */
-#define BENCHMARK_LIBLZO_SAFE 0
-#define BENCHMARK_LIBLZO_UNSAFE 0
-
-int main(int argc, char *argv[]) {
- FILE *in = fopen(argv[1], "rb");
- uint8_t *orig = av_malloc(MAXSZ + 16);
- uint8_t *comp = av_malloc(2*MAXSZ + 16);
- uint8_t *decomp = av_malloc(MAXSZ + 16);
- size_t s = fread(orig, 1, MAXSZ, in);
- lzo_uint clen = 0;
- long tmp[LZO1X_MEM_COMPRESS];
- int inlen, outlen;
- int i;
- av_log_set_level(AV_LOG_DEBUG);
- lzo1x_999_compress(orig, s, comp, &clen, tmp);
- for (i = 0; i < 300; i++) {
-START_TIMER
- inlen = clen; outlen = MAXSZ;
-#if BENCHMARK_LIBLZO_SAFE
- if (lzo1x_decompress_safe(comp, inlen, decomp, &outlen, NULL))
-#elif BENCHMARK_LIBLZO_UNSAFE
- if (lzo1x_decompress(comp, inlen, decomp, &outlen, NULL))
-#else
- if (av_lzo1x_decode(decomp, &outlen, comp, &inlen))
-#endif
- av_log(NULL, AV_LOG_ERROR, "decompression error\n");
-STOP_TIMER("lzod")
- }
- if (memcmp(orig, decomp, s))
- av_log(NULL, AV_LOG_ERROR, "decompression incorrect\n");
- else
- av_log(NULL, AV_LOG_ERROR, "decompression OK\n");
- return 0;
-}
-#endif
diff --git a/src/thirdparty/ffmpeg/libavutil/lzo.h b/src/thirdparty/ffmpeg/libavutil/lzo.h
deleted file mode 100644
index 1db7d0940..000000000
--- a/src/thirdparty/ffmpeg/libavutil/lzo.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * LZO 1x decompression
- * copyright (c) 2006 Reimar Doeffinger
- *
- * 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 AVUTIL_LZO_H
-#define AVUTIL_LZO_H
-
-/**
- * @defgroup lavu_lzo LZO
- * @ingroup lavu_crypto
- *
- * @{
- */
-
-#include <stdint.h>
-
-/** @name Error flags returned by av_lzo1x_decode
- * @{ */
-/// end of the input buffer reached before decoding finished
-#define AV_LZO_INPUT_DEPLETED 1
-/// decoded data did not fit into output buffer
-#define AV_LZO_OUTPUT_FULL 2
-/// a reference to previously decoded data was wrong
-#define AV_LZO_INVALID_BACKPTR 4
-/// a non-specific error in the compressed bitstream
-#define AV_LZO_ERROR 8
-/** @} */
-
-#define AV_LZO_INPUT_PADDING 8
-#define AV_LZO_OUTPUT_PADDING 12
-
-/**
- * @brief Decodes LZO 1x compressed data.
- * @param out output buffer
- * @param outlen size of output buffer, number of bytes left are returned here
- * @param in input buffer
- * @param inlen size of input buffer, number of bytes left are returned here
- * @return 0 on success, otherwise a combination of the error flags above
- *
- * Make sure all buffers are appropriately padded, in must provide
- * AV_LZO_INPUT_PADDING, out must provide AV_LZO_OUTPUT_PADDING additional bytes.
- */
-int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen);
-
-/**
- * @}
- */
-
-#endif /* AVUTIL_LZO_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/mathematics.c b/src/thirdparty/ffmpeg/libavutil/mathematics.c
deleted file mode 100644
index 13d802df0..000000000
--- a/src/thirdparty/ffmpeg/libavutil/mathematics.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (c) 2005-2012 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
- * miscellaneous math routines and tables
- */
-
-#include <stdint.h>
-#include <limits.h>
-
-#include "mathematics.h"
-#include "libavutil/common.h"
-#include "avassert.h"
-#include "version.h"
-
-#if FF_API_AV_REVERSE
-const uint8_t av_reverse[256]={
-0x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50,0xD0,0x30,0xB0,0x70,0xF0,
-0x08,0x88,0x48,0xC8,0x28,0xA8,0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8,
-0x04,0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,0x34,0xB4,0x74,0xF4,
-0x0C,0x8C,0x4C,0xCC,0x2C,0xAC,0x6C,0xEC,0x1C,0x9C,0x5C,0xDC,0x3C,0xBC,0x7C,0xFC,
-0x02,0x82,0x42,0xC2,0x22,0xA2,0x62,0xE2,0x12,0x92,0x52,0xD2,0x32,0xB2,0x72,0xF2,
-0x0A,0x8A,0x4A,0xCA,0x2A,0xAA,0x6A,0xEA,0x1A,0x9A,0x5A,0xDA,0x3A,0xBA,0x7A,0xFA,
-0x06,0x86,0x46,0xC6,0x26,0xA6,0x66,0xE6,0x16,0x96,0x56,0xD6,0x36,0xB6,0x76,0xF6,
-0x0E,0x8E,0x4E,0xCE,0x2E,0xAE,0x6E,0xEE,0x1E,0x9E,0x5E,0xDE,0x3E,0xBE,0x7E,0xFE,
-0x01,0x81,0x41,0xC1,0x21,0xA1,0x61,0xE1,0x11,0x91,0x51,0xD1,0x31,0xB1,0x71,0xF1,
-0x09,0x89,0x49,0xC9,0x29,0xA9,0x69,0xE9,0x19,0x99,0x59,0xD9,0x39,0xB9,0x79,0xF9,
-0x05,0x85,0x45,0xC5,0x25,0xA5,0x65,0xE5,0x15,0x95,0x55,0xD5,0x35,0xB5,0x75,0xF5,
-0x0D,0x8D,0x4D,0xCD,0x2D,0xAD,0x6D,0xED,0x1D,0x9D,0x5D,0xDD,0x3D,0xBD,0x7D,0xFD,
-0x03,0x83,0x43,0xC3,0x23,0xA3,0x63,0xE3,0x13,0x93,0x53,0xD3,0x33,0xB3,0x73,0xF3,
-0x0B,0x8B,0x4B,0xCB,0x2B,0xAB,0x6B,0xEB,0x1B,0x9B,0x5B,0xDB,0x3B,0xBB,0x7B,0xFB,
-0x07,0x87,0x47,0xC7,0x27,0xA7,0x67,0xE7,0x17,0x97,0x57,0xD7,0x37,0xB7,0x77,0xF7,
-0x0F,0x8F,0x4F,0xCF,0x2F,0xAF,0x6F,0xEF,0x1F,0x9F,0x5F,0xDF,0x3F,0xBF,0x7F,0xFF,
-};
-#endif
-
-int64_t av_gcd(int64_t a, int64_t b){
- if(b) return av_gcd(b, a%b);
- else return a;
-}
-
-int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd){
- int64_t r=0;
- av_assert2(c > 0);
- av_assert2(b >=0);
- av_assert2((unsigned)(rnd&~AV_ROUND_PASS_MINMAX)<=5 && (rnd&~AV_ROUND_PASS_MINMAX)!=4);
-
- if (rnd & AV_ROUND_PASS_MINMAX) {
- if (a == INT64_MIN || a == INT64_MAX)
- return a;
- rnd -= AV_ROUND_PASS_MINMAX;
- }
-
- if(a<0 && a != INT64_MIN) return -av_rescale_rnd(-a, b, c, rnd ^ ((rnd>>1)&1));
-
- if(rnd==AV_ROUND_NEAR_INF) r= c/2;
- else if(rnd&1) r= c-1;
-
- if(b<=INT_MAX && c<=INT_MAX){
- if(a<=INT_MAX)
- return (a * b + r)/c;
- else
- return a/c*b + (a%c*b + r)/c;
- }else{
-#if 1
- uint64_t a0= a&0xFFFFFFFF;
- uint64_t a1= a>>32;
- uint64_t b0= b&0xFFFFFFFF;
- uint64_t b1= b>>32;
- uint64_t t1= a0*b1 + a1*b0;
- uint64_t t1a= t1<<32;
- int i;
-
- a0 = a0*b0 + t1a;
- a1 = a1*b1 + (t1>>32) + (a0<t1a);
- a0 += r;
- a1 += a0<r;
-
- for(i=63; i>=0; i--){
-// int o= a1 & 0x8000000000000000ULL;
- a1+= a1 + ((a0>>i)&1);
- t1+=t1;
- if(/*o || */c <= a1){
- a1 -= c;
- t1++;
- }
- }
- return t1;
- }
-#else
- AVInteger ai;
- ai= av_mul_i(av_int2i(a), av_int2i(b));
- ai= av_add_i(ai, av_int2i(r));
-
- return av_i2int(av_div_i(ai, av_int2i(c)));
- }
-#endif
-}
-
-int64_t av_rescale(int64_t a, int64_t b, int64_t c){
- return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF);
-}
-
-int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq,
- enum AVRounding rnd)
-{
- int64_t b= bq.num * (int64_t)cq.den;
- int64_t c= cq.num * (int64_t)bq.den;
- return av_rescale_rnd(a, b, c, rnd);
-}
-
-int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
-{
- return av_rescale_q_rnd(a, bq, cq, AV_ROUND_NEAR_INF);
-}
-
-int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b){
- int64_t a= tb_a.num * (int64_t)tb_b.den;
- int64_t b= tb_b.num * (int64_t)tb_a.den;
- if((FFABS(ts_a)|a|FFABS(ts_b)|b)<=INT_MAX)
- return (ts_a*a > ts_b*b) - (ts_a*a < ts_b*b);
- if (av_rescale_rnd(ts_a, a, b, AV_ROUND_DOWN) < ts_b) return -1;
- if (av_rescale_rnd(ts_b, b, a, AV_ROUND_DOWN) < ts_a) return 1;
- return 0;
-}
-
-int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod){
- int64_t c= (a-b) & (mod-1);
- if(c > (mod>>1))
- c-= mod;
- return c;
-}
-
-int64_t av_rescale_delta(AVRational in_tb, int64_t in_ts, AVRational fs_tb, int duration, int64_t *last, AVRational out_tb){
- int64_t a, b, this;
-
- av_assert0(in_ts != AV_NOPTS_VALUE);
- av_assert0(duration >= 0);
-
- if (*last == AV_NOPTS_VALUE || !duration || in_tb.num*(int64_t)out_tb.den <= out_tb.num*(int64_t)in_tb.den) {
-simple_round:
- *last = av_rescale_q(in_ts, in_tb, fs_tb) + duration;
- return av_rescale_q(in_ts, in_tb, out_tb);
- }
-
- a = av_rescale_q_rnd(2*in_ts-1, in_tb, fs_tb, AV_ROUND_DOWN) >>1;
- b = (av_rescale_q_rnd(2*in_ts+1, in_tb, fs_tb, AV_ROUND_UP )+1)>>1;
- if (*last < 2*a - b || *last > 2*b - a)
- goto simple_round;
-
- this = av_clip64(*last, a, b);
- *last = this + duration;
-
- return av_rescale_q(this, fs_tb, out_tb);
-}
diff --git a/src/thirdparty/ffmpeg/libavutil/mathematics.h b/src/thirdparty/ffmpeg/libavutil/mathematics.h
deleted file mode 100644
index da4ad6254..000000000
--- a/src/thirdparty/ffmpeg/libavutil/mathematics.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * copyright (c) 2005-2012 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
- */
-
-#ifndef AVUTIL_MATHEMATICS_H
-#define AVUTIL_MATHEMATICS_H
-
-#include <stdint.h>
-#include <math.h>
-#include "attributes.h"
-#include "rational.h"
-#include "intfloat.h"
-
-#ifndef M_E
-#define M_E 2.7182818284590452354 /* e */
-#endif
-#ifndef M_LN2
-#define M_LN2 0.69314718055994530942 /* log_e 2 */
-#endif
-#ifndef M_LN10
-#define M_LN10 2.30258509299404568402 /* log_e 10 */
-#endif
-#ifndef M_LOG2_10
-#define M_LOG2_10 3.32192809488736234787 /* log_2 10 */
-#endif
-#ifndef M_PHI
-#define M_PHI 1.61803398874989484820 /* phi / golden ratio */
-#endif
-#ifndef M_PI
-#define M_PI 3.14159265358979323846 /* pi */
-#endif
-#ifndef M_SQRT1_2
-#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
-#endif
-#ifndef M_SQRT2
-#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
-#endif
-#ifndef NAN
-#define NAN av_int2float(0x7fc00000)
-#endif
-#ifndef INFINITY
-#define INFINITY av_int2float(0x7f800000)
-#endif
-
-/**
- * @addtogroup lavu_math
- * @{
- */
-
-
-enum AVRounding {
- AV_ROUND_ZERO = 0, ///< Round toward zero.
- AV_ROUND_INF = 1, ///< Round away from zero.
- AV_ROUND_DOWN = 2, ///< Round toward -infinity.
- AV_ROUND_UP = 3, ///< Round toward +infinity.
- AV_ROUND_NEAR_INF = 5, ///< Round to nearest and halfway cases away from zero.
- AV_ROUND_PASS_MINMAX = 8192, ///< Flag to pass INT64_MIN/MAX through instead of rescaling, this avoids special cases for AV_NOPTS_VALUE
-};
-
-/**
- * Return the greatest common divisor of a and b.
- * If both a and b are 0 or either or both are <0 then behavior is
- * undefined.
- */
-int64_t av_const av_gcd(int64_t a, int64_t b);
-
-/**
- * Rescale a 64-bit integer with rounding to nearest.
- * A simple a*b/c isn't possible as it can overflow.
- */
-int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const;
-
-/**
- * Rescale a 64-bit integer with specified rounding.
- * A simple a*b/c isn't possible as it can overflow.
- *
- * @return rescaled value a, or if AV_ROUND_PASS_MINMAX is set and a is
- * INT64_MIN or INT64_MAX then a is passed through unchanged.
- */
-int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding) av_const;
-
-/**
- * Rescale a 64-bit integer by 2 rational numbers.
- */
-int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const;
-
-/**
- * Rescale a 64-bit integer by 2 rational numbers with specified rounding.
- *
- * @return rescaled value a, or if AV_ROUND_PASS_MINMAX is set and a is
- * INT64_MIN or INT64_MAX then a is passed through unchanged.
- */
-int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq,
- enum AVRounding) av_const;
-
-/**
- * Compare 2 timestamps each in its own timebases.
- * The result of the function is undefined if one of the timestamps
- * is outside the int64_t range when represented in the others timebase.
- * @return -1 if ts_a is before ts_b, 1 if ts_a is after ts_b or 0 if they represent the same position
- */
-int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b);
-
-/**
- * Compare 2 integers modulo mod.
- * That is we compare integers a and b for which only the least
- * significant log2(mod) bits are known.
- *
- * @param mod must be a power of 2
- * @return a negative value if a is smaller than b
- * a positive value if a is greater than b
- * 0 if a equals b
- */
-int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod);
-
-/**
- * Rescale a timestamp while preserving known durations.
- *
- * @param in_ts Input timestamp
- * @param in_tb Input timesbase
- * @param fs_tb Duration and *last timebase
- * @param duration duration till the next call
- * @param out_tb Output timesbase
- */
-int64_t av_rescale_delta(AVRational in_tb, int64_t in_ts, AVRational fs_tb, int duration, int64_t *last, AVRational out_tb);
-
-/**
- * @}
- */
-
-#endif /* AVUTIL_MATHEMATICS_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/md5.c b/src/thirdparty/ffmpeg/libavutil/md5.c
deleted file mode 100644
index 4d6db22aa..000000000
--- a/src/thirdparty/ffmpeg/libavutil/md5.c
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (C) 2006 Michael Niedermayer (michaelni@gmx.at)
- * Copyright (C) 2003-2005 by Christopher R. Hertel (crh@ubiqx.mn.org)
- *
- * References:
- * IETF RFC 1321: The MD5 Message-Digest Algorithm
- * Ron Rivest. IETF, April, 1992
- *
- * based on http://ubiqx.org/libcifs/source/Auth/MD5.c
- * from Christopher R. Hertel (crh@ubiqx.mn.org)
- * Simplified, cleaned and IMO redundant comments removed by michael.
- *
- * If you use gcc, then version 4.1 or later and -fomit-frame-pointer is
- * strongly recommended.
- *
- * 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 "bswap.h"
-#include "intreadwrite.h"
-#include "md5.h"
-#include "mem.h"
-
-typedef struct AVMD5{
- uint64_t len;
- uint8_t block[64];
- uint32_t ABCD[4];
-} AVMD5;
-
-const int av_md5_size = sizeof(AVMD5);
-
-struct AVMD5 *av_md5_alloc(void)
-{
- return av_mallocz(sizeof(struct AVMD5));
-}
-
-static const uint8_t S[4][4] = {
- { 7, 12, 17, 22 }, /* round 1 */
- { 5, 9, 14, 20 }, /* round 2 */
- { 4, 11, 16, 23 }, /* round 3 */
- { 6, 10, 15, 21 } /* round 4 */
-};
-
-static const uint32_t T[64] = { // T[i]= fabs(sin(i+1)<<32)
- 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, /* round 1 */
- 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
- 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
- 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
-
- 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, /* round 2 */
- 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
- 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
- 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
-
- 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, /* round 3 */
- 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
- 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05,
- 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
-
- 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, /* round 4 */
- 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
- 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
- 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391,
-};
-
-#define CORE(i, a, b, c, d) do { \
- t = S[i >> 4][i & 3]; \
- a += T[i]; \
- \
- if (i < 32) { \
- if (i < 16) a += (d ^ (b & (c ^ d))) + X[ i & 15]; \
- else a += (c ^ (d & (c ^ b))) + X[(1 + 5*i) & 15]; \
- } else { \
- if (i < 48) a += (b ^ c ^ d) + X[(5 + 3*i) & 15]; \
- else a += (c ^ (b | ~d)) + X[( 7*i) & 15]; \
- } \
- a = b + (a << t | a >> (32 - t)); \
- } while (0)
-
-static void body(uint32_t ABCD[4], uint32_t X[16])
-{
- int i av_unused;
- uint32_t t;
- uint32_t a = ABCD[3];
- uint32_t b = ABCD[2];
- uint32_t c = ABCD[1];
- uint32_t d = ABCD[0];
-
-#if HAVE_BIGENDIAN
- for (i = 0; i < 16; i++)
- X[i] = av_bswap32(X[i]);
-#endif
-
-#if CONFIG_SMALL
- for (i = 0; i < 64; i++) {
- CORE(i, a, b, c, d);
- t = d;
- d = c;
- c = b;
- b = a;
- a = t;
- }
-#else
-#define CORE2(i) \
- CORE( i, a,b,c,d); CORE((i+1),d,a,b,c); \
- CORE((i+2),c,d,a,b); CORE((i+3),b,c,d,a)
-#define CORE4(i) CORE2(i); CORE2((i+4)); CORE2((i+8)); CORE2((i+12))
- CORE4(0); CORE4(16); CORE4(32); CORE4(48);
-#endif
-
- ABCD[0] += d;
- ABCD[1] += c;
- ABCD[2] += b;
- ABCD[3] += a;
-}
-
-void av_md5_init(AVMD5 *ctx)
-{
- ctx->len = 0;
-
- ctx->ABCD[0] = 0x10325476;
- ctx->ABCD[1] = 0x98badcfe;
- ctx->ABCD[2] = 0xefcdab89;
- ctx->ABCD[3] = 0x67452301;
-}
-
-void av_md5_update(AVMD5 *ctx, const uint8_t *src, const int len)
-{
- int i, j;
-
- j = ctx->len & 63;
- ctx->len += len;
-
- for (i = 0; i < len; i++) {
- ctx->block[j++] = src[i];
- if (j == 64) {
- body(ctx->ABCD, (uint32_t *) ctx->block);
- j = 0;
- }
- }
-}
-
-void av_md5_final(AVMD5 *ctx, uint8_t *dst)
-{
- int i;
- uint64_t finalcount = av_le2ne64(ctx->len << 3);
-
- av_md5_update(ctx, "\200", 1);
- while ((ctx->len & 63) != 56)
- av_md5_update(ctx, "", 1);
-
- av_md5_update(ctx, (uint8_t *)&finalcount, 8);
-
- for (i = 0; i < 4; i++)
- AV_WL32(dst + 4*i, ctx->ABCD[3 - i]);
-}
-
-void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len)
-{
- AVMD5 ctx;
-
- av_md5_init(&ctx);
- av_md5_update(&ctx, src, len);
- av_md5_final(&ctx, dst);
-}
-
-#ifdef TEST
-#include <stdio.h>
-
-static void print_md5(uint8_t *md5)
-{
- int i;
- for (i = 0; i < 16; i++)
- printf("%02x", md5[i]);
- printf("\n");
-}
-
-int main(void){
- uint8_t md5val[16];
- int i;
- uint8_t in[1000];
-
- for (i = 0; i < 1000; i++)
- in[i] = i * i;
- av_md5_sum(md5val, in, 1000); print_md5(md5val);
- av_md5_sum(md5val, in, 63); print_md5(md5val);
- av_md5_sum(md5val, in, 64); print_md5(md5val);
- av_md5_sum(md5val, in, 65); print_md5(md5val);
- for (i = 0; i < 1000; i++)
- in[i] = i % 127;
- av_md5_sum(md5val, in, 999); print_md5(md5val);
-
- return 0;
-}
-#endif
diff --git a/src/thirdparty/ffmpeg/libavutil/md5.h b/src/thirdparty/ffmpeg/libavutil/md5.h
deleted file mode 100644
index 4b29e8da7..000000000
--- a/src/thirdparty/ffmpeg/libavutil/md5.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * copyright (c) 2006 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
- */
-
-#ifndef AVUTIL_MD5_H
-#define AVUTIL_MD5_H
-
-#include <stdint.h>
-
-#include "attributes.h"
-#include "version.h"
-
-/**
- * @defgroup lavu_md5 MD5
- * @ingroup lavu_crypto
- * @{
- */
-
-extern const int av_md5_size;
-
-struct AVMD5;
-
-struct AVMD5 *av_md5_alloc(void);
-void av_md5_init(struct AVMD5 *ctx);
-void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, const int len);
-void av_md5_final(struct AVMD5 *ctx, uint8_t *dst);
-void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len);
-
-/**
- * @}
- */
-
-#endif /* AVUTIL_MD5_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/mem.c b/src/thirdparty/ffmpeg/libavutil/mem.c
deleted file mode 100644
index 0968f3cbb..000000000
--- a/src/thirdparty/ffmpeg/libavutil/mem.c
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- * default memory allocator for libavutil
- * Copyright (c) 2002 Fabrice Bellard
- *
- * 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
- * default memory allocator for libavutil
- */
-
-#define _XOPEN_SOURCE 600
-
-#include "config.h"
-
-#include <limits.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#if HAVE_MALLOC_H
-#include <malloc.h>
-#endif
-
-#include "avutil.h"
-#include "intreadwrite.h"
-#include "mem.h"
-
-#ifdef MALLOC_PREFIX
-
-#define malloc AV_JOIN(MALLOC_PREFIX, malloc)
-#define memalign AV_JOIN(MALLOC_PREFIX, memalign)
-#define posix_memalign AV_JOIN(MALLOC_PREFIX, posix_memalign)
-#define realloc AV_JOIN(MALLOC_PREFIX, realloc)
-#define free AV_JOIN(MALLOC_PREFIX, free)
-
-void *malloc(size_t size);
-void *memalign(size_t align, size_t size);
-int posix_memalign(void **ptr, size_t align, size_t size);
-void *realloc(void *ptr, size_t size);
-void free(void *ptr);
-
-#endif /* MALLOC_PREFIX */
-
-#define ALIGN (HAVE_AVX ? 32 : 16)
-
-/* NOTE: if you want to override these functions with your own
- * implementations (not recommended) you have to link libav* as
- * dynamic libraries and remove -Wl,-Bsymbolic from the linker flags.
- * Note that this will cost performance. */
-
-static size_t max_alloc_size= INT_MAX;
-
-void av_max_alloc(size_t max){
- max_alloc_size = max;
-}
-
-void *av_malloc(size_t size)
-{
- void *ptr = NULL;
-#if CONFIG_MEMALIGN_HACK
- long diff;
-#endif
-
- /* let's disallow possible ambiguous cases */
- if (size > (max_alloc_size - 32))
- return NULL;
-
-#if CONFIG_MEMALIGN_HACK
- ptr = malloc(size + ALIGN);
- if (!ptr)
- return ptr;
- diff = ((~(long)ptr)&(ALIGN - 1)) + 1;
- ptr = (char *)ptr + diff;
- ((char *)ptr)[-1] = diff;
-#elif HAVE_POSIX_MEMALIGN
- if (size) //OS X on SDK 10.6 has a broken posix_memalign implementation
- if (posix_memalign(&ptr, ALIGN, size))
- ptr = NULL;
-#elif HAVE_ALIGNED_MALLOC
- //ptr = _aligned_malloc(size, ALIGN);
- ptr = __mingw_aligned_malloc(size, ALIGN); // MPC-HC patch
-#elif HAVE_MEMALIGN
- ptr = memalign(ALIGN, size);
- /* Why 64?
- * Indeed, we should align it:
- * on 4 for 386
- * on 16 for 486
- * on 32 for 586, PPro - K6-III
- * on 64 for K7 (maybe for P3 too).
- * Because L1 and L2 caches are aligned on those values.
- * But I don't want to code such logic here!
- */
- /* Why 32?
- * For AVX ASM. SSE / NEON needs only 16.
- * Why not larger? Because I did not see a difference in benchmarks ...
- */
- /* benchmarks with P3
- * memalign(64) + 1 3071, 3051, 3032
- * memalign(64) + 2 3051, 3032, 3041
- * memalign(64) + 4 2911, 2896, 2915
- * memalign(64) + 8 2545, 2554, 2550
- * memalign(64) + 16 2543, 2572, 2563
- * memalign(64) + 32 2546, 2545, 2571
- * memalign(64) + 64 2570, 2533, 2558
- *
- * BTW, malloc seems to do 8-byte alignment by default here.
- */
-#else
- ptr = malloc(size);
-#endif
- if(!ptr && !size) {
- size = 1;
- ptr= av_malloc(1);
- }
-#if CONFIG_MEMORY_POISONING
- if (ptr)
- memset(ptr, 0x2a, size);
-#endif
- return ptr;
-}
-
-void *av_realloc(void *ptr, size_t size)
-{
-#if CONFIG_MEMALIGN_HACK
- int diff;
-#endif
-
- /* let's disallow possible ambiguous cases */
- if (size > (max_alloc_size - 32))
- return NULL;
-
-#if CONFIG_MEMALIGN_HACK
- //FIXME this isn't aligned correctly, though it probably isn't needed
- if (!ptr)
- return av_malloc(size);
- diff = ((char *)ptr)[-1];
- ptr = realloc((char *)ptr - diff, size + diff);
- if (ptr)
- ptr = (char *)ptr + diff;
- return ptr;
-#elif HAVE_ALIGNED_MALLOC
- //return _aligned_realloc(ptr, size + !size, ALIGN);
- return __mingw_aligned_realloc(ptr, size + !size, ALIGN); // MPC-HC patch
-#else
- return realloc(ptr, size + !size);
-#endif
-}
-
-void *av_realloc_f(void *ptr, size_t nelem, size_t elsize)
-{
- size_t size;
- void *r;
-
- if (av_size_mult(elsize, nelem, &size)) {
- av_free(ptr);
- return NULL;
- }
- r = av_realloc(ptr, size);
- if (!r && size)
- av_free(ptr);
- return r;
-}
-
-void av_free(void *ptr)
-{
-#if CONFIG_MEMALIGN_HACK
- if (ptr)
- free((char *)ptr - ((char *)ptr)[-1]);
-#elif HAVE_ALIGNED_MALLOC
- //_aligned_free(ptr);
- __mingw_aligned_free(ptr); // MPC-HC patch
-#else
- free(ptr);
-#endif
-}
-
-void av_freep(void *arg)
-{
- void **ptr = (void **)arg;
- av_free(*ptr);
- *ptr = NULL;
-}
-
-void *av_mallocz(size_t size)
-{
- void *ptr = av_malloc(size);
- if (ptr)
- memset(ptr, 0, size);
- return ptr;
-}
-
-void *av_calloc(size_t nmemb, size_t size)
-{
- if (size <= 0 || nmemb >= INT_MAX / size)
- return NULL;
- return av_mallocz(nmemb * size);
-}
-
-char *av_strdup(const char *s)
-{
- char *ptr = NULL;
- if (s) {
- int len = strlen(s) + 1;
- ptr = av_malloc(len);
- if (ptr)
- memcpy(ptr, s, len);
- }
- return ptr;
-}
-
-/* add one element to a dynamic array */
-void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem)
-{
- /* see similar ffmpeg.c:grow_array() */
- int nb, nb_alloc;
- intptr_t *tab;
-
- nb = *nb_ptr;
- tab = *(intptr_t**)tab_ptr;
- if ((nb & (nb - 1)) == 0) {
- if (nb == 0)
- nb_alloc = 1;
- else
- nb_alloc = nb * 2;
- tab = av_realloc(tab, nb_alloc * sizeof(intptr_t));
- *(intptr_t**)tab_ptr = tab;
- }
- tab[nb++] = (intptr_t)elem;
- *nb_ptr = nb;
-}
-
-static void fill16(uint8_t *dst, int len)
-{
- uint32_t v = AV_RN16(dst - 2);
-
- v |= v << 16;
-
- while (len >= 4) {
- AV_WN32(dst, v);
- dst += 4;
- len -= 4;
- }
-
- while (len--) {
- *dst = dst[-2];
- dst++;
- }
-}
-
-static void fill24(uint8_t *dst, int len)
-{
-#if HAVE_BIGENDIAN
- uint32_t v = AV_RB24(dst - 3);
- uint32_t a = v << 8 | v >> 16;
- uint32_t b = v << 16 | v >> 8;
- uint32_t c = v << 24 | v;
-#else
- uint32_t v = AV_RL24(dst - 3);
- uint32_t a = v | v << 24;
- uint32_t b = v >> 8 | v << 16;
- uint32_t c = v >> 16 | v << 8;
-#endif
-
- while (len >= 12) {
- AV_WN32(dst, a);
- AV_WN32(dst + 4, b);
- AV_WN32(dst + 8, c);
- dst += 12;
- len -= 12;
- }
-
- if (len >= 4) {
- AV_WN32(dst, a);
- dst += 4;
- len -= 4;
- }
-
- if (len >= 4) {
- AV_WN32(dst, b);
- dst += 4;
- len -= 4;
- }
-
- while (len--) {
- *dst = dst[-3];
- dst++;
- }
-}
-
-static void fill32(uint8_t *dst, int len)
-{
- uint32_t v = AV_RN32(dst - 4);
-
- while (len >= 4) {
- AV_WN32(dst, v);
- dst += 4;
- len -= 4;
- }
-
- while (len--) {
- *dst = dst[-4];
- dst++;
- }
-}
-
-void av_memcpy_backptr(uint8_t *dst, int back, int cnt)
-{
- const uint8_t *src = &dst[-back];
- if (back <= 1) {
- memset(dst, *src, cnt);
- } else if (back == 2) {
- fill16(dst, cnt);
- } else if (back == 3) {
- fill24(dst, cnt);
- } else if (back == 4) {
- fill32(dst, cnt);
- } else {
- if (cnt >= 16) {
- int blocklen = back;
- while (cnt > blocklen) {
- memcpy(dst, src, blocklen);
- dst += blocklen;
- cnt -= blocklen;
- blocklen <<= 1;
- }
- memcpy(dst, src, cnt);
- return;
- }
- if (cnt >= 8) {
- AV_COPY32U(dst, src);
- AV_COPY32U(dst + 4, src + 4);
- src += 8;
- dst += 8;
- cnt -= 8;
- }
- if (cnt >= 4) {
- AV_COPY32U(dst, src);
- src += 4;
- dst += 4;
- cnt -= 4;
- }
- if (cnt >= 2) {
- AV_COPY16U(dst, src);
- src += 2;
- dst += 2;
- cnt -= 2;
- }
- if (cnt)
- *dst = *src;
- }
-}
-
diff --git a/src/thirdparty/ffmpeg/libavutil/mem.h b/src/thirdparty/ffmpeg/libavutil/mem.h
deleted file mode 100644
index 3f235b62f..000000000
--- a/src/thirdparty/ffmpeg/libavutil/mem.h
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * copyright (c) 2006 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
- * memory handling functions
- */
-
-#ifndef AVUTIL_MEM_H
-#define AVUTIL_MEM_H
-
-#include <limits.h>
-#include <stdint.h>
-
-#include "attributes.h"
-#include "error.h"
-#include "avutil.h"
-
-/**
- * @addtogroup lavu_mem
- * @{
- */
-
-
-#if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1110 || defined(__SUNPRO_C)
- #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
- #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v
-#elif defined(__TI_COMPILER_VERSION__)
- #define DECLARE_ALIGNED(n,t,v) \
- AV_PRAGMA(DATA_ALIGN(v,n)) \
- t __attribute__((aligned(n))) v
- #define DECLARE_ASM_CONST(n,t,v) \
- AV_PRAGMA(DATA_ALIGN(v,n)) \
- static const t __attribute__((aligned(n))) v
-#elif defined(__GNUC__)
- #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
- #define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (n))) v
-#elif defined(_MSC_VER)
- #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v
- #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v
-#else
- #define DECLARE_ALIGNED(n,t,v) t v
- #define DECLARE_ASM_CONST(n,t,v) static const t v
-#endif
-
-#if AV_GCC_VERSION_AT_LEAST(3,1)
- #define av_malloc_attrib __attribute__((__malloc__))
-#else
- #define av_malloc_attrib
-#endif
-
-#if AV_GCC_VERSION_AT_LEAST(4,3)
- #define av_alloc_size(...) __attribute__((alloc_size(__VA_ARGS__)))
-#else
- #define av_alloc_size(...)
-#endif
-
-/**
- * Allocate a block of size bytes with alignment suitable for all
- * memory accesses (including vectors if available on the CPU).
- * @param size Size in bytes for the memory block to be allocated.
- * @return Pointer to the allocated block, NULL if the block cannot
- * be allocated.
- * @see av_mallocz()
- */
-void *av_malloc(size_t size) av_malloc_attrib av_alloc_size(1);
-
-/**
- * Helper function to allocate a block of size * nmemb bytes with
- * using av_malloc()
- * @param nmemb Number of elements
- * @param size Size of the single element
- * @return Pointer to the allocated block, NULL if the block cannot
- * be allocated.
- * @see av_malloc()
- */
-av_alloc_size(1, 2) static inline void *av_malloc_array(size_t nmemb, size_t size)
-{
- if (size <= 0 || nmemb >= INT_MAX / size)
- return NULL;
- return av_malloc(nmemb * size);
-}
-
-/**
- * Allocate or reallocate a block of memory.
- * If ptr is NULL and size > 0, allocate a new block. If
- * size is zero, free the memory block pointed to by ptr.
- * @param ptr Pointer to a memory block already allocated with
- * av_malloc(z)() or av_realloc() or NULL.
- * @param size Size in bytes for the memory block to be allocated or
- * reallocated.
- * @return Pointer to a newly reallocated block or NULL if the block
- * cannot be reallocated or the function is used to free the memory block.
- * @see av_fast_realloc()
- */
-void *av_realloc(void *ptr, size_t size) av_alloc_size(2);
-
-/**
- * Allocate or reallocate a block of memory.
- * This function does the same thing as av_realloc, except:
- * - It takes two arguments and checks the result of the multiplication for
- * integer overflow.
- * - It frees the input block in case of failure, thus avoiding the memory
- * leak with the classic "buf = realloc(buf); if (!buf) return -1;".
- */
-void *av_realloc_f(void *ptr, size_t nelem, size_t elsize);
-
-/**
- * Free a memory block which has been allocated with av_malloc(z)() or
- * av_realloc().
- * @param ptr Pointer to the memory block which should be freed.
- * @note ptr = NULL is explicitly allowed.
- * @note It is recommended that you use av_freep() instead.
- * @see av_freep()
- */
-void av_free(void *ptr);
-
-/**
- * Allocate a block of size bytes with alignment suitable for all
- * memory accesses (including vectors if available on the CPU) and
- * zero all the bytes of the block.
- * @param size Size in bytes for the memory block to be allocated.
- * @return Pointer to the allocated block, NULL if it cannot be allocated.
- * @see av_malloc()
- */
-void *av_mallocz(size_t size) av_malloc_attrib av_alloc_size(1);
-
-/**
- * Allocate a block of nmemb * size bytes with alignment suitable for all
- * memory accesses (including vectors if available on the CPU) and
- * zero all the bytes of the block.
- * The allocation will fail if nmemb * size is greater than or equal
- * to INT_MAX.
- * @param nmemb
- * @param size
- * @return Pointer to the allocated block, NULL if it cannot be allocated.
- */
-void *av_calloc(size_t nmemb, size_t size) av_malloc_attrib;
-
-/**
- * Helper function to allocate a block of size * nmemb bytes with
- * using av_mallocz()
- * @param nmemb Number of elements
- * @param size Size of the single element
- * @return Pointer to the allocated block, NULL if the block cannot
- * be allocated.
- * @see av_mallocz()
- * @see av_malloc_array()
- */
-av_alloc_size(1, 2) static inline void *av_mallocz_array(size_t nmemb, size_t size)
-{
- if (size <= 0 || nmemb >= INT_MAX / size)
- return NULL;
- return av_mallocz(nmemb * size);
-}
-
-/**
- * Duplicate the string s.
- * @param s string to be duplicated
- * @return Pointer to a newly allocated string containing a
- * copy of s or NULL if the string cannot be allocated.
- */
-char *av_strdup(const char *s) av_malloc_attrib;
-
-/**
- * Free a memory block which has been allocated with av_malloc(z)() or
- * av_realloc() and set the pointer pointing to it to NULL.
- * @param ptr Pointer to the pointer to the memory block which should
- * be freed.
- * @see av_free()
- */
-void av_freep(void *ptr);
-
-/**
- * Add an element to a dynamic array.
- *
- * @param tab_ptr Pointer to the array.
- * @param nb_ptr Pointer to the number of elements in the array.
- * @param elem Element to be added.
- */
-void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem);
-
-/**
- * Multiply two size_t values checking for overflow.
- * @return 0 if success, AVERROR(EINVAL) if overflow.
- */
-static inline int av_size_mult(size_t a, size_t b, size_t *r)
-{
- size_t t = a * b;
- /* Hack inspired from glibc: only try the division if nelem and elsize
- * are both greater than sqrt(SIZE_MAX). */
- if ((a | b) >= ((size_t)1 << (sizeof(size_t) * 4)) && a && t / a != b)
- return AVERROR(EINVAL);
- *r = t;
- return 0;
-}
-
-/**
- * Set the maximum size that may me allocated in one block.
- */
-void av_max_alloc(size_t max);
-
-/**
- * @brief deliberately overlapping memcpy implementation
- * @param dst destination buffer
- * @param back how many bytes back we start (the initial size of the overlapping window), must be > 0
- * @param cnt number of bytes to copy, must be >= 0
- *
- * cnt > back is valid, this will copy the bytes we just copied,
- * thus creating a repeating pattern with a period length of back.
- */
-void av_memcpy_backptr(uint8_t *dst, int back, int cnt);
-
-/**
- * @}
- */
-
-#endif /* AVUTIL_MEM_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/old_pix_fmts.h b/src/thirdparty/ffmpeg/libavutil/old_pix_fmts.h
deleted file mode 100644
index 57b699220..000000000
--- a/src/thirdparty/ffmpeg/libavutil/old_pix_fmts.h
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * copyright (c) 2006-2012 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
- */
-
-#ifndef AVUTIL_OLD_PIX_FMTS_H
-#define AVUTIL_OLD_PIX_FMTS_H
-
-/*
- * This header exists to prevent new pixel formats from being accidentally added
- * to the deprecated list.
- * Do not include it directly. It will be removed on next major bump
- *
- * Do not add new items to this list. Use the AVPixelFormat enum instead.
- */
- PIX_FMT_NONE = AV_PIX_FMT_NONE,
- PIX_FMT_YUV420P, ///< planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
- PIX_FMT_YUYV422, ///< packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
- PIX_FMT_RGB24, ///< packed RGB 8:8:8, 24bpp, RGBRGB...
- PIX_FMT_BGR24, ///< packed RGB 8:8:8, 24bpp, BGRBGR...
- PIX_FMT_YUV422P, ///< planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
- PIX_FMT_YUV444P, ///< planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
- PIX_FMT_YUV410P, ///< planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
- PIX_FMT_YUV411P, ///< planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
- PIX_FMT_GRAY8, ///< Y , 8bpp
- PIX_FMT_MONOWHITE, ///< Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb
- PIX_FMT_MONOBLACK, ///< Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb
- PIX_FMT_PAL8, ///< 8 bit with PIX_FMT_RGB32 palette
- PIX_FMT_YUVJ420P, ///< planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_range
- PIX_FMT_YUVJ422P, ///< planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_range
- PIX_FMT_YUVJ444P, ///< planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_range
- PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing
- PIX_FMT_XVMC_MPEG2_IDCT,
- PIX_FMT_UYVY422, ///< packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
- PIX_FMT_UYYVYY411, ///< packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
- PIX_FMT_BGR8, ///< packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
- PIX_FMT_BGR4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits
- PIX_FMT_BGR4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
- PIX_FMT_RGB8, ///< packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
- PIX_FMT_RGB4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits
- PIX_FMT_RGB4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
- PIX_FMT_NV12, ///< planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V)
- PIX_FMT_NV21, ///< as above, but U and V bytes are swapped
-
- PIX_FMT_ARGB, ///< packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
- PIX_FMT_RGBA, ///< packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
- PIX_FMT_ABGR, ///< packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
- PIX_FMT_BGRA, ///< packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
-
- PIX_FMT_GRAY16BE, ///< Y , 16bpp, big-endian
- PIX_FMT_GRAY16LE, ///< Y , 16bpp, little-endian
- PIX_FMT_YUV440P, ///< planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
- PIX_FMT_YUVJ440P, ///< planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range
- PIX_FMT_YUVA420P, ///< planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
- PIX_FMT_VDPAU_H264,///< H.264 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
- PIX_FMT_VDPAU_MPEG1,///< MPEG-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
- PIX_FMT_VDPAU_MPEG2,///< MPEG-2 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
- PIX_FMT_VDPAU_WMV3,///< WMV3 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
- PIX_FMT_VDPAU_VC1, ///< VC-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
- PIX_FMT_RGB48BE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big-endian
- PIX_FMT_RGB48LE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as little-endian
-
- PIX_FMT_RGB565BE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
- PIX_FMT_RGB565LE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
- PIX_FMT_RGB555BE, ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0
- PIX_FMT_RGB555LE, ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0
-
- PIX_FMT_BGR565BE, ///< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
- PIX_FMT_BGR565LE, ///< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
- PIX_FMT_BGR555BE, ///< packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), big-endian, most significant bit to 1
- PIX_FMT_BGR555LE, ///< packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), little-endian, most significant bit to 1
-
- PIX_FMT_VAAPI_MOCO, ///< HW acceleration through VA API at motion compensation entry-point, Picture.data[3] contains a vaapi_render_state struct which contains macroblocks as well as various fields extracted from headers
- PIX_FMT_VAAPI_IDCT, ///< HW acceleration through VA API at IDCT entry-point, Picture.data[3] contains a vaapi_render_state struct which contains fields extracted from headers
- PIX_FMT_VAAPI_VLD, ///< HW decoding through VA API, Picture.data[3] contains a vaapi_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
-
- PIX_FMT_YUV420P16LE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
- PIX_FMT_YUV420P16BE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
- PIX_FMT_YUV422P16LE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
- PIX_FMT_YUV422P16BE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
- PIX_FMT_YUV444P16LE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
- PIX_FMT_YUV444P16BE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
- PIX_FMT_VDPAU_MPEG4, ///< MPEG4 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
- PIX_FMT_DXVA2_VLD, ///< HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer
-
- PIX_FMT_RGB444LE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0
- PIX_FMT_RGB444BE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-endian, most significant bits to 0
- PIX_FMT_BGR444LE, ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), little-endian, most significant bits to 1
- PIX_FMT_BGR444BE, ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), big-endian, most significant bits to 1
- PIX_FMT_GRAY8A, ///< 8bit gray, 8bit alpha
- PIX_FMT_BGR48BE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big-endian
- PIX_FMT_BGR48LE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as little-endian
-
- //the following 10 formats have the disadvantage of needing 1 format for each bit depth, thus
- //If you want to support multiple bit depths, then using PIX_FMT_YUV420P16* with the bpp stored separately
- //is better
- PIX_FMT_YUV420P9BE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
- PIX_FMT_YUV420P9LE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
- PIX_FMT_YUV420P10BE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
- PIX_FMT_YUV420P10LE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
- PIX_FMT_YUV422P10BE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
- PIX_FMT_YUV422P10LE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
- PIX_FMT_YUV444P9BE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
- PIX_FMT_YUV444P9LE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
- PIX_FMT_YUV444P10BE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
- PIX_FMT_YUV444P10LE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
- PIX_FMT_YUV422P9BE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
- PIX_FMT_YUV422P9LE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
- PIX_FMT_VDA_VLD, ///< hardware decoding through VDA
-
-#ifdef AV_PIX_FMT_ABI_GIT_MASTER
- PIX_FMT_RGBA64BE, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
- PIX_FMT_RGBA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
- PIX_FMT_BGRA64BE, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
- PIX_FMT_BGRA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
-#endif
- PIX_FMT_GBRP, ///< planar GBR 4:4:4 24bpp
- PIX_FMT_GBRP9BE, ///< planar GBR 4:4:4 27bpp, big endian
- PIX_FMT_GBRP9LE, ///< planar GBR 4:4:4 27bpp, little endian
- PIX_FMT_GBRP10BE, ///< planar GBR 4:4:4 30bpp, big endian
- PIX_FMT_GBRP10LE, ///< planar GBR 4:4:4 30bpp, little endian
- PIX_FMT_GBRP16BE, ///< planar GBR 4:4:4 48bpp, big endian
- PIX_FMT_GBRP16LE, ///< planar GBR 4:4:4 48bpp, little endian
-
-#ifndef AV_PIX_FMT_ABI_GIT_MASTER
- PIX_FMT_RGBA64BE=0x123, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
- PIX_FMT_RGBA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
- PIX_FMT_BGRA64BE, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
- PIX_FMT_BGRA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
-#endif
- PIX_FMT_0RGB=0x123+4, ///< packed RGB 8:8:8, 32bpp, 0RGB0RGB...
- PIX_FMT_RGB0, ///< packed RGB 8:8:8, 32bpp, RGB0RGB0...
- PIX_FMT_0BGR, ///< packed BGR 8:8:8, 32bpp, 0BGR0BGR...
- PIX_FMT_BGR0, ///< packed BGR 8:8:8, 32bpp, BGR0BGR0...
- PIX_FMT_YUVA444P, ///< planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
- PIX_FMT_YUVA422P, ///< planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
-
- PIX_FMT_YUV420P12BE, ///< planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
- PIX_FMT_YUV420P12LE, ///< planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
- PIX_FMT_YUV420P14BE, ///< planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
- PIX_FMT_YUV420P14LE, ///< planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
- PIX_FMT_YUV422P12BE, ///< planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
- PIX_FMT_YUV422P12LE, ///< planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
- PIX_FMT_YUV422P14BE, ///< planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
- PIX_FMT_YUV422P14LE, ///< planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
- PIX_FMT_YUV444P12BE, ///< planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
- PIX_FMT_YUV444P12LE, ///< planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
- PIX_FMT_YUV444P14BE, ///< planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
- PIX_FMT_YUV444P14LE, ///< planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
- PIX_FMT_GBRP12BE, ///< planar GBR 4:4:4 36bpp, big endian
- PIX_FMT_GBRP12LE, ///< planar GBR 4:4:4 36bpp, little endian
- PIX_FMT_GBRP14BE, ///< planar GBR 4:4:4 42bpp, big endian
- PIX_FMT_GBRP14LE, ///< planar GBR 4:4:4 42bpp, little endian
-
- PIX_FMT_NB, ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions
-#endif /* AVUTIL_OLD_PIX_FMTS_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/opt.c b/src/thirdparty/ffmpeg/libavutil/opt.c
deleted file mode 100644
index 091b798dc..000000000
--- a/src/thirdparty/ffmpeg/libavutil/opt.c
+++ /dev/null
@@ -1,1435 +0,0 @@
-/*
- * AVOptions
- * Copyright (c) 2005 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
- * AVOptions
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#include "avutil.h"
-#include "avstring.h"
-#include "common.h"
-#include "opt.h"
-#include "eval.h"
-#include "dict.h"
-#include "log.h"
-#include "parseutils.h"
-#include "pixdesc.h"
-#include "mathematics.h"
-#include "samplefmt.h"
-
-#include <float.h>
-
-#if FF_API_FIND_OPT
-//FIXME order them and do a bin search
-const AVOption *av_find_opt(void *v, const char *name, const char *unit, int mask, int flags)
-{
- const AVOption *o = NULL;
-
- while ((o = av_next_option(v, o))) {
- if (!strcmp(o->name, name) && (!unit || (o->unit && !strcmp(o->unit, unit))) && (o->flags & mask) == flags)
- return o;
- }
- return NULL;
-}
-#endif
-
-#if FF_API_OLD_AVOPTIONS
-const AVOption *av_next_option(void *obj, const AVOption *last)
-{
- return av_opt_next(obj, last);
-}
-#endif
-
-const AVOption *av_opt_next(void *obj, const AVOption *last)
-{
- AVClass *class = *(AVClass**)obj;
- if (!last && class->option && class->option[0].name)
- return class->option;
- if (last && last[1].name)
- return ++last;
- return NULL;
-}
-
-static int read_number(const AVOption *o, void *dst, double *num, int *den, int64_t *intnum)
-{
- switch (o->type) {
- case AV_OPT_TYPE_FLAGS: *intnum = *(unsigned int*)dst;return 0;
- case AV_OPT_TYPE_PIXEL_FMT:
- case AV_OPT_TYPE_SAMPLE_FMT:
- case AV_OPT_TYPE_INT: *intnum = *(int *)dst;return 0;
- case AV_OPT_TYPE_INT64: *intnum = *(int64_t *)dst;return 0;
- case AV_OPT_TYPE_FLOAT: *num = *(float *)dst;return 0;
- case AV_OPT_TYPE_DOUBLE: *num = *(double *)dst;return 0;
- case AV_OPT_TYPE_RATIONAL: *intnum = ((AVRational*)dst)->num;
- *den = ((AVRational*)dst)->den;
- return 0;
- case AV_OPT_TYPE_CONST: *num = o->default_val.dbl; return 0;
- }
- return AVERROR(EINVAL);
-}
-
-static int write_number(void *obj, const AVOption *o, void *dst, double num, int den, int64_t intnum)
-{
- if (o->max*den < num*intnum || o->min*den > num*intnum) {
- av_log(obj, AV_LOG_ERROR, "Value %f for parameter '%s' out of range [%g - %g]\n",
- num*intnum/den, o->name, o->min, o->max);
- return AVERROR(ERANGE);
- }
-
- switch (o->type) {
- case AV_OPT_TYPE_FLAGS:
- case AV_OPT_TYPE_PIXEL_FMT:
- case AV_OPT_TYPE_SAMPLE_FMT:
- case AV_OPT_TYPE_INT: *(int *)dst= llrint(num/den)*intnum; break;
- case AV_OPT_TYPE_INT64: *(int64_t *)dst= llrint(num/den)*intnum; break;
- case AV_OPT_TYPE_FLOAT: *(float *)dst= num*intnum/den; break;
- case AV_OPT_TYPE_DOUBLE:*(double *)dst= num*intnum/den; break;
- case AV_OPT_TYPE_RATIONAL:
- if ((int)num == num) *(AVRational*)dst= (AVRational){num*intnum, den};
- else *(AVRational*)dst= av_d2q(num*intnum/den, 1<<24);
- break;
- default:
- return AVERROR(EINVAL);
- }
- return 0;
-}
-
-static const double const_values[] = {
- M_PI,
- M_E,
- FF_QP2LAMBDA,
- 0
-};
-
-static const char * const const_names[] = {
- "PI",
- "E",
- "QP2LAMBDA",
- 0
-};
-
-static int hexchar2int(char c) {
- if (c >= '0' && c <= '9') return c - '0';
- if (c >= 'a' && c <= 'f') return c - 'a' + 10;
- if (c >= 'A' && c <= 'F') return c - 'A' + 10;
- return -1;
-}
-
-static int set_string_binary(void *obj, const AVOption *o, const char *val, uint8_t **dst)
-{
- int *lendst = (int *)(dst + 1);
- uint8_t *bin, *ptr;
- int len = strlen(val);
-
- av_freep(dst);
- *lendst = 0;
-
- if (len & 1)
- return AVERROR(EINVAL);
- len /= 2;
-
- ptr = bin = av_malloc(len);
- while (*val) {
- int a = hexchar2int(*val++);
- int b = hexchar2int(*val++);
- if (a < 0 || b < 0) {
- av_free(bin);
- return AVERROR(EINVAL);
- }
- *ptr++ = (a << 4) | b;
- }
- *dst = bin;
- *lendst = len;
-
- return 0;
-}
-
-static int set_string(void *obj, const AVOption *o, const char *val, uint8_t **dst)
-{
- av_freep(dst);
- *dst = av_strdup(val);
- return 0;
-}
-
-#define DEFAULT_NUMVAL(opt) ((opt->type == AV_OPT_TYPE_INT64 || \
- opt->type == AV_OPT_TYPE_CONST || \
- opt->type == AV_OPT_TYPE_FLAGS || \
- opt->type == AV_OPT_TYPE_INT) ? \
- opt->default_val.i64 : opt->default_val.dbl)
-
-static int set_string_number(void *obj, const AVOption *o, const char *val, void *dst)
-{
- int ret = 0, notfirst = 0;
- for (;;) {
- int i, den = 1;
- char buf[256];
- int cmd = 0;
- double d, num = 1;
- int64_t intnum = 1;
-
- i = 0;
- if (*val == '+' || *val == '-') {
- if (o->type == AV_OPT_TYPE_FLAGS)
- cmd = *(val++);
- else if (!notfirst)
- buf[i++] = *val;
- }
-
- for (; i < sizeof(buf) - 1 && val[i] && val[i] != '+' && val[i] != '-'; i++)
- buf[i] = val[i];
- buf[i] = 0;
-
- {
- const AVOption *o_named = av_opt_find(obj, buf, o->unit, 0, 0);
- if (o_named && o_named->type == AV_OPT_TYPE_CONST)
- d = DEFAULT_NUMVAL(o_named);
- else if (!strcmp(buf, "default")) d = DEFAULT_NUMVAL(o);
- else if (!strcmp(buf, "max" )) d = o->max;
- else if (!strcmp(buf, "min" )) d = o->min;
- else if (!strcmp(buf, "none" )) d = 0;
- else if (!strcmp(buf, "all" )) d = ~0;
- else {
- int res = av_expr_parse_and_eval(&d, buf, const_names, const_values, NULL, NULL, NULL, NULL, NULL, 0, obj);
- if (res < 0) {
- av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\"\n", val);
- return res;
- }
- }
- }
- if (o->type == AV_OPT_TYPE_FLAGS) {
- read_number(o, dst, NULL, NULL, &intnum);
- if (cmd == '+') d = intnum | (int64_t)d;
- else if (cmd == '-') d = intnum &~(int64_t)d;
- } else {
- read_number(o, dst, &num, &den, &intnum);
- if (cmd == '+') d = notfirst*num*intnum/den + d;
- else if (cmd == '-') d = notfirst*num*intnum/den - d;
- }
-
- if ((ret = write_number(obj, o, dst, d, 1, 1)) < 0)
- return ret;
- val += i;
- if (!*val)
- return 0;
- notfirst = 1;
- }
-
- return 0;
-}
-
-#if FF_API_OLD_AVOPTIONS
-int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out)
-{
- const AVOption *o = av_opt_find(obj, name, NULL, 0, 0);
- if (o_out)
- *o_out = o;
- return av_opt_set(obj, name, val, 0);
-}
-#endif
-
-int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
-{
- int ret;
- void *dst, *target_obj;
- const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj);
- if (!o || !target_obj)
- return AVERROR_OPTION_NOT_FOUND;
- if (!val && (o->type != AV_OPT_TYPE_STRING &&
- o->type != AV_OPT_TYPE_PIXEL_FMT && o->type != AV_OPT_TYPE_SAMPLE_FMT &&
- o->type != AV_OPT_TYPE_IMAGE_SIZE))
- return AVERROR(EINVAL);
-
- dst = ((uint8_t*)target_obj) + o->offset;
- switch (o->type) {
- case AV_OPT_TYPE_STRING: return set_string(obj, o, val, dst);
- case AV_OPT_TYPE_BINARY: return set_string_binary(obj, o, val, dst);
- case AV_OPT_TYPE_FLAGS:
- case AV_OPT_TYPE_INT:
- case AV_OPT_TYPE_INT64:
- case AV_OPT_TYPE_FLOAT:
- case AV_OPT_TYPE_DOUBLE:
- case AV_OPT_TYPE_RATIONAL: return set_string_number(obj, o, val, dst);
- case AV_OPT_TYPE_IMAGE_SIZE:
- if (!val || !strcmp(val, "none")) {
- *(int *)dst = *((int *)dst + 1) = 0;
- return 0;
- }
- ret = av_parse_video_size(dst, ((int *)dst) + 1, val);
- if (ret < 0)
- av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as image size\n", val);
- return ret;
- case AV_OPT_TYPE_PIXEL_FMT:
- if (!val || !strcmp(val, "none")) {
- ret = AV_PIX_FMT_NONE;
- } else {
- ret = av_get_pix_fmt(val);
- if (ret == AV_PIX_FMT_NONE) {
- char *tail;
- ret = strtol(val, &tail, 0);
- if (*tail || (unsigned)ret >= AV_PIX_FMT_NB) {
- av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as pixel format\n", val);
- return AVERROR(EINVAL);
- }
- }
- }
- *(enum AVPixelFormat *)dst = ret;
- return 0;
- case AV_OPT_TYPE_SAMPLE_FMT:
- if (!val || !strcmp(val, "none")) {
- ret = AV_SAMPLE_FMT_NONE;
- } else {
- ret = av_get_sample_fmt(val);
- if (ret == AV_SAMPLE_FMT_NONE) {
- char *tail;
- ret = strtol(val, &tail, 0);
- if (*tail || (unsigned)ret >= AV_SAMPLE_FMT_NB) {
- av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as sample format\n", val);
- return AVERROR(EINVAL);
- }
- }
- }
- *(enum AVSampleFormat *)dst = ret;
- return 0;
- }
-
- av_log(obj, AV_LOG_ERROR, "Invalid option type.\n");
- return AVERROR(EINVAL);
-}
-
-#define OPT_EVAL_NUMBER(name, opttype, vartype)\
- int av_opt_eval_ ## name(void *obj, const AVOption *o, const char *val, vartype *name ## _out)\
- {\
- if (!o || o->type != opttype)\
- return AVERROR(EINVAL);\
- return set_string_number(obj, o, val, name ## _out);\
- }
-
-OPT_EVAL_NUMBER(flags, AV_OPT_TYPE_FLAGS, int)
-OPT_EVAL_NUMBER(int, AV_OPT_TYPE_INT, int)
-OPT_EVAL_NUMBER(int64, AV_OPT_TYPE_INT64, int64_t)
-OPT_EVAL_NUMBER(float, AV_OPT_TYPE_FLOAT, float)
-OPT_EVAL_NUMBER(double, AV_OPT_TYPE_DOUBLE, double)
-OPT_EVAL_NUMBER(q, AV_OPT_TYPE_RATIONAL, AVRational)
-
-static int set_number(void *obj, const char *name, double num, int den, int64_t intnum,
- int search_flags)
-{
- void *dst, *target_obj;
- const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj);
-
- if (!o || !target_obj)
- return AVERROR_OPTION_NOT_FOUND;
-
- dst = ((uint8_t*)target_obj) + o->offset;
- return write_number(obj, o, dst, num, den, intnum);
-}
-
-#if FF_API_OLD_AVOPTIONS
-const AVOption *av_set_double(void *obj, const char *name, double n)
-{
- const AVOption *o = av_opt_find(obj, name, NULL, 0, 0);
- if (set_number(obj, name, n, 1, 1, 0) < 0)
- return NULL;
- return o;
-}
-
-const AVOption *av_set_q(void *obj, const char *name, AVRational n)
-{
- const AVOption *o = av_opt_find(obj, name, NULL, 0, 0);
- if (set_number(obj, name, n.num, n.den, 1, 0) < 0)
- return NULL;
- return o;
-}
-
-const AVOption *av_set_int(void *obj, const char *name, int64_t n)
-{
- const AVOption *o = av_opt_find(obj, name, NULL, 0, 0);
- if (set_number(obj, name, 1, 1, n, 0) < 0)
- return NULL;
- return o;
-}
-#endif
-
-int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
-{
- return set_number(obj, name, 1, 1, val, search_flags);
-}
-
-int av_opt_set_double(void *obj, const char *name, double val, int search_flags)
-{
- return set_number(obj, name, val, 1, 1, search_flags);
-}
-
-int av_opt_set_q(void *obj, const char *name, AVRational val, int search_flags)
-{
- return set_number(obj, name, val.num, val.den, 1, search_flags);
-}
-
-int av_opt_set_bin(void *obj, const char *name, const uint8_t *val, int len, int search_flags)
-{
- void *target_obj;
- const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj);
- uint8_t *ptr;
- uint8_t **dst;
- int *lendst;
-
- if (!o || !target_obj)
- return AVERROR_OPTION_NOT_FOUND;
-
- if (o->type != AV_OPT_TYPE_BINARY)
- return AVERROR(EINVAL);
-
- ptr = av_malloc(len);
- if (!ptr)
- return AVERROR(ENOMEM);
-
- dst = (uint8_t **)(((uint8_t *)target_obj) + o->offset);
- lendst = (int *)(dst + 1);
-
- av_free(*dst);
- *dst = ptr;
- *lendst = len;
- memcpy(ptr, val, len);
-
- return 0;
-}
-
-int av_opt_set_image_size(void *obj, const char *name, int w, int h, int search_flags)
-{
- void *target_obj;
- const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj);
-
- if (!o || !target_obj)
- return AVERROR_OPTION_NOT_FOUND;
- if (o->type != AV_OPT_TYPE_IMAGE_SIZE) {
- av_log(obj, AV_LOG_ERROR,
- "The value set by option '%s' is not an image size.\n", o->name);
- return AVERROR(EINVAL);
- }
- if (w<0 || h<0) {
- av_log(obj, AV_LOG_ERROR,
- "Invalid negative size value %dx%d for size '%s'\n", w, h, o->name);
- return AVERROR(EINVAL);
- }
- *(int *)(((uint8_t *)target_obj) + o->offset) = w;
- *(int *)(((uint8_t *)target_obj+sizeof(int)) + o->offset) = h;
- return 0;
-}
-
-static int set_format(void *obj, const char *name, int fmt, int search_flags,
- enum AVOptionType type, const char *desc, int nb_fmts)
-{
- void *target_obj;
- const AVOption *o = av_opt_find2(obj, name, NULL, 0,
- search_flags, &target_obj);
- int min, max;
- const AVClass *class = *(AVClass **)obj;
-
- if (!o || !target_obj)
- return AVERROR_OPTION_NOT_FOUND;
- if (o->type != type) {
- av_log(obj, AV_LOG_ERROR,
- "The value set by option '%s' is not a %s format", name, desc);
- return AVERROR(EINVAL);
- }
-
-#if LIBAVUTIL_VERSION_MAJOR < 53
- if (class->version && class->version < AV_VERSION_INT(52, 11, 100)) {
- min = -1;
- max = nb_fmts-1;
- } else
-#endif
- {
- min = FFMIN(o->min, -1);
- max = FFMAX(o->max, nb_fmts-1);
- }
- if (fmt < min || fmt > max) {
- av_log(obj, AV_LOG_ERROR,
- "Value %d for parameter '%s' out of %s format range [%d - %d]\n",
- fmt, name, desc, min, max);
- return AVERROR(ERANGE);
- }
- *(int *)(((uint8_t *)target_obj) + o->offset) = fmt;
- return 0;
-}
-
-int av_opt_set_pixel_fmt(void *obj, const char *name, enum AVPixelFormat fmt, int search_flags)
-{
- return set_format(obj, name, fmt, search_flags, AV_OPT_TYPE_PIXEL_FMT, "pixel", AV_PIX_FMT_NB);
-}
-
-int av_opt_set_sample_fmt(void *obj, const char *name, enum AVSampleFormat fmt, int search_flags)
-{
- return set_format(obj, name, fmt, search_flags, AV_OPT_TYPE_SAMPLE_FMT, "sample", AV_SAMPLE_FMT_NB);
-}
-
-#if FF_API_OLD_AVOPTIONS
-/**
- *
- * @param buf a buffer which is used for returning non string values as strings, can be NULL
- * @param buf_len allocated length in bytes of buf
- */
-const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len)
-{
- const AVOption *o = av_opt_find(obj, name, NULL, 0, AV_OPT_SEARCH_CHILDREN);
- void *dst;
- uint8_t *bin;
- int len, i;
- if (!o)
- return NULL;
- if (o->type != AV_OPT_TYPE_STRING && (!buf || !buf_len))
- return NULL;
-
- dst= ((uint8_t*)obj) + o->offset;
- if (o_out) *o_out= o;
-
- switch (o->type) {
- case AV_OPT_TYPE_FLAGS: snprintf(buf, buf_len, "0x%08X",*(int *)dst);break;
- case AV_OPT_TYPE_INT: snprintf(buf, buf_len, "%d" , *(int *)dst);break;
- case AV_OPT_TYPE_INT64: snprintf(buf, buf_len, "%"PRId64, *(int64_t*)dst);break;
- case AV_OPT_TYPE_FLOAT: snprintf(buf, buf_len, "%f" , *(float *)dst);break;
- case AV_OPT_TYPE_DOUBLE: snprintf(buf, buf_len, "%f" , *(double *)dst);break;
- case AV_OPT_TYPE_RATIONAL: snprintf(buf, buf_len, "%d/%d", ((AVRational*)dst)->num, ((AVRational*)dst)->den);break;
- case AV_OPT_TYPE_CONST: snprintf(buf, buf_len, "%f" , o->default_val.dbl);break;
- case AV_OPT_TYPE_STRING: return *(void**)dst;
- case AV_OPT_TYPE_BINARY:
- len = *(int*)(((uint8_t *)dst) + sizeof(uint8_t *));
- if (len >= (buf_len + 1)/2) return NULL;
- bin = *(uint8_t**)dst;
- for (i = 0; i < len; i++) snprintf(buf + i*2, 3, "%02X", bin[i]);
- break;
- default: return NULL;
- }
- return buf;
-}
-#endif
-
-int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
-{
- void *dst, *target_obj;
- const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj);
- uint8_t *bin, buf[128];
- int len, i, ret;
-
- if (!o || !target_obj || (o->offset<=0 && o->type != AV_OPT_TYPE_CONST))
- return AVERROR_OPTION_NOT_FOUND;
-
- dst = (uint8_t*)target_obj + o->offset;
-
- buf[0] = 0;
- switch (o->type) {
- case AV_OPT_TYPE_FLAGS: ret = snprintf(buf, sizeof(buf), "0x%08X", *(int *)dst);break;
- case AV_OPT_TYPE_INT: ret = snprintf(buf, sizeof(buf), "%d" , *(int *)dst);break;
- case AV_OPT_TYPE_INT64: ret = snprintf(buf, sizeof(buf), "%"PRId64, *(int64_t*)dst);break;
- case AV_OPT_TYPE_FLOAT: ret = snprintf(buf, sizeof(buf), "%f" , *(float *)dst);break;
- case AV_OPT_TYPE_DOUBLE: ret = snprintf(buf, sizeof(buf), "%f" , *(double *)dst);break;
- case AV_OPT_TYPE_RATIONAL: ret = snprintf(buf, sizeof(buf), "%d/%d", ((AVRational*)dst)->num, ((AVRational*)dst)->den);break;
- case AV_OPT_TYPE_CONST: ret = snprintf(buf, sizeof(buf), "%f" , o->default_val.dbl);break;
- case AV_OPT_TYPE_STRING:
- if (*(uint8_t**)dst)
- *out_val = av_strdup(*(uint8_t**)dst);
- else
- *out_val = av_strdup("");
- return 0;
- case AV_OPT_TYPE_BINARY:
- len = *(int*)(((uint8_t *)dst) + sizeof(uint8_t *));
- if ((uint64_t)len*2 + 1 > INT_MAX)
- return AVERROR(EINVAL);
- if (!(*out_val = av_malloc(len*2 + 1)))
- return AVERROR(ENOMEM);
- bin = *(uint8_t**)dst;
- for (i = 0; i < len; i++)
- snprintf(*out_val + i*2, 3, "%02X", bin[i]);
- return 0;
- case AV_OPT_TYPE_IMAGE_SIZE:
- ret = snprintf(buf, sizeof(buf), "%dx%d", ((int *)dst)[0], ((int *)dst)[1]);
- break;
- case AV_OPT_TYPE_PIXEL_FMT:
- ret = snprintf(buf, sizeof(buf), "%s", (char *)av_x_if_null(av_get_pix_fmt_name(*(enum AVPixelFormat *)dst), "none"));
- break;
- case AV_OPT_TYPE_SAMPLE_FMT:
- ret = snprintf(buf, sizeof(buf), "%s", (char *)av_x_if_null(av_get_sample_fmt_name(*(enum AVSampleFormat *)dst), "none"));
- break;
- default:
- return AVERROR(EINVAL);
- }
-
- if (ret >= sizeof(buf))
- return AVERROR(EINVAL);
- *out_val = av_strdup(buf);
- return 0;
-}
-
-static int get_number(void *obj, const char *name, const AVOption **o_out, double *num, int *den, int64_t *intnum,
- int search_flags)
-{
- void *dst, *target_obj;
- const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj);
- if (!o || !target_obj)
- goto error;
-
- dst = ((uint8_t*)target_obj) + o->offset;
-
- if (o_out) *o_out= o;
-
- return read_number(o, dst, num, den, intnum);
-
-error:
- *den=*intnum=0;
- return -1;
-}
-
-#if FF_API_OLD_AVOPTIONS
-double av_get_double(void *obj, const char *name, const AVOption **o_out)
-{
- int64_t intnum=1;
- double num=1;
- int den=1;
-
- if (get_number(obj, name, o_out, &num, &den, &intnum, 0) < 0)
- return NAN;
- return num*intnum/den;
-}
-
-AVRational av_get_q(void *obj, const char *name, const AVOption **o_out)
-{
- int64_t intnum=1;
- double num=1;
- int den=1;
-
- if (get_number(obj, name, o_out, &num, &den, &intnum, 0) < 0)
- return (AVRational){0, 0};
- if (num == 1.0 && (int)intnum == intnum)
- return (AVRational){intnum, den};
- else
- return av_d2q(num*intnum/den, 1<<24);
-}
-
-int64_t av_get_int(void *obj, const char *name, const AVOption **o_out)
-{
- int64_t intnum=1;
- double num=1;
- int den=1;
-
- if (get_number(obj, name, o_out, &num, &den, &intnum, 0) < 0)
- return -1;
- return num*intnum/den;
-}
-#endif
-
-int av_opt_get_int(void *obj, const char *name, int search_flags, int64_t *out_val)
-{
- int64_t intnum = 1;
- double num = 1;
- int ret, den = 1;
-
- if ((ret = get_number(obj, name, NULL, &num, &den, &intnum, search_flags)) < 0)
- return ret;
- *out_val = num*intnum/den;
- return 0;
-}
-
-int av_opt_get_double(void *obj, const char *name, int search_flags, double *out_val)
-{
- int64_t intnum = 1;
- double num = 1;
- int ret, den = 1;
-
- if ((ret = get_number(obj, name, NULL, &num, &den, &intnum, search_flags)) < 0)
- return ret;
- *out_val = num*intnum/den;
- return 0;
-}
-
-int av_opt_get_q(void *obj, const char *name, int search_flags, AVRational *out_val)
-{
- int64_t intnum = 1;
- double num = 1;
- int ret, den = 1;
-
- if ((ret = get_number(obj, name, NULL, &num, &den, &intnum, search_flags)) < 0)
- return ret;
-
- if (num == 1.0 && (int)intnum == intnum)
- *out_val = (AVRational){intnum, den};
- else
- *out_val = av_d2q(num*intnum/den, 1<<24);
- return 0;
-}
-
-int av_opt_get_image_size(void *obj, const char *name, int search_flags, int *w_out, int *h_out)
-{
- void *dst, *target_obj;
- const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj);
- if (!o || !target_obj)
- return AVERROR_OPTION_NOT_FOUND;
- if (o->type != AV_OPT_TYPE_IMAGE_SIZE) {
- av_log(obj, AV_LOG_ERROR,
- "The value for option '%s' is not an image size.\n", name);
- return AVERROR(EINVAL);
- }
-
- dst = ((uint8_t*)target_obj) + o->offset;
- if (w_out) *w_out = *(int *)dst;
- if (h_out) *h_out = *((int *)dst+1);
- return 0;
-}
-
-static int get_format(void *obj, const char *name, int search_flags, int *out_fmt,
- enum AVOptionType type, const char *desc)
-{
- void *dst, *target_obj;
- const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj);
- if (!o || !target_obj)
- return AVERROR_OPTION_NOT_FOUND;
- if (o->type != type) {
- av_log(obj, AV_LOG_ERROR,
- "The value for option '%s' is not a %s format.\n", desc, name);
- return AVERROR(EINVAL);
- }
-
- dst = ((uint8_t*)target_obj) + o->offset;
- *out_fmt = *(int *)dst;
- return 0;
-}
-
-int av_opt_get_pixel_fmt(void *obj, const char *name, int search_flags, enum AVPixelFormat *out_fmt)
-{
- return get_format(obj, name, search_flags, out_fmt, AV_OPT_TYPE_PIXEL_FMT, "pixel");
-}
-
-int av_opt_get_sample_fmt(void *obj, const char *name, int search_flags, enum AVSampleFormat *out_fmt)
-{
- return get_format(obj, name, search_flags, out_fmt, AV_OPT_TYPE_SAMPLE_FMT, "sample");
-}
-
-int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name)
-{
- const AVOption *field = av_opt_find(obj, field_name, NULL, 0, 0);
- const AVOption *flag = av_opt_find(obj, flag_name,
- field ? field->unit : NULL, 0, 0);
- int64_t res;
-
- if (!field || !flag || flag->type != AV_OPT_TYPE_CONST ||
- av_opt_get_int(obj, field_name, 0, &res) < 0)
- return 0;
- return res & flag->default_val.i64;
-}
-
-static void log_value(void *av_log_obj, int level, double d)
-{
- if (d == INT_MAX) {
- av_log(av_log_obj, level, "INT_MAX");
- } else if (d == INT_MIN) {
- av_log(av_log_obj, level, "INT_MIN");
- } else if (d == (double)INT64_MAX) {
- av_log(av_log_obj, level, "I64_MAX");
- } else if (d == INT64_MIN) {
- av_log(av_log_obj, level, "I64_MIN");
- } else if (d == FLT_MAX) {
- av_log(av_log_obj, level, "FLT_MAX");
- } else if (d == FLT_MIN) {
- av_log(av_log_obj, level, "FLT_MIN");
- } else {
- av_log(av_log_obj, level, "%g", d);
- }
-}
-
-static void opt_list(void *obj, void *av_log_obj, const char *unit,
- int req_flags, int rej_flags)
-{
- const AVOption *opt=NULL;
- AVOptionRanges *r;
- int i;
-
- while ((opt = av_opt_next(obj, opt))) {
- if (!(opt->flags & req_flags) || (opt->flags & rej_flags))
- continue;
-
- /* Don't print CONST's on level one.
- * Don't print anything but CONST's on level two.
- * Only print items from the requested unit.
- */
- if (!unit && opt->type==AV_OPT_TYPE_CONST)
- continue;
- else if (unit && opt->type!=AV_OPT_TYPE_CONST)
- continue;
- else if (unit && opt->type==AV_OPT_TYPE_CONST && strcmp(unit, opt->unit))
- continue;
- else if (unit && opt->type == AV_OPT_TYPE_CONST)
- av_log(av_log_obj, AV_LOG_INFO, " %-15s ", opt->name);
- else
- av_log(av_log_obj, AV_LOG_INFO, "-%-17s ", opt->name);
-
- switch (opt->type) {
- case AV_OPT_TYPE_FLAGS:
- av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "<flags>");
- break;
- case AV_OPT_TYPE_INT:
- av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "<int>");
- break;
- case AV_OPT_TYPE_INT64:
- av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "<int64>");
- break;
- case AV_OPT_TYPE_DOUBLE:
- av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "<double>");
- break;
- case AV_OPT_TYPE_FLOAT:
- av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "<float>");
- break;
- case AV_OPT_TYPE_STRING:
- av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "<string>");
- break;
- case AV_OPT_TYPE_RATIONAL:
- av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "<rational>");
- break;
- case AV_OPT_TYPE_BINARY:
- av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "<binary>");
- break;
- case AV_OPT_TYPE_IMAGE_SIZE:
- av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "<image_size>");
- break;
- case AV_OPT_TYPE_PIXEL_FMT:
- av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "<pix_fmt>");
- break;
- case AV_OPT_TYPE_SAMPLE_FMT:
- av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "<sample_fmt>");
- break;
- case AV_OPT_TYPE_CONST:
- default:
- av_log(av_log_obj, AV_LOG_INFO, "%-12s ", "");
- break;
- }
- av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_ENCODING_PARAM) ? 'E' : '.');
- av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_DECODING_PARAM) ? 'D' : '.');
- av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_FILTERING_PARAM)? 'F' : '.');
- av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_VIDEO_PARAM ) ? 'V' : '.');
- av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_AUDIO_PARAM ) ? 'A' : '.');
- av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_SUBTITLE_PARAM) ? 'S' : '.');
-
- if (opt->help)
- av_log(av_log_obj, AV_LOG_INFO, " %s", opt->help);
-
- if (av_opt_query_ranges(&r, obj, opt->name, AV_OPT_SEARCH_FAKE_OBJ) >= 0) {
- switch (opt->type) {
- case AV_OPT_TYPE_INT:
- case AV_OPT_TYPE_INT64:
- case AV_OPT_TYPE_DOUBLE:
- case AV_OPT_TYPE_FLOAT:
- case AV_OPT_TYPE_RATIONAL:
- for (i = 0; i < r->nb_ranges; i++) {
- av_log(av_log_obj, AV_LOG_INFO, " (from ");
- log_value(av_log_obj, AV_LOG_INFO, r->range[i]->value_min);
- av_log(av_log_obj, AV_LOG_INFO, " to ");
- log_value(av_log_obj, AV_LOG_INFO, r->range[i]->value_max);
- av_log(av_log_obj, AV_LOG_INFO, ")");
- }
- break;
- }
- av_opt_freep_ranges(&r);
- }
-
- av_log(av_log_obj, AV_LOG_INFO, "\n");
- if (opt->unit && opt->type != AV_OPT_TYPE_CONST) {
- opt_list(obj, av_log_obj, opt->unit, req_flags, rej_flags);
- }
- }
-}
-
-int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags)
-{
- if (!obj)
- return -1;
-
- av_log(av_log_obj, AV_LOG_INFO, "%s AVOptions:\n", (*(AVClass**)obj)->class_name);
-
- opt_list(obj, av_log_obj, NULL, req_flags, rej_flags);
-
- return 0;
-}
-
-void av_opt_set_defaults(void *s)
-{
-#if FF_API_OLD_AVOPTIONS
- av_opt_set_defaults2(s, 0, 0);
-}
-
-void av_opt_set_defaults2(void *s, int mask, int flags)
-{
-#endif
- const AVClass *class = *(AVClass **)s;
- const AVOption *opt = NULL;
- while ((opt = av_opt_next(s, opt)) != NULL) {
-#if FF_API_OLD_AVOPTIONS
- if ((opt->flags & mask) != flags)
- continue;
-#endif
- switch (opt->type) {
- case AV_OPT_TYPE_CONST:
- /* Nothing to be done here */
- break;
- case AV_OPT_TYPE_FLAGS:
- case AV_OPT_TYPE_INT:
- case AV_OPT_TYPE_INT64:
- av_opt_set_int(s, opt->name, opt->default_val.i64, 0);
- break;
- case AV_OPT_TYPE_DOUBLE:
- case AV_OPT_TYPE_FLOAT: {
- double val;
- val = opt->default_val.dbl;
- av_opt_set_double(s, opt->name, val, 0);
- }
- break;
- case AV_OPT_TYPE_RATIONAL: {
- AVRational val;
- val = av_d2q(opt->default_val.dbl, INT_MAX);
- av_opt_set_q(s, opt->name, val, 0);
- }
- break;
- case AV_OPT_TYPE_STRING:
- case AV_OPT_TYPE_IMAGE_SIZE:
- av_opt_set(s, opt->name, opt->default_val.str, 0);
- break;
- case AV_OPT_TYPE_PIXEL_FMT:
-#if LIBAVUTIL_VERSION_MAJOR < 53
- if (class->version && class->version < AV_VERSION_INT(52, 10, 100))
- av_opt_set(s, opt->name, opt->default_val.str, 0);
- else
-#endif
- av_opt_set_pixel_fmt(s, opt->name, opt->default_val.i64, 0);
- break;
- case AV_OPT_TYPE_SAMPLE_FMT:
-#if LIBAVUTIL_VERSION_MAJOR < 53
- if (class->version && class->version < AV_VERSION_INT(52, 10, 100))
- av_opt_set(s, opt->name, opt->default_val.str, 0);
- else
-#endif
- av_opt_set_sample_fmt(s, opt->name, opt->default_val.i64, 0);
- break;
- case AV_OPT_TYPE_BINARY:
- /* Cannot set default for binary */
- break;
- default:
- av_log(s, AV_LOG_DEBUG, "AVOption type %d of option %s not implemented yet\n", opt->type, opt->name);
- }
- }
-}
-
-/**
- * Store the value in the field in ctx that is named like key.
- * ctx must be an AVClass context, storing is done using AVOptions.
- *
- * @param buf the string to parse, buf will be updated to point at the
- * separator just after the parsed key/value pair
- * @param key_val_sep a 0-terminated list of characters used to
- * separate key from value
- * @param pairs_sep a 0-terminated list of characters used to separate
- * two pairs from each other
- * @return 0 if the key/value pair has been successfully parsed and
- * set, or a negative value corresponding to an AVERROR code in case
- * of error:
- * AVERROR(EINVAL) if the key/value pair cannot be parsed,
- * the error code issued by av_opt_set() if the key/value pair
- * cannot be set
- */
-static int parse_key_value_pair(void *ctx, const char **buf,
- const char *key_val_sep, const char *pairs_sep)
-{
- char *key = av_get_token(buf, key_val_sep);
- char *val;
- int ret;
-
- if (*key && strspn(*buf, key_val_sep)) {
- (*buf)++;
- val = av_get_token(buf, pairs_sep);
- } else {
- av_log(ctx, AV_LOG_ERROR, "Missing key or no key/value separator found after key '%s'\n", key);
- av_free(key);
- return AVERROR(EINVAL);
- }
-
- av_log(ctx, AV_LOG_DEBUG, "Setting entry with key '%s' to value '%s'\n", key, val);
-
- ret = av_opt_set(ctx, key, val, 0);
- if (ret == AVERROR_OPTION_NOT_FOUND)
- av_log(ctx, AV_LOG_ERROR, "Key '%s' not found.\n", key);
-
- av_free(key);
- av_free(val);
- return ret;
-}
-
-int av_set_options_string(void *ctx, const char *opts,
- const char *key_val_sep, const char *pairs_sep)
-{
- int ret, count = 0;
-
- if (!opts)
- return 0;
-
- while (*opts) {
- if ((ret = parse_key_value_pair(ctx, &opts, key_val_sep, pairs_sep)) < 0)
- return ret;
- count++;
-
- if (*opts)
- opts++;
- }
-
- return count;
-}
-
-#define WHITESPACES " \n\t"
-
-static int is_key_char(char c)
-{
- return (unsigned)((c | 32) - 'a') < 26 ||
- (unsigned)(c - '0') < 10 ||
- c == '-' || c == '_' || c == '/' || c == '.';
-}
-
-/**
- * Read a key from a string.
- *
- * The key consists of is_key_char characters and must be terminated by a
- * character from the delim string; spaces are ignored.
- *
- * @return 0 for success (even with ellipsis), <0 for failure
- */
-static int get_key(const char **ropts, const char *delim, char **rkey)
-{
- const char *opts = *ropts;
- const char *key_start, *key_end;
-
- key_start = opts += strspn(opts, WHITESPACES);
- while (is_key_char(*opts))
- opts++;
- key_end = opts;
- opts += strspn(opts, WHITESPACES);
- if (!*opts || !strchr(delim, *opts))
- return AVERROR(EINVAL);
- opts++;
- if (!(*rkey = av_malloc(key_end - key_start + 1)))
- return AVERROR(ENOMEM);
- memcpy(*rkey, key_start, key_end - key_start);
- (*rkey)[key_end - key_start] = 0;
- *ropts = opts;
- return 0;
-}
-
-int av_opt_get_key_value(const char **ropts,
- const char *key_val_sep, const char *pairs_sep,
- unsigned flags,
- char **rkey, char **rval)
-{
- int ret;
- char *key = NULL, *val;
- const char *opts = *ropts;
-
- if ((ret = get_key(&opts, key_val_sep, &key)) < 0 &&
- !(flags & AV_OPT_FLAG_IMPLICIT_KEY))
- return AVERROR(EINVAL);
- if (!(val = av_get_token(&opts, pairs_sep))) {
- av_free(key);
- return AVERROR(ENOMEM);
- }
- *ropts = opts;
- *rkey = key;
- *rval = val;
- return 0;
-}
-
-int av_opt_set_from_string(void *ctx, const char *opts,
- const char *const *shorthand,
- const char *key_val_sep, const char *pairs_sep)
-{
- int ret, count = 0;
- const char *dummy_shorthand = NULL;
- char *av_uninit(parsed_key), *av_uninit(value);
- const char *key;
-
- if (!opts)
- return 0;
- if (!shorthand)
- shorthand = &dummy_shorthand;
-
- while (*opts) {
- ret = av_opt_get_key_value(&opts, key_val_sep, pairs_sep,
- *shorthand ? AV_OPT_FLAG_IMPLICIT_KEY : 0,
- &parsed_key, &value);
- if (ret < 0) {
- if (ret == AVERROR(EINVAL))
- av_log(ctx, AV_LOG_ERROR, "No option name near '%s'\n", opts);
- else
- av_log(ctx, AV_LOG_ERROR, "Unable to parse '%s': %s\n", opts,
- av_err2str(ret));
- return ret;
- }
- if (*opts)
- opts++;
- if (parsed_key) {
- key = parsed_key;
- while (*shorthand) /* discard all remaining shorthand */
- shorthand++;
- } else {
- key = *(shorthand++);
- }
-
- av_log(ctx, AV_LOG_DEBUG, "Setting '%s' to value '%s'\n", key, value);
- if ((ret = av_opt_set(ctx, key, value, 0)) < 0) {
- if (ret == AVERROR_OPTION_NOT_FOUND)
- av_log(ctx, AV_LOG_ERROR, "Option '%s' not found\n", key);
- av_free(value);
- av_free(parsed_key);
- return ret;
- }
-
- av_free(value);
- av_free(parsed_key);
- count++;
- }
- return count;
-}
-
-void av_opt_free(void *obj)
-{
- const AVOption *o = NULL;
- while ((o = av_opt_next(obj, o)))
- if (o->type == AV_OPT_TYPE_STRING || o->type == AV_OPT_TYPE_BINARY)
- av_freep((uint8_t *)obj + o->offset);
-}
-
-int av_opt_set_dict(void *obj, AVDictionary **options)
-{
- AVDictionaryEntry *t = NULL;
- AVDictionary *tmp = NULL;
- int ret = 0;
-
- while ((t = av_dict_get(*options, "", t, AV_DICT_IGNORE_SUFFIX))) {
- ret = av_opt_set(obj, t->key, t->value, 0);
- if (ret == AVERROR_OPTION_NOT_FOUND)
- av_dict_set(&tmp, t->key, t->value, 0);
- else if (ret < 0) {
- av_log(obj, AV_LOG_ERROR, "Error setting option %s to value %s.\n", t->key, t->value);
- break;
- }
- ret = 0;
- }
- av_dict_free(options);
- *options = tmp;
- return ret;
-}
-
-const AVOption *av_opt_find(void *obj, const char *name, const char *unit,
- int opt_flags, int search_flags)
-{
- return av_opt_find2(obj, name, unit, opt_flags, search_flags, NULL);
-}
-
-const AVOption *av_opt_find2(void *obj, const char *name, const char *unit,
- int opt_flags, int search_flags, void **target_obj)
-{
- const AVClass *c;
- const AVOption *o = NULL;
-
- if(!obj)
- return NULL;
-
- c= *(AVClass**)obj;
-
- if (search_flags & AV_OPT_SEARCH_CHILDREN) {
- if (search_flags & AV_OPT_SEARCH_FAKE_OBJ) {
- const AVClass *child = NULL;
- while (child = av_opt_child_class_next(c, child))
- if (o = av_opt_find2(&child, name, unit, opt_flags, search_flags, NULL))
- return o;
- } else {
- void *child = NULL;
- while (child = av_opt_child_next(obj, child))
- if (o = av_opt_find2(child, name, unit, opt_flags, search_flags, target_obj))
- return o;
- }
- }
-
- while (o = av_opt_next(obj, o)) {
- if (!strcmp(o->name, name) && (o->flags & opt_flags) == opt_flags &&
- ((!unit && o->type != AV_OPT_TYPE_CONST) ||
- (unit && o->type == AV_OPT_TYPE_CONST && o->unit && !strcmp(o->unit, unit)))) {
- if (target_obj) {
- if (!(search_flags & AV_OPT_SEARCH_FAKE_OBJ))
- *target_obj = obj;
- else
- *target_obj = NULL;
- }
- return o;
- }
- }
- return NULL;
-}
-
-void *av_opt_child_next(void *obj, void *prev)
-{
- const AVClass *c = *(AVClass**)obj;
- if (c->child_next)
- return c->child_next(obj, prev);
- return NULL;
-}
-
-const AVClass *av_opt_child_class_next(const AVClass *parent, const AVClass *prev)
-{
- if (parent->child_class_next)
- return parent->child_class_next(prev);
- return NULL;
-}
-
-void *av_opt_ptr(const AVClass *class, void *obj, const char *name)
-{
- const AVOption *opt= av_opt_find2(&class, name, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ, NULL);
- if(!opt)
- return NULL;
- return (uint8_t*)obj + opt->offset;
-}
-
-int av_opt_query_ranges(AVOptionRanges **ranges_arg, void *obj, const char *key, int flags)
-{
- const AVClass *c = *(AVClass**)obj;
- int (*callback)(AVOptionRanges **, void *obj, const char *key, int flags) = NULL;
-
- if (c->version > (52 << 16 | 11 << 8))
- callback = c->query_ranges;
-
- if (!callback)
- callback = av_opt_query_ranges_default;
-
- return callback(ranges_arg, obj, key, flags);
-}
-
-int av_opt_query_ranges_default(AVOptionRanges **ranges_arg, void *obj, const char *key, int flags)
-{
- AVOptionRanges *ranges = av_mallocz(sizeof(*ranges));
- AVOptionRange **range_array = av_mallocz(sizeof(void*));
- AVOptionRange *range = av_mallocz(sizeof(*range));
- const AVOption *field = av_opt_find(obj, key, NULL, 0, flags);
- int ret;
-
- *ranges_arg = NULL;
-
- if (!ranges || !range || !range_array || !field) {
- ret = AVERROR(ENOMEM);
- goto fail;
- }
-
- ranges->range = range_array;
- ranges->range[0] = range;
- ranges->nb_ranges = 1;
- range->is_range = 1;
- range->value_min = field->min;
- range->value_max = field->max;
-
- switch (field->type) {
- case AV_OPT_TYPE_INT:
- case AV_OPT_TYPE_INT64:
- case AV_OPT_TYPE_PIXEL_FMT:
- case AV_OPT_TYPE_SAMPLE_FMT:
- case AV_OPT_TYPE_FLOAT:
- case AV_OPT_TYPE_DOUBLE:
- break;
- case AV_OPT_TYPE_STRING:
- range->component_min = 0;
- range->component_max = 0x10FFFF; // max unicode value
- range->value_min = -1;
- range->value_max = INT_MAX;
- break;
- case AV_OPT_TYPE_RATIONAL:
- range->component_min = INT_MIN;
- range->component_max = INT_MAX;
- break;
- case AV_OPT_TYPE_IMAGE_SIZE:
- range->component_min = 0;
- range->component_max = INT_MAX/128/8;
- range->value_min = 0;
- range->value_max = INT_MAX/8;
- break;
- default:
- ret = AVERROR(ENOSYS);
- goto fail;
- }
-
- *ranges_arg = ranges;
- return 0;
-fail:
- av_free(ranges);
- av_free(range);
- av_free(range_array);
- return ret;
-}
-
-void av_opt_freep_ranges(AVOptionRanges **rangesp)
-{
- int i;
- AVOptionRanges *ranges = *rangesp;
-
- for (i = 0; i < ranges->nb_ranges; i++) {
- AVOptionRange *range = ranges->range[i];
- av_freep(&range->str);
- av_freep(&ranges->range[i]);
- }
- av_freep(&ranges->range);
- av_freep(rangesp);
-}
-
-#ifdef TEST
-
-typedef struct TestContext
-{
- const AVClass *class;
- int num;
- int toggle;
- char *string;
- int flags;
- AVRational rational;
- int w, h;
- enum AVPixelFormat pix_fmt;
- enum AVSampleFormat sample_fmt;
-} TestContext;
-
-#define OFFSET(x) offsetof(TestContext, x)
-
-#define TEST_FLAG_COOL 01
-#define TEST_FLAG_LAME 02
-#define TEST_FLAG_MU 04
-
-static const AVOption test_options[]= {
-{"num", "set num", OFFSET(num), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 100 },
-{"toggle", "set toggle", OFFSET(toggle), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1 },
-{"rational", "set rational", OFFSET(rational), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, 0, 10 },
-{"string", "set string", OFFSET(string), AV_OPT_TYPE_STRING, {0}, CHAR_MIN, CHAR_MAX },
-{"flags", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = 0}, 0, INT_MAX, 0, "flags" },
-{"cool", "set cool flag ", 0, AV_OPT_TYPE_CONST, {.i64 = TEST_FLAG_COOL}, INT_MIN, INT_MAX, 0, "flags" },
-{"lame", "set lame flag ", 0, AV_OPT_TYPE_CONST, {.i64 = TEST_FLAG_LAME}, INT_MIN, INT_MAX, 0, "flags" },
-{"mu", "set mu flag ", 0, AV_OPT_TYPE_CONST, {.i64 = TEST_FLAG_MU}, INT_MIN, INT_MAX, 0, "flags" },
-{"size", "set size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE,{0}, 0, 0 },
-{"pix_fmt", "set pixfmt", OFFSET(pix_fmt), AV_OPT_TYPE_PIXEL_FMT, {.i64 = AV_PIX_FMT_NONE}, -1, AV_PIX_FMT_NB-1},
-{"sample_fmt", "set samplefmt", OFFSET(sample_fmt), AV_OPT_TYPE_SAMPLE_FMT, {.i64 = AV_SAMPLE_FMT_NONE}, -1, AV_SAMPLE_FMT_NB-1},
-{NULL},
-};
-
-static const char *test_get_name(void *ctx)
-{
- return "test";
-}
-
-static const AVClass test_class = {
- "TestContext",
- test_get_name,
- test_options
-};
-
-int main(void)
-{
- int i;
-
- printf("\nTesting av_set_options_string()\n");
- {
- TestContext test_ctx = { 0 };
- const char *options[] = {
- "",
- ":",
- "=",
- "foo=:",
- ":=foo",
- "=foo",
- "foo=",
- "foo",
- "foo=val",
- "foo==val",
- "toggle=:",
- "string=:",
- "toggle=1 : foo",
- "toggle=100",
- "toggle==1",
- "flags=+mu-lame : num=42: toggle=0",
- "num=42 : string=blahblah",
- "rational=0 : rational=1/2 : rational=1/-1",
- "rational=-1/0",
- "size=1024x768",
- "size=pal",
- "size=bogus",
- "pix_fmt=yuv420p",
- "pix_fmt=2",
- "pix_fmt=bogus",
- "sample_fmt=s16",
- "sample_fmt=2",
- "sample_fmt=bogus",
- };
-
- test_ctx.class = &test_class;
- av_opt_set_defaults(&test_ctx);
- test_ctx.string = av_strdup("default");
-
- av_log_set_level(AV_LOG_DEBUG);
-
- for (i=0; i < FF_ARRAY_ELEMS(options); i++) {
- av_log(&test_ctx, AV_LOG_DEBUG, "Setting options string '%s'\n", options[i]);
- if (av_set_options_string(&test_ctx, options[i], "=", ":") < 0)
- av_log(&test_ctx, AV_LOG_ERROR, "Error setting options string: '%s'\n", options[i]);
- printf("\n");
- }
- av_freep(&test_ctx.string);
- }
-
- printf("\nTesting av_opt_set_from_string()\n");
- {
- TestContext test_ctx = { 0 };
- const char *options[] = {
- "",
- "5",
- "5:hello",
- "5:hello:size=pal",
- "5:size=pal:hello",
- ":",
- "=",
- " 5 : hello : size = pal ",
- "a_very_long_option_name_that_will_need_to_be_ellipsized_around_here=42"
- };
- const char *shorthand[] = { "num", "string", NULL };
-
- test_ctx.class = &test_class;
- av_opt_set_defaults(&test_ctx);
- test_ctx.string = av_strdup("default");
-
- av_log_set_level(AV_LOG_DEBUG);
-
- for (i=0; i < FF_ARRAY_ELEMS(options); i++) {
- av_log(&test_ctx, AV_LOG_DEBUG, "Setting options string '%s'\n", options[i]);
- if (av_opt_set_from_string(&test_ctx, options[i], shorthand, "=", ":") < 0)
- av_log(&test_ctx, AV_LOG_ERROR, "Error setting options string: '%s'\n", options[i]);
- printf("\n");
- }
- av_freep(&test_ctx.string);
- }
-
- return 0;
-}
-
-#endif
diff --git a/src/thirdparty/ffmpeg/libavutil/opt.h b/src/thirdparty/ffmpeg/libavutil/opt.h
deleted file mode 100644
index ae288ecd1..000000000
--- a/src/thirdparty/ffmpeg/libavutil/opt.h
+++ /dev/null
@@ -1,733 +0,0 @@
-/*
- * AVOptions
- * copyright (c) 2005 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
- */
-
-#ifndef AVUTIL_OPT_H
-#define AVUTIL_OPT_H
-
-/**
- * @file
- * AVOptions
- */
-
-#include "rational.h"
-#include "avutil.h"
-#include "dict.h"
-#include "log.h"
-#include "pixfmt.h"
-#include "samplefmt.h"
-
-/**
- * @defgroup avoptions AVOptions
- * @ingroup lavu_data
- * @{
- * AVOptions provide a generic system to declare options on arbitrary structs
- * ("objects"). An option can have a help text, a type and a range of possible
- * values. Options may then be enumerated, read and written to.
- *
- * @section avoptions_implement Implementing AVOptions
- * This section describes how to add AVOptions capabilities to a struct.
- *
- * All AVOptions-related information is stored in an AVClass. Therefore
- * the first member of the struct should be a pointer to an AVClass describing it.
- * The option field of the AVClass must be set to a NULL-terminated static array
- * of AVOptions. Each AVOption must have a non-empty name, a type, a default
- * value and for number-type AVOptions also a range of allowed values. It must
- * also declare an offset in bytes from the start of the struct, where the field
- * associated with this AVOption is located. Other fields in the AVOption struct
- * should also be set when applicable, but are not required.
- *
- * The following example illustrates an AVOptions-enabled struct:
- * @code
- * typedef struct test_struct {
- * AVClass *class;
- * int int_opt;
- * char *str_opt;
- * uint8_t *bin_opt;
- * int bin_len;
- * } test_struct;
- *
- * static const AVOption options[] = {
- * { "test_int", "This is a test option of int type.", offsetof(test_struct, int_opt),
- * AV_OPT_TYPE_INT, { .i64 = -1 }, INT_MIN, INT_MAX },
- * { "test_str", "This is a test option of string type.", offsetof(test_struct, str_opt),
- * AV_OPT_TYPE_STRING },
- * { "test_bin", "This is a test option of binary type.", offsetof(test_struct, bin_opt),
- * AV_OPT_TYPE_BINARY },
- * { NULL },
- * };
- *
- * static const AVClass test_class = {
- * .class_name = "test class",
- * .item_name = av_default_item_name,
- * .option = options,
- * .version = LIBAVUTIL_VERSION_INT,
- * };
- * @endcode
- *
- * Next, when allocating your struct, you must ensure that the AVClass pointer
- * is set to the correct value. Then, av_opt_set_defaults() can be called to
- * initialize defaults. After that the struct is ready to be used with the
- * AVOptions API.
- *
- * When cleaning up, you may use the av_opt_free() function to automatically
- * free all the allocated string and binary options.
- *
- * Continuing with the above example:
- *
- * @code
- * test_struct *alloc_test_struct(void)
- * {
- * test_struct *ret = av_malloc(sizeof(*ret));
- * ret->class = &test_class;
- * av_opt_set_defaults(ret);
- * return ret;
- * }
- * void free_test_struct(test_struct **foo)
- * {
- * av_opt_free(*foo);
- * av_freep(foo);
- * }
- * @endcode
- *
- * @subsection avoptions_implement_nesting Nesting
- * It may happen that an AVOptions-enabled struct contains another
- * AVOptions-enabled struct as a member (e.g. AVCodecContext in
- * libavcodec exports generic options, while its priv_data field exports
- * codec-specific options). In such a case, it is possible to set up the
- * parent struct to export a child's options. To do that, simply
- * implement AVClass.child_next() and AVClass.child_class_next() in the
- * parent struct's AVClass.
- * Assuming that the test_struct from above now also contains a
- * child_struct field:
- *
- * @code
- * typedef struct child_struct {
- * AVClass *class;
- * int flags_opt;
- * } child_struct;
- * static const AVOption child_opts[] = {
- * { "test_flags", "This is a test option of flags type.",
- * offsetof(child_struct, flags_opt), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT_MIN, INT_MAX },
- * { NULL },
- * };
- * static const AVClass child_class = {
- * .class_name = "child class",
- * .item_name = av_default_item_name,
- * .option = child_opts,
- * .version = LIBAVUTIL_VERSION_INT,
- * };
- *
- * void *child_next(void *obj, void *prev)
- * {
- * test_struct *t = obj;
- * if (!prev && t->child_struct)
- * return t->child_struct;
- * return NULL
- * }
- * const AVClass child_class_next(const AVClass *prev)
- * {
- * return prev ? NULL : &child_class;
- * }
- * @endcode
- * Putting child_next() and child_class_next() as defined above into
- * test_class will now make child_struct's options accessible through
- * test_struct (again, proper setup as described above needs to be done on
- * child_struct right after it is created).
- *
- * From the above example it might not be clear why both child_next()
- * and child_class_next() are needed. The distinction is that child_next()
- * iterates over actually existing objects, while child_class_next()
- * iterates over all possible child classes. E.g. if an AVCodecContext
- * was initialized to use a codec which has private options, then its
- * child_next() will return AVCodecContext.priv_data and finish
- * iterating. OTOH child_class_next() on AVCodecContext.av_class will
- * iterate over all available codecs with private options.
- *
- * @subsection avoptions_implement_named_constants Named constants
- * It is possible to create named constants for options. Simply set the unit
- * field of the option the constants should apply to to a string and
- * create the constants themselves as options of type AV_OPT_TYPE_CONST
- * with their unit field set to the same string.
- * Their default_val field should contain the value of the named
- * constant.
- * For example, to add some named constants for the test_flags option
- * above, put the following into the child_opts array:
- * @code
- * { "test_flags", "This is a test option of flags type.",
- * offsetof(child_struct, flags_opt), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT_MIN, INT_MAX, "test_unit" },
- * { "flag1", "This is a flag with value 16", 0, AV_OPT_TYPE_CONST, { .i64 = 16 }, 0, 0, "test_unit" },
- * @endcode
- *
- * @section avoptions_use Using AVOptions
- * This section deals with accessing options in an AVOptions-enabled struct.
- * Such structs in FFmpeg are e.g. AVCodecContext in libavcodec or
- * AVFormatContext in libavformat.
- *
- * @subsection avoptions_use_examine Examining AVOptions
- * The basic functions for examining options are av_opt_next(), which iterates
- * over all options defined for one object, and av_opt_find(), which searches
- * for an option with the given name.
- *
- * The situation is more complicated with nesting. An AVOptions-enabled struct
- * may have AVOptions-enabled children. Passing the AV_OPT_SEARCH_CHILDREN flag
- * to av_opt_find() will make the function search children recursively.
- *
- * For enumerating there are basically two cases. The first is when you want to
- * get all options that may potentially exist on the struct and its children
- * (e.g. when constructing documentation). In that case you should call
- * av_opt_child_class_next() recursively on the parent struct's AVClass. The
- * second case is when you have an already initialized struct with all its
- * children and you want to get all options that can be actually written or read
- * from it. In that case you should call av_opt_child_next() recursively (and
- * av_opt_next() on each result).
- *
- * @subsection avoptions_use_get_set Reading and writing AVOptions
- * When setting options, you often have a string read directly from the
- * user. In such a case, simply passing it to av_opt_set() is enough. For
- * non-string type options, av_opt_set() will parse the string according to the
- * option type.
- *
- * Similarly av_opt_get() will read any option type and convert it to a string
- * which will be returned. Do not forget that the string is allocated, so you
- * have to free it with av_free().
- *
- * In some cases it may be more convenient to put all options into an
- * AVDictionary and call av_opt_set_dict() on it. A specific case of this
- * are the format/codec open functions in lavf/lavc which take a dictionary
- * filled with option as a parameter. This allows to set some options
- * that cannot be set otherwise, since e.g. the input file format is not known
- * before the file is actually opened.
- */
-
-enum AVOptionType{
- AV_OPT_TYPE_FLAGS,
- AV_OPT_TYPE_INT,
- AV_OPT_TYPE_INT64,
- AV_OPT_TYPE_DOUBLE,
- AV_OPT_TYPE_FLOAT,
- AV_OPT_TYPE_STRING,
- AV_OPT_TYPE_RATIONAL,
- AV_OPT_TYPE_BINARY, ///< offset must point to a pointer immediately followed by an int for the length
- AV_OPT_TYPE_CONST = 128,
- AV_OPT_TYPE_IMAGE_SIZE = MKBETAG('S','I','Z','E'), ///< offset must point to two consecutive integers
- AV_OPT_TYPE_PIXEL_FMT = MKBETAG('P','F','M','T'),
- AV_OPT_TYPE_SAMPLE_FMT = MKBETAG('S','F','M','T'),
-#if FF_API_OLD_AVOPTIONS
- FF_OPT_TYPE_FLAGS = 0,
- FF_OPT_TYPE_INT,
- FF_OPT_TYPE_INT64,
- FF_OPT_TYPE_DOUBLE,
- FF_OPT_TYPE_FLOAT,
- FF_OPT_TYPE_STRING,
- FF_OPT_TYPE_RATIONAL,
- FF_OPT_TYPE_BINARY, ///< offset must point to a pointer immediately followed by an int for the length
- FF_OPT_TYPE_CONST=128,
-#endif
-};
-
-/**
- * AVOption
- */
-typedef struct AVOption {
- const char *name;
-
- /**
- * short English help text
- * @todo What about other languages?
- */
- const char *help;
-
- /**
- * The offset relative to the context structure where the option
- * value is stored. It should be 0 for named constants.
- */
- int offset;
- enum AVOptionType type;
-
- /**
- * the default value for scalar options
- */
- union {
- int64_t i64;
- double dbl;
- const char *str;
- /* TODO those are unused now */
- AVRational q;
- } default_val;
- double min; ///< minimum valid value for the option
- double max; ///< maximum valid value for the option
-
- int flags;
-#define AV_OPT_FLAG_ENCODING_PARAM 1 ///< a generic parameter which can be set by the user for muxing or encoding
-#define AV_OPT_FLAG_DECODING_PARAM 2 ///< a generic parameter which can be set by the user for demuxing or decoding
-#define AV_OPT_FLAG_METADATA 4 ///< some data extracted or inserted into the file like title, comment, ...
-#define AV_OPT_FLAG_AUDIO_PARAM 8
-#define AV_OPT_FLAG_VIDEO_PARAM 16
-#define AV_OPT_FLAG_SUBTITLE_PARAM 32
-#define AV_OPT_FLAG_FILTERING_PARAM (1<<16) ///< a generic parameter which can be set by the user for filtering
-//FIXME think about enc-audio, ... style flags
-
- /**
- * The logical unit to which the option belongs. Non-constant
- * options and corresponding named constants share the same
- * unit. May be NULL.
- */
- const char *unit;
-} AVOption;
-
-/**
- * A single allowed range of values, or a single allowed value.
- */
-typedef struct AVOptionRange {
- const char *str;
- double value_min, value_max; ///< For string ranges this represents the min/max length, for dimensions this represents the min/max pixel count
- double component_min, component_max; ///< For string this represents the unicode range for chars, 0-127 limits to ASCII
- int is_range; ///< if set to 1 the struct encodes a range, if set to 0 a single value
-} AVOptionRange;
-
-/**
- * List of AVOptionRange structs
- */
-typedef struct AVOptionRanges {
- AVOptionRange **range;
- int nb_ranges;
-} AVOptionRanges;
-
-
-#if FF_API_FIND_OPT
-/**
- * Look for an option in obj. Look only for the options which
- * have the flags set as specified in mask and flags (that is,
- * for which it is the case that opt->flags & mask == flags).
- *
- * @param[in] obj a pointer to a struct whose first element is a
- * pointer to an AVClass
- * @param[in] name the name of the option to look for
- * @param[in] unit the unit of the option to look for, or any if NULL
- * @return a pointer to the option found, or NULL if no option
- * has been found
- *
- * @deprecated use av_opt_find.
- */
-attribute_deprecated
-const AVOption *av_find_opt(void *obj, const char *name, const char *unit, int mask, int flags);
-#endif
-
-#if FF_API_OLD_AVOPTIONS
-/**
- * Set the field of obj with the given name to value.
- *
- * @param[in] obj A struct whose first element is a pointer to an
- * AVClass.
- * @param[in] name the name of the field to set
- * @param[in] val The value to set. If the field is not of a string
- * type, then the given string is parsed.
- * SI postfixes and some named scalars are supported.
- * If the field is of a numeric type, it has to be a numeric or named
- * scalar. Behavior with more than one scalar and +- infix operators
- * is undefined.
- * If the field is of a flags type, it has to be a sequence of numeric
- * scalars or named flags separated by '+' or '-'. Prefixing a flag
- * with '+' causes it to be set without affecting the other flags;
- * similarly, '-' unsets a flag.
- * @param[out] o_out if non-NULL put here a pointer to the AVOption
- * found
- * @param alloc this parameter is currently ignored
- * @return 0 if the value has been set, or an AVERROR code in case of
- * error:
- * AVERROR_OPTION_NOT_FOUND if no matching option exists
- * AVERROR(ERANGE) if the value is out of range
- * AVERROR(EINVAL) if the value is not valid
- * @deprecated use av_opt_set()
- */
-attribute_deprecated
-int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out);
-
-attribute_deprecated const AVOption *av_set_double(void *obj, const char *name, double n);
-attribute_deprecated const AVOption *av_set_q(void *obj, const char *name, AVRational n);
-attribute_deprecated const AVOption *av_set_int(void *obj, const char *name, int64_t n);
-
-double av_get_double(void *obj, const char *name, const AVOption **o_out);
-AVRational av_get_q(void *obj, const char *name, const AVOption **o_out);
-int64_t av_get_int(void *obj, const char *name, const AVOption **o_out);
-attribute_deprecated const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len);
-attribute_deprecated const AVOption *av_next_option(void *obj, const AVOption *last);
-#endif
-
-/**
- * Show the obj options.
- *
- * @param req_flags requested flags for the options to show. Show only the
- * options for which it is opt->flags & req_flags.
- * @param rej_flags rejected flags for the options to show. Show only the
- * options for which it is !(opt->flags & req_flags).
- * @param av_log_obj log context to use for showing the options
- */
-int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags);
-
-/**
- * Set the values of all AVOption fields to their default values.
- *
- * @param s an AVOption-enabled struct (its first member must be a pointer to AVClass)
- */
-void av_opt_set_defaults(void *s);
-
-#if FF_API_OLD_AVOPTIONS
-attribute_deprecated
-void av_opt_set_defaults2(void *s, int mask, int flags);
-#endif
-
-/**
- * Parse the key/value pairs list in opts. For each key/value pair
- * found, stores the value in the field in ctx that is named like the
- * key. ctx must be an AVClass context, storing is done using
- * AVOptions.
- *
- * @param opts options string to parse, may be NULL
- * @param key_val_sep a 0-terminated list of characters used to
- * separate key from value
- * @param pairs_sep a 0-terminated list of characters used to separate
- * two pairs from each other
- * @return the number of successfully set key/value pairs, or a negative
- * value corresponding to an AVERROR code in case of error:
- * AVERROR(EINVAL) if opts cannot be parsed,
- * the error code issued by av_set_string3() if a key/value pair
- * cannot be set
- */
-int av_set_options_string(void *ctx, const char *opts,
- const char *key_val_sep, const char *pairs_sep);
-
-/**
- * Parse the key-value pairs list in opts. For each key=value pair found,
- * set the value of the corresponding option in ctx.
- *
- * @param ctx the AVClass object to set options on
- * @param opts the options string, key-value pairs separated by a
- * delimiter
- * @param shorthand a NULL-terminated array of options names for shorthand
- * notation: if the first field in opts has no key part,
- * the key is taken from the first element of shorthand;
- * then again for the second, etc., until either opts is
- * finished, shorthand is finished or a named option is
- * found; after that, all options must be named
- * @param key_val_sep a 0-terminated list of characters used to separate
- * key from value, for example '='
- * @param pairs_sep a 0-terminated list of characters used to separate
- * two pairs from each other, for example ':' or ','
- * @return the number of successfully set key=value pairs, or a negative
- * value corresponding to an AVERROR code in case of error:
- * AVERROR(EINVAL) if opts cannot be parsed,
- * the error code issued by av_set_string3() if a key/value pair
- * cannot be set
- *
- * Options names must use only the following characters: a-z A-Z 0-9 - . / _
- * Separators must use characters distinct from option names and from each
- * other.
- */
-int av_opt_set_from_string(void *ctx, const char *opts,
- const char *const *shorthand,
- const char *key_val_sep, const char *pairs_sep);
-/**
- * Free all string and binary options in obj.
- */
-void av_opt_free(void *obj);
-
-/**
- * Check whether a particular flag is set in a flags field.
- *
- * @param field_name the name of the flag field option
- * @param flag_name the name of the flag to check
- * @return non-zero if the flag is set, zero if the flag isn't set,
- * isn't of the right type, or the flags field doesn't exist.
- */
-int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name);
-
-/**
- * Set all the options from a given dictionary on an object.
- *
- * @param obj a struct whose first element is a pointer to AVClass
- * @param options options to process. This dictionary will be freed and replaced
- * by a new one containing all options not found in obj.
- * Of course this new dictionary needs to be freed by caller
- * with av_dict_free().
- *
- * @return 0 on success, a negative AVERROR if some option was found in obj,
- * but could not be set.
- *
- * @see av_dict_copy()
- */
-int av_opt_set_dict(void *obj, struct AVDictionary **options);
-
-/**
- * Extract a key-value pair from the beginning of a string.
- *
- * @param ropts pointer to the options string, will be updated to
- * point to the rest of the string (one of the pairs_sep
- * or the final NUL)
- * @param key_val_sep a 0-terminated list of characters used to separate
- * key from value, for example '='
- * @param pairs_sep a 0-terminated list of characters used to separate
- * two pairs from each other, for example ':' or ','
- * @param flags flags; see the AV_OPT_FLAG_* values below
- * @param rkey parsed key; must be freed using av_free()
- * @param rval parsed value; must be freed using av_free()
- *
- * @return >=0 for success, or a negative value corresponding to an
- * AVERROR code in case of error; in particular:
- * AVERROR(EINVAL) if no key is present
- *
- */
-int av_opt_get_key_value(const char **ropts,
- const char *key_val_sep, const char *pairs_sep,
- unsigned flags,
- char **rkey, char **rval);
-
-enum {
-
- /**
- * Accept to parse a value without a key; the key will then be returned
- * as NULL.
- */
- AV_OPT_FLAG_IMPLICIT_KEY = 1,
-};
-
-/**
- * @defgroup opt_eval_funcs Evaluating option strings
- * @{
- * This group of functions can be used to evaluate option strings
- * and get numbers out of them. They do the same thing as av_opt_set(),
- * except the result is written into the caller-supplied pointer.
- *
- * @param obj a struct whose first element is a pointer to AVClass.
- * @param o an option for which the string is to be evaluated.
- * @param val string to be evaluated.
- * @param *_out value of the string will be written here.
- *
- * @return 0 on success, a negative number on failure.
- */
-int av_opt_eval_flags (void *obj, const AVOption *o, const char *val, int *flags_out);
-int av_opt_eval_int (void *obj, const AVOption *o, const char *val, int *int_out);
-int av_opt_eval_int64 (void *obj, const AVOption *o, const char *val, int64_t *int64_out);
-int av_opt_eval_float (void *obj, const AVOption *o, const char *val, float *float_out);
-int av_opt_eval_double(void *obj, const AVOption *o, const char *val, double *double_out);
-int av_opt_eval_q (void *obj, const AVOption *o, const char *val, AVRational *q_out);
-/**
- * @}
- */
-
-#define AV_OPT_SEARCH_CHILDREN 0x0001 /**< Search in possible children of the
- given object first. */
-/**
- * The obj passed to av_opt_find() is fake -- only a double pointer to AVClass
- * instead of a required pointer to a struct containing AVClass. This is
- * useful for searching for options without needing to allocate the corresponding
- * object.
- */
-#define AV_OPT_SEARCH_FAKE_OBJ 0x0002
-
-/**
- * Look for an option in an object. Consider only options which
- * have all the specified flags set.
- *
- * @param[in] obj A pointer to a struct whose first element is a
- * pointer to an AVClass.
- * Alternatively a double pointer to an AVClass, if
- * AV_OPT_SEARCH_FAKE_OBJ search flag is set.
- * @param[in] name The name of the option to look for.
- * @param[in] unit When searching for named constants, name of the unit
- * it belongs to.
- * @param opt_flags Find only options with all the specified flags set (AV_OPT_FLAG).
- * @param search_flags A combination of AV_OPT_SEARCH_*.
- *
- * @return A pointer to the option found, or NULL if no option
- * was found.
- *
- * @note Options found with AV_OPT_SEARCH_CHILDREN flag may not be settable
- * directly with av_set_string3(). Use special calls which take an options
- * AVDictionary (e.g. avformat_open_input()) to set options found with this
- * flag.
- */
-const AVOption *av_opt_find(void *obj, const char *name, const char *unit,
- int opt_flags, int search_flags);
-
-/**
- * Look for an option in an object. Consider only options which
- * have all the specified flags set.
- *
- * @param[in] obj A pointer to a struct whose first element is a
- * pointer to an AVClass.
- * Alternatively a double pointer to an AVClass, if
- * AV_OPT_SEARCH_FAKE_OBJ search flag is set.
- * @param[in] name The name of the option to look for.
- * @param[in] unit When searching for named constants, name of the unit
- * it belongs to.
- * @param opt_flags Find only options with all the specified flags set (AV_OPT_FLAG).
- * @param search_flags A combination of AV_OPT_SEARCH_*.
- * @param[out] target_obj if non-NULL, an object to which the option belongs will be
- * written here. It may be different from obj if AV_OPT_SEARCH_CHILDREN is present
- * in search_flags. This parameter is ignored if search_flags contain
- * AV_OPT_SEARCH_FAKE_OBJ.
- *
- * @return A pointer to the option found, or NULL if no option
- * was found.
- */
-const AVOption *av_opt_find2(void *obj, const char *name, const char *unit,
- int opt_flags, int search_flags, void **target_obj);
-
-/**
- * Iterate over all AVOptions belonging to obj.
- *
- * @param obj an AVOptions-enabled struct or a double pointer to an
- * AVClass describing it.
- * @param prev result of the previous call to av_opt_next() on this object
- * or NULL
- * @return next AVOption or NULL
- */
-const AVOption *av_opt_next(void *obj, const AVOption *prev);
-
-/**
- * Iterate over AVOptions-enabled children of obj.
- *
- * @param prev result of a previous call to this function or NULL
- * @return next AVOptions-enabled child or NULL
- */
-void *av_opt_child_next(void *obj, void *prev);
-
-/**
- * Iterate over potential AVOptions-enabled children of parent.
- *
- * @param prev result of a previous call to this function or NULL
- * @return AVClass corresponding to next potential child or NULL
- */
-const AVClass *av_opt_child_class_next(const AVClass *parent, const AVClass *prev);
-
-/**
- * @defgroup opt_set_funcs Option setting functions
- * @{
- * Those functions set the field of obj with the given name to value.
- *
- * @param[in] obj A struct whose first element is a pointer to an AVClass.
- * @param[in] name the name of the field to set
- * @param[in] val The value to set. In case of av_opt_set() if the field is not
- * of a string type, then the given string is parsed.
- * SI postfixes and some named scalars are supported.
- * If the field is of a numeric type, it has to be a numeric or named
- * scalar. Behavior with more than one scalar and +- infix operators
- * is undefined.
- * If the field is of a flags type, it has to be a sequence of numeric
- * scalars or named flags separated by '+' or '-'. Prefixing a flag
- * with '+' causes it to be set without affecting the other flags;
- * similarly, '-' unsets a flag.
- * @param search_flags flags passed to av_opt_find2. I.e. if AV_OPT_SEARCH_CHILDREN
- * is passed here, then the option may be set on a child of obj.
- *
- * @return 0 if the value has been set, or an AVERROR code in case of
- * error:
- * AVERROR_OPTION_NOT_FOUND if no matching option exists
- * AVERROR(ERANGE) if the value is out of range
- * AVERROR(EINVAL) if the value is not valid
- */
-int av_opt_set (void *obj, const char *name, const char *val, int search_flags);
-int av_opt_set_int (void *obj, const char *name, int64_t val, int search_flags);
-int av_opt_set_double(void *obj, const char *name, double val, int search_flags);
-int av_opt_set_q (void *obj, const char *name, AVRational val, int search_flags);
-int av_opt_set_bin (void *obj, const char *name, const uint8_t *val, int size, int search_flags);
-int av_opt_set_image_size(void *obj, const char *name, int w, int h, int search_flags);
-int av_opt_set_pixel_fmt (void *obj, const char *name, enum AVPixelFormat fmt, int search_flags);
-int av_opt_set_sample_fmt(void *obj, const char *name, enum AVSampleFormat fmt, int search_flags);
-/**
- * @}
- */
-
-/**
- * @defgroup opt_get_funcs Option getting functions
- * @{
- * Those functions get a value of the option with the given name from an object.
- *
- * @param[in] obj a struct whose first element is a pointer to an AVClass.
- * @param[in] name name of the option to get.
- * @param[in] search_flags flags passed to av_opt_find2. I.e. if AV_OPT_SEARCH_CHILDREN
- * is passed here, then the option may be found in a child of obj.
- * @param[out] out_val value of the option will be written here
- * @return 0 on success, a negative error code otherwise
- */
-/**
- * @note the returned string will av_malloc()ed and must be av_free()ed by the caller
- */
-int av_opt_get (void *obj, const char *name, int search_flags, uint8_t **out_val);
-int av_opt_get_int (void *obj, const char *name, int search_flags, int64_t *out_val);
-int av_opt_get_double(void *obj, const char *name, int search_flags, double *out_val);
-int av_opt_get_q (void *obj, const char *name, int search_flags, AVRational *out_val);
-int av_opt_get_image_size(void *obj, const char *name, int search_flags, int *w_out, int *h_out);
-int av_opt_get_pixel_fmt (void *obj, const char *name, int search_flags, enum AVPixelFormat *out_fmt);
-int av_opt_get_sample_fmt(void *obj, const char *name, int search_flags, enum AVSampleFormat *out_fmt);
-/**
- * @}
- */
-/**
- * Gets a pointer to the requested field in a struct.
- * This function allows accessing a struct even when its fields are moved or
- * renamed since the application making the access has been compiled,
- *
- * @returns a pointer to the field, it can be cast to the correct type and read
- * or written to.
- */
-void *av_opt_ptr(const AVClass *avclass, void *obj, const char *name);
-
-/**
- * Free an AVOptionRanges struct and set it to NULL.
- */
-void av_opt_freep_ranges(AVOptionRanges **ranges);
-
-/**
- * Get a list of allowed ranges for the given option.
- *
- * The returned list may depend on other fields in obj like for example profile.
- *
- * @param flags is a bitmask of flags, undefined flags should not be set and should be ignored
- * AV_OPT_SEARCH_FAKE_OBJ indicates that the obj is a double pointer to a AVClass instead of a full instance
- *
- * The result must be freed with av_opt_freep_ranges.
- *
- * @return >= 0 on success, a negative errro code otherwise
- */
-int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags);
-
-/**
- * Get a default list of allowed ranges for the given option.
- *
- * This list is constructed without using the AVClass.query_ranges() callback
- * and can be used as fallback from within the callback.
- *
- * @param flags is a bitmask of flags, undefined flags should not be set and should be ignored
- * AV_OPT_SEARCH_FAKE_OBJ indicates that the obj is a double pointer to a AVClass instead of a full instance
- *
- * The result must be freed with av_opt_free_ranges.
- *
- * @return >= 0 on success, a negative errro code otherwise
- */
-int av_opt_query_ranges_default(AVOptionRanges **, void *obj, const char *key, int flags);
-
-/**
- * @}
- */
-
-#endif /* AVUTIL_OPT_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/parseutils.c b/src/thirdparty/ffmpeg/libavutil/parseutils.c
deleted file mode 100644
index 303aa6bd2..000000000
--- a/src/thirdparty/ffmpeg/libavutil/parseutils.c
+++ /dev/null
@@ -1,865 +0,0 @@
-/*
- * 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
- * misc parsing utilities
- */
-
-#include <time.h>
-
-#include "avstring.h"
-#include "avutil.h"
-#include "common.h"
-#include "eval.h"
-#include "log.h"
-#include "random_seed.h"
-#include "parseutils.h"
-
-#ifdef TEST
-
-#define av_get_random_seed av_get_random_seed_deterministic
-static uint32_t av_get_random_seed_deterministic(void);
-
-#define time(t) 1331972053
-
-#endif
-
-int av_parse_ratio(AVRational *q, const char *str, int max,
- int log_offset, void *log_ctx)
-{
- char c;
- int ret;
-
- if (sscanf(str, "%d:%d%c", &q->num, &q->den, &c) != 2) {
- double d;
- ret = av_expr_parse_and_eval(&d, str, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, log_offset, log_ctx);
- if (ret < 0)
- return ret;
- *q = av_d2q(d, max);
- } else {
- av_reduce(&q->num, &q->den, q->num, q->den, max);
- }
-
- return 0;
-}
-
-typedef struct {
- const char *abbr;
- int width, height;
-} VideoSizeAbbr;
-
-typedef struct {
- const char *abbr;
- AVRational rate;
-} VideoRateAbbr;
-
-static const VideoSizeAbbr video_size_abbrs[] = {
- { "ntsc", 720, 480 },
- { "pal", 720, 576 },
- { "qntsc", 352, 240 }, /* VCD compliant NTSC */
- { "qpal", 352, 288 }, /* VCD compliant PAL */
- { "sntsc", 640, 480 }, /* square pixel NTSC */
- { "spal", 768, 576 }, /* square pixel PAL */
- { "film", 352, 240 },
- { "ntsc-film", 352, 240 },
- { "sqcif", 128, 96 },
- { "qcif", 176, 144 },
- { "cif", 352, 288 },
- { "4cif", 704, 576 },
- { "16cif", 1408,1152 },
- { "qqvga", 160, 120 },
- { "qvga", 320, 240 },
- { "vga", 640, 480 },
- { "svga", 800, 600 },
- { "xga", 1024, 768 },
- { "uxga", 1600,1200 },
- { "qxga", 2048,1536 },
- { "sxga", 1280,1024 },
- { "qsxga", 2560,2048 },
- { "hsxga", 5120,4096 },
- { "wvga", 852, 480 },
- { "wxga", 1366, 768 },
- { "wsxga", 1600,1024 },
- { "wuxga", 1920,1200 },
- { "woxga", 2560,1600 },
- { "wqsxga", 3200,2048 },
- { "wquxga", 3840,2400 },
- { "whsxga", 6400,4096 },
- { "whuxga", 7680,4800 },
- { "cga", 320, 200 },
- { "ega", 640, 350 },
- { "hd480", 852, 480 },
- { "hd720", 1280, 720 },
- { "hd1080", 1920,1080 },
- { "2k", 2048,1080 }, /* Digital Cinema System Specification */
- { "2kflat", 1998,1080 },
- { "2kscope", 2048, 858 },
- { "4k", 4096,2160 }, /* Digital Cinema System Specification */
- { "4kflat", 3996,2160 },
- { "4kscope", 4096,1716 },
-};
-
-static const VideoRateAbbr video_rate_abbrs[]= {
- { "ntsc", { 30000, 1001 } },
- { "pal", { 25, 1 } },
- { "qntsc", { 30000, 1001 } }, /* VCD compliant NTSC */
- { "qpal", { 25, 1 } }, /* VCD compliant PAL */
- { "sntsc", { 30000, 1001 } }, /* square pixel NTSC */
- { "spal", { 25, 1 } }, /* square pixel PAL */
- { "film", { 24, 1 } },
- { "ntsc-film", { 24000, 1001 } },
-};
-
-int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str)
-{
- int i;
- int n = FF_ARRAY_ELEMS(video_size_abbrs);
- const char *p;
- int width = 0, height = 0;
-
- for (i = 0; i < n; i++) {
- if (!strcmp(video_size_abbrs[i].abbr, str)) {
- width = video_size_abbrs[i].width;
- height = video_size_abbrs[i].height;
- break;
- }
- }
- if (i == n) {
- width = strtol(str, (void*)&p, 10);
- if (*p)
- p++;
- height = strtol(p, (void*)&p, 10);
-
- /* trailing extraneous data detected, like in 123x345foobar */
- if (*p)
- return AVERROR(EINVAL);
- }
- if (width <= 0 || height <= 0)
- return AVERROR(EINVAL);
- *width_ptr = width;
- *height_ptr = height;
- return 0;
-}
-
-int av_parse_video_rate(AVRational *rate, const char *arg)
-{
- int i, ret;
- int n = FF_ARRAY_ELEMS(video_rate_abbrs);
-
- /* First, we check our abbreviation table */
- for (i = 0; i < n; ++i)
- if (!strcmp(video_rate_abbrs[i].abbr, arg)) {
- *rate = video_rate_abbrs[i].rate;
- return 0;
- }
-
- /* Then, we try to parse it as fraction */
- if ((ret = av_parse_ratio_quiet(rate, arg, 1001000)) < 0)
- return ret;
- if (rate->num <= 0 || rate->den <= 0)
- return AVERROR(EINVAL);
- return 0;
-}
-
-typedef struct {
- const char *name; ///< a string representing the name of the color
- uint8_t rgb_color[3]; ///< RGB values for the color
-} ColorEntry;
-
-static const ColorEntry color_table[] = {
- { "AliceBlue", { 0xF0, 0xF8, 0xFF } },
- { "AntiqueWhite", { 0xFA, 0xEB, 0xD7 } },
- { "Aqua", { 0x00, 0xFF, 0xFF } },
- { "Aquamarine", { 0x7F, 0xFF, 0xD4 } },
- { "Azure", { 0xF0, 0xFF, 0xFF } },
- { "Beige", { 0xF5, 0xF5, 0xDC } },
- { "Bisque", { 0xFF, 0xE4, 0xC4 } },
- { "Black", { 0x00, 0x00, 0x00 } },
- { "BlanchedAlmond", { 0xFF, 0xEB, 0xCD } },
- { "Blue", { 0x00, 0x00, 0xFF } },
- { "BlueViolet", { 0x8A, 0x2B, 0xE2 } },
- { "Brown", { 0xA5, 0x2A, 0x2A } },
- { "BurlyWood", { 0xDE, 0xB8, 0x87 } },
- { "CadetBlue", { 0x5F, 0x9E, 0xA0 } },
- { "Chartreuse", { 0x7F, 0xFF, 0x00 } },
- { "Chocolate", { 0xD2, 0x69, 0x1E } },
- { "Coral", { 0xFF, 0x7F, 0x50 } },
- { "CornflowerBlue", { 0x64, 0x95, 0xED } },
- { "Cornsilk", { 0xFF, 0xF8, 0xDC } },
- { "Crimson", { 0xDC, 0x14, 0x3C } },
- { "Cyan", { 0x00, 0xFF, 0xFF } },
- { "DarkBlue", { 0x00, 0x00, 0x8B } },
- { "DarkCyan", { 0x00, 0x8B, 0x8B } },
- { "DarkGoldenRod", { 0xB8, 0x86, 0x0B } },
- { "DarkGray", { 0xA9, 0xA9, 0xA9 } },
- { "DarkGreen", { 0x00, 0x64, 0x00 } },
- { "DarkKhaki", { 0xBD, 0xB7, 0x6B } },
- { "DarkMagenta", { 0x8B, 0x00, 0x8B } },
- { "DarkOliveGreen", { 0x55, 0x6B, 0x2F } },
- { "Darkorange", { 0xFF, 0x8C, 0x00 } },
- { "DarkOrchid", { 0x99, 0x32, 0xCC } },
- { "DarkRed", { 0x8B, 0x00, 0x00 } },
- { "DarkSalmon", { 0xE9, 0x96, 0x7A } },
- { "DarkSeaGreen", { 0x8F, 0xBC, 0x8F } },
- { "DarkSlateBlue", { 0x48, 0x3D, 0x8B } },
- { "DarkSlateGray", { 0x2F, 0x4F, 0x4F } },
- { "DarkTurquoise", { 0x00, 0xCE, 0xD1 } },
- { "DarkViolet", { 0x94, 0x00, 0xD3 } },
- { "DeepPink", { 0xFF, 0x14, 0x93 } },
- { "DeepSkyBlue", { 0x00, 0xBF, 0xFF } },
- { "DimGray", { 0x69, 0x69, 0x69 } },
- { "DodgerBlue", { 0x1E, 0x90, 0xFF } },
- { "FireBrick", { 0xB2, 0x22, 0x22 } },
- { "FloralWhite", { 0xFF, 0xFA, 0xF0 } },
- { "ForestGreen", { 0x22, 0x8B, 0x22 } },
- { "Fuchsia", { 0xFF, 0x00, 0xFF } },
- { "Gainsboro", { 0xDC, 0xDC, 0xDC } },
- { "GhostWhite", { 0xF8, 0xF8, 0xFF } },
- { "Gold", { 0xFF, 0xD7, 0x00 } },
- { "GoldenRod", { 0xDA, 0xA5, 0x20 } },
- { "Gray", { 0x80, 0x80, 0x80 } },
- { "Green", { 0x00, 0x80, 0x00 } },
- { "GreenYellow", { 0xAD, 0xFF, 0x2F } },
- { "HoneyDew", { 0xF0, 0xFF, 0xF0 } },
- { "HotPink", { 0xFF, 0x69, 0xB4 } },
- { "IndianRed", { 0xCD, 0x5C, 0x5C } },
- { "Indigo", { 0x4B, 0x00, 0x82 } },
- { "Ivory", { 0xFF, 0xFF, 0xF0 } },
- { "Khaki", { 0xF0, 0xE6, 0x8C } },
- { "Lavender", { 0xE6, 0xE6, 0xFA } },
- { "LavenderBlush", { 0xFF, 0xF0, 0xF5 } },
- { "LawnGreen", { 0x7C, 0xFC, 0x00 } },
- { "LemonChiffon", { 0xFF, 0xFA, 0xCD } },
- { "LightBlue", { 0xAD, 0xD8, 0xE6 } },
- { "LightCoral", { 0xF0, 0x80, 0x80 } },
- { "LightCyan", { 0xE0, 0xFF, 0xFF } },
- { "LightGoldenRodYellow", { 0xFA, 0xFA, 0xD2 } },
- { "LightGreen", { 0x90, 0xEE, 0x90 } },
- { "LightGrey", { 0xD3, 0xD3, 0xD3 } },
- { "LightPink", { 0xFF, 0xB6, 0xC1 } },
- { "LightSalmon", { 0xFF, 0xA0, 0x7A } },
- { "LightSeaGreen", { 0x20, 0xB2, 0xAA } },
- { "LightSkyBlue", { 0x87, 0xCE, 0xFA } },
- { "LightSlateGray", { 0x77, 0x88, 0x99 } },
- { "LightSteelBlue", { 0xB0, 0xC4, 0xDE } },
- { "LightYellow", { 0xFF, 0xFF, 0xE0 } },
- { "Lime", { 0x00, 0xFF, 0x00 } },
- { "LimeGreen", { 0x32, 0xCD, 0x32 } },
- { "Linen", { 0xFA, 0xF0, 0xE6 } },
- { "Magenta", { 0xFF, 0x00, 0xFF } },
- { "Maroon", { 0x80, 0x00, 0x00 } },
- { "MediumAquaMarine", { 0x66, 0xCD, 0xAA } },
- { "MediumBlue", { 0x00, 0x00, 0xCD } },
- { "MediumOrchid", { 0xBA, 0x55, 0xD3 } },
- { "MediumPurple", { 0x93, 0x70, 0xD8 } },
- { "MediumSeaGreen", { 0x3C, 0xB3, 0x71 } },
- { "MediumSlateBlue", { 0x7B, 0x68, 0xEE } },
- { "MediumSpringGreen", { 0x00, 0xFA, 0x9A } },
- { "MediumTurquoise", { 0x48, 0xD1, 0xCC } },
- { "MediumVioletRed", { 0xC7, 0x15, 0x85 } },
- { "MidnightBlue", { 0x19, 0x19, 0x70 } },
- { "MintCream", { 0xF5, 0xFF, 0xFA } },
- { "MistyRose", { 0xFF, 0xE4, 0xE1 } },
- { "Moccasin", { 0xFF, 0xE4, 0xB5 } },
- { "NavajoWhite", { 0xFF, 0xDE, 0xAD } },
- { "Navy", { 0x00, 0x00, 0x80 } },
- { "OldLace", { 0xFD, 0xF5, 0xE6 } },
- { "Olive", { 0x80, 0x80, 0x00 } },
- { "OliveDrab", { 0x6B, 0x8E, 0x23 } },
- { "Orange", { 0xFF, 0xA5, 0x00 } },
- { "OrangeRed", { 0xFF, 0x45, 0x00 } },
- { "Orchid", { 0xDA, 0x70, 0xD6 } },
- { "PaleGoldenRod", { 0xEE, 0xE8, 0xAA } },
- { "PaleGreen", { 0x98, 0xFB, 0x98 } },
- { "PaleTurquoise", { 0xAF, 0xEE, 0xEE } },
- { "PaleVioletRed", { 0xD8, 0x70, 0x93 } },
- { "PapayaWhip", { 0xFF, 0xEF, 0xD5 } },
- { "PeachPuff", { 0xFF, 0xDA, 0xB9 } },
- { "Peru", { 0xCD, 0x85, 0x3F } },
- { "Pink", { 0xFF, 0xC0, 0xCB } },
- { "Plum", { 0xDD, 0xA0, 0xDD } },
- { "PowderBlue", { 0xB0, 0xE0, 0xE6 } },
- { "Purple", { 0x80, 0x00, 0x80 } },
- { "Red", { 0xFF, 0x00, 0x00 } },
- { "RosyBrown", { 0xBC, 0x8F, 0x8F } },
- { "RoyalBlue", { 0x41, 0x69, 0xE1 } },
- { "SaddleBrown", { 0x8B, 0x45, 0x13 } },
- { "Salmon", { 0xFA, 0x80, 0x72 } },
- { "SandyBrown", { 0xF4, 0xA4, 0x60 } },
- { "SeaGreen", { 0x2E, 0x8B, 0x57 } },
- { "SeaShell", { 0xFF, 0xF5, 0xEE } },
- { "Sienna", { 0xA0, 0x52, 0x2D } },
- { "Silver", { 0xC0, 0xC0, 0xC0 } },
- { "SkyBlue", { 0x87, 0xCE, 0xEB } },
- { "SlateBlue", { 0x6A, 0x5A, 0xCD } },
- { "SlateGray", { 0x70, 0x80, 0x90 } },
- { "Snow", { 0xFF, 0xFA, 0xFA } },
- { "SpringGreen", { 0x00, 0xFF, 0x7F } },
- { "SteelBlue", { 0x46, 0x82, 0xB4 } },
- { "Tan", { 0xD2, 0xB4, 0x8C } },
- { "Teal", { 0x00, 0x80, 0x80 } },
- { "Thistle", { 0xD8, 0xBF, 0xD8 } },
- { "Tomato", { 0xFF, 0x63, 0x47 } },
- { "Turquoise", { 0x40, 0xE0, 0xD0 } },
- { "Violet", { 0xEE, 0x82, 0xEE } },
- { "Wheat", { 0xF5, 0xDE, 0xB3 } },
- { "White", { 0xFF, 0xFF, 0xFF } },
- { "WhiteSmoke", { 0xF5, 0xF5, 0xF5 } },
- { "Yellow", { 0xFF, 0xFF, 0x00 } },
- { "YellowGreen", { 0x9A, 0xCD, 0x32 } },
-};
-
-static int color_table_compare(const void *lhs, const void *rhs)
-{
- return av_strcasecmp(lhs, ((const ColorEntry *)rhs)->name);
-}
-
-#define ALPHA_SEP '@'
-
-int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen,
- void *log_ctx)
-{
- char *tail, color_string2[128];
- const ColorEntry *entry;
- int len, hex_offset = 0;
-
- if (color_string[0] == '#') {
- hex_offset = 1;
- } else if (!strncmp(color_string, "0x", 2))
- hex_offset = 2;
-
- if (slen < 0)
- slen = strlen(color_string);
- av_strlcpy(color_string2, color_string + hex_offset,
- FFMIN(slen-hex_offset+1, sizeof(color_string2)));
- if ((tail = strchr(color_string2, ALPHA_SEP)))
- *tail++ = 0;
- len = strlen(color_string2);
- rgba_color[3] = 255;
-
- if (!av_strcasecmp(color_string2, "random") || !av_strcasecmp(color_string2, "bikeshed")) {
- int rgba = av_get_random_seed();
- rgba_color[0] = rgba >> 24;
- rgba_color[1] = rgba >> 16;
- rgba_color[2] = rgba >> 8;
- rgba_color[3] = rgba;
- } else if (hex_offset ||
- strspn(color_string2, "0123456789ABCDEFabcdef") == len) {
- char *tail;
- unsigned int rgba = strtoul(color_string2, &tail, 16);
-
- if (*tail || (len != 6 && len != 8)) {
- av_log(log_ctx, AV_LOG_ERROR, "Invalid 0xRRGGBB[AA] color string: '%s'\n", color_string2);
- return AVERROR(EINVAL);
- }
- if (len == 8) {
- rgba_color[3] = rgba;
- rgba >>= 8;
- }
- rgba_color[0] = rgba >> 16;
- rgba_color[1] = rgba >> 8;
- rgba_color[2] = rgba;
- } else {
- entry = bsearch(color_string2,
- color_table,
- FF_ARRAY_ELEMS(color_table),
- sizeof(ColorEntry),
- color_table_compare);
- if (!entry) {
- av_log(log_ctx, AV_LOG_ERROR, "Cannot find color '%s'\n", color_string2);
- return AVERROR(EINVAL);
- }
- memcpy(rgba_color, entry->rgb_color, 3);
- }
-
- if (tail) {
- double alpha;
- const char *alpha_string = tail;
- if (!strncmp(alpha_string, "0x", 2)) {
- alpha = strtoul(alpha_string, &tail, 16);
- } else {
- double norm_alpha = strtod(alpha_string, &tail);
- if (norm_alpha < 0.0 || norm_alpha > 1.0)
- alpha = 256;
- else
- alpha = 255 * norm_alpha;
- }
-
- if (tail == alpha_string || *tail || alpha > 255 || alpha < 0) {
- av_log(log_ctx, AV_LOG_ERROR, "Invalid alpha value specifier '%s' in '%s'\n",
- alpha_string, color_string);
- return AVERROR(EINVAL);
- }
- rgba_color[3] = alpha;
- }
-
- return 0;
-}
-
-/* get a positive number between n_min and n_max, for a maximum length
- of len_max. Return -1 if error. */
-static int date_get_num(const char **pp,
- int n_min, int n_max, int len_max)
-{
- int i, val, c;
- const char *p;
-
- p = *pp;
- val = 0;
- for(i = 0; i < len_max; i++) {
- c = *p;
- if (!isdigit(c))
- break;
- val = (val * 10) + c - '0';
- p++;
- }
- /* no number read ? */
- if (p == *pp)
- return -1;
- if (val < n_min || val > n_max)
- return -1;
- *pp = p;
- return val;
-}
-
-char *av_small_strptime(const char *p, const char *fmt, struct tm *dt)
-{
- int c, val;
-
- for(;;) {
- /* consume time string until a non whitespace char is found */
- while (isspace(*fmt)) {
- while (isspace(*p))
- p++;
- fmt++;
- }
- c = *fmt++;
- if (c == '\0') {
- return (char *)p;
- } else if (c == '%') {
- c = *fmt++;
- switch(c) {
- case 'H':
- case 'J':
- val = date_get_num(&p, 0, c == 'H' ? 23 : INT_MAX, 2);
- if (val == -1)
- return NULL;
- dt->tm_hour = val;
- break;
- case 'M':
- val = date_get_num(&p, 0, 59, 2);
- if (val == -1)
- return NULL;
- dt->tm_min = val;
- break;
- case 'S':
- val = date_get_num(&p, 0, 59, 2);
- if (val == -1)
- return NULL;
- dt->tm_sec = val;
- break;
- case 'Y':
- val = date_get_num(&p, 0, 9999, 4);
- if (val == -1)
- return NULL;
- dt->tm_year = val - 1900;
- break;
- case 'm':
- val = date_get_num(&p, 1, 12, 2);
- if (val == -1)
- return NULL;
- dt->tm_mon = val - 1;
- break;
- case 'd':
- val = date_get_num(&p, 1, 31, 2);
- if (val == -1)
- return NULL;
- dt->tm_mday = val;
- break;
- case '%':
- goto match;
- default:
- return NULL;
- }
- } else {
- match:
- if (c != *p)
- return NULL;
- p++;
- }
- }
-}
-
-time_t av_timegm(struct tm *tm)
-{
- time_t t;
-
- int y = tm->tm_year + 1900, m = tm->tm_mon + 1, d = tm->tm_mday;
-
- if (m < 3) {
- m += 12;
- y--;
- }
-
- t = 86400 *
- (d + (153 * m - 457) / 5 + 365 * y + y / 4 - y / 100 + y / 400 - 719469);
-
- t += 3600 * tm->tm_hour + 60 * tm->tm_min + tm->tm_sec;
-
- return t;
-}
-
-int av_parse_time(int64_t *timeval, const char *timestr, int duration)
-{
- const char *p, *q;
- int64_t t;
- time_t now;
- struct tm dt = { 0 };
- int today = 0, negative = 0, microseconds = 0;
- int i;
- static const char * const date_fmt[] = {
- "%Y-%m-%d",
- "%Y%m%d",
- };
- static const char * const time_fmt[] = {
- "%H:%M:%S",
- "%H%M%S",
- };
-
- p = timestr;
- q = NULL;
- *timeval = INT64_MIN;
- if (!duration) {
- now = time(0);
-
- if (!av_strcasecmp(timestr, "now")) {
- *timeval = (int64_t) now * 1000000;
- return 0;
- }
-
- /* parse the year-month-day part */
- for (i = 0; i < FF_ARRAY_ELEMS(date_fmt); i++) {
- q = av_small_strptime(p, date_fmt[i], &dt);
- if (q)
- break;
- }
-
- /* if the year-month-day part is missing, then take the
- * current year-month-day time */
- if (!q) {
- today = 1;
- q = p;
- }
- p = q;
-
- if (*p == 'T' || *p == 't' || *p == ' ')
- p++;
-
- /* parse the hour-minute-second part */
- for (i = 0; i < FF_ARRAY_ELEMS(time_fmt); i++) {
- q = av_small_strptime(p, time_fmt[i], &dt);
- if (q)
- break;
- }
- } else {
- /* parse timestr as a duration */
- if (p[0] == '-') {
- negative = 1;
- ++p;
- }
- /* parse timestr as HH:MM:SS */
- q = av_small_strptime(p, "%J:%M:%S", &dt);
- if (!q) {
- /* parse timestr as S+ */
- dt.tm_sec = strtol(p, (void *)&q, 10);
- if (q == p) /* the parsing didn't succeed */
- return AVERROR(EINVAL);
- dt.tm_min = 0;
- dt.tm_hour = 0;
- }
- }
-
- /* Now we have all the fields that we can get */
- if (!q)
- return AVERROR(EINVAL);
-
- /* parse the .m... part */
- if (*q == '.') {
- int n;
- q++;
- for (n = 100000; n >= 1; n /= 10, q++) {
- if (!isdigit(*q))
- break;
- microseconds += n * (*q - '0');
- }
- while (isdigit(*q))
- q++;
- }
-
- if (duration) {
- t = dt.tm_hour * 3600 + dt.tm_min * 60 + dt.tm_sec;
- } else {
- int is_utc = *q == 'Z' || *q == 'z';
- q += is_utc;
- if (today) { /* fill in today's date */
- struct tm dt2 = is_utc ? *gmtime(&now) : *localtime(&now);
- dt2.tm_hour = dt.tm_hour;
- dt2.tm_min = dt.tm_min;
- dt2.tm_sec = dt.tm_sec;
- dt = dt2;
- }
- t = is_utc ? av_timegm(&dt) : mktime(&dt);
- }
-
- /* Check that we are at the end of the string */
- if (*q)
- return AVERROR(EINVAL);
-
- t *= 1000000;
- t += microseconds;
- *timeval = negative ? -t : t;
- return 0;
-}
-
-int av_find_info_tag(char *arg, int arg_size, const char *tag1, const char *info)
-{
- const char *p;
- char tag[128], *q;
-
- p = info;
- if (*p == '?')
- p++;
- for(;;) {
- q = tag;
- while (*p != '\0' && *p != '=' && *p != '&') {
- if ((q - tag) < sizeof(tag) - 1)
- *q++ = *p;
- p++;
- }
- *q = '\0';
- q = arg;
- if (*p == '=') {
- p++;
- while (*p != '&' && *p != '\0') {
- if ((q - arg) < arg_size - 1) {
- if (*p == '+')
- *q++ = ' ';
- else
- *q++ = *p;
- }
- p++;
- }
- }
- *q = '\0';
- if (!strcmp(tag, tag1))
- return 1;
- if (*p != '&')
- break;
- p++;
- }
- return 0;
-}
-
-#ifdef TEST
-
-static uint32_t randomv = MKTAG('L','A','V','U');
-
-static uint32_t av_get_random_seed_deterministic(void)
-{
- return randomv = randomv * 1664525 + 1013904223;
-}
-
-int main(void)
-{
- printf("Testing av_parse_video_rate()\n");
- {
- int i;
- static const char *const rates[] = {
- "-inf",
- "inf",
- "nan",
- "123/0",
- "-123 / 0",
- "",
- "/",
- " 123 / 321",
- "foo/foo",
- "foo/1",
- "1/foo",
- "0/0",
- "/0",
- "1/",
- "1",
- "0",
- "-123/123",
- "-foo",
- "123.23",
- ".23",
- "-.23",
- "-0.234",
- "-0.0000001",
- " 21332.2324 ",
- " -21332.2324 ",
- };
-
- for (i = 0; i < FF_ARRAY_ELEMS(rates); i++) {
- int ret;
- AVRational q = { 0, 0 };
- ret = av_parse_video_rate(&q, rates[i]);
- printf("'%s' -> %d/%d %s\n",
- rates[i], q.num, q.den, ret ? "ERROR" : "OK");
- }
- }
-
- printf("\nTesting av_parse_color()\n");
- {
- int i;
- uint8_t rgba[4];
- static const char *const color_names[] = {
- "bikeshed",
- "RaNdOm",
- "foo",
- "red",
- "Red ",
- "RED",
- "Violet",
- "Yellow",
- "Red",
- "0x000000",
- "0x0000000",
- "0xff000000",
- "0x3e34ff",
- "0x3e34ffaa",
- "0xffXXee",
- "0xfoobar",
- "0xffffeeeeeeee",
- "#ff0000",
- "#ffXX00",
- "ff0000",
- "ffXX00",
- "red@foo",
- "random@10",
- "0xff0000@1.0",
- "red@",
- "red@0xfff",
- "red@0xf",
- "red@2",
- "red@0.1",
- "red@-1",
- "red@0.5",
- "red@1.0",
- "red@256",
- "red@10foo",
- "red@-1.0",
- "red@-0.0",
- };
-
- av_log_set_level(AV_LOG_DEBUG);
-
- for (i = 0; i < FF_ARRAY_ELEMS(color_names); i++) {
- if (av_parse_color(rgba, color_names[i], -1, NULL) >= 0)
- printf("%s -> R(%d) G(%d) B(%d) A(%d)\n",
- color_names[i], rgba[0], rgba[1], rgba[2], rgba[3]);
- else
- printf("%s -> error\n", color_names[i]);
- }
- }
-
- printf("\nTesting av_small_strptime()\n");
- {
- int i;
- struct tm tm = { 0 };
- struct fmt_timespec_entry {
- const char *fmt, *timespec;
- } fmt_timespec_entries[] = {
- { "%Y-%m-%d", "2012-12-21" },
- { "%Y - %m - %d", "2012-12-21" },
- { "%Y-%m-%d %H:%M:%S", "2012-12-21 20:12:21" },
- { " %Y - %m - %d %H : %M : %S", " 2012 - 12 - 21 20 : 12 : 21" },
- };
-
- av_log_set_level(AV_LOG_DEBUG);
- for (i = 0; i < FF_ARRAY_ELEMS(fmt_timespec_entries); i++) {
- char *p;
- struct fmt_timespec_entry *e = &fmt_timespec_entries[i];
- printf("fmt:'%s' spec:'%s' -> ", e->fmt, e->timespec);
- p = av_small_strptime(e->timespec, e->fmt, &tm);
- if (p) {
- printf("%04d-%02d-%2d %02d:%02d:%02d\n",
- 1900+tm.tm_year, tm.tm_mon+1, tm.tm_mday,
- tm.tm_hour, tm.tm_min, tm.tm_sec);
- } else {
- printf("error\n");
- }
- }
- }
-
- printf("\nTesting av_parse_time()\n");
- {
- int i;
- int64_t tv;
- time_t tvi;
- struct tm *tm;
- static char tzstr[] = "TZ=CET-1";
- const char *time_string[] = {
- "now",
- "12:35:46",
- "2000-12-20 0:02:47.5z",
- "2000-12-20T010247.6",
- };
- const char *duration_string[] = {
- "2:34:56.79",
- "-1:23:45.67",
- "42.1729",
- "-1729.42",
- "12:34",
- };
-
- av_log_set_level(AV_LOG_DEBUG);
- putenv(tzstr);
- printf("(now is 2012-03-17 09:14:13 +0100, local time is UTC+1)\n");
- for (i = 0; i < FF_ARRAY_ELEMS(time_string); i++) {
- printf("%-24s -> ", time_string[i]);
- if (av_parse_time(&tv, time_string[i], 0)) {
- printf("error\n");
- } else {
- tvi = tv / 1000000;
- tm = gmtime(&tvi);
- printf("%14"PRIi64".%06d = %04d-%02d-%02dT%02d:%02d:%02dZ\n",
- tv / 1000000, (int)(tv % 1000000),
- tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
- tm->tm_hour, tm->tm_min, tm->tm_sec);
- }
- }
- for (i = 0; i < FF_ARRAY_ELEMS(duration_string); i++) {
- printf("%-24s -> ", duration_string[i]);
- if (av_parse_time(&tv, duration_string[i], 1)) {
- printf("error\n");
- } else {
- printf("%+21"PRIi64"\n", tv);
- }
- }
- }
-
- return 0;
-}
-
-#endif /* TEST */
diff --git a/src/thirdparty/ffmpeg/libavutil/parseutils.h b/src/thirdparty/ffmpeg/libavutil/parseutils.h
deleted file mode 100644
index 0035aa677..000000000
--- a/src/thirdparty/ffmpeg/libavutil/parseutils.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * 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 AVUTIL_PARSEUTILS_H
-#define AVUTIL_PARSEUTILS_H
-
-#include <time.h>
-
-#include "rational.h"
-
-/**
- * @file
- * misc parsing utilities
- */
-
-/**
- * Parse str and store the parsed ratio in q.
- *
- * Note that a ratio with infinite (1/0) or negative value is
- * considered valid, so you should check on the returned value if you
- * want to exclude those values.
- *
- * The undefined value can be expressed using the "0:0" string.
- *
- * @param[in,out] q pointer to the AVRational which will contain the ratio
- * @param[in] str the string to parse: it has to be a string in the format
- * num:den, a float number or an expression
- * @param[in] max the maximum allowed numerator and denominator
- * @param[in] log_offset log level offset which is applied to the log
- * level of log_ctx
- * @param[in] log_ctx parent logging context
- * @return >= 0 on success, a negative error code otherwise
- */
-int av_parse_ratio(AVRational *q, const char *str, int max,
- int log_offset, void *log_ctx);
-
-#define av_parse_ratio_quiet(rate, str, max) \
- av_parse_ratio(rate, str, max, AV_LOG_MAX_OFFSET, NULL)
-
-/**
- * Parse str and put in width_ptr and height_ptr the detected values.
- *
- * @param[in,out] width_ptr pointer to the variable which will contain the detected
- * width value
- * @param[in,out] height_ptr pointer to the variable which will contain the detected
- * height value
- * @param[in] str the string to parse: it has to be a string in the format
- * width x height or a valid video size abbreviation.
- * @return >= 0 on success, a negative error code otherwise
- */
-int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str);
-
-/**
- * Parse str and store the detected values in *rate.
- *
- * @param[in,out] rate pointer to the AVRational which will contain the detected
- * frame rate
- * @param[in] str the string to parse: it has to be a string in the format
- * rate_num / rate_den, a float number or a valid video rate abbreviation
- * @return >= 0 on success, a negative error code otherwise
- */
-int av_parse_video_rate(AVRational *rate, const char *str);
-
-/**
- * Put the RGBA values that correspond to color_string in rgba_color.
- *
- * @param color_string a string specifying a color. It can be the name of
- * a color (case insensitive match) or a [0x|#]RRGGBB[AA] sequence,
- * possibly followed by "@" and a string representing the alpha
- * component.
- * The alpha component may be a string composed by "0x" followed by an
- * hexadecimal number or a decimal number between 0.0 and 1.0, which
- * represents the opacity value (0x00/0.0 means completely transparent,
- * 0xff/1.0 completely opaque).
- * If the alpha component is not specified then 0xff is assumed.
- * The string "random" will result in a random color.
- * @param slen length of the initial part of color_string containing the
- * color. It can be set to -1 if color_string is a null terminated string
- * containing nothing else than the color.
- * @return >= 0 in case of success, a negative value in case of
- * failure (for example if color_string cannot be parsed).
- */
-int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen,
- void *log_ctx);
-
-/**
- * Parse timestr and return in *time a corresponding number of
- * microseconds.
- *
- * @param timeval puts here the number of microseconds corresponding
- * to the string in timestr. If the string represents a duration, it
- * is the number of microseconds contained in the time interval. If
- * the string is a date, is the number of microseconds since 1st of
- * January, 1970 up to the time of the parsed date. If timestr cannot
- * be successfully parsed, set *time to INT64_MIN.
-
- * @param timestr a string representing a date or a duration.
- * - If a date the syntax is:
- * @code
- * [{YYYY-MM-DD|YYYYMMDD}[T|t| ]]{{HH:MM:SS[.m...]]]}|{HHMMSS[.m...]]]}}[Z]
- * now
- * @endcode
- * If the value is "now" it takes the current time.
- * Time is local time unless Z is appended, in which case it is
- * interpreted as UTC.
- * If the year-month-day part is not specified it takes the current
- * year-month-day.
- * - If a duration the syntax is:
- * @code
- * [-]HH:MM:SS[.m...]]]
- * [-]S+[.m...]
- * @endcode
- * @param duration flag which tells how to interpret timestr, if not
- * zero timestr is interpreted as a duration, otherwise as a date
- * @return 0 in case of success, a negative value corresponding to an
- * AVERROR code otherwise
- */
-int av_parse_time(int64_t *timeval, const char *timestr, int duration);
-
-/**
- * Parse the input string p according to the format string fmt and
- * store its results in the structure dt.
- * This implementation supports only a subset of the formats supported
- * by the standard strptime().
- *
- * In particular it actually supports the parameters:
- * - %H: the hour as a decimal number, using a 24-hour clock, in the
- * range '00' through '23'
- * - %J: hours as a decimal number, in the range '0' through INT_MAX
- * - %M: the minute as a decimal number, using a 24-hour clock, in the
- * range '00' through '59'
- * - %S: the second as a decimal number, using a 24-hour clock, in the
- * range '00' through '59'
- * - %Y: the year as a decimal number, using the Gregorian calendar
- * - %m: the month as a decimal number, in the range '1' through '12'
- * - %d: the day of the month as a decimal number, in the range '1'
- * through '31'
- * - %%: a literal '%'
- *
- * @return a pointer to the first character not processed in this
- * function call, or NULL in case the function fails to match all of
- * the fmt string and therefore an error occurred
- */
-char *av_small_strptime(const char *p, const char *fmt, struct tm *dt);
-
-/**
- * Attempt to find a specific tag in a URL.
- *
- * syntax: '?tag1=val1&tag2=val2...'. Little URL decoding is done.
- * Return 1 if found.
- */
-int av_find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
-
-/**
- * Convert the decomposed UTC time in tm to a time_t value.
- */
-time_t av_timegm(struct tm *tm);
-
-#endif /* AVUTIL_PARSEUTILS_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/pixdesc.c b/src/thirdparty/ffmpeg/libavutil/pixdesc.c
deleted file mode 100644
index f0b6c2235..000000000
--- a/src/thirdparty/ffmpeg/libavutil/pixdesc.c
+++ /dev/null
@@ -1,1793 +0,0 @@
-/*
- * pixel format descriptor
- * Copyright (c) 2009 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
- */
-
-#include <stdio.h>
-#include <string.h>
-
-#include "common.h"
-#include "pixfmt.h"
-#include "pixdesc.h"
-
-#include "intreadwrite.h"
-
-void av_read_image_line(uint16_t *dst,
- const uint8_t *data[4], const int linesize[4],
- const AVPixFmtDescriptor *desc,
- int x, int y, int c, int w,
- int read_pal_component)
-{
- AVComponentDescriptor comp = desc->comp[c];
- int plane = comp.plane;
- int depth = comp.depth_minus1 + 1;
- int mask = (1 << depth) - 1;
- int shift = comp.shift;
- int step = comp.step_minus1 + 1;
- int flags = desc->flags;
-
- if (flags & PIX_FMT_BITSTREAM) {
- int skip = x * step + comp.offset_plus1 - 1;
- const uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3);
- int shift = 8 - depth - (skip & 7);
-
- while (w--) {
- int val = (*p >> shift) & mask;
- if (read_pal_component)
- val = data[1][4*val + c];
- shift -= step;
- p -= shift >> 3;
- shift &= 7;
- *dst++ = val;
- }
- } else {
- const uint8_t *p = data[plane] + y * linesize[plane] +
- x * step + comp.offset_plus1 - 1;
- int is_8bit = shift + depth <= 8;
-
- if (is_8bit)
- p += !!(flags & PIX_FMT_BE);
-
- while (w--) {
- int val = is_8bit ? *p :
- flags & PIX_FMT_BE ? AV_RB16(p) : AV_RL16(p);
- val = (val >> shift) & mask;
- if (read_pal_component)
- val = data[1][4 * val + c];
- p += step;
- *dst++ = val;
- }
- }
-}
-
-void av_write_image_line(const uint16_t *src,
- uint8_t *data[4], const int linesize[4],
- const AVPixFmtDescriptor *desc,
- int x, int y, int c, int w)
-{
- AVComponentDescriptor comp = desc->comp[c];
- int plane = comp.plane;
- int depth = comp.depth_minus1 + 1;
- int step = comp.step_minus1 + 1;
- int flags = desc->flags;
-
- if (flags & PIX_FMT_BITSTREAM) {
- int skip = x * step + comp.offset_plus1 - 1;
- uint8_t *p = data[plane] + y * linesize[plane] + (skip >> 3);
- int shift = 8 - depth - (skip & 7);
-
- while (w--) {
- *p |= *src++ << shift;
- shift -= step;
- p -= shift >> 3;
- shift &= 7;
- }
- } else {
- int shift = comp.shift;
- uint8_t *p = data[plane] + y * linesize[plane] +
- x * step + comp.offset_plus1 - 1;
-
- if (shift + depth <= 8) {
- p += !!(flags & PIX_FMT_BE);
- while (w--) {
- *p |= (*src++ << shift);
- p += step;
- }
- } else {
- while (w--) {
- if (flags & PIX_FMT_BE) {
- uint16_t val = AV_RB16(p) | (*src++ << shift);
- AV_WB16(p, val);
- } else {
- uint16_t val = AV_RL16(p) | (*src++ << shift);
- AV_WL16(p, val);
- }
- p += step;
- }
- }
- }
-}
-
-#if !FF_API_PIX_FMT_DESC
-static
-#endif
-const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
- [AV_PIX_FMT_YUV420P] = {
- .name = "yuv420p",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .comp = {
- { 0, 0, 1, 0, 7 }, /* Y */
- { 1, 0, 1, 0, 7 }, /* U */
- { 2, 0, 1, 0, 7 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUYV422] = {
- .name = "yuyv422",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 7 }, /* Y */
- { 0, 3, 2, 0, 7 }, /* U */
- { 0, 3, 4, 0, 7 }, /* V */
- },
- },
- [AV_PIX_FMT_RGB24] = {
- .name = "rgb24",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 2, 1, 0, 7 }, /* R */
- { 0, 2, 2, 0, 7 }, /* G */
- { 0, 2, 3, 0, 7 }, /* B */
- },
- .flags = PIX_FMT_RGB,
- },
- [AV_PIX_FMT_BGR24] = {
- .name = "bgr24",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 2, 3, 0, 7 }, /* R */
- { 0, 2, 2, 0, 7 }, /* G */
- { 0, 2, 1, 0, 7 }, /* B */
- },
- .flags = PIX_FMT_RGB,
- },
- [AV_PIX_FMT_YUV422P] = {
- .name = "yuv422p",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 0, 1, 0, 7 }, /* Y */
- { 1, 0, 1, 0, 7 }, /* U */
- { 2, 0, 1, 0, 7 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV444P] = {
- .name = "yuv444p",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 0, 1, 0, 7 }, /* Y */
- { 1, 0, 1, 0, 7 }, /* U */
- { 2, 0, 1, 0, 7 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV410P] = {
- .name = "yuv410p",
- .nb_components = 3,
- .log2_chroma_w = 2,
- .log2_chroma_h = 2,
- .comp = {
- { 0, 0, 1, 0, 7 }, /* Y */
- { 1, 0, 1, 0, 7 }, /* U */
- { 2, 0, 1, 0, 7 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV411P] = {
- .name = "yuv411p",
- .nb_components = 3,
- .log2_chroma_w = 2,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 0, 1, 0, 7 }, /* Y */
- { 1, 0, 1, 0, 7 }, /* U */
- { 2, 0, 1, 0, 7 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_GRAY8] = {
- .name = "gray",
- .nb_components = 1,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 0, 1, 0, 7 }, /* Y */
- },
- .flags = PIX_FMT_PSEUDOPAL,
- },
- [AV_PIX_FMT_MONOWHITE] = {
- .name = "monow",
- .nb_components = 1,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 0, 1, 0, 0 }, /* Y */
- },
- .flags = PIX_FMT_BITSTREAM,
- },
- [AV_PIX_FMT_MONOBLACK] = {
- .name = "monob",
- .nb_components = 1,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 0, 1, 7, 0 }, /* Y */
- },
- .flags = PIX_FMT_BITSTREAM,
- },
- [AV_PIX_FMT_PAL8] = {
- .name = "pal8",
- .nb_components = 1,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 0, 1, 0, 7 },
- },
- .flags = PIX_FMT_PAL,
- },
- [AV_PIX_FMT_YUVJ420P] = {
- .name = "yuvj420p",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .comp = {
- { 0, 0, 1, 0, 7 }, /* Y */
- { 1, 0, 1, 0, 7 }, /* U */
- { 2, 0, 1, 0, 7 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUVJ422P] = {
- .name = "yuvj422p",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 0, 1, 0, 7 }, /* Y */
- { 1, 0, 1, 0, 7 }, /* U */
- { 2, 0, 1, 0, 7 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUVJ444P] = {
- .name = "yuvj444p",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 0, 1, 0, 7 }, /* Y */
- { 1, 0, 1, 0, 7 }, /* U */
- { 2, 0, 1, 0, 7 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_XVMC_MPEG2_MC] = {
- .name = "xvmcmc",
- .flags = PIX_FMT_HWACCEL,
- },
- [AV_PIX_FMT_XVMC_MPEG2_IDCT] = {
- .name = "xvmcidct",
- .flags = PIX_FMT_HWACCEL,
- },
- [AV_PIX_FMT_UYVY422] = {
- .name = "uyvy422",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 2, 0, 7 }, /* Y */
- { 0, 3, 1, 0, 7 }, /* U */
- { 0, 3, 3, 0, 7 }, /* V */
- },
- },
- [AV_PIX_FMT_UYYVYY411] = {
- .name = "uyyvyy411",
- .nb_components = 3,
- .log2_chroma_w = 2,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 3, 2, 0, 7 }, /* Y */
- { 0, 5, 1, 0, 7 }, /* U */
- { 0, 5, 4, 0, 7 }, /* V */
- },
- },
- [AV_PIX_FMT_BGR8] = {
- .name = "bgr8",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 0, 1, 0, 2 }, /* R */
- { 0, 0, 1, 3, 2 }, /* G */
- { 0, 0, 1, 6, 1 }, /* B */
- },
- .flags = PIX_FMT_RGB | PIX_FMT_PSEUDOPAL,
- },
- [AV_PIX_FMT_BGR4] = {
- .name = "bgr4",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 3, 4, 0, 0 }, /* R */
- { 0, 3, 2, 0, 1 }, /* G */
- { 0, 3, 1, 0, 0 }, /* B */
- },
- .flags = PIX_FMT_BITSTREAM | PIX_FMT_RGB,
- },
- [AV_PIX_FMT_BGR4_BYTE] = {
- .name = "bgr4_byte",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 0, 1, 0, 0 }, /* R */
- { 0, 0, 1, 1, 1 }, /* G */
- { 0, 0, 1, 3, 0 }, /* B */
- },
- .flags = PIX_FMT_RGB | PIX_FMT_PSEUDOPAL,
- },
- [AV_PIX_FMT_RGB8] = {
- .name = "rgb8",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 0, 1, 6, 1 }, /* R */
- { 0, 0, 1, 3, 2 }, /* G */
- { 0, 0, 1, 0, 2 }, /* B */
- },
- .flags = PIX_FMT_RGB | PIX_FMT_PSEUDOPAL,
- },
- [AV_PIX_FMT_RGB4] = {
- .name = "rgb4",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 3, 1, 0, 0 }, /* R */
- { 0, 3, 2, 0, 1 }, /* G */
- { 0, 3, 4, 0, 0 }, /* B */
- },
- .flags = PIX_FMT_BITSTREAM | PIX_FMT_RGB,
- },
- [AV_PIX_FMT_RGB4_BYTE] = {
- .name = "rgb4_byte",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 0, 1, 3, 0 }, /* R */
- { 0, 0, 1, 1, 1 }, /* G */
- { 0, 0, 1, 0, 0 }, /* B */
- },
- .flags = PIX_FMT_RGB | PIX_FMT_PSEUDOPAL,
- },
- [AV_PIX_FMT_NV12] = {
- .name = "nv12",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .comp = {
- { 0, 0, 1, 0, 7 }, /* Y */
- { 1, 1, 1, 0, 7 }, /* U */
- { 1, 1, 2, 0, 7 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_NV21] = {
- .name = "nv21",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .comp = {
- { 0, 0, 1, 0, 7 }, /* Y */
- { 1, 1, 2, 0, 7 }, /* U */
- { 1, 1, 1, 0, 7 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_ARGB] = {
- .name = "argb",
- .nb_components = 4,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 3, 2, 0, 7 }, /* R */
- { 0, 3, 3, 0, 7 }, /* G */
- { 0, 3, 4, 0, 7 }, /* B */
- { 0, 3, 1, 0, 7 }, /* A */
- },
- .flags = PIX_FMT_RGB | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_RGBA] = {
- .name = "rgba",
- .nb_components = 4,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 3, 1, 0, 7 }, /* R */
- { 0, 3, 2, 0, 7 }, /* G */
- { 0, 3, 3, 0, 7 }, /* B */
- { 0, 3, 4, 0, 7 }, /* A */
- },
- .flags = PIX_FMT_RGB | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_ABGR] = {
- .name = "abgr",
- .nb_components = 4,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 3, 4, 0, 7 }, /* R */
- { 0, 3, 3, 0, 7 }, /* G */
- { 0, 3, 2, 0, 7 }, /* B */
- { 0, 3, 1, 0, 7 }, /* A */
- },
- .flags = PIX_FMT_RGB | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_BGRA] = {
- .name = "bgra",
- .nb_components = 4,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 3, 3, 0, 7 }, /* R */
- { 0, 3, 2, 0, 7 }, /* G */
- { 0, 3, 1, 0, 7 }, /* B */
- { 0, 3, 4, 0, 7 }, /* A */
- },
- .flags = PIX_FMT_RGB | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_0RGB] = {
- .name = "0rgb",
- .nb_components= 3,
- .log2_chroma_w= 0,
- .log2_chroma_h= 0,
- .comp = {
- { 0, 3, 2, 0, 7 }, /* R */
- { 0, 3, 3, 0, 7 }, /* G */
- { 0, 3, 4, 0, 7 }, /* B */
- },
- .flags = PIX_FMT_RGB,
- },
- [AV_PIX_FMT_RGB0] = {
- .name = "rgb0",
- .nb_components= 3,
- .log2_chroma_w= 0,
- .log2_chroma_h= 0,
- .comp = {
- { 0, 3, 1, 0, 7 }, /* R */
- { 0, 3, 2, 0, 7 }, /* G */
- { 0, 3, 3, 0, 7 }, /* B */
- { 0, 3, 4, 0, 7 }, /* A */
- },
- .flags = PIX_FMT_RGB,
- },
- [AV_PIX_FMT_0BGR] = {
- .name = "0bgr",
- .nb_components= 3,
- .log2_chroma_w= 0,
- .log2_chroma_h= 0,
- .comp = {
- { 0, 3, 4, 0, 7 }, /* R */
- { 0, 3, 3, 0, 7 }, /* G */
- { 0, 3, 2, 0, 7 }, /* B */
- },
- .flags = PIX_FMT_RGB,
- },
- [AV_PIX_FMT_BGR0] = {
- .name = "bgr0",
- .nb_components= 3,
- .log2_chroma_w= 0,
- .log2_chroma_h= 0,
- .comp = {
- { 0, 3, 3, 0, 7 }, /* R */
- { 0, 3, 2, 0, 7 }, /* G */
- { 0, 3, 1, 0, 7 }, /* B */
- { 0, 3, 4, 0, 7 }, /* A */
- },
- .flags = PIX_FMT_RGB,
- },
- [AV_PIX_FMT_GRAY16BE] = {
- .name = "gray16be",
- .nb_components = 1,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 15 }, /* Y */
- },
- .flags = PIX_FMT_BE,
- },
- [AV_PIX_FMT_GRAY16LE] = {
- .name = "gray16le",
- .nb_components = 1,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 15 }, /* Y */
- },
- },
- [AV_PIX_FMT_YUV440P] = {
- .name = "yuv440p",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 1,
- .comp = {
- { 0, 0, 1, 0, 7 }, /* Y */
- { 1, 0, 1, 0, 7 }, /* U */
- { 2, 0, 1, 0, 7 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUVJ440P] = {
- .name = "yuvj440p",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 1,
- .comp = {
- { 0, 0, 1, 0, 7 }, /* Y */
- { 1, 0, 1, 0, 7 }, /* U */
- { 2, 0, 1, 0, 7 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUVA420P] = {
- .name = "yuva420p",
- .nb_components = 4,
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .comp = {
- { 0, 0, 1, 0, 7 }, /* Y */
- { 1, 0, 1, 0, 7 }, /* U */
- { 2, 0, 1, 0, 7 }, /* V */
- { 3, 0, 1, 0, 7 }, /* A */
- },
- .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_YUVA422P] = {
- .name = "yuva422p",
- .nb_components = 4,
- .log2_chroma_w = 1,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 0, 1, 0, 7 }, /* Y */
- { 1, 0, 1, 0, 7 }, /* U */
- { 2, 0, 1, 0, 7 }, /* V */
- { 3, 0, 1, 0, 7 }, /* A */
- },
- .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_YUVA444P] = {
- .name = "yuva444p",
- .nb_components = 4,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 0, 1, 0, 7 }, /* Y */
- { 1, 0, 1, 0, 7 }, /* U */
- { 2, 0, 1, 0, 7 }, /* V */
- { 3, 0, 1, 0, 7 }, /* A */
- },
- .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_YUVA420P9BE] = {
- .name = "yuva420p9be",
- .nb_components = 4,
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .comp = {
- { 0, 1, 1, 0, 8 }, /* Y */
- { 1, 1, 1, 0, 8 }, /* U */
- { 2, 1, 1, 0, 8 }, /* V */
- { 3, 1, 1, 0, 8 }, /* A */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_YUVA420P9LE] = {
- .name = "yuva420p9le",
- .nb_components = 4,
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .comp = {
- { 0, 1, 1, 0, 8 }, /* Y */
- { 1, 1, 1, 0, 8 }, /* U */
- { 2, 1, 1, 0, 8 }, /* V */
- { 3, 1, 1, 0, 8 }, /* A */
- },
- .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_YUVA422P9BE] = {
- .name = "yuva422p9be",
- .nb_components = 4,
- .log2_chroma_w = 1,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 8 }, /* Y */
- { 1, 1, 1, 0, 8 }, /* U */
- { 2, 1, 1, 0, 8 }, /* V */
- { 3, 1, 1, 0, 8 }, /* A */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_YUVA422P9LE] = {
- .name = "yuva422p9le",
- .nb_components = 4,
- .log2_chroma_w = 1,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 8 }, /* Y */
- { 1, 1, 1, 0, 8 }, /* U */
- { 2, 1, 1, 0, 8 }, /* V */
- { 3, 1, 1, 0, 8 }, /* A */
- },
- .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_YUVA444P9BE] = {
- .name = "yuva444p9be",
- .nb_components = 4,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 8 }, /* Y */
- { 1, 1, 1, 0, 8 }, /* U */
- { 2, 1, 1, 0, 8 }, /* V */
- { 3, 1, 1, 0, 8 }, /* A */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_YUVA444P9LE] = {
- .name = "yuva444p9le",
- .nb_components = 4,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 8 }, /* Y */
- { 1, 1, 1, 0, 8 }, /* U */
- { 2, 1, 1, 0, 8 }, /* V */
- { 3, 1, 1, 0, 8 }, /* A */
- },
- .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_YUVA420P10BE] = {
- .name = "yuva420p10be",
- .nb_components = 4,
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .comp = {
- { 0, 1, 1, 0, 9 }, /* Y */
- { 1, 1, 1, 0, 9 }, /* U */
- { 2, 1, 1, 0, 9 }, /* V */
- { 3, 1, 1, 0, 9 }, /* A */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_YUVA420P10LE] = {
- .name = "yuva420p10le",
- .nb_components = 4,
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .comp = {
- { 0, 1, 1, 0, 9 }, /* Y */
- { 1, 1, 1, 0, 9 }, /* U */
- { 2, 1, 1, 0, 9 }, /* V */
- { 3, 1, 1, 0, 9 }, /* A */
- },
- .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_YUVA422P10BE] = {
- .name = "yuva422p10be",
- .nb_components = 4,
- .log2_chroma_w = 1,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 9 }, /* Y */
- { 1, 1, 1, 0, 9 }, /* U */
- { 2, 1, 1, 0, 9 }, /* V */
- { 3, 1, 1, 0, 9 }, /* A */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_YUVA422P10LE] = {
- .name = "yuva422p10le",
- .nb_components = 4,
- .log2_chroma_w = 1,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 9 }, /* Y */
- { 1, 1, 1, 0, 9 }, /* U */
- { 2, 1, 1, 0, 9 }, /* V */
- { 3, 1, 1, 0, 9 }, /* A */
- },
- .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_YUVA444P10BE] = {
- .name = "yuva444p10be",
- .nb_components = 4,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 9 }, /* Y */
- { 1, 1, 1, 0, 9 }, /* U */
- { 2, 1, 1, 0, 9 }, /* V */
- { 3, 1, 1, 0, 9 }, /* A */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_YUVA444P10LE] = {
- .name = "yuva444p10le",
- .nb_components = 4,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 9 }, /* Y */
- { 1, 1, 1, 0, 9 }, /* U */
- { 2, 1, 1, 0, 9 }, /* V */
- { 3, 1, 1, 0, 9 }, /* A */
- },
- .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_YUVA420P16BE] = {
- .name = "yuva420p16be",
- .nb_components = 4,
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .comp = {
- { 0, 1, 1, 0, 15 }, /* Y */
- { 1, 1, 1, 0, 15 }, /* U */
- { 2, 1, 1, 0, 15 }, /* V */
- { 3, 1, 1, 0, 15 }, /* A */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_YUVA420P16LE] = {
- .name = "yuva420p16le",
- .nb_components = 4,
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .comp = {
- { 0, 1, 1, 0, 15 }, /* Y */
- { 1, 1, 1, 0, 15 }, /* U */
- { 2, 1, 1, 0, 15 }, /* V */
- { 3, 1, 1, 0, 15 }, /* A */
- },
- .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_YUVA422P16BE] = {
- .name = "yuva422p16be",
- .nb_components = 4,
- .log2_chroma_w = 1,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 15 }, /* Y */
- { 1, 1, 1, 0, 15 }, /* U */
- { 2, 1, 1, 0, 15 }, /* V */
- { 3, 1, 1, 0, 15 }, /* A */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_YUVA422P16LE] = {
- .name = "yuva422p16le",
- .nb_components = 4,
- .log2_chroma_w = 1,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 15 }, /* Y */
- { 1, 1, 1, 0, 15 }, /* U */
- { 2, 1, 1, 0, 15 }, /* V */
- { 3, 1, 1, 0, 15 }, /* A */
- },
- .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_YUVA444P16BE] = {
- .name = "yuva444p16be",
- .nb_components = 4,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 15 }, /* Y */
- { 1, 1, 1, 0, 15 }, /* U */
- { 2, 1, 1, 0, 15 }, /* V */
- { 3, 1, 1, 0, 15 }, /* A */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_YUVA444P16LE] = {
- .name = "yuva444p16le",
- .nb_components = 4,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 15 }, /* Y */
- { 1, 1, 1, 0, 15 }, /* U */
- { 2, 1, 1, 0, 15 }, /* V */
- { 3, 1, 1, 0, 15 }, /* A */
- },
- .flags = PIX_FMT_PLANAR | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_VDPAU_H264] = {
- .name = "vdpau_h264",
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .flags = PIX_FMT_HWACCEL,
- },
- [AV_PIX_FMT_VDPAU_MPEG1] = {
- .name = "vdpau_mpeg1",
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .flags = PIX_FMT_HWACCEL,
- },
- [AV_PIX_FMT_VDPAU_MPEG2] = {
- .name = "vdpau_mpeg2",
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .flags = PIX_FMT_HWACCEL,
- },
- [AV_PIX_FMT_VDPAU_WMV3] = {
- .name = "vdpau_wmv3",
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .flags = PIX_FMT_HWACCEL,
- },
- [AV_PIX_FMT_VDPAU_VC1] = {
- .name = "vdpau_vc1",
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .flags = PIX_FMT_HWACCEL,
- },
- [AV_PIX_FMT_VDPAU_MPEG4] = {
- .name = "vdpau_mpeg4",
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .flags = PIX_FMT_HWACCEL,
- },
- [AV_PIX_FMT_RGB48BE] = {
- .name = "rgb48be",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 5, 1, 0, 15 }, /* R */
- { 0, 5, 3, 0, 15 }, /* G */
- { 0, 5, 5, 0, 15 }, /* B */
- },
- .flags = PIX_FMT_RGB | PIX_FMT_BE,
- },
- [AV_PIX_FMT_RGB48LE] = {
- .name = "rgb48le",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 5, 1, 0, 15 }, /* R */
- { 0, 5, 3, 0, 15 }, /* G */
- { 0, 5, 5, 0, 15 }, /* B */
- },
- .flags = PIX_FMT_RGB,
- },
- [AV_PIX_FMT_RGBA64BE] = {
- .name = "rgba64be",
- .nb_components= 4,
- .log2_chroma_w= 0,
- .log2_chroma_h= 0,
- .comp = {
- { 0, 7, 1, 0, 15 }, /* R */
- { 0, 7, 3, 0, 15 }, /* G */
- { 0, 7, 5, 0, 15 }, /* B */
- { 0, 7, 7, 0, 15 }, /* A */
- },
- .flags = PIX_FMT_RGB | PIX_FMT_BE | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_RGBA64LE] = {
- .name = "rgba64le",
- .nb_components= 4,
- .log2_chroma_w= 0,
- .log2_chroma_h= 0,
- .comp = {
- { 0, 7, 1, 0, 15 }, /* R */
- { 0, 7, 3, 0, 15 }, /* G */
- { 0, 7, 5, 0, 15 }, /* B */
- { 0, 7, 7, 0, 15 }, /* A */
- },
- .flags = PIX_FMT_RGB | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_RGB565BE] = {
- .name = "rgb565be",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 0, 3, 4 }, /* R */
- { 0, 1, 1, 5, 5 }, /* G */
- { 0, 1, 1, 0, 4 }, /* B */
- },
- .flags = PIX_FMT_BE | PIX_FMT_RGB,
- },
- [AV_PIX_FMT_RGB565LE] = {
- .name = "rgb565le",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 2, 3, 4 }, /* R */
- { 0, 1, 1, 5, 5 }, /* G */
- { 0, 1, 1, 0, 4 }, /* B */
- },
- .flags = PIX_FMT_RGB,
- },
- [AV_PIX_FMT_RGB555BE] = {
- .name = "rgb555be",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 0, 2, 4 }, /* R */
- { 0, 1, 1, 5, 4 }, /* G */
- { 0, 1, 1, 0, 4 }, /* B */
- },
- .flags = PIX_FMT_BE | PIX_FMT_RGB,
- },
- [AV_PIX_FMT_RGB555LE] = {
- .name = "rgb555le",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 2, 2, 4 }, /* R */
- { 0, 1, 1, 5, 4 }, /* G */
- { 0, 1, 1, 0, 4 }, /* B */
- },
- .flags = PIX_FMT_RGB,
- },
- [AV_PIX_FMT_RGB444BE] = {
- .name = "rgb444be",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 0, 0, 3 }, /* R */
- { 0, 1, 1, 4, 3 }, /* G */
- { 0, 1, 1, 0, 3 }, /* B */
- },
- .flags = PIX_FMT_BE | PIX_FMT_RGB,
- },
- [AV_PIX_FMT_RGB444LE] = {
- .name = "rgb444le",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 2, 0, 3 }, /* R */
- { 0, 1, 1, 4, 3 }, /* G */
- { 0, 1, 1, 0, 3 }, /* B */
- },
- .flags = PIX_FMT_RGB,
- },
- [AV_PIX_FMT_BGR48BE] = {
- .name = "bgr48be",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 5, 5, 0, 15 }, /* R */
- { 0, 5, 3, 0, 15 }, /* G */
- { 0, 5, 1, 0, 15 }, /* B */
- },
- .flags = PIX_FMT_BE | PIX_FMT_RGB,
- },
- [AV_PIX_FMT_BGR48LE] = {
- .name = "bgr48le",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 5, 5, 0, 15 }, /* R */
- { 0, 5, 3, 0, 15 }, /* G */
- { 0, 5, 1, 0, 15 }, /* B */
- },
- .flags = PIX_FMT_RGB,
- },
- [AV_PIX_FMT_BGRA64BE] = {
- .name = "bgra64be",
- .nb_components= 4,
- .log2_chroma_w= 0,
- .log2_chroma_h= 0,
- .comp = {
- { 0, 7, 5, 0, 15 }, /* R */
- { 0, 7, 3, 0, 15 }, /* G */
- { 0, 7, 1, 0, 15 }, /* B */
- { 0, 7, 7, 0, 15 }, /* A */
- },
- .flags = PIX_FMT_BE | PIX_FMT_RGB | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_BGRA64LE] = {
- .name = "bgra64le",
- .nb_components= 4,
- .log2_chroma_w= 0,
- .log2_chroma_h= 0,
- .comp = {
- { 0, 7, 5, 0, 15 }, /* R */
- { 0, 7, 3, 0, 15 }, /* G */
- { 0, 7, 1, 0, 15 }, /* B */
- { 0, 7, 7, 0, 15 }, /* A */
- },
- .flags = PIX_FMT_RGB | PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_BGR565BE] = {
- .name = "bgr565be",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 4 }, /* R */
- { 0, 1, 1, 5, 5 }, /* G */
- { 0, 1, 0, 3, 4 }, /* B */
- },
- .flags = PIX_FMT_BE | PIX_FMT_RGB,
- },
- [AV_PIX_FMT_BGR565LE] = {
- .name = "bgr565le",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 4 }, /* R */
- { 0, 1, 1, 5, 5 }, /* G */
- { 0, 1, 2, 3, 4 }, /* B */
- },
- .flags = PIX_FMT_RGB,
- },
- [AV_PIX_FMT_BGR555BE] = {
- .name = "bgr555be",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 4 }, /* R */
- { 0, 1, 1, 5, 4 }, /* G */
- { 0, 1, 0, 2, 4 }, /* B */
- },
- .flags = PIX_FMT_BE | PIX_FMT_RGB,
- },
- [AV_PIX_FMT_BGR555LE] = {
- .name = "bgr555le",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 4 }, /* R */
- { 0, 1, 1, 5, 4 }, /* G */
- { 0, 1, 2, 2, 4 }, /* B */
- },
- .flags = PIX_FMT_RGB,
- },
- [AV_PIX_FMT_BGR444BE] = {
- .name = "bgr444be",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 3 }, /* R */
- { 0, 1, 1, 4, 3 }, /* G */
- { 0, 1, 0, 0, 3 }, /* B */
- },
- .flags = PIX_FMT_BE | PIX_FMT_RGB,
- },
- [AV_PIX_FMT_BGR444LE] = {
- .name = "bgr444le",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 3 }, /* R */
- { 0, 1, 1, 4, 3 }, /* G */
- { 0, 1, 2, 0, 3 }, /* B */
- },
- .flags = PIX_FMT_RGB,
- },
- [AV_PIX_FMT_VAAPI_MOCO] = {
- .name = "vaapi_moco",
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .flags = PIX_FMT_HWACCEL,
- },
- [AV_PIX_FMT_VAAPI_IDCT] = {
- .name = "vaapi_idct",
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .flags = PIX_FMT_HWACCEL,
- },
- [AV_PIX_FMT_VAAPI_VLD] = {
- .name = "vaapi_vld",
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .flags = PIX_FMT_HWACCEL,
- },
- [AV_PIX_FMT_YUV420P9LE] = {
- .name = "yuv420p9le",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .comp = {
- { 0, 1, 1, 0, 8 }, /* Y */
- { 1, 1, 1, 0, 8 }, /* U */
- { 2, 1, 1, 0, 8 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV420P9BE] = {
- .name = "yuv420p9be",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .comp = {
- { 0, 1, 1, 0, 8 }, /* Y */
- { 1, 1, 1, 0, 8 }, /* U */
- { 2, 1, 1, 0, 8 }, /* V */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV420P10LE] = {
- .name = "yuv420p10le",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .comp = {
- { 0, 1, 1, 0, 9 }, /* Y */
- { 1, 1, 1, 0, 9 }, /* U */
- { 2, 1, 1, 0, 9 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV420P10BE] = {
- .name = "yuv420p10be",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .comp = {
- { 0, 1, 1, 0, 9 }, /* Y */
- { 1, 1, 1, 0, 9 }, /* U */
- { 2, 1, 1, 0, 9 }, /* V */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV420P12LE] = {
- .name = "yuv420p12le",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .comp = {
- { 0, 1, 1, 0, 11 }, /* Y */
- { 1, 1, 1, 0, 11 }, /* U */
- { 2, 1, 1, 0, 11 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV420P12BE] = {
- .name = "yuv420p12be",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .comp = {
- { 0, 1, 1, 0, 11 }, /* Y */
- { 1, 1, 1, 0, 11 }, /* U */
- { 2, 1, 1, 0, 11 }, /* V */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV420P14LE] = {
- .name = "yuv420p14le",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .comp = {
- { 0, 1, 1, 0, 13 }, /* Y */
- { 1, 1, 1, 0, 13 }, /* U */
- { 2, 1, 1, 0, 13 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV420P14BE] = {
- .name = "yuv420p14be",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .comp = {
- { 0, 1, 1, 0, 13 }, /* Y */
- { 1, 1, 1, 0, 13 }, /* U */
- { 2, 1, 1, 0, 13 }, /* V */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV420P16LE] = {
- .name = "yuv420p16le",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .comp = {
- { 0, 1, 1, 0, 15 }, /* Y */
- { 1, 1, 1, 0, 15 }, /* U */
- { 2, 1, 1, 0, 15 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV420P16BE] = {
- .name = "yuv420p16be",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .comp = {
- { 0, 1, 1, 0, 15 }, /* Y */
- { 1, 1, 1, 0, 15 }, /* U */
- { 2, 1, 1, 0, 15 }, /* V */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV422P9LE] = {
- .name = "yuv422p9le",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 8 }, /* Y */
- { 1, 1, 1, 0, 8 }, /* U */
- { 2, 1, 1, 0, 8 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV422P9BE] = {
- .name = "yuv422p9be",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 8 }, /* Y */
- { 1, 1, 1, 0, 8 }, /* U */
- { 2, 1, 1, 0, 8 }, /* V */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV422P10LE] = {
- .name = "yuv422p10le",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 9 }, /* Y */
- { 1, 1, 1, 0, 9 }, /* U */
- { 2, 1, 1, 0, 9 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV422P10BE] = {
- .name = "yuv422p10be",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 9 }, /* Y */
- { 1, 1, 1, 0, 9 }, /* U */
- { 2, 1, 1, 0, 9 }, /* V */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV422P12LE] = {
- .name = "yuv422p12le",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 11 }, /* Y */
- { 1, 1, 1, 0, 11 }, /* U */
- { 2, 1, 1, 0, 11 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV422P12BE] = {
- .name = "yuv422p12be",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 11 }, /* Y */
- { 1, 1, 1, 0, 11 }, /* U */
- { 2, 1, 1, 0, 11 }, /* V */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV422P14LE] = {
- .name = "yuv422p14le",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 13 }, /* Y */
- { 1, 1, 1, 0, 13 }, /* U */
- { 2, 1, 1, 0, 13 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV422P14BE] = {
- .name = "yuv422p14be",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 13 }, /* Y */
- { 1, 1, 1, 0, 13 }, /* U */
- { 2, 1, 1, 0, 13 }, /* V */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV422P16LE] = {
- .name = "yuv422p16le",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 15 }, /* Y */
- { 1, 1, 1, 0, 15 }, /* U */
- { 2, 1, 1, 0, 15 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV422P16BE] = {
- .name = "yuv422p16be",
- .nb_components = 3,
- .log2_chroma_w = 1,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 15 }, /* Y */
- { 1, 1, 1, 0, 15 }, /* U */
- { 2, 1, 1, 0, 15 }, /* V */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV444P16LE] = {
- .name = "yuv444p16le",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 15 }, /* Y */
- { 1, 1, 1, 0, 15 }, /* U */
- { 2, 1, 1, 0, 15 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV444P16BE] = {
- .name = "yuv444p16be",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 15 }, /* Y */
- { 1, 1, 1, 0, 15 }, /* U */
- { 2, 1, 1, 0, 15 }, /* V */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV444P10LE] = {
- .name = "yuv444p10le",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 9 }, /* Y */
- { 1, 1, 1, 0, 9 }, /* U */
- { 2, 1, 1, 0, 9 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV444P10BE] = {
- .name = "yuv444p10be",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 9 }, /* Y */
- { 1, 1, 1, 0, 9 }, /* U */
- { 2, 1, 1, 0, 9 }, /* V */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV444P9LE] = {
- .name = "yuv444p9le",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 8 }, /* Y */
- { 1, 1, 1, 0, 8 }, /* U */
- { 2, 1, 1, 0, 8 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV444P9BE] = {
- .name = "yuv444p9be",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 8 }, /* Y */
- { 1, 1, 1, 0, 8 }, /* U */
- { 2, 1, 1, 0, 8 }, /* V */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV444P12LE] = {
- .name = "yuv444p12le",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 11 }, /* Y */
- { 1, 1, 1, 0, 11 }, /* U */
- { 2, 1, 1, 0, 11 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV444P12BE] = {
- .name = "yuv444p12be",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 11 }, /* Y */
- { 1, 1, 1, 0, 11 }, /* U */
- { 2, 1, 1, 0, 11 }, /* V */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV444P14LE] = {
- .name = "yuv444p14le",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 13 }, /* Y */
- { 1, 1, 1, 0, 13 }, /* U */
- { 2, 1, 1, 0, 13 }, /* V */
- },
- .flags = PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_YUV444P14BE] = {
- .name = "yuv444p14be",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 0, 1, 1, 0, 13 }, /* Y */
- { 1, 1, 1, 0, 13 }, /* U */
- { 2, 1, 1, 0, 13 }, /* V */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR,
- },
- [AV_PIX_FMT_DXVA2_VLD] = {
- .name = "dxva2_vld",
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .flags = PIX_FMT_HWACCEL,
- },
- [AV_PIX_FMT_VDA_VLD] = {
- .name = "vda_vld",
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .flags = PIX_FMT_HWACCEL,
- },
- [AV_PIX_FMT_GRAY8A] = {
- .name = "gray8a",
- .nb_components = 2,
- .comp = {
- { 0, 1, 1, 0, 7 }, /* Y */
- { 0, 1, 2, 0, 7 }, /* A */
- },
- .flags = PIX_FMT_ALPHA,
- },
- [AV_PIX_FMT_GBRP] = {
- .name = "gbrp",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 2, 0, 1, 0, 7 }, /* R */
- { 0, 0, 1, 0, 7 }, /* G */
- { 1, 0, 1, 0, 7 }, /* B */
- },
- .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
- },
- [AV_PIX_FMT_GBRP9LE] = {
- .name = "gbrp9le",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 2, 1, 1, 0, 8 }, /* R */
- { 0, 1, 1, 0, 8 }, /* G */
- { 1, 1, 1, 0, 8 }, /* B */
- },
- .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
- },
- [AV_PIX_FMT_GBRP9BE] = {
- .name = "gbrp9be",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 2, 1, 1, 0, 8 }, /* R */
- { 0, 1, 1, 0, 8 }, /* G */
- { 1, 1, 1, 0, 8 }, /* B */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
- },
- [AV_PIX_FMT_GBRP10LE] = {
- .name = "gbrp10le",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 2, 1, 1, 0, 9 }, /* R */
- { 0, 1, 1, 0, 9 }, /* G */
- { 1, 1, 1, 0, 9 }, /* B */
- },
- .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
- },
- [AV_PIX_FMT_GBRP10BE] = {
- .name = "gbrp10be",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 2, 1, 1, 0, 9 }, /* R */
- { 0, 1, 1, 0, 9 }, /* G */
- { 1, 1, 1, 0, 9 }, /* B */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
- },
- [AV_PIX_FMT_GBRP12LE] = {
- .name = "gbrp12le",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 2, 1, 1, 0, 11 }, /* R */
- { 0, 1, 1, 0, 11 }, /* G */
- { 1, 1, 1, 0, 11 }, /* B */
- },
- .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
- },
- [AV_PIX_FMT_GBRP12BE] = {
- .name = "gbrp12be",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 2, 1, 1, 0, 11 }, /* R */
- { 0, 1, 1, 0, 11 }, /* G */
- { 1, 1, 1, 0, 11 }, /* B */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
- },
- [AV_PIX_FMT_GBRP14LE] = {
- .name = "gbrp14le",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 2, 1, 1, 0, 13 }, /* R */
- { 0, 1, 1, 0, 13 }, /* G */
- { 1, 1, 1, 0, 13 }, /* B */
- },
- .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
- },
- [AV_PIX_FMT_GBRP14BE] = {
- .name = "gbrp14be",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 2, 1, 1, 0, 13 }, /* R */
- { 0, 1, 1, 0, 13 }, /* G */
- { 1, 1, 1, 0, 13 }, /* B */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
- },
- [AV_PIX_FMT_GBRP16LE] = {
- .name = "gbrp16le",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 2, 1, 1, 0, 15 }, /* R */
- { 0, 1, 1, 0, 15 }, /* G */
- { 1, 1, 1, 0, 15 }, /* B */
- },
- .flags = PIX_FMT_PLANAR | PIX_FMT_RGB,
- },
- [AV_PIX_FMT_GBRP16BE] = {
- .name = "gbrp16be",
- .nb_components = 3,
- .log2_chroma_w = 0,
- .log2_chroma_h = 0,
- .comp = {
- { 2, 1, 1, 0, 15 }, /* R */
- { 0, 1, 1, 0, 15 }, /* G */
- { 1, 1, 1, 0, 15 }, /* B */
- },
- .flags = PIX_FMT_BE | PIX_FMT_PLANAR | PIX_FMT_RGB,
- },
- [AV_PIX_FMT_VDPAU] = {
- .name = "vdpau",
- .log2_chroma_w = 1,
- .log2_chroma_h = 1,
- .flags = PIX_FMT_HWACCEL,
- },
-};
-
-static enum AVPixelFormat get_pix_fmt_internal(const char *name)
-{
- enum AVPixelFormat pix_fmt;
-
- for (pix_fmt = 0; pix_fmt < AV_PIX_FMT_NB; pix_fmt++)
- if (av_pix_fmt_descriptors[pix_fmt].name &&
- !strcmp(av_pix_fmt_descriptors[pix_fmt].name, name))
- return pix_fmt;
-
- return AV_PIX_FMT_NONE;
-}
-
-const char *av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
-{
- return (unsigned)pix_fmt < AV_PIX_FMT_NB ?
- av_pix_fmt_descriptors[pix_fmt].name : NULL;
-}
-
-#if HAVE_BIGENDIAN
-# define X_NE(be, le) be
-#else
-# define X_NE(be, le) le
-#endif
-
-enum AVPixelFormat av_get_pix_fmt(const char *name)
-{
- enum AVPixelFormat pix_fmt;
-
- if (!strcmp(name, "rgb32"))
- name = X_NE("argb", "bgra");
- else if (!strcmp(name, "bgr32"))
- name = X_NE("abgr", "rgba");
-
- pix_fmt = get_pix_fmt_internal(name);
- if (pix_fmt == AV_PIX_FMT_NONE) {
- char name2[32];
-
- snprintf(name2, sizeof(name2), "%s%s", name, X_NE("be", "le"));
- pix_fmt = get_pix_fmt_internal(name2);
- }
- return pix_fmt;
-}
-
-int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
-{
- int c, bits = 0;
- int log2_pixels = pixdesc->log2_chroma_w + pixdesc->log2_chroma_h;
-
- for (c = 0; c < pixdesc->nb_components; c++) {
- int s = c == 1 || c == 2 ? 0 : log2_pixels;
- bits += (pixdesc->comp[c].depth_minus1 + 1) << s;
- }
-
- return bits >> log2_pixels;
-}
-
-int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
-{
- int c, bits = 0;
- int log2_pixels = pixdesc->log2_chroma_w + pixdesc->log2_chroma_h;
- int steps[4] = {0};
-
- for (c = 0; c < pixdesc->nb_components; c++) {
- const AVComponentDescriptor *comp = &pixdesc->comp[c];
- int s = c == 1 || c == 2 ? 0 : log2_pixels;
- steps[comp->plane] = (comp->step_minus1 + 1) << s;
- }
- for (c = 0; c < 4; c++)
- bits += steps[c];
-
- if(!(pixdesc->flags & PIX_FMT_BITSTREAM))
- bits *= 8;
-
- return bits >> log2_pixels;
-}
-
-char *av_get_pix_fmt_string (char *buf, int buf_size, enum AVPixelFormat pix_fmt)
-{
- /* print header */
- if (pix_fmt < 0) {
- snprintf (buf, buf_size, "name" " nb_components" " nb_bits");
- } else {
- const AVPixFmtDescriptor *pixdesc = &av_pix_fmt_descriptors[pix_fmt];
- snprintf(buf, buf_size, "%-11s %7d %10d", pixdesc->name,
- pixdesc->nb_components, av_get_bits_per_pixel(pixdesc));
- }
-
- return buf;
-}
-
-const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
-{
- if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)
- return NULL;
- return &av_pix_fmt_descriptors[pix_fmt];
-}
-
-const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
-{
- if (!prev)
- return &av_pix_fmt_descriptors[0];
- while (prev - av_pix_fmt_descriptors < FF_ARRAY_ELEMS(av_pix_fmt_descriptors) - 1) {
- prev++;
- if (prev->name)
- return prev;
- }
- return NULL;
-}
-
-enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
-{
- if (desc < av_pix_fmt_descriptors ||
- desc >= av_pix_fmt_descriptors + FF_ARRAY_ELEMS(av_pix_fmt_descriptors))
- return AV_PIX_FMT_NONE;
-
- return desc - av_pix_fmt_descriptors;
-}
-
-int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt,
- int *h_shift, int *v_shift)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- if (!desc)
- return AVERROR(ENOSYS);
- *h_shift = desc->log2_chroma_w;
- *v_shift = desc->log2_chroma_h;
-
- return 0;
-}
diff --git a/src/thirdparty/ffmpeg/libavutil/pixdesc.h b/src/thirdparty/ffmpeg/libavutil/pixdesc.h
deleted file mode 100644
index 4921c5880..000000000
--- a/src/thirdparty/ffmpeg/libavutil/pixdesc.h
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * pixel format descriptor
- * Copyright (c) 2009 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
- */
-
-#ifndef AVUTIL_PIXDESC_H
-#define AVUTIL_PIXDESC_H
-
-#include <inttypes.h>
-#include "pixfmt.h"
-
-typedef struct AVComponentDescriptor{
- uint16_t plane :2; ///< which of the 4 planes contains the component
-
- /**
- * Number of elements between 2 horizontally consecutive pixels minus 1.
- * Elements are bits for bitstream formats, bytes otherwise.
- */
- uint16_t step_minus1 :3;
-
- /**
- * Number of elements before the component of the first pixel plus 1.
- * Elements are bits for bitstream formats, bytes otherwise.
- */
- uint16_t offset_plus1 :3;
- uint16_t shift :3; ///< number of least significant bits that must be shifted away to get the value
- uint16_t depth_minus1 :4; ///< number of bits in the component minus 1
-}AVComponentDescriptor;
-
-/**
- * Descriptor that unambiguously describes how the bits of a pixel are
- * stored in the up to 4 data planes of an image. It also stores the
- * subsampling factors and number of components.
- *
- * @note This is separate of the colorspace (RGB, YCbCr, YPbPr, JPEG-style YUV
- * and all the YUV variants) AVPixFmtDescriptor just stores how values
- * are stored not what these values represent.
- */
-typedef struct AVPixFmtDescriptor{
- const char *name;
- uint8_t nb_components; ///< The number of components each pixel has, (1-4)
-
- /**
- * Amount to shift the luma width right to find the chroma width.
- * For YV12 this is 1 for example.
- * chroma_width = -((-luma_width) >> log2_chroma_w)
- * The note above is needed to ensure rounding up.
- * This value only refers to the chroma components.
- */
- uint8_t log2_chroma_w; ///< chroma_width = -((-luma_width )>>log2_chroma_w)
-
- /**
- * Amount to shift the luma height right to find the chroma height.
- * For YV12 this is 1 for example.
- * chroma_height= -((-luma_height) >> log2_chroma_h)
- * The note above is needed to ensure rounding up.
- * This value only refers to the chroma components.
- */
- uint8_t log2_chroma_h;
- uint8_t flags;
-
- /**
- * Parameters that describe how pixels are packed.
- * If the format has 2 or 4 components, then alpha is last.
- * If the format has 1 or 2 components, then luma is 0.
- * If the format has 3 or 4 components,
- * if the RGB flag is set then 0 is red, 1 is green and 2 is blue;
- * otherwise 0 is luma, 1 is chroma-U and 2 is chroma-V.
- */
- AVComponentDescriptor comp[4];
-}AVPixFmtDescriptor;
-
-#define PIX_FMT_BE 1 ///< Pixel format is big-endian.
-#define PIX_FMT_PAL 2 ///< Pixel format has a palette in data[1], values are indexes in this palette.
-#define PIX_FMT_BITSTREAM 4 ///< All values of a component are bit-wise packed end to end.
-#define PIX_FMT_HWACCEL 8 ///< Pixel format is an HW accelerated format.
-#define PIX_FMT_PLANAR 16 ///< At least one pixel component is not in the first data plane
-#define PIX_FMT_RGB 32 ///< The pixel format contains RGB-like data (as opposed to YUV/grayscale)
-/**
- * The pixel format is "pseudo-paletted". This means that FFmpeg treats it as
- * paletted internally, but the palette is generated by the decoder and is not
- * stored in the file.
- */
-#define PIX_FMT_PSEUDOPAL 64
-
-#define PIX_FMT_ALPHA 128 ///< The pixel format has an alpha channel
-
-
-#if FF_API_PIX_FMT_DESC
-/**
- * The array of all the pixel format descriptors.
- */
-extern const AVPixFmtDescriptor av_pix_fmt_descriptors[];
-#endif
-
-/**
- * Read a line from an image, and write the values of the
- * pixel format component c to dst.
- *
- * @param data the array containing the pointers to the planes of the image
- * @param linesize the array containing the linesizes of the image
- * @param desc the pixel format descriptor for the image
- * @param x the horizontal coordinate of the first pixel to read
- * @param y the vertical coordinate of the first pixel to read
- * @param w the width of the line to read, that is the number of
- * values to write to dst
- * @param read_pal_component if not zero and the format is a paletted
- * format writes the values corresponding to the palette
- * component c in data[1] to dst, rather than the palette indexes in
- * data[0]. The behavior is undefined if the format is not paletted.
- */
-void av_read_image_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4],
- const AVPixFmtDescriptor *desc, int x, int y, int c, int w, int read_pal_component);
-
-/**
- * Write the values from src to the pixel format component c of an
- * image line.
- *
- * @param src array containing the values to write
- * @param data the array containing the pointers to the planes of the
- * image to write into. It is supposed to be zeroed.
- * @param linesize the array containing the linesizes of the image
- * @param desc the pixel format descriptor for the image
- * @param x the horizontal coordinate of the first pixel to write
- * @param y the vertical coordinate of the first pixel to write
- * @param w the width of the line to write, that is the number of
- * values to write to the image line
- */
-void av_write_image_line(const uint16_t *src, uint8_t *data[4], const int linesize[4],
- const AVPixFmtDescriptor *desc, int x, int y, int c, int w);
-
-/**
- * Return the pixel format corresponding to name.
- *
- * If there is no pixel format with name name, then looks for a
- * pixel format with the name corresponding to the native endian
- * format of name.
- * For example in a little-endian system, first looks for "gray16",
- * then for "gray16le".
- *
- * Finally if no pixel format has been found, returns AV_PIX_FMT_NONE.
- */
-enum AVPixelFormat av_get_pix_fmt(const char *name);
-
-/**
- * Return the short name for a pixel format, NULL in case pix_fmt is
- * unknown.
- *
- * @see av_get_pix_fmt(), av_get_pix_fmt_string()
- */
-const char *av_get_pix_fmt_name(enum AVPixelFormat pix_fmt);
-
-/**
- * Print in buf the string corresponding to the pixel format with
- * number pix_fmt, or an header if pix_fmt is negative.
- *
- * @param buf the buffer where to write the string
- * @param buf_size the size of buf
- * @param pix_fmt the number of the pixel format to print the
- * corresponding info string, or a negative value to print the
- * corresponding header.
- */
-char *av_get_pix_fmt_string (char *buf, int buf_size, enum AVPixelFormat pix_fmt);
-
-/**
- * Return the number of bits per pixel used by the pixel format
- * described by pixdesc.
- *
- * The returned number of bits refers to the number of bits actually
- * used for storing the pixel information, that is padding bits are
- * not counted.
- */
-int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc);
-
-/**
- * Return the number of bits per pixel for the pixel format
- * described by pixdesc, including any padding or unused bits.
- */
-int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc);
-
-/**
- * @return a pixel format descriptor for provided pixel format or NULL if
- * this pixel format is unknown.
- */
-const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt);
-
-/**
- * Iterate over all pixel format descriptors known to libavutil.
- *
- * @param prev previous descriptor. NULL to get the first descriptor.
- *
- * @return next descriptor or NULL after the last descriptor
- */
-const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev);
-
-/**
- * @return an AVPixelFormat id described by desc, or AV_PIX_FMT_NONE if desc
- * is not a valid pointer to a pixel format descriptor.
- */
-enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc);
-
-/**
- * Utility function to access log2_chroma_w log2_chroma_h from
- * the pixel format AVPixFmtDescriptor.
- *
- * See avcodec_get_chroma_sub_sample() for a function that asserts a
- * valid pixel format instead of returning an error code.
- * Its recommanded that you use avcodec_get_chroma_sub_sample unless
- * you do check the return code!
- *
- * @param[in] pix_fmt the pixel format
- * @param[out] h_shift store log2_chroma_h
- * @param[out] v_shift store log2_chroma_w
- *
- * @return 0 on success, AVERROR(ENOSYS) on invalid or unknown pixel format
- */
-int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt,
- int *h_shift, int *v_shift);
-
-
-#endif /* AVUTIL_PIXDESC_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/pixfmt.h b/src/thirdparty/ffmpeg/libavutil/pixfmt.h
deleted file mode 100644
index 3389f4555..000000000
--- a/src/thirdparty/ffmpeg/libavutil/pixfmt.h
+++ /dev/null
@@ -1,357 +0,0 @@
-/*
- * copyright (c) 2006 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
- */
-
-#ifndef AVUTIL_PIXFMT_H
-#define AVUTIL_PIXFMT_H
-
-/**
- * @file
- * pixel format definitions
- *
- */
-
-#include "libavutil/avconfig.h"
-#include "libavutil/version.h"
-
-#define AVPALETTE_SIZE 1024
-#define AVPALETTE_COUNT 256
-
-/**
- * Pixel format.
- *
- * @note
- * PIX_FMT_RGB32 is handled in an endian-specific manner. An RGBA
- * color is put together as:
- * (A << 24) | (R << 16) | (G << 8) | B
- * This is stored as BGRA on little-endian CPU architectures and ARGB on
- * big-endian CPUs.
- *
- * @par
- * When the pixel format is palettized RGB (PIX_FMT_PAL8), the palettized
- * image data is stored in AVFrame.data[0]. The palette is transported in
- * AVFrame.data[1], is 1024 bytes long (256 4-byte entries) and is
- * formatted the same as in PIX_FMT_RGB32 described above (i.e., it is
- * also endian-specific). Note also that the individual RGB palette
- * components stored in AVFrame.data[1] should be in the range 0..255.
- * This is important as many custom PAL8 video codecs that were designed
- * to run on the IBM VGA graphics adapter use 6-bit palette components.
- *
- * @par
- * For all the 8bit per pixel formats, an RGB32 palette is in data[1] like
- * for pal8. This palette is filled in automatically by the function
- * allocating the picture.
- *
- * @note
- * Make sure that all newly added big-endian formats have pix_fmt & 1 == 1
- * and that all newly added little-endian formats have pix_fmt & 1 == 0.
- * This allows simpler detection of big vs little-endian.
- */
-enum AVPixelFormat {
- AV_PIX_FMT_NONE = -1,
- AV_PIX_FMT_YUV420P, ///< planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
- AV_PIX_FMT_YUYV422, ///< packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
- AV_PIX_FMT_RGB24, ///< packed RGB 8:8:8, 24bpp, RGBRGB...
- AV_PIX_FMT_BGR24, ///< packed RGB 8:8:8, 24bpp, BGRBGR...
- AV_PIX_FMT_YUV422P, ///< planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
- AV_PIX_FMT_YUV444P, ///< planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
- AV_PIX_FMT_YUV410P, ///< planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
- AV_PIX_FMT_YUV411P, ///< planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
- AV_PIX_FMT_GRAY8, ///< Y , 8bpp
- AV_PIX_FMT_MONOWHITE, ///< Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb
- AV_PIX_FMT_MONOBLACK, ///< Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb
- AV_PIX_FMT_PAL8, ///< 8 bit with PIX_FMT_RGB32 palette
- AV_PIX_FMT_YUVJ420P, ///< planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_range
- AV_PIX_FMT_YUVJ422P, ///< planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_range
- AV_PIX_FMT_YUVJ444P, ///< planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_range
- AV_PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing
- AV_PIX_FMT_XVMC_MPEG2_IDCT,
- AV_PIX_FMT_UYVY422, ///< packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
- AV_PIX_FMT_UYYVYY411, ///< packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
- AV_PIX_FMT_BGR8, ///< packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
- AV_PIX_FMT_BGR4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits
- AV_PIX_FMT_BGR4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
- AV_PIX_FMT_RGB8, ///< packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
- AV_PIX_FMT_RGB4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits
- AV_PIX_FMT_RGB4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
- AV_PIX_FMT_NV12, ///< planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V)
- AV_PIX_FMT_NV21, ///< as above, but U and V bytes are swapped
-
- AV_PIX_FMT_ARGB, ///< packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
- AV_PIX_FMT_RGBA, ///< packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
- AV_PIX_FMT_ABGR, ///< packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
- AV_PIX_FMT_BGRA, ///< packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
-
- AV_PIX_FMT_GRAY16BE, ///< Y , 16bpp, big-endian
- AV_PIX_FMT_GRAY16LE, ///< Y , 16bpp, little-endian
- AV_PIX_FMT_YUV440P, ///< planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
- AV_PIX_FMT_YUVJ440P, ///< planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range
- AV_PIX_FMT_YUVA420P, ///< planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
- AV_PIX_FMT_VDPAU_H264,///< H.264 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
- AV_PIX_FMT_VDPAU_MPEG1,///< MPEG-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
- AV_PIX_FMT_VDPAU_MPEG2,///< MPEG-2 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
- AV_PIX_FMT_VDPAU_WMV3,///< WMV3 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
- AV_PIX_FMT_VDPAU_VC1, ///< VC-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
- AV_PIX_FMT_RGB48BE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big-endian
- AV_PIX_FMT_RGB48LE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as little-endian
-
- AV_PIX_FMT_RGB565BE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
- AV_PIX_FMT_RGB565LE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
- AV_PIX_FMT_RGB555BE, ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0
- AV_PIX_FMT_RGB555LE, ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0
-
- AV_PIX_FMT_BGR565BE, ///< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
- AV_PIX_FMT_BGR565LE, ///< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
- AV_PIX_FMT_BGR555BE, ///< packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), big-endian, most significant bit to 1
- AV_PIX_FMT_BGR555LE, ///< packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), little-endian, most significant bit to 1
-
- AV_PIX_FMT_VAAPI_MOCO, ///< HW acceleration through VA API at motion compensation entry-point, Picture.data[3] contains a vaapi_render_state struct which contains macroblocks as well as various fields extracted from headers
- AV_PIX_FMT_VAAPI_IDCT, ///< HW acceleration through VA API at IDCT entry-point, Picture.data[3] contains a vaapi_render_state struct which contains fields extracted from headers
- AV_PIX_FMT_VAAPI_VLD, ///< HW decoding through VA API, Picture.data[3] contains a vaapi_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
-
- AV_PIX_FMT_YUV420P16LE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
- AV_PIX_FMT_YUV420P16BE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
- AV_PIX_FMT_YUV422P16LE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
- AV_PIX_FMT_YUV422P16BE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
- AV_PIX_FMT_YUV444P16LE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
- AV_PIX_FMT_YUV444P16BE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
- AV_PIX_FMT_VDPAU_MPEG4, ///< MPEG4 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
- AV_PIX_FMT_DXVA2_VLD, ///< HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer
-
- AV_PIX_FMT_RGB444LE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0
- AV_PIX_FMT_RGB444BE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-endian, most significant bits to 0
- AV_PIX_FMT_BGR444LE, ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), little-endian, most significant bits to 1
- AV_PIX_FMT_BGR444BE, ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), big-endian, most significant bits to 1
- AV_PIX_FMT_GRAY8A, ///< 8bit gray, 8bit alpha
- AV_PIX_FMT_BGR48BE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big-endian
- AV_PIX_FMT_BGR48LE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as little-endian
-
- //the following 10 formats have the disadvantage of needing 1 format for each bit depth, thus
- //If you want to support multiple bit depths, then using AV_PIX_FMT_YUV420P16* with the bpp stored separately
- //is better
- AV_PIX_FMT_YUV420P9BE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
- AV_PIX_FMT_YUV420P9LE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
- AV_PIX_FMT_YUV420P10BE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
- AV_PIX_FMT_YUV420P10LE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
- AV_PIX_FMT_YUV422P10BE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
- AV_PIX_FMT_YUV422P10LE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
- AV_PIX_FMT_YUV444P9BE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
- AV_PIX_FMT_YUV444P9LE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
- AV_PIX_FMT_YUV444P10BE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
- AV_PIX_FMT_YUV444P10LE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
- AV_PIX_FMT_YUV422P9BE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
- AV_PIX_FMT_YUV422P9LE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
- AV_PIX_FMT_VDA_VLD, ///< hardware decoding through VDA
-
-#ifdef AV_PIX_FMT_ABI_GIT_MASTER
- AV_PIX_FMT_RGBA64BE, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
- AV_PIX_FMT_RGBA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
- AV_PIX_FMT_BGRA64BE, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
- AV_PIX_FMT_BGRA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
-#endif
- AV_PIX_FMT_GBRP, ///< planar GBR 4:4:4 24bpp
- AV_PIX_FMT_GBRP9BE, ///< planar GBR 4:4:4 27bpp, big-endian
- AV_PIX_FMT_GBRP9LE, ///< planar GBR 4:4:4 27bpp, little-endian
- AV_PIX_FMT_GBRP10BE, ///< planar GBR 4:4:4 30bpp, big-endian
- AV_PIX_FMT_GBRP10LE, ///< planar GBR 4:4:4 30bpp, little-endian
- AV_PIX_FMT_GBRP16BE, ///< planar GBR 4:4:4 48bpp, big-endian
- AV_PIX_FMT_GBRP16LE, ///< planar GBR 4:4:4 48bpp, little-endian
-
- /**
- * duplicated pixel formats for compatibility with libav.
- * FFmpeg supports these formats since May 8 2012 and Jan 28 2012 (commits f9ca1ac7 and 143a5c55)
- * Libav added them Oct 12 2012 with incompatible values (commit 6d5600e85)
- */
- AV_PIX_FMT_YUVA422P_LIBAV, ///< planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
- AV_PIX_FMT_YUVA444P_LIBAV, ///< planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
-
- AV_PIX_FMT_YUVA420P9BE, ///< planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), big-endian
- AV_PIX_FMT_YUVA420P9LE, ///< planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), little-endian
- AV_PIX_FMT_YUVA422P9BE, ///< planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), big-endian
- AV_PIX_FMT_YUVA422P9LE, ///< planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), little-endian
- AV_PIX_FMT_YUVA444P9BE, ///< planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), big-endian
- AV_PIX_FMT_YUVA444P9LE, ///< planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), little-endian
- AV_PIX_FMT_YUVA420P10BE, ///< planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
- AV_PIX_FMT_YUVA420P10LE, ///< planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
- AV_PIX_FMT_YUVA422P10BE, ///< planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
- AV_PIX_FMT_YUVA422P10LE, ///< planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
- AV_PIX_FMT_YUVA444P10BE, ///< planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
- AV_PIX_FMT_YUVA444P10LE, ///< planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
- AV_PIX_FMT_YUVA420P16BE, ///< planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
- AV_PIX_FMT_YUVA420P16LE, ///< planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
- AV_PIX_FMT_YUVA422P16BE, ///< planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
- AV_PIX_FMT_YUVA422P16LE, ///< planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
- AV_PIX_FMT_YUVA444P16BE, ///< planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
- AV_PIX_FMT_YUVA444P16LE, ///< planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
-
- AV_PIX_FMT_VDPAU, ///< HW acceleration through VDPAU, Picture.data[3] contains a VdpVideoSurface
-
-#ifndef AV_PIX_FMT_ABI_GIT_MASTER
- AV_PIX_FMT_RGBA64BE=0x123, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
- AV_PIX_FMT_RGBA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
- AV_PIX_FMT_BGRA64BE, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
- AV_PIX_FMT_BGRA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
-#endif
- AV_PIX_FMT_0RGB=0x123+4, ///< packed RGB 8:8:8, 32bpp, 0RGB0RGB...
- AV_PIX_FMT_RGB0, ///< packed RGB 8:8:8, 32bpp, RGB0RGB0...
- AV_PIX_FMT_0BGR, ///< packed BGR 8:8:8, 32bpp, 0BGR0BGR...
- AV_PIX_FMT_BGR0, ///< packed BGR 8:8:8, 32bpp, BGR0BGR0...
- AV_PIX_FMT_YUVA444P, ///< planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
- AV_PIX_FMT_YUVA422P, ///< planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
-
- AV_PIX_FMT_YUV420P12BE, ///< planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
- AV_PIX_FMT_YUV420P12LE, ///< planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
- AV_PIX_FMT_YUV420P14BE, ///< planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
- AV_PIX_FMT_YUV420P14LE, ///< planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
- AV_PIX_FMT_YUV422P12BE, ///< planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
- AV_PIX_FMT_YUV422P12LE, ///< planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
- AV_PIX_FMT_YUV422P14BE, ///< planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
- AV_PIX_FMT_YUV422P14LE, ///< planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
- AV_PIX_FMT_YUV444P12BE, ///< planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
- AV_PIX_FMT_YUV444P12LE, ///< planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
- AV_PIX_FMT_YUV444P14BE, ///< planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
- AV_PIX_FMT_YUV444P14LE, ///< planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
- AV_PIX_FMT_GBRP12BE, ///< planar GBR 4:4:4 36bpp, big-endian
- AV_PIX_FMT_GBRP12LE, ///< planar GBR 4:4:4 36bpp, little-endian
- AV_PIX_FMT_GBRP14BE, ///< planar GBR 4:4:4 42bpp, big-endian
- AV_PIX_FMT_GBRP14LE, ///< planar GBR 4:4:4 42bpp, little-endian
- AV_PIX_FMT_NB, ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions
-
-#if FF_API_PIX_FMT
-#include "old_pix_fmts.h"
-#endif
-};
-
-#if AV_HAVE_INCOMPATIBLE_FORK_ABI
-#define AV_PIX_FMT_YUVA422P AV_PIX_FMT_YUVA422P_LIBAV
-#define AV_PIX_FMT_YUVA444P AV_PIX_FMT_YUVA444P_LIBAV
-#endif
-
-
-#define AV_PIX_FMT_Y400A AV_PIX_FMT_GRAY8A
-#define AV_PIX_FMT_GBR24P AV_PIX_FMT_GBRP
-
-#if AV_HAVE_BIGENDIAN
-# define AV_PIX_FMT_NE(be, le) AV_PIX_FMT_##be
-#else
-# define AV_PIX_FMT_NE(be, le) AV_PIX_FMT_##le
-#endif
-
-#define AV_PIX_FMT_RGB32 AV_PIX_FMT_NE(ARGB, BGRA)
-#define AV_PIX_FMT_RGB32_1 AV_PIX_FMT_NE(RGBA, ABGR)
-#define AV_PIX_FMT_BGR32 AV_PIX_FMT_NE(ABGR, RGBA)
-#define AV_PIX_FMT_BGR32_1 AV_PIX_FMT_NE(BGRA, ARGB)
-#define AV_PIX_FMT_0RGB32 AV_PIX_FMT_NE(0RGB, BGR0)
-#define AV_PIX_FMT_0BGR32 AV_PIX_FMT_NE(0BGR, RGB0)
-
-#define AV_PIX_FMT_GRAY16 AV_PIX_FMT_NE(GRAY16BE, GRAY16LE)
-#define AV_PIX_FMT_RGB48 AV_PIX_FMT_NE(RGB48BE, RGB48LE)
-#define AV_PIX_FMT_RGB565 AV_PIX_FMT_NE(RGB565BE, RGB565LE)
-#define AV_PIX_FMT_RGB555 AV_PIX_FMT_NE(RGB555BE, RGB555LE)
-#define AV_PIX_FMT_RGB444 AV_PIX_FMT_NE(RGB444BE, RGB444LE)
-#define AV_PIX_FMT_BGR48 AV_PIX_FMT_NE(BGR48BE, BGR48LE)
-#define AV_PIX_FMT_BGR565 AV_PIX_FMT_NE(BGR565BE, BGR565LE)
-#define AV_PIX_FMT_BGR555 AV_PIX_FMT_NE(BGR555BE, BGR555LE)
-#define AV_PIX_FMT_BGR444 AV_PIX_FMT_NE(BGR444BE, BGR444LE)
-
-#define AV_PIX_FMT_YUV420P9 AV_PIX_FMT_NE(YUV420P9BE , YUV420P9LE)
-#define AV_PIX_FMT_YUV422P9 AV_PIX_FMT_NE(YUV422P9BE , YUV422P9LE)
-#define AV_PIX_FMT_YUV444P9 AV_PIX_FMT_NE(YUV444P9BE , YUV444P9LE)
-#define AV_PIX_FMT_YUV420P10 AV_PIX_FMT_NE(YUV420P10BE, YUV420P10LE)
-#define AV_PIX_FMT_YUV422P10 AV_PIX_FMT_NE(YUV422P10BE, YUV422P10LE)
-#define AV_PIX_FMT_YUV444P10 AV_PIX_FMT_NE(YUV444P10BE, YUV444P10LE)
-#define AV_PIX_FMT_YUV420P12 AV_PIX_FMT_NE(YUV420P12BE, YUV420P12LE)
-#define AV_PIX_FMT_YUV422P12 AV_PIX_FMT_NE(YUV422P12BE, YUV422P12LE)
-#define AV_PIX_FMT_YUV444P12 AV_PIX_FMT_NE(YUV444P12BE, YUV444P12LE)
-#define AV_PIX_FMT_YUV420P14 AV_PIX_FMT_NE(YUV420P14BE, YUV420P14LE)
-#define AV_PIX_FMT_YUV422P14 AV_PIX_FMT_NE(YUV422P14BE, YUV422P14LE)
-#define AV_PIX_FMT_YUV444P14 AV_PIX_FMT_NE(YUV444P14BE, YUV444P14LE)
-#define AV_PIX_FMT_YUV420P16 AV_PIX_FMT_NE(YUV420P16BE, YUV420P16LE)
-#define AV_PIX_FMT_YUV422P16 AV_PIX_FMT_NE(YUV422P16BE, YUV422P16LE)
-#define AV_PIX_FMT_YUV444P16 AV_PIX_FMT_NE(YUV444P16BE, YUV444P16LE)
-
-#define AV_PIX_FMT_RGBA64 AV_PIX_FMT_NE(RGBA64BE, RGBA64LE)
-#define AV_PIX_FMT_BGRA64 AV_PIX_FMT_NE(BGRA64BE, BGRA64LE)
-#define AV_PIX_FMT_GBRP9 AV_PIX_FMT_NE(GBRP9BE , GBRP9LE)
-#define AV_PIX_FMT_GBRP10 AV_PIX_FMT_NE(GBRP10BE, GBRP10LE)
-#define AV_PIX_FMT_GBRP12 AV_PIX_FMT_NE(GBRP12BE, GBRP12LE)
-#define AV_PIX_FMT_GBRP14 AV_PIX_FMT_NE(GBRP14BE, GBRP14LE)
-#define AV_PIX_FMT_GBRP16 AV_PIX_FMT_NE(GBRP16BE, GBRP16LE)
-
-#define AV_PIX_FMT_YUVA420P9 AV_PIX_FMT_NE(YUVA420P9BE , YUVA420P9LE)
-#define AV_PIX_FMT_YUVA422P9 AV_PIX_FMT_NE(YUVA422P9BE , YUVA422P9LE)
-#define AV_PIX_FMT_YUVA444P9 AV_PIX_FMT_NE(YUVA444P9BE , YUVA444P9LE)
-#define AV_PIX_FMT_YUVA420P10 AV_PIX_FMT_NE(YUVA420P10BE, YUVA420P10LE)
-#define AV_PIX_FMT_YUVA422P10 AV_PIX_FMT_NE(YUVA422P10BE, YUVA422P10LE)
-#define AV_PIX_FMT_YUVA444P10 AV_PIX_FMT_NE(YUVA444P10BE, YUVA444P10LE)
-#define AV_PIX_FMT_YUVA420P16 AV_PIX_FMT_NE(YUVA420P16BE, YUVA420P16LE)
-#define AV_PIX_FMT_YUVA422P16 AV_PIX_FMT_NE(YUVA422P16BE, YUVA422P16LE)
-#define AV_PIX_FMT_YUVA444P16 AV_PIX_FMT_NE(YUVA444P16BE, YUVA444P16LE)
-
-#if FF_API_PIX_FMT
-#define PixelFormat AVPixelFormat
-
-#define PIX_FMT_Y400A AV_PIX_FMT_Y400A
-#define PIX_FMT_GBR24P AV_PIX_FMT_GBR24P
-
-#define PIX_FMT_NE(be, le) AV_PIX_FMT_NE(be, le)
-
-#define PIX_FMT_RGB32 AV_PIX_FMT_RGB32
-#define PIX_FMT_RGB32_1 AV_PIX_FMT_RGB32_1
-#define PIX_FMT_BGR32 AV_PIX_FMT_BGR32
-#define PIX_FMT_BGR32_1 AV_PIX_FMT_BGR32_1
-#define PIX_FMT_0RGB32 AV_PIX_FMT_0RGB32
-#define PIX_FMT_0BGR32 AV_PIX_FMT_0BGR32
-
-#define PIX_FMT_GRAY16 AV_PIX_FMT_GRAY16
-#define PIX_FMT_RGB48 AV_PIX_FMT_RGB48
-#define PIX_FMT_RGB565 AV_PIX_FMT_RGB565
-#define PIX_FMT_RGB555 AV_PIX_FMT_RGB555
-#define PIX_FMT_RGB444 AV_PIX_FMT_RGB444
-#define PIX_FMT_BGR48 AV_PIX_FMT_BGR48
-#define PIX_FMT_BGR565 AV_PIX_FMT_BGR565
-#define PIX_FMT_BGR555 AV_PIX_FMT_BGR555
-#define PIX_FMT_BGR444 AV_PIX_FMT_BGR444
-
-#define PIX_FMT_YUV420P9 AV_PIX_FMT_YUV420P9
-#define PIX_FMT_YUV422P9 AV_PIX_FMT_YUV422P9
-#define PIX_FMT_YUV444P9 AV_PIX_FMT_YUV444P9
-#define PIX_FMT_YUV420P10 AV_PIX_FMT_YUV420P10
-#define PIX_FMT_YUV422P10 AV_PIX_FMT_YUV422P10
-#define PIX_FMT_YUV444P10 AV_PIX_FMT_YUV444P10
-#define PIX_FMT_YUV420P12 AV_PIX_FMT_YUV420P12
-#define PIX_FMT_YUV422P12 AV_PIX_FMT_YUV422P12
-#define PIX_FMT_YUV444P12 AV_PIX_FMT_YUV444P12
-#define PIX_FMT_YUV420P14 AV_PIX_FMT_YUV420P14
-#define PIX_FMT_YUV422P14 AV_PIX_FMT_YUV422P14
-#define PIX_FMT_YUV444P14 AV_PIX_FMT_YUV444P14
-#define PIX_FMT_YUV420P16 AV_PIX_FMT_YUV420P16
-#define PIX_FMT_YUV422P16 AV_PIX_FMT_YUV422P16
-#define PIX_FMT_YUV444P16 AV_PIX_FMT_YUV444P16
-
-#define PIX_FMT_RGBA64 AV_PIX_FMT_RGBA64
-#define PIX_FMT_BGRA64 AV_PIX_FMT_BGRA64
-#define PIX_FMT_GBRP9 AV_PIX_FMT_GBRP9
-#define PIX_FMT_GBRP10 AV_PIX_FMT_GBRP10
-#define PIX_FMT_GBRP12 AV_PIX_FMT_GBRP12
-#define PIX_FMT_GBRP14 AV_PIX_FMT_GBRP14
-#define PIX_FMT_GBRP16 AV_PIX_FMT_GBRP16
-#endif
-
-#endif /* AVUTIL_PIXFMT_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/random_seed.c b/src/thirdparty/ffmpeg/libavutil/random_seed.c
deleted file mode 100644
index 8aecd2641..000000000
--- a/src/thirdparty/ffmpeg/libavutil/random_seed.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (c) 2009 Baptiste Coudurier <baptiste.coudurier@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 "config.h"
-
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#if HAVE_CRYPTGENRANDOM
-#include <windows.h>
-#include <wincrypt.h>
-#endif
-#include <fcntl.h>
-#include <math.h>
-#include <time.h>
-#include <string.h>
-#include "avassert.h"
-#include "timer.h"
-#include "random_seed.h"
-#include "sha.h"
-#include "intreadwrite.h"
-
-#ifndef TEST
-#define TEST 0
-#endif
-
-static int read_random(uint32_t *dst, const char *file)
-{
-#if HAVE_UNISTD_H
- int fd = open(file, O_RDONLY);
- int err = -1;
-
- if (fd == -1)
- return -1;
- err = read(fd, dst, sizeof(*dst));
- close(fd);
-
- return err;
-#else
- return -1;
-#endif
-}
-
-static uint32_t get_generic_seed(void)
-{
- uint8_t tmp[120];
- struct AVSHA *sha = (void*)tmp;
- clock_t last_t = 0;
- static uint64_t i = 0;
- static uint32_t buffer[512] = {0};
- unsigned char digest[20];
- uint64_t last_i = i;
-
- av_assert0(sizeof(tmp) >= av_sha_size);
-
- if(TEST){
- memset(buffer, 0, sizeof(buffer));
- last_i = i = 0;
- }else{
-#ifdef AV_READ_TIME
- buffer[13] ^= AV_READ_TIME();
- buffer[41] ^= AV_READ_TIME()>>32;
-#endif
- }
-
- for (;;) {
- clock_t t = clock();
-
- if(last_t == t){
- buffer[i&511]++;
- }else{
- buffer[++i&511]+= (t-last_t) % 3294638521U;
- if(last_i && i-last_i > 4 || i-last_i > 64 || TEST && i-last_i > 8)
- break;
- }
- last_t = t;
- }
-
- if(TEST)
- buffer[0] = buffer[1] = 0;
-
- av_sha_init(sha, 160);
- av_sha_update(sha, (uint8_t*)buffer, sizeof(buffer));
- av_sha_final(sha, digest);
- return AV_RB32(digest) + AV_RB32(digest+16);
-}
-
-uint32_t av_get_random_seed(void)
-{
- uint32_t seed;
-
-#if HAVE_CRYPTGENRANDOM
- HCRYPTPROV provider;
- if (CryptAcquireContext(&provider, NULL, NULL, PROV_RSA_FULL,
- CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
- BOOL ret = CryptGenRandom(provider, sizeof(seed), (PBYTE) &seed);
- CryptReleaseContext(provider, 0);
- if (ret)
- return seed;
- }
-#endif
-
- if (read_random(&seed, "/dev/urandom") == sizeof(seed))
- return seed;
- if (read_random(&seed, "/dev/random") == sizeof(seed))
- return seed;
- return get_generic_seed();
-}
-
-#if TEST
-#undef printf
-#define N 256
-#include <stdio.h>
-
-int main(void)
-{
- int i, j, retry;
- uint32_t seeds[N];
-
- for (retry=0; retry<3; retry++){
- for (i=0; i<N; i++){
- seeds[i] = av_get_random_seed();
- for (j=0; j<i; j++)
- if (seeds[j] == seeds[i])
- goto retry;
- }
- printf("seeds OK\n");
- return 0;
- retry:;
- }
- printf("FAIL at %d with %X\n", j, seeds[j]);
- return 1;
-}
-#endif
diff --git a/src/thirdparty/ffmpeg/libavutil/random_seed.h b/src/thirdparty/ffmpeg/libavutil/random_seed.h
deleted file mode 100644
index 13d3eb8d1..000000000
--- a/src/thirdparty/ffmpeg/libavutil/random_seed.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2009 Baptiste Coudurier <baptiste.coudurier@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 AVUTIL_RANDOM_SEED_H
-#define AVUTIL_RANDOM_SEED_H
-
-#include <stdint.h>
-/**
- * @addtogroup lavu_crypto
- * @{
- */
-
-/**
- * Get a seed to use in conjunction with random functions.
- * This function tries to provide a good seed at a best effort bases.
- * Its possible to call this function multiple times if more bits are needed.
- * It can be quite slow, which is why it should only be used as seed for a faster
- * PRNG. The quality of the seed depends on the platform.
- */
-uint32_t av_get_random_seed(void);
-
-/**
- * @}
- */
-
-#endif /* AVUTIL_RANDOM_SEED_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/rational.c b/src/thirdparty/ffmpeg/libavutil/rational.c
deleted file mode 100644
index 3f661d70a..000000000
--- a/src/thirdparty/ffmpeg/libavutil/rational.c
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * rational numbers
- * 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
- * rational numbers
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#include "avassert.h"
-//#include <math.h>
-#include <limits.h>
-
-#include "common.h"
-#include "mathematics.h"
-#include "rational.h"
-
-int av_reduce(int *dst_num, int *dst_den,
- int64_t num, int64_t den, int64_t max)
-{
- AVRational a0 = { 0, 1 }, a1 = { 1, 0 };
- int sign = (num < 0) ^ (den < 0);
- int64_t gcd = av_gcd(FFABS(num), FFABS(den));
-
- if (gcd) {
- num = FFABS(num) / gcd;
- den = FFABS(den) / gcd;
- }
- if (num <= max && den <= max) {
- a1 = (AVRational) { num, den };
- den = 0;
- }
-
- while (den) {
- uint64_t x = num / den;
- int64_t next_den = num - den * x;
- int64_t a2n = x * a1.num + a0.num;
- int64_t a2d = x * a1.den + a0.den;
-
- if (a2n > max || a2d > max) {
- if (a1.num) x = (max - a0.num) / a1.num;
- if (a1.den) x = FFMIN(x, (max - a0.den) / a1.den);
-
- if (den * (2 * x * a1.den + a0.den) > num * a1.den)
- a1 = (AVRational) { x * a1.num + a0.num, x * a1.den + a0.den };
- break;
- }
-
- a0 = a1;
- a1 = (AVRational) { a2n, a2d };
- num = den;
- den = next_den;
- }
- av_assert2(av_gcd(a1.num, a1.den) <= 1U);
-
- *dst_num = sign ? -a1.num : a1.num;
- *dst_den = a1.den;
-
- return den == 0;
-}
-
-AVRational av_mul_q(AVRational b, AVRational c)
-{
- av_reduce(&b.num, &b.den,
- b.num * (int64_t) c.num,
- b.den * (int64_t) c.den, INT_MAX);
- return b;
-}
-
-AVRational av_div_q(AVRational b, AVRational c)
-{
- return av_mul_q(b, (AVRational) { c.den, c.num });
-}
-
-AVRational av_add_q(AVRational b, AVRational c) {
- av_reduce(&b.num, &b.den,
- b.num * (int64_t) c.den +
- c.num * (int64_t) b.den,
- b.den * (int64_t) c.den, INT_MAX);
- return b;
-}
-
-AVRational av_sub_q(AVRational b, AVRational c)
-{
- return av_add_q(b, (AVRational) { -c.num, c.den });
-}
-
-AVRational av_d2q(double d, int max)
-{
- AVRational a;
-#define LOG2 0.69314718055994530941723212145817656807550013436025
- int exponent;
- int64_t den;
- if (isnan(d))
- return (AVRational) { 0,0 };
- if (isinf(d))
- return (AVRational) { d < 0 ? -1 : 1, 0 };
- exponent = FFMAX( (int)(log(fabs(d) + 1e-20)/LOG2), 0);
- den = 1LL << (61 - exponent);
- av_reduce(&a.num, &a.den, (int64_t)(d * den + 0.5), den, max);
-
- return a;
-}
-
-int av_nearer_q(AVRational q, AVRational q1, AVRational q2)
-{
- /* n/d is q, a/b is the median between q1 and q2 */
- int64_t a = q1.num * (int64_t)q2.den + q2.num * (int64_t)q1.den;
- int64_t b = 2 * (int64_t)q1.den * q2.den;
-
- /* rnd_up(a*d/b) > n => a*d/b > n */
- int64_t x_up = av_rescale_rnd(a, q.den, b, AV_ROUND_UP);
-
- /* rnd_down(a*d/b) < n => a*d/b < n */
- int64_t x_down = av_rescale_rnd(a, q.den, b, AV_ROUND_DOWN);
-
- return ((x_up > q.num) - (x_down < q.num)) * av_cmp_q(q2, q1);
-}
-
-int av_find_nearest_q_idx(AVRational q, const AVRational* q_list)
-{
- int i, nearest_q_idx = 0;
- for (i = 0; q_list[i].den; i++)
- if (av_nearer_q(q, q_list[i], q_list[nearest_q_idx]) > 0)
- nearest_q_idx = i;
-
- return nearest_q_idx;
-}
-
-#ifdef TEST
-int main(void)
-{
- AVRational a,b,r;
- for (a.num = -2; a.num <= 2; a.num++) {
- for (a.den = -2; a.den <= 2; a.den++) {
- for (b.num = -2; b.num <= 2; b.num++) {
- for (b.den = -2; b.den <= 2; b.den++) {
- int c = av_cmp_q(a,b);
- double d = av_q2d(a) == av_q2d(b) ?
- 0 : (av_q2d(a) - av_q2d(b));
- if (d > 0) d = 1;
- else if (d < 0) d = -1;
- else if (d != d) d = INT_MIN;
- if (c != d)
- av_log(NULL, AV_LOG_ERROR, "%d/%d %d/%d, %d %f\n", a.num,
- a.den, b.num, b.den, c,d);
- r = av_sub_q(av_add_q(b,a), b);
- if(b.den && (r.num*a.den != a.num*r.den || !r.num != !a.num || !r.den != !a.den))
- av_log(NULL, AV_LOG_ERROR, "%d/%d ", r.num, r.den);
- }
- }
- }
- }
- return 0;
-}
-#endif
diff --git a/src/thirdparty/ffmpeg/libavutil/rational.h b/src/thirdparty/ffmpeg/libavutil/rational.h
deleted file mode 100644
index dc1cc5115..000000000
--- a/src/thirdparty/ffmpeg/libavutil/rational.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * rational numbers
- * 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
- * rational numbers
- * @author Michael Niedermayer <michaelni@gmx.at>
- */
-
-#ifndef AVUTIL_RATIONAL_H
-#define AVUTIL_RATIONAL_H
-
-#include <stdint.h>
-#include <limits.h>
-#include "attributes.h"
-
-/**
- * @addtogroup lavu_math
- * @{
- */
-
-/**
- * rational number numerator/denominator
- */
-typedef struct AVRational{
- int num; ///< numerator
- int den; ///< denominator
-} AVRational;
-
-/**
- * Compare two rationals.
- * @param a first rational
- * @param b second rational
- * @return 0 if a==b, 1 if a>b, -1 if a<b, and INT_MIN if one of the
- * values is of the form 0/0
- */
-static inline int av_cmp_q(AVRational a, AVRational b){
- const int64_t tmp= a.num * (int64_t)b.den - b.num * (int64_t)a.den;
-
- if(tmp) return ((tmp ^ a.den ^ b.den)>>63)|1;
- else if(b.den && a.den) return 0;
- else if(a.num && b.num) return (a.num>>31) - (b.num>>31);
- else return INT_MIN;
-}
-
-/**
- * Convert rational to double.
- * @param a rational to convert
- * @return (double) a
- */
-static inline double av_q2d(AVRational a){
- return a.num / (double) a.den;
-}
-
-/**
- * Reduce a fraction.
- * This is useful for framerate calculations.
- * @param dst_num destination numerator
- * @param dst_den destination denominator
- * @param num source numerator
- * @param den source denominator
- * @param max the maximum allowed for dst_num & dst_den
- * @return 1 if exact, 0 otherwise
- */
-int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max);
-
-/**
- * Multiply two rationals.
- * @param b first rational
- * @param c second rational
- * @return b*c
- */
-AVRational av_mul_q(AVRational b, AVRational c) av_const;
-
-/**
- * Divide one rational by another.
- * @param b first rational
- * @param c second rational
- * @return b/c
- */
-AVRational av_div_q(AVRational b, AVRational c) av_const;
-
-/**
- * Add two rationals.
- * @param b first rational
- * @param c second rational
- * @return b+c
- */
-AVRational av_add_q(AVRational b, AVRational c) av_const;
-
-/**
- * Subtract one rational from another.
- * @param b first rational
- * @param c second rational
- * @return b-c
- */
-AVRational av_sub_q(AVRational b, AVRational c) av_const;
-
-/**
- * Invert a rational.
- * @param q value
- * @return 1 / q
- */
-static av_always_inline AVRational av_inv_q(AVRational q)
-{
- AVRational r = { q.den, q.num };
- return r;
-}
-
-/**
- * Convert a double precision floating point number to a rational.
- * inf is expressed as {1,0} or {-1,0} depending on the sign.
- *
- * @param d double to convert
- * @param max the maximum allowed numerator and denominator
- * @return (AVRational) d
- */
-AVRational av_d2q(double d, int max) av_const;
-
-/**
- * @return 1 if q1 is nearer to q than q2, -1 if q2 is nearer
- * than q1, 0 if they have the same distance.
- */
-int av_nearer_q(AVRational q, AVRational q1, AVRational q2);
-
-/**
- * Find the nearest value in q_list to q.
- * @param q_list an array of rationals terminated by {0, 0}
- * @return the index of the nearest value found in the array
- */
-int av_find_nearest_q_idx(AVRational q, const AVRational* q_list);
-
-/**
- * @}
- */
-
-#endif /* AVUTIL_RATIONAL_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/samplefmt.c b/src/thirdparty/ffmpeg/libavutil/samplefmt.c
deleted file mode 100644
index bdcd56889..000000000
--- a/src/thirdparty/ffmpeg/libavutil/samplefmt.c
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * 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 "common.h"
-#include "samplefmt.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-typedef struct SampleFmtInfo {
- char name[8];
- int bits;
- int planar;
- enum AVSampleFormat altform; ///< planar<->packed alternative form
-} SampleFmtInfo;
-
-/** this table gives more information about formats */
-static const SampleFmtInfo sample_fmt_info[AV_SAMPLE_FMT_NB] = {
- [AV_SAMPLE_FMT_U8] = { .name = "u8", .bits = 8, .planar = 0, .altform = AV_SAMPLE_FMT_U8P },
- [AV_SAMPLE_FMT_S16] = { .name = "s16", .bits = 16, .planar = 0, .altform = AV_SAMPLE_FMT_S16P },
- [AV_SAMPLE_FMT_S32] = { .name = "s32", .bits = 32, .planar = 0, .altform = AV_SAMPLE_FMT_S32P },
- [AV_SAMPLE_FMT_FLT] = { .name = "flt", .bits = 32, .planar = 0, .altform = AV_SAMPLE_FMT_FLTP },
- [AV_SAMPLE_FMT_DBL] = { .name = "dbl", .bits = 64, .planar = 0, .altform = AV_SAMPLE_FMT_DBLP },
- [AV_SAMPLE_FMT_U8P] = { .name = "u8p", .bits = 8, .planar = 1, .altform = AV_SAMPLE_FMT_U8 },
- [AV_SAMPLE_FMT_S16P] = { .name = "s16p", .bits = 16, .planar = 1, .altform = AV_SAMPLE_FMT_S16 },
- [AV_SAMPLE_FMT_S32P] = { .name = "s32p", .bits = 32, .planar = 1, .altform = AV_SAMPLE_FMT_S32 },
- [AV_SAMPLE_FMT_FLTP] = { .name = "fltp", .bits = 32, .planar = 1, .altform = AV_SAMPLE_FMT_FLT },
- [AV_SAMPLE_FMT_DBLP] = { .name = "dblp", .bits = 64, .planar = 1, .altform = AV_SAMPLE_FMT_DBL },
-};
-
-const char *av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
-{
- if (sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB)
- return NULL;
- return sample_fmt_info[sample_fmt].name;
-}
-
-enum AVSampleFormat av_get_sample_fmt(const char *name)
-{
- int i;
-
- for (i = 0; i < AV_SAMPLE_FMT_NB; i++)
- if (!strcmp(sample_fmt_info[i].name, name))
- return i;
- return AV_SAMPLE_FMT_NONE;
-}
-
-enum AVSampleFormat av_get_alt_sample_fmt(enum AVSampleFormat sample_fmt, int planar)
-{
- if (sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB)
- return AV_SAMPLE_FMT_NONE;
- if (sample_fmt_info[sample_fmt].planar == planar)
- return sample_fmt;
- return sample_fmt_info[sample_fmt].altform;
-}
-
-enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt)
-{
- if (sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB)
- return AV_SAMPLE_FMT_NONE;
- if (sample_fmt_info[sample_fmt].planar)
- return sample_fmt_info[sample_fmt].altform;
- return sample_fmt;
-}
-
-enum AVSampleFormat av_get_planar_sample_fmt(enum AVSampleFormat sample_fmt)
-{
- if (sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB)
- return AV_SAMPLE_FMT_NONE;
- if (sample_fmt_info[sample_fmt].planar)
- return sample_fmt;
- return sample_fmt_info[sample_fmt].altform;
-}
-
-char *av_get_sample_fmt_string (char *buf, int buf_size, enum AVSampleFormat sample_fmt)
-{
- /* print header */
- if (sample_fmt < 0)
- snprintf(buf, buf_size, "name " " depth");
- else if (sample_fmt < AV_SAMPLE_FMT_NB) {
- SampleFmtInfo info = sample_fmt_info[sample_fmt];
- snprintf (buf, buf_size, "%-6s" " %2d ", info.name, info.bits);
- }
-
- return buf;
-}
-
-int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
-{
- return sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB ?
- 0 : sample_fmt_info[sample_fmt].bits >> 3;
-}
-
-#if FF_API_GET_BITS_PER_SAMPLE_FMT
-int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt)
-{
- return sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB ?
- 0 : sample_fmt_info[sample_fmt].bits;
-}
-#endif
-
-int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
-{
- if (sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB)
- return 0;
- return sample_fmt_info[sample_fmt].planar;
-}
-
-int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
- enum AVSampleFormat sample_fmt, int align)
-{
- int line_size;
- int sample_size = av_get_bytes_per_sample(sample_fmt);
- int planar = av_sample_fmt_is_planar(sample_fmt);
-
- /* validate parameter ranges */
- if (!sample_size || nb_samples <= 0 || nb_channels <= 0)
- return AVERROR(EINVAL);
-
- /* auto-select alignment if not specified */
- if (!align) {
- align = 1;
- nb_samples = FFALIGN(nb_samples, 32);
- }
-
- /* check for integer overflow */
- if (nb_channels > INT_MAX / align ||
- (int64_t)nb_channels * nb_samples > (INT_MAX - (align * nb_channels)) / sample_size)
- return AVERROR(EINVAL);
-
- line_size = planar ? FFALIGN(nb_samples * sample_size, align) :
- FFALIGN(nb_samples * sample_size * nb_channels, align);
- if (linesize)
- *linesize = line_size;
-
- return planar ? line_size * nb_channels : line_size;
-}
-
-int av_samples_fill_arrays(uint8_t **audio_data, int *linesize,
- const uint8_t *buf, int nb_channels, int nb_samples,
- enum AVSampleFormat sample_fmt, int align)
-{
- int ch, planar, buf_size, line_size;
-
- planar = av_sample_fmt_is_planar(sample_fmt);
- buf_size = av_samples_get_buffer_size(&line_size, nb_channels, nb_samples,
- sample_fmt, align);
- if (buf_size < 0)
- return buf_size;
-
- audio_data[0] = (uint8_t *)buf;
- for (ch = 1; planar && ch < nb_channels; ch++)
- audio_data[ch] = audio_data[ch-1] + line_size;
-
- if (linesize)
- *linesize = line_size;
-
-#if FF_API_SAMPLES_UTILS_RETURN_ZERO
- return 0;
-#else
- return buf_size;
-#endif
-}
-
-int av_samples_alloc(uint8_t **audio_data, int *linesize, int nb_channels,
- int nb_samples, enum AVSampleFormat sample_fmt, int align)
-{
- uint8_t *buf;
- int size = av_samples_get_buffer_size(NULL, nb_channels, nb_samples,
- sample_fmt, align);
- if (size < 0)
- return size;
-
- buf = av_malloc(size);
- if (!buf)
- return AVERROR(ENOMEM);
-
- size = av_samples_fill_arrays(audio_data, linesize, buf, nb_channels,
- nb_samples, sample_fmt, align);
- if (size < 0) {
- av_free(buf);
- return size;
- }
-
- av_samples_set_silence(audio_data, 0, nb_samples, nb_channels, sample_fmt);
-
-#if FF_API_SAMPLES_UTILS_RETURN_ZERO
- return 0;
-#else
- return size;
-#endif
-}
-
-int av_samples_copy(uint8_t **dst, uint8_t * const *src, int dst_offset,
- int src_offset, int nb_samples, int nb_channels,
- enum AVSampleFormat sample_fmt)
-{
- int planar = av_sample_fmt_is_planar(sample_fmt);
- int planes = planar ? nb_channels : 1;
- int block_align = av_get_bytes_per_sample(sample_fmt) * (planar ? 1 : nb_channels);
- int data_size = nb_samples * block_align;
- int i;
-
- dst_offset *= block_align;
- src_offset *= block_align;
-
- if((dst[0] < src[0] ? src[0] - dst[0] : dst[0] - src[0]) >= data_size) {
- for (i = 0; i < planes; i++)
- memcpy(dst[i] + dst_offset, src[i] + src_offset, data_size);
- } else {
- for (i = 0; i < planes; i++)
- memmove(dst[i] + dst_offset, src[i] + src_offset, data_size);
- }
-
- return 0;
-}
-
-int av_samples_set_silence(uint8_t **audio_data, int offset, int nb_samples,
- int nb_channels, enum AVSampleFormat sample_fmt)
-{
- int planar = av_sample_fmt_is_planar(sample_fmt);
- int planes = planar ? nb_channels : 1;
- int block_align = av_get_bytes_per_sample(sample_fmt) * (planar ? 1 : nb_channels);
- int data_size = nb_samples * block_align;
- int fill_char = (sample_fmt == AV_SAMPLE_FMT_U8 ||
- sample_fmt == AV_SAMPLE_FMT_U8P) ? 0x80 : 0x00;
- int i;
-
- offset *= block_align;
-
- for (i = 0; i < planes; i++)
- memset(audio_data[i] + offset, fill_char, data_size);
-
- return 0;
-}
diff --git a/src/thirdparty/ffmpeg/libavutil/samplefmt.h b/src/thirdparty/ffmpeg/libavutil/samplefmt.h
deleted file mode 100644
index c83ab72db..000000000
--- a/src/thirdparty/ffmpeg/libavutil/samplefmt.h
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * 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 AVUTIL_SAMPLEFMT_H
-#define AVUTIL_SAMPLEFMT_H
-
-#include <stdint.h>
-
-#include "avutil.h"
-#include "attributes.h"
-
-/**
- * Audio Sample Formats
- *
- * @par
- * The data described by the sample format is always in native-endian order.
- * Sample values can be expressed by native C types, hence the lack of a signed
- * 24-bit sample format even though it is a common raw audio data format.
- *
- * @par
- * The floating-point formats are based on full volume being in the range
- * [-1.0, 1.0]. Any values outside this range are beyond full volume level.
- *
- * @par
- * The data layout as used in av_samples_fill_arrays() and elsewhere in FFmpeg
- * (such as AVFrame in libavcodec) is as follows:
- *
- * For planar sample formats, each audio channel is in a separate data plane,
- * and linesize is the buffer size, in bytes, for a single plane. All data
- * planes must be the same size. For packed sample formats, only the first data
- * plane is used, and samples for each channel are interleaved. In this case,
- * linesize is the buffer size, in bytes, for the 1 plane.
- */
-enum AVSampleFormat {
- AV_SAMPLE_FMT_NONE = -1,
- AV_SAMPLE_FMT_U8, ///< unsigned 8 bits
- AV_SAMPLE_FMT_S16, ///< signed 16 bits
- AV_SAMPLE_FMT_S32, ///< signed 32 bits
- AV_SAMPLE_FMT_FLT, ///< float
- AV_SAMPLE_FMT_DBL, ///< double
-
- AV_SAMPLE_FMT_U8P, ///< unsigned 8 bits, planar
- AV_SAMPLE_FMT_S16P, ///< signed 16 bits, planar
- AV_SAMPLE_FMT_S32P, ///< signed 32 bits, planar
- AV_SAMPLE_FMT_FLTP, ///< float, planar
- AV_SAMPLE_FMT_DBLP, ///< double, planar
-
- AV_SAMPLE_FMT_NB ///< Number of sample formats. DO NOT USE if linking dynamically
-};
-
-/**
- * Return the name of sample_fmt, or NULL if sample_fmt is not
- * recognized.
- */
-const char *av_get_sample_fmt_name(enum AVSampleFormat sample_fmt);
-
-/**
- * Return a sample format corresponding to name, or AV_SAMPLE_FMT_NONE
- * on error.
- */
-enum AVSampleFormat av_get_sample_fmt(const char *name);
-
-/**
- * Return the planar<->packed alternative form of the given sample format, or
- * AV_SAMPLE_FMT_NONE on error. If the passed sample_fmt is already in the
- * requested planar/packed format, the format returned is the same as the
- * input.
- */
-enum AVSampleFormat av_get_alt_sample_fmt(enum AVSampleFormat sample_fmt, int planar);
-
-/**
- * Get the packed alternative form of the given sample format.
- *
- * If the passed sample_fmt is already in packed format, the format returned is
- * the same as the input.
- *
- * @return the packed alternative form of the given sample format or
- AV_SAMPLE_FMT_NONE on error.
- */
-enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt);
-
-/**
- * Get the planar alternative form of the given sample format.
- *
- * If the passed sample_fmt is already in planar format, the format returned is
- * the same as the input.
- *
- * @return the planar alternative form of the given sample format or
- AV_SAMPLE_FMT_NONE on error.
- */
-enum AVSampleFormat av_get_planar_sample_fmt(enum AVSampleFormat sample_fmt);
-
-/**
- * Generate a string corresponding to the sample format with
- * sample_fmt, or a header if sample_fmt is negative.
- *
- * @param buf the buffer where to write the string
- * @param buf_size the size of buf
- * @param sample_fmt the number of the sample format to print the
- * corresponding info string, or a negative value to print the
- * corresponding header.
- * @return the pointer to the filled buffer or NULL if sample_fmt is
- * unknown or in case of other errors
- */
-char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt);
-
-#if FF_API_GET_BITS_PER_SAMPLE_FMT
-/**
- * @deprecated Use av_get_bytes_per_sample() instead.
- */
-attribute_deprecated
-int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt);
-#endif
-
-/**
- * Return number of bytes per sample.
- *
- * @param sample_fmt the sample format
- * @return number of bytes per sample or zero if unknown for the given
- * sample format
- */
-int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt);
-
-/**
- * Check if the sample format is planar.
- *
- * @param sample_fmt the sample format to inspect
- * @return 1 if the sample format is planar, 0 if it is interleaved
- */
-int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt);
-
-/**
- * Get the required buffer size for the given audio parameters.
- *
- * @param[out] linesize calculated linesize, may be NULL
- * @param nb_channels the number of channels
- * @param nb_samples the number of samples in a single channel
- * @param sample_fmt the sample format
- * @param align buffer size alignment (0 = default, 1 = no alignment)
- * @return required buffer size, or negative error code on failure
- */
-int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
- enum AVSampleFormat sample_fmt, int align);
-
-/**
- * Fill plane data pointers and linesize for samples with sample
- * format sample_fmt.
- *
- * The audio_data array is filled with the pointers to the samples data planes:
- * for planar, set the start point of each channel's data within the buffer,
- * for packed, set the start point of the entire buffer only.
- *
- * The value pointed to by linesize is set to the aligned size of each
- * channel's data buffer for planar layout, or to the aligned size of the
- * buffer for all channels for packed layout.
- *
- * The buffer in buf must be big enough to contain all the samples
- * (use av_samples_get_buffer_size() to compute its minimum size),
- * otherwise the audio_data pointers will point to invalid data.
- *
- * @see enum AVSampleFormat
- * The documentation for AVSampleFormat describes the data layout.
- *
- * @param[out] audio_data array to be filled with the pointer for each channel
- * @param[out] linesize calculated linesize, may be NULL
- * @param buf the pointer to a buffer containing the samples
- * @param nb_channels the number of channels
- * @param nb_samples the number of samples in a single channel
- * @param sample_fmt the sample format
- * @param align buffer size alignment (0 = default, 1 = no alignment)
- * @return >=0 on success or a negative error code on failure
- * @todo return minimum size in bytes required for the buffer in case
- * of success at the next bump
- */
-int av_samples_fill_arrays(uint8_t **audio_data, int *linesize,
- const uint8_t *buf,
- int nb_channels, int nb_samples,
- enum AVSampleFormat sample_fmt, int align);
-
-/**
- * Allocate a samples buffer for nb_samples samples, and fill data pointers and
- * linesize accordingly.
- * The allocated samples buffer can be freed by using av_freep(&audio_data[0])
- * Allocated data will be initialized to silence.
- *
- * @see enum AVSampleFormat
- * The documentation for AVSampleFormat describes the data layout.
- *
- * @param[out] audio_data array to be filled with the pointer for each channel
- * @param[out] linesize aligned size for audio buffer(s), may be NULL
- * @param nb_channels number of audio channels
- * @param nb_samples number of samples per channel
- * @param align buffer size alignment (0 = default, 1 = no alignment)
- * @return >=0 on success or a negative error code on failure
- * @todo return the size of the allocated buffer in case of success at the next bump
- * @see av_samples_fill_arrays()
- */
-int av_samples_alloc(uint8_t **audio_data, int *linesize, int nb_channels,
- int nb_samples, enum AVSampleFormat sample_fmt, int align);
-
-/**
- * Copy samples from src to dst.
- *
- * @param dst destination array of pointers to data planes
- * @param src source array of pointers to data planes
- * @param dst_offset offset in samples at which the data will be written to dst
- * @param src_offset offset in samples at which the data will be read from src
- * @param nb_samples number of samples to be copied
- * @param nb_channels number of audio channels
- * @param sample_fmt audio sample format
- */
-int av_samples_copy(uint8_t **dst, uint8_t * const *src, int dst_offset,
- int src_offset, int nb_samples, int nb_channels,
- enum AVSampleFormat sample_fmt);
-
-/**
- * Fill an audio buffer with silence.
- *
- * @param audio_data array of pointers to data planes
- * @param offset offset in samples at which to start filling
- * @param nb_samples number of samples to fill
- * @param nb_channels number of audio channels
- * @param sample_fmt audio sample format
- */
-int av_samples_set_silence(uint8_t **audio_data, int offset, int nb_samples,
- int nb_channels, enum AVSampleFormat sample_fmt);
-
-#endif /* AVUTIL_SAMPLEFMT_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/sha.c b/src/thirdparty/ffmpeg/libavutil/sha.c
deleted file mode 100644
index bc10df887..000000000
--- a/src/thirdparty/ffmpeg/libavutil/sha.c
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
- * Copyright (C) 2007 Michael Niedermayer <michaelni@gmx.at>
- * Copyright (C) 2009 Konstantin Shishkov
- * based on public domain SHA-1 code by Steve Reid <steve@edmweb.com>
- * and on BSD-licensed SHA-2 code by Aaron D. Gifford
- *
- * 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 <string.h>
-#include "avutil.h"
-#include "bswap.h"
-#include "sha.h"
-#include "intreadwrite.h"
-#include "mem.h"
-
-/** hash context */
-typedef struct AVSHA {
- uint8_t digest_len; ///< digest length in 32-bit words
- uint64_t count; ///< number of bytes in buffer
- uint8_t buffer[64]; ///< 512-bit buffer of input values used in hash updating
- uint32_t state[8]; ///< current hash value
- /** function used to update hash for 512-bit input block */
- void (*transform)(uint32_t *state, const uint8_t buffer[64]);
-} AVSHA;
-
-const int av_sha_size = sizeof(AVSHA);
-
-struct AVSHA *av_sha_alloc(void)
-{
- return av_mallocz(sizeof(struct AVSHA));
-}
-
-#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
-
-/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
-#define blk0(i) (block[i] = AV_RB32(buffer + 4 * (i)))
-#define blk(i) (block[i] = rol(block[i-3] ^ block[i-8] ^ block[i-14] ^ block[i-16], 1))
-
-#define R0(v,w,x,y,z,i) z += ((w&(x^y))^y) + blk0(i) + 0x5A827999 + rol(v, 5); w = rol(w, 30);
-#define R1(v,w,x,y,z,i) z += ((w&(x^y))^y) + blk (i) + 0x5A827999 + rol(v, 5); w = rol(w, 30);
-#define R2(v,w,x,y,z,i) z += ( w^x ^y) + blk (i) + 0x6ED9EBA1 + rol(v, 5); w = rol(w, 30);
-#define R3(v,w,x,y,z,i) z += (((w|x)&y)|(w&x)) + blk (i) + 0x8F1BBCDC + rol(v, 5); w = rol(w, 30);
-#define R4(v,w,x,y,z,i) z += ( w^x ^y) + blk (i) + 0xCA62C1D6 + rol(v, 5); w = rol(w, 30);
-
-/* Hash a single 512-bit block. This is the core of the algorithm. */
-
-static void sha1_transform(uint32_t state[5], const uint8_t buffer[64])
-{
- uint32_t block[80];
- unsigned int i, a, b, c, d, e;
-
- a = state[0];
- b = state[1];
- c = state[2];
- d = state[3];
- e = state[4];
-#if CONFIG_SMALL
- for (i = 0; i < 80; i++) {
- int t;
- if (i < 16)
- t = AV_RB32(buffer + 4 * i);
- else
- t = rol(block[i-3] ^ block[i-8] ^ block[i-14] ^ block[i-16], 1);
- block[i] = t;
- t += e + rol(a, 5);
- if (i < 40) {
- if (i < 20)
- t += ((b&(c^d))^d) + 0x5A827999;
- else
- t += ( b^c ^d) + 0x6ED9EBA1;
- } else {
- if (i < 60)
- t += (((b|c)&d)|(b&c)) + 0x8F1BBCDC;
- else
- t += ( b^c ^d) + 0xCA62C1D6;
- }
- e = d;
- d = c;
- c = rol(b, 30);
- b = a;
- a = t;
- }
-#else
- for (i = 0; i < 15; i += 5) {
- R0(a, b, c, d, e, 0 + i);
- R0(e, a, b, c, d, 1 + i);
- R0(d, e, a, b, c, 2 + i);
- R0(c, d, e, a, b, 3 + i);
- R0(b, c, d, e, a, 4 + i);
- }
- R0(a, b, c, d, e, 15);
- R1(e, a, b, c, d, 16);
- R1(d, e, a, b, c, 17);
- R1(c, d, e, a, b, 18);
- R1(b, c, d, e, a, 19);
- for (i = 20; i < 40; i += 5) {
- R2(a, b, c, d, e, 0 + i);
- R2(e, a, b, c, d, 1 + i);
- R2(d, e, a, b, c, 2 + i);
- R2(c, d, e, a, b, 3 + i);
- R2(b, c, d, e, a, 4 + i);
- }
- for (; i < 60; i += 5) {
- R3(a, b, c, d, e, 0 + i);
- R3(e, a, b, c, d, 1 + i);
- R3(d, e, a, b, c, 2 + i);
- R3(c, d, e, a, b, 3 + i);
- R3(b, c, d, e, a, 4 + i);
- }
- for (; i < 80; i += 5) {
- R4(a, b, c, d, e, 0 + i);
- R4(e, a, b, c, d, 1 + i);
- R4(d, e, a, b, c, 2 + i);
- R4(c, d, e, a, b, 3 + i);
- R4(b, c, d, e, a, 4 + i);
- }
-#endif
- state[0] += a;
- state[1] += b;
- state[2] += c;
- state[3] += d;
- state[4] += e;
-}
-
-static const uint32_t K256[64] = {
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
- 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
- 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
- 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
- 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
- 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
- 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
- 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
- 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
- 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
- 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
- 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
- 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
-};
-
-
-#define Ch(x,y,z) (((x) & ((y) ^ (z))) ^ (z))
-#define Maj(x,y,z) ((((x) | (y)) & (z)) | ((x) & (y)))
-
-#define Sigma0_256(x) (rol((x), 30) ^ rol((x), 19) ^ rol((x), 10))
-#define Sigma1_256(x) (rol((x), 26) ^ rol((x), 21) ^ rol((x), 7))
-#define sigma0_256(x) (rol((x), 25) ^ rol((x), 14) ^ ((x) >> 3))
-#define sigma1_256(x) (rol((x), 15) ^ rol((x), 13) ^ ((x) >> 10))
-
-#undef blk
-#define blk(i) (block[i] = block[i - 16] + sigma0_256(block[i - 15]) + \
- sigma1_256(block[i - 2]) + block[i - 7])
-
-#define ROUND256(a,b,c,d,e,f,g,h) \
- T1 += (h) + Sigma1_256(e) + Ch((e), (f), (g)) + K256[i]; \
- (d) += T1; \
- (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \
- i++
-
-#define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) \
- T1 = blk0(i); \
- ROUND256(a,b,c,d,e,f,g,h)
-
-#define ROUND256_16_TO_63(a,b,c,d,e,f,g,h) \
- T1 = blk(i); \
- ROUND256(a,b,c,d,e,f,g,h)
-
-static void sha256_transform(uint32_t *state, const uint8_t buffer[64])
-{
- unsigned int i, a, b, c, d, e, f, g, h;
- uint32_t block[64];
- uint32_t T1;
-
- a = state[0];
- b = state[1];
- c = state[2];
- d = state[3];
- e = state[4];
- f = state[5];
- g = state[6];
- h = state[7];
-#if CONFIG_SMALL
- for (i = 0; i < 64; i++) {
- uint32_t T2;
- if (i < 16)
- T1 = blk0(i);
- else
- T1 = blk(i);
- T1 += h + Sigma1_256(e) + Ch(e, f, g) + K256[i];
- T2 = Sigma0_256(a) + Maj(a, b, c);
- h = g;
- g = f;
- f = e;
- e = d + T1;
- d = c;
- c = b;
- b = a;
- a = T1 + T2;
- }
-#else
- for (i = 0; i < 16 - 7;) {
- ROUND256_0_TO_15(a, b, c, d, e, f, g, h);
- ROUND256_0_TO_15(h, a, b, c, d, e, f, g);
- ROUND256_0_TO_15(g, h, a, b, c, d, e, f);
- ROUND256_0_TO_15(f, g, h, a, b, c, d, e);
- ROUND256_0_TO_15(e, f, g, h, a, b, c, d);
- ROUND256_0_TO_15(d, e, f, g, h, a, b, c);
- ROUND256_0_TO_15(c, d, e, f, g, h, a, b);
- ROUND256_0_TO_15(b, c, d, e, f, g, h, a);
- }
-
- for (; i < 64 - 7;) {
- ROUND256_16_TO_63(a, b, c, d, e, f, g, h);
- ROUND256_16_TO_63(h, a, b, c, d, e, f, g);
- ROUND256_16_TO_63(g, h, a, b, c, d, e, f);
- ROUND256_16_TO_63(f, g, h, a, b, c, d, e);
- ROUND256_16_TO_63(e, f, g, h, a, b, c, d);
- ROUND256_16_TO_63(d, e, f, g, h, a, b, c);
- ROUND256_16_TO_63(c, d, e, f, g, h, a, b);
- ROUND256_16_TO_63(b, c, d, e, f, g, h, a);
- }
-#endif
- state[0] += a;
- state[1] += b;
- state[2] += c;
- state[3] += d;
- state[4] += e;
- state[5] += f;
- state[6] += g;
- state[7] += h;
-}
-
-
-int av_sha_init(AVSHA* ctx, int bits)
-{
- ctx->digest_len = bits >> 5;
- switch (bits) {
- case 160: // SHA-1
- ctx->state[0] = 0x67452301;
- ctx->state[1] = 0xEFCDAB89;
- ctx->state[2] = 0x98BADCFE;
- ctx->state[3] = 0x10325476;
- ctx->state[4] = 0xC3D2E1F0;
- ctx->transform = sha1_transform;
- break;
- case 224: // SHA-224
- ctx->state[0] = 0xC1059ED8;
- ctx->state[1] = 0x367CD507;
- ctx->state[2] = 0x3070DD17;
- ctx->state[3] = 0xF70E5939;
- ctx->state[4] = 0xFFC00B31;
- ctx->state[5] = 0x68581511;
- ctx->state[6] = 0x64F98FA7;
- ctx->state[7] = 0xBEFA4FA4;
- ctx->transform = sha256_transform;
- break;
- case 256: // SHA-256
- ctx->state[0] = 0x6A09E667;
- ctx->state[1] = 0xBB67AE85;
- ctx->state[2] = 0x3C6EF372;
- ctx->state[3] = 0xA54FF53A;
- ctx->state[4] = 0x510E527F;
- ctx->state[5] = 0x9B05688C;
- ctx->state[6] = 0x1F83D9AB;
- ctx->state[7] = 0x5BE0CD19;
- ctx->transform = sha256_transform;
- break;
- default:
- return -1;
- }
- ctx->count = 0;
- return 0;
-}
-
-void av_sha_update(AVSHA* ctx, const uint8_t* data, unsigned int len)
-{
- unsigned int i, j;
-
- j = ctx->count & 63;
- ctx->count += len;
-#if CONFIG_SMALL
- for (i = 0; i < len; i++) {
- ctx->buffer[j++] = data[i];
- if (64 == j) {
- ctx->transform(ctx->state, ctx->buffer);
- j = 0;
- }
- }
-#else
- if ((j + len) > 63) {
- memcpy(&ctx->buffer[j], data, (i = 64 - j));
- ctx->transform(ctx->state, ctx->buffer);
- for (; i + 63 < len; i += 64)
- ctx->transform(ctx->state, &data[i]);
- j = 0;
- } else
- i = 0;
- memcpy(&ctx->buffer[j], &data[i], len - i);
-#endif
-}
-
-void av_sha_final(AVSHA* ctx, uint8_t *digest)
-{
- int i;
- uint64_t finalcount = av_be2ne64(ctx->count << 3);
-
- av_sha_update(ctx, "\200", 1);
- while ((ctx->count & 63) != 56)
- av_sha_update(ctx, "", 1);
- av_sha_update(ctx, (uint8_t *)&finalcount, 8); /* Should cause a transform() */
- for (i = 0; i < ctx->digest_len; i++)
- AV_WB32(digest + i*4, ctx->state[i]);
-}
-
-#ifdef TEST
-#include <stdio.h>
-
-int main(void)
-{
- int i, j, k;
- AVSHA ctx;
- unsigned char digest[32];
- const int lengths[3] = { 160, 224, 256 };
-
- for (j = 0; j < 3; j++) {
- printf("Testing SHA-%d\n", lengths[j]);
- for (k = 0; k < 3; k++) {
- av_sha_init(&ctx, lengths[j]);
- if (k == 0)
- av_sha_update(&ctx, "abc", 3);
- else if (k == 1)
- av_sha_update(&ctx, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 56);
- else
- for (i = 0; i < 1000*1000; i++)
- av_sha_update(&ctx, "a", 1);
- av_sha_final(&ctx, digest);
- for (i = 0; i < lengths[j] >> 3; i++)
- printf("%02X", digest[i]);
- putchar('\n');
- }
- switch (j) {
- case 0:
- //test vectors (from FIPS PUB 180-1)
- printf("A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D\n"
- "84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1\n"
- "34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F\n");
- break;
- case 1:
- //test vectors (from FIPS PUB 180-2 Appendix A)
- printf("23097d22 3405d822 8642a477 bda255b3 2aadbce4 bda0b3f7 e36c9da7\n"
- "75388b16 512776cc 5dba5da1 fd890150 b0c6455c b4f58b19 52522525\n"
- "20794655 980c91d8 bbb4c1ea 97618a4b f03f4258 1948b2ee 4ee7ad67\n");
- break;
- case 2:
- //test vectors (from FIPS PUB 180-2)
- printf("ba7816bf 8f01cfea 414140de 5dae2223 b00361a3 96177a9c b410ff61 f20015ad\n"
- "248d6a61 d20638b8 e5c02693 0c3e6039 a33ce459 64ff2167 f6ecedd4 19db06c1\n"
- "cdc76e5c 9914fb92 81a1c7e2 84d73e67 f1809a48 a497200e 046d39cc c7112cd0\n");
- break;
- }
- }
-
- return 0;
-}
-#endif
diff --git a/src/thirdparty/ffmpeg/libavutil/sha.h b/src/thirdparty/ffmpeg/libavutil/sha.h
deleted file mode 100644
index 6caa63fc2..000000000
--- a/src/thirdparty/ffmpeg/libavutil/sha.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2007 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
- */
-
-#ifndef AVUTIL_SHA_H
-#define AVUTIL_SHA_H
-
-#include <stdint.h>
-
-#include "attributes.h"
-#include "version.h"
-
-/**
- * @defgroup lavu_sha SHA
- * @ingroup lavu_crypto
- * @{
- */
-
-extern const int av_sha_size;
-
-struct AVSHA;
-
-/**
- * Allocate an AVSHA context.
- */
-struct AVSHA *av_sha_alloc(void);
-
-/**
- * Initialize SHA-1 or SHA-2 hashing.
- *
- * @param context pointer to the function context (of size av_sha_size)
- * @param bits number of bits in digest (SHA-1 - 160 bits, SHA-2 224 or 256 bits)
- * @return zero if initialization succeeded, -1 otherwise
- */
-int av_sha_init(struct AVSHA* context, int bits);
-
-/**
- * Update hash value.
- *
- * @param context hash function context
- * @param data input data to update hash with
- * @param len input data length
- */
-void av_sha_update(struct AVSHA* context, const uint8_t* data, unsigned int len);
-
-/**
- * Finish hashing and output digest value.
- *
- * @param context hash function context
- * @param digest buffer where output digest value is stored
- */
-void av_sha_final(struct AVSHA* context, uint8_t *digest);
-
-/**
- * @}
- */
-
-#endif /* AVUTIL_SHA_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/time.c b/src/thirdparty/ffmpeg/libavutil/time.c
deleted file mode 100644
index 27feb0b75..000000000
--- a/src/thirdparty/ffmpeg/libavutil/time.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2000-2003 Fabrice Bellard
- *
- * 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 <stddef.h>
-#include <stdint.h>
-#include <time.h>
-#if HAVE_GETTIMEOFDAY
-#include <sys/time.h>
-#endif
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#if HAVE_WINDOWS_H
-#include <windows.h>
-#endif
-
-#include "libavutil/time.h"
-#include "error.h"
-
-int64_t av_gettime(void)
-{
-#if HAVE_GETTIMEOFDAY
- struct timeval tv;
- gettimeofday(&tv, NULL);
- return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
-#elif HAVE_GETSYSTEMTIMEASFILETIME
- FILETIME ft;
- int64_t t;
- GetSystemTimeAsFileTime(&ft);
- t = (int64_t)ft.dwHighDateTime << 32 | ft.dwLowDateTime;
- return t / 10 - 11644473600000000; /* Jan 1, 1601 */
-#else
- return -1;
-#endif
-}
-
-int av_usleep(unsigned usec)
-{
-#if HAVE_NANOSLEEP
- struct timespec ts = { usec / 1000000, usec % 1000000 * 1000 };
- while (nanosleep(&ts, &ts) < 0 && errno == EINTR);
- return 0;
-#elif HAVE_USLEEP
- return usleep(usec);
-#elif HAVE_SLEEP
- Sleep(usec / 1000);
- return 0;
-#else
- return AVERROR(ENOSYS);
-#endif
-}
diff --git a/src/thirdparty/ffmpeg/libavutil/time.h b/src/thirdparty/ffmpeg/libavutil/time.h
deleted file mode 100644
index 90eb43694..000000000
--- a/src/thirdparty/ffmpeg/libavutil/time.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2000-2003 Fabrice Bellard
- *
- * 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 AVUTIL_TIME_H
-#define AVUTIL_TIME_H
-
-#include <stdint.h>
-
-/**
- * Get the current time in microseconds.
- */
-int64_t av_gettime(void);
-
-/**
- * Sleep for a period of time. Although the duration is expressed in
- * microseconds, the actual delay may be rounded to the precision of the
- * system timer.
- *
- * @param usec Number of microseconds to sleep.
- * @return zero on success or (negative) error code.
- */
-int av_usleep(unsigned usec);
-
-#endif /* AVUTIL_TIME_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/timecode.c b/src/thirdparty/ffmpeg/libavutil/timecode.c
deleted file mode 100644
index 35b4d7174..000000000
--- a/src/thirdparty/ffmpeg/libavutil/timecode.c
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Copyright (c) 2006 Smartjog S.A.S, Baptiste Coudurier <baptiste.coudurier@gmail.com>
- * Copyright (c) 2011-2012 Smartjog S.A.S, Clément Bœsch <clement.boesch@smartjog.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
- * Timecode helpers
- * @see https://en.wikipedia.org/wiki/SMPTE_time_code
- * @see http://www.dropframetimecode.org
- */
-
-#include <stdio.h>
-#include "timecode.h"
-#include "log.h"
-#include "error.h"
-
-int av_timecode_adjust_ntsc_framenum2(int framenum, int fps)
-{
- /* only works for NTSC 29.97 and 59.94 */
- int drop_frames = 0;
- int d, m, frames_per_10mins;
-
- if (fps == 30) {
- drop_frames = 2;
- frames_per_10mins = 17982;
- } else if (fps == 60) {
- drop_frames = 4;
- frames_per_10mins = 35964;
- } else
- return framenum;
-
- d = framenum / frames_per_10mins;
- m = framenum % frames_per_10mins;
-
- return framenum + 9 * drop_frames * d + drop_frames * ((m - drop_frames) / (frames_per_10mins / 10));
-}
-
-uint32_t av_timecode_get_smpte_from_framenum(const AVTimecode *tc, int framenum)
-{
- unsigned fps = tc->fps;
- int drop = !!(tc->flags & AV_TIMECODE_FLAG_DROPFRAME);
- int hh, mm, ss, ff;
-
- framenum += tc->start;
- if (drop)
- framenum = av_timecode_adjust_ntsc_framenum2(framenum, tc->fps);
- ff = framenum % fps;
- ss = framenum / fps % 60;
- mm = framenum / (fps*60) % 60;
- hh = framenum / (fps*3600) % 24;
- return 0 << 31 | // color frame flag (0: unsync mode, 1: sync mode)
- drop << 30 | // drop frame flag (0: non drop, 1: drop)
- (ff / 10) << 28 | // tens of frames
- (ff % 10) << 24 | // units of frames
- 0 << 23 | // PC (NTSC) or BGF0 (PAL)
- (ss / 10) << 20 | // tens of seconds
- (ss % 10) << 16 | // units of seconds
- 0 << 15 | // BGF0 (NTSC) or BGF2 (PAL)
- (mm / 10) << 12 | // tens of minutes
- (mm % 10) << 8 | // units of minutes
- 0 << 7 | // BGF2 (NTSC) or PC (PAL)
- 0 << 6 | // BGF1
- (hh / 10) << 4 | // tens of hours
- (hh % 10); // units of hours
-}
-
-char *av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum)
-{
- int fps = tc->fps;
- int drop = tc->flags & AV_TIMECODE_FLAG_DROPFRAME;
- int hh, mm, ss, ff, neg = 0;
-
- framenum += tc->start;
- if (drop)
- framenum = av_timecode_adjust_ntsc_framenum2(framenum, fps);
- if (framenum < 0) {
- framenum = -framenum;
- neg = tc->flags & AV_TIMECODE_FLAG_ALLOWNEGATIVE;
- }
- ff = framenum % fps;
- ss = framenum / fps % 60;
- mm = framenum / (fps*60) % 60;
- hh = framenum / (fps*3600);
- if (tc->flags & AV_TIMECODE_FLAG_24HOURSMAX)
- hh = hh % 24;
- snprintf(buf, AV_TIMECODE_STR_SIZE, "%s%02d:%02d:%02d%c%02d",
- neg ? "-" : "",
- hh, mm, ss, drop ? ';' : ':', ff);
- return buf;
-}
-
-static unsigned bcd2uint(uint8_t bcd)
-{
- unsigned low = bcd & 0xf;
- unsigned high = bcd >> 4;
- if (low > 9 || high > 9)
- return 0;
- return low + 10*high;
-}
-
-char *av_timecode_make_smpte_tc_string(char *buf, uint32_t tcsmpte, int prevent_df)
-{
- unsigned hh = bcd2uint(tcsmpte & 0x3f); // 6-bit hours
- unsigned mm = bcd2uint(tcsmpte>>8 & 0x7f); // 7-bit minutes
- unsigned ss = bcd2uint(tcsmpte>>16 & 0x7f); // 7-bit seconds
- unsigned ff = bcd2uint(tcsmpte>>24 & 0x3f); // 6-bit frames
- unsigned drop = tcsmpte & 1<<30 && !prevent_df; // 1-bit drop if not arbitrary bit
- snprintf(buf, AV_TIMECODE_STR_SIZE, "%02u:%02u:%02u%c%02u",
- hh, mm, ss, drop ? ';' : ':', ff);
- return buf;
-}
-
-char *av_timecode_make_mpeg_tc_string(char *buf, uint32_t tc25bit)
-{
- snprintf(buf, AV_TIMECODE_STR_SIZE, "%02u:%02u:%02u%c%02u",
- tc25bit>>19 & 0x1f, // 5-bit hours
- tc25bit>>13 & 0x3f, // 6-bit minutes
- tc25bit>>6 & 0x3f, // 6-bit seconds
- tc25bit & 1<<24 ? ';' : ':', // 1-bit drop flag
- tc25bit & 0x3f); // 6-bit frames
- return buf;
-}
-
-static int check_fps(int fps)
-{
- int i;
- static const int supported_fps[] = {24, 25, 30, 50, 60};
-
- for (i = 0; i < FF_ARRAY_ELEMS(supported_fps); i++)
- if (fps == supported_fps[i])
- return 0;
- return -1;
-}
-
-static int check_timecode(void *log_ctx, AVTimecode *tc)
-{
- if (tc->fps <= 0) {
- av_log(log_ctx, AV_LOG_ERROR, "Timecode frame rate must be specified\n");
- return AVERROR(EINVAL);
- }
- if ((tc->flags & AV_TIMECODE_FLAG_DROPFRAME) && tc->fps != 30 && tc->fps != 60) {
- av_log(log_ctx, AV_LOG_ERROR, "Drop frame is only allowed with 30000/1001 or 60000/1001 FPS\n");
- return AVERROR(EINVAL);
- }
- if (check_fps(tc->fps) < 0) {
- av_log(log_ctx, AV_LOG_ERROR, "Timecode frame rate %d/%d not supported\n",
- tc->rate.num, tc->rate.den);
- return AVERROR_PATCHWELCOME;
- }
- return 0;
-}
-
-static int fps_from_frame_rate(AVRational rate)
-{
- if (!rate.den || !rate.num)
- return -1;
- return (rate.num + rate.den/2) / rate.den;
-}
-
-int av_timecode_check_frame_rate(AVRational rate)
-{
- return check_fps(fps_from_frame_rate(rate));
-}
-
-int av_timecode_init(AVTimecode *tc, AVRational rate, int flags, int frame_start, void *log_ctx)
-{
- memset(tc, 0, sizeof(*tc));
- tc->start = frame_start;
- tc->flags = flags;
- tc->rate = rate;
- tc->fps = fps_from_frame_rate(rate);
- return check_timecode(log_ctx, tc);
-}
-
-int av_timecode_init_from_string(AVTimecode *tc, AVRational rate, const char *str, void *log_ctx)
-{
- char c;
- int hh, mm, ss, ff, ret;
-
- if (sscanf(str, "%d:%d:%d%c%d", &hh, &mm, &ss, &c, &ff) != 5) {
- av_log(log_ctx, AV_LOG_ERROR, "Unable to parse timecode, "
- "syntax: hh:mm:ss[:;.]ff\n");
- return AVERROR_INVALIDDATA;
- }
-
- memset(tc, 0, sizeof(*tc));
- tc->flags = c != ':' ? AV_TIMECODE_FLAG_DROPFRAME : 0; // drop if ';', '.', ...
- tc->rate = rate;
- tc->fps = fps_from_frame_rate(rate);
-
- ret = check_timecode(log_ctx, tc);
- if (ret < 0)
- return ret;
-
- tc->start = (hh*3600 + mm*60 + ss) * tc->fps + ff;
- if (tc->flags & AV_TIMECODE_FLAG_DROPFRAME) { /* adjust frame number */
- int tmins = 60*hh + mm;
- tc->start -= 2 * (tmins - tmins/10);
- }
- return 0;
-}
diff --git a/src/thirdparty/ffmpeg/libavutil/timecode.h b/src/thirdparty/ffmpeg/libavutil/timecode.h
deleted file mode 100644
index 4afb75dd0..000000000
--- a/src/thirdparty/ffmpeg/libavutil/timecode.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (c) 2006 Smartjog S.A.S, Baptiste Coudurier <baptiste.coudurier@gmail.com>
- * Copyright (c) 2011-2012 Smartjog S.A.S, Clément Bœsch <clement.boesch@smartjog.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
- * Timecode helpers header
- */
-
-#ifndef AVUTIL_TIMECODE_H
-#define AVUTIL_TIMECODE_H
-
-#include <stdint.h>
-#include "rational.h"
-
-#define AV_TIMECODE_STR_SIZE 16
-
-enum AVTimecodeFlag {
- AV_TIMECODE_FLAG_DROPFRAME = 1<<0, ///< timecode is drop frame
- AV_TIMECODE_FLAG_24HOURSMAX = 1<<1, ///< timecode wraps after 24 hours
- AV_TIMECODE_FLAG_ALLOWNEGATIVE = 1<<2, ///< negative time values are allowed
-};
-
-typedef struct {
- int start; ///< timecode frame start (first base frame number)
- uint32_t flags; ///< flags such as drop frame, +24 hours support, ...
- AVRational rate; ///< frame rate in rational form
- unsigned fps; ///< frame per second; must be consistent with the rate field
-} AVTimecode;
-
-/**
- * Adjust frame number for NTSC drop frame time code.
- *
- * @param framenum frame number to adjust
- * @param fps frame per second, 30 or 60
- * @return adjusted frame number
- * @warning adjustment is only valid in NTSC 29.97 and 59.94
- */
-int av_timecode_adjust_ntsc_framenum2(int framenum, int fps);
-
-/**
- * Convert frame number to SMPTE 12M binary representation.
- *
- * @param tc timecode data correctly initialized
- * @param framenum frame number
- * @return the SMPTE binary representation
- *
- * @note Frame number adjustment is automatically done in case of drop timecode,
- * you do NOT have to call av_timecode_adjust_ntsc_framenum2().
- * @note The frame number is relative to tc->start.
- * @note Color frame (CF), binary group flags (BGF) and biphase mark polarity
- * correction (PC) bits are set to zero.
- */
-uint32_t av_timecode_get_smpte_from_framenum(const AVTimecode *tc, int framenum);
-
-/**
- * Load timecode string in buf.
- *
- * @param buf destination buffer, must be at least AV_TIMECODE_STR_SIZE long
- * @param tc timecode data correctly initialized
- * @param framenum frame number
- * @return the buf parameter
- *
- * @note Timecode representation can be a negative timecode and have more than
- * 24 hours, but will only be honored if the flags are correctly set.
- * @note The frame number is relative to tc->start.
- */
-char *av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum);
-
-/**
- * Get the timecode string from the SMPTE timecode format.
- *
- * @param buf destination buffer, must be at least AV_TIMECODE_STR_SIZE long
- * @param tcsmpte the 32-bit SMPTE timecode
- * @param prevent_df prevent the use of a drop flag when it is known the DF bit
- * is arbitrary
- * @return the buf parameter
- */
-char *av_timecode_make_smpte_tc_string(char *buf, uint32_t tcsmpte, int prevent_df);
-
-/**
- * Get the timecode string from the 25-bit timecode format (MPEG GOP format).
- *
- * @param buf destination buffer, must be at least AV_TIMECODE_STR_SIZE long
- * @param tc25bit the 25-bits timecode
- * @return the buf parameter
- */
-char *av_timecode_make_mpeg_tc_string(char *buf, uint32_t tc25bit);
-
-/**
- * Init a timecode struct with the passed parameters.
- *
- * @param log_ctx a pointer to an arbitrary struct of which the first field
- * is a pointer to an AVClass struct (used for av_log)
- * @param tc pointer to an allocated AVTimecode
- * @param rate frame rate in rational form
- * @param flags miscellaneous flags such as drop frame, +24 hours, ...
- * (see AVTimecodeFlag)
- * @param frame_start the first frame number
- * @return 0 on success, AVERROR otherwise
- */
-int av_timecode_init(AVTimecode *tc, AVRational rate, int flags, int frame_start, void *log_ctx);
-
-/**
- * Parse timecode representation (hh:mm:ss[:;.]ff).
- *
- * @param log_ctx a pointer to an arbitrary struct of which the first field is a
- * pointer to an AVClass struct (used for av_log).
- * @param tc pointer to an allocated AVTimecode
- * @param rate frame rate in rational form
- * @param str timecode string which will determine the frame start
- * @return 0 on success, AVERROR otherwise
- */
-int av_timecode_init_from_string(AVTimecode *tc, AVRational rate, const char *str, void *log_ctx);
-
-/**
- * Check if the timecode feature is available for the given frame rate
- *
- * @return 0 if supported, <0 otherwise
- */
-int av_timecode_check_frame_rate(AVRational rate);
-
-#endif /* AVUTIL_TIMECODE_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/timer.h b/src/thirdparty/ffmpeg/libavutil/timer.h
deleted file mode 100644
index 9ad8b1eba..000000000
--- a/src/thirdparty/ffmpeg/libavutil/timer.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * copyright (c) 2006 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
- * high precision timer, useful to profile code
- */
-
-#ifndef AVUTIL_TIMER_H
-#define AVUTIL_TIMER_H
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <inttypes.h>
-
-#include "config.h"
-
-#if ARCH_ARM
-# include "arm/timer.h"
-#elif ARCH_BFIN
-# include "bfin/timer.h"
-#elif ARCH_PPC
-# include "ppc/timer.h"
-#elif ARCH_X86
-# include "x86/timer.h"
-#endif
-
-#if !defined(AV_READ_TIME) && HAVE_GETHRTIME
-# define AV_READ_TIME gethrtime
-#endif
-
-#ifdef AV_READ_TIME
-#define START_TIMER \
- uint64_t tend; \
- uint64_t tstart = AV_READ_TIME(); \
-
-#define STOP_TIMER(id) \
- tend = AV_READ_TIME(); \
- { \
- static uint64_t tsum = 0; \
- static int tcount = 0; \
- static int tskip_count = 0; \
- if (tcount < 2 || \
- tend - tstart < 8 * tsum / tcount || \
- tend - tstart < 2000) { \
- tsum+= tend - tstart; \
- tcount++; \
- } else \
- tskip_count++; \
- if (((tcount + tskip_count) & (tcount + tskip_count - 1)) == 0) { \
- av_log(NULL, AV_LOG_ERROR, \
- "%"PRIu64" decicycles in %s, %d runs, %d skips\n", \
- tsum * 10 / tcount, id, tcount, tskip_count); \
- } \
- }
-#else
-#define START_TIMER
-#define STOP_TIMER(id) { }
-#endif
-
-#endif /* AVUTIL_TIMER_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/utils.c b/src/thirdparty/ffmpeg/libavutil/utils.c
deleted file mode 100644
index 4485b2b74..000000000
--- a/src/thirdparty/ffmpeg/libavutil/utils.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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 "avutil.h"
-#include "avassert.h"
-#include "samplefmt.h"
-
-/**
- * @file
- * various utility functions
- */
-
-unsigned avutil_version(void)
-{
- av_assert0(AV_PIX_FMT_VDA_VLD == 81); //check if the pix fmt enum has not had anything inserted or removed by mistake
- av_assert0(AV_SAMPLE_FMT_DBLP == 9);
- av_assert0(AVMEDIA_TYPE_ATTACHMENT == 4);
- av_assert0(AV_PICTURE_TYPE_BI == 7);
- av_assert0(LIBAVUTIL_VERSION_MICRO >= 100);
- av_assert0(HAVE_MMX2 == HAVE_MMXEXT);
-
- if (av_sat_dadd32(1, 2) != 5) {
- av_log(NULL, AV_LOG_FATAL, "Libavutil has been build with a broken binutils, please upgrade binutils and rebuild\n");
- abort();
- }
-
- return LIBAVUTIL_VERSION_INT;
-}
-
-const char *avutil_configuration(void)
-{
- return FFMPEG_CONFIGURATION;
-}
-
-const char *avutil_license(void)
-{
-#define LICENSE_PREFIX "libavutil license: "
- return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1;
-}
-
-const char *av_get_media_type_string(enum AVMediaType media_type)
-{
- switch (media_type) {
- case AVMEDIA_TYPE_VIDEO: return "video";
- case AVMEDIA_TYPE_AUDIO: return "audio";
- case AVMEDIA_TYPE_DATA: return "data";
- case AVMEDIA_TYPE_SUBTITLE: return "subtitle";
- case AVMEDIA_TYPE_ATTACHMENT: return "attachment";
- default: return NULL;
- }
-}
-
-char av_get_picture_type_char(enum AVPictureType pict_type)
-{
- switch (pict_type) {
- case AV_PICTURE_TYPE_I: return 'I';
- case AV_PICTURE_TYPE_P: return 'P';
- case AV_PICTURE_TYPE_B: return 'B';
- case AV_PICTURE_TYPE_S: return 'S';
- case AV_PICTURE_TYPE_SI: return 'i';
- case AV_PICTURE_TYPE_SP: return 'p';
- case AV_PICTURE_TYPE_BI: return 'b';
- default: return '?';
- }
-}
diff --git a/src/thirdparty/ffmpeg/libavutil/version.h b/src/thirdparty/ffmpeg/libavutil/version.h
deleted file mode 100644
index 9e76395f9..000000000
--- a/src/thirdparty/ffmpeg/libavutil/version.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * copyright (c) 2003 Fabrice Bellard
- *
- * 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 AVUTIL_VERSION_H
-#define AVUTIL_VERSION_H
-
-/**
- * @defgroup preproc_misc Preprocessor String Macros
- *
- * String manipulation macros
- *
- * @{
- */
-
-#define AV_STRINGIFY(s) AV_TOSTRING(s)
-#define AV_TOSTRING(s) #s
-
-#define AV_GLUE(a, b) a ## b
-#define AV_JOIN(a, b) AV_GLUE(a, b)
-
-#define AV_PRAGMA(s) _Pragma(#s)
-
-/**
- * @}
- */
-
-/**
- * @defgroup version_utils Library Version Macros
- *
- * Useful to check and match library version in order to maintain
- * backward compatibility.
- *
- * @{
- */
-
-#define AV_VERSION_INT(a, b, c) (a<<16 | b<<8 | c)
-#define AV_VERSION_DOT(a, b, c) a ##.## b ##.## c
-#define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
-
-/**
- * @}
- */
-
-
-/**
- * @file
- * @ingroup lavu
- * Libavutil version macros
- */
-
-/**
- * @defgroup lavu_ver Version and Build diagnostics
- *
- * Macros and function useful to check at compiletime and at runtime
- * which version of libavutil is in use.
- *
- * @{
- */
-
-#define LIBAVUTIL_VERSION_MAJOR 52
-#define LIBAVUTIL_VERSION_MINOR 17
-#define LIBAVUTIL_VERSION_MICRO 101
-
-#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
- LIBAVUTIL_VERSION_MINOR, \
- LIBAVUTIL_VERSION_MICRO)
-#define LIBAVUTIL_VERSION AV_VERSION(LIBAVUTIL_VERSION_MAJOR, \
- LIBAVUTIL_VERSION_MINOR, \
- LIBAVUTIL_VERSION_MICRO)
-#define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT
-
-#define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION)
-
-/**
- * @}
- *
- * @defgroup depr_guards Deprecation guards
- * FF_API_* defines may be placed below to indicate public API that will be
- * dropped at a future version bump. The defines themselves are not part of
- * the public API and may change, break or disappear at any time.
- *
- * @{
- */
-
-#ifndef FF_API_GET_BITS_PER_SAMPLE_FMT
-#define FF_API_GET_BITS_PER_SAMPLE_FMT (LIBAVUTIL_VERSION_MAJOR < 53)
-#endif
-#ifndef FF_API_FIND_OPT
-#define FF_API_FIND_OPT (LIBAVUTIL_VERSION_MAJOR < 53)
-#endif
-#ifndef FF_API_OLD_AVOPTIONS
-#define FF_API_OLD_AVOPTIONS (LIBAVUTIL_VERSION_MAJOR < 53)
-#endif
-#ifndef FF_API_PIX_FMT
-#define FF_API_PIX_FMT (LIBAVUTIL_VERSION_MAJOR < 53)
-#endif
-#ifndef FF_API_CONTEXT_SIZE
-#define FF_API_CONTEXT_SIZE (LIBAVUTIL_VERSION_MAJOR < 53)
-#endif
-#ifndef FF_API_PIX_FMT_DESC
-#define FF_API_PIX_FMT_DESC (LIBAVUTIL_VERSION_MAJOR < 53)
-#endif
-#ifndef FF_API_AV_REVERSE
-#define FF_API_AV_REVERSE (LIBAVUTIL_VERSION_MAJOR < 53)
-#endif
-#ifndef FF_API_AUDIOCONVERT
-#define FF_API_AUDIOCONVERT (LIBAVUTIL_VERSION_MAJOR < 53)
-#endif
-#ifndef FF_API_CPU_FLAG_MMX2
-#define FF_API_CPU_FLAG_MMX2 (LIBAVUTIL_VERSION_MAJOR < 53)
-#endif
-#ifndef FF_API_SAMPLES_UTILS_RETURN_ZERO
-#define FF_API_SAMPLES_UTILS_RETURN_ZERO (LIBAVUTIL_VERSION_MAJOR < 53)
-#endif
-
-/**
- * @}
- */
-
-#endif /* AVUTIL_VERSION_H */
-
diff --git a/src/thirdparty/ffmpeg/libavutil/x86/asm.h b/src/thirdparty/ffmpeg/libavutil/x86/asm.h
deleted file mode 100644
index d2e76db6f..000000000
--- a/src/thirdparty/ffmpeg/libavutil/x86/asm.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * copyright (c) 2006 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
- */
-
-#ifndef AVUTIL_X86_ASM_H
-#define AVUTIL_X86_ASM_H
-
-#include <stdint.h>
-#include "config.h"
-
-#if ARCH_X86_64
-# define OPSIZE "q"
-# define REG_a "rax"
-# define REG_b "rbx"
-# define REG_c "rcx"
-# define REG_d "rdx"
-# define REG_D "rdi"
-# define REG_S "rsi"
-# define PTR_SIZE "8"
-typedef int64_t x86_reg;
-
-# define REG_SP "rsp"
-# define REG_BP "rbp"
-# define REGBP rbp
-# define REGa rax
-# define REGb rbx
-# define REGc rcx
-# define REGd rdx
-# define REGSP rsp
-
-#elif ARCH_X86_32
-
-# define OPSIZE "l"
-# define REG_a "eax"
-# define REG_b "ebx"
-# define REG_c "ecx"
-# define REG_d "edx"
-# define REG_D "edi"
-# define REG_S "esi"
-# define PTR_SIZE "4"
-typedef int32_t x86_reg;
-
-# define REG_SP "esp"
-# define REG_BP "ebp"
-# define REGBP ebp
-# define REGa eax
-# define REGb ebx
-# define REGc ecx
-# define REGd edx
-# define REGSP esp
-#else
-typedef int x86_reg;
-#endif
-
-#define HAVE_7REGS (ARCH_X86_64 || (HAVE_EBX_AVAILABLE && HAVE_EBP_AVAILABLE))
-#define HAVE_6REGS (ARCH_X86_64 || (HAVE_EBX_AVAILABLE || HAVE_EBP_AVAILABLE))
-
-#if ARCH_X86_64 && defined(PIC)
-# define BROKEN_RELOCATIONS 1
-#endif
-
-/*
- * If gcc is not set to support sse (-msse) it will not accept xmm registers
- * in the clobber list for inline asm. XMM_CLOBBERS takes a list of xmm
- * registers to be marked as clobbered and evaluates to nothing if they are
- * not supported, or to the list itself if they are supported. Since a clobber
- * list may not be empty, XMM_CLOBBERS_ONLY should be used if the xmm
- * registers are the only in the clobber list.
- * For example a list with "eax" and "xmm0" as clobbers should become:
- * : XMM_CLOBBERS("xmm0",) "eax"
- * and a list with only "xmm0" should become:
- * XMM_CLOBBERS_ONLY("xmm0")
- */
-#if HAVE_XMM_CLOBBERS
-# define XMM_CLOBBERS(...) __VA_ARGS__
-# define XMM_CLOBBERS_ONLY(...) : __VA_ARGS__
-#else
-# define XMM_CLOBBERS(...)
-# define XMM_CLOBBERS_ONLY(...)
-#endif
-
-/* Use to export labels from asm. */
-#define LABEL_MANGLE(a) EXTERN_PREFIX #a
-
-// Use rip-relative addressing if compiling PIC code on x86-64.
-#if ARCH_X86_64 && defined(PIC)
-# define LOCAL_MANGLE(a) #a "(%%rip)"
-#else
-# define LOCAL_MANGLE(a) #a
-#endif
-
-#define MANGLE(a) EXTERN_PREFIX LOCAL_MANGLE(a)
-
-#endif /* AVUTIL_X86_ASM_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/x86/bswap.h b/src/thirdparty/ffmpeg/libavutil/x86/bswap.h
deleted file mode 100644
index b10809603..000000000
--- a/src/thirdparty/ffmpeg/libavutil/x86/bswap.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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
- * byte swapping routines
- */
-
-#ifndef AVUTIL_X86_BSWAP_H
-#define AVUTIL_X86_BSWAP_H
-
-#include <stdint.h>
-#include "config.h"
-#include "libavutil/attributes.h"
-
-#if HAVE_INLINE_ASM
-
-#if !AV_GCC_VERSION_AT_LEAST(4,1)
-#define av_bswap16 av_bswap16
-static av_always_inline av_const unsigned av_bswap16(unsigned x)
-{
- __asm__("rorw $8, %w0" : "+r"(x));
- return x;
-}
-#endif /* !AV_GCC_VERSION_AT_LEAST(4,1) */
-
-#if !AV_GCC_VERSION_AT_LEAST(4,5)
-#define av_bswap32 av_bswap32
-static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
-{
- __asm__("bswap %0" : "+r" (x));
- return x;
-}
-
-#if ARCH_X86_64
-#define av_bswap64 av_bswap64
-static inline uint64_t av_const av_bswap64(uint64_t x)
-{
- __asm__("bswap %0": "=r" (x) : "0" (x));
- return x;
-}
-#endif
-#endif /* !AV_GCC_VERSION_AT_LEAST(4,5) */
-
-#endif /* HAVE_INLINE_ASM */
-#endif /* AVUTIL_X86_BSWAP_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/x86/cpu.c b/src/thirdparty/ffmpeg/libavutil/x86/cpu.c
deleted file mode 100644
index ab40a16d5..000000000
--- a/src/thirdparty/ffmpeg/libavutil/x86/cpu.c
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * CPU detection code, extracted from mmx.h
- * (c)1997-99 by H. Dietz and R. Fisher
- * Converted to C and improved by Fabrice Bellard.
- *
- * 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 <stdlib.h>
-#include <string.h>
-
-#include "libavutil/x86/asm.h"
-#include "libavutil/x86/cpu.h"
-#include "libavutil/cpu.h"
-
-#if HAVE_YASM
-
-#define cpuid(index, eax, ebx, ecx, edx) \
- ff_cpu_cpuid(index, &eax, &ebx, &ecx, &edx)
-
-#define xgetbv(index, eax, edx) \
- ff_cpu_xgetbv(index, &eax, &edx)
-
-#elif HAVE_INLINE_ASM
-
-/* ebx saving is necessary for PIC. gcc seems unable to see it alone */
-#define cpuid(index, eax, ebx, ecx, edx) \
- __asm__ volatile ( \
- "mov %%"REG_b", %%"REG_S" \n\t" \
- "cpuid \n\t" \
- "xchg %%"REG_b", %%"REG_S \
- : "=a" (eax), "=S" (ebx), "=c" (ecx), "=d" (edx) \
- : "0" (index))
-
-#define xgetbv(index, eax, edx) \
- __asm__ (".byte 0x0f, 0x01, 0xd0" : "=a"(eax), "=d"(edx) : "c" (index))
-
-#define get_eflags(x) \
- __asm__ volatile ("pushfl \n" \
- "pop %0 \n" \
- : "=r"(x))
-
-#define set_eflags(x) \
- __asm__ volatile ("push %0 \n" \
- "popfl \n" \
- :: "r"(x))
-
-#endif /* HAVE_INLINE_ASM */
-
-#if ARCH_X86_64
-
-#define cpuid_test() 1
-
-#elif HAVE_YASM
-
-#define cpuid_test ff_cpu_cpuid_test
-
-#elif HAVE_INLINE_ASM
-
-static int cpuid_test(void)
-{
- x86_reg a, c;
-
- /* Check if CPUID is supported by attempting to toggle the ID bit in
- * the EFLAGS register. */
- get_eflags(a);
- set_eflags(a ^ 0x200000);
- get_eflags(c);
-
- return a != c;
-}
-#endif
-
-/* Function to test if multimedia instructions are supported... */
-int ff_get_cpu_flags_x86(void)
-{
- int rval = 0;
-
-#ifdef cpuid
-
- int eax, ebx, ecx, edx;
- int max_std_level, max_ext_level, std_caps = 0, ext_caps = 0;
- int family = 0, model = 0;
- union { int i[3]; char c[12]; } vendor;
-
- if (!cpuid_test())
- return 0; /* CPUID not supported */
-
- cpuid(0, max_std_level, vendor.i[0], vendor.i[2], vendor.i[1]);
-
- if (max_std_level >= 1) {
- cpuid(1, eax, ebx, ecx, std_caps);
- family = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);
- model = ((eax >> 4) & 0xf) + ((eax >> 12) & 0xf0);
- if (std_caps & (1 << 15))
- rval |= AV_CPU_FLAG_CMOV;
- if (std_caps & (1 << 23))
- rval |= AV_CPU_FLAG_MMX;
- if (std_caps & (1 << 25))
- rval |= AV_CPU_FLAG_MMXEXT;
-#if HAVE_SSE
- if (std_caps & (1 << 25))
- rval |= AV_CPU_FLAG_SSE;
- if (std_caps & (1 << 26))
- rval |= AV_CPU_FLAG_SSE2;
- if (ecx & 1)
- rval |= AV_CPU_FLAG_SSE3;
- if (ecx & 0x00000200 )
- rval |= AV_CPU_FLAG_SSSE3;
- if (ecx & 0x00080000 )
- rval |= AV_CPU_FLAG_SSE4;
- if (ecx & 0x00100000 )
- rval |= AV_CPU_FLAG_SSE42;
-#if HAVE_AVX
- /* Check OXSAVE and AVX bits */
- if ((ecx & 0x18000000) == 0x18000000) {
- /* Check for OS support */
- xgetbv(0, eax, edx);
- if ((eax & 0x6) == 0x6)
- rval |= AV_CPU_FLAG_AVX;
- }
-#endif /* HAVE_AVX */
-#endif /* HAVE_SSE */
- }
-
- cpuid(0x80000000, max_ext_level, ebx, ecx, edx);
-
- if (max_ext_level >= 0x80000001) {
- cpuid(0x80000001, eax, ebx, ecx, ext_caps);
- if (ext_caps & (1U << 31))
- rval |= AV_CPU_FLAG_3DNOW;
- if (ext_caps & (1 << 30))
- rval |= AV_CPU_FLAG_3DNOWEXT;
- if (ext_caps & (1 << 23))
- rval |= AV_CPU_FLAG_MMX;
- if (ext_caps & (1 << 22))
- rval |= AV_CPU_FLAG_MMXEXT;
-
- /* Allow for selectively disabling SSE2 functions on AMD processors
- with SSE2 support but not SSE4a. This includes Athlon64, some
- Opteron, and some Sempron processors. MMX, SSE, or 3DNow! are faster
- than SSE2 often enough to utilize this special-case flag.
- AV_CPU_FLAG_SSE2 and AV_CPU_FLAG_SSE2SLOW are both set in this case
- so that SSE2 is used unless explicitly disabled by checking
- AV_CPU_FLAG_SSE2SLOW. */
- if (!strncmp(vendor.c, "AuthenticAMD", 12) &&
- rval & AV_CPU_FLAG_SSE2 && !(ecx & 0x00000040)) {
- rval |= AV_CPU_FLAG_SSE2SLOW;
- }
-
- /* XOP and FMA4 use the AVX instruction coding scheme, so they can't be
- * used unless the OS has AVX support. */
- if (rval & AV_CPU_FLAG_AVX) {
- if (ecx & 0x00000800)
- rval |= AV_CPU_FLAG_XOP;
- if (ecx & 0x00010000)
- rval |= AV_CPU_FLAG_FMA4;
- }
- }
-
- if (!strncmp(vendor.c, "GenuineIntel", 12)) {
- if (family == 6 && (model == 9 || model == 13 || model == 14)) {
- /* 6/9 (pentium-m "banias"), 6/13 (pentium-m "dothan"), and
- * 6/14 (core1 "yonah") theoretically support sse2, but it's
- * usually slower than mmx, so let's just pretend they don't.
- * AV_CPU_FLAG_SSE2 is disabled and AV_CPU_FLAG_SSE2SLOW is
- * enabled so that SSE2 is not used unless explicitly enabled
- * by checking AV_CPU_FLAG_SSE2SLOW. The same situation
- * applies for AV_CPU_FLAG_SSE3 and AV_CPU_FLAG_SSE3SLOW. */
- if (rval & AV_CPU_FLAG_SSE2)
- rval ^= AV_CPU_FLAG_SSE2SLOW | AV_CPU_FLAG_SSE2;
- if (rval & AV_CPU_FLAG_SSE3)
- rval ^= AV_CPU_FLAG_SSE3SLOW | AV_CPU_FLAG_SSE3;
- }
- /* The Atom processor has SSSE3 support, which is useful in many cases,
- * but sometimes the SSSE3 version is slower than the SSE2 equivalent
- * on the Atom, but is generally faster on other processors supporting
- * SSSE3. This flag allows for selectively disabling certain SSSE3
- * functions on the Atom. */
- if (family == 6 && model == 28)
- rval |= AV_CPU_FLAG_ATOM;
- }
-
-#endif /* cpuid */
-
- return rval;
-}
diff --git a/src/thirdparty/ffmpeg/libavutil/x86/cpu.h b/src/thirdparty/ffmpeg/libavutil/x86/cpu.h
deleted file mode 100644
index 601476ee1..000000000
--- a/src/thirdparty/ffmpeg/libavutil/x86/cpu.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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 AVUTIL_X86_CPU_H
-#define AVUTIL_X86_CPU_H
-
-#include "config.h"
-#include "libavutil/cpu.h"
-
-#define CPUEXT(flags, suffix, cpuext) \
- (HAVE_ ## cpuext ## suffix && ((flags) & AV_CPU_FLAG_ ## cpuext))
-
-#define AV_CPU_FLAG_AMD3DNOW AV_CPU_FLAG_3DNOW
-#define AV_CPU_FLAG_AMD3DNOWEXT AV_CPU_FLAG_3DNOWEXT
-
-#define EXTERNAL_AMD3DNOW(flags) CPUEXT(flags, _EXTERNAL, AMD3DNOW)
-#define EXTERNAL_AMD3DNOWEXT(flags) CPUEXT(flags, _EXTERNAL, AMD3DNOWEXT)
-#define EXTERNAL_MMX(flags) CPUEXT(flags, _EXTERNAL, MMX)
-#define EXTERNAL_MMXEXT(flags) CPUEXT(flags, _EXTERNAL, MMXEXT)
-#define EXTERNAL_SSE(flags) CPUEXT(flags, _EXTERNAL, SSE)
-#define EXTERNAL_SSE2(flags) CPUEXT(flags, _EXTERNAL, SSE2)
-#define EXTERNAL_SSE3(flags) CPUEXT(flags, _EXTERNAL, SSE3)
-#define EXTERNAL_SSSE3(flags) CPUEXT(flags, _EXTERNAL, SSSE3)
-#define EXTERNAL_SSE4(flags) CPUEXT(flags, _EXTERNAL, SSE4)
-#define EXTERNAL_SSE42(flags) CPUEXT(flags, _EXTERNAL, SSE42)
-#define EXTERNAL_AVX(flags) CPUEXT(flags, _EXTERNAL, AVX)
-#define EXTERNAL_FMA4(flags) CPUEXT(flags, _EXTERNAL, FMA4)
-
-#define INLINE_AMD3DNOW(flags) CPUEXT(flags, _INLINE, AMD3DNOW)
-#define INLINE_AMD3DNOWEXT(flags) CPUEXT(flags, _INLINE, AMD3DNOWEXT)
-#define INLINE_MMX(flags) CPUEXT(flags, _INLINE, MMX)
-#define INLINE_MMXEXT(flags) CPUEXT(flags, _INLINE, MMXEXT)
-#define INLINE_SSE(flags) CPUEXT(flags, _INLINE, SSE)
-#define INLINE_SSE2(flags) CPUEXT(flags, _INLINE, SSE2)
-#define INLINE_SSE3(flags) CPUEXT(flags, _INLINE, SSE3)
-#define INLINE_SSSE3(flags) CPUEXT(flags, _INLINE, SSSE3)
-#define INLINE_SSE4(flags) CPUEXT(flags, _INLINE, SSE4)
-#define INLINE_SSE42(flags) CPUEXT(flags, _INLINE, SSE42)
-#define INLINE_AVX(flags) CPUEXT(flags, _INLINE, AVX)
-#define INLINE_FMA4(flags) CPUEXT(flags, _INLINE, FMA4)
-
-void ff_cpu_cpuid(int index, int *eax, int *ebx, int *ecx, int *edx);
-void ff_cpu_xgetbv(int op, int *eax, int *edx);
-int ff_cpu_cpuid_test(void);
-
-#endif /* AVUTIL_X86_CPU_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/x86/cpuid.asm b/src/thirdparty/ffmpeg/libavutil/x86/cpuid.asm
deleted file mode 100644
index 56876a870..000000000
--- a/src/thirdparty/ffmpeg/libavutil/x86/cpuid.asm
+++ /dev/null
@@ -1,91 +0,0 @@
-;*****************************************************************************
-;* Copyright (C) 2005-2010 x264 project
-;*
-;* Authors: Loren Merritt <lorenm@u.washington.edu>
-;* Jason Garrett-Glaser <darkshikari@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 "x86util.asm"
-
-SECTION .text
-
-;-----------------------------------------------------------------------------
-; void ff_cpu_cpuid(int index, int *eax, int *ebx, int *ecx, int *edx)
-;-----------------------------------------------------------------------------
-cglobal cpu_cpuid, 5,7
- push rbx
- push r4
- push r3
- push r2
- push r1
- mov eax, r0d
- xor ecx, ecx
- cpuid
- pop r4
- mov [r4], eax
- pop r4
- mov [r4], ebx
- pop r4
- mov [r4], ecx
- pop r4
- mov [r4], edx
- pop rbx
- RET
-
-;-----------------------------------------------------------------------------
-; void ff_cpu_xgetbv(int op, int *eax, int *edx)
-;-----------------------------------------------------------------------------
-cglobal cpu_xgetbv, 3,7
- push r2
- push r1
- mov ecx, r0d
- xgetbv
- pop r4
- mov [r4], eax
- pop r4
- mov [r4], edx
- RET
-
-%if ARCH_X86_64 == 0
-;-----------------------------------------------------------------------------
-; int ff_cpu_cpuid_test(void)
-; return 0 if unsupported
-;-----------------------------------------------------------------------------
-cglobal cpu_cpuid_test
- pushfd
- push ebx
- push ebp
- push esi
- push edi
- pushfd
- pop eax
- mov ebx, eax
- xor eax, 0x200000
- push eax
- popfd
- pushfd
- pop eax
- xor eax, ebx
- pop edi
- pop esi
- pop ebp
- pop ebx
- popfd
- ret
-%endif
diff --git a/src/thirdparty/ffmpeg/libavutil/x86/emms.asm b/src/thirdparty/ffmpeg/libavutil/x86/emms.asm
deleted file mode 100644
index 0aad34af3..000000000
--- a/src/thirdparty/ffmpeg/libavutil/x86/emms.asm
+++ /dev/null
@@ -1,30 +0,0 @@
-;*****************************************************************************
-;* 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 "x86util.asm"
-
-SECTION .text
-
-;-----------------------------------------------------------------------------
-; void avpriv_emms_yasm(void)
-;-----------------------------------------------------------------------------
-cvisible emms_yasm, 0, 0
- emms
- RET
diff --git a/src/thirdparty/ffmpeg/libavutil/x86/emms.h b/src/thirdparty/ffmpeg/libavutil/x86/emms.h
deleted file mode 100644
index 809a23b05..000000000
--- a/src/thirdparty/ffmpeg/libavutil/x86/emms.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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 AVUTIL_X86_EMMS_H
-#define AVUTIL_X86_EMMS_H
-
-#include "config.h"
-#include "libavutil/attributes.h"
-
-void avpriv_emms_yasm(void);
-
-#if HAVE_MMX_INLINE
-# define emms_c emms_c
-/**
- * Empty mmx state.
- * this must be called between any dsp function and float/double code.
- * for example sin(); dsp->idct_put(); emms_c(); cos()
- */
-static av_always_inline void emms_c(void)
-{
- if(av_get_cpu_flags() & AV_CPU_FLAG_MMX)
- __asm__ volatile ("emms" ::: "memory");
-}
-#elif HAVE_MMX && HAVE_MM_EMPTY
-# include <mmintrin.h>
-# define emms_c _mm_empty
-#elif HAVE_MMX_EXTERNAL
-# define emms_c avpriv_emms_yasm
-#endif /* HAVE_MMX_INLINE */
-
-#endif /* AVUTIL_X86_EMMS_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/x86/float_dsp.asm b/src/thirdparty/ffmpeg/libavutil/x86/float_dsp.asm
deleted file mode 100644
index 28ea49d6d..000000000
--- a/src/thirdparty/ffmpeg/libavutil/x86/float_dsp.asm
+++ /dev/null
@@ -1,265 +0,0 @@
-;*****************************************************************************
-;* x86-optimized Float DSP functions
-;*
-;* Copyright 2006 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 "x86util.asm"
-
-SECTION .text
-
-;-----------------------------------------------------------------------------
-; void vector_fmul(float *dst, const float *src0, const float *src1, int len)
-;-----------------------------------------------------------------------------
-%macro VECTOR_FMUL 0
-cglobal vector_fmul, 4,4,2, dst, src0, src1, len
- lea lenq, [lend*4 - 2*mmsize]
-ALIGN 16
-.loop:
- mova m0, [src0q + lenq]
- mova m1, [src0q + lenq + mmsize]
- mulps m0, m0, [src1q + lenq]
- mulps m1, m1, [src1q + lenq + mmsize]
- mova [dstq + lenq], m0
- mova [dstq + lenq + mmsize], m1
-
- sub lenq, 2*mmsize
- jge .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse
-VECTOR_FMUL
-%if HAVE_AVX_EXTERNAL
-INIT_YMM avx
-VECTOR_FMUL
-%endif
-
-;------------------------------------------------------------------------------
-; void ff_vector_fmac_scalar(float *dst, const float *src, float mul, int len)
-;------------------------------------------------------------------------------
-
-%macro VECTOR_FMAC_SCALAR 0
-%if UNIX64
-cglobal vector_fmac_scalar, 3,3,3, dst, src, len
-%else
-cglobal vector_fmac_scalar, 4,4,3, dst, src, mul, len
-%endif
-%if ARCH_X86_32
- VBROADCASTSS m0, mulm
-%else
-%if WIN64
- mova xmm0, xmm2
-%endif
- shufps xmm0, xmm0, 0
-%if cpuflag(avx)
- vinsertf128 m0, m0, xmm0, 1
-%endif
-%endif
- lea lenq, [lend*4-2*mmsize]
-.loop:
- mulps m1, m0, [srcq+lenq ]
- mulps m2, m0, [srcq+lenq+mmsize]
- addps m1, m1, [dstq+lenq ]
- addps m2, m2, [dstq+lenq+mmsize]
- mova [dstq+lenq ], m1
- mova [dstq+lenq+mmsize], m2
- sub lenq, 2*mmsize
- jge .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse
-VECTOR_FMAC_SCALAR
-%if HAVE_AVX_EXTERNAL
-INIT_YMM avx
-VECTOR_FMAC_SCALAR
-%endif
-
-;------------------------------------------------------------------------------
-; void ff_vector_fmul_scalar(float *dst, const float *src, float mul, int len)
-;------------------------------------------------------------------------------
-
-%macro VECTOR_FMUL_SCALAR 0
-%if UNIX64
-cglobal vector_fmul_scalar, 3,3,2, dst, src, len
-%else
-cglobal vector_fmul_scalar, 4,4,3, dst, src, mul, len
-%endif
-%if ARCH_X86_32
- movss m0, mulm
-%elif WIN64
- SWAP 0, 2
-%endif
- shufps m0, m0, 0
- lea lenq, [lend*4-mmsize]
-.loop:
- mova m1, [srcq+lenq]
- mulps m1, m0
- mova [dstq+lenq], m1
- sub lenq, mmsize
- jge .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse
-VECTOR_FMUL_SCALAR
-
-;------------------------------------------------------------------------------
-; void ff_vector_dmul_scalar(double *dst, const double *src, double mul,
-; int len)
-;------------------------------------------------------------------------------
-
-%macro VECTOR_DMUL_SCALAR 0
-%if ARCH_X86_32
-cglobal vector_dmul_scalar, 3,4,3, dst, src, mul, len, lenaddr
- mov lenq, lenaddrm
-%elif UNIX64
-cglobal vector_dmul_scalar, 3,3,3, dst, src, len
-%else
-cglobal vector_dmul_scalar, 4,4,3, dst, src, mul, len
-%endif
-%if ARCH_X86_32
- VBROADCASTSD m0, mulm
-%else
-%if WIN64
- movlhps xmm2, xmm2
-%if cpuflag(avx)
- vinsertf128 ymm2, ymm2, xmm2, 1
-%endif
- SWAP 0, 2
-%else
- movlhps xmm0, xmm0
-%if cpuflag(avx)
- vinsertf128 ymm0, ymm0, xmm0, 1
-%endif
-%endif
-%endif
- lea lenq, [lend*8-2*mmsize]
-.loop:
- mulpd m1, m0, [srcq+lenq ]
- mulpd m2, m0, [srcq+lenq+mmsize]
- mova [dstq+lenq ], m1
- mova [dstq+lenq+mmsize], m2
- sub lenq, 2*mmsize
- jge .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse2
-VECTOR_DMUL_SCALAR
-%if HAVE_AVX_EXTERNAL
-INIT_YMM avx
-VECTOR_DMUL_SCALAR
-%endif
-
-;-----------------------------------------------------------------------------
-; vector_fmul_add(float *dst, const float *src0, const float *src1,
-; const float *src2, int len)
-;-----------------------------------------------------------------------------
-%macro VECTOR_FMUL_ADD 0
-cglobal vector_fmul_add, 5,5,2, dst, src0, src1, src2, len
- lea lenq, [lend*4 - 2*mmsize]
-ALIGN 16
-.loop:
- mova m0, [src0q + lenq]
- mova m1, [src0q + lenq + mmsize]
- mulps m0, m0, [src1q + lenq]
- mulps m1, m1, [src1q + lenq + mmsize]
- addps m0, m0, [src2q + lenq]
- addps m1, m1, [src2q + lenq + mmsize]
- mova [dstq + lenq], m0
- mova [dstq + lenq + mmsize], m1
-
- sub lenq, 2*mmsize
- jge .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse
-VECTOR_FMUL_ADD
-%if HAVE_AVX_EXTERNAL
-INIT_YMM avx
-VECTOR_FMUL_ADD
-%endif
-
-;-----------------------------------------------------------------------------
-; void vector_fmul_reverse(float *dst, const float *src0, const float *src1,
-; int len)
-;-----------------------------------------------------------------------------
-%macro VECTOR_FMUL_REVERSE 0
-cglobal vector_fmul_reverse, 4,4,2, dst, src0, src1, len
- lea lenq, [lend*4 - 2*mmsize]
-ALIGN 16
-.loop:
-%if cpuflag(avx)
- vmovaps xmm0, [src1q + 16]
- vinsertf128 m0, m0, [src1q], 1
- vshufps m0, m0, m0, q0123
- vmovaps xmm1, [src1q + mmsize + 16]
- vinsertf128 m1, m1, [src1q + mmsize], 1
- vshufps m1, m1, m1, q0123
-%else
- mova m0, [src1q]
- mova m1, [src1q + mmsize]
- shufps m0, m0, q0123
- shufps m1, m1, q0123
-%endif
- mulps m0, m0, [src0q + lenq + mmsize]
- mulps m1, m1, [src0q + lenq]
- mova [dstq + lenq + mmsize], m0
- mova [dstq + lenq], m1
- add src1q, 2*mmsize
- sub lenq, 2*mmsize
- jge .loop
- REP_RET
-%endmacro
-
-INIT_XMM sse
-VECTOR_FMUL_REVERSE
-%if HAVE_AVX_EXTERNAL
-INIT_YMM avx
-VECTOR_FMUL_REVERSE
-%endif
-
-; float scalarproduct_float_sse(const float *v1, const float *v2, int len)
-INIT_XMM sse
-cglobal scalarproduct_float, 3,3,2, v1, v2, offset
- neg offsetq
- shl offsetq, 2
- sub v1q, offsetq
- sub v2q, offsetq
- xorps xmm0, xmm0
-.loop:
- movaps xmm1, [v1q+offsetq]
- mulps xmm1, [v2q+offsetq]
- addps xmm0, xmm1
- add offsetq, 16
- js .loop
- movhlps xmm1, xmm0
- addps xmm0, xmm1
- movss xmm1, xmm0
- shufps xmm0, xmm0, 1
- addss xmm0, xmm1
-%if ARCH_X86_64 == 0
- movss r0m, xmm0
- fld dword r0m
-%endif
- RET
-
diff --git a/src/thirdparty/ffmpeg/libavutil/x86/float_dsp_init.c b/src/thirdparty/ffmpeg/libavutil/x86/float_dsp_init.c
deleted file mode 100644
index 72c638f70..000000000
--- a/src/thirdparty/ffmpeg/libavutil/x86/float_dsp_init.c
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * 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/float_dsp.h"
-#include "cpu.h"
-#include "asm.h"
-
-extern void ff_vector_fmul_sse(float *dst, const float *src0, const float *src1,
- int len);
-extern void ff_vector_fmul_avx(float *dst, const float *src0, const float *src1,
- int len);
-
-extern void ff_vector_fmac_scalar_sse(float *dst, const float *src, float mul,
- int len);
-extern void ff_vector_fmac_scalar_avx(float *dst, const float *src, float mul,
- int len);
-
-extern void ff_vector_fmul_scalar_sse(float *dst, const float *src, float mul,
- int len);
-
-extern void ff_vector_dmul_scalar_sse2(double *dst, const double *src,
- double mul, int len);
-extern void ff_vector_dmul_scalar_avx(double *dst, const double *src,
- double mul, int len);
-
-void ff_vector_fmul_add_sse(float *dst, const float *src0, const float *src1,
- const float *src2, int len);
-void ff_vector_fmul_add_avx(float *dst, const float *src0, const float *src1,
- const float *src2, int len);
-
-void ff_vector_fmul_reverse_sse(float *dst, const float *src0,
- const float *src1, int len);
-void ff_vector_fmul_reverse_avx(float *dst, const float *src0,
- const float *src1, int len);
-
-float ff_scalarproduct_float_sse(const float *v1, const float *v2, int order);
-
-#if HAVE_6REGS && HAVE_INLINE_ASM
-static void vector_fmul_window_3dnowext(float *dst, const float *src0,
- const float *src1, const float *win,
- int len)
-{
- x86_reg i = -len * 4;
- x86_reg j = len * 4 - 8;
- __asm__ volatile (
- "1: \n"
- "pswapd (%5, %1), %%mm1 \n"
- "movq (%5, %0), %%mm0 \n"
- "pswapd (%4, %1), %%mm5 \n"
- "movq (%3, %0), %%mm4 \n"
- "movq %%mm0, %%mm2 \n"
- "movq %%mm1, %%mm3 \n"
- "pfmul %%mm4, %%mm2 \n" // src0[len + i] * win[len + i]
- "pfmul %%mm5, %%mm3 \n" // src1[j] * win[len + j]
- "pfmul %%mm4, %%mm1 \n" // src0[len + i] * win[len + j]
- "pfmul %%mm5, %%mm0 \n" // src1[j] * win[len + i]
- "pfadd %%mm3, %%mm2 \n"
- "pfsub %%mm0, %%mm1 \n"
- "pswapd %%mm2, %%mm2 \n"
- "movq %%mm1, (%2, %0) \n"
- "movq %%mm2, (%2, %1) \n"
- "sub $8, %1 \n"
- "add $8, %0 \n"
- "jl 1b \n"
- "femms \n"
- : "+r"(i), "+r"(j)
- : "r"(dst + len), "r"(src0 + len), "r"(src1), "r"(win + len)
- );
-}
-
-static void vector_fmul_window_sse(float *dst, const float *src0,
- const float *src1, const float *win, int len)
-{
- x86_reg i = -len * 4;
- x86_reg j = len * 4 - 16;
- __asm__ volatile (
- "1: \n"
- "movaps (%5, %1), %%xmm1 \n"
- "movaps (%5, %0), %%xmm0 \n"
- "movaps (%4, %1), %%xmm5 \n"
- "movaps (%3, %0), %%xmm4 \n"
- "shufps $0x1b, %%xmm1, %%xmm1 \n"
- "shufps $0x1b, %%xmm5, %%xmm5 \n"
- "movaps %%xmm0, %%xmm2 \n"
- "movaps %%xmm1, %%xmm3 \n"
- "mulps %%xmm4, %%xmm2 \n" // src0[len + i] * win[len + i]
- "mulps %%xmm5, %%xmm3 \n" // src1[j] * win[len + j]
- "mulps %%xmm4, %%xmm1 \n" // src0[len + i] * win[len + j]
- "mulps %%xmm5, %%xmm0 \n" // src1[j] * win[len + i]
- "addps %%xmm3, %%xmm2 \n"
- "subps %%xmm0, %%xmm1 \n"
- "shufps $0x1b, %%xmm2, %%xmm2 \n"
- "movaps %%xmm1, (%2, %0) \n"
- "movaps %%xmm2, (%2, %1) \n"
- "sub $16, %1 \n"
- "add $16, %0 \n"
- "jl 1b \n"
- : "+r"(i), "+r"(j)
- : "r"(dst + len), "r"(src0 + len), "r"(src1), "r"(win + len)
- );
-}
-#endif /* HAVE_6REGS && HAVE_INLINE_ASM */
-
-void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp)
-{
- int mm_flags = av_get_cpu_flags();
-
-#if HAVE_6REGS && HAVE_INLINE_ASM
- if (INLINE_AMD3DNOWEXT(mm_flags)) {
- fdsp->vector_fmul_window = vector_fmul_window_3dnowext;
- }
- if (INLINE_SSE(mm_flags)) {
- fdsp->vector_fmul_window = vector_fmul_window_sse;
- }
-#endif
- if (EXTERNAL_SSE(mm_flags)) {
- fdsp->vector_fmul = ff_vector_fmul_sse;
- fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_sse;
- fdsp->vector_fmul_scalar = ff_vector_fmul_scalar_sse;
- fdsp->vector_fmul_add = ff_vector_fmul_add_sse;
- fdsp->vector_fmul_reverse = ff_vector_fmul_reverse_sse;
- fdsp->scalarproduct_float = ff_scalarproduct_float_sse;
- }
- if (EXTERNAL_SSE2(mm_flags)) {
- fdsp->vector_dmul_scalar = ff_vector_dmul_scalar_sse2;
- }
- if (EXTERNAL_AVX(mm_flags)) {
- fdsp->vector_fmul = ff_vector_fmul_avx;
- fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_avx;
- fdsp->vector_dmul_scalar = ff_vector_dmul_scalar_avx;
- fdsp->vector_fmul_add = ff_vector_fmul_add_avx;
- fdsp->vector_fmul_reverse = ff_vector_fmul_reverse_avx;
- }
-}
diff --git a/src/thirdparty/ffmpeg/libavutil/x86/intreadwrite.h b/src/thirdparty/ffmpeg/libavutil/x86/intreadwrite.h
deleted file mode 100644
index 2fe2312f5..000000000
--- a/src/thirdparty/ffmpeg/libavutil/x86/intreadwrite.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (c) 2010 Alexander Strange <astrange@ithinksw.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 AVUTIL_X86_INTREADWRITE_H
-#define AVUTIL_X86_INTREADWRITE_H
-
-#include <stdint.h>
-#include "config.h"
-#include "libavutil/attributes.h"
-
-#if HAVE_MMX
-
-#if !HAVE_FAST_64BIT && defined(__MMX__)
-
-#define AV_COPY64 AV_COPY64
-static av_always_inline void AV_COPY64(void *d, const void *s)
-{
- __asm__("movq %1, %%mm0 \n\t"
- "movq %%mm0, %0 \n\t"
- : "=m"(*(uint64_t*)d)
- : "m" (*(const uint64_t*)s)
- : "mm0");
-}
-
-#define AV_SWAP64 AV_SWAP64
-static av_always_inline void AV_SWAP64(void *a, void *b)
-{
- __asm__("movq %1, %%mm0 \n\t"
- "movq %0, %%mm1 \n\t"
- "movq %%mm0, %0 \n\t"
- "movq %%mm1, %1 \n\t"
- : "+m"(*(uint64_t*)a), "+m"(*(uint64_t*)b)
- ::"mm0", "mm1");
-}
-
-#define AV_ZERO64 AV_ZERO64
-static av_always_inline void AV_ZERO64(void *d)
-{
- __asm__("pxor %%mm0, %%mm0 \n\t"
- "movq %%mm0, %0 \n\t"
- : "=m"(*(uint64_t*)d)
- :: "mm0");
-}
-
-#endif /* !HAVE_FAST_64BIT && defined(__MMX__) */
-
-#ifdef __SSE__
-
-#define AV_COPY128 AV_COPY128
-static av_always_inline void AV_COPY128(void *d, const void *s)
-{
- struct v {uint64_t v[2];};
-
- __asm__("movaps %1, %%xmm0 \n\t"
- "movaps %%xmm0, %0 \n\t"
- : "=m"(*(struct v*)d)
- : "m" (*(const struct v*)s)
- : "xmm0");
-}
-
-#endif /* __SSE__ */
-
-#ifdef __SSE2__
-
-#define AV_ZERO128 AV_ZERO128
-static av_always_inline void AV_ZERO128(void *d)
-{
- struct v {uint64_t v[2];};
-
- __asm__("pxor %%xmm0, %%xmm0 \n\t"
- "movdqa %%xmm0, %0 \n\t"
- : "=m"(*(struct v*)d)
- :: "xmm0");
-}
-
-#endif /* __SSE2__ */
-
-#endif /* HAVE_MMX */
-
-#endif /* AVUTIL_X86_INTREADWRITE_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/x86/timer.h b/src/thirdparty/ffmpeg/libavutil/x86/timer.h
deleted file mode 100644
index 3a88ecc2a..000000000
--- a/src/thirdparty/ffmpeg/libavutil/x86/timer.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * copyright (c) 2006 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
- */
-
-#ifndef AVUTIL_X86_TIMER_H
-#define AVUTIL_X86_TIMER_H
-
-#include <stdint.h>
-
-#if HAVE_INLINE_ASM
-
-#define AV_READ_TIME read_time
-
-static inline uint64_t read_time(void)
-{
- uint32_t a, d;
- __asm__ volatile("rdtsc" : "=a" (a), "=d" (d));
- return ((uint64_t)d << 32) + a;
-}
-
-#elif HAVE_RDTSC
-
-#define AV_READ_TIME __rdtsc
-
-#endif /* HAVE_INLINE_ASM */
-
-#endif /* AVUTIL_X86_TIMER_H */
diff --git a/src/thirdparty/ffmpeg/libavutil/x86/x86inc.asm b/src/thirdparty/ffmpeg/libavutil/x86/x86inc.asm
deleted file mode 100644
index 957a1d23e..000000000
--- a/src/thirdparty/ffmpeg/libavutil/x86/x86inc.asm
+++ /dev/null
@@ -1,1310 +0,0 @@
-;*****************************************************************************
-;* x86inc.asm: x264asm abstraction layer
-;*****************************************************************************
-;* Copyright (C) 2005-2012 x264 project
-;*
-;* Authors: Loren Merritt <lorenm@u.washington.edu>
-;* Anton Mitrofanov <BugMaster@narod.ru>
-;* Jason Garrett-Glaser <darkshikari@gmail.com>
-;* Henrik Gramner <hengar-6@student.ltu.se>
-;*
-;* Permission to use, copy, modify, and/or distribute this software for any
-;* purpose with or without fee is hereby granted, provided that the above
-;* copyright notice and this permission notice appear in all copies.
-;*
-;* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-;* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-;* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-;* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-;* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-;* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-;* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-;*****************************************************************************
-
-; This is a header file for the x264ASM assembly language, which uses
-; NASM/YASM syntax combined with a large number of macros to provide easy
-; abstraction between different calling conventions (x86_32, win64, linux64).
-; It also has various other useful features to simplify writing the kind of
-; DSP functions that are most often used in x264.
-
-; Unlike the rest of x264, this file is available under an ISC license, as it
-; has significant usefulness outside of x264 and we want it to be available
-; to the largest audience possible. Of course, if you modify it for your own
-; purposes to add a new feature, we strongly encourage contributing a patch
-; as this feature might be useful for others as well. Send patches or ideas
-; to x264-devel@videolan.org .
-
-%ifndef private_prefix
- %define private_prefix x264
-%endif
-
-%ifndef public_prefix
- %define public_prefix private_prefix
-%endif
-
-%define WIN64 0
-%define UNIX64 0
-%if ARCH_X86_64
- %ifidn __OUTPUT_FORMAT__,win32
- %define WIN64 1
- %elifidn __OUTPUT_FORMAT__,win64
- %define WIN64 1
- %else
- %define UNIX64 1
- %endif
-%endif
-
-%ifdef PREFIX
- %define mangle(x) _ %+ x
-%else
- %define mangle(x) x
-%endif
-
-; Name of the .rodata section.
-%macro SECTION_RODATA 0-1 16
- ; Kludge: Something on OS X fails to align .rodata even given an align
- ; attribute, so use a different read-only section. This has been fixed in
- ; yasm 0.8.0 and nasm 2.6.
- %ifdef __YASM_VERSION_ID__
- %if __YASM_VERSION_ID__ < 00080000h
- %define NEED_MACHO_RODATA_KLUDGE
- %endif
- %elifdef __NASM_VERSION_ID__
- %if __NASM_VERSION_ID__ < 02060000h
- %define NEED_MACHO_RODATA_KLUDGE
- %endif
- %endif
-
- %ifidn __OUTPUT_FORMAT__,aout
- section .text
- %else
- %ifndef NEED_MACHO_RODATA_KLUDGE
- SECTION .rodata align=%1
- %else
- %ifidn __OUTPUT_FORMAT__,macho64
- SECTION .text align=%1
- %elifidn __OUTPUT_FORMAT__,macho
- SECTION .text align=%1
- fakegot:
- %else
- SECTION .rodata align=%1
- %endif
- %endif
- %endif
-
- %undef NEED_MACHO_RODATA_KLUDGE
-%endmacro
-
-; aout does not support align=
-%macro SECTION_TEXT 0-1 16
- %ifidn __OUTPUT_FORMAT__,aout
- SECTION .text
- %else
- SECTION .text align=%1
- %endif
-%endmacro
-
-%if WIN64
- %define PIC
-%elif ARCH_X86_64 == 0
-; x86_32 doesn't require PIC.
-; Some distros prefer shared objects to be PIC, but nothing breaks if
-; the code contains a few textrels, so we'll skip that complexity.
- %undef PIC
-%endif
-%ifdef PIC
- default rel
-%endif
-
-%macro CPUNOP 1
- %if HAVE_CPUNOP
- CPU %1
- %endif
-%endmacro
-
-; Always use long nops (reduces 0x90 spam in disassembly on x86_32)
-CPUNOP amdnop
-
-; Macros to eliminate most code duplication between x86_32 and x86_64:
-; Currently this works only for leaf functions which load all their arguments
-; into registers at the start, and make no other use of the stack. Luckily that
-; covers most of x264's asm.
-
-; PROLOGUE:
-; %1 = number of arguments. loads them from stack if needed.
-; %2 = number of registers used. pushes callee-saved regs if needed.
-; %3 = number of xmm registers used. pushes callee-saved xmm regs if needed.
-; %4 = (optional) stack size to be allocated. If not aligned (x86-32 ICC 10.x,
-; MSVC or YMM), the stack will be manually aligned (to 16 or 32 bytes),
-; and an extra register will be allocated to hold the original stack
-; pointer (to not invalidate r0m etc.). To prevent the use of an extra
-; register as stack pointer, request a negative stack size.
-; %4+/%5+ = list of names to define to registers
-; PROLOGUE can also be invoked by adding the same options to cglobal
-
-; e.g.
-; cglobal foo, 2,3,0, dst, src, tmp
-; declares a function (foo), taking two args (dst and src) and one local variable (tmp)
-
-; TODO Some functions can use some args directly from the stack. If they're the
-; last args then you can just not declare them, but if they're in the middle
-; we need more flexible macro.
-
-; RET:
-; Pops anything that was pushed by PROLOGUE, and returns.
-
-; REP_RET:
-; Same, but if it doesn't pop anything it becomes a 2-byte ret, for athlons
-; which are slow when a normal ret follows a branch.
-
-; registers:
-; rN and rNq are the native-size register holding function argument N
-; rNd, rNw, rNb are dword, word, and byte size
-; rNh is the high 8 bits of the word size
-; rNm is the original location of arg N (a register or on the stack), dword
-; rNmp is native size
-
-%macro DECLARE_REG 2-3
- %define r%1q %2
- %define r%1d %2d
- %define r%1w %2w
- %define r%1b %2b
- %define r%1h %2h
- %define %2q %2
- %if %0 == 2
- %define r%1m %2d
- %define r%1mp %2
- %elif ARCH_X86_64 ; memory
- %define r%1m [rstk + stack_offset + %3]
- %define r%1mp qword r %+ %1 %+ m
- %else
- %define r%1m [rstk + stack_offset + %3]
- %define r%1mp dword r %+ %1 %+ m
- %endif
- %define r%1 %2
-%endmacro
-
-%macro DECLARE_REG_SIZE 3
- %define r%1q r%1
- %define e%1q r%1
- %define r%1d e%1
- %define e%1d e%1
- %define r%1w %1
- %define e%1w %1
- %define r%1h %3
- %define e%1h %3
- %define r%1b %2
- %define e%1b %2
-%if ARCH_X86_64 == 0
- %define r%1 e%1
-%endif
-%endmacro
-
-DECLARE_REG_SIZE ax, al, ah
-DECLARE_REG_SIZE bx, bl, bh
-DECLARE_REG_SIZE cx, cl, ch
-DECLARE_REG_SIZE dx, dl, dh
-DECLARE_REG_SIZE si, sil, null
-DECLARE_REG_SIZE di, dil, null
-DECLARE_REG_SIZE bp, bpl, null
-
-; t# defines for when per-arch register allocation is more complex than just function arguments
-
-%macro DECLARE_REG_TMP 1-*
- %assign %%i 0
- %rep %0
- CAT_XDEFINE t, %%i, r%1
- %assign %%i %%i+1
- %rotate 1
- %endrep
-%endmacro
-
-%macro DECLARE_REG_TMP_SIZE 0-*
- %rep %0
- %define t%1q t%1 %+ q
- %define t%1d t%1 %+ d
- %define t%1w t%1 %+ w
- %define t%1h t%1 %+ h
- %define t%1b t%1 %+ b
- %rotate 1
- %endrep
-%endmacro
-
-DECLARE_REG_TMP_SIZE 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14
-
-%if ARCH_X86_64
- %define gprsize 8
-%else
- %define gprsize 4
-%endif
-
-%macro PUSH 1
- push %1
- %ifidn rstk, rsp
- %assign stack_offset stack_offset+gprsize
- %endif
-%endmacro
-
-%macro POP 1
- pop %1
- %ifidn rstk, rsp
- %assign stack_offset stack_offset-gprsize
- %endif
-%endmacro
-
-%macro PUSH_IF_USED 1-*
- %rep %0
- %if %1 < regs_used
- PUSH r%1
- %endif
- %rotate 1
- %endrep
-%endmacro
-
-%macro POP_IF_USED 1-*
- %rep %0
- %if %1 < regs_used
- pop r%1
- %endif
- %rotate 1
- %endrep
-%endmacro
-
-%macro LOAD_IF_USED 1-*
- %rep %0
- %if %1 < num_args
- mov r%1, r %+ %1 %+ mp
- %endif
- %rotate 1
- %endrep
-%endmacro
-
-%macro SUB 2
- sub %1, %2
- %ifidn %1, rstk
- %assign stack_offset stack_offset+(%2)
- %endif
-%endmacro
-
-%macro ADD 2
- add %1, %2
- %ifidn %1, rstk
- %assign stack_offset stack_offset-(%2)
- %endif
-%endmacro
-
-%macro movifnidn 2
- %ifnidn %1, %2
- mov %1, %2
- %endif
-%endmacro
-
-%macro movsxdifnidn 2
- %ifnidn %1, %2
- movsxd %1, %2
- %endif
-%endmacro
-
-%macro ASSERT 1
- %if (%1) == 0
- %error assert failed
- %endif
-%endmacro
-
-%macro DEFINE_ARGS 0-*
- %ifdef n_arg_names
- %assign %%i 0
- %rep n_arg_names
- CAT_UNDEF arg_name %+ %%i, q
- CAT_UNDEF arg_name %+ %%i, d
- CAT_UNDEF arg_name %+ %%i, w
- CAT_UNDEF arg_name %+ %%i, h
- CAT_UNDEF arg_name %+ %%i, b
- CAT_UNDEF arg_name %+ %%i, m
- CAT_UNDEF arg_name %+ %%i, mp
- CAT_UNDEF arg_name, %%i
- %assign %%i %%i+1
- %endrep
- %endif
-
- %xdefine %%stack_offset stack_offset
- %undef stack_offset ; so that the current value of stack_offset doesn't get baked in by xdefine
- %assign %%i 0
- %rep %0
- %xdefine %1q r %+ %%i %+ q
- %xdefine %1d r %+ %%i %+ d
- %xdefine %1w r %+ %%i %+ w
- %xdefine %1h r %+ %%i %+ h
- %xdefine %1b r %+ %%i %+ b
- %xdefine %1m r %+ %%i %+ m
- %xdefine %1mp r %+ %%i %+ mp
- CAT_XDEFINE arg_name, %%i, %1
- %assign %%i %%i+1
- %rotate 1
- %endrep
- %xdefine stack_offset %%stack_offset
- %assign n_arg_names %0
-%endmacro
-
-%macro ALLOC_STACK 1-2 0 ; stack_size, n_xmm_regs (for win64 only)
- %ifnum %1
- %if %1 != 0
- %assign %%stack_alignment ((mmsize + 15) & ~15)
- %assign stack_size %1
- %if stack_size < 0
- %assign stack_size -stack_size
- %endif
- %if mmsize != 8
- %assign xmm_regs_used %2
- %endif
- %if mmsize <= 16 && HAVE_ALIGNED_STACK
- %assign stack_size_padded stack_size + %%stack_alignment - gprsize - (stack_offset & (%%stack_alignment - 1))
- %if xmm_regs_used > 6
- %assign stack_size_padded stack_size_padded + (xmm_regs_used - 6) * 16
- %endif
- SUB rsp, stack_size_padded
- %else
- %assign %%reg_num (regs_used - 1)
- %xdefine rstk r %+ %%reg_num
- ; align stack, and save original stack location directly above
- ; it, i.e. in [rsp+stack_size_padded], so we can restore the
- ; stack in a single instruction (i.e. mov rsp, rstk or mov
- ; rsp, [rsp+stack_size_padded])
- mov rstk, rsp
- %assign stack_size_padded stack_size
- %if xmm_regs_used > 6
- %assign stack_size_padded stack_size_padded + (xmm_regs_used - 6) * 16
- %if mmsize == 32 && xmm_regs_used & 1
- ; re-align to 32 bytes
- %assign stack_size_padded (stack_size_padded + 16)
- %endif
- %endif
- %if %1 < 0 ; need to store rsp on stack
- sub rsp, gprsize+stack_size_padded
- and rsp, ~(%%stack_alignment-1)
- %xdefine rstkm [rsp+stack_size_padded]
- mov rstkm, rstk
- %else ; can keep rsp in rstk during whole function
- sub rsp, stack_size_padded
- and rsp, ~(%%stack_alignment-1)
- %xdefine rstkm rstk
- %endif
- %endif
- %if xmm_regs_used > 6
- WIN64_PUSH_XMM
- %endif
- %endif
- %endif
-%endmacro
-
-%macro SETUP_STACK_POINTER 1
- %ifnum %1
- %if %1 != 0 && (HAVE_ALIGNED_STACK == 0 || mmsize == 32)
- %if %1 > 0
- %assign regs_used (regs_used + 1)
- %elif ARCH_X86_64 && regs_used == num_args && num_args <= 4 + UNIX64 * 2
- %warning "Stack pointer will overwrite register argument"
- %endif
- %endif
- %endif
-%endmacro
-
-%macro DEFINE_ARGS_INTERNAL 3+
- %ifnum %2
- DEFINE_ARGS %3
- %elif %1 == 4
- DEFINE_ARGS %2
- %elif %1 > 4
- DEFINE_ARGS %2, %3
- %endif
-%endmacro
-
-%if WIN64 ; Windows x64 ;=================================================
-
-DECLARE_REG 0, rcx
-DECLARE_REG 1, rdx
-DECLARE_REG 2, R8
-DECLARE_REG 3, R9
-DECLARE_REG 4, R10, 40
-DECLARE_REG 5, R11, 48
-DECLARE_REG 6, rax, 56
-DECLARE_REG 7, rdi, 64
-DECLARE_REG 8, rsi, 72
-DECLARE_REG 9, rbx, 80
-DECLARE_REG 10, rbp, 88
-DECLARE_REG 11, R12, 96
-DECLARE_REG 12, R13, 104
-DECLARE_REG 13, R14, 112
-DECLARE_REG 14, R15, 120
-
-%macro PROLOGUE 2-5+ 0 ; #args, #regs, #xmm_regs, [stack_size,] arg_names...
- %assign num_args %1
- %assign regs_used %2
- ASSERT regs_used >= num_args
- SETUP_STACK_POINTER %4
- ASSERT regs_used <= 15
- PUSH_IF_USED 7, 8, 9, 10, 11, 12, 13, 14
- ALLOC_STACK %4, %3
- %if mmsize != 8 && stack_size == 0
- WIN64_SPILL_XMM %3
- %endif
- LOAD_IF_USED 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
- DEFINE_ARGS_INTERNAL %0, %4, %5
-%endmacro
-
-%macro WIN64_PUSH_XMM 0
- %assign %%i xmm_regs_used
- %rep (xmm_regs_used-6)
- %assign %%i %%i-1
- movdqa [rsp + (%%i-6)*16 + stack_size + (~stack_offset&8)], xmm %+ %%i
- %endrep
-%endmacro
-
-%macro WIN64_SPILL_XMM 1
- %assign xmm_regs_used %1
- ASSERT xmm_regs_used <= 16
- %if xmm_regs_used > 6
- SUB rsp, (xmm_regs_used-6)*16+16
- WIN64_PUSH_XMM
- %endif
-%endmacro
-
-%macro WIN64_RESTORE_XMM_INTERNAL 1
- %if xmm_regs_used > 6
- %assign %%i xmm_regs_used
- %rep (xmm_regs_used-6)
- %assign %%i %%i-1
- movdqa xmm %+ %%i, [%1 + (%%i-6)*16+stack_size+(~stack_offset&8)]
- %endrep
- %if stack_size_padded == 0
- add %1, (xmm_regs_used-6)*16+16
- %endif
- %endif
- %if stack_size_padded > 0
- %if stack_size > 0 && (mmsize == 32 || HAVE_ALIGNED_STACK == 0)
- mov rsp, rstkm
- %else
- add %1, stack_size_padded
- %endif
- %endif
-%endmacro
-
-%macro WIN64_RESTORE_XMM 1
- WIN64_RESTORE_XMM_INTERNAL %1
- %assign stack_offset (stack_offset-stack_size_padded)
- %assign xmm_regs_used 0
-%endmacro
-
-%define has_epilogue regs_used > 7 || xmm_regs_used > 6 || mmsize == 32 || stack_size > 0
-
-%macro RET 0
- WIN64_RESTORE_XMM_INTERNAL rsp
- POP_IF_USED 14, 13, 12, 11, 10, 9, 8, 7
-%if mmsize == 32
- vzeroupper
-%endif
- ret
-%endmacro
-
-%elif ARCH_X86_64 ; *nix x64 ;=============================================
-
-DECLARE_REG 0, rdi
-DECLARE_REG 1, rsi
-DECLARE_REG 2, rdx
-DECLARE_REG 3, rcx
-DECLARE_REG 4, R8
-DECLARE_REG 5, R9
-DECLARE_REG 6, rax, 8
-DECLARE_REG 7, R10, 16
-DECLARE_REG 8, R11, 24
-DECLARE_REG 9, rbx, 32
-DECLARE_REG 10, rbp, 40
-DECLARE_REG 11, R12, 48
-DECLARE_REG 12, R13, 56
-DECLARE_REG 13, R14, 64
-DECLARE_REG 14, R15, 72
-
-%macro PROLOGUE 2-5+ ; #args, #regs, #xmm_regs, [stack_size,] arg_names...
- %assign num_args %1
- %assign regs_used %2
- ASSERT regs_used >= num_args
- SETUP_STACK_POINTER %4
- ASSERT regs_used <= 15
- PUSH_IF_USED 9, 10, 11, 12, 13, 14
- ALLOC_STACK %4
- LOAD_IF_USED 6, 7, 8, 9, 10, 11, 12, 13, 14
- DEFINE_ARGS_INTERNAL %0, %4, %5
-%endmacro
-
-%define has_epilogue regs_used > 9 || mmsize == 32 || stack_size > 0
-
-%macro RET 0
-%if stack_size_padded > 0
-%if mmsize == 32 || HAVE_ALIGNED_STACK == 0
- mov rsp, rstkm
-%else
- add rsp, stack_size_padded
-%endif
-%endif
- POP_IF_USED 14, 13, 12, 11, 10, 9
-%if mmsize == 32
- vzeroupper
-%endif
- ret
-%endmacro
-
-%else ; X86_32 ;==============================================================
-
-DECLARE_REG 0, eax, 4
-DECLARE_REG 1, ecx, 8
-DECLARE_REG 2, edx, 12
-DECLARE_REG 3, ebx, 16
-DECLARE_REG 4, esi, 20
-DECLARE_REG 5, edi, 24
-DECLARE_REG 6, ebp, 28
-%define rsp esp
-
-%macro DECLARE_ARG 1-*
- %rep %0
- %define r%1m [rstk + stack_offset + 4*%1 + 4]
- %define r%1mp dword r%1m
- %rotate 1
- %endrep
-%endmacro
-
-DECLARE_ARG 7, 8, 9, 10, 11, 12, 13, 14
-
-%macro PROLOGUE 2-5+ ; #args, #regs, #xmm_regs, [stack_size,] arg_names...
- %assign num_args %1
- %assign regs_used %2
- ASSERT regs_used >= num_args
- %if num_args > 7
- %assign num_args 7
- %endif
- %if regs_used > 7
- %assign regs_used 7
- %endif
- SETUP_STACK_POINTER %4
- ASSERT regs_used <= 7
- PUSH_IF_USED 3, 4, 5, 6
- ALLOC_STACK %4
- LOAD_IF_USED 0, 1, 2, 3, 4, 5, 6
- DEFINE_ARGS_INTERNAL %0, %4, %5
-%endmacro
-
-%define has_epilogue regs_used > 3 || mmsize == 32 || stack_size > 0
-
-%macro RET 0
-%if stack_size_padded > 0
-%if mmsize == 32 || HAVE_ALIGNED_STACK == 0
- mov rsp, rstkm
-%else
- add rsp, stack_size_padded
-%endif
-%endif
- POP_IF_USED 6, 5, 4, 3
-%if mmsize == 32
- vzeroupper
-%endif
- ret
-%endmacro
-
-%endif ;======================================================================
-
-%if WIN64 == 0
-%macro WIN64_SPILL_XMM 1
-%endmacro
-%macro WIN64_RESTORE_XMM 1
-%endmacro
-%macro WIN64_PUSH_XMM 0
-%endmacro
-%endif
-
-%macro REP_RET 0
- %if has_epilogue
- RET
- %else
- rep ret
- %endif
-%endmacro
-
-%macro TAIL_CALL 2 ; callee, is_nonadjacent
- %if has_epilogue
- call %1
- RET
- %elif %2
- jmp %1
- %endif
-%endmacro
-
-;=============================================================================
-; arch-independent part
-;=============================================================================
-
-%assign function_align 16
-
-; Begin a function.
-; Applies any symbol mangling needed for C linkage, and sets up a define such that
-; subsequent uses of the function name automatically refer to the mangled version.
-; Appends cpuflags to the function name if cpuflags has been specified.
-; The "" empty default parameter is a workaround for nasm, which fails if SUFFIX
-; is empty and we call cglobal_internal with just %1 %+ SUFFIX (without %2).
-%macro cglobal 1-2+ "" ; name, [PROLOGUE args]
- cglobal_internal 1, %1 %+ SUFFIX, %2
-%endmacro
-%macro cvisible 1-2+ "" ; name, [PROLOGUE args]
- cglobal_internal 0, %1 %+ SUFFIX, %2
-%endmacro
-%macro cglobal_internal 2-3+
- %if %1
- %xdefine %%FUNCTION_PREFIX private_prefix
- %xdefine %%VISIBILITY hidden
- %else
- %xdefine %%FUNCTION_PREFIX public_prefix
- %xdefine %%VISIBILITY
- %endif
- %ifndef cglobaled_%2
- %xdefine %2 mangle(%%FUNCTION_PREFIX %+ _ %+ %2)
- %xdefine %2.skip_prologue %2 %+ .skip_prologue
- CAT_XDEFINE cglobaled_, %2, 1
- %endif
- %xdefine current_function %2
- %ifidn __OUTPUT_FORMAT__,elf
- global %2:function %%VISIBILITY
- %else
- global %2
- %endif
- align function_align
- %2:
- RESET_MM_PERMUTATION ; not really needed, but makes disassembly somewhat nicer
- %xdefine rstk rsp
- %assign stack_offset 0
- %assign stack_size 0
- %assign stack_size_padded 0
- %assign xmm_regs_used 0
- %ifnidn %3, ""
- PROLOGUE %3
- %endif
-%endmacro
-
-%macro cextern 1
- %xdefine %1 mangle(private_prefix %+ _ %+ %1)
- CAT_XDEFINE cglobaled_, %1, 1
- extern %1
-%endmacro
-
-; like cextern, but without the prefix
-%macro cextern_naked 1
- %xdefine %1 mangle(%1)
- CAT_XDEFINE cglobaled_, %1, 1
- extern %1
-%endmacro
-
-%macro const 2+
- %xdefine %1 mangle(private_prefix %+ _ %+ %1)
- global %1
- %1: %2
-%endmacro
-
-; This is needed for ELF, otherwise the GNU linker assumes the stack is
-; executable by default.
-%ifidn __OUTPUT_FORMAT__,elf
-SECTION .note.GNU-stack noalloc noexec nowrite progbits
-%endif
-
-; cpuflags
-
-%assign cpuflags_mmx (1<<0)
-%assign cpuflags_mmx2 (1<<1) | cpuflags_mmx
-%assign cpuflags_3dnow (1<<2) | cpuflags_mmx
-%assign cpuflags_3dnowext (1<<3) | cpuflags_3dnow
-%assign cpuflags_sse (1<<4) | cpuflags_mmx2
-%assign cpuflags_sse2 (1<<5) | cpuflags_sse
-%assign cpuflags_sse2slow (1<<6) | cpuflags_sse2
-%assign cpuflags_sse3 (1<<7) | cpuflags_sse2
-%assign cpuflags_ssse3 (1<<8) | cpuflags_sse3
-%assign cpuflags_sse4 (1<<9) | cpuflags_ssse3
-%assign cpuflags_sse42 (1<<10)| cpuflags_sse4
-%assign cpuflags_avx (1<<11)| cpuflags_sse42
-%assign cpuflags_xop (1<<12)| cpuflags_avx
-%assign cpuflags_fma4 (1<<13)| cpuflags_avx
-%assign cpuflags_avx2 (1<<14)| cpuflags_avx
-%assign cpuflags_fma3 (1<<15)| cpuflags_avx
-
-%assign cpuflags_cache32 (1<<16)
-%assign cpuflags_cache64 (1<<17)
-%assign cpuflags_slowctz (1<<18)
-%assign cpuflags_lzcnt (1<<19)
-%assign cpuflags_misalign (1<<20)
-%assign cpuflags_aligned (1<<21) ; not a cpu feature, but a function variant
-%assign cpuflags_atom (1<<22)
-%assign cpuflags_bmi1 (1<<23)
-%assign cpuflags_bmi2 (1<<24)|cpuflags_bmi1
-%assign cpuflags_tbm (1<<25)|cpuflags_bmi1
-
-%define cpuflag(x) ((cpuflags & (cpuflags_ %+ x)) == (cpuflags_ %+ x))
-%define notcpuflag(x) ((cpuflags & (cpuflags_ %+ x)) != (cpuflags_ %+ x))
-
-; Takes up to 2 cpuflags from the above list.
-; All subsequent functions (up to the next INIT_CPUFLAGS) is built for the specified cpu.
-; You shouldn't need to invoke this macro directly, it's a subroutine for INIT_MMX &co.
-%macro INIT_CPUFLAGS 0-2
- CPUNOP amdnop
- %if %0 >= 1
- %xdefine cpuname %1
- %assign cpuflags cpuflags_%1
- %if %0 >= 2
- %xdefine cpuname %1_%2
- %assign cpuflags cpuflags | cpuflags_%2
- %endif
- %xdefine SUFFIX _ %+ cpuname
- %if cpuflag(avx)
- %assign avx_enabled 1
- %endif
- %if mmsize == 16 && notcpuflag(sse2)
- %define mova movaps
- %define movu movups
- %define movnta movntps
- %endif
- %if cpuflag(aligned)
- %define movu mova
- %elifidn %1, sse3
- %define movu lddqu
- %endif
- %if notcpuflag(sse2)
- CPUNOP basicnop
- %endif
- %else
- %xdefine SUFFIX
- %undef cpuname
- %undef cpuflags
- %endif
-%endmacro
-
-; merge mmx and sse*
-
-%macro CAT_XDEFINE 3
- %xdefine %1%2 %3
-%endmacro
-
-%macro CAT_UNDEF 2
- %undef %1%2
-%endmacro
-
-%macro INIT_MMX 0-1+
- %assign avx_enabled 0
- %define RESET_MM_PERMUTATION INIT_MMX %1
- %define mmsize 8
- %define num_mmregs 8
- %define mova movq
- %define movu movq
- %define movh movd
- %define movnta movntq
- %assign %%i 0
- %rep 8
- CAT_XDEFINE m, %%i, mm %+ %%i
- CAT_XDEFINE nmm, %%i, %%i
- %assign %%i %%i+1
- %endrep
- %rep 8
- CAT_UNDEF m, %%i
- CAT_UNDEF nmm, %%i
- %assign %%i %%i+1
- %endrep
- INIT_CPUFLAGS %1
-%endmacro
-
-%macro INIT_XMM 0-1+
- %assign avx_enabled 0
- %define RESET_MM_PERMUTATION INIT_XMM %1
- %define mmsize 16
- %define num_mmregs 8
- %if ARCH_X86_64
- %define num_mmregs 16
- %endif
- %define mova movdqa
- %define movu movdqu
- %define movh movq
- %define movnta movntdq
- %assign %%i 0
- %rep num_mmregs
- CAT_XDEFINE m, %%i, xmm %+ %%i
- CAT_XDEFINE nxmm, %%i, %%i
- %assign %%i %%i+1
- %endrep
- INIT_CPUFLAGS %1
-%endmacro
-
-; FIXME: INIT_AVX can be replaced by INIT_XMM avx
-%macro INIT_AVX 0
- INIT_XMM
- %assign avx_enabled 1
- %define PALIGNR PALIGNR_SSSE3
- %define RESET_MM_PERMUTATION INIT_AVX
-%endmacro
-
-%macro INIT_YMM 0-1+
- %assign avx_enabled 1
- %define RESET_MM_PERMUTATION INIT_YMM %1
- %define mmsize 32
- %define num_mmregs 8
- %if ARCH_X86_64
- %define num_mmregs 16
- %endif
- %define mova vmovaps
- %define movu vmovups
- %undef movh
- %define movnta vmovntps
- %assign %%i 0
- %rep num_mmregs
- CAT_XDEFINE m, %%i, ymm %+ %%i
- CAT_XDEFINE nymm, %%i, %%i
- %assign %%i %%i+1
- %endrep
- INIT_CPUFLAGS %1
-%endmacro
-
-INIT_XMM
-
-; I often want to use macros that permute their arguments. e.g. there's no
-; efficient way to implement butterfly or transpose or dct without swapping some
-; arguments.
-;
-; I would like to not have to manually keep track of the permutations:
-; If I insert a permutation in the middle of a function, it should automatically
-; change everything that follows. For more complex macros I may also have multiple
-; implementations, e.g. the SSE2 and SSSE3 versions may have different permutations.
-;
-; Hence these macros. Insert a PERMUTE or some SWAPs at the end of a macro that
-; permutes its arguments. It's equivalent to exchanging the contents of the
-; registers, except that this way you exchange the register names instead, so it
-; doesn't cost any cycles.
-
-%macro PERMUTE 2-* ; takes a list of pairs to swap
-%rep %0/2
- %xdefine tmp%2 m%2
- %xdefine ntmp%2 nm%2
- %rotate 2
-%endrep
-%rep %0/2
- %xdefine m%1 tmp%2
- %xdefine nm%1 ntmp%2
- %undef tmp%2
- %undef ntmp%2
- %rotate 2
-%endrep
-%endmacro
-
-%macro SWAP 2-* ; swaps a single chain (sometimes more concise than pairs)
-%rep %0-1
-%ifdef m%1
- %xdefine tmp m%1
- %xdefine m%1 m%2
- %xdefine m%2 tmp
- CAT_XDEFINE n, m%1, %1
- CAT_XDEFINE n, m%2, %2
-%else
- ; If we were called as "SWAP m0,m1" rather than "SWAP 0,1" infer the original numbers here.
- ; Be careful using this mode in nested macros though, as in some cases there may be
- ; other copies of m# that have already been dereferenced and don't get updated correctly.
- %xdefine %%n1 n %+ %1
- %xdefine %%n2 n %+ %2
- %xdefine tmp m %+ %%n1
- CAT_XDEFINE m, %%n1, m %+ %%n2
- CAT_XDEFINE m, %%n2, tmp
- CAT_XDEFINE n, m %+ %%n1, %%n1
- CAT_XDEFINE n, m %+ %%n2, %%n2
-%endif
- %undef tmp
- %rotate 1
-%endrep
-%endmacro
-
-; If SAVE_MM_PERMUTATION is placed at the end of a function, then any later
-; calls to that function will automatically load the permutation, so values can
-; be returned in mmregs.
-%macro SAVE_MM_PERMUTATION 0-1
- %if %0
- %xdefine %%f %1_m
- %else
- %xdefine %%f current_function %+ _m
- %endif
- %assign %%i 0
- %rep num_mmregs
- CAT_XDEFINE %%f, %%i, m %+ %%i
- %assign %%i %%i+1
- %endrep
-%endmacro
-
-%macro LOAD_MM_PERMUTATION 1 ; name to load from
- %ifdef %1_m0
- %assign %%i 0
- %rep num_mmregs
- CAT_XDEFINE m, %%i, %1_m %+ %%i
- CAT_XDEFINE n, m %+ %%i, %%i
- %assign %%i %%i+1
- %endrep
- %endif
-%endmacro
-
-; Append cpuflags to the callee's name iff the appended name is known and the plain name isn't
-%macro call 1
- call_internal %1 %+ SUFFIX, %1
-%endmacro
-%macro call_internal 2
- %xdefine %%i %2
- %ifndef cglobaled_%2
- %ifdef cglobaled_%1
- %xdefine %%i %1
- %endif
- %endif
- call %%i
- LOAD_MM_PERMUTATION %%i
-%endmacro
-
-; Substitutions that reduce instruction size but are functionally equivalent
-%macro add 2
- %ifnum %2
- %if %2==128
- sub %1, -128
- %else
- add %1, %2
- %endif
- %else
- add %1, %2
- %endif
-%endmacro
-
-%macro sub 2
- %ifnum %2
- %if %2==128
- add %1, -128
- %else
- sub %1, %2
- %endif
- %else
- sub %1, %2
- %endif
-%endmacro
-
-;=============================================================================
-; AVX abstraction layer
-;=============================================================================
-
-%assign i 0
-%rep 16
- %if i < 8
- CAT_XDEFINE sizeofmm, i, 8
- %endif
- CAT_XDEFINE sizeofxmm, i, 16
- CAT_XDEFINE sizeofymm, i, 32
-%assign i i+1
-%endrep
-%undef i
-
-%macro CHECK_AVX_INSTR_EMU 3-*
- %xdefine %%opcode %1
- %xdefine %%dst %2
- %rep %0-2
- %ifidn %%dst, %3
- %error non-avx emulation of ``%%opcode'' is not supported
- %endif
- %rotate 1
- %endrep
-%endmacro
-
-;%1 == instruction
-;%2 == 1 if float, 0 if int
-;%3 == 1 if 4-operand (xmm, xmm, xmm, imm), 0 if 2- or 3-operand (xmm, xmm, xmm)
-;%4 == number of operands given
-;%5+: operands
-%macro RUN_AVX_INSTR 6-7+
- %ifid %6
- %define %%sizeofreg sizeof%6
- %elifid %5
- %define %%sizeofreg sizeof%5
- %else
- %define %%sizeofreg mmsize
- %endif
- %if %%sizeofreg==32
- %if %4>=3
- v%1 %5, %6, %7
- %else
- v%1 %5, %6
- %endif
- %else
- %if %%sizeofreg==8
- %define %%regmov movq
- %elif %2
- %define %%regmov movaps
- %else
- %define %%regmov movdqa
- %endif
-
- %if %4>=3+%3
- %ifnidn %5, %6
- %if avx_enabled && %%sizeofreg==16
- v%1 %5, %6, %7
- %else
- CHECK_AVX_INSTR_EMU {%1 %5, %6, %7}, %5, %7
- %%regmov %5, %6
- %1 %5, %7
- %endif
- %else
- %1 %5, %7
- %endif
- %elif %4>=3
- %1 %5, %6, %7
- %else
- %1 %5, %6
- %endif
- %endif
-%endmacro
-
-; 3arg AVX ops with a memory arg can only have it in src2,
-; whereas SSE emulation of 3arg prefers to have it in src1 (i.e. the mov).
-; So, if the op is symmetric and the wrong one is memory, swap them.
-%macro RUN_AVX_INSTR1 8
- %assign %%swap 0
- %if avx_enabled
- %ifnid %6
- %assign %%swap 1
- %endif
- %elifnidn %5, %6
- %ifnid %7
- %assign %%swap 1
- %endif
- %endif
- %if %%swap && %3 == 0 && %8 == 1
- RUN_AVX_INSTR %1, %2, %3, %4, %5, %7, %6
- %else
- RUN_AVX_INSTR %1, %2, %3, %4, %5, %6, %7
- %endif
-%endmacro
-
-;%1 == instruction
-;%2 == 1 if float, 0 if int
-;%3 == 1 if 4-operand (xmm, xmm, xmm, imm), 0 if 2- or 3-operand (xmm, xmm, xmm)
-;%4 == 1 if symmetric (i.e. doesn't matter which src arg is which), 0 if not
-%macro AVX_INSTR 4
- %macro %1 2-9 fnord, fnord, fnord, %1, %2, %3, %4
- %ifidn %3, fnord
- RUN_AVX_INSTR %6, %7, %8, 2, %1, %2
- %elifidn %4, fnord
- RUN_AVX_INSTR1 %6, %7, %8, 3, %1, %2, %3, %9
- %elifidn %5, fnord
- RUN_AVX_INSTR %6, %7, %8, 4, %1, %2, %3, %4
- %else
- RUN_AVX_INSTR %6, %7, %8, 5, %1, %2, %3, %4, %5
- %endif
- %endmacro
-%endmacro
-
-AVX_INSTR addpd, 1, 0, 1
-AVX_INSTR addps, 1, 0, 1
-AVX_INSTR addsd, 1, 0, 1
-AVX_INSTR addss, 1, 0, 1
-AVX_INSTR addsubpd, 1, 0, 0
-AVX_INSTR addsubps, 1, 0, 0
-AVX_INSTR andpd, 1, 0, 1
-AVX_INSTR andps, 1, 0, 1
-AVX_INSTR andnpd, 1, 0, 0
-AVX_INSTR andnps, 1, 0, 0
-AVX_INSTR blendpd, 1, 0, 0
-AVX_INSTR blendps, 1, 0, 0
-AVX_INSTR blendvpd, 1, 0, 0
-AVX_INSTR blendvps, 1, 0, 0
-AVX_INSTR cmppd, 1, 0, 0
-AVX_INSTR cmpps, 1, 0, 0
-AVX_INSTR cmpsd, 1, 0, 0
-AVX_INSTR cmpss, 1, 0, 0
-AVX_INSTR cvtdq2ps, 1, 0, 0
-AVX_INSTR cvtpd2dq, 1, 0, 0
-AVX_INSTR cvtps2dq, 1, 0, 0
-AVX_INSTR divpd, 1, 0, 0
-AVX_INSTR divps, 1, 0, 0
-AVX_INSTR divsd, 1, 0, 0
-AVX_INSTR divss, 1, 0, 0
-AVX_INSTR dppd, 1, 1, 0
-AVX_INSTR dpps, 1, 1, 0
-AVX_INSTR haddpd, 1, 0, 0
-AVX_INSTR haddps, 1, 0, 0
-AVX_INSTR hsubpd, 1, 0, 0
-AVX_INSTR hsubps, 1, 0, 0
-AVX_INSTR maxpd, 1, 0, 1
-AVX_INSTR maxps, 1, 0, 1
-AVX_INSTR maxsd, 1, 0, 1
-AVX_INSTR maxss, 1, 0, 1
-AVX_INSTR minpd, 1, 0, 1
-AVX_INSTR minps, 1, 0, 1
-AVX_INSTR minsd, 1, 0, 1
-AVX_INSTR minss, 1, 0, 1
-AVX_INSTR movhlps, 1, 0, 0
-AVX_INSTR movlhps, 1, 0, 0
-AVX_INSTR movsd, 1, 0, 0
-AVX_INSTR movss, 1, 0, 0
-AVX_INSTR mpsadbw, 0, 1, 0
-AVX_INSTR mulpd, 1, 0, 1
-AVX_INSTR mulps, 1, 0, 1
-AVX_INSTR mulsd, 1, 0, 1
-AVX_INSTR mulss, 1, 0, 1
-AVX_INSTR orpd, 1, 0, 1
-AVX_INSTR orps, 1, 0, 1
-AVX_INSTR pabsb, 0, 0, 0
-AVX_INSTR pabsw, 0, 0, 0
-AVX_INSTR pabsd, 0, 0, 0
-AVX_INSTR packsswb, 0, 0, 0
-AVX_INSTR packssdw, 0, 0, 0
-AVX_INSTR packuswb, 0, 0, 0
-AVX_INSTR packusdw, 0, 0, 0
-AVX_INSTR paddb, 0, 0, 1
-AVX_INSTR paddw, 0, 0, 1
-AVX_INSTR paddd, 0, 0, 1
-AVX_INSTR paddq, 0, 0, 1
-AVX_INSTR paddsb, 0, 0, 1
-AVX_INSTR paddsw, 0, 0, 1
-AVX_INSTR paddusb, 0, 0, 1
-AVX_INSTR paddusw, 0, 0, 1
-AVX_INSTR palignr, 0, 1, 0
-AVX_INSTR pand, 0, 0, 1
-AVX_INSTR pandn, 0, 0, 0
-AVX_INSTR pavgb, 0, 0, 1
-AVX_INSTR pavgw, 0, 0, 1
-AVX_INSTR pblendvb, 0, 0, 0
-AVX_INSTR pblendw, 0, 1, 0
-AVX_INSTR pcmpestri, 0, 0, 0
-AVX_INSTR pcmpestrm, 0, 0, 0
-AVX_INSTR pcmpistri, 0, 0, 0
-AVX_INSTR pcmpistrm, 0, 0, 0
-AVX_INSTR pcmpeqb, 0, 0, 1
-AVX_INSTR pcmpeqw, 0, 0, 1
-AVX_INSTR pcmpeqd, 0, 0, 1
-AVX_INSTR pcmpeqq, 0, 0, 1
-AVX_INSTR pcmpgtb, 0, 0, 0
-AVX_INSTR pcmpgtw, 0, 0, 0
-AVX_INSTR pcmpgtd, 0, 0, 0
-AVX_INSTR pcmpgtq, 0, 0, 0
-AVX_INSTR phaddw, 0, 0, 0
-AVX_INSTR phaddd, 0, 0, 0
-AVX_INSTR phaddsw, 0, 0, 0
-AVX_INSTR phsubw, 0, 0, 0
-AVX_INSTR phsubd, 0, 0, 0
-AVX_INSTR phsubsw, 0, 0, 0
-AVX_INSTR pmaddwd, 0, 0, 1
-AVX_INSTR pmaddubsw, 0, 0, 0
-AVX_INSTR pmaxsb, 0, 0, 1
-AVX_INSTR pmaxsw, 0, 0, 1
-AVX_INSTR pmaxsd, 0, 0, 1
-AVX_INSTR pmaxub, 0, 0, 1
-AVX_INSTR pmaxuw, 0, 0, 1
-AVX_INSTR pmaxud, 0, 0, 1
-AVX_INSTR pminsb, 0, 0, 1
-AVX_INSTR pminsw, 0, 0, 1
-AVX_INSTR pminsd, 0, 0, 1
-AVX_INSTR pminub, 0, 0, 1
-AVX_INSTR pminuw, 0, 0, 1
-AVX_INSTR pminud, 0, 0, 1
-AVX_INSTR pmovmskb, 0, 0, 0
-AVX_INSTR pmulhuw, 0, 0, 1
-AVX_INSTR pmulhrsw, 0, 0, 1
-AVX_INSTR pmulhw, 0, 0, 1
-AVX_INSTR pmullw, 0, 0, 1
-AVX_INSTR pmulld, 0, 0, 1
-AVX_INSTR pmuludq, 0, 0, 1
-AVX_INSTR pmuldq, 0, 0, 1
-AVX_INSTR por, 0, 0, 1
-AVX_INSTR psadbw, 0, 0, 1
-AVX_INSTR pshufb, 0, 0, 0
-AVX_INSTR pshufd, 0, 1, 0
-AVX_INSTR pshufhw, 0, 1, 0
-AVX_INSTR pshuflw, 0, 1, 0
-AVX_INSTR psignb, 0, 0, 0
-AVX_INSTR psignw, 0, 0, 0
-AVX_INSTR psignd, 0, 0, 0
-AVX_INSTR psllw, 0, 0, 0
-AVX_INSTR pslld, 0, 0, 0
-AVX_INSTR psllq, 0, 0, 0
-AVX_INSTR pslldq, 0, 0, 0
-AVX_INSTR psraw, 0, 0, 0
-AVX_INSTR psrad, 0, 0, 0
-AVX_INSTR psrlw, 0, 0, 0
-AVX_INSTR psrld, 0, 0, 0
-AVX_INSTR psrlq, 0, 0, 0
-AVX_INSTR psrldq, 0, 0, 0
-AVX_INSTR psubb, 0, 0, 0
-AVX_INSTR psubw, 0, 0, 0
-AVX_INSTR psubd, 0, 0, 0
-AVX_INSTR psubq, 0, 0, 0
-AVX_INSTR psubsb, 0, 0, 0
-AVX_INSTR psubsw, 0, 0, 0
-AVX_INSTR psubusb, 0, 0, 0
-AVX_INSTR psubusw, 0, 0, 0
-AVX_INSTR ptest, 0, 0, 0
-AVX_INSTR punpckhbw, 0, 0, 0
-AVX_INSTR punpckhwd, 0, 0, 0
-AVX_INSTR punpckhdq, 0, 0, 0
-AVX_INSTR punpckhqdq, 0, 0, 0
-AVX_INSTR punpcklbw, 0, 0, 0
-AVX_INSTR punpcklwd, 0, 0, 0
-AVX_INSTR punpckldq, 0, 0, 0
-AVX_INSTR punpcklqdq, 0, 0, 0
-AVX_INSTR pxor, 0, 0, 1
-AVX_INSTR shufps, 1, 1, 0
-AVX_INSTR subpd, 1, 0, 0
-AVX_INSTR subps, 1, 0, 0
-AVX_INSTR subsd, 1, 0, 0
-AVX_INSTR subss, 1, 0, 0
-AVX_INSTR unpckhpd, 1, 0, 0
-AVX_INSTR unpckhps, 1, 0, 0
-AVX_INSTR unpcklpd, 1, 0, 0
-AVX_INSTR unpcklps, 1, 0, 0
-AVX_INSTR xorpd, 1, 0, 1
-AVX_INSTR xorps, 1, 0, 1
-
-; 3DNow instructions, for sharing code between AVX, SSE and 3DN
-AVX_INSTR pfadd, 1, 0, 1
-AVX_INSTR pfsub, 1, 0, 0
-AVX_INSTR pfmul, 1, 0, 1
-
-; base-4 constants for shuffles
-%assign i 0
-%rep 256
- %assign j ((i>>6)&3)*1000 + ((i>>4)&3)*100 + ((i>>2)&3)*10 + (i&3)
- %if j < 10
- CAT_XDEFINE q000, j, i
- %elif j < 100
- CAT_XDEFINE q00, j, i
- %elif j < 1000
- CAT_XDEFINE q0, j, i
- %else
- CAT_XDEFINE q, j, i
- %endif
-%assign i i+1
-%endrep
-%undef i
-%undef j
-
-%macro FMA_INSTR 3
- %macro %1 5-8 %1, %2, %3
- %if cpuflag(xop) || cpuflag(fma4)
- v%6 %1, %2, %3, %4
- %else
- %ifidn %1, %4
- %7 %5, %2, %3
- %8 %1, %4, %5
- %else
- %7 %1, %2, %3
- %8 %1, %4
- %endif
- %endif
- %endmacro
-%endmacro
-
-FMA_INSTR fmaddps, mulps, addps
-FMA_INSTR pmacsdd, pmulld, paddd
-FMA_INSTR pmacsww, pmullw, paddw
-FMA_INSTR pmadcswd, pmaddwd, paddd
-
-; tzcnt is equivalent to "rep bsf" and is backwards-compatible with bsf.
-; This lets us use tzcnt without bumping the yasm version requirement yet.
-%define tzcnt rep bsf
diff --git a/src/thirdparty/ffmpeg/libavutil/x86/x86util.asm b/src/thirdparty/ffmpeg/libavutil/x86/x86util.asm
deleted file mode 100644
index 303a958fb..000000000
--- a/src/thirdparty/ffmpeg/libavutil/x86/x86util.asm
+++ /dev/null
@@ -1,667 +0,0 @@
-;*****************************************************************************
-;* x86util.asm
-;*****************************************************************************
-;* Copyright (C) 2008-2010 x264 project
-;*
-;* Authors: Loren Merritt <lorenm@u.washington.edu>
-;* Holger Lubitz <holger@lubitz.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
-;******************************************************************************
-
-%define private_prefix ff
-%define public_prefix avpriv
-%define cpuflags_mmxext cpuflags_mmx2
-
-%include "libavutil/x86/x86inc.asm"
-
-%macro SBUTTERFLY 4
-%if avx_enabled == 0
- mova m%4, m%2
- punpckl%1 m%2, m%3
- punpckh%1 m%4, m%3
-%else
- punpckh%1 m%4, m%2, m%3
- punpckl%1 m%2, m%3
-%endif
- SWAP %3, %4
-%endmacro
-
-%macro SBUTTERFLY2 4
- punpckl%1 m%4, m%2, m%3
- punpckh%1 m%2, m%2, m%3
- SWAP %2, %4, %3
-%endmacro
-
-%macro SBUTTERFLYPS 3
- unpcklps m%3, m%1, m%2
- unpckhps m%1, m%1, m%2
- SWAP %1, %3, %2
-%endmacro
-
-%macro TRANSPOSE4x4B 5
- SBUTTERFLY bw, %1, %2, %5
- SBUTTERFLY bw, %3, %4, %5
- SBUTTERFLY wd, %1, %3, %5
- SBUTTERFLY wd, %2, %4, %5
- SWAP %2, %3
-%endmacro
-
-%macro TRANSPOSE4x4W 5
- SBUTTERFLY wd, %1, %2, %5
- SBUTTERFLY wd, %3, %4, %5
- SBUTTERFLY dq, %1, %3, %5
- SBUTTERFLY dq, %2, %4, %5
- SWAP %2, %3
-%endmacro
-
-%macro TRANSPOSE2x4x4W 5
- SBUTTERFLY wd, %1, %2, %5
- SBUTTERFLY wd, %3, %4, %5
- SBUTTERFLY dq, %1, %3, %5
- SBUTTERFLY dq, %2, %4, %5
- SBUTTERFLY qdq, %1, %2, %5
- SBUTTERFLY qdq, %3, %4, %5
-%endmacro
-
-%macro TRANSPOSE4x4D 5
- SBUTTERFLY dq, %1, %2, %5
- SBUTTERFLY dq, %3, %4, %5
- SBUTTERFLY qdq, %1, %3, %5
- SBUTTERFLY qdq, %2, %4, %5
- SWAP %2, %3
-%endmacro
-
-; identical behavior to TRANSPOSE4x4D, but using SSE1 float ops
-%macro TRANSPOSE4x4PS 5
- SBUTTERFLYPS %1, %2, %5
- SBUTTERFLYPS %3, %4, %5
- movlhps m%5, m%1, m%3
- movhlps m%3, m%1
- SWAP %5, %1
- movlhps m%5, m%2, m%4
- movhlps m%4, m%2
- SWAP %5, %2, %3
-%endmacro
-
-%macro TRANSPOSE8x8W 9-11
-%if ARCH_X86_64
- SBUTTERFLY wd, %1, %2, %9
- SBUTTERFLY wd, %3, %4, %9
- SBUTTERFLY wd, %5, %6, %9
- SBUTTERFLY wd, %7, %8, %9
- SBUTTERFLY dq, %1, %3, %9
- SBUTTERFLY dq, %2, %4, %9
- SBUTTERFLY dq, %5, %7, %9
- SBUTTERFLY dq, %6, %8, %9
- SBUTTERFLY qdq, %1, %5, %9
- SBUTTERFLY qdq, %2, %6, %9
- SBUTTERFLY qdq, %3, %7, %9
- SBUTTERFLY qdq, %4, %8, %9
- SWAP %2, %5
- SWAP %4, %7
-%else
-; in: m0..m7, unless %11 in which case m6 is in %9
-; out: m0..m7, unless %11 in which case m4 is in %10
-; spills into %9 and %10
-%if %0<11
- movdqa %9, m%7
-%endif
- SBUTTERFLY wd, %1, %2, %7
- movdqa %10, m%2
- movdqa m%7, %9
- SBUTTERFLY wd, %3, %4, %2
- SBUTTERFLY wd, %5, %6, %2
- SBUTTERFLY wd, %7, %8, %2
- SBUTTERFLY dq, %1, %3, %2
- movdqa %9, m%3
- movdqa m%2, %10
- SBUTTERFLY dq, %2, %4, %3
- SBUTTERFLY dq, %5, %7, %3
- SBUTTERFLY dq, %6, %8, %3
- SBUTTERFLY qdq, %1, %5, %3
- SBUTTERFLY qdq, %2, %6, %3
- movdqa %10, m%2
- movdqa m%3, %9
- SBUTTERFLY qdq, %3, %7, %2
- SBUTTERFLY qdq, %4, %8, %2
- SWAP %2, %5
- SWAP %4, %7
-%if %0<11
- movdqa m%5, %10
-%endif
-%endif
-%endmacro
-
-; PABSW macro assumes %1 != %2, while ABS1/2 macros work in-place
-%macro PABSW 2
-%if cpuflag(ssse3)
- pabsw %1, %2
-%elif cpuflag(mmxext)
- pxor %1, %1
- psubw %1, %2
- pmaxsw %1, %2
-%else
- pxor %1, %1
- pcmpgtw %1, %2
- pxor %2, %1
- psubw %2, %1
- SWAP %1, %2
-%endif
-%endmacro
-
-%macro PSIGNW_MMX 2
- pxor %1, %2
- psubw %1, %2
-%endmacro
-
-%macro PSIGNW_SSSE3 2
- psignw %1, %2
-%endmacro
-
-%macro ABS1 2
-%if cpuflag(ssse3)
- pabsw %1, %1
-%elif cpuflag(mmxext) ; a, tmp
- pxor %2, %2
- psubw %2, %1
- pmaxsw %1, %2
-%else ; a, tmp
- pxor %2, %2
- pcmpgtw %2, %1
- pxor %1, %2
- psubw %1, %2
-%endif
-%endmacro
-
-%macro ABS2 4
-%if cpuflag(ssse3)
- pabsw %1, %1
- pabsw %2, %2
-%elif cpuflag(mmxext) ; a, b, tmp0, tmp1
- pxor %3, %3
- pxor %4, %4
- psubw %3, %1
- psubw %4, %2
- pmaxsw %1, %3
- pmaxsw %2, %4
-%else ; a, b, tmp0, tmp1
- pxor %3, %3
- pxor %4, %4
- pcmpgtw %3, %1
- pcmpgtw %4, %2
- pxor %1, %3
- pxor %2, %4
- psubw %1, %3
- psubw %2, %4
-%endif
-%endmacro
-
-%macro ABSB 2 ; source mmreg, temp mmreg (unused for ssse3)
-%if cpuflag(ssse3)
- pabsb %1, %1
-%else
- pxor %2, %2
- psubb %2, %1
- pminub %1, %2
-%endif
-%endmacro
-
-%macro ABSB2 4 ; src1, src2, tmp1, tmp2 (tmp1/2 unused for SSSE3)
-%if cpuflag(ssse3)
- pabsb %1, %1
- pabsb %2, %2
-%else
- pxor %3, %3
- pxor %4, %4
- psubb %3, %1
- psubb %4, %2
- pminub %1, %3
- pminub %2, %4
-%endif
-%endmacro
-
-%macro ABSD2_MMX 4
- pxor %3, %3
- pxor %4, %4
- pcmpgtd %3, %1
- pcmpgtd %4, %2
- pxor %1, %3
- pxor %2, %4
- psubd %1, %3
- psubd %2, %4
-%endmacro
-
-%macro ABS4 6
- ABS2 %1, %2, %5, %6
- ABS2 %3, %4, %5, %6
-%endmacro
-
-%macro SPLATB_LOAD 3
-%if cpuflag(ssse3)
- movd %1, [%2-3]
- pshufb %1, %3
-%else
- movd %1, [%2-3] ;to avoid crossing a cacheline
- punpcklbw %1, %1
- SPLATW %1, %1, 3
-%endif
-%endmacro
-
-%macro SPLATB_REG 3
-%if cpuflag(ssse3)
- movd %1, %2d
- pshufb %1, %3
-%else
- movd %1, %2d
- punpcklbw %1, %1
- SPLATW %1, %1, 0
-%endif
-%endmacro
-
-%macro PALIGNR 4-5
-%if cpuflag(ssse3)
-%if %0==5
- palignr %1, %2, %3, %4
-%else
- palignr %1, %2, %3
-%endif
-%elif cpuflag(mmx) ; [dst,] src1, src2, imm, tmp
- %define %%dst %1
-%if %0==5
-%ifnidn %1, %2
- mova %%dst, %2
-%endif
- %rotate 1
-%endif
-%ifnidn %4, %2
- mova %4, %2
-%endif
-%if mmsize==8
- psllq %%dst, (8-%3)*8
- psrlq %4, %3*8
-%else
- pslldq %%dst, 16-%3
- psrldq %4, %3
-%endif
- por %%dst, %4
-%endif
-%endmacro
-
-%macro PAVGB 2
-%if cpuflag(mmxext)
- pavgb %1, %2
-%elif cpuflag(3dnow)
- pavgusb %1, %2
-%endif
-%endmacro
-
-%macro PSHUFLW 1+
- %if mmsize == 8
- pshufw %1
- %else
- pshuflw %1
- %endif
-%endmacro
-
-%macro PSWAPD 2
-%if cpuflag(mmxext)
- pshufw %1, %2, q1032
-%elif cpuflag(3dnowext)
- pswapd %1, %2
-%elif cpuflag(3dnow)
- movq %1, %2
- psrlq %1, 32
- punpckldq %1, %2
-%endif
-%endmacro
-
-%macro DEINTB 5 ; mask, reg1, mask, reg2, optional src to fill masks from
-%ifnum %5
- pand m%3, m%5, m%4 ; src .. y6 .. y4
- pand m%1, m%5, m%2 ; dst .. y6 .. y4
-%else
- mova m%1, %5
- pand m%3, m%1, m%4 ; src .. y6 .. y4
- pand m%1, m%1, m%2 ; dst .. y6 .. y4
-%endif
- psrlw m%2, 8 ; dst .. y7 .. y5
- psrlw m%4, 8 ; src .. y7 .. y5
-%endmacro
-
-%macro SUMSUB_BA 3-4
-%if %0==3
- padd%1 m%2, m%3
- padd%1 m%3, m%3
- psub%1 m%3, m%2
-%else
-%if avx_enabled == 0
- mova m%4, m%2
- padd%1 m%2, m%3
- psub%1 m%3, m%4
-%else
- padd%1 m%4, m%2, m%3
- psub%1 m%3, m%2
- SWAP %2, %4
-%endif
-%endif
-%endmacro
-
-%macro SUMSUB_BADC 5-6
-%if %0==6
- SUMSUB_BA %1, %2, %3, %6
- SUMSUB_BA %1, %4, %5, %6
-%else
- padd%1 m%2, m%3
- padd%1 m%4, m%5
- padd%1 m%3, m%3
- padd%1 m%5, m%5
- psub%1 m%3, m%2
- psub%1 m%5, m%4
-%endif
-%endmacro
-
-%macro SUMSUB2_AB 4
-%ifnum %3
- psub%1 m%4, m%2, m%3
- psub%1 m%4, m%3
- padd%1 m%2, m%2
- padd%1 m%2, m%3
-%else
- mova m%4, m%2
- padd%1 m%2, m%2
- padd%1 m%2, %3
- psub%1 m%4, %3
- psub%1 m%4, %3
-%endif
-%endmacro
-
-%macro SUMSUB2_BA 4
-%if avx_enabled == 0
- mova m%4, m%2
- padd%1 m%2, m%3
- padd%1 m%2, m%3
- psub%1 m%3, m%4
- psub%1 m%3, m%4
-%else
- padd%1 m%4, m%2, m%3
- padd%1 m%4, m%3
- psub%1 m%3, m%2
- psub%1 m%3, m%2
- SWAP %2, %4
-%endif
-%endmacro
-
-%macro SUMSUBD2_AB 5
-%ifnum %4
- psra%1 m%5, m%2, 1 ; %3: %3>>1
- psra%1 m%4, m%3, 1 ; %2: %2>>1
- padd%1 m%4, m%2 ; %3: %3>>1+%2
- psub%1 m%5, m%3 ; %2: %2>>1-%3
- SWAP %2, %5
- SWAP %3, %4
-%else
- mova %5, m%2
- mova %4, m%3
- psra%1 m%3, 1 ; %3: %3>>1
- psra%1 m%2, 1 ; %2: %2>>1
- padd%1 m%3, %5 ; %3: %3>>1+%2
- psub%1 m%2, %4 ; %2: %2>>1-%3
-%endif
-%endmacro
-
-%macro DCT4_1D 5
-%ifnum %5
- SUMSUB_BADC w, %4, %1, %3, %2, %5
- SUMSUB_BA w, %3, %4, %5
- SUMSUB2_AB w, %1, %2, %5
- SWAP %1, %3, %4, %5, %2
-%else
- SUMSUB_BADC w, %4, %1, %3, %2
- SUMSUB_BA w, %3, %4
- mova [%5], m%2
- SUMSUB2_AB w, %1, [%5], %2
- SWAP %1, %3, %4, %2
-%endif
-%endmacro
-
-%macro IDCT4_1D 6-7
-%ifnum %6
- SUMSUBD2_AB %1, %3, %5, %7, %6
- ; %3: %3>>1-%5 %5: %3+%5>>1
- SUMSUB_BA %1, %4, %2, %7
- ; %4: %2+%4 %2: %2-%4
- SUMSUB_BADC %1, %5, %4, %3, %2, %7
- ; %5: %2+%4 + (%3+%5>>1)
- ; %4: %2+%4 - (%3+%5>>1)
- ; %3: %2-%4 + (%3>>1-%5)
- ; %2: %2-%4 - (%3>>1-%5)
-%else
-%ifidn %1, w
- SUMSUBD2_AB %1, %3, %5, [%6], [%6+16]
-%else
- SUMSUBD2_AB %1, %3, %5, [%6], [%6+32]
-%endif
- SUMSUB_BA %1, %4, %2
- SUMSUB_BADC %1, %5, %4, %3, %2
-%endif
- SWAP %2, %5, %4
- ; %2: %2+%4 + (%3+%5>>1) row0
- ; %3: %2-%4 + (%3>>1-%5) row1
- ; %4: %2-%4 - (%3>>1-%5) row2
- ; %5: %2+%4 - (%3+%5>>1) row3
-%endmacro
-
-
-%macro LOAD_DIFF 5
-%ifidn %3, none
- movh %1, %4
- movh %2, %5
- punpcklbw %1, %2
- punpcklbw %2, %2
- psubw %1, %2
-%else
- movh %1, %4
- punpcklbw %1, %3
- movh %2, %5
- punpcklbw %2, %3
- psubw %1, %2
-%endif
-%endmacro
-
-%macro STORE_DCT 6
- movq [%5+%6+ 0], m%1
- movq [%5+%6+ 8], m%2
- movq [%5+%6+16], m%3
- movq [%5+%6+24], m%4
- movhps [%5+%6+32], m%1
- movhps [%5+%6+40], m%2
- movhps [%5+%6+48], m%3
- movhps [%5+%6+56], m%4
-%endmacro
-
-%macro LOAD_DIFF_8x4P 7-10 r0,r2,0 ; 4x dest, 2x temp, 2x pointer, increment?
- LOAD_DIFF m%1, m%5, m%7, [%8], [%9]
- LOAD_DIFF m%2, m%6, m%7, [%8+r1], [%9+r3]
- LOAD_DIFF m%3, m%5, m%7, [%8+2*r1], [%9+2*r3]
- LOAD_DIFF m%4, m%6, m%7, [%8+r4], [%9+r5]
-%if %10
- lea %8, [%8+4*r1]
- lea %9, [%9+4*r3]
-%endif
-%endmacro
-
-%macro DIFFx2 6-7
- movh %3, %5
- punpcklbw %3, %4
- psraw %1, 6
- paddsw %1, %3
- movh %3, %6
- punpcklbw %3, %4
- psraw %2, 6
- paddsw %2, %3
- packuswb %2, %1
-%endmacro
-
-%macro STORE_DIFF 4
- movh %2, %4
- punpcklbw %2, %3
- psraw %1, 6
- paddsw %1, %2
- packuswb %1, %1
- movh %4, %1
-%endmacro
-
-%macro STORE_DIFFx2 8 ; add1, add2, reg1, reg2, zero, shift, source, stride
- movh %3, [%7]
- movh %4, [%7+%8]
- psraw %1, %6
- psraw %2, %6
- punpcklbw %3, %5
- punpcklbw %4, %5
- paddw %3, %1
- paddw %4, %2
- packuswb %3, %5
- packuswb %4, %5
- movh [%7], %3
- movh [%7+%8], %4
-%endmacro
-
-%macro PMINUB 3 ; dst, src, ignored
-%if cpuflag(mmxext)
- pminub %1, %2
-%else ; dst, src, tmp
- mova %3, %1
- psubusb %3, %2
- psubb %1, %3
-%endif
-%endmacro
-
-%macro SPLATW 2-3 0
-%if mmsize == 16
- pshuflw %1, %2, (%3)*0x55
- punpcklqdq %1, %1
-%elif cpuflag(mmxext)
- pshufw %1, %2, (%3)*0x55
-%else
- %ifnidn %1, %2
- mova %1, %2
- %endif
- %if %3 & 2
- punpckhwd %1, %1
- %else
- punpcklwd %1, %1
- %endif
- %if %3 & 1
- punpckhwd %1, %1
- %else
- punpcklwd %1, %1
- %endif
-%endif
-%endmacro
-
-%macro SPLATD 1
-%if mmsize == 8
- punpckldq %1, %1
-%elif cpuflag(sse2)
- pshufd %1, %1, 0
-%elif cpuflag(sse)
- shufps %1, %1, 0
-%endif
-%endmacro
-
-%macro CLIPW 3 ;(dst, min, max)
- pmaxsw %1, %2
- pminsw %1, %3
-%endmacro
-
-%macro PMINSD_MMX 3 ; dst, src, tmp
- mova %3, %2
- pcmpgtd %3, %1
- pxor %1, %2
- pand %1, %3
- pxor %1, %2
-%endmacro
-
-%macro PMAXSD_MMX 3 ; dst, src, tmp
- mova %3, %1
- pcmpgtd %3, %2
- pand %1, %3
- pandn %3, %2
- por %1, %3
-%endmacro
-
-%macro CLIPD_MMX 3-4 ; src/dst, min, max, tmp
- PMINSD_MMX %1, %3, %4
- PMAXSD_MMX %1, %2, %4
-%endmacro
-
-%macro CLIPD_SSE2 3-4 ; src/dst, min (float), max (float), unused
- cvtdq2ps %1, %1
- minps %1, %3
- maxps %1, %2
- cvtps2dq %1, %1
-%endmacro
-
-%macro CLIPD_SSE41 3-4 ; src/dst, min, max, unused
- pminsd %1, %3
- pmaxsd %1, %2
-%endmacro
-
-%macro VBROADCASTSS 2 ; dst xmm/ymm, src m32
-%if cpuflag(avx)
- vbroadcastss %1, %2
-%else ; sse
- movss %1, %2
- shufps %1, %1, 0
-%endif
-%endmacro
-
-%macro VBROADCASTSD 2 ; dst xmm/ymm, src m64
-%if cpuflag(avx) && mmsize == 32
- vbroadcastsd %1, %2
-%elif cpuflag(sse3)
- movddup %1, %2
-%else ; sse2
- movsd %1, %2
- movlhps %1, %1
-%endif
-%endmacro
-
-%macro SHUFFLE_MASK_W 8
- %rep 8
- %if %1>=0x80
- db %1, %1
- %else
- db %1*2
- db %1*2+1
- %endif
- %rotate 1
- %endrep
-%endmacro
-
-%macro PMOVSXWD 2; dst, src
-%if cpuflag(sse4)
- pmovsxwd %1, %2
-%else
- %ifnidn %1, %2
- mova %1, %2
- %endif
- punpcklwd %1, %1
- psrad %1, 16
-%endif
-%endmacro
diff --git a/src/thirdparty/ffmpeg/libavutil/x86_cpu.h b/src/thirdparty/ffmpeg/libavutil/x86_cpu.h
deleted file mode 100644
index bec1c7777..000000000
--- a/src/thirdparty/ffmpeg/libavutil/x86_cpu.h
+++ /dev/null
@@ -1 +0,0 @@
-#include "libavutil/x86/asm.h"
diff --git a/src/thirdparty/ffmpeg/libswscale/input.c b/src/thirdparty/ffmpeg/libswscale/input.c
deleted file mode 100644
index 7fb72d784..000000000
--- a/src/thirdparty/ffmpeg/libswscale/input.c
+++ /dev/null
@@ -1,1354 +0,0 @@
-/*
- * Copyright (C) 2001-2012 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
- */
-
-#include <assert.h>
-#include <math.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "libavutil/avutil.h"
-#include "libavutil/bswap.h"
-#include "libavutil/cpu.h"
-#include "libavutil/intreadwrite.h"
-#include "libavutil/mathematics.h"
-#include "libavutil/pixdesc.h"
-#include "libavutil/avassert.h"
-#include "config.h"
-#include "rgb2rgb.h"
-#include "swscale.h"
-#include "swscale_internal.h"
-
-#define RGB2YUV_SHIFT 15
-#define BY ((int)(0.114 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
-#define BV (-(int)(0.081 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
-#define BU ((int)(0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
-#define GY ((int)(0.587 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
-#define GV (-(int)(0.419 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
-#define GU (-(int)(0.331 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
-#define RY ((int)(0.299 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
-#define RV ((int)(0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
-#define RU (-(int)(0.169 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
-
-#define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos))
-
-#define r ((origin == AV_PIX_FMT_BGR48BE || origin == AV_PIX_FMT_BGR48LE) ? b_r : r_b)
-#define b ((origin == AV_PIX_FMT_BGR48BE || origin == AV_PIX_FMT_BGR48LE) ? r_b : b_r)
-
-static av_always_inline void
-rgb64ToY_c_template(uint16_t *dst, const uint16_t *src, int width,
- enum AVPixelFormat origin)
-{
- int i;
- for (i = 0; i < width; i++) {
- unsigned int r_b = input_pixel(&src[i*4+0]);
- unsigned int g = input_pixel(&src[i*4+1]);
- unsigned int b_r = input_pixel(&src[i*4+2]);
-
- dst[i] = (RY*r + GY*g + BY*b + (0x2001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
- }
-}
-
-static av_always_inline void
-rgb64ToUV_c_template(uint16_t *dstU, uint16_t *dstV,
- const uint16_t *src1, const uint16_t *src2,
- int width, enum AVPixelFormat origin)
-{
- int i;
- av_assert1(src1==src2);
- for (i = 0; i < width; i++) {
- int r_b = input_pixel(&src1[i*4+0]);
- int g = input_pixel(&src1[i*4+1]);
- int b_r = input_pixel(&src1[i*4+2]);
-
- dstU[i] = (RU*r + GU*g + BU*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
- dstV[i] = (RV*r + GV*g + BV*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
- }
-}
-
-static av_always_inline void
-rgb64ToUV_half_c_template(uint16_t *dstU, uint16_t *dstV,
- const uint16_t *src1, const uint16_t *src2,
- int width, enum AVPixelFormat origin)
-{
- int i;
- av_assert1(src1==src2);
- for (i = 0; i < width; i++) {
- int r_b = (input_pixel(&src1[8 * i + 0]) + input_pixel(&src1[8 * i + 4]) + 1) >> 1;
- int g = (input_pixel(&src1[8 * i + 1]) + input_pixel(&src1[8 * i + 5]) + 1) >> 1;
- int b_r = (input_pixel(&src1[8 * i + 2]) + input_pixel(&src1[8 * i + 6]) + 1) >> 1;
-
- dstU[i]= (RU*r + GU*g + BU*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
- dstV[i]= (RV*r + GV*g + BV*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
- }
-}
-
-#define rgb64funcs(pattern, BE_LE, origin) \
-static void pattern ## 64 ## BE_LE ## ToY_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused0, const uint8_t *unused1,\
- int width, uint32_t *unused) \
-{ \
- const uint16_t *src = (const uint16_t *) _src; \
- uint16_t *dst = (uint16_t *) _dst; \
- rgb64ToY_c_template(dst, src, width, origin); \
-} \
- \
-static void pattern ## 64 ## BE_LE ## ToUV_c(uint8_t *_dstU, uint8_t *_dstV, \
- const uint8_t *unused0, const uint8_t *_src1, const uint8_t *_src2, \
- int width, uint32_t *unused) \
-{ \
- const uint16_t *src1 = (const uint16_t *) _src1, \
- *src2 = (const uint16_t *) _src2; \
- uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \
- rgb64ToUV_c_template(dstU, dstV, src1, src2, width, origin); \
-} \
- \
-static void pattern ## 64 ## BE_LE ## ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, \
- const uint8_t *unused0, const uint8_t *_src1, const uint8_t *_src2, \
- int width, uint32_t *unused) \
-{ \
- const uint16_t *src1 = (const uint16_t *) _src1, \
- *src2 = (const uint16_t *) _src2; \
- uint16_t *dstU = (uint16_t *) _dstU, *dstV = (uint16_t *) _dstV; \
- rgb64ToUV_half_c_template(dstU, dstV, src1, src2, width, origin); \
-}
-
-rgb64funcs(rgb, LE, AV_PIX_FMT_RGBA64LE)
-rgb64funcs(rgb, BE, AV_PIX_FMT_RGBA64BE)
-
-static av_always_inline void rgb48ToY_c_template(uint16_t *dst,
- const uint16_t *src, int width,
- enum AVPixelFormat origin)
-{
- int i;
- for (i = 0; i < width; i++) {
- unsigned int r_b = input_pixel(&src[i * 3 + 0]);
- unsigned int g = input_pixel(&src[i * 3 + 1]);
- unsigned int b_r = input_pixel(&src[i * 3 + 2]);
-
- dst[i] = (RY * r + GY * g + BY * b + (0x2001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
- }
-}
-
-static av_always_inline void rgb48ToUV_c_template(uint16_t *dstU,
- uint16_t *dstV,
- const uint16_t *src1,
- const uint16_t *src2,
- int width,
- enum AVPixelFormat origin)
-{
- int i;
- av_assert1(src1 == src2);
- for (i = 0; i < width; i++) {
- int r_b = input_pixel(&src1[i * 3 + 0]);
- int g = input_pixel(&src1[i * 3 + 1]);
- int b_r = input_pixel(&src1[i * 3 + 2]);
-
- dstU[i] = (RU * r + GU * g + BU * b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
- dstV[i] = (RV * r + GV * g + BV * b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
- }
-}
-
-static av_always_inline void rgb48ToUV_half_c_template(uint16_t *dstU,
- uint16_t *dstV,
- const uint16_t *src1,
- const uint16_t *src2,
- int width,
- enum AVPixelFormat origin)
-{
- int i;
- av_assert1(src1 == src2);
- for (i = 0; i < width; i++) {
- int r_b = (input_pixel(&src1[6 * i + 0]) +
- input_pixel(&src1[6 * i + 3]) + 1) >> 1;
- int g = (input_pixel(&src1[6 * i + 1]) +
- input_pixel(&src1[6 * i + 4]) + 1) >> 1;
- int b_r = (input_pixel(&src1[6 * i + 2]) +
- input_pixel(&src1[6 * i + 5]) + 1) >> 1;
-
- dstU[i] = (RU * r + GU * g + BU * b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
- dstV[i] = (RV * r + GV * g + BV * b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
- }
-}
-
-#undef r
-#undef b
-#undef input_pixel
-
-#define rgb48funcs(pattern, BE_LE, origin) \
-static void pattern ## 48 ## BE_LE ## ToY_c(uint8_t *_dst, \
- const uint8_t *_src, \
- const uint8_t *unused0, const uint8_t *unused1,\
- int width, \
- uint32_t *unused) \
-{ \
- const uint16_t *src = (const uint16_t *)_src; \
- uint16_t *dst = (uint16_t *)_dst; \
- rgb48ToY_c_template(dst, src, width, origin); \
-} \
- \
-static void pattern ## 48 ## BE_LE ## ToUV_c(uint8_t *_dstU, \
- uint8_t *_dstV, \
- const uint8_t *unused0, \
- const uint8_t *_src1, \
- const uint8_t *_src2, \
- int width, \
- uint32_t *unused) \
-{ \
- const uint16_t *src1 = (const uint16_t *)_src1, \
- *src2 = (const uint16_t *)_src2; \
- uint16_t *dstU = (uint16_t *)_dstU, \
- *dstV = (uint16_t *)_dstV; \
- rgb48ToUV_c_template(dstU, dstV, src1, src2, width, origin); \
-} \
- \
-static void pattern ## 48 ## BE_LE ## ToUV_half_c(uint8_t *_dstU, \
- uint8_t *_dstV, \
- const uint8_t *unused0, \
- const uint8_t *_src1, \
- const uint8_t *_src2, \
- int width, \
- uint32_t *unused) \
-{ \
- const uint16_t *src1 = (const uint16_t *)_src1, \
- *src2 = (const uint16_t *)_src2; \
- uint16_t *dstU = (uint16_t *)_dstU, \
- *dstV = (uint16_t *)_dstV; \
- rgb48ToUV_half_c_template(dstU, dstV, src1, src2, width, origin); \
-}
-
-rgb48funcs(rgb, LE, AV_PIX_FMT_RGB48LE)
-rgb48funcs(rgb, BE, AV_PIX_FMT_RGB48BE)
-rgb48funcs(bgr, LE, AV_PIX_FMT_BGR48LE)
-rgb48funcs(bgr, BE, AV_PIX_FMT_BGR48BE)
-
-#define input_pixel(i) ((origin == AV_PIX_FMT_RGBA || \
- origin == AV_PIX_FMT_BGRA || \
- origin == AV_PIX_FMT_ARGB || \
- origin == AV_PIX_FMT_ABGR) \
- ? AV_RN32A(&src[(i) * 4]) \
- : (isBE(origin) ? AV_RB16(&src[(i) * 2]) \
- : AV_RL16(&src[(i) * 2])))
-
-static av_always_inline void rgb16_32ToY_c_template(int16_t *dst,
- const uint8_t *src,
- int width,
- enum AVPixelFormat origin,
- int shr, int shg,
- int shb, int shp,
- int maskr, int maskg,
- int maskb, int rsh,
- int gsh, int bsh, int S)
-{
- const int ry = RY << rsh, gy = GY << gsh, by = BY << bsh;
- const unsigned rnd = (32<<((S)-1)) + (1<<(S-7));
- int i;
-
- for (i = 0; i < width; i++) {
- int px = input_pixel(i) >> shp;
- int b = (px & maskb) >> shb;
- int g = (px & maskg) >> shg;
- int r = (px & maskr) >> shr;
-
- dst[i] = (ry * r + gy * g + by * b + rnd) >> ((S)-6);
- }
-}
-
-static av_always_inline void rgb16_32ToUV_c_template(int16_t *dstU,
- int16_t *dstV,
- const uint8_t *src,
- int width,
- enum AVPixelFormat origin,
- int shr, int shg,
- int shb, int shp,
- int maskr, int maskg,
- int maskb, int rsh,
- int gsh, int bsh, int S)
-{
- const int ru = RU << rsh, gu = GU << gsh, bu = BU << bsh,
- rv = RV << rsh, gv = GV << gsh, bv = BV << bsh;
- const unsigned rnd = (256u<<((S)-1)) + (1<<(S-7));
- int i;
-
- for (i = 0; i < width; i++) {
- int px = input_pixel(i) >> shp;
- int b = (px & maskb) >> shb;
- int g = (px & maskg) >> shg;
- int r = (px & maskr) >> shr;
-
- dstU[i] = (ru * r + gu * g + bu * b + rnd) >> ((S)-6);
- dstV[i] = (rv * r + gv * g + bv * b + rnd) >> ((S)-6);
- }
-}
-
-static av_always_inline void rgb16_32ToUV_half_c_template(int16_t *dstU,
- int16_t *dstV,
- const uint8_t *src,
- int width,
- enum AVPixelFormat origin,
- int shr, int shg,
- int shb, int shp,
- int maskr, int maskg,
- int maskb, int rsh,
- int gsh, int bsh, int S)
-{
- const int ru = RU << rsh, gu = GU << gsh, bu = BU << bsh,
- rv = RV << rsh, gv = GV << gsh, bv = BV << bsh,
- maskgx = ~(maskr | maskb);
- const unsigned rnd = (256U<<(S)) + (1<<(S-6));
- int i;
-
- maskr |= maskr << 1;
- maskb |= maskb << 1;
- maskg |= maskg << 1;
- for (i = 0; i < width; i++) {
- int px0 = input_pixel(2 * i + 0) >> shp;
- int px1 = input_pixel(2 * i + 1) >> shp;
- int b, r, g = (px0 & maskgx) + (px1 & maskgx);
- int rb = px0 + px1 - g;
-
- b = (rb & maskb) >> shb;
- if (shp ||
- origin == AV_PIX_FMT_BGR565LE || origin == AV_PIX_FMT_BGR565BE ||
- origin == AV_PIX_FMT_RGB565LE || origin == AV_PIX_FMT_RGB565BE) {
- g >>= shg;
- } else {
- g = (g & maskg) >> shg;
- }
- r = (rb & maskr) >> shr;
-
- dstU[i] = (ru * r + gu * g + bu * b + (unsigned)rnd) >> ((S)-6+1);
- dstV[i] = (rv * r + gv * g + bv * b + (unsigned)rnd) >> ((S)-6+1);
- }
-}
-
-#undef input_pixel
-
-#define rgb16_32_wrapper(fmt, name, shr, shg, shb, shp, maskr, \
- maskg, maskb, rsh, gsh, bsh, S) \
-static void name ## ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, \
- int width, uint32_t *unused) \
-{ \
- rgb16_32ToY_c_template((int16_t*)dst, src, width, fmt, shr, shg, shb, shp, \
- maskr, maskg, maskb, rsh, gsh, bsh, S); \
-} \
- \
-static void name ## ToUV_c(uint8_t *dstU, uint8_t *dstV, \
- const uint8_t *unused0, const uint8_t *src, const uint8_t *dummy, \
- int width, uint32_t *unused) \
-{ \
- rgb16_32ToUV_c_template((int16_t*)dstU, (int16_t*)dstV, src, width, fmt, \
- shr, shg, shb, shp, \
- maskr, maskg, maskb, rsh, gsh, bsh, S); \
-} \
- \
-static void name ## ToUV_half_c(uint8_t *dstU, uint8_t *dstV, \
- const uint8_t *unused0, const uint8_t *src, \
- const uint8_t *dummy, \
- int width, uint32_t *unused) \
-{ \
- rgb16_32ToUV_half_c_template((int16_t*)dstU, (int16_t*)dstV, src, width, fmt, \
- shr, shg, shb, shp, \
- maskr, maskg, maskb, \
- rsh, gsh, bsh, S); \
-}
-
-rgb16_32_wrapper(AV_PIX_FMT_BGR32, bgr32, 16, 0, 0, 0, 0xFF0000, 0xFF00, 0x00FF, 8, 0, 8, RGB2YUV_SHIFT + 8)
-rgb16_32_wrapper(AV_PIX_FMT_BGR32_1, bgr321, 16, 0, 0, 8, 0xFF0000, 0xFF00, 0x00FF, 8, 0, 8, RGB2YUV_SHIFT + 8)
-rgb16_32_wrapper(AV_PIX_FMT_RGB32, rgb32, 0, 0, 16, 0, 0x00FF, 0xFF00, 0xFF0000, 8, 0, 8, RGB2YUV_SHIFT + 8)
-rgb16_32_wrapper(AV_PIX_FMT_RGB32_1, rgb321, 0, 0, 16, 8, 0x00FF, 0xFF00, 0xFF0000, 8, 0, 8, RGB2YUV_SHIFT + 8)
-rgb16_32_wrapper(AV_PIX_FMT_BGR565LE, bgr16le, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, 11, 5, 0, RGB2YUV_SHIFT + 8)
-rgb16_32_wrapper(AV_PIX_FMT_BGR555LE, bgr15le, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, 10, 5, 0, RGB2YUV_SHIFT + 7)
-rgb16_32_wrapper(AV_PIX_FMT_BGR444LE, bgr12le, 0, 0, 0, 0, 0x000F, 0x00F0, 0x0F00, 8, 4, 0, RGB2YUV_SHIFT + 4)
-rgb16_32_wrapper(AV_PIX_FMT_RGB565LE, rgb16le, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11, RGB2YUV_SHIFT + 8)
-rgb16_32_wrapper(AV_PIX_FMT_RGB555LE, rgb15le, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10, RGB2YUV_SHIFT + 7)
-rgb16_32_wrapper(AV_PIX_FMT_RGB444LE, rgb12le, 0, 0, 0, 0, 0x0F00, 0x00F0, 0x000F, 0, 4, 8, RGB2YUV_SHIFT + 4)
-rgb16_32_wrapper(AV_PIX_FMT_BGR565BE, bgr16be, 0, 0, 0, 0, 0x001F, 0x07E0, 0xF800, 11, 5, 0, RGB2YUV_SHIFT + 8)
-rgb16_32_wrapper(AV_PIX_FMT_BGR555BE, bgr15be, 0, 0, 0, 0, 0x001F, 0x03E0, 0x7C00, 10, 5, 0, RGB2YUV_SHIFT + 7)
-rgb16_32_wrapper(AV_PIX_FMT_BGR444BE, bgr12be, 0, 0, 0, 0, 0x000F, 0x00F0, 0x0F00, 8, 4, 0, RGB2YUV_SHIFT + 4)
-rgb16_32_wrapper(AV_PIX_FMT_RGB565BE, rgb16be, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11, RGB2YUV_SHIFT + 8)
-rgb16_32_wrapper(AV_PIX_FMT_RGB555BE, rgb15be, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10, RGB2YUV_SHIFT + 7)
-rgb16_32_wrapper(AV_PIX_FMT_RGB444BE, rgb12be, 0, 0, 0, 0, 0x0F00, 0x00F0, 0x000F, 0, 4, 8, RGB2YUV_SHIFT + 4)
-
-static void gbr24pToUV_half_c(uint8_t *_dstU, uint8_t *_dstV,
- const uint8_t *gsrc, const uint8_t *bsrc, const uint8_t *rsrc,
- int width, uint32_t *unused)
-{
- uint16_t *dstU = (uint16_t *)_dstU;
- uint16_t *dstV = (uint16_t *)_dstV;
- int i;
- for (i = 0; i < width; i++) {
- unsigned int g = gsrc[2*i] + gsrc[2*i+1];
- unsigned int b = bsrc[2*i] + bsrc[2*i+1];
- unsigned int r = rsrc[2*i] + rsrc[2*i+1];
-
- dstU[i] = (RU*r + GU*g + BU*b + (0x4001<<(RGB2YUV_SHIFT-6))) >> (RGB2YUV_SHIFT-6+1);
- dstV[i] = (RV*r + GV*g + BV*b + (0x4001<<(RGB2YUV_SHIFT-6))) >> (RGB2YUV_SHIFT-6+1);
- }
-}
-
-static void rgba64ToA_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
- const uint8_t *unused2, int width, uint32_t *unused)
-{
- int16_t *dst = (int16_t *)_dst;
- const uint16_t *src = (const uint16_t *)_src;
- int i;
- for (i = 0; i < width; i++)
- dst[i] = src[4 * i + 3];
-}
-
-static void abgrToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
-{
- int16_t *dst = (int16_t *)_dst;
- int i;
- for (i=0; i<width; i++) {
- dst[i]= src[4*i]<<6;
- }
-}
-
-static void rgbaToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
-{
- int16_t *dst = (int16_t *)_dst;
- int i;
- for (i=0; i<width; i++) {
- dst[i]= src[4*i+3]<<6;
- }
-}
-
-static void palToA_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *pal)
-{
- int16_t *dst = (int16_t *)_dst;
- int i;
- for (i=0; i<width; i++) {
- int d= src[i];
-
- dst[i]= (pal[d] >> 24)<<6;
- }
-}
-
-static void palToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *pal)
-{
- int16_t *dst = (int16_t *)_dst;
- int i;
- for (i = 0; i < width; i++) {
- int d = src[i];
-
- dst[i] = (pal[d] & 0xFF)<<6;
- }
-}
-
-static void palToUV_c(uint8_t *_dstU, uint8_t *_dstV,
- const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
- int width, uint32_t *pal)
-{
- uint16_t *dstU = (uint16_t *)_dstU;
- int16_t *dstV = (int16_t *)_dstV;
- int i;
- av_assert1(src1 == src2);
- for (i = 0; i < width; i++) {
- int p = pal[src1[i]];
-
- dstU[i] = (uint8_t)(p>> 8)<<6;
- dstV[i] = (uint8_t)(p>>16)<<6;
- }
-}
-
-static void monowhite2Y_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
-{
- int16_t *dst = (int16_t *)_dst;
- int i, j;
- width = (width + 7) >> 3;
- for (i = 0; i < width; i++) {
- int d = ~src[i];
- for (j = 0; j < 8; j++)
- dst[8*i+j]= ((d>>(7-j))&1) * 16383;
- }
- if(width&7){
- int d= ~src[i];
- for (j = 0; j < (width&7); j++)
- dst[8*i+j]= ((d>>(7-j))&1) * 16383;
- }
-}
-
-static void monoblack2Y_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused)
-{
- int16_t *dst = (int16_t *)_dst;
- int i, j;
- width = (width + 7) >> 3;
- for (i = 0; i < width; i++) {
- int d = src[i];
- for (j = 0; j < 8; j++)
- dst[8*i+j]= ((d>>(7-j))&1) * 16383;
- }
- if(width&7){
- int d = src[i];
- for (j = 0; j < (width&7); j++)
- dst[8*i+j] = ((d>>(7-j))&1) * 16383;
- }
-}
-
-static void yuy2ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
- uint32_t *unused)
-{
- int i;
- for (i = 0; i < width; i++)
- dst[i] = src[2 * i];
-}
-
-static void yuy2ToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1,
- const uint8_t *src2, int width, uint32_t *unused)
-{
- int i;
- for (i = 0; i < width; i++) {
- dstU[i] = src1[4 * i + 1];
- dstV[i] = src1[4 * i + 3];
- }
- av_assert1(src1 == src2);
-}
-
-static void bswap16Y_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1, const uint8_t *unused2, int width,
- uint32_t *unused)
-{
- int i;
- const uint16_t *src = (const uint16_t *)_src;
- uint16_t *dst = (uint16_t *)_dst;
- for (i = 0; i < width; i++)
- dst[i] = av_bswap16(src[i]);
-}
-
-static void bswap16UV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *_src1,
- const uint8_t *_src2, int width, uint32_t *unused)
-{
- int i;
- const uint16_t *src1 = (const uint16_t *)_src1,
- *src2 = (const uint16_t *)_src2;
- uint16_t *dstU = (uint16_t *)_dstU, *dstV = (uint16_t *)_dstV;
- for (i = 0; i < width; i++) {
- dstU[i] = av_bswap16(src1[i]);
- dstV[i] = av_bswap16(src2[i]);
- }
-}
-
-/* This is almost identical to the previous, end exists only because
- * yuy2ToY/UV)(dst, src + 1, ...) would have 100% unaligned accesses. */
-static void uyvyToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
- uint32_t *unused)
-{
- int i;
- for (i = 0; i < width; i++)
- dst[i] = src[2 * i + 1];
-}
-
-static void uyvyToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, const uint8_t *src1,
- const uint8_t *src2, int width, uint32_t *unused)
-{
- int i;
- for (i = 0; i < width; i++) {
- dstU[i] = src1[4 * i + 0];
- dstV[i] = src1[4 * i + 2];
- }
- av_assert1(src1 == src2);
-}
-
-static av_always_inline void nvXXtoUV_c(uint8_t *dst1, uint8_t *dst2,
- const uint8_t *src, int width)
-{
- int i;
- for (i = 0; i < width; i++) {
- dst1[i] = src[2 * i + 0];
- dst2[i] = src[2 * i + 1];
- }
-}
-
-static void nv12ToUV_c(uint8_t *dstU, uint8_t *dstV,
- const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
- int width, uint32_t *unused)
-{
- nvXXtoUV_c(dstU, dstV, src1, width);
-}
-
-static void nv21ToUV_c(uint8_t *dstU, uint8_t *dstV,
- const uint8_t *unused0, const uint8_t *src1, const uint8_t *src2,
- int width, uint32_t *unused)
-{
- nvXXtoUV_c(dstV, dstU, src1, width);
-}
-
-#define input_pixel(pos) (isBE(origin) ? AV_RB16(pos) : AV_RL16(pos))
-
-static void bgr24ToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2,
- int width, uint32_t *unused)
-{
- int16_t *dst = (int16_t *)_dst;
- int i;
- for (i = 0; i < width; i++) {
- int b = src[i * 3 + 0];
- int g = src[i * 3 + 1];
- int r = src[i * 3 + 2];
-
- dst[i] = ((RY*r + GY*g + BY*b + (32<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6));
- }
-}
-
-static void bgr24ToUV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
- const uint8_t *src2, int width, uint32_t *unused)
-{
- int16_t *dstU = (int16_t *)_dstU;
- int16_t *dstV = (int16_t *)_dstV;
- int i;
- for (i = 0; i < width; i++) {
- int b = src1[3 * i + 0];
- int g = src1[3 * i + 1];
- int r = src1[3 * i + 2];
-
- dstU[i] = (RU*r + GU*g + BU*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
- dstV[i] = (RV*r + GV*g + BV*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
- }
- av_assert1(src1 == src2);
-}
-
-static void bgr24ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
- const uint8_t *src2, int width, uint32_t *unused)
-{
- int16_t *dstU = (int16_t *)_dstU;
- int16_t *dstV = (int16_t *)_dstV;
- int i;
- for (i = 0; i < width; i++) {
- int b = src1[6 * i + 0] + src1[6 * i + 3];
- int g = src1[6 * i + 1] + src1[6 * i + 4];
- int r = src1[6 * i + 2] + src1[6 * i + 5];
-
- dstU[i] = (RU*r + GU*g + BU*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
- dstV[i] = (RV*r + GV*g + BV*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
- }
- av_assert1(src1 == src2);
-}
-
-static void rgb24ToY_c(uint8_t *_dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width,
- uint32_t *unused)
-{
- int16_t *dst = (int16_t *)_dst;
- int i;
- for (i = 0; i < width; i++) {
- int r = src[i * 3 + 0];
- int g = src[i * 3 + 1];
- int b = src[i * 3 + 2];
-
- dst[i] = ((RY*r + GY*g + BY*b + (32<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6));
- }
-}
-
-static void rgb24ToUV_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
- const uint8_t *src2, int width, uint32_t *unused)
-{
- int16_t *dstU = (int16_t *)_dstU;
- int16_t *dstV = (int16_t *)_dstV;
- int i;
- av_assert1(src1 == src2);
- for (i = 0; i < width; i++) {
- int r = src1[3 * i + 0];
- int g = src1[3 * i + 1];
- int b = src1[3 * i + 2];
-
- dstU[i] = (RU*r + GU*g + BU*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
- dstV[i] = (RV*r + GV*g + BV*b + (256<<(RGB2YUV_SHIFT-1)) + (1<<(RGB2YUV_SHIFT-7)))>>(RGB2YUV_SHIFT-6);
- }
-}
-
-static void rgb24ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *unused0, const uint8_t *src1,
- const uint8_t *src2, int width, uint32_t *unused)
-{
- int16_t *dstU = (int16_t *)_dstU;
- int16_t *dstV = (int16_t *)_dstV;
- int i;
- av_assert1(src1 == src2);
- for (i = 0; i < width; i++) {
- int r = src1[6 * i + 0] + src1[6 * i + 3];
- int g = src1[6 * i + 1] + src1[6 * i + 4];
- int b = src1[6 * i + 2] + src1[6 * i + 5];
-
- dstU[i] = (RU*r + GU*g + BU*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
- dstV[i] = (RV*r + GV*g + BV*b + (256<<RGB2YUV_SHIFT) + (1<<(RGB2YUV_SHIFT-6)))>>(RGB2YUV_SHIFT-5);
- }
-}
-
-static void planar_rgb_to_y(uint8_t *_dst, const uint8_t *src[4], int width)
-{
- uint16_t *dst = (uint16_t *)_dst;
- int i;
- for (i = 0; i < width; i++) {
- int g = src[0][i];
- int b = src[1][i];
- int r = src[2][i];
-
- dst[i] = (RY*r + GY*g + BY*b + (0x801<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
- }
-}
-
-static void planar_rgb_to_uv(uint8_t *_dstU, uint8_t *_dstV, const uint8_t *src[4], int width)
-{
- uint16_t *dstU = (uint16_t *)_dstU;
- uint16_t *dstV = (uint16_t *)_dstV;
- int i;
- for (i = 0; i < width; i++) {
- int g = src[0][i];
- int b = src[1][i];
- int r = src[2][i];
-
- dstU[i] = (RU*r + GU*g + BU*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
- dstV[i] = (RV*r + GV*g + BV*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
- }
-}
-
-#define rdpx(src) \
- is_be ? AV_RB16(src) : AV_RL16(src)
-static av_always_inline void planar_rgb16_to_y(uint8_t *_dst, const uint8_t *_src[4],
- int width, int bpc, int is_be)
-{
- int i;
- const uint16_t **src = (const uint16_t **)_src;
- uint16_t *dst = (uint16_t *)_dst;
- for (i = 0; i < width; i++) {
- int g = rdpx(src[0] + i);
- int b = rdpx(src[1] + i);
- int r = rdpx(src[2] + i);
-
- dst[i] = ((RY * r + GY * g + BY * b + (33 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + bpc - 14));
- }
-}
-
-static void planar_rgb9le_to_y(uint8_t *dst, const uint8_t *src[4], int w)
-{
- planar_rgb16_to_y(dst, src, w, 9, 0);
-}
-
-static void planar_rgb9be_to_y(uint8_t *dst, const uint8_t *src[4], int w)
-{
- planar_rgb16_to_y(dst, src, w, 9, 1);
-}
-
-static void planar_rgb10le_to_y(uint8_t *dst, const uint8_t *src[4], int w)
-{
- planar_rgb16_to_y(dst, src, w, 10, 0);
-}
-
-static void planar_rgb10be_to_y(uint8_t *dst, const uint8_t *src[4], int w)
-{
- planar_rgb16_to_y(dst, src, w, 10, 1);
-}
-
-static void planar_rgb12le_to_y(uint8_t *dst, const uint8_t *src[4], int w)
-{
- planar_rgb16_to_y(dst, src, w, 12, 0);
-}
-
-static void planar_rgb12be_to_y(uint8_t *dst, const uint8_t *src[4], int w)
-{
- planar_rgb16_to_y(dst, src, w, 12, 1);
-}
-
-static void planar_rgb14le_to_y(uint8_t *dst, const uint8_t *src[4], int w)
-{
- planar_rgb16_to_y(dst, src, w, 14, 0);
-}
-
-static void planar_rgb14be_to_y(uint8_t *dst, const uint8_t *src[4], int w)
-{
- planar_rgb16_to_y(dst, src, w, 14, 1);
-}
-
-static void planar_rgb16le_to_y(uint8_t *dst, const uint8_t *src[4], int w)
-{
- planar_rgb16_to_y(dst, src, w, 16, 0);
-}
-
-static void planar_rgb16be_to_y(uint8_t *dst, const uint8_t *src[4], int w)
-{
- planar_rgb16_to_y(dst, src, w, 16, 1);
-}
-
-static av_always_inline void planar_rgb16_to_uv(uint8_t *_dstU, uint8_t *_dstV,
- const uint8_t *_src[4], int width,
- int bpc, int is_be)
-{
- int i;
- const uint16_t **src = (const uint16_t **)_src;
- uint16_t *dstU = (uint16_t *)_dstU;
- uint16_t *dstV = (uint16_t *)_dstV;
- for (i = 0; i < width; i++) {
- int g = rdpx(src[0] + i);
- int b = rdpx(src[1] + i);
- int r = rdpx(src[2] + i);
-
- dstU[i] = (RU * r + GU * g + BU * b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + bpc - 14);
- dstV[i] = (RV * r + GV * g + BV * b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> (RGB2YUV_SHIFT + bpc - 14);
- }
-}
-#undef rdpx
-
-static void planar_rgb9le_to_uv(uint8_t *dstU, uint8_t *dstV,
- const uint8_t *src[4], int w)
-{
- planar_rgb16_to_uv(dstU, dstV, src, w, 9, 0);
-}
-
-static void planar_rgb9be_to_uv(uint8_t *dstU, uint8_t *dstV,
- const uint8_t *src[4], int w)
-{
- planar_rgb16_to_uv(dstU, dstV, src, w, 9, 1);
-}
-
-static void planar_rgb10le_to_uv(uint8_t *dstU, uint8_t *dstV,
- const uint8_t *src[4], int w)
-{
- planar_rgb16_to_uv(dstU, dstV, src, w, 10, 0);
-}
-
-static void planar_rgb10be_to_uv(uint8_t *dstU, uint8_t *dstV,
- const uint8_t *src[4], int w)
-{
- planar_rgb16_to_uv(dstU, dstV, src, w, 10, 1);
-}
-
-static void planar_rgb12le_to_uv(uint8_t *dstU, uint8_t *dstV,
- const uint8_t *src[4], int w)
-{
- planar_rgb16_to_uv(dstU, dstV, src, w, 12, 0);
-}
-
-static void planar_rgb12be_to_uv(uint8_t *dstU, uint8_t *dstV,
- const uint8_t *src[4], int w)
-{
- planar_rgb16_to_uv(dstU, dstV, src, w, 12, 1);
-}
-
-static void planar_rgb14le_to_uv(uint8_t *dstU, uint8_t *dstV,
- const uint8_t *src[4], int w)
-{
- planar_rgb16_to_uv(dstU, dstV, src, w, 14, 0);
-}
-
-static void planar_rgb14be_to_uv(uint8_t *dstU, uint8_t *dstV,
- const uint8_t *src[4], int w)
-{
- planar_rgb16_to_uv(dstU, dstV, src, w, 14, 1);
-}
-
-static void planar_rgb16le_to_uv(uint8_t *dstU, uint8_t *dstV,
- const uint8_t *src[4], int w)
-{
- planar_rgb16_to_uv(dstU, dstV, src, w, 16, 0);
-}
-
-static void planar_rgb16be_to_uv(uint8_t *dstU, uint8_t *dstV,
- const uint8_t *src[4], int w)
-{
- planar_rgb16_to_uv(dstU, dstV, src, w, 16, 1);
-}
-
-av_cold void ff_sws_init_input_funcs(SwsContext *c)
-{
- enum AVPixelFormat srcFormat = c->srcFormat;
-
- c->chrToYV12 = NULL;
- switch (srcFormat) {
- case AV_PIX_FMT_YUYV422:
- c->chrToYV12 = yuy2ToUV_c;
- break;
- case AV_PIX_FMT_UYVY422:
- c->chrToYV12 = uyvyToUV_c;
- break;
- case AV_PIX_FMT_NV12:
- c->chrToYV12 = nv12ToUV_c;
- break;
- case AV_PIX_FMT_NV21:
- c->chrToYV12 = nv21ToUV_c;
- break;
- case AV_PIX_FMT_RGB8:
- case AV_PIX_FMT_BGR8:
- case AV_PIX_FMT_PAL8:
- case AV_PIX_FMT_BGR4_BYTE:
- case AV_PIX_FMT_RGB4_BYTE:
- c->chrToYV12 = palToUV_c;
- break;
- case AV_PIX_FMT_GBRP9LE:
- c->readChrPlanar = planar_rgb9le_to_uv;
- break;
- case AV_PIX_FMT_GBRP10LE:
- c->readChrPlanar = planar_rgb10le_to_uv;
- break;
- case AV_PIX_FMT_GBRP12LE:
- c->readChrPlanar = planar_rgb12le_to_uv;
- break;
- case AV_PIX_FMT_GBRP14LE:
- c->readChrPlanar = planar_rgb14le_to_uv;
- break;
- case AV_PIX_FMT_GBRP16LE:
- c->readChrPlanar = planar_rgb16le_to_uv;
- break;
- case AV_PIX_FMT_GBRP9BE:
- c->readChrPlanar = planar_rgb9be_to_uv;
- break;
- case AV_PIX_FMT_GBRP10BE:
- c->readChrPlanar = planar_rgb10be_to_uv;
- break;
- case AV_PIX_FMT_GBRP12BE:
- c->readChrPlanar = planar_rgb12be_to_uv;
- break;
- case AV_PIX_FMT_GBRP14BE:
- c->readChrPlanar = planar_rgb14be_to_uv;
- break;
- case AV_PIX_FMT_GBRP16BE:
- c->readChrPlanar = planar_rgb16be_to_uv;
- break;
- case AV_PIX_FMT_GBRP:
- c->readChrPlanar = planar_rgb_to_uv;
- break;
-#if HAVE_BIGENDIAN
- case AV_PIX_FMT_YUV444P9LE:
- case AV_PIX_FMT_YUV422P9LE:
- case AV_PIX_FMT_YUV420P9LE:
- case AV_PIX_FMT_YUV422P10LE:
- case AV_PIX_FMT_YUV444P10LE:
- case AV_PIX_FMT_YUV420P10LE:
- case AV_PIX_FMT_YUV422P12LE:
- case AV_PIX_FMT_YUV444P12LE:
- case AV_PIX_FMT_YUV420P12LE:
- case AV_PIX_FMT_YUV422P14LE:
- case AV_PIX_FMT_YUV444P14LE:
- case AV_PIX_FMT_YUV420P14LE:
- case AV_PIX_FMT_YUV420P16LE:
- case AV_PIX_FMT_YUV422P16LE:
- case AV_PIX_FMT_YUV444P16LE:
-
- case AV_PIX_FMT_YUVA444P9LE:
- case AV_PIX_FMT_YUVA422P9LE:
- case AV_PIX_FMT_YUVA420P9LE:
- case AV_PIX_FMT_YUVA444P10LE:
- case AV_PIX_FMT_YUVA422P10LE:
- case AV_PIX_FMT_YUVA420P10LE:
- case AV_PIX_FMT_YUVA420P16LE:
- case AV_PIX_FMT_YUVA422P16LE:
- case AV_PIX_FMT_YUVA444P16LE:
- c->chrToYV12 = bswap16UV_c;
- break;
-#else
- case AV_PIX_FMT_YUV444P9BE:
- case AV_PIX_FMT_YUV422P9BE:
- case AV_PIX_FMT_YUV420P9BE:
- case AV_PIX_FMT_YUV444P10BE:
- case AV_PIX_FMT_YUV422P10BE:
- case AV_PIX_FMT_YUV420P10BE:
- case AV_PIX_FMT_YUV444P12BE:
- case AV_PIX_FMT_YUV422P12BE:
- case AV_PIX_FMT_YUV420P12BE:
- case AV_PIX_FMT_YUV444P14BE:
- case AV_PIX_FMT_YUV422P14BE:
- case AV_PIX_FMT_YUV420P14BE:
- case AV_PIX_FMT_YUV420P16BE:
- case AV_PIX_FMT_YUV422P16BE:
- case AV_PIX_FMT_YUV444P16BE:
-
- case AV_PIX_FMT_YUVA444P9BE:
- case AV_PIX_FMT_YUVA422P9BE:
- case AV_PIX_FMT_YUVA420P9BE:
- case AV_PIX_FMT_YUVA444P10BE:
- case AV_PIX_FMT_YUVA422P10BE:
- case AV_PIX_FMT_YUVA420P10BE:
- case AV_PIX_FMT_YUVA420P16BE:
- case AV_PIX_FMT_YUVA422P16BE:
- case AV_PIX_FMT_YUVA444P16BE:
- c->chrToYV12 = bswap16UV_c;
- break;
-#endif
- }
- if (c->chrSrcHSubSample) {
- switch (srcFormat) {
- case AV_PIX_FMT_RGBA64BE:
- c->chrToYV12 = rgb64BEToUV_half_c;
- break;
- case AV_PIX_FMT_RGBA64LE:
- c->chrToYV12 = rgb64LEToUV_half_c;
- break;
- case AV_PIX_FMT_RGB48BE:
- c->chrToYV12 = rgb48BEToUV_half_c;
- break;
- case AV_PIX_FMT_RGB48LE:
- c->chrToYV12 = rgb48LEToUV_half_c;
- break;
- case AV_PIX_FMT_BGR48BE:
- c->chrToYV12 = bgr48BEToUV_half_c;
- break;
- case AV_PIX_FMT_BGR48LE:
- c->chrToYV12 = bgr48LEToUV_half_c;
- break;
- case AV_PIX_FMT_RGB32:
- c->chrToYV12 = bgr32ToUV_half_c;
- break;
- case AV_PIX_FMT_RGB32_1:
- c->chrToYV12 = bgr321ToUV_half_c;
- break;
- case AV_PIX_FMT_BGR24:
- c->chrToYV12 = bgr24ToUV_half_c;
- break;
- case AV_PIX_FMT_BGR565LE:
- c->chrToYV12 = bgr16leToUV_half_c;
- break;
- case AV_PIX_FMT_BGR565BE:
- c->chrToYV12 = bgr16beToUV_half_c;
- break;
- case AV_PIX_FMT_BGR555LE:
- c->chrToYV12 = bgr15leToUV_half_c;
- break;
- case AV_PIX_FMT_BGR555BE:
- c->chrToYV12 = bgr15beToUV_half_c;
- break;
- case AV_PIX_FMT_GBR24P :
- c->chrToYV12 = gbr24pToUV_half_c;
- break;
- case AV_PIX_FMT_BGR444LE:
- c->chrToYV12 = bgr12leToUV_half_c;
- break;
- case AV_PIX_FMT_BGR444BE:
- c->chrToYV12 = bgr12beToUV_half_c;
- break;
- case AV_PIX_FMT_BGR32:
- c->chrToYV12 = rgb32ToUV_half_c;
- break;
- case AV_PIX_FMT_BGR32_1:
- c->chrToYV12 = rgb321ToUV_half_c;
- break;
- case AV_PIX_FMT_RGB24:
- c->chrToYV12 = rgb24ToUV_half_c;
- break;
- case AV_PIX_FMT_RGB565LE:
- c->chrToYV12 = rgb16leToUV_half_c;
- break;
- case AV_PIX_FMT_RGB565BE:
- c->chrToYV12 = rgb16beToUV_half_c;
- break;
- case AV_PIX_FMT_RGB555LE:
- c->chrToYV12 = rgb15leToUV_half_c;
- break;
- case AV_PIX_FMT_RGB555BE:
- c->chrToYV12 = rgb15beToUV_half_c;
- break;
- case AV_PIX_FMT_RGB444LE:
- c->chrToYV12 = rgb12leToUV_half_c;
- break;
- case AV_PIX_FMT_RGB444BE:
- c->chrToYV12 = rgb12beToUV_half_c;
- break;
- }
- } else {
- switch (srcFormat) {
- case AV_PIX_FMT_RGBA64BE:
- c->chrToYV12 = rgb64BEToUV_c;
- break;
- case AV_PIX_FMT_RGBA64LE:
- c->chrToYV12 = rgb64LEToUV_c;
- break;
- case AV_PIX_FMT_RGB48BE:
- c->chrToYV12 = rgb48BEToUV_c;
- break;
- case AV_PIX_FMT_RGB48LE:
- c->chrToYV12 = rgb48LEToUV_c;
- break;
- case AV_PIX_FMT_BGR48BE:
- c->chrToYV12 = bgr48BEToUV_c;
- break;
- case AV_PIX_FMT_BGR48LE:
- c->chrToYV12 = bgr48LEToUV_c;
- break;
- case AV_PIX_FMT_RGB32:
- c->chrToYV12 = bgr32ToUV_c;
- break;
- case AV_PIX_FMT_RGB32_1:
- c->chrToYV12 = bgr321ToUV_c;
- break;
- case AV_PIX_FMT_BGR24:
- c->chrToYV12 = bgr24ToUV_c;
- break;
- case AV_PIX_FMT_BGR565LE:
- c->chrToYV12 = bgr16leToUV_c;
- break;
- case AV_PIX_FMT_BGR565BE:
- c->chrToYV12 = bgr16beToUV_c;
- break;
- case AV_PIX_FMT_BGR555LE:
- c->chrToYV12 = bgr15leToUV_c;
- break;
- case AV_PIX_FMT_BGR555BE:
- c->chrToYV12 = bgr15beToUV_c;
- break;
- case AV_PIX_FMT_BGR444LE:
- c->chrToYV12 = bgr12leToUV_c;
- break;
- case AV_PIX_FMT_BGR444BE:
- c->chrToYV12 = bgr12beToUV_c;
- break;
- case AV_PIX_FMT_BGR32:
- c->chrToYV12 = rgb32ToUV_c;
- break;
- case AV_PIX_FMT_BGR32_1:
- c->chrToYV12 = rgb321ToUV_c;
- break;
- case AV_PIX_FMT_RGB24:
- c->chrToYV12 = rgb24ToUV_c;
- break;
- case AV_PIX_FMT_RGB565LE:
- c->chrToYV12 = rgb16leToUV_c;
- break;
- case AV_PIX_FMT_RGB565BE:
- c->chrToYV12 = rgb16beToUV_c;
- break;
- case AV_PIX_FMT_RGB555LE:
- c->chrToYV12 = rgb15leToUV_c;
- break;
- case AV_PIX_FMT_RGB555BE:
- c->chrToYV12 = rgb15beToUV_c;
- break;
- case AV_PIX_FMT_RGB444LE:
- c->chrToYV12 = rgb12leToUV_c;
- break;
- case AV_PIX_FMT_RGB444BE:
- c->chrToYV12 = rgb12beToUV_c;
- break;
- }
- }
-
- c->lumToYV12 = NULL;
- c->alpToYV12 = NULL;
- switch (srcFormat) {
- case AV_PIX_FMT_GBRP9LE:
- c->readLumPlanar = planar_rgb9le_to_y;
- break;
- case AV_PIX_FMT_GBRP10LE:
- c->readLumPlanar = planar_rgb10le_to_y;
- break;
- case AV_PIX_FMT_GBRP12LE:
- c->readLumPlanar = planar_rgb12le_to_y;
- break;
- case AV_PIX_FMT_GBRP14LE:
- c->readLumPlanar = planar_rgb14le_to_y;
- break;
- case AV_PIX_FMT_GBRP16LE:
- c->readLumPlanar = planar_rgb16le_to_y;
- break;
- case AV_PIX_FMT_GBRP9BE:
- c->readLumPlanar = planar_rgb9be_to_y;
- break;
- case AV_PIX_FMT_GBRP10BE:
- c->readLumPlanar = planar_rgb10be_to_y;
- break;
- case AV_PIX_FMT_GBRP12BE:
- c->readLumPlanar = planar_rgb12be_to_y;
- break;
- case AV_PIX_FMT_GBRP14BE:
- c->readLumPlanar = planar_rgb14be_to_y;
- break;
- case AV_PIX_FMT_GBRP16BE:
- c->readLumPlanar = planar_rgb16be_to_y;
- break;
- case AV_PIX_FMT_GBRP:
- c->readLumPlanar = planar_rgb_to_y;
- break;
-#if HAVE_BIGENDIAN
- case AV_PIX_FMT_YUV444P9LE:
- case AV_PIX_FMT_YUV422P9LE:
- case AV_PIX_FMT_YUV420P9LE:
- case AV_PIX_FMT_YUV444P10LE:
- case AV_PIX_FMT_YUV422P10LE:
- case AV_PIX_FMT_YUV420P10LE:
- case AV_PIX_FMT_YUV444P12LE:
- case AV_PIX_FMT_YUV422P12LE:
- case AV_PIX_FMT_YUV420P12LE:
- case AV_PIX_FMT_YUV444P14LE:
- case AV_PIX_FMT_YUV422P14LE:
- case AV_PIX_FMT_YUV420P14LE:
- case AV_PIX_FMT_YUV420P16LE:
- case AV_PIX_FMT_YUV422P16LE:
- case AV_PIX_FMT_YUV444P16LE:
-
- case AV_PIX_FMT_GRAY16LE:
- c->lumToYV12 = bswap16Y_c;
- break;
- case AV_PIX_FMT_YUVA444P9LE:
- case AV_PIX_FMT_YUVA422P9LE:
- case AV_PIX_FMT_YUVA420P9LE:
- case AV_PIX_FMT_YUVA444P10LE:
- case AV_PIX_FMT_YUVA422P10LE:
- case AV_PIX_FMT_YUVA420P10LE:
- case AV_PIX_FMT_YUVA420P16LE:
- case AV_PIX_FMT_YUVA422P16LE:
- case AV_PIX_FMT_YUVA444P16LE:
- c->lumToYV12 = bswap16Y_c;
- c->alpToYV12 = bswap16Y_c;
- break;
-#else
- case AV_PIX_FMT_YUV444P9BE:
- case AV_PIX_FMT_YUV422P9BE:
- case AV_PIX_FMT_YUV420P9BE:
- case AV_PIX_FMT_YUV444P10BE:
- case AV_PIX_FMT_YUV422P10BE:
- case AV_PIX_FMT_YUV420P10BE:
- case AV_PIX_FMT_YUV444P12BE:
- case AV_PIX_FMT_YUV422P12BE:
- case AV_PIX_FMT_YUV420P12BE:
- case AV_PIX_FMT_YUV444P14BE:
- case AV_PIX_FMT_YUV422P14BE:
- case AV_PIX_FMT_YUV420P14BE:
- case AV_PIX_FMT_YUV420P16BE:
- case AV_PIX_FMT_YUV422P16BE:
- case AV_PIX_FMT_YUV444P16BE:
-
- case AV_PIX_FMT_GRAY16BE:
- c->lumToYV12 = bswap16Y_c;
- break;
- case AV_PIX_FMT_YUVA444P9BE:
- case AV_PIX_FMT_YUVA422P9BE:
- case AV_PIX_FMT_YUVA420P9BE:
- case AV_PIX_FMT_YUVA444P10BE:
- case AV_PIX_FMT_YUVA422P10BE:
- case AV_PIX_FMT_YUVA420P10BE:
- case AV_PIX_FMT_YUVA420P16BE:
- case AV_PIX_FMT_YUVA422P16BE:
- case AV_PIX_FMT_YUVA444P16BE:
- c->lumToYV12 = bswap16Y_c;
- c->alpToYV12 = bswap16Y_c;
- break;
-#endif
- case AV_PIX_FMT_YUYV422:
- case AV_PIX_FMT_Y400A:
- c->lumToYV12 = yuy2ToY_c;
- break;
- case AV_PIX_FMT_UYVY422:
- c->lumToYV12 = uyvyToY_c;
- break;
- case AV_PIX_FMT_BGR24:
- c->lumToYV12 = bgr24ToY_c;
- break;
- case AV_PIX_FMT_BGR565LE:
- c->lumToYV12 = bgr16leToY_c;
- break;
- case AV_PIX_FMT_BGR565BE:
- c->lumToYV12 = bgr16beToY_c;
- break;
- case AV_PIX_FMT_BGR555LE:
- c->lumToYV12 = bgr15leToY_c;
- break;
- case AV_PIX_FMT_BGR555BE:
- c->lumToYV12 = bgr15beToY_c;
- break;
- case AV_PIX_FMT_BGR444LE:
- c->lumToYV12 = bgr12leToY_c;
- break;
- case AV_PIX_FMT_BGR444BE:
- c->lumToYV12 = bgr12beToY_c;
- break;
- case AV_PIX_FMT_RGB24:
- c->lumToYV12 = rgb24ToY_c;
- break;
- case AV_PIX_FMT_RGB565LE:
- c->lumToYV12 = rgb16leToY_c;
- break;
- case AV_PIX_FMT_RGB565BE:
- c->lumToYV12 = rgb16beToY_c;
- break;
- case AV_PIX_FMT_RGB555LE:
- c->lumToYV12 = rgb15leToY_c;
- break;
- case AV_PIX_FMT_RGB555BE:
- c->lumToYV12 = rgb15beToY_c;
- break;
- case AV_PIX_FMT_RGB444LE:
- c->lumToYV12 = rgb12leToY_c;
- break;
- case AV_PIX_FMT_RGB444BE:
- c->lumToYV12 = rgb12beToY_c;
- break;
- case AV_PIX_FMT_RGB8:
- case AV_PIX_FMT_BGR8:
- case AV_PIX_FMT_PAL8:
- case AV_PIX_FMT_BGR4_BYTE:
- case AV_PIX_FMT_RGB4_BYTE:
- c->lumToYV12 = palToY_c;
- break;
- case AV_PIX_FMT_MONOBLACK:
- c->lumToYV12 = monoblack2Y_c;
- break;
- case AV_PIX_FMT_MONOWHITE:
- c->lumToYV12 = monowhite2Y_c;
- break;
- case AV_PIX_FMT_RGB32:
- c->lumToYV12 = bgr32ToY_c;
- break;
- case AV_PIX_FMT_RGB32_1:
- c->lumToYV12 = bgr321ToY_c;
- break;
- case AV_PIX_FMT_BGR32:
- c->lumToYV12 = rgb32ToY_c;
- break;
- case AV_PIX_FMT_BGR32_1:
- c->lumToYV12 = rgb321ToY_c;
- break;
- case AV_PIX_FMT_RGB48BE:
- c->lumToYV12 = rgb48BEToY_c;
- break;
- case AV_PIX_FMT_RGB48LE:
- c->lumToYV12 = rgb48LEToY_c;
- break;
- case AV_PIX_FMT_BGR48BE:
- c->lumToYV12 = bgr48BEToY_c;
- break;
- case AV_PIX_FMT_BGR48LE:
- c->lumToYV12 = bgr48LEToY_c;
- break;
- case AV_PIX_FMT_RGBA64BE:
- c->lumToYV12 = rgb64BEToY_c;
- break;
- case AV_PIX_FMT_RGBA64LE:
- c->lumToYV12 = rgb64LEToY_c;
- break;
- }
- if (c->alpPixBuf) {
- if (is16BPS(srcFormat) || isNBPS(srcFormat)) {
- if (HAVE_BIGENDIAN == !isBE(srcFormat))
- c->alpToYV12 = bswap16Y_c;
- }
- switch (srcFormat) {
- case AV_PIX_FMT_RGBA64LE:
- case AV_PIX_FMT_RGBA64BE: c->alpToYV12 = rgba64ToA_c; break;
- case AV_PIX_FMT_BGRA:
- case AV_PIX_FMT_RGBA:
- c->alpToYV12 = rgbaToA_c;
- break;
- case AV_PIX_FMT_ABGR:
- case AV_PIX_FMT_ARGB:
- c->alpToYV12 = abgrToA_c;
- break;
- case AV_PIX_FMT_Y400A:
- c->alpToYV12 = uyvyToY_c;
- break;
- case AV_PIX_FMT_PAL8 :
- c->alpToYV12 = palToA_c;
- break;
- }
- }
-}
diff --git a/src/thirdparty/ffmpeg/libswscale/options.c b/src/thirdparty/ffmpeg/libswscale/options.c
deleted file mode 100644
index 4ebeaeb3a..000000000
--- a/src/thirdparty/ffmpeg/libswscale/options.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2001-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
- */
-
-#include "libavutil/avutil.h"
-#include "libavutil/opt.h"
-#include "libavutil/pixfmt.h"
-#include "swscale.h"
-#include "swscale_internal.h"
-
-static const char *sws_context_to_name(void *ptr)
-{
- return "swscaler";
-}
-
-#define OFFSET(x) offsetof(SwsContext, x)
-#define DEFAULT 0
-#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
-
-static const AVOption options[] = {
- { "sws_flags", "scaler flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, { .i64 = DEFAULT }, 0, UINT_MAX, VE, "sws_flags" },
- { "fast_bilinear", "fast bilinear", 0, AV_OPT_TYPE_CONST, { .i64 = SWS_FAST_BILINEAR }, INT_MIN, INT_MAX, VE, "sws_flags" },
- { "bilinear", "bilinear", 0, AV_OPT_TYPE_CONST, { .i64 = SWS_BILINEAR }, INT_MIN, INT_MAX, VE, "sws_flags" },
- { "bicubic", "bicubic", 0, AV_OPT_TYPE_CONST, { .i64 = SWS_BICUBIC }, INT_MIN, INT_MAX, VE, "sws_flags" },
- { "experimental", "experimental", 0, AV_OPT_TYPE_CONST, { .i64 = SWS_X }, INT_MIN, INT_MAX, VE, "sws_flags" },
- { "neighbor", "nearest neighbor", 0, AV_OPT_TYPE_CONST, { .i64 = SWS_POINT }, INT_MIN, INT_MAX, VE, "sws_flags" },
- { "area", "averaging area", 0, AV_OPT_TYPE_CONST, { .i64 = SWS_AREA }, INT_MIN, INT_MAX, VE, "sws_flags" },
- { "bicublin", "luma bicubic, chroma bilinear", 0, AV_OPT_TYPE_CONST, { .i64 = SWS_BICUBLIN }, INT_MIN, INT_MAX, VE, "sws_flags" },
- { "gauss", "gaussian", 0, AV_OPT_TYPE_CONST, { .i64 = SWS_GAUSS }, INT_MIN, INT_MAX, VE, "sws_flags" },
- { "sinc", "sinc", 0, AV_OPT_TYPE_CONST, { .i64 = SWS_SINC }, INT_MIN, INT_MAX, VE, "sws_flags" },
- { "lanczos", "lanczos", 0, AV_OPT_TYPE_CONST, { .i64 = SWS_LANCZOS }, INT_MIN, INT_MAX, VE, "sws_flags" },
- { "spline", "natural bicubic spline", 0, AV_OPT_TYPE_CONST, { .i64 = SWS_SPLINE }, INT_MIN, INT_MAX, VE, "sws_flags" },
- { "print_info", "print info", 0, AV_OPT_TYPE_CONST, { .i64 = SWS_PRINT_INFO }, INT_MIN, INT_MAX, VE, "sws_flags" },
- { "accurate_rnd", "accurate rounding", 0, AV_OPT_TYPE_CONST, { .i64 = SWS_ACCURATE_RND }, INT_MIN, INT_MAX, VE, "sws_flags" },
- { "full_chroma_int", "full chroma interpolation", 0, AV_OPT_TYPE_CONST, { .i64 = SWS_FULL_CHR_H_INT }, INT_MIN, INT_MAX, VE, "sws_flags" },
- { "full_chroma_inp", "full chroma input", 0, AV_OPT_TYPE_CONST, { .i64 = SWS_FULL_CHR_H_INP }, INT_MIN, INT_MAX, VE, "sws_flags" },
- { "bitexact", "", 0, AV_OPT_TYPE_CONST, { .i64 = SWS_BITEXACT }, INT_MIN, INT_MAX, VE, "sws_flags" },
- { "error_diffusion", "error diffusion dither", 0, AV_OPT_TYPE_CONST, { .i64 = SWS_ERROR_DIFFUSION}, INT_MIN, INT_MAX, VE, "sws_flags" },
-
- { "srcw", "source width", OFFSET(srcW), AV_OPT_TYPE_INT, { .i64 = 16 }, 1, INT_MAX, VE },
- { "srch", "source height", OFFSET(srcH), AV_OPT_TYPE_INT, { .i64 = 16 }, 1, INT_MAX, VE },
- { "dstw", "destination width", OFFSET(dstW), AV_OPT_TYPE_INT, { .i64 = 16 }, 1, INT_MAX, VE },
- { "dsth", "destination height", OFFSET(dstH), AV_OPT_TYPE_INT, { .i64 = 16 }, 1, INT_MAX, VE },
- { "src_format", "source format", OFFSET(srcFormat), AV_OPT_TYPE_INT, { .i64 = DEFAULT }, 0, AV_PIX_FMT_NB - 1, VE },
- { "dst_format", "destination format", OFFSET(dstFormat), AV_OPT_TYPE_INT, { .i64 = DEFAULT }, 0, AV_PIX_FMT_NB - 1, VE },
- { "src_range", "source range", OFFSET(srcRange), AV_OPT_TYPE_INT, { .i64 = DEFAULT }, 0, 1, VE },
- { "dst_range", "destination range", OFFSET(dstRange), AV_OPT_TYPE_INT, { .i64 = DEFAULT }, 0, 1, VE },
- { "param0", "scaler param 0", OFFSET(param[0]), AV_OPT_TYPE_DOUBLE, { .dbl = SWS_PARAM_DEFAULT }, INT_MIN, INT_MAX, VE },
- { "param1", "scaler param 1", OFFSET(param[1]), AV_OPT_TYPE_DOUBLE, { .dbl = SWS_PARAM_DEFAULT }, INT_MIN, INT_MAX, VE },
-
- { NULL }
-};
-
-const AVClass sws_context_class = {
- .class_name = "SWScaler",
- .item_name = sws_context_to_name,
- .option = options,
- .category = AV_CLASS_CATEGORY_SWSCALER,
- .version = LIBAVUTIL_VERSION_INT,
-};
-
-const AVClass *sws_get_class(void)
-{
- return &sws_context_class;
-}
diff --git a/src/thirdparty/ffmpeg/libswscale/output.c b/src/thirdparty/ffmpeg/libswscale/output.c
deleted file mode 100644
index 4371e4b6c..000000000
--- a/src/thirdparty/ffmpeg/libswscale/output.c
+++ /dev/null
@@ -1,1722 +0,0 @@
-/*
- * Copyright (C) 2001-2012 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
- */
-
-#include <assert.h>
-#include <math.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "libavutil/attributes.h"
-#include "libavutil/avutil.h"
-#include "libavutil/avassert.h"
-#include "libavutil/bswap.h"
-#include "libavutil/cpu.h"
-#include "libavutil/intreadwrite.h"
-#include "libavutil/mathematics.h"
-#include "libavutil/pixdesc.h"
-#include "config.h"
-#include "rgb2rgb.h"
-#include "swscale.h"
-#include "swscale_internal.h"
-
-DECLARE_ALIGNED(8, const uint8_t, dither_2x2_4)[][8]={
-{ 1, 3, 1, 3, 1, 3, 1, 3, },
-{ 2, 0, 2, 0, 2, 0, 2, 0, },
-{ 1, 3, 1, 3, 1, 3, 1, 3, },
-};
-
-DECLARE_ALIGNED(8, const uint8_t, dither_2x2_8)[][8]={
-{ 6, 2, 6, 2, 6, 2, 6, 2, },
-{ 0, 4, 0, 4, 0, 4, 0, 4, },
-{ 6, 2, 6, 2, 6, 2, 6, 2, },
-};
-
-DECLARE_ALIGNED(8, const uint8_t, dither_4x4_16)[][8]={
-{ 8, 4, 11, 7, 8, 4, 11, 7, },
-{ 2, 14, 1, 13, 2, 14, 1, 13, },
-{ 10, 6, 9, 5, 10, 6, 9, 5, },
-{ 0, 12, 3, 15, 0, 12, 3, 15, },
-{ 8, 4, 11, 7, 8, 4, 11, 7, },
-};
-
-DECLARE_ALIGNED(8, const uint8_t, dither_8x8_32)[][8]={
-{ 17, 9, 23, 15, 16, 8, 22, 14, },
-{ 5, 29, 3, 27, 4, 28, 2, 26, },
-{ 21, 13, 19, 11, 20, 12, 18, 10, },
-{ 0, 24, 6, 30, 1, 25, 7, 31, },
-{ 16, 8, 22, 14, 17, 9, 23, 15, },
-{ 4, 28, 2, 26, 5, 29, 3, 27, },
-{ 20, 12, 18, 10, 21, 13, 19, 11, },
-{ 1, 25, 7, 31, 0, 24, 6, 30, },
-{ 17, 9, 23, 15, 16, 8, 22, 14, },
-};
-
-DECLARE_ALIGNED(8, const uint8_t, dither_8x8_73)[][8]={
-{ 0, 55, 14, 68, 3, 58, 17, 72, },
-{ 37, 18, 50, 32, 40, 22, 54, 35, },
-{ 9, 64, 5, 59, 13, 67, 8, 63, },
-{ 46, 27, 41, 23, 49, 31, 44, 26, },
-{ 2, 57, 16, 71, 1, 56, 15, 70, },
-{ 39, 21, 52, 34, 38, 19, 51, 33, },
-{ 11, 66, 7, 62, 10, 65, 6, 60, },
-{ 48, 30, 43, 25, 47, 29, 42, 24, },
-{ 0, 55, 14, 68, 3, 58, 17, 72, },
-};
-
-#if 1
-DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220)[][8]={
-{117, 62, 158, 103, 113, 58, 155, 100, },
-{ 34, 199, 21, 186, 31, 196, 17, 182, },
-{144, 89, 131, 76, 141, 86, 127, 72, },
-{ 0, 165, 41, 206, 10, 175, 52, 217, },
-{110, 55, 151, 96, 120, 65, 162, 107, },
-{ 28, 193, 14, 179, 38, 203, 24, 189, },
-{138, 83, 124, 69, 148, 93, 134, 79, },
-{ 7, 172, 48, 213, 3, 168, 45, 210, },
-{117, 62, 158, 103, 113, 58, 155, 100, },
-};
-#elif 1
-// tries to correct a gamma of 1.5
-DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220)[][8]={
-{ 0, 143, 18, 200, 2, 156, 25, 215, },
-{ 78, 28, 125, 64, 89, 36, 138, 74, },
-{ 10, 180, 3, 161, 16, 195, 8, 175, },
-{109, 51, 93, 38, 121, 60, 105, 47, },
-{ 1, 152, 23, 210, 0, 147, 20, 205, },
-{ 85, 33, 134, 71, 81, 30, 130, 67, },
-{ 14, 190, 6, 171, 12, 185, 5, 166, },
-{117, 57, 101, 44, 113, 54, 97, 41, },
-{ 0, 143, 18, 200, 2, 156, 25, 215, },
-};
-#elif 1
-// tries to correct a gamma of 2.0
-DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220)[][8]={
-{ 0, 124, 8, 193, 0, 140, 12, 213, },
-{ 55, 14, 104, 42, 66, 19, 119, 52, },
-{ 3, 168, 1, 145, 6, 187, 3, 162, },
-{ 86, 31, 70, 21, 99, 39, 82, 28, },
-{ 0, 134, 11, 206, 0, 129, 9, 200, },
-{ 62, 17, 114, 48, 58, 16, 109, 45, },
-{ 5, 181, 2, 157, 4, 175, 1, 151, },
-{ 95, 36, 78, 26, 90, 34, 74, 24, },
-{ 0, 124, 8, 193, 0, 140, 12, 213, },
-};
-#else
-// tries to correct a gamma of 2.5
-DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220)[][8]={
-{ 0, 107, 3, 187, 0, 125, 6, 212, },
-{ 39, 7, 86, 28, 49, 11, 102, 36, },
-{ 1, 158, 0, 131, 3, 180, 1, 151, },
-{ 68, 19, 52, 12, 81, 25, 64, 17, },
-{ 0, 119, 5, 203, 0, 113, 4, 195, },
-{ 45, 9, 96, 33, 42, 8, 91, 30, },
-{ 2, 172, 1, 144, 2, 165, 0, 137, },
-{ 77, 23, 60, 15, 72, 21, 56, 14, },
-{ 0, 107, 3, 187, 0, 125, 6, 212, },
-};
-#endif
-
-#define output_pixel(pos, val, bias, signedness) \
- if (big_endian) { \
- AV_WB16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \
- } else { \
- AV_WL16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \
- }
-
-static av_always_inline void
-yuv2plane1_16_c_template(const int32_t *src, uint16_t *dest, int dstW,
- int big_endian, int output_bits)
-{
- int i;
- int shift = 3;
- av_assert0(output_bits == 16);
-
- for (i = 0; i < dstW; i++) {
- int val = src[i] + (1 << (shift - 1));
- output_pixel(&dest[i], val, 0, uint);
- }
-}
-
-static av_always_inline void
-yuv2planeX_16_c_template(const int16_t *filter, int filterSize,
- const int32_t **src, uint16_t *dest, int dstW,
- int big_endian, int output_bits)
-{
- int i;
- int shift = 15;
- av_assert0(output_bits == 16);
-
- for (i = 0; i < dstW; i++) {
- int val = 1 << (shift - 1);
- int j;
-
- /* range of val is [0,0x7FFFFFFF], so 31 bits, but with lanczos/spline
- * filters (or anything with negative coeffs, the range can be slightly
- * wider in both directions. To account for this overflow, we subtract
- * a constant so it always fits in the signed range (assuming a
- * reasonable filterSize), and re-add that at the end. */
- val -= 0x40000000;
- for (j = 0; j < filterSize; j++)
- val += src[j][i] * (unsigned)filter[j];
-
- output_pixel(&dest[i], val, 0x8000, int);
- }
-}
-
-#undef output_pixel
-
-#define output_pixel(pos, val) \
- if (big_endian) { \
- AV_WB16(pos, av_clip_uintp2(val >> shift, output_bits)); \
- } else { \
- AV_WL16(pos, av_clip_uintp2(val >> shift, output_bits)); \
- }
-
-static av_always_inline void
-yuv2plane1_10_c_template(const int16_t *src, uint16_t *dest, int dstW,
- int big_endian, int output_bits)
-{
- int i;
- int shift = 15 - output_bits;
-
- for (i = 0; i < dstW; i++) {
- int val = src[i] + (1 << (shift - 1));
- output_pixel(&dest[i], val);
- }
-}
-
-static av_always_inline void
-yuv2planeX_10_c_template(const int16_t *filter, int filterSize,
- const int16_t **src, uint16_t *dest, int dstW,
- int big_endian, int output_bits)
-{
- int i;
- int shift = 11 + 16 - output_bits;
-
- for (i = 0; i < dstW; i++) {
- int val = 1 << (shift - 1);
- int j;
-
- for (j = 0; j < filterSize; j++)
- val += src[j][i] * filter[j];
-
- output_pixel(&dest[i], val);
- }
-}
-
-#undef output_pixel
-
-#define yuv2NBPS(bits, BE_LE, is_be, template_size, typeX_t) \
-static void yuv2plane1_ ## bits ## BE_LE ## _c(const int16_t *src, \
- uint8_t *dest, int dstW, \
- const uint8_t *dither, int offset)\
-{ \
- yuv2plane1_ ## template_size ## _c_template((const typeX_t *) src, \
- (uint16_t *) dest, dstW, is_be, bits); \
-}\
-static void yuv2planeX_ ## bits ## BE_LE ## _c(const int16_t *filter, int filterSize, \
- const int16_t **src, uint8_t *dest, int dstW, \
- const uint8_t *dither, int offset)\
-{ \
- yuv2planeX_## template_size ## _c_template(filter, \
- filterSize, (const typeX_t **) src, \
- (uint16_t *) dest, dstW, is_be, bits); \
-}
-yuv2NBPS( 9, BE, 1, 10, int16_t)
-yuv2NBPS( 9, LE, 0, 10, int16_t)
-yuv2NBPS(10, BE, 1, 10, int16_t)
-yuv2NBPS(10, LE, 0, 10, int16_t)
-yuv2NBPS(12, BE, 1, 10, int16_t)
-yuv2NBPS(12, LE, 0, 10, int16_t)
-yuv2NBPS(14, BE, 1, 10, int16_t)
-yuv2NBPS(14, LE, 0, 10, int16_t)
-yuv2NBPS(16, BE, 1, 16, int32_t)
-yuv2NBPS(16, LE, 0, 16, int32_t)
-
-static void yuv2planeX_8_c(const int16_t *filter, int filterSize,
- const int16_t **src, uint8_t *dest, int dstW,
- const uint8_t *dither, int offset)
-{
- int i;
- for (i=0; i<dstW; i++) {
- int val = dither[(i + offset) & 7] << 12;
- int j;
- for (j=0; j<filterSize; j++)
- val += src[j][i] * filter[j];
-
- dest[i]= av_clip_uint8(val>>19);
- }
-}
-
-static void yuv2plane1_8_c(const int16_t *src, uint8_t *dest, int dstW,
- const uint8_t *dither, int offset)
-{
- int i;
- for (i=0; i<dstW; i++) {
- int val = (src[i] + dither[(i + offset) & 7]) >> 7;
- dest[i]= av_clip_uint8(val);
- }
-}
-
-static void yuv2nv12cX_c(SwsContext *c, const int16_t *chrFilter, int chrFilterSize,
- const int16_t **chrUSrc, const int16_t **chrVSrc,
- uint8_t *dest, int chrDstW)
-{
- enum AVPixelFormat dstFormat = c->dstFormat;
- const uint8_t *chrDither = c->chrDither8;
- int i;
-
- if (dstFormat == AV_PIX_FMT_NV12)
- for (i=0; i<chrDstW; i++) {
- int u = chrDither[i & 7] << 12;
- int v = chrDither[(i + 3) & 7] << 12;
- int j;
- for (j=0; j<chrFilterSize; j++) {
- u += chrUSrc[j][i] * chrFilter[j];
- v += chrVSrc[j][i] * chrFilter[j];
- }
-
- dest[2*i]= av_clip_uint8(u>>19);
- dest[2*i+1]= av_clip_uint8(v>>19);
- }
- else
- for (i=0; i<chrDstW; i++) {
- int u = chrDither[i & 7] << 12;
- int v = chrDither[(i + 3) & 7] << 12;
- int j;
- for (j=0; j<chrFilterSize; j++) {
- u += chrUSrc[j][i] * chrFilter[j];
- v += chrVSrc[j][i] * chrFilter[j];
- }
-
- dest[2*i]= av_clip_uint8(v>>19);
- dest[2*i+1]= av_clip_uint8(u>>19);
- }
-}
-
-#define accumulate_bit(acc, val) \
- acc <<= 1; \
- acc |= (val) >= (128 + 110)
-#define output_pixel(pos, acc) \
- if (target == AV_PIX_FMT_MONOBLACK) { \
- pos = acc; \
- } else { \
- pos = ~acc; \
- }
-
-static av_always_inline void
-yuv2mono_X_c_template(SwsContext *c, const int16_t *lumFilter,
- const int16_t **lumSrc, int lumFilterSize,
- const int16_t *chrFilter, const int16_t **chrUSrc,
- const int16_t **chrVSrc, int chrFilterSize,
- const int16_t **alpSrc, uint8_t *dest, int dstW,
- int y, enum AVPixelFormat target)
-{
- const uint8_t * const d128=dither_8x8_220[y&7];
- int i;
- unsigned acc = 0;
- int err = 0;
-
- for (i = 0; i < dstW; i += 2) {
- int j;
- int Y1 = 1 << 18;
- int Y2 = 1 << 18;
-
- for (j = 0; j < lumFilterSize; j++) {
- Y1 += lumSrc[j][i] * lumFilter[j];
- Y2 += lumSrc[j][i+1] * lumFilter[j];
- }
- Y1 >>= 19;
- Y2 >>= 19;
- if ((Y1 | Y2) & 0x100) {
- Y1 = av_clip_uint8(Y1);
- Y2 = av_clip_uint8(Y2);
- }
- if (c->flags & SWS_ERROR_DIFFUSION) {
- Y1 += (7*err + 1*c->dither_error[0][i] + 5*c->dither_error[0][i+1] + 3*c->dither_error[0][i+2] + 8 - 256)>>4;
- c->dither_error[0][i] = err;
- acc = 2*acc + (Y1 >= 128);
- Y1 -= 220*(acc&1);
-
- err = Y2 + ((7*Y1 + 1*c->dither_error[0][i+1] + 5*c->dither_error[0][i+2] + 3*c->dither_error[0][i+3] + 8 - 256)>>4);
- c->dither_error[0][i+1] = Y1;
- acc = 2*acc + (err >= 128);
- err -= 220*(acc&1);
- } else {
- accumulate_bit(acc, Y1 + d128[(i + 0) & 7]);
- accumulate_bit(acc, Y2 + d128[(i + 1) & 7]);
- }
- if ((i & 7) == 6) {
- output_pixel(*dest++, acc);
- }
- }
- c->dither_error[0][i] = err;
-
- if (i & 6) {
- output_pixel(*dest, acc);
- }
-}
-
-static av_always_inline void
-yuv2mono_2_c_template(SwsContext *c, const int16_t *buf[2],
- const int16_t *ubuf[2], const int16_t *vbuf[2],
- const int16_t *abuf[2], uint8_t *dest, int dstW,
- int yalpha, int uvalpha, int y,
- enum AVPixelFormat target)
-{
- const int16_t *buf0 = buf[0], *buf1 = buf[1];
- const uint8_t * const d128 = dither_8x8_220[y & 7];
- int yalpha1 = 4096 - yalpha;
- int i;
-
- if (c->flags & SWS_ERROR_DIFFUSION) {
- int err = 0;
- int acc = 0;
- for (i = 0; i < dstW; i +=2) {
- int Y;
-
- Y = (buf0[i + 0] * yalpha1 + buf1[i + 0] * yalpha) >> 19;
- Y += (7*err + 1*c->dither_error[0][i] + 5*c->dither_error[0][i+1] + 3*c->dither_error[0][i+2] + 8 - 256)>>4;
- c->dither_error[0][i] = err;
- acc = 2*acc + (Y >= 128);
- Y -= 220*(acc&1);
-
- err = (buf0[i + 1] * yalpha1 + buf1[i + 1] * yalpha) >> 19;
- err += (7*Y + 1*c->dither_error[0][i+1] + 5*c->dither_error[0][i+2] + 3*c->dither_error[0][i+3] + 8 - 256)>>4;
- c->dither_error[0][i+1] = Y;
- acc = 2*acc + (err >= 128);
- err -= 220*(acc&1);
-
- if ((i & 7) == 6)
- output_pixel(*dest++, acc);
- }
- c->dither_error[0][i] = err;
- } else {
- for (i = 0; i < dstW; i += 8) {
- int Y, acc = 0;
-
- Y = (buf0[i + 0] * yalpha1 + buf1[i + 0] * yalpha) >> 19;
- accumulate_bit(acc, Y + d128[0]);
- Y = (buf0[i + 1] * yalpha1 + buf1[i + 1] * yalpha) >> 19;
- accumulate_bit(acc, Y + d128[1]);
- Y = (buf0[i + 2] * yalpha1 + buf1[i + 2] * yalpha) >> 19;
- accumulate_bit(acc, Y + d128[2]);
- Y = (buf0[i + 3] * yalpha1 + buf1[i + 3] * yalpha) >> 19;
- accumulate_bit(acc, Y + d128[3]);
- Y = (buf0[i + 4] * yalpha1 + buf1[i + 4] * yalpha) >> 19;
- accumulate_bit(acc, Y + d128[4]);
- Y = (buf0[i + 5] * yalpha1 + buf1[i + 5] * yalpha) >> 19;
- accumulate_bit(acc, Y + d128[5]);
- Y = (buf0[i + 6] * yalpha1 + buf1[i + 6] * yalpha) >> 19;
- accumulate_bit(acc, Y + d128[6]);
- Y = (buf0[i + 7] * yalpha1 + buf1[i + 7] * yalpha) >> 19;
- accumulate_bit(acc, Y + d128[7]);
-
- output_pixel(*dest++, acc);
- }
- }
-}
-
-static av_always_inline void
-yuv2mono_1_c_template(SwsContext *c, const int16_t *buf0,
- const int16_t *ubuf[2], const int16_t *vbuf[2],
- const int16_t *abuf0, uint8_t *dest, int dstW,
- int uvalpha, int y, enum AVPixelFormat target)
-{
- const uint8_t * const d128 = dither_8x8_220[y & 7];
- int i;
-
- if (c->flags & SWS_ERROR_DIFFUSION) {
- int err = 0;
- int acc = 0;
- for (i = 0; i < dstW; i +=2) {
- int Y;
-
- Y = ((buf0[i + 0] + 64) >> 7);
- Y += (7*err + 1*c->dither_error[0][i] + 5*c->dither_error[0][i+1] + 3*c->dither_error[0][i+2] + 8 - 256)>>4;
- c->dither_error[0][i] = err;
- acc = 2*acc + (Y >= 128);
- Y -= 220*(acc&1);
-
- err = ((buf0[i + 1] + 64) >> 7);
- err += (7*Y + 1*c->dither_error[0][i+1] + 5*c->dither_error[0][i+2] + 3*c->dither_error[0][i+3] + 8 - 256)>>4;
- c->dither_error[0][i+1] = Y;
- acc = 2*acc + (err >= 128);
- err -= 220*(acc&1);
-
- if ((i & 7) == 6)
- output_pixel(*dest++, acc);
- }
- c->dither_error[0][i] = err;
- } else {
- for (i = 0; i < dstW; i += 8) {
- int acc = 0;
- accumulate_bit(acc, ((buf0[i + 0] + 64) >> 7) + d128[0]);
- accumulate_bit(acc, ((buf0[i + 1] + 64) >> 7) + d128[1]);
- accumulate_bit(acc, ((buf0[i + 2] + 64) >> 7) + d128[2]);
- accumulate_bit(acc, ((buf0[i + 3] + 64) >> 7) + d128[3]);
- accumulate_bit(acc, ((buf0[i + 4] + 64) >> 7) + d128[4]);
- accumulate_bit(acc, ((buf0[i + 5] + 64) >> 7) + d128[5]);
- accumulate_bit(acc, ((buf0[i + 6] + 64) >> 7) + d128[6]);
- accumulate_bit(acc, ((buf0[i + 7] + 64) >> 7) + d128[7]);
-
- output_pixel(*dest++, acc);
- }
- }
-}
-
-#undef output_pixel
-#undef accumulate_bit
-
-#define YUV2PACKEDWRAPPER(name, base, ext, fmt) \
-static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \
- const int16_t **lumSrc, int lumFilterSize, \
- const int16_t *chrFilter, const int16_t **chrUSrc, \
- const int16_t **chrVSrc, int chrFilterSize, \
- const int16_t **alpSrc, uint8_t *dest, int dstW, \
- int y) \
-{ \
- name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
- chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
- alpSrc, dest, dstW, y, fmt); \
-} \
- \
-static void name ## ext ## _2_c(SwsContext *c, const int16_t *buf[2], \
- const int16_t *ubuf[2], const int16_t *vbuf[2], \
- const int16_t *abuf[2], uint8_t *dest, int dstW, \
- int yalpha, int uvalpha, int y) \
-{ \
- name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
- dest, dstW, yalpha, uvalpha, y, fmt); \
-} \
- \
-static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \
- const int16_t *ubuf[2], const int16_t *vbuf[2], \
- const int16_t *abuf0, uint8_t *dest, int dstW, \
- int uvalpha, int y) \
-{ \
- name ## base ## _1_c_template(c, buf0, ubuf, vbuf, \
- abuf0, dest, dstW, uvalpha, \
- y, fmt); \
-}
-
-YUV2PACKEDWRAPPER(yuv2mono,, white, AV_PIX_FMT_MONOWHITE)
-YUV2PACKEDWRAPPER(yuv2mono,, black, AV_PIX_FMT_MONOBLACK)
-
-#define output_pixels(pos, Y1, U, Y2, V) \
- if (target == AV_PIX_FMT_YUYV422) { \
- dest[pos + 0] = Y1; \
- dest[pos + 1] = U; \
- dest[pos + 2] = Y2; \
- dest[pos + 3] = V; \
- } else { \
- dest[pos + 0] = U; \
- dest[pos + 1] = Y1; \
- dest[pos + 2] = V; \
- dest[pos + 3] = Y2; \
- }
-
-static av_always_inline void
-yuv2422_X_c_template(SwsContext *c, const int16_t *lumFilter,
- const int16_t **lumSrc, int lumFilterSize,
- const int16_t *chrFilter, const int16_t **chrUSrc,
- const int16_t **chrVSrc, int chrFilterSize,
- const int16_t **alpSrc, uint8_t *dest, int dstW,
- int y, enum AVPixelFormat target)
-{
- int i;
-
- for (i = 0; i < ((dstW + 1) >> 1); i++) {
- int j;
- int Y1 = 1 << 18;
- int Y2 = 1 << 18;
- int U = 1 << 18;
- int V = 1 << 18;
-
- for (j = 0; j < lumFilterSize; j++) {
- Y1 += lumSrc[j][i * 2] * lumFilter[j];
- Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j];
- }
- for (j = 0; j < chrFilterSize; j++) {
- U += chrUSrc[j][i] * chrFilter[j];
- V += chrVSrc[j][i] * chrFilter[j];
- }
- Y1 >>= 19;
- Y2 >>= 19;
- U >>= 19;
- V >>= 19;
- if ((Y1 | Y2 | U | V) & 0x100) {
- Y1 = av_clip_uint8(Y1);
- Y2 = av_clip_uint8(Y2);
- U = av_clip_uint8(U);
- V = av_clip_uint8(V);
- }
- output_pixels(4*i, Y1, U, Y2, V);
- }
-}
-
-static av_always_inline void
-yuv2422_2_c_template(SwsContext *c, const int16_t *buf[2],
- const int16_t *ubuf[2], const int16_t *vbuf[2],
- const int16_t *abuf[2], uint8_t *dest, int dstW,
- int yalpha, int uvalpha, int y,
- enum AVPixelFormat target)
-{
- const int16_t *buf0 = buf[0], *buf1 = buf[1],
- *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
- *vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
- int yalpha1 = 4096 - yalpha;
- int uvalpha1 = 4096 - uvalpha;
- int i;
-
- for (i = 0; i < ((dstW + 1) >> 1); i++) {
- int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19;
- int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19;
- int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;
- int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19;
-
- if ((Y1 | Y2 | U | V) & 0x100) {
- Y1 = av_clip_uint8(Y1);
- Y2 = av_clip_uint8(Y2);
- U = av_clip_uint8(U);
- V = av_clip_uint8(V);
- }
-
- output_pixels(i * 4, Y1, U, Y2, V);
- }
-}
-
-static av_always_inline void
-yuv2422_1_c_template(SwsContext *c, const int16_t *buf0,
- const int16_t *ubuf[2], const int16_t *vbuf[2],
- const int16_t *abuf0, uint8_t *dest, int dstW,
- int uvalpha, int y, enum AVPixelFormat target)
-{
- const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
- int i;
-
- if (uvalpha < 2048) {
- for (i = 0; i < ((dstW + 1) >> 1); i++) {
- int Y1 = (buf0[i * 2 ]+64) >> 7;
- int Y2 = (buf0[i * 2 + 1]+64) >> 7;
- int U = (ubuf0[i] +64) >> 7;
- int V = (vbuf0[i] +64) >> 7;
-
- if ((Y1 | Y2 | U | V) & 0x100) {
- Y1 = av_clip_uint8(Y1);
- Y2 = av_clip_uint8(Y2);
- U = av_clip_uint8(U);
- V = av_clip_uint8(V);
- }
-
- Y1 = av_clip_uint8(Y1);
- Y2 = av_clip_uint8(Y2);
- U = av_clip_uint8(U);
- V = av_clip_uint8(V);
-
- output_pixels(i * 4, Y1, U, Y2, V);
- }
- } else {
- const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
- for (i = 0; i < ((dstW + 1) >> 1); i++) {
- int Y1 = (buf0[i * 2 ] + 64) >> 7;
- int Y2 = (buf0[i * 2 + 1] + 64) >> 7;
- int U = (ubuf0[i] + ubuf1[i]+128) >> 8;
- int V = (vbuf0[i] + vbuf1[i]+128) >> 8;
-
- if ((Y1 | Y2 | U | V) & 0x100) {
- Y1 = av_clip_uint8(Y1);
- Y2 = av_clip_uint8(Y2);
- U = av_clip_uint8(U);
- V = av_clip_uint8(V);
- }
-
- Y1 = av_clip_uint8(Y1);
- Y2 = av_clip_uint8(Y2);
- U = av_clip_uint8(U);
- V = av_clip_uint8(V);
-
- output_pixels(i * 4, Y1, U, Y2, V);
- }
- }
-}
-
-#undef output_pixels
-
-YUV2PACKEDWRAPPER(yuv2, 422, yuyv422, AV_PIX_FMT_YUYV422)
-YUV2PACKEDWRAPPER(yuv2, 422, uyvy422, AV_PIX_FMT_UYVY422)
-
-#define R_B ((target == AV_PIX_FMT_RGB48LE || target == AV_PIX_FMT_RGB48BE) ? R : B)
-#define B_R ((target == AV_PIX_FMT_RGB48LE || target == AV_PIX_FMT_RGB48BE) ? B : R)
-#define output_pixel(pos, val) \
- if (isBE(target)) { \
- AV_WB16(pos, val); \
- } else { \
- AV_WL16(pos, val); \
- }
-
-static av_always_inline void
-yuv2rgb48_X_c_template(SwsContext *c, const int16_t *lumFilter,
- const int32_t **lumSrc, int lumFilterSize,
- const int16_t *chrFilter, const int32_t **chrUSrc,
- const int32_t **chrVSrc, int chrFilterSize,
- const int32_t **alpSrc, uint16_t *dest, int dstW,
- int y, enum AVPixelFormat target)
-{
- int i;
-
- for (i = 0; i < ((dstW + 1) >> 1); i++) {
- int j;
- int Y1 = -0x40000000;
- int Y2 = -0x40000000;
- int U = -128 << 23; // 19
- int V = -128 << 23;
- int R, G, B;
-
- for (j = 0; j < lumFilterSize; j++) {
- Y1 += lumSrc[j][i * 2] * (unsigned)lumFilter[j];
- Y2 += lumSrc[j][i * 2 + 1] * (unsigned)lumFilter[j];
- }
- for (j = 0; j < chrFilterSize; j++) {;
- U += chrUSrc[j][i] * (unsigned)chrFilter[j];
- V += chrVSrc[j][i] * (unsigned)chrFilter[j];
- }
-
- // 8bit: 12+15=27; 16-bit: 12+19=31
- Y1 >>= 14; // 10
- Y1 += 0x10000;
- Y2 >>= 14;
- Y2 += 0x10000;
- U >>= 14;
- V >>= 14;
-
- // 8bit: 27 -> 17bit, 16bit: 31 - 14 = 17bit
- Y1 -= c->yuv2rgb_y_offset;
- Y2 -= c->yuv2rgb_y_offset;
- Y1 *= c->yuv2rgb_y_coeff;
- Y2 *= c->yuv2rgb_y_coeff;
- Y1 += 1 << 13; // 21
- Y2 += 1 << 13;
- // 8bit: 17 + 13bit = 30bit, 16bit: 17 + 13bit = 30bit
-
- R = V * c->yuv2rgb_v2r_coeff;
- G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
- B = U * c->yuv2rgb_u2b_coeff;
-
- // 8bit: 30 - 22 = 8bit, 16bit: 30bit - 14 = 16bit
- output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14);
- output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
- output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14);
- output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14);
- output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14);
- output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14);
- dest += 6;
- }
-}
-
-static av_always_inline void
-yuv2rgb48_2_c_template(SwsContext *c, const int32_t *buf[2],
- const int32_t *ubuf[2], const int32_t *vbuf[2],
- const int32_t *abuf[2], uint16_t *dest, int dstW,
- int yalpha, int uvalpha, int y,
- enum AVPixelFormat target)
-{
- const int32_t *buf0 = buf[0], *buf1 = buf[1],
- *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
- *vbuf0 = vbuf[0], *vbuf1 = vbuf[1];
- int yalpha1 = 4096 - yalpha;
- int uvalpha1 = 4096 - uvalpha;
- int i;
-
- for (i = 0; i < ((dstW + 1) >> 1); i++) {
- int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 14;
- int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 14;
- int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha + (-128 << 23)) >> 14;
- int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha + (-128 << 23)) >> 14;
- int R, G, B;
-
- Y1 -= c->yuv2rgb_y_offset;
- Y2 -= c->yuv2rgb_y_offset;
- Y1 *= c->yuv2rgb_y_coeff;
- Y2 *= c->yuv2rgb_y_coeff;
- Y1 += 1 << 13;
- Y2 += 1 << 13;
-
- R = V * c->yuv2rgb_v2r_coeff;
- G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
- B = U * c->yuv2rgb_u2b_coeff;
-
- output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14);
- output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
- output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14);
- output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14);
- output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14);
- output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14);
- dest += 6;
- }
-}
-
-static av_always_inline void
-yuv2rgb48_1_c_template(SwsContext *c, const int32_t *buf0,
- const int32_t *ubuf[2], const int32_t *vbuf[2],
- const int32_t *abuf0, uint16_t *dest, int dstW,
- int uvalpha, int y, enum AVPixelFormat target)
-{
- const int32_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
- int i;
-
- if (uvalpha < 2048) {
- for (i = 0; i < ((dstW + 1) >> 1); i++) {
- int Y1 = (buf0[i * 2] ) >> 2;
- int Y2 = (buf0[i * 2 + 1]) >> 2;
- int U = (ubuf0[i] + (-128 << 11)) >> 2;
- int V = (vbuf0[i] + (-128 << 11)) >> 2;
- int R, G, B;
-
- Y1 -= c->yuv2rgb_y_offset;
- Y2 -= c->yuv2rgb_y_offset;
- Y1 *= c->yuv2rgb_y_coeff;
- Y2 *= c->yuv2rgb_y_coeff;
- Y1 += 1 << 13;
- Y2 += 1 << 13;
-
- R = V * c->yuv2rgb_v2r_coeff;
- G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
- B = U * c->yuv2rgb_u2b_coeff;
-
- output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14);
- output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
- output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14);
- output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14);
- output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14);
- output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14);
- dest += 6;
- }
- } else {
- const int32_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
- for (i = 0; i < ((dstW + 1) >> 1); i++) {
- int Y1 = (buf0[i * 2] ) >> 2;
- int Y2 = (buf0[i * 2 + 1]) >> 2;
- int U = (ubuf0[i] + ubuf1[i] + (-128 << 12)) >> 3;
- int V = (vbuf0[i] + vbuf1[i] + (-128 << 12)) >> 3;
- int R, G, B;
-
- Y1 -= c->yuv2rgb_y_offset;
- Y2 -= c->yuv2rgb_y_offset;
- Y1 *= c->yuv2rgb_y_coeff;
- Y2 *= c->yuv2rgb_y_coeff;
- Y1 += 1 << 13;
- Y2 += 1 << 13;
-
- R = V * c->yuv2rgb_v2r_coeff;
- G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
- B = U * c->yuv2rgb_u2b_coeff;
-
- output_pixel(&dest[0], av_clip_uintp2(R_B + Y1, 30) >> 14);
- output_pixel(&dest[1], av_clip_uintp2( G + Y1, 30) >> 14);
- output_pixel(&dest[2], av_clip_uintp2(B_R + Y1, 30) >> 14);
- output_pixel(&dest[3], av_clip_uintp2(R_B + Y2, 30) >> 14);
- output_pixel(&dest[4], av_clip_uintp2( G + Y2, 30) >> 14);
- output_pixel(&dest[5], av_clip_uintp2(B_R + Y2, 30) >> 14);
- dest += 6;
- }
- }
-}
-
-#undef output_pixel
-#undef r_b
-#undef b_r
-
-#define YUV2PACKED16WRAPPER(name, base, ext, fmt) \
-static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \
- const int16_t **_lumSrc, int lumFilterSize, \
- const int16_t *chrFilter, const int16_t **_chrUSrc, \
- const int16_t **_chrVSrc, int chrFilterSize, \
- const int16_t **_alpSrc, uint8_t *_dest, int dstW, \
- int y) \
-{ \
- const int32_t **lumSrc = (const int32_t **) _lumSrc, \
- **chrUSrc = (const int32_t **) _chrUSrc, \
- **chrVSrc = (const int32_t **) _chrVSrc, \
- **alpSrc = (const int32_t **) _alpSrc; \
- uint16_t *dest = (uint16_t *) _dest; \
- name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
- chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
- alpSrc, dest, dstW, y, fmt); \
-} \
- \
-static void name ## ext ## _2_c(SwsContext *c, const int16_t *_buf[2], \
- const int16_t *_ubuf[2], const int16_t *_vbuf[2], \
- const int16_t *_abuf[2], uint8_t *_dest, int dstW, \
- int yalpha, int uvalpha, int y) \
-{ \
- const int32_t **buf = (const int32_t **) _buf, \
- **ubuf = (const int32_t **) _ubuf, \
- **vbuf = (const int32_t **) _vbuf, \
- **abuf = (const int32_t **) _abuf; \
- uint16_t *dest = (uint16_t *) _dest; \
- name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
- dest, dstW, yalpha, uvalpha, y, fmt); \
-} \
- \
-static void name ## ext ## _1_c(SwsContext *c, const int16_t *_buf0, \
- const int16_t *_ubuf[2], const int16_t *_vbuf[2], \
- const int16_t *_abuf0, uint8_t *_dest, int dstW, \
- int uvalpha, int y) \
-{ \
- const int32_t *buf0 = (const int32_t *) _buf0, \
- **ubuf = (const int32_t **) _ubuf, \
- **vbuf = (const int32_t **) _vbuf, \
- *abuf0 = (const int32_t *) _abuf0; \
- uint16_t *dest = (uint16_t *) _dest; \
- name ## base ## _1_c_template(c, buf0, ubuf, vbuf, abuf0, dest, \
- dstW, uvalpha, y, fmt); \
-}
-
-YUV2PACKED16WRAPPER(yuv2, rgb48, rgb48be, AV_PIX_FMT_RGB48BE)
-YUV2PACKED16WRAPPER(yuv2, rgb48, rgb48le, AV_PIX_FMT_RGB48LE)
-YUV2PACKED16WRAPPER(yuv2, rgb48, bgr48be, AV_PIX_FMT_BGR48BE)
-YUV2PACKED16WRAPPER(yuv2, rgb48, bgr48le, AV_PIX_FMT_BGR48LE)
-
-/*
- * Write out 2 RGB pixels in the target pixel format. This function takes a
- * R/G/B LUT as generated by ff_yuv2rgb_c_init_tables(), which takes care of
- * things like endianness conversion and shifting. The caller takes care of
- * setting the correct offset in these tables from the chroma (U/V) values.
- * This function then uses the luminance (Y1/Y2) values to write out the
- * correct RGB values into the destination buffer.
- */
-static av_always_inline void
-yuv2rgb_write(uint8_t *_dest, int i, int Y1, int Y2,
- unsigned A1, unsigned A2,
- const void *_r, const void *_g, const void *_b, int y,
- enum AVPixelFormat target, int hasAlpha)
-{
- if (target == AV_PIX_FMT_ARGB || target == AV_PIX_FMT_RGBA ||
- target == AV_PIX_FMT_ABGR || target == AV_PIX_FMT_BGRA) {
- uint32_t *dest = (uint32_t *) _dest;
- const uint32_t *r = (const uint32_t *) _r;
- const uint32_t *g = (const uint32_t *) _g;
- const uint32_t *b = (const uint32_t *) _b;
-
-#if CONFIG_SMALL
- int sh = hasAlpha ? ((target == AV_PIX_FMT_RGB32_1 || target == AV_PIX_FMT_BGR32_1) ? 0 : 24) : 0;
-
- dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1] + (hasAlpha ? A1 << sh : 0);
- dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2] + (hasAlpha ? A2 << sh : 0);
-#else
- if (hasAlpha) {
- int sh = (target == AV_PIX_FMT_RGB32_1 || target == AV_PIX_FMT_BGR32_1) ? 0 : 24;
-
- dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1] + (A1 << sh);
- dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2] + (A2 << sh);
- } else {
- dest[i * 2 + 0] = r[Y1] + g[Y1] + b[Y1];
- dest[i * 2 + 1] = r[Y2] + g[Y2] + b[Y2];
- }
-#endif
- } else if (target == AV_PIX_FMT_RGB24 || target == AV_PIX_FMT_BGR24) {
- uint8_t *dest = (uint8_t *) _dest;
- const uint8_t *r = (const uint8_t *) _r;
- const uint8_t *g = (const uint8_t *) _g;
- const uint8_t *b = (const uint8_t *) _b;
-
-#define r_b ((target == AV_PIX_FMT_RGB24) ? r : b)
-#define b_r ((target == AV_PIX_FMT_RGB24) ? b : r)
-
- dest[i * 6 + 0] = r_b[Y1];
- dest[i * 6 + 1] = g[Y1];
- dest[i * 6 + 2] = b_r[Y1];
- dest[i * 6 + 3] = r_b[Y2];
- dest[i * 6 + 4] = g[Y2];
- dest[i * 6 + 5] = b_r[Y2];
-#undef r_b
-#undef b_r
- } else if (target == AV_PIX_FMT_RGB565 || target == AV_PIX_FMT_BGR565 ||
- target == AV_PIX_FMT_RGB555 || target == AV_PIX_FMT_BGR555 ||
- target == AV_PIX_FMT_RGB444 || target == AV_PIX_FMT_BGR444) {
- uint16_t *dest = (uint16_t *) _dest;
- const uint16_t *r = (const uint16_t *) _r;
- const uint16_t *g = (const uint16_t *) _g;
- const uint16_t *b = (const uint16_t *) _b;
- int dr1, dg1, db1, dr2, dg2, db2;
-
- if (target == AV_PIX_FMT_RGB565 || target == AV_PIX_FMT_BGR565) {
- dr1 = dither_2x2_8[ y & 1 ][0];
- dg1 = dither_2x2_4[ y & 1 ][0];
- db1 = dither_2x2_8[(y & 1) ^ 1][0];
- dr2 = dither_2x2_8[ y & 1 ][1];
- dg2 = dither_2x2_4[ y & 1 ][1];
- db2 = dither_2x2_8[(y & 1) ^ 1][1];
- } else if (target == AV_PIX_FMT_RGB555 || target == AV_PIX_FMT_BGR555) {
- dr1 = dither_2x2_8[ y & 1 ][0];
- dg1 = dither_2x2_8[ y & 1 ][1];
- db1 = dither_2x2_8[(y & 1) ^ 1][0];
- dr2 = dither_2x2_8[ y & 1 ][1];
- dg2 = dither_2x2_8[ y & 1 ][0];
- db2 = dither_2x2_8[(y & 1) ^ 1][1];
- } else {
- dr1 = dither_4x4_16[ y & 3 ][0];
- dg1 = dither_4x4_16[ y & 3 ][1];
- db1 = dither_4x4_16[(y & 3) ^ 3][0];
- dr2 = dither_4x4_16[ y & 3 ][1];
- dg2 = dither_4x4_16[ y & 3 ][0];
- db2 = dither_4x4_16[(y & 3) ^ 3][1];
- }
-
- dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1];
- dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2];
- } else /* 8/4-bit */ {
- uint8_t *dest = (uint8_t *) _dest;
- const uint8_t *r = (const uint8_t *) _r;
- const uint8_t *g = (const uint8_t *) _g;
- const uint8_t *b = (const uint8_t *) _b;
- int dr1, dg1, db1, dr2, dg2, db2;
-
- if (target == AV_PIX_FMT_RGB8 || target == AV_PIX_FMT_BGR8) {
- const uint8_t * const d64 = dither_8x8_73[y & 7];
- const uint8_t * const d32 = dither_8x8_32[y & 7];
- dr1 = dg1 = d32[(i * 2 + 0) & 7];
- db1 = d64[(i * 2 + 0) & 7];
- dr2 = dg2 = d32[(i * 2 + 1) & 7];
- db2 = d64[(i * 2 + 1) & 7];
- } else {
- const uint8_t * const d64 = dither_8x8_73 [y & 7];
- const uint8_t * const d128 = dither_8x8_220[y & 7];
- dr1 = db1 = d128[(i * 2 + 0) & 7];
- dg1 = d64[(i * 2 + 0) & 7];
- dr2 = db2 = d128[(i * 2 + 1) & 7];
- dg2 = d64[(i * 2 + 1) & 7];
- }
-
- if (target == AV_PIX_FMT_RGB4 || target == AV_PIX_FMT_BGR4) {
- dest[i] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1] +
- ((r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2]) << 4);
- } else {
- dest[i * 2 + 0] = r[Y1 + dr1] + g[Y1 + dg1] + b[Y1 + db1];
- dest[i * 2 + 1] = r[Y2 + dr2] + g[Y2 + dg2] + b[Y2 + db2];
- }
- }
-}
-
-static av_always_inline void
-yuv2rgb_X_c_template(SwsContext *c, const int16_t *lumFilter,
- const int16_t **lumSrc, int lumFilterSize,
- const int16_t *chrFilter, const int16_t **chrUSrc,
- const int16_t **chrVSrc, int chrFilterSize,
- const int16_t **alpSrc, uint8_t *dest, int dstW,
- int y, enum AVPixelFormat target, int hasAlpha)
-{
- int i;
-
- for (i = 0; i < ((dstW + 1) >> 1); i++) {
- int j, A1, A2;
- int Y1 = 1 << 18;
- int Y2 = 1 << 18;
- int U = 1 << 18;
- int V = 1 << 18;
- const void *r, *g, *b;
-
- for (j = 0; j < lumFilterSize; j++) {
- Y1 += lumSrc[j][i * 2] * lumFilter[j];
- Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j];
- }
- for (j = 0; j < chrFilterSize; j++) {
- U += chrUSrc[j][i] * chrFilter[j];
- V += chrVSrc[j][i] * chrFilter[j];
- }
- Y1 >>= 19;
- Y2 >>= 19;
- U >>= 19;
- V >>= 19;
- if (hasAlpha) {
- A1 = 1 << 18;
- A2 = 1 << 18;
- for (j = 0; j < lumFilterSize; j++) {
- A1 += alpSrc[j][i * 2 ] * lumFilter[j];
- A2 += alpSrc[j][i * 2 + 1] * lumFilter[j];
- }
- A1 >>= 19;
- A2 >>= 19;
- if ((A1 | A2) & 0x100) {
- A1 = av_clip_uint8(A1);
- A2 = av_clip_uint8(A2);
- }
- }
-
- r = c->table_rV[V + YUVRGB_TABLE_HEADROOM];
- g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + YUVRGB_TABLE_HEADROOM]);
- b = c->table_bU[U + YUVRGB_TABLE_HEADROOM];
-
- yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
- r, g, b, y, target, hasAlpha);
- }
-}
-
-static av_always_inline void
-yuv2rgb_2_c_template(SwsContext *c, const int16_t *buf[2],
- const int16_t *ubuf[2], const int16_t *vbuf[2],
- const int16_t *abuf[2], uint8_t *dest, int dstW,
- int yalpha, int uvalpha, int y,
- enum AVPixelFormat target, int hasAlpha)
-{
- const int16_t *buf0 = buf[0], *buf1 = buf[1],
- *ubuf0 = ubuf[0], *ubuf1 = ubuf[1],
- *vbuf0 = vbuf[0], *vbuf1 = vbuf[1],
- *abuf0 = hasAlpha ? abuf[0] : NULL,
- *abuf1 = hasAlpha ? abuf[1] : NULL;
- int yalpha1 = 4096 - yalpha;
- int uvalpha1 = 4096 - uvalpha;
- int i;
-
- for (i = 0; i < ((dstW + 1) >> 1); i++) {
- int Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 19;
- int Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 19;
- int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha) >> 19;
- int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha) >> 19;
- int A1, A2;
- const void *r = c->table_rV[V + YUVRGB_TABLE_HEADROOM],
- *g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + YUVRGB_TABLE_HEADROOM]),
- *b = c->table_bU[U + YUVRGB_TABLE_HEADROOM];
-
- if (hasAlpha) {
- A1 = (abuf0[i * 2 ] * yalpha1 + abuf1[i * 2 ] * yalpha) >> 19;
- A2 = (abuf0[i * 2 + 1] * yalpha1 + abuf1[i * 2 + 1] * yalpha) >> 19;
- A1 = av_clip_uint8(A1);
- A2 = av_clip_uint8(A2);
- }
-
- yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
- r, g, b, y, target, hasAlpha);
- }
-}
-
-static av_always_inline void
-yuv2rgb_1_c_template(SwsContext *c, const int16_t *buf0,
- const int16_t *ubuf[2], const int16_t *vbuf[2],
- const int16_t *abuf0, uint8_t *dest, int dstW,
- int uvalpha, int y, enum AVPixelFormat target,
- int hasAlpha)
-{
- const int16_t *ubuf0 = ubuf[0], *vbuf0 = vbuf[0];
- int i;
-
- if (uvalpha < 2048) {
- for (i = 0; i < ((dstW + 1) >> 1); i++) {
- int Y1 = (buf0[i * 2 ] + 64) >> 7;
- int Y2 = (buf0[i * 2 + 1] + 64) >> 7;
- int U = (ubuf0[i] + 64) >> 7;
- int V = (vbuf0[i] + 64) >> 7;
- int A1, A2;
- const void *r = c->table_rV[V + YUVRGB_TABLE_HEADROOM],
- *g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + YUVRGB_TABLE_HEADROOM]),
- *b = c->table_bU[U + YUVRGB_TABLE_HEADROOM];
-
- if (hasAlpha) {
- A1 = abuf0[i * 2 ] * 255 + 16384 >> 15;
- A2 = abuf0[i * 2 + 1] * 255 + 16384 >> 15;
- A1 = av_clip_uint8(A1);
- A2 = av_clip_uint8(A2);
- }
-
- yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
- r, g, b, y, target, hasAlpha);
- }
- } else {
- const int16_t *ubuf1 = ubuf[1], *vbuf1 = vbuf[1];
- for (i = 0; i < ((dstW + 1) >> 1); i++) {
- int Y1 = (buf0[i * 2 ] + 64) >> 7;
- int Y2 = (buf0[i * 2 + 1] + 64) >> 7;
- int U = (ubuf0[i] + ubuf1[i] + 128) >> 8;
- int V = (vbuf0[i] + vbuf1[i] + 128) >> 8;
- int A1, A2;
- const void *r = c->table_rV[V + YUVRGB_TABLE_HEADROOM],
- *g = (c->table_gU[U + YUVRGB_TABLE_HEADROOM] + c->table_gV[V + YUVRGB_TABLE_HEADROOM]),
- *b = c->table_bU[U + YUVRGB_TABLE_HEADROOM];
-
- if (hasAlpha) {
- A1 = (abuf0[i * 2 ] + 64) >> 7;
- A2 = (abuf0[i * 2 + 1] + 64) >> 7;
- A1 = av_clip_uint8(A1);
- A2 = av_clip_uint8(A2);
- }
-
- yuv2rgb_write(dest, i, Y1, Y2, hasAlpha ? A1 : 0, hasAlpha ? A2 : 0,
- r, g, b, y, target, hasAlpha);
- }
- }
-}
-
-#define YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha) \
-static void name ## ext ## _X_c(SwsContext *c, const int16_t *lumFilter, \
- const int16_t **lumSrc, int lumFilterSize, \
- const int16_t *chrFilter, const int16_t **chrUSrc, \
- const int16_t **chrVSrc, int chrFilterSize, \
- const int16_t **alpSrc, uint8_t *dest, int dstW, \
- int y) \
-{ \
- name ## base ## _X_c_template(c, lumFilter, lumSrc, lumFilterSize, \
- chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
- alpSrc, dest, dstW, y, fmt, hasAlpha); \
-}
-#define YUV2RGBWRAPPER(name, base, ext, fmt, hasAlpha) \
-YUV2RGBWRAPPERX(name, base, ext, fmt, hasAlpha) \
-static void name ## ext ## _2_c(SwsContext *c, const int16_t *buf[2], \
- const int16_t *ubuf[2], const int16_t *vbuf[2], \
- const int16_t *abuf[2], uint8_t *dest, int dstW, \
- int yalpha, int uvalpha, int y) \
-{ \
- name ## base ## _2_c_template(c, buf, ubuf, vbuf, abuf, \
- dest, dstW, yalpha, uvalpha, y, fmt, hasAlpha); \
-} \
- \
-static void name ## ext ## _1_c(SwsContext *c, const int16_t *buf0, \
- const int16_t *ubuf[2], const int16_t *vbuf[2], \
- const int16_t *abuf0, uint8_t *dest, int dstW, \
- int uvalpha, int y) \
-{ \
- name ## base ## _1_c_template(c, buf0, ubuf, vbuf, abuf0, dest, \
- dstW, uvalpha, y, fmt, hasAlpha); \
-}
-
-#if CONFIG_SMALL
-YUV2RGBWRAPPER(yuv2rgb,, 32_1, AV_PIX_FMT_RGB32_1, CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
-YUV2RGBWRAPPER(yuv2rgb,, 32, AV_PIX_FMT_RGB32, CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
-#else
-#if CONFIG_SWSCALE_ALPHA
-YUV2RGBWRAPPER(yuv2rgb,, a32_1, AV_PIX_FMT_RGB32_1, 1)
-YUV2RGBWRAPPER(yuv2rgb,, a32, AV_PIX_FMT_RGB32, 1)
-#endif
-YUV2RGBWRAPPER(yuv2rgb,, x32_1, AV_PIX_FMT_RGB32_1, 0)
-YUV2RGBWRAPPER(yuv2rgb,, x32, AV_PIX_FMT_RGB32, 0)
-#endif
-YUV2RGBWRAPPER(yuv2, rgb, rgb24, AV_PIX_FMT_RGB24, 0)
-YUV2RGBWRAPPER(yuv2, rgb, bgr24, AV_PIX_FMT_BGR24, 0)
-YUV2RGBWRAPPER(yuv2rgb,, 16, AV_PIX_FMT_RGB565, 0)
-YUV2RGBWRAPPER(yuv2rgb,, 15, AV_PIX_FMT_RGB555, 0)
-YUV2RGBWRAPPER(yuv2rgb,, 12, AV_PIX_FMT_RGB444, 0)
-YUV2RGBWRAPPER(yuv2rgb,, 8, AV_PIX_FMT_RGB8, 0)
-YUV2RGBWRAPPER(yuv2rgb,, 4, AV_PIX_FMT_RGB4, 0)
-YUV2RGBWRAPPER(yuv2rgb,, 4b, AV_PIX_FMT_RGB4_BYTE, 0)
-
-static av_always_inline void
-yuv2rgb_full_X_c_template(SwsContext *c, const int16_t *lumFilter,
- const int16_t **lumSrc, int lumFilterSize,
- const int16_t *chrFilter, const int16_t **chrUSrc,
- const int16_t **chrVSrc, int chrFilterSize,
- const int16_t **alpSrc, uint8_t *dest,
- int dstW, int y, enum AVPixelFormat target, int hasAlpha)
-{
- int i;
- int step = (target == AV_PIX_FMT_RGB24 || target == AV_PIX_FMT_BGR24) ? 3 : 4;
- int err[4] = {0};
- int isrgb8 = target == AV_PIX_FMT_BGR8 || target == AV_PIX_FMT_RGB8;
-
- for (i = 0; i < dstW; i++) {
- int j;
- int Y = 1<<9;
- int U = (1<<9)-(128 << 19);
- int V = (1<<9)-(128 << 19);
- int R, G, B, A;
-
- for (j = 0; j < lumFilterSize; j++) {
- Y += lumSrc[j][i] * lumFilter[j];
- }
- for (j = 0; j < chrFilterSize; j++) {
- U += chrUSrc[j][i] * chrFilter[j];
- V += chrVSrc[j][i] * chrFilter[j];
- }
- Y >>= 10;
- U >>= 10;
- V >>= 10;
- if (hasAlpha) {
- A = 1 << 18;
- for (j = 0; j < lumFilterSize; j++) {
- A += alpSrc[j][i] * lumFilter[j];
- }
- A >>= 19;
- if (A & 0x100)
- A = av_clip_uint8(A);
- }
- Y -= c->yuv2rgb_y_offset;
- Y *= c->yuv2rgb_y_coeff;
- Y += 1 << 21;
- R = Y + V*c->yuv2rgb_v2r_coeff;
- G = Y + V*c->yuv2rgb_v2g_coeff + U*c->yuv2rgb_u2g_coeff;
- B = Y + U*c->yuv2rgb_u2b_coeff;
- if ((R | G | B) & 0xC0000000) {
- R = av_clip_uintp2(R, 30);
- G = av_clip_uintp2(G, 30);
- B = av_clip_uintp2(B, 30);
- }
-
- switch(target) {
- case AV_PIX_FMT_ARGB:
- dest[0] = hasAlpha ? A : 255;
- dest[1] = R >> 22;
- dest[2] = G >> 22;
- dest[3] = B >> 22;
- break;
- case AV_PIX_FMT_RGB24:
- dest[0] = R >> 22;
- dest[1] = G >> 22;
- dest[2] = B >> 22;
- break;
- case AV_PIX_FMT_RGBA:
- dest[0] = R >> 22;
- dest[1] = G >> 22;
- dest[2] = B >> 22;
- dest[3] = hasAlpha ? A : 255;
- break;
- case AV_PIX_FMT_ABGR:
- dest[0] = hasAlpha ? A : 255;
- dest[1] = B >> 22;
- dest[2] = G >> 22;
- dest[3] = R >> 22;
- break;
- case AV_PIX_FMT_BGR24:
- dest[0] = B >> 22;
- dest[1] = G >> 22;
- dest[2] = R >> 22;
- break;
- case AV_PIX_FMT_BGRA:
- dest[0] = B >> 22;
- dest[1] = G >> 22;
- dest[2] = R >> 22;
- dest[3] = hasAlpha ? A : 255;
- break;
- case AV_PIX_FMT_BGR4_BYTE:
- case AV_PIX_FMT_RGB4_BYTE:
- case AV_PIX_FMT_BGR8:
- case AV_PIX_FMT_RGB8:
- {
- int r,g,b;
- R >>= 22;
- G >>= 22;
- B >>= 22;
- R += (7*err[0] + 1*c->dither_error[0][i] + 5*c->dither_error[0][i+1] + 3*c->dither_error[0][i+2])>>4;
- G += (7*err[1] + 1*c->dither_error[1][i] + 5*c->dither_error[1][i+1] + 3*c->dither_error[1][i+2])>>4;
- B += (7*err[2] + 1*c->dither_error[2][i] + 5*c->dither_error[2][i+1] + 3*c->dither_error[2][i+2])>>4;
- c->dither_error[0][i] = err[0];
- c->dither_error[1][i] = err[1];
- c->dither_error[2][i] = err[2];
- r = R >> (isrgb8 ? 5 : 7);
- g = G >> (isrgb8 ? 5 : 6);
- b = B >> (isrgb8 ? 6 : 7);
- r = av_clip(r, 0, isrgb8 ? 7 : 1);
- g = av_clip(g, 0, isrgb8 ? 7 : 3);
- b = av_clip(b, 0, isrgb8 ? 3 : 1);
- err[0] = R - r*(isrgb8 ? 36 : 255);
- err[1] = G - g*(isrgb8 ? 36 : 85);
- err[2] = B - b*(isrgb8 ? 85 : 255);
- if(target == AV_PIX_FMT_BGR4_BYTE) {
- dest[0] = r + 2*g + 8*b;
- } else if(target == AV_PIX_FMT_RGB4_BYTE) {
- dest[0] = b + 2*g + 8*r;
- } else if(target == AV_PIX_FMT_BGR8) {
- dest[0] = r + 8*g + 64*b;
- } else if(target == AV_PIX_FMT_RGB8) {
- dest[0] = b + 4*g + 32*r;
- } else
- av_assert2(0);
- step = 1;
- break;}
- }
- dest += step;
- }
- c->dither_error[0][i] = err[0];
- c->dither_error[1][i] = err[1];
- c->dither_error[2][i] = err[2];
-}
-
-#if CONFIG_SMALL
-YUV2RGBWRAPPERX(yuv2, rgb_full, bgra32_full, AV_PIX_FMT_BGRA, CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
-YUV2RGBWRAPPERX(yuv2, rgb_full, abgr32_full, AV_PIX_FMT_ABGR, CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
-YUV2RGBWRAPPERX(yuv2, rgb_full, rgba32_full, AV_PIX_FMT_RGBA, CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
-YUV2RGBWRAPPERX(yuv2, rgb_full, argb32_full, AV_PIX_FMT_ARGB, CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
-#else
-#if CONFIG_SWSCALE_ALPHA
-YUV2RGBWRAPPERX(yuv2, rgb_full, bgra32_full, AV_PIX_FMT_BGRA, 1)
-YUV2RGBWRAPPERX(yuv2, rgb_full, abgr32_full, AV_PIX_FMT_ABGR, 1)
-YUV2RGBWRAPPERX(yuv2, rgb_full, rgba32_full, AV_PIX_FMT_RGBA, 1)
-YUV2RGBWRAPPERX(yuv2, rgb_full, argb32_full, AV_PIX_FMT_ARGB, 1)
-#endif
-YUV2RGBWRAPPERX(yuv2, rgb_full, bgrx32_full, AV_PIX_FMT_BGRA, 0)
-YUV2RGBWRAPPERX(yuv2, rgb_full, xbgr32_full, AV_PIX_FMT_ABGR, 0)
-YUV2RGBWRAPPERX(yuv2, rgb_full, rgbx32_full, AV_PIX_FMT_RGBA, 0)
-YUV2RGBWRAPPERX(yuv2, rgb_full, xrgb32_full, AV_PIX_FMT_ARGB, 0)
-#endif
-YUV2RGBWRAPPERX(yuv2, rgb_full, bgr24_full, AV_PIX_FMT_BGR24, 0)
-YUV2RGBWRAPPERX(yuv2, rgb_full, rgb24_full, AV_PIX_FMT_RGB24, 0)
-
-YUV2RGBWRAPPERX(yuv2, rgb_full, bgr4_byte_full, AV_PIX_FMT_BGR4_BYTE, 0)
-YUV2RGBWRAPPERX(yuv2, rgb_full, rgb4_byte_full, AV_PIX_FMT_RGB4_BYTE, 0)
-YUV2RGBWRAPPERX(yuv2, rgb_full, bgr8_full, AV_PIX_FMT_BGR8, 0)
-YUV2RGBWRAPPERX(yuv2, rgb_full, rgb8_full, AV_PIX_FMT_RGB8, 0)
-
-static void
-yuv2gbrp_full_X_c(SwsContext *c, const int16_t *lumFilter,
- const int16_t **lumSrc, int lumFilterSize,
- const int16_t *chrFilter, const int16_t **chrUSrc,
- const int16_t **chrVSrc, int chrFilterSize,
- const int16_t **alpSrc, uint8_t **dest,
- int dstW, int y)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->dstFormat);
- int i;
- int hasAlpha = 0;
- uint16_t **dest16 = (uint16_t**)dest;
- int SH = 22 + 7 - desc->comp[0].depth_minus1;
-
- for (i = 0; i < dstW; i++) {
- int j;
- int Y = 1 << 9;
- int U = (1 << 9) - (128 << 19);
- int V = (1 << 9) - (128 << 19);
- int R, G, B, A;
-
- for (j = 0; j < lumFilterSize; j++)
- Y += lumSrc[j][i] * lumFilter[j];
-
- for (j = 0; j < chrFilterSize; j++) {
- U += chrUSrc[j][i] * chrFilter[j];
- V += chrVSrc[j][i] * chrFilter[j];
- }
-
- Y >>= 10;
- U >>= 10;
- V >>= 10;
-
- if (hasAlpha) {
- A = 1 << 18;
-
- for (j = 0; j < lumFilterSize; j++)
- A += alpSrc[j][i] * lumFilter[j];
-
- A >>= 19;
-
- if (A & 0x100)
- A = av_clip_uint8(A);
- }
-
- Y -= c->yuv2rgb_y_offset;
- Y *= c->yuv2rgb_y_coeff;
- Y += 1 << 21;
- R = Y + V * c->yuv2rgb_v2r_coeff;
- G = Y + V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
- B = Y + U * c->yuv2rgb_u2b_coeff;
-
- if ((R | G | B) & 0xC0000000) {
- R = av_clip_uintp2(R, 30);
- G = av_clip_uintp2(G, 30);
- B = av_clip_uintp2(B, 30);
- }
-
- if (SH != 22) {
- dest16[0][i] = G >> SH;
- dest16[1][i] = B >> SH;
- dest16[2][i] = R >> SH;
- } else {
- dest[0][i] = G >> 22;
- dest[1][i] = B >> 22;
- dest[2][i] = R >> 22;
- }
- }
- if (SH != 22 && (!isBE(c->dstFormat)) != (!HAVE_BIGENDIAN)) {
- for (i = 0; i < dstW; i++) {
- dest16[0][i] = av_bswap16(dest16[0][i]);
- dest16[1][i] = av_bswap16(dest16[1][i]);
- dest16[2][i] = av_bswap16(dest16[2][i]);
- }
- }
-}
-
-av_cold void ff_sws_init_output_funcs(SwsContext *c,
- yuv2planar1_fn *yuv2plane1,
- yuv2planarX_fn *yuv2planeX,
- yuv2interleavedX_fn *yuv2nv12cX,
- yuv2packed1_fn *yuv2packed1,
- yuv2packed2_fn *yuv2packed2,
- yuv2packedX_fn *yuv2packedX,
- yuv2anyX_fn *yuv2anyX)
-{
- enum AVPixelFormat dstFormat = c->dstFormat;
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(dstFormat);
-
- if (is16BPS(dstFormat)) {
- *yuv2planeX = isBE(dstFormat) ? yuv2planeX_16BE_c : yuv2planeX_16LE_c;
- *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_16BE_c : yuv2plane1_16LE_c;
- } else if (is9_OR_10BPS(dstFormat)) {
- if (desc->comp[0].depth_minus1 == 8) {
- *yuv2planeX = isBE(dstFormat) ? yuv2planeX_9BE_c : yuv2planeX_9LE_c;
- *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_9BE_c : yuv2plane1_9LE_c;
- } else if (desc->comp[0].depth_minus1 == 9) {
- *yuv2planeX = isBE(dstFormat) ? yuv2planeX_10BE_c : yuv2planeX_10LE_c;
- *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_10BE_c : yuv2plane1_10LE_c;
- } else if (desc->comp[0].depth_minus1 == 11) {
- *yuv2planeX = isBE(dstFormat) ? yuv2planeX_12BE_c : yuv2planeX_12LE_c;
- *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_12BE_c : yuv2plane1_12LE_c;
- } else if (desc->comp[0].depth_minus1 == 13) {
- *yuv2planeX = isBE(dstFormat) ? yuv2planeX_14BE_c : yuv2planeX_14LE_c;
- *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_14BE_c : yuv2plane1_14LE_c;
- } else
- av_assert0(0);
- } else {
- *yuv2plane1 = yuv2plane1_8_c;
- *yuv2planeX = yuv2planeX_8_c;
- if (dstFormat == AV_PIX_FMT_NV12 || dstFormat == AV_PIX_FMT_NV21)
- *yuv2nv12cX = yuv2nv12cX_c;
- }
-
- if(c->flags & SWS_FULL_CHR_H_INT) {
- switch (dstFormat) {
- case AV_PIX_FMT_RGBA:
-#if CONFIG_SMALL
- *yuv2packedX = yuv2rgba32_full_X_c;
-#else
-#if CONFIG_SWSCALE_ALPHA
- if (c->alpPixBuf) {
- *yuv2packedX = yuv2rgba32_full_X_c;
- } else
-#endif /* CONFIG_SWSCALE_ALPHA */
- {
- *yuv2packedX = yuv2rgbx32_full_X_c;
- }
-#endif /* !CONFIG_SMALL */
- break;
- case AV_PIX_FMT_ARGB:
-#if CONFIG_SMALL
- *yuv2packedX = yuv2argb32_full_X_c;
-#else
-#if CONFIG_SWSCALE_ALPHA
- if (c->alpPixBuf) {
- *yuv2packedX = yuv2argb32_full_X_c;
- } else
-#endif /* CONFIG_SWSCALE_ALPHA */
- {
- *yuv2packedX = yuv2xrgb32_full_X_c;
- }
-#endif /* !CONFIG_SMALL */
- break;
- case AV_PIX_FMT_BGRA:
-#if CONFIG_SMALL
- *yuv2packedX = yuv2bgra32_full_X_c;
-#else
-#if CONFIG_SWSCALE_ALPHA
- if (c->alpPixBuf) {
- *yuv2packedX = yuv2bgra32_full_X_c;
- } else
-#endif /* CONFIG_SWSCALE_ALPHA */
- {
- *yuv2packedX = yuv2bgrx32_full_X_c;
- }
-#endif /* !CONFIG_SMALL */
- break;
- case AV_PIX_FMT_ABGR:
-#if CONFIG_SMALL
- *yuv2packedX = yuv2abgr32_full_X_c;
-#else
-#if CONFIG_SWSCALE_ALPHA
- if (c->alpPixBuf) {
- *yuv2packedX = yuv2abgr32_full_X_c;
- } else
-#endif /* CONFIG_SWSCALE_ALPHA */
- {
- *yuv2packedX = yuv2xbgr32_full_X_c;
- }
-#endif /* !CONFIG_SMALL */
- break;
- case AV_PIX_FMT_RGB24:
- *yuv2packedX = yuv2rgb24_full_X_c;
- break;
- case AV_PIX_FMT_BGR24:
- *yuv2packedX = yuv2bgr24_full_X_c;
- break;
- case AV_PIX_FMT_BGR4_BYTE:
- *yuv2packedX = yuv2bgr4_byte_full_X_c;
- break;
- case AV_PIX_FMT_RGB4_BYTE:
- *yuv2packedX = yuv2rgb4_byte_full_X_c;
- break;
- case AV_PIX_FMT_BGR8:
- *yuv2packedX = yuv2bgr8_full_X_c;
- break;
- case AV_PIX_FMT_RGB8:
- *yuv2packedX = yuv2rgb8_full_X_c;
- break;
- case AV_PIX_FMT_GBRP:
- case AV_PIX_FMT_GBRP9BE:
- case AV_PIX_FMT_GBRP9LE:
- case AV_PIX_FMT_GBRP10BE:
- case AV_PIX_FMT_GBRP10LE:
- case AV_PIX_FMT_GBRP12BE:
- case AV_PIX_FMT_GBRP12LE:
- case AV_PIX_FMT_GBRP14BE:
- case AV_PIX_FMT_GBRP14LE:
- case AV_PIX_FMT_GBRP16BE:
- case AV_PIX_FMT_GBRP16LE:
- *yuv2anyX = yuv2gbrp_full_X_c;
- break;
- }
- if (!*yuv2packedX && !*yuv2anyX)
- goto YUV_PACKED;
- } else {
- YUV_PACKED:
- switch (dstFormat) {
- case AV_PIX_FMT_RGB48LE:
- *yuv2packed1 = yuv2rgb48le_1_c;
- *yuv2packed2 = yuv2rgb48le_2_c;
- *yuv2packedX = yuv2rgb48le_X_c;
- break;
- case AV_PIX_FMT_RGB48BE:
- *yuv2packed1 = yuv2rgb48be_1_c;
- *yuv2packed2 = yuv2rgb48be_2_c;
- *yuv2packedX = yuv2rgb48be_X_c;
- break;
- case AV_PIX_FMT_BGR48LE:
- *yuv2packed1 = yuv2bgr48le_1_c;
- *yuv2packed2 = yuv2bgr48le_2_c;
- *yuv2packedX = yuv2bgr48le_X_c;
- break;
- case AV_PIX_FMT_BGR48BE:
- *yuv2packed1 = yuv2bgr48be_1_c;
- *yuv2packed2 = yuv2bgr48be_2_c;
- *yuv2packedX = yuv2bgr48be_X_c;
- break;
- case AV_PIX_FMT_RGB32:
- case AV_PIX_FMT_BGR32:
-#if CONFIG_SMALL
- *yuv2packed1 = yuv2rgb32_1_c;
- *yuv2packed2 = yuv2rgb32_2_c;
- *yuv2packedX = yuv2rgb32_X_c;
-#else
-#if CONFIG_SWSCALE_ALPHA
- if (c->alpPixBuf) {
- *yuv2packed1 = yuv2rgba32_1_c;
- *yuv2packed2 = yuv2rgba32_2_c;
- *yuv2packedX = yuv2rgba32_X_c;
- } else
-#endif /* CONFIG_SWSCALE_ALPHA */
- {
- *yuv2packed1 = yuv2rgbx32_1_c;
- *yuv2packed2 = yuv2rgbx32_2_c;
- *yuv2packedX = yuv2rgbx32_X_c;
- }
-#endif /* !CONFIG_SMALL */
- break;
- case AV_PIX_FMT_RGB32_1:
- case AV_PIX_FMT_BGR32_1:
-#if CONFIG_SMALL
- *yuv2packed1 = yuv2rgb32_1_1_c;
- *yuv2packed2 = yuv2rgb32_1_2_c;
- *yuv2packedX = yuv2rgb32_1_X_c;
-#else
-#if CONFIG_SWSCALE_ALPHA
- if (c->alpPixBuf) {
- *yuv2packed1 = yuv2rgba32_1_1_c;
- *yuv2packed2 = yuv2rgba32_1_2_c;
- *yuv2packedX = yuv2rgba32_1_X_c;
- } else
-#endif /* CONFIG_SWSCALE_ALPHA */
- {
- *yuv2packed1 = yuv2rgbx32_1_1_c;
- *yuv2packed2 = yuv2rgbx32_1_2_c;
- *yuv2packedX = yuv2rgbx32_1_X_c;
- }
-#endif /* !CONFIG_SMALL */
- break;
- case AV_PIX_FMT_RGB24:
- *yuv2packed1 = yuv2rgb24_1_c;
- *yuv2packed2 = yuv2rgb24_2_c;
- *yuv2packedX = yuv2rgb24_X_c;
- break;
- case AV_PIX_FMT_BGR24:
- *yuv2packed1 = yuv2bgr24_1_c;
- *yuv2packed2 = yuv2bgr24_2_c;
- *yuv2packedX = yuv2bgr24_X_c;
- break;
- case AV_PIX_FMT_RGB565LE:
- case AV_PIX_FMT_RGB565BE:
- case AV_PIX_FMT_BGR565LE:
- case AV_PIX_FMT_BGR565BE:
- *yuv2packed1 = yuv2rgb16_1_c;
- *yuv2packed2 = yuv2rgb16_2_c;
- *yuv2packedX = yuv2rgb16_X_c;
- break;
- case AV_PIX_FMT_RGB555LE:
- case AV_PIX_FMT_RGB555BE:
- case AV_PIX_FMT_BGR555LE:
- case AV_PIX_FMT_BGR555BE:
- *yuv2packed1 = yuv2rgb15_1_c;
- *yuv2packed2 = yuv2rgb15_2_c;
- *yuv2packedX = yuv2rgb15_X_c;
- break;
- case AV_PIX_FMT_RGB444LE:
- case AV_PIX_FMT_RGB444BE:
- case AV_PIX_FMT_BGR444LE:
- case AV_PIX_FMT_BGR444BE:
- *yuv2packed1 = yuv2rgb12_1_c;
- *yuv2packed2 = yuv2rgb12_2_c;
- *yuv2packedX = yuv2rgb12_X_c;
- break;
- case AV_PIX_FMT_RGB8:
- case AV_PIX_FMT_BGR8:
- *yuv2packed1 = yuv2rgb8_1_c;
- *yuv2packed2 = yuv2rgb8_2_c;
- *yuv2packedX = yuv2rgb8_X_c;
- break;
- case AV_PIX_FMT_RGB4:
- case AV_PIX_FMT_BGR4:
- *yuv2packed1 = yuv2rgb4_1_c;
- *yuv2packed2 = yuv2rgb4_2_c;
- *yuv2packedX = yuv2rgb4_X_c;
- break;
- case AV_PIX_FMT_RGB4_BYTE:
- case AV_PIX_FMT_BGR4_BYTE:
- *yuv2packed1 = yuv2rgb4b_1_c;
- *yuv2packed2 = yuv2rgb4b_2_c;
- *yuv2packedX = yuv2rgb4b_X_c;
- break;
- }
- }
- switch (dstFormat) {
- case AV_PIX_FMT_MONOWHITE:
- *yuv2packed1 = yuv2monowhite_1_c;
- *yuv2packed2 = yuv2monowhite_2_c;
- *yuv2packedX = yuv2monowhite_X_c;
- break;
- case AV_PIX_FMT_MONOBLACK:
- *yuv2packed1 = yuv2monoblack_1_c;
- *yuv2packed2 = yuv2monoblack_2_c;
- *yuv2packedX = yuv2monoblack_X_c;
- break;
- case AV_PIX_FMT_YUYV422:
- *yuv2packed1 = yuv2yuyv422_1_c;
- *yuv2packed2 = yuv2yuyv422_2_c;
- *yuv2packedX = yuv2yuyv422_X_c;
- break;
- case AV_PIX_FMT_UYVY422:
- *yuv2packed1 = yuv2uyvy422_1_c;
- *yuv2packed2 = yuv2uyvy422_2_c;
- *yuv2packedX = yuv2uyvy422_X_c;
- break;
- }
-}
diff --git a/src/thirdparty/ffmpeg/libswscale/rgb2rgb.c b/src/thirdparty/ffmpeg/libswscale/rgb2rgb.c
deleted file mode 100644
index 90b665bbd..000000000
--- a/src/thirdparty/ffmpeg/libswscale/rgb2rgb.c
+++ /dev/null
@@ -1,390 +0,0 @@
-/*
- * software RGB to RGB converter
- * pluralize by software PAL8 to RGB converter
- * software YUV to YUV converter
- * software YUV to RGB converter
- * Written by Nick Kurshev.
- * palette & YUV & runtime CPU stuff by Michael (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
- */
-
-#include <inttypes.h>
-
-#include "libavutil/attributes.h"
-#include "libavutil/bswap.h"
-#include "config.h"
-#include "rgb2rgb.h"
-#include "swscale.h"
-#include "swscale_internal.h"
-
-void (*rgb32tobgr24)(const uint8_t *src, uint8_t *dst, int src_size);
-void (*rgb32tobgr16)(const uint8_t *src, uint8_t *dst, int src_size);
-void (*rgb32tobgr15)(const uint8_t *src, uint8_t *dst, int src_size);
-void (*rgb24tobgr32)(const uint8_t *src, uint8_t *dst, int src_size);
-void (*rgb24tobgr24)(const uint8_t *src, uint8_t *dst, int src_size);
-void (*rgb24tobgr16)(const uint8_t *src, uint8_t *dst, int src_size);
-void (*rgb24tobgr15)(const uint8_t *src, uint8_t *dst, int src_size);
-void (*rgb16tobgr24)(const uint8_t *src, uint8_t *dst, int src_size);
-void (*rgb15tobgr24)(const uint8_t *src, uint8_t *dst, int src_size);
-
-void (*rgb32to16)(const uint8_t *src, uint8_t *dst, int src_size);
-void (*rgb32to15)(const uint8_t *src, uint8_t *dst, int src_size);
-void (*rgb24to16)(const uint8_t *src, uint8_t *dst, int src_size);
-void (*rgb24to15)(const uint8_t *src, uint8_t *dst, int src_size);
-void (*rgb16to32)(const uint8_t *src, uint8_t *dst, int src_size);
-void (*rgb16to15)(const uint8_t *src, uint8_t *dst, int src_size);
-void (*rgb15to16)(const uint8_t *src, uint8_t *dst, int src_size);
-void (*rgb15to32)(const uint8_t *src, uint8_t *dst, int src_size);
-
-void (*shuffle_bytes_2103)(const uint8_t *src, uint8_t *dst, int src_size);
-
-void (*yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc,
- const uint8_t *vsrc, uint8_t *dst,
- int width, int height,
- int lumStride, int chromStride, int dstStride);
-void (*yv12touyvy)(const uint8_t *ysrc, const uint8_t *usrc,
- const uint8_t *vsrc, uint8_t *dst,
- int width, int height,
- int lumStride, int chromStride, int dstStride);
-void (*yuv422ptoyuy2)(const uint8_t *ysrc, const uint8_t *usrc,
- const uint8_t *vsrc, uint8_t *dst,
- int width, int height,
- int lumStride, int chromStride, int dstStride);
-void (*yuv422ptouyvy)(const uint8_t *ysrc, const uint8_t *usrc,
- const uint8_t *vsrc, uint8_t *dst,
- int width, int height,
- int lumStride, int chromStride, int dstStride);
-void (*yuy2toyv12)(const uint8_t *src, uint8_t *ydst,
- uint8_t *udst, uint8_t *vdst,
- int width, int height,
- int lumStride, int chromStride, int srcStride);
-void (*rgb24toyv12)(const uint8_t *src, uint8_t *ydst,
- uint8_t *udst, uint8_t *vdst,
- int width, int height,
- int lumStride, int chromStride, int srcStride);
-void (*planar2x)(const uint8_t *src, uint8_t *dst, int width, int height,
- int srcStride, int dstStride);
-void (*interleaveBytes)(const uint8_t *src1, const uint8_t *src2, uint8_t *dst,
- int width, int height, int src1Stride,
- int src2Stride, int dstStride);
-void (*vu9_to_vu12)(const uint8_t *src1, const uint8_t *src2,
- uint8_t *dst1, uint8_t *dst2,
- int width, int height,
- int srcStride1, int srcStride2,
- int dstStride1, int dstStride2);
-void (*yvu9_to_yuy2)(const uint8_t *src1, const uint8_t *src2,
- const uint8_t *src3, uint8_t *dst,
- int width, int height,
- int srcStride1, int srcStride2,
- int srcStride3, int dstStride);
-void (*uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
- const uint8_t *src, int width, int height,
- int lumStride, int chromStride, int srcStride);
-void (*uyvytoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
- const uint8_t *src, int width, int height,
- int lumStride, int chromStride, int srcStride);
-void (*yuyvtoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
- const uint8_t *src, int width, int height,
- int lumStride, int chromStride, int srcStride);
-void (*yuyvtoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
- const uint8_t *src, int width, int height,
- int lumStride, int chromStride, int srcStride);
-
-#define RGB2YUV_SHIFT 8
-#define BY ((int)( 0.098 * (1 << RGB2YUV_SHIFT) + 0.5))
-#define BV ((int)(-0.071 * (1 << RGB2YUV_SHIFT) + 0.5))
-#define BU ((int)( 0.439 * (1 << RGB2YUV_SHIFT) + 0.5))
-#define GY ((int)( 0.504 * (1 << RGB2YUV_SHIFT) + 0.5))
-#define GV ((int)(-0.368 * (1 << RGB2YUV_SHIFT) + 0.5))
-#define GU ((int)(-0.291 * (1 << RGB2YUV_SHIFT) + 0.5))
-#define RY ((int)( 0.257 * (1 << RGB2YUV_SHIFT) + 0.5))
-#define RV ((int)( 0.439 * (1 << RGB2YUV_SHIFT) + 0.5))
-#define RU ((int)(-0.148 * (1 << RGB2YUV_SHIFT) + 0.5))
-
-//plain C versions
-#include "rgb2rgb_template.c"
-
-/*
- * RGB15->RGB16 original by Strepto/Astral
- * ported to gcc & bugfixed : A'rpi
- * MMXEXT, 3DNOW optimization by Nick Kurshev
- * 32-bit C version, and and&add trick by Michael Niedermayer
- */
-
-av_cold void sws_rgb2rgb_init(void)
-{
- rgb2rgb_init_c();
- if (HAVE_MMX)
- rgb2rgb_init_x86();
-}
-
-void rgb32to24(const uint8_t *src, uint8_t *dst, int src_size)
-{
- int i, num_pixels = src_size >> 2;
-
- for (i = 0; i < num_pixels; i++) {
-#if HAVE_BIGENDIAN
- /* RGB32 (= A,B,G,R) -> BGR24 (= B,G,R) */
- dst[3 * i + 0] = src[4 * i + 1];
- dst[3 * i + 1] = src[4 * i + 2];
- dst[3 * i + 2] = src[4 * i + 3];
-#else
- dst[3 * i + 0] = src[4 * i + 2];
- dst[3 * i + 1] = src[4 * i + 1];
- dst[3 * i + 2] = src[4 * i + 0];
-#endif
- }
-}
-
-void rgb24to32(const uint8_t *src, uint8_t *dst, int src_size)
-{
- int i;
-
- for (i = 0; 3 * i < src_size; i++) {
-#if HAVE_BIGENDIAN
- /* RGB24 (= R, G, B) -> BGR32 (= A, R, G, B) */
- dst[4 * i + 0] = 255;
- dst[4 * i + 1] = src[3 * i + 0];
- dst[4 * i + 2] = src[3 * i + 1];
- dst[4 * i + 3] = src[3 * i + 2];
-#else
- dst[4 * i + 0] = src[3 * i + 2];
- dst[4 * i + 1] = src[3 * i + 1];
- dst[4 * i + 2] = src[3 * i + 0];
- dst[4 * i + 3] = 255;
-#endif
- }
-}
-
-void rgb16tobgr32(const uint8_t *src, uint8_t *dst, int src_size)
-{
- uint8_t *d = dst;
- const uint16_t *s = (const uint16_t *)src;
- const uint16_t *end = s + src_size / 2;
-
- while (s < end) {
- register uint16_t bgr = *s++;
-#if HAVE_BIGENDIAN
- *d++ = 255;
- *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2);
- *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9);
- *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
-#else
- *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
- *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9);
- *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2);
- *d++ = 255;
-#endif
- }
-}
-
-void rgb12to15(const uint8_t *src, uint8_t *dst, int src_size)
-{
- uint16_t rgb, r, g, b;
- uint16_t *d = (uint16_t *)dst;
- const uint16_t *s = (const uint16_t *)src;
- const uint16_t *end = s + src_size / 2;
-
- while (s < end) {
- rgb = *s++;
- r = rgb & 0xF00;
- g = rgb & 0x0F0;
- b = rgb & 0x00F;
- r = (r << 3) | ((r & 0x800) >> 1);
- g = (g << 2) | ((g & 0x080) >> 2);
- b = (b << 1) | ( b >> 3);
- *d++ = r | g | b;
- }
-}
-
-void rgb16to24(const uint8_t *src, uint8_t *dst, int src_size)
-{
- uint8_t *d = dst;
- const uint16_t *s = (const uint16_t *)src;
- const uint16_t *end = s + src_size / 2;
-
- while (s < end) {
- register uint16_t bgr = *s++;
- *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
- *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9);
- *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2);
- }
-}
-
-void rgb16tobgr16(const uint8_t *src, uint8_t *dst, int src_size)
-{
- int i, num_pixels = src_size >> 1;
-
- for (i = 0; i < num_pixels; i++) {
- unsigned rgb = ((const uint16_t *)src)[i];
- ((uint16_t *)dst)[i] = (rgb >> 11) | (rgb & 0x7E0) | (rgb << 11);
- }
-}
-
-void rgb16tobgr15(const uint8_t *src, uint8_t *dst, int src_size)
-{
- int i, num_pixels = src_size >> 1;
-
- for (i = 0; i < num_pixels; i++) {
- unsigned rgb = ((const uint16_t *)src)[i];
- ((uint16_t *)dst)[i] = (rgb >> 11) | ((rgb & 0x7C0) >> 1) | ((rgb & 0x1F) << 10);
- }
-}
-
-void rgb15tobgr32(const uint8_t *src, uint8_t *dst, int src_size)
-{
- uint8_t *d = dst;
- const uint16_t *s = (const uint16_t *)src;
- const uint16_t *end = s + src_size / 2;
-
- while (s < end) {
- register uint16_t bgr = *s++;
-#if HAVE_BIGENDIAN
- *d++ = 255;
- *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2);
- *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7);
- *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
-#else
- *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
- *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7);
- *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2);
- *d++ = 255;
-#endif
- }
-}
-
-void rgb15to24(const uint8_t *src, uint8_t *dst, int src_size)
-{
- uint8_t *d = dst;
- const uint16_t *s = (const uint16_t *)src;
- const uint16_t *end = s + src_size / 2;
-
- while (s < end) {
- register uint16_t bgr = *s++;
- *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
- *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7);
- *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2);
- }
-}
-
-void rgb15tobgr16(const uint8_t *src, uint8_t *dst, int src_size)
-{
- int i, num_pixels = src_size >> 1;
-
- for (i = 0; i < num_pixels; i++) {
- unsigned rgb = ((const uint16_t *)src)[i];
- ((uint16_t *)dst)[i] = ((rgb & 0x7C00) >> 10) | ((rgb & 0x3E0) << 1) | (rgb << 11);
- }
-}
-
-void rgb15tobgr15(const uint8_t *src, uint8_t *dst, int src_size)
-{
- int i, num_pixels = src_size >> 1;
-
- for (i = 0; i < num_pixels; i++) {
- unsigned rgb = ((const uint16_t *)src)[i];
- unsigned br = rgb & 0x7C1F;
- ((uint16_t *)dst)[i] = (br >> 10) | (rgb & 0x3E0) | (br << 10);
- }
-}
-
-void rgb12tobgr12(const uint8_t *src, uint8_t *dst, int src_size)
-{
- uint16_t *d = (uint16_t *)dst;
- uint16_t *s = (uint16_t *)src;
- int i, num_pixels = src_size >> 1;
-
- for (i = 0; i < num_pixels; i++) {
- unsigned rgb = s[i];
- d[i] = (rgb << 8 | rgb & 0xF0 | rgb >> 8) & 0xFFF;
- }
-}
-
-
-#define DEFINE_SHUFFLE_BYTES(a, b, c, d) \
-void shuffle_bytes_ ## a ## b ## c ## d(const uint8_t *src, \
- uint8_t *dst, int src_size) \
-{ \
- int i; \
- \
- for (i = 0; i < src_size; i += 4) { \
- dst[i + 0] = src[i + a]; \
- dst[i + 1] = src[i + b]; \
- dst[i + 2] = src[i + c]; \
- dst[i + 3] = src[i + d]; \
- } \
-}
-
-DEFINE_SHUFFLE_BYTES(0, 3, 2, 1)
-DEFINE_SHUFFLE_BYTES(1, 2, 3, 0)
-DEFINE_SHUFFLE_BYTES(3, 0, 1, 2)
-DEFINE_SHUFFLE_BYTES(3, 2, 1, 0)
-
-#define DEFINE_RGB48TOBGR48(need_bswap, swap) \
-void rgb48tobgr48_ ## need_bswap(const uint8_t *src, \
- uint8_t *dst, int src_size) \
-{ \
- uint16_t *d = (uint16_t *)dst; \
- uint16_t *s = (uint16_t *)src; \
- int i, num_pixels = src_size >> 1; \
- \
- for (i = 0; i < num_pixels; i += 3) { \
- d[i ] = swap ? av_bswap16(s[i + 2]) : s[i + 2]; \
- d[i + 1] = swap ? av_bswap16(s[i + 1]) : s[i + 1]; \
- d[i + 2] = swap ? av_bswap16(s[i ]) : s[i ]; \
- } \
-}
-
-DEFINE_RGB48TOBGR48(nobswap, 0)
-DEFINE_RGB48TOBGR48(bswap, 1)
-
-#define DEFINE_RGB64TOBGR48(need_bswap, swap) \
-void rgb64tobgr48_ ## need_bswap(const uint8_t *src, \
- uint8_t *dst, int src_size) \
-{ \
- uint16_t *d = (uint16_t *)dst; \
- uint16_t *s = (uint16_t *)src; \
- int i, num_pixels = src_size >> 3; \
- \
- for (i = 0; i < num_pixels; i++) { \
- d[3 * i ] = swap ? av_bswap16(s[4 * i + 2]) : s[4 * i + 2]; \
- d[3 * i + 1] = swap ? av_bswap16(s[4 * i + 1]) : s[4 * i + 1]; \
- d[3 * i + 2] = swap ? av_bswap16(s[4 * i ]) : s[4 * i ]; \
- } \
-}
-
-DEFINE_RGB64TOBGR48(nobswap, 0)
-DEFINE_RGB64TOBGR48(bswap, 1)
-
-#define DEFINE_RGB64TO48(need_bswap, swap) \
-void rgb64to48_ ## need_bswap(const uint8_t *src, \
- uint8_t *dst, int src_size) \
-{ \
- uint16_t *d = (uint16_t *)dst; \
- uint16_t *s = (uint16_t *)src; \
- int i, num_pixels = src_size >> 3; \
- \
- for (i = 0; i < num_pixels; i++) { \
- d[3 * i ] = swap ? av_bswap16(s[4 * i ]) : s[4 * i ]; \
- d[3 * i + 1] = swap ? av_bswap16(s[4 * i + 1]) : s[4 * i + 1]; \
- d[3 * i + 2] = swap ? av_bswap16(s[4 * i + 2]) : s[4 * i + 2]; \
- } \
-}
-
-DEFINE_RGB64TO48(nobswap, 0)
-DEFINE_RGB64TO48(bswap, 1)
diff --git a/src/thirdparty/ffmpeg/libswscale/rgb2rgb.h b/src/thirdparty/ffmpeg/libswscale/rgb2rgb.h
deleted file mode 100644
index 296e1a5fe..000000000
--- a/src/thirdparty/ffmpeg/libswscale/rgb2rgb.h
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * software RGB to RGB converter
- * pluralize by Software PAL8 to RGB converter
- * Software YUV to YUV converter
- * Software YUV to RGB converter
- * Written by Nick Kurshev.
- * YUV & runtime CPU stuff by Michael (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
- */
-
-#ifndef SWSCALE_RGB2RGB_H
-#define SWSCALE_RGB2RGB_H
-
-#include <inttypes.h>
-
-#include "libswscale/swscale.h"
-#include "libavutil/avutil.h"
-
-/* A full collection of RGB to RGB(BGR) converters */
-extern void (*rgb24tobgr32)(const uint8_t *src, uint8_t *dst, int src_size);
-extern void (*rgb24tobgr16)(const uint8_t *src, uint8_t *dst, int src_size);
-extern void (*rgb24tobgr15)(const uint8_t *src, uint8_t *dst, int src_size);
-extern void (*rgb32tobgr24)(const uint8_t *src, uint8_t *dst, int src_size);
-extern void (*rgb32to16)(const uint8_t *src, uint8_t *dst, int src_size);
-extern void (*rgb32to15)(const uint8_t *src, uint8_t *dst, int src_size);
-extern void (*rgb15to16)(const uint8_t *src, uint8_t *dst, int src_size);
-extern void (*rgb15tobgr24)(const uint8_t *src, uint8_t *dst, int src_size);
-extern void (*rgb15to32)(const uint8_t *src, uint8_t *dst, int src_size);
-extern void (*rgb16to15)(const uint8_t *src, uint8_t *dst, int src_size);
-extern void (*rgb16tobgr24)(const uint8_t *src, uint8_t *dst, int src_size);
-extern void (*rgb16to32)(const uint8_t *src, uint8_t *dst, int src_size);
-extern void (*rgb24tobgr24)(const uint8_t *src, uint8_t *dst, int src_size);
-extern void (*rgb24to16)(const uint8_t *src, uint8_t *dst, int src_size);
-extern void (*rgb24to15)(const uint8_t *src, uint8_t *dst, int src_size);
-extern void (*rgb32tobgr16)(const uint8_t *src, uint8_t *dst, int src_size);
-extern void (*rgb32tobgr15)(const uint8_t *src, uint8_t *dst, int src_size);
-
-extern void (*shuffle_bytes_2103)(const uint8_t *src, uint8_t *dst, int src_size);
-
-void rgb64tobgr48_nobswap(const uint8_t *src, uint8_t *dst, int src_size);
-void rgb64tobgr48_bswap(const uint8_t *src, uint8_t *dst, int src_size);
-void rgb48tobgr48_nobswap(const uint8_t *src, uint8_t *dst, int src_size);
-void rgb48tobgr48_bswap(const uint8_t *src, uint8_t *dst, int src_size);
-void rgb64to48_nobswap(const uint8_t *src, uint8_t *dst, int src_size);
-void rgb64to48_bswap(const uint8_t *src, uint8_t *dst, int src_size);
-void rgb24to32(const uint8_t *src, uint8_t *dst, int src_size);
-void rgb32to24(const uint8_t *src, uint8_t *dst, int src_size);
-void rgb16tobgr32(const uint8_t *src, uint8_t *dst, int src_size);
-void rgb16to24(const uint8_t *src, uint8_t *dst, int src_size);
-void rgb16tobgr16(const uint8_t *src, uint8_t *dst, int src_size);
-void rgb16tobgr15(const uint8_t *src, uint8_t *dst, int src_size);
-void rgb15tobgr32(const uint8_t *src, uint8_t *dst, int src_size);
-void rgb15to24(const uint8_t *src, uint8_t *dst, int src_size);
-void rgb15tobgr16(const uint8_t *src, uint8_t *dst, int src_size);
-void rgb15tobgr15(const uint8_t *src, uint8_t *dst, int src_size);
-void rgb12tobgr12(const uint8_t *src, uint8_t *dst, int src_size);
-void rgb12to15(const uint8_t *src, uint8_t *dst, int src_size);
-
-void shuffle_bytes_0321(const uint8_t *src, uint8_t *dst, int src_size);
-void shuffle_bytes_1230(const uint8_t *src, uint8_t *dst, int src_size);
-void shuffle_bytes_3012(const uint8_t *src, uint8_t *dst, int src_size);
-void shuffle_bytes_3210(const uint8_t *src, uint8_t *dst, int src_size);
-
-void rgb24toyv12_c(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
- uint8_t *vdst, int width, int height, int lumStride,
- int chromStride, int srcStride);
-
-/**
- * Height should be a multiple of 2 and width should be a multiple of 16.
- * (If this is a problem for anyone then tell me, and I will fix it.)
- */
-extern void (*yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
- int width, int height,
- int lumStride, int chromStride, int dstStride);
-
-/**
- * Width should be a multiple of 16.
- */
-extern void (*yuv422ptoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
- int width, int height,
- int lumStride, int chromStride, int dstStride);
-
-/**
- * Height should be a multiple of 2 and width should be a multiple of 16.
- * (If this is a problem for anyone then tell me, and I will fix it.)
- */
-extern void (*yuy2toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
- int width, int height,
- int lumStride, int chromStride, int srcStride);
-
-/**
- * Height should be a multiple of 2 and width should be a multiple of 16.
- * (If this is a problem for anyone then tell me, and I will fix it.)
- */
-extern void (*yv12touyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
- int width, int height,
- int lumStride, int chromStride, int dstStride);
-
-/**
- * Width should be a multiple of 16.
- */
-extern void (*yuv422ptouyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
- int width, int height,
- int lumStride, int chromStride, int dstStride);
-
-/**
- * Height should be a multiple of 2 and width should be a multiple of 2.
- * (If this is a problem for anyone then tell me, and I will fix it.)
- * Chrominance data is only taken from every second line, others are ignored.
- * FIXME: Write high quality version.
- */
-extern void (*rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
- int width, int height,
- int lumStride, int chromStride, int srcStride);
-extern void (*planar2x)(const uint8_t *src, uint8_t *dst, int width, int height,
- int srcStride, int dstStride);
-
-extern void (*interleaveBytes)(const uint8_t *src1, const uint8_t *src2, uint8_t *dst,
- int width, int height, int src1Stride,
- int src2Stride, int dstStride);
-
-extern void (*vu9_to_vu12)(const uint8_t *src1, const uint8_t *src2,
- uint8_t *dst1, uint8_t *dst2,
- int width, int height,
- int srcStride1, int srcStride2,
- int dstStride1, int dstStride2);
-
-extern void (*yvu9_to_yuy2)(const uint8_t *src1, const uint8_t *src2, const uint8_t *src3,
- uint8_t *dst,
- int width, int height,
- int srcStride1, int srcStride2,
- int srcStride3, int dstStride);
-
-extern void (*uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
- int width, int height,
- int lumStride, int chromStride, int srcStride);
-extern void (*uyvytoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
- int width, int height,
- int lumStride, int chromStride, int srcStride);
-extern void (*yuyvtoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
- int width, int height,
- int lumStride, int chromStride, int srcStride);
-extern void (*yuyvtoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
- int width, int height,
- int lumStride, int chromStride, int srcStride);
-
-void sws_rgb2rgb_init(void);
-
-void rgb2rgb_init_x86(void);
-
-#endif /* SWSCALE_RGB2RGB_H */
diff --git a/src/thirdparty/ffmpeg/libswscale/rgb2rgb_template.c b/src/thirdparty/ffmpeg/libswscale/rgb2rgb_template.c
deleted file mode 100644
index 0810b231d..000000000
--- a/src/thirdparty/ffmpeg/libswscale/rgb2rgb_template.c
+++ /dev/null
@@ -1,927 +0,0 @@
-/*
- * software RGB to RGB converter
- * pluralize by software PAL8 to RGB converter
- * software YUV to YUV converter
- * software YUV to RGB converter
- * Written by Nick Kurshev.
- * palette & YUV & runtime CPU stuff by Michael (michaelni@gmx.at)
- * lot of big-endian byte order fixes by Alex Beregszaszi
- *
- * 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>
-
-static inline void rgb24tobgr32_c(const uint8_t *src, uint8_t *dst,
- int src_size)
-{
- uint8_t *dest = dst;
- const uint8_t *s = src;
- const uint8_t *end = s + src_size;
-
- while (s < end) {
-#if HAVE_BIGENDIAN
- /* RGB24 (= R, G, B) -> RGB32 (= A, B, G, R) */
- *dest++ = 255;
- *dest++ = s[2];
- *dest++ = s[1];
- *dest++ = s[0];
- s += 3;
-#else
- *dest++ = *s++;
- *dest++ = *s++;
- *dest++ = *s++;
- *dest++ = 255;
-#endif
- }
-}
-
-static inline void rgb32tobgr24_c(const uint8_t *src, uint8_t *dst,
- int src_size)
-{
- uint8_t *dest = dst;
- const uint8_t *s = src;
- const uint8_t *end = s + src_size;
-
- while (s < end) {
-#if HAVE_BIGENDIAN
- /* RGB32 (= A, B, G, R) -> RGB24 (= R, G, B) */
- s++;
- dest[2] = *s++;
- dest[1] = *s++;
- dest[0] = *s++;
- dest += 3;
-#else
- *dest++ = *s++;
- *dest++ = *s++;
- *dest++ = *s++;
- s++;
-#endif
- }
-}
-
-/*
- * original by Strepto/Astral
- * ported to gcc & bugfixed: A'rpi
- * MMXEXT, 3DNOW optimization by Nick Kurshev
- * 32-bit C version, and and&add trick by Michael Niedermayer
- */
-static inline void rgb15to16_c(const uint8_t *src, uint8_t *dst, int src_size)
-{
- register uint8_t *d = dst;
- register const uint8_t *s = src;
- register const uint8_t *end = s + src_size;
- const uint8_t *mm_end = end - 3;
-
- while (s < mm_end) {
- register unsigned x = *((const uint32_t *)s);
- *((uint32_t *)d) = (x & 0x7FFF7FFF) + (x & 0x7FE07FE0);
- d += 4;
- s += 4;
- }
- if (s < end) {
- register unsigned short x = *((const uint16_t *)s);
- *((uint16_t *)d) = (x & 0x7FFF) + (x & 0x7FE0);
- }
-}
-
-static inline void rgb16to15_c(const uint8_t *src, uint8_t *dst, int src_size)
-{
- register uint8_t *d = dst;
- register const uint8_t *s = src;
- register const uint8_t *end = s + src_size;
- const uint8_t *mm_end = end - 3;
-
- while (s < mm_end) {
- register uint32_t x = *((const uint32_t *)s);
- *((uint32_t *)d) = ((x >> 1) & 0x7FE07FE0) | (x & 0x001F001F);
- s += 4;
- d += 4;
- }
- if (s < end) {
- register uint16_t x = *((const uint16_t *)s);
- *((uint16_t *)d) = ((x >> 1) & 0x7FE0) | (x & 0x001F);
- }
-}
-
-static inline void rgb32to16_c(const uint8_t *src, uint8_t *dst, int src_size)
-{
- uint16_t *d = (uint16_t *)dst;
- const uint8_t *s = src;
- const uint8_t *end = s + src_size;
-
- while (s < end) {
- register int rgb = *(const uint32_t *)s;
- s += 4;
- *d++ = ((rgb & 0xFF) >> 3) +
- ((rgb & 0xFC00) >> 5) +
- ((rgb & 0xF80000) >> 8);
- }
-}
-
-static inline void rgb32tobgr16_c(const uint8_t *src, uint8_t *dst,
- int src_size)
-{
- uint16_t *d = (uint16_t *)dst;
- const uint8_t *s = src;
- const uint8_t *end = s + src_size;
-
- while (s < end) {
- register int rgb = *(const uint32_t *)s;
- s += 4;
- *d++ = ((rgb & 0xF8) << 8) +
- ((rgb & 0xFC00) >> 5) +
- ((rgb & 0xF80000) >> 19);
- }
-}
-
-static inline void rgb32to15_c(const uint8_t *src, uint8_t *dst, int src_size)
-{
- uint16_t *d = (uint16_t *)dst;
- const uint8_t *s = src;
- const uint8_t *end = s + src_size;
-
- while (s < end) {
- register int rgb = *(const uint32_t *)s;
- s += 4;
- *d++ = ((rgb & 0xFF) >> 3) +
- ((rgb & 0xF800) >> 6) +
- ((rgb & 0xF80000) >> 9);
- }
-}
-
-static inline void rgb32tobgr15_c(const uint8_t *src, uint8_t *dst,
- int src_size)
-{
- uint16_t *d = (uint16_t *)dst;
- const uint8_t *s = src;
- const uint8_t *end = s + src_size;
-
- while (s < end) {
- register int rgb = *(const uint32_t *)s;
- s += 4;
- *d++ = ((rgb & 0xF8) << 7) +
- ((rgb & 0xF800) >> 6) +
- ((rgb & 0xF80000) >> 19);
- }
-}
-
-static inline void rgb24tobgr16_c(const uint8_t *src, uint8_t *dst,
- int src_size)
-{
- uint16_t *d = (uint16_t *)dst;
- const uint8_t *s = src;
- const uint8_t *end = s + src_size;
-
- while (s < end) {
- const int b = *s++;
- const int g = *s++;
- const int r = *s++;
- *d++ = (b >> 3) | ((g & 0xFC) << 3) | ((r & 0xF8) << 8);
- }
-}
-
-static inline void rgb24to16_c(const uint8_t *src, uint8_t *dst, int src_size)
-{
- uint16_t *d = (uint16_t *)dst;
- const uint8_t *s = src;
- const uint8_t *end = s + src_size;
-
- while (s < end) {
- const int r = *s++;
- const int g = *s++;
- const int b = *s++;
- *d++ = (b >> 3) | ((g & 0xFC) << 3) | ((r & 0xF8) << 8);
- }
-}
-
-static inline void rgb24tobgr15_c(const uint8_t *src, uint8_t *dst,
- int src_size)
-{
- uint16_t *d = (uint16_t *)dst;
- const uint8_t *s = src;
- const uint8_t *end = s + src_size;
-
- while (s < end) {
- const int b = *s++;
- const int g = *s++;
- const int r = *s++;
- *d++ = (b >> 3) | ((g & 0xF8) << 2) | ((r & 0xF8) << 7);
- }
-}
-
-static inline void rgb24to15_c(const uint8_t *src, uint8_t *dst, int src_size)
-{
- uint16_t *d = (uint16_t *)dst;
- const uint8_t *s = src;
- const uint8_t *end = s + src_size;
-
- while (s < end) {
- const int r = *s++;
- const int g = *s++;
- const int b = *s++;
- *d++ = (b >> 3) | ((g & 0xF8) << 2) | ((r & 0xF8) << 7);
- }
-}
-
-static inline void rgb15tobgr24_c(const uint8_t *src, uint8_t *dst,
- int src_size)
-{
- uint8_t *d = dst;
- const uint16_t *s = (const uint16_t *)src;
- const uint16_t *end = s + src_size / 2;
-
- while (s < end) {
- register uint16_t bgr = *s++;
- *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2);
- *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7);
- *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
- }
-}
-
-static inline void rgb16tobgr24_c(const uint8_t *src, uint8_t *dst,
- int src_size)
-{
- uint8_t *d = (uint8_t *)dst;
- const uint16_t *s = (const uint16_t *)src;
- const uint16_t *end = s + src_size / 2;
-
- while (s < end) {
- register uint16_t bgr = *s++;
- *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2);
- *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9);
- *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
- }
-}
-
-static inline void rgb15to32_c(const uint8_t *src, uint8_t *dst, int src_size)
-{
- uint8_t *d = dst;
- const uint16_t *s = (const uint16_t *)src;
- const uint16_t *end = s + src_size / 2;
-
- while (s < end) {
- register uint16_t bgr = *s++;
-#if HAVE_BIGENDIAN
- *d++ = 255;
- *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
- *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7);
- *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2);
-#else
- *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2);
- *d++ = ((bgr&0x03E0)>>2) | ((bgr&0x03E0)>> 7);
- *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
- *d++ = 255;
-#endif
- }
-}
-
-static inline void rgb16to32_c(const uint8_t *src, uint8_t *dst, int src_size)
-{
- uint8_t *d = dst;
- const uint16_t *s = (const uint16_t *)src;
- const uint16_t *end = s + src_size / 2;
-
- while (s < end) {
- register uint16_t bgr = *s++;
-#if HAVE_BIGENDIAN
- *d++ = 255;
- *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
- *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9);
- *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2);
-#else
- *d++ = ((bgr&0x001F)<<3) | ((bgr&0x001F)>> 2);
- *d++ = ((bgr&0x07E0)>>3) | ((bgr&0x07E0)>> 9);
- *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
- *d++ = 255;
-#endif
- }
-}
-
-static inline void shuffle_bytes_2103_c(const uint8_t *src, uint8_t *dst,
- int src_size)
-{
- int idx = 15 - src_size;
- const uint8_t *s = src - idx;
- uint8_t *d = dst - idx;
-
- for (; idx < 15; idx += 4) {
- register int v = *(const uint32_t *)&s[idx], g = v & 0xff00ff00;
- v &= 0xff00ff;
- *(uint32_t *)&d[idx] = (v >> 16) + g + (v << 16);
- }
-}
-
-static inline void rgb24tobgr24_c(const uint8_t *src, uint8_t *dst, int src_size)
-{
- unsigned i;
-
- for (i = 0; i < src_size; i += 3) {
- register uint8_t x = src[i + 2];
- dst[i + 1] = src[i + 1];
- dst[i + 2] = src[i + 0];
- dst[i + 0] = x;
- }
-}
-
-static inline void yuvPlanartoyuy2_c(const uint8_t *ysrc, const uint8_t *usrc,
- const uint8_t *vsrc, uint8_t *dst,
- int width, int height,
- int lumStride, int chromStride,
- int dstStride, int vertLumPerChroma)
-{
- int y, i;
- const int chromWidth = width >> 1;
-
- for (y = 0; y < height; y++) {
-#if HAVE_FAST_64BIT
- uint64_t *ldst = (uint64_t *)dst;
- const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
- for (i = 0; i < chromWidth; i += 2) {
- uint64_t k = yc[0] + (uc[0] << 8) +
- (yc[1] << 16) + (unsigned)(vc[0] << 24);
- uint64_t l = yc[2] + (uc[1] << 8) +
- (yc[3] << 16) + (unsigned)(vc[1] << 24);
- *ldst++ = k + (l << 32);
- yc += 4;
- uc += 2;
- vc += 2;
- }
-
-#else
- int *idst = (int32_t *)dst;
- const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
-
- for (i = 0; i < chromWidth; i++) {
-#if HAVE_BIGENDIAN
- *idst++ = (yc[0] << 24) + (uc[0] << 16) +
- (yc[1] << 8) + (vc[0] << 0);
-#else
- *idst++ = yc[0] + (uc[0] << 8) +
- (yc[1] << 16) + (vc[0] << 24);
-#endif
- yc += 2;
- uc++;
- vc++;
- }
-#endif
- if ((y & (vertLumPerChroma - 1)) == vertLumPerChroma - 1) {
- usrc += chromStride;
- vsrc += chromStride;
- }
- ysrc += lumStride;
- dst += dstStride;
- }
-}
-
-/**
- * Height should be a multiple of 2 and width should be a multiple of 16.
- * (If this is a problem for anyone then tell me, and I will fix it.)
- */
-static inline void yv12toyuy2_c(const uint8_t *ysrc, const uint8_t *usrc,
- const uint8_t *vsrc, uint8_t *dst,
- int width, int height, int lumStride,
- int chromStride, int dstStride)
-{
- //FIXME interpolate chroma
- yuvPlanartoyuy2_c(ysrc, usrc, vsrc, dst, width, height, lumStride,
- chromStride, dstStride, 2);
-}
-
-static inline void yuvPlanartouyvy_c(const uint8_t *ysrc, const uint8_t *usrc,
- const uint8_t *vsrc, uint8_t *dst,
- int width, int height,
- int lumStride, int chromStride,
- int dstStride, int vertLumPerChroma)
-{
- int y, i;
- const int chromWidth = width >> 1;
-
- for (y = 0; y < height; y++) {
-#if HAVE_FAST_64BIT
- uint64_t *ldst = (uint64_t *)dst;
- const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
- for (i = 0; i < chromWidth; i += 2) {
- uint64_t k = uc[0] + (yc[0] << 8) +
- (vc[0] << 16) + (unsigned)(yc[1] << 24);
- uint64_t l = uc[1] + (yc[2] << 8) +
- (vc[1] << 16) + (unsigned)(yc[3] << 24);
- *ldst++ = k + (l << 32);
- yc += 4;
- uc += 2;
- vc += 2;
- }
-
-#else
- int *idst = (int32_t *)dst;
- const uint8_t *yc = ysrc, *uc = usrc, *vc = vsrc;
-
- for (i = 0; i < chromWidth; i++) {
-#if HAVE_BIGENDIAN
- *idst++ = (uc[0] << 24) + (yc[0] << 16) +
- (vc[0] << 8) + (yc[1] << 0);
-#else
- *idst++ = uc[0] + (yc[0] << 8) +
- (vc[0] << 16) + (yc[1] << 24);
-#endif
- yc += 2;
- uc++;
- vc++;
- }
-#endif
- if ((y & (vertLumPerChroma - 1)) == vertLumPerChroma - 1) {
- usrc += chromStride;
- vsrc += chromStride;
- }
- ysrc += lumStride;
- dst += dstStride;
- }
-}
-
-/**
- * Height should be a multiple of 2 and width should be a multiple of 16
- * (If this is a problem for anyone then tell me, and I will fix it.)
- */
-static inline void yv12touyvy_c(const uint8_t *ysrc, const uint8_t *usrc,
- const uint8_t *vsrc, uint8_t *dst,
- int width, int height, int lumStride,
- int chromStride, int dstStride)
-{
- //FIXME interpolate chroma
- yuvPlanartouyvy_c(ysrc, usrc, vsrc, dst, width, height, lumStride,
- chromStride, dstStride, 2);
-}
-
-/**
- * Width should be a multiple of 16.
- */
-static inline void yuv422ptouyvy_c(const uint8_t *ysrc, const uint8_t *usrc,
- const uint8_t *vsrc, uint8_t *dst,
- int width, int height, int lumStride,
- int chromStride, int dstStride)
-{
- yuvPlanartouyvy_c(ysrc, usrc, vsrc, dst, width, height, lumStride,
- chromStride, dstStride, 1);
-}
-
-/**
- * Width should be a multiple of 16.
- */
-static inline void yuv422ptoyuy2_c(const uint8_t *ysrc, const uint8_t *usrc,
- const uint8_t *vsrc, uint8_t *dst,
- int width, int height, int lumStride,
- int chromStride, int dstStride)
-{
- yuvPlanartoyuy2_c(ysrc, usrc, vsrc, dst, width, height, lumStride,
- chromStride, dstStride, 1);
-}
-
-/**
- * Height should be a multiple of 2 and width should be a multiple of 16.
- * (If this is a problem for anyone then tell me, and I will fix it.)
- */
-static inline void yuy2toyv12_c(const uint8_t *src, uint8_t *ydst,
- uint8_t *udst, uint8_t *vdst,
- int width, int height, int lumStride,
- int chromStride, int srcStride)
-{
- int y;
- const int chromWidth = width >> 1;
-
- for (y = 0; y < height; y += 2) {
- int i;
- for (i = 0; i < chromWidth; i++) {
- ydst[2 * i + 0] = src[4 * i + 0];
- udst[i] = src[4 * i + 1];
- ydst[2 * i + 1] = src[4 * i + 2];
- vdst[i] = src[4 * i + 3];
- }
- ydst += lumStride;
- src += srcStride;
-
- for (i = 0; i < chromWidth; i++) {
- ydst[2 * i + 0] = src[4 * i + 0];
- ydst[2 * i + 1] = src[4 * i + 2];
- }
- udst += chromStride;
- vdst += chromStride;
- ydst += lumStride;
- src += srcStride;
- }
-}
-
-static inline void planar2x_c(const uint8_t *src, uint8_t *dst, int srcWidth,
- int srcHeight, int srcStride, int dstStride)
-{
- int x, y;
-
- dst[0] = src[0];
-
- // first line
- for (x = 0; x < srcWidth - 1; x++) {
- dst[2 * x + 1] = (3 * src[x] + src[x + 1]) >> 2;
- dst[2 * x + 2] = (src[x] + 3 * src[x + 1]) >> 2;
- }
- dst[2 * srcWidth - 1] = src[srcWidth - 1];
-
- dst += dstStride;
-
- for (y = 1; y < srcHeight; y++) {
- const int mmxSize = 1;
-
- dst[0] = (src[0] * 3 + src[srcStride]) >> 2;
- dst[dstStride] = (src[0] + 3 * src[srcStride]) >> 2;
-
- for (x = mmxSize - 1; x < srcWidth - 1; x++) {
- dst[2 * x + 1] = (src[x + 0] * 3 + src[x + srcStride + 1]) >> 2;
- dst[2 * x + dstStride + 2] = (src[x + 0] + 3 * src[x + srcStride + 1]) >> 2;
- dst[2 * x + dstStride + 1] = (src[x + 1] + 3 * src[x + srcStride]) >> 2;
- dst[2 * x + 2] = (src[x + 1] * 3 + src[x + srcStride]) >> 2;
- }
- dst[srcWidth * 2 - 1] = (src[srcWidth - 1] * 3 + src[srcWidth - 1 + srcStride]) >> 2;
- dst[srcWidth * 2 - 1 + dstStride] = (src[srcWidth - 1] + 3 * src[srcWidth - 1 + srcStride]) >> 2;
-
- dst += dstStride * 2;
- src += srcStride;
- }
-
- // last line
- dst[0] = src[0];
-
- for (x = 0; x < srcWidth - 1; x++) {
- dst[2 * x + 1] = (src[x] * 3 + src[x + 1]) >> 2;
- dst[2 * x + 2] = (src[x] + 3 * src[x + 1]) >> 2;
- }
- dst[2 * srcWidth - 1] = src[srcWidth - 1];
-}
-
-/**
- * Height should be a multiple of 2 and width should be a multiple of 16.
- * (If this is a problem for anyone then tell me, and I will fix it.)
- * Chrominance data is only taken from every second line, others are ignored.
- * FIXME: Write HQ version.
- */
-static inline void uyvytoyv12_c(const uint8_t *src, uint8_t *ydst,
- uint8_t *udst, uint8_t *vdst,
- int width, int height, int lumStride,
- int chromStride, int srcStride)
-{
- int y;
- const int chromWidth = width >> 1;
-
- for (y = 0; y < height; y += 2) {
- int i;
- for (i = 0; i < chromWidth; i++) {
- udst[i] = src[4 * i + 0];
- ydst[2 * i + 0] = src[4 * i + 1];
- vdst[i] = src[4 * i + 2];
- ydst[2 * i + 1] = src[4 * i + 3];
- }
- ydst += lumStride;
- src += srcStride;
-
- for (i = 0; i < chromWidth; i++) {
- ydst[2 * i + 0] = src[4 * i + 1];
- ydst[2 * i + 1] = src[4 * i + 3];
- }
- udst += chromStride;
- vdst += chromStride;
- ydst += lumStride;
- src += srcStride;
- }
-}
-
-/**
- * Height should be a multiple of 2 and width should be a multiple of 2.
- * (If this is a problem for anyone then tell me, and I will fix it.)
- * Chrominance data is only taken from every second line,
- * others are ignored in the C version.
- * FIXME: Write HQ version.
- */
-void rgb24toyv12_c(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
- uint8_t *vdst, int width, int height, int lumStride,
- int chromStride, int srcStride)
-{
- int y;
- const int chromWidth = width >> 1;
-
- for (y = 0; y < height; y += 2) {
- int i;
- for (i = 0; i < chromWidth; i++) {
- unsigned int b = src[6 * i + 0];
- unsigned int g = src[6 * i + 1];
- unsigned int r = src[6 * i + 2];
-
- unsigned int Y = ((RY * r + GY * g + BY * b) >> RGB2YUV_SHIFT) + 16;
- unsigned int V = ((RV * r + GV * g + BV * b) >> RGB2YUV_SHIFT) + 128;
- unsigned int U = ((RU * r + GU * g + BU * b) >> RGB2YUV_SHIFT) + 128;
-
- udst[i] = U;
- vdst[i] = V;
- ydst[2 * i] = Y;
-
- b = src[6 * i + 3];
- g = src[6 * i + 4];
- r = src[6 * i + 5];
-
- Y = ((RY * r + GY * g + BY * b) >> RGB2YUV_SHIFT) + 16;
- ydst[2 * i + 1] = Y;
- }
- ydst += lumStride;
- src += srcStride;
-
- if (y+1 == height)
- break;
-
- for (i = 0; i < chromWidth; i++) {
- unsigned int b = src[6 * i + 0];
- unsigned int g = src[6 * i + 1];
- unsigned int r = src[6 * i + 2];
-
- unsigned int Y = ((RY * r + GY * g + BY * b) >> RGB2YUV_SHIFT) + 16;
-
- ydst[2 * i] = Y;
-
- b = src[6 * i + 3];
- g = src[6 * i + 4];
- r = src[6 * i + 5];
-
- Y = ((RY * r + GY * g + BY * b) >> RGB2YUV_SHIFT) + 16;
- ydst[2 * i + 1] = Y;
- }
- udst += chromStride;
- vdst += chromStride;
- ydst += lumStride;
- src += srcStride;
- }
-}
-
-static void interleaveBytes_c(const uint8_t *src1, const uint8_t *src2,
- uint8_t *dest, int width, int height,
- int src1Stride, int src2Stride, int dstStride)
-{
- int h;
-
- for (h = 0; h < height; h++) {
- int w;
- for (w = 0; w < width; w++) {
- dest[2 * w + 0] = src1[w];
- dest[2 * w + 1] = src2[w];
- }
- dest += dstStride;
- src1 += src1Stride;
- src2 += src2Stride;
- }
-}
-
-static inline void vu9_to_vu12_c(const uint8_t *src1, const uint8_t *src2,
- uint8_t *dst1, uint8_t *dst2,
- int width, int height,
- int srcStride1, int srcStride2,
- int dstStride1, int dstStride2)
-{
- int x, y;
- int w = width / 2;
- int h = height / 2;
-
- for (y = 0; y < h; y++) {
- const uint8_t *s1 = src1 + srcStride1 * (y >> 1);
- uint8_t *d = dst1 + dstStride1 * y;
- for (x = 0; x < w; x++)
- d[2 * x] = d[2 * x + 1] = s1[x];
- }
- for (y = 0; y < h; y++) {
- const uint8_t *s2 = src2 + srcStride2 * (y >> 1);
- uint8_t *d = dst2 + dstStride2 * y;
- for (x = 0; x < w; x++)
- d[2 * x] = d[2 * x + 1] = s2[x];
- }
-}
-
-static inline void yvu9_to_yuy2_c(const uint8_t *src1, const uint8_t *src2,
- const uint8_t *src3, uint8_t *dst,
- int width, int height,
- int srcStride1, int srcStride2,
- int srcStride3, int dstStride)
-{
- int x, y;
- int w = width / 2;
- int h = height;
-
- for (y = 0; y < h; y++) {
- const uint8_t *yp = src1 + srcStride1 * y;
- const uint8_t *up = src2 + srcStride2 * (y >> 2);
- const uint8_t *vp = src3 + srcStride3 * (y >> 2);
- uint8_t *d = dst + dstStride * y;
- for (x = 0; x < w; x++) {
- const int x2 = x << 2;
- d[8 * x + 0] = yp[x2];
- d[8 * x + 1] = up[x];
- d[8 * x + 2] = yp[x2 + 1];
- d[8 * x + 3] = vp[x];
- d[8 * x + 4] = yp[x2 + 2];
- d[8 * x + 5] = up[x];
- d[8 * x + 6] = yp[x2 + 3];
- d[8 * x + 7] = vp[x];
- }
- }
-}
-
-static void extract_even_c(const uint8_t *src, uint8_t *dst, int count)
-{
- dst += count;
- src += count * 2;
- count = -count;
- while (count < 0) {
- dst[count] = src[2 * count];
- count++;
- }
-}
-
-static void extract_even2_c(const uint8_t *src, uint8_t *dst0, uint8_t *dst1,
- int count)
-{
- dst0 += count;
- dst1 += count;
- src += count * 4;
- count = -count;
- while (count < 0) {
- dst0[count] = src[4 * count + 0];
- dst1[count] = src[4 * count + 2];
- count++;
- }
-}
-
-static void extract_even2avg_c(const uint8_t *src0, const uint8_t *src1,
- uint8_t *dst0, uint8_t *dst1, int count)
-{
- dst0 += count;
- dst1 += count;
- src0 += count * 4;
- src1 += count * 4;
- count = -count;
- while (count < 0) {
- dst0[count] = (src0[4 * count + 0] + src1[4 * count + 0]) >> 1;
- dst1[count] = (src0[4 * count + 2] + src1[4 * count + 2]) >> 1;
- count++;
- }
-}
-
-static void extract_odd2_c(const uint8_t *src, uint8_t *dst0, uint8_t *dst1,
- int count)
-{
- dst0 += count;
- dst1 += count;
- src += count * 4;
- count = -count;
- src++;
- while (count < 0) {
- dst0[count] = src[4 * count + 0];
- dst1[count] = src[4 * count + 2];
- count++;
- }
-}
-
-static void extract_odd2avg_c(const uint8_t *src0, const uint8_t *src1,
- uint8_t *dst0, uint8_t *dst1, int count)
-{
- dst0 += count;
- dst1 += count;
- src0 += count * 4;
- src1 += count * 4;
- count = -count;
- src0++;
- src1++;
- while (count < 0) {
- dst0[count] = (src0[4 * count + 0] + src1[4 * count + 0]) >> 1;
- dst1[count] = (src0[4 * count + 2] + src1[4 * count + 2]) >> 1;
- count++;
- }
-}
-
-static void yuyvtoyuv420_c(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
- const uint8_t *src, int width, int height,
- int lumStride, int chromStride, int srcStride)
-{
- int y;
- const int chromWidth = -((-width) >> 1);
-
- for (y = 0; y < height; y++) {
- extract_even_c(src, ydst, width);
- if (y & 1) {
- extract_odd2avg_c(src - srcStride, src, udst, vdst, chromWidth);
- udst += chromStride;
- vdst += chromStride;
- }
-
- src += srcStride;
- ydst += lumStride;
- }
-}
-
-static void yuyvtoyuv422_c(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
- const uint8_t *src, int width, int height,
- int lumStride, int chromStride, int srcStride)
-{
- int y;
- const int chromWidth = -((-width) >> 1);
-
- for (y = 0; y < height; y++) {
- extract_even_c(src, ydst, width);
- extract_odd2_c(src, udst, vdst, chromWidth);
-
- src += srcStride;
- ydst += lumStride;
- udst += chromStride;
- vdst += chromStride;
- }
-}
-
-static void uyvytoyuv420_c(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
- const uint8_t *src, int width, int height,
- int lumStride, int chromStride, int srcStride)
-{
- int y;
- const int chromWidth = -((-width) >> 1);
-
- for (y = 0; y < height; y++) {
- extract_even_c(src + 1, ydst, width);
- if (y & 1) {
- extract_even2avg_c(src - srcStride, src, udst, vdst, chromWidth);
- udst += chromStride;
- vdst += chromStride;
- }
-
- src += srcStride;
- ydst += lumStride;
- }
-}
-
-static void uyvytoyuv422_c(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
- const uint8_t *src, int width, int height,
- int lumStride, int chromStride, int srcStride)
-{
- int y;
- const int chromWidth = -((-width) >> 1);
-
- for (y = 0; y < height; y++) {
- extract_even_c(src + 1, ydst, width);
- extract_even2_c(src, udst, vdst, chromWidth);
-
- src += srcStride;
- ydst += lumStride;
- udst += chromStride;
- vdst += chromStride;
- }
-}
-
-static inline void rgb2rgb_init_c(void)
-{
- rgb15to16 = rgb15to16_c;
- rgb15tobgr24 = rgb15tobgr24_c;
- rgb15to32 = rgb15to32_c;
- rgb16tobgr24 = rgb16tobgr24_c;
- rgb16to32 = rgb16to32_c;
- rgb16to15 = rgb16to15_c;
- rgb24tobgr16 = rgb24tobgr16_c;
- rgb24tobgr15 = rgb24tobgr15_c;
- rgb24tobgr32 = rgb24tobgr32_c;
- rgb32to16 = rgb32to16_c;
- rgb32to15 = rgb32to15_c;
- rgb32tobgr24 = rgb32tobgr24_c;
- rgb24to15 = rgb24to15_c;
- rgb24to16 = rgb24to16_c;
- rgb24tobgr24 = rgb24tobgr24_c;
- shuffle_bytes_2103 = shuffle_bytes_2103_c;
- rgb32tobgr16 = rgb32tobgr16_c;
- rgb32tobgr15 = rgb32tobgr15_c;
- yv12toyuy2 = yv12toyuy2_c;
- yv12touyvy = yv12touyvy_c;
- yuv422ptoyuy2 = yuv422ptoyuy2_c;
- yuv422ptouyvy = yuv422ptouyvy_c;
- yuy2toyv12 = yuy2toyv12_c;
- planar2x = planar2x_c;
- rgb24toyv12 = rgb24toyv12_c;
- interleaveBytes = interleaveBytes_c;
- vu9_to_vu12 = vu9_to_vu12_c;
- yvu9_to_yuy2 = yvu9_to_yuy2_c;
-
- uyvytoyuv420 = uyvytoyuv420_c;
- uyvytoyuv422 = uyvytoyuv422_c;
- yuyvtoyuv420 = yuyvtoyuv420_c;
- yuyvtoyuv422 = yuyvtoyuv422_c;
-}
diff --git a/src/thirdparty/ffmpeg/libswscale/swscale.c b/src/thirdparty/ffmpeg/libswscale/swscale.c
deleted file mode 100644
index 1c164e925..000000000
--- a/src/thirdparty/ffmpeg/libswscale/swscale.c
+++ /dev/null
@@ -1,974 +0,0 @@
-/*
- * Copyright (C) 2001-2011 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
- */
-
-#include <assert.h>
-#include <inttypes.h>
-#include <math.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "libavutil/avassert.h"
-#include "libavutil/avutil.h"
-#include "libavutil/bswap.h"
-#include "libavutil/cpu.h"
-#include "libavutil/intreadwrite.h"
-#include "libavutil/mathematics.h"
-#include "libavutil/pixdesc.h"
-#include "config.h"
-#include "rgb2rgb.h"
-#include "swscale_internal.h"
-#include "swscale.h"
-
-DECLARE_ALIGNED(8, const uint8_t, dither_8x8_128)[8][8] = {
- { 36, 68, 60, 92, 34, 66, 58, 90, },
- { 100, 4, 124, 28, 98, 2, 122, 26, },
- { 52, 84, 44, 76, 50, 82, 42, 74, },
- { 116, 20, 108, 12, 114, 18, 106, 10, },
- { 32, 64, 56, 88, 38, 70, 62, 94, },
- { 96, 0, 120, 24, 102, 6, 126, 30, },
- { 48, 80, 40, 72, 54, 86, 46, 78, },
- { 112, 16, 104, 8, 118, 22, 110, 14, },
-};
-
-DECLARE_ALIGNED(8, const uint8_t, ff_sws_pb_64)[8] = {
- 64, 64, 64, 64, 64, 64, 64, 64
-};
-
-static av_always_inline void fillPlane(uint8_t *plane, int stride, int width,
- int height, int y, uint8_t val)
-{
- int i;
- uint8_t *ptr = plane + stride * y;
- for (i = 0; i < height; i++) {
- memset(ptr, val, width);
- ptr += stride;
- }
-}
-
-static void hScale16To19_c(SwsContext *c, int16_t *_dst, int dstW,
- const uint8_t *_src, const int16_t *filter,
- const int32_t *filterPos, int filterSize)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
- int i;
- int32_t *dst = (int32_t *) _dst;
- const uint16_t *src = (const uint16_t *) _src;
- int bits = desc->comp[0].depth_minus1;
- int sh = bits - 4;
-
- if((isAnyRGB(c->srcFormat) || c->srcFormat==AV_PIX_FMT_PAL8) && desc->comp[0].depth_minus1<15)
- sh= 9;
-
- for (i = 0; i < dstW; i++) {
- int j;
- int srcPos = filterPos[i];
- int val = 0;
-
- for (j = 0; j < filterSize; j++) {
- val += src[srcPos + j] * filter[filterSize * i + j];
- }
- // filter=14 bit, input=16 bit, output=30 bit, >> 11 makes 19 bit
- dst[i] = FFMIN(val >> sh, (1 << 19) - 1);
- }
-}
-
-static void hScale16To15_c(SwsContext *c, int16_t *dst, int dstW,
- const uint8_t *_src, const int16_t *filter,
- const int32_t *filterPos, int filterSize)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
- int i;
- const uint16_t *src = (const uint16_t *) _src;
- int sh = desc->comp[0].depth_minus1;
-
- if(sh<15)
- sh= isAnyRGB(c->srcFormat) || c->srcFormat==AV_PIX_FMT_PAL8 ? 13 : desc->comp[0].depth_minus1;
-
- for (i = 0; i < dstW; i++) {
- int j;
- int srcPos = filterPos[i];
- int val = 0;
-
- for (j = 0; j < filterSize; j++) {
- val += src[srcPos + j] * filter[filterSize * i + j];
- }
- // filter=14 bit, input=16 bit, output=30 bit, >> 15 makes 15 bit
- dst[i] = FFMIN(val >> sh, (1 << 15) - 1);
- }
-}
-
-// bilinear / bicubic scaling
-static void hScale8To15_c(SwsContext *c, int16_t *dst, int dstW,
- const uint8_t *src, const int16_t *filter,
- const int32_t *filterPos, int filterSize)
-{
- int i;
- for (i = 0; i < dstW; i++) {
- int j;
- int srcPos = filterPos[i];
- int val = 0;
- for (j = 0; j < filterSize; j++) {
- val += ((int)src[srcPos + j]) * filter[filterSize * i + j];
- }
- dst[i] = FFMIN(val >> 7, (1 << 15) - 1); // the cubic equation does overflow ...
- }
-}
-
-static void hScale8To19_c(SwsContext *c, int16_t *_dst, int dstW,
- const uint8_t *src, const int16_t *filter,
- const int32_t *filterPos, int filterSize)
-{
- int i;
- int32_t *dst = (int32_t *) _dst;
- for (i = 0; i < dstW; i++) {
- int j;
- int srcPos = filterPos[i];
- int val = 0;
- for (j = 0; j < filterSize; j++) {
- val += ((int)src[srcPos + j]) * filter[filterSize * i + j];
- }
- dst[i] = FFMIN(val >> 3, (1 << 19) - 1); // the cubic equation does overflow ...
- }
-}
-
-// FIXME all pal and rgb srcFormats could do this conversion as well
-// FIXME all scalers more complex than bilinear could do half of this transform
-static void chrRangeToJpeg_c(int16_t *dstU, int16_t *dstV, int width)
-{
- int i;
- for (i = 0; i < width; i++) {
- dstU[i] = (FFMIN(dstU[i], 30775) * 4663 - 9289992) >> 12; // -264
- dstV[i] = (FFMIN(dstV[i], 30775) * 4663 - 9289992) >> 12; // -264
- }
-}
-
-static void chrRangeFromJpeg_c(int16_t *dstU, int16_t *dstV, int width)
-{
- int i;
- for (i = 0; i < width; i++) {
- dstU[i] = (dstU[i] * 1799 + 4081085) >> 11; // 1469
- dstV[i] = (dstV[i] * 1799 + 4081085) >> 11; // 1469
- }
-}
-
-static void lumRangeToJpeg_c(int16_t *dst, int width)
-{
- int i;
- for (i = 0; i < width; i++)
- dst[i] = (FFMIN(dst[i], 30189) * 19077 - 39057361) >> 14;
-}
-
-static void lumRangeFromJpeg_c(int16_t *dst, int width)
-{
- int i;
- for (i = 0; i < width; i++)
- dst[i] = (dst[i] * 14071 + 33561947) >> 14;
-}
-
-static void chrRangeToJpeg16_c(int16_t *_dstU, int16_t *_dstV, int width)
-{
- int i;
- int32_t *dstU = (int32_t *) _dstU;
- int32_t *dstV = (int32_t *) _dstV;
- for (i = 0; i < width; i++) {
- dstU[i] = (FFMIN(dstU[i], 30775 << 4) * 4663 - (9289992 << 4)) >> 12; // -264
- dstV[i] = (FFMIN(dstV[i], 30775 << 4) * 4663 - (9289992 << 4)) >> 12; // -264
- }
-}
-
-static void chrRangeFromJpeg16_c(int16_t *_dstU, int16_t *_dstV, int width)
-{
- int i;
- int32_t *dstU = (int32_t *) _dstU;
- int32_t *dstV = (int32_t *) _dstV;
- for (i = 0; i < width; i++) {
- dstU[i] = (dstU[i] * 1799 + (4081085 << 4)) >> 11; // 1469
- dstV[i] = (dstV[i] * 1799 + (4081085 << 4)) >> 11; // 1469
- }
-}
-
-static void lumRangeToJpeg16_c(int16_t *_dst, int width)
-{
- int i;
- int32_t *dst = (int32_t *) _dst;
- for (i = 0; i < width; i++)
- dst[i] = (FFMIN(dst[i], 30189 << 4) * 4769 - (39057361 << 2)) >> 12;
-}
-
-static void lumRangeFromJpeg16_c(int16_t *_dst, int width)
-{
- int i;
- int32_t *dst = (int32_t *) _dst;
- for (i = 0; i < width; i++)
- dst[i] = (dst[i]*(14071/4) + (33561947<<4)/4)>>12;
-}
-
-static void hyscale_fast_c(SwsContext *c, int16_t *dst, int dstWidth,
- const uint8_t *src, int srcW, int xInc)
-{
- int i;
- unsigned int xpos = 0;
- for (i = 0; i < dstWidth; i++) {
- register unsigned int xx = xpos >> 16;
- register unsigned int xalpha = (xpos & 0xFFFF) >> 9;
- dst[i] = (src[xx] << 7) + (src[xx + 1] - src[xx]) * xalpha;
- xpos += xInc;
- }
- for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--)
- dst[i] = src[srcW-1]*128;
-}
-
-// *** horizontal scale Y line to temp buffer
-static av_always_inline void hyscale(SwsContext *c, int16_t *dst, int dstWidth,
- const uint8_t *src_in[4],
- int srcW, int xInc,
- const int16_t *hLumFilter,
- const int32_t *hLumFilterPos,
- int hLumFilterSize,
- uint8_t *formatConvBuffer,
- uint32_t *pal, int isAlpha)
-{
- void (*toYV12)(uint8_t *, const uint8_t *, const uint8_t *, const uint8_t *, int, uint32_t *) =
- isAlpha ? c->alpToYV12 : c->lumToYV12;
- void (*convertRange)(int16_t *, int) = isAlpha ? NULL : c->lumConvertRange;
- const uint8_t *src = src_in[isAlpha ? 3 : 0];
-
- if (toYV12) {
- toYV12(formatConvBuffer, src, src_in[1], src_in[2], srcW, pal);
- src = formatConvBuffer;
- } else if (c->readLumPlanar && !isAlpha) {
- c->readLumPlanar(formatConvBuffer, src_in, srcW);
- src = formatConvBuffer;
- }
-
- if (!c->hyscale_fast) {
- c->hyScale(c, dst, dstWidth, src, hLumFilter,
- hLumFilterPos, hLumFilterSize);
- } else { // fast bilinear upscale / crap downscale
- c->hyscale_fast(c, dst, dstWidth, src, srcW, xInc);
- }
-
- if (convertRange)
- convertRange(dst, dstWidth);
-}
-
-static void hcscale_fast_c(SwsContext *c, int16_t *dst1, int16_t *dst2,
- int dstWidth, const uint8_t *src1,
- const uint8_t *src2, int srcW, int xInc)
-{
- int i;
- unsigned int xpos = 0;
- for (i = 0; i < dstWidth; i++) {
- register unsigned int xx = xpos >> 16;
- register unsigned int xalpha = (xpos & 0xFFFF) >> 9;
- dst1[i] = (src1[xx] * (xalpha ^ 127) + src1[xx + 1] * xalpha);
- dst2[i] = (src2[xx] * (xalpha ^ 127) + src2[xx + 1] * xalpha);
- xpos += xInc;
- }
- for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) {
- dst1[i] = src1[srcW-1]*128;
- dst2[i] = src2[srcW-1]*128;
- }
-}
-
-static av_always_inline void hcscale(SwsContext *c, int16_t *dst1,
- int16_t *dst2, int dstWidth,
- const uint8_t *src_in[4],
- int srcW, int xInc,
- const int16_t *hChrFilter,
- const int32_t *hChrFilterPos,
- int hChrFilterSize,
- uint8_t *formatConvBuffer, uint32_t *pal)
-{
- const uint8_t *src1 = src_in[1], *src2 = src_in[2];
- if (c->chrToYV12) {
- uint8_t *buf2 = formatConvBuffer +
- FFALIGN(srcW*2+78, 16);
- c->chrToYV12(formatConvBuffer, buf2, src_in[0], src1, src2, srcW, pal);
- src1= formatConvBuffer;
- src2= buf2;
- } else if (c->readChrPlanar) {
- uint8_t *buf2 = formatConvBuffer +
- FFALIGN(srcW*2+78, 16);
- c->readChrPlanar(formatConvBuffer, buf2, src_in, srcW);
- src1 = formatConvBuffer;
- src2 = buf2;
- }
-
- if (!c->hcscale_fast) {
- c->hcScale(c, dst1, dstWidth, src1, hChrFilter, hChrFilterPos, hChrFilterSize);
- c->hcScale(c, dst2, dstWidth, src2, hChrFilter, hChrFilterPos, hChrFilterSize);
- } else { // fast bilinear upscale / crap downscale
- c->hcscale_fast(c, dst1, dst2, dstWidth, src1, src2, srcW, xInc);
- }
-
- if (c->chrConvertRange)
- c->chrConvertRange(dst1, dst2, dstWidth);
-}
-
-#define DEBUG_SWSCALE_BUFFERS 0
-#define DEBUG_BUFFERS(...) \
- if (DEBUG_SWSCALE_BUFFERS) \
- av_log(c, AV_LOG_DEBUG, __VA_ARGS__)
-
-static int swScale(SwsContext *c, const uint8_t *src[],
- int srcStride[], int srcSliceY,
- int srcSliceH, uint8_t *dst[], int dstStride[])
-{
- /* load a few things into local vars to make the code more readable?
- * and faster */
- const int srcW = c->srcW;
- const int dstW = c->dstW;
- const int dstH = c->dstH;
- const int chrDstW = c->chrDstW;
- const int chrSrcW = c->chrSrcW;
- const int lumXInc = c->lumXInc;
- const int chrXInc = c->chrXInc;
- const enum AVPixelFormat dstFormat = c->dstFormat;
- const int flags = c->flags;
- int32_t *vLumFilterPos = c->vLumFilterPos;
- int32_t *vChrFilterPos = c->vChrFilterPos;
- int32_t *hLumFilterPos = c->hLumFilterPos;
- int32_t *hChrFilterPos = c->hChrFilterPos;
- int16_t *hLumFilter = c->hLumFilter;
- int16_t *hChrFilter = c->hChrFilter;
- int32_t *lumMmxFilter = c->lumMmxFilter;
- int32_t *chrMmxFilter = c->chrMmxFilter;
- const int vLumFilterSize = c->vLumFilterSize;
- const int vChrFilterSize = c->vChrFilterSize;
- const int hLumFilterSize = c->hLumFilterSize;
- const int hChrFilterSize = c->hChrFilterSize;
- int16_t **lumPixBuf = c->lumPixBuf;
- int16_t **chrUPixBuf = c->chrUPixBuf;
- int16_t **chrVPixBuf = c->chrVPixBuf;
- int16_t **alpPixBuf = c->alpPixBuf;
- const int vLumBufSize = c->vLumBufSize;
- const int vChrBufSize = c->vChrBufSize;
- uint8_t *formatConvBuffer = c->formatConvBuffer;
- uint32_t *pal = c->pal_yuv;
- yuv2planar1_fn yuv2plane1 = c->yuv2plane1;
- yuv2planarX_fn yuv2planeX = c->yuv2planeX;
- yuv2interleavedX_fn yuv2nv12cX = c->yuv2nv12cX;
- yuv2packed1_fn yuv2packed1 = c->yuv2packed1;
- yuv2packed2_fn yuv2packed2 = c->yuv2packed2;
- yuv2packedX_fn yuv2packedX = c->yuv2packedX;
- yuv2anyX_fn yuv2anyX = c->yuv2anyX;
- const int chrSrcSliceY = srcSliceY >> c->chrSrcVSubSample;
- const int chrSrcSliceH = -((-srcSliceH) >> c->chrSrcVSubSample);
- int should_dither = is9_OR_10BPS(c->srcFormat) ||
- is16BPS(c->srcFormat);
- int lastDstY;
-
- /* vars which will change and which we need to store back in the context */
- int dstY = c->dstY;
- int lumBufIndex = c->lumBufIndex;
- int chrBufIndex = c->chrBufIndex;
- int lastInLumBuf = c->lastInLumBuf;
- int lastInChrBuf = c->lastInChrBuf;
-
- if (isPacked(c->srcFormat)) {
- src[0] =
- src[1] =
- src[2] =
- src[3] = src[0];
- srcStride[0] =
- srcStride[1] =
- srcStride[2] =
- srcStride[3] = srcStride[0];
- }
- srcStride[1] <<= c->vChrDrop;
- srcStride[2] <<= c->vChrDrop;
-
- DEBUG_BUFFERS("swScale() %p[%d] %p[%d] %p[%d] %p[%d] -> %p[%d] %p[%d] %p[%d] %p[%d]\n",
- src[0], srcStride[0], src[1], srcStride[1],
- src[2], srcStride[2], src[3], srcStride[3],
- dst[0], dstStride[0], dst[1], dstStride[1],
- dst[2], dstStride[2], dst[3], dstStride[3]);
- DEBUG_BUFFERS("srcSliceY: %d srcSliceH: %d dstY: %d dstH: %d\n",
- srcSliceY, srcSliceH, dstY, dstH);
- DEBUG_BUFFERS("vLumFilterSize: %d vLumBufSize: %d vChrFilterSize: %d vChrBufSize: %d\n",
- vLumFilterSize, vLumBufSize, vChrFilterSize, vChrBufSize);
-
- if (dstStride[0]%16 !=0 || dstStride[1]%16 !=0 ||
- dstStride[2]%16 !=0 || dstStride[3]%16 != 0) {
- static int warnedAlready = 0; // FIXME maybe move this into the context
- if (flags & SWS_PRINT_INFO && !warnedAlready) {
- av_log(c, AV_LOG_WARNING,
- "Warning: dstStride is not aligned!\n"
- " ->cannot do aligned memory accesses anymore\n");
- warnedAlready = 1;
- }
- }
-
- if ( (uintptr_t)dst[0]%16 || (uintptr_t)dst[1]%16 || (uintptr_t)dst[2]%16
- || (uintptr_t)src[0]%16 || (uintptr_t)src[1]%16 || (uintptr_t)src[2]%16
- || dstStride[0]%16 || dstStride[1]%16 || dstStride[2]%16 || dstStride[3]%16
- || srcStride[0]%16 || srcStride[1]%16 || srcStride[2]%16 || srcStride[3]%16
- ) {
- static int warnedAlready=0;
- int cpu_flags = av_get_cpu_flags();
- if (HAVE_MMXEXT && (cpu_flags & AV_CPU_FLAG_SSE2) && !warnedAlready){
- av_log(c, AV_LOG_WARNING, "Warning: data is not aligned! This can lead to a speedloss\n");
- warnedAlready=1;
- }
- }
-
- /* Note the user might start scaling the picture in the middle so this
- * will not get executed. This is not really intended but works
- * currently, so people might do it. */
- if (srcSliceY == 0) {
- lumBufIndex = -1;
- chrBufIndex = -1;
- dstY = 0;
- lastInLumBuf = -1;
- lastInChrBuf = -1;
- }
-
- if (!should_dither) {
- c->chrDither8 = c->lumDither8 = ff_sws_pb_64;
- }
- lastDstY = dstY;
-
- for (; dstY < dstH; dstY++) {
- const int chrDstY = dstY >> c->chrDstVSubSample;
- uint8_t *dest[4] = {
- dst[0] + dstStride[0] * dstY,
- dst[1] + dstStride[1] * chrDstY,
- dst[2] + dstStride[2] * chrDstY,
- (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? dst[3] + dstStride[3] * dstY : NULL,
- };
- int use_mmx_vfilter= c->use_mmx_vfilter;
-
- // First line needed as input
- const int firstLumSrcY = FFMAX(1 - vLumFilterSize, vLumFilterPos[dstY]);
- const int firstLumSrcY2 = FFMAX(1 - vLumFilterSize, vLumFilterPos[FFMIN(dstY | ((1 << c->chrDstVSubSample) - 1), dstH - 1)]);
- // First line needed as input
- const int firstChrSrcY = FFMAX(1 - vChrFilterSize, vChrFilterPos[chrDstY]);
-
- // Last line needed as input
- int lastLumSrcY = FFMIN(c->srcH, firstLumSrcY + vLumFilterSize) - 1;
- int lastLumSrcY2 = FFMIN(c->srcH, firstLumSrcY2 + vLumFilterSize) - 1;
- int lastChrSrcY = FFMIN(c->chrSrcH, firstChrSrcY + vChrFilterSize) - 1;
- int enough_lines;
-
- // handle holes (FAST_BILINEAR & weird filters)
- if (firstLumSrcY > lastInLumBuf)
- lastInLumBuf = firstLumSrcY - 1;
- if (firstChrSrcY > lastInChrBuf)
- lastInChrBuf = firstChrSrcY - 1;
- av_assert0(firstLumSrcY >= lastInLumBuf - vLumBufSize + 1);
- av_assert0(firstChrSrcY >= lastInChrBuf - vChrBufSize + 1);
-
- DEBUG_BUFFERS("dstY: %d\n", dstY);
- DEBUG_BUFFERS("\tfirstLumSrcY: %d lastLumSrcY: %d lastInLumBuf: %d\n",
- firstLumSrcY, lastLumSrcY, lastInLumBuf);
- DEBUG_BUFFERS("\tfirstChrSrcY: %d lastChrSrcY: %d lastInChrBuf: %d\n",
- firstChrSrcY, lastChrSrcY, lastInChrBuf);
-
- // Do we have enough lines in this slice to output the dstY line
- enough_lines = lastLumSrcY2 < srcSliceY + srcSliceH &&
- lastChrSrcY < -((-srcSliceY - srcSliceH) >> c->chrSrcVSubSample);
-
- if (!enough_lines) {
- lastLumSrcY = srcSliceY + srcSliceH - 1;
- lastChrSrcY = chrSrcSliceY + chrSrcSliceH - 1;
- DEBUG_BUFFERS("buffering slice: lastLumSrcY %d lastChrSrcY %d\n",
- lastLumSrcY, lastChrSrcY);
- }
-
- // Do horizontal scaling
- while (lastInLumBuf < lastLumSrcY) {
- const uint8_t *src1[4] = {
- src[0] + (lastInLumBuf + 1 - srcSliceY) * srcStride[0],
- src[1] + (lastInLumBuf + 1 - srcSliceY) * srcStride[1],
- src[2] + (lastInLumBuf + 1 - srcSliceY) * srcStride[2],
- src[3] + (lastInLumBuf + 1 - srcSliceY) * srcStride[3],
- };
- lumBufIndex++;
- av_assert0(lumBufIndex < 2 * vLumBufSize);
- av_assert0(lastInLumBuf + 1 - srcSliceY < srcSliceH);
- av_assert0(lastInLumBuf + 1 - srcSliceY >= 0);
- hyscale(c, lumPixBuf[lumBufIndex], dstW, src1, srcW, lumXInc,
- hLumFilter, hLumFilterPos, hLumFilterSize,
- formatConvBuffer, pal, 0);
- if (CONFIG_SWSCALE_ALPHA && alpPixBuf)
- hyscale(c, alpPixBuf[lumBufIndex], dstW, src1, srcW,
- lumXInc, hLumFilter, hLumFilterPos, hLumFilterSize,
- formatConvBuffer, pal, 1);
- lastInLumBuf++;
- DEBUG_BUFFERS("\t\tlumBufIndex %d: lastInLumBuf: %d\n",
- lumBufIndex, lastInLumBuf);
- }
- while (lastInChrBuf < lastChrSrcY) {
- const uint8_t *src1[4] = {
- src[0] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[0],
- src[1] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[1],
- src[2] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[2],
- src[3] + (lastInChrBuf + 1 - chrSrcSliceY) * srcStride[3],
- };
- chrBufIndex++;
- av_assert0(chrBufIndex < 2 * vChrBufSize);
- av_assert0(lastInChrBuf + 1 - chrSrcSliceY < (chrSrcSliceH));
- av_assert0(lastInChrBuf + 1 - chrSrcSliceY >= 0);
- // FIXME replace parameters through context struct (some at least)
-
- if (c->needs_hcscale)
- hcscale(c, chrUPixBuf[chrBufIndex], chrVPixBuf[chrBufIndex],
- chrDstW, src1, chrSrcW, chrXInc,
- hChrFilter, hChrFilterPos, hChrFilterSize,
- formatConvBuffer, pal);
- lastInChrBuf++;
- DEBUG_BUFFERS("\t\tchrBufIndex %d: lastInChrBuf: %d\n",
- chrBufIndex, lastInChrBuf);
- }
- // wrap buf index around to stay inside the ring buffer
- if (lumBufIndex >= vLumBufSize)
- lumBufIndex -= vLumBufSize;
- if (chrBufIndex >= vChrBufSize)
- chrBufIndex -= vChrBufSize;
- if (!enough_lines)
- break; // we can't output a dstY line so let's try with the next slice
-
-#if HAVE_MMX_INLINE
- updateMMXDitherTables(c, dstY, lumBufIndex, chrBufIndex,
- lastInLumBuf, lastInChrBuf);
-#endif
- if (should_dither) {
- c->chrDither8 = dither_8x8_128[chrDstY & 7];
- c->lumDither8 = dither_8x8_128[dstY & 7];
- }
- if (dstY >= dstH - 2) {
- /* hmm looks like we can't use MMX here without overwriting
- * this array's tail */
- ff_sws_init_output_funcs(c, &yuv2plane1, &yuv2planeX, &yuv2nv12cX,
- &yuv2packed1, &yuv2packed2, &yuv2packedX, &yuv2anyX);
- use_mmx_vfilter= 0;
- }
-
- {
- const int16_t **lumSrcPtr = (const int16_t **)(void*) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
- const int16_t **chrUSrcPtr = (const int16_t **)(void*) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
- const int16_t **chrVSrcPtr = (const int16_t **)(void*) chrVPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
- const int16_t **alpSrcPtr = (CONFIG_SWSCALE_ALPHA && alpPixBuf) ?
- (const int16_t **)(void*) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
- int16_t *vLumFilter = c->vLumFilter;
- int16_t *vChrFilter = c->vChrFilter;
-
- if (isPlanarYUV(dstFormat) ||
- (isGray(dstFormat) && !isALPHA(dstFormat))) { // YV12 like
- const int chrSkipMask = (1 << c->chrDstVSubSample) - 1;
-
- vLumFilter += dstY * vLumFilterSize;
- vChrFilter += chrDstY * vChrFilterSize;
-
-// av_assert0(use_mmx_vfilter != (
-// yuv2planeX == yuv2planeX_10BE_c
-// || yuv2planeX == yuv2planeX_10LE_c
-// || yuv2planeX == yuv2planeX_9BE_c
-// || yuv2planeX == yuv2planeX_9LE_c
-// || yuv2planeX == yuv2planeX_16BE_c
-// || yuv2planeX == yuv2planeX_16LE_c
-// || yuv2planeX == yuv2planeX_8_c) || !ARCH_X86);
-
- if(use_mmx_vfilter){
- vLumFilter= (int16_t *)c->lumMmxFilter;
- vChrFilter= (int16_t *)c->chrMmxFilter;
- }
-
- if (vLumFilterSize == 1) {
- yuv2plane1(lumSrcPtr[0], dest[0], dstW, c->lumDither8, 0);
- } else {
- yuv2planeX(vLumFilter, vLumFilterSize,
- lumSrcPtr, dest[0],
- dstW, c->lumDither8, 0);
- }
-
- if (!((dstY & chrSkipMask) || isGray(dstFormat))) {
- if (yuv2nv12cX) {
- yuv2nv12cX(c, vChrFilter,
- vChrFilterSize, chrUSrcPtr, chrVSrcPtr,
- dest[1], chrDstW);
- } else if (vChrFilterSize == 1) {
- yuv2plane1(chrUSrcPtr[0], dest[1], chrDstW, c->chrDither8, 0);
- yuv2plane1(chrVSrcPtr[0], dest[2], chrDstW, c->chrDither8, 3);
- } else {
- yuv2planeX(vChrFilter,
- vChrFilterSize, chrUSrcPtr, dest[1],
- chrDstW, c->chrDither8, 0);
- yuv2planeX(vChrFilter,
- vChrFilterSize, chrVSrcPtr, dest[2],
- chrDstW, c->chrDither8, use_mmx_vfilter ? (c->uv_offx2 >> 1) : 3);
- }
- }
-
- if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
- if(use_mmx_vfilter){
- vLumFilter= (int16_t *)c->alpMmxFilter;
- }
- if (vLumFilterSize == 1) {
- yuv2plane1(alpSrcPtr[0], dest[3], dstW,
- c->lumDither8, 0);
- } else {
- yuv2planeX(vLumFilter,
- vLumFilterSize, alpSrcPtr, dest[3],
- dstW, c->lumDither8, 0);
- }
- }
- } else if (yuv2packedX) {
- av_assert1(lumSrcPtr + vLumFilterSize - 1 < (const int16_t **)lumPixBuf + vLumBufSize * 2);
- av_assert1(chrUSrcPtr + vChrFilterSize - 1 < (const int16_t **)chrUPixBuf + vChrBufSize * 2);
- if (c->yuv2packed1 && vLumFilterSize == 1 &&
- vChrFilterSize <= 2) { // unscaled RGB
- int chrAlpha = vChrFilterSize == 1 ? 0 : vChrFilter[2 * dstY + 1];
- yuv2packed1(c, *lumSrcPtr, chrUSrcPtr, chrVSrcPtr,
- alpPixBuf ? *alpSrcPtr : NULL,
- dest[0], dstW, chrAlpha, dstY);
- } else if (c->yuv2packed2 && vLumFilterSize == 2 &&
- vChrFilterSize == 2) { // bilinear upscale RGB
- int lumAlpha = vLumFilter[2 * dstY + 1];
- int chrAlpha = vChrFilter[2 * dstY + 1];
- lumMmxFilter[2] =
- lumMmxFilter[3] = vLumFilter[2 * dstY] * 0x10001;
- chrMmxFilter[2] =
- chrMmxFilter[3] = vChrFilter[2 * chrDstY] * 0x10001;
- yuv2packed2(c, lumSrcPtr, chrUSrcPtr, chrVSrcPtr,
- alpPixBuf ? alpSrcPtr : NULL,
- dest[0], dstW, lumAlpha, chrAlpha, dstY);
- } else { // general RGB
- yuv2packedX(c, vLumFilter + dstY * vLumFilterSize,
- lumSrcPtr, vLumFilterSize,
- vChrFilter + dstY * vChrFilterSize,
- chrUSrcPtr, chrVSrcPtr, vChrFilterSize,
- alpSrcPtr, dest[0], dstW, dstY);
- }
- } else {
- av_assert1(!yuv2packed1 && !yuv2packed2);
- yuv2anyX(c, vLumFilter + dstY * vLumFilterSize,
- lumSrcPtr, vLumFilterSize,
- vChrFilter + dstY * vChrFilterSize,
- chrUSrcPtr, chrVSrcPtr, vChrFilterSize,
- alpSrcPtr, dest, dstW, dstY);
- }
- }
- }
- if (isPlanar(dstFormat) && isALPHA(dstFormat) && !alpPixBuf) {
- int length = dstW;
- int height = dstY - lastDstY;
-
- if (is16BPS(dstFormat) || isNBPS(dstFormat)) {
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(dstFormat);
- fillPlane16(dst[3], dstStride[3], length, height, lastDstY,
- 1, desc->comp[3].depth_minus1,
- isBE(dstFormat));
- } else
- fillPlane(dst[3], dstStride[3], length, height, lastDstY, 255);
- }
-
-#if HAVE_MMXEXT_INLINE
- if (av_get_cpu_flags() & AV_CPU_FLAG_MMXEXT)
- __asm__ volatile ("sfence" ::: "memory");
-#endif
- emms_c();
-
- /* store changed local vars back in the context */
- c->dstY = dstY;
- c->lumBufIndex = lumBufIndex;
- c->chrBufIndex = chrBufIndex;
- c->lastInLumBuf = lastInLumBuf;
- c->lastInChrBuf = lastInChrBuf;
-
- return dstY - lastDstY;
-}
-
-static av_cold void sws_init_swScale_c(SwsContext *c)
-{
- enum AVPixelFormat srcFormat = c->srcFormat;
-
- ff_sws_init_output_funcs(c, &c->yuv2plane1, &c->yuv2planeX,
- &c->yuv2nv12cX, &c->yuv2packed1,
- &c->yuv2packed2, &c->yuv2packedX, &c->yuv2anyX);
-
- ff_sws_init_input_funcs(c);
-
-
- if (c->srcBpc == 8) {
- if (c->dstBpc <= 14) {
- c->hyScale = c->hcScale = hScale8To15_c;
- if (c->flags & SWS_FAST_BILINEAR) {
- c->hyscale_fast = hyscale_fast_c;
- c->hcscale_fast = hcscale_fast_c;
- }
- } else {
- c->hyScale = c->hcScale = hScale8To19_c;
- }
- } else {
- c->hyScale = c->hcScale = c->dstBpc > 14 ? hScale16To19_c
- : hScale16To15_c;
- }
-
- if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) {
- if (c->dstBpc <= 14) {
- if (c->srcRange) {
- c->lumConvertRange = lumRangeFromJpeg_c;
- c->chrConvertRange = chrRangeFromJpeg_c;
- } else {
- c->lumConvertRange = lumRangeToJpeg_c;
- c->chrConvertRange = chrRangeToJpeg_c;
- }
- } else {
- if (c->srcRange) {
- c->lumConvertRange = lumRangeFromJpeg16_c;
- c->chrConvertRange = chrRangeFromJpeg16_c;
- } else {
- c->lumConvertRange = lumRangeToJpeg16_c;
- c->chrConvertRange = chrRangeToJpeg16_c;
- }
- }
- }
-
- if (!(isGray(srcFormat) || isGray(c->dstFormat) ||
- srcFormat == AV_PIX_FMT_MONOBLACK || srcFormat == AV_PIX_FMT_MONOWHITE))
- c->needs_hcscale = 1;
-}
-
-SwsFunc ff_getSwsFunc(SwsContext *c)
-{
- sws_init_swScale_c(c);
-
- if (HAVE_MMX)
- ff_sws_init_swScale_mmx(c);
- if (HAVE_ALTIVEC)
- ff_sws_init_swScale_altivec(c);
-
- return swScale;
-}
-
-static void reset_ptr(const uint8_t *src[], int format)
-{
- if (!isALPHA(format))
- src[3] = NULL;
- if (!isPlanar(format)) {
- src[3] = src[2] = NULL;
-
- if (!usePal(format))
- src[1] = NULL;
- }
-}
-
-static int check_image_pointers(const uint8_t * const data[4], enum AVPixelFormat pix_fmt,
- const int linesizes[4])
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- int i;
-
- for (i = 0; i < 4; i++) {
- int plane = desc->comp[i].plane;
- if (!data[plane] || !linesizes[plane])
- return 0;
- }
-
- return 1;
-}
-
-/**
- * swscale wrapper, so we don't need to export the SwsContext.
- * Assumes planar YUV to be in YUV order instead of YVU.
- */
-int attribute_align_arg sws_scale(struct SwsContext *c,
- const uint8_t * const srcSlice[],
- const int srcStride[], int srcSliceY,
- int srcSliceH, uint8_t *const dst[],
- const int dstStride[])
-{
- int i, ret;
- const uint8_t *src2[4];
- uint8_t *dst2[4];
- uint8_t *rgb0_tmp = NULL;
-
- if (!srcSlice || !dstStride || !dst || !srcSlice) {
- av_log(c, AV_LOG_ERROR, "One of the input parameters to sws_scale() is NULL, please check the calling code\n");
- return 0;
- }
- memcpy(src2, srcSlice, sizeof(src2));
- memcpy(dst2, dst, sizeof(dst2));
-
- // do not mess up sliceDir if we have a "trailing" 0-size slice
- if (srcSliceH == 0)
- return 0;
-
- if (!check_image_pointers(srcSlice, c->srcFormat, srcStride)) {
- av_log(c, AV_LOG_ERROR, "bad src image pointers\n");
- return 0;
- }
- if (!check_image_pointers((const uint8_t* const*)dst, c->dstFormat, dstStride)) {
- av_log(c, AV_LOG_ERROR, "bad dst image pointers\n");
- return 0;
- }
-
- if (c->sliceDir == 0 && srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) {
- av_log(c, AV_LOG_ERROR, "Slices start in the middle!\n");
- return 0;
- }
- if (c->sliceDir == 0) {
- if (srcSliceY == 0) c->sliceDir = 1; else c->sliceDir = -1;
- }
-
- if (usePal(c->srcFormat)) {
- for (i = 0; i < 256; i++) {
- int p, r, g, b, y, u, v, a = 0xff;
- if (c->srcFormat == AV_PIX_FMT_PAL8) {
- p = ((const uint32_t *)(srcSlice[1]))[i];
- a = (p >> 24) & 0xFF;
- r = (p >> 16) & 0xFF;
- g = (p >> 8) & 0xFF;
- b = p & 0xFF;
- } else if (c->srcFormat == AV_PIX_FMT_RGB8) {
- r = ( i >> 5 ) * 36;
- g = ((i >> 2) & 7) * 36;
- b = ( i & 3) * 85;
- } else if (c->srcFormat == AV_PIX_FMT_BGR8) {
- b = ( i >> 6 ) * 85;
- g = ((i >> 3) & 7) * 36;
- r = ( i & 7) * 36;
- } else if (c->srcFormat == AV_PIX_FMT_RGB4_BYTE) {
- r = ( i >> 3 ) * 255;
- g = ((i >> 1) & 3) * 85;
- b = ( i & 1) * 255;
- } else if (c->srcFormat == AV_PIX_FMT_GRAY8 || c->srcFormat == AV_PIX_FMT_GRAY8A) {
- r = g = b = i;
- } else {
- av_assert1(c->srcFormat == AV_PIX_FMT_BGR4_BYTE);
- b = ( i >> 3 ) * 255;
- g = ((i >> 1) & 3) * 85;
- r = ( i & 1) * 255;
- }
-#define RGB2YUV_SHIFT 15
-#define BY ( (int) (0.114 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
-#define BV (-(int) (0.081 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
-#define BU ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
-#define GY ( (int) (0.587 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
-#define GV (-(int) (0.419 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
-#define GU (-(int) (0.331 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
-#define RY ( (int) (0.299 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
-#define RV ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
-#define RU (-(int) (0.169 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5))
-
- y = av_clip_uint8((RY * r + GY * g + BY * b + ( 33 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
- u = av_clip_uint8((RU * r + GU * g + BU * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
- v = av_clip_uint8((RV * r + GV * g + BV * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
- c->pal_yuv[i]= y + (u<<8) + (v<<16) + ((unsigned)a<<24);
-
- switch (c->dstFormat) {
- case AV_PIX_FMT_BGR32:
-#if !HAVE_BIGENDIAN
- case AV_PIX_FMT_RGB24:
-#endif
- c->pal_rgb[i]= r + (g<<8) + (b<<16) + ((unsigned)a<<24);
- break;
- case AV_PIX_FMT_BGR32_1:
-#if HAVE_BIGENDIAN
- case AV_PIX_FMT_BGR24:
-#endif
- c->pal_rgb[i]= a + (r<<8) + (g<<16) + ((unsigned)b<<24);
- break;
- case AV_PIX_FMT_RGB32_1:
-#if HAVE_BIGENDIAN
- case AV_PIX_FMT_RGB24:
-#endif
- c->pal_rgb[i]= a + (b<<8) + (g<<16) + ((unsigned)r<<24);
- break;
- case AV_PIX_FMT_RGB32:
-#if !HAVE_BIGENDIAN
- case AV_PIX_FMT_BGR24:
-#endif
- default:
- c->pal_rgb[i]= b + (g<<8) + (r<<16) + ((unsigned)a<<24);
- }
- }
- }
-
- if (c->src0Alpha && !c->dst0Alpha && isALPHA(c->dstFormat)) {
- uint8_t *base;
- int x,y;
- rgb0_tmp = av_malloc(FFABS(srcStride[0]) * srcSliceH + 32);
- base = srcStride[0] < 0 ? rgb0_tmp - srcStride[0] * (srcSliceH-1) : rgb0_tmp;
- for (y=0; y<srcSliceH; y++){
- memcpy(base + srcStride[0]*y, src2[0] + srcStride[0]*y, 4*c->srcW);
- for (x=c->src0Alpha-1; x<4*c->srcW; x+=4) {
- base[ srcStride[0]*y + x] = 0xFF;
- }
- }
- src2[0] = base;
- }
-
- if (!srcSliceY && (c->flags & SWS_BITEXACT) && (c->flags & SWS_ERROR_DIFFUSION) && c->dither_error[0])
- for (i = 0; i < 4; i++)
- memset(c->dither_error[i], 0, sizeof(c->dither_error[0][0]) * (c->dstW+2));
-
-
- // copy strides, so they can safely be modified
- if (c->sliceDir == 1) {
- // slices go from top to bottom
- int srcStride2[4] = { srcStride[0], srcStride[1], srcStride[2],
- srcStride[3] };
- int dstStride2[4] = { dstStride[0], dstStride[1], dstStride[2],
- dstStride[3] };
-
- reset_ptr(src2, c->srcFormat);
- reset_ptr((void*)dst2, c->dstFormat);
-
- /* reset slice direction at end of frame */
- if (srcSliceY + srcSliceH == c->srcH)
- c->sliceDir = 0;
-
- ret = c->swScale(c, src2, srcStride2, srcSliceY, srcSliceH, dst2,
- dstStride2);
- } else {
- // slices go from bottom to top => we flip the image internally
- int srcStride2[4] = { -srcStride[0], -srcStride[1], -srcStride[2],
- -srcStride[3] };
- int dstStride2[4] = { -dstStride[0], -dstStride[1], -dstStride[2],
- -dstStride[3] };
-
- src2[0] += (srcSliceH - 1) * srcStride[0];
- if (!usePal(c->srcFormat))
- src2[1] += ((srcSliceH >> c->chrSrcVSubSample) - 1) * srcStride[1];
- src2[2] += ((srcSliceH >> c->chrSrcVSubSample) - 1) * srcStride[2];
- src2[3] += (srcSliceH - 1) * srcStride[3];
- dst2[0] += ( c->dstH - 1) * dstStride[0];
- dst2[1] += ((c->dstH >> c->chrDstVSubSample) - 1) * dstStride[1];
- dst2[2] += ((c->dstH >> c->chrDstVSubSample) - 1) * dstStride[2];
- dst2[3] += ( c->dstH - 1) * dstStride[3];
-
- reset_ptr(src2, c->srcFormat);
- reset_ptr((void*)dst2, c->dstFormat);
-
- /* reset slice direction at end of frame */
- if (!srcSliceY)
- c->sliceDir = 0;
-
- ret = c->swScale(c, src2, srcStride2, c->srcH-srcSliceY-srcSliceH,
- srcSliceH, dst2, dstStride2);
- }
-
- av_free(rgb0_tmp);
- return ret;
-}
-
diff --git a/src/thirdparty/ffmpeg/libswscale/swscale.h b/src/thirdparty/ffmpeg/libswscale/swscale.h
deleted file mode 100644
index 822934c09..000000000
--- a/src/thirdparty/ffmpeg/libswscale/swscale.h
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * Copyright (C) 2001-2011 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
- */
-
-#ifndef SWSCALE_SWSCALE_H
-#define SWSCALE_SWSCALE_H
-
-/**
- * @file
- * @ingroup lsws
- * external API header
- */
-
-/**
- * @defgroup lsws Libswscale
- * @{
- */
-
-#include <stdint.h>
-
-#include "libavutil/avutil.h"
-#include "libavutil/log.h"
-#include "libavutil/pixfmt.h"
-#include "version.h"
-
-/**
- * Return the LIBSWSCALE_VERSION_INT constant.
- */
-unsigned swscale_version(void);
-
-/**
- * Return the libswscale build-time configuration.
- */
-const char *swscale_configuration(void);
-
-/**
- * Return the libswscale license.
- */
-const char *swscale_license(void);
-
-/* values for the flags, the stuff on the command line is different */
-#define SWS_FAST_BILINEAR 1
-#define SWS_BILINEAR 2
-#define SWS_BICUBIC 4
-#define SWS_X 8
-#define SWS_POINT 0x10
-#define SWS_AREA 0x20
-#define SWS_BICUBLIN 0x40
-#define SWS_GAUSS 0x80
-#define SWS_SINC 0x100
-#define SWS_LANCZOS 0x200
-#define SWS_SPLINE 0x400
-
-#define SWS_SRC_V_CHR_DROP_MASK 0x30000
-#define SWS_SRC_V_CHR_DROP_SHIFT 16
-
-#define SWS_PARAM_DEFAULT 123456
-
-#define SWS_PRINT_INFO 0x1000
-
-//the following 3 flags are not completely implemented
-//internal chrominace subsampling info
-#define SWS_FULL_CHR_H_INT 0x2000
-//input subsampling info
-#define SWS_FULL_CHR_H_INP 0x4000
-#define SWS_DIRECT_BGR 0x8000
-#define SWS_ACCURATE_RND 0x40000
-#define SWS_BITEXACT 0x80000
-#define SWS_ERROR_DIFFUSION 0x800000
-
-#if FF_API_SWS_CPU_CAPS
-/**
- * CPU caps are autodetected now, those flags
- * are only provided for API compatibility.
- */
-#define SWS_CPU_CAPS_MMX 0x80000000
-#define SWS_CPU_CAPS_MMXEXT 0x20000000
-#define SWS_CPU_CAPS_MMX2 0x20000000
-#define SWS_CPU_CAPS_3DNOW 0x40000000
-#define SWS_CPU_CAPS_ALTIVEC 0x10000000
-#define SWS_CPU_CAPS_BFIN 0x01000000
-#define SWS_CPU_CAPS_SSE2 0x02000000
-#endif
-
-#define SWS_MAX_REDUCE_CUTOFF 0.002
-
-#define SWS_CS_ITU709 1
-#define SWS_CS_FCC 4
-#define SWS_CS_ITU601 5
-#define SWS_CS_ITU624 5
-#define SWS_CS_SMPTE170M 5
-#define SWS_CS_SMPTE240M 7
-#define SWS_CS_DEFAULT 5
-
-/**
- * Return a pointer to yuv<->rgb coefficients for the given colorspace
- * suitable for sws_setColorspaceDetails().
- *
- * @param colorspace One of the SWS_CS_* macros. If invalid,
- * SWS_CS_DEFAULT is used.
- */
-const int *sws_getCoefficients(int colorspace);
-
-// when used for filters they must have an odd number of elements
-// coeffs cannot be shared between vectors
-typedef struct SwsVector {
- double *coeff; ///< pointer to the list of coefficients
- int length; ///< number of coefficients in the vector
-} SwsVector;
-
-// vectors can be shared
-typedef struct SwsFilter {
- SwsVector *lumH;
- SwsVector *lumV;
- SwsVector *chrH;
- SwsVector *chrV;
-} SwsFilter;
-
-struct SwsContext;
-
-/**
- * Return a positive value if pix_fmt is a supported input format, 0
- * otherwise.
- */
-int sws_isSupportedInput(enum AVPixelFormat pix_fmt);
-
-/**
- * Return a positive value if pix_fmt is a supported output format, 0
- * otherwise.
- */
-int sws_isSupportedOutput(enum AVPixelFormat pix_fmt);
-
-/**
- * Allocate an empty SwsContext. This must be filled and passed to
- * sws_init_context(). For filling see AVOptions, options.c and
- * sws_setColorspaceDetails().
- */
-struct SwsContext *sws_alloc_context(void);
-
-/**
- * Initialize the swscaler context sws_context.
- *
- * @return zero or positive value on success, a negative value on
- * error
- */
-int sws_init_context(struct SwsContext *sws_context, SwsFilter *srcFilter, SwsFilter *dstFilter);
-
-/**
- * Free the swscaler context swsContext.
- * If swsContext is NULL, then does nothing.
- */
-void sws_freeContext(struct SwsContext *swsContext);
-
-#if FF_API_SWS_GETCONTEXT
-/**
- * Allocate and return an SwsContext. You need it to perform
- * scaling/conversion operations using sws_scale().
- *
- * @param srcW the width of the source image
- * @param srcH the height of the source image
- * @param srcFormat the source image format
- * @param dstW the width of the destination image
- * @param dstH the height of the destination image
- * @param dstFormat the destination image format
- * @param flags specify which algorithm and options to use for rescaling
- * @return a pointer to an allocated context, or NULL in case of error
- * @note this function is to be removed after a saner alternative is
- * written
- * @deprecated Use sws_getCachedContext() instead.
- */
-struct SwsContext *sws_getContext(int srcW, int srcH, enum AVPixelFormat srcFormat,
- int dstW, int dstH, enum AVPixelFormat dstFormat,
- int flags, SwsFilter *srcFilter,
- SwsFilter *dstFilter, const double *param);
-#endif
-
-/**
- * Scale the image slice in srcSlice and put the resulting scaled
- * slice in the image in dst. A slice is a sequence of consecutive
- * rows in an image.
- *
- * Slices have to be provided in sequential order, either in
- * top-bottom or bottom-top order. If slices are provided in
- * non-sequential order the behavior of the function is undefined.
- *
- * @param c the scaling context previously created with
- * sws_getContext()
- * @param srcSlice the array containing the pointers to the planes of
- * the source slice
- * @param srcStride the array containing the strides for each plane of
- * the source image
- * @param srcSliceY the position in the source image of the slice to
- * process, that is the number (counted starting from
- * zero) in the image of the first row of the slice
- * @param srcSliceH the height of the source slice, that is the number
- * of rows in the slice
- * @param dst the array containing the pointers to the planes of
- * the destination image
- * @param dstStride the array containing the strides for each plane of
- * the destination image
- * @return the height of the output slice
- */
-int sws_scale(struct SwsContext *c, const uint8_t *const srcSlice[],
- const int srcStride[], int srcSliceY, int srcSliceH,
- uint8_t *const dst[], const int dstStride[]);
-
-/**
- * @param dstRange flag indicating the while-black range of the output (1=jpeg / 0=mpeg)
- * @param srcRange flag indicating the while-black range of the input (1=jpeg / 0=mpeg)
- * @param table the yuv2rgb coefficients describing the output yuv space, normally ff_yuv2rgb_coeffs[x]
- * @param inv_table the yuv2rgb coefficients describing the input yuv space, normally ff_yuv2rgb_coeffs[x]
- * @param brightness 16.16 fixed point brightness correction
- * @param contrast 16.16 fixed point contrast correction
- * @param saturation 16.16 fixed point saturation correction
- * @return -1 if not supported
- */
-int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
- int srcRange, const int table[4], int dstRange,
- int brightness, int contrast, int saturation);
-
-/**
- * @return -1 if not supported
- */
-int sws_getColorspaceDetails(struct SwsContext *c, int **inv_table,
- int *srcRange, int **table, int *dstRange,
- int *brightness, int *contrast, int *saturation);
-
-/**
- * Allocate and return an uninitialized vector with length coefficients.
- */
-SwsVector *sws_allocVec(int length);
-
-/**
- * Return a normalized Gaussian curve used to filter stuff
- * quality = 3 is high quality, lower is lower quality.
- */
-SwsVector *sws_getGaussianVec(double variance, double quality);
-
-/**
- * Allocate and return a vector with length coefficients, all
- * with the same value c.
- */
-SwsVector *sws_getConstVec(double c, int length);
-
-/**
- * Allocate and return a vector with just one coefficient, with
- * value 1.0.
- */
-SwsVector *sws_getIdentityVec(void);
-
-/**
- * Scale all the coefficients of a by the scalar value.
- */
-void sws_scaleVec(SwsVector *a, double scalar);
-
-/**
- * Scale all the coefficients of a so that their sum equals height.
- */
-void sws_normalizeVec(SwsVector *a, double height);
-void sws_convVec(SwsVector *a, SwsVector *b);
-void sws_addVec(SwsVector *a, SwsVector *b);
-void sws_subVec(SwsVector *a, SwsVector *b);
-void sws_shiftVec(SwsVector *a, int shift);
-
-/**
- * Allocate and return a clone of the vector a, that is a vector
- * with the same coefficients as a.
- */
-SwsVector *sws_cloneVec(SwsVector *a);
-
-/**
- * Print with av_log() a textual representation of the vector a
- * if log_level <= av_log_level.
- */
-void sws_printVec2(SwsVector *a, AVClass *log_ctx, int log_level);
-
-void sws_freeVec(SwsVector *a);
-
-SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur,
- float lumaSharpen, float chromaSharpen,
- float chromaHShift, float chromaVShift,
- int verbose);
-void sws_freeFilter(SwsFilter *filter);
-
-/**
- * Check if context can be reused, otherwise reallocate a new one.
- *
- * If context is NULL, just calls sws_getContext() to get a new
- * context. Otherwise, checks if the parameters are the ones already
- * saved in context. If that is the case, returns the current
- * context. Otherwise, frees context and gets a new context with
- * the new parameters.
- *
- * Be warned that srcFilter and dstFilter are not checked, they
- * are assumed to remain the same.
- */
-struct SwsContext *sws_getCachedContext(struct SwsContext *context,
- int srcW, int srcH, enum AVPixelFormat srcFormat,
- int dstW, int dstH, enum AVPixelFormat dstFormat,
- int flags, SwsFilter *srcFilter,
- SwsFilter *dstFilter, const double *param);
-
-/**
- * Convert an 8-bit paletted frame into a frame with a color depth of 32 bits.
- *
- * The output frame will have the same packed format as the palette.
- *
- * @param src source frame buffer
- * @param dst destination frame buffer
- * @param num_pixels number of pixels to convert
- * @param palette array with [256] entries, which must match color arrangement (RGB or BGR) of src
- */
-void sws_convertPalette8ToPacked32(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette);
-
-/**
- * Convert an 8-bit paletted frame into a frame with a color depth of 24 bits.
- *
- * With the palette format "ABCD", the destination frame ends up with the format "ABC".
- *
- * @param src source frame buffer
- * @param dst destination frame buffer
- * @param num_pixels number of pixels to convert
- * @param palette array with [256] entries, which must match color arrangement (RGB or BGR) of src
- */
-void sws_convertPalette8ToPacked24(const uint8_t *src, uint8_t *dst, int num_pixels, const uint8_t *palette);
-
-/**
- * Get the AVClass for swsContext. It can be used in combination with
- * AV_OPT_SEARCH_FAKE_OBJ for examining options.
- *
- * @see av_opt_find().
- */
-const AVClass *sws_get_class(void);
-
-/**
- * @}
- */
-
-#endif /* SWSCALE_SWSCALE_H */
diff --git a/src/thirdparty/ffmpeg/libswscale/swscale_internal.h b/src/thirdparty/ffmpeg/libswscale/swscale_internal.h
deleted file mode 100644
index e0d61e621..000000000
--- a/src/thirdparty/ffmpeg/libswscale/swscale_internal.h
+++ /dev/null
@@ -1,840 +0,0 @@
-/*
- * Copyright (C) 2001-2011 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
- */
-
-#ifndef SWSCALE_SWSCALE_INTERNAL_H
-#define SWSCALE_SWSCALE_INTERNAL_H
-
-#include "config.h"
-
-#if HAVE_ALTIVEC_H
-#include <altivec.h>
-#endif
-
-#include "libavutil/avassert.h"
-#include "libavutil/avutil.h"
-#include "libavutil/common.h"
-#include "libavutil/intreadwrite.h"
-#include "libavutil/log.h"
-#include "libavutil/pixfmt.h"
-#include "libavutil/pixdesc.h"
-
-#define STR(s) AV_TOSTRING(s) // AV_STRINGIFY is too long
-
-#define YUVRGB_TABLE_HEADROOM 128
-
-#define FAST_BGR2YV12 // use 7-bit instead of 15-bit coefficients
-
-#define MAX_FILTER_SIZE 256
-
-#define DITHER1XBPP
-
-#if HAVE_BIGENDIAN
-#define ALT32_CORR (-1)
-#else
-#define ALT32_CORR 1
-#endif
-
-#if ARCH_X86_64
-# define APCK_PTR2 8
-# define APCK_COEF 16
-# define APCK_SIZE 24
-#else
-# define APCK_PTR2 4
-# define APCK_COEF 8
-# define APCK_SIZE 16
-#endif
-
-struct SwsContext;
-
-typedef int (*SwsFunc)(struct SwsContext *context, const uint8_t *src[],
- int srcStride[], int srcSliceY, int srcSliceH,
- uint8_t *dst[], int dstStride[]);
-
-/**
- * Write one line of horizontally scaled data to planar output
- * without any additional vertical scaling (or point-scaling).
- *
- * @param src scaled source data, 15bit for 8-10bit output,
- * 19-bit for 16bit output (in int32_t)
- * @param dest pointer to the output plane. For >8bit
- * output, this is in uint16_t
- * @param dstW width of destination in pixels
- * @param dither ordered dither array of type int16_t and size 8
- * @param offset Dither offset
- */
-typedef void (*yuv2planar1_fn)(const int16_t *src, uint8_t *dest, int dstW,
- const uint8_t *dither, int offset);
-
-/**
- * Write one line of horizontally scaled data to planar output
- * with multi-point vertical scaling between input pixels.
- *
- * @param filter vertical luma/alpha scaling coefficients, 12bit [0,4096]
- * @param src scaled luma (Y) or alpha (A) source data, 15bit for 8-10bit output,
- * 19-bit for 16bit output (in int32_t)
- * @param filterSize number of vertical input lines to scale
- * @param dest pointer to output plane. For >8bit
- * output, this is in uint16_t
- * @param dstW width of destination pixels
- * @param offset Dither offset
- */
-typedef void (*yuv2planarX_fn)(const int16_t *filter, int filterSize,
- const int16_t **src, uint8_t *dest, int dstW,
- const uint8_t *dither, int offset);
-
-/**
- * Write one line of horizontally scaled chroma to interleaved output
- * with multi-point vertical scaling between input pixels.
- *
- * @param c SWS scaling context
- * @param chrFilter vertical chroma scaling coefficients, 12bit [0,4096]
- * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output,
- * 19-bit for 16bit output (in int32_t)
- * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output,
- * 19-bit for 16bit output (in int32_t)
- * @param chrFilterSize number of vertical chroma input lines to scale
- * @param dest pointer to the output plane. For >8bit
- * output, this is in uint16_t
- * @param dstW width of chroma planes
- */
-typedef void (*yuv2interleavedX_fn)(struct SwsContext *c,
- const int16_t *chrFilter,
- int chrFilterSize,
- const int16_t **chrUSrc,
- const int16_t **chrVSrc,
- uint8_t *dest, int dstW);
-
-/**
- * Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB
- * output without any additional vertical scaling (or point-scaling). Note
- * that this function may do chroma scaling, see the "uvalpha" argument.
- *
- * @param c SWS scaling context
- * @param lumSrc scaled luma (Y) source data, 15bit for 8-10bit output,
- * 19-bit for 16bit output (in int32_t)
- * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output,
- * 19-bit for 16bit output (in int32_t)
- * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output,
- * 19-bit for 16bit output (in int32_t)
- * @param alpSrc scaled alpha (A) source data, 15bit for 8-10bit output,
- * 19-bit for 16bit output (in int32_t)
- * @param dest pointer to the output plane. For 16bit output, this is
- * uint16_t
- * @param dstW width of lumSrc and alpSrc in pixels, number of pixels
- * to write into dest[]
- * @param uvalpha chroma scaling coefficient for the second line of chroma
- * pixels, either 2048 or 0. If 0, one chroma input is used
- * for 2 output pixels (or if the SWS_FLAG_FULL_CHR_INT flag
- * is set, it generates 1 output pixel). If 2048, two chroma
- * input pixels should be averaged for 2 output pixels (this
- * only happens if SWS_FLAG_FULL_CHR_INT is not set)
- * @param y vertical line number for this output. This does not need
- * to be used to calculate the offset in the destination,
- * but can be used to generate comfort noise using dithering
- * for some output formats.
- */
-typedef void (*yuv2packed1_fn)(struct SwsContext *c, const int16_t *lumSrc,
- const int16_t *chrUSrc[2],
- const int16_t *chrVSrc[2],
- const int16_t *alpSrc, uint8_t *dest,
- int dstW, int uvalpha, int y);
-/**
- * Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB
- * output by doing bilinear scaling between two input lines.
- *
- * @param c SWS scaling context
- * @param lumSrc scaled luma (Y) source data, 15bit for 8-10bit output,
- * 19-bit for 16bit output (in int32_t)
- * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output,
- * 19-bit for 16bit output (in int32_t)
- * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output,
- * 19-bit for 16bit output (in int32_t)
- * @param alpSrc scaled alpha (A) source data, 15bit for 8-10bit output,
- * 19-bit for 16bit output (in int32_t)
- * @param dest pointer to the output plane. For 16bit output, this is
- * uint16_t
- * @param dstW width of lumSrc and alpSrc in pixels, number of pixels
- * to write into dest[]
- * @param yalpha luma/alpha scaling coefficients for the second input line.
- * The first line's coefficients can be calculated by using
- * 4096 - yalpha
- * @param uvalpha chroma scaling coefficient for the second input line. The
- * first line's coefficients can be calculated by using
- * 4096 - uvalpha
- * @param y vertical line number for this output. This does not need
- * to be used to calculate the offset in the destination,
- * but can be used to generate comfort noise using dithering
- * for some output formats.
- */
-typedef void (*yuv2packed2_fn)(struct SwsContext *c, const int16_t *lumSrc[2],
- const int16_t *chrUSrc[2],
- const int16_t *chrVSrc[2],
- const int16_t *alpSrc[2],
- uint8_t *dest,
- int dstW, int yalpha, int uvalpha, int y);
-/**
- * Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB
- * output by doing multi-point vertical scaling between input pixels.
- *
- * @param c SWS scaling context
- * @param lumFilter vertical luma/alpha scaling coefficients, 12bit [0,4096]
- * @param lumSrc scaled luma (Y) source data, 15bit for 8-10bit output,
- * 19-bit for 16bit output (in int32_t)
- * @param lumFilterSize number of vertical luma/alpha input lines to scale
- * @param chrFilter vertical chroma scaling coefficients, 12bit [0,4096]
- * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output,
- * 19-bit for 16bit output (in int32_t)
- * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output,
- * 19-bit for 16bit output (in int32_t)
- * @param chrFilterSize number of vertical chroma input lines to scale
- * @param alpSrc scaled alpha (A) source data, 15bit for 8-10bit output,
- * 19-bit for 16bit output (in int32_t)
- * @param dest pointer to the output plane. For 16bit output, this is
- * uint16_t
- * @param dstW width of lumSrc and alpSrc in pixels, number of pixels
- * to write into dest[]
- * @param y vertical line number for this output. This does not need
- * to be used to calculate the offset in the destination,
- * but can be used to generate comfort noise using dithering
- * or some output formats.
- */
-typedef void (*yuv2packedX_fn)(struct SwsContext *c, const int16_t *lumFilter,
- const int16_t **lumSrc, int lumFilterSize,
- const int16_t *chrFilter,
- const int16_t **chrUSrc,
- const int16_t **chrVSrc, int chrFilterSize,
- const int16_t **alpSrc, uint8_t *dest,
- int dstW, int y);
-
-/**
- * Write one line of horizontally scaled Y/U/V/A to YUV/RGB
- * output by doing multi-point vertical scaling between input pixels.
- *
- * @param c SWS scaling context
- * @param lumFilter vertical luma/alpha scaling coefficients, 12bit [0,4096]
- * @param lumSrc scaled luma (Y) source data, 15bit for 8-10bit output,
- * 19-bit for 16bit output (in int32_t)
- * @param lumFilterSize number of vertical luma/alpha input lines to scale
- * @param chrFilter vertical chroma scaling coefficients, 12bit [0,4096]
- * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output,
- * 19-bit for 16bit output (in int32_t)
- * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output,
- * 19-bit for 16bit output (in int32_t)
- * @param chrFilterSize number of vertical chroma input lines to scale
- * @param alpSrc scaled alpha (A) source data, 15bit for 8-10bit output,
- * 19-bit for 16bit output (in int32_t)
- * @param dest pointer to the output planes. For 16bit output, this is
- * uint16_t
- * @param dstW width of lumSrc and alpSrc in pixels, number of pixels
- * to write into dest[]
- * @param y vertical line number for this output. This does not need
- * to be used to calculate the offset in the destination,
- * but can be used to generate comfort noise using dithering
- * or some output formats.
- */
-typedef void (*yuv2anyX_fn)(struct SwsContext *c, const int16_t *lumFilter,
- const int16_t **lumSrc, int lumFilterSize,
- const int16_t *chrFilter,
- const int16_t **chrUSrc,
- const int16_t **chrVSrc, int chrFilterSize,
- const int16_t **alpSrc, uint8_t **dest,
- int dstW, int y);
-
-/* This struct should be aligned on at least a 32-byte boundary. */
-typedef struct SwsContext {
- /**
- * info on struct for av_log
- */
- const AVClass *av_class;
-
- /**
- * Note that src, dst, srcStride, dstStride will be copied in the
- * sws_scale() wrapper so they can be freely modified here.
- */
- SwsFunc swScale;
- int srcW; ///< Width of source luma/alpha planes.
- int srcH; ///< Height of source luma/alpha planes.
- int dstH; ///< Height of destination luma/alpha planes.
- int chrSrcW; ///< Width of source chroma planes.
- int chrSrcH; ///< Height of source chroma planes.
- int chrDstW; ///< Width of destination chroma planes.
- int chrDstH; ///< Height of destination chroma planes.
- int lumXInc, chrXInc;
- int lumYInc, chrYInc;
- enum AVPixelFormat dstFormat; ///< Destination pixel format.
- enum AVPixelFormat srcFormat; ///< Source pixel format.
- int dstFormatBpp; ///< Number of bits per pixel of the destination pixel format.
- int srcFormatBpp; ///< Number of bits per pixel of the source pixel format.
- int dstBpc, srcBpc;
- int chrSrcHSubSample; ///< Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in source image.
- int chrSrcVSubSample; ///< Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in source image.
- int chrDstHSubSample; ///< Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in destination image.
- int chrDstVSubSample; ///< Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in destination image.
- int vChrDrop; ///< Binary logarithm of extra vertical subsampling factor in source image chroma planes specified by user.
- int sliceDir; ///< Direction that slices are fed to the scaler (1 = top-to-bottom, -1 = bottom-to-top).
- double param[2]; ///< Input parameters for scaling algorithms that need them.
-
- uint32_t pal_yuv[256];
- uint32_t pal_rgb[256];
-
- /**
- * @name Scaled horizontal lines ring buffer.
- * The horizontal scaler keeps just enough scaled lines in a ring buffer
- * so they may be passed to the vertical scaler. The pointers to the
- * allocated buffers for each line are duplicated in sequence in the ring
- * buffer to simplify indexing and avoid wrapping around between lines
- * inside the vertical scaler code. The wrapping is done before the
- * vertical scaler is called.
- */
- //@{
- int16_t **lumPixBuf; ///< Ring buffer for scaled horizontal luma plane lines to be fed to the vertical scaler.
- int16_t **chrUPixBuf; ///< Ring buffer for scaled horizontal chroma plane lines to be fed to the vertical scaler.
- int16_t **chrVPixBuf; ///< Ring buffer for scaled horizontal chroma plane lines to be fed to the vertical scaler.
- int16_t **alpPixBuf; ///< Ring buffer for scaled horizontal alpha plane lines to be fed to the vertical scaler.
- int vLumBufSize; ///< Number of vertical luma/alpha lines allocated in the ring buffer.
- int vChrBufSize; ///< Number of vertical chroma lines allocated in the ring buffer.
- int lastInLumBuf; ///< Last scaled horizontal luma/alpha line from source in the ring buffer.
- int lastInChrBuf; ///< Last scaled horizontal chroma line from source in the ring buffer.
- int lumBufIndex; ///< Index in ring buffer of the last scaled horizontal luma/alpha line from source.
- int chrBufIndex; ///< Index in ring buffer of the last scaled horizontal chroma line from source.
- //@}
-
- uint8_t *formatConvBuffer;
-
- /**
- * @name Horizontal and vertical filters.
- * To better understand the following fields, here is a pseudo-code of
- * their usage in filtering a horizontal line:
- * @code
- * for (i = 0; i < width; i++) {
- * dst[i] = 0;
- * for (j = 0; j < filterSize; j++)
- * dst[i] += src[ filterPos[i] + j ] * filter[ filterSize * i + j ];
- * dst[i] >>= FRAC_BITS; // The actual implementation is fixed-point.
- * }
- * @endcode
- */
- //@{
- int16_t *hLumFilter; ///< Array of horizontal filter coefficients for luma/alpha planes.
- int16_t *hChrFilter; ///< Array of horizontal filter coefficients for chroma planes.
- int16_t *vLumFilter; ///< Array of vertical filter coefficients for luma/alpha planes.
- int16_t *vChrFilter; ///< Array of vertical filter coefficients for chroma planes.
- int32_t *hLumFilterPos; ///< Array of horizontal filter starting positions for each dst[i] for luma/alpha planes.
- int32_t *hChrFilterPos; ///< Array of horizontal filter starting positions for each dst[i] for chroma planes.
- int32_t *vLumFilterPos; ///< Array of vertical filter starting positions for each dst[i] for luma/alpha planes.
- int32_t *vChrFilterPos; ///< Array of vertical filter starting positions for each dst[i] for chroma planes.
- int hLumFilterSize; ///< Horizontal filter size for luma/alpha pixels.
- int hChrFilterSize; ///< Horizontal filter size for chroma pixels.
- int vLumFilterSize; ///< Vertical filter size for luma/alpha pixels.
- int vChrFilterSize; ///< Vertical filter size for chroma pixels.
- //@}
-
- int lumMmxextFilterCodeSize; ///< Runtime-generated MMXEXT horizontal fast bilinear scaler code size for luma/alpha planes.
- int chrMmxextFilterCodeSize; ///< Runtime-generated MMXEXT horizontal fast bilinear scaler code size for chroma planes.
- uint8_t *lumMmxextFilterCode; ///< Runtime-generated MMXEXT horizontal fast bilinear scaler code for luma/alpha planes.
- uint8_t *chrMmxextFilterCode; ///< Runtime-generated MMXEXT horizontal fast bilinear scaler code for chroma planes.
-
- int canMMXEXTBeUsed;
-
- int dstY; ///< Last destination vertical line output from last slice.
- int flags; ///< Flags passed by the user to select scaler algorithm, optimizations, subsampling, etc...
- void *yuvTable; // pointer to the yuv->rgb table start so it can be freed()
- uint8_t *table_rV[256 + 2*YUVRGB_TABLE_HEADROOM];
- uint8_t *table_gU[256 + 2*YUVRGB_TABLE_HEADROOM];
- int table_gV[256 + 2*YUVRGB_TABLE_HEADROOM];
- uint8_t *table_bU[256 + 2*YUVRGB_TABLE_HEADROOM];
-
- int *dither_error[4];
-
- //Colorspace stuff
- int contrast, brightness, saturation; // for sws_getColorspaceDetails
- int srcColorspaceTable[4];
- int dstColorspaceTable[4];
- int srcRange; ///< 0 = MPG YUV range, 1 = JPG YUV range (source image).
- int dstRange; ///< 0 = MPG YUV range, 1 = JPG YUV range (destination image).
- int src0Alpha;
- int dst0Alpha;
- int yuv2rgb_y_offset;
- int yuv2rgb_y_coeff;
- int yuv2rgb_v2r_coeff;
- int yuv2rgb_v2g_coeff;
- int yuv2rgb_u2g_coeff;
- int yuv2rgb_u2b_coeff;
-
-#define RED_DITHER "0*8"
-#define GREEN_DITHER "1*8"
-#define BLUE_DITHER "2*8"
-#define Y_COEFF "3*8"
-#define VR_COEFF "4*8"
-#define UB_COEFF "5*8"
-#define VG_COEFF "6*8"
-#define UG_COEFF "7*8"
-#define Y_OFFSET "8*8"
-#define U_OFFSET "9*8"
-#define V_OFFSET "10*8"
-#define LUM_MMX_FILTER_OFFSET "11*8"
-#define CHR_MMX_FILTER_OFFSET "11*8+4*4*256"
-#define DSTW_OFFSET "11*8+4*4*256*2" //do not change, it is hardcoded in the ASM
-#define ESP_OFFSET "11*8+4*4*256*2+8"
-#define VROUNDER_OFFSET "11*8+4*4*256*2+16"
-#define U_TEMP "11*8+4*4*256*2+24"
-#define V_TEMP "11*8+4*4*256*2+32"
-#define Y_TEMP "11*8+4*4*256*2+40"
-#define ALP_MMX_FILTER_OFFSET "11*8+4*4*256*2+48"
-#define UV_OFF_PX "11*8+4*4*256*3+48"
-#define UV_OFF_BYTE "11*8+4*4*256*3+56"
-#define DITHER16 "11*8+4*4*256*3+64"
-#define DITHER32 "11*8+4*4*256*3+80"
-
- DECLARE_ALIGNED(8, uint64_t, redDither);
- DECLARE_ALIGNED(8, uint64_t, greenDither);
- DECLARE_ALIGNED(8, uint64_t, blueDither);
-
- DECLARE_ALIGNED(8, uint64_t, yCoeff);
- DECLARE_ALIGNED(8, uint64_t, vrCoeff);
- DECLARE_ALIGNED(8, uint64_t, ubCoeff);
- DECLARE_ALIGNED(8, uint64_t, vgCoeff);
- DECLARE_ALIGNED(8, uint64_t, ugCoeff);
- DECLARE_ALIGNED(8, uint64_t, yOffset);
- DECLARE_ALIGNED(8, uint64_t, uOffset);
- DECLARE_ALIGNED(8, uint64_t, vOffset);
- int32_t lumMmxFilter[4 * MAX_FILTER_SIZE];
- int32_t chrMmxFilter[4 * MAX_FILTER_SIZE];
- int dstW; ///< Width of destination luma/alpha planes.
- DECLARE_ALIGNED(8, uint64_t, esp);
- DECLARE_ALIGNED(8, uint64_t, vRounder);
- DECLARE_ALIGNED(8, uint64_t, u_temp);
- DECLARE_ALIGNED(8, uint64_t, v_temp);
- DECLARE_ALIGNED(8, uint64_t, y_temp);
- int32_t alpMmxFilter[4 * MAX_FILTER_SIZE];
- // alignment of these values is not necessary, but merely here
- // to maintain the same offset across x8632 and x86-64. Once we
- // use proper offset macros in the asm, they can be removed.
- DECLARE_ALIGNED(8, ptrdiff_t, uv_off); ///< offset (in pixels) between u and v planes
- DECLARE_ALIGNED(8, ptrdiff_t, uv_offx2); ///< offset (in bytes) between u and v planes
- DECLARE_ALIGNED(8, uint16_t, dither16)[8];
- DECLARE_ALIGNED(8, uint32_t, dither32)[8];
-
- const uint8_t *chrDither8, *lumDither8;
-
-#if HAVE_ALTIVEC
- vector signed short CY;
- vector signed short CRV;
- vector signed short CBU;
- vector signed short CGU;
- vector signed short CGV;
- vector signed short OY;
- vector unsigned short CSHIFT;
- vector signed short *vYCoeffsBank, *vCCoeffsBank;
-#endif
-
-#if ARCH_BFIN
- DECLARE_ALIGNED(4, uint32_t, oy);
- DECLARE_ALIGNED(4, uint32_t, oc);
- DECLARE_ALIGNED(4, uint32_t, zero);
- DECLARE_ALIGNED(4, uint32_t, cy);
- DECLARE_ALIGNED(4, uint32_t, crv);
- DECLARE_ALIGNED(4, uint32_t, rmask);
- DECLARE_ALIGNED(4, uint32_t, cbu);
- DECLARE_ALIGNED(4, uint32_t, bmask);
- DECLARE_ALIGNED(4, uint32_t, cgu);
- DECLARE_ALIGNED(4, uint32_t, cgv);
- DECLARE_ALIGNED(4, uint32_t, gmask);
-#endif
-
-#if HAVE_VIS
- DECLARE_ALIGNED(8, uint64_t, sparc_coeffs)[10];
-#endif
- int use_mmx_vfilter;
-
- /* function pointers for swScale() */
- yuv2planar1_fn yuv2plane1;
- yuv2planarX_fn yuv2planeX;
- yuv2interleavedX_fn yuv2nv12cX;
- yuv2packed1_fn yuv2packed1;
- yuv2packed2_fn yuv2packed2;
- yuv2packedX_fn yuv2packedX;
- yuv2anyX_fn yuv2anyX;
-
- /// Unscaled conversion of luma plane to YV12 for horizontal scaler.
- void (*lumToYV12)(uint8_t *dst, const uint8_t *src, const uint8_t *src2, const uint8_t *src3,
- int width, uint32_t *pal);
- /// Unscaled conversion of alpha plane to YV12 for horizontal scaler.
- void (*alpToYV12)(uint8_t *dst, const uint8_t *src, const uint8_t *src2, const uint8_t *src3,
- int width, uint32_t *pal);
- /// Unscaled conversion of chroma planes to YV12 for horizontal scaler.
- void (*chrToYV12)(uint8_t *dstU, uint8_t *dstV,
- const uint8_t *src1, const uint8_t *src2, const uint8_t *src3,
- int width, uint32_t *pal);
-
- /**
- * Functions to read planar input, such as planar RGB, and convert
- * internally to Y/UV.
- */
- /** @{ */
- void (*readLumPlanar)(uint8_t *dst, const uint8_t *src[4], int width);
- void (*readChrPlanar)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src[4],
- int width);
- /** @} */
-
- /**
- * Scale one horizontal line of input data using a bilinear filter
- * to produce one line of output data. Compared to SwsContext->hScale(),
- * please take note of the following caveats when using these:
- * - Scaling is done using only 7bit instead of 14bit coefficients.
- * - You can use no more than 5 input pixels to produce 4 output
- * pixels. Therefore, this filter should not be used for downscaling
- * by more than ~20% in width (because that equals more than 5/4th
- * downscaling and thus more than 5 pixels input per 4 pixels output).
- * - In general, bilinear filters create artifacts during downscaling
- * (even when <20%), because one output pixel will span more than one
- * input pixel, and thus some pixels will need edges of both neighbor
- * pixels to interpolate the output pixel. Since you can use at most
- * two input pixels per output pixel in bilinear scaling, this is
- * impossible and thus downscaling by any size will create artifacts.
- * To enable this type of scaling, set SWS_FLAG_FAST_BILINEAR
- * in SwsContext->flags.
- */
- /** @{ */
- void (*hyscale_fast)(struct SwsContext *c,
- int16_t *dst, int dstWidth,
- const uint8_t *src, int srcW, int xInc);
- void (*hcscale_fast)(struct SwsContext *c,
- int16_t *dst1, int16_t *dst2, int dstWidth,
- const uint8_t *src1, const uint8_t *src2,
- int srcW, int xInc);
- /** @} */
-
- /**
- * Scale one horizontal line of input data using a filter over the input
- * lines, to produce one (differently sized) line of output data.
- *
- * @param dst pointer to destination buffer for horizontally scaled
- * data. If the number of bits per component of one
- * destination pixel (SwsContext->dstBpc) is <= 10, data
- * will be 15bpc in 16bits (int16_t) width. Else (i.e.
- * SwsContext->dstBpc == 16), data will be 19bpc in
- * 32bits (int32_t) width.
- * @param dstW width of destination image
- * @param src pointer to source data to be scaled. If the number of
- * bits per component of a source pixel (SwsContext->srcBpc)
- * is 8, this is 8bpc in 8bits (uint8_t) width. Else
- * (i.e. SwsContext->dstBpc > 8), this is native depth
- * in 16bits (uint16_t) width. In other words, for 9-bit
- * YUV input, this is 9bpc, for 10-bit YUV input, this is
- * 10bpc, and for 16-bit RGB or YUV, this is 16bpc.
- * @param filter filter coefficients to be used per output pixel for
- * scaling. This contains 14bpp filtering coefficients.
- * Guaranteed to contain dstW * filterSize entries.
- * @param filterPos position of the first input pixel to be used for
- * each output pixel during scaling. Guaranteed to
- * contain dstW entries.
- * @param filterSize the number of input coefficients to be used (and
- * thus the number of input pixels to be used) for
- * creating a single output pixel. Is aligned to 4
- * (and input coefficients thus padded with zeroes)
- * to simplify creating SIMD code.
- */
- /** @{ */
- void (*hyScale)(struct SwsContext *c, int16_t *dst, int dstW,
- const uint8_t *src, const int16_t *filter,
- const int32_t *filterPos, int filterSize);
- void (*hcScale)(struct SwsContext *c, int16_t *dst, int dstW,
- const uint8_t *src, const int16_t *filter,
- const int32_t *filterPos, int filterSize);
- /** @} */
-
- /// Color range conversion function for luma plane if needed.
- void (*lumConvertRange)(int16_t *dst, int width);
- /// Color range conversion function for chroma planes if needed.
- void (*chrConvertRange)(int16_t *dst1, int16_t *dst2, int width);
-
- int needs_hcscale; ///< Set if there are chroma planes to be converted.
-} SwsContext;
-//FIXME check init (where 0)
-
-SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c);
-int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4],
- int fullRange, int brightness,
- int contrast, int saturation);
-
-void ff_yuv2rgb_init_tables_altivec(SwsContext *c, const int inv_table[4],
- int brightness, int contrast, int saturation);
-void updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrBufIndex,
- int lastInLumBuf, int lastInChrBuf);
-
-SwsFunc ff_yuv2rgb_init_mmx(SwsContext *c);
-SwsFunc ff_yuv2rgb_init_vis(SwsContext *c);
-SwsFunc ff_yuv2rgb_init_altivec(SwsContext *c);
-SwsFunc ff_yuv2rgb_get_func_ptr_bfin(SwsContext *c);
-void ff_bfin_get_unscaled_swscale(SwsContext *c);
-
-#if FF_API_SWS_FORMAT_NAME
-/**
- * @deprecated Use av_get_pix_fmt_name() instead.
- */
-attribute_deprecated
-const char *sws_format_name(enum AVPixelFormat format);
-#endif
-
-static av_always_inline int is16BPS(enum AVPixelFormat pix_fmt)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- av_assert0(desc);
- return desc->comp[0].depth_minus1 == 15;
-}
-
-static av_always_inline int is9_OR_10BPS(enum AVPixelFormat pix_fmt)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- av_assert0(desc);
- return desc->comp[0].depth_minus1 >= 8 && desc->comp[0].depth_minus1 <= 13;
-}
-
-#define isNBPS(x) is9_OR_10BPS(x)
-
-static av_always_inline int isBE(enum AVPixelFormat pix_fmt)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- av_assert0(desc);
- return desc->flags & PIX_FMT_BE;
-}
-
-static av_always_inline int isYUV(enum AVPixelFormat pix_fmt)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- av_assert0(desc);
- return !(desc->flags & PIX_FMT_RGB) && desc->nb_components >= 2;
-}
-
-static av_always_inline int isPlanarYUV(enum AVPixelFormat pix_fmt)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- av_assert0(desc);
- return ((desc->flags & PIX_FMT_PLANAR) && isYUV(pix_fmt));
-}
-
-static av_always_inline int isRGB(enum AVPixelFormat pix_fmt)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- av_assert0(desc);
- return (desc->flags & PIX_FMT_RGB);
-}
-
-#if 0 // FIXME
-#define isGray(x) \
- (!(av_pix_fmt_desc_get(x)->flags & PIX_FMT_PAL) && \
- av_pix_fmt_desc_get(x)->nb_components <= 2)
-#else
-#define isGray(x) \
- ((x) == AV_PIX_FMT_GRAY8 || \
- (x) == AV_PIX_FMT_Y400A || \
- (x) == AV_PIX_FMT_GRAY16BE || \
- (x) == AV_PIX_FMT_GRAY16LE)
-#endif
-
-#define isRGBinInt(x) \
- ( \
- (x) == AV_PIX_FMT_RGB48BE || \
- (x) == AV_PIX_FMT_RGB48LE || \
- (x) == AV_PIX_FMT_RGBA64BE || \
- (x) == AV_PIX_FMT_RGBA64LE || \
- (x) == AV_PIX_FMT_RGB32 || \
- (x) == AV_PIX_FMT_RGB32_1 || \
- (x) == AV_PIX_FMT_RGB24 || \
- (x) == AV_PIX_FMT_RGB565BE || \
- (x) == AV_PIX_FMT_RGB565LE || \
- (x) == AV_PIX_FMT_RGB555BE || \
- (x) == AV_PIX_FMT_RGB555LE || \
- (x) == AV_PIX_FMT_RGB444BE || \
- (x) == AV_PIX_FMT_RGB444LE || \
- (x) == AV_PIX_FMT_RGB8 || \
- (x) == AV_PIX_FMT_RGB4 || \
- (x) == AV_PIX_FMT_RGB4_BYTE || \
- (x) == AV_PIX_FMT_MONOBLACK || \
- (x) == AV_PIX_FMT_MONOWHITE \
- )
-#define isBGRinInt(x) \
- ( \
- (x) == AV_PIX_FMT_BGR48BE || \
- (x) == AV_PIX_FMT_BGR48LE || \
- (x) == AV_PIX_FMT_BGRA64BE || \
- (x) == AV_PIX_FMT_BGRA64LE || \
- (x) == AV_PIX_FMT_BGR32 || \
- (x) == AV_PIX_FMT_BGR32_1 || \
- (x) == AV_PIX_FMT_BGR24 || \
- (x) == AV_PIX_FMT_BGR565BE || \
- (x) == AV_PIX_FMT_BGR565LE || \
- (x) == AV_PIX_FMT_BGR555BE || \
- (x) == AV_PIX_FMT_BGR555LE || \
- (x) == AV_PIX_FMT_BGR444BE || \
- (x) == AV_PIX_FMT_BGR444LE || \
- (x) == AV_PIX_FMT_BGR8 || \
- (x) == AV_PIX_FMT_BGR4 || \
- (x) == AV_PIX_FMT_BGR4_BYTE || \
- (x) == AV_PIX_FMT_MONOBLACK || \
- (x) == AV_PIX_FMT_MONOWHITE \
- )
-
-#define isRGBinBytes(x) ( \
- (x) == AV_PIX_FMT_RGB48BE \
- || (x) == AV_PIX_FMT_RGB48LE \
- || (x) == AV_PIX_FMT_RGBA64BE \
- || (x) == AV_PIX_FMT_RGBA64LE \
- || (x) == AV_PIX_FMT_RGBA \
- || (x) == AV_PIX_FMT_ARGB \
- || (x) == AV_PIX_FMT_RGB24 \
- )
-#define isBGRinBytes(x) ( \
- (x) == AV_PIX_FMT_BGR48BE \
- || (x) == AV_PIX_FMT_BGR48LE \
- || (x) == AV_PIX_FMT_BGRA64BE \
- || (x) == AV_PIX_FMT_BGRA64LE \
- || (x) == AV_PIX_FMT_BGRA \
- || (x) == AV_PIX_FMT_ABGR \
- || (x) == AV_PIX_FMT_BGR24 \
- )
-
-#define isAnyRGB(x) \
- ( \
- isRGBinInt(x) || \
- isBGRinInt(x) || \
- isRGB(x) || \
- (x)==AV_PIX_FMT_GBRP9LE || \
- (x)==AV_PIX_FMT_GBRP9BE || \
- (x)==AV_PIX_FMT_GBRP10LE || \
- (x)==AV_PIX_FMT_GBRP10BE || \
- (x)==AV_PIX_FMT_GBRP12LE || \
- (x)==AV_PIX_FMT_GBRP12BE || \
- (x)==AV_PIX_FMT_GBRP14LE || \
- (x)==AV_PIX_FMT_GBRP14BE || \
- (x)==AV_PIX_FMT_GBR24P \
- )
-
-static av_always_inline int isALPHA(enum AVPixelFormat pix_fmt)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- av_assert0(desc);
- return desc->flags & PIX_FMT_ALPHA;
-}
-
-#if 1
-#define isPacked(x) ( \
- (x)==AV_PIX_FMT_PAL8 \
- || (x)==AV_PIX_FMT_YUYV422 \
- || (x)==AV_PIX_FMT_UYVY422 \
- || (x)==AV_PIX_FMT_Y400A \
- || isRGBinInt(x) \
- || isBGRinInt(x) \
- )
-#else
-static av_always_inline int isPacked(enum AVPixelFormat pix_fmt)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- av_assert0(desc);
- return ((desc->nb_components >= 2 && !(desc->flags & PIX_FMT_PLANAR)) ||
- pix_fmt == AV_PIX_FMT_PAL8);
-}
-
-#endif
-static av_always_inline int isPlanar(enum AVPixelFormat pix_fmt)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- av_assert0(desc);
- return (desc->nb_components >= 2 && (desc->flags & PIX_FMT_PLANAR));
-}
-
-static av_always_inline int isPackedRGB(enum AVPixelFormat pix_fmt)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- av_assert0(desc);
- return ((desc->flags & (PIX_FMT_PLANAR | PIX_FMT_RGB)) == PIX_FMT_RGB);
-}
-
-static av_always_inline int isPlanarRGB(enum AVPixelFormat pix_fmt)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- av_assert0(desc);
- return ((desc->flags & (PIX_FMT_PLANAR | PIX_FMT_RGB)) ==
- (PIX_FMT_PLANAR | PIX_FMT_RGB));
-}
-
-static av_always_inline int usePal(enum AVPixelFormat pix_fmt)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
- av_assert0(desc);
- return (desc->flags & PIX_FMT_PAL) || (desc->flags & PIX_FMT_PSEUDOPAL);
-}
-
-extern const uint64_t ff_dither4[2];
-extern const uint64_t ff_dither8[2];
-extern const uint8_t dithers[8][8][8];
-extern const uint16_t dither_scale[15][16];
-
-
-extern const AVClass sws_context_class;
-
-/**
- * Set c->swScale to an unscaled converter if one exists for the specific
- * source and destination formats, bit depths, flags, etc.
- */
-void ff_get_unscaled_swscale(SwsContext *c);
-
-void ff_swscale_get_unscaled_altivec(SwsContext *c);
-
-/**
- * Return function pointer to fastest main scaler path function depending
- * on architecture and available optimizations.
- */
-SwsFunc ff_getSwsFunc(SwsContext *c);
-
-void ff_sws_init_input_funcs(SwsContext *c);
-void ff_sws_init_output_funcs(SwsContext *c,
- yuv2planar1_fn *yuv2plane1,
- yuv2planarX_fn *yuv2planeX,
- yuv2interleavedX_fn *yuv2nv12cX,
- yuv2packed1_fn *yuv2packed1,
- yuv2packed2_fn *yuv2packed2,
- yuv2packedX_fn *yuv2packedX,
- yuv2anyX_fn *yuv2anyX);
-void ff_sws_init_swScale_altivec(SwsContext *c);
-void ff_sws_init_swScale_mmx(SwsContext *c);
-
-static inline void fillPlane16(uint8_t *plane, int stride, int width, int height, int y,
- int alpha, int bits, const int big_endian)
-{
- int i, j;
- uint8_t *ptr = plane + stride * y;
- int v = alpha ? 0xFFFF>>(15-bits) : (1<<bits);
- for (i = 0; i < height; i++) {
-#define FILL(wfunc) \
- for (j = 0; j < width; j++) {\
- wfunc(ptr+2*j, v);\
- }
- if (big_endian) {
- FILL(AV_WB16);
- } else {
- FILL(AV_WL16);
- }
- ptr += stride;
- }
-}
-
-#endif /* SWSCALE_SWSCALE_INTERNAL_H */
diff --git a/src/thirdparty/ffmpeg/libswscale/swscale_unscaled.c b/src/thirdparty/ffmpeg/libswscale/swscale_unscaled.c
deleted file mode 100644
index 115898e8a..000000000
--- a/src/thirdparty/ffmpeg/libswscale/swscale_unscaled.c
+++ /dev/null
@@ -1,1068 +0,0 @@
-/*
- * Copyright (C) 2001-2011 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
- */
-
-#include <inttypes.h>
-#include <string.h>
-#include <math.h>
-#include <stdio.h>
-#include "config.h"
-#include "swscale.h"
-#include "swscale_internal.h"
-#include "rgb2rgb.h"
-#include "libavutil/intreadwrite.h"
-#include "libavutil/cpu.h"
-#include "libavutil/avutil.h"
-#include "libavutil/mathematics.h"
-#include "libavutil/bswap.h"
-#include "libavutil/pixdesc.h"
-#include "libavutil/avassert.h"
-
-DECLARE_ALIGNED(8, const uint8_t, dithers)[8][8][8]={
-{
- { 0, 1, 0, 1, 0, 1, 0, 1,},
- { 1, 0, 1, 0, 1, 0, 1, 0,},
- { 0, 1, 0, 1, 0, 1, 0, 1,},
- { 1, 0, 1, 0, 1, 0, 1, 0,},
- { 0, 1, 0, 1, 0, 1, 0, 1,},
- { 1, 0, 1, 0, 1, 0, 1, 0,},
- { 0, 1, 0, 1, 0, 1, 0, 1,},
- { 1, 0, 1, 0, 1, 0, 1, 0,},
-},{
- { 1, 2, 1, 2, 1, 2, 1, 2,},
- { 3, 0, 3, 0, 3, 0, 3, 0,},
- { 1, 2, 1, 2, 1, 2, 1, 2,},
- { 3, 0, 3, 0, 3, 0, 3, 0,},
- { 1, 2, 1, 2, 1, 2, 1, 2,},
- { 3, 0, 3, 0, 3, 0, 3, 0,},
- { 1, 2, 1, 2, 1, 2, 1, 2,},
- { 3, 0, 3, 0, 3, 0, 3, 0,},
-},{
- { 2, 4, 3, 5, 2, 4, 3, 5,},
- { 6, 0, 7, 1, 6, 0, 7, 1,},
- { 3, 5, 2, 4, 3, 5, 2, 4,},
- { 7, 1, 6, 0, 7, 1, 6, 0,},
- { 2, 4, 3, 5, 2, 4, 3, 5,},
- { 6, 0, 7, 1, 6, 0, 7, 1,},
- { 3, 5, 2, 4, 3, 5, 2, 4,},
- { 7, 1, 6, 0, 7, 1, 6, 0,},
-},{
- { 4, 8, 7, 11, 4, 8, 7, 11,},
- { 12, 0, 15, 3, 12, 0, 15, 3,},
- { 6, 10, 5, 9, 6, 10, 5, 9,},
- { 14, 2, 13, 1, 14, 2, 13, 1,},
- { 4, 8, 7, 11, 4, 8, 7, 11,},
- { 12, 0, 15, 3, 12, 0, 15, 3,},
- { 6, 10, 5, 9, 6, 10, 5, 9,},
- { 14, 2, 13, 1, 14, 2, 13, 1,},
-},{
- { 9, 17, 15, 23, 8, 16, 14, 22,},
- { 25, 1, 31, 7, 24, 0, 30, 6,},
- { 13, 21, 11, 19, 12, 20, 10, 18,},
- { 29, 5, 27, 3, 28, 4, 26, 2,},
- { 8, 16, 14, 22, 9, 17, 15, 23,},
- { 24, 0, 30, 6, 25, 1, 31, 7,},
- { 12, 20, 10, 18, 13, 21, 11, 19,},
- { 28, 4, 26, 2, 29, 5, 27, 3,},
-},{
- { 18, 34, 30, 46, 17, 33, 29, 45,},
- { 50, 2, 62, 14, 49, 1, 61, 13,},
- { 26, 42, 22, 38, 25, 41, 21, 37,},
- { 58, 10, 54, 6, 57, 9, 53, 5,},
- { 16, 32, 28, 44, 19, 35, 31, 47,},
- { 48, 0, 60, 12, 51, 3, 63, 15,},
- { 24, 40, 20, 36, 27, 43, 23, 39,},
- { 56, 8, 52, 4, 59, 11, 55, 7,},
-},{
- { 18, 34, 30, 46, 17, 33, 29, 45,},
- { 50, 2, 62, 14, 49, 1, 61, 13,},
- { 26, 42, 22, 38, 25, 41, 21, 37,},
- { 58, 10, 54, 6, 57, 9, 53, 5,},
- { 16, 32, 28, 44, 19, 35, 31, 47,},
- { 48, 0, 60, 12, 51, 3, 63, 15,},
- { 24, 40, 20, 36, 27, 43, 23, 39,},
- { 56, 8, 52, 4, 59, 11, 55, 7,},
-},{
- { 36, 68, 60, 92, 34, 66, 58, 90,},
- { 100, 4,124, 28, 98, 2,122, 26,},
- { 52, 84, 44, 76, 50, 82, 42, 74,},
- { 116, 20,108, 12,114, 18,106, 10,},
- { 32, 64, 56, 88, 38, 70, 62, 94,},
- { 96, 0,120, 24,102, 6,126, 30,},
- { 48, 80, 40, 72, 54, 86, 46, 78,},
- { 112, 16,104, 8,118, 22,110, 14,},
-}};
-
-const uint16_t dither_scale[15][16]={
-{ 2, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,},
-{ 2, 3, 7, 7, 13, 13, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,},
-{ 3, 3, 4, 15, 15, 29, 57, 57, 57, 113, 113, 113, 113, 113, 113, 113,},
-{ 3, 4, 4, 5, 31, 31, 61, 121, 241, 241, 241, 241, 481, 481, 481, 481,},
-{ 3, 4, 5, 5, 6, 63, 63, 125, 249, 497, 993, 993, 993, 993, 993, 1985,},
-{ 3, 5, 6, 6, 6, 7, 127, 127, 253, 505, 1009, 2017, 4033, 4033, 4033, 4033,},
-{ 3, 5, 6, 7, 7, 7, 8, 255, 255, 509, 1017, 2033, 4065, 8129,16257,16257,},
-{ 3, 5, 6, 8, 8, 8, 8, 9, 511, 511, 1021, 2041, 4081, 8161,16321,32641,},
-{ 3, 5, 7, 8, 9, 9, 9, 9, 10, 1023, 1023, 2045, 4089, 8177,16353,32705,},
-{ 3, 5, 7, 8, 10, 10, 10, 10, 10, 11, 2047, 2047, 4093, 8185,16369,32737,},
-{ 3, 5, 7, 8, 10, 11, 11, 11, 11, 11, 12, 4095, 4095, 8189,16377,32753,},
-{ 3, 5, 7, 9, 10, 12, 12, 12, 12, 12, 12, 13, 8191, 8191,16381,32761,},
-{ 3, 5, 7, 9, 10, 12, 13, 13, 13, 13, 13, 13, 14,16383,16383,32765,},
-{ 3, 5, 7, 9, 10, 12, 14, 14, 14, 14, 14, 14, 14, 15,32767,32767,},
-{ 3, 5, 7, 9, 11, 12, 14, 15, 15, 15, 15, 15, 15, 15, 16,65535,},
-};
-
-
-static void fillPlane(uint8_t *plane, int stride, int width, int height, int y,
- uint8_t val)
-{
- int i;
- uint8_t *ptr = plane + stride * y;
- for (i = 0; i < height; i++) {
- memset(ptr, val, width);
- ptr += stride;
- }
-}
-
-static void copyPlane(const uint8_t *src, int srcStride,
- int srcSliceY, int srcSliceH, int width,
- uint8_t *dst, int dstStride)
-{
- dst += dstStride * srcSliceY;
- if (dstStride == srcStride && srcStride > 0) {
- memcpy(dst, src, srcSliceH * dstStride);
- } else {
- int i;
- for (i = 0; i < srcSliceH; i++) {
- memcpy(dst, src, width);
- src += srcStride;
- dst += dstStride;
- }
- }
-}
-
-static int planarToNv12Wrapper(SwsContext *c, const uint8_t *src[],
- int srcStride[], int srcSliceY,
- int srcSliceH, uint8_t *dstParam[],
- int dstStride[])
-{
- uint8_t *dst = dstParam[1] + dstStride[1] * srcSliceY / 2;
-
- copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->srcW,
- dstParam[0], dstStride[0]);
-
- if (c->dstFormat == AV_PIX_FMT_NV12)
- interleaveBytes(src[1], src[2], dst, c->srcW / 2, srcSliceH / 2,
- srcStride[1], srcStride[2], dstStride[0]);
- else
- interleaveBytes(src[2], src[1], dst, c->srcW / 2, srcSliceH / 2,
- srcStride[2], srcStride[1], dstStride[0]);
-
- return srcSliceH;
-}
-
-static int planarToYuy2Wrapper(SwsContext *c, const uint8_t *src[],
- int srcStride[], int srcSliceY, int srcSliceH,
- uint8_t *dstParam[], int dstStride[])
-{
- uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
-
- yv12toyuy2(src[0], src[1], src[2], dst, c->srcW, srcSliceH, srcStride[0],
- srcStride[1], dstStride[0]);
-
- return srcSliceH;
-}
-
-static int planarToUyvyWrapper(SwsContext *c, const uint8_t *src[],
- int srcStride[], int srcSliceY, int srcSliceH,
- uint8_t *dstParam[], int dstStride[])
-{
- uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
-
- yv12touyvy(src[0], src[1], src[2], dst, c->srcW, srcSliceH, srcStride[0],
- srcStride[1], dstStride[0]);
-
- return srcSliceH;
-}
-
-static int yuv422pToYuy2Wrapper(SwsContext *c, const uint8_t *src[],
- int srcStride[], int srcSliceY, int srcSliceH,
- uint8_t *dstParam[], int dstStride[])
-{
- uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
-
- yuv422ptoyuy2(src[0], src[1], src[2], dst, c->srcW, srcSliceH, srcStride[0],
- srcStride[1], dstStride[0]);
-
- return srcSliceH;
-}
-
-static int yuv422pToUyvyWrapper(SwsContext *c, const uint8_t *src[],
- int srcStride[], int srcSliceY, int srcSliceH,
- uint8_t *dstParam[], int dstStride[])
-{
- uint8_t *dst = dstParam[0] + dstStride[0] * srcSliceY;
-
- yuv422ptouyvy(src[0], src[1], src[2], dst, c->srcW, srcSliceH, srcStride[0],
- srcStride[1], dstStride[0]);
-
- return srcSliceH;
-}
-
-static int yuyvToYuv420Wrapper(SwsContext *c, const uint8_t *src[],
- int srcStride[], int srcSliceY, int srcSliceH,
- uint8_t *dstParam[], int dstStride[])
-{
- uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
- uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY / 2;
- uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY / 2;
-
- yuyvtoyuv420(ydst, udst, vdst, src[0], c->srcW, srcSliceH, dstStride[0],
- dstStride[1], srcStride[0]);
-
- if (dstParam[3])
- fillPlane(dstParam[3], dstStride[3], c->srcW, srcSliceH, srcSliceY, 255);
-
- return srcSliceH;
-}
-
-static int yuyvToYuv422Wrapper(SwsContext *c, const uint8_t *src[],
- int srcStride[], int srcSliceY, int srcSliceH,
- uint8_t *dstParam[], int dstStride[])
-{
- uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
- uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY;
- uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY;
-
- yuyvtoyuv422(ydst, udst, vdst, src[0], c->srcW, srcSliceH, dstStride[0],
- dstStride[1], srcStride[0]);
-
- return srcSliceH;
-}
-
-static int uyvyToYuv420Wrapper(SwsContext *c, const uint8_t *src[],
- int srcStride[], int srcSliceY, int srcSliceH,
- uint8_t *dstParam[], int dstStride[])
-{
- uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
- uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY / 2;
- uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY / 2;
-
- uyvytoyuv420(ydst, udst, vdst, src[0], c->srcW, srcSliceH, dstStride[0],
- dstStride[1], srcStride[0]);
-
- if (dstParam[3])
- fillPlane(dstParam[3], dstStride[3], c->srcW, srcSliceH, srcSliceY, 255);
-
- return srcSliceH;
-}
-
-static int uyvyToYuv422Wrapper(SwsContext *c, const uint8_t *src[],
- int srcStride[], int srcSliceY, int srcSliceH,
- uint8_t *dstParam[], int dstStride[])
-{
- uint8_t *ydst = dstParam[0] + dstStride[0] * srcSliceY;
- uint8_t *udst = dstParam[1] + dstStride[1] * srcSliceY;
- uint8_t *vdst = dstParam[2] + dstStride[2] * srcSliceY;
-
- uyvytoyuv422(ydst, udst, vdst, src[0], c->srcW, srcSliceH, dstStride[0],
- dstStride[1], srcStride[0]);
-
- return srcSliceH;
-}
-
-static void gray8aToPacked32(const uint8_t *src, uint8_t *dst, int num_pixels,
- const uint8_t *palette)
-{
- int i;
- for (i = 0; i < num_pixels; i++)
- ((uint32_t *) dst)[i] = ((const uint32_t *) palette)[src[i << 1]] | (src[(i << 1) + 1] << 24);
-}
-
-static void gray8aToPacked32_1(const uint8_t *src, uint8_t *dst, int num_pixels,
- const uint8_t *palette)
-{
- int i;
-
- for (i = 0; i < num_pixels; i++)
- ((uint32_t *) dst)[i] = ((const uint32_t *) palette)[src[i << 1]] | src[(i << 1) + 1];
-}
-
-static void gray8aToPacked24(const uint8_t *src, uint8_t *dst, int num_pixels,
- const uint8_t *palette)
-{
- int i;
-
- for (i = 0; i < num_pixels; i++) {
- //FIXME slow?
- dst[0] = palette[src[i << 1] * 4 + 0];
- dst[1] = palette[src[i << 1] * 4 + 1];
- dst[2] = palette[src[i << 1] * 4 + 2];
- dst += 3;
- }
-}
-
-static int packed_16bpc_bswap(SwsContext *c, const uint8_t *src[],
- int srcStride[], int srcSliceY, int srcSliceH,
- uint8_t *dst[], int dstStride[])
-{
- int i, j;
- int srcstr = srcStride[0] >> 1;
- int dststr = dstStride[0] >> 1;
- uint16_t *dstPtr = (uint16_t *) dst[0];
- const uint16_t *srcPtr = (const uint16_t *) src[0];
- int min_stride = FFMIN(srcstr, dststr);
-
- for (i = 0; i < srcSliceH; i++) {
- for (j = 0; j < min_stride; j++) {
- dstPtr[j] = av_bswap16(srcPtr[j]);
- }
- srcPtr += srcstr;
- dstPtr += dststr;
- }
-
- return srcSliceH;
-}
-
-static int palToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[],
- int srcSliceY, int srcSliceH, uint8_t *dst[],
- int dstStride[])
-{
- const enum AVPixelFormat srcFormat = c->srcFormat;
- const enum AVPixelFormat dstFormat = c->dstFormat;
- void (*conv)(const uint8_t *src, uint8_t *dst, int num_pixels,
- const uint8_t *palette) = NULL;
- int i;
- uint8_t *dstPtr = dst[0] + dstStride[0] * srcSliceY;
- const uint8_t *srcPtr = src[0];
-
- if (srcFormat == AV_PIX_FMT_GRAY8A) {
- switch (dstFormat) {
- case AV_PIX_FMT_RGB32 : conv = gray8aToPacked32; break;
- case AV_PIX_FMT_BGR32 : conv = gray8aToPacked32; break;
- case AV_PIX_FMT_BGR32_1: conv = gray8aToPacked32_1; break;
- case AV_PIX_FMT_RGB32_1: conv = gray8aToPacked32_1; break;
- case AV_PIX_FMT_RGB24 : conv = gray8aToPacked24; break;
- case AV_PIX_FMT_BGR24 : conv = gray8aToPacked24; break;
- }
- } else if (usePal(srcFormat)) {
- switch (dstFormat) {
- case AV_PIX_FMT_RGB32 : conv = sws_convertPalette8ToPacked32; break;
- case AV_PIX_FMT_BGR32 : conv = sws_convertPalette8ToPacked32; break;
- case AV_PIX_FMT_BGR32_1: conv = sws_convertPalette8ToPacked32; break;
- case AV_PIX_FMT_RGB32_1: conv = sws_convertPalette8ToPacked32; break;
- case AV_PIX_FMT_RGB24 : conv = sws_convertPalette8ToPacked24; break;
- case AV_PIX_FMT_BGR24 : conv = sws_convertPalette8ToPacked24; break;
- }
- }
-
- if (!conv)
- av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
- av_get_pix_fmt_name(srcFormat), av_get_pix_fmt_name(dstFormat));
- else {
- for (i = 0; i < srcSliceH; i++) {
- conv(srcPtr, dstPtr, c->srcW, (uint8_t *) c->pal_rgb);
- srcPtr += srcStride[0];
- dstPtr += dstStride[0];
- }
- }
-
- return srcSliceH;
-}
-
-static void gbr24ptopacked24(const uint8_t *src[], int srcStride[],
- uint8_t *dst, int dstStride, int srcSliceH,
- int width)
-{
- int x, h, i;
- for (h = 0; h < srcSliceH; h++) {
- uint8_t *dest = dst + dstStride * h;
- for (x = 0; x < width; x++) {
- *dest++ = src[0][x];
- *dest++ = src[1][x];
- *dest++ = src[2][x];
- }
-
- for (i = 0; i < 3; i++)
- src[i] += srcStride[i];
- }
-}
-
-static void gbr24ptopacked32(const uint8_t *src[], int srcStride[],
- uint8_t *dst, int dstStride, int srcSliceH,
- int alpha_first, int width)
-{
- int x, h, i;
- for (h = 0; h < srcSliceH; h++) {
- uint8_t *dest = dst + dstStride * h;
-
- if (alpha_first) {
- for (x = 0; x < width; x++) {
- *dest++ = 0xff;
- *dest++ = src[0][x];
- *dest++ = src[1][x];
- *dest++ = src[2][x];
- }
- } else {
- for (x = 0; x < width; x++) {
- *dest++ = src[0][x];
- *dest++ = src[1][x];
- *dest++ = src[2][x];
- *dest++ = 0xff;
- }
- }
-
- for (i = 0; i < 3; i++)
- src[i] += srcStride[i];
- }
-}
-
-static int planarRgbToRgbWrapper(SwsContext *c, const uint8_t *src[],
- int srcStride[], int srcSliceY, int srcSliceH,
- uint8_t *dst[], int dstStride[])
-{
- int alpha_first = 0;
- const uint8_t *src102[] = { src[1], src[0], src[2] };
- const uint8_t *src201[] = { src[2], src[0], src[1] };
- int stride102[] = { srcStride[1], srcStride[0], srcStride[2] };
- int stride201[] = { srcStride[2], srcStride[0], srcStride[1] };
-
- if (c->srcFormat != AV_PIX_FMT_GBRP) {
- av_log(c, AV_LOG_ERROR, "unsupported planar RGB conversion %s -> %s\n",
- av_get_pix_fmt_name(c->srcFormat),
- av_get_pix_fmt_name(c->dstFormat));
- return srcSliceH;
- }
-
- switch (c->dstFormat) {
- case AV_PIX_FMT_BGR24:
- gbr24ptopacked24(src102, stride102,
- dst[0] + srcSliceY * dstStride[0], dstStride[0],
- srcSliceH, c->srcW);
- break;
-
- case AV_PIX_FMT_RGB24:
- gbr24ptopacked24(src201, stride201,
- dst[0] + srcSliceY * dstStride[0], dstStride[0],
- srcSliceH, c->srcW);
- break;
-
- case AV_PIX_FMT_ARGB:
- alpha_first = 1;
- case AV_PIX_FMT_RGBA:
- gbr24ptopacked32(src201, stride201,
- dst[0] + srcSliceY * dstStride[0], dstStride[0],
- srcSliceH, alpha_first, c->srcW);
- break;
-
- case AV_PIX_FMT_ABGR:
- alpha_first = 1;
- case AV_PIX_FMT_BGRA:
- gbr24ptopacked32(src102, stride102,
- dst[0] + srcSliceY * dstStride[0], dstStride[0],
- srcSliceH, alpha_first, c->srcW);
- break;
-
- default:
- av_log(c, AV_LOG_ERROR,
- "unsupported planar RGB conversion %s -> %s\n",
- av_get_pix_fmt_name(c->srcFormat),
- av_get_pix_fmt_name(c->dstFormat));
- }
-
- return srcSliceH;
-}
-
-#define isRGBA32(x) ( \
- (x) == AV_PIX_FMT_ARGB \
- || (x) == AV_PIX_FMT_RGBA \
- || (x) == AV_PIX_FMT_BGRA \
- || (x) == AV_PIX_FMT_ABGR \
- )
-
-#define isRGBA64(x) ( \
- (x) == AV_PIX_FMT_RGBA64LE \
- || (x) == AV_PIX_FMT_RGBA64BE \
- || (x) == AV_PIX_FMT_BGRA64LE \
- || (x) == AV_PIX_FMT_BGRA64BE \
- )
-
-#define isRGB48(x) ( \
- (x) == AV_PIX_FMT_RGB48LE \
- || (x) == AV_PIX_FMT_RGB48BE \
- || (x) == AV_PIX_FMT_BGR48LE \
- || (x) == AV_PIX_FMT_BGR48BE \
- )
-
-/* {RGB,BGR}{15,16,24,32,32_1} -> {RGB,BGR}{15,16,24,32} */
-typedef void (* rgbConvFn) (const uint8_t *, uint8_t *, int);
-static rgbConvFn findRgbConvFn(SwsContext *c)
-{
- const enum AVPixelFormat srcFormat = c->srcFormat;
- const enum AVPixelFormat dstFormat = c->dstFormat;
- const int srcId = c->srcFormatBpp;
- const int dstId = c->dstFormatBpp;
- rgbConvFn conv = NULL;
-
-#define IS_NOT_NE(bpp, desc) \
- (((bpp + 7) >> 3) == 2 && \
- (!(desc->flags & PIX_FMT_BE) != !HAVE_BIGENDIAN))
-
-#define CONV_IS(src, dst) (srcFormat == AV_PIX_FMT_##src && dstFormat == AV_PIX_FMT_##dst)
-
- if (isRGBA32(srcFormat) && isRGBA32(dstFormat)) {
- if ( CONV_IS(ABGR, RGBA)
- || CONV_IS(ARGB, BGRA)
- || CONV_IS(BGRA, ARGB)
- || CONV_IS(RGBA, ABGR)) conv = shuffle_bytes_3210;
- else if (CONV_IS(ABGR, ARGB)
- || CONV_IS(ARGB, ABGR)) conv = shuffle_bytes_0321;
- else if (CONV_IS(ABGR, BGRA)
- || CONV_IS(ARGB, RGBA)) conv = shuffle_bytes_1230;
- else if (CONV_IS(BGRA, RGBA)
- || CONV_IS(RGBA, BGRA)) conv = shuffle_bytes_2103;
- else if (CONV_IS(BGRA, ABGR)
- || CONV_IS(RGBA, ARGB)) conv = shuffle_bytes_3012;
- } else if (isRGB48(srcFormat) && isRGB48(dstFormat)) {
- if (CONV_IS(RGB48LE, BGR48LE)
- || CONV_IS(BGR48LE, RGB48LE)
- || CONV_IS(RGB48BE, BGR48BE)
- || CONV_IS(BGR48BE, RGB48BE)) conv = rgb48tobgr48_nobswap;
- else if (CONV_IS(RGB48LE, BGR48BE)
- || CONV_IS(BGR48LE, RGB48BE)
- || CONV_IS(RGB48BE, BGR48LE)
- || CONV_IS(BGR48BE, RGB48LE)) conv = rgb48tobgr48_bswap;
- } else if (isRGBA64(srcFormat) && isRGB48(dstFormat)) {
- if (CONV_IS(RGBA64LE, BGR48LE)
- || CONV_IS(BGRA64LE, RGB48LE)
- || CONV_IS(RGBA64BE, BGR48BE)
- || CONV_IS(BGRA64BE, RGB48BE)) conv = rgb64tobgr48_nobswap;
- else if (CONV_IS(RGBA64LE, BGR48BE)
- || CONV_IS(BGRA64LE, RGB48BE)
- || CONV_IS(RGBA64BE, BGR48LE)
- || CONV_IS(BGRA64BE, RGB48LE)) conv = rgb64tobgr48_bswap;
- else if (CONV_IS(RGBA64LE, RGB48LE)
- || CONV_IS(BGRA64LE, BGR48LE)
- || CONV_IS(RGBA64BE, RGB48BE)
- || CONV_IS(BGRA64BE, BGR48BE)) conv = rgb64to48_nobswap;
- else if (CONV_IS(RGBA64LE, RGB48BE)
- || CONV_IS(BGRA64LE, BGR48BE)
- || CONV_IS(RGBA64BE, RGB48LE)
- || CONV_IS(BGRA64BE, BGR48LE)) conv = rgb64to48_bswap;
- } else
- /* BGR -> BGR */
- if ((isBGRinInt(srcFormat) && isBGRinInt(dstFormat)) ||
- (isRGBinInt(srcFormat) && isRGBinInt(dstFormat))) {
- switch (srcId | (dstId << 16)) {
- case 0x000F000C: conv = rgb12to15; break;
- case 0x000F0010: conv = rgb16to15; break;
- case 0x000F0018: conv = rgb24to15; break;
- case 0x000F0020: conv = rgb32to15; break;
- case 0x0010000F: conv = rgb15to16; break;
- case 0x00100018: conv = rgb24to16; break;
- case 0x00100020: conv = rgb32to16; break;
- case 0x0018000F: conv = rgb15to24; break;
- case 0x00180010: conv = rgb16to24; break;
- case 0x00180020: conv = rgb32to24; break;
- case 0x0020000F: conv = rgb15to32; break;
- case 0x00200010: conv = rgb16to32; break;
- case 0x00200018: conv = rgb24to32; break;
- }
- } else if ((isBGRinInt(srcFormat) && isRGBinInt(dstFormat)) ||
- (isRGBinInt(srcFormat) && isBGRinInt(dstFormat))) {
- switch (srcId | (dstId << 16)) {
- case 0x000C000C: conv = rgb12tobgr12; break;
- case 0x000F000F: conv = rgb15tobgr15; break;
- case 0x000F0010: conv = rgb16tobgr15; break;
- case 0x000F0018: conv = rgb24tobgr15; break;
- case 0x000F0020: conv = rgb32tobgr15; break;
- case 0x0010000F: conv = rgb15tobgr16; break;
- case 0x00100010: conv = rgb16tobgr16; break;
- case 0x00100018: conv = rgb24tobgr16; break;
- case 0x00100020: conv = rgb32tobgr16; break;
- case 0x0018000F: conv = rgb15tobgr24; break;
- case 0x00180010: conv = rgb16tobgr24; break;
- case 0x00180018: conv = rgb24tobgr24; break;
- case 0x00180020: conv = rgb32tobgr24; break;
- case 0x0020000F: conv = rgb15tobgr32; break;
- case 0x00200010: conv = rgb16tobgr32; break;
- case 0x00200018: conv = rgb24tobgr32; break;
- }
- }
-
- if ((dstFormat == AV_PIX_FMT_RGB32_1 || dstFormat == AV_PIX_FMT_BGR32_1) && !isRGBA32(srcFormat) && ALT32_CORR<0)
- return NULL;
-
- return conv;
-}
-
-/* {RGB,BGR}{15,16,24,32,32_1} -> {RGB,BGR}{15,16,24,32} */
-static int rgbToRgbWrapper(SwsContext *c, const uint8_t *src[], int srcStride[],
- int srcSliceY, int srcSliceH, uint8_t *dst[],
- int dstStride[])
-
-{
- const enum AVPixelFormat srcFormat = c->srcFormat;
- const enum AVPixelFormat dstFormat = c->dstFormat;
- const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(c->srcFormat);
- const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(c->dstFormat);
- const int srcBpp = (c->srcFormatBpp + 7) >> 3;
- const int dstBpp = (c->dstFormatBpp + 7) >> 3;
- rgbConvFn conv = findRgbConvFn(c);
-
- if (!conv) {
- av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
- av_get_pix_fmt_name(srcFormat), av_get_pix_fmt_name(dstFormat));
- } else {
- const uint8_t *srcPtr = src[0];
- uint8_t *dstPtr = dst[0];
- int src_bswap = IS_NOT_NE(c->srcFormatBpp, desc_src);
- int dst_bswap = IS_NOT_NE(c->dstFormatBpp, desc_dst);
-
- if ((srcFormat == AV_PIX_FMT_RGB32_1 || srcFormat == AV_PIX_FMT_BGR32_1) &&
- !isRGBA32(dstFormat))
- srcPtr += ALT32_CORR;
-
- if ((dstFormat == AV_PIX_FMT_RGB32_1 || dstFormat == AV_PIX_FMT_BGR32_1) &&
- !isRGBA32(srcFormat))
- dstPtr += ALT32_CORR;
-
- if (dstStride[0] * srcBpp == srcStride[0] * dstBpp && srcStride[0] > 0 &&
- !(srcStride[0] % srcBpp) && !dst_bswap && !src_bswap)
- conv(srcPtr, dstPtr + dstStride[0] * srcSliceY,
- srcSliceH * srcStride[0]);
- else {
- int i, j;
- dstPtr += dstStride[0] * srcSliceY;
-
- for (i = 0; i < srcSliceH; i++) {
- if(src_bswap) {
- for(j=0; j<c->srcW; j++)
- ((uint16_t*)c->formatConvBuffer)[j] = av_bswap16(((uint16_t*)srcPtr)[j]);
- conv(c->formatConvBuffer, dstPtr, c->srcW * srcBpp);
- }else
- conv(srcPtr, dstPtr, c->srcW * srcBpp);
- if(dst_bswap)
- for(j=0; j<c->srcW; j++)
- ((uint16_t*)dstPtr)[j] = av_bswap16(((uint16_t*)dstPtr)[j]);
- srcPtr += srcStride[0];
- dstPtr += dstStride[0];
- }
- }
- }
- return srcSliceH;
-}
-
-static int bgr24ToYv12Wrapper(SwsContext *c, const uint8_t *src[],
- int srcStride[], int srcSliceY, int srcSliceH,
- uint8_t *dst[], int dstStride[])
-{
- rgb24toyv12(
- src[0],
- dst[0] + srcSliceY * dstStride[0],
- dst[1] + (srcSliceY >> 1) * dstStride[1],
- dst[2] + (srcSliceY >> 1) * dstStride[2],
- c->srcW, srcSliceH,
- dstStride[0], dstStride[1], srcStride[0]);
- if (dst[3])
- fillPlane(dst[3], dstStride[3], c->srcW, srcSliceH, srcSliceY, 255);
- return srcSliceH;
-}
-
-static int yvu9ToYv12Wrapper(SwsContext *c, const uint8_t *src[],
- int srcStride[], int srcSliceY, int srcSliceH,
- uint8_t *dst[], int dstStride[])
-{
- copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->srcW,
- dst[0], dstStride[0]);
-
- planar2x(src[1], dst[1] + dstStride[1] * (srcSliceY >> 1), c->chrSrcW,
- srcSliceH >> 2, srcStride[1], dstStride[1]);
- planar2x(src[2], dst[2] + dstStride[2] * (srcSliceY >> 1), c->chrSrcW,
- srcSliceH >> 2, srcStride[2], dstStride[2]);
- if (dst[3])
- fillPlane(dst[3], dstStride[3], c->srcW, srcSliceH, srcSliceY, 255);
- return srcSliceH;
-}
-
-/* unscaled copy like stuff (assumes nearly identical formats) */
-static int packedCopyWrapper(SwsContext *c, const uint8_t *src[],
- int srcStride[], int srcSliceY, int srcSliceH,
- uint8_t *dst[], int dstStride[])
-{
- if (dstStride[0] == srcStride[0] && srcStride[0] > 0)
- memcpy(dst[0] + dstStride[0] * srcSliceY, src[0], srcSliceH * dstStride[0]);
- else {
- int i;
- const uint8_t *srcPtr = src[0];
- uint8_t *dstPtr = dst[0] + dstStride[0] * srcSliceY;
- int length = 0;
-
- /* universal length finder */
- while (length + c->srcW <= FFABS(dstStride[0]) &&
- length + c->srcW <= FFABS(srcStride[0]))
- length += c->srcW;
- av_assert1(length != 0);
-
- for (i = 0; i < srcSliceH; i++) {
- memcpy(dstPtr, srcPtr, length);
- srcPtr += srcStride[0];
- dstPtr += dstStride[0];
- }
- }
- return srcSliceH;
-}
-
-#define DITHER_COPY(dst, dstStride, src, srcStride, bswap, dbswap)\
- uint16_t scale= dither_scale[dst_depth-1][src_depth-1];\
- int shift= src_depth-dst_depth + dither_scale[src_depth-2][dst_depth-1];\
- for (i = 0; i < height; i++) {\
- const uint8_t *dither= dithers[src_depth-9][i&7];\
- for (j = 0; j < length-7; j+=8){\
- dst[j+0] = dbswap((bswap(src[j+0]) + dither[0])*scale>>shift);\
- dst[j+1] = dbswap((bswap(src[j+1]) + dither[1])*scale>>shift);\
- dst[j+2] = dbswap((bswap(src[j+2]) + dither[2])*scale>>shift);\
- dst[j+3] = dbswap((bswap(src[j+3]) + dither[3])*scale>>shift);\
- dst[j+4] = dbswap((bswap(src[j+4]) + dither[4])*scale>>shift);\
- dst[j+5] = dbswap((bswap(src[j+5]) + dither[5])*scale>>shift);\
- dst[j+6] = dbswap((bswap(src[j+6]) + dither[6])*scale>>shift);\
- dst[j+7] = dbswap((bswap(src[j+7]) + dither[7])*scale>>shift);\
- }\
- for (; j < length; j++)\
- dst[j] = dbswap((bswap(src[j]) + dither[j&7])*scale>>shift);\
- dst += dstStride;\
- src += srcStride;\
- }
-
-static int planarCopyWrapper(SwsContext *c, const uint8_t *src[],
- int srcStride[], int srcSliceY, int srcSliceH,
- uint8_t *dst[], int dstStride[])
-{
- const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(c->srcFormat);
- const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(c->dstFormat);
- int plane, i, j;
- for (plane = 0; plane < 4; plane++) {
- int length = (plane == 0 || plane == 3) ? c->srcW : -((-c->srcW ) >> c->chrDstHSubSample);
- int y = (plane == 0 || plane == 3) ? srcSliceY: -((-srcSliceY) >> c->chrDstVSubSample);
- int height = (plane == 0 || plane == 3) ? srcSliceH: -((-srcSliceH) >> c->chrDstVSubSample);
- const uint8_t *srcPtr = src[plane];
- uint8_t *dstPtr = dst[plane] + dstStride[plane] * y;
- int shiftonly= plane==1 || plane==2 || (!c->srcRange && plane==0);
-
- if (!dst[plane])
- continue;
- // ignore palette for GRAY8
- if (plane == 1 && !dst[2]) continue;
- if (!src[plane] || (plane == 1 && !src[2])) {
- if (is16BPS(c->dstFormat) || isNBPS(c->dstFormat)) {
- fillPlane16(dst[plane], dstStride[plane], length, height, y,
- plane == 3, desc_dst->comp[plane].depth_minus1,
- isBE(c->dstFormat));
- } else {
- fillPlane(dst[plane], dstStride[plane], length, height, y,
- (plane == 3) ? 255 : 128);
- }
- } else {
- if(isNBPS(c->srcFormat) || isNBPS(c->dstFormat)
- || (is16BPS(c->srcFormat) != is16BPS(c->dstFormat))
- ) {
- const int src_depth = desc_src->comp[plane].depth_minus1 + 1;
- const int dst_depth = desc_dst->comp[plane].depth_minus1 + 1;
- const uint16_t *srcPtr2 = (const uint16_t *) srcPtr;
- uint16_t *dstPtr2 = (uint16_t*)dstPtr;
-
- if (dst_depth == 8) {
- if(isBE(c->srcFormat) == HAVE_BIGENDIAN){
- DITHER_COPY(dstPtr, dstStride[plane], srcPtr2, srcStride[plane]/2, , )
- } else {
- DITHER_COPY(dstPtr, dstStride[plane], srcPtr2, srcStride[plane]/2, av_bswap16, )
- }
- } else if (src_depth == 8) {
- for (i = 0; i < height; i++) {
- #define COPY816(w)\
- if(shiftonly){\
- for (j = 0; j < length; j++)\
- w(&dstPtr2[j], srcPtr[j]<<(dst_depth-8));\
- }else{\
- for (j = 0; j < length; j++)\
- w(&dstPtr2[j], (srcPtr[j]<<(dst_depth-8)) |\
- (srcPtr[j]>>(2*8-dst_depth)));\
- }
- if(isBE(c->dstFormat)){
- COPY816(AV_WB16)
- } else {
- COPY816(AV_WL16)
- }
- dstPtr2 += dstStride[plane]/2;
- srcPtr += srcStride[plane];
- }
- } else if (src_depth <= dst_depth) {
- int orig_length = length;
- for (i = 0; i < height; i++) {
- if(isBE(c->srcFormat) == HAVE_BIGENDIAN &&
- isBE(c->dstFormat) == HAVE_BIGENDIAN &&
- shiftonly) {
- unsigned shift = dst_depth - src_depth;
- length = orig_length;
-#if HAVE_FAST_64BIT
-#define FAST_COPY_UP(shift) \
- for (j = 0; j < length - 3; j += 4) { \
- uint64_t v = AV_RN64A(srcPtr2 + j); \
- AV_WN64A(dstPtr2 + j, v << shift); \
- } \
- length &= 3;
-#else
-#define FAST_COPY_UP(shift) \
- for (j = 0; j < length - 1; j += 2) { \
- uint32_t v = AV_RN32A(srcPtr2 + j); \
- AV_WN32A(dstPtr2 + j, v << shift); \
- } \
- length &= 1;
-#endif
- switch (shift)
- {
- case 6: FAST_COPY_UP(6); break;
- case 7: FAST_COPY_UP(7); break;
- }
- }
-#define COPY_UP(r,w) \
- if(shiftonly){\
- for (j = 0; j < length; j++){ \
- unsigned int v= r(&srcPtr2[j]);\
- w(&dstPtr2[j], v<<(dst_depth-src_depth));\
- }\
- }else{\
- for (j = 0; j < length; j++){ \
- unsigned int v= r(&srcPtr2[j]);\
- w(&dstPtr2[j], (v<<(dst_depth-src_depth)) | \
- (v>>(2*src_depth-dst_depth)));\
- }\
- }
- if(isBE(c->srcFormat)){
- if(isBE(c->dstFormat)){
- COPY_UP(AV_RB16, AV_WB16)
- } else {
- COPY_UP(AV_RB16, AV_WL16)
- }
- } else {
- if(isBE(c->dstFormat)){
- COPY_UP(AV_RL16, AV_WB16)
- } else {
- COPY_UP(AV_RL16, AV_WL16)
- }
- }
- dstPtr2 += dstStride[plane]/2;
- srcPtr2 += srcStride[plane]/2;
- }
- } else {
- if(isBE(c->srcFormat) == HAVE_BIGENDIAN){
- if(isBE(c->dstFormat) == HAVE_BIGENDIAN){
- DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, , )
- } else {
- DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, , av_bswap16)
- }
- }else{
- if(isBE(c->dstFormat) == HAVE_BIGENDIAN){
- DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, av_bswap16, )
- } else {
- DITHER_COPY(dstPtr2, dstStride[plane]/2, srcPtr2, srcStride[plane]/2, av_bswap16, av_bswap16)
- }
- }
- }
- } else if (is16BPS(c->srcFormat) && is16BPS(c->dstFormat) &&
- isBE(c->srcFormat) != isBE(c->dstFormat)) {
-
- for (i = 0; i < height; i++) {
- for (j = 0; j < length; j++)
- ((uint16_t *) dstPtr)[j] = av_bswap16(((const uint16_t *) srcPtr)[j]);
- srcPtr += srcStride[plane];
- dstPtr += dstStride[plane];
- }
- } else if (dstStride[plane] == srcStride[plane] &&
- srcStride[plane] > 0 && srcStride[plane] == length) {
- memcpy(dst[plane] + dstStride[plane] * y, src[plane],
- height * dstStride[plane]);
- } else {
- if (is16BPS(c->srcFormat) && is16BPS(c->dstFormat))
- length *= 2;
- else if (!desc_src->comp[0].depth_minus1)
- length >>= 3; // monowhite/black
- for (i = 0; i < height; i++) {
- memcpy(dstPtr, srcPtr, length);
- srcPtr += srcStride[plane];
- dstPtr += dstStride[plane];
- }
- }
- }
- }
- return srcSliceH;
-}
-
-
-#define IS_DIFFERENT_ENDIANESS(src_fmt, dst_fmt, pix_fmt) \
- ((src_fmt == pix_fmt ## BE && dst_fmt == pix_fmt ## LE) || \
- (src_fmt == pix_fmt ## LE && dst_fmt == pix_fmt ## BE))
-
-
-void ff_get_unscaled_swscale(SwsContext *c)
-{
- const enum AVPixelFormat srcFormat = c->srcFormat;
- const enum AVPixelFormat dstFormat = c->dstFormat;
- const int flags = c->flags;
- const int dstH = c->dstH;
- int needsDither;
-
- needsDither = isAnyRGB(dstFormat) &&
- c->dstFormatBpp < 24 &&
- (c->dstFormatBpp < c->srcFormatBpp || (!isAnyRGB(srcFormat)));
-
- /* yv12_to_nv12 */
- if ((srcFormat == AV_PIX_FMT_YUV420P || srcFormat == AV_PIX_FMT_YUVA420P) &&
- (dstFormat == AV_PIX_FMT_NV12 || dstFormat == AV_PIX_FMT_NV21)) {
- c->swScale = planarToNv12Wrapper;
- }
- /* yuv2bgr */
- if ((srcFormat == AV_PIX_FMT_YUV420P || srcFormat == AV_PIX_FMT_YUV422P ||
- srcFormat == AV_PIX_FMT_YUVA420P) && isAnyRGB(dstFormat) &&
- !(flags & (SWS_ACCURATE_RND|SWS_ERROR_DIFFUSION)) && !(dstH & 1)) {
- c->swScale = ff_yuv2rgb_get_func_ptr(c);
- }
-
- if (srcFormat == AV_PIX_FMT_YUV410P &&
- (dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P) &&
- !(flags & SWS_BITEXACT)) {
- c->swScale = yvu9ToYv12Wrapper;
- }
-
- /* bgr24toYV12 */
- if (srcFormat == AV_PIX_FMT_BGR24 &&
- (dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P) &&
- !(flags & SWS_ACCURATE_RND))
- c->swScale = bgr24ToYv12Wrapper;
-
- /* RGB/BGR -> RGB/BGR (no dither needed forms) */
- if (isAnyRGB(srcFormat) && isAnyRGB(dstFormat) && findRgbConvFn(c)
- && (!needsDither || (c->flags&(SWS_FAST_BILINEAR|SWS_POINT))))
- c->swScale= rgbToRgbWrapper;
-
-#define isByteRGB(f) ( \
- f == AV_PIX_FMT_RGB32 || \
- f == AV_PIX_FMT_RGB32_1 || \
- f == AV_PIX_FMT_RGB24 || \
- f == AV_PIX_FMT_BGR32 || \
- f == AV_PIX_FMT_BGR32_1 || \
- f == AV_PIX_FMT_BGR24)
-
- if (srcFormat == AV_PIX_FMT_GBRP && isPlanar(srcFormat) && isByteRGB(dstFormat))
- c->swScale = planarRgbToRgbWrapper;
-
- /* bswap 16 bits per pixel/component packed formats */
- if (IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR444) ||
- IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR48) ||
- IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGRA64) ||
- IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR555) ||
- IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_BGR565) ||
- IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_GRAY16) ||
- IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB444) ||
- IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB48) ||
- IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGBA64) ||
- IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB555) ||
- IS_DIFFERENT_ENDIANESS(srcFormat, dstFormat, AV_PIX_FMT_RGB565))
- c->swScale = packed_16bpc_bswap;
-
- if (usePal(srcFormat) && isByteRGB(dstFormat))
- c->swScale = palToRgbWrapper;
-
- if (srcFormat == AV_PIX_FMT_YUV422P) {
- if (dstFormat == AV_PIX_FMT_YUYV422)
- c->swScale = yuv422pToYuy2Wrapper;
- else if (dstFormat == AV_PIX_FMT_UYVY422)
- c->swScale = yuv422pToUyvyWrapper;
- }
-
- /* LQ converters if -sws 0 or -sws 4*/
- if (c->flags&(SWS_FAST_BILINEAR|SWS_POINT)) {
- /* yv12_to_yuy2 */
- if (srcFormat == AV_PIX_FMT_YUV420P || srcFormat == AV_PIX_FMT_YUVA420P) {
- if (dstFormat == AV_PIX_FMT_YUYV422)
- c->swScale = planarToYuy2Wrapper;
- else if (dstFormat == AV_PIX_FMT_UYVY422)
- c->swScale = planarToUyvyWrapper;
- }
- }
- if (srcFormat == AV_PIX_FMT_YUYV422 &&
- (dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P))
- c->swScale = yuyvToYuv420Wrapper;
- if (srcFormat == AV_PIX_FMT_UYVY422 &&
- (dstFormat == AV_PIX_FMT_YUV420P || dstFormat == AV_PIX_FMT_YUVA420P))
- c->swScale = uyvyToYuv420Wrapper;
- if (srcFormat == AV_PIX_FMT_YUYV422 && dstFormat == AV_PIX_FMT_YUV422P)
- c->swScale = yuyvToYuv422Wrapper;
- if (srcFormat == AV_PIX_FMT_UYVY422 && dstFormat == AV_PIX_FMT_YUV422P)
- c->swScale = uyvyToYuv422Wrapper;
-
-#define isPlanarGray(x) (isGray(x) && (x) != AV_PIX_FMT_GRAY8A)
- /* simple copy */
- if ( srcFormat == dstFormat ||
- (srcFormat == AV_PIX_FMT_YUVA420P && dstFormat == AV_PIX_FMT_YUV420P) ||
- (srcFormat == AV_PIX_FMT_YUV420P && dstFormat == AV_PIX_FMT_YUVA420P) ||
- (isPlanarYUV(srcFormat) && isPlanarGray(dstFormat)) ||
- (isPlanarYUV(dstFormat) && isPlanarGray(srcFormat)) ||
- (isPlanarGray(dstFormat) && isPlanarGray(srcFormat)) ||
- (isPlanarYUV(srcFormat) && isPlanarYUV(dstFormat) &&
- c->chrDstHSubSample == c->chrSrcHSubSample &&
- c->chrDstVSubSample == c->chrSrcVSubSample &&
- dstFormat != AV_PIX_FMT_NV12 && dstFormat != AV_PIX_FMT_NV21 &&
- srcFormat != AV_PIX_FMT_NV12 && srcFormat != AV_PIX_FMT_NV21))
- {
- if (isPacked(c->srcFormat))
- c->swScale = packedCopyWrapper;
- else /* Planar YUV or gray */
- c->swScale = planarCopyWrapper;
- }
-
- if (ARCH_BFIN)
- ff_bfin_get_unscaled_swscale(c);
- if (HAVE_ALTIVEC)
- ff_swscale_get_unscaled_altivec(c);
-}
-
-/* Convert the palette to the same packed 32-bit format as the palette */
-void sws_convertPalette8ToPacked32(const uint8_t *src, uint8_t *dst,
- int num_pixels, const uint8_t *palette)
-{
- int i;
-
- for (i = 0; i < num_pixels; i++)
- ((uint32_t *) dst)[i] = ((const uint32_t *) palette)[src[i]];
-}
-
-/* Palette format: ABCD -> dst format: ABC */
-void sws_convertPalette8ToPacked24(const uint8_t *src, uint8_t *dst,
- int num_pixels, const uint8_t *palette)
-{
- int i;
-
- for (i = 0; i < num_pixels; i++) {
- //FIXME slow?
- dst[0] = palette[src[i] * 4 + 0];
- dst[1] = palette[src[i] * 4 + 1];
- dst[2] = palette[src[i] * 4 + 2];
- dst += 3;
- }
-}
diff --git a/src/thirdparty/ffmpeg/libswscale/utils.c b/src/thirdparty/ffmpeg/libswscale/utils.c
deleted file mode 100644
index a5a7977c8..000000000
--- a/src/thirdparty/ffmpeg/libswscale/utils.c
+++ /dev/null
@@ -1,1882 +0,0 @@
-/*
- * Copyright (C) 2001-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
- */
-
-#include "config.h"
-
-#define _SVID_SOURCE // needed for MAP_ANONYMOUS
-#define _DARWIN_C_SOURCE // needed for MAP_ANON
-#include <inttypes.h>
-#include <math.h>
-#include <stdio.h>
-#include <string.h>
-#if HAVE_SYS_MMAN_H
-#include <sys/mman.h>
-#if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
-#define MAP_ANONYMOUS MAP_ANON
-#endif
-#endif
-#if HAVE_VIRTUALALLOC
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#endif
-
-#include "libavutil/attributes.h"
-#include "libavutil/avassert.h"
-#include "libavutil/avutil.h"
-#include "libavutil/bswap.h"
-#include "libavutil/cpu.h"
-#include "libavutil/intreadwrite.h"
-#include "libavutil/mathematics.h"
-#include "libavutil/opt.h"
-#include "libavutil/pixdesc.h"
-#include "libavutil/x86/asm.h"
-#include "libavutil/x86/cpu.h"
-#include "rgb2rgb.h"
-#include "swscale.h"
-#include "swscale_internal.h"
-
-unsigned swscale_version(void)
-{
- av_assert0(LIBSWSCALE_VERSION_MICRO >= 100);
- return LIBSWSCALE_VERSION_INT;
-}
-
-const char *swscale_configuration(void)
-{
- return FFMPEG_CONFIGURATION;
-}
-
-const char *swscale_license(void)
-{
-#define LICENSE_PREFIX "libswscale license: "
- return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1;
-}
-
-#define RET 0xC3 // near return opcode for x86
-
-typedef struct FormatEntry {
- int is_supported_in, is_supported_out;
-} FormatEntry;
-
-static const FormatEntry format_entries[AV_PIX_FMT_NB] = {
- [AV_PIX_FMT_YUV420P] = { 1, 1 },
- [AV_PIX_FMT_YUYV422] = { 1, 1 },
- [AV_PIX_FMT_RGB24] = { 1, 1 },
- [AV_PIX_FMT_BGR24] = { 1, 1 },
- [AV_PIX_FMT_YUV422P] = { 1, 1 },
- [AV_PIX_FMT_YUV444P] = { 1, 1 },
- [AV_PIX_FMT_YUV410P] = { 1, 1 },
- [AV_PIX_FMT_YUV411P] = { 1, 1 },
- [AV_PIX_FMT_GRAY8] = { 1, 1 },
- [AV_PIX_FMT_MONOWHITE] = { 1, 1 },
- [AV_PIX_FMT_MONOBLACK] = { 1, 1 },
- [AV_PIX_FMT_PAL8] = { 1, 0 },
- [AV_PIX_FMT_YUVJ420P] = { 1, 1 },
- [AV_PIX_FMT_YUVJ422P] = { 1, 1 },
- [AV_PIX_FMT_YUVJ444P] = { 1, 1 },
- [AV_PIX_FMT_UYVY422] = { 1, 1 },
- [AV_PIX_FMT_UYYVYY411] = { 0, 0 },
- [AV_PIX_FMT_BGR8] = { 1, 1 },
- [AV_PIX_FMT_BGR4] = { 0, 1 },
- [AV_PIX_FMT_BGR4_BYTE] = { 1, 1 },
- [AV_PIX_FMT_RGB8] = { 1, 1 },
- [AV_PIX_FMT_RGB4] = { 0, 1 },
- [AV_PIX_FMT_RGB4_BYTE] = { 1, 1 },
- [AV_PIX_FMT_NV12] = { 1, 1 },
- [AV_PIX_FMT_NV21] = { 1, 1 },
- [AV_PIX_FMT_ARGB] = { 1, 1 },
- [AV_PIX_FMT_RGBA] = { 1, 1 },
- [AV_PIX_FMT_ABGR] = { 1, 1 },
- [AV_PIX_FMT_BGRA] = { 1, 1 },
- [AV_PIX_FMT_0RGB] = { 1, 1 },
- [AV_PIX_FMT_RGB0] = { 1, 1 },
- [AV_PIX_FMT_0BGR] = { 1, 1 },
- [AV_PIX_FMT_BGR0] = { 1, 1 },
- [AV_PIX_FMT_GRAY16BE] = { 1, 1 },
- [AV_PIX_FMT_GRAY16LE] = { 1, 1 },
- [AV_PIX_FMT_YUV440P] = { 1, 1 },
- [AV_PIX_FMT_YUVJ440P] = { 1, 1 },
- [AV_PIX_FMT_YUVA420P] = { 1, 1 },
- [AV_PIX_FMT_YUVA422P] = { 1, 1 },
- [AV_PIX_FMT_YUVA444P] = { 1, 1 },
- [AV_PIX_FMT_YUVA420P9BE] = { 1, 1 },
- [AV_PIX_FMT_YUVA420P9LE] = { 1, 1 },
- [AV_PIX_FMT_YUVA422P9BE] = { 1, 1 },
- [AV_PIX_FMT_YUVA422P9LE] = { 1, 1 },
- [AV_PIX_FMT_YUVA444P9BE] = { 1, 1 },
- [AV_PIX_FMT_YUVA444P9LE] = { 1, 1 },
- [AV_PIX_FMT_YUVA420P10BE]= { 1, 1 },
- [AV_PIX_FMT_YUVA420P10LE]= { 1, 1 },
- [AV_PIX_FMT_YUVA422P10BE]= { 1, 1 },
- [AV_PIX_FMT_YUVA422P10LE]= { 1, 1 },
- [AV_PIX_FMT_YUVA444P10BE]= { 1, 1 },
- [AV_PIX_FMT_YUVA444P10LE]= { 1, 1 },
- [AV_PIX_FMT_YUVA420P16BE]= { 1, 1 },
- [AV_PIX_FMT_YUVA420P16LE]= { 1, 1 },
- [AV_PIX_FMT_YUVA422P16BE]= { 1, 1 },
- [AV_PIX_FMT_YUVA422P16LE]= { 1, 1 },
- [AV_PIX_FMT_YUVA444P16BE]= { 1, 1 },
- [AV_PIX_FMT_YUVA444P16LE]= { 1, 1 },
- [AV_PIX_FMT_RGB48BE] = { 1, 1 },
- [AV_PIX_FMT_RGB48LE] = { 1, 1 },
- [AV_PIX_FMT_RGBA64BE] = { 1, 0 },
- [AV_PIX_FMT_RGBA64LE] = { 1, 0 },
- [AV_PIX_FMT_RGB565BE] = { 1, 1 },
- [AV_PIX_FMT_RGB565LE] = { 1, 1 },
- [AV_PIX_FMT_RGB555BE] = { 1, 1 },
- [AV_PIX_FMT_RGB555LE] = { 1, 1 },
- [AV_PIX_FMT_BGR565BE] = { 1, 1 },
- [AV_PIX_FMT_BGR565LE] = { 1, 1 },
- [AV_PIX_FMT_BGR555BE] = { 1, 1 },
- [AV_PIX_FMT_BGR555LE] = { 1, 1 },
- [AV_PIX_FMT_YUV420P16LE] = { 1, 1 },
- [AV_PIX_FMT_YUV420P16BE] = { 1, 1 },
- [AV_PIX_FMT_YUV422P16LE] = { 1, 1 },
- [AV_PIX_FMT_YUV422P16BE] = { 1, 1 },
- [AV_PIX_FMT_YUV444P16LE] = { 1, 1 },
- [AV_PIX_FMT_YUV444P16BE] = { 1, 1 },
- [AV_PIX_FMT_RGB444LE] = { 1, 1 },
- [AV_PIX_FMT_RGB444BE] = { 1, 1 },
- [AV_PIX_FMT_BGR444LE] = { 1, 1 },
- [AV_PIX_FMT_BGR444BE] = { 1, 1 },
- [AV_PIX_FMT_Y400A] = { 1, 0 },
- [AV_PIX_FMT_BGR48BE] = { 1, 1 },
- [AV_PIX_FMT_BGR48LE] = { 1, 1 },
- [AV_PIX_FMT_BGRA64BE] = { 0, 0 },
- [AV_PIX_FMT_BGRA64LE] = { 0, 0 },
- [AV_PIX_FMT_YUV420P9BE] = { 1, 1 },
- [AV_PIX_FMT_YUV420P9LE] = { 1, 1 },
- [AV_PIX_FMT_YUV420P10BE] = { 1, 1 },
- [AV_PIX_FMT_YUV420P10LE] = { 1, 1 },
- [AV_PIX_FMT_YUV420P12BE] = { 1, 1 },
- [AV_PIX_FMT_YUV420P12LE] = { 1, 1 },
- [AV_PIX_FMT_YUV420P14BE] = { 1, 1 },
- [AV_PIX_FMT_YUV420P14LE] = { 1, 1 },
- [AV_PIX_FMT_YUV422P9BE] = { 1, 1 },
- [AV_PIX_FMT_YUV422P9LE] = { 1, 1 },
- [AV_PIX_FMT_YUV422P10BE] = { 1, 1 },
- [AV_PIX_FMT_YUV422P10LE] = { 1, 1 },
- [AV_PIX_FMT_YUV422P12BE] = { 1, 1 },
- [AV_PIX_FMT_YUV422P12LE] = { 1, 1 },
- [AV_PIX_FMT_YUV422P14BE] = { 1, 1 },
- [AV_PIX_FMT_YUV422P14LE] = { 1, 1 },
- [AV_PIX_FMT_YUV444P9BE] = { 1, 1 },
- [AV_PIX_FMT_YUV444P9LE] = { 1, 1 },
- [AV_PIX_FMT_YUV444P10BE] = { 1, 1 },
- [AV_PIX_FMT_YUV444P10LE] = { 1, 1 },
- [AV_PIX_FMT_YUV444P12BE] = { 1, 1 },
- [AV_PIX_FMT_YUV444P12LE] = { 1, 1 },
- [AV_PIX_FMT_YUV444P14BE] = { 1, 1 },
- [AV_PIX_FMT_YUV444P14LE] = { 1, 1 },
- [AV_PIX_FMT_GBRP] = { 1, 1 },
- [AV_PIX_FMT_GBRP9LE] = { 1, 1 },
- [AV_PIX_FMT_GBRP9BE] = { 1, 1 },
- [AV_PIX_FMT_GBRP10LE] = { 1, 1 },
- [AV_PIX_FMT_GBRP10BE] = { 1, 1 },
- [AV_PIX_FMT_GBRP12LE] = { 1, 1 },
- [AV_PIX_FMT_GBRP12BE] = { 1, 1 },
- [AV_PIX_FMT_GBRP14LE] = { 1, 1 },
- [AV_PIX_FMT_GBRP14BE] = { 1, 1 },
- [AV_PIX_FMT_GBRP16LE] = { 1, 0 },
- [AV_PIX_FMT_GBRP16BE] = { 1, 0 },
-};
-
-int sws_isSupportedInput(enum AVPixelFormat pix_fmt)
-{
- return (unsigned)pix_fmt < AV_PIX_FMT_NB ?
- format_entries[pix_fmt].is_supported_in : 0;
-}
-
-int sws_isSupportedOutput(enum AVPixelFormat pix_fmt)
-{
- return (unsigned)pix_fmt < AV_PIX_FMT_NB ?
- format_entries[pix_fmt].is_supported_out : 0;
-}
-
-extern const int32_t ff_yuv2rgb_coeffs[8][4];
-
-#if FF_API_SWS_FORMAT_NAME
-const char *sws_format_name(enum AVPixelFormat format)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(format);
- if (desc)
- return desc->name;
- else
- return "Unknown format";
-}
-#endif
-
-static double getSplineCoeff(double a, double b, double c, double d,
- double dist)
-{
- if (dist <= 1.0)
- return ((d * dist + c) * dist + b) * dist + a;
- else
- return getSplineCoeff(0.0,
- b + 2.0 * c + 3.0 * d,
- c + 3.0 * d,
- -b - 3.0 * c - 6.0 * d,
- dist - 1.0);
-}
-
-static int initFilter(int16_t **outFilter, int32_t **filterPos,
- int *outFilterSize, int xInc, int srcW, int dstW,
- int filterAlign, int one, int flags, int cpu_flags,
- SwsVector *srcFilter, SwsVector *dstFilter,
- double param[2])
-{
- int i;
- int filterSize;
- int filter2Size;
- int minFilterSize;
- int64_t *filter = NULL;
- int64_t *filter2 = NULL;
- const int64_t fone = 1LL << (54 - FFMIN(av_log2(srcW/dstW), 8));
- int ret = -1;
-
- emms_c(); // FIXME should not be required but IS (even for non-MMX versions)
-
- // NOTE: the +3 is for the MMX(+1) / SSE(+3) scaler which reads over the end
- FF_ALLOC_OR_GOTO(NULL, *filterPos, (dstW + 3) * sizeof(**filterPos), fail);
-
- if (FFABS(xInc - 0x10000) < 10) { // unscaled
- int i;
- filterSize = 1;
- FF_ALLOCZ_OR_GOTO(NULL, filter,
- dstW * sizeof(*filter) * filterSize, fail);
-
- for (i = 0; i < dstW; i++) {
- filter[i * filterSize] = fone;
- (*filterPos)[i] = i;
- }
- } else if (flags & SWS_POINT) { // lame looking point sampling mode
- int i;
- int64_t xDstInSrc;
- filterSize = 1;
- FF_ALLOC_OR_GOTO(NULL, filter,
- dstW * sizeof(*filter) * filterSize, fail);
-
- xDstInSrc = xInc / 2 - 0x8000;
- for (i = 0; i < dstW; i++) {
- int xx = (xDstInSrc - ((filterSize - 1) << 15) + (1 << 15)) >> 16;
-
- (*filterPos)[i] = xx;
- filter[i] = fone;
- xDstInSrc += xInc;
- }
- } else if ((xInc <= (1 << 16) && (flags & SWS_AREA)) ||
- (flags & SWS_FAST_BILINEAR)) { // bilinear upscale
- int i;
- int64_t xDstInSrc;
- filterSize = 2;
- FF_ALLOC_OR_GOTO(NULL, filter,
- dstW * sizeof(*filter) * filterSize, fail);
-
- xDstInSrc = xInc / 2 - 0x8000;
- for (i = 0; i < dstW; i++) {
- int xx = (xDstInSrc - ((filterSize - 1) << 15) + (1 << 15)) >> 16;
- int j;
-
- (*filterPos)[i] = xx;
- // bilinear upscale / linear interpolate / area averaging
- for (j = 0; j < filterSize; j++) {
- int64_t coeff= fone - FFABS(((int64_t)xx<<16) - xDstInSrc)*(fone>>16);
- if (coeff < 0)
- coeff = 0;
- filter[i * filterSize + j] = coeff;
- xx++;
- }
- xDstInSrc += xInc;
- }
- } else {
- int64_t xDstInSrc;
- int sizeFactor;
-
- if (flags & SWS_BICUBIC)
- sizeFactor = 4;
- else if (flags & SWS_X)
- sizeFactor = 8;
- else if (flags & SWS_AREA)
- sizeFactor = 1; // downscale only, for upscale it is bilinear
- else if (flags & SWS_GAUSS)
- sizeFactor = 8; // infinite ;)
- else if (flags & SWS_LANCZOS)
- sizeFactor = param[0] != SWS_PARAM_DEFAULT ? ceil(2 * param[0]) : 6;
- else if (flags & SWS_SINC)
- sizeFactor = 20; // infinite ;)
- else if (flags & SWS_SPLINE)
- sizeFactor = 20; // infinite ;)
- else if (flags & SWS_BILINEAR)
- sizeFactor = 2;
- else {
- av_assert0(0);
- }
-
- if (xInc <= 1 << 16)
- filterSize = 1 + sizeFactor; // upscale
- else
- filterSize = 1 + (sizeFactor * srcW + dstW - 1) / dstW;
-
- filterSize = FFMIN(filterSize, srcW - 2);
- filterSize = FFMAX(filterSize, 1);
-
- FF_ALLOC_OR_GOTO(NULL, filter,
- dstW * sizeof(*filter) * filterSize, fail);
-
- xDstInSrc = xInc - 0x10000;
- for (i = 0; i < dstW; i++) {
- int xx = (xDstInSrc - ((filterSize - 2) << 16)) / (1 << 17);
- int j;
- (*filterPos)[i] = xx;
- for (j = 0; j < filterSize; j++) {
- int64_t d = (FFABS(((int64_t)xx << 17) - xDstInSrc)) << 13;
- double floatd;
- int64_t coeff;
-
- if (xInc > 1 << 16)
- d = d * dstW / srcW;
- floatd = d * (1.0 / (1 << 30));
-
- if (flags & SWS_BICUBIC) {
- int64_t B = (param[0] != SWS_PARAM_DEFAULT ? param[0] : 0) * (1 << 24);
- int64_t C = (param[1] != SWS_PARAM_DEFAULT ? param[1] : 0.6) * (1 << 24);
-
- if (d >= 1LL << 31) {
- coeff = 0.0;
- } else {
- int64_t dd = (d * d) >> 30;
- int64_t ddd = (dd * d) >> 30;
-
- if (d < 1LL << 30)
- coeff = (12 * (1 << 24) - 9 * B - 6 * C) * ddd +
- (-18 * (1 << 24) + 12 * B + 6 * C) * dd +
- (6 * (1 << 24) - 2 * B) * (1 << 30);
- else
- coeff = (-B - 6 * C) * ddd +
- (6 * B + 30 * C) * dd +
- (-12 * B - 48 * C) * d +
- (8 * B + 24 * C) * (1 << 30);
- }
- coeff /= (1LL<<54)/fone;
- }
-#if 0
- else if (flags & SWS_X) {
- double p = param ? param * 0.01 : 0.3;
- coeff = d ? sin(d * M_PI) / (d * M_PI) : 1.0;
- coeff *= pow(2.0, -p * d * d);
- }
-#endif
- else if (flags & SWS_X) {
- double A = param[0] != SWS_PARAM_DEFAULT ? param[0] : 1.0;
- double c;
-
- if (floatd < 1.0)
- c = cos(floatd * M_PI);
- else
- c = -1.0;
- if (c < 0.0)
- c = -pow(-c, A);
- else
- c = pow(c, A);
- coeff = (c * 0.5 + 0.5) * fone;
- } else if (flags & SWS_AREA) {
- int64_t d2 = d - (1 << 29);
- if (d2 * xInc < -(1LL << (29 + 16)))
- coeff = 1.0 * (1LL << (30 + 16));
- else if (d2 * xInc < (1LL << (29 + 16)))
- coeff = -d2 * xInc + (1LL << (29 + 16));
- else
- coeff = 0.0;
- coeff *= fone >> (30 + 16);
- } else if (flags & SWS_GAUSS) {
- double p = param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0;
- coeff = (pow(2.0, -p * floatd * floatd)) * fone;
- } else if (flags & SWS_SINC) {
- coeff = (d ? sin(floatd * M_PI) / (floatd * M_PI) : 1.0) * fone;
- } else if (flags & SWS_LANCZOS) {
- double p = param[0] != SWS_PARAM_DEFAULT ? param[0] : 3.0;
- coeff = (d ? sin(floatd * M_PI) * sin(floatd * M_PI / p) /
- (floatd * floatd * M_PI * M_PI / p) : 1.0) * fone;
- if (floatd > p)
- coeff = 0;
- } else if (flags & SWS_BILINEAR) {
- coeff = (1 << 30) - d;
- if (coeff < 0)
- coeff = 0;
- coeff *= fone >> 30;
- } else if (flags & SWS_SPLINE) {
- double p = -2.196152422706632;
- coeff = getSplineCoeff(1.0, 0.0, p, -p - 1.0, floatd) * fone;
- } else {
- av_assert0(0);
- }
-
- filter[i * filterSize + j] = coeff;
- xx++;
- }
- xDstInSrc += 2 * xInc;
- }
- }
-
- /* apply src & dst Filter to filter -> filter2
- * av_free(filter);
- */
- av_assert0(filterSize > 0);
- filter2Size = filterSize;
- if (srcFilter)
- filter2Size += srcFilter->length - 1;
- if (dstFilter)
- filter2Size += dstFilter->length - 1;
- av_assert0(filter2Size > 0);
- FF_ALLOCZ_OR_GOTO(NULL, filter2, filter2Size * dstW * sizeof(*filter2), fail);
-
- for (i = 0; i < dstW; i++) {
- int j, k;
-
- if (srcFilter) {
- for (k = 0; k < srcFilter->length; k++) {
- for (j = 0; j < filterSize; j++)
- filter2[i * filter2Size + k + j] +=
- srcFilter->coeff[k] * filter[i * filterSize + j];
- }
- } else {
- for (j = 0; j < filterSize; j++)
- filter2[i * filter2Size + j] = filter[i * filterSize + j];
- }
- // FIXME dstFilter
-
- (*filterPos)[i] += (filterSize - 1) / 2 - (filter2Size - 1) / 2;
- }
- av_freep(&filter);
-
- /* try to reduce the filter-size (step1 find size and shift left) */
- // Assume it is near normalized (*0.5 or *2.0 is OK but * 0.001 is not).
- minFilterSize = 0;
- for (i = dstW - 1; i >= 0; i--) {
- int min = filter2Size;
- int j;
- int64_t cutOff = 0.0;
-
- /* get rid of near zero elements on the left by shifting left */
- for (j = 0; j < filter2Size; j++) {
- int k;
- cutOff += FFABS(filter2[i * filter2Size]);
-
- if (cutOff > SWS_MAX_REDUCE_CUTOFF * fone)
- break;
-
- /* preserve monotonicity because the core can't handle the
- * filter otherwise */
- if (i < dstW - 1 && (*filterPos)[i] >= (*filterPos)[i + 1])
- break;
-
- // move filter coefficients left
- for (k = 1; k < filter2Size; k++)
- filter2[i * filter2Size + k - 1] = filter2[i * filter2Size + k];
- filter2[i * filter2Size + k - 1] = 0;
- (*filterPos)[i]++;
- }
-
- cutOff = 0;
- /* count near zeros on the right */
- for (j = filter2Size - 1; j > 0; j--) {
- cutOff += FFABS(filter2[i * filter2Size + j]);
-
- if (cutOff > SWS_MAX_REDUCE_CUTOFF * fone)
- break;
- min--;
- }
-
- if (min > minFilterSize)
- minFilterSize = min;
- }
-
- if (HAVE_ALTIVEC && cpu_flags & AV_CPU_FLAG_ALTIVEC) {
- // we can handle the special case 4, so we don't want to go the full 8
- if (minFilterSize < 5)
- filterAlign = 4;
-
- /* We really don't want to waste our time doing useless computation, so
- * fall back on the scalar C code for very small filters.
- * Vectorizing is worth it only if you have a decent-sized vector. */
- if (minFilterSize < 3)
- filterAlign = 1;
- }
-
- if (INLINE_MMX(cpu_flags)) {
- // special case for unscaled vertical filtering
- if (minFilterSize == 1 && filterAlign == 2)
- filterAlign = 1;
- }
-
- av_assert0(minFilterSize > 0);
- filterSize = (minFilterSize + (filterAlign - 1)) & (~(filterAlign - 1));
- av_assert0(filterSize > 0);
- filter = av_malloc(filterSize * dstW * sizeof(*filter));
- if (filterSize >= MAX_FILTER_SIZE * 16 /
- ((flags & SWS_ACCURATE_RND) ? APCK_SIZE : 16) || !filter) {
- av_log(NULL, AV_LOG_ERROR, "sws: filterSize %d is too large, try less extreem scaling or increase MAX_FILTER_SIZE and recompile\n", filterSize);
- goto fail;
- }
- *outFilterSize = filterSize;
-
- if (flags & SWS_PRINT_INFO)
- av_log(NULL, AV_LOG_VERBOSE,
- "SwScaler: reducing / aligning filtersize %d -> %d\n",
- filter2Size, filterSize);
- /* try to reduce the filter-size (step2 reduce it) */
- for (i = 0; i < dstW; i++) {
- int j;
-
- for (j = 0; j < filterSize; j++) {
- if (j >= filter2Size)
- filter[i * filterSize + j] = 0;
- else
- filter[i * filterSize + j] = filter2[i * filter2Size + j];
- if ((flags & SWS_BITEXACT) && j >= minFilterSize)
- filter[i * filterSize + j] = 0;
- }
- }
-
- // FIXME try to align filterPos if possible
-
- // fix borders
- for (i = 0; i < dstW; i++) {
- int j;
- if ((*filterPos)[i] < 0) {
- // move filter coefficients left to compensate for filterPos
- for (j = 1; j < filterSize; j++) {
- int left = FFMAX(j + (*filterPos)[i], 0);
- filter[i * filterSize + left] += filter[i * filterSize + j];
- filter[i * filterSize + j] = 0;
- }
- (*filterPos)[i]= 0;
- }
-
- if ((*filterPos)[i] + filterSize > srcW) {
- int shift = (*filterPos)[i] + filterSize - srcW;
- // move filter coefficients right to compensate for filterPos
- for (j = filterSize - 2; j >= 0; j--) {
- int right = FFMIN(j + shift, filterSize - 1);
- filter[i * filterSize + right] += filter[i * filterSize + j];
- filter[i * filterSize + j] = 0;
- }
- (*filterPos)[i]= srcW - filterSize;
- }
- }
-
- // Note the +1 is for the MMX scaler which reads over the end
- /* align at 16 for AltiVec (needed by hScale_altivec_real) */
- FF_ALLOCZ_OR_GOTO(NULL, *outFilter,
- *outFilterSize * (dstW + 3) * sizeof(int16_t), fail);
-
- /* normalize & store in outFilter */
- for (i = 0; i < dstW; i++) {
- int j;
- int64_t error = 0;
- int64_t sum = 0;
-
- for (j = 0; j < filterSize; j++) {
- sum += filter[i * filterSize + j];
- }
- sum = (sum + one / 2) / one;
- for (j = 0; j < *outFilterSize; j++) {
- int64_t v = filter[i * filterSize + j] + error;
- int intV = ROUNDED_DIV(v, sum);
- (*outFilter)[i * (*outFilterSize) + j] = intV;
- error = v - intV * sum;
- }
- }
-
- (*filterPos)[dstW + 0] =
- (*filterPos)[dstW + 1] =
- (*filterPos)[dstW + 2] = (*filterPos)[dstW - 1]; /* the MMX/SSE scaler will
- * read over the end */
- for (i = 0; i < *outFilterSize; i++) {
- int k = (dstW - 1) * (*outFilterSize) + i;
- (*outFilter)[k + 1 * (*outFilterSize)] =
- (*outFilter)[k + 2 * (*outFilterSize)] =
- (*outFilter)[k + 3 * (*outFilterSize)] = (*outFilter)[k];
- }
-
- ret = 0;
-
-fail:
- if(ret < 0)
- av_log(NULL, AV_LOG_ERROR, "sws: initFilter failed\n");
- av_free(filter);
- av_free(filter2);
- return ret;
-}
-
-#if HAVE_MMXEXT_INLINE
-static int init_hscaler_mmxext(int dstW, int xInc, uint8_t *filterCode,
- int16_t *filter, int32_t *filterPos,
- int numSplits)
-{
- uint8_t *fragmentA;
- x86_reg imm8OfPShufW1A;
- x86_reg imm8OfPShufW2A;
- x86_reg fragmentLengthA;
- uint8_t *fragmentB;
- x86_reg imm8OfPShufW1B;
- x86_reg imm8OfPShufW2B;
- x86_reg fragmentLengthB;
- int fragmentPos;
-
- int xpos, i;
-
- // create an optimized horizontal scaling routine
- /* This scaler is made of runtime-generated MMXEXT code using specially tuned
- * pshufw instructions. For every four output pixels, if four input pixels
- * are enough for the fast bilinear scaling, then a chunk of fragmentB is
- * used. If five input pixels are needed, then a chunk of fragmentA is used.
- */
-
- // code fragment
-
- __asm__ volatile (
- "jmp 9f \n\t"
- // Begin
- "0: \n\t"
- "movq (%%"REG_d", %%"REG_a"), %%mm3 \n\t"
- "movd (%%"REG_c", %%"REG_S"), %%mm0 \n\t"
- "movd 1(%%"REG_c", %%"REG_S"), %%mm1 \n\t"
- "punpcklbw %%mm7, %%mm1 \n\t"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "pshufw $0xFF, %%mm1, %%mm1 \n\t"
- "1: \n\t"
- "pshufw $0xFF, %%mm0, %%mm0 \n\t"
- "2: \n\t"
- "psubw %%mm1, %%mm0 \n\t"
- "movl 8(%%"REG_b", %%"REG_a"), %%esi \n\t"
- "pmullw %%mm3, %%mm0 \n\t"
- "psllw $7, %%mm1 \n\t"
- "paddw %%mm1, %%mm0 \n\t"
-
- "movq %%mm0, (%%"REG_D", %%"REG_a") \n\t"
-
- "add $8, %%"REG_a" \n\t"
- // End
- "9: \n\t"
- // "int $3 \n\t"
- "lea " LOCAL_MANGLE(0b) ", %0 \n\t"
- "lea " LOCAL_MANGLE(1b) ", %1 \n\t"
- "lea " LOCAL_MANGLE(2b) ", %2 \n\t"
- "dec %1 \n\t"
- "dec %2 \n\t"
- "sub %0, %1 \n\t"
- "sub %0, %2 \n\t"
- "lea " LOCAL_MANGLE(9b) ", %3 \n\t"
- "sub %0, %3 \n\t"
-
-
- : "=r" (fragmentA), "=r" (imm8OfPShufW1A), "=r" (imm8OfPShufW2A),
- "=r" (fragmentLengthA)
- );
-
- __asm__ volatile (
- "jmp 9f \n\t"
- // Begin
- "0: \n\t"
- "movq (%%"REG_d", %%"REG_a"), %%mm3 \n\t"
- "movd (%%"REG_c", %%"REG_S"), %%mm0 \n\t"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "pshufw $0xFF, %%mm0, %%mm1 \n\t"
- "1: \n\t"
- "pshufw $0xFF, %%mm0, %%mm0 \n\t"
- "2: \n\t"
- "psubw %%mm1, %%mm0 \n\t"
- "movl 8(%%"REG_b", %%"REG_a"), %%esi \n\t"
- "pmullw %%mm3, %%mm0 \n\t"
- "psllw $7, %%mm1 \n\t"
- "paddw %%mm1, %%mm0 \n\t"
-
- "movq %%mm0, (%%"REG_D", %%"REG_a") \n\t"
-
- "add $8, %%"REG_a" \n\t"
- // End
- "9: \n\t"
- // "int $3 \n\t"
- "lea " LOCAL_MANGLE(0b) ", %0 \n\t"
- "lea " LOCAL_MANGLE(1b) ", %1 \n\t"
- "lea " LOCAL_MANGLE(2b) ", %2 \n\t"
- "dec %1 \n\t"
- "dec %2 \n\t"
- "sub %0, %1 \n\t"
- "sub %0, %2 \n\t"
- "lea " LOCAL_MANGLE(9b) ", %3 \n\t"
- "sub %0, %3 \n\t"
-
-
- : "=r" (fragmentB), "=r" (imm8OfPShufW1B), "=r" (imm8OfPShufW2B),
- "=r" (fragmentLengthB)
- );
-
- xpos = 0; // lumXInc/2 - 0x8000; // difference between pixel centers
- fragmentPos = 0;
-
- for (i = 0; i < dstW / numSplits; i++) {
- int xx = xpos >> 16;
-
- if ((i & 3) == 0) {
- int a = 0;
- int b = ((xpos + xInc) >> 16) - xx;
- int c = ((xpos + xInc * 2) >> 16) - xx;
- int d = ((xpos + xInc * 3) >> 16) - xx;
- int inc = (d + 1 < 4);
- uint8_t *fragment = (d + 1 < 4) ? fragmentB : fragmentA;
- x86_reg imm8OfPShufW1 = (d + 1 < 4) ? imm8OfPShufW1B : imm8OfPShufW1A;
- x86_reg imm8OfPShufW2 = (d + 1 < 4) ? imm8OfPShufW2B : imm8OfPShufW2A;
- x86_reg fragmentLength = (d + 1 < 4) ? fragmentLengthB : fragmentLengthA;
- int maxShift = 3 - (d + inc);
- int shift = 0;
-
- if (filterCode) {
- filter[i] = ((xpos & 0xFFFF) ^ 0xFFFF) >> 9;
- filter[i + 1] = (((xpos + xInc) & 0xFFFF) ^ 0xFFFF) >> 9;
- filter[i + 2] = (((xpos + xInc * 2) & 0xFFFF) ^ 0xFFFF) >> 9;
- filter[i + 3] = (((xpos + xInc * 3) & 0xFFFF) ^ 0xFFFF) >> 9;
- filterPos[i / 2] = xx;
-
- memcpy(filterCode + fragmentPos, fragment, fragmentLength);
-
- filterCode[fragmentPos + imm8OfPShufW1] = (a + inc) |
- ((b + inc) << 2) |
- ((c + inc) << 4) |
- ((d + inc) << 6);
- filterCode[fragmentPos + imm8OfPShufW2] = a | (b << 2) |
- (c << 4) |
- (d << 6);
-
- if (i + 4 - inc >= dstW)
- shift = maxShift; // avoid overread
- else if ((filterPos[i / 2] & 3) <= maxShift)
- shift = filterPos[i / 2] & 3; // align
-
- if (shift && i >= shift) {
- filterCode[fragmentPos + imm8OfPShufW1] += 0x55 * shift;
- filterCode[fragmentPos + imm8OfPShufW2] += 0x55 * shift;
- filterPos[i / 2] -= shift;
- }
- }
-
- fragmentPos += fragmentLength;
-
- if (filterCode)
- filterCode[fragmentPos] = RET;
- }
- xpos += xInc;
- }
- if (filterCode)
- filterPos[((i / 2) + 1) & (~1)] = xpos >> 16; // needed to jump to the next part
-
- return fragmentPos + 1;
-}
-#endif /* HAVE_MMXEXT_INLINE */
-
-static void getSubSampleFactors(int *h, int *v, enum AVPixelFormat format)
-{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(format);
- *h = desc->log2_chroma_w;
- *v = desc->log2_chroma_h;
-}
-
-int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
- int srcRange, const int table[4], int dstRange,
- int brightness, int contrast, int saturation)
-{
- const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(c->dstFormat);
- const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(c->srcFormat);
- memcpy(c->srcColorspaceTable, inv_table, sizeof(int) * 4);
- memcpy(c->dstColorspaceTable, table, sizeof(int) * 4);
-
- if(!isYUV(c->dstFormat) && !isGray(c->dstFormat))
- dstRange = 0;
- if(!isYUV(c->srcFormat) && !isGray(c->srcFormat))
- srcRange = 0;
-
- c->brightness = brightness;
- c->contrast = contrast;
- c->saturation = saturation;
- c->srcRange = srcRange;
- c->dstRange = dstRange;
-
- if (isYUV(c->dstFormat) || isGray(c->dstFormat))
- return -1;
-
- c->dstFormatBpp = av_get_bits_per_pixel(desc_dst);
- c->srcFormatBpp = av_get_bits_per_pixel(desc_src);
-
- ff_yuv2rgb_c_init_tables(c, inv_table, srcRange, brightness,
- contrast, saturation);
- // FIXME factorize
-
- if (HAVE_ALTIVEC && av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)
- ff_yuv2rgb_init_tables_altivec(c, inv_table, brightness,
- contrast, saturation);
- return 0;
-}
-
-int sws_getColorspaceDetails(struct SwsContext *c, int **inv_table,
- int *srcRange, int **table, int *dstRange,
- int *brightness, int *contrast, int *saturation)
-{
- if (!c || isYUV(c->dstFormat) || isGray(c->dstFormat))
- return -1;
-
- *inv_table = c->srcColorspaceTable;
- *table = c->dstColorspaceTable;
- *srcRange = c->srcRange;
- *dstRange = c->dstRange;
- *brightness = c->brightness;
- *contrast = c->contrast;
- *saturation = c->saturation;
-
- return 0;
-}
-
-static int handle_jpeg(enum AVPixelFormat *format)
-{
- switch (*format) {
- case AV_PIX_FMT_YUVJ420P:
- *format = AV_PIX_FMT_YUV420P;
- return 1;
- case AV_PIX_FMT_YUVJ422P:
- *format = AV_PIX_FMT_YUV422P;
- return 1;
- case AV_PIX_FMT_YUVJ444P:
- *format = AV_PIX_FMT_YUV444P;
- return 1;
- case AV_PIX_FMT_YUVJ440P:
- *format = AV_PIX_FMT_YUV440P;
- return 1;
- default:
- return 0;
- }
-}
-
-static int handle_0alpha(enum AVPixelFormat *format)
-{
- switch (*format) {
- case AV_PIX_FMT_0BGR : *format = AV_PIX_FMT_ABGR ; return 1;
- case AV_PIX_FMT_BGR0 : *format = AV_PIX_FMT_BGRA ; return 4;
- case AV_PIX_FMT_0RGB : *format = AV_PIX_FMT_ARGB ; return 1;
- case AV_PIX_FMT_RGB0 : *format = AV_PIX_FMT_RGBA ; return 4;
- default: return 0;
- }
-}
-
-SwsContext *sws_alloc_context(void)
-{
- SwsContext *c = av_mallocz(sizeof(SwsContext));
-
- if (c) {
- c->av_class = &sws_context_class;
- av_opt_set_defaults(c);
- }
-
- return c;
-}
-
-av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
- SwsFilter *dstFilter)
-{
- int i, j;
- int usesVFilter, usesHFilter;
- int unscaled;
- SwsFilter dummyFilter = { NULL, NULL, NULL, NULL };
- int srcW = c->srcW;
- int srcH = c->srcH;
- int dstW = c->dstW;
- int dstH = c->dstH;
- int dst_stride = FFALIGN(dstW * sizeof(int16_t) + 66, 16);
- int flags, cpu_flags;
- enum AVPixelFormat srcFormat = c->srcFormat;
- enum AVPixelFormat dstFormat = c->dstFormat;
- const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(srcFormat);
- const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(dstFormat);
-
- cpu_flags = av_get_cpu_flags();
- flags = c->flags;
- emms_c();
- if (!rgb15to16)
- sws_rgb2rgb_init();
-
- unscaled = (srcW == dstW && srcH == dstH);
-
- handle_jpeg(&srcFormat);
- handle_jpeg(&dstFormat);
- handle_0alpha(&srcFormat);
- handle_0alpha(&dstFormat);
-
- if(srcFormat!=c->srcFormat || dstFormat!=c->dstFormat){
- av_log(c, AV_LOG_WARNING, "deprecated pixel format used, make sure you did set range correctly\n");
- c->srcFormat= srcFormat;
- c->dstFormat= dstFormat;
- }
-
- if (!sws_isSupportedInput(srcFormat)) {
- av_log(c, AV_LOG_ERROR, "%s is not supported as input pixel format\n",
- av_get_pix_fmt_name(srcFormat));
- return AVERROR(EINVAL);
- }
- if (!sws_isSupportedOutput(dstFormat)) {
- av_log(c, AV_LOG_ERROR, "%s is not supported as output pixel format\n",
- av_get_pix_fmt_name(dstFormat));
- return AVERROR(EINVAL);
- }
-
- i = flags & (SWS_POINT |
- SWS_AREA |
- SWS_BILINEAR |
- SWS_FAST_BILINEAR |
- SWS_BICUBIC |
- SWS_X |
- SWS_GAUSS |
- SWS_LANCZOS |
- SWS_SINC |
- SWS_SPLINE |
- SWS_BICUBLIN);
- if (!i || (i & (i - 1))) {
- av_log(c, AV_LOG_ERROR, "Exactly one scaler algorithm must be chosen, got %X\n", i);
- return AVERROR(EINVAL);
- }
- /* sanity check */
- if (srcW < 1 || srcH < 1 || dstW < 1 || dstH < 1) {
- /* FIXME check if these are enough and try to lower them after
- * fixing the relevant parts of the code */
- av_log(c, AV_LOG_ERROR, "%dx%d -> %dx%d is invalid scaling dimension\n",
- srcW, srcH, dstW, dstH);
- return AVERROR(EINVAL);
- }
-
- if (!dstFilter)
- dstFilter = &dummyFilter;
- if (!srcFilter)
- srcFilter = &dummyFilter;
-
- c->lumXInc = (((int64_t)srcW << 16) + (dstW >> 1)) / dstW;
- c->lumYInc = (((int64_t)srcH << 16) + (dstH >> 1)) / dstH;
- c->dstFormatBpp = av_get_bits_per_pixel(desc_dst);
- c->srcFormatBpp = av_get_bits_per_pixel(desc_src);
- c->vRounder = 4 * 0x0001000100010001ULL;
-
- usesVFilter = (srcFilter->lumV && srcFilter->lumV->length > 1) ||
- (srcFilter->chrV && srcFilter->chrV->length > 1) ||
- (dstFilter->lumV && dstFilter->lumV->length > 1) ||
- (dstFilter->chrV && dstFilter->chrV->length > 1);
- usesHFilter = (srcFilter->lumH && srcFilter->lumH->length > 1) ||
- (srcFilter->chrH && srcFilter->chrH->length > 1) ||
- (dstFilter->lumH && dstFilter->lumH->length > 1) ||
- (dstFilter->chrH && dstFilter->chrH->length > 1);
-
- getSubSampleFactors(&c->chrSrcHSubSample, &c->chrSrcVSubSample, srcFormat);
- getSubSampleFactors(&c->chrDstHSubSample, &c->chrDstVSubSample, dstFormat);
-
- if (isAnyRGB(dstFormat) && !(flags&SWS_FULL_CHR_H_INT)) {
- if (dstW&1) {
- av_log(c, AV_LOG_DEBUG, "Forcing full internal H chroma due to odd output size\n");
- flags |= SWS_FULL_CHR_H_INT;
- c->flags = flags;
- }
- }
-
- if(dstFormat == AV_PIX_FMT_BGR4_BYTE ||
- dstFormat == AV_PIX_FMT_RGB4_BYTE ||
- dstFormat == AV_PIX_FMT_BGR8 ||
- dstFormat == AV_PIX_FMT_RGB8) {
- if (flags & SWS_ERROR_DIFFUSION && !(flags & SWS_FULL_CHR_H_INT)) {
- av_log(c, AV_LOG_DEBUG,
- "Error diffusion dither is only supported in full chroma interpolation for destination format '%s'\n",
- av_get_pix_fmt_name(dstFormat));
- flags |= SWS_FULL_CHR_H_INT;
- c->flags = flags;
- }
- if (!(flags & SWS_ERROR_DIFFUSION) && (flags & SWS_FULL_CHR_H_INT)) {
- av_log(c, AV_LOG_DEBUG,
- "Ordered dither is not supported in full chroma interpolation for destination format '%s'\n",
- av_get_pix_fmt_name(dstFormat));
- flags |= SWS_ERROR_DIFFUSION;
- c->flags = flags;
- }
- }
- if (isPlanarRGB(dstFormat)) {
- if (!(flags & SWS_FULL_CHR_H_INT)) {
- av_log(c, AV_LOG_DEBUG,
- "%s output is not supported with half chroma resolution, switching to full\n",
- av_get_pix_fmt_name(dstFormat));
- flags |= SWS_FULL_CHR_H_INT;
- c->flags = flags;
- }
- }
-
- /* reuse chroma for 2 pixels RGB/BGR unless user wants full
- * chroma interpolation */
- if (flags & SWS_FULL_CHR_H_INT &&
- isAnyRGB(dstFormat) &&
- !isPlanarRGB(dstFormat) &&
- dstFormat != AV_PIX_FMT_RGBA &&
- dstFormat != AV_PIX_FMT_ARGB &&
- dstFormat != AV_PIX_FMT_BGRA &&
- dstFormat != AV_PIX_FMT_ABGR &&
- dstFormat != AV_PIX_FMT_RGB24 &&
- dstFormat != AV_PIX_FMT_BGR24 &&
- dstFormat != AV_PIX_FMT_BGR4_BYTE &&
- dstFormat != AV_PIX_FMT_RGB4_BYTE &&
- dstFormat != AV_PIX_FMT_BGR8 &&
- dstFormat != AV_PIX_FMT_RGB8
- ) {
- av_log(c, AV_LOG_WARNING,
- "full chroma interpolation for destination format '%s' not yet implemented\n",
- av_get_pix_fmt_name(dstFormat));
- flags &= ~SWS_FULL_CHR_H_INT;
- c->flags = flags;
- }
- if (isAnyRGB(dstFormat) && !(flags & SWS_FULL_CHR_H_INT))
- c->chrDstHSubSample = 1;
-
- // drop some chroma lines if the user wants it
- c->vChrDrop = (flags & SWS_SRC_V_CHR_DROP_MASK) >>
- SWS_SRC_V_CHR_DROP_SHIFT;
- c->chrSrcVSubSample += c->vChrDrop;
-
- /* drop every other pixel for chroma calculation unless user
- * wants full chroma */
- if (isAnyRGB(srcFormat) && !(flags & SWS_FULL_CHR_H_INP) &&
- srcFormat != AV_PIX_FMT_RGB8 && srcFormat != AV_PIX_FMT_BGR8 &&
- srcFormat != AV_PIX_FMT_RGB4 && srcFormat != AV_PIX_FMT_BGR4 &&
- srcFormat != AV_PIX_FMT_RGB4_BYTE && srcFormat != AV_PIX_FMT_BGR4_BYTE &&
- srcFormat != AV_PIX_FMT_GBRP9BE && srcFormat != AV_PIX_FMT_GBRP9LE &&
- srcFormat != AV_PIX_FMT_GBRP10BE && srcFormat != AV_PIX_FMT_GBRP10LE &&
- srcFormat != AV_PIX_FMT_GBRP12BE && srcFormat != AV_PIX_FMT_GBRP12LE &&
- srcFormat != AV_PIX_FMT_GBRP14BE && srcFormat != AV_PIX_FMT_GBRP14LE &&
- srcFormat != AV_PIX_FMT_GBRP16BE && srcFormat != AV_PIX_FMT_GBRP16LE &&
- ((dstW >> c->chrDstHSubSample) <= (srcW >> 1) ||
- (flags & SWS_FAST_BILINEAR)))
- c->chrSrcHSubSample = 1;
-
- // Note the -((-x)>>y) is so that we always round toward +inf.
- c->chrSrcW = -((-srcW) >> c->chrSrcHSubSample);
- c->chrSrcH = -((-srcH) >> c->chrSrcVSubSample);
- c->chrDstW = -((-dstW) >> c->chrDstHSubSample);
- c->chrDstH = -((-dstH) >> c->chrDstVSubSample);
-
- FF_ALLOC_OR_GOTO(c, c->formatConvBuffer, FFALIGN(srcW*2+78, 16) * 2, fail);
-
- /* unscaled special cases */
- if (unscaled && !usesHFilter && !usesVFilter &&
- (c->srcRange == c->dstRange || isAnyRGB(dstFormat))) {
- ff_get_unscaled_swscale(c);
-
- if (c->swScale) {
- if (flags & SWS_PRINT_INFO)
- av_log(c, AV_LOG_INFO,
- "using unscaled %s -> %s special converter\n",
- av_get_pix_fmt_name(srcFormat), av_get_pix_fmt_name(dstFormat));
- return 0;
- }
- }
-
- c->srcBpc = 1 + desc_src->comp[0].depth_minus1;
- if (c->srcBpc < 8)
- c->srcBpc = 8;
- c->dstBpc = 1 + desc_dst->comp[0].depth_minus1;
- if (c->dstBpc < 8)
- c->dstBpc = 8;
- if (isAnyRGB(srcFormat) || srcFormat == AV_PIX_FMT_PAL8)
- c->srcBpc = 16;
- if (c->dstBpc == 16)
- dst_stride <<= 1;
-
- if (INLINE_MMXEXT(cpu_flags) && c->srcBpc == 8 && c->dstBpc <= 14) {
- c->canMMXEXTBeUsed = (dstW >= srcW && (dstW & 31) == 0 &&
- (srcW & 15) == 0) ? 1 : 0;
- if (!c->canMMXEXTBeUsed && dstW >= srcW && (srcW & 15) == 0
-
- && (flags & SWS_FAST_BILINEAR)) {
- if (flags & SWS_PRINT_INFO)
- av_log(c, AV_LOG_INFO,
- "output width is not a multiple of 32 -> no MMXEXT scaler\n");
- }
- if (usesHFilter || isNBPS(c->srcFormat) || is16BPS(c->srcFormat) || isAnyRGB(c->srcFormat))
- c->canMMXEXTBeUsed = 0;
- } else
- c->canMMXEXTBeUsed = 0;
-
- c->chrXInc = (((int64_t)c->chrSrcW << 16) + (c->chrDstW >> 1)) / c->chrDstW;
- c->chrYInc = (((int64_t)c->chrSrcH << 16) + (c->chrDstH >> 1)) / c->chrDstH;
-
- /* Match pixel 0 of the src to pixel 0 of dst and match pixel n-2 of src
- * to pixel n-2 of dst, but only for the FAST_BILINEAR mode otherwise do
- * correct scaling.
- * n-2 is the last chrominance sample available.
- * This is not perfect, but no one should notice the difference, the more
- * correct variant would be like the vertical one, but that would require
- * some special code for the first and last pixel */
- if (flags & SWS_FAST_BILINEAR) {
- if (c->canMMXEXTBeUsed) {
- c->lumXInc += 20;
- c->chrXInc += 20;
- }
- // we don't use the x86 asm scaler if MMX is available
- else if (INLINE_MMX(cpu_flags) && c->dstBpc <= 14) {
- c->lumXInc = ((int64_t)(srcW - 2) << 16) / (dstW - 2) - 20;
- c->chrXInc = ((int64_t)(c->chrSrcW - 2) << 16) / (c->chrDstW - 2) - 20;
- }
- }
-
-#define USE_MMAP (HAVE_MMAP && HAVE_MPROTECT && defined MAP_ANONYMOUS)
-
- /* precalculate horizontal scaler filter coefficients */
- {
-#if HAVE_MMXEXT_INLINE
-// can't downscale !!!
- if (c->canMMXEXTBeUsed && (flags & SWS_FAST_BILINEAR)) {
- c->lumMmxextFilterCodeSize = init_hscaler_mmxext(dstW, c->lumXInc, NULL,
- NULL, NULL, 8);
- c->chrMmxextFilterCodeSize = init_hscaler_mmxext(c->chrDstW, c->chrXInc,
- NULL, NULL, NULL, 4);
-
-#if USE_MMAP
- c->lumMmxextFilterCode = mmap(NULL, c->lumMmxextFilterCodeSize,
- PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANONYMOUS,
- -1, 0);
- c->chrMmxextFilterCode = mmap(NULL, c->chrMmxextFilterCodeSize,
- PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANONYMOUS,
- -1, 0);
-#elif HAVE_VIRTUALALLOC
- c->lumMmxextFilterCode = VirtualAlloc(NULL,
- c->lumMmxextFilterCodeSize,
- MEM_COMMIT,
- PAGE_EXECUTE_READWRITE);
- c->chrMmxextFilterCode = VirtualAlloc(NULL,
- c->chrMmxextFilterCodeSize,
- MEM_COMMIT,
- PAGE_EXECUTE_READWRITE);
-#else
- c->lumMmxextFilterCode = av_malloc(c->lumMmxextFilterCodeSize);
- c->chrMmxextFilterCode = av_malloc(c->chrMmxextFilterCodeSize);
-#endif
-
-#ifdef MAP_ANONYMOUS
- if (c->lumMmxextFilterCode == MAP_FAILED || c->chrMmxextFilterCode == MAP_FAILED)
-#else
- if (!c->lumMmxextFilterCode || !c->chrMmxextFilterCode)
-#endif
- {
- av_log(c, AV_LOG_ERROR, "Failed to allocate MMX2FilterCode\n");
- return AVERROR(ENOMEM);
- }
-
- FF_ALLOCZ_OR_GOTO(c, c->hLumFilter, (dstW / 8 + 8) * sizeof(int16_t), fail);
- FF_ALLOCZ_OR_GOTO(c, c->hChrFilter, (c->chrDstW / 4 + 8) * sizeof(int16_t), fail);
- FF_ALLOCZ_OR_GOTO(c, c->hLumFilterPos, (dstW / 2 / 8 + 8) * sizeof(int32_t), fail);
- FF_ALLOCZ_OR_GOTO(c, c->hChrFilterPos, (c->chrDstW / 2 / 4 + 8) * sizeof(int32_t), fail);
-
- init_hscaler_mmxext( dstW, c->lumXInc, c->lumMmxextFilterCode,
- c->hLumFilter, (uint32_t*)c->hLumFilterPos, 8);
- init_hscaler_mmxext(c->chrDstW, c->chrXInc, c->chrMmxextFilterCode,
- c->hChrFilter, (uint32_t*)c->hChrFilterPos, 4);
-
-#if USE_MMAP
- mprotect(c->lumMmxextFilterCode, c->lumMmxextFilterCodeSize, PROT_EXEC | PROT_READ);
- mprotect(c->chrMmxextFilterCode, c->chrMmxextFilterCodeSize, PROT_EXEC | PROT_READ);
-#endif
- } else
-#endif /* HAVE_MMXEXT_INLINE */
- {
- const int filterAlign =
- (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) ? 4 :
- (HAVE_ALTIVEC && cpu_flags & AV_CPU_FLAG_ALTIVEC) ? 8 :
- 1;
-
- if (initFilter(&c->hLumFilter, &c->hLumFilterPos,
- &c->hLumFilterSize, c->lumXInc,
- srcW, dstW, filterAlign, 1 << 14,
- (flags & SWS_BICUBLIN) ? (flags | SWS_BICUBIC) : flags,
- cpu_flags, srcFilter->lumH, dstFilter->lumH,
- c->param) < 0)
- goto fail;
- if (initFilter(&c->hChrFilter, &c->hChrFilterPos,
- &c->hChrFilterSize, c->chrXInc,
- c->chrSrcW, c->chrDstW, filterAlign, 1 << 14,
- (flags & SWS_BICUBLIN) ? (flags | SWS_BILINEAR) : flags,
- cpu_flags, srcFilter->chrH, dstFilter->chrH,
- c->param) < 0)
- goto fail;
- }
- } // initialize horizontal stuff
-
- /* precalculate vertical scaler filter coefficients */
- {
- const int filterAlign =
- (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) ? 2 :
- (HAVE_ALTIVEC && cpu_flags & AV_CPU_FLAG_ALTIVEC) ? 8 :
- 1;
-
- if (initFilter(&c->vLumFilter, &c->vLumFilterPos, &c->vLumFilterSize,
- c->lumYInc, srcH, dstH, filterAlign, (1 << 12),
- (flags & SWS_BICUBLIN) ? (flags | SWS_BICUBIC) : flags,
- cpu_flags, srcFilter->lumV, dstFilter->lumV,
- c->param) < 0)
- goto fail;
- if (initFilter(&c->vChrFilter, &c->vChrFilterPos, &c->vChrFilterSize,
- c->chrYInc, c->chrSrcH, c->chrDstH,
- filterAlign, (1 << 12),
- (flags & SWS_BICUBLIN) ? (flags | SWS_BILINEAR) : flags,
- cpu_flags, srcFilter->chrV, dstFilter->chrV,
- c->param) < 0)
- goto fail;
-
-#if HAVE_ALTIVEC
- FF_ALLOC_OR_GOTO(c, c->vYCoeffsBank, sizeof(vector signed short) * c->vLumFilterSize * c->dstH, fail);
- FF_ALLOC_OR_GOTO(c, c->vCCoeffsBank, sizeof(vector signed short) * c->vChrFilterSize * c->chrDstH, fail);
-
- for (i = 0; i < c->vLumFilterSize * c->dstH; i++) {
- int j;
- short *p = (short *)&c->vYCoeffsBank[i];
- for (j = 0; j < 8; j++)
- p[j] = c->vLumFilter[i];
- }
-
- for (i = 0; i < c->vChrFilterSize * c->chrDstH; i++) {
- int j;
- short *p = (short *)&c->vCCoeffsBank[i];
- for (j = 0; j < 8; j++)
- p[j] = c->vChrFilter[i];
- }
-#endif
- }
-
- // calculate buffer sizes so that they won't run out while handling these damn slices
- c->vLumBufSize = c->vLumFilterSize;
- c->vChrBufSize = c->vChrFilterSize;
- for (i = 0; i < dstH; i++) {
- int chrI = (int64_t)i * c->chrDstH / dstH;
- int nextSlice = FFMAX(c->vLumFilterPos[i] + c->vLumFilterSize - 1,
- ((c->vChrFilterPos[chrI] + c->vChrFilterSize - 1)
- << c->chrSrcVSubSample));
-
- nextSlice >>= c->chrSrcVSubSample;
- nextSlice <<= c->chrSrcVSubSample;
- if (c->vLumFilterPos[i] + c->vLumBufSize < nextSlice)
- c->vLumBufSize = nextSlice - c->vLumFilterPos[i];
- if (c->vChrFilterPos[chrI] + c->vChrBufSize <
- (nextSlice >> c->chrSrcVSubSample))
- c->vChrBufSize = (nextSlice >> c->chrSrcVSubSample) -
- c->vChrFilterPos[chrI];
- }
-
- for (i = 0; i < 4; i++)
- FF_ALLOCZ_OR_GOTO(c, c->dither_error[i], (c->dstW+2) * sizeof(int), fail);
-
- /* Allocate pixbufs (we use dynamic allocation because otherwise we would
- * need to allocate several megabytes to handle all possible cases) */
- FF_ALLOC_OR_GOTO(c, c->lumPixBuf, c->vLumBufSize * 3 * sizeof(int16_t *), fail);
- FF_ALLOC_OR_GOTO(c, c->chrUPixBuf, c->vChrBufSize * 3 * sizeof(int16_t *), fail);
- FF_ALLOC_OR_GOTO(c, c->chrVPixBuf, c->vChrBufSize * 3 * sizeof(int16_t *), fail);
- if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat) && isALPHA(c->dstFormat))
- FF_ALLOCZ_OR_GOTO(c, c->alpPixBuf, c->vLumBufSize * 3 * sizeof(int16_t *), fail);
- /* Note we need at least one pixel more at the end because of the MMX code
- * (just in case someone wants to replace the 4000/8000). */
- /* align at 16 bytes for AltiVec */
- for (i = 0; i < c->vLumBufSize; i++) {
- FF_ALLOCZ_OR_GOTO(c, c->lumPixBuf[i + c->vLumBufSize],
- dst_stride + 16, fail);
- c->lumPixBuf[i] = c->lumPixBuf[i + c->vLumBufSize];
- }
- // 64 / c->scalingBpp is the same as 16 / sizeof(scaling_intermediate)
- c->uv_off = (dst_stride>>1) + 64 / (c->dstBpc &~ 7);
- c->uv_offx2 = dst_stride + 16;
- for (i = 0; i < c->vChrBufSize; i++) {
- FF_ALLOC_OR_GOTO(c, c->chrUPixBuf[i + c->vChrBufSize],
- dst_stride * 2 + 32, fail);
- c->chrUPixBuf[i] = c->chrUPixBuf[i + c->vChrBufSize];
- c->chrVPixBuf[i] = c->chrVPixBuf[i + c->vChrBufSize]
- = c->chrUPixBuf[i] + (dst_stride >> 1) + 8;
- }
- if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
- for (i = 0; i < c->vLumBufSize; i++) {
- FF_ALLOCZ_OR_GOTO(c, c->alpPixBuf[i + c->vLumBufSize],
- dst_stride + 16, fail);
- c->alpPixBuf[i] = c->alpPixBuf[i + c->vLumBufSize];
- }
-
- // try to avoid drawing green stuff between the right end and the stride end
- for (i = 0; i < c->vChrBufSize; i++)
- if(desc_dst->comp[0].depth_minus1 == 15){
- av_assert0(c->dstBpc > 14);
- for(j=0; j<dst_stride/2+1; j++)
- ((int32_t*)(c->chrUPixBuf[i]))[j] = 1<<18;
- } else
- for(j=0; j<dst_stride+1; j++)
- ((int16_t*)(c->chrUPixBuf[i]))[j] = 1<<14;
-
- av_assert0(c->chrDstH <= dstH);
-
- if (flags & SWS_PRINT_INFO) {
- if (flags & SWS_FAST_BILINEAR)
- av_log(c, AV_LOG_INFO, "FAST_BILINEAR scaler, ");
- else if (flags & SWS_BILINEAR)
- av_log(c, AV_LOG_INFO, "BILINEAR scaler, ");
- else if (flags & SWS_BICUBIC)
- av_log(c, AV_LOG_INFO, "BICUBIC scaler, ");
- else if (flags & SWS_X)
- av_log(c, AV_LOG_INFO, "Experimental scaler, ");
- else if (flags & SWS_POINT)
- av_log(c, AV_LOG_INFO, "Nearest Neighbor / POINT scaler, ");
- else if (flags & SWS_AREA)
- av_log(c, AV_LOG_INFO, "Area Averaging scaler, ");
- else if (flags & SWS_BICUBLIN)
- av_log(c, AV_LOG_INFO, "luma BICUBIC / chroma BILINEAR scaler, ");
- else if (flags & SWS_GAUSS)
- av_log(c, AV_LOG_INFO, "Gaussian scaler, ");
- else if (flags & SWS_SINC)
- av_log(c, AV_LOG_INFO, "Sinc scaler, ");
- else if (flags & SWS_LANCZOS)
- av_log(c, AV_LOG_INFO, "Lanczos scaler, ");
- else if (flags & SWS_SPLINE)
- av_log(c, AV_LOG_INFO, "Bicubic spline scaler, ");
- else
- av_log(c, AV_LOG_INFO, "ehh flags invalid?! ");
-
- av_log(c, AV_LOG_INFO, "from %s to %s%s ",
- av_get_pix_fmt_name(srcFormat),
-#ifdef DITHER1XBPP
- dstFormat == AV_PIX_FMT_BGR555 || dstFormat == AV_PIX_FMT_BGR565 ||
- dstFormat == AV_PIX_FMT_RGB444BE || dstFormat == AV_PIX_FMT_RGB444LE ||
- dstFormat == AV_PIX_FMT_BGR444BE || dstFormat == AV_PIX_FMT_BGR444LE ?
- "dithered " : "",
-#else
- "",
-#endif
- av_get_pix_fmt_name(dstFormat));
-
- if (INLINE_MMXEXT(cpu_flags))
- av_log(c, AV_LOG_INFO, "using MMXEXT\n");
- else if (INLINE_AMD3DNOW(cpu_flags))
- av_log(c, AV_LOG_INFO, "using 3DNOW\n");
- else if (INLINE_MMX(cpu_flags))
- av_log(c, AV_LOG_INFO, "using MMX\n");
- else if (HAVE_ALTIVEC && cpu_flags & AV_CPU_FLAG_ALTIVEC)
- av_log(c, AV_LOG_INFO, "using AltiVec\n");
- else
- av_log(c, AV_LOG_INFO, "using C\n");
-
- av_log(c, AV_LOG_VERBOSE, "%dx%d -> %dx%d\n", srcW, srcH, dstW, dstH);
- av_log(c, AV_LOG_DEBUG,
- "lum srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
- c->srcW, c->srcH, c->dstW, c->dstH, c->lumXInc, c->lumYInc);
- av_log(c, AV_LOG_DEBUG,
- "chr srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
- c->chrSrcW, c->chrSrcH, c->chrDstW, c->chrDstH,
- c->chrXInc, c->chrYInc);
- }
-
- c->swScale = ff_getSwsFunc(c);
- return 0;
-fail: // FIXME replace things by appropriate error codes
- return -1;
-}
-
-#if FF_API_SWS_GETCONTEXT
-SwsContext *sws_getContext(int srcW, int srcH, enum AVPixelFormat srcFormat,
- int dstW, int dstH, enum AVPixelFormat dstFormat,
- int flags, SwsFilter *srcFilter,
- SwsFilter *dstFilter, const double *param)
-{
- SwsContext *c;
-
- if (!(c = sws_alloc_context()))
- return NULL;
-
- c->flags = flags;
- c->srcW = srcW;
- c->srcH = srcH;
- c->dstW = dstW;
- c->dstH = dstH;
- c->srcRange = handle_jpeg(&srcFormat);
- c->dstRange = handle_jpeg(&dstFormat);
- c->src0Alpha = handle_0alpha(&srcFormat);
- c->dst0Alpha = handle_0alpha(&dstFormat);
- c->srcFormat = srcFormat;
- c->dstFormat = dstFormat;
-
- if (param) {
- c->param[0] = param[0];
- c->param[1] = param[1];
- }
- sws_setColorspaceDetails(c, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT], c->srcRange,
- ff_yuv2rgb_coeffs[SWS_CS_DEFAULT] /* FIXME*/,
- c->dstRange, 0, 1 << 16, 1 << 16);
-
- if (sws_init_context(c, srcFilter, dstFilter) < 0) {
- sws_freeContext(c);
- return NULL;
- }
-
- return c;
-}
-#endif
-
-SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur,
- float lumaSharpen, float chromaSharpen,
- float chromaHShift, float chromaVShift,
- int verbose)
-{
- SwsFilter *filter = av_malloc(sizeof(SwsFilter));
- if (!filter)
- return NULL;
-
- if (lumaGBlur != 0.0) {
- filter->lumH = sws_getGaussianVec(lumaGBlur, 3.0);
- filter->lumV = sws_getGaussianVec(lumaGBlur, 3.0);
- } else {
- filter->lumH = sws_getIdentityVec();
- filter->lumV = sws_getIdentityVec();
- }
-
- if (chromaGBlur != 0.0) {
- filter->chrH = sws_getGaussianVec(chromaGBlur, 3.0);
- filter->chrV = sws_getGaussianVec(chromaGBlur, 3.0);
- } else {
- filter->chrH = sws_getIdentityVec();
- filter->chrV = sws_getIdentityVec();
- }
-
- if (chromaSharpen != 0.0) {
- SwsVector *id = sws_getIdentityVec();
- sws_scaleVec(filter->chrH, -chromaSharpen);
- sws_scaleVec(filter->chrV, -chromaSharpen);
- sws_addVec(filter->chrH, id);
- sws_addVec(filter->chrV, id);
- sws_freeVec(id);
- }
-
- if (lumaSharpen != 0.0) {
- SwsVector *id = sws_getIdentityVec();
- sws_scaleVec(filter->lumH, -lumaSharpen);
- sws_scaleVec(filter->lumV, -lumaSharpen);
- sws_addVec(filter->lumH, id);
- sws_addVec(filter->lumV, id);
- sws_freeVec(id);
- }
-
- if (chromaHShift != 0.0)
- sws_shiftVec(filter->chrH, (int)(chromaHShift + 0.5));
-
- if (chromaVShift != 0.0)
- sws_shiftVec(filter->chrV, (int)(chromaVShift + 0.5));
-
- sws_normalizeVec(filter->chrH, 1.0);
- sws_normalizeVec(filter->chrV, 1.0);
- sws_normalizeVec(filter->lumH, 1.0);
- sws_normalizeVec(filter->lumV, 1.0);
-
- if (verbose)
- sws_printVec2(filter->chrH, NULL, AV_LOG_DEBUG);
- if (verbose)
- sws_printVec2(filter->lumH, NULL, AV_LOG_DEBUG);
-
- return filter;
-}
-
-SwsVector *sws_allocVec(int length)
-{
- SwsVector *vec;
-
- if(length <= 0 || length > INT_MAX/ sizeof(double))
- return NULL;
-
- vec = av_malloc(sizeof(SwsVector));
- if (!vec)
- return NULL;
- vec->length = length;
- vec->coeff = av_malloc(sizeof(double) * length);
- if (!vec->coeff)
- av_freep(&vec);
- return vec;
-}
-
-SwsVector *sws_getGaussianVec(double variance, double quality)
-{
- const int length = (int)(variance * quality + 0.5) | 1;
- int i;
- double middle = (length - 1) * 0.5;
- SwsVector *vec;
-
- if(variance < 0 || quality < 0)
- return NULL;
-
- vec = sws_allocVec(length);
-
- if (!vec)
- return NULL;
-
- for (i = 0; i < length; i++) {
- double dist = i - middle;
- vec->coeff[i] = exp(-dist * dist / (2 * variance * variance)) /
- sqrt(2 * variance * M_PI);
- }
-
- sws_normalizeVec(vec, 1.0);
-
- return vec;
-}
-
-SwsVector *sws_getConstVec(double c, int length)
-{
- int i;
- SwsVector *vec = sws_allocVec(length);
-
- if (!vec)
- return NULL;
-
- for (i = 0; i < length; i++)
- vec->coeff[i] = c;
-
- return vec;
-}
-
-SwsVector *sws_getIdentityVec(void)
-{
- return sws_getConstVec(1.0, 1);
-}
-
-static double sws_dcVec(SwsVector *a)
-{
- int i;
- double sum = 0;
-
- for (i = 0; i < a->length; i++)
- sum += a->coeff[i];
-
- return sum;
-}
-
-void sws_scaleVec(SwsVector *a, double scalar)
-{
- int i;
-
- for (i = 0; i < a->length; i++)
- a->coeff[i] *= scalar;
-}
-
-void sws_normalizeVec(SwsVector *a, double height)
-{
- sws_scaleVec(a, height / sws_dcVec(a));
-}
-
-static SwsVector *sws_getConvVec(SwsVector *a, SwsVector *b)
-{
- int length = a->length + b->length - 1;
- int i, j;
- SwsVector *vec = sws_getConstVec(0.0, length);
-
- if (!vec)
- return NULL;
-
- for (i = 0; i < a->length; i++) {
- for (j = 0; j < b->length; j++) {
- vec->coeff[i + j] += a->coeff[i] * b->coeff[j];
- }
- }
-
- return vec;
-}
-
-static SwsVector *sws_sumVec(SwsVector *a, SwsVector *b)
-{
- int length = FFMAX(a->length, b->length);
- int i;
- SwsVector *vec = sws_getConstVec(0.0, length);
-
- if (!vec)
- return NULL;
-
- for (i = 0; i < a->length; i++)
- vec->coeff[i + (length - 1) / 2 - (a->length - 1) / 2] += a->coeff[i];
- for (i = 0; i < b->length; i++)
- vec->coeff[i + (length - 1) / 2 - (b->length - 1) / 2] += b->coeff[i];
-
- return vec;
-}
-
-static SwsVector *sws_diffVec(SwsVector *a, SwsVector *b)
-{
- int length = FFMAX(a->length, b->length);
- int i;
- SwsVector *vec = sws_getConstVec(0.0, length);
-
- if (!vec)
- return NULL;
-
- for (i = 0; i < a->length; i++)
- vec->coeff[i + (length - 1) / 2 - (a->length - 1) / 2] += a->coeff[i];
- for (i = 0; i < b->length; i++)
- vec->coeff[i + (length - 1) / 2 - (b->length - 1) / 2] -= b->coeff[i];
-
- return vec;
-}
-
-/* shift left / or right if "shift" is negative */
-static SwsVector *sws_getShiftedVec(SwsVector *a, int shift)
-{
- int length = a->length + FFABS(shift) * 2;
- int i;
- SwsVector *vec = sws_getConstVec(0.0, length);
-
- if (!vec)
- return NULL;
-
- for (i = 0; i < a->length; i++) {
- vec->coeff[i + (length - 1) / 2 -
- (a->length - 1) / 2 - shift] = a->coeff[i];
- }
-
- return vec;
-}
-
-void sws_shiftVec(SwsVector *a, int shift)
-{
- SwsVector *shifted = sws_getShiftedVec(a, shift);
- av_free(a->coeff);
- a->coeff = shifted->coeff;
- a->length = shifted->length;
- av_free(shifted);
-}
-
-void sws_addVec(SwsVector *a, SwsVector *b)
-{
- SwsVector *sum = sws_sumVec(a, b);
- av_free(a->coeff);
- a->coeff = sum->coeff;
- a->length = sum->length;
- av_free(sum);
-}
-
-void sws_subVec(SwsVector *a, SwsVector *b)
-{
- SwsVector *diff = sws_diffVec(a, b);
- av_free(a->coeff);
- a->coeff = diff->coeff;
- a->length = diff->length;
- av_free(diff);
-}
-
-void sws_convVec(SwsVector *a, SwsVector *b)
-{
- SwsVector *conv = sws_getConvVec(a, b);
- av_free(a->coeff);
- a->coeff = conv->coeff;
- a->length = conv->length;
- av_free(conv);
-}
-
-SwsVector *sws_cloneVec(SwsVector *a)
-{
- int i;
- SwsVector *vec = sws_allocVec(a->length);
-
- if (!vec)
- return NULL;
-
- for (i = 0; i < a->length; i++)
- vec->coeff[i] = a->coeff[i];
-
- return vec;
-}
-
-void sws_printVec2(SwsVector *a, AVClass *log_ctx, int log_level)
-{
- int i;
- double max = 0;
- double min = 0;
- double range;
-
- for (i = 0; i < a->length; i++)
- if (a->coeff[i] > max)
- max = a->coeff[i];
-
- for (i = 0; i < a->length; i++)
- if (a->coeff[i] < min)
- min = a->coeff[i];
-
- range = max - min;
-
- for (i = 0; i < a->length; i++) {
- int x = (int)((a->coeff[i] - min) * 60.0 / range + 0.5);
- av_log(log_ctx, log_level, "%1.3f ", a->coeff[i]);
- for (; x > 0; x--)
- av_log(log_ctx, log_level, " ");
- av_log(log_ctx, log_level, "|\n");
- }
-}
-
-void sws_freeVec(SwsVector *a)
-{
- if (!a)
- return;
- av_freep(&a->coeff);
- a->length = 0;
- av_free(a);
-}
-
-void sws_freeFilter(SwsFilter *filter)
-{
- if (!filter)
- return;
-
- if (filter->lumH)
- sws_freeVec(filter->lumH);
- if (filter->lumV)
- sws_freeVec(filter->lumV);
- if (filter->chrH)
- sws_freeVec(filter->chrH);
- if (filter->chrV)
- sws_freeVec(filter->chrV);
- av_free(filter);
-}
-
-void sws_freeContext(SwsContext *c)
-{
- int i;
- if (!c)
- return;
-
- if (c->lumPixBuf) {
- for (i = 0; i < c->vLumBufSize; i++)
- av_freep(&c->lumPixBuf[i]);
- av_freep(&c->lumPixBuf);
- }
-
- if (c->chrUPixBuf) {
- for (i = 0; i < c->vChrBufSize; i++)
- av_freep(&c->chrUPixBuf[i]);
- av_freep(&c->chrUPixBuf);
- av_freep(&c->chrVPixBuf);
- }
-
- if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) {
- for (i = 0; i < c->vLumBufSize; i++)
- av_freep(&c->alpPixBuf[i]);
- av_freep(&c->alpPixBuf);
- }
-
- for (i = 0; i < 4; i++)
- av_freep(&c->dither_error[i]);
-
- av_freep(&c->vLumFilter);
- av_freep(&c->vChrFilter);
- av_freep(&c->hLumFilter);
- av_freep(&c->hChrFilter);
-#if HAVE_ALTIVEC
- av_freep(&c->vYCoeffsBank);
- av_freep(&c->vCCoeffsBank);
-#endif
-
- av_freep(&c->vLumFilterPos);
- av_freep(&c->vChrFilterPos);
- av_freep(&c->hLumFilterPos);
- av_freep(&c->hChrFilterPos);
-
-#if HAVE_MMX_INLINE
-#if USE_MMAP
- if (c->lumMmxextFilterCode)
- munmap(c->lumMmxextFilterCode, c->lumMmxextFilterCodeSize);
- if (c->chrMmxextFilterCode)
- munmap(c->chrMmxextFilterCode, c->chrMmxextFilterCodeSize);
-#elif HAVE_VIRTUALALLOC
- if (c->lumMmxextFilterCode)
- VirtualFree(c->lumMmxextFilterCode, 0, MEM_RELEASE);
- if (c->chrMmxextFilterCode)
- VirtualFree(c->chrMmxextFilterCode, 0, MEM_RELEASE);
-#else
- av_free(c->lumMmxextFilterCode);
- av_free(c->chrMmxextFilterCode);
-#endif
- c->lumMmxextFilterCode = NULL;
- c->chrMmxextFilterCode = NULL;
-#endif /* HAVE_MMX_INLINE */
-
- av_freep(&c->yuvTable);
- av_freep(&c->formatConvBuffer);
-
- av_free(c);
-}
-
-struct SwsContext *sws_getCachedContext(struct SwsContext *context, int srcW,
- int srcH, enum AVPixelFormat srcFormat,
- int dstW, int dstH,
- enum AVPixelFormat dstFormat, int flags,
- SwsFilter *srcFilter,
- SwsFilter *dstFilter,
- const double *param)
-{
- static const double default_param[2] = { SWS_PARAM_DEFAULT,
- SWS_PARAM_DEFAULT };
-
- if (!param)
- param = default_param;
-
- if (context &&
- (context->srcW != srcW ||
- context->srcH != srcH ||
- context->srcFormat != srcFormat ||
- context->dstW != dstW ||
- context->dstH != dstH ||
- context->dstFormat != dstFormat ||
- context->flags != flags ||
- context->param[0] != param[0] ||
- context->param[1] != param[1])) {
- sws_freeContext(context);
- context = NULL;
- }
-
- if (!context) {
- if (!(context = sws_alloc_context()))
- return NULL;
- context->srcW = srcW;
- context->srcH = srcH;
- context->srcRange = handle_jpeg(&srcFormat);
- context->src0Alpha = handle_0alpha(&srcFormat);
- context->srcFormat = srcFormat;
- context->dstW = dstW;
- context->dstH = dstH;
- context->dstRange = handle_jpeg(&dstFormat);
- context->dst0Alpha = handle_0alpha(&dstFormat);
- context->dstFormat = dstFormat;
- context->flags = flags;
- context->param[0] = param[0];
- context->param[1] = param[1];
- sws_setColorspaceDetails(context, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT],
- context->srcRange,
- ff_yuv2rgb_coeffs[SWS_CS_DEFAULT] /* FIXME*/,
- context->dstRange, 0, 1 << 16, 1 << 16);
- if (sws_init_context(context, srcFilter, dstFilter) < 0) {
- sws_freeContext(context);
- return NULL;
- }
- }
- return context;
-}
diff --git a/src/thirdparty/ffmpeg/libswscale/version.h b/src/thirdparty/ffmpeg/libswscale/version.h
deleted file mode 100644
index 3be87ccc4..000000000
--- a/src/thirdparty/ffmpeg/libswscale/version.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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 SWSCALE_VERSION_H
-#define SWSCALE_VERSION_H
-
-/**
- * @file
- * swscale version macros
- */
-
-#include "libavutil/avutil.h"
-
-#define LIBSWSCALE_VERSION_MAJOR 2
-#define LIBSWSCALE_VERSION_MINOR 2
-#define LIBSWSCALE_VERSION_MICRO 100
-
-#define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \
- LIBSWSCALE_VERSION_MINOR, \
- LIBSWSCALE_VERSION_MICRO)
-#define LIBSWSCALE_VERSION AV_VERSION(LIBSWSCALE_VERSION_MAJOR, \
- LIBSWSCALE_VERSION_MINOR, \
- LIBSWSCALE_VERSION_MICRO)
-#define LIBSWSCALE_BUILD LIBSWSCALE_VERSION_INT
-
-#define LIBSWSCALE_IDENT "SwS" AV_STRINGIFY(LIBSWSCALE_VERSION)
-
-/**
- * FF_API_* defines may be placed below to indicate public API that will be
- * dropped at a future version bump. The defines themselves are not part of
- * the public API and may change, break or disappear at any time.
- */
-
-#ifndef FF_API_SWS_GETCONTEXT
-#define FF_API_SWS_GETCONTEXT (LIBSWSCALE_VERSION_MAJOR < 3)
-#endif
-#ifndef FF_API_SWS_CPU_CAPS
-#define FF_API_SWS_CPU_CAPS (LIBSWSCALE_VERSION_MAJOR < 3)
-#endif
-#ifndef FF_API_SWS_FORMAT_NAME
-#define FF_API_SWS_FORMAT_NAME (LIBSWSCALE_VERSION_MAJOR < 3)
-#endif
-
-#endif /* SWSCALE_VERSION_H */
diff --git a/src/thirdparty/ffmpeg/libswscale/x86/input.asm b/src/thirdparty/ffmpeg/libswscale/x86/input.asm
deleted file mode 100644
index b0eff7127..000000000
--- a/src/thirdparty/ffmpeg/libswscale/x86/input.asm
+++ /dev/null
@@ -1,670 +0,0 @@
-;******************************************************************************
-;* x86-optimized input routines; does shuffling of packed
-;* YUV formats into individual planes, and converts RGB
-;* into YUV planes also.
-;* Copyright (c) 2012 Ronald S. Bultje <rsbultje@gmail.com>
-;*
-;* This file is part of Libav.
-;*
-;* Libav is free software; you can redistribute it and/or
-;* modify it under the terms of the GNU Lesser General Public
-;* License as published by the Free Software Foundation; either
-;* version 2.1 of the License, or (at your option) any later version.
-;*
-;* Libav is distributed in the hope that it will be useful,
-;* but WITHOUT ANY WARRANTY; without even the implied warranty of
-;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-;* Lesser General Public License for more details.
-;*
-;* You should have received a copy of the GNU Lesser General Public
-;* License along with Libav; if not, write to the Free Software
-;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-;******************************************************************************
-
-%include "libavutil/x86/x86util.asm"
-
-SECTION_RODATA
-
-%define RY 0x20DE
-%define GY 0x4087
-%define BY 0x0C88
-%define RU 0xECFF
-%define GU 0xDAC8
-%define BU 0x3838
-%define RV 0x3838
-%define GV 0xD0E3
-%define BV 0xF6E4
-
-rgb_Yrnd: times 4 dd 0x80100 ; 16.5 << 15
-rgb_UVrnd: times 4 dd 0x400100 ; 128.5 << 15
-bgr_Ycoeff_12x4: times 2 dw BY, GY, 0, BY
-bgr_Ycoeff_3x56: times 2 dw RY, 0, GY, RY
-rgb_Ycoeff_12x4: times 2 dw RY, GY, 0, RY
-rgb_Ycoeff_3x56: times 2 dw BY, 0, GY, BY
-bgr_Ucoeff_12x4: times 2 dw BU, GU, 0, BU
-bgr_Ucoeff_3x56: times 2 dw RU, 0, GU, RU
-rgb_Ucoeff_12x4: times 2 dw RU, GU, 0, RU
-rgb_Ucoeff_3x56: times 2 dw BU, 0, GU, BU
-bgr_Vcoeff_12x4: times 2 dw BV, GV, 0, BV
-bgr_Vcoeff_3x56: times 2 dw RV, 0, GV, RV
-rgb_Vcoeff_12x4: times 2 dw RV, GV, 0, RV
-rgb_Vcoeff_3x56: times 2 dw BV, 0, GV, BV
-
-rgba_Ycoeff_rb: times 4 dw RY, BY
-rgba_Ycoeff_br: times 4 dw BY, RY
-rgba_Ycoeff_ga: times 4 dw GY, 0
-rgba_Ycoeff_ag: times 4 dw 0, GY
-rgba_Ucoeff_rb: times 4 dw RU, BU
-rgba_Ucoeff_br: times 4 dw BU, RU
-rgba_Ucoeff_ga: times 4 dw GU, 0
-rgba_Ucoeff_ag: times 4 dw 0, GU
-rgba_Vcoeff_rb: times 4 dw RV, BV
-rgba_Vcoeff_br: times 4 dw BV, RV
-rgba_Vcoeff_ga: times 4 dw GV, 0
-rgba_Vcoeff_ag: times 4 dw 0, GV
-
-shuf_rgb_12x4: db 0, 0x80, 1, 0x80, 2, 0x80, 3, 0x80, \
- 6, 0x80, 7, 0x80, 8, 0x80, 9, 0x80
-shuf_rgb_3x56: db 2, 0x80, 3, 0x80, 4, 0x80, 5, 0x80, \
- 8, 0x80, 9, 0x80, 10, 0x80, 11, 0x80
-
-SECTION .text
-
-;-----------------------------------------------------------------------------
-; RGB to Y/UV.
-;
-; void <fmt>ToY_<opt>(uint8_t *dst, const uint8_t *src, int w);
-; and
-; void <fmt>toUV_<opt>(uint8_t *dstU, uint8_t *dstV, const uint8_t *src,
-; const uint8_t *unused, int w);
-;-----------------------------------------------------------------------------
-
-; %1 = nr. of XMM registers
-; %2 = rgb or bgr
-%macro RGB24_TO_Y_FN 2-3
-cglobal %2 %+ 24ToY, 6, 6, %1, dst, src, u1, u2, w, u3
-%if mmsize == 8
- mova m5, [%2_Ycoeff_12x4]
- mova m6, [%2_Ycoeff_3x56]
-%define coeff1 m5
-%define coeff2 m6
-%elif ARCH_X86_64
- mova m8, [%2_Ycoeff_12x4]
- mova m9, [%2_Ycoeff_3x56]
-%define coeff1 m8
-%define coeff2 m9
-%else ; x86-32 && mmsize == 16
-%define coeff1 [%2_Ycoeff_12x4]
-%define coeff2 [%2_Ycoeff_3x56]
-%endif ; x86-32/64 && mmsize == 8/16
-%if (ARCH_X86_64 || mmsize == 8) && %0 == 3
- jmp mangle(private_prefix %+ _ %+ %3 %+ 24ToY %+ SUFFIX).body
-%else ; (ARCH_X86_64 && %0 == 3) || mmsize == 8
-.body:
-%if cpuflag(ssse3)
- mova m7, [shuf_rgb_12x4]
-%define shuf_rgb1 m7
-%if ARCH_X86_64
- mova m10, [shuf_rgb_3x56]
-%define shuf_rgb2 m10
-%else ; x86-32
-%define shuf_rgb2 [shuf_rgb_3x56]
-%endif ; x86-32/64
-%endif ; cpuflag(ssse3)
-%if ARCH_X86_64
- movsxd wq, wd
-%endif
- add wq, wq
- add dstq, wq
- neg wq
-%if notcpuflag(ssse3)
- pxor m7, m7
-%endif ; !cpuflag(ssse3)
- mova m4, [rgb_Yrnd]
-.loop:
-%if cpuflag(ssse3)
- movu m0, [srcq+0] ; (byte) { Bx, Gx, Rx }[0-3]
- movu m2, [srcq+12] ; (byte) { Bx, Gx, Rx }[4-7]
- pshufb m1, m0, shuf_rgb2 ; (word) { R0, B1, G1, R1, R2, B3, G3, R3 }
- pshufb m0, shuf_rgb1 ; (word) { B0, G0, R0, B1, B2, G2, R2, B3 }
- pshufb m3, m2, shuf_rgb2 ; (word) { R4, B5, G5, R5, R6, B7, G7, R7 }
- pshufb m2, shuf_rgb1 ; (word) { B4, G4, R4, B5, B6, G6, R6, B7 }
-%else ; !cpuflag(ssse3)
- movd m0, [srcq+0] ; (byte) { B0, G0, R0, B1 }
- movd m1, [srcq+2] ; (byte) { R0, B1, G1, R1 }
- movd m2, [srcq+6] ; (byte) { B2, G2, R2, B3 }
- movd m3, [srcq+8] ; (byte) { R2, B3, G3, R3 }
-%if mmsize == 16 ; i.e. sse2
- punpckldq m0, m2 ; (byte) { B0, G0, R0, B1, B2, G2, R2, B3 }
- punpckldq m1, m3 ; (byte) { R0, B1, G1, R1, R2, B3, G3, R3 }
- movd m2, [srcq+12] ; (byte) { B4, G4, R4, B5 }
- movd m3, [srcq+14] ; (byte) { R4, B5, G5, R5 }
- movd m5, [srcq+18] ; (byte) { B6, G6, R6, B7 }
- movd m6, [srcq+20] ; (byte) { R6, B7, G7, R7 }
- punpckldq m2, m5 ; (byte) { B4, G4, R4, B5, B6, G6, R6, B7 }
- punpckldq m3, m6 ; (byte) { R4, B5, G5, R5, R6, B7, G7, R7 }
-%endif ; mmsize == 16
- punpcklbw m0, m7 ; (word) { B0, G0, R0, B1, B2, G2, R2, B3 }
- punpcklbw m1, m7 ; (word) { R0, B1, G1, R1, R2, B3, G3, R3 }
- punpcklbw m2, m7 ; (word) { B4, G4, R4, B5, B6, G6, R6, B7 }
- punpcklbw m3, m7 ; (word) { R4, B5, G5, R5, R6, B7, G7, R7 }
-%endif ; cpuflag(ssse3)
- add srcq, 3 * mmsize / 2
- pmaddwd m0, coeff1 ; (dword) { B0*BY + G0*GY, B1*BY, B2*BY + G2*GY, B3*BY }
- pmaddwd m1, coeff2 ; (dword) { R0*RY, G1+GY + R1*RY, R2*RY, G3+GY + R3*RY }
- pmaddwd m2, coeff1 ; (dword) { B4*BY + G4*GY, B5*BY, B6*BY + G6*GY, B7*BY }
- pmaddwd m3, coeff2 ; (dword) { R4*RY, G5+GY + R5*RY, R6*RY, G7+GY + R7*RY }
- paddd m0, m1 ; (dword) { Bx*BY + Gx*GY + Rx*RY }[0-3]
- paddd m2, m3 ; (dword) { Bx*BY + Gx*GY + Rx*RY }[4-7]
- paddd m0, m4 ; += rgb_Yrnd, i.e. (dword) { Y[0-3] }
- paddd m2, m4 ; += rgb_Yrnd, i.e. (dword) { Y[4-7] }
- psrad m0, 9
- psrad m2, 9
- packssdw m0, m2 ; (word) { Y[0-7] }
- mova [dstq+wq], m0
- add wq, mmsize
- jl .loop
- REP_RET
-%endif ; (ARCH_X86_64 && %0 == 3) || mmsize == 8
-%endmacro
-
-; %1 = nr. of XMM registers
-; %2 = rgb or bgr
-%macro RGB24_TO_UV_FN 2-3
-cglobal %2 %+ 24ToUV, 7, 7, %1, dstU, dstV, u1, src, u2, w, u3
-%if ARCH_X86_64
- mova m8, [%2_Ucoeff_12x4]
- mova m9, [%2_Ucoeff_3x56]
- mova m10, [%2_Vcoeff_12x4]
- mova m11, [%2_Vcoeff_3x56]
-%define coeffU1 m8
-%define coeffU2 m9
-%define coeffV1 m10
-%define coeffV2 m11
-%else ; x86-32
-%define coeffU1 [%2_Ucoeff_12x4]
-%define coeffU2 [%2_Ucoeff_3x56]
-%define coeffV1 [%2_Vcoeff_12x4]
-%define coeffV2 [%2_Vcoeff_3x56]
-%endif ; x86-32/64
-%if ARCH_X86_64 && %0 == 3
- jmp mangle(private_prefix %+ _ %+ %3 %+ 24ToUV %+ SUFFIX).body
-%else ; ARCH_X86_64 && %0 == 3
-.body:
-%if cpuflag(ssse3)
- mova m7, [shuf_rgb_12x4]
-%define shuf_rgb1 m7
-%if ARCH_X86_64
- mova m12, [shuf_rgb_3x56]
-%define shuf_rgb2 m12
-%else ; x86-32
-%define shuf_rgb2 [shuf_rgb_3x56]
-%endif ; x86-32/64
-%endif ; cpuflag(ssse3)
-%if ARCH_X86_64
- movsxd wq, dword r5m
-%else ; x86-32
- mov wq, r5m
-%endif
- add wq, wq
- add dstUq, wq
- add dstVq, wq
- neg wq
- mova m6, [rgb_UVrnd]
-%if notcpuflag(ssse3)
- pxor m7, m7
-%endif
-.loop:
-%if cpuflag(ssse3)
- movu m0, [srcq+0] ; (byte) { Bx, Gx, Rx }[0-3]
- movu m4, [srcq+12] ; (byte) { Bx, Gx, Rx }[4-7]
- pshufb m1, m0, shuf_rgb2 ; (word) { R0, B1, G1, R1, R2, B3, G3, R3 }
- pshufb m0, shuf_rgb1 ; (word) { B0, G0, R0, B1, B2, G2, R2, B3 }
-%else ; !cpuflag(ssse3)
- movd m0, [srcq+0] ; (byte) { B0, G0, R0, B1 }
- movd m1, [srcq+2] ; (byte) { R0, B1, G1, R1 }
- movd m4, [srcq+6] ; (byte) { B2, G2, R2, B3 }
- movd m5, [srcq+8] ; (byte) { R2, B3, G3, R3 }
-%if mmsize == 16
- punpckldq m0, m4 ; (byte) { B0, G0, R0, B1, B2, G2, R2, B3 }
- punpckldq m1, m5 ; (byte) { R0, B1, G1, R1, R2, B3, G3, R3 }
- movd m4, [srcq+12] ; (byte) { B4, G4, R4, B5 }
- movd m5, [srcq+14] ; (byte) { R4, B5, G5, R5 }
-%endif ; mmsize == 16
- punpcklbw m0, m7 ; (word) { B0, G0, R0, B1, B2, G2, R2, B3 }
- punpcklbw m1, m7 ; (word) { R0, B1, G1, R1, R2, B3, G3, R3 }
-%endif ; cpuflag(ssse3)
- pmaddwd m2, m0, coeffV1 ; (dword) { B0*BV + G0*GV, B1*BV, B2*BV + G2*GV, B3*BV }
- pmaddwd m3, m1, coeffV2 ; (dword) { R0*BV, G1*GV + R1*BV, R2*BV, G3*GV + R3*BV }
- pmaddwd m0, coeffU1 ; (dword) { B0*BU + G0*GU, B1*BU, B2*BU + G2*GU, B3*BU }
- pmaddwd m1, coeffU2 ; (dword) { R0*BU, G1*GU + R1*BU, R2*BU, G3*GU + R3*BU }
- paddd m0, m1 ; (dword) { Bx*BU + Gx*GU + Rx*RU }[0-3]
- paddd m2, m3 ; (dword) { Bx*BV + Gx*GV + Rx*RV }[0-3]
-%if cpuflag(ssse3)
- pshufb m5, m4, shuf_rgb2 ; (word) { R4, B5, G5, R5, R6, B7, G7, R7 }
- pshufb m4, shuf_rgb1 ; (word) { B4, G4, R4, B5, B6, G6, R6, B7 }
-%else ; !cpuflag(ssse3)
-%if mmsize == 16
- movd m1, [srcq+18] ; (byte) { B6, G6, R6, B7 }
- movd m3, [srcq+20] ; (byte) { R6, B7, G7, R7 }
- punpckldq m4, m1 ; (byte) { B4, G4, R4, B5, B6, G6, R6, B7 }
- punpckldq m5, m3 ; (byte) { R4, B5, G5, R5, R6, B7, G7, R7 }
-%endif ; mmsize == 16 && !cpuflag(ssse3)
- punpcklbw m4, m7 ; (word) { B4, G4, R4, B5, B6, G6, R6, B7 }
- punpcklbw m5, m7 ; (word) { R4, B5, G5, R5, R6, B7, G7, R7 }
-%endif ; cpuflag(ssse3)
- add srcq, 3 * mmsize / 2
- pmaddwd m1, m4, coeffU1 ; (dword) { B4*BU + G4*GU, B5*BU, B6*BU + G6*GU, B7*BU }
- pmaddwd m3, m5, coeffU2 ; (dword) { R4*BU, G5*GU + R5*BU, R6*BU, G7*GU + R7*BU }
- pmaddwd m4, coeffV1 ; (dword) { B4*BV + G4*GV, B5*BV, B6*BV + G6*GV, B7*BV }
- pmaddwd m5, coeffV2 ; (dword) { R4*BV, G5*GV + R5*BV, R6*BV, G7*GV + R7*BV }
- paddd m1, m3 ; (dword) { Bx*BU + Gx*GU + Rx*RU }[4-7]
- paddd m4, m5 ; (dword) { Bx*BV + Gx*GV + Rx*RV }[4-7]
- paddd m0, m6 ; += rgb_UVrnd, i.e. (dword) { U[0-3] }
- paddd m2, m6 ; += rgb_UVrnd, i.e. (dword) { V[0-3] }
- paddd m1, m6 ; += rgb_UVrnd, i.e. (dword) { U[4-7] }
- paddd m4, m6 ; += rgb_UVrnd, i.e. (dword) { V[4-7] }
- psrad m0, 9
- psrad m2, 9
- psrad m1, 9
- psrad m4, 9
- packssdw m0, m1 ; (word) { U[0-7] }
- packssdw m2, m4 ; (word) { V[0-7] }
-%if mmsize == 8
- mova [dstUq+wq], m0
- mova [dstVq+wq], m2
-%else ; mmsize == 16
- mova [dstUq+wq], m0
- mova [dstVq+wq], m2
-%endif ; mmsize == 8/16
- add wq, mmsize
- jl .loop
- REP_RET
-%endif ; ARCH_X86_64 && %0 == 3
-%endmacro
-
-; %1 = nr. of XMM registers for rgb-to-Y func
-; %2 = nr. of XMM registers for rgb-to-UV func
-%macro RGB24_FUNCS 2
-RGB24_TO_Y_FN %1, rgb
-RGB24_TO_Y_FN %1, bgr, rgb
-RGB24_TO_UV_FN %2, rgb
-RGB24_TO_UV_FN %2, bgr, rgb
-%endmacro
-
-%if ARCH_X86_32
-INIT_MMX mmx
-RGB24_FUNCS 0, 0
-%endif
-
-INIT_XMM sse2
-RGB24_FUNCS 10, 12
-
-INIT_XMM ssse3
-RGB24_FUNCS 11, 13
-
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-RGB24_FUNCS 11, 13
-%endif
-
-; %1 = nr. of XMM registers
-; %2-5 = rgba, bgra, argb or abgr (in individual characters)
-%macro RGB32_TO_Y_FN 5-6
-cglobal %2%3%4%5 %+ ToY, 6, 6, %1, dst, src, u1, u2, w, u3
- mova m5, [rgba_Ycoeff_%2%4]
- mova m6, [rgba_Ycoeff_%3%5]
-%if %0 == 6
- jmp mangle(private_prefix %+ _ %+ %6 %+ ToY %+ SUFFIX).body
-%else ; %0 == 6
-.body:
-%if ARCH_X86_64
- movsxd wq, wd
-%endif
- lea srcq, [srcq+wq*4]
- add wq, wq
- add dstq, wq
- neg wq
- mova m4, [rgb_Yrnd]
- pcmpeqb m7, m7
- psrlw m7, 8 ; (word) { 0x00ff } x4
-.loop:
- ; FIXME check alignment and use mova
- movu m0, [srcq+wq*2+0] ; (byte) { Bx, Gx, Rx, xx }[0-3]
- movu m2, [srcq+wq*2+mmsize] ; (byte) { Bx, Gx, Rx, xx }[4-7]
- DEINTB 1, 0, 3, 2, 7 ; (word) { Gx, xx (m0/m2) or Bx, Rx (m1/m3) }[0-3]/[4-7]
- pmaddwd m1, m5 ; (dword) { Bx*BY + Rx*RY }[0-3]
- pmaddwd m0, m6 ; (dword) { Gx*GY }[0-3]
- pmaddwd m3, m5 ; (dword) { Bx*BY + Rx*RY }[4-7]
- pmaddwd m2, m6 ; (dword) { Gx*GY }[4-7]
- paddd m0, m4 ; += rgb_Yrnd
- paddd m2, m4 ; += rgb_Yrnd
- paddd m0, m1 ; (dword) { Y[0-3] }
- paddd m2, m3 ; (dword) { Y[4-7] }
- psrad m0, 9
- psrad m2, 9
- packssdw m0, m2 ; (word) { Y[0-7] }
- mova [dstq+wq], m0
- add wq, mmsize
- jl .loop
- REP_RET
-%endif ; %0 == 3
-%endmacro
-
-; %1 = nr. of XMM registers
-; %2-5 = rgba, bgra, argb or abgr (in individual characters)
-%macro RGB32_TO_UV_FN 5-6
-cglobal %2%3%4%5 %+ ToUV, 7, 7, %1, dstU, dstV, u1, src, u2, w, u3
-%if ARCH_X86_64
- mova m8, [rgba_Ucoeff_%2%4]
- mova m9, [rgba_Ucoeff_%3%5]
- mova m10, [rgba_Vcoeff_%2%4]
- mova m11, [rgba_Vcoeff_%3%5]
-%define coeffU1 m8
-%define coeffU2 m9
-%define coeffV1 m10
-%define coeffV2 m11
-%else ; x86-32
-%define coeffU1 [rgba_Ucoeff_%2%4]
-%define coeffU2 [rgba_Ucoeff_%3%5]
-%define coeffV1 [rgba_Vcoeff_%2%4]
-%define coeffV2 [rgba_Vcoeff_%3%5]
-%endif ; x86-64/32
-%if ARCH_X86_64 && %0 == 6
- jmp mangle(private_prefix %+ _ %+ %6 %+ ToUV %+ SUFFIX).body
-%else ; ARCH_X86_64 && %0 == 6
-.body:
-%if ARCH_X86_64
- movsxd wq, dword r5m
-%else ; x86-32
- mov wq, r5m
-%endif
- add wq, wq
- add dstUq, wq
- add dstVq, wq
- lea srcq, [srcq+wq*2]
- neg wq
- pcmpeqb m7, m7
- psrlw m7, 8 ; (word) { 0x00ff } x4
- mova m6, [rgb_UVrnd]
-.loop:
- ; FIXME check alignment and use mova
- movu m0, [srcq+wq*2+0] ; (byte) { Bx, Gx, Rx, xx }[0-3]
- movu m4, [srcq+wq*2+mmsize] ; (byte) { Bx, Gx, Rx, xx }[4-7]
- DEINTB 1, 0, 5, 4, 7 ; (word) { Gx, xx (m0/m4) or Bx, Rx (m1/m5) }[0-3]/[4-7]
- pmaddwd m3, m1, coeffV1 ; (dword) { Bx*BV + Rx*RV }[0-3]
- pmaddwd m2, m0, coeffV2 ; (dword) { Gx*GV }[0-3]
- pmaddwd m1, coeffU1 ; (dword) { Bx*BU + Rx*RU }[0-3]
- pmaddwd m0, coeffU2 ; (dword) { Gx*GU }[0-3]
- paddd m3, m6 ; += rgb_UVrnd
- paddd m1, m6 ; += rgb_UVrnd
- paddd m2, m3 ; (dword) { V[0-3] }
- paddd m0, m1 ; (dword) { U[0-3] }
- pmaddwd m3, m5, coeffV1 ; (dword) { Bx*BV + Rx*RV }[4-7]
- pmaddwd m1, m4, coeffV2 ; (dword) { Gx*GV }[4-7]
- pmaddwd m5, coeffU1 ; (dword) { Bx*BU + Rx*RU }[4-7]
- pmaddwd m4, coeffU2 ; (dword) { Gx*GU }[4-7]
- paddd m3, m6 ; += rgb_UVrnd
- paddd m5, m6 ; += rgb_UVrnd
- psrad m0, 9
- paddd m1, m3 ; (dword) { V[4-7] }
- paddd m4, m5 ; (dword) { U[4-7] }
- psrad m2, 9
- psrad m4, 9
- psrad m1, 9
- packssdw m0, m4 ; (word) { U[0-7] }
- packssdw m2, m1 ; (word) { V[0-7] }
-%if mmsize == 8
- mova [dstUq+wq], m0
- mova [dstVq+wq], m2
-%else ; mmsize == 16
- mova [dstUq+wq], m0
- mova [dstVq+wq], m2
-%endif ; mmsize == 8/16
- add wq, mmsize
- jl .loop
- REP_RET
-%endif ; ARCH_X86_64 && %0 == 3
-%endmacro
-
-; %1 = nr. of XMM registers for rgb-to-Y func
-; %2 = nr. of XMM registers for rgb-to-UV func
-%macro RGB32_FUNCS 2
-RGB32_TO_Y_FN %1, r, g, b, a
-RGB32_TO_Y_FN %1, b, g, r, a, rgba
-RGB32_TO_Y_FN %1, a, r, g, b, rgba
-RGB32_TO_Y_FN %1, a, b, g, r, rgba
-
-RGB32_TO_UV_FN %2, r, g, b, a
-RGB32_TO_UV_FN %2, b, g, r, a, rgba
-RGB32_TO_UV_FN %2, a, r, g, b, rgba
-RGB32_TO_UV_FN %2, a, b, g, r, rgba
-%endmacro
-
-%if ARCH_X86_32
-INIT_MMX mmx
-RGB32_FUNCS 0, 0
-%endif
-
-INIT_XMM sse2
-RGB32_FUNCS 8, 12
-
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-RGB32_FUNCS 8, 12
-%endif
-
-;-----------------------------------------------------------------------------
-; YUYV/UYVY/NV12/NV21 packed pixel shuffling.
-;
-; void <fmt>ToY_<opt>(uint8_t *dst, const uint8_t *src, int w);
-; and
-; void <fmt>toUV_<opt>(uint8_t *dstU, uint8_t *dstV, const uint8_t *src,
-; const uint8_t *unused, int w);
-;-----------------------------------------------------------------------------
-
-; %1 = a (aligned) or u (unaligned)
-; %2 = yuyv or uyvy
-%macro LOOP_YUYV_TO_Y 2
-.loop_%1:
- mov%1 m0, [srcq+wq*2] ; (byte) { Y0, U0, Y1, V0, ... }
- mov%1 m1, [srcq+wq*2+mmsize] ; (byte) { Y8, U4, Y9, V4, ... }
-%ifidn %2, yuyv
- pand m0, m2 ; (word) { Y0, Y1, ..., Y7 }
- pand m1, m2 ; (word) { Y8, Y9, ..., Y15 }
-%else ; uyvy
- psrlw m0, 8 ; (word) { Y0, Y1, ..., Y7 }
- psrlw m1, 8 ; (word) { Y8, Y9, ..., Y15 }
-%endif ; yuyv/uyvy
- packuswb m0, m1 ; (byte) { Y0, ..., Y15 }
- mova [dstq+wq], m0
- add wq, mmsize
- jl .loop_%1
- REP_RET
-%endmacro
-
-; %1 = nr. of XMM registers
-; %2 = yuyv or uyvy
-; %3 = if specified, it means that unaligned and aligned code in loop
-; will be the same (i.e. YUYV+AVX), and thus we don't need to
-; split the loop in an aligned and unaligned case
-%macro YUYV_TO_Y_FN 2-3
-cglobal %2ToY, 5, 5, %1, dst, unused0, unused1, src, w
-%if ARCH_X86_64
- movsxd wq, wd
-%endif
- add dstq, wq
-%if mmsize == 16
- test srcq, 15
-%endif
- lea srcq, [srcq+wq*2]
-%ifidn %2, yuyv
- pcmpeqb m2, m2 ; (byte) { 0xff } x 16
- psrlw m2, 8 ; (word) { 0x00ff } x 8
-%endif ; yuyv
-%if mmsize == 16
- jnz .loop_u_start
- neg wq
- LOOP_YUYV_TO_Y a, %2
-.loop_u_start:
- neg wq
- LOOP_YUYV_TO_Y u, %2
-%else ; mmsize == 8
- neg wq
- LOOP_YUYV_TO_Y a, %2
-%endif ; mmsize == 8/16
-%endmacro
-
-; %1 = a (aligned) or u (unaligned)
-; %2 = yuyv or uyvy
-%macro LOOP_YUYV_TO_UV 2
-.loop_%1:
-%ifidn %2, yuyv
- mov%1 m0, [srcq+wq*4] ; (byte) { Y0, U0, Y1, V0, ... }
- mov%1 m1, [srcq+wq*4+mmsize] ; (byte) { Y8, U4, Y9, V4, ... }
- psrlw m0, 8 ; (word) { U0, V0, ..., U3, V3 }
- psrlw m1, 8 ; (word) { U4, V4, ..., U7, V7 }
-%else ; uyvy
-%if cpuflag(avx)
- vpand m0, m2, [srcq+wq*4] ; (word) { U0, V0, ..., U3, V3 }
- vpand m1, m2, [srcq+wq*4+mmsize] ; (word) { U4, V4, ..., U7, V7 }
-%else
- mov%1 m0, [srcq+wq*4] ; (byte) { Y0, U0, Y1, V0, ... }
- mov%1 m1, [srcq+wq*4+mmsize] ; (byte) { Y8, U4, Y9, V4, ... }
- pand m0, m2 ; (word) { U0, V0, ..., U3, V3 }
- pand m1, m2 ; (word) { U4, V4, ..., U7, V7 }
-%endif
-%endif ; yuyv/uyvy
- packuswb m0, m1 ; (byte) { U0, V0, ..., U7, V7 }
- pand m1, m0, m2 ; (word) { U0, U1, ..., U7 }
- psrlw m0, 8 ; (word) { V0, V1, ..., V7 }
-%if mmsize == 16
- packuswb m1, m0 ; (byte) { U0, ... U7, V1, ... V7 }
- movh [dstUq+wq], m1
- movhps [dstVq+wq], m1
-%else ; mmsize == 8
- packuswb m1, m1 ; (byte) { U0, ... U3 }
- packuswb m0, m0 ; (byte) { V0, ... V3 }
- movh [dstUq+wq], m1
- movh [dstVq+wq], m0
-%endif ; mmsize == 8/16
- add wq, mmsize / 2
- jl .loop_%1
- REP_RET
-%endmacro
-
-; %1 = nr. of XMM registers
-; %2 = yuyv or uyvy
-; %3 = if specified, it means that unaligned and aligned code in loop
-; will be the same (i.e. UYVY+AVX), and thus we don't need to
-; split the loop in an aligned and unaligned case
-%macro YUYV_TO_UV_FN 2-3
-cglobal %2ToUV, 4, 5, %1, dstU, dstV, unused, src, w
-%if ARCH_X86_64
- movsxd wq, dword r5m
-%else ; x86-32
- mov wq, r5m
-%endif
- add dstUq, wq
- add dstVq, wq
-%if mmsize == 16 && %0 == 2
- test srcq, 15
-%endif
- lea srcq, [srcq+wq*4]
- pcmpeqb m2, m2 ; (byte) { 0xff } x 16
- psrlw m2, 8 ; (word) { 0x00ff } x 8
- ; NOTE: if uyvy+avx, u/a are identical
-%if mmsize == 16 && %0 == 2
- jnz .loop_u_start
- neg wq
- LOOP_YUYV_TO_UV a, %2
-.loop_u_start:
- neg wq
- LOOP_YUYV_TO_UV u, %2
-%else ; mmsize == 8
- neg wq
- LOOP_YUYV_TO_UV a, %2
-%endif ; mmsize == 8/16
-%endmacro
-
-; %1 = a (aligned) or u (unaligned)
-; %2 = nv12 or nv21
-%macro LOOP_NVXX_TO_UV 2
-.loop_%1:
- mov%1 m0, [srcq+wq*2] ; (byte) { U0, V0, U1, V1, ... }
- mov%1 m1, [srcq+wq*2+mmsize] ; (byte) { U8, V8, U9, V9, ... }
- pand m2, m0, m5 ; (word) { U0, U1, ..., U7 }
- pand m3, m1, m5 ; (word) { U8, U9, ..., U15 }
- psrlw m0, 8 ; (word) { V0, V1, ..., V7 }
- psrlw m1, 8 ; (word) { V8, V9, ..., V15 }
- packuswb m2, m3 ; (byte) { U0, ..., U15 }
- packuswb m0, m1 ; (byte) { V0, ..., V15 }
-%ifidn %2, nv12
- mova [dstUq+wq], m2
- mova [dstVq+wq], m0
-%else ; nv21
- mova [dstVq+wq], m2
- mova [dstUq+wq], m0
-%endif ; nv12/21
- add wq, mmsize
- jl .loop_%1
- REP_RET
-%endmacro
-
-; %1 = nr. of XMM registers
-; %2 = nv12 or nv21
-%macro NVXX_TO_UV_FN 2
-cglobal %2ToUV, 4, 5, %1, dstU, dstV, unused, src, w
-%if ARCH_X86_64
- movsxd wq, dword r5m
-%else ; x86-32
- mov wq, r5m
-%endif
- add dstUq, wq
- add dstVq, wq
-%if mmsize == 16
- test srcq, 15
-%endif
- lea srcq, [srcq+wq*2]
- pcmpeqb m5, m5 ; (byte) { 0xff } x 16
- psrlw m5, 8 ; (word) { 0x00ff } x 8
-%if mmsize == 16
- jnz .loop_u_start
- neg wq
- LOOP_NVXX_TO_UV a, %2
-.loop_u_start:
- neg wq
- LOOP_NVXX_TO_UV u, %2
-%else ; mmsize == 8
- neg wq
- LOOP_NVXX_TO_UV a, %2
-%endif ; mmsize == 8/16
-%endmacro
-
-%if ARCH_X86_32
-INIT_MMX mmx
-YUYV_TO_Y_FN 0, yuyv
-YUYV_TO_Y_FN 0, uyvy
-YUYV_TO_UV_FN 0, yuyv
-YUYV_TO_UV_FN 0, uyvy
-NVXX_TO_UV_FN 0, nv12
-NVXX_TO_UV_FN 0, nv21
-%endif
-
-INIT_XMM sse2
-YUYV_TO_Y_FN 3, yuyv
-YUYV_TO_Y_FN 2, uyvy
-YUYV_TO_UV_FN 3, yuyv
-YUYV_TO_UV_FN 3, uyvy
-NVXX_TO_UV_FN 5, nv12
-NVXX_TO_UV_FN 5, nv21
-
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-; in theory, we could write a yuy2-to-y using vpand (i.e. AVX), but
-; that's not faster in practice
-YUYV_TO_UV_FN 3, yuyv
-YUYV_TO_UV_FN 3, uyvy, 1
-NVXX_TO_UV_FN 5, nv12
-NVXX_TO_UV_FN 5, nv21
-%endif
diff --git a/src/thirdparty/ffmpeg/libswscale/x86/output.asm b/src/thirdparty/ffmpeg/libswscale/x86/output.asm
deleted file mode 100644
index c08480bd9..000000000
--- a/src/thirdparty/ffmpeg/libswscale/x86/output.asm
+++ /dev/null
@@ -1,413 +0,0 @@
-;******************************************************************************
-;* x86-optimized vertical line scaling functions
-;* Copyright (c) 2011 Ronald S. Bultje <rsbultje@gmail.com>
-;* Kieran Kunhya <kieran@kunhya.com>
-;*
-;* This file is part of Libav.
-;*
-;* Libav is free software; you can redistribute it and/or
-;* modify it under the terms of the GNU Lesser General Public
-;* License as published by the Free Software Foundation; either
-;* version 2.1 of the License, or (at your option) any later version.
-;*
-;* Libav is distributed in the hope that it will be useful,
-;* but WITHOUT ANY WARRANTY; without even the implied warranty of
-;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-;* Lesser General Public License for more details.
-;*
-;* You should have received a copy of the GNU Lesser General Public
-;* License along with Libav; if not, write to the Free Software
-;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-;******************************************************************************
-
-%include "libavutil/x86/x86util.asm"
-
-SECTION_RODATA
-
-minshort: times 8 dw 0x8000
-yuv2yuvX_16_start: times 4 dd 0x4000 - 0x40000000
-yuv2yuvX_10_start: times 4 dd 0x10000
-yuv2yuvX_9_start: times 4 dd 0x20000
-yuv2yuvX_10_upper: times 8 dw 0x3ff
-yuv2yuvX_9_upper: times 8 dw 0x1ff
-pd_4: times 4 dd 4
-pd_4min0x40000:times 4 dd 4 - (0x40000)
-pw_16: times 8 dw 16
-pw_32: times 8 dw 32
-pw_512: times 8 dw 512
-pw_1024: times 8 dw 1024
-
-SECTION .text
-
-;-----------------------------------------------------------------------------
-; vertical line scaling
-;
-; void yuv2plane1_<output_size>_<opt>(const int16_t *src, uint8_t *dst, int dstW,
-; const uint8_t *dither, int offset)
-; and
-; void yuv2planeX_<output_size>_<opt>(const int16_t *filter, int filterSize,
-; const int16_t **src, uint8_t *dst, int dstW,
-; const uint8_t *dither, int offset)
-;
-; Scale one or $filterSize lines of source data to generate one line of output
-; data. The input is 15-bit in int16_t if $output_size is [8,10] and 19-bit in
-; int32_t if $output_size is 16. $filter is 12-bits. $filterSize is a multiple
-; of 2. $offset is either 0 or 3. $dither holds 8 values.
-;-----------------------------------------------------------------------------
-
-%macro yuv2planeX_fn 3
-
-%if ARCH_X86_32
-%define cntr_reg fltsizeq
-%define movsx mov
-%else
-%define cntr_reg r7
-%define movsx movsxd
-%endif
-
-cglobal yuv2planeX_%1, %3, 8, %2, filter, fltsize, src, dst, w, dither, offset
-%if %1 == 8 || %1 == 9 || %1 == 10
- pxor m6, m6
-%endif ; %1 == 8/9/10
-
-%if %1 == 8
-%if ARCH_X86_32
-%assign pad 0x2c - (stack_offset & 15)
- SUB rsp, pad
-%define m_dith m7
-%else ; x86-64
-%define m_dith m9
-%endif ; x86-32
-
- ; create registers holding dither
- movq m_dith, [ditherq] ; dither
- test offsetd, offsetd
- jz .no_rot
-%if mmsize == 16
- punpcklqdq m_dith, m_dith
-%endif ; mmsize == 16
- PALIGNR m_dith, m_dith, 3, m0
-.no_rot:
-%if mmsize == 16
- punpcklbw m_dith, m6
-%if ARCH_X86_64
- punpcklwd m8, m_dith, m6
- pslld m8, 12
-%else ; x86-32
- punpcklwd m5, m_dith, m6
- pslld m5, 12
-%endif ; x86-32/64
- punpckhwd m_dith, m6
- pslld m_dith, 12
-%if ARCH_X86_32
- mova [rsp+ 0], m5
- mova [rsp+16], m_dith
-%endif
-%else ; mmsize == 8
- punpcklbw m5, m_dith, m6
- punpckhbw m_dith, m6
- punpcklwd m4, m5, m6
- punpckhwd m5, m6
- punpcklwd m3, m_dith, m6
- punpckhwd m_dith, m6
- pslld m4, 12
- pslld m5, 12
- pslld m3, 12
- pslld m_dith, 12
- mova [rsp+ 0], m4
- mova [rsp+ 8], m5
- mova [rsp+16], m3
- mova [rsp+24], m_dith
-%endif ; mmsize == 8/16
-%endif ; %1 == 8
-
- xor r5, r5
-
-.pixelloop:
-%assign %%i 0
- ; the rep here is for the 8bit output mmx case, where dither covers
- ; 8 pixels but we can only handle 2 pixels per register, and thus 4
- ; pixels per iteration. In order to not have to keep track of where
- ; we are w.r.t. dithering, we unroll the mmx/8bit loop x2.
-%if %1 == 8
-%assign %%repcnt 16/mmsize
-%else
-%assign %%repcnt 1
-%endif
-
-%rep %%repcnt
-
-%if %1 == 8
-%if ARCH_X86_32
- mova m2, [rsp+mmsize*(0+%%i)]
- mova m1, [rsp+mmsize*(1+%%i)]
-%else ; x86-64
- mova m2, m8
- mova m1, m_dith
-%endif ; x86-32/64
-%else ; %1 == 9/10/16
- mova m1, [yuv2yuvX_%1_start]
- mova m2, m1
-%endif ; %1 == 8/9/10/16
- movsx cntr_reg, fltsizem
-.filterloop_ %+ %%i:
- ; input pixels
- mov r6, [srcq+gprsize*cntr_reg-2*gprsize]
-%if %1 == 16
- mova m3, [r6+r5*4]
- mova m5, [r6+r5*4+mmsize]
-%else ; %1 == 8/9/10
- mova m3, [r6+r5*2]
-%endif ; %1 == 8/9/10/16
- mov r6, [srcq+gprsize*cntr_reg-gprsize]
-%if %1 == 16
- mova m4, [r6+r5*4]
- mova m6, [r6+r5*4+mmsize]
-%else ; %1 == 8/9/10
- mova m4, [r6+r5*2]
-%endif ; %1 == 8/9/10/16
-
- ; coefficients
- movd m0, [filterq+2*cntr_reg-4] ; coeff[0], coeff[1]
-%if %1 == 16
- pshuflw m7, m0, 0 ; coeff[0]
- pshuflw m0, m0, 0x55 ; coeff[1]
- pmovsxwd m7, m7 ; word -> dword
- pmovsxwd m0, m0 ; word -> dword
-
- pmulld m3, m7
- pmulld m5, m7
- pmulld m4, m0
- pmulld m6, m0
-
- paddd m2, m3
- paddd m1, m5
- paddd m2, m4
- paddd m1, m6
-%else ; %1 == 10/9/8
- punpcklwd m5, m3, m4
- punpckhwd m3, m4
- SPLATD m0
-
- pmaddwd m5, m0
- pmaddwd m3, m0
-
- paddd m2, m5
- paddd m1, m3
-%endif ; %1 == 8/9/10/16
-
- sub cntr_reg, 2
- jg .filterloop_ %+ %%i
-
-%if %1 == 16
- psrad m2, 31 - %1
- psrad m1, 31 - %1
-%else ; %1 == 10/9/8
- psrad m2, 27 - %1
- psrad m1, 27 - %1
-%endif ; %1 == 8/9/10/16
-
-%if %1 == 8
- packssdw m2, m1
- packuswb m2, m2
- movh [dstq+r5*1], m2
-%else ; %1 == 9/10/16
-%if %1 == 16
- packssdw m2, m1
- paddw m2, [minshort]
-%else ; %1 == 9/10
-%if cpuflag(sse4)
- packusdw m2, m1
-%else ; mmxext/sse2
- packssdw m2, m1
- pmaxsw m2, m6
-%endif ; mmxext/sse2/sse4/avx
- pminsw m2, [yuv2yuvX_%1_upper]
-%endif ; %1 == 9/10/16
- mova [dstq+r5*2], m2
-%endif ; %1 == 8/9/10/16
-
- add r5, mmsize/2
- sub wd, mmsize/2
-
-%assign %%i %%i+2
-%endrep
- jg .pixelloop
-
-%if %1 == 8
-%if ARCH_X86_32
- ADD rsp, pad
- RET
-%else ; x86-64
- REP_RET
-%endif ; x86-32/64
-%else ; %1 == 9/10/16
- REP_RET
-%endif ; %1 == 8/9/10/16
-%endmacro
-
-%if ARCH_X86_32
-INIT_MMX mmxext
-yuv2planeX_fn 8, 0, 7
-yuv2planeX_fn 9, 0, 5
-yuv2planeX_fn 10, 0, 5
-%endif
-
-INIT_XMM sse2
-yuv2planeX_fn 8, 10, 7
-yuv2planeX_fn 9, 7, 5
-yuv2planeX_fn 10, 7, 5
-
-INIT_XMM sse4
-yuv2planeX_fn 8, 10, 7
-yuv2planeX_fn 9, 7, 5
-yuv2planeX_fn 10, 7, 5
-yuv2planeX_fn 16, 8, 5
-
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-yuv2planeX_fn 8, 10, 7
-yuv2planeX_fn 9, 7, 5
-yuv2planeX_fn 10, 7, 5
-%endif
-
-; %1=outout-bpc, %2=alignment (u/a)
-%macro yuv2plane1_mainloop 2
-.loop_%2:
-%if %1 == 8
- paddsw m0, m2, [srcq+wq*2+mmsize*0]
- paddsw m1, m3, [srcq+wq*2+mmsize*1]
- psraw m0, 7
- psraw m1, 7
- packuswb m0, m1
- mov%2 [dstq+wq], m0
-%elif %1 == 16
- paddd m0, m4, [srcq+wq*4+mmsize*0]
- paddd m1, m4, [srcq+wq*4+mmsize*1]
- paddd m2, m4, [srcq+wq*4+mmsize*2]
- paddd m3, m4, [srcq+wq*4+mmsize*3]
- psrad m0, 3
- psrad m1, 3
- psrad m2, 3
- psrad m3, 3
-%if cpuflag(sse4) ; avx/sse4
- packusdw m0, m1
- packusdw m2, m3
-%else ; mmx/sse2
- packssdw m0, m1
- packssdw m2, m3
- paddw m0, m5
- paddw m2, m5
-%endif ; mmx/sse2/sse4/avx
- mov%2 [dstq+wq*2+mmsize*0], m0
- mov%2 [dstq+wq*2+mmsize*1], m2
-%else ; %1 == 9/10
- paddsw m0, m2, [srcq+wq*2+mmsize*0]
- paddsw m1, m2, [srcq+wq*2+mmsize*1]
- psraw m0, 15 - %1
- psraw m1, 15 - %1
- pmaxsw m0, m4
- pmaxsw m1, m4
- pminsw m0, m3
- pminsw m1, m3
- mov%2 [dstq+wq*2+mmsize*0], m0
- mov%2 [dstq+wq*2+mmsize*1], m1
-%endif
- add wq, mmsize
- jl .loop_%2
-%endmacro
-
-%macro yuv2plane1_fn 3
-cglobal yuv2plane1_%1, %3, %3, %2, src, dst, w, dither, offset
- movsxdifnidn wq, wd
- add wq, mmsize - 1
- and wq, ~(mmsize - 1)
-%if %1 == 8
- add dstq, wq
-%else ; %1 != 8
- lea dstq, [dstq+wq*2]
-%endif ; %1 == 8
-%if %1 == 16
- lea srcq, [srcq+wq*4]
-%else ; %1 != 16
- lea srcq, [srcq+wq*2]
-%endif ; %1 == 16
- neg wq
-
-%if %1 == 8
- pxor m4, m4 ; zero
-
- ; create registers holding dither
- movq m3, [ditherq] ; dither
- test offsetd, offsetd
- jz .no_rot
-%if mmsize == 16
- punpcklqdq m3, m3
-%endif ; mmsize == 16
- PALIGNR m3, m3, 3, m2
-.no_rot:
-%if mmsize == 8
- mova m2, m3
- punpckhbw m3, m4 ; byte->word
- punpcklbw m2, m4 ; byte->word
-%else
- punpcklbw m3, m4
- mova m2, m3
-%endif
-%elif %1 == 9
- pxor m4, m4
- mova m3, [pw_512]
- mova m2, [pw_32]
-%elif %1 == 10
- pxor m4, m4
- mova m3, [pw_1024]
- mova m2, [pw_16]
-%else ; %1 == 16
-%if cpuflag(sse4) ; sse4/avx
- mova m4, [pd_4]
-%else ; mmx/sse2
- mova m4, [pd_4min0x40000]
- mova m5, [minshort]
-%endif ; mmx/sse2/sse4/avx
-%endif ; %1 == ..
-
- ; actual pixel scaling
-%if mmsize == 8
- yuv2plane1_mainloop %1, a
-%else ; mmsize == 16
- test dstq, 15
- jnz .unaligned
- yuv2plane1_mainloop %1, a
- REP_RET
-.unaligned:
- yuv2plane1_mainloop %1, u
-%endif ; mmsize == 8/16
- REP_RET
-%endmacro
-
-%if ARCH_X86_32
-INIT_MMX mmx
-yuv2plane1_fn 8, 0, 5
-yuv2plane1_fn 16, 0, 3
-
-INIT_MMX mmxext
-yuv2plane1_fn 9, 0, 3
-yuv2plane1_fn 10, 0, 3
-%endif
-
-INIT_XMM sse2
-yuv2plane1_fn 8, 5, 5
-yuv2plane1_fn 9, 5, 3
-yuv2plane1_fn 10, 5, 3
-yuv2plane1_fn 16, 6, 3
-
-INIT_XMM sse4
-yuv2plane1_fn 16, 5, 3
-
-%if HAVE_AVX_EXTERNAL
-INIT_XMM avx
-yuv2plane1_fn 8, 5, 5
-yuv2plane1_fn 9, 5, 3
-yuv2plane1_fn 10, 5, 3
-yuv2plane1_fn 16, 5, 3
-%endif
diff --git a/src/thirdparty/ffmpeg/libswscale/x86/rgb2rgb.c b/src/thirdparty/ffmpeg/libswscale/x86/rgb2rgb.c
deleted file mode 100644
index 6e05a5d38..000000000
--- a/src/thirdparty/ffmpeg/libswscale/x86/rgb2rgb.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * software RGB to RGB converter
- * pluralize by software PAL8 to RGB converter
- * software YUV to YUV converter
- * software YUV to RGB converter
- * Written by Nick Kurshev.
- * palette & YUV & runtime CPU stuff by Michael (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
- */
-
-#include <stdint.h>
-
-#include "config.h"
-#include "libavutil/attributes.h"
-#include "libavutil/x86/asm.h"
-#include "libavutil/x86/cpu.h"
-#include "libavutil/cpu.h"
-#include "libavutil/bswap.h"
-#include "libswscale/rgb2rgb.h"
-#include "libswscale/swscale.h"
-#include "libswscale/swscale_internal.h"
-
-#if HAVE_INLINE_ASM
-
-DECLARE_ASM_CONST(8, uint64_t, mmx_ff) = 0x00000000000000FFULL;
-DECLARE_ASM_CONST(8, uint64_t, mmx_null) = 0x0000000000000000ULL;
-DECLARE_ASM_CONST(8, uint64_t, mmx_one) = 0xFFFFFFFFFFFFFFFFULL;
-DECLARE_ASM_CONST(8, uint64_t, mask32b) = 0x000000FF000000FFULL;
-DECLARE_ASM_CONST(8, uint64_t, mask32g) = 0x0000FF000000FF00ULL;
-DECLARE_ASM_CONST(8, uint64_t, mask32r) = 0x00FF000000FF0000ULL;
-DECLARE_ASM_CONST(8, uint64_t, mask32a) = 0xFF000000FF000000ULL;
-DECLARE_ASM_CONST(8, uint64_t, mask32) = 0x00FFFFFF00FFFFFFULL;
-DECLARE_ASM_CONST(8, uint64_t, mask3216br) = 0x00F800F800F800F8ULL;
-DECLARE_ASM_CONST(8, uint64_t, mask3216g) = 0x0000FC000000FC00ULL;
-DECLARE_ASM_CONST(8, uint64_t, mask3215g) = 0x0000F8000000F800ULL;
-DECLARE_ASM_CONST(8, uint64_t, mul3216) = 0x2000000420000004ULL;
-DECLARE_ASM_CONST(8, uint64_t, mul3215) = 0x2000000820000008ULL;
-DECLARE_ASM_CONST(8, uint64_t, mask24b) = 0x00FF0000FF0000FFULL;
-DECLARE_ASM_CONST(8, uint64_t, mask24g) = 0xFF0000FF0000FF00ULL;
-DECLARE_ASM_CONST(8, uint64_t, mask24r) = 0x0000FF0000FF0000ULL;
-DECLARE_ASM_CONST(8, uint64_t, mask24l) = 0x0000000000FFFFFFULL;
-DECLARE_ASM_CONST(8, uint64_t, mask24h) = 0x0000FFFFFF000000ULL;
-DECLARE_ASM_CONST(8, uint64_t, mask24hh) = 0xffff000000000000ULL;
-DECLARE_ASM_CONST(8, uint64_t, mask24hhh) = 0xffffffff00000000ULL;
-DECLARE_ASM_CONST(8, uint64_t, mask24hhhh) = 0xffffffffffff0000ULL;
-DECLARE_ASM_CONST(8, uint64_t, mask15b) = 0x001F001F001F001FULL; /* 00000000 00011111 xxB */
-DECLARE_ASM_CONST(8, uint64_t, mask15rg) = 0x7FE07FE07FE07FE0ULL; /* 01111111 11100000 RGx */
-DECLARE_ASM_CONST(8, uint64_t, mask15s) = 0xFFE0FFE0FFE0FFE0ULL;
-DECLARE_ASM_CONST(8, uint64_t, mask15g) = 0x03E003E003E003E0ULL;
-DECLARE_ASM_CONST(8, uint64_t, mask15r) = 0x7C007C007C007C00ULL;
-#define mask16b mask15b
-DECLARE_ASM_CONST(8, uint64_t, mask16g) = 0x07E007E007E007E0ULL;
-DECLARE_ASM_CONST(8, uint64_t, mask16r) = 0xF800F800F800F800ULL;
-DECLARE_ASM_CONST(8, uint64_t, red_16mask) = 0x0000f8000000f800ULL;
-DECLARE_ASM_CONST(8, uint64_t, green_16mask) = 0x000007e0000007e0ULL;
-DECLARE_ASM_CONST(8, uint64_t, blue_16mask) = 0x0000001f0000001fULL;
-DECLARE_ASM_CONST(8, uint64_t, red_15mask) = 0x00007c0000007c00ULL;
-DECLARE_ASM_CONST(8, uint64_t, green_15mask) = 0x000003e0000003e0ULL;
-DECLARE_ASM_CONST(8, uint64_t, blue_15mask) = 0x0000001f0000001fULL;
-DECLARE_ASM_CONST(8, uint64_t, mul15_mid) = 0x4200420042004200ULL;
-DECLARE_ASM_CONST(8, uint64_t, mul15_hi) = 0x0210021002100210ULL;
-DECLARE_ASM_CONST(8, uint64_t, mul16_mid) = 0x2080208020802080ULL;
-
-#define RGB2YUV_SHIFT 8
-#define BY ((int)( 0.098*(1<<RGB2YUV_SHIFT)+0.5))
-#define BV ((int)(-0.071*(1<<RGB2YUV_SHIFT)+0.5))
-#define BU ((int)( 0.439*(1<<RGB2YUV_SHIFT)+0.5))
-#define GY ((int)( 0.504*(1<<RGB2YUV_SHIFT)+0.5))
-#define GV ((int)(-0.368*(1<<RGB2YUV_SHIFT)+0.5))
-#define GU ((int)(-0.291*(1<<RGB2YUV_SHIFT)+0.5))
-#define RY ((int)( 0.257*(1<<RGB2YUV_SHIFT)+0.5))
-#define RV ((int)( 0.439*(1<<RGB2YUV_SHIFT)+0.5))
-#define RU ((int)(-0.148*(1<<RGB2YUV_SHIFT)+0.5))
-
-// Note: We have C, MMX, MMXEXT, 3DNOW versions, there is no 3DNOW + MMXEXT one.
-
-#define COMPILE_TEMPLATE_MMXEXT 0
-#define COMPILE_TEMPLATE_AMD3DNOW 0
-#define COMPILE_TEMPLATE_SSE2 0
-
-//MMX versions
-#undef RENAME
-#define RENAME(a) a ## _MMX
-#include "rgb2rgb_template.c"
-
-// MMXEXT versions
-#undef RENAME
-#undef COMPILE_TEMPLATE_MMXEXT
-#define COMPILE_TEMPLATE_MMXEXT 1
-#define RENAME(a) a ## _MMXEXT
-#include "rgb2rgb_template.c"
-
-//SSE2 versions
-#undef RENAME
-#undef COMPILE_TEMPLATE_SSE2
-#define COMPILE_TEMPLATE_SSE2 1
-#define RENAME(a) a ## _SSE2
-#include "rgb2rgb_template.c"
-
-//3DNOW versions
-#undef RENAME
-#undef COMPILE_TEMPLATE_MMXEXT
-#undef COMPILE_TEMPLATE_SSE2
-#undef COMPILE_TEMPLATE_AMD3DNOW
-#define COMPILE_TEMPLATE_MMXEXT 0
-#define COMPILE_TEMPLATE_SSE2 0
-#define COMPILE_TEMPLATE_AMD3DNOW 1
-#define RENAME(a) a ## _3DNOW
-#include "rgb2rgb_template.c"
-
-/*
- RGB15->RGB16 original by Strepto/Astral
- ported to gcc & bugfixed : A'rpi
- MMXEXT, 3DNOW optimization by Nick Kurshev
- 32-bit C version, and and&add trick by Michael Niedermayer
-*/
-
-#endif /* HAVE_INLINE_ASM */
-
-av_cold void rgb2rgb_init_x86(void)
-{
-#if HAVE_INLINE_ASM
- int cpu_flags = av_get_cpu_flags();
-
- if (INLINE_MMX(cpu_flags))
- rgb2rgb_init_MMX();
- if (INLINE_AMD3DNOW(cpu_flags))
- rgb2rgb_init_3DNOW();
- if (INLINE_MMXEXT(cpu_flags))
- rgb2rgb_init_MMXEXT();
- if (INLINE_SSE2(cpu_flags))
- rgb2rgb_init_SSE2();
-#endif /* HAVE_INLINE_ASM */
-}
diff --git a/src/thirdparty/ffmpeg/libswscale/x86/rgb2rgb_template.c b/src/thirdparty/ffmpeg/libswscale/x86/rgb2rgb_template.c
deleted file mode 100644
index 8b239d195..000000000
--- a/src/thirdparty/ffmpeg/libswscale/x86/rgb2rgb_template.c
+++ /dev/null
@@ -1,2498 +0,0 @@
-/*
- * software RGB to RGB converter
- * pluralize by software PAL8 to RGB converter
- * software YUV to YUV converter
- * software YUV to RGB converter
- * Written by Nick Kurshev.
- * palette & YUV & runtime CPU stuff by Michael (michaelni@gmx.at)
- * lot of big-endian byte order fixes by Alex Beregszaszi
- *
- * 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>
-
-#undef PREFETCH
-#undef MOVNTQ
-#undef EMMS
-#undef SFENCE
-#undef PAVGB
-
-#if COMPILE_TEMPLATE_AMD3DNOW
-#define PREFETCH "prefetch"
-#define PAVGB "pavgusb"
-#elif COMPILE_TEMPLATE_MMXEXT
-#define PREFETCH "prefetchnta"
-#define PAVGB "pavgb"
-#else
-#define PREFETCH " # nop"
-#endif
-
-#if COMPILE_TEMPLATE_AMD3DNOW
-/* On K6 femms is faster than emms. On K7 femms is directly mapped to emms. */
-#define EMMS "femms"
-#else
-#define EMMS "emms"
-#endif
-
-#if COMPILE_TEMPLATE_MMXEXT
-#define MOVNTQ "movntq"
-#define SFENCE "sfence"
-#else
-#define MOVNTQ "movq"
-#define SFENCE " # nop"
-#endif
-
-#if !COMPILE_TEMPLATE_SSE2
-
-#if !COMPILE_TEMPLATE_AMD3DNOW
-
-static inline void RENAME(rgb24tobgr32)(const uint8_t *src, uint8_t *dst, int src_size)
-{
- uint8_t *dest = dst;
- const uint8_t *s = src;
- const uint8_t *end;
- const uint8_t *mm_end;
- end = s + src_size;
- __asm__ volatile(PREFETCH" %0"::"m"(*s):"memory");
- mm_end = end - 23;
- __asm__ volatile("movq %0, %%mm7"::"m"(mask32a):"memory");
- while (s < mm_end) {
- __asm__ volatile(
- PREFETCH" 32(%1) \n\t"
- "movd (%1), %%mm0 \n\t"
- "punpckldq 3(%1), %%mm0 \n\t"
- "movd 6(%1), %%mm1 \n\t"
- "punpckldq 9(%1), %%mm1 \n\t"
- "movd 12(%1), %%mm2 \n\t"
- "punpckldq 15(%1), %%mm2 \n\t"
- "movd 18(%1), %%mm3 \n\t"
- "punpckldq 21(%1), %%mm3 \n\t"
- "por %%mm7, %%mm0 \n\t"
- "por %%mm7, %%mm1 \n\t"
- "por %%mm7, %%mm2 \n\t"
- "por %%mm7, %%mm3 \n\t"
- MOVNTQ" %%mm0, (%0) \n\t"
- MOVNTQ" %%mm1, 8(%0) \n\t"
- MOVNTQ" %%mm2, 16(%0) \n\t"
- MOVNTQ" %%mm3, 24(%0)"
- :: "r"(dest), "r"(s)
- :"memory");
- dest += 32;
- s += 24;
- }
- __asm__ volatile(SFENCE:::"memory");
- __asm__ volatile(EMMS:::"memory");
- while (s < end) {
- *dest++ = *s++;
- *dest++ = *s++;
- *dest++ = *s++;
- *dest++ = 255;
- }
-}
-
-#define STORE_BGR24_MMX \
- "psrlq $8, %%mm2 \n\t" \
- "psrlq $8, %%mm3 \n\t" \
- "psrlq $8, %%mm6 \n\t" \
- "psrlq $8, %%mm7 \n\t" \
- "pand "MANGLE(mask24l)", %%mm0\n\t" \
- "pand "MANGLE(mask24l)", %%mm1\n\t" \
- "pand "MANGLE(mask24l)", %%mm4\n\t" \
- "pand "MANGLE(mask24l)", %%mm5\n\t" \
- "pand "MANGLE(mask24h)", %%mm2\n\t" \
- "pand "MANGLE(mask24h)", %%mm3\n\t" \
- "pand "MANGLE(mask24h)", %%mm6\n\t" \
- "pand "MANGLE(mask24h)", %%mm7\n\t" \
- "por %%mm2, %%mm0 \n\t" \
- "por %%mm3, %%mm1 \n\t" \
- "por %%mm6, %%mm4 \n\t" \
- "por %%mm7, %%mm5 \n\t" \
- \
- "movq %%mm1, %%mm2 \n\t" \
- "movq %%mm4, %%mm3 \n\t" \
- "psllq $48, %%mm2 \n\t" \
- "psllq $32, %%mm3 \n\t" \
- "por %%mm2, %%mm0 \n\t" \
- "psrlq $16, %%mm1 \n\t" \
- "psrlq $32, %%mm4 \n\t" \
- "psllq $16, %%mm5 \n\t" \
- "por %%mm3, %%mm1 \n\t" \
- "por %%mm5, %%mm4 \n\t" \
- \
- MOVNTQ" %%mm0, (%0) \n\t" \
- MOVNTQ" %%mm1, 8(%0) \n\t" \
- MOVNTQ" %%mm4, 16(%0)"
-
-
-static inline void RENAME(rgb32tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
-{
- uint8_t *dest = dst;
- const uint8_t *s = src;
- const uint8_t *end;
- const uint8_t *mm_end;
- end = s + src_size;
- __asm__ volatile(PREFETCH" %0"::"m"(*s):"memory");
- mm_end = end - 31;
- while (s < mm_end) {
- __asm__ volatile(
- PREFETCH" 32(%1) \n\t"
- "movq (%1), %%mm0 \n\t"
- "movq 8(%1), %%mm1 \n\t"
- "movq 16(%1), %%mm4 \n\t"
- "movq 24(%1), %%mm5 \n\t"
- "movq %%mm0, %%mm2 \n\t"
- "movq %%mm1, %%mm3 \n\t"
- "movq %%mm4, %%mm6 \n\t"
- "movq %%mm5, %%mm7 \n\t"
- STORE_BGR24_MMX
- :: "r"(dest), "r"(s)
- :"memory");
- dest += 24;
- s += 32;
- }
- __asm__ volatile(SFENCE:::"memory");
- __asm__ volatile(EMMS:::"memory");
- while (s < end) {
- *dest++ = *s++;
- *dest++ = *s++;
- *dest++ = *s++;
- s++;
- }
-}
-
-/*
- original by Strepto/Astral
- ported to gcc & bugfixed: A'rpi
- MMXEXT, 3DNOW optimization by Nick Kurshev
- 32-bit C version, and and&add trick by Michael Niedermayer
-*/
-static inline void RENAME(rgb15to16)(const uint8_t *src, uint8_t *dst, int src_size)
-{
- register const uint8_t* s=src;
- register uint8_t* d=dst;
- register const uint8_t *end;
- const uint8_t *mm_end;
- end = s + src_size;
- __asm__ volatile(PREFETCH" %0"::"m"(*s));
- __asm__ volatile("movq %0, %%mm4"::"m"(mask15s));
- mm_end = end - 15;
- while (s<mm_end) {
- __asm__ volatile(
- PREFETCH" 32(%1) \n\t"
- "movq (%1), %%mm0 \n\t"
- "movq 8(%1), %%mm2 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "movq %%mm2, %%mm3 \n\t"
- "pand %%mm4, %%mm0 \n\t"
- "pand %%mm4, %%mm2 \n\t"
- "paddw %%mm1, %%mm0 \n\t"
- "paddw %%mm3, %%mm2 \n\t"
- MOVNTQ" %%mm0, (%0) \n\t"
- MOVNTQ" %%mm2, 8(%0)"
- :: "r"(d), "r"(s)
- );
- d+=16;
- s+=16;
- }
- __asm__ volatile(SFENCE:::"memory");
- __asm__ volatile(EMMS:::"memory");
- mm_end = end - 3;
- while (s < mm_end) {
- register unsigned x= *((const uint32_t *)s);
- *((uint32_t *)d) = (x&0x7FFF7FFF) + (x&0x7FE07FE0);
- d+=4;
- s+=4;
- }
- if (s < end) {
- register unsigned short x= *((const uint16_t *)s);
- *((uint16_t *)d) = (x&0x7FFF) + (x&0x7FE0);
- }
-}
-
-static inline void RENAME(rgb16to15)(const uint8_t *src, uint8_t *dst, int src_size)
-{
- register const uint8_t* s=src;
- register uint8_t* d=dst;
- register const uint8_t *end;
- const uint8_t *mm_end;
- end = s + src_size;
- __asm__ volatile(PREFETCH" %0"::"m"(*s));
- __asm__ volatile("movq %0, %%mm7"::"m"(mask15rg));
- __asm__ volatile("movq %0, %%mm6"::"m"(mask15b));
- mm_end = end - 15;
- while (s<mm_end) {
- __asm__ volatile(
- PREFETCH" 32(%1) \n\t"
- "movq (%1), %%mm0 \n\t"
- "movq 8(%1), %%mm2 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "movq %%mm2, %%mm3 \n\t"
- "psrlq $1, %%mm0 \n\t"
- "psrlq $1, %%mm2 \n\t"
- "pand %%mm7, %%mm0 \n\t"
- "pand %%mm7, %%mm2 \n\t"
- "pand %%mm6, %%mm1 \n\t"
- "pand %%mm6, %%mm3 \n\t"
- "por %%mm1, %%mm0 \n\t"
- "por %%mm3, %%mm2 \n\t"
- MOVNTQ" %%mm0, (%0) \n\t"
- MOVNTQ" %%mm2, 8(%0)"
- :: "r"(d), "r"(s)
- );
- d+=16;
- s+=16;
- }
- __asm__ volatile(SFENCE:::"memory");
- __asm__ volatile(EMMS:::"memory");
- mm_end = end - 3;
- while (s < mm_end) {
- register uint32_t x= *((const uint32_t*)s);
- *((uint32_t *)d) = ((x>>1)&0x7FE07FE0) | (x&0x001F001F);
- s+=4;
- d+=4;
- }
- if (s < end) {
- register uint16_t x= *((const uint16_t*)s);
- *((uint16_t *)d) = ((x>>1)&0x7FE0) | (x&0x001F);
- }
-}
-
-static inline void RENAME(rgb32to16)(const uint8_t *src, uint8_t *dst, int src_size)
-{
- const uint8_t *s = src;
- const uint8_t *end;
- const uint8_t *mm_end;
- uint16_t *d = (uint16_t *)dst;
- end = s + src_size;
- mm_end = end - 15;
- __asm__ volatile(
- "movq %3, %%mm5 \n\t"
- "movq %4, %%mm6 \n\t"
- "movq %5, %%mm7 \n\t"
- "jmp 2f \n\t"
- ".p2align 4 \n\t"
- "1: \n\t"
- PREFETCH" 32(%1) \n\t"
- "movd (%1), %%mm0 \n\t"
- "movd 4(%1), %%mm3 \n\t"
- "punpckldq 8(%1), %%mm0 \n\t"
- "punpckldq 12(%1), %%mm3 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "movq %%mm3, %%mm4 \n\t"
- "pand %%mm6, %%mm0 \n\t"
- "pand %%mm6, %%mm3 \n\t"
- "pmaddwd %%mm7, %%mm0 \n\t"
- "pmaddwd %%mm7, %%mm3 \n\t"
- "pand %%mm5, %%mm1 \n\t"
- "pand %%mm5, %%mm4 \n\t"
- "por %%mm1, %%mm0 \n\t"
- "por %%mm4, %%mm3 \n\t"
- "psrld $5, %%mm0 \n\t"
- "pslld $11, %%mm3 \n\t"
- "por %%mm3, %%mm0 \n\t"
- MOVNTQ" %%mm0, (%0) \n\t"
- "add $16, %1 \n\t"
- "add $8, %0 \n\t"
- "2: \n\t"
- "cmp %2, %1 \n\t"
- " jb 1b \n\t"
- : "+r" (d), "+r"(s)
- : "r" (mm_end), "m" (mask3216g), "m" (mask3216br), "m" (mul3216)
- );
- __asm__ volatile(SFENCE:::"memory");
- __asm__ volatile(EMMS:::"memory");
- while (s < end) {
- register int rgb = *(const uint32_t*)s; s += 4;
- *d++ = ((rgb&0xFF)>>3) + ((rgb&0xFC00)>>5) + ((rgb&0xF80000)>>8);
- }
-}
-
-static inline void RENAME(rgb32tobgr16)(const uint8_t *src, uint8_t *dst, int src_size)
-{
- const uint8_t *s = src;
- const uint8_t *end;
- const uint8_t *mm_end;
- uint16_t *d = (uint16_t *)dst;
- end = s + src_size;
- __asm__ volatile(PREFETCH" %0"::"m"(*src):"memory");
- __asm__ volatile(
- "movq %0, %%mm7 \n\t"
- "movq %1, %%mm6 \n\t"
- ::"m"(red_16mask),"m"(green_16mask));
- mm_end = end - 15;
- while (s < mm_end) {
- __asm__ volatile(
- PREFETCH" 32(%1) \n\t"
- "movd (%1), %%mm0 \n\t"
- "movd 4(%1), %%mm3 \n\t"
- "punpckldq 8(%1), %%mm0 \n\t"
- "punpckldq 12(%1), %%mm3 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "movq %%mm0, %%mm2 \n\t"
- "movq %%mm3, %%mm4 \n\t"
- "movq %%mm3, %%mm5 \n\t"
- "psllq $8, %%mm0 \n\t"
- "psllq $8, %%mm3 \n\t"
- "pand %%mm7, %%mm0 \n\t"
- "pand %%mm7, %%mm3 \n\t"
- "psrlq $5, %%mm1 \n\t"
- "psrlq $5, %%mm4 \n\t"
- "pand %%mm6, %%mm1 \n\t"
- "pand %%mm6, %%mm4 \n\t"
- "psrlq $19, %%mm2 \n\t"
- "psrlq $19, %%mm5 \n\t"
- "pand %2, %%mm2 \n\t"
- "pand %2, %%mm5 \n\t"
- "por %%mm1, %%mm0 \n\t"
- "por %%mm4, %%mm3 \n\t"
- "por %%mm2, %%mm0 \n\t"
- "por %%mm5, %%mm3 \n\t"
- "psllq $16, %%mm3 \n\t"
- "por %%mm3, %%mm0 \n\t"
- MOVNTQ" %%mm0, (%0) \n\t"
- :: "r"(d),"r"(s),"m"(blue_16mask):"memory");
- d += 4;
- s += 16;
- }
- __asm__ volatile(SFENCE:::"memory");
- __asm__ volatile(EMMS:::"memory");
- while (s < end) {
- register int rgb = *(const uint32_t*)s; s += 4;
- *d++ = ((rgb&0xF8)<<8) + ((rgb&0xFC00)>>5) + ((rgb&0xF80000)>>19);
- }
-}
-
-static inline void RENAME(rgb32to15)(const uint8_t *src, uint8_t *dst, int src_size)
-{
- const uint8_t *s = src;
- const uint8_t *end;
- const uint8_t *mm_end;
- uint16_t *d = (uint16_t *)dst;
- end = s + src_size;
- mm_end = end - 15;
- __asm__ volatile(
- "movq %3, %%mm5 \n\t"
- "movq %4, %%mm6 \n\t"
- "movq %5, %%mm7 \n\t"
- "jmp 2f \n\t"
- ".p2align 4 \n\t"
- "1: \n\t"
- PREFETCH" 32(%1) \n\t"
- "movd (%1), %%mm0 \n\t"
- "movd 4(%1), %%mm3 \n\t"
- "punpckldq 8(%1), %%mm0 \n\t"
- "punpckldq 12(%1), %%mm3 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "movq %%mm3, %%mm4 \n\t"
- "pand %%mm6, %%mm0 \n\t"
- "pand %%mm6, %%mm3 \n\t"
- "pmaddwd %%mm7, %%mm0 \n\t"
- "pmaddwd %%mm7, %%mm3 \n\t"
- "pand %%mm5, %%mm1 \n\t"
- "pand %%mm5, %%mm4 \n\t"
- "por %%mm1, %%mm0 \n\t"
- "por %%mm4, %%mm3 \n\t"
- "psrld $6, %%mm0 \n\t"
- "pslld $10, %%mm3 \n\t"
- "por %%mm3, %%mm0 \n\t"
- MOVNTQ" %%mm0, (%0) \n\t"
- "add $16, %1 \n\t"
- "add $8, %0 \n\t"
- "2: \n\t"
- "cmp %2, %1 \n\t"
- " jb 1b \n\t"
- : "+r" (d), "+r"(s)
- : "r" (mm_end), "m" (mask3215g), "m" (mask3216br), "m" (mul3215)
- );
- __asm__ volatile(SFENCE:::"memory");
- __asm__ volatile(EMMS:::"memory");
- while (s < end) {
- register int rgb = *(const uint32_t*)s; s += 4;
- *d++ = ((rgb&0xFF)>>3) + ((rgb&0xF800)>>6) + ((rgb&0xF80000)>>9);
- }
-}
-
-static inline void RENAME(rgb32tobgr15)(const uint8_t *src, uint8_t *dst, int src_size)
-{
- const uint8_t *s = src;
- const uint8_t *end;
- const uint8_t *mm_end;
- uint16_t *d = (uint16_t *)dst;
- end = s + src_size;
- __asm__ volatile(PREFETCH" %0"::"m"(*src):"memory");
- __asm__ volatile(
- "movq %0, %%mm7 \n\t"
- "movq %1, %%mm6 \n\t"
- ::"m"(red_15mask),"m"(green_15mask));
- mm_end = end - 15;
- while (s < mm_end) {
- __asm__ volatile(
- PREFETCH" 32(%1) \n\t"
- "movd (%1), %%mm0 \n\t"
- "movd 4(%1), %%mm3 \n\t"
- "punpckldq 8(%1), %%mm0 \n\t"
- "punpckldq 12(%1), %%mm3 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "movq %%mm0, %%mm2 \n\t"
- "movq %%mm3, %%mm4 \n\t"
- "movq %%mm3, %%mm5 \n\t"
- "psllq $7, %%mm0 \n\t"
- "psllq $7, %%mm3 \n\t"
- "pand %%mm7, %%mm0 \n\t"
- "pand %%mm7, %%mm3 \n\t"
- "psrlq $6, %%mm1 \n\t"
- "psrlq $6, %%mm4 \n\t"
- "pand %%mm6, %%mm1 \n\t"
- "pand %%mm6, %%mm4 \n\t"
- "psrlq $19, %%mm2 \n\t"
- "psrlq $19, %%mm5 \n\t"
- "pand %2, %%mm2 \n\t"
- "pand %2, %%mm5 \n\t"
- "por %%mm1, %%mm0 \n\t"
- "por %%mm4, %%mm3 \n\t"
- "por %%mm2, %%mm0 \n\t"
- "por %%mm5, %%mm3 \n\t"
- "psllq $16, %%mm3 \n\t"
- "por %%mm3, %%mm0 \n\t"
- MOVNTQ" %%mm0, (%0) \n\t"
- ::"r"(d),"r"(s),"m"(blue_15mask):"memory");
- d += 4;
- s += 16;
- }
- __asm__ volatile(SFENCE:::"memory");
- __asm__ volatile(EMMS:::"memory");
- while (s < end) {
- register int rgb = *(const uint32_t*)s; s += 4;
- *d++ = ((rgb&0xF8)<<7) + ((rgb&0xF800)>>6) + ((rgb&0xF80000)>>19);
- }
-}
-
-static inline void RENAME(rgb24tobgr16)(const uint8_t *src, uint8_t *dst, int src_size)
-{
- const uint8_t *s = src;
- const uint8_t *end;
- const uint8_t *mm_end;
- uint16_t *d = (uint16_t *)dst;
- end = s + src_size;
- __asm__ volatile(PREFETCH" %0"::"m"(*src):"memory");
- __asm__ volatile(
- "movq %0, %%mm7 \n\t"
- "movq %1, %%mm6 \n\t"
- ::"m"(red_16mask),"m"(green_16mask));
- mm_end = end - 11;
- while (s < mm_end) {
- __asm__ volatile(
- PREFETCH" 32(%1) \n\t"
- "movd (%1), %%mm0 \n\t"
- "movd 3(%1), %%mm3 \n\t"
- "punpckldq 6(%1), %%mm0 \n\t"
- "punpckldq 9(%1), %%mm3 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "movq %%mm0, %%mm2 \n\t"
- "movq %%mm3, %%mm4 \n\t"
- "movq %%mm3, %%mm5 \n\t"
- "psrlq $3, %%mm0 \n\t"
- "psrlq $3, %%mm3 \n\t"
- "pand %2, %%mm0 \n\t"
- "pand %2, %%mm3 \n\t"
- "psrlq $5, %%mm1 \n\t"
- "psrlq $5, %%mm4 \n\t"
- "pand %%mm6, %%mm1 \n\t"
- "pand %%mm6, %%mm4 \n\t"
- "psrlq $8, %%mm2 \n\t"
- "psrlq $8, %%mm5 \n\t"
- "pand %%mm7, %%mm2 \n\t"
- "pand %%mm7, %%mm5 \n\t"
- "por %%mm1, %%mm0 \n\t"
- "por %%mm4, %%mm3 \n\t"
- "por %%mm2, %%mm0 \n\t"
- "por %%mm5, %%mm3 \n\t"
- "psllq $16, %%mm3 \n\t"
- "por %%mm3, %%mm0 \n\t"
- MOVNTQ" %%mm0, (%0) \n\t"
- ::"r"(d),"r"(s),"m"(blue_16mask):"memory");
- d += 4;
- s += 12;
- }
- __asm__ volatile(SFENCE:::"memory");
- __asm__ volatile(EMMS:::"memory");
- while (s < end) {
- const int b = *s++;
- const int g = *s++;
- const int r = *s++;
- *d++ = (b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8);
- }
-}
-
-static inline void RENAME(rgb24to16)(const uint8_t *src, uint8_t *dst, int src_size)
-{
- const uint8_t *s = src;
- const uint8_t *end;
- const uint8_t *mm_end;
- uint16_t *d = (uint16_t *)dst;
- end = s + src_size;
- __asm__ volatile(PREFETCH" %0"::"m"(*src):"memory");
- __asm__ volatile(
- "movq %0, %%mm7 \n\t"
- "movq %1, %%mm6 \n\t"
- ::"m"(red_16mask),"m"(green_16mask));
- mm_end = end - 15;
- while (s < mm_end) {
- __asm__ volatile(
- PREFETCH" 32(%1) \n\t"
- "movd (%1), %%mm0 \n\t"
- "movd 3(%1), %%mm3 \n\t"
- "punpckldq 6(%1), %%mm0 \n\t"
- "punpckldq 9(%1), %%mm3 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "movq %%mm0, %%mm2 \n\t"
- "movq %%mm3, %%mm4 \n\t"
- "movq %%mm3, %%mm5 \n\t"
- "psllq $8, %%mm0 \n\t"
- "psllq $8, %%mm3 \n\t"
- "pand %%mm7, %%mm0 \n\t"
- "pand %%mm7, %%mm3 \n\t"
- "psrlq $5, %%mm1 \n\t"
- "psrlq $5, %%mm4 \n\t"
- "pand %%mm6, %%mm1 \n\t"
- "pand %%mm6, %%mm4 \n\t"
- "psrlq $19, %%mm2 \n\t"
- "psrlq $19, %%mm5 \n\t"
- "pand %2, %%mm2 \n\t"
- "pand %2, %%mm5 \n\t"
- "por %%mm1, %%mm0 \n\t"
- "por %%mm4, %%mm3 \n\t"
- "por %%mm2, %%mm0 \n\t"
- "por %%mm5, %%mm3 \n\t"
- "psllq $16, %%mm3 \n\t"
- "por %%mm3, %%mm0 \n\t"
- MOVNTQ" %%mm0, (%0) \n\t"
- ::"r"(d),"r"(s),"m"(blue_16mask):"memory");
- d += 4;
- s += 12;
- }
- __asm__ volatile(SFENCE:::"memory");
- __asm__ volatile(EMMS:::"memory");
- while (s < end) {
- const int r = *s++;
- const int g = *s++;
- const int b = *s++;
- *d++ = (b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8);
- }
-}
-
-static inline void RENAME(rgb24tobgr15)(const uint8_t *src, uint8_t *dst, int src_size)
-{
- const uint8_t *s = src;
- const uint8_t *end;
- const uint8_t *mm_end;
- uint16_t *d = (uint16_t *)dst;
- end = s + src_size;
- __asm__ volatile(PREFETCH" %0"::"m"(*src):"memory");
- __asm__ volatile(
- "movq %0, %%mm7 \n\t"
- "movq %1, %%mm6 \n\t"
- ::"m"(red_15mask),"m"(green_15mask));
- mm_end = end - 11;
- while (s < mm_end) {
- __asm__ volatile(
- PREFETCH" 32(%1) \n\t"
- "movd (%1), %%mm0 \n\t"
- "movd 3(%1), %%mm3 \n\t"
- "punpckldq 6(%1), %%mm0 \n\t"
- "punpckldq 9(%1), %%mm3 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "movq %%mm0, %%mm2 \n\t"
- "movq %%mm3, %%mm4 \n\t"
- "movq %%mm3, %%mm5 \n\t"
- "psrlq $3, %%mm0 \n\t"
- "psrlq $3, %%mm3 \n\t"
- "pand %2, %%mm0 \n\t"
- "pand %2, %%mm3 \n\t"
- "psrlq $6, %%mm1 \n\t"
- "psrlq $6, %%mm4 \n\t"
- "pand %%mm6, %%mm1 \n\t"
- "pand %%mm6, %%mm4 \n\t"
- "psrlq $9, %%mm2 \n\t"
- "psrlq $9, %%mm5 \n\t"
- "pand %%mm7, %%mm2 \n\t"
- "pand %%mm7, %%mm5 \n\t"
- "por %%mm1, %%mm0 \n\t"
- "por %%mm4, %%mm3 \n\t"
- "por %%mm2, %%mm0 \n\t"
- "por %%mm5, %%mm3 \n\t"
- "psllq $16, %%mm3 \n\t"
- "por %%mm3, %%mm0 \n\t"
- MOVNTQ" %%mm0, (%0) \n\t"
- ::"r"(d),"r"(s),"m"(blue_15mask):"memory");
- d += 4;
- s += 12;
- }
- __asm__ volatile(SFENCE:::"memory");
- __asm__ volatile(EMMS:::"memory");
- while (s < end) {
- const int b = *s++;
- const int g = *s++;
- const int r = *s++;
- *d++ = (b>>3) | ((g&0xF8)<<2) | ((r&0xF8)<<7);
- }
-}
-
-static inline void RENAME(rgb24to15)(const uint8_t *src, uint8_t *dst, int src_size)
-{
- const uint8_t *s = src;
- const uint8_t *end;
- const uint8_t *mm_end;
- uint16_t *d = (uint16_t *)dst;
- end = s + src_size;
- __asm__ volatile(PREFETCH" %0"::"m"(*src):"memory");
- __asm__ volatile(
- "movq %0, %%mm7 \n\t"
- "movq %1, %%mm6 \n\t"
- ::"m"(red_15mask),"m"(green_15mask));
- mm_end = end - 15;
- while (s < mm_end) {
- __asm__ volatile(
- PREFETCH" 32(%1) \n\t"
- "movd (%1), %%mm0 \n\t"
- "movd 3(%1), %%mm3 \n\t"
- "punpckldq 6(%1), %%mm0 \n\t"
- "punpckldq 9(%1), %%mm3 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "movq %%mm0, %%mm2 \n\t"
- "movq %%mm3, %%mm4 \n\t"
- "movq %%mm3, %%mm5 \n\t"
- "psllq $7, %%mm0 \n\t"
- "psllq $7, %%mm3 \n\t"
- "pand %%mm7, %%mm0 \n\t"
- "pand %%mm7, %%mm3 \n\t"
- "psrlq $6, %%mm1 \n\t"
- "psrlq $6, %%mm4 \n\t"
- "pand %%mm6, %%mm1 \n\t"
- "pand %%mm6, %%mm4 \n\t"
- "psrlq $19, %%mm2 \n\t"
- "psrlq $19, %%mm5 \n\t"
- "pand %2, %%mm2 \n\t"
- "pand %2, %%mm5 \n\t"
- "por %%mm1, %%mm0 \n\t"
- "por %%mm4, %%mm3 \n\t"
- "por %%mm2, %%mm0 \n\t"
- "por %%mm5, %%mm3 \n\t"
- "psllq $16, %%mm3 \n\t"
- "por %%mm3, %%mm0 \n\t"
- MOVNTQ" %%mm0, (%0) \n\t"
- ::"r"(d),"r"(s),"m"(blue_15mask):"memory");
- d += 4;
- s += 12;
- }
- __asm__ volatile(SFENCE:::"memory");
- __asm__ volatile(EMMS:::"memory");
- while (s < end) {
- const int r = *s++;
- const int g = *s++;
- const int b = *s++;
- *d++ = (b>>3) | ((g&0xF8)<<2) | ((r&0xF8)<<7);
- }
-}
-
-static inline void RENAME(rgb15tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
-{
- const uint16_t *end;
- const uint16_t *mm_end;
- uint8_t *d = dst;
- const uint16_t *s = (const uint16_t*)src;
- end = s + src_size/2;
- __asm__ volatile(PREFETCH" %0"::"m"(*s):"memory");
- mm_end = end - 7;
- while (s < mm_end) {
- __asm__ volatile(
- PREFETCH" 32(%1) \n\t"
- "movq (%1), %%mm0 \n\t"
- "movq (%1), %%mm1 \n\t"
- "movq (%1), %%mm2 \n\t"
- "pand %2, %%mm0 \n\t"
- "pand %3, %%mm1 \n\t"
- "pand %4, %%mm2 \n\t"
- "psllq $5, %%mm0 \n\t"
- "pmulhw "MANGLE(mul15_mid)", %%mm0 \n\t"
- "pmulhw "MANGLE(mul15_mid)", %%mm1 \n\t"
- "pmulhw "MANGLE(mul15_hi)", %%mm2 \n\t"
- "movq %%mm0, %%mm3 \n\t"
- "movq %%mm1, %%mm4 \n\t"
- "movq %%mm2, %%mm5 \n\t"
- "punpcklwd %5, %%mm0 \n\t"
- "punpcklwd %5, %%mm1 \n\t"
- "punpcklwd %5, %%mm2 \n\t"
- "punpckhwd %5, %%mm3 \n\t"
- "punpckhwd %5, %%mm4 \n\t"
- "punpckhwd %5, %%mm5 \n\t"
- "psllq $8, %%mm1 \n\t"
- "psllq $16, %%mm2 \n\t"
- "por %%mm1, %%mm0 \n\t"
- "por %%mm2, %%mm0 \n\t"
- "psllq $8, %%mm4 \n\t"
- "psllq $16, %%mm5 \n\t"
- "por %%mm4, %%mm3 \n\t"
- "por %%mm5, %%mm3 \n\t"
-
- "movq %%mm0, %%mm6 \n\t"
- "movq %%mm3, %%mm7 \n\t"
-
- "movq 8(%1), %%mm0 \n\t"
- "movq 8(%1), %%mm1 \n\t"
- "movq 8(%1), %%mm2 \n\t"
- "pand %2, %%mm0 \n\t"
- "pand %3, %%mm1 \n\t"
- "pand %4, %%mm2 \n\t"
- "psllq $5, %%mm0 \n\t"
- "pmulhw "MANGLE(mul15_mid)", %%mm0 \n\t"
- "pmulhw "MANGLE(mul15_mid)", %%mm1 \n\t"
- "pmulhw "MANGLE(mul15_hi)", %%mm2 \n\t"
- "movq %%mm0, %%mm3 \n\t"
- "movq %%mm1, %%mm4 \n\t"
- "movq %%mm2, %%mm5 \n\t"
- "punpcklwd %5, %%mm0 \n\t"
- "punpcklwd %5, %%mm1 \n\t"
- "punpcklwd %5, %%mm2 \n\t"
- "punpckhwd %5, %%mm3 \n\t"
- "punpckhwd %5, %%mm4 \n\t"
- "punpckhwd %5, %%mm5 \n\t"
- "psllq $8, %%mm1 \n\t"
- "psllq $16, %%mm2 \n\t"
- "por %%mm1, %%mm0 \n\t"
- "por %%mm2, %%mm0 \n\t"
- "psllq $8, %%mm4 \n\t"
- "psllq $16, %%mm5 \n\t"
- "por %%mm4, %%mm3 \n\t"
- "por %%mm5, %%mm3 \n\t"
-
- :"=m"(*d)
- :"r"(s),"m"(mask15b),"m"(mask15g),"m"(mask15r), "m"(mmx_null)
- :"memory");
- /* borrowed 32 to 24 */
- __asm__ volatile(
- "movq %%mm0, %%mm4 \n\t"
- "movq %%mm3, %%mm5 \n\t"
- "movq %%mm6, %%mm0 \n\t"
- "movq %%mm7, %%mm1 \n\t"
-
- "movq %%mm4, %%mm6 \n\t"
- "movq %%mm5, %%mm7 \n\t"
- "movq %%mm0, %%mm2 \n\t"
- "movq %%mm1, %%mm3 \n\t"
-
- STORE_BGR24_MMX
-
- :: "r"(d), "m"(*s)
- :"memory");
- d += 24;
- s += 8;
- }
- __asm__ volatile(SFENCE:::"memory");
- __asm__ volatile(EMMS:::"memory");
- while (s < end) {
- register uint16_t bgr;
- bgr = *s++;
- *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
- *d++ = ((bgr&0x3E0)>>2) | ((bgr&0x3E0)>>7);
- *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
- }
-}
-
-static inline void RENAME(rgb16tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
-{
- const uint16_t *end;
- const uint16_t *mm_end;
- uint8_t *d = (uint8_t *)dst;
- const uint16_t *s = (const uint16_t *)src;
- end = s + src_size/2;
- __asm__ volatile(PREFETCH" %0"::"m"(*s):"memory");
- mm_end = end - 7;
- while (s < mm_end) {
- __asm__ volatile(
- PREFETCH" 32(%1) \n\t"
- "movq (%1), %%mm0 \n\t"
- "movq (%1), %%mm1 \n\t"
- "movq (%1), %%mm2 \n\t"
- "pand %2, %%mm0 \n\t"
- "pand %3, %%mm1 \n\t"
- "pand %4, %%mm2 \n\t"
- "psllq $5, %%mm0 \n\t"
- "psrlq $1, %%mm2 \n\t"
- "pmulhw "MANGLE(mul15_mid)", %%mm0 \n\t"
- "pmulhw "MANGLE(mul16_mid)", %%mm1 \n\t"
- "pmulhw "MANGLE(mul15_hi)", %%mm2 \n\t"
- "movq %%mm0, %%mm3 \n\t"
- "movq %%mm1, %%mm4 \n\t"
- "movq %%mm2, %%mm5 \n\t"
- "punpcklwd %5, %%mm0 \n\t"
- "punpcklwd %5, %%mm1 \n\t"
- "punpcklwd %5, %%mm2 \n\t"
- "punpckhwd %5, %%mm3 \n\t"
- "punpckhwd %5, %%mm4 \n\t"
- "punpckhwd %5, %%mm5 \n\t"
- "psllq $8, %%mm1 \n\t"
- "psllq $16, %%mm2 \n\t"
- "por %%mm1, %%mm0 \n\t"
- "por %%mm2, %%mm0 \n\t"
- "psllq $8, %%mm4 \n\t"
- "psllq $16, %%mm5 \n\t"
- "por %%mm4, %%mm3 \n\t"
- "por %%mm5, %%mm3 \n\t"
-
- "movq %%mm0, %%mm6 \n\t"
- "movq %%mm3, %%mm7 \n\t"
-
- "movq 8(%1), %%mm0 \n\t"
- "movq 8(%1), %%mm1 \n\t"
- "movq 8(%1), %%mm2 \n\t"
- "pand %2, %%mm0 \n\t"
- "pand %3, %%mm1 \n\t"
- "pand %4, %%mm2 \n\t"
- "psllq $5, %%mm0 \n\t"
- "psrlq $1, %%mm2 \n\t"
- "pmulhw "MANGLE(mul15_mid)", %%mm0 \n\t"
- "pmulhw "MANGLE(mul16_mid)", %%mm1 \n\t"
- "pmulhw "MANGLE(mul15_hi)", %%mm2 \n\t"
- "movq %%mm0, %%mm3 \n\t"
- "movq %%mm1, %%mm4 \n\t"
- "movq %%mm2, %%mm5 \n\t"
- "punpcklwd %5, %%mm0 \n\t"
- "punpcklwd %5, %%mm1 \n\t"
- "punpcklwd %5, %%mm2 \n\t"
- "punpckhwd %5, %%mm3 \n\t"
- "punpckhwd %5, %%mm4 \n\t"
- "punpckhwd %5, %%mm5 \n\t"
- "psllq $8, %%mm1 \n\t"
- "psllq $16, %%mm2 \n\t"
- "por %%mm1, %%mm0 \n\t"
- "por %%mm2, %%mm0 \n\t"
- "psllq $8, %%mm4 \n\t"
- "psllq $16, %%mm5 \n\t"
- "por %%mm4, %%mm3 \n\t"
- "por %%mm5, %%mm3 \n\t"
- :"=m"(*d)
- :"r"(s),"m"(mask16b),"m"(mask16g),"m"(mask16r),"m"(mmx_null)
- :"memory");
- /* borrowed 32 to 24 */
- __asm__ volatile(
- "movq %%mm0, %%mm4 \n\t"
- "movq %%mm3, %%mm5 \n\t"
- "movq %%mm6, %%mm0 \n\t"
- "movq %%mm7, %%mm1 \n\t"
-
- "movq %%mm4, %%mm6 \n\t"
- "movq %%mm5, %%mm7 \n\t"
- "movq %%mm0, %%mm2 \n\t"
- "movq %%mm1, %%mm3 \n\t"
-
- STORE_BGR24_MMX
-
- :: "r"(d), "m"(*s)
- :"memory");
- d += 24;
- s += 8;
- }
- __asm__ volatile(SFENCE:::"memory");
- __asm__ volatile(EMMS:::"memory");
- while (s < end) {
- register uint16_t bgr;
- bgr = *s++;
- *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
- *d++ = ((bgr&0x7E0)>>3) | ((bgr&0x7E0)>>9);
- *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
- }
-}
-
-/*
- * mm0 = 00 B3 00 B2 00 B1 00 B0
- * mm1 = 00 G3 00 G2 00 G1 00 G0
- * mm2 = 00 R3 00 R2 00 R1 00 R0
- * mm6 = FF FF FF FF FF FF FF FF
- * mm7 = 00 00 00 00 00 00 00 00
- */
-#define PACK_RGB32 \
- "packuswb %%mm7, %%mm0 \n\t" /* 00 00 00 00 B3 B2 B1 B0 */ \
- "packuswb %%mm7, %%mm1 \n\t" /* 00 00 00 00 G3 G2 G1 G0 */ \
- "packuswb %%mm7, %%mm2 \n\t" /* 00 00 00 00 R3 R2 R1 R0 */ \
- "punpcklbw %%mm1, %%mm0 \n\t" /* G3 B3 G2 B2 G1 B1 G0 B0 */ \
- "punpcklbw %%mm6, %%mm2 \n\t" /* FF R3 FF R2 FF R1 FF R0 */ \
- "movq %%mm0, %%mm3 \n\t" \
- "punpcklwd %%mm2, %%mm0 \n\t" /* FF R1 G1 B1 FF R0 G0 B0 */ \
- "punpckhwd %%mm2, %%mm3 \n\t" /* FF R3 G3 B3 FF R2 G2 B2 */ \
- MOVNTQ" %%mm0, (%0) \n\t" \
- MOVNTQ" %%mm3, 8(%0) \n\t" \
-
-static inline void RENAME(rgb15to32)(const uint8_t *src, uint8_t *dst, int src_size)
-{
- const uint16_t *end;
- const uint16_t *mm_end;
- uint8_t *d = dst;
- const uint16_t *s = (const uint16_t *)src;
- end = s + src_size/2;
- __asm__ volatile(PREFETCH" %0"::"m"(*s):"memory");
- __asm__ volatile("pxor %%mm7,%%mm7 \n\t":::"memory");
- __asm__ volatile("pcmpeqd %%mm6,%%mm6 \n\t":::"memory");
- mm_end = end - 3;
- while (s < mm_end) {
- __asm__ volatile(
- PREFETCH" 32(%1) \n\t"
- "movq (%1), %%mm0 \n\t"
- "movq (%1), %%mm1 \n\t"
- "movq (%1), %%mm2 \n\t"
- "pand %2, %%mm0 \n\t"
- "pand %3, %%mm1 \n\t"
- "pand %4, %%mm2 \n\t"
- "psllq $5, %%mm0 \n\t"
- "pmulhw %5, %%mm0 \n\t"
- "pmulhw %5, %%mm1 \n\t"
- "pmulhw "MANGLE(mul15_hi)", %%mm2 \n\t"
- PACK_RGB32
- ::"r"(d),"r"(s),"m"(mask15b),"m"(mask15g),"m"(mask15r) ,"m"(mul15_mid)
- :"memory");
- d += 16;
- s += 4;
- }
- __asm__ volatile(SFENCE:::"memory");
- __asm__ volatile(EMMS:::"memory");
- while (s < end) {
- register uint16_t bgr;
- bgr = *s++;
- *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
- *d++ = ((bgr&0x3E0)>>2) | ((bgr&0x3E0)>>7);
- *d++ = ((bgr&0x7C00)>>7) | ((bgr&0x7C00)>>12);
- *d++ = 255;
- }
-}
-
-static inline void RENAME(rgb16to32)(const uint8_t *src, uint8_t *dst, int src_size)
-{
- const uint16_t *end;
- const uint16_t *mm_end;
- uint8_t *d = dst;
- const uint16_t *s = (const uint16_t*)src;
- end = s + src_size/2;
- __asm__ volatile(PREFETCH" %0"::"m"(*s):"memory");
- __asm__ volatile("pxor %%mm7,%%mm7 \n\t":::"memory");
- __asm__ volatile("pcmpeqd %%mm6,%%mm6 \n\t":::"memory");
- mm_end = end - 3;
- while (s < mm_end) {
- __asm__ volatile(
- PREFETCH" 32(%1) \n\t"
- "movq (%1), %%mm0 \n\t"
- "movq (%1), %%mm1 \n\t"
- "movq (%1), %%mm2 \n\t"
- "pand %2, %%mm0 \n\t"
- "pand %3, %%mm1 \n\t"
- "pand %4, %%mm2 \n\t"
- "psllq $5, %%mm0 \n\t"
- "psrlq $1, %%mm2 \n\t"
- "pmulhw %5, %%mm0 \n\t"
- "pmulhw "MANGLE(mul16_mid)", %%mm1 \n\t"
- "pmulhw "MANGLE(mul15_hi)", %%mm2 \n\t"
- PACK_RGB32
- ::"r"(d),"r"(s),"m"(mask16b),"m"(mask16g),"m"(mask16r),"m"(mul15_mid)
- :"memory");
- d += 16;
- s += 4;
- }
- __asm__ volatile(SFENCE:::"memory");
- __asm__ volatile(EMMS:::"memory");
- while (s < end) {
- register uint16_t bgr;
- bgr = *s++;
- *d++ = ((bgr&0x1F)<<3) | ((bgr&0x1F)>>2);
- *d++ = ((bgr&0x7E0)>>3) | ((bgr&0x7E0)>>9);
- *d++ = ((bgr&0xF800)>>8) | ((bgr&0xF800)>>13);
- *d++ = 255;
- }
-}
-
-static inline void RENAME(shuffle_bytes_2103)(const uint8_t *src, uint8_t *dst, int src_size)
-{
- x86_reg idx = 15 - src_size;
- const uint8_t *s = src-idx;
- uint8_t *d = dst-idx;
- __asm__ volatile(
- "test %0, %0 \n\t"
- "jns 2f \n\t"
- PREFETCH" (%1, %0) \n\t"
- "movq %3, %%mm7 \n\t"
- "pxor %4, %%mm7 \n\t"
- "movq %%mm7, %%mm6 \n\t"
- "pxor %5, %%mm7 \n\t"
- ".p2align 4 \n\t"
- "1: \n\t"
- PREFETCH" 32(%1, %0) \n\t"
- "movq (%1, %0), %%mm0 \n\t"
- "movq 8(%1, %0), %%mm1 \n\t"
-# if COMPILE_TEMPLATE_MMXEXT
- "pshufw $177, %%mm0, %%mm3 \n\t"
- "pshufw $177, %%mm1, %%mm5 \n\t"
- "pand %%mm7, %%mm0 \n\t"
- "pand %%mm6, %%mm3 \n\t"
- "pand %%mm7, %%mm1 \n\t"
- "pand %%mm6, %%mm5 \n\t"
- "por %%mm3, %%mm0 \n\t"
- "por %%mm5, %%mm1 \n\t"
-# else
- "movq %%mm0, %%mm2 \n\t"
- "movq %%mm1, %%mm4 \n\t"
- "pand %%mm7, %%mm0 \n\t"
- "pand %%mm6, %%mm2 \n\t"
- "pand %%mm7, %%mm1 \n\t"
- "pand %%mm6, %%mm4 \n\t"
- "movq %%mm2, %%mm3 \n\t"
- "movq %%mm4, %%mm5 \n\t"
- "pslld $16, %%mm2 \n\t"
- "psrld $16, %%mm3 \n\t"
- "pslld $16, %%mm4 \n\t"
- "psrld $16, %%mm5 \n\t"
- "por %%mm2, %%mm0 \n\t"
- "por %%mm4, %%mm1 \n\t"
- "por %%mm3, %%mm0 \n\t"
- "por %%mm5, %%mm1 \n\t"
-# endif
- MOVNTQ" %%mm0, (%2, %0) \n\t"
- MOVNTQ" %%mm1, 8(%2, %0) \n\t"
- "add $16, %0 \n\t"
- "js 1b \n\t"
- SFENCE" \n\t"
- EMMS" \n\t"
- "2: \n\t"
- : "+&r"(idx)
- : "r" (s), "r" (d), "m" (mask32b), "m" (mask32r), "m" (mmx_one)
- : "memory");
- for (; idx<15; idx+=4) {
- register int v = *(const uint32_t *)&s[idx], g = v & 0xff00ff00;
- v &= 0xff00ff;
- *(uint32_t *)&d[idx] = (v>>16) + g + (v<<16);
- }
-}
-
-static inline void RENAME(rgb24tobgr24)(const uint8_t *src, uint8_t *dst, int src_size)
-{
- unsigned i;
- x86_reg mmx_size= 23 - src_size;
- __asm__ volatile (
- "test %%"REG_a", %%"REG_a" \n\t"
- "jns 2f \n\t"
- "movq "MANGLE(mask24r)", %%mm5 \n\t"
- "movq "MANGLE(mask24g)", %%mm6 \n\t"
- "movq "MANGLE(mask24b)", %%mm7 \n\t"
- ".p2align 4 \n\t"
- "1: \n\t"
- PREFETCH" 32(%1, %%"REG_a") \n\t"
- "movq (%1, %%"REG_a"), %%mm0 \n\t" // BGR BGR BG
- "movq (%1, %%"REG_a"), %%mm1 \n\t" // BGR BGR BG
- "movq 2(%1, %%"REG_a"), %%mm2 \n\t" // R BGR BGR B
- "psllq $16, %%mm0 \n\t" // 00 BGR BGR
- "pand %%mm5, %%mm0 \n\t"
- "pand %%mm6, %%mm1 \n\t"
- "pand %%mm7, %%mm2 \n\t"
- "por %%mm0, %%mm1 \n\t"
- "por %%mm2, %%mm1 \n\t"
- "movq 6(%1, %%"REG_a"), %%mm0 \n\t" // BGR BGR BG
- MOVNTQ" %%mm1, (%2, %%"REG_a") \n\t" // RGB RGB RG
- "movq 8(%1, %%"REG_a"), %%mm1 \n\t" // R BGR BGR B
- "movq 10(%1, %%"REG_a"), %%mm2 \n\t" // GR BGR BGR
- "pand %%mm7, %%mm0 \n\t"
- "pand %%mm5, %%mm1 \n\t"
- "pand %%mm6, %%mm2 \n\t"
- "por %%mm0, %%mm1 \n\t"
- "por %%mm2, %%mm1 \n\t"
- "movq 14(%1, %%"REG_a"), %%mm0 \n\t" // R BGR BGR B
- MOVNTQ" %%mm1, 8(%2, %%"REG_a") \n\t" // B RGB RGB R
- "movq 16(%1, %%"REG_a"), %%mm1 \n\t" // GR BGR BGR
- "movq 18(%1, %%"REG_a"), %%mm2 \n\t" // BGR BGR BG
- "pand %%mm6, %%mm0 \n\t"
- "pand %%mm7, %%mm1 \n\t"
- "pand %%mm5, %%mm2 \n\t"
- "por %%mm0, %%mm1 \n\t"
- "por %%mm2, %%mm1 \n\t"
- MOVNTQ" %%mm1, 16(%2, %%"REG_a") \n\t"
- "add $24, %%"REG_a" \n\t"
- " js 1b \n\t"
- "2: \n\t"
- : "+a" (mmx_size)
- : "r" (src-mmx_size), "r"(dst-mmx_size)
- );
-
- __asm__ volatile(SFENCE:::"memory");
- __asm__ volatile(EMMS:::"memory");
-
- if (mmx_size==23) return; //finished, was multiple of 8
-
- src+= src_size;
- dst+= src_size;
- src_size= 23-mmx_size;
- src-= src_size;
- dst-= src_size;
- for (i=0; i<src_size; i+=3) {
- register uint8_t x;
- x = src[i + 2];
- dst[i + 1] = src[i + 1];
- dst[i + 2] = src[i + 0];
- dst[i + 0] = x;
- }
-}
-
-static inline void RENAME(yuvPlanartoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
- int width, int height,
- int lumStride, int chromStride, int dstStride, int vertLumPerChroma)
-{
- int y;
- const x86_reg chromWidth= width>>1;
- for (y=0; y<height; y++) {
- //FIXME handle 2 lines at once (fewer prefetches, reuse some chroma, but very likely memory-limited anyway)
- __asm__ volatile(
- "xor %%"REG_a", %%"REG_a" \n\t"
- ".p2align 4 \n\t"
- "1: \n\t"
- PREFETCH" 32(%1, %%"REG_a", 2) \n\t"
- PREFETCH" 32(%2, %%"REG_a") \n\t"
- PREFETCH" 32(%3, %%"REG_a") \n\t"
- "movq (%2, %%"REG_a"), %%mm0 \n\t" // U(0)
- "movq %%mm0, %%mm2 \n\t" // U(0)
- "movq (%3, %%"REG_a"), %%mm1 \n\t" // V(0)
- "punpcklbw %%mm1, %%mm0 \n\t" // UVUV UVUV(0)
- "punpckhbw %%mm1, %%mm2 \n\t" // UVUV UVUV(8)
-
- "movq (%1, %%"REG_a",2), %%mm3 \n\t" // Y(0)
- "movq 8(%1, %%"REG_a",2), %%mm5 \n\t" // Y(8)
- "movq %%mm3, %%mm4 \n\t" // Y(0)
- "movq %%mm5, %%mm6 \n\t" // Y(8)
- "punpcklbw %%mm0, %%mm3 \n\t" // YUYV YUYV(0)
- "punpckhbw %%mm0, %%mm4 \n\t" // YUYV YUYV(4)
- "punpcklbw %%mm2, %%mm5 \n\t" // YUYV YUYV(8)
- "punpckhbw %%mm2, %%mm6 \n\t" // YUYV YUYV(12)
-
- MOVNTQ" %%mm3, (%0, %%"REG_a", 4) \n\t"
- MOVNTQ" %%mm4, 8(%0, %%"REG_a", 4) \n\t"
- MOVNTQ" %%mm5, 16(%0, %%"REG_a", 4) \n\t"
- MOVNTQ" %%mm6, 24(%0, %%"REG_a", 4) \n\t"
-
- "add $8, %%"REG_a" \n\t"
- "cmp %4, %%"REG_a" \n\t"
- " jb 1b \n\t"
- ::"r"(dst), "r"(ysrc), "r"(usrc), "r"(vsrc), "g" (chromWidth)
- : "%"REG_a
- );
- if ((y&(vertLumPerChroma-1)) == vertLumPerChroma-1) {
- usrc += chromStride;
- vsrc += chromStride;
- }
- ysrc += lumStride;
- dst += dstStride;
- }
- __asm__(EMMS" \n\t"
- SFENCE" \n\t"
- :::"memory");
-}
-
-/**
- * Height should be a multiple of 2 and width should be a multiple of 16.
- * (If this is a problem for anyone then tell me, and I will fix it.)
- */
-static inline void RENAME(yv12toyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
- int width, int height,
- int lumStride, int chromStride, int dstStride)
-{
- //FIXME interpolate chroma
- RENAME(yuvPlanartoyuy2)(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride, 2);
-}
-
-static inline void RENAME(yuvPlanartouyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
- int width, int height,
- int lumStride, int chromStride, int dstStride, int vertLumPerChroma)
-{
- int y;
- const x86_reg chromWidth= width>>1;
- for (y=0; y<height; y++) {
- //FIXME handle 2 lines at once (fewer prefetches, reuse some chroma, but very likely memory-limited anyway)
- __asm__ volatile(
- "xor %%"REG_a", %%"REG_a" \n\t"
- ".p2align 4 \n\t"
- "1: \n\t"
- PREFETCH" 32(%1, %%"REG_a", 2) \n\t"
- PREFETCH" 32(%2, %%"REG_a") \n\t"
- PREFETCH" 32(%3, %%"REG_a") \n\t"
- "movq (%2, %%"REG_a"), %%mm0 \n\t" // U(0)
- "movq %%mm0, %%mm2 \n\t" // U(0)
- "movq (%3, %%"REG_a"), %%mm1 \n\t" // V(0)
- "punpcklbw %%mm1, %%mm0 \n\t" // UVUV UVUV(0)
- "punpckhbw %%mm1, %%mm2 \n\t" // UVUV UVUV(8)
-
- "movq (%1, %%"REG_a",2), %%mm3 \n\t" // Y(0)
- "movq 8(%1, %%"REG_a",2), %%mm5 \n\t" // Y(8)
- "movq %%mm0, %%mm4 \n\t" // Y(0)
- "movq %%mm2, %%mm6 \n\t" // Y(8)
- "punpcklbw %%mm3, %%mm0 \n\t" // YUYV YUYV(0)
- "punpckhbw %%mm3, %%mm4 \n\t" // YUYV YUYV(4)
- "punpcklbw %%mm5, %%mm2 \n\t" // YUYV YUYV(8)
- "punpckhbw %%mm5, %%mm6 \n\t" // YUYV YUYV(12)
-
- MOVNTQ" %%mm0, (%0, %%"REG_a", 4) \n\t"
- MOVNTQ" %%mm4, 8(%0, %%"REG_a", 4) \n\t"
- MOVNTQ" %%mm2, 16(%0, %%"REG_a", 4) \n\t"
- MOVNTQ" %%mm6, 24(%0, %%"REG_a", 4) \n\t"
-
- "add $8, %%"REG_a" \n\t"
- "cmp %4, %%"REG_a" \n\t"
- " jb 1b \n\t"
- ::"r"(dst), "r"(ysrc), "r"(usrc), "r"(vsrc), "g" (chromWidth)
- : "%"REG_a
- );
- if ((y&(vertLumPerChroma-1)) == vertLumPerChroma-1) {
- usrc += chromStride;
- vsrc += chromStride;
- }
- ysrc += lumStride;
- dst += dstStride;
- }
- __asm__(EMMS" \n\t"
- SFENCE" \n\t"
- :::"memory");
-}
-
-/**
- * Height should be a multiple of 2 and width should be a multiple of 16
- * (If this is a problem for anyone then tell me, and I will fix it.)
- */
-static inline void RENAME(yv12touyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
- int width, int height,
- int lumStride, int chromStride, int dstStride)
-{
- //FIXME interpolate chroma
- RENAME(yuvPlanartouyvy)(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride, 2);
-}
-
-/**
- * Width should be a multiple of 16.
- */
-static inline void RENAME(yuv422ptouyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
- int width, int height,
- int lumStride, int chromStride, int dstStride)
-{
- RENAME(yuvPlanartouyvy)(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride, 1);
-}
-
-/**
- * Width should be a multiple of 16.
- */
-static inline void RENAME(yuv422ptoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst,
- int width, int height,
- int lumStride, int chromStride, int dstStride)
-{
- RENAME(yuvPlanartoyuy2)(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride, 1);
-}
-
-/**
- * Height should be a multiple of 2 and width should be a multiple of 16.
- * (If this is a problem for anyone then tell me, and I will fix it.)
- */
-static inline void RENAME(yuy2toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
- int width, int height,
- int lumStride, int chromStride, int srcStride)
-{
- int y;
- const x86_reg chromWidth= width>>1;
- for (y=0; y<height; y+=2) {
- __asm__ volatile(
- "xor %%"REG_a", %%"REG_a" \n\t"
- "pcmpeqw %%mm7, %%mm7 \n\t"
- "psrlw $8, %%mm7 \n\t" // FF,00,FF,00...
- ".p2align 4 \n\t"
- "1: \n\t"
- PREFETCH" 64(%0, %%"REG_a", 4) \n\t"
- "movq (%0, %%"REG_a", 4), %%mm0 \n\t" // YUYV YUYV(0)
- "movq 8(%0, %%"REG_a", 4), %%mm1 \n\t" // YUYV YUYV(4)
- "movq %%mm0, %%mm2 \n\t" // YUYV YUYV(0)
- "movq %%mm1, %%mm3 \n\t" // YUYV YUYV(4)
- "psrlw $8, %%mm0 \n\t" // U0V0 U0V0(0)
- "psrlw $8, %%mm1 \n\t" // U0V0 U0V0(4)
- "pand %%mm7, %%mm2 \n\t" // Y0Y0 Y0Y0(0)
- "pand %%mm7, %%mm3 \n\t" // Y0Y0 Y0Y0(4)
- "packuswb %%mm1, %%mm0 \n\t" // UVUV UVUV(0)
- "packuswb %%mm3, %%mm2 \n\t" // YYYY YYYY(0)
-
- MOVNTQ" %%mm2, (%1, %%"REG_a", 2) \n\t"
-
- "movq 16(%0, %%"REG_a", 4), %%mm1 \n\t" // YUYV YUYV(8)
- "movq 24(%0, %%"REG_a", 4), %%mm2 \n\t" // YUYV YUYV(12)
- "movq %%mm1, %%mm3 \n\t" // YUYV YUYV(8)
- "movq %%mm2, %%mm4 \n\t" // YUYV YUYV(12)
- "psrlw $8, %%mm1 \n\t" // U0V0 U0V0(8)
- "psrlw $8, %%mm2 \n\t" // U0V0 U0V0(12)
- "pand %%mm7, %%mm3 \n\t" // Y0Y0 Y0Y0(8)
- "pand %%mm7, %%mm4 \n\t" // Y0Y0 Y0Y0(12)
- "packuswb %%mm2, %%mm1 \n\t" // UVUV UVUV(8)
- "packuswb %%mm4, %%mm3 \n\t" // YYYY YYYY(8)
-
- MOVNTQ" %%mm3, 8(%1, %%"REG_a", 2) \n\t"
-
- "movq %%mm0, %%mm2 \n\t" // UVUV UVUV(0)
- "movq %%mm1, %%mm3 \n\t" // UVUV UVUV(8)
- "psrlw $8, %%mm0 \n\t" // V0V0 V0V0(0)
- "psrlw $8, %%mm1 \n\t" // V0V0 V0V0(8)
- "pand %%mm7, %%mm2 \n\t" // U0U0 U0U0(0)
- "pand %%mm7, %%mm3 \n\t" // U0U0 U0U0(8)
- "packuswb %%mm1, %%mm0 \n\t" // VVVV VVVV(0)
- "packuswb %%mm3, %%mm2 \n\t" // UUUU UUUU(0)
-
- MOVNTQ" %%mm0, (%3, %%"REG_a") \n\t"
- MOVNTQ" %%mm2, (%2, %%"REG_a") \n\t"
-
- "add $8, %%"REG_a" \n\t"
- "cmp %4, %%"REG_a" \n\t"
- " jb 1b \n\t"
- ::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "g" (chromWidth)
- : "memory", "%"REG_a
- );
-
- ydst += lumStride;
- src += srcStride;
-
- __asm__ volatile(
- "xor %%"REG_a", %%"REG_a" \n\t"
- ".p2align 4 \n\t"
- "1: \n\t"
- PREFETCH" 64(%0, %%"REG_a", 4) \n\t"
- "movq (%0, %%"REG_a", 4), %%mm0 \n\t" // YUYV YUYV(0)
- "movq 8(%0, %%"REG_a", 4), %%mm1 \n\t" // YUYV YUYV(4)
- "movq 16(%0, %%"REG_a", 4), %%mm2 \n\t" // YUYV YUYV(8)
- "movq 24(%0, %%"REG_a", 4), %%mm3 \n\t" // YUYV YUYV(12)
- "pand %%mm7, %%mm0 \n\t" // Y0Y0 Y0Y0(0)
- "pand %%mm7, %%mm1 \n\t" // Y0Y0 Y0Y0(4)
- "pand %%mm7, %%mm2 \n\t" // Y0Y0 Y0Y0(8)
- "pand %%mm7, %%mm3 \n\t" // Y0Y0 Y0Y0(12)
- "packuswb %%mm1, %%mm0 \n\t" // YYYY YYYY(0)
- "packuswb %%mm3, %%mm2 \n\t" // YYYY YYYY(8)
-
- MOVNTQ" %%mm0, (%1, %%"REG_a", 2) \n\t"
- MOVNTQ" %%mm2, 8(%1, %%"REG_a", 2) \n\t"
-
- "add $8, %%"REG_a" \n\t"
- "cmp %4, %%"REG_a" \n\t"
- " jb 1b \n\t"
-
- ::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "g" (chromWidth)
- : "memory", "%"REG_a
- );
- udst += chromStride;
- vdst += chromStride;
- ydst += lumStride;
- src += srcStride;
- }
- __asm__ volatile(EMMS" \n\t"
- SFENCE" \n\t"
- :::"memory");
-}
-#endif /* !COMPILE_TEMPLATE_AMD3DNOW */
-
-#if COMPILE_TEMPLATE_MMXEXT || COMPILE_TEMPLATE_AMD3DNOW
-static inline void RENAME(planar2x)(const uint8_t *src, uint8_t *dst, int srcWidth, int srcHeight, int srcStride, int dstStride)
-{
- int x,y;
-
- dst[0]= src[0];
-
- // first line
- for (x=0; x<srcWidth-1; x++) {
- dst[2*x+1]= (3*src[x] + src[x+1])>>2;
- dst[2*x+2]= ( src[x] + 3*src[x+1])>>2;
- }
- dst[2*srcWidth-1]= src[srcWidth-1];
-
- dst+= dstStride;
-
- for (y=1; y<srcHeight; y++) {
- const x86_reg mmxSize= srcWidth&~15;
- __asm__ volatile(
- "mov %4, %%"REG_a" \n\t"
- "movq "MANGLE(mmx_ff)", %%mm0 \n\t"
- "movq (%0, %%"REG_a"), %%mm4 \n\t"
- "movq %%mm4, %%mm2 \n\t"
- "psllq $8, %%mm4 \n\t"
- "pand %%mm0, %%mm2 \n\t"
- "por %%mm2, %%mm4 \n\t"
- "movq (%1, %%"REG_a"), %%mm5 \n\t"
- "movq %%mm5, %%mm3 \n\t"
- "psllq $8, %%mm5 \n\t"
- "pand %%mm0, %%mm3 \n\t"
- "por %%mm3, %%mm5 \n\t"
- "1: \n\t"
- "movq (%0, %%"REG_a"), %%mm0 \n\t"
- "movq (%1, %%"REG_a"), %%mm1 \n\t"
- "movq 1(%0, %%"REG_a"), %%mm2 \n\t"
- "movq 1(%1, %%"REG_a"), %%mm3 \n\t"
- PAVGB" %%mm0, %%mm5 \n\t"
- PAVGB" %%mm0, %%mm3 \n\t"
- PAVGB" %%mm0, %%mm5 \n\t"
- PAVGB" %%mm0, %%mm3 \n\t"
- PAVGB" %%mm1, %%mm4 \n\t"
- PAVGB" %%mm1, %%mm2 \n\t"
- PAVGB" %%mm1, %%mm4 \n\t"
- PAVGB" %%mm1, %%mm2 \n\t"
- "movq %%mm5, %%mm7 \n\t"
- "movq %%mm4, %%mm6 \n\t"
- "punpcklbw %%mm3, %%mm5 \n\t"
- "punpckhbw %%mm3, %%mm7 \n\t"
- "punpcklbw %%mm2, %%mm4 \n\t"
- "punpckhbw %%mm2, %%mm6 \n\t"
- MOVNTQ" %%mm5, (%2, %%"REG_a", 2) \n\t"
- MOVNTQ" %%mm7, 8(%2, %%"REG_a", 2) \n\t"
- MOVNTQ" %%mm4, (%3, %%"REG_a", 2) \n\t"
- MOVNTQ" %%mm6, 8(%3, %%"REG_a", 2) \n\t"
- "add $8, %%"REG_a" \n\t"
- "movq -1(%0, %%"REG_a"), %%mm4 \n\t"
- "movq -1(%1, %%"REG_a"), %%mm5 \n\t"
- " js 1b \n\t"
- :: "r" (src + mmxSize ), "r" (src + srcStride + mmxSize ),
- "r" (dst + mmxSize*2), "r" (dst + dstStride + mmxSize*2),
- "g" (-mmxSize)
- : "%"REG_a
- );
-
- for (x=mmxSize-1; x<srcWidth-1; x++) {
- dst[2*x +1]= (3*src[x+0] + src[x+srcStride+1])>>2;
- dst[2*x+dstStride+2]= ( src[x+0] + 3*src[x+srcStride+1])>>2;
- dst[2*x+dstStride+1]= ( src[x+1] + 3*src[x+srcStride ])>>2;
- dst[2*x +2]= (3*src[x+1] + src[x+srcStride ])>>2;
- }
- dst[srcWidth*2 -1 ]= (3*src[srcWidth-1] + src[srcWidth-1 + srcStride])>>2;
- dst[srcWidth*2 -1 + dstStride]= ( src[srcWidth-1] + 3*src[srcWidth-1 + srcStride])>>2;
-
- dst+=dstStride*2;
- src+=srcStride;
- }
-
- // last line
- dst[0]= src[0];
-
- for (x=0; x<srcWidth-1; x++) {
- dst[2*x+1]= (3*src[x] + src[x+1])>>2;
- dst[2*x+2]= ( src[x] + 3*src[x+1])>>2;
- }
- dst[2*srcWidth-1]= src[srcWidth-1];
-
- __asm__ volatile(EMMS" \n\t"
- SFENCE" \n\t"
- :::"memory");
-}
-#endif /* COMPILE_TEMPLATE_MMXEXT || COMPILE_TEMPLATE_AMD3DNOW */
-
-#if !COMPILE_TEMPLATE_AMD3DNOW
-/**
- * Height should be a multiple of 2 and width should be a multiple of 16.
- * (If this is a problem for anyone then tell me, and I will fix it.)
- * Chrominance data is only taken from every second line, others are ignored.
- * FIXME: Write HQ version.
- */
-static inline void RENAME(uyvytoyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
- int width, int height,
- int lumStride, int chromStride, int srcStride)
-{
- int y;
- const x86_reg chromWidth= width>>1;
- for (y=0; y<height; y+=2) {
- __asm__ volatile(
- "xor %%"REG_a", %%"REG_a" \n\t"
- "pcmpeqw %%mm7, %%mm7 \n\t"
- "psrlw $8, %%mm7 \n\t" // FF,00,FF,00...
- ".p2align 4 \n\t"
- "1: \n\t"
- PREFETCH" 64(%0, %%"REG_a", 4) \n\t"
- "movq (%0, %%"REG_a", 4), %%mm0 \n\t" // UYVY UYVY(0)
- "movq 8(%0, %%"REG_a", 4), %%mm1 \n\t" // UYVY UYVY(4)
- "movq %%mm0, %%mm2 \n\t" // UYVY UYVY(0)
- "movq %%mm1, %%mm3 \n\t" // UYVY UYVY(4)
- "pand %%mm7, %%mm0 \n\t" // U0V0 U0V0(0)
- "pand %%mm7, %%mm1 \n\t" // U0V0 U0V0(4)
- "psrlw $8, %%mm2 \n\t" // Y0Y0 Y0Y0(0)
- "psrlw $8, %%mm3 \n\t" // Y0Y0 Y0Y0(4)
- "packuswb %%mm1, %%mm0 \n\t" // UVUV UVUV(0)
- "packuswb %%mm3, %%mm2 \n\t" // YYYY YYYY(0)
-
- MOVNTQ" %%mm2, (%1, %%"REG_a", 2) \n\t"
-
- "movq 16(%0, %%"REG_a", 4), %%mm1 \n\t" // UYVY UYVY(8)
- "movq 24(%0, %%"REG_a", 4), %%mm2 \n\t" // UYVY UYVY(12)
- "movq %%mm1, %%mm3 \n\t" // UYVY UYVY(8)
- "movq %%mm2, %%mm4 \n\t" // UYVY UYVY(12)
- "pand %%mm7, %%mm1 \n\t" // U0V0 U0V0(8)
- "pand %%mm7, %%mm2 \n\t" // U0V0 U0V0(12)
- "psrlw $8, %%mm3 \n\t" // Y0Y0 Y0Y0(8)
- "psrlw $8, %%mm4 \n\t" // Y0Y0 Y0Y0(12)
- "packuswb %%mm2, %%mm1 \n\t" // UVUV UVUV(8)
- "packuswb %%mm4, %%mm3 \n\t" // YYYY YYYY(8)
-
- MOVNTQ" %%mm3, 8(%1, %%"REG_a", 2) \n\t"
-
- "movq %%mm0, %%mm2 \n\t" // UVUV UVUV(0)
- "movq %%mm1, %%mm3 \n\t" // UVUV UVUV(8)
- "psrlw $8, %%mm0 \n\t" // V0V0 V0V0(0)
- "psrlw $8, %%mm1 \n\t" // V0V0 V0V0(8)
- "pand %%mm7, %%mm2 \n\t" // U0U0 U0U0(0)
- "pand %%mm7, %%mm3 \n\t" // U0U0 U0U0(8)
- "packuswb %%mm1, %%mm0 \n\t" // VVVV VVVV(0)
- "packuswb %%mm3, %%mm2 \n\t" // UUUU UUUU(0)
-
- MOVNTQ" %%mm0, (%3, %%"REG_a") \n\t"
- MOVNTQ" %%mm2, (%2, %%"REG_a") \n\t"
-
- "add $8, %%"REG_a" \n\t"
- "cmp %4, %%"REG_a" \n\t"
- " jb 1b \n\t"
- ::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "g" (chromWidth)
- : "memory", "%"REG_a
- );
-
- ydst += lumStride;
- src += srcStride;
-
- __asm__ volatile(
- "xor %%"REG_a", %%"REG_a" \n\t"
- ".p2align 4 \n\t"
- "1: \n\t"
- PREFETCH" 64(%0, %%"REG_a", 4) \n\t"
- "movq (%0, %%"REG_a", 4), %%mm0 \n\t" // YUYV YUYV(0)
- "movq 8(%0, %%"REG_a", 4), %%mm1 \n\t" // YUYV YUYV(4)
- "movq 16(%0, %%"REG_a", 4), %%mm2 \n\t" // YUYV YUYV(8)
- "movq 24(%0, %%"REG_a", 4), %%mm3 \n\t" // YUYV YUYV(12)
- "psrlw $8, %%mm0 \n\t" // Y0Y0 Y0Y0(0)
- "psrlw $8, %%mm1 \n\t" // Y0Y0 Y0Y0(4)
- "psrlw $8, %%mm2 \n\t" // Y0Y0 Y0Y0(8)
- "psrlw $8, %%mm3 \n\t" // Y0Y0 Y0Y0(12)
- "packuswb %%mm1, %%mm0 \n\t" // YYYY YYYY(0)
- "packuswb %%mm3, %%mm2 \n\t" // YYYY YYYY(8)
-
- MOVNTQ" %%mm0, (%1, %%"REG_a", 2) \n\t"
- MOVNTQ" %%mm2, 8(%1, %%"REG_a", 2) \n\t"
-
- "add $8, %%"REG_a" \n\t"
- "cmp %4, %%"REG_a" \n\t"
- " jb 1b \n\t"
-
- ::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "g" (chromWidth)
- : "memory", "%"REG_a
- );
- udst += chromStride;
- vdst += chromStride;
- ydst += lumStride;
- src += srcStride;
- }
- __asm__ volatile(EMMS" \n\t"
- SFENCE" \n\t"
- :::"memory");
-}
-#endif /* !COMPILE_TEMPLATE_AMD3DNOW */
-
-/**
- * Height should be a multiple of 2 and width should be a multiple of 2.
- * (If this is a problem for anyone then tell me, and I will fix it.)
- * Chrominance data is only taken from every second line,
- * others are ignored in the C version.
- * FIXME: Write HQ version.
- */
-static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
- int width, int height,
- int lumStride, int chromStride, int srcStride)
-{
- int y;
- const x86_reg chromWidth= width>>1;
- for (y=0; y<height-2; y+=2) {
- int i;
- for (i=0; i<2; i++) {
- __asm__ volatile(
- "mov %2, %%"REG_a" \n\t"
- "movq "MANGLE(ff_bgr2YCoeff)", %%mm6 \n\t"
- "movq "MANGLE(ff_w1111)", %%mm5 \n\t"
- "pxor %%mm7, %%mm7 \n\t"
- "lea (%%"REG_a", %%"REG_a", 2), %%"REG_d" \n\t"
- ".p2align 4 \n\t"
- "1: \n\t"
- PREFETCH" 64(%0, %%"REG_d") \n\t"
- "movd (%0, %%"REG_d"), %%mm0 \n\t"
- "movd 3(%0, %%"REG_d"), %%mm1 \n\t"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "punpcklbw %%mm7, %%mm1 \n\t"
- "movd 6(%0, %%"REG_d"), %%mm2 \n\t"
- "movd 9(%0, %%"REG_d"), %%mm3 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
- "punpcklbw %%mm7, %%mm3 \n\t"
- "pmaddwd %%mm6, %%mm0 \n\t"
- "pmaddwd %%mm6, %%mm1 \n\t"
- "pmaddwd %%mm6, %%mm2 \n\t"
- "pmaddwd %%mm6, %%mm3 \n\t"
-#ifndef FAST_BGR2YV12
- "psrad $8, %%mm0 \n\t"
- "psrad $8, %%mm1 \n\t"
- "psrad $8, %%mm2 \n\t"
- "psrad $8, %%mm3 \n\t"
-#endif
- "packssdw %%mm1, %%mm0 \n\t"
- "packssdw %%mm3, %%mm2 \n\t"
- "pmaddwd %%mm5, %%mm0 \n\t"
- "pmaddwd %%mm5, %%mm2 \n\t"
- "packssdw %%mm2, %%mm0 \n\t"
- "psraw $7, %%mm0 \n\t"
-
- "movd 12(%0, %%"REG_d"), %%mm4 \n\t"
- "movd 15(%0, %%"REG_d"), %%mm1 \n\t"
- "punpcklbw %%mm7, %%mm4 \n\t"
- "punpcklbw %%mm7, %%mm1 \n\t"
- "movd 18(%0, %%"REG_d"), %%mm2 \n\t"
- "movd 21(%0, %%"REG_d"), %%mm3 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
- "punpcklbw %%mm7, %%mm3 \n\t"
- "pmaddwd %%mm6, %%mm4 \n\t"
- "pmaddwd %%mm6, %%mm1 \n\t"
- "pmaddwd %%mm6, %%mm2 \n\t"
- "pmaddwd %%mm6, %%mm3 \n\t"
-#ifndef FAST_BGR2YV12
- "psrad $8, %%mm4 \n\t"
- "psrad $8, %%mm1 \n\t"
- "psrad $8, %%mm2 \n\t"
- "psrad $8, %%mm3 \n\t"
-#endif
- "packssdw %%mm1, %%mm4 \n\t"
- "packssdw %%mm3, %%mm2 \n\t"
- "pmaddwd %%mm5, %%mm4 \n\t"
- "pmaddwd %%mm5, %%mm2 \n\t"
- "add $24, %%"REG_d" \n\t"
- "packssdw %%mm2, %%mm4 \n\t"
- "psraw $7, %%mm4 \n\t"
-
- "packuswb %%mm4, %%mm0 \n\t"
- "paddusb "MANGLE(ff_bgr2YOffset)", %%mm0 \n\t"
-
- MOVNTQ" %%mm0, (%1, %%"REG_a") \n\t"
- "add $8, %%"REG_a" \n\t"
- " js 1b \n\t"
- : : "r" (src+width*3), "r" (ydst+width), "g" ((x86_reg)-width)
- : "%"REG_a, "%"REG_d
- );
- ydst += lumStride;
- src += srcStride;
- }
- src -= srcStride*2;
- __asm__ volatile(
- "mov %4, %%"REG_a" \n\t"
- "movq "MANGLE(ff_w1111)", %%mm5 \n\t"
- "movq "MANGLE(ff_bgr2UCoeff)", %%mm6 \n\t"
- "pxor %%mm7, %%mm7 \n\t"
- "lea (%%"REG_a", %%"REG_a", 2), %%"REG_d" \n\t"
- "add %%"REG_d", %%"REG_d" \n\t"
- ".p2align 4 \n\t"
- "1: \n\t"
- PREFETCH" 64(%0, %%"REG_d") \n\t"
- PREFETCH" 64(%1, %%"REG_d") \n\t"
-#if COMPILE_TEMPLATE_MMXEXT || COMPILE_TEMPLATE_AMD3DNOW
- "movq (%0, %%"REG_d"), %%mm0 \n\t"
- "movq (%1, %%"REG_d"), %%mm1 \n\t"
- "movq 6(%0, %%"REG_d"), %%mm2 \n\t"
- "movq 6(%1, %%"REG_d"), %%mm3 \n\t"
- PAVGB" %%mm1, %%mm0 \n\t"
- PAVGB" %%mm3, %%mm2 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "movq %%mm2, %%mm3 \n\t"
- "psrlq $24, %%mm0 \n\t"
- "psrlq $24, %%mm2 \n\t"
- PAVGB" %%mm1, %%mm0 \n\t"
- PAVGB" %%mm3, %%mm2 \n\t"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
-#else
- "movd (%0, %%"REG_d"), %%mm0 \n\t"
- "movd (%1, %%"REG_d"), %%mm1 \n\t"
- "movd 3(%0, %%"REG_d"), %%mm2 \n\t"
- "movd 3(%1, %%"REG_d"), %%mm3 \n\t"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "punpcklbw %%mm7, %%mm1 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
- "punpcklbw %%mm7, %%mm3 \n\t"
- "paddw %%mm1, %%mm0 \n\t"
- "paddw %%mm3, %%mm2 \n\t"
- "paddw %%mm2, %%mm0 \n\t"
- "movd 6(%0, %%"REG_d"), %%mm4 \n\t"
- "movd 6(%1, %%"REG_d"), %%mm1 \n\t"
- "movd 9(%0, %%"REG_d"), %%mm2 \n\t"
- "movd 9(%1, %%"REG_d"), %%mm3 \n\t"
- "punpcklbw %%mm7, %%mm4 \n\t"
- "punpcklbw %%mm7, %%mm1 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
- "punpcklbw %%mm7, %%mm3 \n\t"
- "paddw %%mm1, %%mm4 \n\t"
- "paddw %%mm3, %%mm2 \n\t"
- "paddw %%mm4, %%mm2 \n\t"
- "psrlw $2, %%mm0 \n\t"
- "psrlw $2, %%mm2 \n\t"
-#endif
- "movq "MANGLE(ff_bgr2VCoeff)", %%mm1 \n\t"
- "movq "MANGLE(ff_bgr2VCoeff)", %%mm3 \n\t"
-
- "pmaddwd %%mm0, %%mm1 \n\t"
- "pmaddwd %%mm2, %%mm3 \n\t"
- "pmaddwd %%mm6, %%mm0 \n\t"
- "pmaddwd %%mm6, %%mm2 \n\t"
-#ifndef FAST_BGR2YV12
- "psrad $8, %%mm0 \n\t"
- "psrad $8, %%mm1 \n\t"
- "psrad $8, %%mm2 \n\t"
- "psrad $8, %%mm3 \n\t"
-#endif
- "packssdw %%mm2, %%mm0 \n\t"
- "packssdw %%mm3, %%mm1 \n\t"
- "pmaddwd %%mm5, %%mm0 \n\t"
- "pmaddwd %%mm5, %%mm1 \n\t"
- "packssdw %%mm1, %%mm0 \n\t" // V1 V0 U1 U0
- "psraw $7, %%mm0 \n\t"
-
-#if COMPILE_TEMPLATE_MMXEXT || COMPILE_TEMPLATE_AMD3DNOW
- "movq 12(%0, %%"REG_d"), %%mm4 \n\t"
- "movq 12(%1, %%"REG_d"), %%mm1 \n\t"
- "movq 18(%0, %%"REG_d"), %%mm2 \n\t"
- "movq 18(%1, %%"REG_d"), %%mm3 \n\t"
- PAVGB" %%mm1, %%mm4 \n\t"
- PAVGB" %%mm3, %%mm2 \n\t"
- "movq %%mm4, %%mm1 \n\t"
- "movq %%mm2, %%mm3 \n\t"
- "psrlq $24, %%mm4 \n\t"
- "psrlq $24, %%mm2 \n\t"
- PAVGB" %%mm1, %%mm4 \n\t"
- PAVGB" %%mm3, %%mm2 \n\t"
- "punpcklbw %%mm7, %%mm4 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
-#else
- "movd 12(%0, %%"REG_d"), %%mm4 \n\t"
- "movd 12(%1, %%"REG_d"), %%mm1 \n\t"
- "movd 15(%0, %%"REG_d"), %%mm2 \n\t"
- "movd 15(%1, %%"REG_d"), %%mm3 \n\t"
- "punpcklbw %%mm7, %%mm4 \n\t"
- "punpcklbw %%mm7, %%mm1 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
- "punpcklbw %%mm7, %%mm3 \n\t"
- "paddw %%mm1, %%mm4 \n\t"
- "paddw %%mm3, %%mm2 \n\t"
- "paddw %%mm2, %%mm4 \n\t"
- "movd 18(%0, %%"REG_d"), %%mm5 \n\t"
- "movd 18(%1, %%"REG_d"), %%mm1 \n\t"
- "movd 21(%0, %%"REG_d"), %%mm2 \n\t"
- "movd 21(%1, %%"REG_d"), %%mm3 \n\t"
- "punpcklbw %%mm7, %%mm5 \n\t"
- "punpcklbw %%mm7, %%mm1 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
- "punpcklbw %%mm7, %%mm3 \n\t"
- "paddw %%mm1, %%mm5 \n\t"
- "paddw %%mm3, %%mm2 \n\t"
- "paddw %%mm5, %%mm2 \n\t"
- "movq "MANGLE(ff_w1111)", %%mm5 \n\t"
- "psrlw $2, %%mm4 \n\t"
- "psrlw $2, %%mm2 \n\t"
-#endif
- "movq "MANGLE(ff_bgr2VCoeff)", %%mm1 \n\t"
- "movq "MANGLE(ff_bgr2VCoeff)", %%mm3 \n\t"
-
- "pmaddwd %%mm4, %%mm1 \n\t"
- "pmaddwd %%mm2, %%mm3 \n\t"
- "pmaddwd %%mm6, %%mm4 \n\t"
- "pmaddwd %%mm6, %%mm2 \n\t"
-#ifndef FAST_BGR2YV12
- "psrad $8, %%mm4 \n\t"
- "psrad $8, %%mm1 \n\t"
- "psrad $8, %%mm2 \n\t"
- "psrad $8, %%mm3 \n\t"
-#endif
- "packssdw %%mm2, %%mm4 \n\t"
- "packssdw %%mm3, %%mm1 \n\t"
- "pmaddwd %%mm5, %%mm4 \n\t"
- "pmaddwd %%mm5, %%mm1 \n\t"
- "add $24, %%"REG_d" \n\t"
- "packssdw %%mm1, %%mm4 \n\t" // V3 V2 U3 U2
- "psraw $7, %%mm4 \n\t"
-
- "movq %%mm0, %%mm1 \n\t"
- "punpckldq %%mm4, %%mm0 \n\t"
- "punpckhdq %%mm4, %%mm1 \n\t"
- "packsswb %%mm1, %%mm0 \n\t"
- "paddb "MANGLE(ff_bgr2UVOffset)", %%mm0 \n\t"
- "movd %%mm0, (%2, %%"REG_a") \n\t"
- "punpckhdq %%mm0, %%mm0 \n\t"
- "movd %%mm0, (%3, %%"REG_a") \n\t"
- "add $4, %%"REG_a" \n\t"
- " js 1b \n\t"
- : : "r" (src+chromWidth*6), "r" (src+srcStride+chromWidth*6), "r" (udst+chromWidth), "r" (vdst+chromWidth), "g" (-chromWidth)
- : "%"REG_a, "%"REG_d
- );
-
- udst += chromStride;
- vdst += chromStride;
- src += srcStride*2;
- }
-
- __asm__ volatile(EMMS" \n\t"
- SFENCE" \n\t"
- :::"memory");
-
- rgb24toyv12_c(src, ydst, udst, vdst, width, height-y, lumStride, chromStride, srcStride);
-}
-#endif /* !COMPILE_TEMPLATE_SSE2 */
-
-#if !COMPILE_TEMPLATE_AMD3DNOW
-static void RENAME(interleaveBytes)(const uint8_t *src1, const uint8_t *src2, uint8_t *dest,
- int width, int height, int src1Stride,
- int src2Stride, int dstStride)
-{
- int h;
-
- for (h=0; h < height; h++) {
- int w;
-
-#if COMPILE_TEMPLATE_SSE2
- __asm__(
- "xor %%"REG_a", %%"REG_a" \n\t"
- "1: \n\t"
- PREFETCH" 64(%1, %%"REG_a") \n\t"
- PREFETCH" 64(%2, %%"REG_a") \n\t"
- "movdqa (%1, %%"REG_a"), %%xmm0 \n\t"
- "movdqa (%1, %%"REG_a"), %%xmm1 \n\t"
- "movdqa (%2, %%"REG_a"), %%xmm2 \n\t"
- "punpcklbw %%xmm2, %%xmm0 \n\t"
- "punpckhbw %%xmm2, %%xmm1 \n\t"
- "movntdq %%xmm0, (%0, %%"REG_a", 2) \n\t"
- "movntdq %%xmm1, 16(%0, %%"REG_a", 2) \n\t"
- "add $16, %%"REG_a" \n\t"
- "cmp %3, %%"REG_a" \n\t"
- " jb 1b \n\t"
- ::"r"(dest), "r"(src1), "r"(src2), "r" ((x86_reg)width-15)
- : "memory", "%"REG_a""
- );
-#else
- __asm__(
- "xor %%"REG_a", %%"REG_a" \n\t"
- "1: \n\t"
- PREFETCH" 64(%1, %%"REG_a") \n\t"
- PREFETCH" 64(%2, %%"REG_a") \n\t"
- "movq (%1, %%"REG_a"), %%mm0 \n\t"
- "movq 8(%1, %%"REG_a"), %%mm2 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "movq %%mm2, %%mm3 \n\t"
- "movq (%2, %%"REG_a"), %%mm4 \n\t"
- "movq 8(%2, %%"REG_a"), %%mm5 \n\t"
- "punpcklbw %%mm4, %%mm0 \n\t"
- "punpckhbw %%mm4, %%mm1 \n\t"
- "punpcklbw %%mm5, %%mm2 \n\t"
- "punpckhbw %%mm5, %%mm3 \n\t"
- MOVNTQ" %%mm0, (%0, %%"REG_a", 2) \n\t"
- MOVNTQ" %%mm1, 8(%0, %%"REG_a", 2) \n\t"
- MOVNTQ" %%mm2, 16(%0, %%"REG_a", 2) \n\t"
- MOVNTQ" %%mm3, 24(%0, %%"REG_a", 2) \n\t"
- "add $16, %%"REG_a" \n\t"
- "cmp %3, %%"REG_a" \n\t"
- " jb 1b \n\t"
- ::"r"(dest), "r"(src1), "r"(src2), "r" ((x86_reg)width-15)
- : "memory", "%"REG_a
- );
-#endif
- for (w= (width&(~15)); w < width; w++) {
- dest[2*w+0] = src1[w];
- dest[2*w+1] = src2[w];
- }
- dest += dstStride;
- src1 += src1Stride;
- src2 += src2Stride;
- }
- __asm__(
- EMMS" \n\t"
- SFENCE" \n\t"
- ::: "memory"
- );
-}
-#endif /* !COMPILE_TEMPLATE_AMD3DNOW */
-
-#if !COMPILE_TEMPLATE_SSE2
-#if !COMPILE_TEMPLATE_AMD3DNOW
-static inline void RENAME(vu9_to_vu12)(const uint8_t *src1, const uint8_t *src2,
- uint8_t *dst1, uint8_t *dst2,
- int width, int height,
- int srcStride1, int srcStride2,
- int dstStride1, int dstStride2)
-{
- x86_reg x, y;
- int w,h;
- w=width/2; h=height/2;
- __asm__ volatile(
- PREFETCH" %0 \n\t"
- PREFETCH" %1 \n\t"
- ::"m"(*(src1+srcStride1)),"m"(*(src2+srcStride2)):"memory");
- for (y=0;y<h;y++) {
- const uint8_t* s1=src1+srcStride1*(y>>1);
- uint8_t* d=dst1+dstStride1*y;
- x=0;
- for (;x<w-31;x+=32) {
- __asm__ volatile(
- PREFETCH" 32(%1,%2) \n\t"
- "movq (%1,%2), %%mm0 \n\t"
- "movq 8(%1,%2), %%mm2 \n\t"
- "movq 16(%1,%2), %%mm4 \n\t"
- "movq 24(%1,%2), %%mm6 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "movq %%mm2, %%mm3 \n\t"
- "movq %%mm4, %%mm5 \n\t"
- "movq %%mm6, %%mm7 \n\t"
- "punpcklbw %%mm0, %%mm0 \n\t"
- "punpckhbw %%mm1, %%mm1 \n\t"
- "punpcklbw %%mm2, %%mm2 \n\t"
- "punpckhbw %%mm3, %%mm3 \n\t"
- "punpcklbw %%mm4, %%mm4 \n\t"
- "punpckhbw %%mm5, %%mm5 \n\t"
- "punpcklbw %%mm6, %%mm6 \n\t"
- "punpckhbw %%mm7, %%mm7 \n\t"
- MOVNTQ" %%mm0, (%0,%2,2) \n\t"
- MOVNTQ" %%mm1, 8(%0,%2,2) \n\t"
- MOVNTQ" %%mm2, 16(%0,%2,2) \n\t"
- MOVNTQ" %%mm3, 24(%0,%2,2) \n\t"
- MOVNTQ" %%mm4, 32(%0,%2,2) \n\t"
- MOVNTQ" %%mm5, 40(%0,%2,2) \n\t"
- MOVNTQ" %%mm6, 48(%0,%2,2) \n\t"
- MOVNTQ" %%mm7, 56(%0,%2,2)"
- :: "r"(d), "r"(s1), "r"(x)
- :"memory");
- }
- for (;x<w;x++) d[2*x]=d[2*x+1]=s1[x];
- }
- for (y=0;y<h;y++) {
- const uint8_t* s2=src2+srcStride2*(y>>1);
- uint8_t* d=dst2+dstStride2*y;
- x=0;
- for (;x<w-31;x+=32) {
- __asm__ volatile(
- PREFETCH" 32(%1,%2) \n\t"
- "movq (%1,%2), %%mm0 \n\t"
- "movq 8(%1,%2), %%mm2 \n\t"
- "movq 16(%1,%2), %%mm4 \n\t"
- "movq 24(%1,%2), %%mm6 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "movq %%mm2, %%mm3 \n\t"
- "movq %%mm4, %%mm5 \n\t"
- "movq %%mm6, %%mm7 \n\t"
- "punpcklbw %%mm0, %%mm0 \n\t"
- "punpckhbw %%mm1, %%mm1 \n\t"
- "punpcklbw %%mm2, %%mm2 \n\t"
- "punpckhbw %%mm3, %%mm3 \n\t"
- "punpcklbw %%mm4, %%mm4 \n\t"
- "punpckhbw %%mm5, %%mm5 \n\t"
- "punpcklbw %%mm6, %%mm6 \n\t"
- "punpckhbw %%mm7, %%mm7 \n\t"
- MOVNTQ" %%mm0, (%0,%2,2) \n\t"
- MOVNTQ" %%mm1, 8(%0,%2,2) \n\t"
- MOVNTQ" %%mm2, 16(%0,%2,2) \n\t"
- MOVNTQ" %%mm3, 24(%0,%2,2) \n\t"
- MOVNTQ" %%mm4, 32(%0,%2,2) \n\t"
- MOVNTQ" %%mm5, 40(%0,%2,2) \n\t"
- MOVNTQ" %%mm6, 48(%0,%2,2) \n\t"
- MOVNTQ" %%mm7, 56(%0,%2,2)"
- :: "r"(d), "r"(s2), "r"(x)
- :"memory");
- }
- for (;x<w;x++) d[2*x]=d[2*x+1]=s2[x];
- }
- __asm__(
- EMMS" \n\t"
- SFENCE" \n\t"
- ::: "memory"
- );
-}
-
-static inline void RENAME(yvu9_to_yuy2)(const uint8_t *src1, const uint8_t *src2, const uint8_t *src3,
- uint8_t *dst,
- int width, int height,
- int srcStride1, int srcStride2,
- int srcStride3, int dstStride)
-{
- x86_reg x;
- int y,w,h;
- w=width/2; h=height;
- for (y=0;y<h;y++) {
- const uint8_t* yp=src1+srcStride1*y;
- const uint8_t* up=src2+srcStride2*(y>>2);
- const uint8_t* vp=src3+srcStride3*(y>>2);
- uint8_t* d=dst+dstStride*y;
- x=0;
- for (;x<w-7;x+=8) {
- __asm__ volatile(
- PREFETCH" 32(%1, %0) \n\t"
- PREFETCH" 32(%2, %0) \n\t"
- PREFETCH" 32(%3, %0) \n\t"
- "movq (%1, %0, 4), %%mm0 \n\t" /* Y0Y1Y2Y3Y4Y5Y6Y7 */
- "movq (%2, %0), %%mm1 \n\t" /* U0U1U2U3U4U5U6U7 */
- "movq (%3, %0), %%mm2 \n\t" /* V0V1V2V3V4V5V6V7 */
- "movq %%mm0, %%mm3 \n\t" /* Y0Y1Y2Y3Y4Y5Y6Y7 */
- "movq %%mm1, %%mm4 \n\t" /* U0U1U2U3U4U5U6U7 */
- "movq %%mm2, %%mm5 \n\t" /* V0V1V2V3V4V5V6V7 */
- "punpcklbw %%mm1, %%mm1 \n\t" /* U0U0 U1U1 U2U2 U3U3 */
- "punpcklbw %%mm2, %%mm2 \n\t" /* V0V0 V1V1 V2V2 V3V3 */
- "punpckhbw %%mm4, %%mm4 \n\t" /* U4U4 U5U5 U6U6 U7U7 */
- "punpckhbw %%mm5, %%mm5 \n\t" /* V4V4 V5V5 V6V6 V7V7 */
-
- "movq %%mm1, %%mm6 \n\t"
- "punpcklbw %%mm2, %%mm1 \n\t" /* U0V0 U0V0 U1V1 U1V1*/
- "punpcklbw %%mm1, %%mm0 \n\t" /* Y0U0 Y1V0 Y2U0 Y3V0*/
- "punpckhbw %%mm1, %%mm3 \n\t" /* Y4U1 Y5V1 Y6U1 Y7V1*/
- MOVNTQ" %%mm0, (%4, %0, 8) \n\t"
- MOVNTQ" %%mm3, 8(%4, %0, 8) \n\t"
-
- "punpckhbw %%mm2, %%mm6 \n\t" /* U2V2 U2V2 U3V3 U3V3*/
- "movq 8(%1, %0, 4), %%mm0 \n\t"
- "movq %%mm0, %%mm3 \n\t"
- "punpcklbw %%mm6, %%mm0 \n\t" /* Y U2 Y V2 Y U2 Y V2*/
- "punpckhbw %%mm6, %%mm3 \n\t" /* Y U3 Y V3 Y U3 Y V3*/
- MOVNTQ" %%mm0, 16(%4, %0, 8) \n\t"
- MOVNTQ" %%mm3, 24(%4, %0, 8) \n\t"
-
- "movq %%mm4, %%mm6 \n\t"
- "movq 16(%1, %0, 4), %%mm0 \n\t"
- "movq %%mm0, %%mm3 \n\t"
- "punpcklbw %%mm5, %%mm4 \n\t"
- "punpcklbw %%mm4, %%mm0 \n\t" /* Y U4 Y V4 Y U4 Y V4*/
- "punpckhbw %%mm4, %%mm3 \n\t" /* Y U5 Y V5 Y U5 Y V5*/
- MOVNTQ" %%mm0, 32(%4, %0, 8) \n\t"
- MOVNTQ" %%mm3, 40(%4, %0, 8) \n\t"
-
- "punpckhbw %%mm5, %%mm6 \n\t"
- "movq 24(%1, %0, 4), %%mm0 \n\t"
- "movq %%mm0, %%mm3 \n\t"
- "punpcklbw %%mm6, %%mm0 \n\t" /* Y U6 Y V6 Y U6 Y V6*/
- "punpckhbw %%mm6, %%mm3 \n\t" /* Y U7 Y V7 Y U7 Y V7*/
- MOVNTQ" %%mm0, 48(%4, %0, 8) \n\t"
- MOVNTQ" %%mm3, 56(%4, %0, 8) \n\t"
-
- : "+r" (x)
- : "r"(yp), "r" (up), "r"(vp), "r"(d)
- :"memory");
- }
- for (; x<w; x++) {
- const int x2 = x<<2;
- d[8*x+0] = yp[x2];
- d[8*x+1] = up[x];
- d[8*x+2] = yp[x2+1];
- d[8*x+3] = vp[x];
- d[8*x+4] = yp[x2+2];
- d[8*x+5] = up[x];
- d[8*x+6] = yp[x2+3];
- d[8*x+7] = vp[x];
- }
- }
- __asm__(
- EMMS" \n\t"
- SFENCE" \n\t"
- ::: "memory"
- );
-}
-#endif /* !COMPILE_TEMPLATE_AMD3DNOW */
-
-static void RENAME(extract_even)(const uint8_t *src, uint8_t *dst, x86_reg count)
-{
- dst += count;
- src += 2*count;
- count= - count;
-
- if(count <= -16) {
- count += 15;
- __asm__ volatile(
- "pcmpeqw %%mm7, %%mm7 \n\t"
- "psrlw $8, %%mm7 \n\t"
- "1: \n\t"
- "movq -30(%1, %0, 2), %%mm0 \n\t"
- "movq -22(%1, %0, 2), %%mm1 \n\t"
- "movq -14(%1, %0, 2), %%mm2 \n\t"
- "movq -6(%1, %0, 2), %%mm3 \n\t"
- "pand %%mm7, %%mm0 \n\t"
- "pand %%mm7, %%mm1 \n\t"
- "pand %%mm7, %%mm2 \n\t"
- "pand %%mm7, %%mm3 \n\t"
- "packuswb %%mm1, %%mm0 \n\t"
- "packuswb %%mm3, %%mm2 \n\t"
- MOVNTQ" %%mm0,-15(%2, %0) \n\t"
- MOVNTQ" %%mm2,- 7(%2, %0) \n\t"
- "add $16, %0 \n\t"
- " js 1b \n\t"
- : "+r"(count)
- : "r"(src), "r"(dst)
- );
- count -= 15;
- }
- while(count<0) {
- dst[count]= src[2*count];
- count++;
- }
-}
-
-#if !COMPILE_TEMPLATE_AMD3DNOW
-static void RENAME(extract_even2)(const uint8_t *src, uint8_t *dst0, uint8_t *dst1, x86_reg count)
-{
- dst0+= count;
- dst1+= count;
- src += 4*count;
- count= - count;
- if(count <= -8) {
- count += 7;
- __asm__ volatile(
- "pcmpeqw %%mm7, %%mm7 \n\t"
- "psrlw $8, %%mm7 \n\t"
- "1: \n\t"
- "movq -28(%1, %0, 4), %%mm0 \n\t"
- "movq -20(%1, %0, 4), %%mm1 \n\t"
- "movq -12(%1, %0, 4), %%mm2 \n\t"
- "movq -4(%1, %0, 4), %%mm3 \n\t"
- "pand %%mm7, %%mm0 \n\t"
- "pand %%mm7, %%mm1 \n\t"
- "pand %%mm7, %%mm2 \n\t"
- "pand %%mm7, %%mm3 \n\t"
- "packuswb %%mm1, %%mm0 \n\t"
- "packuswb %%mm3, %%mm2 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "movq %%mm2, %%mm3 \n\t"
- "psrlw $8, %%mm0 \n\t"
- "psrlw $8, %%mm2 \n\t"
- "pand %%mm7, %%mm1 \n\t"
- "pand %%mm7, %%mm3 \n\t"
- "packuswb %%mm2, %%mm0 \n\t"
- "packuswb %%mm3, %%mm1 \n\t"
- MOVNTQ" %%mm0,- 7(%3, %0) \n\t"
- MOVNTQ" %%mm1,- 7(%2, %0) \n\t"
- "add $8, %0 \n\t"
- " js 1b \n\t"
- : "+r"(count)
- : "r"(src), "r"(dst0), "r"(dst1)
- );
- count -= 7;
- }
- while(count<0) {
- dst0[count]= src[4*count+0];
- dst1[count]= src[4*count+2];
- count++;
- }
-}
-#endif /* !COMPILE_TEMPLATE_AMD3DNOW */
-
-static void RENAME(extract_even2avg)(const uint8_t *src0, const uint8_t *src1, uint8_t *dst0, uint8_t *dst1, x86_reg count)
-{
- dst0 += count;
- dst1 += count;
- src0 += 4*count;
- src1 += 4*count;
- count= - count;
-#ifdef PAVGB
- if(count <= -8) {
- count += 7;
- __asm__ volatile(
- "pcmpeqw %%mm7, %%mm7 \n\t"
- "psrlw $8, %%mm7 \n\t"
- "1: \n\t"
- "movq -28(%1, %0, 4), %%mm0 \n\t"
- "movq -20(%1, %0, 4), %%mm1 \n\t"
- "movq -12(%1, %0, 4), %%mm2 \n\t"
- "movq -4(%1, %0, 4), %%mm3 \n\t"
- PAVGB" -28(%2, %0, 4), %%mm0 \n\t"
- PAVGB" -20(%2, %0, 4), %%mm1 \n\t"
- PAVGB" -12(%2, %0, 4), %%mm2 \n\t"
- PAVGB" - 4(%2, %0, 4), %%mm3 \n\t"
- "pand %%mm7, %%mm0 \n\t"
- "pand %%mm7, %%mm1 \n\t"
- "pand %%mm7, %%mm2 \n\t"
- "pand %%mm7, %%mm3 \n\t"
- "packuswb %%mm1, %%mm0 \n\t"
- "packuswb %%mm3, %%mm2 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "movq %%mm2, %%mm3 \n\t"
- "psrlw $8, %%mm0 \n\t"
- "psrlw $8, %%mm2 \n\t"
- "pand %%mm7, %%mm1 \n\t"
- "pand %%mm7, %%mm3 \n\t"
- "packuswb %%mm2, %%mm0 \n\t"
- "packuswb %%mm3, %%mm1 \n\t"
- MOVNTQ" %%mm0,- 7(%4, %0) \n\t"
- MOVNTQ" %%mm1,- 7(%3, %0) \n\t"
- "add $8, %0 \n\t"
- " js 1b \n\t"
- : "+r"(count)
- : "r"(src0), "r"(src1), "r"(dst0), "r"(dst1)
- );
- count -= 7;
- }
-#endif
- while(count<0) {
- dst0[count]= (src0[4*count+0]+src1[4*count+0])>>1;
- dst1[count]= (src0[4*count+2]+src1[4*count+2])>>1;
- count++;
- }
-}
-
-#if !COMPILE_TEMPLATE_AMD3DNOW
-static void RENAME(extract_odd2)(const uint8_t *src, uint8_t *dst0, uint8_t *dst1, x86_reg count)
-{
- dst0+= count;
- dst1+= count;
- src += 4*count;
- count= - count;
- if(count <= -8) {
- count += 7;
- __asm__ volatile(
- "pcmpeqw %%mm7, %%mm7 \n\t"
- "psrlw $8, %%mm7 \n\t"
- "1: \n\t"
- "movq -28(%1, %0, 4), %%mm0 \n\t"
- "movq -20(%1, %0, 4), %%mm1 \n\t"
- "movq -12(%1, %0, 4), %%mm2 \n\t"
- "movq -4(%1, %0, 4), %%mm3 \n\t"
- "psrlw $8, %%mm0 \n\t"
- "psrlw $8, %%mm1 \n\t"
- "psrlw $8, %%mm2 \n\t"
- "psrlw $8, %%mm3 \n\t"
- "packuswb %%mm1, %%mm0 \n\t"
- "packuswb %%mm3, %%mm2 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "movq %%mm2, %%mm3 \n\t"
- "psrlw $8, %%mm0 \n\t"
- "psrlw $8, %%mm2 \n\t"
- "pand %%mm7, %%mm1 \n\t"
- "pand %%mm7, %%mm3 \n\t"
- "packuswb %%mm2, %%mm0 \n\t"
- "packuswb %%mm3, %%mm1 \n\t"
- MOVNTQ" %%mm0,- 7(%3, %0) \n\t"
- MOVNTQ" %%mm1,- 7(%2, %0) \n\t"
- "add $8, %0 \n\t"
- " js 1b \n\t"
- : "+r"(count)
- : "r"(src), "r"(dst0), "r"(dst1)
- );
- count -= 7;
- }
- src++;
- while(count<0) {
- dst0[count]= src[4*count+0];
- dst1[count]= src[4*count+2];
- count++;
- }
-}
-#endif /* !COMPILE_TEMPLATE_AMD3DNOW */
-
-static void RENAME(extract_odd2avg)(const uint8_t *src0, const uint8_t *src1, uint8_t *dst0, uint8_t *dst1, x86_reg count)
-{
- dst0 += count;
- dst1 += count;
- src0 += 4*count;
- src1 += 4*count;
- count= - count;
-#ifdef PAVGB
- if(count <= -8) {
- count += 7;
- __asm__ volatile(
- "pcmpeqw %%mm7, %%mm7 \n\t"
- "psrlw $8, %%mm7 \n\t"
- "1: \n\t"
- "movq -28(%1, %0, 4), %%mm0 \n\t"
- "movq -20(%1, %0, 4), %%mm1 \n\t"
- "movq -12(%1, %0, 4), %%mm2 \n\t"
- "movq -4(%1, %0, 4), %%mm3 \n\t"
- PAVGB" -28(%2, %0, 4), %%mm0 \n\t"
- PAVGB" -20(%2, %0, 4), %%mm1 \n\t"
- PAVGB" -12(%2, %0, 4), %%mm2 \n\t"
- PAVGB" - 4(%2, %0, 4), %%mm3 \n\t"
- "psrlw $8, %%mm0 \n\t"
- "psrlw $8, %%mm1 \n\t"
- "psrlw $8, %%mm2 \n\t"
- "psrlw $8, %%mm3 \n\t"
- "packuswb %%mm1, %%mm0 \n\t"
- "packuswb %%mm3, %%mm2 \n\t"
- "movq %%mm0, %%mm1 \n\t"
- "movq %%mm2, %%mm3 \n\t"
- "psrlw $8, %%mm0 \n\t"
- "psrlw $8, %%mm2 \n\t"
- "pand %%mm7, %%mm1 \n\t"
- "pand %%mm7, %%mm3 \n\t"
- "packuswb %%mm2, %%mm0 \n\t"
- "packuswb %%mm3, %%mm1 \n\t"
- MOVNTQ" %%mm0,- 7(%4, %0) \n\t"
- MOVNTQ" %%mm1,- 7(%3, %0) \n\t"
- "add $8, %0 \n\t"
- " js 1b \n\t"
- : "+r"(count)
- : "r"(src0), "r"(src1), "r"(dst0), "r"(dst1)
- );
- count -= 7;
- }
-#endif
- src0++;
- src1++;
- while(count<0) {
- dst0[count]= (src0[4*count+0]+src1[4*count+0])>>1;
- dst1[count]= (src0[4*count+2]+src1[4*count+2])>>1;
- count++;
- }
-}
-
-static void RENAME(yuyvtoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
- int width, int height,
- int lumStride, int chromStride, int srcStride)
-{
- int y;
- const int chromWidth= -((-width)>>1);
-
- for (y=0; y<height; y++) {
- RENAME(extract_even)(src, ydst, width);
- if(y&1) {
- RENAME(extract_odd2avg)(src-srcStride, src, udst, vdst, chromWidth);
- udst+= chromStride;
- vdst+= chromStride;
- }
-
- src += srcStride;
- ydst+= lumStride;
- }
- __asm__(
- EMMS" \n\t"
- SFENCE" \n\t"
- ::: "memory"
- );
-}
-
-#if !COMPILE_TEMPLATE_AMD3DNOW
-static void RENAME(yuyvtoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
- int width, int height,
- int lumStride, int chromStride, int srcStride)
-{
- int y;
- const int chromWidth= -((-width)>>1);
-
- for (y=0; y<height; y++) {
- RENAME(extract_even)(src, ydst, width);
- RENAME(extract_odd2)(src, udst, vdst, chromWidth);
-
- src += srcStride;
- ydst+= lumStride;
- udst+= chromStride;
- vdst+= chromStride;
- }
- __asm__(
- EMMS" \n\t"
- SFENCE" \n\t"
- ::: "memory"
- );
-}
-#endif /* !COMPILE_TEMPLATE_AMD3DNOW */
-
-static void RENAME(uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
- int width, int height,
- int lumStride, int chromStride, int srcStride)
-{
- int y;
- const int chromWidth= -((-width)>>1);
-
- for (y=0; y<height; y++) {
- RENAME(extract_even)(src+1, ydst, width);
- if(y&1) {
- RENAME(extract_even2avg)(src-srcStride, src, udst, vdst, chromWidth);
- udst+= chromStride;
- vdst+= chromStride;
- }
-
- src += srcStride;
- ydst+= lumStride;
- }
- __asm__(
- EMMS" \n\t"
- SFENCE" \n\t"
- ::: "memory"
- );
-}
-
-#if !COMPILE_TEMPLATE_AMD3DNOW
-static void RENAME(uyvytoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
- int width, int height,
- int lumStride, int chromStride, int srcStride)
-{
- int y;
- const int chromWidth= -((-width)>>1);
-
- for (y=0; y<height; y++) {
- RENAME(extract_even)(src+1, ydst, width);
- RENAME(extract_even2)(src, udst, vdst, chromWidth);
-
- src += srcStride;
- ydst+= lumStride;
- udst+= chromStride;
- vdst+= chromStride;
- }
- __asm__(
- EMMS" \n\t"
- SFENCE" \n\t"
- ::: "memory"
- );
-}
-#endif /* !COMPILE_TEMPLATE_AMD3DNOW */
-#endif /* !COMPILE_TEMPLATE_SSE2 */
-
-static inline void RENAME(rgb2rgb_init)(void)
-{
-#if !COMPILE_TEMPLATE_SSE2
-#if !COMPILE_TEMPLATE_AMD3DNOW
- rgb15to16 = RENAME(rgb15to16);
- rgb15tobgr24 = RENAME(rgb15tobgr24);
- rgb15to32 = RENAME(rgb15to32);
- rgb16tobgr24 = RENAME(rgb16tobgr24);
- rgb16to32 = RENAME(rgb16to32);
- rgb16to15 = RENAME(rgb16to15);
- rgb24tobgr16 = RENAME(rgb24tobgr16);
- rgb24tobgr15 = RENAME(rgb24tobgr15);
- rgb24tobgr32 = RENAME(rgb24tobgr32);
- rgb32to16 = RENAME(rgb32to16);
- rgb32to15 = RENAME(rgb32to15);
- rgb32tobgr24 = RENAME(rgb32tobgr24);
- rgb24to15 = RENAME(rgb24to15);
- rgb24to16 = RENAME(rgb24to16);
- rgb24tobgr24 = RENAME(rgb24tobgr24);
- shuffle_bytes_2103 = RENAME(shuffle_bytes_2103);
- rgb32tobgr16 = RENAME(rgb32tobgr16);
- rgb32tobgr15 = RENAME(rgb32tobgr15);
- yv12toyuy2 = RENAME(yv12toyuy2);
- yv12touyvy = RENAME(yv12touyvy);
- yuv422ptoyuy2 = RENAME(yuv422ptoyuy2);
- yuv422ptouyvy = RENAME(yuv422ptouyvy);
- yuy2toyv12 = RENAME(yuy2toyv12);
- vu9_to_vu12 = RENAME(vu9_to_vu12);
- yvu9_to_yuy2 = RENAME(yvu9_to_yuy2);
- uyvytoyuv422 = RENAME(uyvytoyuv422);
- yuyvtoyuv422 = RENAME(yuyvtoyuv422);
-#endif /* !COMPILE_TEMPLATE_AMD3DNOW */
-
-#if COMPILE_TEMPLATE_MMXEXT || COMPILE_TEMPLATE_AMD3DNOW
- planar2x = RENAME(planar2x);
-#endif /* COMPILE_TEMPLATE_MMXEXT || COMPILE_TEMPLATE_AMD3DNOW */
- rgb24toyv12 = RENAME(rgb24toyv12);
-
- yuyvtoyuv420 = RENAME(yuyvtoyuv420);
- uyvytoyuv420 = RENAME(uyvytoyuv420);
-#endif /* !COMPILE_TEMPLATE_SSE2 */
-
-#if !COMPILE_TEMPLATE_AMD3DNOW
- interleaveBytes = RENAME(interleaveBytes);
-#endif /* !COMPILE_TEMPLATE_AMD3DNOW */
-}
diff --git a/src/thirdparty/ffmpeg/libswscale/x86/scale.asm b/src/thirdparty/ffmpeg/libswscale/x86/scale.asm
deleted file mode 100644
index 983342dbf..000000000
--- a/src/thirdparty/ffmpeg/libswscale/x86/scale.asm
+++ /dev/null
@@ -1,431 +0,0 @@
-;******************************************************************************
-;* x86-optimized horizontal line scaling functions
-;* Copyright (c) 2011 Ronald S. Bultje <rsbultje@gmail.com>
-;*
-;* This file is part of Libav.
-;*
-;* Libav is free software; you can redistribute it and/or
-;* modify it under the terms of the GNU Lesser General Public
-;* License as published by the Free Software Foundation; either
-;* version 2.1 of the License, or (at your option) any later version.
-;*
-;* Libav is distributed in the hope that it will be useful,
-;* but WITHOUT ANY WARRANTY; without even the implied warranty of
-;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-;* Lesser General Public License for more details.
-;*
-;* You should have received a copy of the GNU Lesser General Public
-;* License along with Libav; if not, write to the Free Software
-;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-;******************************************************************************
-
-%include "libavutil/x86/x86util.asm"
-
-SECTION_RODATA
-
-max_19bit_int: times 4 dd 0x7ffff
-max_19bit_flt: times 4 dd 524287.0
-minshort: times 8 dw 0x8000
-unicoeff: times 4 dd 0x20000000
-
-SECTION .text
-
-;-----------------------------------------------------------------------------
-; horizontal line scaling
-;
-; void hscale<source_width>to<intermediate_nbits>_<filterSize>_<opt>
-; (SwsContext *c, int{16,32}_t *dst,
-; int dstW, const uint{8,16}_t *src,
-; const int16_t *filter,
-; const int32_t *filterPos, int filterSize);
-;
-; Scale one horizontal line. Input is either 8-bits width or 16-bits width
-; ($source_width can be either 8, 9, 10 or 16, difference is whether we have to
-; downscale before multiplying). Filter is 14-bits. Output is either 15bits
-; (in int16_t) or 19bits (in int32_t), as given in $intermediate_nbits. Each
-; output pixel is generated from $filterSize input pixels, the position of
-; the first pixel is given in filterPos[nOutputPixel].
-;-----------------------------------------------------------------------------
-
-; SCALE_FUNC source_width, intermediate_nbits, filtersize, filtersuffix, n_args, n_xmm
-%macro SCALE_FUNC 6
-%ifnidn %3, X
-cglobal hscale%1to%2_%4, %5, 7, %6, pos0, dst, w, src, filter, fltpos, pos1
-%else
-cglobal hscale%1to%2_%4, %5, 10, %6, pos0, dst, w, srcmem, filter, fltpos, fltsize
-%endif
-%if ARCH_X86_64
- movsxd wq, wd
-%define mov32 movsxd
-%else ; x86-32
-%define mov32 mov
-%endif ; x86-64
-%if %2 == 19
-%if mmsize == 8 ; mmx
- mova m2, [max_19bit_int]
-%elif cpuflag(sse4)
- mova m2, [max_19bit_int]
-%else ; ssse3/sse2
- mova m2, [max_19bit_flt]
-%endif ; mmx/sse2/ssse3/sse4
-%endif ; %2 == 19
-%if %1 == 16
- mova m6, [minshort]
- mova m7, [unicoeff]
-%elif %1 == 8
- pxor m3, m3
-%endif ; %1 == 8/16
-
-%if %1 == 8
-%define movlh movd
-%define movbh movh
-%define srcmul 1
-%else ; %1 == 9-16
-%define movlh movq
-%define movbh movu
-%define srcmul 2
-%endif ; %1 == 8/9-16
-
-%ifnidn %3, X
-
- ; setup loop
-%if %3 == 8
- shl wq, 1 ; this allows *16 (i.e. now *8) in lea instructions for the 8-tap filter
-%define wshr 1
-%else ; %3 == 4
-%define wshr 0
-%endif ; %3 == 8
- lea filterq, [filterq+wq*8]
-%if %2 == 15
- lea dstq, [dstq+wq*(2>>wshr)]
-%else ; %2 == 19
- lea dstq, [dstq+wq*(4>>wshr)]
-%endif ; %2 == 15/19
- lea fltposq, [fltposq+wq*(4>>wshr)]
- neg wq
-
-.loop:
-%if %3 == 4 ; filterSize == 4 scaling
- ; load 2x4 or 4x4 source pixels into m0/m1
- mov32 pos0q, dword [fltposq+wq*4+ 0] ; filterPos[0]
- mov32 pos1q, dword [fltposq+wq*4+ 4] ; filterPos[1]
- movlh m0, [srcq+pos0q*srcmul] ; src[filterPos[0] + {0,1,2,3}]
-%if mmsize == 8
- movlh m1, [srcq+pos1q*srcmul] ; src[filterPos[1] + {0,1,2,3}]
-%else ; mmsize == 16
-%if %1 > 8
- movhps m0, [srcq+pos1q*srcmul] ; src[filterPos[1] + {0,1,2,3}]
-%else ; %1 == 8
- movd m4, [srcq+pos1q*srcmul] ; src[filterPos[1] + {0,1,2,3}]
-%endif
- mov32 pos0q, dword [fltposq+wq*4+ 8] ; filterPos[2]
- mov32 pos1q, dword [fltposq+wq*4+12] ; filterPos[3]
- movlh m1, [srcq+pos0q*srcmul] ; src[filterPos[2] + {0,1,2,3}]
-%if %1 > 8
- movhps m1, [srcq+pos1q*srcmul] ; src[filterPos[3] + {0,1,2,3}]
-%else ; %1 == 8
- movd m5, [srcq+pos1q*srcmul] ; src[filterPos[3] + {0,1,2,3}]
- punpckldq m0, m4
- punpckldq m1, m5
-%endif ; %1 == 8
-%endif ; mmsize == 8/16
-%if %1 == 8
- punpcklbw m0, m3 ; byte -> word
- punpcklbw m1, m3 ; byte -> word
-%endif ; %1 == 8
-
- ; multiply with filter coefficients
-%if %1 == 16 ; pmaddwd needs signed adds, so this moves unsigned -> signed, we'll
- ; add back 0x8000 * sum(coeffs) after the horizontal add
- psubw m0, m6
- psubw m1, m6
-%endif ; %1 == 16
- pmaddwd m0, [filterq+wq*8+mmsize*0] ; *= filter[{0,1,..,6,7}]
- pmaddwd m1, [filterq+wq*8+mmsize*1] ; *= filter[{8,9,..,14,15}]
-
- ; add up horizontally (4 srcpix * 4 coefficients -> 1 dstpix)
-%if mmsize == 8 ; mmx
- movq m4, m0
- punpckldq m0, m1
- punpckhdq m4, m1
- paddd m0, m4
-%elif notcpuflag(ssse3) ; sse2
- mova m4, m0
- shufps m0, m1, 10001000b
- shufps m4, m1, 11011101b
- paddd m0, m4
-%else ; ssse3/sse4
- phaddd m0, m1 ; filter[{ 0, 1, 2, 3}]*src[filterPos[0]+{0,1,2,3}],
- ; filter[{ 4, 5, 6, 7}]*src[filterPos[1]+{0,1,2,3}],
- ; filter[{ 8, 9,10,11}]*src[filterPos[2]+{0,1,2,3}],
- ; filter[{12,13,14,15}]*src[filterPos[3]+{0,1,2,3}]
-%endif ; mmx/sse2/ssse3/sse4
-%else ; %3 == 8, i.e. filterSize == 8 scaling
- ; load 2x8 or 4x8 source pixels into m0, m1, m4 and m5
- mov32 pos0q, dword [fltposq+wq*2+0] ; filterPos[0]
- mov32 pos1q, dword [fltposq+wq*2+4] ; filterPos[1]
- movbh m0, [srcq+ pos0q *srcmul] ; src[filterPos[0] + {0,1,2,3,4,5,6,7}]
-%if mmsize == 8
- movbh m1, [srcq+(pos0q+4)*srcmul] ; src[filterPos[0] + {4,5,6,7}]
- movbh m4, [srcq+ pos1q *srcmul] ; src[filterPos[1] + {0,1,2,3}]
- movbh m5, [srcq+(pos1q+4)*srcmul] ; src[filterPos[1] + {4,5,6,7}]
-%else ; mmsize == 16
- movbh m1, [srcq+ pos1q *srcmul] ; src[filterPos[1] + {0,1,2,3,4,5,6,7}]
- mov32 pos0q, dword [fltposq+wq*2+8] ; filterPos[2]
- mov32 pos1q, dword [fltposq+wq*2+12] ; filterPos[3]
- movbh m4, [srcq+ pos0q *srcmul] ; src[filterPos[2] + {0,1,2,3,4,5,6,7}]
- movbh m5, [srcq+ pos1q *srcmul] ; src[filterPos[3] + {0,1,2,3,4,5,6,7}]
-%endif ; mmsize == 8/16
-%if %1 == 8
- punpcklbw m0, m3 ; byte -> word
- punpcklbw m1, m3 ; byte -> word
- punpcklbw m4, m3 ; byte -> word
- punpcklbw m5, m3 ; byte -> word
-%endif ; %1 == 8
-
- ; multiply
-%if %1 == 16 ; pmaddwd needs signed adds, so this moves unsigned -> signed, we'll
- ; add back 0x8000 * sum(coeffs) after the horizontal add
- psubw m0, m6
- psubw m1, m6
- psubw m4, m6
- psubw m5, m6
-%endif ; %1 == 16
- pmaddwd m0, [filterq+wq*8+mmsize*0] ; *= filter[{0,1,..,6,7}]
- pmaddwd m1, [filterq+wq*8+mmsize*1] ; *= filter[{8,9,..,14,15}]
- pmaddwd m4, [filterq+wq*8+mmsize*2] ; *= filter[{16,17,..,22,23}]
- pmaddwd m5, [filterq+wq*8+mmsize*3] ; *= filter[{24,25,..,30,31}]
-
- ; add up horizontally (8 srcpix * 8 coefficients -> 1 dstpix)
-%if mmsize == 8
- paddd m0, m1
- paddd m4, m5
- movq m1, m0
- punpckldq m0, m4
- punpckhdq m1, m4
- paddd m0, m1
-%elif notcpuflag(ssse3) ; sse2
-%if %1 == 8
-%define mex m6
-%else
-%define mex m3
-%endif
- ; emulate horizontal add as transpose + vertical add
- mova mex, m0
- punpckldq m0, m1
- punpckhdq mex, m1
- paddd m0, mex
- mova m1, m4
- punpckldq m4, m5
- punpckhdq m1, m5
- paddd m4, m1
- mova m1, m0
- punpcklqdq m0, m4
- punpckhqdq m1, m4
- paddd m0, m1
-%else ; ssse3/sse4
- ; FIXME if we rearrange the filter in pairs of 4, we can
- ; load pixels likewise and use 2 x paddd + phaddd instead
- ; of 3 x phaddd here, faster on older cpus
- phaddd m0, m1
- phaddd m4, m5
- phaddd m0, m4 ; filter[{ 0, 1,..., 6, 7}]*src[filterPos[0]+{0,1,...,6,7}],
- ; filter[{ 8, 9,...,14,15}]*src[filterPos[1]+{0,1,...,6,7}],
- ; filter[{16,17,...,22,23}]*src[filterPos[2]+{0,1,...,6,7}],
- ; filter[{24,25,...,30,31}]*src[filterPos[3]+{0,1,...,6,7}]
-%endif ; mmx/sse2/ssse3/sse4
-%endif ; %3 == 4/8
-
-%else ; %3 == X, i.e. any filterSize scaling
-
-%ifidn %4, X4
-%define dlt 4
-%else ; %4 == X || %4 == X8
-%define dlt 0
-%endif ; %4 ==/!= X4
-%if ARCH_X86_64
-%define srcq r8
-%define pos1q r7
-%define srcendq r9
- movsxd fltsizeq, fltsized ; filterSize
- lea srcendq, [srcmemq+(fltsizeq-dlt)*srcmul] ; &src[filterSize&~4]
-%else ; x86-32
-%define srcq srcmemq
-%define pos1q dstq
-%define srcendq r6m
- lea pos0q, [srcmemq+(fltsizeq-dlt)*srcmul] ; &src[filterSize&~4]
- mov srcendq, pos0q
-%endif ; x86-32/64
- lea fltposq, [fltposq+wq*4]
-%if %2 == 15
- lea dstq, [dstq+wq*2]
-%else ; %2 == 19
- lea dstq, [dstq+wq*4]
-%endif ; %2 == 15/19
- movifnidn dstmp, dstq
- neg wq
-
-.loop:
- mov32 pos0q, dword [fltposq+wq*4+0] ; filterPos[0]
- mov32 pos1q, dword [fltposq+wq*4+4] ; filterPos[1]
- ; FIXME maybe do 4px/iteration on x86-64 (x86-32 wouldn't have enough regs)?
- pxor m4, m4
- pxor m5, m5
- mov srcq, srcmemmp
-
-.innerloop:
- ; load 2x4 (mmx) or 2x8 (sse) source pixels into m0/m1 -> m4/m5
- movbh m0, [srcq+ pos0q *srcmul] ; src[filterPos[0] + {0,1,2,3(,4,5,6,7)}]
- movbh m1, [srcq+(pos1q+dlt)*srcmul] ; src[filterPos[1] + {0,1,2,3(,4,5,6,7)}]
-%if %1 == 8
- punpcklbw m0, m3
- punpcklbw m1, m3
-%endif ; %1 == 8
-
- ; multiply
-%if %1 == 16 ; pmaddwd needs signed adds, so this moves unsigned -> signed, we'll
- ; add back 0x8000 * sum(coeffs) after the horizontal add
- psubw m0, m6
- psubw m1, m6
-%endif ; %1 == 16
- pmaddwd m0, [filterq] ; filter[{0,1,2,3(,4,5,6,7)}]
- pmaddwd m1, [filterq+(fltsizeq+dlt)*2]; filter[filtersize+{0,1,2,3(,4,5,6,7)}]
- paddd m4, m0
- paddd m5, m1
- add filterq, mmsize
- add srcq, srcmul*mmsize/2
- cmp srcq, srcendq ; while (src += 4) < &src[filterSize]
- jl .innerloop
-
-%ifidn %4, X4
- mov32 pos1q, dword [fltposq+wq*4+4] ; filterPos[1]
- movlh m0, [srcq+ pos0q *srcmul] ; split last 4 srcpx of dstpx[0]
- sub pos1q, fltsizeq ; and first 4 srcpx of dstpx[1]
-%if %1 > 8
- movhps m0, [srcq+(pos1q+dlt)*srcmul]
-%else ; %1 == 8
- movd m1, [srcq+(pos1q+dlt)*srcmul]
- punpckldq m0, m1
-%endif ; %1 == 8
-%if %1 == 8
- punpcklbw m0, m3
-%endif ; %1 == 8
-%if %1 == 16 ; pmaddwd needs signed adds, so this moves unsigned -> signed, we'll
- ; add back 0x8000 * sum(coeffs) after the horizontal add
- psubw m0, m6
-%endif ; %1 == 16
- pmaddwd m0, [filterq]
-%endif ; %4 == X4
-
- lea filterq, [filterq+(fltsizeq+dlt)*2]
-
-%if mmsize == 8 ; mmx
- movq m0, m4
- punpckldq m4, m5
- punpckhdq m0, m5
- paddd m0, m4
-%else ; mmsize == 16
-%if notcpuflag(ssse3) ; sse2
- mova m1, m4
- punpcklqdq m4, m5
- punpckhqdq m1, m5
- paddd m4, m1
-%else ; ssse3/sse4
- phaddd m4, m5
-%endif ; sse2/ssse3/sse4
-%ifidn %4, X4
- paddd m4, m0
-%endif ; %3 == X4
-%if notcpuflag(ssse3) ; sse2
- pshufd m4, m4, 11011000b
- movhlps m0, m4
- paddd m0, m4
-%else ; ssse3/sse4
- phaddd m4, m4
- SWAP 0, 4
-%endif ; sse2/ssse3/sse4
-%endif ; mmsize == 8/16
-%endif ; %3 ==/!= X
-
-%if %1 == 16 ; add 0x8000 * sum(coeffs), i.e. back from signed -> unsigned
- paddd m0, m7
-%endif ; %1 == 16
-
- ; clip, store
- psrad m0, 14 + %1 - %2
-%ifidn %3, X
- movifnidn dstq, dstmp
-%endif ; %3 == X
-%if %2 == 15
- packssdw m0, m0
-%ifnidn %3, X
- movh [dstq+wq*(2>>wshr)], m0
-%else ; %3 == X
- movd [dstq+wq*2], m0
-%endif ; %3 ==/!= X
-%else ; %2 == 19
-%if mmsize == 8
- PMINSD_MMX m0, m2, m4
-%elif cpuflag(sse4)
- pminsd m0, m2
-%else ; sse2/ssse3
- cvtdq2ps m0, m0
- minps m0, m2
- cvtps2dq m0, m0
-%endif ; mmx/sse2/ssse3/sse4
-%ifnidn %3, X
- mova [dstq+wq*(4>>wshr)], m0
-%else ; %3 == X
- movq [dstq+wq*4], m0
-%endif ; %3 ==/!= X
-%endif ; %2 == 15/19
-%ifnidn %3, X
- add wq, (mmsize<<wshr)/4 ; both 8tap and 4tap really only do 4 pixels (or for mmx: 2 pixels)
- ; per iteration. see "shl wq,1" above as for why we do this
-%else ; %3 == X
- add wq, 2
-%endif ; %3 ==/!= X
- jl .loop
- REP_RET
-%endmacro
-
-; SCALE_FUNCS source_width, intermediate_nbits, n_xmm
-%macro SCALE_FUNCS 3
-SCALE_FUNC %1, %2, 4, 4, 6, %3
-SCALE_FUNC %1, %2, 8, 8, 6, %3
-%if mmsize == 8
-SCALE_FUNC %1, %2, X, X, 7, %3
-%else
-SCALE_FUNC %1, %2, X, X4, 7, %3
-SCALE_FUNC %1, %2, X, X8, 7, %3
-%endif
-%endmacro
-
-; SCALE_FUNCS2 8_xmm_args, 9to10_xmm_args, 16_xmm_args
-%macro SCALE_FUNCS2 3
-%if notcpuflag(sse4)
-SCALE_FUNCS 8, 15, %1
-SCALE_FUNCS 9, 15, %2
-SCALE_FUNCS 10, 15, %2
-SCALE_FUNCS 12, 15, %2
-SCALE_FUNCS 14, 15, %2
-SCALE_FUNCS 16, 15, %3
-%endif ; !sse4
-SCALE_FUNCS 8, 19, %1
-SCALE_FUNCS 9, 19, %2
-SCALE_FUNCS 10, 19, %2
-SCALE_FUNCS 12, 19, %2
-SCALE_FUNCS 14, 19, %2
-SCALE_FUNCS 16, 19, %3
-%endmacro
-
-%if ARCH_X86_32
-INIT_MMX mmx
-SCALE_FUNCS2 0, 0, 0
-%endif
-INIT_XMM sse2
-SCALE_FUNCS2 6, 7, 8
-INIT_XMM ssse3
-SCALE_FUNCS2 6, 6, 8
-INIT_XMM sse4
-SCALE_FUNCS2 6, 6, 8
diff --git a/src/thirdparty/ffmpeg/libswscale/x86/swscale.c b/src/thirdparty/ffmpeg/libswscale/x86/swscale.c
deleted file mode 100644
index 2f67b1b03..000000000
--- a/src/thirdparty/ffmpeg/libswscale/x86/swscale.c
+++ /dev/null
@@ -1,585 +0,0 @@
-/*
- * Copyright (C) 2001-2011 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
- */
-
-#include <inttypes.h>
-#include "config.h"
-#include "libswscale/swscale.h"
-#include "libswscale/swscale_internal.h"
-#include "libavutil/attributes.h"
-#include "libavutil/avassert.h"
-#include "libavutil/intreadwrite.h"
-#include "libavutil/x86/asm.h"
-#include "libavutil/x86/cpu.h"
-#include "libavutil/cpu.h"
-#include "libavutil/pixdesc.h"
-
-#if HAVE_INLINE_ASM
-
-#define DITHER1XBPP
-
-DECLARE_ASM_CONST(8, uint64_t, bF8)= 0xF8F8F8F8F8F8F8F8LL;
-DECLARE_ASM_CONST(8, uint64_t, bFC)= 0xFCFCFCFCFCFCFCFCLL;
-DECLARE_ASM_CONST(8, uint64_t, w10)= 0x0010001000100010LL;
-DECLARE_ASM_CONST(8, uint64_t, w02)= 0x0002000200020002LL;
-
-const DECLARE_ALIGNED(8, uint64_t, ff_dither4)[2] = {
- 0x0103010301030103LL,
- 0x0200020002000200LL,};
-
-const DECLARE_ALIGNED(8, uint64_t, ff_dither8)[2] = {
- 0x0602060206020602LL,
- 0x0004000400040004LL,};
-
-DECLARE_ASM_CONST(8, uint64_t, b16Mask)= 0x001F001F001F001FLL;
-DECLARE_ASM_CONST(8, uint64_t, g16Mask)= 0x07E007E007E007E0LL;
-DECLARE_ASM_CONST(8, uint64_t, r16Mask)= 0xF800F800F800F800LL;
-DECLARE_ASM_CONST(8, uint64_t, b15Mask)= 0x001F001F001F001FLL;
-DECLARE_ASM_CONST(8, uint64_t, g15Mask)= 0x03E003E003E003E0LL;
-DECLARE_ASM_CONST(8, uint64_t, r15Mask)= 0x7C007C007C007C00LL;
-
-DECLARE_ALIGNED(8, const uint64_t, ff_M24A) = 0x00FF0000FF0000FFLL;
-DECLARE_ALIGNED(8, const uint64_t, ff_M24B) = 0xFF0000FF0000FF00LL;
-DECLARE_ALIGNED(8, const uint64_t, ff_M24C) = 0x0000FF0000FF0000LL;
-
-#ifdef FAST_BGR2YV12
-DECLARE_ALIGNED(8, const uint64_t, ff_bgr2YCoeff) = 0x000000210041000DULL;
-DECLARE_ALIGNED(8, const uint64_t, ff_bgr2UCoeff) = 0x0000FFEEFFDC0038ULL;
-DECLARE_ALIGNED(8, const uint64_t, ff_bgr2VCoeff) = 0x00000038FFD2FFF8ULL;
-#else
-DECLARE_ALIGNED(8, const uint64_t, ff_bgr2YCoeff) = 0x000020E540830C8BULL;
-DECLARE_ALIGNED(8, const uint64_t, ff_bgr2UCoeff) = 0x0000ED0FDAC23831ULL;
-DECLARE_ALIGNED(8, const uint64_t, ff_bgr2VCoeff) = 0x00003831D0E6F6EAULL;
-#endif /* FAST_BGR2YV12 */
-DECLARE_ALIGNED(8, const uint64_t, ff_bgr2YOffset) = 0x1010101010101010ULL;
-DECLARE_ALIGNED(8, const uint64_t, ff_bgr2UVOffset) = 0x8080808080808080ULL;
-DECLARE_ALIGNED(8, const uint64_t, ff_w1111) = 0x0001000100010001ULL;
-
-
-//MMX versions
-#if HAVE_MMX_INLINE
-#undef RENAME
-#define COMPILE_TEMPLATE_MMXEXT 0
-#define RENAME(a) a ## _MMX
-#include "swscale_template.c"
-#endif
-
-// MMXEXT versions
-#if HAVE_MMXEXT_INLINE
-#undef RENAME
-#undef COMPILE_TEMPLATE_MMXEXT
-#define COMPILE_TEMPLATE_MMXEXT 1
-#define RENAME(a) a ## _MMXEXT
-#include "swscale_template.c"
-#endif
-
-void updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrBufIndex,
- int lastInLumBuf, int lastInChrBuf)
-{
- const int dstH= c->dstH;
- const int flags= c->flags;
- int16_t **lumPixBuf= c->lumPixBuf;
- int16_t **chrUPixBuf= c->chrUPixBuf;
- int16_t **alpPixBuf= c->alpPixBuf;
- const int vLumBufSize= c->vLumBufSize;
- const int vChrBufSize= c->vChrBufSize;
- int32_t *vLumFilterPos= c->vLumFilterPos;
- int32_t *vChrFilterPos= c->vChrFilterPos;
- int16_t *vLumFilter= c->vLumFilter;
- int16_t *vChrFilter= c->vChrFilter;
- int32_t *lumMmxFilter= c->lumMmxFilter;
- int32_t *chrMmxFilter= c->chrMmxFilter;
- int32_t av_unused *alpMmxFilter= c->alpMmxFilter;
- const int vLumFilterSize= c->vLumFilterSize;
- const int vChrFilterSize= c->vChrFilterSize;
- const int chrDstY= dstY>>c->chrDstVSubSample;
- const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input
- const int firstChrSrcY= vChrFilterPos[chrDstY]; //First line needed as input
-
- c->blueDither= ff_dither8[dstY&1];
- if (c->dstFormat == AV_PIX_FMT_RGB555 || c->dstFormat == AV_PIX_FMT_BGR555)
- c->greenDither= ff_dither8[dstY&1];
- else
- c->greenDither= ff_dither4[dstY&1];
- c->redDither= ff_dither8[(dstY+1)&1];
- if (dstY < dstH - 2) {
- const int16_t **lumSrcPtr= (const int16_t **)(void*) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
- const int16_t **chrUSrcPtr= (const int16_t **)(void*) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
- const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **)(void*) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
- int i;
-
- if (firstLumSrcY < 0 || firstLumSrcY + vLumFilterSize > c->srcH) {
- const int16_t **tmpY = (const int16_t **) lumPixBuf + 2 * vLumBufSize;
- int neg = -firstLumSrcY, i, end = FFMIN(c->srcH - firstLumSrcY, vLumFilterSize);
- for (i = 0; i < neg; i++)
- tmpY[i] = lumSrcPtr[neg];
- for ( ; i < end; i++)
- tmpY[i] = lumSrcPtr[i];
- for ( ; i < vLumFilterSize; i++)
- tmpY[i] = tmpY[i-1];
- lumSrcPtr = tmpY;
-
- if (alpSrcPtr) {
- const int16_t **tmpA = (const int16_t **) alpPixBuf + 2 * vLumBufSize;
- for (i = 0; i < neg; i++)
- tmpA[i] = alpSrcPtr[neg];
- for ( ; i < end; i++)
- tmpA[i] = alpSrcPtr[i];
- for ( ; i < vLumFilterSize; i++)
- tmpA[i] = tmpA[i - 1];
- alpSrcPtr = tmpA;
- }
- }
- if (firstChrSrcY < 0 || firstChrSrcY + vChrFilterSize > c->chrSrcH) {
- const int16_t **tmpU = (const int16_t **) chrUPixBuf + 2 * vChrBufSize;
- int neg = -firstChrSrcY, i, end = FFMIN(c->chrSrcH - firstChrSrcY, vChrFilterSize);
- for (i = 0; i < neg; i++) {
- tmpU[i] = chrUSrcPtr[neg];
- }
- for ( ; i < end; i++) {
- tmpU[i] = chrUSrcPtr[i];
- }
- for ( ; i < vChrFilterSize; i++) {
- tmpU[i] = tmpU[i - 1];
- }
- chrUSrcPtr = tmpU;
- }
-
- if (flags & SWS_ACCURATE_RND) {
- int s= APCK_SIZE / 8;
- for (i=0; i<vLumFilterSize; i+=2) {
- *(const void**)&lumMmxFilter[s*i ]= lumSrcPtr[i ];
- *(const void**)&lumMmxFilter[s*i+APCK_PTR2/4 ]= lumSrcPtr[i+(vLumFilterSize>1)];
- lumMmxFilter[s*i+APCK_COEF/4 ]=
- lumMmxFilter[s*i+APCK_COEF/4+1]= vLumFilter[dstY*vLumFilterSize + i ]
- + (vLumFilterSize>1 ? vLumFilter[dstY*vLumFilterSize + i + 1]<<16 : 0);
- if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
- *(const void**)&alpMmxFilter[s*i ]= alpSrcPtr[i ];
- *(const void**)&alpMmxFilter[s*i+APCK_PTR2/4 ]= alpSrcPtr[i+(vLumFilterSize>1)];
- alpMmxFilter[s*i+APCK_COEF/4 ]=
- alpMmxFilter[s*i+APCK_COEF/4+1]= lumMmxFilter[s*i+APCK_COEF/4 ];
- }
- }
- for (i=0; i<vChrFilterSize; i+=2) {
- *(const void**)&chrMmxFilter[s*i ]= chrUSrcPtr[i ];
- *(const void**)&chrMmxFilter[s*i+APCK_PTR2/4 ]= chrUSrcPtr[i+(vChrFilterSize>1)];
- chrMmxFilter[s*i+APCK_COEF/4 ]=
- chrMmxFilter[s*i+APCK_COEF/4+1]= vChrFilter[chrDstY*vChrFilterSize + i ]
- + (vChrFilterSize>1 ? vChrFilter[chrDstY*vChrFilterSize + i + 1]<<16 : 0);
- }
- } else {
- for (i=0; i<vLumFilterSize; i++) {
- *(const void**)&lumMmxFilter[4*i+0]= lumSrcPtr[i];
- lumMmxFilter[4*i+2]=
- lumMmxFilter[4*i+3]=
- ((uint16_t)vLumFilter[dstY*vLumFilterSize + i])*0x10001U;
- if (CONFIG_SWSCALE_ALPHA && alpPixBuf) {
- *(const void**)&alpMmxFilter[4*i+0]= alpSrcPtr[i];
- alpMmxFilter[4*i+2]=
- alpMmxFilter[4*i+3]= lumMmxFilter[4*i+2];
- }
- }
- for (i=0; i<vChrFilterSize; i++) {
- *(const void**)&chrMmxFilter[4*i+0]= chrUSrcPtr[i];
- chrMmxFilter[4*i+2]=
- chrMmxFilter[4*i+3]=
- ((uint16_t)vChrFilter[chrDstY*vChrFilterSize + i])*0x10001U;
- }
- }
- }
-}
-
-#if HAVE_MMXEXT
-static void yuv2yuvX_sse3(const int16_t *filter, int filterSize,
- const int16_t **src, uint8_t *dest, int dstW,
- const uint8_t *dither, int offset)
-{
- if(((int)dest) & 15){
- return yuv2yuvX_MMXEXT(filter, filterSize, src, dest, dstW, dither, offset);
- }
- if (offset) {
- __asm__ volatile("movq (%0), %%xmm3\n\t"
- "movdqa %%xmm3, %%xmm4\n\t"
- "psrlq $24, %%xmm3\n\t"
- "psllq $40, %%xmm4\n\t"
- "por %%xmm4, %%xmm3\n\t"
- :: "r"(dither)
- );
- } else {
- __asm__ volatile("movq (%0), %%xmm3\n\t"
- :: "r"(dither)
- );
- }
- filterSize--;
- __asm__ volatile(
- "pxor %%xmm0, %%xmm0\n\t"
- "punpcklbw %%xmm0, %%xmm3\n\t"
- "movd %0, %%xmm1\n\t"
- "punpcklwd %%xmm1, %%xmm1\n\t"
- "punpckldq %%xmm1, %%xmm1\n\t"
- "punpcklqdq %%xmm1, %%xmm1\n\t"
- "psllw $3, %%xmm1\n\t"
- "paddw %%xmm1, %%xmm3\n\t"
- "psraw $4, %%xmm3\n\t"
- ::"m"(filterSize)
- );
- __asm__ volatile(
- "movdqa %%xmm3, %%xmm4\n\t"
- "movdqa %%xmm3, %%xmm7\n\t"
- "movl %3, %%ecx\n\t"
- "mov %0, %%"REG_d" \n\t"\
- "mov (%%"REG_d"), %%"REG_S" \n\t"\
- ".p2align 4 \n\t" /* FIXME Unroll? */\
- "1: \n\t"\
- "movddup 8(%%"REG_d"), %%xmm0 \n\t" /* filterCoeff */\
- "movdqa (%%"REG_S", %%"REG_c", 2), %%xmm2 \n\t" /* srcData */\
- "movdqa 16(%%"REG_S", %%"REG_c", 2), %%xmm5 \n\t" /* srcData */\
- "add $16, %%"REG_d" \n\t"\
- "mov (%%"REG_d"), %%"REG_S" \n\t"\
- "test %%"REG_S", %%"REG_S" \n\t"\
- "pmulhw %%xmm0, %%xmm2 \n\t"\
- "pmulhw %%xmm0, %%xmm5 \n\t"\
- "paddw %%xmm2, %%xmm3 \n\t"\
- "paddw %%xmm5, %%xmm4 \n\t"\
- " jnz 1b \n\t"\
- "psraw $3, %%xmm3 \n\t"\
- "psraw $3, %%xmm4 \n\t"\
- "packuswb %%xmm4, %%xmm3 \n\t"
- "movntdq %%xmm3, (%1, %%"REG_c")\n\t"
- "add $16, %%"REG_c" \n\t"\
- "cmp %2, %%"REG_c" \n\t"\
- "movdqa %%xmm7, %%xmm3\n\t"
- "movdqa %%xmm7, %%xmm4\n\t"
- "mov %0, %%"REG_d" \n\t"\
- "mov (%%"REG_d"), %%"REG_S" \n\t"\
- "jb 1b \n\t"\
- :: "g" (filter),
- "r" (dest-offset), "g" ((x86_reg)(dstW+offset)), "m" (offset)
- : "%"REG_d, "%"REG_S, "%"REG_c
- );
-}
-#endif
-
-#endif /* HAVE_INLINE_ASM */
-
-#define SCALE_FUNC(filter_n, from_bpc, to_bpc, opt) \
-extern void ff_hscale ## from_bpc ## to ## to_bpc ## _ ## filter_n ## _ ## opt( \
- SwsContext *c, int16_t *data, \
- int dstW, const uint8_t *src, \
- const int16_t *filter, \
- const int32_t *filterPos, int filterSize)
-
-#define SCALE_FUNCS(filter_n, opt) \
- SCALE_FUNC(filter_n, 8, 15, opt); \
- SCALE_FUNC(filter_n, 9, 15, opt); \
- SCALE_FUNC(filter_n, 10, 15, opt); \
- SCALE_FUNC(filter_n, 12, 15, opt); \
- SCALE_FUNC(filter_n, 14, 15, opt); \
- SCALE_FUNC(filter_n, 16, 15, opt); \
- SCALE_FUNC(filter_n, 8, 19, opt); \
- SCALE_FUNC(filter_n, 9, 19, opt); \
- SCALE_FUNC(filter_n, 10, 19, opt); \
- SCALE_FUNC(filter_n, 12, 19, opt); \
- SCALE_FUNC(filter_n, 14, 19, opt); \
- SCALE_FUNC(filter_n, 16, 19, opt)
-
-#define SCALE_FUNCS_MMX(opt) \
- SCALE_FUNCS(4, opt); \
- SCALE_FUNCS(8, opt); \
- SCALE_FUNCS(X, opt)
-
-#define SCALE_FUNCS_SSE(opt) \
- SCALE_FUNCS(4, opt); \
- SCALE_FUNCS(8, opt); \
- SCALE_FUNCS(X4, opt); \
- SCALE_FUNCS(X8, opt)
-
-#if ARCH_X86_32
-SCALE_FUNCS_MMX(mmx);
-#endif
-SCALE_FUNCS_SSE(sse2);
-SCALE_FUNCS_SSE(ssse3);
-SCALE_FUNCS_SSE(sse4);
-
-#define VSCALEX_FUNC(size, opt) \
-extern void ff_yuv2planeX_ ## size ## _ ## opt(const int16_t *filter, int filterSize, \
- const int16_t **src, uint8_t *dest, int dstW, \
- const uint8_t *dither, int offset)
-#define VSCALEX_FUNCS(opt) \
- VSCALEX_FUNC(8, opt); \
- VSCALEX_FUNC(9, opt); \
- VSCALEX_FUNC(10, opt)
-
-#if ARCH_X86_32
-VSCALEX_FUNCS(mmxext);
-#endif
-VSCALEX_FUNCS(sse2);
-VSCALEX_FUNCS(sse4);
-VSCALEX_FUNC(16, sse4);
-VSCALEX_FUNCS(avx);
-
-#define VSCALE_FUNC(size, opt) \
-extern void ff_yuv2plane1_ ## size ## _ ## opt(const int16_t *src, uint8_t *dst, int dstW, \
- const uint8_t *dither, int offset)
-#define VSCALE_FUNCS(opt1, opt2) \
- VSCALE_FUNC(8, opt1); \
- VSCALE_FUNC(9, opt2); \
- VSCALE_FUNC(10, opt2); \
- VSCALE_FUNC(16, opt1)
-
-#if ARCH_X86_32
-VSCALE_FUNCS(mmx, mmxext);
-#endif
-VSCALE_FUNCS(sse2, sse2);
-VSCALE_FUNC(16, sse4);
-VSCALE_FUNCS(avx, avx);
-
-#define INPUT_Y_FUNC(fmt, opt) \
-extern void ff_ ## fmt ## ToY_ ## opt(uint8_t *dst, const uint8_t *src, \
- const uint8_t *unused1, const uint8_t *unused2, \
- int w, uint32_t *unused)
-#define INPUT_UV_FUNC(fmt, opt) \
-extern void ff_ ## fmt ## ToUV_ ## opt(uint8_t *dstU, uint8_t *dstV, \
- const uint8_t *unused0, \
- const uint8_t *src1, \
- const uint8_t *src2, \
- int w, uint32_t *unused)
-#define INPUT_FUNC(fmt, opt) \
- INPUT_Y_FUNC(fmt, opt); \
- INPUT_UV_FUNC(fmt, opt)
-#define INPUT_FUNCS(opt) \
- INPUT_FUNC(uyvy, opt); \
- INPUT_FUNC(yuyv, opt); \
- INPUT_UV_FUNC(nv12, opt); \
- INPUT_UV_FUNC(nv21, opt); \
- INPUT_FUNC(rgba, opt); \
- INPUT_FUNC(bgra, opt); \
- INPUT_FUNC(argb, opt); \
- INPUT_FUNC(abgr, opt); \
- INPUT_FUNC(rgb24, opt); \
- INPUT_FUNC(bgr24, opt)
-
-#if ARCH_X86_32
-INPUT_FUNCS(mmx);
-#endif
-INPUT_FUNCS(sse2);
-INPUT_FUNCS(ssse3);
-INPUT_FUNCS(avx);
-
-av_cold void ff_sws_init_swScale_mmx(SwsContext *c)
-{
- int cpu_flags = av_get_cpu_flags();
-
-#if HAVE_INLINE_ASM
- if (cpu_flags & AV_CPU_FLAG_MMX)
- sws_init_swScale_MMX(c);
-#if HAVE_MMXEXT_INLINE
- if (cpu_flags & AV_CPU_FLAG_MMXEXT)
- sws_init_swScale_MMXEXT(c);
- if (cpu_flags & AV_CPU_FLAG_SSE3){
- if(c->use_mmx_vfilter && !(c->flags & SWS_ACCURATE_RND))
- c->yuv2planeX = yuv2yuvX_sse3;
- }
-#endif
-#endif /* HAVE_INLINE_ASM */
-
-#define ASSIGN_SCALE_FUNC2(hscalefn, filtersize, opt1, opt2) do { \
- if (c->srcBpc == 8) { \
- hscalefn = c->dstBpc <= 14 ? ff_hscale8to15_ ## filtersize ## _ ## opt2 : \
- ff_hscale8to19_ ## filtersize ## _ ## opt1; \
- } else if (c->srcBpc == 9) { \
- hscalefn = c->dstBpc <= 14 ? ff_hscale9to15_ ## filtersize ## _ ## opt2 : \
- ff_hscale9to19_ ## filtersize ## _ ## opt1; \
- } else if (c->srcBpc == 10) { \
- hscalefn = c->dstBpc <= 14 ? ff_hscale10to15_ ## filtersize ## _ ## opt2 : \
- ff_hscale10to19_ ## filtersize ## _ ## opt1; \
- } else if (c->srcBpc == 12) { \
- hscalefn = c->dstBpc <= 14 ? ff_hscale12to15_ ## filtersize ## _ ## opt2 : \
- ff_hscale12to19_ ## filtersize ## _ ## opt1; \
- } else if (c->srcBpc == 14 || ((c->srcFormat==AV_PIX_FMT_PAL8||isAnyRGB(c->srcFormat)) && av_pix_fmt_desc_get(c->srcFormat)->comp[0].depth_minus1<15)) { \
- hscalefn = c->dstBpc <= 14 ? ff_hscale14to15_ ## filtersize ## _ ## opt2 : \
- ff_hscale14to19_ ## filtersize ## _ ## opt1; \
- } else { /* c->srcBpc == 16 */ \
- av_assert0(c->srcBpc == 16);\
- hscalefn = c->dstBpc <= 14 ? ff_hscale16to15_ ## filtersize ## _ ## opt2 : \
- ff_hscale16to19_ ## filtersize ## _ ## opt1; \
- } \
-} while (0)
-#define ASSIGN_MMX_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \
- switch (filtersize) { \
- case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \
- case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \
- default: ASSIGN_SCALE_FUNC2(hscalefn, X, opt1, opt2); break; \
- }
-#define ASSIGN_VSCALEX_FUNC(vscalefn, opt, do_16_case, condition_8bit) \
-switch(c->dstBpc){ \
- case 16: do_16_case; break; \
- case 10: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_10_ ## opt; break; \
- case 9: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2planeX_9_ ## opt; break; \
- default: if (condition_8bit) /*vscalefn = ff_yuv2planeX_8_ ## opt;*/ break; \
- }
-#define ASSIGN_VSCALE_FUNC(vscalefn, opt1, opt2, opt2chk) \
- switch(c->dstBpc){ \
- case 16: if (!isBE(c->dstFormat)) vscalefn = ff_yuv2plane1_16_ ## opt1; break; \
- case 10: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_10_ ## opt2; break; \
- case 9: if (!isBE(c->dstFormat) && opt2chk) vscalefn = ff_yuv2plane1_9_ ## opt2; break; \
- case 8: vscalefn = ff_yuv2plane1_8_ ## opt1; break; \
- default: av_assert0(c->dstBpc>8); \
- }
-#define case_rgb(x, X, opt) \
- case AV_PIX_FMT_ ## X: \
- c->lumToYV12 = ff_ ## x ## ToY_ ## opt; \
- if (!c->chrSrcHSubSample) \
- c->chrToYV12 = ff_ ## x ## ToUV_ ## opt; \
- break
-#if ARCH_X86_32
- if (EXTERNAL_MMX(cpu_flags)) {
- ASSIGN_MMX_SCALE_FUNC(c->hyScale, c->hLumFilterSize, mmx, mmx);
- ASSIGN_MMX_SCALE_FUNC(c->hcScale, c->hChrFilterSize, mmx, mmx);
- ASSIGN_VSCALE_FUNC(c->yuv2plane1, mmx, mmxext, cpu_flags & AV_CPU_FLAG_MMXEXT);
-
- switch (c->srcFormat) {
- case AV_PIX_FMT_Y400A:
- c->lumToYV12 = ff_yuyvToY_mmx;
- if (c->alpPixBuf)
- c->alpToYV12 = ff_uyvyToY_mmx;
- break;
- case AV_PIX_FMT_YUYV422:
- c->lumToYV12 = ff_yuyvToY_mmx;
- c->chrToYV12 = ff_yuyvToUV_mmx;
- break;
- case AV_PIX_FMT_UYVY422:
- c->lumToYV12 = ff_uyvyToY_mmx;
- c->chrToYV12 = ff_uyvyToUV_mmx;
- break;
- case AV_PIX_FMT_NV12:
- c->chrToYV12 = ff_nv12ToUV_mmx;
- break;
- case AV_PIX_FMT_NV21:
- c->chrToYV12 = ff_nv21ToUV_mmx;
- break;
- case_rgb(rgb24, RGB24, mmx);
- case_rgb(bgr24, BGR24, mmx);
- case_rgb(bgra, BGRA, mmx);
- case_rgb(rgba, RGBA, mmx);
- case_rgb(abgr, ABGR, mmx);
- case_rgb(argb, ARGB, mmx);
- default:
- break;
- }
- }
- if (EXTERNAL_MMXEXT(cpu_flags)) {
- ASSIGN_VSCALEX_FUNC(c->yuv2planeX, mmxext, , 1);
- }
-#endif /* ARCH_X86_32 */
-#define ASSIGN_SSE_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \
- switch (filtersize) { \
- case 4: ASSIGN_SCALE_FUNC2(hscalefn, 4, opt1, opt2); break; \
- case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \
- default: if (filtersize & 4) ASSIGN_SCALE_FUNC2(hscalefn, X4, opt1, opt2); \
- else ASSIGN_SCALE_FUNC2(hscalefn, X8, opt1, opt2); \
- break; \
- }
- if (EXTERNAL_SSE2(cpu_flags)) {
- ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse2, sse2);
- ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse2, sse2);
- ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse2, ,
- HAVE_ALIGNED_STACK || ARCH_X86_64);
- ASSIGN_VSCALE_FUNC(c->yuv2plane1, sse2, sse2, 1);
-
- switch (c->srcFormat) {
- case AV_PIX_FMT_Y400A:
- c->lumToYV12 = ff_yuyvToY_sse2;
- if (c->alpPixBuf)
- c->alpToYV12 = ff_uyvyToY_sse2;
- break;
- case AV_PIX_FMT_YUYV422:
- c->lumToYV12 = ff_yuyvToY_sse2;
- c->chrToYV12 = ff_yuyvToUV_sse2;
- break;
- case AV_PIX_FMT_UYVY422:
- c->lumToYV12 = ff_uyvyToY_sse2;
- c->chrToYV12 = ff_uyvyToUV_sse2;
- break;
- case AV_PIX_FMT_NV12:
- c->chrToYV12 = ff_nv12ToUV_sse2;
- break;
- case AV_PIX_FMT_NV21:
- c->chrToYV12 = ff_nv21ToUV_sse2;
- break;
- case_rgb(rgb24, RGB24, sse2);
- case_rgb(bgr24, BGR24, sse2);
- case_rgb(bgra, BGRA, sse2);
- case_rgb(rgba, RGBA, sse2);
- case_rgb(abgr, ABGR, sse2);
- case_rgb(argb, ARGB, sse2);
- default:
- break;
- }
- }
- if (EXTERNAL_SSSE3(cpu_flags)) {
- ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, ssse3, ssse3);
- ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, ssse3, ssse3);
- switch (c->srcFormat) {
- case_rgb(rgb24, RGB24, ssse3);
- case_rgb(bgr24, BGR24, ssse3);
- default:
- break;
- }
- }
- if (EXTERNAL_SSE4(cpu_flags)) {
- /* Xto15 don't need special sse4 functions */
- ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse4, ssse3);
- ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse4, ssse3);
- ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse4,
- if (!isBE(c->dstFormat)) c->yuv2planeX = ff_yuv2planeX_16_sse4,
- HAVE_ALIGNED_STACK || ARCH_X86_64);
- if (c->dstBpc == 16 && !isBE(c->dstFormat))
- c->yuv2plane1 = ff_yuv2plane1_16_sse4;
- }
-
- if (EXTERNAL_AVX(cpu_flags)) {
- ASSIGN_VSCALEX_FUNC(c->yuv2planeX, avx, ,
- HAVE_ALIGNED_STACK || ARCH_X86_64);
- ASSIGN_VSCALE_FUNC(c->yuv2plane1, avx, avx, 1);
-
- switch (c->srcFormat) {
- case AV_PIX_FMT_YUYV422:
- c->chrToYV12 = ff_yuyvToUV_avx;
- break;
- case AV_PIX_FMT_UYVY422:
- c->chrToYV12 = ff_uyvyToUV_avx;
- break;
- case AV_PIX_FMT_NV12:
- c->chrToYV12 = ff_nv12ToUV_avx;
- break;
- case AV_PIX_FMT_NV21:
- c->chrToYV12 = ff_nv21ToUV_avx;
- break;
- case_rgb(rgb24, RGB24, avx);
- case_rgb(bgr24, BGR24, avx);
- case_rgb(bgra, BGRA, avx);
- case_rgb(rgba, RGBA, avx);
- case_rgb(abgr, ABGR, avx);
- case_rgb(argb, ARGB, avx);
- default:
- break;
- }
- }
-}
diff --git a/src/thirdparty/ffmpeg/libswscale/x86/swscale_template.c b/src/thirdparty/ffmpeg/libswscale/x86/swscale_template.c
deleted file mode 100644
index 9d59b49c7..000000000
--- a/src/thirdparty/ffmpeg/libswscale/x86/swscale_template.c
+++ /dev/null
@@ -1,1717 +0,0 @@
-/*
- * Copyright (C) 2001-2011 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
- */
-
-#undef REAL_MOVNTQ
-#undef MOVNTQ
-#undef MOVNTQ2
-#undef PREFETCH
-
-#if COMPILE_TEMPLATE_MMXEXT
-#define PREFETCH "prefetchnta"
-#else
-#define PREFETCH " # nop"
-#endif
-
-#if COMPILE_TEMPLATE_MMXEXT
-#define REAL_MOVNTQ(a,b) "movntq " #a ", " #b " \n\t"
-#define MOVNTQ2 "movntq "
-#else
-#define REAL_MOVNTQ(a,b) "movq " #a ", " #b " \n\t"
-#define MOVNTQ2 "movq "
-#endif
-#define MOVNTQ(a,b) REAL_MOVNTQ(a,b)
-
-#if !COMPILE_TEMPLATE_MMXEXT
-static av_always_inline void
-dither_8to16(const uint8_t *srcDither, int rot)
-{
- if (rot) {
- __asm__ volatile("pxor %%mm0, %%mm0\n\t"
- "movq (%0), %%mm3\n\t"
- "movq %%mm3, %%mm4\n\t"
- "psrlq $24, %%mm3\n\t"
- "psllq $40, %%mm4\n\t"
- "por %%mm4, %%mm3\n\t"
- "movq %%mm3, %%mm4\n\t"
- "punpcklbw %%mm0, %%mm3\n\t"
- "punpckhbw %%mm0, %%mm4\n\t"
- :: "r"(srcDither)
- );
- } else {
- __asm__ volatile("pxor %%mm0, %%mm0\n\t"
- "movq (%0), %%mm3\n\t"
- "movq %%mm3, %%mm4\n\t"
- "punpcklbw %%mm0, %%mm3\n\t"
- "punpckhbw %%mm0, %%mm4\n\t"
- :: "r"(srcDither)
- );
- }
-}
-#endif
-
-static void RENAME(yuv2yuvX)(const int16_t *filter, int filterSize,
- const int16_t **src, uint8_t *dest, int dstW,
- const uint8_t *dither, int offset)
-{
- dither_8to16(dither, offset);
- filterSize--;
- __asm__ volatile(
- "movd %0, %%mm1\n\t"
- "punpcklwd %%mm1, %%mm1\n\t"
- "punpckldq %%mm1, %%mm1\n\t"
- "psllw $3, %%mm1\n\t"
- "paddw %%mm1, %%mm3\n\t"
- "paddw %%mm1, %%mm4\n\t"
- "psraw $4, %%mm3\n\t"
- "psraw $4, %%mm4\n\t"
- ::"m"(filterSize)
- );
-
- __asm__ volatile(\
- "movq %%mm3, %%mm6\n\t"
- "movq %%mm4, %%mm7\n\t"
- "movl %3, %%ecx\n\t"
- "mov %0, %%"REG_d" \n\t"\
- "mov (%%"REG_d"), %%"REG_S" \n\t"\
- ".p2align 4 \n\t" /* FIXME Unroll? */\
- "1: \n\t"\
- "movq 8(%%"REG_d"), %%mm0 \n\t" /* filterCoeff */\
- "movq (%%"REG_S", %%"REG_c", 2), %%mm2 \n\t" /* srcData */\
- "movq 8(%%"REG_S", %%"REG_c", 2), %%mm5 \n\t" /* srcData */\
- "add $16, %%"REG_d" \n\t"\
- "mov (%%"REG_d"), %%"REG_S" \n\t"\
- "test %%"REG_S", %%"REG_S" \n\t"\
- "pmulhw %%mm0, %%mm2 \n\t"\
- "pmulhw %%mm0, %%mm5 \n\t"\
- "paddw %%mm2, %%mm3 \n\t"\
- "paddw %%mm5, %%mm4 \n\t"\
- " jnz 1b \n\t"\
- "psraw $3, %%mm3 \n\t"\
- "psraw $3, %%mm4 \n\t"\
- "packuswb %%mm4, %%mm3 \n\t"
- MOVNTQ2 " %%mm3, (%1, %%"REG_c")\n\t"
- "add $8, %%"REG_c" \n\t"\
- "cmp %2, %%"REG_c" \n\t"\
- "movq %%mm6, %%mm3\n\t"
- "movq %%mm7, %%mm4\n\t"
- "mov %0, %%"REG_d" \n\t"\
- "mov (%%"REG_d"), %%"REG_S" \n\t"\
- "jb 1b \n\t"\
- :: "g" (filter),
- "r" (dest-offset), "g" ((x86_reg)(dstW+offset)), "m" (offset)
- : "%"REG_d, "%"REG_S, "%"REG_c
- );
-}
-
-#define YSCALEYUV2PACKEDX_UV \
- __asm__ volatile(\
- "xor %%"REG_a", %%"REG_a" \n\t"\
- ".p2align 4 \n\t"\
- "nop \n\t"\
- "1: \n\t"\
- "lea "CHR_MMX_FILTER_OFFSET"(%0), %%"REG_d" \n\t"\
- "mov (%%"REG_d"), %%"REG_S" \n\t"\
- "movq "VROUNDER_OFFSET"(%0), %%mm3 \n\t"\
- "movq %%mm3, %%mm4 \n\t"\
- ".p2align 4 \n\t"\
- "2: \n\t"\
- "movq 8(%%"REG_d"), %%mm0 \n\t" /* filterCoeff */\
- "movq (%%"REG_S", %%"REG_a"), %%mm2 \n\t" /* UsrcData */\
- "add %6, %%"REG_S" \n\t" \
- "movq (%%"REG_S", %%"REG_a"), %%mm5 \n\t" /* VsrcData */\
- "add $16, %%"REG_d" \n\t"\
- "mov (%%"REG_d"), %%"REG_S" \n\t"\
- "pmulhw %%mm0, %%mm2 \n\t"\
- "pmulhw %%mm0, %%mm5 \n\t"\
- "paddw %%mm2, %%mm3 \n\t"\
- "paddw %%mm5, %%mm4 \n\t"\
- "test %%"REG_S", %%"REG_S" \n\t"\
- " jnz 2b \n\t"\
-
-#define YSCALEYUV2PACKEDX_YA(offset,coeff,src1,src2,dst1,dst2) \
- "lea "offset"(%0), %%"REG_d" \n\t"\
- "mov (%%"REG_d"), %%"REG_S" \n\t"\
- "movq "VROUNDER_OFFSET"(%0), "#dst1" \n\t"\
- "movq "#dst1", "#dst2" \n\t"\
- ".p2align 4 \n\t"\
- "2: \n\t"\
- "movq 8(%%"REG_d"), "#coeff" \n\t" /* filterCoeff */\
- "movq (%%"REG_S", %%"REG_a", 2), "#src1" \n\t" /* Y1srcData */\
- "movq 8(%%"REG_S", %%"REG_a", 2), "#src2" \n\t" /* Y2srcData */\
- "add $16, %%"REG_d" \n\t"\
- "mov (%%"REG_d"), %%"REG_S" \n\t"\
- "pmulhw "#coeff", "#src1" \n\t"\
- "pmulhw "#coeff", "#src2" \n\t"\
- "paddw "#src1", "#dst1" \n\t"\
- "paddw "#src2", "#dst2" \n\t"\
- "test %%"REG_S", %%"REG_S" \n\t"\
- " jnz 2b \n\t"\
-
-#define YSCALEYUV2PACKEDX \
- YSCALEYUV2PACKEDX_UV \
- YSCALEYUV2PACKEDX_YA(LUM_MMX_FILTER_OFFSET,%%mm0,%%mm2,%%mm5,%%mm1,%%mm7) \
-
-#define YSCALEYUV2PACKEDX_END \
- :: "r" (&c->redDither), \
- "m" (dummy), "m" (dummy), "m" (dummy),\
- "r" (dest), "m" (dstW_reg), "m"(uv_off) \
- : "%"REG_a, "%"REG_d, "%"REG_S \
- );
-
-#define YSCALEYUV2PACKEDX_ACCURATE_UV \
- __asm__ volatile(\
- "xor %%"REG_a", %%"REG_a" \n\t"\
- ".p2align 4 \n\t"\
- "nop \n\t"\
- "1: \n\t"\
- "lea "CHR_MMX_FILTER_OFFSET"(%0), %%"REG_d" \n\t"\
- "mov (%%"REG_d"), %%"REG_S" \n\t"\
- "pxor %%mm4, %%mm4 \n\t"\
- "pxor %%mm5, %%mm5 \n\t"\
- "pxor %%mm6, %%mm6 \n\t"\
- "pxor %%mm7, %%mm7 \n\t"\
- ".p2align 4 \n\t"\
- "2: \n\t"\
- "movq (%%"REG_S", %%"REG_a"), %%mm0 \n\t" /* UsrcData */\
- "add %6, %%"REG_S" \n\t" \
- "movq (%%"REG_S", %%"REG_a"), %%mm2 \n\t" /* VsrcData */\
- "mov "STR(APCK_PTR2)"(%%"REG_d"), %%"REG_S" \n\t"\
- "movq (%%"REG_S", %%"REG_a"), %%mm1 \n\t" /* UsrcData */\
- "movq %%mm0, %%mm3 \n\t"\
- "punpcklwd %%mm1, %%mm0 \n\t"\
- "punpckhwd %%mm1, %%mm3 \n\t"\
- "movq "STR(APCK_COEF)"(%%"REG_d"),%%mm1 \n\t" /* filterCoeff */\
- "pmaddwd %%mm1, %%mm0 \n\t"\
- "pmaddwd %%mm1, %%mm3 \n\t"\
- "paddd %%mm0, %%mm4 \n\t"\
- "paddd %%mm3, %%mm5 \n\t"\
- "add %6, %%"REG_S" \n\t" \
- "movq (%%"REG_S", %%"REG_a"), %%mm3 \n\t" /* VsrcData */\
- "mov "STR(APCK_SIZE)"(%%"REG_d"), %%"REG_S" \n\t"\
- "add $"STR(APCK_SIZE)", %%"REG_d" \n\t"\
- "test %%"REG_S", %%"REG_S" \n\t"\
- "movq %%mm2, %%mm0 \n\t"\
- "punpcklwd %%mm3, %%mm2 \n\t"\
- "punpckhwd %%mm3, %%mm0 \n\t"\
- "pmaddwd %%mm1, %%mm2 \n\t"\
- "pmaddwd %%mm1, %%mm0 \n\t"\
- "paddd %%mm2, %%mm6 \n\t"\
- "paddd %%mm0, %%mm7 \n\t"\
- " jnz 2b \n\t"\
- "psrad $16, %%mm4 \n\t"\
- "psrad $16, %%mm5 \n\t"\
- "psrad $16, %%mm6 \n\t"\
- "psrad $16, %%mm7 \n\t"\
- "movq "VROUNDER_OFFSET"(%0), %%mm0 \n\t"\
- "packssdw %%mm5, %%mm4 \n\t"\
- "packssdw %%mm7, %%mm6 \n\t"\
- "paddw %%mm0, %%mm4 \n\t"\
- "paddw %%mm0, %%mm6 \n\t"\
- "movq %%mm4, "U_TEMP"(%0) \n\t"\
- "movq %%mm6, "V_TEMP"(%0) \n\t"\
-
-#define YSCALEYUV2PACKEDX_ACCURATE_YA(offset) \
- "lea "offset"(%0), %%"REG_d" \n\t"\
- "mov (%%"REG_d"), %%"REG_S" \n\t"\
- "pxor %%mm1, %%mm1 \n\t"\
- "pxor %%mm5, %%mm5 \n\t"\
- "pxor %%mm7, %%mm7 \n\t"\
- "pxor %%mm6, %%mm6 \n\t"\
- ".p2align 4 \n\t"\
- "2: \n\t"\
- "movq (%%"REG_S", %%"REG_a", 2), %%mm0 \n\t" /* Y1srcData */\
- "movq 8(%%"REG_S", %%"REG_a", 2), %%mm2 \n\t" /* Y2srcData */\
- "mov "STR(APCK_PTR2)"(%%"REG_d"), %%"REG_S" \n\t"\
- "movq (%%"REG_S", %%"REG_a", 2), %%mm4 \n\t" /* Y1srcData */\
- "movq %%mm0, %%mm3 \n\t"\
- "punpcklwd %%mm4, %%mm0 \n\t"\
- "punpckhwd %%mm4, %%mm3 \n\t"\
- "movq "STR(APCK_COEF)"(%%"REG_d"), %%mm4 \n\t" /* filterCoeff */\
- "pmaddwd %%mm4, %%mm0 \n\t"\
- "pmaddwd %%mm4, %%mm3 \n\t"\
- "paddd %%mm0, %%mm1 \n\t"\
- "paddd %%mm3, %%mm5 \n\t"\
- "movq 8(%%"REG_S", %%"REG_a", 2), %%mm3 \n\t" /* Y2srcData */\
- "mov "STR(APCK_SIZE)"(%%"REG_d"), %%"REG_S" \n\t"\
- "add $"STR(APCK_SIZE)", %%"REG_d" \n\t"\
- "test %%"REG_S", %%"REG_S" \n\t"\
- "movq %%mm2, %%mm0 \n\t"\
- "punpcklwd %%mm3, %%mm2 \n\t"\
- "punpckhwd %%mm3, %%mm0 \n\t"\
- "pmaddwd %%mm4, %%mm2 \n\t"\
- "pmaddwd %%mm4, %%mm0 \n\t"\
- "paddd %%mm2, %%mm7 \n\t"\
- "paddd %%mm0, %%mm6 \n\t"\
- " jnz 2b \n\t"\
- "psrad $16, %%mm1 \n\t"\
- "psrad $16, %%mm5 \n\t"\
- "psrad $16, %%mm7 \n\t"\
- "psrad $16, %%mm6 \n\t"\
- "movq "VROUNDER_OFFSET"(%0), %%mm0 \n\t"\
- "packssdw %%mm5, %%mm1 \n\t"\
- "packssdw %%mm6, %%mm7 \n\t"\
- "paddw %%mm0, %%mm1 \n\t"\
- "paddw %%mm0, %%mm7 \n\t"\
- "movq "U_TEMP"(%0), %%mm3 \n\t"\
- "movq "V_TEMP"(%0), %%mm4 \n\t"\
-
-#define YSCALEYUV2PACKEDX_ACCURATE \
- YSCALEYUV2PACKEDX_ACCURATE_UV \
- YSCALEYUV2PACKEDX_ACCURATE_YA(LUM_MMX_FILTER_OFFSET)
-
-#define YSCALEYUV2RGBX \
- "psubw "U_OFFSET"(%0), %%mm3 \n\t" /* (U-128)8*/\
- "psubw "V_OFFSET"(%0), %%mm4 \n\t" /* (V-128)8*/\
- "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\
- "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\
- "pmulhw "UG_COEFF"(%0), %%mm3 \n\t"\
- "pmulhw "VG_COEFF"(%0), %%mm4 \n\t"\
- /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\
- "pmulhw "UB_COEFF"(%0), %%mm2 \n\t"\
- "pmulhw "VR_COEFF"(%0), %%mm5 \n\t"\
- "psubw "Y_OFFSET"(%0), %%mm1 \n\t" /* 8(Y-16)*/\
- "psubw "Y_OFFSET"(%0), %%mm7 \n\t" /* 8(Y-16)*/\
- "pmulhw "Y_COEFF"(%0), %%mm1 \n\t"\
- "pmulhw "Y_COEFF"(%0), %%mm7 \n\t"\
- /* mm1= Y1, mm2=ub, mm3=ug, mm4=vg mm5=vr, mm7=Y2 */\
- "paddw %%mm3, %%mm4 \n\t"\
- "movq %%mm2, %%mm0 \n\t"\
- "movq %%mm5, %%mm6 \n\t"\
- "movq %%mm4, %%mm3 \n\t"\
- "punpcklwd %%mm2, %%mm2 \n\t"\
- "punpcklwd %%mm5, %%mm5 \n\t"\
- "punpcklwd %%mm4, %%mm4 \n\t"\
- "paddw %%mm1, %%mm2 \n\t"\
- "paddw %%mm1, %%mm5 \n\t"\
- "paddw %%mm1, %%mm4 \n\t"\
- "punpckhwd %%mm0, %%mm0 \n\t"\
- "punpckhwd %%mm6, %%mm6 \n\t"\
- "punpckhwd %%mm3, %%mm3 \n\t"\
- "paddw %%mm7, %%mm0 \n\t"\
- "paddw %%mm7, %%mm6 \n\t"\
- "paddw %%mm7, %%mm3 \n\t"\
- /* mm0=B1, mm2=B2, mm3=G2, mm4=G1, mm5=R1, mm6=R2 */\
- "packuswb %%mm0, %%mm2 \n\t"\
- "packuswb %%mm6, %%mm5 \n\t"\
- "packuswb %%mm3, %%mm4 \n\t"\
-
-#define REAL_WRITEBGR32(dst, dstw, index, b, g, r, a, q0, q2, q3, t) \
- "movq "#b", "#q2" \n\t" /* B */\
- "movq "#r", "#t" \n\t" /* R */\
- "punpcklbw "#g", "#b" \n\t" /* GBGBGBGB 0 */\
- "punpcklbw "#a", "#r" \n\t" /* ARARARAR 0 */\
- "punpckhbw "#g", "#q2" \n\t" /* GBGBGBGB 2 */\
- "punpckhbw "#a", "#t" \n\t" /* ARARARAR 2 */\
- "movq "#b", "#q0" \n\t" /* GBGBGBGB 0 */\
- "movq "#q2", "#q3" \n\t" /* GBGBGBGB 2 */\
- "punpcklwd "#r", "#q0" \n\t" /* ARGBARGB 0 */\
- "punpckhwd "#r", "#b" \n\t" /* ARGBARGB 1 */\
- "punpcklwd "#t", "#q2" \n\t" /* ARGBARGB 2 */\
- "punpckhwd "#t", "#q3" \n\t" /* ARGBARGB 3 */\
-\
- MOVNTQ( q0, (dst, index, 4))\
- MOVNTQ( b, 8(dst, index, 4))\
- MOVNTQ( q2, 16(dst, index, 4))\
- MOVNTQ( q3, 24(dst, index, 4))\
-\
- "add $8, "#index" \n\t"\
- "cmp "#dstw", "#index" \n\t"\
- " jb 1b \n\t"
-#define WRITEBGR32(dst, dstw, index, b, g, r, a, q0, q2, q3, t) REAL_WRITEBGR32(dst, dstw, index, b, g, r, a, q0, q2, q3, t)
-
-static void RENAME(yuv2rgb32_X_ar)(SwsContext *c, const int16_t *lumFilter,
- const int16_t **lumSrc, int lumFilterSize,
- const int16_t *chrFilter, const int16_t **chrUSrc,
- const int16_t **chrVSrc,
- int chrFilterSize, const int16_t **alpSrc,
- uint8_t *dest, int dstW, int dstY)
-{
- x86_reg dummy=0;
- x86_reg dstW_reg = dstW;
- x86_reg uv_off = c->uv_offx2;
-
- if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) {
- YSCALEYUV2PACKEDX_ACCURATE
- YSCALEYUV2RGBX
- "movq %%mm2, "U_TEMP"(%0) \n\t"
- "movq %%mm4, "V_TEMP"(%0) \n\t"
- "movq %%mm5, "Y_TEMP"(%0) \n\t"
- YSCALEYUV2PACKEDX_ACCURATE_YA(ALP_MMX_FILTER_OFFSET)
- "movq "Y_TEMP"(%0), %%mm5 \n\t"
- "psraw $3, %%mm1 \n\t"
- "psraw $3, %%mm7 \n\t"
- "packuswb %%mm7, %%mm1 \n\t"
- WRITEBGR32(%4, %5, %%REGa, %%mm3, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm2, %%mm6)
- YSCALEYUV2PACKEDX_END
- } else {
- YSCALEYUV2PACKEDX_ACCURATE
- YSCALEYUV2RGBX
- "pcmpeqd %%mm7, %%mm7 \n\t"
- WRITEBGR32(%4, %5, %%REGa, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
- YSCALEYUV2PACKEDX_END
- }
-}
-
-static void RENAME(yuv2rgb32_X)(SwsContext *c, const int16_t *lumFilter,
- const int16_t **lumSrc, int lumFilterSize,
- const int16_t *chrFilter, const int16_t **chrUSrc,
- const int16_t **chrVSrc,
- int chrFilterSize, const int16_t **alpSrc,
- uint8_t *dest, int dstW, int dstY)
-{
- x86_reg dummy=0;
- x86_reg dstW_reg = dstW;
- x86_reg uv_off = c->uv_offx2;
-
- if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) {
- YSCALEYUV2PACKEDX
- YSCALEYUV2RGBX
- YSCALEYUV2PACKEDX_YA(ALP_MMX_FILTER_OFFSET, %%mm0, %%mm3, %%mm6, %%mm1, %%mm7)
- "psraw $3, %%mm1 \n\t"
- "psraw $3, %%mm7 \n\t"
- "packuswb %%mm7, %%mm1 \n\t"
- WRITEBGR32(%4, %5, %%REGa, %%mm2, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm3, %%mm6)
- YSCALEYUV2PACKEDX_END
- } else {
- YSCALEYUV2PACKEDX
- YSCALEYUV2RGBX
- "pcmpeqd %%mm7, %%mm7 \n\t"
- WRITEBGR32(%4, %5, %%REGa, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
- YSCALEYUV2PACKEDX_END
- }
-}
-
-#define REAL_WRITERGB16(dst, dstw, index) \
- "pand "MANGLE(bF8)", %%mm2 \n\t" /* B */\
- "pand "MANGLE(bFC)", %%mm4 \n\t" /* G */\
- "pand "MANGLE(bF8)", %%mm5 \n\t" /* R */\
- "psrlq $3, %%mm2 \n\t"\
-\
- "movq %%mm2, %%mm1 \n\t"\
- "movq %%mm4, %%mm3 \n\t"\
-\
- "punpcklbw %%mm7, %%mm3 \n\t"\
- "punpcklbw %%mm5, %%mm2 \n\t"\
- "punpckhbw %%mm7, %%mm4 \n\t"\
- "punpckhbw %%mm5, %%mm1 \n\t"\
-\
- "psllq $3, %%mm3 \n\t"\
- "psllq $3, %%mm4 \n\t"\
-\
- "por %%mm3, %%mm2 \n\t"\
- "por %%mm4, %%mm1 \n\t"\
-\
- MOVNTQ(%%mm2, (dst, index, 2))\
- MOVNTQ(%%mm1, 8(dst, index, 2))\
-\
- "add $8, "#index" \n\t"\
- "cmp "#dstw", "#index" \n\t"\
- " jb 1b \n\t"
-#define WRITERGB16(dst, dstw, index) REAL_WRITERGB16(dst, dstw, index)
-
-static void RENAME(yuv2rgb565_X_ar)(SwsContext *c, const int16_t *lumFilter,
- const int16_t **lumSrc, int lumFilterSize,
- const int16_t *chrFilter, const int16_t **chrUSrc,
- const int16_t **chrVSrc,
- int chrFilterSize, const int16_t **alpSrc,
- uint8_t *dest, int dstW, int dstY)
-{
- x86_reg dummy=0;
- x86_reg dstW_reg = dstW;
- x86_reg uv_off = c->uv_offx2;
-
- YSCALEYUV2PACKEDX_ACCURATE
- YSCALEYUV2RGBX
- "pxor %%mm7, %%mm7 \n\t"
- /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
-#ifdef DITHER1XBPP
- "paddusb "BLUE_DITHER"(%0), %%mm2\n\t"
- "paddusb "GREEN_DITHER"(%0), %%mm4\n\t"
- "paddusb "RED_DITHER"(%0), %%mm5\n\t"
-#endif
- WRITERGB16(%4, %5, %%REGa)
- YSCALEYUV2PACKEDX_END
-}
-
-static void RENAME(yuv2rgb565_X)(SwsContext *c, const int16_t *lumFilter,
- const int16_t **lumSrc, int lumFilterSize,
- const int16_t *chrFilter, const int16_t **chrUSrc,
- const int16_t **chrVSrc,
- int chrFilterSize, const int16_t **alpSrc,
- uint8_t *dest, int dstW, int dstY)
-{
- x86_reg dummy=0;
- x86_reg dstW_reg = dstW;
- x86_reg uv_off = c->uv_offx2;
-
- YSCALEYUV2PACKEDX
- YSCALEYUV2RGBX
- "pxor %%mm7, %%mm7 \n\t"
- /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
-#ifdef DITHER1XBPP
- "paddusb "BLUE_DITHER"(%0), %%mm2 \n\t"
- "paddusb "GREEN_DITHER"(%0), %%mm4 \n\t"
- "paddusb "RED_DITHER"(%0), %%mm5 \n\t"
-#endif
- WRITERGB16(%4, %5, %%REGa)
- YSCALEYUV2PACKEDX_END
-}
-
-#define REAL_WRITERGB15(dst, dstw, index) \
- "pand "MANGLE(bF8)", %%mm2 \n\t" /* B */\
- "pand "MANGLE(bF8)", %%mm4 \n\t" /* G */\
- "pand "MANGLE(bF8)", %%mm5 \n\t" /* R */\
- "psrlq $3, %%mm2 \n\t"\
- "psrlq $1, %%mm5 \n\t"\
-\
- "movq %%mm2, %%mm1 \n\t"\
- "movq %%mm4, %%mm3 \n\t"\
-\
- "punpcklbw %%mm7, %%mm3 \n\t"\
- "punpcklbw %%mm5, %%mm2 \n\t"\
- "punpckhbw %%mm7, %%mm4 \n\t"\
- "punpckhbw %%mm5, %%mm1 \n\t"\
-\
- "psllq $2, %%mm3 \n\t"\
- "psllq $2, %%mm4 \n\t"\
-\
- "por %%mm3, %%mm2 \n\t"\
- "por %%mm4, %%mm1 \n\t"\
-\
- MOVNTQ(%%mm2, (dst, index, 2))\
- MOVNTQ(%%mm1, 8(dst, index, 2))\
-\
- "add $8, "#index" \n\t"\
- "cmp "#dstw", "#index" \n\t"\
- " jb 1b \n\t"
-#define WRITERGB15(dst, dstw, index) REAL_WRITERGB15(dst, dstw, index)
-
-static void RENAME(yuv2rgb555_X_ar)(SwsContext *c, const int16_t *lumFilter,
- const int16_t **lumSrc, int lumFilterSize,
- const int16_t *chrFilter, const int16_t **chrUSrc,
- const int16_t **chrVSrc,
- int chrFilterSize, const int16_t **alpSrc,
- uint8_t *dest, int dstW, int dstY)
-{
- x86_reg dummy=0;
- x86_reg dstW_reg = dstW;
- x86_reg uv_off = c->uv_offx2;
-
- YSCALEYUV2PACKEDX_ACCURATE
- YSCALEYUV2RGBX
- "pxor %%mm7, %%mm7 \n\t"
- /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
-#ifdef DITHER1XBPP
- "paddusb "BLUE_DITHER"(%0), %%mm2\n\t"
- "paddusb "GREEN_DITHER"(%0), %%mm4\n\t"
- "paddusb "RED_DITHER"(%0), %%mm5\n\t"
-#endif
- WRITERGB15(%4, %5, %%REGa)
- YSCALEYUV2PACKEDX_END
-}
-
-static void RENAME(yuv2rgb555_X)(SwsContext *c, const int16_t *lumFilter,
- const int16_t **lumSrc, int lumFilterSize,
- const int16_t *chrFilter, const int16_t **chrUSrc,
- const int16_t **chrVSrc,
- int chrFilterSize, const int16_t **alpSrc,
- uint8_t *dest, int dstW, int dstY)
-{
- x86_reg dummy=0;
- x86_reg dstW_reg = dstW;
- x86_reg uv_off = c->uv_offx2;
-
- YSCALEYUV2PACKEDX
- YSCALEYUV2RGBX
- "pxor %%mm7, %%mm7 \n\t"
- /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
-#ifdef DITHER1XBPP
- "paddusb "BLUE_DITHER"(%0), %%mm2 \n\t"
- "paddusb "GREEN_DITHER"(%0), %%mm4 \n\t"
- "paddusb "RED_DITHER"(%0), %%mm5 \n\t"
-#endif
- WRITERGB15(%4, %5, %%REGa)
- YSCALEYUV2PACKEDX_END
-}
-
-#define WRITEBGR24MMX(dst, dstw, index) \
- /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\
- "movq %%mm2, %%mm1 \n\t" /* B */\
- "movq %%mm5, %%mm6 \n\t" /* R */\
- "punpcklbw %%mm4, %%mm2 \n\t" /* GBGBGBGB 0 */\
- "punpcklbw %%mm7, %%mm5 \n\t" /* 0R0R0R0R 0 */\
- "punpckhbw %%mm4, %%mm1 \n\t" /* GBGBGBGB 2 */\
- "punpckhbw %%mm7, %%mm6 \n\t" /* 0R0R0R0R 2 */\
- "movq %%mm2, %%mm0 \n\t" /* GBGBGBGB 0 */\
- "movq %%mm1, %%mm3 \n\t" /* GBGBGBGB 2 */\
- "punpcklwd %%mm5, %%mm0 \n\t" /* 0RGB0RGB 0 */\
- "punpckhwd %%mm5, %%mm2 \n\t" /* 0RGB0RGB 1 */\
- "punpcklwd %%mm6, %%mm1 \n\t" /* 0RGB0RGB 2 */\
- "punpckhwd %%mm6, %%mm3 \n\t" /* 0RGB0RGB 3 */\
-\
- "movq %%mm0, %%mm4 \n\t" /* 0RGB0RGB 0 */\
- "movq %%mm2, %%mm6 \n\t" /* 0RGB0RGB 1 */\
- "movq %%mm1, %%mm5 \n\t" /* 0RGB0RGB 2 */\
- "movq %%mm3, %%mm7 \n\t" /* 0RGB0RGB 3 */\
-\
- "psllq $40, %%mm0 \n\t" /* RGB00000 0 */\
- "psllq $40, %%mm2 \n\t" /* RGB00000 1 */\
- "psllq $40, %%mm1 \n\t" /* RGB00000 2 */\
- "psllq $40, %%mm3 \n\t" /* RGB00000 3 */\
-\
- "punpckhdq %%mm4, %%mm0 \n\t" /* 0RGBRGB0 0 */\
- "punpckhdq %%mm6, %%mm2 \n\t" /* 0RGBRGB0 1 */\
- "punpckhdq %%mm5, %%mm1 \n\t" /* 0RGBRGB0 2 */\
- "punpckhdq %%mm7, %%mm3 \n\t" /* 0RGBRGB0 3 */\
-\
- "psrlq $8, %%mm0 \n\t" /* 00RGBRGB 0 */\
- "movq %%mm2, %%mm6 \n\t" /* 0RGBRGB0 1 */\
- "psllq $40, %%mm2 \n\t" /* GB000000 1 */\
- "por %%mm2, %%mm0 \n\t" /* GBRGBRGB 0 */\
- MOVNTQ(%%mm0, (dst))\
-\
- "psrlq $24, %%mm6 \n\t" /* 0000RGBR 1 */\
- "movq %%mm1, %%mm5 \n\t" /* 0RGBRGB0 2 */\
- "psllq $24, %%mm1 \n\t" /* BRGB0000 2 */\
- "por %%mm1, %%mm6 \n\t" /* BRGBRGBR 1 */\
- MOVNTQ(%%mm6, 8(dst))\
-\
- "psrlq $40, %%mm5 \n\t" /* 000000RG 2 */\
- "psllq $8, %%mm3 \n\t" /* RGBRGB00 3 */\
- "por %%mm3, %%mm5 \n\t" /* RGBRGBRG 2 */\
- MOVNTQ(%%mm5, 16(dst))\
-\
- "add $24, "#dst" \n\t"\
-\
- "add $8, "#index" \n\t"\
- "cmp "#dstw", "#index" \n\t"\
- " jb 1b \n\t"
-
-#define WRITEBGR24MMXEXT(dst, dstw, index) \
- /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\
- "movq "MANGLE(ff_M24A)", %%mm0 \n\t"\
- "movq "MANGLE(ff_M24C)", %%mm7 \n\t"\
- "pshufw $0x50, %%mm2, %%mm1 \n\t" /* B3 B2 B3 B2 B1 B0 B1 B0 */\
- "pshufw $0x50, %%mm4, %%mm3 \n\t" /* G3 G2 G3 G2 G1 G0 G1 G0 */\
- "pshufw $0x00, %%mm5, %%mm6 \n\t" /* R1 R0 R1 R0 R1 R0 R1 R0 */\
-\
- "pand %%mm0, %%mm1 \n\t" /* B2 B1 B0 */\
- "pand %%mm0, %%mm3 \n\t" /* G2 G1 G0 */\
- "pand %%mm7, %%mm6 \n\t" /* R1 R0 */\
-\
- "psllq $8, %%mm3 \n\t" /* G2 G1 G0 */\
- "por %%mm1, %%mm6 \n\t"\
- "por %%mm3, %%mm6 \n\t"\
- MOVNTQ(%%mm6, (dst))\
-\
- "psrlq $8, %%mm4 \n\t" /* 00 G7 G6 G5 G4 G3 G2 G1 */\
- "pshufw $0xA5, %%mm2, %%mm1 \n\t" /* B5 B4 B5 B4 B3 B2 B3 B2 */\
- "pshufw $0x55, %%mm4, %%mm3 \n\t" /* G4 G3 G4 G3 G4 G3 G4 G3 */\
- "pshufw $0xA5, %%mm5, %%mm6 \n\t" /* R5 R4 R5 R4 R3 R2 R3 R2 */\
-\
- "pand "MANGLE(ff_M24B)", %%mm1 \n\t" /* B5 B4 B3 */\
- "pand %%mm7, %%mm3 \n\t" /* G4 G3 */\
- "pand %%mm0, %%mm6 \n\t" /* R4 R3 R2 */\
-\
- "por %%mm1, %%mm3 \n\t" /* B5 G4 B4 G3 B3 */\
- "por %%mm3, %%mm6 \n\t"\
- MOVNTQ(%%mm6, 8(dst))\
-\
- "pshufw $0xFF, %%mm2, %%mm1 \n\t" /* B7 B6 B7 B6 B7 B6 B6 B7 */\
- "pshufw $0xFA, %%mm4, %%mm3 \n\t" /* 00 G7 00 G7 G6 G5 G6 G5 */\
- "pshufw $0xFA, %%mm5, %%mm6 \n\t" /* R7 R6 R7 R6 R5 R4 R5 R4 */\
-\
- "pand %%mm7, %%mm1 \n\t" /* B7 B6 */\
- "pand %%mm0, %%mm3 \n\t" /* G7 G6 G5 */\
- "pand "MANGLE(ff_M24B)", %%mm6 \n\t" /* R7 R6 R5 */\
-\
- "por %%mm1, %%mm3 \n\t"\
- "por %%mm3, %%mm6 \n\t"\
- MOVNTQ(%%mm6, 16(dst))\
-\
- "add $24, "#dst" \n\t"\
-\
- "add $8, "#index" \n\t"\
- "cmp "#dstw", "#index" \n\t"\
- " jb 1b \n\t"
-
-#if COMPILE_TEMPLATE_MMXEXT
-#undef WRITEBGR24
-#define WRITEBGR24(dst, dstw, index) WRITEBGR24MMXEXT(dst, dstw, index)
-#else
-#undef WRITEBGR24
-#define WRITEBGR24(dst, dstw, index) WRITEBGR24MMX(dst, dstw, index)
-#endif
-
-static void RENAME(yuv2bgr24_X_ar)(SwsContext *c, const int16_t *lumFilter,
- const int16_t **lumSrc, int lumFilterSize,
- const int16_t *chrFilter, const int16_t **chrUSrc,
- const int16_t **chrVSrc,
- int chrFilterSize, const int16_t **alpSrc,
- uint8_t *dest, int dstW, int dstY)
-{
- x86_reg dummy=0;
- x86_reg dstW_reg = dstW;
- x86_reg uv_off = c->uv_offx2;
-
- YSCALEYUV2PACKEDX_ACCURATE
- YSCALEYUV2RGBX
- "pxor %%mm7, %%mm7 \n\t"
- "lea (%%"REG_a", %%"REG_a", 2), %%"REG_c"\n\t" //FIXME optimize
- "add %4, %%"REG_c" \n\t"
- WRITEBGR24(%%REGc, %5, %%REGa)
- :: "r" (&c->redDither),
- "m" (dummy), "m" (dummy), "m" (dummy),
- "r" (dest), "m" (dstW_reg), "m"(uv_off)
- : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S
- );
-}
-
-static void RENAME(yuv2bgr24_X)(SwsContext *c, const int16_t *lumFilter,
- const int16_t **lumSrc, int lumFilterSize,
- const int16_t *chrFilter, const int16_t **chrUSrc,
- const int16_t **chrVSrc,
- int chrFilterSize, const int16_t **alpSrc,
- uint8_t *dest, int dstW, int dstY)
-{
- x86_reg dummy=0;
- x86_reg dstW_reg = dstW;
- x86_reg uv_off = c->uv_offx2;
-
- YSCALEYUV2PACKEDX
- YSCALEYUV2RGBX
- "pxor %%mm7, %%mm7 \n\t"
- "lea (%%"REG_a", %%"REG_a", 2), %%"REG_c" \n\t" //FIXME optimize
- "add %4, %%"REG_c" \n\t"
- WRITEBGR24(%%REGc, %5, %%REGa)
- :: "r" (&c->redDither),
- "m" (dummy), "m" (dummy), "m" (dummy),
- "r" (dest), "m" (dstW_reg), "m"(uv_off)
- : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S
- );
-}
-
-#define REAL_WRITEYUY2(dst, dstw, index) \
- "packuswb %%mm3, %%mm3 \n\t"\
- "packuswb %%mm4, %%mm4 \n\t"\
- "packuswb %%mm7, %%mm1 \n\t"\
- "punpcklbw %%mm4, %%mm3 \n\t"\
- "movq %%mm1, %%mm7 \n\t"\
- "punpcklbw %%mm3, %%mm1 \n\t"\
- "punpckhbw %%mm3, %%mm7 \n\t"\
-\
- MOVNTQ(%%mm1, (dst, index, 2))\
- MOVNTQ(%%mm7, 8(dst, index, 2))\
-\
- "add $8, "#index" \n\t"\
- "cmp "#dstw", "#index" \n\t"\
- " jb 1b \n\t"
-#define WRITEYUY2(dst, dstw, index) REAL_WRITEYUY2(dst, dstw, index)
-
-static void RENAME(yuv2yuyv422_X_ar)(SwsContext *c, const int16_t *lumFilter,
- const int16_t **lumSrc, int lumFilterSize,
- const int16_t *chrFilter, const int16_t **chrUSrc,
- const int16_t **chrVSrc,
- int chrFilterSize, const int16_t **alpSrc,
- uint8_t *dest, int dstW, int dstY)
-{
- x86_reg dummy=0;
- x86_reg dstW_reg = dstW;
- x86_reg uv_off = c->uv_offx2;
-
- YSCALEYUV2PACKEDX_ACCURATE
- /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
- "psraw $3, %%mm3 \n\t"
- "psraw $3, %%mm4 \n\t"
- "psraw $3, %%mm1 \n\t"
- "psraw $3, %%mm7 \n\t"
- WRITEYUY2(%4, %5, %%REGa)
- YSCALEYUV2PACKEDX_END
-}
-
-static void RENAME(yuv2yuyv422_X)(SwsContext *c, const int16_t *lumFilter,
- const int16_t **lumSrc, int lumFilterSize,
- const int16_t *chrFilter, const int16_t **chrUSrc,
- const int16_t **chrVSrc,
- int chrFilterSize, const int16_t **alpSrc,
- uint8_t *dest, int dstW, int dstY)
-{
- x86_reg dummy=0;
- x86_reg dstW_reg = dstW;
- x86_reg uv_off = c->uv_offx2;
-
- YSCALEYUV2PACKEDX
- /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
- "psraw $3, %%mm3 \n\t"
- "psraw $3, %%mm4 \n\t"
- "psraw $3, %%mm1 \n\t"
- "psraw $3, %%mm7 \n\t"
- WRITEYUY2(%4, %5, %%REGa)
- YSCALEYUV2PACKEDX_END
-}
-
-#define REAL_YSCALEYUV2RGB_UV(index, c) \
- "xor "#index", "#index" \n\t"\
- ".p2align 4 \n\t"\
- "1: \n\t"\
- "movq (%2, "#index"), %%mm2 \n\t" /* uvbuf0[eax]*/\
- "movq (%3, "#index"), %%mm3 \n\t" /* uvbuf1[eax]*/\
- "add "UV_OFF_BYTE"("#c"), "#index" \n\t" \
- "movq (%2, "#index"), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\
- "movq (%3, "#index"), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\
- "sub "UV_OFF_BYTE"("#c"), "#index" \n\t" \
- "psubw %%mm3, %%mm2 \n\t" /* uvbuf0[eax] - uvbuf1[eax]*/\
- "psubw %%mm4, %%mm5 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048]*/\
- "movq "CHR_MMX_FILTER_OFFSET"+8("#c"), %%mm0 \n\t"\
- "pmulhw %%mm0, %%mm2 \n\t" /* (uvbuf0[eax] - uvbuf1[eax])uvalpha1>>16*/\
- "pmulhw %%mm0, %%mm5 \n\t" /* (uvbuf0[eax+2048] - uvbuf1[eax+2048])uvalpha1>>16*/\
- "psraw $4, %%mm3 \n\t" /* uvbuf0[eax] - uvbuf1[eax] >>4*/\
- "psraw $4, %%mm4 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048] >>4*/\
- "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax]uvalpha1 - uvbuf1[eax](1-uvalpha1)*/\
- "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048]uvalpha1 - uvbuf1[eax+2048](1-uvalpha1)*/\
- "psubw "U_OFFSET"("#c"), %%mm3 \n\t" /* (U-128)8*/\
- "psubw "V_OFFSET"("#c"), %%mm4 \n\t" /* (V-128)8*/\
- "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\
- "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\
- "pmulhw "UG_COEFF"("#c"), %%mm3 \n\t"\
- "pmulhw "VG_COEFF"("#c"), %%mm4 \n\t"\
- /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\
-
-#define REAL_YSCALEYUV2RGB_YA(index, c, b1, b2) \
- "movq ("#b1", "#index", 2), %%mm0 \n\t" /*buf0[eax]*/\
- "movq ("#b2", "#index", 2), %%mm1 \n\t" /*buf1[eax]*/\
- "movq 8("#b1", "#index", 2), %%mm6 \n\t" /*buf0[eax]*/\
- "movq 8("#b2", "#index", 2), %%mm7 \n\t" /*buf1[eax]*/\
- "psubw %%mm1, %%mm0 \n\t" /* buf0[eax] - buf1[eax]*/\
- "psubw %%mm7, %%mm6 \n\t" /* buf0[eax] - buf1[eax]*/\
- "pmulhw "LUM_MMX_FILTER_OFFSET"+8("#c"), %%mm0 \n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\
- "pmulhw "LUM_MMX_FILTER_OFFSET"+8("#c"), %%mm6 \n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\
- "psraw $4, %%mm1 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
- "psraw $4, %%mm7 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
- "paddw %%mm0, %%mm1 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\
- "paddw %%mm6, %%mm7 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\
-
-#define REAL_YSCALEYUV2RGB_COEFF(c) \
- "pmulhw "UB_COEFF"("#c"), %%mm2 \n\t"\
- "pmulhw "VR_COEFF"("#c"), %%mm5 \n\t"\
- "psubw "Y_OFFSET"("#c"), %%mm1 \n\t" /* 8(Y-16)*/\
- "psubw "Y_OFFSET"("#c"), %%mm7 \n\t" /* 8(Y-16)*/\
- "pmulhw "Y_COEFF"("#c"), %%mm1 \n\t"\
- "pmulhw "Y_COEFF"("#c"), %%mm7 \n\t"\
- /* mm1= Y1, mm2=ub, mm3=ug, mm4=vg mm5=vr, mm7=Y2 */\
- "paddw %%mm3, %%mm4 \n\t"\
- "movq %%mm2, %%mm0 \n\t"\
- "movq %%mm5, %%mm6 \n\t"\
- "movq %%mm4, %%mm3 \n\t"\
- "punpcklwd %%mm2, %%mm2 \n\t"\
- "punpcklwd %%mm5, %%mm5 \n\t"\
- "punpcklwd %%mm4, %%mm4 \n\t"\
- "paddw %%mm1, %%mm2 \n\t"\
- "paddw %%mm1, %%mm5 \n\t"\
- "paddw %%mm1, %%mm4 \n\t"\
- "punpckhwd %%mm0, %%mm0 \n\t"\
- "punpckhwd %%mm6, %%mm6 \n\t"\
- "punpckhwd %%mm3, %%mm3 \n\t"\
- "paddw %%mm7, %%mm0 \n\t"\
- "paddw %%mm7, %%mm6 \n\t"\
- "paddw %%mm7, %%mm3 \n\t"\
- /* mm0=B1, mm2=B2, mm3=G2, mm4=G1, mm5=R1, mm6=R2 */\
- "packuswb %%mm0, %%mm2 \n\t"\
- "packuswb %%mm6, %%mm5 \n\t"\
- "packuswb %%mm3, %%mm4 \n\t"\
-
-#define YSCALEYUV2RGB_YA(index, c, b1, b2) REAL_YSCALEYUV2RGB_YA(index, c, b1, b2)
-
-#define YSCALEYUV2RGB(index, c) \
- REAL_YSCALEYUV2RGB_UV(index, c) \
- REAL_YSCALEYUV2RGB_YA(index, c, %0, %1) \
- REAL_YSCALEYUV2RGB_COEFF(c)
-
-/**
- * vertical bilinear scale YV12 to RGB
- */
-static void RENAME(yuv2rgb32_2)(SwsContext *c, const int16_t *buf[2],
- const int16_t *ubuf[2], const int16_t *vbuf[2],
- const int16_t *abuf[2], uint8_t *dest,
- int dstW, int yalpha, int uvalpha, int y)
-{
- const int16_t *buf0 = buf[0], *buf1 = buf[1],
- *ubuf0 = ubuf[0], *ubuf1 = ubuf[1];
-
- if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) {
- const int16_t *abuf0 = abuf[0], *abuf1 = abuf[1];
-#if ARCH_X86_64
- __asm__ volatile(
- YSCALEYUV2RGB(%%r8, %5)
- YSCALEYUV2RGB_YA(%%r8, %5, %6, %7)
- "psraw $3, %%mm1 \n\t" /* abuf0[eax] - abuf1[eax] >>7*/
- "psraw $3, %%mm7 \n\t" /* abuf0[eax] - abuf1[eax] >>7*/
- "packuswb %%mm7, %%mm1 \n\t"
- WRITEBGR32(%4, 8280(%5), %%r8, %%mm2, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm3, %%mm6)
- :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "r" (dest),
- "a" (&c->redDither),
- "r" (abuf0), "r" (abuf1)
- : "%r8"
- );
-#else
- c->u_temp=(intptr_t)abuf0;
- c->v_temp=(intptr_t)abuf1;
- __asm__ volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB(%%REGBP, %5)
- "push %0 \n\t"
- "push %1 \n\t"
- "mov "U_TEMP"(%5), %0 \n\t"
- "mov "V_TEMP"(%5), %1 \n\t"
- YSCALEYUV2RGB_YA(%%REGBP, %5, %0, %1)
- "psraw $3, %%mm1 \n\t" /* abuf0[eax] - abuf1[eax] >>7*/
- "psraw $3, %%mm7 \n\t" /* abuf0[eax] - abuf1[eax] >>7*/
- "packuswb %%mm7, %%mm1 \n\t"
- "pop %1 \n\t"
- "pop %0 \n\t"
- WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm3, %%mm6)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
- :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
- "a" (&c->redDither)
- );
-#endif
- } else {
- __asm__ volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB(%%REGBP, %5)
- "pcmpeqd %%mm7, %%mm7 \n\t"
- WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
- :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
- "a" (&c->redDither)
- );
- }
-}
-
-static void RENAME(yuv2bgr24_2)(SwsContext *c, const int16_t *buf[2],
- const int16_t *ubuf[2], const int16_t *vbuf[2],
- const int16_t *abuf[2], uint8_t *dest,
- int dstW, int yalpha, int uvalpha, int y)
-{
- const int16_t *buf0 = buf[0], *buf1 = buf[1],
- *ubuf0 = ubuf[0], *ubuf1 = ubuf[1];
-
- //Note 8280 == DSTW_OFFSET but the preprocessor can't handle that there :(
- __asm__ volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB(%%REGBP, %5)
- "pxor %%mm7, %%mm7 \n\t"
- WRITEBGR24(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
- :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
- "a" (&c->redDither)
- );
-}
-
-static void RENAME(yuv2rgb555_2)(SwsContext *c, const int16_t *buf[2],
- const int16_t *ubuf[2], const int16_t *vbuf[2],
- const int16_t *abuf[2], uint8_t *dest,
- int dstW, int yalpha, int uvalpha, int y)
-{
- const int16_t *buf0 = buf[0], *buf1 = buf[1],
- *ubuf0 = ubuf[0], *ubuf1 = ubuf[1];
-
- //Note 8280 == DSTW_OFFSET but the preprocessor can't handle that there :(
- __asm__ volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB(%%REGBP, %5)
- "pxor %%mm7, %%mm7 \n\t"
- /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
-#ifdef DITHER1XBPP
- "paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
- "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
- "paddusb "RED_DITHER"(%5), %%mm5 \n\t"
-#endif
- WRITERGB15(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
- :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
- "a" (&c->redDither)
- );
-}
-
-static void RENAME(yuv2rgb565_2)(SwsContext *c, const int16_t *buf[2],
- const int16_t *ubuf[2], const int16_t *vbuf[2],
- const int16_t *abuf[2], uint8_t *dest,
- int dstW, int yalpha, int uvalpha, int y)
-{
- const int16_t *buf0 = buf[0], *buf1 = buf[1],
- *ubuf0 = ubuf[0], *ubuf1 = ubuf[1];
-
- //Note 8280 == DSTW_OFFSET but the preprocessor can't handle that there :(
- __asm__ volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB(%%REGBP, %5)
- "pxor %%mm7, %%mm7 \n\t"
- /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
-#ifdef DITHER1XBPP
- "paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
- "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
- "paddusb "RED_DITHER"(%5), %%mm5 \n\t"
-#endif
- WRITERGB16(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
- :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
- "a" (&c->redDither)
- );
-}
-
-#define REAL_YSCALEYUV2PACKED(index, c) \
- "movq "CHR_MMX_FILTER_OFFSET"+8("#c"), %%mm0 \n\t"\
- "movq "LUM_MMX_FILTER_OFFSET"+8("#c"), %%mm1 \n\t"\
- "psraw $3, %%mm0 \n\t"\
- "psraw $3, %%mm1 \n\t"\
- "movq %%mm0, "CHR_MMX_FILTER_OFFSET"+8("#c") \n\t"\
- "movq %%mm1, "LUM_MMX_FILTER_OFFSET"+8("#c") \n\t"\
- "xor "#index", "#index" \n\t"\
- ".p2align 4 \n\t"\
- "1: \n\t"\
- "movq (%2, "#index"), %%mm2 \n\t" /* uvbuf0[eax]*/\
- "movq (%3, "#index"), %%mm3 \n\t" /* uvbuf1[eax]*/\
- "add "UV_OFF_BYTE"("#c"), "#index" \n\t" \
- "movq (%2, "#index"), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\
- "movq (%3, "#index"), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\
- "sub "UV_OFF_BYTE"("#c"), "#index" \n\t" \
- "psubw %%mm3, %%mm2 \n\t" /* uvbuf0[eax] - uvbuf1[eax]*/\
- "psubw %%mm4, %%mm5 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048]*/\
- "movq "CHR_MMX_FILTER_OFFSET"+8("#c"), %%mm0 \n\t"\
- "pmulhw %%mm0, %%mm2 \n\t" /* (uvbuf0[eax] - uvbuf1[eax])uvalpha1>>16*/\
- "pmulhw %%mm0, %%mm5 \n\t" /* (uvbuf0[eax+2048] - uvbuf1[eax+2048])uvalpha1>>16*/\
- "psraw $7, %%mm3 \n\t" /* uvbuf0[eax] - uvbuf1[eax] >>4*/\
- "psraw $7, %%mm4 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048] >>4*/\
- "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax]uvalpha1 - uvbuf1[eax](1-uvalpha1)*/\
- "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048]uvalpha1 - uvbuf1[eax+2048](1-uvalpha1)*/\
- "movq (%0, "#index", 2), %%mm0 \n\t" /*buf0[eax]*/\
- "movq (%1, "#index", 2), %%mm1 \n\t" /*buf1[eax]*/\
- "movq 8(%0, "#index", 2), %%mm6 \n\t" /*buf0[eax]*/\
- "movq 8(%1, "#index", 2), %%mm7 \n\t" /*buf1[eax]*/\
- "psubw %%mm1, %%mm0 \n\t" /* buf0[eax] - buf1[eax]*/\
- "psubw %%mm7, %%mm6 \n\t" /* buf0[eax] - buf1[eax]*/\
- "pmulhw "LUM_MMX_FILTER_OFFSET"+8("#c"), %%mm0 \n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\
- "pmulhw "LUM_MMX_FILTER_OFFSET"+8("#c"), %%mm6 \n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\
- "psraw $7, %%mm1 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
- "psraw $7, %%mm7 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
- "paddw %%mm0, %%mm1 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\
- "paddw %%mm6, %%mm7 \n\t" /* buf0[eax]yalpha1 + buf1[eax](1-yalpha1) >>16*/\
-
-#define YSCALEYUV2PACKED(index, c) REAL_YSCALEYUV2PACKED(index, c)
-
-static void RENAME(yuv2yuyv422_2)(SwsContext *c, const int16_t *buf[2],
- const int16_t *ubuf[2], const int16_t *vbuf[2],
- const int16_t *abuf[2], uint8_t *dest,
- int dstW, int yalpha, int uvalpha, int y)
-{
- const int16_t *buf0 = buf[0], *buf1 = buf[1],
- *ubuf0 = ubuf[0], *ubuf1 = ubuf[1];
-
- //Note 8280 == DSTW_OFFSET but the preprocessor can't handle that there :(
- __asm__ volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2PACKED(%%REGBP, %5)
- WRITEYUY2(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
- :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
- "a" (&c->redDither)
- );
-}
-
-#define REAL_YSCALEYUV2RGB1(index, c) \
- "xor "#index", "#index" \n\t"\
- ".p2align 4 \n\t"\
- "1: \n\t"\
- "movq (%2, "#index"), %%mm3 \n\t" /* uvbuf0[eax]*/\
- "add "UV_OFF_BYTE"("#c"), "#index" \n\t" \
- "movq (%2, "#index"), %%mm4 \n\t" /* uvbuf0[eax+2048]*/\
- "sub "UV_OFF_BYTE"("#c"), "#index" \n\t" \
- "psraw $4, %%mm3 \n\t" /* uvbuf0[eax] - uvbuf1[eax] >>4*/\
- "psraw $4, %%mm4 \n\t" /* uvbuf0[eax+2048] - uvbuf1[eax+2048] >>4*/\
- "psubw "U_OFFSET"("#c"), %%mm3 \n\t" /* (U-128)8*/\
- "psubw "V_OFFSET"("#c"), %%mm4 \n\t" /* (V-128)8*/\
- "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\
- "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\
- "pmulhw "UG_COEFF"("#c"), %%mm3 \n\t"\
- "pmulhw "VG_COEFF"("#c"), %%mm4 \n\t"\
- /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\
- "movq (%0, "#index", 2), %%mm1 \n\t" /*buf0[eax]*/\
- "movq 8(%0, "#index", 2), %%mm7 \n\t" /*buf0[eax]*/\
- "psraw $4, %%mm1 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
- "psraw $4, %%mm7 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
- "pmulhw "UB_COEFF"("#c"), %%mm2 \n\t"\
- "pmulhw "VR_COEFF"("#c"), %%mm5 \n\t"\
- "psubw "Y_OFFSET"("#c"), %%mm1 \n\t" /* 8(Y-16)*/\
- "psubw "Y_OFFSET"("#c"), %%mm7 \n\t" /* 8(Y-16)*/\
- "pmulhw "Y_COEFF"("#c"), %%mm1 \n\t"\
- "pmulhw "Y_COEFF"("#c"), %%mm7 \n\t"\
- /* mm1= Y1, mm2=ub, mm3=ug, mm4=vg mm5=vr, mm7=Y2 */\
- "paddw %%mm3, %%mm4 \n\t"\
- "movq %%mm2, %%mm0 \n\t"\
- "movq %%mm5, %%mm6 \n\t"\
- "movq %%mm4, %%mm3 \n\t"\
- "punpcklwd %%mm2, %%mm2 \n\t"\
- "punpcklwd %%mm5, %%mm5 \n\t"\
- "punpcklwd %%mm4, %%mm4 \n\t"\
- "paddw %%mm1, %%mm2 \n\t"\
- "paddw %%mm1, %%mm5 \n\t"\
- "paddw %%mm1, %%mm4 \n\t"\
- "punpckhwd %%mm0, %%mm0 \n\t"\
- "punpckhwd %%mm6, %%mm6 \n\t"\
- "punpckhwd %%mm3, %%mm3 \n\t"\
- "paddw %%mm7, %%mm0 \n\t"\
- "paddw %%mm7, %%mm6 \n\t"\
- "paddw %%mm7, %%mm3 \n\t"\
- /* mm0=B1, mm2=B2, mm3=G2, mm4=G1, mm5=R1, mm6=R2 */\
- "packuswb %%mm0, %%mm2 \n\t"\
- "packuswb %%mm6, %%mm5 \n\t"\
- "packuswb %%mm3, %%mm4 \n\t"\
-
-#define YSCALEYUV2RGB1(index, c) REAL_YSCALEYUV2RGB1(index, c)
-
-// do vertical chrominance interpolation
-#define REAL_YSCALEYUV2RGB1b(index, c) \
- "xor "#index", "#index" \n\t"\
- ".p2align 4 \n\t"\
- "1: \n\t"\
- "movq (%2, "#index"), %%mm2 \n\t" /* uvbuf0[eax]*/\
- "movq (%3, "#index"), %%mm3 \n\t" /* uvbuf1[eax]*/\
- "add "UV_OFF_BYTE"("#c"), "#index" \n\t" \
- "movq (%2, "#index"), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\
- "movq (%3, "#index"), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\
- "sub "UV_OFF_BYTE"("#c"), "#index" \n\t" \
- "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax] + uvbuf1[eax]*/\
- "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048] + uvbuf1[eax+2048]*/\
- "psrlw $5, %%mm3 \n\t" /*FIXME might overflow*/\
- "psrlw $5, %%mm4 \n\t" /*FIXME might overflow*/\
- "psubw "U_OFFSET"("#c"), %%mm3 \n\t" /* (U-128)8*/\
- "psubw "V_OFFSET"("#c"), %%mm4 \n\t" /* (V-128)8*/\
- "movq %%mm3, %%mm2 \n\t" /* (U-128)8*/\
- "movq %%mm4, %%mm5 \n\t" /* (V-128)8*/\
- "pmulhw "UG_COEFF"("#c"), %%mm3 \n\t"\
- "pmulhw "VG_COEFF"("#c"), %%mm4 \n\t"\
- /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\
- "movq (%0, "#index", 2), %%mm1 \n\t" /*buf0[eax]*/\
- "movq 8(%0, "#index", 2), %%mm7 \n\t" /*buf0[eax]*/\
- "psraw $4, %%mm1 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
- "psraw $4, %%mm7 \n\t" /* buf0[eax] - buf1[eax] >>4*/\
- "pmulhw "UB_COEFF"("#c"), %%mm2 \n\t"\
- "pmulhw "VR_COEFF"("#c"), %%mm5 \n\t"\
- "psubw "Y_OFFSET"("#c"), %%mm1 \n\t" /* 8(Y-16)*/\
- "psubw "Y_OFFSET"("#c"), %%mm7 \n\t" /* 8(Y-16)*/\
- "pmulhw "Y_COEFF"("#c"), %%mm1 \n\t"\
- "pmulhw "Y_COEFF"("#c"), %%mm7 \n\t"\
- /* mm1= Y1, mm2=ub, mm3=ug, mm4=vg mm5=vr, mm7=Y2 */\
- "paddw %%mm3, %%mm4 \n\t"\
- "movq %%mm2, %%mm0 \n\t"\
- "movq %%mm5, %%mm6 \n\t"\
- "movq %%mm4, %%mm3 \n\t"\
- "punpcklwd %%mm2, %%mm2 \n\t"\
- "punpcklwd %%mm5, %%mm5 \n\t"\
- "punpcklwd %%mm4, %%mm4 \n\t"\
- "paddw %%mm1, %%mm2 \n\t"\
- "paddw %%mm1, %%mm5 \n\t"\
- "paddw %%mm1, %%mm4 \n\t"\
- "punpckhwd %%mm0, %%mm0 \n\t"\
- "punpckhwd %%mm6, %%mm6 \n\t"\
- "punpckhwd %%mm3, %%mm3 \n\t"\
- "paddw %%mm7, %%mm0 \n\t"\
- "paddw %%mm7, %%mm6 \n\t"\
- "paddw %%mm7, %%mm3 \n\t"\
- /* mm0=B1, mm2=B2, mm3=G2, mm4=G1, mm5=R1, mm6=R2 */\
- "packuswb %%mm0, %%mm2 \n\t"\
- "packuswb %%mm6, %%mm5 \n\t"\
- "packuswb %%mm3, %%mm4 \n\t"\
-
-#define YSCALEYUV2RGB1b(index, c) REAL_YSCALEYUV2RGB1b(index, c)
-
-#define REAL_YSCALEYUV2RGB1_ALPHA(index) \
- "movq (%1, "#index", 2), %%mm7 \n\t" /* abuf0[index ] */\
- "movq 8(%1, "#index", 2), %%mm1 \n\t" /* abuf0[index+4] */\
- "psraw $7, %%mm7 \n\t" /* abuf0[index ] >>7 */\
- "psraw $7, %%mm1 \n\t" /* abuf0[index+4] >>7 */\
- "packuswb %%mm1, %%mm7 \n\t"
-#define YSCALEYUV2RGB1_ALPHA(index) REAL_YSCALEYUV2RGB1_ALPHA(index)
-
-/**
- * YV12 to RGB without scaling or interpolating
- */
-static void RENAME(yuv2rgb32_1)(SwsContext *c, const int16_t *buf0,
- const int16_t *ubuf[2], const int16_t *vbuf[2],
- const int16_t *abuf0, uint8_t *dest,
- int dstW, int uvalpha, int y)
-{
- const int16_t *ubuf0 = ubuf[0];
- const int16_t *buf1= buf0; //FIXME needed for RGB1/BGR1
-
- if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster
- const int16_t *ubuf1 = ubuf[0];
- if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) {
- __asm__ volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB1(%%REGBP, %5)
- YSCALEYUV2RGB1_ALPHA(%%REGBP)
- WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
- :: "c" (buf0), "d" (abuf0), "S" (ubuf0), "D" (ubuf1), "m" (dest),
- "a" (&c->redDither)
- );
- } else {
- __asm__ volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB1(%%REGBP, %5)
- "pcmpeqd %%mm7, %%mm7 \n\t"
- WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
- :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
- "a" (&c->redDither)
- );
- }
- } else {
- const int16_t *ubuf1 = ubuf[1];
- if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) {
- __asm__ volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB1b(%%REGBP, %5)
- YSCALEYUV2RGB1_ALPHA(%%REGBP)
- WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
- :: "c" (buf0), "d" (abuf0), "S" (ubuf0), "D" (ubuf1), "m" (dest),
- "a" (&c->redDither)
- );
- } else {
- __asm__ volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB1b(%%REGBP, %5)
- "pcmpeqd %%mm7, %%mm7 \n\t"
- WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
- :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
- "a" (&c->redDither)
- );
- }
- }
-}
-
-static void RENAME(yuv2bgr24_1)(SwsContext *c, const int16_t *buf0,
- const int16_t *ubuf[2], const int16_t *vbuf[2],
- const int16_t *abuf0, uint8_t *dest,
- int dstW, int uvalpha, int y)
-{
- const int16_t *ubuf0 = ubuf[0];
- const int16_t *buf1= buf0; //FIXME needed for RGB1/BGR1
-
- if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster
- const int16_t *ubuf1 = ubuf[0];
- __asm__ volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB1(%%REGBP, %5)
- "pxor %%mm7, %%mm7 \n\t"
- WRITEBGR24(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
- :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
- "a" (&c->redDither)
- );
- } else {
- const int16_t *ubuf1 = ubuf[1];
- __asm__ volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB1b(%%REGBP, %5)
- "pxor %%mm7, %%mm7 \n\t"
- WRITEBGR24(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
- :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
- "a" (&c->redDither)
- );
- }
-}
-
-static void RENAME(yuv2rgb555_1)(SwsContext *c, const int16_t *buf0,
- const int16_t *ubuf[2], const int16_t *vbuf[2],
- const int16_t *abuf0, uint8_t *dest,
- int dstW, int uvalpha, int y)
-{
- const int16_t *ubuf0 = ubuf[0];
- const int16_t *buf1= buf0; //FIXME needed for RGB1/BGR1
-
- if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster
- const int16_t *ubuf1 = ubuf[0];
- __asm__ volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB1(%%REGBP, %5)
- "pxor %%mm7, %%mm7 \n\t"
- /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
-#ifdef DITHER1XBPP
- "paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
- "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
- "paddusb "RED_DITHER"(%5), %%mm5 \n\t"
-#endif
- WRITERGB15(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
- :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
- "a" (&c->redDither)
- );
- } else {
- const int16_t *ubuf1 = ubuf[1];
- __asm__ volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB1b(%%REGBP, %5)
- "pxor %%mm7, %%mm7 \n\t"
- /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
-#ifdef DITHER1XBPP
- "paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
- "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
- "paddusb "RED_DITHER"(%5), %%mm5 \n\t"
-#endif
- WRITERGB15(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
- :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
- "a" (&c->redDither)
- );
- }
-}
-
-static void RENAME(yuv2rgb565_1)(SwsContext *c, const int16_t *buf0,
- const int16_t *ubuf[2], const int16_t *vbuf[2],
- const int16_t *abuf0, uint8_t *dest,
- int dstW, int uvalpha, int y)
-{
- const int16_t *ubuf0 = ubuf[0];
- const int16_t *buf1= buf0; //FIXME needed for RGB1/BGR1
-
- if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster
- const int16_t *ubuf1 = ubuf[0];
- __asm__ volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB1(%%REGBP, %5)
- "pxor %%mm7, %%mm7 \n\t"
- /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
-#ifdef DITHER1XBPP
- "paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
- "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
- "paddusb "RED_DITHER"(%5), %%mm5 \n\t"
-#endif
- WRITERGB16(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
- :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
- "a" (&c->redDither)
- );
- } else {
- const int16_t *ubuf1 = ubuf[1];
- __asm__ volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2RGB1b(%%REGBP, %5)
- "pxor %%mm7, %%mm7 \n\t"
- /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */
-#ifdef DITHER1XBPP
- "paddusb "BLUE_DITHER"(%5), %%mm2 \n\t"
- "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t"
- "paddusb "RED_DITHER"(%5), %%mm5 \n\t"
-#endif
- WRITERGB16(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
- :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
- "a" (&c->redDither)
- );
- }
-}
-
-#define REAL_YSCALEYUV2PACKED1(index, c) \
- "xor "#index", "#index" \n\t"\
- ".p2align 4 \n\t"\
- "1: \n\t"\
- "movq (%2, "#index"), %%mm3 \n\t" /* uvbuf0[eax]*/\
- "add "UV_OFF_BYTE"("#c"), "#index" \n\t" \
- "movq (%2, "#index"), %%mm4 \n\t" /* uvbuf0[eax+2048]*/\
- "sub "UV_OFF_BYTE"("#c"), "#index" \n\t" \
- "psraw $7, %%mm3 \n\t" \
- "psraw $7, %%mm4 \n\t" \
- "movq (%0, "#index", 2), %%mm1 \n\t" /*buf0[eax]*/\
- "movq 8(%0, "#index", 2), %%mm7 \n\t" /*buf0[eax]*/\
- "psraw $7, %%mm1 \n\t" \
- "psraw $7, %%mm7 \n\t" \
-
-#define YSCALEYUV2PACKED1(index, c) REAL_YSCALEYUV2PACKED1(index, c)
-
-#define REAL_YSCALEYUV2PACKED1b(index, c) \
- "xor "#index", "#index" \n\t"\
- ".p2align 4 \n\t"\
- "1: \n\t"\
- "movq (%2, "#index"), %%mm2 \n\t" /* uvbuf0[eax]*/\
- "movq (%3, "#index"), %%mm3 \n\t" /* uvbuf1[eax]*/\
- "add "UV_OFF_BYTE"("#c"), "#index" \n\t" \
- "movq (%2, "#index"), %%mm5 \n\t" /* uvbuf0[eax+2048]*/\
- "movq (%3, "#index"), %%mm4 \n\t" /* uvbuf1[eax+2048]*/\
- "sub "UV_OFF_BYTE"("#c"), "#index" \n\t" \
- "paddw %%mm2, %%mm3 \n\t" /* uvbuf0[eax] + uvbuf1[eax]*/\
- "paddw %%mm5, %%mm4 \n\t" /* uvbuf0[eax+2048] + uvbuf1[eax+2048]*/\
- "psrlw $8, %%mm3 \n\t" \
- "psrlw $8, %%mm4 \n\t" \
- "movq (%0, "#index", 2), %%mm1 \n\t" /*buf0[eax]*/\
- "movq 8(%0, "#index", 2), %%mm7 \n\t" /*buf0[eax]*/\
- "psraw $7, %%mm1 \n\t" \
- "psraw $7, %%mm7 \n\t"
-#define YSCALEYUV2PACKED1b(index, c) REAL_YSCALEYUV2PACKED1b(index, c)
-
-static void RENAME(yuv2yuyv422_1)(SwsContext *c, const int16_t *buf0,
- const int16_t *ubuf[2], const int16_t *vbuf[2],
- const int16_t *abuf0, uint8_t *dest,
- int dstW, int uvalpha, int y)
-{
- const int16_t *ubuf0 = ubuf[0];
- const int16_t *buf1= buf0; //FIXME needed for RGB1/BGR1
-
- if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster
- const int16_t *ubuf1 = ubuf[0];
- __asm__ volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2PACKED1(%%REGBP, %5)
- WRITEYUY2(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
- :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
- "a" (&c->redDither)
- );
- } else {
- const int16_t *ubuf1 = ubuf[1];
- __asm__ volatile(
- "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t"
- "mov %4, %%"REG_b" \n\t"
- "push %%"REG_BP" \n\t"
- YSCALEYUV2PACKED1b(%%REGBP, %5)
- WRITEYUY2(%%REGb, 8280(%5), %%REGBP)
- "pop %%"REG_BP" \n\t"
- "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t"
- :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest),
- "a" (&c->redDither)
- );
- }
-}
-
-#if COMPILE_TEMPLATE_MMXEXT
-static void RENAME(hyscale_fast)(SwsContext *c, int16_t *dst,
- int dstWidth, const uint8_t *src,
- int srcW, int xInc)
-{
- int32_t *filterPos = c->hLumFilterPos;
- int16_t *filter = c->hLumFilter;
- void *mmxextFilterCode = c->lumMmxextFilterCode;
- int i;
-#if defined(PIC)
- uint64_t ebxsave;
-#endif
-#if ARCH_X86_64
- uint64_t retsave;
-#endif
-
- __asm__ volatile(
-#if defined(PIC)
- "mov %%"REG_b", %5 \n\t"
-#if ARCH_X86_64
- "mov -8(%%rsp), %%"REG_a" \n\t"
- "mov %%"REG_a", %6 \n\t"
-#endif
-#else
-#if ARCH_X86_64
- "mov -8(%%rsp), %%"REG_a" \n\t"
- "mov %%"REG_a", %5 \n\t"
-#endif
-#endif
- "pxor %%mm7, %%mm7 \n\t"
- "mov %0, %%"REG_c" \n\t"
- "mov %1, %%"REG_D" \n\t"
- "mov %2, %%"REG_d" \n\t"
- "mov %3, %%"REG_b" \n\t"
- "xor %%"REG_a", %%"REG_a" \n\t" // i
- PREFETCH" (%%"REG_c") \n\t"
- PREFETCH" 32(%%"REG_c") \n\t"
- PREFETCH" 64(%%"REG_c") \n\t"
-
-#if ARCH_X86_64
-#define CALL_MMXEXT_FILTER_CODE \
- "movl (%%"REG_b"), %%esi \n\t"\
- "call *%4 \n\t"\
- "movl (%%"REG_b", %%"REG_a"), %%esi \n\t"\
- "add %%"REG_S", %%"REG_c" \n\t"\
- "add %%"REG_a", %%"REG_D" \n\t"\
- "xor %%"REG_a", %%"REG_a" \n\t"\
-
-#else
-#define CALL_MMXEXT_FILTER_CODE \
- "movl (%%"REG_b"), %%esi \n\t"\
- "call *%4 \n\t"\
- "addl (%%"REG_b", %%"REG_a"), %%"REG_c" \n\t"\
- "add %%"REG_a", %%"REG_D" \n\t"\
- "xor %%"REG_a", %%"REG_a" \n\t"\
-
-#endif /* ARCH_X86_64 */
-
- CALL_MMXEXT_FILTER_CODE
- CALL_MMXEXT_FILTER_CODE
- CALL_MMXEXT_FILTER_CODE
- CALL_MMXEXT_FILTER_CODE
- CALL_MMXEXT_FILTER_CODE
- CALL_MMXEXT_FILTER_CODE
- CALL_MMXEXT_FILTER_CODE
- CALL_MMXEXT_FILTER_CODE
-
-#if defined(PIC)
- "mov %5, %%"REG_b" \n\t"
-#if ARCH_X86_64
- "mov %6, %%"REG_a" \n\t"
- "mov %%"REG_a", -8(%%rsp) \n\t"
-#endif
-#else
-#if ARCH_X86_64
- "mov %5, %%"REG_a" \n\t"
- "mov %%"REG_a", -8(%%rsp) \n\t"
-#endif
-#endif
- :: "m" (src), "m" (dst), "m" (filter), "m" (filterPos),
- "m" (mmxextFilterCode)
-#if defined(PIC)
- ,"m" (ebxsave)
-#endif
-#if ARCH_X86_64
- ,"m"(retsave)
-#endif
- : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
-#if !defined(PIC)
- ,"%"REG_b
-#endif
- );
-
- for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--)
- dst[i] = src[srcW-1]*128;
-}
-
-static void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst1, int16_t *dst2,
- int dstWidth, const uint8_t *src1,
- const uint8_t *src2, int srcW, int xInc)
-{
- int32_t *filterPos = c->hChrFilterPos;
- int16_t *filter = c->hChrFilter;
- void *mmxextFilterCode = c->chrMmxextFilterCode;
- int i;
-#if defined(PIC)
- DECLARE_ALIGNED(8, uint64_t, ebxsave);
-#endif
-#if ARCH_X86_64
- DECLARE_ALIGNED(8, uint64_t, retsave);
-#endif
-
- __asm__ volatile(
-#if defined(PIC)
- "mov %%"REG_b", %7 \n\t"
-#if ARCH_X86_64
- "mov -8(%%rsp), %%"REG_a" \n\t"
- "mov %%"REG_a", %8 \n\t"
-#endif
-#else
-#if ARCH_X86_64
- "mov -8(%%rsp), %%"REG_a" \n\t"
- "mov %%"REG_a", %7 \n\t"
-#endif
-#endif
- "pxor %%mm7, %%mm7 \n\t"
- "mov %0, %%"REG_c" \n\t"
- "mov %1, %%"REG_D" \n\t"
- "mov %2, %%"REG_d" \n\t"
- "mov %3, %%"REG_b" \n\t"
- "xor %%"REG_a", %%"REG_a" \n\t" // i
- PREFETCH" (%%"REG_c") \n\t"
- PREFETCH" 32(%%"REG_c") \n\t"
- PREFETCH" 64(%%"REG_c") \n\t"
-
- CALL_MMXEXT_FILTER_CODE
- CALL_MMXEXT_FILTER_CODE
- CALL_MMXEXT_FILTER_CODE
- CALL_MMXEXT_FILTER_CODE
- "xor %%"REG_a", %%"REG_a" \n\t" // i
- "mov %5, %%"REG_c" \n\t" // src
- "mov %6, %%"REG_D" \n\t" // buf2
- PREFETCH" (%%"REG_c") \n\t"
- PREFETCH" 32(%%"REG_c") \n\t"
- PREFETCH" 64(%%"REG_c") \n\t"
-
- CALL_MMXEXT_FILTER_CODE
- CALL_MMXEXT_FILTER_CODE
- CALL_MMXEXT_FILTER_CODE
- CALL_MMXEXT_FILTER_CODE
-
-#if defined(PIC)
- "mov %7, %%"REG_b" \n\t"
-#if ARCH_X86_64
- "mov %8, %%"REG_a" \n\t"
- "mov %%"REG_a", -8(%%rsp) \n\t"
-#endif
-#else
-#if ARCH_X86_64
- "mov %7, %%"REG_a" \n\t"
- "mov %%"REG_a", -8(%%rsp) \n\t"
-#endif
-#endif
- :: "m" (src1), "m" (dst1), "m" (filter), "m" (filterPos),
- "m" (mmxextFilterCode), "m" (src2), "m"(dst2)
-#if defined(PIC)
- ,"m" (ebxsave)
-#endif
-#if ARCH_X86_64
- ,"m"(retsave)
-#endif
- : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
-#if !defined(PIC)
- ,"%"REG_b
-#endif
- );
-
- for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) {
- dst1[i] = src1[srcW-1]*128;
- dst2[i] = src2[srcW-1]*128;
- }
-}
-#endif /* COMPILE_TEMPLATE_MMXEXT */
-
-static av_cold void RENAME(sws_init_swScale)(SwsContext *c)
-{
- enum AVPixelFormat dstFormat = c->dstFormat;
-
- c->use_mmx_vfilter= 0;
- if (!is16BPS(dstFormat) && !is9_OR_10BPS(dstFormat) && dstFormat != AV_PIX_FMT_NV12
- && dstFormat != AV_PIX_FMT_NV21 && !(c->flags & SWS_BITEXACT)) {
- if (c->flags & SWS_ACCURATE_RND) {
- if (!(c->flags & SWS_FULL_CHR_H_INT)) {
- switch (c->dstFormat) {
- case AV_PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X_ar); break;
- case AV_PIX_FMT_BGR24: c->yuv2packedX = RENAME(yuv2bgr24_X_ar); break;
- case AV_PIX_FMT_RGB555: c->yuv2packedX = RENAME(yuv2rgb555_X_ar); break;
- case AV_PIX_FMT_RGB565: c->yuv2packedX = RENAME(yuv2rgb565_X_ar); break;
- case AV_PIX_FMT_YUYV422: c->yuv2packedX = RENAME(yuv2yuyv422_X_ar); break;
- default: break;
- }
- }
- } else {
- c->use_mmx_vfilter= 1;
- c->yuv2planeX = RENAME(yuv2yuvX );
- if (!(c->flags & SWS_FULL_CHR_H_INT)) {
- switch (c->dstFormat) {
- case AV_PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X); break;
- case AV_PIX_FMT_BGR24: c->yuv2packedX = RENAME(yuv2bgr24_X); break;
- case AV_PIX_FMT_RGB555: c->yuv2packedX = RENAME(yuv2rgb555_X); break;
- case AV_PIX_FMT_RGB565: c->yuv2packedX = RENAME(yuv2rgb565_X); break;
- case AV_PIX_FMT_YUYV422: c->yuv2packedX = RENAME(yuv2yuyv422_X); break;
- default: break;
- }
- }
- }
- if (!(c->flags & SWS_FULL_CHR_H_INT)) {
- switch (c->dstFormat) {
- case AV_PIX_FMT_RGB32:
- c->yuv2packed1 = RENAME(yuv2rgb32_1);
- c->yuv2packed2 = RENAME(yuv2rgb32_2);
- break;
- case AV_PIX_FMT_BGR24:
- c->yuv2packed1 = RENAME(yuv2bgr24_1);
- c->yuv2packed2 = RENAME(yuv2bgr24_2);
- break;
- case AV_PIX_FMT_RGB555:
- c->yuv2packed1 = RENAME(yuv2rgb555_1);
- c->yuv2packed2 = RENAME(yuv2rgb555_2);
- break;
- case AV_PIX_FMT_RGB565:
- c->yuv2packed1 = RENAME(yuv2rgb565_1);
- c->yuv2packed2 = RENAME(yuv2rgb565_2);
- break;
- case AV_PIX_FMT_YUYV422:
- c->yuv2packed1 = RENAME(yuv2yuyv422_1);
- c->yuv2packed2 = RENAME(yuv2yuyv422_2);
- break;
- default:
- break;
- }
- }
- }
-
- if (c->srcBpc == 8 && c->dstBpc <= 14) {
- // Use the new MMX scaler if the MMXEXT one can't be used (it is faster than the x86 ASM one).
-#if COMPILE_TEMPLATE_MMXEXT
- if (c->flags & SWS_FAST_BILINEAR && c->canMMXEXTBeUsed) {
- c->hyscale_fast = RENAME(hyscale_fast);
- c->hcscale_fast = RENAME(hcscale_fast);
- } else {
-#endif /* COMPILE_TEMPLATE_MMXEXT */
- c->hyscale_fast = NULL;
- c->hcscale_fast = NULL;
-#if COMPILE_TEMPLATE_MMXEXT
- }
-#endif /* COMPILE_TEMPLATE_MMXEXT */
- }
-}
diff --git a/src/thirdparty/ffmpeg/libswscale/x86/yuv2rgb.c b/src/thirdparty/ffmpeg/libswscale/x86/yuv2rgb.c
deleted file mode 100644
index 3938e6bae..000000000
--- a/src/thirdparty/ffmpeg/libswscale/x86/yuv2rgb.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * software YUV to RGB converter
- *
- * Copyright (C) 2009 Konstantin Shishkov
- *
- * MMX/MMXEXT template stuff (needed for fast movntq support),
- * 1,4,8bpp support and context / deglobalize stuff
- * 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
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <inttypes.h>
-#include <assert.h>
-
-#include "config.h"
-#include "libswscale/rgb2rgb.h"
-#include "libswscale/swscale.h"
-#include "libswscale/swscale_internal.h"
-#include "libavutil/attributes.h"
-#include "libavutil/x86/asm.h"
-#include "libavutil/cpu.h"
-
-#if HAVE_INLINE_ASM
-
-#define DITHER1XBPP // only for MMX
-
-/* hope these constant values are cache line aligned */
-DECLARE_ASM_CONST(8, uint64_t, mmx_00ffw) = 0x00ff00ff00ff00ffULL;
-DECLARE_ASM_CONST(8, uint64_t, mmx_redmask) = 0xf8f8f8f8f8f8f8f8ULL;
-DECLARE_ASM_CONST(8, uint64_t, mmx_grnmask) = 0xfcfcfcfcfcfcfcfcULL;
-DECLARE_ASM_CONST(8, uint64_t, pb_e0) = 0xe0e0e0e0e0e0e0e0ULL;
-DECLARE_ASM_CONST(8, uint64_t, pb_03) = 0x0303030303030303ULL;
-DECLARE_ASM_CONST(8, uint64_t, pb_07) = 0x0707070707070707ULL;
-
-//MMX versions
-#if HAVE_MMX_INLINE
-#undef RENAME
-#undef COMPILE_TEMPLATE_MMXEXT
-#define COMPILE_TEMPLATE_MMXEXT 0
-#define RENAME(a) a ## _MMX
-#include "yuv2rgb_template.c"
-#endif /* HAVE_MMX_INLINE */
-
-// MMXEXT versions
-#if HAVE_MMXEXT_INLINE
-#undef RENAME
-#undef COMPILE_TEMPLATE_MMXEXT
-#define COMPILE_TEMPLATE_MMXEXT 1
-#define RENAME(a) a ## _MMXEXT
-#include "yuv2rgb_template.c"
-#endif /* HAVE_MMXEXT_INLINE */
-
-#endif /* HAVE_INLINE_ASM */
-
-av_cold SwsFunc ff_yuv2rgb_init_mmx(SwsContext *c)
-{
-#if HAVE_INLINE_ASM
- int cpu_flags = av_get_cpu_flags();
-
-#if HAVE_MMXEXT_INLINE
- if (cpu_flags & AV_CPU_FLAG_MMXEXT) {
- switch (c->dstFormat) {
- case AV_PIX_FMT_RGB24:
- return yuv420_rgb24_MMXEXT;
- case AV_PIX_FMT_BGR24:
- return yuv420_bgr24_MMXEXT;
- }
- }
-#endif
-
- if (cpu_flags & AV_CPU_FLAG_MMX) {
- switch (c->dstFormat) {
- case AV_PIX_FMT_RGB32:
- if (c->srcFormat == AV_PIX_FMT_YUVA420P) {
-#if HAVE_7REGS && CONFIG_SWSCALE_ALPHA
- return yuva420_rgb32_MMX;
-#endif
- break;
- } else return yuv420_rgb32_MMX;
- case AV_PIX_FMT_BGR32:
- if (c->srcFormat == AV_PIX_FMT_YUVA420P) {
-#if HAVE_7REGS && CONFIG_SWSCALE_ALPHA
- return yuva420_bgr32_MMX;
-#endif
- break;
- } else return yuv420_bgr32_MMX;
- case AV_PIX_FMT_RGB24: return yuv420_rgb24_MMX;
- case AV_PIX_FMT_BGR24: return yuv420_bgr24_MMX;
- case AV_PIX_FMT_RGB565: return yuv420_rgb16_MMX;
- case AV_PIX_FMT_RGB555: return yuv420_rgb15_MMX;
- }
- }
-#endif /* HAVE_INLINE_ASM */
-
- return NULL;
-}
diff --git a/src/thirdparty/ffmpeg/libswscale/x86/yuv2rgb_template.c b/src/thirdparty/ffmpeg/libswscale/x86/yuv2rgb_template.c
deleted file mode 100644
index 38bdc165c..000000000
--- a/src/thirdparty/ffmpeg/libswscale/x86/yuv2rgb_template.c
+++ /dev/null
@@ -1,451 +0,0 @@
-/*
- * software YUV to RGB converter
- *
- * Copyright (C) 2001-2007 Michael Niedermayer
- * (c) 2010 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
- */
-
-#undef MOVNTQ
-#undef EMMS
-#undef SFENCE
-
-#if COMPILE_TEMPLATE_MMXEXT
-#define MOVNTQ "movntq"
-#define SFENCE "sfence"
-#else
-#define MOVNTQ "movq"
-#define SFENCE " # nop"
-#endif
-
-#define REG_BLUE "0"
-#define REG_RED "1"
-#define REG_GREEN "2"
-#define REG_ALPHA "3"
-
-#define YUV2RGB_LOOP(depth) \
- h_size = (c->dstW + 7) & ~7; \
- if (h_size * depth > FFABS(dstStride[0])) \
- h_size -= 8; \
- \
- vshift = c->srcFormat != AV_PIX_FMT_YUV422P; \
- \
- __asm__ volatile ("pxor %mm4, %mm4\n\t"); \
- for (y = 0; y < srcSliceH; y++) { \
- uint8_t *image = dst[0] + (y + srcSliceY) * dstStride[0]; \
- const uint8_t *py = src[0] + y * srcStride[0]; \
- const uint8_t *pu = src[1] + (y >> vshift) * srcStride[1]; \
- const uint8_t *pv = src[2] + (y >> vshift) * srcStride[2]; \
- x86_reg index = -h_size / 2; \
-
-#define YUV2RGB_INITIAL_LOAD \
- __asm__ volatile ( \
- "movq (%5, %0, 2), %%mm6\n\t" \
- "movd (%2, %0), %%mm0\n\t" \
- "movd (%3, %0), %%mm1\n\t" \
- "1: \n\t" \
-
-/* YUV2RGB core
- * Conversion is performed in usual way:
- * R = Y' * Ycoef + Vred * V'
- * G = Y' * Ycoef + Vgreen * V' + Ugreen * U'
- * B = Y' * Ycoef + Ublue * U'
- *
- * where X' = X * 8 - Xoffset (multiplication is performed to increase
- * precision a bit).
- * Since it operates in YUV420 colorspace, Y component is additionally
- * split into Y1 and Y2 for even and odd pixels.
- *
- * Input:
- * mm0 - U (4 elems), mm1 - V (4 elems), mm6 - Y (8 elems), mm4 - zero register
- * Output:
- * mm1 - R, mm2 - G, mm0 - B
- */
-#define YUV2RGB \
- /* convert Y, U, V into Y1', Y2', U', V' */ \
- "movq %%mm6, %%mm7\n\t" \
- "punpcklbw %%mm4, %%mm0\n\t" \
- "punpcklbw %%mm4, %%mm1\n\t" \
- "pand "MANGLE(mmx_00ffw)", %%mm6\n\t" \
- "psrlw $8, %%mm7\n\t" \
- "psllw $3, %%mm0\n\t" \
- "psllw $3, %%mm1\n\t" \
- "psllw $3, %%mm6\n\t" \
- "psllw $3, %%mm7\n\t" \
- "psubsw "U_OFFSET"(%4), %%mm0\n\t" \
- "psubsw "V_OFFSET"(%4), %%mm1\n\t" \
- "psubw "Y_OFFSET"(%4), %%mm6\n\t" \
- "psubw "Y_OFFSET"(%4), %%mm7\n\t" \
-\
- /* multiply by coefficients */ \
- "movq %%mm0, %%mm2\n\t" \
- "movq %%mm1, %%mm3\n\t" \
- "pmulhw "UG_COEFF"(%4), %%mm2\n\t" \
- "pmulhw "VG_COEFF"(%4), %%mm3\n\t" \
- "pmulhw "Y_COEFF" (%4), %%mm6\n\t" \
- "pmulhw "Y_COEFF" (%4), %%mm7\n\t" \
- "pmulhw "UB_COEFF"(%4), %%mm0\n\t" \
- "pmulhw "VR_COEFF"(%4), %%mm1\n\t" \
- "paddsw %%mm3, %%mm2\n\t" \
- /* now: mm0 = UB, mm1 = VR, mm2 = CG */ \
- /* mm6 = Y1, mm7 = Y2 */ \
-\
- /* produce RGB */ \
- "movq %%mm7, %%mm3\n\t" \
- "movq %%mm7, %%mm5\n\t" \
- "paddsw %%mm0, %%mm3\n\t" \
- "paddsw %%mm1, %%mm5\n\t" \
- "paddsw %%mm2, %%mm7\n\t" \
- "paddsw %%mm6, %%mm0\n\t" \
- "paddsw %%mm6, %%mm1\n\t" \
- "paddsw %%mm6, %%mm2\n\t" \
-
-#define RGB_PACK_INTERLEAVE \
- /* pack and interleave even/odd pixels */ \
- "packuswb %%mm1, %%mm0\n\t" \
- "packuswb %%mm5, %%mm3\n\t" \
- "packuswb %%mm2, %%mm2\n\t" \
- "movq %%mm0, %%mm1\n\n" \
- "packuswb %%mm7, %%mm7\n\t" \
- "punpcklbw %%mm3, %%mm0\n\t" \
- "punpckhbw %%mm3, %%mm1\n\t" \
- "punpcklbw %%mm7, %%mm2\n\t" \
-
-#define YUV2RGB_ENDLOOP(depth) \
- "movq 8 (%5, %0, 2), %%mm6\n\t" \
- "movd 4 (%3, %0), %%mm1\n\t" \
- "movd 4 (%2, %0), %%mm0\n\t" \
- "add $"AV_STRINGIFY(depth * 8)", %1\n\t" \
- "add $4, %0\n\t" \
- "js 1b\n\t" \
-
-#define YUV2RGB_OPERANDS \
- : "+r" (index), "+r" (image) \
- : "r" (pu - index), "r" (pv - index), "r"(&c->redDither), \
- "r" (py - 2*index) \
- : "memory" \
- ); \
- } \
-
-#define YUV2RGB_OPERANDS_ALPHA \
- : "+r" (index), "+r" (image) \
- : "r" (pu - index), "r" (pv - index), "r"(&c->redDither), \
- "r" (py - 2*index), "r" (pa - 2*index) \
- : "memory" \
- ); \
- } \
-
-#define YUV2RGB_ENDFUNC \
- __asm__ volatile (SFENCE"\n\t" \
- "emms \n\t"); \
- return srcSliceH; \
-
-#define IF0(x)
-#define IF1(x) x
-
-#define RGB_PACK16(gmask, is15) \
- "pand "MANGLE(mmx_redmask)", %%mm0\n\t" \
- "pand "MANGLE(mmx_redmask)", %%mm1\n\t" \
- "movq %%mm2, %%mm3\n\t" \
- "psllw $"AV_STRINGIFY(3-is15)", %%mm2\n\t" \
- "psrlw $"AV_STRINGIFY(5+is15)", %%mm3\n\t" \
- "psrlw $3, %%mm0\n\t" \
- IF##is15("psrlw $1, %%mm1\n\t") \
- "pand "MANGLE(pb_e0)", %%mm2\n\t" \
- "pand "MANGLE(gmask)", %%mm3\n\t" \
- "por %%mm2, %%mm0\n\t" \
- "por %%mm3, %%mm1\n\t" \
- "movq %%mm0, %%mm2\n\t" \
- "punpcklbw %%mm1, %%mm0\n\t" \
- "punpckhbw %%mm1, %%mm2\n\t" \
- MOVNTQ " %%mm0, (%1)\n\t" \
- MOVNTQ " %%mm2, 8(%1)\n\t" \
-
-#define DITHER_RGB \
- "paddusb "BLUE_DITHER"(%4), %%mm0\n\t" \
- "paddusb "GREEN_DITHER"(%4), %%mm2\n\t" \
- "paddusb "RED_DITHER"(%4), %%mm1\n\t" \
-
-#if !COMPILE_TEMPLATE_MMXEXT
-static inline int RENAME(yuv420_rgb15)(SwsContext *c, const uint8_t *src[],
- int srcStride[],
- int srcSliceY, int srcSliceH,
- uint8_t *dst[], int dstStride[])
-{
- int y, h_size, vshift;
-
- YUV2RGB_LOOP(2)
-
-#ifdef DITHER1XBPP
- c->blueDither = ff_dither8[y & 1];
- c->greenDither = ff_dither8[y & 1];
- c->redDither = ff_dither8[(y + 1) & 1];
-#endif
-
- YUV2RGB_INITIAL_LOAD
- YUV2RGB
- RGB_PACK_INTERLEAVE
-#ifdef DITHER1XBPP
- DITHER_RGB
-#endif
- RGB_PACK16(pb_03, 1)
-
- YUV2RGB_ENDLOOP(2)
- YUV2RGB_OPERANDS
- YUV2RGB_ENDFUNC
-}
-
-static inline int RENAME(yuv420_rgb16)(SwsContext *c, const uint8_t *src[],
- int srcStride[],
- int srcSliceY, int srcSliceH,
- uint8_t *dst[], int dstStride[])
-{
- int y, h_size, vshift;
-
- YUV2RGB_LOOP(2)
-
-#ifdef DITHER1XBPP
- c->blueDither = ff_dither8[y & 1];
- c->greenDither = ff_dither4[y & 1];
- c->redDither = ff_dither8[(y + 1) & 1];
-#endif
-
- YUV2RGB_INITIAL_LOAD
- YUV2RGB
- RGB_PACK_INTERLEAVE
-#ifdef DITHER1XBPP
- DITHER_RGB
-#endif
- RGB_PACK16(pb_07, 0)
-
- YUV2RGB_ENDLOOP(2)
- YUV2RGB_OPERANDS
- YUV2RGB_ENDFUNC
-}
-#endif /* !COMPILE_TEMPLATE_MMXEXT */
-
-#define RGB_PACK24(blue, red)\
- "packuswb %%mm3, %%mm0 \n" /* R0 R2 R4 R6 R1 R3 R5 R7 */\
- "packuswb %%mm5, %%mm1 \n" /* B0 B2 B4 B6 B1 B3 B5 B7 */\
- "packuswb %%mm7, %%mm2 \n" /* G0 G2 G4 G6 G1 G3 G5 G7 */\
- "movq %%mm"red", %%mm3 \n"\
- "movq %%mm"blue", %%mm6 \n"\
- "psrlq $32, %%mm"red" \n" /* R1 R3 R5 R7 */\
- "punpcklbw %%mm2, %%mm3 \n" /* R0 G0 R2 G2 R4 G4 R6 G6 */\
- "punpcklbw %%mm"red", %%mm6 \n" /* B0 R1 B2 R3 B4 R5 B6 R7 */\
- "movq %%mm3, %%mm5 \n"\
- "punpckhbw %%mm"blue", %%mm2 \n" /* G1 B1 G3 B3 G5 B5 G7 B7 */\
- "punpcklwd %%mm6, %%mm3 \n" /* R0 G0 B0 R1 R2 G2 B2 R3 */\
- "punpckhwd %%mm6, %%mm5 \n" /* R4 G4 B4 R5 R6 G6 B6 R7 */\
- RGB_PACK24_B
-
-#if COMPILE_TEMPLATE_MMXEXT
-DECLARE_ASM_CONST(8, int16_t, mask1101[4]) = {-1,-1, 0,-1};
-DECLARE_ASM_CONST(8, int16_t, mask0010[4]) = { 0, 0,-1, 0};
-DECLARE_ASM_CONST(8, int16_t, mask0110[4]) = { 0,-1,-1, 0};
-DECLARE_ASM_CONST(8, int16_t, mask1001[4]) = {-1, 0, 0,-1};
-DECLARE_ASM_CONST(8, int16_t, mask0100[4]) = { 0,-1, 0, 0};
-#undef RGB_PACK24_B
-#define RGB_PACK24_B\
- "pshufw $0xc6, %%mm2, %%mm1 \n"\
- "pshufw $0x84, %%mm3, %%mm6 \n"\
- "pshufw $0x38, %%mm5, %%mm7 \n"\
- "pand "MANGLE(mask1101)", %%mm6 \n" /* R0 G0 B0 R1 -- -- R2 G2 */\
- "movq %%mm1, %%mm0 \n"\
- "pand "MANGLE(mask0110)", %%mm7 \n" /* -- -- R6 G6 B6 R7 -- -- */\
- "movq %%mm1, %%mm2 \n"\
- "pand "MANGLE(mask0100)", %%mm1 \n" /* -- -- G3 B3 -- -- -- -- */\
- "psrlq $48, %%mm3 \n" /* B2 R3 -- -- -- -- -- -- */\
- "pand "MANGLE(mask0010)", %%mm0 \n" /* -- -- -- -- G1 B1 -- -- */\
- "psllq $32, %%mm5 \n" /* -- -- -- -- R4 G4 B4 R5 */\
- "pand "MANGLE(mask1001)", %%mm2 \n" /* G5 B5 -- -- -- -- G7 B7 */\
- "por %%mm3, %%mm1 \n"\
- "por %%mm6, %%mm0 \n"\
- "por %%mm5, %%mm1 \n"\
- "por %%mm7, %%mm2 \n"\
- MOVNTQ" %%mm0, (%1) \n"\
- MOVNTQ" %%mm1, 8(%1) \n"\
- MOVNTQ" %%mm2, 16(%1) \n"\
-
-#else
-#undef RGB_PACK24_B
-#define RGB_PACK24_B\
- "movd %%mm3, (%1) \n" /* R0 G0 B0 R1 */\
- "movd %%mm2, 4(%1) \n" /* G1 B1 */\
- "psrlq $32, %%mm3 \n"\
- "psrlq $16, %%mm2 \n"\
- "movd %%mm3, 6(%1) \n" /* R2 G2 B2 R3 */\
- "movd %%mm2, 10(%1) \n" /* G3 B3 */\
- "psrlq $16, %%mm2 \n"\
- "movd %%mm5, 12(%1) \n" /* R4 G4 B4 R5 */\
- "movd %%mm2, 16(%1) \n" /* G5 B5 */\
- "psrlq $32, %%mm5 \n"\
- "movd %%mm2, 20(%1) \n" /* -- -- G7 B7 */\
- "movd %%mm5, 18(%1) \n" /* R6 G6 B6 R7 */\
-
-#endif
-
-static inline int RENAME(yuv420_rgb24)(SwsContext *c, const uint8_t *src[],
- int srcStride[],
- int srcSliceY, int srcSliceH,
- uint8_t *dst[], int dstStride[])
-{
- int y, h_size, vshift;
-
- YUV2RGB_LOOP(3)
-
- YUV2RGB_INITIAL_LOAD
- YUV2RGB
- RGB_PACK24(REG_BLUE, REG_RED)
-
- YUV2RGB_ENDLOOP(3)
- YUV2RGB_OPERANDS
- YUV2RGB_ENDFUNC
-}
-
-static inline int RENAME(yuv420_bgr24)(SwsContext *c, const uint8_t *src[],
- int srcStride[],
- int srcSliceY, int srcSliceH,
- uint8_t *dst[], int dstStride[])
-{
- int y, h_size, vshift;
-
- YUV2RGB_LOOP(3)
-
- YUV2RGB_INITIAL_LOAD
- YUV2RGB
- RGB_PACK24(REG_RED, REG_BLUE)
-
- YUV2RGB_ENDLOOP(3)
- YUV2RGB_OPERANDS
- YUV2RGB_ENDFUNC
-}
-
-
-#define SET_EMPTY_ALPHA \
- "pcmpeqd %%mm"REG_ALPHA", %%mm"REG_ALPHA"\n\t" /* set alpha to 0xFF */ \
-
-#define LOAD_ALPHA \
- "movq (%6, %0, 2), %%mm"REG_ALPHA"\n\t" \
-
-#define RGB_PACK32(red, green, blue, alpha) \
- "movq %%mm"blue", %%mm5\n\t" \
- "movq %%mm"red", %%mm6\n\t" \
- "punpckhbw %%mm"green", %%mm5\n\t" \
- "punpcklbw %%mm"green", %%mm"blue"\n\t" \
- "punpckhbw %%mm"alpha", %%mm6\n\t" \
- "punpcklbw %%mm"alpha", %%mm"red"\n\t" \
- "movq %%mm"blue", %%mm"green"\n\t" \
- "movq %%mm5, %%mm"alpha"\n\t" \
- "punpcklwd %%mm"red", %%mm"blue"\n\t" \
- "punpckhwd %%mm"red", %%mm"green"\n\t" \
- "punpcklwd %%mm6, %%mm5\n\t" \
- "punpckhwd %%mm6, %%mm"alpha"\n\t" \
- MOVNTQ " %%mm"blue", 0(%1)\n\t" \
- MOVNTQ " %%mm"green", 8(%1)\n\t" \
- MOVNTQ " %%mm5, 16(%1)\n\t" \
- MOVNTQ " %%mm"alpha", 24(%1)\n\t" \
-
-#if !COMPILE_TEMPLATE_MMXEXT
-static inline int RENAME(yuv420_rgb32)(SwsContext *c, const uint8_t *src[],
- int srcStride[],
- int srcSliceY, int srcSliceH,
- uint8_t *dst[], int dstStride[])
-{
- int y, h_size, vshift;
-
- YUV2RGB_LOOP(4)
-
- YUV2RGB_INITIAL_LOAD
- YUV2RGB
- RGB_PACK_INTERLEAVE
- SET_EMPTY_ALPHA
- RGB_PACK32(REG_RED, REG_GREEN, REG_BLUE, REG_ALPHA)
-
- YUV2RGB_ENDLOOP(4)
- YUV2RGB_OPERANDS
- YUV2RGB_ENDFUNC
-}
-
-#if HAVE_7REGS && CONFIG_SWSCALE_ALPHA
-static inline int RENAME(yuva420_rgb32)(SwsContext *c, const uint8_t *src[],
- int srcStride[],
- int srcSliceY, int srcSliceH,
- uint8_t *dst[], int dstStride[])
-{
- int y, h_size, vshift;
-
- YUV2RGB_LOOP(4)
-
- const uint8_t *pa = src[3] + y * srcStride[3];
- YUV2RGB_INITIAL_LOAD
- YUV2RGB
- RGB_PACK_INTERLEAVE
- LOAD_ALPHA
- RGB_PACK32(REG_RED, REG_GREEN, REG_BLUE, REG_ALPHA)
-
- YUV2RGB_ENDLOOP(4)
- YUV2RGB_OPERANDS_ALPHA
- YUV2RGB_ENDFUNC
-}
-#endif
-
-static inline int RENAME(yuv420_bgr32)(SwsContext *c, const uint8_t *src[],
- int srcStride[],
- int srcSliceY, int srcSliceH,
- uint8_t *dst[], int dstStride[])
-{
- int y, h_size, vshift;
-
- YUV2RGB_LOOP(4)
-
- YUV2RGB_INITIAL_LOAD
- YUV2RGB
- RGB_PACK_INTERLEAVE
- SET_EMPTY_ALPHA
- RGB_PACK32(REG_BLUE, REG_GREEN, REG_RED, REG_ALPHA)
-
- YUV2RGB_ENDLOOP(4)
- YUV2RGB_OPERANDS
- YUV2RGB_ENDFUNC
-}
-
-#if HAVE_7REGS && CONFIG_SWSCALE_ALPHA
-static inline int RENAME(yuva420_bgr32)(SwsContext *c, const uint8_t *src[],
- int srcStride[],
- int srcSliceY, int srcSliceH,
- uint8_t *dst[], int dstStride[])
-{
- int y, h_size, vshift;
-
- YUV2RGB_LOOP(4)
-
- const uint8_t *pa = src[3] + y * srcStride[3];
- YUV2RGB_INITIAL_LOAD
- YUV2RGB
- RGB_PACK_INTERLEAVE
- LOAD_ALPHA
- RGB_PACK32(REG_BLUE, REG_GREEN, REG_RED, REG_ALPHA)
-
- YUV2RGB_ENDLOOP(4)
- YUV2RGB_OPERANDS_ALPHA
- YUV2RGB_ENDFUNC
-}
-#endif
-
-#endif /* !COMPILE_TEMPLATE_MMXEXT */
diff --git a/src/thirdparty/ffmpeg/libswscale/yuv2rgb.c b/src/thirdparty/ffmpeg/libswscale/yuv2rgb.c
deleted file mode 100644
index 4e32d5058..000000000
--- a/src/thirdparty/ffmpeg/libswscale/yuv2rgb.c
+++ /dev/null
@@ -1,927 +0,0 @@
-/*
- * software YUV to RGB converter
- *
- * Copyright (C) 2009 Konstantin Shishkov
- *
- * 1,4,8bpp support and context / deglobalize stuff
- * 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
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <inttypes.h>
-
-#include "libavutil/cpu.h"
-#include "libavutil/bswap.h"
-#include "config.h"
-#include "rgb2rgb.h"
-#include "swscale.h"
-#include "swscale_internal.h"
-#include "libavutil/pixdesc.h"
-
-extern const uint8_t dither_2x2_4[3][8];
-extern const uint8_t dither_2x2_8[3][8];
-extern const uint8_t dither_4x4_16[5][8];
-extern const uint8_t dither_8x8_32[9][8];
-extern const uint8_t dither_8x8_73[9][8];
-extern const uint8_t dither_8x8_220[9][8];
-
-const int32_t ff_yuv2rgb_coeffs[8][4] = {
- { 117504, 138453, 13954, 34903 }, /* no sequence_display_extension */
- { 117504, 138453, 13954, 34903 }, /* ITU-R Rec. 709 (1990) */
- { 104597, 132201, 25675, 53279 }, /* unspecified */
- { 104597, 132201, 25675, 53279 }, /* reserved */
- { 104448, 132798, 24759, 53109 }, /* FCC */
- { 104597, 132201, 25675, 53279 }, /* ITU-R Rec. 624-4 System B, G */
- { 104597, 132201, 25675, 53279 }, /* SMPTE 170M */
- { 117579, 136230, 16907, 35559 } /* SMPTE 240M (1987) */
-};
-
-const int *sws_getCoefficients(int colorspace)
-{
- if (colorspace > 7 || colorspace < 0)
- colorspace = SWS_CS_DEFAULT;
- return ff_yuv2rgb_coeffs[colorspace];
-}
-
-#define LOADCHROMA(i) \
- U = pu[i]; \
- V = pv[i]; \
- r = (void *)c->table_rV[V+YUVRGB_TABLE_HEADROOM]; \
- g = (void *)(c->table_gU[U+YUVRGB_TABLE_HEADROOM] + c->table_gV[V+YUVRGB_TABLE_HEADROOM]); \
- b = (void *)c->table_bU[U+YUVRGB_TABLE_HEADROOM];
-
-#define PUTRGB(dst, src, i) \
- Y = src[2 * i]; \
- dst[2 * i] = r[Y] + g[Y] + b[Y]; \
- Y = src[2 * i + 1]; \
- dst[2 * i + 1] = r[Y] + g[Y] + b[Y];
-
-#define PUTRGB24(dst, src, i) \
- Y = src[2 * i]; \
- dst[6 * i + 0] = r[Y]; \
- dst[6 * i + 1] = g[Y]; \
- dst[6 * i + 2] = b[Y]; \
- Y = src[2 * i + 1]; \
- dst[6 * i + 3] = r[Y]; \
- dst[6 * i + 4] = g[Y]; \
- dst[6 * i + 5] = b[Y];
-
-#define PUTBGR24(dst, src, i) \
- Y = src[2 * i]; \
- dst[6 * i + 0] = b[Y]; \
- dst[6 * i + 1] = g[Y]; \
- dst[6 * i + 2] = r[Y]; \
- Y = src[2 * i + 1]; \
- dst[6 * i + 3] = b[Y]; \
- dst[6 * i + 4] = g[Y]; \
- dst[6 * i + 5] = r[Y];
-
-#define PUTRGBA(dst, ysrc, asrc, i, s) \
- Y = ysrc[2 * i]; \
- dst[2 * i] = r[Y] + g[Y] + b[Y] + (asrc[2 * i] << s); \
- Y = ysrc[2 * i + 1]; \
- dst[2 * i + 1] = r[Y] + g[Y] + b[Y] + (asrc[2 * i + 1] << s);
-
-#define PUTRGB48(dst, src, i) \
- Y = src[ 2 * i]; \
- dst[12 * i + 0] = dst[12 * i + 1] = r[Y]; \
- dst[12 * i + 2] = dst[12 * i + 3] = g[Y]; \
- dst[12 * i + 4] = dst[12 * i + 5] = b[Y]; \
- Y = src[ 2 * i + 1]; \
- dst[12 * i + 6] = dst[12 * i + 7] = r[Y]; \
- dst[12 * i + 8] = dst[12 * i + 9] = g[Y]; \
- dst[12 * i + 10] = dst[12 * i + 11] = b[Y];
-
-#define PUTBGR48(dst, src, i) \
- Y = src[2 * i]; \
- dst[12 * i + 0] = dst[12 * i + 1] = b[Y]; \
- dst[12 * i + 2] = dst[12 * i + 3] = g[Y]; \
- dst[12 * i + 4] = dst[12 * i + 5] = r[Y]; \
- Y = src[2 * i + 1]; \
- dst[12 * i + 6] = dst[12 * i + 7] = b[Y]; \
- dst[12 * i + 8] = dst[12 * i + 9] = g[Y]; \
- dst[12 * i + 10] = dst[12 * i + 11] = r[Y];
-
-#define YUV2RGBFUNC(func_name, dst_type, alpha) \
- static int func_name(SwsContext *c, const uint8_t *src[], \
- int srcStride[], int srcSliceY, int srcSliceH, \
- uint8_t *dst[], int dstStride[]) \
- { \
- int y; \
- \
- if (!alpha && c->srcFormat == AV_PIX_FMT_YUV422P) { \
- srcStride[1] *= 2; \
- srcStride[2] *= 2; \
- } \
- for (y = 0; y < srcSliceH; y += 2) { \
- dst_type *dst_1 = \
- (dst_type *)(dst[0] + (y + srcSliceY) * dstStride[0]); \
- dst_type *dst_2 = \
- (dst_type *)(dst[0] + (y + srcSliceY + 1) * dstStride[0]); \
- dst_type av_unused *r, *g, *b; \
- const uint8_t *py_1 = src[0] + y * srcStride[0]; \
- const uint8_t *py_2 = py_1 + srcStride[0]; \
- const uint8_t *pu = src[1] + (y >> 1) * srcStride[1]; \
- const uint8_t *pv = src[2] + (y >> 1) * srcStride[2]; \
- const uint8_t av_unused *pa_1, *pa_2; \
- unsigned int h_size = c->dstW >> 3; \
- if (alpha) { \
- pa_1 = src[3] + y * srcStride[3]; \
- pa_2 = pa_1 + srcStride[3]; \
- } \
- while (h_size--) { \
- int av_unused U, V, Y; \
-
-#define ENDYUV2RGBLINE(dst_delta, ss) \
- pu += 4 >> ss; \
- pv += 4 >> ss; \
- py_1 += 8 >> ss; \
- py_2 += 8 >> ss; \
- dst_1 += dst_delta >> ss; \
- dst_2 += dst_delta >> ss; \
- } \
- if (c->dstW & (4 >> ss)) { \
- int av_unused Y, U, V; \
-
-#define ENDYUV2RGBFUNC() \
- } \
- } \
- return srcSliceH; \
- }
-
-#define CLOSEYUV2RGBFUNC(dst_delta) \
- ENDYUV2RGBLINE(dst_delta, 0) \
- ENDYUV2RGBFUNC()
-
-YUV2RGBFUNC(yuv2rgb_c_48, uint8_t, 0)
- LOADCHROMA(0);
- PUTRGB48(dst_1, py_1, 0);
- PUTRGB48(dst_2, py_2, 0);
-
- LOADCHROMA(1);
- PUTRGB48(dst_2, py_2, 1);
- PUTRGB48(dst_1, py_1, 1);
-
- LOADCHROMA(2);
- PUTRGB48(dst_1, py_1, 2);
- PUTRGB48(dst_2, py_2, 2);
-
- LOADCHROMA(3);
- PUTRGB48(dst_2, py_2, 3);
- PUTRGB48(dst_1, py_1, 3);
-ENDYUV2RGBLINE(48, 0)
- LOADCHROMA(0);
- PUTRGB48(dst_1, py_1, 0);
- PUTRGB48(dst_2, py_2, 0);
-
- LOADCHROMA(1);
- PUTRGB48(dst_2, py_2, 1);
- PUTRGB48(dst_1, py_1, 1);
-ENDYUV2RGBLINE(48, 1)
- LOADCHROMA(0);
- PUTRGB48(dst_1, py_1, 0);
- PUTRGB48(dst_2, py_2, 0);
-ENDYUV2RGBFUNC()
-
-YUV2RGBFUNC(yuv2rgb_c_bgr48, uint8_t, 0)
- LOADCHROMA(0);
- PUTBGR48(dst_1, py_1, 0);
- PUTBGR48(dst_2, py_2, 0);
-
- LOADCHROMA(1);
- PUTBGR48(dst_2, py_2, 1);
- PUTBGR48(dst_1, py_1, 1);
-
- LOADCHROMA(2);
- PUTBGR48(dst_1, py_1, 2);
- PUTBGR48(dst_2, py_2, 2);
-
- LOADCHROMA(3);
- PUTBGR48(dst_2, py_2, 3);
- PUTBGR48(dst_1, py_1, 3);
-ENDYUV2RGBLINE(48, 0)
- LOADCHROMA(0);
- PUTBGR48(dst_1, py_1, 0);
- PUTBGR48(dst_2, py_2, 0);
-
- LOADCHROMA(1);
- PUTBGR48(dst_2, py_2, 1);
- PUTBGR48(dst_1, py_1, 1);
-ENDYUV2RGBLINE(48, 1)
- LOADCHROMA(0);
- PUTBGR48(dst_1, py_1, 0);
- PUTBGR48(dst_2, py_2, 0);
-ENDYUV2RGBFUNC()
-
-YUV2RGBFUNC(yuv2rgb_c_32, uint32_t, 0)
- LOADCHROMA(0);
- PUTRGB(dst_1, py_1, 0);
- PUTRGB(dst_2, py_2, 0);
-
- LOADCHROMA(1);
- PUTRGB(dst_2, py_2, 1);
- PUTRGB(dst_1, py_1, 1);
-
- LOADCHROMA(2);
- PUTRGB(dst_1, py_1, 2);
- PUTRGB(dst_2, py_2, 2);
-
- LOADCHROMA(3);
- PUTRGB(dst_2, py_2, 3);
- PUTRGB(dst_1, py_1, 3);
-ENDYUV2RGBLINE(8, 0)
- LOADCHROMA(0);
- PUTRGB(dst_1, py_1, 0);
- PUTRGB(dst_2, py_2, 0);
-
- LOADCHROMA(1);
- PUTRGB(dst_2, py_2, 1);
- PUTRGB(dst_1, py_1, 1);
-ENDYUV2RGBLINE(8, 1)
- LOADCHROMA(0);
- PUTRGB(dst_1, py_1, 0);
- PUTRGB(dst_2, py_2, 0);
-ENDYUV2RGBFUNC()
-
-YUV2RGBFUNC(yuva2rgba_c, uint32_t, 1)
- LOADCHROMA(0);
- PUTRGBA(dst_1, py_1, pa_1, 0, 24);
- PUTRGBA(dst_2, py_2, pa_2, 0, 24);
-
- LOADCHROMA(1);
- PUTRGBA(dst_2, py_2, pa_1, 1, 24);
- PUTRGBA(dst_1, py_1, pa_2, 1, 24);
-
- LOADCHROMA(2);
- PUTRGBA(dst_1, py_1, pa_1, 2, 24);
- PUTRGBA(dst_2, py_2, pa_2, 2, 24);
-
- LOADCHROMA(3);
- PUTRGBA(dst_2, py_2, pa_1, 3, 24);
- PUTRGBA(dst_1, py_1, pa_2, 3, 24);
- pa_1 += 8; \
- pa_2 += 8; \
-ENDYUV2RGBLINE(8, 0)
- LOADCHROMA(0);
- PUTRGBA(dst_1, py_1, pa_1, 0, 24);
- PUTRGBA(dst_2, py_2, pa_2, 0, 24);
-
- LOADCHROMA(1);
- PUTRGBA(dst_2, py_2, pa_1, 1, 24);
- PUTRGBA(dst_1, py_1, pa_2, 1, 24);
- pa_1 += 4; \
- pa_2 += 4; \
-ENDYUV2RGBLINE(8, 1)
- LOADCHROMA(0);
- PUTRGBA(dst_1, py_1, pa_1, 0, 24);
- PUTRGBA(dst_2, py_2, pa_2, 0, 24);
-ENDYUV2RGBFUNC()
-
-YUV2RGBFUNC(yuva2argb_c, uint32_t, 1)
- LOADCHROMA(0);
- PUTRGBA(dst_1, py_1, pa_1, 0, 0);
- PUTRGBA(dst_2, py_2, pa_2, 0, 0);
-
- LOADCHROMA(1);
- PUTRGBA(dst_2, py_2, pa_2, 1, 0);
- PUTRGBA(dst_1, py_1, pa_1, 1, 0);
-
- LOADCHROMA(2);
- PUTRGBA(dst_1, py_1, pa_1, 2, 0);
- PUTRGBA(dst_2, py_2, pa_2, 2, 0);
-
- LOADCHROMA(3);
- PUTRGBA(dst_2, py_2, pa_2, 3, 0);
- PUTRGBA(dst_1, py_1, pa_1, 3, 0);
- pa_1 += 8; \
- pa_2 += 8; \
-ENDYUV2RGBLINE(8, 0)
- LOADCHROMA(0);
- PUTRGBA(dst_1, py_1, pa_1, 0, 0);
- PUTRGBA(dst_2, py_2, pa_2, 0, 0);
-
- LOADCHROMA(1);
- PUTRGBA(dst_2, py_2, pa_2, 1, 0);
- PUTRGBA(dst_1, py_1, pa_1, 1, 0);
- pa_1 += 4; \
- pa_2 += 4; \
-ENDYUV2RGBLINE(8, 1)
- LOADCHROMA(0);
- PUTRGBA(dst_1, py_1, pa_1, 0, 0);
- PUTRGBA(dst_2, py_2, pa_2, 0, 0);
-ENDYUV2RGBFUNC()
-
-YUV2RGBFUNC(yuv2rgb_c_24_rgb, uint8_t, 0)
- LOADCHROMA(0);
- PUTRGB24(dst_1, py_1, 0);
- PUTRGB24(dst_2, py_2, 0);
-
- LOADCHROMA(1);
- PUTRGB24(dst_2, py_2, 1);
- PUTRGB24(dst_1, py_1, 1);
-
- LOADCHROMA(2);
- PUTRGB24(dst_1, py_1, 2);
- PUTRGB24(dst_2, py_2, 2);
-
- LOADCHROMA(3);
- PUTRGB24(dst_2, py_2, 3);
- PUTRGB24(dst_1, py_1, 3);
-ENDYUV2RGBLINE(24, 0)
- LOADCHROMA(0);
- PUTRGB24(dst_1, py_1, 0);
- PUTRGB24(dst_2, py_2, 0);
-
- LOADCHROMA(1);
- PUTRGB24(dst_2, py_2, 1);
- PUTRGB24(dst_1, py_1, 1);
-ENDYUV2RGBLINE(24, 1)
- LOADCHROMA(0);
- PUTRGB24(dst_1, py_1, 0);
- PUTRGB24(dst_2, py_2, 0);
-ENDYUV2RGBFUNC()
-
-// only trivial mods from yuv2rgb_c_24_rgb
-YUV2RGBFUNC(yuv2rgb_c_24_bgr, uint8_t, 0)
- LOADCHROMA(0);
- PUTBGR24(dst_1, py_1, 0);
- PUTBGR24(dst_2, py_2, 0);
-
- LOADCHROMA(1);
- PUTBGR24(dst_2, py_2, 1);
- PUTBGR24(dst_1, py_1, 1);
-
- LOADCHROMA(2);
- PUTBGR24(dst_1, py_1, 2);
- PUTBGR24(dst_2, py_2, 2);
-
- LOADCHROMA(3);
- PUTBGR24(dst_2, py_2, 3);
- PUTBGR24(dst_1, py_1, 3);
-ENDYUV2RGBLINE(24, 0)
- LOADCHROMA(0);
- PUTBGR24(dst_1, py_1, 0);
- PUTBGR24(dst_2, py_2, 0);
-
- LOADCHROMA(1);
- PUTBGR24(dst_2, py_2, 1);
- PUTBGR24(dst_1, py_1, 1);
-ENDYUV2RGBLINE(24, 1)
- LOADCHROMA(0);
- PUTBGR24(dst_1, py_1, 0);
- PUTBGR24(dst_2, py_2, 0);
-ENDYUV2RGBFUNC()
-
-YUV2RGBFUNC(yuv2rgb_c_16_ordered_dither, uint16_t, 0)
- const uint8_t *d16 = dither_2x2_8[y & 1];
- const uint8_t *e16 = dither_2x2_4[y & 1];
- const uint8_t *f16 = dither_2x2_8[(y & 1)^1];
-
-#define PUTRGB16(dst, src, i, o) \
- Y = src[2 * i]; \
- dst[2 * i] = r[Y + d16[0 + o]] + \
- g[Y + e16[0 + o]] + \
- b[Y + f16[0 + o]]; \
- Y = src[2 * i + 1]; \
- dst[2 * i + 1] = r[Y + d16[1 + o]] + \
- g[Y + e16[1 + o]] + \
- b[Y + f16[1 + o]];
- LOADCHROMA(0);
- PUTRGB16(dst_1, py_1, 0, 0);
- PUTRGB16(dst_2, py_2, 0, 0 + 8);
-
- LOADCHROMA(1);
- PUTRGB16(dst_2, py_2, 1, 2 + 8);
- PUTRGB16(dst_1, py_1, 1, 2);
-
- LOADCHROMA(2);
- PUTRGB16(dst_1, py_1, 2, 4);
- PUTRGB16(dst_2, py_2, 2, 4 + 8);
-
- LOADCHROMA(3);
- PUTRGB16(dst_2, py_2, 3, 6 + 8);
- PUTRGB16(dst_1, py_1, 3, 6);
-CLOSEYUV2RGBFUNC(8)
-
-YUV2RGBFUNC(yuv2rgb_c_15_ordered_dither, uint16_t, 0)
- const uint8_t *d16 = dither_2x2_8[y & 1];
- const uint8_t *e16 = dither_2x2_8[(y & 1)^1];
-
-#define PUTRGB15(dst, src, i, o) \
- Y = src[2 * i]; \
- dst[2 * i] = r[Y + d16[0 + o]] + \
- g[Y + d16[1 + o]] + \
- b[Y + e16[0 + o]]; \
- Y = src[2 * i + 1]; \
- dst[2 * i + 1] = r[Y + d16[1 + o]] + \
- g[Y + d16[0 + o]] + \
- b[Y + e16[1 + o]];
- LOADCHROMA(0);
- PUTRGB15(dst_1, py_1, 0, 0);
- PUTRGB15(dst_2, py_2, 0, 0 + 8);
-
- LOADCHROMA(1);
- PUTRGB15(dst_2, py_2, 1, 2 + 8);
- PUTRGB15(dst_1, py_1, 1, 2);
-
- LOADCHROMA(2);
- PUTRGB15(dst_1, py_1, 2, 4);
- PUTRGB15(dst_2, py_2, 2, 4 + 8);
-
- LOADCHROMA(3);
- PUTRGB15(dst_2, py_2, 3, 6 + 8);
- PUTRGB15(dst_1, py_1, 3, 6);
-CLOSEYUV2RGBFUNC(8)
-
-// r, g, b, dst_1, dst_2
-YUV2RGBFUNC(yuv2rgb_c_12_ordered_dither, uint16_t, 0)
- const uint8_t *d16 = dither_4x4_16[y & 3];
-
-#define PUTRGB12(dst, src, i, o) \
- Y = src[2 * i]; \
- dst[2 * i] = r[Y + d16[0 + o]] + \
- g[Y + d16[0 + o]] + \
- b[Y + d16[0 + o]]; \
- Y = src[2 * i + 1]; \
- dst[2 * i + 1] = r[Y + d16[1 + o]] + \
- g[Y + d16[1 + o]] + \
- b[Y + d16[1 + o]];
-
- LOADCHROMA(0);
- PUTRGB12(dst_1, py_1, 0, 0);
- PUTRGB12(dst_2, py_2, 0, 0 + 8);
-
- LOADCHROMA(1);
- PUTRGB12(dst_2, py_2, 1, 2 + 8);
- PUTRGB12(dst_1, py_1, 1, 2);
-
- LOADCHROMA(2);
- PUTRGB12(dst_1, py_1, 2, 4);
- PUTRGB12(dst_2, py_2, 2, 4 + 8);
-
- LOADCHROMA(3);
- PUTRGB12(dst_2, py_2, 3, 6 + 8);
- PUTRGB12(dst_1, py_1, 3, 6);
-CLOSEYUV2RGBFUNC(8)
-
-// r, g, b, dst_1, dst_2
-YUV2RGBFUNC(yuv2rgb_c_8_ordered_dither, uint8_t, 0)
- const uint8_t *d32 = dither_8x8_32[y & 7];
- const uint8_t *d64 = dither_8x8_73[y & 7];
-
-#define PUTRGB8(dst, src, i, o) \
- Y = src[2 * i]; \
- dst[2 * i] = r[Y + d32[0 + o]] + \
- g[Y + d32[0 + o]] + \
- b[Y + d64[0 + o]]; \
- Y = src[2 * i + 1]; \
- dst[2 * i + 1] = r[Y + d32[1 + o]] + \
- g[Y + d32[1 + o]] + \
- b[Y + d64[1 + o]];
-
- LOADCHROMA(0);
- PUTRGB8(dst_1, py_1, 0, 0);
- PUTRGB8(dst_2, py_2, 0, 0 + 8);
-
- LOADCHROMA(1);
- PUTRGB8(dst_2, py_2, 1, 2 + 8);
- PUTRGB8(dst_1, py_1, 1, 2);
-
- LOADCHROMA(2);
- PUTRGB8(dst_1, py_1, 2, 4);
- PUTRGB8(dst_2, py_2, 2, 4 + 8);
-
- LOADCHROMA(3);
- PUTRGB8(dst_2, py_2, 3, 6 + 8);
- PUTRGB8(dst_1, py_1, 3, 6);
-CLOSEYUV2RGBFUNC(8)
-
-YUV2RGBFUNC(yuv2rgb_c_4_ordered_dither, uint8_t, 0)
- const uint8_t * d64 = dither_8x8_73[y & 7];
- const uint8_t *d128 = dither_8x8_220[y & 7];
- int acc;
-
-#define PUTRGB4D(dst, src, i, o) \
- Y = src[2 * i]; \
- acc = r[Y + d128[0 + o]] + \
- g[Y + d64[0 + o]] + \
- b[Y + d128[0 + o]]; \
- Y = src[2 * i + 1]; \
- acc |= (r[Y + d128[1 + o]] + \
- g[Y + d64[1 + o]] + \
- b[Y + d128[1 + o]]) << 4; \
- dst[i] = acc;
-
- LOADCHROMA(0);
- PUTRGB4D(dst_1, py_1, 0, 0);
- PUTRGB4D(dst_2, py_2, 0, 0 + 8);
-
- LOADCHROMA(1);
- PUTRGB4D(dst_2, py_2, 1, 2 + 8);
- PUTRGB4D(dst_1, py_1, 1, 2);
-
- LOADCHROMA(2);
- PUTRGB4D(dst_1, py_1, 2, 4);
- PUTRGB4D(dst_2, py_2, 2, 4 + 8);
-
- LOADCHROMA(3);
- PUTRGB4D(dst_2, py_2, 3, 6 + 8);
- PUTRGB4D(dst_1, py_1, 3, 6);
-CLOSEYUV2RGBFUNC(4)
-
-YUV2RGBFUNC(yuv2rgb_c_4b_ordered_dither, uint8_t, 0)
- const uint8_t *d64 = dither_8x8_73[y & 7];
- const uint8_t *d128 = dither_8x8_220[y & 7];
-
-#define PUTRGB4DB(dst, src, i, o) \
- Y = src[2 * i]; \
- dst[2 * i] = r[Y + d128[0 + o]] + \
- g[Y + d64[0 + o]] + \
- b[Y + d128[0 + o]]; \
- Y = src[2 * i + 1]; \
- dst[2 * i + 1] = r[Y + d128[1 + o]] + \
- g[Y + d64[1 + o]] + \
- b[Y + d128[1 + o]];
-
- LOADCHROMA(0);
- PUTRGB4DB(dst_1, py_1, 0, 0);
- PUTRGB4DB(dst_2, py_2, 0, 0 + 8);
-
- LOADCHROMA(1);
- PUTRGB4DB(dst_2, py_2, 1, 2 + 8);
- PUTRGB4DB(dst_1, py_1, 1, 2);
-
- LOADCHROMA(2);
- PUTRGB4DB(dst_1, py_1, 2, 4);
- PUTRGB4DB(dst_2, py_2, 2, 4 + 8);
-
- LOADCHROMA(3);
- PUTRGB4DB(dst_2, py_2, 3, 6 + 8);
- PUTRGB4DB(dst_1, py_1, 3, 6);
-CLOSEYUV2RGBFUNC(8)
-
-YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0)
- const uint8_t *d128 = dither_8x8_220[y & 7];
- char out_1 = 0, out_2 = 0;
- g = c->table_gU[128 + YUVRGB_TABLE_HEADROOM] + c->table_gV[128 + YUVRGB_TABLE_HEADROOM];
-
-#define PUTRGB1(out, src, i, o) \
- Y = src[2 * i]; \
- out += out + g[Y + d128[0 + o]]; \
- Y = src[2 * i + 1]; \
- out += out + g[Y + d128[1 + o]];
-
- PUTRGB1(out_1, py_1, 0, 0);
- PUTRGB1(out_2, py_2, 0, 0 + 8);
-
- PUTRGB1(out_2, py_2, 1, 2 + 8);
- PUTRGB1(out_1, py_1, 1, 2);
-
- PUTRGB1(out_1, py_1, 2, 4);
- PUTRGB1(out_2, py_2, 2, 4 + 8);
-
- PUTRGB1(out_2, py_2, 3, 6 + 8);
- PUTRGB1(out_1, py_1, 3, 6);
-
- dst_1[0] = out_1;
- dst_2[0] = out_2;
-CLOSEYUV2RGBFUNC(1)
-
-SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c)
-{
- SwsFunc t = NULL;
-
- if (HAVE_MMX)
- t = ff_yuv2rgb_init_mmx(c);
- else if (HAVE_VIS)
- t = ff_yuv2rgb_init_vis(c);
- else if (HAVE_ALTIVEC)
- t = ff_yuv2rgb_init_altivec(c);
- else if (ARCH_BFIN)
- t = ff_yuv2rgb_get_func_ptr_bfin(c);
-
- if (t)
- return t;
-
- av_log(c, AV_LOG_WARNING,
- "No accelerated colorspace conversion found from %s to %s.\n",
- av_get_pix_fmt_name(c->srcFormat), av_get_pix_fmt_name(c->dstFormat));
-
- switch (c->dstFormat) {
- case AV_PIX_FMT_BGR48BE:
- case AV_PIX_FMT_BGR48LE:
- return yuv2rgb_c_bgr48;
- case AV_PIX_FMT_RGB48BE:
- case AV_PIX_FMT_RGB48LE:
- return yuv2rgb_c_48;
- case AV_PIX_FMT_ARGB:
- case AV_PIX_FMT_ABGR:
- if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat))
- return yuva2argb_c;
- case AV_PIX_FMT_RGBA:
- case AV_PIX_FMT_BGRA:
- return (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat)) ? yuva2rgba_c : yuv2rgb_c_32;
- case AV_PIX_FMT_RGB24:
- return yuv2rgb_c_24_rgb;
- case AV_PIX_FMT_BGR24:
- return yuv2rgb_c_24_bgr;
- case AV_PIX_FMT_RGB565:
- case AV_PIX_FMT_BGR565:
- return yuv2rgb_c_16_ordered_dither;
- case AV_PIX_FMT_RGB555:
- case AV_PIX_FMT_BGR555:
- return yuv2rgb_c_15_ordered_dither;
- case AV_PIX_FMT_RGB444:
- case AV_PIX_FMT_BGR444:
- return yuv2rgb_c_12_ordered_dither;
- case AV_PIX_FMT_RGB8:
- case AV_PIX_FMT_BGR8:
- return yuv2rgb_c_8_ordered_dither;
- case AV_PIX_FMT_RGB4:
- case AV_PIX_FMT_BGR4:
- return yuv2rgb_c_4_ordered_dither;
- case AV_PIX_FMT_RGB4_BYTE:
- case AV_PIX_FMT_BGR4_BYTE:
- return yuv2rgb_c_4b_ordered_dither;
- case AV_PIX_FMT_MONOBLACK:
- return yuv2rgb_c_1_ordered_dither;
- }
- return NULL;
-}
-
-static void fill_table(uint8_t* table[256 + 2*YUVRGB_TABLE_HEADROOM], const int elemsize,
- const int64_t inc, void *y_tab)
-{
- int i;
- uint8_t *y_table = y_tab;
-
- y_table -= elemsize * (inc >> 9);
-
- for (i = 0; i < 256 + 2*YUVRGB_TABLE_HEADROOM; i++) {
- int64_t cb = av_clip(i-YUVRGB_TABLE_HEADROOM, 0, 255)*inc;
- table[i] = y_table + elemsize * (cb >> 16);
- }
-}
-
-static void fill_gv_table(int table[256 + 2*YUVRGB_TABLE_HEADROOM], const int elemsize, const int64_t inc)
-{
- int i;
- int off = -(inc >> 9);
-
- for (i = 0; i < 256 + 2*YUVRGB_TABLE_HEADROOM; i++) {
- int64_t cb = av_clip(i-YUVRGB_TABLE_HEADROOM, 0, 255)*inc;
- table[i] = elemsize * (off + (cb >> 16));
- }
-}
-
-static uint16_t roundToInt16(int64_t f)
-{
- int r = (f + (1 << 15)) >> 16;
-
- if (r < -0x7FFF)
- return 0x8000;
- else if (r > 0x7FFF)
- return 0x7FFF;
- else
- return r;
-}
-
-av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4],
- int fullRange, int brightness,
- int contrast, int saturation)
-{
- const int isRgb = c->dstFormat == AV_PIX_FMT_RGB32 ||
- c->dstFormat == AV_PIX_FMT_RGB32_1 ||
- c->dstFormat == AV_PIX_FMT_BGR24 ||
- c->dstFormat == AV_PIX_FMT_RGB565BE ||
- c->dstFormat == AV_PIX_FMT_RGB565LE ||
- c->dstFormat == AV_PIX_FMT_RGB555BE ||
- c->dstFormat == AV_PIX_FMT_RGB555LE ||
- c->dstFormat == AV_PIX_FMT_RGB444BE ||
- c->dstFormat == AV_PIX_FMT_RGB444LE ||
- c->dstFormat == AV_PIX_FMT_RGB8 ||
- c->dstFormat == AV_PIX_FMT_RGB4 ||
- c->dstFormat == AV_PIX_FMT_RGB4_BYTE ||
- c->dstFormat == AV_PIX_FMT_MONOBLACK;
- const int isNotNe = c->dstFormat == AV_PIX_FMT_NE(RGB565LE, RGB565BE) ||
- c->dstFormat == AV_PIX_FMT_NE(RGB555LE, RGB555BE) ||
- c->dstFormat == AV_PIX_FMT_NE(RGB444LE, RGB444BE) ||
- c->dstFormat == AV_PIX_FMT_NE(BGR565LE, BGR565BE) ||
- c->dstFormat == AV_PIX_FMT_NE(BGR555LE, BGR555BE) ||
- c->dstFormat == AV_PIX_FMT_NE(BGR444LE, BGR444BE);
- const int bpp = c->dstFormatBpp;
- uint8_t *y_table;
- uint16_t *y_table16;
- uint32_t *y_table32;
- int i, base, rbase, gbase, bbase, av_uninit(abase), needAlpha;
- const int yoffs = fullRange ? 384 : 326;
-
- int64_t crv = inv_table[0];
- int64_t cbu = inv_table[1];
- int64_t cgu = -inv_table[2];
- int64_t cgv = -inv_table[3];
- int64_t cy = 1 << 16;
- int64_t oy = 0;
- int64_t yb = 0;
-
- if (!fullRange) {
- cy = (cy * 255) / 219;
- oy = 16 << 16;
- } else {
- crv = (crv * 224) / 255;
- cbu = (cbu * 224) / 255;
- cgu = (cgu * 224) / 255;
- cgv = (cgv * 224) / 255;
- }
-
- cy = (cy * contrast) >> 16;
- crv = (crv * contrast * saturation) >> 32;
- cbu = (cbu * contrast * saturation) >> 32;
- cgu = (cgu * contrast * saturation) >> 32;
- cgv = (cgv * contrast * saturation) >> 32;
- oy -= 256 * brightness;
-
- c->uOffset = 0x0400040004000400LL;
- c->vOffset = 0x0400040004000400LL;
- c->yCoeff = roundToInt16(cy * 8192) * 0x0001000100010001ULL;
- c->vrCoeff = roundToInt16(crv * 8192) * 0x0001000100010001ULL;
- c->ubCoeff = roundToInt16(cbu * 8192) * 0x0001000100010001ULL;
- c->vgCoeff = roundToInt16(cgv * 8192) * 0x0001000100010001ULL;
- c->ugCoeff = roundToInt16(cgu * 8192) * 0x0001000100010001ULL;
- c->yOffset = roundToInt16(oy * 8) * 0x0001000100010001ULL;
-
- c->yuv2rgb_y_coeff = (int16_t)roundToInt16(cy << 13);
- c->yuv2rgb_y_offset = (int16_t)roundToInt16(oy << 9);
- c->yuv2rgb_v2r_coeff = (int16_t)roundToInt16(crv << 13);
- c->yuv2rgb_v2g_coeff = (int16_t)roundToInt16(cgv << 13);
- c->yuv2rgb_u2g_coeff = (int16_t)roundToInt16(cgu << 13);
- c->yuv2rgb_u2b_coeff = (int16_t)roundToInt16(cbu << 13);
-
- //scale coefficients by cy
- crv = ((crv << 16) + 0x8000) / cy;
- cbu = ((cbu << 16) + 0x8000) / cy;
- cgu = ((cgu << 16) + 0x8000) / cy;
- cgv = ((cgv << 16) + 0x8000) / cy;
-
- av_free(c->yuvTable);
-
- switch (bpp) {
- case 1:
- c->yuvTable = av_malloc(1024);
- y_table = c->yuvTable;
- yb = -(384 << 16) - oy;
- for (i = 0; i < 1024 - 110; i++) {
- y_table[i + 110] = av_clip_uint8((yb + 0x8000) >> 16) >> 7;
- yb += cy;
- }
- fill_table(c->table_gU, 1, cgu, y_table + yoffs);
- fill_gv_table(c->table_gV, 1, cgv);
- break;
- case 4:
- case 4 | 128:
- rbase = isRgb ? 3 : 0;
- gbase = 1;
- bbase = isRgb ? 0 : 3;
- c->yuvTable = av_malloc(1024 * 3);
- y_table = c->yuvTable;
- yb = -(384 << 16) - oy;
- for (i = 0; i < 1024 - 110; i++) {
- int yval = av_clip_uint8((yb + 0x8000) >> 16);
- y_table[i + 110] = (yval >> 7) << rbase;
- y_table[i + 37 + 1024] = ((yval + 43) / 85) << gbase;
- y_table[i + 110 + 2048] = (yval >> 7) << bbase;
- yb += cy;
- }
- fill_table(c->table_rV, 1, crv, y_table + yoffs);
- fill_table(c->table_gU, 1, cgu, y_table + yoffs + 1024);
- fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2048);
- fill_gv_table(c->table_gV, 1, cgv);
- break;
- case 8:
- rbase = isRgb ? 5 : 0;
- gbase = isRgb ? 2 : 3;
- bbase = isRgb ? 0 : 6;
- c->yuvTable = av_malloc(1024 * 3);
- y_table = c->yuvTable;
- yb = -(384 << 16) - oy;
- for (i = 0; i < 1024 - 38; i++) {
- int yval = av_clip_uint8((yb + 0x8000) >> 16);
- y_table[i + 16] = ((yval + 18) / 36) << rbase;
- y_table[i + 16 + 1024] = ((yval + 18) / 36) << gbase;
- y_table[i + 37 + 2048] = ((yval + 43) / 85) << bbase;
- yb += cy;
- }
- fill_table(c->table_rV, 1, crv, y_table + yoffs);
- fill_table(c->table_gU, 1, cgu, y_table + yoffs + 1024);
- fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2048);
- fill_gv_table(c->table_gV, 1, cgv);
- break;
- case 12:
- rbase = isRgb ? 8 : 0;
- gbase = 4;
- bbase = isRgb ? 0 : 8;
- c->yuvTable = av_malloc(1024 * 3 * 2);
- y_table16 = c->yuvTable;
- yb = -(384 << 16) - oy;
- for (i = 0; i < 1024; i++) {
- uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
- y_table16[i] = (yval >> 4) << rbase;
- y_table16[i + 1024] = (yval >> 4) << gbase;
- y_table16[i + 2048] = (yval >> 4) << bbase;
- yb += cy;
- }
- if (isNotNe)
- for (i = 0; i < 1024 * 3; i++)
- y_table16[i] = av_bswap16(y_table16[i]);
- fill_table(c->table_rV, 2, crv, y_table16 + yoffs);
- fill_table(c->table_gU, 2, cgu, y_table16 + yoffs + 1024);
- fill_table(c->table_bU, 2, cbu, y_table16 + yoffs + 2048);
- fill_gv_table(c->table_gV, 2, cgv);
- break;
- case 15:
- case 16:
- rbase = isRgb ? bpp - 5 : 0;
- gbase = 5;
- bbase = isRgb ? 0 : (bpp - 5);
- c->yuvTable = av_malloc(1024 * 3 * 2);
- y_table16 = c->yuvTable;
- yb = -(384 << 16) - oy;
- for (i = 0; i < 1024; i++) {
- uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
- y_table16[i] = (yval >> 3) << rbase;
- y_table16[i + 1024] = (yval >> (18 - bpp)) << gbase;
- y_table16[i + 2048] = (yval >> 3) << bbase;
- yb += cy;
- }
- if (isNotNe)
- for (i = 0; i < 1024 * 3; i++)
- y_table16[i] = av_bswap16(y_table16[i]);
- fill_table(c->table_rV, 2, crv, y_table16 + yoffs);
- fill_table(c->table_gU, 2, cgu, y_table16 + yoffs + 1024);
- fill_table(c->table_bU, 2, cbu, y_table16 + yoffs + 2048);
- fill_gv_table(c->table_gV, 2, cgv);
- break;
- case 24:
- case 48:
- c->yuvTable = av_malloc(1024);
- y_table = c->yuvTable;
- yb = -(384 << 16) - oy;
- for (i = 0; i < 1024; i++) {
- y_table[i] = av_clip_uint8((yb + 0x8000) >> 16);
- yb += cy;
- }
- fill_table(c->table_rV, 1, crv, y_table + yoffs);
- fill_table(c->table_gU, 1, cgu, y_table + yoffs);
- fill_table(c->table_bU, 1, cbu, y_table + yoffs);
- fill_gv_table(c->table_gV, 1, cgv);
- break;
- case 32:
- base = (c->dstFormat == AV_PIX_FMT_RGB32_1 ||
- c->dstFormat == AV_PIX_FMT_BGR32_1) ? 8 : 0;
- rbase = base + (isRgb ? 16 : 0);
- gbase = base + 8;
- bbase = base + (isRgb ? 0 : 16);
- needAlpha = CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat);
- if (!needAlpha)
- abase = (base + 24) & 31;
- c->yuvTable = av_malloc(1024 * 3 * 4);
- y_table32 = c->yuvTable;
- yb = -(384 << 16) - oy;
- for (i = 0; i < 1024; i++) {
- unsigned yval = av_clip_uint8((yb + 0x8000) >> 16);
- y_table32[i] = (yval << rbase) +
- (needAlpha ? 0 : (255u << abase));
- y_table32[i + 1024] = yval << gbase;
- y_table32[i + 2048] = yval << bbase;
- yb += cy;
- }
- fill_table(c->table_rV, 4, crv, y_table32 + yoffs);
- fill_table(c->table_gU, 4, cgu, y_table32 + yoffs + 1024);
- fill_table(c->table_bU, 4, cbu, y_table32 + yoffs + 2048);
- fill_gv_table(c->table_gV, 4, cgv);
- break;
- default:
- c->yuvTable = NULL;
- if(!isPlanar(c->dstFormat) || bpp <= 24)
- av_log(c, AV_LOG_ERROR, "%ibpp not supported by yuv2rgb\n", bpp);
- return -1;
- }
- return 0;
-}
diff --git a/src/thirdparty/ffmpeg/mpc_helper.c b/src/thirdparty/ffmpeg/mpc_helper.c
deleted file mode 100644
index d57d860a6..000000000
--- a/src/thirdparty/ffmpeg/mpc_helper.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * (C) 2008-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "libavcodec/avcodec.h"
-
-#if defined(DEBUG) || defined(_DEBUG)
- #define COMPILER " Debug"
-#else
- #define COMPILER ""
-#endif
-
-#if defined(__AVX2__)
- #define COMPILER_SSE " (AVX2)"
-#elif defined(__AVX__)
- #define COMPILER_SSE " (AVX)"
-#elif defined(__SSE4_2__)
- #define COMPILER_SSE " (SSE4.2)"
-#elif defined(__SSE4_1__)
- #define COMPILER_SSE " (SSE4.1)"
-#elif defined(__SSE4__)
- #define COMPILER_SSE " (SSE4)"
-#elif defined(__SSSE3__)
- #define COMPILER_SSE " (SSSE3)"
-#elif defined(__SSE3__)
- #define COMPILER_SSE " (SSE3)"
-#elif !ARCH_X86_64
- #if defined(__SSE2__)
- #define COMPILER_SSE " (SSE2)"
- #elif defined(__SSE__)
- #define COMPILER_SSE " (SSE)"
- #elif defined(__MMX__)
- #define COMPILER_SSE " (MMX)"
- #else
- #define COMPILER_SSE ""
- #endif
-#else
- #define COMPILER_SSE ""
-#endif
-
-static char g_Gcc_Compiler[35];
-
-char* GetFFmpegCompiler()
-{
- snprintf(g_Gcc_Compiler, sizeof(g_Gcc_Compiler)/sizeof(g_Gcc_Compiler[0]),
- "MinGW-w64 GCC %d.%d.%d%s%s", __GNUC__, __GNUC_MINOR__,
- __GNUC_PATCHLEVEL__, COMPILER, COMPILER_SSE);
- return g_Gcc_Compiler;
-}
diff --git a/src/thirdparty/libflac/include/FLAC/all.h b/src/thirdparty/libflac/include/FLAC/all.h
deleted file mode 100644
index 76df8249c..000000000
--- a/src/thirdparty/libflac/include/FLAC/all.h
+++ /dev/null
@@ -1,370 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__ALL_H
-#define FLAC__ALL_H
-
-#include "export.h"
-
-#include "assert.h"
-#include "callback.h"
-#include "format.h"
-#include "metadata.h"
-#include "ordinals.h"
-#include "stream_decoder.h"
-#include "stream_encoder.h"
-
-/** \mainpage
- *
- * \section intro Introduction
- *
- * This is the documentation for the FLAC C and C++ APIs. It is
- * highly interconnected; this introduction should give you a top
- * level idea of the structure and how to find the information you
- * need. As a prerequisite you should have at least a basic
- * knowledge of the FLAC format, documented
- * <A HREF="../format.html">here</A>.
- *
- * \section c_api FLAC C API
- *
- * The FLAC C API is the interface to libFLAC, a set of structures
- * describing the components of FLAC streams, and functions for
- * encoding and decoding streams, as well as manipulating FLAC
- * metadata in files. The public include files will be installed
- * in your include area (for example /usr/include/FLAC/...).
- *
- * By writing a little code and linking against libFLAC, it is
- * relatively easy to add FLAC support to another program. The
- * library is licensed under <A HREF="../license.html">Xiph's BSD license</A>.
- * Complete source code of libFLAC as well as the command-line
- * encoder and plugins is available and is a useful source of
- * examples.
- *
- * Aside from encoders and decoders, libFLAC provides a powerful
- * metadata interface for manipulating metadata in FLAC files. It
- * allows the user to add, delete, and modify FLAC metadata blocks
- * and it can automatically take advantage of PADDING blocks to avoid
- * rewriting the entire FLAC file when changing the size of the
- * metadata.
- *
- * libFLAC usually only requires the standard C library and C math
- * library. In particular, threading is not used so there is no
- * dependency on a thread library. However, libFLAC does not use
- * global variables and should be thread-safe.
- *
- * libFLAC also supports encoding to and decoding from Ogg FLAC.
- * However the metadata editing interfaces currently have limited
- * read-only support for Ogg FLAC files.
- *
- * \section cpp_api FLAC C++ API
- *
- * The FLAC C++ API is a set of classes that encapsulate the
- * structures and functions in libFLAC. They provide slightly more
- * functionality with respect to metadata but are otherwise
- * equivalent. For the most part, they share the same usage as
- * their counterparts in libFLAC, and the FLAC C API documentation
- * can be used as a supplement. The public include files
- * for the C++ API will be installed in your include area (for
- * example /usr/include/FLAC++/...).
- *
- * libFLAC++ is also licensed under
- * <A HREF="../license.html">Xiph's BSD license</A>.
- *
- * \section getting_started Getting Started
- *
- * A good starting point for learning the API is to browse through
- * the <A HREF="modules.html">modules</A>. Modules are logical
- * groupings of related functions or classes, which correspond roughly
- * to header files or sections of header files. Each module includes a
- * detailed description of the general usage of its functions or
- * classes.
- *
- * From there you can go on to look at the documentation of
- * individual functions. You can see different views of the individual
- * functions through the links in top bar across this page.
- *
- * If you prefer a more hands-on approach, you can jump right to some
- * <A HREF="../documentation_example_code.html">example code</A>.
- *
- * \section porting_guide Porting Guide
- *
- * Starting with FLAC 1.1.3 a \link porting Porting Guide \endlink
- * has been introduced which gives detailed instructions on how to
- * port your code to newer versions of FLAC.
- *
- * \section embedded_developers Embedded Developers
- *
- * libFLAC has grown larger over time as more functionality has been
- * included, but much of it may be unnecessary for a particular embedded
- * implementation. Unused parts may be pruned by some simple editing of
- * src/libFLAC/Makefile.am. In general, the decoders, encoders, and
- * metadata interface are all independent from each other.
- *
- * It is easiest to just describe the dependencies:
- *
- * - All modules depend on the \link flac_format Format \endlink module.
- * - The decoders and encoders depend on the bitbuffer.
- * - The decoder is independent of the encoder. The encoder uses the
- * decoder because of the verify feature, but this can be removed if
- * not needed.
- * - Parts of the metadata interface require the stream decoder (but not
- * the encoder).
- * - Ogg support is selectable through the compile time macro
- * \c FLAC__HAS_OGG.
- *
- * For example, if your application only requires the stream decoder, no
- * encoder, and no metadata interface, you can remove the stream encoder
- * and the metadata interface, which will greatly reduce the size of the
- * library.
- *
- * Also, there are several places in the libFLAC code with comments marked
- * with "OPT:" where a #define can be changed to enable code that might be
- * faster on a specific platform. Experimenting with these can yield faster
- * binaries.
- */
-
-/** \defgroup porting Porting Guide for New Versions
- *
- * This module describes differences in the library interfaces from
- * version to version. It assists in the porting of code that uses
- * the libraries to newer versions of FLAC.
- *
- * One simple facility for making porting easier that has been added
- * in FLAC 1.1.3 is a set of \c #defines in \c export.h of each
- * library's includes (e.g. \c include/FLAC/export.h). The
- * \c #defines mirror the libraries'
- * <A HREF="http://www.gnu.org/software/libtool/manual.html#Libtool-versioning">libtool version numbers</A>,
- * e.g. in libFLAC there are \c FLAC_API_VERSION_CURRENT,
- * \c FLAC_API_VERSION_REVISION, and \c FLAC_API_VERSION_AGE.
- * These can be used to support multiple versions of an API during the
- * transition phase, e.g.
- *
- * \code
- * #if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7
- * legacy code
- * #else
- * new code
- * #endif
- * \endcode
- *
- * The the source will work for multiple versions and the legacy code can
- * easily be removed when the transition is complete.
- *
- * Another available symbol is FLAC_API_SUPPORTS_OGG_FLAC (defined in
- * include/FLAC/export.h), which can be used to determine whether or not
- * the library has been compiled with support for Ogg FLAC. This is
- * simpler than trying to call an Ogg init function and catching the
- * error.
- */
-
-/** \defgroup porting_1_1_2_to_1_1_3 Porting from FLAC 1.1.2 to 1.1.3
- * \ingroup porting
- *
- * \brief
- * This module describes porting from FLAC 1.1.2 to FLAC 1.1.3.
- *
- * The main change between the APIs in 1.1.2 and 1.1.3 is that they have
- * been simplified. First, libOggFLAC has been merged into libFLAC and
- * libOggFLAC++ has been merged into libFLAC++. Second, both the three
- * decoding layers and three encoding layers have been merged into a
- * single stream decoder and stream encoder. That is, the functionality
- * of FLAC__SeekableStreamDecoder and FLAC__FileDecoder has been merged
- * into FLAC__StreamDecoder, and FLAC__SeekableStreamEncoder and
- * FLAC__FileEncoder into FLAC__StreamEncoder. Only the
- * FLAC__StreamDecoder and FLAC__StreamEncoder remain. What this means
- * is there is now a single API that can be used to encode or decode
- * streams to/from native FLAC or Ogg FLAC and the single API can work
- * on both seekable and non-seekable streams.
- *
- * Instead of creating an encoder or decoder of a certain layer, now the
- * client will always create a FLAC__StreamEncoder or
- * FLAC__StreamDecoder. The old layers are now differentiated by the
- * initialization function. For example, for the decoder,
- * FLAC__stream_decoder_init() has been replaced by
- * FLAC__stream_decoder_init_stream(). This init function takes
- * callbacks for the I/O, and the seeking callbacks are optional. This
- * allows the client to use the same object for seekable and
- * non-seekable streams. For decoding a FLAC file directly, the client
- * can use FLAC__stream_decoder_init_file() and pass just a filename
- * and fewer callbacks; most of the other callbacks are supplied
- * internally. For situations where fopen()ing by filename is not
- * possible (e.g. Unicode filenames on Windows) the client can instead
- * open the file itself and supply the FILE* to
- * FLAC__stream_decoder_init_FILE(). The init functions now returns a
- * FLAC__StreamDecoderInitStatus instead of FLAC__StreamDecoderState.
- * Since the callbacks and client data are now passed to the init
- * function, the FLAC__stream_decoder_set_*_callback() functions and
- * FLAC__stream_decoder_set_client_data() are no longer needed. The
- * rest of the calls to the decoder are the same as before.
- *
- * There are counterpart init functions for Ogg FLAC, e.g.
- * FLAC__stream_decoder_init_ogg_stream(). All the rest of the calls
- * and callbacks are the same as for native FLAC.
- *
- * As an example, in FLAC 1.1.2 a seekable stream decoder would have
- * been set up like so:
- *
- * \code
- * FLAC__SeekableStreamDecoder *decoder = FLAC__seekable_stream_decoder_new();
- * if(decoder == NULL) do_something;
- * FLAC__seekable_stream_decoder_set_md5_checking(decoder, true);
- * [... other settings ...]
- * FLAC__seekable_stream_decoder_set_read_callback(decoder, my_read_callback);
- * FLAC__seekable_stream_decoder_set_seek_callback(decoder, my_seek_callback);
- * FLAC__seekable_stream_decoder_set_tell_callback(decoder, my_tell_callback);
- * FLAC__seekable_stream_decoder_set_length_callback(decoder, my_length_callback);
- * FLAC__seekable_stream_decoder_set_eof_callback(decoder, my_eof_callback);
- * FLAC__seekable_stream_decoder_set_write_callback(decoder, my_write_callback);
- * FLAC__seekable_stream_decoder_set_metadata_callback(decoder, my_metadata_callback);
- * FLAC__seekable_stream_decoder_set_error_callback(decoder, my_error_callback);
- * FLAC__seekable_stream_decoder_set_client_data(decoder, my_client_data);
- * if(FLAC__seekable_stream_decoder_init(decoder) != FLAC__SEEKABLE_STREAM_DECODER_OK) do_something;
- * \endcode
- *
- * In FLAC 1.1.3 it is like this:
- *
- * \code
- * FLAC__StreamDecoder *decoder = FLAC__stream_decoder_new();
- * if(decoder == NULL) do_something;
- * FLAC__stream_decoder_set_md5_checking(decoder, true);
- * [... other settings ...]
- * if(FLAC__stream_decoder_init_stream(
- * decoder,
- * my_read_callback,
- * my_seek_callback, // or NULL
- * my_tell_callback, // or NULL
- * my_length_callback, // or NULL
- * my_eof_callback, // or NULL
- * my_write_callback,
- * my_metadata_callback, // or NULL
- * my_error_callback,
- * my_client_data
- * ) != FLAC__STREAM_DECODER_INIT_STATUS_OK) do_something;
- * \endcode
- *
- * or you could do;
- *
- * \code
- * [...]
- * FILE *file = fopen("somefile.flac","rb");
- * if(file == NULL) do_somthing;
- * if(FLAC__stream_decoder_init_FILE(
- * decoder,
- * file,
- * my_write_callback,
- * my_metadata_callback, // or NULL
- * my_error_callback,
- * my_client_data
- * ) != FLAC__STREAM_DECODER_INIT_STATUS_OK) do_something;
- * \endcode
- *
- * or just:
- *
- * \code
- * [...]
- * if(FLAC__stream_decoder_init_file(
- * decoder,
- * "somefile.flac",
- * my_write_callback,
- * my_metadata_callback, // or NULL
- * my_error_callback,
- * my_client_data
- * ) != FLAC__STREAM_DECODER_INIT_STATUS_OK) do_something;
- * \endcode
- *
- * Another small change to the decoder is in how it handles unparseable
- * streams. Before, when the decoder found an unparseable stream
- * (reserved for when the decoder encounters a stream from a future
- * encoder that it can't parse), it changed the state to
- * \c FLAC__STREAM_DECODER_UNPARSEABLE_STREAM. Now the decoder instead
- * drops sync and calls the error callback with a new error code
- * \c FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM. This is
- * more robust. If your error callback does not discriminate on the the
- * error state, your code does not need to be changed.
- *
- * The encoder now has a new setting:
- * FLAC__stream_encoder_set_apodization(). This is for setting the
- * method used to window the data before LPC analysis. You only need to
- * add a call to this function if the default is not suitable. There
- * are also two new convenience functions that may be useful:
- * FLAC__metadata_object_cuesheet_calculate_cddb_id() and
- * FLAC__metadata_get_cuesheet().
- *
- * The \a bytes parameter to FLAC__StreamDecoderReadCallback,
- * FLAC__StreamEncoderReadCallback, and FLAC__StreamEncoderWriteCallback
- * is now \c size_t instead of \c unsigned.
- */
-
-/** \defgroup porting_1_1_3_to_1_1_4 Porting from FLAC 1.1.3 to 1.1.4
- * \ingroup porting
- *
- * \brief
- * This module describes porting from FLAC 1.1.3 to FLAC 1.1.4.
- *
- * There were no changes to any of the interfaces from 1.1.3 to 1.1.4.
- * There was a slight change in the implementation of
- * FLAC__stream_encoder_set_metadata(); the function now makes a copy
- * of the \a metadata array of pointers so the client no longer needs
- * to maintain it after the call. The objects themselves that are
- * pointed to by the array are still not copied though and must be
- * maintained until the call to FLAC__stream_encoder_finish().
- */
-
-/** \defgroup porting_1_1_4_to_1_2_0 Porting from FLAC 1.1.4 to 1.2.0
- * \ingroup porting
- *
- * \brief
- * This module describes porting from FLAC 1.1.4 to FLAC 1.2.0.
- *
- * There were only very minor changes to the interfaces from 1.1.4 to 1.2.0.
- * In libFLAC, \c FLAC__format_sample_rate_is_subset() was added.
- * In libFLAC++, \c FLAC::Decoder::Stream::get_decode_position() was added.
- *
- * Finally, value of the constant \c FLAC__FRAME_HEADER_RESERVED_LEN
- * has changed to reflect the conversion of one of the reserved bits
- * into active use. It used to be \c 2 and now is \c 1. However the
- * FLAC frame header length has not changed, so to skip the proper
- * number of bits, use \c FLAC__FRAME_HEADER_RESERVED_LEN +
- * \c FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN
- */
-
-/** \defgroup flac FLAC C API
- *
- * The FLAC C API is the interface to libFLAC, a set of structures
- * describing the components of FLAC streams, and functions for
- * encoding and decoding streams, as well as manipulating FLAC
- * metadata in files.
- *
- * You should start with the format components as all other modules
- * are dependent on it.
- */
-
-#endif
diff --git a/src/thirdparty/libflac/include/FLAC/assert.h b/src/thirdparty/libflac/include/FLAC/assert.h
deleted file mode 100644
index ebc9cc1a9..000000000
--- a/src/thirdparty/libflac/include/FLAC/assert.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__ASSERT_H
-#define FLAC__ASSERT_H
-
-/* we need this since some compilers (like MSVC) leave assert()s on release code (and we don't want to use their ASSERT) */
-#ifdef DEBUG
-#include <assert.h>
-#define FLAC__ASSERT(x) assert(x)
-#define FLAC__ASSERT_DECLARATION(x) x
-#else
-#define FLAC__ASSERT(x)
-#define FLAC__ASSERT_DECLARATION(x)
-#endif
-
-#endif
diff --git a/src/thirdparty/libflac/include/FLAC/callback.h b/src/thirdparty/libflac/include/FLAC/callback.h
deleted file mode 100644
index 3def56dab..000000000
--- a/src/thirdparty/libflac/include/FLAC/callback.h
+++ /dev/null
@@ -1,184 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__CALLBACK_H
-#define FLAC__CALLBACK_H
-
-#include "ordinals.h"
-#include <stdlib.h> /* for size_t */
-
-/** \file include/FLAC/callback.h
- *
- * \brief
- * This module defines the structures for describing I/O callbacks
- * to the other FLAC interfaces.
- *
- * See the detailed documentation for callbacks in the
- * \link flac_callbacks callbacks \endlink module.
- */
-
-/** \defgroup flac_callbacks FLAC/callback.h: I/O callback structures
- * \ingroup flac
- *
- * \brief
- * This module defines the structures for describing I/O callbacks
- * to the other FLAC interfaces.
- *
- * The purpose of the I/O callback functions is to create a common way
- * for the metadata interfaces to handle I/O.
- *
- * Originally the metadata interfaces required filenames as the way of
- * specifying FLAC files to operate on. This is problematic in some
- * environments so there is an additional option to specify a set of
- * callbacks for doing I/O on the FLAC file, instead of the filename.
- *
- * In addition to the callbacks, a FLAC__IOHandle type is defined as an
- * opaque structure for a data source.
- *
- * The callback function prototypes are similar (but not identical) to the
- * stdio functions fread, fwrite, fseek, ftell, feof, and fclose. If you use
- * stdio streams to implement the callbacks, you can pass fread, fwrite, and
- * fclose anywhere a FLAC__IOCallback_Read, FLAC__IOCallback_Write, or
- * FLAC__IOCallback_Close is required, and a FILE* anywhere a FLAC__IOHandle
- * is required. \warning You generally CANNOT directly use fseek or ftell
- * for FLAC__IOCallback_Seek or FLAC__IOCallback_Tell since on most systems
- * these use 32-bit offsets and FLAC requires 64-bit offsets to deal with
- * large files. You will have to find an equivalent function (e.g. ftello),
- * or write a wrapper. The same is true for feof() since this is usually
- * implemented as a macro, not as a function whose address can be taken.
- *
- * \{
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/** This is the opaque handle type used by the callbacks. Typically
- * this is a \c FILE* or address of a file descriptor.
- */
-typedef void* FLAC__IOHandle;
-
-/** Signature for the read callback.
- * The signature and semantics match POSIX fread() implementations
- * and can generally be used interchangeably.
- *
- * \param ptr The address of the read buffer.
- * \param size The size of the records to be read.
- * \param nmemb The number of records to be read.
- * \param handle The handle to the data source.
- * \retval size_t
- * The number of records read.
- */
-typedef size_t (*FLAC__IOCallback_Read) (void *ptr, size_t size, size_t nmemb, FLAC__IOHandle handle);
-
-/** Signature for the write callback.
- * The signature and semantics match POSIX fwrite() implementations
- * and can generally be used interchangeably.
- *
- * \param ptr The address of the write buffer.
- * \param size The size of the records to be written.
- * \param nmemb The number of records to be written.
- * \param handle The handle to the data source.
- * \retval size_t
- * The number of records written.
- */
-typedef size_t (*FLAC__IOCallback_Write) (const void *ptr, size_t size, size_t nmemb, FLAC__IOHandle handle);
-
-/** Signature for the seek callback.
- * The signature and semantics mostly match POSIX fseek() WITH ONE IMPORTANT
- * EXCEPTION: the offset is a 64-bit type whereas fseek() is generally 'long'
- * and 32-bits wide.
- *
- * \param handle The handle to the data source.
- * \param offset The new position, relative to \a whence
- * \param whence \c SEEK_SET, \c SEEK_CUR, or \c SEEK_END
- * \retval int
- * \c 0 on success, \c -1 on error.
- */
-typedef int (*FLAC__IOCallback_Seek) (FLAC__IOHandle handle, FLAC__int64 offset, int whence);
-
-/** Signature for the tell callback.
- * The signature and semantics mostly match POSIX ftell() WITH ONE IMPORTANT
- * EXCEPTION: the offset is a 64-bit type whereas ftell() is generally 'long'
- * and 32-bits wide.
- *
- * \param handle The handle to the data source.
- * \retval FLAC__int64
- * The current position on success, \c -1 on error.
- */
-typedef FLAC__int64 (*FLAC__IOCallback_Tell) (FLAC__IOHandle handle);
-
-/** Signature for the EOF callback.
- * The signature and semantics mostly match POSIX feof() but WATCHOUT:
- * on many systems, feof() is a macro, so in this case a wrapper function
- * must be provided instead.
- *
- * \param handle The handle to the data source.
- * \retval int
- * \c 0 if not at end of file, nonzero if at end of file.
- */
-typedef int (*FLAC__IOCallback_Eof) (FLAC__IOHandle handle);
-
-/** Signature for the close callback.
- * The signature and semantics match POSIX fclose() implementations
- * and can generally be used interchangeably.
- *
- * \param handle The handle to the data source.
- * \retval int
- * \c 0 on success, \c EOF on error.
- */
-typedef int (*FLAC__IOCallback_Close) (FLAC__IOHandle handle);
-
-/** A structure for holding a set of callbacks.
- * Each FLAC interface that requires a FLAC__IOCallbacks structure will
- * describe which of the callbacks are required. The ones that are not
- * required may be set to NULL.
- *
- * If the seek requirement for an interface is optional, you can signify that
- * a data sorce is not seekable by setting the \a seek field to \c NULL.
- */
-typedef struct {
- FLAC__IOCallback_Read read;
- FLAC__IOCallback_Write write;
- FLAC__IOCallback_Seek seek;
- FLAC__IOCallback_Tell tell;
- FLAC__IOCallback_Eof eof;
- FLAC__IOCallback_Close close;
-} FLAC__IOCallbacks;
-
-/* \} */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/src/thirdparty/libflac/include/FLAC/export.h b/src/thirdparty/libflac/include/FLAC/export.h
deleted file mode 100644
index 9bf6d6387..000000000
--- a/src/thirdparty/libflac/include/FLAC/export.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__EXPORT_H
-#define FLAC__EXPORT_H
-
-/** \file include/FLAC/export.h
- *
- * \brief
- * This module contains #defines and symbols for exporting function
- * calls, and providing version information and compiled-in features.
- *
- * See the \link flac_export export \endlink module.
- */
-
-/** \defgroup flac_export FLAC/export.h: export symbols
- * \ingroup flac
- *
- * \brief
- * This module contains #defines and symbols for exporting function
- * calls, and providing version information and compiled-in features.
- *
- * If you are compiling with MSVC and will link to the static library
- * (libFLAC.lib) you should define FLAC__NO_DLL in your project to
- * make sure the symbols are exported properly.
- *
- * \{
- */
-
-#if defined(FLAC__NO_DLL) || !defined(_MSC_VER)
-#define FLAC_API
-
-#else
-
-#ifdef FLAC_API_EXPORTS
-#define FLAC_API _declspec(dllexport)
-#else
-#define FLAC_API _declspec(dllimport)
-
-#endif
-#endif
-
-/** These #defines will mirror the libtool-based library version number, see
- * http://www.gnu.org/software/libtool/manual.html#Libtool-versioning
- */
-#define FLAC_API_VERSION_CURRENT 10
-#define FLAC_API_VERSION_REVISION 0 /**< see above */
-#define FLAC_API_VERSION_AGE 2 /**< see above */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/** \c 1 if the library has been compiled with support for Ogg FLAC, else \c 0. */
-extern FLAC_API int FLAC_API_SUPPORTS_OGG_FLAC;
-
-#ifdef __cplusplus
-}
-#endif
-
-/* \} */
-
-#endif
diff --git a/src/thirdparty/libflac/include/FLAC/format.h b/src/thirdparty/libflac/include/FLAC/format.h
deleted file mode 100644
index 27dc36521..000000000
--- a/src/thirdparty/libflac/include/FLAC/format.h
+++ /dev/null
@@ -1,1022 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__FORMAT_H
-#define FLAC__FORMAT_H
-
-#include "export.h"
-#include "ordinals.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/** \file include/FLAC/format.h
- *
- * \brief
- * This module contains structure definitions for the representation
- * of FLAC format components in memory. These are the basic
- * structures used by the rest of the interfaces.
- *
- * See the detailed documentation in the
- * \link flac_format format \endlink module.
- */
-
-/** \defgroup flac_format FLAC/format.h: format components
- * \ingroup flac
- *
- * \brief
- * This module contains structure definitions for the representation
- * of FLAC format components in memory. These are the basic
- * structures used by the rest of the interfaces.
- *
- * First, you should be familiar with the
- * <A HREF="../format.html">FLAC format</A>. Many of the values here
- * follow directly from the specification. As a user of libFLAC, the
- * interesting parts really are the structures that describe the frame
- * header and metadata blocks.
- *
- * The format structures here are very primitive, designed to store
- * information in an efficient way. Reading information from the
- * structures is easy but creating or modifying them directly is
- * more complex. For the most part, as a user of a library, editing
- * is not necessary; however, for metadata blocks it is, so there are
- * convenience functions provided in the \link flac_metadata metadata
- * module \endlink to simplify the manipulation of metadata blocks.
- *
- * \note
- * It's not the best convention, but symbols ending in _LEN are in bits
- * and _LENGTH are in bytes. _LENGTH symbols are \#defines instead of
- * global variables because they are usually used when declaring byte
- * arrays and some compilers require compile-time knowledge of array
- * sizes when declared on the stack.
- *
- * \{
- */
-
-
-/*
- Most of the values described in this file are defined by the FLAC
- format specification. There is nothing to tune here.
-*/
-
-/** The largest legal metadata type code. */
-#define FLAC__MAX_METADATA_TYPE_CODE (126u)
-
-/** The minimum block size, in samples, permitted by the format. */
-#define FLAC__MIN_BLOCK_SIZE (16u)
-
-/** The maximum block size, in samples, permitted by the format. */
-#define FLAC__MAX_BLOCK_SIZE (65535u)
-
-/** The maximum block size, in samples, permitted by the FLAC subset for
- * sample rates up to 48kHz. */
-#define FLAC__SUBSET_MAX_BLOCK_SIZE_48000HZ (4608u)
-
-/** The maximum number of channels permitted by the format. */
-#define FLAC__MAX_CHANNELS (8u)
-
-/** The minimum sample resolution permitted by the format. */
-#define FLAC__MIN_BITS_PER_SAMPLE (4u)
-
-/** The maximum sample resolution permitted by the format. */
-#define FLAC__MAX_BITS_PER_SAMPLE (32u)
-
-/** The maximum sample resolution permitted by libFLAC.
- *
- * \warning
- * FLAC__MAX_BITS_PER_SAMPLE is the limit of the FLAC format. However,
- * the reference encoder/decoder is currently limited to 24 bits because
- * of prevalent 32-bit math, so make sure and use this value when
- * appropriate.
- */
-#define FLAC__REFERENCE_CODEC_MAX_BITS_PER_SAMPLE (24u)
-
-/** The maximum sample rate permitted by the format. The value is
- * ((2 ^ 16) - 1) * 10; see <A HREF="../format.html">FLAC format</A>
- * as to why.
- */
-#define FLAC__MAX_SAMPLE_RATE (655350u)
-
-/** The maximum LPC order permitted by the format. */
-#define FLAC__MAX_LPC_ORDER (32u)
-
-/** The maximum LPC order permitted by the FLAC subset for sample rates
- * up to 48kHz. */
-#define FLAC__SUBSET_MAX_LPC_ORDER_48000HZ (12u)
-
-/** The minimum quantized linear predictor coefficient precision
- * permitted by the format.
- */
-#define FLAC__MIN_QLP_COEFF_PRECISION (5u)
-
-/** The maximum quantized linear predictor coefficient precision
- * permitted by the format.
- */
-#define FLAC__MAX_QLP_COEFF_PRECISION (15u)
-
-/** The maximum order of the fixed predictors permitted by the format. */
-#define FLAC__MAX_FIXED_ORDER (4u)
-
-/** The maximum Rice partition order permitted by the format. */
-#define FLAC__MAX_RICE_PARTITION_ORDER (15u)
-
-/** The maximum Rice partition order permitted by the FLAC Subset. */
-#define FLAC__SUBSET_MAX_RICE_PARTITION_ORDER (8u)
-
-/** The version string of the release, stamped onto the libraries and binaries.
- *
- * \note
- * This does not correspond to the shared library version number, which
- * is used to determine binary compatibility.
- */
-extern FLAC_API const char *FLAC__VERSION_STRING;
-
-/** The vendor string inserted by the encoder into the VORBIS_COMMENT block.
- * This is a NUL-terminated ASCII string; when inserted into the
- * VORBIS_COMMENT the trailing null is stripped.
- */
-extern FLAC_API const char *FLAC__VENDOR_STRING;
-
-/** The byte string representation of the beginning of a FLAC stream. */
-extern FLAC_API const FLAC__byte FLAC__STREAM_SYNC_STRING[4]; /* = "fLaC" */
-
-/** The 32-bit integer big-endian representation of the beginning of
- * a FLAC stream.
- */
-extern FLAC_API const unsigned FLAC__STREAM_SYNC; /* = 0x664C6143 */
-
-/** The length of the FLAC signature in bits. */
-extern FLAC_API const unsigned FLAC__STREAM_SYNC_LEN; /* = 32 bits */
-
-/** The length of the FLAC signature in bytes. */
-#define FLAC__STREAM_SYNC_LENGTH (4u)
-
-
-/*****************************************************************************
- *
- * Subframe structures
- *
- *****************************************************************************/
-
-/*****************************************************************************/
-
-/** An enumeration of the available entropy coding methods. */
-typedef enum {
- FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE = 0,
- /**< Residual is coded by partitioning into contexts, each with it's own
- * 4-bit Rice parameter. */
-
- FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 = 1
- /**< Residual is coded by partitioning into contexts, each with it's own
- * 5-bit Rice parameter. */
-} FLAC__EntropyCodingMethodType;
-
-/** Maps a FLAC__EntropyCodingMethodType to a C string.
- *
- * Using a FLAC__EntropyCodingMethodType as the index to this array will
- * give the string equivalent. The contents should not be modified.
- */
-extern FLAC_API const char * const FLAC__EntropyCodingMethodTypeString[];
-
-
-/** Contents of a Rice partitioned residual
- */
-typedef struct {
-
- unsigned *parameters;
- /**< The Rice parameters for each context. */
-
- unsigned *raw_bits;
- /**< Widths for escape-coded partitions. Will be non-zero for escaped
- * partitions and zero for unescaped partitions.
- */
-
- unsigned capacity_by_order;
- /**< The capacity of the \a parameters and \a raw_bits arrays
- * specified as an order, i.e. the number of array elements
- * allocated is 2 ^ \a capacity_by_order.
- */
-} FLAC__EntropyCodingMethod_PartitionedRiceContents;
-
-/** Header for a Rice partitioned residual. (c.f. <A HREF="../format.html#partitioned_rice">format specification</A>)
- */
-typedef struct {
-
- unsigned order;
- /**< The partition order, i.e. # of contexts = 2 ^ \a order. */
-
- const FLAC__EntropyCodingMethod_PartitionedRiceContents *contents;
- /**< The context's Rice parameters and/or raw bits. */
-
-} FLAC__EntropyCodingMethod_PartitionedRice;
-
-extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN; /**< == 4 (bits) */
-extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN; /**< == 4 (bits) */
-extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN; /**< == 5 (bits) */
-extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN; /**< == 5 (bits) */
-
-extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER;
-/**< == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN)-1 */
-extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER;
-/**< == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN)-1 */
-
-/** Header for the entropy coding method. (c.f. <A HREF="../format.html#residual">format specification</A>)
- */
-typedef struct {
- FLAC__EntropyCodingMethodType type;
- union {
- FLAC__EntropyCodingMethod_PartitionedRice partitioned_rice;
- } data;
-} FLAC__EntropyCodingMethod;
-
-extern FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_TYPE_LEN; /**< == 2 (bits) */
-
-/*****************************************************************************/
-
-/** An enumeration of the available subframe types. */
-typedef enum {
- FLAC__SUBFRAME_TYPE_CONSTANT = 0, /**< constant signal */
- FLAC__SUBFRAME_TYPE_VERBATIM = 1, /**< uncompressed signal */
- FLAC__SUBFRAME_TYPE_FIXED = 2, /**< fixed polynomial prediction */
- FLAC__SUBFRAME_TYPE_LPC = 3 /**< linear prediction */
-} FLAC__SubframeType;
-
-/** Maps a FLAC__SubframeType to a C string.
- *
- * Using a FLAC__SubframeType as the index to this array will
- * give the string equivalent. The contents should not be modified.
- */
-extern FLAC_API const char * const FLAC__SubframeTypeString[];
-
-
-/** CONSTANT subframe. (c.f. <A HREF="../format.html#subframe_constant">format specification</A>)
- */
-typedef struct {
- FLAC__int32 value; /**< The constant signal value. */
-} FLAC__Subframe_Constant;
-
-
-/** VERBATIM subframe. (c.f. <A HREF="../format.html#subframe_verbatim">format specification</A>)
- */
-typedef struct {
- const FLAC__int32 *data; /**< A pointer to verbatim signal. */
-} FLAC__Subframe_Verbatim;
-
-
-/** FIXED subframe. (c.f. <A HREF="../format.html#subframe_fixed">format specification</A>)
- */
-typedef struct {
- FLAC__EntropyCodingMethod entropy_coding_method;
- /**< The residual coding method. */
-
- unsigned order;
- /**< The polynomial order. */
-
- FLAC__int32 warmup[FLAC__MAX_FIXED_ORDER];
- /**< Warmup samples to prime the predictor, length == order. */
-
- const FLAC__int32 *residual;
- /**< The residual signal, length == (blocksize minus order) samples. */
-} FLAC__Subframe_Fixed;
-
-
-/** LPC subframe. (c.f. <A HREF="../format.html#subframe_lpc">format specification</A>)
- */
-typedef struct {
- FLAC__EntropyCodingMethod entropy_coding_method;
- /**< The residual coding method. */
-
- unsigned order;
- /**< The FIR order. */
-
- unsigned qlp_coeff_precision;
- /**< Quantized FIR filter coefficient precision in bits. */
-
- int quantization_level;
- /**< The qlp coeff shift needed. */
-
- FLAC__int32 qlp_coeff[FLAC__MAX_LPC_ORDER];
- /**< FIR filter coefficients. */
-
- FLAC__int32 warmup[FLAC__MAX_LPC_ORDER];
- /**< Warmup samples to prime the predictor, length == order. */
-
- const FLAC__int32 *residual;
- /**< The residual signal, length == (blocksize minus order) samples. */
-} FLAC__Subframe_LPC;
-
-extern FLAC_API const unsigned FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN; /**< == 4 (bits) */
-extern FLAC_API const unsigned FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN; /**< == 5 (bits) */
-
-
-/** FLAC subframe structure. (c.f. <A HREF="../format.html#subframe">format specification</A>)
- */
-typedef struct {
- FLAC__SubframeType type;
- union {
- FLAC__Subframe_Constant constant;
- FLAC__Subframe_Fixed fixed;
- FLAC__Subframe_LPC lpc;
- FLAC__Subframe_Verbatim verbatim;
- } data;
- unsigned wasted_bits;
-} FLAC__Subframe;
-
-/** == 1 (bit)
- *
- * This used to be a zero-padding bit (hence the name
- * FLAC__SUBFRAME_ZERO_PAD_LEN) but is now a reserved bit. It still has a
- * mandatory value of \c 0 but in the future may take on the value \c 0 or \c 1
- * to mean something else.
- */
-extern FLAC_API const unsigned FLAC__SUBFRAME_ZERO_PAD_LEN;
-extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_LEN; /**< == 6 (bits) */
-extern FLAC_API const unsigned FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN; /**< == 1 (bit) */
-
-extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_CONSTANT_BYTE_ALIGNED_MASK; /**< = 0x00 */
-extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK; /**< = 0x02 */
-extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_FIXED_BYTE_ALIGNED_MASK; /**< = 0x10 */
-extern FLAC_API const unsigned FLAC__SUBFRAME_TYPE_LPC_BYTE_ALIGNED_MASK; /**< = 0x40 */
-
-/*****************************************************************************/
-
-
-/*****************************************************************************
- *
- * Frame structures
- *
- *****************************************************************************/
-
-/** An enumeration of the available channel assignments. */
-typedef enum {
- FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT = 0, /**< independent channels */
- FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE = 1, /**< left+side stereo */
- FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE = 2, /**< right+side stereo */
- FLAC__CHANNEL_ASSIGNMENT_MID_SIDE = 3 /**< mid+side stereo */
-} FLAC__ChannelAssignment;
-
-/** Maps a FLAC__ChannelAssignment to a C string.
- *
- * Using a FLAC__ChannelAssignment as the index to this array will
- * give the string equivalent. The contents should not be modified.
- */
-extern FLAC_API const char * const FLAC__ChannelAssignmentString[];
-
-/** An enumeration of the possible frame numbering methods. */
-typedef enum {
- FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER, /**< number contains the frame number */
- FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER /**< number contains the sample number of first sample in frame */
-} FLAC__FrameNumberType;
-
-/** Maps a FLAC__FrameNumberType to a C string.
- *
- * Using a FLAC__FrameNumberType as the index to this array will
- * give the string equivalent. The contents should not be modified.
- */
-extern FLAC_API const char * const FLAC__FrameNumberTypeString[];
-
-
-/** FLAC frame header structure. (c.f. <A HREF="../format.html#frame_header">format specification</A>)
- */
-typedef struct {
- unsigned blocksize;
- /**< The number of samples per subframe. */
-
- unsigned sample_rate;
- /**< The sample rate in Hz. */
-
- unsigned channels;
- /**< The number of channels (== number of subframes). */
-
- FLAC__ChannelAssignment channel_assignment;
- /**< The channel assignment for the frame. */
-
- unsigned bits_per_sample;
- /**< The sample resolution. */
-
- FLAC__FrameNumberType number_type;
- /**< The numbering scheme used for the frame. As a convenience, the
- * decoder will always convert a frame number to a sample number because
- * the rules are complex. */
-
- union {
- FLAC__uint32 frame_number;
- FLAC__uint64 sample_number;
- } number;
- /**< The frame number or sample number of first sample in frame;
- * use the \a number_type value to determine which to use. */
-
- FLAC__uint8 crc;
- /**< CRC-8 (polynomial = x^8 + x^2 + x^1 + x^0, initialized with 0)
- * of the raw frame header bytes, meaning everything before the CRC byte
- * including the sync code.
- */
-} FLAC__FrameHeader;
-
-extern FLAC_API const unsigned FLAC__FRAME_HEADER_SYNC; /**< == 0x3ffe; the frame header sync code */
-extern FLAC_API const unsigned FLAC__FRAME_HEADER_SYNC_LEN; /**< == 14 (bits) */
-extern FLAC_API const unsigned FLAC__FRAME_HEADER_RESERVED_LEN; /**< == 1 (bits) */
-extern FLAC_API const unsigned FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN; /**< == 1 (bits) */
-extern FLAC_API const unsigned FLAC__FRAME_HEADER_BLOCK_SIZE_LEN; /**< == 4 (bits) */
-extern FLAC_API const unsigned FLAC__FRAME_HEADER_SAMPLE_RATE_LEN; /**< == 4 (bits) */
-extern FLAC_API const unsigned FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN; /**< == 4 (bits) */
-extern FLAC_API const unsigned FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN; /**< == 3 (bits) */
-extern FLAC_API const unsigned FLAC__FRAME_HEADER_ZERO_PAD_LEN; /**< == 1 (bit) */
-extern FLAC_API const unsigned FLAC__FRAME_HEADER_CRC_LEN; /**< == 8 (bits) */
-
-
-/** FLAC frame footer structure. (c.f. <A HREF="../format.html#frame_footer">format specification</A>)
- */
-typedef struct {
- FLAC__uint16 crc;
- /**< CRC-16 (polynomial = x^16 + x^15 + x^2 + x^0, initialized with
- * 0) of the bytes before the crc, back to and including the frame header
- * sync code.
- */
-} FLAC__FrameFooter;
-
-extern FLAC_API const unsigned FLAC__FRAME_FOOTER_CRC_LEN; /**< == 16 (bits) */
-
-
-/** FLAC frame structure. (c.f. <A HREF="../format.html#frame">format specification</A>)
- */
-typedef struct {
- FLAC__FrameHeader header;
- FLAC__Subframe subframes[FLAC__MAX_CHANNELS];
- FLAC__FrameFooter footer;
-} FLAC__Frame;
-
-/*****************************************************************************/
-
-
-/*****************************************************************************
- *
- * Meta-data structures
- *
- *****************************************************************************/
-
-/** An enumeration of the available metadata block types. */
-typedef enum {
-
- FLAC__METADATA_TYPE_STREAMINFO = 0,
- /**< <A HREF="../format.html#metadata_block_streaminfo">STREAMINFO</A> block */
-
- FLAC__METADATA_TYPE_PADDING = 1,
- /**< <A HREF="../format.html#metadata_block_padding">PADDING</A> block */
-
- FLAC__METADATA_TYPE_APPLICATION = 2,
- /**< <A HREF="../format.html#metadata_block_application">APPLICATION</A> block */
-
- FLAC__METADATA_TYPE_SEEKTABLE = 3,
- /**< <A HREF="../format.html#metadata_block_seektable">SEEKTABLE</A> block */
-
- FLAC__METADATA_TYPE_VORBIS_COMMENT = 4,
- /**< <A HREF="../format.html#metadata_block_vorbis_comment">VORBISCOMMENT</A> block (a.k.a. FLAC tags) */
-
- FLAC__METADATA_TYPE_CUESHEET = 5,
- /**< <A HREF="../format.html#metadata_block_cuesheet">CUESHEET</A> block */
-
- FLAC__METADATA_TYPE_PICTURE = 6,
- /**< <A HREF="../format.html#metadata_block_picture">PICTURE</A> block */
-
- FLAC__METADATA_TYPE_UNDEFINED = 7
- /**< marker to denote beginning of undefined type range; this number will increase as new metadata types are added */
-
-} FLAC__MetadataType;
-
-/** Maps a FLAC__MetadataType to a C string.
- *
- * Using a FLAC__MetadataType as the index to this array will
- * give the string equivalent. The contents should not be modified.
- */
-extern FLAC_API const char * const FLAC__MetadataTypeString[];
-
-
-/** FLAC STREAMINFO structure. (c.f. <A HREF="../format.html#metadata_block_streaminfo">format specification</A>)
- */
-typedef struct {
- unsigned min_blocksize, max_blocksize;
- unsigned min_framesize, max_framesize;
- unsigned sample_rate;
- unsigned channels;
- unsigned bits_per_sample;
- FLAC__uint64 total_samples;
- FLAC__byte md5sum[16];
-} FLAC__StreamMetadata_StreamInfo;
-
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN; /**< == 16 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN; /**< == 16 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN; /**< == 24 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN; /**< == 24 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN; /**< == 20 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN; /**< == 3 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN; /**< == 5 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN; /**< == 36 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MD5SUM_LEN; /**< == 128 (bits) */
-
-/** The total stream length of the STREAMINFO block in bytes. */
-#define FLAC__STREAM_METADATA_STREAMINFO_LENGTH (34u)
-
-/** FLAC PADDING structure. (c.f. <A HREF="../format.html#metadata_block_padding">format specification</A>)
- */
-typedef struct {
- int dummy;
- /**< Conceptually this is an empty struct since we don't store the
- * padding bytes. Empty structs are not allowed by some C compilers,
- * hence the dummy.
- */
-} FLAC__StreamMetadata_Padding;
-
-
-/** FLAC APPLICATION structure. (c.f. <A HREF="../format.html#metadata_block_application">format specification</A>)
- */
-typedef struct {
- FLAC__byte id[4];
- FLAC__byte *data;
-} FLAC__StreamMetadata_Application;
-
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_APPLICATION_ID_LEN; /**< == 32 (bits) */
-
-/** SeekPoint structure used in SEEKTABLE blocks. (c.f. <A HREF="../format.html#seekpoint">format specification</A>)
- */
-typedef struct {
- FLAC__uint64 sample_number;
- /**< The sample number of the target frame. */
-
- FLAC__uint64 stream_offset;
- /**< The offset, in bytes, of the target frame with respect to
- * beginning of the first frame. */
-
- unsigned frame_samples;
- /**< The number of samples in the target frame. */
-} FLAC__StreamMetadata_SeekPoint;
-
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN; /**< == 64 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN; /**< == 64 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN; /**< == 16 (bits) */
-
-/** The total stream length of a seek point in bytes. */
-#define FLAC__STREAM_METADATA_SEEKPOINT_LENGTH (18u)
-
-/** The value used in the \a sample_number field of
- * FLAC__StreamMetadataSeekPoint used to indicate a placeholder
- * point (== 0xffffffffffffffff).
- */
-extern FLAC_API const FLAC__uint64 FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER;
-
-
-/** FLAC SEEKTABLE structure. (c.f. <A HREF="../format.html#metadata_block_seektable">format specification</A>)
- *
- * \note From the format specification:
- * - The seek points must be sorted by ascending sample number.
- * - Each seek point's sample number must be the first sample of the
- * target frame.
- * - Each seek point's sample number must be unique within the table.
- * - Existence of a SEEKTABLE block implies a correct setting of
- * total_samples in the stream_info block.
- * - Behavior is undefined when more than one SEEKTABLE block is
- * present in a stream.
- */
-typedef struct {
- unsigned num_points;
- FLAC__StreamMetadata_SeekPoint *points;
-} FLAC__StreamMetadata_SeekTable;
-
-
-/** Vorbis comment entry structure used in VORBIS_COMMENT blocks. (c.f. <A HREF="../format.html#metadata_block_vorbis_comment">format specification</A>)
- *
- * For convenience, the APIs maintain a trailing NUL character at the end of
- * \a entry which is not counted toward \a length, i.e.
- * \code strlen(entry) == length \endcode
- */
-typedef struct {
- FLAC__uint32 length;
- FLAC__byte *entry;
-} FLAC__StreamMetadata_VorbisComment_Entry;
-
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN; /**< == 32 (bits) */
-
-
-/** FLAC VORBIS_COMMENT structure. (c.f. <A HREF="../format.html#metadata_block_vorbis_comment">format specification</A>)
- */
-typedef struct {
- FLAC__StreamMetadata_VorbisComment_Entry vendor_string;
- FLAC__uint32 num_comments;
- FLAC__StreamMetadata_VorbisComment_Entry *comments;
-} FLAC__StreamMetadata_VorbisComment;
-
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN; /**< == 32 (bits) */
-
-
-/** FLAC CUESHEET track index structure. (See the
- * <A HREF="../format.html#cuesheet_track_index">format specification</A> for
- * the full description of each field.)
- */
-typedef struct {
- FLAC__uint64 offset;
- /**< Offset in samples, relative to the track offset, of the index
- * point.
- */
-
- FLAC__byte number;
- /**< The index point number. */
-} FLAC__StreamMetadata_CueSheet_Index;
-
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN; /**< == 64 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN; /**< == 8 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN; /**< == 3*8 (bits) */
-
-
-/** FLAC CUESHEET track structure. (See the
- * <A HREF="../format.html#cuesheet_track">format specification</A> for
- * the full description of each field.)
- */
-typedef struct {
- FLAC__uint64 offset;
- /**< Track offset in samples, relative to the beginning of the FLAC audio stream. */
-
- FLAC__byte number;
- /**< The track number. */
-
- char isrc[13];
- /**< Track ISRC. This is a 12-digit alphanumeric code plus a trailing \c NUL byte */
-
- unsigned type:1;
- /**< The track type: 0 for audio, 1 for non-audio. */
-
- unsigned pre_emphasis:1;
- /**< The pre-emphasis flag: 0 for no pre-emphasis, 1 for pre-emphasis. */
-
- FLAC__byte num_indices;
- /**< The number of track index points. */
-
- FLAC__StreamMetadata_CueSheet_Index *indices;
- /**< NULL if num_indices == 0, else pointer to array of index points. */
-
-} FLAC__StreamMetadata_CueSheet_Track;
-
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN; /**< == 64 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN; /**< == 8 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN; /**< == 12*8 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN; /**< == 1 (bit) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN; /**< == 1 (bit) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN; /**< == 6+13*8 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN; /**< == 8 (bits) */
-
-
-/** FLAC CUESHEET structure. (See the
- * <A HREF="../format.html#metadata_block_cuesheet">format specification</A>
- * for the full description of each field.)
- */
-typedef struct {
- char media_catalog_number[129];
- /**< Media catalog number, in ASCII printable characters 0x20-0x7e. In
- * general, the media catalog number may be 0 to 128 bytes long; any
- * unused characters should be right-padded with NUL characters.
- */
-
- FLAC__uint64 lead_in;
- /**< The number of lead-in samples. */
-
- FLAC__bool is_cd;
- /**< \c true if CUESHEET corresponds to a Compact Disc, else \c false. */
-
- unsigned num_tracks;
- /**< The number of tracks. */
-
- FLAC__StreamMetadata_CueSheet_Track *tracks;
- /**< NULL if num_tracks == 0, else pointer to array of tracks. */
-
-} FLAC__StreamMetadata_CueSheet;
-
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN; /**< == 128*8 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN; /**< == 64 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN; /**< == 1 (bit) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN; /**< == 7+258*8 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN; /**< == 8 (bits) */
-
-
-/** An enumeration of the PICTURE types (see FLAC__StreamMetadataPicture and id3 v2.4 APIC tag). */
-typedef enum {
- FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER = 0, /**< Other */
- FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD = 1, /**< 32x32 pixels 'file icon' (PNG only) */
- FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON = 2, /**< Other file icon */
- FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER = 3, /**< Cover (front) */
- FLAC__STREAM_METADATA_PICTURE_TYPE_BACK_COVER = 4, /**< Cover (back) */
- FLAC__STREAM_METADATA_PICTURE_TYPE_LEAFLET_PAGE = 5, /**< Leaflet page */
- FLAC__STREAM_METADATA_PICTURE_TYPE_MEDIA = 6, /**< Media (e.g. label side of CD) */
- FLAC__STREAM_METADATA_PICTURE_TYPE_LEAD_ARTIST = 7, /**< Lead artist/lead performer/soloist */
- FLAC__STREAM_METADATA_PICTURE_TYPE_ARTIST = 8, /**< Artist/performer */
- FLAC__STREAM_METADATA_PICTURE_TYPE_CONDUCTOR = 9, /**< Conductor */
- FLAC__STREAM_METADATA_PICTURE_TYPE_BAND = 10, /**< Band/Orchestra */
- FLAC__STREAM_METADATA_PICTURE_TYPE_COMPOSER = 11, /**< Composer */
- FLAC__STREAM_METADATA_PICTURE_TYPE_LYRICIST = 12, /**< Lyricist/text writer */
- FLAC__STREAM_METADATA_PICTURE_TYPE_RECORDING_LOCATION = 13, /**< Recording Location */
- FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_RECORDING = 14, /**< During recording */
- FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_PERFORMANCE = 15, /**< During performance */
- FLAC__STREAM_METADATA_PICTURE_TYPE_VIDEO_SCREEN_CAPTURE = 16, /**< Movie/video screen capture */
- FLAC__STREAM_METADATA_PICTURE_TYPE_FISH = 17, /**< A bright coloured fish */
- FLAC__STREAM_METADATA_PICTURE_TYPE_ILLUSTRATION = 18, /**< Illustration */
- FLAC__STREAM_METADATA_PICTURE_TYPE_BAND_LOGOTYPE = 19, /**< Band/artist logotype */
- FLAC__STREAM_METADATA_PICTURE_TYPE_PUBLISHER_LOGOTYPE = 20, /**< Publisher/Studio logotype */
- FLAC__STREAM_METADATA_PICTURE_TYPE_UNDEFINED
-} FLAC__StreamMetadata_Picture_Type;
-
-/** Maps a FLAC__StreamMetadata_Picture_Type to a C string.
- *
- * Using a FLAC__StreamMetadata_Picture_Type as the index to this array
- * will give the string equivalent. The contents should not be
- * modified.
- */
-extern FLAC_API const char * const FLAC__StreamMetadata_Picture_TypeString[];
-
-/** FLAC PICTURE structure. (See the
- * <A HREF="../format.html#metadata_block_picture">format specification</A>
- * for the full description of each field.)
- */
-typedef struct {
- FLAC__StreamMetadata_Picture_Type type;
- /**< The kind of picture stored. */
-
- char *mime_type;
- /**< Picture data's MIME type, in ASCII printable characters
- * 0x20-0x7e, NUL terminated. For best compatibility with players,
- * use picture data of MIME type \c image/jpeg or \c image/png. A
- * MIME type of '-->' is also allowed, in which case the picture
- * data should be a complete URL. In file storage, the MIME type is
- * stored as a 32-bit length followed by the ASCII string with no NUL
- * terminator, but is converted to a plain C string in this structure
- * for convenience.
- */
-
- FLAC__byte *description;
- /**< Picture's description in UTF-8, NUL terminated. In file storage,
- * the description is stored as a 32-bit length followed by the UTF-8
- * string with no NUL terminator, but is converted to a plain C string
- * in this structure for convenience.
- */
-
- FLAC__uint32 width;
- /**< Picture's width in pixels. */
-
- FLAC__uint32 height;
- /**< Picture's height in pixels. */
-
- FLAC__uint32 depth;
- /**< Picture's color depth in bits-per-pixel. */
-
- FLAC__uint32 colors;
- /**< For indexed palettes (like GIF), picture's number of colors (the
- * number of palette entries), or \c 0 for non-indexed (i.e. 2^depth).
- */
-
- FLAC__uint32 data_length;
- /**< Length of binary picture data in bytes. */
-
- FLAC__byte *data;
- /**< Binary picture data. */
-
-} FLAC__StreamMetadata_Picture;
-
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_TYPE_LEN; /**< == 32 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN; /**< == 32 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN; /**< == 32 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN; /**< == 32 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN; /**< == 32 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN; /**< == 32 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_COLORS_LEN; /**< == 32 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN; /**< == 32 (bits) */
-
-
-/** Structure that is used when a metadata block of unknown type is loaded.
- * The contents are opaque. The structure is used only internally to
- * correctly handle unknown metadata.
- */
-typedef struct {
- FLAC__byte *data;
-} FLAC__StreamMetadata_Unknown;
-
-
-/** FLAC metadata block structure. (c.f. <A HREF="../format.html#metadata_block">format specification</A>)
- */
-typedef struct {
- FLAC__MetadataType type;
- /**< The type of the metadata block; used determine which member of the
- * \a data union to dereference. If type >= FLAC__METADATA_TYPE_UNDEFINED
- * then \a data.unknown must be used. */
-
- FLAC__bool is_last;
- /**< \c true if this metadata block is the last, else \a false */
-
- unsigned length;
- /**< Length, in bytes, of the block data as it appears in the stream. */
-
- union {
- FLAC__StreamMetadata_StreamInfo stream_info;
- FLAC__StreamMetadata_Padding padding;
- FLAC__StreamMetadata_Application application;
- FLAC__StreamMetadata_SeekTable seek_table;
- FLAC__StreamMetadata_VorbisComment vorbis_comment;
- FLAC__StreamMetadata_CueSheet cue_sheet;
- FLAC__StreamMetadata_Picture picture;
- FLAC__StreamMetadata_Unknown unknown;
- } data;
- /**< Polymorphic block data; use the \a type value to determine which
- * to use. */
-} FLAC__StreamMetadata;
-
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_IS_LAST_LEN; /**< == 1 (bit) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_TYPE_LEN; /**< == 7 (bits) */
-extern FLAC_API const unsigned FLAC__STREAM_METADATA_LENGTH_LEN; /**< == 24 (bits) */
-
-/** The total stream length of a metadata block header in bytes. */
-#define FLAC__STREAM_METADATA_HEADER_LENGTH (4u)
-
-/*****************************************************************************/
-
-
-/*****************************************************************************
- *
- * Utility functions
- *
- *****************************************************************************/
-
-/** Tests that a sample rate is valid for FLAC.
- *
- * \param sample_rate The sample rate to test for compliance.
- * \retval FLAC__bool
- * \c true if the given sample rate conforms to the specification, else
- * \c false.
- */
-FLAC_API FLAC__bool FLAC__format_sample_rate_is_valid(unsigned sample_rate);
-
-/** Tests that a blocksize at the given sample rate is valid for the FLAC
- * subset.
- *
- * \param blocksize The blocksize to test for compliance.
- * \param sample_rate The sample rate is needed, since the valid subset
- * blocksize depends on the sample rate.
- * \retval FLAC__bool
- * \c true if the given blocksize conforms to the specification for the
- * subset at the given sample rate, else \c false.
- */
-FLAC_API FLAC__bool FLAC__format_blocksize_is_subset(unsigned blocksize, unsigned sample_rate);
-
-/** Tests that a sample rate is valid for the FLAC subset. The subset rules
- * for valid sample rates are slightly more complex since the rate has to
- * be expressible completely in the frame header.
- *
- * \param sample_rate The sample rate to test for compliance.
- * \retval FLAC__bool
- * \c true if the given sample rate conforms to the specification for the
- * subset, else \c false.
- */
-FLAC_API FLAC__bool FLAC__format_sample_rate_is_subset(unsigned sample_rate);
-
-/** Check a Vorbis comment entry name to see if it conforms to the Vorbis
- * comment specification.
- *
- * Vorbis comment names must be composed only of characters from
- * [0x20-0x3C,0x3E-0x7D].
- *
- * \param name A NUL-terminated string to be checked.
- * \assert
- * \code name != NULL \endcode
- * \retval FLAC__bool
- * \c false if entry name is illegal, else \c true.
- */
-FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_name_is_legal(const char *name);
-
-/** Check a Vorbis comment entry value to see if it conforms to the Vorbis
- * comment specification.
- *
- * Vorbis comment values must be valid UTF-8 sequences.
- *
- * \param value A string to be checked.
- * \param length A the length of \a value in bytes. May be
- * \c (unsigned)(-1) to indicate that \a value is a plain
- * UTF-8 NUL-terminated string.
- * \assert
- * \code value != NULL \endcode
- * \retval FLAC__bool
- * \c false if entry name is illegal, else \c true.
- */
-FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_value_is_legal(const FLAC__byte *value, unsigned length);
-
-/** Check a Vorbis comment entry to see if it conforms to the Vorbis
- * comment specification.
- *
- * Vorbis comment entries must be of the form 'name=value', and 'name' and
- * 'value' must be legal according to
- * FLAC__format_vorbiscomment_entry_name_is_legal() and
- * FLAC__format_vorbiscomment_entry_value_is_legal() respectively.
- *
- * \param entry An entry to be checked.
- * \param length The length of \a entry in bytes.
- * \assert
- * \code value != NULL \endcode
- * \retval FLAC__bool
- * \c false if entry name is illegal, else \c true.
- */
-FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_is_legal(const FLAC__byte *entry, unsigned length);
-
-/** Check a seek table to see if it conforms to the FLAC specification.
- * See the format specification for limits on the contents of the
- * seek table.
- *
- * \param seek_table A pointer to a seek table to be checked.
- * \assert
- * \code seek_table != NULL \endcode
- * \retval FLAC__bool
- * \c false if seek table is illegal, else \c true.
- */
-FLAC_API FLAC__bool FLAC__format_seektable_is_legal(const FLAC__StreamMetadata_SeekTable *seek_table);
-
-/** Sort a seek table's seek points according to the format specification.
- * This includes a "unique-ification" step to remove duplicates, i.e.
- * seek points with identical \a sample_number values. Duplicate seek
- * points are converted into placeholder points and sorted to the end of
- * the table.
- *
- * \param seek_table A pointer to a seek table to be sorted.
- * \assert
- * \code seek_table != NULL \endcode
- * \retval unsigned
- * The number of duplicate seek points converted into placeholders.
- */
-FLAC_API unsigned FLAC__format_seektable_sort(FLAC__StreamMetadata_SeekTable *seek_table);
-
-/** Check a cue sheet to see if it conforms to the FLAC specification.
- * See the format specification for limits on the contents of the
- * cue sheet.
- *
- * \param cue_sheet A pointer to an existing cue sheet to be checked.
- * \param check_cd_da_subset If \c true, check CUESHEET against more
- * stringent requirements for a CD-DA (audio) disc.
- * \param violation Address of a pointer to a string. If there is a
- * violation, a pointer to a string explanation of the
- * violation will be returned here. \a violation may be
- * \c NULL if you don't need the returned string. Do not
- * free the returned string; it will always point to static
- * data.
- * \assert
- * \code cue_sheet != NULL \endcode
- * \retval FLAC__bool
- * \c false if cue sheet is illegal, else \c true.
- */
-FLAC_API FLAC__bool FLAC__format_cuesheet_is_legal(const FLAC__StreamMetadata_CueSheet *cue_sheet, FLAC__bool check_cd_da_subset, const char **violation);
-
-/** Check picture data to see if it conforms to the FLAC specification.
- * See the format specification for limits on the contents of the
- * PICTURE block.
- *
- * \param picture A pointer to existing picture data to be checked.
- * \param violation Address of a pointer to a string. If there is a
- * violation, a pointer to a string explanation of the
- * violation will be returned here. \a violation may be
- * \c NULL if you don't need the returned string. Do not
- * free the returned string; it will always point to static
- * data.
- * \assert
- * \code picture != NULL \endcode
- * \retval FLAC__bool
- * \c false if picture data is illegal, else \c true.
- */
-FLAC_API FLAC__bool FLAC__format_picture_is_legal(const FLAC__StreamMetadata_Picture *picture, const char **violation);
-
-/* \} */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/src/thirdparty/libflac/include/FLAC/metadata.h b/src/thirdparty/libflac/include/FLAC/metadata.h
deleted file mode 100644
index 3452e8fb1..000000000
--- a/src/thirdparty/libflac/include/FLAC/metadata.h
+++ /dev/null
@@ -1,2181 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__METADATA_H
-#define FLAC__METADATA_H
-
-#include <sys/types.h> /* for off_t */
-#include "export.h"
-#include "callback.h"
-#include "format.h"
-
-/* --------------------------------------------------------------------
- (For an example of how all these routines are used, see the source
- code for the unit tests in src/test_libFLAC/metadata_*.c, or
- metaflac in src/metaflac/)
- ------------------------------------------------------------------*/
-
-/** \file include/FLAC/metadata.h
- *
- * \brief
- * This module provides functions for creating and manipulating FLAC
- * metadata blocks in memory, and three progressively more powerful
- * interfaces for traversing and editing metadata in FLAC files.
- *
- * See the detailed documentation for each interface in the
- * \link flac_metadata metadata \endlink module.
- */
-
-/** \defgroup flac_metadata FLAC/metadata.h: metadata interfaces
- * \ingroup flac
- *
- * \brief
- * This module provides functions for creating and manipulating FLAC
- * metadata blocks in memory, and three progressively more powerful
- * interfaces for traversing and editing metadata in native FLAC files.
- * Note that currently only the Chain interface (level 2) supports Ogg
- * FLAC files, and it is read-only i.e. no writing back changed
- * metadata to file.
- *
- * There are three metadata interfaces of increasing complexity:
- *
- * Level 0:
- * Read-only access to the STREAMINFO, VORBIS_COMMENT, CUESHEET, and
- * PICTURE blocks.
- *
- * Level 1:
- * Read-write access to all metadata blocks. This level is write-
- * efficient in most cases (more on this below), and uses less memory
- * than level 2.
- *
- * Level 2:
- * Read-write access to all metadata blocks. This level is write-
- * efficient in all cases, but uses more memory since all metadata for
- * the whole file is read into memory and manipulated before writing
- * out again.
- *
- * What do we mean by efficient? Since FLAC metadata appears at the
- * beginning of the file, when writing metadata back to a FLAC file
- * it is possible to grow or shrink the metadata such that the entire
- * file must be rewritten. However, if the size remains the same during
- * changes or PADDING blocks are utilized, only the metadata needs to be
- * overwritten, which is much faster.
- *
- * Efficient means the whole file is rewritten at most one time, and only
- * when necessary. Level 1 is not efficient only in the case that you
- * cause more than one metadata block to grow or shrink beyond what can
- * be accomodated by padding. In this case you should probably use level
- * 2, which allows you to edit all the metadata for a file in memory and
- * write it out all at once.
- *
- * All levels know how to skip over and not disturb an ID3v2 tag at the
- * front of the file.
- *
- * All levels access files via their filenames. In addition, level 2
- * has additional alternative read and write functions that take an I/O
- * handle and callbacks, for situations where access by filename is not
- * possible.
- *
- * In addition to the three interfaces, this module defines functions for
- * creating and manipulating various metadata objects in memory. As we see
- * from the Format module, FLAC metadata blocks in memory are very primitive
- * structures for storing information in an efficient way. Reading
- * information from the structures is easy but creating or modifying them
- * directly is more complex. The metadata object routines here facilitate
- * this by taking care of the consistency and memory management drudgery.
- *
- * Unless you will be using the level 1 or 2 interfaces to modify existing
- * metadata however, you will not probably not need these.
- *
- * From a dependency standpoint, none of the encoders or decoders require
- * the metadata module. This is so that embedded users can strip out the
- * metadata module from libFLAC to reduce the size and complexity.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/** \defgroup flac_metadata_level0 FLAC/metadata.h: metadata level 0 interface
- * \ingroup flac_metadata
- *
- * \brief
- * The level 0 interface consists of individual routines to read the
- * STREAMINFO, VORBIS_COMMENT, CUESHEET, and PICTURE blocks, requiring
- * only a filename.
- *
- * They try to skip any ID3v2 tag at the head of the file.
- *
- * \{
- */
-
-/** Read the STREAMINFO metadata block of the given FLAC file. This function
- * will try to skip any ID3v2 tag at the head of the file.
- *
- * \param filename The path to the FLAC file to read.
- * \param streaminfo A pointer to space for the STREAMINFO block. Since
- * FLAC__StreamMetadata is a simple structure with no
- * memory allocation involved, you pass the address of
- * an existing structure. It need not be initialized.
- * \assert
- * \code filename != NULL \endcode
- * \code streaminfo != NULL \endcode
- * \retval FLAC__bool
- * \c true if a valid STREAMINFO block was read from \a filename. Returns
- * \c false if there was a memory allocation error, a file decoder error,
- * or the file contained no STREAMINFO block. (A memory allocation error
- * is possible because this function must set up a file decoder.)
- */
-FLAC_API FLAC__bool FLAC__metadata_get_streaminfo(const char *filename, FLAC__StreamMetadata *streaminfo);
-
-/** Read the VORBIS_COMMENT metadata block of the given FLAC file. This
- * function will try to skip any ID3v2 tag at the head of the file.
- *
- * \param filename The path to the FLAC file to read.
- * \param tags The address where the returned pointer will be
- * stored. The \a tags object must be deleted by
- * the caller using FLAC__metadata_object_delete().
- * \assert
- * \code filename != NULL \endcode
- * \code tags != NULL \endcode
- * \retval FLAC__bool
- * \c true if a valid VORBIS_COMMENT block was read from \a filename,
- * and \a *tags will be set to the address of the metadata structure.
- * Returns \c false if there was a memory allocation error, a file
- * decoder error, or the file contained no VORBIS_COMMENT block, and
- * \a *tags will be set to \c NULL.
- */
-FLAC_API FLAC__bool FLAC__metadata_get_tags(const char *filename, FLAC__StreamMetadata **tags);
-
-/** Read the CUESHEET metadata block of the given FLAC file. This
- * function will try to skip any ID3v2 tag at the head of the file.
- *
- * \param filename The path to the FLAC file to read.
- * \param cuesheet The address where the returned pointer will be
- * stored. The \a cuesheet object must be deleted by
- * the caller using FLAC__metadata_object_delete().
- * \assert
- * \code filename != NULL \endcode
- * \code cuesheet != NULL \endcode
- * \retval FLAC__bool
- * \c true if a valid CUESHEET block was read from \a filename,
- * and \a *cuesheet will be set to the address of the metadata
- * structure. Returns \c false if there was a memory allocation
- * error, a file decoder error, or the file contained no CUESHEET
- * block, and \a *cuesheet will be set to \c NULL.
- */
-FLAC_API FLAC__bool FLAC__metadata_get_cuesheet(const char *filename, FLAC__StreamMetadata **cuesheet);
-
-/** Read a PICTURE metadata block of the given FLAC file. This
- * function will try to skip any ID3v2 tag at the head of the file.
- * Since there can be more than one PICTURE block in a file, this
- * function takes a number of parameters that act as constraints to
- * the search. The PICTURE block with the largest area matching all
- * the constraints will be returned, or \a *picture will be set to
- * \c NULL if there was no such block.
- *
- * \param filename The path to the FLAC file to read.
- * \param picture The address where the returned pointer will be
- * stored. The \a picture object must be deleted by
- * the caller using FLAC__metadata_object_delete().
- * \param type The desired picture type. Use \c -1 to mean
- * "any type".
- * \param mime_type The desired MIME type, e.g. "image/jpeg". The
- * string will be matched exactly. Use \c NULL to
- * mean "any MIME type".
- * \param description The desired description. The string will be
- * matched exactly. Use \c NULL to mean "any
- * description".
- * \param max_width The maximum width in pixels desired. Use
- * \c (unsigned)(-1) to mean "any width".
- * \param max_height The maximum height in pixels desired. Use
- * \c (unsigned)(-1) to mean "any height".
- * \param max_depth The maximum color depth in bits-per-pixel desired.
- * Use \c (unsigned)(-1) to mean "any depth".
- * \param max_colors The maximum number of colors desired. Use
- * \c (unsigned)(-1) to mean "any number of colors".
- * \assert
- * \code filename != NULL \endcode
- * \code picture != NULL \endcode
- * \retval FLAC__bool
- * \c true if a valid PICTURE block was read from \a filename,
- * and \a *picture will be set to the address of the metadata
- * structure. Returns \c false if there was a memory allocation
- * error, a file decoder error, or the file contained no PICTURE
- * block, and \a *picture will be set to \c NULL.
- */
-FLAC_API FLAC__bool FLAC__metadata_get_picture(const char *filename, FLAC__StreamMetadata **picture, FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, unsigned max_width, unsigned max_height, unsigned max_depth, unsigned max_colors);
-
-/* \} */
-
-
-/** \defgroup flac_metadata_level1 FLAC/metadata.h: metadata level 1 interface
- * \ingroup flac_metadata
- *
- * \brief
- * The level 1 interface provides read-write access to FLAC file metadata and
- * operates directly on the FLAC file.
- *
- * The general usage of this interface is:
- *
- * - Create an iterator using FLAC__metadata_simple_iterator_new()
- * - Attach it to a file using FLAC__metadata_simple_iterator_init() and check
- * the exit code. Call FLAC__metadata_simple_iterator_is_writable() to
- * see if the file is writable, or only read access is allowed.
- * - Use FLAC__metadata_simple_iterator_next() and
- * FLAC__metadata_simple_iterator_prev() to traverse the blocks.
- * This is does not read the actual blocks themselves.
- * FLAC__metadata_simple_iterator_next() is relatively fast.
- * FLAC__metadata_simple_iterator_prev() is slower since it needs to search
- * forward from the front of the file.
- * - Use FLAC__metadata_simple_iterator_get_block_type() or
- * FLAC__metadata_simple_iterator_get_block() to access the actual data at
- * the current iterator position. The returned object is yours to modify
- * and free.
- * - Use FLAC__metadata_simple_iterator_set_block() to write a modified block
- * back. You must have write permission to the original file. Make sure to
- * read the whole comment to FLAC__metadata_simple_iterator_set_block()
- * below.
- * - Use FLAC__metadata_simple_iterator_insert_block_after() to add new blocks.
- * Use the object creation functions from
- * \link flac_metadata_object here \endlink to generate new objects.
- * - Use FLAC__metadata_simple_iterator_delete_block() to remove the block
- * currently referred to by the iterator, or replace it with padding.
- * - Destroy the iterator with FLAC__metadata_simple_iterator_delete() when
- * finished.
- *
- * \note
- * The FLAC file remains open the whole time between
- * FLAC__metadata_simple_iterator_init() and
- * FLAC__metadata_simple_iterator_delete(), so make sure you are not altering
- * the file during this time.
- *
- * \note
- * Do not modify the \a is_last, \a length, or \a type fields of returned
- * FLAC__StreamMetadata objects. These are managed automatically.
- *
- * \note
- * If any of the modification functions
- * (FLAC__metadata_simple_iterator_set_block(),
- * FLAC__metadata_simple_iterator_delete_block(),
- * FLAC__metadata_simple_iterator_insert_block_after(), etc.) return \c false,
- * you should delete the iterator as it may no longer be valid.
- *
- * \{
- */
-
-struct FLAC__Metadata_SimpleIterator;
-/** The opaque structure definition for the level 1 iterator type.
- * See the
- * \link flac_metadata_level1 metadata level 1 module \endlink
- * for a detailed description.
- */
-typedef struct FLAC__Metadata_SimpleIterator FLAC__Metadata_SimpleIterator;
-
-/** Status type for FLAC__Metadata_SimpleIterator.
- *
- * The iterator's current status can be obtained by calling FLAC__metadata_simple_iterator_status().
- */
-typedef enum {
-
- FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK = 0,
- /**< The iterator is in the normal OK state */
-
- FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT,
- /**< The data passed into a function violated the function's usage criteria */
-
- FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE,
- /**< The iterator could not open the target file */
-
- FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_A_FLAC_FILE,
- /**< The iterator could not find the FLAC signature at the start of the file */
-
- FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_WRITABLE,
- /**< The iterator tried to write to a file that was not writable */
-
- FLAC__METADATA_SIMPLE_ITERATOR_STATUS_BAD_METADATA,
- /**< The iterator encountered input that does not conform to the FLAC metadata specification */
-
- FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR,
- /**< The iterator encountered an error while reading the FLAC file */
-
- FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR,
- /**< The iterator encountered an error while seeking in the FLAC file */
-
- FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR,
- /**< The iterator encountered an error while writing the FLAC file */
-
- FLAC__METADATA_SIMPLE_ITERATOR_STATUS_RENAME_ERROR,
- /**< The iterator encountered an error renaming the FLAC file */
-
- FLAC__METADATA_SIMPLE_ITERATOR_STATUS_UNLINK_ERROR,
- /**< The iterator encountered an error removing the temporary file */
-
- FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR,
- /**< Memory allocation failed */
-
- FLAC__METADATA_SIMPLE_ITERATOR_STATUS_INTERNAL_ERROR
- /**< The caller violated an assertion or an unexpected error occurred */
-
-} FLAC__Metadata_SimpleIteratorStatus;
-
-/** Maps a FLAC__Metadata_SimpleIteratorStatus to a C string.
- *
- * Using a FLAC__Metadata_SimpleIteratorStatus as the index to this array
- * will give the string equivalent. The contents should not be modified.
- */
-extern FLAC_API const char * const FLAC__Metadata_SimpleIteratorStatusString[];
-
-
-/** Create a new iterator instance.
- *
- * \retval FLAC__Metadata_SimpleIterator*
- * \c NULL if there was an error allocating memory, else the new instance.
- */
-FLAC_API FLAC__Metadata_SimpleIterator *FLAC__metadata_simple_iterator_new(void);
-
-/** Free an iterator instance. Deletes the object pointed to by \a iterator.
- *
- * \param iterator A pointer to an existing iterator.
- * \assert
- * \code iterator != NULL \endcode
- */
-FLAC_API void FLAC__metadata_simple_iterator_delete(FLAC__Metadata_SimpleIterator *iterator);
-
-/** Get the current status of the iterator. Call this after a function
- * returns \c false to get the reason for the error. Also resets the status
- * to FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK.
- *
- * \param iterator A pointer to an existing iterator.
- * \assert
- * \code iterator != NULL \endcode
- * \retval FLAC__Metadata_SimpleIteratorStatus
- * The current status of the iterator.
- */
-FLAC_API FLAC__Metadata_SimpleIteratorStatus FLAC__metadata_simple_iterator_status(FLAC__Metadata_SimpleIterator *iterator);
-
-/** Initialize the iterator to point to the first metadata block in the
- * given FLAC file.
- *
- * \param iterator A pointer to an existing iterator.
- * \param filename The path to the FLAC file.
- * \param read_only If \c true, the FLAC file will be opened
- * in read-only mode; if \c false, the FLAC
- * file will be opened for edit even if no
- * edits are performed.
- * \param preserve_file_stats If \c true, the owner and modification
- * time will be preserved even if the FLAC
- * file is written to.
- * \assert
- * \code iterator != NULL \endcode
- * \code filename != NULL \endcode
- * \retval FLAC__bool
- * \c false if a memory allocation error occurs, the file can't be
- * opened, or another error occurs, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_simple_iterator_init(FLAC__Metadata_SimpleIterator *iterator, const char *filename, FLAC__bool read_only, FLAC__bool preserve_file_stats);
-
-/** Returns \c true if the FLAC file is writable. If \c false, calls to
- * FLAC__metadata_simple_iterator_set_block() and
- * FLAC__metadata_simple_iterator_insert_block_after() will fail.
- *
- * \param iterator A pointer to an existing iterator.
- * \assert
- * \code iterator != NULL \endcode
- * \retval FLAC__bool
- * See above.
- */
-FLAC_API FLAC__bool FLAC__metadata_simple_iterator_is_writable(const FLAC__Metadata_SimpleIterator *iterator);
-
-/** Moves the iterator forward one metadata block, returning \c false if
- * already at the end.
- *
- * \param iterator A pointer to an existing initialized iterator.
- * \assert
- * \code iterator != NULL \endcode
- * \a iterator has been successfully initialized with
- * FLAC__metadata_simple_iterator_init()
- * \retval FLAC__bool
- * \c false if already at the last metadata block of the chain, else
- * \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_simple_iterator_next(FLAC__Metadata_SimpleIterator *iterator);
-
-/** Moves the iterator backward one metadata block, returning \c false if
- * already at the beginning.
- *
- * \param iterator A pointer to an existing initialized iterator.
- * \assert
- * \code iterator != NULL \endcode
- * \a iterator has been successfully initialized with
- * FLAC__metadata_simple_iterator_init()
- * \retval FLAC__bool
- * \c false if already at the first metadata block of the chain, else
- * \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_simple_iterator_prev(FLAC__Metadata_SimpleIterator *iterator);
-
-/** Returns a flag telling if the current metadata block is the last.
- *
- * \param iterator A pointer to an existing initialized iterator.
- * \assert
- * \code iterator != NULL \endcode
- * \a iterator has been successfully initialized with
- * FLAC__metadata_simple_iterator_init()
- * \retval FLAC__bool
- * \c true if the current metadata block is the last in the file,
- * else \c false.
- */
-FLAC_API FLAC__bool FLAC__metadata_simple_iterator_is_last(const FLAC__Metadata_SimpleIterator *iterator);
-
-/** Get the offset of the metadata block at the current position. This
- * avoids reading the actual block data which can save time for large
- * blocks.
- *
- * \param iterator A pointer to an existing initialized iterator.
- * \assert
- * \code iterator != NULL \endcode
- * \a iterator has been successfully initialized with
- * FLAC__metadata_simple_iterator_init()
- * \retval off_t
- * The offset of the metadata block at the current iterator position.
- * This is the byte offset relative to the beginning of the file of
- * the current metadata block's header.
- */
-FLAC_API off_t FLAC__metadata_simple_iterator_get_block_offset(const FLAC__Metadata_SimpleIterator *iterator);
-
-/** Get the type of the metadata block at the current position. This
- * avoids reading the actual block data which can save time for large
- * blocks.
- *
- * \param iterator A pointer to an existing initialized iterator.
- * \assert
- * \code iterator != NULL \endcode
- * \a iterator has been successfully initialized with
- * FLAC__metadata_simple_iterator_init()
- * \retval FLAC__MetadataType
- * The type of the metadata block at the current iterator position.
- */
-FLAC_API FLAC__MetadataType FLAC__metadata_simple_iterator_get_block_type(const FLAC__Metadata_SimpleIterator *iterator);
-
-/** Get the length of the metadata block at the current position. This
- * avoids reading the actual block data which can save time for large
- * blocks.
- *
- * \param iterator A pointer to an existing initialized iterator.
- * \assert
- * \code iterator != NULL \endcode
- * \a iterator has been successfully initialized with
- * FLAC__metadata_simple_iterator_init()
- * \retval unsigned
- * The length of the metadata block at the current iterator position.
- * The is same length as that in the
- * <a href="http://flac.sourceforge.net/format.html#metadata_block_header">metadata block header</a>,
- * i.e. the length of the metadata body that follows the header.
- */
-FLAC_API unsigned FLAC__metadata_simple_iterator_get_block_length(const FLAC__Metadata_SimpleIterator *iterator);
-
-/** Get the application ID of the \c APPLICATION block at the current
- * position. This avoids reading the actual block data which can save
- * time for large blocks.
- *
- * \param iterator A pointer to an existing initialized iterator.
- * \param id A pointer to a buffer of at least \c 4 bytes where
- * the ID will be stored.
- * \assert
- * \code iterator != NULL \endcode
- * \code id != NULL \endcode
- * \a iterator has been successfully initialized with
- * FLAC__metadata_simple_iterator_init()
- * \retval FLAC__bool
- * \c true if the ID was successfully read, else \c false, in which
- * case you should check FLAC__metadata_simple_iterator_status() to
- * find out why. If the status is
- * \c FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT, then the
- * current metadata block is not an \c APPLICATION block. Otherwise
- * if the status is
- * \c FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR or
- * \c FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR, an I/O error
- * occurred and the iterator can no longer be used.
- */
-FLAC_API FLAC__bool FLAC__metadata_simple_iterator_get_application_id(FLAC__Metadata_SimpleIterator *iterator, FLAC__byte *id);
-
-/** Get the metadata block at the current position. You can modify the
- * block but must use FLAC__metadata_simple_iterator_set_block() to
- * write it back to the FLAC file.
- *
- * You must call FLAC__metadata_object_delete() on the returned object
- * when you are finished with it.
- *
- * \param iterator A pointer to an existing initialized iterator.
- * \assert
- * \code iterator != NULL \endcode
- * \a iterator has been successfully initialized with
- * FLAC__metadata_simple_iterator_init()
- * \retval FLAC__StreamMetadata*
- * The current metadata block, or \c NULL if there was a memory
- * allocation error.
- */
-FLAC_API FLAC__StreamMetadata *FLAC__metadata_simple_iterator_get_block(FLAC__Metadata_SimpleIterator *iterator);
-
-/** Write a block back to the FLAC file. This function tries to be
- * as efficient as possible; how the block is actually written is
- * shown by the following:
- *
- * Existing block is a STREAMINFO block and the new block is a
- * STREAMINFO block: the new block is written in place. Make sure
- * you know what you're doing when changing the values of a
- * STREAMINFO block.
- *
- * Existing block is a STREAMINFO block and the new block is a
- * not a STREAMINFO block: this is an error since the first block
- * must be a STREAMINFO block. Returns \c false without altering the
- * file.
- *
- * Existing block is not a STREAMINFO block and the new block is a
- * STREAMINFO block: this is an error since there may be only one
- * STREAMINFO block. Returns \c false without altering the file.
- *
- * Existing block and new block are the same length: the existing
- * block will be replaced by the new block, written in place.
- *
- * Existing block is longer than new block: if use_padding is \c true,
- * the existing block will be overwritten in place with the new
- * block followed by a PADDING block, if possible, to make the total
- * size the same as the existing block. Remember that a padding
- * block requires at least four bytes so if the difference in size
- * between the new block and existing block is less than that, the
- * entire file will have to be rewritten, using the new block's
- * exact size. If use_padding is \c false, the entire file will be
- * rewritten, replacing the existing block by the new block.
- *
- * Existing block is shorter than new block: if use_padding is \c true,
- * the function will try and expand the new block into the following
- * PADDING block, if it exists and doing so won't shrink the PADDING
- * block to less than 4 bytes. If there is no following PADDING
- * block, or it will shrink to less than 4 bytes, or use_padding is
- * \c false, the entire file is rewritten, replacing the existing block
- * with the new block. Note that in this case any following PADDING
- * block is preserved as is.
- *
- * After writing the block, the iterator will remain in the same
- * place, i.e. pointing to the new block.
- *
- * \param iterator A pointer to an existing initialized iterator.
- * \param block The block to set.
- * \param use_padding See above.
- * \assert
- * \code iterator != NULL \endcode
- * \a iterator has been successfully initialized with
- * FLAC__metadata_simple_iterator_init()
- * \code block != NULL \endcode
- * \retval FLAC__bool
- * \c true if successful, else \c false.
- */
-FLAC_API FLAC__bool FLAC__metadata_simple_iterator_set_block(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool use_padding);
-
-/** This is similar to FLAC__metadata_simple_iterator_set_block()
- * except that instead of writing over an existing block, it appends
- * a block after the existing block. \a use_padding is again used to
- * tell the function to try an expand into following padding in an
- * attempt to avoid rewriting the entire file.
- *
- * This function will fail and return \c false if given a STREAMINFO
- * block.
- *
- * After writing the block, the iterator will be pointing to the
- * new block.
- *
- * \param iterator A pointer to an existing initialized iterator.
- * \param block The block to set.
- * \param use_padding See above.
- * \assert
- * \code iterator != NULL \endcode
- * \a iterator has been successfully initialized with
- * FLAC__metadata_simple_iterator_init()
- * \code block != NULL \endcode
- * \retval FLAC__bool
- * \c true if successful, else \c false.
- */
-FLAC_API FLAC__bool FLAC__metadata_simple_iterator_insert_block_after(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool use_padding);
-
-/** Deletes the block at the current position. This will cause the
- * entire FLAC file to be rewritten, unless \a use_padding is \c true,
- * in which case the block will be replaced by an equal-sized PADDING
- * block. The iterator will be left pointing to the block before the
- * one just deleted.
- *
- * You may not delete the STREAMINFO block.
- *
- * \param iterator A pointer to an existing initialized iterator.
- * \param use_padding See above.
- * \assert
- * \code iterator != NULL \endcode
- * \a iterator has been successfully initialized with
- * FLAC__metadata_simple_iterator_init()
- * \retval FLAC__bool
- * \c true if successful, else \c false.
- */
-FLAC_API FLAC__bool FLAC__metadata_simple_iterator_delete_block(FLAC__Metadata_SimpleIterator *iterator, FLAC__bool use_padding);
-
-/* \} */
-
-
-/** \defgroup flac_metadata_level2 FLAC/metadata.h: metadata level 2 interface
- * \ingroup flac_metadata
- *
- * \brief
- * The level 2 interface provides read-write access to FLAC file metadata;
- * all metadata is read into memory, operated on in memory, and then written
- * to file, which is more efficient than level 1 when editing multiple blocks.
- *
- * Currently Ogg FLAC is supported for read only, via
- * FLAC__metadata_chain_read_ogg() but a subsequent
- * FLAC__metadata_chain_write() will fail.
- *
- * The general usage of this interface is:
- *
- * - Create a new chain using FLAC__metadata_chain_new(). A chain is a
- * linked list of FLAC metadata blocks.
- * - Read all metadata into the the chain from a FLAC file using
- * FLAC__metadata_chain_read() or FLAC__metadata_chain_read_ogg() and
- * check the status.
- * - Optionally, consolidate the padding using
- * FLAC__metadata_chain_merge_padding() or
- * FLAC__metadata_chain_sort_padding().
- * - Create a new iterator using FLAC__metadata_iterator_new()
- * - Initialize the iterator to point to the first element in the chain
- * using FLAC__metadata_iterator_init()
- * - Traverse the chain using FLAC__metadata_iterator_next and
- * FLAC__metadata_iterator_prev().
- * - Get a block for reading or modification using
- * FLAC__metadata_iterator_get_block(). The pointer to the object
- * inside the chain is returned, so the block is yours to modify.
- * Changes will be reflected in the FLAC file when you write the
- * chain. You can also add and delete blocks (see functions below).
- * - When done, write out the chain using FLAC__metadata_chain_write().
- * Make sure to read the whole comment to the function below.
- * - Delete the chain using FLAC__metadata_chain_delete().
- *
- * \note
- * Even though the FLAC file is not open while the chain is being
- * manipulated, you must not alter the file externally during
- * this time. The chain assumes the FLAC file will not change
- * between the time of FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg()
- * and FLAC__metadata_chain_write().
- *
- * \note
- * Do not modify the is_last, length, or type fields of returned
- * FLAC__StreamMetadata objects. These are managed automatically.
- *
- * \note
- * The metadata objects returned by FLAC__metadata_iterator_get_block()
- * are owned by the chain; do not FLAC__metadata_object_delete() them.
- * In the same way, blocks passed to FLAC__metadata_iterator_set_block()
- * become owned by the chain and they will be deleted when the chain is
- * deleted.
- *
- * \{
- */
-
-struct FLAC__Metadata_Chain;
-/** The opaque structure definition for the level 2 chain type.
- */
-typedef struct FLAC__Metadata_Chain FLAC__Metadata_Chain;
-
-struct FLAC__Metadata_Iterator;
-/** The opaque structure definition for the level 2 iterator type.
- */
-typedef struct FLAC__Metadata_Iterator FLAC__Metadata_Iterator;
-
-typedef enum {
- FLAC__METADATA_CHAIN_STATUS_OK = 0,
- /**< The chain is in the normal OK state */
-
- FLAC__METADATA_CHAIN_STATUS_ILLEGAL_INPUT,
- /**< The data passed into a function violated the function's usage criteria */
-
- FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE,
- /**< The chain could not open the target file */
-
- FLAC__METADATA_CHAIN_STATUS_NOT_A_FLAC_FILE,
- /**< The chain could not find the FLAC signature at the start of the file */
-
- FLAC__METADATA_CHAIN_STATUS_NOT_WRITABLE,
- /**< The chain tried to write to a file that was not writable */
-
- FLAC__METADATA_CHAIN_STATUS_BAD_METADATA,
- /**< The chain encountered input that does not conform to the FLAC metadata specification */
-
- FLAC__METADATA_CHAIN_STATUS_READ_ERROR,
- /**< The chain encountered an error while reading the FLAC file */
-
- FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR,
- /**< The chain encountered an error while seeking in the FLAC file */
-
- FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR,
- /**< The chain encountered an error while writing the FLAC file */
-
- FLAC__METADATA_CHAIN_STATUS_RENAME_ERROR,
- /**< The chain encountered an error renaming the FLAC file */
-
- FLAC__METADATA_CHAIN_STATUS_UNLINK_ERROR,
- /**< The chain encountered an error removing the temporary file */
-
- FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR,
- /**< Memory allocation failed */
-
- FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR,
- /**< The caller violated an assertion or an unexpected error occurred */
-
- FLAC__METADATA_CHAIN_STATUS_INVALID_CALLBACKS,
- /**< One or more of the required callbacks was NULL */
-
- FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH,
- /**< FLAC__metadata_chain_write() was called on a chain read by
- * FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks(),
- * or
- * FLAC__metadata_chain_write_with_callbacks()/FLAC__metadata_chain_write_with_callbacks_and_tempfile()
- * was called on a chain read by
- * FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg().
- * Matching read/write methods must always be used. */
-
- FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL
- /**< FLAC__metadata_chain_write_with_callbacks() was called when the
- * chain write requires a tempfile; use
- * FLAC__metadata_chain_write_with_callbacks_and_tempfile() instead.
- * Or, FLAC__metadata_chain_write_with_callbacks_and_tempfile() was
- * called when the chain write does not require a tempfile; use
- * FLAC__metadata_chain_write_with_callbacks() instead.
- * Always check FLAC__metadata_chain_check_if_tempfile_needed()
- * before writing via callbacks. */
-
-} FLAC__Metadata_ChainStatus;
-
-/** Maps a FLAC__Metadata_ChainStatus to a C string.
- *
- * Using a FLAC__Metadata_ChainStatus as the index to this array
- * will give the string equivalent. The contents should not be modified.
- */
-extern FLAC_API const char * const FLAC__Metadata_ChainStatusString[];
-
-/*********** FLAC__Metadata_Chain ***********/
-
-/** Create a new chain instance.
- *
- * \retval FLAC__Metadata_Chain*
- * \c NULL if there was an error allocating memory, else the new instance.
- */
-FLAC_API FLAC__Metadata_Chain *FLAC__metadata_chain_new(void);
-
-/** Free a chain instance. Deletes the object pointed to by \a chain.
- *
- * \param chain A pointer to an existing chain.
- * \assert
- * \code chain != NULL \endcode
- */
-FLAC_API void FLAC__metadata_chain_delete(FLAC__Metadata_Chain *chain);
-
-/** Get the current status of the chain. Call this after a function
- * returns \c false to get the reason for the error. Also resets the
- * status to FLAC__METADATA_CHAIN_STATUS_OK.
- *
- * \param chain A pointer to an existing chain.
- * \assert
- * \code chain != NULL \endcode
- * \retval FLAC__Metadata_ChainStatus
- * The current status of the chain.
- */
-FLAC_API FLAC__Metadata_ChainStatus FLAC__metadata_chain_status(FLAC__Metadata_Chain *chain);
-
-/** Read all metadata from a FLAC file into the chain.
- *
- * \param chain A pointer to an existing chain.
- * \param filename The path to the FLAC file to read.
- * \assert
- * \code chain != NULL \endcode
- * \code filename != NULL \endcode
- * \retval FLAC__bool
- * \c true if a valid list of metadata blocks was read from
- * \a filename, else \c false. On failure, check the status with
- * FLAC__metadata_chain_status().
- */
-FLAC_API FLAC__bool FLAC__metadata_chain_read(FLAC__Metadata_Chain *chain, const char *filename);
-
-/** Read all metadata from an Ogg FLAC file into the chain.
- *
- * \note Ogg FLAC metadata data writing is not supported yet and
- * FLAC__metadata_chain_write() will fail.
- *
- * \param chain A pointer to an existing chain.
- * \param filename The path to the Ogg FLAC file to read.
- * \assert
- * \code chain != NULL \endcode
- * \code filename != NULL \endcode
- * \retval FLAC__bool
- * \c true if a valid list of metadata blocks was read from
- * \a filename, else \c false. On failure, check the status with
- * FLAC__metadata_chain_status().
- */
-FLAC_API FLAC__bool FLAC__metadata_chain_read_ogg(FLAC__Metadata_Chain *chain, const char *filename);
-
-/** Read all metadata from a FLAC stream into the chain via I/O callbacks.
- *
- * The \a handle need only be open for reading, but must be seekable.
- * The equivalent minimum stdio fopen() file mode is \c "r" (or \c "rb"
- * for Windows).
- *
- * \param chain A pointer to an existing chain.
- * \param handle The I/O handle of the FLAC stream to read. The
- * handle will NOT be closed after the metadata is read;
- * that is the duty of the caller.
- * \param callbacks
- * A set of callbacks to use for I/O. The mandatory
- * callbacks are \a read, \a seek, and \a tell.
- * \assert
- * \code chain != NULL \endcode
- * \retval FLAC__bool
- * \c true if a valid list of metadata blocks was read from
- * \a handle, else \c false. On failure, check the status with
- * FLAC__metadata_chain_status().
- */
-FLAC_API FLAC__bool FLAC__metadata_chain_read_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks);
-
-/** Read all metadata from an Ogg FLAC stream into the chain via I/O callbacks.
- *
- * The \a handle need only be open for reading, but must be seekable.
- * The equivalent minimum stdio fopen() file mode is \c "r" (or \c "rb"
- * for Windows).
- *
- * \note Ogg FLAC metadata data writing is not supported yet and
- * FLAC__metadata_chain_write() will fail.
- *
- * \param chain A pointer to an existing chain.
- * \param handle The I/O handle of the Ogg FLAC stream to read. The
- * handle will NOT be closed after the metadata is read;
- * that is the duty of the caller.
- * \param callbacks
- * A set of callbacks to use for I/O. The mandatory
- * callbacks are \a read, \a seek, and \a tell.
- * \assert
- * \code chain != NULL \endcode
- * \retval FLAC__bool
- * \c true if a valid list of metadata blocks was read from
- * \a handle, else \c false. On failure, check the status with
- * FLAC__metadata_chain_status().
- */
-FLAC_API FLAC__bool FLAC__metadata_chain_read_ogg_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks);
-
-/** Checks if writing the given chain would require the use of a
- * temporary file, or if it could be written in place.
- *
- * Under certain conditions, padding can be utilized so that writing
- * edited metadata back to the FLAC file does not require rewriting the
- * entire file. If rewriting is required, then a temporary workfile is
- * required. When writing metadata using callbacks, you must check
- * this function to know whether to call
- * FLAC__metadata_chain_write_with_callbacks() or
- * FLAC__metadata_chain_write_with_callbacks_and_tempfile(). When
- * writing with FLAC__metadata_chain_write(), the temporary file is
- * handled internally.
- *
- * \param chain A pointer to an existing chain.
- * \param use_padding
- * Whether or not padding will be allowed to be used
- * during the write. The value of \a use_padding given
- * here must match the value later passed to
- * FLAC__metadata_chain_write_with_callbacks() or
- * FLAC__metadata_chain_write_with_callbacks_with_tempfile().
- * \assert
- * \code chain != NULL \endcode
- * \retval FLAC__bool
- * \c true if writing the current chain would require a tempfile, or
- * \c false if metadata can be written in place.
- */
-FLAC_API FLAC__bool FLAC__metadata_chain_check_if_tempfile_needed(FLAC__Metadata_Chain *chain, FLAC__bool use_padding);
-
-/** Write all metadata out to the FLAC file. This function tries to be as
- * efficient as possible; how the metadata is actually written is shown by
- * the following:
- *
- * If the current chain is the same size as the existing metadata, the new
- * data is written in place.
- *
- * If the current chain is longer than the existing metadata, and
- * \a use_padding is \c true, and the last block is a PADDING block of
- * sufficient length, the function will truncate the final padding block
- * so that the overall size of the metadata is the same as the existing
- * metadata, and then just rewrite the metadata. Otherwise, if not all of
- * the above conditions are met, the entire FLAC file must be rewritten.
- * If you want to use padding this way it is a good idea to call
- * FLAC__metadata_chain_sort_padding() first so that you have the maximum
- * amount of padding to work with, unless you need to preserve ordering
- * of the PADDING blocks for some reason.
- *
- * If the current chain is shorter than the existing metadata, and
- * \a use_padding is \c true, and the final block is a PADDING block, the padding
- * is extended to make the overall size the same as the existing data. If
- * \a use_padding is \c true and the last block is not a PADDING block, a new
- * PADDING block is added to the end of the new data to make it the same
- * size as the existing data (if possible, see the note to
- * FLAC__metadata_simple_iterator_set_block() about the four byte limit)
- * and the new data is written in place. If none of the above apply or
- * \a use_padding is \c false, the entire FLAC file is rewritten.
- *
- * If \a preserve_file_stats is \c true, the owner and modification time will
- * be preserved even if the FLAC file is written.
- *
- * For this write function to be used, the chain must have been read with
- * FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg(), not
- * FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks().
- *
- * \param chain A pointer to an existing chain.
- * \param use_padding See above.
- * \param preserve_file_stats See above.
- * \assert
- * \code chain != NULL \endcode
- * \retval FLAC__bool
- * \c true if the write succeeded, else \c false. On failure,
- * check the status with FLAC__metadata_chain_status().
- */
-FLAC_API FLAC__bool FLAC__metadata_chain_write(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__bool preserve_file_stats);
-
-/** Write all metadata out to a FLAC stream via callbacks.
- *
- * (See FLAC__metadata_chain_write() for the details on how padding is
- * used to write metadata in place if possible.)
- *
- * The \a handle must be open for updating and be seekable. The
- * equivalent minimum stdio fopen() file mode is \c "r+" (or \c "r+b"
- * for Windows).
- *
- * For this write function to be used, the chain must have been read with
- * FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks(),
- * not FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg().
- * Also, FLAC__metadata_chain_check_if_tempfile_needed() must have returned
- * \c false.
- *
- * \param chain A pointer to an existing chain.
- * \param use_padding See FLAC__metadata_chain_write()
- * \param handle The I/O handle of the FLAC stream to write. The
- * handle will NOT be closed after the metadata is
- * written; that is the duty of the caller.
- * \param callbacks A set of callbacks to use for I/O. The mandatory
- * callbacks are \a write and \a seek.
- * \assert
- * \code chain != NULL \endcode
- * \retval FLAC__bool
- * \c true if the write succeeded, else \c false. On failure,
- * check the status with FLAC__metadata_chain_status().
- */
-FLAC_API FLAC__bool FLAC__metadata_chain_write_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks);
-
-/** Write all metadata out to a FLAC stream via callbacks.
- *
- * (See FLAC__metadata_chain_write() for the details on how padding is
- * used to write metadata in place if possible.)
- *
- * This version of the write-with-callbacks function must be used when
- * FLAC__metadata_chain_check_if_tempfile_needed() returns true. In
- * this function, you must supply an I/O handle corresponding to the
- * FLAC file to edit, and a temporary handle to which the new FLAC
- * file will be written. It is the caller's job to move this temporary
- * FLAC file on top of the original FLAC file to complete the metadata
- * edit.
- *
- * The \a handle must be open for reading and be seekable. The
- * equivalent minimum stdio fopen() file mode is \c "r" (or \c "rb"
- * for Windows).
- *
- * The \a temp_handle must be open for writing. The
- * equivalent minimum stdio fopen() file mode is \c "w" (or \c "wb"
- * for Windows). It should be an empty stream, or at least positioned
- * at the start-of-file (in which case it is the caller's duty to
- * truncate it on return).
- *
- * For this write function to be used, the chain must have been read with
- * FLAC__metadata_chain_read_with_callbacks()/FLAC__metadata_chain_read_ogg_with_callbacks(),
- * not FLAC__metadata_chain_read()/FLAC__metadata_chain_read_ogg().
- * Also, FLAC__metadata_chain_check_if_tempfile_needed() must have returned
- * \c true.
- *
- * \param chain A pointer to an existing chain.
- * \param use_padding See FLAC__metadata_chain_write()
- * \param handle The I/O handle of the original FLAC stream to read.
- * The handle will NOT be closed after the metadata is
- * written; that is the duty of the caller.
- * \param callbacks A set of callbacks to use for I/O on \a handle.
- * The mandatory callbacks are \a read, \a seek, and
- * \a eof.
- * \param temp_handle The I/O handle of the FLAC stream to write. The
- * handle will NOT be closed after the metadata is
- * written; that is the duty of the caller.
- * \param temp_callbacks
- * A set of callbacks to use for I/O on temp_handle.
- * The only mandatory callback is \a write.
- * \assert
- * \code chain != NULL \endcode
- * \retval FLAC__bool
- * \c true if the write succeeded, else \c false. On failure,
- * check the status with FLAC__metadata_chain_status().
- */
-FLAC_API FLAC__bool FLAC__metadata_chain_write_with_callbacks_and_tempfile(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks, FLAC__IOHandle temp_handle, FLAC__IOCallbacks temp_callbacks);
-
-/** Merge adjacent PADDING blocks into a single block.
- *
- * \note This function does not write to the FLAC file, it only
- * modifies the chain.
- *
- * \warning Any iterator on the current chain will become invalid after this
- * call. You should delete the iterator and get a new one.
- *
- * \param chain A pointer to an existing chain.
- * \assert
- * \code chain != NULL \endcode
- */
-FLAC_API void FLAC__metadata_chain_merge_padding(FLAC__Metadata_Chain *chain);
-
-/** This function will move all PADDING blocks to the end on the metadata,
- * then merge them into a single block.
- *
- * \note This function does not write to the FLAC file, it only
- * modifies the chain.
- *
- * \warning Any iterator on the current chain will become invalid after this
- * call. You should delete the iterator and get a new one.
- *
- * \param chain A pointer to an existing chain.
- * \assert
- * \code chain != NULL \endcode
- */
-FLAC_API void FLAC__metadata_chain_sort_padding(FLAC__Metadata_Chain *chain);
-
-
-/*********** FLAC__Metadata_Iterator ***********/
-
-/** Create a new iterator instance.
- *
- * \retval FLAC__Metadata_Iterator*
- * \c NULL if there was an error allocating memory, else the new instance.
- */
-FLAC_API FLAC__Metadata_Iterator *FLAC__metadata_iterator_new(void);
-
-/** Free an iterator instance. Deletes the object pointed to by \a iterator.
- *
- * \param iterator A pointer to an existing iterator.
- * \assert
- * \code iterator != NULL \endcode
- */
-FLAC_API void FLAC__metadata_iterator_delete(FLAC__Metadata_Iterator *iterator);
-
-/** Initialize the iterator to point to the first metadata block in the
- * given chain.
- *
- * \param iterator A pointer to an existing iterator.
- * \param chain A pointer to an existing and initialized (read) chain.
- * \assert
- * \code iterator != NULL \endcode
- * \code chain != NULL \endcode
- */
-FLAC_API void FLAC__metadata_iterator_init(FLAC__Metadata_Iterator *iterator, FLAC__Metadata_Chain *chain);
-
-/** Moves the iterator forward one metadata block, returning \c false if
- * already at the end.
- *
- * \param iterator A pointer to an existing initialized iterator.
- * \assert
- * \code iterator != NULL \endcode
- * \a iterator has been successfully initialized with
- * FLAC__metadata_iterator_init()
- * \retval FLAC__bool
- * \c false if already at the last metadata block of the chain, else
- * \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_iterator_next(FLAC__Metadata_Iterator *iterator);
-
-/** Moves the iterator backward one metadata block, returning \c false if
- * already at the beginning.
- *
- * \param iterator A pointer to an existing initialized iterator.
- * \assert
- * \code iterator != NULL \endcode
- * \a iterator has been successfully initialized with
- * FLAC__metadata_iterator_init()
- * \retval FLAC__bool
- * \c false if already at the first metadata block of the chain, else
- * \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_iterator_prev(FLAC__Metadata_Iterator *iterator);
-
-/** Get the type of the metadata block at the current position.
- *
- * \param iterator A pointer to an existing initialized iterator.
- * \assert
- * \code iterator != NULL \endcode
- * \a iterator has been successfully initialized with
- * FLAC__metadata_iterator_init()
- * \retval FLAC__MetadataType
- * The type of the metadata block at the current iterator position.
- */
-FLAC_API FLAC__MetadataType FLAC__metadata_iterator_get_block_type(const FLAC__Metadata_Iterator *iterator);
-
-/** Get the metadata block at the current position. You can modify
- * the block in place but must write the chain before the changes
- * are reflected to the FLAC file. You do not need to call
- * FLAC__metadata_iterator_set_block() to reflect the changes;
- * the pointer returned by FLAC__metadata_iterator_get_block()
- * points directly into the chain.
- *
- * \warning
- * Do not call FLAC__metadata_object_delete() on the returned object;
- * to delete a block use FLAC__metadata_iterator_delete_block().
- *
- * \param iterator A pointer to an existing initialized iterator.
- * \assert
- * \code iterator != NULL \endcode
- * \a iterator has been successfully initialized with
- * FLAC__metadata_iterator_init()
- * \retval FLAC__StreamMetadata*
- * The current metadata block.
- */
-FLAC_API FLAC__StreamMetadata *FLAC__metadata_iterator_get_block(FLAC__Metadata_Iterator *iterator);
-
-/** Set the metadata block at the current position, replacing the existing
- * block. The new block passed in becomes owned by the chain and it will be
- * deleted when the chain is deleted.
- *
- * \param iterator A pointer to an existing initialized iterator.
- * \param block A pointer to a metadata block.
- * \assert
- * \code iterator != NULL \endcode
- * \a iterator has been successfully initialized with
- * FLAC__metadata_iterator_init()
- * \code block != NULL \endcode
- * \retval FLAC__bool
- * \c false if the conditions in the above description are not met, or
- * a memory allocation error occurs, otherwise \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_iterator_set_block(FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block);
-
-/** Removes the current block from the chain. If \a replace_with_padding is
- * \c true, the block will instead be replaced with a padding block of equal
- * size. You can not delete the STREAMINFO block. The iterator will be
- * left pointing to the block before the one just "deleted", even if
- * \a replace_with_padding is \c true.
- *
- * \param iterator A pointer to an existing initialized iterator.
- * \param replace_with_padding See above.
- * \assert
- * \code iterator != NULL \endcode
- * \a iterator has been successfully initialized with
- * FLAC__metadata_iterator_init()
- * \retval FLAC__bool
- * \c false if the conditions in the above description are not met,
- * otherwise \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_iterator_delete_block(FLAC__Metadata_Iterator *iterator, FLAC__bool replace_with_padding);
-
-/** Insert a new block before the current block. You cannot insert a block
- * before the first STREAMINFO block. You cannot insert a STREAMINFO block
- * as there can be only one, the one that already exists at the head when you
- * read in a chain. The chain takes ownership of the new block and it will be
- * deleted when the chain is deleted. The iterator will be left pointing to
- * the new block.
- *
- * \param iterator A pointer to an existing initialized iterator.
- * \param block A pointer to a metadata block to insert.
- * \assert
- * \code iterator != NULL \endcode
- * \a iterator has been successfully initialized with
- * FLAC__metadata_iterator_init()
- * \retval FLAC__bool
- * \c false if the conditions in the above description are not met, or
- * a memory allocation error occurs, otherwise \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_iterator_insert_block_before(FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block);
-
-/** Insert a new block after the current block. You cannot insert a STREAMINFO
- * block as there can be only one, the one that already exists at the head when
- * you read in a chain. The chain takes ownership of the new block and it will
- * be deleted when the chain is deleted. The iterator will be left pointing to
- * the new block.
- *
- * \param iterator A pointer to an existing initialized iterator.
- * \param block A pointer to a metadata block to insert.
- * \assert
- * \code iterator != NULL \endcode
- * \a iterator has been successfully initialized with
- * FLAC__metadata_iterator_init()
- * \retval FLAC__bool
- * \c false if the conditions in the above description are not met, or
- * a memory allocation error occurs, otherwise \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_iterator_insert_block_after(FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block);
-
-/* \} */
-
-
-/** \defgroup flac_metadata_object FLAC/metadata.h: metadata object methods
- * \ingroup flac_metadata
- *
- * \brief
- * This module contains methods for manipulating FLAC metadata objects.
- *
- * Since many are variable length we have to be careful about the memory
- * management. We decree that all pointers to data in the object are
- * owned by the object and memory-managed by the object.
- *
- * Use the FLAC__metadata_object_new() and FLAC__metadata_object_delete()
- * functions to create all instances. When using the
- * FLAC__metadata_object_set_*() functions to set pointers to data, set
- * \a copy to \c true to have the function make it's own copy of the data, or
- * to \c false to give the object ownership of your data. In the latter case
- * your pointer must be freeable by free() and will be free()d when the object
- * is FLAC__metadata_object_delete()d. It is legal to pass a null pointer as
- * the data pointer to a FLAC__metadata_object_set_*() function as long as
- * the length argument is 0 and the \a copy argument is \c false.
- *
- * The FLAC__metadata_object_new() and FLAC__metadata_object_clone() function
- * will return \c NULL in the case of a memory allocation error, otherwise a new
- * object. The FLAC__metadata_object_set_*() functions return \c false in the
- * case of a memory allocation error.
- *
- * We don't have the convenience of C++ here, so note that the library relies
- * on you to keep the types straight. In other words, if you pass, for
- * example, a FLAC__StreamMetadata* that represents a STREAMINFO block to
- * FLAC__metadata_object_application_set_data(), you will get an assertion
- * failure.
- *
- * For convenience the FLAC__metadata_object_vorbiscomment_*() functions
- * maintain a trailing NUL on each Vorbis comment entry. This is not counted
- * toward the length or stored in the stream, but it can make working with plain
- * comments (those that don't contain embedded-NULs in the value) easier.
- * Entries passed into these functions have trailing NULs added if missing, and
- * returned entries are guaranteed to have a trailing NUL.
- *
- * The FLAC__metadata_object_vorbiscomment_*() functions that take a Vorbis
- * comment entry/name/value will first validate that it complies with the Vorbis
- * comment specification and return false if it does not.
- *
- * There is no need to recalculate the length field on metadata blocks you
- * have modified. They will be calculated automatically before they are
- * written back to a file.
- *
- * \{
- */
-
-
-/** Create a new metadata object instance of the given type.
- *
- * The object will be "empty"; i.e. values and data pointers will be \c 0,
- * with the exception of FLAC__METADATA_TYPE_VORBIS_COMMENT, which will have
- * the vendor string set (but zero comments).
- *
- * Do not pass in a value greater than or equal to
- * \a FLAC__METADATA_TYPE_UNDEFINED unless you really know what you're
- * doing.
- *
- * \param type Type of object to create
- * \retval FLAC__StreamMetadata*
- * \c NULL if there was an error allocating memory or the type code is
- * greater than FLAC__MAX_METADATA_TYPE_CODE, else the new instance.
- */
-FLAC_API FLAC__StreamMetadata *FLAC__metadata_object_new(FLAC__MetadataType type);
-
-/** Create a copy of an existing metadata object.
- *
- * The copy is a "deep" copy, i.e. dynamically allocated data within the
- * object is also copied. The caller takes ownership of the new block and
- * is responsible for freeing it with FLAC__metadata_object_delete().
- *
- * \param object Pointer to object to copy.
- * \assert
- * \code object != NULL \endcode
- * \retval FLAC__StreamMetadata*
- * \c NULL if there was an error allocating memory, else the new instance.
- */
-FLAC_API FLAC__StreamMetadata *FLAC__metadata_object_clone(const FLAC__StreamMetadata *object);
-
-/** Free a metadata object. Deletes the object pointed to by \a object.
- *
- * The delete is a "deep" delete, i.e. dynamically allocated data within the
- * object is also deleted.
- *
- * \param object A pointer to an existing object.
- * \assert
- * \code object != NULL \endcode
- */
-FLAC_API void FLAC__metadata_object_delete(FLAC__StreamMetadata *object);
-
-/** Compares two metadata objects.
- *
- * The compare is "deep", i.e. dynamically allocated data within the
- * object is also compared.
- *
- * \param block1 A pointer to an existing object.
- * \param block2 A pointer to an existing object.
- * \assert
- * \code block1 != NULL \endcode
- * \code block2 != NULL \endcode
- * \retval FLAC__bool
- * \c true if objects are identical, else \c false.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_is_equal(const FLAC__StreamMetadata *block1, const FLAC__StreamMetadata *block2);
-
-/** Sets the application data of an APPLICATION block.
- *
- * If \a copy is \c true, a copy of the data is stored; otherwise, the object
- * takes ownership of the pointer. The existing data will be freed if this
- * function is successful, otherwise the original data will remain if \a copy
- * is \c true and malloc() fails.
- *
- * \note It is safe to pass a const pointer to \a data if \a copy is \c true.
- *
- * \param object A pointer to an existing APPLICATION object.
- * \param data A pointer to the data to set.
- * \param length The length of \a data in bytes.
- * \param copy See above.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_APPLICATION \endcode
- * \code (data != NULL && length > 0) ||
- * (data == NULL && length == 0 && copy == false) \endcode
- * \retval FLAC__bool
- * \c false if \a copy is \c true and malloc() fails, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_application_set_data(FLAC__StreamMetadata *object, FLAC__byte *data, unsigned length, FLAC__bool copy);
-
-/** Resize the seekpoint array.
- *
- * If the size shrinks, elements will truncated; if it grows, new placeholder
- * points will be added to the end.
- *
- * \param object A pointer to an existing SEEKTABLE object.
- * \param new_num_points The desired length of the array; may be \c 0.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
- * \code (object->data.seek_table.points == NULL && object->data.seek_table.num_points == 0) ||
- * (object->data.seek_table.points != NULL && object->data.seek_table.num_points > 0) \endcode
- * \retval FLAC__bool
- * \c false if memory allocation error, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_seektable_resize_points(FLAC__StreamMetadata *object, unsigned new_num_points);
-
-/** Set a seekpoint in a seektable.
- *
- * \param object A pointer to an existing SEEKTABLE object.
- * \param point_num Index into seekpoint array to set.
- * \param point The point to set.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
- * \code object->data.seek_table.num_points > point_num \endcode
- */
-FLAC_API void FLAC__metadata_object_seektable_set_point(FLAC__StreamMetadata *object, unsigned point_num, FLAC__StreamMetadata_SeekPoint point);
-
-/** Insert a seekpoint into a seektable.
- *
- * \param object A pointer to an existing SEEKTABLE object.
- * \param point_num Index into seekpoint array to set.
- * \param point The point to set.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
- * \code object->data.seek_table.num_points >= point_num \endcode
- * \retval FLAC__bool
- * \c false if memory allocation error, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_seektable_insert_point(FLAC__StreamMetadata *object, unsigned point_num, FLAC__StreamMetadata_SeekPoint point);
-
-/** Delete a seekpoint from a seektable.
- *
- * \param object A pointer to an existing SEEKTABLE object.
- * \param point_num Index into seekpoint array to set.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
- * \code object->data.seek_table.num_points > point_num \endcode
- * \retval FLAC__bool
- * \c false if memory allocation error, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_seektable_delete_point(FLAC__StreamMetadata *object, unsigned point_num);
-
-/** Check a seektable to see if it conforms to the FLAC specification.
- * See the format specification for limits on the contents of the
- * seektable.
- *
- * \param object A pointer to an existing SEEKTABLE object.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
- * \retval FLAC__bool
- * \c false if seek table is illegal, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_seektable_is_legal(const FLAC__StreamMetadata *object);
-
-/** Append a number of placeholder points to the end of a seek table.
- *
- * \note
- * As with the other ..._seektable_template_... functions, you should
- * call FLAC__metadata_object_seektable_template_sort() when finished
- * to make the seek table legal.
- *
- * \param object A pointer to an existing SEEKTABLE object.
- * \param num The number of placeholder points to append.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
- * \retval FLAC__bool
- * \c false if memory allocation fails, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_placeholders(FLAC__StreamMetadata *object, unsigned num);
-
-/** Append a specific seek point template to the end of a seek table.
- *
- * \note
- * As with the other ..._seektable_template_... functions, you should
- * call FLAC__metadata_object_seektable_template_sort() when finished
- * to make the seek table legal.
- *
- * \param object A pointer to an existing SEEKTABLE object.
- * \param sample_number The sample number of the seek point template.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
- * \retval FLAC__bool
- * \c false if memory allocation fails, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_point(FLAC__StreamMetadata *object, FLAC__uint64 sample_number);
-
-/** Append specific seek point templates to the end of a seek table.
- *
- * \note
- * As with the other ..._seektable_template_... functions, you should
- * call FLAC__metadata_object_seektable_template_sort() when finished
- * to make the seek table legal.
- *
- * \param object A pointer to an existing SEEKTABLE object.
- * \param sample_numbers An array of sample numbers for the seek points.
- * \param num The number of seek point templates to append.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
- * \retval FLAC__bool
- * \c false if memory allocation fails, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_points(FLAC__StreamMetadata *object, FLAC__uint64 sample_numbers[], unsigned num);
-
-/** Append a set of evenly-spaced seek point templates to the end of a
- * seek table.
- *
- * \note
- * As with the other ..._seektable_template_... functions, you should
- * call FLAC__metadata_object_seektable_template_sort() when finished
- * to make the seek table legal.
- *
- * \param object A pointer to an existing SEEKTABLE object.
- * \param num The number of placeholder points to append.
- * \param total_samples The total number of samples to be encoded;
- * the seekpoints will be spaced approximately
- * \a total_samples / \a num samples apart.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
- * \code total_samples > 0 \endcode
- * \retval FLAC__bool
- * \c false if memory allocation fails, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_points(FLAC__StreamMetadata *object, unsigned num, FLAC__uint64 total_samples);
-
-/** Append a set of evenly-spaced seek point templates to the end of a
- * seek table.
- *
- * \note
- * As with the other ..._seektable_template_... functions, you should
- * call FLAC__metadata_object_seektable_template_sort() when finished
- * to make the seek table legal.
- *
- * \param object A pointer to an existing SEEKTABLE object.
- * \param samples The number of samples apart to space the placeholder
- * points. The first point will be at sample \c 0, the
- * second at sample \a samples, then 2*\a samples, and
- * so on. As long as \a samples and \a total_samples
- * are greater than \c 0, there will always be at least
- * one seekpoint at sample \c 0.
- * \param total_samples The total number of samples to be encoded;
- * the seekpoints will be spaced
- * \a samples samples apart.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
- * \code samples > 0 \endcode
- * \code total_samples > 0 \endcode
- * \retval FLAC__bool
- * \c false if memory allocation fails, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(FLAC__StreamMetadata *object, unsigned samples, FLAC__uint64 total_samples);
-
-/** Sort a seek table's seek points according to the format specification,
- * removing duplicates.
- *
- * \param object A pointer to a seek table to be sorted.
- * \param compact If \c false, behaves like FLAC__format_seektable_sort().
- * If \c true, duplicates are deleted and the seek table is
- * shrunk appropriately; the number of placeholder points
- * present in the seek table will be the same after the call
- * as before.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
- * \retval FLAC__bool
- * \c false if realloc() fails, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_sort(FLAC__StreamMetadata *object, FLAC__bool compact);
-
-/** Sets the vendor string in a VORBIS_COMMENT block.
- *
- * For convenience, a trailing NUL is added to the entry if it doesn't have
- * one already.
- *
- * If \a copy is \c true, a copy of the entry is stored; otherwise, the object
- * takes ownership of the \c entry.entry pointer.
- *
- * \note If this function returns \c false, the caller still owns the
- * pointer.
- *
- * \param object A pointer to an existing VORBIS_COMMENT object.
- * \param entry The entry to set the vendor string to.
- * \param copy See above.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
- * \code (entry.entry != NULL && entry.length > 0) ||
- * (entry.entry == NULL && entry.length == 0) \endcode
- * \retval FLAC__bool
- * \c false if memory allocation fails or \a entry does not comply with the
- * Vorbis comment specification, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_set_vendor_string(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy);
-
-/** Resize the comment array.
- *
- * If the size shrinks, elements will truncated; if it grows, new empty
- * fields will be added to the end.
- *
- * \param object A pointer to an existing VORBIS_COMMENT object.
- * \param new_num_comments The desired length of the array; may be \c 0.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
- * \code (object->data.vorbis_comment.comments == NULL && object->data.vorbis_comment.num_comments == 0) ||
- * (object->data.vorbis_comment.comments != NULL && object->data.vorbis_comment.num_comments > 0) \endcode
- * \retval FLAC__bool
- * \c false if memory allocation fails, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_resize_comments(FLAC__StreamMetadata *object, unsigned new_num_comments);
-
-/** Sets a comment in a VORBIS_COMMENT block.
- *
- * For convenience, a trailing NUL is added to the entry if it doesn't have
- * one already.
- *
- * If \a copy is \c true, a copy of the entry is stored; otherwise, the object
- * takes ownership of the \c entry.entry pointer.
- *
- * \note If this function returns \c false, the caller still owns the
- * pointer.
- *
- * \param object A pointer to an existing VORBIS_COMMENT object.
- * \param comment_num Index into comment array to set.
- * \param entry The entry to set the comment to.
- * \param copy See above.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
- * \code comment_num < object->data.vorbis_comment.num_comments \endcode
- * \code (entry.entry != NULL && entry.length > 0) ||
- * (entry.entry == NULL && entry.length == 0) \endcode
- * \retval FLAC__bool
- * \c false if memory allocation fails or \a entry does not comply with the
- * Vorbis comment specification, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_set_comment(FLAC__StreamMetadata *object, unsigned comment_num, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy);
-
-/** Insert a comment in a VORBIS_COMMENT block at the given index.
- *
- * For convenience, a trailing NUL is added to the entry if it doesn't have
- * one already.
- *
- * If \a copy is \c true, a copy of the entry is stored; otherwise, the object
- * takes ownership of the \c entry.entry pointer.
- *
- * \note If this function returns \c false, the caller still owns the
- * pointer.
- *
- * \param object A pointer to an existing VORBIS_COMMENT object.
- * \param comment_num The index at which to insert the comment. The comments
- * at and after \a comment_num move right one position.
- * To append a comment to the end, set \a comment_num to
- * \c object->data.vorbis_comment.num_comments .
- * \param entry The comment to insert.
- * \param copy See above.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
- * \code object->data.vorbis_comment.num_comments >= comment_num \endcode
- * \code (entry.entry != NULL && entry.length > 0) ||
- * (entry.entry == NULL && entry.length == 0 && copy == false) \endcode
- * \retval FLAC__bool
- * \c false if memory allocation fails or \a entry does not comply with the
- * Vorbis comment specification, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_insert_comment(FLAC__StreamMetadata *object, unsigned comment_num, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy);
-
-/** Appends a comment to a VORBIS_COMMENT block.
- *
- * For convenience, a trailing NUL is added to the entry if it doesn't have
- * one already.
- *
- * If \a copy is \c true, a copy of the entry is stored; otherwise, the object
- * takes ownership of the \c entry.entry pointer.
- *
- * \note If this function returns \c false, the caller still owns the
- * pointer.
- *
- * \param object A pointer to an existing VORBIS_COMMENT object.
- * \param entry The comment to insert.
- * \param copy See above.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
- * \code (entry.entry != NULL && entry.length > 0) ||
- * (entry.entry == NULL && entry.length == 0 && copy == false) \endcode
- * \retval FLAC__bool
- * \c false if memory allocation fails or \a entry does not comply with the
- * Vorbis comment specification, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_append_comment(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy);
-
-/** Replaces comments in a VORBIS_COMMENT block with a new one.
- *
- * For convenience, a trailing NUL is added to the entry if it doesn't have
- * one already.
- *
- * Depending on the the value of \a all, either all or just the first comment
- * whose field name(s) match the given entry's name will be replaced by the
- * given entry. If no comments match, \a entry will simply be appended.
- *
- * If \a copy is \c true, a copy of the entry is stored; otherwise, the object
- * takes ownership of the \c entry.entry pointer.
- *
- * \note If this function returns \c false, the caller still owns the
- * pointer.
- *
- * \param object A pointer to an existing VORBIS_COMMENT object.
- * \param entry The comment to insert.
- * \param all If \c true, all comments whose field name matches
- * \a entry's field name will be removed, and \a entry will
- * be inserted at the position of the first matching
- * comment. If \c false, only the first comment whose
- * field name matches \a entry's field name will be
- * replaced with \a entry.
- * \param copy See above.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
- * \code (entry.entry != NULL && entry.length > 0) ||
- * (entry.entry == NULL && entry.length == 0 && copy == false) \endcode
- * \retval FLAC__bool
- * \c false if memory allocation fails or \a entry does not comply with the
- * Vorbis comment specification, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_replace_comment(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool all, FLAC__bool copy);
-
-/** Delete a comment in a VORBIS_COMMENT block at the given index.
- *
- * \param object A pointer to an existing VORBIS_COMMENT object.
- * \param comment_num The index of the comment to delete.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
- * \code object->data.vorbis_comment.num_comments > comment_num \endcode
- * \retval FLAC__bool
- * \c false if realloc() fails, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_delete_comment(FLAC__StreamMetadata *object, unsigned comment_num);
-
-/** Creates a Vorbis comment entry from NUL-terminated name and value strings.
- *
- * On return, the filled-in \a entry->entry pointer will point to malloc()ed
- * memory and shall be owned by the caller. For convenience the entry will
- * have a terminating NUL.
- *
- * \param entry A pointer to a Vorbis comment entry. The entry's
- * \c entry pointer should not point to allocated
- * memory as it will be overwritten.
- * \param field_name The field name in ASCII, \c NUL terminated.
- * \param field_value The field value in UTF-8, \c NUL terminated.
- * \assert
- * \code entry != NULL \endcode
- * \code field_name != NULL \endcode
- * \code field_value != NULL \endcode
- * \retval FLAC__bool
- * \c false if malloc() fails, or if \a field_name or \a field_value does
- * not comply with the Vorbis comment specification, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(FLAC__StreamMetadata_VorbisComment_Entry *entry, const char *field_name, const char *field_value);
-
-/** Splits a Vorbis comment entry into NUL-terminated name and value strings.
- *
- * The returned pointers to name and value will be allocated by malloc()
- * and shall be owned by the caller.
- *
- * \param entry An existing Vorbis comment entry.
- * \param field_name The address of where the returned pointer to the
- * field name will be stored.
- * \param field_value The address of where the returned pointer to the
- * field value will be stored.
- * \assert
- * \code (entry.entry != NULL && entry.length > 0) \endcode
- * \code memchr(entry.entry, '=', entry.length) != NULL \endcode
- * \code field_name != NULL \endcode
- * \code field_value != NULL \endcode
- * \retval FLAC__bool
- * \c false if memory allocation fails or \a entry does not comply with the
- * Vorbis comment specification, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_to_name_value_pair(const FLAC__StreamMetadata_VorbisComment_Entry entry, char **field_name, char **field_value);
-
-/** Check if the given Vorbis comment entry's field name matches the given
- * field name.
- *
- * \param entry An existing Vorbis comment entry.
- * \param field_name The field name to check.
- * \param field_name_length The length of \a field_name, not including the
- * terminating \c NUL.
- * \assert
- * \code (entry.entry != NULL && entry.length > 0) \endcode
- * \retval FLAC__bool
- * \c true if the field names match, else \c false
- */
-FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_matches(const FLAC__StreamMetadata_VorbisComment_Entry entry, const char *field_name, unsigned field_name_length);
-
-/** Find a Vorbis comment with the given field name.
- *
- * The search begins at entry number \a offset; use an offset of 0 to
- * search from the beginning of the comment array.
- *
- * \param object A pointer to an existing VORBIS_COMMENT object.
- * \param offset The offset into the comment array from where to start
- * the search.
- * \param field_name The field name of the comment to find.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
- * \code field_name != NULL \endcode
- * \retval int
- * The offset in the comment array of the first comment whose field
- * name matches \a field_name, or \c -1 if no match was found.
- */
-FLAC_API int FLAC__metadata_object_vorbiscomment_find_entry_from(const FLAC__StreamMetadata *object, unsigned offset, const char *field_name);
-
-/** Remove first Vorbis comment matching the given field name.
- *
- * \param object A pointer to an existing VORBIS_COMMENT object.
- * \param field_name The field name of comment to delete.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
- * \retval int
- * \c -1 for memory allocation error, \c 0 for no matching entries,
- * \c 1 for one matching entry deleted.
- */
-FLAC_API int FLAC__metadata_object_vorbiscomment_remove_entry_matching(FLAC__StreamMetadata *object, const char *field_name);
-
-/** Remove all Vorbis comments matching the given field name.
- *
- * \param object A pointer to an existing VORBIS_COMMENT object.
- * \param field_name The field name of comments to delete.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
- * \retval int
- * \c -1 for memory allocation error, \c 0 for no matching entries,
- * else the number of matching entries deleted.
- */
-FLAC_API int FLAC__metadata_object_vorbiscomment_remove_entries_matching(FLAC__StreamMetadata *object, const char *field_name);
-
-/** Create a new CUESHEET track instance.
- *
- * The object will be "empty"; i.e. values and data pointers will be \c 0.
- *
- * \retval FLAC__StreamMetadata_CueSheet_Track*
- * \c NULL if there was an error allocating memory, else the new instance.
- */
-FLAC_API FLAC__StreamMetadata_CueSheet_Track *FLAC__metadata_object_cuesheet_track_new(void);
-
-/** Create a copy of an existing CUESHEET track object.
- *
- * The copy is a "deep" copy, i.e. dynamically allocated data within the
- * object is also copied. The caller takes ownership of the new object and
- * is responsible for freeing it with
- * FLAC__metadata_object_cuesheet_track_delete().
- *
- * \param object Pointer to object to copy.
- * \assert
- * \code object != NULL \endcode
- * \retval FLAC__StreamMetadata_CueSheet_Track*
- * \c NULL if there was an error allocating memory, else the new instance.
- */
-FLAC_API FLAC__StreamMetadata_CueSheet_Track *FLAC__metadata_object_cuesheet_track_clone(const FLAC__StreamMetadata_CueSheet_Track *object);
-
-/** Delete a CUESHEET track object
- *
- * \param object A pointer to an existing CUESHEET track object.
- * \assert
- * \code object != NULL \endcode
- */
-FLAC_API void FLAC__metadata_object_cuesheet_track_delete(FLAC__StreamMetadata_CueSheet_Track *object);
-
-/** Resize a track's index point array.
- *
- * If the size shrinks, elements will truncated; if it grows, new blank
- * indices will be added to the end.
- *
- * \param object A pointer to an existing CUESHEET object.
- * \param track_num The index of the track to modify. NOTE: this is not
- * necessarily the same as the track's \a number field.
- * \param new_num_indices The desired length of the array; may be \c 0.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode
- * \code object->data.cue_sheet.num_tracks > track_num \endcode
- * \code (object->data.cue_sheet.tracks[track_num].indices == NULL && object->data.cue_sheet.tracks[track_num].num_indices == 0) ||
- * (object->data.cue_sheet.tracks[track_num].indices != NULL && object->data.cue_sheet.tracks[track_num].num_indices > 0) \endcode
- * \retval FLAC__bool
- * \c false if memory allocation error, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_resize_indices(FLAC__StreamMetadata *object, unsigned track_num, unsigned new_num_indices);
-
-/** Insert an index point in a CUESHEET track at the given index.
- *
- * \param object A pointer to an existing CUESHEET object.
- * \param track_num The index of the track to modify. NOTE: this is not
- * necessarily the same as the track's \a number field.
- * \param index_num The index into the track's index array at which to
- * insert the index point. NOTE: this is not necessarily
- * the same as the index point's \a number field. The
- * indices at and after \a index_num move right one
- * position. To append an index point to the end, set
- * \a index_num to
- * \c object->data.cue_sheet.tracks[track_num].num_indices .
- * \param index The index point to insert.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode
- * \code object->data.cue_sheet.num_tracks > track_num \endcode
- * \code object->data.cue_sheet.tracks[track_num].num_indices >= index_num \endcode
- * \retval FLAC__bool
- * \c false if realloc() fails, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_insert_index(FLAC__StreamMetadata *object, unsigned track_num, unsigned index_num, FLAC__StreamMetadata_CueSheet_Index index);
-
-/** Insert a blank index point in a CUESHEET track at the given index.
- *
- * A blank index point is one in which all field values are zero.
- *
- * \param object A pointer to an existing CUESHEET object.
- * \param track_num The index of the track to modify. NOTE: this is not
- * necessarily the same as the track's \a number field.
- * \param index_num The index into the track's index array at which to
- * insert the index point. NOTE: this is not necessarily
- * the same as the index point's \a number field. The
- * indices at and after \a index_num move right one
- * position. To append an index point to the end, set
- * \a index_num to
- * \c object->data.cue_sheet.tracks[track_num].num_indices .
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode
- * \code object->data.cue_sheet.num_tracks > track_num \endcode
- * \code object->data.cue_sheet.tracks[track_num].num_indices >= index_num \endcode
- * \retval FLAC__bool
- * \c false if realloc() fails, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_insert_blank_index(FLAC__StreamMetadata *object, unsigned track_num, unsigned index_num);
-
-/** Delete an index point in a CUESHEET track at the given index.
- *
- * \param object A pointer to an existing CUESHEET object.
- * \param track_num The index into the track array of the track to
- * modify. NOTE: this is not necessarily the same
- * as the track's \a number field.
- * \param index_num The index into the track's index array of the index
- * to delete. NOTE: this is not necessarily the same
- * as the index's \a number field.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode
- * \code object->data.cue_sheet.num_tracks > track_num \endcode
- * \code object->data.cue_sheet.tracks[track_num].num_indices > index_num \endcode
- * \retval FLAC__bool
- * \c false if realloc() fails, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_delete_index(FLAC__StreamMetadata *object, unsigned track_num, unsigned index_num);
-
-/** Resize the track array.
- *
- * If the size shrinks, elements will truncated; if it grows, new blank
- * tracks will be added to the end.
- *
- * \param object A pointer to an existing CUESHEET object.
- * \param new_num_tracks The desired length of the array; may be \c 0.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode
- * \code (object->data.cue_sheet.tracks == NULL && object->data.cue_sheet.num_tracks == 0) ||
- * (object->data.cue_sheet.tracks != NULL && object->data.cue_sheet.num_tracks > 0) \endcode
- * \retval FLAC__bool
- * \c false if memory allocation error, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_resize_tracks(FLAC__StreamMetadata *object, unsigned new_num_tracks);
-
-/** Sets a track in a CUESHEET block.
- *
- * If \a copy is \c true, a copy of the track is stored; otherwise, the object
- * takes ownership of the \a track pointer.
- *
- * \param object A pointer to an existing CUESHEET object.
- * \param track_num Index into track array to set. NOTE: this is not
- * necessarily the same as the track's \a number field.
- * \param track The track to set the track to. You may safely pass in
- * a const pointer if \a copy is \c true.
- * \param copy See above.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode
- * \code track_num < object->data.cue_sheet.num_tracks \endcode
- * \code (track->indices != NULL && track->num_indices > 0) ||
- * (track->indices == NULL && track->num_indices == 0)
- * \retval FLAC__bool
- * \c false if \a copy is \c true and malloc() fails, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_set_track(FLAC__StreamMetadata *object, unsigned track_num, FLAC__StreamMetadata_CueSheet_Track *track, FLAC__bool copy);
-
-/** Insert a track in a CUESHEET block at the given index.
- *
- * If \a copy is \c true, a copy of the track is stored; otherwise, the object
- * takes ownership of the \a track pointer.
- *
- * \param object A pointer to an existing CUESHEET object.
- * \param track_num The index at which to insert the track. NOTE: this
- * is not necessarily the same as the track's \a number
- * field. The tracks at and after \a track_num move right
- * one position. To append a track to the end, set
- * \a track_num to \c object->data.cue_sheet.num_tracks .
- * \param track The track to insert. You may safely pass in a const
- * pointer if \a copy is \c true.
- * \param copy See above.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode
- * \code object->data.cue_sheet.num_tracks >= track_num \endcode
- * \retval FLAC__bool
- * \c false if \a copy is \c true and malloc() fails, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_insert_track(FLAC__StreamMetadata *object, unsigned track_num, FLAC__StreamMetadata_CueSheet_Track *track, FLAC__bool copy);
-
-/** Insert a blank track in a CUESHEET block at the given index.
- *
- * A blank track is one in which all field values are zero.
- *
- * \param object A pointer to an existing CUESHEET object.
- * \param track_num The index at which to insert the track. NOTE: this
- * is not necessarily the same as the track's \a number
- * field. The tracks at and after \a track_num move right
- * one position. To append a track to the end, set
- * \a track_num to \c object->data.cue_sheet.num_tracks .
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode
- * \code object->data.cue_sheet.num_tracks >= track_num \endcode
- * \retval FLAC__bool
- * \c false if \a copy is \c true and malloc() fails, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_insert_blank_track(FLAC__StreamMetadata *object, unsigned track_num);
-
-/** Delete a track in a CUESHEET block at the given index.
- *
- * \param object A pointer to an existing CUESHEET object.
- * \param track_num The index into the track array of the track to
- * delete. NOTE: this is not necessarily the same
- * as the track's \a number field.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode
- * \code object->data.cue_sheet.num_tracks > track_num \endcode
- * \retval FLAC__bool
- * \c false if realloc() fails, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_delete_track(FLAC__StreamMetadata *object, unsigned track_num);
-
-/** Check a cue sheet to see if it conforms to the FLAC specification.
- * See the format specification for limits on the contents of the
- * cue sheet.
- *
- * \param object A pointer to an existing CUESHEET object.
- * \param check_cd_da_subset If \c true, check CUESHEET against more
- * stringent requirements for a CD-DA (audio) disc.
- * \param violation Address of a pointer to a string. If there is a
- * violation, a pointer to a string explanation of the
- * violation will be returned here. \a violation may be
- * \c NULL if you don't need the returned string. Do not
- * free the returned string; it will always point to static
- * data.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode
- * \retval FLAC__bool
- * \c false if cue sheet is illegal, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_is_legal(const FLAC__StreamMetadata *object, FLAC__bool check_cd_da_subset, const char **violation);
-
-/** Calculate and return the CDDB/freedb ID for a cue sheet. The function
- * assumes the cue sheet corresponds to a CD; the result is undefined
- * if the cuesheet's is_cd bit is not set.
- *
- * \param object A pointer to an existing CUESHEET object.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_CUESHEET \endcode
- * \retval FLAC__uint32
- * The unsigned integer representation of the CDDB/freedb ID
- */
-FLAC_API FLAC__uint32 FLAC__metadata_object_cuesheet_calculate_cddb_id(const FLAC__StreamMetadata *object);
-
-/** Sets the MIME type of a PICTURE block.
- *
- * If \a copy is \c true, a copy of the string is stored; otherwise, the object
- * takes ownership of the pointer. The existing string will be freed if this
- * function is successful, otherwise the original string will remain if \a copy
- * is \c true and malloc() fails.
- *
- * \note It is safe to pass a const pointer to \a mime_type if \a copy is \c true.
- *
- * \param object A pointer to an existing PICTURE object.
- * \param mime_type A pointer to the MIME type string. The string must be
- * ASCII characters 0x20-0x7e, NUL-terminated. No validation
- * is done.
- * \param copy See above.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_PICTURE \endcode
- * \code (mime_type != NULL) \endcode
- * \retval FLAC__bool
- * \c false if \a copy is \c true and malloc() fails, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_picture_set_mime_type(FLAC__StreamMetadata *object, char *mime_type, FLAC__bool copy);
-
-/** Sets the description of a PICTURE block.
- *
- * If \a copy is \c true, a copy of the string is stored; otherwise, the object
- * takes ownership of the pointer. The existing string will be freed if this
- * function is successful, otherwise the original string will remain if \a copy
- * is \c true and malloc() fails.
- *
- * \note It is safe to pass a const pointer to \a description if \a copy is \c true.
- *
- * \param object A pointer to an existing PICTURE object.
- * \param description A pointer to the description string. The string must be
- * valid UTF-8, NUL-terminated. No validation is done.
- * \param copy See above.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_PICTURE \endcode
- * \code (description != NULL) \endcode
- * \retval FLAC__bool
- * \c false if \a copy is \c true and malloc() fails, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_picture_set_description(FLAC__StreamMetadata *object, FLAC__byte *description, FLAC__bool copy);
-
-/** Sets the picture data of a PICTURE block.
- *
- * If \a copy is \c true, a copy of the data is stored; otherwise, the object
- * takes ownership of the pointer. Also sets the \a data_length field of the
- * metadata object to what is passed in as the \a length parameter. The
- * existing data will be freed if this function is successful, otherwise the
- * original data and data_length will remain if \a copy is \c true and
- * malloc() fails.
- *
- * \note It is safe to pass a const pointer to \a data if \a copy is \c true.
- *
- * \param object A pointer to an existing PICTURE object.
- * \param data A pointer to the data to set.
- * \param length The length of \a data in bytes.
- * \param copy See above.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_PICTURE \endcode
- * \code (data != NULL && length > 0) ||
- * (data == NULL && length == 0 && copy == false) \endcode
- * \retval FLAC__bool
- * \c false if \a copy is \c true and malloc() fails, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_picture_set_data(FLAC__StreamMetadata *object, FLAC__byte *data, FLAC__uint32 length, FLAC__bool copy);
-
-/** Check a PICTURE block to see if it conforms to the FLAC specification.
- * See the format specification for limits on the contents of the
- * PICTURE block.
- *
- * \param object A pointer to existing PICTURE block to be checked.
- * \param violation Address of a pointer to a string. If there is a
- * violation, a pointer to a string explanation of the
- * violation will be returned here. \a violation may be
- * \c NULL if you don't need the returned string. Do not
- * free the returned string; it will always point to static
- * data.
- * \assert
- * \code object != NULL \endcode
- * \code object->type == FLAC__METADATA_TYPE_PICTURE \endcode
- * \retval FLAC__bool
- * \c false if PICTURE block is illegal, else \c true.
- */
-FLAC_API FLAC__bool FLAC__metadata_object_picture_is_legal(const FLAC__StreamMetadata *object, const char **violation);
-
-/* \} */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/src/thirdparty/libflac/include/FLAC/ordinals.h b/src/thirdparty/libflac/include/FLAC/ordinals.h
deleted file mode 100644
index 223a59809..000000000
--- a/src/thirdparty/libflac/include/FLAC/ordinals.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__ORDINALS_H
-#define FLAC__ORDINALS_H
-
-#if !(defined(_MSC_VER) || defined(__BORLANDC__) || defined(__EMX__))
-#include <inttypes.h>
-#endif
-
-typedef signed char FLAC__int8;
-typedef unsigned char FLAC__uint8;
-
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-typedef __int16 FLAC__int16;
-typedef __int32 FLAC__int32;
-typedef __int64 FLAC__int64;
-typedef unsigned __int16 FLAC__uint16;
-typedef unsigned __int32 FLAC__uint32;
-typedef unsigned __int64 FLAC__uint64;
-#elif defined(__EMX__)
-typedef short FLAC__int16;
-typedef long FLAC__int32;
-typedef long long FLAC__int64;
-typedef unsigned short FLAC__uint16;
-typedef unsigned long FLAC__uint32;
-typedef unsigned long long FLAC__uint64;
-#else
-typedef int16_t FLAC__int16;
-typedef int32_t FLAC__int32;
-typedef int64_t FLAC__int64;
-typedef uint16_t FLAC__uint16;
-typedef uint32_t FLAC__uint32;
-typedef uint64_t FLAC__uint64;
-#endif
-
-typedef int FLAC__bool;
-
-typedef FLAC__uint8 FLAC__byte;
-
-#ifdef true
-#undef true
-#endif
-#ifdef false
-#undef false
-#endif
-#ifndef __cplusplus
-#define true 1
-#define false 0
-#endif
-
-#endif
diff --git a/src/thirdparty/libflac/include/FLAC/stream_decoder.h b/src/thirdparty/libflac/include/FLAC/stream_decoder.h
deleted file mode 100644
index 9bbca4d7a..000000000
--- a/src/thirdparty/libflac/include/FLAC/stream_decoder.h
+++ /dev/null
@@ -1,1559 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__STREAM_DECODER_H
-#define FLAC__STREAM_DECODER_H
-
-#include <stdio.h> /* for FILE */
-#include "export.h"
-#include "format.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/** \file include/FLAC/stream_decoder.h
- *
- * \brief
- * This module contains the functions which implement the stream
- * decoder.
- *
- * See the detailed documentation in the
- * \link flac_stream_decoder stream decoder \endlink module.
- */
-
-/** \defgroup flac_decoder FLAC/ \*_decoder.h: decoder interfaces
- * \ingroup flac
- *
- * \brief
- * This module describes the decoder layers provided by libFLAC.
- *
- * The stream decoder can be used to decode complete streams either from
- * the client via callbacks, or directly from a file, depending on how
- * it is initialized. When decoding via callbacks, the client provides
- * callbacks for reading FLAC data and writing decoded samples, and
- * handling metadata and errors. If the client also supplies seek-related
- * callback, the decoder function for sample-accurate seeking within the
- * FLAC input is also available. When decoding from a file, the client
- * needs only supply a filename or open \c FILE* and write/metadata/error
- * callbacks; the rest of the callbacks are supplied internally. For more
- * info see the \link flac_stream_decoder stream decoder \endlink module.
- */
-
-/** \defgroup flac_stream_decoder FLAC/stream_decoder.h: stream decoder interface
- * \ingroup flac_decoder
- *
- * \brief
- * This module contains the functions which implement the stream
- * decoder.
- *
- * The stream decoder can decode native FLAC, and optionally Ogg FLAC
- * (check FLAC_API_SUPPORTS_OGG_FLAC) streams and files.
- *
- * The basic usage of this decoder is as follows:
- * - The program creates an instance of a decoder using
- * FLAC__stream_decoder_new().
- * - The program overrides the default settings using
- * FLAC__stream_decoder_set_*() functions.
- * - The program initializes the instance to validate the settings and
- * prepare for decoding using
- * - FLAC__stream_decoder_init_stream() or FLAC__stream_decoder_init_FILE()
- * or FLAC__stream_decoder_init_file() for native FLAC,
- * - FLAC__stream_decoder_init_ogg_stream() or FLAC__stream_decoder_init_ogg_FILE()
- * or FLAC__stream_decoder_init_ogg_file() for Ogg FLAC
- * - The program calls the FLAC__stream_decoder_process_*() functions
- * to decode data, which subsequently calls the callbacks.
- * - The program finishes the decoding with FLAC__stream_decoder_finish(),
- * which flushes the input and output and resets the decoder to the
- * uninitialized state.
- * - The instance may be used again or deleted with
- * FLAC__stream_decoder_delete().
- *
- * In more detail, the program will create a new instance by calling
- * FLAC__stream_decoder_new(), then call FLAC__stream_decoder_set_*()
- * functions to override the default decoder options, and call
- * one of the FLAC__stream_decoder_init_*() functions.
- *
- * There are three initialization functions for native FLAC, one for
- * setting up the decoder to decode FLAC data from the client via
- * callbacks, and two for decoding directly from a FLAC file.
- *
- * For decoding via callbacks, use FLAC__stream_decoder_init_stream().
- * You must also supply several callbacks for handling I/O. Some (like
- * seeking) are optional, depending on the capabilities of the input.
- *
- * For decoding directly from a file, use FLAC__stream_decoder_init_FILE()
- * or FLAC__stream_decoder_init_file(). Then you must only supply an open
- * \c FILE* or filename and fewer callbacks; the decoder will handle
- * the other callbacks internally.
- *
- * There are three similarly-named init functions for decoding from Ogg
- * FLAC streams. Check \c FLAC_API_SUPPORTS_OGG_FLAC to find out if the
- * library has been built with Ogg support.
- *
- * Once the decoder is initialized, your program will call one of several
- * functions to start the decoding process:
- *
- * - FLAC__stream_decoder_process_single() - Tells the decoder to process at
- * most one metadata block or audio frame and return, calling either the
- * metadata callback or write callback, respectively, once. If the decoder
- * loses sync it will return with only the error callback being called.
- * - FLAC__stream_decoder_process_until_end_of_metadata() - Tells the decoder
- * to process the stream from the current location and stop upon reaching
- * the first audio frame. The client will get one metadata, write, or error
- * callback per metadata block, audio frame, or sync error, respectively.
- * - FLAC__stream_decoder_process_until_end_of_stream() - Tells the decoder
- * to process the stream from the current location until the read callback
- * returns FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM or
- * FLAC__STREAM_DECODER_READ_STATUS_ABORT. The client will get one metadata,
- * write, or error callback per metadata block, audio frame, or sync error,
- * respectively.
- *
- * When the decoder has finished decoding (normally or through an abort),
- * the instance is finished by calling FLAC__stream_decoder_finish(), which
- * ensures the decoder is in the correct state and frees memory. Then the
- * instance may be deleted with FLAC__stream_decoder_delete() or initialized
- * again to decode another stream.
- *
- * Seeking is exposed through the FLAC__stream_decoder_seek_absolute() method.
- * At any point after the stream decoder has been initialized, the client can
- * call this function to seek to an exact sample within the stream.
- * Subsequently, the first time the write callback is called it will be
- * passed a (possibly partial) block starting at that sample.
- *
- * If the client cannot seek via the callback interface provided, but still
- * has another way of seeking, it can flush the decoder using
- * FLAC__stream_decoder_flush() and start feeding data from the new position
- * through the read callback.
- *
- * The stream decoder also provides MD5 signature checking. If this is
- * turned on before initialization, FLAC__stream_decoder_finish() will
- * report when the decoded MD5 signature does not match the one stored
- * in the STREAMINFO block. MD5 checking is automatically turned off
- * (until the next FLAC__stream_decoder_reset()) if there is no signature
- * in the STREAMINFO block or when a seek is attempted.
- *
- * The FLAC__stream_decoder_set_metadata_*() functions deserve special
- * attention. By default, the decoder only calls the metadata_callback for
- * the STREAMINFO block. These functions allow you to tell the decoder
- * explicitly which blocks to parse and return via the metadata_callback
- * and/or which to skip. Use a FLAC__stream_decoder_set_metadata_respond_all(),
- * FLAC__stream_decoder_set_metadata_ignore() ... or FLAC__stream_decoder_set_metadata_ignore_all(),
- * FLAC__stream_decoder_set_metadata_respond() ... sequence to exactly specify
- * which blocks to return. Remember that metadata blocks can potentially
- * be big (for example, cover art) so filtering out the ones you don't
- * use can reduce the memory requirements of the decoder. Also note the
- * special forms FLAC__stream_decoder_set_metadata_respond_application(id)
- * and FLAC__stream_decoder_set_metadata_ignore_application(id) for
- * filtering APPLICATION blocks based on the application ID.
- *
- * STREAMINFO and SEEKTABLE blocks are always parsed and used internally, but
- * they still can legally be filtered from the metadata_callback.
- *
- * \note
- * The "set" functions may only be called when the decoder is in the
- * state FLAC__STREAM_DECODER_UNINITIALIZED, i.e. after
- * FLAC__stream_decoder_new() or FLAC__stream_decoder_finish(), but
- * before FLAC__stream_decoder_init_*(). If this is the case they will
- * return \c true, otherwise \c false.
- *
- * \note
- * FLAC__stream_decoder_finish() resets all settings to the constructor
- * defaults, including the callbacks.
- *
- * \{
- */
-
-
-/** State values for a FLAC__StreamDecoder
- *
- * The decoder's state can be obtained by calling FLAC__stream_decoder_get_state().
- */
-typedef enum {
-
- FLAC__STREAM_DECODER_SEARCH_FOR_METADATA = 0,
- /**< The decoder is ready to search for metadata. */
-
- FLAC__STREAM_DECODER_READ_METADATA,
- /**< The decoder is ready to or is in the process of reading metadata. */
-
- FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC,
- /**< The decoder is ready to or is in the process of searching for the
- * frame sync code.
- */
-
- FLAC__STREAM_DECODER_READ_FRAME,
- /**< The decoder is ready to or is in the process of reading a frame. */
-
- FLAC__STREAM_DECODER_END_OF_STREAM,
- /**< The decoder has reached the end of the stream. */
-
- FLAC__STREAM_DECODER_OGG_ERROR,
- /**< An error occurred in the underlying Ogg layer. */
-
- FLAC__STREAM_DECODER_SEEK_ERROR,
- /**< An error occurred while seeking. The decoder must be flushed
- * with FLAC__stream_decoder_flush() or reset with
- * FLAC__stream_decoder_reset() before decoding can continue.
- */
-
- FLAC__STREAM_DECODER_ABORTED,
- /**< The decoder was aborted by the read callback. */
-
- FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR,
- /**< An error occurred allocating memory. The decoder is in an invalid
- * state and can no longer be used.
- */
-
- FLAC__STREAM_DECODER_UNINITIALIZED
- /**< The decoder is in the uninitialized state; one of the
- * FLAC__stream_decoder_init_*() functions must be called before samples
- * can be processed.
- */
-
-} FLAC__StreamDecoderState;
-
-/** Maps a FLAC__StreamDecoderState to a C string.
- *
- * Using a FLAC__StreamDecoderState as the index to this array
- * will give the string equivalent. The contents should not be modified.
- */
-extern FLAC_API const char * const FLAC__StreamDecoderStateString[];
-
-
-/** Possible return values for the FLAC__stream_decoder_init_*() functions.
- */
-typedef enum {
-
- FLAC__STREAM_DECODER_INIT_STATUS_OK = 0,
- /**< Initialization was successful. */
-
- FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER,
- /**< The library was not compiled with support for the given container
- * format.
- */
-
- FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS,
- /**< A required callback was not supplied. */
-
- FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR,
- /**< An error occurred allocating memory. */
-
- FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE,
- /**< fopen() failed in FLAC__stream_decoder_init_file() or
- * FLAC__stream_decoder_init_ogg_file(). */
-
- FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED
- /**< FLAC__stream_decoder_init_*() was called when the decoder was
- * already initialized, usually because
- * FLAC__stream_decoder_finish() was not called.
- */
-
-} FLAC__StreamDecoderInitStatus;
-
-/** Maps a FLAC__StreamDecoderInitStatus to a C string.
- *
- * Using a FLAC__StreamDecoderInitStatus as the index to this array
- * will give the string equivalent. The contents should not be modified.
- */
-extern FLAC_API const char * const FLAC__StreamDecoderInitStatusString[];
-
-
-/** Return values for the FLAC__StreamDecoder read callback.
- */
-typedef enum {
-
- FLAC__STREAM_DECODER_READ_STATUS_CONTINUE,
- /**< The read was OK and decoding can continue. */
-
- FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM,
- /**< The read was attempted while at the end of the stream. Note that
- * the client must only return this value when the read callback was
- * called when already at the end of the stream. Otherwise, if the read
- * itself moves to the end of the stream, the client should still return
- * the data and \c FLAC__STREAM_DECODER_READ_STATUS_CONTINUE, and then on
- * the next read callback it should return
- * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM with a byte count
- * of \c 0.
- */
-
- FLAC__STREAM_DECODER_READ_STATUS_ABORT
- /**< An unrecoverable error occurred. The decoder will return from the process call. */
-
-} FLAC__StreamDecoderReadStatus;
-
-/** Maps a FLAC__StreamDecoderReadStatus to a C string.
- *
- * Using a FLAC__StreamDecoderReadStatus as the index to this array
- * will give the string equivalent. The contents should not be modified.
- */
-extern FLAC_API const char * const FLAC__StreamDecoderReadStatusString[];
-
-
-/** Return values for the FLAC__StreamDecoder seek callback.
- */
-typedef enum {
-
- FLAC__STREAM_DECODER_SEEK_STATUS_OK,
- /**< The seek was OK and decoding can continue. */
-
- FLAC__STREAM_DECODER_SEEK_STATUS_ERROR,
- /**< An unrecoverable error occurred. The decoder will return from the process call. */
-
- FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED
- /**< Client does not support seeking. */
-
-} FLAC__StreamDecoderSeekStatus;
-
-/** Maps a FLAC__StreamDecoderSeekStatus to a C string.
- *
- * Using a FLAC__StreamDecoderSeekStatus as the index to this array
- * will give the string equivalent. The contents should not be modified.
- */
-extern FLAC_API const char * const FLAC__StreamDecoderSeekStatusString[];
-
-
-/** Return values for the FLAC__StreamDecoder tell callback.
- */
-typedef enum {
-
- FLAC__STREAM_DECODER_TELL_STATUS_OK,
- /**< The tell was OK and decoding can continue. */
-
- FLAC__STREAM_DECODER_TELL_STATUS_ERROR,
- /**< An unrecoverable error occurred. The decoder will return from the process call. */
-
- FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED
- /**< Client does not support telling the position. */
-
-} FLAC__StreamDecoderTellStatus;
-
-/** Maps a FLAC__StreamDecoderTellStatus to a C string.
- *
- * Using a FLAC__StreamDecoderTellStatus as the index to this array
- * will give the string equivalent. The contents should not be modified.
- */
-extern FLAC_API const char * const FLAC__StreamDecoderTellStatusString[];
-
-
-/** Return values for the FLAC__StreamDecoder length callback.
- */
-typedef enum {
-
- FLAC__STREAM_DECODER_LENGTH_STATUS_OK,
- /**< The length call was OK and decoding can continue. */
-
- FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR,
- /**< An unrecoverable error occurred. The decoder will return from the process call. */
-
- FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED
- /**< Client does not support reporting the length. */
-
-} FLAC__StreamDecoderLengthStatus;
-
-/** Maps a FLAC__StreamDecoderLengthStatus to a C string.
- *
- * Using a FLAC__StreamDecoderLengthStatus as the index to this array
- * will give the string equivalent. The contents should not be modified.
- */
-extern FLAC_API const char * const FLAC__StreamDecoderLengthStatusString[];
-
-
-/** Return values for the FLAC__StreamDecoder write callback.
- */
-typedef enum {
-
- FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE,
- /**< The write was OK and decoding can continue. */
-
- FLAC__STREAM_DECODER_WRITE_STATUS_ABORT
- /**< An unrecoverable error occurred. The decoder will return from the process call. */
-
-} FLAC__StreamDecoderWriteStatus;
-
-/** Maps a FLAC__StreamDecoderWriteStatus to a C string.
- *
- * Using a FLAC__StreamDecoderWriteStatus as the index to this array
- * will give the string equivalent. The contents should not be modified.
- */
-extern FLAC_API const char * const FLAC__StreamDecoderWriteStatusString[];
-
-
-/** Possible values passed back to the FLAC__StreamDecoder error callback.
- * \c FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC is the generic catch-
- * all. The rest could be caused by bad sync (false synchronization on
- * data that is not the start of a frame) or corrupted data. The error
- * itself is the decoder's best guess at what happened assuming a correct
- * sync. For example \c FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER
- * could be caused by a correct sync on the start of a frame, but some
- * data in the frame header was corrupted. Or it could be the result of
- * syncing on a point the stream that looked like the starting of a frame
- * but was not. \c FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM
- * could be because the decoder encountered a valid frame made by a future
- * version of the encoder which it cannot parse, or because of a false
- * sync making it appear as though an encountered frame was generated by
- * a future encoder.
- */
-typedef enum {
-
- FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC,
- /**< An error in the stream caused the decoder to lose synchronization. */
-
- FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER,
- /**< The decoder encountered a corrupted frame header. */
-
- FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH,
- /**< The frame's data did not match the CRC in the footer. */
-
- FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM
- /**< The decoder encountered reserved fields in use in the stream. */
-
-} FLAC__StreamDecoderErrorStatus;
-
-/** Maps a FLAC__StreamDecoderErrorStatus to a C string.
- *
- * Using a FLAC__StreamDecoderErrorStatus as the index to this array
- * will give the string equivalent. The contents should not be modified.
- */
-extern FLAC_API const char * const FLAC__StreamDecoderErrorStatusString[];
-
-
-/***********************************************************************
- *
- * class FLAC__StreamDecoder
- *
- ***********************************************************************/
-
-struct FLAC__StreamDecoderProtected;
-struct FLAC__StreamDecoderPrivate;
-/** The opaque structure definition for the stream decoder type.
- * See the \link flac_stream_decoder stream decoder module \endlink
- * for a detailed description.
- */
-typedef struct {
- struct FLAC__StreamDecoderProtected *protected_; /* avoid the C++ keyword 'protected' */
- struct FLAC__StreamDecoderPrivate *private_; /* avoid the C++ keyword 'private' */
-} FLAC__StreamDecoder;
-
-/** Signature for the read callback.
- *
- * A function pointer matching this signature must be passed to
- * FLAC__stream_decoder_init*_stream(). The supplied function will be
- * called when the decoder needs more input data. The address of the
- * buffer to be filled is supplied, along with the number of bytes the
- * buffer can hold. The callback may choose to supply less data and
- * modify the byte count but must be careful not to overflow the buffer.
- * The callback then returns a status code chosen from
- * FLAC__StreamDecoderReadStatus.
- *
- * Here is an example of a read callback for stdio streams:
- * \code
- * FLAC__StreamDecoderReadStatus read_cb(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
- * {
- * FILE *file = ((MyClientData*)client_data)->file;
- * if(*bytes > 0) {
- * *bytes = fread(buffer, sizeof(FLAC__byte), *bytes, file);
- * if(ferror(file))
- * return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
- * else if(*bytes == 0)
- * return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
- * else
- * return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
- * }
- * else
- * return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
- * }
- * \endcode
- *
- * \note In general, FLAC__StreamDecoder functions which change the
- * state should not be called on the \a decoder while in the callback.
- *
- * \param decoder The decoder instance calling the callback.
- * \param buffer A pointer to a location for the callee to store
- * data to be decoded.
- * \param bytes A pointer to the size of the buffer. On entry
- * to the callback, it contains the maximum number
- * of bytes that may be stored in \a buffer. The
- * callee must set it to the actual number of bytes
- * stored (0 in case of error or end-of-stream) before
- * returning.
- * \param client_data The callee's client data set through
- * FLAC__stream_decoder_init_*().
- * \retval FLAC__StreamDecoderReadStatus
- * The callee's return status. Note that the callback should return
- * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM if and only if
- * zero bytes were read and there is no more data to be read.
- */
-typedef FLAC__StreamDecoderReadStatus (*FLAC__StreamDecoderReadCallback)(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
-
-/** Signature for the seek callback.
- *
- * A function pointer matching this signature may be passed to
- * FLAC__stream_decoder_init*_stream(). The supplied function will be
- * called when the decoder needs to seek the input stream. The decoder
- * will pass the absolute byte offset to seek to, 0 meaning the
- * beginning of the stream.
- *
- * Here is an example of a seek callback for stdio streams:
- * \code
- * FLAC__StreamDecoderSeekStatus seek_cb(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data)
- * {
- * FILE *file = ((MyClientData*)client_data)->file;
- * if(file == stdin)
- * return FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED;
- * else if(fseeko(file, (off_t)absolute_byte_offset, SEEK_SET) < 0)
- * return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
- * else
- * return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
- * }
- * \endcode
- *
- * \note In general, FLAC__StreamDecoder functions which change the
- * state should not be called on the \a decoder while in the callback.
- *
- * \param decoder The decoder instance calling the callback.
- * \param absolute_byte_offset The offset from the beginning of the stream
- * to seek to.
- * \param client_data The callee's client data set through
- * FLAC__stream_decoder_init_*().
- * \retval FLAC__StreamDecoderSeekStatus
- * The callee's return status.
- */
-typedef FLAC__StreamDecoderSeekStatus (*FLAC__StreamDecoderSeekCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
-
-/** Signature for the tell callback.
- *
- * A function pointer matching this signature may be passed to
- * FLAC__stream_decoder_init*_stream(). The supplied function will be
- * called when the decoder wants to know the current position of the
- * stream. The callback should return the byte offset from the
- * beginning of the stream.
- *
- * Here is an example of a tell callback for stdio streams:
- * \code
- * FLAC__StreamDecoderTellStatus tell_cb(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data)
- * {
- * FILE *file = ((MyClientData*)client_data)->file;
- * off_t pos;
- * if(file == stdin)
- * return FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED;
- * else if((pos = ftello(file)) < 0)
- * return FLAC__STREAM_DECODER_TELL_STATUS_ERROR;
- * else {
- * *absolute_byte_offset = (FLAC__uint64)pos;
- * return FLAC__STREAM_DECODER_TELL_STATUS_OK;
- * }
- * }
- * \endcode
- *
- * \note In general, FLAC__StreamDecoder functions which change the
- * state should not be called on the \a decoder while in the callback.
- *
- * \param decoder The decoder instance calling the callback.
- * \param absolute_byte_offset A pointer to storage for the current offset
- * from the beginning of the stream.
- * \param client_data The callee's client data set through
- * FLAC__stream_decoder_init_*().
- * \retval FLAC__StreamDecoderTellStatus
- * The callee's return status.
- */
-typedef FLAC__StreamDecoderTellStatus (*FLAC__StreamDecoderTellCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
-
-/** Signature for the length callback.
- *
- * A function pointer matching this signature may be passed to
- * FLAC__stream_decoder_init*_stream(). The supplied function will be
- * called when the decoder wants to know the total length of the stream
- * in bytes.
- *
- * Here is an example of a length callback for stdio streams:
- * \code
- * FLAC__StreamDecoderLengthStatus length_cb(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data)
- * {
- * FILE *file = ((MyClientData*)client_data)->file;
- * struct stat filestats;
- *
- * if(file == stdin)
- * return FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED;
- * else if(fstat(fileno(file), &filestats) != 0)
- * return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
- * else {
- * *stream_length = (FLAC__uint64)filestats.st_size;
- * return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
- * }
- * }
- * \endcode
- *
- * \note In general, FLAC__StreamDecoder functions which change the
- * state should not be called on the \a decoder while in the callback.
- *
- * \param decoder The decoder instance calling the callback.
- * \param stream_length A pointer to storage for the length of the stream
- * in bytes.
- * \param client_data The callee's client data set through
- * FLAC__stream_decoder_init_*().
- * \retval FLAC__StreamDecoderLengthStatus
- * The callee's return status.
- */
-typedef FLAC__StreamDecoderLengthStatus (*FLAC__StreamDecoderLengthCallback)(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
-
-/** Signature for the EOF callback.
- *
- * A function pointer matching this signature may be passed to
- * FLAC__stream_decoder_init*_stream(). The supplied function will be
- * called when the decoder needs to know if the end of the stream has
- * been reached.
- *
- * Here is an example of a EOF callback for stdio streams:
- * FLAC__bool eof_cb(const FLAC__StreamDecoder *decoder, void *client_data)
- * \code
- * {
- * FILE *file = ((MyClientData*)client_data)->file;
- * return feof(file)? true : false;
- * }
- * \endcode
- *
- * \note In general, FLAC__StreamDecoder functions which change the
- * state should not be called on the \a decoder while in the callback.
- *
- * \param decoder The decoder instance calling the callback.
- * \param client_data The callee's client data set through
- * FLAC__stream_decoder_init_*().
- * \retval FLAC__bool
- * \c true if the currently at the end of the stream, else \c false.
- */
-typedef FLAC__bool (*FLAC__StreamDecoderEofCallback)(const FLAC__StreamDecoder *decoder, void *client_data);
-
-/** Signature for the write callback.
- *
- * A function pointer matching this signature must be passed to one of
- * the FLAC__stream_decoder_init_*() functions.
- * The supplied function will be called when the decoder has decoded a
- * single audio frame. The decoder will pass the frame metadata as well
- * as an array of pointers (one for each channel) pointing to the
- * decoded audio.
- *
- * \note In general, FLAC__StreamDecoder functions which change the
- * state should not be called on the \a decoder while in the callback.
- *
- * \param decoder The decoder instance calling the callback.
- * \param frame The description of the decoded frame. See
- * FLAC__Frame.
- * \param buffer An array of pointers to decoded channels of data.
- * Each pointer will point to an array of signed
- * samples of length \a frame->header.blocksize.
- * Channels will be ordered according to the FLAC
- * specification; see the documentation for the
- * <A HREF="../format.html#frame_header">frame header</A>.
- * \param client_data The callee's client data set through
- * FLAC__stream_decoder_init_*().
- * \retval FLAC__StreamDecoderWriteStatus
- * The callee's return status.
- */
-typedef FLAC__StreamDecoderWriteStatus (*FLAC__StreamDecoderWriteCallback)(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
-
-/** Signature for the metadata callback.
- *
- * A function pointer matching this signature must be passed to one of
- * the FLAC__stream_decoder_init_*() functions.
- * The supplied function will be called when the decoder has decoded a
- * metadata block. In a valid FLAC file there will always be one
- * \c STREAMINFO block, followed by zero or more other metadata blocks.
- * These will be supplied by the decoder in the same order as they
- * appear in the stream and always before the first audio frame (i.e.
- * write callback). The metadata block that is passed in must not be
- * modified, and it doesn't live beyond the callback, so you should make
- * a copy of it with FLAC__metadata_object_clone() if you will need it
- * elsewhere. Since metadata blocks can potentially be large, by
- * default the decoder only calls the metadata callback for the
- * \c STREAMINFO block; you can instruct the decoder to pass or filter
- * other blocks with FLAC__stream_decoder_set_metadata_*() calls.
- *
- * \note In general, FLAC__StreamDecoder functions which change the
- * state should not be called on the \a decoder while in the callback.
- *
- * \param decoder The decoder instance calling the callback.
- * \param metadata The decoded metadata block.
- * \param client_data The callee's client data set through
- * FLAC__stream_decoder_init_*().
- */
-typedef void (*FLAC__StreamDecoderMetadataCallback)(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
-
-/** Signature for the error callback.
- *
- * A function pointer matching this signature must be passed to one of
- * the FLAC__stream_decoder_init_*() functions.
- * The supplied function will be called whenever an error occurs during
- * decoding.
- *
- * \note In general, FLAC__StreamDecoder functions which change the
- * state should not be called on the \a decoder while in the callback.
- *
- * \param decoder The decoder instance calling the callback.
- * \param status The error encountered by the decoder.
- * \param client_data The callee's client data set through
- * FLAC__stream_decoder_init_*().
- */
-typedef void (*FLAC__StreamDecoderErrorCallback)(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
-
-
-/***********************************************************************
- *
- * Class constructor/destructor
- *
- ***********************************************************************/
-
-/** Create a new stream decoder instance. The instance is created with
- * default settings; see the individual FLAC__stream_decoder_set_*()
- * functions for each setting's default.
- *
- * \retval FLAC__StreamDecoder*
- * \c NULL if there was an error allocating memory, else the new instance.
- */
-FLAC_API FLAC__StreamDecoder *FLAC__stream_decoder_new(void);
-
-/** Free a decoder instance. Deletes the object pointed to by \a decoder.
- *
- * \param decoder A pointer to an existing decoder.
- * \assert
- * \code decoder != NULL \endcode
- */
-FLAC_API void FLAC__stream_decoder_delete(FLAC__StreamDecoder *decoder);
-
-
-/***********************************************************************
- *
- * Public class method prototypes
- *
- ***********************************************************************/
-
-/** Set the serial number for the FLAC stream within the Ogg container.
- * The default behavior is to use the serial number of the first Ogg
- * page. Setting a serial number here will explicitly specify which
- * stream is to be decoded.
- *
- * \note
- * This does not need to be set for native FLAC decoding.
- *
- * \default \c use serial number of first page
- * \param decoder A decoder instance to set.
- * \param serial_number See above.
- * \assert
- * \code decoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if the decoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_decoder_set_ogg_serial_number(FLAC__StreamDecoder *decoder, long serial_number);
-
-/** Set the "MD5 signature checking" flag. If \c true, the decoder will
- * compute the MD5 signature of the unencoded audio data while decoding
- * and compare it to the signature from the STREAMINFO block, if it
- * exists, during FLAC__stream_decoder_finish().
- *
- * MD5 signature checking will be turned off (until the next
- * FLAC__stream_decoder_reset()) if there is no signature in the
- * STREAMINFO block or when a seek is attempted.
- *
- * Clients that do not use the MD5 check should leave this off to speed
- * up decoding.
- *
- * \default \c false
- * \param decoder A decoder instance to set.
- * \param value Flag value (see above).
- * \assert
- * \code decoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if the decoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_decoder_set_md5_checking(FLAC__StreamDecoder *decoder, FLAC__bool value);
-
-/** Direct the decoder to pass on all metadata blocks of type \a type.
- *
- * \default By default, only the \c STREAMINFO block is returned via the
- * metadata callback.
- * \param decoder A decoder instance to set.
- * \param type See above.
- * \assert
- * \code decoder != NULL \endcode
- * \a type is valid
- * \retval FLAC__bool
- * \c false if the decoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond(FLAC__StreamDecoder *decoder, FLAC__MetadataType type);
-
-/** Direct the decoder to pass on all APPLICATION metadata blocks of the
- * given \a id.
- *
- * \default By default, only the \c STREAMINFO block is returned via the
- * metadata callback.
- * \param decoder A decoder instance to set.
- * \param id See above.
- * \assert
- * \code decoder != NULL \endcode
- * \code id != NULL \endcode
- * \retval FLAC__bool
- * \c false if the decoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_application(FLAC__StreamDecoder *decoder, const FLAC__byte id[4]);
-
-/** Direct the decoder to pass on all metadata blocks of any type.
- *
- * \default By default, only the \c STREAMINFO block is returned via the
- * metadata callback.
- * \param decoder A decoder instance to set.
- * \assert
- * \code decoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if the decoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_all(FLAC__StreamDecoder *decoder);
-
-/** Direct the decoder to filter out all metadata blocks of type \a type.
- *
- * \default By default, only the \c STREAMINFO block is returned via the
- * metadata callback.
- * \param decoder A decoder instance to set.
- * \param type See above.
- * \assert
- * \code decoder != NULL \endcode
- * \a type is valid
- * \retval FLAC__bool
- * \c false if the decoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore(FLAC__StreamDecoder *decoder, FLAC__MetadataType type);
-
-/** Direct the decoder to filter out all APPLICATION metadata blocks of
- * the given \a id.
- *
- * \default By default, only the \c STREAMINFO block is returned via the
- * metadata callback.
- * \param decoder A decoder instance to set.
- * \param id See above.
- * \assert
- * \code decoder != NULL \endcode
- * \code id != NULL \endcode
- * \retval FLAC__bool
- * \c false if the decoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_application(FLAC__StreamDecoder *decoder, const FLAC__byte id[4]);
-
-/** Direct the decoder to filter out all metadata blocks of any type.
- *
- * \default By default, only the \c STREAMINFO block is returned via the
- * metadata callback.
- * \param decoder A decoder instance to set.
- * \assert
- * \code decoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if the decoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_all(FLAC__StreamDecoder *decoder);
-
-/** Get the current decoder state.
- *
- * \param decoder A decoder instance to query.
- * \assert
- * \code decoder != NULL \endcode
- * \retval FLAC__StreamDecoderState
- * The current decoder state.
- */
-FLAC_API FLAC__StreamDecoderState FLAC__stream_decoder_get_state(const FLAC__StreamDecoder *decoder);
-
-/** Get the current decoder state as a C string.
- *
- * \param decoder A decoder instance to query.
- * \assert
- * \code decoder != NULL \endcode
- * \retval const char *
- * The decoder state as a C string. Do not modify the contents.
- */
-FLAC_API const char *FLAC__stream_decoder_get_resolved_state_string(const FLAC__StreamDecoder *decoder);
-
-/** Get the "MD5 signature checking" flag.
- * This is the value of the setting, not whether or not the decoder is
- * currently checking the MD5 (remember, it can be turned off automatically
- * by a seek). When the decoder is reset the flag will be restored to the
- * value returned by this function.
- *
- * \param decoder A decoder instance to query.
- * \assert
- * \code decoder != NULL \endcode
- * \retval FLAC__bool
- * See above.
- */
-FLAC_API FLAC__bool FLAC__stream_decoder_get_md5_checking(const FLAC__StreamDecoder *decoder);
-
-/** Get the total number of samples in the stream being decoded.
- * Will only be valid after decoding has started and will contain the
- * value from the \c STREAMINFO block. A value of \c 0 means "unknown".
- *
- * \param decoder A decoder instance to query.
- * \assert
- * \code decoder != NULL \endcode
- * \retval unsigned
- * See above.
- */
-FLAC_API FLAC__uint64 FLAC__stream_decoder_get_total_samples(const FLAC__StreamDecoder *decoder);
-
-/** Get the current number of channels in the stream being decoded.
- * Will only be valid after decoding has started and will contain the
- * value from the most recently decoded frame header.
- *
- * \param decoder A decoder instance to query.
- * \assert
- * \code decoder != NULL \endcode
- * \retval unsigned
- * See above.
- */
-FLAC_API unsigned FLAC__stream_decoder_get_channels(const FLAC__StreamDecoder *decoder);
-
-/** Get the current channel assignment in the stream being decoded.
- * Will only be valid after decoding has started and will contain the
- * value from the most recently decoded frame header.
- *
- * \param decoder A decoder instance to query.
- * \assert
- * \code decoder != NULL \endcode
- * \retval FLAC__ChannelAssignment
- * See above.
- */
-FLAC_API FLAC__ChannelAssignment FLAC__stream_decoder_get_channel_assignment(const FLAC__StreamDecoder *decoder);
-
-/** Get the current sample resolution in the stream being decoded.
- * Will only be valid after decoding has started and will contain the
- * value from the most recently decoded frame header.
- *
- * \param decoder A decoder instance to query.
- * \assert
- * \code decoder != NULL \endcode
- * \retval unsigned
- * See above.
- */
-FLAC_API unsigned FLAC__stream_decoder_get_bits_per_sample(const FLAC__StreamDecoder *decoder);
-
-/** Get the current sample rate in Hz of the stream being decoded.
- * Will only be valid after decoding has started and will contain the
- * value from the most recently decoded frame header.
- *
- * \param decoder A decoder instance to query.
- * \assert
- * \code decoder != NULL \endcode
- * \retval unsigned
- * See above.
- */
-FLAC_API unsigned FLAC__stream_decoder_get_sample_rate(const FLAC__StreamDecoder *decoder);
-
-/** Get the current blocksize of the stream being decoded.
- * Will only be valid after decoding has started and will contain the
- * value from the most recently decoded frame header.
- *
- * \param decoder A decoder instance to query.
- * \assert
- * \code decoder != NULL \endcode
- * \retval unsigned
- * See above.
- */
-FLAC_API unsigned FLAC__stream_decoder_get_blocksize(const FLAC__StreamDecoder *decoder);
-
-/** Returns the decoder's current read position within the stream.
- * The position is the byte offset from the start of the stream.
- * Bytes before this position have been fully decoded. Note that
- * there may still be undecoded bytes in the decoder's read FIFO.
- * The returned position is correct even after a seek.
- *
- * \warning This function currently only works for native FLAC,
- * not Ogg FLAC streams.
- *
- * \param decoder A decoder instance to query.
- * \param position Address at which to return the desired position.
- * \assert
- * \code decoder != NULL \endcode
- * \code position != NULL \endcode
- * \retval FLAC__bool
- * \c true if successful, \c false if the stream is not native FLAC,
- * or there was an error from the 'tell' callback or it returned
- * \c FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED.
- */
-FLAC_API FLAC__bool FLAC__stream_decoder_get_decode_position(const FLAC__StreamDecoder *decoder, FLAC__uint64 *position);
-
-/** Initialize the decoder instance to decode native FLAC streams.
- *
- * This flavor of initialization sets up the decoder to decode from a
- * native FLAC stream. I/O is performed via callbacks to the client.
- * For decoding from a plain file via filename or open FILE*,
- * FLAC__stream_decoder_init_file() and FLAC__stream_decoder_init_FILE()
- * provide a simpler interface.
- *
- * This function should be called after FLAC__stream_decoder_new() and
- * FLAC__stream_decoder_set_*() but before any of the
- * FLAC__stream_decoder_process_*() functions. Will set and return the
- * decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA
- * if initialization succeeded.
- *
- * \param decoder An uninitialized decoder instance.
- * \param read_callback See FLAC__StreamDecoderReadCallback. This
- * pointer must not be \c NULL.
- * \param seek_callback See FLAC__StreamDecoderSeekCallback. This
- * pointer may be \c NULL if seeking is not
- * supported. If \a seek_callback is not \c NULL then a
- * \a tell_callback, \a length_callback, and \a eof_callback must also be supplied.
- * Alternatively, a dummy seek callback that just
- * returns \c FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED
- * may also be supplied, all though this is slightly
- * less efficient for the decoder.
- * \param tell_callback See FLAC__StreamDecoderTellCallback. This
- * pointer may be \c NULL if not supported by the client. If
- * \a seek_callback is not \c NULL then a
- * \a tell_callback must also be supplied.
- * Alternatively, a dummy tell callback that just
- * returns \c FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED
- * may also be supplied, all though this is slightly
- * less efficient for the decoder.
- * \param length_callback See FLAC__StreamDecoderLengthCallback. This
- * pointer may be \c NULL if not supported by the client. If
- * \a seek_callback is not \c NULL then a
- * \a length_callback must also be supplied.
- * Alternatively, a dummy length callback that just
- * returns \c FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED
- * may also be supplied, all though this is slightly
- * less efficient for the decoder.
- * \param eof_callback See FLAC__StreamDecoderEofCallback. This
- * pointer may be \c NULL if not supported by the client. If
- * \a seek_callback is not \c NULL then a
- * \a eof_callback must also be supplied.
- * Alternatively, a dummy length callback that just
- * returns \c false
- * may also be supplied, all though this is slightly
- * less efficient for the decoder.
- * \param write_callback See FLAC__StreamDecoderWriteCallback. This
- * pointer must not be \c NULL.
- * \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This
- * pointer may be \c NULL if the callback is not
- * desired.
- * \param error_callback See FLAC__StreamDecoderErrorCallback. This
- * pointer must not be \c NULL.
- * \param client_data This value will be supplied to callbacks in their
- * \a client_data argument.
- * \assert
- * \code decoder != NULL \endcode
- * \retval FLAC__StreamDecoderInitStatus
- * \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful;
- * see FLAC__StreamDecoderInitStatus for the meanings of other return values.
- */
-FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_stream(
- FLAC__StreamDecoder *decoder,
- FLAC__StreamDecoderReadCallback read_callback,
- FLAC__StreamDecoderSeekCallback seek_callback,
- FLAC__StreamDecoderTellCallback tell_callback,
- FLAC__StreamDecoderLengthCallback length_callback,
- FLAC__StreamDecoderEofCallback eof_callback,
- FLAC__StreamDecoderWriteCallback write_callback,
- FLAC__StreamDecoderMetadataCallback metadata_callback,
- FLAC__StreamDecoderErrorCallback error_callback,
- void *client_data
-);
-
-/** Initialize the decoder instance to decode Ogg FLAC streams.
- *
- * This flavor of initialization sets up the decoder to decode from a
- * FLAC stream in an Ogg container. I/O is performed via callbacks to the
- * client. For decoding from a plain file via filename or open FILE*,
- * FLAC__stream_decoder_init_ogg_file() and FLAC__stream_decoder_init_ogg_FILE()
- * provide a simpler interface.
- *
- * This function should be called after FLAC__stream_decoder_new() and
- * FLAC__stream_decoder_set_*() but before any of the
- * FLAC__stream_decoder_process_*() functions. Will set and return the
- * decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA
- * if initialization succeeded.
- *
- * \note Support for Ogg FLAC in the library is optional. If this
- * library has been built without support for Ogg FLAC, this function
- * will return \c FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER.
- *
- * \param decoder An uninitialized decoder instance.
- * \param read_callback See FLAC__StreamDecoderReadCallback. This
- * pointer must not be \c NULL.
- * \param seek_callback See FLAC__StreamDecoderSeekCallback. This
- * pointer may be \c NULL if seeking is not
- * supported. If \a seek_callback is not \c NULL then a
- * \a tell_callback, \a length_callback, and \a eof_callback must also be supplied.
- * Alternatively, a dummy seek callback that just
- * returns \c FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED
- * may also be supplied, all though this is slightly
- * less efficient for the decoder.
- * \param tell_callback See FLAC__StreamDecoderTellCallback. This
- * pointer may be \c NULL if not supported by the client. If
- * \a seek_callback is not \c NULL then a
- * \a tell_callback must also be supplied.
- * Alternatively, a dummy tell callback that just
- * returns \c FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED
- * may also be supplied, all though this is slightly
- * less efficient for the decoder.
- * \param length_callback See FLAC__StreamDecoderLengthCallback. This
- * pointer may be \c NULL if not supported by the client. If
- * \a seek_callback is not \c NULL then a
- * \a length_callback must also be supplied.
- * Alternatively, a dummy length callback that just
- * returns \c FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED
- * may also be supplied, all though this is slightly
- * less efficient for the decoder.
- * \param eof_callback See FLAC__StreamDecoderEofCallback. This
- * pointer may be \c NULL if not supported by the client. If
- * \a seek_callback is not \c NULL then a
- * \a eof_callback must also be supplied.
- * Alternatively, a dummy length callback that just
- * returns \c false
- * may also be supplied, all though this is slightly
- * less efficient for the decoder.
- * \param write_callback See FLAC__StreamDecoderWriteCallback. This
- * pointer must not be \c NULL.
- * \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This
- * pointer may be \c NULL if the callback is not
- * desired.
- * \param error_callback See FLAC__StreamDecoderErrorCallback. This
- * pointer must not be \c NULL.
- * \param client_data This value will be supplied to callbacks in their
- * \a client_data argument.
- * \assert
- * \code decoder != NULL \endcode
- * \retval FLAC__StreamDecoderInitStatus
- * \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful;
- * see FLAC__StreamDecoderInitStatus for the meanings of other return values.
- */
-FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_stream(
- FLAC__StreamDecoder *decoder,
- FLAC__StreamDecoderReadCallback read_callback,
- FLAC__StreamDecoderSeekCallback seek_callback,
- FLAC__StreamDecoderTellCallback tell_callback,
- FLAC__StreamDecoderLengthCallback length_callback,
- FLAC__StreamDecoderEofCallback eof_callback,
- FLAC__StreamDecoderWriteCallback write_callback,
- FLAC__StreamDecoderMetadataCallback metadata_callback,
- FLAC__StreamDecoderErrorCallback error_callback,
- void *client_data
-);
-
-/** Initialize the decoder instance to decode native FLAC files.
- *
- * This flavor of initialization sets up the decoder to decode from a
- * plain native FLAC file. For non-stdio streams, you must use
- * FLAC__stream_decoder_init_stream() and provide callbacks for the I/O.
- *
- * This function should be called after FLAC__stream_decoder_new() and
- * FLAC__stream_decoder_set_*() but before any of the
- * FLAC__stream_decoder_process_*() functions. Will set and return the
- * decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA
- * if initialization succeeded.
- *
- * \param decoder An uninitialized decoder instance.
- * \param file An open FLAC file. The file should have been
- * opened with mode \c "rb" and rewound. The file
- * becomes owned by the decoder and should not be
- * manipulated by the client while decoding.
- * Unless \a file is \c stdin, it will be closed
- * when FLAC__stream_decoder_finish() is called.
- * Note however that seeking will not work when
- * decoding from \c stdout since it is not seekable.
- * \param write_callback See FLAC__StreamDecoderWriteCallback. This
- * pointer must not be \c NULL.
- * \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This
- * pointer may be \c NULL if the callback is not
- * desired.
- * \param error_callback See FLAC__StreamDecoderErrorCallback. This
- * pointer must not be \c NULL.
- * \param client_data This value will be supplied to callbacks in their
- * \a client_data argument.
- * \assert
- * \code decoder != NULL \endcode
- * \code file != NULL \endcode
- * \retval FLAC__StreamDecoderInitStatus
- * \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful;
- * see FLAC__StreamDecoderInitStatus for the meanings of other return values.
- */
-FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_FILE(
- FLAC__StreamDecoder *decoder,
- FILE *file,
- FLAC__StreamDecoderWriteCallback write_callback,
- FLAC__StreamDecoderMetadataCallback metadata_callback,
- FLAC__StreamDecoderErrorCallback error_callback,
- void *client_data
-);
-
-/** Initialize the decoder instance to decode Ogg FLAC files.
- *
- * This flavor of initialization sets up the decoder to decode from a
- * plain Ogg FLAC file. For non-stdio streams, you must use
- * FLAC__stream_decoder_init_ogg_stream() and provide callbacks for the I/O.
- *
- * This function should be called after FLAC__stream_decoder_new() and
- * FLAC__stream_decoder_set_*() but before any of the
- * FLAC__stream_decoder_process_*() functions. Will set and return the
- * decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA
- * if initialization succeeded.
- *
- * \note Support for Ogg FLAC in the library is optional. If this
- * library has been built without support for Ogg FLAC, this function
- * will return \c FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER.
- *
- * \param decoder An uninitialized decoder instance.
- * \param file An open FLAC file. The file should have been
- * opened with mode \c "rb" and rewound. The file
- * becomes owned by the decoder and should not be
- * manipulated by the client while decoding.
- * Unless \a file is \c stdin, it will be closed
- * when FLAC__stream_decoder_finish() is called.
- * Note however that seeking will not work when
- * decoding from \c stdout since it is not seekable.
- * \param write_callback See FLAC__StreamDecoderWriteCallback. This
- * pointer must not be \c NULL.
- * \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This
- * pointer may be \c NULL if the callback is not
- * desired.
- * \param error_callback See FLAC__StreamDecoderErrorCallback. This
- * pointer must not be \c NULL.
- * \param client_data This value will be supplied to callbacks in their
- * \a client_data argument.
- * \assert
- * \code decoder != NULL \endcode
- * \code file != NULL \endcode
- * \retval FLAC__StreamDecoderInitStatus
- * \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful;
- * see FLAC__StreamDecoderInitStatus for the meanings of other return values.
- */
-FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_FILE(
- FLAC__StreamDecoder *decoder,
- FILE *file,
- FLAC__StreamDecoderWriteCallback write_callback,
- FLAC__StreamDecoderMetadataCallback metadata_callback,
- FLAC__StreamDecoderErrorCallback error_callback,
- void *client_data
-);
-
-/** Initialize the decoder instance to decode native FLAC files.
- *
- * This flavor of initialization sets up the decoder to decode from a plain
- * native FLAC file. If POSIX fopen() semantics are not sufficient, (for
- * example, with Unicode filenames on Windows), you must use
- * FLAC__stream_decoder_init_FILE(), or FLAC__stream_decoder_init_stream()
- * and provide callbacks for the I/O.
- *
- * This function should be called after FLAC__stream_decoder_new() and
- * FLAC__stream_decoder_set_*() but before any of the
- * FLAC__stream_decoder_process_*() functions. Will set and return the
- * decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA
- * if initialization succeeded.
- *
- * \param decoder An uninitialized decoder instance.
- * \param filename The name of the file to decode from. The file will
- * be opened with fopen(). Use \c NULL to decode from
- * \c stdin. Note that \c stdin is not seekable.
- * \param write_callback See FLAC__StreamDecoderWriteCallback. This
- * pointer must not be \c NULL.
- * \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This
- * pointer may be \c NULL if the callback is not
- * desired.
- * \param error_callback See FLAC__StreamDecoderErrorCallback. This
- * pointer must not be \c NULL.
- * \param client_data This value will be supplied to callbacks in their
- * \a client_data argument.
- * \assert
- * \code decoder != NULL \endcode
- * \retval FLAC__StreamDecoderInitStatus
- * \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful;
- * see FLAC__StreamDecoderInitStatus for the meanings of other return values.
- */
-FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_file(
- FLAC__StreamDecoder *decoder,
- const char *filename,
- FLAC__StreamDecoderWriteCallback write_callback,
- FLAC__StreamDecoderMetadataCallback metadata_callback,
- FLAC__StreamDecoderErrorCallback error_callback,
- void *client_data
-);
-
-/** Initialize the decoder instance to decode Ogg FLAC files.
- *
- * This flavor of initialization sets up the decoder to decode from a plain
- * Ogg FLAC file. If POSIX fopen() semantics are not sufficient, (for
- * example, with Unicode filenames on Windows), you must use
- * FLAC__stream_decoder_init_ogg_FILE(), or FLAC__stream_decoder_init_ogg_stream()
- * and provide callbacks for the I/O.
- *
- * This function should be called after FLAC__stream_decoder_new() and
- * FLAC__stream_decoder_set_*() but before any of the
- * FLAC__stream_decoder_process_*() functions. Will set and return the
- * decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA
- * if initialization succeeded.
- *
- * \note Support for Ogg FLAC in the library is optional. If this
- * library has been built without support for Ogg FLAC, this function
- * will return \c FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER.
- *
- * \param decoder An uninitialized decoder instance.
- * \param filename The name of the file to decode from. The file will
- * be opened with fopen(). Use \c NULL to decode from
- * \c stdin. Note that \c stdin is not seekable.
- * \param write_callback See FLAC__StreamDecoderWriteCallback. This
- * pointer must not be \c NULL.
- * \param metadata_callback See FLAC__StreamDecoderMetadataCallback. This
- * pointer may be \c NULL if the callback is not
- * desired.
- * \param error_callback See FLAC__StreamDecoderErrorCallback. This
- * pointer must not be \c NULL.
- * \param client_data This value will be supplied to callbacks in their
- * \a client_data argument.
- * \assert
- * \code decoder != NULL \endcode
- * \retval FLAC__StreamDecoderInitStatus
- * \c FLAC__STREAM_DECODER_INIT_STATUS_OK if initialization was successful;
- * see FLAC__StreamDecoderInitStatus for the meanings of other return values.
- */
-FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_file(
- FLAC__StreamDecoder *decoder,
- const char *filename,
- FLAC__StreamDecoderWriteCallback write_callback,
- FLAC__StreamDecoderMetadataCallback metadata_callback,
- FLAC__StreamDecoderErrorCallback error_callback,
- void *client_data
-);
-
-/** Finish the decoding process.
- * Flushes the decoding buffer, releases resources, resets the decoder
- * settings to their defaults, and returns the decoder state to
- * FLAC__STREAM_DECODER_UNINITIALIZED.
- *
- * In the event of a prematurely-terminated decode, it is not strictly
- * necessary to call this immediately before FLAC__stream_decoder_delete()
- * but it is good practice to match every FLAC__stream_decoder_init_*()
- * with a FLAC__stream_decoder_finish().
- *
- * \param decoder An uninitialized decoder instance.
- * \assert
- * \code decoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if MD5 checking is on AND a STREAMINFO block was available
- * AND the MD5 signature in the STREAMINFO block was non-zero AND the
- * signature does not match the one computed by the decoder; else
- * \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder);
-
-/** Flush the stream input.
- * The decoder's input buffer will be cleared and the state set to
- * \c FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC. This will also turn
- * off MD5 checking.
- *
- * \param decoder A decoder instance.
- * \assert
- * \code decoder != NULL \endcode
- * \retval FLAC__bool
- * \c true if successful, else \c false if a memory allocation
- * error occurs (in which case the state will be set to
- * \c FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR).
- */
-FLAC_API FLAC__bool FLAC__stream_decoder_flush(FLAC__StreamDecoder *decoder);
-
-/** Reset the decoding process.
- * The decoder's input buffer will be cleared and the state set to
- * \c FLAC__STREAM_DECODER_SEARCH_FOR_METADATA. This is similar to
- * FLAC__stream_decoder_finish() except that the settings are
- * preserved; there is no need to call FLAC__stream_decoder_init_*()
- * before decoding again. MD5 checking will be restored to its original
- * setting.
- *
- * If the decoder is seekable, or was initialized with
- * FLAC__stream_decoder_init*_FILE() or FLAC__stream_decoder_init*_file(),
- * the decoder will also attempt to seek to the beginning of the file.
- * If this rewind fails, this function will return \c false. It follows
- * that FLAC__stream_decoder_reset() cannot be used when decoding from
- * \c stdin.
- *
- * If the decoder was initialized with FLAC__stream_encoder_init*_stream()
- * and is not seekable (i.e. no seek callback was provided or the seek
- * callback returns \c FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED), it
- * is the duty of the client to start feeding data from the beginning of
- * the stream on the next FLAC__stream_decoder_process() or
- * FLAC__stream_decoder_process_interleaved() call.
- *
- * \param decoder A decoder instance.
- * \assert
- * \code decoder != NULL \endcode
- * \retval FLAC__bool
- * \c true if successful, else \c false if a memory allocation occurs
- * (in which case the state will be set to
- * \c FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR) or a seek error
- * occurs (the state will be unchanged).
- */
-FLAC_API FLAC__bool FLAC__stream_decoder_reset(FLAC__StreamDecoder *decoder);
-
-/** Decode one metadata block or audio frame.
- * This version instructs the decoder to decode a either a single metadata
- * block or a single frame and stop, unless the callbacks return a fatal
- * error or the read callback returns
- * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM.
- *
- * As the decoder needs more input it will call the read callback.
- * Depending on what was decoded, the metadata or write callback will be
- * called with the decoded metadata block or audio frame.
- *
- * Unless there is a fatal read error or end of stream, this function
- * will return once one whole frame is decoded. In other words, if the
- * stream is not synchronized or points to a corrupt frame header, the
- * decoder will continue to try and resync until it gets to a valid
- * frame, then decode one frame, then return. If the decoder points to
- * a frame whose frame CRC in the frame footer does not match the
- * computed frame CRC, this function will issue a
- * FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH error to the
- * error callback, and return, having decoded one complete, although
- * corrupt, frame. (Such corrupted frames are sent as silence of the
- * correct length to the write callback.)
- *
- * \param decoder An initialized decoder instance.
- * \assert
- * \code decoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if any fatal read, write, or memory allocation error
- * occurred (meaning decoding must stop), else \c true; for more
- * information about the decoder, check the decoder state with
- * FLAC__stream_decoder_get_state().
- */
-FLAC_API FLAC__bool FLAC__stream_decoder_process_single(FLAC__StreamDecoder *decoder);
-
-/** Decode until the end of the metadata.
- * This version instructs the decoder to decode from the current position
- * and continue until all the metadata has been read, or until the
- * callbacks return a fatal error or the read callback returns
- * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM.
- *
- * As the decoder needs more input it will call the read callback.
- * As each metadata block is decoded, the metadata callback will be called
- * with the decoded metadata.
- *
- * \param decoder An initialized decoder instance.
- * \assert
- * \code decoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if any fatal read, write, or memory allocation error
- * occurred (meaning decoding must stop), else \c true; for more
- * information about the decoder, check the decoder state with
- * FLAC__stream_decoder_get_state().
- */
-FLAC_API FLAC__bool FLAC__stream_decoder_process_until_end_of_metadata(FLAC__StreamDecoder *decoder);
-
-/** Decode until the end of the stream.
- * This version instructs the decoder to decode from the current position
- * and continue until the end of stream (the read callback returns
- * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM), or until the
- * callbacks return a fatal error.
- *
- * As the decoder needs more input it will call the read callback.
- * As each metadata block and frame is decoded, the metadata or write
- * callback will be called with the decoded metadata or frame.
- *
- * \param decoder An initialized decoder instance.
- * \assert
- * \code decoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if any fatal read, write, or memory allocation error
- * occurred (meaning decoding must stop), else \c true; for more
- * information about the decoder, check the decoder state with
- * FLAC__stream_decoder_get_state().
- */
-FLAC_API FLAC__bool FLAC__stream_decoder_process_until_end_of_stream(FLAC__StreamDecoder *decoder);
-
-/** Skip one audio frame.
- * This version instructs the decoder to 'skip' a single frame and stop,
- * unless the callbacks return a fatal error or the read callback returns
- * \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM.
- *
- * The decoding flow is the same as what occurs when
- * FLAC__stream_decoder_process_single() is called to process an audio
- * frame, except that this function does not decode the parsed data into
- * PCM or call the write callback. The integrity of the frame is still
- * checked the same way as in the other process functions.
- *
- * This function will return once one whole frame is skipped, in the
- * same way that FLAC__stream_decoder_process_single() will return once
- * one whole frame is decoded.
- *
- * This function can be used in more quickly determining FLAC frame
- * boundaries when decoding of the actual data is not needed, for
- * example when an application is separating a FLAC stream into frames
- * for editing or storing in a container. To do this, the application
- * can use FLAC__stream_decoder_skip_single_frame() to quickly advance
- * to the next frame, then use
- * FLAC__stream_decoder_get_decode_position() to find the new frame
- * boundary.
- *
- * This function should only be called when the stream has advanced
- * past all the metadata, otherwise it will return \c false.
- *
- * \param decoder An initialized decoder instance not in a metadata
- * state.
- * \assert
- * \code decoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if any fatal read, write, or memory allocation error
- * occurred (meaning decoding must stop), or if the decoder
- * is in the FLAC__STREAM_DECODER_SEARCH_FOR_METADATA or
- * FLAC__STREAM_DECODER_READ_METADATA state, else \c true; for more
- * information about the decoder, check the decoder state with
- * FLAC__stream_decoder_get_state().
- */
-FLAC_API FLAC__bool FLAC__stream_decoder_skip_single_frame(FLAC__StreamDecoder *decoder);
-
-/** Flush the input and seek to an absolute sample.
- * Decoding will resume at the given sample. Note that because of
- * this, the next write callback may contain a partial block. The
- * client must support seeking the input or this function will fail
- * and return \c false. Furthermore, if the decoder state is
- * \c FLAC__STREAM_DECODER_SEEK_ERROR, then the decoder must be flushed
- * with FLAC__stream_decoder_flush() or reset with
- * FLAC__stream_decoder_reset() before decoding can continue.
- *
- * \param decoder A decoder instance.
- * \param sample The target sample number to seek to.
- * \assert
- * \code decoder != NULL \endcode
- * \retval FLAC__bool
- * \c true if successful, else \c false.
- */
-FLAC_API FLAC__bool FLAC__stream_decoder_seek_absolute(FLAC__StreamDecoder *decoder, FLAC__uint64 sample);
-
-/* \} */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/src/thirdparty/libflac/include/FLAC/stream_encoder.h b/src/thirdparty/libflac/include/FLAC/stream_encoder.h
deleted file mode 100644
index f5bad11bf..000000000
--- a/src/thirdparty/libflac/include/FLAC/stream_encoder.h
+++ /dev/null
@@ -1,1768 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__STREAM_ENCODER_H
-#define FLAC__STREAM_ENCODER_H
-
-#include <stdio.h> /* for FILE */
-#include "export.h"
-#include "format.h"
-#include "stream_decoder.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/** \file include/FLAC/stream_encoder.h
- *
- * \brief
- * This module contains the functions which implement the stream
- * encoder.
- *
- * See the detailed documentation in the
- * \link flac_stream_encoder stream encoder \endlink module.
- */
-
-/** \defgroup flac_encoder FLAC/ \*_encoder.h: encoder interfaces
- * \ingroup flac
- *
- * \brief
- * This module describes the encoder layers provided by libFLAC.
- *
- * The stream encoder can be used to encode complete streams either to the
- * client via callbacks, or directly to a file, depending on how it is
- * initialized. When encoding via callbacks, the client provides a write
- * callback which will be called whenever FLAC data is ready to be written.
- * If the client also supplies a seek callback, the encoder will also
- * automatically handle the writing back of metadata discovered while
- * encoding, like stream info, seek points offsets, etc. When encoding to
- * a file, the client needs only supply a filename or open \c FILE* and an
- * optional progress callback for periodic notification of progress; the
- * write and seek callbacks are supplied internally. For more info see the
- * \link flac_stream_encoder stream encoder \endlink module.
- */
-
-/** \defgroup flac_stream_encoder FLAC/stream_encoder.h: stream encoder interface
- * \ingroup flac_encoder
- *
- * \brief
- * This module contains the functions which implement the stream
- * encoder.
- *
- * The stream encoder can encode to native FLAC, and optionally Ogg FLAC
- * (check FLAC_API_SUPPORTS_OGG_FLAC) streams and files.
- *
- * The basic usage of this encoder is as follows:
- * - The program creates an instance of an encoder using
- * FLAC__stream_encoder_new().
- * - The program overrides the default settings using
- * FLAC__stream_encoder_set_*() functions. At a minimum, the following
- * functions should be called:
- * - FLAC__stream_encoder_set_channels()
- * - FLAC__stream_encoder_set_bits_per_sample()
- * - FLAC__stream_encoder_set_sample_rate()
- * - FLAC__stream_encoder_set_ogg_serial_number() (if encoding to Ogg FLAC)
- * - FLAC__stream_encoder_set_total_samples_estimate() (if known)
- * - If the application wants to control the compression level or set its own
- * metadata, then the following should also be called:
- * - FLAC__stream_encoder_set_compression_level()
- * - FLAC__stream_encoder_set_verify()
- * - FLAC__stream_encoder_set_metadata()
- * - The rest of the set functions should only be called if the client needs
- * exact control over how the audio is compressed; thorough understanding
- * of the FLAC format is necessary to achieve good results.
- * - The program initializes the instance to validate the settings and
- * prepare for encoding using
- * - FLAC__stream_encoder_init_stream() or FLAC__stream_encoder_init_FILE()
- * or FLAC__stream_encoder_init_file() for native FLAC
- * - FLAC__stream_encoder_init_ogg_stream() or FLAC__stream_encoder_init_ogg_FILE()
- * or FLAC__stream_encoder_init_ogg_file() for Ogg FLAC
- * - The program calls FLAC__stream_encoder_process() or
- * FLAC__stream_encoder_process_interleaved() to encode data, which
- * subsequently calls the callbacks when there is encoder data ready
- * to be written.
- * - The program finishes the encoding with FLAC__stream_encoder_finish(),
- * which causes the encoder to encode any data still in its input pipe,
- * update the metadata with the final encoding statistics if output
- * seeking is possible, and finally reset the encoder to the
- * uninitialized state.
- * - The instance may be used again or deleted with
- * FLAC__stream_encoder_delete().
- *
- * In more detail, the stream encoder functions similarly to the
- * \link flac_stream_decoder stream decoder \endlink, but has fewer
- * callbacks and more options. Typically the client will create a new
- * instance by calling FLAC__stream_encoder_new(), then set the necessary
- * parameters with FLAC__stream_encoder_set_*(), and initialize it by
- * calling one of the FLAC__stream_encoder_init_*() functions.
- *
- * Unlike the decoders, the stream encoder has many options that can
- * affect the speed and compression ratio. When setting these parameters
- * you should have some basic knowledge of the format (see the
- * <A HREF="../documentation.html#format">user-level documentation</A>
- * or the <A HREF="../format.html">formal description</A>). The
- * FLAC__stream_encoder_set_*() functions themselves do not validate the
- * values as many are interdependent. The FLAC__stream_encoder_init_*()
- * functions will do this, so make sure to pay attention to the state
- * returned by FLAC__stream_encoder_init_*() to make sure that it is
- * FLAC__STREAM_ENCODER_INIT_STATUS_OK. Any parameters that are not set
- * before FLAC__stream_encoder_init_*() will take on the defaults from
- * the constructor.
- *
- * There are three initialization functions for native FLAC, one for
- * setting up the encoder to encode FLAC data to the client via
- * callbacks, and two for encoding directly to a file.
- *
- * For encoding via callbacks, use FLAC__stream_encoder_init_stream().
- * You must also supply a write callback which will be called anytime
- * there is raw encoded data to write. If the client can seek the output
- * it is best to also supply seek and tell callbacks, as this allows the
- * encoder to go back after encoding is finished to write back
- * information that was collected while encoding, like seek point offsets,
- * frame sizes, etc.
- *
- * For encoding directly to a file, use FLAC__stream_encoder_init_FILE()
- * or FLAC__stream_encoder_init_file(). Then you must only supply a
- * filename or open \c FILE*; the encoder will handle all the callbacks
- * internally. You may also supply a progress callback for periodic
- * notification of the encoding progress.
- *
- * There are three similarly-named init functions for encoding to Ogg
- * FLAC streams. Check \c FLAC_API_SUPPORTS_OGG_FLAC to find out if the
- * library has been built with Ogg support.
- *
- * The call to FLAC__stream_encoder_init_*() currently will also immediately
- * call the write callback several times, once with the \c fLaC signature,
- * and once for each encoded metadata block. Note that for Ogg FLAC
- * encoding you will usually get at least twice the number of callbacks than
- * with native FLAC, one for the Ogg page header and one for the page body.
- *
- * After initializing the instance, the client may feed audio data to the
- * encoder in one of two ways:
- *
- * - Channel separate, through FLAC__stream_encoder_process() - The client
- * will pass an array of pointers to buffers, one for each channel, to
- * the encoder, each of the same length. The samples need not be
- * block-aligned, but each channel should have the same number of samples.
- * - Channel interleaved, through
- * FLAC__stream_encoder_process_interleaved() - The client will pass a single
- * pointer to data that is channel-interleaved (i.e. channel0_sample0,
- * channel1_sample0, ... , channelN_sample0, channel0_sample1, ...).
- * Again, the samples need not be block-aligned but they must be
- * sample-aligned, i.e. the first value should be channel0_sample0 and
- * the last value channelN_sampleM.
- *
- * Note that for either process call, each sample in the buffers should be a
- * signed integer, right-justified to the resolution set by
- * FLAC__stream_encoder_set_bits_per_sample(). For example, if the resolution
- * is 16 bits per sample, the samples should all be in the range [-32768,32767].
- *
- * When the client is finished encoding data, it calls
- * FLAC__stream_encoder_finish(), which causes the encoder to encode any
- * data still in its input pipe, and call the metadata callback with the
- * final encoding statistics. Then the instance may be deleted with
- * FLAC__stream_encoder_delete() or initialized again to encode another
- * stream.
- *
- * For programs that write their own metadata, but that do not know the
- * actual metadata until after encoding, it is advantageous to instruct
- * the encoder to write a PADDING block of the correct size, so that
- * instead of rewriting the whole stream after encoding, the program can
- * just overwrite the PADDING block. If only the maximum size of the
- * metadata is known, the program can write a slightly larger padding
- * block, then split it after encoding.
- *
- * Make sure you understand how lengths are calculated. All FLAC metadata
- * blocks have a 4 byte header which contains the type and length. This
- * length does not include the 4 bytes of the header. See the format page
- * for the specification of metadata blocks and their lengths.
- *
- * \note
- * If you are writing the FLAC data to a file via callbacks, make sure it
- * is open for update (e.g. mode "w+" for stdio streams). This is because
- * after the first encoding pass, the encoder will try to seek back to the
- * beginning of the stream, to the STREAMINFO block, to write some data
- * there. (If using FLAC__stream_encoder_init*_file() or
- * FLAC__stream_encoder_init*_FILE(), the file is managed internally.)
- *
- * \note
- * The "set" functions may only be called when the encoder is in the
- * state FLAC__STREAM_ENCODER_UNINITIALIZED, i.e. after
- * FLAC__stream_encoder_new() or FLAC__stream_encoder_finish(), but
- * before FLAC__stream_encoder_init_*(). If this is the case they will
- * return \c true, otherwise \c false.
- *
- * \note
- * FLAC__stream_encoder_finish() resets all settings to the constructor
- * defaults.
- *
- * \{
- */
-
-
-/** State values for a FLAC__StreamEncoder.
- *
- * The encoder's state can be obtained by calling FLAC__stream_encoder_get_state().
- *
- * If the encoder gets into any other state besides \c FLAC__STREAM_ENCODER_OK
- * or \c FLAC__STREAM_ENCODER_UNINITIALIZED, it becomes invalid for encoding and
- * must be deleted with FLAC__stream_encoder_delete().
- */
-typedef enum {
-
- FLAC__STREAM_ENCODER_OK = 0,
- /**< The encoder is in the normal OK state and samples can be processed. */
-
- FLAC__STREAM_ENCODER_UNINITIALIZED,
- /**< The encoder is in the uninitialized state; one of the
- * FLAC__stream_encoder_init_*() functions must be called before samples
- * can be processed.
- */
-
- FLAC__STREAM_ENCODER_OGG_ERROR,
- /**< An error occurred in the underlying Ogg layer. */
-
- FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR,
- /**< An error occurred in the underlying verify stream decoder;
- * check FLAC__stream_encoder_get_verify_decoder_state().
- */
-
- FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA,
- /**< The verify decoder detected a mismatch between the original
- * audio signal and the decoded audio signal.
- */
-
- FLAC__STREAM_ENCODER_CLIENT_ERROR,
- /**< One of the callbacks returned a fatal error. */
-
- FLAC__STREAM_ENCODER_IO_ERROR,
- /**< An I/O error occurred while opening/reading/writing a file.
- * Check \c errno.
- */
-
- FLAC__STREAM_ENCODER_FRAMING_ERROR,
- /**< An error occurred while writing the stream; usually, the
- * write_callback returned an error.
- */
-
- FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR
- /**< Memory allocation failed. */
-
-} FLAC__StreamEncoderState;
-
-/** Maps a FLAC__StreamEncoderState to a C string.
- *
- * Using a FLAC__StreamEncoderState as the index to this array
- * will give the string equivalent. The contents should not be modified.
- */
-extern FLAC_API const char * const FLAC__StreamEncoderStateString[];
-
-
-/** Possible return values for the FLAC__stream_encoder_init_*() functions.
- */
-typedef enum {
-
- FLAC__STREAM_ENCODER_INIT_STATUS_OK = 0,
- /**< Initialization was successful. */
-
- FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR,
- /**< General failure to set up encoder; call FLAC__stream_encoder_get_state() for cause. */
-
- FLAC__STREAM_ENCODER_INIT_STATUS_UNSUPPORTED_CONTAINER,
- /**< The library was not compiled with support for the given container
- * format.
- */
-
- FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_CALLBACKS,
- /**< A required callback was not supplied. */
-
- FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_NUMBER_OF_CHANNELS,
- /**< The encoder has an invalid setting for number of channels. */
-
- FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BITS_PER_SAMPLE,
- /**< The encoder has an invalid setting for bits-per-sample.
- * FLAC supports 4-32 bps but the reference encoder currently supports
- * only up to 24 bps.
- */
-
- FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_SAMPLE_RATE,
- /**< The encoder has an invalid setting for the input sample rate. */
-
- FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BLOCK_SIZE,
- /**< The encoder has an invalid setting for the block size. */
-
- FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_MAX_LPC_ORDER,
- /**< The encoder has an invalid setting for the maximum LPC order. */
-
- FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_QLP_COEFF_PRECISION,
- /**< The encoder has an invalid setting for the precision of the quantized linear predictor coefficients. */
-
- FLAC__STREAM_ENCODER_INIT_STATUS_BLOCK_SIZE_TOO_SMALL_FOR_LPC_ORDER,
- /**< The specified block size is less than the maximum LPC order. */
-
- FLAC__STREAM_ENCODER_INIT_STATUS_NOT_STREAMABLE,
- /**< The encoder is bound to the <A HREF="../format.html#subset">Subset</A> but other settings violate it. */
-
- FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA,
- /**< The metadata input to the encoder is invalid, in one of the following ways:
- * - FLAC__stream_encoder_set_metadata() was called with a null pointer but a block count > 0
- * - One of the metadata blocks contains an undefined type
- * - It contains an illegal CUESHEET as checked by FLAC__format_cuesheet_is_legal()
- * - It contains an illegal SEEKTABLE as checked by FLAC__format_seektable_is_legal()
- * - It contains more than one SEEKTABLE block or more than one VORBIS_COMMENT block
- */
-
- FLAC__STREAM_ENCODER_INIT_STATUS_ALREADY_INITIALIZED
- /**< FLAC__stream_encoder_init_*() was called when the encoder was
- * already initialized, usually because
- * FLAC__stream_encoder_finish() was not called.
- */
-
-} FLAC__StreamEncoderInitStatus;
-
-/** Maps a FLAC__StreamEncoderInitStatus to a C string.
- *
- * Using a FLAC__StreamEncoderInitStatus as the index to this array
- * will give the string equivalent. The contents should not be modified.
- */
-extern FLAC_API const char * const FLAC__StreamEncoderInitStatusString[];
-
-
-/** Return values for the FLAC__StreamEncoder read callback.
- */
-typedef enum {
-
- FLAC__STREAM_ENCODER_READ_STATUS_CONTINUE,
- /**< The read was OK and decoding can continue. */
-
- FLAC__STREAM_ENCODER_READ_STATUS_END_OF_STREAM,
- /**< The read was attempted at the end of the stream. */
-
- FLAC__STREAM_ENCODER_READ_STATUS_ABORT,
- /**< An unrecoverable error occurred. */
-
- FLAC__STREAM_ENCODER_READ_STATUS_UNSUPPORTED
- /**< Client does not support reading back from the output. */
-
-} FLAC__StreamEncoderReadStatus;
-
-/** Maps a FLAC__StreamEncoderReadStatus to a C string.
- *
- * Using a FLAC__StreamEncoderReadStatus as the index to this array
- * will give the string equivalent. The contents should not be modified.
- */
-extern FLAC_API const char * const FLAC__StreamEncoderReadStatusString[];
-
-
-/** Return values for the FLAC__StreamEncoder write callback.
- */
-typedef enum {
-
- FLAC__STREAM_ENCODER_WRITE_STATUS_OK = 0,
- /**< The write was OK and encoding can continue. */
-
- FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR
- /**< An unrecoverable error occurred. The encoder will return from the process call. */
-
-} FLAC__StreamEncoderWriteStatus;
-
-/** Maps a FLAC__StreamEncoderWriteStatus to a C string.
- *
- * Using a FLAC__StreamEncoderWriteStatus as the index to this array
- * will give the string equivalent. The contents should not be modified.
- */
-extern FLAC_API const char * const FLAC__StreamEncoderWriteStatusString[];
-
-
-/** Return values for the FLAC__StreamEncoder seek callback.
- */
-typedef enum {
-
- FLAC__STREAM_ENCODER_SEEK_STATUS_OK,
- /**< The seek was OK and encoding can continue. */
-
- FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR,
- /**< An unrecoverable error occurred. */
-
- FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED
- /**< Client does not support seeking. */
-
-} FLAC__StreamEncoderSeekStatus;
-
-/** Maps a FLAC__StreamEncoderSeekStatus to a C string.
- *
- * Using a FLAC__StreamEncoderSeekStatus as the index to this array
- * will give the string equivalent. The contents should not be modified.
- */
-extern FLAC_API const char * const FLAC__StreamEncoderSeekStatusString[];
-
-
-/** Return values for the FLAC__StreamEncoder tell callback.
- */
-typedef enum {
-
- FLAC__STREAM_ENCODER_TELL_STATUS_OK,
- /**< The tell was OK and encoding can continue. */
-
- FLAC__STREAM_ENCODER_TELL_STATUS_ERROR,
- /**< An unrecoverable error occurred. */
-
- FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED
- /**< Client does not support seeking. */
-
-} FLAC__StreamEncoderTellStatus;
-
-/** Maps a FLAC__StreamEncoderTellStatus to a C string.
- *
- * Using a FLAC__StreamEncoderTellStatus as the index to this array
- * will give the string equivalent. The contents should not be modified.
- */
-extern FLAC_API const char * const FLAC__StreamEncoderTellStatusString[];
-
-
-/***********************************************************************
- *
- * class FLAC__StreamEncoder
- *
- ***********************************************************************/
-
-struct FLAC__StreamEncoderProtected;
-struct FLAC__StreamEncoderPrivate;
-/** The opaque structure definition for the stream encoder type.
- * See the \link flac_stream_encoder stream encoder module \endlink
- * for a detailed description.
- */
-typedef struct {
- struct FLAC__StreamEncoderProtected *protected_; /* avoid the C++ keyword 'protected' */
- struct FLAC__StreamEncoderPrivate *private_; /* avoid the C++ keyword 'private' */
-} FLAC__StreamEncoder;
-
-/** Signature for the read callback.
- *
- * A function pointer matching this signature must be passed to
- * FLAC__stream_encoder_init_ogg_stream() if seeking is supported.
- * The supplied function will be called when the encoder needs to read back
- * encoded data. This happens during the metadata callback, when the encoder
- * has to read, modify, and rewrite the metadata (e.g. seekpoints) gathered
- * while encoding. The address of the buffer to be filled is supplied, along
- * with the number of bytes the buffer can hold. The callback may choose to
- * supply less data and modify the byte count but must be careful not to
- * overflow the buffer. The callback then returns a status code chosen from
- * FLAC__StreamEncoderReadStatus.
- *
- * Here is an example of a read callback for stdio streams:
- * \code
- * FLAC__StreamEncoderReadStatus read_cb(const FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
- * {
- * FILE *file = ((MyClientData*)client_data)->file;
- * if(*bytes > 0) {
- * *bytes = fread(buffer, sizeof(FLAC__byte), *bytes, file);
- * if(ferror(file))
- * return FLAC__STREAM_ENCODER_READ_STATUS_ABORT;
- * else if(*bytes == 0)
- * return FLAC__STREAM_ENCODER_READ_STATUS_END_OF_STREAM;
- * else
- * return FLAC__STREAM_ENCODER_READ_STATUS_CONTINUE;
- * }
- * else
- * return FLAC__STREAM_ENCODER_READ_STATUS_ABORT;
- * }
- * \endcode
- *
- * \note In general, FLAC__StreamEncoder functions which change the
- * state should not be called on the \a encoder while in the callback.
- *
- * \param encoder The encoder instance calling the callback.
- * \param buffer A pointer to a location for the callee to store
- * data to be encoded.
- * \param bytes A pointer to the size of the buffer. On entry
- * to the callback, it contains the maximum number
- * of bytes that may be stored in \a buffer. The
- * callee must set it to the actual number of bytes
- * stored (0 in case of error or end-of-stream) before
- * returning.
- * \param client_data The callee's client data set through
- * FLAC__stream_encoder_set_client_data().
- * \retval FLAC__StreamEncoderReadStatus
- * The callee's return status.
- */
-typedef FLAC__StreamEncoderReadStatus (*FLAC__StreamEncoderReadCallback)(const FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
-
-/** Signature for the write callback.
- *
- * A function pointer matching this signature must be passed to
- * FLAC__stream_encoder_init*_stream(). The supplied function will be called
- * by the encoder anytime there is raw encoded data ready to write. It may
- * include metadata mixed with encoded audio frames and the data is not
- * guaranteed to be aligned on frame or metadata block boundaries.
- *
- * The only duty of the callback is to write out the \a bytes worth of data
- * in \a buffer to the current position in the output stream. The arguments
- * \a samples and \a current_frame are purely informational. If \a samples
- * is greater than \c 0, then \a current_frame will hold the current frame
- * number that is being written; otherwise it indicates that the write
- * callback is being called to write metadata.
- *
- * \note
- * Unlike when writing to native FLAC, when writing to Ogg FLAC the
- * write callback will be called twice when writing each audio
- * frame; once for the page header, and once for the page body.
- * When writing the page header, the \a samples argument to the
- * write callback will be \c 0.
- *
- * \note In general, FLAC__StreamEncoder functions which change the
- * state should not be called on the \a encoder while in the callback.
- *
- * \param encoder The encoder instance calling the callback.
- * \param buffer An array of encoded data of length \a bytes.
- * \param bytes The byte length of \a buffer.
- * \param samples The number of samples encoded by \a buffer.
- * \c 0 has a special meaning; see above.
- * \param current_frame The number of the current frame being encoded.
- * \param client_data The callee's client data set through
- * FLAC__stream_encoder_init_*().
- * \retval FLAC__StreamEncoderWriteStatus
- * The callee's return status.
- */
-typedef FLAC__StreamEncoderWriteStatus (*FLAC__StreamEncoderWriteCallback)(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, void *client_data);
-
-/** Signature for the seek callback.
- *
- * A function pointer matching this signature may be passed to
- * FLAC__stream_encoder_init*_stream(). The supplied function will be called
- * when the encoder needs to seek the output stream. The encoder will pass
- * the absolute byte offset to seek to, 0 meaning the beginning of the stream.
- *
- * Here is an example of a seek callback for stdio streams:
- * \code
- * FLAC__StreamEncoderSeekStatus seek_cb(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data)
- * {
- * FILE *file = ((MyClientData*)client_data)->file;
- * if(file == stdin)
- * return FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED;
- * else if(fseeko(file, (off_t)absolute_byte_offset, SEEK_SET) < 0)
- * return FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR;
- * else
- * return FLAC__STREAM_ENCODER_SEEK_STATUS_OK;
- * }
- * \endcode
- *
- * \note In general, FLAC__StreamEncoder functions which change the
- * state should not be called on the \a encoder while in the callback.
- *
- * \param encoder The encoder instance calling the callback.
- * \param absolute_byte_offset The offset from the beginning of the stream
- * to seek to.
- * \param client_data The callee's client data set through
- * FLAC__stream_encoder_init_*().
- * \retval FLAC__StreamEncoderSeekStatus
- * The callee's return status.
- */
-typedef FLAC__StreamEncoderSeekStatus (*FLAC__StreamEncoderSeekCallback)(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
-
-/** Signature for the tell callback.
- *
- * A function pointer matching this signature may be passed to
- * FLAC__stream_encoder_init*_stream(). The supplied function will be called
- * when the encoder needs to know the current position of the output stream.
- *
- * \warning
- * The callback must return the true current byte offset of the output to
- * which the encoder is writing. If you are buffering the output, make
- * sure and take this into account. If you are writing directly to a
- * FILE* from your write callback, ftell() is sufficient. If you are
- * writing directly to a file descriptor from your write callback, you
- * can use lseek(fd, SEEK_CUR, 0). The encoder may later seek back to
- * these points to rewrite metadata after encoding.
- *
- * Here is an example of a tell callback for stdio streams:
- * \code
- * FLAC__StreamEncoderTellStatus tell_cb(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data)
- * {
- * FILE *file = ((MyClientData*)client_data)->file;
- * off_t pos;
- * if(file == stdin)
- * return FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED;
- * else if((pos = ftello(file)) < 0)
- * return FLAC__STREAM_ENCODER_TELL_STATUS_ERROR;
- * else {
- * *absolute_byte_offset = (FLAC__uint64)pos;
- * return FLAC__STREAM_ENCODER_TELL_STATUS_OK;
- * }
- * }
- * \endcode
- *
- * \note In general, FLAC__StreamEncoder functions which change the
- * state should not be called on the \a encoder while in the callback.
- *
- * \param encoder The encoder instance calling the callback.
- * \param absolute_byte_offset The address at which to store the current
- * position of the output.
- * \param client_data The callee's client data set through
- * FLAC__stream_encoder_init_*().
- * \retval FLAC__StreamEncoderTellStatus
- * The callee's return status.
- */
-typedef FLAC__StreamEncoderTellStatus (*FLAC__StreamEncoderTellCallback)(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
-
-/** Signature for the metadata callback.
- *
- * A function pointer matching this signature may be passed to
- * FLAC__stream_encoder_init*_stream(). The supplied function will be called
- * once at the end of encoding with the populated STREAMINFO structure. This
- * is so the client can seek back to the beginning of the file and write the
- * STREAMINFO block with the correct statistics after encoding (like
- * minimum/maximum frame size and total samples).
- *
- * \note In general, FLAC__StreamEncoder functions which change the
- * state should not be called on the \a encoder while in the callback.
- *
- * \param encoder The encoder instance calling the callback.
- * \param metadata The final populated STREAMINFO block.
- * \param client_data The callee's client data set through
- * FLAC__stream_encoder_init_*().
- */
-typedef void (*FLAC__StreamEncoderMetadataCallback)(const FLAC__StreamEncoder *encoder, const FLAC__StreamMetadata *metadata, void *client_data);
-
-/** Signature for the progress callback.
- *
- * A function pointer matching this signature may be passed to
- * FLAC__stream_encoder_init*_file() or FLAC__stream_encoder_init*_FILE().
- * The supplied function will be called when the encoder has finished
- * writing a frame. The \c total_frames_estimate argument to the
- * callback will be based on the value from
- * FLAC__stream_encoder_set_total_samples_estimate().
- *
- * \note In general, FLAC__StreamEncoder functions which change the
- * state should not be called on the \a encoder while in the callback.
- *
- * \param encoder The encoder instance calling the callback.
- * \param bytes_written Bytes written so far.
- * \param samples_written Samples written so far.
- * \param frames_written Frames written so far.
- * \param total_frames_estimate The estimate of the total number of
- * frames to be written.
- * \param client_data The callee's client data set through
- * FLAC__stream_encoder_init_*().
- */
-typedef void (*FLAC__StreamEncoderProgressCallback)(const FLAC__StreamEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data);
-
-
-/***********************************************************************
- *
- * Class constructor/destructor
- *
- ***********************************************************************/
-
-/** Create a new stream encoder instance. The instance is created with
- * default settings; see the individual FLAC__stream_encoder_set_*()
- * functions for each setting's default.
- *
- * \retval FLAC__StreamEncoder*
- * \c NULL if there was an error allocating memory, else the new instance.
- */
-FLAC_API FLAC__StreamEncoder *FLAC__stream_encoder_new(void);
-
-/** Free an encoder instance. Deletes the object pointed to by \a encoder.
- *
- * \param encoder A pointer to an existing encoder.
- * \assert
- * \code encoder != NULL \endcode
- */
-FLAC_API void FLAC__stream_encoder_delete(FLAC__StreamEncoder *encoder);
-
-
-/***********************************************************************
- *
- * Public class method prototypes
- *
- ***********************************************************************/
-
-/** Set the serial number for the FLAC stream to use in the Ogg container.
- *
- * \note
- * This does not need to be set for native FLAC encoding.
- *
- * \note
- * It is recommended to set a serial number explicitly as the default of '0'
- * may collide with other streams.
- *
- * \default \c 0
- * \param encoder An encoder instance to set.
- * \param serial_number See above.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if the encoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_set_ogg_serial_number(FLAC__StreamEncoder *encoder, long serial_number);
-
-/** Set the "verify" flag. If \c true, the encoder will verify it's own
- * encoded output by feeding it through an internal decoder and comparing
- * the original signal against the decoded signal. If a mismatch occurs,
- * the process call will return \c false. Note that this will slow the
- * encoding process by the extra time required for decoding and comparison.
- *
- * \default \c false
- * \param encoder An encoder instance to set.
- * \param value Flag value (see above).
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if the encoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_set_verify(FLAC__StreamEncoder *encoder, FLAC__bool value);
-
-/** Set the <A HREF="../format.html#subset">Subset</A> flag. If \c true,
- * the encoder will comply with the Subset and will check the
- * settings during FLAC__stream_encoder_init_*() to see if all settings
- * comply. If \c false, the settings may take advantage of the full
- * range that the format allows.
- *
- * Make sure you know what it entails before setting this to \c false.
- *
- * \default \c true
- * \param encoder An encoder instance to set.
- * \param value Flag value (see above).
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if the encoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_set_streamable_subset(FLAC__StreamEncoder *encoder, FLAC__bool value);
-
-/** Set the number of channels to be encoded.
- *
- * \default \c 2
- * \param encoder An encoder instance to set.
- * \param value See above.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if the encoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_set_channels(FLAC__StreamEncoder *encoder, unsigned value);
-
-/** Set the sample resolution of the input to be encoded.
- *
- * \warning
- * Do not feed the encoder data that is wider than the value you
- * set here or you will generate an invalid stream.
- *
- * \default \c 16
- * \param encoder An encoder instance to set.
- * \param value See above.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if the encoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_set_bits_per_sample(FLAC__StreamEncoder *encoder, unsigned value);
-
-/** Set the sample rate (in Hz) of the input to be encoded.
- *
- * \default \c 44100
- * \param encoder An encoder instance to set.
- * \param value See above.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if the encoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_set_sample_rate(FLAC__StreamEncoder *encoder, unsigned value);
-
-/** Set the compression level
- *
- * The compression level is roughly proportional to the amount of effort
- * the encoder expends to compress the file. A higher level usually
- * means more computation but higher compression. The default level is
- * suitable for most applications.
- *
- * Currently the levels range from \c 0 (fastest, least compression) to
- * \c 8 (slowest, most compression). A value larger than \c 8 will be
- * treated as \c 8.
- *
- * This function automatically calls the following other \c _set_
- * functions with appropriate values, so the client does not need to
- * unless it specifically wants to override them:
- * - FLAC__stream_encoder_set_do_mid_side_stereo()
- * - FLAC__stream_encoder_set_loose_mid_side_stereo()
- * - FLAC__stream_encoder_set_apodization()
- * - FLAC__stream_encoder_set_max_lpc_order()
- * - FLAC__stream_encoder_set_qlp_coeff_precision()
- * - FLAC__stream_encoder_set_do_qlp_coeff_prec_search()
- * - FLAC__stream_encoder_set_do_escape_coding()
- * - FLAC__stream_encoder_set_do_exhaustive_model_search()
- * - FLAC__stream_encoder_set_min_residual_partition_order()
- * - FLAC__stream_encoder_set_max_residual_partition_order()
- * - FLAC__stream_encoder_set_rice_parameter_search_dist()
- *
- * The actual values set for each level are:
- * <table>
- * <tr>
- * <td><b>level</b><td>
- * <td>do mid-side stereo<td>
- * <td>loose mid-side stereo<td>
- * <td>apodization<td>
- * <td>max lpc order<td>
- * <td>qlp coeff precision<td>
- * <td>qlp coeff prec search<td>
- * <td>escape coding<td>
- * <td>exhaustive model search<td>
- * <td>min residual partition order<td>
- * <td>max residual partition order<td>
- * <td>rice parameter search dist<td>
- * </tr>
- * <tr> <td><b>0</b><td> <td>false<td> <td>false<td> <td>tukey(0.5)<td> <td>0<td> <td>0<td> <td>false<td> <td>false<td> <td>false<td> <td>0<td> <td>3<td> <td>0<td> </tr>
- * <tr> <td><b>1</b><td> <td>true<td> <td>true<td> <td>tukey(0.5)<td> <td>0<td> <td>0<td> <td>false<td> <td>false<td> <td>false<td> <td>0<td> <td>3<td> <td>0<td> </tr>
- * <tr> <td><b>2</b><td> <td>true<td> <td>false<td> <td>tukey(0.5)<td> <td>0<td> <td>0<td> <td>false<td> <td>false<td> <td>false<td> <td>0<td> <td>3<td> <td>0<td> </tr>
- * <tr> <td><b>3</b><td> <td>false<td> <td>false<td> <td>tukey(0.5)<td> <td>6<td> <td>0<td> <td>false<td> <td>false<td> <td>false<td> <td>0<td> <td>4<td> <td>0<td> </tr>
- * <tr> <td><b>4</b><td> <td>true<td> <td>true<td> <td>tukey(0.5)<td> <td>8<td> <td>0<td> <td>false<td> <td>false<td> <td>false<td> <td>0<td> <td>4<td> <td>0<td> </tr>
- * <tr> <td><b>5</b><td> <td>true<td> <td>false<td> <td>tukey(0.5)<td> <td>8<td> <td>0<td> <td>false<td> <td>false<td> <td>false<td> <td>0<td> <td>5<td> <td>0<td> </tr>
- * <tr> <td><b>6</b><td> <td>true<td> <td>false<td> <td>tukey(0.5)<td> <td>8<td> <td>0<td> <td>false<td> <td>false<td> <td>false<td> <td>0<td> <td>6<td> <td>0<td> </tr>
- * <tr> <td><b>7</b><td> <td>true<td> <td>false<td> <td>tukey(0.5)<td> <td>8<td> <td>0<td> <td>false<td> <td>false<td> <td>true<td> <td>0<td> <td>6<td> <td>0<td> </tr>
- * <tr> <td><b>8</b><td> <td>true<td> <td>false<td> <td>tukey(0.5)<td> <td>12<td> <td>0<td> <td>false<td> <td>false<td> <td>true<td> <td>0<td> <td>6<td> <td>0<td> </tr>
- * </table>
- *
- * \default \c 5
- * \param encoder An encoder instance to set.
- * \param value See above.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if the encoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_set_compression_level(FLAC__StreamEncoder *encoder, unsigned value);
-
-/** Set the blocksize to use while encoding.
- *
- * The number of samples to use per frame. Use \c 0 to let the encoder
- * estimate a blocksize; this is usually best.
- *
- * \default \c 0
- * \param encoder An encoder instance to set.
- * \param value See above.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if the encoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_set_blocksize(FLAC__StreamEncoder *encoder, unsigned value);
-
-/** Set to \c true to enable mid-side encoding on stereo input. The
- * number of channels must be 2 for this to have any effect. Set to
- * \c false to use only independent channel coding.
- *
- * \default \c false
- * \param encoder An encoder instance to set.
- * \param value Flag value (see above).
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if the encoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_set_do_mid_side_stereo(FLAC__StreamEncoder *encoder, FLAC__bool value);
-
-/** Set to \c true to enable adaptive switching between mid-side and
- * left-right encoding on stereo input. Set to \c false to use
- * exhaustive searching. Setting this to \c true requires
- * FLAC__stream_encoder_set_do_mid_side_stereo() to also be set to
- * \c true in order to have any effect.
- *
- * \default \c false
- * \param encoder An encoder instance to set.
- * \param value Flag value (see above).
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if the encoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_set_loose_mid_side_stereo(FLAC__StreamEncoder *encoder, FLAC__bool value);
-
-/** Sets the apodization function(s) the encoder will use when windowing
- * audio data for LPC analysis.
- *
- * The \a specification is a plain ASCII string which specifies exactly
- * which functions to use. There may be more than one (up to 32),
- * separated by \c ';' characters. Some functions take one or more
- * comma-separated arguments in parentheses.
- *
- * The available functions are \c bartlett, \c bartlett_hann,
- * \c blackman, \c blackman_harris_4term_92db, \c connes, \c flattop,
- * \c gauss(STDDEV), \c hamming, \c hann, \c kaiser_bessel, \c nuttall,
- * \c rectangle, \c triangle, \c tukey(P), \c welch.
- *
- * For \c gauss(STDDEV), STDDEV specifies the standard deviation
- * (0<STDDEV<=0.5).
- *
- * For \c tukey(P), P specifies the fraction of the window that is
- * tapered (0<=P<=1). P=0 corresponds to \c rectangle and P=1
- * corresponds to \c hann.
- *
- * Example specifications are \c "blackman" or
- * \c "hann;triangle;tukey(0.5);tukey(0.25);tukey(0.125)"
- *
- * Any function that is specified erroneously is silently dropped. Up
- * to 32 functions are kept, the rest are dropped. If the specification
- * is empty the encoder defaults to \c "tukey(0.5)".
- *
- * When more than one function is specified, then for every subframe the
- * encoder will try each of them separately and choose the window that
- * results in the smallest compressed subframe.
- *
- * Note that each function specified causes the encoder to occupy a
- * floating point array in which to store the window.
- *
- * \default \c "tukey(0.5)"
- * \param encoder An encoder instance to set.
- * \param specification See above.
- * \assert
- * \code encoder != NULL \endcode
- * \code specification != NULL \endcode
- * \retval FLAC__bool
- * \c false if the encoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_set_apodization(FLAC__StreamEncoder *encoder, const char *specification);
-
-/** Set the maximum LPC order, or \c 0 to use only the fixed predictors.
- *
- * \default \c 0
- * \param encoder An encoder instance to set.
- * \param value See above.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if the encoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_set_max_lpc_order(FLAC__StreamEncoder *encoder, unsigned value);
-
-/** Set the precision, in bits, of the quantized linear predictor
- * coefficients, or \c 0 to let the encoder select it based on the
- * blocksize.
- *
- * \note
- * In the current implementation, qlp_coeff_precision + bits_per_sample must
- * be less than 32.
- *
- * \default \c 0
- * \param encoder An encoder instance to set.
- * \param value See above.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if the encoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_set_qlp_coeff_precision(FLAC__StreamEncoder *encoder, unsigned value);
-
-/** Set to \c false to use only the specified quantized linear predictor
- * coefficient precision, or \c true to search neighboring precision
- * values and use the best one.
- *
- * \default \c false
- * \param encoder An encoder instance to set.
- * \param value See above.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if the encoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_set_do_qlp_coeff_prec_search(FLAC__StreamEncoder *encoder, FLAC__bool value);
-
-/** Deprecated. Setting this value has no effect.
- *
- * \default \c false
- * \param encoder An encoder instance to set.
- * \param value See above.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if the encoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_set_do_escape_coding(FLAC__StreamEncoder *encoder, FLAC__bool value);
-
-/** Set to \c false to let the encoder estimate the best model order
- * based on the residual signal energy, or \c true to force the
- * encoder to evaluate all order models and select the best.
- *
- * \default \c false
- * \param encoder An encoder instance to set.
- * \param value See above.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if the encoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_set_do_exhaustive_model_search(FLAC__StreamEncoder *encoder, FLAC__bool value);
-
-/** Set the minimum partition order to search when coding the residual.
- * This is used in tandem with
- * FLAC__stream_encoder_set_max_residual_partition_order().
- *
- * The partition order determines the context size in the residual.
- * The context size will be approximately <tt>blocksize / (2 ^ order)</tt>.
- *
- * Set both min and max values to \c 0 to force a single context,
- * whose Rice parameter is based on the residual signal variance.
- * Otherwise, set a min and max order, and the encoder will search
- * all orders, using the mean of each context for its Rice parameter,
- * and use the best.
- *
- * \default \c 0
- * \param encoder An encoder instance to set.
- * \param value See above.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if the encoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_set_min_residual_partition_order(FLAC__StreamEncoder *encoder, unsigned value);
-
-/** Set the maximum partition order to search when coding the residual.
- * This is used in tandem with
- * FLAC__stream_encoder_set_min_residual_partition_order().
- *
- * The partition order determines the context size in the residual.
- * The context size will be approximately <tt>blocksize / (2 ^ order)</tt>.
- *
- * Set both min and max values to \c 0 to force a single context,
- * whose Rice parameter is based on the residual signal variance.
- * Otherwise, set a min and max order, and the encoder will search
- * all orders, using the mean of each context for its Rice parameter,
- * and use the best.
- *
- * \default \c 0
- * \param encoder An encoder instance to set.
- * \param value See above.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if the encoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_set_max_residual_partition_order(FLAC__StreamEncoder *encoder, unsigned value);
-
-/** Deprecated. Setting this value has no effect.
- *
- * \default \c 0
- * \param encoder An encoder instance to set.
- * \param value See above.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if the encoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_set_rice_parameter_search_dist(FLAC__StreamEncoder *encoder, unsigned value);
-
-/** Set an estimate of the total samples that will be encoded.
- * This is merely an estimate and may be set to \c 0 if unknown.
- * This value will be written to the STREAMINFO block before encoding,
- * and can remove the need for the caller to rewrite the value later
- * if the value is known before encoding.
- *
- * \default \c 0
- * \param encoder An encoder instance to set.
- * \param value See above.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if the encoder is already initialized, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_set_total_samples_estimate(FLAC__StreamEncoder *encoder, FLAC__uint64 value);
-
-/** Set the metadata blocks to be emitted to the stream before encoding.
- * A value of \c NULL, \c 0 implies no metadata; otherwise, supply an
- * array of pointers to metadata blocks. The array is non-const since
- * the encoder may need to change the \a is_last flag inside them, and
- * in some cases update seek point offsets. Otherwise, the encoder will
- * not modify or free the blocks. It is up to the caller to free the
- * metadata blocks after encoding finishes.
- *
- * \note
- * The encoder stores only copies of the pointers in the \a metadata array;
- * the metadata blocks themselves must survive at least until after
- * FLAC__stream_encoder_finish() returns. Do not free the blocks until then.
- *
- * \note
- * The STREAMINFO block is always written and no STREAMINFO block may
- * occur in the supplied array.
- *
- * \note
- * By default the encoder does not create a SEEKTABLE. If one is supplied
- * in the \a metadata array, but the client has specified that it does not
- * support seeking, then the SEEKTABLE will be written verbatim. However
- * by itself this is not very useful as the client will not know the stream
- * offsets for the seekpoints ahead of time. In order to get a proper
- * seektable the client must support seeking. See next note.
- *
- * \note
- * SEEKTABLE blocks are handled specially. Since you will not know
- * the values for the seek point stream offsets, you should pass in
- * a SEEKTABLE 'template', that is, a SEEKTABLE object with the
- * required sample numbers (or placeholder points), with \c 0 for the
- * \a frame_samples and \a stream_offset fields for each point. If the
- * client has specified that it supports seeking by providing a seek
- * callback to FLAC__stream_encoder_init_stream() or both seek AND read
- * callback to FLAC__stream_encoder_init_ogg_stream() (or by using
- * FLAC__stream_encoder_init*_file() or FLAC__stream_encoder_init*_FILE()),
- * then while it is encoding the encoder will fill the stream offsets in
- * for you and when encoding is finished, it will seek back and write the
- * real values into the SEEKTABLE block in the stream. There are helper
- * routines for manipulating seektable template blocks; see metadata.h:
- * FLAC__metadata_object_seektable_template_*(). If the client does
- * not support seeking, the SEEKTABLE will have inaccurate offsets which
- * will slow down or remove the ability to seek in the FLAC stream.
- *
- * \note
- * The encoder instance \b will modify the first \c SEEKTABLE block
- * as it transforms the template to a valid seektable while encoding,
- * but it is still up to the caller to free all metadata blocks after
- * encoding.
- *
- * \note
- * A VORBIS_COMMENT block may be supplied. The vendor string in it
- * will be ignored. libFLAC will use it's own vendor string. libFLAC
- * will not modify the passed-in VORBIS_COMMENT's vendor string, it
- * will simply write it's own into the stream. If no VORBIS_COMMENT
- * block is present in the \a metadata array, libFLAC will write an
- * empty one, containing only the vendor string.
- *
- * \note The Ogg FLAC mapping requires that the VORBIS_COMMENT block be
- * the second metadata block of the stream. The encoder already supplies
- * the STREAMINFO block automatically. If \a metadata does not contain a
- * VORBIS_COMMENT block, the encoder will supply that too. Otherwise, if
- * \a metadata does contain a VORBIS_COMMENT block and it is not the
- * first, the init function will reorder \a metadata by moving the
- * VORBIS_COMMENT block to the front; the relative ordering of the other
- * blocks will remain as they were.
- *
- * \note The Ogg FLAC mapping limits the number of metadata blocks per
- * stream to \c 65535. If \a num_blocks exceeds this the function will
- * return \c false.
- *
- * \default \c NULL, 0
- * \param encoder An encoder instance to set.
- * \param metadata See above.
- * \param num_blocks See above.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if the encoder is already initialized, else \c true.
- * \c false if the encoder is already initialized, or if
- * \a num_blocks > 65535 if encoding to Ogg FLAC, else \c true.
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_set_metadata(FLAC__StreamEncoder *encoder, FLAC__StreamMetadata **metadata, unsigned num_blocks);
-
-/** Get the current encoder state.
- *
- * \param encoder An encoder instance to query.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__StreamEncoderState
- * The current encoder state.
- */
-FLAC_API FLAC__StreamEncoderState FLAC__stream_encoder_get_state(const FLAC__StreamEncoder *encoder);
-
-/** Get the state of the verify stream decoder.
- * Useful when the stream encoder state is
- * \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR.
- *
- * \param encoder An encoder instance to query.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__StreamDecoderState
- * The verify stream decoder state.
- */
-FLAC_API FLAC__StreamDecoderState FLAC__stream_encoder_get_verify_decoder_state(const FLAC__StreamEncoder *encoder);
-
-/** Get the current encoder state as a C string.
- * This version automatically resolves
- * \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR by getting the
- * verify decoder's state.
- *
- * \param encoder A encoder instance to query.
- * \assert
- * \code encoder != NULL \endcode
- * \retval const char *
- * The encoder state as a C string. Do not modify the contents.
- */
-FLAC_API const char *FLAC__stream_encoder_get_resolved_state_string(const FLAC__StreamEncoder *encoder);
-
-/** Get relevant values about the nature of a verify decoder error.
- * Useful when the stream encoder state is
- * \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR. The arguments should
- * be addresses in which the stats will be returned, or NULL if value
- * is not desired.
- *
- * \param encoder An encoder instance to query.
- * \param absolute_sample The absolute sample number of the mismatch.
- * \param frame_number The number of the frame in which the mismatch occurred.
- * \param channel The channel in which the mismatch occurred.
- * \param sample The number of the sample (relative to the frame) in
- * which the mismatch occurred.
- * \param expected The expected value for the sample in question.
- * \param got The actual value returned by the decoder.
- * \assert
- * \code encoder != NULL \endcode
- */
-FLAC_API void FLAC__stream_encoder_get_verify_decoder_error_stats(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got);
-
-/** Get the "verify" flag.
- *
- * \param encoder An encoder instance to query.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * See FLAC__stream_encoder_set_verify().
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_get_verify(const FLAC__StreamEncoder *encoder);
-
-/** Get the <A HREF="../format.html#subset>Subset</A> flag.
- *
- * \param encoder An encoder instance to query.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * See FLAC__stream_encoder_set_streamable_subset().
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_get_streamable_subset(const FLAC__StreamEncoder *encoder);
-
-/** Get the number of input channels being processed.
- *
- * \param encoder An encoder instance to query.
- * \assert
- * \code encoder != NULL \endcode
- * \retval unsigned
- * See FLAC__stream_encoder_set_channels().
- */
-FLAC_API unsigned FLAC__stream_encoder_get_channels(const FLAC__StreamEncoder *encoder);
-
-/** Get the input sample resolution setting.
- *
- * \param encoder An encoder instance to query.
- * \assert
- * \code encoder != NULL \endcode
- * \retval unsigned
- * See FLAC__stream_encoder_set_bits_per_sample().
- */
-FLAC_API unsigned FLAC__stream_encoder_get_bits_per_sample(const FLAC__StreamEncoder *encoder);
-
-/** Get the input sample rate setting.
- *
- * \param encoder An encoder instance to query.
- * \assert
- * \code encoder != NULL \endcode
- * \retval unsigned
- * See FLAC__stream_encoder_set_sample_rate().
- */
-FLAC_API unsigned FLAC__stream_encoder_get_sample_rate(const FLAC__StreamEncoder *encoder);
-
-/** Get the blocksize setting.
- *
- * \param encoder An encoder instance to query.
- * \assert
- * \code encoder != NULL \endcode
- * \retval unsigned
- * See FLAC__stream_encoder_set_blocksize().
- */
-FLAC_API unsigned FLAC__stream_encoder_get_blocksize(const FLAC__StreamEncoder *encoder);
-
-/** Get the "mid/side stereo coding" flag.
- *
- * \param encoder An encoder instance to query.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * See FLAC__stream_encoder_get_do_mid_side_stereo().
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_get_do_mid_side_stereo(const FLAC__StreamEncoder *encoder);
-
-/** Get the "adaptive mid/side switching" flag.
- *
- * \param encoder An encoder instance to query.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * See FLAC__stream_encoder_set_loose_mid_side_stereo().
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_get_loose_mid_side_stereo(const FLAC__StreamEncoder *encoder);
-
-/** Get the maximum LPC order setting.
- *
- * \param encoder An encoder instance to query.
- * \assert
- * \code encoder != NULL \endcode
- * \retval unsigned
- * See FLAC__stream_encoder_set_max_lpc_order().
- */
-FLAC_API unsigned FLAC__stream_encoder_get_max_lpc_order(const FLAC__StreamEncoder *encoder);
-
-/** Get the quantized linear predictor coefficient precision setting.
- *
- * \param encoder An encoder instance to query.
- * \assert
- * \code encoder != NULL \endcode
- * \retval unsigned
- * See FLAC__stream_encoder_set_qlp_coeff_precision().
- */
-FLAC_API unsigned FLAC__stream_encoder_get_qlp_coeff_precision(const FLAC__StreamEncoder *encoder);
-
-/** Get the qlp coefficient precision search flag.
- *
- * \param encoder An encoder instance to query.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * See FLAC__stream_encoder_set_do_qlp_coeff_prec_search().
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_get_do_qlp_coeff_prec_search(const FLAC__StreamEncoder *encoder);
-
-/** Get the "escape coding" flag.
- *
- * \param encoder An encoder instance to query.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * See FLAC__stream_encoder_set_do_escape_coding().
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_get_do_escape_coding(const FLAC__StreamEncoder *encoder);
-
-/** Get the exhaustive model search flag.
- *
- * \param encoder An encoder instance to query.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * See FLAC__stream_encoder_set_do_exhaustive_model_search().
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_get_do_exhaustive_model_search(const FLAC__StreamEncoder *encoder);
-
-/** Get the minimum residual partition order setting.
- *
- * \param encoder An encoder instance to query.
- * \assert
- * \code encoder != NULL \endcode
- * \retval unsigned
- * See FLAC__stream_encoder_set_min_residual_partition_order().
- */
-FLAC_API unsigned FLAC__stream_encoder_get_min_residual_partition_order(const FLAC__StreamEncoder *encoder);
-
-/** Get maximum residual partition order setting.
- *
- * \param encoder An encoder instance to query.
- * \assert
- * \code encoder != NULL \endcode
- * \retval unsigned
- * See FLAC__stream_encoder_set_max_residual_partition_order().
- */
-FLAC_API unsigned FLAC__stream_encoder_get_max_residual_partition_order(const FLAC__StreamEncoder *encoder);
-
-/** Get the Rice parameter search distance setting.
- *
- * \param encoder An encoder instance to query.
- * \assert
- * \code encoder != NULL \endcode
- * \retval unsigned
- * See FLAC__stream_encoder_set_rice_parameter_search_dist().
- */
-FLAC_API unsigned FLAC__stream_encoder_get_rice_parameter_search_dist(const FLAC__StreamEncoder *encoder);
-
-/** Get the previously set estimate of the total samples to be encoded.
- * The encoder merely mimics back the value given to
- * FLAC__stream_encoder_set_total_samples_estimate() since it has no
- * other way of knowing how many samples the client will encode.
- *
- * \param encoder An encoder instance to set.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__uint64
- * See FLAC__stream_encoder_get_total_samples_estimate().
- */
-FLAC_API FLAC__uint64 FLAC__stream_encoder_get_total_samples_estimate(const FLAC__StreamEncoder *encoder);
-
-/** Initialize the encoder instance to encode native FLAC streams.
- *
- * This flavor of initialization sets up the encoder to encode to a
- * native FLAC stream. I/O is performed via callbacks to the client.
- * For encoding to a plain file via filename or open \c FILE*,
- * FLAC__stream_encoder_init_file() and FLAC__stream_encoder_init_FILE()
- * provide a simpler interface.
- *
- * This function should be called after FLAC__stream_encoder_new() and
- * FLAC__stream_encoder_set_*() but before FLAC__stream_encoder_process()
- * or FLAC__stream_encoder_process_interleaved().
- * initialization succeeded.
- *
- * The call to FLAC__stream_encoder_init_stream() currently will also
- * immediately call the write callback several times, once with the \c fLaC
- * signature, and once for each encoded metadata block.
- *
- * \param encoder An uninitialized encoder instance.
- * \param write_callback See FLAC__StreamEncoderWriteCallback. This
- * pointer must not be \c NULL.
- * \param seek_callback See FLAC__StreamEncoderSeekCallback. This
- * pointer may be \c NULL if seeking is not
- * supported. The encoder uses seeking to go back
- * and write some some stream statistics to the
- * STREAMINFO block; this is recommended but not
- * necessary to create a valid FLAC stream. If
- * \a seek_callback is not \c NULL then a
- * \a tell_callback must also be supplied.
- * Alternatively, a dummy seek callback that just
- * returns \c FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED
- * may also be supplied, all though this is slightly
- * less efficient for the encoder.
- * \param tell_callback See FLAC__StreamEncoderTellCallback. This
- * pointer may be \c NULL if seeking is not
- * supported. If \a seek_callback is \c NULL then
- * this argument will be ignored. If
- * \a seek_callback is not \c NULL then a
- * \a tell_callback must also be supplied.
- * Alternatively, a dummy tell callback that just
- * returns \c FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED
- * may also be supplied, all though this is slightly
- * less efficient for the encoder.
- * \param metadata_callback See FLAC__StreamEncoderMetadataCallback. This
- * pointer may be \c NULL if the callback is not
- * desired. If the client provides a seek callback,
- * this function is not necessary as the encoder
- * will automatically seek back and update the
- * STREAMINFO block. It may also be \c NULL if the
- * client does not support seeking, since it will
- * have no way of going back to update the
- * STREAMINFO. However the client can still supply
- * a callback if it would like to know the details
- * from the STREAMINFO.
- * \param client_data This value will be supplied to callbacks in their
- * \a client_data argument.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__StreamEncoderInitStatus
- * \c FLAC__STREAM_ENCODER_INIT_STATUS_OK if initialization was successful;
- * see FLAC__StreamEncoderInitStatus for the meanings of other return values.
- */
-FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_stream(FLAC__StreamEncoder *encoder, FLAC__StreamEncoderWriteCallback write_callback, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderTellCallback tell_callback, FLAC__StreamEncoderMetadataCallback metadata_callback, void *client_data);
-
-/** Initialize the encoder instance to encode Ogg FLAC streams.
- *
- * This flavor of initialization sets up the encoder to encode to a FLAC
- * stream in an Ogg container. I/O is performed via callbacks to the
- * client. For encoding to a plain file via filename or open \c FILE*,
- * FLAC__stream_encoder_init_ogg_file() and FLAC__stream_encoder_init_ogg_FILE()
- * provide a simpler interface.
- *
- * This function should be called after FLAC__stream_encoder_new() and
- * FLAC__stream_encoder_set_*() but before FLAC__stream_encoder_process()
- * or FLAC__stream_encoder_process_interleaved().
- * initialization succeeded.
- *
- * The call to FLAC__stream_encoder_init_ogg_stream() currently will also
- * immediately call the write callback several times to write the metadata
- * packets.
- *
- * \param encoder An uninitialized encoder instance.
- * \param read_callback See FLAC__StreamEncoderReadCallback. This
- * pointer must not be \c NULL if \a seek_callback
- * is non-NULL since they are both needed to be
- * able to write data back to the Ogg FLAC stream
- * in the post-encode phase.
- * \param write_callback See FLAC__StreamEncoderWriteCallback. This
- * pointer must not be \c NULL.
- * \param seek_callback See FLAC__StreamEncoderSeekCallback. This
- * pointer may be \c NULL if seeking is not
- * supported. The encoder uses seeking to go back
- * and write some some stream statistics to the
- * STREAMINFO block; this is recommended but not
- * necessary to create a valid FLAC stream. If
- * \a seek_callback is not \c NULL then a
- * \a tell_callback must also be supplied.
- * Alternatively, a dummy seek callback that just
- * returns \c FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED
- * may also be supplied, all though this is slightly
- * less efficient for the encoder.
- * \param tell_callback See FLAC__StreamEncoderTellCallback. This
- * pointer may be \c NULL if seeking is not
- * supported. If \a seek_callback is \c NULL then
- * this argument will be ignored. If
- * \a seek_callback is not \c NULL then a
- * \a tell_callback must also be supplied.
- * Alternatively, a dummy tell callback that just
- * returns \c FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED
- * may also be supplied, all though this is slightly
- * less efficient for the encoder.
- * \param metadata_callback See FLAC__StreamEncoderMetadataCallback. This
- * pointer may be \c NULL if the callback is not
- * desired. If the client provides a seek callback,
- * this function is not necessary as the encoder
- * will automatically seek back and update the
- * STREAMINFO block. It may also be \c NULL if the
- * client does not support seeking, since it will
- * have no way of going back to update the
- * STREAMINFO. However the client can still supply
- * a callback if it would like to know the details
- * from the STREAMINFO.
- * \param client_data This value will be supplied to callbacks in their
- * \a client_data argument.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__StreamEncoderInitStatus
- * \c FLAC__STREAM_ENCODER_INIT_STATUS_OK if initialization was successful;
- * see FLAC__StreamEncoderInitStatus for the meanings of other return values.
- */
-FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_stream(FLAC__StreamEncoder *encoder, FLAC__StreamEncoderReadCallback read_callback, FLAC__StreamEncoderWriteCallback write_callback, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderTellCallback tell_callback, FLAC__StreamEncoderMetadataCallback metadata_callback, void *client_data);
-
-/** Initialize the encoder instance to encode native FLAC files.
- *
- * This flavor of initialization sets up the encoder to encode to a
- * plain native FLAC file. For non-stdio streams, you must use
- * FLAC__stream_encoder_init_stream() and provide callbacks for the I/O.
- *
- * This function should be called after FLAC__stream_encoder_new() and
- * FLAC__stream_encoder_set_*() but before FLAC__stream_encoder_process()
- * or FLAC__stream_encoder_process_interleaved().
- * initialization succeeded.
- *
- * \param encoder An uninitialized encoder instance.
- * \param file An open file. The file should have been opened
- * with mode \c "w+b" and rewound. The file
- * becomes owned by the encoder and should not be
- * manipulated by the client while encoding.
- * Unless \a file is \c stdout, it will be closed
- * when FLAC__stream_encoder_finish() is called.
- * Note however that a proper SEEKTABLE cannot be
- * created when encoding to \c stdout since it is
- * not seekable.
- * \param progress_callback See FLAC__StreamEncoderProgressCallback. This
- * pointer may be \c NULL if the callback is not
- * desired.
- * \param client_data This value will be supplied to callbacks in their
- * \a client_data argument.
- * \assert
- * \code encoder != NULL \endcode
- * \code file != NULL \endcode
- * \retval FLAC__StreamEncoderInitStatus
- * \c FLAC__STREAM_ENCODER_INIT_STATUS_OK if initialization was successful;
- * see FLAC__StreamEncoderInitStatus for the meanings of other return values.
- */
-FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_FILE(FLAC__StreamEncoder *encoder, FILE *file, FLAC__StreamEncoderProgressCallback progress_callback, void *client_data);
-
-/** Initialize the encoder instance to encode Ogg FLAC files.
- *
- * This flavor of initialization sets up the encoder to encode to a
- * plain Ogg FLAC file. For non-stdio streams, you must use
- * FLAC__stream_encoder_init_ogg_stream() and provide callbacks for the I/O.
- *
- * This function should be called after FLAC__stream_encoder_new() and
- * FLAC__stream_encoder_set_*() but before FLAC__stream_encoder_process()
- * or FLAC__stream_encoder_process_interleaved().
- * initialization succeeded.
- *
- * \param encoder An uninitialized encoder instance.
- * \param file An open file. The file should have been opened
- * with mode \c "w+b" and rewound. The file
- * becomes owned by the encoder and should not be
- * manipulated by the client while encoding.
- * Unless \a file is \c stdout, it will be closed
- * when FLAC__stream_encoder_finish() is called.
- * Note however that a proper SEEKTABLE cannot be
- * created when encoding to \c stdout since it is
- * not seekable.
- * \param progress_callback See FLAC__StreamEncoderProgressCallback. This
- * pointer may be \c NULL if the callback is not
- * desired.
- * \param client_data This value will be supplied to callbacks in their
- * \a client_data argument.
- * \assert
- * \code encoder != NULL \endcode
- * \code file != NULL \endcode
- * \retval FLAC__StreamEncoderInitStatus
- * \c FLAC__STREAM_ENCODER_INIT_STATUS_OK if initialization was successful;
- * see FLAC__StreamEncoderInitStatus for the meanings of other return values.
- */
-FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_FILE(FLAC__StreamEncoder *encoder, FILE *file, FLAC__StreamEncoderProgressCallback progress_callback, void *client_data);
-
-/** Initialize the encoder instance to encode native FLAC files.
- *
- * This flavor of initialization sets up the encoder to encode to a plain
- * FLAC file. If POSIX fopen() semantics are not sufficient (for example,
- * with Unicode filenames on Windows), you must use
- * FLAC__stream_encoder_init_FILE(), or FLAC__stream_encoder_init_stream()
- * and provide callbacks for the I/O.
- *
- * This function should be called after FLAC__stream_encoder_new() and
- * FLAC__stream_encoder_set_*() but before FLAC__stream_encoder_process()
- * or FLAC__stream_encoder_process_interleaved().
- * initialization succeeded.
- *
- * \param encoder An uninitialized encoder instance.
- * \param filename The name of the file to encode to. The file will
- * be opened with fopen(). Use \c NULL to encode to
- * \c stdout. Note however that a proper SEEKTABLE
- * cannot be created when encoding to \c stdout since
- * it is not seekable.
- * \param progress_callback See FLAC__StreamEncoderProgressCallback. This
- * pointer may be \c NULL if the callback is not
- * desired.
- * \param client_data This value will be supplied to callbacks in their
- * \a client_data argument.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__StreamEncoderInitStatus
- * \c FLAC__STREAM_ENCODER_INIT_STATUS_OK if initialization was successful;
- * see FLAC__StreamEncoderInitStatus for the meanings of other return values.
- */
-FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_file(FLAC__StreamEncoder *encoder, const char *filename, FLAC__StreamEncoderProgressCallback progress_callback, void *client_data);
-
-/** Initialize the encoder instance to encode Ogg FLAC files.
- *
- * This flavor of initialization sets up the encoder to encode to a plain
- * Ogg FLAC file. If POSIX fopen() semantics are not sufficient (for example,
- * with Unicode filenames on Windows), you must use
- * FLAC__stream_encoder_init_ogg_FILE(), or FLAC__stream_encoder_init_ogg_stream()
- * and provide callbacks for the I/O.
- *
- * This function should be called after FLAC__stream_encoder_new() and
- * FLAC__stream_encoder_set_*() but before FLAC__stream_encoder_process()
- * or FLAC__stream_encoder_process_interleaved().
- * initialization succeeded.
- *
- * \param encoder An uninitialized encoder instance.
- * \param filename The name of the file to encode to. The file will
- * be opened with fopen(). Use \c NULL to encode to
- * \c stdout. Note however that a proper SEEKTABLE
- * cannot be created when encoding to \c stdout since
- * it is not seekable.
- * \param progress_callback See FLAC__StreamEncoderProgressCallback. This
- * pointer may be \c NULL if the callback is not
- * desired.
- * \param client_data This value will be supplied to callbacks in their
- * \a client_data argument.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__StreamEncoderInitStatus
- * \c FLAC__STREAM_ENCODER_INIT_STATUS_OK if initialization was successful;
- * see FLAC__StreamEncoderInitStatus for the meanings of other return values.
- */
-FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_file(FLAC__StreamEncoder *encoder, const char *filename, FLAC__StreamEncoderProgressCallback progress_callback, void *client_data);
-
-/** Finish the encoding process.
- * Flushes the encoding buffer, releases resources, resets the encoder
- * settings to their defaults, and returns the encoder state to
- * FLAC__STREAM_ENCODER_UNINITIALIZED. Note that this can generate
- * one or more write callbacks before returning, and will generate
- * a metadata callback.
- *
- * Note that in the course of processing the last frame, errors can
- * occur, so the caller should be sure to check the return value to
- * ensure the file was encoded properly.
- *
- * In the event of a prematurely-terminated encode, it is not strictly
- * necessary to call this immediately before FLAC__stream_encoder_delete()
- * but it is good practice to match every FLAC__stream_encoder_init_*()
- * with a FLAC__stream_encoder_finish().
- *
- * \param encoder An uninitialized encoder instance.
- * \assert
- * \code encoder != NULL \endcode
- * \retval FLAC__bool
- * \c false if an error occurred processing the last frame; or if verify
- * mode is set (see FLAC__stream_encoder_set_verify()), there was a
- * verify mismatch; else \c true. If \c false, caller should check the
- * state with FLAC__stream_encoder_get_state() for more information
- * about the error.
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_finish(FLAC__StreamEncoder *encoder);
-
-/** Submit data for encoding.
- * This version allows you to supply the input data via an array of
- * pointers, each pointer pointing to an array of \a samples samples
- * representing one channel. The samples need not be block-aligned,
- * but each channel should have the same number of samples. Each sample
- * should be a signed integer, right-justified to the resolution set by
- * FLAC__stream_encoder_set_bits_per_sample(). For example, if the
- * resolution is 16 bits per sample, the samples should all be in the
- * range [-32768,32767].
- *
- * For applications where channel order is important, channels must
- * follow the order as described in the
- * <A HREF="../format.html#frame_header">frame header</A>.
- *
- * \param encoder An initialized encoder instance in the OK state.
- * \param buffer An array of pointers to each channel's signal.
- * \param samples The number of samples in one channel.
- * \assert
- * \code encoder != NULL \endcode
- * \code FLAC__stream_encoder_get_state(encoder) == FLAC__STREAM_ENCODER_OK \endcode
- * \retval FLAC__bool
- * \c true if successful, else \c false; in this case, check the
- * encoder state with FLAC__stream_encoder_get_state() to see what
- * went wrong.
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, const FLAC__int32 * const buffer[], unsigned samples);
-
-/** Submit data for encoding.
- * This version allows you to supply the input data where the channels
- * are interleaved into a single array (i.e. channel0_sample0,
- * channel1_sample0, ... , channelN_sample0, channel0_sample1, ...).
- * The samples need not be block-aligned but they must be
- * sample-aligned, i.e. the first value should be channel0_sample0
- * and the last value channelN_sampleM. Each sample should be a signed
- * integer, right-justified to the resolution set by
- * FLAC__stream_encoder_set_bits_per_sample(). For example, if the
- * resolution is 16 bits per sample, the samples should all be in the
- * range [-32768,32767].
- *
- * For applications where channel order is important, channels must
- * follow the order as described in the
- * <A HREF="../format.html#frame_header">frame header</A>.
- *
- * \param encoder An initialized encoder instance in the OK state.
- * \param buffer An array of channel-interleaved data (see above).
- * \param samples The number of samples in one channel, the same as for
- * FLAC__stream_encoder_process(). For example, if
- * encoding two channels, \c 1000 \a samples corresponds
- * to a \a buffer of 2000 values.
- * \assert
- * \code encoder != NULL \endcode
- * \code FLAC__stream_encoder_get_state(encoder) == FLAC__STREAM_ENCODER_OK \endcode
- * \retval FLAC__bool
- * \c true if successful, else \c false; in this case, check the
- * encoder state with FLAC__stream_encoder_get_state() to see what
- * went wrong.
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_process_interleaved(FLAC__StreamEncoder *encoder, const FLAC__int32 buffer[], unsigned samples);
-
-/* \} */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/src/thirdparty/libflac/include/ogg/ogg.h b/src/thirdparty/libflac/include/ogg/ogg.h
deleted file mode 100644
index cea4ebed7..000000000
--- a/src/thirdparty/libflac/include/ogg/ogg.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/********************************************************************
- * *
- * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
- * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
- * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
- * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
- * *
- * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 *
- * by the Xiph.Org Foundation http://www.xiph.org/ *
- * *
- ********************************************************************
-
- function: toplevel libogg include
- last mod: $Id: ogg.h 18044 2011-08-01 17:55:20Z gmaxwell $
-
- ********************************************************************/
-#ifndef _OGG_H
-#define _OGG_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stddef.h>
-#include <ogg/os_types.h>
-
-typedef struct {
- void *iov_base;
- size_t iov_len;
-} ogg_iovec_t;
-
-typedef struct {
- long endbyte;
- int endbit;
-
- unsigned char *buffer;
- unsigned char *ptr;
- long storage;
-} oggpack_buffer;
-
-/* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/
-
-typedef struct {
- unsigned char *header;
- long header_len;
- unsigned char *body;
- long body_len;
-} ogg_page;
-
-/* ogg_stream_state contains the current encode/decode state of a logical
- Ogg bitstream **********************************************************/
-
-typedef struct {
- unsigned char *body_data; /* bytes from packet bodies */
- long body_storage; /* storage elements allocated */
- long body_fill; /* elements stored; fill mark */
- long body_returned; /* elements of fill returned */
-
-
- int *lacing_vals; /* The values that will go to the segment table */
- ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact
- this way, but it is simple coupled to the
- lacing fifo */
- long lacing_storage;
- long lacing_fill;
- long lacing_packet;
- long lacing_returned;
-
- unsigned char header[282]; /* working space for header encode */
- int header_fill;
-
- int e_o_s; /* set when we have buffered the last packet in the
- logical bitstream */
- int b_o_s; /* set after we've written the initial page
- of a logical bitstream */
- long serialno;
- long pageno;
- ogg_int64_t packetno; /* sequence number for decode; the framing
- knows where there's a hole in the data,
- but we need coupling so that the codec
- (which is in a separate abstraction
- layer) also knows about the gap */
- ogg_int64_t granulepos;
-
-} ogg_stream_state;
-
-/* ogg_packet is used to encapsulate the data and metadata belonging
- to a single raw Ogg/Vorbis packet *************************************/
-
-typedef struct {
- unsigned char *packet;
- long bytes;
- long b_o_s;
- long e_o_s;
-
- ogg_int64_t granulepos;
-
- ogg_int64_t packetno; /* sequence number for decode; the framing
- knows where there's a hole in the data,
- but we need coupling so that the codec
- (which is in a separate abstraction
- layer) also knows about the gap */
-} ogg_packet;
-
-typedef struct {
- unsigned char *data;
- int storage;
- int fill;
- int returned;
-
- int unsynced;
- int headerbytes;
- int bodybytes;
-} ogg_sync_state;
-
-/* Ogg BITSTREAM PRIMITIVES: bitstream ************************/
-
-extern void oggpack_writeinit(oggpack_buffer *b);
-extern int oggpack_writecheck(oggpack_buffer *b);
-extern void oggpack_writetrunc(oggpack_buffer *b,long bits);
-extern void oggpack_writealign(oggpack_buffer *b);
-extern void oggpack_writecopy(oggpack_buffer *b,void *source,long bits);
-extern void oggpack_reset(oggpack_buffer *b);
-extern void oggpack_writeclear(oggpack_buffer *b);
-extern void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
-extern void oggpack_write(oggpack_buffer *b,unsigned long value,int bits);
-extern long oggpack_look(oggpack_buffer *b,int bits);
-extern long oggpack_look1(oggpack_buffer *b);
-extern void oggpack_adv(oggpack_buffer *b,int bits);
-extern void oggpack_adv1(oggpack_buffer *b);
-extern long oggpack_read(oggpack_buffer *b,int bits);
-extern long oggpack_read1(oggpack_buffer *b);
-extern long oggpack_bytes(oggpack_buffer *b);
-extern long oggpack_bits(oggpack_buffer *b);
-extern unsigned char *oggpack_get_buffer(oggpack_buffer *b);
-
-extern void oggpackB_writeinit(oggpack_buffer *b);
-extern int oggpackB_writecheck(oggpack_buffer *b);
-extern void oggpackB_writetrunc(oggpack_buffer *b,long bits);
-extern void oggpackB_writealign(oggpack_buffer *b);
-extern void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits);
-extern void oggpackB_reset(oggpack_buffer *b);
-extern void oggpackB_writeclear(oggpack_buffer *b);
-extern void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
-extern void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits);
-extern long oggpackB_look(oggpack_buffer *b,int bits);
-extern long oggpackB_look1(oggpack_buffer *b);
-extern void oggpackB_adv(oggpack_buffer *b,int bits);
-extern void oggpackB_adv1(oggpack_buffer *b);
-extern long oggpackB_read(oggpack_buffer *b,int bits);
-extern long oggpackB_read1(oggpack_buffer *b);
-extern long oggpackB_bytes(oggpack_buffer *b);
-extern long oggpackB_bits(oggpack_buffer *b);
-extern unsigned char *oggpackB_get_buffer(oggpack_buffer *b);
-
-/* Ogg BITSTREAM PRIMITIVES: encoding **************************/
-
-extern int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op);
-extern int ogg_stream_iovecin(ogg_stream_state *os, ogg_iovec_t *iov,
- int count, long e_o_s, ogg_int64_t granulepos);
-extern int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
-extern int ogg_stream_pageout_fill(ogg_stream_state *os, ogg_page *og, int nfill);
-extern int ogg_stream_flush(ogg_stream_state *os, ogg_page *og);
-extern int ogg_stream_flush_fill(ogg_stream_state *os, ogg_page *og, int nfill);
-
-/* Ogg BITSTREAM PRIMITIVES: decoding **************************/
-
-extern int ogg_sync_init(ogg_sync_state *oy);
-extern int ogg_sync_clear(ogg_sync_state *oy);
-extern int ogg_sync_reset(ogg_sync_state *oy);
-extern int ogg_sync_destroy(ogg_sync_state *oy);
-extern int ogg_sync_check(ogg_sync_state *oy);
-
-extern char *ogg_sync_buffer(ogg_sync_state *oy, long size);
-extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes);
-extern long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og);
-extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
-extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
-extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
-extern int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op);
-
-/* Ogg BITSTREAM PRIMITIVES: general ***************************/
-
-extern int ogg_stream_init(ogg_stream_state *os,int serialno);
-extern int ogg_stream_clear(ogg_stream_state *os);
-extern int ogg_stream_reset(ogg_stream_state *os);
-extern int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno);
-extern int ogg_stream_destroy(ogg_stream_state *os);
-extern int ogg_stream_check(ogg_stream_state *os);
-extern int ogg_stream_eos(ogg_stream_state *os);
-
-extern void ogg_page_checksum_set(ogg_page *og);
-
-extern int ogg_page_version(const ogg_page *og);
-extern int ogg_page_continued(const ogg_page *og);
-extern int ogg_page_bos(const ogg_page *og);
-extern int ogg_page_eos(const ogg_page *og);
-extern ogg_int64_t ogg_page_granulepos(const ogg_page *og);
-extern int ogg_page_serialno(const ogg_page *og);
-extern long ogg_page_pageno(const ogg_page *og);
-extern int ogg_page_packets(const ogg_page *og);
-
-extern void ogg_packet_clear(ogg_packet *op);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _OGG_H */
diff --git a/src/thirdparty/libflac/include/ogg/os_types.h b/src/thirdparty/libflac/include/ogg/os_types.h
deleted file mode 100644
index d6691b703..000000000
--- a/src/thirdparty/libflac/include/ogg/os_types.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/********************************************************************
- * *
- * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
- * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
- * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
- * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
- * *
- * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
- * by the Xiph.Org Foundation http://www.xiph.org/ *
- * *
- ********************************************************************
-
- function: #ifdef jail to whip a few platforms into the UNIX ideal.
- last mod: $Id: os_types.h 17712 2010-12-03 17:10:02Z xiphmont $
-
- ********************************************************************/
-#ifndef _OS_TYPES_H
-#define _OS_TYPES_H
-
-/* make it easy on the folks that want to compile the libs with a
- different malloc than stdlib */
-#define _ogg_malloc malloc
-#define _ogg_calloc calloc
-#define _ogg_realloc realloc
-#define _ogg_free free
-
-#if defined(_WIN32)
-
-# if defined(__CYGWIN__)
-# include <stdint.h>
- typedef int16_t ogg_int16_t;
- typedef uint16_t ogg_uint16_t;
- typedef int32_t ogg_int32_t;
- typedef uint32_t ogg_uint32_t;
- typedef int64_t ogg_int64_t;
- typedef uint64_t ogg_uint64_t;
-# elif defined(__MINGW32__)
-# include <sys/types.h>
- typedef short ogg_int16_t;
- typedef unsigned short ogg_uint16_t;
- typedef int ogg_int32_t;
- typedef unsigned int ogg_uint32_t;
- typedef long long ogg_int64_t;
- typedef unsigned long long ogg_uint64_t;
-# elif defined(__MWERKS__)
- typedef long long ogg_int64_t;
- typedef int ogg_int32_t;
- typedef unsigned int ogg_uint32_t;
- typedef short ogg_int16_t;
- typedef unsigned short ogg_uint16_t;
-# else
- /* MSVC/Borland */
- typedef __int64 ogg_int64_t;
- typedef __int32 ogg_int32_t;
- typedef unsigned __int32 ogg_uint32_t;
- typedef __int16 ogg_int16_t;
- typedef unsigned __int16 ogg_uint16_t;
-# endif
-
-#elif defined(__MACOS__)
-
-# include <sys/types.h>
- typedef SInt16 ogg_int16_t;
- typedef UInt16 ogg_uint16_t;
- typedef SInt32 ogg_int32_t;
- typedef UInt32 ogg_uint32_t;
- typedef SInt64 ogg_int64_t;
-
-#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */
-
-# include <inttypes.h>
- typedef int16_t ogg_int16_t;
- typedef uint16_t ogg_uint16_t;
- typedef int32_t ogg_int32_t;
- typedef uint32_t ogg_uint32_t;
- typedef int64_t ogg_int64_t;
-
-#elif defined(__HAIKU__)
-
- /* Haiku */
-# include <sys/types.h>
- typedef short ogg_int16_t;
- typedef unsigned short ogg_uint16_t;
- typedef int ogg_int32_t;
- typedef unsigned int ogg_uint32_t;
- typedef long long ogg_int64_t;
-
-#elif defined(__BEOS__)
-
- /* Be */
-# include <inttypes.h>
- typedef int16_t ogg_int16_t;
- typedef uint16_t ogg_uint16_t;
- typedef int32_t ogg_int32_t;
- typedef uint32_t ogg_uint32_t;
- typedef int64_t ogg_int64_t;
-
-#elif defined (__EMX__)
-
- /* OS/2 GCC */
- typedef short ogg_int16_t;
- typedef unsigned short ogg_uint16_t;
- typedef int ogg_int32_t;
- typedef unsigned int ogg_uint32_t;
- typedef long long ogg_int64_t;
-
-#elif defined (DJGPP)
-
- /* DJGPP */
- typedef short ogg_int16_t;
- typedef int ogg_int32_t;
- typedef unsigned int ogg_uint32_t;
- typedef long long ogg_int64_t;
-
-#elif defined(R5900)
-
- /* PS2 EE */
- typedef long ogg_int64_t;
- typedef int ogg_int32_t;
- typedef unsigned ogg_uint32_t;
- typedef short ogg_int16_t;
-
-#elif defined(__SYMBIAN32__)
-
- /* Symbian GCC */
- typedef signed short ogg_int16_t;
- typedef unsigned short ogg_uint16_t;
- typedef signed int ogg_int32_t;
- typedef unsigned int ogg_uint32_t;
- typedef long long int ogg_int64_t;
-
-#elif defined(__TMS320C6X__)
-
- /* TI C64x compiler */
- typedef signed short ogg_int16_t;
- typedef unsigned short ogg_uint16_t;
- typedef signed int ogg_int32_t;
- typedef unsigned int ogg_uint32_t;
- typedef long long int ogg_int64_t;
-
-#else
-
-# include <ogg/config_types.h>
-
-#endif
-
-#endif /* _OS_TYPES_H */
diff --git a/src/thirdparty/libflac/include/share/alloc.h b/src/thirdparty/libflac/include/share/alloc.h
deleted file mode 100644
index efc0113ed..000000000
--- a/src/thirdparty/libflac/include/share/alloc.h
+++ /dev/null
@@ -1,208 +0,0 @@
-/* alloc - Convenience routines for safely allocating memory
- * Copyright (C) 2007,2008,2009 Josh Coalson
- *
- * This library 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.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef FLAC__SHARE__ALLOC_H
-#define FLAC__SHARE__ALLOC_H
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-/* WATCHOUT: for c++ you may have to #define __STDC_LIMIT_MACROS 1 real early
- * before #including this file, otherwise SIZE_MAX might not be defined
- */
-
-#include <limits.h> /* for SIZE_MAX */
-#if HAVE_STDINT_H
-#include <stdint.h> /* for SIZE_MAX in case limits.h didn't get it */
-#endif
-#include <stdlib.h> /* for size_t, malloc(), etc */
-
-#ifndef SIZE_MAX
-# ifndef SIZE_T_MAX
-# ifdef _MSC_VER
-# define SIZE_T_MAX UINT_MAX
-# else
-# error
-# endif
-# endif
-# define SIZE_MAX SIZE_T_MAX
-#endif
-
-/* avoid malloc()ing 0 bytes, see:
- * https://www.securecoding.cert.org/confluence/display/seccode/MEM04-A.+Do+not+make+assumptions+about+the+result+of+allocating+0+bytes?focusedCommentId=5407003
-*/
-static void *safe_malloc_(size_t size)
-{
- /* malloc(0) is undefined; FLAC src convention is to always allocate */
- if(!size)
- size++;
- return malloc(size);
-}
-
-static void *safe_calloc_(size_t nmemb, size_t size)
-{
- if(!nmemb || !size)
- return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
- return calloc(nmemb, size);
-}
-
-/*@@@@ there's probably a better way to prevent overflows when allocating untrusted sums but this works for now */
-
-static void *safe_malloc_add_2op_(size_t size1, size_t size2)
-{
- size2 += size1;
- if(size2 < size1)
- return 0;
- return safe_malloc_(size2);
-}
-
-static void *safe_malloc_add_3op_(size_t size1, size_t size2, size_t size3)
-{
- size2 += size1;
- if(size2 < size1)
- return 0;
- size3 += size2;
- if(size3 < size2)
- return 0;
- return safe_malloc_(size3);
-}
-
-static void *safe_malloc_add_4op_(size_t size1, size_t size2, size_t size3, size_t size4)
-{
- size2 += size1;
- if(size2 < size1)
- return 0;
- size3 += size2;
- if(size3 < size2)
- return 0;
- size4 += size3;
- if(size4 < size3)
- return 0;
- return safe_malloc_(size4);
-}
-
-static void *safe_malloc_mul_2op_(size_t size1, size_t size2)
-#if 0
-needs support for cases where sizeof(size_t) != 4
-{
- /* could be faster #ifdef'ing off SIZEOF_SIZE_T */
- if(sizeof(size_t) == 4) {
- if ((double)size1 * (double)size2 < 4294967296.0)
- return malloc(size1*size2);
- }
- return 0;
-}
-#else
-/* better? */
-{
- if(!size1 || !size2)
- return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
- if(size1 > SIZE_MAX / size2)
- return 0;
- return malloc(size1*size2);
-}
-#endif
-
-static void *safe_malloc_mul_3op_(size_t size1, size_t size2, size_t size3)
-{
- if(!size1 || !size2 || !size3)
- return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
- if(size1 > SIZE_MAX / size2)
- return 0;
- size1 *= size2;
- if(size1 > SIZE_MAX / size3)
- return 0;
- return malloc(size1*size3);
-}
-
-/* size1*size2 + size3 */
-static void *safe_malloc_mul2add_(size_t size1, size_t size2, size_t size3)
-{
- if(!size1 || !size2)
- return safe_malloc_(size3);
- if(size1 > SIZE_MAX / size2)
- return 0;
- return safe_malloc_add_2op_(size1*size2, size3);
-}
-
-/* size1 * (size2 + size3) */
-static void *safe_malloc_muladd2_(size_t size1, size_t size2, size_t size3)
-{
- if(!size1 || (!size2 && !size3))
- return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
- size2 += size3;
- if(size2 < size3)
- return 0;
- return safe_malloc_mul_2op_(size1, size2);
-}
-
-static void *safe_realloc_add_2op_(void *ptr, size_t size1, size_t size2)
-{
- size2 += size1;
- if(size2 < size1)
- return 0;
- return realloc(ptr, size2);
-}
-
-static void *safe_realloc_add_3op_(void *ptr, size_t size1, size_t size2, size_t size3)
-{
- size2 += size1;
- if(size2 < size1)
- return 0;
- size3 += size2;
- if(size3 < size2)
- return 0;
- return realloc(ptr, size3);
-}
-
-static void *safe_realloc_add_4op_(void *ptr, size_t size1, size_t size2, size_t size3, size_t size4)
-{
- size2 += size1;
- if(size2 < size1)
- return 0;
- size3 += size2;
- if(size3 < size2)
- return 0;
- size4 += size3;
- if(size4 < size3)
- return 0;
- return realloc(ptr, size4);
-}
-
-static void *safe_realloc_mul_2op_(void *ptr, size_t size1, size_t size2)
-{
- if(!size1 || !size2)
- return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
- if(size1 > SIZE_MAX / size2)
- return 0;
- return realloc(ptr, size1*size2);
-}
-
-/* size1 * (size2 + size3) */
-static void *safe_realloc_muladd2_(void *ptr, size_t size1, size_t size2, size_t size3)
-{
- if(!size1 || (!size2 && !size3))
- return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
- size2 += size3;
- if(size2 < size3)
- return 0;
- return safe_realloc_mul_2op_(ptr, size1, size2);
-}
-
-#endif
diff --git a/src/thirdparty/libflac/include/share/getopt.h b/src/thirdparty/libflac/include/share/getopt.h
deleted file mode 100644
index 1b314b2e7..000000000
--- a/src/thirdparty/libflac/include/share/getopt.h
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- NOTE:
- I cannot get the vanilla getopt code to work (i.e. compile only what
- is needed and not duplicate symbols found in the standard library)
- on all the platforms that FLAC supports. In particular the gating
- of code with the ELIDE_CODE #define is not accurate enough on systems
- that are POSIX but not glibc. If someone has a patch that works on
- GNU/Linux, Darwin, AND Solaris please submit it on the project page:
- http://sourceforge.net/projects/flac
-
- In the meantime I have munged the global symbols and removed gates
- around code, while at the same time trying to touch the original as
- little as possible.
-*/
-/* Declarations for getopt.
- Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The GNU C Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#ifndef SHARE__GETOPT_H
-#define SHARE__GETOPT_H
-
-/*[JEC] was:#ifndef __need_getopt*/
-/*[JEC] was:# define _GETOPT_H 1*/
-/*[JEC] was:#endif*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* For communication from `share__getopt' to the caller.
- When `share__getopt' finds an option that takes an argument,
- the argument value is returned here.
- Also, when `ordering' is RETURN_IN_ORDER,
- each non-option ARGV-element is returned here. */
-
-extern char *share__optarg;
-
-/* Index in ARGV of the next element to be scanned.
- This is used for communication to and from the caller
- and for communication between successive calls to `share__getopt'.
-
- On entry to `share__getopt', zero means this is the first call; initialize.
-
- When `share__getopt' returns -1, this is the index of the first of the
- non-option elements that the caller should itself scan.
-
- Otherwise, `share__optind' communicates from one call to the next
- how much of ARGV has been scanned so far. */
-
-extern int share__optind;
-
-/* Callers store zero here to inhibit the error message `share__getopt' prints
- for unrecognized options. */
-
-extern int share__opterr;
-
-/* Set to an option character which was unrecognized. */
-
-extern int share__optopt;
-
-/*[JEC] was:#ifndef __need_getopt */
-/* Describe the long-named options requested by the application.
- The LONG_OPTIONS argument to share__getopt_long or share__getopt_long_only is a vector
- of `struct share__option' terminated by an element containing a name which is
- zero.
-
- The field `has_arg' is:
- share__no_argument (or 0) if the option does not take an argument,
- share__required_argument (or 1) if the option requires an argument,
- share__optional_argument (or 2) if the option takes an optional argument.
-
- If the field `flag' is not NULL, it points to a variable that is set
- to the value given in the field `val' when the option is found, but
- left unchanged if the option is not found.
-
- To have a long-named option do something other than set an `int' to
- a compiled-in constant, such as set a value from `share__optarg', set the
- option's `flag' field to zero and its `val' field to a nonzero
- value (the equivalent single-letter option character, if there is
- one). For long options that have a zero `flag' field, `share__getopt'
- returns the contents of the `val' field. */
-
-struct share__option
-{
-# if defined __STDC__ && __STDC__
- const char *name;
-# else
- char *name;
-# endif
- /* has_arg can't be an enum because some compilers complain about
- type mismatches in all the code that assumes it is an int. */
- int has_arg;
- int *flag;
- int val;
-};
-
-/* Names for the values of the `has_arg' field of `struct share__option'. */
-
-# define share__no_argument 0
-# define share__required_argument 1
-# define share__optional_argument 2
-/*[JEC] was:#endif*/ /* need getopt */
-
-
-/* Get definitions and prototypes for functions to process the
- arguments in ARGV (ARGC of them, minus the program name) for
- options given in OPTS.
-
- Return the option character from OPTS just read. Return -1 when
- there are no more options. For unrecognized options, or options
- missing arguments, `share__optopt' is set to the option letter, and '?' is
- returned.
-
- The OPTS string is a list of characters which are recognized option
- letters, optionally followed by colons, specifying that that letter
- takes an argument, to be placed in `share__optarg'.
-
- If a letter in OPTS is followed by two colons, its argument is
- optional. This behavior is specific to the GNU `share__getopt'.
-
- The argument `--' causes premature termination of argument
- scanning, explicitly telling `share__getopt' that there are no more
- options.
-
- If OPTS begins with `--', then non-option arguments are treated as
- arguments to the option '\0'. This behavior is specific to the GNU
- `share__getopt'. */
-
-/*[JEC] was:#if defined __STDC__ && __STDC__*/
-/*[JEC] was:# ifdef __GNU_LIBRARY__*/
-/* Many other libraries have conflicting prototypes for getopt, with
- differences in the consts, in stdlib.h. To avoid compilation
- errors, only prototype getopt for the GNU C library. */
-extern int share__getopt (int argc, char *const *argv, const char *shortopts);
-/*[JEC] was:# else*/ /* not __GNU_LIBRARY__ */
-/*[JEC] was:extern int getopt ();*/
-/*[JEC] was:# endif*/ /* __GNU_LIBRARY__ */
-
-/*[JEC] was:# ifndef __need_getopt*/
-extern int share__getopt_long (int argc, char *const *argv, const char *shortopts,
- const struct share__option *longopts, int *longind);
-extern int share__getopt_long_only (int argc, char *const *argv,
- const char *shortopts,
- const struct share__option *longopts, int *longind);
-
-/* Internal only. Users should not call this directly. */
-extern int share___getopt_internal (int argc, char *const *argv,
- const char *shortopts,
- const struct share__option *longopts, int *longind,
- int long_only);
-/*[JEC] was:# endif*/
-/*[JEC] was:#else*/ /* not __STDC__ */
-/*[JEC] was:extern int getopt ();*/
-/*[JEC] was:# ifndef __need_getopt*/
-/*[JEC] was:extern int getopt_long ();*/
-/*[JEC] was:extern int getopt_long_only ();*/
-
-/*[JEC] was:extern int _getopt_internal ();*/
-/*[JEC] was:# endif*/
-/*[JEC] was:#endif*/ /* __STDC__ */
-
-#ifdef __cplusplus
-}
-#endif
-
-/* Make sure we later can get all the definitions and declarations. */
-/*[JEC] was:#undef __need_getopt*/
-
-#endif /* getopt.h */
diff --git a/src/thirdparty/libflac/include/share/grabbag.h b/src/thirdparty/libflac/include/share/grabbag.h
deleted file mode 100644
index 33a214481..000000000
--- a/src/thirdparty/libflac/include/share/grabbag.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* grabbag - Convenience lib for various routines common to several tools
- * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * This library 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.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef SHARE__GRABBAG_H
-#define SHARE__GRABBAG_H
-
-/* These can't be included by themselves, only from within grabbag.h */
-#include "grabbag/cuesheet.h"
-#include "grabbag/file.h"
-#include "grabbag/picture.h"
-#include "grabbag/replaygain.h"
-#include "grabbag/seektable.h"
-
-#endif
diff --git a/src/thirdparty/libflac/include/share/grabbag/cuesheet.h b/src/thirdparty/libflac/include/share/grabbag/cuesheet.h
deleted file mode 100644
index c8e2741dc..000000000
--- a/src/thirdparty/libflac/include/share/grabbag/cuesheet.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* grabbag - Convenience lib for various routines common to several tools
- * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * This library 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.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/* This .h cannot be included by itself; #include "share/grabbag.h" instead. */
-
-#ifndef GRABBAG__CUESHEET_H
-#define GRABBAG__CUESHEET_H
-
-#include <stdio.h>
-#include "FLAC/metadata.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-unsigned grabbag__cuesheet_msf_to_frame(unsigned minutes, unsigned seconds, unsigned frames);
-void grabbag__cuesheet_frame_to_msf(unsigned frame, unsigned *minutes, unsigned *seconds, unsigned *frames);
-
-FLAC__StreamMetadata *grabbag__cuesheet_parse(FILE *file, const char **error_message, unsigned *last_line_read, unsigned sample_rate, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset);
-
-void grabbag__cuesheet_emit(FILE *file, const FLAC__StreamMetadata *cuesheet, const char *file_reference);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/src/thirdparty/libflac/include/share/grabbag/file.h b/src/thirdparty/libflac/include/share/grabbag/file.h
deleted file mode 100644
index 8711e1f7a..000000000
--- a/src/thirdparty/libflac/include/share/grabbag/file.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* grabbag - Convenience lib for various routines common to several tools
- * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * This library 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.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/* Convenience routines for manipulating files */
-
-/* This .h cannot be included by itself; #include "share/grabbag.h" instead. */
-
-#ifndef GRABAG__FILE_H
-#define GRABAG__FILE_H
-
-/* needed because of off_t */
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <sys/types.h> /* for off_t */
-#include <stdio.h> /* for FILE */
-#include "FLAC/ordinals.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void grabbag__file_copy_metadata(const char *srcpath, const char *destpath);
-off_t grabbag__file_get_filesize(const char *srcpath);
-const char *grabbag__file_get_basename(const char *srcpath);
-
-/* read_only == false means "make file writable by user"
- * read_only == true means "make file read-only for everyone"
- */
-FLAC__bool grabbag__file_change_stats(const char *filename, FLAC__bool read_only);
-
-/* returns true iff stat() succeeds for both files and they have the same device and inode. */
-/* on windows, uses GetFileInformationByHandle() to compare */
-FLAC__bool grabbag__file_are_same(const char *f1, const char *f2);
-
-/* attempts to make writable before unlinking */
-FLAC__bool grabbag__file_remove_file(const char *filename);
-
-/* these will forcibly set stdin/stdout to binary mode (for OSes that require it) */
-FILE *grabbag__file_get_binary_stdin(void);
-FILE *grabbag__file_get_binary_stdout(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/src/thirdparty/libflac/include/share/grabbag/picture.h b/src/thirdparty/libflac/include/share/grabbag/picture.h
deleted file mode 100644
index 166b96142..000000000
--- a/src/thirdparty/libflac/include/share/grabbag/picture.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* grabbag - Convenience lib for various routines common to several tools
- * Copyright (C) 2006,2007,2008,2009 Josh Coalson
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-/* This .h cannot be included by itself; #include "share/grabbag.h" instead. */
-
-#ifndef GRABBAG__PICTURE_H
-#define GRABBAG__PICTURE_H
-
-#include "FLAC/metadata.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* spec should be of the form "[TYPE]|MIME_TYPE|[DESCRIPTION]|[WIDTHxHEIGHTxDEPTH[/COLORS]]|FILE", e.g.
- * "|image/jpeg|||cover.jpg"
- * "4|image/jpeg||300x300x24|backcover.jpg"
- * "|image/png|description|300x300x24/71|cover.png"
- * "-->|image/gif||300x300x24/71|http://blah.blah.blah/cover.gif"
- *
- * empty type means default to FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER
- * empty resolution spec means to get from the file (cannot get used with "-->" linked images)
- * spec and error_message must not be NULL
- */
-FLAC__StreamMetadata *grabbag__picture_parse_specification(const char *spec, const char **error_message);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/src/thirdparty/libflac/include/share/grabbag/replaygain.h b/src/thirdparty/libflac/include/share/grabbag/replaygain.h
deleted file mode 100644
index c70c1862e..000000000
--- a/src/thirdparty/libflac/include/share/grabbag/replaygain.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* grabbag - Convenience lib for various routines common to several tools
- * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * This library 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.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * This wraps the replaygain_analysis lib, which is LGPL. This wrapper
- * allows analysis of different input resolutions by automatically
- * scaling the input signal
- */
-
-/* This .h cannot be included by itself; #include "share/grabbag.h" instead. */
-
-#ifndef GRABBAG__REPLAYGAIN_H
-#define GRABBAG__REPLAYGAIN_H
-
-#include "FLAC/metadata.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern const unsigned GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED;
-
-extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_REFERENCE_LOUDNESS; /* = "REPLAYGAIN_REFERENCE_LOUDNESS" */
-extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_TITLE_GAIN; /* = "REPLAYGAIN_TRACK_GAIN" */
-extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_TITLE_PEAK; /* = "REPLAYGAIN_TRACK_PEAK" */
-extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_ALBUM_GAIN; /* = "REPLAYGAIN_ALBUM_GAIN" */
-extern const FLAC__byte * const GRABBAG__REPLAYGAIN_TAG_ALBUM_PEAK; /* = "REPLAYGAIN_ALBUM_PEAK" */
-
-FLAC__bool grabbag__replaygain_is_valid_sample_frequency(unsigned sample_frequency);
-
-FLAC__bool grabbag__replaygain_init(unsigned sample_frequency);
-
-/* 'bps' must be valid for FLAC, i.e. >=4 and <= 32 */
-FLAC__bool grabbag__replaygain_analyze(const FLAC__int32 * const input[], FLAC__bool is_stereo, unsigned bps, unsigned samples);
-
-void grabbag__replaygain_get_album(float *gain, float *peak);
-void grabbag__replaygain_get_title(float *gain, float *peak);
-
-/* These three functions return an error string on error, or NULL if successful */
-const char *grabbag__replaygain_analyze_file(const char *filename, float *title_gain, float *title_peak);
-const char *grabbag__replaygain_store_to_vorbiscomment(FLAC__StreamMetadata *block, float album_gain, float album_peak, float title_gain, float title_peak);
-const char *grabbag__replaygain_store_to_vorbiscomment_reference(FLAC__StreamMetadata *block);
-const char *grabbag__replaygain_store_to_vorbiscomment_album(FLAC__StreamMetadata *block, float album_gain, float album_peak);
-const char *grabbag__replaygain_store_to_vorbiscomment_title(FLAC__StreamMetadata *block, float title_gain, float title_peak);
-const char *grabbag__replaygain_store_to_file(const char *filename, float album_gain, float album_peak, float title_gain, float title_peak, FLAC__bool preserve_modtime);
-const char *grabbag__replaygain_store_to_file_reference(const char *filename, FLAC__bool preserve_modtime);
-const char *grabbag__replaygain_store_to_file_album(const char *filename, float album_gain, float album_peak, FLAC__bool preserve_modtime);
-const char *grabbag__replaygain_store_to_file_title(const char *filename, float title_gain, float title_peak, FLAC__bool preserve_modtime);
-
-FLAC__bool grabbag__replaygain_load_from_vorbiscomment(const FLAC__StreamMetadata *block, FLAC__bool album_mode, FLAC__bool strict, double *reference, double *gain, double *peak);
-double grabbag__replaygain_compute_scale_factor(double peak, double gain, double preamp, FLAC__bool prevent_clipping);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/src/thirdparty/libflac/include/share/grabbag/seektable.h b/src/thirdparty/libflac/include/share/grabbag/seektable.h
deleted file mode 100644
index 67c91551b..000000000
--- a/src/thirdparty/libflac/include/share/grabbag/seektable.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* grabbag - Convenience lib for various routines common to several tools
- * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * This library 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.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/* Convenience routines for working with seek tables */
-
-/* This .h cannot be included by itself; #include "share/grabbag.h" instead. */
-
-#ifndef GRABAG__SEEKTABLE_H
-#define GRABAG__SEEKTABLE_H
-
-#include "FLAC/format.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-FLAC__bool grabbag__seektable_convert_specification_to_template(const char *spec, FLAC__bool only_explicit_placeholders, FLAC__uint64 total_samples_to_encode, unsigned sample_rate, FLAC__StreamMetadata *seektable_template, FLAC__bool *spec_has_real_points);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/src/thirdparty/libflac/include/share/replaygain_analysis.h b/src/thirdparty/libflac/include/share/replaygain_analysis.h
deleted file mode 100644
index 02067d21f..000000000
--- a/src/thirdparty/libflac/include/share/replaygain_analysis.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * ReplayGainAnalysis - analyzes input samples and give the recommended dB change
- * Copyright (C) 2001 David Robinson and Glen Sawyer
- *
- * This library 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.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * concept and filter values by David Robinson (David@Robinson.org)
- * -- blame him if you think the idea is flawed
- * coding by Glen Sawyer (glensawyer@hotmail.com) 442 N 700 E, Provo, UT 84606 USA
- * -- blame him if you think this runs too slowly, or the coding is otherwise flawed
- * minor cosmetic tweaks to integrate with FLAC by Josh Coalson
- *
- * For an explanation of the concepts and the basic algorithms involved, go to:
- * http://www.replaygain.org/
- */
-
-#ifndef GAIN_ANALYSIS_H
-#define GAIN_ANALYSIS_H
-
-#include <stddef.h>
-
-#define GAIN_NOT_ENOUGH_SAMPLES -24601
-#define GAIN_ANALYSIS_ERROR 0
-#define GAIN_ANALYSIS_OK 1
-
-#define INIT_GAIN_ANALYSIS_ERROR 0
-#define INIT_GAIN_ANALYSIS_OK 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef float Float_t; /* Type used for filtering */
-
-extern Float_t ReplayGainReferenceLoudness; /* in dB SPL, currently == 89.0 */
-
-int InitGainAnalysis ( long samplefreq );
-int AnalyzeSamples ( const Float_t* left_samples, const Float_t* right_samples, size_t num_samples, int num_channels );
-int ResetSampleFrequency ( long samplefreq );
-Float_t GetTitleGain ( void );
-Float_t GetAlbumGain ( void );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* GAIN_ANALYSIS_H */
diff --git a/src/thirdparty/libflac/include/share/replaygain_synthesis.h b/src/thirdparty/libflac/include/share/replaygain_synthesis.h
deleted file mode 100644
index a1fdc5a4d..000000000
--- a/src/thirdparty/libflac/include/share/replaygain_synthesis.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* replaygain_synthesis - Routines for applying ReplayGain to a signal
- * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * This library 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.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef FLAC__SHARE__REPLAYGAIN_SYNTHESIS_H
-#define FLAC__SHARE__REPLAYGAIN_SYNTHESIS_H
-
-#include <stdlib.h> /* for size_t */
-#include "FLAC/ordinals.h"
-
-#define FLAC_SHARE__MAX_SUPPORTED_CHANNELS 2
-
-typedef enum {
- NOISE_SHAPING_NONE = 0,
- NOISE_SHAPING_LOW = 1,
- NOISE_SHAPING_MEDIUM = 2,
- NOISE_SHAPING_HIGH = 3
-} NoiseShaping;
-
-typedef struct {
- const float* FilterCoeff;
- FLAC__uint64 Mask;
- double Add;
- float Dither;
- float ErrorHistory [FLAC_SHARE__MAX_SUPPORTED_CHANNELS] [16]; /* 16th order Noise shaping */
- float DitherHistory [FLAC_SHARE__MAX_SUPPORTED_CHANNELS] [16];
- int LastRandomNumber [FLAC_SHARE__MAX_SUPPORTED_CHANNELS];
- unsigned LastHistoryIndex;
- NoiseShaping ShapingType;
-} DitherContext;
-
-void FLAC__replaygain_synthesis__init_dither_context(DitherContext *dither, int bits, int shapingtype);
-
-/* scale = (float) pow(10., (double)replaygain * 0.05); */
-size_t FLAC__replaygain_synthesis__apply_gain(FLAC__byte *data_out, FLAC__bool little_endian_data_out, FLAC__bool unsigned_data_out, const FLAC__int32 * const input[], unsigned wide_samples, unsigned channels, const unsigned source_bps, const unsigned target_bps, const double scale, const FLAC__bool hard_limit, FLAC__bool do_dithering, DitherContext *dither_context);
-
-#endif
diff --git a/src/thirdparty/libflac/include/share/utf8.h b/src/thirdparty/libflac/include/share/utf8.h
deleted file mode 100644
index 7d6650d60..000000000
--- a/src/thirdparty/libflac/include/share/utf8.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef SHARE__UTF8_H
-#define SHARE__UTF8_H
-
-/*
- * Convert a string between UTF-8 and the locale's charset.
- * Invalid bytes are replaced by '#', and characters that are
- * not available in the target encoding are replaced by '?'.
- *
- * If the locale's charset is not set explicitly then it is
- * obtained using nl_langinfo(CODESET), where available, the
- * environment variable CHARSET, or assumed to be US-ASCII.
- *
- * Return value of conversion functions:
- *
- * -1 : memory allocation failed
- * 0 : data was converted exactly
- * 1 : valid data was converted approximately (using '?')
- * 2 : input was invalid (but still converted, using '#')
- * 3 : unknown encoding (but still converted, using '?')
- */
-
-int utf8_encode(const char *from, char **to);
-int utf8_decode(const char *from, char **to);
-
-#endif
diff --git a/src/thirdparty/libflac/src/libFLAC/Ogg/bitwise.c b/src/thirdparty/libflac/src/libFLAC/Ogg/bitwise.c
deleted file mode 100644
index 68aca6754..000000000
--- a/src/thirdparty/libflac/src/libFLAC/Ogg/bitwise.c
+++ /dev/null
@@ -1,857 +0,0 @@
-/********************************************************************
- * *
- * THIS FILE IS PART OF THE Ogg CONTAINER SOURCE CODE. *
- * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
- * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
- * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
- * *
- * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 *
- * by the Xiph.Org Foundation http://www.xiph.org/ *
- * *
- ********************************************************************
-
- function: packing variable sized words into an octet stream
- last mod: $Id: bitwise.c 18051 2011-08-04 17:56:39Z giles $
-
- ********************************************************************/
-
-/* We're 'LSb' endian; if we write a word but read individual bits,
- then we'll read the lsb first */
-
-#include <string.h>
-#include <stdlib.h>
-#include <limits.h>
-#include <ogg/ogg.h>
-
-#define BUFFER_INCREMENT 256
-
-static const unsigned long mask[]=
-{0x00000000,0x00000001,0x00000003,0x00000007,0x0000000f,
- 0x0000001f,0x0000003f,0x0000007f,0x000000ff,0x000001ff,
- 0x000003ff,0x000007ff,0x00000fff,0x00001fff,0x00003fff,
- 0x00007fff,0x0000ffff,0x0001ffff,0x0003ffff,0x0007ffff,
- 0x000fffff,0x001fffff,0x003fffff,0x007fffff,0x00ffffff,
- 0x01ffffff,0x03ffffff,0x07ffffff,0x0fffffff,0x1fffffff,
- 0x3fffffff,0x7fffffff,0xffffffff };
-
-static const unsigned int mask8B[]=
-{0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff};
-
-void oggpack_writeinit(oggpack_buffer *b){
- memset(b,0,sizeof(*b));
- b->ptr=b->buffer=_ogg_malloc(BUFFER_INCREMENT);
- b->buffer[0]='\0';
- b->storage=BUFFER_INCREMENT;
-}
-
-void oggpackB_writeinit(oggpack_buffer *b){
- oggpack_writeinit(b);
-}
-
-int oggpack_writecheck(oggpack_buffer *b){
- if(!b->ptr || !b->storage)return -1;
- return 0;
-}
-
-int oggpackB_writecheck(oggpack_buffer *b){
- return oggpack_writecheck(b);
-}
-
-void oggpack_writetrunc(oggpack_buffer *b,long bits){
- long bytes=bits>>3;
- if(b->ptr){
- bits-=bytes*8;
- b->ptr=b->buffer+bytes;
- b->endbit=bits;
- b->endbyte=bytes;
- *b->ptr&=mask[bits];
- }
-}
-
-void oggpackB_writetrunc(oggpack_buffer *b,long bits){
- long bytes=bits>>3;
- if(b->ptr){
- bits-=bytes*8;
- b->ptr=b->buffer+bytes;
- b->endbit=bits;
- b->endbyte=bytes;
- *b->ptr&=mask8B[bits];
- }
-}
-
-/* Takes only up to 32 bits. */
-void oggpack_write(oggpack_buffer *b,unsigned long value,int bits){
- if(bits<0 || bits>32) goto err;
- if(b->endbyte>=b->storage-4){
- void *ret;
- if(!b->ptr)return;
- if(b->storage>LONG_MAX-BUFFER_INCREMENT) goto err;
- ret=_ogg_realloc(b->buffer,b->storage+BUFFER_INCREMENT);
- if(!ret) goto err;
- b->buffer=ret;
- b->storage+=BUFFER_INCREMENT;
- b->ptr=b->buffer+b->endbyte;
- }
-
- value&=mask[bits];
- bits+=b->endbit;
-
- b->ptr[0]|=value<<b->endbit;
-
- if(bits>=8){
- b->ptr[1]=(unsigned char)(value>>(8-b->endbit));
- if(bits>=16){
- b->ptr[2]=(unsigned char)(value>>(16-b->endbit));
- if(bits>=24){
- b->ptr[3]=(unsigned char)(value>>(24-b->endbit));
- if(bits>=32){
- if(b->endbit)
- b->ptr[4]=(unsigned char)(value>>(32-b->endbit));
- else
- b->ptr[4]=0;
- }
- }
- }
- }
-
- b->endbyte+=bits/8;
- b->ptr+=bits/8;
- b->endbit=bits&7;
- return;
- err:
- oggpack_writeclear(b);
-}
-
-/* Takes only up to 32 bits. */
-void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits){
- if(bits<0 || bits>32) goto err;
- if(b->endbyte>=b->storage-4){
- void *ret;
- if(!b->ptr)return;
- if(b->storage>LONG_MAX-BUFFER_INCREMENT) goto err;
- ret=_ogg_realloc(b->buffer,b->storage+BUFFER_INCREMENT);
- if(!ret) goto err;
- b->buffer=ret;
- b->storage+=BUFFER_INCREMENT;
- b->ptr=b->buffer+b->endbyte;
- }
-
- value=(value&mask[bits])<<(32-bits);
- bits+=b->endbit;
-
- b->ptr[0]|=value>>(24+b->endbit);
-
- if(bits>=8){
- b->ptr[1]=(unsigned char)(value>>(16+b->endbit));
- if(bits>=16){
- b->ptr[2]=(unsigned char)(value>>(8+b->endbit));
- if(bits>=24){
- b->ptr[3]=(unsigned char)(value>>(b->endbit));
- if(bits>=32){
- if(b->endbit)
- b->ptr[4]=(unsigned char)(value<<(8-b->endbit));
- else
- b->ptr[4]=0;
- }
- }
- }
- }
-
- b->endbyte+=bits/8;
- b->ptr+=bits/8;
- b->endbit=bits&7;
- return;
- err:
- oggpack_writeclear(b);
-}
-
-void oggpack_writealign(oggpack_buffer *b){
- int bits=8-b->endbit;
- if(bits<8)
- oggpack_write(b,0,bits);
-}
-
-void oggpackB_writealign(oggpack_buffer *b){
- int bits=8-b->endbit;
- if(bits<8)
- oggpackB_write(b,0,bits);
-}
-
-static void oggpack_writecopy_helper(oggpack_buffer *b,
- void *source,
- long bits,
- void (*w)(oggpack_buffer *,
- unsigned long,
- int),
- int msb){
- unsigned char *ptr=(unsigned char *)source;
-
- long bytes=bits/8;
- bits-=bytes*8;
-
- if(b->endbit){
- int i;
- /* unaligned copy. Do it the hard way. */
- for(i=0;i<bytes;i++)
- w(b,(unsigned long)(ptr[i]),8);
- }else{
- /* aligned block copy */
- if(b->endbyte+bytes+1>=b->storage){
- void *ret;
- if(!b->ptr) goto err;
- if(b->endbyte+bytes+BUFFER_INCREMENT>b->storage) goto err;
- b->storage=b->endbyte+bytes+BUFFER_INCREMENT;
- ret=_ogg_realloc(b->buffer,b->storage);
- if(!ret) goto err;
- b->buffer=ret;
- b->ptr=b->buffer+b->endbyte;
- }
-
- memmove(b->ptr,source,bytes);
- b->ptr+=bytes;
- b->endbyte+=bytes;
- *b->ptr=0;
-
- }
- if(bits){
- if(msb)
- w(b,(unsigned long)(ptr[bytes]>>(8-bits)),bits);
- else
- w(b,(unsigned long)(ptr[bytes]),bits);
- }
- return;
- err:
- oggpack_writeclear(b);
-}
-
-void oggpack_writecopy(oggpack_buffer *b,void *source,long bits){
- oggpack_writecopy_helper(b,source,bits,oggpack_write,0);
-}
-
-void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits){
- oggpack_writecopy_helper(b,source,bits,oggpackB_write,1);
-}
-
-void oggpack_reset(oggpack_buffer *b){
- if(!b->ptr)return;
- b->ptr=b->buffer;
- b->buffer[0]=0;
- b->endbit=b->endbyte=0;
-}
-
-void oggpackB_reset(oggpack_buffer *b){
- oggpack_reset(b);
-}
-
-void oggpack_writeclear(oggpack_buffer *b){
- if(b->buffer)_ogg_free(b->buffer);
- memset(b,0,sizeof(*b));
-}
-
-void oggpackB_writeclear(oggpack_buffer *b){
- oggpack_writeclear(b);
-}
-
-void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes){
- memset(b,0,sizeof(*b));
- b->buffer=b->ptr=buf;
- b->storage=bytes;
-}
-
-void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes){
- oggpack_readinit(b,buf,bytes);
-}
-
-/* Read in bits without advancing the bitptr; bits <= 32 */
-long oggpack_look(oggpack_buffer *b,int bits){
- unsigned long ret;
- unsigned long m;
-
- if(bits<0 || bits>32) return -1;
- m=mask[bits];
- bits+=b->endbit;
-
- if(b->endbyte >= b->storage-4){
- /* not the main path */
- if(b->endbyte > b->storage-((bits+7)>>3)) return -1;
- /* special case to avoid reading b->ptr[0], which might be past the end of
- the buffer; also skips some useless accounting */
- else if(!bits)return(0L);
- }
-
- ret=b->ptr[0]>>b->endbit;
- if(bits>8){
- ret|=b->ptr[1]<<(8-b->endbit);
- if(bits>16){
- ret|=b->ptr[2]<<(16-b->endbit);
- if(bits>24){
- ret|=b->ptr[3]<<(24-b->endbit);
- if(bits>32 && b->endbit)
- ret|=b->ptr[4]<<(32-b->endbit);
- }
- }
- }
- return(m&ret);
-}
-
-/* Read in bits without advancing the bitptr; bits <= 32 */
-long oggpackB_look(oggpack_buffer *b,int bits){
- unsigned long ret;
- int m=32-bits;
-
- if(m<0 || m>32) return -1;
- bits+=b->endbit;
-
- if(b->endbyte >= b->storage-4){
- /* not the main path */
- if(b->endbyte > b->storage-((bits+7)>>3)) return -1;
- /* special case to avoid reading b->ptr[0], which might be past the end of
- the buffer; also skips some useless accounting */
- else if(!bits)return(0L);
- }
-
- ret=b->ptr[0]<<(24+b->endbit);
- if(bits>8){
- ret|=b->ptr[1]<<(16+b->endbit);
- if(bits>16){
- ret|=b->ptr[2]<<(8+b->endbit);
- if(bits>24){
- ret|=b->ptr[3]<<(b->endbit);
- if(bits>32 && b->endbit)
- ret|=b->ptr[4]>>(8-b->endbit);
- }
- }
- }
- return ((ret&0xffffffff)>>(m>>1))>>((m+1)>>1);
-}
-
-long oggpack_look1(oggpack_buffer *b){
- if(b->endbyte>=b->storage)return(-1);
- return((b->ptr[0]>>b->endbit)&1);
-}
-
-long oggpackB_look1(oggpack_buffer *b){
- if(b->endbyte>=b->storage)return(-1);
- return((b->ptr[0]>>(7-b->endbit))&1);
-}
-
-void oggpack_adv(oggpack_buffer *b,int bits){
- bits+=b->endbit;
-
- if(b->endbyte > b->storage-((bits+7)>>3)) goto overflow;
-
- b->ptr+=bits/8;
- b->endbyte+=bits/8;
- b->endbit=bits&7;
- return;
-
- overflow:
- b->ptr=NULL;
- b->endbyte=b->storage;
- b->endbit=1;
-}
-
-void oggpackB_adv(oggpack_buffer *b,int bits){
- oggpack_adv(b,bits);
-}
-
-void oggpack_adv1(oggpack_buffer *b){
- if(++(b->endbit)>7){
- b->endbit=0;
- b->ptr++;
- b->endbyte++;
- }
-}
-
-void oggpackB_adv1(oggpack_buffer *b){
- oggpack_adv1(b);
-}
-
-/* bits <= 32 */
-long oggpack_read(oggpack_buffer *b,int bits){
- long ret;
- unsigned long m;
-
- if(bits<0 || bits>32) goto err;
- m=mask[bits];
- bits+=b->endbit;
-
- if(b->endbyte >= b->storage-4){
- /* not the main path */
- if(b->endbyte > b->storage-((bits+7)>>3)) goto overflow;
- /* special case to avoid reading b->ptr[0], which might be past the end of
- the buffer; also skips some useless accounting */
- else if(!bits)return(0L);
- }
-
- ret=b->ptr[0]>>b->endbit;
- if(bits>8){
- ret|=b->ptr[1]<<(8-b->endbit);
- if(bits>16){
- ret|=b->ptr[2]<<(16-b->endbit);
- if(bits>24){
- ret|=b->ptr[3]<<(24-b->endbit);
- if(bits>32 && b->endbit){
- ret|=b->ptr[4]<<(32-b->endbit);
- }
- }
- }
- }
- ret&=m;
- b->ptr+=bits/8;
- b->endbyte+=bits/8;
- b->endbit=bits&7;
- return ret;
-
- overflow:
- err:
- b->ptr=NULL;
- b->endbyte=b->storage;
- b->endbit=1;
- return -1L;
-}
-
-/* bits <= 32 */
-long oggpackB_read(oggpack_buffer *b,int bits){
- long ret;
- long m=32-bits;
-
- if(m<0 || m>32) goto err;
- bits+=b->endbit;
-
- if(b->endbyte+4>=b->storage){
- /* not the main path */
- if(b->endbyte > b->storage-((bits+7)>>3)) goto overflow;
- /* special case to avoid reading b->ptr[0], which might be past the end of
- the buffer; also skips some useless accounting */
- else if(!bits)return(0L);
- }
-
- ret=b->ptr[0]<<(24+b->endbit);
- if(bits>8){
- ret|=b->ptr[1]<<(16+b->endbit);
- if(bits>16){
- ret|=b->ptr[2]<<(8+b->endbit);
- if(bits>24){
- ret|=b->ptr[3]<<(b->endbit);
- if(bits>32 && b->endbit)
- ret|=b->ptr[4]>>(8-b->endbit);
- }
- }
- }
- ret=((ret&0xffffffffUL)>>(m>>1))>>((m+1)>>1);
-
- b->ptr+=bits/8;
- b->endbyte+=bits/8;
- b->endbit=bits&7;
- return ret;
-
- overflow:
- err:
- b->ptr=NULL;
- b->endbyte=b->storage;
- b->endbit=1;
- return -1L;
-}
-
-long oggpack_read1(oggpack_buffer *b){
- long ret;
-
- if(b->endbyte >= b->storage) goto overflow;
- ret=(b->ptr[0]>>b->endbit)&1;
-
- b->endbit++;
- if(b->endbit>7){
- b->endbit=0;
- b->ptr++;
- b->endbyte++;
- }
- return ret;
-
- overflow:
- b->ptr=NULL;
- b->endbyte=b->storage;
- b->endbit=1;
- return -1L;
-}
-
-long oggpackB_read1(oggpack_buffer *b){
- long ret;
-
- if(b->endbyte >= b->storage) goto overflow;
- ret=(b->ptr[0]>>(7-b->endbit))&1;
-
- b->endbit++;
- if(b->endbit>7){
- b->endbit=0;
- b->ptr++;
- b->endbyte++;
- }
- return ret;
-
- overflow:
- b->ptr=NULL;
- b->endbyte=b->storage;
- b->endbit=1;
- return -1L;
-}
-
-long oggpack_bytes(oggpack_buffer *b){
- return(b->endbyte+(b->endbit+7)/8);
-}
-
-long oggpack_bits(oggpack_buffer *b){
- return(b->endbyte*8+b->endbit);
-}
-
-long oggpackB_bytes(oggpack_buffer *b){
- return oggpack_bytes(b);
-}
-
-long oggpackB_bits(oggpack_buffer *b){
- return oggpack_bits(b);
-}
-
-unsigned char *oggpack_get_buffer(oggpack_buffer *b){
- return(b->buffer);
-}
-
-unsigned char *oggpackB_get_buffer(oggpack_buffer *b){
- return oggpack_get_buffer(b);
-}
-
-/* Self test of the bitwise routines; everything else is based on
- them, so they damned well better be solid. */
-
-#ifdef _V_SELFTEST
-#include <stdio.h>
-
-static int ilog(unsigned int v){
- int ret=0;
- while(v){
- ret++;
- v>>=1;
- }
- return(ret);
-}
-
-oggpack_buffer o;
-oggpack_buffer r;
-
-void report(char *in){
- fprintf(stderr,"%s",in);
- exit(1);
-}
-
-void cliptest(unsigned long *b,int vals,int bits,int *comp,int compsize){
- long bytes,i;
- unsigned char *buffer;
-
- oggpack_reset(&o);
- for(i=0;i<vals;i++)
- oggpack_write(&o,b[i],bits?bits:ilog(b[i]));
- buffer=oggpack_get_buffer(&o);
- bytes=oggpack_bytes(&o);
- if(bytes!=compsize)report("wrong number of bytes!\n");
- for(i=0;i<bytes;i++)if(buffer[i]!=comp[i]){
- for(i=0;i<bytes;i++)fprintf(stderr,"%x %x\n",(int)buffer[i],(int)comp[i]);
- report("wrote incorrect value!\n");
- }
- oggpack_readinit(&r,buffer,bytes);
- for(i=0;i<vals;i++){
- int tbit=bits?bits:ilog(b[i]);
- if(oggpack_look(&r,tbit)==-1)
- report("out of data!\n");
- if(oggpack_look(&r,tbit)!=(b[i]&mask[tbit]))
- report("looked at incorrect value!\n");
- if(tbit==1)
- if(oggpack_look1(&r)!=(b[i]&mask[tbit]))
- report("looked at single bit incorrect value!\n");
- if(tbit==1){
- if(oggpack_read1(&r)!=(b[i]&mask[tbit]))
- report("read incorrect single bit value!\n");
- }else{
- if(oggpack_read(&r,tbit)!=(b[i]&mask[tbit]))
- report("read incorrect value!\n");
- }
- }
- if(oggpack_bytes(&r)!=bytes)report("leftover bytes after read!\n");
-}
-
-void cliptestB(unsigned long *b,int vals,int bits,int *comp,int compsize){
- long bytes,i;
- unsigned char *buffer;
-
- oggpackB_reset(&o);
- for(i=0;i<vals;i++)
- oggpackB_write(&o,b[i],bits?bits:ilog(b[i]));
- buffer=oggpackB_get_buffer(&o);
- bytes=oggpackB_bytes(&o);
- if(bytes!=compsize)report("wrong number of bytes!\n");
- for(i=0;i<bytes;i++)if(buffer[i]!=comp[i]){
- for(i=0;i<bytes;i++)fprintf(stderr,"%x %x\n",(int)buffer[i],(int)comp[i]);
- report("wrote incorrect value!\n");
- }
- oggpackB_readinit(&r,buffer,bytes);
- for(i=0;i<vals;i++){
- int tbit=bits?bits:ilog(b[i]);
- if(oggpackB_look(&r,tbit)==-1)
- report("out of data!\n");
- if(oggpackB_look(&r,tbit)!=(b[i]&mask[tbit]))
- report("looked at incorrect value!\n");
- if(tbit==1)
- if(oggpackB_look1(&r)!=(b[i]&mask[tbit]))
- report("looked at single bit incorrect value!\n");
- if(tbit==1){
- if(oggpackB_read1(&r)!=(b[i]&mask[tbit]))
- report("read incorrect single bit value!\n");
- }else{
- if(oggpackB_read(&r,tbit)!=(b[i]&mask[tbit]))
- report("read incorrect value!\n");
- }
- }
- if(oggpackB_bytes(&r)!=bytes)report("leftover bytes after read!\n");
-}
-
-int main(void){
- unsigned char *buffer;
- long bytes,i;
- static unsigned long testbuffer1[]=
- {18,12,103948,4325,543,76,432,52,3,65,4,56,32,42,34,21,1,23,32,546,456,7,
- 567,56,8,8,55,3,52,342,341,4,265,7,67,86,2199,21,7,1,5,1,4};
- int test1size=43;
-
- static unsigned long testbuffer2[]=
- {216531625L,1237861823,56732452,131,3212421,12325343,34547562,12313212,
- 1233432,534,5,346435231,14436467,7869299,76326614,167548585,
- 85525151,0,12321,1,349528352};
- int test2size=21;
-
- static unsigned long testbuffer3[]=
- {1,0,14,0,1,0,12,0,1,0,0,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0,1,1,1,1,1,0,0,1,
- 0,1,30,1,1,1,0,0,1,0,0,0,12,0,11,0,1,0,0,1};
- int test3size=56;
-
- static unsigned long large[]=
- {2136531625L,2137861823,56732452,131,3212421,12325343,34547562,12313212,
- 1233432,534,5,2146435231,14436467,7869299,76326614,167548585,
- 85525151,0,12321,1,2146528352};
-
- int onesize=33;
- static int one[33]={146,25,44,151,195,15,153,176,233,131,196,65,85,172,47,40,
- 34,242,223,136,35,222,211,86,171,50,225,135,214,75,172,
- 223,4};
- static int oneB[33]={150,101,131,33,203,15,204,216,105,193,156,65,84,85,222,
- 8,139,145,227,126,34,55,244,171,85,100,39,195,173,18,
- 245,251,128};
-
- int twosize=6;
- static int two[6]={61,255,255,251,231,29};
- static int twoB[6]={247,63,255,253,249,120};
-
- int threesize=54;
- static int three[54]={169,2,232,252,91,132,156,36,89,13,123,176,144,32,254,
- 142,224,85,59,121,144,79,124,23,67,90,90,216,79,23,83,
- 58,135,196,61,55,129,183,54,101,100,170,37,127,126,10,
- 100,52,4,14,18,86,77,1};
- static int threeB[54]={206,128,42,153,57,8,183,251,13,89,36,30,32,144,183,
- 130,59,240,121,59,85,223,19,228,180,134,33,107,74,98,
- 233,253,196,135,63,2,110,114,50,155,90,127,37,170,104,
- 200,20,254,4,58,106,176,144,0};
-
- int foursize=38;
- static int four[38]={18,6,163,252,97,194,104,131,32,1,7,82,137,42,129,11,72,
- 132,60,220,112,8,196,109,64,179,86,9,137,195,208,122,169,
- 28,2,133,0,1};
- static int fourB[38]={36,48,102,83,243,24,52,7,4,35,132,10,145,21,2,93,2,41,
- 1,219,184,16,33,184,54,149,170,132,18,30,29,98,229,67,
- 129,10,4,32};
-
- int fivesize=45;
- static int five[45]={169,2,126,139,144,172,30,4,80,72,240,59,130,218,73,62,
- 241,24,210,44,4,20,0,248,116,49,135,100,110,130,181,169,
- 84,75,159,2,1,0,132,192,8,0,0,18,22};
- static int fiveB[45]={1,84,145,111,245,100,128,8,56,36,40,71,126,78,213,226,
- 124,105,12,0,133,128,0,162,233,242,67,152,77,205,77,
- 172,150,169,129,79,128,0,6,4,32,0,27,9,0};
-
- int sixsize=7;
- static int six[7]={17,177,170,242,169,19,148};
- static int sixB[7]={136,141,85,79,149,200,41};
-
- /* Test read/write together */
- /* Later we test against pregenerated bitstreams */
- oggpack_writeinit(&o);
-
- fprintf(stderr,"\nSmall preclipped packing (LSb): ");
- cliptest(testbuffer1,test1size,0,one,onesize);
- fprintf(stderr,"ok.");
-
- fprintf(stderr,"\nNull bit call (LSb): ");
- cliptest(testbuffer3,test3size,0,two,twosize);
- fprintf(stderr,"ok.");
-
- fprintf(stderr,"\nLarge preclipped packing (LSb): ");
- cliptest(testbuffer2,test2size,0,three,threesize);
- fprintf(stderr,"ok.");
-
- fprintf(stderr,"\n32 bit preclipped packing (LSb): ");
- oggpack_reset(&o);
- for(i=0;i<test2size;i++)
- oggpack_write(&o,large[i],32);
- buffer=oggpack_get_buffer(&o);
- bytes=oggpack_bytes(&o);
- oggpack_readinit(&r,buffer,bytes);
- for(i=0;i<test2size;i++){
- if(oggpack_look(&r,32)==-1)report("out of data. failed!");
- if(oggpack_look(&r,32)!=large[i]){
- fprintf(stderr,"%ld != %ld (%lx!=%lx):",oggpack_look(&r,32),large[i],
- oggpack_look(&r,32),large[i]);
- report("read incorrect value!\n");
- }
- oggpack_adv(&r,32);
- }
- if(oggpack_bytes(&r)!=bytes)report("leftover bytes after read!\n");
- fprintf(stderr,"ok.");
-
- fprintf(stderr,"\nSmall unclipped packing (LSb): ");
- cliptest(testbuffer1,test1size,7,four,foursize);
- fprintf(stderr,"ok.");
-
- fprintf(stderr,"\nLarge unclipped packing (LSb): ");
- cliptest(testbuffer2,test2size,17,five,fivesize);
- fprintf(stderr,"ok.");
-
- fprintf(stderr,"\nSingle bit unclipped packing (LSb): ");
- cliptest(testbuffer3,test3size,1,six,sixsize);
- fprintf(stderr,"ok.");
-
- fprintf(stderr,"\nTesting read past end (LSb): ");
- oggpack_readinit(&r,(unsigned char *)"\0\0\0\0\0\0\0\0",8);
- for(i=0;i<64;i++){
- if(oggpack_read(&r,1)!=0){
- fprintf(stderr,"failed; got -1 prematurely.\n");
- exit(1);
- }
- }
- if(oggpack_look(&r,1)!=-1 ||
- oggpack_read(&r,1)!=-1){
- fprintf(stderr,"failed; read past end without -1.\n");
- exit(1);
- }
- oggpack_readinit(&r,(unsigned char *)"\0\0\0\0\0\0\0\0",8);
- if(oggpack_read(&r,30)!=0 || oggpack_read(&r,16)!=0){
- fprintf(stderr,"failed 2; got -1 prematurely.\n");
- exit(1);
- }
-
- if(oggpack_look(&r,18)!=0 ||
- oggpack_look(&r,18)!=0){
- fprintf(stderr,"failed 3; got -1 prematurely.\n");
- exit(1);
- }
- if(oggpack_look(&r,19)!=-1 ||
- oggpack_look(&r,19)!=-1){
- fprintf(stderr,"failed; read past end without -1.\n");
- exit(1);
- }
- if(oggpack_look(&r,32)!=-1 ||
- oggpack_look(&r,32)!=-1){
- fprintf(stderr,"failed; read past end without -1.\n");
- exit(1);
- }
- oggpack_writeclear(&o);
- fprintf(stderr,"ok.\n");
-
- /********** lazy, cut-n-paste retest with MSb packing ***********/
-
- /* Test read/write together */
- /* Later we test against pregenerated bitstreams */
- oggpackB_writeinit(&o);
-
- fprintf(stderr,"\nSmall preclipped packing (MSb): ");
- cliptestB(testbuffer1,test1size,0,oneB,onesize);
- fprintf(stderr,"ok.");
-
- fprintf(stderr,"\nNull bit call (MSb): ");
- cliptestB(testbuffer3,test3size,0,twoB,twosize);
- fprintf(stderr,"ok.");
-
- fprintf(stderr,"\nLarge preclipped packing (MSb): ");
- cliptestB(testbuffer2,test2size,0,threeB,threesize);
- fprintf(stderr,"ok.");
-
- fprintf(stderr,"\n32 bit preclipped packing (MSb): ");
- oggpackB_reset(&o);
- for(i=0;i<test2size;i++)
- oggpackB_write(&o,large[i],32);
- buffer=oggpackB_get_buffer(&o);
- bytes=oggpackB_bytes(&o);
- oggpackB_readinit(&r,buffer,bytes);
- for(i=0;i<test2size;i++){
- if(oggpackB_look(&r,32)==-1)report("out of data. failed!");
- if(oggpackB_look(&r,32)!=large[i]){
- fprintf(stderr,"%ld != %ld (%lx!=%lx):",oggpackB_look(&r,32),large[i],
- oggpackB_look(&r,32),large[i]);
- report("read incorrect value!\n");
- }
- oggpackB_adv(&r,32);
- }
- if(oggpackB_bytes(&r)!=bytes)report("leftover bytes after read!\n");
- fprintf(stderr,"ok.");
-
- fprintf(stderr,"\nSmall unclipped packing (MSb): ");
- cliptestB(testbuffer1,test1size,7,fourB,foursize);
- fprintf(stderr,"ok.");
-
- fprintf(stderr,"\nLarge unclipped packing (MSb): ");
- cliptestB(testbuffer2,test2size,17,fiveB,fivesize);
- fprintf(stderr,"ok.");
-
- fprintf(stderr,"\nSingle bit unclipped packing (MSb): ");
- cliptestB(testbuffer3,test3size,1,sixB,sixsize);
- fprintf(stderr,"ok.");
-
- fprintf(stderr,"\nTesting read past end (MSb): ");
- oggpackB_readinit(&r,(unsigned char *)"\0\0\0\0\0\0\0\0",8);
- for(i=0;i<64;i++){
- if(oggpackB_read(&r,1)!=0){
- fprintf(stderr,"failed; got -1 prematurely.\n");
- exit(1);
- }
- }
- if(oggpackB_look(&r,1)!=-1 ||
- oggpackB_read(&r,1)!=-1){
- fprintf(stderr,"failed; read past end without -1.\n");
- exit(1);
- }
- oggpackB_readinit(&r,(unsigned char *)"\0\0\0\0\0\0\0\0",8);
- if(oggpackB_read(&r,30)!=0 || oggpackB_read(&r,16)!=0){
- fprintf(stderr,"failed 2; got -1 prematurely.\n");
- exit(1);
- }
-
- if(oggpackB_look(&r,18)!=0 ||
- oggpackB_look(&r,18)!=0){
- fprintf(stderr,"failed 3; got -1 prematurely.\n");
- exit(1);
- }
- if(oggpackB_look(&r,19)!=-1 ||
- oggpackB_look(&r,19)!=-1){
- fprintf(stderr,"failed; read past end without -1.\n");
- exit(1);
- }
- if(oggpackB_look(&r,32)!=-1 ||
- oggpackB_look(&r,32)!=-1){
- fprintf(stderr,"failed; read past end without -1.\n");
- exit(1);
- }
- oggpackB_writeclear(&o);
- fprintf(stderr,"ok.\n\n");
-
-
- return(0);
-}
-#endif /* _V_SELFTEST */
-
-#undef BUFFER_INCREMENT
diff --git a/src/thirdparty/libflac/src/libFLAC/Ogg/framing.c b/src/thirdparty/libflac/src/libFLAC/Ogg/framing.c
deleted file mode 100644
index 4452cbd58..000000000
--- a/src/thirdparty/libflac/src/libFLAC/Ogg/framing.c
+++ /dev/null
@@ -1,2093 +0,0 @@
-/********************************************************************
- * *
- * THIS FILE IS PART OF THE Ogg CONTAINER SOURCE CODE. *
- * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
- * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
- * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
- * *
- * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 *
- * by the Xiph.Org Foundation http://www.xiph.org/ *
- * *
- ********************************************************************
-
- function: code raw packets into framed OggSquish stream and
- decode Ogg streams back into raw packets
- last mod: $Id: framing.c 18052 2011-08-04 17:57:02Z giles $
-
- note: The CRC code is directly derived from public domain code by
- Ross Williams (ross@guest.adelaide.edu.au). See docs/framing.html
- for details.
-
- ********************************************************************/
-
-#include <stdlib.h>
-#include <string.h>
-#include <ogg/ogg.h>
-
-/* A complete description of Ogg framing exists in docs/framing.html */
-
-int ogg_page_version(const ogg_page *og){
- return((int)(og->header[4]));
-}
-
-int ogg_page_continued(const ogg_page *og){
- return((int)(og->header[5]&0x01));
-}
-
-int ogg_page_bos(const ogg_page *og){
- return((int)(og->header[5]&0x02));
-}
-
-int ogg_page_eos(const ogg_page *og){
- return((int)(og->header[5]&0x04));
-}
-
-ogg_int64_t ogg_page_granulepos(const ogg_page *og){
- unsigned char *page=og->header;
- ogg_int64_t granulepos=page[13]&(0xff);
- granulepos= (granulepos<<8)|(page[12]&0xff);
- granulepos= (granulepos<<8)|(page[11]&0xff);
- granulepos= (granulepos<<8)|(page[10]&0xff);
- granulepos= (granulepos<<8)|(page[9]&0xff);
- granulepos= (granulepos<<8)|(page[8]&0xff);
- granulepos= (granulepos<<8)|(page[7]&0xff);
- granulepos= (granulepos<<8)|(page[6]&0xff);
- return(granulepos);
-}
-
-int ogg_page_serialno(const ogg_page *og){
- return(og->header[14] |
- (og->header[15]<<8) |
- (og->header[16]<<16) |
- (og->header[17]<<24));
-}
-
-long ogg_page_pageno(const ogg_page *og){
- return(og->header[18] |
- (og->header[19]<<8) |
- (og->header[20]<<16) |
- (og->header[21]<<24));
-}
-
-
-
-/* returns the number of packets that are completed on this page (if
- the leading packet is begun on a previous page, but ends on this
- page, it's counted */
-
-/* NOTE:
- If a page consists of a packet begun on a previous page, and a new
- packet begun (but not completed) on this page, the return will be:
- ogg_page_packets(page) ==1,
- ogg_page_continued(page) !=0
-
- If a page happens to be a single packet that was begun on a
- previous page, and spans to the next page (in the case of a three or
- more page packet), the return will be:
- ogg_page_packets(page) ==0,
- ogg_page_continued(page) !=0
-*/
-
-int ogg_page_packets(const ogg_page *og){
- int i,n=og->header[26],count=0;
- for(i=0;i<n;i++)
- if(og->header[27+i]<255)count++;
- return(count);
-}
-
-
-#if 0
-/* helper to initialize lookup for direct-table CRC (illustrative; we
- use the static init below) */
-
-static ogg_uint32_t _ogg_crc_entry(unsigned long index){
- int i;
- unsigned long r;
-
- r = index << 24;
- for (i=0; i<8; i++)
- if (r & 0x80000000UL)
- r = (r << 1) ^ 0x04c11db7; /* The same as the ethernet generator
- polynomial, although we use an
- unreflected alg and an init/final
- of 0, not 0xffffffff */
- else
- r<<=1;
- return (r & 0xffffffffUL);
-}
-#endif
-
-static const ogg_uint32_t crc_lookup[256]={
- 0x00000000,0x04c11db7,0x09823b6e,0x0d4326d9,
- 0x130476dc,0x17c56b6b,0x1a864db2,0x1e475005,
- 0x2608edb8,0x22c9f00f,0x2f8ad6d6,0x2b4bcb61,
- 0x350c9b64,0x31cd86d3,0x3c8ea00a,0x384fbdbd,
- 0x4c11db70,0x48d0c6c7,0x4593e01e,0x4152fda9,
- 0x5f15adac,0x5bd4b01b,0x569796c2,0x52568b75,
- 0x6a1936c8,0x6ed82b7f,0x639b0da6,0x675a1011,
- 0x791d4014,0x7ddc5da3,0x709f7b7a,0x745e66cd,
- 0x9823b6e0,0x9ce2ab57,0x91a18d8e,0x95609039,
- 0x8b27c03c,0x8fe6dd8b,0x82a5fb52,0x8664e6e5,
- 0xbe2b5b58,0xbaea46ef,0xb7a96036,0xb3687d81,
- 0xad2f2d84,0xa9ee3033,0xa4ad16ea,0xa06c0b5d,
- 0xd4326d90,0xd0f37027,0xddb056fe,0xd9714b49,
- 0xc7361b4c,0xc3f706fb,0xceb42022,0xca753d95,
- 0xf23a8028,0xf6fb9d9f,0xfbb8bb46,0xff79a6f1,
- 0xe13ef6f4,0xe5ffeb43,0xe8bccd9a,0xec7dd02d,
- 0x34867077,0x30476dc0,0x3d044b19,0x39c556ae,
- 0x278206ab,0x23431b1c,0x2e003dc5,0x2ac12072,
- 0x128e9dcf,0x164f8078,0x1b0ca6a1,0x1fcdbb16,
- 0x018aeb13,0x054bf6a4,0x0808d07d,0x0cc9cdca,
- 0x7897ab07,0x7c56b6b0,0x71159069,0x75d48dde,
- 0x6b93dddb,0x6f52c06c,0x6211e6b5,0x66d0fb02,
- 0x5e9f46bf,0x5a5e5b08,0x571d7dd1,0x53dc6066,
- 0x4d9b3063,0x495a2dd4,0x44190b0d,0x40d816ba,
- 0xaca5c697,0xa864db20,0xa527fdf9,0xa1e6e04e,
- 0xbfa1b04b,0xbb60adfc,0xb6238b25,0xb2e29692,
- 0x8aad2b2f,0x8e6c3698,0x832f1041,0x87ee0df6,
- 0x99a95df3,0x9d684044,0x902b669d,0x94ea7b2a,
- 0xe0b41de7,0xe4750050,0xe9362689,0xedf73b3e,
- 0xf3b06b3b,0xf771768c,0xfa325055,0xfef34de2,
- 0xc6bcf05f,0xc27dede8,0xcf3ecb31,0xcbffd686,
- 0xd5b88683,0xd1799b34,0xdc3abded,0xd8fba05a,
- 0x690ce0ee,0x6dcdfd59,0x608edb80,0x644fc637,
- 0x7a089632,0x7ec98b85,0x738aad5c,0x774bb0eb,
- 0x4f040d56,0x4bc510e1,0x46863638,0x42472b8f,
- 0x5c007b8a,0x58c1663d,0x558240e4,0x51435d53,
- 0x251d3b9e,0x21dc2629,0x2c9f00f0,0x285e1d47,
- 0x36194d42,0x32d850f5,0x3f9b762c,0x3b5a6b9b,
- 0x0315d626,0x07d4cb91,0x0a97ed48,0x0e56f0ff,
- 0x1011a0fa,0x14d0bd4d,0x19939b94,0x1d528623,
- 0xf12f560e,0xf5ee4bb9,0xf8ad6d60,0xfc6c70d7,
- 0xe22b20d2,0xe6ea3d65,0xeba91bbc,0xef68060b,
- 0xd727bbb6,0xd3e6a601,0xdea580d8,0xda649d6f,
- 0xc423cd6a,0xc0e2d0dd,0xcda1f604,0xc960ebb3,
- 0xbd3e8d7e,0xb9ff90c9,0xb4bcb610,0xb07daba7,
- 0xae3afba2,0xaafbe615,0xa7b8c0cc,0xa379dd7b,
- 0x9b3660c6,0x9ff77d71,0x92b45ba8,0x9675461f,
- 0x8832161a,0x8cf30bad,0x81b02d74,0x857130c3,
- 0x5d8a9099,0x594b8d2e,0x5408abf7,0x50c9b640,
- 0x4e8ee645,0x4a4ffbf2,0x470cdd2b,0x43cdc09c,
- 0x7b827d21,0x7f436096,0x7200464f,0x76c15bf8,
- 0x68860bfd,0x6c47164a,0x61043093,0x65c52d24,
- 0x119b4be9,0x155a565e,0x18197087,0x1cd86d30,
- 0x029f3d35,0x065e2082,0x0b1d065b,0x0fdc1bec,
- 0x3793a651,0x3352bbe6,0x3e119d3f,0x3ad08088,
- 0x2497d08d,0x2056cd3a,0x2d15ebe3,0x29d4f654,
- 0xc5a92679,0xc1683bce,0xcc2b1d17,0xc8ea00a0,
- 0xd6ad50a5,0xd26c4d12,0xdf2f6bcb,0xdbee767c,
- 0xe3a1cbc1,0xe760d676,0xea23f0af,0xeee2ed18,
- 0xf0a5bd1d,0xf464a0aa,0xf9278673,0xfde69bc4,
- 0x89b8fd09,0x8d79e0be,0x803ac667,0x84fbdbd0,
- 0x9abc8bd5,0x9e7d9662,0x933eb0bb,0x97ffad0c,
- 0xafb010b1,0xab710d06,0xa6322bdf,0xa2f33668,
- 0xbcb4666d,0xb8757bda,0xb5365d03,0xb1f740b4};
-
-/* init the encode/decode logical stream state */
-
-int ogg_stream_init(ogg_stream_state *os,int serialno){
- if(os){
- memset(os,0,sizeof(*os));
- os->body_storage=16*1024;
- os->lacing_storage=1024;
-
- os->body_data=_ogg_malloc(os->body_storage*sizeof(*os->body_data));
- os->lacing_vals=_ogg_malloc(os->lacing_storage*sizeof(*os->lacing_vals));
- os->granule_vals=_ogg_malloc(os->lacing_storage*sizeof(*os->granule_vals));
-
- if(!os->body_data || !os->lacing_vals || !os->granule_vals){
- ogg_stream_clear(os);
- return -1;
- }
-
- os->serialno=serialno;
-
- return(0);
- }
- return(-1);
-}
-
-/* async/delayed error detection for the ogg_stream_state */
-int ogg_stream_check(ogg_stream_state *os){
- if(!os || !os->body_data) return -1;
- return 0;
-}
-
-/* _clear does not free os, only the non-flat storage within */
-int ogg_stream_clear(ogg_stream_state *os){
- if(os){
- if(os->body_data)_ogg_free(os->body_data);
- if(os->lacing_vals)_ogg_free(os->lacing_vals);
- if(os->granule_vals)_ogg_free(os->granule_vals);
-
- memset(os,0,sizeof(*os));
- }
- return(0);
-}
-
-int ogg_stream_destroy(ogg_stream_state *os){
- if(os){
- ogg_stream_clear(os);
- _ogg_free(os);
- }
- return(0);
-}
-
-/* Helpers for ogg_stream_encode; this keeps the structure and
- what's happening fairly clear */
-
-static int _os_body_expand(ogg_stream_state *os,int needed){
- if(os->body_storage<=os->body_fill+needed){
- void *ret;
- ret=_ogg_realloc(os->body_data,(os->body_storage+needed+1024)*
- sizeof(*os->body_data));
- if(!ret){
- ogg_stream_clear(os);
- return -1;
- }
- os->body_storage+=(needed+1024);
- os->body_data=ret;
- }
- return 0;
-}
-
-static int _os_lacing_expand(ogg_stream_state *os,int needed){
- if(os->lacing_storage<=os->lacing_fill+needed){
- void *ret;
- ret=_ogg_realloc(os->lacing_vals,(os->lacing_storage+needed+32)*
- sizeof(*os->lacing_vals));
- if(!ret){
- ogg_stream_clear(os);
- return -1;
- }
- os->lacing_vals=ret;
- ret=_ogg_realloc(os->granule_vals,(os->lacing_storage+needed+32)*
- sizeof(*os->granule_vals));
- if(!ret){
- ogg_stream_clear(os);
- return -1;
- }
- os->granule_vals=ret;
- os->lacing_storage+=(needed+32);
- }
- return 0;
-}
-
-/* checksum the page */
-/* Direct table CRC; note that this will be faster in the future if we
- perform the checksum simultaneously with other copies */
-
-void ogg_page_checksum_set(ogg_page *og){
- if(og){
- ogg_uint32_t crc_reg=0;
- int i;
-
- /* safety; needed for API behavior, but not framing code */
- og->header[22]=0;
- og->header[23]=0;
- og->header[24]=0;
- og->header[25]=0;
-
- for(i=0;i<og->header_len;i++)
- crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)&0xff)^og->header[i]];
- for(i=0;i<og->body_len;i++)
- crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)&0xff)^og->body[i]];
-
- og->header[22]=(unsigned char)(crc_reg&0xff);
- og->header[23]=(unsigned char)((crc_reg>>8)&0xff);
- og->header[24]=(unsigned char)((crc_reg>>16)&0xff);
- og->header[25]=(unsigned char)((crc_reg>>24)&0xff);
- }
-}
-
-/* submit data to the internal buffer of the framing engine */
-int ogg_stream_iovecin(ogg_stream_state *os, ogg_iovec_t *iov, int count,
- long e_o_s, ogg_int64_t granulepos){
-
- int bytes = 0, lacing_vals, i;
-
- if(ogg_stream_check(os)) return -1;
- if(!iov) return 0;
-
- for (i = 0; i < count; ++i) bytes += (int)iov[i].iov_len;
- lacing_vals=bytes/255+1;
-
- if(os->body_returned){
- /* advance packet data according to the body_returned pointer. We
- had to keep it around to return a pointer into the buffer last
- call */
-
- os->body_fill-=os->body_returned;
- if(os->body_fill)
- memmove(os->body_data,os->body_data+os->body_returned,
- os->body_fill);
- os->body_returned=0;
- }
-
- /* make sure we have the buffer storage */
- if(_os_body_expand(os,bytes) || _os_lacing_expand(os,lacing_vals))
- return -1;
-
- /* Copy in the submitted packet. Yes, the copy is a waste; this is
- the liability of overly clean abstraction for the time being. It
- will actually be fairly easy to eliminate the extra copy in the
- future */
-
- for (i = 0; i < count; ++i) {
- memcpy(os->body_data+os->body_fill, iov[i].iov_base, iov[i].iov_len);
- os->body_fill += (int)iov[i].iov_len;
- }
-
- /* Store lacing vals for this packet */
- for(i=0;i<lacing_vals-1;i++){
- os->lacing_vals[os->lacing_fill+i]=255;
- os->granule_vals[os->lacing_fill+i]=os->granulepos;
- }
- os->lacing_vals[os->lacing_fill+i]=bytes%255;
- os->granulepos=os->granule_vals[os->lacing_fill+i]=granulepos;
-
- /* flag the first segment as the beginning of the packet */
- os->lacing_vals[os->lacing_fill]|= 0x100;
-
- os->lacing_fill+=lacing_vals;
-
- /* for the sake of completeness */
- os->packetno++;
-
- if(e_o_s)os->e_o_s=1;
-
- return(0);
-}
-
-int ogg_stream_packetin(ogg_stream_state *os,ogg_packet *op){
- ogg_iovec_t iov;
- iov.iov_base = op->packet;
- iov.iov_len = op->bytes;
- return ogg_stream_iovecin(os, &iov, 1, op->e_o_s, op->granulepos);
-}
-
-/* Conditionally flush a page; force==0 will only flush nominal-size
- pages, force==1 forces us to flush a page regardless of page size
- so long as there's any data available at all. */
-static int ogg_stream_flush_i(ogg_stream_state *os,ogg_page *og, int force, int nfill){
- int i;
- int vals=0;
- int maxvals=(os->lacing_fill>255?255:os->lacing_fill);
- int bytes=0;
- long acc=0;
- ogg_int64_t granule_pos=-1;
-
- if(ogg_stream_check(os)) return(0);
- if(maxvals==0) return(0);
-
- /* construct a page */
- /* decide how many segments to include */
-
- /* If this is the initial header case, the first page must only include
- the initial header packet */
- if(os->b_o_s==0){ /* 'initial header page' case */
- granule_pos=0;
- for(vals=0;vals<maxvals;vals++){
- if((os->lacing_vals[vals]&0x0ff)<255){
- vals++;
- break;
- }
- }
- }else{
-
- /* The extra packets_done, packet_just_done logic here attempts to do two things:
- 1) Don't unneccessarily span pages.
- 2) Unless necessary, don't flush pages if there are less than four packets on
- them; this expands page size to reduce unneccessary overhead if incoming packets
- are large.
- These are not necessary behaviors, just 'always better than naive flushing'
- without requiring an application to explicitly request a specific optimized
- behavior. We'll want an explicit behavior setup pathway eventually as well. */
-
- int packets_done=0;
- int packet_just_done=0;
- for(vals=0;vals<maxvals;vals++){
- if(acc>nfill && packet_just_done>=4){
- force=1;
- break;
- }
- acc+=os->lacing_vals[vals]&0x0ff;
- if((os->lacing_vals[vals]&0xff)<255){
- granule_pos=os->granule_vals[vals];
- packet_just_done=++packets_done;
- }else
- packet_just_done=0;
- }
- if(vals==255)force=1;
- }
-
- if(!force) return(0);
-
- /* construct the header in temp storage */
- memcpy(os->header,"OggS",4);
-
- /* stream structure version */
- os->header[4]=0x00;
-
- /* continued packet flag? */
- os->header[5]=0x00;
- if((os->lacing_vals[0]&0x100)==0)os->header[5]|=0x01;
- /* first page flag? */
- if(os->b_o_s==0)os->header[5]|=0x02;
- /* last page flag? */
- if(os->e_o_s && os->lacing_fill==vals)os->header[5]|=0x04;
- os->b_o_s=1;
-
- /* 64 bits of PCM position */
- for(i=6;i<14;i++){
- os->header[i]=(unsigned char)(granule_pos&0xff);
- granule_pos>>=8;
- }
-
- /* 32 bits of stream serial number */
- {
- long serialno=os->serialno;
- for(i=14;i<18;i++){
- os->header[i]=(unsigned char)(serialno&0xff);
- serialno>>=8;
- }
- }
-
- /* 32 bits of page counter (we have both counter and page header
- because this val can roll over) */
- if(os->pageno==-1)os->pageno=0; /* because someone called
- stream_reset; this would be a
- strange thing to do in an
- encode stream, but it has
- plausible uses */
- {
- long pageno=os->pageno++;
- for(i=18;i<22;i++){
- os->header[i]=(unsigned char)(pageno&0xff);
- pageno>>=8;
- }
- }
-
- /* zero for computation; filled in later */
- os->header[22]=0;
- os->header[23]=0;
- os->header[24]=0;
- os->header[25]=0;
-
- /* segment table */
- os->header[26]=(unsigned char)(vals&0xff);
- for(i=0;i<vals;i++)
- bytes+=os->header[i+27]=(unsigned char)(os->lacing_vals[i]&0xff);
-
- /* set pointers in the ogg_page struct */
- og->header=os->header;
- og->header_len=os->header_fill=vals+27;
- og->body=os->body_data+os->body_returned;
- og->body_len=bytes;
-
- /* advance the lacing data and set the body_returned pointer */
-
- os->lacing_fill-=vals;
- memmove(os->lacing_vals,os->lacing_vals+vals,os->lacing_fill*sizeof(*os->lacing_vals));
- memmove(os->granule_vals,os->granule_vals+vals,os->lacing_fill*sizeof(*os->granule_vals));
- os->body_returned+=bytes;
-
- /* calculate the checksum */
-
- ogg_page_checksum_set(og);
-
- /* done */
- return(1);
-}
-
-/* This will flush remaining packets into a page (returning nonzero),
- even if there is not enough data to trigger a flush normally
- (undersized page). If there are no packets or partial packets to
- flush, ogg_stream_flush returns 0. Note that ogg_stream_flush will
- try to flush a normal sized page like ogg_stream_pageout; a call to
- ogg_stream_flush does not guarantee that all packets have flushed.
- Only a return value of 0 from ogg_stream_flush indicates all packet
- data is flushed into pages.
-
- since ogg_stream_flush will flush the last page in a stream even if
- it's undersized, you almost certainly want to use ogg_stream_pageout
- (and *not* ogg_stream_flush) unless you specifically need to flush
- a page regardless of size in the middle of a stream. */
-
-int ogg_stream_flush(ogg_stream_state *os,ogg_page *og){
- return ogg_stream_flush_i(os,og,1,4096);
-}
-
-/* Like the above, but an argument is provided to adjust the nominal
- page size for applications which are smart enough to provide their
- own delay based flushing */
-
-int ogg_stream_flush_fill(ogg_stream_state *os,ogg_page *og, int nfill){
- return ogg_stream_flush_i(os,og,1,nfill);
-}
-
-/* This constructs pages from buffered packet segments. The pointers
-returned are to static buffers; do not free. The returned buffers are
-good only until the next call (using the same ogg_stream_state) */
-
-int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og){
- int force=0;
- if(ogg_stream_check(os)) return 0;
-
- if((os->e_o_s&&os->lacing_fill) || /* 'were done, now flush' case */
- (os->lacing_fill&&!os->b_o_s)) /* 'initial header page' case */
- force=1;
-
- return(ogg_stream_flush_i(os,og,force,4096));
-}
-
-/* Like the above, but an argument is provided to adjust the nominal
-page size for applications which are smart enough to provide their
-own delay based flushing */
-
-int ogg_stream_pageout_fill(ogg_stream_state *os, ogg_page *og, int nfill){
- int force=0;
- if(ogg_stream_check(os)) return 0;
-
- if((os->e_o_s&&os->lacing_fill) || /* 'were done, now flush' case */
- (os->lacing_fill&&!os->b_o_s)) /* 'initial header page' case */
- force=1;
-
- return(ogg_stream_flush_i(os,og,force,nfill));
-}
-
-int ogg_stream_eos(ogg_stream_state *os){
- if(ogg_stream_check(os)) return 1;
- return os->e_o_s;
-}
-
-/* DECODING PRIMITIVES: packet streaming layer **********************/
-
-/* This has two layers to place more of the multi-serialno and paging
- control in the application's hands. First, we expose a data buffer
- using ogg_sync_buffer(). The app either copies into the
- buffer, or passes it directly to read(), etc. We then call
- ogg_sync_wrote() to tell how many bytes we just added.
-
- Pages are returned (pointers into the buffer in ogg_sync_state)
- by ogg_sync_pageout(). The page is then submitted to
- ogg_stream_pagein() along with the appropriate
- ogg_stream_state* (ie, matching serialno). We then get raw
- packets out calling ogg_stream_packetout() with a
- ogg_stream_state. */
-
-/* initialize the struct to a known state */
-int ogg_sync_init(ogg_sync_state *oy){
- if(oy){
- oy->storage = -1; /* used as a readiness flag */
- memset(oy,0,sizeof(*oy));
- }
- return(0);
-}
-
-/* clear non-flat storage within */
-int ogg_sync_clear(ogg_sync_state *oy){
- if(oy){
- if(oy->data)_ogg_free(oy->data);
- memset(oy,0,sizeof(*oy));
- }
- return(0);
-}
-
-int ogg_sync_destroy(ogg_sync_state *oy){
- if(oy){
- ogg_sync_clear(oy);
- _ogg_free(oy);
- }
- return(0);
-}
-
-int ogg_sync_check(ogg_sync_state *oy){
- if(oy->storage<0) return -1;
- return 0;
-}
-
-char *ogg_sync_buffer(ogg_sync_state *oy, long size){
- if(ogg_sync_check(oy)) return NULL;
-
- /* first, clear out any space that has been previously returned */
- if(oy->returned){
- oy->fill-=oy->returned;
- if(oy->fill>0)
- memmove(oy->data,oy->data+oy->returned,oy->fill);
- oy->returned=0;
- }
-
- if(size>oy->storage-oy->fill){
- /* We need to extend the internal buffer */
- long newsize=size+oy->fill+4096; /* an extra page to be nice */
- void *ret;
-
- if(oy->data)
- ret=_ogg_realloc(oy->data,newsize);
- else
- ret=_ogg_malloc(newsize);
- if(!ret){
- ogg_sync_clear(oy);
- return NULL;
- }
- oy->data=ret;
- oy->storage=newsize;
- }
-
- /* expose a segment at least as large as requested at the fill mark */
- return((char *)oy->data+oy->fill);
-}
-
-int ogg_sync_wrote(ogg_sync_state *oy, long bytes){
- if(ogg_sync_check(oy))return -1;
- if(oy->fill+bytes>oy->storage)return -1;
- oy->fill+=bytes;
- return(0);
-}
-
-/* sync the stream. This is meant to be useful for finding page
- boundaries.
-
- return values for this:
- -n) skipped n bytes
- 0) page not ready; more data (no bytes skipped)
- n) page synced at current location; page length n bytes
-
-*/
-
-long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og){
- unsigned char *page=oy->data+oy->returned;
- unsigned char *next;
- long bytes=oy->fill-oy->returned;
-
- if(ogg_sync_check(oy))return 0;
-
- if(oy->headerbytes==0){
- int headerbytes,i;
- if(bytes<27)return(0); /* not enough for a header */
-
- /* verify capture pattern */
- if(memcmp(page,"OggS",4))goto sync_fail;
-
- headerbytes=page[26]+27;
- if(bytes<headerbytes)return(0); /* not enough for header + seg table */
-
- /* count up body length in the segment table */
-
- for(i=0;i<page[26];i++)
- oy->bodybytes+=page[27+i];
- oy->headerbytes=headerbytes;
- }
-
- if(oy->bodybytes+oy->headerbytes>bytes)return(0);
-
- /* The whole test page is buffered. Verify the checksum */
- {
- /* Grab the checksum bytes, set the header field to zero */
- char chksum[4];
- ogg_page log;
-
- memcpy(chksum,page+22,4);
- memset(page+22,0,4);
-
- /* set up a temp page struct and recompute the checksum */
- log.header=page;
- log.header_len=oy->headerbytes;
- log.body=page+oy->headerbytes;
- log.body_len=oy->bodybytes;
- ogg_page_checksum_set(&log);
-
- /* Compare */
- if(memcmp(chksum,page+22,4)){
- /* D'oh. Mismatch! Corrupt page (or miscapture and not a page
- at all) */
- /* replace the computed checksum with the one actually read in */
- memcpy(page+22,chksum,4);
-
- /* Bad checksum. Lose sync */
- goto sync_fail;
- }
- }
-
- /* yes, have a whole page all ready to go */
- {
- unsigned char *page=oy->data+oy->returned;
- long bytes;
-
- if(og){
- og->header=page;
- og->header_len=oy->headerbytes;
- og->body=page+oy->headerbytes;
- og->body_len=oy->bodybytes;
- }
-
- oy->unsynced=0;
- oy->returned+=(bytes=oy->headerbytes+oy->bodybytes);
- oy->headerbytes=0;
- oy->bodybytes=0;
- return(bytes);
- }
-
- sync_fail:
-
- oy->headerbytes=0;
- oy->bodybytes=0;
-
- /* search for possible capture */
- next=memchr(page+1,'O',bytes-1);
- if(!next)
- next=oy->data+oy->fill;
-
- oy->returned=(int)(next-oy->data);
- return((long)-(next-page));
-}
-
-/* sync the stream and get a page. Keep trying until we find a page.
- Suppress 'sync errors' after reporting the first.
-
- return values:
- -1) recapture (hole in data)
- 0) need more data
- 1) page returned
-
- Returns pointers into buffered data; invalidated by next call to
- _stream, _clear, _init, or _buffer */
-
-int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og){
-
- if(ogg_sync_check(oy))return 0;
-
- /* all we need to do is verify a page at the head of the stream
- buffer. If it doesn't verify, we look for the next potential
- frame */
-
- for(;;){
- long ret=ogg_sync_pageseek(oy,og);
- if(ret>0){
- /* have a page */
- return(1);
- }
- if(ret==0){
- /* need more data */
- return(0);
- }
-
- /* head did not start a synced page... skipped some bytes */
- if(!oy->unsynced){
- oy->unsynced=1;
- return(-1);
- }
-
- /* loop. keep looking */
-
- }
-}
-
-/* add the incoming page to the stream state; we decompose the page
- into packet segments here as well. */
-
-int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og){
- unsigned char *header=og->header;
- unsigned char *body=og->body;
- long bodysize=og->body_len;
- int segptr=0;
-
- int version=ogg_page_version(og);
- int continued=ogg_page_continued(og);
- int bos=ogg_page_bos(og);
- int eos=ogg_page_eos(og);
- ogg_int64_t granulepos=ogg_page_granulepos(og);
- int serialno=ogg_page_serialno(og);
- long pageno=ogg_page_pageno(og);
- int segments=header[26];
-
- if(ogg_stream_check(os)) return -1;
-
- /* clean up 'returned data' */
- {
- long lr=os->lacing_returned;
- long br=os->body_returned;
-
- /* body data */
- if(br){
- os->body_fill-=br;
- if(os->body_fill)
- memmove(os->body_data,os->body_data+br,os->body_fill);
- os->body_returned=0;
- }
-
- if(lr){
- /* segment table */
- if(os->lacing_fill-lr){
- memmove(os->lacing_vals,os->lacing_vals+lr,
- (os->lacing_fill-lr)*sizeof(*os->lacing_vals));
- memmove(os->granule_vals,os->granule_vals+lr,
- (os->lacing_fill-lr)*sizeof(*os->granule_vals));
- }
- os->lacing_fill-=lr;
- os->lacing_packet-=lr;
- os->lacing_returned=0;
- }
- }
-
- /* check the serial number */
- if(serialno!=os->serialno)return(-1);
- if(version>0)return(-1);
-
- if(_os_lacing_expand(os,segments+1)) return -1;
-
- /* are we in sequence? */
- if(pageno!=os->pageno){
- int i;
-
- /* unroll previous partial packet (if any) */
- for(i=os->lacing_packet;i<os->lacing_fill;i++)
- os->body_fill-=os->lacing_vals[i]&0xff;
- os->lacing_fill=os->lacing_packet;
-
- /* make a note of dropped data in segment table */
- if(os->pageno!=-1){
- os->lacing_vals[os->lacing_fill++]=0x400;
- os->lacing_packet++;
- }
- }
-
- /* are we a 'continued packet' page? If so, we may need to skip
- some segments */
- if(continued){
- if(os->lacing_fill<1 ||
- os->lacing_vals[os->lacing_fill-1]==0x400){
- bos=0;
- for(;segptr<segments;segptr++){
- int val=header[27+segptr];
- body+=val;
- bodysize-=val;
- if(val<255){
- segptr++;
- break;
- }
- }
- }
- }
-
- if(bodysize){
- if(_os_body_expand(os,bodysize)) return -1;
- memcpy(os->body_data+os->body_fill,body,bodysize);
- os->body_fill+=bodysize;
- }
-
- {
- int saved=-1;
- while(segptr<segments){
- int val=header[27+segptr];
- os->lacing_vals[os->lacing_fill]=val;
- os->granule_vals[os->lacing_fill]=-1;
-
- if(bos){
- os->lacing_vals[os->lacing_fill]|=0x100;
- bos=0;
- }
-
- if(val<255)saved=os->lacing_fill;
-
- os->lacing_fill++;
- segptr++;
-
- if(val<255)os->lacing_packet=os->lacing_fill;
- }
-
- /* set the granulepos on the last granuleval of the last full packet */
- if(saved!=-1){
- os->granule_vals[saved]=granulepos;
- }
-
- }
-
- if(eos){
- os->e_o_s=1;
- if(os->lacing_fill>0)
- os->lacing_vals[os->lacing_fill-1]|=0x200;
- }
-
- os->pageno=pageno+1;
-
- return(0);
-}
-
-/* clear things to an initial state. Good to call, eg, before seeking */
-int ogg_sync_reset(ogg_sync_state *oy){
- if(ogg_sync_check(oy))return -1;
-
- oy->fill=0;
- oy->returned=0;
- oy->unsynced=0;
- oy->headerbytes=0;
- oy->bodybytes=0;
- return(0);
-}
-
-int ogg_stream_reset(ogg_stream_state *os){
- if(ogg_stream_check(os)) return -1;
-
- os->body_fill=0;
- os->body_returned=0;
-
- os->lacing_fill=0;
- os->lacing_packet=0;
- os->lacing_returned=0;
-
- os->header_fill=0;
-
- os->e_o_s=0;
- os->b_o_s=0;
- os->pageno=-1;
- os->packetno=0;
- os->granulepos=0;
-
- return(0);
-}
-
-int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno){
- if(ogg_stream_check(os)) return -1;
- ogg_stream_reset(os);
- os->serialno=serialno;
- return(0);
-}
-
-static int _packetout(ogg_stream_state *os,ogg_packet *op,int adv){
-
- /* The last part of decode. We have the stream broken into packet
- segments. Now we need to group them into packets (or return the
- out of sync markers) */
-
- int ptr=os->lacing_returned;
-
- if(os->lacing_packet<=ptr)return(0);
-
- if(os->lacing_vals[ptr]&0x400){
- /* we need to tell the codec there's a gap; it might need to
- handle previous packet dependencies. */
- os->lacing_returned++;
- os->packetno++;
- return(-1);
- }
-
- if(!op && !adv)return(1); /* just using peek as an inexpensive way
- to ask if there's a whole packet
- waiting */
-
- /* Gather the whole packet. We'll have no holes or a partial packet */
- {
- int size=os->lacing_vals[ptr]&0xff;
- long bytes=size;
- int eos=os->lacing_vals[ptr]&0x200; /* last packet of the stream? */
- int bos=os->lacing_vals[ptr]&0x100; /* first packet of the stream? */
-
- while(size==255){
- int val=os->lacing_vals[++ptr];
- size=val&0xff;
- if(val&0x200)eos=0x200;
- bytes+=size;
- }
-
- if(op){
- op->e_o_s=eos;
- op->b_o_s=bos;
- op->packet=os->body_data+os->body_returned;
- op->packetno=os->packetno;
- op->granulepos=os->granule_vals[ptr];
- op->bytes=bytes;
- }
-
- if(adv){
- os->body_returned+=bytes;
- os->lacing_returned=ptr+1;
- os->packetno++;
- }
- }
- return(1);
-}
-
-int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op){
- if(ogg_stream_check(os)) return 0;
- return _packetout(os,op,1);
-}
-
-int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op){
- if(ogg_stream_check(os)) return 0;
- return _packetout(os,op,0);
-}
-
-void ogg_packet_clear(ogg_packet *op) {
- _ogg_free(op->packet);
- memset(op, 0, sizeof(*op));
-}
-
-#ifdef _V_SELFTEST
-#include <stdio.h>
-
-ogg_stream_state os_en, os_de;
-ogg_sync_state oy;
-
-void checkpacket(ogg_packet *op,long len, int no, long pos){
- long j;
- static int sequence=0;
- static int lastno=0;
-
- if(op->bytes!=len){
- fprintf(stderr,"incorrect packet length (%ld != %ld)!\n",op->bytes,len);
- exit(1);
- }
- if(op->granulepos!=pos){
- fprintf(stderr,"incorrect packet granpos (%ld != %ld)!\n",(long)op->granulepos,pos);
- exit(1);
- }
-
- /* packet number just follows sequence/gap; adjust the input number
- for that */
- if(no==0){
- sequence=0;
- }else{
- sequence++;
- if(no>lastno+1)
- sequence++;
- }
- lastno=no;
- if(op->packetno!=sequence){
- fprintf(stderr,"incorrect packet sequence %ld != %d\n",
- (long)(op->packetno),sequence);
- exit(1);
- }
-
- /* Test data */
- for(j=0;j<op->bytes;j++)
- if(op->packet[j]!=((j+no)&0xff)){
- fprintf(stderr,"body data mismatch (1) at pos %ld: %x!=%lx!\n\n",
- j,op->packet[j],(j+no)&0xff);
- exit(1);
- }
-}
-
-void check_page(unsigned char *data,const int *header,ogg_page *og){
- long j;
- /* Test data */
- for(j=0;j<og->body_len;j++)
- if(og->body[j]!=data[j]){
- fprintf(stderr,"body data mismatch (2) at pos %ld: %x!=%x!\n\n",
- j,data[j],og->body[j]);
- exit(1);
- }
-
- /* Test header */
- for(j=0;j<og->header_len;j++){
- if(og->header[j]!=header[j]){
- fprintf(stderr,"header content mismatch at pos %ld:\n",j);
- for(j=0;j<header[26]+27;j++)
- fprintf(stderr," (%ld)%02x:%02x",j,header[j],og->header[j]);
- fprintf(stderr,"\n");
- exit(1);
- }
- }
- if(og->header_len!=header[26]+27){
- fprintf(stderr,"header length incorrect! (%ld!=%d)\n",
- og->header_len,header[26]+27);
- exit(1);
- }
-}
-
-void print_header(ogg_page *og){
- int j;
- fprintf(stderr,"\nHEADER:\n");
- fprintf(stderr," capture: %c %c %c %c version: %d flags: %x\n",
- og->header[0],og->header[1],og->header[2],og->header[3],
- (int)og->header[4],(int)og->header[5]);
-
- fprintf(stderr," granulepos: %d serialno: %d pageno: %ld\n",
- (og->header[9]<<24)|(og->header[8]<<16)|
- (og->header[7]<<8)|og->header[6],
- (og->header[17]<<24)|(og->header[16]<<16)|
- (og->header[15]<<8)|og->header[14],
- ((long)(og->header[21])<<24)|(og->header[20]<<16)|
- (og->header[19]<<8)|og->header[18]);
-
- fprintf(stderr," checksum: %02x:%02x:%02x:%02x\n segments: %d (",
- (int)og->header[22],(int)og->header[23],
- (int)og->header[24],(int)og->header[25],
- (int)og->header[26]);
-
- for(j=27;j<og->header_len;j++)
- fprintf(stderr,"%d ",(int)og->header[j]);
- fprintf(stderr,")\n\n");
-}
-
-void copy_page(ogg_page *og){
- unsigned char *temp=_ogg_malloc(og->header_len);
- memcpy(temp,og->header,og->header_len);
- og->header=temp;
-
- temp=_ogg_malloc(og->body_len);
- memcpy(temp,og->body,og->body_len);
- og->body=temp;
-}
-
-void free_page(ogg_page *og){
- _ogg_free (og->header);
- _ogg_free (og->body);
-}
-
-void error(void){
- fprintf(stderr,"error!\n");
- exit(1);
-}
-
-/* 17 only */
-const int head1_0[] = {0x4f,0x67,0x67,0x53,0,0x06,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,0,0,0,0,
- 0x15,0xed,0xec,0x91,
- 1,
- 17};
-
-/* 17, 254, 255, 256, 500, 510, 600 byte, pad */
-const int head1_1[] = {0x4f,0x67,0x67,0x53,0,0x02,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,0,0,0,0,
- 0x59,0x10,0x6c,0x2c,
- 1,
- 17};
-const int head2_1[] = {0x4f,0x67,0x67,0x53,0,0x04,
- 0x07,0x18,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,1,0,0,0,
- 0x89,0x33,0x85,0xce,
- 13,
- 254,255,0,255,1,255,245,255,255,0,
- 255,255,90};
-
-/* nil packets; beginning,middle,end */
-const int head1_2[] = {0x4f,0x67,0x67,0x53,0,0x02,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,0,0,0,0,
- 0xff,0x7b,0x23,0x17,
- 1,
- 0};
-const int head2_2[] = {0x4f,0x67,0x67,0x53,0,0x04,
- 0x07,0x28,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,1,0,0,0,
- 0x5c,0x3f,0x66,0xcb,
- 17,
- 17,254,255,0,0,255,1,0,255,245,255,255,0,
- 255,255,90,0};
-
-/* large initial packet */
-const int head1_3[] = {0x4f,0x67,0x67,0x53,0,0x02,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,0,0,0,0,
- 0x01,0x27,0x31,0xaa,
- 18,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255,10};
-
-const int head2_3[] = {0x4f,0x67,0x67,0x53,0,0x04,
- 0x07,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,1,0,0,0,
- 0x7f,0x4e,0x8a,0xd2,
- 4,
- 255,4,255,0};
-
-
-/* continuing packet test */
-const int head1_4[] = {0x4f,0x67,0x67,0x53,0,0x02,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,0,0,0,0,
- 0xff,0x7b,0x23,0x17,
- 1,
- 0};
-
-const int head2_4[] = {0x4f,0x67,0x67,0x53,0,0x00,
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 0x01,0x02,0x03,0x04,1,0,0,0,
- 0xf8,0x3c,0x19,0x79,
- 255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255};
-
-const int head3_4[] = {0x4f,0x67,0x67,0x53,0,0x05,
- 0x07,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,2,0,0,0,
- 0x38,0xe6,0xb6,0x28,
- 6,
- 255,220,255,4,255,0};
-
-
-/* spill expansion test */
-const int head1_4b[] = {0x4f,0x67,0x67,0x53,0,0x02,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,0,0,0,0,
- 0xff,0x7b,0x23,0x17,
- 1,
- 0};
-
-const int head2_4b[] = {0x4f,0x67,0x67,0x53,0,0x00,
- 0x07,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,1,0,0,0,
- 0xce,0x8f,0x17,0x1a,
- 23,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,255,10,255,4,255,0,0};
-
-
-const int head3_4b[] = {0x4f,0x67,0x67,0x53,0,0x04,
- 0x07,0x14,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,2,0,0,0,
- 0x9b,0xb2,0x50,0xa1,
- 1,
- 0};
-
-/* page with the 255 segment limit */
-const int head1_5[] = {0x4f,0x67,0x67,0x53,0,0x02,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,0,0,0,0,
- 0xff,0x7b,0x23,0x17,
- 1,
- 0};
-
-const int head2_5[] = {0x4f,0x67,0x67,0x53,0,0x00,
- 0x07,0xfc,0x03,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,1,0,0,0,
- 0xed,0x2a,0x2e,0xa7,
- 255,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10};
-
-const int head3_5[] = {0x4f,0x67,0x67,0x53,0,0x04,
- 0x07,0x00,0x04,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,2,0,0,0,
- 0x6c,0x3b,0x82,0x3d,
- 1,
- 50};
-
-
-/* packet that overspans over an entire page */
-const int head1_6[] = {0x4f,0x67,0x67,0x53,0,0x02,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,0,0,0,0,
- 0xff,0x7b,0x23,0x17,
- 1,
- 0};
-
-const int head2_6[] = {0x4f,0x67,0x67,0x53,0,0x00,
- 0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,1,0,0,0,
- 0x68,0x22,0x7c,0x3d,
- 255,
- 100,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255};
-
-const int head3_6[] = {0x4f,0x67,0x67,0x53,0,0x01,
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
- 0x01,0x02,0x03,0x04,2,0,0,0,
- 0xf4,0x87,0xba,0xf3,
- 255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255};
-
-const int head4_6[] = {0x4f,0x67,0x67,0x53,0,0x05,
- 0x07,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,3,0,0,0,
- 0xf7,0x2f,0x6c,0x60,
- 5,
- 254,255,4,255,0};
-
-/* packet that overspans over an entire page */
-const int head1_7[] = {0x4f,0x67,0x67,0x53,0,0x02,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,0,0,0,0,
- 0xff,0x7b,0x23,0x17,
- 1,
- 0};
-
-const int head2_7[] = {0x4f,0x67,0x67,0x53,0,0x00,
- 0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,1,0,0,0,
- 0x68,0x22,0x7c,0x3d,
- 255,
- 100,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255,255,255,
- 255,255,255,255,255,255};
-
-const int head3_7[] = {0x4f,0x67,0x67,0x53,0,0x05,
- 0x07,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0x02,0x03,0x04,2,0,0,0,
- 0xd4,0xe0,0x60,0xe5,
- 1,
- 0};
-
-void test_pack(const int *pl, const int **headers, int byteskip,
- int pageskip, int packetskip){
- unsigned char *data=_ogg_malloc(1024*1024); /* for scripted test cases only */
- long inptr=0;
- long outptr=0;
- long deptr=0;
- long depacket=0;
- long granule_pos=7,pageno=0;
- int i,j,packets,pageout=pageskip;
- int eosflag=0;
- int bosflag=0;
-
- int byteskipcount=0;
-
- ogg_stream_reset(&os_en);
- ogg_stream_reset(&os_de);
- ogg_sync_reset(&oy);
-
- for(packets=0;packets<packetskip;packets++)
- depacket+=pl[packets];
-
- for(packets=0;;packets++)if(pl[packets]==-1)break;
-
- for(i=0;i<packets;i++){
- /* construct a test packet */
- ogg_packet op;
- int len=pl[i];
-
- op.packet=data+inptr;
- op.bytes=len;
- op.e_o_s=(pl[i+1]<0?1:0);
- op.granulepos=granule_pos;
-
- granule_pos+=1024;
-
- for(j=0;j<len;j++)data[inptr++]=i+j;
-
- /* submit the test packet */
- ogg_stream_packetin(&os_en,&op);
-
- /* retrieve any finished pages */
- {
- ogg_page og;
-
- while(ogg_stream_pageout(&os_en,&og)){
- /* We have a page. Check it carefully */
-
- fprintf(stderr,"%ld, ",pageno);
-
- if(headers[pageno]==NULL){
- fprintf(stderr,"coded too many pages!\n");
- exit(1);
- }
-
- check_page(data+outptr,headers[pageno],&og);
-
- outptr+=og.body_len;
- pageno++;
- if(pageskip){
- bosflag=1;
- pageskip--;
- deptr+=og.body_len;
- }
-
- /* have a complete page; submit it to sync/decode */
-
- {
- ogg_page og_de;
- ogg_packet op_de,op_de2;
- char *buf=ogg_sync_buffer(&oy,og.header_len+og.body_len);
- char *next=buf;
- byteskipcount+=og.header_len;
- if(byteskipcount>byteskip){
- memcpy(next,og.header,byteskipcount-byteskip);
- next+=byteskipcount-byteskip;
- byteskipcount=byteskip;
- }
-
- byteskipcount+=og.body_len;
- if(byteskipcount>byteskip){
- memcpy(next,og.body,byteskipcount-byteskip);
- next+=byteskipcount-byteskip;
- byteskipcount=byteskip;
- }
-
- ogg_sync_wrote(&oy,next-buf);
-
- while(1){
- int ret=ogg_sync_pageout(&oy,&og_de);
- if(ret==0)break;
- if(ret<0)continue;
- /* got a page. Happy happy. Verify that it's good. */
-
- fprintf(stderr,"(%d), ",pageout);
-
- check_page(data+deptr,headers[pageout],&og_de);
- deptr+=og_de.body_len;
- pageout++;
-
- /* submit it to deconstitution */
- ogg_stream_pagein(&os_de,&og_de);
-
- /* packets out? */
- while(ogg_stream_packetpeek(&os_de,&op_de2)>0){
- ogg_stream_packetpeek(&os_de,NULL);
- ogg_stream_packetout(&os_de,&op_de); /* just catching them all */
-
- /* verify peek and out match */
- if(memcmp(&op_de,&op_de2,sizeof(op_de))){
- fprintf(stderr,"packetout != packetpeek! pos=%ld\n",
- depacket);
- exit(1);
- }
-
- /* verify the packet! */
- /* check data */
- if(memcmp(data+depacket,op_de.packet,op_de.bytes)){
- fprintf(stderr,"packet data mismatch in decode! pos=%ld\n",
- depacket);
- exit(1);
- }
- /* check bos flag */
- if(bosflag==0 && op_de.b_o_s==0){
- fprintf(stderr,"b_o_s flag not set on packet!\n");
- exit(1);
- }
- if(bosflag && op_de.b_o_s){
- fprintf(stderr,"b_o_s flag incorrectly set on packet!\n");
- exit(1);
- }
- bosflag=1;
- depacket+=op_de.bytes;
-
- /* check eos flag */
- if(eosflag){
- fprintf(stderr,"Multiple decoded packets with eos flag!\n");
- exit(1);
- }
-
- if(op_de.e_o_s)eosflag=1;
-
- /* check granulepos flag */
- if(op_de.granulepos!=-1){
- fprintf(stderr," granule:%ld ",(long)op_de.granulepos);
- }
- }
- }
- }
- }
- }
- }
- _ogg_free(data);
- if(headers[pageno]!=NULL){
- fprintf(stderr,"did not write last page!\n");
- exit(1);
- }
- if(headers[pageout]!=NULL){
- fprintf(stderr,"did not decode last page!\n");
- exit(1);
- }
- if(inptr!=outptr){
- fprintf(stderr,"encoded page data incomplete!\n");
- exit(1);
- }
- if(inptr!=deptr){
- fprintf(stderr,"decoded page data incomplete!\n");
- exit(1);
- }
- if(inptr!=depacket){
- fprintf(stderr,"decoded packet data incomplete!\n");
- exit(1);
- }
- if(!eosflag){
- fprintf(stderr,"Never got a packet with EOS set!\n");
- exit(1);
- }
- fprintf(stderr,"ok.\n");
-}
-
-int main(void){
-
- ogg_stream_init(&os_en,0x04030201);
- ogg_stream_init(&os_de,0x04030201);
- ogg_sync_init(&oy);
-
- /* Exercise each code path in the framing code. Also verify that
- the checksums are working. */
-
- {
- /* 17 only */
- const int packets[]={17, -1};
- const int *headret[]={head1_0,NULL};
-
- fprintf(stderr,"testing single page encoding... ");
- test_pack(packets,headret,0,0,0);
- }
-
- {
- /* 17, 254, 255, 256, 500, 510, 600 byte, pad */
- const int packets[]={17, 254, 255, 256, 500, 510, 600, -1};
- const int *headret[]={head1_1,head2_1,NULL};
-
- fprintf(stderr,"testing basic page encoding... ");
- test_pack(packets,headret,0,0,0);
- }
-
- {
- /* nil packets; beginning,middle,end */
- const int packets[]={0,17, 254, 255, 0, 256, 0, 500, 510, 600, 0, -1};
- const int *headret[]={head1_2,head2_2,NULL};
-
- fprintf(stderr,"testing basic nil packets... ");
- test_pack(packets,headret,0,0,0);
- }
-
- {
- /* large initial packet */
- const int packets[]={4345,259,255,-1};
- const int *headret[]={head1_3,head2_3,NULL};
-
- fprintf(stderr,"testing initial-packet lacing > 4k... ");
- test_pack(packets,headret,0,0,0);
- }
-
- {
- /* continuing packet test; with page spill expansion, we have to
- overflow the lacing table. */
- const int packets[]={0,65500,259,255,-1};
- const int *headret[]={head1_4,head2_4,head3_4,NULL};
-
- fprintf(stderr,"testing single packet page span... ");
- test_pack(packets,headret,0,0,0);
- }
-
- {
- /* spill expand packet test */
- const int packets[]={0,4345,259,255,0,0,-1};
- const int *headret[]={head1_4b,head2_4b,head3_4b,NULL};
-
- fprintf(stderr,"testing page spill expansion... ");
- test_pack(packets,headret,0,0,0);
- }
-
- /* page with the 255 segment limit */
- {
-
- const int packets[]={0,10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,10,
- 10,10,10,10,10,10,10,50,-1};
- const int *headret[]={head1_5,head2_5,head3_5,NULL};
-
- fprintf(stderr,"testing max packet segments... ");
- test_pack(packets,headret,0,0,0);
- }
-
- {
- /* packet that overspans over an entire page */
- const int packets[]={0,100,130049,259,255,-1};
- const int *headret[]={head1_6,head2_6,head3_6,head4_6,NULL};
-
- fprintf(stderr,"testing very large packets... ");
- test_pack(packets,headret,0,0,0);
- }
-
- {
- /* test for the libogg 1.1.1 resync in large continuation bug
- found by Josh Coalson) */
- const int packets[]={0,100,130049,259,255,-1};
- const int *headret[]={head1_6,head2_6,head3_6,head4_6,NULL};
-
- fprintf(stderr,"testing continuation resync in very large packets... ");
- test_pack(packets,headret,100,2,3);
- }
-
- {
- /* term only page. why not? */
- const int packets[]={0,100,64770,-1};
- const int *headret[]={head1_7,head2_7,head3_7,NULL};
-
- fprintf(stderr,"testing zero data page (1 nil packet)... ");
- test_pack(packets,headret,0,0,0);
- }
-
-
-
- {
- /* build a bunch of pages for testing */
- unsigned char *data=_ogg_malloc(1024*1024);
- int pl[]={0, 1,1,98,4079, 1,1,2954,2057, 76,34,912,0,234,1000,1000, 1000,300,-1};
- int inptr=0,i,j;
- ogg_page og[5];
-
- ogg_stream_reset(&os_en);
-
- for(i=0;pl[i]!=-1;i++){
- ogg_packet op;
- int len=pl[i];
-
- op.packet=data+inptr;
- op.bytes=len;
- op.e_o_s=(pl[i+1]<0?1:0);
- op.granulepos=(i+1)*1000;
-
- for(j=0;j<len;j++)data[inptr++]=i+j;
- ogg_stream_packetin(&os_en,&op);
- }
-
- _ogg_free(data);
-
- /* retrieve finished pages */
- for(i=0;i<5;i++){
- if(ogg_stream_pageout(&os_en,&og[i])==0){
- fprintf(stderr,"Too few pages output building sync tests!\n");
- exit(1);
- }
- copy_page(&og[i]);
- }
-
- /* Test lost pages on pagein/packetout: no rollback */
- {
- ogg_page temp;
- ogg_packet test;
-
- fprintf(stderr,"Testing loss of pages... ");
-
- ogg_sync_reset(&oy);
- ogg_stream_reset(&os_de);
- for(i=0;i<5;i++){
- memcpy(ogg_sync_buffer(&oy,og[i].header_len),og[i].header,
- og[i].header_len);
- ogg_sync_wrote(&oy,og[i].header_len);
- memcpy(ogg_sync_buffer(&oy,og[i].body_len),og[i].body,og[i].body_len);
- ogg_sync_wrote(&oy,og[i].body_len);
- }
-
- ogg_sync_pageout(&oy,&temp);
- ogg_stream_pagein(&os_de,&temp);
- ogg_sync_pageout(&oy,&temp);
- ogg_stream_pagein(&os_de,&temp);
- ogg_sync_pageout(&oy,&temp);
- /* skip */
- ogg_sync_pageout(&oy,&temp);
- ogg_stream_pagein(&os_de,&temp);
-
- /* do we get the expected results/packets? */
-
- if(ogg_stream_packetout(&os_de,&test)!=1)error();
- checkpacket(&test,0,0,0);
- if(ogg_stream_packetout(&os_de,&test)!=1)error();
- checkpacket(&test,1,1,-1);
- if(ogg_stream_packetout(&os_de,&test)!=1)error();
- checkpacket(&test,1,2,-1);
- if(ogg_stream_packetout(&os_de,&test)!=1)error();
- checkpacket(&test,98,3,-1);
- if(ogg_stream_packetout(&os_de,&test)!=1)error();
- checkpacket(&test,4079,4,5000);
- if(ogg_stream_packetout(&os_de,&test)!=-1){
- fprintf(stderr,"Error: loss of page did not return error\n");
- exit(1);
- }
- if(ogg_stream_packetout(&os_de,&test)!=1)error();
- checkpacket(&test,76,9,-1);
- if(ogg_stream_packetout(&os_de,&test)!=1)error();
- checkpacket(&test,34,10,-1);
- fprintf(stderr,"ok.\n");
- }
-
- /* Test lost pages on pagein/packetout: rollback with continuation */
- {
- ogg_page temp;
- ogg_packet test;
-
- fprintf(stderr,"Testing loss of pages (rollback required)... ");
-
- ogg_sync_reset(&oy);
- ogg_stream_reset(&os_de);
- for(i=0;i<5;i++){
- memcpy(ogg_sync_buffer(&oy,og[i].header_len),og[i].header,
- og[i].header_len);
- ogg_sync_wrote(&oy,og[i].header_len);
- memcpy(ogg_sync_buffer(&oy,og[i].body_len),og[i].body,og[i].body_len);
- ogg_sync_wrote(&oy,og[i].body_len);
- }
-
- ogg_sync_pageout(&oy,&temp);
- ogg_stream_pagein(&os_de,&temp);
- ogg_sync_pageout(&oy,&temp);
- ogg_stream_pagein(&os_de,&temp);
- ogg_sync_pageout(&oy,&temp);
- ogg_stream_pagein(&os_de,&temp);
- ogg_sync_pageout(&oy,&temp);
- /* skip */
- ogg_sync_pageout(&oy,&temp);
- ogg_stream_pagein(&os_de,&temp);
-
- /* do we get the expected results/packets? */
-
- if(ogg_stream_packetout(&os_de,&test)!=1)error();
- checkpacket(&test,0,0,0);
- if(ogg_stream_packetout(&os_de,&test)!=1)error();
- checkpacket(&test,1,1,-1);
- if(ogg_stream_packetout(&os_de,&test)!=1)error();
- checkpacket(&test,1,2,-1);
- if(ogg_stream_packetout(&os_de,&test)!=1)error();
- checkpacket(&test,98,3,-1);
- if(ogg_stream_packetout(&os_de,&test)!=1)error();
- checkpacket(&test,4079,4,5000);
- if(ogg_stream_packetout(&os_de,&test)!=1)error();
- checkpacket(&test,1,5,-1);
- if(ogg_stream_packetout(&os_de,&test)!=1)error();
- checkpacket(&test,1,6,-1);
- if(ogg_stream_packetout(&os_de,&test)!=1)error();
- checkpacket(&test,2954,7,-1);
- if(ogg_stream_packetout(&os_de,&test)!=1)error();
- checkpacket(&test,2057,8,9000);
- if(ogg_stream_packetout(&os_de,&test)!=-1){
- fprintf(stderr,"Error: loss of page did not return error\n");
- exit(1);
- }
- if(ogg_stream_packetout(&os_de,&test)!=1)error();
- checkpacket(&test,300,17,18000);
- fprintf(stderr,"ok.\n");
- }
-
- /* the rest only test sync */
- {
- ogg_page og_de;
- /* Test fractional page inputs: incomplete capture */
- fprintf(stderr,"Testing sync on partial inputs... ");
- ogg_sync_reset(&oy);
- memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header,
- 3);
- ogg_sync_wrote(&oy,3);
- if(ogg_sync_pageout(&oy,&og_de)>0)error();
-
- /* Test fractional page inputs: incomplete fixed header */
- memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header+3,
- 20);
- ogg_sync_wrote(&oy,20);
- if(ogg_sync_pageout(&oy,&og_de)>0)error();
-
- /* Test fractional page inputs: incomplete header */
- memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header+23,
- 5);
- ogg_sync_wrote(&oy,5);
- if(ogg_sync_pageout(&oy,&og_de)>0)error();
-
- /* Test fractional page inputs: incomplete body */
-
- memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header+28,
- og[1].header_len-28);
- ogg_sync_wrote(&oy,og[1].header_len-28);
- if(ogg_sync_pageout(&oy,&og_de)>0)error();
-
- memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body,1000);
- ogg_sync_wrote(&oy,1000);
- if(ogg_sync_pageout(&oy,&og_de)>0)error();
-
- memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body+1000,
- og[1].body_len-1000);
- ogg_sync_wrote(&oy,og[1].body_len-1000);
- if(ogg_sync_pageout(&oy,&og_de)<=0)error();
-
- fprintf(stderr,"ok.\n");
- }
-
- /* Test fractional page inputs: page + incomplete capture */
- {
- ogg_page og_de;
- fprintf(stderr,"Testing sync on 1+partial inputs... ");
- ogg_sync_reset(&oy);
-
- memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header,
- og[1].header_len);
- ogg_sync_wrote(&oy,og[1].header_len);
-
- memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body,
- og[1].body_len);
- ogg_sync_wrote(&oy,og[1].body_len);
-
- memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header,
- 20);
- ogg_sync_wrote(&oy,20);
- if(ogg_sync_pageout(&oy,&og_de)<=0)error();
- if(ogg_sync_pageout(&oy,&og_de)>0)error();
-
- memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header+20,
- og[1].header_len-20);
- ogg_sync_wrote(&oy,og[1].header_len-20);
- memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body,
- og[1].body_len);
- ogg_sync_wrote(&oy,og[1].body_len);
- if(ogg_sync_pageout(&oy,&og_de)<=0)error();
-
- fprintf(stderr,"ok.\n");
- }
-
- /* Test recapture: garbage + page */
- {
- ogg_page og_de;
- fprintf(stderr,"Testing search for capture... ");
- ogg_sync_reset(&oy);
-
- /* 'garbage' */
- memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body,
- og[1].body_len);
- ogg_sync_wrote(&oy,og[1].body_len);
-
- memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header,
- og[1].header_len);
- ogg_sync_wrote(&oy,og[1].header_len);
-
- memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body,
- og[1].body_len);
- ogg_sync_wrote(&oy,og[1].body_len);
-
- memcpy(ogg_sync_buffer(&oy,og[2].header_len),og[2].header,
- 20);
- ogg_sync_wrote(&oy,20);
- if(ogg_sync_pageout(&oy,&og_de)>0)error();
- if(ogg_sync_pageout(&oy,&og_de)<=0)error();
- if(ogg_sync_pageout(&oy,&og_de)>0)error();
-
- memcpy(ogg_sync_buffer(&oy,og[2].header_len),og[2].header+20,
- og[2].header_len-20);
- ogg_sync_wrote(&oy,og[2].header_len-20);
- memcpy(ogg_sync_buffer(&oy,og[2].body_len),og[2].body,
- og[2].body_len);
- ogg_sync_wrote(&oy,og[2].body_len);
- if(ogg_sync_pageout(&oy,&og_de)<=0)error();
-
- fprintf(stderr,"ok.\n");
- }
-
- /* Test recapture: page + garbage + page */
- {
- ogg_page og_de;
- fprintf(stderr,"Testing recapture... ");
- ogg_sync_reset(&oy);
-
- memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header,
- og[1].header_len);
- ogg_sync_wrote(&oy,og[1].header_len);
-
- memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body,
- og[1].body_len);
- ogg_sync_wrote(&oy,og[1].body_len);
-
- memcpy(ogg_sync_buffer(&oy,og[2].header_len),og[2].header,
- og[2].header_len);
- ogg_sync_wrote(&oy,og[2].header_len);
-
- memcpy(ogg_sync_buffer(&oy,og[2].header_len),og[2].header,
- og[2].header_len);
- ogg_sync_wrote(&oy,og[2].header_len);
-
- if(ogg_sync_pageout(&oy,&og_de)<=0)error();
-
- memcpy(ogg_sync_buffer(&oy,og[2].body_len),og[2].body,
- og[2].body_len-5);
- ogg_sync_wrote(&oy,og[2].body_len-5);
-
- memcpy(ogg_sync_buffer(&oy,og[3].header_len),og[3].header,
- og[3].header_len);
- ogg_sync_wrote(&oy,og[3].header_len);
-
- memcpy(ogg_sync_buffer(&oy,og[3].body_len),og[3].body,
- og[3].body_len);
- ogg_sync_wrote(&oy,og[3].body_len);
-
- if(ogg_sync_pageout(&oy,&og_de)>0)error();
- if(ogg_sync_pageout(&oy,&og_de)<=0)error();
-
- fprintf(stderr,"ok.\n");
- }
-
- /* Free page data that was previously copied */
- {
- for(i=0;i<5;i++){
- free_page(&og[i]);
- }
- }
- }
-
- return(0);
-}
-
-#endif
diff --git a/src/thirdparty/libflac/src/libFLAC/bitmath.c b/src/thirdparty/libflac/src/libFLAC/bitmath.c
deleted file mode 100644
index 3415b9144..000000000
--- a/src/thirdparty/libflac/src/libFLAC/bitmath.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "private/bitmath.h"
-#include "FLAC/assert.h"
-
-/* An example of what FLAC__bitmath_ilog2() computes:
- *
- * ilog2( 0) = assertion failure
- * ilog2( 1) = 0
- * ilog2( 2) = 1
- * ilog2( 3) = 1
- * ilog2( 4) = 2
- * ilog2( 5) = 2
- * ilog2( 6) = 2
- * ilog2( 7) = 2
- * ilog2( 8) = 3
- * ilog2( 9) = 3
- * ilog2(10) = 3
- * ilog2(11) = 3
- * ilog2(12) = 3
- * ilog2(13) = 3
- * ilog2(14) = 3
- * ilog2(15) = 3
- * ilog2(16) = 4
- * ilog2(17) = 4
- * ilog2(18) = 4
- */
-unsigned FLAC__bitmath_ilog2(FLAC__uint32 v)
-{
- unsigned l = 0;
- FLAC__ASSERT(v > 0);
- while(v >>= 1)
- l++;
- return l;
-}
-
-unsigned FLAC__bitmath_ilog2_wide(FLAC__uint64 v)
-{
- unsigned l = 0;
- FLAC__ASSERT(v > 0);
- while(v >>= 1)
- l++;
- return l;
-}
-
-/* An example of what FLAC__bitmath_silog2() computes:
- *
- * silog2(-10) = 5
- * silog2(- 9) = 5
- * silog2(- 8) = 4
- * silog2(- 7) = 4
- * silog2(- 6) = 4
- * silog2(- 5) = 4
- * silog2(- 4) = 3
- * silog2(- 3) = 3
- * silog2(- 2) = 2
- * silog2(- 1) = 2
- * silog2( 0) = 0
- * silog2( 1) = 2
- * silog2( 2) = 3
- * silog2( 3) = 3
- * silog2( 4) = 4
- * silog2( 5) = 4
- * silog2( 6) = 4
- * silog2( 7) = 4
- * silog2( 8) = 5
- * silog2( 9) = 5
- * silog2( 10) = 5
- */
-unsigned FLAC__bitmath_silog2(int v)
-{
- while(1) {
- if(v == 0) {
- return 0;
- }
- else if(v > 0) {
- unsigned l = 0;
- while(v) {
- l++;
- v >>= 1;
- }
- return l+1;
- }
- else if(v == -1) {
- return 2;
- }
- else {
- v++;
- v = -v;
- }
- }
-}
-
-unsigned FLAC__bitmath_silog2_wide(FLAC__int64 v)
-{
- while(1) {
- if(v == 0) {
- return 0;
- }
- else if(v > 0) {
- unsigned l = 0;
- while(v) {
- l++;
- v >>= 1;
- }
- return l+1;
- }
- else if(v == -1) {
- return 2;
- }
- else {
- v++;
- v = -v;
- }
- }
-}
diff --git a/src/thirdparty/libflac/src/libFLAC/bitreader.c b/src/thirdparty/libflac/src/libFLAC/bitreader.c
deleted file mode 100644
index 1ba74314f..000000000
--- a/src/thirdparty/libflac/src/libFLAC/bitreader.c
+++ /dev/null
@@ -1,1383 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdlib.h> /* for malloc() */
-#include <string.h> /* for memcpy(), memset() */
-#ifdef _MSC_VER
-# include <winsock.h> /* for ntohl() */
-# if _MSC_VER >= 1310
-# include <winsock2.h> /* for ntohl(), sometimes it is not in winsock.h */
-# endif
-#elif defined FLAC__SYS_DARWIN
-# include <machine/endian.h> /* for ntohl() */
-#elif defined __MINGW32__
-# include <winsock.h> /* for ntohl() */
-#else
-# include <netinet/in.h> /* for ntohl() */
-#endif
-#include "private/bitmath.h"
-#include "private/bitreader.h"
-#include "private/crc.h"
-#include "FLAC/assert.h"
-
-/* Things should be fastest when this matches the machine word size */
-/* WATCHOUT: if you change this you must also change the following #defines down to COUNT_ZERO_MSBS below to match */
-/* WATCHOUT: there are a few places where the code will not work unless brword is >= 32 bits wide */
-/* also, some sections currently only have fast versions for 4 or 8 bytes per word */
-typedef FLAC__uint32 brword;
-#define FLAC__BYTES_PER_WORD 4
-#define FLAC__BITS_PER_WORD 32
-#define FLAC__WORD_ALL_ONES ((FLAC__uint32)0xffffffff)
-/* SWAP_BE_WORD_TO_HOST swaps bytes in a brword (which is always big-endian) if necessary to match host byte order */
-#if WORDS_BIGENDIAN
-#define SWAP_BE_WORD_TO_HOST(x) (x)
-#else
-#ifdef _MSC_VER
-#define SWAP_BE_WORD_TO_HOST(x) local_swap32_(x)
-#else
-#define SWAP_BE_WORD_TO_HOST(x) ntohl(x)
-#endif
-#endif
-/* counts the # of zero MSBs in a word */
-#define COUNT_ZERO_MSBS(word) ( \
- (word) <= 0xffff ? \
- ( (word) <= 0xff? byte_to_unary_table[word] + 24 : byte_to_unary_table[(word) >> 8] + 16 ) : \
- ( (word) <= 0xffffff? byte_to_unary_table[word >> 16] + 8 : byte_to_unary_table[(word) >> 24] ) \
-)
-/* this alternate might be slightly faster on some systems/compilers: */
-#define COUNT_ZERO_MSBS2(word) ( (word) <= 0xff ? byte_to_unary_table[word] + 24 : ((word) <= 0xffff ? byte_to_unary_table[(word) >> 8] + 16 : ((word) <= 0xffffff ? byte_to_unary_table[(word) >> 16] + 8 : byte_to_unary_table[(word) >> 24])) )
-
-
-/*
- * This should be at least twice as large as the largest number of words
- * required to represent any 'number' (in any encoding) you are going to
- * read. With FLAC this is on the order of maybe a few hundred bits.
- * If the buffer is smaller than that, the decoder won't be able to read
- * in a whole number that is in a variable length encoding (e.g. Rice).
- * But to be practical it should be at least 1K bytes.
- *
- * Increase this number to decrease the number of read callbacks, at the
- * expense of using more memory. Or decrease for the reverse effect,
- * keeping in mind the limit from the first paragraph. The optimal size
- * also depends on the CPU cache size and other factors; some twiddling
- * may be necessary to squeeze out the best performance.
- */
-static const unsigned FLAC__BITREADER_DEFAULT_CAPACITY = 65536u / FLAC__BITS_PER_WORD; /* in words */
-
-static const unsigned char byte_to_unary_table[] = {
- 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 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,
- 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
-};
-
-#ifdef min
-#undef min
-#endif
-#define min(x,y) ((x)<(y)?(x):(y))
-#ifdef max
-#undef max
-#endif
-#define max(x,y) ((x)>(y)?(x):(y))
-
-/* adjust for compilers that can't understand using LLU suffix for uint64_t literals */
-#ifdef _MSC_VER
-#define FLAC__U64L(x) x
-#else
-#define FLAC__U64L(x) x##LLU
-#endif
-
-#ifndef FLaC__INLINE
-#define FLaC__INLINE
-#endif
-
-/* WATCHOUT: assembly routines rely on the order in which these fields are declared */
-struct FLAC__BitReader {
- /* any partially-consumed word at the head will stay right-justified as bits are consumed from the left */
- /* any incomplete word at the tail will be left-justified, and bytes from the read callback are added on the right */
- brword *buffer;
- unsigned capacity; /* in words */
- unsigned words; /* # of completed words in buffer */
- unsigned bytes; /* # of bytes in incomplete word at buffer[words] */
- unsigned consumed_words; /* #words ... */
- unsigned consumed_bits; /* ... + (#bits of head word) already consumed from the front of buffer */
- unsigned read_crc16; /* the running frame CRC */
- unsigned crc16_align; /* the number of bits in the current consumed word that should not be CRC'd */
- FLAC__BitReaderReadCallback read_callback;
- void *client_data;
- FLAC__CPUInfo cpu_info;
-};
-
-#ifdef _MSC_VER
-/* OPT: an MSVC built-in would be better */
-/* OPT: use _byteswap_ulong intrinsic? */
-static _inline FLAC__uint32 local_swap32_(FLAC__uint32 x)
-{
- x = ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
- return (x>>16) | (x<<16);
-}
-#ifdef _WIN64
-#else
-static void local_swap32_block_(FLAC__uint32 *start, FLAC__uint32 len)
-{
- __asm {
- mov edx, start
- mov ecx, len
- test ecx, ecx
-loop1:
- jz done1
- mov eax, [edx]
- bswap eax
- mov [edx], eax
- add edx, 4
- dec ecx
- jmp short loop1
-done1:
- }
-}
-#endif
-#endif
-
-static FLaC__INLINE void crc16_update_word_(FLAC__BitReader *br, brword word)
-{
- register unsigned crc = br->read_crc16;
-#if FLAC__BYTES_PER_WORD == 4
- switch(br->crc16_align) {
- case 0: crc = FLAC__CRC16_UPDATE((unsigned)(word >> 24), crc);
- case 8: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 16) & 0xff), crc);
- case 16: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 8) & 0xff), crc);
- case 24: br->read_crc16 = FLAC__CRC16_UPDATE((unsigned)(word & 0xff), crc);
- }
-#elif FLAC__BYTES_PER_WORD == 8
- switch(br->crc16_align) {
- case 0: crc = FLAC__CRC16_UPDATE((unsigned)(word >> 56), crc);
- case 8: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 48) & 0xff), crc);
- case 16: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 40) & 0xff), crc);
- case 24: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 32) & 0xff), crc);
- case 32: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 24) & 0xff), crc);
- case 40: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 16) & 0xff), crc);
- case 48: crc = FLAC__CRC16_UPDATE((unsigned)((word >> 8) & 0xff), crc);
- case 56: br->read_crc16 = FLAC__CRC16_UPDATE((unsigned)(word & 0xff), crc);
- }
-#else
- for( ; br->crc16_align < FLAC__BITS_PER_WORD; br->crc16_align += 8)
- crc = FLAC__CRC16_UPDATE((unsigned)((word >> (FLAC__BITS_PER_WORD-8-br->crc16_align)) & 0xff), crc);
- br->read_crc16 = crc;
-#endif
- br->crc16_align = 0;
-}
-
-/* would be static except it needs to be called by asm routines */
-FLAC__bool bitreader_read_from_client_(FLAC__BitReader *br)
-{
- unsigned start, end;
- size_t bytes;
- FLAC__byte *target;
-
- /* first shift the unconsumed buffer data toward the front as much as possible */
- if(br->consumed_words > 0) {
- start = br->consumed_words;
- end = br->words + (br->bytes? 1:0);
- memmove(br->buffer, br->buffer+start, FLAC__BYTES_PER_WORD * (end - start));
-
- br->words -= start;
- br->consumed_words = 0;
- }
-
- /*
- * set the target for reading, taking into account word alignment and endianness
- */
- bytes = (br->capacity - br->words) * FLAC__BYTES_PER_WORD - br->bytes;
- if(bytes == 0)
- return false; /* no space left, buffer is too small; see note for FLAC__BITREADER_DEFAULT_CAPACITY */
- target = ((FLAC__byte*)(br->buffer+br->words)) + br->bytes;
-
- /* before reading, if the existing reader looks like this (say brword is 32 bits wide)
- * bitstream : 11 22 33 44 55 br->words=1 br->bytes=1 (partial tail word is left-justified)
- * buffer[BE]: 11 22 33 44 55 ?? ?? ?? (shown layed out as bytes sequentially in memory)
- * buffer[LE]: 44 33 22 11 ?? ?? ?? 55 (?? being don't-care)
- * ^^-------target, bytes=3
- * on LE machines, have to byteswap the odd tail word so nothing is
- * overwritten:
- */
-#if WORDS_BIGENDIAN
-#else
- if(br->bytes)
- br->buffer[br->words] = SWAP_BE_WORD_TO_HOST(br->buffer[br->words]);
-#endif
-
- /* now it looks like:
- * bitstream : 11 22 33 44 55 br->words=1 br->bytes=1
- * buffer[BE]: 11 22 33 44 55 ?? ?? ??
- * buffer[LE]: 44 33 22 11 55 ?? ?? ??
- * ^^-------target, bytes=3
- */
-
- /* read in the data; note that the callback may return a smaller number of bytes */
- if(!br->read_callback(target, &bytes, br->client_data))
- return false;
-
- /* after reading bytes 66 77 88 99 AA BB CC DD EE FF from the client:
- * bitstream : 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF
- * buffer[BE]: 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF ??
- * buffer[LE]: 44 33 22 11 55 66 77 88 99 AA BB CC DD EE FF ??
- * now have to byteswap on LE machines:
- */
-#if WORDS_BIGENDIAN
-#else
- end = (br->words*FLAC__BYTES_PER_WORD + br->bytes + bytes + (FLAC__BYTES_PER_WORD-1)) / FLAC__BYTES_PER_WORD;
-# if defined(_MSC_VER) && !defined(_WIN64) && (FLAC__BYTES_PER_WORD == 4)
- if(br->cpu_info.type == FLAC__CPUINFO_TYPE_IA32 && br->cpu_info.data.ia32.bswap) {
- start = br->words;
- local_swap32_block_(br->buffer + start, end - start);
- }
- else
-# endif
- for(start = br->words; start < end; start++)
- br->buffer[start] = SWAP_BE_WORD_TO_HOST(br->buffer[start]);
-#endif
-
- /* now it looks like:
- * bitstream : 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF
- * buffer[BE]: 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF ??
- * buffer[LE]: 44 33 22 11 88 77 66 55 CC BB AA 99 ?? FF EE DD
- * finally we'll update the reader values:
- */
- end = br->words*FLAC__BYTES_PER_WORD + br->bytes + bytes;
- br->words = end / FLAC__BYTES_PER_WORD;
- br->bytes = end % FLAC__BYTES_PER_WORD;
-
- return true;
-}
-
-/***********************************************************************
- *
- * Class constructor/destructor
- *
- ***********************************************************************/
-
-FLAC__BitReader *FLAC__bitreader_new(void)
-{
- FLAC__BitReader *br = (FLAC__BitReader*)calloc(1, sizeof(FLAC__BitReader));
-
- /* calloc() implies:
- memset(br, 0, sizeof(FLAC__BitReader));
- br->buffer = 0;
- br->capacity = 0;
- br->words = br->bytes = 0;
- br->consumed_words = br->consumed_bits = 0;
- br->read_callback = 0;
- br->client_data = 0;
- */
- return br;
-}
-
-void FLAC__bitreader_delete(FLAC__BitReader *br)
-{
- FLAC__ASSERT(0 != br);
-
- FLAC__bitreader_free(br);
- free(br);
-}
-
-/***********************************************************************
- *
- * Public class methods
- *
- ***********************************************************************/
-
-FLAC__bool FLAC__bitreader_init(FLAC__BitReader *br, FLAC__CPUInfo cpu, FLAC__BitReaderReadCallback rcb, void *cd)
-{
- FLAC__ASSERT(0 != br);
-
- br->words = br->bytes = 0;
- br->consumed_words = br->consumed_bits = 0;
- br->capacity = FLAC__BITREADER_DEFAULT_CAPACITY;
- br->buffer = (brword*)malloc(sizeof(brword) * br->capacity);
- if(br->buffer == 0)
- return false;
- br->read_callback = rcb;
- br->client_data = cd;
- br->cpu_info = cpu;
-
- return true;
-}
-
-void FLAC__bitreader_free(FLAC__BitReader *br)
-{
- FLAC__ASSERT(0 != br);
-
- if(0 != br->buffer)
- free(br->buffer);
- br->buffer = 0;
- br->capacity = 0;
- br->words = br->bytes = 0;
- br->consumed_words = br->consumed_bits = 0;
- br->read_callback = 0;
- br->client_data = 0;
-}
-
-FLAC__bool FLAC__bitreader_clear(FLAC__BitReader *br)
-{
- br->words = br->bytes = 0;
- br->consumed_words = br->consumed_bits = 0;
- return true;
-}
-
-void FLAC__bitreader_dump(const FLAC__BitReader *br, FILE *out)
-{
- unsigned i, j;
- if(br == 0) {
- fprintf(out, "bitreader is NULL\n");
- }
- else {
- fprintf(out, "bitreader: capacity=%u words=%u bytes=%u consumed: words=%u, bits=%u\n", br->capacity, br->words, br->bytes, br->consumed_words, br->consumed_bits);
-
- for(i = 0; i < br->words; i++) {
- fprintf(out, "%08X: ", i);
- for(j = 0; j < FLAC__BITS_PER_WORD; j++)
- if(i < br->consumed_words || (i == br->consumed_words && j < br->consumed_bits))
- fprintf(out, ".");
- else
- fprintf(out, "%01u", br->buffer[i] & (1 << (FLAC__BITS_PER_WORD-j-1)) ? 1:0);
- fprintf(out, "\n");
- }
- if(br->bytes > 0) {
- fprintf(out, "%08X: ", i);
- for(j = 0; j < br->bytes*8; j++)
- if(i < br->consumed_words || (i == br->consumed_words && j < br->consumed_bits))
- fprintf(out, ".");
- else
- fprintf(out, "%01u", br->buffer[i] & (1 << (br->bytes*8-j-1)) ? 1:0);
- fprintf(out, "\n");
- }
- }
-}
-
-void FLAC__bitreader_reset_read_crc16(FLAC__BitReader *br, FLAC__uint16 seed)
-{
- FLAC__ASSERT(0 != br);
- FLAC__ASSERT(0 != br->buffer);
- FLAC__ASSERT((br->consumed_bits & 7) == 0);
-
- br->read_crc16 = (unsigned)seed;
- br->crc16_align = br->consumed_bits;
-}
-
-FLAC__uint16 FLAC__bitreader_get_read_crc16(FLAC__BitReader *br)
-{
- FLAC__ASSERT(0 != br);
- FLAC__ASSERT(0 != br->buffer);
- FLAC__ASSERT((br->consumed_bits & 7) == 0);
- FLAC__ASSERT(br->crc16_align <= br->consumed_bits);
-
- /* CRC any tail bytes in a partially-consumed word */
- if(br->consumed_bits) {
- const brword tail = br->buffer[br->consumed_words];
- for( ; br->crc16_align < br->consumed_bits; br->crc16_align += 8)
- br->read_crc16 = FLAC__CRC16_UPDATE((unsigned)((tail >> (FLAC__BITS_PER_WORD-8-br->crc16_align)) & 0xff), br->read_crc16);
- }
- return br->read_crc16;
-}
-
-FLaC__INLINE FLAC__bool FLAC__bitreader_is_consumed_byte_aligned(const FLAC__BitReader *br)
-{
- return ((br->consumed_bits & 7) == 0);
-}
-
-FLaC__INLINE unsigned FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br)
-{
- return 8 - (br->consumed_bits & 7);
-}
-
-FLaC__INLINE unsigned FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br)
-{
- return (br->words-br->consumed_words)*FLAC__BITS_PER_WORD + br->bytes*8 - br->consumed_bits;
-}
-
-FLaC__INLINE FLAC__bool FLAC__bitreader_read_raw_uint32(FLAC__BitReader *br, FLAC__uint32 *val, unsigned bits)
-{
- FLAC__ASSERT(0 != br);
- FLAC__ASSERT(0 != br->buffer);
-
- FLAC__ASSERT(bits <= 32);
- FLAC__ASSERT((br->capacity*FLAC__BITS_PER_WORD) * 2 >= bits);
- FLAC__ASSERT(br->consumed_words <= br->words);
-
- /* WATCHOUT: code does not work with <32bit words; we can make things much faster with this assertion */
- FLAC__ASSERT(FLAC__BITS_PER_WORD >= 32);
-
- if(bits == 0) { /* OPT: investigate if this can ever happen, maybe change to assertion */
- *val = 0;
- return true;
- }
-
- while((br->words-br->consumed_words)*FLAC__BITS_PER_WORD + br->bytes*8 - br->consumed_bits < bits) {
- if(!bitreader_read_from_client_(br))
- return false;
- }
- if(br->consumed_words < br->words) { /* if we've not consumed up to a partial tail word... */
- /* OPT: taking out the consumed_bits==0 "else" case below might make things faster if less code allows the compiler to inline this function */
- if(br->consumed_bits) {
- /* this also works when consumed_bits==0, it's just a little slower than necessary for that case */
- const unsigned n = FLAC__BITS_PER_WORD - br->consumed_bits;
- const brword word = br->buffer[br->consumed_words];
- if(bits < n) {
- *val = (word & (FLAC__WORD_ALL_ONES >> br->consumed_bits)) >> (n-bits);
- br->consumed_bits += bits;
- return true;
- }
- *val = word & (FLAC__WORD_ALL_ONES >> br->consumed_bits);
- bits -= n;
- crc16_update_word_(br, word);
- br->consumed_words++;
- br->consumed_bits = 0;
- if(bits) { /* if there are still bits left to read, there have to be less than 32 so they will all be in the next word */
- *val <<= bits;
- *val |= (br->buffer[br->consumed_words] >> (FLAC__BITS_PER_WORD-bits));
- br->consumed_bits = bits;
- }
- return true;
- }
- else {
- const brword word = br->buffer[br->consumed_words];
- if(bits < FLAC__BITS_PER_WORD) {
- *val = word >> (FLAC__BITS_PER_WORD-bits);
- br->consumed_bits = bits;
- return true;
- }
- /* at this point 'bits' must be == FLAC__BITS_PER_WORD; because of previous assertions, it can't be larger */
- *val = word;
- crc16_update_word_(br, word);
- br->consumed_words++;
- return true;
- }
- }
- else {
- /* in this case we're starting our read at a partial tail word;
- * the reader has guaranteed that we have at least 'bits' bits
- * available to read, which makes this case simpler.
- */
- /* OPT: taking out the consumed_bits==0 "else" case below might make things faster if less code allows the compiler to inline this function */
- if(br->consumed_bits) {
- /* this also works when consumed_bits==0, it's just a little slower than necessary for that case */
- FLAC__ASSERT(br->consumed_bits + bits <= br->bytes*8);
- *val = (br->buffer[br->consumed_words] & (FLAC__WORD_ALL_ONES >> br->consumed_bits)) >> (FLAC__BITS_PER_WORD-br->consumed_bits-bits);
- br->consumed_bits += bits;
- return true;
- }
- else {
- *val = br->buffer[br->consumed_words] >> (FLAC__BITS_PER_WORD-bits);
- br->consumed_bits += bits;
- return true;
- }
- }
-}
-
-FLAC__bool FLAC__bitreader_read_raw_int32(FLAC__BitReader *br, FLAC__int32 *val, unsigned bits)
-{
- /* OPT: inline raw uint32 code here, or make into a macro if possible in the .h file */
- if(!FLAC__bitreader_read_raw_uint32(br, (FLAC__uint32*)val, bits))
- return false;
- /* sign-extend: */
- *val <<= (32-bits);
- *val >>= (32-bits);
- return true;
-}
-
-FLAC__bool FLAC__bitreader_read_raw_uint64(FLAC__BitReader *br, FLAC__uint64 *val, unsigned bits)
-{
- FLAC__uint32 hi, lo;
-
- if(bits > 32) {
- if(!FLAC__bitreader_read_raw_uint32(br, &hi, bits-32))
- return false;
- if(!FLAC__bitreader_read_raw_uint32(br, &lo, 32))
- return false;
- *val = hi;
- *val <<= 32;
- *val |= lo;
- }
- else {
- if(!FLAC__bitreader_read_raw_uint32(br, &lo, bits))
- return false;
- *val = lo;
- }
- return true;
-}
-
-FLaC__INLINE FLAC__bool FLAC__bitreader_read_uint32_little_endian(FLAC__BitReader *br, FLAC__uint32 *val)
-{
- FLAC__uint32 x8, x32 = 0;
-
- /* this doesn't need to be that fast as currently it is only used for vorbis comments */
-
- if(!FLAC__bitreader_read_raw_uint32(br, &x32, 8))
- return false;
-
- if(!FLAC__bitreader_read_raw_uint32(br, &x8, 8))
- return false;
- x32 |= (x8 << 8);
-
- if(!FLAC__bitreader_read_raw_uint32(br, &x8, 8))
- return false;
- x32 |= (x8 << 16);
-
- if(!FLAC__bitreader_read_raw_uint32(br, &x8, 8))
- return false;
- x32 |= (x8 << 24);
-
- *val = x32;
- return true;
-}
-
-FLAC__bool FLAC__bitreader_skip_bits_no_crc(FLAC__BitReader *br, unsigned bits)
-{
- /*
- * OPT: a faster implementation is possible but probably not that useful
- * since this is only called a couple of times in the metadata readers.
- */
- FLAC__ASSERT(0 != br);
- FLAC__ASSERT(0 != br->buffer);
-
- if(bits > 0) {
- const unsigned n = br->consumed_bits & 7;
- unsigned m;
- FLAC__uint32 x;
-
- if(n != 0) {
- m = min(8-n, bits);
- if(!FLAC__bitreader_read_raw_uint32(br, &x, m))
- return false;
- bits -= m;
- }
- m = bits / 8;
- if(m > 0) {
- if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(br, m))
- return false;
- bits %= 8;
- }
- if(bits > 0) {
- if(!FLAC__bitreader_read_raw_uint32(br, &x, bits))
- return false;
- }
- }
-
- return true;
-}
-
-FLAC__bool FLAC__bitreader_skip_byte_block_aligned_no_crc(FLAC__BitReader *br, unsigned nvals)
-{
- FLAC__uint32 x;
-
- FLAC__ASSERT(0 != br);
- FLAC__ASSERT(0 != br->buffer);
- FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(br));
-
- /* step 1: skip over partial head word to get word aligned */
- while(nvals && br->consumed_bits) { /* i.e. run until we read 'nvals' bytes or we hit the end of the head word */
- if(!FLAC__bitreader_read_raw_uint32(br, &x, 8))
- return false;
- nvals--;
- }
- if(0 == nvals)
- return true;
- /* step 2: skip whole words in chunks */
- while(nvals >= FLAC__BYTES_PER_WORD) {
- if(br->consumed_words < br->words) {
- br->consumed_words++;
- nvals -= FLAC__BYTES_PER_WORD;
- }
- else if(!bitreader_read_from_client_(br))
- return false;
- }
- /* step 3: skip any remainder from partial tail bytes */
- while(nvals) {
- if(!FLAC__bitreader_read_raw_uint32(br, &x, 8))
- return false;
- nvals--;
- }
-
- return true;
-}
-
-FLAC__bool FLAC__bitreader_read_byte_block_aligned_no_crc(FLAC__BitReader *br, FLAC__byte *val, unsigned nvals)
-{
- FLAC__uint32 x;
-
- FLAC__ASSERT(0 != br);
- FLAC__ASSERT(0 != br->buffer);
- FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(br));
-
- /* step 1: read from partial head word to get word aligned */
- while(nvals && br->consumed_bits) { /* i.e. run until we read 'nvals' bytes or we hit the end of the head word */
- if(!FLAC__bitreader_read_raw_uint32(br, &x, 8))
- return false;
- *val++ = (FLAC__byte)x;
- nvals--;
- }
- if(0 == nvals)
- return true;
- /* step 2: read whole words in chunks */
- while(nvals >= FLAC__BYTES_PER_WORD) {
- if(br->consumed_words < br->words) {
- const brword word = br->buffer[br->consumed_words++];
-#if FLAC__BYTES_PER_WORD == 4
- val[0] = (FLAC__byte)(word >> 24);
- val[1] = (FLAC__byte)(word >> 16);
- val[2] = (FLAC__byte)(word >> 8);
- val[3] = (FLAC__byte)word;
-#elif FLAC__BYTES_PER_WORD == 8
- val[0] = (FLAC__byte)(word >> 56);
- val[1] = (FLAC__byte)(word >> 48);
- val[2] = (FLAC__byte)(word >> 40);
- val[3] = (FLAC__byte)(word >> 32);
- val[4] = (FLAC__byte)(word >> 24);
- val[5] = (FLAC__byte)(word >> 16);
- val[6] = (FLAC__byte)(word >> 8);
- val[7] = (FLAC__byte)word;
-#else
- for(x = 0; x < FLAC__BYTES_PER_WORD; x++)
- val[x] = (FLAC__byte)(word >> (8*(FLAC__BYTES_PER_WORD-x-1)));
-#endif
- val += FLAC__BYTES_PER_WORD;
- nvals -= FLAC__BYTES_PER_WORD;
- }
- else if(!bitreader_read_from_client_(br))
- return false;
- }
- /* step 3: read any remainder from partial tail bytes */
- while(nvals) {
- if(!FLAC__bitreader_read_raw_uint32(br, &x, 8))
- return false;
- *val++ = (FLAC__byte)x;
- nvals--;
- }
-
- return true;
-}
-
-FLAC__bool FLAC__bitreader_read_unary_unsigned(FLAC__BitReader *br, unsigned *val)
-#if 0 /* slow but readable version */
-{
- unsigned bit;
-
- FLAC__ASSERT(0 != br);
- FLAC__ASSERT(0 != br->buffer);
-
- *val = 0;
- while(1) {
- if(!FLAC__bitreader_read_bit(br, &bit))
- return false;
- if(bit)
- break;
- else
- *val++;
- }
- return true;
-}
-#else
-{
- unsigned i;
-
- FLAC__ASSERT(0 != br);
- FLAC__ASSERT(0 != br->buffer);
-
- *val = 0;
- while(1) {
- while(br->consumed_words < br->words) { /* if we've not consumed up to a partial tail word... */
- brword b = br->buffer[br->consumed_words] << br->consumed_bits;
- if(b) {
- i = COUNT_ZERO_MSBS(b);
- *val += i;
- i++;
- br->consumed_bits += i;
- if(br->consumed_bits >= FLAC__BITS_PER_WORD) { /* faster way of testing if(br->consumed_bits == FLAC__BITS_PER_WORD) */
- crc16_update_word_(br, br->buffer[br->consumed_words]);
- br->consumed_words++;
- br->consumed_bits = 0;
- }
- return true;
- }
- else {
- *val += FLAC__BITS_PER_WORD - br->consumed_bits;
- crc16_update_word_(br, br->buffer[br->consumed_words]);
- br->consumed_words++;
- br->consumed_bits = 0;
- /* didn't find stop bit yet, have to keep going... */
- }
- }
- /* at this point we've eaten up all the whole words; have to try
- * reading through any tail bytes before calling the read callback.
- * this is a repeat of the above logic adjusted for the fact we
- * don't have a whole word. note though if the client is feeding
- * us data a byte at a time (unlikely), br->consumed_bits may not
- * be zero.
- */
- if(br->bytes*8 > br->consumed_bits) {
- const unsigned end = br->bytes * 8;
- brword b = (br->buffer[br->consumed_words] & (FLAC__WORD_ALL_ONES << (FLAC__BITS_PER_WORD-end))) << br->consumed_bits;
- if(b) {
- i = COUNT_ZERO_MSBS(b);
- *val += i;
- i++;
- br->consumed_bits += i;
- FLAC__ASSERT(br->consumed_bits < FLAC__BITS_PER_WORD);
- return true;
- }
- else {
- *val += end - br->consumed_bits;
- br->consumed_bits = end;
- FLAC__ASSERT(br->consumed_bits < FLAC__BITS_PER_WORD);
- /* didn't find stop bit yet, have to keep going... */
- }
- }
- if(!bitreader_read_from_client_(br))
- return false;
- }
-}
-#endif
-
-FLAC__bool FLAC__bitreader_read_rice_signed(FLAC__BitReader *br, int *val, unsigned parameter)
-{
- FLAC__uint32 lsbs = 0, msbs = 0;
- unsigned uval;
-
- FLAC__ASSERT(0 != br);
- FLAC__ASSERT(0 != br->buffer);
- FLAC__ASSERT(parameter <= 31);
-
- /* read the unary MSBs and end bit */
- if(!FLAC__bitreader_read_unary_unsigned(br, &msbs))
- return false;
-
- /* read the binary LSBs */
- if(!FLAC__bitreader_read_raw_uint32(br, &lsbs, parameter))
- return false;
-
- /* compose the value */
- uval = (msbs << parameter) | lsbs;
- if(uval & 1)
- *val = -((int)(uval >> 1)) - 1;
- else
- *val = (int)(uval >> 1);
-
- return true;
-}
-
-/* this is by far the most heavily used reader call. it ain't pretty but it's fast */
-/* a lot of the logic is copied, then adapted, from FLAC__bitreader_read_unary_unsigned() and FLAC__bitreader_read_raw_uint32() */
-FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], unsigned nvals, unsigned parameter)
-/* OPT: possibly faster version for use with MSVC */
-#ifdef _MSC_VER
-{
- unsigned i;
- unsigned uval = 0;
- unsigned bits; /* the # of binary LSBs left to read to finish a rice codeword */
-
- /* try and get br->consumed_words and br->consumed_bits into register;
- * must remember to flush them back to *br before calling other
- * bitwriter functions that use them, and before returning */
- register unsigned cwords;
- register unsigned cbits;
-
- FLAC__ASSERT(0 != br);
- FLAC__ASSERT(0 != br->buffer);
- /* WATCHOUT: code does not work with <32bit words; we can make things much faster with this assertion */
- FLAC__ASSERT(FLAC__BITS_PER_WORD >= 32);
- FLAC__ASSERT(parameter < 32);
- /* the above two asserts also guarantee that the binary part never straddles more that 2 words, so we don't have to loop to read it */
-
- if(nvals == 0)
- return true;
-
- cbits = br->consumed_bits;
- cwords = br->consumed_words;
-
- while(1) {
-
- /* read unary part */
- while(1) {
- while(cwords < br->words) { /* if we've not consumed up to a partial tail word... */
- brword b = br->buffer[cwords] << cbits;
- if(b) {
-#if 0 /* slower, probably due to bad register allocation... */ && defined FLAC__CPU_IA32 && !defined FLAC__NO_ASM && FLAC__BITS_PER_WORD == 32
- __asm {
- bsr eax, b
- not eax
- and eax, 31
- mov i, eax
- }
-#else
- i = COUNT_ZERO_MSBS(b);
-#endif
- uval += i;
- bits = parameter;
- i++;
- cbits += i;
- if(cbits == FLAC__BITS_PER_WORD) {
- crc16_update_word_(br, br->buffer[cwords]);
- cwords++;
- cbits = 0;
- }
- goto break1;
- }
- else {
- uval += FLAC__BITS_PER_WORD - cbits;
- crc16_update_word_(br, br->buffer[cwords]);
- cwords++;
- cbits = 0;
- /* didn't find stop bit yet, have to keep going... */
- }
- }
- /* at this point we've eaten up all the whole words; have to try
- * reading through any tail bytes before calling the read callback.
- * this is a repeat of the above logic adjusted for the fact we
- * don't have a whole word. note though if the client is feeding
- * us data a byte at a time (unlikely), br->consumed_bits may not
- * be zero.
- */
- if(br->bytes*8 > cbits) {
- const unsigned end = br->bytes * 8;
- brword b = (br->buffer[cwords] & (FLAC__WORD_ALL_ONES << (FLAC__BITS_PER_WORD-end))) << cbits;
- if(b) {
- i = COUNT_ZERO_MSBS(b);
- uval += i;
- bits = parameter;
- i++;
- cbits += i;
- FLAC__ASSERT(cbits < FLAC__BITS_PER_WORD);
- goto break1;
- }
- else {
- uval += end - cbits;
- cbits = end;
- FLAC__ASSERT(cbits < FLAC__BITS_PER_WORD);
- /* didn't find stop bit yet, have to keep going... */
- }
- }
- /* flush registers and read; bitreader_read_from_client_() does
- * not touch br->consumed_bits at all but we still need to set
- * it in case it fails and we have to return false.
- */
- br->consumed_bits = cbits;
- br->consumed_words = cwords;
- if(!bitreader_read_from_client_(br))
- return false;
- cwords = br->consumed_words;
- }
-break1:
- /* read binary part */
- FLAC__ASSERT(cwords <= br->words);
-
- if(bits) {
- while((br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits < bits) {
- /* flush registers and read; bitreader_read_from_client_() does
- * not touch br->consumed_bits at all but we still need to set
- * it in case it fails and we have to return false.
- */
- br->consumed_bits = cbits;
- br->consumed_words = cwords;
- if(!bitreader_read_from_client_(br))
- return false;
- cwords = br->consumed_words;
- }
- if(cwords < br->words) { /* if we've not consumed up to a partial tail word... */
- if(cbits) {
- /* this also works when consumed_bits==0, it's just a little slower than necessary for that case */
- const unsigned n = FLAC__BITS_PER_WORD - cbits;
- const brword word = br->buffer[cwords];
- if(bits < n) {
- uval <<= bits;
- uval |= (word & (FLAC__WORD_ALL_ONES >> cbits)) >> (n-bits);
- cbits += bits;
- goto break2;
- }
- uval <<= n;
- uval |= word & (FLAC__WORD_ALL_ONES >> cbits);
- bits -= n;
- crc16_update_word_(br, word);
- cwords++;
- cbits = 0;
- if(bits) { /* if there are still bits left to read, there have to be less than 32 so they will all be in the next word */
- uval <<= bits;
- uval |= (br->buffer[cwords] >> (FLAC__BITS_PER_WORD-bits));
- cbits = bits;
- }
- goto break2;
- }
- else {
- FLAC__ASSERT(bits < FLAC__BITS_PER_WORD);
- uval <<= bits;
- uval |= br->buffer[cwords] >> (FLAC__BITS_PER_WORD-bits);
- cbits = bits;
- goto break2;
- }
- }
- else {
- /* in this case we're starting our read at a partial tail word;
- * the reader has guaranteed that we have at least 'bits' bits
- * available to read, which makes this case simpler.
- */
- uval <<= bits;
- if(cbits) {
- /* this also works when consumed_bits==0, it's just a little slower than necessary for that case */
- FLAC__ASSERT(cbits + bits <= br->bytes*8);
- uval |= (br->buffer[cwords] & (FLAC__WORD_ALL_ONES >> cbits)) >> (FLAC__BITS_PER_WORD-cbits-bits);
- cbits += bits;
- goto break2;
- }
- else {
- uval |= br->buffer[cwords] >> (FLAC__BITS_PER_WORD-bits);
- cbits += bits;
- goto break2;
- }
- }
- }
-break2:
- /* compose the value */
- *vals = (int)(uval >> 1 ^ -(int)(uval & 1));
-
- /* are we done? */
- --nvals;
- if(nvals == 0) {
- br->consumed_bits = cbits;
- br->consumed_words = cwords;
- return true;
- }
-
- uval = 0;
- ++vals;
-
- }
-}
-#else
-{
- unsigned i;
- unsigned uval = 0;
-
- /* try and get br->consumed_words and br->consumed_bits into register;
- * must remember to flush them back to *br before calling other
- * bitwriter functions that use them, and before returning */
- register unsigned cwords;
- register unsigned cbits;
- unsigned ucbits; /* keep track of the number of unconsumed bits in the buffer */
-
- FLAC__ASSERT(0 != br);
- FLAC__ASSERT(0 != br->buffer);
- /* WATCHOUT: code does not work with <32bit words; we can make things much faster with this assertion */
- FLAC__ASSERT(FLAC__BITS_PER_WORD >= 32);
- FLAC__ASSERT(parameter < 32);
- /* the above two asserts also guarantee that the binary part never straddles more than 2 words, so we don't have to loop to read it */
-
- if(nvals == 0)
- return true;
-
- cbits = br->consumed_bits;
- cwords = br->consumed_words;
- ucbits = (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits;
-
- while(1) {
-
- /* read unary part */
- while(1) {
- while(cwords < br->words) { /* if we've not consumed up to a partial tail word... */
- brword b = br->buffer[cwords] << cbits;
- if(b) {
-#if 0 /* is not discernably faster... */ && defined FLAC__CPU_IA32 && !defined FLAC__NO_ASM && FLAC__BITS_PER_WORD == 32 && defined __GNUC__
- asm volatile (
- "bsrl %1, %0;"
- "notl %0;"
- "andl $31, %0;"
- : "=r"(i)
- : "r"(b)
- );
-#else
- i = COUNT_ZERO_MSBS(b);
-#endif
- uval += i;
- cbits += i;
- cbits++; /* skip over stop bit */
- if(cbits >= FLAC__BITS_PER_WORD) { /* faster way of testing if(cbits == FLAC__BITS_PER_WORD) */
- crc16_update_word_(br, br->buffer[cwords]);
- cwords++;
- cbits = 0;
- }
- goto break1;
- }
- else {
- uval += FLAC__BITS_PER_WORD - cbits;
- crc16_update_word_(br, br->buffer[cwords]);
- cwords++;
- cbits = 0;
- /* didn't find stop bit yet, have to keep going... */
- }
- }
- /* at this point we've eaten up all the whole words; have to try
- * reading through any tail bytes before calling the read callback.
- * this is a repeat of the above logic adjusted for the fact we
- * don't have a whole word. note though if the client is feeding
- * us data a byte at a time (unlikely), br->consumed_bits may not
- * be zero.
- */
- if(br->bytes*8 > cbits) {
- const unsigned end = br->bytes * 8;
- brword b = (br->buffer[cwords] & ~(FLAC__WORD_ALL_ONES >> end)) << cbits;
- if(b) {
- i = COUNT_ZERO_MSBS(b);
- uval += i;
- cbits += i;
- cbits++; /* skip over stop bit */
- FLAC__ASSERT(cbits < FLAC__BITS_PER_WORD);
- goto break1;
- }
- else {
- uval += end - cbits;
- cbits = end;
- FLAC__ASSERT(cbits < FLAC__BITS_PER_WORD);
- /* didn't find stop bit yet, have to keep going... */
- }
- }
- /* flush registers and read; bitreader_read_from_client_() does
- * not touch br->consumed_bits at all but we still need to set
- * it in case it fails and we have to return false.
- */
- br->consumed_bits = cbits;
- br->consumed_words = cwords;
- if(!bitreader_read_from_client_(br))
- return false;
- cwords = br->consumed_words;
- ucbits = (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits + uval;
- /* + uval to offset our count by the # of unary bits already
- * consumed before the read, because we will add these back
- * in all at once at break1
- */
- }
-break1:
- ucbits -= uval;
- ucbits--; /* account for stop bit */
-
- /* read binary part */
- FLAC__ASSERT(cwords <= br->words);
-
- if(parameter) {
- while(ucbits < parameter) {
- /* flush registers and read; bitreader_read_from_client_() does
- * not touch br->consumed_bits at all but we still need to set
- * it in case it fails and we have to return false.
- */
- br->consumed_bits = cbits;
- br->consumed_words = cwords;
- if(!bitreader_read_from_client_(br))
- return false;
- cwords = br->consumed_words;
- ucbits = (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits;
- }
- if(cwords < br->words) { /* if we've not consumed up to a partial tail word... */
- if(cbits) {
- /* this also works when consumed_bits==0, it's just slower than necessary for that case */
- const unsigned n = FLAC__BITS_PER_WORD - cbits;
- const brword word = br->buffer[cwords];
- if(parameter < n) {
- uval <<= parameter;
- uval |= (word & (FLAC__WORD_ALL_ONES >> cbits)) >> (n-parameter);
- cbits += parameter;
- }
- else {
- uval <<= n;
- uval |= word & (FLAC__WORD_ALL_ONES >> cbits);
- crc16_update_word_(br, word);
- cwords++;
- cbits = parameter - n;
- if(cbits) { /* parameter > n, i.e. if there are still bits left to read, there have to be less than 32 so they will all be in the next word */
- uval <<= cbits;
- uval |= (br->buffer[cwords] >> (FLAC__BITS_PER_WORD-cbits));
- }
- }
- }
- else {
- cbits = parameter;
- uval <<= parameter;
- uval |= br->buffer[cwords] >> (FLAC__BITS_PER_WORD-cbits);
- }
- }
- else {
- /* in this case we're starting our read at a partial tail word;
- * the reader has guaranteed that we have at least 'parameter'
- * bits available to read, which makes this case simpler.
- */
- uval <<= parameter;
- if(cbits) {
- /* this also works when consumed_bits==0, it's just a little slower than necessary for that case */
- FLAC__ASSERT(cbits + parameter <= br->bytes*8);
- uval |= (br->buffer[cwords] & (FLAC__WORD_ALL_ONES >> cbits)) >> (FLAC__BITS_PER_WORD-cbits-parameter);
- cbits += parameter;
- }
- else {
- cbits = parameter;
- uval |= br->buffer[cwords] >> (FLAC__BITS_PER_WORD-cbits);
- }
- }
- }
-
- ucbits -= parameter;
-
- /* compose the value */
- *vals = (int)(uval >> 1 ^ -(int)(uval & 1));
-
- /* are we done? */
- --nvals;
- if(nvals == 0) {
- br->consumed_bits = cbits;
- br->consumed_words = cwords;
- return true;
- }
-
- uval = 0;
- ++vals;
-
- }
-}
-#endif
-
-#if 0 /* UNUSED */
-FLAC__bool FLAC__bitreader_read_golomb_signed(FLAC__BitReader *br, int *val, unsigned parameter)
-{
- FLAC__uint32 lsbs = 0, msbs = 0;
- unsigned bit, uval, k;
-
- FLAC__ASSERT(0 != br);
- FLAC__ASSERT(0 != br->buffer);
-
- k = FLAC__bitmath_ilog2(parameter);
-
- /* read the unary MSBs and end bit */
- if(!FLAC__bitreader_read_unary_unsigned(br, &msbs))
- return false;
-
- /* read the binary LSBs */
- if(!FLAC__bitreader_read_raw_uint32(br, &lsbs, k))
- return false;
-
- if(parameter == 1u<<k) {
- /* compose the value */
- uval = (msbs << k) | lsbs;
- }
- else {
- unsigned d = (1 << (k+1)) - parameter;
- if(lsbs >= d) {
- if(!FLAC__bitreader_read_bit(br, &bit))
- return false;
- lsbs <<= 1;
- lsbs |= bit;
- lsbs -= d;
- }
- /* compose the value */
- uval = msbs * parameter + lsbs;
- }
-
- /* unfold unsigned to signed */
- if(uval & 1)
- *val = -((int)(uval >> 1)) - 1;
- else
- *val = (int)(uval >> 1);
-
- return true;
-}
-
-FLAC__bool FLAC__bitreader_read_golomb_unsigned(FLAC__BitReader *br, unsigned *val, unsigned parameter)
-{
- FLAC__uint32 lsbs, msbs = 0;
- unsigned bit, k;
-
- FLAC__ASSERT(0 != br);
- FLAC__ASSERT(0 != br->buffer);
-
- k = FLAC__bitmath_ilog2(parameter);
-
- /* read the unary MSBs and end bit */
- if(!FLAC__bitreader_read_unary_unsigned(br, &msbs))
- return false;
-
- /* read the binary LSBs */
- if(!FLAC__bitreader_read_raw_uint32(br, &lsbs, k))
- return false;
-
- if(parameter == 1u<<k) {
- /* compose the value */
- *val = (msbs << k) | lsbs;
- }
- else {
- unsigned d = (1 << (k+1)) - parameter;
- if(lsbs >= d) {
- if(!FLAC__bitreader_read_bit(br, &bit))
- return false;
- lsbs <<= 1;
- lsbs |= bit;
- lsbs -= d;
- }
- /* compose the value */
- *val = msbs * parameter + lsbs;
- }
-
- return true;
-}
-#endif /* UNUSED */
-
-/* on return, if *val == 0xffffffff then the utf-8 sequence was invalid, but the return value will be true */
-FLAC__bool FLAC__bitreader_read_utf8_uint32(FLAC__BitReader *br, FLAC__uint32 *val, FLAC__byte *raw, unsigned *rawlen)
-{
- FLAC__uint32 v = 0;
- FLAC__uint32 x;
- unsigned i;
-
- if(!FLAC__bitreader_read_raw_uint32(br, &x, 8))
- return false;
- if(raw)
- raw[(*rawlen)++] = (FLAC__byte)x;
- if(!(x & 0x80)) { /* 0xxxxxxx */
- v = x;
- i = 0;
- }
- else if(x & 0xC0 && !(x & 0x20)) { /* 110xxxxx */
- v = x & 0x1F;
- i = 1;
- }
- else if(x & 0xE0 && !(x & 0x10)) { /* 1110xxxx */
- v = x & 0x0F;
- i = 2;
- }
- else if(x & 0xF0 && !(x & 0x08)) { /* 11110xxx */
- v = x & 0x07;
- i = 3;
- }
- else if(x & 0xF8 && !(x & 0x04)) { /* 111110xx */
- v = x & 0x03;
- i = 4;
- }
- else if(x & 0xFC && !(x & 0x02)) { /* 1111110x */
- v = x & 0x01;
- i = 5;
- }
- else {
- *val = 0xffffffff;
- return true;
- }
- for( ; i; i--) {
- if(!FLAC__bitreader_read_raw_uint32(br, &x, 8))
- return false;
- if(raw)
- raw[(*rawlen)++] = (FLAC__byte)x;
- if(!(x & 0x80) || (x & 0x40)) { /* 10xxxxxx */
- *val = 0xffffffff;
- return true;
- }
- v <<= 6;
- v |= (x & 0x3F);
- }
- *val = v;
- return true;
-}
-
-/* on return, if *val == 0xffffffffffffffff then the utf-8 sequence was invalid, but the return value will be true */
-FLAC__bool FLAC__bitreader_read_utf8_uint64(FLAC__BitReader *br, FLAC__uint64 *val, FLAC__byte *raw, unsigned *rawlen)
-{
- FLAC__uint64 v = 0;
- FLAC__uint32 x;
- unsigned i;
-
- if(!FLAC__bitreader_read_raw_uint32(br, &x, 8))
- return false;
- if(raw)
- raw[(*rawlen)++] = (FLAC__byte)x;
- if(!(x & 0x80)) { /* 0xxxxxxx */
- v = x;
- i = 0;
- }
- else if(x & 0xC0 && !(x & 0x20)) { /* 110xxxxx */
- v = x & 0x1F;
- i = 1;
- }
- else if(x & 0xE0 && !(x & 0x10)) { /* 1110xxxx */
- v = x & 0x0F;
- i = 2;
- }
- else if(x & 0xF0 && !(x & 0x08)) { /* 11110xxx */
- v = x & 0x07;
- i = 3;
- }
- else if(x & 0xF8 && !(x & 0x04)) { /* 111110xx */
- v = x & 0x03;
- i = 4;
- }
- else if(x & 0xFC && !(x & 0x02)) { /* 1111110x */
- v = x & 0x01;
- i = 5;
- }
- else if(x & 0xFE && !(x & 0x01)) { /* 11111110 */
- v = 0;
- i = 6;
- }
- else {
- *val = FLAC__U64L(0xffffffffffffffff);
- return true;
- }
- for( ; i; i--) {
- if(!FLAC__bitreader_read_raw_uint32(br, &x, 8))
- return false;
- if(raw)
- raw[(*rawlen)++] = (FLAC__byte)x;
- if(!(x & 0x80) || (x & 0x40)) { /* 10xxxxxx */
- *val = FLAC__U64L(0xffffffffffffffff);
- return true;
- }
- v <<= 6;
- v |= (x & 0x3F);
- }
- *val = v;
- return true;
-}
diff --git a/src/thirdparty/libflac/src/libFLAC/bitwriter.c b/src/thirdparty/libflac/src/libFLAC/bitwriter.c
deleted file mode 100644
index 581a941fe..000000000
--- a/src/thirdparty/libflac/src/libFLAC/bitwriter.c
+++ /dev/null
@@ -1,892 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdlib.h> /* for malloc() */
-#include <string.h> /* for memcpy(), memset() */
-#ifdef _MSC_VER
-# include <winsock.h> /* for ntohl() */
-# if _MSC_VER >= 1310
-# include <winsock2.h> /* for ntohl(), sometimes it is not in winsock.h */
-# endif
-#elif defined FLAC__SYS_DARWIN
-# include <machine/endian.h> /* for ntohl() */
-#elif defined __MINGW32__
-# include <winsock.h> /* for ntohl() */
-#else
-# include <netinet/in.h> /* for ntohl() */
-#endif
-#if 0 /* UNUSED */
-#include "private/bitmath.h"
-#endif
-#include "private/bitwriter.h"
-#include "private/crc.h"
-#include "FLAC/assert.h"
-#include "share/alloc.h"
-
-/* Things should be fastest when this matches the machine word size */
-/* WATCHOUT: if you change this you must also change the following #defines down to SWAP_BE_WORD_TO_HOST below to match */
-/* WATCHOUT: there are a few places where the code will not work unless bwword is >= 32 bits wide */
-typedef FLAC__uint32 bwword;
-#define FLAC__BYTES_PER_WORD 4
-#define FLAC__BITS_PER_WORD 32
-#define FLAC__WORD_ALL_ONES ((FLAC__uint32)0xffffffff)
-/* SWAP_BE_WORD_TO_HOST swaps bytes in a bwword (which is always big-endian) if necessary to match host byte order */
-#if WORDS_BIGENDIAN
-#define SWAP_BE_WORD_TO_HOST(x) (x)
-#else
-#ifdef _MSC_VER
-#define SWAP_BE_WORD_TO_HOST(x) local_swap32_(x)
-#else
-#define SWAP_BE_WORD_TO_HOST(x) ntohl(x)
-#endif
-#endif
-
-/*
- * The default capacity here doesn't matter too much. The buffer always grows
- * to hold whatever is written to it. Usually the encoder will stop adding at
- * a frame or metadata block, then write that out and clear the buffer for the
- * next one.
- */
-static const unsigned FLAC__BITWRITER_DEFAULT_CAPACITY = 32768u / sizeof(bwword); /* size in words */
-/* When growing, increment 4K at a time */
-static const unsigned FLAC__BITWRITER_DEFAULT_INCREMENT = 4096u / sizeof(bwword); /* size in words */
-
-#define FLAC__WORDS_TO_BITS(words) ((words) * FLAC__BITS_PER_WORD)
-#define FLAC__TOTAL_BITS(bw) (FLAC__WORDS_TO_BITS((bw)->words) + (bw)->bits)
-
-#ifdef min
-#undef min
-#endif
-#define min(x,y) ((x)<(y)?(x):(y))
-
-/* adjust for compilers that can't understand using LLU suffix for uint64_t literals */
-#ifdef _MSC_VER
-#define FLAC__U64L(x) x
-#else
-#define FLAC__U64L(x) x##LLU
-#endif
-
-#ifndef FLaC__INLINE
-#define FLaC__INLINE
-#endif
-
-struct FLAC__BitWriter {
- bwword *buffer;
- bwword accum; /* accumulator; bits are right-justified; when full, accum is appended to buffer */
- unsigned capacity; /* capacity of buffer in words */
- unsigned words; /* # of complete words in buffer */
- unsigned bits; /* # of used bits in accum */
-};
-
-#ifdef _MSC_VER
-/* OPT: an MSVC built-in would be better */
-static _inline FLAC__uint32 local_swap32_(FLAC__uint32 x)
-{
- x = ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
- return (x>>16) | (x<<16);
-}
-#endif
-
-/* * WATCHOUT: The current implementation only grows the buffer. */
-static FLAC__bool bitwriter_grow_(FLAC__BitWriter *bw, unsigned bits_to_add)
-{
- unsigned new_capacity;
- bwword *new_buffer;
-
- FLAC__ASSERT(0 != bw);
- FLAC__ASSERT(0 != bw->buffer);
-
- /* calculate total words needed to store 'bits_to_add' additional bits */
- new_capacity = bw->words + ((bw->bits + bits_to_add + FLAC__BITS_PER_WORD - 1) / FLAC__BITS_PER_WORD);
-
- /* it's possible (due to pessimism in the growth estimation that
- * leads to this call) that we don't actually need to grow
- */
- if(bw->capacity >= new_capacity)
- return true;
-
- /* round up capacity increase to the nearest FLAC__BITWRITER_DEFAULT_INCREMENT */
- if((new_capacity - bw->capacity) % FLAC__BITWRITER_DEFAULT_INCREMENT)
- new_capacity += FLAC__BITWRITER_DEFAULT_INCREMENT - ((new_capacity - bw->capacity) % FLAC__BITWRITER_DEFAULT_INCREMENT);
- /* make sure we got everything right */
- FLAC__ASSERT(0 == (new_capacity - bw->capacity) % FLAC__BITWRITER_DEFAULT_INCREMENT);
- FLAC__ASSERT(new_capacity > bw->capacity);
- FLAC__ASSERT(new_capacity >= bw->words + ((bw->bits + bits_to_add + FLAC__BITS_PER_WORD - 1) / FLAC__BITS_PER_WORD));
-
- new_buffer = (bwword*)safe_realloc_mul_2op_(bw->buffer, sizeof(bwword), /*times*/new_capacity);
- if(new_buffer == 0)
- return false;
- bw->buffer = new_buffer;
- bw->capacity = new_capacity;
- return true;
-}
-
-
-/***********************************************************************
- *
- * Class constructor/destructor
- *
- ***********************************************************************/
-
-FLAC__BitWriter *FLAC__bitwriter_new(void)
-{
- FLAC__BitWriter *bw = (FLAC__BitWriter*)calloc(1, sizeof(FLAC__BitWriter));
- /* note that calloc() sets all members to 0 for us */
- return bw;
-}
-
-void FLAC__bitwriter_delete(FLAC__BitWriter *bw)
-{
- FLAC__ASSERT(0 != bw);
-
- FLAC__bitwriter_free(bw);
- free(bw);
-}
-
-/***********************************************************************
- *
- * Public class methods
- *
- ***********************************************************************/
-
-FLAC__bool FLAC__bitwriter_init(FLAC__BitWriter *bw)
-{
- FLAC__ASSERT(0 != bw);
-
- bw->words = bw->bits = 0;
- bw->capacity = FLAC__BITWRITER_DEFAULT_CAPACITY;
- bw->buffer = (bwword*)malloc(sizeof(bwword) * bw->capacity);
- if(bw->buffer == 0)
- return false;
-
- return true;
-}
-
-void FLAC__bitwriter_free(FLAC__BitWriter *bw)
-{
- FLAC__ASSERT(0 != bw);
-
- if(0 != bw->buffer)
- free(bw->buffer);
- bw->buffer = 0;
- bw->capacity = 0;
- bw->words = bw->bits = 0;
-}
-
-void FLAC__bitwriter_clear(FLAC__BitWriter *bw)
-{
- bw->words = bw->bits = 0;
-}
-
-void FLAC__bitwriter_dump(const FLAC__BitWriter *bw, FILE *out)
-{
- unsigned i, j;
- if(bw == 0) {
- fprintf(out, "bitwriter is NULL\n");
- }
- else {
- fprintf(out, "bitwriter: capacity=%u words=%u bits=%u total_bits=%u\n", bw->capacity, bw->words, bw->bits, FLAC__TOTAL_BITS(bw));
-
- for(i = 0; i < bw->words; i++) {
- fprintf(out, "%08X: ", i);
- for(j = 0; j < FLAC__BITS_PER_WORD; j++)
- fprintf(out, "%01u", bw->buffer[i] & (1 << (FLAC__BITS_PER_WORD-j-1)) ? 1:0);
- fprintf(out, "\n");
- }
- if(bw->bits > 0) {
- fprintf(out, "%08X: ", i);
- for(j = 0; j < bw->bits; j++)
- fprintf(out, "%01u", bw->accum & (1 << (bw->bits-j-1)) ? 1:0);
- fprintf(out, "\n");
- }
- }
-}
-
-FLAC__bool FLAC__bitwriter_get_write_crc16(FLAC__BitWriter *bw, FLAC__uint16 *crc)
-{
- const FLAC__byte *buffer;
- size_t bytes;
-
- FLAC__ASSERT((bw->bits & 7) == 0); /* assert that we're byte-aligned */
-
- if(!FLAC__bitwriter_get_buffer(bw, &buffer, &bytes))
- return false;
-
- *crc = (FLAC__uint16)FLAC__crc16(buffer, bytes);
- FLAC__bitwriter_release_buffer(bw);
- return true;
-}
-
-FLAC__bool FLAC__bitwriter_get_write_crc8(FLAC__BitWriter *bw, FLAC__byte *crc)
-{
- const FLAC__byte *buffer;
- size_t bytes;
-
- FLAC__ASSERT((bw->bits & 7) == 0); /* assert that we're byte-aligned */
-
- if(!FLAC__bitwriter_get_buffer(bw, &buffer, &bytes))
- return false;
-
- *crc = FLAC__crc8(buffer, bytes);
- FLAC__bitwriter_release_buffer(bw);
- return true;
-}
-
-FLAC__bool FLAC__bitwriter_is_byte_aligned(const FLAC__BitWriter *bw)
-{
- return ((bw->bits & 7) == 0);
-}
-
-unsigned FLAC__bitwriter_get_input_bits_unconsumed(const FLAC__BitWriter *bw)
-{
- return FLAC__TOTAL_BITS(bw);
-}
-
-FLAC__bool FLAC__bitwriter_get_buffer(FLAC__BitWriter *bw, const FLAC__byte **buffer, size_t *bytes)
-{
- FLAC__ASSERT((bw->bits & 7) == 0);
- /* double protection */
- if(bw->bits & 7)
- return false;
- /* if we have bits in the accumulator we have to flush those to the buffer first */
- if(bw->bits) {
- FLAC__ASSERT(bw->words <= bw->capacity);
- if(bw->words == bw->capacity && !bitwriter_grow_(bw, FLAC__BITS_PER_WORD))
- return false;
- /* append bits as complete word to buffer, but don't change bw->accum or bw->bits */
- bw->buffer[bw->words] = SWAP_BE_WORD_TO_HOST(bw->accum << (FLAC__BITS_PER_WORD-bw->bits));
- }
- /* now we can just return what we have */
- *buffer = (FLAC__byte*)bw->buffer;
- *bytes = (FLAC__BYTES_PER_WORD * bw->words) + (bw->bits >> 3);
- return true;
-}
-
-void FLAC__bitwriter_release_buffer(FLAC__BitWriter *bw)
-{
- /* nothing to do. in the future, strict checking of a 'writer-is-in-
- * get-mode' flag could be added everywhere and then cleared here
- */
- (void)bw;
-}
-
-FLaC__INLINE FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, unsigned bits)
-{
- unsigned n;
-
- FLAC__ASSERT(0 != bw);
- FLAC__ASSERT(0 != bw->buffer);
-
- if(bits == 0)
- return true;
- /* slightly pessimistic size check but faster than "<= bw->words + (bw->bits+bits+FLAC__BITS_PER_WORD-1)/FLAC__BITS_PER_WORD" */
- if(bw->capacity <= bw->words + bits && !bitwriter_grow_(bw, bits))
- return false;
- /* first part gets to word alignment */
- if(bw->bits) {
- n = min(FLAC__BITS_PER_WORD - bw->bits, bits);
- bw->accum <<= n;
- bits -= n;
- bw->bits += n;
- if(bw->bits == FLAC__BITS_PER_WORD) {
- bw->buffer[bw->words++] = SWAP_BE_WORD_TO_HOST(bw->accum);
- bw->bits = 0;
- }
- else
- return true;
- }
- /* do whole words */
- while(bits >= FLAC__BITS_PER_WORD) {
- bw->buffer[bw->words++] = 0;
- bits -= FLAC__BITS_PER_WORD;
- }
- /* do any leftovers */
- if(bits > 0) {
- bw->accum = 0;
- bw->bits = bits;
- }
- return true;
-}
-
-FLaC__INLINE FLAC__bool FLAC__bitwriter_write_raw_uint32(FLAC__BitWriter *bw, FLAC__uint32 val, unsigned bits)
-{
- register unsigned left;
-
- /* WATCHOUT: code does not work with <32bit words; we can make things much faster with this assertion */
- FLAC__ASSERT(FLAC__BITS_PER_WORD >= 32);
-
- FLAC__ASSERT(0 != bw);
- FLAC__ASSERT(0 != bw->buffer);
-
- FLAC__ASSERT(bits <= 32);
- if(bits == 0)
- return true;
-
- /* slightly pessimistic size check but faster than "<= bw->words + (bw->bits+bits+FLAC__BITS_PER_WORD-1)/FLAC__BITS_PER_WORD" */
- if(bw->capacity <= bw->words + bits && !bitwriter_grow_(bw, bits))
- return false;
-
- left = FLAC__BITS_PER_WORD - bw->bits;
- if(bits < left) {
- bw->accum <<= bits;
- bw->accum |= val;
- bw->bits += bits;
- }
- else if(bw->bits) { /* WATCHOUT: if bw->bits == 0, left==FLAC__BITS_PER_WORD and bw->accum<<=left is a NOP instead of setting to 0 */
- bw->accum <<= left;
- bw->accum |= val >> (bw->bits = bits - left);
- bw->buffer[bw->words++] = SWAP_BE_WORD_TO_HOST(bw->accum);
- bw->accum = val;
- }
- else {
- bw->accum = val;
- bw->bits = 0;
- bw->buffer[bw->words++] = SWAP_BE_WORD_TO_HOST(val);
- }
-
- return true;
-}
-
-FLaC__INLINE FLAC__bool FLAC__bitwriter_write_raw_int32(FLAC__BitWriter *bw, FLAC__int32 val, unsigned bits)
-{
- /* zero-out unused bits */
- if(bits < 32)
- val &= (~(0xffffffff << bits));
-
- return FLAC__bitwriter_write_raw_uint32(bw, (FLAC__uint32)val, bits);
-}
-
-FLaC__INLINE FLAC__bool FLAC__bitwriter_write_raw_uint64(FLAC__BitWriter *bw, FLAC__uint64 val, unsigned bits)
-{
- /* this could be a little faster but it's not used for much */
- if(bits > 32) {
- return
- FLAC__bitwriter_write_raw_uint32(bw, (FLAC__uint32)(val>>32), bits-32) &&
- FLAC__bitwriter_write_raw_uint32(bw, (FLAC__uint32)val, 32);
- }
- else
- return FLAC__bitwriter_write_raw_uint32(bw, (FLAC__uint32)val, bits);
-}
-
-FLaC__INLINE FLAC__bool FLAC__bitwriter_write_raw_uint32_little_endian(FLAC__BitWriter *bw, FLAC__uint32 val)
-{
- /* this doesn't need to be that fast as currently it is only used for vorbis comments */
-
- if(!FLAC__bitwriter_write_raw_uint32(bw, val & 0xff, 8))
- return false;
- if(!FLAC__bitwriter_write_raw_uint32(bw, (val>>8) & 0xff, 8))
- return false;
- if(!FLAC__bitwriter_write_raw_uint32(bw, (val>>16) & 0xff, 8))
- return false;
- if(!FLAC__bitwriter_write_raw_uint32(bw, val>>24, 8))
- return false;
-
- return true;
-}
-
-FLaC__INLINE FLAC__bool FLAC__bitwriter_write_byte_block(FLAC__BitWriter *bw, const FLAC__byte vals[], unsigned nvals)
-{
- unsigned i;
-
- /* this could be faster but currently we don't need it to be since it's only used for writing metadata */
- for(i = 0; i < nvals; i++) {
- if(!FLAC__bitwriter_write_raw_uint32(bw, (FLAC__uint32)(vals[i]), 8))
- return false;
- }
-
- return true;
-}
-
-FLAC__bool FLAC__bitwriter_write_unary_unsigned(FLAC__BitWriter *bw, unsigned val)
-{
- if(val < 32)
- return FLAC__bitwriter_write_raw_uint32(bw, 1, ++val);
- else
- return
- FLAC__bitwriter_write_zeroes(bw, val) &&
- FLAC__bitwriter_write_raw_uint32(bw, 1, 1);
-}
-
-unsigned FLAC__bitwriter_rice_bits(FLAC__int32 val, unsigned parameter)
-{
- FLAC__uint32 uval;
-
- FLAC__ASSERT(parameter < sizeof(unsigned)*8);
-
- /* fold signed to unsigned; actual formula is: negative(v)? -2v-1 : 2v */
- uval = (val<<1) ^ (val>>31);
-
- return 1 + parameter + (uval >> parameter);
-}
-
-#if 0 /* UNUSED */
-unsigned FLAC__bitwriter_golomb_bits_signed(int val, unsigned parameter)
-{
- unsigned bits, msbs, uval;
- unsigned k;
-
- FLAC__ASSERT(parameter > 0);
-
- /* fold signed to unsigned */
- if(val < 0)
- uval = (unsigned)(((-(++val)) << 1) + 1);
- else
- uval = (unsigned)(val << 1);
-
- k = FLAC__bitmath_ilog2(parameter);
- if(parameter == 1u<<k) {
- FLAC__ASSERT(k <= 30);
-
- msbs = uval >> k;
- bits = 1 + k + msbs;
- }
- else {
- unsigned q, r, d;
-
- d = (1 << (k+1)) - parameter;
- q = uval / parameter;
- r = uval - (q * parameter);
-
- bits = 1 + q + k;
- if(r >= d)
- bits++;
- }
- return bits;
-}
-
-unsigned FLAC__bitwriter_golomb_bits_unsigned(unsigned uval, unsigned parameter)
-{
- unsigned bits, msbs;
- unsigned k;
-
- FLAC__ASSERT(parameter > 0);
-
- k = FLAC__bitmath_ilog2(parameter);
- if(parameter == 1u<<k) {
- FLAC__ASSERT(k <= 30);
-
- msbs = uval >> k;
- bits = 1 + k + msbs;
- }
- else {
- unsigned q, r, d;
-
- d = (1 << (k+1)) - parameter;
- q = uval / parameter;
- r = uval - (q * parameter);
-
- bits = 1 + q + k;
- if(r >= d)
- bits++;
- }
- return bits;
-}
-#endif /* UNUSED */
-
-FLAC__bool FLAC__bitwriter_write_rice_signed(FLAC__BitWriter *bw, FLAC__int32 val, unsigned parameter)
-{
- unsigned total_bits, interesting_bits, msbs;
- FLAC__uint32 uval, pattern;
-
- FLAC__ASSERT(0 != bw);
- FLAC__ASSERT(0 != bw->buffer);
- FLAC__ASSERT(parameter < 8*sizeof(uval));
-
- /* fold signed to unsigned; actual formula is: negative(v)? -2v-1 : 2v */
- uval = (val<<1) ^ (val>>31);
-
- msbs = uval >> parameter;
- interesting_bits = 1 + parameter;
- total_bits = interesting_bits + msbs;
- pattern = 1 << parameter; /* the unary end bit */
- pattern |= (uval & ((1<<parameter)-1)); /* the binary LSBs */
-
- if(total_bits <= 32)
- return FLAC__bitwriter_write_raw_uint32(bw, pattern, total_bits);
- else
- return
- FLAC__bitwriter_write_zeroes(bw, msbs) && /* write the unary MSBs */
- FLAC__bitwriter_write_raw_uint32(bw, pattern, interesting_bits); /* write the unary end bit and binary LSBs */
-}
-
-FLAC__bool FLAC__bitwriter_write_rice_signed_block(FLAC__BitWriter *bw, const FLAC__int32 *vals, unsigned nvals, unsigned parameter)
-{
- const FLAC__uint32 mask1 = FLAC__WORD_ALL_ONES << parameter; /* we val|=mask1 to set the stop bit above it... */
- const FLAC__uint32 mask2 = FLAC__WORD_ALL_ONES >> (31-parameter); /* ...then mask off the bits above the stop bit with val&=mask2*/
- FLAC__uint32 uval;
- unsigned left;
- const unsigned lsbits = 1 + parameter;
- unsigned msbits;
-
- FLAC__ASSERT(0 != bw);
- FLAC__ASSERT(0 != bw->buffer);
- FLAC__ASSERT(parameter < 8*sizeof(bwword)-1);
- /* WATCHOUT: code does not work with <32bit words; we can make things much faster with this assertion */
- FLAC__ASSERT(FLAC__BITS_PER_WORD >= 32);
-
- while(nvals) {
- /* fold signed to unsigned; actual formula is: negative(v)? -2v-1 : 2v */
- uval = (*vals<<1) ^ (*vals>>31);
-
- msbits = uval >> parameter;
-
-#if 0 /* OPT: can remove this special case if it doesn't make up for the extra compare (doesn't make a statistically significant difference with msvc or gcc/x86) */
- if(bw->bits && bw->bits + msbits + lsbits <= FLAC__BITS_PER_WORD) { /* i.e. if the whole thing fits in the current bwword */
- /* ^^^ if bw->bits is 0 then we may have filled the buffer and have no free bwword to work in */
- bw->bits = bw->bits + msbits + lsbits;
- uval |= mask1; /* set stop bit */
- uval &= mask2; /* mask off unused top bits */
- /* NOT: bw->accum <<= msbits + lsbits because msbits+lsbits could be 32, then the shift would be a NOP */
- bw->accum <<= msbits;
- bw->accum <<= lsbits;
- bw->accum |= uval;
- if(bw->bits == FLAC__BITS_PER_WORD) {
- bw->buffer[bw->words++] = SWAP_BE_WORD_TO_HOST(bw->accum);
- bw->bits = 0;
- /* burying the capacity check down here means we have to grow the buffer a little if there are more vals to do */
- if(bw->capacity <= bw->words && nvals > 1 && !bitwriter_grow_(bw, 1)) {
- FLAC__ASSERT(bw->capacity == bw->words);
- return false;
- }
- }
- }
- else {
-#elif 1 /*@@@@@@ OPT: try this version with MSVC6 to see if better, not much difference for gcc-4 */
- if(bw->bits && bw->bits + msbits + lsbits < FLAC__BITS_PER_WORD) { /* i.e. if the whole thing fits in the current bwword */
- /* ^^^ if bw->bits is 0 then we may have filled the buffer and have no free bwword to work in */
- bw->bits = bw->bits + msbits + lsbits;
- uval |= mask1; /* set stop bit */
- uval &= mask2; /* mask off unused top bits */
- bw->accum <<= msbits + lsbits;
- bw->accum |= uval;
- }
- else {
-#endif
- /* slightly pessimistic size check but faster than "<= bw->words + (bw->bits+msbits+lsbits+FLAC__BITS_PER_WORD-1)/FLAC__BITS_PER_WORD" */
- /* OPT: pessimism may cause flurry of false calls to grow_ which eat up all savings before it */
- if(bw->capacity <= bw->words + bw->bits + msbits + 1/*lsbits always fit in 1 bwword*/ && !bitwriter_grow_(bw, msbits+lsbits))
- return false;
-
- if(msbits) {
- /* first part gets to word alignment */
- if(bw->bits) {
- left = FLAC__BITS_PER_WORD - bw->bits;
- if(msbits < left) {
- bw->accum <<= msbits;
- bw->bits += msbits;
- goto break1;
- }
- else {
- bw->accum <<= left;
- msbits -= left;
- bw->buffer[bw->words++] = SWAP_BE_WORD_TO_HOST(bw->accum);
- bw->bits = 0;
- }
- }
- /* do whole words */
- while(msbits >= FLAC__BITS_PER_WORD) {
- bw->buffer[bw->words++] = 0;
- msbits -= FLAC__BITS_PER_WORD;
- }
- /* do any leftovers */
- if(msbits > 0) {
- bw->accum = 0;
- bw->bits = msbits;
- }
- }
-break1:
- uval |= mask1; /* set stop bit */
- uval &= mask2; /* mask off unused top bits */
-
- left = FLAC__BITS_PER_WORD - bw->bits;
- if(lsbits < left) {
- bw->accum <<= lsbits;
- bw->accum |= uval;
- bw->bits += lsbits;
- }
- else {
- /* if bw->bits == 0, left==FLAC__BITS_PER_WORD which will always
- * be > lsbits (because of previous assertions) so it would have
- * triggered the (lsbits<left) case above.
- */
- FLAC__ASSERT(bw->bits);
- FLAC__ASSERT(left < FLAC__BITS_PER_WORD);
- bw->accum <<= left;
- bw->accum |= uval >> (bw->bits = lsbits - left);
- bw->buffer[bw->words++] = SWAP_BE_WORD_TO_HOST(bw->accum);
- bw->accum = uval;
- }
-#if 1
- }
-#endif
- vals++;
- nvals--;
- }
- return true;
-}
-
-#if 0 /* UNUSED */
-FLAC__bool FLAC__bitwriter_write_golomb_signed(FLAC__BitWriter *bw, int val, unsigned parameter)
-{
- unsigned total_bits, msbs, uval;
- unsigned k;
-
- FLAC__ASSERT(0 != bw);
- FLAC__ASSERT(0 != bw->buffer);
- FLAC__ASSERT(parameter > 0);
-
- /* fold signed to unsigned */
- if(val < 0)
- uval = (unsigned)(((-(++val)) << 1) + 1);
- else
- uval = (unsigned)(val << 1);
-
- k = FLAC__bitmath_ilog2(parameter);
- if(parameter == 1u<<k) {
- unsigned pattern;
-
- FLAC__ASSERT(k <= 30);
-
- msbs = uval >> k;
- total_bits = 1 + k + msbs;
- pattern = 1 << k; /* the unary end bit */
- pattern |= (uval & ((1u<<k)-1)); /* the binary LSBs */
-
- if(total_bits <= 32) {
- if(!FLAC__bitwriter_write_raw_uint32(bw, pattern, total_bits))
- return false;
- }
- else {
- /* write the unary MSBs */
- if(!FLAC__bitwriter_write_zeroes(bw, msbs))
- return false;
- /* write the unary end bit and binary LSBs */
- if(!FLAC__bitwriter_write_raw_uint32(bw, pattern, k+1))
- return false;
- }
- }
- else {
- unsigned q, r, d;
-
- d = (1 << (k+1)) - parameter;
- q = uval / parameter;
- r = uval - (q * parameter);
- /* write the unary MSBs */
- if(!FLAC__bitwriter_write_zeroes(bw, q))
- return false;
- /* write the unary end bit */
- if(!FLAC__bitwriter_write_raw_uint32(bw, 1, 1))
- return false;
- /* write the binary LSBs */
- if(r >= d) {
- if(!FLAC__bitwriter_write_raw_uint32(bw, r+d, k+1))
- return false;
- }
- else {
- if(!FLAC__bitwriter_write_raw_uint32(bw, r, k))
- return false;
- }
- }
- return true;
-}
-
-FLAC__bool FLAC__bitwriter_write_golomb_unsigned(FLAC__BitWriter *bw, unsigned uval, unsigned parameter)
-{
- unsigned total_bits, msbs;
- unsigned k;
-
- FLAC__ASSERT(0 != bw);
- FLAC__ASSERT(0 != bw->buffer);
- FLAC__ASSERT(parameter > 0);
-
- k = FLAC__bitmath_ilog2(parameter);
- if(parameter == 1u<<k) {
- unsigned pattern;
-
- FLAC__ASSERT(k <= 30);
-
- msbs = uval >> k;
- total_bits = 1 + k + msbs;
- pattern = 1 << k; /* the unary end bit */
- pattern |= (uval & ((1u<<k)-1)); /* the binary LSBs */
-
- if(total_bits <= 32) {
- if(!FLAC__bitwriter_write_raw_uint32(bw, pattern, total_bits))
- return false;
- }
- else {
- /* write the unary MSBs */
- if(!FLAC__bitwriter_write_zeroes(bw, msbs))
- return false;
- /* write the unary end bit and binary LSBs */
- if(!FLAC__bitwriter_write_raw_uint32(bw, pattern, k+1))
- return false;
- }
- }
- else {
- unsigned q, r, d;
-
- d = (1 << (k+1)) - parameter;
- q = uval / parameter;
- r = uval - (q * parameter);
- /* write the unary MSBs */
- if(!FLAC__bitwriter_write_zeroes(bw, q))
- return false;
- /* write the unary end bit */
- if(!FLAC__bitwriter_write_raw_uint32(bw, 1, 1))
- return false;
- /* write the binary LSBs */
- if(r >= d) {
- if(!FLAC__bitwriter_write_raw_uint32(bw, r+d, k+1))
- return false;
- }
- else {
- if(!FLAC__bitwriter_write_raw_uint32(bw, r, k))
- return false;
- }
- }
- return true;
-}
-#endif /* UNUSED */
-
-FLAC__bool FLAC__bitwriter_write_utf8_uint32(FLAC__BitWriter *bw, FLAC__uint32 val)
-{
- FLAC__bool ok = 1;
-
- FLAC__ASSERT(0 != bw);
- FLAC__ASSERT(0 != bw->buffer);
-
- FLAC__ASSERT(!(val & 0x80000000)); /* this version only handles 31 bits */
-
- if(val < 0x80) {
- return FLAC__bitwriter_write_raw_uint32(bw, val, 8);
- }
- else if(val < 0x800) {
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0xC0 | (val>>6), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (val&0x3F), 8);
- }
- else if(val < 0x10000) {
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0xE0 | (val>>12), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | ((val>>6)&0x3F), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (val&0x3F), 8);
- }
- else if(val < 0x200000) {
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0xF0 | (val>>18), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | ((val>>12)&0x3F), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | ((val>>6)&0x3F), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (val&0x3F), 8);
- }
- else if(val < 0x4000000) {
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0xF8 | (val>>24), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | ((val>>18)&0x3F), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | ((val>>12)&0x3F), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | ((val>>6)&0x3F), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (val&0x3F), 8);
- }
- else {
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0xFC | (val>>30), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | ((val>>24)&0x3F), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | ((val>>18)&0x3F), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | ((val>>12)&0x3F), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | ((val>>6)&0x3F), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (val&0x3F), 8);
- }
-
- return ok;
-}
-
-FLAC__bool FLAC__bitwriter_write_utf8_uint64(FLAC__BitWriter *bw, FLAC__uint64 val)
-{
- FLAC__bool ok = 1;
-
- FLAC__ASSERT(0 != bw);
- FLAC__ASSERT(0 != bw->buffer);
-
- FLAC__ASSERT(!(val & FLAC__U64L(0xFFFFFFF000000000))); /* this version only handles 36 bits */
-
- if(val < 0x80) {
- return FLAC__bitwriter_write_raw_uint32(bw, (FLAC__uint32)val, 8);
- }
- else if(val < 0x800) {
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0xC0 | (FLAC__uint32)(val>>6), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)(val&0x3F), 8);
- }
- else if(val < 0x10000) {
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0xE0 | (FLAC__uint32)(val>>12), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>6)&0x3F), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)(val&0x3F), 8);
- }
- else if(val < 0x200000) {
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0xF0 | (FLAC__uint32)(val>>18), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>12)&0x3F), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>6)&0x3F), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)(val&0x3F), 8);
- }
- else if(val < 0x4000000) {
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0xF8 | (FLAC__uint32)(val>>24), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>18)&0x3F), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>12)&0x3F), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>6)&0x3F), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)(val&0x3F), 8);
- }
- else if(val < 0x80000000) {
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0xFC | (FLAC__uint32)(val>>30), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>24)&0x3F), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>18)&0x3F), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>12)&0x3F), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>6)&0x3F), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)(val&0x3F), 8);
- }
- else {
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0xFE, 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>30)&0x3F), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>24)&0x3F), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>18)&0x3F), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>12)&0x3F), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)((val>>6)&0x3F), 8);
- ok &= FLAC__bitwriter_write_raw_uint32(bw, 0x80 | (FLAC__uint32)(val&0x3F), 8);
- }
-
- return ok;
-}
-
-FLAC__bool FLAC__bitwriter_zero_pad_to_byte_boundary(FLAC__BitWriter *bw)
-{
- /* 0-pad to byte boundary */
- if(bw->bits & 7u)
- return FLAC__bitwriter_write_zeroes(bw, 8 - (bw->bits & 7u));
- else
- return true;
-}
diff --git a/src/thirdparty/libflac/src/libFLAC/cpu.c b/src/thirdparty/libflac/src/libFLAC/cpu.c
deleted file mode 100644
index 6d4d70ad6..000000000
--- a/src/thirdparty/libflac/src/libFLAC/cpu.c
+++ /dev/null
@@ -1,418 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "private/cpu.h"
-#include <stdlib.h>
-#include <stdio.h>
-
-#if defined FLAC__CPU_IA32
-# include <signal.h>
-#elif defined FLAC__CPU_PPC
-# if !defined FLAC__NO_ASM
-# if defined FLAC__SYS_DARWIN
-# include <sys/sysctl.h>
-# include <mach/mach.h>
-# include <mach/mach_host.h>
-# include <mach/host_info.h>
-# include <mach/machine.h>
-# ifndef CPU_SUBTYPE_POWERPC_970
-# define CPU_SUBTYPE_POWERPC_970 ((cpu_subtype_t) 100)
-# endif
-# else /* FLAC__SYS_DARWIN */
-
-# include <signal.h>
-# include <setjmp.h>
-
-static sigjmp_buf jmpbuf;
-static volatile sig_atomic_t canjump = 0;
-
-static void sigill_handler (int sig)
-{
- if (!canjump) {
- signal (sig, SIG_DFL);
- raise (sig);
- }
- canjump = 0;
- siglongjmp (jmpbuf, 1);
-}
-# endif /* FLAC__SYS_DARWIN */
-# endif /* FLAC__NO_ASM */
-#endif /* FLAC__CPU_PPC */
-
-#if defined (__NetBSD__) || defined(__OpenBSD__)
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#include <machine/cpu.h>
-#endif
-
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
-#include <sys/types.h>
-#include <sys/sysctl.h>
-#endif
-
-#if defined(__APPLE__)
-/* how to get sysctlbyname()? */
-#endif
-
-/* these are flags in EDX of CPUID AX=00000001 */
-static const unsigned FLAC__CPUINFO_IA32_CPUID_CMOV = 0x00008000;
-static const unsigned FLAC__CPUINFO_IA32_CPUID_MMX = 0x00800000;
-static const unsigned FLAC__CPUINFO_IA32_CPUID_FXSR = 0x01000000;
-static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE = 0x02000000;
-static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE2 = 0x04000000;
-/* these are flags in ECX of CPUID AX=00000001 */
-static const unsigned FLAC__CPUINFO_IA32_CPUID_SSE3 = 0x00000001;
-static const unsigned FLAC__CPUINFO_IA32_CPUID_SSSE3 = 0x00000200;
-/* these are flags in EDX of CPUID AX=80000001 */
-static const unsigned FLAC__CPUINFO_IA32_CPUID_EXTENDED_AMD_3DNOW = 0x80000000;
-static const unsigned FLAC__CPUINFO_IA32_CPUID_EXTENDED_AMD_EXT3DNOW = 0x40000000;
-static const unsigned FLAC__CPUINFO_IA32_CPUID_EXTENDED_AMD_EXTMMX = 0x00400000;
-
-
-/*
- * Extra stuff needed for detection of OS support for SSE on IA-32
- */
-#if defined(FLAC__CPU_IA32) && !defined FLAC__NO_ASM && defined FLAC__HAS_NASM && !defined FLAC__NO_SSE_OS && !defined FLAC__SSE_OS
-# if defined(__linux__)
-/*
- * If the OS doesn't support SSE, we will get here with a SIGILL. We
- * modify the return address to jump over the offending SSE instruction
- * and also the operation following it that indicates the instruction
- * executed successfully. In this way we use no global variables and
- * stay thread-safe.
- *
- * 3 + 3 + 6:
- * 3 bytes for "xorps xmm0,xmm0"
- * 3 bytes for estimate of how long the follwing "inc var" instruction is
- * 6 bytes extra in case our estimate is wrong
- * 12 bytes puts us in the NOP "landing zone"
- */
-# undef USE_OBSOLETE_SIGCONTEXT_FLAVOR /* #define this to use the older signal handler method */
-# ifdef USE_OBSOLETE_SIGCONTEXT_FLAVOR
- static void sigill_handler_sse_os(int signal, struct sigcontext sc)
- {
- (void)signal;
- sc.eip += 3 + 3 + 6;
- }
-# else
-# include <sys/ucontext.h>
- static void sigill_handler_sse_os(int signal, siginfo_t *si, void *uc)
- {
- (void)signal, (void)si;
- ((ucontext_t*)uc)->uc_mcontext.gregs[14/*REG_EIP*/] += 3 + 3 + 6;
- }
-# endif
-# elif defined(_MSC_VER)
-# include <windows.h>
-# define USE_TRY_CATCH_FLAVOR /* sigill_handler flavor resulted in several crash reports on win32 */
-# ifdef USE_TRY_CATCH_FLAVOR
-# else
- LONG CALLBACK sigill_handler_sse_os(EXCEPTION_POINTERS *ep)
- {
- if(ep->ExceptionRecord->ExceptionCode == EXCEPTION_ILLEGAL_INSTRUCTION) {
- ep->ContextRecord->Eip += 3 + 3 + 6;
- return EXCEPTION_CONTINUE_EXECUTION;
- }
- return EXCEPTION_CONTINUE_SEARCH;
- }
-# endif
-# endif
-#endif
-
-
-void FLAC__cpu_info(FLAC__CPUInfo *info)
-{
-/*
- * IA32-specific
- */
-#ifdef FLAC__CPU_IA32
- info->type = FLAC__CPUINFO_TYPE_IA32;
-#if !defined FLAC__NO_ASM && defined FLAC__HAS_NASM
- info->use_asm = true; /* we assume a minimum of 80386 with FLAC__CPU_IA32 */
- info->data.ia32.cpuid = FLAC__cpu_have_cpuid_asm_ia32()? true : false;
- info->data.ia32.bswap = info->data.ia32.cpuid; /* CPUID => BSWAP since it came after */
- info->data.ia32.cmov = false;
- info->data.ia32.mmx = false;
- info->data.ia32.fxsr = false;
- info->data.ia32.sse = false;
- info->data.ia32.sse2 = false;
- info->data.ia32.sse3 = false;
- info->data.ia32.ssse3 = false;
- info->data.ia32._3dnow = false;
- info->data.ia32.ext3dnow = false;
- info->data.ia32.extmmx = false;
- if(info->data.ia32.cpuid) {
- /* http://www.sandpile.org/ia32/cpuid.htm */
- FLAC__uint32 flags_edx, flags_ecx;
- FLAC__cpu_info_asm_ia32(&flags_edx, &flags_ecx);
- info->data.ia32.cmov = (flags_edx & FLAC__CPUINFO_IA32_CPUID_CMOV )? true : false;
- info->data.ia32.mmx = (flags_edx & FLAC__CPUINFO_IA32_CPUID_MMX )? true : false;
- info->data.ia32.fxsr = (flags_edx & FLAC__CPUINFO_IA32_CPUID_FXSR )? true : false;
- info->data.ia32.sse = (flags_edx & FLAC__CPUINFO_IA32_CPUID_SSE )? true : false;
- info->data.ia32.sse2 = (flags_edx & FLAC__CPUINFO_IA32_CPUID_SSE2 )? true : false;
- info->data.ia32.sse3 = (flags_ecx & FLAC__CPUINFO_IA32_CPUID_SSE3 )? true : false;
- info->data.ia32.ssse3 = (flags_ecx & FLAC__CPUINFO_IA32_CPUID_SSSE3)? true : false;
-
-#ifdef FLAC__USE_3DNOW
- flags_edx = FLAC__cpu_info_extended_amd_asm_ia32();
- info->data.ia32._3dnow = (flags_edx & FLAC__CPUINFO_IA32_CPUID_EXTENDED_AMD_3DNOW )? true : false;
- info->data.ia32.ext3dnow = (flags_edx & FLAC__CPUINFO_IA32_CPUID_EXTENDED_AMD_EXT3DNOW)? true : false;
- info->data.ia32.extmmx = (flags_edx & FLAC__CPUINFO_IA32_CPUID_EXTENDED_AMD_EXTMMX )? true : false;
-#else
- info->data.ia32._3dnow = info->data.ia32.ext3dnow = info->data.ia32.extmmx = false;
-#endif
-
-#ifdef DEBUG
- fprintf(stderr, "CPU info (IA-32):\n");
- fprintf(stderr, " CPUID ...... %c\n", info->data.ia32.cpuid ? 'Y' : 'n');
- fprintf(stderr, " BSWAP ...... %c\n", info->data.ia32.bswap ? 'Y' : 'n');
- fprintf(stderr, " CMOV ....... %c\n", info->data.ia32.cmov ? 'Y' : 'n');
- fprintf(stderr, " MMX ........ %c\n", info->data.ia32.mmx ? 'Y' : 'n');
- fprintf(stderr, " FXSR ....... %c\n", info->data.ia32.fxsr ? 'Y' : 'n');
- fprintf(stderr, " SSE ........ %c\n", info->data.ia32.sse ? 'Y' : 'n');
- fprintf(stderr, " SSE2 ....... %c\n", info->data.ia32.sse2 ? 'Y' : 'n');
- fprintf(stderr, " SSE3 ....... %c\n", info->data.ia32.sse3 ? 'Y' : 'n');
- fprintf(stderr, " SSSE3 ...... %c\n", info->data.ia32.ssse3 ? 'Y' : 'n');
- fprintf(stderr, " 3DNow! ..... %c\n", info->data.ia32._3dnow ? 'Y' : 'n');
- fprintf(stderr, " 3DNow!-ext . %c\n", info->data.ia32.ext3dnow? 'Y' : 'n');
- fprintf(stderr, " 3DNow!-MMX . %c\n", info->data.ia32.extmmx ? 'Y' : 'n');
-#endif
-
- /*
- * now have to check for OS support of SSE/SSE2
- */
- if(info->data.ia32.fxsr || info->data.ia32.sse || info->data.ia32.sse2) {
-#if defined FLAC__NO_SSE_OS
- /* assume user knows better than us; turn it off */
- info->data.ia32.fxsr = info->data.ia32.sse = info->data.ia32.sse2 = info->data.ia32.sse3 = info->data.ia32.ssse3 = false;
-#elif defined FLAC__SSE_OS
- /* assume user knows better than us; leave as detected above */
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) || defined(__APPLE__)
- int sse = 0;
- size_t len;
- /* at least one of these must work: */
- len = sizeof(sse); sse = sse || (sysctlbyname("hw.instruction_sse", &sse, &len, NULL, 0) == 0 && sse);
- len = sizeof(sse); sse = sse || (sysctlbyname("hw.optional.sse" , &sse, &len, NULL, 0) == 0 && sse); /* __APPLE__ ? */
- if(!sse)
- info->data.ia32.fxsr = info->data.ia32.sse = info->data.ia32.sse2 = info->data.ia32.sse3 = info->data.ia32.ssse3 = false;
-#elif defined(__NetBSD__) || defined (__OpenBSD__)
-# if __NetBSD_Version__ >= 105250000 || (defined __OpenBSD__)
- int val = 0, mib[2] = { CTL_MACHDEP, CPU_SSE };
- size_t len = sizeof(val);
- if(sysctl(mib, 2, &val, &len, NULL, 0) < 0 || !val)
- info->data.ia32.fxsr = info->data.ia32.sse = info->data.ia32.sse2 = info->data.ia32.sse3 = info->data.ia32.ssse3 = false;
- else { /* double-check SSE2 */
- mib[1] = CPU_SSE2;
- len = sizeof(val);
- if(sysctl(mib, 2, &val, &len, NULL, 0) < 0 || !val)
- info->data.ia32.sse2 = info->data.ia32.sse3 = info->data.ia32.ssse3 = false;
- }
-# else
- info->data.ia32.fxsr = info->data.ia32.sse = info->data.ia32.sse2 = info->data.ia32.sse3 = info->data.ia32.ssse3 = false;
-# endif
-#elif defined(__linux__)
- int sse = 0;
- struct sigaction sigill_save;
-#ifdef USE_OBSOLETE_SIGCONTEXT_FLAVOR
- if(0 == sigaction(SIGILL, NULL, &sigill_save) && signal(SIGILL, (void (*)(int))sigill_handler_sse_os) != SIG_ERR)
-#else
- struct sigaction sigill_sse;
- sigill_sse.sa_sigaction = sigill_handler_sse_os;
- __sigemptyset(&sigill_sse.sa_mask);
- sigill_sse.sa_flags = SA_SIGINFO | SA_RESETHAND; /* SA_RESETHAND just in case our SIGILL return jump breaks, so we don't get stuck in a loop */
- if(0 == sigaction(SIGILL, &sigill_sse, &sigill_save))
-#endif
- {
- /* http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html */
- /* see sigill_handler_sse_os() for an explanation of the following: */
- asm volatile (
- "xorl %0,%0\n\t" /* for some reason, still need to do this to clear 'sse' var */
- "xorps %%xmm0,%%xmm0\n\t" /* will cause SIGILL if unsupported by OS */
- "incl %0\n\t" /* SIGILL handler will jump over this */
- /* landing zone */
- "nop\n\t" /* SIGILL jump lands here if "inc" is 9 bytes */
- "nop\n\t"
- "nop\n\t"
- "nop\n\t"
- "nop\n\t"
- "nop\n\t"
- "nop\n\t" /* SIGILL jump lands here if "inc" is 3 bytes (expected) */
- "nop\n\t"
- "nop" /* SIGILL jump lands here if "inc" is 1 byte */
- : "=r"(sse)
- : "r"(sse)
- );
-
- sigaction(SIGILL, &sigill_save, NULL);
- }
-
- if(!sse)
- info->data.ia32.fxsr = info->data.ia32.sse = info->data.ia32.sse2 = info->data.ia32.sse3 = info->data.ia32.ssse3 = false;
-#elif defined(_MSC_VER)
-# ifdef USE_TRY_CATCH_FLAVOR
- _try {
- __asm {
-# if _MSC_VER <= 1200
- /* VC6 assembler doesn't know SSE, have to emit bytecode instead */
- _emit 0x0F
- _emit 0x57
- _emit 0xC0
-# else
- xorps xmm0,xmm0
-# endif
- }
- }
- _except(EXCEPTION_EXECUTE_HANDLER) {
- if (_exception_code() == STATUS_ILLEGAL_INSTRUCTION)
- info->data.ia32.fxsr = info->data.ia32.sse = info->data.ia32.sse2 = info->data.ia32.sse3 = info->data.ia32.ssse3 = false;
- }
-# else
- int sse = 0;
- LPTOP_LEVEL_EXCEPTION_FILTER save = SetUnhandledExceptionFilter(sigill_handler_sse_os);
- /* see GCC version above for explanation */
- /* http://msdn2.microsoft.com/en-us/library/4ks26t93.aspx */
- /* http://www.codeproject.com/cpp/gccasm.asp */
- /* http://www.hick.org/~mmiller/msvc_inline_asm.html */
- __asm {
-# if _MSC_VER <= 1200
- /* VC6 assembler doesn't know SSE, have to emit bytecode instead */
- _emit 0x0F
- _emit 0x57
- _emit 0xC0
-# else
- xorps xmm0,xmm0
-# endif
- inc sse
- nop
- nop
- nop
- nop
- nop
- nop
- nop
- nop
- nop
- }
- SetUnhandledExceptionFilter(save);
- if(!sse)
- info->data.ia32.fxsr = info->data.ia32.sse = info->data.ia32.sse2 = info->data.ia32.sse3 = info->data.ia32.ssse3 = false;
-# endif
-#else
- /* no way to test, disable to be safe */
- info->data.ia32.fxsr = info->data.ia32.sse = info->data.ia32.sse2 = info->data.ia32.sse3 = info->data.ia32.ssse3 = false;
-#endif
-#ifdef DEBUG
- fprintf(stderr, " SSE OS sup . %c\n", info->data.ia32.sse ? 'Y' : 'n');
-#endif
-
- }
- }
-#else
- info->use_asm = false;
-#endif
-
-/*
- * PPC-specific
- */
-#elif defined FLAC__CPU_PPC
- info->type = FLAC__CPUINFO_TYPE_PPC;
-# if !defined FLAC__NO_ASM
- info->use_asm = true;
-# ifdef FLAC__USE_ALTIVEC
-# if defined FLAC__SYS_DARWIN
- {
- int val = 0, mib[2] = { CTL_HW, HW_VECTORUNIT };
- size_t len = sizeof(val);
- info->data.ppc.altivec = !(sysctl(mib, 2, &val, &len, NULL, 0) || !val);
- }
- {
- host_basic_info_data_t hostInfo;
- mach_msg_type_number_t infoCount;
-
- infoCount = HOST_BASIC_INFO_COUNT;
- host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)&hostInfo, &infoCount);
-
- info->data.ppc.ppc64 = (hostInfo.cpu_type == CPU_TYPE_POWERPC) && (hostInfo.cpu_subtype == CPU_SUBTYPE_POWERPC_970);
- }
-# else /* FLAC__USE_ALTIVEC && !FLAC__SYS_DARWIN */
- {
- /* no Darwin, do it the brute-force way */
- /* @@@@@@ this is not thread-safe; replace with SSE OS method above or remove */
- info->data.ppc.altivec = 0;
- info->data.ppc.ppc64 = 0;
-
- signal (SIGILL, sigill_handler);
- canjump = 0;
- if (!sigsetjmp (jmpbuf, 1)) {
- canjump = 1;
-
- asm volatile (
- "mtspr 256, %0\n\t"
- "vand %%v0, %%v0, %%v0"
- :
- : "r" (-1)
- );
-
- info->data.ppc.altivec = 1;
- }
- canjump = 0;
- if (!sigsetjmp (jmpbuf, 1)) {
- int x = 0;
- canjump = 1;
-
- /* PPC64 hardware implements the cntlzd instruction */
- asm volatile ("cntlzd %0, %1" : "=r" (x) : "r" (x) );
-
- info->data.ppc.ppc64 = 1;
- }
- signal (SIGILL, SIG_DFL); /*@@@@@@ should save and restore old signal */
- }
-# endif
-# else /* !FLAC__USE_ALTIVEC */
- info->data.ppc.altivec = 0;
- info->data.ppc.ppc64 = 0;
-# endif
-# else
- info->use_asm = false;
-# endif
-
-/*
- * unknown CPI
- */
-#else
- info->type = FLAC__CPUINFO_TYPE_UNKNOWN;
- info->use_asm = false;
-#endif
-}
diff --git a/src/thirdparty/libflac/src/libFLAC/crc.c b/src/thirdparty/libflac/src/libFLAC/crc.c
deleted file mode 100644
index 5fa44737f..000000000
--- a/src/thirdparty/libflac/src/libFLAC/crc.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "private/crc.h"
-
-/* CRC-8, poly = x^8 + x^2 + x^1 + x^0, init = 0 */
-
-FLAC__byte const FLAC__crc8_table[256] = {
- 0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15,
- 0x38, 0x3F, 0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D,
- 0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65,
- 0x48, 0x4F, 0x46, 0x41, 0x54, 0x53, 0x5A, 0x5D,
- 0xE0, 0xE7, 0xEE, 0xE9, 0xFC, 0xFB, 0xF2, 0xF5,
- 0xD8, 0xDF, 0xD6, 0xD1, 0xC4, 0xC3, 0xCA, 0xCD,
- 0x90, 0x97, 0x9E, 0x99, 0x8C, 0x8B, 0x82, 0x85,
- 0xA8, 0xAF, 0xA6, 0xA1, 0xB4, 0xB3, 0xBA, 0xBD,
- 0xC7, 0xC0, 0xC9, 0xCE, 0xDB, 0xDC, 0xD5, 0xD2,
- 0xFF, 0xF8, 0xF1, 0xF6, 0xE3, 0xE4, 0xED, 0xEA,
- 0xB7, 0xB0, 0xB9, 0xBE, 0xAB, 0xAC, 0xA5, 0xA2,
- 0x8F, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9D, 0x9A,
- 0x27, 0x20, 0x29, 0x2E, 0x3B, 0x3C, 0x35, 0x32,
- 0x1F, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0D, 0x0A,
- 0x57, 0x50, 0x59, 0x5E, 0x4B, 0x4C, 0x45, 0x42,
- 0x6F, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7D, 0x7A,
- 0x89, 0x8E, 0x87, 0x80, 0x95, 0x92, 0x9B, 0x9C,
- 0xB1, 0xB6, 0xBF, 0xB8, 0xAD, 0xAA, 0xA3, 0xA4,
- 0xF9, 0xFE, 0xF7, 0xF0, 0xE5, 0xE2, 0xEB, 0xEC,
- 0xC1, 0xC6, 0xCF, 0xC8, 0xDD, 0xDA, 0xD3, 0xD4,
- 0x69, 0x6E, 0x67, 0x60, 0x75, 0x72, 0x7B, 0x7C,
- 0x51, 0x56, 0x5F, 0x58, 0x4D, 0x4A, 0x43, 0x44,
- 0x19, 0x1E, 0x17, 0x10, 0x05, 0x02, 0x0B, 0x0C,
- 0x21, 0x26, 0x2F, 0x28, 0x3D, 0x3A, 0x33, 0x34,
- 0x4E, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5C, 0x5B,
- 0x76, 0x71, 0x78, 0x7F, 0x6A, 0x6D, 0x64, 0x63,
- 0x3E, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2C, 0x2B,
- 0x06, 0x01, 0x08, 0x0F, 0x1A, 0x1D, 0x14, 0x13,
- 0xAE, 0xA9, 0xA0, 0xA7, 0xB2, 0xB5, 0xBC, 0xBB,
- 0x96, 0x91, 0x98, 0x9F, 0x8A, 0x8D, 0x84, 0x83,
- 0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB,
- 0xE6, 0xE1, 0xE8, 0xEF, 0xFA, 0xFD, 0xF4, 0xF3
-};
-
-/* CRC-16, poly = x^16 + x^15 + x^2 + x^0, init = 0 */
-
-unsigned const FLAC__crc16_table[256] = {
- 0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011,
- 0x8033, 0x0036, 0x003c, 0x8039, 0x0028, 0x802d, 0x8027, 0x0022,
- 0x8063, 0x0066, 0x006c, 0x8069, 0x0078, 0x807d, 0x8077, 0x0072,
- 0x0050, 0x8055, 0x805f, 0x005a, 0x804b, 0x004e, 0x0044, 0x8041,
- 0x80c3, 0x00c6, 0x00cc, 0x80c9, 0x00d8, 0x80dd, 0x80d7, 0x00d2,
- 0x00f0, 0x80f5, 0x80ff, 0x00fa, 0x80eb, 0x00ee, 0x00e4, 0x80e1,
- 0x00a0, 0x80a5, 0x80af, 0x00aa, 0x80bb, 0x00be, 0x00b4, 0x80b1,
- 0x8093, 0x0096, 0x009c, 0x8099, 0x0088, 0x808d, 0x8087, 0x0082,
- 0x8183, 0x0186, 0x018c, 0x8189, 0x0198, 0x819d, 0x8197, 0x0192,
- 0x01b0, 0x81b5, 0x81bf, 0x01ba, 0x81ab, 0x01ae, 0x01a4, 0x81a1,
- 0x01e0, 0x81e5, 0x81ef, 0x01ea, 0x81fb, 0x01fe, 0x01f4, 0x81f1,
- 0x81d3, 0x01d6, 0x01dc, 0x81d9, 0x01c8, 0x81cd, 0x81c7, 0x01c2,
- 0x0140, 0x8145, 0x814f, 0x014a, 0x815b, 0x015e, 0x0154, 0x8151,
- 0x8173, 0x0176, 0x017c, 0x8179, 0x0168, 0x816d, 0x8167, 0x0162,
- 0x8123, 0x0126, 0x012c, 0x8129, 0x0138, 0x813d, 0x8137, 0x0132,
- 0x0110, 0x8115, 0x811f, 0x011a, 0x810b, 0x010e, 0x0104, 0x8101,
- 0x8303, 0x0306, 0x030c, 0x8309, 0x0318, 0x831d, 0x8317, 0x0312,
- 0x0330, 0x8335, 0x833f, 0x033a, 0x832b, 0x032e, 0x0324, 0x8321,
- 0x0360, 0x8365, 0x836f, 0x036a, 0x837b, 0x037e, 0x0374, 0x8371,
- 0x8353, 0x0356, 0x035c, 0x8359, 0x0348, 0x834d, 0x8347, 0x0342,
- 0x03c0, 0x83c5, 0x83cf, 0x03ca, 0x83db, 0x03de, 0x03d4, 0x83d1,
- 0x83f3, 0x03f6, 0x03fc, 0x83f9, 0x03e8, 0x83ed, 0x83e7, 0x03e2,
- 0x83a3, 0x03a6, 0x03ac, 0x83a9, 0x03b8, 0x83bd, 0x83b7, 0x03b2,
- 0x0390, 0x8395, 0x839f, 0x039a, 0x838b, 0x038e, 0x0384, 0x8381,
- 0x0280, 0x8285, 0x828f, 0x028a, 0x829b, 0x029e, 0x0294, 0x8291,
- 0x82b3, 0x02b6, 0x02bc, 0x82b9, 0x02a8, 0x82ad, 0x82a7, 0x02a2,
- 0x82e3, 0x02e6, 0x02ec, 0x82e9, 0x02f8, 0x82fd, 0x82f7, 0x02f2,
- 0x02d0, 0x82d5, 0x82df, 0x02da, 0x82cb, 0x02ce, 0x02c4, 0x82c1,
- 0x8243, 0x0246, 0x024c, 0x8249, 0x0258, 0x825d, 0x8257, 0x0252,
- 0x0270, 0x8275, 0x827f, 0x027a, 0x826b, 0x026e, 0x0264, 0x8261,
- 0x0220, 0x8225, 0x822f, 0x022a, 0x823b, 0x023e, 0x0234, 0x8231,
- 0x8213, 0x0216, 0x021c, 0x8219, 0x0208, 0x820d, 0x8207, 0x0202
-};
-
-
-void FLAC__crc8_update(const FLAC__byte data, FLAC__uint8 *crc)
-{
- *crc = FLAC__crc8_table[*crc ^ data];
-}
-
-void FLAC__crc8_update_block(const FLAC__byte *data, unsigned len, FLAC__uint8 *crc)
-{
- while(len--)
- *crc = FLAC__crc8_table[*crc ^ *data++];
-}
-
-FLAC__uint8 FLAC__crc8(const FLAC__byte *data, unsigned len)
-{
- FLAC__uint8 crc = 0;
-
- while(len--)
- crc = FLAC__crc8_table[crc ^ *data++];
-
- return crc;
-}
-
-unsigned FLAC__crc16(const FLAC__byte *data, unsigned len)
-{
- unsigned crc = 0;
-
- while(len--)
- crc = ((crc<<8) ^ FLAC__crc16_table[(crc>>8) ^ *data++]) & 0xffff;
-
- return crc;
-}
diff --git a/src/thirdparty/libflac/src/libFLAC/fixed.c b/src/thirdparty/libflac/src/libFLAC/fixed.c
deleted file mode 100644
index cca0a8923..000000000
--- a/src/thirdparty/libflac/src/libFLAC/fixed.c
+++ /dev/null
@@ -1,435 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <math.h>
-#include <string.h>
-#include "private/bitmath.h"
-#include "private/fixed.h"
-#include "FLAC/assert.h"
-
-#ifndef M_LN2
-/* math.h in VC++ doesn't seem to have this (how Microsoft is that?) */
-#define M_LN2 0.69314718055994530942
-#endif
-
-#ifdef min
-#undef min
-#endif
-#define min(x,y) ((x) < (y)? (x) : (y))
-
-#ifdef local_abs
-#undef local_abs
-#endif
-#define local_abs(x) ((unsigned)((x)<0? -(x) : (x)))
-
-#ifdef FLAC__INTEGER_ONLY_LIBRARY
-/* rbps stands for residual bits per sample
- *
- * (ln(2) * err)
- * rbps = log (-----------)
- * 2 ( n )
- */
-static FLAC__fixedpoint local__compute_rbps_integerized(FLAC__uint32 err, FLAC__uint32 n)
-{
- FLAC__uint32 rbps;
- unsigned bits; /* the number of bits required to represent a number */
- int fracbits; /* the number of bits of rbps that comprise the fractional part */
-
- FLAC__ASSERT(sizeof(rbps) == sizeof(FLAC__fixedpoint));
- FLAC__ASSERT(err > 0);
- FLAC__ASSERT(n > 0);
-
- FLAC__ASSERT(n <= FLAC__MAX_BLOCK_SIZE);
- if(err <= n)
- return 0;
- /*
- * The above two things tell us 1) n fits in 16 bits; 2) err/n > 1.
- * These allow us later to know we won't lose too much precision in the
- * fixed-point division (err<<fracbits)/n.
- */
-
- fracbits = (8*sizeof(err)) - (FLAC__bitmath_ilog2(err)+1);
-
- err <<= fracbits;
- err /= n;
- /* err now holds err/n with fracbits fractional bits */
-
- /*
- * Whittle err down to 16 bits max. 16 significant bits is enough for
- * our purposes.
- */
- FLAC__ASSERT(err > 0);
- bits = FLAC__bitmath_ilog2(err)+1;
- if(bits > 16) {
- err >>= (bits-16);
- fracbits -= (bits-16);
- }
- rbps = (FLAC__uint32)err;
-
- /* Multiply by fixed-point version of ln(2), with 16 fractional bits */
- rbps *= FLAC__FP_LN2;
- fracbits += 16;
- FLAC__ASSERT(fracbits >= 0);
-
- /* FLAC__fixedpoint_log2 requires fracbits%4 to be 0 */
- {
- const int f = fracbits & 3;
- if(f) {
- rbps >>= f;
- fracbits -= f;
- }
- }
-
- rbps = FLAC__fixedpoint_log2(rbps, fracbits, (unsigned)(-1));
-
- if(rbps == 0)
- return 0;
-
- /*
- * The return value must have 16 fractional bits. Since the whole part
- * of the base-2 log of a 32 bit number must fit in 5 bits, and fracbits
- * must be >= -3, these assertion allows us to be able to shift rbps
- * left if necessary to get 16 fracbits without losing any bits of the
- * whole part of rbps.
- *
- * There is a slight chance due to accumulated error that the whole part
- * will require 6 bits, so we use 6 in the assertion. Really though as
- * long as it fits in 13 bits (32 - (16 - (-3))) we are fine.
- */
- FLAC__ASSERT((int)FLAC__bitmath_ilog2(rbps)+1 <= fracbits + 6);
- FLAC__ASSERT(fracbits >= -3);
-
- /* now shift the decimal point into place */
- if(fracbits < 16)
- return rbps << (16-fracbits);
- else if(fracbits > 16)
- return rbps >> (fracbits-16);
- else
- return rbps;
-}
-
-static FLAC__fixedpoint local__compute_rbps_wide_integerized(FLAC__uint64 err, FLAC__uint32 n)
-{
- FLAC__uint32 rbps;
- unsigned bits; /* the number of bits required to represent a number */
- int fracbits; /* the number of bits of rbps that comprise the fractional part */
-
- FLAC__ASSERT(sizeof(rbps) == sizeof(FLAC__fixedpoint));
- FLAC__ASSERT(err > 0);
- FLAC__ASSERT(n > 0);
-
- FLAC__ASSERT(n <= FLAC__MAX_BLOCK_SIZE);
- if(err <= n)
- return 0;
- /*
- * The above two things tell us 1) n fits in 16 bits; 2) err/n > 1.
- * These allow us later to know we won't lose too much precision in the
- * fixed-point division (err<<fracbits)/n.
- */
-
- fracbits = (8*sizeof(err)) - (FLAC__bitmath_ilog2_wide(err)+1);
-
- err <<= fracbits;
- err /= n;
- /* err now holds err/n with fracbits fractional bits */
-
- /*
- * Whittle err down to 16 bits max. 16 significant bits is enough for
- * our purposes.
- */
- FLAC__ASSERT(err > 0);
- bits = FLAC__bitmath_ilog2_wide(err)+1;
- if(bits > 16) {
- err >>= (bits-16);
- fracbits -= (bits-16);
- }
- rbps = (FLAC__uint32)err;
-
- /* Multiply by fixed-point version of ln(2), with 16 fractional bits */
- rbps *= FLAC__FP_LN2;
- fracbits += 16;
- FLAC__ASSERT(fracbits >= 0);
-
- /* FLAC__fixedpoint_log2 requires fracbits%4 to be 0 */
- {
- const int f = fracbits & 3;
- if(f) {
- rbps >>= f;
- fracbits -= f;
- }
- }
-
- rbps = FLAC__fixedpoint_log2(rbps, fracbits, (unsigned)(-1));
-
- if(rbps == 0)
- return 0;
-
- /*
- * The return value must have 16 fractional bits. Since the whole part
- * of the base-2 log of a 32 bit number must fit in 5 bits, and fracbits
- * must be >= -3, these assertion allows us to be able to shift rbps
- * left if necessary to get 16 fracbits without losing any bits of the
- * whole part of rbps.
- *
- * There is a slight chance due to accumulated error that the whole part
- * will require 6 bits, so we use 6 in the assertion. Really though as
- * long as it fits in 13 bits (32 - (16 - (-3))) we are fine.
- */
- FLAC__ASSERT((int)FLAC__bitmath_ilog2(rbps)+1 <= fracbits + 6);
- FLAC__ASSERT(fracbits >= -3);
-
- /* now shift the decimal point into place */
- if(fracbits < 16)
- return rbps << (16-fracbits);
- else if(fracbits > 16)
- return rbps >> (fracbits-16);
- else
- return rbps;
-}
-#endif
-
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
-unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1])
-#else
-unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1])
-#endif
-{
- FLAC__int32 last_error_0 = data[-1];
- FLAC__int32 last_error_1 = data[-1] - data[-2];
- FLAC__int32 last_error_2 = last_error_1 - (data[-2] - data[-3]);
- FLAC__int32 last_error_3 = last_error_2 - (data[-2] - 2*data[-3] + data[-4]);
- FLAC__int32 error, save;
- FLAC__uint32 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0;
- unsigned i, order;
-
- for(i = 0; i < data_len; i++) {
- error = data[i] ; total_error_0 += local_abs(error); save = error;
- error -= last_error_0; total_error_1 += local_abs(error); last_error_0 = save; save = error;
- error -= last_error_1; total_error_2 += local_abs(error); last_error_1 = save; save = error;
- error -= last_error_2; total_error_3 += local_abs(error); last_error_2 = save; save = error;
- error -= last_error_3; total_error_4 += local_abs(error); last_error_3 = save;
- }
-
- if(total_error_0 < min(min(min(total_error_1, total_error_2), total_error_3), total_error_4))
- order = 0;
- else if(total_error_1 < min(min(total_error_2, total_error_3), total_error_4))
- order = 1;
- else if(total_error_2 < min(total_error_3, total_error_4))
- order = 2;
- else if(total_error_3 < total_error_4)
- order = 3;
- else
- order = 4;
-
- /* Estimate the expected number of bits per residual signal sample. */
- /* 'total_error*' is linearly related to the variance of the residual */
- /* signal, so we use it directly to compute E(|x|) */
- FLAC__ASSERT(data_len > 0 || total_error_0 == 0);
- FLAC__ASSERT(data_len > 0 || total_error_1 == 0);
- FLAC__ASSERT(data_len > 0 || total_error_2 == 0);
- FLAC__ASSERT(data_len > 0 || total_error_3 == 0);
- FLAC__ASSERT(data_len > 0 || total_error_4 == 0);
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
- residual_bits_per_sample[0] = (FLAC__float)((total_error_0 > 0) ? log(M_LN2 * (FLAC__double)total_error_0 / (FLAC__double)data_len) / M_LN2 : 0.0);
- residual_bits_per_sample[1] = (FLAC__float)((total_error_1 > 0) ? log(M_LN2 * (FLAC__double)total_error_1 / (FLAC__double)data_len) / M_LN2 : 0.0);
- residual_bits_per_sample[2] = (FLAC__float)((total_error_2 > 0) ? log(M_LN2 * (FLAC__double)total_error_2 / (FLAC__double)data_len) / M_LN2 : 0.0);
- residual_bits_per_sample[3] = (FLAC__float)((total_error_3 > 0) ? log(M_LN2 * (FLAC__double)total_error_3 / (FLAC__double)data_len) / M_LN2 : 0.0);
- residual_bits_per_sample[4] = (FLAC__float)((total_error_4 > 0) ? log(M_LN2 * (FLAC__double)total_error_4 / (FLAC__double)data_len) / M_LN2 : 0.0);
-#else
- residual_bits_per_sample[0] = (total_error_0 > 0) ? local__compute_rbps_integerized(total_error_0, data_len) : 0;
- residual_bits_per_sample[1] = (total_error_1 > 0) ? local__compute_rbps_integerized(total_error_1, data_len) : 0;
- residual_bits_per_sample[2] = (total_error_2 > 0) ? local__compute_rbps_integerized(total_error_2, data_len) : 0;
- residual_bits_per_sample[3] = (total_error_3 > 0) ? local__compute_rbps_integerized(total_error_3, data_len) : 0;
- residual_bits_per_sample[4] = (total_error_4 > 0) ? local__compute_rbps_integerized(total_error_4, data_len) : 0;
-#endif
-
- return order;
-}
-
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
-unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1])
-#else
-unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsigned data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1])
-#endif
-{
- FLAC__int32 last_error_0 = data[-1];
- FLAC__int32 last_error_1 = data[-1] - data[-2];
- FLAC__int32 last_error_2 = last_error_1 - (data[-2] - data[-3]);
- FLAC__int32 last_error_3 = last_error_2 - (data[-2] - 2*data[-3] + data[-4]);
- FLAC__int32 error, save;
- /* total_error_* are 64-bits to avoid overflow when encoding
- * erratic signals when the bits-per-sample and blocksize are
- * large.
- */
- FLAC__uint64 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0;
- unsigned i, order;
-
- for(i = 0; i < data_len; i++) {
- error = data[i] ; total_error_0 += local_abs(error); save = error;
- error -= last_error_0; total_error_1 += local_abs(error); last_error_0 = save; save = error;
- error -= last_error_1; total_error_2 += local_abs(error); last_error_1 = save; save = error;
- error -= last_error_2; total_error_3 += local_abs(error); last_error_2 = save; save = error;
- error -= last_error_3; total_error_4 += local_abs(error); last_error_3 = save;
- }
-
- if(total_error_0 < min(min(min(total_error_1, total_error_2), total_error_3), total_error_4))
- order = 0;
- else if(total_error_1 < min(min(total_error_2, total_error_3), total_error_4))
- order = 1;
- else if(total_error_2 < min(total_error_3, total_error_4))
- order = 2;
- else if(total_error_3 < total_error_4)
- order = 3;
- else
- order = 4;
-
- /* Estimate the expected number of bits per residual signal sample. */
- /* 'total_error*' is linearly related to the variance of the residual */
- /* signal, so we use it directly to compute E(|x|) */
- FLAC__ASSERT(data_len > 0 || total_error_0 == 0);
- FLAC__ASSERT(data_len > 0 || total_error_1 == 0);
- FLAC__ASSERT(data_len > 0 || total_error_2 == 0);
- FLAC__ASSERT(data_len > 0 || total_error_3 == 0);
- FLAC__ASSERT(data_len > 0 || total_error_4 == 0);
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
-#if defined _MSC_VER || defined __MINGW32__
- /* with MSVC you have to spoon feed it the casting */
- residual_bits_per_sample[0] = (FLAC__float)((total_error_0 > 0) ? log(M_LN2 * (FLAC__double)(FLAC__int64)total_error_0 / (FLAC__double)data_len) / M_LN2 : 0.0);
- residual_bits_per_sample[1] = (FLAC__float)((total_error_1 > 0) ? log(M_LN2 * (FLAC__double)(FLAC__int64)total_error_1 / (FLAC__double)data_len) / M_LN2 : 0.0);
- residual_bits_per_sample[2] = (FLAC__float)((total_error_2 > 0) ? log(M_LN2 * (FLAC__double)(FLAC__int64)total_error_2 / (FLAC__double)data_len) / M_LN2 : 0.0);
- residual_bits_per_sample[3] = (FLAC__float)((total_error_3 > 0) ? log(M_LN2 * (FLAC__double)(FLAC__int64)total_error_3 / (FLAC__double)data_len) / M_LN2 : 0.0);
- residual_bits_per_sample[4] = (FLAC__float)((total_error_4 > 0) ? log(M_LN2 * (FLAC__double)(FLAC__int64)total_error_4 / (FLAC__double)data_len) / M_LN2 : 0.0);
-#else
- residual_bits_per_sample[0] = (FLAC__float)((total_error_0 > 0) ? log(M_LN2 * (FLAC__double)total_error_0 / (FLAC__double)data_len) / M_LN2 : 0.0);
- residual_bits_per_sample[1] = (FLAC__float)((total_error_1 > 0) ? log(M_LN2 * (FLAC__double)total_error_1 / (FLAC__double)data_len) / M_LN2 : 0.0);
- residual_bits_per_sample[2] = (FLAC__float)((total_error_2 > 0) ? log(M_LN2 * (FLAC__double)total_error_2 / (FLAC__double)data_len) / M_LN2 : 0.0);
- residual_bits_per_sample[3] = (FLAC__float)((total_error_3 > 0) ? log(M_LN2 * (FLAC__double)total_error_3 / (FLAC__double)data_len) / M_LN2 : 0.0);
- residual_bits_per_sample[4] = (FLAC__float)((total_error_4 > 0) ? log(M_LN2 * (FLAC__double)total_error_4 / (FLAC__double)data_len) / M_LN2 : 0.0);
-#endif
-#else
- residual_bits_per_sample[0] = (total_error_0 > 0) ? local__compute_rbps_wide_integerized(total_error_0, data_len) : 0;
- residual_bits_per_sample[1] = (total_error_1 > 0) ? local__compute_rbps_wide_integerized(total_error_1, data_len) : 0;
- residual_bits_per_sample[2] = (total_error_2 > 0) ? local__compute_rbps_wide_integerized(total_error_2, data_len) : 0;
- residual_bits_per_sample[3] = (total_error_3 > 0) ? local__compute_rbps_wide_integerized(total_error_3, data_len) : 0;
- residual_bits_per_sample[4] = (total_error_4 > 0) ? local__compute_rbps_wide_integerized(total_error_4, data_len) : 0;
-#endif
-
- return order;
-}
-
-void FLAC__fixed_compute_residual(const FLAC__int32 data[], unsigned data_len, unsigned order, FLAC__int32 residual[])
-{
- const int idata_len = (int)data_len;
- int i;
-
- switch(order) {
- case 0:
- FLAC__ASSERT(sizeof(residual[0]) == sizeof(data[0]));
- memcpy(residual, data, sizeof(residual[0])*data_len);
- break;
- case 1:
- for(i = 0; i < idata_len; i++)
- residual[i] = data[i] - data[i-1];
- break;
- case 2:
- for(i = 0; i < idata_len; i++)
-#if 1 /* OPT: may be faster with some compilers on some systems */
- residual[i] = data[i] - (data[i-1] << 1) + data[i-2];
-#else
- residual[i] = data[i] - 2*data[i-1] + data[i-2];
-#endif
- break;
- case 3:
- for(i = 0; i < idata_len; i++)
-#if 1 /* OPT: may be faster with some compilers on some systems */
- residual[i] = data[i] - (((data[i-1]-data[i-2])<<1) + (data[i-1]-data[i-2])) - data[i-3];
-#else
- residual[i] = data[i] - 3*data[i-1] + 3*data[i-2] - data[i-3];
-#endif
- break;
- case 4:
- for(i = 0; i < idata_len; i++)
-#if 1 /* OPT: may be faster with some compilers on some systems */
- residual[i] = data[i] - ((data[i-1]+data[i-3])<<2) + ((data[i-2]<<2) + (data[i-2]<<1)) + data[i-4];
-#else
- residual[i] = data[i] - 4*data[i-1] + 6*data[i-2] - 4*data[i-3] + data[i-4];
-#endif
- break;
- default:
- FLAC__ASSERT(0);
- }
-}
-
-void FLAC__fixed_restore_signal(const FLAC__int32 residual[], unsigned data_len, unsigned order, FLAC__int32 data[])
-{
- int i, idata_len = (int)data_len;
-
- switch(order) {
- case 0:
- FLAC__ASSERT(sizeof(residual[0]) == sizeof(data[0]));
- memcpy(data, residual, sizeof(residual[0])*data_len);
- break;
- case 1:
- for(i = 0; i < idata_len; i++)
- data[i] = residual[i] + data[i-1];
- break;
- case 2:
- for(i = 0; i < idata_len; i++)
-#if 1 /* OPT: may be faster with some compilers on some systems */
- data[i] = residual[i] + (data[i-1]<<1) - data[i-2];
-#else
- data[i] = residual[i] + 2*data[i-1] - data[i-2];
-#endif
- break;
- case 3:
- for(i = 0; i < idata_len; i++)
-#if 1 /* OPT: may be faster with some compilers on some systems */
- data[i] = residual[i] + (((data[i-1]-data[i-2])<<1) + (data[i-1]-data[i-2])) + data[i-3];
-#else
- data[i] = residual[i] + 3*data[i-1] - 3*data[i-2] + data[i-3];
-#endif
- break;
- case 4:
- for(i = 0; i < idata_len; i++)
-#if 1 /* OPT: may be faster with some compilers on some systems */
- data[i] = residual[i] + ((data[i-1]+data[i-3])<<2) - ((data[i-2]<<2) + (data[i-2]<<1)) - data[i-4];
-#else
- data[i] = residual[i] + 4*data[i-1] - 6*data[i-2] + 4*data[i-3] - data[i-4];
-#endif
- break;
- default:
- FLAC__ASSERT(0);
- }
-}
diff --git a/src/thirdparty/libflac/src/libFLAC/float.c b/src/thirdparty/libflac/src/libFLAC/float.c
deleted file mode 100644
index 139da180b..000000000
--- a/src/thirdparty/libflac/src/libFLAC/float.c
+++ /dev/null
@@ -1,308 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "FLAC/assert.h"
-
-#include "private/float.h"
-
-#ifdef FLAC__INTEGER_ONLY_LIBRARY
-
-/* adjust for compilers that can't understand using LLU suffix for uint64_t literals */
-#ifdef _MSC_VER
-#define FLAC__U64L(x) x
-#else
-#define FLAC__U64L(x) x##LLU
-#endif
-
-const FLAC__fixedpoint FLAC__FP_ZERO = 0;
-const FLAC__fixedpoint FLAC__FP_ONE_HALF = 0x00008000;
-const FLAC__fixedpoint FLAC__FP_ONE = 0x00010000;
-const FLAC__fixedpoint FLAC__FP_LN2 = 45426;
-const FLAC__fixedpoint FLAC__FP_E = 178145;
-
-/* Lookup tables for Knuth's logarithm algorithm */
-#define LOG2_LOOKUP_PRECISION 16
-static const FLAC__uint32 log2_lookup[][LOG2_LOOKUP_PRECISION] = {
- {
- /*
- * 0 fraction bits
- */
- /* undefined */ 0x00000000,
- /* lg(2/1) = */ 0x00000001,
- /* lg(4/3) = */ 0x00000000,
- /* lg(8/7) = */ 0x00000000,
- /* lg(16/15) = */ 0x00000000,
- /* lg(32/31) = */ 0x00000000,
- /* lg(64/63) = */ 0x00000000,
- /* lg(128/127) = */ 0x00000000,
- /* lg(256/255) = */ 0x00000000,
- /* lg(512/511) = */ 0x00000000,
- /* lg(1024/1023) = */ 0x00000000,
- /* lg(2048/2047) = */ 0x00000000,
- /* lg(4096/4095) = */ 0x00000000,
- /* lg(8192/8191) = */ 0x00000000,
- /* lg(16384/16383) = */ 0x00000000,
- /* lg(32768/32767) = */ 0x00000000
- },
- {
- /*
- * 4 fraction bits
- */
- /* undefined */ 0x00000000,
- /* lg(2/1) = */ 0x00000010,
- /* lg(4/3) = */ 0x00000007,
- /* lg(8/7) = */ 0x00000003,
- /* lg(16/15) = */ 0x00000001,
- /* lg(32/31) = */ 0x00000001,
- /* lg(64/63) = */ 0x00000000,
- /* lg(128/127) = */ 0x00000000,
- /* lg(256/255) = */ 0x00000000,
- /* lg(512/511) = */ 0x00000000,
- /* lg(1024/1023) = */ 0x00000000,
- /* lg(2048/2047) = */ 0x00000000,
- /* lg(4096/4095) = */ 0x00000000,
- /* lg(8192/8191) = */ 0x00000000,
- /* lg(16384/16383) = */ 0x00000000,
- /* lg(32768/32767) = */ 0x00000000
- },
- {
- /*
- * 8 fraction bits
- */
- /* undefined */ 0x00000000,
- /* lg(2/1) = */ 0x00000100,
- /* lg(4/3) = */ 0x0000006a,
- /* lg(8/7) = */ 0x00000031,
- /* lg(16/15) = */ 0x00000018,
- /* lg(32/31) = */ 0x0000000c,
- /* lg(64/63) = */ 0x00000006,
- /* lg(128/127) = */ 0x00000003,
- /* lg(256/255) = */ 0x00000001,
- /* lg(512/511) = */ 0x00000001,
- /* lg(1024/1023) = */ 0x00000000,
- /* lg(2048/2047) = */ 0x00000000,
- /* lg(4096/4095) = */ 0x00000000,
- /* lg(8192/8191) = */ 0x00000000,
- /* lg(16384/16383) = */ 0x00000000,
- /* lg(32768/32767) = */ 0x00000000
- },
- {
- /*
- * 12 fraction bits
- */
- /* undefined */ 0x00000000,
- /* lg(2/1) = */ 0x00001000,
- /* lg(4/3) = */ 0x000006a4,
- /* lg(8/7) = */ 0x00000315,
- /* lg(16/15) = */ 0x0000017d,
- /* lg(32/31) = */ 0x000000bc,
- /* lg(64/63) = */ 0x0000005d,
- /* lg(128/127) = */ 0x0000002e,
- /* lg(256/255) = */ 0x00000017,
- /* lg(512/511) = */ 0x0000000c,
- /* lg(1024/1023) = */ 0x00000006,
- /* lg(2048/2047) = */ 0x00000003,
- /* lg(4096/4095) = */ 0x00000001,
- /* lg(8192/8191) = */ 0x00000001,
- /* lg(16384/16383) = */ 0x00000000,
- /* lg(32768/32767) = */ 0x00000000
- },
- {
- /*
- * 16 fraction bits
- */
- /* undefined */ 0x00000000,
- /* lg(2/1) = */ 0x00010000,
- /* lg(4/3) = */ 0x00006a40,
- /* lg(8/7) = */ 0x00003151,
- /* lg(16/15) = */ 0x000017d6,
- /* lg(32/31) = */ 0x00000bba,
- /* lg(64/63) = */ 0x000005d1,
- /* lg(128/127) = */ 0x000002e6,
- /* lg(256/255) = */ 0x00000172,
- /* lg(512/511) = */ 0x000000b9,
- /* lg(1024/1023) = */ 0x0000005c,
- /* lg(2048/2047) = */ 0x0000002e,
- /* lg(4096/4095) = */ 0x00000017,
- /* lg(8192/8191) = */ 0x0000000c,
- /* lg(16384/16383) = */ 0x00000006,
- /* lg(32768/32767) = */ 0x00000003
- },
- {
- /*
- * 20 fraction bits
- */
- /* undefined */ 0x00000000,
- /* lg(2/1) = */ 0x00100000,
- /* lg(4/3) = */ 0x0006a3fe,
- /* lg(8/7) = */ 0x00031513,
- /* lg(16/15) = */ 0x00017d60,
- /* lg(32/31) = */ 0x0000bb9d,
- /* lg(64/63) = */ 0x00005d10,
- /* lg(128/127) = */ 0x00002e59,
- /* lg(256/255) = */ 0x00001721,
- /* lg(512/511) = */ 0x00000b8e,
- /* lg(1024/1023) = */ 0x000005c6,
- /* lg(2048/2047) = */ 0x000002e3,
- /* lg(4096/4095) = */ 0x00000171,
- /* lg(8192/8191) = */ 0x000000b9,
- /* lg(16384/16383) = */ 0x0000005c,
- /* lg(32768/32767) = */ 0x0000002e
- },
- {
- /*
- * 24 fraction bits
- */
- /* undefined */ 0x00000000,
- /* lg(2/1) = */ 0x01000000,
- /* lg(4/3) = */ 0x006a3fe6,
- /* lg(8/7) = */ 0x00315130,
- /* lg(16/15) = */ 0x0017d605,
- /* lg(32/31) = */ 0x000bb9ca,
- /* lg(64/63) = */ 0x0005d0fc,
- /* lg(128/127) = */ 0x0002e58f,
- /* lg(256/255) = */ 0x0001720e,
- /* lg(512/511) = */ 0x0000b8d8,
- /* lg(1024/1023) = */ 0x00005c61,
- /* lg(2048/2047) = */ 0x00002e2d,
- /* lg(4096/4095) = */ 0x00001716,
- /* lg(8192/8191) = */ 0x00000b8b,
- /* lg(16384/16383) = */ 0x000005c5,
- /* lg(32768/32767) = */ 0x000002e3
- },
- {
- /*
- * 28 fraction bits
- */
- /* undefined */ 0x00000000,
- /* lg(2/1) = */ 0x10000000,
- /* lg(4/3) = */ 0x06a3fe5c,
- /* lg(8/7) = */ 0x03151301,
- /* lg(16/15) = */ 0x017d6049,
- /* lg(32/31) = */ 0x00bb9ca6,
- /* lg(64/63) = */ 0x005d0fba,
- /* lg(128/127) = */ 0x002e58f7,
- /* lg(256/255) = */ 0x001720da,
- /* lg(512/511) = */ 0x000b8d87,
- /* lg(1024/1023) = */ 0x0005c60b,
- /* lg(2048/2047) = */ 0x0002e2d7,
- /* lg(4096/4095) = */ 0x00017160,
- /* lg(8192/8191) = */ 0x0000b8ad,
- /* lg(16384/16383) = */ 0x00005c56,
- /* lg(32768/32767) = */ 0x00002e2b
- }
-};
-
-#if 0
-static const FLAC__uint64 log2_lookup_wide[] = {
- {
- /*
- * 32 fraction bits
- */
- /* undefined */ 0x00000000,
- /* lg(2/1) = */ FLAC__U64L(0x100000000),
- /* lg(4/3) = */ FLAC__U64L(0x6a3fe5c6),
- /* lg(8/7) = */ FLAC__U64L(0x31513015),
- /* lg(16/15) = */ FLAC__U64L(0x17d60497),
- /* lg(32/31) = */ FLAC__U64L(0x0bb9ca65),
- /* lg(64/63) = */ FLAC__U64L(0x05d0fba2),
- /* lg(128/127) = */ FLAC__U64L(0x02e58f74),
- /* lg(256/255) = */ FLAC__U64L(0x01720d9c),
- /* lg(512/511) = */ FLAC__U64L(0x00b8d875),
- /* lg(1024/1023) = */ FLAC__U64L(0x005c60aa),
- /* lg(2048/2047) = */ FLAC__U64L(0x002e2d72),
- /* lg(4096/4095) = */ FLAC__U64L(0x00171600),
- /* lg(8192/8191) = */ FLAC__U64L(0x000b8ad2),
- /* lg(16384/16383) = */ FLAC__U64L(0x0005c55d),
- /* lg(32768/32767) = */ FLAC__U64L(0x0002e2ac)
- },
- {
- /*
- * 48 fraction bits
- */
- /* undefined */ 0x00000000,
- /* lg(2/1) = */ FLAC__U64L(0x1000000000000),
- /* lg(4/3) = */ FLAC__U64L(0x6a3fe5c60429),
- /* lg(8/7) = */ FLAC__U64L(0x315130157f7a),
- /* lg(16/15) = */ FLAC__U64L(0x17d60496cfbb),
- /* lg(32/31) = */ FLAC__U64L(0xbb9ca64ecac),
- /* lg(64/63) = */ FLAC__U64L(0x5d0fba187cd),
- /* lg(128/127) = */ FLAC__U64L(0x2e58f7441ee),
- /* lg(256/255) = */ FLAC__U64L(0x1720d9c06a8),
- /* lg(512/511) = */ FLAC__U64L(0xb8d8752173),
- /* lg(1024/1023) = */ FLAC__U64L(0x5c60aa252e),
- /* lg(2048/2047) = */ FLAC__U64L(0x2e2d71b0d8),
- /* lg(4096/4095) = */ FLAC__U64L(0x1716001719),
- /* lg(8192/8191) = */ FLAC__U64L(0xb8ad1de1b),
- /* lg(16384/16383) = */ FLAC__U64L(0x5c55d640d),
- /* lg(32768/32767) = */ FLAC__U64L(0x2e2abcf52)
- }
-};
-#endif
-
-FLAC__uint32 FLAC__fixedpoint_log2(FLAC__uint32 x, unsigned fracbits, unsigned precision)
-{
- const FLAC__uint32 ONE = (1u << fracbits);
- const FLAC__uint32 *table = log2_lookup[fracbits >> 2];
-
- FLAC__ASSERT(fracbits < 32);
- FLAC__ASSERT((fracbits & 0x3) == 0);
-
- if(x < ONE)
- return 0;
-
- if(precision > LOG2_LOOKUP_PRECISION)
- precision = LOG2_LOOKUP_PRECISION;
-
- /* Knuth's algorithm for computing logarithms, optimized for base-2 with lookup tables */
- {
- FLAC__uint32 y = 0;
- FLAC__uint32 z = x >> 1, k = 1;
- while (x > ONE && k < precision) {
- if (x - z >= ONE) {
- x -= z;
- z = x >> k;
- y += table[k];
- }
- else {
- z >>= 1;
- k++;
- }
- }
- return y;
- }
-}
-
-#endif /* defined FLAC__INTEGER_ONLY_LIBRARY */
diff --git a/src/thirdparty/libflac/src/libFLAC/format.c b/src/thirdparty/libflac/src/libFLAC/format.c
deleted file mode 100644
index a2db3ca8a..000000000
--- a/src/thirdparty/libflac/src/libFLAC/format.c
+++ /dev/null
@@ -1,599 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h> /* for qsort() */
-#include <string.h> /* for memset() */
-#include "FLAC/assert.h"
-#include "FLAC/format.h"
-#include "private/format.h"
-
-#ifdef min
-#undef min
-#endif
-#define min(a,b) ((a)<(b)?(a):(b))
-
-/* adjust for compilers that can't understand using LLU suffix for uint64_t literals */
-#ifdef _MSC_VER
-#define FLAC__U64L(x) x
-#else
-#define FLAC__U64L(x) x##LLU
-#endif
-
-/* VERSION should come from configure */
-FLAC_API const char *FLAC__VERSION_STRING = VERSION;
-
-#if defined _MSC_VER || defined __BORLANDC__ || defined __MINW32__
-/* yet one more hack because of MSVC6: */
-FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC 1.2.1 20070917";
-#else
-FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC " VERSION " 20070917";
-#endif
-
-FLAC_API const FLAC__byte FLAC__STREAM_SYNC_STRING[4] = { 'f','L','a','C' };
-FLAC_API const unsigned FLAC__STREAM_SYNC = 0x664C6143;
-FLAC_API const unsigned FLAC__STREAM_SYNC_LEN = 32; /* bits */
-
-FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN = 16; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN = 16; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN = 24; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN = 24; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN = 20; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN = 3; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN = 5; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN = 36; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_STREAMINFO_MD5SUM_LEN = 128; /* bits */
-
-FLAC_API const unsigned FLAC__STREAM_METADATA_APPLICATION_ID_LEN = 32; /* bits */
-
-FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN = 64; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN = 64; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN = 16; /* bits */
-
-FLAC_API const FLAC__uint64 FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER = FLAC__U64L(0xffffffffffffffff);
-
-FLAC_API const unsigned FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN = 32; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN = 32; /* bits */
-
-FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN = 64; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN = 8; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN = 3*8; /* bits */
-
-FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN = 64; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN = 8; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN = 12*8; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN = 1; /* bit */
-FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN = 1; /* bit */
-FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN = 6+13*8; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN = 8; /* bits */
-
-FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN = 128*8; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN = 64; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN = 1; /* bit */
-FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN = 7+258*8; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN = 8; /* bits */
-
-FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_TYPE_LEN = 32; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN = 32; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN = 32; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN = 32; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN = 32; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN = 32; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_COLORS_LEN = 32; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN = 32; /* bits */
-
-FLAC_API const unsigned FLAC__STREAM_METADATA_IS_LAST_LEN = 1; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_TYPE_LEN = 7; /* bits */
-FLAC_API const unsigned FLAC__STREAM_METADATA_LENGTH_LEN = 24; /* bits */
-
-FLAC_API const unsigned FLAC__FRAME_HEADER_SYNC = 0x3ffe;
-FLAC_API const unsigned FLAC__FRAME_HEADER_SYNC_LEN = 14; /* bits */
-FLAC_API const unsigned FLAC__FRAME_HEADER_RESERVED_LEN = 1; /* bits */
-FLAC_API const unsigned FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN = 1; /* bits */
-FLAC_API const unsigned FLAC__FRAME_HEADER_BLOCK_SIZE_LEN = 4; /* bits */
-FLAC_API const unsigned FLAC__FRAME_HEADER_SAMPLE_RATE_LEN = 4; /* bits */
-FLAC_API const unsigned FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN = 4; /* bits */
-FLAC_API const unsigned FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN = 3; /* bits */
-FLAC_API const unsigned FLAC__FRAME_HEADER_ZERO_PAD_LEN = 1; /* bits */
-FLAC_API const unsigned FLAC__FRAME_HEADER_CRC_LEN = 8; /* bits */
-
-FLAC_API const unsigned FLAC__FRAME_FOOTER_CRC_LEN = 16; /* bits */
-
-FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_TYPE_LEN = 2; /* bits */
-FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN = 4; /* bits */
-FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN = 4; /* bits */
-FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN = 5; /* bits */
-FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN = 5; /* bits */
-
-FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER = 15; /* == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN)-1 */
-FLAC_API const unsigned FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER = 31; /* == (1<<FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN)-1 */
-
-FLAC_API const char * const FLAC__EntropyCodingMethodTypeString[] = {
- "PARTITIONED_RICE",
- "PARTITIONED_RICE2"
-};
-
-FLAC_API const unsigned FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN = 4; /* bits */
-FLAC_API const unsigned FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN = 5; /* bits */
-
-FLAC_API const unsigned FLAC__SUBFRAME_ZERO_PAD_LEN = 1; /* bits */
-FLAC_API const unsigned FLAC__SUBFRAME_TYPE_LEN = 6; /* bits */
-FLAC_API const unsigned FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN = 1; /* bits */
-
-FLAC_API const unsigned FLAC__SUBFRAME_TYPE_CONSTANT_BYTE_ALIGNED_MASK = 0x00;
-FLAC_API const unsigned FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK = 0x02;
-FLAC_API const unsigned FLAC__SUBFRAME_TYPE_FIXED_BYTE_ALIGNED_MASK = 0x10;
-FLAC_API const unsigned FLAC__SUBFRAME_TYPE_LPC_BYTE_ALIGNED_MASK = 0x40;
-
-FLAC_API const char * const FLAC__SubframeTypeString[] = {
- "CONSTANT",
- "VERBATIM",
- "FIXED",
- "LPC"
-};
-
-FLAC_API const char * const FLAC__ChannelAssignmentString[] = {
- "INDEPENDENT",
- "LEFT_SIDE",
- "RIGHT_SIDE",
- "MID_SIDE"
-};
-
-FLAC_API const char * const FLAC__FrameNumberTypeString[] = {
- "FRAME_NUMBER_TYPE_FRAME_NUMBER",
- "FRAME_NUMBER_TYPE_SAMPLE_NUMBER"
-};
-
-FLAC_API const char * const FLAC__MetadataTypeString[] = {
- "STREAMINFO",
- "PADDING",
- "APPLICATION",
- "SEEKTABLE",
- "VORBIS_COMMENT",
- "CUESHEET",
- "PICTURE"
-};
-
-FLAC_API const char * const FLAC__StreamMetadata_Picture_TypeString[] = {
- "Other",
- "32x32 pixels 'file icon' (PNG only)",
- "Other file icon",
- "Cover (front)",
- "Cover (back)",
- "Leaflet page",
- "Media (e.g. label side of CD)",
- "Lead artist/lead performer/soloist",
- "Artist/performer",
- "Conductor",
- "Band/Orchestra",
- "Composer",
- "Lyricist/text writer",
- "Recording Location",
- "During recording",
- "During performance",
- "Movie/video screen capture",
- "A bright coloured fish",
- "Illustration",
- "Band/artist logotype",
- "Publisher/Studio logotype"
-};
-
-FLAC_API FLAC__bool FLAC__format_sample_rate_is_valid(unsigned sample_rate)
-{
- if(sample_rate == 0 || sample_rate > FLAC__MAX_SAMPLE_RATE) {
- return false;
- }
- else
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__format_blocksize_is_subset(unsigned blocksize, unsigned sample_rate)
-{
- if(blocksize > 16384)
- return false;
- else if(sample_rate <= 48000 && blocksize > 4608)
- return false;
- else
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__format_sample_rate_is_subset(unsigned sample_rate)
-{
- if(
- !FLAC__format_sample_rate_is_valid(sample_rate) ||
- (
- sample_rate >= (1u << 16) &&
- !(sample_rate % 1000 == 0 || sample_rate % 10 == 0)
- )
- ) {
- return false;
- }
- else
- return true;
-}
-
-/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */
-FLAC_API FLAC__bool FLAC__format_seektable_is_legal(const FLAC__StreamMetadata_SeekTable *seek_table)
-{
- unsigned i;
- FLAC__uint64 prev_sample_number = 0;
- FLAC__bool got_prev = false;
-
- FLAC__ASSERT(0 != seek_table);
-
- for(i = 0; i < seek_table->num_points; i++) {
- if(got_prev) {
- if(
- seek_table->points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER &&
- seek_table->points[i].sample_number <= prev_sample_number
- )
- return false;
- }
- prev_sample_number = seek_table->points[i].sample_number;
- got_prev = true;
- }
-
- return true;
-}
-
-/* used as the sort predicate for qsort() */
-static int seekpoint_compare_(const FLAC__StreamMetadata_SeekPoint *l, const FLAC__StreamMetadata_SeekPoint *r)
-{
- /* we don't just 'return l->sample_number - r->sample_number' since the result (FLAC__int64) might overflow an 'int' */
- if(l->sample_number == r->sample_number)
- return 0;
- else if(l->sample_number < r->sample_number)
- return -1;
- else
- return 1;
-}
-
-/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */
-FLAC_API unsigned FLAC__format_seektable_sort(FLAC__StreamMetadata_SeekTable *seek_table)
-{
- unsigned i, j;
- FLAC__bool first;
-
- FLAC__ASSERT(0 != seek_table);
-
- /* sort the seekpoints */
- qsort(seek_table->points, seek_table->num_points, sizeof(FLAC__StreamMetadata_SeekPoint), (int (*)(const void *, const void *))seekpoint_compare_);
-
- /* uniquify the seekpoints */
- first = true;
- for(i = j = 0; i < seek_table->num_points; i++) {
- if(seek_table->points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER) {
- if(!first) {
- if(seek_table->points[i].sample_number == seek_table->points[j-1].sample_number)
- continue;
- }
- }
- first = false;
- seek_table->points[j++] = seek_table->points[i];
- }
-
- for(i = j; i < seek_table->num_points; i++) {
- seek_table->points[i].sample_number = FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER;
- seek_table->points[i].stream_offset = 0;
- seek_table->points[i].frame_samples = 0;
- }
-
- return j;
-}
-
-/*
- * also disallows non-shortest-form encodings, c.f.
- * http://www.unicode.org/versions/corrigendum1.html
- * and a more clear explanation at the end of this section:
- * http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
- */
-static unsigned utf8len_(const FLAC__byte *utf8)
-{
- FLAC__ASSERT(0 != utf8);
- if ((utf8[0] & 0x80) == 0) {
- return 1;
- }
- else if ((utf8[0] & 0xE0) == 0xC0 && (utf8[1] & 0xC0) == 0x80) {
- if ((utf8[0] & 0xFE) == 0xC0) /* overlong sequence check */
- return 0;
- return 2;
- }
- else if ((utf8[0] & 0xF0) == 0xE0 && (utf8[1] & 0xC0) == 0x80 && (utf8[2] & 0xC0) == 0x80) {
- if (utf8[0] == 0xE0 && (utf8[1] & 0xE0) == 0x80) /* overlong sequence check */
- return 0;
- /* illegal surrogates check (U+D800...U+DFFF and U+FFFE...U+FFFF) */
- if (utf8[0] == 0xED && (utf8[1] & 0xE0) == 0xA0) /* D800-DFFF */
- return 0;
- if (utf8[0] == 0xEF && utf8[1] == 0xBF && (utf8[2] & 0xFE) == 0xBE) /* FFFE-FFFF */
- return 0;
- return 3;
- }
- else if ((utf8[0] & 0xF8) == 0xF0 && (utf8[1] & 0xC0) == 0x80 && (utf8[2] & 0xC0) == 0x80 && (utf8[3] & 0xC0) == 0x80) {
- if (utf8[0] == 0xF0 && (utf8[1] & 0xF0) == 0x80) /* overlong sequence check */
- return 0;
- return 4;
- }
- else if ((utf8[0] & 0xFC) == 0xF8 && (utf8[1] & 0xC0) == 0x80 && (utf8[2] & 0xC0) == 0x80 && (utf8[3] & 0xC0) == 0x80 && (utf8[4] & 0xC0) == 0x80) {
- if (utf8[0] == 0xF8 && (utf8[1] & 0xF8) == 0x80) /* overlong sequence check */
- return 0;
- return 5;
- }
- else if ((utf8[0] & 0xFE) == 0xFC && (utf8[1] & 0xC0) == 0x80 && (utf8[2] & 0xC0) == 0x80 && (utf8[3] & 0xC0) == 0x80 && (utf8[4] & 0xC0) == 0x80 && (utf8[5] & 0xC0) == 0x80) {
- if (utf8[0] == 0xFC && (utf8[1] & 0xFC) == 0x80) /* overlong sequence check */
- return 0;
- return 6;
- }
- else {
- return 0;
- }
-}
-
-FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_name_is_legal(const char *name)
-{
- char c;
- for(c = *name; c; c = *(++name))
- if(c < 0x20 || c == 0x3d || c > 0x7d)
- return false;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_value_is_legal(const FLAC__byte *value, unsigned length)
-{
- if(length == (unsigned)(-1)) {
- while(*value) {
- unsigned n = utf8len_(value);
- if(n == 0)
- return false;
- value += n;
- }
- }
- else {
- const FLAC__byte *end = value + length;
- while(value < end) {
- unsigned n = utf8len_(value);
- if(n == 0)
- return false;
- value += n;
- }
- if(value != end)
- return false;
- }
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__format_vorbiscomment_entry_is_legal(const FLAC__byte *entry, unsigned length)
-{
- const FLAC__byte *s, *end;
-
- for(s = entry, end = s + length; s < end && *s != '='; s++) {
- if(*s < 0x20 || *s > 0x7D)
- return false;
- }
- if(s == end)
- return false;
-
- s++; /* skip '=' */
-
- while(s < end) {
- unsigned n = utf8len_(s);
- if(n == 0)
- return false;
- s += n;
- }
- if(s != end)
- return false;
-
- return true;
-}
-
-/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */
-FLAC_API FLAC__bool FLAC__format_cuesheet_is_legal(const FLAC__StreamMetadata_CueSheet *cue_sheet, FLAC__bool check_cd_da_subset, const char **violation)
-{
- unsigned i, j;
-
- if(check_cd_da_subset) {
- if(cue_sheet->lead_in < 2 * 44100) {
- if(violation) *violation = "CD-DA cue sheet must have a lead-in length of at least 2 seconds";
- return false;
- }
- if(cue_sheet->lead_in % 588 != 0) {
- if(violation) *violation = "CD-DA cue sheet lead-in length must be evenly divisible by 588 samples";
- return false;
- }
- }
-
- if(cue_sheet->num_tracks == 0) {
- if(violation) *violation = "cue sheet must have at least one track (the lead-out)";
- return false;
- }
-
- if(check_cd_da_subset && cue_sheet->tracks[cue_sheet->num_tracks-1].number != 170) {
- if(violation) *violation = "CD-DA cue sheet must have a lead-out track number 170 (0xAA)";
- return false;
- }
-
- for(i = 0; i < cue_sheet->num_tracks; i++) {
- if(cue_sheet->tracks[i].number == 0) {
- if(violation) *violation = "cue sheet may not have a track number 0";
- return false;
- }
-
- if(check_cd_da_subset) {
- if(!((cue_sheet->tracks[i].number >= 1 && cue_sheet->tracks[i].number <= 99) || cue_sheet->tracks[i].number == 170)) {
- if(violation) *violation = "CD-DA cue sheet track number must be 1-99 or 170";
- return false;
- }
- }
-
- if(check_cd_da_subset && cue_sheet->tracks[i].offset % 588 != 0) {
- if(violation) {
- if(i == cue_sheet->num_tracks-1) /* the lead-out track... */
- *violation = "CD-DA cue sheet lead-out offset must be evenly divisible by 588 samples";
- else
- *violation = "CD-DA cue sheet track offset must be evenly divisible by 588 samples";
- }
- return false;
- }
-
- if(i < cue_sheet->num_tracks - 1) {
- if(cue_sheet->tracks[i].num_indices == 0) {
- if(violation) *violation = "cue sheet track must have at least one index point";
- return false;
- }
-
- if(cue_sheet->tracks[i].indices[0].number > 1) {
- if(violation) *violation = "cue sheet track's first index number must be 0 or 1";
- return false;
- }
- }
-
- for(j = 0; j < cue_sheet->tracks[i].num_indices; j++) {
- if(check_cd_da_subset && cue_sheet->tracks[i].indices[j].offset % 588 != 0) {
- if(violation) *violation = "CD-DA cue sheet track index offset must be evenly divisible by 588 samples";
- return false;
- }
-
- if(j > 0) {
- if(cue_sheet->tracks[i].indices[j].number != cue_sheet->tracks[i].indices[j-1].number + 1) {
- if(violation) *violation = "cue sheet track index numbers must increase by 1";
- return false;
- }
- }
- }
- }
-
- return true;
-}
-
-/* @@@@ add to unit tests; it is already indirectly tested by the metadata_object tests */
-FLAC_API FLAC__bool FLAC__format_picture_is_legal(const FLAC__StreamMetadata_Picture *picture, const char **violation)
-{
- char *p;
- FLAC__byte *b;
-
- for(p = picture->mime_type; *p; p++) {
- if(*p < 0x20 || *p > 0x7e) {
- if(violation) *violation = "MIME type string must contain only printable ASCII characters (0x20-0x7e)";
- return false;
- }
- }
-
- for(b = picture->description; *b; ) {
- unsigned n = utf8len_(b);
- if(n == 0) {
- if(violation) *violation = "description string must be valid UTF-8";
- return false;
- }
- b += n;
- }
-
- return true;
-}
-
-/*
- * These routines are private to libFLAC
- */
-unsigned FLAC__format_get_max_rice_partition_order(unsigned blocksize, unsigned predictor_order)
-{
- return
- FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order(
- FLAC__format_get_max_rice_partition_order_from_blocksize(blocksize),
- blocksize,
- predictor_order
- );
-}
-
-unsigned FLAC__format_get_max_rice_partition_order_from_blocksize(unsigned blocksize)
-{
- unsigned max_rice_partition_order = 0;
- while(!(blocksize & 1)) {
- max_rice_partition_order++;
- blocksize >>= 1;
- }
- return min(FLAC__MAX_RICE_PARTITION_ORDER, max_rice_partition_order);
-}
-
-unsigned FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order(unsigned limit, unsigned blocksize, unsigned predictor_order)
-{
- unsigned max_rice_partition_order = limit;
-
- while(max_rice_partition_order > 0 && (blocksize >> max_rice_partition_order) <= predictor_order)
- max_rice_partition_order--;
-
- FLAC__ASSERT(
- (max_rice_partition_order == 0 && blocksize >= predictor_order) ||
- (max_rice_partition_order > 0 && blocksize >> max_rice_partition_order > predictor_order)
- );
-
- return max_rice_partition_order;
-}
-
-void FLAC__format_entropy_coding_method_partitioned_rice_contents_init(FLAC__EntropyCodingMethod_PartitionedRiceContents *object)
-{
- FLAC__ASSERT(0 != object);
-
- object->parameters = 0;
- object->raw_bits = 0;
- object->capacity_by_order = 0;
-}
-
-void FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(FLAC__EntropyCodingMethod_PartitionedRiceContents *object)
-{
- FLAC__ASSERT(0 != object);
-
- if(0 != object->parameters)
- free(object->parameters);
- if(0 != object->raw_bits)
- free(object->raw_bits);
- FLAC__format_entropy_coding_method_partitioned_rice_contents_init(object);
-}
-
-FLAC__bool FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(FLAC__EntropyCodingMethod_PartitionedRiceContents *object, unsigned max_partition_order)
-{
- FLAC__ASSERT(0 != object);
-
- FLAC__ASSERT(object->capacity_by_order > 0 || (0 == object->parameters && 0 == object->raw_bits));
-
- if(object->capacity_by_order < max_partition_order) {
- if(0 == (object->parameters = (unsigned*)realloc(object->parameters, sizeof(unsigned)*(1 << max_partition_order))))
- return false;
- if(0 == (object->raw_bits = (unsigned*)realloc(object->raw_bits, sizeof(unsigned)*(1 << max_partition_order))))
- return false;
- memset(object->raw_bits, 0, sizeof(unsigned)*(1 << max_partition_order));
- object->capacity_by_order = max_partition_order;
- }
-
- return true;
-}
diff --git a/src/thirdparty/libflac/src/libFLAC/ia32/bitreader_asm.nasm b/src/thirdparty/libflac/src/libFLAC/ia32/bitreader_asm.nasm
deleted file mode 100644
index 39c0d2a9a..000000000
--- a/src/thirdparty/libflac/src/libFLAC/ia32/bitreader_asm.nasm
+++ /dev/null
@@ -1,569 +0,0 @@
-; vim:filetype=nasm ts=8
-
-; libFLAC - Free Lossless Audio Codec library
-; Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
-;
-; Redistribution and use in source and binary forms, with or without
-; modification, are permitted provided that the following conditions
-; are met:
-;
-; - Redistributions of source code must retain the above copyright
-; notice, this list of conditions and the following disclaimer.
-;
-; - 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.
-;
-; - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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 "nasm.h"
-
- data_section
-
-cextern FLAC__crc16_table ; unsigned FLAC__crc16_table[256];
-cextern bitreader_read_from_client_ ; FLAC__bool bitreader_read_from_client_(FLAC__BitReader *br);
-
-cglobal FLAC__bitreader_read_rice_signed_block_asm_ia32_bswap
-
- code_section
-
-
-; **********************************************************************
-;
-; void FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], unsigned nvals, unsigned parameter)
-;
-; Some details like assertions and other checking is performed by the caller.
- ALIGN 16
-cident FLAC__bitreader_read_rice_signed_block_asm_ia32_bswap
-
- ;ASSERT(0 != br);
- ;ASSERT(0 != br->buffer);
- ; WATCHOUT: code only works if sizeof(brword)==32; we can make things much faster with this assertion
- ;ASSERT(FLAC__BITS_PER_WORD == 32);
- ;ASSERT(parameter < 32);
- ; the above two asserts also guarantee that the binary part never straddles more than 2 words, so we don't have to loop to read it
-
- ;; peppered throughout the code at major checkpoints are keys like this as to where things are at that point in time
- ;; [esp + 16] unsigned parameter
- ;; [esp + 12] unsigned nvals
- ;; [esp + 8] int vals[]
- ;; [esp + 4] FLAC__BitReader *br
- mov eax, [esp + 12] ; if(nvals == 0)
- test eax, eax
- ja .nvals_gt_0
- mov eax, 1 ; return true;
- ret
-
-.nvals_gt_0:
- push ebp
- push ebx
- push esi
- push edi
- sub esp, 4
- ;; [esp + 36] unsigned parameter
- ;; [esp + 32] unsigned nvals
- ;; [esp + 28] int vals[]
- ;; [esp + 24] FLAC__BitReader *br
- ;; [esp] ucbits
- mov ebp, [esp + 24] ; ebp <- br == br->buffer
- mov esi, [ebp + 16] ; esi <- br->consumed_words (aka 'cwords' in the C version)
- mov ecx, [ebp + 20] ; ecx <- br->consumed_bits (aka 'cbits' in the C version)
- xor edi, edi ; edi <- 0 'uval'
- ;; ecx cbits
- ;; esi cwords
- ;; edi uval
- ;; ebp br
- ;; [ebp] br->buffer
- ;; [ebp + 8] br->words
- ;; [ebp + 12] br->bytes
- ;; [ebp + 16] br->consumed_words
- ;; [ebp + 20] br->consumed_bits
- ;; [ebp + 24] br->read_crc
- ;; [ebp + 28] br->crc16_align
-
- ; ucbits = (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits;
- mov eax, [ebp + 8] ; eax <- br->words
- sub eax, esi ; eax <- br->words-cwords
- shl eax, 2 ; eax <- (br->words-cwords)*FLAC__BYTES_PER_WORD
- add eax, [ebp + 12] ; eax <- (br->words-cwords)*FLAC__BYTES_PER_WORD + br->bytes
- shl eax, 3 ; eax <- (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8
- sub eax, ecx ; eax <- (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits
- mov [esp], eax ; ucbits <- eax
-
- ALIGN 16
-.val_loop: ; while(1) {
-
- ;
- ; read unary part
- ;
-.unary_loop: ; while(1) {
- ;; ecx cbits
- ;; esi cwords
- ;; edi uval
- ;; ebp br
- cmp esi, [ebp + 8] ; while(cwords < br->words) /* if we've not consumed up to a partial tail word... */
- jae near .c1_next1
-.c1_loop: ; {
- mov ebx, [ebp]
- mov eax, [ebx + 4*esi] ; b = br->buffer[cwords]
- mov edx, eax ; edx = br->buffer[cwords] (saved for later use)
- shl eax, cl ; b = br->buffer[cwords] << cbits
- test eax, eax ; (still have to test since cbits may be 0, thus ZF not updated for shl eax,0)
- jz near .c1_next2 ; if(b) {
- bsr ebx, eax
- not ebx
- and ebx, 31 ; ebx = 'i' = # of leading 0 bits in 'b' (eax)
- add ecx, ebx ; cbits += i;
- add edi, ebx ; uval += i;
- add ecx, byte 1 ; cbits++; /* skip over stop bit */
- test ecx, ~31
- jz near .break1 ; if(cbits >= FLAC__BITS_PER_WORD) { /* faster way of testing if(cbits == FLAC__BITS_PER_WORD) */
- ; crc16_update_word_(br, br->buffer[cwords]);
- push edi ; [need more registers]
- bswap edx ; edx = br->buffer[cwords] swapped; now we can CRC the bytes from LSByte to MSByte which makes things much easier
- mov ecx, [ebp + 28] ; ecx <- br->crc16_align
- mov eax, [ebp + 24] ; ax <- br->read_crc (a.k.a. crc)
-%ifdef FLAC__PUBLIC_NEEDS_UNDERSCORE
- mov edi, _FLAC__crc16_table
-%else
- mov edi, FLAC__crc16_table
-%endif
- ;; eax (ax) crc a.k.a. br->read_crc
- ;; ebx (bl) intermediate result index into FLAC__crc16_table[]
- ;; ecx br->crc16_align
- ;; edx byteswapped brword to CRC
- ;; esi cwords
- ;; edi unsigned FLAC__crc16_table[]
- ;; ebp br
- test ecx, ecx ; switch(br->crc16_align) ...
- jnz .c0b4 ; [br->crc16_align is 0 the vast majority of the time so we optimize the common case]
-.c0b0: xor dl, ah ; dl <- (crc>>8)^(word>>24)
- movzx ebx, dl
- mov ecx, [ebx*4 + edi] ; cx <- FLAC__crc16_table[(crc>>8)^(word>>24)]
- shl eax, 8 ; ax <- (crc<<8)
- xor eax, ecx ; crc <- ax <- (crc<<8) ^ FLAC__crc16_table[(crc>>8)^(word>>24)]
-.c0b1: xor dh, ah ; dh <- (crc>>8)^((word>>16)&0xff))
- movzx ebx, dh
- mov ecx, [ebx*4 + edi] ; cx <- FLAC__crc16_table[(crc>>8)^((word>>16)&0xff))]
- shl eax, 8 ; ax <- (crc<<8)
- xor eax, ecx ; crc <- ax <- (crc<<8) ^ FLAC__crc16_table[(crc>>8)^((word>>16)&0xff))]
- shr edx, 16
-.c0b2: xor dl, ah ; dl <- (crc>>8)^((word>>8)&0xff))
- movzx ebx, dl
- mov ecx, [ebx*4 + edi] ; cx <- FLAC__crc16_table[(crc>>8)^((word>>8)&0xff))]
- shl eax, 8 ; ax <- (crc<<8)
- xor eax, ecx ; crc <- ax <- (crc<<8) ^ FLAC__crc16_table[(crc>>8)^((word>>8)&0xff))]
-.c0b3: xor dh, ah ; dh <- (crc>>8)^(word&0xff)
- movzx ebx, dh
- mov ecx, [ebx*4 + edi] ; cx <- FLAC__crc16_table[(crc>>8)^(word&0xff)]
- shl eax, 8 ; ax <- (crc<<8)
- xor eax, ecx ; crc <- ax <- (crc<<8) ^ FLAC__crc16_table[(crc>>8)^(word&0xff)]
- movzx eax, ax
- mov [ebp + 24], eax ; br->read_crc <- crc
- pop edi
-
- add esi, byte 1 ; cwords++;
- xor ecx, ecx ; cbits = 0;
- ; }
- jmp near .break1 ; goto break1;
- ;; this section relocated out of the way for performance
-.c0b4:
- mov [ebp + 28], dword 0 ; br->crc16_align <- 0
- cmp ecx, 8
- je .c0b1
- shr edx, 16
- cmp ecx, 16
- je .c0b2
- jmp .c0b3
-
- ;; this section relocated out of the way for performance
-.c1b4:
- mov [ebp + 28], dword 0 ; br->crc16_align <- 0
- cmp ecx, 8
- je .c1b1
- shr edx, 16
- cmp ecx, 16
- je .c1b2
- jmp .c1b3
-
-.c1_next2: ; } else {
- ;; ecx cbits
- ;; edx current brword 'b'
- ;; esi cwords
- ;; edi uval
- ;; ebp br
- add edi, 32
- sub edi, ecx ; uval += FLAC__BITS_PER_WORD - cbits;
- ; crc16_update_word_(br, br->buffer[cwords]);
- push edi ; [need more registers]
- bswap edx ; edx = br->buffer[cwords] swapped; now we can CRC the bytes from LSByte to MSByte which makes things much easier
- mov ecx, [ebp + 28] ; ecx <- br->crc16_align
- mov eax, [ebp + 24] ; ax <- br->read_crc (a.k.a. crc)
-%ifdef FLAC__PUBLIC_NEEDS_UNDERSCORE
- mov edi, _FLAC__crc16_table
-%else
- mov edi, FLAC__crc16_table
-%endif
- ;; eax (ax) crc a.k.a. br->read_crc
- ;; ebx (bl) intermediate result index into FLAC__crc16_table[]
- ;; ecx br->crc16_align
- ;; edx byteswapped brword to CRC
- ;; esi cwords
- ;; edi unsigned FLAC__crc16_table[]
- ;; ebp br
- test ecx, ecx ; switch(br->crc16_align) ...
- jnz .c1b4 ; [br->crc16_align is 0 the vast majority of the time so we optimize the common case]
-.c1b0: xor dl, ah ; dl <- (crc>>8)^(word>>24)
- movzx ebx, dl
- mov ecx, [ebx*4 + edi] ; cx <- FLAC__crc16_table[(crc>>8)^(word>>24)]
- shl eax, 8 ; ax <- (crc<<8)
- xor eax, ecx ; crc <- ax <- (crc<<8) ^ FLAC__crc16_table[(crc>>8)^(word>>24)]
-.c1b1: xor dh, ah ; dh <- (crc>>8)^((word>>16)&0xff))
- movzx ebx, dh
- mov ecx, [ebx*4 + edi] ; cx <- FLAC__crc16_table[(crc>>8)^((word>>16)&0xff))]
- shl eax, 8 ; ax <- (crc<<8)
- xor eax, ecx ; crc <- ax <- (crc<<8) ^ FLAC__crc16_table[(crc>>8)^((word>>16)&0xff))]
- shr edx, 16
-.c1b2: xor dl, ah ; dl <- (crc>>8)^((word>>8)&0xff))
- movzx ebx, dl
- mov ecx, [ebx*4 + edi] ; cx <- FLAC__crc16_table[(crc>>8)^((word>>8)&0xff))]
- shl eax, 8 ; ax <- (crc<<8)
- xor eax, ecx ; crc <- ax <- (crc<<8) ^ FLAC__crc16_table[(crc>>8)^((word>>8)&0xff))]
-.c1b3: xor dh, ah ; dh <- (crc>>8)^(word&0xff)
- movzx ebx, dh
- mov ecx, [ebx*4 + edi] ; cx <- FLAC__crc16_table[(crc>>8)^(word&0xff)]
- shl eax, 8 ; ax <- (crc<<8)
- xor eax, ecx ; crc <- ax <- (crc<<8) ^ FLAC__crc16_table[(crc>>8)^(word&0xff)]
- movzx eax, ax
- mov [ebp + 24], eax ; br->read_crc <- crc
- pop edi
-
- add esi, byte 1 ; cwords++;
- xor ecx, ecx ; cbits = 0;
- ; /* didn't find stop bit yet, have to keep going... */
- ; }
-
- cmp esi, [ebp + 8] ; } while(cwords < br->words) /* if we've not consumed up to a partial tail word... */
- jb near .c1_loop
-
-.c1_next1:
- ; at this point we've eaten up all the whole words; have to try
- ; reading through any tail bytes before calling the read callback.
- ; this is a repeat of the above logic adjusted for the fact we
- ; don't have a whole word. note though if the client is feeding
- ; us data a byte at a time (unlikely), br->consumed_bits may not
- ; be zero.
- ;; ecx cbits
- ;; esi cwords
- ;; edi uval
- ;; ebp br
- mov edx, [ebp + 12] ; edx <- br->bytes
- shl edx, 3 ; edx <- br->bytes*8
- cmp edx, ecx
- jbe .read1 ; if(br->bytes*8 > cbits) { [NOTE: this case is rare so it doesn't have to be all that fast ]
- mov ebx, [ebp]
- ; edx <- const unsigned end = br->bytes * 8;
- mov eax, [ebx + 4*esi] ; b = br->buffer[cwords]
- xchg edx, ecx ; [edx <- cbits , ecx <- end]
- mov ebx, 0xffffffff ; ebx <- FLAC__WORD_ALL_ONES
- shr ebx, cl ; ebx <- FLAC__WORD_ALL_ONES >> end
- not ebx ; ebx <- ~(FLAC__WORD_ALL_ONES >> end)
- xchg edx, ecx ; [edx <- end , ecx <- cbits]
- and eax, ebx ; b = (br->buffer[cwords] & ~(FLAC__WORD_ALL_ONES >> end));
- shl eax, cl ; b = (br->buffer[cwords] & ~(FLAC__WORD_ALL_ONES >> end)) << cbits;
- test eax, eax ; (still have to test since cbits may be 0, thus ZF not updated for shl eax,0)
- jz .c1_next3 ; if(b) {
- bsr ebx, eax
- not ebx
- and ebx, 31 ; ebx = 'i' = # of leading 0 bits in 'b' (eax)
- add ecx, ebx ; cbits += i;
- add edi, ebx ; uval += i;
- add ecx, byte 1 ; cbits++; /* skip over stop bit */
- jmp short .break1 ; goto break1;
-.c1_next3: ; } else {
- sub edi, ecx
- add edi, edx ; uval += end - cbits;
- mov ecx, edx ; cbits = end
- ; /* didn't find stop bit yet, have to keep going... */
- ; }
- ; }
-.read1:
- ; flush registers and read; bitreader_read_from_client_() does
- ; not touch br->consumed_bits at all but we still need to set
- ; it in case it fails and we have to return false.
- ;; ecx cbits
- ;; esi cwords
- ;; edi uval
- ;; ebp br
- mov [ebp + 16], esi ; br->consumed_words = cwords;
- mov [ebp + 20], ecx ; br->consumed_bits = cbits;
- push ecx ; /* save */
- push ebp ; /* push br argument */
-%ifdef FLAC__PUBLIC_NEEDS_UNDERSCORE
- call _bitreader_read_from_client_
-%else
- call bitreader_read_from_client_
-%endif
- pop edx ; /* discard, unused */
- pop ecx ; /* restore */
- mov esi, [ebp + 16] ; cwords = br->consumed_words;
- ; ucbits = (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits;
- mov ebx, [ebp + 8] ; ebx <- br->words
- sub ebx, esi ; ebx <- br->words-cwords
- shl ebx, 2 ; ebx <- (br->words-cwords)*FLAC__BYTES_PER_WORD
- add ebx, [ebp + 12] ; ebx <- (br->words-cwords)*FLAC__BYTES_PER_WORD + br->bytes
- shl ebx, 3 ; ebx <- (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8
- sub ebx, ecx ; ebx <- (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits
- add ebx, edi ; ebx <- (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits + uval
- ; + uval to offset our count by the # of unary bits already
- ; consumed before the read, because we will add these back
- ; in all at once at break1
- mov [esp], ebx ; ucbits <- ebx
- test eax, eax ; if(!bitreader_read_from_client_(br))
- jnz near .unary_loop
- jmp .end ; return false; /* eax (the return value) is already 0 */
- ; } /* end while(1) unary part */
-
- ALIGN 16
-.break1:
- ;; ecx cbits
- ;; esi cwords
- ;; edi uval
- ;; ebp br
- ;; [esp] ucbits
- sub [esp], edi ; ucbits -= uval;
- sub dword [esp], byte 1 ; ucbits--; /* account for stop bit */
-
- ;
- ; read binary part
- ;
- mov ebx, [esp + 36] ; ebx <- parameter
- test ebx, ebx ; if(parameter) {
- jz near .break2
-.read2:
- cmp [esp], ebx ; while(ucbits < parameter) {
- jae .c2_next1
- ; flush registers and read; bitreader_read_from_client_() does
- ; not touch br->consumed_bits at all but we still need to set
- ; it in case it fails and we have to return false.
- mov [ebp + 16], esi ; br->consumed_words = cwords;
- mov [ebp + 20], ecx ; br->consumed_bits = cbits;
- push ecx ; /* save */
- push ebp ; /* push br argument */
-%ifdef FLAC__PUBLIC_NEEDS_UNDERSCORE
- call _bitreader_read_from_client_
-%else
- call bitreader_read_from_client_
-%endif
- pop edx ; /* discard, unused */
- pop ecx ; /* restore */
- mov esi, [ebp + 16] ; cwords = br->consumed_words;
- ; ucbits = (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits;
- mov edx, [ebp + 8] ; edx <- br->words
- sub edx, esi ; edx <- br->words-cwords
- shl edx, 2 ; edx <- (br->words-cwords)*FLAC__BYTES_PER_WORD
- add edx, [ebp + 12] ; edx <- (br->words-cwords)*FLAC__BYTES_PER_WORD + br->bytes
- shl edx, 3 ; edx <- (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8
- sub edx, ecx ; edx <- (br->words-cwords)*FLAC__BITS_PER_WORD + br->bytes*8 - cbits
- mov [esp], edx ; ucbits <- edx
- test eax, eax ; if(!bitreader_read_from_client_(br))
- jnz .read2
- jmp .end ; return false; /* eax (the return value) is already 0 */
- ; }
-.c2_next1:
- ;; ebx parameter
- ;; ecx cbits
- ;; esi cwords
- ;; edi uval
- ;; ebp br
- ;; [esp] ucbits
- cmp esi, [ebp + 8] ; if(cwords < br->words) { /* if we've not consumed up to a partial tail word... */
- jae near .c2_next2
- test ecx, ecx ; if(cbits) {
- jz near .c2_next3 ; /* this also works when consumed_bits==0, it's just a little slower than necessary for that case */
- mov eax, 32
- mov edx, [ebp]
- sub eax, ecx ; const unsigned n = FLAC__BITS_PER_WORD - cbits;
- mov edx, [edx + 4*esi] ; const brword word = br->buffer[cwords];
- cmp ebx, eax ; if(parameter < n) {
- jae .c2_next4
- ; uval <<= parameter;
- ; uval |= (word & (FLAC__WORD_ALL_ONES >> cbits)) >> (n-parameter);
- shl edx, cl
- xchg ebx, ecx
- shld edi, edx, cl
- add ebx, ecx ; cbits += parameter;
- xchg ebx, ecx ; ebx <- parameter, ecx <- cbits
- jmp .break2 ; goto break2;
- ; }
-.c2_next4:
- ; uval <<= n;
- ; uval |= word & (FLAC__WORD_ALL_ONES >> cbits);
-%if 1
- rol edx, cl ; @@@@@@OPT: may be faster to use rol to save edx so we can restore it for CRC'ing
- ; @@@@@@OPT: or put parameter in ch instead and free up ebx completely again
-%else
- shl edx, cl
-%endif
- xchg eax, ecx
- shld edi, edx, cl
- xchg eax, ecx
-%if 1
- ror edx, cl ; restored.
-%else
- mov edx, [ebp]
- mov edx, [edx + 4*esi]
-%endif
- ; crc16_update_word_(br, br->buffer[cwords]);
- push edi ; [need more registers]
- push ebx ; [need more registers]
- push eax ; [need more registers]
- bswap edx ; edx = br->buffer[cwords] swapped; now we can CRC the bytes from LSByte to MSByte which makes things much easier
- mov ecx, [ebp + 28] ; ecx <- br->crc16_align
- mov eax, [ebp + 24] ; ax <- br->read_crc (a.k.a. crc)
-%ifdef FLAC__PUBLIC_NEEDS_UNDERSCORE
- mov edi, _FLAC__crc16_table
-%else
- mov edi, FLAC__crc16_table
-%endif
- ;; eax (ax) crc a.k.a. br->read_crc
- ;; ebx (bl) intermediate result index into FLAC__crc16_table[]
- ;; ecx br->crc16_align
- ;; edx byteswapped brword to CRC
- ;; esi cwords
- ;; edi unsigned FLAC__crc16_table[]
- ;; ebp br
- test ecx, ecx ; switch(br->crc16_align) ...
- jnz .c2b4 ; [br->crc16_align is 0 the vast majority of the time so we optimize the common case]
-.c2b0: xor dl, ah ; dl <- (crc>>8)^(word>>24)
- movzx ebx, dl
- mov ecx, [ebx*4 + edi] ; cx <- FLAC__crc16_table[(crc>>8)^(word>>24)]
- shl eax, 8 ; ax <- (crc<<8)
- xor eax, ecx ; crc <- ax <- (crc<<8) ^ FLAC__crc16_table[(crc>>8)^(word>>24)]
-.c2b1: xor dh, ah ; dh <- (crc>>8)^((word>>16)&0xff))
- movzx ebx, dh
- mov ecx, [ebx*4 + edi] ; cx <- FLAC__crc16_table[(crc>>8)^((word>>16)&0xff))]
- shl eax, 8 ; ax <- (crc<<8)
- xor eax, ecx ; crc <- ax <- (crc<<8) ^ FLAC__crc16_table[(crc>>8)^((word>>16)&0xff))]
- shr edx, 16
-.c2b2: xor dl, ah ; dl <- (crc>>8)^((word>>8)&0xff))
- movzx ebx, dl
- mov ecx, [ebx*4 + edi] ; cx <- FLAC__crc16_table[(crc>>8)^((word>>8)&0xff))]
- shl eax, 8 ; ax <- (crc<<8)
- xor eax, ecx ; crc <- ax <- (crc<<8) ^ FLAC__crc16_table[(crc>>8)^((word>>8)&0xff))]
-.c2b3: xor dh, ah ; dh <- (crc>>8)^(word&0xff)
- movzx ebx, dh
- mov ecx, [ebx*4 + edi] ; cx <- FLAC__crc16_table[(crc>>8)^(word&0xff)]
- shl eax, 8 ; ax <- (crc<<8)
- xor eax, ecx ; crc <- ax <- (crc<<8) ^ FLAC__crc16_table[(crc>>8)^(word&0xff)]
- movzx eax, ax
- mov [ebp + 24], eax ; br->read_crc <- crc
- pop eax
- pop ebx
- pop edi
- add esi, byte 1 ; cwords++;
- mov ecx, ebx
- sub ecx, eax ; cbits = parameter - n;
- jz .break2 ; if(cbits) { /* parameter > n, i.e. if there are still bits left to read, there have to be less than 32 so they will all be in the next word */
- ; uval <<= cbits;
- ; uval |= (br->buffer[cwords] >> (FLAC__BITS_PER_WORD-cbits));
- mov eax, [ebp]
- mov eax, [eax + 4*esi]
- shld edi, eax, cl
- ; }
- jmp .break2 ; goto break2;
-
- ;; this section relocated out of the way for performance
-.c2b4:
- mov [ebp + 28], dword 0 ; br->crc16_align <- 0
- cmp ecx, 8
- je .c2b1
- shr edx, 16
- cmp ecx, 16
- je .c2b2
- jmp .c2b3
-
-.c2_next3: ; } else {
- mov ecx, ebx ; cbits = parameter;
- ; uval <<= cbits;
- ; uval |= (br->buffer[cwords] >> (FLAC__BITS_PER_WORD-cbits));
- mov eax, [ebp]
- mov eax, [eax + 4*esi]
- shld edi, eax, cl
- jmp .break2 ; goto break2;
- ; }
-.c2_next2: ; } else {
- ; in this case we're starting our read at a partial tail word;
- ; the reader has guaranteed that we have at least 'parameter'
- ; bits available to read, which makes this case simpler.
- ; uval <<= parameter;
- ; if(cbits) {
- ; /* this also works when consumed_bits==0, it's just a little slower than necessary for that case */
- ; uval |= (br->buffer[cwords] & (FLAC__WORD_ALL_ONES >> cbits)) >> (FLAC__BITS_PER_WORD-cbits-parameter);
- ; cbits += parameter;
- ; goto break2;
- ; } else {
- ; cbits = parameter;
- ; uval |= br->buffer[cwords] >> (FLAC__BITS_PER_WORD-cbits);
- ; goto break2;
- ; }
- ; the above is much shorter in assembly:
- mov eax, [ebp]
- mov eax, [eax + 4*esi] ; eax <- br->buffer[cwords]
- shl eax, cl ; eax <- br->buffer[cwords] << cbits
- add ecx, ebx ; cbits += parameter
- xchg ebx, ecx ; ebx <- cbits, ecx <- parameter
- shld edi, eax, cl ; uval <<= parameter <<< 'parameter' bits of tail word
- xchg ebx, ecx ; ebx <- parameter, ecx <- cbits
- ; }
- ; }
-.break2:
- sub [esp], ebx ; ucbits -= parameter;
-
- ;
- ; compose the value
- ;
- mov ebx, [esp + 28] ; ebx <- vals
- mov edx, edi ; edx <- uval
- and edi, 1 ; edi <- uval & 1
- shr edx, 1 ; edx <- uval >> 1
- neg edi ; edi <- -(int)(uval & 1)
- xor edx, edi ; edx <- (uval >> 1 ^ -(int)(uval & 1))
- mov [ebx], edx ; *vals <- edx
- sub dword [esp + 32], byte 1 ; --nvals;
- jz .finished ; if(nvals == 0) /* jump to finish */
- xor edi, edi ; uval = 0;
- add dword [esp + 28], 4 ; ++vals
- jmp .val_loop ; }
-
-.finished:
- mov [ebp + 16], esi ; br->consumed_words = cwords;
- mov [ebp + 20], ecx ; br->consumed_bits = cbits;
- mov eax, 1
-.end:
- add esp, 4
- pop edi
- pop esi
- pop ebx
- pop ebp
- ret
-
-end
-
-%ifdef OBJ_FORMAT_elf
- section .note.GNU-stack noalloc
-%endif
diff --git a/src/thirdparty/libflac/src/libFLAC/ia32/cpu_asm.nasm b/src/thirdparty/libflac/src/libFLAC/ia32/cpu_asm.nasm
deleted file mode 100644
index 3f92ba7d2..000000000
--- a/src/thirdparty/libflac/src/libFLAC/ia32/cpu_asm.nasm
+++ /dev/null
@@ -1,121 +0,0 @@
-; vim:filetype=nasm ts=8
-
-; libFLAC - Free Lossless Audio Codec library
-; Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
-;
-; Redistribution and use in source and binary forms, with or without
-; modification, are permitted provided that the following conditions
-; are met:
-;
-; - Redistributions of source code must retain the above copyright
-; notice, this list of conditions and the following disclaimer.
-;
-; - 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.
-;
-; - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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 "nasm.h"
-
- data_section
-
-cglobal FLAC__cpu_have_cpuid_asm_ia32
-cglobal FLAC__cpu_info_asm_ia32
-cglobal FLAC__cpu_info_extended_amd_asm_ia32
-
- code_section
-
-; **********************************************************************
-;
-; FLAC__uint32 FLAC__cpu_have_cpuid_asm_ia32()
-;
-
-cident FLAC__cpu_have_cpuid_asm_ia32
- push ebx
- pushfd
- pop eax
- mov edx, eax
- xor eax, 0x00200000
- push eax
- popfd
- pushfd
- pop eax
- cmp eax, edx
- jz .no_cpuid
- mov eax, 1
- jmp .end
-.no_cpuid:
- xor eax, eax
-.end:
- pop ebx
- ret
-
-; **********************************************************************
-;
-; void FLAC__cpu_info_asm_ia32(FLAC__uint32 *flags_edx, FLAC__uint32 *flags_ecx)
-;
-
-cident FLAC__cpu_info_asm_ia32
- ;[esp + 8] == flags_edx
- ;[esp + 12] == flags_ecx
-
- push ebx
- call FLAC__cpu_have_cpuid_asm_ia32
- test eax, eax
- jz .no_cpuid
- mov eax, 1
- cpuid
- mov ebx, [esp + 8]
- mov [ebx], edx
- mov ebx, [esp + 12]
- mov [ebx], ecx
- jmp .end
-.no_cpuid:
- xor eax, eax
- mov ebx, [esp + 8]
- mov [ebx], eax
- mov ebx, [esp + 12]
- mov [ebx], eax
-.end:
- pop ebx
- ret
-
-cident FLAC__cpu_info_extended_amd_asm_ia32
- push ebx
- call FLAC__cpu_have_cpuid_asm_ia32
- test eax, eax
- jz .no_cpuid
- mov eax, 0x80000000
- cpuid
- cmp eax, 0x80000001
- jb .no_cpuid
- mov eax, 0x80000001
- cpuid
- mov eax, edx
- jmp .end
-.no_cpuid:
- xor eax, eax
-.end:
- pop ebx
- ret
-
-end
-
-%ifdef OBJ_FORMAT_elf
- section .note.GNU-stack noalloc
-%endif
diff --git a/src/thirdparty/libflac/src/libFLAC/ia32/fixed_asm.nasm b/src/thirdparty/libflac/src/libFLAC/ia32/fixed_asm.nasm
deleted file mode 100644
index fed229eca..000000000
--- a/src/thirdparty/libflac/src/libFLAC/ia32/fixed_asm.nasm
+++ /dev/null
@@ -1,312 +0,0 @@
-; vim:filetype=nasm ts=8
-
-; libFLAC - Free Lossless Audio Codec library
-; Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
-;
-; Redistribution and use in source and binary forms, with or without
-; modification, are permitted provided that the following conditions
-; are met:
-;
-; - Redistributions of source code must retain the above copyright
-; notice, this list of conditions and the following disclaimer.
-;
-; - 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.
-;
-; - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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 "nasm.h"
-
- data_section
-
-cglobal FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov
-
- code_section
-
-; **********************************************************************
-;
-; unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 *data, unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1])
-; {
-; FLAC__int32 last_error_0 = data[-1];
-; FLAC__int32 last_error_1 = data[-1] - data[-2];
-; FLAC__int32 last_error_2 = last_error_1 - (data[-2] - data[-3]);
-; FLAC__int32 last_error_3 = last_error_2 - (data[-2] - 2*data[-3] + data[-4]);
-; FLAC__int32 error, save;
-; FLAC__uint32 total_error_0 = 0, total_error_1 = 0, total_error_2 = 0, total_error_3 = 0, total_error_4 = 0;
-; unsigned i, order;
-;
-; for(i = 0; i < data_len; i++) {
-; error = data[i] ; total_error_0 += local_abs(error); save = error;
-; error -= last_error_0; total_error_1 += local_abs(error); last_error_0 = save; save = error;
-; error -= last_error_1; total_error_2 += local_abs(error); last_error_1 = save; save = error;
-; error -= last_error_2; total_error_3 += local_abs(error); last_error_2 = save; save = error;
-; error -= last_error_3; total_error_4 += local_abs(error); last_error_3 = save;
-; }
-;
-; if(total_error_0 < min(min(min(total_error_1, total_error_2), total_error_3), total_error_4))
-; order = 0;
-; else if(total_error_1 < min(min(total_error_2, total_error_3), total_error_4))
-; order = 1;
-; else if(total_error_2 < min(total_error_3, total_error_4))
-; order = 2;
-; else if(total_error_3 < total_error_4)
-; order = 3;
-; else
-; order = 4;
-;
-; residual_bits_per_sample[0] = (FLAC__float)((data_len > 0 && total_error_0 > 0) ? log(M_LN2 * (FLAC__double)total_error_0 / (FLAC__double)data_len) / M_LN2 : 0.0);
-; residual_bits_per_sample[1] = (FLAC__float)((data_len > 0 && total_error_1 > 0) ? log(M_LN2 * (FLAC__double)total_error_1 / (FLAC__double)data_len) / M_LN2 : 0.0);
-; residual_bits_per_sample[2] = (FLAC__float)((data_len > 0 && total_error_2 > 0) ? log(M_LN2 * (FLAC__double)total_error_2 / (FLAC__double)data_len) / M_LN2 : 0.0);
-; residual_bits_per_sample[3] = (FLAC__float)((data_len > 0 && total_error_3 > 0) ? log(M_LN2 * (FLAC__double)total_error_3 / (FLAC__double)data_len) / M_LN2 : 0.0);
-; residual_bits_per_sample[4] = (FLAC__float)((data_len > 0 && total_error_4 > 0) ? log(M_LN2 * (FLAC__double)total_error_4 / (FLAC__double)data_len) / M_LN2 : 0.0);
-;
-; return order;
-; }
- ALIGN 16
-cident FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov
-
- ; esp + 36 == data[]
- ; esp + 40 == data_len
- ; esp + 44 == residual_bits_per_sample[]
-
- push ebp
- push ebx
- push esi
- push edi
- sub esp, byte 16
- ; qword [esp] == temp space for loading FLAC__uint64s to FPU regs
-
- ; ebx == &data[i]
- ; ecx == loop counter (i)
- ; ebp == order
- ; mm0 == total_error_1:total_error_0
- ; mm1 == total_error_2:total_error_3
- ; mm2 == :total_error_4
- ; mm3 == last_error_1:last_error_0
- ; mm4 == last_error_2:last_error_3
-
- mov ecx, [esp + 40] ; ecx = data_len
- test ecx, ecx
- jz near .data_len_is_0
-
- mov ebx, [esp + 36] ; ebx = data[]
- movd mm3, [ebx - 4] ; mm3 = 0:last_error_0
- movd mm2, [ebx - 8] ; mm2 = 0:data[-2]
- movd mm1, [ebx - 12] ; mm1 = 0:data[-3]
- movd mm0, [ebx - 16] ; mm0 = 0:data[-4]
- movq mm5, mm3 ; mm5 = 0:last_error_0
- psubd mm5, mm2 ; mm5 = 0:last_error_1
- punpckldq mm3, mm5 ; mm3 = last_error_1:last_error_0
- psubd mm2, mm1 ; mm2 = 0:data[-2] - data[-3]
- psubd mm5, mm2 ; mm5 = 0:last_error_2
- movq mm4, mm5 ; mm4 = 0:last_error_2
- psubd mm4, mm2 ; mm4 = 0:last_error_2 - (data[-2] - data[-3])
- paddd mm4, mm1 ; mm4 = 0:last_error_2 - (data[-2] - 2 * data[-3])
- psubd mm4, mm0 ; mm4 = 0:last_error_3
- punpckldq mm4, mm5 ; mm4 = last_error_2:last_error_3
- pxor mm0, mm0 ; mm0 = total_error_1:total_error_0
- pxor mm1, mm1 ; mm1 = total_error_2:total_error_3
- pxor mm2, mm2 ; mm2 = 0:total_error_4
-
- ALIGN 16
-.loop:
- movd mm7, [ebx] ; mm7 = 0:error_0
- add ebx, byte 4
- movq mm6, mm7 ; mm6 = 0:error_0
- psubd mm7, mm3 ; mm7 = :error_1
- punpckldq mm6, mm7 ; mm6 = error_1:error_0
- movq mm5, mm6 ; mm5 = error_1:error_0
- movq mm7, mm6 ; mm7 = error_1:error_0
- psubd mm5, mm3 ; mm5 = error_2:
- movq mm3, mm6 ; mm3 = error_1:error_0
- psrad mm6, 31
- pxor mm7, mm6
- psubd mm7, mm6 ; mm7 = abs(error_1):abs(error_0)
- paddd mm0, mm7 ; mm0 = total_error_1:total_error_0
- movq mm6, mm5 ; mm6 = error_2:
- psubd mm5, mm4 ; mm5 = error_3:
- punpckhdq mm5, mm6 ; mm5 = error_2:error_3
- movq mm7, mm5 ; mm7 = error_2:error_3
- movq mm6, mm5 ; mm6 = error_2:error_3
- psubd mm5, mm4 ; mm5 = :error_4
- movq mm4, mm6 ; mm4 = error_2:error_3
- psrad mm6, 31
- pxor mm7, mm6
- psubd mm7, mm6 ; mm7 = abs(error_2):abs(error_3)
- paddd mm1, mm7 ; mm1 = total_error_2:total_error_3
- movq mm6, mm5 ; mm6 = :error_4
- psrad mm5, 31
- pxor mm6, mm5
- psubd mm6, mm5 ; mm6 = :abs(error_4)
- paddd mm2, mm6 ; mm2 = :total_error_4
-
- dec ecx
- jnz short .loop
-
-; if(total_error_0 < min(min(min(total_error_1, total_error_2), total_error_3), total_error_4))
-; order = 0;
-; else if(total_error_1 < min(min(total_error_2, total_error_3), total_error_4))
-; order = 1;
-; else if(total_error_2 < min(total_error_3, total_error_4))
-; order = 2;
-; else if(total_error_3 < total_error_4)
-; order = 3;
-; else
-; order = 4;
- movq mm3, mm0 ; mm3 = total_error_1:total_error_0
- movd edi, mm2 ; edi = total_error_4
- movd esi, mm1 ; esi = total_error_3
- movd eax, mm0 ; eax = total_error_0
- punpckhdq mm1, mm1 ; mm1 = total_error_2:total_error_2
- punpckhdq mm3, mm3 ; mm3 = total_error_1:total_error_1
- movd edx, mm1 ; edx = total_error_2
- movd ecx, mm3 ; ecx = total_error_1
-
- xor ebx, ebx
- xor ebp, ebp
- inc ebx
- cmp ecx, eax
- cmovb eax, ecx ; eax = min(total_error_0, total_error_1)
- cmovbe ebp, ebx
- inc ebx
- cmp edx, eax
- cmovb eax, edx ; eax = min(total_error_0, total_error_1, total_error_2)
- cmovbe ebp, ebx
- inc ebx
- cmp esi, eax
- cmovb eax, esi ; eax = min(total_error_0, total_error_1, total_error_2, total_error_3)
- cmovbe ebp, ebx
- inc ebx
- cmp edi, eax
- cmovb eax, edi ; eax = min(total_error_0, total_error_1, total_error_2, total_error_3, total_error_4)
- cmovbe ebp, ebx
- movd ebx, mm0 ; ebx = total_error_0
- emms
-
- ; residual_bits_per_sample[0] = (FLAC__float)((data_len > 0 && total_error_0 > 0) ? log(M_LN2 * (FLAC__double)total_error_0 / (FLAC__double)data_len) / M_LN2 : 0.0);
- ; residual_bits_per_sample[1] = (FLAC__float)((data_len > 0 && total_error_1 > 0) ? log(M_LN2 * (FLAC__double)total_error_1 / (FLAC__double)data_len) / M_LN2 : 0.0);
- ; residual_bits_per_sample[2] = (FLAC__float)((data_len > 0 && total_error_2 > 0) ? log(M_LN2 * (FLAC__double)total_error_2 / (FLAC__double)data_len) / M_LN2 : 0.0);
- ; residual_bits_per_sample[3] = (FLAC__float)((data_len > 0 && total_error_3 > 0) ? log(M_LN2 * (FLAC__double)total_error_3 / (FLAC__double)data_len) / M_LN2 : 0.0);
- ; residual_bits_per_sample[4] = (FLAC__float)((data_len > 0 && total_error_4 > 0) ? log(M_LN2 * (FLAC__double)total_error_4 / (FLAC__double)data_len) / M_LN2 : 0.0);
- xor eax, eax
- fild dword [esp + 40] ; ST = data_len (NOTE: assumes data_len is <2gigs)
-.rbps_0:
- test ebx, ebx
- jz .total_error_0_is_0
- fld1 ; ST = 1.0 data_len
- mov [esp], ebx
- mov [esp + 4], eax ; [esp] = (FLAC__uint64)total_error_0
- mov ebx, [esp + 44]
- fild qword [esp] ; ST = total_error_0 1.0 data_len
- fdiv st2 ; ST = total_error_0/data_len 1.0 data_len
- fldln2 ; ST = ln2 total_error_0/data_len 1.0 data_len
- fmulp st1 ; ST = ln2*total_error_0/data_len 1.0 data_len
- fyl2x ; ST = log2(ln2*total_error_0/data_len) data_len
- fstp dword [ebx] ; residual_bits_per_sample[0] = log2(ln2*total_error_0/data_len) ST = data_len
- jmp short .rbps_1
-.total_error_0_is_0:
- mov ebx, [esp + 44]
- mov [ebx], eax ; residual_bits_per_sample[0] = 0.0
-.rbps_1:
- test ecx, ecx
- jz .total_error_1_is_0
- fld1 ; ST = 1.0 data_len
- mov [esp], ecx
- mov [esp + 4], eax ; [esp] = (FLAC__uint64)total_error_1
- fild qword [esp] ; ST = total_error_1 1.0 data_len
- fdiv st2 ; ST = total_error_1/data_len 1.0 data_len
- fldln2 ; ST = ln2 total_error_1/data_len 1.0 data_len
- fmulp st1 ; ST = ln2*total_error_1/data_len 1.0 data_len
- fyl2x ; ST = log2(ln2*total_error_1/data_len) data_len
- fstp dword [ebx + 4] ; residual_bits_per_sample[1] = log2(ln2*total_error_1/data_len) ST = data_len
- jmp short .rbps_2
-.total_error_1_is_0:
- mov [ebx + 4], eax ; residual_bits_per_sample[1] = 0.0
-.rbps_2:
- test edx, edx
- jz .total_error_2_is_0
- fld1 ; ST = 1.0 data_len
- mov [esp], edx
- mov [esp + 4], eax ; [esp] = (FLAC__uint64)total_error_2
- fild qword [esp] ; ST = total_error_2 1.0 data_len
- fdiv st2 ; ST = total_error_2/data_len 1.0 data_len
- fldln2 ; ST = ln2 total_error_2/data_len 1.0 data_len
- fmulp st1 ; ST = ln2*total_error_2/data_len 1.0 data_len
- fyl2x ; ST = log2(ln2*total_error_2/data_len) data_len
- fstp dword [ebx + 8] ; residual_bits_per_sample[2] = log2(ln2*total_error_2/data_len) ST = data_len
- jmp short .rbps_3
-.total_error_2_is_0:
- mov [ebx + 8], eax ; residual_bits_per_sample[2] = 0.0
-.rbps_3:
- test esi, esi
- jz .total_error_3_is_0
- fld1 ; ST = 1.0 data_len
- mov [esp], esi
- mov [esp + 4], eax ; [esp] = (FLAC__uint64)total_error_3
- fild qword [esp] ; ST = total_error_3 1.0 data_len
- fdiv st2 ; ST = total_error_3/data_len 1.0 data_len
- fldln2 ; ST = ln2 total_error_3/data_len 1.0 data_len
- fmulp st1 ; ST = ln2*total_error_3/data_len 1.0 data_len
- fyl2x ; ST = log2(ln2*total_error_3/data_len) data_len
- fstp dword [ebx + 12] ; residual_bits_per_sample[3] = log2(ln2*total_error_3/data_len) ST = data_len
- jmp short .rbps_4
-.total_error_3_is_0:
- mov [ebx + 12], eax ; residual_bits_per_sample[3] = 0.0
-.rbps_4:
- test edi, edi
- jz .total_error_4_is_0
- fld1 ; ST = 1.0 data_len
- mov [esp], edi
- mov [esp + 4], eax ; [esp] = (FLAC__uint64)total_error_4
- fild qword [esp] ; ST = total_error_4 1.0 data_len
- fdiv st2 ; ST = total_error_4/data_len 1.0 data_len
- fldln2 ; ST = ln2 total_error_4/data_len 1.0 data_len
- fmulp st1 ; ST = ln2*total_error_4/data_len 1.0 data_len
- fyl2x ; ST = log2(ln2*total_error_4/data_len) data_len
- fstp dword [ebx + 16] ; residual_bits_per_sample[4] = log2(ln2*total_error_4/data_len) ST = data_len
- jmp short .rbps_end
-.total_error_4_is_0:
- mov [ebx + 16], eax ; residual_bits_per_sample[4] = 0.0
-.rbps_end:
- fstp st0 ; ST = [empty]
- jmp short .end
-.data_len_is_0:
- ; data_len == 0, so residual_bits_per_sample[*] = 0.0
- xor ebp, ebp
- mov edi, [esp + 44]
- mov [edi], ebp
- mov [edi + 4], ebp
- mov [edi + 8], ebp
- mov [edi + 12], ebp
- mov [edi + 16], ebp
- add ebp, byte 4 ; order = 4
-
-.end:
- mov eax, ebp ; return order
- add esp, byte 16
- pop edi
- pop esi
- pop ebx
- pop ebp
- ret
-
-end
-
-%ifdef OBJ_FORMAT_elf
- section .note.GNU-stack noalloc
-%endif
diff --git a/src/thirdparty/libflac/src/libFLAC/ia32/lpc_asm.nasm b/src/thirdparty/libflac/src/libFLAC/ia32/lpc_asm.nasm
deleted file mode 100644
index 470371179..000000000
--- a/src/thirdparty/libflac/src/libFLAC/ia32/lpc_asm.nasm
+++ /dev/null
@@ -1,1511 +0,0 @@
-; vim:filetype=nasm ts=8
-
-; libFLAC - Free Lossless Audio Codec library
-; Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
-;
-; Redistribution and use in source and binary forms, with or without
-; modification, are permitted provided that the following conditions
-; are met:
-;
-; - Redistributions of source code must retain the above copyright
-; notice, this list of conditions and the following disclaimer.
-;
-; - 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.
-;
-; - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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 "nasm.h"
-
- data_section
-
-cglobal FLAC__lpc_compute_autocorrelation_asm_ia32
-cglobal FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_4
-cglobal FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_8
-cglobal FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_12
-cglobal FLAC__lpc_compute_autocorrelation_asm_ia32_3dnow
-cglobal FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32
-cglobal FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32_mmx
-cglobal FLAC__lpc_restore_signal_asm_ia32
-cglobal FLAC__lpc_restore_signal_asm_ia32_mmx
-
- code_section
-
-; **********************************************************************
-;
-; void FLAC__lpc_compute_autocorrelation_asm(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[])
-; {
-; FLAC__real d;
-; unsigned sample, coeff;
-; const unsigned limit = data_len - lag;
-;
-; FLAC__ASSERT(lag > 0);
-; FLAC__ASSERT(lag <= data_len);
-;
-; for(coeff = 0; coeff < lag; coeff++)
-; autoc[coeff] = 0.0;
-; for(sample = 0; sample <= limit; sample++) {
-; d = data[sample];
-; for(coeff = 0; coeff < lag; coeff++)
-; autoc[coeff] += d * data[sample+coeff];
-; }
-; for(; sample < data_len; sample++) {
-; d = data[sample];
-; for(coeff = 0; coeff < data_len - sample; coeff++)
-; autoc[coeff] += d * data[sample+coeff];
-; }
-; }
-;
- ALIGN 16
-cident FLAC__lpc_compute_autocorrelation_asm_ia32
- ;[esp + 28] == autoc[]
- ;[esp + 24] == lag
- ;[esp + 20] == data_len
- ;[esp + 16] == data[]
-
- ;ASSERT(lag > 0)
- ;ASSERT(lag <= 33)
- ;ASSERT(lag <= data_len)
-
-.begin:
- push esi
- push edi
- push ebx
-
- ; for(coeff = 0; coeff < lag; coeff++)
- ; autoc[coeff] = 0.0;
- mov edi, [esp + 28] ; edi == autoc
- mov ecx, [esp + 24] ; ecx = # of dwords (=lag) of 0 to write
- xor eax, eax
- rep stosd
-
- ; const unsigned limit = data_len - lag;
- mov eax, [esp + 24] ; eax == lag
- mov ecx, [esp + 20]
- sub ecx, eax ; ecx == limit
-
- mov edi, [esp + 28] ; edi == autoc
- mov esi, [esp + 16] ; esi == data
- inc ecx ; we are looping <= limit so we add one to the counter
-
- ; for(sample = 0; sample <= limit; sample++) {
- ; d = data[sample];
- ; for(coeff = 0; coeff < lag; coeff++)
- ; autoc[coeff] += d * data[sample+coeff];
- ; }
- fld dword [esi] ; ST = d <- data[sample]
- ; each iteration is 11 bytes so we need (-eax)*11, so we do (-12*eax + eax)
- lea edx, [eax + eax*2]
- neg edx
- lea edx, [eax + edx*4 + .jumper1_0 - .get_eip1]
- call .get_eip1
-.get_eip1:
- pop ebx
- add edx, ebx
- inc edx ; compensate for the shorter opcode on the last iteration
- inc edx ; compensate for the shorter opcode on the last iteration
- inc edx ; compensate for the shorter opcode on the last iteration
- cmp eax, 33
- jne .loop1_start
- sub edx, byte 9 ; compensate for the longer opcodes on the first iteration
-.loop1_start:
- jmp edx
-
- fld st0 ; ST = d d
- fmul dword [esi + (32*4)] ; ST = d*data[sample+32] d WATCHOUT: not a byte displacement here!
- fadd dword [edi + (32*4)] ; ST = autoc[32]+d*data[sample+32] d WATCHOUT: not a byte displacement here!
- fstp dword [edi + (32*4)] ; autoc[32]+=d*data[sample+32] ST = d WATCHOUT: not a byte displacement here!
- fld st0 ; ST = d d
- fmul dword [esi + (31*4)] ; ST = d*data[sample+31] d
- fadd dword [edi + (31*4)] ; ST = autoc[31]+d*data[sample+31] d
- fstp dword [edi + (31*4)] ; autoc[31]+=d*data[sample+31] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (30*4)] ; ST = d*data[sample+30] d
- fadd dword [edi + (30*4)] ; ST = autoc[30]+d*data[sample+30] d
- fstp dword [edi + (30*4)] ; autoc[30]+=d*data[sample+30] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (29*4)] ; ST = d*data[sample+29] d
- fadd dword [edi + (29*4)] ; ST = autoc[29]+d*data[sample+29] d
- fstp dword [edi + (29*4)] ; autoc[29]+=d*data[sample+29] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (28*4)] ; ST = d*data[sample+28] d
- fadd dword [edi + (28*4)] ; ST = autoc[28]+d*data[sample+28] d
- fstp dword [edi + (28*4)] ; autoc[28]+=d*data[sample+28] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (27*4)] ; ST = d*data[sample+27] d
- fadd dword [edi + (27*4)] ; ST = autoc[27]+d*data[sample+27] d
- fstp dword [edi + (27*4)] ; autoc[27]+=d*data[sample+27] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (26*4)] ; ST = d*data[sample+26] d
- fadd dword [edi + (26*4)] ; ST = autoc[26]+d*data[sample+26] d
- fstp dword [edi + (26*4)] ; autoc[26]+=d*data[sample+26] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (25*4)] ; ST = d*data[sample+25] d
- fadd dword [edi + (25*4)] ; ST = autoc[25]+d*data[sample+25] d
- fstp dword [edi + (25*4)] ; autoc[25]+=d*data[sample+25] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (24*4)] ; ST = d*data[sample+24] d
- fadd dword [edi + (24*4)] ; ST = autoc[24]+d*data[sample+24] d
- fstp dword [edi + (24*4)] ; autoc[24]+=d*data[sample+24] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (23*4)] ; ST = d*data[sample+23] d
- fadd dword [edi + (23*4)] ; ST = autoc[23]+d*data[sample+23] d
- fstp dword [edi + (23*4)] ; autoc[23]+=d*data[sample+23] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (22*4)] ; ST = d*data[sample+22] d
- fadd dword [edi + (22*4)] ; ST = autoc[22]+d*data[sample+22] d
- fstp dword [edi + (22*4)] ; autoc[22]+=d*data[sample+22] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (21*4)] ; ST = d*data[sample+21] d
- fadd dword [edi + (21*4)] ; ST = autoc[21]+d*data[sample+21] d
- fstp dword [edi + (21*4)] ; autoc[21]+=d*data[sample+21] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (20*4)] ; ST = d*data[sample+20] d
- fadd dword [edi + (20*4)] ; ST = autoc[20]+d*data[sample+20] d
- fstp dword [edi + (20*4)] ; autoc[20]+=d*data[sample+20] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (19*4)] ; ST = d*data[sample+19] d
- fadd dword [edi + (19*4)] ; ST = autoc[19]+d*data[sample+19] d
- fstp dword [edi + (19*4)] ; autoc[19]+=d*data[sample+19] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (18*4)] ; ST = d*data[sample+18] d
- fadd dword [edi + (18*4)] ; ST = autoc[18]+d*data[sample+18] d
- fstp dword [edi + (18*4)] ; autoc[18]+=d*data[sample+18] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (17*4)] ; ST = d*data[sample+17] d
- fadd dword [edi + (17*4)] ; ST = autoc[17]+d*data[sample+17] d
- fstp dword [edi + (17*4)] ; autoc[17]+=d*data[sample+17] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (16*4)] ; ST = d*data[sample+16] d
- fadd dword [edi + (16*4)] ; ST = autoc[16]+d*data[sample+16] d
- fstp dword [edi + (16*4)] ; autoc[16]+=d*data[sample+16] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (15*4)] ; ST = d*data[sample+15] d
- fadd dword [edi + (15*4)] ; ST = autoc[15]+d*data[sample+15] d
- fstp dword [edi + (15*4)] ; autoc[15]+=d*data[sample+15] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (14*4)] ; ST = d*data[sample+14] d
- fadd dword [edi + (14*4)] ; ST = autoc[14]+d*data[sample+14] d
- fstp dword [edi + (14*4)] ; autoc[14]+=d*data[sample+14] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (13*4)] ; ST = d*data[sample+13] d
- fadd dword [edi + (13*4)] ; ST = autoc[13]+d*data[sample+13] d
- fstp dword [edi + (13*4)] ; autoc[13]+=d*data[sample+13] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (12*4)] ; ST = d*data[sample+12] d
- fadd dword [edi + (12*4)] ; ST = autoc[12]+d*data[sample+12] d
- fstp dword [edi + (12*4)] ; autoc[12]+=d*data[sample+12] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (11*4)] ; ST = d*data[sample+11] d
- fadd dword [edi + (11*4)] ; ST = autoc[11]+d*data[sample+11] d
- fstp dword [edi + (11*4)] ; autoc[11]+=d*data[sample+11] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (10*4)] ; ST = d*data[sample+10] d
- fadd dword [edi + (10*4)] ; ST = autoc[10]+d*data[sample+10] d
- fstp dword [edi + (10*4)] ; autoc[10]+=d*data[sample+10] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + ( 9*4)] ; ST = d*data[sample+9] d
- fadd dword [edi + ( 9*4)] ; ST = autoc[9]+d*data[sample+9] d
- fstp dword [edi + ( 9*4)] ; autoc[9]+=d*data[sample+9] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + ( 8*4)] ; ST = d*data[sample+8] d
- fadd dword [edi + ( 8*4)] ; ST = autoc[8]+d*data[sample+8] d
- fstp dword [edi + ( 8*4)] ; autoc[8]+=d*data[sample+8] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + ( 7*4)] ; ST = d*data[sample+7] d
- fadd dword [edi + ( 7*4)] ; ST = autoc[7]+d*data[sample+7] d
- fstp dword [edi + ( 7*4)] ; autoc[7]+=d*data[sample+7] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + ( 6*4)] ; ST = d*data[sample+6] d
- fadd dword [edi + ( 6*4)] ; ST = autoc[6]+d*data[sample+6] d
- fstp dword [edi + ( 6*4)] ; autoc[6]+=d*data[sample+6] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + ( 5*4)] ; ST = d*data[sample+4] d
- fadd dword [edi + ( 5*4)] ; ST = autoc[4]+d*data[sample+4] d
- fstp dword [edi + ( 5*4)] ; autoc[4]+=d*data[sample+4] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + ( 4*4)] ; ST = d*data[sample+4] d
- fadd dword [edi + ( 4*4)] ; ST = autoc[4]+d*data[sample+4] d
- fstp dword [edi + ( 4*4)] ; autoc[4]+=d*data[sample+4] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + ( 3*4)] ; ST = d*data[sample+3] d
- fadd dword [edi + ( 3*4)] ; ST = autoc[3]+d*data[sample+3] d
- fstp dword [edi + ( 3*4)] ; autoc[3]+=d*data[sample+3] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + ( 2*4)] ; ST = d*data[sample+2] d
- fadd dword [edi + ( 2*4)] ; ST = autoc[2]+d*data[sample+2] d
- fstp dword [edi + ( 2*4)] ; autoc[2]+=d*data[sample+2] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + ( 1*4)] ; ST = d*data[sample+1] d
- fadd dword [edi + ( 1*4)] ; ST = autoc[1]+d*data[sample+1] d
- fstp dword [edi + ( 1*4)] ; autoc[1]+=d*data[sample+1] ST = d
- fld st0 ; ST = d d
- fmul dword [esi] ; ST = d*data[sample] d WATCHOUT: no displacement byte here!
- fadd dword [edi] ; ST = autoc[0]+d*data[sample] d WATCHOUT: no displacement byte here!
- fstp dword [edi] ; autoc[0]+=d*data[sample] ST = d WATCHOUT: no displacement byte here!
-.jumper1_0:
-
- fstp st0 ; pop d, ST = empty
- add esi, byte 4 ; sample++
- dec ecx
- jz .loop1_end
- fld dword [esi] ; ST = d <- data[sample]
- jmp edx
-.loop1_end:
-
- ; for(; sample < data_len; sample++) {
- ; d = data[sample];
- ; for(coeff = 0; coeff < data_len - sample; coeff++)
- ; autoc[coeff] += d * data[sample+coeff];
- ; }
- mov ecx, [esp + 24] ; ecx <- lag
- dec ecx ; ecx <- lag - 1
- jz near .end ; skip loop if 0 (i.e. lag == 1)
-
- fld dword [esi] ; ST = d <- data[sample]
- mov eax, ecx ; eax <- lag - 1 == data_len - sample the first time through
- ; each iteration is 11 bytes so we need (-eax)*11, so we do (-12*eax + eax)
- lea edx, [eax + eax*2]
- neg edx
- lea edx, [eax + edx*4 + .jumper2_0 - .get_eip2]
- call .get_eip2
-.get_eip2:
- pop ebx
- add edx, ebx
- inc edx ; compensate for the shorter opcode on the last iteration
- inc edx ; compensate for the shorter opcode on the last iteration
- inc edx ; compensate for the shorter opcode on the last iteration
- jmp edx
-
- fld st0 ; ST = d d
- fmul dword [esi + (31*4)] ; ST = d*data[sample+31] d
- fadd dword [edi + (31*4)] ; ST = autoc[31]+d*data[sample+31] d
- fstp dword [edi + (31*4)] ; autoc[31]+=d*data[sample+31] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (30*4)] ; ST = d*data[sample+30] d
- fadd dword [edi + (30*4)] ; ST = autoc[30]+d*data[sample+30] d
- fstp dword [edi + (30*4)] ; autoc[30]+=d*data[sample+30] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (29*4)] ; ST = d*data[sample+29] d
- fadd dword [edi + (29*4)] ; ST = autoc[29]+d*data[sample+29] d
- fstp dword [edi + (29*4)] ; autoc[29]+=d*data[sample+29] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (28*4)] ; ST = d*data[sample+28] d
- fadd dword [edi + (28*4)] ; ST = autoc[28]+d*data[sample+28] d
- fstp dword [edi + (28*4)] ; autoc[28]+=d*data[sample+28] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (27*4)] ; ST = d*data[sample+27] d
- fadd dword [edi + (27*4)] ; ST = autoc[27]+d*data[sample+27] d
- fstp dword [edi + (27*4)] ; autoc[27]+=d*data[sample+27] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (26*4)] ; ST = d*data[sample+26] d
- fadd dword [edi + (26*4)] ; ST = autoc[26]+d*data[sample+26] d
- fstp dword [edi + (26*4)] ; autoc[26]+=d*data[sample+26] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (25*4)] ; ST = d*data[sample+25] d
- fadd dword [edi + (25*4)] ; ST = autoc[25]+d*data[sample+25] d
- fstp dword [edi + (25*4)] ; autoc[25]+=d*data[sample+25] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (24*4)] ; ST = d*data[sample+24] d
- fadd dword [edi + (24*4)] ; ST = autoc[24]+d*data[sample+24] d
- fstp dword [edi + (24*4)] ; autoc[24]+=d*data[sample+24] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (23*4)] ; ST = d*data[sample+23] d
- fadd dword [edi + (23*4)] ; ST = autoc[23]+d*data[sample+23] d
- fstp dword [edi + (23*4)] ; autoc[23]+=d*data[sample+23] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (22*4)] ; ST = d*data[sample+22] d
- fadd dword [edi + (22*4)] ; ST = autoc[22]+d*data[sample+22] d
- fstp dword [edi + (22*4)] ; autoc[22]+=d*data[sample+22] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (21*4)] ; ST = d*data[sample+21] d
- fadd dword [edi + (21*4)] ; ST = autoc[21]+d*data[sample+21] d
- fstp dword [edi + (21*4)] ; autoc[21]+=d*data[sample+21] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (20*4)] ; ST = d*data[sample+20] d
- fadd dword [edi + (20*4)] ; ST = autoc[20]+d*data[sample+20] d
- fstp dword [edi + (20*4)] ; autoc[20]+=d*data[sample+20] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (19*4)] ; ST = d*data[sample+19] d
- fadd dword [edi + (19*4)] ; ST = autoc[19]+d*data[sample+19] d
- fstp dword [edi + (19*4)] ; autoc[19]+=d*data[sample+19] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (18*4)] ; ST = d*data[sample+18] d
- fadd dword [edi + (18*4)] ; ST = autoc[18]+d*data[sample+18] d
- fstp dword [edi + (18*4)] ; autoc[18]+=d*data[sample+18] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (17*4)] ; ST = d*data[sample+17] d
- fadd dword [edi + (17*4)] ; ST = autoc[17]+d*data[sample+17] d
- fstp dword [edi + (17*4)] ; autoc[17]+=d*data[sample+17] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (16*4)] ; ST = d*data[sample+16] d
- fadd dword [edi + (16*4)] ; ST = autoc[16]+d*data[sample+16] d
- fstp dword [edi + (16*4)] ; autoc[16]+=d*data[sample+16] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (15*4)] ; ST = d*data[sample+15] d
- fadd dword [edi + (15*4)] ; ST = autoc[15]+d*data[sample+15] d
- fstp dword [edi + (15*4)] ; autoc[15]+=d*data[sample+15] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (14*4)] ; ST = d*data[sample+14] d
- fadd dword [edi + (14*4)] ; ST = autoc[14]+d*data[sample+14] d
- fstp dword [edi + (14*4)] ; autoc[14]+=d*data[sample+14] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (13*4)] ; ST = d*data[sample+13] d
- fadd dword [edi + (13*4)] ; ST = autoc[13]+d*data[sample+13] d
- fstp dword [edi + (13*4)] ; autoc[13]+=d*data[sample+13] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (12*4)] ; ST = d*data[sample+12] d
- fadd dword [edi + (12*4)] ; ST = autoc[12]+d*data[sample+12] d
- fstp dword [edi + (12*4)] ; autoc[12]+=d*data[sample+12] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (11*4)] ; ST = d*data[sample+11] d
- fadd dword [edi + (11*4)] ; ST = autoc[11]+d*data[sample+11] d
- fstp dword [edi + (11*4)] ; autoc[11]+=d*data[sample+11] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + (10*4)] ; ST = d*data[sample+10] d
- fadd dword [edi + (10*4)] ; ST = autoc[10]+d*data[sample+10] d
- fstp dword [edi + (10*4)] ; autoc[10]+=d*data[sample+10] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + ( 9*4)] ; ST = d*data[sample+9] d
- fadd dword [edi + ( 9*4)] ; ST = autoc[9]+d*data[sample+9] d
- fstp dword [edi + ( 9*4)] ; autoc[9]+=d*data[sample+9] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + ( 8*4)] ; ST = d*data[sample+8] d
- fadd dword [edi + ( 8*4)] ; ST = autoc[8]+d*data[sample+8] d
- fstp dword [edi + ( 8*4)] ; autoc[8]+=d*data[sample+8] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + ( 7*4)] ; ST = d*data[sample+7] d
- fadd dword [edi + ( 7*4)] ; ST = autoc[7]+d*data[sample+7] d
- fstp dword [edi + ( 7*4)] ; autoc[7]+=d*data[sample+7] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + ( 6*4)] ; ST = d*data[sample+6] d
- fadd dword [edi + ( 6*4)] ; ST = autoc[6]+d*data[sample+6] d
- fstp dword [edi + ( 6*4)] ; autoc[6]+=d*data[sample+6] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + ( 5*4)] ; ST = d*data[sample+4] d
- fadd dword [edi + ( 5*4)] ; ST = autoc[4]+d*data[sample+4] d
- fstp dword [edi + ( 5*4)] ; autoc[4]+=d*data[sample+4] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + ( 4*4)] ; ST = d*data[sample+4] d
- fadd dword [edi + ( 4*4)] ; ST = autoc[4]+d*data[sample+4] d
- fstp dword [edi + ( 4*4)] ; autoc[4]+=d*data[sample+4] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + ( 3*4)] ; ST = d*data[sample+3] d
- fadd dword [edi + ( 3*4)] ; ST = autoc[3]+d*data[sample+3] d
- fstp dword [edi + ( 3*4)] ; autoc[3]+=d*data[sample+3] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + ( 2*4)] ; ST = d*data[sample+2] d
- fadd dword [edi + ( 2*4)] ; ST = autoc[2]+d*data[sample+2] d
- fstp dword [edi + ( 2*4)] ; autoc[2]+=d*data[sample+2] ST = d
- fld st0 ; ST = d d
- fmul dword [esi + ( 1*4)] ; ST = d*data[sample+1] d
- fadd dword [edi + ( 1*4)] ; ST = autoc[1]+d*data[sample+1] d
- fstp dword [edi + ( 1*4)] ; autoc[1]+=d*data[sample+1] ST = d
- fld st0 ; ST = d d
- fmul dword [esi] ; ST = d*data[sample] d WATCHOUT: no displacement byte here!
- fadd dword [edi] ; ST = autoc[0]+d*data[sample] d WATCHOUT: no displacement byte here!
- fstp dword [edi] ; autoc[0]+=d*data[sample] ST = d WATCHOUT: no displacement byte here!
-.jumper2_0:
-
- fstp st0 ; pop d, ST = empty
- add esi, byte 4 ; sample++
- dec ecx
- jz .loop2_end
- add edx, byte 11 ; adjust our inner loop counter by adjusting the jump target
- fld dword [esi] ; ST = d <- data[sample]
- jmp edx
-.loop2_end:
-
-.end:
- pop ebx
- pop edi
- pop esi
- ret
-
- ALIGN 16
-cident FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_4
- ;[esp + 16] == autoc[]
- ;[esp + 12] == lag
- ;[esp + 8] == data_len
- ;[esp + 4] == data[]
-
- ;ASSERT(lag > 0)
- ;ASSERT(lag <= 4)
- ;ASSERT(lag <= data_len)
-
- ; for(coeff = 0; coeff < lag; coeff++)
- ; autoc[coeff] = 0.0;
- xorps xmm5, xmm5
-
- mov edx, [esp + 8] ; edx == data_len
- mov eax, [esp + 4] ; eax == &data[sample] <- &data[0]
-
- movss xmm0, [eax] ; xmm0 = 0,0,0,data[0]
- add eax, 4
- movaps xmm2, xmm0 ; xmm2 = 0,0,0,data[0]
- shufps xmm0, xmm0, 0 ; xmm0 == data[sample],data[sample],data[sample],data[sample] = data[0],data[0],data[0],data[0]
-.warmup: ; xmm2 == data[sample-3],data[sample-2],data[sample-1],data[sample]
- mulps xmm0, xmm2 ; xmm0 = xmm0 * xmm2
- addps xmm5, xmm0 ; xmm5 += xmm0 * xmm2
- dec edx
- jz .loop_end
- ALIGN 16
-.loop_start:
- ; start by reading the next sample
- movss xmm0, [eax] ; xmm0 = 0,0,0,data[sample]
- add eax, 4
- shufps xmm0, xmm0, 0 ; xmm0 = data[sample],data[sample],data[sample],data[sample]
- shufps xmm2, xmm2, 93h ; 93h=2-1-0-3 => xmm2 gets rotated left by one float
- movss xmm2, xmm0
- mulps xmm0, xmm2 ; xmm0 = xmm0 * xmm2
- addps xmm5, xmm0 ; xmm5 += xmm0 * xmm2
- dec edx
- jnz .loop_start
-.loop_end:
- ; store autoc
- mov edx, [esp + 16] ; edx == autoc
- movups [edx], xmm5
-
-.end:
- ret
-
- ALIGN 16
-cident FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_8
- ;[esp + 16] == autoc[]
- ;[esp + 12] == lag
- ;[esp + 8] == data_len
- ;[esp + 4] == data[]
-
- ;ASSERT(lag > 0)
- ;ASSERT(lag <= 8)
- ;ASSERT(lag <= data_len)
-
- ; for(coeff = 0; coeff < lag; coeff++)
- ; autoc[coeff] = 0.0;
- xorps xmm5, xmm5
- xorps xmm6, xmm6
-
- mov edx, [esp + 8] ; edx == data_len
- mov eax, [esp + 4] ; eax == &data[sample] <- &data[0]
-
- movss xmm0, [eax] ; xmm0 = 0,0,0,data[0]
- add eax, 4
- movaps xmm2, xmm0 ; xmm2 = 0,0,0,data[0]
- shufps xmm0, xmm0, 0 ; xmm0 == data[sample],data[sample],data[sample],data[sample] = data[0],data[0],data[0],data[0]
- movaps xmm1, xmm0 ; xmm1 == data[sample],data[sample],data[sample],data[sample] = data[0],data[0],data[0],data[0]
- xorps xmm3, xmm3 ; xmm3 = 0,0,0,0
-.warmup: ; xmm3:xmm2 == data[sample-7],data[sample-6],...,data[sample]
- mulps xmm0, xmm2
- mulps xmm1, xmm3 ; xmm1:xmm0 = xmm1:xmm0 * xmm3:xmm2
- addps xmm5, xmm0
- addps xmm6, xmm1 ; xmm6:xmm5 += xmm1:xmm0 * xmm3:xmm2
- dec edx
- jz .loop_end
- ALIGN 16
-.loop_start:
- ; start by reading the next sample
- movss xmm0, [eax] ; xmm0 = 0,0,0,data[sample]
- ; here we reorder the instructions; see the (#) indexes for a logical order
- shufps xmm2, xmm2, 93h ; (3) 93h=2-1-0-3 => xmm2 gets rotated left by one float
- add eax, 4 ; (0)
- shufps xmm3, xmm3, 93h ; (4) 93h=2-1-0-3 => xmm3 gets rotated left by one float
- shufps xmm0, xmm0, 0 ; (1) xmm0 = data[sample],data[sample],data[sample],data[sample]
- movss xmm3, xmm2 ; (5)
- movaps xmm1, xmm0 ; (2) xmm1 = data[sample],data[sample],data[sample],data[sample]
- movss xmm2, xmm0 ; (6)
- mulps xmm1, xmm3 ; (8)
- mulps xmm0, xmm2 ; (7) xmm1:xmm0 = xmm1:xmm0 * xmm3:xmm2
- addps xmm6, xmm1 ; (10)
- addps xmm5, xmm0 ; (9) xmm6:xmm5 += xmm1:xmm0 * xmm3:xmm2
- dec edx
- jnz .loop_start
-.loop_end:
- ; store autoc
- mov edx, [esp + 16] ; edx == autoc
- movups [edx], xmm5
- movups [edx + 16], xmm6
-
-.end:
- ret
-
- ALIGN 16
-cident FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_12
- ;[esp + 16] == autoc[]
- ;[esp + 12] == lag
- ;[esp + 8] == data_len
- ;[esp + 4] == data[]
-
- ;ASSERT(lag > 0)
- ;ASSERT(lag <= 12)
- ;ASSERT(lag <= data_len)
-
- ; for(coeff = 0; coeff < lag; coeff++)
- ; autoc[coeff] = 0.0;
- xorps xmm5, xmm5
- xorps xmm6, xmm6
- xorps xmm7, xmm7
-
- mov edx, [esp + 8] ; edx == data_len
- mov eax, [esp + 4] ; eax == &data[sample] <- &data[0]
-
- movss xmm0, [eax] ; xmm0 = 0,0,0,data[0]
- add eax, 4
- movaps xmm2, xmm0 ; xmm2 = 0,0,0,data[0]
- shufps xmm0, xmm0, 0 ; xmm0 == data[sample],data[sample],data[sample],data[sample] = data[0],data[0],data[0],data[0]
- xorps xmm3, xmm3 ; xmm3 = 0,0,0,0
- xorps xmm4, xmm4 ; xmm4 = 0,0,0,0
-.warmup: ; xmm3:xmm2 == data[sample-7],data[sample-6],...,data[sample]
- movaps xmm1, xmm0
- mulps xmm1, xmm2
- addps xmm5, xmm1
- movaps xmm1, xmm0
- mulps xmm1, xmm3
- addps xmm6, xmm1
- mulps xmm0, xmm4
- addps xmm7, xmm0 ; xmm7:xmm6:xmm5 += xmm0:xmm0:xmm0 * xmm4:xmm3:xmm2
- dec edx
- jz .loop_end
- ALIGN 16
-.loop_start:
- ; start by reading the next sample
- movss xmm0, [eax] ; xmm0 = 0,0,0,data[sample]
- add eax, 4
- shufps xmm0, xmm0, 0 ; xmm0 = data[sample],data[sample],data[sample],data[sample]
-
- ; shift xmm4:xmm3:xmm2 left by one float
- shufps xmm2, xmm2, 93h ; 93h=2-1-0-3 => xmm2 gets rotated left by one float
- shufps xmm3, xmm3, 93h ; 93h=2-1-0-3 => xmm3 gets rotated left by one float
- shufps xmm4, xmm4, 93h ; 93h=2-1-0-3 => xmm4 gets rotated left by one float
- movss xmm4, xmm3
- movss xmm3, xmm2
- movss xmm2, xmm0
-
- ; xmm7:xmm6:xmm5 += xmm0:xmm0:xmm0 * xmm3:xmm3:xmm2
- movaps xmm1, xmm0
- mulps xmm1, xmm2
- addps xmm5, xmm1
- movaps xmm1, xmm0
- mulps xmm1, xmm3
- addps xmm6, xmm1
- mulps xmm0, xmm4
- addps xmm7, xmm0
-
- dec edx
- jnz .loop_start
-.loop_end:
- ; store autoc
- mov edx, [esp + 16] ; edx == autoc
- movups [edx], xmm5
- movups [edx + 16], xmm6
- movups [edx + 32], xmm7
-
-.end:
- ret
-
- ALIGN 16
-cident FLAC__lpc_compute_autocorrelation_asm_ia32_3dnow
- ;[ebp + 32] autoc
- ;[ebp + 28] lag
- ;[ebp + 24] data_len
- ;[ebp + 20] data
-
- push ebp
- push ebx
- push esi
- push edi
- mov ebp, esp
-
- mov esi, [ebp + 20]
- mov edi, [ebp + 24]
- mov edx, [ebp + 28]
- inc edx
- and edx, byte -2
- mov eax, edx
- neg eax
- and esp, byte -8
- lea esp, [esp + 4 * eax]
- mov ecx, edx
- xor eax, eax
-.loop0:
- dec ecx
- mov [esp + 4 * ecx], eax
- jnz short .loop0
-
- mov eax, edi
- sub eax, edx
- mov ebx, edx
- and ebx, byte 1
- sub eax, ebx
- lea ecx, [esi + 4 * eax - 12]
- cmp esi, ecx
- mov eax, esi
- ja short .loop2_pre
- ALIGN 16 ;4 nops
-.loop1_i:
- movd mm0, [eax]
- movd mm2, [eax + 4]
- movd mm4, [eax + 8]
- movd mm6, [eax + 12]
- mov ebx, edx
- punpckldq mm0, mm0
- punpckldq mm2, mm2
- punpckldq mm4, mm4
- punpckldq mm6, mm6
- ALIGN 16 ;3 nops
-.loop1_j:
- sub ebx, byte 2
- movd mm1, [eax + 4 * ebx]
- movd mm3, [eax + 4 * ebx + 4]
- movd mm5, [eax + 4 * ebx + 8]
- movd mm7, [eax + 4 * ebx + 12]
- punpckldq mm1, mm3
- punpckldq mm3, mm5
- pfmul mm1, mm0
- punpckldq mm5, mm7
- pfmul mm3, mm2
- punpckldq mm7, [eax + 4 * ebx + 16]
- pfmul mm5, mm4
- pfmul mm7, mm6
- pfadd mm1, mm3
- movq mm3, [esp + 4 * ebx]
- pfadd mm5, mm7
- pfadd mm1, mm5
- pfadd mm3, mm1
- movq [esp + 4 * ebx], mm3
- jg short .loop1_j
-
- add eax, byte 16
- cmp eax, ecx
- jb short .loop1_i
-
-.loop2_pre:
- mov ebx, eax
- sub eax, esi
- shr eax, 2
- lea ecx, [esi + 4 * edi]
- mov esi, ebx
-.loop2_i:
- movd mm0, [esi]
- mov ebx, edi
- sub ebx, eax
- cmp ebx, edx
- jbe short .loop2_j
- mov ebx, edx
-.loop2_j:
- dec ebx
- movd mm1, [esi + 4 * ebx]
- pfmul mm1, mm0
- movd mm2, [esp + 4 * ebx]
- pfadd mm1, mm2
- movd [esp + 4 * ebx], mm1
-
- jnz short .loop2_j
-
- add esi, byte 4
- inc eax
- cmp esi, ecx
- jnz short .loop2_i
-
- mov edi, [ebp + 32]
- mov edx, [ebp + 28]
-.loop3:
- dec edx
- mov eax, [esp + 4 * edx]
- mov [edi + 4 * edx], eax
- jnz short .loop3
-
- femms
-
- mov esp, ebp
- pop edi
- pop esi
- pop ebx
- pop ebp
- ret
-
-;void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[])
-;
-; for(i = 0; i < data_len; i++) {
-; sum = 0;
-; for(j = 0; j < order; j++)
-; sum += qlp_coeff[j] * data[i-j-1];
-; residual[i] = data[i] - (sum >> lp_quantization);
-; }
-;
- ALIGN 16
-cident FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32
- ;[esp + 40] residual[]
- ;[esp + 36] lp_quantization
- ;[esp + 32] order
- ;[esp + 28] qlp_coeff[]
- ;[esp + 24] data_len
- ;[esp + 20] data[]
-
- ;ASSERT(order > 0)
-
- push ebp
- push ebx
- push esi
- push edi
-
- mov esi, [esp + 20] ; esi = data[]
- mov edi, [esp + 40] ; edi = residual[]
- mov eax, [esp + 32] ; eax = order
- mov ebx, [esp + 24] ; ebx = data_len
-
- test ebx, ebx
- jz near .end ; do nothing if data_len == 0
-.begin:
- cmp eax, byte 1
- jg short .i_1more
-
- mov ecx, [esp + 28]
- mov edx, [ecx] ; edx = qlp_coeff[0]
- mov eax, [esi - 4] ; eax = data[-1]
- mov cl, [esp + 36] ; cl = lp_quantization
- ALIGN 16
-.i_1_loop_i:
- imul eax, edx
- sar eax, cl
- neg eax
- add eax, [esi]
- mov [edi], eax
- mov eax, [esi]
- add edi, byte 4
- add esi, byte 4
- dec ebx
- jnz .i_1_loop_i
-
- jmp .end
-
-.i_1more:
- cmp eax, byte 32 ; for order <= 32 there is a faster routine
- jbe short .i_32
-
- ; This version is here just for completeness, since FLAC__MAX_LPC_ORDER == 32
- ALIGN 16
-.i_32more_loop_i:
- xor ebp, ebp
- mov ecx, [esp + 32]
- mov edx, ecx
- shl edx, 2
- add edx, [esp + 28]
- neg ecx
- ALIGN 16
-.i_32more_loop_j:
- sub edx, byte 4
- mov eax, [edx]
- imul eax, [esi + 4 * ecx]
- add ebp, eax
- inc ecx
- jnz short .i_32more_loop_j
-
- mov cl, [esp + 36]
- sar ebp, cl
- neg ebp
- add ebp, [esi]
- mov [edi], ebp
- add esi, byte 4
- add edi, byte 4
-
- dec ebx
- jnz .i_32more_loop_i
-
- jmp .end
-
-.i_32:
- sub edi, esi
- neg eax
- lea edx, [eax + eax * 8 + .jumper_0 - .get_eip0]
- call .get_eip0
-.get_eip0:
- pop eax
- add edx, eax
- inc edx
- mov eax, [esp + 28] ; eax = qlp_coeff[]
- xor ebp, ebp
- jmp edx
-
- mov ecx, [eax + 124]
- imul ecx, [esi - 128]
- add ebp, ecx
- mov ecx, [eax + 120]
- imul ecx, [esi - 124]
- add ebp, ecx
- mov ecx, [eax + 116]
- imul ecx, [esi - 120]
- add ebp, ecx
- mov ecx, [eax + 112]
- imul ecx, [esi - 116]
- add ebp, ecx
- mov ecx, [eax + 108]
- imul ecx, [esi - 112]
- add ebp, ecx
- mov ecx, [eax + 104]
- imul ecx, [esi - 108]
- add ebp, ecx
- mov ecx, [eax + 100]
- imul ecx, [esi - 104]
- add ebp, ecx
- mov ecx, [eax + 96]
- imul ecx, [esi - 100]
- add ebp, ecx
- mov ecx, [eax + 92]
- imul ecx, [esi - 96]
- add ebp, ecx
- mov ecx, [eax + 88]
- imul ecx, [esi - 92]
- add ebp, ecx
- mov ecx, [eax + 84]
- imul ecx, [esi - 88]
- add ebp, ecx
- mov ecx, [eax + 80]
- imul ecx, [esi - 84]
- add ebp, ecx
- mov ecx, [eax + 76]
- imul ecx, [esi - 80]
- add ebp, ecx
- mov ecx, [eax + 72]
- imul ecx, [esi - 76]
- add ebp, ecx
- mov ecx, [eax + 68]
- imul ecx, [esi - 72]
- add ebp, ecx
- mov ecx, [eax + 64]
- imul ecx, [esi - 68]
- add ebp, ecx
- mov ecx, [eax + 60]
- imul ecx, [esi - 64]
- add ebp, ecx
- mov ecx, [eax + 56]
- imul ecx, [esi - 60]
- add ebp, ecx
- mov ecx, [eax + 52]
- imul ecx, [esi - 56]
- add ebp, ecx
- mov ecx, [eax + 48]
- imul ecx, [esi - 52]
- add ebp, ecx
- mov ecx, [eax + 44]
- imul ecx, [esi - 48]
- add ebp, ecx
- mov ecx, [eax + 40]
- imul ecx, [esi - 44]
- add ebp, ecx
- mov ecx, [eax + 36]
- imul ecx, [esi - 40]
- add ebp, ecx
- mov ecx, [eax + 32]
- imul ecx, [esi - 36]
- add ebp, ecx
- mov ecx, [eax + 28]
- imul ecx, [esi - 32]
- add ebp, ecx
- mov ecx, [eax + 24]
- imul ecx, [esi - 28]
- add ebp, ecx
- mov ecx, [eax + 20]
- imul ecx, [esi - 24]
- add ebp, ecx
- mov ecx, [eax + 16]
- imul ecx, [esi - 20]
- add ebp, ecx
- mov ecx, [eax + 12]
- imul ecx, [esi - 16]
- add ebp, ecx
- mov ecx, [eax + 8]
- imul ecx, [esi - 12]
- add ebp, ecx
- mov ecx, [eax + 4]
- imul ecx, [esi - 8]
- add ebp, ecx
- mov ecx, [eax] ; there is one byte missing
- imul ecx, [esi - 4]
- add ebp, ecx
-.jumper_0:
-
- mov cl, [esp + 36]
- sar ebp, cl
- neg ebp
- add ebp, [esi]
- mov [edi + esi], ebp
- add esi, byte 4
-
- dec ebx
- jz short .end
- xor ebp, ebp
- jmp edx
-
-.end:
- pop edi
- pop esi
- pop ebx
- pop ebp
- ret
-
-; WATCHOUT: this routine works on 16 bit data which means bits-per-sample for
-; the channel and qlp_coeffs must be <= 16. Especially note that this routine
-; cannot be used for side-channel coded 16bps channels since the effective bps
-; is 17.
- ALIGN 16
-cident FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32_mmx
- ;[esp + 40] residual[]
- ;[esp + 36] lp_quantization
- ;[esp + 32] order
- ;[esp + 28] qlp_coeff[]
- ;[esp + 24] data_len
- ;[esp + 20] data[]
-
- ;ASSERT(order > 0)
-
- push ebp
- push ebx
- push esi
- push edi
-
- mov esi, [esp + 20] ; esi = data[]
- mov edi, [esp + 40] ; edi = residual[]
- mov eax, [esp + 32] ; eax = order
- mov ebx, [esp + 24] ; ebx = data_len
-
- test ebx, ebx
- jz near .end ; do nothing if data_len == 0
- dec ebx
- test ebx, ebx
- jz near .last_one
-
- mov edx, [esp + 28] ; edx = qlp_coeff[]
- movd mm6, [esp + 36] ; mm6 = 0:lp_quantization
- mov ebp, esp
-
- and esp, 0xfffffff8
-
- xor ecx, ecx
-.copy_qlp_loop:
- push word [edx + 4 * ecx]
- inc ecx
- cmp ecx, eax
- jnz short .copy_qlp_loop
-
- and ecx, 0x3
- test ecx, ecx
- je short .za_end
- sub ecx, byte 4
-.za_loop:
- push word 0
- inc eax
- inc ecx
- jnz short .za_loop
-.za_end:
-
- movq mm5, [esp + 2 * eax - 8]
- movd mm4, [esi - 16]
- punpckldq mm4, [esi - 12]
- movd mm0, [esi - 8]
- punpckldq mm0, [esi - 4]
- packssdw mm4, mm0
-
- cmp eax, byte 4
- jnbe short .mmx_4more
-
- ALIGN 16
-.mmx_4_loop_i:
- movd mm1, [esi]
- movq mm3, mm4
- punpckldq mm1, [esi + 4]
- psrlq mm4, 16
- movq mm0, mm1
- psllq mm0, 48
- por mm4, mm0
- movq mm2, mm4
- psrlq mm4, 16
- pxor mm0, mm0
- punpckhdq mm0, mm1
- pmaddwd mm3, mm5
- pmaddwd mm2, mm5
- psllq mm0, 16
- por mm4, mm0
- movq mm0, mm3
- punpckldq mm3, mm2
- punpckhdq mm0, mm2
- paddd mm3, mm0
- psrad mm3, mm6
- psubd mm1, mm3
- movd [edi], mm1
- punpckhdq mm1, mm1
- movd [edi + 4], mm1
-
- add edi, byte 8
- add esi, byte 8
-
- sub ebx, 2
- jg .mmx_4_loop_i
- jmp .mmx_end
-
-.mmx_4more:
- shl eax, 2
- neg eax
- add eax, byte 16
-
- ALIGN 16
-.mmx_4more_loop_i:
- movd mm1, [esi]
- punpckldq mm1, [esi + 4]
- movq mm3, mm4
- psrlq mm4, 16
- movq mm0, mm1
- psllq mm0, 48
- por mm4, mm0
- movq mm2, mm4
- psrlq mm4, 16
- pxor mm0, mm0
- punpckhdq mm0, mm1
- pmaddwd mm3, mm5
- pmaddwd mm2, mm5
- psllq mm0, 16
- por mm4, mm0
-
- mov ecx, esi
- add ecx, eax
- mov edx, esp
-
- ALIGN 16
-.mmx_4more_loop_j:
- movd mm0, [ecx - 16]
- movd mm7, [ecx - 8]
- punpckldq mm0, [ecx - 12]
- punpckldq mm7, [ecx - 4]
- packssdw mm0, mm7
- pmaddwd mm0, [edx]
- punpckhdq mm7, mm7
- paddd mm3, mm0
- movd mm0, [ecx - 12]
- punpckldq mm0, [ecx - 8]
- punpckldq mm7, [ecx]
- packssdw mm0, mm7
- pmaddwd mm0, [edx]
- paddd mm2, mm0
-
- add edx, byte 8
- add ecx, byte 16
- cmp ecx, esi
- jnz .mmx_4more_loop_j
-
- movq mm0, mm3
- punpckldq mm3, mm2
- punpckhdq mm0, mm2
- paddd mm3, mm0
- psrad mm3, mm6
- psubd mm1, mm3
- movd [edi], mm1
- punpckhdq mm1, mm1
- movd [edi + 4], mm1
-
- add edi, byte 8
- add esi, byte 8
-
- sub ebx, 2
- jg near .mmx_4more_loop_i
-
-.mmx_end:
- emms
- mov esp, ebp
-.last_one:
- mov eax, [esp + 32]
- inc ebx
- jnz near FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32.begin
-
-.end:
- pop edi
- pop esi
- pop ebx
- pop ebp
- ret
-
-; **********************************************************************
-;
-; void FLAC__lpc_restore_signal(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[])
-; {
-; unsigned i, j;
-; FLAC__int32 sum;
-;
-; FLAC__ASSERT(order > 0);
-;
-; for(i = 0; i < data_len; i++) {
-; sum = 0;
-; for(j = 0; j < order; j++)
-; sum += qlp_coeff[j] * data[i-j-1];
-; data[i] = residual[i] + (sum >> lp_quantization);
-; }
-; }
- ALIGN 16
-cident FLAC__lpc_restore_signal_asm_ia32
- ;[esp + 40] data[]
- ;[esp + 36] lp_quantization
- ;[esp + 32] order
- ;[esp + 28] qlp_coeff[]
- ;[esp + 24] data_len
- ;[esp + 20] residual[]
-
- ;ASSERT(order > 0)
-
- push ebp
- push ebx
- push esi
- push edi
-
- mov esi, [esp + 20] ; esi = residual[]
- mov edi, [esp + 40] ; edi = data[]
- mov eax, [esp + 32] ; eax = order
- mov ebx, [esp + 24] ; ebx = data_len
-
- test ebx, ebx
- jz near .end ; do nothing if data_len == 0
-
-.begin:
- cmp eax, byte 1
- jg short .x87_1more
-
- mov ecx, [esp + 28]
- mov edx, [ecx]
- mov eax, [edi - 4]
- mov cl, [esp + 36]
- ALIGN 16
-.x87_1_loop_i:
- imul eax, edx
- sar eax, cl
- add eax, [esi]
- mov [edi], eax
- add esi, byte 4
- add edi, byte 4
- dec ebx
- jnz .x87_1_loop_i
-
- jmp .end
-
-.x87_1more:
- cmp eax, byte 32 ; for order <= 32 there is a faster routine
- jbe short .x87_32
-
- ; This version is here just for completeness, since FLAC__MAX_LPC_ORDER == 32
- ALIGN 16
-.x87_32more_loop_i:
- xor ebp, ebp
- mov ecx, [esp + 32]
- mov edx, ecx
- shl edx, 2
- add edx, [esp + 28]
- neg ecx
- ALIGN 16
-.x87_32more_loop_j:
- sub edx, byte 4
- mov eax, [edx]
- imul eax, [edi + 4 * ecx]
- add ebp, eax
- inc ecx
- jnz short .x87_32more_loop_j
-
- mov cl, [esp + 36]
- sar ebp, cl
- add ebp, [esi]
- mov [edi], ebp
- add edi, byte 4
- add esi, byte 4
-
- dec ebx
- jnz .x87_32more_loop_i
-
- jmp .end
-
-.x87_32:
- sub esi, edi
- neg eax
- lea edx, [eax + eax * 8 + .jumper_0 - .get_eip0]
- call .get_eip0
-.get_eip0:
- pop eax
- add edx, eax
- inc edx ; compensate for the shorter opcode on the last iteration
- mov eax, [esp + 28] ; eax = qlp_coeff[]
- xor ebp, ebp
- jmp edx
-
- mov ecx, [eax + 124] ; ecx = qlp_coeff[31]
- imul ecx, [edi - 128] ; ecx = qlp_coeff[31] * data[i-32]
- add ebp, ecx ; sum += qlp_coeff[31] * data[i-32]
- mov ecx, [eax + 120] ; ecx = qlp_coeff[30]
- imul ecx, [edi - 124] ; ecx = qlp_coeff[30] * data[i-31]
- add ebp, ecx ; sum += qlp_coeff[30] * data[i-31]
- mov ecx, [eax + 116] ; ecx = qlp_coeff[29]
- imul ecx, [edi - 120] ; ecx = qlp_coeff[29] * data[i-30]
- add ebp, ecx ; sum += qlp_coeff[29] * data[i-30]
- mov ecx, [eax + 112] ; ecx = qlp_coeff[28]
- imul ecx, [edi - 116] ; ecx = qlp_coeff[28] * data[i-29]
- add ebp, ecx ; sum += qlp_coeff[28] * data[i-29]
- mov ecx, [eax + 108] ; ecx = qlp_coeff[27]
- imul ecx, [edi - 112] ; ecx = qlp_coeff[27] * data[i-28]
- add ebp, ecx ; sum += qlp_coeff[27] * data[i-28]
- mov ecx, [eax + 104] ; ecx = qlp_coeff[26]
- imul ecx, [edi - 108] ; ecx = qlp_coeff[26] * data[i-27]
- add ebp, ecx ; sum += qlp_coeff[26] * data[i-27]
- mov ecx, [eax + 100] ; ecx = qlp_coeff[25]
- imul ecx, [edi - 104] ; ecx = qlp_coeff[25] * data[i-26]
- add ebp, ecx ; sum += qlp_coeff[25] * data[i-26]
- mov ecx, [eax + 96] ; ecx = qlp_coeff[24]
- imul ecx, [edi - 100] ; ecx = qlp_coeff[24] * data[i-25]
- add ebp, ecx ; sum += qlp_coeff[24] * data[i-25]
- mov ecx, [eax + 92] ; ecx = qlp_coeff[23]
- imul ecx, [edi - 96] ; ecx = qlp_coeff[23] * data[i-24]
- add ebp, ecx ; sum += qlp_coeff[23] * data[i-24]
- mov ecx, [eax + 88] ; ecx = qlp_coeff[22]
- imul ecx, [edi - 92] ; ecx = qlp_coeff[22] * data[i-23]
- add ebp, ecx ; sum += qlp_coeff[22] * data[i-23]
- mov ecx, [eax + 84] ; ecx = qlp_coeff[21]
- imul ecx, [edi - 88] ; ecx = qlp_coeff[21] * data[i-22]
- add ebp, ecx ; sum += qlp_coeff[21] * data[i-22]
- mov ecx, [eax + 80] ; ecx = qlp_coeff[20]
- imul ecx, [edi - 84] ; ecx = qlp_coeff[20] * data[i-21]
- add ebp, ecx ; sum += qlp_coeff[20] * data[i-21]
- mov ecx, [eax + 76] ; ecx = qlp_coeff[19]
- imul ecx, [edi - 80] ; ecx = qlp_coeff[19] * data[i-20]
- add ebp, ecx ; sum += qlp_coeff[19] * data[i-20]
- mov ecx, [eax + 72] ; ecx = qlp_coeff[18]
- imul ecx, [edi - 76] ; ecx = qlp_coeff[18] * data[i-19]
- add ebp, ecx ; sum += qlp_coeff[18] * data[i-19]
- mov ecx, [eax + 68] ; ecx = qlp_coeff[17]
- imul ecx, [edi - 72] ; ecx = qlp_coeff[17] * data[i-18]
- add ebp, ecx ; sum += qlp_coeff[17] * data[i-18]
- mov ecx, [eax + 64] ; ecx = qlp_coeff[16]
- imul ecx, [edi - 68] ; ecx = qlp_coeff[16] * data[i-17]
- add ebp, ecx ; sum += qlp_coeff[16] * data[i-17]
- mov ecx, [eax + 60] ; ecx = qlp_coeff[15]
- imul ecx, [edi - 64] ; ecx = qlp_coeff[15] * data[i-16]
- add ebp, ecx ; sum += qlp_coeff[15] * data[i-16]
- mov ecx, [eax + 56] ; ecx = qlp_coeff[14]
- imul ecx, [edi - 60] ; ecx = qlp_coeff[14] * data[i-15]
- add ebp, ecx ; sum += qlp_coeff[14] * data[i-15]
- mov ecx, [eax + 52] ; ecx = qlp_coeff[13]
- imul ecx, [edi - 56] ; ecx = qlp_coeff[13] * data[i-14]
- add ebp, ecx ; sum += qlp_coeff[13] * data[i-14]
- mov ecx, [eax + 48] ; ecx = qlp_coeff[12]
- imul ecx, [edi - 52] ; ecx = qlp_coeff[12] * data[i-13]
- add ebp, ecx ; sum += qlp_coeff[12] * data[i-13]
- mov ecx, [eax + 44] ; ecx = qlp_coeff[11]
- imul ecx, [edi - 48] ; ecx = qlp_coeff[11] * data[i-12]
- add ebp, ecx ; sum += qlp_coeff[11] * data[i-12]
- mov ecx, [eax + 40] ; ecx = qlp_coeff[10]
- imul ecx, [edi - 44] ; ecx = qlp_coeff[10] * data[i-11]
- add ebp, ecx ; sum += qlp_coeff[10] * data[i-11]
- mov ecx, [eax + 36] ; ecx = qlp_coeff[ 9]
- imul ecx, [edi - 40] ; ecx = qlp_coeff[ 9] * data[i-10]
- add ebp, ecx ; sum += qlp_coeff[ 9] * data[i-10]
- mov ecx, [eax + 32] ; ecx = qlp_coeff[ 8]
- imul ecx, [edi - 36] ; ecx = qlp_coeff[ 8] * data[i- 9]
- add ebp, ecx ; sum += qlp_coeff[ 8] * data[i- 9]
- mov ecx, [eax + 28] ; ecx = qlp_coeff[ 7]
- imul ecx, [edi - 32] ; ecx = qlp_coeff[ 7] * data[i- 8]
- add ebp, ecx ; sum += qlp_coeff[ 7] * data[i- 8]
- mov ecx, [eax + 24] ; ecx = qlp_coeff[ 6]
- imul ecx, [edi - 28] ; ecx = qlp_coeff[ 6] * data[i- 7]
- add ebp, ecx ; sum += qlp_coeff[ 6] * data[i- 7]
- mov ecx, [eax + 20] ; ecx = qlp_coeff[ 5]
- imul ecx, [edi - 24] ; ecx = qlp_coeff[ 5] * data[i- 6]
- add ebp, ecx ; sum += qlp_coeff[ 5] * data[i- 6]
- mov ecx, [eax + 16] ; ecx = qlp_coeff[ 4]
- imul ecx, [edi - 20] ; ecx = qlp_coeff[ 4] * data[i- 5]
- add ebp, ecx ; sum += qlp_coeff[ 4] * data[i- 5]
- mov ecx, [eax + 12] ; ecx = qlp_coeff[ 3]
- imul ecx, [edi - 16] ; ecx = qlp_coeff[ 3] * data[i- 4]
- add ebp, ecx ; sum += qlp_coeff[ 3] * data[i- 4]
- mov ecx, [eax + 8] ; ecx = qlp_coeff[ 2]
- imul ecx, [edi - 12] ; ecx = qlp_coeff[ 2] * data[i- 3]
- add ebp, ecx ; sum += qlp_coeff[ 2] * data[i- 3]
- mov ecx, [eax + 4] ; ecx = qlp_coeff[ 1]
- imul ecx, [edi - 8] ; ecx = qlp_coeff[ 1] * data[i- 2]
- add ebp, ecx ; sum += qlp_coeff[ 1] * data[i- 2]
- mov ecx, [eax] ; ecx = qlp_coeff[ 0] (NOTE: one byte missing from instruction)
- imul ecx, [edi - 4] ; ecx = qlp_coeff[ 0] * data[i- 1]
- add ebp, ecx ; sum += qlp_coeff[ 0] * data[i- 1]
-.jumper_0:
-
- mov cl, [esp + 36]
- sar ebp, cl ; ebp = (sum >> lp_quantization)
- add ebp, [esi + edi] ; ebp = residual[i] + (sum >> lp_quantization)
- mov [edi], ebp ; data[i] = residual[i] + (sum >> lp_quantization)
- add edi, byte 4
-
- dec ebx
- jz short .end
- xor ebp, ebp
- jmp edx
-
-.end:
- pop edi
- pop esi
- pop ebx
- pop ebp
- ret
-
-; WATCHOUT: this routine works on 16 bit data which means bits-per-sample for
-; the channel and qlp_coeffs must be <= 16. Especially note that this routine
-; cannot be used for side-channel coded 16bps channels since the effective bps
-; is 17.
-; WATCHOUT: this routine requires that each data array have a buffer of up to
-; 3 zeroes in front (at negative indices) for alignment purposes, i.e. for each
-; channel n, data[n][-1] through data[n][-3] should be accessible and zero.
- ALIGN 16
-cident FLAC__lpc_restore_signal_asm_ia32_mmx
- ;[esp + 40] data[]
- ;[esp + 36] lp_quantization
- ;[esp + 32] order
- ;[esp + 28] qlp_coeff[]
- ;[esp + 24] data_len
- ;[esp + 20] residual[]
-
- ;ASSERT(order > 0)
-
- push ebp
- push ebx
- push esi
- push edi
-
- mov esi, [esp + 20]
- mov edi, [esp + 40]
- mov eax, [esp + 32]
- mov ebx, [esp + 24]
-
- test ebx, ebx
- jz near .end ; do nothing if data_len == 0
- cmp eax, byte 4
- jb near FLAC__lpc_restore_signal_asm_ia32.begin
-
- mov edx, [esp + 28]
- movd mm6, [esp + 36]
- mov ebp, esp
-
- and esp, 0xfffffff8
-
- xor ecx, ecx
-.copy_qlp_loop:
- push word [edx + 4 * ecx]
- inc ecx
- cmp ecx, eax
- jnz short .copy_qlp_loop
-
- and ecx, 0x3
- test ecx, ecx
- je short .za_end
- sub ecx, byte 4
-.za_loop:
- push word 0
- inc eax
- inc ecx
- jnz short .za_loop
-.za_end:
-
- movq mm5, [esp + 2 * eax - 8]
- movd mm4, [edi - 16]
- punpckldq mm4, [edi - 12]
- movd mm0, [edi - 8]
- punpckldq mm0, [edi - 4]
- packssdw mm4, mm0
-
- cmp eax, byte 4
- jnbe short .mmx_4more
-
- ALIGN 16
-.mmx_4_loop_i:
- movq mm7, mm4
- pmaddwd mm7, mm5
- movq mm0, mm7
- punpckhdq mm7, mm7
- paddd mm7, mm0
- psrad mm7, mm6
- movd mm1, [esi]
- paddd mm7, mm1
- movd [edi], mm7
- psllq mm7, 48
- psrlq mm4, 16
- por mm4, mm7
-
- add esi, byte 4
- add edi, byte 4
-
- dec ebx
- jnz .mmx_4_loop_i
- jmp .mmx_end
-.mmx_4more:
- shl eax, 2
- neg eax
- add eax, byte 16
- ALIGN 16
-.mmx_4more_loop_i:
- mov ecx, edi
- add ecx, eax
- mov edx, esp
-
- movq mm7, mm4
- pmaddwd mm7, mm5
-
- ALIGN 16
-.mmx_4more_loop_j:
- movd mm0, [ecx - 16]
- punpckldq mm0, [ecx - 12]
- movd mm1, [ecx - 8]
- punpckldq mm1, [ecx - 4]
- packssdw mm0, mm1
- pmaddwd mm0, [edx]
- paddd mm7, mm0
-
- add edx, byte 8
- add ecx, byte 16
- cmp ecx, edi
- jnz .mmx_4more_loop_j
-
- movq mm0, mm7
- punpckhdq mm7, mm7
- paddd mm7, mm0
- psrad mm7, mm6
- movd mm1, [esi]
- paddd mm7, mm1
- movd [edi], mm7
- psllq mm7, 48
- psrlq mm4, 16
- por mm4, mm7
-
- add esi, byte 4
- add edi, byte 4
-
- dec ebx
- jnz short .mmx_4more_loop_i
-.mmx_end:
- emms
- mov esp, ebp
-
-.end:
- pop edi
- pop esi
- pop ebx
- pop ebp
- ret
-
-end
-
-%ifdef OBJ_FORMAT_elf
- section .note.GNU-stack noalloc
-%endif
diff --git a/src/thirdparty/libflac/src/libFLAC/ia32/nasm.h b/src/thirdparty/libflac/src/libFLAC/ia32/nasm.h
deleted file mode 100644
index b7cb2d257..000000000
--- a/src/thirdparty/libflac/src/libFLAC/ia32/nasm.h
+++ /dev/null
@@ -1,75 +0,0 @@
-; libFLAC - Free Lossless Audio Codec library
-; Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
-;
-; Redistribution and use in source and binary forms, with or without
-; modification, are permitted provided that the following conditions
-; are met:
-;
-; - Redistributions of source code must retain the above copyright
-; notice, this list of conditions and the following disclaimer.
-;
-; - 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.
-;
-; - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
-
- bits 32
-
-%ifdef OBJ_FORMAT_win32
- %define FLAC__PUBLIC_NEEDS_UNDERSCORE
- %idefine code_section section .text align=16
- %idefine data_section section .data align=32
- %idefine bss_section section .bss align=32
-%elifdef OBJ_FORMAT_aout
- %define FLAC__PUBLIC_NEEDS_UNDERSCORE
- %idefine code_section section .text
- %idefine data_section section .data
- %idefine bss_section section .bss
-%elifdef OBJ_FORMAT_aoutb
- %define FLAC__PUBLIC_NEEDS_UNDERSCORE
- %idefine code_section section .text
- %idefine data_section section .data
- %idefine bss_section section .bss
-%elifdef OBJ_FORMAT_elf
- %idefine code_section section .text align=16
- %idefine data_section section .data align=32
- %idefine bss_section section .bss align=32
-%else
- %error unsupported object format!
-%endif
-
-%imacro cglobal 1
- %ifdef FLAC__PUBLIC_NEEDS_UNDERSCORE
- global _%1
- %else
- global %1
- %endif
-%endmacro
-
-%imacro cextern 1
- %ifdef FLAC__PUBLIC_NEEDS_UNDERSCORE
- extern _%1
- %else
- extern %1
- %endif
-%endmacro
-
-%imacro cident 1
-_%1:
-%1:
-%endmacro
diff --git a/src/thirdparty/libflac/src/libFLAC/ia32/stream_encoder_asm.nasm b/src/thirdparty/libflac/src/libFLAC/ia32/stream_encoder_asm.nasm
deleted file mode 100644
index 866c1ecf7..000000000
--- a/src/thirdparty/libflac/src/libFLAC/ia32/stream_encoder_asm.nasm
+++ /dev/null
@@ -1,159 +0,0 @@
-; vim:filetype=nasm ts=8
-
-; libFLAC - Free Lossless Audio Codec library
-; Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
-;
-; Redistribution and use in source and binary forms, with or without
-; modification, are permitted provided that the following conditions
-; are met:
-;
-; - Redistributions of source code must retain the above copyright
-; notice, this list of conditions and the following disclaimer.
-;
-; - 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.
-;
-; - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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 "nasm.h"
-
- data_section
-
-cglobal precompute_partition_info_sums_32bit_asm_ia32_
-
- code_section
-
-
-; **********************************************************************
-;
-; void FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], unsigned nvals, unsigned parameter)
-; void precompute_partition_info_sums_32bit_(
-; const FLAC__int32 residual[],
-; FLAC__uint64 abs_residual_partition_sums[],
-; unsigned blocksize,
-; unsigned predictor_order,
-; unsigned min_partition_order,
-; unsigned max_partition_order
-; )
-;
- ALIGN 16
-cident precompute_partition_info_sums_32bit_asm_ia32_
-
- ;; peppered throughout the code at major checkpoints are keys like this as to where things are at that point in time
- ;; [esp + 4] const FLAC__int32 residual[]
- ;; [esp + 8] FLAC__uint64 abs_residual_partition_sums[]
- ;; [esp + 12] unsigned blocksize
- ;; [esp + 16] unsigned predictor_order
- ;; [esp + 20] unsigned min_partition_order
- ;; [esp + 24] unsigned max_partition_order
- push ebp
- push ebx
- push esi
- push edi
- sub esp, 8
- ;; [esp + 28] const FLAC__int32 residual[]
- ;; [esp + 32] FLAC__uint64 abs_residual_partition_sums[]
- ;; [esp + 36] unsigned blocksize
- ;; [esp + 40] unsigned predictor_order
- ;; [esp + 44] unsigned min_partition_order
- ;; [esp + 48] unsigned max_partition_order
- ;; [esp] partitions
- ;; [esp + 4] default_partition_samples
-
- mov ecx, [esp + 48]
- mov eax, 1
- shl eax, cl
- mov [esp], eax ; [esp] <- partitions = 1u << max_partition_order;
- mov eax, [esp + 36]
- shr eax, cl
- mov [esp + 4], eax ; [esp + 4] <- default_partition_samples = blocksize >> max_partition_order;
-
- ;
- ; first do max_partition_order
- ;
- mov edi, [esp + 4]
- sub edi, [esp + 40] ; edi <- end = (unsigned)(-(int)predictor_order) + default_partition_samples
- xor esi, esi ; esi <- residual_sample = 0
- xor ecx, ecx ; ecx <- partition = 0
- mov ebp, [esp + 28] ; ebp <- residual[]
- xor ebx, ebx ; ebx <- abs_residual_partition_sum = 0;
- ; note we put the updates to 'end' and 'abs_residual_partition_sum' at the end of loop0 and in the initialization above so we could align loop0 and loop1
- ALIGN 16
-.loop0: ; for(partition = residual_sample = 0; partition < partitions; partition++) {
-.loop1: ; for( ; residual_sample < end; residual_sample++)
- mov eax, [ebp + esi * 4]
- cdq
- xor eax, edx
- sub eax, edx
- add ebx, eax ; abs_residual_partition_sum += abs(residual[residual_sample]);
- ;@@@@@@ check overflow flag and abort here?
- add esi, byte 1
- cmp esi, edi ; /* since the loop will always run at least once, we can put the loop check down here */
- jb .loop1
-.next1:
- add edi, [esp + 4] ; end += default_partition_samples;
- mov eax, [esp + 32]
- mov [eax + ecx * 8], ebx ; abs_residual_partition_sums[partition] = abs_residual_partition_sum;
- mov [eax + ecx * 8 + 4], dword 0
- xor ebx, ebx ; abs_residual_partition_sum = 0;
- add ecx, byte 1
- cmp ecx, [esp] ; /* since the loop will always run at least once, we can put the loop check down here */
- jb .loop0
-.next0: ; }
- ;
- ; now merge partitions for lower orders
- ;
- mov esi, [esp + 32] ; esi <- abs_residual_partition_sums[from_partition==0];
- mov eax, [esp]
- lea edi, [esi + eax * 8] ; edi <- abs_residual_partition_sums[to_partition==partitions];
- mov ecx, [esp + 48]
- sub ecx, byte 1 ; ecx <- partition_order = (int)max_partition_order - 1;
- ALIGN 16
-.loop2: ; for(; partition_order >= (int)min_partition_order; partition_order--) {
- cmp ecx, [esp + 44]
- jl .next2
- mov edx, 1
- shl edx, cl ; const unsigned partitions = 1u << partition_order;
- ALIGN 16
-.loop3: ; for(i = 0; i < partitions; i++) {
- mov eax, [esi]
- mov ebx, [esi + 4]
- add eax, [esi + 8]
- adc ebx, [esi + 12]
- mov [edi], eax
- mov [edi + 4], ebx ; a_r_p_s[to_partition] = a_r_p_s[from_partition] + a_r_p_s[from_partition+1];
- add esi, byte 16
- add edi, byte 8
- sub edx, byte 1
- jnz .loop3 ; }
- sub ecx, byte 1
- jmp .loop2 ; }
-.next2:
-
- add esp, 8
- pop edi
- pop esi
- pop ebx
- pop ebp
- ret
-
-end
-
-%ifdef OBJ_FORMAT_elf
- section .note.GNU-stack noalloc
-%endif
diff --git a/src/thirdparty/libflac/src/libFLAC/include/private/all.h b/src/thirdparty/libflac/src/libFLAC/include/private/all.h
deleted file mode 100644
index ad701434a..000000000
--- a/src/thirdparty/libflac/src/libFLAC/include/private/all.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__PRIVATE__ALL_H
-#define FLAC__PRIVATE__ALL_H
-
-#include "bitmath.h"
-#include "bitreader.h"
-#include "bitwriter.h"
-#include "cpu.h"
-#include "crc.h"
-#include "fixed.h"
-#include "float.h"
-#include "format.h"
-#include "lpc.h"
-#include "md5.h"
-#include "memory.h"
-#include "metadata.h"
-#include "stream_encoder_framing.h"
-
-#endif
diff --git a/src/thirdparty/libflac/src/libFLAC/include/private/bitmath.h b/src/thirdparty/libflac/src/libFLAC/include/private/bitmath.h
deleted file mode 100644
index 5958fceca..000000000
--- a/src/thirdparty/libflac/src/libFLAC/include/private/bitmath.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__PRIVATE__BITMATH_H
-#define FLAC__PRIVATE__BITMATH_H
-
-#include "FLAC/ordinals.h"
-
-unsigned FLAC__bitmath_ilog2(FLAC__uint32 v);
-unsigned FLAC__bitmath_ilog2_wide(FLAC__uint64 v);
-unsigned FLAC__bitmath_silog2(int v);
-unsigned FLAC__bitmath_silog2_wide(FLAC__int64 v);
-
-#endif
diff --git a/src/thirdparty/libflac/src/libFLAC/include/private/bitreader.h b/src/thirdparty/libflac/src/libFLAC/include/private/bitreader.h
deleted file mode 100644
index 436ef6d63..000000000
--- a/src/thirdparty/libflac/src/libFLAC/include/private/bitreader.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__PRIVATE__BITREADER_H
-#define FLAC__PRIVATE__BITREADER_H
-
-#include <stdio.h> /* for FILE */
-#include "FLAC/ordinals.h"
-#include "cpu.h"
-
-/*
- * opaque structure definition
- */
-struct FLAC__BitReader;
-typedef struct FLAC__BitReader FLAC__BitReader;
-
-typedef FLAC__bool (*FLAC__BitReaderReadCallback)(FLAC__byte buffer[], size_t *bytes, void *client_data);
-
-/*
- * construction, deletion, initialization, etc functions
- */
-FLAC__BitReader *FLAC__bitreader_new(void);
-void FLAC__bitreader_delete(FLAC__BitReader *br);
-FLAC__bool FLAC__bitreader_init(FLAC__BitReader *br, FLAC__CPUInfo cpu, FLAC__BitReaderReadCallback rcb, void *cd);
-void FLAC__bitreader_free(FLAC__BitReader *br); /* does not 'free(br)' */
-FLAC__bool FLAC__bitreader_clear(FLAC__BitReader *br);
-void FLAC__bitreader_dump(const FLAC__BitReader *br, FILE *out);
-
-/*
- * CRC functions
- */
-void FLAC__bitreader_reset_read_crc16(FLAC__BitReader *br, FLAC__uint16 seed);
-FLAC__uint16 FLAC__bitreader_get_read_crc16(FLAC__BitReader *br);
-
-/*
- * info functions
- */
-FLAC__bool FLAC__bitreader_is_consumed_byte_aligned(const FLAC__BitReader *br);
-unsigned FLAC__bitreader_bits_left_for_byte_alignment(const FLAC__BitReader *br);
-unsigned FLAC__bitreader_get_input_bits_unconsumed(const FLAC__BitReader *br);
-
-/*
- * read functions
- */
-
-FLAC__bool FLAC__bitreader_read_raw_uint32(FLAC__BitReader *br, FLAC__uint32 *val, unsigned bits);
-FLAC__bool FLAC__bitreader_read_raw_int32(FLAC__BitReader *br, FLAC__int32 *val, unsigned bits);
-FLAC__bool FLAC__bitreader_read_raw_uint64(FLAC__BitReader *br, FLAC__uint64 *val, unsigned bits);
-FLAC__bool FLAC__bitreader_read_uint32_little_endian(FLAC__BitReader *br, FLAC__uint32 *val); /*only for bits=32*/
-FLAC__bool FLAC__bitreader_skip_bits_no_crc(FLAC__BitReader *br, unsigned bits); /* WATCHOUT: does not CRC the skipped data! */ /*@@@@ add to unit tests */
-FLAC__bool FLAC__bitreader_skip_byte_block_aligned_no_crc(FLAC__BitReader *br, unsigned nvals); /* WATCHOUT: does not CRC the read data! */
-FLAC__bool FLAC__bitreader_read_byte_block_aligned_no_crc(FLAC__BitReader *br, FLAC__byte *val, unsigned nvals); /* WATCHOUT: does not CRC the read data! */
-FLAC__bool FLAC__bitreader_read_unary_unsigned(FLAC__BitReader *br, unsigned *val);
-FLAC__bool FLAC__bitreader_read_rice_signed(FLAC__BitReader *br, int *val, unsigned parameter);
-FLAC__bool FLAC__bitreader_read_rice_signed_block(FLAC__BitReader *br, int vals[], unsigned nvals, unsigned parameter);
-#ifndef FLAC__NO_ASM
-# ifdef FLAC__CPU_IA32
-# ifdef FLAC__HAS_NASM
-FLAC__bool FLAC__bitreader_read_rice_signed_block_asm_ia32_bswap(FLAC__BitReader *br, int vals[], unsigned nvals, unsigned parameter);
-# endif
-# endif
-#endif
-#if 0 /* UNUSED */
-FLAC__bool FLAC__bitreader_read_golomb_signed(FLAC__BitReader *br, int *val, unsigned parameter);
-FLAC__bool FLAC__bitreader_read_golomb_unsigned(FLAC__BitReader *br, unsigned *val, unsigned parameter);
-#endif
-FLAC__bool FLAC__bitreader_read_utf8_uint32(FLAC__BitReader *br, FLAC__uint32 *val, FLAC__byte *raw, unsigned *rawlen);
-FLAC__bool FLAC__bitreader_read_utf8_uint64(FLAC__BitReader *br, FLAC__uint64 *val, FLAC__byte *raw, unsigned *rawlen);
-
-FLAC__bool bitreader_read_from_client_(FLAC__BitReader *br);
-#endif
diff --git a/src/thirdparty/libflac/src/libFLAC/include/private/bitwriter.h b/src/thirdparty/libflac/src/libFLAC/include/private/bitwriter.h
deleted file mode 100644
index c8cf11681..000000000
--- a/src/thirdparty/libflac/src/libFLAC/include/private/bitwriter.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__PRIVATE__BITWRITER_H
-#define FLAC__PRIVATE__BITWRITER_H
-
-#include <stdio.h> /* for FILE */
-#include "FLAC/ordinals.h"
-
-/*
- * opaque structure definition
- */
-struct FLAC__BitWriter;
-typedef struct FLAC__BitWriter FLAC__BitWriter;
-
-/*
- * construction, deletion, initialization, etc functions
- */
-FLAC__BitWriter *FLAC__bitwriter_new(void);
-void FLAC__bitwriter_delete(FLAC__BitWriter *bw);
-FLAC__bool FLAC__bitwriter_init(FLAC__BitWriter *bw);
-void FLAC__bitwriter_free(FLAC__BitWriter *bw); /* does not 'free(buffer)' */
-void FLAC__bitwriter_clear(FLAC__BitWriter *bw);
-void FLAC__bitwriter_dump(const FLAC__BitWriter *bw, FILE *out);
-
-/*
- * CRC functions
- *
- * non-const *bw because they have to cal FLAC__bitwriter_get_buffer()
- */
-FLAC__bool FLAC__bitwriter_get_write_crc16(FLAC__BitWriter *bw, FLAC__uint16 *crc);
-FLAC__bool FLAC__bitwriter_get_write_crc8(FLAC__BitWriter *bw, FLAC__byte *crc);
-
-/*
- * info functions
- */
-FLAC__bool FLAC__bitwriter_is_byte_aligned(const FLAC__BitWriter *bw);
-unsigned FLAC__bitwriter_get_input_bits_unconsumed(const FLAC__BitWriter *bw); /* can be called anytime, returns total # of bits unconsumed */
-
-/*
- * direct buffer access
- *
- * there may be no calls on the bitwriter between get and release.
- * the bitwriter continues to own the returned buffer.
- * before get, bitwriter MUST be byte aligned: check with FLAC__bitwriter_is_byte_aligned()
- */
-FLAC__bool FLAC__bitwriter_get_buffer(FLAC__BitWriter *bw, const FLAC__byte **buffer, size_t *bytes);
-void FLAC__bitwriter_release_buffer(FLAC__BitWriter *bw);
-
-/*
- * write functions
- */
-FLAC__bool FLAC__bitwriter_write_zeroes(FLAC__BitWriter *bw, unsigned bits);
-FLAC__bool FLAC__bitwriter_write_raw_uint32(FLAC__BitWriter *bw, FLAC__uint32 val, unsigned bits);
-FLAC__bool FLAC__bitwriter_write_raw_int32(FLAC__BitWriter *bw, FLAC__int32 val, unsigned bits);
-FLAC__bool FLAC__bitwriter_write_raw_uint64(FLAC__BitWriter *bw, FLAC__uint64 val, unsigned bits);
-FLAC__bool FLAC__bitwriter_write_raw_uint32_little_endian(FLAC__BitWriter *bw, FLAC__uint32 val); /*only for bits=32*/
-FLAC__bool FLAC__bitwriter_write_byte_block(FLAC__BitWriter *bw, const FLAC__byte vals[], unsigned nvals);
-FLAC__bool FLAC__bitwriter_write_unary_unsigned(FLAC__BitWriter *bw, unsigned val);
-unsigned FLAC__bitwriter_rice_bits(FLAC__int32 val, unsigned parameter);
-#if 0 /* UNUSED */
-unsigned FLAC__bitwriter_golomb_bits_signed(int val, unsigned parameter);
-unsigned FLAC__bitwriter_golomb_bits_unsigned(unsigned val, unsigned parameter);
-#endif
-FLAC__bool FLAC__bitwriter_write_rice_signed(FLAC__BitWriter *bw, FLAC__int32 val, unsigned parameter);
-FLAC__bool FLAC__bitwriter_write_rice_signed_block(FLAC__BitWriter *bw, const FLAC__int32 *vals, unsigned nvals, unsigned parameter);
-#if 0 /* UNUSED */
-FLAC__bool FLAC__bitwriter_write_golomb_signed(FLAC__BitWriter *bw, int val, unsigned parameter);
-FLAC__bool FLAC__bitwriter_write_golomb_unsigned(FLAC__BitWriter *bw, unsigned val, unsigned parameter);
-#endif
-FLAC__bool FLAC__bitwriter_write_utf8_uint32(FLAC__BitWriter *bw, FLAC__uint32 val);
-FLAC__bool FLAC__bitwriter_write_utf8_uint64(FLAC__BitWriter *bw, FLAC__uint64 val);
-FLAC__bool FLAC__bitwriter_zero_pad_to_byte_boundary(FLAC__BitWriter *bw);
-
-#endif
diff --git a/src/thirdparty/libflac/src/libFLAC/include/private/cpu.h b/src/thirdparty/libflac/src/libFLAC/include/private/cpu.h
deleted file mode 100644
index 297d18215..000000000
--- a/src/thirdparty/libflac/src/libFLAC/include/private/cpu.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__PRIVATE__CPU_H
-#define FLAC__PRIVATE__CPU_H
-
-#include "FLAC/ordinals.h"
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-typedef enum {
- FLAC__CPUINFO_TYPE_IA32,
- FLAC__CPUINFO_TYPE_PPC,
- FLAC__CPUINFO_TYPE_UNKNOWN
-} FLAC__CPUInfo_Type;
-
-typedef struct {
- FLAC__bool cpuid;
- FLAC__bool bswap;
- FLAC__bool cmov;
- FLAC__bool mmx;
- FLAC__bool fxsr;
- FLAC__bool sse;
- FLAC__bool sse2;
- FLAC__bool sse3;
- FLAC__bool ssse3;
- FLAC__bool _3dnow;
- FLAC__bool ext3dnow;
- FLAC__bool extmmx;
-} FLAC__CPUInfo_IA32;
-
-typedef struct {
- FLAC__bool altivec;
- FLAC__bool ppc64;
-} FLAC__CPUInfo_PPC;
-
-typedef struct {
- FLAC__bool use_asm;
- FLAC__CPUInfo_Type type;
- union {
- FLAC__CPUInfo_IA32 ia32;
- FLAC__CPUInfo_PPC ppc;
- } data;
-} FLAC__CPUInfo;
-
-void FLAC__cpu_info(FLAC__CPUInfo *info);
-
-#ifndef FLAC__NO_ASM
-#ifdef FLAC__CPU_IA32
-#ifdef FLAC__HAS_NASM
-FLAC__uint32 FLAC__cpu_have_cpuid_asm_ia32(void);
-void FLAC__cpu_info_asm_ia32(FLAC__uint32 *flags_edx, FLAC__uint32 *flags_ecx);
-FLAC__uint32 FLAC__cpu_info_extended_amd_asm_ia32(void);
-#endif
-#endif
-#endif
-
-#endif
diff --git a/src/thirdparty/libflac/src/libFLAC/include/private/crc.h b/src/thirdparty/libflac/src/libFLAC/include/private/crc.h
deleted file mode 100644
index c2e913ab8..000000000
--- a/src/thirdparty/libflac/src/libFLAC/include/private/crc.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__PRIVATE__CRC_H
-#define FLAC__PRIVATE__CRC_H
-
-#include "FLAC/ordinals.h"
-
-/* 8 bit CRC generator, MSB shifted first
-** polynomial = x^8 + x^2 + x^1 + x^0
-** init = 0
-*/
-extern FLAC__byte const FLAC__crc8_table[256];
-#define FLAC__CRC8_UPDATE(data, crc) (crc) = FLAC__crc8_table[(crc) ^ (data)];
-void FLAC__crc8_update(const FLAC__byte data, FLAC__uint8 *crc);
-void FLAC__crc8_update_block(const FLAC__byte *data, unsigned len, FLAC__uint8 *crc);
-FLAC__uint8 FLAC__crc8(const FLAC__byte *data, unsigned len);
-
-/* 16 bit CRC generator, MSB shifted first
-** polynomial = x^16 + x^15 + x^2 + x^0
-** init = 0
-*/
-extern unsigned const FLAC__crc16_table[256];
-
-#define FLAC__CRC16_UPDATE(data, crc) (((((crc)<<8) & 0xffff) ^ FLAC__crc16_table[((crc)>>8) ^ (data)]))
-/* this alternate may be faster on some systems/compilers */
-#if 0
-#define FLAC__CRC16_UPDATE(data, crc) ((((crc)<<8) ^ FLAC__crc16_table[((crc)>>8) ^ (data)]) & 0xffff)
-#endif
-
-unsigned FLAC__crc16(const FLAC__byte *data, unsigned len);
-
-#endif
diff --git a/src/thirdparty/libflac/src/libFLAC/include/private/fixed.h b/src/thirdparty/libflac/src/libFLAC/include/private/fixed.h
deleted file mode 100644
index 6e131c3ed..000000000
--- a/src/thirdparty/libflac/src/libFLAC/include/private/fixed.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__PRIVATE__FIXED_H
-#define FLAC__PRIVATE__FIXED_H
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "private/float.h"
-#include "FLAC/format.h"
-
-/*
- * FLAC__fixed_compute_best_predictor()
- * --------------------------------------------------------------------
- * Compute the best fixed predictor and the expected bits-per-sample
- * of the residual signal for each order. The _wide() version uses
- * 64-bit integers which is statistically necessary when bits-per-
- * sample + log2(blocksize) > 30
- *
- * IN data[0,data_len-1]
- * IN data_len
- * OUT residual_bits_per_sample[0,FLAC__MAX_FIXED_ORDER]
- */
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
-unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
-# ifndef FLAC__NO_ASM
-# ifdef FLAC__CPU_IA32
-# ifdef FLAC__HAS_NASM
-unsigned FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
-# endif
-# endif
-# endif
-unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
-#else
-unsigned FLAC__fixed_compute_best_predictor(const FLAC__int32 data[], unsigned data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
-unsigned FLAC__fixed_compute_best_predictor_wide(const FLAC__int32 data[], unsigned data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
-#endif
-
-/*
- * FLAC__fixed_compute_residual()
- * --------------------------------------------------------------------
- * Compute the residual signal obtained from sutracting the predicted
- * signal from the original.
- *
- * IN data[-order,data_len-1] original signal (NOTE THE INDICES!)
- * IN data_len length of original signal
- * IN order <= FLAC__MAX_FIXED_ORDER fixed-predictor order
- * OUT residual[0,data_len-1] residual signal
- */
-void FLAC__fixed_compute_residual(const FLAC__int32 data[], unsigned data_len, unsigned order, FLAC__int32 residual[]);
-
-/*
- * FLAC__fixed_restore_signal()
- * --------------------------------------------------------------------
- * Restore the original signal by summing the residual and the
- * predictor.
- *
- * IN residual[0,data_len-1] residual signal
- * IN data_len length of original signal
- * IN order <= FLAC__MAX_FIXED_ORDER fixed-predictor order
- * *** IMPORTANT: the caller must pass in the historical samples:
- * IN data[-order,-1] previously-reconstructed historical samples
- * OUT data[0,data_len-1] original signal
- */
-void FLAC__fixed_restore_signal(const FLAC__int32 residual[], unsigned data_len, unsigned order, FLAC__int32 data[]);
-
-#endif
diff --git a/src/thirdparty/libflac/src/libFLAC/include/private/float.h b/src/thirdparty/libflac/src/libFLAC/include/private/float.h
deleted file mode 100644
index d99a52dc5..000000000
--- a/src/thirdparty/libflac/src/libFLAC/include/private/float.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__PRIVATE__FLOAT_H
-#define FLAC__PRIVATE__FLOAT_H
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "FLAC/ordinals.h"
-
-/*
- * These typedefs make it easier to ensure that integer versions of
- * the library really only contain integer operations. All the code
- * in libFLAC should use FLAC__float and FLAC__double in place of
- * float and double, and be protected by checks of the macro
- * FLAC__INTEGER_ONLY_LIBRARY.
- *
- * FLAC__real is the basic floating point type used in LPC analysis.
- */
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
-typedef double FLAC__double;
-typedef float FLAC__float;
-/*
- * WATCHOUT: changing FLAC__real will change the signatures of many
- * functions that have assembly language equivalents and break them.
- */
-typedef float FLAC__real;
-#else
-/*
- * The convention for FLAC__fixedpoint is to use the upper 16 bits
- * for the integer part and lower 16 bits for the fractional part.
- */
-typedef FLAC__int32 FLAC__fixedpoint;
-extern const FLAC__fixedpoint FLAC__FP_ZERO;
-extern const FLAC__fixedpoint FLAC__FP_ONE_HALF;
-extern const FLAC__fixedpoint FLAC__FP_ONE;
-extern const FLAC__fixedpoint FLAC__FP_LN2;
-extern const FLAC__fixedpoint FLAC__FP_E;
-
-#define FLAC__fixedpoint_trunc(x) ((x)>>16)
-
-#define FLAC__fixedpoint_mul(x, y) ( (FLAC__fixedpoint) ( ((FLAC__int64)(x)*(FLAC__int64)(y)) >> 16 ) )
-
-#define FLAC__fixedpoint_div(x, y) ( (FLAC__fixedpoint) ( ( ((FLAC__int64)(x)<<32) / (FLAC__int64)(y) ) >> 16 ) )
-
-/*
- * FLAC__fixedpoint_log2()
- * --------------------------------------------------------------------
- * Returns the base-2 logarithm of the fixed-point number 'x' using an
- * algorithm by Knuth for x >= 1.0
- *
- * 'fracbits' is the number of fractional bits of 'x'. 'fracbits' must
- * be < 32 and evenly divisible by 4 (0 is OK but not very precise).
- *
- * 'precision' roughly limits the number of iterations that are done;
- * use (unsigned)(-1) for maximum precision.
- *
- * If 'x' is less than one -- that is, x < (1<<fracbits) -- then this
- * function will punt and return 0.
- *
- * The return value will also have 'fracbits' fractional bits.
- */
-FLAC__uint32 FLAC__fixedpoint_log2(FLAC__uint32 x, unsigned fracbits, unsigned precision);
-
-#endif
-
-#endif
diff --git a/src/thirdparty/libflac/src/libFLAC/include/private/format.h b/src/thirdparty/libflac/src/libFLAC/include/private/format.h
deleted file mode 100644
index 2d50f5e18..000000000
--- a/src/thirdparty/libflac/src/libFLAC/include/private/format.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__PRIVATE__FORMAT_H
-#define FLAC__PRIVATE__FORMAT_H
-
-#include "FLAC/format.h"
-
-unsigned FLAC__format_get_max_rice_partition_order(unsigned blocksize, unsigned predictor_order);
-unsigned FLAC__format_get_max_rice_partition_order_from_blocksize(unsigned blocksize);
-unsigned FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order(unsigned limit, unsigned blocksize, unsigned predictor_order);
-void FLAC__format_entropy_coding_method_partitioned_rice_contents_init(FLAC__EntropyCodingMethod_PartitionedRiceContents *object);
-void FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(FLAC__EntropyCodingMethod_PartitionedRiceContents *object);
-FLAC__bool FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(FLAC__EntropyCodingMethod_PartitionedRiceContents *object, unsigned max_partition_order);
-
-#endif
diff --git a/src/thirdparty/libflac/src/libFLAC/include/private/lpc.h b/src/thirdparty/libflac/src/libFLAC/include/private/lpc.h
deleted file mode 100644
index 10275ceac..000000000
--- a/src/thirdparty/libflac/src/libFLAC/include/private/lpc.h
+++ /dev/null
@@ -1,214 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__PRIVATE__LPC_H
-#define FLAC__PRIVATE__LPC_H
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "private/float.h"
-#include "FLAC/format.h"
-
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
-
-/*
- * FLAC__lpc_window_data()
- * --------------------------------------------------------------------
- * Applies the given window to the data.
- * OPT: asm implementation
- *
- * IN in[0,data_len-1]
- * IN window[0,data_len-1]
- * OUT out[0,lag-1]
- * IN data_len
- */
-void FLAC__lpc_window_data(const FLAC__int32 in[], const FLAC__real window[], FLAC__real out[], unsigned data_len);
-
-/*
- * FLAC__lpc_compute_autocorrelation()
- * --------------------------------------------------------------------
- * Compute the autocorrelation for lags between 0 and lag-1.
- * Assumes data[] outside of [0,data_len-1] == 0.
- * Asserts that lag > 0.
- *
- * IN data[0,data_len-1]
- * IN data_len
- * IN 0 < lag <= data_len
- * OUT autoc[0,lag-1]
- */
-void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]);
-#ifndef FLAC__NO_ASM
-# ifdef FLAC__CPU_IA32
-# ifdef FLAC__HAS_NASM
-void FLAC__lpc_compute_autocorrelation_asm_ia32(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]);
-void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_4(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]);
-void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_8(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]);
-void FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_12(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]);
-void FLAC__lpc_compute_autocorrelation_asm_ia32_3dnow(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]);
-# endif
-# endif
-#endif
-
-/*
- * FLAC__lpc_compute_lp_coefficients()
- * --------------------------------------------------------------------
- * Computes LP coefficients for orders 1..max_order.
- * Do not call if autoc[0] == 0.0. This means the signal is zero
- * and there is no point in calculating a predictor.
- *
- * IN autoc[0,max_order] autocorrelation values
- * IN 0 < max_order <= FLAC__MAX_LPC_ORDER max LP order to compute
- * OUT lp_coeff[0,max_order-1][0,max_order-1] LP coefficients for each order
- * *** IMPORTANT:
- * *** lp_coeff[0,max_order-1][max_order,FLAC__MAX_LPC_ORDER-1] are untouched
- * OUT error[0,max_order-1] error for each order (more
- * specifically, the variance of
- * the error signal times # of
- * samples in the signal)
- *
- * Example: if max_order is 9, the LP coefficients for order 9 will be
- * in lp_coeff[8][0,8], the LP coefficients for order 8 will be
- * in lp_coeff[7][0,7], etc.
- */
-void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], unsigned *max_order, FLAC__real lp_coeff[][FLAC__MAX_LPC_ORDER], FLAC__double error[]);
-
-/*
- * FLAC__lpc_quantize_coefficients()
- * --------------------------------------------------------------------
- * Quantizes the LP coefficients. NOTE: precision + bits_per_sample
- * must be less than 32 (sizeof(FLAC__int32)*8).
- *
- * IN lp_coeff[0,order-1] LP coefficients
- * IN order LP order
- * IN FLAC__MIN_QLP_COEFF_PRECISION < precision
- * desired precision (in bits, including sign
- * bit) of largest coefficient
- * OUT qlp_coeff[0,order-1] quantized coefficients
- * OUT shift # of bits to shift right to get approximated
- * LP coefficients. NOTE: could be negative.
- * RETURN 0 => quantization OK
- * 1 => coefficients require too much shifting for *shift to
- * fit in the LPC subframe header. 'shift' is unset.
- * 2 => coefficients are all zero, which is bad. 'shift' is
- * unset.
- */
-int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], unsigned order, unsigned precision, FLAC__int32 qlp_coeff[], int *shift);
-
-/*
- * FLAC__lpc_compute_residual_from_qlp_coefficients()
- * --------------------------------------------------------------------
- * Compute the residual signal obtained from sutracting the predicted
- * signal from the original.
- *
- * IN data[-order,data_len-1] original signal (NOTE THE INDICES!)
- * IN data_len length of original signal
- * IN qlp_coeff[0,order-1] quantized LP coefficients
- * IN order > 0 LP order
- * IN lp_quantization quantization of LP coefficients in bits
- * OUT residual[0,data_len-1] residual signal
- */
-void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]);
-void FLAC__lpc_compute_residual_from_qlp_coefficients_wide(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]);
-#ifndef FLAC__NO_ASM
-# ifdef FLAC__CPU_IA32
-# ifdef FLAC__HAS_NASM
-void FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]);
-void FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32_mmx(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]);
-# endif
-# endif
-#endif
-
-#endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */
-
-/*
- * FLAC__lpc_restore_signal()
- * --------------------------------------------------------------------
- * Restore the original signal by summing the residual and the
- * predictor.
- *
- * IN residual[0,data_len-1] residual signal
- * IN data_len length of original signal
- * IN qlp_coeff[0,order-1] quantized LP coefficients
- * IN order > 0 LP order
- * IN lp_quantization quantization of LP coefficients in bits
- * *** IMPORTANT: the caller must pass in the historical samples:
- * IN data[-order,-1] previously-reconstructed historical samples
- * OUT data[0,data_len-1] original signal
- */
-void FLAC__lpc_restore_signal(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
-void FLAC__lpc_restore_signal_wide(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
-#ifndef FLAC__NO_ASM
-# ifdef FLAC__CPU_IA32
-# ifdef FLAC__HAS_NASM
-void FLAC__lpc_restore_signal_asm_ia32(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
-void FLAC__lpc_restore_signal_asm_ia32_mmx(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
-# endif /* FLAC__HAS_NASM */
-# elif defined FLAC__CPU_PPC
-void FLAC__lpc_restore_signal_asm_ppc_altivec_16(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
-void FLAC__lpc_restore_signal_asm_ppc_altivec_16_order8(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
-# endif/* FLAC__CPU_IA32 || FLAC__CPU_PPC */
-#endif /* FLAC__NO_ASM */
-
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
-
-/*
- * FLAC__lpc_compute_expected_bits_per_residual_sample()
- * --------------------------------------------------------------------
- * Compute the expected number of bits per residual signal sample
- * based on the LP error (which is related to the residual variance).
- *
- * IN lpc_error >= 0.0 error returned from calculating LP coefficients
- * IN total_samples > 0 # of samples in residual signal
- * RETURN expected bits per sample
- */
-FLAC__double FLAC__lpc_compute_expected_bits_per_residual_sample(FLAC__double lpc_error, unsigned total_samples);
-FLAC__double FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(FLAC__double lpc_error, FLAC__double error_scale);
-
-/*
- * FLAC__lpc_compute_best_order()
- * --------------------------------------------------------------------
- * Compute the best order from the array of signal errors returned
- * during coefficient computation.
- *
- * IN lpc_error[0,max_order-1] >= 0.0 error returned from calculating LP coefficients
- * IN max_order > 0 max LP order
- * IN total_samples > 0 # of samples in residual signal
- * IN overhead_bits_per_order # of bits overhead for each increased LP order
- * (includes warmup sample size and quantized LP coefficient)
- * RETURN [1,max_order] best order
- */
-unsigned FLAC__lpc_compute_best_order(const FLAC__double lpc_error[], unsigned max_order, unsigned total_samples, unsigned overhead_bits_per_order);
-
-#endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */
-
-#endif
diff --git a/src/thirdparty/libflac/src/libFLAC/include/private/md5.h b/src/thirdparty/libflac/src/libFLAC/include/private/md5.h
deleted file mode 100644
index 33c2edaff..000000000
--- a/src/thirdparty/libflac/src/libFLAC/include/private/md5.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef FLAC__PRIVATE__MD5_H
-#define FLAC__PRIVATE__MD5_H
-
-/*
- * This is the header file for the MD5 message-digest algorithm.
- * The algorithm is due to Ron Rivest. This code was
- * written by Colin Plumb in 1993, no copyright is claimed.
- * This code is in the public domain; do with it what you wish.
- *
- * Equivalent code is available from RSA Data Security, Inc.
- * This code has been tested against that, and is equivalent,
- * except that you don't need to include two pages of legalese
- * with every copy.
- *
- * To compute the message digest of a chunk of bytes, declare an
- * MD5Context structure, pass it to MD5Init, call MD5Update as
- * needed on buffers full of bytes, and then call MD5Final, which
- * will fill a supplied 16-byte array with the digest.
- *
- * Changed so as no longer to depend on Colin Plumb's `usual.h'
- * header definitions; now uses stuff from dpkg's config.h
- * - Ian Jackson <ijackson@nyx.cs.du.edu>.
- * Still in the public domain.
- *
- * Josh Coalson: made some changes to integrate with libFLAC.
- * Still in the public domain, with no warranty.
- */
-
-#include "FLAC/ordinals.h"
-
-typedef struct {
- FLAC__uint32 in[16];
- FLAC__uint32 buf[4];
- FLAC__uint32 bytes[2];
- FLAC__byte *internal_buf;
- size_t capacity;
-} FLAC__MD5Context;
-
-void FLAC__MD5Init(FLAC__MD5Context *context);
-void FLAC__MD5Final(FLAC__byte digest[16], FLAC__MD5Context *context);
-
-FLAC__bool FLAC__MD5Accumulate(FLAC__MD5Context *ctx, const FLAC__int32 * const signal[], unsigned channels, unsigned samples, unsigned bytes_per_sample);
-
-#endif
diff --git a/src/thirdparty/libflac/src/libFLAC/include/private/memory.h b/src/thirdparty/libflac/src/libFLAC/include/private/memory.h
deleted file mode 100644
index dc95d367f..000000000
--- a/src/thirdparty/libflac/src/libFLAC/include/private/memory.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__PRIVATE__MEMORY_H
-#define FLAC__PRIVATE__MEMORY_H
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdlib.h> /* for size_t */
-
-#include "private/float.h"
-#include "FLAC/ordinals.h" /* for FLAC__bool */
-
-/* Returns the unaligned address returned by malloc.
- * Use free() on this address to deallocate.
- */
-void *FLAC__memory_alloc_aligned(size_t bytes, void **aligned_address);
-FLAC__bool FLAC__memory_alloc_aligned_int32_array(unsigned elements, FLAC__int32 **unaligned_pointer, FLAC__int32 **aligned_pointer);
-FLAC__bool FLAC__memory_alloc_aligned_uint32_array(unsigned elements, FLAC__uint32 **unaligned_pointer, FLAC__uint32 **aligned_pointer);
-FLAC__bool FLAC__memory_alloc_aligned_uint64_array(unsigned elements, FLAC__uint64 **unaligned_pointer, FLAC__uint64 **aligned_pointer);
-FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(unsigned elements, unsigned **unaligned_pointer, unsigned **aligned_pointer);
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
-FLAC__bool FLAC__memory_alloc_aligned_real_array(unsigned elements, FLAC__real **unaligned_pointer, FLAC__real **aligned_pointer);
-#endif
-
-#endif
diff --git a/src/thirdparty/libflac/src/libFLAC/include/private/metadata.h b/src/thirdparty/libflac/src/libFLAC/include/private/metadata.h
deleted file mode 100644
index d75d44236..000000000
--- a/src/thirdparty/libflac/src/libFLAC/include/private/metadata.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__PRIVATE__METADATA_H
-#define FLAC__PRIVATE__METADATA_H
-
-#include "FLAC/metadata.h"
-
-/* WATCHOUT: all malloc()ed data in the block is free()ed; this may not
- * be a consistent state (e.g. PICTURE) or equivalent to the initial
- * state after FLAC__metadata_object_new()
- */
-void FLAC__metadata_object_delete_data(FLAC__StreamMetadata *object);
-
-void FLAC__metadata_object_cuesheet_track_delete_data(FLAC__StreamMetadata_CueSheet_Track *object);
-
-#endif
diff --git a/src/thirdparty/libflac/src/libFLAC/include/private/ogg_decoder_aspect.h b/src/thirdparty/libflac/src/libFLAC/include/private/ogg_decoder_aspect.h
deleted file mode 100644
index 61096654f..000000000
--- a/src/thirdparty/libflac/src/libFLAC/include/private/ogg_decoder_aspect.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec
- * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__PRIVATE__OGG_DECODER_ASPECT_H
-#define FLAC__PRIVATE__OGG_DECODER_ASPECT_H
-
-#include <ogg/ogg.h>
-
-#include "FLAC/ordinals.h"
-#include "FLAC/stream_decoder.h" /* for FLAC__StreamDecoderReadStatus */
-
-typedef struct FLAC__OggDecoderAspect {
- /* these are storage for values that can be set through the API */
- FLAC__bool use_first_serial_number;
- long serial_number;
-
- /* these are for internal state related to Ogg decoding */
- ogg_stream_state stream_state;
- ogg_sync_state sync_state;
- unsigned version_major, version_minor;
- FLAC__bool need_serial_number;
- FLAC__bool end_of_stream;
- FLAC__bool have_working_page; /* only if true will the following vars be valid */
- ogg_page working_page;
- FLAC__bool have_working_packet; /* only if true will the following vars be valid */
- ogg_packet working_packet; /* as we work through the packet we will move working_packet.packet forward and working_packet.bytes down */
-} FLAC__OggDecoderAspect;
-
-void FLAC__ogg_decoder_aspect_set_serial_number(FLAC__OggDecoderAspect *aspect, long value);
-void FLAC__ogg_decoder_aspect_set_defaults(FLAC__OggDecoderAspect *aspect);
-FLAC__bool FLAC__ogg_decoder_aspect_init(FLAC__OggDecoderAspect *aspect);
-void FLAC__ogg_decoder_aspect_finish(FLAC__OggDecoderAspect *aspect);
-void FLAC__ogg_decoder_aspect_flush(FLAC__OggDecoderAspect *aspect);
-void FLAC__ogg_decoder_aspect_reset(FLAC__OggDecoderAspect *aspect);
-
-typedef enum {
- FLAC__OGG_DECODER_ASPECT_READ_STATUS_OK = 0,
- FLAC__OGG_DECODER_ASPECT_READ_STATUS_END_OF_STREAM,
- FLAC__OGG_DECODER_ASPECT_READ_STATUS_LOST_SYNC,
- FLAC__OGG_DECODER_ASPECT_READ_STATUS_NOT_FLAC,
- FLAC__OGG_DECODER_ASPECT_READ_STATUS_UNSUPPORTED_MAPPING_VERSION,
- FLAC__OGG_DECODER_ASPECT_READ_STATUS_ABORT,
- FLAC__OGG_DECODER_ASPECT_READ_STATUS_ERROR,
- FLAC__OGG_DECODER_ASPECT_READ_STATUS_MEMORY_ALLOCATION_ERROR
-} FLAC__OggDecoderAspectReadStatus;
-
-typedef FLAC__OggDecoderAspectReadStatus (*FLAC__OggDecoderAspectReadCallbackProxy)(const void *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
-
-FLAC__OggDecoderAspectReadStatus FLAC__ogg_decoder_aspect_read_callback_wrapper(FLAC__OggDecoderAspect *aspect, FLAC__byte buffer[], size_t *bytes, FLAC__OggDecoderAspectReadCallbackProxy read_callback, const FLAC__StreamDecoder *decoder, void *client_data);
-
-#endif
diff --git a/src/thirdparty/libflac/src/libFLAC/include/private/ogg_encoder_aspect.h b/src/thirdparty/libflac/src/libFLAC/include/private/ogg_encoder_aspect.h
deleted file mode 100644
index 904091126..000000000
--- a/src/thirdparty/libflac/src/libFLAC/include/private/ogg_encoder_aspect.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec
- * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__PRIVATE__OGG_ENCODER_ASPECT_H
-#define FLAC__PRIVATE__OGG_ENCODER_ASPECT_H
-
-#include <ogg/ogg.h>
-
-#include "FLAC/ordinals.h"
-#include "FLAC/stream_encoder.h" /* for FLAC__StreamEncoderWriteStatus */
-
-typedef struct FLAC__OggEncoderAspect {
- /* these are storage for values that can be set through the API */
- long serial_number;
- unsigned num_metadata;
-
- /* these are for internal state related to Ogg encoding */
- ogg_stream_state stream_state;
- ogg_page page;
- FLAC__bool seen_magic; /* true if we've seen the fLaC magic in the write callback yet */
- FLAC__bool is_first_packet;
- FLAC__uint64 samples_written;
-} FLAC__OggEncoderAspect;
-
-void FLAC__ogg_encoder_aspect_set_serial_number(FLAC__OggEncoderAspect *aspect, long value);
-FLAC__bool FLAC__ogg_encoder_aspect_set_num_metadata(FLAC__OggEncoderAspect *aspect, unsigned value);
-void FLAC__ogg_encoder_aspect_set_defaults(FLAC__OggEncoderAspect *aspect);
-FLAC__bool FLAC__ogg_encoder_aspect_init(FLAC__OggEncoderAspect *aspect);
-void FLAC__ogg_encoder_aspect_finish(FLAC__OggEncoderAspect *aspect);
-
-typedef FLAC__StreamEncoderWriteStatus (*FLAC__OggEncoderAspectWriteCallbackProxy)(const void *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, void *client_data);
-
-FLAC__StreamEncoderWriteStatus FLAC__ogg_encoder_aspect_write_callback_wrapper(FLAC__OggEncoderAspect *aspect, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, FLAC__bool is_last_block, FLAC__OggEncoderAspectWriteCallbackProxy write_callback, void *encoder, void *client_data);
-#endif
diff --git a/src/thirdparty/libflac/src/libFLAC/include/private/ogg_helper.h b/src/thirdparty/libflac/src/libFLAC/include/private/ogg_helper.h
deleted file mode 100644
index 7b8ee4265..000000000
--- a/src/thirdparty/libflac/src/libFLAC/include/private/ogg_helper.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec
- * Copyright (C) 2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__PRIVATE__OGG_HELPER_H
-#define FLAC__PRIVATE__OGG_HELPER_H
-
-#include <ogg/ogg.h>
-#include "FLAC/stream_encoder.h" /* for FLAC__StreamEncoder */
-
-void simple_ogg_page__init(ogg_page *page);
-void simple_ogg_page__clear(ogg_page *page);
-FLAC__bool simple_ogg_page__get_at(FLAC__StreamEncoder *encoder, FLAC__uint64 position, ogg_page *page, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderReadCallback read_callback, void *client_data);
-FLAC__bool simple_ogg_page__set_at(FLAC__StreamEncoder *encoder, FLAC__uint64 position, ogg_page *page, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderWriteCallback write_callback, void *client_data);
-
-#endif
diff --git a/src/thirdparty/libflac/src/libFLAC/include/private/ogg_mapping.h b/src/thirdparty/libflac/src/libFLAC/include/private/ogg_mapping.h
deleted file mode 100644
index 17e608097..000000000
--- a/src/thirdparty/libflac/src/libFLAC/include/private/ogg_mapping.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec
- * Copyright (C) 2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__PRIVATE__OGG_MAPPING_H
-#define FLAC__PRIVATE__OGG_MAPPING_H
-
-#include "FLAC/ordinals.h"
-
-/** The length of the 'FLAC' magic in bytes. */
-#define FLAC__OGG_MAPPING_PACKET_TYPE_LENGTH (1u)
-
-extern const unsigned FLAC__OGG_MAPPING_PACKET_TYPE_LEN; /* = 8 bits */
-
-extern const FLAC__byte FLAC__OGG_MAPPING_FIRST_HEADER_PACKET_TYPE; /* = 0x7f */
-
-/** The length of the 'FLAC' magic in bytes. */
-#define FLAC__OGG_MAPPING_MAGIC_LENGTH (4u)
-
-extern const FLAC__byte * const FLAC__OGG_MAPPING_MAGIC; /* = "FLAC" */
-
-extern const unsigned FLAC__OGG_MAPPING_VERSION_MAJOR_LEN; /* = 8 bits */
-extern const unsigned FLAC__OGG_MAPPING_VERSION_MINOR_LEN; /* = 8 bits */
-
-/** The length of the Ogg FLAC mapping major version number in bytes. */
-#define FLAC__OGG_MAPPING_VERSION_MAJOR_LENGTH (1u)
-
-/** The length of the Ogg FLAC mapping minor version number in bytes. */
-#define FLAC__OGG_MAPPING_VERSION_MINOR_LENGTH (1u)
-
-extern const unsigned FLAC__OGG_MAPPING_NUM_HEADERS_LEN; /* = 16 bits */
-
-/** The length of the #-of-header-packets number bytes. */
-#define FLAC__OGG_MAPPING_NUM_HEADERS_LENGTH (2u)
-
-#endif
diff --git a/src/thirdparty/libflac/src/libFLAC/include/private/stream_encoder_framing.h b/src/thirdparty/libflac/src/libFLAC/include/private/stream_encoder_framing.h
deleted file mode 100644
index 2a5699c45..000000000
--- a/src/thirdparty/libflac/src/libFLAC/include/private/stream_encoder_framing.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__PRIVATE__STREAM_ENCODER_FRAMING_H
-#define FLAC__PRIVATE__STREAM_ENCODER_FRAMING_H
-
-#include "FLAC/format.h"
-#include "bitwriter.h"
-
-FLAC__bool FLAC__add_metadata_block(const FLAC__StreamMetadata *metadata, FLAC__BitWriter *bw);
-FLAC__bool FLAC__frame_add_header(const FLAC__FrameHeader *header, FLAC__BitWriter *bw);
-FLAC__bool FLAC__subframe_add_constant(const FLAC__Subframe_Constant *subframe, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitWriter *bw);
-FLAC__bool FLAC__subframe_add_fixed(const FLAC__Subframe_Fixed *subframe, unsigned residual_samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitWriter *bw);
-FLAC__bool FLAC__subframe_add_lpc(const FLAC__Subframe_LPC *subframe, unsigned residual_samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitWriter *bw);
-FLAC__bool FLAC__subframe_add_verbatim(const FLAC__Subframe_Verbatim *subframe, unsigned samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitWriter *bw);
-
-#endif
diff --git a/src/thirdparty/libflac/src/libFLAC/include/private/window.h b/src/thirdparty/libflac/src/libFLAC/include/private/window.h
deleted file mode 100644
index ef952b582..000000000
--- a/src/thirdparty/libflac/src/libFLAC/include/private/window.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__PRIVATE__WINDOW_H
-#define FLAC__PRIVATE__WINDOW_H
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "private/float.h"
-#include "FLAC/format.h"
-
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
-
-/*
- * FLAC__window_*()
- * --------------------------------------------------------------------
- * Calculates window coefficients according to different apodization
- * functions.
- *
- * OUT window[0,L-1]
- * IN L (number of points in window)
- */
-void FLAC__window_bartlett(FLAC__real *window, const FLAC__int32 L);
-void FLAC__window_bartlett_hann(FLAC__real *window, const FLAC__int32 L);
-void FLAC__window_blackman(FLAC__real *window, const FLAC__int32 L);
-void FLAC__window_blackman_harris_4term_92db_sidelobe(FLAC__real *window, const FLAC__int32 L);
-void FLAC__window_connes(FLAC__real *window, const FLAC__int32 L);
-void FLAC__window_flattop(FLAC__real *window, const FLAC__int32 L);
-void FLAC__window_gauss(FLAC__real *window, const FLAC__int32 L, const FLAC__real stddev); /* 0.0 < stddev <= 0.5 */
-void FLAC__window_hamming(FLAC__real *window, const FLAC__int32 L);
-void FLAC__window_hann(FLAC__real *window, const FLAC__int32 L);
-void FLAC__window_kaiser_bessel(FLAC__real *window, const FLAC__int32 L);
-void FLAC__window_nuttall(FLAC__real *window, const FLAC__int32 L);
-void FLAC__window_rectangle(FLAC__real *window, const FLAC__int32 L);
-void FLAC__window_triangle(FLAC__real *window, const FLAC__int32 L);
-void FLAC__window_tukey(FLAC__real *window, const FLAC__int32 L, const FLAC__real p);
-void FLAC__window_welch(FLAC__real *window, const FLAC__int32 L);
-
-#endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */
-
-#endif
diff --git a/src/thirdparty/libflac/src/libFLAC/include/protected/all.h b/src/thirdparty/libflac/src/libFLAC/include/protected/all.h
deleted file mode 100644
index 0523e304a..000000000
--- a/src/thirdparty/libflac/src/libFLAC/include/protected/all.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__PROTECTED__ALL_H
-#define FLAC__PROTECTED__ALL_H
-
-#include "stream_decoder.h"
-#include "stream_encoder.h"
-
-#endif
diff --git a/src/thirdparty/libflac/src/libFLAC/include/protected/stream_decoder.h b/src/thirdparty/libflac/src/libFLAC/include/protected/stream_decoder.h
deleted file mode 100644
index e6fe80799..000000000
--- a/src/thirdparty/libflac/src/libFLAC/include/protected/stream_decoder.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__PROTECTED__STREAM_DECODER_H
-#define FLAC__PROTECTED__STREAM_DECODER_H
-
-#include "FLAC/stream_decoder.h"
-#if FLAC__HAS_OGG
-#include "private/ogg_decoder_aspect.h"
-#endif
-
-typedef struct FLAC__StreamDecoderProtected {
- FLAC__StreamDecoderState state;
- unsigned channels;
- FLAC__ChannelAssignment channel_assignment;
- unsigned bits_per_sample;
- unsigned sample_rate; /* in Hz */
- unsigned blocksize; /* in samples (per channel) */
- FLAC__bool md5_checking; /* if true, generate MD5 signature of decoded data and compare against signature in the STREAMINFO metadata block */
-#if FLAC__HAS_OGG
- FLAC__OggDecoderAspect ogg_decoder_aspect;
-#endif
-} FLAC__StreamDecoderProtected;
-
-/*
- * return the number of input bytes consumed
- */
-unsigned FLAC__stream_decoder_get_input_bytes_unconsumed(const FLAC__StreamDecoder *decoder);
-
-#endif
diff --git a/src/thirdparty/libflac/src/libFLAC/include/protected/stream_encoder.h b/src/thirdparty/libflac/src/libFLAC/include/protected/stream_encoder.h
deleted file mode 100644
index 637281372..000000000
--- a/src/thirdparty/libflac/src/libFLAC/include/protected/stream_encoder.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#ifndef FLAC__PROTECTED__STREAM_ENCODER_H
-#define FLAC__PROTECTED__STREAM_ENCODER_H
-
-#include "FLAC/stream_encoder.h"
-#if FLAC__HAS_OGG
-#include "private/ogg_encoder_aspect.h"
-#endif
-
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
-
-#include "private/float.h"
-
-#define FLAC__MAX_APODIZATION_FUNCTIONS 32
-
-typedef enum {
- FLAC__APODIZATION_BARTLETT,
- FLAC__APODIZATION_BARTLETT_HANN,
- FLAC__APODIZATION_BLACKMAN,
- FLAC__APODIZATION_BLACKMAN_HARRIS_4TERM_92DB_SIDELOBE,
- FLAC__APODIZATION_CONNES,
- FLAC__APODIZATION_FLATTOP,
- FLAC__APODIZATION_GAUSS,
- FLAC__APODIZATION_HAMMING,
- FLAC__APODIZATION_HANN,
- FLAC__APODIZATION_KAISER_BESSEL,
- FLAC__APODIZATION_NUTTALL,
- FLAC__APODIZATION_RECTANGLE,
- FLAC__APODIZATION_TRIANGLE,
- FLAC__APODIZATION_TUKEY,
- FLAC__APODIZATION_WELCH
-} FLAC__ApodizationFunction;
-
-typedef struct {
- FLAC__ApodizationFunction type;
- union {
- struct {
- FLAC__real stddev;
- } gauss;
- struct {
- FLAC__real p;
- } tukey;
- } parameters;
-} FLAC__ApodizationSpecification;
-
-#endif // #ifndef FLAC__INTEGER_ONLY_LIBRARY
-
-typedef struct FLAC__StreamEncoderProtected {
- FLAC__StreamEncoderState state;
- FLAC__bool verify;
- FLAC__bool streamable_subset;
- FLAC__bool do_md5;
- FLAC__bool do_mid_side_stereo;
- FLAC__bool loose_mid_side_stereo;
- unsigned channels;
- unsigned bits_per_sample;
- unsigned sample_rate;
- unsigned blocksize;
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
- unsigned num_apodizations;
- FLAC__ApodizationSpecification apodizations[FLAC__MAX_APODIZATION_FUNCTIONS];
-#endif
- unsigned max_lpc_order;
- unsigned qlp_coeff_precision;
- FLAC__bool do_qlp_coeff_prec_search;
- FLAC__bool do_exhaustive_model_search;
- FLAC__bool do_escape_coding;
- unsigned min_residual_partition_order;
- unsigned max_residual_partition_order;
- unsigned rice_parameter_search_dist;
- FLAC__uint64 total_samples_estimate;
- FLAC__StreamMetadata **metadata;
- unsigned num_metadata_blocks;
- FLAC__uint64 streaminfo_offset, seektable_offset, audio_offset;
-#if FLAC__HAS_OGG
- FLAC__OggEncoderAspect ogg_encoder_aspect;
-#endif
-} FLAC__StreamEncoderProtected;
-
-#endif
diff --git a/src/thirdparty/libflac/src/libFLAC/libflac.vcxproj b/src/thirdparty/libflac/src/libFLAC/libflac.vcxproj
deleted file mode 100644
index 63e7e4072..000000000
--- a/src/thirdparty/libflac/src/libFLAC/libflac.vcxproj
+++ /dev/null
@@ -1,195 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{4CEFBC84-C215-11DB-8314-0800200C9A66}</ProjectGuid>
- <RootNamespace>libflac</RootNamespace>
- <Keyword>Win32Proj</Keyword>
- <ProjectName>libflac</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <Import Project="..\..\..\..\platform.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- <Import Project="..\..\..\..\YASM.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\..\common.props" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>include;..\..\include;..\..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;FLAC__HAS_OGG;FLAC__CPU_IA32;FLAC__HAS_NASM;FLAC__USE_3DNOW;VERSION="1.2.0";FLAC__NO_DLL;FLAC__OVERFLOW_DETECT;_WINSOCK2API_;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <WarningLevel>TurnOffAllWarnings</WarningLevel>
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
- <EnablePREfast>false</EnablePREfast>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>include;..\..\include;..\..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;FLAC__HAS_OGG;FLAC__HAS_NASM;FLAC__USE_3DNOW;VERSION="1.2.0";FLAC__NO_DLL;FLAC__OVERFLOW_DETECT;_WINSOCK2API_;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <WarningLevel>TurnOffAllWarnings</WarningLevel>
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
- <EnablePREfast>false</EnablePREfast>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>include;..\..\include;..\..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;FLAC__HAS_OGG;FLAC__CPU_IA32;FLAC__HAS_NASM;FLAC__USE_3DNOW;VERSION="1.2.0";FLAC__NO_DLL;_WINSOCK2API_;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <WarningLevel>TurnOffAllWarnings</WarningLevel>
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
- <EnablePREfast>false</EnablePREfast>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>include;..\..\include;..\..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;FLAC__HAS_OGG;FLAC__HAS_NASM;FLAC__USE_3DNOW;VERSION="1.2.0";FLAC__NO_DLL;_WINSOCK2API_;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <WarningLevel>TurnOffAllWarnings</WarningLevel>
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
- <EnablePREfast>false</EnablePREfast>
- </ClCompile>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClInclude Include="include\protected\all.h" />
- <ClInclude Include="include\private\all.h" />
- <ClInclude Include="include\private\bitmath.h" />
- <ClInclude Include="include\private\bitreader.h" />
- <ClInclude Include="include\private\bitwriter.h" />
- <ClInclude Include="include\private\cpu.h" />
- <ClInclude Include="include\private\crc.h" />
- <ClInclude Include="include\private\fixed.h" />
- <ClInclude Include="include\private\float.h" />
- <ClInclude Include="include\private\format.h" />
- <ClInclude Include="include\private\lpc.h" />
- <ClInclude Include="include\private\md5.h" />
- <ClInclude Include="include\private\memory.h" />
- <ClInclude Include="include\private\metadata.h" />
- <ClInclude Include="ia32\nasm.h" />
- <ClInclude Include="include\private\ogg_decoder_aspect.h" />
- <ClInclude Include="include\private\ogg_encoder_aspect.h" />
- <ClInclude Include="include\private\ogg_helper.h" />
- <ClInclude Include="include\private\ogg_mapping.h" />
- <ClInclude Include="include\protected\stream_decoder.h" />
- <ClInclude Include="include\protected\stream_encoder.h" />
- <ClInclude Include="include\private\stream_encoder_framing.h" />
- <ClInclude Include="include\private\window.h" />
- <ClInclude Include="..\..\include\FLAC\all.h" />
- <ClInclude Include="..\..\include\FLAC\assert.h" />
- <ClInclude Include="..\..\include\FLAC\callback.h" />
- <ClInclude Include="..\..\include\FLAC\export.h" />
- <ClInclude Include="..\..\include\FLAC\format.h" />
- <ClInclude Include="..\..\include\FLAC\metadata.h" />
- <ClInclude Include="..\..\include\FLAC\ordinals.h" />
- <ClInclude Include="..\..\include\FLAC\stream_decoder.h" />
- <ClInclude Include="..\..\include\FLAC\stream_encoder.h" />
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="bitmath.c" />
- <ClCompile Include="bitreader.c" />
- <ClCompile Include="bitwriter.c" />
- <ClCompile Include="cpu.c" />
- <ClCompile Include="crc.c" />
- <ClCompile Include="fixed.c" />
- <ClCompile Include="float.c" />
- <ClCompile Include="format.c" />
- <ClCompile Include="lpc.c" />
- <ClCompile Include="md5.c" />
- <ClCompile Include="memory.c" />
- <ClCompile Include="metadata_iterators.c" />
- <ClCompile Include="metadata_object.c" />
- <ClCompile Include="ogg_decoder_aspect.c" />
- <ClCompile Include="ogg_encoder_aspect.c" />
- <ClCompile Include="ogg_helper.c" />
- <ClCompile Include="ogg_mapping.c" />
- <ClCompile Include="stream_decoder.c" />
- <ClCompile Include="stream_encoder.c" />
- <ClCompile Include="stream_encoder_framing.c" />
- <ClCompile Include="window.c" />
- <ClCompile Include="Ogg\bitwise.c" />
- <ClCompile Include="Ogg\framing.c" />
- </ItemGroup>
- <ItemGroup>
- <YASM Include="ia32\bitreader_asm.nasm">
- <IncludePaths>ia32</IncludePaths>
- <Defines>OBJ_FORMAT_win32</Defines>
- <AdditionalDependencies>ia32/%(Filename).nasm;ia32/nasm.h</AdditionalDependencies>
- </YASM>
- <YASM Include="ia32\cpu_asm.nasm">
- <IncludePaths>ia32</IncludePaths>
- <Defines>OBJ_FORMAT_win32</Defines>
- <AdditionalDependencies>ia32/%(Filename).nasm;ia32/nasm.h</AdditionalDependencies>
- </YASM>
- <YASM Include="ia32\fixed_asm.nasm">
- <IncludePaths>ia32</IncludePaths>
- <Defines>OBJ_FORMAT_win32</Defines>
- <AdditionalDependencies>ia32/%(Filename).nasm;ia32/nasm.h</AdditionalDependencies>
- </YASM>
- <YASM Include="ia32\lpc_asm.nasm">
- <IncludePaths>ia32</IncludePaths>
- <Defines>OBJ_FORMAT_win32</Defines>
- <AdditionalDependencies>ia32/%(Filename).nasm;ia32/nasm.h</AdditionalDependencies>
- </YASM>
- <YASM Include="ia32\stream_encoder_asm.nasm">
- <IncludePaths>ia32</IncludePaths>
- <Defines>OBJ_FORMAT_win32</Defines>
- <AdditionalDependencies>ia32/%(Filename).nasm;ia32/nasm.h</AdditionalDependencies>
- </YASM>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- <Import Project="..\..\..\..\YASM.targets" />
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/src/thirdparty/libflac/src/libFLAC/libflac.vcxproj.filters b/src/thirdparty/libflac/src/libFLAC/libflac.vcxproj.filters
deleted file mode 100644
index e39a187f3..000000000
--- a/src/thirdparty/libflac/src/libFLAC/libflac.vcxproj.filters
+++ /dev/null
@@ -1,195 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Header Files">
- <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
- </Filter>
- <Filter Include="Public Header Files">
- <UniqueIdentifier>{a378197c-5696-4fb5-b4db-e9f42e1c88b2}</UniqueIdentifier>
- </Filter>
- <Filter Include="Source Files">
- <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
- <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
- </Filter>
- <Filter Include="Ogg">
- <UniqueIdentifier>{9a24d6e1-45f1-4fd5-9e5b-b2fc0805d1fb}</UniqueIdentifier>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="include\protected\all.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="include\private\all.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="include\private\bitmath.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="include\private\bitreader.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="include\private\bitwriter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="include\private\cpu.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="include\private\crc.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="include\private\fixed.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="include\private\float.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="include\private\format.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="include\private\lpc.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="include\private\md5.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="include\private\memory.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="include\private\metadata.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="ia32\nasm.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="include\private\ogg_decoder_aspect.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="include\private\ogg_encoder_aspect.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="include\private\ogg_helper.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="include\private\ogg_mapping.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="include\protected\stream_decoder.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="include\protected\stream_encoder.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="include\private\stream_encoder_framing.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="include\private\window.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\FLAC\all.h">
- <Filter>Public Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\FLAC\assert.h">
- <Filter>Public Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\FLAC\callback.h">
- <Filter>Public Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\FLAC\export.h">
- <Filter>Public Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\FLAC\format.h">
- <Filter>Public Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\FLAC\metadata.h">
- <Filter>Public Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\FLAC\ordinals.h">
- <Filter>Public Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\FLAC\stream_decoder.h">
- <Filter>Public Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\FLAC\stream_encoder.h">
- <Filter>Public Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="bitmath.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="bitreader.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="bitwriter.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="cpu.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="crc.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="fixed.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="float.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="format.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="lpc.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="md5.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="memory.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="metadata_iterators.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="metadata_object.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="ogg_decoder_aspect.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="ogg_encoder_aspect.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="ogg_helper.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="ogg_mapping.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="stream_decoder.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="stream_encoder.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="stream_encoder_framing.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="window.c">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="Ogg\bitwise.c">
- <Filter>Ogg</Filter>
- </ClCompile>
- <ClCompile Include="Ogg\framing.c">
- <Filter>Ogg</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <YASM Include="ia32\lpc_asm.nasm" />
- <YASM Include="ia32\fixed_asm.nasm" />
- <YASM Include="ia32\cpu_asm.nasm" />
- <YASM Include="ia32\stream_encoder_asm.nasm" />
- <YASM Include="ia32\bitreader_asm.nasm" />
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/src/thirdparty/libflac/src/libFLAC/lpc.c b/src/thirdparty/libflac/src/libFLAC/lpc.c
deleted file mode 100644
index 4f8339e55..000000000
--- a/src/thirdparty/libflac/src/libFLAC/lpc.c
+++ /dev/null
@@ -1,1377 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <math.h>
-#include "FLAC/assert.h"
-#include "FLAC/format.h"
-#include "private/bitmath.h"
-#include "private/lpc.h"
-#if defined DEBUG || defined FLAC__OVERFLOW_DETECT || defined FLAC__OVERFLOW_DETECT_VERBOSE
-#include <stdio.h>
-#endif
-
-/* OPT: #undef'ing this may improve the speed on some architectures */
-#define FLAC__LPC_UNROLLED_FILTER_LOOPS
-
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
-
-#ifndef M_LN2
-/* math.h in VC++ doesn't seem to have this (how Microsoft is that?) */
-#define M_LN2 0.69314718055994530942
-#endif
-
-
-void FLAC__lpc_window_data(const FLAC__int32 in[], const FLAC__real window[], FLAC__real out[], unsigned data_len)
-{
- unsigned i;
- for(i = 0; i < data_len; i++)
- out[i] = in[i] * window[i];
-}
-
-void FLAC__lpc_compute_autocorrelation(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[])
-{
- /* a readable, but slower, version */
-#if 0
- FLAC__real d;
- unsigned i;
-
- FLAC__ASSERT(lag > 0);
- FLAC__ASSERT(lag <= data_len);
-
- /*
- * Technically we should subtract the mean first like so:
- * for(i = 0; i < data_len; i++)
- * data[i] -= mean;
- * but it appears not to make enough of a difference to matter, and
- * most signals are already closely centered around zero
- */
- while(lag--) {
- for(i = lag, d = 0.0; i < data_len; i++)
- d += data[i] * data[i - lag];
- autoc[lag] = d;
- }
-#endif
-
- /*
- * this version tends to run faster because of better data locality
- * ('data_len' is usually much larger than 'lag')
- */
- FLAC__real d;
- unsigned sample, coeff;
- const unsigned limit = data_len - lag;
-
- FLAC__ASSERT(lag > 0);
- FLAC__ASSERT(lag <= data_len);
-
- for(coeff = 0; coeff < lag; coeff++)
- autoc[coeff] = 0.0;
- for(sample = 0; sample <= limit; sample++) {
- d = data[sample];
- for(coeff = 0; coeff < lag; coeff++)
- autoc[coeff] += d * data[sample+coeff];
- }
- for(; sample < data_len; sample++) {
- d = data[sample];
- for(coeff = 0; coeff < data_len - sample; coeff++)
- autoc[coeff] += d * data[sample+coeff];
- }
-}
-
-void FLAC__lpc_compute_lp_coefficients(const FLAC__real autoc[], unsigned *max_order, FLAC__real lp_coeff[][FLAC__MAX_LPC_ORDER], FLAC__double error[])
-{
- unsigned i, j;
- FLAC__double r, err, ref[FLAC__MAX_LPC_ORDER], lpc[FLAC__MAX_LPC_ORDER];
-
- FLAC__ASSERT(0 != max_order);
- FLAC__ASSERT(0 < *max_order);
- FLAC__ASSERT(*max_order <= FLAC__MAX_LPC_ORDER);
- FLAC__ASSERT(autoc[0] != 0.0);
-
- err = autoc[0];
-
- for(i = 0; i < *max_order; i++) {
- /* Sum up this iteration's reflection coefficient. */
- r = -autoc[i+1];
- for(j = 0; j < i; j++)
- r -= lpc[j] * autoc[i-j];
- ref[i] = (r/=err);
-
- /* Update LPC coefficients and total error. */
- lpc[i]=r;
- for(j = 0; j < (i>>1); j++) {
- FLAC__double tmp = lpc[j];
- lpc[j] += r * lpc[i-1-j];
- lpc[i-1-j] += r * tmp;
- }
- if(i & 1)
- lpc[j] += lpc[j] * r;
-
- err *= (1.0 - r * r);
-
- /* save this order */
- for(j = 0; j <= i; j++)
- lp_coeff[i][j] = (FLAC__real)(-lpc[j]); /* negate FIR filter coeff to get predictor coeff */
- error[i] = err;
-
- /* see SF bug #1601812 http://sourceforge.net/tracker/index.php?func=detail&aid=1601812&group_id=13478&atid=113478 */
- if(err == 0.0) {
- *max_order = i+1;
- return;
- }
- }
-}
-
-int FLAC__lpc_quantize_coefficients(const FLAC__real lp_coeff[], unsigned order, unsigned precision, FLAC__int32 qlp_coeff[], int *shift)
-{
- unsigned i;
- FLAC__double cmax;
- FLAC__int32 qmax, qmin;
-
- FLAC__ASSERT(precision > 0);
- FLAC__ASSERT(precision >= FLAC__MIN_QLP_COEFF_PRECISION);
-
- /* drop one bit for the sign; from here on out we consider only |lp_coeff[i]| */
- precision--;
- qmax = 1 << precision;
- qmin = -qmax;
- qmax--;
-
- /* calc cmax = max( |lp_coeff[i]| ) */
- cmax = 0.0;
- for(i = 0; i < order; i++) {
- const FLAC__double d = fabs(lp_coeff[i]);
- if(d > cmax)
- cmax = d;
- }
-
- if(cmax <= 0.0) {
- /* => coefficients are all 0, which means our constant-detect didn't work */
- return 2;
- }
- else {
- const int max_shiftlimit = (1 << (FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN-1)) - 1;
- const int min_shiftlimit = -max_shiftlimit - 1;
- int log2cmax;
-
- (void)frexp(cmax, &log2cmax);
- log2cmax--;
- *shift = (int)precision - log2cmax - 1;
-
- if(*shift > max_shiftlimit)
- *shift = max_shiftlimit;
- else if(*shift < min_shiftlimit)
- return 1;
- }
-
- if(*shift >= 0) {
- FLAC__double error = 0.0;
- FLAC__int32 q;
- for(i = 0; i < order; i++) {
- error += lp_coeff[i] * (1 << *shift);
-#if 1 /* unfortunately lround() is C99 */
- if(error >= 0.0)
- q = (FLAC__int32)(error + 0.5);
- else
- q = (FLAC__int32)(error - 0.5);
-#else
- q = lround(error);
-#endif
-#ifdef FLAC__OVERFLOW_DETECT
- if(q > qmax+1) /* we expect q==qmax+1 occasionally due to rounding */
- fprintf(stderr,"FLAC__lpc_quantize_coefficients: quantizer overflow: q>qmax %d>%d shift=%d cmax=%f precision=%u lpc[%u]=%f\n",q,qmax,*shift,cmax,precision+1,i,lp_coeff[i]);
- else if(q < qmin)
- fprintf(stderr,"FLAC__lpc_quantize_coefficients: quantizer overflow: q<qmin %d<%d shift=%d cmax=%f precision=%u lpc[%u]=%f\n",q,qmin,*shift,cmax,precision+1,i,lp_coeff[i]);
-#endif
- if(q > qmax)
- q = qmax;
- else if(q < qmin)
- q = qmin;
- error -= q;
- qlp_coeff[i] = q;
- }
- }
- /* negative shift is very rare but due to design flaw, negative shift is
- * a NOP in the decoder, so it must be handled specially by scaling down
- * coeffs
- */
- else {
- const int nshift = -(*shift);
- FLAC__double error = 0.0;
- FLAC__int32 q;
-#ifdef DEBUG
- fprintf(stderr,"FLAC__lpc_quantize_coefficients: negative shift=%d order=%u cmax=%f\n", *shift, order, cmax);
-#endif
- for(i = 0; i < order; i++) {
- error += lp_coeff[i] / (1 << nshift);
-#if 1 /* unfortunately lround() is C99 */
- if(error >= 0.0)
- q = (FLAC__int32)(error + 0.5);
- else
- q = (FLAC__int32)(error - 0.5);
-#else
- q = lround(error);
-#endif
-#ifdef FLAC__OVERFLOW_DETECT
- if(q > qmax+1) /* we expect q==qmax+1 occasionally due to rounding */
- fprintf(stderr,"FLAC__lpc_quantize_coefficients: quantizer overflow: q>qmax %d>%d shift=%d cmax=%f precision=%u lpc[%u]=%f\n",q,qmax,*shift,cmax,precision+1,i,lp_coeff[i]);
- else if(q < qmin)
- fprintf(stderr,"FLAC__lpc_quantize_coefficients: quantizer overflow: q<qmin %d<%d shift=%d cmax=%f precision=%u lpc[%u]=%f\n",q,qmin,*shift,cmax,precision+1,i,lp_coeff[i]);
-#endif
- if(q > qmax)
- q = qmax;
- else if(q < qmin)
- q = qmin;
- error -= q;
- qlp_coeff[i] = q;
- }
- *shift = 0;
- }
-
- return 0;
-}
-
-void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[])
-#if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPS)
-{
- FLAC__int64 sumo;
- unsigned i, j;
- FLAC__int32 sum;
- const FLAC__int32 *history;
-
-#ifdef FLAC__OVERFLOW_DETECT_VERBOSE
- fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients: data_len=%d, order=%u, lpq=%d",data_len,order,lp_quantization);
- for(i=0;i<order;i++)
- fprintf(stderr,", q[%u]=%d",i,qlp_coeff[i]);
- fprintf(stderr,"\n");
-#endif
- FLAC__ASSERT(order > 0);
-
- for(i = 0; i < data_len; i++) {
- sumo = 0;
- sum = 0;
- history = data;
- for(j = 0; j < order; j++) {
- sum += qlp_coeff[j] * (*(--history));
- sumo += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*history);
-#if defined _MSC_VER
- if(sumo > 2147483647I64 || sumo < -2147483648I64)
- fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients: OVERFLOW, i=%u, j=%u, c=%d, d=%d, sumo=%I64d\n",i,j,qlp_coeff[j],*history,sumo);
-#else
- if(sumo > 2147483647ll || sumo < -2147483648ll)
- fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients: OVERFLOW, i=%u, j=%u, c=%d, d=%d, sumo=%lld\n",i,j,qlp_coeff[j],*history,(long long)sumo);
-#endif
- }
- *(residual++) = *(data++) - (sum >> lp_quantization);
- }
-
- /* Here's a slower but clearer version:
- for(i = 0; i < data_len; i++) {
- sum = 0;
- for(j = 0; j < order; j++)
- sum += qlp_coeff[j] * data[i-j-1];
- residual[i] = data[i] - (sum >> lp_quantization);
- }
- */
-}
-#else /* fully unrolled version for normal use */
-{
- int i;
- FLAC__int32 sum;
-
- FLAC__ASSERT(order > 0);
- FLAC__ASSERT(order <= 32);
-
- /*
- * We do unique versions up to 12th order since that's the subset limit.
- * Also they are roughly ordered to match frequency of occurrence to
- * minimize branching.
- */
- if(order <= 12) {
- if(order > 8) {
- if(order > 10) {
- if(order == 12) {
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[11] * data[i-12];
- sum += qlp_coeff[10] * data[i-11];
- sum += qlp_coeff[9] * data[i-10];
- sum += qlp_coeff[8] * data[i-9];
- sum += qlp_coeff[7] * data[i-8];
- sum += qlp_coeff[6] * data[i-7];
- sum += qlp_coeff[5] * data[i-6];
- sum += qlp_coeff[4] * data[i-5];
- sum += qlp_coeff[3] * data[i-4];
- sum += qlp_coeff[2] * data[i-3];
- sum += qlp_coeff[1] * data[i-2];
- sum += qlp_coeff[0] * data[i-1];
- residual[i] = data[i] - (sum >> lp_quantization);
- }
- }
- else { /* order == 11 */
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[10] * data[i-11];
- sum += qlp_coeff[9] * data[i-10];
- sum += qlp_coeff[8] * data[i-9];
- sum += qlp_coeff[7] * data[i-8];
- sum += qlp_coeff[6] * data[i-7];
- sum += qlp_coeff[5] * data[i-6];
- sum += qlp_coeff[4] * data[i-5];
- sum += qlp_coeff[3] * data[i-4];
- sum += qlp_coeff[2] * data[i-3];
- sum += qlp_coeff[1] * data[i-2];
- sum += qlp_coeff[0] * data[i-1];
- residual[i] = data[i] - (sum >> lp_quantization);
- }
- }
- }
- else {
- if(order == 10) {
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[9] * data[i-10];
- sum += qlp_coeff[8] * data[i-9];
- sum += qlp_coeff[7] * data[i-8];
- sum += qlp_coeff[6] * data[i-7];
- sum += qlp_coeff[5] * data[i-6];
- sum += qlp_coeff[4] * data[i-5];
- sum += qlp_coeff[3] * data[i-4];
- sum += qlp_coeff[2] * data[i-3];
- sum += qlp_coeff[1] * data[i-2];
- sum += qlp_coeff[0] * data[i-1];
- residual[i] = data[i] - (sum >> lp_quantization);
- }
- }
- else { /* order == 9 */
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[8] * data[i-9];
- sum += qlp_coeff[7] * data[i-8];
- sum += qlp_coeff[6] * data[i-7];
- sum += qlp_coeff[5] * data[i-6];
- sum += qlp_coeff[4] * data[i-5];
- sum += qlp_coeff[3] * data[i-4];
- sum += qlp_coeff[2] * data[i-3];
- sum += qlp_coeff[1] * data[i-2];
- sum += qlp_coeff[0] * data[i-1];
- residual[i] = data[i] - (sum >> lp_quantization);
- }
- }
- }
- }
- else if(order > 4) {
- if(order > 6) {
- if(order == 8) {
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[7] * data[i-8];
- sum += qlp_coeff[6] * data[i-7];
- sum += qlp_coeff[5] * data[i-6];
- sum += qlp_coeff[4] * data[i-5];
- sum += qlp_coeff[3] * data[i-4];
- sum += qlp_coeff[2] * data[i-3];
- sum += qlp_coeff[1] * data[i-2];
- sum += qlp_coeff[0] * data[i-1];
- residual[i] = data[i] - (sum >> lp_quantization);
- }
- }
- else { /* order == 7 */
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[6] * data[i-7];
- sum += qlp_coeff[5] * data[i-6];
- sum += qlp_coeff[4] * data[i-5];
- sum += qlp_coeff[3] * data[i-4];
- sum += qlp_coeff[2] * data[i-3];
- sum += qlp_coeff[1] * data[i-2];
- sum += qlp_coeff[0] * data[i-1];
- residual[i] = data[i] - (sum >> lp_quantization);
- }
- }
- }
- else {
- if(order == 6) {
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[5] * data[i-6];
- sum += qlp_coeff[4] * data[i-5];
- sum += qlp_coeff[3] * data[i-4];
- sum += qlp_coeff[2] * data[i-3];
- sum += qlp_coeff[1] * data[i-2];
- sum += qlp_coeff[0] * data[i-1];
- residual[i] = data[i] - (sum >> lp_quantization);
- }
- }
- else { /* order == 5 */
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[4] * data[i-5];
- sum += qlp_coeff[3] * data[i-4];
- sum += qlp_coeff[2] * data[i-3];
- sum += qlp_coeff[1] * data[i-2];
- sum += qlp_coeff[0] * data[i-1];
- residual[i] = data[i] - (sum >> lp_quantization);
- }
- }
- }
- }
- else {
- if(order > 2) {
- if(order == 4) {
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[3] * data[i-4];
- sum += qlp_coeff[2] * data[i-3];
- sum += qlp_coeff[1] * data[i-2];
- sum += qlp_coeff[0] * data[i-1];
- residual[i] = data[i] - (sum >> lp_quantization);
- }
- }
- else { /* order == 3 */
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[2] * data[i-3];
- sum += qlp_coeff[1] * data[i-2];
- sum += qlp_coeff[0] * data[i-1];
- residual[i] = data[i] - (sum >> lp_quantization);
- }
- }
- }
- else {
- if(order == 2) {
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[1] * data[i-2];
- sum += qlp_coeff[0] * data[i-1];
- residual[i] = data[i] - (sum >> lp_quantization);
- }
- }
- else { /* order == 1 */
- for(i = 0; i < (int)data_len; i++)
- residual[i] = data[i] - ((qlp_coeff[0] * data[i-1]) >> lp_quantization);
- }
- }
- }
- }
- else { /* order > 12 */
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- switch(order) {
- case 32: sum += qlp_coeff[31] * data[i-32];
- case 31: sum += qlp_coeff[30] * data[i-31];
- case 30: sum += qlp_coeff[29] * data[i-30];
- case 29: sum += qlp_coeff[28] * data[i-29];
- case 28: sum += qlp_coeff[27] * data[i-28];
- case 27: sum += qlp_coeff[26] * data[i-27];
- case 26: sum += qlp_coeff[25] * data[i-26];
- case 25: sum += qlp_coeff[24] * data[i-25];
- case 24: sum += qlp_coeff[23] * data[i-24];
- case 23: sum += qlp_coeff[22] * data[i-23];
- case 22: sum += qlp_coeff[21] * data[i-22];
- case 21: sum += qlp_coeff[20] * data[i-21];
- case 20: sum += qlp_coeff[19] * data[i-20];
- case 19: sum += qlp_coeff[18] * data[i-19];
- case 18: sum += qlp_coeff[17] * data[i-18];
- case 17: sum += qlp_coeff[16] * data[i-17];
- case 16: sum += qlp_coeff[15] * data[i-16];
- case 15: sum += qlp_coeff[14] * data[i-15];
- case 14: sum += qlp_coeff[13] * data[i-14];
- case 13: sum += qlp_coeff[12] * data[i-13];
- sum += qlp_coeff[11] * data[i-12];
- sum += qlp_coeff[10] * data[i-11];
- sum += qlp_coeff[ 9] * data[i-10];
- sum += qlp_coeff[ 8] * data[i- 9];
- sum += qlp_coeff[ 7] * data[i- 8];
- sum += qlp_coeff[ 6] * data[i- 7];
- sum += qlp_coeff[ 5] * data[i- 6];
- sum += qlp_coeff[ 4] * data[i- 5];
- sum += qlp_coeff[ 3] * data[i- 4];
- sum += qlp_coeff[ 2] * data[i- 3];
- sum += qlp_coeff[ 1] * data[i- 2];
- sum += qlp_coeff[ 0] * data[i- 1];
- }
- residual[i] = data[i] - (sum >> lp_quantization);
- }
- }
-}
-#endif
-
-void FLAC__lpc_compute_residual_from_qlp_coefficients_wide(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[])
-#if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPS)
-{
- unsigned i, j;
- FLAC__int64 sum;
- const FLAC__int32 *history;
-
-#ifdef FLAC__OVERFLOW_DETECT_VERBOSE
- fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients_wide: data_len=%d, order=%u, lpq=%d",data_len,order,lp_quantization);
- for(i=0;i<order;i++)
- fprintf(stderr,", q[%u]=%d",i,qlp_coeff[i]);
- fprintf(stderr,"\n");
-#endif
- FLAC__ASSERT(order > 0);
-
- for(i = 0; i < data_len; i++) {
- sum = 0;
- history = data;
- for(j = 0; j < order; j++)
- sum += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*(--history));
- if(FLAC__bitmath_silog2_wide(sum >> lp_quantization) > 32) {
-#if defined _MSC_VER
- fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients_wide: OVERFLOW, i=%u, sum=%I64d\n", i, sum >> lp_quantization);
-#else
- fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients_wide: OVERFLOW, i=%u, sum=%lld\n", i, (long long)(sum >> lp_quantization));
-#endif
- break;
- }
- if(FLAC__bitmath_silog2_wide((FLAC__int64)(*data) - (sum >> lp_quantization)) > 32) {
-#if defined _MSC_VER
- fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients_wide: OVERFLOW, i=%u, data=%d, sum=%I64d, residual=%I64d\n", i, *data, sum >> lp_quantization, (FLAC__int64)(*data) - (sum >> lp_quantization));
-#else
- fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients_wide: OVERFLOW, i=%u, data=%d, sum=%lld, residual=%lld\n", i, *data, (long long)(sum >> lp_quantization), (long long)((FLAC__int64)(*data) - (sum >> lp_quantization)));
-#endif
- break;
- }
- *(residual++) = *(data++) - (FLAC__int32)(sum >> lp_quantization);
- }
-}
-#else /* fully unrolled version for normal use */
-{
- int i;
- FLAC__int64 sum;
-
- FLAC__ASSERT(order > 0);
- FLAC__ASSERT(order <= 32);
-
- /*
- * We do unique versions up to 12th order since that's the subset limit.
- * Also they are roughly ordered to match frequency of occurrence to
- * minimize branching.
- */
- if(order <= 12) {
- if(order > 8) {
- if(order > 10) {
- if(order == 12) {
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[11] * (FLAC__int64)data[i-12];
- sum += qlp_coeff[10] * (FLAC__int64)data[i-11];
- sum += qlp_coeff[9] * (FLAC__int64)data[i-10];
- sum += qlp_coeff[8] * (FLAC__int64)data[i-9];
- sum += qlp_coeff[7] * (FLAC__int64)data[i-8];
- sum += qlp_coeff[6] * (FLAC__int64)data[i-7];
- sum += qlp_coeff[5] * (FLAC__int64)data[i-6];
- sum += qlp_coeff[4] * (FLAC__int64)data[i-5];
- sum += qlp_coeff[3] * (FLAC__int64)data[i-4];
- sum += qlp_coeff[2] * (FLAC__int64)data[i-3];
- sum += qlp_coeff[1] * (FLAC__int64)data[i-2];
- sum += qlp_coeff[0] * (FLAC__int64)data[i-1];
- residual[i] = data[i] - (FLAC__int32)(sum >> lp_quantization);
- }
- }
- else { /* order == 11 */
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[10] * (FLAC__int64)data[i-11];
- sum += qlp_coeff[9] * (FLAC__int64)data[i-10];
- sum += qlp_coeff[8] * (FLAC__int64)data[i-9];
- sum += qlp_coeff[7] * (FLAC__int64)data[i-8];
- sum += qlp_coeff[6] * (FLAC__int64)data[i-7];
- sum += qlp_coeff[5] * (FLAC__int64)data[i-6];
- sum += qlp_coeff[4] * (FLAC__int64)data[i-5];
- sum += qlp_coeff[3] * (FLAC__int64)data[i-4];
- sum += qlp_coeff[2] * (FLAC__int64)data[i-3];
- sum += qlp_coeff[1] * (FLAC__int64)data[i-2];
- sum += qlp_coeff[0] * (FLAC__int64)data[i-1];
- residual[i] = data[i] - (FLAC__int32)(sum >> lp_quantization);
- }
- }
- }
- else {
- if(order == 10) {
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[9] * (FLAC__int64)data[i-10];
- sum += qlp_coeff[8] * (FLAC__int64)data[i-9];
- sum += qlp_coeff[7] * (FLAC__int64)data[i-8];
- sum += qlp_coeff[6] * (FLAC__int64)data[i-7];
- sum += qlp_coeff[5] * (FLAC__int64)data[i-6];
- sum += qlp_coeff[4] * (FLAC__int64)data[i-5];
- sum += qlp_coeff[3] * (FLAC__int64)data[i-4];
- sum += qlp_coeff[2] * (FLAC__int64)data[i-3];
- sum += qlp_coeff[1] * (FLAC__int64)data[i-2];
- sum += qlp_coeff[0] * (FLAC__int64)data[i-1];
- residual[i] = data[i] - (FLAC__int32)(sum >> lp_quantization);
- }
- }
- else { /* order == 9 */
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[8] * (FLAC__int64)data[i-9];
- sum += qlp_coeff[7] * (FLAC__int64)data[i-8];
- sum += qlp_coeff[6] * (FLAC__int64)data[i-7];
- sum += qlp_coeff[5] * (FLAC__int64)data[i-6];
- sum += qlp_coeff[4] * (FLAC__int64)data[i-5];
- sum += qlp_coeff[3] * (FLAC__int64)data[i-4];
- sum += qlp_coeff[2] * (FLAC__int64)data[i-3];
- sum += qlp_coeff[1] * (FLAC__int64)data[i-2];
- sum += qlp_coeff[0] * (FLAC__int64)data[i-1];
- residual[i] = data[i] - (FLAC__int32)(sum >> lp_quantization);
- }
- }
- }
- }
- else if(order > 4) {
- if(order > 6) {
- if(order == 8) {
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[7] * (FLAC__int64)data[i-8];
- sum += qlp_coeff[6] * (FLAC__int64)data[i-7];
- sum += qlp_coeff[5] * (FLAC__int64)data[i-6];
- sum += qlp_coeff[4] * (FLAC__int64)data[i-5];
- sum += qlp_coeff[3] * (FLAC__int64)data[i-4];
- sum += qlp_coeff[2] * (FLAC__int64)data[i-3];
- sum += qlp_coeff[1] * (FLAC__int64)data[i-2];
- sum += qlp_coeff[0] * (FLAC__int64)data[i-1];
- residual[i] = data[i] - (FLAC__int32)(sum >> lp_quantization);
- }
- }
- else { /* order == 7 */
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[6] * (FLAC__int64)data[i-7];
- sum += qlp_coeff[5] * (FLAC__int64)data[i-6];
- sum += qlp_coeff[4] * (FLAC__int64)data[i-5];
- sum += qlp_coeff[3] * (FLAC__int64)data[i-4];
- sum += qlp_coeff[2] * (FLAC__int64)data[i-3];
- sum += qlp_coeff[1] * (FLAC__int64)data[i-2];
- sum += qlp_coeff[0] * (FLAC__int64)data[i-1];
- residual[i] = data[i] - (FLAC__int32)(sum >> lp_quantization);
- }
- }
- }
- else {
- if(order == 6) {
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[5] * (FLAC__int64)data[i-6];
- sum += qlp_coeff[4] * (FLAC__int64)data[i-5];
- sum += qlp_coeff[3] * (FLAC__int64)data[i-4];
- sum += qlp_coeff[2] * (FLAC__int64)data[i-3];
- sum += qlp_coeff[1] * (FLAC__int64)data[i-2];
- sum += qlp_coeff[0] * (FLAC__int64)data[i-1];
- residual[i] = data[i] - (FLAC__int32)(sum >> lp_quantization);
- }
- }
- else { /* order == 5 */
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[4] * (FLAC__int64)data[i-5];
- sum += qlp_coeff[3] * (FLAC__int64)data[i-4];
- sum += qlp_coeff[2] * (FLAC__int64)data[i-3];
- sum += qlp_coeff[1] * (FLAC__int64)data[i-2];
- sum += qlp_coeff[0] * (FLAC__int64)data[i-1];
- residual[i] = data[i] - (FLAC__int32)(sum >> lp_quantization);
- }
- }
- }
- }
- else {
- if(order > 2) {
- if(order == 4) {
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[3] * (FLAC__int64)data[i-4];
- sum += qlp_coeff[2] * (FLAC__int64)data[i-3];
- sum += qlp_coeff[1] * (FLAC__int64)data[i-2];
- sum += qlp_coeff[0] * (FLAC__int64)data[i-1];
- residual[i] = data[i] - (FLAC__int32)(sum >> lp_quantization);
- }
- }
- else { /* order == 3 */
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[2] * (FLAC__int64)data[i-3];
- sum += qlp_coeff[1] * (FLAC__int64)data[i-2];
- sum += qlp_coeff[0] * (FLAC__int64)data[i-1];
- residual[i] = data[i] - (FLAC__int32)(sum >> lp_quantization);
- }
- }
- }
- else {
- if(order == 2) {
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[1] * (FLAC__int64)data[i-2];
- sum += qlp_coeff[0] * (FLAC__int64)data[i-1];
- residual[i] = data[i] - (FLAC__int32)(sum >> lp_quantization);
- }
- }
- else { /* order == 1 */
- for(i = 0; i < (int)data_len; i++)
- residual[i] = data[i] - (FLAC__int32)((qlp_coeff[0] * (FLAC__int64)data[i-1]) >> lp_quantization);
- }
- }
- }
- }
- else { /* order > 12 */
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- switch(order) {
- case 32: sum += qlp_coeff[31] * (FLAC__int64)data[i-32];
- case 31: sum += qlp_coeff[30] * (FLAC__int64)data[i-31];
- case 30: sum += qlp_coeff[29] * (FLAC__int64)data[i-30];
- case 29: sum += qlp_coeff[28] * (FLAC__int64)data[i-29];
- case 28: sum += qlp_coeff[27] * (FLAC__int64)data[i-28];
- case 27: sum += qlp_coeff[26] * (FLAC__int64)data[i-27];
- case 26: sum += qlp_coeff[25] * (FLAC__int64)data[i-26];
- case 25: sum += qlp_coeff[24] * (FLAC__int64)data[i-25];
- case 24: sum += qlp_coeff[23] * (FLAC__int64)data[i-24];
- case 23: sum += qlp_coeff[22] * (FLAC__int64)data[i-23];
- case 22: sum += qlp_coeff[21] * (FLAC__int64)data[i-22];
- case 21: sum += qlp_coeff[20] * (FLAC__int64)data[i-21];
- case 20: sum += qlp_coeff[19] * (FLAC__int64)data[i-20];
- case 19: sum += qlp_coeff[18] * (FLAC__int64)data[i-19];
- case 18: sum += qlp_coeff[17] * (FLAC__int64)data[i-18];
- case 17: sum += qlp_coeff[16] * (FLAC__int64)data[i-17];
- case 16: sum += qlp_coeff[15] * (FLAC__int64)data[i-16];
- case 15: sum += qlp_coeff[14] * (FLAC__int64)data[i-15];
- case 14: sum += qlp_coeff[13] * (FLAC__int64)data[i-14];
- case 13: sum += qlp_coeff[12] * (FLAC__int64)data[i-13];
- sum += qlp_coeff[11] * (FLAC__int64)data[i-12];
- sum += qlp_coeff[10] * (FLAC__int64)data[i-11];
- sum += qlp_coeff[ 9] * (FLAC__int64)data[i-10];
- sum += qlp_coeff[ 8] * (FLAC__int64)data[i- 9];
- sum += qlp_coeff[ 7] * (FLAC__int64)data[i- 8];
- sum += qlp_coeff[ 6] * (FLAC__int64)data[i- 7];
- sum += qlp_coeff[ 5] * (FLAC__int64)data[i- 6];
- sum += qlp_coeff[ 4] * (FLAC__int64)data[i- 5];
- sum += qlp_coeff[ 3] * (FLAC__int64)data[i- 4];
- sum += qlp_coeff[ 2] * (FLAC__int64)data[i- 3];
- sum += qlp_coeff[ 1] * (FLAC__int64)data[i- 2];
- sum += qlp_coeff[ 0] * (FLAC__int64)data[i- 1];
- }
- residual[i] = data[i] - (FLAC__int32)(sum >> lp_quantization);
- }
- }
-}
-#endif
-
-#endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */
-
-void FLAC__lpc_restore_signal(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[])
-#if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPS)
-{
- FLAC__int64 sumo;
- unsigned i, j;
- FLAC__int32 sum;
- const FLAC__int32 *r = residual, *history;
-
-#ifdef FLAC__OVERFLOW_DETECT_VERBOSE
- fprintf(stderr,"FLAC__lpc_restore_signal: data_len=%d, order=%u, lpq=%d",data_len,order,lp_quantization);
- for(i=0;i<order;i++)
- fprintf(stderr,", q[%u]=%d",i,qlp_coeff[i]);
- fprintf(stderr,"\n");
-#endif
- FLAC__ASSERT(order > 0);
-
- for(i = 0; i < data_len; i++) {
- sumo = 0;
- sum = 0;
- history = data;
- for(j = 0; j < order; j++) {
- sum += qlp_coeff[j] * (*(--history));
- sumo += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*history);
-#if defined _MSC_VER
- if(sumo > 2147483647I64 || sumo < -2147483648I64)
- fprintf(stderr,"FLAC__lpc_restore_signal: OVERFLOW, i=%u, j=%u, c=%d, d=%d, sumo=%I64d\n",i,j,qlp_coeff[j],*history,sumo);
-#else
- if(sumo > 2147483647ll || sumo < -2147483648ll)
- fprintf(stderr,"FLAC__lpc_restore_signal: OVERFLOW, i=%u, j=%u, c=%d, d=%d, sumo=%lld\n",i,j,qlp_coeff[j],*history,(long long)sumo);
-#endif
- }
- *(data++) = *(r++) + (sum >> lp_quantization);
- }
-
- /* Here's a slower but clearer version:
- for(i = 0; i < data_len; i++) {
- sum = 0;
- for(j = 0; j < order; j++)
- sum += qlp_coeff[j] * data[i-j-1];
- data[i] = residual[i] + (sum >> lp_quantization);
- }
- */
-}
-#else /* fully unrolled version for normal use */
-{
- int i;
- FLAC__int32 sum;
-
- FLAC__ASSERT(order > 0);
- FLAC__ASSERT(order <= 32);
-
- /*
- * We do unique versions up to 12th order since that's the subset limit.
- * Also they are roughly ordered to match frequency of occurrence to
- * minimize branching.
- */
- if(order <= 12) {
- if(order > 8) {
- if(order > 10) {
- if(order == 12) {
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[11] * data[i-12];
- sum += qlp_coeff[10] * data[i-11];
- sum += qlp_coeff[9] * data[i-10];
- sum += qlp_coeff[8] * data[i-9];
- sum += qlp_coeff[7] * data[i-8];
- sum += qlp_coeff[6] * data[i-7];
- sum += qlp_coeff[5] * data[i-6];
- sum += qlp_coeff[4] * data[i-5];
- sum += qlp_coeff[3] * data[i-4];
- sum += qlp_coeff[2] * data[i-3];
- sum += qlp_coeff[1] * data[i-2];
- sum += qlp_coeff[0] * data[i-1];
- data[i] = residual[i] + (sum >> lp_quantization);
- }
- }
- else { /* order == 11 */
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[10] * data[i-11];
- sum += qlp_coeff[9] * data[i-10];
- sum += qlp_coeff[8] * data[i-9];
- sum += qlp_coeff[7] * data[i-8];
- sum += qlp_coeff[6] * data[i-7];
- sum += qlp_coeff[5] * data[i-6];
- sum += qlp_coeff[4] * data[i-5];
- sum += qlp_coeff[3] * data[i-4];
- sum += qlp_coeff[2] * data[i-3];
- sum += qlp_coeff[1] * data[i-2];
- sum += qlp_coeff[0] * data[i-1];
- data[i] = residual[i] + (sum >> lp_quantization);
- }
- }
- }
- else {
- if(order == 10) {
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[9] * data[i-10];
- sum += qlp_coeff[8] * data[i-9];
- sum += qlp_coeff[7] * data[i-8];
- sum += qlp_coeff[6] * data[i-7];
- sum += qlp_coeff[5] * data[i-6];
- sum += qlp_coeff[4] * data[i-5];
- sum += qlp_coeff[3] * data[i-4];
- sum += qlp_coeff[2] * data[i-3];
- sum += qlp_coeff[1] * data[i-2];
- sum += qlp_coeff[0] * data[i-1];
- data[i] = residual[i] + (sum >> lp_quantization);
- }
- }
- else { /* order == 9 */
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[8] * data[i-9];
- sum += qlp_coeff[7] * data[i-8];
- sum += qlp_coeff[6] * data[i-7];
- sum += qlp_coeff[5] * data[i-6];
- sum += qlp_coeff[4] * data[i-5];
- sum += qlp_coeff[3] * data[i-4];
- sum += qlp_coeff[2] * data[i-3];
- sum += qlp_coeff[1] * data[i-2];
- sum += qlp_coeff[0] * data[i-1];
- data[i] = residual[i] + (sum >> lp_quantization);
- }
- }
- }
- }
- else if(order > 4) {
- if(order > 6) {
- if(order == 8) {
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[7] * data[i-8];
- sum += qlp_coeff[6] * data[i-7];
- sum += qlp_coeff[5] * data[i-6];
- sum += qlp_coeff[4] * data[i-5];
- sum += qlp_coeff[3] * data[i-4];
- sum += qlp_coeff[2] * data[i-3];
- sum += qlp_coeff[1] * data[i-2];
- sum += qlp_coeff[0] * data[i-1];
- data[i] = residual[i] + (sum >> lp_quantization);
- }
- }
- else { /* order == 7 */
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[6] * data[i-7];
- sum += qlp_coeff[5] * data[i-6];
- sum += qlp_coeff[4] * data[i-5];
- sum += qlp_coeff[3] * data[i-4];
- sum += qlp_coeff[2] * data[i-3];
- sum += qlp_coeff[1] * data[i-2];
- sum += qlp_coeff[0] * data[i-1];
- data[i] = residual[i] + (sum >> lp_quantization);
- }
- }
- }
- else {
- if(order == 6) {
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[5] * data[i-6];
- sum += qlp_coeff[4] * data[i-5];
- sum += qlp_coeff[3] * data[i-4];
- sum += qlp_coeff[2] * data[i-3];
- sum += qlp_coeff[1] * data[i-2];
- sum += qlp_coeff[0] * data[i-1];
- data[i] = residual[i] + (sum >> lp_quantization);
- }
- }
- else { /* order == 5 */
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[4] * data[i-5];
- sum += qlp_coeff[3] * data[i-4];
- sum += qlp_coeff[2] * data[i-3];
- sum += qlp_coeff[1] * data[i-2];
- sum += qlp_coeff[0] * data[i-1];
- data[i] = residual[i] + (sum >> lp_quantization);
- }
- }
- }
- }
- else {
- if(order > 2) {
- if(order == 4) {
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[3] * data[i-4];
- sum += qlp_coeff[2] * data[i-3];
- sum += qlp_coeff[1] * data[i-2];
- sum += qlp_coeff[0] * data[i-1];
- data[i] = residual[i] + (sum >> lp_quantization);
- }
- }
- else { /* order == 3 */
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[2] * data[i-3];
- sum += qlp_coeff[1] * data[i-2];
- sum += qlp_coeff[0] * data[i-1];
- data[i] = residual[i] + (sum >> lp_quantization);
- }
- }
- }
- else {
- if(order == 2) {
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[1] * data[i-2];
- sum += qlp_coeff[0] * data[i-1];
- data[i] = residual[i] + (sum >> lp_quantization);
- }
- }
- else { /* order == 1 */
- for(i = 0; i < (int)data_len; i++)
- data[i] = residual[i] + ((qlp_coeff[0] * data[i-1]) >> lp_quantization);
- }
- }
- }
- }
- else { /* order > 12 */
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- switch(order) {
- case 32: sum += qlp_coeff[31] * data[i-32];
- case 31: sum += qlp_coeff[30] * data[i-31];
- case 30: sum += qlp_coeff[29] * data[i-30];
- case 29: sum += qlp_coeff[28] * data[i-29];
- case 28: sum += qlp_coeff[27] * data[i-28];
- case 27: sum += qlp_coeff[26] * data[i-27];
- case 26: sum += qlp_coeff[25] * data[i-26];
- case 25: sum += qlp_coeff[24] * data[i-25];
- case 24: sum += qlp_coeff[23] * data[i-24];
- case 23: sum += qlp_coeff[22] * data[i-23];
- case 22: sum += qlp_coeff[21] * data[i-22];
- case 21: sum += qlp_coeff[20] * data[i-21];
- case 20: sum += qlp_coeff[19] * data[i-20];
- case 19: sum += qlp_coeff[18] * data[i-19];
- case 18: sum += qlp_coeff[17] * data[i-18];
- case 17: sum += qlp_coeff[16] * data[i-17];
- case 16: sum += qlp_coeff[15] * data[i-16];
- case 15: sum += qlp_coeff[14] * data[i-15];
- case 14: sum += qlp_coeff[13] * data[i-14];
- case 13: sum += qlp_coeff[12] * data[i-13];
- sum += qlp_coeff[11] * data[i-12];
- sum += qlp_coeff[10] * data[i-11];
- sum += qlp_coeff[ 9] * data[i-10];
- sum += qlp_coeff[ 8] * data[i- 9];
- sum += qlp_coeff[ 7] * data[i- 8];
- sum += qlp_coeff[ 6] * data[i- 7];
- sum += qlp_coeff[ 5] * data[i- 6];
- sum += qlp_coeff[ 4] * data[i- 5];
- sum += qlp_coeff[ 3] * data[i- 4];
- sum += qlp_coeff[ 2] * data[i- 3];
- sum += qlp_coeff[ 1] * data[i- 2];
- sum += qlp_coeff[ 0] * data[i- 1];
- }
- data[i] = residual[i] + (sum >> lp_quantization);
- }
- }
-}
-#endif
-
-void FLAC__lpc_restore_signal_wide(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[])
-#if defined(FLAC__OVERFLOW_DETECT) || !defined(FLAC__LPC_UNROLLED_FILTER_LOOPS)
-{
- unsigned i, j;
- FLAC__int64 sum;
- const FLAC__int32 *r = residual, *history;
-
-#ifdef FLAC__OVERFLOW_DETECT_VERBOSE
- fprintf(stderr,"FLAC__lpc_restore_signal_wide: data_len=%d, order=%u, lpq=%d",data_len,order,lp_quantization);
- for(i=0;i<order;i++)
- fprintf(stderr,", q[%u]=%d",i,qlp_coeff[i]);
- fprintf(stderr,"\n");
-#endif
- FLAC__ASSERT(order > 0);
-
- for(i = 0; i < data_len; i++) {
- sum = 0;
- history = data;
- for(j = 0; j < order; j++)
- sum += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*(--history));
- if(FLAC__bitmath_silog2_wide(sum >> lp_quantization) > 32) {
-#ifdef _MSC_VER
- fprintf(stderr,"FLAC__lpc_restore_signal_wide: OVERFLOW, i=%u, sum=%I64d\n", i, sum >> lp_quantization);
-#else
- fprintf(stderr,"FLAC__lpc_restore_signal_wide: OVERFLOW, i=%u, sum=%lld\n", i, (long long)(sum >> lp_quantization));
-#endif
- break;
- }
- if(FLAC__bitmath_silog2_wide((FLAC__int64)(*r) + (sum >> lp_quantization)) > 32) {
-#ifdef _MSC_VER
- fprintf(stderr,"FLAC__lpc_restore_signal_wide: OVERFLOW, i=%u, residual=%d, sum=%I64d, data=%I64d\n", i, *r, sum >> lp_quantization, (FLAC__int64)(*r) + (sum >> lp_quantization));
-#else
- fprintf(stderr,"FLAC__lpc_restore_signal_wide: OVERFLOW, i=%u, residual=%d, sum=%lld, data=%lld\n", i, *r, (long long)(sum >> lp_quantization), (long long)((FLAC__int64)(*r) + (sum >> lp_quantization)));
-#endif
- break;
- }
- *(data++) = *(r++) + (FLAC__int32)(sum >> lp_quantization);
- }
-}
-#else /* fully unrolled version for normal use */
-{
- int i;
- FLAC__int64 sum;
-
- FLAC__ASSERT(order > 0);
- FLAC__ASSERT(order <= 32);
-
- /*
- * We do unique versions up to 12th order since that's the subset limit.
- * Also they are roughly ordered to match frequency of occurrence to
- * minimize branching.
- */
- if(order <= 12) {
- if(order > 8) {
- if(order > 10) {
- if(order == 12) {
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[11] * (FLAC__int64)data[i-12];
- sum += qlp_coeff[10] * (FLAC__int64)data[i-11];
- sum += qlp_coeff[9] * (FLAC__int64)data[i-10];
- sum += qlp_coeff[8] * (FLAC__int64)data[i-9];
- sum += qlp_coeff[7] * (FLAC__int64)data[i-8];
- sum += qlp_coeff[6] * (FLAC__int64)data[i-7];
- sum += qlp_coeff[5] * (FLAC__int64)data[i-6];
- sum += qlp_coeff[4] * (FLAC__int64)data[i-5];
- sum += qlp_coeff[3] * (FLAC__int64)data[i-4];
- sum += qlp_coeff[2] * (FLAC__int64)data[i-3];
- sum += qlp_coeff[1] * (FLAC__int64)data[i-2];
- sum += qlp_coeff[0] * (FLAC__int64)data[i-1];
- data[i] = residual[i] + (FLAC__int32)(sum >> lp_quantization);
- }
- }
- else { /* order == 11 */
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[10] * (FLAC__int64)data[i-11];
- sum += qlp_coeff[9] * (FLAC__int64)data[i-10];
- sum += qlp_coeff[8] * (FLAC__int64)data[i-9];
- sum += qlp_coeff[7] * (FLAC__int64)data[i-8];
- sum += qlp_coeff[6] * (FLAC__int64)data[i-7];
- sum += qlp_coeff[5] * (FLAC__int64)data[i-6];
- sum += qlp_coeff[4] * (FLAC__int64)data[i-5];
- sum += qlp_coeff[3] * (FLAC__int64)data[i-4];
- sum += qlp_coeff[2] * (FLAC__int64)data[i-3];
- sum += qlp_coeff[1] * (FLAC__int64)data[i-2];
- sum += qlp_coeff[0] * (FLAC__int64)data[i-1];
- data[i] = residual[i] + (FLAC__int32)(sum >> lp_quantization);
- }
- }
- }
- else {
- if(order == 10) {
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[9] * (FLAC__int64)data[i-10];
- sum += qlp_coeff[8] * (FLAC__int64)data[i-9];
- sum += qlp_coeff[7] * (FLAC__int64)data[i-8];
- sum += qlp_coeff[6] * (FLAC__int64)data[i-7];
- sum += qlp_coeff[5] * (FLAC__int64)data[i-6];
- sum += qlp_coeff[4] * (FLAC__int64)data[i-5];
- sum += qlp_coeff[3] * (FLAC__int64)data[i-4];
- sum += qlp_coeff[2] * (FLAC__int64)data[i-3];
- sum += qlp_coeff[1] * (FLAC__int64)data[i-2];
- sum += qlp_coeff[0] * (FLAC__int64)data[i-1];
- data[i] = residual[i] + (FLAC__int32)(sum >> lp_quantization);
- }
- }
- else { /* order == 9 */
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[8] * (FLAC__int64)data[i-9];
- sum += qlp_coeff[7] * (FLAC__int64)data[i-8];
- sum += qlp_coeff[6] * (FLAC__int64)data[i-7];
- sum += qlp_coeff[5] * (FLAC__int64)data[i-6];
- sum += qlp_coeff[4] * (FLAC__int64)data[i-5];
- sum += qlp_coeff[3] * (FLAC__int64)data[i-4];
- sum += qlp_coeff[2] * (FLAC__int64)data[i-3];
- sum += qlp_coeff[1] * (FLAC__int64)data[i-2];
- sum += qlp_coeff[0] * (FLAC__int64)data[i-1];
- data[i] = residual[i] + (FLAC__int32)(sum >> lp_quantization);
- }
- }
- }
- }
- else if(order > 4) {
- if(order > 6) {
- if(order == 8) {
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[7] * (FLAC__int64)data[i-8];
- sum += qlp_coeff[6] * (FLAC__int64)data[i-7];
- sum += qlp_coeff[5] * (FLAC__int64)data[i-6];
- sum += qlp_coeff[4] * (FLAC__int64)data[i-5];
- sum += qlp_coeff[3] * (FLAC__int64)data[i-4];
- sum += qlp_coeff[2] * (FLAC__int64)data[i-3];
- sum += qlp_coeff[1] * (FLAC__int64)data[i-2];
- sum += qlp_coeff[0] * (FLAC__int64)data[i-1];
- data[i] = residual[i] + (FLAC__int32)(sum >> lp_quantization);
- }
- }
- else { /* order == 7 */
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[6] * (FLAC__int64)data[i-7];
- sum += qlp_coeff[5] * (FLAC__int64)data[i-6];
- sum += qlp_coeff[4] * (FLAC__int64)data[i-5];
- sum += qlp_coeff[3] * (FLAC__int64)data[i-4];
- sum += qlp_coeff[2] * (FLAC__int64)data[i-3];
- sum += qlp_coeff[1] * (FLAC__int64)data[i-2];
- sum += qlp_coeff[0] * (FLAC__int64)data[i-1];
- data[i] = residual[i] + (FLAC__int32)(sum >> lp_quantization);
- }
- }
- }
- else {
- if(order == 6) {
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[5] * (FLAC__int64)data[i-6];
- sum += qlp_coeff[4] * (FLAC__int64)data[i-5];
- sum += qlp_coeff[3] * (FLAC__int64)data[i-4];
- sum += qlp_coeff[2] * (FLAC__int64)data[i-3];
- sum += qlp_coeff[1] * (FLAC__int64)data[i-2];
- sum += qlp_coeff[0] * (FLAC__int64)data[i-1];
- data[i] = residual[i] + (FLAC__int32)(sum >> lp_quantization);
- }
- }
- else { /* order == 5 */
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[4] * (FLAC__int64)data[i-5];
- sum += qlp_coeff[3] * (FLAC__int64)data[i-4];
- sum += qlp_coeff[2] * (FLAC__int64)data[i-3];
- sum += qlp_coeff[1] * (FLAC__int64)data[i-2];
- sum += qlp_coeff[0] * (FLAC__int64)data[i-1];
- data[i] = residual[i] + (FLAC__int32)(sum >> lp_quantization);
- }
- }
- }
- }
- else {
- if(order > 2) {
- if(order == 4) {
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[3] * (FLAC__int64)data[i-4];
- sum += qlp_coeff[2] * (FLAC__int64)data[i-3];
- sum += qlp_coeff[1] * (FLAC__int64)data[i-2];
- sum += qlp_coeff[0] * (FLAC__int64)data[i-1];
- data[i] = residual[i] + (FLAC__int32)(sum >> lp_quantization);
- }
- }
- else { /* order == 3 */
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[2] * (FLAC__int64)data[i-3];
- sum += qlp_coeff[1] * (FLAC__int64)data[i-2];
- sum += qlp_coeff[0] * (FLAC__int64)data[i-1];
- data[i] = residual[i] + (FLAC__int32)(sum >> lp_quantization);
- }
- }
- }
- else {
- if(order == 2) {
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- sum += qlp_coeff[1] * (FLAC__int64)data[i-2];
- sum += qlp_coeff[0] * (FLAC__int64)data[i-1];
- data[i] = residual[i] + (FLAC__int32)(sum >> lp_quantization);
- }
- }
- else { /* order == 1 */
- for(i = 0; i < (int)data_len; i++)
- data[i] = residual[i] + (FLAC__int32)((qlp_coeff[0] * (FLAC__int64)data[i-1]) >> lp_quantization);
- }
- }
- }
- }
- else { /* order > 12 */
- for(i = 0; i < (int)data_len; i++) {
- sum = 0;
- switch(order) {
- case 32: sum += qlp_coeff[31] * (FLAC__int64)data[i-32];
- case 31: sum += qlp_coeff[30] * (FLAC__int64)data[i-31];
- case 30: sum += qlp_coeff[29] * (FLAC__int64)data[i-30];
- case 29: sum += qlp_coeff[28] * (FLAC__int64)data[i-29];
- case 28: sum += qlp_coeff[27] * (FLAC__int64)data[i-28];
- case 27: sum += qlp_coeff[26] * (FLAC__int64)data[i-27];
- case 26: sum += qlp_coeff[25] * (FLAC__int64)data[i-26];
- case 25: sum += qlp_coeff[24] * (FLAC__int64)data[i-25];
- case 24: sum += qlp_coeff[23] * (FLAC__int64)data[i-24];
- case 23: sum += qlp_coeff[22] * (FLAC__int64)data[i-23];
- case 22: sum += qlp_coeff[21] * (FLAC__int64)data[i-22];
- case 21: sum += qlp_coeff[20] * (FLAC__int64)data[i-21];
- case 20: sum += qlp_coeff[19] * (FLAC__int64)data[i-20];
- case 19: sum += qlp_coeff[18] * (FLAC__int64)data[i-19];
- case 18: sum += qlp_coeff[17] * (FLAC__int64)data[i-18];
- case 17: sum += qlp_coeff[16] * (FLAC__int64)data[i-17];
- case 16: sum += qlp_coeff[15] * (FLAC__int64)data[i-16];
- case 15: sum += qlp_coeff[14] * (FLAC__int64)data[i-15];
- case 14: sum += qlp_coeff[13] * (FLAC__int64)data[i-14];
- case 13: sum += qlp_coeff[12] * (FLAC__int64)data[i-13];
- sum += qlp_coeff[11] * (FLAC__int64)data[i-12];
- sum += qlp_coeff[10] * (FLAC__int64)data[i-11];
- sum += qlp_coeff[ 9] * (FLAC__int64)data[i-10];
- sum += qlp_coeff[ 8] * (FLAC__int64)data[i- 9];
- sum += qlp_coeff[ 7] * (FLAC__int64)data[i- 8];
- sum += qlp_coeff[ 6] * (FLAC__int64)data[i- 7];
- sum += qlp_coeff[ 5] * (FLAC__int64)data[i- 6];
- sum += qlp_coeff[ 4] * (FLAC__int64)data[i- 5];
- sum += qlp_coeff[ 3] * (FLAC__int64)data[i- 4];
- sum += qlp_coeff[ 2] * (FLAC__int64)data[i- 3];
- sum += qlp_coeff[ 1] * (FLAC__int64)data[i- 2];
- sum += qlp_coeff[ 0] * (FLAC__int64)data[i- 1];
- }
- data[i] = residual[i] + (FLAC__int32)(sum >> lp_quantization);
- }
- }
-}
-#endif
-
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
-
-FLAC__double FLAC__lpc_compute_expected_bits_per_residual_sample(FLAC__double lpc_error, unsigned total_samples)
-{
- FLAC__double error_scale;
-
- FLAC__ASSERT(total_samples > 0);
-
- error_scale = 0.5 * M_LN2 * M_LN2 / (FLAC__double)total_samples;
-
- return FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(lpc_error, error_scale);
-}
-
-FLAC__double FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(FLAC__double lpc_error, FLAC__double error_scale)
-{
- if(lpc_error > 0.0) {
- FLAC__double bps = (FLAC__double)0.5 * log(error_scale * lpc_error) / M_LN2;
- if(bps >= 0.0)
- return bps;
- else
- return 0.0;
- }
- else if(lpc_error < 0.0) { /* error should not be negative but can happen due to inadequate floating-point resolution */
- return 1e32;
- }
- else {
- return 0.0;
- }
-}
-
-unsigned FLAC__lpc_compute_best_order(const FLAC__double lpc_error[], unsigned max_order, unsigned total_samples, unsigned overhead_bits_per_order)
-{
- unsigned order, index, best_index; /* 'index' the index into lpc_error; index==order-1 since lpc_error[0] is for order==1, lpc_error[1] is for order==2, etc */
- FLAC__double bits, best_bits, error_scale;
-
- FLAC__ASSERT(max_order > 0);
- FLAC__ASSERT(total_samples > 0);
-
- error_scale = 0.5 * M_LN2 * M_LN2 / (FLAC__double)total_samples;
-
- best_index = 0;
- best_bits = (unsigned)(-1);
-
- for(index = 0, order = 1; index < max_order; index++, order++) {
- bits = FLAC__lpc_compute_expected_bits_per_residual_sample_with_error_scale(lpc_error[index], error_scale) * (FLAC__double)(total_samples - order) + (FLAC__double)(order * overhead_bits_per_order);
- if(bits < best_bits) {
- best_index = index;
- best_bits = bits;
- }
- }
-
- return best_index+1; /* +1 since index of lpc_error[] is order-1 */
-}
-
-#endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */
diff --git a/src/thirdparty/libflac/src/libFLAC/md5.c b/src/thirdparty/libflac/src/libFLAC/md5.c
deleted file mode 100644
index 4fe3cc0ee..000000000
--- a/src/thirdparty/libflac/src/libFLAC/md5.c
+++ /dev/null
@@ -1,420 +0,0 @@
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdlib.h> /* for malloc() */
-#include <string.h> /* for memcpy() */
-
-#include "private/md5.h"
-#include "share/alloc.h"
-
-/*
- * This code implements the MD5 message-digest algorithm.
- * The algorithm is due to Ron Rivest. This code was
- * written by Colin Plumb in 1993, no copyright is claimed.
- * This code is in the public domain; do with it what you wish.
- *
- * Equivalent code is available from RSA Data Security, Inc.
- * This code has been tested against that, and is equivalent,
- * except that you don't need to include two pages of legalese
- * with every copy.
- *
- * To compute the message digest of a chunk of bytes, declare an
- * MD5Context structure, pass it to MD5Init, call MD5Update as
- * needed on buffers full of bytes, and then call MD5Final, which
- * will fill a supplied 16-byte array with the digest.
- *
- * Changed so as no longer to depend on Colin Plumb's `usual.h' header
- * definitions; now uses stuff from dpkg's config.h.
- * - Ian Jackson <ijackson@nyx.cs.du.edu>.
- * Still in the public domain.
- *
- * Josh Coalson: made some changes to integrate with libFLAC.
- * Still in the public domain.
- */
-
-/* The four core functions - F1 is optimized somewhat */
-
-/* #define F1(x, y, z) (x & y | ~x & z) */
-#define F1(x, y, z) (z ^ (x & (y ^ z)))
-#define F2(x, y, z) F1(z, x, y)
-#define F3(x, y, z) (x ^ y ^ z)
-#define F4(x, y, z) (y ^ (x | ~z))
-
-/* This is the central step in the MD5 algorithm. */
-#define MD5STEP(f,w,x,y,z,in,s) \
- (w += f(x,y,z) + in, w = (w<<s | w>>(32-s)) + x)
-
-/*
- * The core of the MD5 algorithm, this alters an existing MD5 hash to
- * reflect the addition of 16 longwords of new data. MD5Update blocks
- * the data and converts bytes into longwords for this routine.
- */
-static void FLAC__MD5Transform(FLAC__uint32 buf[4], FLAC__uint32 const in[16])
-{
- register FLAC__uint32 a, b, c, d;
-
- a = buf[0];
- b = buf[1];
- c = buf[2];
- d = buf[3];
-
- MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
- MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
- MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
- MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
- MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
- MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
- MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
- MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
- MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
- MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
- MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
- MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
- MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
- MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
- MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
- MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
-
- MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
- MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
- MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
- MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
- MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
- MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
- MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
- MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
- MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
- MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
- MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
- MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
- MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
- MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
- MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
- MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
-
- MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
- MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
- MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
- MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
- MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
- MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
- MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
- MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
- MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
- MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
- MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
- MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
- MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
- MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
- MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
- MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
-
- MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
- MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
- MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
- MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
- MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
- MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
- MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
- MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
- MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
- MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
- MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
- MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
- MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
- MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
- MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
- MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
-
- buf[0] += a;
- buf[1] += b;
- buf[2] += c;
- buf[3] += d;
-}
-
-#if WORDS_BIGENDIAN
-//@@@@@@ OPT: use bswap/intrinsics
-static void byteSwap(FLAC__uint32 *buf, unsigned words)
-{
- register FLAC__uint32 x;
- do {
- x = *buf;
- x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff);
- *buf++ = (x >> 16) | (x << 16);
- } while (--words);
-}
-static void byteSwapX16(FLAC__uint32 *buf)
-{
- register FLAC__uint32 x;
-
- x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
- x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
- x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
- x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
- x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
- x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
- x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
- x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
- x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
- x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
- x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
- x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
- x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
- x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
- x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf++ = (x >> 16) | (x << 16);
- x = *buf; x = ((x << 8) & 0xff00ff00) | ((x >> 8) & 0x00ff00ff); *buf = (x >> 16) | (x << 16);
-}
-#else
-#define byteSwap(buf, words)
-#define byteSwapX16(buf)
-#endif
-
-/*
- * Update context to reflect the concatenation of another buffer full
- * of bytes.
- */
-static void FLAC__MD5Update(FLAC__MD5Context *ctx, FLAC__byte const *buf, unsigned len)
-{
- FLAC__uint32 t;
-
- /* Update byte count */
-
- t = ctx->bytes[0];
- if ((ctx->bytes[0] = t + len) < t)
- ctx->bytes[1]++; /* Carry from low to high */
-
- t = 64 - (t & 0x3f); /* Space available in ctx->in (at least 1) */
- if (t > len) {
- memcpy((FLAC__byte *)ctx->in + 64 - t, buf, len);
- return;
- }
- /* First chunk is an odd size */
- memcpy((FLAC__byte *)ctx->in + 64 - t, buf, t);
- byteSwapX16(ctx->in);
- FLAC__MD5Transform(ctx->buf, ctx->in);
- buf += t;
- len -= t;
-
- /* Process data in 64-byte chunks */
- while (len >= 64) {
- memcpy(ctx->in, buf, 64);
- byteSwapX16(ctx->in);
- FLAC__MD5Transform(ctx->buf, ctx->in);
- buf += 64;
- len -= 64;
- }
-
- /* Handle any remaining bytes of data. */
- memcpy(ctx->in, buf, len);
-}
-
-/*
- * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
- * initialization constants.
- */
-void FLAC__MD5Init(FLAC__MD5Context *ctx)
-{
- ctx->buf[0] = 0x67452301;
- ctx->buf[1] = 0xefcdab89;
- ctx->buf[2] = 0x98badcfe;
- ctx->buf[3] = 0x10325476;
-
- ctx->bytes[0] = 0;
- ctx->bytes[1] = 0;
-
- ctx->internal_buf = 0;
- ctx->capacity = 0;
-}
-
-/*
- * Final wrapup - pad to 64-byte boundary with the bit pattern
- * 1 0* (64-bit count of bits processed, MSB-first)
- */
-void FLAC__MD5Final(FLAC__byte digest[16], FLAC__MD5Context *ctx)
-{
- int count = ctx->bytes[0] & 0x3f; /* Number of bytes in ctx->in */
- FLAC__byte *p = (FLAC__byte *)ctx->in + count;
-
- /* Set the first char of padding to 0x80. There is always room. */
- *p++ = 0x80;
-
- /* Bytes of padding needed to make 56 bytes (-8..55) */
- count = 56 - 1 - count;
-
- if (count < 0) { /* Padding forces an extra block */
- memset(p, 0, count + 8);
- byteSwapX16(ctx->in);
- FLAC__MD5Transform(ctx->buf, ctx->in);
- p = (FLAC__byte *)ctx->in;
- count = 56;
- }
- memset(p, 0, count);
- byteSwap(ctx->in, 14);
-
- /* Append length in bits and transform */
- ctx->in[14] = ctx->bytes[0] << 3;
- ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29;
- FLAC__MD5Transform(ctx->buf, ctx->in);
-
- byteSwap(ctx->buf, 4);
- memcpy(digest, ctx->buf, 16);
- memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
- if(0 != ctx->internal_buf) {
- free(ctx->internal_buf);
- ctx->internal_buf = 0;
- ctx->capacity = 0;
- }
-}
-
-/*
- * Convert the incoming audio signal to a byte stream
- */
-static void format_input_(FLAC__byte *buf, const FLAC__int32 * const signal[], unsigned channels, unsigned samples, unsigned bytes_per_sample)
-{
- unsigned channel, sample;
- register FLAC__int32 a_word;
- register FLAC__byte *buf_ = buf;
-
-#if WORDS_BIGENDIAN
-#else
- if(channels == 2 && bytes_per_sample == 2) {
- FLAC__int16 *buf1_ = ((FLAC__int16*)buf_) + 1;
- memcpy(buf_, signal[0], sizeof(FLAC__int32) * samples);
- for(sample = 0; sample < samples; sample++, buf1_+=2)
- *buf1_ = (FLAC__int16)signal[1][sample];
- }
- else if(channels == 1 && bytes_per_sample == 2) {
- FLAC__int16 *buf1_ = (FLAC__int16*)buf_;
- for(sample = 0; sample < samples; sample++)
- *buf1_++ = (FLAC__int16)signal[0][sample];
- }
- else
-#endif
- if(bytes_per_sample == 2) {
- if(channels == 2) {
- for(sample = 0; sample < samples; sample++) {
- a_word = signal[0][sample];
- *buf_++ = (FLAC__byte)a_word; a_word >>= 8;
- *buf_++ = (FLAC__byte)a_word;
- a_word = signal[1][sample];
- *buf_++ = (FLAC__byte)a_word; a_word >>= 8;
- *buf_++ = (FLAC__byte)a_word;
- }
- }
- else if(channels == 1) {
- for(sample = 0; sample < samples; sample++) {
- a_word = signal[0][sample];
- *buf_++ = (FLAC__byte)a_word; a_word >>= 8;
- *buf_++ = (FLAC__byte)a_word;
- }
- }
- else {
- for(sample = 0; sample < samples; sample++) {
- for(channel = 0; channel < channels; channel++) {
- a_word = signal[channel][sample];
- *buf_++ = (FLAC__byte)a_word; a_word >>= 8;
- *buf_++ = (FLAC__byte)a_word;
- }
- }
- }
- }
- else if(bytes_per_sample == 3) {
- if(channels == 2) {
- for(sample = 0; sample < samples; sample++) {
- a_word = signal[0][sample];
- *buf_++ = (FLAC__byte)a_word; a_word >>= 8;
- *buf_++ = (FLAC__byte)a_word; a_word >>= 8;
- *buf_++ = (FLAC__byte)a_word;
- a_word = signal[1][sample];
- *buf_++ = (FLAC__byte)a_word; a_word >>= 8;
- *buf_++ = (FLAC__byte)a_word; a_word >>= 8;
- *buf_++ = (FLAC__byte)a_word;
- }
- }
- else if(channels == 1) {
- for(sample = 0; sample < samples; sample++) {
- a_word = signal[0][sample];
- *buf_++ = (FLAC__byte)a_word; a_word >>= 8;
- *buf_++ = (FLAC__byte)a_word; a_word >>= 8;
- *buf_++ = (FLAC__byte)a_word;
- }
- }
- else {
- for(sample = 0; sample < samples; sample++) {
- for(channel = 0; channel < channels; channel++) {
- a_word = signal[channel][sample];
- *buf_++ = (FLAC__byte)a_word; a_word >>= 8;
- *buf_++ = (FLAC__byte)a_word; a_word >>= 8;
- *buf_++ = (FLAC__byte)a_word;
- }
- }
- }
- }
- else if(bytes_per_sample == 1) {
- if(channels == 2) {
- for(sample = 0; sample < samples; sample++) {
- a_word = signal[0][sample];
- *buf_++ = (FLAC__byte)a_word;
- a_word = signal[1][sample];
- *buf_++ = (FLAC__byte)a_word;
- }
- }
- else if(channels == 1) {
- for(sample = 0; sample < samples; sample++) {
- a_word = signal[0][sample];
- *buf_++ = (FLAC__byte)a_word;
- }
- }
- else {
- for(sample = 0; sample < samples; sample++) {
- for(channel = 0; channel < channels; channel++) {
- a_word = signal[channel][sample];
- *buf_++ = (FLAC__byte)a_word;
- }
- }
- }
- }
- else { /* bytes_per_sample == 4, maybe optimize more later */
- for(sample = 0; sample < samples; sample++) {
- for(channel = 0; channel < channels; channel++) {
- a_word = signal[channel][sample];
- *buf_++ = (FLAC__byte)a_word; a_word >>= 8;
- *buf_++ = (FLAC__byte)a_word; a_word >>= 8;
- *buf_++ = (FLAC__byte)a_word; a_word >>= 8;
- *buf_++ = (FLAC__byte)a_word;
- }
- }
- }
-}
-
-/*
- * Convert the incoming audio signal to a byte stream and FLAC__MD5Update it.
- */
-FLAC__bool FLAC__MD5Accumulate(FLAC__MD5Context *ctx, const FLAC__int32 * const signal[], unsigned channels, unsigned samples, unsigned bytes_per_sample)
-{
- const size_t bytes_needed = (size_t)channels * (size_t)samples * (size_t)bytes_per_sample;
-
- /* overflow check */
- if((size_t)channels > SIZE_MAX / (size_t)bytes_per_sample)
- return false;
- if((size_t)channels * (size_t)bytes_per_sample > SIZE_MAX / (size_t)samples)
- return false;
-
- if(ctx->capacity < bytes_needed) {
- FLAC__byte *tmp = (FLAC__byte*)realloc(ctx->internal_buf, bytes_needed);
- if(0 == tmp) {
- free(ctx->internal_buf);
- if(0 == (ctx->internal_buf = (FLAC__byte*)safe_malloc_(bytes_needed)))
- return false;
- }
- ctx->internal_buf = tmp;
- ctx->capacity = bytes_needed;
- }
-
- format_input_(ctx->internal_buf, signal, channels, samples, bytes_per_sample);
-
- FLAC__MD5Update(ctx, ctx->internal_buf, bytes_needed);
-
- return true;
-}
diff --git a/src/thirdparty/libflac/src/libFLAC/memory.c b/src/thirdparty/libflac/src/libFLAC/memory.c
deleted file mode 100644
index 1dcba0f57..000000000
--- a/src/thirdparty/libflac/src/libFLAC/memory.c
+++ /dev/null
@@ -1,221 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "private/memory.h"
-#include "FLAC/assert.h"
-#include "share/alloc.h"
-
-void *FLAC__memory_alloc_aligned(size_t bytes, void **aligned_address)
-{
- void *x;
-
- FLAC__ASSERT(0 != aligned_address);
-
-#ifdef FLAC__ALIGN_MALLOC_DATA
- /* align on 32-byte (256-bit) boundary */
- x = safe_malloc_add_2op_(bytes, /*+*/31);
-#ifdef SIZEOF_VOIDP
-#if SIZEOF_VOIDP == 4
- /* could do *aligned_address = x + ((unsigned) (32 - (((unsigned)x) & 31))) & 31; */
- *aligned_address = (void*)(((unsigned)x + 31) & -32);
-#elif SIZEOF_VOIDP == 8
- *aligned_address = (void*)(((FLAC__uint64)x + 31) & (FLAC__uint64)(-((FLAC__int64)32)));
-#else
-# error Unsupported sizeof(void*)
-#endif
-#else
- /* there's got to be a better way to do this right for all archs */
- if(sizeof(void*) == sizeof(unsigned))
- *aligned_address = (void*)(((unsigned)x + 31) & -32);
- else if(sizeof(void*) == sizeof(FLAC__uint64))
- *aligned_address = (void*)(((FLAC__uint64)x + 31) & (FLAC__uint64)(-((FLAC__int64)32)));
- else
- return 0;
-#endif
-#else
- x = safe_malloc_(bytes);
- *aligned_address = x;
-#endif
- return x;
-}
-
-FLAC__bool FLAC__memory_alloc_aligned_int32_array(unsigned elements, FLAC__int32 **unaligned_pointer, FLAC__int32 **aligned_pointer)
-{
- FLAC__int32 *pu; /* unaligned pointer */
- union { /* union needed to comply with C99 pointer aliasing rules */
- FLAC__int32 *pa; /* aligned pointer */
- void *pv; /* aligned pointer alias */
- } u;
-
- FLAC__ASSERT(elements > 0);
- FLAC__ASSERT(0 != unaligned_pointer);
- FLAC__ASSERT(0 != aligned_pointer);
- FLAC__ASSERT(unaligned_pointer != aligned_pointer);
-
- if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
- return false;
-
- pu = (FLAC__int32*)FLAC__memory_alloc_aligned(sizeof(*pu) * (size_t)elements, &u.pv);
- if(0 == pu) {
- return false;
- }
- else {
- if(*unaligned_pointer != 0)
- free(*unaligned_pointer);
- *unaligned_pointer = pu;
- *aligned_pointer = u.pa;
- return true;
- }
-}
-
-FLAC__bool FLAC__memory_alloc_aligned_uint32_array(unsigned elements, FLAC__uint32 **unaligned_pointer, FLAC__uint32 **aligned_pointer)
-{
- FLAC__uint32 *pu; /* unaligned pointer */
- union { /* union needed to comply with C99 pointer aliasing rules */
- FLAC__uint32 *pa; /* aligned pointer */
- void *pv; /* aligned pointer alias */
- } u;
-
- FLAC__ASSERT(elements > 0);
- FLAC__ASSERT(0 != unaligned_pointer);
- FLAC__ASSERT(0 != aligned_pointer);
- FLAC__ASSERT(unaligned_pointer != aligned_pointer);
-
- if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
- return false;
-
- pu = (FLAC__uint32*)FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);
- if(0 == pu) {
- return false;
- }
- else {
- if(*unaligned_pointer != 0)
- free(*unaligned_pointer);
- *unaligned_pointer = pu;
- *aligned_pointer = u.pa;
- return true;
- }
-}
-
-FLAC__bool FLAC__memory_alloc_aligned_uint64_array(unsigned elements, FLAC__uint64 **unaligned_pointer, FLAC__uint64 **aligned_pointer)
-{
- FLAC__uint64 *pu; /* unaligned pointer */
- union { /* union needed to comply with C99 pointer aliasing rules */
- FLAC__uint64 *pa; /* aligned pointer */
- void *pv; /* aligned pointer alias */
- } u;
-
- FLAC__ASSERT(elements > 0);
- FLAC__ASSERT(0 != unaligned_pointer);
- FLAC__ASSERT(0 != aligned_pointer);
- FLAC__ASSERT(unaligned_pointer != aligned_pointer);
-
- if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
- return false;
-
- pu = (FLAC__uint64*)FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);
- if(0 == pu) {
- return false;
- }
- else {
- if(*unaligned_pointer != 0)
- free(*unaligned_pointer);
- *unaligned_pointer = pu;
- *aligned_pointer = u.pa;
- return true;
- }
-}
-
-FLAC__bool FLAC__memory_alloc_aligned_unsigned_array(unsigned elements, unsigned **unaligned_pointer, unsigned **aligned_pointer)
-{
- unsigned *pu; /* unaligned pointer */
- union { /* union needed to comply with C99 pointer aliasing rules */
- unsigned *pa; /* aligned pointer */
- void *pv; /* aligned pointer alias */
- } u;
-
- FLAC__ASSERT(elements > 0);
- FLAC__ASSERT(0 != unaligned_pointer);
- FLAC__ASSERT(0 != aligned_pointer);
- FLAC__ASSERT(unaligned_pointer != aligned_pointer);
-
- if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
- return false;
-
- pu = (unsigned*)FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);
- if(0 == pu) {
- return false;
- }
- else {
- if(*unaligned_pointer != 0)
- free(*unaligned_pointer);
- *unaligned_pointer = pu;
- *aligned_pointer = u.pa;
- return true;
- }
-}
-
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
-
-FLAC__bool FLAC__memory_alloc_aligned_real_array(unsigned elements, FLAC__real **unaligned_pointer, FLAC__real **aligned_pointer)
-{
- FLAC__real *pu; /* unaligned pointer */
- union { /* union needed to comply with C99 pointer aliasing rules */
- FLAC__real *pa; /* aligned pointer */
- void *pv; /* aligned pointer alias */
- } u;
-
- FLAC__ASSERT(elements > 0);
- FLAC__ASSERT(0 != unaligned_pointer);
- FLAC__ASSERT(0 != aligned_pointer);
- FLAC__ASSERT(unaligned_pointer != aligned_pointer);
-
- if((size_t)elements > SIZE_MAX / sizeof(*pu)) /* overflow check */
- return false;
-
- pu = (FLAC__real*)FLAC__memory_alloc_aligned(sizeof(*pu) * elements, &u.pv);
- if(0 == pu) {
- return false;
- }
- else {
- if(*unaligned_pointer != 0)
- free(*unaligned_pointer);
- *unaligned_pointer = pu;
- *aligned_pointer = u.pa;
- return true;
- }
-}
-
-#endif
diff --git a/src/thirdparty/libflac/src/libFLAC/metadata_iterators.c b/src/thirdparty/libflac/src/libFLAC/metadata_iterators.c
deleted file mode 100644
index 6b118de48..000000000
--- a/src/thirdparty/libflac/src/libFLAC/metadata_iterators.c
+++ /dev/null
@@ -1,3364 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__
-#if defined __BORLANDC__
-#include <utime.h> /* for utime() */
-#else
-#include <sys/utime.h> /* for utime() */
-#endif
-#include <io.h> /* for chmod() */
-#include <sys/types.h> /* for off_t */
-#if _MSC_VER <= 1700 || defined __BORLANDC__ /* @@@ [2G limit] */
-#define fseeko fseek
-#define ftello ftell
-#endif
-#else
-#include <sys/types.h> /* some flavors of BSD (like OS X) require this to get time_t */
-#include <utime.h> /* for utime() */
-#include <unistd.h> /* for chown(), unlink() */
-#endif
-#include <sys/stat.h> /* for stat(), maybe chmod() */
-
-#include "private/metadata.h"
-
-#include "FLAC/assert.h"
-#include "FLAC/stream_decoder.h"
-#include "share/alloc.h"
-
-#ifdef max
-#undef max
-#endif
-#define max(a,b) ((a)>(b)?(a):(b))
-#ifdef min
-#undef min
-#endif
-#define min(a,b) ((a)<(b)?(a):(b))
-
-
-/****************************************************************************
- *
- * Local function declarations
- *
- ***************************************************************************/
-
-static void pack_uint32_(FLAC__uint32 val, FLAC__byte *b, unsigned bytes);
-static void pack_uint32_little_endian_(FLAC__uint32 val, FLAC__byte *b, unsigned bytes);
-static void pack_uint64_(FLAC__uint64 val, FLAC__byte *b, unsigned bytes);
-static FLAC__uint32 unpack_uint32_(FLAC__byte *b, unsigned bytes);
-static FLAC__uint32 unpack_uint32_little_endian_(FLAC__byte *b, unsigned bytes);
-static FLAC__uint64 unpack_uint64_(FLAC__byte *b, unsigned bytes);
-
-static FLAC__bool read_metadata_block_header_(FLAC__Metadata_SimpleIterator *iterator);
-static FLAC__bool read_metadata_block_data_(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block);
-static FLAC__bool read_metadata_block_header_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__bool *is_last, FLAC__MetadataType *type, unsigned *length);
-static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata *block);
-static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_streaminfo_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_StreamInfo *block);
-static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_padding_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata_Padding *block, unsigned block_length);
-static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_application_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Application *block, unsigned block_length);
-static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_seektable_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_SeekTable *block, unsigned block_length);
-static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_entry_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_VorbisComment_Entry *entry);
-static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_VorbisComment *block);
-static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cuesheet_track_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_CueSheet_Track *track);
-static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cuesheet_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_CueSheet *block);
-static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_picture_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Picture *block);
-static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_unknown_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Unknown *block, unsigned block_length);
-
-static FLAC__bool write_metadata_block_header_(FILE *file, FLAC__Metadata_SimpleIteratorStatus *status, const FLAC__StreamMetadata *block);
-static FLAC__bool write_metadata_block_data_(FILE *file, FLAC__Metadata_SimpleIteratorStatus *status, const FLAC__StreamMetadata *block);
-static FLAC__bool write_metadata_block_header_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata *block);
-static FLAC__bool write_metadata_block_data_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata *block);
-static FLAC__bool write_metadata_block_data_streaminfo_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_StreamInfo *block);
-static FLAC__bool write_metadata_block_data_padding_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Padding *block, unsigned block_length);
-static FLAC__bool write_metadata_block_data_application_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Application *block, unsigned block_length);
-static FLAC__bool write_metadata_block_data_seektable_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_SeekTable *block);
-static FLAC__bool write_metadata_block_data_vorbis_comment_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_VorbisComment *block);
-static FLAC__bool write_metadata_block_data_cuesheet_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_CueSheet *block);
-static FLAC__bool write_metadata_block_data_picture_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Picture *block);
-static FLAC__bool write_metadata_block_data_unknown_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Unknown *block, unsigned block_length);
-
-static FLAC__bool write_metadata_block_stationary_(FLAC__Metadata_SimpleIterator *iterator, const FLAC__StreamMetadata *block);
-static FLAC__bool write_metadata_block_stationary_with_padding_(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, unsigned padding_length, FLAC__bool padding_is_last);
-static FLAC__bool rewrite_whole_file_(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool append);
-
-static void simple_iterator_push_(FLAC__Metadata_SimpleIterator *iterator);
-static FLAC__bool simple_iterator_pop_(FLAC__Metadata_SimpleIterator *iterator);
-
-static unsigned seek_to_first_metadata_block_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb);
-static unsigned seek_to_first_metadata_block_(FILE *f);
-
-static FLAC__bool simple_iterator_copy_file_prefix_(FLAC__Metadata_SimpleIterator *iterator, FILE **tempfile, char **tempfilename, FLAC__bool append);
-static FLAC__bool simple_iterator_copy_file_postfix_(FLAC__Metadata_SimpleIterator *iterator, FILE **tempfile, char **tempfilename, int fixup_is_last_code, off_t fixup_is_last_flag_offset, FLAC__bool backup);
-
-static FLAC__bool copy_n_bytes_from_file_(FILE *file, FILE *tempfile, off_t bytes, FLAC__Metadata_SimpleIteratorStatus *status);
-static FLAC__bool copy_n_bytes_from_file_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOHandle temp_handle, FLAC__IOCallback_Write temp_write_cb, off_t bytes, FLAC__Metadata_SimpleIteratorStatus *status);
-static FLAC__bool copy_remaining_bytes_from_file_(FILE *file, FILE *tempfile, FLAC__Metadata_SimpleIteratorStatus *status);
-static FLAC__bool copy_remaining_bytes_from_file_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Eof eof_cb, FLAC__IOHandle temp_handle, FLAC__IOCallback_Write temp_write_cb, FLAC__Metadata_SimpleIteratorStatus *status);
-
-static FLAC__bool open_tempfile_(const char *filename, const char *tempfile_path_prefix, FILE **tempfile, char **tempfilename, FLAC__Metadata_SimpleIteratorStatus *status);
-static FLAC__bool transport_tempfile_(const char *filename, FILE **tempfile, char **tempfilename, FLAC__Metadata_SimpleIteratorStatus *status);
-static void cleanup_tempfile_(FILE **tempfile, char **tempfilename);
-
-static FLAC__bool get_file_stats_(const char *filename, struct stat *stats);
-static void set_file_stats_(const char *filename, struct stat *stats);
-
-static int fseek_wrapper_(FLAC__IOHandle handle, FLAC__int64 offset, int whence);
-static FLAC__int64 ftell_wrapper_(FLAC__IOHandle handle);
-
-static FLAC__Metadata_ChainStatus get_equivalent_status_(FLAC__Metadata_SimpleIteratorStatus status);
-
-
-#ifdef FLAC__VALGRIND_TESTING
-static size_t local__fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
-{
- size_t ret = fwrite(ptr, size, nmemb, stream);
- if(!ferror(stream))
- fflush(stream);
- return ret;
-}
-#else
-#define local__fwrite fwrite
-#endif
-
-/****************************************************************************
- *
- * Level 0 implementation
- *
- ***************************************************************************/
-
-static FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
-static void metadata_callback_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
-static void error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
-
-typedef struct {
- FLAC__bool got_error;
- FLAC__StreamMetadata *object;
-} level0_client_data;
-
-static FLAC__StreamMetadata *get_one_metadata_block_(const char *filename, FLAC__MetadataType type)
-{
- level0_client_data cd;
- FLAC__StreamDecoder *decoder;
-
- FLAC__ASSERT(0 != filename);
-
- cd.got_error = false;
- cd.object = 0;
-
- decoder = FLAC__stream_decoder_new();
-
- if(0 == decoder)
- return 0;
-
- FLAC__stream_decoder_set_md5_checking(decoder, false);
- FLAC__stream_decoder_set_metadata_ignore_all(decoder);
- FLAC__stream_decoder_set_metadata_respond(decoder, type);
-
- if(FLAC__stream_decoder_init_file(decoder, filename, write_callback_, metadata_callback_, error_callback_, &cd) != FLAC__STREAM_DECODER_INIT_STATUS_OK || cd.got_error) {
- (void)FLAC__stream_decoder_finish(decoder);
- FLAC__stream_decoder_delete(decoder);
- return 0;
- }
-
- if(!FLAC__stream_decoder_process_until_end_of_metadata(decoder) || cd.got_error) {
- (void)FLAC__stream_decoder_finish(decoder);
- FLAC__stream_decoder_delete(decoder);
- if(0 != cd.object)
- FLAC__metadata_object_delete(cd.object);
- return 0;
- }
-
- (void)FLAC__stream_decoder_finish(decoder);
- FLAC__stream_decoder_delete(decoder);
-
- return cd.object;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_get_streaminfo(const char *filename, FLAC__StreamMetadata *streaminfo)
-{
- FLAC__StreamMetadata *object;
-
- FLAC__ASSERT(0 != filename);
- FLAC__ASSERT(0 != streaminfo);
-
- object = get_one_metadata_block_(filename, FLAC__METADATA_TYPE_STREAMINFO);
-
- if (object) {
- /* can just copy the contents since STREAMINFO has no internal structure */
- *streaminfo = *object;
- FLAC__metadata_object_delete(object);
- return true;
- }
- else {
- return false;
- }
-}
-
-FLAC_API FLAC__bool FLAC__metadata_get_tags(const char *filename, FLAC__StreamMetadata **tags)
-{
- FLAC__ASSERT(0 != filename);
- FLAC__ASSERT(0 != tags);
-
- *tags = get_one_metadata_block_(filename, FLAC__METADATA_TYPE_VORBIS_COMMENT);
-
- return 0 != *tags;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_get_cuesheet(const char *filename, FLAC__StreamMetadata **cuesheet)
-{
- FLAC__ASSERT(0 != filename);
- FLAC__ASSERT(0 != cuesheet);
-
- *cuesheet = get_one_metadata_block_(filename, FLAC__METADATA_TYPE_CUESHEET);
-
- return 0 != *cuesheet;
-}
-
-FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data)
-{
- (void)decoder, (void)frame, (void)buffer, (void)client_data;
-
- return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
-}
-
-void metadata_callback_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data)
-{
- level0_client_data *cd = (level0_client_data *)client_data;
- (void)decoder;
-
- /*
- * we assume we only get here when the one metadata block we were
- * looking for was passed to us
- */
- if(!cd->got_error && 0 == cd->object) {
- if(0 == (cd->object = FLAC__metadata_object_clone(metadata)))
- cd->got_error = true;
- }
-}
-
-void error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)
-{
- level0_client_data *cd = (level0_client_data *)client_data;
- (void)decoder;
-
- if(status != FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC)
- cd->got_error = true;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_get_picture(const char *filename, FLAC__StreamMetadata **picture, FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, unsigned max_width, unsigned max_height, unsigned max_depth, unsigned max_colors)
-{
- FLAC__Metadata_SimpleIterator *it;
- FLAC__uint64 max_area_seen = 0;
- FLAC__uint64 max_depth_seen = 0;
-
- FLAC__ASSERT(0 != filename);
- FLAC__ASSERT(0 != picture);
-
- *picture = 0;
-
- it = FLAC__metadata_simple_iterator_new();
- if(0 == it)
- return false;
- if(!FLAC__metadata_simple_iterator_init(it, filename, /*read_only=*/true, /*preserve_file_stats=*/true)) {
- FLAC__metadata_simple_iterator_delete(it);
- return false;
- }
- do {
- if(FLAC__metadata_simple_iterator_get_block_type(it) == FLAC__METADATA_TYPE_PICTURE) {
- FLAC__StreamMetadata *obj = FLAC__metadata_simple_iterator_get_block(it);
- FLAC__uint64 area = (FLAC__uint64)obj->data.picture.width * (FLAC__uint64)obj->data.picture.height;
- /* check constraints */
- if(
- (type == (FLAC__StreamMetadata_Picture_Type)(-1) || type == obj->data.picture.type) &&
- (mime_type == 0 || !strcmp(mime_type, obj->data.picture.mime_type)) &&
- (description == 0 || !strcmp((const char *)description, (const char *)obj->data.picture.description)) &&
- obj->data.picture.width <= max_width &&
- obj->data.picture.height <= max_height &&
- obj->data.picture.depth <= max_depth &&
- obj->data.picture.colors <= max_colors &&
- (area > max_area_seen || (area == max_area_seen && obj->data.picture.depth > max_depth_seen))
- ) {
- if(*picture)
- FLAC__metadata_object_delete(*picture);
- *picture = obj;
- max_area_seen = area;
- max_depth_seen = obj->data.picture.depth;
- }
- else {
- FLAC__metadata_object_delete(obj);
- }
- }
- } while(FLAC__metadata_simple_iterator_next(it));
-
- FLAC__metadata_simple_iterator_delete(it);
-
- return (0 != *picture);
-}
-
-
-/****************************************************************************
- *
- * Level 1 implementation
- *
- ***************************************************************************/
-
-#define SIMPLE_ITERATOR_MAX_PUSH_DEPTH (1+4)
-/* 1 for initial offset, +4 for our own personal use */
-
-struct FLAC__Metadata_SimpleIterator {
- FILE *file;
- char *filename, *tempfile_path_prefix;
- struct stat stats;
- FLAC__bool has_stats;
- FLAC__bool is_writable;
- FLAC__Metadata_SimpleIteratorStatus status;
- off_t offset[SIMPLE_ITERATOR_MAX_PUSH_DEPTH];
- off_t first_offset; /* this is the offset to the STREAMINFO block */
- unsigned depth;
- /* this is the metadata block header of the current block we are pointing to: */
- FLAC__bool is_last;
- FLAC__MetadataType type;
- unsigned length;
-};
-
-FLAC_API const char * const FLAC__Metadata_SimpleIteratorStatusString[] = {
- "FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK",
- "FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT",
- "FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE",
- "FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_A_FLAC_FILE",
- "FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_WRITABLE",
- "FLAC__METADATA_SIMPLE_ITERATOR_STATUS_BAD_METADATA",
- "FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR",
- "FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR",
- "FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR",
- "FLAC__METADATA_SIMPLE_ITERATOR_STATUS_RENAME_ERROR",
- "FLAC__METADATA_SIMPLE_ITERATOR_STATUS_UNLINK_ERROR",
- "FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR",
- "FLAC__METADATA_SIMPLE_ITERATOR_STATUS_INTERNAL_ERROR"
-};
-
-
-FLAC_API FLAC__Metadata_SimpleIterator *FLAC__metadata_simple_iterator_new(void)
-{
- FLAC__Metadata_SimpleIterator *iterator = (FLAC__Metadata_SimpleIterator*)calloc(1, sizeof(FLAC__Metadata_SimpleIterator));
-
- if(0 != iterator) {
- iterator->file = 0;
- iterator->filename = 0;
- iterator->tempfile_path_prefix = 0;
- iterator->has_stats = false;
- iterator->is_writable = false;
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK;
- iterator->first_offset = iterator->offset[0] = -1;
- iterator->depth = 0;
- }
-
- return iterator;
-}
-
-static void simple_iterator_free_guts_(FLAC__Metadata_SimpleIterator *iterator)
-{
- FLAC__ASSERT(0 != iterator);
-
- if(0 != iterator->file) {
- fclose(iterator->file);
- iterator->file = 0;
- if(iterator->has_stats)
- set_file_stats_(iterator->filename, &iterator->stats);
- }
- if(0 != iterator->filename) {
- free(iterator->filename);
- iterator->filename = 0;
- }
- if(0 != iterator->tempfile_path_prefix) {
- free(iterator->tempfile_path_prefix);
- iterator->tempfile_path_prefix = 0;
- }
-}
-
-FLAC_API void FLAC__metadata_simple_iterator_delete(FLAC__Metadata_SimpleIterator *iterator)
-{
- FLAC__ASSERT(0 != iterator);
-
- simple_iterator_free_guts_(iterator);
- free(iterator);
-}
-
-FLAC_API FLAC__Metadata_SimpleIteratorStatus FLAC__metadata_simple_iterator_status(FLAC__Metadata_SimpleIterator *iterator)
-{
- FLAC__Metadata_SimpleIteratorStatus status;
-
- FLAC__ASSERT(0 != iterator);
-
- status = iterator->status;
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK;
- return status;
-}
-
-static FLAC__bool simple_iterator_prime_input_(FLAC__Metadata_SimpleIterator *iterator, FLAC__bool read_only)
-{
- unsigned ret;
-
- FLAC__ASSERT(0 != iterator);
-
- if(read_only || 0 == (iterator->file = fopen(iterator->filename, "r+b"))) {
- iterator->is_writable = false;
- if(read_only || errno == EACCES) {
- if(0 == (iterator->file = fopen(iterator->filename, "rb"))) {
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE;
- return false;
- }
- }
- else {
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE;
- return false;
- }
- }
- else {
- iterator->is_writable = true;
- }
-
- ret = seek_to_first_metadata_block_(iterator->file);
- switch(ret) {
- case 0:
- iterator->depth = 0;
- iterator->first_offset = iterator->offset[iterator->depth] = ftello(iterator->file);
- return read_metadata_block_header_(iterator);
- case 1:
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- return false;
- case 2:
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR;
- return false;
- case 3:
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_A_FLAC_FILE;
- return false;
- default:
- FLAC__ASSERT(0);
- return false;
- }
-}
-
-#if 0
-@@@ If we decide to finish implementing this, put this comment back in metadata.h
-/*
- * The 'tempfile_path_prefix' allows you to specify a directory where
- * tempfiles should go. Remember that if your metadata edits cause the
- * FLAC file to grow, the entire file will have to be rewritten. If
- * 'tempfile_path_prefix' is NULL, the temp file will be written in the
- * same directory as the original FLAC file. This makes replacing the
- * original with the tempfile fast but requires extra space in the same
- * partition for the tempfile. If space is a problem, you can pass a
- * directory name belonging to a different partition in
- * 'tempfile_path_prefix'. Note that you should use the forward slash
- * '/' as the directory separator. A trailing slash is not needed; it
- * will be added automatically.
- */
-FLAC__bool FLAC__metadata_simple_iterator_init(FLAC__Metadata_SimpleIterator *iterator, const char *filename, FLAC__bool preserve_file_stats, const char *tempfile_path_prefix);
-#endif
-
-FLAC_API FLAC__bool FLAC__metadata_simple_iterator_init(FLAC__Metadata_SimpleIterator *iterator, const char *filename, FLAC__bool read_only, FLAC__bool preserve_file_stats)
-{
- const char *tempfile_path_prefix = 0; /*@@@ search for comments near 'rename(...)' for what it will take to finish implementing this */
-
- FLAC__ASSERT(0 != iterator);
- FLAC__ASSERT(0 != filename);
-
- simple_iterator_free_guts_(iterator);
-
- if(!read_only && preserve_file_stats)
- iterator->has_stats = get_file_stats_(filename, &iterator->stats);
-
- if(0 == (iterator->filename = strdup(filename))) {
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR;
- return false;
- }
- if(0 != tempfile_path_prefix && 0 == (iterator->tempfile_path_prefix = strdup(tempfile_path_prefix))) {
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR;
- return false;
- }
-
- return simple_iterator_prime_input_(iterator, read_only);
-}
-
-FLAC_API FLAC__bool FLAC__metadata_simple_iterator_is_writable(const FLAC__Metadata_SimpleIterator *iterator)
-{
- FLAC__ASSERT(0 != iterator);
- FLAC__ASSERT(0 != iterator->file);
-
- return iterator->is_writable;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_simple_iterator_next(FLAC__Metadata_SimpleIterator *iterator)
-{
- FLAC__ASSERT(0 != iterator);
- FLAC__ASSERT(0 != iterator->file);
-
- if(iterator->is_last)
- return false;
-
- if(0 != fseeko(iterator->file, iterator->length, SEEK_CUR)) {
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR;
- return false;
- }
-
- iterator->offset[iterator->depth] = ftello(iterator->file);
-
- return read_metadata_block_header_(iterator);
-}
-
-FLAC_API FLAC__bool FLAC__metadata_simple_iterator_prev(FLAC__Metadata_SimpleIterator *iterator)
-{
- off_t this_offset;
-
- FLAC__ASSERT(0 != iterator);
- FLAC__ASSERT(0 != iterator->file);
-
- if(iterator->offset[iterator->depth] == iterator->first_offset)
- return false;
-
- if(0 != fseeko(iterator->file, iterator->first_offset, SEEK_SET)) {
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR;
- return false;
- }
- this_offset = iterator->first_offset;
- if(!read_metadata_block_header_(iterator))
- return false;
-
- /* we ignore any error from ftello() and catch it in fseeko() */
- while(ftello(iterator->file) + (off_t)iterator->length < iterator->offset[iterator->depth]) {
- if(0 != fseeko(iterator->file, iterator->length, SEEK_CUR)) {
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR;
- return false;
- }
- this_offset = ftello(iterator->file);
- if(!read_metadata_block_header_(iterator))
- return false;
- }
-
- iterator->offset[iterator->depth] = this_offset;
-
- return true;
-}
-
-/*@@@@add to tests*/
-FLAC_API FLAC__bool FLAC__metadata_simple_iterator_is_last(const FLAC__Metadata_SimpleIterator *iterator)
-{
- FLAC__ASSERT(0 != iterator);
- FLAC__ASSERT(0 != iterator->file);
-
- return iterator->is_last;
-}
-
-/*@@@@add to tests*/
-FLAC_API off_t FLAC__metadata_simple_iterator_get_block_offset(const FLAC__Metadata_SimpleIterator *iterator)
-{
- FLAC__ASSERT(0 != iterator);
- FLAC__ASSERT(0 != iterator->file);
-
- return iterator->offset[iterator->depth];
-}
-
-FLAC_API FLAC__MetadataType FLAC__metadata_simple_iterator_get_block_type(const FLAC__Metadata_SimpleIterator *iterator)
-{
- FLAC__ASSERT(0 != iterator);
- FLAC__ASSERT(0 != iterator->file);
-
- return iterator->type;
-}
-
-/*@@@@add to tests*/
-FLAC_API unsigned FLAC__metadata_simple_iterator_get_block_length(const FLAC__Metadata_SimpleIterator *iterator)
-{
- FLAC__ASSERT(0 != iterator);
- FLAC__ASSERT(0 != iterator->file);
-
- return iterator->length;
-}
-
-/*@@@@add to tests*/
-FLAC_API FLAC__bool FLAC__metadata_simple_iterator_get_application_id(FLAC__Metadata_SimpleIterator *iterator, FLAC__byte *id)
-{
- const unsigned id_bytes = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8;
-
- FLAC__ASSERT(0 != iterator);
- FLAC__ASSERT(0 != iterator->file);
- FLAC__ASSERT(0 != id);
-
- if(iterator->type != FLAC__METADATA_TYPE_APPLICATION) {
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT;
- return false;
- }
-
- if(fread(id, 1, id_bytes, iterator->file) != id_bytes) {
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- return false;
- }
-
- /* back up */
- if(0 != fseeko(iterator->file, -((int)id_bytes), SEEK_CUR)) {
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR;
- return false;
- }
-
- return true;
-}
-
-FLAC_API FLAC__StreamMetadata *FLAC__metadata_simple_iterator_get_block(FLAC__Metadata_SimpleIterator *iterator)
-{
- FLAC__StreamMetadata *block = FLAC__metadata_object_new(iterator->type);
-
- FLAC__ASSERT(0 != iterator);
- FLAC__ASSERT(0 != iterator->file);
-
- if(0 != block) {
- block->is_last = iterator->is_last;
- block->length = iterator->length;
-
- if(!read_metadata_block_data_(iterator, block)) {
- FLAC__metadata_object_delete(block);
- return 0;
- }
-
- /* back up to the beginning of the block data to stay consistent */
- if(0 != fseeko(iterator->file, iterator->offset[iterator->depth] + FLAC__STREAM_METADATA_HEADER_LENGTH, SEEK_SET)) {
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR;
- FLAC__metadata_object_delete(block);
- return 0;
- }
- }
- else
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR;
-
- return block;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_simple_iterator_set_block(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool use_padding)
-{
- FLAC__ASSERT_DECLARATION(off_t debug_target_offset = iterator->offset[iterator->depth];)
- FLAC__bool ret;
-
- FLAC__ASSERT(0 != iterator);
- FLAC__ASSERT(0 != iterator->file);
- FLAC__ASSERT(0 != block);
-
- if(!iterator->is_writable) {
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_WRITABLE;
- return false;
- }
-
- if(iterator->type == FLAC__METADATA_TYPE_STREAMINFO || block->type == FLAC__METADATA_TYPE_STREAMINFO) {
- if(iterator->type != block->type) {
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT;
- return false;
- }
- }
-
- block->is_last = iterator->is_last;
-
- if(iterator->length == block->length)
- return write_metadata_block_stationary_(iterator, block);
- else if(iterator->length > block->length) {
- if(use_padding && iterator->length >= FLAC__STREAM_METADATA_HEADER_LENGTH + block->length) {
- ret = write_metadata_block_stationary_with_padding_(iterator, block, iterator->length - FLAC__STREAM_METADATA_HEADER_LENGTH - block->length, block->is_last);
- FLAC__ASSERT(!ret || iterator->offset[iterator->depth] == debug_target_offset);
- FLAC__ASSERT(!ret || ftello(iterator->file) == debug_target_offset + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH);
- return ret;
- }
- else {
- ret = rewrite_whole_file_(iterator, block, /*append=*/false);
- FLAC__ASSERT(!ret || iterator->offset[iterator->depth] == debug_target_offset);
- FLAC__ASSERT(!ret || ftello(iterator->file) == debug_target_offset + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH);
- return ret;
- }
- }
- else /* iterator->length < block->length */ {
- unsigned padding_leftover = 0;
- FLAC__bool padding_is_last = false;
- if(use_padding) {
- /* first see if we can even use padding */
- if(iterator->is_last) {
- use_padding = false;
- }
- else {
- const unsigned extra_padding_bytes_required = block->length - iterator->length;
- simple_iterator_push_(iterator);
- if(!FLAC__metadata_simple_iterator_next(iterator)) {
- (void)simple_iterator_pop_(iterator);
- return false;
- }
- if(iterator->type != FLAC__METADATA_TYPE_PADDING) {
- use_padding = false;
- }
- else {
- if(FLAC__STREAM_METADATA_HEADER_LENGTH + iterator->length == extra_padding_bytes_required) {
- padding_leftover = 0;
- block->is_last = iterator->is_last;
- }
- else if(iterator->length < extra_padding_bytes_required)
- use_padding = false;
- else {
- padding_leftover = FLAC__STREAM_METADATA_HEADER_LENGTH + iterator->length - extra_padding_bytes_required;
- padding_is_last = iterator->is_last;
- block->is_last = false;
- }
- }
- if(!simple_iterator_pop_(iterator))
- return false;
- }
- }
- if(use_padding) {
- if(padding_leftover == 0) {
- ret = write_metadata_block_stationary_(iterator, block);
- FLAC__ASSERT(!ret || iterator->offset[iterator->depth] == debug_target_offset);
- FLAC__ASSERT(!ret || ftello(iterator->file) == debug_target_offset + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH);
- return ret;
- }
- else {
- FLAC__ASSERT(padding_leftover >= FLAC__STREAM_METADATA_HEADER_LENGTH);
- ret = write_metadata_block_stationary_with_padding_(iterator, block, padding_leftover - FLAC__STREAM_METADATA_HEADER_LENGTH, padding_is_last);
- FLAC__ASSERT(!ret || iterator->offset[iterator->depth] == debug_target_offset);
- FLAC__ASSERT(!ret || ftello(iterator->file) == debug_target_offset + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH);
- return ret;
- }
- }
- else {
- ret = rewrite_whole_file_(iterator, block, /*append=*/false);
- FLAC__ASSERT(!ret || iterator->offset[iterator->depth] == debug_target_offset);
- FLAC__ASSERT(!ret || ftello(iterator->file) == debug_target_offset + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH);
- return ret;
- }
- }
-}
-
-FLAC_API FLAC__bool FLAC__metadata_simple_iterator_insert_block_after(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool use_padding)
-{
- unsigned padding_leftover = 0;
- FLAC__bool padding_is_last = false;
-
- FLAC__ASSERT_DECLARATION(off_t debug_target_offset = iterator->offset[iterator->depth] + FLAC__STREAM_METADATA_HEADER_LENGTH + iterator->length;)
- FLAC__bool ret;
-
- FLAC__ASSERT(0 != iterator);
- FLAC__ASSERT(0 != iterator->file);
- FLAC__ASSERT(0 != block);
-
- if(!iterator->is_writable)
- return false;
-
- if(block->type == FLAC__METADATA_TYPE_STREAMINFO) {
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT;
- return false;
- }
-
- block->is_last = iterator->is_last;
-
- if(use_padding) {
- /* first see if we can even use padding */
- if(iterator->is_last) {
- use_padding = false;
- }
- else {
- simple_iterator_push_(iterator);
- if(!FLAC__metadata_simple_iterator_next(iterator)) {
- (void)simple_iterator_pop_(iterator);
- return false;
- }
- if(iterator->type != FLAC__METADATA_TYPE_PADDING) {
- use_padding = false;
- }
- else {
- if(iterator->length == block->length) {
- padding_leftover = 0;
- block->is_last = iterator->is_last;
- }
- else if(iterator->length < FLAC__STREAM_METADATA_HEADER_LENGTH + block->length)
- use_padding = false;
- else {
- padding_leftover = iterator->length - block->length;
- padding_is_last = iterator->is_last;
- block->is_last = false;
- }
- }
- if(!simple_iterator_pop_(iterator))
- return false;
- }
- }
- if(use_padding) {
- /* move to the next block, which is suitable padding */
- if(!FLAC__metadata_simple_iterator_next(iterator))
- return false;
- if(padding_leftover == 0) {
- ret = write_metadata_block_stationary_(iterator, block);
- FLAC__ASSERT(iterator->offset[iterator->depth] == debug_target_offset);
- FLAC__ASSERT(ftello(iterator->file) == debug_target_offset + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH);
- return ret;
- }
- else {
- FLAC__ASSERT(padding_leftover >= FLAC__STREAM_METADATA_HEADER_LENGTH);
- ret = write_metadata_block_stationary_with_padding_(iterator, block, padding_leftover - FLAC__STREAM_METADATA_HEADER_LENGTH, padding_is_last);
- FLAC__ASSERT(iterator->offset[iterator->depth] == debug_target_offset);
- FLAC__ASSERT(ftello(iterator->file) == debug_target_offset + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH);
- return ret;
- }
- }
- else {
- ret = rewrite_whole_file_(iterator, block, /*append=*/true);
- FLAC__ASSERT(iterator->offset[iterator->depth] == debug_target_offset);
- FLAC__ASSERT(ftello(iterator->file) == debug_target_offset + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH);
- return ret;
- }
-}
-
-FLAC_API FLAC__bool FLAC__metadata_simple_iterator_delete_block(FLAC__Metadata_SimpleIterator *iterator, FLAC__bool use_padding)
-{
- FLAC__ASSERT_DECLARATION(off_t debug_target_offset = iterator->offset[iterator->depth];)
- FLAC__bool ret;
-
- if(iterator->type == FLAC__METADATA_TYPE_STREAMINFO) {
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT;
- return false;
- }
-
- if(use_padding) {
- FLAC__StreamMetadata *padding = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING);
- if(0 == padding) {
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR;
- return false;
- }
- padding->length = iterator->length;
- if(!FLAC__metadata_simple_iterator_set_block(iterator, padding, false)) {
- FLAC__metadata_object_delete(padding);
- return false;
- }
- FLAC__metadata_object_delete(padding);
- if(!FLAC__metadata_simple_iterator_prev(iterator))
- return false;
- FLAC__ASSERT(iterator->offset[iterator->depth] + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH + (off_t)iterator->length == debug_target_offset);
- FLAC__ASSERT(ftello(iterator->file) + (off_t)iterator->length == debug_target_offset);
- return true;
- }
- else {
- ret = rewrite_whole_file_(iterator, 0, /*append=*/false);
- FLAC__ASSERT(iterator->offset[iterator->depth] + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH + (off_t)iterator->length == debug_target_offset);
- FLAC__ASSERT(ftello(iterator->file) + (off_t)iterator->length == debug_target_offset);
- return ret;
- }
-}
-
-
-
-/****************************************************************************
- *
- * Level 2 implementation
- *
- ***************************************************************************/
-
-
-typedef struct FLAC__Metadata_Node {
- FLAC__StreamMetadata *data;
- struct FLAC__Metadata_Node *prev, *next;
-} FLAC__Metadata_Node;
-
-struct FLAC__Metadata_Chain {
- char *filename; /* will be NULL if using callbacks */
- FLAC__bool is_ogg;
- FLAC__Metadata_Node *head;
- FLAC__Metadata_Node *tail;
- unsigned nodes;
- FLAC__Metadata_ChainStatus status;
- off_t first_offset, last_offset;
- /*
- * This is the length of the chain initially read from the FLAC file.
- * it is used to compare against the current length to decide whether
- * or not the whole file has to be rewritten.
- */
- off_t initial_length;
- /* @@@ hacky, these are currently only needed by ogg reader */
- FLAC__IOHandle handle;
- FLAC__IOCallback_Read read_cb;
-};
-
-struct FLAC__Metadata_Iterator {
- FLAC__Metadata_Chain *chain;
- FLAC__Metadata_Node *current;
-};
-
-FLAC_API const char * const FLAC__Metadata_ChainStatusString[] = {
- "FLAC__METADATA_CHAIN_STATUS_OK",
- "FLAC__METADATA_CHAIN_STATUS_ILLEGAL_INPUT",
- "FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE",
- "FLAC__METADATA_CHAIN_STATUS_NOT_A_FLAC_FILE",
- "FLAC__METADATA_CHAIN_STATUS_NOT_WRITABLE",
- "FLAC__METADATA_CHAIN_STATUS_BAD_METADATA",
- "FLAC__METADATA_CHAIN_STATUS_READ_ERROR",
- "FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR",
- "FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR",
- "FLAC__METADATA_CHAIN_STATUS_RENAME_ERROR",
- "FLAC__METADATA_CHAIN_STATUS_UNLINK_ERROR",
- "FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR",
- "FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR",
- "FLAC__METADATA_CHAIN_STATUS_INVALID_CALLBACKS",
- "FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH",
- "FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL"
-};
-
-
-static FLAC__Metadata_Node *node_new_(void)
-{
- return (FLAC__Metadata_Node*)calloc(1, sizeof(FLAC__Metadata_Node));
-}
-
-static void node_delete_(FLAC__Metadata_Node *node)
-{
- FLAC__ASSERT(0 != node);
- if(0 != node->data)
- FLAC__metadata_object_delete(node->data);
- free(node);
-}
-
-static void chain_init_(FLAC__Metadata_Chain *chain)
-{
- FLAC__ASSERT(0 != chain);
-
- chain->filename = 0;
- chain->is_ogg = false;
- chain->head = chain->tail = 0;
- chain->nodes = 0;
- chain->status = FLAC__METADATA_CHAIN_STATUS_OK;
- chain->initial_length = 0;
- chain->read_cb = 0;
-}
-
-static void chain_clear_(FLAC__Metadata_Chain *chain)
-{
- FLAC__Metadata_Node *node, *next;
-
- FLAC__ASSERT(0 != chain);
-
- for(node = chain->head; node; ) {
- next = node->next;
- node_delete_(node);
- node = next;
- }
-
- if(0 != chain->filename)
- free(chain->filename);
-
- chain_init_(chain);
-}
-
-static void chain_append_node_(FLAC__Metadata_Chain *chain, FLAC__Metadata_Node *node)
-{
- FLAC__ASSERT(0 != chain);
- FLAC__ASSERT(0 != node);
- FLAC__ASSERT(0 != node->data);
-
- node->next = node->prev = 0;
- node->data->is_last = true;
- if(0 != chain->tail)
- chain->tail->data->is_last = false;
-
- if(0 == chain->head)
- chain->head = node;
- else {
- FLAC__ASSERT(0 != chain->tail);
- chain->tail->next = node;
- node->prev = chain->tail;
- }
- chain->tail = node;
- chain->nodes++;
-}
-
-static void chain_remove_node_(FLAC__Metadata_Chain *chain, FLAC__Metadata_Node *node)
-{
- FLAC__ASSERT(0 != chain);
- FLAC__ASSERT(0 != node);
-
- if(node == chain->head)
- chain->head = node->next;
- else
- node->prev->next = node->next;
-
- if(node == chain->tail)
- chain->tail = node->prev;
- else
- node->next->prev = node->prev;
-
- if(0 != chain->tail)
- chain->tail->data->is_last = true;
-
- chain->nodes--;
-}
-
-static void chain_delete_node_(FLAC__Metadata_Chain *chain, FLAC__Metadata_Node *node)
-{
- chain_remove_node_(chain, node);
- node_delete_(node);
-}
-
-static off_t chain_calculate_length_(FLAC__Metadata_Chain *chain)
-{
- const FLAC__Metadata_Node *node;
- off_t length = 0;
- for(node = chain->head; node; node = node->next)
- length += (FLAC__STREAM_METADATA_HEADER_LENGTH + node->data->length);
- return length;
-}
-
-static void iterator_insert_node_(FLAC__Metadata_Iterator *iterator, FLAC__Metadata_Node *node)
-{
- FLAC__ASSERT(0 != node);
- FLAC__ASSERT(0 != node->data);
- FLAC__ASSERT(0 != iterator);
- FLAC__ASSERT(0 != iterator->current);
- FLAC__ASSERT(0 != iterator->chain);
- FLAC__ASSERT(0 != iterator->chain->head);
- FLAC__ASSERT(0 != iterator->chain->tail);
-
- node->data->is_last = false;
-
- node->prev = iterator->current->prev;
- node->next = iterator->current;
-
- if(0 == node->prev)
- iterator->chain->head = node;
- else
- node->prev->next = node;
-
- iterator->current->prev = node;
-
- iterator->chain->nodes++;
-}
-
-static void iterator_insert_node_after_(FLAC__Metadata_Iterator *iterator, FLAC__Metadata_Node *node)
-{
- FLAC__ASSERT(0 != node);
- FLAC__ASSERT(0 != node->data);
- FLAC__ASSERT(0 != iterator);
- FLAC__ASSERT(0 != iterator->current);
- FLAC__ASSERT(0 != iterator->chain);
- FLAC__ASSERT(0 != iterator->chain->head);
- FLAC__ASSERT(0 != iterator->chain->tail);
-
- iterator->current->data->is_last = false;
-
- node->prev = iterator->current;
- node->next = iterator->current->next;
-
- if(0 == node->next)
- iterator->chain->tail = node;
- else
- node->next->prev = node;
-
- node->prev->next = node;
-
- iterator->chain->tail->data->is_last = true;
-
- iterator->chain->nodes++;
-}
-
-/* return true iff node and node->next are both padding */
-static FLAC__bool chain_merge_adjacent_padding_(FLAC__Metadata_Chain *chain, FLAC__Metadata_Node *node)
-{
- if(node->data->type == FLAC__METADATA_TYPE_PADDING && 0 != node->next && node->next->data->type == FLAC__METADATA_TYPE_PADDING) {
- const unsigned growth = FLAC__STREAM_METADATA_HEADER_LENGTH + node->next->data->length;
- node->data->length += growth;
-
- chain_delete_node_(chain, node->next);
- return true;
- }
- else
- return false;
-}
-
-/* Returns the new length of the chain, or 0 if there was an error. */
-/* WATCHOUT: This can get called multiple times before a write, so
- * it should still work when this happens.
- */
-/* WATCHOUT: Make sure to also update the logic in
- * FLAC__metadata_chain_check_if_tempfile_needed() if the logic here changes.
- */
-static off_t chain_prepare_for_write_(FLAC__Metadata_Chain *chain, FLAC__bool use_padding)
-{
- off_t current_length = chain_calculate_length_(chain);
-
- if(use_padding) {
- /* if the metadata shrank and the last block is padding, we just extend the last padding block */
- if(current_length < chain->initial_length && chain->tail->data->type == FLAC__METADATA_TYPE_PADDING) {
- const off_t delta = chain->initial_length - current_length;
- chain->tail->data->length += delta;
- current_length += delta;
- FLAC__ASSERT(current_length == chain->initial_length);
- }
- /* if the metadata shrank more than 4 bytes then there's room to add another padding block */
- else if(current_length + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH <= chain->initial_length) {
- FLAC__StreamMetadata *padding;
- FLAC__Metadata_Node *node;
- if(0 == (padding = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING))) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR;
- return 0;
- }
- padding->length = chain->initial_length - (FLAC__STREAM_METADATA_HEADER_LENGTH + current_length);
- if(0 == (node = node_new_())) {
- FLAC__metadata_object_delete(padding);
- chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR;
- return 0;
- }
- node->data = padding;
- chain_append_node_(chain, node);
- current_length = chain_calculate_length_(chain);
- FLAC__ASSERT(current_length == chain->initial_length);
- }
- /* if the metadata grew but the last block is padding, try cutting the padding to restore the original length so we don't have to rewrite the whole file */
- else if(current_length > chain->initial_length) {
- const off_t delta = current_length - chain->initial_length;
- if(chain->tail->data->type == FLAC__METADATA_TYPE_PADDING) {
- /* if the delta is exactly the size of the last padding block, remove the padding block */
- if((off_t)chain->tail->data->length + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH == delta) {
- chain_delete_node_(chain, chain->tail);
- current_length = chain_calculate_length_(chain);
- FLAC__ASSERT(current_length == chain->initial_length);
- }
- /* if there is at least 'delta' bytes of padding, trim the padding down */
- else if((off_t)chain->tail->data->length >= delta) {
- chain->tail->data->length -= delta;
- current_length -= delta;
- FLAC__ASSERT(current_length == chain->initial_length);
- }
- }
- }
- }
-
- return current_length;
-}
-
-static FLAC__bool chain_read_cb_(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb, FLAC__IOCallback_Tell tell_cb)
-{
- FLAC__Metadata_Node *node;
-
- FLAC__ASSERT(0 != chain);
-
- /* we assume we're already at the beginning of the file */
-
- switch(seek_to_first_metadata_block_cb_(handle, read_cb, seek_cb)) {
- case 0:
- break;
- case 1:
- chain->status = FLAC__METADATA_CHAIN_STATUS_READ_ERROR;
- return false;
- case 2:
- chain->status = FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR;
- return false;
- case 3:
- chain->status = FLAC__METADATA_CHAIN_STATUS_NOT_A_FLAC_FILE;
- return false;
- default:
- FLAC__ASSERT(0);
- return false;
- }
-
- {
- FLAC__int64 pos = tell_cb(handle);
- if(pos < 0) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_READ_ERROR;
- return false;
- }
- chain->first_offset = (off_t)pos;
- }
-
- {
- FLAC__bool is_last;
- FLAC__MetadataType type;
- unsigned length;
-
- do {
- node = node_new_();
- if(0 == node) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR;
- return false;
- }
-
- if(!read_metadata_block_header_cb_(handle, read_cb, &is_last, &type, &length)) {
- node_delete_(node);
- chain->status = FLAC__METADATA_CHAIN_STATUS_READ_ERROR;
- return false;
- }
-
- node->data = FLAC__metadata_object_new(type);
- if(0 == node->data) {
- node_delete_(node);
- chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR;
- return false;
- }
-
- node->data->is_last = is_last;
- node->data->length = length;
-
- chain->status = get_equivalent_status_(read_metadata_block_data_cb_(handle, read_cb, seek_cb, node->data));
- if(chain->status != FLAC__METADATA_CHAIN_STATUS_OK) {
- node_delete_(node);
- return false;
- }
- chain_append_node_(chain, node);
- } while(!is_last);
- }
-
- {
- FLAC__int64 pos = tell_cb(handle);
- if(pos < 0) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_READ_ERROR;
- return false;
- }
- chain->last_offset = (off_t)pos;
- }
-
- chain->initial_length = chain_calculate_length_(chain);
-
- return true;
-}
-
-static FLAC__StreamDecoderReadStatus chain_read_ogg_read_cb_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
-{
- FLAC__Metadata_Chain *chain = (FLAC__Metadata_Chain*)client_data;
- (void)decoder;
- if(*bytes > 0 && chain->status == FLAC__METADATA_CHAIN_STATUS_OK) {
- *bytes = chain->read_cb(buffer, sizeof(FLAC__byte), *bytes, chain->handle);
- if(*bytes == 0)
- return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
- else
- return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
- }
- else
- return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
-}
-
-static FLAC__StreamDecoderWriteStatus chain_read_ogg_write_cb_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data)
-{
- (void)decoder, (void)frame, (void)buffer, (void)client_data;
- return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
-}
-
-static void chain_read_ogg_metadata_cb_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data)
-{
- FLAC__Metadata_Chain *chain = (FLAC__Metadata_Chain*)client_data;
- FLAC__Metadata_Node *node;
-
- (void)decoder;
-
- node = node_new_();
- if(0 == node) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR;
- return;
- }
-
- node->data = FLAC__metadata_object_clone(metadata);
- if(0 == node->data) {
- node_delete_(node);
- chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR;
- return;
- }
-
- chain_append_node_(chain, node);
-}
-
-static void chain_read_ogg_error_cb_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)
-{
- FLAC__Metadata_Chain *chain = (FLAC__Metadata_Chain*)client_data;
- (void)decoder, (void)status;
- chain->status = FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR; /*@@@ maybe needs better error code */
-}
-
-static FLAC__bool chain_read_ogg_cb_(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb)
-{
- FLAC__StreamDecoder *decoder;
-
- FLAC__ASSERT(0 != chain);
-
- /* we assume we're already at the beginning of the file */
-
- chain->handle = handle;
- chain->read_cb = read_cb;
- if(0 == (decoder = FLAC__stream_decoder_new())) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR;
- return false;
- }
- FLAC__stream_decoder_set_metadata_respond_all(decoder);
- if(FLAC__stream_decoder_init_ogg_stream(decoder, chain_read_ogg_read_cb_, /*seek_callback=*/0, /*tell_callback=*/0, /*length_callback=*/0, /*eof_callback=*/0, chain_read_ogg_write_cb_, chain_read_ogg_metadata_cb_, chain_read_ogg_error_cb_, chain) != FLAC__STREAM_DECODER_INIT_STATUS_OK) {
- FLAC__stream_decoder_delete(decoder);
- chain->status = FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR; /*@@@ maybe needs better error code */
- return false;
- }
-
- chain->first_offset = 0; /*@@@ wrong; will need to be set correctly to implement metadata writing for Ogg FLAC */
-
- if(!FLAC__stream_decoder_process_until_end_of_metadata(decoder))
- chain->status = FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR; /*@@@ maybe needs better error code */
- if(chain->status != FLAC__METADATA_CHAIN_STATUS_OK) {
- FLAC__stream_decoder_delete(decoder);
- return false;
- }
-
- FLAC__stream_decoder_delete(decoder);
-
- chain->last_offset = 0; /*@@@ wrong; will need to be set correctly to implement metadata writing for Ogg FLAC */
-
- chain->initial_length = chain_calculate_length_(chain);
-
- return true;
-}
-
-static FLAC__bool chain_rewrite_metadata_in_place_cb_(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, FLAC__IOCallback_Seek seek_cb)
-{
- FLAC__Metadata_Node *node;
-
- FLAC__ASSERT(0 != chain);
- FLAC__ASSERT(0 != chain->head);
-
- if(0 != seek_cb(handle, chain->first_offset, SEEK_SET)) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR;
- return false;
- }
-
- for(node = chain->head; node; node = node->next) {
- if(!write_metadata_block_header_cb_(handle, write_cb, node->data)) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR;
- return false;
- }
- if(!write_metadata_block_data_cb_(handle, write_cb, node->data)) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR;
- return false;
- }
- }
-
- /*FLAC__ASSERT(fflush(), ftello() == chain->last_offset);*/
-
- chain->status = FLAC__METADATA_CHAIN_STATUS_OK;
- return true;
-}
-
-static FLAC__bool chain_rewrite_metadata_in_place_(FLAC__Metadata_Chain *chain)
-{
- FILE *file;
- FLAC__bool ret;
-
- FLAC__ASSERT(0 != chain->filename);
-
- if(0 == (file = fopen(chain->filename, "r+b"))) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE;
- return false;
- }
-
- /* chain_rewrite_metadata_in_place_cb_() sets chain->status for us */
- ret = chain_rewrite_metadata_in_place_cb_(chain, (FLAC__IOHandle)file, (FLAC__IOCallback_Write)fwrite, fseek_wrapper_);
-
- fclose(file);
-
- return ret;
-}
-
-static FLAC__bool chain_rewrite_file_(FLAC__Metadata_Chain *chain, const char *tempfile_path_prefix)
-{
- FILE *f, *tempfile;
- char *tempfilename;
- FLAC__Metadata_SimpleIteratorStatus status;
- const FLAC__Metadata_Node *node;
-
- FLAC__ASSERT(0 != chain);
- FLAC__ASSERT(0 != chain->filename);
- FLAC__ASSERT(0 != chain->head);
-
- /* copy the file prefix (data up to first metadata block */
- if(0 == (f = fopen(chain->filename, "rb"))) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE;
- return false;
- }
- if(!open_tempfile_(chain->filename, tempfile_path_prefix, &tempfile, &tempfilename, &status)) {
- chain->status = get_equivalent_status_(status);
- cleanup_tempfile_(&tempfile, &tempfilename);
- return false;
- }
- if(!copy_n_bytes_from_file_(f, tempfile, chain->first_offset, &status)) {
- chain->status = get_equivalent_status_(status);
- cleanup_tempfile_(&tempfile, &tempfilename);
- return false;
- }
-
- /* write the metadata */
- for(node = chain->head; node; node = node->next) {
- if(!write_metadata_block_header_(tempfile, &status, node->data)) {
- chain->status = get_equivalent_status_(status);
- return false;
- }
- if(!write_metadata_block_data_(tempfile, &status, node->data)) {
- chain->status = get_equivalent_status_(status);
- return false;
- }
- }
- /*FLAC__ASSERT(fflush(), ftello() == chain->last_offset);*/
-
- /* copy the file postfix (everything after the metadata) */
- if(0 != fseeko(f, chain->last_offset, SEEK_SET)) {
- cleanup_tempfile_(&tempfile, &tempfilename);
- chain->status = FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR;
- return false;
- }
- if(!copy_remaining_bytes_from_file_(f, tempfile, &status)) {
- cleanup_tempfile_(&tempfile, &tempfilename);
- chain->status = get_equivalent_status_(status);
- return false;
- }
-
- /* move the tempfile on top of the original */
- (void)fclose(f);
- if(!transport_tempfile_(chain->filename, &tempfile, &tempfilename, &status))
- return false;
-
- return true;
-}
-
-/* assumes 'handle' is already at beginning of file */
-static FLAC__bool chain_rewrite_file_cb_(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb, FLAC__IOCallback_Eof eof_cb, FLAC__IOHandle temp_handle, FLAC__IOCallback_Write temp_write_cb)
-{
- FLAC__Metadata_SimpleIteratorStatus status;
- const FLAC__Metadata_Node *node;
-
- FLAC__ASSERT(0 != chain);
- FLAC__ASSERT(0 == chain->filename);
- FLAC__ASSERT(0 != chain->head);
-
- /* copy the file prefix (data up to first metadata block */
- if(!copy_n_bytes_from_file_cb_(handle, read_cb, temp_handle, temp_write_cb, chain->first_offset, &status)) {
- chain->status = get_equivalent_status_(status);
- return false;
- }
-
- /* write the metadata */
- for(node = chain->head; node; node = node->next) {
- if(!write_metadata_block_header_cb_(temp_handle, temp_write_cb, node->data)) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR;
- return false;
- }
- if(!write_metadata_block_data_cb_(temp_handle, temp_write_cb, node->data)) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR;
- return false;
- }
- }
- /*FLAC__ASSERT(fflush(), ftello() == chain->last_offset);*/
-
- /* copy the file postfix (everything after the metadata) */
- if(0 != seek_cb(handle, chain->last_offset, SEEK_SET)) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR;
- return false;
- }
- if(!copy_remaining_bytes_from_file_cb_(handle, read_cb, eof_cb, temp_handle, temp_write_cb, &status)) {
- chain->status = get_equivalent_status_(status);
- return false;
- }
-
- return true;
-}
-
-FLAC_API FLAC__Metadata_Chain *FLAC__metadata_chain_new(void)
-{
- FLAC__Metadata_Chain *chain = (FLAC__Metadata_Chain*)calloc(1, sizeof(FLAC__Metadata_Chain));
-
- if(0 != chain)
- chain_init_(chain);
-
- return chain;
-}
-
-FLAC_API void FLAC__metadata_chain_delete(FLAC__Metadata_Chain *chain)
-{
- FLAC__ASSERT(0 != chain);
-
- chain_clear_(chain);
-
- free(chain);
-}
-
-FLAC_API FLAC__Metadata_ChainStatus FLAC__metadata_chain_status(FLAC__Metadata_Chain *chain)
-{
- FLAC__Metadata_ChainStatus status;
-
- FLAC__ASSERT(0 != chain);
-
- status = chain->status;
- chain->status = FLAC__METADATA_CHAIN_STATUS_OK;
- return status;
-}
-
-static FLAC__bool chain_read_(FLAC__Metadata_Chain *chain, const char *filename, FLAC__bool is_ogg)
-{
- FILE *file;
- FLAC__bool ret;
-
- FLAC__ASSERT(0 != chain);
- FLAC__ASSERT(0 != filename);
-
- chain_clear_(chain);
-
- if(0 == (chain->filename = strdup(filename))) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR;
- return false;
- }
-
- chain->is_ogg = is_ogg;
-
- if(0 == (file = fopen(filename, "rb"))) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE;
- return false;
- }
-
- /* the function also sets chain->status for us */
- ret = is_ogg?
- chain_read_ogg_cb_(chain, file, (FLAC__IOCallback_Read)fread) :
- chain_read_cb_(chain, file, (FLAC__IOCallback_Read)fread, fseek_wrapper_, ftell_wrapper_)
- ;
-
- fclose(file);
-
- return ret;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_chain_read(FLAC__Metadata_Chain *chain, const char *filename)
-{
- return chain_read_(chain, filename, /*is_ogg=*/false);
-}
-
-/*@@@@add to tests*/
-FLAC_API FLAC__bool FLAC__metadata_chain_read_ogg(FLAC__Metadata_Chain *chain, const char *filename)
-{
- return chain_read_(chain, filename, /*is_ogg=*/true);
-}
-
-static FLAC__bool chain_read_with_callbacks_(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks, FLAC__bool is_ogg)
-{
- FLAC__bool ret;
-
- FLAC__ASSERT(0 != chain);
-
- chain_clear_(chain);
-
- if (0 == callbacks.read || 0 == callbacks.seek || 0 == callbacks.tell) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_INVALID_CALLBACKS;
- return false;
- }
-
- chain->is_ogg = is_ogg;
-
- /* rewind */
- if(0 != callbacks.seek(handle, 0, SEEK_SET)) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR;
- return false;
- }
-
- /* the function also sets chain->status for us */
- ret = is_ogg?
- chain_read_ogg_cb_(chain, handle, callbacks.read) :
- chain_read_cb_(chain, handle, callbacks.read, callbacks.seek, callbacks.tell)
- ;
-
- return ret;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_chain_read_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks)
-{
- return chain_read_with_callbacks_(chain, handle, callbacks, /*is_ogg=*/false);
-}
-
-/*@@@@add to tests*/
-FLAC_API FLAC__bool FLAC__metadata_chain_read_ogg_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks)
-{
- return chain_read_with_callbacks_(chain, handle, callbacks, /*is_ogg=*/true);
-}
-
-FLAC_API FLAC__bool FLAC__metadata_chain_check_if_tempfile_needed(FLAC__Metadata_Chain *chain, FLAC__bool use_padding)
-{
- /* This does all the same checks that are in chain_prepare_for_write_()
- * but doesn't actually alter the chain. Make sure to update the logic
- * here if chain_prepare_for_write_() changes.
- */
- const off_t current_length = chain_calculate_length_(chain);
-
- FLAC__ASSERT(0 != chain);
-
- if(use_padding) {
- /* if the metadata shrank and the last block is padding, we just extend the last padding block */
- if(current_length < chain->initial_length && chain->tail->data->type == FLAC__METADATA_TYPE_PADDING)
- return false;
- /* if the metadata shrank more than 4 bytes then there's room to add another padding block */
- else if(current_length + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH <= chain->initial_length)
- return false;
- /* if the metadata grew but the last block is padding, try cutting the padding to restore the original length so we don't have to rewrite the whole file */
- else if(current_length > chain->initial_length) {
- const off_t delta = current_length - chain->initial_length;
- if(chain->tail->data->type == FLAC__METADATA_TYPE_PADDING) {
- /* if the delta is exactly the size of the last padding block, remove the padding block */
- if((off_t)chain->tail->data->length + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH == delta)
- return false;
- /* if there is at least 'delta' bytes of padding, trim the padding down */
- else if((off_t)chain->tail->data->length >= delta)
- return false;
- }
- }
- }
-
- return (current_length != chain->initial_length);
-}
-
-FLAC_API FLAC__bool FLAC__metadata_chain_write(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__bool preserve_file_stats)
-{
- struct stat stats;
- const char *tempfile_path_prefix = 0;
- off_t current_length;
-
- FLAC__ASSERT(0 != chain);
-
- if (chain->is_ogg) { /* cannot write back to Ogg FLAC yet */
- chain->status = FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR;
- return false;
- }
-
- if (0 == chain->filename) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH;
- return false;
- }
-
- current_length = chain_prepare_for_write_(chain, use_padding);
-
- /* a return value of 0 means there was an error; chain->status is already set */
- if (0 == current_length)
- return false;
-
- if(preserve_file_stats)
- get_file_stats_(chain->filename, &stats);
-
- if(current_length == chain->initial_length) {
- if(!chain_rewrite_metadata_in_place_(chain))
- return false;
- }
- else {
- if(!chain_rewrite_file_(chain, tempfile_path_prefix))
- return false;
-
- /* recompute lengths and offsets */
- {
- const FLAC__Metadata_Node *node;
- chain->initial_length = current_length;
- chain->last_offset = chain->first_offset;
- for(node = chain->head; node; node = node->next)
- chain->last_offset += (FLAC__STREAM_METADATA_HEADER_LENGTH + node->data->length);
- }
- }
-
- if(preserve_file_stats)
- set_file_stats_(chain->filename, &stats);
-
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_chain_write_with_callbacks(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks)
-{
- off_t current_length;
-
- FLAC__ASSERT(0 != chain);
-
- if (chain->is_ogg) { /* cannot write back to Ogg FLAC yet */
- chain->status = FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR;
- return false;
- }
-
- if (0 != chain->filename) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH;
- return false;
- }
-
- if (0 == callbacks.write || 0 == callbacks.seek) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_INVALID_CALLBACKS;
- return false;
- }
-
- if (FLAC__metadata_chain_check_if_tempfile_needed(chain, use_padding)) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL;
- return false;
- }
-
- current_length = chain_prepare_for_write_(chain, use_padding);
-
- /* a return value of 0 means there was an error; chain->status is already set */
- if (0 == current_length)
- return false;
-
- FLAC__ASSERT(current_length == chain->initial_length);
-
- return chain_rewrite_metadata_in_place_cb_(chain, handle, callbacks.write, callbacks.seek);
-}
-
-FLAC_API FLAC__bool FLAC__metadata_chain_write_with_callbacks_and_tempfile(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__IOHandle handle, FLAC__IOCallbacks callbacks, FLAC__IOHandle temp_handle, FLAC__IOCallbacks temp_callbacks)
-{
- off_t current_length;
-
- FLAC__ASSERT(0 != chain);
-
- if (chain->is_ogg) { /* cannot write back to Ogg FLAC yet */
- chain->status = FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR;
- return false;
- }
-
- if (0 != chain->filename) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH;
- return false;
- }
-
- if (0 == callbacks.read || 0 == callbacks.seek || 0 == callbacks.eof) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_INVALID_CALLBACKS;
- return false;
- }
- if (0 == temp_callbacks.write) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_INVALID_CALLBACKS;
- return false;
- }
-
- if (!FLAC__metadata_chain_check_if_tempfile_needed(chain, use_padding)) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL;
- return false;
- }
-
- current_length = chain_prepare_for_write_(chain, use_padding);
-
- /* a return value of 0 means there was an error; chain->status is already set */
- if (0 == current_length)
- return false;
-
- FLAC__ASSERT(current_length != chain->initial_length);
-
- /* rewind */
- if(0 != callbacks.seek(handle, 0, SEEK_SET)) {
- chain->status = FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR;
- return false;
- }
-
- if(!chain_rewrite_file_cb_(chain, handle, callbacks.read, callbacks.seek, callbacks.eof, temp_handle, temp_callbacks.write))
- return false;
-
- /* recompute lengths and offsets */
- {
- const FLAC__Metadata_Node *node;
- chain->initial_length = current_length;
- chain->last_offset = chain->first_offset;
- for(node = chain->head; node; node = node->next)
- chain->last_offset += (FLAC__STREAM_METADATA_HEADER_LENGTH + node->data->length);
- }
-
- return true;
-}
-
-FLAC_API void FLAC__metadata_chain_merge_padding(FLAC__Metadata_Chain *chain)
-{
- FLAC__Metadata_Node *node;
-
- FLAC__ASSERT(0 != chain);
-
- for(node = chain->head; node; ) {
- if(!chain_merge_adjacent_padding_(chain, node))
- node = node->next;
- }
-}
-
-FLAC_API void FLAC__metadata_chain_sort_padding(FLAC__Metadata_Chain *chain)
-{
- FLAC__Metadata_Node *node, *save;
- unsigned i;
-
- FLAC__ASSERT(0 != chain);
-
- /*
- * Don't try and be too smart... this simple algo is good enough for
- * the small number of nodes that we deal with.
- */
- for(i = 0, node = chain->head; i < chain->nodes; i++) {
- if(node->data->type == FLAC__METADATA_TYPE_PADDING) {
- save = node->next;
- chain_remove_node_(chain, node);
- chain_append_node_(chain, node);
- node = save;
- }
- else {
- node = node->next;
- }
- }
-
- FLAC__metadata_chain_merge_padding(chain);
-}
-
-
-FLAC_API FLAC__Metadata_Iterator *FLAC__metadata_iterator_new(void)
-{
- FLAC__Metadata_Iterator *iterator = (FLAC__Metadata_Iterator*)calloc(1, sizeof(FLAC__Metadata_Iterator));
-
- /* calloc() implies:
- iterator->current = 0;
- iterator->chain = 0;
- */
-
- return iterator;
-}
-
-FLAC_API void FLAC__metadata_iterator_delete(FLAC__Metadata_Iterator *iterator)
-{
- FLAC__ASSERT(0 != iterator);
-
- free(iterator);
-}
-
-FLAC_API void FLAC__metadata_iterator_init(FLAC__Metadata_Iterator *iterator, FLAC__Metadata_Chain *chain)
-{
- FLAC__ASSERT(0 != iterator);
- FLAC__ASSERT(0 != chain);
- FLAC__ASSERT(0 != chain->head);
-
- iterator->chain = chain;
- iterator->current = chain->head;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_iterator_next(FLAC__Metadata_Iterator *iterator)
-{
- FLAC__ASSERT(0 != iterator);
-
- if(0 == iterator->current || 0 == iterator->current->next)
- return false;
-
- iterator->current = iterator->current->next;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_iterator_prev(FLAC__Metadata_Iterator *iterator)
-{
- FLAC__ASSERT(0 != iterator);
-
- if(0 == iterator->current || 0 == iterator->current->prev)
- return false;
-
- iterator->current = iterator->current->prev;
- return true;
-}
-
-FLAC_API FLAC__MetadataType FLAC__metadata_iterator_get_block_type(const FLAC__Metadata_Iterator *iterator)
-{
- FLAC__ASSERT(0 != iterator);
- FLAC__ASSERT(0 != iterator->current);
- FLAC__ASSERT(0 != iterator->current->data);
-
- return iterator->current->data->type;
-}
-
-FLAC_API FLAC__StreamMetadata *FLAC__metadata_iterator_get_block(FLAC__Metadata_Iterator *iterator)
-{
- FLAC__ASSERT(0 != iterator);
- FLAC__ASSERT(0 != iterator->current);
-
- return iterator->current->data;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_iterator_set_block(FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block)
-{
- FLAC__ASSERT(0 != iterator);
- FLAC__ASSERT(0 != block);
- return FLAC__metadata_iterator_delete_block(iterator, false) && FLAC__metadata_iterator_insert_block_after(iterator, block);
-}
-
-FLAC_API FLAC__bool FLAC__metadata_iterator_delete_block(FLAC__Metadata_Iterator *iterator, FLAC__bool replace_with_padding)
-{
- FLAC__Metadata_Node *save;
-
- FLAC__ASSERT(0 != iterator);
- FLAC__ASSERT(0 != iterator->current);
-
- if(0 == iterator->current->prev) {
- FLAC__ASSERT(iterator->current->data->type == FLAC__METADATA_TYPE_STREAMINFO);
- return false;
- }
-
- save = iterator->current->prev;
-
- if(replace_with_padding) {
- FLAC__metadata_object_delete_data(iterator->current->data);
- iterator->current->data->type = FLAC__METADATA_TYPE_PADDING;
- }
- else {
- chain_delete_node_(iterator->chain, iterator->current);
- }
-
- iterator->current = save;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_iterator_insert_block_before(FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block)
-{
- FLAC__Metadata_Node *node;
-
- FLAC__ASSERT(0 != iterator);
- FLAC__ASSERT(0 != iterator->current);
- FLAC__ASSERT(0 != block);
-
- if(block->type == FLAC__METADATA_TYPE_STREAMINFO)
- return false;
-
- if(0 == iterator->current->prev) {
- FLAC__ASSERT(iterator->current->data->type == FLAC__METADATA_TYPE_STREAMINFO);
- return false;
- }
-
- if(0 == (node = node_new_()))
- return false;
-
- node->data = block;
- iterator_insert_node_(iterator, node);
- iterator->current = node;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_iterator_insert_block_after(FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block)
-{
- FLAC__Metadata_Node *node;
-
- FLAC__ASSERT(0 != iterator);
- FLAC__ASSERT(0 != iterator->current);
- FLAC__ASSERT(0 != block);
-
- if(block->type == FLAC__METADATA_TYPE_STREAMINFO)
- return false;
-
- if(0 == (node = node_new_()))
- return false;
-
- node->data = block;
- iterator_insert_node_after_(iterator, node);
- iterator->current = node;
- return true;
-}
-
-
-/****************************************************************************
- *
- * Local function definitions
- *
- ***************************************************************************/
-
-void pack_uint32_(FLAC__uint32 val, FLAC__byte *b, unsigned bytes)
-{
- unsigned i;
-
- b += bytes;
-
- for(i = 0; i < bytes; i++) {
- *(--b) = (FLAC__byte)(val & 0xff);
- val >>= 8;
- }
-}
-
-void pack_uint32_little_endian_(FLAC__uint32 val, FLAC__byte *b, unsigned bytes)
-{
- unsigned i;
-
- for(i = 0; i < bytes; i++) {
- *(b++) = (FLAC__byte)(val & 0xff);
- val >>= 8;
- }
-}
-
-void pack_uint64_(FLAC__uint64 val, FLAC__byte *b, unsigned bytes)
-{
- unsigned i;
-
- b += bytes;
-
- for(i = 0; i < bytes; i++) {
- *(--b) = (FLAC__byte)(val & 0xff);
- val >>= 8;
- }
-}
-
-FLAC__uint32 unpack_uint32_(FLAC__byte *b, unsigned bytes)
-{
- FLAC__uint32 ret = 0;
- unsigned i;
-
- for(i = 0; i < bytes; i++)
- ret = (ret << 8) | (FLAC__uint32)(*b++);
-
- return ret;
-}
-
-FLAC__uint32 unpack_uint32_little_endian_(FLAC__byte *b, unsigned bytes)
-{
- FLAC__uint32 ret = 0;
- unsigned i;
-
- b += bytes;
-
- for(i = 0; i < bytes; i++)
- ret = (ret << 8) | (FLAC__uint32)(*--b);
-
- return ret;
-}
-
-FLAC__uint64 unpack_uint64_(FLAC__byte *b, unsigned bytes)
-{
- FLAC__uint64 ret = 0;
- unsigned i;
-
- for(i = 0; i < bytes; i++)
- ret = (ret << 8) | (FLAC__uint64)(*b++);
-
- return ret;
-}
-
-FLAC__bool read_metadata_block_header_(FLAC__Metadata_SimpleIterator *iterator)
-{
- FLAC__ASSERT(0 != iterator);
- FLAC__ASSERT(0 != iterator->file);
-
- if(!read_metadata_block_header_cb_((FLAC__IOHandle)iterator->file, (FLAC__IOCallback_Read)fread, &iterator->is_last, &iterator->type, &iterator->length)) {
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- return false;
- }
-
- return true;
-}
-
-FLAC__bool read_metadata_block_data_(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block)
-{
- FLAC__ASSERT(0 != iterator);
- FLAC__ASSERT(0 != iterator->file);
-
- iterator->status = read_metadata_block_data_cb_((FLAC__IOHandle)iterator->file, (FLAC__IOCallback_Read)fread, fseek_wrapper_, block);
-
- return (iterator->status == FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK);
-}
-
-FLAC__bool read_metadata_block_header_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__bool *is_last, FLAC__MetadataType *type, unsigned *length)
-{
- FLAC__byte raw_header[FLAC__STREAM_METADATA_HEADER_LENGTH];
-
- if(read_cb(raw_header, 1, FLAC__STREAM_METADATA_HEADER_LENGTH, handle) != FLAC__STREAM_METADATA_HEADER_LENGTH)
- return false;
-
- *is_last = raw_header[0] & 0x80? true : false;
- *type = (FLAC__MetadataType)(raw_header[0] & 0x7f);
- *length = unpack_uint32_(raw_header + 1, 3);
-
- /* Note that we don't check:
- * if(iterator->type >= FLAC__METADATA_TYPE_UNDEFINED)
- * we just will read in an opaque block
- */
-
- return true;
-}
-
-FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata *block)
-{
- switch(block->type) {
- case FLAC__METADATA_TYPE_STREAMINFO:
- return read_metadata_block_data_streaminfo_cb_(handle, read_cb, &block->data.stream_info);
- case FLAC__METADATA_TYPE_PADDING:
- return read_metadata_block_data_padding_cb_(handle, seek_cb, &block->data.padding, block->length);
- case FLAC__METADATA_TYPE_APPLICATION:
- return read_metadata_block_data_application_cb_(handle, read_cb, &block->data.application, block->length);
- case FLAC__METADATA_TYPE_SEEKTABLE:
- return read_metadata_block_data_seektable_cb_(handle, read_cb, &block->data.seek_table, block->length);
- case FLAC__METADATA_TYPE_VORBIS_COMMENT:
- return read_metadata_block_data_vorbis_comment_cb_(handle, read_cb, &block->data.vorbis_comment);
- case FLAC__METADATA_TYPE_CUESHEET:
- return read_metadata_block_data_cuesheet_cb_(handle, read_cb, &block->data.cue_sheet);
- case FLAC__METADATA_TYPE_PICTURE:
- return read_metadata_block_data_picture_cb_(handle, read_cb, &block->data.picture);
- default:
- return read_metadata_block_data_unknown_cb_(handle, read_cb, &block->data.unknown, block->length);
- }
-}
-
-FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_streaminfo_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_StreamInfo *block)
-{
- FLAC__byte buffer[FLAC__STREAM_METADATA_STREAMINFO_LENGTH], *b;
-
- if(read_cb(buffer, 1, FLAC__STREAM_METADATA_STREAMINFO_LENGTH, handle) != FLAC__STREAM_METADATA_STREAMINFO_LENGTH)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
-
- b = buffer;
-
- /* we are using hardcoded numbers for simplicity but we should
- * probably eventually write a bit-level unpacker and use the
- * _STREAMINFO_ constants.
- */
- block->min_blocksize = unpack_uint32_(b, 2); b += 2;
- block->max_blocksize = unpack_uint32_(b, 2); b += 2;
- block->min_framesize = unpack_uint32_(b, 3); b += 3;
- block->max_framesize = unpack_uint32_(b, 3); b += 3;
- block->sample_rate = (unpack_uint32_(b, 2) << 4) | ((unsigned)(b[2] & 0xf0) >> 4);
- block->channels = (unsigned)((b[2] & 0x0e) >> 1) + 1;
- block->bits_per_sample = ((((unsigned)(b[2] & 0x01)) << 4) | (((unsigned)(b[3] & 0xf0)) >> 4)) + 1;
- block->total_samples = (((FLAC__uint64)(b[3] & 0x0f)) << 32) | unpack_uint64_(b+4, 4);
- memcpy(block->md5sum, b+8, 16);
-
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK;
-}
-
-FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_padding_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Seek seek_cb, FLAC__StreamMetadata_Padding *block, unsigned block_length)
-{
- (void)block; /* nothing to do; we don't care about reading the padding bytes */
-
- if(0 != seek_cb(handle, block_length, SEEK_CUR))
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR;
-
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK;
-}
-
-FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_application_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Application *block, unsigned block_length)
-{
- const unsigned id_bytes = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8;
-
- if(read_cb(block->id, 1, id_bytes, handle) != id_bytes)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
-
- if(block_length < id_bytes)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
-
- block_length -= id_bytes;
-
- if(block_length == 0) {
- block->data = 0;
- }
- else {
- if(0 == (block->data = (FLAC__byte*)malloc(block_length)))
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR;
-
- if(read_cb(block->data, 1, block_length, handle) != block_length)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- }
-
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK;
-}
-
-FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_seektable_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_SeekTable *block, unsigned block_length)
-{
- unsigned i;
- FLAC__byte buffer[FLAC__STREAM_METADATA_SEEKPOINT_LENGTH];
-
- FLAC__ASSERT(block_length % FLAC__STREAM_METADATA_SEEKPOINT_LENGTH == 0);
-
- block->num_points = block_length / FLAC__STREAM_METADATA_SEEKPOINT_LENGTH;
-
- if(block->num_points == 0)
- block->points = 0;
- else if(0 == (block->points = (FLAC__StreamMetadata_SeekPoint*)safe_malloc_mul_2op_(block->num_points, /*times*/sizeof(FLAC__StreamMetadata_SeekPoint))))
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR;
-
- for(i = 0; i < block->num_points; i++) {
- if(read_cb(buffer, 1, FLAC__STREAM_METADATA_SEEKPOINT_LENGTH, handle) != FLAC__STREAM_METADATA_SEEKPOINT_LENGTH)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- /* some MAGIC NUMBERs here */
- block->points[i].sample_number = unpack_uint64_(buffer, 8);
- block->points[i].stream_offset = unpack_uint64_(buffer+8, 8);
- block->points[i].frame_samples = unpack_uint32_(buffer+16, 2);
- }
-
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK;
-}
-
-FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_entry_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_VorbisComment_Entry *entry)
-{
- const unsigned entry_length_len = FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN / 8;
- FLAC__byte buffer[4]; /* magic number is asserted below */
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN / 8 == sizeof(buffer));
-
- if(read_cb(buffer, 1, entry_length_len, handle) != entry_length_len)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- entry->length = unpack_uint32_little_endian_(buffer, entry_length_len);
-
- if(0 != entry->entry)
- free(entry->entry);
-
- if(entry->length == 0) {
- entry->entry = 0;
- }
- else {
- if(0 == (entry->entry = (FLAC__byte*)safe_malloc_add_2op_(entry->length, /*+*/1)))
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR;
-
- if(read_cb(entry->entry, 1, entry->length, handle) != entry->length)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
-
- entry->entry[entry->length] = '\0';
- }
-
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK;
-}
-
-FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_vorbis_comment_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_VorbisComment *block)
-{
- unsigned i;
- FLAC__Metadata_SimpleIteratorStatus status;
- const unsigned num_comments_len = FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN / 8;
- FLAC__byte buffer[4]; /* magic number is asserted below */
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN / 8 == sizeof(buffer));
-
- if(FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK != (status = read_metadata_block_data_vorbis_comment_entry_cb_(handle, read_cb, &(block->vendor_string))))
- return status;
-
- if(read_cb(buffer, 1, num_comments_len, handle) != num_comments_len)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- block->num_comments = unpack_uint32_little_endian_(buffer, num_comments_len);
-
- if(block->num_comments == 0) {
- block->comments = 0;
- }
- else if(0 == (block->comments = (FLAC__StreamMetadata_VorbisComment_Entry*)calloc(block->num_comments, sizeof(FLAC__StreamMetadata_VorbisComment_Entry))))
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR;
-
- for(i = 0; i < block->num_comments; i++) {
- if(FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK != (status = read_metadata_block_data_vorbis_comment_entry_cb_(handle, read_cb, block->comments + i)))
- return status;
- }
-
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK;
-}
-
-FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cuesheet_track_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_CueSheet_Track *track)
-{
- unsigned i, len;
- FLAC__byte buffer[32]; /* asserted below that this is big enough */
-
- FLAC__ASSERT(sizeof(buffer) >= sizeof(FLAC__uint64));
- FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN/8);
- FLAC__ASSERT(sizeof(buffer) >= (FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN) / 8);
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN % 8 == 0);
- len = FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN / 8;
- if(read_cb(buffer, 1, len, handle) != len)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- track->offset = unpack_uint64_(buffer, len);
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN % 8 == 0);
- len = FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN / 8;
- if(read_cb(buffer, 1, len, handle) != len)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- track->number = (FLAC__byte)unpack_uint32_(buffer, len);
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN % 8 == 0);
- len = FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN / 8;
- if(read_cb(track->isrc, 1, len, handle) != len)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
-
- FLAC__ASSERT((FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN) % 8 == 0);
- len = (FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN) / 8;
- if(read_cb(buffer, 1, len, handle) != len)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN == 1);
- FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN == 1);
- track->type = buffer[0] >> 7;
- track->pre_emphasis = (buffer[0] >> 6) & 1;
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN % 8 == 0);
- len = FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN / 8;
- if(read_cb(buffer, 1, len, handle) != len)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- track->num_indices = (FLAC__byte)unpack_uint32_(buffer, len);
-
- if(track->num_indices == 0) {
- track->indices = 0;
- }
- else if(0 == (track->indices = (FLAC__StreamMetadata_CueSheet_Index*)calloc(track->num_indices, sizeof(FLAC__StreamMetadata_CueSheet_Index))))
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR;
-
- for(i = 0; i < track->num_indices; i++) {
- FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN % 8 == 0);
- len = FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN / 8;
- if(read_cb(buffer, 1, len, handle) != len)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- track->indices[i].offset = unpack_uint64_(buffer, len);
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN % 8 == 0);
- len = FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN / 8;
- if(read_cb(buffer, 1, len, handle) != len)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- track->indices[i].number = (FLAC__byte)unpack_uint32_(buffer, len);
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN % 8 == 0);
- len = FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN / 8;
- if(read_cb(buffer, 1, len, handle) != len)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- }
-
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK;
-}
-
-FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_cuesheet_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_CueSheet *block)
-{
- unsigned i, len;
- FLAC__Metadata_SimpleIteratorStatus status;
- FLAC__byte buffer[1024]; /* MSVC needs a constant expression so we put a magic number and assert */
-
- FLAC__ASSERT((FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN + FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN)/8 <= sizeof(buffer));
- FLAC__ASSERT(sizeof(FLAC__uint64) <= sizeof(buffer));
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN % 8 == 0);
- len = FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN / 8;
- if(read_cb(block->media_catalog_number, 1, len, handle) != len)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN % 8 == 0);
- len = FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN / 8;
- if(read_cb(buffer, 1, len, handle) != len)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- block->lead_in = unpack_uint64_(buffer, len);
-
- FLAC__ASSERT((FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN + FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN) % 8 == 0);
- len = (FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN + FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN) / 8;
- if(read_cb(buffer, 1, len, handle) != len)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- block->is_cd = buffer[0]&0x80? true : false;
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN % 8 == 0);
- len = FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN / 8;
- if(read_cb(buffer, 1, len, handle) != len)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- block->num_tracks = unpack_uint32_(buffer, len);
-
- if(block->num_tracks == 0) {
- block->tracks = 0;
- }
- else if(0 == (block->tracks = (FLAC__StreamMetadata_CueSheet_Track*)calloc(block->num_tracks, sizeof(FLAC__StreamMetadata_CueSheet_Track))))
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR;
-
- for(i = 0; i < block->num_tracks; i++) {
- if(FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK != (status = read_metadata_block_data_cuesheet_track_cb_(handle, read_cb, block->tracks + i)))
- return status;
- }
-
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK;
-}
-
-static FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_picture_cstring_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__byte **data, FLAC__uint32 *length, FLAC__uint32 length_len)
-{
- FLAC__byte buffer[sizeof(FLAC__uint32)];
-
- FLAC__ASSERT(0 != data);
- FLAC__ASSERT(length_len%8 == 0);
-
- length_len /= 8; /* convert to bytes */
-
- FLAC__ASSERT(sizeof(buffer) >= length_len);
-
- if(read_cb(buffer, 1, length_len, handle) != length_len)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- *length = unpack_uint32_(buffer, length_len);
-
- if(0 != *data)
- free(*data);
-
- if(0 == (*data = (FLAC__byte*)safe_malloc_add_2op_(*length, /*+*/1)))
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR;
-
- if(*length > 0) {
- if(read_cb(*data, 1, *length, handle) != *length)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- }
-
- (*data)[*length] = '\0';
-
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK;
-}
-
-FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_picture_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Picture *block)
-{
- FLAC__Metadata_SimpleIteratorStatus status;
- FLAC__byte buffer[4]; /* asserted below that this is big enough */
- FLAC__uint32 len;
-
- FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_PICTURE_TYPE_LEN/8);
- FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN/8);
- FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN/8);
- FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN/8);
- FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_PICTURE_COLORS_LEN/8);
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_PICTURE_TYPE_LEN % 8 == 0);
- len = FLAC__STREAM_METADATA_PICTURE_TYPE_LEN / 8;
- if(read_cb(buffer, 1, len, handle) != len)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- block->type = (FLAC__StreamMetadata_Picture_Type)unpack_uint32_(buffer, len);
-
- if((status = read_metadata_block_data_picture_cstring_cb_(handle, read_cb, (FLAC__byte**)(&(block->mime_type)), &len, FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN)) != FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK)
- return status;
-
- if((status = read_metadata_block_data_picture_cstring_cb_(handle, read_cb, &(block->description), &len, FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN)) != FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK)
- return status;
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN % 8 == 0);
- len = FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN / 8;
- if(read_cb(buffer, 1, len, handle) != len)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- block->width = unpack_uint32_(buffer, len);
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN % 8 == 0);
- len = FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN / 8;
- if(read_cb(buffer, 1, len, handle) != len)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- block->height = unpack_uint32_(buffer, len);
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN % 8 == 0);
- len = FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN / 8;
- if(read_cb(buffer, 1, len, handle) != len)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- block->depth = unpack_uint32_(buffer, len);
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_PICTURE_COLORS_LEN % 8 == 0);
- len = FLAC__STREAM_METADATA_PICTURE_COLORS_LEN / 8;
- if(read_cb(buffer, 1, len, handle) != len)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- block->colors = unpack_uint32_(buffer, len);
-
- /* for convenience we use read_metadata_block_data_picture_cstring_cb_() even though it adds an extra terminating NUL we don't use */
- if((status = read_metadata_block_data_picture_cstring_cb_(handle, read_cb, &(block->data), &(block->data_length), FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN)) != FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK)
- return status;
-
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK;
-}
-
-FLAC__Metadata_SimpleIteratorStatus read_metadata_block_data_unknown_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__StreamMetadata_Unknown *block, unsigned block_length)
-{
- if(block_length == 0) {
- block->data = 0;
- }
- else {
- if(0 == (block->data = (FLAC__byte*)malloc(block_length)))
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR;
-
- if(read_cb(block->data, 1, block_length, handle) != block_length)
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- }
-
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK;
-}
-
-FLAC__bool write_metadata_block_header_(FILE *file, FLAC__Metadata_SimpleIteratorStatus *status, const FLAC__StreamMetadata *block)
-{
- FLAC__ASSERT(0 != file);
- FLAC__ASSERT(0 != status);
-
- if(!write_metadata_block_header_cb_((FLAC__IOHandle)file, (FLAC__IOCallback_Write)fwrite, block)) {
- *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR;
- return false;
- }
-
- return true;
-}
-
-FLAC__bool write_metadata_block_data_(FILE *file, FLAC__Metadata_SimpleIteratorStatus *status, const FLAC__StreamMetadata *block)
-{
- FLAC__ASSERT(0 != file);
- FLAC__ASSERT(0 != status);
-
- if (write_metadata_block_data_cb_((FLAC__IOHandle)file, (FLAC__IOCallback_Write)fwrite, block)) {
- *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK;
- return true;
- }
- else {
- *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR;
- return false;
- }
-}
-
-FLAC__bool write_metadata_block_header_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata *block)
-{
- FLAC__byte buffer[FLAC__STREAM_METADATA_HEADER_LENGTH];
-
- FLAC__ASSERT(block->length < (1u << FLAC__STREAM_METADATA_LENGTH_LEN));
-
- buffer[0] = (block->is_last? 0x80 : 0) | (FLAC__byte)block->type;
- pack_uint32_(block->length, buffer + 1, 3);
-
- if(write_cb(buffer, 1, FLAC__STREAM_METADATA_HEADER_LENGTH, handle) != FLAC__STREAM_METADATA_HEADER_LENGTH)
- return false;
-
- return true;
-}
-
-FLAC__bool write_metadata_block_data_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata *block)
-{
- FLAC__ASSERT(0 != block);
-
- switch(block->type) {
- case FLAC__METADATA_TYPE_STREAMINFO:
- return write_metadata_block_data_streaminfo_cb_(handle, write_cb, &block->data.stream_info);
- case FLAC__METADATA_TYPE_PADDING:
- return write_metadata_block_data_padding_cb_(handle, write_cb, &block->data.padding, block->length);
- case FLAC__METADATA_TYPE_APPLICATION:
- return write_metadata_block_data_application_cb_(handle, write_cb, &block->data.application, block->length);
- case FLAC__METADATA_TYPE_SEEKTABLE:
- return write_metadata_block_data_seektable_cb_(handle, write_cb, &block->data.seek_table);
- case FLAC__METADATA_TYPE_VORBIS_COMMENT:
- return write_metadata_block_data_vorbis_comment_cb_(handle, write_cb, &block->data.vorbis_comment);
- case FLAC__METADATA_TYPE_CUESHEET:
- return write_metadata_block_data_cuesheet_cb_(handle, write_cb, &block->data.cue_sheet);
- case FLAC__METADATA_TYPE_PICTURE:
- return write_metadata_block_data_picture_cb_(handle, write_cb, &block->data.picture);
- default:
- return write_metadata_block_data_unknown_cb_(handle, write_cb, &block->data.unknown, block->length);
- }
-}
-
-FLAC__bool write_metadata_block_data_streaminfo_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_StreamInfo *block)
-{
- FLAC__byte buffer[FLAC__STREAM_METADATA_STREAMINFO_LENGTH];
- const unsigned channels1 = block->channels - 1;
- const unsigned bps1 = block->bits_per_sample - 1;
-
- /* we are using hardcoded numbers for simplicity but we should
- * probably eventually write a bit-level packer and use the
- * _STREAMINFO_ constants.
- */
- pack_uint32_(block->min_blocksize, buffer, 2);
- pack_uint32_(block->max_blocksize, buffer+2, 2);
- pack_uint32_(block->min_framesize, buffer+4, 3);
- pack_uint32_(block->max_framesize, buffer+7, 3);
- buffer[10] = (block->sample_rate >> 12) & 0xff;
- buffer[11] = (block->sample_rate >> 4) & 0xff;
- buffer[12] = ((block->sample_rate & 0x0f) << 4) | (channels1 << 1) | (bps1 >> 4);
- buffer[13] = (FLAC__byte)(((bps1 & 0x0f) << 4) | ((block->total_samples >> 32) & 0x0f));
- pack_uint32_((FLAC__uint32)block->total_samples, buffer+14, 4);
- memcpy(buffer+18, block->md5sum, 16);
-
- if(write_cb(buffer, 1, FLAC__STREAM_METADATA_STREAMINFO_LENGTH, handle) != FLAC__STREAM_METADATA_STREAMINFO_LENGTH)
- return false;
-
- return true;
-}
-
-FLAC__bool write_metadata_block_data_padding_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Padding *block, unsigned block_length)
-{
- unsigned i, n = block_length;
- FLAC__byte buffer[1024];
-
- (void)block;
-
- memset(buffer, 0, 1024);
-
- for(i = 0; i < n/1024; i++)
- if(write_cb(buffer, 1, 1024, handle) != 1024)
- return false;
-
- n %= 1024;
-
- if(write_cb(buffer, 1, n, handle) != n)
- return false;
-
- return true;
-}
-
-FLAC__bool write_metadata_block_data_application_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Application *block, unsigned block_length)
-{
- const unsigned id_bytes = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8;
-
- if(write_cb(block->id, 1, id_bytes, handle) != id_bytes)
- return false;
-
- block_length -= id_bytes;
-
- if(write_cb(block->data, 1, block_length, handle) != block_length)
- return false;
-
- return true;
-}
-
-FLAC__bool write_metadata_block_data_seektable_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_SeekTable *block)
-{
- unsigned i;
- FLAC__byte buffer[FLAC__STREAM_METADATA_SEEKPOINT_LENGTH];
-
- for(i = 0; i < block->num_points; i++) {
- /* some MAGIC NUMBERs here */
- pack_uint64_(block->points[i].sample_number, buffer, 8);
- pack_uint64_(block->points[i].stream_offset, buffer+8, 8);
- pack_uint32_(block->points[i].frame_samples, buffer+16, 2);
- if(write_cb(buffer, 1, FLAC__STREAM_METADATA_SEEKPOINT_LENGTH, handle) != FLAC__STREAM_METADATA_SEEKPOINT_LENGTH)
- return false;
- }
-
- return true;
-}
-
-FLAC__bool write_metadata_block_data_vorbis_comment_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_VorbisComment *block)
-{
- unsigned i;
- const unsigned entry_length_len = FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN / 8;
- const unsigned num_comments_len = FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN / 8;
- FLAC__byte buffer[4]; /* magic number is asserted below */
-
- FLAC__ASSERT(max(FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN, FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN) / 8 == sizeof(buffer));
-
- pack_uint32_little_endian_(block->vendor_string.length, buffer, entry_length_len);
- if(write_cb(buffer, 1, entry_length_len, handle) != entry_length_len)
- return false;
- if(write_cb(block->vendor_string.entry, 1, block->vendor_string.length, handle) != block->vendor_string.length)
- return false;
-
- pack_uint32_little_endian_(block->num_comments, buffer, num_comments_len);
- if(write_cb(buffer, 1, num_comments_len, handle) != num_comments_len)
- return false;
-
- for(i = 0; i < block->num_comments; i++) {
- pack_uint32_little_endian_(block->comments[i].length, buffer, entry_length_len);
- if(write_cb(buffer, 1, entry_length_len, handle) != entry_length_len)
- return false;
- if(write_cb(block->comments[i].entry, 1, block->comments[i].length, handle) != block->comments[i].length)
- return false;
- }
-
- return true;
-}
-
-FLAC__bool write_metadata_block_data_cuesheet_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_CueSheet *block)
-{
- unsigned i, j, len;
- FLAC__byte buffer[1024]; /* asserted below that this is big enough */
-
- FLAC__ASSERT(sizeof(buffer) >= sizeof(FLAC__uint64));
- FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN/8);
- FLAC__ASSERT(sizeof(buffer) >= (FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN + FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN)/8);
- FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN/8);
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN % 8 == 0);
- len = FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN / 8;
- if(write_cb(block->media_catalog_number, 1, len, handle) != len)
- return false;
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN % 8 == 0);
- len = FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN / 8;
- pack_uint64_(block->lead_in, buffer, len);
- if(write_cb(buffer, 1, len, handle) != len)
- return false;
-
- FLAC__ASSERT((FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN + FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN) % 8 == 0);
- len = (FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN + FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN) / 8;
- memset(buffer, 0, len);
- if(block->is_cd)
- buffer[0] |= 0x80;
- if(write_cb(buffer, 1, len, handle) != len)
- return false;
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN % 8 == 0);
- len = FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN / 8;
- pack_uint32_(block->num_tracks, buffer, len);
- if(write_cb(buffer, 1, len, handle) != len)
- return false;
-
- for(i = 0; i < block->num_tracks; i++) {
- FLAC__StreamMetadata_CueSheet_Track *track = block->tracks + i;
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN % 8 == 0);
- len = FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN / 8;
- pack_uint64_(track->offset, buffer, len);
- if(write_cb(buffer, 1, len, handle) != len)
- return false;
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN % 8 == 0);
- len = FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN / 8;
- pack_uint32_(track->number, buffer, len);
- if(write_cb(buffer, 1, len, handle) != len)
- return false;
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN % 8 == 0);
- len = FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN / 8;
- if(write_cb(track->isrc, 1, len, handle) != len)
- return false;
-
- FLAC__ASSERT((FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN) % 8 == 0);
- len = (FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN + FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN) / 8;
- memset(buffer, 0, len);
- buffer[0] = (track->type << 7) | (track->pre_emphasis << 6);
- if(write_cb(buffer, 1, len, handle) != len)
- return false;
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN % 8 == 0);
- len = FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN / 8;
- pack_uint32_(track->num_indices, buffer, len);
- if(write_cb(buffer, 1, len, handle) != len)
- return false;
-
- for(j = 0; j < track->num_indices; j++) {
- FLAC__StreamMetadata_CueSheet_Index *index = track->indices + j;
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN % 8 == 0);
- len = FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN / 8;
- pack_uint64_(index->offset, buffer, len);
- if(write_cb(buffer, 1, len, handle) != len)
- return false;
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN % 8 == 0);
- len = FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN / 8;
- pack_uint32_(index->number, buffer, len);
- if(write_cb(buffer, 1, len, handle) != len)
- return false;
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN % 8 == 0);
- len = FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN / 8;
- memset(buffer, 0, len);
- if(write_cb(buffer, 1, len, handle) != len)
- return false;
- }
- }
-
- return true;
-}
-
-FLAC__bool write_metadata_block_data_picture_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Picture *block)
-{
- unsigned len;
- size_t slen;
- FLAC__byte buffer[4]; /* magic number is asserted below */
-
- FLAC__ASSERT(0 == FLAC__STREAM_METADATA_PICTURE_TYPE_LEN%8);
- FLAC__ASSERT(0 == FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN%8);
- FLAC__ASSERT(0 == FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN%8);
- FLAC__ASSERT(0 == FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN%8);
- FLAC__ASSERT(0 == FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN%8);
- FLAC__ASSERT(0 == FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN%8);
- FLAC__ASSERT(0 == FLAC__STREAM_METADATA_PICTURE_COLORS_LEN%8);
- FLAC__ASSERT(0 == FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN%8);
- FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_PICTURE_TYPE_LEN/8);
- FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN/8);
- FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN/8);
- FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN/8);
- FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN/8);
- FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN/8);
- FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_PICTURE_COLORS_LEN/8);
- FLAC__ASSERT(sizeof(buffer) >= FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN/8);
-
- len = FLAC__STREAM_METADATA_PICTURE_TYPE_LEN/8;
- pack_uint32_(block->type, buffer, len);
- if(write_cb(buffer, 1, len, handle) != len)
- return false;
-
- len = FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN/8;
- slen = strlen(block->mime_type);
- pack_uint32_(slen, buffer, len);
- if(write_cb(buffer, 1, len, handle) != len)
- return false;
- if(write_cb(block->mime_type, 1, slen, handle) != slen)
- return false;
-
- len = FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN/8;
- slen = strlen((const char *)block->description);
- pack_uint32_(slen, buffer, len);
- if(write_cb(buffer, 1, len, handle) != len)
- return false;
- if(write_cb(block->description, 1, slen, handle) != slen)
- return false;
-
- len = FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN/8;
- pack_uint32_(block->width, buffer, len);
- if(write_cb(buffer, 1, len, handle) != len)
- return false;
-
- len = FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN/8;
- pack_uint32_(block->height, buffer, len);
- if(write_cb(buffer, 1, len, handle) != len)
- return false;
-
- len = FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN/8;
- pack_uint32_(block->depth, buffer, len);
- if(write_cb(buffer, 1, len, handle) != len)
- return false;
-
- len = FLAC__STREAM_METADATA_PICTURE_COLORS_LEN/8;
- pack_uint32_(block->colors, buffer, len);
- if(write_cb(buffer, 1, len, handle) != len)
- return false;
-
- len = FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN/8;
- pack_uint32_(block->data_length, buffer, len);
- if(write_cb(buffer, 1, len, handle) != len)
- return false;
- if(write_cb(block->data, 1, block->data_length, handle) != block->data_length)
- return false;
-
- return true;
-}
-
-FLAC__bool write_metadata_block_data_unknown_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Write write_cb, const FLAC__StreamMetadata_Unknown *block, unsigned block_length)
-{
- if(write_cb(block->data, 1, block_length, handle) != block_length)
- return false;
-
- return true;
-}
-
-FLAC__bool write_metadata_block_stationary_(FLAC__Metadata_SimpleIterator *iterator, const FLAC__StreamMetadata *block)
-{
- if(0 != fseeko(iterator->file, iterator->offset[iterator->depth], SEEK_SET)) {
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR;
- return false;
- }
-
- if(!write_metadata_block_header_(iterator->file, &iterator->status, block))
- return false;
-
- if(!write_metadata_block_data_(iterator->file, &iterator->status, block))
- return false;
-
- if(0 != fseeko(iterator->file, iterator->offset[iterator->depth], SEEK_SET)) {
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR;
- return false;
- }
-
- return read_metadata_block_header_(iterator);
-}
-
-FLAC__bool write_metadata_block_stationary_with_padding_(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, unsigned padding_length, FLAC__bool padding_is_last)
-{
- FLAC__StreamMetadata *padding;
-
- if(0 != fseeko(iterator->file, iterator->offset[iterator->depth], SEEK_SET)) {
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR;
- return false;
- }
-
- block->is_last = false;
-
- if(!write_metadata_block_header_(iterator->file, &iterator->status, block))
- return false;
-
- if(!write_metadata_block_data_(iterator->file, &iterator->status, block))
- return false;
-
- if(0 == (padding = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING)))
- return FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR;
-
- padding->is_last = padding_is_last;
- padding->length = padding_length;
-
- if(!write_metadata_block_header_(iterator->file, &iterator->status, padding)) {
- FLAC__metadata_object_delete(padding);
- return false;
- }
-
- if(!write_metadata_block_data_(iterator->file, &iterator->status, padding)) {
- FLAC__metadata_object_delete(padding);
- return false;
- }
-
- FLAC__metadata_object_delete(padding);
-
- if(0 != fseeko(iterator->file, iterator->offset[iterator->depth], SEEK_SET)) {
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR;
- return false;
- }
-
- return read_metadata_block_header_(iterator);
-}
-
-FLAC__bool rewrite_whole_file_(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool append)
-{
- FILE *tempfile;
- char *tempfilename;
- int fixup_is_last_code = 0; /* 0 => no need to change any is_last flags */
- off_t fixup_is_last_flag_offset = -1;
-
- FLAC__ASSERT(0 != block || append == false);
-
- if(iterator->is_last) {
- if(append) {
- fixup_is_last_code = 1; /* 1 => clear the is_last flag at the following offset */
- fixup_is_last_flag_offset = iterator->offset[iterator->depth];
- }
- else if(0 == block) {
- simple_iterator_push_(iterator);
- if(!FLAC__metadata_simple_iterator_prev(iterator)) {
- (void)simple_iterator_pop_(iterator);
- return false;
- }
- fixup_is_last_code = -1; /* -1 => set the is_last the flag at the following offset */
- fixup_is_last_flag_offset = iterator->offset[iterator->depth];
- if(!simple_iterator_pop_(iterator))
- return false;
- }
- }
-
- if(!simple_iterator_copy_file_prefix_(iterator, &tempfile, &tempfilename, append))
- return false;
-
- if(0 != block) {
- if(!write_metadata_block_header_(tempfile, &iterator->status, block)) {
- cleanup_tempfile_(&tempfile, &tempfilename);
- return false;
- }
-
- if(!write_metadata_block_data_(tempfile, &iterator->status, block)) {
- cleanup_tempfile_(&tempfile, &tempfilename);
- return false;
- }
- }
-
- if(!simple_iterator_copy_file_postfix_(iterator, &tempfile, &tempfilename, fixup_is_last_code, fixup_is_last_flag_offset, block==0))
- return false;
-
- if(append)
- return FLAC__metadata_simple_iterator_next(iterator);
-
- return true;
-}
-
-void simple_iterator_push_(FLAC__Metadata_SimpleIterator *iterator)
-{
- FLAC__ASSERT(iterator->depth+1 < SIMPLE_ITERATOR_MAX_PUSH_DEPTH);
- iterator->offset[iterator->depth+1] = iterator->offset[iterator->depth];
- iterator->depth++;
-}
-
-FLAC__bool simple_iterator_pop_(FLAC__Metadata_SimpleIterator *iterator)
-{
- FLAC__ASSERT(iterator->depth > 0);
- iterator->depth--;
- if(0 != fseeko(iterator->file, iterator->offset[iterator->depth], SEEK_SET)) {
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR;
- return false;
- }
-
- return read_metadata_block_header_(iterator);
-}
-
-/* return meanings:
- * 0: ok
- * 1: read error
- * 2: seek error
- * 3: not a FLAC file
- */
-unsigned seek_to_first_metadata_block_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Seek seek_cb)
-{
- FLAC__byte buffer[4];
- size_t n;
- unsigned i;
-
- FLAC__ASSERT(FLAC__STREAM_SYNC_LENGTH == sizeof(buffer));
-
- /* skip any id3v2 tag */
- errno = 0;
- n = read_cb(buffer, 1, 4, handle);
- if(errno)
- return 1;
- else if(n != 4)
- return 3;
- else if(0 == memcmp(buffer, "ID3", 3)) {
- unsigned tag_length = 0;
-
- /* skip to the tag length */
- if(seek_cb(handle, 2, SEEK_CUR) < 0)
- return 2;
-
- /* read the length */
- for(i = 0; i < 4; i++) {
- if(read_cb(buffer, 1, 1, handle) < 1 || buffer[0] & 0x80)
- return 1;
- tag_length <<= 7;
- tag_length |= (buffer[0] & 0x7f);
- }
-
- /* skip the rest of the tag */
- if(seek_cb(handle, tag_length, SEEK_CUR) < 0)
- return 2;
-
- /* read the stream sync code */
- errno = 0;
- n = read_cb(buffer, 1, 4, handle);
- if(errno)
- return 1;
- else if(n != 4)
- return 3;
- }
-
- /* check for the fLaC signature */
- if(0 == memcmp(FLAC__STREAM_SYNC_STRING, buffer, FLAC__STREAM_SYNC_LENGTH))
- return 0;
- else
- return 3;
-}
-
-unsigned seek_to_first_metadata_block_(FILE *f)
-{
- return seek_to_first_metadata_block_cb_((FLAC__IOHandle)f, (FLAC__IOCallback_Read)fread, fseek_wrapper_);
-}
-
-FLAC__bool simple_iterator_copy_file_prefix_(FLAC__Metadata_SimpleIterator *iterator, FILE **tempfile, char **tempfilename, FLAC__bool append)
-{
- const off_t offset_end = append? iterator->offset[iterator->depth] + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH + (off_t)iterator->length : iterator->offset[iterator->depth];
-
- if(0 != fseeko(iterator->file, 0, SEEK_SET)) {
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR;
- return false;
- }
- if(!open_tempfile_(iterator->filename, iterator->tempfile_path_prefix, tempfile, tempfilename, &iterator->status)) {
- cleanup_tempfile_(tempfile, tempfilename);
- return false;
- }
- if(!copy_n_bytes_from_file_(iterator->file, *tempfile, offset_end, &iterator->status)) {
- cleanup_tempfile_(tempfile, tempfilename);
- return false;
- }
-
- return true;
-}
-
-FLAC__bool simple_iterator_copy_file_postfix_(FLAC__Metadata_SimpleIterator *iterator, FILE **tempfile, char **tempfilename, int fixup_is_last_code, off_t fixup_is_last_flag_offset, FLAC__bool backup)
-{
- off_t save_offset = iterator->offset[iterator->depth];
- FLAC__ASSERT(0 != *tempfile);
-
- if(0 != fseeko(iterator->file, save_offset + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH + (off_t)iterator->length, SEEK_SET)) {
- cleanup_tempfile_(tempfile, tempfilename);
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR;
- return false;
- }
- if(!copy_remaining_bytes_from_file_(iterator->file, *tempfile, &iterator->status)) {
- cleanup_tempfile_(tempfile, tempfilename);
- return false;
- }
-
- if(fixup_is_last_code != 0) {
- /*
- * if code == 1, it means a block was appended to the end so
- * we have to clear the is_last flag of the previous block
- * if code == -1, it means the last block was deleted so
- * we have to set the is_last flag of the previous block
- */
- /* MAGIC NUMBERs here; we know the is_last flag is the high bit of the byte at this location */
- FLAC__byte x;
- if(0 != fseeko(*tempfile, fixup_is_last_flag_offset, SEEK_SET)) {
- cleanup_tempfile_(tempfile, tempfilename);
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR;
- return false;
- }
- if(fread(&x, 1, 1, *tempfile) != 1) {
- cleanup_tempfile_(tempfile, tempfilename);
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- return false;
- }
- if(fixup_is_last_code > 0) {
- FLAC__ASSERT(x & 0x80);
- x &= 0x7f;
- }
- else {
- FLAC__ASSERT(!(x & 0x80));
- x |= 0x80;
- }
- if(0 != fseeko(*tempfile, fixup_is_last_flag_offset, SEEK_SET)) {
- cleanup_tempfile_(tempfile, tempfilename);
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR;
- return false;
- }
- if(local__fwrite(&x, 1, 1, *tempfile) != 1) {
- cleanup_tempfile_(tempfile, tempfilename);
- iterator->status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR;
- return false;
- }
- }
-
- (void)fclose(iterator->file);
-
- if(!transport_tempfile_(iterator->filename, tempfile, tempfilename, &iterator->status))
- return false;
-
- if(iterator->has_stats)
- set_file_stats_(iterator->filename, &iterator->stats);
-
- if(!simple_iterator_prime_input_(iterator, !iterator->is_writable))
- return false;
- if(backup) {
- while(iterator->offset[iterator->depth] + (off_t)FLAC__STREAM_METADATA_HEADER_LENGTH + (off_t)iterator->length < save_offset)
- if(!FLAC__metadata_simple_iterator_next(iterator))
- return false;
- return true;
- }
- else {
- /* move the iterator to it's original block faster by faking a push, then doing a pop_ */
- FLAC__ASSERT(iterator->depth == 0);
- iterator->offset[0] = save_offset;
- iterator->depth++;
- return simple_iterator_pop_(iterator);
- }
-}
-
-FLAC__bool copy_n_bytes_from_file_(FILE *file, FILE *tempfile, off_t bytes, FLAC__Metadata_SimpleIteratorStatus *status)
-{
- FLAC__byte buffer[8192];
- size_t n;
-
- FLAC__ASSERT(bytes >= 0);
- while(bytes > 0) {
- n = min(sizeof(buffer), (size_t)bytes);
- if(fread(buffer, 1, n, file) != n) {
- *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- return false;
- }
- if(local__fwrite(buffer, 1, n, tempfile) != n) {
- *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR;
- return false;
- }
- bytes -= n;
- }
-
- return true;
-}
-
-FLAC__bool copy_n_bytes_from_file_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOHandle temp_handle, FLAC__IOCallback_Write temp_write_cb, off_t bytes, FLAC__Metadata_SimpleIteratorStatus *status)
-{
- FLAC__byte buffer[8192];
- size_t n;
-
- FLAC__ASSERT(bytes >= 0);
- while(bytes > 0) {
- n = min(sizeof(buffer), (size_t)bytes);
- if(read_cb(buffer, 1, n, handle) != n) {
- *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- return false;
- }
- if(temp_write_cb(buffer, 1, n, temp_handle) != n) {
- *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR;
- return false;
- }
- bytes -= n;
- }
-
- return true;
-}
-
-FLAC__bool copy_remaining_bytes_from_file_(FILE *file, FILE *tempfile, FLAC__Metadata_SimpleIteratorStatus *status)
-{
- FLAC__byte buffer[8192];
- size_t n;
-
- while(!feof(file)) {
- n = fread(buffer, 1, sizeof(buffer), file);
- if(n == 0 && !feof(file)) {
- *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- return false;
- }
- if(n > 0 && local__fwrite(buffer, 1, n, tempfile) != n) {
- *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR;
- return false;
- }
- }
-
- return true;
-}
-
-FLAC__bool copy_remaining_bytes_from_file_cb_(FLAC__IOHandle handle, FLAC__IOCallback_Read read_cb, FLAC__IOCallback_Eof eof_cb, FLAC__IOHandle temp_handle, FLAC__IOCallback_Write temp_write_cb, FLAC__Metadata_SimpleIteratorStatus *status)
-{
- FLAC__byte buffer[8192];
- size_t n;
-
- while(!eof_cb(handle)) {
- n = read_cb(buffer, 1, sizeof(buffer), handle);
- if(n == 0 && !eof_cb(handle)) {
- *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR;
- return false;
- }
- if(n > 0 && temp_write_cb(buffer, 1, n, temp_handle) != n) {
- *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR;
- return false;
- }
- }
-
- return true;
-}
-
-FLAC__bool open_tempfile_(const char *filename, const char *tempfile_path_prefix, FILE **tempfile, char **tempfilename, FLAC__Metadata_SimpleIteratorStatus *status)
-{
- static const char *tempfile_suffix = ".metadata_edit";
- if(0 == tempfile_path_prefix) {
- if(0 == (*tempfilename = (char*)safe_malloc_add_3op_(strlen(filename), /*+*/strlen(tempfile_suffix), /*+*/1))) {
- *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR;
- return false;
- }
- strcpy(*tempfilename, filename);
- strcat(*tempfilename, tempfile_suffix);
- }
- else {
- const char *p = strrchr(filename, '/');
- if(0 == p)
- p = filename;
- else
- p++;
-
- if(0 == (*tempfilename = (char*)safe_malloc_add_4op_(strlen(tempfile_path_prefix), /*+*/strlen(p), /*+*/strlen(tempfile_suffix), /*+*/2))) {
- *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR;
- return false;
- }
- strcpy(*tempfilename, tempfile_path_prefix);
- strcat(*tempfilename, "/");
- strcat(*tempfilename, p);
- strcat(*tempfilename, tempfile_suffix);
- }
-
- if(0 == (*tempfile = fopen(*tempfilename, "w+b"))) {
- *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE;
- return false;
- }
-
- return true;
-}
-
-FLAC__bool transport_tempfile_(const char *filename, FILE **tempfile, char **tempfilename, FLAC__Metadata_SimpleIteratorStatus *status)
-{
- FLAC__ASSERT(0 != filename);
- FLAC__ASSERT(0 != tempfile);
- FLAC__ASSERT(0 != *tempfile);
- FLAC__ASSERT(0 != tempfilename);
- FLAC__ASSERT(0 != *tempfilename);
- FLAC__ASSERT(0 != status);
-
- (void)fclose(*tempfile);
- *tempfile = 0;
-
-#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ || defined __EMX__
- /* on some flavors of windows, rename() will fail if the destination already exists */
- if(unlink(filename) < 0) {
- cleanup_tempfile_(tempfile, tempfilename);
- *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_UNLINK_ERROR;
- return false;
- }
-#endif
-
- /*@@@ to fully support the tempfile_path_prefix we need to update this piece to actually copy across filesystems instead of just rename(): */
- if(0 != rename(*tempfilename, filename)) {
- cleanup_tempfile_(tempfile, tempfilename);
- *status = FLAC__METADATA_SIMPLE_ITERATOR_STATUS_RENAME_ERROR;
- return false;
- }
-
- cleanup_tempfile_(tempfile, tempfilename);
-
- return true;
-}
-
-void cleanup_tempfile_(FILE **tempfile, char **tempfilename)
-{
- if(0 != *tempfile) {
- (void)fclose(*tempfile);
- *tempfile = 0;
- }
-
- if(0 != *tempfilename) {
- (void)unlink(*tempfilename);
- free(*tempfilename);
- *tempfilename = 0;
- }
-}
-
-FLAC__bool get_file_stats_(const char *filename, struct stat *stats)
-{
- FLAC__ASSERT(0 != filename);
- FLAC__ASSERT(0 != stats);
- return (0 == stat(filename, stats));
-}
-
-void set_file_stats_(const char *filename, struct stat *stats)
-{
- struct utimbuf srctime;
-
- FLAC__ASSERT(0 != filename);
- FLAC__ASSERT(0 != stats);
-
- srctime.actime = stats->st_atime;
- srctime.modtime = stats->st_mtime;
- (void)chmod(filename, stats->st_mode);
- (void)utime(filename, &srctime);
-#if !defined _MSC_VER && !defined __BORLANDC__ && !defined __MINGW32__ && !defined __EMX__
- (void)chown(filename, stats->st_uid, -1);
- (void)chown(filename, -1, stats->st_gid);
-#endif
-}
-
-int fseek_wrapper_(FLAC__IOHandle handle, FLAC__int64 offset, int whence)
-{
- return fseeko((FILE*)handle, (off_t)offset, whence);
-}
-
-FLAC__int64 ftell_wrapper_(FLAC__IOHandle handle)
-{
- return ftello((FILE*)handle);
-}
-
-FLAC__Metadata_ChainStatus get_equivalent_status_(FLAC__Metadata_SimpleIteratorStatus status)
-{
- switch(status) {
- case FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK:
- return FLAC__METADATA_CHAIN_STATUS_OK;
- case FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT:
- return FLAC__METADATA_CHAIN_STATUS_ILLEGAL_INPUT;
- case FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE:
- return FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE;
- case FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_A_FLAC_FILE:
- return FLAC__METADATA_CHAIN_STATUS_NOT_A_FLAC_FILE;
- case FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_WRITABLE:
- return FLAC__METADATA_CHAIN_STATUS_NOT_WRITABLE;
- case FLAC__METADATA_SIMPLE_ITERATOR_STATUS_BAD_METADATA:
- return FLAC__METADATA_CHAIN_STATUS_BAD_METADATA;
- case FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR:
- return FLAC__METADATA_CHAIN_STATUS_READ_ERROR;
- case FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR:
- return FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR;
- case FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR:
- return FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR;
- case FLAC__METADATA_SIMPLE_ITERATOR_STATUS_RENAME_ERROR:
- return FLAC__METADATA_CHAIN_STATUS_RENAME_ERROR;
- case FLAC__METADATA_SIMPLE_ITERATOR_STATUS_UNLINK_ERROR:
- return FLAC__METADATA_CHAIN_STATUS_UNLINK_ERROR;
- case FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR:
- return FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR;
- case FLAC__METADATA_SIMPLE_ITERATOR_STATUS_INTERNAL_ERROR:
- default:
- return FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR;
- }
-}
diff --git a/src/thirdparty/libflac/src/libFLAC/metadata_object.c b/src/thirdparty/libflac/src/libFLAC/metadata_object.c
deleted file mode 100644
index e249e2289..000000000
--- a/src/thirdparty/libflac/src/libFLAC/metadata_object.c
+++ /dev/null
@@ -1,1824 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "private/metadata.h"
-
-#include "FLAC/assert.h"
-#include "share/alloc.h"
-
-
-/****************************************************************************
- *
- * Local routines
- *
- ***************************************************************************/
-
-/* copy bytes:
- * from = NULL && bytes = 0
- * to <- NULL
- * from != NULL && bytes > 0
- * to <- copy of from
- * else ASSERT
- * malloc error leaves 'to' unchanged
- */
-static FLAC__bool copy_bytes_(FLAC__byte **to, const FLAC__byte *from, unsigned bytes)
-{
- FLAC__ASSERT(0 != to);
- if(bytes > 0 && 0 != from) {
- FLAC__byte *x;
- if(0 == (x = (FLAC__byte*)safe_malloc_(bytes)))
- return false;
- memcpy(x, from, bytes);
- *to = x;
- }
- else {
- FLAC__ASSERT(0 == from);
- FLAC__ASSERT(bytes == 0);
- *to = 0;
- }
- return true;
-}
-
-#if 0 /* UNUSED */
-/* like copy_bytes_(), but free()s the original '*to' if the copy succeeds and the original '*to' is non-NULL */
-static FLAC__bool free_copy_bytes_(FLAC__byte **to, const FLAC__byte *from, unsigned bytes)
-{
- FLAC__byte *copy;
- FLAC__ASSERT(0 != to);
- if(copy_bytes_(&copy, from, bytes)) {
- if(*to)
- free(*to);
- *to = copy;
- return true;
- }
- else
- return false;
-}
-#endif
-
-/* reallocate entry to 1 byte larger and add a terminating NUL */
-/* realloc() failure leaves entry unchanged */
-static FLAC__bool ensure_null_terminated_(FLAC__byte **entry, unsigned length)
-{
- FLAC__byte *x = (FLAC__byte*)safe_realloc_add_2op_(*entry, length, /*+*/1);
- if(0 != x) {
- x[length] = '\0';
- *entry = x;
- return true;
- }
- else
- return false;
-}
-
-/* copies the NUL-terminated C-string 'from' to '*to', leaving '*to'
- * unchanged if malloc fails, free()ing the original '*to' if it
- * succeeds and the original '*to' was not NULL
- */
-static FLAC__bool copy_cstring_(char **to, const char *from)
-{
- char *copy = strdup(from);
- FLAC__ASSERT(to);
- if(copy) {
- if(*to)
- free(*to);
- *to = copy;
- return true;
- }
- else
- return false;
-}
-
-static FLAC__bool copy_vcentry_(FLAC__StreamMetadata_VorbisComment_Entry *to, const FLAC__StreamMetadata_VorbisComment_Entry *from)
-{
- to->length = from->length;
- if(0 == from->entry) {
- FLAC__ASSERT(from->length == 0);
- to->entry = 0;
- }
- else {
- FLAC__byte *x;
- FLAC__ASSERT(from->length > 0);
- if(0 == (x = (FLAC__byte*)safe_malloc_add_2op_(from->length, /*+*/1)))
- return false;
- memcpy(x, from->entry, from->length);
- x[from->length] = '\0';
- to->entry = x;
- }
- return true;
-}
-
-static FLAC__bool copy_track_(FLAC__StreamMetadata_CueSheet_Track *to, const FLAC__StreamMetadata_CueSheet_Track *from)
-{
- memcpy(to, from, sizeof(FLAC__StreamMetadata_CueSheet_Track));
- if(0 == from->indices) {
- FLAC__ASSERT(from->num_indices == 0);
- }
- else {
- FLAC__StreamMetadata_CueSheet_Index *x;
- FLAC__ASSERT(from->num_indices > 0);
- if(0 == (x = (FLAC__StreamMetadata_CueSheet_Index*)safe_malloc_mul_2op_(from->num_indices, /*times*/sizeof(FLAC__StreamMetadata_CueSheet_Index))))
- return false;
- memcpy(x, from->indices, from->num_indices * sizeof(FLAC__StreamMetadata_CueSheet_Index));
- to->indices = x;
- }
- return true;
-}
-
-static void seektable_calculate_length_(FLAC__StreamMetadata *object)
-{
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE);
-
- object->length = object->data.seek_table.num_points * FLAC__STREAM_METADATA_SEEKPOINT_LENGTH;
-}
-
-static FLAC__StreamMetadata_SeekPoint *seekpoint_array_new_(unsigned num_points)
-{
- FLAC__StreamMetadata_SeekPoint *object_array;
-
- FLAC__ASSERT(num_points > 0);
-
- object_array = (FLAC__StreamMetadata_SeekPoint*)safe_malloc_mul_2op_(num_points, /*times*/sizeof(FLAC__StreamMetadata_SeekPoint));
-
- if(0 != object_array) {
- unsigned i;
- for(i = 0; i < num_points; i++) {
- object_array[i].sample_number = FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER;
- object_array[i].stream_offset = 0;
- object_array[i].frame_samples = 0;
- }
- }
-
- return object_array;
-}
-
-static void vorbiscomment_calculate_length_(FLAC__StreamMetadata *object)
-{
- unsigned i;
-
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT);
-
- object->length = (FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN) / 8;
- object->length += object->data.vorbis_comment.vendor_string.length;
- object->length += (FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN) / 8;
- for(i = 0; i < object->data.vorbis_comment.num_comments; i++) {
- object->length += (FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN / 8);
- object->length += object->data.vorbis_comment.comments[i].length;
- }
-}
-
-static FLAC__StreamMetadata_VorbisComment_Entry *vorbiscomment_entry_array_new_(unsigned num_comments)
-{
- FLAC__ASSERT(num_comments > 0);
-
- return (FLAC__StreamMetadata_VorbisComment_Entry*)safe_calloc_(num_comments, sizeof(FLAC__StreamMetadata_VorbisComment_Entry));
-}
-
-static void vorbiscomment_entry_array_delete_(FLAC__StreamMetadata_VorbisComment_Entry *object_array, unsigned num_comments)
-{
- unsigned i;
-
- FLAC__ASSERT(0 != object_array && num_comments > 0);
-
- for(i = 0; i < num_comments; i++)
- if(0 != object_array[i].entry)
- free(object_array[i].entry);
-
- if(0 != object_array)
- free(object_array);
-}
-
-static FLAC__StreamMetadata_VorbisComment_Entry *vorbiscomment_entry_array_copy_(const FLAC__StreamMetadata_VorbisComment_Entry *object_array, unsigned num_comments)
-{
- FLAC__StreamMetadata_VorbisComment_Entry *return_array;
-
- FLAC__ASSERT(0 != object_array);
- FLAC__ASSERT(num_comments > 0);
-
- return_array = vorbiscomment_entry_array_new_(num_comments);
-
- if(0 != return_array) {
- unsigned i;
-
- for(i = 0; i < num_comments; i++) {
- if(!copy_vcentry_(return_array+i, object_array+i)) {
- vorbiscomment_entry_array_delete_(return_array, num_comments);
- return 0;
- }
- }
- }
-
- return return_array;
-}
-
-static FLAC__bool vorbiscomment_set_entry_(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry *dest, const FLAC__StreamMetadata_VorbisComment_Entry *src, FLAC__bool copy)
-{
- FLAC__byte *save;
-
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(0 != dest);
- FLAC__ASSERT(0 != src);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT);
- FLAC__ASSERT((0 != src->entry && src->length > 0) || (0 == src->entry && src->length == 0));
-
- save = dest->entry;
-
- if(0 != src->entry && src->length > 0) {
- if(copy) {
- /* do the copy first so that if we fail we leave the dest object untouched */
- if(!copy_vcentry_(dest, src))
- return false;
- }
- else {
- /* we have to make sure that the string we're taking over is null-terminated */
-
- /*
- * Stripping the const from src->entry is OK since we're taking
- * ownership of the pointer. This is a hack around a deficiency
- * in the API where the same function is used for 'copy' and
- * 'own', but the source entry is a const pointer. If we were
- * precise, the 'own' flavor would be a separate function with a
- * non-const source pointer. But it's not, so we hack away.
- */
- if(!ensure_null_terminated_((FLAC__byte**)(&src->entry), src->length))
- return false;
- *dest = *src;
- }
- }
- else {
- /* the src is null */
- *dest = *src;
- }
-
- if(0 != save)
- free(save);
-
- vorbiscomment_calculate_length_(object);
- return true;
-}
-
-static int vorbiscomment_find_entry_from_(const FLAC__StreamMetadata *object, unsigned offset, const char *field_name, unsigned field_name_length)
-{
- unsigned i;
-
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT);
- FLAC__ASSERT(0 != field_name);
-
- for(i = offset; i < object->data.vorbis_comment.num_comments; i++) {
- if(FLAC__metadata_object_vorbiscomment_entry_matches(object->data.vorbis_comment.comments[i], field_name, field_name_length))
- return (int)i;
- }
-
- return -1;
-}
-
-static void cuesheet_calculate_length_(FLAC__StreamMetadata *object)
-{
- unsigned i;
-
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_CUESHEET);
-
- object->length = (
- FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN +
- FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN +
- FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN +
- FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN +
- FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN
- ) / 8;
-
- object->length += object->data.cue_sheet.num_tracks * (
- FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN +
- FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN +
- FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN +
- FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN +
- FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN +
- FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN +
- FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN
- ) / 8;
-
- for(i = 0; i < object->data.cue_sheet.num_tracks; i++) {
- object->length += object->data.cue_sheet.tracks[i].num_indices * (
- FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN +
- FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN +
- FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN
- ) / 8;
- }
-}
-
-static FLAC__StreamMetadata_CueSheet_Index *cuesheet_track_index_array_new_(unsigned num_indices)
-{
- FLAC__ASSERT(num_indices > 0);
-
- return (FLAC__StreamMetadata_CueSheet_Index*)safe_calloc_(num_indices, sizeof(FLAC__StreamMetadata_CueSheet_Index));
-}
-
-static FLAC__StreamMetadata_CueSheet_Track *cuesheet_track_array_new_(unsigned num_tracks)
-{
- FLAC__ASSERT(num_tracks > 0);
-
- return (FLAC__StreamMetadata_CueSheet_Track*)safe_calloc_(num_tracks, sizeof(FLAC__StreamMetadata_CueSheet_Track));
-}
-
-static void cuesheet_track_array_delete_(FLAC__StreamMetadata_CueSheet_Track *object_array, unsigned num_tracks)
-{
- unsigned i;
-
- FLAC__ASSERT(0 != object_array && num_tracks > 0);
-
- for(i = 0; i < num_tracks; i++) {
- if(0 != object_array[i].indices) {
- FLAC__ASSERT(object_array[i].num_indices > 0);
- free(object_array[i].indices);
- }
- }
-
- if(0 != object_array)
- free(object_array);
-}
-
-static FLAC__StreamMetadata_CueSheet_Track *cuesheet_track_array_copy_(const FLAC__StreamMetadata_CueSheet_Track *object_array, unsigned num_tracks)
-{
- FLAC__StreamMetadata_CueSheet_Track *return_array;
-
- FLAC__ASSERT(0 != object_array);
- FLAC__ASSERT(num_tracks > 0);
-
- return_array = cuesheet_track_array_new_(num_tracks);
-
- if(0 != return_array) {
- unsigned i;
-
- for(i = 0; i < num_tracks; i++) {
- if(!copy_track_(return_array+i, object_array+i)) {
- cuesheet_track_array_delete_(return_array, num_tracks);
- return 0;
- }
- }
- }
-
- return return_array;
-}
-
-static FLAC__bool cuesheet_set_track_(FLAC__StreamMetadata *object, FLAC__StreamMetadata_CueSheet_Track *dest, const FLAC__StreamMetadata_CueSheet_Track *src, FLAC__bool copy)
-{
- FLAC__StreamMetadata_CueSheet_Index *save;
-
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(0 != dest);
- FLAC__ASSERT(0 != src);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_CUESHEET);
- FLAC__ASSERT((0 != src->indices && src->num_indices > 0) || (0 == src->indices && src->num_indices == 0));
-
- save = dest->indices;
-
- /* do the copy first so that if we fail we leave the object untouched */
- if(copy) {
- if(!copy_track_(dest, src))
- return false;
- }
- else {
- *dest = *src;
- }
-
- if(0 != save)
- free(save);
-
- cuesheet_calculate_length_(object);
- return true;
-}
-
-
-/****************************************************************************
- *
- * Metadata object routines
- *
- ***************************************************************************/
-
-FLAC_API FLAC__StreamMetadata *FLAC__metadata_object_new(FLAC__MetadataType type)
-{
- FLAC__StreamMetadata *object;
-
- if(type > FLAC__MAX_METADATA_TYPE_CODE)
- return 0;
-
- object = (FLAC__StreamMetadata*)calloc(1, sizeof(FLAC__StreamMetadata));
- if(0 != object) {
- object->is_last = false;
- object->type = type;
- switch(type) {
- case FLAC__METADATA_TYPE_STREAMINFO:
- object->length = FLAC__STREAM_METADATA_STREAMINFO_LENGTH;
- break;
- case FLAC__METADATA_TYPE_PADDING:
- /* calloc() took care of this for us:
- object->length = 0;
- */
- break;
- case FLAC__METADATA_TYPE_APPLICATION:
- object->length = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8;
- /* calloc() took care of this for us:
- object->data.application.data = 0;
- */
- break;
- case FLAC__METADATA_TYPE_SEEKTABLE:
- /* calloc() took care of this for us:
- object->length = 0;
- object->data.seek_table.num_points = 0;
- object->data.seek_table.points = 0;
- */
- break;
- case FLAC__METADATA_TYPE_VORBIS_COMMENT:
- object->data.vorbis_comment.vendor_string.length = (unsigned)strlen(FLAC__VENDOR_STRING);
- if(!copy_bytes_(&object->data.vorbis_comment.vendor_string.entry, (const FLAC__byte*)FLAC__VENDOR_STRING, object->data.vorbis_comment.vendor_string.length+1)) {
- free(object);
- return 0;
- }
- vorbiscomment_calculate_length_(object);
- break;
- case FLAC__METADATA_TYPE_CUESHEET:
- cuesheet_calculate_length_(object);
- break;
- case FLAC__METADATA_TYPE_PICTURE:
- object->length = (
- FLAC__STREAM_METADATA_PICTURE_TYPE_LEN +
- FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN + /* empty mime_type string */
- FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN + /* empty description string */
- FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN +
- FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN +
- FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN +
- FLAC__STREAM_METADATA_PICTURE_COLORS_LEN +
- FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN +
- 0 /* no data */
- ) / 8;
- object->data.picture.type = FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER;
- object->data.picture.mime_type = 0;
- object->data.picture.description = 0;
- /* calloc() took care of this for us:
- object->data.picture.width = 0;
- object->data.picture.height = 0;
- object->data.picture.depth = 0;
- object->data.picture.colors = 0;
- object->data.picture.data_length = 0;
- object->data.picture.data = 0;
- */
- /* now initialize mime_type and description with empty strings to make things easier on the client */
- if(!copy_cstring_(&object->data.picture.mime_type, "")) {
- free(object);
- return 0;
- }
- if(!copy_cstring_((char**)(&object->data.picture.description), "")) {
- if(object->data.picture.mime_type)
- free(object->data.picture.mime_type);
- free(object);
- return 0;
- }
- break;
- default:
- /* calloc() took care of this for us:
- object->length = 0;
- object->data.unknown.data = 0;
- */
- break;
- }
- }
-
- return object;
-}
-
-FLAC_API FLAC__StreamMetadata *FLAC__metadata_object_clone(const FLAC__StreamMetadata *object)
-{
- FLAC__StreamMetadata *to;
-
- FLAC__ASSERT(0 != object);
-
- if(0 != (to = FLAC__metadata_object_new(object->type))) {
- to->is_last = object->is_last;
- to->type = object->type;
- to->length = object->length;
- switch(to->type) {
- case FLAC__METADATA_TYPE_STREAMINFO:
- memcpy(&to->data.stream_info, &object->data.stream_info, sizeof(FLAC__StreamMetadata_StreamInfo));
- break;
- case FLAC__METADATA_TYPE_PADDING:
- break;
- case FLAC__METADATA_TYPE_APPLICATION:
- if(to->length < FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8) { /* underflow check */
- FLAC__metadata_object_delete(to);
- return 0;
- }
- memcpy(&to->data.application.id, &object->data.application.id, FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8);
- if(!copy_bytes_(&to->data.application.data, object->data.application.data, object->length - FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8)) {
- FLAC__metadata_object_delete(to);
- return 0;
- }
- break;
- case FLAC__METADATA_TYPE_SEEKTABLE:
- to->data.seek_table.num_points = object->data.seek_table.num_points;
- if(to->data.seek_table.num_points > SIZE_MAX / sizeof(FLAC__StreamMetadata_SeekPoint)) { /* overflow check */
- FLAC__metadata_object_delete(to);
- return 0;
- }
- if(!copy_bytes_((FLAC__byte**)&to->data.seek_table.points, (FLAC__byte*)object->data.seek_table.points, object->data.seek_table.num_points * sizeof(FLAC__StreamMetadata_SeekPoint))) {
- FLAC__metadata_object_delete(to);
- return 0;
- }
- break;
- case FLAC__METADATA_TYPE_VORBIS_COMMENT:
- if(0 != to->data.vorbis_comment.vendor_string.entry) {
- free(to->data.vorbis_comment.vendor_string.entry);
- to->data.vorbis_comment.vendor_string.entry = 0;
- }
- if(!copy_vcentry_(&to->data.vorbis_comment.vendor_string, &object->data.vorbis_comment.vendor_string)) {
- FLAC__metadata_object_delete(to);
- return 0;
- }
- if(object->data.vorbis_comment.num_comments == 0) {
- FLAC__ASSERT(0 == object->data.vorbis_comment.comments);
- to->data.vorbis_comment.comments = 0;
- }
- else {
- FLAC__ASSERT(0 != object->data.vorbis_comment.comments);
- to->data.vorbis_comment.comments = vorbiscomment_entry_array_copy_(object->data.vorbis_comment.comments, object->data.vorbis_comment.num_comments);
- if(0 == to->data.vorbis_comment.comments) {
- FLAC__metadata_object_delete(to);
- return 0;
- }
- }
- to->data.vorbis_comment.num_comments = object->data.vorbis_comment.num_comments;
- break;
- case FLAC__METADATA_TYPE_CUESHEET:
- memcpy(&to->data.cue_sheet, &object->data.cue_sheet, sizeof(FLAC__StreamMetadata_CueSheet));
- if(object->data.cue_sheet.num_tracks == 0) {
- FLAC__ASSERT(0 == object->data.cue_sheet.tracks);
- }
- else {
- FLAC__ASSERT(0 != object->data.cue_sheet.tracks);
- to->data.cue_sheet.tracks = cuesheet_track_array_copy_(object->data.cue_sheet.tracks, object->data.cue_sheet.num_tracks);
- if(0 == to->data.cue_sheet.tracks) {
- FLAC__metadata_object_delete(to);
- return 0;
- }
- }
- break;
- case FLAC__METADATA_TYPE_PICTURE:
- to->data.picture.type = object->data.picture.type;
- if(!copy_cstring_(&to->data.picture.mime_type, object->data.picture.mime_type)) {
- FLAC__metadata_object_delete(to);
- return 0;
- }
- if(!copy_cstring_((char**)(&to->data.picture.description), (const char*)object->data.picture.description)) {
- FLAC__metadata_object_delete(to);
- return 0;
- }
- to->data.picture.width = object->data.picture.width;
- to->data.picture.height = object->data.picture.height;
- to->data.picture.depth = object->data.picture.depth;
- to->data.picture.colors = object->data.picture.colors;
- to->data.picture.data_length = object->data.picture.data_length;
- if(!copy_bytes_((&to->data.picture.data), object->data.picture.data, object->data.picture.data_length)) {
- FLAC__metadata_object_delete(to);
- return 0;
- }
- break;
- default:
- if(!copy_bytes_(&to->data.unknown.data, object->data.unknown.data, object->length)) {
- FLAC__metadata_object_delete(to);
- return 0;
- }
- break;
- }
- }
-
- return to;
-}
-
-void FLAC__metadata_object_delete_data(FLAC__StreamMetadata *object)
-{
- FLAC__ASSERT(0 != object);
-
- switch(object->type) {
- case FLAC__METADATA_TYPE_STREAMINFO:
- case FLAC__METADATA_TYPE_PADDING:
- break;
- case FLAC__METADATA_TYPE_APPLICATION:
- if(0 != object->data.application.data) {
- free(object->data.application.data);
- object->data.application.data = 0;
- }
- break;
- case FLAC__METADATA_TYPE_SEEKTABLE:
- if(0 != object->data.seek_table.points) {
- free(object->data.seek_table.points);
- object->data.seek_table.points = 0;
- }
- break;
- case FLAC__METADATA_TYPE_VORBIS_COMMENT:
- if(0 != object->data.vorbis_comment.vendor_string.entry) {
- free(object->data.vorbis_comment.vendor_string.entry);
- object->data.vorbis_comment.vendor_string.entry = 0;
- }
- if(0 != object->data.vorbis_comment.comments) {
- FLAC__ASSERT(object->data.vorbis_comment.num_comments > 0);
- vorbiscomment_entry_array_delete_(object->data.vorbis_comment.comments, object->data.vorbis_comment.num_comments);
- }
- break;
- case FLAC__METADATA_TYPE_CUESHEET:
- if(0 != object->data.cue_sheet.tracks) {
- FLAC__ASSERT(object->data.cue_sheet.num_tracks > 0);
- cuesheet_track_array_delete_(object->data.cue_sheet.tracks, object->data.cue_sheet.num_tracks);
- }
- break;
- case FLAC__METADATA_TYPE_PICTURE:
- if(0 != object->data.picture.mime_type) {
- free(object->data.picture.mime_type);
- object->data.picture.mime_type = 0;
- }
- if(0 != object->data.picture.description) {
- free(object->data.picture.description);
- object->data.picture.description = 0;
- }
- if(0 != object->data.picture.data) {
- free(object->data.picture.data);
- object->data.picture.data = 0;
- }
- break;
- default:
- if(0 != object->data.unknown.data) {
- free(object->data.unknown.data);
- object->data.unknown.data = 0;
- }
- break;
- }
-}
-
-FLAC_API void FLAC__metadata_object_delete(FLAC__StreamMetadata *object)
-{
- FLAC__metadata_object_delete_data(object);
- free(object);
-}
-
-static FLAC__bool compare_block_data_streaminfo_(const FLAC__StreamMetadata_StreamInfo *block1, const FLAC__StreamMetadata_StreamInfo *block2)
-{
- if(block1->min_blocksize != block2->min_blocksize)
- return false;
- if(block1->max_blocksize != block2->max_blocksize)
- return false;
- if(block1->min_framesize != block2->min_framesize)
- return false;
- if(block1->max_framesize != block2->max_framesize)
- return false;
- if(block1->sample_rate != block2->sample_rate)
- return false;
- if(block1->channels != block2->channels)
- return false;
- if(block1->bits_per_sample != block2->bits_per_sample)
- return false;
- if(block1->total_samples != block2->total_samples)
- return false;
- if(0 != memcmp(block1->md5sum, block2->md5sum, 16))
- return false;
- return true;
-}
-
-static FLAC__bool compare_block_data_application_(const FLAC__StreamMetadata_Application *block1, const FLAC__StreamMetadata_Application *block2, unsigned block_length)
-{
- FLAC__ASSERT(0 != block1);
- FLAC__ASSERT(0 != block2);
- FLAC__ASSERT(block_length >= sizeof(block1->id));
-
- if(0 != memcmp(block1->id, block2->id, sizeof(block1->id)))
- return false;
- if(0 != block1->data && 0 != block2->data)
- return 0 == memcmp(block1->data, block2->data, block_length - sizeof(block1->id));
- else
- return block1->data == block2->data;
-}
-
-static FLAC__bool compare_block_data_seektable_(const FLAC__StreamMetadata_SeekTable *block1, const FLAC__StreamMetadata_SeekTable *block2)
-{
- unsigned i;
-
- FLAC__ASSERT(0 != block1);
- FLAC__ASSERT(0 != block2);
-
- if(block1->num_points != block2->num_points)
- return false;
-
- if(0 != block1->points && 0 != block2->points) {
- for(i = 0; i < block1->num_points; i++) {
- if(block1->points[i].sample_number != block2->points[i].sample_number)
- return false;
- if(block1->points[i].stream_offset != block2->points[i].stream_offset)
- return false;
- if(block1->points[i].frame_samples != block2->points[i].frame_samples)
- return false;
- }
- return true;
- }
- else
- return block1->points == block2->points;
-}
-
-static FLAC__bool compare_block_data_vorbiscomment_(const FLAC__StreamMetadata_VorbisComment *block1, const FLAC__StreamMetadata_VorbisComment *block2)
-{
- unsigned i;
-
- if(block1->vendor_string.length != block2->vendor_string.length)
- return false;
-
- if(0 != block1->vendor_string.entry && 0 != block2->vendor_string.entry) {
- if(0 != memcmp(block1->vendor_string.entry, block2->vendor_string.entry, block1->vendor_string.length))
- return false;
- }
- else if(block1->vendor_string.entry != block2->vendor_string.entry)
- return false;
-
- if(block1->num_comments != block2->num_comments)
- return false;
-
- for(i = 0; i < block1->num_comments; i++) {
- if(0 != block1->comments[i].entry && 0 != block2->comments[i].entry) {
- if(0 != memcmp(block1->comments[i].entry, block2->comments[i].entry, block1->comments[i].length))
- return false;
- }
- else if(block1->comments[i].entry != block2->comments[i].entry)
- return false;
- }
- return true;
-}
-
-static FLAC__bool compare_block_data_cuesheet_(const FLAC__StreamMetadata_CueSheet *block1, const FLAC__StreamMetadata_CueSheet *block2)
-{
- unsigned i, j;
-
- if(0 != strcmp(block1->media_catalog_number, block2->media_catalog_number))
- return false;
-
- if(block1->lead_in != block2->lead_in)
- return false;
-
- if(block1->is_cd != block2->is_cd)
- return false;
-
- if(block1->num_tracks != block2->num_tracks)
- return false;
-
- if(0 != block1->tracks && 0 != block2->tracks) {
- FLAC__ASSERT(block1->num_tracks > 0);
- for(i = 0; i < block1->num_tracks; i++) {
- if(block1->tracks[i].offset != block2->tracks[i].offset)
- return false;
- if(block1->tracks[i].number != block2->tracks[i].number)
- return false;
- if(0 != memcmp(block1->tracks[i].isrc, block2->tracks[i].isrc, sizeof(block1->tracks[i].isrc)))
- return false;
- if(block1->tracks[i].type != block2->tracks[i].type)
- return false;
- if(block1->tracks[i].pre_emphasis != block2->tracks[i].pre_emphasis)
- return false;
- if(block1->tracks[i].num_indices != block2->tracks[i].num_indices)
- return false;
- if(0 != block1->tracks[i].indices && 0 != block2->tracks[i].indices) {
- FLAC__ASSERT(block1->tracks[i].num_indices > 0);
- for(j = 0; j < block1->tracks[i].num_indices; j++) {
- if(block1->tracks[i].indices[j].offset != block2->tracks[i].indices[j].offset)
- return false;
- if(block1->tracks[i].indices[j].number != block2->tracks[i].indices[j].number)
- return false;
- }
- }
- else if(block1->tracks[i].indices != block2->tracks[i].indices)
- return false;
- }
- }
- else if(block1->tracks != block2->tracks)
- return false;
- return true;
-}
-
-static FLAC__bool compare_block_data_picture_(const FLAC__StreamMetadata_Picture *block1, const FLAC__StreamMetadata_Picture *block2)
-{
- if(block1->type != block2->type)
- return false;
- if(block1->mime_type != block2->mime_type && (0 == block1->mime_type || 0 == block2->mime_type || strcmp(block1->mime_type, block2->mime_type)))
- return false;
- if(block1->description != block2->description && (0 == block1->description || 0 == block2->description || strcmp((const char *)block1->description, (const char *)block2->description)))
- return false;
- if(block1->width != block2->width)
- return false;
- if(block1->height != block2->height)
- return false;
- if(block1->depth != block2->depth)
- return false;
- if(block1->colors != block2->colors)
- return false;
- if(block1->data_length != block2->data_length)
- return false;
- if(block1->data != block2->data && (0 == block1->data || 0 == block2->data || memcmp(block1->data, block2->data, block1->data_length)))
- return false;
- return true;
-}
-
-static FLAC__bool compare_block_data_unknown_(const FLAC__StreamMetadata_Unknown *block1, const FLAC__StreamMetadata_Unknown *block2, unsigned block_length)
-{
- FLAC__ASSERT(0 != block1);
- FLAC__ASSERT(0 != block2);
-
- if(0 != block1->data && 0 != block2->data)
- return 0 == memcmp(block1->data, block2->data, block_length);
- else
- return block1->data == block2->data;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_is_equal(const FLAC__StreamMetadata *block1, const FLAC__StreamMetadata *block2)
-{
- FLAC__ASSERT(0 != block1);
- FLAC__ASSERT(0 != block2);
-
- if(block1->type != block2->type) {
- return false;
- }
- if(block1->is_last != block2->is_last) {
- return false;
- }
- if(block1->length != block2->length) {
- return false;
- }
- switch(block1->type) {
- case FLAC__METADATA_TYPE_STREAMINFO:
- return compare_block_data_streaminfo_(&block1->data.stream_info, &block2->data.stream_info);
- case FLAC__METADATA_TYPE_PADDING:
- return true; /* we don't compare the padding guts */
- case FLAC__METADATA_TYPE_APPLICATION:
- return compare_block_data_application_(&block1->data.application, &block2->data.application, block1->length);
- case FLAC__METADATA_TYPE_SEEKTABLE:
- return compare_block_data_seektable_(&block1->data.seek_table, &block2->data.seek_table);
- case FLAC__METADATA_TYPE_VORBIS_COMMENT:
- return compare_block_data_vorbiscomment_(&block1->data.vorbis_comment, &block2->data.vorbis_comment);
- case FLAC__METADATA_TYPE_CUESHEET:
- return compare_block_data_cuesheet_(&block1->data.cue_sheet, &block2->data.cue_sheet);
- case FLAC__METADATA_TYPE_PICTURE:
- return compare_block_data_picture_(&block1->data.picture, &block2->data.picture);
- default:
- return compare_block_data_unknown_(&block1->data.unknown, &block2->data.unknown, block1->length);
- }
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_application_set_data(FLAC__StreamMetadata *object, FLAC__byte *data, unsigned length, FLAC__bool copy)
-{
- FLAC__byte *save;
-
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_APPLICATION);
- FLAC__ASSERT((0 != data && length > 0) || (0 == data && length == 0 && copy == false));
-
- save = object->data.application.data;
-
- /* do the copy first so that if we fail we leave the object untouched */
- if(copy) {
- if(!copy_bytes_(&object->data.application.data, data, length))
- return false;
- }
- else {
- object->data.application.data = data;
- }
-
- if(0 != save)
- free(save);
-
- object->length = FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8 + length;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_seektable_resize_points(FLAC__StreamMetadata *object, unsigned new_num_points)
-{
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE);
-
- if(0 == object->data.seek_table.points) {
- FLAC__ASSERT(object->data.seek_table.num_points == 0);
- if(0 == new_num_points)
- return true;
- else if(0 == (object->data.seek_table.points = seekpoint_array_new_(new_num_points)))
- return false;
- }
- else {
- const size_t old_size = object->data.seek_table.num_points * sizeof(FLAC__StreamMetadata_SeekPoint);
- const size_t new_size = new_num_points * sizeof(FLAC__StreamMetadata_SeekPoint);
-
- /* overflow check */
- if((size_t)new_num_points > SIZE_MAX / sizeof(FLAC__StreamMetadata_SeekPoint))
- return false;
-
- FLAC__ASSERT(object->data.seek_table.num_points > 0);
-
- if(new_size == 0) {
- free(object->data.seek_table.points);
- object->data.seek_table.points = 0;
- }
- else if(0 == (object->data.seek_table.points = (FLAC__StreamMetadata_SeekPoint*)realloc(object->data.seek_table.points, new_size)))
- return false;
-
- /* if growing, set new elements to placeholders */
- if(new_size > old_size) {
- unsigned i;
- for(i = object->data.seek_table.num_points; i < new_num_points; i++) {
- object->data.seek_table.points[i].sample_number = FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER;
- object->data.seek_table.points[i].stream_offset = 0;
- object->data.seek_table.points[i].frame_samples = 0;
- }
- }
- }
-
- object->data.seek_table.num_points = new_num_points;
-
- seektable_calculate_length_(object);
- return true;
-}
-
-FLAC_API void FLAC__metadata_object_seektable_set_point(FLAC__StreamMetadata *object, unsigned point_num, FLAC__StreamMetadata_SeekPoint point)
-{
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE);
- FLAC__ASSERT(point_num < object->data.seek_table.num_points);
-
- object->data.seek_table.points[point_num] = point;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_seektable_insert_point(FLAC__StreamMetadata *object, unsigned point_num, FLAC__StreamMetadata_SeekPoint point)
-{
- int i;
-
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE);
- FLAC__ASSERT(point_num <= object->data.seek_table.num_points);
-
- if(!FLAC__metadata_object_seektable_resize_points(object, object->data.seek_table.num_points+1))
- return false;
-
- /* move all points >= point_num forward one space */
- for(i = (int)object->data.seek_table.num_points-1; i > (int)point_num; i--)
- object->data.seek_table.points[i] = object->data.seek_table.points[i-1];
-
- FLAC__metadata_object_seektable_set_point(object, point_num, point);
- seektable_calculate_length_(object);
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_seektable_delete_point(FLAC__StreamMetadata *object, unsigned point_num)
-{
- unsigned i;
-
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE);
- FLAC__ASSERT(point_num < object->data.seek_table.num_points);
-
- /* move all points > point_num backward one space */
- for(i = point_num; i < object->data.seek_table.num_points-1; i++)
- object->data.seek_table.points[i] = object->data.seek_table.points[i+1];
-
- return FLAC__metadata_object_seektable_resize_points(object, object->data.seek_table.num_points-1);
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_seektable_is_legal(const FLAC__StreamMetadata *object)
-{
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE);
-
- return FLAC__format_seektable_is_legal(&object->data.seek_table);
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_placeholders(FLAC__StreamMetadata *object, unsigned num)
-{
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE);
-
- if(num > 0)
- /* WATCHOUT: we rely on the fact that growing the array adds PLACEHOLDERS at the end */
- return FLAC__metadata_object_seektable_resize_points(object, object->data.seek_table.num_points + num);
- else
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_point(FLAC__StreamMetadata *object, FLAC__uint64 sample_number)
-{
- FLAC__StreamMetadata_SeekTable *seek_table;
-
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE);
-
- seek_table = &object->data.seek_table;
-
- if(!FLAC__metadata_object_seektable_resize_points(object, seek_table->num_points + 1))
- return false;
-
- seek_table->points[seek_table->num_points - 1].sample_number = sample_number;
- seek_table->points[seek_table->num_points - 1].stream_offset = 0;
- seek_table->points[seek_table->num_points - 1].frame_samples = 0;
-
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_points(FLAC__StreamMetadata *object, FLAC__uint64 sample_numbers[], unsigned num)
-{
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE);
- FLAC__ASSERT(0 != sample_numbers || num == 0);
-
- if(num > 0) {
- FLAC__StreamMetadata_SeekTable *seek_table = &object->data.seek_table;
- unsigned i, j;
-
- i = seek_table->num_points;
-
- if(!FLAC__metadata_object_seektable_resize_points(object, seek_table->num_points + num))
- return false;
-
- for(j = 0; j < num; i++, j++) {
- seek_table->points[i].sample_number = sample_numbers[j];
- seek_table->points[i].stream_offset = 0;
- seek_table->points[i].frame_samples = 0;
- }
- }
-
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_points(FLAC__StreamMetadata *object, unsigned num, FLAC__uint64 total_samples)
-{
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE);
- FLAC__ASSERT(total_samples > 0);
-
- if(num > 0 && total_samples > 0) {
- FLAC__StreamMetadata_SeekTable *seek_table = &object->data.seek_table;
- unsigned i, j;
-
- i = seek_table->num_points;
-
- if(!FLAC__metadata_object_seektable_resize_points(object, seek_table->num_points + num))
- return false;
-
- for(j = 0; j < num; i++, j++) {
- seek_table->points[i].sample_number = total_samples * (FLAC__uint64)j / (FLAC__uint64)num;
- seek_table->points[i].stream_offset = 0;
- seek_table->points[i].frame_samples = 0;
- }
- }
-
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(FLAC__StreamMetadata *object, unsigned samples, FLAC__uint64 total_samples)
-{
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE);
- FLAC__ASSERT(samples > 0);
- FLAC__ASSERT(total_samples > 0);
-
- if(samples > 0 && total_samples > 0) {
- FLAC__StreamMetadata_SeekTable *seek_table = &object->data.seek_table;
- unsigned i, j;
- FLAC__uint64 num, sample;
-
- num = 1 + total_samples / samples; /* 1+ for the first sample at 0 */
- /* now account for the fact that we don't place a seekpoint at "total_samples" since samples are number from 0: */
- if(total_samples % samples == 0)
- num--;
-
- i = seek_table->num_points;
-
- if(!FLAC__metadata_object_seektable_resize_points(object, seek_table->num_points + (unsigned)num))
- return false;
-
- sample = 0;
- for(j = 0; j < num; i++, j++, sample += samples) {
- seek_table->points[i].sample_number = sample;
- seek_table->points[i].stream_offset = 0;
- seek_table->points[i].frame_samples = 0;
- }
- }
-
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_sort(FLAC__StreamMetadata *object, FLAC__bool compact)
-{
- unsigned unique;
-
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_SEEKTABLE);
-
- unique = FLAC__format_seektable_sort(&object->data.seek_table);
-
- return !compact || FLAC__metadata_object_seektable_resize_points(object, unique);
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_set_vendor_string(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy)
-{
- if(!FLAC__format_vorbiscomment_entry_value_is_legal(entry.entry, entry.length))
- return false;
- return vorbiscomment_set_entry_(object, &object->data.vorbis_comment.vendor_string, &entry, copy);
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_resize_comments(FLAC__StreamMetadata *object, unsigned new_num_comments)
-{
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT);
-
- if(0 == object->data.vorbis_comment.comments) {
- FLAC__ASSERT(object->data.vorbis_comment.num_comments == 0);
- if(0 == new_num_comments)
- return true;
- else if(0 == (object->data.vorbis_comment.comments = vorbiscomment_entry_array_new_(new_num_comments)))
- return false;
- }
- else {
- const size_t old_size = object->data.vorbis_comment.num_comments * sizeof(FLAC__StreamMetadata_VorbisComment_Entry);
- const size_t new_size = new_num_comments * sizeof(FLAC__StreamMetadata_VorbisComment_Entry);
-
- /* overflow check */
- if((size_t)new_num_comments > SIZE_MAX / sizeof(FLAC__StreamMetadata_VorbisComment_Entry))
- return false;
-
- FLAC__ASSERT(object->data.vorbis_comment.num_comments > 0);
-
- /* if shrinking, free the truncated entries */
- if(new_num_comments < object->data.vorbis_comment.num_comments) {
- unsigned i;
- for(i = new_num_comments; i < object->data.vorbis_comment.num_comments; i++)
- if(0 != object->data.vorbis_comment.comments[i].entry)
- free(object->data.vorbis_comment.comments[i].entry);
- }
-
- if(new_size == 0) {
- free(object->data.vorbis_comment.comments);
- object->data.vorbis_comment.comments = 0;
- }
- else if(0 == (object->data.vorbis_comment.comments = (FLAC__StreamMetadata_VorbisComment_Entry*)realloc(object->data.vorbis_comment.comments, new_size)))
- return false;
-
- /* if growing, zero all the length/pointers of new elements */
- if(new_size > old_size)
- memset(object->data.vorbis_comment.comments + object->data.vorbis_comment.num_comments, 0, new_size - old_size);
- }
-
- object->data.vorbis_comment.num_comments = new_num_comments;
-
- vorbiscomment_calculate_length_(object);
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_set_comment(FLAC__StreamMetadata *object, unsigned comment_num, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy)
-{
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(comment_num < object->data.vorbis_comment.num_comments);
-
- if(!FLAC__format_vorbiscomment_entry_is_legal(entry.entry, entry.length))
- return false;
- return vorbiscomment_set_entry_(object, &object->data.vorbis_comment.comments[comment_num], &entry, copy);
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_insert_comment(FLAC__StreamMetadata *object, unsigned comment_num, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy)
-{
- FLAC__StreamMetadata_VorbisComment *vc;
-
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT);
- FLAC__ASSERT(comment_num <= object->data.vorbis_comment.num_comments);
-
- if(!FLAC__format_vorbiscomment_entry_is_legal(entry.entry, entry.length))
- return false;
-
- vc = &object->data.vorbis_comment;
-
- if(!FLAC__metadata_object_vorbiscomment_resize_comments(object, vc->num_comments+1))
- return false;
-
- /* move all comments >= comment_num forward one space */
- memmove(&vc->comments[comment_num+1], &vc->comments[comment_num], sizeof(FLAC__StreamMetadata_VorbisComment_Entry)*(vc->num_comments-1-comment_num));
- vc->comments[comment_num].length = 0;
- vc->comments[comment_num].entry = 0;
-
- return FLAC__metadata_object_vorbiscomment_set_comment(object, comment_num, entry, copy);
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_append_comment(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy)
-{
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT);
- return FLAC__metadata_object_vorbiscomment_insert_comment(object, object->data.vorbis_comment.num_comments, entry, copy);
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_replace_comment(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool all, FLAC__bool copy)
-{
- FLAC__ASSERT(0 != entry.entry && entry.length > 0);
-
- if(!FLAC__format_vorbiscomment_entry_is_legal(entry.entry, entry.length))
- return false;
-
- {
- int i;
- size_t field_name_length;
- const FLAC__byte *eq = (FLAC__byte*)memchr(entry.entry, '=', entry.length);
-
- FLAC__ASSERT(0 != eq);
-
- if(0 == eq)
- return false; /* double protection */
-
- field_name_length = eq-entry.entry;
-
- i = vorbiscomment_find_entry_from_(object, 0, (const char *)entry.entry, field_name_length);
- if(i >= 0) {
- unsigned index = (unsigned)i;
- if(!FLAC__metadata_object_vorbiscomment_set_comment(object, index, entry, copy))
- return false;
- entry = object->data.vorbis_comment.comments[index];
- index++; /* skip over replaced comment */
- if(all && index < object->data.vorbis_comment.num_comments) {
- i = vorbiscomment_find_entry_from_(object, index, (const char *)entry.entry, field_name_length);
- while(i >= 0) {
- index = (unsigned)i;
- if(!FLAC__metadata_object_vorbiscomment_delete_comment(object, index))
- return false;
- if(index < object->data.vorbis_comment.num_comments)
- i = vorbiscomment_find_entry_from_(object, index, (const char *)entry.entry, field_name_length);
- else
- i = -1;
- }
- }
- return true;
- }
- else
- return FLAC__metadata_object_vorbiscomment_append_comment(object, entry, copy);
- }
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_delete_comment(FLAC__StreamMetadata *object, unsigned comment_num)
-{
- FLAC__StreamMetadata_VorbisComment *vc;
-
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT);
- FLAC__ASSERT(comment_num < object->data.vorbis_comment.num_comments);
-
- vc = &object->data.vorbis_comment;
-
- /* free the comment at comment_num */
- if(0 != vc->comments[comment_num].entry)
- free(vc->comments[comment_num].entry);
-
- /* move all comments > comment_num backward one space */
- memmove(&vc->comments[comment_num], &vc->comments[comment_num+1], sizeof(FLAC__StreamMetadata_VorbisComment_Entry)*(vc->num_comments-comment_num-1));
- vc->comments[vc->num_comments-1].length = 0;
- vc->comments[vc->num_comments-1].entry = 0;
-
- return FLAC__metadata_object_vorbiscomment_resize_comments(object, vc->num_comments-1);
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(FLAC__StreamMetadata_VorbisComment_Entry *entry, const char *field_name, const char *field_value)
-{
- FLAC__ASSERT(0 != entry);
- FLAC__ASSERT(0 != field_name);
- FLAC__ASSERT(0 != field_value);
-
- if(!FLAC__format_vorbiscomment_entry_name_is_legal(field_name))
- return false;
- if(!FLAC__format_vorbiscomment_entry_value_is_legal((const FLAC__byte *)field_value, (unsigned)(-1)))
- return false;
-
- {
- const size_t nn = strlen(field_name);
- const size_t nv = strlen(field_value);
- entry->length = nn + 1 /*=*/ + nv;
- if(0 == (entry->entry = (FLAC__byte*)safe_malloc_add_4op_(nn, /*+*/1, /*+*/nv, /*+*/1)))
- return false;
- memcpy(entry->entry, field_name, nn);
- entry->entry[nn] = '=';
- memcpy(entry->entry+nn+1, field_value, nv);
- entry->entry[entry->length] = '\0';
- }
-
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_to_name_value_pair(const FLAC__StreamMetadata_VorbisComment_Entry entry, char **field_name, char **field_value)
-{
- FLAC__ASSERT(0 != entry.entry && entry.length > 0);
- FLAC__ASSERT(0 != field_name);
- FLAC__ASSERT(0 != field_value);
-
- if(!FLAC__format_vorbiscomment_entry_is_legal(entry.entry, entry.length))
- return false;
-
- {
- const FLAC__byte *eq = (FLAC__byte*)memchr(entry.entry, '=', entry.length);
- const size_t nn = eq-entry.entry;
- const size_t nv = entry.length-nn-1; /* -1 for the '=' */
- FLAC__ASSERT(0 != eq);
- if(0 == eq)
- return false; /* double protection */
- if(0 == (*field_name = (char*)safe_malloc_add_2op_(nn, /*+*/1)))
- return false;
- if(0 == (*field_value = (char*)safe_malloc_add_2op_(nv, /*+*/1))) {
- free(*field_name);
- return false;
- }
- memcpy(*field_name, entry.entry, nn);
- memcpy(*field_value, entry.entry+nn+1, nv);
- (*field_name)[nn] = '\0';
- (*field_value)[nv] = '\0';
- }
-
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_entry_matches(const FLAC__StreamMetadata_VorbisComment_Entry entry, const char *field_name, unsigned field_name_length)
-{
- FLAC__ASSERT(0 != entry.entry && entry.length > 0);
- {
- const FLAC__byte *eq = (FLAC__byte*)memchr(entry.entry, '=', entry.length);
-#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__ || defined __EMX__
-#define FLAC__STRNCASECMP strnicmp
-#else
-#define FLAC__STRNCASECMP strncasecmp
-#endif
- return (0 != eq && (unsigned)(eq-entry.entry) == field_name_length && 0 == FLAC__STRNCASECMP(field_name, (const char *)entry.entry, field_name_length));
-#undef FLAC__STRNCASECMP
- }
-}
-
-FLAC_API int FLAC__metadata_object_vorbiscomment_find_entry_from(const FLAC__StreamMetadata *object, unsigned offset, const char *field_name)
-{
- FLAC__ASSERT(0 != field_name);
-
- return vorbiscomment_find_entry_from_(object, offset, field_name, strlen(field_name));
-}
-
-FLAC_API int FLAC__metadata_object_vorbiscomment_remove_entry_matching(FLAC__StreamMetadata *object, const char *field_name)
-{
- const unsigned field_name_length = strlen(field_name);
- unsigned i;
-
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT);
-
- for(i = 0; i < object->data.vorbis_comment.num_comments; i++) {
- if(FLAC__metadata_object_vorbiscomment_entry_matches(object->data.vorbis_comment.comments[i], field_name, field_name_length)) {
- if(!FLAC__metadata_object_vorbiscomment_delete_comment(object, i))
- return -1;
- else
- return 1;
- }
- }
-
- return 0;
-}
-
-FLAC_API int FLAC__metadata_object_vorbiscomment_remove_entries_matching(FLAC__StreamMetadata *object, const char *field_name)
-{
- FLAC__bool ok = true;
- unsigned matching = 0;
- const unsigned field_name_length = strlen(field_name);
- int i;
-
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT);
-
- /* must delete from end to start otherwise it will interfere with our iteration */
- for(i = (int)object->data.vorbis_comment.num_comments - 1; ok && i >= 0; i--) {
- if(FLAC__metadata_object_vorbiscomment_entry_matches(object->data.vorbis_comment.comments[i], field_name, field_name_length)) {
- matching++;
- ok &= FLAC__metadata_object_vorbiscomment_delete_comment(object, (unsigned)i);
- }
- }
-
- return ok? (int)matching : -1;
-}
-
-FLAC_API FLAC__StreamMetadata_CueSheet_Track *FLAC__metadata_object_cuesheet_track_new(void)
-{
- return (FLAC__StreamMetadata_CueSheet_Track*)calloc(1, sizeof(FLAC__StreamMetadata_CueSheet_Track));
-}
-
-FLAC_API FLAC__StreamMetadata_CueSheet_Track *FLAC__metadata_object_cuesheet_track_clone(const FLAC__StreamMetadata_CueSheet_Track *object)
-{
- FLAC__StreamMetadata_CueSheet_Track *to;
-
- FLAC__ASSERT(0 != object);
-
- if(0 != (to = FLAC__metadata_object_cuesheet_track_new())) {
- if(!copy_track_(to, object)) {
- FLAC__metadata_object_cuesheet_track_delete(to);
- return 0;
- }
- }
-
- return to;
-}
-
-void FLAC__metadata_object_cuesheet_track_delete_data(FLAC__StreamMetadata_CueSheet_Track *object)
-{
- FLAC__ASSERT(0 != object);
-
- if(0 != object->indices) {
- FLAC__ASSERT(object->num_indices > 0);
- free(object->indices);
- }
-}
-
-FLAC_API void FLAC__metadata_object_cuesheet_track_delete(FLAC__StreamMetadata_CueSheet_Track *object)
-{
- FLAC__metadata_object_cuesheet_track_delete_data(object);
- free(object);
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_resize_indices(FLAC__StreamMetadata *object, unsigned track_num, unsigned new_num_indices)
-{
- FLAC__StreamMetadata_CueSheet_Track *track;
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_CUESHEET);
- FLAC__ASSERT(track_num < object->data.cue_sheet.num_tracks);
-
- track = &object->data.cue_sheet.tracks[track_num];
-
- if(0 == track->indices) {
- FLAC__ASSERT(track->num_indices == 0);
- if(0 == new_num_indices)
- return true;
- else if(0 == (track->indices = cuesheet_track_index_array_new_(new_num_indices)))
- return false;
- }
- else {
- const size_t old_size = track->num_indices * sizeof(FLAC__StreamMetadata_CueSheet_Index);
- const size_t new_size = new_num_indices * sizeof(FLAC__StreamMetadata_CueSheet_Index);
-
- /* overflow check */
- if((size_t)new_num_indices > SIZE_MAX / sizeof(FLAC__StreamMetadata_CueSheet_Index))
- return false;
-
- FLAC__ASSERT(track->num_indices > 0);
-
- if(new_size == 0) {
- free(track->indices);
- track->indices = 0;
- }
- else if(0 == (track->indices = (FLAC__StreamMetadata_CueSheet_Index*)realloc(track->indices, new_size)))
- return false;
-
- /* if growing, zero all the lengths/pointers of new elements */
- if(new_size > old_size)
- memset(track->indices + track->num_indices, 0, new_size - old_size);
- }
-
- track->num_indices = new_num_indices;
-
- cuesheet_calculate_length_(object);
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_insert_index(FLAC__StreamMetadata *object, unsigned track_num, unsigned index_num, FLAC__StreamMetadata_CueSheet_Index index)
-{
- FLAC__StreamMetadata_CueSheet_Track *track;
-
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_CUESHEET);
- FLAC__ASSERT(track_num < object->data.cue_sheet.num_tracks);
- FLAC__ASSERT(index_num <= object->data.cue_sheet.tracks[track_num].num_indices);
-
- track = &object->data.cue_sheet.tracks[track_num];
-
- if(!FLAC__metadata_object_cuesheet_track_resize_indices(object, track_num, track->num_indices+1))
- return false;
-
- /* move all indices >= index_num forward one space */
- memmove(&track->indices[index_num+1], &track->indices[index_num], sizeof(FLAC__StreamMetadata_CueSheet_Index)*(track->num_indices-1-index_num));
-
- track->indices[index_num] = index;
- cuesheet_calculate_length_(object);
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_insert_blank_index(FLAC__StreamMetadata *object, unsigned track_num, unsigned index_num)
-{
- FLAC__StreamMetadata_CueSheet_Index index;
- memset(&index, 0, sizeof(index));
- return FLAC__metadata_object_cuesheet_track_insert_index(object, track_num, index_num, index);
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_track_delete_index(FLAC__StreamMetadata *object, unsigned track_num, unsigned index_num)
-{
- FLAC__StreamMetadata_CueSheet_Track *track;
-
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_CUESHEET);
- FLAC__ASSERT(track_num < object->data.cue_sheet.num_tracks);
- FLAC__ASSERT(index_num < object->data.cue_sheet.tracks[track_num].num_indices);
-
- track = &object->data.cue_sheet.tracks[track_num];
-
- /* move all indices > index_num backward one space */
- memmove(&track->indices[index_num], &track->indices[index_num+1], sizeof(FLAC__StreamMetadata_CueSheet_Index)*(track->num_indices-index_num-1));
-
- FLAC__metadata_object_cuesheet_track_resize_indices(object, track_num, track->num_indices-1);
- cuesheet_calculate_length_(object);
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_resize_tracks(FLAC__StreamMetadata *object, unsigned new_num_tracks)
-{
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_CUESHEET);
-
- if(0 == object->data.cue_sheet.tracks) {
- FLAC__ASSERT(object->data.cue_sheet.num_tracks == 0);
- if(0 == new_num_tracks)
- return true;
- else if(0 == (object->data.cue_sheet.tracks = cuesheet_track_array_new_(new_num_tracks)))
- return false;
- }
- else {
- const size_t old_size = object->data.cue_sheet.num_tracks * sizeof(FLAC__StreamMetadata_CueSheet_Track);
- const size_t new_size = new_num_tracks * sizeof(FLAC__StreamMetadata_CueSheet_Track);
-
- /* overflow check */
- if((size_t)new_num_tracks > SIZE_MAX / sizeof(FLAC__StreamMetadata_CueSheet_Track))
- return false;
-
- FLAC__ASSERT(object->data.cue_sheet.num_tracks > 0);
-
- /* if shrinking, free the truncated entries */
- if(new_num_tracks < object->data.cue_sheet.num_tracks) {
- unsigned i;
- for(i = new_num_tracks; i < object->data.cue_sheet.num_tracks; i++)
- if(0 != object->data.cue_sheet.tracks[i].indices)
- free(object->data.cue_sheet.tracks[i].indices);
- }
-
- if(new_size == 0) {
- free(object->data.cue_sheet.tracks);
- object->data.cue_sheet.tracks = 0;
- }
- else if(0 == (object->data.cue_sheet.tracks = (FLAC__StreamMetadata_CueSheet_Track*)realloc(object->data.cue_sheet.tracks, new_size)))
- return false;
-
- /* if growing, zero all the lengths/pointers of new elements */
- if(new_size > old_size)
- memset(object->data.cue_sheet.tracks + object->data.cue_sheet.num_tracks, 0, new_size - old_size);
- }
-
- object->data.cue_sheet.num_tracks = new_num_tracks;
-
- cuesheet_calculate_length_(object);
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_set_track(FLAC__StreamMetadata *object, unsigned track_num, FLAC__StreamMetadata_CueSheet_Track *track, FLAC__bool copy)
-{
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(track_num < object->data.cue_sheet.num_tracks);
-
- return cuesheet_set_track_(object, object->data.cue_sheet.tracks + track_num, track, copy);
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_insert_track(FLAC__StreamMetadata *object, unsigned track_num, FLAC__StreamMetadata_CueSheet_Track *track, FLAC__bool copy)
-{
- FLAC__StreamMetadata_CueSheet *cs;
-
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_CUESHEET);
- FLAC__ASSERT(track_num <= object->data.cue_sheet.num_tracks);
-
- cs = &object->data.cue_sheet;
-
- if(!FLAC__metadata_object_cuesheet_resize_tracks(object, cs->num_tracks+1))
- return false;
-
- /* move all tracks >= track_num forward one space */
- memmove(&cs->tracks[track_num+1], &cs->tracks[track_num], sizeof(FLAC__StreamMetadata_CueSheet_Track)*(cs->num_tracks-1-track_num));
- cs->tracks[track_num].num_indices = 0;
- cs->tracks[track_num].indices = 0;
-
- return FLAC__metadata_object_cuesheet_set_track(object, track_num, track, copy);
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_insert_blank_track(FLAC__StreamMetadata *object, unsigned track_num)
-{
- FLAC__StreamMetadata_CueSheet_Track track;
- memset(&track, 0, sizeof(track));
- return FLAC__metadata_object_cuesheet_insert_track(object, track_num, &track, /*copy=*/false);
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_delete_track(FLAC__StreamMetadata *object, unsigned track_num)
-{
- FLAC__StreamMetadata_CueSheet *cs;
-
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_CUESHEET);
- FLAC__ASSERT(track_num < object->data.cue_sheet.num_tracks);
-
- cs = &object->data.cue_sheet;
-
- /* free the track at track_num */
- if(0 != cs->tracks[track_num].indices)
- free(cs->tracks[track_num].indices);
-
- /* move all tracks > track_num backward one space */
- memmove(&cs->tracks[track_num], &cs->tracks[track_num+1], sizeof(FLAC__StreamMetadata_CueSheet_Track)*(cs->num_tracks-track_num-1));
- cs->tracks[cs->num_tracks-1].num_indices = 0;
- cs->tracks[cs->num_tracks-1].indices = 0;
-
- return FLAC__metadata_object_cuesheet_resize_tracks(object, cs->num_tracks-1);
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_cuesheet_is_legal(const FLAC__StreamMetadata *object, FLAC__bool check_cd_da_subset, const char **violation)
-{
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_CUESHEET);
-
- return FLAC__format_cuesheet_is_legal(&object->data.cue_sheet, check_cd_da_subset, violation);
-}
-
-static FLAC__uint64 get_index_01_offset_(const FLAC__StreamMetadata_CueSheet *cs, unsigned track)
-{
- if (track >= (cs->num_tracks-1) || cs->tracks[track].num_indices < 1)
- return 0;
- else if (cs->tracks[track].indices[0].number == 1)
- return cs->tracks[track].indices[0].offset + cs->tracks[track].offset + cs->lead_in;
- else if (cs->tracks[track].num_indices < 2)
- return 0;
- else if (cs->tracks[track].indices[1].number == 1)
- return cs->tracks[track].indices[1].offset + cs->tracks[track].offset + cs->lead_in;
- else
- return 0;
-}
-
-static FLAC__uint32 cddb_add_digits_(FLAC__uint32 x)
-{
- FLAC__uint32 n = 0;
- while (x) {
- n += (x%10);
- x /= 10;
- }
- return n;
-}
-
-/*@@@@add to tests*/
-FLAC_API FLAC__uint32 FLAC__metadata_object_cuesheet_calculate_cddb_id(const FLAC__StreamMetadata *object)
-{
- const FLAC__StreamMetadata_CueSheet *cs;
-
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_CUESHEET);
-
- cs = &object->data.cue_sheet;
-
- if (cs->num_tracks < 2) /* need at least one real track and the lead-out track */
- return 0;
-
- {
- FLAC__uint32 i, length, sum = 0;
- for (i = 0; i < (cs->num_tracks-1); i++) /* -1 to avoid counting the lead-out */
- sum += cddb_add_digits_((FLAC__uint32)(get_index_01_offset_(cs, i) / 44100));
- length = (FLAC__uint32)((cs->tracks[cs->num_tracks-1].offset+cs->lead_in) / 44100) - (FLAC__uint32)(get_index_01_offset_(cs, 0) / 44100);
-
- return (sum % 0xFF) << 24 | length << 8 | (FLAC__uint32)(cs->num_tracks-1);
- }
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_picture_set_mime_type(FLAC__StreamMetadata *object, char *mime_type, FLAC__bool copy)
-{
- char *old;
- size_t old_length, new_length;
-
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_PICTURE);
- FLAC__ASSERT(0 != mime_type);
-
- old = object->data.picture.mime_type;
- old_length = old? strlen(old) : 0;
- new_length = strlen(mime_type);
-
- /* do the copy first so that if we fail we leave the object untouched */
- if(copy) {
- if(new_length >= SIZE_MAX) /* overflow check */
- return false;
- if(!copy_bytes_((FLAC__byte**)(&object->data.picture.mime_type), (FLAC__byte*)mime_type, new_length+1))
- return false;
- }
- else {
- object->data.picture.mime_type = mime_type;
- }
-
- if(0 != old)
- free(old);
-
- object->length -= old_length;
- object->length += new_length;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_picture_set_description(FLAC__StreamMetadata *object, FLAC__byte *description, FLAC__bool copy)
-{
- FLAC__byte *old;
- size_t old_length, new_length;
-
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_PICTURE);
- FLAC__ASSERT(0 != description);
-
- old = object->data.picture.description;
- old_length = old? strlen((const char *)old) : 0;
- new_length = strlen((const char *)description);
-
- /* do the copy first so that if we fail we leave the object untouched */
- if(copy) {
- if(new_length >= SIZE_MAX) /* overflow check */
- return false;
- if(!copy_bytes_(&object->data.picture.description, description, new_length+1))
- return false;
- }
- else {
- object->data.picture.description = description;
- }
-
- if(0 != old)
- free(old);
-
- object->length -= old_length;
- object->length += new_length;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_picture_set_data(FLAC__StreamMetadata *object, FLAC__byte *data, FLAC__uint32 length, FLAC__bool copy)
-{
- FLAC__byte *old;
-
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_PICTURE);
- FLAC__ASSERT((0 != data && length > 0) || (0 == data && length == 0 && copy == false));
-
- old = object->data.picture.data;
-
- /* do the copy first so that if we fail we leave the object untouched */
- if(copy) {
- if(!copy_bytes_(&object->data.picture.data, data, length))
- return false;
- }
- else {
- object->data.picture.data = data;
- }
-
- if(0 != old)
- free(old);
-
- object->length -= object->data.picture.data_length;
- object->data.picture.data_length = length;
- object->length += length;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__metadata_object_picture_is_legal(const FLAC__StreamMetadata *object, const char **violation)
-{
- FLAC__ASSERT(0 != object);
- FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_PICTURE);
-
- return FLAC__format_picture_is_legal(&object->data.picture, violation);
-}
diff --git a/src/thirdparty/libflac/src/libFLAC/ogg_decoder_aspect.c b/src/thirdparty/libflac/src/libFLAC/ogg_decoder_aspect.c
deleted file mode 100644
index 0f71edca1..000000000
--- a/src/thirdparty/libflac/src/libFLAC/ogg_decoder_aspect.c
+++ /dev/null
@@ -1,253 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec
- * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <string.h> /* for memcpy() */
-#include "FLAC/assert.h"
-#include "private/ogg_decoder_aspect.h"
-#include "private/ogg_mapping.h"
-
-#ifdef max
-#undef max
-#endif
-#define max(x,y) ((x)>(y)?(x):(y))
-
-/***********************************************************************
- *
- * Public class methods
- *
- ***********************************************************************/
-
-FLAC__bool FLAC__ogg_decoder_aspect_init(FLAC__OggDecoderAspect *aspect)
-{
- /* we will determine the serial number later if necessary */
- if(ogg_stream_init(&aspect->stream_state, aspect->serial_number) != 0)
- return false;
-
- if(ogg_sync_init(&aspect->sync_state) != 0)
- return false;
-
- aspect->version_major = ~(0u);
- aspect->version_minor = ~(0u);
-
- aspect->need_serial_number = aspect->use_first_serial_number;
-
- aspect->end_of_stream = false;
- aspect->have_working_page = false;
-
- return true;
-}
-
-void FLAC__ogg_decoder_aspect_finish(FLAC__OggDecoderAspect *aspect)
-{
- (void)ogg_sync_clear(&aspect->sync_state);
- (void)ogg_stream_clear(&aspect->stream_state);
-}
-
-void FLAC__ogg_decoder_aspect_set_serial_number(FLAC__OggDecoderAspect *aspect, long value)
-{
- aspect->use_first_serial_number = false;
- aspect->serial_number = value;
-}
-
-void FLAC__ogg_decoder_aspect_set_defaults(FLAC__OggDecoderAspect *aspect)
-{
- aspect->use_first_serial_number = true;
-}
-
-void FLAC__ogg_decoder_aspect_flush(FLAC__OggDecoderAspect *aspect)
-{
- (void)ogg_stream_reset(&aspect->stream_state);
- (void)ogg_sync_reset(&aspect->sync_state);
- aspect->end_of_stream = false;
- aspect->have_working_page = false;
-}
-
-void FLAC__ogg_decoder_aspect_reset(FLAC__OggDecoderAspect *aspect)
-{
- FLAC__ogg_decoder_aspect_flush(aspect);
-
- if(aspect->use_first_serial_number)
- aspect->need_serial_number = true;
-}
-
-FLAC__OggDecoderAspectReadStatus FLAC__ogg_decoder_aspect_read_callback_wrapper(FLAC__OggDecoderAspect *aspect, FLAC__byte buffer[], size_t *bytes, FLAC__OggDecoderAspectReadCallbackProxy read_callback, const FLAC__StreamDecoder *decoder, void *client_data)
-{
- static const size_t OGG_BYTES_CHUNK = 8192;
- const size_t bytes_requested = *bytes;
-
- /*
- * The FLAC decoding API uses pull-based reads, whereas Ogg decoding
- * is push-based. In libFLAC, when you ask to decode a frame, the
- * decoder will eventually call the read callback to supply some data,
- * but how much it asks for depends on how much free space it has in
- * its internal buffer. It does not try to grow its internal buffer
- * to accomodate a whole frame because then the internal buffer size
- * could not be limited, which is necessary in embedded applications.
- *
- * Ogg however grows its internal buffer until a whole page is present;
- * only then can you get decoded data out. So we can't just ask for
- * the same number of bytes from Ogg, then pass what's decoded down to
- * libFLAC. If what libFLAC is asking for will not contain a whole
- * page, then we will get no data from ogg_sync_pageout(), and at the
- * same time cannot just read more data from the client for the purpose
- * of getting a whole decoded page because the decoded size might be
- * larger than libFLAC's internal buffer.
- *
- * Instead, whenever this read callback wrapper is called, we will
- * continually request data from the client until we have at least one
- * page, and manage pages internally so that we can send pieces of
- * pages down to libFLAC in such a way that we obey its size
- * requirement. To limit the amount of callbacks, we will always try
- * to read in enough pages to return the full number of bytes
- * requested.
- */
- *bytes = 0;
- while (*bytes < bytes_requested && !aspect->end_of_stream) {
- if (aspect->have_working_page) {
- if (aspect->have_working_packet) {
- size_t n = bytes_requested - *bytes;
- if ((size_t)aspect->working_packet.bytes <= n) {
- /* the rest of the packet will fit in the buffer */
- n = aspect->working_packet.bytes;
- memcpy(buffer, aspect->working_packet.packet, n);
- *bytes += n;
- buffer += n;
- aspect->have_working_packet = false;
- }
- else {
- /* only n bytes of the packet will fit in the buffer */
- memcpy(buffer, aspect->working_packet.packet, n);
- *bytes += n;
- buffer += n;
- aspect->working_packet.packet += n;
- aspect->working_packet.bytes -= n;
- }
- }
- else {
- /* try and get another packet */
- const int ret = ogg_stream_packetout(&aspect->stream_state, &aspect->working_packet);
- if (ret > 0) {
- aspect->have_working_packet = true;
- /* if it is the first header packet, check for magic and a supported Ogg FLAC mapping version */
- if (aspect->working_packet.bytes > 0 && aspect->working_packet.packet[0] == FLAC__OGG_MAPPING_FIRST_HEADER_PACKET_TYPE) {
- const FLAC__byte *b = aspect->working_packet.packet;
- const unsigned header_length =
- FLAC__OGG_MAPPING_PACKET_TYPE_LENGTH +
- FLAC__OGG_MAPPING_MAGIC_LENGTH +
- FLAC__OGG_MAPPING_VERSION_MAJOR_LENGTH +
- FLAC__OGG_MAPPING_VERSION_MINOR_LENGTH +
- FLAC__OGG_MAPPING_NUM_HEADERS_LENGTH;
- if (aspect->working_packet.bytes < (long)header_length)
- return FLAC__OGG_DECODER_ASPECT_READ_STATUS_NOT_FLAC;
- b += FLAC__OGG_MAPPING_PACKET_TYPE_LENGTH;
- if (memcmp(b, FLAC__OGG_MAPPING_MAGIC, FLAC__OGG_MAPPING_MAGIC_LENGTH))
- return FLAC__OGG_DECODER_ASPECT_READ_STATUS_NOT_FLAC;
- b += FLAC__OGG_MAPPING_MAGIC_LENGTH;
- aspect->version_major = (unsigned)(*b);
- b += FLAC__OGG_MAPPING_VERSION_MAJOR_LENGTH;
- aspect->version_minor = (unsigned)(*b);
- if (aspect->version_major != 1)
- return FLAC__OGG_DECODER_ASPECT_READ_STATUS_UNSUPPORTED_MAPPING_VERSION;
- aspect->working_packet.packet += header_length;
- aspect->working_packet.bytes -= header_length;
- }
- }
- else if (ret == 0) {
- aspect->have_working_page = false;
- }
- else { /* ret < 0 */
- /* lost sync, we'll leave the working page for the next call */
- return FLAC__OGG_DECODER_ASPECT_READ_STATUS_LOST_SYNC;
- }
- }
- }
- else {
- /* try and get another page */
- const int ret = ogg_sync_pageout(&aspect->sync_state, &aspect->working_page);
- if (ret > 0) {
- /* got a page, grab the serial number if necessary */
- if(aspect->need_serial_number) {
- aspect->stream_state.serialno = aspect->serial_number = ogg_page_serialno(&aspect->working_page);
- aspect->need_serial_number = false;
- }
- if(ogg_stream_pagein(&aspect->stream_state, &aspect->working_page) == 0) {
- aspect->have_working_page = true;
- aspect->have_working_packet = false;
- }
- /* else do nothing, could be a page from another stream */
- }
- else if (ret == 0) {
- /* need more data */
- const size_t ogg_bytes_to_read = max(bytes_requested - *bytes, OGG_BYTES_CHUNK);
- char *oggbuf = ogg_sync_buffer(&aspect->sync_state, ogg_bytes_to_read);
-
- if(0 == oggbuf) {
- return FLAC__OGG_DECODER_ASPECT_READ_STATUS_MEMORY_ALLOCATION_ERROR;
- }
- else {
- size_t ogg_bytes_read = ogg_bytes_to_read;
-
- switch(read_callback(decoder, (FLAC__byte*)oggbuf, &ogg_bytes_read, client_data)) {
- case FLAC__OGG_DECODER_ASPECT_READ_STATUS_OK:
- break;
- case FLAC__OGG_DECODER_ASPECT_READ_STATUS_END_OF_STREAM:
- aspect->end_of_stream = true;
- break;
- case FLAC__OGG_DECODER_ASPECT_READ_STATUS_ABORT:
- return FLAC__OGG_DECODER_ASPECT_READ_STATUS_ABORT;
- default:
- FLAC__ASSERT(0);
- }
-
- if(ogg_sync_wrote(&aspect->sync_state, ogg_bytes_read) < 0) {
- /* double protection; this will happen if the read callback returns more bytes than the max requested, which would overflow Ogg's internal buffer */
- FLAC__ASSERT(0);
- return FLAC__OGG_DECODER_ASPECT_READ_STATUS_ERROR;
- }
- }
- }
- else { /* ret < 0 */
- /* lost sync, bail out */
- return FLAC__OGG_DECODER_ASPECT_READ_STATUS_LOST_SYNC;
- }
- }
- }
-
- if (aspect->end_of_stream && *bytes == 0) {
- return FLAC__OGG_DECODER_ASPECT_READ_STATUS_END_OF_STREAM;
- }
-
- return FLAC__OGG_DECODER_ASPECT_READ_STATUS_OK;
-}
diff --git a/src/thirdparty/libflac/src/libFLAC/ogg_encoder_aspect.c b/src/thirdparty/libflac/src/libFLAC/ogg_encoder_aspect.c
deleted file mode 100644
index e3f5ecc4e..000000000
--- a/src/thirdparty/libflac/src/libFLAC/ogg_encoder_aspect.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec
- * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <string.h> /* for memset() */
-#include "FLAC/assert.h"
-#include "private/ogg_encoder_aspect.h"
-#include "private/ogg_mapping.h"
-
-static const FLAC__byte FLAC__OGG_MAPPING_VERSION_MAJOR = 1;
-static const FLAC__byte FLAC__OGG_MAPPING_VERSION_MINOR = 0;
-
-/***********************************************************************
- *
- * Public class methods
- *
- ***********************************************************************/
-
-FLAC__bool FLAC__ogg_encoder_aspect_init(FLAC__OggEncoderAspect *aspect)
-{
- /* we will determine the serial number later if necessary */
- if(ogg_stream_init(&aspect->stream_state, aspect->serial_number) != 0)
- return false;
-
- aspect->seen_magic = false;
- aspect->is_first_packet = true;
- aspect->samples_written = 0;
-
- return true;
-}
-
-void FLAC__ogg_encoder_aspect_finish(FLAC__OggEncoderAspect *aspect)
-{
- (void)ogg_stream_clear(&aspect->stream_state);
- /*@@@ what about the page? */
-}
-
-void FLAC__ogg_encoder_aspect_set_serial_number(FLAC__OggEncoderAspect *aspect, long value)
-{
- aspect->serial_number = value;
-}
-
-FLAC__bool FLAC__ogg_encoder_aspect_set_num_metadata(FLAC__OggEncoderAspect *aspect, unsigned value)
-{
- if(value < (1u << FLAC__OGG_MAPPING_NUM_HEADERS_LEN)) {
- aspect->num_metadata = value;
- return true;
- }
- else
- return false;
-}
-
-void FLAC__ogg_encoder_aspect_set_defaults(FLAC__OggEncoderAspect *aspect)
-{
- aspect->serial_number = 0;
- aspect->num_metadata = 0;
-}
-
-/*
- * The basic FLAC -> Ogg mapping goes like this:
- *
- * - 'fLaC' magic and STREAMINFO block get combined into the first
- * packet. The packet is prefixed with
- * + the one-byte packet type 0x7F
- * + 'FLAC' magic
- * + the 2 byte Ogg FLAC mapping version number
- * + tne 2 byte big-endian # of header packets
- * - The first packet is flushed to the first page.
- * - Each subsequent metadata block goes into its own packet.
- * - Each metadata packet is flushed to page (this is not required,
- * the mapping only requires that a flush must occur after all
- * metadata is written).
- * - Each subsequent FLAC audio frame goes into its own packet.
- *
- * WATCHOUT:
- * This depends on the behavior of FLAC__StreamEncoder that we get a
- * separate write callback for the fLaC magic, and then separate write
- * callbacks for each metadata block and audio frame.
- */
-FLAC__StreamEncoderWriteStatus FLAC__ogg_encoder_aspect_write_callback_wrapper(FLAC__OggEncoderAspect *aspect, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, FLAC__bool is_last_block, FLAC__OggEncoderAspectWriteCallbackProxy write_callback, void *encoder, void *client_data)
-{
- /* WATCHOUT:
- * This depends on the behavior of FLAC__StreamEncoder that 'samples'
- * will be 0 for metadata writes.
- */
- const FLAC__bool is_metadata = (samples == 0);
-
- /*
- * Treat fLaC magic packet specially. We will note when we see it, then
- * wait until we get the STREAMINFO and prepend it in that packet
- */
- if(aspect->seen_magic) {
- ogg_packet packet;
- FLAC__byte synthetic_first_packet_body[
- FLAC__OGG_MAPPING_PACKET_TYPE_LENGTH +
- FLAC__OGG_MAPPING_MAGIC_LENGTH +
- FLAC__OGG_MAPPING_VERSION_MAJOR_LENGTH +
- FLAC__OGG_MAPPING_VERSION_MINOR_LENGTH +
- FLAC__OGG_MAPPING_NUM_HEADERS_LENGTH +
- FLAC__STREAM_SYNC_LENGTH +
- FLAC__STREAM_METADATA_HEADER_LENGTH +
- FLAC__STREAM_METADATA_STREAMINFO_LENGTH
- ];
-
- memset(&packet, 0, sizeof(packet));
- packet.granulepos = aspect->samples_written + samples;
-
- if(aspect->is_first_packet) {
- FLAC__byte *b = synthetic_first_packet_body;
- if(bytes != FLAC__STREAM_METADATA_HEADER_LENGTH + FLAC__STREAM_METADATA_STREAMINFO_LENGTH) {
- /*
- * If we get here, our assumption about the way write callbacks happen
- * (explained above) is wrong
- */
- FLAC__ASSERT(0);
- return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
- }
- /* add first header packet type */
- *b = FLAC__OGG_MAPPING_FIRST_HEADER_PACKET_TYPE;
- b += FLAC__OGG_MAPPING_PACKET_TYPE_LENGTH;
- /* add 'FLAC' mapping magic */
- memcpy(b, FLAC__OGG_MAPPING_MAGIC, FLAC__OGG_MAPPING_MAGIC_LENGTH);
- b += FLAC__OGG_MAPPING_MAGIC_LENGTH;
- /* add Ogg FLAC mapping major version number */
- memcpy(b, &FLAC__OGG_MAPPING_VERSION_MAJOR, FLAC__OGG_MAPPING_VERSION_MAJOR_LENGTH);
- b += FLAC__OGG_MAPPING_VERSION_MAJOR_LENGTH;
- /* add Ogg FLAC mapping minor version number */
- memcpy(b, &FLAC__OGG_MAPPING_VERSION_MINOR, FLAC__OGG_MAPPING_VERSION_MINOR_LENGTH);
- b += FLAC__OGG_MAPPING_VERSION_MINOR_LENGTH;
- /* add number of header packets */
- *b = (FLAC__byte)(aspect->num_metadata >> 8);
- b++;
- *b = (FLAC__byte)(aspect->num_metadata);
- b++;
- /* add native FLAC 'fLaC' magic */
- memcpy(b, FLAC__STREAM_SYNC_STRING, FLAC__STREAM_SYNC_LENGTH);
- b += FLAC__STREAM_SYNC_LENGTH;
- /* add STREAMINFO */
- memcpy(b, buffer, bytes);
- FLAC__ASSERT(b + bytes - synthetic_first_packet_body == sizeof(synthetic_first_packet_body));
- packet.packet = (unsigned char *)synthetic_first_packet_body;
- packet.bytes = sizeof(synthetic_first_packet_body);
-
- packet.b_o_s = 1;
- aspect->is_first_packet = false;
- }
- else {
- packet.packet = (unsigned char *)buffer;
- packet.bytes = bytes;
- }
-
- if(is_last_block) {
- /* we used to check:
- * FLAC__ASSERT(total_samples_estimate == 0 || total_samples_estimate == aspect->samples_written + samples);
- * but it's really not useful since total_samples_estimate is an estimate and can be inexact
- */
- packet.e_o_s = 1;
- }
-
- if(ogg_stream_packetin(&aspect->stream_state, &packet) != 0)
- return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
-
- /*@@@ can't figure out a way to pass a useful number for 'samples' to the write_callback, so we'll just pass 0 */
- if(is_metadata) {
- while(ogg_stream_flush(&aspect->stream_state, &aspect->page) != 0) {
- if(write_callback(encoder, aspect->page.header, aspect->page.header_len, 0, current_frame, client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK)
- return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
- if(write_callback(encoder, aspect->page.body, aspect->page.body_len, 0, current_frame, client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK)
- return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
- }
- }
- else {
- while(ogg_stream_pageout(&aspect->stream_state, &aspect->page) != 0) {
- if(write_callback(encoder, aspect->page.header, aspect->page.header_len, 0, current_frame, client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK)
- return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
- if(write_callback(encoder, aspect->page.body, aspect->page.body_len, 0, current_frame, client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK)
- return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
- }
- }
- }
- else if(is_metadata && current_frame == 0 && samples == 0 && bytes == 4 && 0 == memcmp(buffer, FLAC__STREAM_SYNC_STRING, sizeof(FLAC__STREAM_SYNC_STRING))) {
- aspect->seen_magic = true;
- }
- else {
- /*
- * If we get here, our assumption about the way write callbacks happen
- * explained above is wrong
- */
- FLAC__ASSERT(0);
- return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
- }
-
- aspect->samples_written += samples;
-
- return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
-}
diff --git a/src/thirdparty/libflac/src/libFLAC/ogg_helper.c b/src/thirdparty/libflac/src/libFLAC/ogg_helper.c
deleted file mode 100644
index c3b091f45..000000000
--- a/src/thirdparty/libflac/src/libFLAC/ogg_helper.c
+++ /dev/null
@@ -1,209 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec
- * Copyright (C) 2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdlib.h> /* for malloc() */
-#include <string.h> /* for memcmp(), memcpy() */
-#include "FLAC/assert.h"
-#include "share/alloc.h"
-#include "private/ogg_helper.h"
-#include "protected/stream_encoder.h"
-
-
-static FLAC__bool full_read_(FLAC__StreamEncoder *encoder, FLAC__byte *buffer, size_t bytes, FLAC__StreamEncoderReadCallback read_callback, void *client_data)
-{
- while(bytes > 0) {
- size_t bytes_read = bytes;
- switch(read_callback(encoder, buffer, &bytes_read, client_data)) {
- case FLAC__STREAM_ENCODER_READ_STATUS_CONTINUE:
- bytes -= bytes_read;
- buffer += bytes_read;
- break;
- case FLAC__STREAM_ENCODER_READ_STATUS_END_OF_STREAM:
- if(bytes_read == 0) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR;
- return false;
- }
- bytes -= bytes_read;
- buffer += bytes_read;
- break;
- case FLAC__STREAM_ENCODER_READ_STATUS_ABORT:
- encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR;
- return false;
- case FLAC__STREAM_ENCODER_READ_STATUS_UNSUPPORTED:
- return false;
- default:
- /* double protection: */
- FLAC__ASSERT(0);
- encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR;
- return false;
- }
- }
-
- return true;
-}
-
-void simple_ogg_page__init(ogg_page *page)
-{
- page->header = 0;
- page->header_len = 0;
- page->body = 0;
- page->body_len = 0;
-}
-
-void simple_ogg_page__clear(ogg_page *page)
-{
- if(page->header)
- free(page->header);
- if(page->body)
- free(page->body);
- simple_ogg_page__init(page);
-}
-
-FLAC__bool simple_ogg_page__get_at(FLAC__StreamEncoder *encoder, FLAC__uint64 position, ogg_page *page, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderReadCallback read_callback, void *client_data)
-{
- static const unsigned OGG_HEADER_FIXED_PORTION_LEN = 27;
- static const unsigned OGG_MAX_HEADER_LEN = 27/*OGG_HEADER_FIXED_PORTION_LEN*/ + 255;
- FLAC__byte crc[4];
- FLAC__StreamEncoderSeekStatus seek_status;
-
- FLAC__ASSERT(page->header == 0);
- FLAC__ASSERT(page->header_len == 0);
- FLAC__ASSERT(page->body == 0);
- FLAC__ASSERT(page->body_len == 0);
-
- /* move the stream pointer to the supposed beginning of the page */
- if(0 == seek_callback)
- return false;
- if((seek_status = seek_callback((FLAC__StreamEncoder*)encoder, position, client_data)) != FLAC__STREAM_ENCODER_SEEK_STATUS_OK) {
- if(seek_status == FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR)
- encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR;
- return false;
- }
-
- /* allocate space for the page header */
- if(0 == (page->header = (unsigned char *)safe_malloc_(OGG_MAX_HEADER_LEN))) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR;
- return false;
- }
-
- /* read in the fixed part of the page header (up to but not including
- * the segment table */
- if(!full_read_(encoder, page->header, OGG_HEADER_FIXED_PORTION_LEN, read_callback, client_data))
- return false;
-
- page->header_len = OGG_HEADER_FIXED_PORTION_LEN + page->header[26];
-
- /* check to see if it's a correct, "simple" page (one packet only) */
- if(
- memcmp(page->header, "OggS", 4) || /* doesn't start with OggS */
- (page->header[5] & 0x01) || /* continued packet */
- memcmp(page->header+6, "\0\0\0\0\0\0\0\0", 8) || /* granulepos is non-zero */
- page->header[26] == 0 /* packet is 0-size */
- ) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR;
- return false;
- }
-
- /* read in the segment table */
- if(!full_read_(encoder, page->header + OGG_HEADER_FIXED_PORTION_LEN, page->header[26], read_callback, client_data))
- return false;
-
- {
- unsigned i;
-
- /* check to see that it specifies a single packet */
- for(i = 0; i < (unsigned)page->header[26] - 1; i++) {
- if(page->header[i + OGG_HEADER_FIXED_PORTION_LEN] != 255) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR;
- return false;
- }
- }
-
- page->body_len = 255 * i + page->header[i + OGG_HEADER_FIXED_PORTION_LEN];
- }
-
- /* allocate space for the page body */
- if(0 == (page->body = (unsigned char *)safe_malloc_(page->body_len))) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR;
- return false;
- }
-
- /* read in the page body */
- if(!full_read_(encoder, page->body, page->body_len, read_callback, client_data))
- return false;
-
- /* check the CRC */
- memcpy(crc, page->header+22, 4);
- ogg_page_checksum_set(page);
- if(memcmp(crc, page->header+22, 4)) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR;
- return false;
- }
-
- return true;
-}
-
-FLAC__bool simple_ogg_page__set_at(FLAC__StreamEncoder *encoder, FLAC__uint64 position, ogg_page *page, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderWriteCallback write_callback, void *client_data)
-{
- FLAC__StreamEncoderSeekStatus seek_status;
-
- FLAC__ASSERT(page->header != 0);
- FLAC__ASSERT(page->header_len != 0);
- FLAC__ASSERT(page->body != 0);
- FLAC__ASSERT(page->body_len != 0);
-
- /* move the stream pointer to the supposed beginning of the page */
- if(0 == seek_callback)
- return false;
- if((seek_status = seek_callback((FLAC__StreamEncoder*)encoder, position, client_data)) != FLAC__STREAM_ENCODER_SEEK_STATUS_OK) {
- if(seek_status == FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR)
- encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR;
- return false;
- }
-
- ogg_page_checksum_set(page);
-
- /* re-write the page */
- if(write_callback((FLAC__StreamEncoder*)encoder, page->header, page->header_len, 0, 0, client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR;
- return false;
- }
- if(write_callback((FLAC__StreamEncoder*)encoder, page->body, page->body_len, 0, 0, client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR;
- return false;
- }
-
- return true;
-}
diff --git a/src/thirdparty/libflac/src/libFLAC/ogg_mapping.c b/src/thirdparty/libflac/src/libFLAC/ogg_mapping.c
deleted file mode 100644
index 4b75f96f5..000000000
--- a/src/thirdparty/libflac/src/libFLAC/ogg_mapping.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec
- * Copyright (C) 2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "private/ogg_mapping.h"
-
-const unsigned FLAC__OGG_MAPPING_PACKET_TYPE_LEN = 8; /* bits */
-
-const FLAC__byte FLAC__OGG_MAPPING_FIRST_HEADER_PACKET_TYPE = 0x7f;
-
-const FLAC__byte * const FLAC__OGG_MAPPING_MAGIC = (const FLAC__byte * const)"FLAC";
-
-const unsigned FLAC__OGG_MAPPING_VERSION_MAJOR_LEN = 8; /* bits */
-const unsigned FLAC__OGG_MAPPING_VERSION_MINOR_LEN = 8; /* bits */
-
-const unsigned FLAC__OGG_MAPPING_NUM_HEADERS_LEN = 16; /* bits */
diff --git a/src/thirdparty/libflac/src/libFLAC/stream_decoder.c b/src/thirdparty/libflac/src/libFLAC/stream_decoder.c
deleted file mode 100644
index 12927700b..000000000
--- a/src/thirdparty/libflac/src/libFLAC/stream_decoder.c
+++ /dev/null
@@ -1,3387 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#if defined _MSC_VER || defined __MINGW32__
-#include <io.h> /* for _setmode() */
-#include <fcntl.h> /* for _O_BINARY */
-#endif
-#if defined __CYGWIN__ || defined __EMX__
-#include <io.h> /* for setmode(), O_BINARY */
-#include <fcntl.h> /* for _O_BINARY */
-#endif
-#include <stdio.h>
-#include <stdlib.h> /* for malloc() */
-#include <string.h> /* for memset/memcpy() */
-#include <sys/stat.h> /* for stat() */
-#include <sys/types.h> /* for off_t */
-#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__
-#if _MSC_VER <= 1700 || defined __BORLANDC__ /* @@@ [2G limit] */
-#define fseeko fseek
-#define ftello ftell
-#endif
-#endif
-#include "FLAC/assert.h"
-#include "share/alloc.h"
-#include "protected/stream_decoder.h"
-#include "private/bitreader.h"
-#include "private/bitmath.h"
-#include "private/cpu.h"
-#include "private/crc.h"
-#include "private/fixed.h"
-#include "private/format.h"
-#include "private/lpc.h"
-#include "private/md5.h"
-#include "private/memory.h"
-
-#ifdef max
-#undef max
-#endif
-#define max(a,b) ((a)>(b)?(a):(b))
-
-/* adjust for compilers that can't understand using LLU suffix for uint64_t literals */
-#ifdef _MSC_VER
-#define FLAC__U64L(x) x
-#else
-#define FLAC__U64L(x) x##LLU
-#endif
-
-
-/* technically this should be in an "export.c" but this is convenient enough */
-FLAC_API int FLAC_API_SUPPORTS_OGG_FLAC =
-#if FLAC__HAS_OGG
- 1
-#else
- 0
-#endif
-;
-
-
-/***********************************************************************
- *
- * Private static data
- *
- ***********************************************************************/
-
-static FLAC__byte ID3V2_TAG_[3] = { 'I', 'D', '3' };
-
-/***********************************************************************
- *
- * Private class method prototypes
- *
- ***********************************************************************/
-
-static void set_defaults_(FLAC__StreamDecoder *decoder);
-static FILE *get_binary_stdin_(void);
-static FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, unsigned size, unsigned channels);
-static FLAC__bool has_id_filtered_(FLAC__StreamDecoder *decoder, FLAC__byte *id);
-static FLAC__bool find_metadata_(FLAC__StreamDecoder *decoder);
-static FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder);
-static FLAC__bool read_metadata_streaminfo_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, unsigned length);
-static FLAC__bool read_metadata_seektable_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, unsigned length);
-static FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_VorbisComment *obj);
-static FLAC__bool read_metadata_cuesheet_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_CueSheet *obj);
-static FLAC__bool read_metadata_picture_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_Picture *obj);
-static FLAC__bool skip_id3v2_tag_(FLAC__StreamDecoder *decoder);
-static FLAC__bool frame_sync_(FLAC__StreamDecoder *decoder);
-static FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FLAC__bool do_full_decode);
-static FLAC__bool read_frame_header_(FLAC__StreamDecoder *decoder);
-static FLAC__bool read_subframe_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, FLAC__bool do_full_decode);
-static FLAC__bool read_subframe_constant_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, FLAC__bool do_full_decode);
-static FLAC__bool read_subframe_fixed_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const unsigned order, FLAC__bool do_full_decode);
-static FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const unsigned order, FLAC__bool do_full_decode);
-static FLAC__bool read_subframe_verbatim_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, FLAC__bool do_full_decode);
-static FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, unsigned predictor_order, unsigned partition_order, FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents, FLAC__int32 *residual, FLAC__bool is_extended);
-static FLAC__bool read_zero_padding_(FLAC__StreamDecoder *decoder);
-static FLAC__bool read_callback_(FLAC__byte buffer[], size_t *bytes, void *client_data);
-#if FLAC__HAS_OGG
-static FLAC__StreamDecoderReadStatus read_callback_ogg_aspect_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes);
-static FLAC__OggDecoderAspectReadStatus read_callback_proxy_(const void *void_decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
-#endif
-static FLAC__StreamDecoderWriteStatus write_audio_frame_to_client_(FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[]);
-static void send_error_to_client_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status);
-static FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length, FLAC__uint64 target_sample);
-#if FLAC__HAS_OGG
-static FLAC__bool seek_to_absolute_sample_ogg_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length, FLAC__uint64 target_sample);
-#endif
-static FLAC__StreamDecoderReadStatus file_read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
-static FLAC__StreamDecoderSeekStatus file_seek_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
-static FLAC__StreamDecoderTellStatus file_tell_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
-static FLAC__StreamDecoderLengthStatus file_length_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
-static FLAC__bool file_eof_callback_(const FLAC__StreamDecoder *decoder, void *client_data);
-
-/***********************************************************************
- *
- * Private class data
- *
- ***********************************************************************/
-
-typedef struct FLAC__StreamDecoderPrivate {
-#if FLAC__HAS_OGG
- FLAC__bool is_ogg;
-#endif
- FLAC__StreamDecoderReadCallback read_callback;
- FLAC__StreamDecoderSeekCallback seek_callback;
- FLAC__StreamDecoderTellCallback tell_callback;
- FLAC__StreamDecoderLengthCallback length_callback;
- FLAC__StreamDecoderEofCallback eof_callback;
- FLAC__StreamDecoderWriteCallback write_callback;
- FLAC__StreamDecoderMetadataCallback metadata_callback;
- FLAC__StreamDecoderErrorCallback error_callback;
- /* generic 32-bit datapath: */
- void (*local_lpc_restore_signal)(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
- /* generic 64-bit datapath: */
- void (*local_lpc_restore_signal_64bit)(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
- /* for use when the signal is <= 16 bits-per-sample, or <= 15 bits-per-sample on a side channel (which requires 1 extra bit): */
- void (*local_lpc_restore_signal_16bit)(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
- /* for use when the signal is <= 16 bits-per-sample, or <= 15 bits-per-sample on a side channel (which requires 1 extra bit), AND order <= 8: */
- void (*local_lpc_restore_signal_16bit_order8)(const FLAC__int32 residual[], unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 data[]);
- FLAC__bool (*local_bitreader_read_rice_signed_block)(FLAC__BitReader *br, int vals[], unsigned nvals, unsigned parameter);
- void *client_data;
- FILE *file; /* only used if FLAC__stream_decoder_init_file()/FLAC__stream_decoder_init_file() called, else NULL */
- FLAC__BitReader *input;
- FLAC__int32 *output[FLAC__MAX_CHANNELS];
- FLAC__int32 *residual[FLAC__MAX_CHANNELS]; /* WATCHOUT: these are the aligned pointers; the real pointers that should be free()'d are residual_unaligned[] below */
- FLAC__EntropyCodingMethod_PartitionedRiceContents partitioned_rice_contents[FLAC__MAX_CHANNELS];
- unsigned output_capacity, output_channels;
- FLAC__uint32 fixed_block_size, next_fixed_block_size;
- FLAC__uint64 samples_decoded;
- FLAC__bool has_stream_info, has_seek_table;
- FLAC__StreamMetadata stream_info;
- FLAC__StreamMetadata seek_table;
- FLAC__bool metadata_filter[128]; /* MAGIC number 128 == total number of metadata block types == 1 << 7 */
- FLAC__byte *metadata_filter_ids;
- size_t metadata_filter_ids_count, metadata_filter_ids_capacity; /* units for both are IDs, not bytes */
- FLAC__Frame frame;
- FLAC__bool cached; /* true if there is a byte in lookahead */
- FLAC__CPUInfo cpuinfo;
- FLAC__byte header_warmup[2]; /* contains the sync code and reserved bits */
- FLAC__byte lookahead; /* temp storage when we need to look ahead one byte in the stream */
- /* unaligned (original) pointers to allocated data */
- FLAC__int32 *residual_unaligned[FLAC__MAX_CHANNELS];
- FLAC__bool do_md5_checking; /* initially gets protected_->md5_checking but is turned off after a seek or if the metadata has a zero MD5 */
- FLAC__bool internal_reset_hack; /* used only during init() so we can call reset to set up the decoder without rewinding the input */
- FLAC__bool is_seeking;
- FLAC__MD5Context md5context;
- FLAC__byte computed_md5sum[16]; /* this is the sum we computed from the decoded data */
- /* (the rest of these are only used for seeking) */
- FLAC__Frame last_frame; /* holds the info of the last frame we seeked to */
- FLAC__uint64 first_frame_offset; /* hint to the seek routine of where in the stream the first audio frame starts */
- FLAC__uint64 target_sample;
- unsigned unparseable_frame_count; /* used to tell whether we're decoding a future version of FLAC or just got a bad sync */
-#if FLAC__HAS_OGG
- FLAC__bool got_a_frame; /* hack needed in Ogg FLAC seek routine to check when process_single() actually writes a frame */
-#endif
-} FLAC__StreamDecoderPrivate;
-
-/***********************************************************************
- *
- * Public static class data
- *
- ***********************************************************************/
-
-FLAC_API const char * const FLAC__StreamDecoderStateString[] = {
- "FLAC__STREAM_DECODER_SEARCH_FOR_METADATA",
- "FLAC__STREAM_DECODER_READ_METADATA",
- "FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC",
- "FLAC__STREAM_DECODER_READ_FRAME",
- "FLAC__STREAM_DECODER_END_OF_STREAM",
- "FLAC__STREAM_DECODER_OGG_ERROR",
- "FLAC__STREAM_DECODER_SEEK_ERROR",
- "FLAC__STREAM_DECODER_ABORTED",
- "FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR",
- "FLAC__STREAM_DECODER_UNINITIALIZED"
-};
-
-FLAC_API const char * const FLAC__StreamDecoderInitStatusString[] = {
- "FLAC__STREAM_DECODER_INIT_STATUS_OK",
- "FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER",
- "FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS",
- "FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR",
- "FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE",
- "FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED"
-};
-
-FLAC_API const char * const FLAC__StreamDecoderReadStatusString[] = {
- "FLAC__STREAM_DECODER_READ_STATUS_CONTINUE",
- "FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM",
- "FLAC__STREAM_DECODER_READ_STATUS_ABORT"
-};
-
-FLAC_API const char * const FLAC__StreamDecoderSeekStatusString[] = {
- "FLAC__STREAM_DECODER_SEEK_STATUS_OK",
- "FLAC__STREAM_DECODER_SEEK_STATUS_ERROR",
- "FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED"
-};
-
-FLAC_API const char * const FLAC__StreamDecoderTellStatusString[] = {
- "FLAC__STREAM_DECODER_TELL_STATUS_OK",
- "FLAC__STREAM_DECODER_TELL_STATUS_ERROR",
- "FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED"
-};
-
-FLAC_API const char * const FLAC__StreamDecoderLengthStatusString[] = {
- "FLAC__STREAM_DECODER_LENGTH_STATUS_OK",
- "FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR",
- "FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED"
-};
-
-FLAC_API const char * const FLAC__StreamDecoderWriteStatusString[] = {
- "FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE",
- "FLAC__STREAM_DECODER_WRITE_STATUS_ABORT"
-};
-
-FLAC_API const char * const FLAC__StreamDecoderErrorStatusString[] = {
- "FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC",
- "FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER",
- "FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH",
- "FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM"
-};
-
-/***********************************************************************
- *
- * Class constructor/destructor
- *
- ***********************************************************************/
-FLAC_API FLAC__StreamDecoder *FLAC__stream_decoder_new(void)
-{
- FLAC__StreamDecoder *decoder;
- unsigned i;
-
- FLAC__ASSERT(sizeof(int) >= 4); /* we want to die right away if this is not true */
-
- decoder = (FLAC__StreamDecoder*)calloc(1, sizeof(FLAC__StreamDecoder));
- if(decoder == 0) {
- return 0;
- }
-
- decoder->protected_ = (FLAC__StreamDecoderProtected*)calloc(1, sizeof(FLAC__StreamDecoderProtected));
- if(decoder->protected_ == 0) {
- free(decoder);
- return 0;
- }
-
- decoder->private_ = (FLAC__StreamDecoderPrivate*)calloc(1, sizeof(FLAC__StreamDecoderPrivate));
- if(decoder->private_ == 0) {
- free(decoder->protected_);
- free(decoder);
- return 0;
- }
-
- decoder->private_->input = FLAC__bitreader_new();
- if(decoder->private_->input == 0) {
- free(decoder->private_);
- free(decoder->protected_);
- free(decoder);
- return 0;
- }
-
- decoder->private_->metadata_filter_ids_capacity = 16;
- if(0 == (decoder->private_->metadata_filter_ids = (FLAC__byte*)malloc((FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8) * decoder->private_->metadata_filter_ids_capacity))) {
- FLAC__bitreader_delete(decoder->private_->input);
- free(decoder->private_);
- free(decoder->protected_);
- free(decoder);
- return 0;
- }
-
- for(i = 0; i < FLAC__MAX_CHANNELS; i++) {
- decoder->private_->output[i] = 0;
- decoder->private_->residual_unaligned[i] = decoder->private_->residual[i] = 0;
- }
-
- decoder->private_->output_capacity = 0;
- decoder->private_->output_channels = 0;
- decoder->private_->has_seek_table = false;
-
- for(i = 0; i < FLAC__MAX_CHANNELS; i++)
- FLAC__format_entropy_coding_method_partitioned_rice_contents_init(&decoder->private_->partitioned_rice_contents[i]);
-
- decoder->private_->file = 0;
-
- set_defaults_(decoder);
-
- decoder->protected_->state = FLAC__STREAM_DECODER_UNINITIALIZED;
-
- return decoder;
-}
-
-FLAC_API void FLAC__stream_decoder_delete(FLAC__StreamDecoder *decoder)
-{
- unsigned i;
-
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != decoder->protected_);
- FLAC__ASSERT(0 != decoder->private_);
- FLAC__ASSERT(0 != decoder->private_->input);
-
- (void)FLAC__stream_decoder_finish(decoder);
-
- if(0 != decoder->private_->metadata_filter_ids)
- free(decoder->private_->metadata_filter_ids);
-
- FLAC__bitreader_delete(decoder->private_->input);
-
- for(i = 0; i < FLAC__MAX_CHANNELS; i++)
- FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(&decoder->private_->partitioned_rice_contents[i]);
-
- free(decoder->private_);
- free(decoder->protected_);
- free(decoder);
-}
-
-/***********************************************************************
- *
- * Public class methods
- *
- ***********************************************************************/
-
-static FLAC__StreamDecoderInitStatus init_stream_internal_(
- FLAC__StreamDecoder *decoder,
- FLAC__StreamDecoderReadCallback read_callback,
- FLAC__StreamDecoderSeekCallback seek_callback,
- FLAC__StreamDecoderTellCallback tell_callback,
- FLAC__StreamDecoderLengthCallback length_callback,
- FLAC__StreamDecoderEofCallback eof_callback,
- FLAC__StreamDecoderWriteCallback write_callback,
- FLAC__StreamDecoderMetadataCallback metadata_callback,
- FLAC__StreamDecoderErrorCallback error_callback,
- void *client_data,
- FLAC__bool is_ogg
-)
-{
- FLAC__ASSERT(0 != decoder);
-
- if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED)
- return FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED;
-
-#if !FLAC__HAS_OGG
- if(is_ogg)
- return FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER;
-#endif
-
- if(
- 0 == read_callback ||
- 0 == write_callback ||
- 0 == error_callback ||
- (seek_callback && (0 == tell_callback || 0 == length_callback || 0 == eof_callback))
- )
- return FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS;
-
-#if FLAC__HAS_OGG
- decoder->private_->is_ogg = is_ogg;
- if(is_ogg && !FLAC__ogg_decoder_aspect_init(&decoder->protected_->ogg_decoder_aspect))
- return decoder->protected_->state = FLAC__STREAM_DECODER_OGG_ERROR;
-#endif
-
- /*
- * get the CPU info and set the function pointers
- */
- FLAC__cpu_info(&decoder->private_->cpuinfo);
- /* first default to the non-asm routines */
- decoder->private_->local_lpc_restore_signal = FLAC__lpc_restore_signal;
- decoder->private_->local_lpc_restore_signal_64bit = FLAC__lpc_restore_signal_wide;
- decoder->private_->local_lpc_restore_signal_16bit = FLAC__lpc_restore_signal;
- decoder->private_->local_lpc_restore_signal_16bit_order8 = FLAC__lpc_restore_signal;
- decoder->private_->local_bitreader_read_rice_signed_block = FLAC__bitreader_read_rice_signed_block;
- /* now override with asm where appropriate */
-#ifndef FLAC__NO_ASM
- if(decoder->private_->cpuinfo.use_asm) {
-#ifdef FLAC__CPU_IA32
- FLAC__ASSERT(decoder->private_->cpuinfo.type == FLAC__CPUINFO_TYPE_IA32);
-#ifdef FLAC__HAS_NASM
-#if 1 /*@@@@@@ OPT: not clearly faster, needs more testing */
- if(decoder->private_->cpuinfo.data.ia32.bswap)
- decoder->private_->local_bitreader_read_rice_signed_block = FLAC__bitreader_read_rice_signed_block_asm_ia32_bswap;
-#endif
- if(decoder->private_->cpuinfo.data.ia32.mmx) {
- decoder->private_->local_lpc_restore_signal = FLAC__lpc_restore_signal_asm_ia32;
- decoder->private_->local_lpc_restore_signal_16bit = FLAC__lpc_restore_signal_asm_ia32_mmx;
- decoder->private_->local_lpc_restore_signal_16bit_order8 = FLAC__lpc_restore_signal_asm_ia32_mmx;
- }
- else {
- decoder->private_->local_lpc_restore_signal = FLAC__lpc_restore_signal_asm_ia32;
- decoder->private_->local_lpc_restore_signal_16bit = FLAC__lpc_restore_signal_asm_ia32;
- decoder->private_->local_lpc_restore_signal_16bit_order8 = FLAC__lpc_restore_signal_asm_ia32;
- }
-#endif
-#elif defined FLAC__CPU_PPC
- FLAC__ASSERT(decoder->private_->cpuinfo.type == FLAC__CPUINFO_TYPE_PPC);
- if(decoder->private_->cpuinfo.data.ppc.altivec) {
- decoder->private_->local_lpc_restore_signal_16bit = FLAC__lpc_restore_signal_asm_ppc_altivec_16;
- decoder->private_->local_lpc_restore_signal_16bit_order8 = FLAC__lpc_restore_signal_asm_ppc_altivec_16_order8;
- }
-#endif
- }
-#endif
-
- /* from here on, errors are fatal */
-
- if(!FLAC__bitreader_init(decoder->private_->input, decoder->private_->cpuinfo, read_callback_, decoder)) {
- decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
- return FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR;
- }
-
- decoder->private_->read_callback = read_callback;
- decoder->private_->seek_callback = seek_callback;
- decoder->private_->tell_callback = tell_callback;
- decoder->private_->length_callback = length_callback;
- decoder->private_->eof_callback = eof_callback;
- decoder->private_->write_callback = write_callback;
- decoder->private_->metadata_callback = metadata_callback;
- decoder->private_->error_callback = error_callback;
- decoder->private_->client_data = client_data;
- decoder->private_->fixed_block_size = decoder->private_->next_fixed_block_size = 0;
- decoder->private_->samples_decoded = 0;
- decoder->private_->has_stream_info = false;
- decoder->private_->cached = false;
-
- decoder->private_->do_md5_checking = decoder->protected_->md5_checking;
- decoder->private_->is_seeking = false;
-
- decoder->private_->internal_reset_hack = true; /* so the following reset does not try to rewind the input */
- if(!FLAC__stream_decoder_reset(decoder)) {
- /* above call sets the state for us */
- return FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR;
- }
-
- return FLAC__STREAM_DECODER_INIT_STATUS_OK;
-}
-
-FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_stream(
- FLAC__StreamDecoder *decoder,
- FLAC__StreamDecoderReadCallback read_callback,
- FLAC__StreamDecoderSeekCallback seek_callback,
- FLAC__StreamDecoderTellCallback tell_callback,
- FLAC__StreamDecoderLengthCallback length_callback,
- FLAC__StreamDecoderEofCallback eof_callback,
- FLAC__StreamDecoderWriteCallback write_callback,
- FLAC__StreamDecoderMetadataCallback metadata_callback,
- FLAC__StreamDecoderErrorCallback error_callback,
- void *client_data
-)
-{
- return init_stream_internal_(
- decoder,
- read_callback,
- seek_callback,
- tell_callback,
- length_callback,
- eof_callback,
- write_callback,
- metadata_callback,
- error_callback,
- client_data,
- /*is_ogg=*/false
- );
-}
-
-FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_stream(
- FLAC__StreamDecoder *decoder,
- FLAC__StreamDecoderReadCallback read_callback,
- FLAC__StreamDecoderSeekCallback seek_callback,
- FLAC__StreamDecoderTellCallback tell_callback,
- FLAC__StreamDecoderLengthCallback length_callback,
- FLAC__StreamDecoderEofCallback eof_callback,
- FLAC__StreamDecoderWriteCallback write_callback,
- FLAC__StreamDecoderMetadataCallback metadata_callback,
- FLAC__StreamDecoderErrorCallback error_callback,
- void *client_data
-)
-{
- return init_stream_internal_(
- decoder,
- read_callback,
- seek_callback,
- tell_callback,
- length_callback,
- eof_callback,
- write_callback,
- metadata_callback,
- error_callback,
- client_data,
- /*is_ogg=*/true
- );
-}
-
-static FLAC__StreamDecoderInitStatus init_FILE_internal_(
- FLAC__StreamDecoder *decoder,
- FILE *file,
- FLAC__StreamDecoderWriteCallback write_callback,
- FLAC__StreamDecoderMetadataCallback metadata_callback,
- FLAC__StreamDecoderErrorCallback error_callback,
- void *client_data,
- FLAC__bool is_ogg
-)
-{
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != file);
-
- if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED)
- return decoder->protected_->state = FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED;
-
- if(0 == write_callback || 0 == error_callback)
- return decoder->protected_->state = FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS;
-
- /*
- * To make sure that our file does not go unclosed after an error, we
- * must assign the FILE pointer before any further error can occur in
- * this routine.
- */
- if(file == stdin)
- file = get_binary_stdin_(); /* just to be safe */
-
- decoder->private_->file = file;
-
- return init_stream_internal_(
- decoder,
- file_read_callback_,
- decoder->private_->file == stdin? 0: file_seek_callback_,
- decoder->private_->file == stdin? 0: file_tell_callback_,
- decoder->private_->file == stdin? 0: file_length_callback_,
- file_eof_callback_,
- write_callback,
- metadata_callback,
- error_callback,
- client_data,
- is_ogg
- );
-}
-
-FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_FILE(
- FLAC__StreamDecoder *decoder,
- FILE *file,
- FLAC__StreamDecoderWriteCallback write_callback,
- FLAC__StreamDecoderMetadataCallback metadata_callback,
- FLAC__StreamDecoderErrorCallback error_callback,
- void *client_data
-)
-{
- return init_FILE_internal_(decoder, file, write_callback, metadata_callback, error_callback, client_data, /*is_ogg=*/false);
-}
-
-FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_FILE(
- FLAC__StreamDecoder *decoder,
- FILE *file,
- FLAC__StreamDecoderWriteCallback write_callback,
- FLAC__StreamDecoderMetadataCallback metadata_callback,
- FLAC__StreamDecoderErrorCallback error_callback,
- void *client_data
-)
-{
- return init_FILE_internal_(decoder, file, write_callback, metadata_callback, error_callback, client_data, /*is_ogg=*/true);
-}
-
-static FLAC__StreamDecoderInitStatus init_file_internal_(
- FLAC__StreamDecoder *decoder,
- const char *filename,
- FLAC__StreamDecoderWriteCallback write_callback,
- FLAC__StreamDecoderMetadataCallback metadata_callback,
- FLAC__StreamDecoderErrorCallback error_callback,
- void *client_data,
- FLAC__bool is_ogg
-)
-{
- FILE *file;
-
- FLAC__ASSERT(0 != decoder);
-
- /*
- * To make sure that our file does not go unclosed after an error, we
- * have to do the same entrance checks here that are later performed
- * in FLAC__stream_decoder_init_FILE() before the FILE* is assigned.
- */
- if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED)
- return decoder->protected_->state = FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED;
-
- if(0 == write_callback || 0 == error_callback)
- return decoder->protected_->state = FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS;
-
- file = filename? fopen(filename, "rb") : stdin;
-
- if(0 == file)
- return FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE;
-
- return init_FILE_internal_(decoder, file, write_callback, metadata_callback, error_callback, client_data, is_ogg);
-}
-
-FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_file(
- FLAC__StreamDecoder *decoder,
- const char *filename,
- FLAC__StreamDecoderWriteCallback write_callback,
- FLAC__StreamDecoderMetadataCallback metadata_callback,
- FLAC__StreamDecoderErrorCallback error_callback,
- void *client_data
-)
-{
- return init_file_internal_(decoder, filename, write_callback, metadata_callback, error_callback, client_data, /*is_ogg=*/false);
-}
-
-FLAC_API FLAC__StreamDecoderInitStatus FLAC__stream_decoder_init_ogg_file(
- FLAC__StreamDecoder *decoder,
- const char *filename,
- FLAC__StreamDecoderWriteCallback write_callback,
- FLAC__StreamDecoderMetadataCallback metadata_callback,
- FLAC__StreamDecoderErrorCallback error_callback,
- void *client_data
-)
-{
- return init_file_internal_(decoder, filename, write_callback, metadata_callback, error_callback, client_data, /*is_ogg=*/true);
-}
-
-FLAC_API FLAC__bool FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder)
-{
- FLAC__bool md5_failed = false;
- unsigned i;
-
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != decoder->private_);
- FLAC__ASSERT(0 != decoder->protected_);
-
- if(decoder->protected_->state == FLAC__STREAM_DECODER_UNINITIALIZED)
- return true;
-
- /* see the comment in FLAC__seekable_stream_decoder_reset() as to why we
- * always call FLAC__MD5Final()
- */
- FLAC__MD5Final(decoder->private_->computed_md5sum, &decoder->private_->md5context);
-
- if(decoder->private_->has_seek_table && 0 != decoder->private_->seek_table.data.seek_table.points) {
- free(decoder->private_->seek_table.data.seek_table.points);
- decoder->private_->seek_table.data.seek_table.points = 0;
- decoder->private_->has_seek_table = false;
- }
- FLAC__bitreader_free(decoder->private_->input);
- for(i = 0; i < FLAC__MAX_CHANNELS; i++) {
- /* WATCHOUT:
- * FLAC__lpc_restore_signal_asm_ia32_mmx() requires that the
- * output arrays have a buffer of up to 3 zeroes in front
- * (at negative indices) for alignment purposes; we use 4
- * to keep the data well-aligned.
- */
- if(0 != decoder->private_->output[i]) {
- free(decoder->private_->output[i]-4);
- decoder->private_->output[i] = 0;
- }
- if(0 != decoder->private_->residual_unaligned[i]) {
- free(decoder->private_->residual_unaligned[i]);
- decoder->private_->residual_unaligned[i] = decoder->private_->residual[i] = 0;
- }
- }
- decoder->private_->output_capacity = 0;
- decoder->private_->output_channels = 0;
-
-#if FLAC__HAS_OGG
- if(decoder->private_->is_ogg)
- FLAC__ogg_decoder_aspect_finish(&decoder->protected_->ogg_decoder_aspect);
-#endif
-
- if(0 != decoder->private_->file) {
- if(decoder->private_->file != stdin)
- fclose(decoder->private_->file);
- decoder->private_->file = 0;
- }
-
- if(decoder->private_->do_md5_checking) {
- if(memcmp(decoder->private_->stream_info.data.stream_info.md5sum, decoder->private_->computed_md5sum, 16))
- md5_failed = true;
- }
- decoder->private_->is_seeking = false;
-
- set_defaults_(decoder);
-
- decoder->protected_->state = FLAC__STREAM_DECODER_UNINITIALIZED;
-
- return !md5_failed;
-}
-
-FLAC_API FLAC__bool FLAC__stream_decoder_set_ogg_serial_number(FLAC__StreamDecoder *decoder, long value)
-{
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != decoder->private_);
- FLAC__ASSERT(0 != decoder->protected_);
- if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED)
- return false;
-#if FLAC__HAS_OGG
- /* can't check decoder->private_->is_ogg since that's not set until init time */
- FLAC__ogg_decoder_aspect_set_serial_number(&decoder->protected_->ogg_decoder_aspect, value);
- return true;
-#else
- (void)value;
- return false;
-#endif
-}
-
-FLAC_API FLAC__bool FLAC__stream_decoder_set_md5_checking(FLAC__StreamDecoder *decoder, FLAC__bool value)
-{
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != decoder->protected_);
- if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED)
- return false;
- decoder->protected_->md5_checking = value;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond(FLAC__StreamDecoder *decoder, FLAC__MetadataType type)
-{
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != decoder->private_);
- FLAC__ASSERT(0 != decoder->protected_);
- FLAC__ASSERT((unsigned)type <= FLAC__MAX_METADATA_TYPE_CODE);
- /* double protection */
- if((unsigned)type > FLAC__MAX_METADATA_TYPE_CODE)
- return false;
- if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED)
- return false;
- decoder->private_->metadata_filter[type] = true;
- if(type == FLAC__METADATA_TYPE_APPLICATION)
- decoder->private_->metadata_filter_ids_count = 0;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_application(FLAC__StreamDecoder *decoder, const FLAC__byte id[4])
-{
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != decoder->private_);
- FLAC__ASSERT(0 != decoder->protected_);
- FLAC__ASSERT(0 != id);
- if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED)
- return false;
-
- if(decoder->private_->metadata_filter[FLAC__METADATA_TYPE_APPLICATION])
- return true;
-
- FLAC__ASSERT(0 != decoder->private_->metadata_filter_ids);
-
- if(decoder->private_->metadata_filter_ids_count == decoder->private_->metadata_filter_ids_capacity) {
- if(0 == (decoder->private_->metadata_filter_ids = (FLAC__byte*)safe_realloc_mul_2op_(decoder->private_->metadata_filter_ids, decoder->private_->metadata_filter_ids_capacity, /*times*/2))) {
- decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
- return false;
- }
- decoder->private_->metadata_filter_ids_capacity *= 2;
- }
-
- memcpy(decoder->private_->metadata_filter_ids + decoder->private_->metadata_filter_ids_count * (FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8), id, (FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8));
- decoder->private_->metadata_filter_ids_count++;
-
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_respond_all(FLAC__StreamDecoder *decoder)
-{
- unsigned i;
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != decoder->private_);
- FLAC__ASSERT(0 != decoder->protected_);
- if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED)
- return false;
- for(i = 0; i < sizeof(decoder->private_->metadata_filter) / sizeof(decoder->private_->metadata_filter[0]); i++)
- decoder->private_->metadata_filter[i] = true;
- decoder->private_->metadata_filter_ids_count = 0;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore(FLAC__StreamDecoder *decoder, FLAC__MetadataType type)
-{
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != decoder->private_);
- FLAC__ASSERT(0 != decoder->protected_);
- FLAC__ASSERT((unsigned)type <= FLAC__MAX_METADATA_TYPE_CODE);
- /* double protection */
- if((unsigned)type > FLAC__MAX_METADATA_TYPE_CODE)
- return false;
- if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED)
- return false;
- decoder->private_->metadata_filter[type] = false;
- if(type == FLAC__METADATA_TYPE_APPLICATION)
- decoder->private_->metadata_filter_ids_count = 0;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_application(FLAC__StreamDecoder *decoder, const FLAC__byte id[4])
-{
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != decoder->private_);
- FLAC__ASSERT(0 != decoder->protected_);
- FLAC__ASSERT(0 != id);
- if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED)
- return false;
-
- if(!decoder->private_->metadata_filter[FLAC__METADATA_TYPE_APPLICATION])
- return true;
-
- FLAC__ASSERT(0 != decoder->private_->metadata_filter_ids);
-
- if(decoder->private_->metadata_filter_ids_count == decoder->private_->metadata_filter_ids_capacity) {
- if(0 == (decoder->private_->metadata_filter_ids = (FLAC__byte*)safe_realloc_mul_2op_(decoder->private_->metadata_filter_ids, decoder->private_->metadata_filter_ids_capacity, /*times*/2))) {
- decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
- return false;
- }
- decoder->private_->metadata_filter_ids_capacity *= 2;
- }
-
- memcpy(decoder->private_->metadata_filter_ids + decoder->private_->metadata_filter_ids_count * (FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8), id, (FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8));
- decoder->private_->metadata_filter_ids_count++;
-
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_decoder_set_metadata_ignore_all(FLAC__StreamDecoder *decoder)
-{
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != decoder->private_);
- FLAC__ASSERT(0 != decoder->protected_);
- if(decoder->protected_->state != FLAC__STREAM_DECODER_UNINITIALIZED)
- return false;
- memset(decoder->private_->metadata_filter, 0, sizeof(decoder->private_->metadata_filter));
- decoder->private_->metadata_filter_ids_count = 0;
- return true;
-}
-
-FLAC_API FLAC__StreamDecoderState FLAC__stream_decoder_get_state(const FLAC__StreamDecoder *decoder)
-{
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != decoder->protected_);
- return decoder->protected_->state;
-}
-
-FLAC_API const char *FLAC__stream_decoder_get_resolved_state_string(const FLAC__StreamDecoder *decoder)
-{
- return FLAC__StreamDecoderStateString[decoder->protected_->state];
-}
-
-FLAC_API FLAC__bool FLAC__stream_decoder_get_md5_checking(const FLAC__StreamDecoder *decoder)
-{
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != decoder->protected_);
- return decoder->protected_->md5_checking;
-}
-
-FLAC_API FLAC__uint64 FLAC__stream_decoder_get_total_samples(const FLAC__StreamDecoder *decoder)
-{
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != decoder->protected_);
- return decoder->private_->has_stream_info? decoder->private_->stream_info.data.stream_info.total_samples : 0;
-}
-
-FLAC_API unsigned FLAC__stream_decoder_get_channels(const FLAC__StreamDecoder *decoder)
-{
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != decoder->protected_);
- return decoder->protected_->channels;
-}
-
-FLAC_API FLAC__ChannelAssignment FLAC__stream_decoder_get_channel_assignment(const FLAC__StreamDecoder *decoder)
-{
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != decoder->protected_);
- return decoder->protected_->channel_assignment;
-}
-
-FLAC_API unsigned FLAC__stream_decoder_get_bits_per_sample(const FLAC__StreamDecoder *decoder)
-{
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != decoder->protected_);
- return decoder->protected_->bits_per_sample;
-}
-
-FLAC_API unsigned FLAC__stream_decoder_get_sample_rate(const FLAC__StreamDecoder *decoder)
-{
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != decoder->protected_);
- return decoder->protected_->sample_rate;
-}
-
-FLAC_API unsigned FLAC__stream_decoder_get_blocksize(const FLAC__StreamDecoder *decoder)
-{
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != decoder->protected_);
- return decoder->protected_->blocksize;
-}
-
-FLAC_API FLAC__bool FLAC__stream_decoder_get_decode_position(const FLAC__StreamDecoder *decoder, FLAC__uint64 *position)
-{
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != decoder->private_);
- FLAC__ASSERT(0 != position);
-
-#if FLAC__HAS_OGG
- if(decoder->private_->is_ogg)
- return false;
-#endif
- if(0 == decoder->private_->tell_callback)
- return false;
- if(decoder->private_->tell_callback(decoder, position, decoder->private_->client_data) != FLAC__STREAM_DECODER_TELL_STATUS_OK)
- return false;
- /* should never happen since all FLAC frames and metadata blocks are byte aligned, but check just in case */
- if(!FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input))
- return false;
- FLAC__ASSERT(*position >= FLAC__stream_decoder_get_input_bytes_unconsumed(decoder));
- *position -= FLAC__stream_decoder_get_input_bytes_unconsumed(decoder);
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_decoder_flush(FLAC__StreamDecoder *decoder)
-{
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != decoder->private_);
- FLAC__ASSERT(0 != decoder->protected_);
-
- decoder->private_->samples_decoded = 0;
- decoder->private_->do_md5_checking = false;
-
-#if FLAC__HAS_OGG
- if(decoder->private_->is_ogg)
- FLAC__ogg_decoder_aspect_flush(&decoder->protected_->ogg_decoder_aspect);
-#endif
-
- if(!FLAC__bitreader_clear(decoder->private_->input)) {
- decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
- return false;
- }
- decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
-
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_decoder_reset(FLAC__StreamDecoder *decoder)
-{
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != decoder->private_);
- FLAC__ASSERT(0 != decoder->protected_);
-
- if(!FLAC__stream_decoder_flush(decoder)) {
- /* above call sets the state for us */
- return false;
- }
-
-#if FLAC__HAS_OGG
- /*@@@ could go in !internal_reset_hack block below */
- if(decoder->private_->is_ogg)
- FLAC__ogg_decoder_aspect_reset(&decoder->protected_->ogg_decoder_aspect);
-#endif
-
- /* Rewind if necessary. If FLAC__stream_decoder_init() is calling us,
- * (internal_reset_hack) don't try to rewind since we are already at
- * the beginning of the stream and don't want to fail if the input is
- * not seekable.
- */
- if(!decoder->private_->internal_reset_hack) {
- if(decoder->private_->file == stdin)
- return false; /* can't rewind stdin, reset fails */
- if(decoder->private_->seek_callback && decoder->private_->seek_callback(decoder, 0, decoder->private_->client_data) == FLAC__STREAM_DECODER_SEEK_STATUS_ERROR)
- return false; /* seekable and seek fails, reset fails */
- }
- else
- decoder->private_->internal_reset_hack = false;
-
- decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_METADATA;
-
- decoder->private_->has_stream_info = false;
- if(decoder->private_->has_seek_table && 0 != decoder->private_->seek_table.data.seek_table.points) {
- free(decoder->private_->seek_table.data.seek_table.points);
- decoder->private_->seek_table.data.seek_table.points = 0;
- decoder->private_->has_seek_table = false;
- }
- decoder->private_->do_md5_checking = decoder->protected_->md5_checking;
- /*
- * This goes in reset() and not flush() because according to the spec, a
- * fixed-blocksize stream must stay that way through the whole stream.
- */
- decoder->private_->fixed_block_size = decoder->private_->next_fixed_block_size = 0;
-
- /* We initialize the FLAC__MD5Context even though we may never use it. This
- * is because md5 checking may be turned on to start and then turned off if
- * a seek occurs. So we init the context here and finalize it in
- * FLAC__stream_decoder_finish() to make sure things are always cleaned up
- * properly.
- */
- FLAC__MD5Init(&decoder->private_->md5context);
-
- decoder->private_->first_frame_offset = 0;
- decoder->private_->unparseable_frame_count = 0;
-
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_decoder_process_single(FLAC__StreamDecoder *decoder)
-{
- FLAC__bool got_a_frame;
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != decoder->protected_);
-
- while(1) {
- switch(decoder->protected_->state) {
- case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA:
- if(!find_metadata_(decoder))
- return false; /* above function sets the status for us */
- break;
- case FLAC__STREAM_DECODER_READ_METADATA:
- if(!read_metadata_(decoder))
- return false; /* above function sets the status for us */
- else
- return true;
- case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC:
- if(!frame_sync_(decoder))
- return true; /* above function sets the status for us */
- break;
- case FLAC__STREAM_DECODER_READ_FRAME:
- if(!read_frame_(decoder, &got_a_frame, /*do_full_decode=*/true))
- return false; /* above function sets the status for us */
- if(got_a_frame)
- return true; /* above function sets the status for us */
- break;
- case FLAC__STREAM_DECODER_END_OF_STREAM:
- case FLAC__STREAM_DECODER_ABORTED:
- return true;
- default:
- FLAC__ASSERT(0);
- return false;
- }
- }
-}
-
-FLAC_API FLAC__bool FLAC__stream_decoder_process_until_end_of_metadata(FLAC__StreamDecoder *decoder)
-{
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != decoder->protected_);
-
- while(1) {
- switch(decoder->protected_->state) {
- case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA:
- if(!find_metadata_(decoder))
- return false; /* above function sets the status for us */
- break;
- case FLAC__STREAM_DECODER_READ_METADATA:
- if(!read_metadata_(decoder))
- return false; /* above function sets the status for us */
- break;
- case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC:
- case FLAC__STREAM_DECODER_READ_FRAME:
- case FLAC__STREAM_DECODER_END_OF_STREAM:
- case FLAC__STREAM_DECODER_ABORTED:
- return true;
- default:
- FLAC__ASSERT(0);
- return false;
- }
- }
-}
-
-FLAC_API FLAC__bool FLAC__stream_decoder_process_until_end_of_stream(FLAC__StreamDecoder *decoder)
-{
- FLAC__bool dummy;
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != decoder->protected_);
-
- while(1) {
- switch(decoder->protected_->state) {
- case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA:
- if(!find_metadata_(decoder))
- return false; /* above function sets the status for us */
- break;
- case FLAC__STREAM_DECODER_READ_METADATA:
- if(!read_metadata_(decoder))
- return false; /* above function sets the status for us */
- break;
- case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC:
- if(!frame_sync_(decoder))
- return true; /* above function sets the status for us */
- break;
- case FLAC__STREAM_DECODER_READ_FRAME:
- if(!read_frame_(decoder, &dummy, /*do_full_decode=*/true))
- return false; /* above function sets the status for us */
- break;
- case FLAC__STREAM_DECODER_END_OF_STREAM:
- case FLAC__STREAM_DECODER_ABORTED:
- return true;
- default:
- FLAC__ASSERT(0);
- return false;
- }
- }
-}
-
-FLAC_API FLAC__bool FLAC__stream_decoder_skip_single_frame(FLAC__StreamDecoder *decoder)
-{
- FLAC__bool got_a_frame;
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != decoder->protected_);
-
- while(1) {
- switch(decoder->protected_->state) {
- case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA:
- case FLAC__STREAM_DECODER_READ_METADATA:
- return false; /* above function sets the status for us */
- case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC:
- if(!frame_sync_(decoder))
- return true; /* above function sets the status for us */
- break;
- case FLAC__STREAM_DECODER_READ_FRAME:
- if(!read_frame_(decoder, &got_a_frame, /*do_full_decode=*/false))
- return false; /* above function sets the status for us */
- if(got_a_frame)
- return true; /* above function sets the status for us */
- break;
- case FLAC__STREAM_DECODER_END_OF_STREAM:
- case FLAC__STREAM_DECODER_ABORTED:
- return true;
- default:
- FLAC__ASSERT(0);
- return false;
- }
- }
-}
-
-FLAC_API FLAC__bool FLAC__stream_decoder_seek_absolute(FLAC__StreamDecoder *decoder, FLAC__uint64 sample)
-{
- FLAC__uint64 length;
-
- FLAC__ASSERT(0 != decoder);
-
- if(
- decoder->protected_->state != FLAC__STREAM_DECODER_SEARCH_FOR_METADATA &&
- decoder->protected_->state != FLAC__STREAM_DECODER_READ_METADATA &&
- decoder->protected_->state != FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC &&
- decoder->protected_->state != FLAC__STREAM_DECODER_READ_FRAME &&
- decoder->protected_->state != FLAC__STREAM_DECODER_END_OF_STREAM
- )
- return false;
-
- if(0 == decoder->private_->seek_callback)
- return false;
-
- FLAC__ASSERT(decoder->private_->seek_callback);
- FLAC__ASSERT(decoder->private_->tell_callback);
- FLAC__ASSERT(decoder->private_->length_callback);
- FLAC__ASSERT(decoder->private_->eof_callback);
-
- if(FLAC__stream_decoder_get_total_samples(decoder) > 0 && sample >= FLAC__stream_decoder_get_total_samples(decoder))
- return false;
-
- decoder->private_->is_seeking = true;
-
- /* turn off md5 checking if a seek is attempted */
- decoder->private_->do_md5_checking = false;
-
- /* get the file length (currently our algorithm needs to know the length so it's also an error to get FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED) */
- if(decoder->private_->length_callback(decoder, &length, decoder->private_->client_data) != FLAC__STREAM_DECODER_LENGTH_STATUS_OK) {
- decoder->private_->is_seeking = false;
- return false;
- }
-
- /* if we haven't finished processing the metadata yet, do that so we have the STREAMINFO, SEEK_TABLE, and first_frame_offset */
- if(
- decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_METADATA ||
- decoder->protected_->state == FLAC__STREAM_DECODER_READ_METADATA
- ) {
- if(!FLAC__stream_decoder_process_until_end_of_metadata(decoder)) {
- /* above call sets the state for us */
- decoder->private_->is_seeking = false;
- return false;
- }
- /* check this again in case we didn't know total_samples the first time */
- if(FLAC__stream_decoder_get_total_samples(decoder) > 0 && sample >= FLAC__stream_decoder_get_total_samples(decoder)) {
- decoder->private_->is_seeking = false;
- return false;
- }
- }
-
- {
- const FLAC__bool ok =
-#if FLAC__HAS_OGG
- decoder->private_->is_ogg?
- seek_to_absolute_sample_ogg_(decoder, length, sample) :
-#endif
- seek_to_absolute_sample_(decoder, length, sample)
- ;
- decoder->private_->is_seeking = false;
- return ok;
- }
-}
-
-/***********************************************************************
- *
- * Protected class methods
- *
- ***********************************************************************/
-
-unsigned FLAC__stream_decoder_get_input_bytes_unconsumed(const FLAC__StreamDecoder *decoder)
-{
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input));
- FLAC__ASSERT(!(FLAC__bitreader_get_input_bits_unconsumed(decoder->private_->input) & 7));
- return FLAC__bitreader_get_input_bits_unconsumed(decoder->private_->input) / 8;
-}
-
-/***********************************************************************
- *
- * Private class methods
- *
- ***********************************************************************/
-
-void set_defaults_(FLAC__StreamDecoder *decoder)
-{
-#if FLAC__HAS_OGG
- decoder->private_->is_ogg = false;
-#endif
- decoder->private_->read_callback = 0;
- decoder->private_->seek_callback = 0;
- decoder->private_->tell_callback = 0;
- decoder->private_->length_callback = 0;
- decoder->private_->eof_callback = 0;
- decoder->private_->write_callback = 0;
- decoder->private_->metadata_callback = 0;
- decoder->private_->error_callback = 0;
- decoder->private_->client_data = 0;
-
- memset(decoder->private_->metadata_filter, 0, sizeof(decoder->private_->metadata_filter));
- decoder->private_->metadata_filter[FLAC__METADATA_TYPE_STREAMINFO] = true;
- decoder->private_->metadata_filter_ids_count = 0;
-
- decoder->protected_->md5_checking = false;
-
-#if FLAC__HAS_OGG
- FLAC__ogg_decoder_aspect_set_defaults(&decoder->protected_->ogg_decoder_aspect);
-#endif
-}
-
-/*
- * This will forcibly set stdin to binary mode (for OSes that require it)
- */
-FILE *get_binary_stdin_(void)
-{
- /* if something breaks here it is probably due to the presence or
- * absence of an underscore before the identifiers 'setmode',
- * 'fileno', and/or 'O_BINARY'; check your system header files.
- */
-#if defined _MSC_VER || defined __MINGW32__
- _setmode(_fileno(stdin), _O_BINARY);
-#elif defined __CYGWIN__
- /* almost certainly not needed for any modern Cygwin, but let's be safe... */
- setmode(_fileno(stdin), _O_BINARY);
-#elif defined __EMX__
- setmode(fileno(stdin), O_BINARY);
-#endif
-
- return stdin;
-}
-
-FLAC__bool allocate_output_(FLAC__StreamDecoder *decoder, unsigned size, unsigned channels)
-{
- unsigned i;
- FLAC__int32 *tmp;
-
- if(size <= decoder->private_->output_capacity && channels <= decoder->private_->output_channels)
- return true;
-
- /* simply using realloc() is not practical because the number of channels may change mid-stream */
-
- for(i = 0; i < FLAC__MAX_CHANNELS; i++) {
- if(0 != decoder->private_->output[i]) {
- free(decoder->private_->output[i]-4);
- decoder->private_->output[i] = 0;
- }
- if(0 != decoder->private_->residual_unaligned[i]) {
- free(decoder->private_->residual_unaligned[i]);
- decoder->private_->residual_unaligned[i] = decoder->private_->residual[i] = 0;
- }
- }
-
- for(i = 0; i < channels; i++) {
- /* WATCHOUT:
- * FLAC__lpc_restore_signal_asm_ia32_mmx() requires that the
- * output arrays have a buffer of up to 3 zeroes in front
- * (at negative indices) for alignment purposes; we use 4
- * to keep the data well-aligned.
- */
- tmp = (FLAC__int32*)safe_malloc_muladd2_(sizeof(FLAC__int32), /*times (*/size, /*+*/4/*)*/);
- if(tmp == 0) {
- decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
- return false;
- }
- memset(tmp, 0, sizeof(FLAC__int32)*4);
- decoder->private_->output[i] = tmp + 4;
-
- /* WATCHOUT:
- * minimum of quadword alignment for PPC vector optimizations is REQUIRED:
- */
- if(!FLAC__memory_alloc_aligned_int32_array(size, &decoder->private_->residual_unaligned[i], &decoder->private_->residual[i])) {
- decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
- return false;
- }
- }
-
- decoder->private_->output_capacity = size;
- decoder->private_->output_channels = channels;
-
- return true;
-}
-
-FLAC__bool has_id_filtered_(FLAC__StreamDecoder *decoder, FLAC__byte *id)
-{
- size_t i;
-
- FLAC__ASSERT(0 != decoder);
- FLAC__ASSERT(0 != decoder->private_);
-
- for(i = 0; i < decoder->private_->metadata_filter_ids_count; i++)
- if(0 == memcmp(decoder->private_->metadata_filter_ids + i * (FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8), id, (FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8)))
- return true;
-
- return false;
-}
-
-FLAC__bool find_metadata_(FLAC__StreamDecoder *decoder)
-{
- FLAC__uint32 x;
- unsigned i, id;
- FLAC__bool first = true;
-
- FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input));
-
- for(i = id = 0; i < 4; ) {
- if(decoder->private_->cached) {
- x = (FLAC__uint32)decoder->private_->lookahead;
- decoder->private_->cached = false;
- }
- else {
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8))
- return false; /* read_callback_ sets the state for us */
- }
- if(x == FLAC__STREAM_SYNC_STRING[i]) {
- first = true;
- i++;
- id = 0;
- continue;
- }
- if(x == ID3V2_TAG_[id]) {
- id++;
- i = 0;
- if(id == 3) {
- if(!skip_id3v2_tag_(decoder))
- return false; /* skip_id3v2_tag_ sets the state for us */
- }
- continue;
- }
- id = 0;
- if(x == 0xff) { /* MAGIC NUMBER for the first 8 frame sync bits */
- decoder->private_->header_warmup[0] = (FLAC__byte)x;
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8))
- return false; /* read_callback_ sets the state for us */
-
- /* we have to check if we just read two 0xff's in a row; the second may actually be the beginning of the sync code */
- /* else we have to check if the second byte is the end of a sync code */
- if(x == 0xff) { /* MAGIC NUMBER for the first 8 frame sync bits */
- decoder->private_->lookahead = (FLAC__byte)x;
- decoder->private_->cached = true;
- }
- else if(x >> 1 == 0x7c) { /* MAGIC NUMBER for the last 6 sync bits and reserved 7th bit */
- decoder->private_->header_warmup[1] = (FLAC__byte)x;
- decoder->protected_->state = FLAC__STREAM_DECODER_READ_FRAME;
- return true;
- }
- }
- i = 0;
- if(first) {
- send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC);
- first = false;
- }
- }
-
- decoder->protected_->state = FLAC__STREAM_DECODER_READ_METADATA;
- return true;
-}
-
-FLAC__bool read_metadata_(FLAC__StreamDecoder *decoder)
-{
- FLAC__bool is_last;
- FLAC__uint32 i, x, type, length;
-
- FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input));
-
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_IS_LAST_LEN))
- return false; /* read_callback_ sets the state for us */
- is_last = x? true : false;
-
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &type, FLAC__STREAM_METADATA_TYPE_LEN))
- return false; /* read_callback_ sets the state for us */
-
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &length, FLAC__STREAM_METADATA_LENGTH_LEN))
- return false; /* read_callback_ sets the state for us */
-
- if(type == FLAC__METADATA_TYPE_STREAMINFO) {
- if(!read_metadata_streaminfo_(decoder, is_last, length))
- return false;
-
- decoder->private_->has_stream_info = true;
- if(0 == memcmp(decoder->private_->stream_info.data.stream_info.md5sum, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16))
- decoder->private_->do_md5_checking = false;
- if(!decoder->private_->is_seeking && decoder->private_->metadata_filter[FLAC__METADATA_TYPE_STREAMINFO] && decoder->private_->metadata_callback)
- decoder->private_->metadata_callback(decoder, &decoder->private_->stream_info, decoder->private_->client_data);
- }
- else if(type == FLAC__METADATA_TYPE_SEEKTABLE) {
- if(!read_metadata_seektable_(decoder, is_last, length))
- return false;
-
- decoder->private_->has_seek_table = true;
- if(!decoder->private_->is_seeking && decoder->private_->metadata_filter[FLAC__METADATA_TYPE_SEEKTABLE] && decoder->private_->metadata_callback)
- decoder->private_->metadata_callback(decoder, &decoder->private_->seek_table, decoder->private_->client_data);
- }
- else {
- FLAC__bool skip_it = !decoder->private_->metadata_filter[type];
- unsigned real_length = length;
- FLAC__StreamMetadata block;
-
- block.is_last = is_last;
- block.type = (FLAC__MetadataType)type;
- block.length = length;
-
- if(type == FLAC__METADATA_TYPE_APPLICATION) {
- if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, block.data.application.id, FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8))
- return false; /* read_callback_ sets the state for us */
-
- if(real_length < FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8) { /* underflow check */
- decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;/*@@@@@@ maybe wrong error? need to resync?*/
- return false;
- }
-
- real_length -= FLAC__STREAM_METADATA_APPLICATION_ID_LEN/8;
-
- if(decoder->private_->metadata_filter_ids_count > 0 && has_id_filtered_(decoder, block.data.application.id))
- skip_it = !skip_it;
- }
-
- if(skip_it) {
- if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, real_length))
- return false; /* read_callback_ sets the state for us */
- }
- else {
- switch(type) {
- case FLAC__METADATA_TYPE_PADDING:
- /* skip the padding bytes */
- if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, real_length))
- return false; /* read_callback_ sets the state for us */
- break;
- case FLAC__METADATA_TYPE_APPLICATION:
- /* remember, we read the ID already */
- if(real_length > 0) {
- if(0 == (block.data.application.data = (FLAC__byte*)malloc(real_length))) {
- decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
- return false;
- }
- if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, block.data.application.data, real_length))
- return false; /* read_callback_ sets the state for us */
- }
- else
- block.data.application.data = 0;
- break;
- case FLAC__METADATA_TYPE_VORBIS_COMMENT:
- if(!read_metadata_vorbiscomment_(decoder, &block.data.vorbis_comment))
- return false;
- break;
- case FLAC__METADATA_TYPE_CUESHEET:
- if(!read_metadata_cuesheet_(decoder, &block.data.cue_sheet))
- return false;
- break;
- case FLAC__METADATA_TYPE_PICTURE:
- if(!read_metadata_picture_(decoder, &block.data.picture))
- return false;
- break;
- case FLAC__METADATA_TYPE_STREAMINFO:
- case FLAC__METADATA_TYPE_SEEKTABLE:
- FLAC__ASSERT(0);
- break;
- default:
- if(real_length > 0) {
- if(0 == (block.data.unknown.data = (FLAC__byte*)malloc(real_length))) {
- decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
- return false;
- }
- if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, block.data.unknown.data, real_length))
- return false; /* read_callback_ sets the state for us */
- }
- else
- block.data.unknown.data = 0;
- break;
- }
- if(!decoder->private_->is_seeking && decoder->private_->metadata_callback)
- decoder->private_->metadata_callback(decoder, &block, decoder->private_->client_data);
-
- /* now we have to free any malloc()ed data in the block */
- switch(type) {
- case FLAC__METADATA_TYPE_PADDING:
- break;
- case FLAC__METADATA_TYPE_APPLICATION:
- if(0 != block.data.application.data)
- free(block.data.application.data);
- break;
- case FLAC__METADATA_TYPE_VORBIS_COMMENT:
- if(0 != block.data.vorbis_comment.vendor_string.entry)
- free(block.data.vorbis_comment.vendor_string.entry);
- if(block.data.vorbis_comment.num_comments > 0)
- for(i = 0; i < block.data.vorbis_comment.num_comments; i++)
- if(0 != block.data.vorbis_comment.comments[i].entry)
- free(block.data.vorbis_comment.comments[i].entry);
- if(0 != block.data.vorbis_comment.comments)
- free(block.data.vorbis_comment.comments);
- break;
- case FLAC__METADATA_TYPE_CUESHEET:
- if(block.data.cue_sheet.num_tracks > 0)
- for(i = 0; i < block.data.cue_sheet.num_tracks; i++)
- if(0 != block.data.cue_sheet.tracks[i].indices)
- free(block.data.cue_sheet.tracks[i].indices);
- if(0 != block.data.cue_sheet.tracks)
- free(block.data.cue_sheet.tracks);
- break;
- case FLAC__METADATA_TYPE_PICTURE:
- if(0 != block.data.picture.mime_type)
- free(block.data.picture.mime_type);
- if(0 != block.data.picture.description)
- free(block.data.picture.description);
- if(0 != block.data.picture.data)
- free(block.data.picture.data);
- break;
- case FLAC__METADATA_TYPE_STREAMINFO:
- case FLAC__METADATA_TYPE_SEEKTABLE:
- FLAC__ASSERT(0);
- default:
- if(0 != block.data.unknown.data)
- free(block.data.unknown.data);
- break;
- }
- }
- }
-
- if(is_last) {
- /* if this fails, it's OK, it's just a hint for the seek routine */
- if(!FLAC__stream_decoder_get_decode_position(decoder, &decoder->private_->first_frame_offset))
- decoder->private_->first_frame_offset = 0;
- decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
- }
-
- return true;
-}
-
-FLAC__bool read_metadata_streaminfo_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, unsigned length)
-{
- FLAC__uint32 x;
- unsigned bits, used_bits = 0;
-
- FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input));
-
- decoder->private_->stream_info.type = FLAC__METADATA_TYPE_STREAMINFO;
- decoder->private_->stream_info.is_last = is_last;
- decoder->private_->stream_info.length = length;
-
- bits = FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN;
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, bits))
- return false; /* read_callback_ sets the state for us */
- decoder->private_->stream_info.data.stream_info.min_blocksize = x;
- used_bits += bits;
-
- bits = FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN;
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN))
- return false; /* read_callback_ sets the state for us */
- decoder->private_->stream_info.data.stream_info.max_blocksize = x;
- used_bits += bits;
-
- bits = FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN;
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN))
- return false; /* read_callback_ sets the state for us */
- decoder->private_->stream_info.data.stream_info.min_framesize = x;
- used_bits += bits;
-
- bits = FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN;
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN))
- return false; /* read_callback_ sets the state for us */
- decoder->private_->stream_info.data.stream_info.max_framesize = x;
- used_bits += bits;
-
- bits = FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN;
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN))
- return false; /* read_callback_ sets the state for us */
- decoder->private_->stream_info.data.stream_info.sample_rate = x;
- used_bits += bits;
-
- bits = FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN;
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN))
- return false; /* read_callback_ sets the state for us */
- decoder->private_->stream_info.data.stream_info.channels = x+1;
- used_bits += bits;
-
- bits = FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN;
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN))
- return false; /* read_callback_ sets the state for us */
- decoder->private_->stream_info.data.stream_info.bits_per_sample = x+1;
- used_bits += bits;
-
- bits = FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN;
- if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &decoder->private_->stream_info.data.stream_info.total_samples, FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN))
- return false; /* read_callback_ sets the state for us */
- used_bits += bits;
-
- if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, decoder->private_->stream_info.data.stream_info.md5sum, 16))
- return false; /* read_callback_ sets the state for us */
- used_bits += 16*8;
-
- /* skip the rest of the block */
- FLAC__ASSERT(used_bits % 8 == 0);
- length -= (used_bits / 8);
- if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, length))
- return false; /* read_callback_ sets the state for us */
-
- return true;
-}
-
-FLAC__bool read_metadata_seektable_(FLAC__StreamDecoder *decoder, FLAC__bool is_last, unsigned length)
-{
- FLAC__uint32 i, x;
- FLAC__uint64 xx;
-
- FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input));
-
- decoder->private_->seek_table.type = FLAC__METADATA_TYPE_SEEKTABLE;
- decoder->private_->seek_table.is_last = is_last;
- decoder->private_->seek_table.length = length;
-
- decoder->private_->seek_table.data.seek_table.num_points = length / FLAC__STREAM_METADATA_SEEKPOINT_LENGTH;
-
- /* use realloc since we may pass through here several times (e.g. after seeking) */
- if(0 == (decoder->private_->seek_table.data.seek_table.points = (FLAC__StreamMetadata_SeekPoint*)safe_realloc_mul_2op_(decoder->private_->seek_table.data.seek_table.points, decoder->private_->seek_table.data.seek_table.num_points, /*times*/sizeof(FLAC__StreamMetadata_SeekPoint)))) {
- decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
- return false;
- }
- for(i = 0; i < decoder->private_->seek_table.data.seek_table.num_points; i++) {
- if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &xx, FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN))
- return false; /* read_callback_ sets the state for us */
- decoder->private_->seek_table.data.seek_table.points[i].sample_number = xx;
-
- if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &xx, FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN))
- return false; /* read_callback_ sets the state for us */
- decoder->private_->seek_table.data.seek_table.points[i].stream_offset = xx;
-
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN))
- return false; /* read_callback_ sets the state for us */
- decoder->private_->seek_table.data.seek_table.points[i].frame_samples = x;
- }
- length -= (decoder->private_->seek_table.data.seek_table.num_points * FLAC__STREAM_METADATA_SEEKPOINT_LENGTH);
- /* if there is a partial point left, skip over it */
- if(length > 0) {
- /*@@@ do a send_error_to_client_() here? there's an argument for either way */
- if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, length))
- return false; /* read_callback_ sets the state for us */
- }
-
- return true;
-}
-
-FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_VorbisComment *obj)
-{
- FLAC__uint32 i;
-
- FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input));
-
- /* read vendor string */
- FLAC__ASSERT(FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN == 32);
- if(!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->vendor_string.length))
- return false; /* read_callback_ sets the state for us */
- if(obj->vendor_string.length > 0) {
- if(0 == (obj->vendor_string.entry = (FLAC__byte*)safe_malloc_add_2op_(obj->vendor_string.length, /*+*/1))) {
- decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
- return false;
- }
- if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->vendor_string.entry, obj->vendor_string.length))
- return false; /* read_callback_ sets the state for us */
- obj->vendor_string.entry[obj->vendor_string.length] = '\0';
- }
- else
- obj->vendor_string.entry = 0;
-
- /* read num comments */
- FLAC__ASSERT(FLAC__STREAM_METADATA_VORBIS_COMMENT_NUM_COMMENTS_LEN == 32);
- if(!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->num_comments))
- return false; /* read_callback_ sets the state for us */
-
- /* read comments */
- if(obj->num_comments > 0) {
- if(0 == (obj->comments = (FLAC__StreamMetadata_VorbisComment_Entry*)safe_malloc_mul_2op_(obj->num_comments, /*times*/sizeof(FLAC__StreamMetadata_VorbisComment_Entry)))) {
- decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
- return false;
- }
- for(i = 0; i < obj->num_comments; i++) {
- FLAC__ASSERT(FLAC__STREAM_METADATA_VORBIS_COMMENT_ENTRY_LENGTH_LEN == 32);
- if(!FLAC__bitreader_read_uint32_little_endian(decoder->private_->input, &obj->comments[i].length))
- return false; /* read_callback_ sets the state for us */
- if(obj->comments[i].length > 0) {
- if(0 == (obj->comments[i].entry = (FLAC__byte*)safe_malloc_add_2op_(obj->comments[i].length, /*+*/1))) {
- decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
- return false;
- }
- if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->comments[i].entry, obj->comments[i].length))
- return false; /* read_callback_ sets the state for us */
- obj->comments[i].entry[obj->comments[i].length] = '\0';
- }
- else
- obj->comments[i].entry = 0;
- }
- }
- else {
- obj->comments = 0;
- }
-
- return true;
-}
-
-FLAC__bool read_metadata_cuesheet_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_CueSheet *obj)
-{
- FLAC__uint32 i, j, x;
-
- FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input));
-
- memset(obj, 0, sizeof(FLAC__StreamMetadata_CueSheet));
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN % 8 == 0);
- if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, (FLAC__byte*)obj->media_catalog_number, FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN/8))
- return false; /* read_callback_ sets the state for us */
-
- if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &obj->lead_in, FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN))
- return false; /* read_callback_ sets the state for us */
-
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN))
- return false; /* read_callback_ sets the state for us */
- obj->is_cd = x? true : false;
-
- if(!FLAC__bitreader_skip_bits_no_crc(decoder->private_->input, FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN))
- return false; /* read_callback_ sets the state for us */
-
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN))
- return false; /* read_callback_ sets the state for us */
- obj->num_tracks = x;
-
- if(obj->num_tracks > 0) {
- if(0 == (obj->tracks = (FLAC__StreamMetadata_CueSheet_Track*)safe_calloc_(obj->num_tracks, sizeof(FLAC__StreamMetadata_CueSheet_Track)))) {
- decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
- return false;
- }
- for(i = 0; i < obj->num_tracks; i++) {
- FLAC__StreamMetadata_CueSheet_Track *track = &obj->tracks[i];
- if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &track->offset, FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN))
- return false; /* read_callback_ sets the state for us */
-
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN))
- return false; /* read_callback_ sets the state for us */
- track->number = (FLAC__byte)x;
-
- FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN % 8 == 0);
- if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, (FLAC__byte*)track->isrc, FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN/8))
- return false; /* read_callback_ sets the state for us */
-
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN))
- return false; /* read_callback_ sets the state for us */
- track->type = x;
-
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN))
- return false; /* read_callback_ sets the state for us */
- track->pre_emphasis = x;
-
- if(!FLAC__bitreader_skip_bits_no_crc(decoder->private_->input, FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN))
- return false; /* read_callback_ sets the state for us */
-
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN))
- return false; /* read_callback_ sets the state for us */
- track->num_indices = (FLAC__byte)x;
-
- if(track->num_indices > 0) {
- if(0 == (track->indices = (FLAC__StreamMetadata_CueSheet_Index*)safe_calloc_(track->num_indices, sizeof(FLAC__StreamMetadata_CueSheet_Index)))) {
- decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
- return false;
- }
- for(j = 0; j < track->num_indices; j++) {
- FLAC__StreamMetadata_CueSheet_Index *index = &track->indices[j];
- if(!FLAC__bitreader_read_raw_uint64(decoder->private_->input, &index->offset, FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN))
- return false; /* read_callback_ sets the state for us */
-
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN))
- return false; /* read_callback_ sets the state for us */
- index->number = (FLAC__byte)x;
-
- if(!FLAC__bitreader_skip_bits_no_crc(decoder->private_->input, FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN))
- return false; /* read_callback_ sets the state for us */
- }
- }
- }
- }
-
- return true;
-}
-
-FLAC__bool read_metadata_picture_(FLAC__StreamDecoder *decoder, FLAC__StreamMetadata_Picture *obj)
-{
- FLAC__uint32 x;
-
- FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input));
-
- /* read type */
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_PICTURE_TYPE_LEN))
- return false; /* read_callback_ sets the state for us */
- obj->type = x;
-
- /* read MIME type */
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN))
- return false; /* read_callback_ sets the state for us */
- if(0 == (obj->mime_type = (char*)safe_malloc_add_2op_(x, /*+*/1))) {
- decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
- return false;
- }
- if(x > 0) {
- if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, (FLAC__byte*)obj->mime_type, x))
- return false; /* read_callback_ sets the state for us */
- }
- obj->mime_type[x] = '\0';
-
- /* read description */
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN))
- return false; /* read_callback_ sets the state for us */
- if(0 == (obj->description = (FLAC__byte*)safe_malloc_add_2op_(x, /*+*/1))) {
- decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
- return false;
- }
- if(x > 0) {
- if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->description, x))
- return false; /* read_callback_ sets the state for us */
- }
- obj->description[x] = '\0';
-
- /* read width */
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->width, FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN))
- return false; /* read_callback_ sets the state for us */
-
- /* read height */
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->height, FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN))
- return false; /* read_callback_ sets the state for us */
-
- /* read depth */
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->depth, FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN))
- return false; /* read_callback_ sets the state for us */
-
- /* read colors */
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &obj->colors, FLAC__STREAM_METADATA_PICTURE_COLORS_LEN))
- return false; /* read_callback_ sets the state for us */
-
- /* read data */
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &(obj->data_length), FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN))
- return false; /* read_callback_ sets the state for us */
- if(0 == (obj->data = (FLAC__byte*)safe_malloc_(obj->data_length))) {
- decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
- return false;
- }
- if(obj->data_length > 0) {
- if(!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->data, obj->data_length))
- return false; /* read_callback_ sets the state for us */
- }
-
- return true;
-}
-
-FLAC__bool skip_id3v2_tag_(FLAC__StreamDecoder *decoder)
-{
- FLAC__uint32 x;
- unsigned i, skip;
-
- /* skip the version and flags bytes */
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 24))
- return false; /* read_callback_ sets the state for us */
- /* get the size (in bytes) to skip */
- skip = 0;
- for(i = 0; i < 4; i++) {
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8))
- return false; /* read_callback_ sets the state for us */
- skip <<= 7;
- skip |= (x & 0x7f);
- }
- /* skip the rest of the tag */
- if(!FLAC__bitreader_skip_byte_block_aligned_no_crc(decoder->private_->input, skip))
- return false; /* read_callback_ sets the state for us */
- return true;
-}
-
-FLAC__bool frame_sync_(FLAC__StreamDecoder *decoder)
-{
- FLAC__uint32 x;
- FLAC__bool first = true;
-
- /* If we know the total number of samples in the stream, stop if we've read that many. */
- /* This will stop us, for example, from wasting time trying to sync on an ID3V1 tag. */
- if(FLAC__stream_decoder_get_total_samples(decoder) > 0) {
- if(decoder->private_->samples_decoded >= FLAC__stream_decoder_get_total_samples(decoder)) {
- decoder->protected_->state = FLAC__STREAM_DECODER_END_OF_STREAM;
- return true;
- }
- }
-
- /* make sure we're byte aligned */
- if(!FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)) {
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__bitreader_bits_left_for_byte_alignment(decoder->private_->input)))
- return false; /* read_callback_ sets the state for us */
- }
-
- while(1) {
- if(decoder->private_->cached) {
- x = (FLAC__uint32)decoder->private_->lookahead;
- decoder->private_->cached = false;
- }
- else {
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8))
- return false; /* read_callback_ sets the state for us */
- }
- if(x == 0xff) { /* MAGIC NUMBER for the first 8 frame sync bits */
- decoder->private_->header_warmup[0] = (FLAC__byte)x;
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8))
- return false; /* read_callback_ sets the state for us */
-
- /* we have to check if we just read two 0xff's in a row; the second may actually be the beginning of the sync code */
- /* else we have to check if the second byte is the end of a sync code */
- if(x == 0xff) { /* MAGIC NUMBER for the first 8 frame sync bits */
- decoder->private_->lookahead = (FLAC__byte)x;
- decoder->private_->cached = true;
- }
- else if(x >> 1 == 0x7c) { /* MAGIC NUMBER for the last 6 sync bits and reserved 7th bit */
- decoder->private_->header_warmup[1] = (FLAC__byte)x;
- decoder->protected_->state = FLAC__STREAM_DECODER_READ_FRAME;
- return true;
- }
- }
- if(first) {
- send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC);
- first = false;
- }
- }
-
- return true;
-}
-
-FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FLAC__bool do_full_decode)
-{
- unsigned channel;
- unsigned i;
- FLAC__int32 mid, side;
- unsigned frame_crc; /* the one we calculate from the input stream */
- FLAC__uint32 x;
-
- *got_a_frame = false;
-
- /* init the CRC */
- frame_crc = 0;
- frame_crc = FLAC__CRC16_UPDATE(decoder->private_->header_warmup[0], frame_crc);
- frame_crc = FLAC__CRC16_UPDATE(decoder->private_->header_warmup[1], frame_crc);
- FLAC__bitreader_reset_read_crc16(decoder->private_->input, (FLAC__uint16)frame_crc);
-
- if(!read_frame_header_(decoder))
- return false;
- if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means we didn't sync on a valid header */
- return true;
- if(!allocate_output_(decoder, decoder->private_->frame.header.blocksize, decoder->private_->frame.header.channels))
- return false;
- for(channel = 0; channel < decoder->private_->frame.header.channels; channel++) {
- /*
- * first figure the correct bits-per-sample of the subframe
- */
- unsigned bps = decoder->private_->frame.header.bits_per_sample;
- switch(decoder->private_->frame.header.channel_assignment) {
- case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT:
- /* no adjustment needed */
- break;
- case FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE:
- FLAC__ASSERT(decoder->private_->frame.header.channels == 2);
- if(channel == 1)
- bps++;
- break;
- case FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE:
- FLAC__ASSERT(decoder->private_->frame.header.channels == 2);
- if(channel == 0)
- bps++;
- break;
- case FLAC__CHANNEL_ASSIGNMENT_MID_SIDE:
- FLAC__ASSERT(decoder->private_->frame.header.channels == 2);
- if(channel == 1)
- bps++;
- break;
- default:
- FLAC__ASSERT(0);
- }
- /*
- * now read it
- */
- if(!read_subframe_(decoder, channel, bps, do_full_decode))
- return false;
- if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means bad sync or got corruption */
- return true;
- }
- if(!read_zero_padding_(decoder))
- return false;
- if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means bad sync or got corruption (i.e. "zero bits" were not all zeroes) */
- return true;
-
- /*
- * Read the frame CRC-16 from the footer and check
- */
- frame_crc = FLAC__bitreader_get_read_crc16(decoder->private_->input);
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, FLAC__FRAME_FOOTER_CRC_LEN))
- return false; /* read_callback_ sets the state for us */
- if(frame_crc == x) {
- if(do_full_decode) {
- /* Undo any special channel coding */
- switch(decoder->private_->frame.header.channel_assignment) {
- case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT:
- /* do nothing */
- break;
- case FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE:
- FLAC__ASSERT(decoder->private_->frame.header.channels == 2);
- for(i = 0; i < decoder->private_->frame.header.blocksize; i++)
- decoder->private_->output[1][i] = decoder->private_->output[0][i] - decoder->private_->output[1][i];
- break;
- case FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE:
- FLAC__ASSERT(decoder->private_->frame.header.channels == 2);
- for(i = 0; i < decoder->private_->frame.header.blocksize; i++)
- decoder->private_->output[0][i] += decoder->private_->output[1][i];
- break;
- case FLAC__CHANNEL_ASSIGNMENT_MID_SIDE:
- FLAC__ASSERT(decoder->private_->frame.header.channels == 2);
- for(i = 0; i < decoder->private_->frame.header.blocksize; i++) {
-#if 1
- mid = decoder->private_->output[0][i];
- side = decoder->private_->output[1][i];
- mid <<= 1;
- mid |= (side & 1); /* i.e. if 'side' is odd... */
- decoder->private_->output[0][i] = (mid + side) >> 1;
- decoder->private_->output[1][i] = (mid - side) >> 1;
-#else
- /* OPT: without 'side' temp variable */
- mid = (decoder->private_->output[0][i] << 1) | (decoder->private_->output[1][i] & 1); /* i.e. if 'side' is odd... */
- decoder->private_->output[0][i] = (mid + decoder->private_->output[1][i]) >> 1;
- decoder->private_->output[1][i] = (mid - decoder->private_->output[1][i]) >> 1;
-#endif
- }
- break;
- default:
- FLAC__ASSERT(0);
- break;
- }
- }
- }
- else {
- /* Bad frame, emit error and zero the output signal */
- send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH);
- if(do_full_decode) {
- for(channel = 0; channel < decoder->private_->frame.header.channels; channel++) {
- memset(decoder->private_->output[channel], 0, sizeof(FLAC__int32) * decoder->private_->frame.header.blocksize);
- }
- }
- }
-
- *got_a_frame = true;
-
- /* we wait to update fixed_block_size until here, when we're sure we've got a proper frame and hence a correct blocksize */
- if(decoder->private_->next_fixed_block_size)
- decoder->private_->fixed_block_size = decoder->private_->next_fixed_block_size;
-
- /* put the latest values into the public section of the decoder instance */
- decoder->protected_->channels = decoder->private_->frame.header.channels;
- decoder->protected_->channel_assignment = decoder->private_->frame.header.channel_assignment;
- decoder->protected_->bits_per_sample = decoder->private_->frame.header.bits_per_sample;
- decoder->protected_->sample_rate = decoder->private_->frame.header.sample_rate;
- decoder->protected_->blocksize = decoder->private_->frame.header.blocksize;
-
- FLAC__ASSERT(decoder->private_->frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER);
- decoder->private_->samples_decoded = decoder->private_->frame.header.number.sample_number + decoder->private_->frame.header.blocksize;
-
- /* write it */
- if(do_full_decode) {
- if(write_audio_frame_to_client_(decoder, &decoder->private_->frame, (const FLAC__int32 * const *)decoder->private_->output) != FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE)
- return false;
- }
-
- decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
- return true;
-}
-
-FLAC__bool read_frame_header_(FLAC__StreamDecoder *decoder)
-{
- FLAC__uint32 x;
- FLAC__uint64 xx;
- unsigned i, blocksize_hint = 0, sample_rate_hint = 0;
- FLAC__byte crc8, raw_header[16]; /* MAGIC NUMBER based on the maximum frame header size, including CRC */
- unsigned raw_header_len;
- FLAC__bool is_unparseable = false;
-
- FLAC__ASSERT(FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input));
-
- /* init the raw header with the saved bits from synchronization */
- raw_header[0] = decoder->private_->header_warmup[0];
- raw_header[1] = decoder->private_->header_warmup[1];
- raw_header_len = 2;
-
- /* check to make sure that reserved bit is 0 */
- if(raw_header[1] & 0x02) /* MAGIC NUMBER */
- is_unparseable = true;
-
- /*
- * Note that along the way as we read the header, we look for a sync
- * code inside. If we find one it would indicate that our original
- * sync was bad since there cannot be a sync code in a valid header.
- *
- * Three kinds of things can go wrong when reading the frame header:
- * 1) We may have sync'ed incorrectly and not landed on a frame header.
- * If we don't find a sync code, it can end up looking like we read
- * a valid but unparseable header, until getting to the frame header
- * CRC. Even then we could get a false positive on the CRC.
- * 2) We may have sync'ed correctly but on an unparseable frame (from a
- * future encoder).
- * 3) We may be on a damaged frame which appears valid but unparseable.
- *
- * For all these reasons, we try and read a complete frame header as
- * long as it seems valid, even if unparseable, up until the frame
- * header CRC.
- */
-
- /*
- * read in the raw header as bytes so we can CRC it, and parse it on the way
- */
- for(i = 0; i < 2; i++) {
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8))
- return false; /* read_callback_ sets the state for us */
- if(x == 0xff) { /* MAGIC NUMBER for the first 8 frame sync bits */
- /* if we get here it means our original sync was erroneous since the sync code cannot appear in the header */
- decoder->private_->lookahead = (FLAC__byte)x;
- decoder->private_->cached = true;
- send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER);
- decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
- return true;
- }
- raw_header[raw_header_len++] = (FLAC__byte)x;
- }
-
- switch(x = raw_header[2] >> 4) {
- case 0:
- is_unparseable = true;
- break;
- case 1:
- decoder->private_->frame.header.blocksize = 192;
- break;
- case 2:
- case 3:
- case 4:
- case 5:
- decoder->private_->frame.header.blocksize = 576 << (x-2);
- break;
- case 6:
- case 7:
- blocksize_hint = x;
- break;
- case 8:
- case 9:
- case 10:
- case 11:
- case 12:
- case 13:
- case 14:
- case 15:
- decoder->private_->frame.header.blocksize = 256 << (x-8);
- break;
- default:
- FLAC__ASSERT(0);
- break;
- }
-
- switch(x = raw_header[2] & 0x0f) {
- case 0:
- if(decoder->private_->has_stream_info)
- decoder->private_->frame.header.sample_rate = decoder->private_->stream_info.data.stream_info.sample_rate;
- else
- is_unparseable = true;
- break;
- case 1:
- decoder->private_->frame.header.sample_rate = 88200;
- break;
- case 2:
- decoder->private_->frame.header.sample_rate = 176400;
- break;
- case 3:
- decoder->private_->frame.header.sample_rate = 192000;
- break;
- case 4:
- decoder->private_->frame.header.sample_rate = 8000;
- break;
- case 5:
- decoder->private_->frame.header.sample_rate = 16000;
- break;
- case 6:
- decoder->private_->frame.header.sample_rate = 22050;
- break;
- case 7:
- decoder->private_->frame.header.sample_rate = 24000;
- break;
- case 8:
- decoder->private_->frame.header.sample_rate = 32000;
- break;
- case 9:
- decoder->private_->frame.header.sample_rate = 44100;
- break;
- case 10:
- decoder->private_->frame.header.sample_rate = 48000;
- break;
- case 11:
- decoder->private_->frame.header.sample_rate = 96000;
- break;
- case 12:
- case 13:
- case 14:
- sample_rate_hint = x;
- break;
- case 15:
- send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER);
- decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
- return true;
- default:
- FLAC__ASSERT(0);
- }
-
- x = (unsigned)(raw_header[3] >> 4);
- if(x & 8) {
- decoder->private_->frame.header.channels = 2;
- switch(x & 7) {
- case 0:
- decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE;
- break;
- case 1:
- decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE;
- break;
- case 2:
- decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_MID_SIDE;
- break;
- default:
- is_unparseable = true;
- break;
- }
- }
- else {
- decoder->private_->frame.header.channels = (unsigned)x + 1;
- decoder->private_->frame.header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT;
- }
-
- switch(x = (unsigned)(raw_header[3] & 0x0e) >> 1) {
- case 0:
- if(decoder->private_->has_stream_info)
- decoder->private_->frame.header.bits_per_sample = decoder->private_->stream_info.data.stream_info.bits_per_sample;
- else
- is_unparseable = true;
- break;
- case 1:
- decoder->private_->frame.header.bits_per_sample = 8;
- break;
- case 2:
- decoder->private_->frame.header.bits_per_sample = 12;
- break;
- case 4:
- decoder->private_->frame.header.bits_per_sample = 16;
- break;
- case 5:
- decoder->private_->frame.header.bits_per_sample = 20;
- break;
- case 6:
- decoder->private_->frame.header.bits_per_sample = 24;
- break;
- case 3:
- case 7:
- is_unparseable = true;
- break;
- default:
- FLAC__ASSERT(0);
- break;
- }
-
- /* check to make sure that reserved bit is 0 */
- if(raw_header[3] & 0x01) /* MAGIC NUMBER */
- is_unparseable = true;
-
- /* read the frame's starting sample number (or frame number as the case may be) */
- if(
- raw_header[1] & 0x01 ||
- /*@@@ this clause is a concession to the old way of doing variable blocksize; the only known implementation is flake and can probably be removed without inconveniencing anyone */
- (decoder->private_->has_stream_info && decoder->private_->stream_info.data.stream_info.min_blocksize != decoder->private_->stream_info.data.stream_info.max_blocksize)
- ) { /* variable blocksize */
- if(!FLAC__bitreader_read_utf8_uint64(decoder->private_->input, &xx, raw_header, &raw_header_len))
- return false; /* read_callback_ sets the state for us */
- if(xx == FLAC__U64L(0xffffffffffffffff)) { /* i.e. non-UTF8 code... */
- decoder->private_->lookahead = raw_header[raw_header_len-1]; /* back up as much as we can */
- decoder->private_->cached = true;
- send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER);
- decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
- return true;
- }
- decoder->private_->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER;
- decoder->private_->frame.header.number.sample_number = xx;
- }
- else { /* fixed blocksize */
- if(!FLAC__bitreader_read_utf8_uint32(decoder->private_->input, &x, raw_header, &raw_header_len))
- return false; /* read_callback_ sets the state for us */
- if(x == 0xffffffff) { /* i.e. non-UTF8 code... */
- decoder->private_->lookahead = raw_header[raw_header_len-1]; /* back up as much as we can */
- decoder->private_->cached = true;
- send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER);
- decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
- return true;
- }
- decoder->private_->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER;
- decoder->private_->frame.header.number.frame_number = x;
- }
-
- if(blocksize_hint) {
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8))
- return false; /* read_callback_ sets the state for us */
- raw_header[raw_header_len++] = (FLAC__byte)x;
- if(blocksize_hint == 7) {
- FLAC__uint32 _x;
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &_x, 8))
- return false; /* read_callback_ sets the state for us */
- raw_header[raw_header_len++] = (FLAC__byte)_x;
- x = (x << 8) | _x;
- }
- decoder->private_->frame.header.blocksize = x+1;
- }
-
- if(sample_rate_hint) {
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8))
- return false; /* read_callback_ sets the state for us */
- raw_header[raw_header_len++] = (FLAC__byte)x;
- if(sample_rate_hint != 12) {
- FLAC__uint32 _x;
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &_x, 8))
- return false; /* read_callback_ sets the state for us */
- raw_header[raw_header_len++] = (FLAC__byte)_x;
- x = (x << 8) | _x;
- }
- if(sample_rate_hint == 12)
- decoder->private_->frame.header.sample_rate = x*1000;
- else if(sample_rate_hint == 13)
- decoder->private_->frame.header.sample_rate = x;
- else
- decoder->private_->frame.header.sample_rate = x*10;
- }
-
- /* read the CRC-8 byte */
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8))
- return false; /* read_callback_ sets the state for us */
- crc8 = (FLAC__byte)x;
-
- if(FLAC__crc8(raw_header, raw_header_len) != crc8) {
- send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER);
- decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
- return true;
- }
-
- /* calculate the sample number from the frame number if needed */
- decoder->private_->next_fixed_block_size = 0;
- if(decoder->private_->frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER) {
- x = decoder->private_->frame.header.number.frame_number;
- decoder->private_->frame.header.number_type = FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER;
- if(decoder->private_->fixed_block_size)
- decoder->private_->frame.header.number.sample_number = (FLAC__uint64)decoder->private_->fixed_block_size * (FLAC__uint64)x;
- else if(decoder->private_->has_stream_info) {
- if(decoder->private_->stream_info.data.stream_info.min_blocksize == decoder->private_->stream_info.data.stream_info.max_blocksize) {
- decoder->private_->frame.header.number.sample_number = (FLAC__uint64)decoder->private_->stream_info.data.stream_info.min_blocksize * (FLAC__uint64)x;
- decoder->private_->next_fixed_block_size = decoder->private_->stream_info.data.stream_info.max_blocksize;
- }
- else
- is_unparseable = true;
- }
- else if(x == 0) {
- decoder->private_->frame.header.number.sample_number = 0;
- decoder->private_->next_fixed_block_size = decoder->private_->frame.header.blocksize;
- }
- else {
- /* can only get here if the stream has invalid frame numbering and no STREAMINFO, so assume it's not the last (possibly short) frame */
- decoder->private_->frame.header.number.sample_number = (FLAC__uint64)decoder->private_->frame.header.blocksize * (FLAC__uint64)x;
- }
- }
-
- if(is_unparseable) {
- send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM);
- decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
- return true;
- }
-
- return true;
-}
-
-FLAC__bool read_subframe_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, FLAC__bool do_full_decode)
-{
- FLAC__uint32 x;
- FLAC__bool wasted_bits;
- unsigned i;
-
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &x, 8)) /* MAGIC NUMBER */
- return false; /* read_callback_ sets the state for us */
-
- wasted_bits = (x & 1);
- x &= 0xfe;
-
- if(wasted_bits) {
- unsigned u;
- if(!FLAC__bitreader_read_unary_unsigned(decoder->private_->input, &u))
- return false; /* read_callback_ sets the state for us */
- decoder->private_->frame.subframes[channel].wasted_bits = u+1;
- bps -= decoder->private_->frame.subframes[channel].wasted_bits;
- }
- else
- decoder->private_->frame.subframes[channel].wasted_bits = 0;
-
- /*
- * Lots of magic numbers here
- */
- if(x & 0x80) {
- send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC);
- decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
- return true;
- }
- else if(x == 0) {
- if(!read_subframe_constant_(decoder, channel, bps, do_full_decode))
- return false;
- }
- else if(x == 2) {
- if(!read_subframe_verbatim_(decoder, channel, bps, do_full_decode))
- return false;
- }
- else if(x < 16) {
- send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM);
- decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
- return true;
- }
- else if(x <= 24) {
- if(!read_subframe_fixed_(decoder, channel, bps, (x>>1)&7, do_full_decode))
- return false;
- if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means bad sync or got corruption */
- return true;
- }
- else if(x < 64) {
- send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM);
- decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
- return true;
- }
- else {
- if(!read_subframe_lpc_(decoder, channel, bps, ((x>>1)&31)+1, do_full_decode))
- return false;
- if(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC) /* means bad sync or got corruption */
- return true;
- }
-
- if(wasted_bits && do_full_decode) {
- x = decoder->private_->frame.subframes[channel].wasted_bits;
- for(i = 0; i < decoder->private_->frame.header.blocksize; i++)
- decoder->private_->output[channel][i] <<= x;
- }
-
- return true;
-}
-
-FLAC__bool read_subframe_constant_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, FLAC__bool do_full_decode)
-{
- FLAC__Subframe_Constant *subframe = &decoder->private_->frame.subframes[channel].data.constant;
- FLAC__int32 x;
- unsigned i;
- FLAC__int32 *output = decoder->private_->output[channel];
-
- decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_CONSTANT;
-
- if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &x, bps))
- return false; /* read_callback_ sets the state for us */
-
- subframe->value = x;
-
- /* decode the subframe */
- if(do_full_decode) {
- for(i = 0; i < decoder->private_->frame.header.blocksize; i++)
- output[i] = x;
- }
-
- return true;
-}
-
-FLAC__bool read_subframe_fixed_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const unsigned order, FLAC__bool do_full_decode)
-{
- FLAC__Subframe_Fixed *subframe = &decoder->private_->frame.subframes[channel].data.fixed;
- FLAC__int32 i32;
- FLAC__uint32 u32;
- unsigned u;
-
- decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_FIXED;
-
- subframe->residual = decoder->private_->residual[channel];
- subframe->order = order;
-
- /* read warm-up samples */
- for(u = 0; u < order; u++) {
- if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, bps))
- return false; /* read_callback_ sets the state for us */
- subframe->warmup[u] = i32;
- }
-
- /* read entropy coding method info */
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_TYPE_LEN))
- return false; /* read_callback_ sets the state for us */
- subframe->entropy_coding_method.type = (FLAC__EntropyCodingMethodType)u32;
- switch(subframe->entropy_coding_method.type) {
- case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE:
- case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2:
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN))
- return false; /* read_callback_ sets the state for us */
- subframe->entropy_coding_method.data.partitioned_rice.order = u32;
- subframe->entropy_coding_method.data.partitioned_rice.contents = &decoder->private_->partitioned_rice_contents[channel];
- break;
- default:
- send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM);
- decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
- return true;
- }
-
- /* read residual */
- switch(subframe->entropy_coding_method.type) {
- case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE:
- case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2:
- if(!read_residual_partitioned_rice_(decoder, order, subframe->entropy_coding_method.data.partitioned_rice.order, &decoder->private_->partitioned_rice_contents[channel], decoder->private_->residual[channel], /*is_extended=*/subframe->entropy_coding_method.type == FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2))
- return false;
- break;
- default:
- FLAC__ASSERT(0);
- }
-
- /* decode the subframe */
- if(do_full_decode) {
- memcpy(decoder->private_->output[channel], subframe->warmup, sizeof(FLAC__int32) * order);
- FLAC__fixed_restore_signal(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, order, decoder->private_->output[channel]+order);
- }
-
- return true;
-}
-
-FLAC__bool read_subframe_lpc_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, const unsigned order, FLAC__bool do_full_decode)
-{
- FLAC__Subframe_LPC *subframe = &decoder->private_->frame.subframes[channel].data.lpc;
- FLAC__int32 i32;
- FLAC__uint32 u32;
- unsigned u;
-
- decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_LPC;
-
- subframe->residual = decoder->private_->residual[channel];
- subframe->order = order;
-
- /* read warm-up samples */
- for(u = 0; u < order; u++) {
- if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, bps))
- return false; /* read_callback_ sets the state for us */
- subframe->warmup[u] = i32;
- }
-
- /* read qlp coeff precision */
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN))
- return false; /* read_callback_ sets the state for us */
- if(u32 == (1u << FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN) - 1) {
- send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC);
- decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
- return true;
- }
- subframe->qlp_coeff_precision = u32+1;
-
- /* read qlp shift */
- if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN))
- return false; /* read_callback_ sets the state for us */
- subframe->quantization_level = i32;
-
- /* read quantized lp coefficiencts */
- for(u = 0; u < order; u++) {
- if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i32, subframe->qlp_coeff_precision))
- return false; /* read_callback_ sets the state for us */
- subframe->qlp_coeff[u] = i32;
- }
-
- /* read entropy coding method info */
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_TYPE_LEN))
- return false; /* read_callback_ sets the state for us */
- subframe->entropy_coding_method.type = (FLAC__EntropyCodingMethodType)u32;
- switch(subframe->entropy_coding_method.type) {
- case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE:
- case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2:
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &u32, FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN))
- return false; /* read_callback_ sets the state for us */
- subframe->entropy_coding_method.data.partitioned_rice.order = u32;
- subframe->entropy_coding_method.data.partitioned_rice.contents = &decoder->private_->partitioned_rice_contents[channel];
- break;
- default:
- send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM);
- decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
- return true;
- }
-
- /* read residual */
- switch(subframe->entropy_coding_method.type) {
- case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE:
- case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2:
- if(!read_residual_partitioned_rice_(decoder, order, subframe->entropy_coding_method.data.partitioned_rice.order, &decoder->private_->partitioned_rice_contents[channel], decoder->private_->residual[channel], /*is_extended=*/subframe->entropy_coding_method.type == FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2))
- return false;
- break;
- default:
- FLAC__ASSERT(0);
- }
-
- /* decode the subframe */
- if(do_full_decode) {
- memcpy(decoder->private_->output[channel], subframe->warmup, sizeof(FLAC__int32) * order);
- /*@@@@@@ technically not pessimistic enough, should be more like
- if( (FLAC__uint64)order * ((((FLAC__uint64)1)<<bps)-1) * ((1<<subframe->qlp_coeff_precision)-1) < (((FLAC__uint64)-1) << 32) )
- */
- if(bps + subframe->qlp_coeff_precision + FLAC__bitmath_ilog2(order) <= 32)
- if(bps <= 16 && subframe->qlp_coeff_precision <= 16) {
- if(order <= 8)
- decoder->private_->local_lpc_restore_signal_16bit_order8(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, subframe->qlp_coeff, order, subframe->quantization_level, decoder->private_->output[channel]+order);
- else
- decoder->private_->local_lpc_restore_signal_16bit(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, subframe->qlp_coeff, order, subframe->quantization_level, decoder->private_->output[channel]+order);
- }
- else
- decoder->private_->local_lpc_restore_signal(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, subframe->qlp_coeff, order, subframe->quantization_level, decoder->private_->output[channel]+order);
- else
- decoder->private_->local_lpc_restore_signal_64bit(decoder->private_->residual[channel], decoder->private_->frame.header.blocksize-order, subframe->qlp_coeff, order, subframe->quantization_level, decoder->private_->output[channel]+order);
- }
-
- return true;
-}
-
-FLAC__bool read_subframe_verbatim_(FLAC__StreamDecoder *decoder, unsigned channel, unsigned bps, FLAC__bool do_full_decode)
-{
- FLAC__Subframe_Verbatim *subframe = &decoder->private_->frame.subframes[channel].data.verbatim;
- FLAC__int32 x, *residual = decoder->private_->residual[channel];
- unsigned i;
-
- decoder->private_->frame.subframes[channel].type = FLAC__SUBFRAME_TYPE_VERBATIM;
-
- subframe->data = residual;
-
- for(i = 0; i < decoder->private_->frame.header.blocksize; i++) {
- if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &x, bps))
- return false; /* read_callback_ sets the state for us */
- residual[i] = x;
- }
-
- /* decode the subframe */
- if(do_full_decode)
- memcpy(decoder->private_->output[channel], subframe->data, sizeof(FLAC__int32) * decoder->private_->frame.header.blocksize);
-
- return true;
-}
-
-FLAC__bool read_residual_partitioned_rice_(FLAC__StreamDecoder *decoder, unsigned predictor_order, unsigned partition_order, FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents, FLAC__int32 *residual, FLAC__bool is_extended)
-{
- FLAC__uint32 rice_parameter;
- int i;
- unsigned partition, sample, u;
- const unsigned partitions = 1u << partition_order;
- const unsigned partition_samples = partition_order > 0? decoder->private_->frame.header.blocksize >> partition_order : decoder->private_->frame.header.blocksize - predictor_order;
- const unsigned plen = is_extended? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN;
- const unsigned pesc = is_extended? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER;
-
- /* sanity checks */
- if(partition_order == 0) {
- if(decoder->private_->frame.header.blocksize < predictor_order) {
- send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC);
- decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
- return true;
- }
- }
- else {
- if(partition_samples < predictor_order) {
- send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC);
- decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
- return true;
- }
- }
-
- if(!FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(partitioned_rice_contents, max(6, partition_order))) {
- decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
- return false;
- }
-
- sample = 0;
- for(partition = 0; partition < partitions; partition++) {
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &rice_parameter, plen))
- return false; /* read_callback_ sets the state for us */
- partitioned_rice_contents->parameters[partition] = rice_parameter;
- if(rice_parameter < pesc) {
- partitioned_rice_contents->raw_bits[partition] = 0;
- u = (partition_order == 0 || partition > 0)? partition_samples : partition_samples - predictor_order;
- if(!decoder->private_->local_bitreader_read_rice_signed_block(decoder->private_->input, residual + sample, u, rice_parameter))
- return false; /* read_callback_ sets the state for us */
- sample += u;
- }
- else {
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &rice_parameter, FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN))
- return false; /* read_callback_ sets the state for us */
- partitioned_rice_contents->raw_bits[partition] = rice_parameter;
- for(u = (partition_order == 0 || partition > 0)? 0 : predictor_order; u < partition_samples; u++, sample++) {
- if(!FLAC__bitreader_read_raw_int32(decoder->private_->input, &i, rice_parameter))
- return false; /* read_callback_ sets the state for us */
- residual[sample] = i;
- }
- }
- }
-
- return true;
-}
-
-FLAC__bool read_zero_padding_(FLAC__StreamDecoder *decoder)
-{
- if(!FLAC__bitreader_is_consumed_byte_aligned(decoder->private_->input)) {
- FLAC__uint32 zero = 0;
- if(!FLAC__bitreader_read_raw_uint32(decoder->private_->input, &zero, FLAC__bitreader_bits_left_for_byte_alignment(decoder->private_->input)))
- return false; /* read_callback_ sets the state for us */
- if(zero != 0) {
- send_error_to_client_(decoder, FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC);
- decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;
- }
- }
- return true;
-}
-
-FLAC__bool read_callback_(FLAC__byte buffer[], size_t *bytes, void *client_data)
-{
- FLAC__StreamDecoder *decoder = (FLAC__StreamDecoder *)client_data;
-
- if(
-#if FLAC__HAS_OGG
- /* see [1] HACK NOTE below for why we don't call the eof_callback when decoding Ogg FLAC */
- !decoder->private_->is_ogg &&
-#endif
- decoder->private_->eof_callback && decoder->private_->eof_callback(decoder, decoder->private_->client_data)
- ) {
- *bytes = 0;
- decoder->protected_->state = FLAC__STREAM_DECODER_END_OF_STREAM;
- return false;
- }
- else if(*bytes > 0) {
- /* While seeking, it is possible for our seek to land in the
- * middle of audio data that looks exactly like a frame header
- * from a future version of an encoder. When that happens, our
- * error callback will get an
- * FLAC__STREAM_DECODER_UNPARSEABLE_STREAM and increment its
- * unparseable_frame_count. But there is a remote possibility
- * that it is properly synced at such a "future-codec frame",
- * so to make sure, we wait to see many "unparseable" errors in
- * a row before bailing out.
- */
- if(decoder->private_->is_seeking && decoder->private_->unparseable_frame_count > 20) {
- decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED;
- return false;
- }
- else {
- const FLAC__StreamDecoderReadStatus status =
-#if FLAC__HAS_OGG
- decoder->private_->is_ogg?
- read_callback_ogg_aspect_(decoder, buffer, bytes) :
-#endif
- decoder->private_->read_callback(decoder, buffer, bytes, decoder->private_->client_data)
- ;
- if(status == FLAC__STREAM_DECODER_READ_STATUS_ABORT) {
- decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED;
- return false;
- }
- else if(*bytes == 0) {
- if(
- status == FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM ||
- (
-#if FLAC__HAS_OGG
- /* see [1] HACK NOTE below for why we don't call the eof_callback when decoding Ogg FLAC */
- !decoder->private_->is_ogg &&
-#endif
- decoder->private_->eof_callback && decoder->private_->eof_callback(decoder, decoder->private_->client_data)
- )
- ) {
- decoder->protected_->state = FLAC__STREAM_DECODER_END_OF_STREAM;
- return false;
- }
- else
- return true;
- }
- else
- return true;
- }
- }
- else {
- /* abort to avoid a deadlock */
- decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED;
- return false;
- }
- /* [1] @@@ HACK NOTE: The end-of-stream checking has to be hacked around
- * for Ogg FLAC. This is because the ogg decoder aspect can lose sync
- * and at the same time hit the end of the stream (for example, seeking
- * to a point that is after the beginning of the last Ogg page). There
- * is no way to report an Ogg sync loss through the callbacks (see note
- * in read_callback_ogg_aspect_()) so it returns CONTINUE with *bytes==0.
- * So to keep the decoder from stopping at this point we gate the call
- * to the eof_callback and let the Ogg decoder aspect set the
- * end-of-stream state when it is needed.
- */
-}
-
-#if FLAC__HAS_OGG
-FLAC__StreamDecoderReadStatus read_callback_ogg_aspect_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes)
-{
- switch(FLAC__ogg_decoder_aspect_read_callback_wrapper(&decoder->protected_->ogg_decoder_aspect, buffer, bytes, read_callback_proxy_, decoder, decoder->private_->client_data)) {
- case FLAC__OGG_DECODER_ASPECT_READ_STATUS_OK:
- return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
- /* we don't really have a way to handle lost sync via read
- * callback so we'll let it pass and let the underlying
- * FLAC decoder catch the error
- */
- case FLAC__OGG_DECODER_ASPECT_READ_STATUS_LOST_SYNC:
- return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
- case FLAC__OGG_DECODER_ASPECT_READ_STATUS_END_OF_STREAM:
- return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
- case FLAC__OGG_DECODER_ASPECT_READ_STATUS_NOT_FLAC:
- case FLAC__OGG_DECODER_ASPECT_READ_STATUS_UNSUPPORTED_MAPPING_VERSION:
- case FLAC__OGG_DECODER_ASPECT_READ_STATUS_ABORT:
- case FLAC__OGG_DECODER_ASPECT_READ_STATUS_ERROR:
- case FLAC__OGG_DECODER_ASPECT_READ_STATUS_MEMORY_ALLOCATION_ERROR:
- return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
- default:
- FLAC__ASSERT(0);
- /* double protection */
- return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
- }
-}
-
-FLAC__OggDecoderAspectReadStatus read_callback_proxy_(const void *void_decoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
-{
- FLAC__StreamDecoder *decoder = (FLAC__StreamDecoder*)void_decoder;
-
- switch(decoder->private_->read_callback(decoder, buffer, bytes, client_data)) {
- case FLAC__STREAM_DECODER_READ_STATUS_CONTINUE:
- return FLAC__OGG_DECODER_ASPECT_READ_STATUS_OK;
- case FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM:
- return FLAC__OGG_DECODER_ASPECT_READ_STATUS_END_OF_STREAM;
- case FLAC__STREAM_DECODER_READ_STATUS_ABORT:
- return FLAC__OGG_DECODER_ASPECT_READ_STATUS_ABORT;
- default:
- /* double protection: */
- FLAC__ASSERT(0);
- return FLAC__OGG_DECODER_ASPECT_READ_STATUS_ABORT;
- }
-}
-#endif
-
-FLAC__StreamDecoderWriteStatus write_audio_frame_to_client_(FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[])
-{
- if(decoder->private_->is_seeking) {
- FLAC__uint64 this_frame_sample = frame->header.number.sample_number;
- FLAC__uint64 next_frame_sample = this_frame_sample + (FLAC__uint64)frame->header.blocksize;
- FLAC__uint64 target_sample = decoder->private_->target_sample;
-
- FLAC__ASSERT(frame->header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER);
-
-#if FLAC__HAS_OGG
- decoder->private_->got_a_frame = true;
-#endif
- decoder->private_->last_frame = *frame; /* save the frame */
- if(this_frame_sample <= target_sample && target_sample < next_frame_sample) { /* we hit our target frame */
- unsigned delta = (unsigned)(target_sample - this_frame_sample);
- /* kick out of seek mode */
- decoder->private_->is_seeking = false;
- /* shift out the samples before target_sample */
- if(delta > 0) {
- unsigned channel;
- const FLAC__int32 *newbuffer[FLAC__MAX_CHANNELS];
- for(channel = 0; channel < frame->header.channels; channel++)
- newbuffer[channel] = buffer[channel] + delta;
- decoder->private_->last_frame.header.blocksize -= delta;
- decoder->private_->last_frame.header.number.sample_number += (FLAC__uint64)delta;
- /* write the relevant samples */
- return decoder->private_->write_callback(decoder, &decoder->private_->last_frame, newbuffer, decoder->private_->client_data);
- }
- else {
- /* write the relevant samples */
- return decoder->private_->write_callback(decoder, frame, buffer, decoder->private_->client_data);
- }
- }
- else {
- return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
- }
- }
- else {
- /*
- * If we never got STREAMINFO, turn off MD5 checking to save
- * cycles since we don't have a sum to compare to anyway
- */
- if(!decoder->private_->has_stream_info)
- decoder->private_->do_md5_checking = false;
- if(decoder->private_->do_md5_checking) {
- if(!FLAC__MD5Accumulate(&decoder->private_->md5context, buffer, frame->header.channels, frame->header.blocksize, (frame->header.bits_per_sample+7) / 8))
- return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
- }
- return decoder->private_->write_callback(decoder, frame, buffer, decoder->private_->client_data);
- }
-}
-
-void send_error_to_client_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status)
-{
- if(!decoder->private_->is_seeking)
- decoder->private_->error_callback(decoder, status, decoder->private_->client_data);
- else if(status == FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM)
- decoder->private_->unparseable_frame_count++;
-}
-
-FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length, FLAC__uint64 target_sample)
-{
- FLAC__uint64 first_frame_offset = decoder->private_->first_frame_offset, lower_bound, upper_bound, lower_bound_sample, upper_bound_sample, this_frame_sample;
- FLAC__int64 pos = -1;
- int i;
- unsigned approx_bytes_per_frame;
- FLAC__bool first_seek = true;
- const FLAC__uint64 total_samples = FLAC__stream_decoder_get_total_samples(decoder);
- const unsigned min_blocksize = decoder->private_->stream_info.data.stream_info.min_blocksize;
- const unsigned max_blocksize = decoder->private_->stream_info.data.stream_info.max_blocksize;
- const unsigned max_framesize = decoder->private_->stream_info.data.stream_info.max_framesize;
- const unsigned min_framesize = decoder->private_->stream_info.data.stream_info.min_framesize;
- /* take these from the current frame in case they've changed mid-stream */
- unsigned channels = FLAC__stream_decoder_get_channels(decoder);
- unsigned bps = FLAC__stream_decoder_get_bits_per_sample(decoder);
- const FLAC__StreamMetadata_SeekTable *seek_table = decoder->private_->has_seek_table? &decoder->private_->seek_table.data.seek_table : 0;
-
- /* use values from stream info if we didn't decode a frame */
- if(channels == 0)
- channels = decoder->private_->stream_info.data.stream_info.channels;
- if(bps == 0)
- bps = decoder->private_->stream_info.data.stream_info.bits_per_sample;
-
- /* we are just guessing here */
- if(max_framesize > 0)
- approx_bytes_per_frame = (max_framesize + min_framesize) / 2 + 1;
- /*
- * Check if it's a known fixed-blocksize stream. Note that though
- * the spec doesn't allow zeroes in the STREAMINFO block, we may
- * never get a STREAMINFO block when decoding so the value of
- * min_blocksize might be zero.
- */
- else if(min_blocksize == max_blocksize && min_blocksize > 0) {
- /* note there are no () around 'bps/8' to keep precision up since it's an integer calulation */
- approx_bytes_per_frame = min_blocksize * channels * bps/8 + 64;
- }
- else
- approx_bytes_per_frame = 4096 * channels * bps/8 + 64;
-
- /*
- * First, we set an upper and lower bound on where in the
- * stream we will search. For now we assume the worst case
- * scenario, which is our best guess at the beginning of
- * the first frame and end of the stream.
- */
- lower_bound = first_frame_offset;
- lower_bound_sample = 0;
- upper_bound = stream_length;
- upper_bound_sample = total_samples > 0 ? total_samples : target_sample /*estimate it*/;
-
- /*
- * Now we refine the bounds if we have a seektable with
- * suitable points. Note that according to the spec they
- * must be ordered by ascending sample number.
- *
- * Note: to protect against invalid seek tables we will ignore points
- * that have frame_samples==0 or sample_number>=total_samples
- */
- if(seek_table) {
- FLAC__uint64 new_lower_bound = lower_bound;
- FLAC__uint64 new_upper_bound = upper_bound;
- FLAC__uint64 new_lower_bound_sample = lower_bound_sample;
- FLAC__uint64 new_upper_bound_sample = upper_bound_sample;
-
- /* find the closest seek point <= target_sample, if it exists */
- for(i = (int)seek_table->num_points - 1; i >= 0; i--) {
- if(
- seek_table->points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER &&
- seek_table->points[i].frame_samples > 0 && /* defense against bad seekpoints */
- (total_samples <= 0 || seek_table->points[i].sample_number < total_samples) && /* defense against bad seekpoints */
- seek_table->points[i].sample_number <= target_sample
- )
- break;
- }
- if(i >= 0) { /* i.e. we found a suitable seek point... */
- new_lower_bound = first_frame_offset + seek_table->points[i].stream_offset;
- new_lower_bound_sample = seek_table->points[i].sample_number;
- }
-
- /* find the closest seek point > target_sample, if it exists */
- for(i = 0; i < (int)seek_table->num_points; i++) {
- if(
- seek_table->points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER &&
- seek_table->points[i].frame_samples > 0 && /* defense against bad seekpoints */
- (total_samples <= 0 || seek_table->points[i].sample_number < total_samples) && /* defense against bad seekpoints */
- seek_table->points[i].sample_number > target_sample
- )
- break;
- }
- if(i < (int)seek_table->num_points) { /* i.e. we found a suitable seek point... */
- new_upper_bound = first_frame_offset + seek_table->points[i].stream_offset;
- new_upper_bound_sample = seek_table->points[i].sample_number;
- }
- /* final protection against unsorted seek tables; keep original values if bogus */
- if(new_upper_bound >= new_lower_bound) {
- lower_bound = new_lower_bound;
- upper_bound = new_upper_bound;
- lower_bound_sample = new_lower_bound_sample;
- upper_bound_sample = new_upper_bound_sample;
- }
- }
-
- FLAC__ASSERT(upper_bound_sample >= lower_bound_sample);
- /* there are 2 insidious ways that the following equality occurs, which
- * we need to fix:
- * 1) total_samples is 0 (unknown) and target_sample is 0
- * 2) total_samples is 0 (unknown) and target_sample happens to be
- * exactly equal to the last seek point in the seek table; this
- * means there is no seek point above it, and upper_bound_samples
- * remains equal to the estimate (of target_samples) we made above
- * in either case it does not hurt to move upper_bound_sample up by 1
- */
- if(upper_bound_sample == lower_bound_sample)
- upper_bound_sample++;
-
- decoder->private_->target_sample = target_sample;
- while(1) {
- /* check if the bounds are still ok */
- if (lower_bound_sample >= upper_bound_sample || lower_bound > upper_bound) {
- decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR;
- return false;
- }
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
-#if defined _MSC_VER || defined __MINGW32__
- /* with VC++ you have to spoon feed it the casting */
- pos = (FLAC__int64)lower_bound + (FLAC__int64)((FLAC__double)(FLAC__int64)(target_sample - lower_bound_sample) / (FLAC__double)(FLAC__int64)(upper_bound_sample - lower_bound_sample) * (FLAC__double)(FLAC__int64)(upper_bound - lower_bound)) - approx_bytes_per_frame;
-#else
- pos = (FLAC__int64)lower_bound + (FLAC__int64)((FLAC__double)(target_sample - lower_bound_sample) / (FLAC__double)(upper_bound_sample - lower_bound_sample) * (FLAC__double)(upper_bound - lower_bound)) - approx_bytes_per_frame;
-#endif
-#else
- /* a little less accurate: */
- if(upper_bound - lower_bound < 0xffffffff)
- pos = (FLAC__int64)lower_bound + (FLAC__int64)(((target_sample - lower_bound_sample) * (upper_bound - lower_bound)) / (upper_bound_sample - lower_bound_sample)) - approx_bytes_per_frame;
- else /* @@@ WATCHOUT, ~2TB limit */
- pos = (FLAC__int64)lower_bound + (FLAC__int64)((((target_sample - lower_bound_sample)>>8) * ((upper_bound - lower_bound)>>8)) / ((upper_bound_sample - lower_bound_sample)>>16)) - approx_bytes_per_frame;
-#endif
- if(pos >= (FLAC__int64)upper_bound)
- pos = (FLAC__int64)upper_bound - 1;
- if(pos < (FLAC__int64)lower_bound)
- pos = (FLAC__int64)lower_bound;
- if(decoder->private_->seek_callback(decoder, (FLAC__uint64)pos, decoder->private_->client_data) != FLAC__STREAM_DECODER_SEEK_STATUS_OK) {
- decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR;
- return false;
- }
- if(!FLAC__stream_decoder_flush(decoder)) {
- /* above call sets the state for us */
- return false;
- }
- /* Now we need to get a frame. First we need to reset our
- * unparseable_frame_count; if we get too many unparseable
- * frames in a row, the read callback will return
- * FLAC__STREAM_DECODER_READ_STATUS_ABORT, causing
- * FLAC__stream_decoder_process_single() to return false.
- */
- decoder->private_->unparseable_frame_count = 0;
- if(!FLAC__stream_decoder_process_single(decoder)) {
- decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR;
- return false;
- }
- /* our write callback will change the state when it gets to the target frame */
- /* actually, we could have got_a_frame if our decoder is at FLAC__STREAM_DECODER_END_OF_STREAM so we need to check for that also */
-#if 0
- /*@@@@@@ used to be the following; not clear if the check for end of stream is needed anymore */
- if(decoder->protected_->state != FLAC__SEEKABLE_STREAM_DECODER_SEEKING && decoder->protected_->state != FLAC__STREAM_DECODER_END_OF_STREAM)
- break;
-#endif
- if(!decoder->private_->is_seeking)
- break;
-
- FLAC__ASSERT(decoder->private_->last_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER);
- this_frame_sample = decoder->private_->last_frame.header.number.sample_number;
-
- if (0 == decoder->private_->samples_decoded || (this_frame_sample + decoder->private_->last_frame.header.blocksize >= upper_bound_sample && !first_seek)) {
- if (pos == (FLAC__int64)lower_bound) {
- /* can't move back any more than the first frame, something is fatally wrong */
- decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR;
- return false;
- }
- /* our last move backwards wasn't big enough, try again */
- approx_bytes_per_frame = approx_bytes_per_frame? approx_bytes_per_frame * 2 : 16;
- continue;
- }
- /* allow one seek over upper bound, so we can get a correct upper_bound_sample for streams with unknown total_samples */
- first_seek = false;
-
- /* make sure we are not seeking in corrupted stream */
- if (this_frame_sample < lower_bound_sample) {
- decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR;
- return false;
- }
-
- /* we need to narrow the search */
- if(target_sample < this_frame_sample) {
- upper_bound_sample = this_frame_sample + decoder->private_->last_frame.header.blocksize;
-/*@@@@@@ what will decode position be if at end of stream? */
- if(!FLAC__stream_decoder_get_decode_position(decoder, &upper_bound)) {
- decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR;
- return false;
- }
- approx_bytes_per_frame = (unsigned)(2 * (upper_bound - pos) / 3 + 16);
- }
- else { /* target_sample >= this_frame_sample + this frame's blocksize */
- lower_bound_sample = this_frame_sample + decoder->private_->last_frame.header.blocksize;
- if(!FLAC__stream_decoder_get_decode_position(decoder, &lower_bound)) {
- decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR;
- return false;
- }
- approx_bytes_per_frame = (unsigned)(2 * (lower_bound - pos) / 3 + 16);
- }
- }
-
- return true;
-}
-
-#if FLAC__HAS_OGG
-FLAC__bool seek_to_absolute_sample_ogg_(FLAC__StreamDecoder *decoder, FLAC__uint64 stream_length, FLAC__uint64 target_sample)
-{
- FLAC__uint64 left_pos = 0, right_pos = stream_length;
- FLAC__uint64 left_sample = 0, right_sample = FLAC__stream_decoder_get_total_samples(decoder);
- FLAC__uint64 this_frame_sample = (FLAC__uint64)0 - 1;
- FLAC__uint64 pos = 0; /* only initialized to avoid compiler warning */
- FLAC__bool did_a_seek;
- unsigned iteration = 0;
-
- /* In the first iterations, we will calculate the target byte position
- * by the distance from the target sample to left_sample and
- * right_sample (let's call it "proportional search"). After that, we
- * will switch to binary search.
- */
- unsigned BINARY_SEARCH_AFTER_ITERATION = 2;
-
- /* We will switch to a linear search once our current sample is less
- * than this number of samples ahead of the target sample
- */
- static const FLAC__uint64 LINEAR_SEARCH_WITHIN_SAMPLES = FLAC__MAX_BLOCK_SIZE * 2;
-
- /* If the total number of samples is unknown, use a large value, and
- * force binary search immediately.
- */
- if(right_sample == 0) {
- right_sample = (FLAC__uint64)(-1);
- BINARY_SEARCH_AFTER_ITERATION = 0;
- }
-
- decoder->private_->target_sample = target_sample;
- for( ; ; iteration++) {
- if (iteration == 0 || this_frame_sample > target_sample || target_sample - this_frame_sample > LINEAR_SEARCH_WITHIN_SAMPLES) {
- if (iteration >= BINARY_SEARCH_AFTER_ITERATION) {
- pos = (right_pos + left_pos) / 2;
- }
- else {
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
-#if defined _MSC_VER || defined __MINGW32__
- /* with MSVC you have to spoon feed it the casting */
- pos = (FLAC__uint64)((FLAC__double)(FLAC__int64)(target_sample - left_sample) / (FLAC__double)(FLAC__int64)(right_sample - left_sample) * (FLAC__double)(FLAC__int64)(right_pos - left_pos));
-#else
- pos = (FLAC__uint64)((FLAC__double)(target_sample - left_sample) / (FLAC__double)(right_sample - left_sample) * (FLAC__double)(right_pos - left_pos));
-#endif
-#else
- /* a little less accurate: */
- if ((target_sample-left_sample <= 0xffffffff) && (right_pos-left_pos <= 0xffffffff))
- pos = (FLAC__int64)(((target_sample-left_sample) * (right_pos-left_pos)) / (right_sample-left_sample));
- else /* @@@ WATCHOUT, ~2TB limit */
- pos = (FLAC__int64)((((target_sample-left_sample)>>8) * ((right_pos-left_pos)>>8)) / ((right_sample-left_sample)>>16));
-#endif
- /* @@@ TODO: might want to limit pos to some distance
- * before EOF, to make sure we land before the last frame,
- * thereby getting a this_frame_sample and so having a better
- * estimate.
- */
- }
-
- /* physical seek */
- if(decoder->private_->seek_callback((FLAC__StreamDecoder*)decoder, (FLAC__uint64)pos, decoder->private_->client_data) != FLAC__STREAM_DECODER_SEEK_STATUS_OK) {
- decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR;
- return false;
- }
- if(!FLAC__stream_decoder_flush(decoder)) {
- /* above call sets the state for us */
- return false;
- }
- did_a_seek = true;
- }
- else
- did_a_seek = false;
-
- decoder->private_->got_a_frame = false;
- if(!FLAC__stream_decoder_process_single(decoder)) {
- decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR;
- return false;
- }
- if(!decoder->private_->got_a_frame) {
- if(did_a_seek) {
- /* this can happen if we seek to a point after the last frame; we drop
- * to binary search right away in this case to avoid any wasted
- * iterations of proportional search.
- */
- right_pos = pos;
- BINARY_SEARCH_AFTER_ITERATION = 0;
- }
- else {
- /* this can probably only happen if total_samples is unknown and the
- * target_sample is past the end of the stream
- */
- decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR;
- return false;
- }
- }
- /* our write callback will change the state when it gets to the target frame */
- else if(!decoder->private_->is_seeking) {
- break;
- }
- else {
- this_frame_sample = decoder->private_->last_frame.header.number.sample_number;
- FLAC__ASSERT(decoder->private_->last_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER);
-
- if (did_a_seek) {
- if (this_frame_sample <= target_sample) {
- /* The 'equal' case should not happen, since
- * FLAC__stream_decoder_process_single()
- * should recognize that it has hit the
- * target sample and we would exit through
- * the 'break' above.
- */
- FLAC__ASSERT(this_frame_sample != target_sample);
-
- left_sample = this_frame_sample;
- /* sanity check to avoid infinite loop */
- if (left_pos == pos) {
- decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR;
- return false;
- }
- left_pos = pos;
- }
- else if(this_frame_sample > target_sample) {
- right_sample = this_frame_sample;
- /* sanity check to avoid infinite loop */
- if (right_pos == pos) {
- decoder->protected_->state = FLAC__STREAM_DECODER_SEEK_ERROR;
- return false;
- }
- right_pos = pos;
- }
- }
- }
- }
-
- return true;
-}
-#endif
-
-FLAC__StreamDecoderReadStatus file_read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
-{
- (void)client_data;
-
- if(*bytes > 0) {
- *bytes = fread(buffer, sizeof(FLAC__byte), *bytes, decoder->private_->file);
- if(ferror(decoder->private_->file))
- return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
- else if(*bytes == 0)
- return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
- else
- return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
- }
- else
- return FLAC__STREAM_DECODER_READ_STATUS_ABORT; /* abort to avoid a deadlock */
-}
-
-FLAC__StreamDecoderSeekStatus file_seek_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data)
-{
- (void)client_data;
-
- if(decoder->private_->file == stdin)
- return FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED;
- else if(fseeko(decoder->private_->file, (off_t)absolute_byte_offset, SEEK_SET) < 0)
- return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
- else
- return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
-}
-
-FLAC__StreamDecoderTellStatus file_tell_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data)
-{
- off_t pos;
- (void)client_data;
-
- if(decoder->private_->file == stdin)
- return FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED;
- else if((pos = ftello(decoder->private_->file)) < 0)
- return FLAC__STREAM_DECODER_TELL_STATUS_ERROR;
- else {
- *absolute_byte_offset = (FLAC__uint64)pos;
- return FLAC__STREAM_DECODER_TELL_STATUS_OK;
- }
-}
-
-FLAC__StreamDecoderLengthStatus file_length_callback_(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data)
-{
- struct stat filestats;
- (void)client_data;
-
- if(decoder->private_->file == stdin)
- return FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED;
- else if(fstat(fileno(decoder->private_->file), &filestats) != 0)
- return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
- else {
- *stream_length = (FLAC__uint64)filestats.st_size;
- return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
- }
-}
-
-FLAC__bool file_eof_callback_(const FLAC__StreamDecoder *decoder, void *client_data)
-{
- (void)client_data;
-
- return feof(decoder->private_->file)? true : false;
-}
diff --git a/src/thirdparty/libflac/src/libFLAC/stream_encoder.c b/src/thirdparty/libflac/src/libFLAC/stream_encoder.c
deleted file mode 100644
index 058412188..000000000
--- a/src/thirdparty/libflac/src/libFLAC/stream_encoder.c
+++ /dev/null
@@ -1,4348 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#if defined _MSC_VER || defined __MINGW32__
-#include <io.h> /* for _setmode() */
-#include <fcntl.h> /* for _O_BINARY */
-#endif
-#if defined __CYGWIN__ || defined __EMX__
-#include <io.h> /* for setmode(), O_BINARY */
-#include <fcntl.h> /* for _O_BINARY */
-#endif
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h> /* for malloc() */
-#include <string.h> /* for memcpy() */
-#include <sys/types.h> /* for off_t */
-#if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__
-#if _MSC_VER <= 1700 || defined __BORLANDC__ /* @@@ [2G limit] */
-#define fseeko fseek
-#define ftello ftell
-#endif
-#endif
-#include "FLAC/assert.h"
-#include "FLAC/stream_decoder.h"
-#include "share/alloc.h"
-#include "protected/stream_encoder.h"
-#include "private/bitwriter.h"
-#include "private/bitmath.h"
-#include "private/crc.h"
-#include "private/cpu.h"
-#include "private/fixed.h"
-#include "private/format.h"
-#include "private/lpc.h"
-#include "private/md5.h"
-#include "private/memory.h"
-#if FLAC__HAS_OGG
-#include "private/ogg_helper.h"
-#include "private/ogg_mapping.h"
-#endif
-#include "private/stream_encoder_framing.h"
-#include "private/window.h"
-
-#ifndef FLaC__INLINE
-#define FLaC__INLINE
-#endif
-
-#ifdef min
-#undef min
-#endif
-#define min(x,y) ((x)<(y)?(x):(y))
-
-#ifdef max
-#undef max
-#endif
-#define max(x,y) ((x)>(y)?(x):(y))
-
-/* Exact Rice codeword length calculation is off by default. The simple
- * (and fast) estimation (of how many bits a residual value will be
- * encoded with) in this encoder is very good, almost always yielding
- * compression within 0.1% of exact calculation.
- */
-#undef EXACT_RICE_BITS_CALCULATION
-/* Rice parameter searching is off by default. The simple (and fast)
- * parameter estimation in this encoder is very good, almost always
- * yielding compression within 0.1% of the optimal parameters.
- */
-#undef ENABLE_RICE_PARAMETER_SEARCH
-
-
-typedef struct {
- FLAC__int32 *data[FLAC__MAX_CHANNELS];
- unsigned size; /* of each data[] in samples */
- unsigned tail;
-} verify_input_fifo;
-
-typedef struct {
- const FLAC__byte *data;
- unsigned capacity;
- unsigned bytes;
-} verify_output;
-
-typedef enum {
- ENCODER_IN_MAGIC = 0,
- ENCODER_IN_METADATA = 1,
- ENCODER_IN_AUDIO = 2
-} EncoderStateHint;
-
-static struct CompressionLevels {
- FLAC__bool do_mid_side_stereo;
- FLAC__bool loose_mid_side_stereo;
- unsigned max_lpc_order;
- unsigned qlp_coeff_precision;
- FLAC__bool do_qlp_coeff_prec_search;
- FLAC__bool do_escape_coding;
- FLAC__bool do_exhaustive_model_search;
- unsigned min_residual_partition_order;
- unsigned max_residual_partition_order;
- unsigned rice_parameter_search_dist;
-} compression_levels_[] = {
- { false, false, 0, 0, false, false, false, 0, 3, 0 },
- { true , true , 0, 0, false, false, false, 0, 3, 0 },
- { true , false, 0, 0, false, false, false, 0, 3, 0 },
- { false, false, 6, 0, false, false, false, 0, 4, 0 },
- { true , true , 8, 0, false, false, false, 0, 4, 0 },
- { true , false, 8, 0, false, false, false, 0, 5, 0 },
- { true , false, 8, 0, false, false, false, 0, 6, 0 },
- { true , false, 8, 0, false, false, true , 0, 6, 0 },
- { true , false, 12, 0, false, false, true , 0, 6, 0 }
-};
-
-
-/***********************************************************************
- *
- * Private class method prototypes
- *
- ***********************************************************************/
-
-static void set_defaults_(FLAC__StreamEncoder *encoder);
-static void free_(FLAC__StreamEncoder *encoder);
-static FLAC__bool resize_buffers_(FLAC__StreamEncoder *encoder, unsigned new_blocksize);
-static FLAC__bool write_bitbuffer_(FLAC__StreamEncoder *encoder, unsigned samples, FLAC__bool is_last_block);
-static FLAC__StreamEncoderWriteStatus write_frame_(FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, FLAC__bool is_last_block);
-static void update_metadata_(const FLAC__StreamEncoder *encoder);
-#if FLAC__HAS_OGG
-static void update_ogg_metadata_(FLAC__StreamEncoder *encoder);
-#endif
-static FLAC__bool process_frame_(FLAC__StreamEncoder *encoder, FLAC__bool is_fractional_block, FLAC__bool is_last_block);
-static FLAC__bool process_subframes_(FLAC__StreamEncoder *encoder, FLAC__bool is_fractional_block);
-
-static FLAC__bool process_subframe_(
- FLAC__StreamEncoder *encoder,
- unsigned min_partition_order,
- unsigned max_partition_order,
- const FLAC__FrameHeader *frame_header,
- unsigned subframe_bps,
- const FLAC__int32 integer_signal[],
- FLAC__Subframe *subframe[2],
- FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents[2],
- FLAC__int32 *residual[2],
- unsigned *best_subframe,
- unsigned *best_bits
-);
-
-static FLAC__bool add_subframe_(
- FLAC__StreamEncoder *encoder,
- unsigned blocksize,
- unsigned subframe_bps,
- const FLAC__Subframe *subframe,
- FLAC__BitWriter *frame
-);
-
-static unsigned evaluate_constant_subframe_(
- FLAC__StreamEncoder *encoder,
- const FLAC__int32 signal,
- unsigned blocksize,
- unsigned subframe_bps,
- FLAC__Subframe *subframe
-);
-
-static unsigned evaluate_fixed_subframe_(
- FLAC__StreamEncoder *encoder,
- const FLAC__int32 signal[],
- FLAC__int32 residual[],
- FLAC__uint64 abs_residual_partition_sums[],
- unsigned raw_bits_per_partition[],
- unsigned blocksize,
- unsigned subframe_bps,
- unsigned order,
- unsigned rice_parameter,
- unsigned rice_parameter_limit,
- unsigned min_partition_order,
- unsigned max_partition_order,
- FLAC__bool do_escape_coding,
- unsigned rice_parameter_search_dist,
- FLAC__Subframe *subframe,
- FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents
-);
-
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
-static unsigned evaluate_lpc_subframe_(
- FLAC__StreamEncoder *encoder,
- const FLAC__int32 signal[],
- FLAC__int32 residual[],
- FLAC__uint64 abs_residual_partition_sums[],
- unsigned raw_bits_per_partition[],
- const FLAC__real lp_coeff[],
- unsigned blocksize,
- unsigned subframe_bps,
- unsigned order,
- unsigned qlp_coeff_precision,
- unsigned rice_parameter,
- unsigned rice_parameter_limit,
- unsigned min_partition_order,
- unsigned max_partition_order,
- FLAC__bool do_escape_coding,
- unsigned rice_parameter_search_dist,
- FLAC__Subframe *subframe,
- FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents
-);
-#endif
-
-static unsigned evaluate_verbatim_subframe_(
- FLAC__StreamEncoder *encoder,
- const FLAC__int32 signal[],
- unsigned blocksize,
- unsigned subframe_bps,
- FLAC__Subframe *subframe
-);
-
-static unsigned find_best_partition_order_(
- struct FLAC__StreamEncoderPrivate *private_,
- const FLAC__int32 residual[],
- FLAC__uint64 abs_residual_partition_sums[],
- unsigned raw_bits_per_partition[],
- unsigned residual_samples,
- unsigned predictor_order,
- unsigned rice_parameter,
- unsigned rice_parameter_limit,
- unsigned min_partition_order,
- unsigned max_partition_order,
- unsigned bps,
- FLAC__bool do_escape_coding,
- unsigned rice_parameter_search_dist,
- FLAC__EntropyCodingMethod *best_ecm
-);
-
-static void precompute_partition_info_sums_(
- const FLAC__int32 residual[],
- FLAC__uint64 abs_residual_partition_sums[],
- unsigned residual_samples,
- unsigned predictor_order,
- unsigned min_partition_order,
- unsigned max_partition_order,
- unsigned bps
-);
-
-static void precompute_partition_info_escapes_(
- const FLAC__int32 residual[],
- unsigned raw_bits_per_partition[],
- unsigned residual_samples,
- unsigned predictor_order,
- unsigned min_partition_order,
- unsigned max_partition_order
-);
-
-static FLAC__bool set_partitioned_rice_(
-#ifdef EXACT_RICE_BITS_CALCULATION
- const FLAC__int32 residual[],
-#endif
- const FLAC__uint64 abs_residual_partition_sums[],
- const unsigned raw_bits_per_partition[],
- const unsigned residual_samples,
- const unsigned predictor_order,
- const unsigned suggested_rice_parameter,
- const unsigned rice_parameter_limit,
- const unsigned rice_parameter_search_dist,
- const unsigned partition_order,
- const FLAC__bool search_for_escapes,
- FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents,
- unsigned *bits
-);
-
-static unsigned get_wasted_bits_(FLAC__int32 signal[], unsigned samples);
-
-/* verify-related routines: */
-static void append_to_verify_fifo_(
- verify_input_fifo *fifo,
- const FLAC__int32 * const input[],
- unsigned input_offset,
- unsigned channels,
- unsigned wide_samples
-);
-
-static void append_to_verify_fifo_interleaved_(
- verify_input_fifo *fifo,
- const FLAC__int32 input[],
- unsigned input_offset,
- unsigned channels,
- unsigned wide_samples
-);
-
-static FLAC__StreamDecoderReadStatus verify_read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
-static FLAC__StreamDecoderWriteStatus verify_write_callback_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
-static void verify_metadata_callback_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
-static void verify_error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
-
-static FLAC__StreamEncoderReadStatus file_read_callback_(const FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
-static FLAC__StreamEncoderSeekStatus file_seek_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
-static FLAC__StreamEncoderTellStatus file_tell_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
-static FLAC__StreamEncoderWriteStatus file_write_callback_(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, void *client_data);
-static FILE *get_binary_stdout_(void);
-
-
-/***********************************************************************
- *
- * Private class data
- *
- ***********************************************************************/
-
-typedef struct FLAC__StreamEncoderPrivate {
- unsigned input_capacity; /* current size (in samples) of the signal and residual buffers */
- FLAC__int32 *integer_signal[FLAC__MAX_CHANNELS]; /* the integer version of the input signal */
- FLAC__int32 *integer_signal_mid_side[2]; /* the integer version of the mid-side input signal (stereo only) */
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
- FLAC__real *real_signal[FLAC__MAX_CHANNELS]; /* (@@@ currently unused) the floating-point version of the input signal */
- FLAC__real *real_signal_mid_side[2]; /* (@@@ currently unused) the floating-point version of the mid-side input signal (stereo only) */
- FLAC__real *window[FLAC__MAX_APODIZATION_FUNCTIONS]; /* the pre-computed floating-point window for each apodization function */
- FLAC__real *windowed_signal; /* the integer_signal[] * current window[] */
-#endif
- unsigned subframe_bps[FLAC__MAX_CHANNELS]; /* the effective bits per sample of the input signal (stream bps - wasted bits) */
- unsigned subframe_bps_mid_side[2]; /* the effective bits per sample of the mid-side input signal (stream bps - wasted bits + 0/1) */
- FLAC__int32 *residual_workspace[FLAC__MAX_CHANNELS][2]; /* each channel has a candidate and best workspace where the subframe residual signals will be stored */
- FLAC__int32 *residual_workspace_mid_side[2][2];
- FLAC__Subframe subframe_workspace[FLAC__MAX_CHANNELS][2];
- FLAC__Subframe subframe_workspace_mid_side[2][2];
- FLAC__Subframe *subframe_workspace_ptr[FLAC__MAX_CHANNELS][2];
- FLAC__Subframe *subframe_workspace_ptr_mid_side[2][2];
- FLAC__EntropyCodingMethod_PartitionedRiceContents partitioned_rice_contents_workspace[FLAC__MAX_CHANNELS][2];
- FLAC__EntropyCodingMethod_PartitionedRiceContents partitioned_rice_contents_workspace_mid_side[FLAC__MAX_CHANNELS][2];
- FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents_workspace_ptr[FLAC__MAX_CHANNELS][2];
- FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents_workspace_ptr_mid_side[FLAC__MAX_CHANNELS][2];
- unsigned best_subframe[FLAC__MAX_CHANNELS]; /* index (0 or 1) into 2nd dimension of the above workspaces */
- unsigned best_subframe_mid_side[2];
- unsigned best_subframe_bits[FLAC__MAX_CHANNELS]; /* size in bits of the best subframe for each channel */
- unsigned best_subframe_bits_mid_side[2];
- FLAC__uint64 *abs_residual_partition_sums; /* workspace where the sum of abs(candidate residual) for each partition is stored */
- unsigned *raw_bits_per_partition; /* workspace where the sum of silog2(candidate residual) for each partition is stored */
- FLAC__BitWriter *frame; /* the current frame being worked on */
- unsigned loose_mid_side_stereo_frames; /* rounded number of frames the encoder will use before trying both independent and mid/side frames again */
- unsigned loose_mid_side_stereo_frame_count; /* number of frames using the current channel assignment */
- FLAC__ChannelAssignment last_channel_assignment;
- FLAC__StreamMetadata streaminfo; /* scratchpad for STREAMINFO as it is built */
- FLAC__StreamMetadata_SeekTable *seek_table; /* pointer into encoder->protected_->metadata_ where the seek table is */
- unsigned current_sample_number;
- unsigned current_frame_number;
- FLAC__MD5Context md5context;
- FLAC__CPUInfo cpuinfo;
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
- unsigned (*local_fixed_compute_best_predictor)(const FLAC__int32 data[], unsigned data_len, FLAC__float residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
-#else
- unsigned (*local_fixed_compute_best_predictor)(const FLAC__int32 data[], unsigned data_len, FLAC__fixedpoint residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1]);
-#endif
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
- void (*local_lpc_compute_autocorrelation)(const FLAC__real data[], unsigned data_len, unsigned lag, FLAC__real autoc[]);
- void (*local_lpc_compute_residual_from_qlp_coefficients)(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]);
- void (*local_lpc_compute_residual_from_qlp_coefficients_64bit)(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]);
- void (*local_lpc_compute_residual_from_qlp_coefficients_16bit)(const FLAC__int32 *data, unsigned data_len, const FLAC__int32 qlp_coeff[], unsigned order, int lp_quantization, FLAC__int32 residual[]);
-#endif
- FLAC__bool use_wide_by_block; /* use slow 64-bit versions of some functions because of the block size */
- FLAC__bool use_wide_by_partition; /* use slow 64-bit versions of some functions because of the min partition order and blocksize */
- FLAC__bool use_wide_by_order; /* use slow 64-bit versions of some functions because of the lpc order */
- FLAC__bool disable_constant_subframes;
- FLAC__bool disable_fixed_subframes;
- FLAC__bool disable_verbatim_subframes;
-#if FLAC__HAS_OGG
- FLAC__bool is_ogg;
-#endif
- FLAC__StreamEncoderReadCallback read_callback; /* currently only needed for Ogg FLAC */
- FLAC__StreamEncoderSeekCallback seek_callback;
- FLAC__StreamEncoderTellCallback tell_callback;
- FLAC__StreamEncoderWriteCallback write_callback;
- FLAC__StreamEncoderMetadataCallback metadata_callback;
- FLAC__StreamEncoderProgressCallback progress_callback;
- void *client_data;
- unsigned first_seekpoint_to_check;
- FILE *file; /* only used when encoding to a file */
- FLAC__uint64 bytes_written;
- FLAC__uint64 samples_written;
- unsigned frames_written;
- unsigned total_frames_estimate;
- /* unaligned (original) pointers to allocated data */
- FLAC__int32 *integer_signal_unaligned[FLAC__MAX_CHANNELS];
- FLAC__int32 *integer_signal_mid_side_unaligned[2];
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
- FLAC__real *real_signal_unaligned[FLAC__MAX_CHANNELS]; /* (@@@ currently unused) */
- FLAC__real *real_signal_mid_side_unaligned[2]; /* (@@@ currently unused) */
- FLAC__real *window_unaligned[FLAC__MAX_APODIZATION_FUNCTIONS];
- FLAC__real *windowed_signal_unaligned;
-#endif
- FLAC__int32 *residual_workspace_unaligned[FLAC__MAX_CHANNELS][2];
- FLAC__int32 *residual_workspace_mid_side_unaligned[2][2];
- FLAC__uint64 *abs_residual_partition_sums_unaligned;
- unsigned *raw_bits_per_partition_unaligned;
- /*
- * These fields have been moved here from private function local
- * declarations merely to save stack space during encoding.
- */
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
- FLAC__real lp_coeff[FLAC__MAX_LPC_ORDER][FLAC__MAX_LPC_ORDER]; /* from process_subframe_() */
-#endif
- FLAC__EntropyCodingMethod_PartitionedRiceContents partitioned_rice_contents_extra[2]; /* from find_best_partition_order_() */
- /*
- * The data for the verify section
- */
- struct {
- FLAC__StreamDecoder *decoder;
- EncoderStateHint state_hint;
- FLAC__bool needs_magic_hack;
- verify_input_fifo input_fifo;
- verify_output output;
- struct {
- FLAC__uint64 absolute_sample;
- unsigned frame_number;
- unsigned channel;
- unsigned sample;
- FLAC__int32 expected;
- FLAC__int32 got;
- } error_stats;
- } verify;
- FLAC__bool is_being_deleted; /* if true, call to ..._finish() from ..._delete() will not call the callbacks */
-} FLAC__StreamEncoderPrivate;
-
-/***********************************************************************
- *
- * Public static class data
- *
- ***********************************************************************/
-
-FLAC_API const char * const FLAC__StreamEncoderStateString[] = {
- "FLAC__STREAM_ENCODER_OK",
- "FLAC__STREAM_ENCODER_UNINITIALIZED",
- "FLAC__STREAM_ENCODER_OGG_ERROR",
- "FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR",
- "FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA",
- "FLAC__STREAM_ENCODER_CLIENT_ERROR",
- "FLAC__STREAM_ENCODER_IO_ERROR",
- "FLAC__STREAM_ENCODER_FRAMING_ERROR",
- "FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR"
-};
-
-FLAC_API const char * const FLAC__StreamEncoderInitStatusString[] = {
- "FLAC__STREAM_ENCODER_INIT_STATUS_OK",
- "FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR",
- "FLAC__STREAM_ENCODER_INIT_STATUS_UNSUPPORTED_CONTAINER",
- "FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_CALLBACKS",
- "FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_NUMBER_OF_CHANNELS",
- "FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BITS_PER_SAMPLE",
- "FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_SAMPLE_RATE",
- "FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BLOCK_SIZE",
- "FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_MAX_LPC_ORDER",
- "FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_QLP_COEFF_PRECISION",
- "FLAC__STREAM_ENCODER_INIT_STATUS_BLOCK_SIZE_TOO_SMALL_FOR_LPC_ORDER",
- "FLAC__STREAM_ENCODER_INIT_STATUS_NOT_STREAMABLE",
- "FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA",
- "FLAC__STREAM_ENCODER_INIT_STATUS_ALREADY_INITIALIZED"
-};
-
-FLAC_API const char * const FLAC__treamEncoderReadStatusString[] = {
- "FLAC__STREAM_ENCODER_READ_STATUS_CONTINUE",
- "FLAC__STREAM_ENCODER_READ_STATUS_END_OF_STREAM",
- "FLAC__STREAM_ENCODER_READ_STATUS_ABORT",
- "FLAC__STREAM_ENCODER_READ_STATUS_UNSUPPORTED"
-};
-
-FLAC_API const char * const FLAC__StreamEncoderWriteStatusString[] = {
- "FLAC__STREAM_ENCODER_WRITE_STATUS_OK",
- "FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR"
-};
-
-FLAC_API const char * const FLAC__StreamEncoderSeekStatusString[] = {
- "FLAC__STREAM_ENCODER_SEEK_STATUS_OK",
- "FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR",
- "FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED"
-};
-
-FLAC_API const char * const FLAC__StreamEncoderTellStatusString[] = {
- "FLAC__STREAM_ENCODER_TELL_STATUS_OK",
- "FLAC__STREAM_ENCODER_TELL_STATUS_ERROR",
- "FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED"
-};
-
-/* Number of samples that will be overread to watch for end of stream. By
- * 'overread', we mean that the FLAC__stream_encoder_process*() calls will
- * always try to read blocksize+1 samples before encoding a block, so that
- * even if the stream has a total sample count that is an integral multiple
- * of the blocksize, we will still notice when we are encoding the last
- * block. This is needed, for example, to correctly set the end-of-stream
- * marker in Ogg FLAC.
- *
- * WATCHOUT: some parts of the code assert that OVERREAD_ == 1 and there's
- * not really any reason to change it.
- */
-static const unsigned OVERREAD_ = 1;
-
-/***********************************************************************
- *
- * Class constructor/destructor
- *
- */
-FLAC_API FLAC__StreamEncoder *FLAC__stream_encoder_new(void)
-{
- FLAC__StreamEncoder *encoder;
- unsigned i;
-
- FLAC__ASSERT(sizeof(int) >= 4); /* we want to die right away if this is not true */
-
- encoder = (FLAC__StreamEncoder*)calloc(1, sizeof(FLAC__StreamEncoder));
- if(encoder == 0) {
- return 0;
- }
-
- encoder->protected_ = (FLAC__StreamEncoderProtected*)calloc(1, sizeof(FLAC__StreamEncoderProtected));
- if(encoder->protected_ == 0) {
- free(encoder);
- return 0;
- }
-
- encoder->private_ = (FLAC__StreamEncoderPrivate*)calloc(1, sizeof(FLAC__StreamEncoderPrivate));
- if(encoder->private_ == 0) {
- free(encoder->protected_);
- free(encoder);
- return 0;
- }
-
- encoder->private_->frame = FLAC__bitwriter_new();
- if(encoder->private_->frame == 0) {
- free(encoder->private_);
- free(encoder->protected_);
- free(encoder);
- return 0;
- }
-
- encoder->private_->file = 0;
-
- set_defaults_(encoder);
-
- encoder->private_->is_being_deleted = false;
-
- for(i = 0; i < FLAC__MAX_CHANNELS; i++) {
- encoder->private_->subframe_workspace_ptr[i][0] = &encoder->private_->subframe_workspace[i][0];
- encoder->private_->subframe_workspace_ptr[i][1] = &encoder->private_->subframe_workspace[i][1];
- }
- for(i = 0; i < 2; i++) {
- encoder->private_->subframe_workspace_ptr_mid_side[i][0] = &encoder->private_->subframe_workspace_mid_side[i][0];
- encoder->private_->subframe_workspace_ptr_mid_side[i][1] = &encoder->private_->subframe_workspace_mid_side[i][1];
- }
- for(i = 0; i < FLAC__MAX_CHANNELS; i++) {
- encoder->private_->partitioned_rice_contents_workspace_ptr[i][0] = &encoder->private_->partitioned_rice_contents_workspace[i][0];
- encoder->private_->partitioned_rice_contents_workspace_ptr[i][1] = &encoder->private_->partitioned_rice_contents_workspace[i][1];
- }
- for(i = 0; i < 2; i++) {
- encoder->private_->partitioned_rice_contents_workspace_ptr_mid_side[i][0] = &encoder->private_->partitioned_rice_contents_workspace_mid_side[i][0];
- encoder->private_->partitioned_rice_contents_workspace_ptr_mid_side[i][1] = &encoder->private_->partitioned_rice_contents_workspace_mid_side[i][1];
- }
-
- for(i = 0; i < FLAC__MAX_CHANNELS; i++) {
- FLAC__format_entropy_coding_method_partitioned_rice_contents_init(&encoder->private_->partitioned_rice_contents_workspace[i][0]);
- FLAC__format_entropy_coding_method_partitioned_rice_contents_init(&encoder->private_->partitioned_rice_contents_workspace[i][1]);
- }
- for(i = 0; i < 2; i++) {
- FLAC__format_entropy_coding_method_partitioned_rice_contents_init(&encoder->private_->partitioned_rice_contents_workspace_mid_side[i][0]);
- FLAC__format_entropy_coding_method_partitioned_rice_contents_init(&encoder->private_->partitioned_rice_contents_workspace_mid_side[i][1]);
- }
- for(i = 0; i < 2; i++)
- FLAC__format_entropy_coding_method_partitioned_rice_contents_init(&encoder->private_->partitioned_rice_contents_extra[i]);
-
- encoder->protected_->state = FLAC__STREAM_ENCODER_UNINITIALIZED;
-
- return encoder;
-}
-
-FLAC_API void FLAC__stream_encoder_delete(FLAC__StreamEncoder *encoder)
-{
- unsigned i;
-
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->protected_);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->private_->frame);
-
- encoder->private_->is_being_deleted = true;
-
- (void)FLAC__stream_encoder_finish(encoder);
-
- if(0 != encoder->private_->verify.decoder)
- FLAC__stream_decoder_delete(encoder->private_->verify.decoder);
-
- for(i = 0; i < FLAC__MAX_CHANNELS; i++) {
- FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(&encoder->private_->partitioned_rice_contents_workspace[i][0]);
- FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(&encoder->private_->partitioned_rice_contents_workspace[i][1]);
- }
- for(i = 0; i < 2; i++) {
- FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(&encoder->private_->partitioned_rice_contents_workspace_mid_side[i][0]);
- FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(&encoder->private_->partitioned_rice_contents_workspace_mid_side[i][1]);
- }
- for(i = 0; i < 2; i++)
- FLAC__format_entropy_coding_method_partitioned_rice_contents_clear(&encoder->private_->partitioned_rice_contents_extra[i]);
-
- FLAC__bitwriter_delete(encoder->private_->frame);
- free(encoder->private_);
- free(encoder->protected_);
- free(encoder);
-}
-
-/***********************************************************************
- *
- * Public class methods
- *
- ***********************************************************************/
-
-static FLAC__StreamEncoderInitStatus init_stream_internal_(
- FLAC__StreamEncoder *encoder,
- FLAC__StreamEncoderReadCallback read_callback,
- FLAC__StreamEncoderWriteCallback write_callback,
- FLAC__StreamEncoderSeekCallback seek_callback,
- FLAC__StreamEncoderTellCallback tell_callback,
- FLAC__StreamEncoderMetadataCallback metadata_callback,
- void *client_data,
- FLAC__bool is_ogg
-)
-{
- unsigned i;
- FLAC__bool metadata_has_seektable, metadata_has_vorbis_comment, metadata_picture_has_type1, metadata_picture_has_type2;
-
- FLAC__ASSERT(0 != encoder);
-
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return FLAC__STREAM_ENCODER_INIT_STATUS_ALREADY_INITIALIZED;
-
-#if !FLAC__HAS_OGG
- if(is_ogg)
- return FLAC__STREAM_ENCODER_INIT_STATUS_UNSUPPORTED_CONTAINER;
-#endif
-
- if(0 == write_callback || (seek_callback && 0 == tell_callback))
- return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_CALLBACKS;
-
- if(encoder->protected_->channels == 0 || encoder->protected_->channels > FLAC__MAX_CHANNELS)
- return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_NUMBER_OF_CHANNELS;
-
- if(encoder->protected_->channels != 2) {
- encoder->protected_->do_mid_side_stereo = false;
- encoder->protected_->loose_mid_side_stereo = false;
- }
- else if(!encoder->protected_->do_mid_side_stereo)
- encoder->protected_->loose_mid_side_stereo = false;
-
- if(encoder->protected_->bits_per_sample >= 32)
- encoder->protected_->do_mid_side_stereo = false; /* since we currenty do 32-bit math, the side channel would have 33 bps and overflow */
-
- if(encoder->protected_->bits_per_sample < FLAC__MIN_BITS_PER_SAMPLE || encoder->protected_->bits_per_sample > FLAC__REFERENCE_CODEC_MAX_BITS_PER_SAMPLE)
- return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BITS_PER_SAMPLE;
-
- if(!FLAC__format_sample_rate_is_valid(encoder->protected_->sample_rate))
- return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_SAMPLE_RATE;
-
- if(encoder->protected_->blocksize == 0) {
- if(encoder->protected_->max_lpc_order == 0)
- encoder->protected_->blocksize = 1152;
- else
- encoder->protected_->blocksize = 4096;
- }
-
- if(encoder->protected_->blocksize < FLAC__MIN_BLOCK_SIZE || encoder->protected_->blocksize > FLAC__MAX_BLOCK_SIZE)
- return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BLOCK_SIZE;
-
- if(encoder->protected_->max_lpc_order > FLAC__MAX_LPC_ORDER)
- return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_MAX_LPC_ORDER;
-
- if(encoder->protected_->blocksize < encoder->protected_->max_lpc_order)
- return FLAC__STREAM_ENCODER_INIT_STATUS_BLOCK_SIZE_TOO_SMALL_FOR_LPC_ORDER;
-
- if(encoder->protected_->qlp_coeff_precision == 0) {
- if(encoder->protected_->bits_per_sample < 16) {
- /* @@@ need some data about how to set this here w.r.t. blocksize and sample rate */
- /* @@@ until then we'll make a guess */
- encoder->protected_->qlp_coeff_precision = max(FLAC__MIN_QLP_COEFF_PRECISION, 2 + encoder->protected_->bits_per_sample / 2);
- }
- else if(encoder->protected_->bits_per_sample == 16) {
- if(encoder->protected_->blocksize <= 192)
- encoder->protected_->qlp_coeff_precision = 7;
- else if(encoder->protected_->blocksize <= 384)
- encoder->protected_->qlp_coeff_precision = 8;
- else if(encoder->protected_->blocksize <= 576)
- encoder->protected_->qlp_coeff_precision = 9;
- else if(encoder->protected_->blocksize <= 1152)
- encoder->protected_->qlp_coeff_precision = 10;
- else if(encoder->protected_->blocksize <= 2304)
- encoder->protected_->qlp_coeff_precision = 11;
- else if(encoder->protected_->blocksize <= 4608)
- encoder->protected_->qlp_coeff_precision = 12;
- else
- encoder->protected_->qlp_coeff_precision = 13;
- }
- else {
- if(encoder->protected_->blocksize <= 384)
- encoder->protected_->qlp_coeff_precision = FLAC__MAX_QLP_COEFF_PRECISION-2;
- else if(encoder->protected_->blocksize <= 1152)
- encoder->protected_->qlp_coeff_precision = FLAC__MAX_QLP_COEFF_PRECISION-1;
- else
- encoder->protected_->qlp_coeff_precision = FLAC__MAX_QLP_COEFF_PRECISION;
- }
- FLAC__ASSERT(encoder->protected_->qlp_coeff_precision <= FLAC__MAX_QLP_COEFF_PRECISION);
- }
- else if(encoder->protected_->qlp_coeff_precision < FLAC__MIN_QLP_COEFF_PRECISION || encoder->protected_->qlp_coeff_precision > FLAC__MAX_QLP_COEFF_PRECISION)
- return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_QLP_COEFF_PRECISION;
-
- if(encoder->protected_->streamable_subset) {
- if(!FLAC__format_blocksize_is_subset(encoder->protected_->blocksize, encoder->protected_->sample_rate))
- return FLAC__STREAM_ENCODER_INIT_STATUS_NOT_STREAMABLE;
- if(!FLAC__format_sample_rate_is_subset(encoder->protected_->sample_rate))
- return FLAC__STREAM_ENCODER_INIT_STATUS_NOT_STREAMABLE;
- if(
- encoder->protected_->bits_per_sample != 8 &&
- encoder->protected_->bits_per_sample != 12 &&
- encoder->protected_->bits_per_sample != 16 &&
- encoder->protected_->bits_per_sample != 20 &&
- encoder->protected_->bits_per_sample != 24
- )
- return FLAC__STREAM_ENCODER_INIT_STATUS_NOT_STREAMABLE;
- if(encoder->protected_->max_residual_partition_order > FLAC__SUBSET_MAX_RICE_PARTITION_ORDER)
- return FLAC__STREAM_ENCODER_INIT_STATUS_NOT_STREAMABLE;
- if(
- encoder->protected_->sample_rate <= 48000 &&
- (
- encoder->protected_->blocksize > FLAC__SUBSET_MAX_BLOCK_SIZE_48000HZ ||
- encoder->protected_->max_lpc_order > FLAC__SUBSET_MAX_LPC_ORDER_48000HZ
- )
- ) {
- return FLAC__STREAM_ENCODER_INIT_STATUS_NOT_STREAMABLE;
- }
- }
-
- if(encoder->protected_->max_residual_partition_order >= (1u << FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN))
- encoder->protected_->max_residual_partition_order = (1u << FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN) - 1;
- if(encoder->protected_->min_residual_partition_order >= encoder->protected_->max_residual_partition_order)
- encoder->protected_->min_residual_partition_order = encoder->protected_->max_residual_partition_order;
-
-#if FLAC__HAS_OGG
- /* reorder metadata if necessary to ensure that any VORBIS_COMMENT is the first, according to the mapping spec */
- if(is_ogg && 0 != encoder->protected_->metadata && encoder->protected_->num_metadata_blocks > 1) {
- unsigned i;
- for(i = 1; i < encoder->protected_->num_metadata_blocks; i++) {
- if(0 != encoder->protected_->metadata[i] && encoder->protected_->metadata[i]->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) {
- FLAC__StreamMetadata *vc = encoder->protected_->metadata[i];
- for( ; i > 0; i--)
- encoder->protected_->metadata[i] = encoder->protected_->metadata[i-1];
- encoder->protected_->metadata[0] = vc;
- break;
- }
- }
- }
-#endif
- /* keep track of any SEEKTABLE block */
- if(0 != encoder->protected_->metadata && encoder->protected_->num_metadata_blocks > 0) {
- unsigned i;
- for(i = 0; i < encoder->protected_->num_metadata_blocks; i++) {
- if(0 != encoder->protected_->metadata[i] && encoder->protected_->metadata[i]->type == FLAC__METADATA_TYPE_SEEKTABLE) {
- encoder->private_->seek_table = &encoder->protected_->metadata[i]->data.seek_table;
- break; /* take only the first one */
- }
- }
- }
-
- /* validate metadata */
- if(0 == encoder->protected_->metadata && encoder->protected_->num_metadata_blocks > 0)
- return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA;
- metadata_has_seektable = false;
- metadata_has_vorbis_comment = false;
- metadata_picture_has_type1 = false;
- metadata_picture_has_type2 = false;
- for(i = 0; i < encoder->protected_->num_metadata_blocks; i++) {
- const FLAC__StreamMetadata *m = encoder->protected_->metadata[i];
- if(m->type == FLAC__METADATA_TYPE_STREAMINFO)
- return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA;
- else if(m->type == FLAC__METADATA_TYPE_SEEKTABLE) {
- if(metadata_has_seektable) /* only one is allowed */
- return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA;
- metadata_has_seektable = true;
- if(!FLAC__format_seektable_is_legal(&m->data.seek_table))
- return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA;
- }
- else if(m->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) {
- if(metadata_has_vorbis_comment) /* only one is allowed */
- return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA;
- metadata_has_vorbis_comment = true;
- }
- else if(m->type == FLAC__METADATA_TYPE_CUESHEET) {
- if(!FLAC__format_cuesheet_is_legal(&m->data.cue_sheet, m->data.cue_sheet.is_cd, /*violation=*/0))
- return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA;
- }
- else if(m->type == FLAC__METADATA_TYPE_PICTURE) {
- if(!FLAC__format_picture_is_legal(&m->data.picture, /*violation=*/0))
- return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA;
- if(m->data.picture.type == FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD) {
- if(metadata_picture_has_type1) /* there should only be 1 per stream */
- return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA;
- metadata_picture_has_type1 = true;
- /* standard icon must be 32x32 pixel PNG */
- if(
- m->data.picture.type == FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD &&
- (
- (strcmp(m->data.picture.mime_type, "image/png") && strcmp(m->data.picture.mime_type, "-->")) ||
- m->data.picture.width != 32 ||
- m->data.picture.height != 32
- )
- )
- return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA;
- }
- else if(m->data.picture.type == FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON) {
- if(metadata_picture_has_type2) /* there should only be 1 per stream */
- return FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA;
- metadata_picture_has_type2 = true;
- }
- }
- }
-
- encoder->private_->input_capacity = 0;
- for(i = 0; i < encoder->protected_->channels; i++) {
- encoder->private_->integer_signal_unaligned[i] = encoder->private_->integer_signal[i] = 0;
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
- encoder->private_->real_signal_unaligned[i] = encoder->private_->real_signal[i] = 0;
-#endif
- }
- for(i = 0; i < 2; i++) {
- encoder->private_->integer_signal_mid_side_unaligned[i] = encoder->private_->integer_signal_mid_side[i] = 0;
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
- encoder->private_->real_signal_mid_side_unaligned[i] = encoder->private_->real_signal_mid_side[i] = 0;
-#endif
- }
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
- for(i = 0; i < encoder->protected_->num_apodizations; i++)
- encoder->private_->window_unaligned[i] = encoder->private_->window[i] = 0;
- encoder->private_->windowed_signal_unaligned = encoder->private_->windowed_signal = 0;
-#endif
- for(i = 0; i < encoder->protected_->channels; i++) {
- encoder->private_->residual_workspace_unaligned[i][0] = encoder->private_->residual_workspace[i][0] = 0;
- encoder->private_->residual_workspace_unaligned[i][1] = encoder->private_->residual_workspace[i][1] = 0;
- encoder->private_->best_subframe[i] = 0;
- }
- for(i = 0; i < 2; i++) {
- encoder->private_->residual_workspace_mid_side_unaligned[i][0] = encoder->private_->residual_workspace_mid_side[i][0] = 0;
- encoder->private_->residual_workspace_mid_side_unaligned[i][1] = encoder->private_->residual_workspace_mid_side[i][1] = 0;
- encoder->private_->best_subframe_mid_side[i] = 0;
- }
- encoder->private_->abs_residual_partition_sums_unaligned = encoder->private_->abs_residual_partition_sums = 0;
- encoder->private_->raw_bits_per_partition_unaligned = encoder->private_->raw_bits_per_partition = 0;
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
- encoder->private_->loose_mid_side_stereo_frames = (unsigned)((FLAC__double)encoder->protected_->sample_rate * 0.4 / (FLAC__double)encoder->protected_->blocksize + 0.5);
-#else
- /* 26214 is the approximate fixed-point equivalent to 0.4 (0.4 * 2^16) */
- /* sample rate can be up to 655350 Hz, and thus use 20 bits, so we do the multiply&divide by hand */
- FLAC__ASSERT(FLAC__MAX_SAMPLE_RATE <= 655350);
- FLAC__ASSERT(FLAC__MAX_BLOCK_SIZE <= 65535);
- FLAC__ASSERT(encoder->protected_->sample_rate <= 655350);
- FLAC__ASSERT(encoder->protected_->blocksize <= 65535);
- encoder->private_->loose_mid_side_stereo_frames = (unsigned)FLAC__fixedpoint_trunc((((FLAC__uint64)(encoder->protected_->sample_rate) * (FLAC__uint64)(26214)) << 16) / (encoder->protected_->blocksize<<16) + FLAC__FP_ONE_HALF);
-#endif
- if(encoder->private_->loose_mid_side_stereo_frames == 0)
- encoder->private_->loose_mid_side_stereo_frames = 1;
- encoder->private_->loose_mid_side_stereo_frame_count = 0;
- encoder->private_->current_sample_number = 0;
- encoder->private_->current_frame_number = 0;
-
- encoder->private_->use_wide_by_block = (encoder->protected_->bits_per_sample + FLAC__bitmath_ilog2(encoder->protected_->blocksize)+1 > 30);
- encoder->private_->use_wide_by_order = (encoder->protected_->bits_per_sample + FLAC__bitmath_ilog2(max(encoder->protected_->max_lpc_order, FLAC__MAX_FIXED_ORDER))+1 > 30); /*@@@ need to use this? */
- encoder->private_->use_wide_by_partition = (false); /*@@@ need to set this */
-
- /*
- * get the CPU info and set the function pointers
- */
- FLAC__cpu_info(&encoder->private_->cpuinfo);
- /* first default to the non-asm routines */
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
- encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation;
-#endif
- encoder->private_->local_fixed_compute_best_predictor = FLAC__fixed_compute_best_predictor;
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
- encoder->private_->local_lpc_compute_residual_from_qlp_coefficients = FLAC__lpc_compute_residual_from_qlp_coefficients;
- encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_64bit = FLAC__lpc_compute_residual_from_qlp_coefficients_wide;
- encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_16bit = FLAC__lpc_compute_residual_from_qlp_coefficients;
-#endif
- /* now override with asm where appropriate */
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
-# ifndef FLAC__NO_ASM
- if(encoder->private_->cpuinfo.use_asm) {
-# ifdef FLAC__CPU_IA32
- FLAC__ASSERT(encoder->private_->cpuinfo.type == FLAC__CPUINFO_TYPE_IA32);
-# ifdef FLAC__HAS_NASM
- if(encoder->private_->cpuinfo.data.ia32.sse) {
- if(encoder->protected_->max_lpc_order < 4)
- encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_4;
- else if(encoder->protected_->max_lpc_order < 8)
- encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_8;
- else if(encoder->protected_->max_lpc_order < 12)
- encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_asm_ia32_sse_lag_12;
- else
- encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_asm_ia32;
- }
- else if(encoder->private_->cpuinfo.data.ia32._3dnow)
- encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_asm_ia32_3dnow;
- else
- encoder->private_->local_lpc_compute_autocorrelation = FLAC__lpc_compute_autocorrelation_asm_ia32;
- if(encoder->private_->cpuinfo.data.ia32.mmx) {
- encoder->private_->local_lpc_compute_residual_from_qlp_coefficients = FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32;
- encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_16bit = FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32_mmx;
- }
- else {
- encoder->private_->local_lpc_compute_residual_from_qlp_coefficients = FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32;
- encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_16bit = FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32;
- }
- if(encoder->private_->cpuinfo.data.ia32.mmx && encoder->private_->cpuinfo.data.ia32.cmov)
- encoder->private_->local_fixed_compute_best_predictor = FLAC__fixed_compute_best_predictor_asm_ia32_mmx_cmov;
-# endif /* FLAC__HAS_NASM */
-# endif /* FLAC__CPU_IA32 */
- }
-# endif /* !FLAC__NO_ASM */
-#endif /* !FLAC__INTEGER_ONLY_LIBRARY */
- /* finally override based on wide-ness if necessary */
- if(encoder->private_->use_wide_by_block) {
- encoder->private_->local_fixed_compute_best_predictor = FLAC__fixed_compute_best_predictor_wide;
- }
-
- /* set state to OK; from here on, errors are fatal and we'll override the state then */
- encoder->protected_->state = FLAC__STREAM_ENCODER_OK;
-
-#if FLAC__HAS_OGG
- encoder->private_->is_ogg = is_ogg;
- if(is_ogg && !FLAC__ogg_encoder_aspect_init(&encoder->protected_->ogg_encoder_aspect)) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR;
- return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR;
- }
-#endif
-
- encoder->private_->read_callback = read_callback;
- encoder->private_->write_callback = write_callback;
- encoder->private_->seek_callback = seek_callback;
- encoder->private_->tell_callback = tell_callback;
- encoder->private_->metadata_callback = metadata_callback;
- encoder->private_->client_data = client_data;
-
- if(!resize_buffers_(encoder, encoder->protected_->blocksize)) {
- /* the above function sets the state for us in case of an error */
- return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR;
- }
-
- if(!FLAC__bitwriter_init(encoder->private_->frame)) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR;
- return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR;
- }
-
- /*
- * Set up the verify stuff if necessary
- */
- if(encoder->protected_->verify) {
- /*
- * First, set up the fifo which will hold the
- * original signal to compare against
- */
- encoder->private_->verify.input_fifo.size = encoder->protected_->blocksize+OVERREAD_;
- for(i = 0; i < encoder->protected_->channels; i++) {
- if(0 == (encoder->private_->verify.input_fifo.data[i] = (FLAC__int32*)safe_malloc_mul_2op_(sizeof(FLAC__int32), /*times*/encoder->private_->verify.input_fifo.size))) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR;
- return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR;
- }
- }
- encoder->private_->verify.input_fifo.tail = 0;
-
- /*
- * Now set up a stream decoder for verification
- */
- encoder->private_->verify.decoder = FLAC__stream_decoder_new();
- if(0 == encoder->private_->verify.decoder) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR;
- return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR;
- }
-
- if(FLAC__stream_decoder_init_stream(encoder->private_->verify.decoder, verify_read_callback_, /*seek_callback=*/0, /*tell_callback=*/0, /*length_callback=*/0, /*eof_callback=*/0, verify_write_callback_, verify_metadata_callback_, verify_error_callback_, /*client_data=*/encoder) != FLAC__STREAM_DECODER_INIT_STATUS_OK) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR;
- return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR;
- }
- }
- encoder->private_->verify.error_stats.absolute_sample = 0;
- encoder->private_->verify.error_stats.frame_number = 0;
- encoder->private_->verify.error_stats.channel = 0;
- encoder->private_->verify.error_stats.sample = 0;
- encoder->private_->verify.error_stats.expected = 0;
- encoder->private_->verify.error_stats.got = 0;
-
- /*
- * These must be done before we write any metadata, because that
- * calls the write_callback, which uses these values.
- */
- encoder->private_->first_seekpoint_to_check = 0;
- encoder->private_->samples_written = 0;
- encoder->protected_->streaminfo_offset = 0;
- encoder->protected_->seektable_offset = 0;
- encoder->protected_->audio_offset = 0;
-
- /*
- * write the stream header
- */
- if(encoder->protected_->verify)
- encoder->private_->verify.state_hint = ENCODER_IN_MAGIC;
- if(!FLAC__bitwriter_write_raw_uint32(encoder->private_->frame, FLAC__STREAM_SYNC, FLAC__STREAM_SYNC_LEN)) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR;
- return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR;
- }
- if(!write_bitbuffer_(encoder, 0, /*is_last_block=*/false)) {
- /* the above function sets the state for us in case of an error */
- return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR;
- }
-
- /*
- * write the STREAMINFO metadata block
- */
- if(encoder->protected_->verify)
- encoder->private_->verify.state_hint = ENCODER_IN_METADATA;
- encoder->private_->streaminfo.type = FLAC__METADATA_TYPE_STREAMINFO;
- encoder->private_->streaminfo.is_last = false; /* we will have at a minimum a VORBIS_COMMENT afterwards */
- encoder->private_->streaminfo.length = FLAC__STREAM_METADATA_STREAMINFO_LENGTH;
- encoder->private_->streaminfo.data.stream_info.min_blocksize = encoder->protected_->blocksize; /* this encoder uses the same blocksize for the whole stream */
- encoder->private_->streaminfo.data.stream_info.max_blocksize = encoder->protected_->blocksize;
- encoder->private_->streaminfo.data.stream_info.min_framesize = 0; /* we don't know this yet; have to fill it in later */
- encoder->private_->streaminfo.data.stream_info.max_framesize = 0; /* we don't know this yet; have to fill it in later */
- encoder->private_->streaminfo.data.stream_info.sample_rate = encoder->protected_->sample_rate;
- encoder->private_->streaminfo.data.stream_info.channels = encoder->protected_->channels;
- encoder->private_->streaminfo.data.stream_info.bits_per_sample = encoder->protected_->bits_per_sample;
- encoder->private_->streaminfo.data.stream_info.total_samples = encoder->protected_->total_samples_estimate; /* we will replace this later with the real total */
- memset(encoder->private_->streaminfo.data.stream_info.md5sum, 0, 16); /* we don't know this yet; have to fill it in later */
- if(encoder->protected_->do_md5)
- FLAC__MD5Init(&encoder->private_->md5context);
- if(!FLAC__add_metadata_block(&encoder->private_->streaminfo, encoder->private_->frame)) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR;
- return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR;
- }
- if(!write_bitbuffer_(encoder, 0, /*is_last_block=*/false)) {
- /* the above function sets the state for us in case of an error */
- return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR;
- }
-
- /*
- * Now that the STREAMINFO block is written, we can init this to an
- * absurdly-high value...
- */
- encoder->private_->streaminfo.data.stream_info.min_framesize = (1u << FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN) - 1;
- /* ... and clear this to 0 */
- encoder->private_->streaminfo.data.stream_info.total_samples = 0;
-
- /*
- * Check to see if the supplied metadata contains a VORBIS_COMMENT;
- * if not, we will write an empty one (FLAC__add_metadata_block()
- * automatically supplies the vendor string).
- *
- * WATCHOUT: the Ogg FLAC mapping requires us to write this block after
- * the STREAMINFO. (In the case that metadata_has_vorbis_comment is
- * true it will have already insured that the metadata list is properly
- * ordered.)
- */
- if(!metadata_has_vorbis_comment) {
- FLAC__StreamMetadata vorbis_comment;
- vorbis_comment.type = FLAC__METADATA_TYPE_VORBIS_COMMENT;
- vorbis_comment.is_last = (encoder->protected_->num_metadata_blocks == 0);
- vorbis_comment.length = 4 + 4; /* MAGIC NUMBER */
- vorbis_comment.data.vorbis_comment.vendor_string.length = 0;
- vorbis_comment.data.vorbis_comment.vendor_string.entry = 0;
- vorbis_comment.data.vorbis_comment.num_comments = 0;
- vorbis_comment.data.vorbis_comment.comments = 0;
- if(!FLAC__add_metadata_block(&vorbis_comment, encoder->private_->frame)) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR;
- return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR;
- }
- if(!write_bitbuffer_(encoder, 0, /*is_last_block=*/false)) {
- /* the above function sets the state for us in case of an error */
- return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR;
- }
- }
-
- /*
- * write the user's metadata blocks
- */
- for(i = 0; i < encoder->protected_->num_metadata_blocks; i++) {
- encoder->protected_->metadata[i]->is_last = (i == encoder->protected_->num_metadata_blocks - 1);
- if(!FLAC__add_metadata_block(encoder->protected_->metadata[i], encoder->private_->frame)) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR;
- return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR;
- }
- if(!write_bitbuffer_(encoder, 0, /*is_last_block=*/false)) {
- /* the above function sets the state for us in case of an error */
- return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR;
- }
- }
-
- /* now that all the metadata is written, we save the stream offset */
- if(encoder->private_->tell_callback && encoder->private_->tell_callback(encoder, &encoder->protected_->audio_offset, encoder->private_->client_data) == FLAC__STREAM_ENCODER_TELL_STATUS_ERROR) { /* FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED just means we didn't get the offset; no error */
- encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR;
- return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR;
- }
-
- if(encoder->protected_->verify)
- encoder->private_->verify.state_hint = ENCODER_IN_AUDIO;
-
- return FLAC__STREAM_ENCODER_INIT_STATUS_OK;
-}
-
-FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_stream(
- FLAC__StreamEncoder *encoder,
- FLAC__StreamEncoderWriteCallback write_callback,
- FLAC__StreamEncoderSeekCallback seek_callback,
- FLAC__StreamEncoderTellCallback tell_callback,
- FLAC__StreamEncoderMetadataCallback metadata_callback,
- void *client_data
-)
-{
- return init_stream_internal_(
- encoder,
- /*read_callback=*/0,
- write_callback,
- seek_callback,
- tell_callback,
- metadata_callback,
- client_data,
- /*is_ogg=*/false
- );
-}
-
-FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_stream(
- FLAC__StreamEncoder *encoder,
- FLAC__StreamEncoderReadCallback read_callback,
- FLAC__StreamEncoderWriteCallback write_callback,
- FLAC__StreamEncoderSeekCallback seek_callback,
- FLAC__StreamEncoderTellCallback tell_callback,
- FLAC__StreamEncoderMetadataCallback metadata_callback,
- void *client_data
-)
-{
- return init_stream_internal_(
- encoder,
- read_callback,
- write_callback,
- seek_callback,
- tell_callback,
- metadata_callback,
- client_data,
- /*is_ogg=*/true
- );
-}
-
-static FLAC__StreamEncoderInitStatus init_FILE_internal_(
- FLAC__StreamEncoder *encoder,
- FILE *file,
- FLAC__StreamEncoderProgressCallback progress_callback,
- void *client_data,
- FLAC__bool is_ogg
-)
-{
- FLAC__StreamEncoderInitStatus init_status;
-
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != file);
-
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return FLAC__STREAM_ENCODER_INIT_STATUS_ALREADY_INITIALIZED;
-
- /* double protection */
- if(file == 0) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_IO_ERROR;
- return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR;
- }
-
- /*
- * To make sure that our file does not go unclosed after an error, we
- * must assign the FILE pointer before any further error can occur in
- * this routine.
- */
- if(file == stdout)
- file = get_binary_stdout_(); /* just to be safe */
-
- encoder->private_->file = file;
-
- encoder->private_->progress_callback = progress_callback;
- encoder->private_->bytes_written = 0;
- encoder->private_->samples_written = 0;
- encoder->private_->frames_written = 0;
-
- init_status = init_stream_internal_(
- encoder,
- encoder->private_->file == stdout? 0 : is_ogg? file_read_callback_ : 0,
- file_write_callback_,
- encoder->private_->file == stdout? 0 : file_seek_callback_,
- encoder->private_->file == stdout? 0 : file_tell_callback_,
- /*metadata_callback=*/0,
- client_data,
- is_ogg
- );
- if(init_status != FLAC__STREAM_ENCODER_INIT_STATUS_OK) {
- /* the above function sets the state for us in case of an error */
- return init_status;
- }
-
- {
- unsigned blocksize = FLAC__stream_encoder_get_blocksize(encoder);
-
- FLAC__ASSERT(blocksize != 0);
- encoder->private_->total_frames_estimate = (unsigned)((FLAC__stream_encoder_get_total_samples_estimate(encoder) + blocksize - 1) / blocksize);
- }
-
- return init_status;
-}
-
-FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_FILE(
- FLAC__StreamEncoder *encoder,
- FILE *file,
- FLAC__StreamEncoderProgressCallback progress_callback,
- void *client_data
-)
-{
- return init_FILE_internal_(encoder, file, progress_callback, client_data, /*is_ogg=*/false);
-}
-
-FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_FILE(
- FLAC__StreamEncoder *encoder,
- FILE *file,
- FLAC__StreamEncoderProgressCallback progress_callback,
- void *client_data
-)
-{
- return init_FILE_internal_(encoder, file, progress_callback, client_data, /*is_ogg=*/true);
-}
-
-static FLAC__StreamEncoderInitStatus init_file_internal_(
- FLAC__StreamEncoder *encoder,
- const char *filename,
- FLAC__StreamEncoderProgressCallback progress_callback,
- void *client_data,
- FLAC__bool is_ogg
-)
-{
- FILE *file;
-
- FLAC__ASSERT(0 != encoder);
-
- /*
- * To make sure that our file does not go unclosed after an error, we
- * have to do the same entrance checks here that are later performed
- * in FLAC__stream_encoder_init_FILE() before the FILE* is assigned.
- */
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return FLAC__STREAM_ENCODER_INIT_STATUS_ALREADY_INITIALIZED;
-
- file = filename? fopen(filename, "w+b") : stdout;
-
- if(file == 0) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_IO_ERROR;
- return FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR;
- }
-
- return init_FILE_internal_(encoder, file, progress_callback, client_data, is_ogg);
-}
-
-FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_file(
- FLAC__StreamEncoder *encoder,
- const char *filename,
- FLAC__StreamEncoderProgressCallback progress_callback,
- void *client_data
-)
-{
- return init_file_internal_(encoder, filename, progress_callback, client_data, /*is_ogg=*/false);
-}
-
-FLAC_API FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_ogg_file(
- FLAC__StreamEncoder *encoder,
- const char *filename,
- FLAC__StreamEncoderProgressCallback progress_callback,
- void *client_data
-)
-{
- return init_file_internal_(encoder, filename, progress_callback, client_data, /*is_ogg=*/true);
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_finish(FLAC__StreamEncoder *encoder)
-{
- FLAC__bool error = false;
-
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
-
- if(encoder->protected_->state == FLAC__STREAM_ENCODER_UNINITIALIZED)
- return true;
-
- if(encoder->protected_->state == FLAC__STREAM_ENCODER_OK && !encoder->private_->is_being_deleted) {
- if(encoder->private_->current_sample_number != 0) {
- const FLAC__bool is_fractional_block = encoder->protected_->blocksize != encoder->private_->current_sample_number;
- encoder->protected_->blocksize = encoder->private_->current_sample_number;
- if(!process_frame_(encoder, is_fractional_block, /*is_last_block=*/true))
- error = true;
- }
- }
-
- if(encoder->protected_->do_md5)
- FLAC__MD5Final(encoder->private_->streaminfo.data.stream_info.md5sum, &encoder->private_->md5context);
-
- if(!encoder->private_->is_being_deleted) {
- if(encoder->protected_->state == FLAC__STREAM_ENCODER_OK) {
- if(encoder->private_->seek_callback) {
-#if FLAC__HAS_OGG
- if(encoder->private_->is_ogg)
- update_ogg_metadata_(encoder);
- else
-#endif
- update_metadata_(encoder);
-
- /* check if an error occurred while updating metadata */
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_OK)
- error = true;
- }
- if(encoder->private_->metadata_callback)
- encoder->private_->metadata_callback(encoder, &encoder->private_->streaminfo, encoder->private_->client_data);
- }
-
- if(encoder->protected_->verify && 0 != encoder->private_->verify.decoder && !FLAC__stream_decoder_finish(encoder->private_->verify.decoder)) {
- if(!error)
- encoder->protected_->state = FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA;
- error = true;
- }
- }
-
- if(0 != encoder->private_->file) {
- if(encoder->private_->file != stdout)
- fclose(encoder->private_->file);
- encoder->private_->file = 0;
- }
-
-#if FLAC__HAS_OGG
- if(encoder->private_->is_ogg)
- FLAC__ogg_encoder_aspect_finish(&encoder->protected_->ogg_encoder_aspect);
-#endif
-
- free_(encoder);
- set_defaults_(encoder);
-
- if(!error)
- encoder->protected_->state = FLAC__STREAM_ENCODER_UNINITIALIZED;
-
- return !error;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_set_ogg_serial_number(FLAC__StreamEncoder *encoder, long value)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return false;
-#if FLAC__HAS_OGG
- /* can't check encoder->private_->is_ogg since that's not set until init time */
- FLAC__ogg_encoder_aspect_set_serial_number(&encoder->protected_->ogg_encoder_aspect, value);
- return true;
-#else
- (void)value;
- return false;
-#endif
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_set_verify(FLAC__StreamEncoder *encoder, FLAC__bool value)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return false;
-#ifndef FLAC__MANDATORY_VERIFY_WHILE_ENCODING
- encoder->protected_->verify = value;
-#endif
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_set_streamable_subset(FLAC__StreamEncoder *encoder, FLAC__bool value)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return false;
- encoder->protected_->streamable_subset = value;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_set_do_md5(FLAC__StreamEncoder *encoder, FLAC__bool value)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return false;
- encoder->protected_->do_md5 = value;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_set_channels(FLAC__StreamEncoder *encoder, unsigned value)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return false;
- encoder->protected_->channels = value;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_set_bits_per_sample(FLAC__StreamEncoder *encoder, unsigned value)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return false;
- encoder->protected_->bits_per_sample = value;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_set_sample_rate(FLAC__StreamEncoder *encoder, unsigned value)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return false;
- encoder->protected_->sample_rate = value;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_set_compression_level(FLAC__StreamEncoder *encoder, unsigned value)
-{
- FLAC__bool ok = true;
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return false;
- if(value >= sizeof(compression_levels_)/sizeof(compression_levels_[0]))
- value = sizeof(compression_levels_)/sizeof(compression_levels_[0]) - 1;
- ok &= FLAC__stream_encoder_set_do_mid_side_stereo (encoder, compression_levels_[value].do_mid_side_stereo);
- ok &= FLAC__stream_encoder_set_loose_mid_side_stereo (encoder, compression_levels_[value].loose_mid_side_stereo);
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
-#if 0
- /* was: */
- ok &= FLAC__stream_encoder_set_apodization (encoder, compression_levels_[value].apodization);
- /* but it's too hard to specify the string in a locale-specific way */
-#else
- encoder->protected_->num_apodizations = 1;
- encoder->protected_->apodizations[0].type = FLAC__APODIZATION_TUKEY;
- encoder->protected_->apodizations[0].parameters.tukey.p = 0.5;
-#endif
-#endif
- ok &= FLAC__stream_encoder_set_max_lpc_order (encoder, compression_levels_[value].max_lpc_order);
- ok &= FLAC__stream_encoder_set_qlp_coeff_precision (encoder, compression_levels_[value].qlp_coeff_precision);
- ok &= FLAC__stream_encoder_set_do_qlp_coeff_prec_search (encoder, compression_levels_[value].do_qlp_coeff_prec_search);
- ok &= FLAC__stream_encoder_set_do_escape_coding (encoder, compression_levels_[value].do_escape_coding);
- ok &= FLAC__stream_encoder_set_do_exhaustive_model_search (encoder, compression_levels_[value].do_exhaustive_model_search);
- ok &= FLAC__stream_encoder_set_min_residual_partition_order(encoder, compression_levels_[value].min_residual_partition_order);
- ok &= FLAC__stream_encoder_set_max_residual_partition_order(encoder, compression_levels_[value].max_residual_partition_order);
- ok &= FLAC__stream_encoder_set_rice_parameter_search_dist (encoder, compression_levels_[value].rice_parameter_search_dist);
- return ok;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_set_blocksize(FLAC__StreamEncoder *encoder, unsigned value)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return false;
- encoder->protected_->blocksize = value;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_set_do_mid_side_stereo(FLAC__StreamEncoder *encoder, FLAC__bool value)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return false;
- encoder->protected_->do_mid_side_stereo = value;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_set_loose_mid_side_stereo(FLAC__StreamEncoder *encoder, FLAC__bool value)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return false;
- encoder->protected_->loose_mid_side_stereo = value;
- return true;
-}
-
-/*@@@@add to tests*/
-FLAC_API FLAC__bool FLAC__stream_encoder_set_apodization(FLAC__StreamEncoder *encoder, const char *specification)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- FLAC__ASSERT(0 != specification);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return false;
-#ifdef FLAC__INTEGER_ONLY_LIBRARY
- (void)specification; /* silently ignore since we haven't integerized; will always use a rectangular window */
-#else
- encoder->protected_->num_apodizations = 0;
- while(1) {
- const char *s = strchr(specification, ';');
- const size_t n = s? (size_t)(s - specification) : strlen(specification);
- if (n==8 && 0 == strncmp("bartlett" , specification, n))
- encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_BARTLETT;
- else if(n==13 && 0 == strncmp("bartlett_hann", specification, n))
- encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_BARTLETT_HANN;
- else if(n==8 && 0 == strncmp("blackman" , specification, n))
- encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_BLACKMAN;
- else if(n==26 && 0 == strncmp("blackman_harris_4term_92db", specification, n))
- encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_BLACKMAN_HARRIS_4TERM_92DB_SIDELOBE;
- else if(n==6 && 0 == strncmp("connes" , specification, n))
- encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_CONNES;
- else if(n==7 && 0 == strncmp("flattop" , specification, n))
- encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_FLATTOP;
- else if(n>7 && 0 == strncmp("gauss(" , specification, 6)) {
- FLAC__real stddev = (FLAC__real)strtod(specification+6, 0);
- if (stddev > 0.0 && stddev <= 0.5) {
- encoder->protected_->apodizations[encoder->protected_->num_apodizations].parameters.gauss.stddev = stddev;
- encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_GAUSS;
- }
- }
- else if(n==7 && 0 == strncmp("hamming" , specification, n))
- encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_HAMMING;
- else if(n==4 && 0 == strncmp("hann" , specification, n))
- encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_HANN;
- else if(n==13 && 0 == strncmp("kaiser_bessel", specification, n))
- encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_KAISER_BESSEL;
- else if(n==7 && 0 == strncmp("nuttall" , specification, n))
- encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_NUTTALL;
- else if(n==9 && 0 == strncmp("rectangle" , specification, n))
- encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_RECTANGLE;
- else if(n==8 && 0 == strncmp("triangle" , specification, n))
- encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_TRIANGLE;
- else if(n>7 && 0 == strncmp("tukey(" , specification, 6)) {
- FLAC__real p = (FLAC__real)strtod(specification+6, 0);
- if (p >= 0.0 && p <= 1.0) {
- encoder->protected_->apodizations[encoder->protected_->num_apodizations].parameters.tukey.p = p;
- encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_TUKEY;
- }
- }
- else if(n==5 && 0 == strncmp("welch" , specification, n))
- encoder->protected_->apodizations[encoder->protected_->num_apodizations++].type = FLAC__APODIZATION_WELCH;
- if (encoder->protected_->num_apodizations == 32)
- break;
- if (s)
- specification = s+1;
- else
- break;
- }
- if(encoder->protected_->num_apodizations == 0) {
- encoder->protected_->num_apodizations = 1;
- encoder->protected_->apodizations[0].type = FLAC__APODIZATION_TUKEY;
- encoder->protected_->apodizations[0].parameters.tukey.p = 0.5;
- }
-#endif
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_set_max_lpc_order(FLAC__StreamEncoder *encoder, unsigned value)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return false;
- encoder->protected_->max_lpc_order = value;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_set_qlp_coeff_precision(FLAC__StreamEncoder *encoder, unsigned value)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return false;
- encoder->protected_->qlp_coeff_precision = value;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_set_do_qlp_coeff_prec_search(FLAC__StreamEncoder *encoder, FLAC__bool value)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return false;
- encoder->protected_->do_qlp_coeff_prec_search = value;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_set_do_escape_coding(FLAC__StreamEncoder *encoder, FLAC__bool value)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return false;
-#if 0
- /*@@@ deprecated: */
- encoder->protected_->do_escape_coding = value;
-#else
- (void)value;
-#endif
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_set_do_exhaustive_model_search(FLAC__StreamEncoder *encoder, FLAC__bool value)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return false;
- encoder->protected_->do_exhaustive_model_search = value;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_set_min_residual_partition_order(FLAC__StreamEncoder *encoder, unsigned value)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return false;
- encoder->protected_->min_residual_partition_order = value;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_set_max_residual_partition_order(FLAC__StreamEncoder *encoder, unsigned value)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return false;
- encoder->protected_->max_residual_partition_order = value;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_set_rice_parameter_search_dist(FLAC__StreamEncoder *encoder, unsigned value)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return false;
-#if 0
- /*@@@ deprecated: */
- encoder->protected_->rice_parameter_search_dist = value;
-#else
- (void)value;
-#endif
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_set_total_samples_estimate(FLAC__StreamEncoder *encoder, FLAC__uint64 value)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return false;
- encoder->protected_->total_samples_estimate = value;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_set_metadata(FLAC__StreamEncoder *encoder, FLAC__StreamMetadata **metadata, unsigned num_blocks)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return false;
- if(0 == metadata)
- num_blocks = 0;
- if(0 == num_blocks)
- metadata = 0;
- /* realloc() does not do exactly what we want so... */
- if(encoder->protected_->metadata) {
- free(encoder->protected_->metadata);
- encoder->protected_->metadata = 0;
- encoder->protected_->num_metadata_blocks = 0;
- }
- if(num_blocks) {
- FLAC__StreamMetadata **m;
- if(0 == (m = (FLAC__StreamMetadata**)safe_malloc_mul_2op_(sizeof(m[0]), /*times*/num_blocks)))
- return false;
- memcpy(m, metadata, sizeof(m[0]) * num_blocks);
- encoder->protected_->metadata = m;
- encoder->protected_->num_metadata_blocks = num_blocks;
- }
-#if FLAC__HAS_OGG
- if(!FLAC__ogg_encoder_aspect_set_num_metadata(&encoder->protected_->ogg_encoder_aspect, num_blocks))
- return false;
-#endif
- return true;
-}
-
-/*
- * These three functions are not static, but not publically exposed in
- * include/FLAC/ either. They are used by the test suite.
- */
-FLAC_API FLAC__bool FLAC__stream_encoder_disable_constant_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return false;
- encoder->private_->disable_constant_subframes = value;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_disable_fixed_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return false;
- encoder->private_->disable_fixed_subframes = value;
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_disable_verbatim_subframes(FLAC__StreamEncoder *encoder, FLAC__bool value)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_UNINITIALIZED)
- return false;
- encoder->private_->disable_verbatim_subframes = value;
- return true;
-}
-
-FLAC_API FLAC__StreamEncoderState FLAC__stream_encoder_get_state(const FLAC__StreamEncoder *encoder)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- return encoder->protected_->state;
-}
-
-FLAC_API FLAC__StreamDecoderState FLAC__stream_encoder_get_verify_decoder_state(const FLAC__StreamEncoder *encoder)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(encoder->protected_->verify)
- return FLAC__stream_decoder_get_state(encoder->private_->verify.decoder);
- else
- return FLAC__STREAM_DECODER_UNINITIALIZED;
-}
-
-FLAC_API const char *FLAC__stream_encoder_get_resolved_state_string(const FLAC__StreamEncoder *encoder)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR)
- return FLAC__StreamEncoderStateString[encoder->protected_->state];
- else
- return FLAC__stream_decoder_get_resolved_state_string(encoder->private_->verify.decoder);
-}
-
-FLAC_API void FLAC__stream_encoder_get_verify_decoder_error_stats(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- if(0 != absolute_sample)
- *absolute_sample = encoder->private_->verify.error_stats.absolute_sample;
- if(0 != frame_number)
- *frame_number = encoder->private_->verify.error_stats.frame_number;
- if(0 != channel)
- *channel = encoder->private_->verify.error_stats.channel;
- if(0 != sample)
- *sample = encoder->private_->verify.error_stats.sample;
- if(0 != expected)
- *expected = encoder->private_->verify.error_stats.expected;
- if(0 != got)
- *got = encoder->private_->verify.error_stats.got;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_get_verify(const FLAC__StreamEncoder *encoder)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- return encoder->protected_->verify;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_get_streamable_subset(const FLAC__StreamEncoder *encoder)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- return encoder->protected_->streamable_subset;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_get_do_md5(const FLAC__StreamEncoder *encoder)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- return encoder->protected_->do_md5;
-}
-
-FLAC_API unsigned FLAC__stream_encoder_get_channels(const FLAC__StreamEncoder *encoder)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- return encoder->protected_->channels;
-}
-
-FLAC_API unsigned FLAC__stream_encoder_get_bits_per_sample(const FLAC__StreamEncoder *encoder)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- return encoder->protected_->bits_per_sample;
-}
-
-FLAC_API unsigned FLAC__stream_encoder_get_sample_rate(const FLAC__StreamEncoder *encoder)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- return encoder->protected_->sample_rate;
-}
-
-FLAC_API unsigned FLAC__stream_encoder_get_blocksize(const FLAC__StreamEncoder *encoder)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- return encoder->protected_->blocksize;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_get_do_mid_side_stereo(const FLAC__StreamEncoder *encoder)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- return encoder->protected_->do_mid_side_stereo;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_get_loose_mid_side_stereo(const FLAC__StreamEncoder *encoder)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- return encoder->protected_->loose_mid_side_stereo;
-}
-
-FLAC_API unsigned FLAC__stream_encoder_get_max_lpc_order(const FLAC__StreamEncoder *encoder)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- return encoder->protected_->max_lpc_order;
-}
-
-FLAC_API unsigned FLAC__stream_encoder_get_qlp_coeff_precision(const FLAC__StreamEncoder *encoder)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- return encoder->protected_->qlp_coeff_precision;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_get_do_qlp_coeff_prec_search(const FLAC__StreamEncoder *encoder)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- return encoder->protected_->do_qlp_coeff_prec_search;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_get_do_escape_coding(const FLAC__StreamEncoder *encoder)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- return encoder->protected_->do_escape_coding;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_get_do_exhaustive_model_search(const FLAC__StreamEncoder *encoder)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- return encoder->protected_->do_exhaustive_model_search;
-}
-
-FLAC_API unsigned FLAC__stream_encoder_get_min_residual_partition_order(const FLAC__StreamEncoder *encoder)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- return encoder->protected_->min_residual_partition_order;
-}
-
-FLAC_API unsigned FLAC__stream_encoder_get_max_residual_partition_order(const FLAC__StreamEncoder *encoder)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- return encoder->protected_->max_residual_partition_order;
-}
-
-FLAC_API unsigned FLAC__stream_encoder_get_rice_parameter_search_dist(const FLAC__StreamEncoder *encoder)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- return encoder->protected_->rice_parameter_search_dist;
-}
-
-FLAC_API FLAC__uint64 FLAC__stream_encoder_get_total_samples_estimate(const FLAC__StreamEncoder *encoder)
-{
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- return encoder->protected_->total_samples_estimate;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_process(FLAC__StreamEncoder *encoder, const FLAC__int32 * const buffer[], unsigned samples)
-{
- unsigned i, j = 0, channel;
- const unsigned channels = encoder->protected_->channels, blocksize = encoder->protected_->blocksize;
-
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- FLAC__ASSERT(encoder->protected_->state == FLAC__STREAM_ENCODER_OK);
-
- do {
- const unsigned n = min(blocksize+OVERREAD_-encoder->private_->current_sample_number, samples-j);
-
- if(encoder->protected_->verify)
- append_to_verify_fifo_(&encoder->private_->verify.input_fifo, buffer, j, channels, n);
-
- for(channel = 0; channel < channels; channel++)
- memcpy(&encoder->private_->integer_signal[channel][encoder->private_->current_sample_number], &buffer[channel][j], sizeof(buffer[channel][0]) * n);
-
- if(encoder->protected_->do_mid_side_stereo) {
- FLAC__ASSERT(channels == 2);
- /* "i <= blocksize" to overread 1 sample; see comment in OVERREAD_ decl */
- for(i = encoder->private_->current_sample_number; i <= blocksize && j < samples; i++, j++) {
- encoder->private_->integer_signal_mid_side[1][i] = buffer[0][j] - buffer[1][j];
- encoder->private_->integer_signal_mid_side[0][i] = (buffer[0][j] + buffer[1][j]) >> 1; /* NOTE: not the same as 'mid = (buffer[0][j] + buffer[1][j]) / 2' ! */
- }
- }
- else
- j += n;
-
- encoder->private_->current_sample_number += n;
-
- /* we only process if we have a full block + 1 extra sample; final block is always handled by FLAC__stream_encoder_finish() */
- if(encoder->private_->current_sample_number > blocksize) {
- FLAC__ASSERT(encoder->private_->current_sample_number == blocksize+OVERREAD_);
- FLAC__ASSERT(OVERREAD_ == 1); /* assert we only overread 1 sample which simplifies the rest of the code below */
- if(!process_frame_(encoder, /*is_fractional_block=*/false, /*is_last_block=*/false))
- return false;
- /* move unprocessed overread samples to beginnings of arrays */
- for(channel = 0; channel < channels; channel++)
- encoder->private_->integer_signal[channel][0] = encoder->private_->integer_signal[channel][blocksize];
- if(encoder->protected_->do_mid_side_stereo) {
- encoder->private_->integer_signal_mid_side[0][0] = encoder->private_->integer_signal_mid_side[0][blocksize];
- encoder->private_->integer_signal_mid_side[1][0] = encoder->private_->integer_signal_mid_side[1][blocksize];
- }
- encoder->private_->current_sample_number = 1;
- }
- } while(j < samples);
-
- return true;
-}
-
-FLAC_API FLAC__bool FLAC__stream_encoder_process_interleaved(FLAC__StreamEncoder *encoder, const FLAC__int32 buffer[], unsigned samples)
-{
- unsigned i, j, k, channel;
- FLAC__int32 x, mid, side;
- const unsigned channels = encoder->protected_->channels, blocksize = encoder->protected_->blocksize;
-
- FLAC__ASSERT(0 != encoder);
- FLAC__ASSERT(0 != encoder->private_);
- FLAC__ASSERT(0 != encoder->protected_);
- FLAC__ASSERT(encoder->protected_->state == FLAC__STREAM_ENCODER_OK);
-
- j = k = 0;
- /*
- * we have several flavors of the same basic loop, optimized for
- * different conditions:
- */
- if(encoder->protected_->do_mid_side_stereo && channels == 2) {
- /*
- * stereo coding: unroll channel loop
- */
- do {
- if(encoder->protected_->verify)
- append_to_verify_fifo_interleaved_(&encoder->private_->verify.input_fifo, buffer, j, channels, min(blocksize+OVERREAD_-encoder->private_->current_sample_number, samples-j));
-
- /* "i <= blocksize" to overread 1 sample; see comment in OVERREAD_ decl */
- for(i = encoder->private_->current_sample_number; i <= blocksize && j < samples; i++, j++) {
- encoder->private_->integer_signal[0][i] = mid = side = buffer[k++];
- x = buffer[k++];
- encoder->private_->integer_signal[1][i] = x;
- mid += x;
- side -= x;
- mid >>= 1; /* NOTE: not the same as 'mid = (left + right) / 2' ! */
- encoder->private_->integer_signal_mid_side[1][i] = side;
- encoder->private_->integer_signal_mid_side[0][i] = mid;
- }
- encoder->private_->current_sample_number = i;
- /* we only process if we have a full block + 1 extra sample; final block is always handled by FLAC__stream_encoder_finish() */
- if(i > blocksize) {
- if(!process_frame_(encoder, /*is_fractional_block=*/false, /*is_last_block=*/false))
- return false;
- /* move unprocessed overread samples to beginnings of arrays */
- FLAC__ASSERT(i == blocksize+OVERREAD_);
- FLAC__ASSERT(OVERREAD_ == 1); /* assert we only overread 1 sample which simplifies the rest of the code below */
- encoder->private_->integer_signal[0][0] = encoder->private_->integer_signal[0][blocksize];
- encoder->private_->integer_signal[1][0] = encoder->private_->integer_signal[1][blocksize];
- encoder->private_->integer_signal_mid_side[0][0] = encoder->private_->integer_signal_mid_side[0][blocksize];
- encoder->private_->integer_signal_mid_side[1][0] = encoder->private_->integer_signal_mid_side[1][blocksize];
- encoder->private_->current_sample_number = 1;
- }
- } while(j < samples);
- }
- else {
- /*
- * independent channel coding: buffer each channel in inner loop
- */
- do {
- if(encoder->protected_->verify)
- append_to_verify_fifo_interleaved_(&encoder->private_->verify.input_fifo, buffer, j, channels, min(blocksize+OVERREAD_-encoder->private_->current_sample_number, samples-j));
-
- /* "i <= blocksize" to overread 1 sample; see comment in OVERREAD_ decl */
- for(i = encoder->private_->current_sample_number; i <= blocksize && j < samples; i++, j++) {
- for(channel = 0; channel < channels; channel++)
- encoder->private_->integer_signal[channel][i] = buffer[k++];
- }
- encoder->private_->current_sample_number = i;
- /* we only process if we have a full block + 1 extra sample; final block is always handled by FLAC__stream_encoder_finish() */
- if(i > blocksize) {
- if(!process_frame_(encoder, /*is_fractional_block=*/false, /*is_last_block=*/false))
- return false;
- /* move unprocessed overread samples to beginnings of arrays */
- FLAC__ASSERT(i == blocksize+OVERREAD_);
- FLAC__ASSERT(OVERREAD_ == 1); /* assert we only overread 1 sample which simplifies the rest of the code below */
- for(channel = 0; channel < channels; channel++)
- encoder->private_->integer_signal[channel][0] = encoder->private_->integer_signal[channel][blocksize];
- encoder->private_->current_sample_number = 1;
- }
- } while(j < samples);
- }
-
- return true;
-}
-
-/***********************************************************************
- *
- * Private class methods
- *
- ***********************************************************************/
-
-void set_defaults_(FLAC__StreamEncoder *encoder)
-{
- FLAC__ASSERT(0 != encoder);
-
-#ifdef FLAC__MANDATORY_VERIFY_WHILE_ENCODING
- encoder->protected_->verify = true;
-#else
- encoder->protected_->verify = false;
-#endif
- encoder->protected_->streamable_subset = true;
- encoder->protected_->do_md5 = true;
- encoder->protected_->do_mid_side_stereo = false;
- encoder->protected_->loose_mid_side_stereo = false;
- encoder->protected_->channels = 2;
- encoder->protected_->bits_per_sample = 16;
- encoder->protected_->sample_rate = 44100;
- encoder->protected_->blocksize = 0;
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
- encoder->protected_->num_apodizations = 1;
- encoder->protected_->apodizations[0].type = FLAC__APODIZATION_TUKEY;
- encoder->protected_->apodizations[0].parameters.tukey.p = 0.5;
-#endif
- encoder->protected_->max_lpc_order = 0;
- encoder->protected_->qlp_coeff_precision = 0;
- encoder->protected_->do_qlp_coeff_prec_search = false;
- encoder->protected_->do_exhaustive_model_search = false;
- encoder->protected_->do_escape_coding = false;
- encoder->protected_->min_residual_partition_order = 0;
- encoder->protected_->max_residual_partition_order = 0;
- encoder->protected_->rice_parameter_search_dist = 0;
- encoder->protected_->total_samples_estimate = 0;
- encoder->protected_->metadata = 0;
- encoder->protected_->num_metadata_blocks = 0;
-
- encoder->private_->seek_table = 0;
- encoder->private_->disable_constant_subframes = false;
- encoder->private_->disable_fixed_subframes = false;
- encoder->private_->disable_verbatim_subframes = false;
-#if FLAC__HAS_OGG
- encoder->private_->is_ogg = false;
-#endif
- encoder->private_->read_callback = 0;
- encoder->private_->write_callback = 0;
- encoder->private_->seek_callback = 0;
- encoder->private_->tell_callback = 0;
- encoder->private_->metadata_callback = 0;
- encoder->private_->progress_callback = 0;
- encoder->private_->client_data = 0;
-
-#if FLAC__HAS_OGG
- FLAC__ogg_encoder_aspect_set_defaults(&encoder->protected_->ogg_encoder_aspect);
-#endif
-
- FLAC__stream_encoder_set_compression_level(encoder, 5);
-}
-
-void free_(FLAC__StreamEncoder *encoder)
-{
- unsigned i, channel;
-
- FLAC__ASSERT(0 != encoder);
- if(encoder->protected_->metadata) {
- free(encoder->protected_->metadata);
- encoder->protected_->metadata = 0;
- encoder->protected_->num_metadata_blocks = 0;
- }
- for(i = 0; i < encoder->protected_->channels; i++) {
- if(0 != encoder->private_->integer_signal_unaligned[i]) {
- free(encoder->private_->integer_signal_unaligned[i]);
- encoder->private_->integer_signal_unaligned[i] = 0;
- }
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
- if(0 != encoder->private_->real_signal_unaligned[i]) {
- free(encoder->private_->real_signal_unaligned[i]);
- encoder->private_->real_signal_unaligned[i] = 0;
- }
-#endif
- }
- for(i = 0; i < 2; i++) {
- if(0 != encoder->private_->integer_signal_mid_side_unaligned[i]) {
- free(encoder->private_->integer_signal_mid_side_unaligned[i]);
- encoder->private_->integer_signal_mid_side_unaligned[i] = 0;
- }
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
- if(0 != encoder->private_->real_signal_mid_side_unaligned[i]) {
- free(encoder->private_->real_signal_mid_side_unaligned[i]);
- encoder->private_->real_signal_mid_side_unaligned[i] = 0;
- }
-#endif
- }
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
- for(i = 0; i < encoder->protected_->num_apodizations; i++) {
- if(0 != encoder->private_->window_unaligned[i]) {
- free(encoder->private_->window_unaligned[i]);
- encoder->private_->window_unaligned[i] = 0;
- }
- }
- if(0 != encoder->private_->windowed_signal_unaligned) {
- free(encoder->private_->windowed_signal_unaligned);
- encoder->private_->windowed_signal_unaligned = 0;
- }
-#endif
- for(channel = 0; channel < encoder->protected_->channels; channel++) {
- for(i = 0; i < 2; i++) {
- if(0 != encoder->private_->residual_workspace_unaligned[channel][i]) {
- free(encoder->private_->residual_workspace_unaligned[channel][i]);
- encoder->private_->residual_workspace_unaligned[channel][i] = 0;
- }
- }
- }
- for(channel = 0; channel < 2; channel++) {
- for(i = 0; i < 2; i++) {
- if(0 != encoder->private_->residual_workspace_mid_side_unaligned[channel][i]) {
- free(encoder->private_->residual_workspace_mid_side_unaligned[channel][i]);
- encoder->private_->residual_workspace_mid_side_unaligned[channel][i] = 0;
- }
- }
- }
- if(0 != encoder->private_->abs_residual_partition_sums_unaligned) {
- free(encoder->private_->abs_residual_partition_sums_unaligned);
- encoder->private_->abs_residual_partition_sums_unaligned = 0;
- }
- if(0 != encoder->private_->raw_bits_per_partition_unaligned) {
- free(encoder->private_->raw_bits_per_partition_unaligned);
- encoder->private_->raw_bits_per_partition_unaligned = 0;
- }
- if(encoder->protected_->verify) {
- for(i = 0; i < encoder->protected_->channels; i++) {
- if(0 != encoder->private_->verify.input_fifo.data[i]) {
- free(encoder->private_->verify.input_fifo.data[i]);
- encoder->private_->verify.input_fifo.data[i] = 0;
- }
- }
- }
- FLAC__bitwriter_free(encoder->private_->frame);
-}
-
-FLAC__bool resize_buffers_(FLAC__StreamEncoder *encoder, unsigned new_blocksize)
-{
- FLAC__bool ok;
- unsigned i, channel;
-
- FLAC__ASSERT(new_blocksize > 0);
- FLAC__ASSERT(encoder->protected_->state == FLAC__STREAM_ENCODER_OK);
- FLAC__ASSERT(encoder->private_->current_sample_number == 0);
-
- /* To avoid excessive malloc'ing, we only grow the buffer; no shrinking. */
- if(new_blocksize <= encoder->private_->input_capacity)
- return true;
-
- ok = true;
-
- /* WATCHOUT: FLAC__lpc_compute_residual_from_qlp_coefficients_asm_ia32_mmx()
- * requires that the input arrays (in our case the integer signals)
- * have a buffer of up to 3 zeroes in front (at negative indices) for
- * alignment purposes; we use 4 in front to keep the data well-aligned.
- */
-
- for(i = 0; ok && i < encoder->protected_->channels; i++) {
- ok = ok && FLAC__memory_alloc_aligned_int32_array(new_blocksize+4+OVERREAD_, &encoder->private_->integer_signal_unaligned[i], &encoder->private_->integer_signal[i]);
- memset(encoder->private_->integer_signal[i], 0, sizeof(FLAC__int32)*4);
- encoder->private_->integer_signal[i] += 4;
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
-#if 0 /* @@@ currently unused */
- if(encoder->protected_->max_lpc_order > 0)
- ok = ok && FLAC__memory_alloc_aligned_real_array(new_blocksize+OVERREAD_, &encoder->private_->real_signal_unaligned[i], &encoder->private_->real_signal[i]);
-#endif
-#endif
- }
- for(i = 0; ok && i < 2; i++) {
- ok = ok && FLAC__memory_alloc_aligned_int32_array(new_blocksize+4+OVERREAD_, &encoder->private_->integer_signal_mid_side_unaligned[i], &encoder->private_->integer_signal_mid_side[i]);
- memset(encoder->private_->integer_signal_mid_side[i], 0, sizeof(FLAC__int32)*4);
- encoder->private_->integer_signal_mid_side[i] += 4;
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
-#if 0 /* @@@ currently unused */
- if(encoder->protected_->max_lpc_order > 0)
- ok = ok && FLAC__memory_alloc_aligned_real_array(new_blocksize+OVERREAD_, &encoder->private_->real_signal_mid_side_unaligned[i], &encoder->private_->real_signal_mid_side[i]);
-#endif
-#endif
- }
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
- if(ok && encoder->protected_->max_lpc_order > 0) {
- for(i = 0; ok && i < encoder->protected_->num_apodizations; i++)
- ok = ok && FLAC__memory_alloc_aligned_real_array(new_blocksize, &encoder->private_->window_unaligned[i], &encoder->private_->window[i]);
- ok = ok && FLAC__memory_alloc_aligned_real_array(new_blocksize, &encoder->private_->windowed_signal_unaligned, &encoder->private_->windowed_signal);
- }
-#endif
- for(channel = 0; ok && channel < encoder->protected_->channels; channel++) {
- for(i = 0; ok && i < 2; i++) {
- ok = ok && FLAC__memory_alloc_aligned_int32_array(new_blocksize, &encoder->private_->residual_workspace_unaligned[channel][i], &encoder->private_->residual_workspace[channel][i]);
- }
- }
- for(channel = 0; ok && channel < 2; channel++) {
- for(i = 0; ok && i < 2; i++) {
- ok = ok && FLAC__memory_alloc_aligned_int32_array(new_blocksize, &encoder->private_->residual_workspace_mid_side_unaligned[channel][i], &encoder->private_->residual_workspace_mid_side[channel][i]);
- }
- }
- /* the *2 is an approximation to the series 1 + 1/2 + 1/4 + ... that sums tree occupies in a flat array */
- /*@@@ new_blocksize*2 is too pessimistic, but to fix, we need smarter logic because a smaller new_blocksize can actually increase the # of partitions; would require moving this out into a separate function, then checking its capacity against the need of the current blocksize&min/max_partition_order (and maybe predictor order) */
- ok = ok && FLAC__memory_alloc_aligned_uint64_array(new_blocksize * 2, &encoder->private_->abs_residual_partition_sums_unaligned, &encoder->private_->abs_residual_partition_sums);
- if(encoder->protected_->do_escape_coding)
- ok = ok && FLAC__memory_alloc_aligned_unsigned_array(new_blocksize * 2, &encoder->private_->raw_bits_per_partition_unaligned, &encoder->private_->raw_bits_per_partition);
-
- /* now adjust the windows if the blocksize has changed */
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
- if(ok && new_blocksize != encoder->private_->input_capacity && encoder->protected_->max_lpc_order > 0) {
- for(i = 0; ok && i < encoder->protected_->num_apodizations; i++) {
- switch(encoder->protected_->apodizations[i].type) {
- case FLAC__APODIZATION_BARTLETT:
- FLAC__window_bartlett(encoder->private_->window[i], new_blocksize);
- break;
- case FLAC__APODIZATION_BARTLETT_HANN:
- FLAC__window_bartlett_hann(encoder->private_->window[i], new_blocksize);
- break;
- case FLAC__APODIZATION_BLACKMAN:
- FLAC__window_blackman(encoder->private_->window[i], new_blocksize);
- break;
- case FLAC__APODIZATION_BLACKMAN_HARRIS_4TERM_92DB_SIDELOBE:
- FLAC__window_blackman_harris_4term_92db_sidelobe(encoder->private_->window[i], new_blocksize);
- break;
- case FLAC__APODIZATION_CONNES:
- FLAC__window_connes(encoder->private_->window[i], new_blocksize);
- break;
- case FLAC__APODIZATION_FLATTOP:
- FLAC__window_flattop(encoder->private_->window[i], new_blocksize);
- break;
- case FLAC__APODIZATION_GAUSS:
- FLAC__window_gauss(encoder->private_->window[i], new_blocksize, encoder->protected_->apodizations[i].parameters.gauss.stddev);
- break;
- case FLAC__APODIZATION_HAMMING:
- FLAC__window_hamming(encoder->private_->window[i], new_blocksize);
- break;
- case FLAC__APODIZATION_HANN:
- FLAC__window_hann(encoder->private_->window[i], new_blocksize);
- break;
- case FLAC__APODIZATION_KAISER_BESSEL:
- FLAC__window_kaiser_bessel(encoder->private_->window[i], new_blocksize);
- break;
- case FLAC__APODIZATION_NUTTALL:
- FLAC__window_nuttall(encoder->private_->window[i], new_blocksize);
- break;
- case FLAC__APODIZATION_RECTANGLE:
- FLAC__window_rectangle(encoder->private_->window[i], new_blocksize);
- break;
- case FLAC__APODIZATION_TRIANGLE:
- FLAC__window_triangle(encoder->private_->window[i], new_blocksize);
- break;
- case FLAC__APODIZATION_TUKEY:
- FLAC__window_tukey(encoder->private_->window[i], new_blocksize, encoder->protected_->apodizations[i].parameters.tukey.p);
- break;
- case FLAC__APODIZATION_WELCH:
- FLAC__window_welch(encoder->private_->window[i], new_blocksize);
- break;
- default:
- FLAC__ASSERT(0);
- /* double protection */
- FLAC__window_hann(encoder->private_->window[i], new_blocksize);
- break;
- }
- }
- }
-#endif
-
- if(ok)
- encoder->private_->input_capacity = new_blocksize;
- else
- encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR;
-
- return ok;
-}
-
-FLAC__bool write_bitbuffer_(FLAC__StreamEncoder *encoder, unsigned samples, FLAC__bool is_last_block)
-{
- const FLAC__byte *buffer;
- size_t bytes;
-
- FLAC__ASSERT(FLAC__bitwriter_is_byte_aligned(encoder->private_->frame));
-
- if(!FLAC__bitwriter_get_buffer(encoder->private_->frame, &buffer, &bytes)) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR;
- return false;
- }
-
- if(encoder->protected_->verify) {
- encoder->private_->verify.output.data = buffer;
- encoder->private_->verify.output.bytes = bytes;
- if(encoder->private_->verify.state_hint == ENCODER_IN_MAGIC) {
- encoder->private_->verify.needs_magic_hack = true;
- }
- else {
- if(!FLAC__stream_decoder_process_single(encoder->private_->verify.decoder)) {
- FLAC__bitwriter_release_buffer(encoder->private_->frame);
- FLAC__bitwriter_clear(encoder->private_->frame);
- if(encoder->protected_->state != FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA)
- encoder->protected_->state = FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR;
- return false;
- }
- }
- }
-
- if(write_frame_(encoder, buffer, bytes, samples, is_last_block) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK) {
- FLAC__bitwriter_release_buffer(encoder->private_->frame);
- FLAC__bitwriter_clear(encoder->private_->frame);
- encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR;
- return false;
- }
-
- FLAC__bitwriter_release_buffer(encoder->private_->frame);
- FLAC__bitwriter_clear(encoder->private_->frame);
-
- if(samples > 0) {
- encoder->private_->streaminfo.data.stream_info.min_framesize = min(bytes, encoder->private_->streaminfo.data.stream_info.min_framesize);
- encoder->private_->streaminfo.data.stream_info.max_framesize = max(bytes, encoder->private_->streaminfo.data.stream_info.max_framesize);
- }
-
- return true;
-}
-
-FLAC__StreamEncoderWriteStatus write_frame_(FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, FLAC__bool is_last_block)
-{
- FLAC__StreamEncoderWriteStatus status;
- FLAC__uint64 output_position = 0;
-
- /* FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED just means we didn't get the offset; no error */
- if(encoder->private_->tell_callback && encoder->private_->tell_callback(encoder, &output_position, encoder->private_->client_data) == FLAC__STREAM_ENCODER_TELL_STATUS_ERROR) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR;
- return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
- }
-
- /*
- * Watch for the STREAMINFO block and first SEEKTABLE block to go by and store their offsets.
- */
- if(samples == 0) {
- FLAC__MetadataType type = (buffer[0] & 0x7f);
- if(type == FLAC__METADATA_TYPE_STREAMINFO)
- encoder->protected_->streaminfo_offset = output_position;
- else if(type == FLAC__METADATA_TYPE_SEEKTABLE && encoder->protected_->seektable_offset == 0)
- encoder->protected_->seektable_offset = output_position;
- }
-
- /*
- * Mark the current seek point if hit (if audio_offset == 0 that
- * means we're still writing metadata and haven't hit the first
- * frame yet)
- */
- if(0 != encoder->private_->seek_table && encoder->protected_->audio_offset > 0 && encoder->private_->seek_table->num_points > 0) {
- const unsigned blocksize = FLAC__stream_encoder_get_blocksize(encoder);
- const FLAC__uint64 frame_first_sample = encoder->private_->samples_written;
- const FLAC__uint64 frame_last_sample = frame_first_sample + (FLAC__uint64)blocksize - 1;
- FLAC__uint64 test_sample;
- unsigned i;
- for(i = encoder->private_->first_seekpoint_to_check; i < encoder->private_->seek_table->num_points; i++) {
- test_sample = encoder->private_->seek_table->points[i].sample_number;
- if(test_sample > frame_last_sample) {
- break;
- }
- else if(test_sample >= frame_first_sample) {
- encoder->private_->seek_table->points[i].sample_number = frame_first_sample;
- encoder->private_->seek_table->points[i].stream_offset = output_position - encoder->protected_->audio_offset;
- encoder->private_->seek_table->points[i].frame_samples = blocksize;
- encoder->private_->first_seekpoint_to_check++;
- /* DO NOT: "break;" and here's why:
- * The seektable template may contain more than one target
- * sample for any given frame; we will keep looping, generating
- * duplicate seekpoints for them, and we'll clean it up later,
- * just before writing the seektable back to the metadata.
- */
- }
- else {
- encoder->private_->first_seekpoint_to_check++;
- }
- }
- }
-
-#if FLAC__HAS_OGG
- if(encoder->private_->is_ogg) {
- status = FLAC__ogg_encoder_aspect_write_callback_wrapper(
- &encoder->protected_->ogg_encoder_aspect,
- buffer,
- bytes,
- samples,
- encoder->private_->current_frame_number,
- is_last_block,
- (FLAC__OggEncoderAspectWriteCallbackProxy)encoder->private_->write_callback,
- encoder,
- encoder->private_->client_data
- );
- }
- else
-#endif
- status = encoder->private_->write_callback(encoder, buffer, bytes, samples, encoder->private_->current_frame_number, encoder->private_->client_data);
-
- if(status == FLAC__STREAM_ENCODER_WRITE_STATUS_OK) {
- encoder->private_->bytes_written += bytes;
- encoder->private_->samples_written += samples;
- /* we keep a high watermark on the number of frames written because
- * when the encoder goes back to write metadata, 'current_frame'
- * will drop back to 0.
- */
- encoder->private_->frames_written = max(encoder->private_->frames_written, encoder->private_->current_frame_number+1);
- }
- else
- encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR;
-
- return status;
-}
-
-/* Gets called when the encoding process has finished so that we can update the STREAMINFO and SEEKTABLE blocks. */
-void update_metadata_(const FLAC__StreamEncoder *encoder)
-{
- FLAC__byte b[max(6, FLAC__STREAM_METADATA_SEEKPOINT_LENGTH)];
- const FLAC__StreamMetadata *metadata = &encoder->private_->streaminfo;
- const FLAC__uint64 samples = metadata->data.stream_info.total_samples;
- const unsigned min_framesize = metadata->data.stream_info.min_framesize;
- const unsigned max_framesize = metadata->data.stream_info.max_framesize;
- const unsigned bps = metadata->data.stream_info.bits_per_sample;
- FLAC__StreamEncoderSeekStatus seek_status;
-
- FLAC__ASSERT(metadata->type == FLAC__METADATA_TYPE_STREAMINFO);
-
- /* All this is based on intimate knowledge of the stream header
- * layout, but a change to the header format that would break this
- * would also break all streams encoded in the previous format.
- */
-
- /*
- * Write MD5 signature
- */
- {
- const unsigned md5_offset =
- FLAC__STREAM_METADATA_HEADER_LENGTH +
- (
- FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN
- ) / 8;
-
- if((seek_status = encoder->private_->seek_callback(encoder, encoder->protected_->streaminfo_offset + md5_offset, encoder->private_->client_data)) != FLAC__STREAM_ENCODER_SEEK_STATUS_OK) {
- if(seek_status == FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR)
- encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR;
- return;
- }
- if(encoder->private_->write_callback(encoder, metadata->data.stream_info.md5sum, 16, 0, 0, encoder->private_->client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR;
- return;
- }
- }
-
- /*
- * Write total samples
- */
- {
- const unsigned total_samples_byte_offset =
- FLAC__STREAM_METADATA_HEADER_LENGTH +
- (
- FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN
- - 4
- ) / 8;
-
- b[0] = ((FLAC__byte)(bps-1) << 4) | (FLAC__byte)((samples >> 32) & 0x0F);
- b[1] = (FLAC__byte)((samples >> 24) & 0xFF);
- b[2] = (FLAC__byte)((samples >> 16) & 0xFF);
- b[3] = (FLAC__byte)((samples >> 8) & 0xFF);
- b[4] = (FLAC__byte)(samples & 0xFF);
- if((seek_status = encoder->private_->seek_callback(encoder, encoder->protected_->streaminfo_offset + total_samples_byte_offset, encoder->private_->client_data)) != FLAC__STREAM_ENCODER_SEEK_STATUS_OK) {
- if(seek_status == FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR)
- encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR;
- return;
- }
- if(encoder->private_->write_callback(encoder, b, 5, 0, 0, encoder->private_->client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR;
- return;
- }
- }
-
- /*
- * Write min/max framesize
- */
- {
- const unsigned min_framesize_offset =
- FLAC__STREAM_METADATA_HEADER_LENGTH +
- (
- FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN
- ) / 8;
-
- b[0] = (FLAC__byte)((min_framesize >> 16) & 0xFF);
- b[1] = (FLAC__byte)((min_framesize >> 8) & 0xFF);
- b[2] = (FLAC__byte)(min_framesize & 0xFF);
- b[3] = (FLAC__byte)((max_framesize >> 16) & 0xFF);
- b[4] = (FLAC__byte)((max_framesize >> 8) & 0xFF);
- b[5] = (FLAC__byte)(max_framesize & 0xFF);
- if((seek_status = encoder->private_->seek_callback(encoder, encoder->protected_->streaminfo_offset + min_framesize_offset, encoder->private_->client_data)) != FLAC__STREAM_ENCODER_SEEK_STATUS_OK) {
- if(seek_status == FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR)
- encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR;
- return;
- }
- if(encoder->private_->write_callback(encoder, b, 6, 0, 0, encoder->private_->client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR;
- return;
- }
- }
-
- /*
- * Write seektable
- */
- if(0 != encoder->private_->seek_table && encoder->private_->seek_table->num_points > 0 && encoder->protected_->seektable_offset > 0) {
- unsigned i;
-
- FLAC__format_seektable_sort(encoder->private_->seek_table);
-
- FLAC__ASSERT(FLAC__format_seektable_is_legal(encoder->private_->seek_table));
-
- if((seek_status = encoder->private_->seek_callback(encoder, encoder->protected_->seektable_offset + FLAC__STREAM_METADATA_HEADER_LENGTH, encoder->private_->client_data)) != FLAC__STREAM_ENCODER_SEEK_STATUS_OK) {
- if(seek_status == FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR)
- encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR;
- return;
- }
-
- for(i = 0; i < encoder->private_->seek_table->num_points; i++) {
- FLAC__uint64 xx;
- unsigned x;
- xx = encoder->private_->seek_table->points[i].sample_number;
- b[7] = (FLAC__byte)xx; xx >>= 8;
- b[6] = (FLAC__byte)xx; xx >>= 8;
- b[5] = (FLAC__byte)xx; xx >>= 8;
- b[4] = (FLAC__byte)xx; xx >>= 8;
- b[3] = (FLAC__byte)xx; xx >>= 8;
- b[2] = (FLAC__byte)xx; xx >>= 8;
- b[1] = (FLAC__byte)xx; xx >>= 8;
- b[0] = (FLAC__byte)xx; xx >>= 8;
- xx = encoder->private_->seek_table->points[i].stream_offset;
- b[15] = (FLAC__byte)xx; xx >>= 8;
- b[14] = (FLAC__byte)xx; xx >>= 8;
- b[13] = (FLAC__byte)xx; xx >>= 8;
- b[12] = (FLAC__byte)xx; xx >>= 8;
- b[11] = (FLAC__byte)xx; xx >>= 8;
- b[10] = (FLAC__byte)xx; xx >>= 8;
- b[9] = (FLAC__byte)xx; xx >>= 8;
- b[8] = (FLAC__byte)xx; xx >>= 8;
- x = encoder->private_->seek_table->points[i].frame_samples;
- b[17] = (FLAC__byte)x; x >>= 8;
- b[16] = (FLAC__byte)x; x >>= 8;
- if(encoder->private_->write_callback(encoder, b, 18, 0, 0, encoder->private_->client_data) != FLAC__STREAM_ENCODER_WRITE_STATUS_OK) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_CLIENT_ERROR;
- return;
- }
- }
- }
-}
-
-#if FLAC__HAS_OGG
-/* Gets called when the encoding process has finished so that we can update the STREAMINFO and SEEKTABLE blocks. */
-void update_ogg_metadata_(FLAC__StreamEncoder *encoder)
-{
- /* the # of bytes in the 1st packet that precede the STREAMINFO */
- static const unsigned FIRST_OGG_PACKET_STREAMINFO_PREFIX_LENGTH =
- FLAC__OGG_MAPPING_PACKET_TYPE_LENGTH +
- FLAC__OGG_MAPPING_MAGIC_LENGTH +
- FLAC__OGG_MAPPING_VERSION_MAJOR_LENGTH +
- FLAC__OGG_MAPPING_VERSION_MINOR_LENGTH +
- FLAC__OGG_MAPPING_NUM_HEADERS_LENGTH +
- FLAC__STREAM_SYNC_LENGTH
- ;
- FLAC__byte b[max(6, FLAC__STREAM_METADATA_SEEKPOINT_LENGTH)];
- const FLAC__StreamMetadata *metadata = &encoder->private_->streaminfo;
- const FLAC__uint64 samples = metadata->data.stream_info.total_samples;
- const unsigned min_framesize = metadata->data.stream_info.min_framesize;
- const unsigned max_framesize = metadata->data.stream_info.max_framesize;
- ogg_page page;
-
- FLAC__ASSERT(metadata->type == FLAC__METADATA_TYPE_STREAMINFO);
- FLAC__ASSERT(0 != encoder->private_->seek_callback);
-
- /* Pre-check that client supports seeking, since we don't want the
- * ogg_helper code to ever have to deal with this condition.
- */
- if(encoder->private_->seek_callback(encoder, 0, encoder->private_->client_data) == FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED)
- return;
-
- /* All this is based on intimate knowledge of the stream header
- * layout, but a change to the header format that would break this
- * would also break all streams encoded in the previous format.
- */
-
- /**
- ** Write STREAMINFO stats
- **/
- simple_ogg_page__init(&page);
- if(!simple_ogg_page__get_at(encoder, encoder->protected_->streaminfo_offset, &page, encoder->private_->seek_callback, encoder->private_->read_callback, encoder->private_->client_data)) {
- simple_ogg_page__clear(&page);
- return; /* state already set */
- }
-
- /*
- * Write MD5 signature
- */
- {
- const unsigned md5_offset =
- FIRST_OGG_PACKET_STREAMINFO_PREFIX_LENGTH +
- FLAC__STREAM_METADATA_HEADER_LENGTH +
- (
- FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN
- ) / 8;
-
- if(md5_offset + 16 > (unsigned)page.body_len) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR;
- simple_ogg_page__clear(&page);
- return;
- }
- memcpy(page.body + md5_offset, metadata->data.stream_info.md5sum, 16);
- }
-
- /*
- * Write total samples
- */
- {
- const unsigned total_samples_byte_offset =
- FIRST_OGG_PACKET_STREAMINFO_PREFIX_LENGTH +
- FLAC__STREAM_METADATA_HEADER_LENGTH +
- (
- FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN
- - 4
- ) / 8;
-
- if(total_samples_byte_offset + 5 > (unsigned)page.body_len) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR;
- simple_ogg_page__clear(&page);
- return;
- }
- b[0] = (FLAC__byte)page.body[total_samples_byte_offset] & 0xF0;
- b[0] |= (FLAC__byte)((samples >> 32) & 0x0F);
- b[1] = (FLAC__byte)((samples >> 24) & 0xFF);
- b[2] = (FLAC__byte)((samples >> 16) & 0xFF);
- b[3] = (FLAC__byte)((samples >> 8) & 0xFF);
- b[4] = (FLAC__byte)(samples & 0xFF);
- memcpy(page.body + total_samples_byte_offset, b, 5);
- }
-
- /*
- * Write min/max framesize
- */
- {
- const unsigned min_framesize_offset =
- FIRST_OGG_PACKET_STREAMINFO_PREFIX_LENGTH +
- FLAC__STREAM_METADATA_HEADER_LENGTH +
- (
- FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN +
- FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN
- ) / 8;
-
- if(min_framesize_offset + 6 > (unsigned)page.body_len) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR;
- simple_ogg_page__clear(&page);
- return;
- }
- b[0] = (FLAC__byte)((min_framesize >> 16) & 0xFF);
- b[1] = (FLAC__byte)((min_framesize >> 8) & 0xFF);
- b[2] = (FLAC__byte)(min_framesize & 0xFF);
- b[3] = (FLAC__byte)((max_framesize >> 16) & 0xFF);
- b[4] = (FLAC__byte)((max_framesize >> 8) & 0xFF);
- b[5] = (FLAC__byte)(max_framesize & 0xFF);
- memcpy(page.body + min_framesize_offset, b, 6);
- }
- if(!simple_ogg_page__set_at(encoder, encoder->protected_->streaminfo_offset, &page, encoder->private_->seek_callback, encoder->private_->write_callback, encoder->private_->client_data)) {
- simple_ogg_page__clear(&page);
- return; /* state already set */
- }
- simple_ogg_page__clear(&page);
-
- /*
- * Write seektable
- */
- if(0 != encoder->private_->seek_table && encoder->private_->seek_table->num_points > 0 && encoder->protected_->seektable_offset > 0) {
- unsigned i;
- FLAC__byte *p;
-
- FLAC__format_seektable_sort(encoder->private_->seek_table);
-
- FLAC__ASSERT(FLAC__format_seektable_is_legal(encoder->private_->seek_table));
-
- simple_ogg_page__init(&page);
- if(!simple_ogg_page__get_at(encoder, encoder->protected_->seektable_offset, &page, encoder->private_->seek_callback, encoder->private_->read_callback, encoder->private_->client_data)) {
- simple_ogg_page__clear(&page);
- return; /* state already set */
- }
-
- if((FLAC__STREAM_METADATA_HEADER_LENGTH + 18*encoder->private_->seek_table->num_points) != (unsigned)page.body_len) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_OGG_ERROR;
- simple_ogg_page__clear(&page);
- return;
- }
-
- for(i = 0, p = page.body + FLAC__STREAM_METADATA_HEADER_LENGTH; i < encoder->private_->seek_table->num_points; i++, p += 18) {
- FLAC__uint64 xx;
- unsigned x;
- xx = encoder->private_->seek_table->points[i].sample_number;
- b[7] = (FLAC__byte)xx; xx >>= 8;
- b[6] = (FLAC__byte)xx; xx >>= 8;
- b[5] = (FLAC__byte)xx; xx >>= 8;
- b[4] = (FLAC__byte)xx; xx >>= 8;
- b[3] = (FLAC__byte)xx; xx >>= 8;
- b[2] = (FLAC__byte)xx; xx >>= 8;
- b[1] = (FLAC__byte)xx; xx >>= 8;
- b[0] = (FLAC__byte)xx; xx >>= 8;
- xx = encoder->private_->seek_table->points[i].stream_offset;
- b[15] = (FLAC__byte)xx; xx >>= 8;
- b[14] = (FLAC__byte)xx; xx >>= 8;
- b[13] = (FLAC__byte)xx; xx >>= 8;
- b[12] = (FLAC__byte)xx; xx >>= 8;
- b[11] = (FLAC__byte)xx; xx >>= 8;
- b[10] = (FLAC__byte)xx; xx >>= 8;
- b[9] = (FLAC__byte)xx; xx >>= 8;
- b[8] = (FLAC__byte)xx; xx >>= 8;
- x = encoder->private_->seek_table->points[i].frame_samples;
- b[17] = (FLAC__byte)x; x >>= 8;
- b[16] = (FLAC__byte)x; x >>= 8;
- memcpy(p, b, 18);
- }
-
- if(!simple_ogg_page__set_at(encoder, encoder->protected_->seektable_offset, &page, encoder->private_->seek_callback, encoder->private_->write_callback, encoder->private_->client_data)) {
- simple_ogg_page__clear(&page);
- return; /* state already set */
- }
- simple_ogg_page__clear(&page);
- }
-}
-#endif
-
-FLAC__bool process_frame_(FLAC__StreamEncoder *encoder, FLAC__bool is_fractional_block, FLAC__bool is_last_block)
-{
- FLAC__uint16 crc;
- FLAC__ASSERT(encoder->protected_->state == FLAC__STREAM_ENCODER_OK);
-
- /*
- * Accumulate raw signal to the MD5 signature
- */
- if(encoder->protected_->do_md5 && !FLAC__MD5Accumulate(&encoder->private_->md5context, (const FLAC__int32 * const *)encoder->private_->integer_signal, encoder->protected_->channels, encoder->protected_->blocksize, (encoder->protected_->bits_per_sample+7) / 8)) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR;
- return false;
- }
-
- /*
- * Process the frame header and subframes into the frame bitbuffer
- */
- if(!process_subframes_(encoder, is_fractional_block)) {
- /* the above function sets the state for us in case of an error */
- return false;
- }
-
- /*
- * Zero-pad the frame to a byte_boundary
- */
- if(!FLAC__bitwriter_zero_pad_to_byte_boundary(encoder->private_->frame)) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR;
- return false;
- }
-
- /*
- * CRC-16 the whole thing
- */
- FLAC__ASSERT(FLAC__bitwriter_is_byte_aligned(encoder->private_->frame));
- if(
- !FLAC__bitwriter_get_write_crc16(encoder->private_->frame, &crc) ||
- !FLAC__bitwriter_write_raw_uint32(encoder->private_->frame, crc, FLAC__FRAME_FOOTER_CRC_LEN)
- ) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR;
- return false;
- }
-
- /*
- * Write it
- */
- if(!write_bitbuffer_(encoder, encoder->protected_->blocksize, is_last_block)) {
- /* the above function sets the state for us in case of an error */
- return false;
- }
-
- /*
- * Get ready for the next frame
- */
- encoder->private_->current_sample_number = 0;
- encoder->private_->current_frame_number++;
- encoder->private_->streaminfo.data.stream_info.total_samples += (FLAC__uint64)encoder->protected_->blocksize;
-
- return true;
-}
-
-FLAC__bool process_subframes_(FLAC__StreamEncoder *encoder, FLAC__bool is_fractional_block)
-{
- FLAC__FrameHeader frame_header;
- unsigned channel, min_partition_order = encoder->protected_->min_residual_partition_order, max_partition_order;
- FLAC__bool do_independent, do_mid_side;
-
- /*
- * Calculate the min,max Rice partition orders
- */
- if(is_fractional_block) {
- max_partition_order = 0;
- }
- else {
- max_partition_order = FLAC__format_get_max_rice_partition_order_from_blocksize(encoder->protected_->blocksize);
- max_partition_order = min(max_partition_order, encoder->protected_->max_residual_partition_order);
- }
- min_partition_order = min(min_partition_order, max_partition_order);
-
- /*
- * Setup the frame
- */
- frame_header.blocksize = encoder->protected_->blocksize;
- frame_header.sample_rate = encoder->protected_->sample_rate;
- frame_header.channels = encoder->protected_->channels;
- frame_header.channel_assignment = FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT; /* the default unless the encoder determines otherwise */
- frame_header.bits_per_sample = encoder->protected_->bits_per_sample;
- frame_header.number_type = FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER;
- frame_header.number.frame_number = encoder->private_->current_frame_number;
-
- /*
- * Figure out what channel assignments to try
- */
- if(encoder->protected_->do_mid_side_stereo) {
- if(encoder->protected_->loose_mid_side_stereo) {
- if(encoder->private_->loose_mid_side_stereo_frame_count == 0) {
- do_independent = true;
- do_mid_side = true;
- }
- else {
- do_independent = (encoder->private_->last_channel_assignment == FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT);
- do_mid_side = !do_independent;
- }
- }
- else {
- do_independent = true;
- do_mid_side = true;
- }
- }
- else {
- do_independent = true;
- do_mid_side = false;
- }
-
- FLAC__ASSERT(do_independent || do_mid_side);
-
- /*
- * Check for wasted bits; set effective bps for each subframe
- */
- if(do_independent) {
- for(channel = 0; channel < encoder->protected_->channels; channel++) {
- const unsigned w = get_wasted_bits_(encoder->private_->integer_signal[channel], encoder->protected_->blocksize);
- encoder->private_->subframe_workspace[channel][0].wasted_bits = encoder->private_->subframe_workspace[channel][1].wasted_bits = w;
- encoder->private_->subframe_bps[channel] = encoder->protected_->bits_per_sample - w;
- }
- }
- if(do_mid_side) {
- FLAC__ASSERT(encoder->protected_->channels == 2);
- for(channel = 0; channel < 2; channel++) {
- const unsigned w = get_wasted_bits_(encoder->private_->integer_signal_mid_side[channel], encoder->protected_->blocksize);
- encoder->private_->subframe_workspace_mid_side[channel][0].wasted_bits = encoder->private_->subframe_workspace_mid_side[channel][1].wasted_bits = w;
- encoder->private_->subframe_bps_mid_side[channel] = encoder->protected_->bits_per_sample - w + (channel==0? 0:1);
- }
- }
-
- /*
- * First do a normal encoding pass of each independent channel
- */
- if(do_independent) {
- for(channel = 0; channel < encoder->protected_->channels; channel++) {
- if(!
- process_subframe_(
- encoder,
- min_partition_order,
- max_partition_order,
- &frame_header,
- encoder->private_->subframe_bps[channel],
- encoder->private_->integer_signal[channel],
- encoder->private_->subframe_workspace_ptr[channel],
- encoder->private_->partitioned_rice_contents_workspace_ptr[channel],
- encoder->private_->residual_workspace[channel],
- encoder->private_->best_subframe+channel,
- encoder->private_->best_subframe_bits+channel
- )
- )
- return false;
- }
- }
-
- /*
- * Now do mid and side channels if requested
- */
- if(do_mid_side) {
- FLAC__ASSERT(encoder->protected_->channels == 2);
-
- for(channel = 0; channel < 2; channel++) {
- if(!
- process_subframe_(
- encoder,
- min_partition_order,
- max_partition_order,
- &frame_header,
- encoder->private_->subframe_bps_mid_side[channel],
- encoder->private_->integer_signal_mid_side[channel],
- encoder->private_->subframe_workspace_ptr_mid_side[channel],
- encoder->private_->partitioned_rice_contents_workspace_ptr_mid_side[channel],
- encoder->private_->residual_workspace_mid_side[channel],
- encoder->private_->best_subframe_mid_side+channel,
- encoder->private_->best_subframe_bits_mid_side+channel
- )
- )
- return false;
- }
- }
-
- /*
- * Compose the frame bitbuffer
- */
- if(do_mid_side) {
- unsigned left_bps = 0, right_bps = 0; /* initialized only to prevent superfluous compiler warning */
- FLAC__Subframe *left_subframe = 0, *right_subframe = 0; /* initialized only to prevent superfluous compiler warning */
- FLAC__ChannelAssignment channel_assignment;
-
- FLAC__ASSERT(encoder->protected_->channels == 2);
-
- if(encoder->protected_->loose_mid_side_stereo && encoder->private_->loose_mid_side_stereo_frame_count > 0) {
- channel_assignment = (encoder->private_->last_channel_assignment == FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT? FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT : FLAC__CHANNEL_ASSIGNMENT_MID_SIDE);
- }
- else {
- unsigned bits[4]; /* WATCHOUT - indexed by FLAC__ChannelAssignment */
- unsigned min_bits;
- int ca;
-
- FLAC__ASSERT(FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT == 0);
- FLAC__ASSERT(FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE == 1);
- FLAC__ASSERT(FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE == 2);
- FLAC__ASSERT(FLAC__CHANNEL_ASSIGNMENT_MID_SIDE == 3);
- FLAC__ASSERT(do_independent && do_mid_side);
-
- /* We have to figure out which channel assignent results in the smallest frame */
- bits[FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT] = encoder->private_->best_subframe_bits [0] + encoder->private_->best_subframe_bits [1];
- bits[FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE ] = encoder->private_->best_subframe_bits [0] + encoder->private_->best_subframe_bits_mid_side[1];
- bits[FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE ] = encoder->private_->best_subframe_bits [1] + encoder->private_->best_subframe_bits_mid_side[1];
- bits[FLAC__CHANNEL_ASSIGNMENT_MID_SIDE ] = encoder->private_->best_subframe_bits_mid_side[0] + encoder->private_->best_subframe_bits_mid_side[1];
-
- channel_assignment = FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT;
- min_bits = bits[channel_assignment];
- for(ca = 1; ca <= 3; ca++) {
- if(bits[ca] < min_bits) {
- min_bits = bits[ca];
- channel_assignment = (FLAC__ChannelAssignment)ca;
- }
- }
- }
-
- frame_header.channel_assignment = channel_assignment;
-
- if(!FLAC__frame_add_header(&frame_header, encoder->private_->frame)) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR;
- return false;
- }
-
- switch(channel_assignment) {
- case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT:
- left_subframe = &encoder->private_->subframe_workspace [0][encoder->private_->best_subframe [0]];
- right_subframe = &encoder->private_->subframe_workspace [1][encoder->private_->best_subframe [1]];
- break;
- case FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE:
- left_subframe = &encoder->private_->subframe_workspace [0][encoder->private_->best_subframe [0]];
- right_subframe = &encoder->private_->subframe_workspace_mid_side[1][encoder->private_->best_subframe_mid_side[1]];
- break;
- case FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE:
- left_subframe = &encoder->private_->subframe_workspace_mid_side[1][encoder->private_->best_subframe_mid_side[1]];
- right_subframe = &encoder->private_->subframe_workspace [1][encoder->private_->best_subframe [1]];
- break;
- case FLAC__CHANNEL_ASSIGNMENT_MID_SIDE:
- left_subframe = &encoder->private_->subframe_workspace_mid_side[0][encoder->private_->best_subframe_mid_side[0]];
- right_subframe = &encoder->private_->subframe_workspace_mid_side[1][encoder->private_->best_subframe_mid_side[1]];
- break;
- default:
- FLAC__ASSERT(0);
- }
-
- switch(channel_assignment) {
- case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT:
- left_bps = encoder->private_->subframe_bps [0];
- right_bps = encoder->private_->subframe_bps [1];
- break;
- case FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE:
- left_bps = encoder->private_->subframe_bps [0];
- right_bps = encoder->private_->subframe_bps_mid_side[1];
- break;
- case FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE:
- left_bps = encoder->private_->subframe_bps_mid_side[1];
- right_bps = encoder->private_->subframe_bps [1];
- break;
- case FLAC__CHANNEL_ASSIGNMENT_MID_SIDE:
- left_bps = encoder->private_->subframe_bps_mid_side[0];
- right_bps = encoder->private_->subframe_bps_mid_side[1];
- break;
- default:
- FLAC__ASSERT(0);
- }
-
- /* note that encoder_add_subframe_ sets the state for us in case of an error */
- if(!add_subframe_(encoder, frame_header.blocksize, left_bps , left_subframe , encoder->private_->frame))
- return false;
- if(!add_subframe_(encoder, frame_header.blocksize, right_bps, right_subframe, encoder->private_->frame))
- return false;
- }
- else {
- if(!FLAC__frame_add_header(&frame_header, encoder->private_->frame)) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR;
- return false;
- }
-
- for(channel = 0; channel < encoder->protected_->channels; channel++) {
- if(!add_subframe_(encoder, frame_header.blocksize, encoder->private_->subframe_bps[channel], &encoder->private_->subframe_workspace[channel][encoder->private_->best_subframe[channel]], encoder->private_->frame)) {
- /* the above function sets the state for us in case of an error */
- return false;
- }
- }
- }
-
- if(encoder->protected_->loose_mid_side_stereo) {
- encoder->private_->loose_mid_side_stereo_frame_count++;
- if(encoder->private_->loose_mid_side_stereo_frame_count >= encoder->private_->loose_mid_side_stereo_frames)
- encoder->private_->loose_mid_side_stereo_frame_count = 0;
- }
-
- encoder->private_->last_channel_assignment = frame_header.channel_assignment;
-
- return true;
-}
-
-FLAC__bool process_subframe_(
- FLAC__StreamEncoder *encoder,
- unsigned min_partition_order,
- unsigned max_partition_order,
- const FLAC__FrameHeader *frame_header,
- unsigned subframe_bps,
- const FLAC__int32 integer_signal[],
- FLAC__Subframe *subframe[2],
- FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents[2],
- FLAC__int32 *residual[2],
- unsigned *best_subframe,
- unsigned *best_bits
-)
-{
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
- FLAC__float fixed_residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1];
-#else
- FLAC__fixedpoint fixed_residual_bits_per_sample[FLAC__MAX_FIXED_ORDER+1];
-#endif
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
- FLAC__double lpc_residual_bits_per_sample;
- FLAC__real autoc[FLAC__MAX_LPC_ORDER+1]; /* WATCHOUT: the size is important even though encoder->protected_->max_lpc_order might be less; some asm routines need all the space */
- FLAC__double lpc_error[FLAC__MAX_LPC_ORDER];
- unsigned min_lpc_order, max_lpc_order, lpc_order;
- unsigned min_qlp_coeff_precision, max_qlp_coeff_precision, qlp_coeff_precision;
-#endif
- unsigned min_fixed_order, max_fixed_order, guess_fixed_order, fixed_order;
- unsigned rice_parameter;
- unsigned _candidate_bits, _best_bits;
- unsigned _best_subframe;
- /* only use RICE2 partitions if stream bps > 16 */
- const unsigned rice_parameter_limit = FLAC__stream_encoder_get_bits_per_sample(encoder) > 16? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER;
-
- FLAC__ASSERT(frame_header->blocksize > 0);
-
- /* verbatim subframe is the baseline against which we measure other compressed subframes */
- _best_subframe = 0;
- if(encoder->private_->disable_verbatim_subframes && frame_header->blocksize >= FLAC__MAX_FIXED_ORDER)
- _best_bits = UINT_MAX;
- else
- _best_bits = evaluate_verbatim_subframe_(encoder, integer_signal, frame_header->blocksize, subframe_bps, subframe[_best_subframe]);
-
- if(frame_header->blocksize >= FLAC__MAX_FIXED_ORDER) {
- unsigned signal_is_constant = false;
- guess_fixed_order = encoder->private_->local_fixed_compute_best_predictor(integer_signal+FLAC__MAX_FIXED_ORDER, frame_header->blocksize-FLAC__MAX_FIXED_ORDER, fixed_residual_bits_per_sample);
- /* check for constant subframe */
- if(
- !encoder->private_->disable_constant_subframes &&
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
- fixed_residual_bits_per_sample[1] == 0.0
-#else
- fixed_residual_bits_per_sample[1] == FLAC__FP_ZERO
-#endif
- ) {
- /* the above means it's possible all samples are the same value; now double-check it: */
- unsigned i;
- signal_is_constant = true;
- for(i = 1; i < frame_header->blocksize; i++) {
- if(integer_signal[0] != integer_signal[i]) {
- signal_is_constant = false;
- break;
- }
- }
- }
- if(signal_is_constant) {
- _candidate_bits = evaluate_constant_subframe_(encoder, integer_signal[0], frame_header->blocksize, subframe_bps, subframe[!_best_subframe]);
- if(_candidate_bits < _best_bits) {
- _best_subframe = !_best_subframe;
- _best_bits = _candidate_bits;
- }
- }
- else {
- if(!encoder->private_->disable_fixed_subframes || (encoder->protected_->max_lpc_order == 0 && _best_bits == UINT_MAX)) {
- /* encode fixed */
- if(encoder->protected_->do_exhaustive_model_search) {
- min_fixed_order = 0;
- max_fixed_order = FLAC__MAX_FIXED_ORDER;
- }
- else {
- min_fixed_order = max_fixed_order = guess_fixed_order;
- }
- if(max_fixed_order >= frame_header->blocksize)
- max_fixed_order = frame_header->blocksize - 1;
- for(fixed_order = min_fixed_order; fixed_order <= max_fixed_order; fixed_order++) {
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
- if(fixed_residual_bits_per_sample[fixed_order] >= (FLAC__float)subframe_bps)
- continue; /* don't even try */
- rice_parameter = (fixed_residual_bits_per_sample[fixed_order] > 0.0)? (unsigned)(fixed_residual_bits_per_sample[fixed_order]+0.5) : 0; /* 0.5 is for rounding */
-#else
- if(FLAC__fixedpoint_trunc(fixed_residual_bits_per_sample[fixed_order]) >= (int)subframe_bps)
- continue; /* don't even try */
- rice_parameter = (fixed_residual_bits_per_sample[fixed_order] > FLAC__FP_ZERO)? (unsigned)FLAC__fixedpoint_trunc(fixed_residual_bits_per_sample[fixed_order]+FLAC__FP_ONE_HALF) : 0; /* 0.5 is for rounding */
-#endif
- rice_parameter++; /* to account for the signed->unsigned conversion during rice coding */
- if(rice_parameter >= rice_parameter_limit) {
-#ifdef DEBUG_VERBOSE
- fprintf(stderr, "clipping rice_parameter (%u -> %u) @0\n", rice_parameter, rice_parameter_limit - 1);
-#endif
- rice_parameter = rice_parameter_limit - 1;
- }
- _candidate_bits =
- evaluate_fixed_subframe_(
- encoder,
- integer_signal,
- residual[!_best_subframe],
- encoder->private_->abs_residual_partition_sums,
- encoder->private_->raw_bits_per_partition,
- frame_header->blocksize,
- subframe_bps,
- fixed_order,
- rice_parameter,
- rice_parameter_limit,
- min_partition_order,
- max_partition_order,
- encoder->protected_->do_escape_coding,
- encoder->protected_->rice_parameter_search_dist,
- subframe[!_best_subframe],
- partitioned_rice_contents[!_best_subframe]
- );
- if(_candidate_bits < _best_bits) {
- _best_subframe = !_best_subframe;
- _best_bits = _candidate_bits;
- }
- }
- }
-
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
- /* encode lpc */
- if(encoder->protected_->max_lpc_order > 0) {
- if(encoder->protected_->max_lpc_order >= frame_header->blocksize)
- max_lpc_order = frame_header->blocksize-1;
- else
- max_lpc_order = encoder->protected_->max_lpc_order;
- if(max_lpc_order > 0) {
- unsigned a;
- for (a = 0; a < encoder->protected_->num_apodizations; a++) {
- FLAC__lpc_window_data(integer_signal, encoder->private_->window[a], encoder->private_->windowed_signal, frame_header->blocksize);
- encoder->private_->local_lpc_compute_autocorrelation(encoder->private_->windowed_signal, frame_header->blocksize, max_lpc_order+1, autoc);
- /* if autoc[0] == 0.0, the signal is constant and we usually won't get here, but it can happen */
- if(autoc[0] != 0.0) {
- FLAC__lpc_compute_lp_coefficients(autoc, &max_lpc_order, encoder->private_->lp_coeff, lpc_error);
- if(encoder->protected_->do_exhaustive_model_search) {
- min_lpc_order = 1;
- }
- else {
- const unsigned guess_lpc_order =
- FLAC__lpc_compute_best_order(
- lpc_error,
- max_lpc_order,
- frame_header->blocksize,
- subframe_bps + (
- encoder->protected_->do_qlp_coeff_prec_search?
- FLAC__MIN_QLP_COEFF_PRECISION : /* have to guess; use the min possible size to avoid accidentally favoring lower orders */
- encoder->protected_->qlp_coeff_precision
- )
- );
- min_lpc_order = max_lpc_order = guess_lpc_order;
- }
- if(max_lpc_order >= frame_header->blocksize)
- max_lpc_order = frame_header->blocksize - 1;
- for(lpc_order = min_lpc_order; lpc_order <= max_lpc_order; lpc_order++) {
- lpc_residual_bits_per_sample = FLAC__lpc_compute_expected_bits_per_residual_sample(lpc_error[lpc_order-1], frame_header->blocksize-lpc_order);
- if(lpc_residual_bits_per_sample >= (FLAC__double)subframe_bps)
- continue; /* don't even try */
- rice_parameter = (lpc_residual_bits_per_sample > 0.0)? (unsigned)(lpc_residual_bits_per_sample+0.5) : 0; /* 0.5 is for rounding */
- rice_parameter++; /* to account for the signed->unsigned conversion during rice coding */
- if(rice_parameter >= rice_parameter_limit) {
-#ifdef DEBUG_VERBOSE
- fprintf(stderr, "clipping rice_parameter (%u -> %u) @1\n", rice_parameter, rice_parameter_limit - 1);
-#endif
- rice_parameter = rice_parameter_limit - 1;
- }
- if(encoder->protected_->do_qlp_coeff_prec_search) {
- min_qlp_coeff_precision = FLAC__MIN_QLP_COEFF_PRECISION;
- /* try to ensure a 32-bit datapath throughout for 16bps(+1bps for side channel) or less */
- if(subframe_bps <= 17) {
- max_qlp_coeff_precision = min(32 - subframe_bps - lpc_order, FLAC__MAX_QLP_COEFF_PRECISION);
- max_qlp_coeff_precision = max(max_qlp_coeff_precision, min_qlp_coeff_precision);
- }
- else
- max_qlp_coeff_precision = FLAC__MAX_QLP_COEFF_PRECISION;
- }
- else {
- min_qlp_coeff_precision = max_qlp_coeff_precision = encoder->protected_->qlp_coeff_precision;
- }
- for(qlp_coeff_precision = min_qlp_coeff_precision; qlp_coeff_precision <= max_qlp_coeff_precision; qlp_coeff_precision++) {
- _candidate_bits =
- evaluate_lpc_subframe_(
- encoder,
- integer_signal,
- residual[!_best_subframe],
- encoder->private_->abs_residual_partition_sums,
- encoder->private_->raw_bits_per_partition,
- encoder->private_->lp_coeff[lpc_order-1],
- frame_header->blocksize,
- subframe_bps,
- lpc_order,
- qlp_coeff_precision,
- rice_parameter,
- rice_parameter_limit,
- min_partition_order,
- max_partition_order,
- encoder->protected_->do_escape_coding,
- encoder->protected_->rice_parameter_search_dist,
- subframe[!_best_subframe],
- partitioned_rice_contents[!_best_subframe]
- );
- if(_candidate_bits > 0) { /* if == 0, there was a problem quantizing the lpcoeffs */
- if(_candidate_bits < _best_bits) {
- _best_subframe = !_best_subframe;
- _best_bits = _candidate_bits;
- }
- }
- }
- }
- }
- }
- }
- }
-#endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */
- }
- }
-
- /* under rare circumstances this can happen when all but lpc subframe types are disabled: */
- if(_best_bits == UINT_MAX) {
- FLAC__ASSERT(_best_subframe == 0);
- _best_bits = evaluate_verbatim_subframe_(encoder, integer_signal, frame_header->blocksize, subframe_bps, subframe[_best_subframe]);
- }
-
- *best_subframe = _best_subframe;
- *best_bits = _best_bits;
-
- return true;
-}
-
-FLAC__bool add_subframe_(
- FLAC__StreamEncoder *encoder,
- unsigned blocksize,
- unsigned subframe_bps,
- const FLAC__Subframe *subframe,
- FLAC__BitWriter *frame
-)
-{
- switch(subframe->type) {
- case FLAC__SUBFRAME_TYPE_CONSTANT:
- if(!FLAC__subframe_add_constant(&(subframe->data.constant), subframe_bps, subframe->wasted_bits, frame)) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR;
- return false;
- }
- break;
- case FLAC__SUBFRAME_TYPE_FIXED:
- if(!FLAC__subframe_add_fixed(&(subframe->data.fixed), blocksize - subframe->data.fixed.order, subframe_bps, subframe->wasted_bits, frame)) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR;
- return false;
- }
- break;
- case FLAC__SUBFRAME_TYPE_LPC:
- if(!FLAC__subframe_add_lpc(&(subframe->data.lpc), blocksize - subframe->data.lpc.order, subframe_bps, subframe->wasted_bits, frame)) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR;
- return false;
- }
- break;
- case FLAC__SUBFRAME_TYPE_VERBATIM:
- if(!FLAC__subframe_add_verbatim(&(subframe->data.verbatim), blocksize, subframe_bps, subframe->wasted_bits, frame)) {
- encoder->protected_->state = FLAC__STREAM_ENCODER_FRAMING_ERROR;
- return false;
- }
- break;
- default:
- FLAC__ASSERT(0);
- }
-
- return true;
-}
-
-#define SPOTCHECK_ESTIMATE 0
-#if SPOTCHECK_ESTIMATE
-static void spotcheck_subframe_estimate_(
- FLAC__StreamEncoder *encoder,
- unsigned blocksize,
- unsigned subframe_bps,
- const FLAC__Subframe *subframe,
- unsigned estimate
-)
-{
- FLAC__bool ret;
- FLAC__BitWriter *frame = FLAC__bitwriter_new();
- if(frame == 0) {
- fprintf(stderr, "EST: can't allocate frame\n");
- return;
- }
- if(!FLAC__bitwriter_init(frame)) {
- fprintf(stderr, "EST: can't init frame\n");
- return;
- }
- ret = add_subframe_(encoder, blocksize, subframe_bps, subframe, frame);
- FLAC__ASSERT(ret);
- {
- const unsigned actual = FLAC__bitwriter_get_input_bits_unconsumed(frame);
- if(estimate != actual)
- fprintf(stderr, "EST: bad, frame#%u sub#%%d type=%8s est=%u, actual=%u, delta=%d\n", encoder->private_->current_frame_number, FLAC__SubframeTypeString[subframe->type], estimate, actual, (int)actual-(int)estimate);
- }
- FLAC__bitwriter_delete(frame);
-}
-#endif
-
-unsigned evaluate_constant_subframe_(
- FLAC__StreamEncoder *encoder,
- const FLAC__int32 signal,
- unsigned blocksize,
- unsigned subframe_bps,
- FLAC__Subframe *subframe
-)
-{
- unsigned estimate;
- subframe->type = FLAC__SUBFRAME_TYPE_CONSTANT;
- subframe->data.constant.value = signal;
-
- estimate = FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN + subframe->wasted_bits + subframe_bps;
-
-#if SPOTCHECK_ESTIMATE
- spotcheck_subframe_estimate_(encoder, blocksize, subframe_bps, subframe, estimate);
-#else
- (void)encoder, (void)blocksize;
-#endif
-
- return estimate;
-}
-
-unsigned evaluate_fixed_subframe_(
- FLAC__StreamEncoder *encoder,
- const FLAC__int32 signal[],
- FLAC__int32 residual[],
- FLAC__uint64 abs_residual_partition_sums[],
- unsigned raw_bits_per_partition[],
- unsigned blocksize,
- unsigned subframe_bps,
- unsigned order,
- unsigned rice_parameter,
- unsigned rice_parameter_limit,
- unsigned min_partition_order,
- unsigned max_partition_order,
- FLAC__bool do_escape_coding,
- unsigned rice_parameter_search_dist,
- FLAC__Subframe *subframe,
- FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents
-)
-{
- unsigned i, residual_bits, estimate;
- const unsigned residual_samples = blocksize - order;
-
- FLAC__fixed_compute_residual(signal+order, residual_samples, order, residual);
-
- subframe->type = FLAC__SUBFRAME_TYPE_FIXED;
-
- subframe->data.fixed.entropy_coding_method.type = FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE;
- subframe->data.fixed.entropy_coding_method.data.partitioned_rice.contents = partitioned_rice_contents;
- subframe->data.fixed.residual = residual;
-
- residual_bits =
- find_best_partition_order_(
- encoder->private_,
- residual,
- abs_residual_partition_sums,
- raw_bits_per_partition,
- residual_samples,
- order,
- rice_parameter,
- rice_parameter_limit,
- min_partition_order,
- max_partition_order,
- subframe_bps,
- do_escape_coding,
- rice_parameter_search_dist,
- &subframe->data.fixed.entropy_coding_method
- );
-
- subframe->data.fixed.order = order;
- for(i = 0; i < order; i++)
- subframe->data.fixed.warmup[i] = signal[i];
-
- estimate = FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN + subframe->wasted_bits + (order * subframe_bps) + residual_bits;
-
-#if SPOTCHECK_ESTIMATE
- spotcheck_subframe_estimate_(encoder, blocksize, subframe_bps, subframe, estimate);
-#endif
-
- return estimate;
-}
-
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
-unsigned evaluate_lpc_subframe_(
- FLAC__StreamEncoder *encoder,
- const FLAC__int32 signal[],
- FLAC__int32 residual[],
- FLAC__uint64 abs_residual_partition_sums[],
- unsigned raw_bits_per_partition[],
- const FLAC__real lp_coeff[],
- unsigned blocksize,
- unsigned subframe_bps,
- unsigned order,
- unsigned qlp_coeff_precision,
- unsigned rice_parameter,
- unsigned rice_parameter_limit,
- unsigned min_partition_order,
- unsigned max_partition_order,
- FLAC__bool do_escape_coding,
- unsigned rice_parameter_search_dist,
- FLAC__Subframe *subframe,
- FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents
-)
-{
- FLAC__int32 qlp_coeff[FLAC__MAX_LPC_ORDER];
- unsigned i, residual_bits, estimate;
- int quantization, ret;
- const unsigned residual_samples = blocksize - order;
-
- /* try to keep qlp coeff precision such that only 32-bit math is required for decode of <=16bps streams */
- if(subframe_bps <= 16) {
- FLAC__ASSERT(order > 0);
- FLAC__ASSERT(order <= FLAC__MAX_LPC_ORDER);
- qlp_coeff_precision = min(qlp_coeff_precision, 32 - subframe_bps - FLAC__bitmath_ilog2(order));
- }
-
- ret = FLAC__lpc_quantize_coefficients(lp_coeff, order, qlp_coeff_precision, qlp_coeff, &quantization);
- if(ret != 0)
- return 0; /* this is a hack to indicate to the caller that we can't do lp at this order on this subframe */
-
- if(subframe_bps + qlp_coeff_precision + FLAC__bitmath_ilog2(order) <= 32)
- if(subframe_bps <= 16 && qlp_coeff_precision <= 16)
- encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_16bit(signal+order, residual_samples, qlp_coeff, order, quantization, residual);
- else
- encoder->private_->local_lpc_compute_residual_from_qlp_coefficients(signal+order, residual_samples, qlp_coeff, order, quantization, residual);
- else
- encoder->private_->local_lpc_compute_residual_from_qlp_coefficients_64bit(signal+order, residual_samples, qlp_coeff, order, quantization, residual);
-
- subframe->type = FLAC__SUBFRAME_TYPE_LPC;
-
- subframe->data.lpc.entropy_coding_method.type = FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE;
- subframe->data.lpc.entropy_coding_method.data.partitioned_rice.contents = partitioned_rice_contents;
- subframe->data.lpc.residual = residual;
-
- residual_bits =
- find_best_partition_order_(
- encoder->private_,
- residual,
- abs_residual_partition_sums,
- raw_bits_per_partition,
- residual_samples,
- order,
- rice_parameter,
- rice_parameter_limit,
- min_partition_order,
- max_partition_order,
- subframe_bps,
- do_escape_coding,
- rice_parameter_search_dist,
- &subframe->data.lpc.entropy_coding_method
- );
-
- subframe->data.lpc.order = order;
- subframe->data.lpc.qlp_coeff_precision = qlp_coeff_precision;
- subframe->data.lpc.quantization_level = quantization;
- memcpy(subframe->data.lpc.qlp_coeff, qlp_coeff, sizeof(FLAC__int32)*FLAC__MAX_LPC_ORDER);
- for(i = 0; i < order; i++)
- subframe->data.lpc.warmup[i] = signal[i];
-
- estimate = FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN + subframe->wasted_bits + FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN + FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN + (order * (qlp_coeff_precision + subframe_bps)) + residual_bits;
-
-#if SPOTCHECK_ESTIMATE
- spotcheck_subframe_estimate_(encoder, blocksize, subframe_bps, subframe, estimate);
-#endif
-
- return estimate;
-}
-#endif
-
-unsigned evaluate_verbatim_subframe_(
- FLAC__StreamEncoder *encoder,
- const FLAC__int32 signal[],
- unsigned blocksize,
- unsigned subframe_bps,
- FLAC__Subframe *subframe
-)
-{
- unsigned estimate;
-
- subframe->type = FLAC__SUBFRAME_TYPE_VERBATIM;
-
- subframe->data.verbatim.data = signal;
-
- estimate = FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN + subframe->wasted_bits + (blocksize * subframe_bps);
-
-#if SPOTCHECK_ESTIMATE
- spotcheck_subframe_estimate_(encoder, blocksize, subframe_bps, subframe, estimate);
-#else
- (void)encoder;
-#endif
-
- return estimate;
-}
-
-unsigned find_best_partition_order_(
- FLAC__StreamEncoderPrivate *private_,
- const FLAC__int32 residual[],
- FLAC__uint64 abs_residual_partition_sums[],
- unsigned raw_bits_per_partition[],
- unsigned residual_samples,
- unsigned predictor_order,
- unsigned rice_parameter,
- unsigned rice_parameter_limit,
- unsigned min_partition_order,
- unsigned max_partition_order,
- unsigned bps,
- FLAC__bool do_escape_coding,
- unsigned rice_parameter_search_dist,
- FLAC__EntropyCodingMethod *best_ecm
-)
-{
- unsigned residual_bits, best_residual_bits = 0;
- unsigned best_parameters_index = 0;
- unsigned best_partition_order = 0;
- const unsigned blocksize = residual_samples + predictor_order;
-
- max_partition_order = FLAC__format_get_max_rice_partition_order_from_blocksize_limited_max_and_predictor_order(max_partition_order, blocksize, predictor_order);
- min_partition_order = min(min_partition_order, max_partition_order);
-
- precompute_partition_info_sums_(residual, abs_residual_partition_sums, residual_samples, predictor_order, min_partition_order, max_partition_order, bps);
-
- if(do_escape_coding)
- precompute_partition_info_escapes_(residual, raw_bits_per_partition, residual_samples, predictor_order, min_partition_order, max_partition_order);
-
- {
- int partition_order;
- unsigned sum;
-
- for(partition_order = (int)max_partition_order, sum = 0; partition_order >= (int)min_partition_order; partition_order--) {
- if(!
- set_partitioned_rice_(
-#ifdef EXACT_RICE_BITS_CALCULATION
- residual,
-#endif
- abs_residual_partition_sums+sum,
- raw_bits_per_partition+sum,
- residual_samples,
- predictor_order,
- rice_parameter,
- rice_parameter_limit,
- rice_parameter_search_dist,
- (unsigned)partition_order,
- do_escape_coding,
- &private_->partitioned_rice_contents_extra[!best_parameters_index],
- &residual_bits
- )
- )
- {
- FLAC__ASSERT(best_residual_bits != 0);
- break;
- }
- sum += 1u << partition_order;
- if(best_residual_bits == 0 || residual_bits < best_residual_bits) {
- best_residual_bits = residual_bits;
- best_parameters_index = !best_parameters_index;
- best_partition_order = partition_order;
- }
- }
- }
-
- best_ecm->data.partitioned_rice.order = best_partition_order;
-
- {
- /*
- * We are allowed to de-const the pointer based on our special
- * knowledge; it is const to the outside world.
- */
- FLAC__EntropyCodingMethod_PartitionedRiceContents* prc = (FLAC__EntropyCodingMethod_PartitionedRiceContents*)best_ecm->data.partitioned_rice.contents;
- unsigned partition;
-
- /* save best parameters and raw_bits */
- FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(prc, max(6, best_partition_order));
- memcpy(prc->parameters, private_->partitioned_rice_contents_extra[best_parameters_index].parameters, sizeof(unsigned)*(1<<(best_partition_order)));
- if(do_escape_coding)
- memcpy(prc->raw_bits, private_->partitioned_rice_contents_extra[best_parameters_index].raw_bits, sizeof(unsigned)*(1<<(best_partition_order)));
- /*
- * Now need to check if the type should be changed to
- * FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 based on the
- * size of the rice parameters.
- */
- for(partition = 0; partition < (1u<<best_partition_order); partition++) {
- if(prc->parameters[partition] >= FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER) {
- best_ecm->type = FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2;
- break;
- }
- }
- }
-
- return best_residual_bits;
-}
-
-#if defined(FLAC__CPU_IA32) && !defined FLAC__NO_ASM && defined FLAC__HAS_NASM
-extern void precompute_partition_info_sums_32bit_asm_ia32_(
- const FLAC__int32 residual[],
- FLAC__uint64 abs_residual_partition_sums[],
- unsigned blocksize,
- unsigned predictor_order,
- unsigned min_partition_order,
- unsigned max_partition_order
-);
-#endif
-
-void precompute_partition_info_sums_(
- const FLAC__int32 residual[],
- FLAC__uint64 abs_residual_partition_sums[],
- unsigned residual_samples,
- unsigned predictor_order,
- unsigned min_partition_order,
- unsigned max_partition_order,
- unsigned bps
-)
-{
- const unsigned default_partition_samples = (residual_samples + predictor_order) >> max_partition_order;
- unsigned partitions = 1u << max_partition_order;
-
- FLAC__ASSERT(default_partition_samples > predictor_order);
-
-#if defined(FLAC__CPU_IA32) && !defined FLAC__NO_ASM && defined FLAC__HAS_NASM
- /* slightly pessimistic but still catches all common cases */
- /* WATCHOUT: "+ bps" is an assumption that the average residual magnitude will not be more than "bps" bits */
- if(FLAC__bitmath_ilog2(default_partition_samples) + bps < 32) {
- precompute_partition_info_sums_32bit_asm_ia32_(residual, abs_residual_partition_sums, residual_samples + predictor_order, predictor_order, min_partition_order, max_partition_order);
- return;
- }
-#endif
-
- /* first do max_partition_order */
- {
- unsigned partition, residual_sample, end = (unsigned)(-(int)predictor_order);
- /* slightly pessimistic but still catches all common cases */
- /* WATCHOUT: "+ bps" is an assumption that the average residual magnitude will not be more than "bps" bits */
- if(FLAC__bitmath_ilog2(default_partition_samples) + bps < 32) {
- FLAC__uint32 abs_residual_partition_sum;
-
- for(partition = residual_sample = 0; partition < partitions; partition++) {
- end += default_partition_samples;
- abs_residual_partition_sum = 0;
- for( ; residual_sample < end; residual_sample++)
- abs_residual_partition_sum += abs(residual[residual_sample]); /* abs(INT_MIN) is undefined, but if the residual is INT_MIN we have bigger problems */
- abs_residual_partition_sums[partition] = abs_residual_partition_sum;
- }
- }
- else { /* have to pessimistically use 64 bits for accumulator */
- FLAC__uint64 abs_residual_partition_sum;
-
- for(partition = residual_sample = 0; partition < partitions; partition++) {
- end += default_partition_samples;
- abs_residual_partition_sum = 0;
- for( ; residual_sample < end; residual_sample++)
- abs_residual_partition_sum += abs(residual[residual_sample]); /* abs(INT_MIN) is undefined, but if the residual is INT_MIN we have bigger problems */
- abs_residual_partition_sums[partition] = abs_residual_partition_sum;
- }
- }
- }
-
- /* now merge partitions for lower orders */
- {
- unsigned from_partition = 0, to_partition = partitions;
- int partition_order;
- for(partition_order = (int)max_partition_order - 1; partition_order >= (int)min_partition_order; partition_order--) {
- unsigned i;
- partitions >>= 1;
- for(i = 0; i < partitions; i++) {
- abs_residual_partition_sums[to_partition++] =
- abs_residual_partition_sums[from_partition ] +
- abs_residual_partition_sums[from_partition+1];
- from_partition += 2;
- }
- }
- }
-}
-
-void precompute_partition_info_escapes_(
- const FLAC__int32 residual[],
- unsigned raw_bits_per_partition[],
- unsigned residual_samples,
- unsigned predictor_order,
- unsigned min_partition_order,
- unsigned max_partition_order
-)
-{
- int partition_order;
- unsigned from_partition, to_partition = 0;
- const unsigned blocksize = residual_samples + predictor_order;
-
- /* first do max_partition_order */
- for(partition_order = (int)max_partition_order; partition_order >= 0; partition_order--) {
- FLAC__int32 r;
- FLAC__uint32 rmax;
- unsigned partition, partition_sample, partition_samples, residual_sample;
- const unsigned partitions = 1u << partition_order;
- const unsigned default_partition_samples = blocksize >> partition_order;
-
- FLAC__ASSERT(default_partition_samples > predictor_order);
-
- for(partition = residual_sample = 0; partition < partitions; partition++) {
- partition_samples = default_partition_samples;
- if(partition == 0)
- partition_samples -= predictor_order;
- rmax = 0;
- for(partition_sample = 0; partition_sample < partition_samples; partition_sample++) {
- r = residual[residual_sample++];
- /* OPT: maybe faster: rmax |= r ^ (r>>31) */
- if(r < 0)
- rmax |= ~r;
- else
- rmax |= r;
- }
- /* now we know all residual values are in the range [-rmax-1,rmax] */
- raw_bits_per_partition[partition] = rmax? FLAC__bitmath_ilog2(rmax) + 2 : 1;
- }
- to_partition = partitions;
- break; /*@@@ yuck, should remove the 'for' loop instead */
- }
-
- /* now merge partitions for lower orders */
- for(from_partition = 0, --partition_order; partition_order >= (int)min_partition_order; partition_order--) {
- unsigned m;
- unsigned i;
- const unsigned partitions = 1u << partition_order;
- for(i = 0; i < partitions; i++) {
- m = raw_bits_per_partition[from_partition];
- from_partition++;
- raw_bits_per_partition[to_partition] = max(m, raw_bits_per_partition[from_partition]);
- from_partition++;
- to_partition++;
- }
- }
-}
-
-#ifdef EXACT_RICE_BITS_CALCULATION
-static FLaC__INLINE unsigned count_rice_bits_in_partition_(
- const unsigned rice_parameter,
- const unsigned partition_samples,
- const FLAC__int32 *residual
-)
-{
- unsigned i, partition_bits =
- FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN + /* actually could end up being FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN but err on side of 16bps */
- (1+rice_parameter) * partition_samples /* 1 for unary stop bit + rice_parameter for the binary portion */
- ;
- for(i = 0; i < partition_samples; i++)
- partition_bits += ( (FLAC__uint32)((residual[i]<<1)^(residual[i]>>31)) >> rice_parameter );
- return partition_bits;
-}
-#else
-static FLaC__INLINE unsigned count_rice_bits_in_partition_(
- const unsigned rice_parameter,
- const unsigned partition_samples,
- const FLAC__uint64 abs_residual_partition_sum
-)
-{
- return
- FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN + /* actually could end up being FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN but err on side of 16bps */
- (1+rice_parameter) * partition_samples + /* 1 for unary stop bit + rice_parameter for the binary portion */
- (
- rice_parameter?
- (unsigned)(abs_residual_partition_sum >> (rice_parameter-1)) /* rice_parameter-1 because the real coder sign-folds instead of using a sign bit */
- : (unsigned)(abs_residual_partition_sum << 1) /* can't shift by negative number, so reverse */
- )
- - (partition_samples >> 1)
- /* -(partition_samples>>1) to subtract out extra contributions to the abs_residual_partition_sum.
- * The actual number of bits used is closer to the sum(for all i in the partition) of abs(residual[i])>>(rice_parameter-1)
- * By using the abs_residual_partition sum, we also add in bits in the LSBs that would normally be shifted out.
- * So the subtraction term tries to guess how many extra bits were contributed.
- * If the LSBs are randomly distributed, this should average to 0.5 extra bits per sample.
- */
- ;
-}
-#endif
-
-FLAC__bool set_partitioned_rice_(
-#ifdef EXACT_RICE_BITS_CALCULATION
- const FLAC__int32 residual[],
-#endif
- const FLAC__uint64 abs_residual_partition_sums[],
- const unsigned raw_bits_per_partition[],
- const unsigned residual_samples,
- const unsigned predictor_order,
- const unsigned suggested_rice_parameter,
- const unsigned rice_parameter_limit,
- const unsigned rice_parameter_search_dist,
- const unsigned partition_order,
- const FLAC__bool search_for_escapes,
- FLAC__EntropyCodingMethod_PartitionedRiceContents *partitioned_rice_contents,
- unsigned *bits
-)
-{
- unsigned rice_parameter, partition_bits;
- unsigned best_partition_bits, best_rice_parameter = 0;
- unsigned bits_ = FLAC__ENTROPY_CODING_METHOD_TYPE_LEN + FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN;
- unsigned *parameters, *raw_bits;
-#ifdef ENABLE_RICE_PARAMETER_SEARCH
- unsigned min_rice_parameter, max_rice_parameter;
-#else
- (void)rice_parameter_search_dist;
-#endif
-
- FLAC__ASSERT(suggested_rice_parameter < FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER);
- FLAC__ASSERT(rice_parameter_limit <= FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER);
-
- FLAC__format_entropy_coding_method_partitioned_rice_contents_ensure_size(partitioned_rice_contents, max(6, partition_order));
- parameters = partitioned_rice_contents->parameters;
- raw_bits = partitioned_rice_contents->raw_bits;
-
- if(partition_order == 0) {
- best_partition_bits = (unsigned)(-1);
-#ifdef ENABLE_RICE_PARAMETER_SEARCH
- if(rice_parameter_search_dist) {
- if(suggested_rice_parameter < rice_parameter_search_dist)
- min_rice_parameter = 0;
- else
- min_rice_parameter = suggested_rice_parameter - rice_parameter_search_dist;
- max_rice_parameter = suggested_rice_parameter + rice_parameter_search_dist;
- if(max_rice_parameter >= rice_parameter_limit) {
-#ifdef DEBUG_VERBOSE
- fprintf(stderr, "clipping rice_parameter (%u -> %u) @5\n", max_rice_parameter, rice_parameter_limit - 1);
-#endif
- max_rice_parameter = rice_parameter_limit - 1;
- }
- }
- else
- min_rice_parameter = max_rice_parameter = suggested_rice_parameter;
-
- for(rice_parameter = min_rice_parameter; rice_parameter <= max_rice_parameter; rice_parameter++) {
-#else
- rice_parameter = suggested_rice_parameter;
-#endif
-#ifdef EXACT_RICE_BITS_CALCULATION
- partition_bits = count_rice_bits_in_partition_(rice_parameter, residual_samples, residual);
-#else
- partition_bits = count_rice_bits_in_partition_(rice_parameter, residual_samples, abs_residual_partition_sums[0]);
-#endif
- if(partition_bits < best_partition_bits) {
- best_rice_parameter = rice_parameter;
- best_partition_bits = partition_bits;
- }
-#ifdef ENABLE_RICE_PARAMETER_SEARCH
- }
-#endif
- if(search_for_escapes) {
- partition_bits = FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN + FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN + raw_bits_per_partition[0] * residual_samples;
- if(partition_bits <= best_partition_bits) {
- raw_bits[0] = raw_bits_per_partition[0];
- best_rice_parameter = 0; /* will be converted to appropriate escape parameter later */
- best_partition_bits = partition_bits;
- }
- else
- raw_bits[0] = 0;
- }
- parameters[0] = best_rice_parameter;
- bits_ += best_partition_bits;
- }
- else {
- unsigned partition, residual_sample;
- unsigned partition_samples;
- FLAC__uint64 mean, k;
- const unsigned partitions = 1u << partition_order;
- for(partition = residual_sample = 0; partition < partitions; partition++) {
- partition_samples = (residual_samples+predictor_order) >> partition_order;
- if(partition == 0) {
- if(partition_samples <= predictor_order)
- return false;
- else
- partition_samples -= predictor_order;
- }
- mean = abs_residual_partition_sums[partition];
- /* we are basically calculating the size in bits of the
- * average residual magnitude in the partition:
- * rice_parameter = floor(log2(mean/partition_samples))
- * 'mean' is not a good name for the variable, it is
- * actually the sum of magnitudes of all residual values
- * in the partition, so the actual mean is
- * mean/partition_samples
- */
- for(rice_parameter = 0, k = partition_samples; k < mean; rice_parameter++, k <<= 1)
- ;
- if(rice_parameter >= rice_parameter_limit) {
-#ifdef DEBUG_VERBOSE
- fprintf(stderr, "clipping rice_parameter (%u -> %u) @6\n", rice_parameter, rice_parameter_limit - 1);
-#endif
- rice_parameter = rice_parameter_limit - 1;
- }
-
- best_partition_bits = (unsigned)(-1);
-#ifdef ENABLE_RICE_PARAMETER_SEARCH
- if(rice_parameter_search_dist) {
- if(rice_parameter < rice_parameter_search_dist)
- min_rice_parameter = 0;
- else
- min_rice_parameter = rice_parameter - rice_parameter_search_dist;
- max_rice_parameter = rice_parameter + rice_parameter_search_dist;
- if(max_rice_parameter >= rice_parameter_limit) {
-#ifdef DEBUG_VERBOSE
- fprintf(stderr, "clipping rice_parameter (%u -> %u) @7\n", max_rice_parameter, rice_parameter_limit - 1);
-#endif
- max_rice_parameter = rice_parameter_limit - 1;
- }
- }
- else
- min_rice_parameter = max_rice_parameter = rice_parameter;
-
- for(rice_parameter = min_rice_parameter; rice_parameter <= max_rice_parameter; rice_parameter++) {
-#endif
-#ifdef EXACT_RICE_BITS_CALCULATION
- partition_bits = count_rice_bits_in_partition_(rice_parameter, partition_samples, residual+residual_sample);
-#else
- partition_bits = count_rice_bits_in_partition_(rice_parameter, partition_samples, abs_residual_partition_sums[partition]);
-#endif
- if(partition_bits < best_partition_bits) {
- best_rice_parameter = rice_parameter;
- best_partition_bits = partition_bits;
- }
-#ifdef ENABLE_RICE_PARAMETER_SEARCH
- }
-#endif
- if(search_for_escapes) {
- partition_bits = FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN + FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN + raw_bits_per_partition[partition] * partition_samples;
- if(partition_bits <= best_partition_bits) {
- raw_bits[partition] = raw_bits_per_partition[partition];
- best_rice_parameter = 0; /* will be converted to appropriate escape parameter later */
- best_partition_bits = partition_bits;
- }
- else
- raw_bits[partition] = 0;
- }
- parameters[partition] = best_rice_parameter;
- bits_ += best_partition_bits;
- residual_sample += partition_samples;
- }
- }
-
- *bits = bits_;
- return true;
-}
-
-unsigned get_wasted_bits_(FLAC__int32 signal[], unsigned samples)
-{
- unsigned i, shift;
- FLAC__int32 x = 0;
-
- for(i = 0; i < samples && !(x&1); i++)
- x |= signal[i];
-
- if(x == 0) {
- shift = 0;
- }
- else {
- for(shift = 0; !(x&1); shift++)
- x >>= 1;
- }
-
- if(shift > 0) {
- for(i = 0; i < samples; i++)
- signal[i] >>= shift;
- }
-
- return shift;
-}
-
-void append_to_verify_fifo_(verify_input_fifo *fifo, const FLAC__int32 * const input[], unsigned input_offset, unsigned channels, unsigned wide_samples)
-{
- unsigned channel;
-
- for(channel = 0; channel < channels; channel++)
- memcpy(&fifo->data[channel][fifo->tail], &input[channel][input_offset], sizeof(FLAC__int32) * wide_samples);
-
- fifo->tail += wide_samples;
-
- FLAC__ASSERT(fifo->tail <= fifo->size);
-}
-
-void append_to_verify_fifo_interleaved_(verify_input_fifo *fifo, const FLAC__int32 input[], unsigned input_offset, unsigned channels, unsigned wide_samples)
-{
- unsigned channel;
- unsigned sample, wide_sample;
- unsigned tail = fifo->tail;
-
- sample = input_offset * channels;
- for(wide_sample = 0; wide_sample < wide_samples; wide_sample++) {
- for(channel = 0; channel < channels; channel++)
- fifo->data[channel][tail] = input[sample++];
- tail++;
- }
- fifo->tail = tail;
-
- FLAC__ASSERT(fifo->tail <= fifo->size);
-}
-
-FLAC__StreamDecoderReadStatus verify_read_callback_(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
-{
- FLAC__StreamEncoder *encoder = (FLAC__StreamEncoder*)client_data;
- const size_t encoded_bytes = encoder->private_->verify.output.bytes;
- (void)decoder;
-
- if(encoder->private_->verify.needs_magic_hack) {
- FLAC__ASSERT(*bytes >= FLAC__STREAM_SYNC_LENGTH);
- *bytes = FLAC__STREAM_SYNC_LENGTH;
- memcpy(buffer, FLAC__STREAM_SYNC_STRING, *bytes);
- encoder->private_->verify.needs_magic_hack = false;
- }
- else {
- if(encoded_bytes == 0) {
- /*
- * If we get here, a FIFO underflow has occurred,
- * which means there is a bug somewhere.
- */
- FLAC__ASSERT(0);
- return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
- }
- else if(encoded_bytes < *bytes)
- *bytes = encoded_bytes;
- memcpy(buffer, encoder->private_->verify.output.data, *bytes);
- encoder->private_->verify.output.data += *bytes;
- encoder->private_->verify.output.bytes -= *bytes;
- }
-
- return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
-}
-
-FLAC__StreamDecoderWriteStatus verify_write_callback_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data)
-{
- FLAC__StreamEncoder *encoder = (FLAC__StreamEncoder *)client_data;
- unsigned channel;
- const unsigned channels = frame->header.channels;
- const unsigned blocksize = frame->header.blocksize;
- const unsigned bytes_per_block = sizeof(FLAC__int32) * blocksize;
-
- (void)decoder;
-
- for(channel = 0; channel < channels; channel++) {
- if(0 != memcmp(buffer[channel], encoder->private_->verify.input_fifo.data[channel], bytes_per_block)) {
- unsigned i, sample = 0;
- FLAC__int32 expect = 0, got = 0;
-
- for(i = 0; i < blocksize; i++) {
- if(buffer[channel][i] != encoder->private_->verify.input_fifo.data[channel][i]) {
- sample = i;
- expect = (FLAC__int32)encoder->private_->verify.input_fifo.data[channel][i];
- got = (FLAC__int32)buffer[channel][i];
- break;
- }
- }
- FLAC__ASSERT(i < blocksize);
- FLAC__ASSERT(frame->header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER);
- encoder->private_->verify.error_stats.absolute_sample = frame->header.number.sample_number + sample;
- encoder->private_->verify.error_stats.frame_number = (unsigned)(frame->header.number.sample_number / blocksize);
- encoder->private_->verify.error_stats.channel = channel;
- encoder->private_->verify.error_stats.sample = sample;
- encoder->private_->verify.error_stats.expected = expect;
- encoder->private_->verify.error_stats.got = got;
- encoder->protected_->state = FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA;
- return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
- }
- }
- /* dequeue the frame from the fifo */
- encoder->private_->verify.input_fifo.tail -= blocksize;
- FLAC__ASSERT(encoder->private_->verify.input_fifo.tail <= OVERREAD_);
- for(channel = 0; channel < channels; channel++)
- memmove(&encoder->private_->verify.input_fifo.data[channel][0], &encoder->private_->verify.input_fifo.data[channel][blocksize], encoder->private_->verify.input_fifo.tail * sizeof(encoder->private_->verify.input_fifo.data[0][0]));
- return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
-}
-
-void verify_metadata_callback_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data)
-{
- (void)decoder, (void)metadata, (void)client_data;
-}
-
-void verify_error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)
-{
- FLAC__StreamEncoder *encoder = (FLAC__StreamEncoder*)client_data;
- (void)decoder, (void)status;
- encoder->protected_->state = FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR;
-}
-
-FLAC__StreamEncoderReadStatus file_read_callback_(const FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
-{
- (void)client_data;
-
- *bytes = fread(buffer, 1, *bytes, encoder->private_->file);
- if (*bytes == 0) {
- if (feof(encoder->private_->file))
- return FLAC__STREAM_ENCODER_READ_STATUS_END_OF_STREAM;
- else if (ferror(encoder->private_->file))
- return FLAC__STREAM_ENCODER_READ_STATUS_ABORT;
- }
- return FLAC__STREAM_ENCODER_READ_STATUS_CONTINUE;
-}
-
-FLAC__StreamEncoderSeekStatus file_seek_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data)
-{
- (void)client_data;
-
- if(fseeko(encoder->private_->file, (off_t)absolute_byte_offset, SEEK_SET) < 0)
- return FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR;
- else
- return FLAC__STREAM_ENCODER_SEEK_STATUS_OK;
-}
-
-FLAC__StreamEncoderTellStatus file_tell_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data)
-{
- off_t offset;
-
- (void)client_data;
-
- offset = ftello(encoder->private_->file);
-
- if(offset < 0) {
- return FLAC__STREAM_ENCODER_TELL_STATUS_ERROR;
- }
- else {
- *absolute_byte_offset = (FLAC__uint64)offset;
- return FLAC__STREAM_ENCODER_TELL_STATUS_OK;
- }
-}
-
-#ifdef FLAC__VALGRIND_TESTING
-static size_t local__fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
-{
- size_t ret = fwrite(ptr, size, nmemb, stream);
- if(!ferror(stream))
- fflush(stream);
- return ret;
-}
-#else
-#define local__fwrite fwrite
-#endif
-
-FLAC__StreamEncoderWriteStatus file_write_callback_(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, void *client_data)
-{
- (void)client_data, (void)current_frame;
-
- if(local__fwrite(buffer, sizeof(FLAC__byte), bytes, encoder->private_->file) == bytes) {
- FLAC__bool call_it = 0 != encoder->private_->progress_callback && (
-#if FLAC__HAS_OGG
- /* We would like to be able to use 'samples > 0' in the
- * clause here but currently because of the nature of our
- * Ogg writing implementation, 'samples' is always 0 (see
- * ogg_encoder_aspect.c). The downside is extra progress
- * callbacks.
- */
- encoder->private_->is_ogg? true :
-#endif
- samples > 0
- );
- if(call_it) {
- /* NOTE: We have to add +bytes, +samples, and +1 to the stats
- * because at this point in the callback chain, the stats
- * have not been updated. Only after we return and control
- * gets back to write_frame_() are the stats updated
- */
- encoder->private_->progress_callback(encoder, encoder->private_->bytes_written+bytes, encoder->private_->samples_written+samples, encoder->private_->frames_written+(samples?1:0), encoder->private_->total_frames_estimate, encoder->private_->client_data);
- }
- return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
- }
- else
- return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
-}
-
-/*
- * This will forcibly set stdout to binary mode (for OSes that require it)
- */
-FILE *get_binary_stdout_(void)
-{
- /* if something breaks here it is probably due to the presence or
- * absence of an underscore before the identifiers 'setmode',
- * 'fileno', and/or 'O_BINARY'; check your system header files.
- */
-#if defined _MSC_VER || defined __MINGW32__
- _setmode(_fileno(stdout), _O_BINARY);
-#elif defined __CYGWIN__
- /* almost certainly not needed for any modern Cygwin, but let's be safe... */
- setmode(_fileno(stdout), _O_BINARY);
-#elif defined __EMX__
- setmode(fileno(stdout), O_BINARY);
-#endif
-
- return stdout;
-}
diff --git a/src/thirdparty/libflac/src/libFLAC/stream_encoder_framing.c b/src/thirdparty/libflac/src/libFLAC/stream_encoder_framing.c
deleted file mode 100644
index 35fe9ba9d..000000000
--- a/src/thirdparty/libflac/src/libFLAC/stream_encoder_framing.c
+++ /dev/null
@@ -1,553 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdio.h>
-#include <string.h> /* for strlen() */
-#include "private/stream_encoder_framing.h"
-#include "private/crc.h"
-#include "FLAC/assert.h"
-
-#ifdef max
-#undef max
-#endif
-#define max(x,y) ((x)>(y)?(x):(y))
-
-static FLAC__bool add_entropy_coding_method_(FLAC__BitWriter *bw, const FLAC__EntropyCodingMethod *method);
-static FLAC__bool add_residual_partitioned_rice_(FLAC__BitWriter *bw, const FLAC__int32 residual[], const unsigned residual_samples, const unsigned predictor_order, const unsigned rice_parameters[], const unsigned raw_bits[], const unsigned partition_order, const FLAC__bool is_extended);
-
-FLAC__bool FLAC__add_metadata_block(const FLAC__StreamMetadata *metadata, FLAC__BitWriter *bw)
-{
- unsigned i, j;
- const unsigned vendor_string_length = (unsigned)strlen(FLAC__VENDOR_STRING);
-
- if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->is_last, FLAC__STREAM_METADATA_IS_LAST_LEN))
- return false;
-
- if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->type, FLAC__STREAM_METADATA_TYPE_LEN))
- return false;
-
- /*
- * First, for VORBIS_COMMENTs, adjust the length to reflect our vendor string
- */
- i = metadata->length;
- if(metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) {
- FLAC__ASSERT(metadata->data.vorbis_comment.vendor_string.length == 0 || 0 != metadata->data.vorbis_comment.vendor_string.entry);
- i -= metadata->data.vorbis_comment.vendor_string.length;
- i += vendor_string_length;
- }
- FLAC__ASSERT(i < (1u << FLAC__STREAM_METADATA_LENGTH_LEN));
- if(!FLAC__bitwriter_write_raw_uint32(bw, i, FLAC__STREAM_METADATA_LENGTH_LEN))
- return false;
-
- switch(metadata->type) {
- case FLAC__METADATA_TYPE_STREAMINFO:
- FLAC__ASSERT(metadata->data.stream_info.min_blocksize < (1u << FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN));
- if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.stream_info.min_blocksize, FLAC__STREAM_METADATA_STREAMINFO_MIN_BLOCK_SIZE_LEN))
- return false;
- FLAC__ASSERT(metadata->data.stream_info.max_blocksize < (1u << FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN));
- if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.stream_info.max_blocksize, FLAC__STREAM_METADATA_STREAMINFO_MAX_BLOCK_SIZE_LEN))
- return false;
- FLAC__ASSERT(metadata->data.stream_info.min_framesize < (1u << FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN));
- if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.stream_info.min_framesize, FLAC__STREAM_METADATA_STREAMINFO_MIN_FRAME_SIZE_LEN))
- return false;
- FLAC__ASSERT(metadata->data.stream_info.max_framesize < (1u << FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN));
- if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.stream_info.max_framesize, FLAC__STREAM_METADATA_STREAMINFO_MAX_FRAME_SIZE_LEN))
- return false;
- FLAC__ASSERT(FLAC__format_sample_rate_is_valid(metadata->data.stream_info.sample_rate));
- if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.stream_info.sample_rate, FLAC__STREAM_METADATA_STREAMINFO_SAMPLE_RATE_LEN))
- return false;
- FLAC__ASSERT(metadata->data.stream_info.channels > 0);
- FLAC__ASSERT(metadata->data.stream_info.channels <= (1u << FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN));
- if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.stream_info.channels-1, FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN))
- return false;
- FLAC__ASSERT(metadata->data.stream_info.bits_per_sample > 0);
- FLAC__ASSERT(metadata->data.stream_info.bits_per_sample <= (1u << FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN));
- if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.stream_info.bits_per_sample-1, FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN))
- return false;
- if(!FLAC__bitwriter_write_raw_uint64(bw, metadata->data.stream_info.total_samples, FLAC__STREAM_METADATA_STREAMINFO_TOTAL_SAMPLES_LEN))
- return false;
- if(!FLAC__bitwriter_write_byte_block(bw, metadata->data.stream_info.md5sum, 16))
- return false;
- break;
- case FLAC__METADATA_TYPE_PADDING:
- if(!FLAC__bitwriter_write_zeroes(bw, metadata->length * 8))
- return false;
- break;
- case FLAC__METADATA_TYPE_APPLICATION:
- if(!FLAC__bitwriter_write_byte_block(bw, metadata->data.application.id, FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8))
- return false;
- if(!FLAC__bitwriter_write_byte_block(bw, metadata->data.application.data, metadata->length - (FLAC__STREAM_METADATA_APPLICATION_ID_LEN / 8)))
- return false;
- break;
- case FLAC__METADATA_TYPE_SEEKTABLE:
- for(i = 0; i < metadata->data.seek_table.num_points; i++) {
- if(!FLAC__bitwriter_write_raw_uint64(bw, metadata->data.seek_table.points[i].sample_number, FLAC__STREAM_METADATA_SEEKPOINT_SAMPLE_NUMBER_LEN))
- return false;
- if(!FLAC__bitwriter_write_raw_uint64(bw, metadata->data.seek_table.points[i].stream_offset, FLAC__STREAM_METADATA_SEEKPOINT_STREAM_OFFSET_LEN))
- return false;
- if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.seek_table.points[i].frame_samples, FLAC__STREAM_METADATA_SEEKPOINT_FRAME_SAMPLES_LEN))
- return false;
- }
- break;
- case FLAC__METADATA_TYPE_VORBIS_COMMENT:
- if(!FLAC__bitwriter_write_raw_uint32_little_endian(bw, vendor_string_length))
- return false;
- if(!FLAC__bitwriter_write_byte_block(bw, (const FLAC__byte*)FLAC__VENDOR_STRING, vendor_string_length))
- return false;
- if(!FLAC__bitwriter_write_raw_uint32_little_endian(bw, metadata->data.vorbis_comment.num_comments))
- return false;
- for(i = 0; i < metadata->data.vorbis_comment.num_comments; i++) {
- if(!FLAC__bitwriter_write_raw_uint32_little_endian(bw, metadata->data.vorbis_comment.comments[i].length))
- return false;
- if(!FLAC__bitwriter_write_byte_block(bw, metadata->data.vorbis_comment.comments[i].entry, metadata->data.vorbis_comment.comments[i].length))
- return false;
- }
- break;
- case FLAC__METADATA_TYPE_CUESHEET:
- FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN % 8 == 0);
- if(!FLAC__bitwriter_write_byte_block(bw, (const FLAC__byte*)metadata->data.cue_sheet.media_catalog_number, FLAC__STREAM_METADATA_CUESHEET_MEDIA_CATALOG_NUMBER_LEN/8))
- return false;
- if(!FLAC__bitwriter_write_raw_uint64(bw, metadata->data.cue_sheet.lead_in, FLAC__STREAM_METADATA_CUESHEET_LEAD_IN_LEN))
- return false;
- if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.cue_sheet.is_cd? 1 : 0, FLAC__STREAM_METADATA_CUESHEET_IS_CD_LEN))
- return false;
- if(!FLAC__bitwriter_write_zeroes(bw, FLAC__STREAM_METADATA_CUESHEET_RESERVED_LEN))
- return false;
- if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.cue_sheet.num_tracks, FLAC__STREAM_METADATA_CUESHEET_NUM_TRACKS_LEN))
- return false;
- for(i = 0; i < metadata->data.cue_sheet.num_tracks; i++) {
- const FLAC__StreamMetadata_CueSheet_Track *track = metadata->data.cue_sheet.tracks + i;
-
- if(!FLAC__bitwriter_write_raw_uint64(bw, track->offset, FLAC__STREAM_METADATA_CUESHEET_TRACK_OFFSET_LEN))
- return false;
- if(!FLAC__bitwriter_write_raw_uint32(bw, track->number, FLAC__STREAM_METADATA_CUESHEET_TRACK_NUMBER_LEN))
- return false;
- FLAC__ASSERT(FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN % 8 == 0);
- if(!FLAC__bitwriter_write_byte_block(bw, (const FLAC__byte*)track->isrc, FLAC__STREAM_METADATA_CUESHEET_TRACK_ISRC_LEN/8))
- return false;
- if(!FLAC__bitwriter_write_raw_uint32(bw, track->type, FLAC__STREAM_METADATA_CUESHEET_TRACK_TYPE_LEN))
- return false;
- if(!FLAC__bitwriter_write_raw_uint32(bw, track->pre_emphasis, FLAC__STREAM_METADATA_CUESHEET_TRACK_PRE_EMPHASIS_LEN))
- return false;
- if(!FLAC__bitwriter_write_zeroes(bw, FLAC__STREAM_METADATA_CUESHEET_TRACK_RESERVED_LEN))
- return false;
- if(!FLAC__bitwriter_write_raw_uint32(bw, track->num_indices, FLAC__STREAM_METADATA_CUESHEET_TRACK_NUM_INDICES_LEN))
- return false;
- for(j = 0; j < track->num_indices; j++) {
- const FLAC__StreamMetadata_CueSheet_Index *index = track->indices + j;
-
- if(!FLAC__bitwriter_write_raw_uint64(bw, index->offset, FLAC__STREAM_METADATA_CUESHEET_INDEX_OFFSET_LEN))
- return false;
- if(!FLAC__bitwriter_write_raw_uint32(bw, index->number, FLAC__STREAM_METADATA_CUESHEET_INDEX_NUMBER_LEN))
- return false;
- if(!FLAC__bitwriter_write_zeroes(bw, FLAC__STREAM_METADATA_CUESHEET_INDEX_RESERVED_LEN))
- return false;
- }
- }
- break;
- case FLAC__METADATA_TYPE_PICTURE:
- {
- size_t len;
- if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.picture.type, FLAC__STREAM_METADATA_PICTURE_TYPE_LEN))
- return false;
- len = strlen(metadata->data.picture.mime_type);
- if(!FLAC__bitwriter_write_raw_uint32(bw, len, FLAC__STREAM_METADATA_PICTURE_MIME_TYPE_LENGTH_LEN))
- return false;
- if(!FLAC__bitwriter_write_byte_block(bw, (const FLAC__byte*)metadata->data.picture.mime_type, len))
- return false;
- len = strlen((const char *)metadata->data.picture.description);
- if(!FLAC__bitwriter_write_raw_uint32(bw, len, FLAC__STREAM_METADATA_PICTURE_DESCRIPTION_LENGTH_LEN))
- return false;
- if(!FLAC__bitwriter_write_byte_block(bw, metadata->data.picture.description, len))
- return false;
- if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.picture.width, FLAC__STREAM_METADATA_PICTURE_WIDTH_LEN))
- return false;
- if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.picture.height, FLAC__STREAM_METADATA_PICTURE_HEIGHT_LEN))
- return false;
- if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.picture.depth, FLAC__STREAM_METADATA_PICTURE_DEPTH_LEN))
- return false;
- if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.picture.colors, FLAC__STREAM_METADATA_PICTURE_COLORS_LEN))
- return false;
- if(!FLAC__bitwriter_write_raw_uint32(bw, metadata->data.picture.data_length, FLAC__STREAM_METADATA_PICTURE_DATA_LENGTH_LEN))
- return false;
- if(!FLAC__bitwriter_write_byte_block(bw, metadata->data.picture.data, metadata->data.picture.data_length))
- return false;
- }
- break;
- default:
- if(!FLAC__bitwriter_write_byte_block(bw, metadata->data.unknown.data, metadata->length))
- return false;
- break;
- }
-
- FLAC__ASSERT(FLAC__bitwriter_is_byte_aligned(bw));
- return true;
-}
-
-FLAC__bool FLAC__frame_add_header(const FLAC__FrameHeader *header, FLAC__BitWriter *bw)
-{
- unsigned u, blocksize_hint, sample_rate_hint;
- FLAC__byte crc;
-
- FLAC__ASSERT(FLAC__bitwriter_is_byte_aligned(bw));
-
- if(!FLAC__bitwriter_write_raw_uint32(bw, FLAC__FRAME_HEADER_SYNC, FLAC__FRAME_HEADER_SYNC_LEN))
- return false;
-
- if(!FLAC__bitwriter_write_raw_uint32(bw, 0, FLAC__FRAME_HEADER_RESERVED_LEN))
- return false;
-
- if(!FLAC__bitwriter_write_raw_uint32(bw, (header->number_type == FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER)? 0 : 1, FLAC__FRAME_HEADER_BLOCKING_STRATEGY_LEN))
- return false;
-
- FLAC__ASSERT(header->blocksize > 0 && header->blocksize <= FLAC__MAX_BLOCK_SIZE);
- /* when this assertion holds true, any legal blocksize can be expressed in the frame header */
- FLAC__ASSERT(FLAC__MAX_BLOCK_SIZE <= 65535u);
- blocksize_hint = 0;
- switch(header->blocksize) {
- case 192: u = 1; break;
- case 576: u = 2; break;
- case 1152: u = 3; break;
- case 2304: u = 4; break;
- case 4608: u = 5; break;
- case 256: u = 8; break;
- case 512: u = 9; break;
- case 1024: u = 10; break;
- case 2048: u = 11; break;
- case 4096: u = 12; break;
- case 8192: u = 13; break;
- case 16384: u = 14; break;
- case 32768: u = 15; break;
- default:
- if(header->blocksize <= 0x100)
- blocksize_hint = u = 6;
- else
- blocksize_hint = u = 7;
- break;
- }
- if(!FLAC__bitwriter_write_raw_uint32(bw, u, FLAC__FRAME_HEADER_BLOCK_SIZE_LEN))
- return false;
-
- FLAC__ASSERT(FLAC__format_sample_rate_is_valid(header->sample_rate));
- sample_rate_hint = 0;
- switch(header->sample_rate) {
- case 88200: u = 1; break;
- case 176400: u = 2; break;
- case 192000: u = 3; break;
- case 8000: u = 4; break;
- case 16000: u = 5; break;
- case 22050: u = 6; break;
- case 24000: u = 7; break;
- case 32000: u = 8; break;
- case 44100: u = 9; break;
- case 48000: u = 10; break;
- case 96000: u = 11; break;
- default:
- if(header->sample_rate <= 255000 && header->sample_rate % 1000 == 0)
- sample_rate_hint = u = 12;
- else if(header->sample_rate % 10 == 0)
- sample_rate_hint = u = 14;
- else if(header->sample_rate <= 0xffff)
- sample_rate_hint = u = 13;
- else
- u = 0;
- break;
- }
- if(!FLAC__bitwriter_write_raw_uint32(bw, u, FLAC__FRAME_HEADER_SAMPLE_RATE_LEN))
- return false;
-
- FLAC__ASSERT(header->channels > 0 && header->channels <= (1u << FLAC__STREAM_METADATA_STREAMINFO_CHANNELS_LEN) && header->channels <= FLAC__MAX_CHANNELS);
- switch(header->channel_assignment) {
- case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT:
- u = header->channels - 1;
- break;
- case FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE:
- FLAC__ASSERT(header->channels == 2);
- u = 8;
- break;
- case FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE:
- FLAC__ASSERT(header->channels == 2);
- u = 9;
- break;
- case FLAC__CHANNEL_ASSIGNMENT_MID_SIDE:
- FLAC__ASSERT(header->channels == 2);
- u = 10;
- break;
- default:
- FLAC__ASSERT(0);
- }
- if(!FLAC__bitwriter_write_raw_uint32(bw, u, FLAC__FRAME_HEADER_CHANNEL_ASSIGNMENT_LEN))
- return false;
-
- FLAC__ASSERT(header->bits_per_sample > 0 && header->bits_per_sample <= (1u << FLAC__STREAM_METADATA_STREAMINFO_BITS_PER_SAMPLE_LEN));
- switch(header->bits_per_sample) {
- case 8 : u = 1; break;
- case 12: u = 2; break;
- case 16: u = 4; break;
- case 20: u = 5; break;
- case 24: u = 6; break;
- default: u = 0; break;
- }
- if(!FLAC__bitwriter_write_raw_uint32(bw, u, FLAC__FRAME_HEADER_BITS_PER_SAMPLE_LEN))
- return false;
-
- if(!FLAC__bitwriter_write_raw_uint32(bw, 0, FLAC__FRAME_HEADER_ZERO_PAD_LEN))
- return false;
-
- if(header->number_type == FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER) {
- if(!FLAC__bitwriter_write_utf8_uint32(bw, header->number.frame_number))
- return false;
- }
- else {
- if(!FLAC__bitwriter_write_utf8_uint64(bw, header->number.sample_number))
- return false;
- }
-
- if(blocksize_hint)
- if(!FLAC__bitwriter_write_raw_uint32(bw, header->blocksize-1, (blocksize_hint==6)? 8:16))
- return false;
-
- switch(sample_rate_hint) {
- case 12:
- if(!FLAC__bitwriter_write_raw_uint32(bw, header->sample_rate / 1000, 8))
- return false;
- break;
- case 13:
- if(!FLAC__bitwriter_write_raw_uint32(bw, header->sample_rate, 16))
- return false;
- break;
- case 14:
- if(!FLAC__bitwriter_write_raw_uint32(bw, header->sample_rate / 10, 16))
- return false;
- break;
- }
-
- /* write the CRC */
- if(!FLAC__bitwriter_get_write_crc8(bw, &crc))
- return false;
- if(!FLAC__bitwriter_write_raw_uint32(bw, crc, FLAC__FRAME_HEADER_CRC_LEN))
- return false;
-
- return true;
-}
-
-FLAC__bool FLAC__subframe_add_constant(const FLAC__Subframe_Constant *subframe, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitWriter *bw)
-{
- FLAC__bool ok;
-
- ok =
- FLAC__bitwriter_write_raw_uint32(bw, FLAC__SUBFRAME_TYPE_CONSTANT_BYTE_ALIGNED_MASK | (wasted_bits? 1:0), FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN) &&
- (wasted_bits? FLAC__bitwriter_write_unary_unsigned(bw, wasted_bits-1) : true) &&
- FLAC__bitwriter_write_raw_int32(bw, subframe->value, subframe_bps)
- ;
-
- return ok;
-}
-
-FLAC__bool FLAC__subframe_add_fixed(const FLAC__Subframe_Fixed *subframe, unsigned residual_samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitWriter *bw)
-{
- unsigned i;
-
- if(!FLAC__bitwriter_write_raw_uint32(bw, FLAC__SUBFRAME_TYPE_FIXED_BYTE_ALIGNED_MASK | (subframe->order<<1) | (wasted_bits? 1:0), FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN))
- return false;
- if(wasted_bits)
- if(!FLAC__bitwriter_write_unary_unsigned(bw, wasted_bits-1))
- return false;
-
- for(i = 0; i < subframe->order; i++)
- if(!FLAC__bitwriter_write_raw_int32(bw, subframe->warmup[i], subframe_bps))
- return false;
-
- if(!add_entropy_coding_method_(bw, &subframe->entropy_coding_method))
- return false;
- switch(subframe->entropy_coding_method.type) {
- case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE:
- case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2:
- if(!add_residual_partitioned_rice_(
- bw,
- subframe->residual,
- residual_samples,
- subframe->order,
- subframe->entropy_coding_method.data.partitioned_rice.contents->parameters,
- subframe->entropy_coding_method.data.partitioned_rice.contents->raw_bits,
- subframe->entropy_coding_method.data.partitioned_rice.order,
- /*is_extended=*/subframe->entropy_coding_method.type == FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2
- ))
- return false;
- break;
- default:
- FLAC__ASSERT(0);
- }
-
- return true;
-}
-
-FLAC__bool FLAC__subframe_add_lpc(const FLAC__Subframe_LPC *subframe, unsigned residual_samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitWriter *bw)
-{
- unsigned i;
-
- if(!FLAC__bitwriter_write_raw_uint32(bw, FLAC__SUBFRAME_TYPE_LPC_BYTE_ALIGNED_MASK | ((subframe->order-1)<<1) | (wasted_bits? 1:0), FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN))
- return false;
- if(wasted_bits)
- if(!FLAC__bitwriter_write_unary_unsigned(bw, wasted_bits-1))
- return false;
-
- for(i = 0; i < subframe->order; i++)
- if(!FLAC__bitwriter_write_raw_int32(bw, subframe->warmup[i], subframe_bps))
- return false;
-
- if(!FLAC__bitwriter_write_raw_uint32(bw, subframe->qlp_coeff_precision-1, FLAC__SUBFRAME_LPC_QLP_COEFF_PRECISION_LEN))
- return false;
- if(!FLAC__bitwriter_write_raw_int32(bw, subframe->quantization_level, FLAC__SUBFRAME_LPC_QLP_SHIFT_LEN))
- return false;
- for(i = 0; i < subframe->order; i++)
- if(!FLAC__bitwriter_write_raw_int32(bw, subframe->qlp_coeff[i], subframe->qlp_coeff_precision))
- return false;
-
- if(!add_entropy_coding_method_(bw, &subframe->entropy_coding_method))
- return false;
- switch(subframe->entropy_coding_method.type) {
- case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE:
- case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2:
- if(!add_residual_partitioned_rice_(
- bw,
- subframe->residual,
- residual_samples,
- subframe->order,
- subframe->entropy_coding_method.data.partitioned_rice.contents->parameters,
- subframe->entropy_coding_method.data.partitioned_rice.contents->raw_bits,
- subframe->entropy_coding_method.data.partitioned_rice.order,
- /*is_extended=*/subframe->entropy_coding_method.type == FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2
- ))
- return false;
- break;
- default:
- FLAC__ASSERT(0);
- }
-
- return true;
-}
-
-FLAC__bool FLAC__subframe_add_verbatim(const FLAC__Subframe_Verbatim *subframe, unsigned samples, unsigned subframe_bps, unsigned wasted_bits, FLAC__BitWriter *bw)
-{
- unsigned i;
- const FLAC__int32 *signal = subframe->data;
-
- if(!FLAC__bitwriter_write_raw_uint32(bw, FLAC__SUBFRAME_TYPE_VERBATIM_BYTE_ALIGNED_MASK | (wasted_bits? 1:0), FLAC__SUBFRAME_ZERO_PAD_LEN + FLAC__SUBFRAME_TYPE_LEN + FLAC__SUBFRAME_WASTED_BITS_FLAG_LEN))
- return false;
- if(wasted_bits)
- if(!FLAC__bitwriter_write_unary_unsigned(bw, wasted_bits-1))
- return false;
-
- for(i = 0; i < samples; i++)
- if(!FLAC__bitwriter_write_raw_int32(bw, signal[i], subframe_bps))
- return false;
-
- return true;
-}
-
-FLAC__bool add_entropy_coding_method_(FLAC__BitWriter *bw, const FLAC__EntropyCodingMethod *method)
-{
- if(!FLAC__bitwriter_write_raw_uint32(bw, method->type, FLAC__ENTROPY_CODING_METHOD_TYPE_LEN))
- return false;
- switch(method->type) {
- case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE:
- case FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2:
- if(!FLAC__bitwriter_write_raw_uint32(bw, method->data.partitioned_rice.order, FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ORDER_LEN))
- return false;
- break;
- default:
- FLAC__ASSERT(0);
- }
- return true;
-}
-
-FLAC__bool add_residual_partitioned_rice_(FLAC__BitWriter *bw, const FLAC__int32 residual[], const unsigned residual_samples, const unsigned predictor_order, const unsigned rice_parameters[], const unsigned raw_bits[], const unsigned partition_order, const FLAC__bool is_extended)
-{
- const unsigned plen = is_extended? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_PARAMETER_LEN : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_PARAMETER_LEN;
- const unsigned pesc = is_extended? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER;
-
- if(partition_order == 0) {
- unsigned i;
-
- if(raw_bits[0] == 0) {
- if(!FLAC__bitwriter_write_raw_uint32(bw, rice_parameters[0], plen))
- return false;
- if(!FLAC__bitwriter_write_rice_signed_block(bw, residual, residual_samples, rice_parameters[0]))
- return false;
- }
- else {
- FLAC__ASSERT(rice_parameters[0] == 0);
- if(!FLAC__bitwriter_write_raw_uint32(bw, pesc, plen))
- return false;
- if(!FLAC__bitwriter_write_raw_uint32(bw, raw_bits[0], FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN))
- return false;
- for(i = 0; i < residual_samples; i++) {
- if(!FLAC__bitwriter_write_raw_int32(bw, residual[i], raw_bits[0]))
- return false;
- }
- }
- return true;
- }
- else {
- unsigned i, j, k = 0, k_last = 0;
- unsigned partition_samples;
- const unsigned default_partition_samples = (residual_samples+predictor_order) >> partition_order;
- for(i = 0; i < (1u<<partition_order); i++) {
- partition_samples = default_partition_samples;
- if(i == 0)
- partition_samples -= predictor_order;
- k += partition_samples;
- if(raw_bits[i] == 0) {
- if(!FLAC__bitwriter_write_raw_uint32(bw, rice_parameters[i], plen))
- return false;
- if(!FLAC__bitwriter_write_rice_signed_block(bw, residual+k_last, k-k_last, rice_parameters[i]))
- return false;
- }
- else {
- if(!FLAC__bitwriter_write_raw_uint32(bw, pesc, plen))
- return false;
- if(!FLAC__bitwriter_write_raw_uint32(bw, raw_bits[i], FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_RAW_LEN))
- return false;
- for(j = k_last; j < k; j++) {
- if(!FLAC__bitwriter_write_raw_int32(bw, residual[j], raw_bits[i]))
- return false;
- }
- }
- k_last = k;
- }
- return true;
- }
-}
diff --git a/src/thirdparty/libflac/src/libFLAC/window.c b/src/thirdparty/libflac/src/libFLAC/window.c
deleted file mode 100644
index 56d31c6d3..000000000
--- a/src/thirdparty/libflac/src/libFLAC/window.c
+++ /dev/null
@@ -1,225 +0,0 @@
-/* libFLAC - Free Lossless Audio Codec library
- * Copyright (C) 2006,2007,2008,2009 Josh Coalson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - 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.
- *
- * - Neither the name of the Xiph.org Foundation 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 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 FOUNDATION 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.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <math.h>
-#include "FLAC/assert.h"
-#include "FLAC/format.h"
-#include "private/window.h"
-
-#ifndef FLAC__INTEGER_ONLY_LIBRARY
-
-#ifndef M_PI
-/* math.h in VC++ doesn't seem to have this (how Microsoft is that?) */
-#define M_PI 3.14159265358979323846
-#endif
-
-
-void FLAC__window_bartlett(FLAC__real *window, const FLAC__int32 L)
-{
- const FLAC__int32 N = L - 1;
- FLAC__int32 n;
-
- if (L & 1) {
- for (n = 0; n <= N/2; n++)
- window[n] = 2.0f * n / (float)N;
- for (; n <= N; n++)
- window[n] = 2.0f - 2.0f * n / (float)N;
- }
- else {
- for (n = 0; n <= L/2-1; n++)
- window[n] = 2.0f * n / (float)N;
- for (; n <= N; n++)
- window[n] = 2.0f - 2.0f * (N-n) / (float)N;
- }
-}
-
-void FLAC__window_bartlett_hann(FLAC__real *window, const FLAC__int32 L)
-{
- const FLAC__int32 N = L - 1;
- FLAC__int32 n;
-
- for (n = 0; n < L; n++)
- window[n] = (FLAC__real)(0.62f - 0.48f * fabs((float)n/(float)N+0.5f) + 0.38f * cos(2.0f * M_PI * ((float)n/(float)N+0.5f)));
-}
-
-void FLAC__window_blackman(FLAC__real *window, const FLAC__int32 L)
-{
- const FLAC__int32 N = L - 1;
- FLAC__int32 n;
-
- for (n = 0; n < L; n++)
- window[n] = (FLAC__real)(0.42f - 0.5f * cos(2.0f * M_PI * n / N) + 0.08f * cos(4.0f * M_PI * n / N));
-}
-
-/* 4-term -92dB side-lobe */
-void FLAC__window_blackman_harris_4term_92db_sidelobe(FLAC__real *window, const FLAC__int32 L)
-{
- const FLAC__int32 N = L - 1;
- FLAC__int32 n;
-
- for (n = 0; n <= N; n++)
- window[n] = (FLAC__real)(0.35875f - 0.48829f * cos(2.0f * M_PI * n / N) + 0.14128f * cos(4.0f * M_PI * n / N) - 0.01168f * cos(6.0f * M_PI * n / N));
-}
-
-void FLAC__window_connes(FLAC__real *window, const FLAC__int32 L)
-{
- const FLAC__int32 N = L - 1;
- const double N2 = (double)N / 2.;
- FLAC__int32 n;
-
- for (n = 0; n <= N; n++) {
- double k = ((double)n - N2) / N2;
- k = 1.0f - k * k;
- window[n] = (FLAC__real)(k * k);
- }
-}
-
-void FLAC__window_flattop(FLAC__real *window, const FLAC__int32 L)
-{
- const FLAC__int32 N = L - 1;
- FLAC__int32 n;
-
- for (n = 0; n < L; n++)
- window[n] = (FLAC__real)(1.0f - 1.93f * cos(2.0f * M_PI * n / N) + 1.29f * cos(4.0f * M_PI * n / N) - 0.388f * cos(6.0f * M_PI * n / N) + 0.0322f * cos(8.0f * M_PI * n / N));
-}
-
-void FLAC__window_gauss(FLAC__real *window, const FLAC__int32 L, const FLAC__real stddev)
-{
- const FLAC__int32 N = L - 1;
- const double N2 = (double)N / 2.;
- FLAC__int32 n;
-
- for (n = 0; n <= N; n++) {
- const double k = ((double)n - N2) / (stddev * N2);
- window[n] = (FLAC__real)exp(-0.5f * k * k);
- }
-}
-
-void FLAC__window_hamming(FLAC__real *window, const FLAC__int32 L)
-{
- const FLAC__int32 N = L - 1;
- FLAC__int32 n;
-
- for (n = 0; n < L; n++)
- window[n] = (FLAC__real)(0.54f - 0.46f * cos(2.0f * M_PI * n / N));
-}
-
-void FLAC__window_hann(FLAC__real *window, const FLAC__int32 L)
-{
- const FLAC__int32 N = L - 1;
- FLAC__int32 n;
-
- for (n = 0; n < L; n++)
- window[n] = (FLAC__real)(0.5f - 0.5f * cos(2.0f * M_PI * n / N));
-}
-
-void FLAC__window_kaiser_bessel(FLAC__real *window, const FLAC__int32 L)
-{
- const FLAC__int32 N = L - 1;
- FLAC__int32 n;
-
- for (n = 0; n < L; n++)
- window[n] = (FLAC__real)(0.402f - 0.498f * cos(2.0f * M_PI * n / N) + 0.098f * cos(4.0f * M_PI * n / N) - 0.001f * cos(6.0f * M_PI * n / N));
-}
-
-void FLAC__window_nuttall(FLAC__real *window, const FLAC__int32 L)
-{
- const FLAC__int32 N = L - 1;
- FLAC__int32 n;
-
- for (n = 0; n < L; n++)
- window[n] = (FLAC__real)(0.3635819f - 0.4891775f*cos(2.0f*M_PI*n/N) + 0.1365995f*cos(4.0f*M_PI*n/N) - 0.0106411f*cos(6.0f*M_PI*n/N));
-}
-
-void FLAC__window_rectangle(FLAC__real *window, const FLAC__int32 L)
-{
- FLAC__int32 n;
-
- for (n = 0; n < L; n++)
- window[n] = 1.0f;
-}
-
-void FLAC__window_triangle(FLAC__real *window, const FLAC__int32 L)
-{
- FLAC__int32 n;
-
- if (L & 1) {
- for (n = 1; n <= L+1/2; n++)
- window[n-1] = 2.0f * n / ((float)L + 1.0f);
- for (; n <= L; n++)
- window[n-1] = - (float)(2 * (L - n + 1)) / ((float)L + 1.0f);
- }
- else {
- for (n = 1; n <= L/2; n++)
- window[n-1] = 2.0f * n / (float)L;
- for (; n <= L; n++)
- window[n-1] = ((float)(2 * (L - n)) + 1.0f) / (float)L;
- }
-}
-
-void FLAC__window_tukey(FLAC__real *window, const FLAC__int32 L, const FLAC__real p)
-{
- if (p <= 0.0)
- FLAC__window_rectangle(window, L);
- else if (p >= 1.0)
- FLAC__window_hann(window, L);
- else {
- const FLAC__int32 Np = (FLAC__int32)(p / 2.0f * L) - 1;
- FLAC__int32 n;
- /* start with rectangle... */
- FLAC__window_rectangle(window, L);
- /* ...replace ends with hann */
- if (Np > 0) {
- for (n = 0; n <= Np; n++) {
- window[n] = (FLAC__real)(0.5f - 0.5f * cos(M_PI * n / Np));
- window[L-Np-1+n] = (FLAC__real)(0.5f - 0.5f * cos(M_PI * (n+Np) / Np));
- }
- }
- }
-}
-
-void FLAC__window_welch(FLAC__real *window, const FLAC__int32 L)
-{
- const FLAC__int32 N = L - 1;
- const double N2 = (double)N / 2.;
- FLAC__int32 n;
-
- for (n = 0; n <= N; n++) {
- const double k = ((double)n - N2) / N2;
- window[n] = (FLAC__real)(1.0f - k * k);
- }
-}
-
-#endif /* !defined FLAC__INTEGER_ONLY_LIBRARY */